import{cc as x,cH as C,ct as j,ap as F,bh as P,cb as S}from"./index-8ca08701-1763717014417.js";function G(e){return x()?(C(e),!0):!1}function d(e){return typeof e=="function"?e():P(e)}const L=typeof window<"u"&&typeof document<"u";typeof WorkerGlobalScope<"u"&&globalThis instanceof WorkerGlobalScope;const m=()=>{};function y(e,r){function t(...n){return new Promise((o,i)=>{Promise.resolve(e(()=>r.apply(this,n),{fn:r,thisArg:this,args:n})).then(o).catch(i)})}return t}function g(e,r={}){let t,n,o=m;const i=u=>{clearTimeout(u),o(),o=m};return u=>{const a=d(e),l=d(r.maxWait);return t&&i(t),a<=0||l!==void 0&&l<=0?(n&&(i(n),n=null),Promise.resolve(u())):new Promise((s,T)=>{o=r.rejectOnCancel?T:s,l&&!n&&(n=setTimeout(()=>{t&&i(t),n=null,s(u())},l)),t=setTimeout(()=>{n&&i(n),n=null,s(u())},a)})}}function O(...e){let r=0,t,n=!0,o=m,i,c,u,a,l;!j(e[0])&&typeof e[0]=="object"?{delay:c,trailing:u=!0,leading:a=!0,rejectOnCancel:l=!1}=e[0]:[c,u=!0,a=!0,l=!1]=e;const s=()=>{t&&(clearTimeout(t),t=void 0,o(),o=m)};return b=>{const f=d(c),h=Date.now()-r,p=()=>i=b();return s(),f<=0?(r=Date.now(),p()):(h>f&&(a||!n)?(r=Date.now(),p()):u&&(i=new Promise((w,D)=>{o=l?D:w,t=setTimeout(()=>{r=Date.now(),n=!0,w(p()),s()},Math.max(0,f-h))})),!a&&!t&&(t=setTimeout(()=>n=!0,f)),n=!1,i)}}function W(e){return e||S()}function U(e,r=200,t={}){return y(g(r,t),e)}function V(e,r=200,t=!1,n=!0,o=!1){return y(O(r,t,n,o),e)}function k(e,r){W(r)&&F(e,r)}export{V as a,G as b,d as c,L as i,k as t,U as u};