import{bV as j,cj as x,c5 as C,T as F,aZ as P,bU as S}from"./index-8fb4d12a-1720452812367.js";function U(e){return j()?(x(e),!0):!1}function d(e){return typeof e=="function"?e():P(e)}const V=typeof window<"u"&&typeof document<"u";typeof WorkerGlobalScope<"u"&&globalThis instanceof WorkerGlobalScope;const m=()=>{};function b(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;!C(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 h=>{const f=d(c),w=Date.now()-r,p=()=>i=h();return s(),f<=0?(r=Date.now(),p()):(w>f&&(a||!n)?(r=Date.now(),p()):u&&(i=new Promise((y,D)=>{o=l?D:y,t=setTimeout(()=>{r=Date.now(),n=!0,y(p()),s()},Math.max(0,f-w))})),!a&&!t&&(t=setTimeout(()=>n=!0,f)),n=!1,i)}}function W(e){return e||S()}function G(e,r=200,t={}){return b(g(r,t),e)}function L(e,r=200,t=!1,n=!0,o=!1){return b(O(r,t,n,o),e)}function k(e,r){W(r)&&F(e,r)}export{L as a,U as b,d as c,V as i,k as t,G as u};
