import s from"workerpool";import{isDevelopMode as l}from"../utils/envs/is-develop-mode.js";import{fromCurrentDir as m}from"../utils/paths.js";class p{#t=null;#o;constructor(o){this.#o=o,this.#o.lazy||(this.#t=this.#i())}#i(){const{workerScript:o,lazy:e,...i}=this.#o;let t=o;return!t.endsWith(".js")&&!t.endsWith(".mjs")&&(t=m(import.meta.url,`${t}.${l()?"js":"mjs"}`)),s.pool(t,{...i})}#r(){return this.#t||(this.#t=this.#i()),this.#t}async exec(o,e,i){let r=this.#r().exec(o,e);return i?.timeout&&(r=r.timeout(i.timeout)),await r}async terminate(){this.#t&&(await this.#t.terminate(),this.#t=null)}}export{p as WorkerPool};
