var a=Object.defineProperty;var h=(n,s,e)=>s in n?a(n,s,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[s]=e;var t=(n,s,e)=>(h(n,typeof s!="symbol"?s+"":s,e),e);class f{constructor(){t(this,"queue",[]);t(this,"isRunning",!1)}enqueue(s){return new Promise((e,i)=>{const r=async()=>{try{const u=await s();e(u)}catch(u){i(u)}};this.queue.push(r),this.run()})}async run(){if(this.isRunning||this.queue.length===0)return;this.isRunning=!0;const s=this.queue.shift();s&&await s(),this.isRunning=!1,this.run()}}export{f as T};
