import{g as C}from"./@ui-core-DKdciH1Z.js";var h,y;function F(){if(y)return h;y=1,h=function(t){var r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,o=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},a=void 0,i=void 0,c=void 0,s=[];return function(){var p=u(r),g=new Date().getTime(),P=!a||g-a>p;a=g;for(var b=arguments.length,l=Array(b),f=0;f<b;f++)l[f]=arguments[f];if(P&&o.leading)return o.accumulate?Promise.resolve(t.call(this,[l])).then(function(d){return d[0]}):Promise.resolve(t.call.apply(t,[this].concat(l)));if(i?clearTimeout(c):i=n(),s.push(l),c=setTimeout(D.bind(this),p),o.accumulate){var w=s.length-1;return i.promise.then(function(d){return d[w]})}return i.promise};function D(){var v=i;clearTimeout(c),Promise.resolve(o.accumulate?t.call(this,s):t.apply(this,s[s.length-1])).then(v.resolve,v.reject),s=[],i=null}};function u(e){return typeof e=="function"?e():e}function n(){var e={};return e.promise=new Promise(function(t,r){e.resolve=t,e.reject=r}),e}return h}var j=F();const A=C(j);function O(u){var n=null,e=null,t=new Promise(function(r,o){n=r,e=o});return u&&u.then(function(r){n&&n(r)},function(r){e&&e(r)}),{promise:t,resolve:function(r){n&&n(r)},reject:function(r){e&&e(r)},cancel:function(){n=null,e=null}}}function T(u){var n=null,e=function(){for(var t=[],r=0;r<arguments.length;r++)t[r]=arguments[r];n&&n();var o=u.apply(void 0,t),a=O(o),i=a.promise,c=a.cancel;return n=c,i};return e}var m=function(){return m=Object.assign||function(n){for(var e,t=1,r=arguments.length;t<r;t++){e=arguments[t];for(var o in e)Object.prototype.hasOwnProperty.call(e,o)&&(n[o]=e[o])}return n},m.apply(this,arguments)},R={key:function(){return null},onlyResolvesLast:!0},S=(function(){function u(n){this.config=n,this.debounceSingleton=null,this.debounceCache={}}return u.prototype._createDebouncedFunction=function(){var n=A(this.config.func,this.config.wait,this.config.options);return this.config.options.onlyResolvesLast&&(n=T(n)),{func:n}},u.prototype.getDebouncedFunction=function(n){var e,t=(e=this.config.options).key.apply(e,n);return t===null||typeof t>"u"?(this.debounceSingleton||(this.debounceSingleton=this._createDebouncedFunction()),this.debounceSingleton):(this.debounceCache[t]||(this.debounceCache[t]=this._createDebouncedFunction()),this.debounceCache[t])},u})();function L(u,n,e){var t=m({},R,e),r=new S({func:u,wait:n,options:t}),o=(function(){for(var a=[],i=0;i<arguments.length;i++)a[i]=arguments[i];var c=r.getDebouncedFunction(a).func;return c.apply(void 0,a)});return o}export{L as A};
