import{I as C}from"./vue.runtime.esm-Ct3_M7aQ.chunk.mjs";var b={exports:{}},x;function P(){return x||(x=1,function(f){var t=Object.prototype.hasOwnProperty,e="~";function o(){}Object.create&&(o.prototype=Object.create(null),new o().__proto__||(e=!1));function h(i,n,r){this.fn=i,this.context=n,this.once=r||!1}function a(i,n,r,c,y){if(typeof r!="function")throw new TypeError("The listener must be a function");var p=new h(r,c||i,y),m=e?e+n:n;return i._events[m]?i._events[m].fn?i._events[m]=[i._events[m],p]:i._events[m].push(p):(i._events[m]=p,i._eventsCount++),i}function v(i,n){--i._eventsCount===0?i._events=new o:delete i._events[n]}function u(){this._events=new o,this._eventsCount=0}u.prototype.eventNames=function(){var i=[],n,r;if(this._eventsCount===0)return i;for(r in n=this._events)t.call(n,r)&&i.push(e?r.slice(1):r);return Object.getOwnPropertySymbols?i.concat(Object.getOwnPropertySymbols(n)):i},u.prototype.listeners=function(i){var n=e?e+i:i,r=this._events[n];if(!r)return[];if(r.fn)return[r.fn];for(var c=0,y=r.length,p=new Array(y);cglobalThis.DOMException===void 0?new z(f):new DOMException(f),I=f=>{const t=f.reason===void 0?_("This operation was aborted."):f.reason;return t instanceof Error?t:_(t)};function S(f,t){const{milliseconds:e,fallback:o,message:h,customTimers:a={setTimeout,clearTimeout}}=t;let v;const u=new Promise((i,n)=>{if(typeof e!="number"||Math.sign(e)!==1)throw new TypeError(`Expected \`milliseconds\` to be a positive number, got \`${e}\``);if(t.signal){const{signal:c}=t;c.aborted&&n(I(c)),c.addEventListener("abort",()=>{n(I(c))})}if(e===Number.POSITIVE_INFINITY){f.then(i,n);return}const r=new T;v=a.setTimeout.call(void 0,()=>{if(o){try{i(o())}catch(c){n(c)}return}typeof f.cancel=="function"&&f.cancel(),h===!1?i():h instanceof Error?n(h):(r.message=h??`Promise timed out after ${e} milliseconds`,n(r))},e),(async()=>{try{i(await f)}catch(c){n(c)}})()}).finally(()=>{u.clear()});return u.clear=()=>{a.clearTimeout.call(void 0,v),v=void 0},u}function q(f,t,e){let o=0,h=f.length;for(;h>0;){const a=Math.trunc(h/2);let v=o+a;e(f[v],t)<=0?(o=++v,h-=a+1):h=a}return o}class L{#t=[];enqueue(t,e){e={priority:0,...e};const o={priority:e.priority,id:e.id,run:t};if(this.size===0||this.#t[this.size-1].priority>=e.priority){this.#t.push(o);return}const h=q(this.#t,o,(a,v)=>v.priority-a.priority);this.#t.splice(h,0,o)}setPriority(t,e){const o=this.#t.findIndex(a=>a.id===t);if(o===-1)throw new ReferenceError(`No promise function with the id "${t}" exists in the queue.`);const[h]=this.#t.splice(o,1);this.enqueue(h.run,{priority:e,id:t})}dequeue(){return this.#t.shift()?.run}filter(t){return this.#t.filter(e=>e.priority===t.priority).map(e=>e.run)}get size(){return this.#t.length}}class A extends N{#t;#o;#s=0;#p;#a;#v=0;#i;#c;#e;#m;#n=0;#h;#r;#y;#g=1n;timeout;constructor(t){if(super(),t={carryoverConcurrencyCount:!1,intervalCap:Number.POSITIVE_INFINITY,interval:0,concurrency:Number.POSITIVE_INFINITY,autoStart:!0,queueClass:L,...t},!(typeof t.intervalCap=="number"&&t.intervalCap>=1))throw new TypeError(`Expected \`intervalCap\` to be a number from 1 and up, got \`${t.intervalCap?.toString()??""}\` (${typeof t.intervalCap})`);if(t.interval===void 0||!(Number.isFinite(t.interval)&&t.interval>=0))throw new TypeError(`Expected \`interval\` to be a finite number >= 0, got \`${t.interval?.toString()??""}\` (${typeof t.interval})`);this.#t=t.carryoverConcurrencyCount,this.#o=t.intervalCap===Number.POSITIVE_INFINITY||t.interval===0,this.#p=t.intervalCap,this.#a=t.interval,this.#e=new t.queueClass,this.#m=t.queueClass,this.concurrency=t.concurrency,this.timeout=t.timeout,this.#y=t.throwOnTimeout===!0,this.#r=t.autoStart===!1}get#b(){return this.#o||this.#s{this.#I()},e)),!0}return!1}#u(){if(this.#e.size===0)return this.#i&&clearInterval(this.#i),this.#i=void 0,this.emit("empty"),this.#n===0&&this.emit("idle"),!1;if(!this.#r){const t=!this.#T;if(this.#b&&this.#x){const e=this.#e.dequeue();return e?(this.emit("active"),e(),t&&this.#d(),!0):!1}}return!1}#d(){this.#o||this.#i!==void 0||(this.#i=setInterval(()=>{this.#w()},this.#a),this.#v=Date.now()+this.#a)}#w(){this.#s===0&&this.#n===0&&this.#i&&(clearInterval(this.#i),this.#i=void 0),this.#s=this.#t?this.#n:0,this.#l()}#l(){for(;this.#u(););}get concurrency(){return this.#h}set concurrency(t){if(!(typeof t=="number"&&t>=1))throw new TypeError(`Expected \`concurrency\` to be a number from 1 and up, got \`${t}\` (${typeof t})`);this.#h=t,this.#l()}async#E(t){return new Promise((e,o)=>{t.addEventListener("abort",()=>{o(t.reason)},{once:!0})})}setPriority(t,e){this.#e.setPriority(t,e)}async add(t,e={}){return e.id??=(this.#g++).toString(),e={timeout:this.timeout,throwOnTimeout:this.#y,...e},new Promise((o,h)=>{this.#e.enqueue(async()=>{this.#n++,this.#s++;try{e.signal?.throwIfAborted();let a=t({signal:e.signal});e.timeout&&(a=S(Promise.resolve(a),{milliseconds:e.timeout})),e.signal&&(a=Promise.race([a,this.#E(e.signal)]));const v=await a;o(v),this.emit("completed",v)}catch(a){if(a instanceof T&&!e.throwOnTimeout){o();return}h(a),this.emit("error",a)}finally{this.#_()}},e),this.emit("add"),this.#u()})}async addAll(t,e){return Promise.all(t.map(async o=>this.add(o,e)))}start(){return this.#r?(this.#r=!1,this.#l(),this):this}pause(){this.#r=!0}clear(){this.#e=new this.#m}async onEmpty(){this.#e.size!==0&&await this.#f("empty")}async onSizeLessThan(t){this.#e.sizethis.#e.size{const h=()=>{e&&!e()||(this.off(t,h),o())};this.on(t,h)})}get size(){return this.#e.size}sizeBy(t){return this.#e.filter(t).length}get pending(){return this.#n}get isPaused(){return this.#r}}export{A as P}; //# sourceMappingURL=index-_ghYQSTa.chunk.mjs.map