import{cx as S,b5 as R,cy as W}from"./index.BdH_oWMm.js";var h=function(){return S.Date.now()},_="Expected a function",F=Math.max,N=Math.min;function O(d,t,n){var r,a,g,l,i,f,c=0,E=!1,o=!1,v=!0;if(typeof d!="function")throw new TypeError(_);t=R(t)||0,W(n)&&(E=!!n.leading,o="maxWait"in n,g=o?F(R(n.maxWait)||0,t):g,v="trailing"in n?!!n.trailing:v);function T(e){var u=r,m=a;return r=a=void 0,c=e,l=d.apply(m,u),l}function b(e){return c=e,i=setTimeout(s,t),E?T(e):l}function C(e){var u=e-f,m=e-c,I=t-u;return o?N(I,g-m):I}function k(e){var u=e-f,m=e-c;return f===void 0||u>=t||u<0||o&&m>=g}function s(){var e=h();if(k(e))return y(e);i=setTimeout(s,C(e))}function y(e){return i=void 0,v&&r?T(e):(r=a=void 0,l)}function L(){i!==void 0&&clearTimeout(i),c=0,r=f=a=i=void 0}function M(){return i===void 0?l:y(h())}function x(){var e=h(),u=k(e);if(r=arguments,a=this,f=e,u){if(i===void 0)return b(f);if(o)return clearTimeout(i),i=setTimeout(s,t),T(f)}return i===void 0&&(i=setTimeout(s,t)),l}return x.cancel=L,x.flush=M,x}var p="Expected a function";function U(d,t,n){var r=!0,a=!0;if(typeof d!="function")throw new TypeError(p);return W(n)&&(r="leading"in n?!!n.leading:r,a="trailing"in n?!!n.trailing:a),O(d,t,{leading:r,maxWait:t,trailing:a})}export{O as d,U as t};
