@deslop/scope 0.1.1246 → 0.1.1248
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/client/assets/(home)-jrmEy-uP.js +41 -0
- package/dist/client/assets/{effect-CTnU1PfQ.js → effect-B5i6790O.js} +1 -1
- package/dist/client/assets/{index-CTt5ZHpn.js → index-BnaUEAaO.js} +3 -3
- package/dist/client/index.html +2 -2
- package/package.json +2 -2
- package/dist/client/assets/(home)-D2_281Yi.js +0 -41
|
@@ -10,6 +10,6 @@ var e=(e,t)=>{switch(t.length){case 0:return e;case 1:return t[0](e);case 2:retu
|
|
|
10
10
|
`)},Ms=e=>{let t=[],n=e,r=0;for(;n&&r<10;){let e=n.stack();if(e){let r=e.matchAll(Os),i=!1;for(let[,e]of r)i=!0,t.push(` at ${n.name} (${e})`);i||t.push(` at ${n.name} (${e.replace(/^at /,``)})`)}else t.push(` at ${n.name}`);n=n.parent,r++}return t.join(`
|
|
11
11
|
`)},Ns=e=>Ts(e).map(Ps).join(`
|
|
12
12
|
`),Ps=e=>e.cause?`${e.stack} {\n${Fs(e.cause,` `)}\n}`:e.stack,Fs=(e,t)=>{let n=e.stack.split(`
|
|
13
|
-
`),r=`${t}[cause]: ${n[0]}`;for(let e=1,i=n.length;e<i;e++)r+=`\n${t}${n[e]}`;return e.cause&&(r+=` {\n${Fs(e.cause,`${t} `)}\n${t}}`),r},Is=`~effect/Fiber`,Ls={_A:i,_E:i},Rs={id:0},zs=(()=>{try{return globalThis.process?.getBuiltinModule?.(`node:async_hooks`)?.AsyncResource}catch{return}})(),Bs=()=>zs===void 0?void 0:new zs(`effect/Fiber`),Vs=()=>globalThis[_t],Hs=class{constructor(e,t=!0){this.setContext(e),this.id=++Rs.id,this.currentOpCount=0,this.interruptible=t,this._stack=[],this._observers=void 0,this._exit=void 0,this._children=void 0,this._interruptedCause=void 0,this._yielded=void 0,this._running=!1,this._deferredInterrupt=!1,this._parent=void 0,this._asyncContext=void 0,this.cache.runtimeMetrics?.recordFiberStart(this.context)}get[Is](){return Ls}get currentDispatcher(){return this._dispatcher??=this.cache.scheduler.makeDispatcher()}getRef(e){return D(this.context,e)}addObserver(e){return this._exit?(e(this._exit),l):(this._observers===void 0?this._observers=[e]:this._observers.push(e),()=>this.removeObserver(e))}removeObserver(e){if(this._exit||this._observers===void 0)return;let t=this._observers.indexOf(e);t>=0&&this._observers.splice(t,1)}interruptUnsafe(e,t){if(this._exit)return;let n=us(e);this.cache.stackFrame&&(n=_n(n,sa(Tn,this.cache.stackFrame))),t&&(n=_n(n,t)),this._interruptedCause=this._interruptedCause?fn(this._interruptedCause,n):n,this.interruptible&&(this._running?this._deferredInterrupt=!0:this.evaluate(j(this._interruptedCause)))}pollUnsafe(){return this._exit}evaluate(e){if(this._exit)return;if(this._asyncContext!==void 0){let t=this._asyncContext;this._asyncContext=void 0;try{return t.runInAsyncScope(this.evaluate,this,e)}finally{t.emitDestroy()}}else if(this._yielded!==void 0){let e=this._yielded;this._yielded=void 0,e()}let t=this.runLoop(e);if(t===Jt){this._asyncContext=Bs();return}let n=Ks.interruptChildren&&Ks.interruptChildren(this);if(n!==void 0)return this.evaluate(P(n,()=>t));if(this._exit=t,this.cache.runtimeMetrics?.recordFiberEnd(this.context,this._exit),this._parent&&=(this._parent._children?.delete(this),void 0),this._observers!==void 0){let e=this._observers;this._observers=void 0;for(let n=0;n<e.length;n++)e[n](t)}this._stack.length=0,this._children=void 0,this.context=aa();let r=this.cache;(r.span!==void 0||r.stackFrame!==void 0)&&(this.cache={...r,span:void 0,stackFrame:void 0})}runLoop(e){let t=globalThis[_t];globalThis[_t]=this;let n=this._running;this._running=!0;let r=!1,i=e;this.currentOpCount=0;try{for(;;)try{this._deferredInterrupt&&(this._deferredInterrupt=!1,i=j(this._interruptedCause)),this.currentOpCount++;let e=this.cache;if(!r&&!e.preventYield&&e.scheduler.shouldYield(this)){r=!0;let e=i;i=P(ic,()=>e)}if(i=e.tracerContext?e.tracerContext(i,this):i[Wt](this),i===Jt){let e=this._yielded;if(`~effect/Exit`in e)return this._deferredInterrupt=!1,this._yielded=void 0,e;if(this._deferredInterrupt){this._yielded=void 0,e();continue}return Jt}}catch(e){if(!v(i,`~effect/Effect/evaluate`))return kn(`Fiber.runLoop: Not a valid effect: ${String(i)}`);i=kn(e)}}finally{this._running=n,globalThis[_t]=t}}getCont(e){if(this._deferredInterrupt)return this._deferredInterrupt=!1,Ws;for(;;){let t=this._stack.pop();if(!t)return;let n=t[qt];if(n!==void 0){let r=n.call(t,this);if(r)return r[e]=r,r}if(t[e])return t}}succeedWith(e){if(!(++this.currentOpCount&Gs-1))return C(e);let t=this.getCont(Gt);return t?t[Gt](e,this):this.yieldWith(C(e))}yieldWith(e){return this._yielded=e,Jt}children(){return this._children??=new Set}pipe(){return e(this,arguments)}setContext(e){let t=this.context;if(this.context=e,t!==void 0&&na(t,e))return;let n=e.cacheRoot,r=n._fiberCache??=Us(e);this.cache?.scheduler!==r.scheduler&&(this._dispatcher=void 0),this.cache=r}get currentSpanLocal(){let e=this.cache.span;return e?._tag===`Span`?e:void 0}},Us=e=>{let t=da(e,Ko);return{scheduler:D(e,So),tracer:t,tracerContext:t?t.context:void 0,tracerEnabled:D(e,Zo),span:da(e,Bo),logLevel:D(e,ns),minimumLogLevel:D(e,rs),stackFrame:D(e,Xo),runtimeMetrics:da(e,Yo),maxOpsBeforeYield:D(e,ko),preventYield:D(e,Ao)}},Ws={[Gt](e,t){return j(t._interruptedCause)},[Kt](e,t){return j(t._interruptedCause)}},Gs=32,Ks={interruptChildren:void 0},qs=e=>{if(!e.cache.stackFrame)return;let t=new Map;return t.set(En.key,e.cache.stackFrame),ea(t)},Js=e=>{let t=e;return t._exit?A(t._exit):pc(n=>t._exit?n(A(t._exit)):nc(e.addObserver(e=>n(A(e)))))},Ys=e=>pc(t=>{let n=e[Symbol.iterator](),r=[],i;function a(){let e=n.next();for(;!e.done;)if(e.value._exit)r.push(e.value._exit),e=n.next();else{i=e.value.addObserver(e=>{r.push(e),a()});return}t(A(r))}return a(),nc(()=>i?.())}),Xs=e=>{let t=e;return t._exit?t._exit:pc(n=>t._exit?n(t._exit):nc(e.addObserver(n)))},Zs=e=>pc(t=>{let n=Array.from(e);if(n.length===0)return t(A(ki()));let r=Array(n.length),i=ki(),a=()=>{for(let e=0;e<i.length;e++)n[e].removeObserver(i[e])},o=0,s=!1;for(let e=0;e<n.length&&!s;e++){let c=i=>{if(o++,i._tag===`Failure`)return s=!0,a(),t(i);r[e]=i.value,o===n.length&&t(A(r))};i.push(c),n[e].addObserver(c)}return nc(()=>{s=!0,a()})}),Qs=e=>w(t=>$s(e,t.id)),$s=r(e=>v(e[0],Is),(e,t,n)=>w(r=>{let i=qs(r);return i=i&&n?_a(i,n):i??n,e.interruptUnsafe(t,i),Ic(Js(e))})),ec=e=>w(t=>{let n=qs(t),r=ki();for(let i of e)i.interruptUnsafe(t.id,n),r.push(i);return Ic(Ys(r))}),A=C,j=Dn,tc=On,nc=Cn({op:`Sync`,[Wt](e){let t=this[S],n=t(),r=e.getCont(Gt);return r?r[Gt](n,e):e.yieldWith(C(n))}}),M=Cn({op:`Suspend`,[Wt](e){let t=this[S];return t()}}),rc=Jr({onFailure:tc,onSuccess:A}),ic=Cn({op:`Yield`,[Wt](e){let t=!1;return e.currentDispatcher.scheduleTask(()=>{t||e.evaluate(Zc)},this[`~effect/Effect/args`]??0),e.yieldWith(()=>{t=!0})}})(0),ac=A(T()),oc=e=>M(()=>j(e())),sc=e=>kn(e),N=A(void 0),cc=e=>{let t=typeof e==`function`?e:e.try,n=typeof e==`function`?e=>new Id(e,`An error occurred in Effect.try`):e.catch;return M(()=>{try{return A(t())}catch(e){return tc(n(e))}})},lc=e=>dc(function(t,n){e(n).then(e=>t(A(e)),e=>t(sc(e)))},e.length!==0),uc=e=>{let t=typeof e==`function`?e:e.try,n=typeof e==`function`?e=>new Id(e,`An error occurred in Effect.tryPromise`):e.catch;return dc(function(e,r){let i=e=>M(()=>{try{return tc(zt(()=>n(e)))}catch(e){return sc(e)}});try{t(r).then(t=>e(A(t)),t=>e(i(t)))}catch(t){e(i(t))}},t.length!==0)},dc=function(){let e=Sn({op:`Async`,[Wt](e){let t=!1,n=!1,r=this.withSignal?new AbortController:void 0,i=this.register.call(e.cache.scheduler,r=>{t||(t=!0,n?e.evaluate(r):n=r)},r?.signal);return n===!1?(n=!0,e.yieldWith(()=>{t=!0}),r===void 0&&i===void 0||e._stack.push(fc(()=>(t=!0,r?.abort(),i??Zc))),Jt):n}}),t=function(e,t){this.register=e,this.withSignal=t};return t.prototype=e,function(e,n){return new t(e,n)}}(),fc=Cn({op:`AsyncFinalizer`,[qt](e){e.interruptible&&(e.interruptible=!1,e._stack.push(Ou))},[Kt](e,t){return _s(e)?P(Zl(Dn(e),this[S]()),()=>j(e)):j(e)}}),pc=e=>dc(e,e.length>=2),mc=pc(l),hc=(...e)=>{if(e.length===1){let t=e[0];return M(()=>xc(t()))}let[t,n]=e;return M(()=>xc(n.call(t.self)))},gc=(e,t)=>typeof e==`function`?e:t.shift().bind(e.self),_c=(e,...t)=>{let n=gc(e,t),r=t.length===0?function(){return M(()=>xc(n.apply(this,arguments)))}:function(){let e=M(()=>xc(n.apply(this,arguments)));for(let n=0;n<t.length;n++)e=t[n](e,...arguments);return e};return vc(n.length,r)},vc=(e,t)=>Object.defineProperty(t,"length",{value:e,configurable:!0}),yc=(e,...t)=>{let n=gc(e,t);return vc(n.length,t.length===0?function(){return bc(()=>n.apply(this,arguments))}:function(){let e=bc(()=>n.apply(this,arguments));for(let n of t)e=n(e,...arguments);return e})},bc=e=>{try{let t=e(),n;for(;;){let r=t.next(n);if(r.done)return A(r.value);let i=r.value;if(i&&i._tag===`Success`)n=i.value;else{if(i&&i._tag===`Failure`)return r.value;{let n=!0;return M(()=>n?(n=!1,P(r.value,e=>xc(t,e))):M(()=>xc(e())))}}}}catch(e){return sc(e)}},xc=function(){let e=Sn({op:`Iterator`,[Gt](e,t){let n=this.iterator;for(;;){let r=n.next(e);if(r.done)return A(r.value);if(!F(r.value))return t._stack.push(this),r.value;if(r.value._tag===`Failure`)return r.value;e=r.value.value}},[Wt](e){return this[Gt](this.initial,e)}}),t=function(e,t){this.iterator=e,this.initial=t};return t.prototype=e,function(e,n){return new t(e,n)}}(),Sc=r(2,(e,t)=>new Tc(e,Ec,A(t))),Cc=function(e){return e._stack.push(this),this[S]},wc=Sn({op:`OnSuccess`,[Wt]:Cc}),Tc=function(e,t,n){this[S]=e,this[Gt]=t,this.payload=n};Tc.prototype=wc;var Ec=function(){return this.payload},Dc=function(e,t){return t.succeedWith(this.payload)},Oc=(()=>{let e=It();if(e===0)return!1;let t=`~effect/Effect/stackProbe`,n={[t]:function(){return Error()}};Lt(1);let r=n[t]();return Lt(e),r.stack?.includes(`[as `+t+`]`)===!0})(),kc=function(e,t){let n=this.payload;return t.succeedWith(Oc?n(e):zt(()=>n(e)))},Ac=function(e){let t=this.payload;return t(e)},jc=function(e){let t=this.payload;return new Tc(t(e),Dc,e)},Mc=function(e){return new Tc(this.payload,Dc,e)},Nc=e=>Vc(e,E),Pc=r(2,(e,t)=>new Tc(e,Zt(t)?Ec:Ac,t)),Fc=r(2,(e,t)=>new Tc(e,Zt(t)?Mc:jc,t)),Ic=e=>new Tc(e,Ec,Zc),Lc=(e,t)=>w(n=>{let r=new Set;return hu(n,()=>r.size===0?void 0:ec(r)),pc(i=>{let a=!1,o=0;for(let s of e){if(a)break;let e=o++,c=Uu(n,s,!0,!0,!1);r.add(c),c.addObserver(o=>{r.delete(c);let s=!a;a=!0,i(o),s&&t?.onWinner&&t.onWinner({fiber:c,index:e,parentFiber:n})})}})}),Rc=r(e=>Zt(e[1]),(e,t,n)=>Lc([e,t],n)),P=r(2,(e,t)=>new Tc(e,Ac,t)),F=e=>e[Vt]!==void 0,zc=r(2,(e,t)=>F(e)?e._tag===`Success`?t(e.value):e:P(e,t)),Bc=e=>P(e,i),Vc=r(2,(e,t)=>new Tc(e,kc,t)),Hc=r(2,(e,t)=>F(e)?Qc(e,t):Vc(e,t)),Uc=r(2,(e,t)=>F(e)?$c(e,t):Cl(e,t)),Wc=r(2,(e,t)=>F(e)?el(e,t):wl(e,t)),Gc=r(2,(e,t)=>{if(F(e)){if(e._tag===`Success`)return e;let n=gs(e.cause);return Wr(n)?Dn(n.failure):t(n.success)}return yl(e,t)}),Kc=e=>Dn(us(e)),qc=e=>e._tag===`Success`,Jc=e=>e._tag===`Failure`,Yc=e=>e._tag===`Failure`?Br(e.cause):Vr(e),Xc=e=>e._tag===`Failure`&&_s(e.cause),Zc=C(void 0),Qc=r(2,(e,t)=>e._tag===`Success`?C(t(e.value)):e),$c=r(2,(e,t)=>e._tag===`Success`?e:Dn(Cs(e.cause,t))),el=r(2,(e,t)=>e._tag===`Success`?C(t.onSuccess(e.value)):Dn(Cs(e.cause,t.onFailure))),tl=r(2,(e,t)=>qc(e)?t:e),nl=e=>{let t=[];for(let n of e)n._tag===`Failure`&&t.push(...n.cause.reasons);return t.length===0?Zc:Dn(ln(t))},rl=e=>w(t=>A(ga(t.context,e))),il=r(2,(e,t)=>w(n=>{let r=n.context,i=t(r);return r===i||(n.setContext(i),hu(n,()=>{n.setContext(r)})),e})),al=r(3,(e,t,n)=>il(e,e=>{let r=fa(e,t),i=n(r);return r===i?e:ca(e,t,i)})),ol=()=>sl,sl=w(e=>A(e.context)),cl=e=>w(t=>e(t.context)),ll=r(2,(e,t)=>F(e)?e:il(e,_a(t))),ul=function(){return arguments.length===1?r(2,(e,t)=>dl(e,arguments[0],t)):r(3,(e,t,n)=>dl(e,t,n)).apply(this,arguments)},dl=(e,t,n)=>il(e,ca(t,n)),fl=r(2,(e,t)=>P(t,t=>t?Nc(e):ac)),pl=r(e=>Zt(e[0]),(e,t)=>Fu({while:o,body:a(t?.disableYield?e:P(e,e=>ic)),step:l})),ml=r(2,(e,t)=>new gl(e,t.length===1?t:e=>t(e))),hl=Sn({op:`OnFailure`,[Wt]:Cc}),gl=function(e,t){this[S]=e,this[Kt]=t};gl.prototype=hl;var _l=r(3,(e,t,n)=>ml(e,e=>t(e)?n(e):j(e))),vl=r(3,(e,t,n)=>ml(e,e=>{let r=t(e);return Wr(r)?j(r.failure):n(r.success,e)})),yl=r(2,(e,t)=>vl(e,gs,e=>t(e))),bl=r(2,(e,t)=>ml(e,e=>Pc(t(e),j(e)))),xl=r(3,(e,t,n)=>ml(e,e=>{let r=t(e);return Wr(r)?j(e):Pc(n(r.success,e),j(e))})),Sl=r(2,(e,t)=>xl(e,fs,e=>t(e))),Cl=r(2,(e,t)=>ml(e,e=>j(Cs(e,t)))),wl=r(2,(e,t)=>Al(e,{onFailure:e=>j(Cs(e,t.onFailure)),onSuccess:e=>nc(()=>t.onSuccess(e))})),Tl=e=>yl(e,sc),El=e=>e===`Unhandled`?(...e)=>w(t=>{let n=t.getRef(is);return n===void 0?N:Gd(n)(...e)}):Gd(e===!0?void 0:e),Dl=r(e=>Zt(e[0]),(e,t)=>{if(!t?.log)return Fl(e,{onFailure:e=>N,onSuccess:e=>N});let n=El(t.log);return Al(e,{onFailure(e){let r=gs(e);return Wr(r)?j(r.failure):t.message===void 0?n(e):n(t.message,e)},onSuccess:e=>N})}),Ol=r(e=>Zt(e[0]),(e,t)=>{if(!t?.log)return Al(e,{onFailure:e=>N,onSuccess:e=>N});let n=El(t.log);return Al(e,{onFailure:e=>t.message===void 0?n(e):n(t.message,e),onSuccess:e=>N})}),kl=e=>Ll(e,{onFailure:Vr,onSuccess:Br}),Al=r(2,(e,t)=>new Ml(e,t.onSuccess.length===1?t.onSuccess:e=>t.onSuccess(e),t.onFailure.length===1?t.onFailure:e=>t.onFailure(e))),jl=Sn({op:`OnSuccessAndFailure`,[Wt]:Cc}),Ml=function(e,t,n){this[S]=e,this[Gt]=t,this[Kt]=n};Ml.prototype=jl;var Nl=function(e,t){let n=this.payload;return t.succeedWith(Oc?n.onSuccess(e):zt(()=>n.onSuccess(e)))},Pl=((e,t)=>{let n=Sn({op:e,[Wt]:Cc,[Gt]:Nl,[Kt]:t}),r=function(e,t){this[S]=e,this.payload=t};return r.prototype=n,r})(`Match`,function(e,t){let n=gs(e);if(Wr(n))return j(n.failure);let r=this.payload;return t.succeedWith(Oc?r.onFailure(n.success):zt(()=>r.onFailure(n.success)))}),Fl=r(2,(e,t)=>Al(e,{onFailure:e=>{let n=gs(e);return Wr(n)?j(n.failure):t.onFailure(n.success)},onSuccess:t.onSuccess})),Il=r(2,(e,t)=>new Pl(e,t)),Ll=r(2,(e,t)=>{if(F(e)){if(e._tag===`Success`)return C(t.onSuccess(e.value));let n=gs(e.cause);return Wr(n)?Dn(n.failure):C(t.onFailure(n.success))}return Il(e,t)}),Rl=e=>F(e)?C(e):zl(e),zl=Cn({op:`Exit`,[Wt](e){return e._stack.push(this),this[S]},[Gt](e,t,n){return t.succeedWith(n??C(e))},[Kt](e,t,n){return t.succeedWith(n??Dn(e))}}),Bl=r(2,(e,t)=>Pc(Dd(t),e)),Vl=r(2,(e,t)=>P(Wl(e,t.duration),e=>Cr(e)?t.orElse():A(e.value))),Hl=e=>new Ad(`Operation timed out after '${bo(e)}'`),Ul=r(2,(e,t)=>{let n=Ha(t);return Vl(e,{duration:n,orElse:()=>tc(Hl(n))})}),Wl=r(2,(e,t)=>Rc(Nc(e),Sc(Dd(t),T()))),Gl=`~effect/Scope`,Kl=`~effect/Scope/Closeable`,ql=Hi(`effect/Scope`),Jl=(e,t)=>w(n=>(ju(n),Yl(e,t)??N)),Yl=(e,t)=>{let n=e.state;if(n._tag===`Closed`||(e.state={_tag:`Closed`,exit:t},e.parent!==void 0&&ru(e.parent,e),n._tag===`Empty`))return;if(n.finalizer!==void 0)return Xl(n.finalizer,t);let r=n.finalizers;return r.size===1?Xl(r.values().next().value,t):Ql(e,r,t)},Xl=(e,t)=>{try{return e(t)}catch(e){return kn(e)}},Zl=(e,t)=>qc(e)?t:ml(t,t=>j(hs(dn(e.cause,t)))),Ql=_c(function*(e,t,n){let r=[],i=[],a=Array.from(t),o=Vs();for(let t=a.length-1;t>=0;t--){let[s,c]=a[t];e.strategy===`sequential`?r.push(yield*Rl(Xl(c,n))):s!==o&&i.push(Uu(o,Xl(c,n),!0,!0,`inherit`))}return i.length>0&&(r=yield*Ys(i)),yield*nl(r)}),$l=(e,t)=>{let n=au(t,e);return e.state._tag===`Closed`?(n.state=e.state,n):(nu(e,n,e=>Jl(n,e)),n)},eu=(e,t)=>M(()=>e.state._tag===`Closed`?t(e.state.exit):(nu(e,{},t),N)),tu=(e,t)=>eu(e,a(t)),nu=(e,t,n)=>{if(e.state._tag===`Empty`)e.state={_tag:`Open`,finalizerKey:t,finalizer:n,finalizers:void 0};else if(e.state._tag===`Open`){let r=e.state;r.finalizer===void 0||(r.finalizers=new Map([[r.finalizerKey,r.finalizer]]),r.finalizerKey=void 0,r.finalizer=void 0),r.finalizers.set(t,n)}},ru=(e,t)=>{if(e.state._tag!==`Open`)return;let n=e.state;n.finalizerKey===t?e.state=ou:n.finalizers!==void 0&&(n.finalizers.delete(t),n.finalizers.size===0&&(e.state=ou))},iu=e=>au(e,void 0),au=(e=`sequential`,t)=>({[Kl]:Kl,[Gl]:Gl,strategy:e,parent:t,state:ou}),ou={_tag:`Empty`},su=ql,cu=ul(ql),lu=e=>w(t=>{let n=t.context,r=iu();return t.setContext(ca(t.context,ql,r)),hu(t,e=>(t.setContext(n),Yl(r,e))),e}),uu=e=>M(()=>{let t=iu();return gu(e(t),e=>M(()=>Yl(t,e)??N))}),du=(e,t,n)=>cl(r=>Nu(i=>P(su,a=>Fc(n?.interruptible?i(e):e,e=>eu(a,n=>ll(t(e,n),r)))))),fu=e=>P(su,t=>cl(n=>eu(t,t=>ll(e(t),n)))),pu=function(){let e=Sn({op:`OnExit`,[Wt](e){return e._stack.push(this),this.effect},[qt](e){e.interruptible&&this.interruptible!==!0&&(e._stack.push(Ou),e.interruptible=!1)},[Gt](e,t,n){n??=C(e);let r;try{r=this.onExit(n)}catch(e){r=kn(e)}return r?P(r,e=>n):n},[Kt](e,t,n){n??=Dn(e);let r;try{r=this.onExit(n)}catch(e){r=kn(e)}return r?P(Zl(n,r),e=>n):n}}),t=function(e,t,n){this.effect=e,this.onExit=t,this.interruptible=n};return t.prototype=e,t}(),mu=(e,t,n)=>new pu(e,t,n),hu=(e,t)=>{e._stack.push(new pu(void 0,t,void 0))},gu=r(2,mu),_u=r(2,(e,t)=>gu(e,e=>t)),vu=r(3,(e,t,n)=>gu(e,e=>{let r=t(e);return Wr(r)?N:n(r.success,e)})),yu=r(2,(e,t)=>vu(e,Yc,t)),bu=r(3,(e,t,n)=>gu(e,e=>{if(e._tag!==`Failure`)return N;let r=t(e.cause);return Wr(r)?N:n(r.success,e.cause)})),xu=r(2,(e,t)=>bu(vs,t)(e)),Su=a(1/0),Cu=(e,t)=>{let n=0,r,i,a=(e,t)=>(t.awaiters++,hu(e,()=>{if(!(--t.awaiters>0||t.done))return i===t&&(i=void 0),Qs(t.fiber)}),Xs(t.fiber));return[w(o=>{if(i!==void 0)return o===i.fiber?Xs(i.fiber):a(o,i);if(r!==void 0&&(n===1/0||o.getRef(bd).currentTimeMillisUnsafe()<n))return r;r=void 0;let s=o.getRef(bd),c={fiber:new Hs(o.context),awaiters:0,done:!1};i=c;let l=a(o,c);return c.fiber.evaluate(mu(e,e=>{if(c.done=!0,i!==c||(i=void 0,Xc(e)))return;let a=t(e);n=a===1/0?1/0:s.currentTimeMillisUnsafe()+a,r=e})),c.fiber._exit??l}),nc(()=>{i=void 0,r=void 0})]},wu=e=>nc(()=>Cu(e,Su)[0]),Tu=w(e=>j(us(e.id))),Eu=e=>w(t=>(t.interruptible&&(t.interruptible=!1,t._stack.push(Ou)),e)),Du=Cn({op:`SetInterruptible`,[qt](e){if(e.interruptible=this[S],e._interruptedCause&&e.interruptible)return()=>j(e._interruptedCause)}}),Ou=Du(!0),ku=Du(!1),Au=e=>{if(e.interruptible=!0,e._stack.push(ku),e._interruptedCause)return j(e._interruptedCause)},ju=e=>{let t=e;t.interruptible&&(t.interruptible=!1,t._stack.push(Ou))},Mu=e=>w(t=>t.interruptible?e:Au(t)??e),Nu=e=>w(t=>t.interruptible?(t.interruptible=!1,t._stack.push(Ou),e(Mu)):e(i)),Pu=(e,t)=>xe(e)?t?.mode===`result`?Iu(e,kl,t):Iu(e,i,t):t?.discard?t.mode===`result`?Iu(Object.values(e),kl,t):Iu(Object.values(e),i,t):M(()=>Vc(Iu(Object.entries(e),([e,n])=>Vc(t?.mode===`result`?kl(n):n,t=>[e,t]),{concurrency:t?.concurrency}),Object.fromEntries)),Fu=Cn({op:`While`,[Gt](e,t){return this[S].step(e),this[`~effect/Effect/args`].while()?(t._stack.push(this),this[S].body()):Zc},[Wt](e){return this[`~effect/Effect/args`].while()?(e._stack.push(this),this[S].body()):Zc}}),Iu=r(e=>typeof e[1]==`function`,(e,t,n)=>M(()=>{let r=Ru(n?.concurrency);if(r===1)return Lu(e,t,n);let i=ui(e),a=i.length;if(a===0)return n?.discard?N:A([]);let o=n?.discard?void 0:Array(a),s=Hu({f:t,out:o},i,{concurrency:r});return s?Sc(s,o):A(o)})),Lu=(e,t,n)=>M(()=>{let r=n?.discard?void 0:[],i=e[Symbol.iterator](),a=i.next(),o=0;return Sc(Fu({while:()=>!a.done,body:()=>t(a.value,o++),step:e=>{r&&r.push(e),a=i.next()}}),r)}),Ru=e=>e===`unbounded`?1/0:Math.max(1,e??1),zu=()=>e=>{let t=e.onItem,n=e.step,r=(e,t,r,a,o)=>P(Rl(o),o=>n(e,t[r],o,r)??i(e,t,r+1,a)??N),i=(e,i,a=0,o=i.length)=>{for(;a<o;a++){let s=i[a],c=t(e,s,a);if(!F(c))return r(e,i,a,o,c);let l=n(e,s,c,a);if(l)return l._tag===`Failure`?l:void 0}};return i},Bu=e=>{let t=e.onItem,n=e.step;return(e,r,i)=>{let a=0,o=i.end??r.length,s=i.concurrency,c=!1,l,u,d,f,p,m=e=>{let t=kn(e);return f=t,c=!0,u&&u.size>0?P(Eu(ec(Array.from(u))),()=>f??t):t},h=()=>{let i=!1;for(;!f&&a<o;a++){let o=r[a],g=p??t(e,o,a);if(F(g)){if(f=n(e,o,g,a),f)break}else if(l){p=void 0;let t=Uu(l,g,!0,!0,`inherit`);if(t._exit){if(f=n(e,o,t._exit,a),f)break;continue}u.add(t);let r=a;if(t.addObserver(a=>{u.delete(t);try{if(f){if(a._tag===`Failure`){let e=a.cause.reasons.filter(e=>e._tag!==`Interrupt`);if(e.length>0){let t=ln(e);f=Dn(f._tag===`Failure`?hs(dn(f.cause,t)):t)}}}else{let t=n(e,o,a,r);t&&(f=t,h())}if(i){let e=h();e&&d(e)}else c&&u.size===0&&d(f??N)}catch(e){d(m(e))}}),u.size<s)continue;i=!0,a++;return}else return pc(e=>{l=Vs(),u=new Set,p=g,d=e;let t;try{t=h()}catch(t){return e(m(t))}return t?e(t):M(()=>(f??=Zc,P(u?ec(u):N,()=>f?._tag===`Failure`?f:N)))})}if(c=!0,f){if(u&&u.size>0){let e=qs(l);u.forEach(t=>t.interruptUnsafe(l.id,e));return}if(d||f._tag===`Failure`)return f}else if(d){if(u)u.size===0&&d(N);else return Zc}};return h()}},Vu=()=>e=>Bu(e),Hu=Bu({onItem(e,t,n){return e.f(t,n)},step(e,t,n,r){if(n._tag===`Failure`)return n;e.out&&(e.out[r]=n.value)}}),Uu=(e,t,n=!1,r=!1,i=!1)=>{let a=e,o=i===`inherit`?a.interruptible:!i,s=new Hs(a.context,o);return r||(a.children().add(s),s._parent=a),n?s.evaluate(t):(s._asyncContext=Bs(),a.currentDispatcher.scheduleTask(()=>s.evaluate(t),0)),s},Wu=r(e=>Zt(e[0]),(e,t)=>w(n=>A(Uu(n,e,t?.startImmediately,!0,t?.uninterruptible)))),Gu=e=>()=>w(t=>t===e?N:Qs(e)),Ku=r(e=>Zt(e[0]),(e,t,n)=>w(r=>{let i=t.state._tag===`Closed`?new Hs(r.context):Uu(r,e,n?.startImmediately,!0,n?.uninterruptible);return i._exit||(t.state._tag===`Closed`?i.interruptUnsafe(r.id,qs(r)):(nu(t,i,Gu(i)),i.addObserver(()=>ru(t,i)))),A(i)})),qu=r(e=>Zt(e[0]),(e,t)=>P(su,n=>Ku(e,n,t))),Ju=e=>(t,n)=>{let r=new Hs(n?.scheduler?ca(e,So,n.scheduler):e,n?.uninterruptible!==!0);if(r.evaluate(t),r._exit)return r;if(n?.signal){if(n.signal.aborted)r.interruptUnsafe();else{let e=()=>r.interruptUnsafe();n.signal.addEventListener(`abort`,e,{once:!0}),r.addObserver(()=>n.signal.removeEventListener(`abort`,e))}}return n?.onFiberStart&&n.onFiberStart(r),r},Yu=r(2,(e,t)=>e._exit?e:t.state._tag===`Closed`?(e.interruptUnsafe(e.id),e):(ru(t,e),nu(t,e,Gu(e)),e.addObserver(()=>ru(t,e)),e)),Xu=Ju(aa()),Zu=e=>{let t=Ju(e);return(e,n)=>{let r=t(e,n);return n?.onExit&&r.addObserver(n.onExit),e=>r.interruptUnsafe(e)}},Qu=e=>{let t=Ju(e);return(e,n)=>{let r=t(e,n);return new Promise(e=>{r.addObserver(t=>e(t))})}},$u=Qu(aa()),ed=(e=>{let t=Qu(e);return(e,n)=>t(e,n).then(e=>{if(e._tag===`Failure`)throw ws(e.cause);return e.value})})(aa()),td=e=>{let t=Ju(e);return e=>{if(F(e))return e;let n=new Do(`sync`),r=t(e,{scheduler:n});return r._dispatcher?.flush(),r._exit??kn(new Pd(r))}},nd=td(aa()),rd=e=>{let t=td(e);return e=>{let n=t(e);if(n._tag===`Failure`)throw ws(n.cause);return n.value}},id=rd(aa()),ad=A(!0),od=A(!1),sd=class{waiters=[];scheduled=void 0;_isOpen;constructor(e){this._isOpen=e}scheduleUnsafe(e){if(this.waiters.length===0)return ad;if(this.scheduled===void 0)this.scheduled=this.waiters,e.currentDispatcher.scheduleTask(this.flushScheduled,0);else for(let e=0;e<this.waiters.length;e++)this.scheduled.push(this.waiters[e]);return this.waiters=[],ad}flushScheduled=()=>{if(this.scheduled===void 0)return;let e=this.scheduled;this.scheduled=void 0;for(let t=0;t<e.length;t++)e[t](Zc)};flushWaiters(){let e=this.waiters;this.waiters=[],this.flushScheduled();for(let t=0;t<e.length;t++)e[t](Zc)}open=w(e=>this._isOpen?od:(this._isOpen=!0,this.scheduleUnsafe(e)));release=w(e=>this._isOpen?od:this.scheduleUnsafe(e));openUnsafe(){return!this._isOpen&&(this._isOpen=!0,this.flushWaiters(),!0)}await=pc(e=>this._isOpen?e(N):(this.waiters.push(e),nc(()=>{let t=this.waiters.indexOf(e);t===-1?this.scheduled!==void 0&&(t=this.scheduled.indexOf(e),t!==-1&&this.scheduled.splice(t,1)):this.waiters.splice(t,1)})));closeUnsafe(){return this._isOpen?(this._isOpen=!1,!0):!1}close=nc(()=>this.closeUnsafe());whenOpen=e=>P(this.await,()=>e);isOpen(){return this._isOpen}},cd=e=>new sd(e??!1),ld=BigInt(0),ud={_tag:`Span`,spanId:`noop`,traceId:`noop`,sampled:!1,status:{_tag:`Ended`,startTime:ld,endTime:ld,exit:Zc},attributes:new Map,links:[],kind:`internal`,attribute(){},event(){},end(){},addLinks(){}},dd=e=>Object.assign(Object.create(ud),e),fd=e=>e?D(e.annotations,Uo)?e._tag===`Span`?fd(jr(e.parent)):T():E(e):T(),pd=(e,t,n)=>{let r=!e.cache.tracerEnabled||n?.annotations&&D(n.annotations,Uo),i=n?.parent===void 0?n?.root?T():fd(e.cache.span):E(n.parent),a;if(r)a=dd({name:t,parent:i,annotations:ca(n?.annotations??aa(),Uo,!0)});else{let r=e.cache.tracer??qo,o=e.getRef(bd),s=e.getRef(Qo),c=e.getRef($o),l=e.getRef(es),u=n?.level??e.getRef(Wo),d=n?.links===void 0?l.length===0?[]:l.slice():[...l,...n.links];a=r.span({name:t,parent:i,annotations:n?.annotations??aa(),links:d,startTime:s?o.currentTimeNanosUnsafe():ld,kind:n?.kind??`internal`,root:n?.root??!1,sampled:n?.sampled??(wr(i)&&i.value.sampled===!1?!1:!Rd(e.getRef(Go),u))});for(let e in c)a.attribute(e,c[e]);if(n?.attributes!==void 0)for(let e in n.attributes)a.attribute(e,n.attributes[e])}return a},md=(e,t)=>Eu(w(n=>{let r=fa(n.context,ql),i=pd(n,e,t??{}),a=n.getRef(bd),o=n.getRef(Qo);return Sc(eu(r,e=>gd(i,e,a,o)),i)})),hd=(e,t)=>(t=typeof t==`function`?t:c,al(Xo,n=>({name:e,stack:t,parent:n}))),gd=(e,t,n,r)=>nc(()=>{e.status._tag!==`Ended`&&e.end(r?n.currentTimeNanosUnsafe():ld,t)}),_d=(e,...t)=>{let n=t.length===1?void 0:t[0],r=t[t.length-1];return w(t=>{let i=pd(t,e,n),a=t.getRef(bd),o=t.getRef(Qo);return hu(t,e=>gd(i,e,a,o)),r(i)})},vd=ul(Vo),yd=function(){let e=Zt(arguments[0]),t=e?arguments[1]:arguments[0],n=e?arguments[2]:arguments[1],r=i;return t._tag===`Span`&&(n=os(n),r=hd(t.name,n?.captureStackTrace)),e?vd(r(arguments[0]),t):e=>vd(r(e),t)},bd=O(`effect/Clock`,{defaultValue:()=>new Sd}),xd=2**31-1,Sd=class{currentTimeMillisUnsafe(){return Date.now()}currentTimeMillis=nc(()=>this.currentTimeMillisUnsafe());currentTimeNanosUnsafe(){return Td()}currentTimeNanos=nc(()=>this.currentTimeNanosUnsafe());monotonicTimeNanosUnsafe(){return wd()}monotonicTimeNanos=nc(()=>this.monotonicTimeNanosUnsafe());sleep(e){return this.sleepMillis(uo(e))}sleepMillis(e){return e<=0?ic:Number.isFinite(e)?pc(t=>{let n=e>xd?this.sleepMillis(e-xd):N,r=setTimeout(()=>t(n),Math.min(e,xd));return nc(()=>clearTimeout(r))}):mc}},Cd=BigInt(1e6),wd=function(){let e=globalThis.process?.hrtime;if(typeof e?.bigint==`function`)return()=>e.bigint();if(typeof performance<`u`&&typeof performance.now==`function`)return()=>BigInt(Math.round(performance.now()*1e6));let t=BigInt(0);return()=>{let e=BigInt(Date.now())*Cd;return e>t&&(t=e),t}}(),Td=function(){let e=BigInt(1e9),t;return()=>{let n=wd(),r=BigInt(Date.now())*Cd;if(t===void 0)t=r-n;else{let i=t+n;(r>i?r-i:i-r)>e&&(t=r-n)}return t+n}}(),Ed=e=>w(t=>e(t.getRef(bd))),Dd=e=>Ed(t=>t.sleep(Ha(e))),Od=Ed(e=>e.currentTimeMillis),kd=`~effect/Cause/TimeoutError`,Ad=class extends Mn(`TimeoutError`){[kd]=kd;constructor(e){super({message:e})}},jd=`~effect/Cause/IllegalArgumentError`,Md=class extends Mn(`IllegalArgumentError`){[jd]=jd;constructor(e){super({message:e})}},Nd=`~effect/Cause/AsyncFiberError`,Pd=class extends Mn(`AsyncFiberError`){[Nd]=Nd;constructor(e){super({message:`An asynchronous Effect was executed with Effect.runSync`,fiber:e})}},Fd=`~effect/Cause/UnknownError`,Id=class extends Mn(`UnknownError`){[Fd]=Fd;constructor(e,t){super({message:t,cause:e})}},Ld=O(`effect/Console`,{defaultValue:()=>globalThis.console}),Rd=_r(mr(fr,e=>{switch(e){case`All`:return-(2**53-1);case`Fatal`:return 5e4;case`Error`:return 4e4;case`Warn`:return 3e4;case`Info`:return 2e4;case`Debug`:return 1e4;case`Trace`:return 0;case`None`:return 2**53-1}})),zd=O(`effect/Logger/CurrentLoggers`,{defaultValue:()=>new Set([Jd,Yd])}),Bd=O(`effect/Logger/LogToStderr`,{defaultValue:s}),Vd={"~effect/Logger":{_Message:i,_Output:i},pipe(){return e(this,arguments)}},Hd=e=>{let t=Object.create(Vd);return t.log=e,t},Ud=e=>e.replace(/[\s="]/g,`_`),Wd=(e,t)=>`${Ud(e[0])}=${t-e[1]}ms`,Gd=e=>(...t)=>{let n;for(let e=0,r=t.length;e<r;e++){let r=t[e];tn(r)&&(n?t.splice(e,1):t=t.slice(0,e).concat(t.slice(e+1)),n=n?ln(n.reasons.concat(r.reasons)):r,e--)}return n===void 0&&(n=pn),w(r=>{let i=e??r.cache.logLevel;if(Rd(r.cache.minimumLogLevel,i))return N;let a=r.getRef(bd),o=r.getRef(zd);if(o.size>0){let e=new Date(a.currentTimeMillisUnsafe());for(let a of o)a.log({cause:n,fiber:r,date:e,logLevel:i,message:t})}return N})},Kd={bold:`1`,red:`31`,green:`32`,yellow:`33`,blue:`34`,cyan:`36`,white:`37`,gray:`90`,black:`30`,bgBrightRed:`101`};Kd.gray,Kd.blue,Kd.green,Kd.yellow,Kd.red,Kd.bgBrightRed,Kd.black;var qd=e=>`${e.getHours().toString().padStart(2,`0`)}:${e.getMinutes().toString().padStart(2,`0`)}:${e.getSeconds().toString().padStart(2,`0`)}.${e.getMilliseconds().toString().padStart(3,`0`)}`,Jd=Hd(({cause:e,date:t,fiber:n,logLevel:r,message:i})=>{let a=Array.isArray(i)?i.slice():[i];e.reasons.length>0&&a.push(Ns(e));let o=t.getTime(),s=n.getRef(as),c=``;for(let e of s)c+=` ${Wd(e,o)}`;let l=n.getRef(ts);Object.keys(l).length>0&&a.push(l);let u=n.getRef(Ld);(n.getRef(Bd)?u.error:u.log)(`[${qd(t)}] ${r.toUpperCase()} (#${n.id})${c}:`,...a)}),Yd=Hd(({cause:e,fiber:t,logLevel:n,message:r})=>{let i=t.getRef(bd),a=t.getRef(ts),o=t.cache.span;if(o===void 0||o._tag===`ExternalSpan`||o.status._tag===`Ended`)return;let s={};for(let[e,t]of Object.entries(a))dt(s,e,t);s[`effect.fiberId`]=t.id,s[`effect.logLevel`]=n.toUpperCase(),e.reasons.length>0&&(s[`effect.cause`]=Ns(e)),o.event(Mt(Array.isArray(r)&&r.length===1?r[0]:r),i.currentTimeNanosUnsafe(),s)}),Xd=A(void 0),Zd=tn,Qd=nn,$d=vn,ef=yn,tf=ln,nf=mn,rf=gn,af=us,of=e=>new cn(e),sf=e=>new hn(e),cf=ls,lf=xs,uf=Cs,df=ws,ff=fs,pf=ps,mf=_s,hf=ys,gf=Ts,_f=Pn,vf=In,yf=Bn,bf=Md,xf=Ss,Sf=bd,Cf=Od,wf=Qt,Tf=C,Ef=Dn,Df=On,Of=kn,kf=Kc,Af=Zc,jf=qc,Mf=Jc,Nf={"~effect/Deferred":{_A:i,_E:i},pipe(){return e(this,arguments)}},Pf=function(){this.resumes=void 0,this.effect=void 0};Pf.prototype=Nf;var Ff=()=>new Pf,If=e=>pc(t=>e.effect?t(e.effect):(e.resumes??=[],e.resumes.push(t),nc(()=>{let n=e.resumes;if(n===void 0)return;let r=n.indexOf(t);r>=0&&n.splice(r,1)}))),Lf=r(2,(e,t)=>nc(()=>Hf(e,t))),Rf=r(2,(e,t)=>Lf(e,Dn(t))),zf=r(2,(e,t)=>Rf(e,us(t))),Bf=e=>e.effect!==void 0,Vf=r(2,(e,t)=>Lf(e,C(t))),Hf=(e,t)=>{if(e.effect)return!1;if(e.effect=t,e.resumes){let n=e.resumes;e.resumes=void 0;for(let e=0;e<n.length;e++)n[e](t)}return!0},Uf=ts,Wf=Qo,Gf=ql,Kf=iu,qf=cu,Jf=eu,Yf=tu,Xf=$l,Zf=Jl,Qf=`~effect/Layer`,$f=`~effect/Layer/MemoMap`,ep=(e,t)=>{let n={observers:0,deferred:Ff(),scope:Kf(),finalizer:r=>M(()=>--n.observers>0?N:(e.map.delete(t),Zf(n.scope,r)))};return n},tp=(e,t)=>t.state._tag!==`Closed`&&(e.observers++,nu(t,{},e.finalizer),!0),np={[Qf]:{_ROut:i,_E:i,_RIn:i},pipe(){return e(this,arguments)}},rp=e=>{let t=Object.create(np);return t.build=e,t},ip=e=>rp((t,n)=>{let r=Xf(n);return gu(e(t,r),e=>e._tag===`Failure`?Zf(r,e):N)}),ap=e=>{let t=ip((n,r)=>n.getOrElseMemoize(t,r,e));return t},op=class{get[$f](){return $f}parent;constructor(e){this.parent=e}map=new Map;get(e,t){let n=this.map.get(e);return n?(tp(n,t),n.deferred.effect??If(n.deferred)):this.parent?.get(e,t)}getOrElseMemoize(e,t,n){return M(()=>{let r;return mu(M(()=>{let i=this.get(e,t);if(i)return i;let a=ep(this,e);return tp(a,t)?(r=a.deferred,this.map.set(e,a),n(this,a.scope)):n(this,t)}),e=>{r&&Hf(r,e)})})}},sp=()=>new op,cp=e=>new op(e),lp=class e extends Hi()(`effect/Layer/CurrentMemoMap`){static forkOrCreate(t){let n=ua(t,e);return n?cp(n):sp()}},up=r(3,(e,t,n)=>ul(Vc(M(()=>e.build(t,n)),ca(lp,t)),lp,t)),dp=r(2,(e,t)=>w(n=>up(e,lp.forkOrCreate(n.context),t))),fp=function(){return arguments.length===1?e=>pp(sa(arguments[0],e)):pp(sa(arguments[0],arguments[1]))},pp=e=>rp(a(A(e))),mp=function(){return arguments.length===1?e=>hp(()=>sa(arguments[0],e())):hp(()=>sa(arguments[0],arguments[1]()))},hp=e=>ap(a(nc(e))),gp=function(){return arguments.length===1?e=>_p(arguments[0],e):_p(arguments[0],arguments[1])},_p=(e,t)=>vp(Vc(t,t=>sa(e,t))),vp=e=>ap((t,n)=>qf(e,n)),yp=(e,t,n)=>{let r=Xf(n,`parallel`);return Iu(e,e=>e.build(t,Xf(r,`sequential`)),{concurrency:e.length}).pipe(Vc(e=>va(...e)))},bp=(...e)=>ap((t,n)=>yp(e,t,n)),xp=(e,t,n)=>ap((r,i)=>P(Array.isArray(t)?yp(t,r,i):t.build(r,i),t=>e.build(r,i).pipe(ll(t),Vc(e=>n(e,t))))),Sp=r(2,(e,t)=>xp(e,t,i)),Cp=r(2,(e,t)=>xp(e,t,(e,t)=>_a(t,e))),wp=e=>rp((t,n)=>Tl(e.build(t,n))),Tp=`~effect/DateTime`,Ep=`~effect/DateTime/TimeZone`,Dp={[Tp]:Tp,pipe(){return e(this,arguments)},[At](){return this.toString()},toJSON(){return rm(this).toJSON()}},Op={...Dp,_tag:`Utc`,[Se](){return ke(this.epochMilliseconds)},[Ve](e){return Rp(e)&&e._tag===`Utc`&&this.epochMilliseconds===e.epochMilliseconds},toString(){return`DateTime.Utc(${rm(this).toJSON()})`}},kp={...Dp,_tag:`Zoned`,[Se](){return Te(ke(this.epochMilliseconds))(y(this.zone))},[Ve](e){return Rp(e)&&e._tag===`Zoned`&&this.epochMilliseconds===e.epochMilliseconds&&b(this.zone,e.zone)},toString(){return`DateTime.Zoned(${gm(this)})`}},Ap={[Ep]:Ep,[At](){return this.toString()}},jp={...Ap,_tag:`Named`,[Se](){return Ae(`Named:${this.id}`)},[Ve](e){return zp(e)&&e._tag===`Named`&&this.id===e.id},toString(){return`TimeZone.Named(${this.id})`},toJSON(){return{_id:`TimeZone`,_tag:`Named`,id:this.id}}},Mp={...Ap,_tag:`Offset`,[Se](){return Ae(`Offset:${this.offset}`)},[Ve](e){return zp(e)&&e._tag===`Offset`&&this.offset===e.offset},toString(){return`TimeZone.Offset(${om(this.offset)})`},toJSON(){return{_id:`TimeZone`,_tag:`Offset`,offset:this.offset}}},Np={value:void 0,enumerable:!1,writable:!0},Pp=new WeakMap,Fp=(e,t)=>({get(){return Object.isExtensible(this)?void 0:Pp.get(this)?.[e]},set(n){if(Object.isExtensible(this)){for(let e of t)Object.defineProperty(this,e,Np);this[e]=n}else{let t=Pp.get(this);t===void 0&&(t={},Pp.set(this,t)),t[e]=n}}}),Ip=[`partsUtc`,`adjustedEpochMilliseconds`,`partsAdjusted`];Object.defineProperty(Op,"partsUtc",Fp(`partsUtc`,[`partsUtc`])),Object.defineProperties(kp,{partsUtc:Fp(`partsUtc`,Ip),adjustedEpochMilliseconds:Fp(`adjustedEpochMilliseconds`,Ip),partsAdjusted:Fp(`partsAdjusted`,Ip)});var Lp=(e,t,n)=>{let r=Object.create(kp);return r.epochMilliseconds=e,r.zone=t,n!==void 0&&(r.partsUtc=n),r},Rp=e=>v(e,Tp),zp=e=>v(e,Ep),Bp=e=>e._tag===`Zoned`,Vp=e=>{let t=Object.create(Op);return t.epochMilliseconds=e,t},Hp=e=>{let t=e.getTime();if(Number.isNaN(t))throw new bf(`Invalid date`);return Vp(t)},Up=e=>{if(Rp(e))return e;if(e instanceof Date)return Hp(e);if(typeof e==`object`){if(`epochMilliseconds`in e)return Hp(new Date(e.epochMilliseconds));let t=new Date(0);return lm(t,e),Hp(t)}return typeof e==`string`&&!Wp(e)?Hp(new Date(e+`Z`)):Hp(new Date(e))},Wp=e=>/Z|GMT|[+-]\d{2}$|[+-]\d{2}:?\d{2}$|\]$/.test(e)||/z$|gmt$/i.test(e),Gp=-864e13+432e5,Kp=864e13-504e5,qp=(e,t)=>{let n=t?.timeZone;if(n===void 0&&Rp(e)&&Bp(e))return e;let r=Up(e);if(r.epochMilliseconds<Gp||r.epochMilliseconds>Kp)throw RangeError(`Epoch millis out of range: ${r.epochMilliseconds}`);n===void 0&&typeof e==`object`&&`timeZoneId`in e&&(n=e.timeZoneId);let i;if(n===void 0)i=$p(new Date(r.epochMilliseconds).getTimezoneOffset()*-60*1e3);else if(zp(n))i=n;else if(typeof n==`number`)i=$p(n);else{let e=nm(n);if(Cr(e))throw new bf(`Invalid time zone: ${n}`);i=e.value}return t?.adjustForTimeZone===!0?dm(r.epochMilliseconds,i,t?.disambiguation??`compatible`):Lp(r.epochMilliseconds,i,r.partsUtc)},Jp=()=>Vp(Date.now()),Yp=new Map,Xp={day:`numeric`,month:`numeric`,year:`numeric`,era:`short`,hour:`numeric`,minute:`numeric`,second:`numeric`,timeZoneName:`longOffset`,fractionalSecondDigits:3,hourCycle:`h23`},Zp=e=>{let t=e.resolvedOptions().timeZone,n=Yp.get(t);if(n!==void 0)return n;let r=Object.create(jp);return r.id=t,r.format=e,Yp.set(t,r),r},Qp=e=>{let t=Yp.get(e);if(t!==void 0)return t;try{let t=Zp(new Intl.DateTimeFormat(`en-US`,{...Xp,timeZone:e}));return Yp.set(e,t),t}catch{throw new bf(`Invalid time zone: ${e}`)}},$p=e=>{let t=Object.create(Mp);return t.offset=e,t},em=Mr(Qp),tm=/^(?:GMT)?[+-]/,nm=e=>{if(tm.test(e)){let t=pm(e);return t===null?T():E($p(t))}return em(e)},rm=e=>new Date(e.epochMilliseconds),im=e=>{if(e._tag===`Utc`)return new Date(e.epochMilliseconds);if(e.zone._tag===`Offset`)return new Date(e.epochMilliseconds+e.zone.offset);if(e.adjustedEpochMilliseconds!==void 0)return new Date(e.adjustedEpochMilliseconds);let t=!1,n=e.zone.format.formatToParts(e.epochMilliseconds).filter(e=>e.type===`era`?(t=e.value===`BC`,!1):e.type!==`literal`),r=Number(n[2].value),i=new Date(0);return i.setUTCFullYear(t?1-r:r,Number(n[0].value)-1,Number(n[1].value)),i.setUTCHours(Number(n[3].value),Number(n[4].value),Number(n[5].value),n[6]?.type===`fractionalSecond`?Number(n[6].value):(e.epochMilliseconds%1e3+1e3)%1e3),e.adjustedEpochMilliseconds=i.getTime(),i},am=e=>im(e).getTime()-cm(e),om=e=>{let t=Math.abs(e),n=Math.floor(t/36e5),r=Math.round(t%36e5/6e4);return r===60&&(n+=1,r=0),`${e<0?`-`:`+`}${String(n).padStart(2,`0`)}:${String(r).padStart(2,`0`)}`},sm=e=>om(am(e)),cm=e=>e.epochMilliseconds,lm=(e,t)=>{if((t.year!==void 0||t.month!==void 0||t.day!==void 0)&&e.setUTCFullYear(t.year??e.getUTCFullYear(),t.month===void 0?e.getUTCMonth():t.month-1,t.day??e.getUTCDate()),t.weekDay!==void 0){let n=t.weekDay-e.getUTCDay();e.setUTCDate(e.getUTCDate()+n)}t.hour!==void 0&&e.setUTCHours(t.hour),t.minute!==void 0&&e.setUTCMinutes(t.minute),t.second!==void 0&&e.setUTCSeconds(t.second),t.millisecond!==void 0&&e.setUTCMilliseconds(t.millisecond)},um=864e5,dm=(e,t,n)=>{if(t._tag===`Offset`)return Lp(e-t.offset,t);let r=mm(e-um,e,t),i=mm(e+um,e,t);if(r===i)return Lp(e-r,t);let a=r<i,o=r-i;if(a){if(mm(e-i,e,t)===i)return Lp(e-i,t);let a=Lp(e-r,t);if(e!==im(a).getTime())switch(n){case`reject`:{let n=new Date(e).toISOString();throw RangeError(`Gap time: ${n} does not exist in time zone ${t.id}`)}case`earlier`:return Lp(e-i,t);case`compatible`:case`later`:return a}return a}if(mm(e-r,e,t)===r){if(n===`earlier`||n===`compatible`||mm(e-r+o,e+o,t)===r)return Lp(e-r,t);if(n===`reject`){let n=new Date(e).toISOString();throw RangeError(`Ambiguous time: ${n} occurs twice in time zone ${t.id}`)}}return Lp(e-i,t)},fm=/([+-])(\d{2}):?(\d{2})$/,pm=e=>{let t=fm.exec(e);if(t===null)return null;let[,n,r,i]=t;return(n===`+`?1:-1)*(Number(r)*60+Number(i))*60*1e3},mm=(e,t,n)=>{let r=n.format.formatToParts(e).find(e=>e.type===`timeZoneName`)?.value??``;if(r===`GMT`)return 0;let i=pm(r);return i===null?am(Lp(t,n)):i},hm=e=>{let t=im(e);return e._tag===`Utc`?t.toISOString():`${t.toISOString().slice(0,-1)}${sm(e)}`},gm=e=>e.zone._tag===`Offset`?hm(e):`${hm(e)}[${e.zone.id}]`,_m=globalThis.Number,vm=xr(fr),ym=e=>{if(e===`NaN`)return E(NaN);if(e===`Infinity`)return E(1/0);if(e===`-Infinity`)return E(-1/0);if(e.trim()===``)return T();let t=_m(e);return _m.isNaN(t)?T():E(t)},bm=r(2,(e,t)=>{let n=10**t;return Math.round(e*n)/n}),xm=globalThis.String,Sm=re,Cm=e=>e.toUpperCase(),wm=e=>e.toLowerCase(),Tm=(e,t)=>n=>n.replace(e,t),Em=e=>e.trim(),Dm=(e,t)=>n=>n.slice(e,t),Om=e=>e.length===0,km=e=>e.length>0,Am=r(2,(e,t)=>{let n=e.split(t);return ct(n)?n:[e]}),jm=(e,t)=>n=>n.startsWith(e,t),Mm=e=>t=>Ar(t.match(e)),Nm=r(2,(e,t)=>vl(e,Lm,e=>t(e))),Pm=e=>e.reasons.some(Fm),Fm=e=>e._tag===`Fail`&&vf(e.error),Im=e=>{let t,n=!1;for(let r of e.reasons)Fm(r)?t??=r.error:r._tag!==`Interrupt`&&(n=!0);return t===void 0?Vr(e):n?Vr(tf(e.reasons.filter(e=>!Fm(e)))):Br(t)},Lm=e=>{let t=Im(e);return Wr(t)?t:Br(t.success.value)},Rm=e=>{let t=Im(e);return Wr(t)?Ef(t.failure):Tf(t.success.value)},zm=r(2,(e,t)=>Al(e,{onSuccess:t.onSuccess,onFailure:e=>{let n=Im(e);return Wr(n)?t.onFailure(n.failure):t.onDone(n.success.value)}})),Bm=`~effect/Schedule`,Vm=O(`effect/Schedule/CurrentMetadata`,{defaultValue:a({input:void 0,output:void 0,duration:ro,attempt:0,start:0,now:0,elapsed:0,elapsedSincePrevious:0})}),Hm={[Bm]:{_Out:i,_In:i,_Env:i},pipe(){return e(this,arguments)}},Um=e=>{let t=Object.create(Hm);return t.step=e,t},Wm=()=>{let e=0,t,n;return(r,i)=>{n===void 0&&(n=r);let a=r-n,o=t===void 0?0:r-t;return t=r,{input:i,attempt:++e,start:n,now:r,elapsed:a,elapsedSincePrevious:o}}},Gm=e=>Um(Vc(e,e=>{let t=Wm();return(n,r)=>e(t(n,r))})),Km=e=>ml(e.step,e=>A(()=>j(e))),qm=e=>Ed(t=>Vc(Km(e),e=>{let n=Wm();return r=>M(()=>{let i=t.currentTimeMillisUnsafe();return P(e(i,r),([e,t])=>{let a=n(i,r);return a.output=e,a.duration=t,Sc(Dd(t),a)})})})),Jm=e=>Um(Vc(Pu(e.map(Km)),e=>(t,n)=>P(Iu(e,e=>zm(e(t,n),{onSuccess:e=>A(e[1]),onDone:()=>Xd,onFailure:j})),e=>{let t=Ym(e);return t===void 0?yf(ro):A([t,t])}))),Ym=e=>{let t;for(let n=0;n<e.length;n++){let r=e[n];r!==void 0&&(t=t===void 0?r:_o(t,r))}return t},Xm=(e,t=2)=>{let n=uo(Ha(e));return Gm(A(e=>{let r=so(n*t**(e.attempt-1));return A([r,r])}))},Zm=e=>{let t=Ha(e);return Gm(A(e=>A([e.attempt-1,t])))},Qm=r(2,(e,t)=>Um(Vc(Km(e),e=>{let n=Wm();return(r,i)=>P(e(r,i),e=>{let[a,o]=e,s=t({...n(r,i),output:a,duration:o});return P(Zt(s)?s:A(s),t=>t?A(e):yf(a))})}))),$m=(e,t,n)=>uu(r=>P(n?.local?up(t,sp(),r):dp(t,r),t=>ll(e,t))),eh=r(e=>Zt(e[0]),(e,t,n)=>ra(t)?ll(e,t):$m(e,Array.isArray(t)?bp(...t):t,n)),th=r(3,(e,t,n)=>P(qm(t),t=>{let r=Vm.defaultValue(),i,a=vl(M(()=>ul(e,Vm,r)),gs,e=>(i=e,P(t(e),e=>(r=e,a))));return Nm(a,e=>zt(()=>n(i,e)))})),nh=`~effect/MutableHashMap`,rh={[nh]:nh,[Symbol.iterator](){return this.backing[Symbol.iterator]()},toString(){return`MutableHashMap(${x(Array.from(this))})`},toJSON(){return{_id:`MutableHashMap`,values:jt(Array.from(this))}},[At](){return this.toJSON()},pipe(){return e(this,arguments)}},ih=()=>{let e=Object.create(rh);return e.backing=new Map,e.buckets=new Map,e},ah=r(2,(e,t)=>{if(e.backing.has(t))return E(e.backing.get(t));if(oh(t))return T();let n=y(t),r=e.buckets.get(n);return r===void 0?T():sh(e,r,t)}),oh=e=>typeof e!=`object`&&typeof e!=`function`,sh=(e,t,n)=>{for(let r=0,i=t.length;r<i;r++)if(b(n,t[r])){let n=t[r];return E(e.backing.get(n))}return T()},ch=r(3,(e,t,n)=>{if(e.backing.has(t)||oh(t))return e.backing.set(t,n),e;let r=y(t),i=e.buckets.get(r);if(i===void 0)return e.buckets.set(r,[t]),e.backing.set(t,n),e;let a=lh(i,t);return a===void 0&&(i.push(t),a=t),e.backing.set(a,n),e}),lh=(e,t)=>{for(let n=0,r=e.length;n<r;n++)if(b(t,e[n]))return e[n]},uh=r(2,(e,t)=>{if(oh(t))return e.backing.delete(t),e;let n=y(t),r=e.buckets.get(n);if(r===void 0)return e;for(let n=0,i=r.length;n<i;n++){let i=r[n];if(i===t||b(t,i)){e.backing.delete(i),r.splice(n,1);break}}return r.length===0&&e.buckets.delete(n),e}),dh=Zt,fh=Iu,ph=Fu,mh=lc,hh=uc,I=A,gh=ac,L=M,R=nc,z=N,_h=pc,vh=mc,yh=hc,B=tc,bh=j,xh=oc,Sh=sc,Ch=cc,wh=w,Th=rc,V=P,Eh=Bc,Dh=Pc,Oh=Fc,kh=Rl,H=Vc,Ah=Sc,jh=Ic,Mh=ml,Nh=_l,Ph=Cl,Fh=Tl,Ih=Sl,Lh=bl,Rh=th,zh=Dl,Bh=Ol,Vh=Ul,Hh=Vl,Uh=Bl,Wh=Dd,Gh=Rc,Kh=fl,qh=Al,Jh=ol,Yh=cl,Xh=eh,Zh=ll,Qh=rl,$h=il,eg=ul,tg=su,ng=lu,rg=uu,ig=du,ag=fu,og=_u,sg=yu,cg=mu,lg=gu,ug=wu,dg=Tu,fg=Mu,pg=xu,mg=Eu,hg=Nu,gg=pl,_g=md,vg=_d,yg=yd,bg=Ku,xg=qu,Sg=Wu,Cg=Xu,wg=Ju,Tg=Zu,Eg=ed,Dg=$u,Og=id,kg=rd,Ag=nd,jg=_c,Mg=Gd(`Error`),Ng=r(e=>dh(e[0]),(e,...t)=>al(e,Uf,e=>{let n=t.length===1?{...e,...t[0]}:{...e};return t.length===1||dt(n,t[0],t[1]),n})),Pg=Hc,Fg=Uc,Ig=Wc,Lg=zc,Rg=Gc,zg=yc,Bg=Xs,Vg=Zs,Hg=Qs,Ug=Vs,Wg=Yu,Gg=`~effect/Chunk`;function Kg(e,t,n,r,i){for(let a=t;a<Math.min(e.length,t+i);a++)n[r+a-t]=e[a];return n}var qg=[],Jg=(e=>rt((t,n)=>{if(t.length!==n.length)return!1;let r=e_(t),i=e_(n);for(let t=0;t<r.length;t++)if(!e(r[t],i[t]))return!1;return!0}))(b),Yg={[Gg]:{_A:e=>e},toString(){return`Chunk(${x(e_(this))})`},toJSON(){return{_id:`Chunk`,values:jt(e_(this))}},[At](){return this.toJSON()},[Ve](e){return Zg(e)&&Jg(this,e)},[Se](){return Pe(e_(this))},[Symbol.iterator](){switch(this.backing._tag){case`IArray`:return this.backing.array[Symbol.iterator]();case`IEmpty`:return qg[Symbol.iterator]();default:return e_(this)[Symbol.iterator]()}},pipe(){return e(this,arguments)}},Xg=e=>{let t=Object.create(Yg);switch(t.backing=e,e._tag){case`IEmpty`:t.length=0,t.depth=0,t.left=t,t.right=t;break;case`IConcat`:t.length=e.left.length+e.right.length,t.depth=1+Math.max(e.left.depth,e.right.depth),t.left=e.left,t.right=e.right;break;case`IArray`:t.length=e.array.length,t.depth=0,t.left=Qg,t.right=Qg;break;case`ISingleton`:t.length=1,t.depth=0,t.left=Qg,t.right=Qg;break;case`ISlice`:t.length=e.length,t.depth=0,t.left=Qg,t.right=Qg}return t},Zg=e=>v(e,Gg),Qg=Xg({_tag:`IEmpty`}),$g=(e,t,n)=>{switch(e.backing._tag){case`IArray`:Kg(e.backing.array,0,t,n,e.length);break;case`IConcat`:$g(e.left,t,n),$g(e.right,t,n+e.left.length);break;case`ISingleton`:t[n]=e.backing.a;break;case`ISlice`:Kg(e_(e.backing.chunk),e.backing.offset,t,n,e.length)}},e_=e=>{switch(e.backing._tag){case`IEmpty`:return qg;case`IArray`:return e.backing.array;default:{let t=Array(e.length);return $g(e,t,0),e.backing={_tag:`IArray`,array:t},e.left=Qg,e.right=Qg,e.depth=0,t}}},t_=cd,n_=`~effect/MutableRef`,r_={[n_]:n_,...Yt,toJSON(){return{_id:`MutableRef`,current:jt(this.current)}}},i_=e=>{let t=Object.create(r_);return t.current=e,t},a_=r(2,(e,t)=>(e.current=t,e)),o_=Symbol.for(`effect/MutableList/Empty`),s_=()=>({head:void 0,tail:void 0,length:0}),c_=e=>{let t=e.head;t.offset>=1024&&t===e.tail&&t.mutable&&(t.array.length-t.offset)*8<=t.offset&&(e.head=e.tail={array:t.array.slice(t.offset),mutable:!0,offset:0,next:void 0})},l_=()=>({array:[],mutable:!0,offset:0,next:void 0}),u_=(e,t)=>{e.tail?e.tail.mutable||(e.tail.next=l_(),e.tail=e.tail.next):e.head=e.tail=l_(),e.tail.array.push(t),e.length++},d_=(e,t)=>f_(e,Array.from(t),!0),f_=(e,t,n=!1)=>{if(t.length===0)return 0;let r={array:t,mutable:n,offset:0,next:void 0};return e.head?e.tail=e.tail.next=r:e.head=e.tail=r,e.length+=t.length,t.length},p_=e=>{e.head=e.tail=void 0,e.length=0},m_=(e,t)=>{if(t=lt(t),t<=0||!e.head)return[];if(t=Math.min(t,e.length),t===e.length&&e.head?.offset===0&&!e.head.next){let t=e.head.array;return p_(e),t}let n=Array(t),r=0,i=e.head;for(;i;){for(;i.offset<i.array.length;)if(n[r++]=i.array[i.offset],i.mutable&&(i.array[i.offset]=void 0),i.offset++,r===t)return e.head=i.offset===i.array.length&&i.next?i.next:i,e.length-=t,e.length===0?p_(e):c_(e),n;i=i.next}return p_(e),n},h_=e=>m_(e,e.length),g_=e=>{if(!e.head)return o_;let t=e.head.array[e.head.offset];return e.head.mutable&&(e.head.array[e.head.offset]=void 0),e.head.offset++,e.length--,e.head.offset===e.head.array.length?e.head.next?e.head=e.head.next:p_(e):c_(e),t},__=(e,t)=>{let n=[],r=e.head,i=0;for(;r;){for(let e=r.offset;e<r.array.length;e++)t(r.array[e],i++)&&n.push(r.array[e]);r=r.next}n.length===0?p_(e):(e.head=e.tail={array:n,mutable:!0,offset:0,next:void 0},e.length=n.length)},v_=(e,t)=>__(e,e=>e!==t),y_=`~effect/PubSub/Subscription`,b_=r(2,(e,t)=>e.shutdownFlag.current||wr(e.ended.current)?!1:e.pubsub.publish(t)?(e.strategy.completeSubscribersUnsafe(e.pubsub,e.subscribers),!0):!1),x_=e=>mg(Yh(t=>{let n=D(t,Gf),r=Xf(e.scope),i=T_(e.pubsub,e.subscribers,e.strategy,e.ended);return Yf(r,S_(i)).pipe(Dh(Jf(n,e=>Zf(r,e))),Ah(i))})),S_=e=>mg(wh(t=>(a_(e.shutdownFlag,!0),fh(h_(e.pollers),e=>zf(e,t.id),{discard:!0,concurrency:`unbounded`}).pipe(Oh(()=>R(()=>{e.subscribers.delete(e.subscription),e.subscription.unsubscribe(),e.replayWindow.close(),e.strategy.onPubSubEmptySpaceUnsafe(e.pubsub,e.subscribers)})),Kh(e.shutdownHook.open),jh)))),C_=e=>L(function t(n){if(e.shutdownFlag.current)return dg;let r=e.pollers.length===0?e.subscription.pollUpTo(1/0):[];return n&&(r=n.concat(r)),e.strategy.onPubSubEmptySpaceUnsafe(e.pubsub,e.subscribers),e.replayWindow.remaining>0?I(e.replayWindow.takeAll().concat(r)):hi(r)?I(r):V(w_(e),e=>t([e]))}),w_=e=>_h(t=>{if(e.shutdownFlag.current)return t(dg);if(wr(e.ended.current)){let n=e.pollers.length===0?e.subscription.poll():o_;return n===o_?t(I(e.ended.current.value)):(e.strategy.onPubSubEmptySpaceUnsafe(e.pubsub,e.subscribers),t(I(n)))}let n=Ff(),r=e.subscribers.get(e.subscription);return r||(r=new Set,e.subscribers.set(e.subscription,r)),r.add(e.pollers),u_(e.pollers,n),e.strategy.completePollersUnsafe(e.pubsub,e.subscribers,e.subscription,e.pollers),n.effect?t(n.effect):(n.resumes=[t],R(()=>v_(e.pollers,n)))}),T_=(e,t,n,r)=>new E_(e,t,e.subscribe(),s_(),t_(!1),i_(!1),n,e.replayWindow(),r),E_=class{[y_]={_A:i};pubsub;subscribers;subscription;pollers;shutdownHook;shutdownFlag;strategy;replayWindow;ended;constructor(e,t,n,r,i,a,o,s,c){this.pubsub=e,this.subscribers=t,this.subscription=n,this.pollers=r,this.shutdownHook=i,this.shutdownFlag=a,this.strategy=o,this.replayWindow=s,this.ended=c}pipe(){return e(this,arguments)}},D_=`~effect/Queue`,O_=`~effect/Queue/Enqueue`,k_=`~effect/Queue/Dequeue`,A_={_A:i,_E:i},j_={[D_]:A_,[O_]:A_,[k_]:A_,...Yt,toJSON(){return{_id:`effect/Queue`,state:this.state._tag,size:q_(this)}}},M_=e=>w(t=>{let n=Object.create(j_);return n.dispatcher=t.currentDispatcher,n.capacity=e?.capacity??1/0,n.strategy=e?.strategy??`suspend`,n.messages=s_(),n.scheduleRunning=!1,n.state={_tag:`Open`,takers:new Set,offers:new Set,awaiters:new Set},A(n)}),N_=e=>M_({capacity:e}),P_=r(2,(e,t)=>M(()=>F_(e,t)?Y_:e.state._tag===`Open`&&e.strategy===`suspend`?iv(e,t):J_)),F_=(e,t)=>e.state._tag===`Open`?e.messages.length>=e.capacity?e.strategy===`sliding`?(g_(e.messages),u_(e.messages,t),!0):e.capacity<=0&&e.state.takers.size>0&&(u_(e.messages,t),Q_(e),!0):(u_(e.messages,t),$_(e),!0):!1,I_=r(2,(e,t)=>pc(n=>{let r=L_(e,t);return r.length===0||e.strategy===`dropping`?n(C(r)):av(e,{_tag:`Array`,remaining:r,offset:0,resume:n})})),L_=(e,t)=>{if(e.state._tag!==`Open`)return ui(t);if(e.capacity===1/0||e.strategy===`sliding`)return d_(e.messages,t),e.strategy===`sliding`&&m_(e.messages,e.messages.length-e.capacity),$_(e),[];let n=e.capacity<=0?e.state.takers.size:e.capacity-e.messages.length;if(n===0)return ui(t);let r=[],i=0;for(let a of t)i<n?u_(e.messages,a):r.push(a),i++;return $_(e),r},R_=r(2,(e,t)=>nc(()=>z_(e,t))),z_=(e,t)=>{if(e.state._tag!==`Open`)return!1;let n=tl(Dn(t),X_);return e.state.offers.size===0&&e.messages.length===0?(lv(e,n),!0):(e.state={...e.state,_tag:`Closing`,exit:n},$_(e),!0)},B_=e=>R_(e,mn(Rn())),V_=e=>nc(()=>H_(e)),H_=e=>{if(e.state._tag===`Done`)return!1;p_(e.messages);let t=e.state.offers;lv(e,e.state._tag===`Open`?Z_:e.state.exit);for(let e of t)ov(e);return!0},U_=e=>W_(e,1,1/0),W_=r(3,(e,t,n)=>(t=lt(t),n=lt(n),tv(()=>ev(e,t,n)??Pc(rv(e,()=>nv(e,t)),W_(e,t,n))))),G_=e=>tv(()=>K_(e)??Pc(rv(e,()=>nv(e,1)),G_(e))),K_=e=>{if(e.state._tag===`Done`)return e.state.exit;if(e.messages.length>0){let t=g_(e.messages);return cv(e),C(t)}if(e.capacity<=0&&e.state.offers.size>0){let t=sv(e.state.offers);return cv(e),C(t)}},q_=e=>e.state._tag===`Done`?0:e.messages.length,J_=C(!1),Y_=C(!0),X_=On(Rn()),Z_=Kc(),Q_=e=>{if(e.state._tag!==`Done`&&e.state.takers.size!==0){for(let t of e.state.takers)if(t.ready()&&(e.state.takers.delete(t),t.resume(Zc),e.messages.length===0))break}},$_=e=>{e.scheduleRunning||e.state._tag===`Done`||e.state.takers.size===0||(e.scheduleRunning=!0,e.dispatcher.scheduleTask(()=>{e.scheduleRunning=!1,Q_(e)},0))},ev=(e,t,n)=>{if(e.state._tag===`Done`)return e.state.exit;if(n<=0||t<=0)return C([]);if(!nv(e,t))return;let r=e.messages.length>0?m_(e.messages,n):[sv(e.state.offers)];return cv(e),C(r)},tv=Cn({op:`QueueTake`,[Wt](e){let t=this[S]();return Qt(t)?t[Wt](e):t}}),nv=(e,t)=>e.messages.length>=(e.state._tag===`Closing`?1:Math.min(t,e.capacity||1))||e.capacity<=0&&e.state._tag!==`Done`&&e.state.offers.size>0,rv=(e,t)=>pc(n=>{if(e.state._tag===`Done`)return n(e.state.exit);if(t())return n(Zc);let r={ready:t,resume:n};return e.state.takers.add(r),nc(()=>{e.state._tag!==`Done`&&e.state.takers.delete(r)})}),iv=(e,t)=>pc(n=>F_(e,t)?n(Y_):av(e,{_tag:`Single`,message:t,resume:n})),av=(e,t)=>{if(e.state._tag!==`Open`)return ov(t);let n=e.state.offers;return n.add(t),nc(()=>{e.state._tag!==`Done`&&(n.delete(t),e.state._tag===`Closing`&&n.size===0&&e.messages.length===0&&lv(e,e.state.exit))})},ov=e=>e._tag===`Single`?e.resume(J_):e.resume(C(e.remaining.slice(e.offset))),sv=e=>{let t=e.values().next().value;if(t._tag===`Single`)return e.delete(t),t.resume(Y_),t.message;let n=t.remaining[t.offset++];return t.offset===t.remaining.length&&(e.delete(t),t.resume(C([]))),n},cv=e=>{if(e.state._tag===`Done`)return Pm(e.state.exit.cause);if(e.state.offers.size===0)return e.state._tag===`Closing`&&e.messages.length===0&&(lv(e,e.state.exit),Pm(e.state.exit.cause));for(let t of e.state.offers){let n=e.capacity-e.messages.length;if(n<=0)break;if(t._tag===`Single`)u_(e.messages,t.message),e.state.offers.delete(t),t.resume(Y_);else{for(;t.offset<t.remaining.length;t.offset++){if(n===0)return!1;u_(e.messages,t.remaining[t.offset]),n--}e.state.offers.delete(t),t.resume(C([]))}let r=e.state;if(r._tag===`Done`)return Pm(r.exit.cause)}return!1},lv=(e,t)=>{if(e.state._tag===`Done`)return;let n=e.state;e.state={_tag:`Done`,exit:t};for(let e of n.takers)e.resume(t);n.takers.clear();for(let e of n.awaiters)e(t);n.awaiters.clear()},uv=e=>new pv(e),dv=e=>{for(let t of e.waiters)if(t.permits<=e.free)return t},fv=(e,t,n,r=i)=>w(i=>{if(e.free>=t&&dv(e)===void 0)return e.taken+=t,n();let a={permits:t,resume:void 0},o=()=>{e.waiters.delete(a)&&e.releaseUnsafe(i,0)};e.waiters.add(a),hu(i,o);let s=P(r(pc(t=>{dv(e)===a?t(N):a.resume=t})),()=>dv(e)===a?(e.taken+=t,o(),n()):s);return s}),pv=class{waiters=new Set;taken=0;permits;constructor(e){this.permits=e}get free(){return this.permits-this.taken}take(e){return fv(this,e,()=>A(e))}takeScoped(e){return Nu(t=>P(su,n=>fv(this,e,()=>tu(n,this.release(e)),t)))}takeIfAvailable(e){return M(()=>this.free<e?A(!1):(this.taken+=e,A(!0)))}releaseUnsafe(e,t){return this.taken-=t,this.waiters.size>0&&e.currentDispatcher.scheduleTask(()=>{let e=this.free;for(let t of Array.from(this.waiters)){if(!this.waiters.has(t)||t.permits>e)continue;e-=t.permits;let n=t.resume;t.resume=void 0,n?.(N)}},0),this.free}resize(e){return w(t=>(this.permits=e,this.free<0||this.releaseUnsafe(t,0),N))}release(e){return w(t=>A(this.releaseUnsafe(t,e)))}get releaseAll(){return w(e=>A(this.releaseUnsafe(e,this.taken)))}withPermits(e){return t=>Nu(n=>fv(this,e,()=>mu(n(t),()=>{this.releaseUnsafe(Vs(),e)},!0),n))}withPermit=this.withPermits(1);withPermitsIfAvailable(e){return t=>Nu(n=>this.free<e?ac:(this.taken+=e,mu(n(Nc(t)),()=>{this.releaseUnsafe(Vs(),e)},!0)))}},mv=`~effect/Channel`,hv=e=>v(e,mv),gv={[mv]:{_Env:i,_InErr:i,_InElem:i,_OutErr:i,_OutElem:i},pipe(){return e(this,arguments)}},_v=e=>{let t=Object.create(gv);return t.transform=(t,n)=>Mh(e(t,n),e=>I(bh(e))),t},vv=(e,t)=>_v((n,r)=>V(xv(e)(n,r),e=>t(e,r))),yv=e=>_v((t,n)=>e),bv=e=>_v(jg(function*(t,n){let r=Xf(n),i=e=>Zf(r,Rm(e));return sg(yield*sg(e(t,n,r),i),i)})),xv=e=>e.transform,Sv=(e,t,n)=>M_({capacity:n?.bufferSize,strategy:n?.strategy}).pipe(Oh(t=>Yf(e,V_(t))),Oh(n=>qf(t(n),e).pipe(Mh(e=>R_(n,e)),bg(e,{startImmediately:!0})))),Cv=(e,t)=>_v((n,r)=>H(Sv(r,e,t),U_)),wv=e=>_v((t,n)=>L(()=>xv(e())(t,n))),Tv=yv(I(yf())),Ev=e=>yv(I(B(e))),Dv=e=>yv(I(U_(e))),Ov=e=>yv(I(pg(C_(e),()=>yf()))),kv=e=>Hv(H(x_(e),Ov)),Av=e=>_v((t,n)=>jv({scope:n,readable:e.evaluate(),onError:e.onError,releaseLockOnEnd:e.releaseLockOnEnd})),jv=e=>{let t=e.readable.getReader(),n=e.exit??i_(void 0),r=L(()=>n.current?n.current:qh(hh({try:()=>t.read(),catch:e.onError}),{onFailure:e=>n.current??bh(e),onSuccess:({done:e,value:t})=>n.current?n.current:e?yf():I(Ai(t))}));return Ah(Yf(e.scope,e.releaseLockOnEnd?R(()=>t.releaseLock()):mh(()=>t.cancel().catch(e=>t.closed.then(()=>Promise.reject(e),l))).pipe(og(R(()=>t.releaseLock())))),r)},Mv=r(2,(e,t)=>vv(e,e=>R(()=>{let n=0;return H(e,e=>t(e,n++))}))),Nv=e=>e===void 0||e!==`unbounded`&&e<=1,Pv=r(e=>hv(e[0]),(e,t,n)=>Nv(n?.concurrency)?Fv(e,t):Iv(e,t,n)),Fv=(e,t)=>_v((n,r)=>{let i=0;return H(xv(e)(n,r),V(e=>t(e,i++)))}),Iv=(e,t,n)=>bv(jg(function*(r,i,o){let s=0,c=yield*xv(e)(r,i),l=n.concurrency===`unbounded`?2**53-1:Math.min(n.concurrency,2**53-1),u=yield*N_(0);yield*Yf(o,V_(u));let d=wg(yield*Jh()),f=Wg(o);if(n.unordered){let e=uv(l),n=a(e.release(1)),r=qh({onFailure:e=>V(R_(u,e),n),onSuccess:e=>V(P_(u,e),n)});yield*e.take(1).pipe(V(()=>c),V(e=>{let n=s++;return f(d(r(L(()=>t(e,n))))),z}),gg({disableYield:!0}),Mh(t=>e.withPermits(l-1)(R_(u,t))),bg(o))}else{let e=yield*N_(l-2);yield*Yf(o,V_(e)),yield*G_(e).pipe(Eh,V(e=>P_(u,e)),gg({disableYield:!0}),Mh(e=>R_(u,e)),bg(o));let n,r=e=>{e._tag!==`Success`&&(n=e.cause,z_(u,e.cause))};yield*c.pipe(V(i=>{if(n)return bh(n);let a=s++,o=d(L(()=>t(i,a)));return f(o),o.addObserver(r),P_(e,Bg(o))}),gg({disableYield:!0}),Mh(t=>P_(e,Ef(t)).pipe(Dh(R_(e,t)))),bg(o))}return G_(u)})),Lv=e=>vv(e,e=>{let t,n=0;return I(L(function r(){if(t===void 0)return V(e,e=>{switch(e.length){case 0:return r();case 1:return I(e[0]);default:return t=e,I(e[n++])}});let i=t[n++];return n>=t.length&&(t=void 0,n=0),I(i)}))}),Rv=(e,t)=>_v((n,r)=>R(()=>{let i,a=()=>{let o=Xf(r);return V(xv(e)(n,o),e=>(i=Mh(e,e=>{let n=Rm(e);return Zf(o,n).pipe(V(()=>t(n,r)),V(a))}),i))};return L(()=>i??a())})),zv=r(2,(e,t)=>vv(e,e=>I(V(e,function n(r){let i=[];for(let e=0;e<r.length;e++)t(r[e])&&i.push(r[e]);return gi(i)?I(i):V(e,n)})))),Bv=r(2,(e,t)=>wv(()=>{let n,r=Vm.defaultValue(),a=Gv(Zv(e,Vm,R(()=>r)),()=>(n=void 0,z)),o=typeof t==`function`?t(i):t;return Rv(a,(e,t)=>{if(jf(e))return yf(e.value);let i=gs(e.cause);return Wr(i)?bh(i.failure):yh(function*(){n||=yield*qm(o),r=yield*n(i.success)}).pipe(Nm(()=>B(i.success)),qf(t))})})),Vv=r(e=>hv(e[0])&&hv(e[1]),(e,t,n)=>bv(jg(function*(r,i,a){let o=n?.haltStrategy??`both`,s=yield*N_(0);yield*Yf(a,V_(s));let c=0;function l(e,t){if(c++,!Pm(t))return R_(s,t);switch(o){case`both`:return c===2?R_(s,t):z;case`left`:case`right`:return e===o?R_(s,t):z;case`either`:return R_(s,t)}}let u=(e,t,n)=>xv(t)(r,n).pipe(V(e=>e.pipe(V(e=>P_(s,e)),gg)),sg(t=>cg(Rm(t),e=>Zf(n,e)).pipe(qh({onFailure:t=>l(e,t),onSuccess:()=>l(e,t)}))),bg(a));return yield*u(`left`,e,Xf(a)),yield*u(`right`,t,Xf(a)),G_(s)}))),Hv=e=>_v((t,n)=>{let r;return I(L(()=>r||e.pipe(qf(n),V(e=>xv(e)(t,n)),V(e=>r=e))))}),Uv=r(2,(e,t)=>Vv(e,yv(I(V(t,yf))),{haltStrategy:`either`})),Wv=r(2,(e,t)=>bv((n,r,i)=>Jf(i,t).pipe(Dh(xv(e)(n,r))))),Gv=r(2,(e,t)=>vv(e,e=>R(()=>{let n=!0,r=Oh(e,e=>(n=!1,t(e)));return L(()=>n?r:e)}))),Kv=r(2,(e,t)=>vv(e,e=>I(Nm(e,e=>V(t,()=>yf(e)))))),qv=r(2,(e,t)=>Wv(e,e=>t)),Jv=(e,t,n)=>L(()=>{let r=Kf();return Nm(V(xv(e)(yf(),r),t),n||I).pipe(lg(e=>Zf(r,e)))}),Yv=r(2,(e,t)=>_v((n,r)=>H(Zh(xv(e)(n,r),t),Zh(t)))),Xv=r(3,(e,t,n)=>_v((r,i)=>H(eg(xv(e)(r,i),t,n),eg(t,n)))),Zv=r(3,(e,t,n)=>_v((r,i)=>V(n,n=>xv(Xv(e,t,n))(r,i)))),Qv=r(2,(e,t)=>Jv(e,e=>gg(V(e,t),{disableYield:!0}))),$v=e=>H(ey(e,()=>({bytes:0,arrays:[]}),(e,t)=>{for(let n=0;n<t.length;n++)e.bytes+=t[n].length,e.arrays.push(t[n]);return e}),({arrays:e,bytes:t})=>{let n=new Uint8Array(t),r=0;for(let t=0;t<e.length;t++){let i=e[t];n.set(i,r),r+=i.length}return n}),ey=r(3,(e,t,n)=>L(()=>{let r=t();return Jv(e,e=>ph({while:o,body:()=>e,step:e=>{r=n(r,e)}}),()=>I(r))})),ty=jg(function*(e){let t=uv(1),n=yield*Jh(),r=D(n,Gf);return(yield*xv(e)(yf(),r)).pipe(Zh(n),t.withPermits(1))},Mh(e=>I(bh(e)))),ny=(e,t)=>xv(e)(yf(),t),ry=`~effect/Stream`,iy={_R:i,_E:i,_A:i},ay=function(e){this.channel=e};ay.prototype={[ry]:iy,pipe(){return e(this,arguments)}};var oy=e=>new ay(e),sy=`~effect/Stream`,cy=e=>v(e,sy),ly=oy,uy=e=>dy(R(()=>{let t=!0,n=I(Ai(void 0)),r=Uh(n,e);return L(()=>t?(t=!1,n):r)})),dy=e=>ly(yv(e)),fy=e=>e.channel,py=(e,t)=>ly(Cv(e,t)),my=ly(Tv),hy=e=>{let t=ly(wv(()=>e().channel));return gy.set(t,e),t},gy=new WeakMap,_y=e=>ly(Ev(e)),vy=e=>ly(Dv(e)),yy=e=>ly(kv(e)),by=e=>ly(Av(e)),xy=e=>ly(Hv(H(e,fy))),Sy=r(e=>cy(e[0]),(e,t,n)=>e.channel.pipe(Lv,Pv(t,n),Mv(Ai),ly)),Cy=r(2,(e,t)=>ly(zv(fy(e),t))),wy=r(2,(e,t)=>ly(Bv(e.channel,t))),Ty=r(2,(e,t)=>ly(Uv(e.channel,t))),Ey=r(2,(e,t)=>ly(Kv(e.channel,t))),Dy=r(2,(e,t)=>ly(qv(e.channel,t))),Oy=r(2,(e,t)=>ly(Yv(e.channel,t))),ky=r(2,(e,t)=>Qv(e.channel,t)),Ay=e=>ty(e.channel),jy=e=>H($v(e.channel),e=>e.buffer),My=r(e=>cy(e[0]),(e,t,n)=>{let r,i,a=!1,o=t_(!1),s=n?.signal,c=()=>i.interruptUnsafe();return new ReadableStream({start(n){i=Cg(Zh(Qv(vv(e.channel,e=>I(o.whenOpen(e))),e=>R(()=>{o.closeUnsafe();for(let t=0;t<e.length;t++)n.enqueue(e[t]);r(),r=void 0})),t)),i.addObserver(e=>{s?.removeEventListener(`abort`,c),!a&&(e._tag===`Failure`&&s?.aborted!==!0?n.error(df(e.cause)):n.close())}),s!==void 0&&i.pollUnsafe()===void 0&&(s.aborted?c():s.addEventListener(`abort`,c,{once:!0}))},pull(){return new Promise(e=>{r=e,o.openUnsafe()})},cancel(){if(i)return a=!0,Eg(jh(Hg(i)))}},n?.strategy)}),Ny=r(e=>cy(e[0]),(e,t)=>H(Jh(),n=>My(e,n,t)));function Py(e){return{_tag:`Value`,value:e}}function Fy(e,t){return{_tag:`Record`,keys:e,value:t}}function Iy(e,t){return{_tag:`Array`,length:e,value:t}}var Ly=O(`effect/ConfigProvider`,{defaultValue:()=>Gy()}),Ry={...Yt,toJSON(){return{_id:`ConfigProvider`}}},zy=e=>e;function By(e,t){let n=Object.create(Ry);return n.load=e,n.mapInput=t,n}function Vy(e,t){return By(n=>e(t(n)),n=>Vy(e,e=>n(t(e))))}function Hy(e){return Vy(e,zy)}function Uy(e,t){return e===``&&!t?void 0:e}function Wy(e,t){let n=t?.preserveEmptyStrings===!0,r=Ky(e);return Hy(t=>I(qy(r,e,t,n)))}function Gy(e){return Wy(e?.env??{BASE_URL:`/`,DEV:!1,MODE:`production`,PROD:!0,SSR:!1,TSS_INLINE_CSS_ENABLED:`false`},{preserveEmptyStrings:e?.preserveEmptyStrings})}function Ky(e){let t={};for(let[n,r]of Object.entries(e)){if(r===void 0)continue;let e=n.split(`_`),i=t;for(let t of e){let e=i.children??=Object.create(null);i=e[t]??={}}}return t}function qy(e,t,n,r){let i=n.map(String).join(`_`),a=Uy(Object.hasOwn(t,i)?t[i]:void 0,r),o=Jy(e,n),s=o?.children?Object.keys(o.children):[];return s.length===0?a===void 0?void 0:Py(a):s.every(_i)?Iy(Math.max(...s.map(e=>parseInt(e,10)))+1,a):Fy(new Set(s),a)}function Jy(e,t){if(t.length===0)return e;let n=e;for(let e of t)if(n=n?.children?.[String(e)],!n)return;return n}var Yy=`~effect/BigDecimal`,Xy={[Yy]:Yy,[Se](){let e=ib(this);return Te(Ae(String(e.value)),ke(e.scale))},[Ve](e){return Zy(e)&&ub(this,e)===0},toString(){return`BigDecimal(${fb(this)})`},toJSON(){return{_id:`BigDecimal`,value:String(this.value),scale:this.scale}},[At](){return this.toJSON()},pipe(){return e(this,arguments)}},Zy=e=>v(e,Yy),Qy=(e,t)=>{if(!Number.isSafeInteger(t))throw RangeError(`Scale must be a safe integer, got ${t}`);let n=Object.create(Xy);return n.value=e,n.scale=t,n},$y=(e,t)=>{let n=Qy(e,t);return n.normalized=n,n},eb=BigInt(0),tb=BigInt(1),nb=BigInt(10),rb=$y(eb,0),ib=e=>{if(e.normalized===void 0){if(e.value===eb)e.normalized=rb;else{let t=`${e.value}`,n=ab(t);e.normalized=$y(BigInt(t.slice(0,t.length-n)),e.scale-n)}}return e.normalized},ab=e=>{let t=e.length;for(;e[t-1]===`0`;)t--;return e.length-t},ob=100,sb=[tb],cb=(e,t)=>e===t?0:e<t?-1:1,lb=(e,t)=>{let n=`${e.value<eb?-e.value:e.value}`,r=`${t.value<eb?-t.value:t.value}`,i=BigInt(n.length-r.length)-BigInt(e.scale)+BigInt(t.scale);if(i!==eb)return i<eb?-1:1;let a=Math.max(n.length,r.length);return dr(n.padEnd(a,`0`),r.padEnd(a,`0`))},ub=(e,t)=>{if(e.scale===t.scale)return cb(e.value,t.value);let n=db(e),r=db(t);if(n!==r)return n<r?-1:1;if(n===0)return 0;let i=e.scale-t.scale,a=Math.abs(i);if(a>ob)return n===-1?lb(t,e):lb(e,t);let o=sb[a]??=nb**BigInt(a);return i>0?cb(e.value,t.value*o):cb(e.value*o,t.value)},db=e=>e.value===eb?0:e.value<eb?-1:1,fb=e=>{let t=ib(e);if(Math.abs(t.scale)>=16)return pb(t);let n=t.value<eb,r=`${n?-t.value:t.value}`,i=t.scale>0?r.padStart(t.scale+1,`0`):r.padEnd(r.length-t.scale,`0`),a=i.length-t.scale,o=t.scale>0?`${i.slice(0,a)}.${i.slice(a)}`:i;return n?`-${o}`:o},pb=e=>{if(mb(e))return`0e+0`;let t=ib(e),n=`${t.value}`,r=t.value<eb?2:1,i=n.slice(0,r),a=n.slice(r),o=a.length-t.scale;return`${i}${a===``?``:`.${a}`}e${o>=0?`+`:``}${o}`},mb=e=>e.value===eb,hb=e=>_b(typeof e==`string`?bb.encode(e):e),gb=e=>{let t=Sb(e),n=t.length;if(n%4!=0)return Vr(new Po({kind:`Decode`,module:`Base64`,input:t,message:`Length must be a multiple of 4, but is ${n}`}));let r=t.indexOf(`=`);if(r!==-1&&(r<n-2||r===n-2&&t[n-1]!==`=`))return Vr(new Po({kind:`Decode`,module:`Base64`,input:t,message:`Found a '=' character, but it is not at the end`}));try{let e=t.endsWith(`==`)?2:+!!t.endsWith(`=`),r=new Uint8Array(n/4*3-e);for(let e=0,i=0;e<n;e+=4,i+=3){let n=Db(t.charCodeAt(e))<<18|Db(t.charCodeAt(e+1))<<12|Db(t.charCodeAt(e+2))<<6|Db(t.charCodeAt(e+3));r[i]=n>>16,r[i+1]=n>>8&255,r[i+2]=n&255}return Br(r)}catch(e){return Vr(new Po({kind:`Decode`,module:`Base64`,input:t,message:e instanceof Error?e.message:`Invalid input`}))}},_b=e=>{let t=e.length,n=Uint8Array.prototype.toBase64;return t>=32&&typeof n==`function`?n.call(e):t<128?vb(e):yb(e)},vb=e=>{let t=e.length,n=``,r=2;for(;r<t;r+=3)n+=Cb[e[r-2]>>2],n+=Cb[(e[r-2]&3)<<4|e[r-1]>>4],n+=Cb[(e[r-1]&15)<<2|e[r]>>6],n+=Cb[e[r]&63];return r===t+1&&(n+=Cb[e[r-2]>>2],n+=Cb[(e[r-2]&3)<<4],n+=`==`),r===t&&(n+=Cb[e[r-2]>>2],n+=Cb[(e[r-2]&3)<<4|e[r-1]>>4],n+=Cb[(e[r-1]&15)<<2],n+=`=`),n},yb=e=>{let t=e.length,n=new Uint8Array(Math.ceil(t/3)*4),r,i=0;for(r=2;r<t;r+=3,i+=4)n[i]=wb[e[r-2]>>2],n[i+1]=wb[(e[r-2]&3)<<4|e[r-1]>>4],n[i+2]=wb[(e[r-1]&15)<<2|e[r]>>6],n[i+3]=wb[e[r]&63];return r===t+1&&(n[i]=wb[e[r-2]>>2],n[i+1]=wb[(e[r-2]&3)<<4],n[i+2]=Tb,n[i+3]=Tb),r===t&&(n[i]=wb[e[r-2]>>2],n[i+1]=wb[(e[r-2]&3)<<4|e[r-1]>>4],n[i+2]=wb[(e[r-1]&15)<<2],n[i+3]=Tb),xb.decode(n)},bb=new TextEncoder,xb=new TextDecoder,Sb=e=>e.replace(/[\n\r]/g,``),Cb=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/`,wb=bb.encode(Cb),Tb=61,Eb=new Uint8Array(123).fill(255);for(let e=0;e<64;e++)Eb[Cb.charCodeAt(e)]=e;Eb[61]=0;var Db=e=>{if(e>=Eb.length||Eb[e]===255)throw TypeError(`Invalid character ${String.fromCharCode(e)}`);return Eb[e]},Ob=Rp,kb=Up,Ab=qp,jb=Jp,Mb=cm,Nb=`~effect/HashMap`,Pb=e=>v(e,Nb),Fb=`~effect/HashSet`,Ib=e=>v(e,Fb),Lb=`~effect/http/Cookies`,Rb=`~effect/http/Cookies/Cookie`,zb={[Lb]:Lb,...Nt,toJSON(){return{_id:`effect/Cookies`,cookies:ni(this.cookies,e=>e.toJSON())}},pipe(){return e(this,arguments)}},Bb=e=>{let t=Object.create(zb);return t.cookies=e,t},Vb=e=>{let t={};for(let n of e)dt(t,n.name,n);return Bb(t)},Hb=e=>{let t=typeof e==`string`?[e]:e,n=[];for(let e of t){let t=Ub(e.trim());t&&n.push(t)}return Vb(n)};function Ub(e){let t=e.split(`;`).map(e=>e.trim()).filter(e=>e!==``);if(t.length===0)return;let n=t[0].indexOf(`=`);if(n===-1)return;let r=t[0].slice(0,n).replace(Gb,``);if(!Wb.test(r))return;let i=t[0].slice(n+1).replace(Gb,``),a=Jb(i);if(t.length===1)return Object.assign(Object.create(qb),{name:r,value:a,valueEncoded:i});let o={};for(let e=1;e<t.length;e++){let n=t[e],r=n.indexOf(`=`),i=r===-1?n:n.slice(0,r).trim(),a=r===-1?void 0:n.slice(r+1).trim();switch(i.toLowerCase()){case`domain`:{if(a===void 0)break;let e=a.trim().replace(/^\./,``);e&&(o.domain=e);break}case`expires`:{if(a===void 0)break;let e=new Date(a);isNaN(e.getTime())||(o.expires=e);break}case`max-age`:if(a===void 0||!Kb.test(a))break;o.maxAge=co(parseInt(a,10));break;case`path`:if(a===void 0)break;a[0]===`/`&&(o.path=a);break;case`priority`:if(a===void 0)break;switch(a.toLowerCase()){case`low`:o.priority=`low`;break;case`medium`:o.priority=`medium`;break;case`high`:o.priority=`high`}break;case`httponly`:o.httpOnly=!0;break;case`secure`:o.secure=!0;break;case`partitioned`:o.partitioned=!0;break;case`samesite`:if(a===void 0)break;switch(a.toLowerCase()){case`lax`:o.sameSite=`lax`;break;case`strict`:o.sameSite=`strict`;break;case`none`:o.sameSite=`none`}}}return Object.assign(Object.create(qb),{name:r,value:a,valueEncoded:i,options:Object.keys(o).length>0?o:void 0})}var Wb=/^[!#$%&'*+\-.^_`|~0-9A-Za-z]+$/,Gb=/^[\t ]+|[\t ]+$/g,Kb=/^-?[0-9]+$/,qb={[Rb]:Rb,...Nt,toJSON(){return{_id:`effect/Cookies/Cookie`,name:this.name,value:this.value,options:this.options}}},Jb=e=>{try{return decodeURIComponent(e)}catch{return e}},Yb=new WeakMap,Xb=e=>{if(Yb.has(e))return Yb.get(e);throw Error(`Unable to get redacted value`+(e.label?` with label: "${e.label}"`:``))},Zb=`~effect/Redacted`,Qb=e=>v(e,Zb),$b=(e,t)=>{let n=Object.create(ex);return t?.label&&(n.label=t.label),Yb.set(n,e),n},ex={[Zb]:{_A:e=>e},label:void 0,...Yt,toJSON(){return this.toString()},toString(){return`<redacted${re(this.label)?`:`+this.label:``}>`},[Se](){return y(Yb.get(this))},[Ve](e){return Qb(e)&&b(Yb.get(this),Yb.get(e))}},tx=Xb,nx=Symbol.for(`~effect/http/Headers`),rx=Object.defineProperties(Object.create(null),{[nx]:{value:nx},[pt]:{value(e){return px(this,D(e,hx))}},toJSON:{value(){return ht(this)}},[Ve]:{value(e){return ax(this,e)}},[Se]:{value(){return Me(this)}},toString:{value:Nt.toString},[At]:{value:Nt[At]}}),ix=e=>Object.assign(Object.create(rx),e),ax=oi(at()),ox=Object.create(rx),sx=e=>{if(e===void 0)return ox;if(Symbol.iterator in e){let t=Object.create(rx);for(let[n,r]of e)t[n.toLowerCase()]=r;return t}let t=Object.create(rx);for(let[n,r]of Object.entries(e))Array.isArray(r)?t[n.toLowerCase()]=r.join(`, `):r!==void 0&&(t[n.toLowerCase()]=r);return t},cx=e=>Object.setPrototypeOf(e,rx),lx=r(3,(e,t,n)=>{let r=ix(e);return r[t.toLowerCase()]=n,r}),ux=r(2,(e,t)=>ix({...e,...sx(t)})),dx=r(2,(e,t)=>{let n=ix(e);return Object.assign(n,t),n}),fx=r(2,(e,t)=>{let n=ix(e);return delete n[t.toLowerCase()],n}),px=r(2,(e,t)=>{let n={...e},r=t=>{if(typeof t==`string`){let r=t.toLowerCase();r in e&&(n[r]=$b(e[r]))}else for(let r in e)r.search(t)!==-1&&(n[r]=$b(e[r]))};if(Array.isArray(t))for(let e=0;e<t.length;e++)r(t[e]);else r(t);return n}),mx=(e,t)=>{let n=e.toLowerCase();for(let r=0;r<t.length;r++){let i=t[r];if(typeof i==`string`){if(i.toLowerCase()===n)return!0}else if(e.search(i)!==-1)return!0}return!1},hx=O(`effect/Headers/CurrentRedactedNames`,{defaultValue:()=>[`authorization`,`cookie`,`set-cookie`,`x-api-key`]}),gx=e=>typeof e==`string`?e:tx(e),_x=new TextDecoder(`utf-8`,{ignoreBOM:!0}),vx=e=>new URLSearchParams(_x.decode(e).replace(/^\?/,`%3F`)),yx=`~effect/http/UrlParams`,bx=e=>v(e,yx),xx={...Yt,[yx]:yx,[Symbol.iterator](){return this.params[Symbol.iterator]()},[pt](e){return{_id:`UrlParams`,params:Object.fromEntries(Ax(this,D(e,Bx)))}},toJSON(){return ht(this)},[Ve](e){return Ex(this,e)},[Se](){return Pe(this.params.flat())}},Sx=e=>{let t=Object.create(xx);return t.params=e,t},Cx=e=>{if(bx(e))return e;let t=wx(e),n=[];for(let e=0;e<t.length;e++)if(Array.isArray(t[e][0])){let[r,i]=t[e];n.push([`${r[0]}[${r.slice(1).join(`][`)}]`,i])}else n.push(t[e]);return Sx(n)},wx=e=>{let t=typeof e[Symbol.iterator]==`function`?ui(e):Object.entries(e),n=[];for(let[e,r]of t)if(Array.isArray(r))for(let t=0;t<r.length;t++)r[t]!==void 0&&n.push([e,Tx(r[t])]);else if(typeof r==`object`&&r&&!Qb(r)){let t=wx(r);for(let[r,i]of t)n.push([[e,...typeof r==`string`?[r]:r],i])}else r!==void 0&&n.push([e,Tx(r)]);return n},Tx=e=>Qb(e)?e:String(e),Ex=rt((e,t)=>Dx(e.params,t.params)),Dx=Li(Yr([at(),nt()])),Ox=Sx([]),kx=r(2,(e,t)=>{let n=Cx(t).params.slice(),r=new Set;for(let e=0;e<n.length;e++)r.add(n[e][0]);for(let t=0;t<e.params.length;t++)r.has(e.params[t][0])||n.push(e.params[t]);return Sx(n)}),Ax=r(2,(e,t)=>{let n=Array.isArray(t)?t:[t];return e.params.map(([e,t])=>[e,typeof t==`string`&&jx(e,n)?$b(t):t])}),jx=mx,Mx=(e,t=zx())=>{e.includes(`@`)&&(e=Ix(e));let n=e.indexOf(`?`);if(n===-1||t.length===0)return e;let r=e.indexOf(`#`);if(r!==-1&&r<n)return e;let i=r===-1?e.length:r;return e.slice(0,n+1)+Lx(e.slice(n+1,i),t)+e.slice(i)},Nx=/^(?:(https?|ftp|wss?):[/\\]*|[a-z][a-z\d+.-]*:\/\/|[/\\]{2,})/i,Px=/[/\\?#]/,Fx=/[/?#]/,Ix=e=>{let t=``,n=[];for(let r=0;r<e.length;r++){let i=e.charCodeAt(r);i===9||i===10||i===13||t===``&&i<=32||(t+=e[r],n.push(r))}let r=Nx.exec(t);if(r===null)return e;let i=r[0].length,a=r[1]!==void 0||!r[0].includes(`:`),o=t.slice(i),s=o.search(a?Px:Fx),c=(s===-1?o:o.slice(0,s)).lastIndexOf(`@`);return c===-1?e:e.slice(0,n[i])+`REDACTED:REDACTED`+e.slice(n[i+c])},Lx=(e,t)=>e.split(`&`).map(e=>{let n=e.indexOf(`=`);return n!==-1&&jx(Rx(e.slice(0,n)),t)?e.slice(0,n+1)+`REDACTED`:e}).join(`&`),Rx=e=>{if(!e.includes(`%`)&&!e.includes(`+`))return e;try{return decodeURIComponent(e.replace(/\+/g,` `))}catch{return e}},zx=()=>D(globalThis[`~effect/Fiber/currentFiber`]?.context??aa(),Bx),Bx=O(`effect/http/UrlParams/CurrentRedactedNames`,{defaultValue:()=>[`X-Amz-Signature`,`X-Amz-Credential`,`X-Amz-Security-Token`,`AWSAccessKeyId`,`Signature`,`sig`,`X-Goog-Signature`]});function Vx(e){return e.checks?e.checks[e.checks.length-1].annotations:e.annotations}var Hx=`~structural`,Ux=`~sentinels`,Wx=`~constructor`,Gx=f(e=>{let t=Vx(e)?.identifier;return typeof t==`string`?t:e.getExpected(Gx)}),U=Symbol(),Kx=Tf,qx=Kx(U),W=Kx(U),Jx=e=>e===U?T():E(e),Yx=e=>e._tag===`None`?qx:Kx(e.value),Xx=`~effect/SchemaIssue/Issue`;function Zx(e){return v(e,Xx)&&e[Xx]===Xx}function Qx(e){return Object.hasOwn(e,`input`)}var $x=class{[Xx]=Xx;constructor(e,t){t?.reportInput===!0&&e!==U&&(this.input=e)}},eS=class extends $x{_tag=`Filter`;filter;issue;constructor(e,t,n,r){super(n,r),this.filter=e,this.issue=t}},tS=class extends $x{_tag=`Encoding`;ast;issue;constructor(e,t,n,r){super(n,r),this.ast=e,this.issue=t}},nS=class extends $x{_tag=`Pointer`;path;issue;constructor(e,t){super(),this.path=e,this.issue=t}},rS=class extends $x{_tag=`MissingKey`;annotations;constructor(e){super(),this.annotations=e}},iS=class extends $x{_tag=`UnexpectedKey`;ast;constructor(e,t,n){super(t,n),this.ast=e}},aS=class extends $x{_tag=`Composite`;ast;issues;constructor(e,t,n,r){super(n,r),this.ast=e,this.issues=t}},oS=class extends $x{_tag=`InvalidType`;ast;constructor(e,t,n){super(t,n),this.ast=e}},sS=class extends $x{_tag=`InvalidValue`;annotations;constructor(e,t,n){super(t,n),this.annotations=e}};function cS(e,t,n,r,i){return new aS(e,[new nS([t],n)],r,i)}var lS=class extends $x{_tag=`AnyOf`;ast;issues;constructor(e,t,n,r){super(n,r),this.ast=e,this.issues=t}},uS=class extends $x{_tag=`OneOf`;ast;successes;constructor(e,t,n,r){super(n,r),this.ast=e,this.successes=t}};function dS(e,t,n){if(Zx(e))return e;if(typeof e==`string`)return new sS({message:e},t,n);let r=typeof e.issue==`string`?new sS({message:e.issue},t,n):e.issue;return new nS(e.path,r)}function fS(e,t,n){if(e!==void 0)return typeof e==`boolean`?e?void 0:new sS(void 0,t,n):dS(e,t,n)}function pS(e,t,n,r){return Array.isArray(t)?gi(t)?t.length===1?dS(t[0],n,r):new aS(e,ji(t,e=>dS(e,n,r)),n,r):void 0:fS(t,n,r)}var mS=e=>{let t=wS(e);if(t!==void 0)return t;switch(e._tag){case`InvalidType`:return vS(Gx(e.ast),e);case`InvalidValue`:{let t=_S(e);if(t!==void 0)return vS(t,e);let n=gS(e);return n===void 0?`Expected a valid value`:`Invalid data ${n}`}case`MissingKey`:return`Missing key`;case`UnexpectedKey`:{let t=gS(e);return t===void 0?`Expected no excess property`:`Unexpected key with value ${t}`}case`Forbidden`:return`Forbidden operation`;case`OneOf`:{let t=gS(e);return t===void 0?`Expected exactly one member to match`:`Expected exactly one member to match the input ${t}`}}},hS=e=>wS(e)??wS(e.issue);function gS(e){return Qx(e)?x(e.input):void 0}function _S(e){let t=e.annotations?.expected;return typeof t==`string`?t:void 0}function vS(e,t){let n=gS(t);return n===void 0?`Expected ${e}`:`Expected ${e}, got ${n}`}function yS(e,t){let n=t(e);if(n!==void 0||e.issue._tag!==`InvalidValue`)return n;let r=_S(e.issue);return r===void 0?vS(bS(e.filter),e):vS(r,e.issue)}function bS(e){let t=e.annotations?.expected;if(typeof t==`string`)return t;switch(e._tag){case`Filter`:return`<filter>`;case`FilterGroup`:return e.checks.map(e=>bS(e)).join(` & `)}}function xS(){return e=>CS(e,``)}var SS=xS();function CS(e,t,n){let r;switch(e._tag){case`Filter`:return CS(e.issue,t,n??yS(e,hS));case`Encoding`:return CS(e.issue,t,n);case`Pointer`:return CS(e.issue,t+St(e.path),n);case`Composite`:case`AnyOf`:if(e._tag===`Composite`||e.issues.length>0)return e.issues.map(e=>CS(e,t,n)).join(`
|
|
13
|
+
`),r=`${t}[cause]: ${n[0]}`;for(let e=1,i=n.length;e<i;e++)r+=`\n${t}${n[e]}`;return e.cause&&(r+=` {\n${Fs(e.cause,`${t} `)}\n${t}}`),r},Is=`~effect/Fiber`,Ls={_A:i,_E:i},Rs={id:0},zs=(()=>{try{return globalThis.process?.getBuiltinModule?.(`node:async_hooks`)?.AsyncResource}catch{return}})(),Bs=()=>zs===void 0?void 0:new zs(`effect/Fiber`),Vs=()=>globalThis[_t],Hs=class{constructor(e,t=!0){this.setContext(e),this.id=++Rs.id,this.currentOpCount=0,this.interruptible=t,this._stack=[],this._observers=void 0,this._exit=void 0,this._children=void 0,this._interruptedCause=void 0,this._yielded=void 0,this._running=!1,this._deferredInterrupt=!1,this._parent=void 0,this._asyncContext=void 0,this.cache.runtimeMetrics?.recordFiberStart(this.context)}get[Is](){return Ls}get currentDispatcher(){return this._dispatcher??=this.cache.scheduler.makeDispatcher()}getRef(e){return D(this.context,e)}addObserver(e){return this._exit?(e(this._exit),l):(this._observers===void 0?this._observers=[e]:this._observers.push(e),()=>this.removeObserver(e))}removeObserver(e){if(this._exit||this._observers===void 0)return;let t=this._observers.indexOf(e);t>=0&&this._observers.splice(t,1)}interruptUnsafe(e,t){if(this._exit)return;let n=us(e);this.cache.stackFrame&&(n=_n(n,sa(Tn,this.cache.stackFrame))),t&&(n=_n(n,t)),this._interruptedCause=this._interruptedCause?fn(this._interruptedCause,n):n,this.interruptible&&(this._running?this._deferredInterrupt=!0:this.evaluate(j(this._interruptedCause)))}pollUnsafe(){return this._exit}evaluate(e){if(this._exit)return;if(this._asyncContext!==void 0){let t=this._asyncContext;this._asyncContext=void 0;try{return t.runInAsyncScope(this.evaluate,this,e)}finally{t.emitDestroy()}}else if(this._yielded!==void 0){let e=this._yielded;this._yielded=void 0,e()}let t=this.runLoop(e);if(t===Jt){this._asyncContext=Bs();return}let n=Ks.interruptChildren&&Ks.interruptChildren(this);if(n!==void 0)return this.evaluate(P(n,()=>t));if(this._exit=t,this.cache.runtimeMetrics?.recordFiberEnd(this.context,this._exit),this._parent&&=(this._parent._children?.delete(this),void 0),this._observers!==void 0){let e=this._observers;this._observers=void 0;for(let n=0;n<e.length;n++)e[n](t)}this._stack.length=0,this._children=void 0,this.context=aa();let r=this.cache;(r.span!==void 0||r.stackFrame!==void 0)&&(this.cache={...r,span:void 0,stackFrame:void 0})}runLoop(e){let t=globalThis[_t];globalThis[_t]=this;let n=this._running;this._running=!0;let r=!1,i=e;this.currentOpCount=0;try{for(;;)try{this._deferredInterrupt&&(this._deferredInterrupt=!1,i=j(this._interruptedCause)),this.currentOpCount++;let e=this.cache;if(!r&&!e.preventYield&&e.scheduler.shouldYield(this)){r=!0;let e=i;i=P(ic,()=>e)}if(i=e.tracerContext?e.tracerContext(i,this):i[Wt](this),i===Jt){let e=this._yielded;if(`~effect/Exit`in e)return this._deferredInterrupt=!1,this._yielded=void 0,e;if(this._deferredInterrupt){this._yielded=void 0,e();continue}return Jt}}catch(e){if(!v(i,`~effect/Effect/evaluate`))return kn(`Fiber.runLoop: Not a valid effect: ${String(i)}`);i=kn(e)}}finally{this._running=n,globalThis[_t]=t}}getCont(e){if(this._deferredInterrupt)return this._deferredInterrupt=!1,Ws;for(;;){let t=this._stack.pop();if(!t)return;let n=t[qt];if(n!==void 0){let r=n.call(t,this);if(r)return r[e]=r,r}if(t[e])return t}}succeedWith(e){if(!(++this.currentOpCount&Gs-1))return C(e);let t=this.getCont(Gt);return t?t[Gt](e,this):this.yieldWith(C(e))}yieldWith(e){return this._yielded=e,Jt}children(){return this._children??=new Set}pipe(){return e(this,arguments)}setContext(e){let t=this.context;if(this.context=e,t!==void 0&&na(t,e))return;let n=e.cacheRoot,r=n._fiberCache??=Us(e);this.cache?.scheduler!==r.scheduler&&(this._dispatcher=void 0),this.cache=r}get currentSpanLocal(){let e=this.cache.span;return e?._tag===`Span`?e:void 0}},Us=e=>{let t=da(e,Ko);return{scheduler:D(e,So),tracer:t,tracerContext:t?t.context:void 0,tracerEnabled:D(e,Zo),span:da(e,Bo),logLevel:D(e,ns),minimumLogLevel:D(e,rs),stackFrame:D(e,Xo),runtimeMetrics:da(e,Yo),maxOpsBeforeYield:D(e,ko),preventYield:D(e,Ao)}},Ws={[Gt](e,t){return j(t._interruptedCause)},[Kt](e,t){return j(t._interruptedCause)}},Gs=32,Ks={interruptChildren:void 0},qs=e=>{if(!e.cache.stackFrame)return;let t=new Map;return t.set(En.key,e.cache.stackFrame),ea(t)},Js=e=>{let t=e;return t._exit?A(t._exit):pc(n=>t._exit?n(A(t._exit)):nc(e.addObserver(e=>n(A(e)))))},Ys=e=>pc(t=>{let n=e[Symbol.iterator](),r=[],i;function a(){let e=n.next();for(;!e.done;)if(e.value._exit)r.push(e.value._exit),e=n.next();else{i=e.value.addObserver(e=>{r.push(e),a()});return}t(A(r))}return a(),nc(()=>i?.())}),Xs=e=>{let t=e;return t._exit?t._exit:pc(n=>t._exit?n(t._exit):nc(e.addObserver(n)))},Zs=e=>pc(t=>{let n=Array.from(e);if(n.length===0)return t(A(ki()));let r=Array(n.length),i=ki(),a=()=>{for(let e=0;e<i.length;e++)n[e].removeObserver(i[e])},o=0,s=!1;for(let e=0;e<n.length&&!s;e++){let c=i=>{if(o++,i._tag===`Failure`)return s=!0,a(),t(i);r[e]=i.value,o===n.length&&t(A(r))};i.push(c),n[e].addObserver(c)}return nc(()=>{s=!0,a()})}),Qs=e=>w(t=>$s(e,t.id)),$s=r(e=>v(e[0],Is),(e,t,n)=>w(r=>{let i=qs(r);return i=i&&n?_a(i,n):i??n,e.interruptUnsafe(t,i),Ic(Js(e))})),ec=e=>w(t=>{let n=qs(t),r=ki();for(let i of e)i.interruptUnsafe(t.id,n),r.push(i);return Ic(Ys(r))}),A=C,j=Dn,tc=On,nc=Cn({op:`Sync`,[Wt](e){let t=this[S],n=t(),r=e.getCont(Gt);return r?r[Gt](n,e):e.yieldWith(C(n))}}),M=Cn({op:`Suspend`,[Wt](e){let t=this[S];return t()}}),rc=Jr({onFailure:tc,onSuccess:A}),ic=Cn({op:`Yield`,[Wt](e){let t=!1;return e.currentDispatcher.scheduleTask(()=>{t||e.evaluate(Zc)},this[`~effect/Effect/args`]??0),e.yieldWith(()=>{t=!0})}})(0),ac=A(T()),oc=e=>M(()=>j(e())),sc=e=>kn(e),N=A(void 0),cc=e=>{let t=typeof e==`function`?e:e.try,n=typeof e==`function`?e=>new Id(e,`An error occurred in Effect.try`):e.catch;return M(()=>{try{return A(t())}catch(e){return tc(n(e))}})},lc=e=>dc(function(t,n){e(n).then(e=>t(A(e)),e=>t(sc(e)))},e.length!==0),uc=e=>{let t=typeof e==`function`?e:e.try,n=typeof e==`function`?e=>new Id(e,`An error occurred in Effect.tryPromise`):e.catch;return dc(function(e,r){let i=e=>M(()=>{try{return tc(zt(()=>n(e)))}catch(e){return sc(e)}});try{t(r).then(t=>e(A(t)),t=>e(i(t)))}catch(t){e(i(t))}},t.length!==0)},dc=function(){let e=Sn({op:`Async`,[Wt](e){let t=!1,n=!1,r=this.withSignal?new AbortController:void 0,i=this.register.call(e.cache.scheduler,r=>{t||(t=!0,n?e.evaluate(r):n=r)},r?.signal);return n===!1?(n=!0,e.yieldWith(()=>{t=!0}),r===void 0&&i===void 0||e._stack.push(fc(()=>(t=!0,r?.abort(),i??Zc))),Jt):n}}),t=function(e,t){this.register=e,this.withSignal=t};return t.prototype=e,function(e,n){return new t(e,n)}}(),fc=Cn({op:`AsyncFinalizer`,[qt](e){e.interruptible&&(e.interruptible=!1,e._stack.push(Ou))},[Kt](e,t){return _s(e)?P(Zl(Dn(e),this[S]()),()=>j(e)):j(e)}}),pc=e=>dc(e,e.length>=2),mc=pc(l),hc=(...e)=>{if(e.length===1){let t=e[0];return M(()=>xc(t()))}let[t,n]=e;return M(()=>xc(n.call(t.self)))},gc=(e,t)=>typeof e==`function`?e:t.shift().bind(e.self),_c=(e,...t)=>{let n=gc(e,t),r=t.length===0?function(){return M(()=>xc(n.apply(this,arguments)))}:function(){let e=M(()=>xc(n.apply(this,arguments)));for(let n=0;n<t.length;n++)e=t[n](e,...arguments);return e};return vc(n.length,r)},vc=(e,t)=>Object.defineProperty(t,"length",{value:e,configurable:!0}),yc=(e,...t)=>{let n=gc(e,t);return vc(n.length,t.length===0?function(){return bc(()=>n.apply(this,arguments))}:function(){let e=bc(()=>n.apply(this,arguments));for(let n of t)e=n(e,...arguments);return e})},bc=e=>{try{let t=e(),n;for(;;){let r=t.next(n);if(r.done)return A(r.value);let i=r.value;if(i&&i._tag===`Success`)n=i.value;else{if(i&&i._tag===`Failure`)return r.value;{let n=!0;return M(()=>n?(n=!1,P(r.value,e=>xc(t,e))):M(()=>xc(e())))}}}}catch(e){return sc(e)}},xc=function(){let e=Sn({op:`Iterator`,[Gt](e,t){let n=this.iterator;for(;;){let r=n.next(e);if(r.done)return A(r.value);if(!F(r.value))return t._stack.push(this),r.value;if(r.value._tag===`Failure`)return r.value;e=r.value.value}},[Wt](e){return this[Gt](this.initial,e)}}),t=function(e,t){this.iterator=e,this.initial=t};return t.prototype=e,function(e,n){return new t(e,n)}}(),Sc=r(2,(e,t)=>new Tc(e,Ec,A(t))),Cc=function(e){return e._stack.push(this),this[S]},wc=Sn({op:`OnSuccess`,[Wt]:Cc}),Tc=function(e,t,n){this[S]=e,this[Gt]=t,this.payload=n};Tc.prototype=wc;var Ec=function(){return this.payload},Dc=function(e,t){return t.succeedWith(this.payload)},Oc=(()=>{let e=It();if(e===0)return!1;let t=`~effect/Effect/stackProbe`,n={[t]:function(){return Error()}};Lt(1);let r=n[t]();return Lt(e),r.stack?.includes(`[as `+t+`]`)===!0})(),kc=function(e,t){let n=this.payload;return t.succeedWith(Oc?n(e):zt(()=>n(e)))},Ac=function(e){let t=this.payload;return t(e)},jc=function(e){let t=this.payload;return new Tc(t(e),Dc,e)},Mc=function(e){return new Tc(this.payload,Dc,e)},Nc=e=>Vc(e,E),Pc=r(2,(e,t)=>new Tc(e,Zt(t)?Ec:Ac,t)),Fc=r(2,(e,t)=>new Tc(e,Zt(t)?Mc:jc,t)),Ic=e=>new Tc(e,Ec,Zc),Lc=(e,t)=>w(n=>{let r=new Set;return hu(n,()=>r.size===0?void 0:ec(r)),pc(i=>{let a=!1,o=0;for(let s of e){if(a)break;let e=o++,c=Uu(n,s,!0,!0,!1);r.add(c),c.addObserver(o=>{r.delete(c);let s=!a;a=!0,i(o),s&&t?.onWinner&&t.onWinner({fiber:c,index:e,parentFiber:n})})}})}),Rc=r(e=>Zt(e[1]),(e,t,n)=>Lc([e,t],n)),P=r(2,(e,t)=>new Tc(e,Ac,t)),F=e=>e[Vt]!==void 0,zc=r(2,(e,t)=>F(e)?e._tag===`Success`?t(e.value):e:P(e,t)),Bc=e=>P(e,i),Vc=r(2,(e,t)=>new Tc(e,kc,t)),Hc=r(2,(e,t)=>F(e)?Qc(e,t):Vc(e,t)),Uc=r(2,(e,t)=>F(e)?$c(e,t):Cl(e,t)),Wc=r(2,(e,t)=>F(e)?el(e,t):wl(e,t)),Gc=r(2,(e,t)=>{if(F(e)){if(e._tag===`Success`)return e;let n=gs(e.cause);return Wr(n)?Dn(n.failure):t(n.success)}return yl(e,t)}),Kc=e=>Dn(us(e)),qc=e=>e._tag===`Success`,Jc=e=>e._tag===`Failure`,Yc=e=>e._tag===`Failure`?Br(e.cause):Vr(e),Xc=e=>e._tag===`Failure`&&_s(e.cause),Zc=C(void 0),Qc=r(2,(e,t)=>e._tag===`Success`?C(t(e.value)):e),$c=r(2,(e,t)=>e._tag===`Success`?e:Dn(Cs(e.cause,t))),el=r(2,(e,t)=>e._tag===`Success`?C(t.onSuccess(e.value)):Dn(Cs(e.cause,t.onFailure))),tl=r(2,(e,t)=>qc(e)?t:e),nl=e=>{let t=[];for(let n of e)n._tag===`Failure`&&t.push(...n.cause.reasons);return t.length===0?Zc:Dn(ln(t))},rl=e=>w(t=>A(ga(t.context,e))),il=r(2,(e,t)=>w(n=>{let r=n.context,i=t(r);return r===i||(n.setContext(i),hu(n,()=>{n.setContext(r)})),e})),al=r(3,(e,t,n)=>il(e,e=>{let r=fa(e,t),i=n(r);return r===i?e:ca(e,t,i)})),ol=()=>sl,sl=w(e=>A(e.context)),cl=e=>w(t=>e(t.context)),ll=r(2,(e,t)=>F(e)?e:il(e,_a(t))),ul=function(){return arguments.length===1?r(2,(e,t)=>dl(e,arguments[0],t)):r(3,(e,t,n)=>dl(e,t,n)).apply(this,arguments)},dl=(e,t,n)=>il(e,ca(t,n)),fl=r(2,(e,t)=>P(t,t=>t?Nc(e):ac)),pl=r(e=>Zt(e[0]),(e,t)=>Fu({while:o,body:a(t?.disableYield?e:P(e,e=>ic)),step:l})),ml=r(2,(e,t)=>new gl(e,t.length===1?t:e=>t(e))),hl=Sn({op:`OnFailure`,[Wt]:Cc}),gl=function(e,t){this[S]=e,this[Kt]=t};gl.prototype=hl;var _l=r(3,(e,t,n)=>ml(e,e=>t(e)?n(e):j(e))),vl=r(3,(e,t,n)=>ml(e,e=>{let r=t(e);return Wr(r)?j(r.failure):n(r.success,e)})),yl=r(2,(e,t)=>vl(e,gs,e=>t(e))),bl=r(2,(e,t)=>ml(e,e=>Pc(t(e),j(e)))),xl=r(3,(e,t,n)=>ml(e,e=>{let r=t(e);return Wr(r)?j(e):Pc(n(r.success,e),j(e))})),Sl=r(2,(e,t)=>xl(e,fs,e=>t(e))),Cl=r(2,(e,t)=>ml(e,e=>j(Cs(e,t)))),wl=r(2,(e,t)=>Al(e,{onFailure:e=>j(Cs(e,t.onFailure)),onSuccess:e=>nc(()=>t.onSuccess(e))})),Tl=e=>yl(e,sc),El=e=>e===`Unhandled`?(...e)=>w(t=>{let n=t.getRef(is);return n===void 0?N:Gd(n)(...e)}):Gd(e===!0?void 0:e),Dl=r(e=>Zt(e[0]),(e,t)=>{if(!t?.log)return Fl(e,{onFailure:e=>N,onSuccess:e=>N});let n=El(t.log);return Al(e,{onFailure(e){let r=gs(e);return Wr(r)?j(r.failure):t.message===void 0?n(e):n(t.message,e)},onSuccess:e=>N})}),Ol=r(e=>Zt(e[0]),(e,t)=>{if(!t?.log)return Al(e,{onFailure:e=>N,onSuccess:e=>N});let n=El(t.log);return Al(e,{onFailure:e=>t.message===void 0?n(e):n(t.message,e),onSuccess:e=>N})}),kl=e=>Ll(e,{onFailure:Vr,onSuccess:Br}),Al=r(2,(e,t)=>new Ml(e,t.onSuccess.length===1?t.onSuccess:e=>t.onSuccess(e),t.onFailure.length===1?t.onFailure:e=>t.onFailure(e))),jl=Sn({op:`OnSuccessAndFailure`,[Wt]:Cc}),Ml=function(e,t,n){this[S]=e,this[Gt]=t,this[Kt]=n};Ml.prototype=jl;var Nl=function(e,t){let n=this.payload;return t.succeedWith(Oc?n.onSuccess(e):zt(()=>n.onSuccess(e)))},Pl=((e,t)=>{let n=Sn({op:e,[Wt]:Cc,[Gt]:Nl,[Kt]:t}),r=function(e,t){this[S]=e,this.payload=t};return r.prototype=n,r})(`Match`,function(e,t){let n=gs(e);if(Wr(n))return j(n.failure);let r=this.payload;return t.succeedWith(Oc?r.onFailure(n.success):zt(()=>r.onFailure(n.success)))}),Fl=r(2,(e,t)=>Al(e,{onFailure:e=>{let n=gs(e);return Wr(n)?j(n.failure):t.onFailure(n.success)},onSuccess:t.onSuccess})),Il=r(2,(e,t)=>new Pl(e,t)),Ll=r(2,(e,t)=>{if(F(e)){if(e._tag===`Success`)return C(t.onSuccess(e.value));let n=gs(e.cause);return Wr(n)?Dn(n.failure):C(t.onFailure(n.success))}return Il(e,t)}),Rl=e=>F(e)?C(e):zl(e),zl=Cn({op:`Exit`,[Wt](e){return e._stack.push(this),this[S]},[Gt](e,t,n){return t.succeedWith(n??C(e))},[Kt](e,t,n){return t.succeedWith(n??Dn(e))}}),Bl=r(2,(e,t)=>Pc(Dd(t),e)),Vl=r(2,(e,t)=>P(Wl(e,t.duration),e=>Cr(e)?t.orElse():A(e.value))),Hl=e=>new Ad(`Operation timed out after '${bo(e)}'`),Ul=r(2,(e,t)=>{let n=Ha(t);return Vl(e,{duration:n,orElse:()=>tc(Hl(n))})}),Wl=r(2,(e,t)=>Rc(Nc(e),Sc(Dd(t),T()))),Gl=`~effect/Scope`,Kl=`~effect/Scope/Closeable`,ql=Hi(`effect/Scope`),Jl=(e,t)=>w(n=>(ju(n),Yl(e,t)??N)),Yl=(e,t)=>{let n=e.state;if(n._tag===`Closed`||(e.state={_tag:`Closed`,exit:t},e.parent!==void 0&&ru(e.parent,e),n._tag===`Empty`))return;if(n.finalizer!==void 0)return Xl(n.finalizer,t);let r=n.finalizers;return r.size===1?Xl(r.values().next().value,t):Ql(e,r,t)},Xl=(e,t)=>{try{return e(t)}catch(e){return kn(e)}},Zl=(e,t)=>qc(e)?t:ml(t,t=>j(hs(dn(e.cause,t)))),Ql=_c(function*(e,t,n){let r=[],i=[],a=Array.from(t),o=Vs();for(let t=a.length-1;t>=0;t--){let[s,c]=a[t];e.strategy===`sequential`?r.push(yield*Rl(Xl(c,n))):s!==o&&i.push(Uu(o,Xl(c,n),!0,!0,`inherit`))}return i.length>0&&(r=yield*Ys(i)),yield*nl(r)}),$l=(e,t)=>{let n=au(t,e);return e.state._tag===`Closed`?(n.state=e.state,n):(nu(e,n,e=>Jl(n,e)),n)},eu=(e,t)=>M(()=>e.state._tag===`Closed`?t(e.state.exit):(nu(e,{},t),N)),tu=(e,t)=>eu(e,a(t)),nu=(e,t,n)=>{if(e.state._tag===`Empty`)e.state={_tag:`Open`,finalizerKey:t,finalizer:n,finalizers:void 0};else if(e.state._tag===`Open`){let r=e.state;r.finalizer===void 0||(r.finalizers=new Map([[r.finalizerKey,r.finalizer]]),r.finalizerKey=void 0,r.finalizer=void 0),r.finalizers.set(t,n)}},ru=(e,t)=>{if(e.state._tag!==`Open`)return;let n=e.state;n.finalizerKey===t?e.state=ou:n.finalizers!==void 0&&(n.finalizers.delete(t),n.finalizers.size===0&&(e.state=ou))},iu=e=>au(e,void 0),au=(e=`sequential`,t)=>({[Kl]:Kl,[Gl]:Gl,strategy:e,parent:t,state:ou}),ou={_tag:`Empty`},su=ql,cu=ul(ql),lu=e=>w(t=>{let n=t.context,r=iu();return t.setContext(ca(t.context,ql,r)),hu(t,e=>(t.setContext(n),Yl(r,e))),e}),uu=e=>M(()=>{let t=iu();return gu(e(t),e=>M(()=>Yl(t,e)??N))}),du=(e,t,n)=>cl(r=>Nu(i=>P(su,a=>Fc(n?.interruptible?i(e):e,e=>eu(a,n=>ll(t(e,n),r)))))),fu=e=>P(su,t=>cl(n=>eu(t,t=>ll(e(t),n)))),pu=function(){let e=Sn({op:`OnExit`,[Wt](e){return e._stack.push(this),this.effect},[qt](e){e.interruptible&&this.interruptible!==!0&&(e._stack.push(Ou),e.interruptible=!1)},[Gt](e,t,n){n??=C(e);let r;try{r=this.onExit(n)}catch(e){r=kn(e)}return r?P(r,e=>n):n},[Kt](e,t,n){n??=Dn(e);let r;try{r=this.onExit(n)}catch(e){r=kn(e)}return r?P(Zl(n,r),e=>n):n}}),t=function(e,t,n){this.effect=e,this.onExit=t,this.interruptible=n};return t.prototype=e,t}(),mu=(e,t,n)=>new pu(e,t,n),hu=(e,t)=>{e._stack.push(new pu(void 0,t,void 0))},gu=r(2,mu),_u=r(2,(e,t)=>gu(e,e=>t)),vu=r(3,(e,t,n)=>gu(e,e=>{let r=t(e);return Wr(r)?N:n(r.success,e)})),yu=r(2,(e,t)=>vu(e,Yc,t)),bu=r(3,(e,t,n)=>gu(e,e=>{if(e._tag!==`Failure`)return N;let r=t(e.cause);return Wr(r)?N:n(r.success,e.cause)})),xu=r(2,(e,t)=>bu(vs,t)(e)),Su=a(1/0),Cu=(e,t)=>{let n=0,r,i,a=(e,t)=>(t.awaiters++,hu(e,()=>{if(!(--t.awaiters>0||t.done))return i===t&&(i=void 0),Qs(t.fiber)}),Xs(t.fiber));return[w(o=>{if(i!==void 0)return o===i.fiber?Xs(i.fiber):a(o,i);if(r!==void 0&&(n===1/0||o.getRef(bd).currentTimeMillisUnsafe()<n))return r;r=void 0;let s=o.getRef(bd),c={fiber:new Hs(o.context),awaiters:0,done:!1};i=c;let l=a(o,c);return c.fiber.evaluate(mu(e,e=>{if(c.done=!0,i!==c||(i=void 0,Xc(e)))return;let a=t(e);n=a===1/0?1/0:s.currentTimeMillisUnsafe()+a,r=e})),c.fiber._exit??l}),nc(()=>{i=void 0,r=void 0})]},wu=e=>nc(()=>Cu(e,Su)[0]),Tu=w(e=>j(us(e.id))),Eu=e=>w(t=>(t.interruptible&&(t.interruptible=!1,t._stack.push(Ou)),e)),Du=Cn({op:`SetInterruptible`,[qt](e){if(e.interruptible=this[S],e._interruptedCause&&e.interruptible)return()=>j(e._interruptedCause)}}),Ou=Du(!0),ku=Du(!1),Au=e=>{if(e.interruptible=!0,e._stack.push(ku),e._interruptedCause)return j(e._interruptedCause)},ju=e=>{let t=e;t.interruptible&&(t.interruptible=!1,t._stack.push(Ou))},Mu=e=>w(t=>t.interruptible?e:Au(t)??e),Nu=e=>w(t=>t.interruptible?(t.interruptible=!1,t._stack.push(Ou),e(Mu)):e(i)),Pu=(e,t)=>xe(e)?t?.mode===`result`?Iu(e,kl,t):Iu(e,i,t):t?.discard?t.mode===`result`?Iu(Object.values(e),kl,t):Iu(Object.values(e),i,t):M(()=>Vc(Iu(Object.entries(e),([e,n])=>Vc(t?.mode===`result`?kl(n):n,t=>[e,t]),{concurrency:t?.concurrency}),Object.fromEntries)),Fu=Cn({op:`While`,[Gt](e,t){return this[S].step(e),this[`~effect/Effect/args`].while()?(t._stack.push(this),this[S].body()):Zc},[Wt](e){return this[`~effect/Effect/args`].while()?(e._stack.push(this),this[S].body()):Zc}}),Iu=r(e=>typeof e[1]==`function`,(e,t,n)=>M(()=>{let r=Ru(n?.concurrency);if(r===1)return Lu(e,t,n);let i=ui(e),a=i.length;if(a===0)return n?.discard?N:A([]);let o=n?.discard?void 0:Array(a),s=Hu({f:t,out:o},i,{concurrency:r});return s?Sc(s,o):A(o)})),Lu=(e,t,n)=>M(()=>{let r=n?.discard?void 0:[],i=e[Symbol.iterator](),a=i.next(),o=0;return Sc(Fu({while:()=>!a.done,body:()=>t(a.value,o++),step:e=>{r&&r.push(e),a=i.next()}}),r)}),Ru=e=>e===`unbounded`?1/0:Math.max(1,e??1),zu=()=>e=>{let t=e.onItem,n=e.step,r=(e,t,r,a,o)=>P(Rl(o),o=>n(e,t[r],o,r)??i(e,t,r+1,a)??N),i=(e,i,a=0,o=i.length)=>{for(;a<o;a++){let s=i[a],c=t(e,s,a);if(!F(c))return r(e,i,a,o,c);let l=n(e,s,c,a);if(l)return l._tag===`Failure`?l:void 0}};return i},Bu=e=>{let t=e.onItem,n=e.step;return(e,r,i)=>{let a=0,o=i.end??r.length,s=i.concurrency,c=!1,l,u,d,f,p,m=e=>{let t=kn(e);return f=t,c=!0,u&&u.size>0?P(Eu(ec(Array.from(u))),()=>f??t):t},h=()=>{let i=!1;for(;!f&&a<o;a++){let o=r[a],g=p??t(e,o,a);if(F(g)){if(f=n(e,o,g,a),f)break}else if(l){p=void 0;let t=Uu(l,g,!0,!0,`inherit`);if(t._exit){if(f=n(e,o,t._exit,a),f)break;continue}u.add(t);let r=a;if(t.addObserver(a=>{u.delete(t);try{if(f){if(a._tag===`Failure`){let e=a.cause.reasons.filter(e=>e._tag!==`Interrupt`);if(e.length>0){let t=ln(e);f=Dn(f._tag===`Failure`?hs(dn(f.cause,t)):t)}}}else{let t=n(e,o,a,r);t&&(f=t,h())}if(i){let e=h();e&&d(e)}else c&&u.size===0&&d(f??N)}catch(e){d(m(e))}}),u.size<s)continue;i=!0,a++;return}else return pc(e=>{l=Vs(),u=new Set,p=g,d=e;let t;try{t=h()}catch(t){return e(m(t))}return t?e(t):M(()=>(f??=Zc,P(u?ec(u):N,()=>f?._tag===`Failure`?f:N)))})}if(c=!0,f){if(u&&u.size>0){let e=qs(l);u.forEach(t=>t.interruptUnsafe(l.id,e));return}if(d||f._tag===`Failure`)return f}else if(d){if(u)u.size===0&&d(N);else return Zc}};return h()}},Vu=()=>e=>Bu(e),Hu=Bu({onItem(e,t,n){return e.f(t,n)},step(e,t,n,r){if(n._tag===`Failure`)return n;e.out&&(e.out[r]=n.value)}}),Uu=(e,t,n=!1,r=!1,i=!1)=>{let a=e,o=i===`inherit`?a.interruptible:!i,s=new Hs(a.context,o);return r||(a.children().add(s),s._parent=a),n?s.evaluate(t):(s._asyncContext=Bs(),a.currentDispatcher.scheduleTask(()=>s.evaluate(t),0)),s},Wu=r(e=>Zt(e[0]),(e,t)=>w(n=>A(Uu(n,e,t?.startImmediately,!0,t?.uninterruptible)))),Gu=e=>()=>w(t=>t===e?N:Qs(e)),Ku=r(e=>Zt(e[0]),(e,t,n)=>w(r=>{let i=t.state._tag===`Closed`?new Hs(r.context):Uu(r,e,n?.startImmediately,!0,n?.uninterruptible);return i._exit||(t.state._tag===`Closed`?i.interruptUnsafe(r.id,qs(r)):(nu(t,i,Gu(i)),i.addObserver(()=>ru(t,i)))),A(i)})),qu=r(e=>Zt(e[0]),(e,t)=>P(su,n=>Ku(e,n,t))),Ju=e=>(t,n)=>{let r=new Hs(n?.scheduler?ca(e,So,n.scheduler):e,n?.uninterruptible!==!0);if(r.evaluate(t),r._exit)return r;if(n?.signal){if(n.signal.aborted)r.interruptUnsafe();else{let e=()=>r.interruptUnsafe();n.signal.addEventListener(`abort`,e,{once:!0}),r.addObserver(()=>n.signal.removeEventListener(`abort`,e))}}return n?.onFiberStart&&n.onFiberStart(r),r},Yu=r(2,(e,t)=>e._exit?e:t.state._tag===`Closed`?(e.interruptUnsafe(e.id),e):(ru(t,e),nu(t,e,Gu(e)),e.addObserver(()=>ru(t,e)),e)),Xu=Ju(aa()),Zu=e=>{let t=Ju(e);return(e,n)=>{let r=t(e,n);return n?.onExit&&r.addObserver(n.onExit),e=>r.interruptUnsafe(e)}},Qu=e=>{let t=Ju(e);return(e,n)=>{let r=t(e,n);return new Promise(e=>{r.addObserver(t=>e(t))})}},$u=Qu(aa()),ed=(e=>{let t=Qu(e);return(e,n)=>t(e,n).then(e=>{if(e._tag===`Failure`)throw ws(e.cause);return e.value})})(aa()),td=e=>{let t=Ju(e);return e=>{if(F(e))return e;let n=new Do(`sync`),r=t(e,{scheduler:n});return r._dispatcher?.flush(),r._exit??kn(new Pd(r))}},nd=td(aa()),rd=e=>{let t=td(e);return e=>{let n=t(e);if(n._tag===`Failure`)throw ws(n.cause);return n.value}},id=rd(aa()),ad=A(!0),od=A(!1),sd=class{waiters=[];scheduled=void 0;_isOpen;constructor(e){this._isOpen=e}scheduleUnsafe(e){if(this.waiters.length===0)return ad;if(this.scheduled===void 0)this.scheduled=this.waiters,e.currentDispatcher.scheduleTask(this.flushScheduled,0);else for(let e=0;e<this.waiters.length;e++)this.scheduled.push(this.waiters[e]);return this.waiters=[],ad}flushScheduled=()=>{if(this.scheduled===void 0)return;let e=this.scheduled;this.scheduled=void 0;for(let t=0;t<e.length;t++)e[t](Zc)};flushWaiters(){let e=this.waiters;this.waiters=[],this.flushScheduled();for(let t=0;t<e.length;t++)e[t](Zc)}open=w(e=>this._isOpen?od:(this._isOpen=!0,this.scheduleUnsafe(e)));release=w(e=>this._isOpen?od:this.scheduleUnsafe(e));openUnsafe(){return!this._isOpen&&(this._isOpen=!0,this.flushWaiters(),!0)}await=pc(e=>this._isOpen?e(N):(this.waiters.push(e),nc(()=>{let t=this.waiters.indexOf(e);t===-1?this.scheduled!==void 0&&(t=this.scheduled.indexOf(e),t!==-1&&this.scheduled.splice(t,1)):this.waiters.splice(t,1)})));closeUnsafe(){return this._isOpen?(this._isOpen=!1,!0):!1}close=nc(()=>this.closeUnsafe());whenOpen=e=>P(this.await,()=>e);isOpen(){return this._isOpen}},cd=e=>new sd(e??!1),ld=BigInt(0),ud={_tag:`Span`,spanId:`noop`,traceId:`noop`,sampled:!1,status:{_tag:`Ended`,startTime:ld,endTime:ld,exit:Zc},attributes:new Map,links:[],kind:`internal`,attribute(){},event(){},end(){},addLinks(){}},dd=e=>Object.assign(Object.create(ud),e),fd=e=>e?D(e.annotations,Uo)?e._tag===`Span`?fd(jr(e.parent)):T():E(e):T(),pd=(e,t,n)=>{let r=!e.cache.tracerEnabled||n?.annotations&&D(n.annotations,Uo),i=n?.parent===void 0?n?.root?T():fd(e.cache.span):E(n.parent),a;if(r)a=dd({name:t,parent:i,annotations:ca(n?.annotations??aa(),Uo,!0)});else{let r=e.cache.tracer??qo,o=e.getRef(bd),s=e.getRef(Qo),c=e.getRef($o),l=e.getRef(es),u=n?.level??e.getRef(Wo),d=n?.links===void 0?l.length===0?[]:l.slice():[...l,...n.links];a=r.span({name:t,parent:i,annotations:n?.annotations??aa(),links:d,startTime:s?o.currentTimeNanosUnsafe():ld,kind:n?.kind??`internal`,root:n?.root??!1,sampled:n?.sampled??(wr(i)&&i.value.sampled===!1?!1:!Rd(e.getRef(Go),u))});for(let e in c)a.attribute(e,c[e]);if(n?.attributes!==void 0)for(let e in n.attributes)a.attribute(e,n.attributes[e])}return a},md=(e,t)=>Eu(w(n=>{let r=fa(n.context,ql),i=pd(n,e,t??{}),a=n.getRef(bd),o=n.getRef(Qo);return Sc(eu(r,e=>gd(i,e,a,o)),i)})),hd=(e,t)=>(t=typeof t==`function`?t:c,al(Xo,n=>({name:e,stack:t,parent:n}))),gd=(e,t,n,r)=>nc(()=>{e.status._tag!==`Ended`&&e.end(r?n.currentTimeNanosUnsafe():ld,t)}),_d=(e,...t)=>{let n=t.length===1?void 0:t[0],r=t[t.length-1];return w(t=>{let i=pd(t,e,n),a=t.getRef(bd),o=t.getRef(Qo);return hu(t,e=>gd(i,e,a,o)),r(i)})},vd=ul(Vo),yd=function(){let e=Zt(arguments[0]),t=e?arguments[1]:arguments[0],n=e?arguments[2]:arguments[1],r=i;return t._tag===`Span`&&(n=os(n),r=hd(t.name,n?.captureStackTrace)),e?vd(r(arguments[0]),t):e=>vd(r(e),t)},bd=O(`effect/Clock`,{defaultValue:()=>new Sd}),xd=2**31-1,Sd=class{currentTimeMillisUnsafe(){return Date.now()}currentTimeMillis=nc(()=>this.currentTimeMillisUnsafe());currentTimeNanosUnsafe(){return Td()}currentTimeNanos=nc(()=>this.currentTimeNanosUnsafe());monotonicTimeNanosUnsafe(){return wd()}monotonicTimeNanos=nc(()=>this.monotonicTimeNanosUnsafe());sleep(e){return this.sleepMillis(uo(e))}sleepMillis(e){return e<=0?ic:Number.isFinite(e)?pc(t=>{let n=e>xd?this.sleepMillis(e-xd):N,r=setTimeout(()=>t(n),Math.min(e,xd));return nc(()=>clearTimeout(r))}):mc}},Cd=BigInt(1e6),wd=function(){let e=globalThis.process?.hrtime;if(typeof e?.bigint==`function`)return()=>e.bigint();if(typeof performance<`u`&&typeof performance.now==`function`)return()=>BigInt(Math.round(performance.now()*1e6));let t=BigInt(0);return()=>{let e=BigInt(Date.now())*Cd;return e>t&&(t=e),t}}(),Td=function(){let e=BigInt(1e9),t;return()=>{let n=wd(),r=BigInt(Date.now())*Cd;if(t===void 0)t=r-n;else{let i=t+n;(r>i?r-i:i-r)>e&&(t=r-n)}return t+n}}(),Ed=e=>w(t=>e(t.getRef(bd))),Dd=e=>Ed(t=>t.sleep(Ha(e))),Od=Ed(e=>e.currentTimeMillis),kd=`~effect/Cause/TimeoutError`,Ad=class extends Mn(`TimeoutError`){[kd]=kd;constructor(e){super({message:e})}},jd=`~effect/Cause/IllegalArgumentError`,Md=class extends Mn(`IllegalArgumentError`){[jd]=jd;constructor(e){super({message:e})}},Nd=`~effect/Cause/AsyncFiberError`,Pd=class extends Mn(`AsyncFiberError`){[Nd]=Nd;constructor(e){super({message:`An asynchronous Effect was executed with Effect.runSync`,fiber:e})}},Fd=`~effect/Cause/UnknownError`,Id=class extends Mn(`UnknownError`){[Fd]=Fd;constructor(e,t){super({message:t,cause:e})}},Ld=O(`effect/Console`,{defaultValue:()=>globalThis.console}),Rd=_r(mr(fr,e=>{switch(e){case`All`:return-(2**53-1);case`Fatal`:return 5e4;case`Error`:return 4e4;case`Warn`:return 3e4;case`Info`:return 2e4;case`Debug`:return 1e4;case`Trace`:return 0;case`None`:return 2**53-1}})),zd=O(`effect/Logger/CurrentLoggers`,{defaultValue:()=>new Set([Jd,Yd])}),Bd=O(`effect/Logger/LogToStderr`,{defaultValue:s}),Vd={"~effect/Logger":{_Message:i,_Output:i},pipe(){return e(this,arguments)}},Hd=e=>{let t=Object.create(Vd);return t.log=e,t},Ud=e=>e.replace(/[\s="]/g,`_`),Wd=(e,t)=>`${Ud(e[0])}=${t-e[1]}ms`,Gd=e=>(...t)=>{let n;for(let e=0,r=t.length;e<r;e++){let r=t[e];tn(r)&&(n?t.splice(e,1):t=t.slice(0,e).concat(t.slice(e+1)),n=n?ln(n.reasons.concat(r.reasons)):r,e--)}return n===void 0&&(n=pn),w(r=>{let i=e??r.cache.logLevel;if(Rd(r.cache.minimumLogLevel,i))return N;let a=r.getRef(bd),o=r.getRef(zd);if(o.size>0){let e=new Date(a.currentTimeMillisUnsafe());for(let a of o)a.log({cause:n,fiber:r,date:e,logLevel:i,message:t})}return N})},Kd={bold:`1`,red:`31`,green:`32`,yellow:`33`,blue:`34`,cyan:`36`,white:`37`,gray:`90`,black:`30`,bgBrightRed:`101`};Kd.gray,Kd.blue,Kd.green,Kd.yellow,Kd.red,Kd.bgBrightRed,Kd.black;var qd=e=>`${e.getHours().toString().padStart(2,`0`)}:${e.getMinutes().toString().padStart(2,`0`)}:${e.getSeconds().toString().padStart(2,`0`)}.${e.getMilliseconds().toString().padStart(3,`0`)}`,Jd=Hd(({cause:e,date:t,fiber:n,logLevel:r,message:i})=>{let a=Array.isArray(i)?i.slice():[i];e.reasons.length>0&&a.push(Ns(e));let o=t.getTime(),s=n.getRef(as),c=``;for(let e of s)c+=` ${Wd(e,o)}`;let l=n.getRef(ts);Object.keys(l).length>0&&a.push(l);let u=n.getRef(Ld);(n.getRef(Bd)?u.error:u.log)(`[${qd(t)}] ${r.toUpperCase()} (#${n.id})${c}:`,...a)}),Yd=Hd(({cause:e,fiber:t,logLevel:n,message:r})=>{let i=t.getRef(bd),a=t.getRef(ts),o=t.cache.span;if(o===void 0||o._tag===`ExternalSpan`||o.status._tag===`Ended`)return;let s={};for(let[e,t]of Object.entries(a))dt(s,e,t);s[`effect.fiberId`]=t.id,s[`effect.logLevel`]=n.toUpperCase(),e.reasons.length>0&&(s[`effect.cause`]=Ns(e)),o.event(Mt(Array.isArray(r)&&r.length===1?r[0]:r),i.currentTimeNanosUnsafe(),s)}),Xd=A(void 0),Zd=tn,Qd=nn,$d=vn,ef=yn,tf=ln,nf=mn,rf=gn,af=us,of=e=>new cn(e),sf=e=>new hn(e),cf=ls,lf=xs,uf=Cs,df=ws,ff=fs,pf=ps,mf=_s,hf=ys,gf=Ts,_f=Pn,vf=In,yf=Bn,bf=Md,xf=Ss,Sf=bd,Cf=Od,wf=Qt,Tf=C,Ef=Dn,Df=On,Of=kn,kf=Kc,Af=Zc,jf=qc,Mf=Jc,Nf={"~effect/Deferred":{_A:i,_E:i},pipe(){return e(this,arguments)}},Pf=function(){this.resumes=void 0,this.effect=void 0};Pf.prototype=Nf;var Ff=()=>new Pf,If=e=>pc(t=>e.effect?t(e.effect):(e.resumes??=[],e.resumes.push(t),nc(()=>{let n=e.resumes;if(n===void 0)return;let r=n.indexOf(t);r>=0&&n.splice(r,1)}))),Lf=r(2,(e,t)=>nc(()=>Hf(e,t))),Rf=r(2,(e,t)=>Lf(e,Dn(t))),zf=r(2,(e,t)=>Rf(e,us(t))),Bf=e=>e.effect!==void 0,Vf=r(2,(e,t)=>Lf(e,C(t))),Hf=(e,t)=>{if(e.effect)return!1;if(e.effect=t,e.resumes){let n=e.resumes;e.resumes=void 0;for(let e=0;e<n.length;e++)n[e](t)}return!0},Uf=ts,Wf=Qo,Gf=ql,Kf=iu,qf=cu,Jf=eu,Yf=tu,Xf=$l,Zf=Jl,Qf=`~effect/Layer`,$f=`~effect/Layer/MemoMap`,ep=(e,t)=>{let n={observers:0,deferred:Ff(),scope:Kf(),finalizer:r=>M(()=>--n.observers>0?N:(e.map.delete(t),Zf(n.scope,r)))};return n},tp=(e,t)=>t.state._tag!==`Closed`&&(e.observers++,nu(t,{},e.finalizer),!0),np={[Qf]:{_ROut:i,_E:i,_RIn:i},pipe(){return e(this,arguments)}},rp=e=>{let t=Object.create(np);return t.build=e,t},ip=e=>rp((t,n)=>{let r=Xf(n);return gu(e(t,r),e=>e._tag===`Failure`?Zf(r,e):N)}),ap=e=>{let t=ip((n,r)=>n.getOrElseMemoize(t,r,e));return t},op=class{get[$f](){return $f}parent;constructor(e){this.parent=e}map=new Map;get(e,t){let n=this.map.get(e);return n?(tp(n,t),n.deferred.effect??If(n.deferred)):this.parent?.get(e,t)}getOrElseMemoize(e,t,n){return M(()=>{let r;return mu(M(()=>{let i=this.get(e,t);if(i)return i;let a=ep(this,e);return tp(a,t)?(r=a.deferred,this.map.set(e,a),n(this,a.scope)):n(this,t)}),e=>{r&&Hf(r,e)})})}},sp=()=>new op,cp=e=>new op(e),lp=class e extends Hi()(`effect/Layer/CurrentMemoMap`){static forkOrCreate(t){let n=ua(t,e);return n?cp(n):sp()}},up=r(3,(e,t,n)=>ul(Vc(M(()=>e.build(t,n)),ca(lp,t)),lp,t)),dp=r(2,(e,t)=>w(n=>up(e,lp.forkOrCreate(n.context),t))),fp=function(){return arguments.length===1?e=>pp(sa(arguments[0],e)):pp(sa(arguments[0],arguments[1]))},pp=e=>rp(a(A(e))),mp=function(){return arguments.length===1?e=>hp(()=>sa(arguments[0],e())):hp(()=>sa(arguments[0],arguments[1]()))},hp=e=>ap(a(nc(e))),gp=function(){return arguments.length===1?e=>_p(arguments[0],e):_p(arguments[0],arguments[1])},_p=(e,t)=>vp(Vc(t,t=>sa(e,t))),vp=e=>ap((t,n)=>qf(e,n)),yp=(e,t,n)=>{let r=Xf(n,`parallel`);return Iu(e,e=>e.build(t,Xf(r,`sequential`)),{concurrency:e.length}).pipe(Vc(e=>va(...e)))},bp=(...e)=>ap((t,n)=>yp(e,t,n)),xp=(e,t,n)=>ap((r,i)=>P(Array.isArray(t)?yp(t,r,i):t.build(r,i),t=>e.build(r,i).pipe(ll(t),Vc(e=>n(e,t))))),Sp=r(2,(e,t)=>xp(e,t,i)),Cp=r(2,(e,t)=>xp(e,t,(e,t)=>_a(t,e))),wp=e=>rp((t,n)=>Tl(e.build(t,n))),Tp=`~effect/DateTime`,Ep=`~effect/DateTime/TimeZone`,Dp={[Tp]:Tp,pipe(){return e(this,arguments)},[At](){return this.toString()},toJSON(){return rm(this).toJSON()}},Op={...Dp,_tag:`Utc`,[Se](){return ke(this.epochMilliseconds)},[Ve](e){return Rp(e)&&e._tag===`Utc`&&this.epochMilliseconds===e.epochMilliseconds},toString(){return`DateTime.Utc(${rm(this).toJSON()})`}},kp={...Dp,_tag:`Zoned`,[Se](){return Te(ke(this.epochMilliseconds))(y(this.zone))},[Ve](e){return Rp(e)&&e._tag===`Zoned`&&this.epochMilliseconds===e.epochMilliseconds&&b(this.zone,e.zone)},toString(){return`DateTime.Zoned(${gm(this)})`}},Ap={[Ep]:Ep,[At](){return this.toString()}},jp={...Ap,_tag:`Named`,[Se](){return Ae(`Named:${this.id}`)},[Ve](e){return zp(e)&&e._tag===`Named`&&this.id===e.id},toString(){return`TimeZone.Named(${this.id})`},toJSON(){return{_id:`TimeZone`,_tag:`Named`,id:this.id}}},Mp={...Ap,_tag:`Offset`,[Se](){return Ae(`Offset:${this.offset}`)},[Ve](e){return zp(e)&&e._tag===`Offset`&&this.offset===e.offset},toString(){return`TimeZone.Offset(${om(this.offset)})`},toJSON(){return{_id:`TimeZone`,_tag:`Offset`,offset:this.offset}}},Np={value:void 0,enumerable:!1,writable:!0},Pp=new WeakMap,Fp=(e,t)=>({get(){return Object.isExtensible(this)?void 0:Pp.get(this)?.[e]},set(n){if(Object.isExtensible(this)){for(let e of t)Object.defineProperty(this,e,Np);this[e]=n}else{let t=Pp.get(this);t===void 0&&(t={},Pp.set(this,t)),t[e]=n}}}),Ip=[`partsUtc`,`adjustedEpochMilliseconds`,`partsAdjusted`];Object.defineProperty(Op,"partsUtc",Fp(`partsUtc`,[`partsUtc`])),Object.defineProperties(kp,{partsUtc:Fp(`partsUtc`,Ip),adjustedEpochMilliseconds:Fp(`adjustedEpochMilliseconds`,Ip),partsAdjusted:Fp(`partsAdjusted`,Ip)});var Lp=(e,t,n)=>{let r=Object.create(kp);return r.epochMilliseconds=e,r.zone=t,n!==void 0&&(r.partsUtc=n),r},Rp=e=>v(e,Tp),zp=e=>v(e,Ep),Bp=e=>e._tag===`Zoned`,Vp=e=>{let t=Object.create(Op);return t.epochMilliseconds=e,t},Hp=e=>{let t=e.getTime();if(Number.isNaN(t))throw new bf(`Invalid date`);return Vp(t)},Up=e=>{if(Rp(e))return e;if(e instanceof Date)return Hp(e);if(typeof e==`object`){if(`epochMilliseconds`in e)return Hp(new Date(e.epochMilliseconds));let t=new Date(0);return lm(t,e),Hp(t)}return typeof e==`string`&&!Wp(e)?Hp(new Date(e+`Z`)):Hp(new Date(e))},Wp=e=>/Z|GMT|[+-]\d{2}$|[+-]\d{2}:?\d{2}$|\]$/.test(e)||/z$|gmt$/i.test(e),Gp=-864e13+432e5,Kp=864e13-504e5,qp=(e,t)=>{let n=t?.timeZone;if(n===void 0&&Rp(e)&&Bp(e))return e;let r=Up(e);if(r.epochMilliseconds<Gp||r.epochMilliseconds>Kp)throw RangeError(`Epoch millis out of range: ${r.epochMilliseconds}`);n===void 0&&typeof e==`object`&&`timeZoneId`in e&&(n=e.timeZoneId);let i;if(n===void 0)i=$p(new Date(r.epochMilliseconds).getTimezoneOffset()*-60*1e3);else if(zp(n))i=n;else if(typeof n==`number`)i=$p(n);else{let e=nm(n);if(Cr(e))throw new bf(`Invalid time zone: ${n}`);i=e.value}return t?.adjustForTimeZone===!0?dm(r.epochMilliseconds,i,t?.disambiguation??`compatible`):Lp(r.epochMilliseconds,i,r.partsUtc)},Jp=()=>Vp(Date.now()),Yp=new Map,Xp={day:`numeric`,month:`numeric`,year:`numeric`,era:`short`,hour:`numeric`,minute:`numeric`,second:`numeric`,timeZoneName:`longOffset`,fractionalSecondDigits:3,hourCycle:`h23`},Zp=e=>{let t=e.resolvedOptions().timeZone,n=Yp.get(t);if(n!==void 0)return n;let r=Object.create(jp);return r.id=t,r.format=e,Yp.set(t,r),r},Qp=e=>{let t=Yp.get(e);if(t!==void 0)return t;try{let t=Zp(new Intl.DateTimeFormat(`en-US`,{...Xp,timeZone:e}));return Yp.set(e,t),t}catch{throw new bf(`Invalid time zone: ${e}`)}},$p=e=>{let t=Object.create(Mp);return t.offset=e,t},em=Mr(Qp),tm=/^(?:GMT)?[+-]/,nm=e=>{if(tm.test(e)){let t=pm(e);return t===null?T():E($p(t))}return em(e)},rm=e=>new Date(e.epochMilliseconds),im=e=>{if(e._tag===`Utc`)return new Date(e.epochMilliseconds);if(e.zone._tag===`Offset`)return new Date(e.epochMilliseconds+e.zone.offset);if(e.adjustedEpochMilliseconds!==void 0)return new Date(e.adjustedEpochMilliseconds);let t=!1,n=e.zone.format.formatToParts(e.epochMilliseconds).filter(e=>e.type===`era`?(t=e.value===`BC`,!1):e.type!==`literal`),r=Number(n[2].value),i=new Date(0);return i.setUTCFullYear(t?1-r:r,Number(n[0].value)-1,Number(n[1].value)),i.setUTCHours(Number(n[3].value),Number(n[4].value),Number(n[5].value),n[6]?.type===`fractionalSecond`?Number(n[6].value):(e.epochMilliseconds%1e3+1e3)%1e3),e.adjustedEpochMilliseconds=i.getTime(),i},am=e=>im(e).getTime()-cm(e),om=e=>{let t=Math.abs(e),n=Math.floor(t/36e5),r=Math.round(t%36e5/6e4);return r===60&&(n+=1,r=0),`${e<0?`-`:`+`}${String(n).padStart(2,`0`)}:${String(r).padStart(2,`0`)}`},sm=e=>om(am(e)),cm=e=>e.epochMilliseconds,lm=(e,t)=>{if((t.year!==void 0||t.month!==void 0||t.day!==void 0)&&e.setUTCFullYear(t.year??e.getUTCFullYear(),t.month===void 0?e.getUTCMonth():t.month-1,t.day??e.getUTCDate()),t.weekDay!==void 0){let n=t.weekDay-e.getUTCDay();e.setUTCDate(e.getUTCDate()+n)}t.hour!==void 0&&e.setUTCHours(t.hour),t.minute!==void 0&&e.setUTCMinutes(t.minute),t.second!==void 0&&e.setUTCSeconds(t.second),t.millisecond!==void 0&&e.setUTCMilliseconds(t.millisecond)},um=864e5,dm=(e,t,n)=>{if(t._tag===`Offset`)return Lp(e-t.offset,t);let r=mm(e-um,e,t),i=mm(e+um,e,t);if(r===i)return Lp(e-r,t);let a=r<i,o=r-i;if(a){if(mm(e-i,e,t)===i)return Lp(e-i,t);let a=Lp(e-r,t);if(e!==im(a).getTime())switch(n){case`reject`:{let n=new Date(e).toISOString();throw RangeError(`Gap time: ${n} does not exist in time zone ${t.id}`)}case`earlier`:return Lp(e-i,t);case`compatible`:case`later`:return a}return a}if(mm(e-r,e,t)===r){if(n===`earlier`||n===`compatible`||mm(e-r+o,e+o,t)===r)return Lp(e-r,t);if(n===`reject`){let n=new Date(e).toISOString();throw RangeError(`Ambiguous time: ${n} occurs twice in time zone ${t.id}`)}}return Lp(e-i,t)},fm=/([+-])(\d{2}):?(\d{2})$/,pm=e=>{let t=fm.exec(e);if(t===null)return null;let[,n,r,i]=t;return(n===`+`?1:-1)*(Number(r)*60+Number(i))*60*1e3},mm=(e,t,n)=>{let r=n.format.formatToParts(e).find(e=>e.type===`timeZoneName`)?.value??``;if(r===`GMT`)return 0;let i=pm(r);return i===null?am(Lp(t,n)):i},hm=e=>{let t=im(e);return e._tag===`Utc`?t.toISOString():`${t.toISOString().slice(0,-1)}${sm(e)}`},gm=e=>e.zone._tag===`Offset`?hm(e):`${hm(e)}[${e.zone.id}]`,_m=globalThis.Number,vm=xr(fr),ym=e=>{if(e===`NaN`)return E(NaN);if(e===`Infinity`)return E(1/0);if(e===`-Infinity`)return E(-1/0);if(e.trim()===``)return T();let t=_m(e);return _m.isNaN(t)?T():E(t)},bm=r(2,(e,t)=>{let n=10**t;return Math.round(e*n)/n}),xm=globalThis.String,Sm=re,Cm=e=>e.toUpperCase(),wm=e=>e.toLowerCase(),Tm=(e,t)=>n=>n.replace(e,t),Em=e=>e.trim(),Dm=(e,t)=>n=>n.slice(e,t),Om=e=>e.length===0,km=e=>e.length>0,Am=r(2,(e,t)=>{let n=e.split(t);return ct(n)?n:[e]}),jm=(e,t)=>n=>n.startsWith(e,t),Mm=e=>t=>Ar(t.match(e)),Nm=r(2,(e,t)=>vl(e,Lm,e=>t(e))),Pm=e=>e.reasons.some(Fm),Fm=e=>e._tag===`Fail`&&vf(e.error),Im=e=>{let t,n=!1;for(let r of e.reasons)Fm(r)?t??=r.error:r._tag!==`Interrupt`&&(n=!0);return t===void 0?Vr(e):n?Vr(tf(e.reasons.filter(e=>!Fm(e)))):Br(t)},Lm=e=>{let t=Im(e);return Wr(t)?t:Br(t.success.value)},Rm=e=>{let t=Im(e);return Wr(t)?Ef(t.failure):Tf(t.success.value)},zm=r(2,(e,t)=>Al(e,{onSuccess:t.onSuccess,onFailure:e=>{let n=Im(e);return Wr(n)?t.onFailure(n.failure):t.onDone(n.success.value)}})),Bm=`~effect/Schedule`,Vm=O(`effect/Schedule/CurrentMetadata`,{defaultValue:a({input:void 0,output:void 0,duration:ro,attempt:0,start:0,now:0,elapsed:0,elapsedSincePrevious:0})}),Hm={[Bm]:{_Out:i,_In:i,_Env:i},pipe(){return e(this,arguments)}},Um=e=>{let t=Object.create(Hm);return t.step=e,t},Wm=()=>{let e=0,t,n;return(r,i)=>{n===void 0&&(n=r);let a=r-n,o=t===void 0?0:r-t;return t=r,{input:i,attempt:++e,start:n,now:r,elapsed:a,elapsedSincePrevious:o}}},Gm=e=>Um(Vc(e,e=>{let t=Wm();return(n,r)=>e(t(n,r))})),Km=e=>ml(e.step,e=>A(()=>j(e))),qm=e=>Ed(t=>Vc(Km(e),e=>{let n=Wm();return r=>M(()=>{let i=t.currentTimeMillisUnsafe();return P(e(i,r),([e,t])=>{let a=n(i,r);return a.output=e,a.duration=t,Sc(Dd(t),a)})})})),Jm=e=>Um(Vc(Pu(e.map(Km)),e=>(t,n)=>P(Iu(e,e=>zm(e(t,n),{onSuccess:e=>A(e[1]),onDone:()=>Xd,onFailure:j})),e=>{let t=Ym(e);return t===void 0?yf(ro):A([t,t])}))),Ym=e=>{let t;for(let n=0;n<e.length;n++){let r=e[n];r!==void 0&&(t=t===void 0?r:_o(t,r))}return t},Xm=(e,t=2)=>{let n=uo(Ha(e));return Gm(A(e=>{let r=so(n*t**(e.attempt-1));return A([r,r])}))},Zm=e=>{let t=Ha(e);return Gm(A(e=>A([e.attempt-1,t])))},Qm=r(2,(e,t)=>Um(Vc(Km(e),e=>{let n=Wm();return(r,i)=>P(e(r,i),e=>{let[a,o]=e,s=t({...n(r,i),output:a,duration:o});return P(Zt(s)?s:A(s),t=>t?A(e):yf(a))})}))),$m=(e,t,n)=>uu(r=>P(n?.local?up(t,sp(),r):dp(t,r),t=>ll(e,t))),eh=r(e=>Zt(e[0]),(e,t,n)=>ra(t)?ll(e,t):$m(e,Array.isArray(t)?bp(...t):t,n)),th=r(3,(e,t,n)=>P(qm(t),t=>{let r=Vm.defaultValue(),i,a=vl(M(()=>ul(e,Vm,r)),gs,e=>(i=e,P(t(e),e=>(r=e,a))));return Nm(a,e=>zt(()=>n(i,e)))})),nh=`~effect/MutableHashMap`,rh={[nh]:nh,[Symbol.iterator](){return this.backing[Symbol.iterator]()},toString(){return`MutableHashMap(${x(Array.from(this))})`},toJSON(){return{_id:`MutableHashMap`,values:jt(Array.from(this))}},[At](){return this.toJSON()},pipe(){return e(this,arguments)}},ih=()=>{let e=Object.create(rh);return e.backing=new Map,e.buckets=new Map,e},ah=r(2,(e,t)=>{if(e.backing.has(t))return E(e.backing.get(t));if(oh(t))return T();let n=y(t),r=e.buckets.get(n);return r===void 0?T():sh(e,r,t)}),oh=e=>typeof e!=`object`&&typeof e!=`function`,sh=(e,t,n)=>{for(let r=0,i=t.length;r<i;r++)if(b(n,t[r])){let n=t[r];return E(e.backing.get(n))}return T()},ch=r(3,(e,t,n)=>{if(e.backing.has(t)||oh(t))return e.backing.set(t,n),e;let r=y(t),i=e.buckets.get(r);if(i===void 0)return e.buckets.set(r,[t]),e.backing.set(t,n),e;let a=lh(i,t);return a===void 0&&(i.push(t),a=t),e.backing.set(a,n),e}),lh=(e,t)=>{for(let n=0,r=e.length;n<r;n++)if(b(t,e[n]))return e[n]},uh=r(2,(e,t)=>{if(oh(t))return e.backing.delete(t),e;let n=y(t),r=e.buckets.get(n);if(r===void 0)return e;for(let n=0,i=r.length;n<i;n++){let i=r[n];if(i===t||b(t,i)){e.backing.delete(i),r.splice(n,1);break}}return r.length===0&&e.buckets.delete(n),e}),dh=Zt,fh=Iu,ph=Fu,mh=lc,hh=uc,I=A,gh=ac,L=M,R=nc,z=N,_h=pc,vh=mc,yh=hc,B=tc,bh=j,xh=oc,Sh=sc,Ch=cc,wh=w,Th=rc,V=P,Eh=Bc,Dh=Pc,Oh=Fc,kh=Rl,H=Vc,Ah=Sc,jh=Ic,Mh=ml,Nh=_l,Ph=Cl,Fh=Tl,Ih=Sl,Lh=bl,Rh=th,zh=Dl,Bh=Ol,Vh=Ul,Hh=Vl,Uh=Bl,Wh=Dd,Gh=Rc,Kh=fl,qh=Al,Jh=ol,Yh=cl,Xh=eh,Zh=ll,Qh=rl,$h=il,eg=ul,tg=su,ng=lu,rg=uu,ig=du,ag=fu,og=_u,sg=yu,cg=mu,lg=gu,ug=wu,dg=Tu,fg=Mu,pg=xu,mg=Eu,hg=Nu,gg=pl,_g=md,vg=_d,yg=yd,bg=Ku,xg=qu,Sg=Wu,Cg=Xu,wg=Ju,Tg=Zu,Eg=ed,Dg=$u,Og=id,kg=rd,Ag=nd,jg=_c,Mg=Gd(`Error`),Ng=r(e=>dh(e[0]),(e,...t)=>al(e,Uf,e=>{let n=t.length===1?{...e,...t[0]}:{...e};return t.length===1||dt(n,t[0],t[1]),n})),Pg=Hc,Fg=Uc,Ig=Wc,Lg=zc,Rg=Gc,zg=yc,Bg=Xs,Vg=Zs,Hg=Qs,Ug=Vs,Wg=Yu,Gg=`~effect/Chunk`;function Kg(e,t,n,r,i){for(let a=t;a<Math.min(e.length,t+i);a++)n[r+a-t]=e[a];return n}var qg=[],Jg=(e=>rt((t,n)=>{if(t.length!==n.length)return!1;let r=e_(t),i=e_(n);for(let t=0;t<r.length;t++)if(!e(r[t],i[t]))return!1;return!0}))(b),Yg={[Gg]:{_A:e=>e},toString(){return`Chunk(${x(e_(this))})`},toJSON(){return{_id:`Chunk`,values:jt(e_(this))}},[At](){return this.toJSON()},[Ve](e){return Zg(e)&&Jg(this,e)},[Se](){return Pe(e_(this))},[Symbol.iterator](){switch(this.backing._tag){case`IArray`:return this.backing.array[Symbol.iterator]();case`IEmpty`:return qg[Symbol.iterator]();default:return e_(this)[Symbol.iterator]()}},pipe(){return e(this,arguments)}},Xg=e=>{let t=Object.create(Yg);switch(t.backing=e,e._tag){case`IEmpty`:t.length=0,t.depth=0,t.left=t,t.right=t;break;case`IConcat`:t.length=e.left.length+e.right.length,t.depth=1+Math.max(e.left.depth,e.right.depth),t.left=e.left,t.right=e.right;break;case`IArray`:t.length=e.array.length,t.depth=0,t.left=Qg,t.right=Qg;break;case`ISingleton`:t.length=1,t.depth=0,t.left=Qg,t.right=Qg;break;case`ISlice`:t.length=e.length,t.depth=0,t.left=Qg,t.right=Qg}return t},Zg=e=>v(e,Gg),Qg=Xg({_tag:`IEmpty`}),$g=(e,t,n)=>{switch(e.backing._tag){case`IArray`:Kg(e.backing.array,0,t,n,e.length);break;case`IConcat`:$g(e.left,t,n),$g(e.right,t,n+e.left.length);break;case`ISingleton`:t[n]=e.backing.a;break;case`ISlice`:Kg(e_(e.backing.chunk),e.backing.offset,t,n,e.length)}},e_=e=>{switch(e.backing._tag){case`IEmpty`:return qg;case`IArray`:return e.backing.array;default:{let t=Array(e.length);return $g(e,t,0),e.backing={_tag:`IArray`,array:t},e.left=Qg,e.right=Qg,e.depth=0,t}}},t_=cd,n_=`~effect/MutableRef`,r_={[n_]:n_,...Yt,toJSON(){return{_id:`MutableRef`,current:jt(this.current)}}},i_=e=>{let t=Object.create(r_);return t.current=e,t},a_=r(2,(e,t)=>(e.current=t,e)),o_=Symbol.for(`effect/MutableList/Empty`),s_=()=>({head:void 0,tail:void 0,length:0}),c_=e=>{let t=e.head;t.offset>=1024&&t===e.tail&&t.mutable&&(t.array.length-t.offset)*8<=t.offset&&(e.head=e.tail={array:t.array.slice(t.offset),mutable:!0,offset:0,next:void 0})},l_=()=>({array:[],mutable:!0,offset:0,next:void 0}),u_=(e,t)=>{e.tail?e.tail.mutable||(e.tail.next=l_(),e.tail=e.tail.next):e.head=e.tail=l_(),e.tail.array.push(t),e.length++},d_=(e,t)=>f_(e,Array.from(t),!0),f_=(e,t,n=!1)=>{if(t.length===0)return 0;let r={array:t,mutable:n,offset:0,next:void 0};return e.head?e.tail=e.tail.next=r:e.head=e.tail=r,e.length+=t.length,t.length},p_=e=>{e.head=e.tail=void 0,e.length=0},m_=(e,t)=>{if(t=lt(t),t<=0||!e.head)return[];if(t=Math.min(t,e.length),t===e.length&&e.head?.offset===0&&!e.head.next){let t=e.head.array;return p_(e),t}let n=Array(t),r=0,i=e.head;for(;i;){for(;i.offset<i.array.length;)if(n[r++]=i.array[i.offset],i.mutable&&(i.array[i.offset]=void 0),i.offset++,r===t)return e.head=i.offset===i.array.length&&i.next?i.next:i,e.length-=t,e.length===0?p_(e):c_(e),n;i=i.next}return p_(e),n},h_=e=>m_(e,e.length),g_=e=>{if(!e.head)return o_;let t=e.head.array[e.head.offset];return e.head.mutable&&(e.head.array[e.head.offset]=void 0),e.head.offset++,e.length--,e.head.offset===e.head.array.length?e.head.next?e.head=e.head.next:p_(e):c_(e),t},__=(e,t)=>{let n=[],r=e.head,i=0;for(;r;){for(let e=r.offset;e<r.array.length;e++)t(r.array[e],i++)&&n.push(r.array[e]);r=r.next}n.length===0?p_(e):(e.head=e.tail={array:n,mutable:!0,offset:0,next:void 0},e.length=n.length)},v_=(e,t)=>__(e,e=>e!==t),y_=`~effect/PubSub/Subscription`,b_=r(2,(e,t)=>e.shutdownFlag.current||wr(e.ended.current)?!1:e.pubsub.publish(t)?(e.strategy.completeSubscribersUnsafe(e.pubsub,e.subscribers),!0):!1),x_=e=>mg(Yh(t=>{let n=D(t,Gf),r=Xf(e.scope),i=T_(e.pubsub,e.subscribers,e.strategy,e.ended);return Yf(r,S_(i)).pipe(Dh(Jf(n,e=>Zf(r,e))),Ah(i))})),S_=e=>mg(wh(t=>(a_(e.shutdownFlag,!0),fh(h_(e.pollers),e=>zf(e,t.id),{discard:!0,concurrency:`unbounded`}).pipe(Oh(()=>R(()=>{e.subscribers.delete(e.subscription),e.subscription.unsubscribe(),e.replayWindow.close(),e.strategy.onPubSubEmptySpaceUnsafe(e.pubsub,e.subscribers)})),Kh(e.shutdownHook.open),jh)))),C_=e=>L(function t(n){if(e.shutdownFlag.current)return dg;let r=e.pollers.length===0?e.subscription.pollUpTo(1/0):[];return n&&(r=n.concat(r)),e.strategy.onPubSubEmptySpaceUnsafe(e.pubsub,e.subscribers),e.replayWindow.remaining>0?I(e.replayWindow.takeAll().concat(r)):hi(r)?I(r):V(w_(e),e=>t([e]))}),w_=e=>_h(t=>{if(e.shutdownFlag.current)return t(dg);if(wr(e.ended.current)){let n=e.pollers.length===0?e.subscription.poll():o_;return n===o_?t(I(e.ended.current.value)):(e.strategy.onPubSubEmptySpaceUnsafe(e.pubsub,e.subscribers),t(I(n)))}let n=Ff(),r=e.subscribers.get(e.subscription);return r||(r=new Set,e.subscribers.set(e.subscription,r)),r.add(e.pollers),u_(e.pollers,n),e.strategy.completePollersUnsafe(e.pubsub,e.subscribers,e.subscription,e.pollers),n.effect?t(n.effect):(n.resumes=[t],R(()=>v_(e.pollers,n)))}),T_=(e,t,n,r)=>new E_(e,t,e.subscribe(),s_(),t_(!1),i_(!1),n,e.replayWindow(),r),E_=class{[y_]={_A:i};pubsub;subscribers;subscription;pollers;shutdownHook;shutdownFlag;strategy;replayWindow;ended;constructor(e,t,n,r,i,a,o,s,c){this.pubsub=e,this.subscribers=t,this.subscription=n,this.pollers=r,this.shutdownHook=i,this.shutdownFlag=a,this.strategy=o,this.replayWindow=s,this.ended=c}pipe(){return e(this,arguments)}},D_=`~effect/Queue`,O_=`~effect/Queue/Enqueue`,k_=`~effect/Queue/Dequeue`,A_={_A:i,_E:i},j_={[D_]:A_,[O_]:A_,[k_]:A_,...Yt,toJSON(){return{_id:`effect/Queue`,state:this.state._tag,size:q_(this)}}},M_=e=>w(t=>{let n=Object.create(j_);return n.dispatcher=t.currentDispatcher,n.capacity=e?.capacity??1/0,n.strategy=e?.strategy??`suspend`,n.messages=s_(),n.scheduleRunning=!1,n.state={_tag:`Open`,takers:new Set,offers:new Set,awaiters:new Set},A(n)}),N_=e=>M_({capacity:e}),P_=r(2,(e,t)=>M(()=>F_(e,t)?Y_:e.state._tag===`Open`&&e.strategy===`suspend`?iv(e,t):J_)),F_=(e,t)=>e.state._tag===`Open`?e.messages.length>=e.capacity?e.strategy===`sliding`?(g_(e.messages),u_(e.messages,t),!0):e.capacity<=0&&e.state.takers.size>0&&(u_(e.messages,t),Q_(e),!0):(u_(e.messages,t),$_(e),!0):!1,I_=r(2,(e,t)=>pc(n=>{let r=L_(e,t);return r.length===0||e.strategy===`dropping`?n(C(r)):av(e,{_tag:`Array`,remaining:r,offset:0,resume:n})})),L_=(e,t)=>{if(e.state._tag!==`Open`)return ui(t);if(e.capacity===1/0||e.strategy===`sliding`)return d_(e.messages,t),e.strategy===`sliding`&&m_(e.messages,e.messages.length-e.capacity),$_(e),[];let n=e.capacity<=0?e.state.takers.size:e.capacity-e.messages.length;if(n===0)return ui(t);let r=[],i=0;for(let a of t)i<n?u_(e.messages,a):r.push(a),i++;return $_(e),r},R_=r(2,(e,t)=>nc(()=>z_(e,t))),z_=(e,t)=>{if(e.state._tag!==`Open`)return!1;let n=tl(Dn(t),X_);return e.state.offers.size===0&&e.messages.length===0?(lv(e,n),!0):(e.state={...e.state,_tag:`Closing`,exit:n},$_(e),!0)},B_=e=>R_(e,mn(Rn())),V_=e=>nc(()=>H_(e)),H_=e=>{if(e.state._tag===`Done`)return!1;p_(e.messages);let t=e.state.offers;lv(e,e.state._tag===`Open`?Z_:e.state.exit);for(let e of t)ov(e);return!0},U_=e=>W_(e,1,1/0),W_=r(3,(e,t,n)=>(t=lt(t),n=lt(n),tv(()=>ev(e,t,n)??Pc(rv(e,()=>nv(e,t)),W_(e,t,n))))),G_=e=>tv(()=>K_(e)??Pc(rv(e,()=>nv(e,1)),G_(e))),K_=e=>{if(e.state._tag===`Done`)return e.state.exit;if(e.messages.length>0){let t=g_(e.messages);return cv(e),C(t)}if(e.capacity<=0&&e.state.offers.size>0){let t=sv(e.state.offers);return cv(e),C(t)}},q_=e=>e.state._tag===`Done`?0:e.messages.length,J_=C(!1),Y_=C(!0),X_=On(Rn()),Z_=Kc(),Q_=e=>{if(e.state._tag!==`Done`&&e.state.takers.size!==0){for(let t of e.state.takers)if(t.ready()&&(e.state.takers.delete(t),t.resume(Zc),e.messages.length===0))break}},$_=e=>{e.scheduleRunning||e.state._tag===`Done`||e.state.takers.size===0||(e.scheduleRunning=!0,e.dispatcher.scheduleTask(()=>{e.scheduleRunning=!1,Q_(e)},0))},ev=(e,t,n)=>{if(e.state._tag===`Done`)return e.state.exit;if(n<=0||t<=0)return C([]);if(!nv(e,t))return;let r=e.messages.length>0?m_(e.messages,n):[sv(e.state.offers)];return cv(e),C(r)},tv=Cn({op:`QueueTake`,[Wt](e){let t=this[S]();return Qt(t)?t[Wt](e):t}}),nv=(e,t)=>e.messages.length>=(e.state._tag===`Closing`?1:Math.min(t,e.capacity||1))||e.capacity<=0&&e.state._tag!==`Done`&&e.state.offers.size>0,rv=(e,t)=>pc(n=>{if(e.state._tag===`Done`)return n(e.state.exit);if(t())return n(Zc);let r={ready:t,resume:n};return e.state.takers.add(r),nc(()=>{e.state._tag!==`Done`&&e.state.takers.delete(r)})}),iv=(e,t)=>pc(n=>F_(e,t)?n(Y_):av(e,{_tag:`Single`,message:t,resume:n})),av=(e,t)=>{if(e.state._tag!==`Open`)return ov(t);let n=e.state.offers;return n.add(t),nc(()=>{e.state._tag!==`Done`&&(n.delete(t),e.state._tag===`Closing`&&n.size===0&&e.messages.length===0&&lv(e,e.state.exit))})},ov=e=>e._tag===`Single`?e.resume(J_):e.resume(C(e.remaining.slice(e.offset))),sv=e=>{let t=e.values().next().value;if(t._tag===`Single`)return e.delete(t),t.resume(Y_),t.message;let n=t.remaining[t.offset++];return t.offset===t.remaining.length&&(e.delete(t),t.resume(C([]))),n},cv=e=>{if(e.state._tag===`Done`)return Pm(e.state.exit.cause);if(e.state.offers.size===0)return e.state._tag===`Closing`&&e.messages.length===0&&(lv(e,e.state.exit),Pm(e.state.exit.cause));for(let t of e.state.offers){let n=e.capacity-e.messages.length;if(n<=0)break;if(t._tag===`Single`)u_(e.messages,t.message),e.state.offers.delete(t),t.resume(Y_);else{for(;t.offset<t.remaining.length;t.offset++){if(n===0)return!1;u_(e.messages,t.remaining[t.offset]),n--}e.state.offers.delete(t),t.resume(C([]))}let r=e.state;if(r._tag===`Done`)return Pm(r.exit.cause)}return!1},lv=(e,t)=>{if(e.state._tag===`Done`)return;let n=e.state;e.state={_tag:`Done`,exit:t};for(let e of n.takers)e.resume(t);n.takers.clear();for(let e of n.awaiters)e(t);n.awaiters.clear()},uv=e=>new pv(e),dv=e=>{for(let t of e.waiters)if(t.permits<=e.free)return t},fv=(e,t,n,r=i)=>w(i=>{if(e.free>=t&&dv(e)===void 0)return e.taken+=t,n();let a={permits:t,resume:void 0},o=()=>{e.waiters.delete(a)&&e.releaseUnsafe(i,0)};e.waiters.add(a),hu(i,o);let s=P(r(pc(t=>{dv(e)===a?t(N):a.resume=t})),()=>dv(e)===a?(e.taken+=t,o(),n()):s);return s}),pv=class{waiters=new Set;taken=0;permits;constructor(e){this.permits=e}get free(){return this.permits-this.taken}take(e){return fv(this,e,()=>A(e))}takeScoped(e){return Nu(t=>P(su,n=>fv(this,e,()=>tu(n,this.release(e)),t)))}takeIfAvailable(e){return M(()=>this.free<e?A(!1):(this.taken+=e,A(!0)))}releaseUnsafe(e,t){return this.taken-=t,this.waiters.size>0&&e.currentDispatcher.scheduleTask(()=>{let e=this.free;for(let t of Array.from(this.waiters)){if(!this.waiters.has(t)||t.permits>e)continue;e-=t.permits;let n=t.resume;t.resume=void 0,n?.(N)}},0),this.free}resize(e){return w(t=>(this.permits=e,this.free<0||this.releaseUnsafe(t,0),N))}release(e){return w(t=>A(this.releaseUnsafe(t,e)))}get releaseAll(){return w(e=>A(this.releaseUnsafe(e,this.taken)))}withPermits(e){return t=>Nu(n=>fv(this,e,()=>mu(n(t),()=>{this.releaseUnsafe(Vs(),e)},!0),n))}withPermit=this.withPermits(1);withPermitsIfAvailable(e){return t=>Nu(n=>this.free<e?ac:(this.taken+=e,mu(n(Nc(t)),()=>{this.releaseUnsafe(Vs(),e)},!0)))}},mv=`~effect/Channel`,hv=e=>v(e,mv),gv={[mv]:{_Env:i,_InErr:i,_InElem:i,_OutErr:i,_OutElem:i},pipe(){return e(this,arguments)}},_v=e=>{let t=Object.create(gv);return t.transform=(t,n)=>Mh(e(t,n),e=>I(bh(e))),t},vv=(e,t)=>_v((n,r)=>V(xv(e)(n,r),e=>t(e,r))),yv=e=>_v((t,n)=>e),bv=e=>_v(jg(function*(t,n){let r=Xf(n),i=e=>Zf(r,Rm(e));return sg(yield*sg(e(t,n,r),i),i)})),xv=e=>e.transform,Sv=(e,t,n)=>M_({capacity:n?.bufferSize,strategy:n?.strategy}).pipe(Oh(t=>Yf(e,V_(t))),Oh(n=>qf(t(n),e).pipe(Mh(e=>R_(n,e)),bg(e,{startImmediately:!0})))),Cv=(e,t)=>_v((n,r)=>H(Sv(r,e,t),U_)),wv=e=>_v((t,n)=>L(()=>xv(e())(t,n))),Tv=yv(I(yf())),Ev=e=>yv(I(B(e))),Dv=e=>yv(I(U_(e))),Ov=e=>yv(I(pg(C_(e),()=>yf()))),kv=e=>Hv(H(x_(e),Ov)),Av=e=>_v((t,n)=>jv({scope:n,readable:e.evaluate(),onError:e.onError,releaseLockOnEnd:e.releaseLockOnEnd})),jv=e=>{let t=e.readable.getReader(),n=e.exit??i_(void 0),r=L(()=>n.current?n.current:qh(hh({try:()=>t.read(),catch:e.onError}),{onFailure:e=>n.current??bh(e),onSuccess:({done:e,value:t})=>n.current?n.current:e?yf():I(Ai(t))}));return Ah(Yf(e.scope,e.releaseLockOnEnd?R(()=>t.releaseLock()):mh(()=>t.cancel().catch(e=>t.closed.then(()=>Promise.reject(e),l))).pipe(og(R(()=>t.releaseLock())))),r)},Mv=r(2,(e,t)=>vv(e,e=>R(()=>{let n=0;return H(e,e=>t(e,n++))}))),Nv=e=>e===void 0||e!==`unbounded`&&e<=1,Pv=r(e=>hv(e[0]),(e,t,n)=>Nv(n?.concurrency)?Fv(e,t):Iv(e,t,n)),Fv=(e,t)=>_v((n,r)=>{let i=0;return H(xv(e)(n,r),V(e=>t(e,i++)))}),Iv=(e,t,n)=>bv(jg(function*(r,i,o){let s=0,c=yield*xv(e)(r,i),l=n.concurrency===`unbounded`?2**53-1:Math.min(n.concurrency,2**53-1),u=yield*N_(0);yield*Yf(o,V_(u));let d=wg(yield*Jh()),f=Wg(o);if(n.unordered){let e=uv(l),n=a(e.release(1)),r=qh({onFailure:e=>V(R_(u,e),n),onSuccess:e=>V(P_(u,e),n)});yield*e.take(1).pipe(V(()=>c),V(e=>{let n=s++;return f(d(r(L(()=>t(e,n))))),z}),gg({disableYield:!0}),Mh(t=>e.withPermits(l-1)(R_(u,t))),bg(o))}else{let e=yield*N_(l-2);yield*Yf(o,V_(e)),yield*G_(e).pipe(Eh,V(e=>P_(u,e)),gg({disableYield:!0}),Mh(e=>R_(u,e)),bg(o));let n,r=e=>{e._tag!==`Success`&&(n=e.cause,z_(u,e.cause))};yield*c.pipe(V(i=>{if(n)return bh(n);let a=s++,o=d(L(()=>t(i,a)));return f(o),o.addObserver(r),P_(e,Bg(o))}),gg({disableYield:!0}),Mh(t=>P_(e,Ef(t)).pipe(Dh(R_(e,t)))),bg(o))}return G_(u)})),Lv=e=>vv(e,e=>{let t,n=0;return I(L(function r(){if(t===void 0)return V(e,e=>{switch(e.length){case 0:return r();case 1:return I(e[0]);default:return t=e,I(e[n++])}});let i=t[n++];return n>=t.length&&(t=void 0,n=0),I(i)}))}),Rv=(e,t)=>_v((n,r)=>R(()=>{let i,a=()=>{let o=Xf(r);return V(xv(e)(n,o),e=>(i=Mh(e,e=>{let n=Rm(e);return Zf(o,n).pipe(V(()=>t(n,r)),V(a))}),i))};return L(()=>i??a())})),zv=r(2,(e,t)=>vv(e,e=>I(V(e,function n(r){let i=[];for(let e=0;e<r.length;e++)t(r[e])&&i.push(r[e]);return gi(i)?I(i):V(e,n)})))),Bv=r(2,(e,t)=>wv(()=>{let n,r=Vm.defaultValue(),a=Gv(Zv(e,Vm,R(()=>r)),()=>(n=void 0,z)),o=typeof t==`function`?t(i):t;return Rv(a,(e,t)=>{if(jf(e))return yf(e.value);let i=gs(e.cause);return Wr(i)?bh(i.failure):yh(function*(){n||=yield*qm(o),r=yield*n(i.success)}).pipe(Nm(()=>B(i.success)),qf(t))})})),Vv=r(e=>hv(e[0])&&hv(e[1]),(e,t,n)=>bv(jg(function*(r,i,a){let o=n?.haltStrategy??`both`,s=yield*N_(0);yield*Yf(a,V_(s));let c=0;function l(e,t){if(c++,!Pm(t))return R_(s,t);switch(o){case`both`:return c===2?R_(s,t):z;case`left`:case`right`:return e===o?R_(s,t):z;case`either`:return R_(s,t)}}let u=(e,t,n)=>xv(t)(r,n).pipe(V(e=>e.pipe(V(e=>P_(s,e)),gg)),sg(t=>cg(Rm(t),e=>Zf(n,e)).pipe(qh({onFailure:t=>l(e,t),onSuccess:()=>l(e,t)}))),bg(a));return yield*u(`left`,e,Xf(a)),yield*u(`right`,t,Xf(a)),G_(s)}))),Hv=e=>_v((t,n)=>{let r;return I(L(()=>r||e.pipe(qf(n),V(e=>xv(e)(t,n)),V(e=>r=e))))}),Uv=r(2,(e,t)=>Vv(e,yv(I(V(t,yf))),{haltStrategy:`either`})),Wv=r(2,(e,t)=>bv((n,r,i)=>Jf(i,t).pipe(Dh(xv(e)(n,r))))),Gv=r(2,(e,t)=>vv(e,e=>R(()=>{let n=!0,r=Oh(e,e=>(n=!1,t(e)));return L(()=>n?r:e)}))),Kv=r(2,(e,t)=>vv(e,e=>I(Nm(e,e=>V(t,()=>yf(e)))))),qv=r(2,(e,t)=>Wv(e,e=>t)),Jv=(e,t,n)=>L(()=>{let r=Kf();return Nm(V(xv(e)(yf(),r),t),n||I).pipe(lg(e=>Zf(r,e)))}),Yv=r(2,(e,t)=>_v((n,r)=>H(Zh(xv(e)(n,r),t),Zh(t)))),Xv=r(3,(e,t,n)=>_v((r,i)=>H(eg(xv(e)(r,i),t,n),eg(t,n)))),Zv=r(3,(e,t,n)=>_v((r,i)=>V(n,n=>xv(Xv(e,t,n))(r,i)))),Qv=r(2,(e,t)=>Jv(e,e=>gg(V(e,t),{disableYield:!0}))),$v=e=>H(ey(e,()=>({bytes:0,arrays:[]}),(e,t)=>{for(let n=0;n<t.length;n++)e.bytes+=t[n].length,e.arrays.push(t[n]);return e}),({arrays:e,bytes:t})=>{let n=new Uint8Array(t),r=0;for(let t=0;t<e.length;t++){let i=e[t];n.set(i,r),r+=i.length}return n}),ey=r(3,(e,t,n)=>L(()=>{let r=t();return Jv(e,e=>ph({while:o,body:()=>e,step:e=>{r=n(r,e)}}),()=>I(r))})),ty=jg(function*(e){let t=uv(1),n=yield*Jh(),r=D(n,Gf);return(yield*xv(e)(yf(),r)).pipe(Zh(n),t.withPermits(1))},Mh(e=>I(bh(e)))),ny=(e,t)=>xv(e)(yf(),t),ry=`~effect/Stream`,iy={_R:i,_E:i,_A:i},ay=function(e){this.channel=e};ay.prototype={[ry]:iy,pipe(){return e(this,arguments)}};var oy=e=>new ay(e),sy=`~effect/Stream`,cy=e=>v(e,sy),ly=oy,uy=e=>dy(R(()=>{let t=!0,n=I(Ai(void 0)),r=Uh(n,e);return L(()=>t?(t=!1,n):r)})),dy=e=>ly(yv(e)),fy=e=>e.channel,py=(e,t)=>ly(Cv(e,t)),my=ly(Tv),hy=e=>{let t=ly(wv(()=>e().channel));return gy.set(t,e),t},gy=new WeakMap,_y=e=>ly(Ev(e)),vy=e=>ly(Dv(e)),yy=e=>ly(kv(e)),by=e=>ly(Av(e)),xy=e=>ly(Hv(H(e,fy))),Sy=r(e=>cy(e[0]),(e,t,n)=>e.channel.pipe(Lv,Pv(t,n),Mv(Ai),ly)),Cy=r(2,(e,t)=>ly(zv(fy(e),t))),wy=r(2,(e,t)=>ly(Bv(e.channel,t))),Ty=r(2,(e,t)=>ly(Uv(e.channel,t))),Ey=r(2,(e,t)=>ly(Kv(e.channel,t))),Dy=r(2,(e,t)=>ly(qv(e.channel,t))),Oy=r(2,(e,t)=>ly(Yv(e.channel,t))),ky=r(2,(e,t)=>Qv(e.channel,t)),Ay=e=>ty(e.channel),jy=e=>H($v(e.channel),e=>e.buffer),My=r(e=>cy(e[0]),(e,t,n)=>{let r,i,a=!1,o=t_(!1),s=n?.signal,c=()=>i.interruptUnsafe();return new ReadableStream({start(n){i=Cg(Zh(Qv(vv(e.channel,e=>I(o.whenOpen(e))),e=>R(()=>{o.closeUnsafe();for(let t=0;t<e.length;t++)n.enqueue(e[t]);r(),r=void 0})),t)),i.addObserver(e=>{s?.removeEventListener(`abort`,c),a||(e._tag===`Failure`&&s?.aborted!==!0?n.error(df(e.cause)):n.close())}),s!==void 0&&i.pollUnsafe()===void 0&&(s.aborted?c():s.addEventListener(`abort`,c,{once:!0}))},pull(){return new Promise(e=>{r=e,o.openUnsafe()})},cancel(){if(i)return a=!0,Eg(jh(Hg(i)))}},n?.strategy)}),Ny=r(e=>cy(e[0]),(e,t)=>H(Jh(),n=>My(e,n,t)));function Py(e){return{_tag:`Value`,value:e}}function Fy(e,t){return{_tag:`Record`,keys:e,value:t}}function Iy(e,t){return{_tag:`Array`,length:e,value:t}}var Ly=O(`effect/ConfigProvider`,{defaultValue:()=>Gy()}),Ry={...Yt,toJSON(){return{_id:`ConfigProvider`}}},zy=e=>e;function By(e,t){let n=Object.create(Ry);return n.load=e,n.mapInput=t,n}function Vy(e,t){return By(n=>e(t(n)),n=>Vy(e,e=>n(t(e))))}function Hy(e){return Vy(e,zy)}function Uy(e,t){return e===``&&!t?void 0:e}function Wy(e,t){let n=t?.preserveEmptyStrings===!0,r=Ky(e);return Hy(t=>I(qy(r,e,t,n)))}function Gy(e){return Wy(e?.env??{BASE_URL:`/`,DEV:!1,MODE:`production`,PROD:!0,SSR:!1,TSS_INLINE_CSS_ENABLED:`false`},{preserveEmptyStrings:e?.preserveEmptyStrings})}function Ky(e){let t={};for(let[n,r]of Object.entries(e)){if(r===void 0)continue;let e=n.split(`_`),i=t;for(let t of e){let e=i.children??=Object.create(null);i=e[t]??={}}}return t}function qy(e,t,n,r){let i=n.map(String).join(`_`),a=Uy(Object.hasOwn(t,i)?t[i]:void 0,r),o=Jy(e,n),s=o?.children?Object.keys(o.children):[];return s.length===0?a===void 0?void 0:Py(a):s.every(_i)?Iy(Math.max(...s.map(e=>parseInt(e,10)))+1,a):Fy(new Set(s),a)}function Jy(e,t){if(t.length===0)return e;let n=e;for(let e of t)if(n=n?.children?.[String(e)],!n)return;return n}var Yy=`~effect/BigDecimal`,Xy={[Yy]:Yy,[Se](){let e=ib(this);return Te(Ae(String(e.value)),ke(e.scale))},[Ve](e){return Zy(e)&&ub(this,e)===0},toString(){return`BigDecimal(${fb(this)})`},toJSON(){return{_id:`BigDecimal`,value:String(this.value),scale:this.scale}},[At](){return this.toJSON()},pipe(){return e(this,arguments)}},Zy=e=>v(e,Yy),Qy=(e,t)=>{if(!Number.isSafeInteger(t))throw RangeError(`Scale must be a safe integer, got ${t}`);let n=Object.create(Xy);return n.value=e,n.scale=t,n},$y=(e,t)=>{let n=Qy(e,t);return n.normalized=n,n},eb=BigInt(0),tb=BigInt(1),nb=BigInt(10),rb=$y(eb,0),ib=e=>{if(e.normalized===void 0){if(e.value===eb)e.normalized=rb;else{let t=`${e.value}`,n=ab(t);e.normalized=$y(BigInt(t.slice(0,t.length-n)),e.scale-n)}}return e.normalized},ab=e=>{let t=e.length;for(;e[t-1]===`0`;)t--;return e.length-t},ob=100,sb=[tb],cb=(e,t)=>e===t?0:e<t?-1:1,lb=(e,t)=>{let n=`${e.value<eb?-e.value:e.value}`,r=`${t.value<eb?-t.value:t.value}`,i=BigInt(n.length-r.length)-BigInt(e.scale)+BigInt(t.scale);if(i!==eb)return i<eb?-1:1;let a=Math.max(n.length,r.length);return dr(n.padEnd(a,`0`),r.padEnd(a,`0`))},ub=(e,t)=>{if(e.scale===t.scale)return cb(e.value,t.value);let n=db(e),r=db(t);if(n!==r)return n<r?-1:1;if(n===0)return 0;let i=e.scale-t.scale,a=Math.abs(i);if(a>ob)return n===-1?lb(t,e):lb(e,t);let o=sb[a]??=nb**BigInt(a);return i>0?cb(e.value,t.value*o):cb(e.value*o,t.value)},db=e=>e.value===eb?0:e.value<eb?-1:1,fb=e=>{let t=ib(e);if(Math.abs(t.scale)>=16)return pb(t);let n=t.value<eb,r=`${n?-t.value:t.value}`,i=t.scale>0?r.padStart(t.scale+1,`0`):r.padEnd(r.length-t.scale,`0`),a=i.length-t.scale,o=t.scale>0?`${i.slice(0,a)}.${i.slice(a)}`:i;return n?`-${o}`:o},pb=e=>{if(mb(e))return`0e+0`;let t=ib(e),n=`${t.value}`,r=t.value<eb?2:1,i=n.slice(0,r),a=n.slice(r),o=a.length-t.scale;return`${i}${a===``?``:`.${a}`}e${o>=0?`+`:``}${o}`},mb=e=>e.value===eb,hb=e=>_b(typeof e==`string`?bb.encode(e):e),gb=e=>{let t=Sb(e),n=t.length;if(n%4!=0)return Vr(new Po({kind:`Decode`,module:`Base64`,input:t,message:`Length must be a multiple of 4, but is ${n}`}));let r=t.indexOf(`=`);if(r!==-1&&(r<n-2||r===n-2&&t[n-1]!==`=`))return Vr(new Po({kind:`Decode`,module:`Base64`,input:t,message:`Found a '=' character, but it is not at the end`}));try{let e=t.endsWith(`==`)?2:+!!t.endsWith(`=`),r=new Uint8Array(n/4*3-e);for(let e=0,i=0;e<n;e+=4,i+=3){let n=Db(t.charCodeAt(e))<<18|Db(t.charCodeAt(e+1))<<12|Db(t.charCodeAt(e+2))<<6|Db(t.charCodeAt(e+3));r[i]=n>>16,r[i+1]=n>>8&255,r[i+2]=n&255}return Br(r)}catch(e){return Vr(new Po({kind:`Decode`,module:`Base64`,input:t,message:e instanceof Error?e.message:`Invalid input`}))}},_b=e=>{let t=e.length,n=Uint8Array.prototype.toBase64;return t>=32&&typeof n==`function`?n.call(e):t<128?vb(e):yb(e)},vb=e=>{let t=e.length,n=``,r=2;for(;r<t;r+=3)n+=Cb[e[r-2]>>2],n+=Cb[(e[r-2]&3)<<4|e[r-1]>>4],n+=Cb[(e[r-1]&15)<<2|e[r]>>6],n+=Cb[e[r]&63];return r===t+1&&(n+=Cb[e[r-2]>>2],n+=Cb[(e[r-2]&3)<<4],n+=`==`),r===t&&(n+=Cb[e[r-2]>>2],n+=Cb[(e[r-2]&3)<<4|e[r-1]>>4],n+=Cb[(e[r-1]&15)<<2],n+=`=`),n},yb=e=>{let t=e.length,n=new Uint8Array(Math.ceil(t/3)*4),r,i=0;for(r=2;r<t;r+=3,i+=4)n[i]=wb[e[r-2]>>2],n[i+1]=wb[(e[r-2]&3)<<4|e[r-1]>>4],n[i+2]=wb[(e[r-1]&15)<<2|e[r]>>6],n[i+3]=wb[e[r]&63];return r===t+1&&(n[i]=wb[e[r-2]>>2],n[i+1]=wb[(e[r-2]&3)<<4],n[i+2]=Tb,n[i+3]=Tb),r===t&&(n[i]=wb[e[r-2]>>2],n[i+1]=wb[(e[r-2]&3)<<4|e[r-1]>>4],n[i+2]=wb[(e[r-1]&15)<<2],n[i+3]=Tb),xb.decode(n)},bb=new TextEncoder,xb=new TextDecoder,Sb=e=>e.replace(/[\n\r]/g,``),Cb=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/`,wb=bb.encode(Cb),Tb=61,Eb=new Uint8Array(123).fill(255);for(let e=0;e<64;e++)Eb[Cb.charCodeAt(e)]=e;Eb[61]=0;var Db=e=>{if(e>=Eb.length||Eb[e]===255)throw TypeError(`Invalid character ${String.fromCharCode(e)}`);return Eb[e]},Ob=Rp,kb=Up,Ab=qp,jb=Jp,Mb=cm,Nb=`~effect/HashMap`,Pb=e=>v(e,Nb),Fb=`~effect/HashSet`,Ib=e=>v(e,Fb),Lb=`~effect/http/Cookies`,Rb=`~effect/http/Cookies/Cookie`,zb={[Lb]:Lb,...Nt,toJSON(){return{_id:`effect/Cookies`,cookies:ni(this.cookies,e=>e.toJSON())}},pipe(){return e(this,arguments)}},Bb=e=>{let t=Object.create(zb);return t.cookies=e,t},Vb=e=>{let t={};for(let n of e)dt(t,n.name,n);return Bb(t)},Hb=e=>{let t=typeof e==`string`?[e]:e,n=[];for(let e of t){let t=Ub(e.trim());t&&n.push(t)}return Vb(n)};function Ub(e){let t=e.split(`;`).map(e=>e.trim()).filter(e=>e!==``);if(t.length===0)return;let n=t[0].indexOf(`=`);if(n===-1)return;let r=t[0].slice(0,n).replace(Gb,``);if(!Wb.test(r))return;let i=t[0].slice(n+1).replace(Gb,``),a=Jb(i);if(t.length===1)return Object.assign(Object.create(qb),{name:r,value:a,valueEncoded:i});let o={};for(let e=1;e<t.length;e++){let n=t[e],r=n.indexOf(`=`),i=r===-1?n:n.slice(0,r).trim(),a=r===-1?void 0:n.slice(r+1).trim();switch(i.toLowerCase()){case`domain`:{if(a===void 0)break;let e=a.trim().replace(/^\./,``);e&&(o.domain=e);break}case`expires`:{if(a===void 0)break;let e=new Date(a);isNaN(e.getTime())||(o.expires=e);break}case`max-age`:if(a===void 0||!Kb.test(a))break;o.maxAge=co(parseInt(a,10));break;case`path`:if(a===void 0)break;a[0]===`/`&&(o.path=a);break;case`priority`:if(a===void 0)break;switch(a.toLowerCase()){case`low`:o.priority=`low`;break;case`medium`:o.priority=`medium`;break;case`high`:o.priority=`high`}break;case`httponly`:o.httpOnly=!0;break;case`secure`:o.secure=!0;break;case`partitioned`:o.partitioned=!0;break;case`samesite`:if(a===void 0)break;switch(a.toLowerCase()){case`lax`:o.sameSite=`lax`;break;case`strict`:o.sameSite=`strict`;break;case`none`:o.sameSite=`none`}}}return Object.assign(Object.create(qb),{name:r,value:a,valueEncoded:i,options:Object.keys(o).length>0?o:void 0})}var Wb=/^[!#$%&'*+\-.^_`|~0-9A-Za-z]+$/,Gb=/^[\t ]+|[\t ]+$/g,Kb=/^-?[0-9]+$/,qb={[Rb]:Rb,...Nt,toJSON(){return{_id:`effect/Cookies/Cookie`,name:this.name,value:this.value,options:this.options}}},Jb=e=>{try{return decodeURIComponent(e)}catch{return e}},Yb=new WeakMap,Xb=e=>{if(Yb.has(e))return Yb.get(e);throw Error(`Unable to get redacted value`+(e.label?` with label: "${e.label}"`:``))},Zb=`~effect/Redacted`,Qb=e=>v(e,Zb),$b=(e,t)=>{let n=Object.create(ex);return t?.label&&(n.label=t.label),Yb.set(n,e),n},ex={[Zb]:{_A:e=>e},label:void 0,...Yt,toJSON(){return this.toString()},toString(){return`<redacted${re(this.label)?`:`+this.label:``}>`},[Se](){return y(Yb.get(this))},[Ve](e){return Qb(e)&&b(Yb.get(this),Yb.get(e))}},tx=Xb,nx=Symbol.for(`~effect/http/Headers`),rx=Object.defineProperties(Object.create(null),{[nx]:{value:nx},[pt]:{value(e){return px(this,D(e,hx))}},toJSON:{value(){return ht(this)}},[Ve]:{value(e){return ax(this,e)}},[Se]:{value(){return Me(this)}},toString:{value:Nt.toString},[At]:{value:Nt[At]}}),ix=e=>Object.assign(Object.create(rx),e),ax=oi(at()),ox=Object.create(rx),sx=e=>{if(e===void 0)return ox;if(Symbol.iterator in e){let t=Object.create(rx);for(let[n,r]of e)t[n.toLowerCase()]=r;return t}let t=Object.create(rx);for(let[n,r]of Object.entries(e))Array.isArray(r)?t[n.toLowerCase()]=r.join(`, `):r!==void 0&&(t[n.toLowerCase()]=r);return t},cx=e=>Object.setPrototypeOf(e,rx),lx=r(3,(e,t,n)=>{let r=ix(e);return r[t.toLowerCase()]=n,r}),ux=r(2,(e,t)=>ix({...e,...sx(t)})),dx=r(2,(e,t)=>{let n=ix(e);return Object.assign(n,t),n}),fx=r(2,(e,t)=>{let n=ix(e);return delete n[t.toLowerCase()],n}),px=r(2,(e,t)=>{let n={...e},r=t=>{if(typeof t==`string`){let r=t.toLowerCase();r in e&&(n[r]=$b(e[r]))}else for(let r in e)r.search(t)!==-1&&(n[r]=$b(e[r]))};if(Array.isArray(t))for(let e=0;e<t.length;e++)r(t[e]);else r(t);return n}),mx=(e,t)=>{let n=e.toLowerCase();for(let r=0;r<t.length;r++){let i=t[r];if(typeof i==`string`){if(i.toLowerCase()===n)return!0}else if(e.search(i)!==-1)return!0}return!1},hx=O(`effect/Headers/CurrentRedactedNames`,{defaultValue:()=>[`authorization`,`cookie`,`set-cookie`,`x-api-key`]}),gx=e=>typeof e==`string`?e:tx(e),_x=new TextDecoder(`utf-8`,{ignoreBOM:!0}),vx=e=>new URLSearchParams(_x.decode(e).replace(/^\?/,`%3F`)),yx=`~effect/http/UrlParams`,bx=e=>v(e,yx),xx={...Yt,[yx]:yx,[Symbol.iterator](){return this.params[Symbol.iterator]()},[pt](e){return{_id:`UrlParams`,params:Object.fromEntries(Ax(this,D(e,Bx)))}},toJSON(){return ht(this)},[Ve](e){return Ex(this,e)},[Se](){return Pe(this.params.flat())}},Sx=e=>{let t=Object.create(xx);return t.params=e,t},Cx=e=>{if(bx(e))return e;let t=wx(e),n=[];for(let e=0;e<t.length;e++)if(Array.isArray(t[e][0])){let[r,i]=t[e];n.push([`${r[0]}[${r.slice(1).join(`][`)}]`,i])}else n.push(t[e]);return Sx(n)},wx=e=>{let t=typeof e[Symbol.iterator]==`function`?ui(e):Object.entries(e),n=[];for(let[e,r]of t)if(Array.isArray(r))for(let t=0;t<r.length;t++)r[t]!==void 0&&n.push([e,Tx(r[t])]);else if(typeof r==`object`&&r&&!Qb(r)){let t=wx(r);for(let[r,i]of t)n.push([[e,...typeof r==`string`?[r]:r],i])}else r!==void 0&&n.push([e,Tx(r)]);return n},Tx=e=>Qb(e)?e:String(e),Ex=rt((e,t)=>Dx(e.params,t.params)),Dx=Li(Yr([at(),nt()])),Ox=Sx([]),kx=r(2,(e,t)=>{let n=Cx(t).params.slice(),r=new Set;for(let e=0;e<n.length;e++)r.add(n[e][0]);for(let t=0;t<e.params.length;t++)r.has(e.params[t][0])||n.push(e.params[t]);return Sx(n)}),Ax=r(2,(e,t)=>{let n=Array.isArray(t)?t:[t];return e.params.map(([e,t])=>[e,typeof t==`string`&&jx(e,n)?$b(t):t])}),jx=mx,Mx=(e,t=zx())=>{e.includes(`@`)&&(e=Ix(e));let n=e.indexOf(`?`);if(n===-1||t.length===0)return e;let r=e.indexOf(`#`);if(r!==-1&&r<n)return e;let i=r===-1?e.length:r;return e.slice(0,n+1)+Lx(e.slice(n+1,i),t)+e.slice(i)},Nx=/^(?:(https?|ftp|wss?):[/\\]*|[a-z][a-z\d+.-]*:\/\/|[/\\]{2,})/i,Px=/[/\\?#]/,Fx=/[/?#]/,Ix=e=>{let t=``,n=[];for(let r=0;r<e.length;r++){let i=e.charCodeAt(r);i===9||i===10||i===13||t===``&&i<=32||(t+=e[r],n.push(r))}let r=Nx.exec(t);if(r===null)return e;let i=r[0].length,a=r[1]!==void 0||!r[0].includes(`:`),o=t.slice(i),s=o.search(a?Px:Fx),c=(s===-1?o:o.slice(0,s)).lastIndexOf(`@`);return c===-1?e:e.slice(0,n[i])+`REDACTED:REDACTED`+e.slice(n[i+c])},Lx=(e,t)=>e.split(`&`).map(e=>{let n=e.indexOf(`=`);return n!==-1&&jx(Rx(e.slice(0,n)),t)?e.slice(0,n+1)+`REDACTED`:e}).join(`&`),Rx=e=>{if(!e.includes(`%`)&&!e.includes(`+`))return e;try{return decodeURIComponent(e.replace(/\+/g,` `))}catch{return e}},zx=()=>D(globalThis[`~effect/Fiber/currentFiber`]?.context??aa(),Bx),Bx=O(`effect/http/UrlParams/CurrentRedactedNames`,{defaultValue:()=>[`X-Amz-Signature`,`X-Amz-Credential`,`X-Amz-Security-Token`,`AWSAccessKeyId`,`Signature`,`sig`,`X-Goog-Signature`]});function Vx(e){return e.checks?e.checks[e.checks.length-1].annotations:e.annotations}var Hx=`~structural`,Ux=`~sentinels`,Wx=`~constructor`,Gx=f(e=>{let t=Vx(e)?.identifier;return typeof t==`string`?t:e.getExpected(Gx)}),U=Symbol(),Kx=Tf,qx=Kx(U),W=Kx(U),Jx=e=>e===U?T():E(e),Yx=e=>e._tag===`None`?qx:Kx(e.value),Xx=`~effect/SchemaIssue/Issue`;function Zx(e){return v(e,Xx)&&e[Xx]===Xx}function Qx(e){return Object.hasOwn(e,`input`)}var $x=class{[Xx]=Xx;constructor(e,t){t?.reportInput===!0&&e!==U&&(this.input=e)}},eS=class extends $x{_tag=`Filter`;filter;issue;constructor(e,t,n,r){super(n,r),this.filter=e,this.issue=t}},tS=class extends $x{_tag=`Encoding`;ast;issue;constructor(e,t,n,r){super(n,r),this.ast=e,this.issue=t}},nS=class extends $x{_tag=`Pointer`;path;issue;constructor(e,t){super(),this.path=e,this.issue=t}},rS=class extends $x{_tag=`MissingKey`;annotations;constructor(e){super(),this.annotations=e}},iS=class extends $x{_tag=`UnexpectedKey`;ast;constructor(e,t,n){super(t,n),this.ast=e}},aS=class extends $x{_tag=`Composite`;ast;issues;constructor(e,t,n,r){super(n,r),this.ast=e,this.issues=t}},oS=class extends $x{_tag=`InvalidType`;ast;constructor(e,t,n){super(t,n),this.ast=e}},sS=class extends $x{_tag=`InvalidValue`;annotations;constructor(e,t,n){super(t,n),this.annotations=e}};function cS(e,t,n,r,i){return new aS(e,[new nS([t],n)],r,i)}var lS=class extends $x{_tag=`AnyOf`;ast;issues;constructor(e,t,n,r){super(n,r),this.ast=e,this.issues=t}},uS=class extends $x{_tag=`OneOf`;ast;successes;constructor(e,t,n,r){super(n,r),this.ast=e,this.successes=t}};function dS(e,t,n){if(Zx(e))return e;if(typeof e==`string`)return new sS({message:e},t,n);let r=typeof e.issue==`string`?new sS({message:e.issue},t,n):e.issue;return new nS(e.path,r)}function fS(e,t,n){if(e!==void 0)return typeof e==`boolean`?e?void 0:new sS(void 0,t,n):dS(e,t,n)}function pS(e,t,n,r){return Array.isArray(t)?gi(t)?t.length===1?dS(t[0],n,r):new aS(e,ji(t,e=>dS(e,n,r)),n,r):void 0:fS(t,n,r)}var mS=e=>{let t=wS(e);if(t!==void 0)return t;switch(e._tag){case`InvalidType`:return vS(Gx(e.ast),e);case`InvalidValue`:{let t=_S(e);if(t!==void 0)return vS(t,e);let n=gS(e);return n===void 0?`Expected a valid value`:`Invalid data ${n}`}case`MissingKey`:return`Missing key`;case`UnexpectedKey`:{let t=gS(e);return t===void 0?`Expected no excess property`:`Unexpected key with value ${t}`}case`Forbidden`:return`Forbidden operation`;case`OneOf`:{let t=gS(e);return t===void 0?`Expected exactly one member to match`:`Expected exactly one member to match the input ${t}`}}},hS=e=>wS(e)??wS(e.issue);function gS(e){return Qx(e)?x(e.input):void 0}function _S(e){let t=e.annotations?.expected;return typeof t==`string`?t:void 0}function vS(e,t){let n=gS(t);return n===void 0?`Expected ${e}`:`Expected ${e}, got ${n}`}function yS(e,t){let n=t(e);if(n!==void 0||e.issue._tag!==`InvalidValue`)return n;let r=_S(e.issue);return r===void 0?vS(bS(e.filter),e):vS(r,e.issue)}function bS(e){let t=e.annotations?.expected;if(typeof t==`string`)return t;switch(e._tag){case`Filter`:return`<filter>`;case`FilterGroup`:return e.checks.map(e=>bS(e)).join(` & `)}}function xS(){return e=>CS(e,``)}var SS=xS();function CS(e,t,n){let r;switch(e._tag){case`Filter`:return CS(e.issue,t,n??yS(e,hS));case`Encoding`:return CS(e.issue,t,n);case`Pointer`:return CS(e.issue,t+St(e.path),n);case`Composite`:case`AnyOf`:if(e._tag===`Composite`||e.issues.length>0)return e.issues.map(e=>CS(e,t,n)).join(`
|
|
14
14
|
`);r=n??wS(e)??vS(Gx(e.ast),e);break;default:r=n??mS(e)}return t?`${r}\n at ${t}`:r}function wS(e){if(e._tag===`Pointer`||e._tag===`Composite`)return;if(e._tag===`Encoding`)return wS(e.issue);let t=(e._tag===`Filter`?e.filter.annotations:`annotations`in e?e.annotations:e.ast.annotations)?.[e._tag===`MissingKey`?`messageMissingKey`:e._tag===`UnexpectedKey`?`messageUnexpectedKey`:`message`];if(typeof t==`string`)return t}function TS(e){let t;for(let n of e.reasons){if(!$d(n)||!Zx(n.error))return;t??=n.error}return t}function ES(e,t){let n=TS(e);if(n===void 0)throw Error(t,{cause:e});return n}var DS=(e,t,n)=>{switch(e._tag){case`Passthrough`:return I(t);case`Transform`:return I(Pr(t,e.transform));case`TransformOptional`:return I(e.transform(t));case`TransformEffect`:return Cr(t)?gh:Pg(e.transform(t.value,n),E);case`TransformOptionalEffect`:return e.transform(t,n)}},OS=e=>Object.assign(Object.create(t),e),kS=(e,t)=>IS((n,r)=>Lg(DS(e,n,r),e=>DS(t,e,r))),AS=r(2,(e,t)=>{if(e._tag===`Passthrough`)return t;if(t._tag===`Passthrough`)return e;switch(e._tag){case`Transform`:switch(t._tag){case`Transform`:return NS(n=>t.transform(e.transform(n)));case`TransformOptional`:return FS(n=>t.transform(Pr(n,e.transform)));case`TransformEffect`:return PS((n,r)=>t.transform(e.transform(n),r));case`TransformOptionalEffect`:return kS(e,t)}case`TransformOptional`:switch(t._tag){case`Transform`:return FS(n=>Pr(e.transform(n),t.transform));case`TransformOptional`:return FS(n=>t.transform(e.transform(n)));case`TransformEffect`:case`TransformOptionalEffect`:return kS(e,t)}case`TransformEffect`:switch(t._tag){case`Transform`:return PS((n,r)=>Pg(e.transform(n,r),t.transform));case`TransformOptional`:case`TransformOptionalEffect`:return kS(e,t);case`TransformEffect`:return PS((n,r)=>Lg(e.transform(n,r),e=>t.transform(e,r)))}case`TransformOptionalEffect`:return kS(e,t)}}),jS=OS({_tag:`Passthrough`});function MS(){return jS}function NS(e){return OS({_tag:`Transform`,transform:e})}function PS(e){return OS({_tag:`TransformEffect`,transform:e})}function FS(e){return OS({_tag:`TransformOptional`,transform:e})}function IS(e){return OS({_tag:`TransformOptionalEffect`,transform:e})}function LS(){return FS(()=>T())}function RS(e){return IS(t=>{let n=Lr(t,ue);return wr(n)?I(n):Pg(e,E)})}function zS(){return NS(globalThis.String)}function BS(){return NS(globalThis.Number)}function VS(){return PS((e,t)=>{try{return I(globalThis.BigInt(e))}catch{return B(new sS({expected:`a value that can be converted to a bigint`},e,t))}})}function HS(e){return PS((t,n)=>Ch({try:()=>JSON.parse(t,e?.reviver),catch:()=>new sS({expected:`a valid JSON string`},t,n)}))}function US(e){return PS((t,n)=>Ch({try:()=>{let n=JSON.stringify(t,e?.replacer,e?.space);if(n===void 0)throw TypeError(`Value cannot be represented as JSON`);return n},catch:()=>new sS({expected:`a JSON-serializable value`},t,n)}))}function WS(e){let t=e?.separator??`,`;return NS(e=>e===``?[]:e.split(t))}function GS(){return NS(hb)}function KS(){return PS((e,t)=>Fg(Th(gb(e)),()=>new sS({expected:`a valid Base64 string`},e,t)))}var qS=Symbol.for(`~effect/Schema/content`);function JS(e,t){return Object.defineProperty(e,qS,{value:t}),e}var YS=class extends n{_tag=`Middleware`;decode;encode;constructor(e,t){super(),this.decode=e,this.encode=t}flip(){return new YS(this.encode,this.decode)}},XS=`~effect/SchemaTransformation/Transformation`,ZS=class extends n{[XS]=XS;_tag=`Transformation`;decode;encode;constructor(e,t){super(),this.decode=e,this.encode=t}flip(){return new ZS(this.encode,this.decode)}};function QS(e){return v(e,XS)&&e[XS]===XS}var $S=e=>QS(e)?e:new ZS(e.decode,e.encode);function eC(e){return new ZS(PS(e.decode),PS(e.encode))}function tC(e){return new ZS(NS(e.decode),NS(e.encode))}var nC=new ZS(MS(),MS());function rC(){return nC}var iC=new ZS(BS(),zS()),aC=new ZS(VS(),zS()),oC=e=>_e(e)&&typeof e.message==`string`,sC=e=>{let t=Object.hasOwn(e,`cause`)?Error(e.message,{cause:dC(e.cause)}):Error(e.message);return typeof e.name==`string`&&e.name!==`Error`&&(t.name=e.name),typeof e.stack==`string`&&(t.stack=e.stack),t},cC=e=>{try{let t=Et(e);return t===void 0?x(e):JSON.parse(t)}catch{return x(e)}},lC=(e,t,n)=>{let r={name:e.name,message:typeof e.message==`string`?e.message:``};return t?.includeStack&&typeof e.stack==`string`&&(r.stack=e.stack),!t?.excludeCause&&e.cause!==void 0&&(r.cause=n(e.cause)),r},uC=e=>{let t=new WeakSet,n=r=>{if(be(r)){if(t.has(r))return`[Circular]`;t.add(r);let i=lC(r,e,n);return t.delete(r),i}return cC(r)};return n},dC=e=>oC(e)?sC(e):e,fC=e=>tC({decode:dC,encode:uC(e)}),pC=new ZS(KS(),GS());function mC(e){return new ZS(HS(e??{}),JS(US(e),{mediaType:`application/json`,preserveSchema:e?.reviver===void 0&&e?.replacer===void 0}))}function hC(e){return t=>t._tag===e}var gC=hC(`Declaration`),_C=hC(`Never`),vC=hC(`Literal`),yC=hC(`UniqueSymbol`),bC=hC(`Arrays`),xC=hC(`Objects`),SC=hC(`Suspend`),CC=class{to;transformation;constructor(e,t){this.to=e,this.transformation=t}},wC={},TC=class{isOptional;isMutable;constructorDefault;annotations;constructor(e,t,n=void 0,r=void 0){this.isOptional=e,this.isMutable=t,this.constructorDefault=n,this.annotations=r}},EC=`~effect/Schema`,DC=class{[EC]=EC;annotations;checks;encoding;context;constructor(e=void 0,t=void 0,n=void 0,r=void 0){this.annotations=e,this.checks=t,this.encoding=n,this.context=r}toString(){return`<${this._tag}>`}},OC=class extends DC{_tag=`Declaration`;typeParameters;run;encodingChecks;encodingRun;constructor(e,t,n,r,i,a,o,s){super(n,r,i,a),this.typeParameters=e,this.run=t,this.encodingChecks=o,this.encodingRun=s}getParser(){let e;return(t,n)=>{if(t===U)return qx;e??=this.run(this.typeParameters);try{return e(t,this,n)}catch(e){return Sh(e)}}}_rebuild(e,t,n,r,i){let a=$w(this.typeParameters,e);return a===this.typeParameters&&t===this.checks&&n===this.encodingChecks&&r===this.run&&i===this.encodingRun?this:new OC(a,r,this.annotations,t,void 0,this.context,n,i)}recur(e){return this._rebuild(e,this.checks,this.encodingChecks,this.run,this.encodingRun)}flip(e){return this._rebuild(e,this.encodingChecks,this.checks,this.encodingRun??this.run,this.run)}getExpected(){let e=this.annotations?.expected;return typeof e==`string`?e:`<Declaration>`}},kC=new class extends DC{_tag=`Null`;getParser(){return gT(this,null)}getExpected(){return`null`}},AC=class extends DC{_tag=`Undefined`;getParser(){return gT(this,void 0)}toCodecJson(){return G(this,[jC])}getExpected(){return`undefined`}},jC=new CC(kC,new ZS(NS(()=>void 0),NS(()=>null))),MC=new AC,NC=new class extends DC{_tag=`Void`;getParser(){let e=Kx(void 0);return t=>t===U?qx:e}toCodecJson(){return G(this,[jC])}getExpected(){return`void`}},PC=new class extends DC{_tag=`Never`;getParser(){return _T(this,me)}getExpected(){return`never`}},FC=new class extends DC{_tag=`Unknown`;getParser(){return _T(this,he)}getExpected(){return`unknown`}},IC=class extends DC{_tag=`Literal`;literal;constructor(e,t,n,r,i){if(super(t,n,r,i),typeof e==`number`&&!globalThis.Number.isFinite(e))throw Error(`A numeric literal must be finite, got ${x(e)}`);this.literal=e}getParser(){return gT(this,this.literal)}matchPart(e,t){return e===globalThis.String(this.literal)?this.literal:void 0}toCodecJson(){return typeof this.literal==`bigint`?LC(this):this}toCodecStringTree(){return typeof this.literal==`string`?this:LC(this)}getExpected(){return typeof this.literal==`string`?JSON.stringify(this.literal):globalThis.String(this.literal)}};function LC(e){let t=globalThis.String(e.literal);return G(e,[new CC(new IC(t),new ZS(NS(()=>e.literal),NS(()=>t)))])}var RC=new class extends DC{_tag=`String`;getParser(){return _T(this,re)}matchPart(e,t){let n=this.checks;return n&&!t.disableChecks&&kT(n,e,void 0,this,t)?void 0:e}getExpected(){return`string`}},zC=class extends DC{_tag=`Number`;getParser(){return _T(this,ie)}matchKey(e,t){return this._match(xT,e,t)}matchPart(e,t){return this._match(bT,e,t)}_match(e,t,n){if(!e.test(t))return;let r=globalThis.Number(t);return n.disableChecks||!this.checks?r:kT(this.checks,r,void 0,this,n)?void 0:r}toCodecJson(){return this.checks&&(BC(this.checks,`effect/schema/isFinite`)||BC(this.checks,`effect/schema/isInt`))?this:G(this,[Iw])}toCodecStringTree(){return this.toCodecJson()===this?G(this,[wT]):G(this,[TT])}getExpected(){return`number`}};function BC(e,t){return e.some(e=>e.annotations?.representation?.id===t||e._tag===`FilterGroup`&&BC(e.checks,t))}var VC=new zC,HC=new class extends DC{_tag=`Boolean`;getParser(){return _T(this,ae)}getExpected(){return`boolean`}},UC=new class extends DC{_tag=`BigInt`;getParser(){return _T(this,oe)}matchPart(e,t){if(!ET.test(e))return;let n=globalThis.BigInt(e);return t.disableChecks||!this.checks?n:kT(this.checks,n,void 0,this,t)?void 0:n}toCodecStringTree(){return G(this,[OT])}getExpected(){return`bigint`}},WC=class extends DC{_tag=`Arrays`;isMutable;elements;rest;encodingChecks;constructor(e,t,n,r,i,a,o,s){super(r,i,a,o),this.isMutable=e,this.elements=t,this.rest=n,this.encodingChecks=s;let c=!1;for(let e=0;e<t.length;e++)if(cT(t[e]))c=!0;else if(c)throw Error(`A required element cannot follow an optional element. ts(1257)`);if(c&&n.length>1)throw Error(`A required element cannot follow an optional element. ts(1257)`);for(let e=1;e<n.length;e++)if(cT(n[e]))throw Error(`An optional element cannot follow a rest element. ts(1266)`)}getParser(e,t=e){let n=this,r,i,a=n.elements.length,o=Math.max(0,n.rest.length-1);function s(e,t){return t<a?r[t]:t>=e?i[t-e+1]:i[0]}let c=e=>{let{input:t,len:r,options:i}=e;if(n.rest.length===0&&r>a)for(let o=a;o<r;o++){let r=new iS(n,t[o],i),a=new nS([o],r);if(i.errors===`all`)e.issues?e.issues.push(a):e.issues=[a];else return B(new aS(n,[a],t,i))}return e.issues?B(new aS(n,e.issues,t,i)):Kx(e.output)},l=(e,t)=>{let r=e.length,i={ast:n,getParser:s,input:e,len:r,tailThreshold:Math.max(a,r-o),output:[],issues:void 0,options:t},u=n.rest.length===0?a:Math.max(r,a+o),d=t.concurrency===void 0?1:Ru(t.concurrency),f=d===1?qC(i,e,0,u):JC(i,e,{concurrency:d,end:u});if(!f)return c(i);if(F(f))return Lg(f,()=>c(i));let p=!0;return L(()=>p?(p=!1,V(f,()=>c(i))):l(e,t))};return(e,a)=>{if(e===U)return qx;try{return Array.isArray(e)?(r||(r=n.elements.map(e=>({ast:e,parser:t(e)})),i=n.rest.map(e=>({ast:e,parser:t(e)}))),l(e,a)):B(new oS(n,e,a))}catch(e){return Sh(e)}}}_rebuild(e,t,n){let r=$w(this.elements,e),i=$w(this.rest,e);return r===this.elements&&i===this.rest&&t===this.checks&&n===this.encodingChecks?this:new WC(this.isMutable,r,i,this.annotations,t,void 0,this.context,n)}recur(e){return this._rebuild(e,this.checks,this.encodingChecks)}flip(e){return this._rebuild(e,this.encodingChecks,this.checks)}getExpected(){return`array`}};function GC(e,t,n,r){if(n._tag===`Failure`)return YC(e,e.ast,r,n);let i=n===W?t:n[S];if(i!==U)e.output[r]=i;else{let t=e.getParser(e.tailThreshold,r);if(cT(t.ast))return;let n=new nS([r],new rS(t.ast.context?.annotations));if(e.options.errors===`all`)e.issues?e.issues.push(n):e.issues=[n];else return Df(new aS(e.ast,[n],e.input,e.options))}}var KC={onItem(e,t,n){let r=n<e.len?t:U;return e.getParser(e.tailThreshold,n).parser(r,e.options)},step:GC},qC=zu()(KC),JC=Vu()(KC),YC=(e,t,n,r)=>{if(r.cause.reasons.length===0)return r;let i=TS(r.cause);if(i===void 0)return Ef(uf(r.cause,r=>new aS(t,[new nS([n],r)],e.input,e.options)));let a=new nS([n],i);if(e.options.errors===`all`)e.issues?e.issues.push(a):e.issues=[a];else return Df(new aS(t,[a],e.input,e.options))},XC=`[+-]?(?:\\d+(?:\\.\\d+)?|\\.\\d+)(?:[Ee][+-]?\\d+)?`;function ZC(e,t,n=wC){let r,i;function a(t){switch(t._tag){case`String`:case`TemplateLiteral`:return(r??=Object.keys(e)).filter(e=>t.matchPart(e,n)!==void 0);case`Number`:return(r??=Object.keys(e)).filter(e=>t.matchKey(e,n)!==void 0);case`Symbol`:return(i??=Object.getOwnPropertySymbols(e)).filter(r=>Object.prototype.propertyIsEnumerable.call(e,r)&&t.matchKey(r,n)!==void 0);case`Union`:return[...new Set(t.types.flatMap(a))];default:return[]}}return a(vT(pT(t)))}var QC=class{name;type;constructor(e,t){this.name=e,this.type=t}};function $C(e){switch(e._tag){case`String`:case`Number`:case`Symbol`:case`TemplateLiteral`:return!0;case`Union`:return e.types.every($C);default:return!1}}function ew(e){let t=Hw(e);switch(t._tag){case`String`:case`Number`:case`Symbol`:case`TemplateLiteral`:return!0;case`Union`:return t.types.every(ew);default:return!1}}function tw(e){return $C(e)&&ew(e)}var nw=class{parameter;type;constructor(e,t){if(!tw(e))throw Error(`Invalid index signature parameter ${e._tag}`);if(this.parameter=e,this.type=t,cT(t)||t.encoding!==void 0&&cT(pT(t)))throw Error("Cannot use `Schema.optionalKey` or `Schema.optional` with index signatures. Index signatures already allow keys to be absent; use `Schema.UndefinedOr` to allow `undefined` values.")}},rw=class extends DC{_tag=`Objects`;propertySignatures;indexSignatures;encodingChecks;constructor(e,t,n,r,i,a,o){super(n,r,i,a),this.propertySignatures=e,this.indexSignatures=t,this.encodingChecks=o}getParser(e,t=e){let n=this,r=n.propertySignatures.length,i=n.indexSignatures.length;if(!r&&!i)return _T(n,pe);let a,o,s=()=>(a||(a=n.propertySignatures.map(e=>({parser:t(e.type),name:e.name,type:e.type})),o=i?n.indexSignatures.map(n=>({is:n,parserKey:e(vT(n.parameter)),parserValue:t(n.type)})):void 0),a),c=()=>{let e=new Set(n.propertySignatures.map(e=>typeof e.name==`number`?globalThis.String(e.name):e.name)),t=(t,i,a,o,s)=>{if(s._tag===`Failure`)return YC(t,n,i,s)??Af;let c=s===W?o:s[S];if(a!==U&&c!==U){if(r&&(e.has(i)||e.has(typeof a==`number`?globalThis.String(a):a)))return Af;dt(t.out,a,c)}return Af},c=(e,r,i,a)=>{if(!a){let t=i.parserKey(r,e.options);if(!F(t))return V(kh(t),t=>c(e,r,i,t));a=t}if(a._tag===`Failure`)return YC(e,n,r,a)??Af;let o=a===W?r:a[S],s=e.input[r],l=i.parserValue(s,e.options);return F(l)?t(e,r,o,s,l):V(kh(l),n=>t(e,r,o,s,n))},l=(e,n,r)=>{let i=e.input[n],a=r.parserValue(i,e.options);return F(a)?t(e,n,n,i,a):V(kh(a),r=>t(e,n,n,i,r))},u=i?Vu()({onItem:(e,[t,n])=>n.is.parameter===RC?l(e,t,n):c(e,t,n),step:(e,t,n)=>n._tag===`Failure`?n:void 0}):void 0;return zg(function*(t,d){if(t===U)return U;if(typeof t!=`object`||!t||Array.isArray(t))return yield*B(new oS(n,t,d));s();let f=t,p={},m={ast:n,input:f,out:p,issues:void 0,options:d},h=d.errors===`all`,g=d.onExcessProperty===`error`,ee=d.concurrency===void 0?1:Ru(d.concurrency),_=i&&g?n.indexSignatures.map(e=>ZC(f,e.parameter,d)):void 0;if(g){let r=_?new Set(e):e;if(_)for(let e of _)for(let t of e)r.add(t);let i=Reflect.ownKeys(f);for(let e=0;e<i.length;e++){let a=i[e];if(!r.has(a)&&Object.prototype.propertyIsEnumerable.call(f,a)){let e=new iS(n,f[a],d),r=new nS([a],e);if(h){m.issues?m.issues.push(r):m.issues=[r];continue}return yield*B(new aS(n,[r],t,d))}}}if(r){let e=ee===1?ow(m,a):sw(m,a,{concurrency:ee});e&&(yield*e)}if(i&&ee===1)for(let e=0;e<i;e++){let t=o[e],n=t.is.parameter===RC?l:c,r=_?.[e]??(t.is.parameter===RC?Object.keys(f):ZC(f,t.is.parameter,d));for(let e=0;e<r.length;e++){let i=n(m,r[e],t);if(!F(i))yield*i;else if(i._tag===`Failure`)return yield*i}}else if(u){let e=ki();for(let t=0;t<i;t++){let n=o[t],r=_?.[t]??(n.is.parameter===RC?Object.keys(f):ZC(f,n.is.parameter,d));for(let t=0;t<r.length;t++)e.push([r[t],n])}let t=u(m,e,{concurrency:ee});t&&(yield*t)}return m.issues?yield*B(new aS(n,m.issues,t,d)):p})};if(i)return c();let l,u=(e,t,n)=>{let r=a[t];return V(kh(n),n=>{let i={...e,out:{...e.out}},o=iw(i,r,n);if(o)return o;let s=()=>Kx(i.out),c=ow(i,a.slice(t+1));return c?Lg(c,s):s()})};return(e,t)=>{if(e===U)return qx;if(t.errors===`all`||t.onExcessProperty!==void 0||t.concurrency!==void 0&&Ru(t.concurrency)!==1)return(l??=c())(e,t);if(typeof e!=`object`||!e||Array.isArray(e))return B(new oS(n,e,t));let r=s(),i=e,a={},o={ast:n,input:i,out:a,issues:void 0,options:t};try{for(let e=0;e<r.length;e++){let n=r[e],s=n.name,c=bw(i,s),l=c?i[s]:U,d=n.parser(l,t);if(!F(d))return u(o,e,d);if(d===W){c&&dt(a,s,l);continue}let f=iw(o,n,d);if(f)return f}}catch(e){return Sh(e)}return Kx(a)}}_rebuild(e,t,n,r){let i=$w(this.propertySignatures,t=>{let n=e(t.type);return n===t.type?t:new QC(t.name,n)}),a=$w(this.indexSignatures,n=>{let r=t(n.parameter),i=e(n.type);return r===n.parameter&&i===n.type?n:new nw(r,i)});return i===this.propertySignatures&&a===this.indexSignatures&&n===this.checks&&r===this.encodingChecks?this:new rw(i,a,this.annotations,n,void 0,this.context,r)}flip(e){return this._rebuild(e,e,this.encodingChecks,this.checks)}recur(e,t=e){return this._rebuild(e,t,this.checks,this.encodingChecks)}getExpected(){return this.propertySignatures.length===0&&this.indexSignatures.length===0?`object | array`:`object`}};function iw(e,t,n){if(n._tag===`Failure`)return YC(e,e.ast,t.name,n);if(n===W)return;let r=n[S];if(r!==U)dt(e.out,t.name,r);else if(delete e.out[t.name],!cT(t.type)){let n=new nS([t.name],new rS(t.type.context?.annotations));if(e.options.errors===`all`){e.issues?e.issues.push(n):e.issues=[n];return}return Df(new aS(e.ast,[n],e.input,e.options))}}var aw={onItem(e,t){if(!bw(e.input,t.name))return t.parser(U,e.options);let n=e.input[t.name];return dt(e.out,t.name,n),t.parser(n,e.options)},step:iw},ow=zu()(aw),sw=Vu()(aw);function cw(e,t){return e?t?[...e,...t]:e:t}function lw(e,t,n){return new rw(Reflect.ownKeys(e).map(t=>new QC(t,e[t].ast)),[],n,t)}function uw(e){return e.ast}function dw(e,t=void 0){return new WC(!1,e.map(e=>e.ast),[],void 0,t)}function fw(e,t,n){return new Sw(e.map(uw),t,void 0,n)}function pw(e,t){if(e.encoding||t.some(e=>e.encoding))throw Error(`StructWithRest does not support encodings`);let n=e.propertySignatures,r=e.indexSignatures,i=e.checks;for(let e of t){for(let t of e.propertySignatures)if(n.some(e=>e.name===t.name))throw Error(`Duplicate identifier: ${JSON.stringify(t.name)}. ts(2300)`);n=n.concat(e.propertySignatures),r=r.concat(e.indexSignatures),i=cw(i,e.checks)}return new rw(n,r,void 0,i)}var mw=p(e=>{for(;;){if(SC(e))return FC;let t=e.encoding;if(!t)return e.recur?.(mw,i)??e;if(t.some(e=>e.transformation._tag===`Middleware`&&e.transformation.decode!==i))return FC;e=t[t.length-1].to}});function hw(e){switch(e._tag){case`Null`:return[`null`];case`Undefined`:return[`undefined`];case`String`:case`TemplateLiteral`:return[`string`];case`Number`:return[`number`];case`Boolean`:return[`boolean`];case`Symbol`:case`UniqueSymbol`:return[`symbol`];case`BigInt`:return[`bigint`];case`Arrays`:return[`array`];case`ObjectKeyword`:return[`object`,`array`,`function`];case`Objects`:return e.propertySignatures.length||e.indexSignatures.length?[`object`]:[`string`,`number`,`boolean`,`symbol`,`bigint`,`object`,`array`,`function`];case`Enum`:return Array.from(new Set(e.enums.map(([,e])=>typeof e)));case`Literal`:return[typeof e.literal];case`Union`:return Array.from(new Set(e.types.flatMap(hw)));default:return[`null`,`undefined`,`string`,`number`,`boolean`,`symbol`,`bigint`,`object`,`array`,`function`]}}function gw(e){switch(e._tag){default:return[];case`Declaration`:{let t=e.annotations?.[Ux];return Array.isArray(t)?t:[]}case`Objects`:return e.propertySignatures.flatMap(e=>{let t=e.type;if(!cT(t)){if(vC(t))return[{key:e.name,literal:t.literal}];if(yC(t))return[{key:e.name,literal:t.symbol}]}return[]});case`Arrays`:return e.elements.flatMap((e,t)=>{if(!cT(e)){if(vC(e))return[{key:t,literal:e.literal}];if(yC(e))return[{key:t,literal:e.symbol}]}return[]});case`Union`:{if(e.types.length===0)return[];let t=e.types.map(e=>gw(mw(e)));return t[0].filter(e=>t.every(t=>t.some(t=>t.key===e.key&&t.literal===e.literal)))}case`Suspend`:return gw(e.thunk())}}var _w=new WeakMap,vw=Object.freeze([]),yw=e=>e===null?`null`:Array.isArray(e)?`array`:typeof e,bw=(e,t)=>t===`__proto__`?Object.hasOwn(e,t):t in e;function xw(e){let t=_w.get(e);if(t)return t;let n,r=0,i,a,o=!0,s=[];for(let t=0;t<e.length;t++){let c=e[t],l=mw(c);if(_C(l))continue;if(vC(l)||yC(l)){a??=new Map;let e=vC(l)?l.literal:l.symbol;s[t]=e;let n=a.get(e);n||a.set(e,n=[]),n.push(t)}else o=!1;let u=gw(l);if(u.length){n??=new Map,r++;for(let{key:e,literal:r}of u){let i=n.get(e);i||n.set(e,i=[new Map,new Set]),i[1].add(t);let a=i[0].get(r);a||i[0].set(r,a=new Set),a.add(t)}}else{i??={};let e=hw(l);for(let n of e)(i[n]??=[]).push(t)}}let c={},l=e=>c[e]??=Object.freeze(i?.[e]??vw);if(o&&a)a.forEach(Object.freeze),t=e=>a.get(e)??vw;else if(n?.size===1&&!i){let[r,[i]]=n.entries().next().value,a=new Map;for(let[e,t]of i)a.set(e,Object.freeze(Array.from(t)));let o=Object.freeze(e.map((e,t)=>t));t=(e,t)=>{if(ve(e)){let n=bw(e,r)?e[r]:void 0;if(n!==void 0)return a.get(n)??vw;if(t)return o}return vw}}else if(n){let e;for(let t of n)(!e||t[1][0].size>e[1][0].size)&&t[1][1].size===r&&(e=t);t=(t,r)=>{let a=yw(t);if(!ve(t))return l(a);let o=new Set(i?.[a]),s;if(e){let[n,[i]]=e,c=bw(t,n),u=c?t[n]:void 0;if(c&&(!r||u!==void 0)){let e=i.get(u);if(!e)return l(a);for(let t of e)o.add(t);s=n}}if(s===void 0)for(let[e,[i,a]]of n){let n=bw(t,e),s=n?t[e]:void 0;if(n&&(!r||s!==void 0)){let e=i.get(s);if(e)for(let t of e)o.add(t)}else if(r)for(let e of a)o.add(e)}for(let[e,[i,a]]of n){if(e===s)continue;let n=bw(t,e),c=n?t[e]:void 0;if(n&&(!r||c!==void 0)){let e=i.get(c);for(let t of o)a.has(t)&&!e?.has(t)&&o.delete(t)}}return Array.from(o).sort((e,t)=>e-t)}}else t=e=>{let t=l(yw(e));return a?t.filter(t=>s[t]===void 0||s[t]===e):t};return _w.set(e,t),t}var Sw=class extends DC{_tag=`Union`;types;options;encodingChecks;constructor(e,t,n,r,i,a,o){super(n,r,i,a),this.types=e,this.options=t,this.encodingChecks=o}getParser(e,t){let n=this,r=t!==void 0,i=[],a=t=>i[t]??=e(n.types[t]),o;return(e,t)=>{if(e===U)return qx;let i=(o??=xw(n.types))(e,r);if(i.length===0)return B(new lS(n,[],e,t));if(i.length===1){let r=a(i[0])(e,t);return r._tag===`Success`?r:F(r)?Cw(n,r.cause,e,t):ww(n,r,e,t)}return Tw(n,a,i,e,t)}}_rebuild(e,t,n){let r=$w(this.types,e);return r===this.types&&t===this.checks&&n===this.encodingChecks?this:new Sw(r,this.options,this.annotations,t,void 0,this.context,n)}recur(e){return this._rebuild(e,this.checks,this.encodingChecks)}flip(e){return this._rebuild(e,this.encodingChecks,this.checks)}matchPart(e,t){for(let n of this.types){let r=n.matchPart(e,t);if(r!==void 0)return r}}getExpected(e){let t=this.annotations?.expected;if(typeof t==`string`)return t;if(this.types.length===0)return`never`;let n=this.types.map(t=>{let n=pT(t);switch(n._tag){case`Arrays`:{let t=n.elements.filter(vC);if(t.length>0)return`${kw(n.isMutable)}[ ${t.map(t=>e(t)+Aw(t.context?.isOptional)).join(`, `)}, ... ]`;break}case`Objects`:{let t=n.propertySignatures.filter(e=>vC(e.type));if(t.length>0)return`{ ${t.map(t=>`${kw(t.type.context?.isMutable)}${xt(t.name)}${Aw(t.type.context?.isOptional)}: ${e(t.type)}`).join(`, `)}, ... }`;break}}return e(n)});return Array.from(new Set(n)).join(` | `)}};function Cw(e,t,n,r){let i=TS(t);return i?Df(new lS(e,[i],n,r)):Ef(t)}function ww(e,t,n,r){return Mh(t,t=>Cw(e,t,n,r))}function Tw(e,t,n,r,i){let a={ast:e,parser:t,input:r,out:void 0,successes:e.options?.mode===`oneOf`?[]:void 0,issues:void 0,options:i},o=Dw(a,n);if(!o)return a.out?a.out:B(new lS(e,a.issues??[],r,i));if(F(o))return Ew(o,a);let s=!0;return L(()=>s?(s=!1,Ew(o,a)):Tw(e,t,n,r,i))}function Ew(e,t){return Lg(e,e=>t.out===W?I(t.input):t.out?t.out:B(new lS(t.ast,t.issues??[],t.input,t.options)))}var Dw=zu()({onItem(e,t){return e.parser(t)(e.input,e.options)},step(e,t,n){if(n._tag===`Failure`){let t=TS(n.cause);if(t===void 0)return n;e.issues?e.issues.push(t):e.issues=[t]}else{if(e.out&&e.successes)return e.successes.push(e.ast.types[t]),Df(new uS(e.ast,e.successes,e.input,e.options));if(e.out=n,e.successes)e.successes.push(e.ast.types[t]);else return Af}}}),Ow=new Sw([new IC(`Infinity`),new IC(`-Infinity`),new IC(`NaN`)]);function kw(e){return e?``:`readonly `}function Aw(e){return e?`?`:``}var jw=class extends n{_tag=`Filter`;run;annotations;aborted;constructor(e,t=void 0,n=!1){super(),this.run=e,this.annotations=t,this.aborted=n}annotate(e){return new jw(this.run,{...this.annotations,...e},this.aborted)}abort(){return new jw(this.run,this.annotations,!0)}and(e,t){return new Mw([this,e],t)}},Mw=class extends n{_tag=`FilterGroup`;checks;annotations;constructor(e,t=void 0){super(),this.checks=e,this.annotations=t}annotate(e){return new Mw(this.checks,{...this.annotations,...e})}and(e,t){return new Mw([this,e],t)}};function Nw(e,t,n=!1){return new jw((t,n,r)=>pS(n,e(t,n,r),t,r),t,n)}function Pw(e){return Nw(e=>globalThis.Number.isFinite(e),{expected:`a finite number`,representation:{id:`effect/schema/isFinite`,payload:null},toJsonSchema:()=>({type:`number`}),toCode:()=>({runtime:`Schema.isFinite()`}),arbitraryConstraint:{number:`finite`},...e})}var Fw=Gw(VC,[Pw()]),Iw=new CC(new Sw([Fw,Ow]),new ZS(BS(),NS(e=>globalThis.Number.isFinite(e)?e:globalThis.String(e))));function Lw(e,t){let n=new globalThis.RegExp(e),r={source:n.source,flags:n.flags};return Nw(e=>(n.lastIndex=0,n.test(e)),{expected:`a string matching the RegExp ${r.source}`,representation:{id:`effect/schema/isPattern`,payload:r},toJsonSchema:()=>[{},!0],arbitraryConstraint:{patterns:[r]},...t})}var Rw=new WeakMap;function zw(e,t){let n=Object.assign(Object.create(Object.getPrototypeOf(e)),e,t);return Reflect.ownKeys(t).every(e=>e===`context`||e===`encoding`)&&Rw.set(n,Bw(e)),n}function Bw(e){let t=Rw.get(e);if(t!==void 0)return t;if(e.encoding===void 0)return e;let n=Object.assign(Object.create(Object.getPrototypeOf(e)),e,{encoding:void 0});return Rw.set(e,n),n}function G(e,t){return e.encoding===t?e:zw(e,{encoding:t})}function Vw(e,t){if(e.context===t)return e;let n=Bw(e);return n.context===t&&n.encoding===e.encoding?n:zw(e,{context:t})}function Hw(e){return e.encoding?Hw(e.encoding[e.encoding.length-1].to):e}function Uw(e,t){if(e.checks){let n=e.checks[e.checks.length-1];return Ww(e,fi(e.checks.slice(0,-1),n.annotate(t)))}return zw(e,{annotations:{...e.annotations,...t}})}function Ww(e,t){if(e._tag===`Suspend`&&t)throw Error(`Cannot add checks to Suspend`);return e.checks===t?e:zw(e,{checks:t})}function Gw(e,t){return Ww(e,cw(e.checks,t))}function Kw(e,t){let n=t(e.to);return n===e.to?e:new CC(n,e.transformation)}function qw(e,t){let n=e,r=n[n.length-1],i=Kw(r,t);return i===r?e:fi(e.slice(0,e.length-1),i)}function Jw(e){return t=>t.encoding?G(t,qw(t.encoding,e)):t}function Yw(e,t){return Jw(e=>Vw(e,t))(e)}function Xw(e){function t(n){return n.encoding?G(n,qw(n.encoding,t)):e(n)}return f(t)}function Zw(e,t){function n(r){if(r.encoding){let e=r.encoding[r.encoding.length-1];return t?.stopAt?.(e)?r:G(r,qw(r.encoding,n))}return e(r)}return p(n)}function Qw(e,t,n){let r=new CC(e,t);return G(n,n.encoding?[...n.encoding,r]:[r])}function $w(e,t){let n;for(let r=0;r<e.length;r++){let i=e[r],a=t(i);if(n)n[r]=a;else if(a!==i){n=Array(e.length);for(let t=0;t<r;t++)n[t]=e[t];n[r]=a}}return n??e}function eT(e,t){return Vw(e,e.context?new TC(e.context.isOptional,e.context.isMutable,e.context.constructorDefault,{...e.context.annotations,...t}):new TC(!1,!1,void 0,t))}var tT=p(e=>nT(Vw(e,e.context?e.context.isOptional===!1?new TC(!0,e.context.isMutable,e.context.constructorDefault,e.context.annotations):e.context:new TC(!0,!1)))),nT=Jw(tT),rT=f(e=>tT(new Sw([e,MC])));function iT(e,t){return Vw(e,e.context?new TC(e.context.isOptional,e.context.isMutable,t,e.context.annotations):new TC(!1,!1,t))}function aT(e,t,n){return Qw(e,n,t)}function oT(e){let t=[],n=[];function r(e){t.includes(e)||t.push(e)}function i(e){switch(e._tag){case`Literal`:ce(e.literal)&&r(e.literal);return;case`UniqueSymbol`:r(e.symbol);return;case`Enum`:for(let[,t]of e.enums)r(t);return;case`Never`:return;case`Union`:for(let t=0;t<e.types.length;t++)i(e.types[t]);return;default:n.push(e)}}return i(e),{literals:t,parameters:n}}function sT(e,t){let{literals:n,parameters:r}=oT(e);return new rw(n.map(e=>new QC(e,t)),r.map(e=>new nw(e,t)))}function cT(e){return e.context?.isOptional??!1}function lT(e){return e.annotations?.[`~structural`]===!0||e._tag===`FilterGroup`&&e.checks.every(lT)}function uT(e){function t(e){return lT(e)?[e]:e._tag===`FilterGroup`?e.checks.flatMap(t):[]}let n=e.flatMap(t);return hi(n)?n:void 0}function dT(e){let t=!0;function n(e){return t=t&&!e.encoding&&!SC(e),t&&`recur`in e&&e.recur(n),e}return`recur`in e&&e.recur(n),t}var fT=p(e=>{let t=Bw(e);if(t!==e){let n=fT(t);return n===t&&e.encoding===void 0?e:Vw(n,e.context)}let n=`recur`in e?e.recur(fT):e;if(`encodingChecks`in n&&n.encodingChecks){let t=dT(e)?n.encodingChecks:bC(n)||xC(n)||gC(n)&&n.typeParameters.length>0?uT(n.encodingChecks):void 0;return zw(n,{encodingChecks:void 0,checks:cw(n.checks,t)})}return n}),pT=p(e=>fT(hT(e)));function mT(e,t){let n=t,r=n.length,i=n[r-1],a=[new CC(hT(G(e,void 0)),n[0].transformation.flip())];for(let e=1;e<r;e++)a.unshift(new CC(hT(n[e-1].to),n[e].transformation.flip()));let o=hT(i.to);return o.encoding?G(o,[...o.encoding,...a]):G(o,a)}var hT=f(e=>{if(e.encoding)return mT(e,e.encoding);let t=Bw(e);if(t!==e){let n=hT(t);return n===t?e:Vw(n,e.context)}return`flip`in e?e.flip(hT):`recur`in e?e.recur(hT):e});function gT(e,t){let n=t===0?W:Kx(t);return(r,i)=>r===U?qx:r===t?n:B(new oS(e,r,i))}function _T(e,t){return(n,r)=>n===U?qx:t(n)?W:B(new oS(e,n,r))}var vT=Zw(e=>{switch(e._tag){default:return e;case`Number`:return e.toCodecStringTree();case`Union`:return e.recur(vT)}}),yT=Zw(e=>{switch(e._tag){default:return e;case`Symbol`:case`UniqueSymbol`:return e.toCodecStringTree();case`Union`:return e.recur(yT)}}),bT=new globalThis.RegExp(`^${XC}$`),xT=new globalThis.RegExp(`^(?:${XC}|Infinity|-Infinity|NaN)$`);function ST(e){return Lw(bT,{expected:`a string representing a finite number`,representation:{id:`effect/schema/isStringFinite`,payload:null},toJsonSchema:()=>({pattern:bT.source}),...e})}var CT=Gw(RC,[ST()]),wT=new CC(CT,iC),TT=new CC(new Sw([CT,Ow]),iC),ET=new globalThis.RegExp(`^-?\\d+$`);function DT(e){return Lw(ET,{expected:`a string representing a bigint`,representation:{id:`effect/schema/isStringBigInt`,payload:null},toJsonSchema:()=>({pattern:ET.source}),...e})}var OT=new CC(Gw(RC,[DT({expected:`a string representing a bigint`})]),aC);function kT(e,t,n,r,i){for(let a=0;a<e.length;a++){let o=e[a];if(o._tag===`FilterGroup`){if(n=kT(o.checks,t,n,r,i),n&&(i.errors!==`all`||n[n.length-1].filter.aborted))return n}else{let e=o.run(t,r,i);if(e){let r=new eS(o,e,t,i);if(n?n.push(r):n=[r],i.errors!==`all`||o.aborted)return n}}}return n}function AT(e){if(!gC(e))return;let t=e.annotations?.[Wx];return le(t)?t(e.typeParameters):void 0}function jT(e){return e===null||typeof e==`string`||typeof e==`boolean`||typeof e==`number`&&globalThis.Number.isFinite(e)}function MT(e){return e===void 0||typeof e==`string`}function NT(e,t){let n=new WeakMap,r=[];outer:for(;;){if(typeof e!=`object`||!e){if(!t(e))return!1}else{let t=e,i=n.get(t);if(i===!1)return!1;if(i===void 0){let e=Array.isArray(t);if(!e){let e=Object.getPrototypeOf(t);if(e!==null&&e!==Object.prototype&&Object.getPrototypeOf(e)!==null)return!1}n.set(t,!1),r.push({value:t,keys:e?t.length:Object.keys(t),index:0})}}for(;r.length>0;){let t=r[r.length-1],i=t.keys;if(typeof i==`number`){if(t.index<i){e=t.value[t.index++];continue outer}}else if(t.index<i.length){e=t.value[i[t.index++]];continue outer}n.set(t.value,!0),r.pop()}return!0}}function PT(e){return NT(e,jT)}var FT=new OC([],()=>(e,t,n)=>PT(e)?W:B(new oS(t,e,n)),{representation:{id:`effect/schema/Json`,payload:null},expected:`JSON value`,toCodecJson:()=>void 0,toCodecStringTree:()=>zT}),IT=new CC(FT,rC()),LT=new CC(new Sw([new WC(!1,[],[FT]),new rw([],[new nw(RC,FT)])]),rC());function RT(e){return NT(e,MT)}var zT=new CC(new OC([],()=>(e,t,n)=>RT(e)?W:B(new oS(t,e,n)),{expected:`StringTree`,toCodecStringTree:()=>void 0}),rC()),BT=(e,t,n)=>e===W?n(t):Lg(e,n);function VT(e){let t=HT(e);return(e,n,r)=>{try{return t(e,n,r)}catch(e){return Sh(e)}}}function HT(e){if(e._tag===`Middleware`)return(t,n,r)=>UT(t===W?e.decode(Kx(Jx(n)),r):e.decode(Pg(t,Jx),r));let t=e.decode;switch(t._tag){case`Passthrough`:return(e,t)=>e===W?Kx(t):e;case`Transform`:{let e=e=>e===U?qx:Kx(t.transform(e));return(t,n)=>BT(t,n,e)}case`TransformOptional`:{let e=e=>Yx(t.transform(Jx(e)));return(t,n)=>BT(t,n,e)}case`TransformEffect`:return(e,n,r)=>BT(e,n,e=>e===U?qx:t.transform(e,r));case`TransformOptionalEffect`:return(e,n,r)=>BT(e,n,e=>UT(t.transform(Jx(e),r)))}}var UT=e=>Lg(e,Yx),WT=(e,t,n,r)=>Mh(r,r=>xh(()=>uf(r,r=>new tS(e,r,t,n))));function GT(e,t){let n=VT(e.link.transformation),r;return(i,a)=>{if(i===U)return qx;if(e.isConstructed(i))return W;let o=(r??=t(e.link.to))(i,a);return n(o,i,a)}}function KT(e,t){let n=e.context.constructorDefault;return(r,i)=>{if(r!==U&&r!==void 0)return t(r,i);let a=n;if(F(a)&&a._tag===`Success`){let e=t(a[S],i);return e===W?a:e}return Lg(WT(e,r,i,a),e=>{let n=t(e,i);return n===W?Kx(e):n})}}function qT(e,t){let n=t(e);return e.context?.constructorDefault===void 0?n:KT(e,n)}function JT(e,t,n,r,i){if(e._tag===`Declaration`)for(let n of e.typeParameters)t(n);let a=n?AT(e):void 0,o=a?GT(a,t):r??e.getParser(t,n),s=e.checks,c=e.encoding,l=c?.map(e=>VT(e.transformation)),u=e.encodingChecks;if(!c&&!s&&!u)return o;let d,f=(t,n)=>{let r=o(t,n);try{if(u&&!n.disableChecks){if(F(r)){if(r._tag===`Success`){let i=r===W?t:r[S];if(t!==U&&i!==U){let i=kT(u,t,void 0,e,n);i&&(r=B(new aS(e,i,t,n)))}}}else r=V(r,r=>{if(t!==U&&r!==U){let r=kT(u,t,void 0,e,n);if(r)return B(new aS(e,r,t,n))}return I(r)})}if(s&&!n.disableChecks){if(F(r)){if(r._tag===`Success`){let i=r===W?t:r[S];if(i===U)return r;let a=kT(s,i,void 0,e,n);a&&(r=B(new aS(e,a,i,n)))}}else r=V(r,t=>{if(t!==U){let r=kT(s,t,void 0,e,n);if(r)return B(new aS(e,r,t,n))}return I(t)})}return r}catch(e){return Sh(e)}},p=i===void 0?f:i(f);return c?(n,r)=>{let i=d??=c.map(e=>t(e.to)),a=n,o=i[i.length-1](n,r);for(let e=c.length-1;e>=0;e--)if(o=l[e](o,a,r),e!==0){let t=i[e-1];o._tag===`Success`?(a=o[S],o=t(a,r)):o=Lg(o,e=>{let n=t(e,r);return n===W?Kx(e):n})}if(o._tag===`Success`){let e=o[S],t=p(e,r);return t===W?o:t}return o=WT(e,n,r,o),Lg(o,e=>{let t=p(e,r);return t===W?Kx(e):t})}:p}var YT=Symbol(),XT=new WeakMap,ZT=e=>tE(e).parser,QT=e=>tE(e).makeEffect,$T=e=>qT(e,QT),eE=class{ast;constructor(e){this.ast=e}get decodeEffect(){return this.cachedDecodeEffect??=JT(this.ast,ZT)}get parser(){return this.decodeEffect}get makeEffect(){return this.cachedMakeEffect??=JT(this.ast,QT,$T)}};function tE(e){let t=XT.get(e);if(t!==void 0)return t;let n=new eE(e);return XT.set(e,n),n}function nE(e){let t=e.ast,n;return(e,r)=>(n??=hE(TE,fT(t)))(e,r?.disableChecks?r?.parseOptions?{...r.parseOptions,disableChecks:!0}:{disableChecks:!0}:r?.parseOptions)}function rE(e){let t=nE(e);return(e,n)=>{let r=Ag(t(e,n));return jf(r)?E(r.value):(ES(r.cause,`Option adapter can only return none for schema issues`),T())}}function iE(e){return xE(fT(e.ast))}function aE(e){return sE(e.ast)}function oE(e){{let t=gE(pE(e));return e=>{let n=t(e,wC);return jf(n)?!0:(ES(n.cause,`Type guard adapter can only return false for schema issues`),!1)}}}function sE(e){let t=fT(e),n=e=>(n=oE(t),n(e));return e=>n(e)}function cE(e,t){let n=pE(e.ast);return t===void 0?n:(e,r)=>n(e,dE(t,r))}function lE(e,t){return _E(cE(e,t))}function uE(e,t){let n=pE(hT(e.ast));return t===void 0?n:(e,r)=>n(e,dE(t,r))}var dE=(e,t)=>t?{...e,...t}:e,fE=e=>e===U?B(new sS):I(e);function pE(e){return hE(wE,e)}function mE(e,t){return e===W?I(t):F(e)?e[`~effect/Effect/args`]===U?fE(U):e:Lg(e,fE)}function hE(e,t){let n;return(r,i)=>{let a=(n??=e(t))(r,i??wC);return a===W?I(r):F(a)?a[`~effect/Effect/args`]===U?fE(U):a:Lg(a,fE)}}function gE(e){return(t,n)=>Ag(e(t,n))}function _E(e){let t=gE(e);return(e,n)=>{let r=t(e,n);return jf(r)?E(r.value):(ES(r.cause,`Option adapter can only return none for schema issues`),T())}}function vE(e,t){let n=Ag(e);if(jf(n))return n.value;let r=ES(n.cause,t);throw Error(`Schema validation failed`,{cause:r})}var yE=`Constructor adapter can only throw schema issues`;function bE(e){throw Error(yE,{cause:rf(e)})}function xE(e){let t;return(n,r)=>SE(t??=tE(e),n,r)}function SE(e,t,n){let r=n?.disableChecks?n.parseOptions?{...n.parseOptions,disableChecks:!0}:{disableChecks:!0}:n?.parseOptions??wC,i=e.make;if(i!==void 0&&t!==U){let e;try{e=i(t,r)}catch(e){bE(e)}if(e!==YT&&e!==U)return e}return vE(mE(e.makeEffect(t,r),t),yE)}function CE(e,t,n,r){let i=tE(e),a=AT(e);if(a===void 0||i.make!==void 0||i.compiledMakeEffect!==void 0)return SE(i,t,n);if(a.isConstructed(t))return t;let o=SE((i.resolve??tE)(a.link.to),t,n);try{return r(o)}catch(e){bE(e)}}var wE=e=>tE(e).parser,TE=e=>tE(e).makeEffect,EE=`~effect/Schema/Schema`,DE=Symbol(),OE={[EE]:EE,get make(){let e=iE(this);return Object.defineProperty(this,"make",{value:e,enumerable:!0}),e},get makeEffect(){let e=nE(this);return Object.defineProperty(this,"makeEffect",{value:e,enumerable:!0}),e},get makeOption(){let e=rE(this);return Object.defineProperty(this,"makeOption",{value:e,enumerable:!0}),e},pipe(){return e(this,arguments)},annotate(e){return this.rebuild(Uw(this.ast,e))},annotateKey(e){return this.rebuild(eT(this.ast,e))},check(...e){return this.rebuild(Gw(this.ast,e))},rebuild(e){return kE(e,this[DE])}};function kE(e,t){function n(){}let r=Object.setPrototypeOf(n,OE);return t&&(Object.hasOwn(t,`name`)||Object.hasOwn(t,`length`)||Object.hasOwn(t,`__proto__`))?Object.defineProperties(r,Object.getOwnPropertyDescriptors({...t})):Object.assign(r,t),r[DE]=t,r.ast=e,r}function AE(e){return kE(jE(e.ast),{schema:e})}var jE=ME(LE);function ME(e,t){let n=f(t=>{let n=Vw(t,void 0),i=e(n,r);return i===n?null:i}),r=Zw(e=>{let t=n(Bw(e));if(t===null)return e;let r=Vw(t,e.context);return e.context===void 0?r:Yw(r,NE(e.context))},t);return r}function NE(e){return e.constructorDefault===void 0?e:new TC(e.isOptional,e.isMutable,void 0,e.annotations)}function PE(e){if(e.propertySignatures.some(e=>typeof e.name!=`string`))throw new globalThis.Error(`Objects property names must be strings`,{cause:e})}function FE(e){return t=>{let n=[...t].sort((t,n)=>e(pT(t))-e(pT(n)));return n.some((e,n)=>e!==t[n])?n:t}}var IE=FE(e=>{switch(e._tag){case`BigInt`:case`Symbol`:case`UniqueSymbol`:return 0;default:return 1}});function LE(e,t){switch(e._tag){case`Declaration`:{let n=e.annotations?.toCodecJson??e.annotations?.toCodec;if(!le(n))return G(e,[IT]);let r=n(e.typeParameters.map(e=>kE(pT(e))));return r===void 0?e:G(e,[Kw(r,t)])}case`Unknown`:return G(e,[IT]);case`ObjectKeyword`:return G(e,[LT]);case`Undefined`:case`Void`:case`Literal`:case`Number`:return e.toCodecJson();case`UniqueSymbol`:case`Symbol`:case`BigInt`:return e.toCodecStringTree();case`Objects`:return PE(e),e.recur(t,yT);case`Union`:{let n=IE(e.types);return n===e.types?e.recur(t):new Sw(n,e.options,e.annotations,e.checks,e.encoding,e.context,e.encodingChecks).recur(t)}case`Arrays`:case`Suspend`:return e.recur(t)}return e}function RE(e){return kE(WE(e.ast),{schema:e})}var zE=FE(e=>{switch(e._tag){case`Null`:case`Boolean`:case`Number`:case`BigInt`:case`Symbol`:case`UniqueSymbol`:return 0;default:return 1}});function BE(e,t,n){switch(e._tag){case`Declaration`:{let r=e.typeParameters.map(e=>kE(t(pT(e)))),i=e.annotations?.toCodecStringTree;if(le(i)){let n=i(r);return n===void 0?e:G(e,[Kw(n,t)])}let a=e.annotations?.toCodecJson,o=le(a)?a(r):void 0,s=o===void 0?e.annotations?.toCodec:void 0,c=o??(le(s)?s(r):void 0);return c===void 0?n(e):G(e,[Kw(c,t)])}case`Null`:return G(e,[VE]);case`Boolean`:return G(e,[HE]);case`Unknown`:case`ObjectKeyword`:return G(e,[zT]);case`Enum`:case`Number`:case`Literal`:case`UniqueSymbol`:case`Symbol`:case`BigInt`:return e.toCodecStringTree();case`Objects`:return PE(e),e.recur(t,yT);case`Union`:{let n=zE(e.types);return n===e.types?e.recur(t):new Sw(n,e.options,e.annotations,e.checks,e.encoding,e.context,e.encodingChecks).recur(t)}case`Arrays`:case`Suspend`:return e.recur(t)}return e}var VE=new CC(new IC(`null`),new ZS(NS(()=>null),NS(()=>`null`))),HE=new CC(new Sw([new IC(`true`),new IC(`false`)]),new ZS(NS(e=>e===`true`),zS())),UE=new ZS(NS(e=>typeof e==`string`?[e]:e),MS()),WE=ME((e,t)=>BE(e,t,e=>{throw new globalThis.Error(`Missing structural codec for StringTree`,{cause:e})}),{stopAt:e=>e.transformation===UE}),GE=r(2,(e,t)=>JE(e,(e,n)=>qE(t,e)?void 0:[e,n])),KE=e=>e;function qE(e,t){return e.some(e=>e===t||typeof e==`number`&&String(e)===t)}function JE(e,t){let n={};for(let r of Reflect.ownKeys(e)){if(!Object.prototype.propertyIsEnumerable.call(e,r))continue;let i=t(r,e[r]);if(i){let[e,t]=i;dt(n,e,t)}}return n}var YE=`~effect/Schema/SchemaError`;function XE(e){return v(e,`~effect/Schema/SchemaError`)&&e[`~effect/Schema/SchemaError`]===`~effect/Schema/SchemaError`}var ZE=e=>{let t=0;for(let n=0;n<e.length;n++)t+=e[n].length;let n=new Uint8Array(t),r=0;for(let t=0;t<e.length;t++)n.set(e[t],r),r+=e[t].length;return n},QE=ur((e,t)=>{let n=Math.min(e.length,t.length);for(let r=0;r<n;r++)if(e[r]!==t[r])return e[r]<t[r]?-1:1;return e.length<t.length?-1:+(e.length>t.length)});({...Nt}),{...Nt},{...Nt},{...Nt},{...Nt},{...Nt},{...Nt},{...Nt};var $E=EE;function eD(){return(e,t,n)=>K(new OC(e.map(uw),e=>t(e.map(e=>K(e))),n))}function tD(e,t){return eD()([],()=>(t,n,r)=>e(t)?I(t):B(new oS(n,t,r)),t)}function nD(e){return t=>ED(ED(t).annotate(e))}var rD=class extends Mo(`SchemaError`){[YE]=YE;constructor(e){let t=It();Lt(0);try{super({issue:e})}finally{Lt(t)}}get message(){return SS(this.issue)}toJSON(){return{_tag:this._tag,message:this.message}}[At](){return this.toJSON()}toString(){return`SchemaError(${this.message})`}};function iD(e){return XE(e)}function aD(e){return F(e)?oD(e):Mh(e,e=>xh(()=>uf(e,e=>new rD(e))))}function oD(e){return jf(e)?e:Ef(uf(e.cause,e=>new rD(e)))}function sD(e,t){let n;for(let r of e.reasons){if(!$d(r)||!iD(r.error))throw new globalThis.Error(t,{cause:e});n??=r.error}if(n===void 0)throw new globalThis.Error(t,{cause:e});return n}function cD(e){let t=Ag(e);if(jf(t))return t.value;throw sD(t.cause,`Sync adapter can only throw schema errors`)}var lD=aE;function uD(e,t){let n=cE(e,t);return(e,t)=>aD(n(e,t))}var dD=uD,fD=lE;function pD(e,t){let n=uD(e,t);return(e,t)=>cD(n(e,t))}var mD=pD;function hD(e,t){let n=uE(e,t);return(e,t)=>aD(n(e,t))}var gD=hD;function _D(e,t){let n=hD(e,t);return(e,t)=>cD(n(e,t))}var vD=_D,K=kE;function yD(e){return v(e,$E)&&e[$E]===$E}var bD=KE(e=>K(tT(e.ast),{schema:e})),xD=KE(e=>{let t=KD(e);return K(rT(e.ast),{schema:t})}),SD=KE(e=>K(fT(e.ast),{schema:e})),CD=KE(e=>K(pT(e.ast),{schema:e})),wD=`~effect/Schema/flip`;function TD(e){return v(e,wD)&&e[wD]===wD}function ED(e){return TD(e)?e.schema.rebuild(hT(e.ast)):K(hT(e.ast),{[wD]:wD,schema:e})}function DD(e){let t=K(new IC(e),{literal:e,transform(n){return t.pipe(JD(DD(n),{decode:NS(()=>n),encode:NS(()=>e)}))}});return t}var OD=K(PC),kD=K(FC),AD=K(MC),jD=K(RC),MD=K(VC),ND=K(HC),PD=K(UC),FD=K(NC);function ID(e,t){return K(e,{fields:t,mapFields(e,t){let n=e(this.fields);return ID(lw(n,t?.unsafePreserveChecks?this.ast.checks:void 0),n)}})}function q(e){return ID(lw(e,void 0),e)}function LD(e,t){return K(sT(e.ast,t.ast),{key:e,value:t})}function RD(e,t){return K(pw(e.ast,t.map(uw)),{schema:e,records:t})}function zD(e,t){return K(e,{elements:t,mapElements(e,t){let n=e(this.elements);return zD(dw(n,t?.unsafePreserveChecks?this.ast.checks:void 0),n)}})}function BD(e){return zD(dw(e),e)}var VD=KE(e=>K(new WC(!1,[],[e.ast]),{value:e})),HD=KE(e=>K(new WC(!1,[e.ast],[e.ast]),{value:e}));function UD(e,t){return K(e,{members:t,mapMembers(e,t){let n=e(this.members);return UD(fw(n,this.ast.options,t?.unsafePreserveChecks?this.ast.checks:void 0),n)}})}function WD(e,t){return UD(fw(e,t,void 0),e)}function GD(e){let t=e.map(DD);return K(fw(t,void 0,void 0),{literals:e,members:t,mapMembers(e){return WD(e(this.members))},pick(e){return GD(e)},transform(e){return WD(t.map((t,n)=>t.transform(e[n])))}})}var KD=KE(e=>WD([e,AD]));function qD(...e){return t=>t.check(...e)}function JD(e,t){return n=>K(aT(n.ast,e.ast,t?$S(t):rC()),{from:n,to:e})}function YD(e,t){return n=>t?JD(n,t)(e):JD(n)(e)}function XD(e){return t=>K(iT(t.ast,e),{schema:t})}function ZD(e){return F(e)&&e._tag===`Success`?e:Mh(e,e=>xh(()=>uf(e,e=>e.issue)))}function QD(e,t){let n=t?.encodingStrategy===`omit`?LS():MS();return t=>bD(CD(t)).pipe(JD(t,{decode:RS(ZD(e)),encode:n}))}function $D(e,t){return n=>SD(n).pipe(QD(e,t),YD(bD(n)))}function J(e){return DD(e).pipe(XD(I(e)))}function eO(e,t){return q({_tag:J(e),...t})}function tO(e,t){return tD(t=>t instanceof e,t)}function nO(){return(e,t)=>new CC(e.ast,$S(t))}var rO=Nw;function iO(e,t){let n=e.source,r=e.flags,i=/^[dg]*uy?$/.test(r),a=r===``?`new globalThis.RegExp(${x(n)})`:`new globalThis.RegExp(${x(n)}, ${x(r)})`;return Lw(e,{toJsonSchema:()=>i?{pattern:r.endsWith(`y`)?`^(?:${n})`:n}:[{},!0],toCode:()=>({runtime:`Schema.isPattern(${a})`}),...t})}var aO=K(Fw);function oO(e){let t=yr(e.order),n=e.formatter??x;return(r,i)=>rO(e=>t(e,r),{expected:`a value greater than or equal to ${n(r)}`,arbitraryConstraint:{order:e.order,minimum:r},...e.annotate?.(r),...i})}function sO(e){let t=yr(e.order),n=_r(e.order),r=vr(e.order),i=gr(e.order),a=e.formatter??x;return(o,s)=>{let c=o.exclusiveMinimum?n:t,l=o.exclusiveMaximum?i:r;return rO(e=>c(e,o.minimum)&&l(e,o.maximum),{expected:`a value between ${a(o.minimum)}${o.exclusiveMinimum?` (excluded)`:``} and ${a(o.maximum)}${o.exclusiveMaximum?` (excluded)`:``}`,arbitraryConstraint:{order:e.order,minimum:o.minimum,maximum:o.maximum,...o.exclusiveMinimum&&{exclusiveMinimum:!0},...o.exclusiveMaximum&&{exclusiveMaximum:!0}},...e.annotate?.(o),...s})}}function cO(e){if(!globalThis.Number.isFinite(e))throw new globalThis.RangeError(`Expected a finite number, got ${x(e)}`);return e}var lO=oO({order:fr,annotate:e=>({representation:{id:`effect/schema/isGreaterThanOrEqualTo`,payload:{minimum:cO(e)}},toJsonSchema:()=>({minimum:e}),toCode:()=>({runtime:`Schema.isGreaterThanOrEqualTo(${x(e)})`})})}),uO=sO({order:fr,annotate:e=>{let t=e.exclusiveMinimum?!0:void 0,n=e.exclusiveMaximum?!0:void 0;return{representation:{id:`effect/schema/isBetween`,payload:{minimum:cO(e.minimum),maximum:cO(e.maximum),...t&&{exclusiveMinimum:t},...n&&{exclusiveMaximum:n}}},toJsonSchema:()=>({[t?`exclusiveMinimum`:`minimum`]:e.minimum,[n?`exclusiveMaximum`:`maximum`]:e.maximum}),toCode:()=>({runtime:`Schema.isBetween({ minimum: ${x(e.minimum)}, maximum: ${x(e.maximum)}, exclusiveMinimum: ${x(t)}, exclusiveMaximum: ${x(n)} })`})}}});function dO(e){return rO(e=>globalThis.Number.isSafeInteger(e),{expected:`an integer`,representation:{id:`effect/schema/isInt`,payload:null},toJsonSchema:()=>({type:`integer`,minimum:globalThis.Number.MIN_SAFE_INTEGER,maximum:globalThis.Number.MAX_SAFE_INTEGER}),toCode:()=>({runtime:`Schema.isInt()`}),arbitraryConstraint:{number:`integer`},...e})}var fO=MD.check(dO()),pO=fO.check(lO(0));function mO(e,t,n){return rO(t=>t.length>=e,{expected:`a value with a length of at least ${e}`,representation:{id:`effect/schema/isMinLength`,payload:{minLength:e}},toJsonSchema:({type:n})=>n===`string`?e<=1?{minLength:t}:[{minLength:t},!0]:n===`array`?{minItems:e}:n===void 0?[{minLength:t,minItems:e},!0]:[{},!0],toCode:()=>({runtime:`Schema.isMinLength(${e})`}),[Hx]:!0,arbitraryConstraint:{minLength:e},...n})}function hO(e){return mO(1,1,e)}var gO=jD.check(hO()),_O=e=>+(e?.includeStack===!0)|(e?.excludeCause===!0?2:0),vO=e=>{switch(e){case 0:return;case 1:return{includeStack:!0};case 2:return{excludeCause:!0};case 3:return{includeStack:!0,excludeCause:!0}}},yO=[];function bO(e){let t=_O(e),n=yO[t];if(n!==void 0)return n;let r=GO.pipe(JD(kD,fC(vO(t))));return yO[t]=r,r}globalThis.RegExp,globalThis.URL;var xO=jD.annotate({expected:`a string that will be decoded as JSON`});function SO(e,t){return xO.pipe(JD(e,mC(t)))}globalThis.File,globalThis.URLSearchParams;var CO=jD.annotate({expected:`a base64 encoded string that will be decoded as Uint8Array`,format:`byte`,contentEncoding:`base64`}),wO=tO(globalThis.Uint8Array,{representation:{id:`effect/schema/Uint8Array`,payload:null},toCode:()=>({runtime:`Schema.Uint8Array`,Type:`globalThis.Uint8Array`}),expected:`Uint8Array`,toCodecJson:()=>nO()(CO,pC)});function TO(e,t){return K(eD()([e,t],([e,t])=>(n,r,i)=>{if(!Qd(n))return B(new oS(r,n,i));switch(n._tag){case`Fail`:return Ig(cE(e)(n.error,i),{onSuccess:of,onFailure:e=>cS(r,`error`,e,n,i)});case`Die`:return Ig(cE(t)(n.defect,i),{onSuccess:sf,onFailure:e=>cS(r,`defect`,e,n,i)});case`Interrupt`:return I(n)}},{representation:{id:`effect/schema/CauseReason`,payload:null},toCode:({typeParameters:e})=>({runtime:`Schema.CauseReason(${e[0].runtime}, ${e[1].runtime})`,Type:`Cause.Failure<${e[0].Type}, ${e[1].Type}>`,importDeclarations:[`import * as Cause from "effect/Cause"`]}),expected:`Cause.Failure`,toCodec:([e,t])=>nO()(WD([q({_tag:DD(`Fail`),error:e}),q({_tag:DD(`Die`),defect:t}),q({_tag:DD(`Interrupt`),fiberId:KD(aO)})]),tC({decode:e=>{switch(e._tag){case`Fail`:return of(e.error);case`Die`:return sf(e.defect);case`Interrupt`:return cf(e.fiberId)}},encode:e=>{switch(e._tag){case`Fail`:return{_tag:`Fail`,error:e.error};case`Die`:return{_tag:`Die`,defect:e.defect};case`Interrupt`:return{_tag:`Interrupt`,fiberId:e.fiberId}}}}))}).ast,{error:e,defect:t})}function EO(e,t){return K(eD()([e,t],([e,t])=>{let n=VD(TO(e,t));return(e,t,r)=>Zd(e)?Ig(cE(n)(e.reasons,r),{onSuccess:tf,onFailure:n=>cS(t,`reasons`,n,e,r)}):B(new oS(t,e,r))},{representation:{id:`effect/schema/Cause`,payload:null},toCode:({typeParameters:e})=>({runtime:`Schema.Cause(${e[0].runtime}, ${e[1].runtime})`,Type:`Cause.Cause<${e[0].Type}, ${e[1].Type}>`,importDeclarations:[`import * as Cause from "effect/Cause"`]}),expected:`Cause`,toCodec:([e,t])=>nO()(VD(TO(e,t)),tC({decode:tf,encode:({reasons:e})=>e}))}).ast,{error:e,defect:t})}var DO=eC({decode:(e,t)=>Tr(Ka(e),{onNone:()=>B(new sS({expected:`a valid Duration string`},e,t)),onSome:I}),encode:e=>I(globalThis.String(e))}),OO=tD(Qa,{representation:{id:`effect/schema/Duration`,payload:null},toCode:()=>({runtime:`Schema.Duration`,Type:`Duration.Duration`,importDeclarations:[`import * as Duration from "effect/Duration"`]}),expected:`Duration`,toCodecJson:()=>nO()(WD([q({_tag:DD(`Infinity`)}),q({_tag:DD(`NegativeInfinity`)}),q({_tag:DD(`Nanos`),value:PD}),q({_tag:DD(`Millis`),value:fO})]),tC({decode:e=>{switch(e._tag){case`Infinity`:return io;case`NegativeInfinity`:return ao;case`Nanos`:return oo(e.value);case`Millis`:return so(e.value)}},encode:e=>{switch(e.value._tag){case`Infinity`:return{_tag:`Infinity`};case`NegativeInfinity`:return{_tag:`NegativeInfinity`};case`Nanos`:return{_tag:`Nanos`,value:e.value.nanos};case`Millis`:return{_tag:`Millis`,value:e.value.millis}}}}))}),kO=jD.annotate({expected:`a string that will be decoded as a Duration`}).pipe(JD(OO,DO));function AO(e,t,n){return K(eD()([e,t,n],([e,t,n])=>{let r=EO(t,n);return(t,n,i)=>{if(!wf(t))return B(new oS(n,t,i));switch(t._tag){case`Success`:return Ig(cE(e)(t.value,i),{onSuccess:Tf,onFailure:e=>cS(n,`value`,e,t,i)});case`Failure`:return Ig(cE(r)(t.cause,i),{onSuccess:Ef,onFailure:e=>cS(n,`cause`,e,t,i)})}}},{representation:{id:`effect/schema/Exit`,payload:null},toCode:({typeParameters:e})=>({runtime:`Schema.Exit(${e[0].runtime}, ${e[1].runtime}, ${e[2].runtime})`,Type:`Exit.Exit<${e[0].Type}, ${e[1].Type}, ${e[2].Type}>`,importDeclarations:[`import * as Exit from "effect/Exit"`]}),expected:`Exit`,toCodec:([e,t,n])=>nO()(WD([q({_tag:DD(`Success`),value:e}),q({_tag:DD(`Failure`),cause:EO(t,n)})]),tC({decode:e=>e._tag===`Success`?Tf(e.value):Ef(e.cause),encode:e=>jf(e)?{_tag:`Success`,value:e.value}:{_tag:`Failure`,cause:e.cause}}))}).ast,{value:e,error:t,defect:n})}function jO(e){return K(eD()([e],([e])=>(t,n,r)=>Sr(t)?Cr(t)?gh:Ig(cE(e)(t.value,r),{onSuccess:E,onFailure:e=>cS(n,`value`,e,t,r)}):B(new oS(n,t,r)),{representation:{id:`effect/schema/Option`,payload:null},toCode:({typeParameters:e})=>({runtime:`Schema.Option(${e[0].runtime})`,Type:`Option.Option<${e[0].Type}>`,importDeclarations:[`import * as Option from "effect/Option"`]}),expected:`Option`,toCodec:([e])=>nO()(WD([q({_tag:DD(`Some`),value:e}),q({_tag:DD(`None`)})]),tC({decode:e=>e._tag===`None`?T():E(e.value),encode:e=>wr(e)?{_tag:`Some`,value:e.value}:{_tag:`None`}}))}).ast,{value:e})}var MO=globalThis.Symbol.for(`immer-draftable`),NO={};function PO(t,n,r,i,a){let o=RO(r,n,i),s=LO(n),c=class extends t{constructor(...[e,t]){let n=t?.[`~payload`],i=n?.token===NO?n.value:r.make(e??{},t);super(i,{...t,disableChecks:!0,"~payload":{token:NO,value:i}})}static[$E]=$E;get[s](){return s}static[MO]=!0;static identifier=n;static fields=r.fields;static get ast(){return o(this).ast}static pipe(){return e(this,arguments)}static rebuild(e){return o(this).rebuild(e)}static make(e,t){return CE(fT(o(this).ast),e??{},t,e=>FO(this,e))}static makeOption(e,t){return rE(o(this))(e??{},t)}static makeEffect(e,t){return o(this).makeEffect(e??{},t)}static annotate(e){return this.rebuild(Uw(this.ast,e))}static annotateKey(e){return this.rebuild(eT(this.ast,e))}static check(...e){return this.rebuild(Gw(this.ast,e))}static extend(e){return(t,n)=>{let i=zO(t)?t:q(t),o={...r.fields,...i.fields},s=lw(o,r.ast.checks,{identifier:e});return PO(this,e,ID(Gw(s,i.ast.checks),o),n,a)}}static mapFields(e,t){return r.mapFields(e,t)}};return a!==void 0&&Object.assign(c.prototype,a(n)),c}function FO(e,t){return new e(t,{"~payload":{token:NO,value:t}})}function IO(e){return new ZS(NS(t=>FO(e,t)),MS())}function LO(e){return`~effect/Schema/Class/${e}`}function RO(e,t,n){let r;return i=>{if(r!==void 0)return r;let a=LO(t),o=e=>e instanceof i||v(e,a),s=IO(i);return r=JD(K(new OC([e.ast],()=>(e,t,n)=>o(e)?I(e):B(new oS(t,e,n)),{identifier:t,[Wx]:([e])=>({isConstructed:o,link:new CC(e,s)}),toCodec:([e])=>new CC(e.ast,s),toEquivalence:([e])=>e,toFormatter:([e])=>t=>`${i.identifier}(${e(t)})`,[Ux]:gw(e.ast),...n})),s)(e)}}function zO(e){return yD(e)}var BO=e=>(t,n)=>PO(jo,e,zO(t)?t:q(t),n,e=>({toString(){return`${e}(${x({...this})})`}})),VO=e=>(t,n)=>PO(jn,e,zO(t)?t:q(t),n,e=>({name:e})),HO=e=>(t,n,r)=>{let i=zO(n)?n.mapFields(e=>({_tag:J(t),...e}),{unsafePreserveChecks:!0}):eO(t,n);return VO(e??t)(i,r)},UO=AE,WO=RE,GO=K(Uw(FT,{toCode:()=>({runtime:`Schema.Json`,Type:`Schema.Json`})})),KO=LD(jD,GO),qO=`~effect/Config`,JO=class{_tag=`ConfigError`;name=`ConfigError`;cause;constructor(e){this.cause=e}get message(){return this.cause.toString()}toString(){return`ConfigError(${this.message})`}},YO={...Bi({label:`Config`,evaluate(e){return this.parse(e.getRef(Ly))}}),[qO]:qO,toJSON(){return{_id:`Config`}}};function XO(e){let t=Object.create(YO);return t.evaluator=e,t.parse=t=>Lg(e(t,[]),Th),t}var ZO=(e,t,n)=>e.evaluator(t,n),QO=r(2,(e,t)=>XO((n,r)=>H(ZO(e,n,r),qr(t)))),$O=r(2,(e,t)=>XO((n,r)=>Pg(ZO(e,n,r),e=>Wr(e)?Br(t):e))),ek=e=>e.pipe(QO(E),$O(T())),tk=e=>ye(e,`SourceError`),nk=()=>`<configuration>`,rk=e=>t=>Mh(t,t=>bh(tf(t.reasons.map(e)))),ik=(e,t)=>e.load(t).pipe(rk(e=>$d(e)?sf(e.error).annotate(xf(e)):e),Pg(n=>({provider:e,path:t,node:n,toString:nk}))),ak=(e,t)=>ik(e.provider,[...e.path,t]),ok=(e,t)=>aT(FC,e,new ZS(PS(e=>t(e)),MS())),sk=e=>{switch(e._tag){case`Union`:return e.types.every(sk);case`Objects`:case`Arrays`:case`Suspend`:return!1;default:return!0}},ck=(e,t)=>{switch(e._tag){case`Objects`:return t?._tag===`Record`;case`Arrays`:return t?._tag===`Array`;case`Union`:return e.types.some(e=>ck(e,t));case`Suspend`:return ck(e.thunk(),t);default:return t?.value!==void 0}},lk=f(e=>{let t=new WeakSet,n=Xw(e=>{switch(t.add(e),e._tag){case`Objects`:{let t=jg(function*(t){if(t.node?._tag!==`Record`)return;let n=t.node,r=new Set;for(let t of e.propertySignatures)typeof t.name==`string`&&r.add(t.name);if(e.indexSignatures.length>0){let t={};for(let e of n.keys)dt(t,e,void 0);for(let n of e.indexSignatures)for(let e of ZC(t,n.parameter))typeof e==`string`&&r.add(e)}let i={};for(let e of r){let n=yield*ak(t,e);n.node!==void 0&&dt(i,e,n)}return i});return ok(e.recur(n,e=>e),t)}case`Arrays`:{let t=jg(function*(e){if(e.node?._tag!==`Array`)return;let t=[];for(let n=0;n<e.node.length;n++)t.push(yield*ak(e,n));return t});return ok(e.recur(n),t)}case`Union`:for(let t of e.types)n(t);if(!sk(e))return e.recur(n);break;case`Suspend`:{let r=e.thunk();return t.has(r)||n(r),e.recur(n)}case`Declaration`:case`Any`:throw new globalThis.Error(`Config.schema does not support opaque StringTree encodings`,{cause:e})}return ok(e,e=>I(e.node?.value))});return n(e)});function uk(e,t){let n=WO(e),r=pT(n.ast),i=cE(K(lk(n.ast))),a=typeof t==`string`?[t]:t??[];return XO((e,t)=>{let n=[...t,...a];return ik(e,n).pipe(Lg(e=>i(e).pipe(Pg(Br),Rg(t=>{let i=new JO(new rD(n.length>0?new nS(n,t):t));return ck(r,e.node)?B(i):I(Vr(i))}))),rk(e=>ef(e)&&tk(e.defect)?of(new JO(e.defect)).annotate(xf(e)):e))})}var dk=e=>re(e)||globalThis.Array.isArray(e);function fk(e){return uk(jD,e)}function pk(e,t,n){let r=dk(t),i=r?n:t,a=VD(e),o=i?.separator??`,`;return uk(WD([jD.pipe(JD(WO(a),{decode:WS(i),encode:AS(MS({strict:!1}),NS(e=>e.join(o)))})),a]),r?t:void 0)}var mk=`~effect/Match/Matcher`,hk={[mk]:{_input:i,_filters:i,_remaining:i,_result:i,_return:i,_args:i},_tag:`TypeMatcher`,add(e){return gk(this.select,[...this.cases,e])},pipe(){return e(this,arguments)}};function gk(e,t){let n=Object.create(hk);return n.select=e,n.cases=t,n}var _k={[mk]:{_input:i,_filters:i,_result:i,_return:i,_flavor:i},_tag:`ValueMatcher`,add(e){return Gr(this.value)?this:e._tag===`When`&&e.guard(this.provided)===!0||e._tag===`Not`&&e.guard(this.provided)===!1?vk(this.provided,Br(e.evaluate(this.provided))):this},pipe(){return e(this,arguments)}};function vk(e,t){let n=Object.create(_k);return n.provided=e,n.value=t,n}var yk=(e,t)=>({_tag:`When`,guard:e,evaluate:t}),bk=e=>{if(typeof e==`function`)return e;if(Array.isArray(e)){let t=e.map(bk),n=t.length;return e=>{if(!Array.isArray(e)||e.length<n)return!1;for(let r=0;r<n;r++)if(t[r](e[r])===!1)return!1;return!0}}if(typeof e==`object`&&e){let t=Reflect.ownKeys(e).map(t=>[t,bk(e[t])]),n=t.length;return e=>{if(typeof e!=`object`||!e)return!1;for(let r=0;r<n;r++){let[n,i]=t[r];if(!(n in e)||i(e[n])===!1)return!1}return!0}}return t=>t===e},xk=()=>gk(i,[]),Sk=e=>vk(e,Vr(e)),Ck=(e,t)=>n=>n.add(yk(bk(e),t)),wk=e=>t=>{let n=Tk(t);return Ur(n)?n._tag===`Success`?n.success:e(n.failure):(...t)=>{let r=n(...t);return Gr(r)?r.success:e(r.failure,...t)}},Tk=e=>{if(e._tag===`ValueMatcher`)return e.value;let t=e.cases.length;if(t===1){let t=e.cases[0];return(...n)=>{let r=e.select(...n);return t._tag===`When`&&t.guard(r)===!0||t._tag===`Not`&&t.guard(r)===!1?Br(t.evaluate(r,...n)):Vr(r)}}return(...n)=>{let r=e.select(...n);for(let i=0;i<t;i++){let t=e.cases[i];if(t._tag===`When`&&t.guard(r)===!0||t._tag===`Not`&&t.guard(r)===!1)return Br(t.evaluate(r,...n))}return Vr(r)}},Ek=xk,Dk=Sk,Ok=Ck,kk=wk,Ak=`~effect/http/HttpBody`,jk=class{[Ak];constructor(){this[Ak]=Ak}[At](){return this.toJSON()}toString(){return x(this,{ignoreToString:!0})}},Mk=new class extends jk{_tag=`Empty`;toJSON(){return{_id:`effect/HttpBody`,_tag:`Empty`}}};globalThis.Buffer;var Nk=`~effect/http/HttpClientError`,Pk=class extends Mo(`HttpClientError`){constructor(e){`cause`in e.reason?super({...e,cause:e.reason.cause}):super(e)}[Nk]=Nk;get request(){return this.reason.request}get response(){return`response`in this.reason?this.reason.response:void 0}get message(){return this.reason.message}},Fk=e=>e.endsWith(`Error`)?e.slice(0,-5):e,Ik=(e,t,n)=>t?`${e}: ${t} (${n})`:`${e} error (${n})`,Lk=e=>`${e.method} ${Mx(e.url)}`,Rk=(e,t)=>({...t,request:{_id:`HttpClientRequest`,method:e.request.method,url:Mx(e.request.url)},...`response`in e?{response:{_id:`HttpClientResponse`,status:e.response.status}}:void 0}),zk=class extends Mo(`TransportError`){get methodAndUrl(){return Lk(this.request)}get message(){return Ik(Fk(this._tag),this.description,this.methodAndUrl)}toJSON(){return Rk(this,super.toJSON())}},Bk=class extends Mo(`EncodeError`){get methodAndUrl(){return Lk(this.request)}get message(){return Ik(Fk(this._tag),this.description,this.methodAndUrl)}toJSON(){return Rk(this,super.toJSON())}},Vk=class extends Mo(`InvalidUrlError`){get methodAndUrl(){return Lk(this.request)}get message(){return Ik(Fk(this._tag),this.description,this.methodAndUrl)}toJSON(){return Rk(this,super.toJSON())}},Hk=class extends Mo(`StatusCodeError`){get methodAndUrl(){return Lk(this.request)}get message(){let e=`${this.response.status} ${this.methodAndUrl}`;return Ik(Fk(this._tag),this.description,e)}toJSON(){return Rk(this,super.toJSON())}},Uk=class extends Mo(`DecodeError`){get methodAndUrl(){return Lk(this.request)}get message(){let e=`${this.response.status} ${this.methodAndUrl}`;return Ik(Fk(this._tag),this.description,e)}toJSON(){return Rk(this,super.toJSON())}},Wk=class extends Mo(`EmptyBodyError`){get methodAndUrl(){return Lk(this.request)}get message(){let e=`${this.response.status} ${this.methodAndUrl}`;return Ik(Fk(this._tag),this.description,e)}toJSON(){return Rk(this,super.toJSON())}},Gk=class e extends VO(Nk)({_tag:J(`HttpError`),kind:GD([`EncodeError`,`DecodeError`,`TransportError`,`InvalidUrlError`,`StatusCodeError`,`EmptyBodyError`]),cause:xD(bO())}){static fromHttpClientError(t){return new e({_tag:`HttpError`,kind:t.reason._tag,cause:t.reason})}},Kk=[[`GET`,`get`],[`POST`,`post`],[`PUT`,`put`],[`DELETE`,`del`],[`PATCH`,`patch`],[`HEAD`,`head`],[`OPTIONS`,`options`],[`TRACE`,`trace`],[`QUERY`,`query`]],qk=(e,t)=>t._tag===`Empty`||t._tag===`FormData`?fx(fx(e,`content-type`),`content-length`):(e=t.contentType===void 0?fx(e,`content-type`):lx(e,`content-type`,t.contentType),Jk(e,t)),Jk=(e,t)=>{let n=t._tag===`Empty`||t._tag===`FormData`?void 0:t.contentLength;return n===void 0?fx(e,`content-length`):lx(e,`content-length`,n.toString())},Yk=class extends Mo(`UrlError`){},Xk=(e,t,n)=>Hr({try:()=>{let r=new URL(e,Zk());for(let e=0;e<t.params.length;e++){let[n,i]=t.params[e];i!==void 0&&r.searchParams.append(n,gx(i))}return n!==void 0&&(r.hash=n),r},catch:e=>new Yk({cause:e})}),Zk=()=>{if(`location`in globalThis&&globalThis.location!==void 0&&globalThis.location.origin!==void 0&&globalThis.location.pathname!==void 0){let e=location.origin+location.pathname;try{return new URL(e).href}catch{return}}},Qk=(e,t)=>Hr({try:()=>new URL(e,t),catch:()=>new bf(`Invalid URL: "${e}"${t===void 0?``:` with base "${t}"`}`)}),$k=`~effect/http/HttpClientRequest`,eA={[$k]:$k,...Nt,toJSON(){return{_id:`HttpClientRequest`,method:this.method,url:Mx(this.url),urlParams:this.urlParams,hash:this.hash,headers:ht(this.headers),body:this.body.toJSON()}},pipe(){return e(this,arguments)}};function tA(e,t,n,r,i,a){let o=Object.create(eA);return o.method=e,o.url=t,o.urlParams=n,o.hash=r,o.headers=i,o.body=a,o}var nA=tA(`GET`,``,Ox,T(),ox,Mk),rA=e=>(t,n)=>iA(nA,{method:e,url:t,...n??void 0}),iA=r(2,(e,t)=>{let n=e;return t.method&&(n=aA(n,t.method)),t.url&&(n=uA(n,t.url)),t.headers&&(n=sA(n,t.headers)),t.urlParams&&(n=dA(n,t.urlParams)),t.hash&&(n=fA(n,t.hash)),t.body&&(n=pA(n,t.body)),t.accept&&(n=cA(n,t.accept)),t.acceptJson&&(n=lA(n)),n}),aA=r(2,(e,t)=>tA(t,e.url,e.urlParams,e.hash,e.headers,e.body)),oA=r(3,(e,t,n)=>tA(e.method,e.url,e.urlParams,e.hash,lx(e.headers,t,n),e.body)),sA=r(2,(e,t)=>tA(e.method,e.url,e.urlParams,e.hash,ux(e.headers,t),e.body)),cA=r(2,(e,t)=>oA(e,`Accept`,t)),lA=cA(`application/json`),uA=r(2,(e,t)=>{if(typeof t==`string`)return tA(e.method,t,e.urlParams,e.hash,e.headers,e.body);let n=new URL(t.toString()),r=Cx(n.searchParams),i=Or(n.hash===``?void 0:n.hash.slice(1));return n.search=``,n.hash=``,tA(e.method,n.toString(),r,i,e.headers,e.body)}),dA=r(2,(e,t)=>tA(e.method,e.url,kx(e.urlParams,t),e.hash,e.headers,e.body)),fA=r(2,(e,t)=>tA(e.method,e.url,e.urlParams,E(t),e.headers,e.body)),pA=r(2,(e,t)=>tA(e.method,e.url,e.urlParams,e.hash,qk(e.headers,t),t));function mA(e){let t=Xk(e.url,e.urlParams,jr(e.hash));return Gr(t)?E(t.success):T()}var hA=`~effect/http/HttpIncomingMessage`,gA=(e,t)=>{let n=dD(UO(e)),r=t?.reviver===void 0?void 0:dD(SO(UO(e),t));return e=>r===void 0?V(e.json,e=>n(e,t)):V(e.text,i=>i===``?V(e.json,e=>n(e,t)):r(i,t))},_A=(e,t)=>({...t,headers:ht(e.headers),remoteAddress:e.remoteAddress}),vA=`~effect/http/HttpClientResponse/WebSource`,yA=e=>e[vA]?.(),bA=`~effect/http/HttpClientResponse`,xA=(e,t)=>new CA(e,t),SA=e=>e.status>=200&&e.status<300?I(e):B(new Pk({reason:new Hk({response:e,request:e.request,description:`non 2xx status code`})})),CA=class extends Pt{[hA];[bA];request;source;constructor(e,t){super(),this.request=e,this.source=t,this[hA]=hA,this[bA]=bA}toJSON(){return _A(this,{_id:`HttpClientResponse`,request:this.request.toJSON(),status:this.status})}get status(){return this.source.status}get url(){if(this.source.url)return this.source.url.split(`#`)[0];let e=mA(this.request);return Cr(e)?``:(e.value.hash=``,e.value.href)}get headers(){return sx(this.source.headers)}cachedCookies;get cookies(){return this.cachedCookies?this.cachedCookies:this.cachedCookies=Hb(this.source.headers.getSetCookie?.()??[])}get remoteAddress(){return T()}[vA](){return this.source}get stream(){return this.source.body?by({evaluate:()=>this.source.body,onError:e=>new Pk({reason:new Uk({request:this.request,response:this,cause:e})})}):_y(new Pk({reason:new Wk({request:this.request,response:this,description:`can not create stream from empty body`})}))}get json(){return V(this.text,e=>Ch({try:()=>e===``?null:JSON.parse(e),catch:e=>new Pk({reason:new Uk({request:this.request,response:this,cause:e})})}))}textBody;get text(){return this.textBody??=H(this.arrayBuffer,e=>new TextDecoder().decode(e))}get urlParamsBody(){return V(this.arrayBuffer,e=>Ch({try:()=>Cx(vx(e)),catch:e=>new Pk({reason:new Uk({request:this.request,response:this,cause:e})})}))}formDataBody;get formData(){return this.formDataBody??=hh({try:()=>this.source.formData(),catch:e=>new Pk({reason:new Uk({request:this.request,response:this,cause:e})})}).pipe(ug,Og)}arrayBufferBody;get arrayBuffer(){return this.arrayBufferBody||=hh({try:()=>this.source.arrayBuffer(),catch:e=>new Pk({reason:new Uk({request:this.request,response:this,cause:e})})}).pipe(ug,Og),this.arrayBufferBody}get upgrade(){return B(new Pk({reason:new Hk({request:this.request,response:this,description:`fetch cannot hand over the connection of an HTTP upgrade`})}))}pipe(){return e(this,arguments)}},wA=e=>cx({b3:`${e.traceId}-${e.spanId}-${e.sampled?`1`:`0`}${Tr(e.parent,{onNone:()=>``,onSome:e=>`-${e.spanId}`})}`,traceparent:`00-${e.traceId.padStart(32,`0`)}-${e.spanId}-${e.sampled?`01`:`00`}`}),TA={"http:":80,"https:":443,"ws:":80,"wss:":443},EA=(e,t,n)=>{let r=Mx(t.search,n).slice(1);if(e.attribute(`url.full`,Mx(t.href,n)),e.attribute(`url.path`,t.pathname),r!==``&&e.attribute(`url.query`,r),e.attribute(`url.scheme`,t.protocol.slice(0,-1)),t.hostname!==``){e.attribute(`server.address`,t.hostname.startsWith(`[`)?t.hostname.slice(1,-1):t.hostname);let n=t.port===``?TA[t.protocol]:Number(t.port);n!==void 0&&e.attribute(`server.port`,n)}},DA=(e,t)=>{let n=e.params.filter(([,e])=>typeof e!=`string`).map(([e])=>e);return n.length===0?t:[...t,...new URLSearchParams(n.map(e=>[e,``])).keys()]},OA=(e,t,n,r,i)=>{for(let a in n)r(a,t)&&e.attribute(`http.${t}.header.${a}`,mx(a,i)?`<redacted>`:n[a])},kA=`~effect/http/HttpClient`,AA=Hi(`effect/HttpClient`),jA=(e=>(...t)=>V(AA,n=>n[e](...t)))(`get`),MA=r(2,(e,t)=>NA(n=>t(e.postprocess(n)),e.preprocess)),NA=(e,t)=>{let n=Object.create(PA);return n.preprocess=t,n.postprocess=e,n.execute=function(n){return e(t(n))},n},PA={[kA]:kA,pipe(){return e(this,arguments)},...Nt,toJSON(){return{_id:`effect/HttpClient`}},...Object.fromEntries(Kk.map(([e,t])=>[t,function(t,n){return this.execute(rA(e)(t,n))}]))},FA=e=>NA(t=>V(t,t=>wh(n=>{let r=UA.get(t),i=r??new AbortController,a=Xk(t.url,t.urlParams,jr(t.hash));if(Wr(a))return B(new Pk({reason:new Vk({request:t,cause:a.failure})}));let o=a.success;if(n.getRef(Uo)||n.getRef(LA)(t)){let a=e(t,o,i.signal,n);return r?H(a,e=>GA(e,i,!0)):hg(e=>qh(e(a),{onSuccess(e){return I(GA(e,i,!1))},onFailure(e){return mf(e)&&i.abort(),bh(e)}}))}return vg(n.getRef(BA)(t),{kind:`client`},a=>{a.attribute(`http.request.method`,t.method);let s=n.getRef(hx);EA(a,o,DA(t.urlParams,n.getRef(Bx)));let c=n.getRef(RA);return OA(a,`request`,t.headers,c,s),t=n.getRef(zA)?sA(t,wA(a)):t,hg(l=>l(e(t,o,i.signal,n)).pipe(yg(a,{captureStackTrace:!1}),qh({onSuccess:e=>(a.attribute(`http.response.status_code`,e.status),OA(a,`response`,e.headers,c,s),e.status>=400&&e.status<600&&(a.attribute(`error.type`,String(e.status)),IA(n,a,t,e)),I(GA(e,i,r!==void 0))),onFailure(e){return!r&&mf(e)&&i.abort(),bh(e)}})))})})),I),IA=(e,t,n,r)=>{let i=It();Lt(0);let a;try{a=Df(new Pk({reason:new Hk({request:n,response:r})}))}finally{Lt(i)}t.end(e.getRef(Wf)?e.getRef(Sf).currentTimeNanosUnsafe():BigInt(0),a)},LA=O(`effect/http/HttpClient/TracerDisabledWhen`,{defaultValue:()=>s}),RA=O(`effect/http/HttpClient/TracerHeaderFilter`,{defaultValue:()=>s}),zA=O(`effect/http/HttpClient/TracerPropagationEnabled`,{defaultValue:o}),BA=O(`effect/http/HttpClient/SpanNameGenerator`,{defaultValue:()=>e=>e.method}),VA=e=>gp(AA)(Yh(t=>H(e,e=>MA(e,$h(e=>_a(t,e)))))),HA=(()=>{if(`FinalizationRegistry`in globalThis&&globalThis.FinalizationRegistry){let e=new FinalizationRegistry(e=>{try{e.abort()}catch{}});return{register(t,n){e.register(t,n,t)},unregister(t){e.unregister(t)}}}let e=new WeakMap;return{register(t,n){e.set(t,setTimeout(()=>n.abort(),5e3))},unregister(t){let n=e.get(t);n!==void 0&&(clearTimeout(n),e.delete(t))}}})(),UA=new WeakMap,WA=new WeakMap,GA=(e,t,n)=>(n||(HA.register(e,t),e=new KA(e,t)),WA.set(e,t),e),KA=class{original;controller;constructor(e,t){this.original=e,this.controller=t}[bA]=bA;[hA]=hA;applyInterrupt(e){return L(()=>(HA.unregister(this.original),pg(e,()=>R(()=>{this.controller.abort()}))))}get request(){return this.original.request}get url(){return this.original.url}get status(){return this.original.status}get headers(){return this.original.headers}get cookies(){return this.original.cookies}get remoteAddress(){return this.original.remoteAddress}get formData(){return this.applyInterrupt(this.original.formData)}get text(){return this.applyInterrupt(this.original.text)}get json(){return this.applyInterrupt(this.original.json)}get urlParamsBody(){return this.applyInterrupt(this.original.urlParamsBody)}get arrayBuffer(){return this.applyInterrupt(this.original.arrayBuffer)}get upgrade(){return this.applyInterrupt(this.original.upgrade)}[vA](){let e=yA(this.original);return e!==void 0&&HA.unregister(this.original),e}get stream(){return hy(()=>(HA.unregister(this.original),Dy(this.original.stream,R(()=>{this.controller.abort()}))))}toJSON(){return this.original.toJSON()}[At](){return this.original[At]()}pipe(){return e(this,arguments)}},qA=O(`effect/http/FetchHttpClient/Fetch`,{defaultValue:()=>globalThis.fetch}),JA=O(`effect/http/FetchHttpClient/StreamBodyFallback`,{defaultValue:()=>`error`}),YA=class extends Hi()(`effect/http/FetchHttpClient/RequestInit`){},XA,ZA=()=>{try{let e=!1,t=new ReadableStream,n=new Request(`https://example.com`,{method:`POST`,body:t,get duplex(){return e=!0,`half`}});return(e||n.body===t)&&!n.headers.has(`Content-Type`)}catch{return!1}},QA=VA(I(FA((e,t,n,r)=>{if(e.headers.upgrade!==void 0)return B(new Pk({reason:new zk({request:e,description:`fetch cannot send an HTTP upgrade request`})}));let i=r.getRef(qA),a=ua(r.context,YA)??{},o=a.headers?dx(sx(a.headers),e.headers):e.headers;o[`content-length`]&&(o=fx(o,`content-length`));let s,c=R(()=>s?.abort()),l=r=>H(hh({try:()=>i(t,{...a,method:e.method,headers:o,body:r,duplex:typeof ReadableStream<`u`&&r instanceof ReadableStream?`half`:void 0,signal:s?AbortSignal.any([n,s.signal]):n}),catch:t=>new Pk({reason:new zk({request:e,cause:t})})}),t=>{let n=xA(e,t);return s?(t.body===null&&s.abort(),Object.create(n,{...Object.fromEntries([`arrayBuffer`,`text`,`json`,`formData`,`urlParamsBody`].map(e=>[e,{get:()=>og(n[e],c)}])),stream:{get:()=>Dy(n.stream,c)}})):n}).pipe(sg(()=>c));switch(e.body._tag){case`Raw`:case`Uint8Array`:return l(e.body.body);case`FormData`:return l(e.body.formData);case`Stream`:if(XA??=ZA(),XA){s=new AbortController;let t=AbortSignal.any([n,s.signal]),r=_h(e=>{let n=()=>e(dg);if(t.aborted)n();else return t.addEventListener(`abort`,n,{once:!0}),R(()=>t.removeEventListener(`abort`,n))});return V(Ny(Ty(e.body.stream,r)),l)}return r.getRef(JA)===`error`?B(new Pk({reason:new Bk({request:e,description:`Streaming request bodies are not supported in this runtime`})})):jy(e.body.stream).pipe(Ph(t=>new Pk({reason:new Bk({request:e,cause:t})})),V(l))}return l(void 0)}))),$A=`~effect/reactivity/AsyncResult`,ej=e=>v(e,$A),tj={[$A]:{E:i,A:i},pipe(){return e(this,arguments)},[Ve](e){if(!ej(e)||this._tag!==e._tag||this.waiting!==e.waiting)return!1;switch(this._tag){case`Initial`:return!0;case`Success`:return b(this.value,e.value);case`Failure`:return b(this.cause,e.cause)}},[Se](){let e=Ae(`${this._tag}:${this.waiting}`);return this._tag===`Initial`?e:Te(e)(this._tag===`Success`?y(this.value):y(this.cause))}},nj=e=>e.waiting,rj=(e,t)=>e._tag===`Success`?lj(e.value):fj(e.cause,{previous:t}),ij=e=>e._tag===`None`?sj(!0):mj(e.value),aj=e=>e._tag===`Initial`,oj=e=>e._tag!==`Initial`,sj=(e=!1)=>{let t=Object.create(tj);return t._tag=`Initial`,t.waiting=e,t},cj=e=>e._tag===`Success`,lj=(e,t)=>{let n=Object.create(tj);return n._tag=`Success`,n.value=e,n.waiting=t?.waiting??!1,n.timestamp=t?.timestamp??Date.now(),n},uj=e=>e._tag===`Failure`,dj=(e,t)=>{let n=Object.create(tj);return n._tag=`Failure`,n.cause=e,n.previousSuccess=t?.previousSuccess??T(),n.waiting=t?.waiting??!1,n},fj=(e,t)=>dj(e,{previousSuccess:Fr(t.previous,e=>cj(e)?E(e):uj(e)?e.previousSuccess:T()),waiting:t.waiting}),pj=(e,t)=>fj(nf(e),t),mj=r(e=>ej(e[0]),(e,t)=>{if(e.waiting)return t?.touch?hj(e):e;let n=Object.assign(Object.create(tj),e);return n.waiting=!0,t?.touch&&cj(n)&&(n.timestamp=Date.now()),n}),hj=e=>cj(e)?lj(e.value,{waiting:e.waiting}):e,gj=r(2,(e,t)=>e._tag===`Failure`?fj(e.cause,{previous:t,waiting:e.waiting}):e),_j=e=>e._tag===`Success`?E(e.value):e._tag===`Failure`?Pr(e.previousSuccess,e=>e.value):T(),vj=r(2,(e,t)=>Er(_j(e),t)),yj=e=>Nr(_j(e),()=>new _f(`AsyncResult.getOrThrow: no value found`)),bj=e=>e._tag===`Failure`?pf(e.cause):T(),xj=e=>{switch(e._tag){case`Success`:return Tf(e.value);case`Failure`:return Ef(e.cause);default:return Df(new _f)}},Sj=e=>{let t=e.success??OD,n=e.error??OD,r=eD()([t,EO(n,bO())],([e,t])=>(n,r,i)=>{if(!ej(n))return B(new oS(r,n,i));switch(n._tag){case`Initial`:return I(n);case`Success`:return Ig(cE(e)(n.value,i),{onSuccess:e=>lj(e,n),onFailure:e=>cS(r,`value`,e,n,i)});case`Failure`:{let a=n.previousSuccess.pipe(Pr(t=>Ig(cE(e)(t.value,i),{onSuccess:e=>E(lj(e,t)),onFailure:e=>new aS(r,[new nS([`previousSuccess`,`value`],e)],n,i)})),Er(()=>gh)),o=Fg(cE(t)(n.cause,i),e=>cS(r,`cause`,e,n,i));return Lg(a,e=>Pg(o,t=>dj(t,{previousSuccess:e,waiting:n.waiting})))}}},{expected:`AsyncResult`,toCodec([e,t]){let n=eO(`Success`,{value:e,waiting:ND,timestamp:fO});return nO()(WD([eO(`Initial`,{waiting:ND}),n,eO(`Failure`,{cause:t,previousSuccess:jO(n),waiting:ND})]),tC({decode:e=>{switch(e._tag){case`Initial`:return sj(e.waiting);case`Success`:return lj(e.value,{waiting:e.waiting,timestamp:e.timestamp});case`Failure`:return dj(e.cause,{previousSuccess:Pr(e.previousSuccess,e=>lj(e.value,e)),waiting:e.waiting})}},encode(e){switch(e._tag){case`Initial`:return{_tag:`Initial`,waiting:e.waiting};case`Success`:return{_tag:`Success`,value:e.value,waiting:e.waiting,timestamp:e.timestamp};case`Failure`:return{_tag:`Failure`,cause:e.cause,previousSuccess:e.previousSuccess,waiting:e.waiting}}}}))},toEquivalence:nt,toFormatter:([e,t])=>n=>{switch(n._tag){case`Success`:return`AsyncResult.Success(${e(n.value)}, ${n.waiting}, ${n.timestamp})`;case`Failure`:return`AsyncResult.Failure(${t(n.cause)}, ${n.waiting})`;case`Initial`:return`AsyncResult.Initial(${n.waiting}, ${n.waiting})`}}});return Object.assign(r,{success:t,error:n})},Cj=`~effect/reactivity/Reactivity`,wj=Hi(`effect/reactivity/Reactivity`),Tj=R(()=>{let e=new Map,t=t=>{let n=new Set;for(let r of t)e.get(r)?.forEach(e=>{n.has(e)||(n.add(e),e())})},n=e=>{let n=new Set;jj(e,e=>n.add(e)),t(n)},r=e=>Yh(t=>{let r=ua(t,Ej);return r?jj(e,e=>{r.add(e)}):n(e),z}),i=(e,t)=>Oh(t,r(e)),a=(t,n)=>{let r=[];return jj(t,t=>{r.push(t);let i=e.get(t);i===void 0&&(i=new Set,e.set(t,i)),i.add(n)}),()=>{for(let t=0;t<r.length;t++){let i=e.get(r[t]);i!==void 0&&(i.delete(n),i.size===0&&e.delete(r[t]))}}},o=(e,t)=>yh(function*(){let n=yield*Jh(),r=D(n,Gf),i=yield*M_(),o=d(wg(n),Wg(r)),s=!1,c=!1,l=!1,u=e=>{e._tag===`Failure`?(l=!0,c=!1,s=!1,p(),z_(i,e.cause)):(F_(i,e.value),c?(c=!1,o(t).addObserver(u)):s=!1)};function f(){l||(s?c=!0:(s=!0,o(t).addObserver(u)))}let p=a(e,f);return yield*Yf(r,R(p)),f(),i}),s=(e,t)=>o(e,t).pipe(H(vy),xy),c=e=>L(()=>{let n=new Set;return e.pipe(eg(Ej,n),lg(e=>R(()=>t(n))))});return wj.of({[Cj]:Cj,mutation:i,query:o,stream:s,invalidateUnsafe:n,invalidate:r,registerUnsafe:a,withBatch:c})}),Ej=class extends Hi()(`effect/reactivity/Reactivity/PendingInvalidation`){},Dj=r(2,(e,t)=>wj.use(n=>n.mutation(t,e))),Oj=e=>wj.use(t=>t.invalidate(e)),kj=gp(wj)(Tj);function Aj(e){switch(typeof e){case`string`:case`number`:case`bigint`:case`boolean`:return String(e);default:return y(e)}}var jj=(e,t)=>{if(Array.isArray(e))for(let n=0;n<e.length;n++)t(Aj(e[n]));else for(let n in e){t(n);let r=e[n];for(let e=0;e<r.length;e++)t(`${n}:${Aj(r[e])}`)}},Mj=`~effect/SubscriptionRef`,Nj=e=>v(e,Mj);({...Yt});var Pj=e=>yy(e.pubsub),Fj=e=>R(()=>e.value),Ij=(e,t)=>{e.value=t,b_(e.pubsub,t)},Lj=r(2,(e,t)=>e.semaphore.withPermit(R(()=>Ij(e,t)))),Rj=(e,t)=>!ej(e)||!ej(t)?!0:aj(t)?aj(e):cj(e)&&cj(t)?t.timestamp>=e.timestamp:!0,zj=`~effect/reactivity/AtomRegistry`,Bj=e=>v(e,zj),Vj=e=>new Xj(e?.initialValues,e?.scheduleTask,e?.timeoutResolution,e?.defaultIdleTTL),Hj=Hi(zj),Uj=r(e=>Bj(e[0]),(e,t,n)=>{let r=n?.suspendOnWaiting??!1;return _h(n=>{let i=e.get(t);if(i._tag!==`Initial`&&!(r&&i.waiting))return n(xj(i));let a=e.subscribe(t,e=>{e._tag!==`Initial`&&!(r&&e.waiting)&&(n(xj(e)),a())});return R(a)})}),Wj={immediate:!0},Gj=e=>{e()},Kj={};function qj(e,t){let n=Kj;for(let r of e)try{t(r)}catch(e){n===Kj&&(n=e)}if(n!==Kj)throw n}var Jj=`~effect-atom/atom/Atom/Serializable`,Yj=e=>Jj in e?e[Jj].key:e,Xj=class{[zj];timeoutResolution;defaultIdleTTL;scheduler;schedulerAsync;dispatcher;onNodeAdded;onNodeRemoved;constructor(e,t,n,r){if(this[zj]=zj,this.scheduler=new Do(`sync`,t),this.schedulerAsync=new Do(`async`,t),this.dispatcher=this.schedulerAsync.makeDispatcher(),this.defaultIdleTTL=r,this.timeoutResolution=n===void 0&&r!==void 0?Math.round(r/2):n??1e3,e!==void 0)for(let[t,n,r]of e){let e=t;for(;e.initialValueTarget;)e=e.initialValueTarget;this.ensureNode(e).setInitialValue(n,r?.skipInitialRun)}}nodes=new Map;preloadedSerializable=new Map;timeoutBuckets=new Map;nodeTimeoutBucket=new Map;disposed=!1;getNodes(){return this.nodes}get(e){return this.ensureNode(e).value()}set(e,t){e.write(this.ensureNode(e).writeContext,t)}setSerializable(e,t){this.preloadedSerializable.set(e,t)}modify(e,t){let n=this.ensureNode(e),r=t(n.value());return e.write(n.writeContext,r[1]),r[0]}update(e,t){let n=this.ensureNode(e);e.write(n.writeContext,t(n.value()))}refresh=e=>{e.refresh===void 0?this.invalidateAtom(e):e.refresh(this.refresh)};subscribe(e,t,n){let r=this.ensureNode(e);if(n?.immediate)t(r.value());else try{r.value()}catch(e){if((r.state&Zj.waitingForValue)===0)throw e}let i=r.subscribe(function(){t(r._value)});return()=>{i(),r.canBeRemoved&&this.scheduleNodeRemoval(r)}}mount(e){return this.subscribe(e,l,Wj)}atomHasTtl(e){return!e.keepAlive&&e.idleTTL!==0&&(e.idleTTL!==void 0||this.defaultIdleTTL!==void 0)}ensureNode(e){let t=Yj(e),n=this.nodes.get(t);if(n===void 0?(n=this.createNode(e),this.nodes.set(t,n),this.onNodeAdded?.(n)):this.atomHasTtl(e)&&this.removeNodeTimeout(n),typeof t==`string`&&this.preloadedSerializable.has(t)){let r=this.preloadedSerializable.get(t);this.preloadedSerializable.delete(t);let i=e[Jj],a;try{a=i.decode(r)}catch(e){if(iD(e))return n;throw e}let o=e;for(;o.initialValueTarget;)o=o.initialValueTarget;let s=o===e?n:this.ensureNode(o);Rj(s._value,a)&&s.setInitialValue(a,i.skipInitialRun)}return n}createNode(e){if(this.disposed)throw Error(`Cannot access Atom ${e}: registry is disposed`);return e.keepAlive||this.scheduleAtomRemoval(e),new $j(this,e)}invalidateAtom=e=>{let t=this.ensureNode(e);t.skipInitialRun=!1,t.invalidate()};scheduleAtomRemoval(e){this.dispatcher.scheduleTask(()=>{let t=this.nodes.get(Yj(e));t!==void 0&&t.canBeRemoved&&this.removeNode(t)},0)}scheduleNodeRemoval(e){this.dispatcher.scheduleTask(()=>{e.canBeRemoved&&this.removeNode(e)},0)}removeNode(e){this.atomHasTtl(e.atom)?this.setNodeTimeout(e):(this.nodes.delete(Yj(e.atom)),e.remove(),this.onNodeRemoved?.(e))}setNodeTimeout(e){if(this.nodeTimeoutBucket.has(e))return;let t=e.atom.idleTTL??this.defaultIdleTTL;if(this.#e!==null&&(t-=this.#e,t<=0)){this.nodes.delete(Yj(e.atom)),e.remove(),this.onNodeRemoved?.(e);return}let n=Math.ceil(t/this.timeoutResolution)*this.timeoutResolution,r=Date.now()+n,i=r-r%this.timeoutResolution+this.timeoutResolution,a=this.timeoutBuckets.get(i);a===void 0&&(a=[new Set,setTimeout(()=>this.sweepBucket(i),i-Date.now())],this.timeoutBuckets.set(i,a)),a[0].add(e),this.nodeTimeoutBucket.set(e,i)}removeNodeTimeout(e){let t=this.nodeTimeoutBucket.get(e);if(t===void 0)return;this.nodeTimeoutBucket.delete(e),this.scheduleNodeRemoval(e);let[n,r]=this.timeoutBuckets.get(t);n.delete(e),n.size===0&&(clearTimeout(r),this.timeoutBuckets.delete(t))}#e=null;sweepBucket(e){let t=this.timeoutBuckets.get(e)[0];this.timeoutBuckets.delete(e),qj(t,this.removeIdleNode)}removeIdleNode=e=>{if(this.nodeTimeoutBucket.delete(e),e.canBeRemoved){this.nodes.delete(Yj(e.atom)),this.onNodeRemoved?.(e),this.#e=e.atom.idleTTL??this.defaultIdleTTL;try{e.remove()}finally{this.#e=null}}};reset(){this.timeoutBuckets.forEach(([,e])=>clearTimeout(e)),this.timeoutBuckets.clear(),this.nodeTimeoutBucket.clear();let e=Array.from(this.nodes.values());this.nodes.clear();for(let t of e)t.state=Qj.removed;qj(e,this.destroyNode)}destroyNode=e=>{e.remove(),this.onNodeRemoved?.(e)};dispose(){this.disposed=!0,this.reset()}},Zj={alive:1,initialized:2,waitingForValue:4},Qj={uninitialized:Zj.alive|Zj.waitingForValue,stale:Zj.alive|Zj.initialized|Zj.waitingForValue,valid:Zj.alive|Zj.initialized,removed:0},$j=class{constructor(e,t){this.registry=e,this.atom=t,this.writeContext=new rM(e,this)}registry;atom;state=Qj.uninitialized;lifetime;writeContext;preserveInitialValueOnBuild=!1;skipInitialRun=!1;keptParents;invalidatedDuringBuild=!1;failed=!1;parents=new Set;children=new Set;listeners=new Set;observedChildren=0;currentState(){switch(this.state){case Qj.uninitialized:return`uninitialized`;case Qj.stale:return`stale`;case Qj.valid:return`valid`;default:return`removed`}}get canBeRemoved(){return!this.atom.keepAlive&&this.listeners.size===0&&this.children.size===0&&this.state!==0}get building(){return this.lifetime!==void 0&&this.lifetime.reads!==void 0}get isObserved(){return!this.atom.lazy||this.listeners.size>0||this.observedChildren>0}childObserved(e){let t=this.isObserved;this.observedChildren+=e,t!==this.isObserved&&this.observedChanged(e)}observedChanged(e){for(let t of this.parents)t.childObserved(e)}_value=void 0;value(){for(;(this.state&Zj.waitingForValue)!==0;)this.build();return this._value}build(){let e=nM(this);try{this.disposeLifetime()}catch(t){e.failure=t}this.invalidatedDuringBuild=!1,this.lifetime=e;let t,n=!1;try{t=this.atom.read(e),n=!0}finally{let t=e.reads;e.reads=void 0,this.lifetime===e&&(this.dropUnread(t),n||this.fail())}if(this.lifetime===e&&(this.state&Zj.waitingForValue)!==0&&(this.preserveInitialValueOnBuild?(this.preserveInitialValueOnBuild=!1,this.skipInitialRun&&(this.keptParents=Array.from(this.parents,e=>[e,e.lifetime])),this.failed=!1,this.state=Qj.valid):this.setValue(t)),e.failure!==Kj)throw e.failure}fail(){this.failed=!0;try{this.invalidateChildren()}catch{}}readTracked(e,t){let n=this.registry.ensureNode(e);this.parents.has(n)||(this.parents.add(n),n.children.add(this),this.isObserved&&n.childObserved(1));try{return n.value()}catch(e){if(t.reads===void 0||n.state!==Qj.valid)throw e;return t.failure===Kj&&(t.failure=e),n._value}finally{t.reads!==void 0&&!t.disposed&&t.reads.add(n)}}dropUnread(e){if(e.size===this.parents.size)return;let t=this.isObserved;for(let n of this.parents)e.has(n)||(this.parents.delete(n),n.children.delete(this),t&&n.childObserved(-1),n.canBeRemoved&&this.registry.scheduleNodeRemoval(n))}valueOption(){return(this.state&Zj.initialized)===0?T():E(this._value)}setInitialValue(e,t=!1){(this.state&Zj.initialized)===0?(this.preserveInitialValueOnBuild=!0,this.skipInitialRun=t,this.state=Qj.stale,this._value=e,this.listeners.size>0&&this.announce()):this.setValue(e)}setValue(e){let t=this.failed;this.failed=!1;let n=(this.state&Zj.initialized)!==0;if(this.state=Qj.valid,n&&this.atom.equals(this._value,e)){t&&this.invalidateChildren();return}this._value=e;let r=Kj;try{(n||t)&&this.invalidateChildren()}catch(e){r=e}if(this.listeners.size>0)try{this.announce()}catch(e){r===Kj&&(r=e)}if(r!==Kj)throw r}announce(){aM.phase===iM.collect?aM.notify.add(this):this.notify()}invalidate(){if(this.state===Qj.valid){this.state=Qj.stale;try{this.disposeLifetime()}finally{this.propagate()}}else this.building&&aM.phase!==iM.collect?this.build():this.propagate()}propagate(){aM.phase===iM.collect?(this.building&&(this.invalidatedDuringBuild=!0),aM.stale.push(this)):this.isObserved?this.value():this.invalidateChildren()}invalidateChildren(){if(this.children.size===0)return;let e=Kj;for(let t of Array.from(this.children))if(t.affectedBy(this))try{t.invalidate()}catch(t){e===Kj&&(e=t)}if(e!==Kj)throw e}affectedBy(e){if(this.state===Qj.valid)return!0;let t=this.lifetime?.reads;return t===void 0?this.isObserved&&e.state===Qj.valid:t.has(e)}notify(){aM.phase===iM.commit&&aM.notify.delete(this),qj(this.listeners,Gj)}disposeLifetime(){let e=this.lifetime;e!==void 0&&(this.lifetime=void 0,e.dispose())}remove(){let e=this.isObserved;this.state=Qj.removed,this.listeners.clear();try{this.disposeLifetime()}finally{let t=Array.from(this.parents);this.parents.clear(),qj(t,t=>{t.children.delete(this),e&&t.childObserved(-1),t.canBeRemoved&&this.registry.removeNode(t)})}}subscribe(e){let t=this.isObserved;return this.listeners.add(e),t||this.observedChanged(1),()=>{this.listeners.delete(e)&&!this.isObserved&&this.observedChanged(-1)}}},eM=e=>{let t=e,n=t.node;if(!n.skipInitialRun)return!1;let r=n.keptParents;return n.skipInitialRun=!1,n.keptParents=void 0,!t.isFn&&!aj(n._value)&&(r===void 0||r.every(([e,t])=>e.lifetime===t))},tM={get registry(){return this.node.registry},addFinalizer(e){if(this.disposed)return e();this.finalizers??=[],this.finalizers.push(e)},get(e){return this.disposed?this.node.registry.get(e):this.node.readTracked(e,this)},result(e,t){if(this.disposed||this.isFn)return this.resultOnce(e,t);let n=this.get(e);if(t?.suspendOnWaiting&&n.waiting)return vh;switch(n._tag){case`Initial`:return vh;case`Failure`:return Ef(n.cause);case`Success`:return I(n.value)}},resultOnce(e,t){return _h(n=>{let r=this.once(e);if(r._tag!==`Initial`&&!(t?.suspendOnWaiting&&r.waiting))return n(xj(r));let i=this.node.registry.subscribe(e,e=>{e._tag===`Initial`||t?.suspendOnWaiting&&e.waiting||(i(),n(xj(e)))},{immediate:!1});return R(i)})},setResult(e,t){return this.disposed?vh:(this.node.registry.set(e,t),this.resultOnce(e,{suspendOnWaiting:!0}))},some(e){if(this.disposed||this.isFn)return this.someOnce(e);let t=this.get(e);return t._tag===`None`?vh:I(t.value)},someOnce(e){return _h(t=>{let n=this.once(e);if(wr(n))return t(I(n.value));let r=this.node.registry.subscribe(e,e=>{Cr(e)||(r(),t(I(e.value)))},{immediate:!1});return R(r)})},once(e){return this.node.registry.get(e)},self(){return this.disposed?T():this.node.valueOption()},refresh(e){this.disposed||this.node.registry.refresh(e)},refreshSelf(){this.disposed||this.node.invalidate()},mount(e){this.disposed||this.addFinalizer(this.node.registry.mount(e))},subscribe(e,t,n){this.disposed||this.addFinalizer(this.node.registry.subscribe(e,t,n))},setSelf(e){this.disposed||this.node.setValue(e)},set(e,t){this.disposed||this.node.registry.set(e,t)},stream(e,t){return this.disposed?my:py(n=>R(()=>{this.subscribe(e,e=>F_(n,e),{immediate:!t?.withoutInitialValue})}))},streamResult(e,t){return this.stream(e,t).pipe(Cy(oj),Sy(e=>e._tag===`Success`?I(e.value):bh(e.cause)))},dispose(){if(this.disposed=!0,this.finalizers===void 0)return;let e=this.finalizers;this.finalizers=void 0,qj(e.reverse(),Gj)}},nM=e=>{function t(n){return t.disposed||t.isFn?e.registry.get(n):e.readTracked(n,t)}return Object.setPrototypeOf(t,tM),t.isFn=!1,t.disposed=!1,t.finalizers=void 0,t.node=e,t.reads=new Set,t.failure=Kj,t},rM=class{constructor(e,t){this.registry=e,this.node=t}registry;node;get(e){return this.registry.get(e)}set(e,t){return this.registry.set(e,t)}setSelf(e){return this.node.setValue(e)}refreshSelf(){return this.node.invalidate()}},iM={disabled:0,collect:1,commit:2},aM={phase:iM.disabled,depth:0,stale:[],notify:new Set};function oM(e){let t=aM.phase;aM.phase=iM.collect,aM.depth++;let n=Kj;try{e()}catch(e){n=e}if(aM.depth===1){let{notify:e,stale:t}=aM,r=0;do{for(aM.phase=iM.collect;r<t.length;r++)try{sM(t[r])}catch(e){n===Kj&&(n=e)}aM.phase=iM.commit;for(let t of e)try{t.notify()}catch(e){n===Kj&&(n=e)}}while(r<t.length);aM.stale=[],e.clear()}if(aM.depth--,aM.phase=t,n!==Kj)throw n}function sM(e){if(e.state===Qj.valid){if(!e.invalidatedDuringBuild)return;e.invalidatedDuringBuild=!1,e.state=Qj.stale,e.disposeLifetime()}e.value()}var cM=`~effect/reactivity/Atom`,lM=e=>v(e,cM),uM=`~effect/reactivity/Atom/Writable`,dM=r(2,(e,t)=>{let n=Ha(t),r=$a(n);return Object.assign(Object.create(Object.getPrototypeOf(e)),{...e,keepAlive:!r,idleTTL:r?uo(n):void 0})}),fM=dM(0),pM={[cM]:cM,equals:Object.is,...Yt,toJSON(){return{_id:`Atom`,keepAlive:this.keepAlive,lazy:this.lazy,label:this.label}}},mM={...pM,atom(e,t){let n=SM(e,t);return vM(e=>{let t=e.self(),r=e(this);return r._tag===`Success`?n(e,r.value):gj(r,t)})},fn(e,t){return arguments.length===0?(e,t)=>hM(this,e,t):hM(this,e,t)},pull(e,t){let n=fM(TM(0));return HM(n,vM(r=>{let i=r.self(),a=r(this);return a._tag===`Success`?DM(r,VM(r,n,e,t),sj(!0),a.value):gj(a,i)}))},subscriptionRef(e){return FM(fM(vM(t=>{let n=t.self(),r=t(this);if(r._tag!==`Success`)return gj(r,n);let i=typeof e==`function`?e(t):e;return Nj(i)?i:DM(t,i,sj(!0),r.value)})),(e,t)=>PM(e,t,yj(e(this))))}},hM=(e,t,n)=>{let[r,i,a]=BM(n?.reactivityKeys?(e,r)=>{let i=t(e,r);return dh(i)?Dj(i,n.reactivityKeys):Ey(i,Oj(n.reactivityKeys))}:t,n);return yM(t=>{t.get(a);let n=t.self(),i=t.get(e);return i._tag===`Success`?r(t,i.value):gj(i,n)},i)},gM={...pM,[uM]:uM},_M=e=>uM in e,vM=(e,t)=>{let n=Object.create(pM);return n.keepAlive=!1,n.lazy=!0,n.read=e,n.refresh=t,n},yM=(e,t,n)=>{let r=Object.create(gM);return r.keepAlive=!1,r.lazy=!0,r.read=e,r.write=t,r.refresh=n,r};function bM(e,t){e.setSelf(t)}var xM=(e,t)=>{let n=SM(e,t);return`~effect/reactivity/Atom`in n?n:vM(n)},SM=(e,t)=>{if(typeof e==`function`&&!dh(e)&&!cy(e)){let n=e;return function(e,r){let i=n(e);switch(typeof i){case`function`:case`object`:return i===null?i:CM in i?EM(e,i,t,r):wM in i?MM(e,i,t,r):i;default:return i}}}return dh(e)?function(n,r){return EM(n,e,t,r)}:cy(e)?function(n,r){return MM(n,e,t,r)}:TM(e)},CM=`~effect/Effect`,wM=`~effect/Stream`,TM=e=>yM(function(t){return e},bM),EM=(e,t,n,r)=>DM(e,t,n?.initialValue===void 0?sj():lj(n.initialValue),r,n?.uninterruptible);function DM(e,t,n,r=aa(),i=!1){let o=e.self();if(o._tag===`Some`&&eM(e))return o.value;let s=typeof r==`function`?r:a(r),c=Kf();e.addFinalizer(()=>{wg(s())(OM(c))});let l,u=!1,d=kM(s().pipe(ca(Gf,c),ca(Hj,e.registry),ca(So,e.registry.scheduler)),t,function(t){u?e.setSelf(rj(t,e.self())):l=rj(t,o)},i);return u=!0,d!==void 0&&e.addFinalizer(d),l===void 0?o._tag===`Some`?ij(o):mj(n):l}var OM=e=>Mh(Zf(e,Af),e=>lf(e)?z:Bh(bh(e),{log:`Unhandled`,message:`Unhandled error in atom finalizer`}));function kM(e,t,n,r=!1){if(wf(t)){n(t);return}let i=wg(e)(t);i.currentDispatcher?.flush();let a=i.pollUnsafe();if(a){n(a);return}let o=i.addObserver(n);function s(){o(),r||i.interruptUnsafe()}return s}function AM(e){let t=e?.memoMap??fM(xM(()=>sp())),n=e=>lM(t)?e(t):t,r=kj;function i(e){let t=Object.create(mM);t.keepAlive=!1,t.lazy=!0,t.refresh=void 0,t.factory=i;let a=WM(vM(typeof e==`function`?e:()=>e));return t.layer=a,t.read=function(e){let t=Cp(e(a),r),i=aa();return DM(e,V(tg,r=>H(up(t,n(e),r),e=>(i=e,e))),sj(),()=>i,!0)},t}i.memoMap=t,i.addGlobalLayer=e=>{r=Cp(r,Sp(e,kj))};let a=fM(xM(e=>Yh(t=>up(kj,n(e),D(t,Gf))).pipe(H(D(wj)))));return i.withReactivity=e=>t=>GM(t,n=>{let r=yj(n(a));return n.addFinalizer(r.registerUnsafe(e,()=>{n.refresh(t)})),n.subscribe(t,e=>n.setSelf(e)),n.once(t)},{initialValueTarget:t}),i}var jM=AM();jM.withReactivity;var MM=(e,t,n,r)=>NM(e,t,n?.initialValue===void 0?sj():lj(n.initialValue),r);function NM(e,t,n,r=aa()){let i=e.self();if(i._tag===`Some`&&eM(e))return i.value;r=ca(r,Hj,e.registry);let a=rg(n=>V(ny(t.channel,n),t=>ph({while:o,body:()=>t,step(t){e.setSelf(lj(bi(t),{waiting:!0}))}}))).pipe(Mh(t=>(Pm(t)?u(e.self(),Fr(_j),Tr({onNone:()=>e.setSelf(pj(new _f,{previous:e.self()})),onSome:t=>e.setSelf(lj(t))})):e.setSelf(fj(t,{previous:e.self()})),z))),s=kM(r.pipe(ca(Hj,e.registry),ca(So,e.registry.scheduler)),a,l,!1);return s!==void 0&&e.addFinalizer(s),i._tag===`Some`?ij(i):mj(n)}var PM=(e,t,n=aa())=>Nj(t)?(e.addFinalizer(Pj(t).pipe(ky(t=>{for(let n=0;n<t.length;n++)e.setSelf(t[n]);return z}),Tg(n))),kg(n)(Fj(t))):t._tag===`Success`?NM(e,Pj(t.value),sj(!0),n):t,FM=(e,t)=>{function n(t,n){let r=t.get(e);Nj(r)?Og(Lj(r,n)):cj(r)&&Og(Lj(r.value,n))}return yM(n=>{let r=n(e);return Nj(r)||cj(r)?t(n,r):r},n)},IM=Symbol.for(`effect/reactivity/atom/Atom/Reset`),LM=Symbol.for(`effect/reactivity/atom/Atom/Interrupt`),RM=function(...e){return e.length===0?zM:zM(...e)},zM=(e,t)=>{let[n,r]=BM(e,t);return yM(n,r)};function BM(e,t){let n=fM(TM([0,void 0])),r=t?.initialValue===void 0?sj():lj(t.initialValue),i=t?.concurrent?fM(vM(e=>{let t=new Set;return e.addFinalizer(()=>t.forEach(e=>e.interruptUnsafe())),t})):void 0;function a(t,a){let o=i?t(i):void 0;t.isFn=!0;let[s,c]=t.get(n);if(s===0)return r;if(c===LM)return fj(af(),{previous:t.self()});let l=e(c,t);return CM in l?(o&&(l=V(Sg(l,{startImmediately:!0}),e=>{o.add(e);let t=Array.from(o);return e.addObserver(()=>o.delete(e)),H(Vg(t),e=>e[0])})),DM(t,l,r,a,!1)):NM(t,l,r,a)}function o(e,t){qM(()=>{t===IM?e.set(n,[0,void 0]):t===LM?e.set(n,[e.get(n)[0]+1,LM]):e.set(n,[e.get(n)[0]+1,t]),e.refreshSelf()})}return[a,o,n]}var VM=(e,t,n,r)=>V(Ay(typeof n==`function`?n(e):n),n=>{let i=Ug().context,a=ki(),o=qh(n,{onFailure(e){return Pm(e)?gi(a)?I({done:!0,items:a}):B(new _f(`Atom.pull: no items`)):bh(e)},onSuccess(e){let t;return r?.disableAccumulation?t=e:(t=pi(a,e),a=t),I({done:!1,items:t})}}),s=new Set;return e.addFinalizer(()=>{for(let e of s)e()}),e.once(t),e.subscribe(t,()=>{e.setSelf(ij(e.self()));let t;t=kM(i,o,n=>{t&&s.delete(t);let r=rj(n,e.self()),i=s.size>0;e.setSelf(i?mj(r):r)}),t&&s.add(t)}),o}),HM=(e,t)=>yM(t.read,function(t,n){t.set(e,t.get(e)+1)}),UM=typeof WeakRef>`u`||typeof FinalizationRegistry>`u`?e=>{let t=ih();return function(n){let r=ah(t,n);if(r._tag===`Some`)return r.value;let i=e(n);return ch(t,n,i),i}}:e=>{let t=ih(),n=new FinalizationRegistry(e=>{let n=ah(t,e);n._tag===`Some`&&n.value.deref()===void 0&&uh(t,e)});return function(r){let i=ah(t,r).pipe(Ir(e=>e.deref()));if(i._tag===`Some`)return i.value;let a=e(r);return ch(t,r,new WeakRef(a)),n.register(a,r),a}},WM=e=>Object.assign(Object.create(Object.getPrototypeOf(e)),{...e,keepAlive:!0}),GM=r(e=>lM(e[0]),(e,t,n)=>{let r=fM(_M(e)?yM(n=>t(n,e),function(t,n){t.set(e,n)},e.refresh??function(t){t(e)}):vM(n=>t(n,e),e.refresh??function(t){t(e)}));return n?.initialValueTarget&&(r.initialValueTarget=KM(n.initialValueTarget)),r}),KM=e=>{let t=e;for(;t.initialValueTarget;)t=t.initialValueTarget;return t},qM=oM,JM=`~effect-atom/atom/Atom/Serializable`,YM=r(2,(e,t)=>{let n=UO(t.schema);return Object.assign(Object.create(Object.getPrototypeOf(e)),{...e,label:e.label??[t.key,It()===0?``:Error().stack?.split(`
|
|
15
15
|
`)[5]??``],[JM]:{key:t.key,encode:vD(n),decode:mD(n),skipInitialRun:t.skipInitialRun}})}),XM=`~effect-atom/atom/Atom/ServerValue`,ZM=r(2,(e,t)=>`~effect-atom/atom/Atom/ServerValue`in e?e[XM](e=>t.get(e)):t.get(e)),QM=`~effect/socket/Socket`,$M=Hi(`effect/socket/Socket`),eN=e=>$M.of({[QM]:QM,reader:e.reader,writer:e.writer}),tN=new TextEncoder,nN=`~effect/socket/Socket/CloseEvent`,rN=e=>v(e,nN),iN=`~effect/socket/Socket/SocketError`,aN=e=>v(e,iN),oN=class extends VO(`effect/socket/Socket/SocketReadError`)({_tag:J(`SocketReadError`),cause:bO()}){message=`An error occurred during Read`},sN=class extends VO(`effect/socket/Socket/SocketWriteError`)({_tag:J(`SocketWriteError`),cause:bO()}){message=`An error occurred during Write`},cN=class extends VO(`effect/socket/Socket/SocketOpenError`)({_tag:J(`SocketOpenError`),kind:GD([`Unknown`,`Timeout`]),cause:bO()}){get message(){return this.kind===`Timeout`?`timeout waiting for "open"`:`An error occurred during Open`}},lN=class e extends VO(`effect/socket/Socket/SocketUpgradeError`)({_tag:J(`SocketUpgradeError`),cause:xD(bO())}){static unsupported=()=>B(new fN({reason:new e({})}));get message(){return this.cause===void 0?`Socket does not support TLS upgrade`:`An error occurred during TLS upgrade`}},uN=class extends VO(`effect/socket/Socket/SocketCloseError`)({_tag:J(`SocketCloseError`),code:fO,closeReason:xD(jD)}){get message(){return this.closeReason?`${this.code}: ${this.closeReason}`:`${this.code}`}},dN=WD([oN,sN,cN,lN,uN]),fN=class extends HO(iN)(`SocketError`,{_tag:J(`SocketError`),reason:dN}){constructor(e){`cause`in e.reason?super({...e,cause:e.reason.cause}):super(e)}[iN]=iN;static is(e){return aN(e)}message=this.reason.message},pN=(e,t)=>new fN({reason:new uN({code:e,closeReason:t})}),mN=class extends Hi()(`@effect/platform/Socket/WebSocketConstructor`){},hN=fp(mN)((e,t)=>{if(t!==void 0&&typeof t!=`string`&&!Array.isArray(t))throw TypeError(`WebSocket client options are not supported by the global WebSocket constructor`);return new globalThis.WebSocket(e,t)}),gN=(e,t)=>mN.use(n=>vN(ig((typeof e==`string`?I(e):e).pipe(H(e=>n(e,t?.headers===void 0?t?.protocols:{protocols:t.protocols,headers:t.headers}))),e=>R(()=>e.close(1e3))),t)),_N=e=>`pause`in e&&typeof e.pause==`function`,vN=(e,t)=>wh(n=>{let r,i=t_(!1),a=n.context,o=yh(function*(){let n=yield*tg,a=yield*qf(e,n);`binaryType`in a&&(a.binaryType=`arraybuffer`);let o=_N(a),s=t?.highWaterMark??(o?yN:void 0),c=a.readyState===1,u=o&&`isPaused`in a&&a.isPaused===!0,d=[],f=0,p,m,h;function g(){o&&!u&&(a.pause(),u=!0)}function ee(){o&&u&&(a.resume(),u=!1)}function _(){let e=d;return d=[],f=0,p===void 0&&ee(),e}function te(){if(m===void 0||d.length===0)return;let e=m;m=void 0,e(I(_()))}function ne(e){d.push(e),s!==void 0&&(f+=typeof e==`string`?tN.encode(e).byteLength:e.byteLength),m!==void 0&&te(),o&&f>=s?g():!o&&!m&&s!==void 0&&f>s&&re(new fN({reason:new oN({cause:Error(`Socket highWaterMark of ${s} bytes exceeded`)})}))}function re(e){if(p===void 0&&(p=e),h!==void 0){let{cleanup:e,resume:t}=h;h=void 0,e(),t(B(p))}if(m!==void 0){let e=m;m=void 0,e(d.length>0?I(_()):B(p))}}function ie(e){let t=e.data;typeof Blob<`u`&&t instanceof Blob?t.arrayBuffer().then(e=>ne(new Uint8Array(e)),e=>{re(new fN({reason:new oN({cause:e})}))}):ne(t instanceof ArrayBuffer?new Uint8Array(t):t)}function ae(e){re(new fN({reason:c?new oN({cause:e}):new cN({kind:`Unknown`,cause:e})}))}function oe(e){re(pN(typeof e.code==`number`?e.code:1006,e.reason))}return a.addEventListener(`message`,ie),a.addEventListener(`error`,ae,{once:!0}),a.addEventListener(`close`,oe,{once:!0}),yield*Yf(n,R(()=>{if(re(pN(1006)),a.removeEventListener(`message`,ie),a.addEventListener(`error`,l),a.removeEventListener(`error`,ae),a.removeEventListener(`close`,oe),o)try{ee()}catch{}i.closeUnsafe(),r=void 0})),a.readyState>=2?yield*B(p??pN(1006)):(c||=(yield*_h(e=>{let t=()=>{h?.resume===e&&(h=void 0,a.removeEventListener(`open`,t),e(z))},n=()=>a.removeEventListener(`open`,t);return h={resume:e,cleanup:n},a.addEventListener(`open`,t,{once:!0}),R(()=>{h?.resume===e&&(h=void 0),n()})}).pipe(Hh({duration:t?.openTimeout??1e4,orElse:()=>B(new fN({reason:new cN({kind:`Timeout`,cause:Error(`timeout waiting for "open"`)})}))})),!0),p===void 0&&f<s&&ee(),r=a,i.openUnsafe(),{pull:_h(e=>d.length>0?e(I(_())):p===void 0?(m=e,R(()=>{m===e&&(m=void 0)})):e(B(p))),upgrade:lN.unsupported})}).pipe($h(e=>_a(a,e))),s=e=>L(()=>{let t=r;if(t===void 0)return i.whenOpen(s(e));try{return rN(e)?t.close(e.code,e.reason):t.send(e),z}catch(e){return B(new fN({reason:new sN({cause:e})}))}}),c=e=>L(()=>{let t=r;if(t===void 0)return i.whenOpen(c(e));try{for(let n=0;n<e.length;n++)t.send(e[n]);return z}catch(e){return B(new fN({reason:new sN({cause:e})}))}});return I(eN({reader:o,writer:I({write:s,writeAll:c})}))}),yN=65536,bN=d(gN,gp($M)),xN=class extends Hi()(`effect/workers/Transferable/Collector`){},SN=()=>{let e=[],t=t=>{e.push(...t)},n=()=>e,r=()=>{let t=e;return e=[],t};return xN.of({addAllUnsafe:t,addAll:e=>R(()=>t(e)),readUnsafe:n,read:R(n),clearUnsafe:r,clear:R(r)})},CN=WD([class extends VO(`effect/workers/WorkerError/WorkerSpawnError`)({_tag:J(`WorkerSpawnError`),message:jD,cause:xD(bO())}){},class extends VO(`effect/workers/WorkerError/WorkerSendError`)({_tag:J(`WorkerSendError`),message:jD,cause:xD(bO())}){},class extends VO(`effect/workers/WorkerError/WorkerReceiveError`)({_tag:J(`WorkerReceiveError`),message:jD,cause:xD(bO())}){},class extends VO(`effect/workers/WorkerError/WorkerUnknownError`)({_tag:J(`WorkerUnknownError`),message:jD,cause:xD(bO())}){}]),wN=(e,t)=>e===void 0?t:`${e}.${t}`,TN=(e,t)=>({"rpc.system.name":`effect_rpc`,"rpc.method":e,...t}),EN=`~effect/PrimaryKey`,DN=`~effect/rpc/RpcSchema/StreamSchema`;function ON(e){return v(e,DN)}function kN(e){return ON(e)?E({success:e.success,error:e.error}):T()}var AN=tD(cy);function jN(e,t){return K(AN.ast,{[DN]:DN,success:e,error:t})}var MN=`~effect/rpc/Rpc`,NN={[MN]:MN,pipe(){return e(this,arguments)},setSuccess(e){return PN({_tag:this._tag,payloadSchema:this.payloadSchema,successSchema:e,errorSchema:this.errorSchema,defectSchema:this.defectSchema,annotations:this.annotations,middlewares:this.middlewares})},setError(e){return PN({_tag:this._tag,payloadSchema:this.payloadSchema,successSchema:this.successSchema,errorSchema:e,defectSchema:this.defectSchema,annotations:this.annotations,middlewares:this.middlewares})},setPayload(e){return PN({_tag:this._tag,payloadSchema:yD(e)?e:q(e),successSchema:this.successSchema,errorSchema:this.errorSchema,defectSchema:this.defectSchema,annotations:this.annotations,middlewares:this.middlewares})},middleware(e){return PN({_tag:this._tag,payloadSchema:this.payloadSchema,successSchema:this.successSchema,errorSchema:this.errorSchema,defectSchema:this.defectSchema,annotations:this.annotations,middlewares:new Set([...this.middlewares,e])})},prefix(e){return PN({_tag:`${e}${this._tag}`,payloadSchema:this.payloadSchema,successSchema:this.successSchema,errorSchema:this.errorSchema,defectSchema:this.defectSchema,annotations:this.annotations,middlewares:this.middlewares})},annotate(e,t){return PN({_tag:this._tag,payloadSchema:this.payloadSchema,successSchema:this.successSchema,errorSchema:this.errorSchema,defectSchema:this.defectSchema,middlewares:this.middlewares,annotations:ca(this.annotations,e,t)})},annotateMerge(e){return PN({_tag:this._tag,payloadSchema:this.payloadSchema,successSchema:this.successSchema,errorSchema:this.errorSchema,defectSchema:this.defectSchema,middlewares:this.middlewares,annotations:_a(this.annotations,e)})}},PN=e=>{function t(){}return Object.setPrototypeOf(t,NN),Object.assign(t,e),t.key=`effect/rpc/Rpc/${e._tag}`,t},FN=(e,t)=>{let n=t?.success??FD,r=t?.error??OD,i=t?.defect??bO(),a;return a=t?.primaryKey?class extends BO(`effect/rpc/Rpc/${e}`)(t.payload){[EN](){return t.primaryKey(this)}}:yD(t?.payload)?t?.payload:t?.payload?q(t?.payload):FD,PN({_tag:e,payloadSchema:a,successSchema:t?.stream?jN(n,r):n,errorSchema:t?.stream?OD:r,defectSchema:i,annotations:aa(),middlewares:new Set})},IN=new WeakMap,LN=e=>{if(IN.has(e))return IN.get(e);let t=e,n=new Set([t.errorSchema]),r=kN(t.successSchema);wr(r)&&n.add(r.value.error);for(let e of t.middlewares)n.add(e.error);let i=AO(wr(r)?FD:t.successSchema,WD([...n]),t.defectSchema);return IN.set(e,i),i},RN=O(`effect/rpc/Rpc/ParseOptions`,{defaultValue:()=>wC}),zN=`~effect/rpc/Rpc/Wrapper`,BN=e=>zN in e,VN=`~effect/rpc/RpcClientError`,HN=class extends VO(`effect/rpc/RpcClientError/RpcClientDefect`)({_tag:J(`RpcClientDefect`),message:jD,cause:bO()}){},UN=class extends VO(VN)({_tag:J(`RpcClientError`),reason:WD([CN,dN,Gk,HN])}){[VN]=VN;get message(){return`${this.reason._tag}: ${this.reason.message}`}},WN=e=>e,GN={_tag:`Ping`},KN=WD([jD,MD]),qN=WD([q({_tag:J(`Request`),id:KN,tag:jD,payload:wO,headers:VD(BD([jD,jD])),isNotification:xD(DD(!0)),discard:xD(DD(!0)),traceId:xD(jD),spanId:xD(jD),sampled:xD(ND)}),q({_tag:J(`Ack`),requestId:KN}),q({_tag:J(`Interrupt`),requestId:KN}),q({_tag:J(`Ping`)}),q({_tag:J(`Eof`)}),q({_tag:J(`Chunk`),requestId:KN,values:wO}),q({_tag:J(`Exit`),requestId:KN,exit:wO}),q({_tag:J(`Defect`),defect:wO}),q({_tag:J(`Pong`)})]),JN=new WeakMap,YN=new WeakMap,XN=new WeakMap,ZN=new WeakMap;function QN(e,t){let n=t?.fingerprint===!0?YN:JN,r=n.get(e);if(r!==void 0)return r;let{exact:i,layout:a,recursive:o,target:s}=tR(e),c=$L(a,t?.fingerprint),l=i?{value:void 0}:void 0,u=eP(l===void 0?s:aR(s,l,!o),a,c,l);return n.set(e,u),u}function $N(e,t){let n=t?.fingerprint===!0?ZN:XN,r=n.get(e);if(r!==void 0)return r;let{exact:i,exitSuccess:a,layout:o,target:s}=tR(e);if(!i){if(!a)return QN(e,t);let r={value:void 0},i=eP(sR(s,r),o,$L(o,t?.fingerprint),r,!0);return n.set(e,i),i}let c=eP(cR(s),o,$L(o,t?.fingerprint),void 0);return n.set(e,c),c}function eP(e,t,n,r,i=!1){return wO.pipe(JD(e,ZL(t,n,r,i)))}function tP(e,t){let{exact:n,exitSuccess:r,layout:i}=tR(e),a=$L(i,t?.fingerprint),o=t??wC;if(!n||o.onExcessProperty===`error`){let n=_D(QN(e,t),t);return!r||o.onExcessProperty===`error`?n:e=>{if(!hL(e))return n(e);try{return mL(i,e,o,a)}catch(e){throw e instanceof sF?new rD(e.issue):e}}}return e=>{try{return mL(i,e,o,a)}catch(e){throw e instanceof sF?new rD(e.issue):e}}}function nP(e,t){let{exact:n,layout:r}=tR(e),i=t??wC;if(!n||i.onExcessProperty===`error`){let n=tP(e,t);return e=>rP(e.map(n))}let a=$L(r,t?.fingerprint);return e=>{try{return pL(r,e,i,a)}catch(e){throw e instanceof sF?new rD(e.issue):e}}}function rP(e){return e.length===1?e[0]:ZE(e)}function iP(e,t){let{exact:n,exitSuccess:r,layout:i,target:a}=tR(e),o=t??wC,s=n?void 0:pD(a,o),c=s!==void 0&&r?e=>hL(e)?e:s(e):s;return sP(i,$L(i,t?.fingerprint),o,t?.maxFrameSize,c,aP(n,t))}function aP(e,t){if(t?.dictionary!==!0)return!1;if(!e)throw Error(`Binary layout: dictionary needs a schema the binary layer validates on its own`);return!0}function oP(e,t){let{exact:n,layout:r,target:i}=tR(e),a=aP(n,t),o=tP(e,t),s=nP(e,t);if(!a)return{encode:o,encodeMany:s};let c=$L(r,t?.fingerprint),l=t??wC,u=l.onExcessProperty===`error`?_D(i,t):void 0,d=HI(),f=e=>{try{return e()}catch(e){throw e instanceof sF?new rD(e.issue):e}};return{encode:e=>f(()=>mL(r,u===void 0?e:u(e),l,c,d)),encodeMany:e=>f(()=>pL(r,u===void 0?e:e.map(u),l,c,d))}}function sP(e,t,n,r,i,a){let o=a?[]:void 0,s=new Uint8Array,c=0,l=0,u,d=!1,f=new DF,p=new CF(n,hF),m=()=>{f.release(),p.clear(),s=TF,c=l=0},h=(e,t)=>{throw new rD(new sS({expected:e},t,n))},g=()=>{let e=u;throw u=void 0,e},ee=(e,t)=>{let n=e.length-t;n>s.length&&(s=new Uint8Array(Math.max(256,n))),s.set(t===0?e:e.subarray(t),0),c=0,l=n},_={feedSync(a){if(u!==void 0)return g();if(d)return h(`parser is spent`);let _=l===c,te,ne,re;if(_)te=a,ne=0,re=a.length;else{if(a.length>0){let e=l-c,t=e+a.length;if(t>s.length){let n=new Uint8Array(Math.max(256,s.length*2,t));n.set(s.subarray(c,l)),s=n,c=0,l=e}else c>0&&(s.copyWithin(0,c,l),c=0,l=e);s.set(a,l),l+=a.length}te=s,ne=c,re=l}let ie=[],ae=()=>(_?ne<re&&ee(a,ne):(c=ne,c===l&&(c=l=0)),ie),oe=(e,t)=>{d=!0;let r=new rD(new sS({expected:e},t,n));if(m(),ie.length===0)throw r;return u=r,ie};for(;;){let a=0,s=-1,c=re-ne,l=1;for(let e=0;e<Math.min(6,c);e++){let t=te[ne+e];if(a+=(t&127)*l,!(t&128)){s=e+1;break}l*=128}if(s===-1){if(c<6)return ae();let e=BigInt(a);for(let t=6;t<Math.min(10,c);t++){let n=te[ne+t];if(e|=BigInt(n&127)<<BigInt(t*7),!(n&128)){if(s=t+1,e>gP)return oe(`safe integer length`,e);a=Number(e);break}}if(s===-1)return c>=10?oe(`uvarint`,te.subarray(ne,ne+10)):ae()}if(a===0)return oe(`nonzero frame length`,a);if(r!==void 0&&a>r)return oe(`frame within maxFrameSize`,a);if(s+a>c)return ae();let h=Q;try{Q=0;let r=ne+s;p.beginFrame(),f.reset(te,r,r+a,n,p,t,o);let c=JL(e,f,t);ie.push(i===void 0?c:i(c))}catch(e){d=!0,m();let t=e instanceof sF?new rD(e.issue):iD(e)?e:(()=>{throw e})();if(ie.length===0)throw t;return u=t,ie}finally{Q=h}ne+=s+a}},endSync(){if(u!==void 0)return g();if(d)return h(`parser is spent`);d=!0;let e=c<l?s.subarray(c,l):void 0;if(m(),e!==void 0)return h(`complete value`,e)},feed:e=>L(()=>{try{return I(_.feedSync(e))}catch(e){if(iD(e))return B(e);throw e}}),end:L(()=>{try{return _.endSync(),z}catch(e){if(iD(e))return B(e);throw e}})};return _}var cP=`~effect/encoding/SchemaBinary/fieldId`,lP=`~effect/encoding/SchemaBinary/fixedWidth`,uP=BigInt(`-9223372036854775808`),dP=BigInt(`9223372036854775807`),fP=BigInt(`18446744073709551615`);function pP(e){let t=e.checks;if(t!==void 0)for(let e of t){let t=e.annotations?.[lP];if(t!==void 0)return t}}var mP=32,hP=33,gP=BigInt(2**53-1),_P=BigInt(0),vP=BigInt(1),yP=BigInt(2),bP=BigInt(7),xP=BigInt(127),SP=BigInt(1e6),CP=BigInt(255),wP=BigInt(4294967295),TP=BigInt(32),EP=new TextEncoder,DP=new TextDecoder(`utf-8`,{fatal:!0,ignoreBOM:!0}),OP=7,kP=0xffffffffffff,AP=0xfffffffffffff,jP=0,MP=1,NP=2,PP=512,FP=1048576,IP=4194304,LP=0,RP=1,zP=2,BP=3,VP=4,HP=5,UP=6,WP=7,GP=8;function KP(e){return typeof e==`number`&&Number.isInteger(e)&&e>=-0xffffffffffff&&e<=kP}var qP=8,JP=2199023255551,YP=[1,10,100,1e3,1e4,1e5,1e6,1e7,1e8];function XP(e){for(let t=1;t<=qP;t++){let n=Math.round(e*YP[t]);if(!(n>=-2199023255551&&n<=JP))return 0;if(n/YP[t]===e)return t}return 0}function ZP(e){let t=Math.floor(e/2);return e%2==1?-t:t}var Y={bool:1,null:2,undefined:3,number:4,string:5,bytes:6,bigint:7,int64:8,struct:9,variant:10,array:11,option:12,result:13,duration:14,bigDecimal:15,dateTimeZoned:16,json:17,exit:18,cause:19,causeReason:20};function QP(e){let t=2166136261;for(let n=0;n<e.length;n++)t=Math.imul(t^e[n],16777619);return t>>>0}var $P=BigInt(`14695981039346656037`),eF=BigInt(`1099511628211`),tF=BigInt(`18446744073709551615`);function nF(e){let t=$P;for(let n=0;n<e.length;n++)t=(t^BigInt(e[n]))*eF&tF;return t}function rF(e,t){for(let n=0;n<t.length;n++)e.push(t[n])}function iF(e,t){for(;t>127;)e.push(t&127|128),t=Math.floor(t/128);e.push(t)}function aF(e,t){e.push(t&255,t>>>8&255,t>>>16&255,t>>>24&255)}function oF(e,t){for(let n=0;n<8;n++)e.push(Number(t>>BigInt(n*8)&CP))}var sF=class extends Error{issue;constructor(e){super(`SchemaBinary failure`),this.issue=e}};function X(e,t,n){throw cF(new sS({expected:e},t,n))}var Z=[],Q=0;function cF(e){return new sF(Q===0?e:new nS(Z.slice(0,Q),e))}function lF(e){let t=new Uint8Array(uF(e)),n=0;for(;e>127;)t[n++]=e&127|128,e=Math.floor(e/128);return t[n]=e,t}function uF(e){let t=1;for(;e>127;)e=Math.floor(e/128),t++;return t}var dF=32;function fF(e,t,n,r){let i=n-t;if(i===0)return``;if(i<=dF){let r=pF(e,t,n);if(r!==void 0)return r}try{return DP.decode(e.subarray(t,n))}catch{X(`utf-8`,void 0,r)}}function pF(e,t,n){let r=``,i=t;for(;i+16<=n;i+=16){let t=e[i],n=e[i+1],a=e[i+2],o=e[i+3],s=e[i+4],c=e[i+5],l=e[i+6],u=e[i+7],d=e[i+8],f=e[i+9],p=e[i+10],m=e[i+11],h=e[i+12],g=e[i+13],ee=e[i+14],_=e[i+15];if((t|n|a|o|s|c|l|u|d|f|p|m|h|g|ee|_)>127)return;r+=String.fromCharCode(t,n,a,o,s,c,l,u,d,f,p,m,h,g,ee,_)}if(i+8<=n){let t=e[i],n=e[i+1],a=e[i+2],o=e[i+3],s=e[i+4],c=e[i+5],l=e[i+6],u=e[i+7];if((t|n|a|o|s|c|l|u)>127)return;r+=String.fromCharCode(t,n,a,o,s,c,l,u),i+=8}switch(n-i){case 0:return r;case 1:{let t=e[i];return t>127?void 0:r+String.fromCharCode(t)}case 2:{let t=e[i],n=e[i+1];return(t|n)>127?void 0:r+String.fromCharCode(t,n)}case 3:{let t=e[i],n=e[i+1],a=e[i+2];return(t|n|a)>127?void 0:r+String.fromCharCode(t,n,a)}case 4:{let t=e[i],n=e[i+1],a=e[i+2],o=e[i+3];return(t|n|a|o)>127?void 0:r+String.fromCharCode(t,n,a,o)}case 5:{let t=e[i],n=e[i+1],a=e[i+2],o=e[i+3],s=e[i+4];return(t|n|a|o|s)>127?void 0:r+String.fromCharCode(t,n,a,o,s)}case 6:{let t=e[i],n=e[i+1],a=e[i+2],o=e[i+3],s=e[i+4],c=e[i+5];return(t|n|a|o|s|c)>127?void 0:r+String.fromCharCode(t,n,a,o,s,c)}default:{let t=e[i],n=e[i+1],a=e[i+2],o=e[i+3],s=e[i+4],c=e[i+5],l=e[i+6];return(t|n|a|o|s|c|l)>127?void 0:r+String.fromCharCode(t,n,a,o,s,c,l)}}}var mF=65536,hF=256,gF=512,_F=16384;function vF(e){let t=new Uint8Array(e);return{buf:t,view:new DataView(t.buffer),offset:0,writing:!1}}var yF=vF(mF),bF=class{buf=new Uint8Array;view=new DataView(this.buf.buffer);arena;start=0;limit=0;len=0;reset(){let e=yF;(e.writing||e.offset>=e.buf.length)&&(e=yF=vF(mF)),e.writing=!0,this.arena=e,this.buf=e.buf,this.view=e.view,this.start=e.offset,this.limit=e.buf.length-e.offset,this.len=0}ensure(e){if(this.len+e>this.limit){let t=this.arena,n=this.len+e,r=mF;for(;r<n;)r*=2;let i=vF(r);i.writing=!0,i.buf.set(this.buf.subarray(this.start,this.start+this.len)),t.writing=!1,this.arena=yF=i,this.buf=i.buf,this.view=i.view,this.start=0,this.limit=i.buf.length}}byte(e){this.ensure(1),this.buf[this.start+this.len++]=e}bytes(e){this.ensure(e.length),this.buf.set(e,this.start+this.len),this.len+=e.length}uvarint(e){this.ensure(10);let t=this.buf,n=this.start+this.len;if(e<128)t[n++]=e;else if(t[n++]=e&127|128,e<16384)t[n++]=e>>>7;else{for(t[n++]=e>>>7&127|128,e=Math.floor(e/16384);e>127;)t[n++]=e&127|128,e=Math.floor(e/128);t[n++]=e}this.len=n-this.start}uvarintBig(e){for(;e>xP;)this.byte(Number(e&xP)|128),e>>=bP;this.byte(Number(e))}zigzag(e){this.uvarintBig(e>=_P?e<<vP:(-e<<vP)-vP)}numberVarint(e){let t=e<0||e===0&&1/e<0,n=t?-e:e;n<=AP?this.uvarint(n*2+ +!!t):this.uvarintBig(BigInt(n)*yP+(t?vP:_P))}f64(e){this.ensure(8),this.view.setFloat64(this.start+this.len,e,!0),this.len+=8}i64(e){this.ensure(8),this.view.setBigInt64(this.start+this.len,e,!0),this.len+=8}u64(e){this.ensure(8),this.view.setBigUint64(this.start+this.len,e,!0),this.len+=8}u32le(e){this.ensure(4),this.view.setUint32(this.start+this.len,e>>>0,!0),this.len+=4}i32le(e){this.ensure(4),this.view.setInt32(this.start+this.len,e|0,!0),this.len+=4}idAndMark(e){let t=e.length;this.ensure(t+1);let n=this.buf,r=this.start+this.len;for(let i=0;i<t;i++)n[r++]=e[i];let i=r-this.start;return this.len=i+1,i}beginSized(){return this.ensure(1),this.len++}endSized(e){let t=this.len-e-1;t<128?this.buf[this.start+e]=t:this.growSized(e,t)}endSizedRun(e){let t=(this.len-e-1)*2;t<128?this.buf[this.start+e]=t:this.growSized(e,t)}growSized(e,t){let n=uF(t),r=n-1;this.ensure(r);let i=this.start+e;this.buf.copyWithin(i+n,i+1,this.start+this.len),this.len+=r;let a=t,o=i;for(;a>127;)this.buf[o++]=a&127|128,a=Math.floor(a/128);this.buf[o]=a}string(e){let t=e.length;if(t===0)return;this.ensure(t*3);let n=this.buf,r=this.start+this.len,i=0;for(;i+4<=t;i+=4){let t=e.charCodeAt(i),a=e.charCodeAt(i+1),o=e.charCodeAt(i+2),s=e.charCodeAt(i+3);if((t|a|o|s)>127){this.len+=EP.encodeInto(e,n.subarray(this.start+this.len)).written;return}n[r++]=t,n[r++]=a,n[r++]=o,n[r++]=s}for(;i<t;i++){let t=e.charCodeAt(i);if(t>127){this.len+=EP.encodeInto(e,n.subarray(this.start+this.len)).written;return}n[r++]=t}this.len=r-this.start}out(){let e=this.arena,t=new Uint8Array(e.buf.buffer,this.start,this.len);return e===yF&&(e.offset=this.start+this.len),e.writing=!1,this.arena=void 0,t}abort(){let e=this.arena;e!==void 0&&(e===yF&&(e.offset=this.start),e.writing=!1,this.arena=void 0)}};function xF(e){let t=pT(e);return t._tag===`String`&&t.checks===void 0}function SF(e,t,n){return e.extra.find(e=>ZC({[t]:null},e.parameter,n).length>0)}var CF=class{entries=new WeakMap;orderLayouts;orderKeys;options;size=0;next=0;replace=!1;constructor(e,t){this.options=e,this.orderLayouts=t===void 0?void 0:Array(t),this.orderKeys=t===void 0?void 0:Array(t)}beginFrame(){this.replace=!0}find(e,t){let n=this.entries.get(e);if(n===void 0&&(n=new Map,this.entries.set(e,n)),n.has(t))return n.get(t);let r=SF(e,t,this.options),i=this.orderLayouts;if(i===void 0)return n.set(t,r),r;let a=this.orderKeys;if(this.size<i.length)i[this.size]=e,a[this.size]=t,this.size++,n.set(t,r);else if(this.replace){this.replace=!1;let o=i[this.next];(o===e?n:this.entries.get(o))?.delete(a[this.next]),i[this.next]=e,a[this.next]=t,this.next=(this.next+1)%i.length,n.set(t,r)}return r}clear(){this.entries=new WeakMap,this.orderLayouts?.fill(void 0),this.orderKeys?.fill(void 0),this.size=this.next=0,this.replace=!1}},wF=new ArrayBuffer(0),TF=new Uint8Array(wF),EF=new DataView(wF),DF=class{pos=0;nesting=0;buf=TF;view;viewCache=EF;viewBuffer=wF;viewOffset=0;viewLength=0;end=0;options=wC;indexSignatures;positional=!1;rejectUnknownFields=!1;intern;dict;reset(e,t,n,r,i,a,o){this.nesting=0,this.view=void 0,this.buf=e,this.pos=t,this.end=n,this.options=r,this.indexSignatures=i,this.positional=a.positional,this.rejectUnknownFields=a.rejectUnknownFields,this.intern=void 0,this.dict=o}release(){this.pos=this.end=this.nesting=0,this.buf=TF,this.view=void 0,this.viewCache=EF,this.viewBuffer=wF,this.viewOffset=this.viewLength=0,this.options=wC,this.indexSignatures=void 0,this.positional=!1,this.rejectUnknownFields=!1,this.intern=void 0,this.dict=void 0}get remaining(){return this.end-this.pos}dataView(){let e=this.buf;return(e.buffer!==this.viewBuffer||e.byteOffset!==this.viewOffset||e.byteLength!==this.viewLength)&&(this.viewBuffer=e.buffer,this.viewOffset=e.byteOffset,this.viewLength=e.byteLength,this.viewCache=new DataView(e.buffer,e.byteOffset,e.byteLength)),this.view=this.viewCache}byte(){return this.pos>=this.end&&X(`complete value`,void 0,this.options),this.buf[this.pos++]}take(e){this.pos+e>this.end&&X(`complete value`,void 0,this.options);let t=this.buf.subarray(this.pos,this.pos+e);return this.pos+=e,t}takeCopy(e){this.pos+e>this.end&&X(`complete value`,void 0,this.options);let t=this.buf.slice(this.pos,this.pos+e);return this.pos+=e,t}enter(e){this.pos+e>this.end&&X(`complete value`,void 0,this.options);let t=this.end;return this.end=this.pos+e,t}exit(e){this.pos=this.end,this.end=e}readUtf8(e){this.pos+e>this.end&&X(`complete value`,void 0,this.options);let t=this.pos;return this.pos+=e,fF(this.buf,t,t+e,this.options)}uvarint(){let e=this.buf,t=this.end,n=this.pos;n>=t&&X(`complete value`,void 0,this.options);let r=e[n++];if(r<128)return this.pos=n,r;let i=r&127;if(n>=t&&X(`complete value`,void 0,this.options),r=e[n++],i|=(r&127)<<7,r<128||(n>=t&&X(`complete value`,void 0,this.options),r=e[n++],i|=(r&127)<<14,r<128)||(n>=t&&X(`complete value`,void 0,this.options),r=e[n++],i|=(r&127)<<21,r<128))return this.pos=n,i;let a=268435456;for(let o=4;o<10;o++){n>=t&&(this.pos=n,X(`complete value`,void 0,this.options)),r=e[n++];let o=(r&127)*a;if(o>2**53-1-i&&(this.pos=n,X(`safe integer length`,void 0,this.options)),i+=o,r<128)return this.pos=n,i;a*=128}this.pos=n,X(`uvarint`,void 0,this.options)}fieldTag(){let e=this.buf,t=this.end,n=this.pos;n>=t&&X(`complete value`,void 0,this.options);let r=e[n++];if(r<128)return this.pos=n,r;let i=r&127;return n>=t&&X(`complete value`,void 0,this.options),r=e[n++],i|=(r&127)<<7,r<128||(n>=t&&X(`complete value`,void 0,this.options),r=e[n++],i|=(r&127)<<14,r<128)||(n>=t&&X(`complete value`,void 0,this.options),r=e[n++],i|=(r&127)<<21,r<128)?(this.pos=n,i):(n>=t&&X(`complete value`,void 0,this.options),r=e[n++],this.pos=n,r>=128&&X(`uvarint`,void 0,this.options),i+r*268435456)}uvarintBig(){let e=_P,t=_P;for(;;){let n=this.byte();if(e|=BigInt(n&127)<<t,!(n&128))return e;t+=bP}}numberVarint(){let e=this.buf,t=this.end,n=this.pos,r=0,i=1;for(let a=0;a<OP;a++){n>=t&&(this.pos=n,X(`complete value`,void 0,this.options));let a=e[n++];if(r+=(a&127)*i,a<128)return this.pos=n,ZP(r);i*=128}let a=this.uvarintBig(),o=Number(a>>vP);return Number.isFinite(o)||X(`safe integer length`,void 0,this.options),(a&vP)===vP?-o:o}zigzag(){let e=this.uvarintBig();return(e&vP)===vP?-(e+vP>>vP):e>>vP}f64(){this.pos+8>this.end&&X(`complete value`,void 0,this.options);let e=(this.view??this.dataView()).getFloat64(this.pos,!0);return this.pos+=8,e}i64(){this.pos+8>this.end&&X(`complete value`,void 0,this.options);let e=(this.view??this.dataView()).getBigInt64(this.pos,!0);return this.pos+=8,e}u64(){this.pos+8>this.end&&X(`complete value`,void 0,this.options);let e=(this.view??this.dataView()).getBigUint64(this.pos,!0);return this.pos+=8,e}u32le(){this.pos+4>this.end&&X(`complete value`,void 0,this.options);let e=(this.view??this.dataView()).getUint32(this.pos,!0);return this.pos+=4,e}i32le(){this.pos+4>this.end&&X(`complete value`,void 0,this.options);let e=(this.view??this.dataView()).getInt32(this.pos,!0);return this.pos+=4,e}};function OF(e,t){return{_:`literal`,leaf:e,values:t,valueSet:t.length>4?new Set(t):void 0}}function kF(e,t){let n=e.values;return e.valueSet===void 0?n.length===1?t===n[0]:n.includes(t):e.valueSet.has(t)}function AF(e){return e.values.map(e=>typeof e==`string`?JSON.stringify(e):String(e)).join(` | `)}var jF=0,MF=1,NF=2,PF=3,FF=30,IF=1<<FF;function LF(e){return e._===`literal`?LF(e.leaf):e._===`int`}function RF(e){switch(e._){case`literal`:return RF(e.leaf);case`bool`:return 1;case`i32`:case`u32`:return 4;case`int64`:case`i64`:case`u64`:return 8;default:return}}function zF(e){return RF(e)!==void 0||LF(e)||e._===`null`||e._===`undefined`}function BF(e){return e._===`literal`?BF(e.leaf):e._===`null`||e._===`undefined`}var VF={"effect/schema/Date":{kind:Y.int64,exact:!0},"effect/schema/DateTimeUtc":{kind:Y.int64,exact:!0},"effect/schema/DateTimeZoned":{kind:Y.dateTimeZoned,exact:!0},"effect/schema/Duration":{kind:Y.duration,exact:!0},"effect/schema/BigDecimal":{kind:Y.bigDecimal,exact:!0},"effect/schema/Uint8Array":{kind:Y.bytes,exact:!0},"effect/schema/Option":{kind:Y.option,exact:`parameters`},"effect/schema/Result":{kind:Y.result,exact:`parameters`},"effect/schema/Exit":{kind:Y.exit,exact:`parameters`},"effect/schema/Cause":{kind:Y.cause,exact:`parameters`},"effect/schema/CauseReason":{kind:Y.causeReason,exact:`parameters`}};function HF(e){let t=e.annotations?.representation;return _e(t)&&typeof t.id==`string`?t.id:void 0}var UF=Zw(e=>{let t=WF(e),n=e.context;return t===e||n===void 0?t:Yw(t,new TC(n.isOptional,n.isMutable,void 0,n.annotations))});function WF(e){switch(e._tag){case`Declaration`:{let t=HF(e);if(t!==void 0&&(t in VF||t===`effect/schema/Json`||t===`effect/schema/MutableJson`))return e.recur(UF);let n=e.annotations?.toCodecJson,r=e.annotations?.toCodec;if(!le(n)&&!le(r))return e;let i=e.typeParameters.map(e=>K(pT(e))),a=(le(n)?n(i):void 0)??(le(r)?r(i):void 0);return a===void 0?e:G(e,[Kw(a,UF)])}case`Arrays`:case`Objects`:case`Union`:case`Suspend`:return e.recur(UF);default:return e}}function GF(e){let t=[...e].sort((e,t)=>{let n=typeof e.key==`number`;return n===(typeof t.key==`number`)?n?e.key-t.key:QE(EP.encode(e.key),EP.encode(t.key)):n?-1:1}),n=[];for(let e of t){let t=EP.encode(String(e.key));n.push(typeof e.key==`number`?0:1),aF(n,t.length),rF(n,t);let r=e.literal,i=EP.encode(qF(r));n.push(KF(r)),aF(n,i.length),rF(n,i)}return QP(n)}function KF(e){switch(typeof e){case`string`:return 1;case`number`:return 2;case`boolean`:return 3;case`bigint`:return 4;default:return 5}}function qF(e){if(typeof e==`symbol`){let t=globalThis.Symbol.keyFor(e);if(t===void 0)throw Error(`Binary layout: unregistered unique symbol (Symbol.keyFor)`);return t}return String(e)}function JF(e){switch(e._tag){case`Symbol`:return!0;case`Union`:return e.types.some(JF);default:return!1}}function YF(e){let t=HF(e);return t===`effect/schema/Json`||t===`effect/schema/MutableJson`||le(e.annotations?.toCodecJson)}function XF(e){let t=e.checks;if(t===void 0)return!1;let n=e=>e.annotations?.representation?.id===`effect/schema/isInt`||e._tag===`FilterGroup`&&e.checks.some(n);return t.some(n)}function ZF(e){for(;e._tag===`Suspend`;)e=e.thunk();return e}function QF(e){return new Sw(e.enums.map(e=>new IC(e[1],{title:e[0]})))}function $F(e){let t=[],n=new Set,r=e=>{let i=ZF(e);if(!n.has(i))switch(n.add(i),i._tag){case`Never`:return;case`Union`:i.types.forEach(r);return;case`Enum`:QF(i).types.forEach(r);return;default:t.push(i)}};return e.types.forEach(r),t}function eI(e){switch(typeof e){case`string`:return`string`;case`number`:return`number`;case`boolean`:return`bool`;default:return`bigint`}}function tI(e){switch(e._tag){case`String`:case`TemplateLiteral`:case`Symbol`:return Y.string;case`UniqueSymbol`:if(globalThis.Symbol.keyFor(e.symbol)===void 0)throw Error(`Binary layout: unregistered unique symbol (Symbol.keyFor)`);return Y.string;case`Boolean`:return Y.bool;case`Null`:return Y.null;case`Undefined`:case`Void`:return Y.undefined;case`Number`:return Y.number;case`BigInt`:return Y.bigint;case`Literal`:switch(typeof e.literal){case`string`:return Y.string;case`number`:return Y.number;case`boolean`:return Y.bool;default:return Y.bigint}case`Unknown`:case`Any`:case`ObjectKeyword`:return Y.json;case`Objects`:return Y.struct;case`Arrays`:return Y.array;case`Declaration`:{let t=HF(e);if(t!==void 0&&t in VF)return VF[t].kind;if(YF(e))return Y.json;throw Error(`Binary layout: declaration ${t??`<anonymous>`} has no toCodecJson or toCodec`)}case`Suspend`:return tI(ZF(e));default:throw Error(`Binary layout: union members are not uniquely identifiable`)}}function nI(e){for(let t of e.fields)t.optional||(t.index<32?e.requiredMask|=1<<t.index:e.requiredWide=!0)}function rI(e){let t=iI(e),n=!t&&oI(e);e=pT(e);let r=new Map,i=!1,a=0,o=e=>({_:e,slot:e===`string`?a++:0});function s(e){let t=r.get(e);if(t!==void 0)return t;let n=c(e);return r.set(e,n),n}function c(e){switch(e._tag){case`String`:case`TemplateLiteral`:return o(`string`);case`Symbol`:case`UniqueSymbol`:return o(`symbol`);case`Boolean`:return o(`bool`);case`Null`:return o(`null`);case`Undefined`:case`Void`:return o(`undefined`);case`Number`:{let t=pP(e);return o(t===`i32`||t===`u32`?t:XF(e)?`int`:`number`)}case`BigInt`:{let t=pP(e);return o(t===`i64`||t===`u64`?t:`bigint`)}case`Literal`:return OF(o(eI(e.literal)),[e.literal]);case`Unknown`:case`Any`:case`ObjectKeyword`:return o(`json`);case`Never`:return{_:`never`,ast:e};case`Enum`:return f(e,$F(QF(e)));case`Suspend`:{i=!0;let t=s(e.thunk());return r.set(e,t),t}case`Objects`:return l(e);case`Arrays`:return u(e);case`Union`:return f(e,$F(e));case`Declaration`:return d(e)}}function l(e){let t=[],n=[],i=new Map;for(let r of e.propertySignatures){if(typeof r.name==`symbol`)throw Error(`Binary layout: symbol property names are illegal`);let e=String(r.name),a=r.type.context?.annotations,o=a?.[cP],s=typeof o==`number`?o:QP(EP.encode(e));if(!Number.isInteger(s)||s<0||s>4294967295)throw Error(`Binary layout: illegal field id for ${e}`);let c=i.get(s);c===void 0?i.set(s,[e]):c.push(e),t.push({name:e,id:s,tagBytes:lF(s*GP+LP),index:0,optional:r.type.context?.isOptional===!0,annotations:a,layout:void 0,wireMask:0,inline:!1}),n.push(r.type)}for(let[e,t]of i)if(e===0||t.length>1)throw Error(`Binary layout field id collision: ${e} (${t.join(`, `)})`);let a=[];for(let t of e.indexSignatures){if(JF(t.parameter))throw Error(`Binary layout: symbol property names are illegal`);a.push({parameter:t.parameter,layout:void 0,wireMask:0})}let o={_:`struct`,ast:e,fields:t,byId:new Map,extra:a,extraAll:a.length===1&&xF(a[0].parameter)?a[0]:void 0,names:new Set(t.map(e=>e.name)),extraShape:void 0,optionalCount:0,requiredMask:0,requiredWide:!1};r.set(e,o);for(let e=0;e<t.length;e++){let r=t[e];r.layout=s(n[e]),r.wireMask=OL(r.layout),r.inline=zF(r.layout),r.optional&&o.optionalCount++,o.byId.set(r.id,r)}t.sort((e,t)=>e.id-t.id);for(let e=0;e<t.length;e++)t[e].index=e;nI(o);for(let t=0;t<a.length;t++)a[t].layout=s(e.indexSignatures[t].type),a[t].wireMask=OL(a[t].layout);return o}function u(e){let t={_:`array`,ast:e,elements:[],rest:[],hasCount:e.rest.length>0||e.elements.some(e=>e.context?.isOptional===!0),minCount:e.elements.filter(e=>e.context?.isOptional!==!0).length+Math.max(0,e.rest.length-1),uniform:void 0,uniformInline:!1,uniformPacked:void 0,uniformNumbers:!1,run:void 0};r.set(e,t);for(let n of e.elements)t.elements.push({optional:n.context?.isOptional===!0,layout:s(n)});for(let n of e.rest)t.rest.push(s(n));if(t.elements.length===0&&t.rest.length===1){let e=t.rest[0];t.uniform=e,t.uniformPacked=RF(e),t.uniformNumbers=e._===`number`,t.uniformInline=zF(e)}return t}function d(e){let t=HF(e);switch(t){case`effect/schema/Date`:return{_:`int64`,flavor:`date`};case`effect/schema/DateTimeUtc`:return{_:`int64`,flavor:`utc`};case`effect/schema/DateTimeZoned`:return o(`dateTimeZoned`);case`effect/schema/Duration`:return o(`duration`);case`effect/schema/BigDecimal`:return o(`bigDecimal`);case`effect/schema/Uint8Array`:return o(`bytes`)}let n=e.typeParameters;switch(t){case`effect/schema/Option`:{let t={_:`option`,value:void 0};return r.set(e,t),t.value=s(n[0]),t}case`effect/schema/Result`:{let t={_:`result`,success:void 0,failure:void 0};return r.set(e,t),t.success=s(n[0]),t.failure=s(n[1]),t}case`effect/schema/Exit`:{let t={_:`cause`,error:void 0,defect:void 0},i={_:`exit`,value:void 0,cause:t};return r.set(e,i),i.value=s(n[0]),t.error=s(n[1]),t.defect=s(n[2]),i}case`effect/schema/Cause`:case`effect/schema/CauseReason`:{let i={_:t===`effect/schema/Cause`?`cause`:`causeReason`,error:void 0,defect:void 0};return r.set(e,i),i.error=s(n[0]),i.defect=s(n[1]),i}}if(t!==void 0&&t in VF)throw Error(`Binary layout: native declaration ${t} has no layout constructor`);if(YF(e))return o(`json`);throw Error(`Binary layout: declaration ${t??`<anonymous>`} has no toCodecJson or toCodec`)}function f(e,t){if(t.length===0)return{_:`never`,ast:e};let n=[],i=[],a=new Map,c=new Map,l=(e,t)=>{let n=a.get(e);if(n!==void 0&&n._!==t._)throw Error(`Binary layout: union members are not uniquely identifiable`);a.set(e,t)};for(let e of t)if(e._tag===`Literal`){let t=tI(e),n=c.get(t);n===void 0?c.set(t,[e.literal]):n.includes(e.literal)||n.push(e.literal)}else if(e._tag===`UniqueSymbol`)tI(e),l(Y.string,o(`symbol`));else{if(e._tag===`Objects`||e._tag===`Arrays`){let t=gw(e);if(t!==void 0&&t.length>0){for(let e of t)if(typeof e.key==`symbol`)throw Error(`Binary layout: symbol property names are illegal`);n.push({member:e,sentinels:t});continue}}i.push({member:e,kind:tI(e)})}for(let[e,t]of c)l(e,OF(o(eI(t[0])),t));if(n.length===0&&i.length===0&&a.size===1)return a.values().next().value;let u=new Set(a.keys());for(let{kind:e}of i){if(u.has(e))throw Error(`Binary layout: union members are not uniquely identifiable`);u.add(e)}if(n.length===0&&a.size===0&&i.length===1){let t=s(i[0].member);return r.set(e,t),t}let d=new Map,f=[];for(let{sentinels:e}of n){let t=GF(e);if(d.has(t))throw Error(`Binary layout sentinel collision: ${t}`);d.set(t,e),f.push(t)}let p={_:`union`,ast:e,variants:[],byTag:new Map,discriminator:void 0,others:[],byKind:new Map,byPos:[]};r.set(e,p);for(let e=0;e<n.length;e++){let{member:t,sentinels:r}=n[e],i=f[e],a=s(t),o,c;if(t._tag===`Objects`){let e=a,t=new Set(r.map(e=>String(e.key))),n=e.fields.filter(e=>!t.has(e.name)),i={_:`struct`,ast:e.ast,fields:n,byId:new Map(n.map(e=>[e.id,e])),extra:e.extra,extraAll:e.extraAll,names:e.names,extraShape:void 0,optionalCount:n.reduce((e,t)=>t.optional?e+1:e,0),requiredMask:0,requiredWide:!1};nI(i),o=i,c=!1}else o=a,c=!0;let l={tag:i,sentinels:r,tuple:c,payload:o,position:0};p.variants.push(l),p.byTag.set(i,l)}for(let[e,t]of a)p.others.push({kind:e,layout:t,position:0}),p.byKind.set(e,t);for(let{kind:e,member:t}of i){let n=s(t);p.others.push({kind:e,layout:n,position:0}),p.byKind.set(e,n)}for(let e of[...p.variants].sort((e,t)=>e.tag-t.tag))e.position=p.byPos.length,p.byPos.push({variant:e,layout:e.payload});for(let e of[...p.others].sort((e,t)=>e.kind-t.kind))e.position=p.byPos.length,p.byPos.push({variant:void 0,layout:e.layout});return p.others.sort((e,t)=>fI(e.layout)-fI(t.layout)),p.discriminator=iL(p.variants),p}return{layout:s(e),recursive:i,exact:t,exitSuccess:n}}function iI(e){let t=new Map,n=e=>{if(e.encoding!==void 0||e.checks!==void 0&&!aI(e)||e.encodingChecks!==void 0)return!1;switch(e._tag){case`String`:case`Symbol`:case`Boolean`:case`Null`:case`Undefined`:case`Void`:case`Number`:case`BigInt`:case`Literal`:return!0;case`Never`:return!0;case`Unknown`:case`Any`:return!0;case`Arrays`:return e.elements.every(n)&&e.rest.every(n);case`Objects`:return e.propertySignatures.every(e=>n(e.type))&&e.indexSignatures.every(e=>e.parameter._tag===`String`&&n(e.parameter)&&n(e.type));case`Union`:return(e.options?.mode??`anyOf`)===`anyOf`&&e.types.every(n);case`Suspend`:{let r=t.get(e);if(r!==void 0)return r;t.set(e,!0);let i=n(e.thunk());return t.set(e,i),i}case`Declaration`:{let t=HF(e),r=t===void 0?void 0:VF[t];return r===void 0?!1:r.exact===!0||e.typeParameters.every(n)}default:return!1}};return n(e)}function aI(e){return(e._tag===`Number`||e._tag===`BigInt`)&&e.checks?.length===1&&pP(e)!==void 0}function oI(e){return e._tag===`Declaration`&&e.encoding===void 0&&e.checks===void 0&&e.encodingChecks===void 0&&HF(e)===`effect/schema/Exit`&&iI(e.typeParameters[0])}var sI={backEdge:0,bool:1,null:2,undefined:3,number:4,int:5,string:6,symbol:7,bytes:8,bigint:9,json:10,duration:11,bigDecimal:12,dateTimeZoned:13,date:14,dateTimeUtc:15,never:16,struct:17,array:18,union:19,option:20,result:21,exit:22,cause:23,causeReason:24,literal:25,i32:26,u32:27,i64:28,u64:29};function cI(e){let t=new Map,n=[],r=2**53-1;function i(e){let i=n.lastIndexOf(e);if(i>=0){i<r&&(r=i);let e=[sI.backEdge];return iF(e,n.length-i),nF(e)}let o=t.get(e);if(o!==void 0)return o;let s=n.length,c=r;r=2**53-1,n.push(e);let l=nF(a(e));n.pop();let u=r>=s;return u&&t.set(e,l),r=u?c:Math.min(c,r),l}function a(e){let t=[];switch(e._){case`bool`:case`null`:case`undefined`:case`number`:case`int`:case`string`:case`symbol`:case`bytes`:case`bigint`:case`i32`:case`u32`:case`i64`:case`u64`:case`json`:case`duration`:case`bigDecimal`:case`dateTimeZoned`:return t.push(sI[e._]),t;case`literal`:{t.push(sI.literal),rF(t,a(e.leaf)),iF(t,e.values.length);let n=e.values.map(e=>[KF(e),qF(e)]).sort((e,t)=>e[1]<t[1]?-1:e[1]>t[1]?1:e[0]-t[0]);for(let[e,r]of n){t.push(e);let n=EP.encode(r);iF(t,n.length),rF(t,n)}return t}case`int64`:return t.push(e.flavor===`date`?sI.date:sI.dateTimeUtc),t;case`never`:return t.push(sI.never),t;case`struct`:t.push(sI.struct),iF(t,e.fields.length);for(let n of e.fields)aF(t,n.id),t.push(+!!n.optional),oF(t,i(n.layout));iF(t,e.extra.length);for(let n of e.extra)oF(t,i(n.layout));return t;case`array`:t.push(sI.array),iF(t,e.elements.length);for(let n of e.elements)t.push(+!!n.optional),oF(t,i(n.layout));iF(t,e.rest.length);for(let n of e.rest)oF(t,i(n));return t;case`union`:t.push(sI.union),iF(t,e.byPos.length);for(let n of e.byPos){let e=n.variant;e===void 0?t.push(0):(t.push(1,+!!e.tuple),aF(t,e.tag)),oF(t,i(n.layout))}return t;case`option`:return t.push(sI.option),oF(t,i(e.value)),t;case`result`:return t.push(sI.result),oF(t,i(e.success)),oF(t,i(e.failure)),t;case`exit`:return t.push(sI.exit),oF(t,i(e.value)),oF(t,i(e.cause.error)),oF(t,i(e.cause.defect)),t;case`cause`:case`causeReason`:return t.push(e._===`cause`?sI.cause:sI.causeReason),oF(t,i(e.error)),oF(t,i(e.defect)),t}}return i(e)}function lI(e,t){let n=new Uint8Array(8);for(let r=0;r<4;r++)n[r]=e>>>r*8&255,n[r+4]=t>>>r*8&255;return n}var uI={positional:!1,rejectUnknownFields:!1,envelope:mP,expectedEnvelope:`version 2 envelope, flags 0`,fingerprint:new Uint8Array(8)};({...uI});function dI(e){let t=cI(e);return{positional:!0,rejectUnknownFields:!1,envelope:hP,expectedEnvelope:`version 2 envelope, flags 1`,fingerprint:lI(Number(t&wP),Number(t>>TP&wP))}}function fI(e){switch(e._){case`json`:return 2;case`struct`:return 1;default:return 0}}function pI(e,t){switch(e._){case`literal`:return kF(e,t);case`bool`:return typeof t==`boolean`;case`null`:return t===null;case`undefined`:return t===void 0;case`number`:case`int`:case`i32`:case`u32`:return typeof t==`number`;case`string`:return typeof t==`string`;case`symbol`:return typeof t==`symbol`;case`bigint`:case`i64`:case`u64`:return typeof t==`bigint`;case`bytes`:return t instanceof Uint8Array;case`int64`:return e.flavor===`date`?t instanceof Date:Ob(t)&&t._tag===`Utc`;case`dateTimeZoned`:return Ob(t)&&t._tag===`Zoned`;case`duration`:return Qa(t);case`bigDecimal`:return Zy(t);case`option`:return Sr(t);case`result`:return Ur(t);case`exit`:return wf(t);case`cause`:return Zd(t);case`causeReason`:return Qd(t);case`array`:return Array.isArray(t);case`struct`:return _e(t)&&!Array.isArray(t);case`json`:return!0;case`union`:case`never`:return!1}}function $(e,t,n){throw cF(new sS({expected:e},t,n))}function mI(e,t=new Set){if(!ge(e))return!1;let n=Array.isArray(e),r=Object.getPrototypeOf(e);if(n||r===Object.prototype||r===null){if(t.has(e))return!0;t.add(e);try{if(n){for(let n=0;n<e.length;n++)if(mI(e[n],t))return!0}else for(let n of Object.keys(e))if(mI(e[n],t))return!0}finally{t.delete(e)}return!1}if(e instanceof Date||e instanceof Uint8Array||Ob(e)||Qa(e)||Zy(e))return!1;if(t.has(e))return!0;t.add(e);try{if(Sr(e))return wr(e)&&mI(e.value,t);if(Ur(e))return mI(Gr(e)?e.success:e.failure,t);if(wf(e))return mI(jf(e)?e.value:e.cause,t);if(Zd(e))return e.reasons.some(e=>mI(e,t));if(Qd(e))switch(e._tag){case`Fail`:return mI(e.error,t);case`Die`:return mI(e.defect,t);case`Interrupt`:return!1}if(Zg(e)){for(let n of e)if(mI(n,t))return!0;return!1}if(Pb(e)){for(let[n,r]of e)if(mI(n,t)||mI(r,t))return!0;return!1}if(Ib(e)){for(let n of e)if(mI(n,t))return!0;return!1}if(Qb(e))return mI(tx(e),t);for(let n of Object.keys(e))if(mI(e[n],t))return!0}finally{t.delete(e)}return!1}function hI(e,t,n,r){let i=r.beginSized();lL(e,t,n,r),r.endSized(i)}function gI(e,t,n){let r=globalThis.Symbol.keyFor(t);r===void 0&&$(`registered symbol`,t,e.options),n.string(r)}function _I(e,t,n,r){let i=n;switch(i._tag){case`Fail`:r.byte(0),lL(e,t.error,i.error,r);return;case`Die`:r.byte(1),lL(e,t.defect,i.defect,r);return;case`Interrupt`:i.fiberId===void 0?r.byte(2):(r.byte(3),r.f64(i.fiberId))}}function vI(e){for(let t=0;t<e.length;t++)if(e.charCodeAt(t)>127)return!1;return!0}function yI(e,t,n){if(e.layout!==t||e.keys.length!==n.length)return!1;for(let t=0;t<n.length;t++)if(e.keys[t]!==n[t])return!1;return!0}function bI(e,t){if(e.extraAll===void 0||t.length>gF)return!1;let n=0;for(let e=0;e<t.length;e++)if(n+=t[e].length,n>_F)return!1;return!0}function xI(e,t,n){let r=Object.keys(n),i=t.extraShape;if(i!==void 0&&yI(i,t,r))return i.pairs;let a=bI(t,r),o=a?void 0:e.extraShape;if(o!==void 0&&yI(o,t,r))return o.pairs;let s=t.names,c=t.extraAll,l=[],u=!0;for(let n of r){if(s.has(n))continue;let r=c??(e.indexSignatures??=new CF(e.options)).find(t,n);r!==void 0&&(u&&!vI(n)&&(u=!1),l.push([n,r,void 0]))}if(u)l.sort((e,t)=>e[0]<t[0]?-1:+(e[0]>t[0]));else{for(let e of l)e[2]=EP.encode(e[0]);l.sort((e,t)=>QE(e[2],t[2]))}if(a)for(let e of l)e[2]??=EP.encode(e[0]);let d={layout:t,keys:r,pairs:l};return a?t.extraShape=d:e.extraShape=d,l}function SI(e,t,n,r,i){for(let[a,o,s]of t){let t=s===void 0?a.length:s.length,c=n[a],l=CI(o.layout,c,e.options),u=l%GP;if(i===void 0)r.uvarint(t*GP+u);else{if(!i.disabled){let t=FI(i,a);if(t!==void 0){r.uvarint(t*16+u*2+1),Z[Q++]=a,wI(e,o.layout,c,l,r),Q--;continue}II(i,a)}r.uvarint(t*16+u*2)}s===void 0?r.string(a):r.bytes(s),Z[Q++]=a,wI(e,o.layout,c,l,r),Q--}}function CI(e,t,n){if(e._===`literal`)return kF(e,t)||$(AF(e),t,n),CI(e.leaf,t,n);switch(e._){case`bool`:return typeof t!=`boolean`&&$(`a boolean`,t,n),t?VP:BP;case`number`:if(typeof t!=`number`&&$(`a number`,t,n),KP(t))return RP;{let e=XP(t);return e===0?zP:e*GP+HP}case`int`:return Number.isSafeInteger(t)||$(`an integer`,t,n),RP;case`i32`:case`u32`:return UP;default:return LP}}function wI(e,t,n,r,i){switch(r%GP){case BP:case VP:return;case RP:i.numberVarint(n);return;case zP:i.f64(n);return;case UP:lL(e,t,n,i);return;case HP:{let e=Math.floor(r/GP);i.numberVarint(Math.round(n*YP[e])),i.uvarint(e);return}default:hI(e,t,n,i)}}function TI(e,t,n,r){let i=CI(t.layout,n,e.options),a=i%GP;if(a===LP){let i=r.idAndMark(t.tagBytes);lL(e,t.layout,n,r),r.endSized(i)}else r.uvarint(t.id*GP+a),wI(e,t.layout,n,i,r)}function EI(e,t){let n=e.byName;if(n===void 0)return;let r=Object.getOwnPropertyNames(t),i=0;for(let e=0;e<r.length;e++){let t=n.get(r[e]);t!==void 0&&(i|=1<<t)}let a=e.struct;if((i&a.requiredMask)!==a.requiredMask){let e=a.fields;for(let t=0;t<e.length;t++){let n=e[t];if(!n.optional&&!(i&1<<t))throw Z[Q++]=n.name,cF(new rS(n.annotations))}}return i}function DI(e,t,n,r){let i=n;if(t.extra.length>0){let n=e.intern;e.intern=void 0;let a=xI(e,t,i);if(a.length>0){r.uvarint(0);let t=r.beginSized();SI(e,a,i,r,n),r.endSized(t)}}let a=t.fields;for(let t=0;t<a.length;t++){let n=a[t],o=n.name;if(!Object.hasOwn(i,o)){if(n.optional)continue;throw Z[Q++]=o,cF(new rS(n.annotations))}Z[Q++]=o,TI(e,n,i[o],r),Q--}}function OI(e,t,n,r){let i=n,a=e.intern;e.intern=void 0;let o=t.optionalCount+7>>3,s=0;if(o>0){s=r.len;for(let e=0;e<o;e++)r.byte(0)}let c=t.fields,l=0;for(let t=0;t<c.length;t++){let n=c[t],a=n.name,o=Object.hasOwn(i,a);if(n.optional){if(o&&(r.buf[r.start+s+(l>>3)]|=1<<(l&7)),l++,!o)continue}else if(!o)throw Z[Q++]=a,cF(new rS(n.annotations));Z[Q++]=a,n.inline?lL(e,n.layout,i[a],r):hI(e,n.layout,i[a],r),Q--}if(t.extra.length>0){let n=xI(e,t,i);r.uvarint(n.length),SI(e,n,i,r,a)}}function kI(e){switch(e._){case`string`:return MF;case`array`:return e.uniform?._===`string`?NF:jF;case`struct`:return e.extra.length>0?PF:jF;default:return jF}}function AI(e){let t=e.uniform;if(t===void 0){if(e.rest.length!==1)return;t=e.rest[0];for(let n of e.elements)if(n.optional||n.layout!==t)return}return t._===`struct`?t:void 0}function jI(e){let t=e.run;if(t!==void 0)return t;let n=AI(e);if(n===void 0)return e.run=t=null,t;let r=n.fields.map(e=>kI(e.layout)),i=n.fields.length<=FF;return t={struct:n,intern:r,shapes:i,byName:i&&n.extra.length===0?new Map(n.fields.map((e,t)=>[e.name,t])):void 0},e.run=t,t}var MI=16,NI=64;function PI(e,t){return e[t]??={values:[],refs:void 0,hits:0,disabled:!1}}function FI(e,t){let n=e.refs;if(n!==void 0){let r=n.get(t);return r!==void 0&&e.hits++,r}let r=e.values;for(let n=0;n<r.length;n++)if(r[n]===t)return e.hits++,n}function II(e,t){let n=e.values;if(e.refs!==void 0){if(e.hits===0&&n.length>=NI){e.disabled=!0,e.refs=void 0;return}e.refs.set(t,n.length)}else if(n.length>=MI){let r=e.refs=new Map;for(let e=0;e<n.length;e++)r.set(n[e],e);r.set(t,n.length)}n.push(t)}var LI=0,RI=1,zI=2,BI=64,VI=512;function HI(){return{slots:[],marks:[],frame:0}}function UI(e,t){return e[t]??={values:[],refs:new Map,state:LI,stamp:-1}}function WI(e,t){e.refs.has(t)?e.state=RI:(e.refs.set(t,e.values.length),e.values.push(t),e.values.length>=BI&&(e.state=zI))}function GI(e,t){let n=e.values;n.length>=VI||(e.refs.set(t,n.length),n.push(t))}function KI(e,t){t.stamp!==e.frame&&(t.stamp=e.frame,e.marks.push({slot:t,length:t.values.length,state:t.state}))}function qI(e){e.marks.length=0,e.frame++}function JI(e){let t=e.marks;for(let e=t.length-1;e>=0;e--){let{length:n,slot:r,state:i}=t[e],a=r.values;for(let e=n;e<a.length;e++)r.refs.delete(a[e]);a.length=n,r.state=i}t.length=0,e.frame++}function YI(e,t,n,r){let i=UI(e.slots,t.slot),a=i.state;if(a===zI){r.string(n);return}if(KI(e,i),a===LI){r.string(n),WI(i,n);return}let o=i.refs.get(n);o===void 0?(r.byte(0),GI(i,n),r.string(n)):r.uvarint(o*2+1)}function XI(e,t,n){let r=UI(e,t.slot),i=r.state;if(i===zI)return n.readUtf8(n.end-n.pos);if(i===LI){let e=n.readUtf8(n.end-n.pos);return WI(r,e),e}let a=n.uvarint();if((a&1)==1){let e=(a-1)/2,t=r.values;return e>=t.length&&X(`a dictionary reference`,a,n.options),t[e]}a!==0&&X(`a dictionary marker`,a,n.options);let o=n.readUtf8(n.end-n.pos);return GI(r,o),o}function ZI(e,t,n,r,i){if(!e.disabled){let t=FI(e,r);if(t!==void 0){i.uvarint(t*2+1);return}II(e,r)}let a=i.beginSized();lL(t,n,r,i),i.endSizedRun(a)}function QI(e,t,n,r,i){let a=[],o=[];for(let s=0;s<r;s++){Z[Q++]=s;let r=i.beginSized();$I(e,t,a,o,n[s],i),i.endSized(r),Q--}}function $I(e,t,n,r,i,a){let o=t.struct,s=i,c=o.fields,l;if(o.extra.length>0){let t=xI(e,o,s);t.length>0&&(l=t)}let u=!t.shapes,d=l===void 0?0:IF,f=EI(t,s);if(f!==void 0)d=f;else for(let e=0;e<c.length;e++){let t=c[e];if(Object.hasOwn(s,t.name))u||(d|=1<<e);else if(!t.optional)throw Z[Q++]=t.name,cF(new rS(t.annotations))}let p=-1;for(let e=0;e<n.length;e++)if(n[e]===d){p=e;break}p>=0?a.uvarint(p+1):(a.uvarint(0),u||n.push(d));let m=p<0,h=e.positional&&!u;if(m&&h&&a.uvarint(d),l!==void 0){m&&!h&&a.uvarint(0);let t=a.beginSized();SI(e,l,s,a),a.endSizedRun(t)}for(let n=0;n<c.length;n++){let i=c[n];if(u?!Object.hasOwn(s,i.name):!(d&1<<n))continue;m&&!h&&a.uvarint(i.id),Z[Q++]=i.name;let o=t.intern[n];if(o===MF)ZI(PI(r,n),e,i.layout,s[i.name],a);else{o!==jF&&(e.intern=PI(r,n));let t=a.beginSized();lL(e,i.layout,s[i.name],a),a.endSizedRun(t),e.intern=void 0}Q--}}function eL(e,t,n){let r=e.elements.length;if(t<r)return e.elements[t].layout;let i=Math.max(0,e.rest.length-1),a=Math.max(r,n-i);return t>=a?e.rest[t-a+1]:e.rest[0]}function tL(e,t,n,r){let i=n.length;if(t.rest.length===0&&i>t.elements.length)throw Z[Q++]=t.elements.length,cF(new iS(t.ast,n[t.elements.length],e.options));if(i<t.minCount)throw Z[Q++]=i,cF(new rS(void 0));if(t.hasCount&&r.uvarint(i),i>0){let a=jI(t);if(a!==null){QI(e,a,n,i,r);return}}let a=t.uniform;if(a!==void 0){if(t.uniformNumbers){rL(e,n,i,r);return}let o=e.intern;if(e.intern=void 0,o!==void 0){for(let t=0;t<i;t++)Z[Q++]=t,ZI(o,e,a,n[t],r),Q--;return}let s=t.uniformInline;for(let t=0;t<i;t++)Z[Q++]=t,s?lL(e,a,n[t],r):hI(e,a,n[t],r),Q--}else for(let a=0;a<i;a++){let o=eL(t,a,i);Z[Q++]=a,zF(o)?lL(e,o,n[a],r):hI(e,o,n[a],r),Q--}}var nL=[];function rL(e,t,n,r){let i=!0,a=!0;for(let r=0;r<n;r++){let n=t[r];if(typeof n!=`number`&&(Z[Q++]=r,$(`a number`,n,e.options)),KP(n))(n<0?-n:n)>JP&&(a=!1);else{i=!1;let e=XP(n);e===0?a=!1:nL[r]=e}if(!i&&!a)break}if(i){r.byte(MP);for(let e=0;e<n;e++)r.numberVarint(t[e])}else if(a){r.byte(NP);for(let e=0;e<n;e++){let n=t[e],i=Number.isInteger(n)?0:nL[e],a=i===0?n:Math.round(n*YP[i]),o=a<0||a===0&&1/a<0,s=o?-a:a;r.uvarint((s*2+ +!!o)*16+i)}}else{r.byte(jP);for(let e=0;e<n;e++)r.f64(t[e])}}function iL(e){if(!(e.length<2||e.some(e=>e.tuple)))for(let t of e[0].sentinels){let n=new Map;for(let r of e){let e=r.sentinels.find(e=>e.key===t.key);if(e===void 0||n.has(e.literal)||Number.isNaN(e.literal))break;n.set(e.literal,r)}if(n.size===e.length)return{key:t.key,rows:n}}}function aL(e,t){let n=e.sentinels;for(let e=0;e<n.length;e++){let{key:r,literal:i}=n[e];if(t[r]!==i||!Object.hasOwn(t,r))return!1}return!0}function oL(e,t){return e.tuple?Array.isArray(t)&&aL(e,t):_e(t)&&!Array.isArray(t)&&aL(e,t)}function sL(e,t,n,r){e.positional?r.uvarint(t.position):(r.byte(Y.variant),r.u32le(t.tag)),lL(e,t.payload,n,r)}function cL(e,t,n,r){let i=t.discriminator;if(i!==void 0){if(_e(n)&&!Array.isArray(n)){let t=n,a=i.rows.get(t[i.key]);if(a!==void 0&&aL(a,t)){sL(e,a,n,r);return}}}else for(let i of t.variants)if(oL(i,n)){sL(e,i,n,r);return}for(let i of t.others)if(pI(i.layout,n)){e.positional?r.uvarint(i.position):r.byte(i.kind),lL(e,i.layout,n,r);return}throw cF(new oS(t.ast,n,e.options))}function lL(e,t,n,r){switch(t._){case`literal`:kF(t,n)||$(AF(t),n,e.options),lL(e,t.leaf,n,r);return;case`bool`:typeof n!=`boolean`&&$(`a boolean`,n,e.options),r.byte(+(n===!0));return;case`null`:n!==null&&$(`null`,n,e.options);return;case`undefined`:n!==void 0&&$(`undefined`,n,e.options);return;case`number`:{if(typeof n!=`number`&&$(`a number`,n,e.options),KP(n)){r.numberVarint(n);return}let t=XP(n);t>0?(r.numberVarint(Math.round(n*YP[t])),r.byte(t)):r.f64(n);return}case`int`:Number.isSafeInteger(n)||$(`an integer`,n,e.options),r.numberVarint(n);return;case`string`:{typeof n!=`string`&&$(`a string`,n,e.options);let i=e.dict;i===void 0?r.string(n):YI(i,t,n,r);return}case`symbol`:typeof n!=`symbol`&&$(`a symbol`,n,e.options),gI(e,n,r);return;case`bytes`:n instanceof Uint8Array||$(`a Uint8Array`,n,e.options),r.bytes(n);return;case`bigint`:typeof n!=`bigint`&&$(`a bigint`,n,e.options),r.zigzag(n);return;case`i32`:(typeof n!=`number`||(n|0)!==n)&&$(`a 32-bit integer`,n,e.options),r.i32le(n);return;case`u32`:(typeof n!=`number`||n>>>0!==n)&&$(`a 32-bit unsigned integer`,n,e.options),r.u32le(n);return;case`i64`:(typeof n!=`bigint`||n<uP||n>dP)&&$(`a 64-bit integer`,n,e.options),r.i64(n);return;case`u64`:(typeof n!=`bigint`||n<_P||n>fP)&&$(`a 64-bit unsigned integer`,n,e.options),r.u64(n);return;case`int64`:{pI(t,n)||$(t.flavor===`date`?`a Date`:`a DateTime.Utc`,n,e.options);let i=t.flavor===`date`?n.getTime():n.epochMilliseconds;Number.isNaN(i)&&$(`a valid Date`,n,e.options),r.i64(BigInt(i));return}case`dateTimeZoned`:{pI(t,n)||$(`a DateTime.Zoned`,n,e.options);let i=n;r.i64(BigInt(i.epochMilliseconds)),i.zone._tag===`Offset`?(r.byte(0),r.i32le(i.zone.offset)):(r.byte(1),r.string(i.zone.id));return}case`duration`:{Qa(n)||$(`a Duration`,n,e.options);let t=n.value;switch(t._tag){case`Infinity`:r.byte(1);return;case`NegativeInfinity`:r.byte(2);return;case`Nanos`:r.byte(0),r.zigzag(t.nanos);return;case`Millis`:r.byte(0),r.zigzag(BigInt(t.millis)*SP);return}}case`bigDecimal`:{Zy(n)||$(`a BigDecimal`,n,e.options);let t=ib(n);r.zigzag(t.value),r.zigzag(BigInt(t.scale));return}case`json`:{let t;try{t=JSON.stringify(n)}catch{t=void 0}t===void 0&&(mI(n)&&$(`acyclic value`,n,e.options),$(`a JSON-serializable value`,n,e.options)),r.string(t);return}case`option`:{Sr(n)||$(`an Option`,n,e.options);let i=n;i._tag===`None`?r.byte(0):(r.byte(1),lL(e,t.value,i.value,r));return}case`result`:{Ur(n)||$(`a Result`,n,e.options);let i=n;i._tag===`Success`?(r.byte(0),lL(e,t.success,i.success,r)):(r.byte(1),lL(e,t.failure,i.failure,r));return}case`exit`:{wf(n)||$(`an Exit`,n,e.options);let i=n;i._tag===`Success`?(r.byte(0),lL(e,t.value,i.value,r)):(r.byte(1),lL(e,t.cause,i.cause,r));return}case`cause`:{Zd(n)||$(`a Cause`,n,e.options);let i=n.reasons;r.uvarint(i.length);for(let n of i){let i=r.beginSized();_I(e,t,n,r),r.endSized(i)}return}case`causeReason`:Qd(n)||$(`a Cause.Reason`,n,e.options),_I(e,t,n,r);return;case`struct`:(!_e(n)||Array.isArray(n))&&$(`an object`,n,e.options),e.positional?OI(e,t,n,r):DI(e,t,n,r);return;case`array`:Array.isArray(n)||$(`an array`,n,e.options),tL(e,t,n,r);return;case`union`:cL(e,t,n,r);return;case`never`:throw cF(new oS(t.ast,n,e.options))}}var uL=new bF;function dL(e,t,n,r,i){let a=i.beginSized();i.byte(r.envelope),r.positional&&i.bytes(r.fingerprint),lL(e,t,n,i),i.endSized(a)}function fL(e,t,n,r,i,a){let o={options:r,positional:i.positional,indexSignatures:void 0,extraShape:void 0,intern:void 0,dict:a},s=uL??new bF,c=s===uL;c&&(uL=void 0),s.reset();let l=Q,u=!1;try{if(n===void 0)Q=0,dL(o,e,t,i,s);else for(let t=0;t<n.length;t++)Q=0,dL(o,e,n[t],i,s);let r=s.out();return u=!0,r}finally{a!==void 0&&(u?qI(a):JI(a)),s.abort(),Q=l,c&&(uL=s)}}function pL(e,t,n,r,i){return fL(e,void 0,t,n,r,i)}function mL(e,t,n,r,i){return fL(e,t,void 0,n,r,i)}function hL(e){return wf(e)&&jf(e)}var gL=globalThis.Symbol.for(`~effect/encoding/SchemaBinary/absent`);function _L(e,t){let n=KL(e,t);return n!==gL&&t.pos!==t.end&&X(`no leftover bytes`,void 0,t.options),n}function vL(e,t){let n=t.enter(t.uvarint()),r=_L(e,t);return t.exit(n),r}function yL(e,t){if(LF(e))return KL(e,t);let n=RF(e),r=t.enter(n===void 0?e._===`null`||e._===`undefined`?0:t.uvarint():n),i=_L(e,t);return t.exit(r),i}var bL=8;function xL(e,t){let n=e.set;if(n!==void 0)return n.has(t)?!0:(n.add(t),!1);let r=e.list;if(r.includes(t))return!0;if(r.length>=bL){let n=e.set=new Set;for(let e=0;e<r.length;e++)n.add(r[e]);n.add(t)}else r.push(t);return!1}function SL(e,t,n,r,i){let a=t.uvarint(),o=Math.floor(i===void 0?a/GP:a/16),s=i===void 0?a-o*GP:Math.floor((a-o*16)/2),c=i===void 0?t.readUtf8(o):CL(i,a,o,t);e.names.has(c)&&X(`an extra key distinct from declared fields`,c,t.options),xL(r,c)&&X(`unique extra keys`,void 0,t.options);let l=e.extraAll??(t.indexSignatures??=new CF(t.options)).find(e,c);if(l===void 0){t.rejectUnknownFields&&X(`a key matching an index signature`,c,t.options),DL(s,t);return}Z[Q++]=c;let u=AL(l.layout,l.wireMask,s,t);Q--,u!==gL&&dt(n,c,u)}function CL(e,t,n,r){if((t&1)==1)return n>=e.length&&X(`a known back-reference`,void 0,r.options),e[n];let i=r.readUtf8(n);return e.push(i),i}function wL(e){return new nS([e.name],new rS(e.annotations))}function TL(e,t){throw cF(new aS(e.ast,t))}function EL(e){for(;e.byte()&128;);}function DL(e,t){switch(e){case LP:t.take(t.uvarint());return;case RP:EL(t);return;case zP:t.take(8);return;case BP:case VP:case WP:return;case HP:EL(t),EL(t);return;case UP:t.take(4);return}}function OL(e){if(e._===`literal`)return OL(e.leaf);switch(e._){case`bool`:return 24;case`number`:return 38;case`int`:return 2;case`i32`:case`u32`:return 64;default:return 1}}function kL(e,t){switch(e){case BP:return!1;case VP:return!0;case RP:return t.numberVarint();case zP:return t.f64();case HP:{let e=t.numberVarint(),n=t.uvarint();return(n===0||n>qP)&&X(`a decimal scale in [1, 8]`,n,t.options),e/YP[n]}}return X(`matching field wire kind`,void 0,t.options)}function AL(e,t,n,r){if(!(t&1<<n))return r.rejectUnknownFields&&X(`matching field wire kind`,n,r.options),DL(n,r),gL;if(n===UP)return e._===`u32`?r.u32le():r.i32le();if(n!==LP){let t=kL(n,r);return e._===`literal`&&!kF(e,t)&&X(AF(e),t,r.options),t}let i=r.enter(r.uvarint()),a=_L(e,r);return r.exit(i),a}function jL(e,t){let n;e.extra.length>0&&(n=t.intern,t.intern=void 0);let r={},i=0,a=0,o,s,c,l=!1,u=e.fields,d=0;for(;t.pos<t.end;){let f=t.fieldTag(),p=Math.floor(f/GP),m=f-p*GP;if(p===0){l&&X(`unique field ids`,void 0,t.options),l=!0,m!==LP&&X(`extra field map`,void 0,t.options);let i=t.enter(t.uvarint());PL(e,t,r,n),t.exit(i);continue}let h;if(d<u.length&&u[d].id===p?(h=u[d],d++):(h=e.byId.get(p),h!==void 0&&(d=h.index+1)),h===void 0){t.rejectUnknownFields&&X(`a known field id`,p,t.options),c===void 0?c=new Set:c.has(p)&&X(`unique field ids`,void 0,t.options),c.add(p),DL(m,t);continue}let g=h.index;if(g<32){let e=1<<g;(i&e)!==0&&X(`unique field ids`,void 0,t.options),i|=e}else o===void 0?o=new Set([g]):(o.has(g)&&X(`unique field ids`,void 0,t.options),o.add(g));Z[Q++]=h.name;let ee=AL(h.layout,h.wireMask,m,t);Q--,ee!==gL&&(dt(r,h.name,ee),g<32?a|=1<<g:(s??=new Set).add(g))}return ML(e,a,s,t),r}function ML(e,t,n,r){if((t&e.requiredMask)===e.requiredMask&&!e.requiredWide)return;let i=e.fields,a;for(let e=0;e<i.length;e++){let o=i[e],s=o.index,c=s<32?!!(t&1<<s):n?.has(s)===!0;if(!o.optional&&!c&&((a??=[]).push(wL(o)),r.options.errors!==`all`))break}a!==void 0&&TL(e,a)}function NL(e,t){let n;e.extra.length>0&&(n=t.intern,t.intern=void 0);let r={},i=e.optionalCount+7>>3,a=0;i>0&&(t.pos+i>t.end&&X(`complete value`,void 0,t.options),a=t.pos,t.pos+=i);let o=t.buf,s=e.fields,c=0,l;for(let e=0;e<s.length;e++){let n=s[e];if(n.optional){let e=!!(o[a+(c>>3)]&1<<(c&7));if(c++,!e)continue}Z[Q++]=n.name;let i=n.inline?yL(n.layout,t):vL(n.layout,t);if(Q--,i!==gL)dt(r,n.name,i);else if(!n.optional&&((l??=[]).push(wL(n)),t.options.errors!==`all`))break}if(l!==void 0&&TL(e,l),e.extra.length>0){let i=t.uvarint();if(i>t.remaining&&X(`complete value`,void 0,t.options),i>0){let a={list:[],set:void 0};for(let o=0;o<i;o++)SL(e,t,r,a,n)}}return r}function PL(e,t,n,r){let i={list:[],set:void 0};for(;t.pos<t.end;)SL(e,t,n,i,r)}function FL(e,t,n){let r=n.uvarint();if((r&1)==1){let t=(r-1)/2;return t>=e.length&&X(`a known back-reference`,void 0,n.options),e[t]}if(t._===`string`){if(n.dict!==void 0){let i=n.enter(r/2),a=_L(t,n);return n.exit(i),e.push(a),a}let i=n.readUtf8(r/2);return e.push(i),i}let i=n.enter(r/2),a=_L(t,n);return n.exit(i),e.push(a),a}function IL(e,t,n){let r=Array(t),i=[],a=[];for(let o=0;o<t;o++){Z[Q++]=o;let t=n.enter(n.uvarint());r[o]=RL(e,i,a,n),n.exit(t),Q--}return r}function LL(e,t){let n=t.uvarint(),r=e.fields,i=n&-1073741825;(n>IF*2-1||i>>>r.length)&&X(`a known row shape`,void 0,t.options);let a=[];(n&IF)!==0&&a.push(null);for(let e=0;e<r.length;e++)i&1<<e&&a.push(r[e]);return a}function RL(e,t,n,r){let i=e.struct,a={},o=0,s,c=r.uvarint(),l;if(c===0?r.positional&&e.shapes&&(l=LL(i,r),t.push(l)):(l=t[c-1],l===void 0&&X(`a known row shape`,void 0,r.options)),l!==void 0){for(let t=0;t<l.length;t++){let i=zL(e,n,l[t],a,r);i>=0&&(i<32?o|=1<<i:(s??=new Set).add(i))}r.pos!==r.end&&X(`no leftover bytes`,void 0,r.options)}else{let c=e.shapes?[]:void 0,l=0,u,d,f=!1;for(;r.pos<r.end;){let t=r.uvarint(),p;t===0?(f&&X(`unique field ids`,void 0,r.options),f=!0,p=null):(p=i.byId.get(t),p===void 0?(r.rejectUnknownFields&&X(`a known field id`,t,r.options),d===void 0?d=new Set([t]):d.has(t)?X(`unique field ids`,void 0,r.options):d.add(t)):p.index<32?(l&1<<p.index&&X(`unique field ids`,void 0,r.options),l|=1<<p.index):u===void 0?u=new Set([p.index]):(u.has(p.index)&&X(`unique field ids`,void 0,r.options),u.add(p.index))),c?.push(p);let m=zL(e,n,p,a,r);m>=0&&(m<32?o|=1<<m:(s??=new Set).add(m))}c!==void 0&&t.push(c)}return ML(i,o,s,r),a}function zL(e,t,n,r,i){let a=i.uvarint();if((a&1)==1){if(n==null)return-1;let e=t[n.index],o=(a-1)/2;(e===void 0||o>=e.length)&&X(`a known back-reference`,void 0,i.options);let s=e[o];return s===gL?-1:(dt(r,n.name,s),n.index)}let o=i.enter(a/2);if(n===null)return PL(e.struct,i,r),i.exit(o),-1;if(n===void 0)return i.exit(o),-1;let s=e.intern[n.index];(s===NF||s===PF)&&(i.intern=t[n.index]??=[]),Z[Q++]=n.name;let c=_L(n.layout,i);return Q--,i.intern=void 0,i.exit(o),s===MF&&(t[n.index]??=[]).push(c),c===gL?-1:(dt(r,n.name,c),n.index)}function BL(e,t){let n=e.elements.length,r=e.hasCount?t.uvarint():n;if(e.rest.length===0&&r>n)throw Z[Q++]=n,cF(new iS(e.ast,void 0,t.options));if(r<e.minCount)throw Z[Q++]=r,cF(new rS(void 0));if(e.hasCount&&r>(e.rest.length>0&&BF(e.rest[0])?IP:t.remaining+FP)&&X(`array count within allocation limit`,r,t.options),r>0){let n=jI(e);if(n!==null)return IL(n,r,t)}let i=Array(r),a=e.uniform;if(a!==void 0){if(e.uniformNumbers)return VL(i,r,t);let n=t.intern;if(t.intern=void 0,n!==void 0){for(let e=0;e<r;e++){Z[Q++]=e;let r=FL(n,a,t);if(r===gL)throw cF(new rS(void 0));Q--,i[e]=r}return i}if(LF(a)){for(let e=0;e<r;e++)Z[Q++]=e,i[e]=KL(a,t),Q--;return i}if(a._===`string`){for(let e=0;e<r;e++)Z[Q++]=e,i[e]=t.dict===void 0?t.readUtf8(t.uvarint()):vL(a,t),Q--;return i}let o=e.uniformPacked,s=e.uniformInline;for(let e=0;e<r;e++){Z[Q++]=e;let n=t.enter(s?o??0:t.uvarint()),r=_L(a,t);if(t.exit(n),r===gL)throw cF(new rS(void 0));Q--,i[e]=r}return i}for(let a=0;a<r;a++){let o=eL(e,a,r),s=a<n&&e.elements[a].optional;if(!e.hasCount&&t.remaining===0&&!s&&o._!==`null`&&o._!==`undefined`)throw Z[Q++]=a,cF(new rS(void 0));Z[Q++]=a;let c=yL(o,t);if(c===gL)throw s&&X(`known union member`,void 0,t.options),cF(new rS(void 0));Q--,i[a]=c}if(!e.hasCount&&t.pos<t.end)throw Z[Q++]=n,cF(new iS(e.ast,void 0,t.options));return i}function VL(e,t,n){let r=n.byte();if(r===jP){n.remaining!==t*8&&X(`f64`,void 0,n.options);for(let r=0;r<t;r++)e[r]=n.f64();return e}if(r===NP){for(let r=0;r<t;r++){Z[Q++]=r;let t=n.uvarint(),i=t%16;i>qP&&X(`decimal`,void 0,n.options);let a=ZP((t-i)/16);e[r]=i===0?a:a/YP[i],Q--}return e}r!==MP&&X(`f64`,void 0,n.options);for(let r=0;r<t;r++)Z[Q++]=r,e[r]=n.numberVarint(),Q--;return e}function HL(e,t){let n=t.byte();if(n===Y.variant){let n=t.u32le(),r=e.byTag.get(n);if(r===void 0)return t.rejectUnknownFields&&X(`known union member`,n,t.options),t.take(t.remaining),gL;let i=_L(r.payload,t);if(i===gL)return gL;if(!r.tuple)for(let e of r.sentinels)dt(i,e.key,e.literal);return i}let r=e.byKind.get(n);return r===void 0?(t.rejectUnknownFields&&X(`known union member`,n,t.options),t.take(t.remaining),gL):_L(r,t)}function UL(e,t){let n=e.byPos[t.uvarint()];n===void 0&&X(`known union member`,void 0,t.options);let r=_L(n.layout,t),i=n.variant;if(i!==void 0&&!i.tuple&&r!==gL)for(let e of i.sentinels)dt(r,e.key,e.literal);return r}function WL(e,t){switch(t.byte()){case 0:return of(GL(_L(e.error,t)));case 1:return sf(GL(_L(e.defect,t)));case 2:return t.remaining!==0&&X(`empty`,void 0,t.options),cf();case 3:return t.remaining!==8&&X(`f64`,void 0,t.options),cf(t.f64());default:return t.take(t.remaining),gL}}function GL(e){if(e===gL)throw cF(new rS(void 0));return e}function KL(e,t){t.nesting>=PP&&X(`nesting depth at most ${PP}`,t.nesting+1,t.options),t.nesting++;try{return qL(e,t)}finally{t.nesting--}}function qL(e,t){switch(e._){case`literal`:{let n=KL(e.leaf,t);return kF(e,n)||X(AF(e),n,t.options),n}case`bool`:{t.remaining!==1&&X(`bool`,void 0,t.options);let e=t.byte();return e>1&&X(`bool`,void 0,t.options),e===1}case`null`:return t.remaining!==0&&X(`empty`,void 0,t.options),null;case`undefined`:t.remaining!==0&&X(`empty`,void 0,t.options);return;case`number`:{let e=t.remaining;if(e===8)return t.f64();(e===0||e>OP)&&X(`f64`,void 0,t.options);let n=t.numberVarint();if(t.remaining===0)return n;let r=t.byte();return(t.remaining!==0||r===0||r>qP)&&X(`decimal`,void 0,t.options),n/YP[r]}case`int`:return t.numberVarint();case`string`:{let n=t.dict;return n===void 0?t.readUtf8(t.end-t.pos):XI(n,e,t)}case`symbol`:return globalThis.Symbol.for(t.readUtf8(t.end-t.pos));case`bytes`:return t.takeCopy(t.end-t.pos);case`bigint`:return t.zigzag();case`i32`:return t.remaining!==4&&X(`a 32-bit integer`,void 0,t.options),t.i32le();case`u32`:return t.remaining!==4&&X(`a 32-bit unsigned integer`,void 0,t.options),t.u32le();case`i64`:return t.remaining!==8&&X(`a 64-bit integer`,void 0,t.options),t.i64();case`u64`:return t.remaining!==8&&X(`a 64-bit unsigned integer`,void 0,t.options),t.u64();case`int64`:{t.remaining!==8&&X(`int64`,void 0,t.options);let n=Number(t.i64()),r=new Date(n);return Number.isNaN(r.getTime())&&X(e.flavor===`date`?`a valid Date`:`a valid DateTime`,n,t.options),e.flavor===`date`?r:kb(n)}case`dateTimeZoned`:{let e=Number(t.i64()),n=t.byte(),r;if(n===0)t.remaining!==4&&X(`time zone`,void 0,t.options),r=t.i32le();else if(n===1)r=t.readUtf8(t.end-t.pos);else return X(`time zone`,void 0,t.options);try{return Ab(e,{timeZone:r})}catch{return X(`time zone`,void 0,t.options)}}case`duration`:switch(t.byte()){case 0:return oo(t.zigzag());case 1:return io;case 2:return ao;default:return X(`duration`,void 0,t.options)}case`bigDecimal`:{let e=t.zigzag(),n=t.zigzag();return(n>gP||-n>gP)&&X(`safe integer length`,void 0,t.options),Qy(e,Number(n))}case`json`:{let e=t.readUtf8(t.end-t.pos);try{return JSON.parse(e)}catch{return X(`json`,void 0,t.options)}}case`option`:{let n=t.byte();return n===0?(t.remaining!==0&&X(`empty`,void 0,t.options),T()):(n!==1&&X(`bool`,void 0,t.options),E(GL(_L(e.value,t))))}case`result`:{let n=t.byte();return n===0?Br(GL(_L(e.success,t))):(n!==1&&X(`bool`,void 0,t.options),Vr(GL(_L(e.failure,t))))}case`exit`:{let n=t.byte();return n===0?Tf(GL(_L(e.value,t))):(n!==1&&X(`bool`,void 0,t.options),Ef(KL(e.cause,t)))}case`cause`:{let n=t.uvarint(),r=[];for(let i=0;i<n;i++){Z[Q++]=i;let n=t.enter(t.uvarint()),a=WL(e,t);t.exit(n),Q--,a!==gL&&r.push(a)}return t.pos!==t.end&&X(`no leftover bytes`,void 0,t.options),tf(r)}case`causeReason`:return WL(e,t);case`struct`:return t.positional?NL(e,t):jL(e,t);case`array`:return BL(e,t);case`union`:return t.positional?UL(e,t):HL(e,t);case`never`:throw cF(new oS(e.ast,void 0,t.options))}}function JL(e,t,n){let r=t.byte();if(r!==n.envelope&&X(n.expectedEnvelope,r,t.options),n.positional){t.remaining<8&&X(`complete value`,void 0,t.options);let e=t.buf,r=n.fingerprint,i=t.pos;for(let n=0;n<8;n++)e[i+n]!==r[n]&&X(`matching layout fingerprint`,void 0,t.options);t.pos=i+8}let i=_L(e,t);if(i===gL)throw cF(new rS(void 0));return i}var YL=new DF;function XL(e,t,n,r){let i=YL??new DF,a=i===YL;a&&(YL=void 0),i.reset(t,0,t.length,n,void 0,r,void 0);let o=Q;Q=0;try{let a=i.uvarint();a===0&&X(`nonzero frame length`,void 0,n);let o=i.enter(a),s=JL(e,i,r);return i.exit(o),i.pos!==t.length&&X(`no leftover bytes`,void 0,n),s}finally{Q=o,i.release(),a&&(YL=i)}}function ZL(e,t,n,r=!1){return eC({decode:(i,a)=>{try{let o=XL(e,i,a,t);return n!==void 0&&ge(o)&&(!r||hL(o))&&(n.value=o),I(o)}catch(e){return e instanceof sF?B(e.issue):Sh(e)}},encode:(n,r)=>{try{return I(mL(e,n,r,t))}catch(e){return e instanceof sF?B(e.issue):Sh(e)}}})}var QL=f(dI);function $L(e,t){return t===!0?QL(e):uI}var eR=f(e=>{let t=K(UF(e)),{exact:n,exitSuccess:r,layout:i,recursive:a}=rI(t.ast);return{target:a?lR(t):t,layout:i,exact:n,exitSuccess:r,recursive:a}});function tR(e){return eR(e.ast)}function nR(e,t){return e.value===void 0||t!==e.value?!1:(e.value=void 0,!0)}function rR(e,t,n){let r=K(fT(e.ast)),i=cE(r),a=e=>()=>(t,n,r)=>e(t,r)?W:i(t,r);return K(new OC([r.ast],a(t),{identifier:`binary value`},void 0,void 0,void 0,void 0,a(n)))}function iR(e,t){return t.onExcessProperty!==`error`}function aR(e,t,n){return rR(e,e=>nR(t,e),n?iR:oR)}function oR(){return!1}function sR(e,t){return eD()([e],([e])=>{let n=cE(e);return(e,r,i)=>nR(t,e)||hL(e)&&i.onExcessProperty!==`error`?I(e):n(e,i)},{identifier:`binary exit value`})}function cR(e){return rR(e,iR,iR)}function lR(e){let t=K(fT(e.ast)),n=new WeakSet;return JD(eD()([t],([e])=>(t,r,i)=>ge(t)&&n.delete(t)?I(t):mI(t)?B(new oS(r,t,i)):cE(e)(t,i),{identifier:`acyclic value`}),tC({decode:e=>(ge(e)&&n.add(e),e),encode:e=>e}))(e)}var uR=class extends Hi()(`effect/rpc/RpcSerialization`){},dR=16777216,fR=new TextEncoder,pR=e=>{let t=e?.maxFrameSize===`unbounded`?void 0:e?.maxFrameSize??dR,n=e?.fingerprintPayloads===!0?e=>$N(e,{fingerprint:!0}):$N,r={fingerprint:!0};return uR.of({contentType:`application/vnd.effect.rpc+schema-binary`,includesFraming:!0,codecFor:n,makeUnsafe:()=>{let e=iP(qN,{...r,maxFrameSize:t}),n=oP(qN,r);return{decode:t=>e.feedSync(typeof t==`string`?fR.encode(t):t),encode:e=>{if(!Array.isArray(e))return n.encode(e);if(e.length!==0)return n.encodeMany(e)}}}})},mR=e=>mp(uR)(()=>pR(e)),hR=e=>L(()=>{let t=new Set,n=new Map,r=new Map,i=(e,t)=>Yh(r=>{let i=n.get(e);return i||(i=[],n.set(e,i)),i.push([t,r]),z});return H(e((e,t)=>{let n=r.get(e);return n?n(t):i(e,t)},t),e=>({...e,run(e,i){return yh(function*(){t.add(e),r.set(e,i);let a=n.get(e);if(a){n.delete(e);for(let[e,t]of a)yield*Zh(L(()=>i(e)),t)}return yield*lg(vh,()=>(t.delete(e),r.delete(e),z))})}}))}),gR=0,_R=jg(function*(e,t){let n=t.spanPrefix,r=t?.supportsAck??!0,a=t?.disableTracing??!1,o=t?.generateRequestId??(()=>gR++),s=yield*Jh(),c=D(s,Gf),l=new Map,u=!1;yield*Yf(c,wh(e=>(u=!0,d(kf(e.id)))));let d=jg(function*(e){let t=Array.from(l.values());l.clear();for(let n of t)n._tag===`Queue`?yield*e._tag===`Success`?B_(n.queue):R_(n.queue,e.cause):n.resume(e)},mg),f=e=>{let r=ON(e.successSchema),i=h(e);return(o,s)=>{let c=s?.headers?sx(s.headers):ox,l=s?.context??aa();if(!r){let r=t=>p(e,i,t,e.payloadSchema.make(o),c,l,s?.discard??!1);return a?r(void 0):vg(wN(n,e._tag),{kind:`client`,attributes:TN(e._tag,t.spanAttributes)},r)}let u=m(e,i,e.payloadSchema.make(o),c,s?.streamBufferSize??16,l);return s?.asQueue?u:xy(H(u,vy))}},p=(e,n,r,a,s,c,d)=>wh(f=>{if(u)return dg;let p=o(),m=n(e=>t.onFromClient({message:e,context:c}),{_tag:`Request`,id:p,tag:e._tag,payload:a,...r?{traceId:r.traceId,spanId:r.spanId,sampled:r.sampled}:{},headers:dx(f.getRef(xR),s),...d?{discard:!0}:{}}),h;return pg(_h(t=>{let n=!1,a={_tag:`Effect`,rpc:e,context:c,resume(e){d&&e._tag===`Success`?(n=!0,h?.pollUnsafe()&&t(Af)):(t(e),h&&!h.pollUnsafe()&&f.currentDispatcher.scheduleTask(()=>{h.interruptUnsafe(f.id)},0))}};l.set(p,a),h=m.pipe(r?yg(r,{captureStackTrace:!1}):i,wg(f.context)),h.addObserver(e=>{if(e._tag===`Failure`)return l.delete(p),t(e);if(n)return t(Af)})}),e=>(l.delete(p),Dh(Hg(h),g(p,Array.from(e),c))))}),m=jg(function*(e,r,s,c,d,f){if(u)return yield*dg;let p=a?void 0:yield*_g(wN(n,e._tag),{kind:`client`,attributes:TN(e._tag,t.spanAttributes)}),m=Ug(),h=o(),ee=fa(m.context,Gf),_=yield*N_(d);return yield*Jf(ee,e=>(H_(_),l.has(h)?(l.delete(h),g(h,Mf(e)?Array.from(hf(e.cause)):[],f)):z)),l.set(h,{_tag:`Queue`,rpc:e,queue:_,scope:ee,context:f}),yield*r(e=>t.onFromClient({message:e,context:f}),{_tag:`Request`,id:h,tag:e._tag,payload:s,...p?{traceId:p.traceId,spanId:p.spanId,sampled:p.sampled}:{},headers:dx(m.getRef(xR),c)}).pipe(p?yg(p,{captureStackTrace:!1}):i,sg(e=>(lf(e)||l.delete(h),R_(_,e))),fg,bg(ee,{startImmediately:!0})),_}),h=e=>{let t=[];for(let n of e.middlewares.values()){let e=da(s,`${n.key}/Client`);e&&t.push(e)}return t.length===0?(e,t)=>e(t):function n(r,i,a=t.length-1){return a===-1?r(i):t[a]({rpc:e,request:i,next(e){return n(r,e,a-1)}})}},g=(e,n,r)=>_h(i=>{let a=Ug();t.onFromClient({message:{_tag:`Interrupt`,requestId:e,interruptors:n},context:r}).pipe(Vh(1e3),wg(a.context)).addObserver(()=>{i(z)})}),ee=e=>{switch(e._tag){case`Chunk`:{let n=e.requestId,a=l.get(n);return!a||a._tag!==`Queue`?z:I_(a.queue,e.values).pipe(r?V(n=>n.length>0?z:t.onFromClient({message:{_tag:`Ack`,requestId:e.requestId},context:a.context})):i,Mh(e=>R_(a.queue,e)))}case`Exit`:{let t=e.requestId,n=l.get(t);return n?(l.delete(t),n._tag===`Effect`?(n.resume(e.exit),z):e.exit._tag===`Success`?B_(n.queue):R_(n.queue,e.exit.cause)):z}case`Defect`:return d(Of(e.defect));case`ClientEnd`:return z}},_;if(t.flatten){let t=new Map;_=function(n,r,i){let a=t.get(n);return a||(a=f(e.requests.get(n)),t.set(n,a)),a(r,i)}}else _={},e.requests.forEach(e=>{dt(_,e._tag,f(e))});return{client:_,write:ee}}),vR=0,yR=jg(function*(e,t){let n=vR++,{codecFor:r,run:i,send:a,supportsAck:o,supportsTransferables:s}=yield*SR,c=bR(r),l=mD(r(bO())),u=new Map,d=Ff(),f=e=>u.has(e)?(u.delete(e),a(n,{_tag:`Interrupt`,requestId:e})):z,{client:p,write:m}=yield*_R(e,{...t,supportsAck:o,onFromClient({message:t}){switch(t._tag){case`Request`:{let r=e.requests.get(t.tag),i=s?SN():void 0,o=Ug(),l={rpc:r,context:i?ca(o.context,xN,i):o.context,schemas:c(r),discard:t.discard===!0};return u.set(t.id,l),l.schemas.encodePayload(t.payload).pipe(Zh(l.context),Fh,V(e=>Bf(d)?(u.delete(t.id),dg):a(n,{...t,id:t.id,payload:e,headers:Object.entries(t.headers)},i&&i.readUnsafe())),sg(e=>lf(e)?z:R(()=>u.delete(t.id))))}case`Ack`:return u.get(t.requestId)?a(n,{_tag:`Ack`,requestId:t.requestId}):z;case`Interrupt`:return f(t.requestId);case`Eof`:return z}}});return yield*i(n,e=>{switch(e._tag){case`Chunk`:{let t=WN(e.requestId),n=u.get(t);if(!n||Cr(n.schemas.decodeChunk))return z;let r=n.schemas.decodeChunk.value;return hg(i=>i(r(e.values).pipe(Zh(n.context),Fh,V(e=>m({_tag:`Chunk`,clientId:0,requestId:t,values:e})))).pipe(sg(e=>m({_tag:`Exit`,clientId:0,requestId:t,exit:Ef(e)}).pipe(Dh(mf(e)?z:Gh(zh(f(t)),If(d))))),Nh(e=>!mf(e),()=>z)))}case`Exit`:{let t=WN(e.requestId),n=u.get(t);return n?(u.delete(t),n.discard&&e.exit._tag===`Success`?m({_tag:`Exit`,clientId:0,requestId:t,exit:Af}):(n.discard?n.schemas.decodeDiscardExit:n.schemas.decodeExit)(e.exit).pipe(Zh(n.context),Fh,qh({onSuccess:e=>m({_tag:`Exit`,clientId:0,requestId:t,exit:e}),onFailure:e=>m({_tag:`Exit`,clientId:0,requestId:t,exit:Ef(e)})}))):z}case`Defect`:return u.clear(),m({_tag:`Defect`,clientId:0,defect:l(e.defect)});case`ClientProtocolError`:{let t=Df(e.error),n=e.requestIds===void 0?Array.from(u.keys()):e.requestIds.map(WN).filter(e=>u.has(e));for(let e of n)u.delete(e);return fh(n,e=>m({_tag:`Exit`,clientId:0,requestId:e,exit:t})).pipe(mg)}default:return z}}).pipe(Mh(Mg),fg,xg),yield*ag(()=>Vf(d,void 0)),p}),bR=e=>{let t=new WeakMap;return n=>{let r=t.get(n);if(r!==void 0)return r;let i=kN(n.successSchema),a=D(n.annotations,RN),o=LN(n),s;return r={decodeChunk:Pr(i,t=>uD(e(HD(t.success)),a)),encodePayload:gD(e(n.payloadSchema),a),decodeExit:uD(e(o),a),decodeDiscardExit:t=>(s??=uD(e(AO(FD,o.error,o.defect)),a))(t)},t.set(n,r),r}},xR=O(`effect/rpc/RpcClient/CurrentHeaders`,{defaultValue:()=>ox}),SR=class extends Hi()(`effect/rpc/RpcClient/Protocol`){static make=hR},CR=e=>SR.make(jg(function*(t,n){let r=yield*$M,a=yield*uR,o=yield*Qh(DR),s=new Map,c=yield*r.writer,u=a.makeUnsafe(),d=yield*TR(L(()=>c.write(u.encode(GN))),e),f=Bh(e?.onPingTimeout??z,{log:!0,message:`RpcClient onPingTimeout hook failed`}),p,m=e=>{let r=fh(Array.from(n),n=>t(n,e));return e._tag!==`Defect`&&e._tag!==`ClientProtocolError`?r:(s.clear(),mg(r))},h=e=>(p=e,m({_tag:`ClientProtocolError`,error:e})),g=e=>{try{let n=u.decode(e);if(n.length===0)return z;d.onFrame();let r=0;return ph({while:()=>r<n.length,body:()=>{let e=n[r++];if(e._tag===`Pong`)return z;if(Object.hasOwn(e,`requestId`)){let n=e.requestId,r=s.get(n);if(r!==void 0)return e._tag===`Exit`&&s.delete(n),t(r,e)}return m(e)},step:l})}catch(e){return m({_tag:`ClientProtocolError`,error:new UN({reason:new HN({message:`Error decoding message`,cause:e})})})}};yield*L(()=>{u=a.makeUnsafe(),d.reset();let e=!1;return yh(function*(){let{pull:t}=yield*r.reader;for(p=void 0,e=!0,wr(o)&&(yield*o.value.onConnect);;){let e=yield*t;for(let t=0;t<e.length;t++)yield*g(e[t])}}).pipe(ng,Gh(d.timeout),Dh(()=>e?f:z),Dh(()=>B(new fN({reason:new oN({cause:Error(`ping timeout`)})}))))}).pipe(wr(o)?og(o.value.onDisconnect):i,Lh(t=>{let n=ff(t),r=Gr(n),i=new UN({reason:r?n.success.reason:new HN({message:`Unknown socket error`,cause:df(t)})});return e?.retryTransientErrors&&r&&n.success.reason._tag===`SocketOpenError`?(e.onTransientError?.(i)??z).pipe(Bh({log:!0,message:`RpcClient onTransientError hook failed`})):h(i)}),Rh(e?.retryPolicy??wR,e=>h(new UN({reason:e.reason}))),Ng({module:`RpcClient`,method:`makeProtocolSocket`}),xg);let ee=e=>L(()=>{let t=u.encode(e);return t===void 0?z:Fh(c.write(t))});return{send(e,t){return p?B(p):(t._tag===`Interrupt`&&s.delete(t.requestId),t._tag===`Request`?(s.set(t.id,e),sg(ee(t),()=>R(()=>s.delete(t.id)))):ee(t))},supportsAck:!0,supportsTransferables:!1,codecFor:a.codecFor}})),wR=Jm([Xm(500,1.5),Zm(5e3)]),TR=jg(function*(e,t){let n=yield*Sf,r=t?.pingInterval??`5 seconds`,i=uo(t?.pingTimeout??r),a=n.currentTimeMillisUnsafe(),o=!1,s=t_(),c=()=>{a=n.currentTimeMillisUnsafe(),o=!1};return yield*L(()=>o&&n.currentTimeMillisUnsafe()-a>i?s.open:(o=!0,e)).pipe(Uh(r),zh,gg,fg,xg),{timeout:s.await,reset:()=>{c(),s.closeUnsafe()},onFrame:c}}),ER=e=>gp(SR)(CR(e)),DR=class extends Hi()(`effect/rpc/RpcClient/ConnectionHooks`){},OR=()=>(e,t)=>{let n=Hi()(e),r=gp(n,t.makeEffect??yR(t.group,{...t,flatten:!0}));n.runtime=(t.runtime??jM)(typeof t.protocol==`function`?e=>Sp(r,wp(t.protocol(e))):Sp(r,wp(t.protocol))),n.mutation=UM(r=>{let i=t.group.requests.get(r);return n.runtime.fn()(jg(function*({headers:e,payload:t,reactivityKeys:i}){let a=(yield*n)(r,t,{headers:e});return yield*i?Dj(a,i):a})).pipe(YM({key:`AtomRpc:mutation:${JSON.stringify([e,r])}`,schema:Sj({success:i.successSchema,error:kR(i)})}))});let i=UM(e=>{let{headers:r,payload:i,reactivityKeys:a,tag:o,timeToLive:s}=e,c=t.group.requests.get(o),l=ON(c.successSchema),u=l?n.runtime.pull(xy(n.use(e=>I(e(o,i,{headers:r}))))):n.runtime.atom(n.use(e=>e(o,i,{headers:r})));return a&&(u=n.runtime.factory.withReactivity(a)(u)),!l&&e.serializationKey&&(u=YM(u,{key:`AtomRpc:${e.tag}:${e.serializationKey}`,schema:Sj({success:c.successSchema,error:kR(c)})})),s&&(u=$a(s)?dM(u,s):WM(u)),u});return n.query=(e,t,n)=>{let r={tag:e,payload:t,headers:n?.headers?sx(n.headers):void 0,reactivityKeys:n?.reactivityKeys,timeToLive:n?.timeToLive===void 0?void 0:Ha(n.timeToLive),serializationKey:n?.serializationKey};return i(r)},n},kR=e=>WD([e.errorSchema,...Array.from(e.middlewares,e=>e.error),UN]),AR={add(...e){let t=new Map(this.requests);for(let n of e)t.set(n._tag,n);return jR({requests:t,annotations:this.annotations})},merge(...e){let t=new Map(this.requests),n=new Map(this.annotations.mapUnsafe);for(let r of e){for(let[e,n]of r.requests)t.set(e,n);for(let[e,t]of r.annotations.mapUnsafe)n.set(e,t)}return jR({requests:t,annotations:ea(n)})},omit(...e){let t=new Map(this.requests);for(let n of e)t.delete(n);return jR({requests:t,annotations:this.annotations})},middleware(e){let t=new Map;for(let[n,r]of this.requests)t.set(n,r.middleware(e));return jR({requests:t,annotations:this.annotations})},toHandlers(e){let t=this;return yh(function*(){let n=yield*Jh(),r=dh(e)?yield*e:e,i=new Map;return t.requests.forEach((e,t)=>{i.set(e.key,{tag:e._tag,handler:r[t],context:n})}),ea(i)})},prefix(e){let t=new Map;for(let n of this.requests.values()){let r=n.prefix(e);t.set(r._tag,r)}return jR({requests:t,annotations:this.annotations})},toLayer(e){return vp(this.toHandlers(e))},of:i,toLayerHandler(e,t){let n=this;return vp(yh(function*(){let r=yield*Jh(),i=dh(t)?yield*t:t,a=new Map,o=n.requests.get(e);return a.set(o.key,{handler:i,context:r}),ea(a)}))},accessHandler(e){return Yh(t=>{let n=this.requests.get(e),{handler:r,context:i}=da(t,n.key);return I((e,t)=>{t.rpc=n;let a=r(e,t),o=BN(a)?a.value:a;return dh(o)?Xh(o,i):Oy(o,i)})})},annotate(e,t){return jR({requests:this.requests,annotations:ca(this.annotations,e,t)})},annotateRpcs(e,t){return this.annotateRpcsMerge(sa(e,t))},annotateMerge(e){return jR({requests:this.requests,annotations:_a(this.annotations,e)})},annotateRpcsMerge(e){let t=new Map;for(let[n,r]of this.requests)t.set(n,r.annotateMerge(_a(e,r.annotations)));return jR({requests:t,annotations:this.annotations})}},jR=e=>Object.assign(function(){},AR,{requests:e.requests,annotations:e.annotations}),MR=(...e)=>jR({requests:new Map(e.map(e=>[e._tag,e])),annotations:aa()}),NR=`~effect/rpc/RpcMiddleware`,PR=()=>(e,t)=>{let n=It(),r;n!==0&&(Lt(2),r=new globalThis.Error,Lt(n));function i(){}let a=i;return Object.setPrototypeOf(i,Object.getPrototypeOf(Hi(e))),i.key=e,Object.defineProperty(i,"stack",{get(){return r?.stack}}),a[NR]=NR,a.error=t?.error??OD,a.requiredForClient=t?.requiredForClient??!1,i},FR=(e,t)=>vp(yh(function*(){let n=(yield*Jh()).pipe(ya(Gf)),r=dh(t)?yield*t:t;return ea(new Map([[`${e.key}/Client`,e=>$h(r(e),e=>_a(n,e))]]))}));export{RD as $,ie as $n,Cf as $t,Ek as A,Lr as An,R as At,bO as B,Tr as Bn,Tm as Bt,_j as C,Si as Cn,Dh as Ct,gA as D,ii as Dn,Dg as Dt,SA as E,$r as En,H as Et,QO as F,jr as Fn,xm as Ft,KO as G,fr as Gn,Cm as Gt,aO as H,E as Hn,Am as Ht,ek as I,Cr as In,Om as It,pO as J,v as Jn,ym as Jt,DD as K,mr as Kn,Em as Kt,$O as L,wr as Ln,km as Lt,Ok as M,Or as Mn,hh as Mt,pk as N,kr as Nn,Zm as Nt,Qk as O,Kr as On,Wh as Ot,fk as P,Er as Pn,Qm as Pt,q as Q,fe as Qn,jf as Qt,VD as R,Rr as Rn,Sm as Rt,nj as S,Ii as Sn,xy as St,jA as T,ti as Tn,yh as Tt,fO as U,hr as Un,jm as Ut,kO as V,Dr as Vn,Dm as Vt,GO as W,pr as Wn,wm as Wt,LD as X,be as Xn,Sp as Xt,gO as Y,ae as Yn,bm as Yt,jD as Z,de as Zn,Cp as Zt,Vj as _,Ri as _n,jb as _t,ER as a,lo as an,fD as at,uj as b,li as bn,wy as bt,bN as c,wi as cn,lD as ct,RM as d,Fi as dn,rO as dt,pf as en,_e as er,HO as et,ZM as f,Ni as fn,xD as ft,Uj as g,gi as gn,lx as gt,jM as h,yi as hn,GE as ht,OR as i,$a as in,qD as it,Dk as j,Fr as jn,Ih as jt,kk as k,zr as kn,I as kt,hN as l,Oi as ln,uO as lt,xM as m,Mi as mn,$D as mt,FR as n,gf as nn,re as nr,kD as nt,mR as o,Hi as on,_D as ot,WM as p,Ci as pn,bD as pt,GD as q,Et as qn,vm as qt,MR as r,df as rn,u as rr,nD as rt,FN as s,zi as sn,SO as st,PR as t,Zd as tn,ge as tr,WD as tt,UM as u,ki as un,iO as ut,bj as v,ji as vn,Mb as vt,QA as w,Zr as wn,V as wt,cj as x,Pi as xn,uy as xt,vj as y,di as yn,Sy as yt,ND as z,Pr as zn,Mm as zt};
|