index-bb52b8ab.js 1.2 KB

1
  1. import{aR as b,bi as y,aQ as F,$ as P,bQ as C}from"./index-44e5c545.js";function S(e){return b()?(y(e),!0):!1}function w(e){return typeof e=="function"?e():C(e)}const g=typeof window<"u",m=()=>{};function D(e,o){function n(...t){return new Promise((i,r)=>{Promise.resolve(e(()=>o.apply(this,t),{fn:o,thisArg:this,args:t})).then(i).catch(r)})}return n}function j(e,o={}){let n,t,i=m;const r=u=>{clearTimeout(u),i(),i=m};return u=>{const a=w(e),s=w(o.maxWait);return n&&r(n),a<=0||s!==void 0&&s<=0?(t&&(r(t),t=null),Promise.resolve(u())):new Promise((c,p)=>{i=o.rejectOnCancel?p:c,s&&!t&&(t=setTimeout(()=>{n&&r(n),t=null,c(u())},s)),n=setTimeout(()=>{t&&r(t),t=null,c(u())},a)})}}function O(e,o=!0,n=!0,t=!1){let i=0,r,l=!0,u=m,a;const s=()=>{r&&(clearTimeout(r),r=void 0,u(),u=m)};return p=>{const f=w(e),T=Date.now()-i,d=()=>a=p();return s(),f<=0?(i=Date.now(),d()):(T>f&&(n||!l)?(i=Date.now(),d()):o&&(a=new Promise((h,x)=>{u=t?x:h,r=setTimeout(()=>{i=Date.now(),l=!0,h(d()),s()},Math.max(0,f-T))})),!n&&!r&&(r=setTimeout(()=>l=!0,f)),l=!1,a)}}function Q(e,o=200,n={}){return D(j(o,n),e)}function U(e,o=200,n=!1,t=!0,i=!1){return D(O(o,n,t,i),e)}function V(e){F()&&P(e)}export{w as a,Q as b,V as c,g as i,S as t,U as u};