"use strict";const t="Expected a function";function n(n,o,e){let r,u,c,a,f,l,s=0,d=!1,m=!1,p=!0;if("function"!=typeof n)throw new TypeError(t);function g(t){const i=r,o=u;return r=u=void 0,s=t,a=n.apply(o,i),a}function v(t){const n=t-l;return void 0===l||n>=o||n<0||m&&t-s>=c}function T(){const t=Date.now();if(v(t))return h(t);f=setTimeout(T,function(t){const n=t-s,i=o-(t-l);return m?Math.min(i,c-n):i}(t))}function h(t){return f=void 0,p&&r?g(t):(r=u=void 0,a)}function w(){const t=Date.now(),n=v(t);if(r=arguments,u=this,l=t,n){if(void 0===f)return function(t){return s=t,f=setTimeout(T,o),d?g(t):a}(l);if(m)return clearTimeout(f),f=setTimeout(T,o),g(l)}return void 0===f&&(f=setTimeout(T,o)),a}return o=o||0,e&&i(e)&&(d=!!e.leading,m="maxWait"in e,c=m?Math.max(e.maxWait||0,o):c,p="trailing"in e?!!e.trailing:p),w.cancel=function(){void 0!==f&&clearTimeout(f),s=0,r=l=u=f=void 0},w.flush=function(){return void 0===f?a:h(Date.now())},w}function i(t){const n=typeof t;return null!=t&&("object"==n||"function"==n)}exports.debounce=n,exports.throttle=function(o,e,r){let u=!0,c=!0;if("function"!=typeof o)throw new TypeError(t);return r&&i(r)&&(u="leading"in r?!!r.leading:u,c="trailing"in r?!!r.trailing:c),n(o,e,{leading:u,maxWait:e,trailing:c})};
