function M(n,d,g){var o=g||{},r=o.noTrailing,t=r===void 0?!1:r,v=o.noLeading,p=v===void 0?!1:v,m=o.debounceMode,a=m===void 0?void 0:m,i,T=!1,l=0;function b(){i&&clearTimeout(i)}function D(f){var u=f||{},e=u.upcomingOnly,s=e===void 0?!1:e;b(),T=!s}function w(){for(var f=arguments.length,u=new Array(f),e=0;e<f;e++)u[e]=arguments[e];var s=this,$=Date.now()-l;if(T)return;function c(){l=Date.now(),d.apply(s,u)}function x(){i=void 0}!p&&a&&!i&&c(),b(),a===void 0&&$>n?p?(l=Date.now(),t||(i=setTimeout(a?x:c,n))):c():t!==!0&&(i=setTimeout(a?x:c,a===void 0?n-$:n))}return w.cancel=D,w}function h(n,d,g){var o={},r=o.atBegin,t=r===void 0?!1:r;return M(n,d,{debounceMode:t!==!1})}export{h as debounce,M as throttle};
