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