import{fm as N,bh as T,fn as A}from"./index-BhlVWTSX.js";var L=/\s/;function M(n){for(var e=n.length;e--&&L.test(n.charAt(e)););return e}var _=/^\s+/;function $(n){return n&&n.slice(0,M(n)+1).replace(_,"")}var W=NaN,B=/^[-+]0x[0-9a-f]+$/i,F=/^0b[01]+$/i,U=/^0o[0-7]+$/i,X=parseInt;function k(n){if(typeof n=="number")return n;if(N(n))return W;if(T(n)){var e=typeof n.valueOf=="function"?n.valueOf():n;n=T(e)?e+"":e}if(typeof n!="string")return n===0?n:+n;n=$(n);var i=F.test(n);return i||U.test(n)?X(n.slice(2),i?2:8):B.test(n)?W:+n}var E=function(){return A.Date.now()},j="Expected a function",D=Math.max,H=Math.min;function P(n,e,i){var a,f,l,c,t,d,s=0,I=!1,o=!1,x=!0;if(typeof n!="function")throw new TypeError(j);e=k(e)||0,T(i)&&(I=!!i.leading,o="maxWait"in i,l=o?D(k(i.maxWait)||0,e):l,x="trailing"in i?!!i.trailing:x);function h(r){var u=a,m=f;return a=f=void 0,s=r,c=n.apply(m,u),c}function O(r){return s=r,t=setTimeout(g,e),I?h(r):c}function R(r){var u=r-d,m=r-s,p=e-u;return o?H(p,l-m):p}function y(r){var u=r-d,m=r-s;return d===void 0||u>=e||u<0||o&&m>=l}function g(){var r=E();if(y(r))return b(r);t=setTimeout(g,R(r))}function b(r){return t=void 0,x&&a?h(r):(a=f=void 0,c)}function S(){t!==void 0&&clearTimeout(t),s=0,a=d=f=t=void 0}function C(){return t===void 0?c:b(E())}function v(){var r=E(),u=y(r);if(a=arguments,f=this,d=r,u){if(t===void 0)return O(d);if(o)return clearTimeout(t),t=setTimeout(g,e),h(d)}return t===void 0&&(t=setTimeout(g,e)),c}return v.cancel=S,v.flush=C,v}var q="Expected a function";function G(n,e,i){var a=!0,f=!0;if(typeof n!="function")throw new TypeError(q);return T(i)&&(a="leading"in i?!!i.leading:a,f="trailing"in i?!!i.trailing:f),P(n,e,{leading:a,maxWait:e,trailing:f})}export{G as a,P as d,k as t};
