expandai 0.1.4 → 0.1.5
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/build/dts/Mcp/Server.d.ts +1 -1
- package/build/esm/index.js +2 -2
- package/build/esm/main.js +2 -2
- package/package.json +3 -3
|
@@ -2,7 +2,7 @@ import { Layer } from 'effect';
|
|
|
2
2
|
export { CurrentRequestHeaders } from './RequestHeaders.js';
|
|
3
3
|
export declare const ServerInfo: {
|
|
4
4
|
readonly name: "expandai";
|
|
5
|
-
readonly version: "0.1.
|
|
5
|
+
readonly version: "0.1.5";
|
|
6
6
|
};
|
|
7
7
|
export declare const makeServerLayer: (options?: {
|
|
8
8
|
readonly includeDocs?: boolean;
|
package/build/esm/index.js
CHANGED
|
@@ -177,10 +177,10 @@ schema (${n._tag}): ${n}`;return o},i7=(e)=>ei("Invalid Argument",e),mFe=(e,t,r)
|
|
|
177
177
|
`,a);else e=e+"\r";t=!1}while(c!==-1||l!==-1)if(c===-1||l!==-1&&l<c){if(e.length===0)s.push(i.substring(a,l));else s.push(e+i.substring(a,l)),e="";a=l+1,l=i.indexOf(`
|
|
178
178
|
`,a)}else if(i.length===c+1)t=!0,c=-1;else if(l===c+1){if(e.length===0)s.push(i.substring(a,c));else e=e+i.substring(a,c),s.push(e),e="";a=c+2,c=i.indexOf("\r",a),l=i.indexOf(`
|
|
179
179
|
`,a)}else c=i.indexOf("\r",c+1);if(t)e=e+i.substring(a,i.length-1);else e=e+i.substring(a,i.length)}}),Qr(s)},n=as({onInput:(o)=>{let s=r(o);return Vs(s)?n:Ze(ht(s),()=>n)},onFailure:(o)=>e.length===0?ur(o):Ze(ht(at(e)),()=>ur(o)),onDone:(o)=>e.length===0?ja(o):Ze(ht(at(e)),()=>ja(o))});return n});var ex=h(2,(e,t)=>Ui(se(()=>new Ef(e,void 0,X)),ts()).pipe(Er(([r,n])=>Ik(t,(o)=>{let s=r.close(o);return s!==void 0?Jn(s,n):Y})),_i,z(([r])=>Te(()=>e1(r.run(),r))))),e1=(e,t)=>{let r=e;switch(r._tag){case df:return bs(t.getDone(),{onFailure:kr,onSuccess:(n)=>Z(he(n))});case hf:return Z(me(t.getEmit()));case au:return E(r.effect,w(()=>e1(t.run(),t)));case mf:return bD(r,()=>e1(t.run(),t),(n)=>kr(n))}};var $a=(e)=>lre(Zt(e)),Sh=(e)=>gD(UD(e),(t,r)=>t,(t,r)=>t),bI=(e)=>gD(s1(e),(t,r)=>t,(t,r)=>t);var ox=(e)=>fre(0,e.length,e),fre=(e,t,r)=>e===t?jn:E(ht(E(r,ya(e))),Ze(()=>fre(e+1,t,r))),Are=h((e)=>hD(e[1]),(e,t,r)=>r?.concurrent?ND(e,{other:t,onSelfDone:(n)=>V2((o)=>Te(()=>AL(n,o))),onOtherDone:(n)=>V2((o)=>Te(()=>AL(o,n)))}):Ze(e,(n)=>vD(t,(o)=>[n,o])));var cu=h((e)=>hD(e[1]),(e,t,r)=>r?.concurrent?vD(Are(e,t,{concurrent:!0}),(n)=>n[1]):Ze(e,()=>t)),kD=Symbol.for("effect/Channel/ChannelException"),dre=(e)=>({_tag:"ChannelException",[kD]:kD,error:e}),hre=(e)=>ee(e,kD);var mre=Symbol.for("effect/RcRef"),a1={_tag:"Empty"},HNe={_tag:"Closed"},WNe={_A:X,_E:X};class gre extends Is{acquire;context;scope;idleTimeToLive;[mre]=WNe;[Na]=Na;state=a1;semaphore=aE(1);constructor(e,t,r,n){super();this.acquire=e,this.context=t,this.scope=r,this.idleTimeToLive=n,this.get=c1(this)}get;commit(){return this.get}}var Ere=(e)=>rt((t)=>{let r=t.getFiberRef(Hn),n=Ot(r,Bs),o=new gre(e.acquire,r,n,e.idleTimeToLive?to(e.idleTimeToLive):void 0);return nr(n.addFinalizer(()=>o.semaphore.withPermits(1)(Me(()=>{let s=o.state._tag==="Acquired"?Ec(o.state.scope,Rr):tt;return o.state=HNe,s}))),o)}),c1=(e)=>{let t=e,r=t.idleTimeToLive&&!PQ(t.idleTimeToLive);return Dn((n)=>Me(()=>{switch(t.state._tag){case"Closed":return Cs;case"Acquired":return t.state.refCount++,t.state.fiber?nr(Qp(t.state.fiber),t.state):te(t.state);case"Empty":return Gp().pipe(jC("scope"),zC("value",({scope:o})=>n(js(t.acquire,Hn,dr(t.context,Bs,o)))),Qe(({scope:o,value:s})=>{let i={_tag:"Acquired",value:s,scope:o,fiber:void 0,refCount:1};return t.state=i,i}))}})).pipe(t.semaphore.withPermits(1),jC("state"),zC("scope",()=>Bs),zs(({scope:n,state:o})=>n.addFinalizer(()=>Me(()=>{if(o.refCount--,o.refCount>0||r)return tt;if(t.idleTimeToLive===void 0)return t.state=a1,Ec(o.scope,Rr);return _p(t.idleTimeToLive).pipe(Ol,xt(Me(()=>{if(t.state._tag==="Acquired"&&t.state.refCount===0)return t.state=a1,Ec(o.scope,Rr);return tt})),_a(j(()=>{o.fiber=void 0})),aS(t.scope),zs((s)=>{o.fiber=s}),t.semaphore.withPermits(1))}))),Qe(({state:n})=>n.value))};var xre=Ere,l1=c1;var Cre=Symbol.for("effect/Sink"),i_e={_A:(e)=>e,_In:(e)=>e,_L:(e)=>e,_E:(e)=>e,_R:(e)=>e};class Hc{channel;[Cre]=i_e;constructor(e){this.channel=e}pipe(){return W(this,arguments)}}var Sre=(e)=>new Hc(zi(()=>Ih(e())));var u1=()=>new Hc(Ire(Lt())),Ire=(e)=>as({onInput:(t)=>Ire(E(e,$t(t))),onFailure:ur,onDone:()=>ja(e)});var PD=new Hc(tx(SI()));var bre=(e,t,r)=>Sre(()=>new Hc(Bre(e,t,r))),Bre=(e,t,r)=>{if(!t(e))return cs(e);return za({onInput:(n)=>Bre(r(e,n),t,r),onFailure:Ji,onDone:()=>cs(e)})};var Qre=(e,t)=>bre(e,Io,t);var HD=(e)=>{let t=as({onInput:(r)=>E(Zt(Kt(r,(n)=>e(n),{discard:!0})),Ze(()=>t)),onFailure:ur,onDone:()=>jn});return new Hc(t)},p1=(e)=>{let t=as({onInput:(r)=>E(Zt(e(r)),Ze(()=>t)),onFailure:ur,onDone:()=>jn});return new Hc(t)};var f1=(e)=>new Hc(e),A1=(e)=>new Hc(Zt(e));var Ih=(e)=>tn(e)?Ih(A1(e)):e.channel;var wre=(e)=>new Hc(Sh(e.pipe(z((t)=>Ih(t)))));var kre=(e)=>Object.assign(e,{chunk(r){return this(Z(r))},die(r){return this(Mo(r))},dieMessage(r){return this(Yd(r))},done(r){return this(Te(()=>fL(r,{onFailure:M,onSuccess:at})))},end(){return this(ce(T()))},fail(r){return this(ce(M(r)))},fromEffect(r){return this(dE(r,{onFailure:M,onSuccess:at}))},fromEffectChunk(r){return this(E(r,De(M)))},halt(r){return this(kr(E(r,Gl(M))))},single(r){return this(Z(at(r)))}});var l_e="effect/Take",u_e=Symbol.for(l_e),p_e={_A:(e)=>e,_E:(e)=>e};class WD{exit;[u_e]=p_e;constructor(e){this.exit=e}pipe(){return W(this,arguments)}}var qD=(e)=>new WD(Oo(e));var Dre=(e)=>Te(()=>e.exit),GD=new WD(Pl(T()));var YD=(e)=>new WD(En(E(e,Gl(M))));var Tre=(e)=>zd(e,{onFailure:(t)=>Ge(dk(t),{onNone:()=>GD,onSome:YD}),onSuccess:qD});var d1=h(2,(e,{onEnd:t,onFailure:r,onSuccess:n})=>bs(e.exit,{onFailure:(o)=>Ge(dk(o),{onNone:t,onSome:r}),onSuccess:n}));var vre=()=>ce(T());var F_e="effect/Stream",VD=Symbol.for(F_e),M_e={_R:(e)=>e,_E:(e)=>e,_A:(e)=>e};class Vr{channel;[VD]=M_e;constructor(e){this.channel=e}pipe(){return W(this,arguments)}}var sx=(e)=>ee(e,VD)||tn(e);var N_e=(e)=>{if(e==="unbounded")return lI();else if(typeof e==="number"||e===void 0)return VE(e??16);switch(e.strategy){case"dropping":return X0(e.bufferSize??16);case"sliding":return eD(e.bufferSize??16);default:return VE(e.bufferSize??16)}};var Nre=(e,t)=>E(Mt(N_e(t),(r)=>su(r)),w((r)=>E(ts(),w((n)=>E(e(kre((o)=>E(Tre(o),w((s)=>Vi(r,s)),Pa,k6(n)).then((s)=>{if(vo(s)){if(!Pd(s.cause))throw bc(s.cause)}}))),ve(Oi(!1)),w((o)=>E(Dd(o),z((s)=>s?vre():E(xh(r),w(Dre),SS(()=>E(Vg(o,!0),ve(su(r)))))))))))),S1,g1(y1));var _re=h(2,(e,t)=>{if(t.strategy==="dropping")return __e(e,t.capacity);else if(t.strategy==="sliding")return U_e(e,t.capacity);let r=ine(e,t);return new Vr(Sh(z(r,(n)=>{let o=E(Zt(xh(n)),Ze(d1({onEnd:()=>jn,onFailure:ur,onSuccess:(s)=>E(ht(s),Ze(()=>o))})));return o})))}),__e=h(2,(e,t)=>{let r=Mt(X0(t),(n)=>su(n));return new Vr(Ure(r,yr(e)))}),U_e=h(2,(e,t)=>{let r=Mt(eD(t),(n)=>su(n));return new Vr(Ure(r,yr(e)))});var Ure=(e,t)=>{let r=(o,s)=>{let i=(a)=>E(Dd(s),Er(ut),ve(Pt()),w((c)=>E(Vi(o,[a,c]),ve(Vg(s,c)),ve(ut(c)))),Pa,Zt);return as({onInput:(a)=>E(Pt(),w((c)=>E(Vi(o,[qD(a),c]),w((l)=>E(Vg(s,c),Ha(()=>l))))),Pa,Zt,Ze(()=>r(o,s))),onFailure:(a)=>i(YD(a)),onDone:()=>i(GD)})},n=(o)=>{let s=E(Zt(xh(o)),Ze(([i,a])=>cu(Zt(Gn(a,void 0)),d1(i,{onEnd:()=>jn,onFailure:ur,onSuccess:(c)=>E(ht(c),Ze(()=>s))}))));return s};return Sh(E(e,w((o)=>E(Pt(),Er((s)=>Gn(s,void 0)),w((s)=>E(Oi(s),w((i)=>E(t,sn(r(o,i)),_D,rf)),go(n(o))))))))},h1=h(2,(e,t)=>Lre(e,(r)=>Lr(nE(r),{onLeft:t,onRight:Gre}))),Lre=h(2,(e,t)=>new Vr(E(yr(e),zE((r)=>yr(t(r))))));var Pre=h(3,(e,t,r)=>h1(e,(n)=>{if("_tag"in n&&n._tag===t)return r(n);return m1(n)}));var Hre=(e)=>BI(Mo(e));var Wre=new Vr(jn),qre=h(2,(e,t)=>new Vr(E(yr(e),rx(t))));var m1=(e)=>x1(ce(M(e)));var Gre=(e)=>BI(kr(e));var g1=h((e)=>sx(e[0]),(e,t,r)=>{let n=r?.bufferSize??16;if(r?.switch)return Ore(r?.concurrency,()=>Fre(e,1,n,t),(o)=>Fre(e,o,n,t));return Ore(r?.concurrency,()=>new Vr(CI(yr(e),(o)=>E(o,sp((s)=>yr(t(s))),sC(jn,(s,i)=>E(s,cu(i)))))),(o)=>new Vr(E(yr(e),CI(ox),MD((s)=>yr(t(s)),r))))}),Ore=(e,t,r)=>{switch(e){case void 0:return t();case"unbounded":return r(Number.MAX_SAFE_INTEGER);default:return e>1?r(e):t()}},Fre=h(4,(e,t,r,n)=>new Vr(E(yr(e),CI(ox),MD((o)=>yr(n(o)),{concurrency:t,mergeStrategy:ere(),bufferSize:r})))),E1=h((e)=>sx(e[0]),(e,t)=>g1(e,X,t));var JD=(e)=>new Vr(e),yr=(e)=>{if("channel"in e)return e.channel;else if(tn(e))return yr(BI(e));else throw TypeError("Expected a Stream.")};var BI=(e)=>E(e,De(M),x1),x1=(e)=>new Vr($a(Xk(e,{onFailure:Ge({onNone:()=>jn,onSome:Ji}),onSuccess:(t)=>ht(at(t))})));var Yre=(...e)=>{let t=e.length===1?e[0].evaluate:e[0],r=e.length===1?e[0].onError:e[1],n=e.length===1?e[0].releaseLockOnEnd===!0:!1;return b1(z(Mt(se(()=>t().getReader()),(o)=>n?se(()=>o.releaseLock()):AE(()=>o.cancel())),(o)=>ene(w(lr({try:()=>o.read(),catch:(s)=>M(r(s))}),({done:s,value:i})=>s?ce(T()):Z(i)))))};var Vre=h(2,(e,t)=>new Vr(E(yr(e),nx(sp(t)))));var Jre=h(2,(e,t)=>new Vr(E(yr(e),nx(t)))),zre=h(2,(e,t)=>new Vr(E(yr(e),FD(t))));var jre=h(2,(e,t)=>new Vr(E(yr(e),OD(t))));var $re=(e)=>E(e,Kre(X)),Kre=h(2,(e,t)=>new Vr(E(yr(e),r1(t))));var Zre=h(2,(e,t)=>new Vr(sn(yr(e),t)));var Xre=h(2,(e,t)=>new Vr(E(yr(e),hI(t))));var y1=(e)=>une(e,(t)=>E(z(t,(r)=>M([r,t])),Vn(Ge({onNone:()=>Z(T()),onSome:ce})))),ene=(e)=>y1(E(e,z(at)));var ix=h(2,(e,t)=>yr(e).pipe(II(Ih(t)),o1)),tne=(e)=>ix(e,u1());var rne=(e)=>ix(e,PD);var nne=h(2,(e,t)=>ix(e,HD(t))),C1=h(2,(e,t)=>ix(e,p1(t)));var one=h(2,(e,t)=>{let r=as({onInput:(n)=>Ze(ht(qD(n)),()=>r),onFailure:(n)=>ht(YD(n)),onDone:()=>ht(GD)});return E(sn(yr(e),r),FD((n)=>Vi(t,n)),tx,_D,Pa)});var S1=(e)=>new Vr(rx(UD(E(e,z(at))),Y));var sne=(e)=>Zre(e,i1());var I1=(e)=>new Vr(zi(()=>yr(e())));var ine=h((e)=>sx(e[0]),(e,t)=>Er(Mt(t?.strategy==="unbounded"?lI():t?.strategy==="dropping"?X0(t.capacity??2):t?.strategy==="sliding"?eD(t.capacity??2):VE(t?.capacity??2),(r)=>su(r)),(r)=>rf(one(e,r))));var ane=h((e)=>sx(e[0]),(e,t)=>z(ts(),(r)=>cne(e,r,t))),cne=h((e)=>sx(e[0]),(e,t,r)=>{let n=rs(t),o=void 0,s=void 0,i=Tc(!1);return new ReadableStream({start(a){s=n(C1(e,(c)=>{if(c.length===0)return Y;return i.whenOpen(se(()=>{i.unsafeClose();for(let l of c)a.enqueue(l);o(),o=void 0}))})),s.addObserver((c)=>{try{if(c._tag==="Failure")a.error(bc(c.cause));else a.close()}catch{}})},pull(){return new Promise((a)=>{o=a,on(i.open)})},cancel(){if(!s)return;return t0(Pa(Xo(s)))}},r?.strategy)}),lne=h(2,(e,t)=>{let r=zi(()=>{let n={ref:Lt()},o={ref:!1},s=zi(()=>{let l=n.ref;if(Vs(l))return za({onInput:(u)=>E(ht(u),Ze(()=>s)),onFailure:Ji,onDone:cs});return n.ref=Lt(),E(ox(l),Ze(()=>s))}),i=(l)=>{let u=n.ref,p=$t(u,eg(l,(f)=>f.length!==0));return n.ref=p,p},a=za({onInput:(l)=>Ze(ht(l),()=>a),onFailure:Ji,onDone:(l)=>cu(iu(()=>{o.ref=!0}),cs(l))}),c=E(t,Ih,mD,Ze(([l,u])=>E(ja([o.ref,i(l)]),Ze(([p,f])=>{let A=p&&Vs(f)?jn:c;return E(ht(at(u)),Ze(()=>A))}))));return E(yr(e),sn(a),sn(s),II(c))});return new Vr(r)});var une=(e,t)=>I1(()=>{let r=(n)=>$a(z(t(n),Ge({onNone:()=>jn,onSome:([o,s])=>Ze(ht(o),()=>r(s))})));return new Vr(r(e))});var pne=(e)=>E1(BI(e)),b1=(e)=>E1(S1(e));var B1=VD;var Ane=Nre;var dne=_re,Q1=h1;var L_e=Pre;var hne=Hre;var mne=Wre,gne=qre;var zD=m1;var bh=JD;var Ene=Yre;var xne=Vre;var yne=Jre,Cne=zre;var Sne=jre;var Ine=$re;var jD=Xre;var xf=ix,bne=tne;var P_e=rne;var w1=nne,QI=C1;var Bne=sne;var Qne=I1;var wne=ane;var Rne=lne;var wI=pne,Wc=b1;var kne=Symbol.for("effect/Brand/Refined");var RI=()=>Object.assign((e)=>e,{[kne]:kne,option:(e)=>M(e),either:(e)=>me(e),is:(e)=>!0});var Tne=PD;var vne=Qre;var One=HD;var Fne=f1;var Mne=wre;var R1=Symbol.for("@effect/platform/CommandExecutor"),Nne=Symbol.for("@effect/platform/Process"),_ne=RI(),Une=RI(),KD=Ke("@effect/platform/CommandExecutor"),Lne=(e)=>{let t=(n)=>Wc(z(e(n),(o)=>o.stdout)),r=(n,o)=>{let s=new TextDecoder(o);return Bne(yne(t(n),sp((i)=>s.decode(i))))};return{[R1]:R1,start:e,exitCode:(n)=>ro(w(e(n),(o)=>o.exitCode)),stream:t,string:(n,o="utf-8")=>{let s=new TextDecoder(o);return E(e(n),w((i)=>xf(i.stdout,H_e)),z((i)=>s.decode(i)),ro)},lines:(n,o="utf-8")=>E(r(n,o),bne,z(Tj)),streamLines:r}},H_e=vne(new Uint8Array,(e,t)=>sC(t,e,(r,n)=>{let o=new Uint8Array(r.length+n.length);return o.set(r),o.set(n,r.length),o}));var k1=Symbol.for("@effect/platform/Command");var Hne=(e)=>Array.from(D1(e)),D1=(e)=>{switch(e._tag){case"StandardCommand":return at(e);case"PipedCommand":return $t(D1(e.left),D1(e.right))}};var Wne={[k1]:k1,pipe(){return W(this,arguments)},...Ws},W_e={...Wne,_tag:"StandardCommand",toJSON(){return{_id:"@effect/platform/Command",_tag:this._tag,command:this.command,args:this.args,env:Object.fromEntries(this.env),cwd:this.cwd.toJSON(),shell:this.shell,gid:this.gid.toJSON(),uid:this.uid.toJSON()}}},ZD=(e)=>Object.assign(Object.create(W_e),e),q_e={...Wne,_tag:"PipedCommand",toJSON(){return{_id:"@effect/platform/Command",_tag:this._tag,left:this.left.toJSON(),right:this.right.toJSON()}}},T1=(e)=>Object.assign(Object.create(q_e),e),qne=(e,...t)=>ZD({command:e,args:t,env:Rl(),cwd:T(),shell:!1,stdin:"pipe",stdout:"pipe",stderr:"pipe",gid:T(),uid:T()});var v1=h(2,(e,t)=>{switch(e._tag){case"StandardCommand":return ZD({...e,stderr:t});case"PipedCommand":return T1({...e,right:v1(e.right,t)})}}),O1=h(2,(e,t)=>{switch(e._tag){case"StandardCommand":return ZD({...e,stdin:t});case"PipedCommand":return T1({...e,left:O1(e.left,t)})}}),F1=h(2,(e,t)=>{switch(e._tag){case"StandardCommand":return ZD({...e,stdout:t});case"PipedCommand":return T1({...e,right:F1(e.right,t)})}}),Gne=(e)=>w(KD,(t)=>t.start(e));var M1=Hne;var Yne=qne;var Y_e=Gne;var V_e=v1,XD=O1,J_e=F1;var kI=KD,N1=Nne,Vne=_ne,Jne=Une,zne=Lne;var tT=Symbol.for("@effect/platform/Error");var qc=(e,t)=>{class r extends dS{_tag=t}return r.prototype[e]=e,r.prototype.name=t,r},jne=_("Clipboard","Command","FileSystem","KeyValueStore","Path","Stream","Terminal");class ls extends ot("@effect/platform/Error/BadArgument")("BadArgument",{module:jne,method:m,description:U(m),cause:U(bt)}){[tT]=tT;get message(){return`${this.module}.${this.method}${this.description?`: ${this.description}`:""}`}}var z_e=_("AlreadyExists","BadResource","Busy","InvalidData","NotFound","PermissionDenied","TimedOut","UnexpectedEof","Unknown","WouldBlock","WriteZero");class lu extends ot("@effect/platform/Error/SystemError")("SystemError",{reason:z_e,module:jne,method:m,description:U(m),syscall:U(m),pathOrDescriptor:U(Ie(m,re)),cause:U(bt)}){[tT]=tT;get message(){return`${this.reason}: ${this.module}.${this.method}${this.pathOrDescriptor!==void 0?` (${this.pathOrDescriptor})`:""}${this.description?`: ${this.description}`:""}`}}var U1=Symbol.for("@effect/platform/Cookies"),j_e=(e)=>ee(e,U1),$ne=Symbol.for("@effect/platform/Cookies/Cookie");var $_e={[U1]:U1,...Ws,toJSON(){return{_id:"@effect/platform/Cookies",cookies:Ej(this.cookies,(e)=>e.toJSON())}},pipe(){return W(this,arguments)}},K_e=(e)=>{let t=Object.create($_e);return t.cookies=e,t},Zne=(e)=>{let t={};for(let r of e)t[r.name]=r;return K_e(t)},cx=(e)=>{let t=typeof e==="string"?[e]:e,r=[];for(let n of t){let o=Z_e(n.trim());if(de(o))r.push(o.value)}return Zne(r)};function Z_e(e){let t=e.split(";").map((a)=>a.trim()).filter((a)=>a!=="");if(t.length===0)return T();let r=t[0].indexOf("=");if(r===-1)return T();let n=t[0].slice(0,r);if(!X_e.test(n))return T();let o=t[0].slice(r+1),s=eoe(o);if(t.length===1)return M(Object.assign(Object.create(Kne),{name:n,value:s,valueEncoded:o}));let i={};for(let a=1;a<t.length;a++){let c=t[a],l=c.indexOf("="),u=l===-1?c:c.slice(0,l).trim(),p=l===-1?void 0:c.slice(l+1).trim();switch(u.toLowerCase()){case"domain":{if(p===void 0)break;let f=p.trim().replace(/^\./,"");if(f)i.domain=f;break}case"expires":{if(p===void 0)break;let f=new Date(p);if(!isNaN(f.getTime()))i.expires=f;break}case"max-age":{if(p===void 0)break;let f=parseInt(p,10);if(!isNaN(f))i.maxAge=cC(f);break}case"path":{if(p===void 0)break;if(p[0]==="/")i.path=p;break}case"priority":{if(p===void 0)break;switch(p.toLowerCase()){case"low":i.priority="low";break;case"medium":i.priority="medium";break;case"high":i.priority="high";break}break}case"httponly":{i.httpOnly=!0;break}case"secure":{i.secure=!0;break}case"partitioned":{i.partitioned=!0;break}case"samesite":{if(p===void 0)break;switch(p.toLowerCase()){case"lax":i.sameSite="lax";break;case"strict":i.sameSite="strict";break;case"none":i.sameSite="none";break}break}}}return M(Object.assign(Object.create(Kne),{name:n,value:s,valueEncoded:o,options:Object.keys(i).length>0?i:void 0}))}var uu=Zne([]),L1=(e)=>rN(e.cookies),X_e=/^[\u0009\u0020-\u007e\u0080-\u00ff]+$/,Kne={[$ne]:$ne,...Ws,toJSON(){return{_id:"@effect/platform/Cookies/Cookie",name:this.name,value:this.value,options:this.options}}};var eUe=h((e)=>j_e(e[0]),(e,t)=>gj(e.cookies,t));function tUe(e){let t=e.name+"="+e.valueEncoded;if(e.options===void 0)return t;let r=e.options;if(r.maxAge!==void 0){let n=bN(r.maxAge);t+="; Max-Age="+Math.trunc(n)}if(r.domain!==void 0)t+="; Domain="+r.domain;if(r.path!==void 0)t+="; Path="+r.path;if(r.priority!==void 0)switch(r.priority){case"low":t+="; Priority=Low";break;case"medium":t+="; Priority=Medium";break;case"high":t+="; Priority=High";break}if(r.expires!==void 0)t+="; Expires="+r.expires.toUTCString();if(r.httpOnly)t+="; HttpOnly";if(r.secure)t+="; Secure";if(r.partitioned)t+="; Partitioned";if(r.sameSite!==void 0)switch(r.sameSite){case"lax":t+="; SameSite=Lax";break;case"strict":t+="; SameSite=Strict";break;case"none":t+="; SameSite=None";break}return t}var rT=(e)=>Object.values(e.cookies).map(tUe);function Xne(e){let t={},r=e.length,n=0,o=0;while(!0){if(o===r)break;if(o=e.indexOf(";",n),o===-1)o=r;let s=e.indexOf("=",n);if(s===-1)break;if(s>o){n=o+1;continue}let i=e.substring(n,s++).trim();if(t[i]===void 0){let a=e.charCodeAt(s)===34?e.substring(s+1,o-1).trim():e.substring(s,o).trim();t[i]=a.indexOf("%")!==-1?eoe(a):a}n=o+1}return t}var eoe=(e)=>{try{return decodeURIComponent(e)}catch{return e}};var toe=Symbol.for("@effect/platform/Headers");var DI=Object.assign(Object.create(null),{[toe]:toe,[Jy](e){return Bh(this,CR(e,TI))}}),nT=(e)=>Object.assign(Object.create(DI),e);var oi=Object.create(DI),Kn=(e)=>{if(e===void 0)return oi;else if(Symbol.iterator in e){let r=Object.create(DI);for(let[n,o]of e)r[n.toLowerCase()]=o;return r}let t=Object.create(DI);for(let[r,n]of Object.entries(e))if(Array.isArray(n))t[r.toLowerCase()]=n.join(", ");else if(n!==void 0)t[r.toLowerCase()]=n;return t},pu=(e)=>Object.setPrototypeOf(e,DI);var Cf=h(3,(e,t,r)=>{let n=nT(e);return n[t.toLowerCase()]=r,n}),P1=h(2,(e,t)=>nT({...e,...Kn(t)})),Ka=h(2,(e,t)=>{let r=nT(e);return Object.assign(r,t),r}),H1=h(2,(e,t)=>{let r=nT(e),n=(o)=>{if(typeof o==="string"){let s=o.toLowerCase();if(s in e)delete r[s]}else for(let s in e)if(o.test(s))delete r[s]};if(Array.isArray(t))for(let o=0;o<t.length;o++)n(t[o]);else n(t);return r}),Bh=h(2,(e,t)=>{let r={...e},n=(o)=>{if(typeof o==="string"){let s=o.toLowerCase();if(s in e)r[s]=Mc(e[s])}else for(let s in e)if(o.test(s))r[s]=Mc(e[s])};if(Array.isArray(t))for(let o=0;o<t.length;o++)n(t[o]);else n(t);return r}),TI=Ae("@effect/platform/Headers/currentRedactedNames",()=>Pi(["authorization","cookie","set-cookie","x-api-key"]));var roe=Symbol.for("@effect/platform/HttpClientError");var noe=roe;class si extends qc(noe,"RequestError"){get methodAndUrl(){return`${this.request.method} ${this.request.url}`}get message(){return this.description?`${this.reason}: ${this.description} (${this.methodAndUrl})`:`${this.reason} error (${this.methodAndUrl})`}}class an extends qc(noe,"ResponseError"){get methodAndUrl(){return`${this.request.method} ${this.request.url}`}get message(){let e=`${this.response.status} ${this.methodAndUrl}`;return this.description?`${this.reason}: ${this.description} (${e})`:`${this.reason} error (${e})`}}var ooe=cre;var W1=AI;var soe=rx;var Sf=Ze;var ioe=Zt;var q1=zi;var vI=jn;var oT=ht;var G1=Ke("@effect/platform/FileSystem"),FI=(e)=>typeof e==="bigint"?e:BigInt(e);var OI=BigInt(1024),gTt=OI*OI*OI*OI*OI;var aoe=(e)=>G1.of({...e,exists:(t)=>E(e.access(t),go(!0),Ua("SystemError",(r)=>r.reason==="NotFound"?Z(!1):ce(r))),readFileString:(t,r)=>Xp(e.readFile(t),{try:(n)=>new TextDecoder(r).decode(n),catch:(n)=>new ls({module:"FileSystem",method:"readFileString",description:"invalid encoding",cause:n})}),stream:(t,r)=>E(e.open(t,{flag:"r"}),r?.offset?Er((n)=>n.seek(r.offset,"start")):X,z((n)=>nUe(n,r)),Wc),sink:(t,r)=>E(e.open(t,{flag:"w",...r}),z((n)=>One((o)=>n.writeAll(o))),Mne),writeFileString:(t,r,n)=>w(mo({try:()=>new TextEncoder().encode(r),catch:(o)=>new ls({module:"FileSystem",method:"writeFileString",description:"could not encode string",cause:o})}),(o)=>e.writeFile(t,o,n))});var nUe=(e,{bufferSize:t=16,bytesToRead:r,chunkSize:n=FI(65536)}={})=>{let o=r!==void 0?FI(r):void 0,s=FI(n);function i(a){if(o!==void 0&&o<=a)return vI;let c=o!==void 0&&o-a<s?o-a:s;return Sf(e.readAlloc(c),Ge({onNone:()=>vI,onSome:(l)=>Sf(oT(at(l)),(u)=>i(a+BigInt(l.length)))}))}return dne(bh(i(BigInt(0))),{capacity:t})};var Gc=FI;var Cn=G1,coe=aoe;var iT=Symbol.for("@effect/platform/FileSystem/File");var loe=RI(),uoe=qd("Create"),poe=qd("Update"),foe=qd("Remove");class Y1 extends wi("@effect/platform/FileSystem/WatchBackend")(){}var Vc=(e)=>{let t=Aoe(e),r=[];for(let n=0;n<t.length;n++)if(Array.isArray(t[n][0])){let[o,s]=t[n];r.push([`${o[0]}[${o.slice(1).join("][")}]`,s])}else r.push(t[n]);return r},Aoe=(e)=>{let t=Symbol.iterator in e?et(e):Object.entries(e),r=[];for(let[n,o]of t)if(Array.isArray(o)){for(let s=0;s<o.length;s++)if(o[s]!==void 0)r.push([n,String(o[s])])}else if(typeof o==="object"){let s=Aoe(o);for(let[i,a]of s)r.push([[n,...typeof i==="string"?[i]:i],a])}else if(o!==void 0)r.push([n,String(o)]);return r};var doe=[];var hoe=h(2,(e,t)=>{let r=Vc(t),n=new Set;for(let o=0;o<r.length;o++)n.add(r[o][0]);for(let o=0;o<e.length;o++){if(n.has(e[o][0]))continue;r.push(e[o])}return r});var V1=(e,t,r)=>{try{let n=new URL(e,sUe());for(let o=0;o<t.length;o++){let[s,i]=t[o];if(i!==void 0)n.searchParams.append(s,i)}if(r._tag==="Some")n.hash=r.value;return me(n)}catch(n){return he(n)}},moe=(e)=>new URLSearchParams(e).toString(),sUe=()=>{if("location"in globalThis&&globalThis.location!==void 0&&globalThis.location.origin!==void 0&&globalThis.location.pathname!==void 0)return location.origin+location.pathname;return};var us=Symbol.for("@effect/platform/HttpIncomingMessage"),Ds=(e,t)=>{let r=is(e,t);return(n)=>w(n.json,r)};class If extends hr()("@effect/platform/HttpIncomingMessage/MaxBodySize",{defaultValue:T}){}var bf=(e,t)=>{let r=e.headers["content-type"]??"",n;if(r.includes("application/json"))try{n=on(e.json)}catch{}else if(r.includes("text/")||r.includes("urlencoded"))try{n=on(e.text)}catch{}let o={...t,headers:ju(e.headers),remoteAddress:e.remoteAddress.toJSON()};if(n!==void 0)o.body=n;return o};var goe=(e)=>pu({b3:`${e.traceId}-${e.spanId}-${e.sampled?"1":"0"}${e.parent._tag==="Some"?`-${e.parent.value.spanId}`:""}`,traceparent:`00-${e.traceId}-${e.spanId}-${e.sampled?"01":"00"}`}),Eoe=(e)=>{let t=uUe(e);if(t._tag==="Some")return t;if(t=iUe(e),t._tag==="Some")return t;return aUe(e)},iUe=(e)=>{if(!("b3"in e))return T();let t=e.b3.split("-");if(t.length<2)return T();return M(LR({traceId:t[0],spanId:t[1],sampled:t[2]?t[2]==="1":!0}))},aUe=(e)=>{if(!e["x-b3-traceid"]||!e["x-b3-spanid"])return T();return M(LR({traceId:e["x-b3-traceid"],spanId:e["x-b3-spanid"],sampled:e["x-b3-sampled"]?e["x-b3-sampled"]==="1":!0}))},cUe=/^[0-9a-f]{32}$/i,lUe=/^[0-9a-f]{16}$/i,uUe=(e)=>{if(!e.traceparent)return T();let t=e.traceparent.split("-");if(t.length!==4)return T();let[r,n,o,s]=t;switch(r){case"00":{if(cUe.test(n)===!1||lUe.test(o)===!1)return T();return M(LR({traceId:n,spanId:o,sampled:(parseInt(s,16)&1)===1}))}default:return T()}};var aT=Symbol.for("@effect/platform/HttpBody"),J1=Symbol.for("@effect/platform/HttpBody/HttpBodyError"),pUe=qd("HttpBodyError"),yoe=(e)=>pUe({[J1]:J1,reason:e});class cT{[aT];constructor(){this[aT]=aT}[ke](){return this.toJSON()}toString(){return Ve(this)}}class Coe extends cT{_tag="Empty";toJSON(){return{_id:"@effect/platform/HttpBody",_tag:"Empty"}}}var lx=new Coe;class Soe extends cT{body;contentType;contentLength;_tag="Raw";constructor(e,t,r){super();this.body=e,this.contentType=t,this.contentLength=r}toJSON(){return{_id:"@effect/platform/HttpBody",_tag:"Raw",body:this.body,contentType:this.contentType,contentLength:this.contentLength}}}var lT=(e,t)=>new Soe(e,t?.contentType,t?.contentLength);class Ioe extends cT{body;contentType;_tag="Uint8Array";constructor(e,t){super();this.body=e,this.contentType=t}get contentLength(){return this.body.length}toJSON(){return{_id:"@effect/platform/HttpBody",_tag:"Uint8Array",body:this.contentType.startsWith("text/")||this.contentType.endsWith("json")?new TextDecoder().decode(this.body):`Uint8Array(${this.body.length})`,contentType:this.contentType,contentLength:this.contentLength}}}var uT=(e,t)=>new Ioe(e,t??"application/octet-stream"),fUe=new TextEncoder,ux=(e,t)=>uT(fUe.encode(e),t??"text/plain"),pT=(e,t)=>ux(JSON.stringify(e),t??"application/json"),fT=(e,t)=>mo({try:()=>pT(e,t),catch:(r)=>yoe({_tag:"JsonError",error:r})});var boe=Symbol.for("@effect/platform/HttpClientRequest"),mUe={[boe]:boe,...Ws,toJSON(){return{_id:"@effect/platform/HttpClientRequest",method:this.method,url:this.url,urlParams:this.urlParams,hash:this.hash,headers:ju(this.headers),body:this.body.toJSON()}},pipe(){return W(this,arguments)}};function Jc(e,t,r,n,o,s){let i=Object.create(mUe);return i.method=e,i.url=t,i.urlParams=r,i.hash=n,i.headers=o,i.body=s,i}var gUe=Jc("GET","",doe,T(),oi,lx),Au=(e)=>(t,r)=>Roe(gUe,{method:e,url:t,...r??void 0}),AT=Au("GET"),dT=Au("POST"),j1=Au("PUT"),$1=Au("PATCH"),K1=Au("DELETE"),Z1=Au("HEAD"),X1=Au("OPTIONS"),Roe=h(2,(e,t)=>{let r=e;if(t.method)r=Doe(r,t.method);if(t.url)r=tW(r,t.url);if(t.headers)r=NI(r,t.headers);if(t.urlParams)r=rW(r,t.urlParams);if(t.hash)r=voe(r,t.hash);if(t.body)r=mT(r,t.body);if(t.accept)r=eW(r,t.accept);if(t.acceptJson)r=koe(r);return r}),hT=h(3,(e,t,r)=>Jc(e.method,e.url,e.urlParams,e.hash,Cf(e.headers,t,r),e.body)),NI=h(2,(e,t)=>Jc(e.method,e.url,e.urlParams,e.hash,P1(e.headers,t),e.body));var eW=h(2,(e,t)=>hT(e,"Accept",t)),koe=eW("application/json"),Doe=h(2,(e,t)=>Jc(t,e.url,e.urlParams,e.hash,e.headers,e.body)),tW=h(2,(e,t)=>{if(typeof t==="string")return Jc(e.method,t,e.urlParams,e.hash,e.headers,e.body);let r=new URL(t.toString()),n=Vc(r.searchParams),o=r.hash?M(r.hash.slice(1)):T();return r.search="",r.hash="",Jc(e.method,r.toString(),n,o,e.headers,e.body)});var Toe=h(2,(e,t)=>Jc(e.method,t.endsWith("/")&&e.url.startsWith("/")?t+e.url.slice(1):t+e.url,e.urlParams,e.hash,e.headers,e.body));var rW=h(2,(e,t)=>Jc(e.method,e.url,hoe(e.urlParams,t),e.hash,e.headers,e.body)),voe=h(2,(e,t)=>Jc(e.method,e.url,e.urlParams,M(t),e.headers,e.body));var mT=h(2,(e,t)=>{let r=e.headers;if(t._tag==="Empty"||t._tag==="FormData")r=H1(r,["Content-type","Content-length"]);else{let n=t.contentType;if(n)r=Cf(r,"content-type",n);let o=t.contentLength;if(o)r=Cf(r,"content-length",o.toString())}return Jc(e.method,e.url,e.urlParams,e.hash,r,t)});var Ooe=h(2,(e,t)=>z(fT(t),(r)=>mT(e,r)));var Foe=h(2,(e,t)=>mT(e,ux(moe(Vc(t)),"application/x-www-form-urlencoded")));var Bf=Symbol.for("@effect/platform/HttpClientResponse"),nW=(e,t)=>new Noe(e,t);class Noe extends ha{request;source;[us];[Bf];constructor(e,t){super();this.request=e,this.source=t,this[us]=us,this[Bf]=Bf}toJSON(){return bf(this,{_id:"@effect/platform/HttpClientResponse",request:this.request.toJSON(),status:this.status})}get status(){return this.source.status}get headers(){return Kn(this.source.headers)}cachedCookies;get cookies(){if(this.cachedCookies)return this.cachedCookies;return this.cachedCookies=cx(this.source.headers.getSetCookie())}get remoteAddress(){return T()}get stream(){return this.source.body?Ene(()=>this.source.body,(e)=>new an({request:this.request,response:this,reason:"Decode",cause:e})):zD(new an({request:this.request,response:this,reason:"EmptyBody",description:"can not create stream from empty body"}))}get json(){return Xp(this.text,{try:(e)=>e===""?null:JSON.parse(e),catch:(e)=>new an({request:this.request,response:this,reason:"Decode",cause:e})})}textBody;get text(){return this.textBody??=lr({try:()=>this.source.text(),catch:(e)=>new an({request:this.request,response:this,reason:"Decode",cause:e})}).pipe(Zs,on)}get urlParamsBody(){return w(this.text,(e)=>mo({try:()=>Vc(new URLSearchParams(e)),catch:(t)=>new an({request:this.request,response:this,reason:"Decode",cause:t})}))}formDataBody;get formData(){return this.formDataBody??=lr({try:()=>this.source.formData(),catch:(e)=>new an({request:this.request,response:this,reason:"Decode",cause:e})}).pipe(Zs,on)}arrayBufferBody;get arrayBuffer(){return this.arrayBufferBody??=lr({try:()=>this.source.arrayBuffer(),catch:(e)=>new an({request:this.request,response:this,reason:"Decode",cause:e})}).pipe(Zs,on)}}var _oe=h(2,(e,t)=>{let r=e.status;if(t[r])return t[r](e);else if(r>=200&&r<300&&t["2xx"])return t["2xx"](e);else if(r>=300&&r<400&&t["3xx"])return t["3xx"](e);else if(r>=400&&r<500&&t["4xx"])return t["4xx"](e);else if(r>=500&&r<600&&t["5xx"])return t["5xx"](e);return t.orElse(e)});var yUe=(e)=>`http.request.header.${e}`,CUe="http.request.method",SUe=(e)=>`http.response.header.${e}`,IUe="http.response.status_code",bUe="server.address",BUe="server.port",QUe="url.full",wUe="url.path",RUe="url.scheme",kUe="url.query",sW=Symbol.for("@effect/platform/HttpClient"),ET=Ke("@effect/platform/HttpClient"),aW=Ae(Symbol.for("@effect/platform/HttpClient/tracerDisabledWhen"),()=>Pi(tr)),Uoe=h(2,(e,t)=>yT(e,EE(aW,t))),cW=Ae(Symbol.for("@effect/platform/HttpClient/currentTracerPropagation"),()=>Pi(!0)),Loe=h(2,(e,t)=>yT(e,EE(cW,t))),Poe=hr()("@effect/platform/HttpClient/SpanNameGenerator",{defaultValue:()=>(e)=>`http.client ${e.method}`});var DUe={[sW]:sW,pipe(){return W(this,arguments)},...Ws,toJSON(){return{_id:"@effect/platform/HttpClient"}},get(e,t){return this.execute(AT(e,t))},head(e,t){return this.execute(Z1(e,t))},post(e,t){return this.execute(dT(e,t))},put(e,t){return this.execute(j1(e,t))},patch(e,t){return this.execute($1(e,t))},del(e,t){return this.execute(K1(e,t))},options(e,t){return this.execute(X1(e,t))}};var _I=(e,t)=>{let r=Object.create(DUe);return r.preprocess=t,r.postprocess=e,r.execute=function(n){return e(t(n))},r},gT=Ae("@effect/platform/HttpClient/responseRegistry",()=>{if("FinalizationRegistry"in globalThis&&globalThis.FinalizationRegistry){let t=new FinalizationRegistry((r)=>{r.abort()});return{register(r,n){t.register(r,n,r)},unregister(r){t.unregister(r)}}}let e=new Map;return{register(t,r){e.set(t,setTimeout(()=>r.abort(),5000))},unregister(t){let r=e.get(t);if(r===void 0)return;clearTimeout(r),e.delete(t)}}}),Hoe=Ae("@effect/platform/HttpClient/scopedRequests",()=>new WeakMap),xT=(e)=>_I((t)=>w(t,(r)=>mr((n)=>{let o=Hoe.get(r),s=o??new AbortController,i=V1(r.url,r.urlParams,r.hash);if(i._tag==="Left")return ce(new si({request:r,reason:"InvalidUrl",cause:i.left}));let a=i.right;if(!n.getFiberRef(M6)||n.getFiberRef(aW)(r)){let u=e(r,a,s.signal,n);if(o)return u;return Jl((p)=>xn(p(u),{onSuccess(f){return gT.register(f,s),Z(new iW(f,s))},onFailure(f){if(Pd(f))s.abort();return kr(f)}}))}let l=Ot(n.currentContext,Poe);return CE(l(r),{kind:"client",captureStackTrace:!1},(u)=>{if(u.attribute(CUe,r.method),u.attribute(bUe,a.origin),a.port!=="")u.attribute(BUe,+a.port);u.attribute(QUe,a.toString()),u.attribute(wUe,a.pathname),u.attribute(RUe,a.protocol.slice(0,-1));let p=a.search.slice(1);if(p!=="")u.attribute(kUe,p);let f=n.getFiberRef(TI),A=Bh(r.headers,f);for(let d in A)u.attribute(yUe(d),String(A[d]));return r=n.getFiberRef(cW)?NI(r,goe(u)):r,Jl((d)=>d(e(r,a,s.signal,n)).pipe(jd(u),xn({onSuccess:(g)=>{u.attribute(IUe,g.status);let x=Bh(g.headers,f);for(let y in x)u.attribute(SUe(y),String(x[y]));if(o)return Z(g);return gT.register(g,s),Z(new iW(g,s))},onFailure(g){if(!o&&Pd(g))s.abort();return kr(g)}})))})})),Z);class iW{original;controller;constructor(e,t){this.original=e,this.controller=t}[Bf]=Bf;[us]=us;applyInterrupt(e){return Te(()=>(gT.unregister(this.original),Vk(e,()=>se(()=>{this.controller.abort()}))))}get request(){return this.original.request}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 stream(){return Qne(()=>(gT.unregister(this.original),gne(this.original.stream,se(()=>{this.controller.abort()}))))}toJSON(){return this.original.toJSON()}[ke](){return this.original[ke]()}}var Woe=(e)=>qoe(e,(t,r)=>{let n=new AbortController;return Hoe.set(r,n),ve(Jk((o)=>Qs(o,se(()=>n.abort()))),t)}),{del:TUe,execute:vUe,get:OUe,head:FUe,options:MUe,patch:NUe,post:_Ue,put:UUe}=s6(ET),qoe=h(2,(e,t)=>{let r=e;return _I(w((n)=>t(r.postprocess(Z(n)),n)),r.preprocess)});var yT=h(2,(e,t)=>{let r=e;return _I((n)=>t(r.postprocess(n)),r.preprocess)});var Goe=h(2,(e,t)=>{let r=e;return _I(r.postprocess,(n)=>z(r.preprocess(n),t))});var CT=(e)=>Wa(ET,w(vn(),(t)=>z(e,(r)=>yT(r,gE((n)=>wr(t,n))))));var Voe="@effect/platform/FetchHttpClient/Fetch",lW="@effect/platform/FetchHttpClient/FetchOptions",LUe=xT((e,t,r,n)=>{let o=n.getFiberRef(sf),s=o.unsafeMap.get(Voe)??globalThis.fetch,i=o.unsafeMap.get(lW)??{},a=i.headers?Ka(Kn(i.headers),e.headers):e.headers,c=(l)=>z(lr({try:()=>s(t,{...i,method:e.method,headers:a,body:l,duplex:e.body._tag==="Stream"?"half":void 0,signal:r}),catch:(u)=>new si({request:e,reason:"Transport",cause:u})}),(u)=>nW(e,u));switch(e.body._tag){case"Raw":case"Uint8Array":return c(e.body.body);case"FormData":return c(e.body.formData);case"Stream":return w(wne(e.body.stream),c)}return c(void 0)}),Joe=CT(Z(LUe));class zoe extends wi(lW)(){}var HUe=Joe;var qUe=lT;var Qf=ET;var ST=xT;var IT=Goe;var GUe=Uoe;var YUe=Loe,bT=CT;var VUe=Woe;var ii=Au,uW=AT,BT=dT;var UI=hT,pW=NI;var QT=Toe;var du=rW;var $i=Ooe;var JUe=Foe;var wf=Bf;var ai=_oe;var LI=Symbol.for("@effect/platform/Etag/Generator"),px=Ke("@effect/platform/Etag/Generator"),Koe=(e)=>{switch(e._tag){case"Weak":return`W/"${e.value}"`;case"Strong":return`"${e.value}"`}},Zoe=(e)=>{let t=e.mtime._tag==="Some"?e.mtime.value.getTime().toString(16):"0";return`${e.size.toString(16)}-${t}`},Xoe=(e)=>`${e.size.toString(16)}-${e.lastModified.toString(16)}`,ese=Li(px,px.of({[LI]:LI,fromFileInfo(e){return se(()=>({_tag:"Strong",value:Zoe(e)}))},fromFileWeb(e){return se(()=>({_tag:"Strong",value:Xoe(e)}))}})),tse=Li(px,px.of({[LI]:LI,fromFileInfo(e){return se(()=>({_tag:"Weak",value:Zoe(e)}))},fromFileWeb(e){return se(()=>({_tag:"Weak",value:Xoe(e)}))}}));var fW=Koe;var rse=px,nse=ese,AW=tse;var wT=Symbol.for("@effect/platform/HttpServerResponse"),jUe=Symbol.for("@effect/platform/HttpServerRespondable");class PI extends IU{status;statusText;cookies;body;[wT];headers;constructor(e,t,r,n,o){super();if(this.status=e,this.statusText=t,this.cookies=n,this.body=o,this[wT]=wT,o.contentType||o.contentLength){let s={...r};if(o.contentType)s["content-type"]=o.contentType;if(o.contentLength)s["content-length"]=o.contentLength.toString();this.headers=s}else this.headers=r}commit(){return Z(this)}[jUe](){return Z(this)}[ke](){return this.toJSON()}toString(){return Ve(this)}toJSON(){return{_id:"@effect/platform/HttpServerResponse",status:this.status,statusText:this.statusText,headers:ju(this.headers),cookies:this.cookies.toJSON(),body:this.body.toJSON()}}}var HI=(e)=>typeof e==="object"&&e!==null&&(wT in e),fx=(e)=>new PI(e?.status??204,e?.statusText,e?.headers?Kn(e.headers):oi,e?.cookies??uu,lx),ose=(e,t)=>{let r=pu({location:e.toString()});return new PI(t?.status??302,t?.statusText,t?.headers?Ka(r,Kn(t.headers)):r,t?.cookies??uu,lx)};var sse=(e,t)=>{let r=t?.headers?Kn(t.headers):oi;return new PI(t?.status??200,t?.statusText,r,t?.cookies??uu,ux(e,KUe(t,r)))};var $Ue=Ke("@effect/platform/HttpPlatform"),ise=(e,t)=>w($Ue,(r)=>r.fileResponse(e,t));var ase=(e,t)=>new PI(t?.status??200,t?.statusText,t?.headers?Kn(t.headers):oi,t?.cookies??uu,lT(e,{contentType:t?.contentType,contentLength:t?.contentLength}));var KUe=(e,t)=>{if(e?.contentType)return e.contentType;else if(e?.headers)return t["content-type"];else return};var hW=Symbol.for("@effect/platform/HttpPlatform"),mW=Ke("@effect/platform/HttpPlatform"),lse=(e)=>_e(function*(){let t=yield*Cn,r=yield*rse;return mW.of({[hW]:hW,fileResponse(n,o){return E(a6(t.stat(n),"info"),i6("etag",({info:s})=>r.fromFileInfo(s)),z(({etag:s,info:i})=>{let a=Number(o?.offset??0),c=o?.bytesToRead!==void 0?a+Number(o.bytesToRead):void 0,l=Cf(o?.headers?Kn(o.headers):oi,"etag",fW(s));if(i.mtime._tag==="Some")l["last-modified"]=i.mtime.value.toUTCString();let u=c!==void 0?c-a:Number(i.size)-a;return e.fileResponse(n,o?.status??200,o?.statusText,l,a,c,u)}))},fileWebResponse(n,o){return z(r.fromFileWeb(n),(s)=>{let i=Ka(o?.headers?Kn(o.headers):oi,pu({etag:fW(s),"last-modified":new Date(n.lastModified).toUTCString()}));return e.fileWebResponse(n,o?.status??200,o?.statusText,i,o)})}})});var RT=Symbol.for("@effect/platform/Path"),EW=Ke("@effect/platform/Path");function use(e,t){let r="",n=0,o=-1,s=0,i;for(let a=0;a<=e.length;++a){if(a<e.length)i=e.charCodeAt(a);else if(i===47)break;else i=47;if(i===47){if(o===a-1||s===1);else if(o!==a-1&&s===2){if(r.length<2||n!==2||r.charCodeAt(r.length-1)!==46||r.charCodeAt(r.length-2)!==46){if(r.length>2){let c=r.lastIndexOf("/");if(c!==r.length-1){if(c===-1)r="",n=0;else r=r.slice(0,c),n=r.length-1-r.lastIndexOf("/");o=a,s=0;continue}}else if(r.length===2||r.length===1){r="",n=0,o=a,s=0;continue}}if(t){if(r.length>0)r+="/..";else r="..";n=2}}else{if(r.length>0)r+="/"+e.slice(o+1,a);else r=e.slice(o+1,a);n=a-o-1}o=a,s=0}else if(i===46&&s!==-1)++s;else s=-1}return r}function XUe(e,t){let r=t.dir||t.root,n=t.base||(t.name||"")+(t.ext||"");if(!r)return n;if(r===t.root)return r+n;return r+e+n}function eLe(e){if(e.protocol!=="file:")return ce(new ls({module:"Path",method:"fromFileUrl",description:"URL must be of scheme file"}));else if(e.hostname!=="")return ce(new ls({module:"Path",method:"fromFileUrl",description:"Invalid file URL host"}));let t=e.pathname;for(let r=0;r<t.length;r++)if(t[r]==="%"){let n=t.codePointAt(r+2)|32;if(t[r+1]==="2"&&n===102)return ce(new ls({module:"Path",method:"fromFileUrl",description:"must not include encoded / characters"}))}return Z(decodeURIComponent(t))}var pse=function(){let t="",r=!1,n=void 0;for(let o=arguments.length-1;o>=-1&&!r;o--){let s;if(o>=0)s=arguments[o];else{let i=globalThis.process;if(n===void 0&&"process"in globalThis&&typeof i==="object"&&i!==null&&typeof i.cwd==="function")n=i.cwd();s=n}if(s.length===0)continue;t=s+"/"+t,r=s.charCodeAt(0)===47}if(t=use(t,!r),r)if(t.length>0)return"/"+t;else return"/";else if(t.length>0)return t;else return"."},tLe=47;function rLe(e){let t=new URL("file://"),r=pse(e);if(e.charCodeAt(e.length-1)===tLe&&r[r.length-1]!=="/")r+="/";return t.pathname=cLe(r),Z(t)}var nLe=/%/g,oLe=/\\/g,sLe=/\n/g,iLe=/\r/g,aLe=/\t/g;function cLe(e){if(e.includes("%"))e=e.replace(nLe,"%25");if(e.includes("\\"))e=e.replace(oLe,"%5C");if(e.includes(`
|
|
180
|
-
`))e=e.replace(sLe,"%0A");if(e.includes("\r"))e=e.replace(iLe,"%0D");if(e.includes("\t"))e=e.replace(aLe,"%09");return e}var gW=EW.of({[RT]:RT,resolve:pse,normalize(e){if(e.length===0)return".";let t=e.charCodeAt(0)===47,r=e.charCodeAt(e.length-1)===47;if(e=use(e,!t),e.length===0&&!t)e=".";if(e.length>0&&r)e+="/";if(t)return"/"+e;return e},isAbsolute(e){return e.length>0&&e.charCodeAt(0)===47},join(){if(arguments.length===0)return".";let e;for(let t=0;t<arguments.length;++t){let r=arguments[t];if(r.length>0)if(e===void 0)e=r;else e+="/"+r}if(e===void 0)return".";return gW.normalize(e)},relative(e,t){if(e===t)return"";if(e=gW.resolve(e),t=gW.resolve(t),e===t)return"";let r=1;for(;r<e.length;++r)if(e.charCodeAt(r)!==47)break;let n=e.length,o=n-r,s=1;for(;s<t.length;++s)if(t.charCodeAt(s)!==47)break;let a=t.length-s,c=o<a?o:a,l=-1,u=0;for(;u<=c;++u){if(u===c){if(a>c){if(t.charCodeAt(s+u)===47)return t.slice(s+u+1);else if(u===0)return t.slice(s+u)}else if(o>c){if(e.charCodeAt(r+u)===47)l=u;else if(u===0)l=0}break}let f=e.charCodeAt(r+u),A=t.charCodeAt(s+u);if(f!==A)break;else if(f===47)l=u}let p="";for(u=r+l+1;u<=n;++u)if(u===n||e.charCodeAt(u)===47)if(p.length===0)p+="..";else p+="/..";if(p.length>0)return p+t.slice(s+l);else{if(s+=l,t.charCodeAt(s)===47)++s;return t.slice(s)}},dirname(e){if(e.length===0)return".";let t=e.charCodeAt(0),r=t===47,n=-1,o=!0;for(let s=e.length-1;s>=1;--s)if(t=e.charCodeAt(s),t===47){if(!o){n=s;break}}else o=!1;if(n===-1)return r?"/":".";if(r&&n===1)return"//";return e.slice(0,n)},basename(e,t){let r=0,n=-1,o=!0,s;if(t!==void 0&&t.length>0&&t.length<=e.length){if(t.length===e.length&&t===e)return"";let i=t.length-1,a=-1;for(s=e.length-1;s>=0;--s){let c=e.charCodeAt(s);if(c===47){if(!o){r=s+1;break}}else{if(a===-1)o=!1,a=s+1;if(i>=0)if(c===t.charCodeAt(i)){if(--i===-1)n=s}else i=-1,n=a}}if(r===n)n=a;else if(n===-1)n=e.length;return e.slice(r,n)}else{for(s=e.length-1;s>=0;--s)if(e.charCodeAt(s)===47){if(!o){r=s+1;break}}else if(n===-1)o=!1,n=s+1;if(n===-1)return"";return e.slice(r,n)}},extname(e){let t=-1,r=0,n=-1,o=!0,s=0;for(let i=e.length-1;i>=0;--i){let a=e.charCodeAt(i);if(a===47){if(!o){r=i+1;break}continue}if(n===-1)o=!1,n=i+1;if(a===46){if(t===-1)t=i;else if(s!==1)s=1}else if(t!==-1)s=-1}if(t===-1||n===-1||s===0||s===1&&t===n-1&&t===r+1)return"";return e.slice(t,n)},format:function(t){if(t===null||typeof t!=="object")throw TypeError('The "pathObject" argument must be of type Object. Received type '+typeof t);return XUe("/",t)},parse(e){let t={root:"",dir:"",base:"",ext:"",name:""};if(e.length===0)return t;let r=e.charCodeAt(0),n=r===47,o;if(n)t.root="/",o=1;else o=0;let s=-1,i=0,a=-1,c=!0,l=e.length-1,u=0;for(;l>=o;--l){if(r=e.charCodeAt(l),r===47){if(!c){i=l+1;break}continue}if(a===-1)c=!1,a=l+1;if(r===46){if(s===-1)s=l;else if(u!==1)u=1}else if(s!==-1)u=-1}if(s===-1||a===-1||u===0||u===1&&s===a-1&&s===i+1){if(a!==-1)if(i===0&&n)t.base=t.name=e.slice(1,a);else t.base=t.name=e.slice(i,a)}else{if(i===0&&n)t.name=e.slice(1,s),t.base=e.slice(1,a);else t.name=e.slice(i,s),t.base=e.slice(i,a);t.ext=e.slice(s,a)}if(i>0)t.dir=e.slice(0,i-1);else if(n)t.dir="/";return t},sep:"/",fromFileUrl:eLe,toFileUrl:rLe,toNamespacedPath:X});var xW=Symbol.for("@effect/platform/HttpServer"),fse=Ke("@effect/platform/HttpServer"),uLe={[xW]:xW};var Ase=(e)=>Object.assign(Object.create(uLe),e);var yW=fse,dse=Ase;var SW=HI,kf=fx,fLe=ose;var ALe=sse;var IW=ase;var dLe=ise;var dx=Symbol.for("@effect/platform/HttpServerRespondable"),hse=(e)=>ee(e,dx),hLe=kf({status:400}),mLe=kf({status:404});var mse=(e,t)=>{if(SW(e))return Z(e);else if(hse(e))return rn(e[dx](),()=>Z(t));else if(NE(e))return Z(hLe);else if(D9(e))return Z(mLe);return Z(t)},gse=(e,t)=>{if(SW(e))return Z(e);else if(hse(e))return rn(e[dx](),()=>Z(t));return Z(t)};var yse=Symbol.for("@effect/platform/HttpServerError");var DT=Ae("@effect/platform/HttpServerError/clientAbortFiberId",()=>fw(-499,0)),Cse=(e)=>{let t=Z(kT),r=Ud,n=!1,o=!1;R9(e,void 0,(a,c)=>{let l=pk(r)?Ud:r;switch(c._tag){case"Fail":{t=mse(c.error,kT),r=xse(l,c);break}case"Die":{let u=HI(c.defect);t=gse(c.defect,kT),r=u?l:xse(l,c),o=o||u;break}case"Interrupt":{if(n=n||c.fiberId===DT,Vp(r)&&!o)r=c;break}}return T()});let s=!o&&pk(r)?Z(n?gLe:ELe):t,i=!o&&pk(r)&&n?rE(DT):r;return z(s,(a)=>{if(Vp(i))return[a,Ud];return[a,Ld(i,$s(a))]})},xse=(e,t)=>{if(Vp(e))return t;else if(Vp(t))return e;return Ld(e,t)},Sse=(e)=>{let t,r=w9(e,(n)=>{if(HI(n))return t=n,M(Ud);return T()});return[t??kT,r]},kT=fx({status:500}),gLe=fx({status:499}),ELe=fx({status:503}),Ise=(e)=>{if(e._tag==="Success")return e.value;return Sse(e.cause)[0]};var bW=yse;class WI extends qc(bW,"RequestError"){[dx](){return kf({status:400})}get methodAndUrl(){return`${this.request.method} ${this.request.url}`}get message(){return this.description?`${this.reason}: ${this.description} (${this.methodAndUrl})`:`${this.reason} error (${this.methodAndUrl})`}}class TT extends qc(bW,"ResponseError"){[dx](){return kf({status:500})}get methodAndUrl(){return`${this.request.method} ${this.request.url}`}get message(){let e=`${this.response.status} ${this.methodAndUrl}`;return this.description?`${this.description} (${e})`:`${this.reason} error (${e})`}}class vT extends qc(bW,"ServeError"){}var OT=DT,qI=Cse;var bse=Ise;var NT=Symbol.for("effect/Mailbox"),BW=Symbol.for("effect/Mailbox/ReadonlyMailbox");var wh=Lt(),Bse=yt(wh),FT=yt(!1),MT=yt(!0),Qse=[wh,!0];class wse extends Is{scheduler;capacity;strategy;[NT]=NT;[BW]=BW;state={_tag:"Open",takers:new Set,offers:new Set,awaiters:new Set};messages=[];messagesChunk=Lt();constructor(e,t,r){super();this.scheduler=e,this.capacity=t,this.strategy=r}offer(e){return Me(()=>{if(this.state._tag!=="Open")return FT;else if(this.messages.length+this.messagesChunk.length>=this.capacity)switch(this.strategy){case"dropping":return FT;case"suspend":if(this.capacity<=0&&this.state.takers.size>0)return this.messages.push(e),this.releaseTaker(),MT;return this.offerRemainingSingle(e);case"sliding":return this.unsafeTake(),this.messages.push(e),MT}return this.messages.push(e),this.scheduleReleaseTaker(),MT})}unsafeOffer(e){if(this.state._tag!=="Open")return!1;else if(this.messages.length+this.messagesChunk.length>=this.capacity){if(this.strategy==="sliding")return this.unsafeTake(),this.messages.push(e),!0;else if(this.capacity<=0&&this.state.takers.size>0)return this.messages.push(e),this.releaseTaker(),!0;return!1}return this.messages.push(e),this.scheduleReleaseTaker(),!0}offerAll(e){return Me(()=>{if(this.state._tag!=="Open")return te(Ln(e));let t=this.unsafeOfferAllArray(e);if(t.length===0)return Bse;else if(this.strategy==="dropping")return te(Qr(t));return this.offerRemainingArray(t)})}unsafeOfferAll(e){return Qr(this.unsafeOfferAllArray(e))}unsafeOfferAllArray(e){if(this.state._tag!=="Open")return et(e);else if(this.capacity===Number.POSITIVE_INFINITY||this.strategy==="sliding"){if(this.messages.length>0)this.messagesChunk=$t(this.messagesChunk,Qr(this.messages));if(this.strategy==="sliding")this.messagesChunk=this.messagesChunk.pipe($t(Ln(e)),gN(this.capacity));else if(VA(e))this.messagesChunk=$t(this.messagesChunk,e);else this.messages=et(e);return this.scheduleReleaseTaker(),[]}let t=this.capacity<=0?this.state.takers.size:this.capacity-this.messages.length-this.messagesChunk.length;if(t===0)return et(e);let r=[],n=0;for(let o of e){if(n<t)this.messages.push(o);else r.push(o);n++}return this.scheduleReleaseTaker(),r}fail(e){return this.done(Ml(e))}failCause(e){return this.done(dt(e))}unsafeDone(e){if(this.state._tag!=="Open")return!1;else if(this.state.offers.size===0&&this.messages.length===0&&this.messagesChunk.length===0)return this.finalize(e),!0;return this.state={...this.state,_tag:"Closing",exit:e},!0}shutdown=j(()=>{if(this.state._tag==="Done")return!0;this.messages=[],this.messagesChunk=wh;let e=this.state.offers;if(this.finalize(this.state._tag==="Open"?Rr:this.state.exit),e.size>0){for(let t of e)if(t._tag==="Single")t.resume(FT);else t.resume(yt(Qr(t.remaining.slice(t.offset))));e.clear()}return!0});done(e){return j(()=>this.unsafeDone(e))}end=this.done(Rr);clear=Me(()=>{if(this.state._tag==="Done")return kg(this.state.exit,wh);let e=this.unsafeTakeAll();return this.releaseCapacity(),te(e)});takeAll=Me(()=>{if(this.state._tag==="Done")return kg(this.state.exit,Qse);let e=this.unsafeTakeAll();if(e.length===0)return xt(this.awaitTake,this.takeAll);return te([e,this.releaseCapacity()])});takeN(e){return Me(()=>{if(this.state._tag==="Done")return kg(this.state.exit,Qse);else if(e<=0)return te([wh,!1]);e=Math.min(e,this.capacity);let t;if(e<=this.messagesChunk.length)t=Xm(this.messagesChunk,e),this.messagesChunk=Ca(this.messagesChunk,e);else if(e<=this.messages.length+this.messagesChunk.length)this.messagesChunk=$t(this.messagesChunk,Qr(this.messages)),this.messages=[],t=Xm(this.messagesChunk,e),this.messagesChunk=Ca(this.messagesChunk,e);else return xt(this.awaitTake,this.takeN(e));return te([t,this.releaseCapacity()])})}unsafeTake(){if(this.state._tag==="Done")return rR(this.state.exit,Ml(new k9));let e;if(this.messagesChunk.length>0)e=oC(this.messagesChunk),this.messagesChunk=Ca(this.messagesChunk,1);else if(this.messages.length>0)e=this.messages[0],this.messagesChunk=Ca(Qr(this.messages),1),this.messages=[];else if(this.capacity<=0&&this.state.offers.size>0)return this.capacity=1,this.releaseCapacity(),this.capacity=0,this.messages.length>0?yt(this.messages.pop()):void 0;else return;return this.releaseCapacity(),yt(e)}take=Me(()=>this.unsafeTake()??xt(this.awaitTake,this.take));await=Ac((e)=>{if(this.state._tag==="Done")return e(this.state.exit);return this.state.awaiters.add(e),j(()=>{if(this.state._tag!=="Done")this.state.awaiters.delete(e)})});unsafeSize(){let e=this.messages.length+this.messagesChunk.length;return this.state._tag==="Done"?T():M(e)}size=j(()=>this.unsafeSize());commit(){return this.takeAll}pipe(){return W(this,arguments)}toJSON(){return{_id:"effect/Mailbox",state:this.state._tag,size:this.unsafeSize().toJSON()}}toString(){return Ve(this)}[ke](){return Ve(this)}offerRemainingSingle(e){return Ac((t)=>{if(this.state._tag!=="Open")return t(FT);let r={_tag:"Single",message:e,resume:t};return this.state.offers.add(r),j(()=>{if(this.state._tag==="Open")this.state.offers.delete(r)})})}offerRemainingArray(e){return Ac((t)=>{if(this.state._tag!=="Open")return t(yt(Qr(e)));let r={_tag:"Array",remaining:e,offset:0,resume:t};return this.state.offers.add(r),j(()=>{if(this.state._tag==="Open")this.state.offers.delete(r)})})}releaseCapacity(){if(this.state._tag==="Done")return this.state.exit._tag==="Success";else if(this.state.offers.size===0){if(this.state._tag==="Closing"&&this.messages.length===0&&this.messagesChunk.length===0)return this.finalize(this.state.exit),this.state.exit._tag==="Success";return!1}let e=this.capacity-this.messages.length-this.messagesChunk.length;for(let t of this.state.offers)if(e===0)return!1;else if(t._tag==="Single")this.messages.push(t.message),e--,t.resume(MT),this.state.offers.delete(t);else{for(;t.offset<t.remaining.length;t.offset++){if(e===0)return!1;this.messages.push(t.remaining[t.offset]),e--}t.resume(Bse),this.state.offers.delete(t)}return!1}awaitTake=Ac((e)=>{if(this.state._tag==="Done")return e(this.state.exit);return this.state.takers.add(e),j(()=>{if(this.state._tag!=="Done")this.state.takers.delete(e)})});scheduleRunning=!1;scheduleReleaseTaker(){if(this.scheduleRunning)return;this.scheduleRunning=!0,this.scheduler.scheduleTask(this.releaseTaker,0)}releaseTaker=()=>{if(this.scheduleRunning=!1,this.state._tag==="Done")return;else if(this.state.takers.size===0)return;for(let e of this.state.takers)if(this.state.takers.delete(e),e(Rr),this.messages.length+this.messagesChunk.length===0)break};unsafeTakeAll(){if(this.messagesChunk.length>0){let e=this.messages.length>0?$t(this.messagesChunk,Qr(this.messages)):this.messagesChunk;return this.messagesChunk=wh,this.messages=[],e}else if(this.messages.length>0){let e=Qr(this.messages);return this.messages=[],e}else if(this.state._tag!=="Done"&&this.state.offers.size>0)return this.capacity=1,this.releaseCapacity(),this.capacity=0,at(this.messages.pop());return wh}finalize(e){if(this.state._tag==="Done")return;let t=this.state;this.state={_tag:"Done",exit:e};for(let r of t.takers)r(e);t.takers.clear();for(let r of t.awaiters)r(e);t.awaiters.clear()}}var Rse=(e)=>rt((t)=>te(new wse(t.currentScheduler,typeof e==="number"?e:e?.capacity??Number.POSITIVE_INFINITY,typeof e==="number"?"suspend":e?.strategy??"suspend")));var QW=(e)=>{let t=Ze(e.takeAll,([r,n])=>n?r.length===0?jn:ht(r):cu(ht(r),t));return t},kse=(e)=>JD(QW(e));var CLe=NT;var Dse=(e)=>ee(e,CLe);var Df=Rse;var Tse=QW,vse=kse;var Ose=/; *([!#$%&'*+.^\w`|~-]+)=("(?:[\v\u0020\u0021\u0023-\u005b\u005d-\u007e\u0080-\u00ff]|\\[\v\u0020-\u00ff])*"|[!#$%&'*+.^\w`|~-]+) */gu,Fse=/\\([\v\u0020-\u00ff])/gu,SLe=/^[!#$%&'*+.^\w|~-]+\/[!#$%&'*+.^\w|~-]+$/u,ILe=/^[!#$%&'*+.^\w|~-]+$/u,UT={value:"",parameters:Object.create(null)};function LT(e,t=!1){if(typeof e!=="string")return UT;let r=e.indexOf(";"),n=r!==-1?e.slice(0,r).trim():e.trim();if((t?ILe:SLe).test(n)===!1)return UT;let s={value:n.toLowerCase(),parameters:Object.create(null)};if(r===-1)return s;let i,a,c;Ose.lastIndex=r;while(a=Ose.exec(e)){if(a.index!==r)return UT;if(r+=a[0].length,i=a[1].toLowerCase(),c=a[2],c[0]==='"')c=c.slice(1,c.length-1),!t&&Fse.test(c)&&(c=c.replace(Fse,"$1"));s.parameters[i]=c}if(r!==e.length)return UT;return s}var Ki;(function(e){e[e.key=0]="key",e[e.whitespace=1]="whitespace",e[e.value=2]="value"})(Ki||(Ki={}));var YI={_tag:"Continue"},BLe=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,1,1,1,1,1,0,0,1,1,0,1,1,0,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,1,0,1],QLe=[0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1];function Mse(){let e=new TextDecoder,t={state:Ki.key,headers:Object.create(null),key:"",value:void 0,crlf:0,previousChunk:void 0,pairs:0,size:0};function r(s){return t.state=Ki.key,t.headers=Object.create(null),t.key="",t.value=void 0,t.crlf=0,t.previousChunk=void 0,t.pairs=0,t.size=0,s}function n(s,i){let a=new Uint8Array(s.length+i.length);return a.set(s),a.set(i,s.length),a}function o(s){return r({_tag:"Failure",reason:s,headers:t.headers})}return function(i,a){let c=0,l;if(t.previousChunk!==void 0){c=t.previousChunk.length,l=c;let p=new Uint8Array(i.length+c);p.set(t.previousChunk),p.set(i,c),t.previousChunk=void 0,i=p}let u=i.length;e:while(a<u){if(t.state===Ki.key){let p=a;for(;p<u;p++){if(t.size++>16384)return o("HeaderTooLarge");if(i[p]===58){if(t.key+=e.decode(i.subarray(a,p)).toLowerCase(),t.key.length===0)return o("InvalidHeaderName");if(i[p+1]===32&&i[p+2]!==32&&i[p+2]!==9)a=p+2,t.state=Ki.value,t.size++;else if(i[p+1]!==32&&i[p+1]!==9)a=p+1,t.state=Ki.value;else a=p+1,t.state=Ki.whitespace;break}else if(BLe[i[p]]!==1)return o("InvalidHeaderName")}if(p===u)return t.key+=e.decode(i.subarray(a,u)).toLowerCase(),YI}if(t.state===Ki.whitespace){for(;a<u;a++){if(t.size++>16384)return o("HeaderTooLarge");if(i[a]!==32&&i[a]!==9){t.state=Ki.value;break}}if(a===u)return YI}if(t.state===Ki.value){let p=a;if(l!==void 0)p=l,l=void 0;for(;p<u;p++){if(t.size++>16384)return o("HeaderTooLarge");if(i[p]===13||t.crlf>0){let f=i[p];if(f===13&&t.crlf===0)t.crlf=1,p++,t.size++,f=i[p];if(f===10&&t.crlf===1)t.crlf=2,p++,t.size++,f=i[p];if(f===13&&t.crlf===2)t.crlf=3,p++,t.size++,f=i[p];if(f===10&&t.crlf===3)t.crlf=4,p++,t.size++;if(t.crlf<4&&p>=u)return t.previousChunk=i.subarray(a),YI;else if(t.crlf>=2){t.value=t.value===void 0?i.subarray(a,p-t.crlf):n(t.value,i.subarray(a,p-t.crlf));let A=e.decode(t.value);if(t.headers[t.key]===void 0)t.headers[t.key]=A;else if(typeof t.headers[t.key]==="string")t.headers[t.key]=[t.headers[t.key],A];else t.headers[t.key].push(A);if(a=p,t.size--,t.crlf!==4&&t.pairs===100)return o("TooManyHeaders");else if(t.crlf===3)return o("InvalidHeaderValue");else if(t.crlf===4)return r({_tag:"Headers",headers:t.headers,endPosition:a-c});t.pairs++,t.key="",t.value=void 0,t.crlf=0,t.state=Ki.key;continue e}}else if(QLe[i[p]]!==1)return o("InvalidHeaderValue")}if(p===u)return t.value=t.value===void 0?i.subarray(a,u):n(t.value,i.subarray(a,u)),YI}}if(a>u)t.size+=u-a;return YI}}function RLe(e){let t=new TextEncoder().encode(e),r=t.length,n={};for(let o=0;o<r;o++){let s=t[o];if(n[s]===void 0)n[s]=[];n[s].push(o)}return{needle:t,needleLength:r,indexes:n,firstByte:t[0],previousChunk:void 0,previousChunkLength:0,matchIndex:0}}function Nse(e,t,r){let n=RLe(e);if(r!==void 0)n.previousChunk=r,n.previousChunkLength=r.length;function o(){if("Buffer"in globalThis&&!(("Bun"in globalThis)||("Deno"in globalThis)))return function(l,u,p){return Buffer.prototype.indexOf.call(l,u,p)};let c=new Uint8Array(256).fill(n.needle.length);for(let l=0,u=n.needle.length-1;l<u;++l)c[n.needle[l]]=u-l;return function(l,u,p){let f=l.length,A=p+n.needleLength-1;while(A<f){for(let d=n.needleLength-1,g=A;d>=0&&l[g]===u[d];d--,g--)if(d===0)return g;A+=c[l[A]]}return-1}}let s=o();function i(c){let l=c.length;if(n.previousChunk!==void 0){let p=new Uint8Array(n.previousChunkLength+l);p.set(n.previousChunk),p.set(c,n.previousChunkLength),c=p,l=n.previousChunkLength+l,n.previousChunk=void 0}if(l<n.needleLength){n.previousChunk=c,n.previousChunkLength=l;return}let u=0;while(u<l){let p=s(c,n.needle,u);if(p>-1){if(p>u)t(n.matchIndex,c.subarray(u,p));n.matchIndex+=1,u=p+n.needleLength;continue}else if(c[l-1]in n.indexes){let f=n.indexes[c[l-1]],A=-1;for(let d=0,g=f.length;d<g;d++){let x=f[d];if(c[l-1-x]===n.firstByte&&d>A)A=x}if(A===-1)if(u===0)t(n.matchIndex,c);else t(n.matchIndex,c.subarray(u));else{if(l-1-A>u)t(n.matchIndex,c.subarray(u,l-1-A));n.previousChunk=c.subarray(l-1-A),n.previousChunkLength=A+1}}else if(u===0)t(n.matchIndex,c);else t(n.matchIndex,c.subarray(u));break}}function a(){if(n.previousChunk!==void 0&&n.previousChunk!==r)t(n.matchIndex,n.previousChunk);n.previousChunk=r,n.previousChunkLength=r?.length??0,n.matchIndex=0}return{write:i,end:a}}var mu;(function(e){e[e.headers=0]="headers",e[e.body=1]="body"})(mu||(mu={}));var DLe={_tag:"InvalidDisposition"},TLe={_tag:"EndNotReached"},vLe={_tag:"ReachedLimit",limit:"MaxParts"},OLe={_tag:"ReachedLimit",limit:"MaxTotalSize"},FLe={_tag:"ReachedLimit",limit:"MaxPartSize"},_se={_tag:"ReachedLimit",limit:"MaxFieldSize"},MLe=new TextEncoder().encode(`\r
|
|
180
|
+
`))e=e.replace(sLe,"%0A");if(e.includes("\r"))e=e.replace(iLe,"%0D");if(e.includes("\t"))e=e.replace(aLe,"%09");return e}var gW=EW.of({[RT]:RT,resolve:pse,normalize(e){if(e.length===0)return".";let t=e.charCodeAt(0)===47,r=e.charCodeAt(e.length-1)===47;if(e=use(e,!t),e.length===0&&!t)e=".";if(e.length>0&&r)e+="/";if(t)return"/"+e;return e},isAbsolute(e){return e.length>0&&e.charCodeAt(0)===47},join(){if(arguments.length===0)return".";let e;for(let t=0;t<arguments.length;++t){let r=arguments[t];if(r.length>0)if(e===void 0)e=r;else e+="/"+r}if(e===void 0)return".";return gW.normalize(e)},relative(e,t){if(e===t)return"";if(e=gW.resolve(e),t=gW.resolve(t),e===t)return"";let r=1;for(;r<e.length;++r)if(e.charCodeAt(r)!==47)break;let n=e.length,o=n-r,s=1;for(;s<t.length;++s)if(t.charCodeAt(s)!==47)break;let a=t.length-s,c=o<a?o:a,l=-1,u=0;for(;u<=c;++u){if(u===c){if(a>c){if(t.charCodeAt(s+u)===47)return t.slice(s+u+1);else if(u===0)return t.slice(s+u)}else if(o>c){if(e.charCodeAt(r+u)===47)l=u;else if(u===0)l=0}break}let f=e.charCodeAt(r+u),A=t.charCodeAt(s+u);if(f!==A)break;else if(f===47)l=u}let p="";for(u=r+l+1;u<=n;++u)if(u===n||e.charCodeAt(u)===47)if(p.length===0)p+="..";else p+="/..";if(p.length>0)return p+t.slice(s+l);else{if(s+=l,t.charCodeAt(s)===47)++s;return t.slice(s)}},dirname(e){if(e.length===0)return".";let t=e.charCodeAt(0),r=t===47,n=-1,o=!0;for(let s=e.length-1;s>=1;--s)if(t=e.charCodeAt(s),t===47){if(!o){n=s;break}}else o=!1;if(n===-1)return r?"/":".";if(r&&n===1)return"//";return e.slice(0,n)},basename(e,t){let r=0,n=-1,o=!0,s;if(t!==void 0&&t.length>0&&t.length<=e.length){if(t.length===e.length&&t===e)return"";let i=t.length-1,a=-1;for(s=e.length-1;s>=0;--s){let c=e.charCodeAt(s);if(c===47){if(!o){r=s+1;break}}else{if(a===-1)o=!1,a=s+1;if(i>=0)if(c===t.charCodeAt(i)){if(--i===-1)n=s}else i=-1,n=a}}if(r===n)n=a;else if(n===-1)n=e.length;return e.slice(r,n)}else{for(s=e.length-1;s>=0;--s)if(e.charCodeAt(s)===47){if(!o){r=s+1;break}}else if(n===-1)o=!1,n=s+1;if(n===-1)return"";return e.slice(r,n)}},extname(e){let t=-1,r=0,n=-1,o=!0,s=0;for(let i=e.length-1;i>=0;--i){let a=e.charCodeAt(i);if(a===47){if(!o){r=i+1;break}continue}if(n===-1)o=!1,n=i+1;if(a===46){if(t===-1)t=i;else if(s!==1)s=1}else if(t!==-1)s=-1}if(t===-1||n===-1||s===0||s===1&&t===n-1&&t===r+1)return"";return e.slice(t,n)},format:function(t){if(t===null||typeof t!=="object")throw TypeError('The "pathObject" argument must be of type Object. Received type '+typeof t);return XUe("/",t)},parse(e){let t={root:"",dir:"",base:"",ext:"",name:""};if(e.length===0)return t;let r=e.charCodeAt(0),n=r===47,o;if(n)t.root="/",o=1;else o=0;let s=-1,i=0,a=-1,c=!0,l=e.length-1,u=0;for(;l>=o;--l){if(r=e.charCodeAt(l),r===47){if(!c){i=l+1;break}continue}if(a===-1)c=!1,a=l+1;if(r===46){if(s===-1)s=l;else if(u!==1)u=1}else if(s!==-1)u=-1}if(s===-1||a===-1||u===0||u===1&&s===a-1&&s===i+1){if(a!==-1)if(i===0&&n)t.base=t.name=e.slice(1,a);else t.base=t.name=e.slice(i,a)}else{if(i===0&&n)t.name=e.slice(1,s),t.base=e.slice(1,a);else t.name=e.slice(i,s),t.base=e.slice(i,a);t.ext=e.slice(s,a)}if(i>0)t.dir=e.slice(0,i-1);else if(n)t.dir="/";return t},sep:"/",fromFileUrl:eLe,toFileUrl:rLe,toNamespacedPath:X});var xW=Symbol.for("@effect/platform/HttpServer"),fse=Ke("@effect/platform/HttpServer"),uLe={[xW]:xW};var Ase=(e)=>Object.assign(Object.create(uLe),e);var yW=fse,dse=Ase;var SW=HI,kf=fx,fLe=ose;var ALe=sse;var IW=ase;var dLe=ise;var dx=Symbol.for("@effect/platform/HttpServerRespondable"),hse=(e)=>ee(e,dx),hLe=kf({status:400}),mLe=kf({status:404});var mse=(e,t)=>{if(SW(e))return Z(e);else if(hse(e))return rn(e[dx](),()=>Z(t));else if(NE(e))return Z(hLe);else if(D9(e))return Z(mLe);return Z(t)},gse=(e,t)=>{if(SW(e))return Z(e);else if(hse(e))return rn(e[dx](),()=>Z(t));return Z(t)};var yse=Symbol.for("@effect/platform/HttpServerError");var DT=Ae("@effect/platform/HttpServerError/clientAbortFiberId",()=>fw(-499,0)),Cse=(e)=>{let t=Z(kT),r=Ud,n=!1,o=!1;R9(e,void 0,(a,c)=>{let l=pk(r)?Ud:r;switch(c._tag){case"Fail":{t=mse(c.error,kT),r=xse(l,c);break}case"Die":{let u=HI(c.defect);t=gse(c.defect,kT),r=u?l:xse(l,c),o=o||u;break}case"Interrupt":{if(n=n||c.fiberId===DT,Vp(r)&&!o)r=c;break}}return T()});let s=!o&&pk(r)?Z(n?gLe:ELe):t,i=!o&&pk(r)&&n?rE(DT):r;return z(s,(a)=>{if(Vp(i))return[a,Ud];return[a,Ld(i,$s(a))]})},xse=(e,t)=>{if(Vp(e))return t;else if(Vp(t))return e;return Ld(e,t)},Sse=(e)=>{let t,r=w9(e,(n)=>{if(HI(n))return t=n,M(Ud);return T()});return[t??kT,r]},kT=fx({status:500}),gLe=fx({status:499}),ELe=fx({status:503}),Ise=(e)=>{if(e._tag==="Success")return e.value;return Sse(e.cause)[0]};var bW=yse;class WI extends qc(bW,"RequestError"){[dx](){return kf({status:400})}get methodAndUrl(){return`${this.request.method} ${this.request.url}`}get message(){return this.description?`${this.reason}: ${this.description} (${this.methodAndUrl})`:`${this.reason} error (${this.methodAndUrl})`}}class TT extends qc(bW,"ResponseError"){[dx](){return kf({status:500})}get methodAndUrl(){return`${this.request.method} ${this.request.url}`}get message(){let e=`${this.response.status} ${this.methodAndUrl}`;return this.description?`${this.description} (${e})`:`${this.reason} error (${e})`}}class vT extends qc(bW,"ServeError"){}var OT=DT,qI=Cse;var bse=Ise;var NT=Symbol.for("effect/Mailbox"),BW=Symbol.for("effect/Mailbox/ReadonlyMailbox");var wh=Lt(),Bse=yt(wh),FT=yt(!1),MT=yt(!0),Qse=[wh,!0];class wse extends Is{scheduler;capacity;strategy;[NT]=NT;[BW]=BW;state={_tag:"Open",takers:new Set,offers:new Set,awaiters:new Set};messages=[];messagesChunk=Lt();constructor(e,t,r){super();this.scheduler=e,this.capacity=t,this.strategy=r}offer(e){return Me(()=>{if(this.state._tag!=="Open")return FT;else if(this.messages.length+this.messagesChunk.length>=this.capacity)switch(this.strategy){case"dropping":return FT;case"suspend":if(this.capacity<=0&&this.state.takers.size>0)return this.messages.push(e),this.releaseTaker(),MT;return this.offerRemainingSingle(e);case"sliding":return this.unsafeTake(),this.messages.push(e),MT}return this.messages.push(e),this.scheduleReleaseTaker(),MT})}unsafeOffer(e){if(this.state._tag!=="Open")return!1;else if(this.messages.length+this.messagesChunk.length>=this.capacity){if(this.strategy==="sliding")return this.unsafeTake(),this.messages.push(e),!0;else if(this.capacity<=0&&this.state.takers.size>0)return this.messages.push(e),this.releaseTaker(),!0;return!1}return this.messages.push(e),this.scheduleReleaseTaker(),!0}offerAll(e){return Me(()=>{if(this.state._tag!=="Open")return te(Ln(e));let t=this.unsafeOfferAllArray(e);if(t.length===0)return Bse;else if(this.strategy==="dropping")return te(Qr(t));return this.offerRemainingArray(t)})}unsafeOfferAll(e){return Qr(this.unsafeOfferAllArray(e))}unsafeOfferAllArray(e){if(this.state._tag!=="Open")return et(e);else if(this.capacity===Number.POSITIVE_INFINITY||this.strategy==="sliding"){if(this.messages.length>0)this.messagesChunk=$t(this.messagesChunk,Qr(this.messages));if(this.strategy==="sliding")this.messagesChunk=this.messagesChunk.pipe($t(Ln(e)),gN(this.capacity));else if(VA(e))this.messagesChunk=$t(this.messagesChunk,e);else this.messages=et(e);return this.scheduleReleaseTaker(),[]}let t=this.capacity<=0?this.state.takers.size:this.capacity-this.messages.length-this.messagesChunk.length;if(t===0)return et(e);let r=[],n=0;for(let o of e){if(n<t)this.messages.push(o);else r.push(o);n++}return this.scheduleReleaseTaker(),r}fail(e){return this.done(Ml(e))}failCause(e){return this.done(dt(e))}unsafeDone(e){if(this.state._tag!=="Open")return!1;else if(this.state.offers.size===0&&this.messages.length===0&&this.messagesChunk.length===0)return this.finalize(e),!0;return this.state={...this.state,_tag:"Closing",exit:e},!0}shutdown=j(()=>{if(this.state._tag==="Done")return!0;this.messages=[],this.messagesChunk=wh;let e=this.state.offers;if(this.finalize(this.state._tag==="Open"?Rr:this.state.exit),e.size>0){for(let t of e)if(t._tag==="Single")t.resume(FT);else t.resume(yt(Qr(t.remaining.slice(t.offset))));e.clear()}return!0});done(e){return j(()=>this.unsafeDone(e))}end=this.done(Rr);clear=Me(()=>{if(this.state._tag==="Done")return kg(this.state.exit,wh);let e=this.unsafeTakeAll();return this.releaseCapacity(),te(e)});takeAll=Me(()=>{if(this.state._tag==="Done")return kg(this.state.exit,Qse);let e=this.unsafeTakeAll();if(e.length===0)return xt(this.awaitTake,this.takeAll);return te([e,this.releaseCapacity()])});takeN(e){return Me(()=>{if(this.state._tag==="Done")return kg(this.state.exit,Qse);else if(e<=0)return te([wh,!1]);e=Math.min(e,this.capacity);let t;if(e<=this.messagesChunk.length)t=Xm(this.messagesChunk,e),this.messagesChunk=Ca(this.messagesChunk,e);else if(e<=this.messages.length+this.messagesChunk.length)this.messagesChunk=$t(this.messagesChunk,Qr(this.messages)),this.messages=[],t=Xm(this.messagesChunk,e),this.messagesChunk=Ca(this.messagesChunk,e);else return xt(this.awaitTake,this.takeN(e));return te([t,this.releaseCapacity()])})}unsafeTake(){if(this.state._tag==="Done")return rR(this.state.exit,Ml(new k9));let e;if(this.messagesChunk.length>0)e=oC(this.messagesChunk),this.messagesChunk=Ca(this.messagesChunk,1);else if(this.messages.length>0)e=this.messages[0],this.messagesChunk=Ca(Qr(this.messages),1),this.messages=[];else if(this.capacity<=0&&this.state.offers.size>0)return this.capacity=1,this.releaseCapacity(),this.capacity=0,this.messages.length>0?yt(this.messages.pop()):void 0;else return;return this.releaseCapacity(),yt(e)}take=Me(()=>this.unsafeTake()??xt(this.awaitTake,this.take));await=Ac((e)=>{if(this.state._tag==="Done")return e(this.state.exit);return this.state.awaiters.add(e),j(()=>{if(this.state._tag!=="Done")this.state.awaiters.delete(e)})});unsafeSize(){let e=this.messages.length+this.messagesChunk.length;return this.state._tag==="Done"?T():M(e)}size=j(()=>this.unsafeSize());commit(){return this.takeAll}pipe(){return W(this,arguments)}toJSON(){return{_id:"effect/Mailbox",state:this.state._tag,size:this.unsafeSize().toJSON()}}toString(){return Ve(this)}[ke](){return Ve(this)}offerRemainingSingle(e){return Ac((t)=>{if(this.state._tag!=="Open")return t(FT);let r={_tag:"Single",message:e,resume:t};return this.state.offers.add(r),j(()=>{if(this.state._tag==="Open")this.state.offers.delete(r)})})}offerRemainingArray(e){return Ac((t)=>{if(this.state._tag!=="Open")return t(yt(Qr(e)));let r={_tag:"Array",remaining:e,offset:0,resume:t};return this.state.offers.add(r),j(()=>{if(this.state._tag==="Open")this.state.offers.delete(r)})})}releaseCapacity(){if(this.state._tag==="Done")return this.state.exit._tag==="Success";else if(this.state.offers.size===0){if(this.state._tag==="Closing"&&this.messages.length===0&&this.messagesChunk.length===0)return this.finalize(this.state.exit),this.state.exit._tag==="Success";return!1}let e=this.capacity-this.messages.length-this.messagesChunk.length;for(let t of this.state.offers)if(e===0)return!1;else if(t._tag==="Single")this.messages.push(t.message),e--,t.resume(MT),this.state.offers.delete(t);else{for(;t.offset<t.remaining.length;t.offset++){if(e===0)return!1;this.messages.push(t.remaining[t.offset]),e--}t.resume(Bse),this.state.offers.delete(t)}return!1}awaitTake=Ac((e)=>{if(this.state._tag==="Done")return e(this.state.exit);return this.state.takers.add(e),j(()=>{if(this.state._tag!=="Done")this.state.takers.delete(e)})});scheduleRunning=!1;scheduleReleaseTaker(){if(this.scheduleRunning)return;this.scheduleRunning=!0,this.scheduler.scheduleTask(this.releaseTaker,0)}releaseTaker=()=>{if(this.scheduleRunning=!1,this.state._tag==="Done")return;else if(this.state.takers.size===0)return;for(let e of this.state.takers)if(this.state.takers.delete(e),e(Rr),this.messages.length+this.messagesChunk.length===0)break};unsafeTakeAll(){if(this.messagesChunk.length>0){let e=this.messages.length>0?$t(this.messagesChunk,Qr(this.messages)):this.messagesChunk;return this.messagesChunk=wh,this.messages=[],e}else if(this.messages.length>0){let e=Qr(this.messages);return this.messages=[],e}else if(this.state._tag!=="Done"&&this.state.offers.size>0)return this.capacity=1,this.releaseCapacity(),this.capacity=0,at(this.messages.pop());return wh}finalize(e){if(this.state._tag==="Done")return;let t=this.state;this.state={_tag:"Done",exit:e};for(let r of t.takers)r(e);t.takers.clear();for(let r of t.awaiters)r(e);t.awaiters.clear()}}var Rse=(e)=>rt((t)=>te(new wse(t.currentScheduler,typeof e==="number"?e:e?.capacity??Number.POSITIVE_INFINITY,typeof e==="number"?"suspend":e?.strategy??"suspend")));var QW=(e)=>{let t=Ze(e.takeAll,([r,n])=>n?r.length===0?jn:ht(r):cu(ht(r),t));return t},kse=(e)=>JD(QW(e));var CLe=NT;var Dse=(e)=>ee(e,CLe);var Df=Rse;var Tse=QW,vse=kse;var Ose=/; *([!#$%&'*+.^\w`|~-]+)=("(?:[\v\u0020\u0021\u0023-\u005b\u005d-\u007e\u0080-\u{10ffff}]|\\[\v\u0020-\u{10ffff}])*"|[!#$%&'*+.^\w`|~-]+) */gu,Fse=/\\([\v\u0020-\u{10ffff}])/gu,SLe=/^[!#$%&'*+.^\w|~-]+\/[!#$%&'*+.^\w|~-]+$/u,ILe=/^[!#$%&'*+.^\w|~-]+$/u,UT={value:"",parameters:Object.create(null)};function LT(e,t=!1){if(typeof e!=="string")return UT;let r=e.indexOf(";"),n=r!==-1?e.slice(0,r).trim():e.trim();if((t?ILe:SLe).test(n)===!1)return UT;let s={value:n.toLowerCase(),parameters:Object.create(null)};if(r===-1)return s;let i,a,c;Ose.lastIndex=r;while(a=Ose.exec(e)){if(a.index!==r)return UT;if(r+=a[0].length,i=a[1].toLowerCase(),c=a[2],c[0]==='"')c=c.slice(1,c.length-1),!t&&Fse.test(c)&&(c=c.replace(Fse,"$1"));s.parameters[i]=c}if(r!==e.length)return UT;return s}var Ki;(function(e){e[e.key=0]="key",e[e.whitespace=1]="whitespace",e[e.value=2]="value"})(Ki||(Ki={}));var YI={_tag:"Continue"},BLe=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,1,1,1,1,1,0,0,1,1,0,1,1,0,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,1,0,1],QLe=[0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1];function Mse(){let e=new TextDecoder,t={state:Ki.key,headers:Object.create(null),key:"",value:void 0,crlf:0,previousChunk:void 0,pairs:0,size:0};function r(s){return t.state=Ki.key,t.headers=Object.create(null),t.key="",t.value=void 0,t.crlf=0,t.previousChunk=void 0,t.pairs=0,t.size=0,s}function n(s,i){let a=new Uint8Array(s.length+i.length);return a.set(s),a.set(i,s.length),a}function o(s){return r({_tag:"Failure",reason:s,headers:t.headers})}return function(i,a){let c=0,l;if(t.previousChunk!==void 0){c=t.previousChunk.length,l=c;let p=new Uint8Array(i.length+c);p.set(t.previousChunk),p.set(i,c),t.previousChunk=void 0,i=p}let u=i.length;e:while(a<u){if(t.state===Ki.key){let p=a;for(;p<u;p++){if(t.size++>16384)return o("HeaderTooLarge");if(i[p]===58){if(t.key+=e.decode(i.subarray(a,p)).toLowerCase(),t.key.length===0)return o("InvalidHeaderName");if(i[p+1]===32&&i[p+2]!==32&&i[p+2]!==9)a=p+2,t.state=Ki.value,t.size++;else if(i[p+1]!==32&&i[p+1]!==9)a=p+1,t.state=Ki.value;else a=p+1,t.state=Ki.whitespace;break}else if(BLe[i[p]]!==1)return o("InvalidHeaderName")}if(p===u)return t.key+=e.decode(i.subarray(a,u)).toLowerCase(),YI}if(t.state===Ki.whitespace){for(;a<u;a++){if(t.size++>16384)return o("HeaderTooLarge");if(i[a]!==32&&i[a]!==9){t.state=Ki.value;break}}if(a===u)return YI}if(t.state===Ki.value){let p=a;if(l!==void 0)p=l,l=void 0;for(;p<u;p++){if(t.size++>16384)return o("HeaderTooLarge");if(i[p]===13||t.crlf>0){let f=i[p];if(f===13&&t.crlf===0)t.crlf=1,p++,t.size++,f=i[p];if(f===10&&t.crlf===1)t.crlf=2,p++,t.size++,f=i[p];if(f===13&&t.crlf===2)t.crlf=3,p++,t.size++,f=i[p];if(f===10&&t.crlf===3)t.crlf=4,p++,t.size++;if(t.crlf<4&&p>=u)return t.previousChunk=i.subarray(a),YI;else if(t.crlf>=2){t.value=t.value===void 0?i.subarray(a,p-t.crlf):n(t.value,i.subarray(a,p-t.crlf));let A=e.decode(t.value);if(t.headers[t.key]===void 0)t.headers[t.key]=A;else if(typeof t.headers[t.key]==="string")t.headers[t.key]=[t.headers[t.key],A];else t.headers[t.key].push(A);if(a=p,t.size--,t.crlf!==4&&t.pairs===100)return o("TooManyHeaders");else if(t.crlf===3)return o("InvalidHeaderValue");else if(t.crlf===4)return r({_tag:"Headers",headers:t.headers,endPosition:a-c});t.pairs++,t.key="",t.value=void 0,t.crlf=0,t.state=Ki.key;continue e}}else if(QLe[i[p]]!==1)return o("InvalidHeaderValue")}if(p===u)return t.value=t.value===void 0?i.subarray(a,u):n(t.value,i.subarray(a,u)),YI}}if(a>u)t.size+=u-a;return YI}}function RLe(e){let t=new TextEncoder().encode(e),r=t.length,n={};for(let o=0;o<r;o++){let s=t[o];if(n[s]===void 0)n[s]=[];n[s].push(o)}return{needle:t,needleLength:r,indexes:n,firstByte:t[0],previousChunk:void 0,previousChunkLength:0,matchIndex:0}}function Nse(e,t,r){let n=RLe(e);if(r!==void 0)n.previousChunk=r,n.previousChunkLength=r.length;function o(){if("Buffer"in globalThis&&!(("Bun"in globalThis)||("Deno"in globalThis)))return function(l,u,p){return Buffer.prototype.indexOf.call(l,u,p)};let c=new Uint8Array(256).fill(n.needle.length);for(let l=0,u=n.needle.length-1;l<u;++l)c[n.needle[l]]=u-l;return function(l,u,p){let f=l.length,A=p+n.needleLength-1;while(A<f){for(let d=n.needleLength-1,g=A;d>=0&&l[g]===u[d];d--,g--)if(d===0)return g;A+=c[l[A]]}return-1}}let s=o();function i(c){let l=c.length;if(n.previousChunk!==void 0){let p=new Uint8Array(n.previousChunkLength+l);p.set(n.previousChunk),p.set(c,n.previousChunkLength),c=p,l=n.previousChunkLength+l,n.previousChunk=void 0}if(l<n.needleLength){n.previousChunk=c,n.previousChunkLength=l;return}let u=0;while(u<l){let p=s(c,n.needle,u);if(p>-1){if(p>u)t(n.matchIndex,c.subarray(u,p));n.matchIndex+=1,u=p+n.needleLength;continue}else if(c[l-1]in n.indexes){let f=n.indexes[c[l-1]],A=-1;for(let d=0,g=f.length;d<g;d++){let x=f[d];if(c[l-1-x]===n.firstByte&&d>A)A=x}if(A===-1)if(u===0)t(n.matchIndex,c);else t(n.matchIndex,c.subarray(u));else{if(l-1-A>u)t(n.matchIndex,c.subarray(u,l-1-A));n.previousChunk=c.subarray(l-1-A),n.previousChunkLength=A+1}}else if(u===0)t(n.matchIndex,c);else t(n.matchIndex,c.subarray(u));break}}function a(){if(n.previousChunk!==void 0&&n.previousChunk!==r)t(n.matchIndex,n.previousChunk);n.previousChunk=r,n.previousChunkLength=r?.length??0,n.matchIndex=0}return{write:i,end:a}}var mu;(function(e){e[e.headers=0]="headers",e[e.body=1]="body"})(mu||(mu={}));var DLe={_tag:"InvalidDisposition"},TLe={_tag:"EndNotReached"},vLe={_tag:"ReachedLimit",limit:"MaxParts"},OLe={_tag:"ReachedLimit",limit:"MaxTotalSize"},FLe={_tag:"ReachedLimit",limit:"MaxPartSize"},_se={_tag:"ReachedLimit",limit:"MaxFieldSize"},MLe=new TextEncoder().encode(`\r
|
|
181
181
|
`);function wW(e){return e.filename!==void 0||e.contentType==="application/octet-stream"}function NLe(e){return LT(e["content-type"]).parameters.boundary}function PT(e){}function Lse({headers:e,onFile:t,onField:r,onError:n,onDone:o,isFile:s=wW,maxParts:i=1/0,maxTotalSize:a=1/0,maxPartSize:c=1/0,maxFieldSize:l=1048576}){let u=NLe(e);if(u===void 0)return n({_tag:"InvalidBoundary"}),{write:PT,end(){}};let p={state:mu.headers,index:0,parts:0,onChunk:PT,info:void 0,headerSkip:0,partSize:0,totalSize:0,isFile:!1,fieldChunks:[],fieldSize:0};function f(){p.state=mu.body,p.isFile=!0,p.onChunk=PT}let A=Mse(),d=Nse(`\r
|
|
182
182
|
--${u}`,function(g,x){if(g===0){f();return}else if(g!==p.index){if(p.index>0)if(p.isFile)p.onChunk(null),p.partSize=0;else{if(p.fieldChunks.length===1)r(p.info,p.fieldChunks[0]);else{let y=new Uint8Array(p.fieldSize),S=0;for(let I=0;I<p.fieldChunks.length;I++){let B=p.fieldChunks[I];y.set(B,S),S+=B.length}r(p.info,y)}p.fieldSize=0,p.fieldChunks=[]}if(p.state=mu.headers,p.index=g,p.headerSkip=2,x[0]===45&&x[1]===45)return o();if(p.parts++,p.parts>i)n(vLe)}if((p.partSize+=x.length)>c)n(FLe);if(p.state===mu.headers){let y=A(x,p.headerSkip);if(p.headerSkip=0,y._tag==="Continue")return;else if(y._tag==="Failure")return f(),n({_tag:"BadHeaders",error:y});let S=LT(y.headers["content-type"]),I=LT(y.headers["content-disposition"],!0);if(I.value==="form-data"&&!("name"in I.parameters))return f(),n(DLe);let B;if("filename*"in I.parameters){let R=I.parameters["filename*"].split("''");if(R.length===2)B=decodeURIComponent(R[1])}if(p.info={name:I.parameters.name??"",filename:B??I.parameters.filename,contentType:S.value===""?I.parameters.filename!==void 0?"application/octet-stream":"text/plain":S.value,contentTypeParameters:S.parameters,contentDisposition:I.value,contentDispositionParameters:I.parameters,headers:y.headers},p.state=mu.body,p.isFile=s(p.info),p.isFile)p.onChunk=t(p.info);if(y.endPosition<x.length)if(p.isFile)p.onChunk(x.subarray(y.endPosition));else{let R=x.subarray(y.endPosition);if((p.fieldSize+=R.length)>l)n(_se);p.fieldChunks.push(R)}}else if(p.isFile)p.onChunk(x);else{if((p.fieldSize+=x.length)>l)n(_se);p.fieldChunks.push(x)}},MLe);return{write(g){if((p.totalSize+=g.length)>a)return n(OLe);return d.write(g)},end(){if(d.end(),p.state===mu.body)n(TLe);p.state=mu.headers,p.index=0,p.parts=0,p.onChunk=PT,p.info=void 0,p.totalSize=0,p.partSize=0,p.fieldChunks=[],p.fieldSize=0}}}var Use=new TextDecoder("utf-8");function _Le(e){if(e==="utf-8"||e==="utf8"||e==="")return Use;try{return new TextDecoder(e)}catch(t){return Use}}function Pse(e,t){return _Le(e.contentTypeParameters.charset??"utf-8").decode(t)}var RW=Lse,Hse=wW,kW=Pse;var Rh=RT,Jr=EW;var kh=Symbol.for("@effect/platform/Multipart");var qse=Symbol.for("@effect/platform/Multipart/MultipartError");class ci extends ot()("MultipartError",{reason:_("FileTooLarge","FieldTooLarge","BodyTooLarge","TooManyParts","InternalError","Parse"),cause:bt}){[qse]=qse;get message(){return this.reason}}var Gse=(e)=>mr((t)=>{let r=Ot(t.currentContext,Kse);return Z({headers:e,maxParts:pt(Ot(t.currentContext,zse)),maxFieldSize:Number(Ot(t.currentContext,jse)),maxPartSize:Ot(t.currentContext,$se).pipe(jt(Number),pt),maxTotalSize:Ot(t.currentContext,If).pipe(jt(Number),pt),isFile:r.length===0?void 0:(n)=>!Oj(r,(o)=>n.contentType.includes(o))&&Hse(n)})});class Yse extends ha{[kh];constructor(){super();this[kh]=kh}}var LLe=(e,t)=>w(Cn,(r)=>De(xf(t.content,r.sink(e)),(n)=>new ci({reason:"InternalError",cause:n})));var Vse=(e,t=LLe)=>_e(function*(){let r=yield*Cn,n=yield*Jr,o=yield*r.makeTempDirectoryScoped(),s=Object.create(null);return yield*w1(e,(i)=>{if(i._tag==="Field"){if(!(i.key in s))s[i.key]=i.value;else if(typeof s[i.key]==="string")s[i.key]=[s[i.key],i.value];else s[i.key].push(i.value);return Y}else if(i.name==="")return Y;let a=i,c=n.join(o,n.basename(a.name).slice(-128)),l=new Jse(a.key,a.name,a.contentType,c);if(Array.isArray(s[i.key]))s[i.key].push(l);else s[i.key]=[l];return t(c,a)}),s}).pipe(yS({SystemError:(r)=>ce(new ci({reason:"InternalError",cause:r})),BadArgument:(r)=>ce(new ci({reason:"InternalError",cause:r}))}));class Jse extends Yse{key;name;contentType;path;_tag="PersistedFile";constructor(e,t,r,n){super();this.key=e,this.name=t,this.contentType=r,this.path=n}toJSON(){return{_id:"@effect/platform/Multipart/Part",_tag:"PersistedFile",key:this.key,name:this.name,contentType:this.contentType,path:this.path}}}class zse extends hr()("@effect/platform/Multipart/MaxParts",{defaultValue:T}){}class jse extends hr()("@effect/platform/Multipart/MaxFieldSize",{defaultValue:Yu(Gc(10485760))}){}class $se extends hr()("@effect/platform/Multipart/MaxFileSize",{defaultValue:T}){}class Kse extends hr()("@effect/platform/Multipart/FieldMimeTypes",{defaultValue:Yu(np("application/json"))}){}var Zse=Symbol.for("@effect/platform/Socket");var Xse=Ke("@effect/platform/Socket"),HLe=Symbol.for("@effect/platform/Socket/CloseEvent");var eie=(e)=>ee(e,HLe),DW=Symbol.for("@effect/platform/Socket/SocketError"),WLe=(e)=>ee(e,DW);class HT extends qc(DW,"SocketError"){get message(){return`An error occurred during ${this.reason}`}}class WT extends qc(DW,"SocketError"){static is(e){return WLe(e)&&e.reason==="Close"}static isClean(e){return function(t){return WT.is(t)&&e(t.code)}}get message(){if(this.closeReason)return`${this.reason}: ${this.code}: ${this.closeReason}`;return`${this.reason}: ${this.code}`}}var qLe=(e)=>e!==1000&&e!==1006,GLe=Ke("@effect/platform/Socket/WebSocket");var TW=(e,t)=>mr((r)=>{let n,o=Tc(!1),s=r.currentContext,i=t?.closeCodeIsError??qLe,a=(f,A)=>mE(Ht(function*(d){let g=yield*IE().pipe(Yl(d)),x=yield*Yl(e,d),y=yield*nn(nH(g)(),GLe,x),S=!1;function I(Q){if(Q.data instanceof Blob)return AE(()=>Q.data.arrayBuffer()).pipe(c6((F)=>f(new Uint8Array(F))),y);let P=f(Q.data);if(tn(P))y(P)}function B(Q){x.removeEventListener("message",I),x.removeEventListener("close",R),Yn(g.deferred,ce(new HT({reason:S?"Read":"Open",cause:Q})))}function R(Q){x.removeEventListener("message",I),x.removeEventListener("error",B),Yn(g.deferred,ce(new WT({reason:"Close",code:Q.code,closeReason:Q.reason})))}if(x.addEventListener("close",R,{once:!0}),x.addEventListener("error",B,{once:!0}),x.addEventListener("message",I),x.readyState!==1){let Q=Y8(r.id());x.addEventListener("open",()=>{S=!0,Yn(Q,Y)},{once:!0}),yield*ut(Q).pipe(zk({duration:t?.openTimeout??1e4,onTimeout:()=>new HT({reason:"OpenTimeout",cause:'timeout waiting for "open"'})}),$k(TS(g)))}if(S=!0,n=x,yield*o.open,A?.onOpen)yield*A.onOpen;return yield*TS(g).pipe(r6(WT.isClean((Q)=>!i(Q)),(Q)=>Y))})).pipe(gE((d)=>wr(s,d)),ws(se(()=>{o.unsafeClose(),n=void 0})),gr),c=new TextEncoder,l=(f,A)=>a((d)=>typeof d==="string"?f(c.encode(d)):d instanceof Uint8Array?f(d):f(new Uint8Array(d)),A),p=Z((f)=>o.whenOpen(se(()=>{let A=n;if(eie(f))A.close(f.code,f.reason);else A.send(f)})));return Z(Xse.of({[Zse]:Zse,run:l,runRaw:a,writer:p}))});var tie=Symbol.for("@effect/platform/HttpServerRequest"),rie=Ke("@effect/platform/HttpServerRequest");var nie=(e)=>{let t=e.headers.host??"localhost",r=e.headers["x-forwarded-proto"]==="https"?"https":"http";try{return M(new URL(e.url,`${r}://${t}`))}catch{return T()}};var qT=tie,Za=rie;var oie=nie;import*as VT from"node:child_process";var Xt=(e,t)=>(r,[n])=>{let o="Unknown";switch(r.code){case"ENOENT":o="NotFound";break;case"EACCES":o="PermissionDenied";break;case"EEXIST":o="AlreadyExists";break;case"EISDIR":o="BadResource";break;case"ENOTDIR":o="BadResource";break;case"EBUSY":o="Busy";break;case"ELOOP":o="BadResource";break}return new lu({reason:o,module:e,method:t,pathOrDescriptor:n,syscall:r.syscall,description:r.message,cause:r})};import{Readable as VLe}from"node:stream";var vf=(e,t,r)=>bh(iie(e,t,r)),sie=(e,t)=>{let r=t.maxBytes?Number(t.maxBytes):void 0;return ef(se(()=>{let n=e();return n.setEncoding(t.encoding??"utf8"),n}),(n)=>Dt((o)=>{let s="",i=0;n.once("error",(a)=>{o(ce(t.onFailure(a)))}),n.once("end",()=>{o(Z(s))}),n.on("data",(a)=>{if(s+=a,i+=Buffer.byteLength(a),r&&i>r)o(ce(t.onFailure(Error("maxBytes exceeded"))))})}),(n)=>se(()=>{if("closed"in n&&!n.closed)n.destroy()}))},GT=(e,t)=>{let r=t.maxBytes?Number(t.maxBytes):void 0;return ef(se(e),(n)=>Dt((o)=>{let s=Buffer.alloc(0),i=0;n.once("error",(a)=>{o(ce(t.onFailure(a)))}),n.once("end",()=>{o(Z(s))}),n.on("data",(a)=>{if(s=Buffer.concat([s,a]),i+=a.length,r&&i>r)o(ce(t.onFailure(Error("maxBytes exceeded"))))})}),(n)=>se(()=>{if("closed"in n&&!n.closed)n.destroy()}))};var iie=(e,t,r)=>q1(()=>zLe(e(),t,Ri(void 0),r)),aie=(e,t,{encoding:r,endOnDone:n=!0}={},o=Y)=>{let s=JLe(e,r),i=n?Dt((a)=>{if("closed"in e&&e.closed)a(Y);else e.once("finish",()=>a(Y)),e.end()}):Y;return{awaitRead:()=>Y,emit:s,error:(a)=>ve(i,t(a)),done:(a)=>ve(i,o)}},JLe=(e,t)=>(r)=>r.length===0?Y:Dt((n)=>{let o=r[Symbol.iterator](),s=o.next();function i(){let a=s;s=o.next();let c=e.write(a.value,t);if(s.done)n(Y);else if(c)i();else e.once("drain",i)}i()}),zLe=(e,t,r,n)=>{if(!e.readable)return vI;let o=Tc(!1);function s(){o.unsafeOpen()}function i(u){r.current=Pl(t(u)),o.unsafeOpen()}function a(){r.current=Fi,o.unsafeOpen()}e.on("readable",s),e.on("error",i),e.on("end",a);let c=n?.chunkSize?Number(n.chunkSize):void 0,l=q1(function u(){let p=e.read(c);if(p===null){if(r.current)return ioe(r.current);return o.unsafeClose(),Sf(o.await,u)}let f=[p];while(!0){if(p=e.read(c),p===null)return Sf(oT(Qr(f)),u);f.push(p)}});return soe(l,se(()=>{if(e.off("readable",s),e.off("error",i),e.off("end",a),n?.closeOnDone!==!1&&"closed"in e&&!e.closed)e.destroy()}))};class cie extends VLe{readLatch;fiber=void 0;constructor(e,t){super({});this.readLatch=Tc(!1),this.fiber=rs(e)(this.readLatch.whenOpen(QI(t,(r)=>this.readLatch.whenOpen(se(()=>{if(r.length===0)return;this.readLatch.unsafeClose();for(let n of r)if(typeof n==="string")this.push(n,"utf8");else this.push(n)}))))),this.fiber.addObserver((r)=>{if(this.fiber=void 0,Td(r))this.push(null);else this.destroy(bc(r.cause))})}_read(e){this.readLatch.unsafeOpen()}_destroy(e,t){if(!this.fiber)return t(e);jl(Xo(this.fiber)).addObserver((r)=>{t(r._tag==="Failure"?bc(r.cause):e)})}}var lie=(e)=>z(ts(),(t)=>new cie(t,e));var YT=(e,t,r)=>Fne(pie(e,t,r)),pie=(e,t,r)=>Sf(Ui(se(()=>e()),Pt()),([n,o])=>W1(jLe(n,o,t),aie(n,(s)=>Qc(o,s),r,Lk(o,Y)))),jLe=(e,t,r)=>Te(()=>{function n(o){Yn(t,ce(r(o)))}return e.on("error",n),ws(ut(t),se(()=>{e.removeListener("error",n)}))});var KLe=(e)=>typeof e==="string"?e:"pipe",fie=(e)=>typeof e==="string"?e:"pipe",JI=(e)=>e instanceof globalThis.Error?e:new globalThis.Error(String(e)),Of=(e,t,r)=>{let n=M1(r).reduce((o,s)=>{let i=`${s.command} ${s.args.join(" ")}`;return o.length===0?i:`${o} | ${i}`},"");return Xt("Command",e)(t,[n])},ZLe={[N1]:N1,...Ws,toJSON(){return{_id:"@effect/platform/CommandExecutor/Process",pid:this.pid}}},zI=(e)=>(t)=>{switch(t._tag){case"StandardCommand":{let r=w(Pt(),(s)=>Dt((i)=>{let a=VT.spawn(t.command,t.args,{stdio:[KLe(t.stdin),fie(t.stdout),fie(t.stderr)],cwd:je(t.cwd,Hm),shell:t.shell,env:{...process.env,...Object.fromEntries(t.env)},detached:process.platform!=="win32"});return a.on("error",(c)=>{i(ce(Of("spawn",c,t)))}),a.on("exit",(...c)=>{Yn(s,Z(c))}),a.on("spawn",()=>{i(Z([a,s]))}),se(()=>{a.kill("SIGTERM")})})),n=process.platform==="win32"?(s,i)=>Dt((a)=>{VT.exec(`taskkill /pid ${s.pid} /T /F`,(c)=>{if(c)a(ce(Of("kill",JI(c),t)));else a(Y)})}):(s,i)=>mo({try:()=>process.kill(-s.pid,i),catch:(a)=>Of("kill",JI(a),t)}),o=(s,i)=>Te(()=>s.kill(i)?Y:ce(Of("kill",new globalThis.Error("Failed to kill process"),t)));return E(Ge(t.cwd,{onNone:()=>Y,onSome:(s)=>e.access(s)}),ve(Mt(r,([s,i])=>w(Zp(i),(a)=>{if(!a)return n(s,"SIGTERM").pipe(e0(()=>o(s,"SIGTERM")),ve(ut(i)),La);return w(ut(i),([c])=>{if(c!==0&&c!==null)return n(s,"SIGTERM").pipe(La);return Y})}))),z(([s,i])=>{let a=Tne;if(s.stdin!==null)a=YT(()=>s.stdin,(d)=>Of("toWritable",JI(d),t));let c=w(ut(i),([d,g])=>{if(d!==null)return Z(Vne(d));return ce(Of("exitCode",new globalThis.Error(`Process interrupted due to receipt of signal: ${g}`),t))}),l=n6(Zp(i)),u=(d="SIGTERM")=>n(s,d).pipe(e0(()=>o(s,d)),ve(Pa(ut(i)))),p=Jne(s.pid),f=vf(()=>s.stderr,(d)=>Of("fromReadable(stderr)",JI(d),t)),A=vf(()=>s.stdout,(d)=>Of("fromReadable(stdout)",JI(d),t));if(typeof t.stdout!=="string")A=Rne(A,t.stdout);return Object.assign(Object.create(ZLe),{pid:p,exitCode:c,isRunning:l,kill:u,stdin:a,stderr:f,stdout:A})}),typeof t.stdin==="string"?X:Er((s)=>Vd(xf(t.stdin,s.stdin))))}case"PipedCommand":{let r=M1(t);if(r.length===1)return E(r[0],zI(e));let n=r[0],o=r.slice(1),s=o.slice(0,o.length-1),i=o[o.length-1],a=s.reduce((c,l)=>E(XD(l,c),zI(e),z((u)=>u.stdout),Wc),E(zI(e)(n),z((c)=>c.stdout),Wc));return E(XD(i,a),zI(e))}}},Aie=Wa(kI,E(Cn,z((e)=>zne(zI(e)))));var die=Aie;var hie=(e,t,r)=>(...n)=>Dt((o)=>{try{e(...n,(s,i)=>{if(s)o(ce(t?t(s,n):s));else o(Z(i))})}catch(s){o(r?ce(r(s,n)):Mo(s))}});var Mr=hie;import*as mie from"node:crypto";import*as Ue from"node:fs";import*as gie from"node:os";import*as hx from"node:path";var Cr=(e)=>(t)=>new ls({module:"FileSystem",method:e,cause:t}),rPe=(()=>{let e=Mr(Ue.access,Xt("FileSystem","access"),Cr("access"));return(t,r)=>{let n=Ue.constants.F_OK;if(r?.readable)n|=Ue.constants.R_OK;if(r?.writable)n|=Ue.constants.W_OK;return e(t,n)}})(),nPe=(()=>{let e=Mr(Ue.cp,Xt("FileSystem","copy"),Cr("copy"));return(t,r,n)=>e(t,r,{force:n?.overwrite??!1,preserveTimestamps:n?.preserveTimestamps??!1,recursive:!0})})(),oPe=(()=>{let e=Mr(Ue.copyFile,Xt("FileSystem","copyFile"),Cr("copyFile"));return(t,r)=>e(t,r)})(),sPe=(()=>{let e=Mr(Ue.chmod,Xt("FileSystem","chmod"),Cr("chmod"));return(t,r)=>e(t,r)})(),iPe=(()=>{let e=Mr(Ue.chown,Xt("FileSystem","chown"),Cr("chown"));return(t,r,n)=>e(t,r,n)})(),aPe=(()=>{let e=Mr(Ue.link,Xt("FileSystem","link"),Cr("link"));return(t,r)=>e(t,r)})(),cPe=(()=>{let e=Mr(Ue.mkdir,Xt("FileSystem","makeDirectory"),Cr("makeDirectory"));return(t,r)=>e(t,{recursive:r?.recursive??!1,mode:r?.mode})})(),OW=(e)=>{let t=Mr(Ue.mkdtemp,Xt("FileSystem",e),Cr(e));return(r)=>Te(()=>{let n=r?.prefix??"",o=typeof r?.directory==="string"?hx.join(r.directory,"."):gie.tmpdir();return t(n?hx.join(o,n):o+"/")})},lPe=OW("makeTempDirectory"),FW=(e)=>{let t=Mr(Ue.rm,Xt("FileSystem",e),Cr(e));return(r,n)=>t(r,{recursive:n?.recursive??!1,force:n?.force??!1})},uPe=FW("remove"),pPe=(()=>{let e=OW("makeTempDirectoryScoped"),t=FW("makeTempDirectoryScoped");return(r)=>Mt(e(r),(n)=>qr(t(n,{recursive:!0})))})(),Eie=(e)=>{let t=Mr(Ue.open,Xt("FileSystem",e),Cr(e)),r=Mr(Ue.close,Xt("FileSystem",e),Cr(e));return(n,o)=>E(Mt(t(n,o?.flag??"r",o?.mode),(s)=>qr(r(s))),z((s)=>APe(loe(s),o?.flag?.startsWith("a")??!1)))},fPe=Eie("open"),APe=(()=>{let e=(u)=>Mr(Ue.read,Xt("FileSystem",u),Cr(u)),t=e("read"),r=e("readAlloc"),n=Mr(Ue.fstat,Xt("FileSystem","stat"),Cr("stat")),o=Mr(Ue.ftruncate,Xt("FileSystem","truncate"),Cr("truncate")),s=Mr(Ue.fsync,Xt("FileSystem","sync"),Cr("sync")),i=(u)=>Mr(Ue.write,Xt("FileSystem",u),Cr(u)),a=i("write"),c=i("writeAll");class l{fd;append;[iT];semaphore=l6(1);position=0n;constructor(u,p){this.fd=u,this.append=p,this[iT]=iT}get stat(){return z(n(this.fd),yie)}get sync(){return s(this.fd)}seek(u,p){let f=Gc(u);return this.semaphore.withPermits(1)(se(()=>{if(p==="start")this.position=f;else if(p==="current")this.position=this.position+f;return this.position}))}read(u){return this.semaphore.withPermits(1)(z(Te(()=>t(this.fd,{buffer:u,position:this.position})),(p)=>{let f=Gc(p);return this.position=this.position+f,f}))}readAlloc(u){let p=Number(u);return this.semaphore.withPermits(1)(w(se(()=>Buffer.allocUnsafeSlow(p)),(f)=>z(r(this.fd,{buffer:f,position:this.position}),(A)=>{if(A===0)return T();if(this.position=this.position+BigInt(A),A===p)return M(f);let d=Buffer.allocUnsafeSlow(A);return f.copy(d,0,0,A),M(d)})))}truncate(u){return this.semaphore.withPermits(1)(z(o(this.fd,u?Number(u):void 0),()=>{if(!this.append){let p=BigInt(u??0);if(this.position>p)this.position=p}}))}write(u){return this.semaphore.withPermits(1)(z(Te(()=>a(this.fd,u,void 0,void 0,this.append?void 0:Number(this.position))),(p)=>{let f=Gc(p);if(!this.append)this.position=this.position+f;return f}))}writeAllChunk(u){return w(Te(()=>c(this.fd,u,void 0,void 0,this.append?void 0:Number(this.position))),(p)=>{if(p===0)return ce(new lu({module:"FileSystem",method:"writeAll",reason:"WriteZero",pathOrDescriptor:this.fd,description:"write returned 0 bytes written"}));if(!this.append)this.position=this.position+BigInt(p);return p<u.length?this.writeAllChunk(u.subarray(p)):Y})}writeAll(u){return this.semaphore.withPermits(1)(this.writeAllChunk(u))}}return(u,p)=>new l(u,p)})(),xie=(e)=>{let t=OW(e),r=Eie(e),n=(o)=>se(()=>mie.randomBytes(o).toString("hex"));return(o)=>E(Ui(t(o),n(6)),z(([s,i])=>hx.join(s,i+(o?.suffix??""))),Er((s)=>ro(r(s,{flag:"w+"}))))},dPe=xie("makeTempFile"),hPe=(()=>{let e=xie("makeTempFileScoped"),t=FW("makeTempFileScoped");return(r)=>Mt(e(r),(n)=>qr(t(hx.dirname(n),{recursive:!0})))})(),mPe=(e,t)=>lr({try:()=>Ue.promises.readdir(e,t),catch:(r)=>Xt("FileSystem","readDirectory")(r,[e])}),gPe=(e)=>Dt((t,r)=>{try{Ue.readFile(e,{signal:r},(n,o)=>{if(n)t(ce(Xt("FileSystem","readFile")(n,[e])));else t(Z(o))})}catch(n){t(ce(Cr("readFile")(n)))}}),EPe=(()=>{let e=Mr(Ue.readlink,Xt("FileSystem","readLink"),Cr("readLink"));return(t)=>e(t)})(),xPe=(()=>{let e=Mr(Ue.realpath,Xt("FileSystem","realPath"),Cr("realPath"));return(t)=>e(t)})(),yPe=(()=>{let e=Mr(Ue.rename,Xt("FileSystem","rename"),Cr("rename"));return(t,r)=>e(t,r)})(),yie=(e)=>({type:e.isFile()?"File":e.isDirectory()?"Directory":e.isSymbolicLink()?"SymbolicLink":e.isBlockDevice()?"BlockDevice":e.isCharacterDevice()?"CharacterDevice":e.isFIFO()?"FIFO":e.isSocket()?"Socket":"Unknown",mtime:ct(e.mtime),atime:ct(e.atime),birthtime:ct(e.birthtime),dev:e.dev,rdev:ct(e.rdev),ino:ct(e.ino),mode:e.mode,nlink:ct(e.nlink),uid:ct(e.uid),gid:ct(e.gid),size:Gc(e.size),blksize:jt(ct(e.blksize),Gc),blocks:ct(e.blocks)}),MW=(()=>{let e=Mr(Ue.stat,Xt("FileSystem","stat"),Cr("stat"));return(t)=>z(e(t),yie)})(),CPe=(()=>{let e=Mr(Ue.symlink,Xt("FileSystem","symlink"),Cr("symlink"));return(t,r)=>e(t,r)})(),SPe=(()=>{let e=Mr(Ue.truncate,Xt("FileSystem","truncate"),Cr("truncate"));return(t,r)=>e(t,r!==void 0?Number(r):void 0)})(),IPe=(()=>{let e=Mr(Ue.utimes,Xt("FileSystem","utime"),Cr("utime"));return(t,r,n)=>e(t,r,n)})(),bPe=(e,t)=>Ane((r)=>Mt(se(()=>{let n=Ue.watch(e,{recursive:t?.recursive},(o,s)=>{if(!s)return;switch(o){case"rename":{r.fromEffect(of(MW(s),{onSuccess:(i)=>Z(uoe({path:s})),onFailure:(i)=>i._tag==="SystemError"&&i.reason==="NotFound"?Z(foe({path:s})):ce(i)}));return}case"change":{r.single(poe({path:s}));return}}});return n.on("error",(o)=>{r.fail(new lu({module:"FileSystem",reason:"Unknown",method:"watch",pathOrDescriptor:e,cause:o}))}),n.on("close",()=>{r.end()}),n}),(n)=>se(()=>n.close()))),BPe=(e,t,r)=>MW(t).pipe(z((n)=>e.pipe(Bn((o)=>o.register(t,n,r)),je(()=>bPe(t,r)))),wI),QPe=(e,t,r)=>Dt((n,o)=>{try{Ue.writeFile(e,t,{signal:o,flag:r?.flag,mode:r?.mode},(s)=>{if(s)n(ce(Xt("FileSystem","writeFile")(s,[e])));else n(Y)})}catch(s){n(ce(Cr("writeFile")(s)))}}),wPe=z(bS(Y1),(e)=>coe({access:rPe,chmod:sPe,chown:iPe,copy:nPe,copyFile:oPe,link:aPe,makeDirectory:cPe,makeTempDirectory:lPe,makeTempDirectoryScoped:pPe,makeTempFile:dPe,makeTempFileScoped:hPe,open:fPe,readDirectory:mPe,readFile:gPe,readLink:EPe,realPath:xPe,remove:uPe,rename:yPe,stat:MW,symlink:CPe,truncate:SPe,utimes:IPe,watch(t,r){return BPe(e,t,r)},writeFile:QPe})),Cie=Wa(Cn,wPe);var JT=Cie;import*as jI from"node:path";import*as zT from"node:url";var NW=(e)=>mo({try:()=>zT.fileURLToPath(e),catch:(t)=>new ls({module:"Path",method:"fromFileUrl",description:`Invalid file URL: ${e}`,cause:t})}),_W=(e)=>mo({try:()=>zT.pathToFileURL(e),catch:(t)=>new ls({module:"Path",method:"toFileUrl",description:`Invalid path: ${e}`,cause:t})}),kPe=Li(Jr,Jr.of({[Rh]:Rh,...jI.posix,fromFileUrl:NW,toFileUrl:_W})),DPe=Li(Jr,Jr.of({[Rh]:Rh,...jI.win32,fromFileUrl:NW,toFileUrl:_W})),Iie=Li(Jr,Jr.of({[Rh]:Rh,...jI,fromFileUrl:NW,toFileUrl:_W}));var jT=Iie;var Bie=Ke("@effect/platform/Terminal");var UW=Bie;import*as $T from"node:readline";var Qie=(e)=>e.key.ctrl&&(e.key.name==="c"||e.key.name==="d"),wie=Ht(function*(e=Qie){let t=process.stdin,r=process.stdout,n=yield*xre({acquire:Mt(se(()=>{let u=$T.createInterface({input:t,escapeCodeTimeout:50});if($T.emitKeypressEvents(t,u),t.isTTY)t.setRawMode(!0);return u}),(u)=>se(()=>{if(t.isTTY)t.setRawMode(!1);u.close()}))}),o=se(()=>r.columns??0),s=se(()=>r.rows??0),i=se(()=>Boolean(r.isTTY)),a=_e(function*(){yield*l1(n);let u=yield*Df(),p=(f,A)=>{let d={input:ct(f),key:{name:A.name??"",ctrl:!!A.ctrl,meta:!!A.meta,shift:!!A.shift}};if(u.unsafeOffer(d),e(d))u.unsafeDone(Fi)};return yield*hE(()=>se(()=>t.off("keypress",p))),t.on("keypress",p),u}),c=l1(n).pipe(w((u)=>Dt((p)=>{let f=(A)=>p(Z(A));return u.once("line",f),se(()=>u.off("line",f))})),ro),l=(u)=>_i(Dt((p)=>{r.write(u,(f)=>f?p(ce(new ls({module:"Terminal",method:"display",description:"Failed to write prompt to stdout",cause:f}))):p(Y))}));return UW.of({columns:o,rows:s,isTTY:i,readInput:a,readLine:c,display:l})}),Rie=Oc(UW,wie(Qie));var kie=Rie;class KT extends wi("@effect/platform/Transferable/Collector")(){}var Die=()=>{let e=[],t=(o)=>{e.push(...o)},r=()=>e,n=()=>{let o=e;return e=[],o};return KT.of({unsafeAddAll:t,addAll:(o)=>se(()=>t(o)),unsafeRead:r,read:se(r),unsafeClear:n,clear:se(n)})};var Tie=Symbol.for("@effect/platform/WorkerError");var vie=Tie;class gu extends ot()("WorkerError",{reason:_("spawn","decode","send","unknown","encode"),cause:bt}){[vie]=vie;static Cause=pte({error:this,defect:bt});static encodeCause=UE(this.Cause);static decodeCause=M0(this.Cause);get message(){switch(this.reason){case"send":return"An error occurred calling .postMessage";case"spawn":return"An error occurred while spawning a worker";case"decode":return"An error occurred during decoding";case"encode":return"An error occurred during encoding";case"unknown":return"An unexpected error occurred"}}}var LW=Symbol.for("@effect/platform/Worker/PlatformWorker"),ZT=Ke("@effect/platform/Worker/PlatformWorker"),PW=Symbol.for("@effect/platform/Worker/WorkerManager"),HW=Ke("@effect/platform/Worker/WorkerManager"),Oie=Ke("@effect/platform/Worker/Spawner"),Fie=_e(function*(){let e=yield*ZT,t=0;return HW.of({[PW]:PW,spawn({encode:r,initialMessage:n}){return _e(function*(){let o=t++,s=0,i=new Map,a=Die(),c=r?(x)=>ve(a.clear,nn(r(x),KT,a)):Z,l=yield*Pt(),u=yield*e.spawn(o);yield*u.run((x)=>{if(x[0]===0)return Lk(l,Y);return p(x[1])}).pipe(SS((x)=>Kt(i.values(),(y)=>(Kp in y)?Qc(y,x):y.failCause(x))),Rc(kc),CS(fH(1000)),Dc({package:"@effect/platform",module:"Worker"}),gr,rf),yield*hE(()=>ve(Kt(i.values(),(x)=>(Kp in x)?LP(x):x.end,{discard:!0}),se(()=>i.clear())));let p=(x)=>Te(()=>{let y=i.get(x[0]);if(!y)return Y;switch(x[1]){case 0:return Kp in y?Gn(y,x[2][0]):y.offerAll(x[2]);case 1:{if(x.length===2)return Kp in y?LP(y):y.end;return Kp in y?Gn(y,x[2][0]):ve(y.offerAll(x[2]),y.end)}case 2:case 3:{if(x[1]===2)return Kp in y?xS(y,x[2]):y.fail(x[2]);let S=gu.decodeCause(x[2]);return Kp in y?Qc(y,S):y.failCause(S)}}}),f=(x,y)=>mr((S)=>{let I=S.getFiberRef(sf),B=Jo(I,uZ).pipe(qs((Q)=>Q._tag==="Span")),R=s++;return y.pipe(Er((Q)=>(i.set(R,Q),c(x).pipe(Er((P)=>u.send([R,0,P,B._tag==="Some"?[B.value.traceId,B.value.spanId,B.value.sampled]:void 0],a.unsafeRead())),rn((P)=>Dse(Q)?Q.failCause(P):Qc(Q,P))))),z((Q)=>({id:R,mailbox:Q})))}),A=({id:x},y)=>{let S=se(()=>i.delete(x));return vo(y)?ve(qr(u.send([x,1])),S):S},d=(x)=>bh(ooe(f(x,Df()),({mailbox:y})=>Tse(y),A)),g=(x)=>ef(f(x,Pt()),({mailbox:y})=>ut(y),A);if(yield*ut(l),n)yield*se(n).pipe(w(g),De((x)=>new gu({reason:"spawn",cause:x})));return{id:o,execute:d,executeEffect:g}})}})}),Mie=Wa(HW,Fie);var Nie=()=>(e)=>ZT.of({[LW]:LW,spawn(t){return _e(function*(){let r=yield*Oie,n,o=[];return{run:(a)=>Jl((c)=>_e(function*(){let l=yield*tf,u=yield*e.setup({worker:r(t),scope:l});n=u,yield*Qs(l,se(()=>{n=void 0}));let p=(yield*ts()).pipe(D6(M$(iE))),f=yield*IE(),A=rs(p);if(yield*e.listen({port:u,scope:l,emit(d){u0(f,A(a(d)))},deferred:f.deferred}),o.length>0){for(let[d,g]of o)u.postMessage([0,d],g);o.length=0}return yield*c(TS(f))}).pipe(ro)),send:(a,c)=>mo({try:()=>{if(n===void 0)o.push([a,c]);else n.postMessage([0,a],c)},catch:(l)=>new gu({reason:"send",cause:l})})}})}});var _ie=Nie,Uie=ZT;var Lie=Mie;var PPe=_ie()({setup({scope:e,worker:t}){return w(Pt(),(r)=>{let n="postMessage"in t?{postMessage(o,s){t.postMessage(o,s)},kill:()=>t.terminate(),worker:t}:{postMessage(o,s){t.send(o)},kill:()=>t.kill("SIGKILL"),worker:t};return t.on("exit",()=>{Yn(r,Fi)}),go(Qs(e,Te(()=>(n.postMessage([1]),ut(r))).pipe(gr,nf(5000),rn(()=>se(()=>n.kill())))),n)})},listen({deferred:e,emit:t,port:r}){return r.worker.on("message",(n)=>{t(n)}),r.worker.on("messageerror",(n)=>{Yn(e,new gu({reason:"decode",cause:n}))}),r.worker.on("error",(n)=>{Yn(e,new gu({reason:"unknown",cause:n}))}),r.worker.on("exit",(n)=>{Yn(e,new gu({reason:"unknown",cause:Error(`exited with code ${n}`)}))}),Y}}),Pie=Li(Uie,PPe),Hie=no(Lie,Pie);var Wie=Hie;var WW=E($d(jT,die,kie,Wie),n0(JT));var Dh=JT;import*as tv from"node:http";import*as rv from"node:https";import{Readable as zie}from"node:stream";import{pipeline as GPe}from"node:stream/promises";var qie=YT;var ev=vf;var Gie=lie;var Yie=sie,Vie=GT;class $I extends ha{source;onError;remoteAddressOverride;[us];constructor(e,t,r){super();this.source=e,this.onError=t,this.remoteAddressOverride=r,this[us]=us}get headers(){return Kn(this.source.headers)}get remoteAddress(){return ct(this.remoteAddressOverride??this.source.socket.remoteAddress)}textEffect;get text(){if(this.textEffect)return this.textEffect;return this.textEffect=on(Zs(w(If,(e)=>Yie(()=>this.source,{onFailure:this.onError,maxBytes:pt(e)})))),this.textEffect}get unsafeText(){return on(this.text)}get json(){return Xp(this.text,{try:(e)=>e===""?null:JSON.parse(e),catch:this.onError})}get unsafeJson(){return on(this.json)}get urlParamsBody(){return w(this.text,(e)=>mo({try:()=>Vc(new URLSearchParams(e)),catch:this.onError}))}get stream(){return ev(()=>this.source,this.onError)}get arrayBuffer(){return w(If,(e)=>Vie(()=>this.source,{onFailure:this.onError,maxBytes:pt(e)}))}}var GW=Symbol.for("@effect/platform-node/Http/NodeClient/HttpAgent"),YW=Ke("@effect/platform-node/Http/NodeClient/HttpAgent"),jie=(e)=>z(wc([Mt(se(()=>new tv.Agent(e)),(t)=>se(()=>t.destroy())),Mt(se(()=>new rv.Agent(e)),(t)=>se(()=>t.destroy()))]),([t,r])=>({[GW]:GW,http:t,https:r})),$ie=(e)=>Oc(YW,jie(e)),Kie=$ie(),YPe=(e)=>ST((t,r,n)=>{let o=r.protocol==="https:"?rv.request(r,{agent:e.https,method:t.method,headers:t.headers,signal:n}):tv.request(r,{agent:e.http,method:t.method,headers:t.headers,signal:n});return E(ve(VPe(o,t,t.body),JPe(o,t),{concurrent:!0}),z((s)=>new Zie(t,s)))}),VPe=(e,t,r)=>Te(()=>{switch(r._tag){case"Empty":return e.end(),Jie(e,t);case"Uint8Array":case"Raw":return e.end(r.body),Jie(e,t);case"FormData":{let n=new Response(r.formData);return n.headers.forEach((o,s)=>{e.setHeader(s,o)}),lr({try:()=>GPe(zie.fromWeb(n.body),e),catch:(o)=>new si({request:t,reason:"Transport",cause:o})})}case"Stream":return xf(Sne(r.stream,(n)=>new si({request:t,reason:"Encode",cause:n})),qie(()=>e,(n)=>new si({request:t,reason:"Transport",cause:n})))}}),JPe=(e,t)=>Dt((r)=>{function n(s){r(ce(new si({request:t,reason:"Transport",cause:s})))}e.on("error",n);function o(s){e.off("error",n),r(Z(s))}return e.on("upgrade",o),e.on("response",o),se(()=>{e.off("error",n),e.off("upgrade",o),e.off("response",o)})}),Jie=(e,t)=>Dt((r)=>{function n(s){r(ce(new si({request:t,reason:"Transport",cause:s})))}e.once("error",n);function o(){e.off("error",n),r(Y)}return e.once("finish",o),se(()=>{e.off("error",n),e.off("finish",o)})});class Zie extends $I{request;[wf];constructor(e,t){super(t,(r)=>new an({request:e,response:this,reason:"Decode",cause:r}));this.request=e,this[wf]=wf}get status(){return this.source.statusCode}cachedCookies;get cookies(){if(this.cachedCookies!==void 0)return this.cachedCookies;let e=this.source.headers["set-cookie"];if(Array.isArray(e))return this.cachedCookies=cx(e);return this.cachedCookies=uu}get formData(){return lr({try:()=>{let e={headers:new globalThis.Headers(this.source.headers)};if(this.source.statusCode)e.status=this.source.statusCode;if(this.source.statusMessage)e.statusText=this.source.statusMessage;return new Response(zie.toWeb(this.source),e).formData()},catch:this.onError})}toJSON(){return bf(this,{_id:"@effect/platform/HttpClientResponse",request:this.request.toJSON(),status:this.status})}}var Xie=z(YW,YPe),eae=bT(Xie),tae=no(eae,Kie);var WEe=Ii(gV(),1);_M(ym,Ii(gV(),1));var EV=Ke("@effect/platform-node/NodeHttpClient/Dispatcher");var qEe="@effect/platform-node/NodeHttpClient/undiciOptions",GEe=(e)=>ST((t,r,n,o)=>{let i=o.getFiberRef(sf).unsafeMap.get(qEe)??{};return k9e(t.body).pipe(w((a)=>lr({try:()=>e.request({...i,signal:n,method:t.method,headers:t.headers,origin:r.origin,path:r.pathname+r.search+r.hash,body:a,headersTimeout:3600000,bodyTimeout:0}),catch:(c)=>new si({request:t,reason:"Transport",cause:c})})),z((a)=>new YEe(t,a)))});function k9e(e){switch(e._tag){case"Empty":return Z(null);case"Uint8Array":case"Raw":return Z(e.body);case"FormData":return Z(e.formData);case"Stream":return Gie(e.stream)}}function D9e(e){}class YEe extends ha{request;source;[us];[wf];constructor(e,t){super();this.request=e,this.source=t,this[us]=us,this[wf]=wf,t.body.on("error",D9e)}get status(){return this.source.statusCode}get statusText(){return}cachedCookies;get cookies(){if(this.cachedCookies!==void 0)return this.cachedCookies;let e=this.source.headers["set-cookie"];if(e!==void 0)return this.cachedCookies=cx(Array.isArray(e)?e:[e]);return this.cachedCookies=uu}get headers(){return Kn(this.source.headers)}get remoteAddress(){return T()}get stream(){return ev(()=>this.source.body,(e)=>new an({request:this.request,response:this,reason:"Decode",cause:e}))}get json(){return Xp(this.text,{try:(e)=>e===""?null:JSON.parse(e),catch:(e)=>new an({request:this.request,response:this,reason:"Decode",cause:e})})}textBody;get text(){return this.textBody??=lr({try:()=>this.source.body.text(),catch:(e)=>new an({request:this.request,response:this,reason:"Decode",cause:e})}).pipe(Zs,on)}get urlParamsBody(){return w(this.text,(e)=>mo({try:()=>Vc(new URLSearchParams(e)),catch:(t)=>new an({request:this.request,response:this,reason:"Decode",cause:t})}))}formDataBody;get formData(){return this.formDataBody??=lr({try:()=>this.source.body.formData(),catch:(e)=>new an({request:this.request,response:this,reason:"Decode",cause:e})}).pipe(Zs,on)}arrayBufferBody;get arrayBuffer(){return this.arrayBufferBody??=lr({try:()=>this.source.body.arrayBuffer(),catch:(e)=>new an({request:this.request,response:this,reason:"Decode",cause:e})}).pipe(Zs,on)}toJSON(){return bf(this,{_id:"@effect/platform/HttpClientResponse",request:this.request.toJSON(),status:this.status})}}var VEe=bT(z(EV,GEe));var v9e=tae;var O9e=EV;var F9e=VEe;import{Duplex as M9e,Readable as N9e}from"node:stream";class JEe extends M9e{_parser;_canWrite=!0;_writeCallback;constructor(e){super({readableObjectMode:!0});let t,r;this._parser=RW({...e,onField:(n,o)=>{if(t!==void 0)return;let s={_tag:"Field",info:n,value:o};this.push(s),this.emit("field",s)},onFile:(n)=>{if(t!==void 0)return(s)=>{};let o=new jEe(n,this);return r=o,this.push(o),this.emit("file",o),(s)=>{if(this._canWrite=o.push(s),s===null&&!this._canWrite)r=void 0,this._resume()}},onError:(n)=>{this.emit("error",n),r?.emit("error",n),t=n},onDone:()=>{this.push(null)}})}_resume(){if(this._canWrite=!0,this._writeCallback!==void 0){let e=this._writeCallback;this._writeCallback=void 0,e()}}_read(e){}_write(e,t,r){if(this._parser.write(e instanceof Uint8Array?e:Buffer.from(e,t)),this._canWrite)r();else this._writeCallback=r}_final(e){this._parser.end(),e()}}var zEe=(e)=>new JEe(e);class jEe extends N9e{info;_parent;_tag="File";filename;constructor(e,t){super();this.info=e,this._parent=t,this.filename=e.filename}_read(e){if(this._parent._canWrite===!1)this._parent._resume()}}import*as $Ee from"node:fs";import*as KEe from"node:stream/promises";var yV=(e,t)=>E(Gse(t),z((r)=>vf(()=>{let n=zEe(r);return e.pipe(n),n},(n)=>L9e(n))),wI,xne(U9e)),ZEe=(e,t)=>Vse(yV(e,t),(r,n)=>lr({try:(o)=>KEe.pipeline(n.file,$Ee.createWriteStream(r),{signal:o}),catch:(o)=>new ci({reason:"InternalError",cause:o})})),U9e=(e)=>e._tag==="Field"?new XEe(e.info,e.value):new exe(e);class CV extends ha{[kh];constructor(){super();this[kh]=kh}}class XEe extends CV{_tag="Field";key;contentType;value;constructor(e,t){super();this.key=e.name,this.contentType=e.contentType,this.value=kW(e,t)}toJSON(){return{_id:"@effect/platform/Multipart/Part",_tag:"Field",key:this.key,value:this.value,contentType:this.contentType}}}class exe extends CV{file;_tag="File";key;name;contentType;content;contentEffect;constructor(e){super();this.file=e,this.key=e.info.name,this.name=e.filename??e.info.name,this.contentType=e.info.contentType,this.content=vf(()=>e,(t)=>new ci({reason:"InternalError",cause:t})),this.contentEffect=GT(()=>e,{onFailure:(t)=>new ci({reason:"InternalError",cause:t})})}toJSON(){return{_id:"@effect/platform/Multipart/Part",_tag:"File",key:this.key,name:this.name,contentType:this.contentType}}}function L9e(e){switch(e._tag){case"ReachedLimit":switch(e.limit){case"MaxParts":return new ci({reason:"TooManyParts",cause:e});case"MaxFieldSize":return new ci({reason:"FieldTooLarge",cause:e});case"MaxPartSize":return new ci({reason:"FileTooLarge",cause:e});case"MaxTotalSize":return new ci({reason:"BodyTooLarge",cause:e})}default:return new ci({reason:"Parse",cause:e})}}var txe=yV,rxe=ZEe;var nxe=X;var oxe=Ae(Symbol.for("@effect/platform/HttpApp/preResponseHandlers"),()=>Pi(T()));var q9e=(e)=>e;var G9e=Ae(Symbol.for("@effect/platform/HttpMiddleware/tracerDisabledWhen"),()=>Pi(tr));var Y9e=hr()("@effect/platform/HttpMiddleware/SpanNameGenerator",{defaultValue:()=>(e)=>`http.server ${e.method}`});var SV=q9e((e)=>mr((t)=>{let r=Ro(t.currentContext,Za);if(t.getFiberRef(G9e)(r))return e;let o=pt(oie(r));if(o!==void 0&&(o.username!==""||o.password!==""))o.username="REDACTED",o.password="REDACTED";let s=t.getFiberRef(TI),i=Bh(r.headers,s),a=Ot(t.currentContext,Y9e);return CE(a(r),{parent:pt(Eoe(r.headers)),kind:"server",captureStackTrace:!1},(c)=>{if(c.attribute("http.request.method",r.method),o!==void 0){if(c.attribute("url.full",o.toString()),c.attribute("url.path",o.pathname),o.search.slice(1)!=="")c.attribute("url.query",o.search.slice(1));c.attribute("url.scheme",o.protocol.slice(0,-1))}if(r.headers["user-agent"]!==void 0)c.attribute("user_agent.original",r.headers["user-agent"]);for(let l in i)c.attribute(`http.request.header.${l}`,String(i[l]));if(r.remoteAddress._tag==="Some")c.attribute("client.address",r.remoteAddress.value);return w(Dr(jd(e,c)),(l)=>{let u=bse(l);c.attribute("http.response.status_code",u.status);let p=Bh(u.headers,s);for(let f in p)c.attribute(`http.response.header.${f}`,String(p[f]));return l})})}));var ay=Symbol.for("@effect/platform/HttpApp/handled"),IV=(e,t,r)=>{let n=mr((i)=>w(e,(a)=>{let c=Ro(i.currentContext,Za),l=i.getFiberRef(sxe);if(l._tag==="None")return c[ay]=!0,go(t(c,a),a);return Er(l.value(c,a),(u)=>(c[ay]=!0,t(c,u)))})),o=rn(n,(i)=>mr((a)=>w(qI(i),([c,l])=>{let u=Ro(a.currentContext,Za),p=a.getFiberRef(sxe);if(p._tag==="None")return u[ay]=!0,ve(t(u,c),Vp(l)?Z(c):kr(l));return ve(Er(p.value(u,c),(f)=>(u[ay]=!0,t(u,f))),Vp(l)?Z(c):kr(l))}))),s=nxe(r===void 0?SV(o):xn(SV(r(o)),{onFailure:(i)=>mr((a)=>{let c=Ro(a.currentContext,Za);if(ay in c)return Y;return xn(qI(i),{onFailure:(l)=>t(c,kf({status:500})),onSuccess:([l])=>t(c,l)})}),onSuccess:(i)=>mr((a)=>{let c=Ro(a.currentContext,Za);return ay in c?Y:t(c,i)})}));return _i(z9e(s))};var J9e=Ae("@effect/platform/HttpApp/ejectedScopes",()=>new WeakSet),z9e=(e)=>w(bk(),(t)=>o6(Yl(e,t),(r)=>{if(J9e.has(t))return Y;return Jp(t,r)})),sxe=oxe;import*as HV from"node:http";import{Readable as b8e}from"node:stream";import{pipeline as B8e}from"node:stream/promises";var f8e=Ii(Xxe(),1),A8e=Ii(rF(),1),d8e=Ii(uy(),1),h8e=Ii(kV(),1),m8e=Ii(TV(),1),g8e=Ii(_V(),1),lF=Ii(aF(),1),UV=Ii(sye(),1);var iye=mW,aye=lse;var LV=Ii(hye(),1);import*as mye from"node:fs";import{Readable as C8e}from"node:stream";var S8e=aye({fileResponse(e,t,r,n,o,s,i){let a=mye.createReadStream(e,{start:o,end:s});return IW(a,{headers:{...n,"content-type":n["content-type"]??LV.default.getType(e)??"application/octet-stream","content-length":i.toString()},status:t,statusText:r})},fileWebResponse(e,t,r,n,o){return IW(C8e.fromWeb(e.stream()),{headers:Ka(n,pu({"content-type":n["content-type"]??LV.default.getType(e.name)??"application/octet-stream","content-length":e.size.toString()})),status:t,statusText:r})}}),gye=E(Wa(iye,S8e),no(Dh),no(nse));var Eye=(e,t)=>_e(function*(){let r=yield*tf,n=yield*Mt(se(e),(i)=>Dt((a)=>{if(!i.listening)return a(Y);i.close((c)=>{if(c)a(Mo(c));else a(Y)})}));yield*Dt((i)=>{function a(c){i(ce(new vT({cause:c})))}n.on("error",a),n.listen(t,()=>{n.off("error",a),i(Y)})});let o=n.address(),s=yield*E(Mt(se(()=>new UV.default({noServer:!0})),(i)=>Dt((a)=>{i.close(()=>a(Y))})),Yl(r),Zs);return dse({address:typeof o==="string"?{_tag:"UnixAddress",path:o}:{_tag:"TcpAddress",hostname:o.address==="::"?"0.0.0.0":o.address,port:o.port},serve:(i,a)=>_e(function*(){let c=yield*xye(i,a),l=yield*Q8e(s,i,a);yield*hE(()=>se(()=>{n.off("request",c),n.off("upgrade",l)})),n.on("request",c),n.on("upgrade",l)})})}).pipe(nn(If,M(Gc(10485760)))),xye=(e,t)=>{let r=IV(e,Sye,t);return z(ts(),(n)=>{let o=rs(n);return function(i,a){let c=o(nn(r,Za,new pF(i,a)));a.on("close",()=>{if(!a.writableEnded)c.unsafeInterruptAsFork(OT)})}})},Q8e=(e,t,r)=>{let n=IV(t,Sye,r);return z(_6(),(o)=>function(i,a,c){let l=void 0,u=()=>{if(l===void 0)l=new HV.ServerResponse(i),l.assignSocket(a),l.on("finish",()=>{a.end()});return l},p=TW(w(e,(A)=>Mt(Dt((d)=>A.handleUpgrade(i,a,c,(g)=>{d(Z(g))})),(d)=>se(()=>d.close())))),f=o(nn(n,Za,new pF(i,u,p)));a.on("close",()=>{if(!a.writableEnded)f.unsafeInterruptAsFork(OT)})})};class pF extends $I{source;response;upgradeEffect;url;headersOverride;[qT];constructor(e,t,r,n=e.url,o,s){super(e,(i)=>new WI({request:this,reason:"Decode",cause:i}),s);this.source=e,this.response=t,this.upgradeEffect=r,this.url=n,this.headersOverride=o,this[qT]=qT}cachedCookies;get cookies(){if(this.cachedCookies)return this.cachedCookies;return this.cachedCookies=Xne(this.headers.cookie??"")}get resolvedResponse(){return typeof this.response==="function"?this.response():this.response}modify(e){return new pF(this.source,this.response,this.upgradeEffect,e.url??this.url,e.headers??this.headersOverride,e.remoteAddress??this.remoteAddressOverride)}get originalUrl(){return this.source.url}get method(){return this.source.method.toUpperCase()}get headers(){return this.headersOverride??=this.source.headers,this.headersOverride}multipartEffect;get multipart(){if(this.multipartEffect)return this.multipartEffect;return this.multipartEffect=on(Zs(rxe(this.source,this.source.headers))),this.multipartEffect}get multipartStream(){return txe(this.source,this.source.headers)}get upgrade(){return this.upgradeEffect??ce(new WI({request:this,reason:"Decode",description:"not an upgradeable ServerRequest"}))}toString(){return`ServerRequest(${this.method} ${this.url})`}toJSON(){return bf(this,{_id:"@effect/platform/HttpServerRequest",method:this.method,url:this.originalUrl})}}var yye=$d(gye,AW,WW),Cye=(e,t)=>$d(Oc(yW,Eye(e,t)),yye);var Sye=(e,t)=>Te(()=>{let r=e.resolvedResponse;if(r.writableEnded)return Y;let n=t.headers;if(!L1(t.cookies)){n={...n};let s=rT(t.cookies);if(n["set-cookie"]!==void 0)s.push(n["set-cookie"]);n["set-cookie"]=s}if(e.method==="HEAD")return r.writeHead(t.status,n),Dt((s)=>{r.end(()=>s(Y))});let o=t.body;switch(o._tag){case"Empty":return r.writeHead(t.status,n),r.end(),Y;case"Raw":{if(r.writeHead(t.status,n),typeof o.body==="object"&&o.body!==null&&"pipe"in o.body&&typeof o.body.pipe==="function")return lr({try:(s)=>B8e(o.body,r,{signal:s,end:!0}),catch:(s)=>new TT({request:e,response:t,reason:"Decode",cause:s})}).pipe(gr,Rc(PV(r,t)));return Dt((s)=>{r.end(o.body,()=>s(Y))})}case"Uint8Array":return r.writeHead(t.status,n),Dt((s)=>{r.end(o.body,()=>s(Y))});case"FormData":return Te(()=>{let s=new Response(o.formData);return r.writeHead(t.status,{...n,...Object.fromEntries(s.headers)}),Dt((i,a)=>{b8e.fromWeb(s.body,{signal:a}).pipe(r).on("error",(c)=>{i(ce(new TT({request:e,response:t,reason:"Decode",cause:c})))}).once("finish",()=>{i(Y)})}).pipe(gr,Rc(PV(r,t)))});case"Stream":{r.writeHead(t.status,n);let s=Tc();return r.on("drain",()=>s.unsafeOpen()),o.stream.pipe(Ine,QI((i)=>{let a=hn(i);if(a.length===0)return Y;let c=!1;for(let l=0;l<a.length;l++){let u=r.write(a[l]);if(!u&&!c)c=!0,s.unsafeClose();else if(u&&c)c=!1}if(!c)return Y;return s.await}),gr,xn({onSuccess:()=>se(()=>r.end()),onFailure:PV(r,t)}))}}}),PV=(e,t)=>(r)=>qI(r).pipe(w(([n,o])=>{let s=e.headersSent;if(!s)e.writeHead(n.status);if(!e.writableEnded)e.end();return kr(s?Ld(r,$s(t)):o)}));var R8e=Cye;var hB=jT;var bye=new URL("../",import.meta.url),Bye=new URL("skills/expandai/",bye),$Ut=new URL("assets/opencode/expandai-webfetch.js",bye);class k8e extends ot()("McpParseError",{path:m,error:bt}){get message(){return`Failed to parse MCP config at ${this.path}: ${Ve(this.error)}`}}class D8e extends ot()("McpWriteError",{path:m,error:bt}){get message(){return`Failed to write MCP config at ${this.path}: ${Ve(this.error)}`}}var T8e=_("claude-code","cursor","opencode","codex","fx"),Rye=_(...T8e.literals,"unknown"),rLt=_("project","global"),fF=Fn({key:m,value:Tt}),nLt=xo(b({mcpServers:C(fF,{default:()=>({})})},fF),{space:2}),oLt=xo(b({mcp:C(fF,{default:()=>({})})},fF),{space:2}),kye="expandai",v8e={command:"expandai",args:[]},O8e={command:"npx",args:["-y","expandai"]};var Qye=_e(function*(){let e=yield*Cn,t=yield*Jr,r=yield*Do("PATH").pipe(bd("")),n=yield*Do("PATHEXT").pipe(bd(".COM;.EXE;.BAT;.CMD")),o=t.sep==="\\",s=o?["",...nC(n.split(";"),RP)]:[""];return{resolve:we("CliInvocation.resolve")(function*(){let a=nC(r.split(o?";":":"),RP);return(yield*t6(a,(l)=>t6(s,(u)=>e.exists(t.join(l.replace(/^"(.*)"$/u,"$1"),`expandai${u}`)).pipe(yE(()=>!1)))))?v8e:O8e})}});class qV extends vc()("@expandai/cli/Install/CliInvocation",{dependencies:[Dh,hB],effect:Qye}){static layer=Wa(qV,Qye.pipe(z(qV.make)))}var F8e=we(function*(e){let t=yield*Cn;if(!(yield*t.exists(e)))return"{}";return yield*t.readFileString(e)}),wye=we(function*(e,t){let r=yield*Cn,n=yield*Jr;yield*r.makeDirectory(n.dirname(e),{recursive:!0}),yield*r.writeFileString(e,`${t}
|
|
183
|
-
`)});class M8e extends vc()("@expandai/cli/Install/ConfigIo",{dependencies:[Dh,hB],effect:_e(function*(){let e=yield*Cn,t=yield*Jr,r=we("ConfigIo.read")(function*(a,c){let l=yield*F8e(a).pipe(nn(Cn,e));return yield*P0(c)(l)}),n=we("ConfigIo.write")(function*(a,c,l){let u=yield*hh(l)(c);yield*wye(a,u).pipe(nn(Cn,e),nn(Jr,t))}),o=we("ConfigIo.exists")(function*(a){return yield*e.exists(a)}),s=we("ConfigIo.readText")(function*(a){return(yield*e.exists(a))?yield*e.readFileString(a):""}),i=we("ConfigIo.writeText")(function*(a,c){yield*wye(a,c).pipe(nn(Cn,e),nn(Jr,t))});return{read:r,write:n,exists:o,readText:s,writeText:i}})}){}class N8e extends vc()("@expandai/cli/Install/SkillIo",{dependencies:[Dh,hB],effect:_e(function*(){let e=yield*Cn,t=yield*Jr,r=yield*t.fromFileUrl(Bye),n=we("SkillIo.install")(function*(a){return yield*e.makeDirectory(t.dirname(a),{recursive:!0}),yield*e.copy(r,a,{overwrite:!0}),a}),o=we("SkillIo.uninstall")(function*(a){if(yield*e.exists(a))yield*e.remove(a,{recursive:!0});return a}),s=we("SkillIo.isCurrent")(function*(a){let c=t.join(a,"SKILL.md");if(!(yield*e.exists(c)))return!1;let[l,u]=yield*wc([e.readFileString(c),e.readFileString(t.join(r,"SKILL.md"))]);return l===u}),i=we("SkillIo.isInstalled")(function*(a){return yield*e.exists(t.join(a,"SKILL.md"))});return{install:n,uninstall:o,isCurrent:s,isInstalled:i}})}){}var mB="0.1.4";var Dye=Symbol.for("effect/PrimaryKey");var GV=Symbol.for("@effect/rpc/RpcSchema/Stream"),vye=(e)=>e.ast.annotations[th]===GV;var Oye=({failure:e,success:t})=>Object.assign(ni([t,e],{decode:(r,n)=>Tye(Lc(S2(r)),Lc(n)),encode:(r,n)=>Tye(Pc(S2(r)),Pc(n))},{schemaId:GV,[GV]:{success:t,failure:e}}),{success:t,failure:e}),U8e=(e)=>ee(e,B1),Tye=(e,t)=>(r,n,o)=>w(vn(),(s)=>{if(!U8e(r))return ce(new Fr(o,r));return Z(r.pipe(Cne((i)=>e(i,n)),Q1((i)=>{if(NE(i))return hne(i);return of(t(i,n),{onFailure:Mo,onSuccess:ce})}),jD(s)))});var Mye=Symbol.for("@effect/rpc/Rpc");var P8e={[Mye]:Mye,pipe(){return W(this,arguments)},setSuccess(e){return Ou({_tag:this._tag,payloadSchema:this.payloadSchema,successSchema:e,errorSchema:this.errorSchema,defectSchema:this.defectSchema,annotations:this.annotations,middlewares:this.middlewares})},setError(e){return Ou({_tag:this._tag,payloadSchema:this.payloadSchema,successSchema:this.successSchema,errorSchema:e,defectSchema:this.defectSchema,annotations:this.annotations,middlewares:this.middlewares})},setPayload(e){return Ou({_tag:this._tag,payloadSchema:On(e)?e:b(e),successSchema:this.successSchema,errorSchema:this.errorSchema,defectSchema:this.defectSchema,annotations:this.annotations,middlewares:this.middlewares})},middleware(e){return Ou({_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 Ou({_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 Ou({_tag:this._tag,payloadSchema:this.payloadSchema,successSchema:this.successSchema,errorSchema:this.errorSchema,defectSchema:this.defectSchema,middlewares:this.middlewares,annotations:dr(this.annotations,e,t)})},annotateContext(e){return Ou({_tag:this._tag,payloadSchema:this.payloadSchema,successSchema:this.successSchema,errorSchema:this.errorSchema,defectSchema:this.defectSchema,middlewares:this.middlewares,annotations:wr(this.annotations,e)})}},Ou=(e)=>{function t(){}return Object.setPrototypeOf(t,P8e),Object.assign(t,e),t.key=`@effect/rpc/Rpc/${e._tag}`,t},Wo=(e,t)=>{let r=t?.success??qE,n=t?.error??Af,o;if(t?.primaryKey)o=class extends Oe(`@effect/rpc/Rpc/${e}`)(t.payload){[Dye](){return t.primaryKey(this)}};else o=On(t?.payload)?t?.payload:t?.payload?b(t?.payload):qE;return Ou({_tag:e,payloadSchema:o,successSchema:t?.stream?Oye({success:r,failure:n}):r,errorSchema:t?.stream?Af:n,defectSchema:t?.defect??bt,annotations:Pr(),middlewares:new Set})},Nye=(e)=>Ou({_tag:e._tag,payloadSchema:e,successSchema:e.success,errorSchema:e.failure,defectSchema:bt,annotations:Pr(),middlewares:new Set});var H8e=Symbol.for("@effect/rpc/Rpc/Wrapper"),_ye=(e)=>(H8e in e);var W8e=BigInt(0),Pye=Ht(function*(e,t){let r=t?.spanPrefix??"RpcClient",n=t?.supportsAck??!0,o=t?.disableTracing??!1,s=t?.generateRequestId??(()=>W8e++),i=yield*vn(),a=Ot(i,iE),c=new Map,l=!1;yield*Qs(a,Te(()=>(l=!0,u(PZ(q8e)))));let u=Ht(function*(S){for(let[I,B]of c)if(c.delete(I),B._tag==="Mailbox")yield*B.mailbox.done(S);else B.resume(S)}),p=(S)=>{let I=vye(S.successSchema),B=d(S);return(R,Q)=>{let P=Q?.headers?Kn(Q.headers):oi,F=Q?.context??Pr();if(!I){let V=(G)=>f(S,B,G,S.payloadSchema.make?S.payloadSchema.make(R):R,P,F,Q?.discard??!1);return o?V(void 0):CE(`${r}.${S._tag}`,{captureStackTrace:!1,attributes:t.spanAttributes},V)}let D=A(S,B,S.payloadSchema.make?S.payloadSchema.make(R):R,P,Q?.streamBufferSize??16,F);if(Q?.asMailbox)return D;return Wc(z(D,vse))}},f=(S,I,B,R,Q,P,F)=>mr((D)=>{if(l)return es;let V=s(),G=I({_tag:"Request",id:V,tag:S._tag,payload:R,traceId:B?.traceId,spanId:B?.spanId,sampled:B?.sampled,headers:Ka(D.getFiberRef(Lye),Q)});if(F)return w(G,(v)=>t.onFromClient({message:v,context:P,discard:F}));let le=l0({context:D.currentContext,fiberRefs:D.getFiberRefs(),runtimeFlags:SE.runtimeFlags}),Be,Fe=!1;return Vk(Dt((v)=>{let O={_tag:"Effect",rpc:S,context:P,resume(H){if(Fe=!0,v(H),Be&&!Be.unsafePoll())D.currentScheduler.scheduleTask(()=>{Be.unsafeInterruptAsFork(D.id())},0,Be)}};c.set(V,O),Be=G.pipe(w((H)=>t.onFromClient({message:H,context:P,discard:F})),B?jd(B):X,rs(le)),Be.addObserver((H)=>{if(H._tag==="Failure")return v(H)})}),(v)=>{if(Fe)return Y;c.delete(V);let O=Array.from(v).flatMap((H)=>Array.from(jN(H)));return ve(Xo(Be),g(V,O,P))})}),A=Ht(function*(S,I,B,R,Q,P){if(l)return yield*es;let F=o?void 0:yield*p6(`${r}.${S._tag}`,{captureStackTrace:!1,attributes:t.spanAttributes}),D=HA(aP()),V=s(),G=Ro(D.currentContext,iE);yield*Ik(G,(Be)=>{if(!c.has(V))return Y;return c.delete(V),g(V,vo(Be)?Array.from(Ak(Be.cause)).flatMap((Fe)=>Array.from(jN(Fe))):[],P)});let le=yield*Df(Q);return c.set(V,{_tag:"Mailbox",rpc:S,mailbox:le,scope:G,context:P}),yield*I({_tag:"Request",id:V,tag:S._tag,traceId:F?.traceId,payload:B,spanId:F?.spanId,sampled:F?.sampled,headers:Ka(D.getFiberRef(Lye),R)}).pipe(w((Be)=>t.onFromClient({message:Be,context:P,discard:!1})),F?jd(F):X,rn((Be)=>le.failCause(Be)),gr,Xs(G)),le}),d=(S)=>{let I=[];for(let B of S.middlewares.values()){let R=i.unsafeMap.get(`${B.key}/Client`);if(!R)continue;I.push(R)}return I.length===0?Z:function(B){let R=0;return z(BS({while:()=>R<I.length,body:()=>I[R]({rpc:S,request:B}),step(Q){B=Q,R++}}),()=>B)}},g=(S,I,B)=>Dt((R)=>{let Q=HA(aP()),P=l0({context:Q.currentContext,fiberRefs:Q.getFiberRefs(),runtimeFlags:SE.runtimeFlags});t.onFromClient({message:{_tag:"Interrupt",requestId:S,interruptors:I},context:B,discard:!1}).pipe(nf(1000),rs(P)).addObserver(()=>{R(Y)})}),x=(S)=>{switch(S._tag){case"Chunk":{let I=S.requestId,B=c.get(I);if(!B||B._tag!=="Mailbox")return Y;return B.mailbox.offerAll(S.values).pipe(n?ve(t.onFromClient({message:{_tag:"Ack",requestId:S.requestId},context:B.context,discard:!1})):X,rn((R)=>B.mailbox.done(En(R))))}case"Exit":{let I=S.requestId,B=c.get(I);if(!B)return Y;if(c.delete(I),B._tag==="Effect")return B.resume(S.exit),Y;return B.mailbox.done(UZ(S.exit))}case"Defect":return u(Zg(S.defect));case"ClientEnd":return Y}},y;if(t.flatten){let S=new Map;y=function(B,R,Q){let P=S.get(B);if(!P)P=p(e.requests.get(B)),S.set(B,P);return P(R,Q)}}else{y={};for(let S of e.requests.values()){let I=S._tag.indexOf("."),B=I===-1?void 0:S._tag.slice(0,I);if(B!==void 0&&!(B in y))y[B]={};let R=B!==void 0?y[B]:y,Q=B!==void 0?S._tag.slice(I+1):S._tag;R[Q]=p(S)}}return{client:y,write:x}}),q8e=cg(-503,0);var Lye=Ae("@effect/rpc/RpcClient/currentHeaders",()=>Pi(oi));var Hye=/\+/g,Wye=function(){};Wye.prototype=Object.create(null);function qye(e){let t=new Wye;if(typeof e!=="string")return t;let r=e.length,n="",o="",s=-1,i=-1,a=!1,c=!1,l=!1,u=!1,p=!1,f=0;for(let A=0;A<r+1;A++)if(f=A!==r?e.charCodeAt(A):38,f===38){if(p=i>s,!p)i=A;if(n=e.slice(s+1,i),p||n.length>0){if(l)n=n.replace(Hye," ");if(a)try{n=decodeURIComponent(n)||n}catch{}if(p){if(o=e.slice(i+1,A),u)o=o.replace(Hye," ");if(c)try{o=decodeURIComponent(o)||o}catch{}}let d=t[n];if(d===void 0)t[n]=o;else if(d.pop)d.push(o);else t[n]=[d,o]}o="",s=A,i=A,a=!1,c=!1,l=!1,u=!1}else if(f===61)if(i<=s)i=A;else c=!0;else if(f===43)if(i>s)u=!0;else l=!0;else if(f===37)if(i>s)c=!0;else a=!0;return t}var V8e=/^https?:\/\/.*?\//,YV=/(\/:[^/()]*?)\?(\/?)/,Jye=(e={})=>new zye(e);class zye{constructor(e={}){this.options={ignoreTrailingSlash:!0,ignoreDuplicateSlashes:!0,caseSensitive:!1,maxParamLength:100,...e}}options;routes=[];trees={};on(e,t,r){let n=t.match(YV);if(n&&n.index!==void 0){J8e(t.length===n.index+n[0].length,"Optional Parameter needs to be the last parameter of the path");let s=t.replace(YV,"$1$2"),i=t.replace(YV,"$2");this.on(e,s,r),this.on(e,i,r);return}if(this.options.ignoreDuplicateSlashes)t=Gye(t);if(this.options.ignoreTrailingSlash)t=Yye(t);let o=typeof e==="string"?[e]:e;for(let s of o)this._on(s,t,r)}all(e,t){this.on(X8e,e,t)}_on(e,t,r){if(this.trees[e]===void 0)this.trees[e]=new gB("/");let n=t;if(n==="*"&&this.trees[e].prefix.length!==0){let c=this.trees[e];this.trees[e]=new gB(""),this.trees[e].staticChildren["/"]=c}let o=this.trees[e].prefix.length,s=this.trees[e],i=[];for(let c=0;c<=n.length;c++){if(n.charCodeAt(c)===58&&n.charCodeAt(c+1)===58){c++;continue}let l=n.charCodeAt(c)===58&&n.charCodeAt(c+1)!==58,u=n.charCodeAt(c)===42;if(l||u||c===n.length&&c!==o){let p=n.slice(o,c);if(!this.options.caseSensitive)p=p.toLowerCase();p=p.split("::").join(":"),p=p.split("%").join("%25"),s=s.createStaticChild(p)}if(l){let p=!1,f=[],A=c+1;for(let d=A;;d++){let g=n.charCodeAt(d),x=g===40,y=g===45||g===46,S=g===47||d===n.length;if(x||y||S){let I=n.slice(A,d);if(i.push(I),p=p||x||y,x){let Q=j8e(n,d),P=n.slice(d,Q+1);f.push($8e(P)),d=Q+1}else f.push("(.*?)");let B=d;for(;d<n.length;d++){let Q=n.charCodeAt(d);if(Q===47)break;if(Q===58)if(n.charCodeAt(d+1)===58)d++;else break}let R=n.slice(B,d);if(R)R=R.split("::").join(":"),R=R.split("%").join("%25"),f.push(K8e(R));if(A=d+1,S||n.charCodeAt(d)===47||d===n.length){let Q=p?"()"+R:R,P=n.slice(c,d);n=n.slice(0,c+1)+Q+n.slice(d),c+=Q.length;let F=p?new RegExp("^"+f.join("")+"$"):void 0;s=s.createParametricChild(F,R,P),o=c+1;break}}}}else if(u){if(i.push("*"),s=s.createWildcardChild(),o=c+1,c!==n.length-1)throw Error("Wildcard must be the last character in the route")}}if(!this.options.caseSensitive)n=n.toLowerCase();if(n==="*")n="/*";for(let c of this.routes)if(c.method===e&&c.pattern===n)throw Error(`Method '${e}' already declared for route '${n}'`);let a={method:e,path:t,pattern:n,params:i,handler:r};this.routes.push(a),s.addRoute(a)}has(e,t){let r=this.trees[e];if(r===void 0)return!1;let n=r.getStaticChild(t);if(n===void 0)return!1;return n.isLeafNode}find(e,t){let r=this.trees[e];if(r===void 0)return;if(t.charCodeAt(0)!==47)t=t.replace(V8e,"/");if(this.options.ignoreDuplicateSlashes)t=Gye(t);let n,o,s;try{n=Z8e(t),t=n.path,o=n.querystring,s=n.shouldDecodeParam}catch(f){return}if(this.options.ignoreTrailingSlash)t=Yye(t);let i=t;if(this.options.caseSensitive===!1)t=t.toLowerCase();let a=this.options.maxParamLength,c=r.prefix.length,l=[],u=t.length,p=[];while(!0){if(c===u&&r.isLeafNode){let A=r.handlerStorage?.find();if(A!==void 0)return{handler:A.handler,params:A.createParams(l),searchParams:qye(o)}}let f=r.getNextNode(t,c,p,l.length);if(f===void 0){if(p.length===0)return;let A=p.pop();c=A.brotherPathIndex,l.splice(A.paramsCount),f=A.brotherNode}if(r=f,r._tag==="StaticNode"){c+=r.prefix.length;continue}if(r._tag==="WildcardNode"){let A=i.slice(c);if(s)A=Vye(A);l.push(A),c=u;continue}if(r._tag==="ParametricNode"){let A=i.indexOf("/",c);if(A===-1)A=u;let d=i.slice(c,A);if(s)d=Vye(d);if(r.regex!==void 0){let g=r.regex.exec(d);if(g===null)continue;for(let x=1;x<g.length;x++){let y=g[x];if(y.length>a)return;l.push(y)}}else{if(d.length>a)return;l.push(d)}c=A}}}}class jye{handlers=[];unconstrainedHandler;find(){return this.unconstrainedHandler}add(e){let t={params:e.params,handler:e.handler,createParams:z8e(e.params)};this.handlers.push(t),this.unconstrainedHandler=this.handlers[0]}}class VV{isLeafNode=!1;routes;handlerStorage;addRoute(e){if(this.routes===void 0)this.routes=[e];else this.routes.push(e);if(this.handlerStorage===void 0)this.handlerStorage=new jye;this.isLeafNode=!0,this.handlerStorage.add(e)}}class JV extends VV{staticChildren={};findStaticMatchingChild(e,t){let r=this.staticChildren[e.charAt(t)];if(r===void 0||!r.matchPrefix(e,t))return;return r}getStaticChild(e,t=0){if(e.length===t)return this;let r=this.findStaticMatchingChild(e,t);if(r===void 0)return;return r.getStaticChild(e,t+r.prefix.length)}createStaticChild(e){if(e.length===0)return this;let t=this.staticChildren[e.charAt(0)];if(t){let n=1;for(;n<t.prefix.length;n++)if(e.charCodeAt(n)!==t.prefix.charCodeAt(n)){t=t.split(this,n);break}return t.createStaticChild(e.slice(n))}let r=e.charAt(0);return this.staticChildren[r]=new gB(e),this.staticChildren[r]}}class gB extends JV{_tag="StaticNode";constructor(e){super();this.setPrefix(e)}prefix;matchPrefix;parametricChildren=[];wildcardChild;setPrefix(e){if(this.prefix=e,e.length===1)this.matchPrefix=(t,r)=>!0;else{let t=e.length;this.matchPrefix=function(r,n){for(let o=1;o<t;o++)if(r.charCodeAt(n+o)!==this.prefix.charCodeAt(o))return!1;return!0}}}getParametricChild(e){if(e===void 0)return this.parametricChildren.find((r)=>r.isRegex===!1);let t=e.source;return this.parametricChildren.find((r)=>{if(r.regex===void 0)return!1;return r.regex.source===t})}createParametricChild(e,t,r){let n=this.getParametricChild(e);if(n!==void 0)return n.nodePaths.add(r),n;return n=new $ye(e,t,r),this.parametricChildren.push(n),this.parametricChildren.sort((o,s)=>{if(!o.isRegex)return 1;if(!s.isRegex)return-1;if(o.staticSuffix===void 0)return 1;if(s.staticSuffix===void 0)return-1;if(s.staticSuffix.endsWith(o.staticSuffix))return 1;if(o.staticSuffix.endsWith(s.staticSuffix))return-1;return 0}),n}createWildcardChild(){if(this.wildcardChild===void 0)this.wildcardChild=new Kye;return this.wildcardChild}split(e,t){let r=this.prefix.slice(0,t),n=this.prefix.slice(t);this.setPrefix(n);let o=new gB(r);return o.staticChildren[n.charAt(0)]=this,e.staticChildren[r.charAt(0)]=o,o}getNextNode(e,t,r,n){let o=this.findStaticMatchingChild(e,t),s=0;if(o===void 0){if(this.parametricChildren.length===0)return this.wildcardChild;o=this.parametricChildren[0],s=1}if(this.wildcardChild!==void 0)r.push({paramsCount:n,brotherPathIndex:t,brotherNode:this.wildcardChild});for(let i=this.parametricChildren.length-1;i>=s;i--)r.push({paramsCount:n,brotherPathIndex:t,brotherNode:this.parametricChildren[i]});return o}}class $ye extends JV{regex;staticSuffix;_tag="ParametricNode";constructor(e,t,r){super();this.regex=e,this.staticSuffix=t,this.isRegex=!!e,this.nodePaths=new Set([r])}isRegex;nodePaths;getNextNode(e,t){return this.findStaticMatchingChild(e,t)}}class Kye extends VV{_tag="WildcardNode";getNextNode(e,t,r,n){return}}var J8e=(e,t)=>{if(!e)throw Error(t)};function Gye(e){return e.replace(/\/\/+/g,"/")}function Yye(e){if(e.length>1&&e.charCodeAt(e.length-1)===47)return e.slice(0,-1);return e}function z8e(e){let t=e.length;return function(r){let n={};for(let o=0;o<t;o++)n[e[o]]=r[o];return n}}function j8e(e,t){let r=1;while(t<e.length){if(t++,e[t]==="\\"){t++;continue}if(e[t]===")")r--;else if(e[t]==="(")r++;if(!r)return t}throw TypeError('Invalid regexp expression in "'+e+'"')}function $8e(e){if(e.charCodeAt(1)===94)e=e.slice(0,1)+e.slice(2);if(e.charCodeAt(e.length-2)===36)e=e.slice(0,e.length-2)+e.slice(e.length-1);return e}function K8e(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Zye(e,t){if(e===50){if(t===53)return"%";if(t===51)return"#";if(t===52)return"$";if(t===54)return"&";if(t===66)return"+";if(t===98)return"+";if(t===67)return",";if(t===99)return",";if(t===70)return"/";if(t===102)return"/";return}if(e===51){if(t===65)return":";if(t===97)return":";if(t===66)return";";if(t===98)return";";if(t===68)return"=";if(t===100)return"=";if(t===70)return"?";if(t===102)return"?";return}if(e===52&&t===48)return"@";return}function Z8e(e){let t=!1,r=!1,n="";for(let s=1;s<e.length;s++){let i=e.charCodeAt(s);if(i===37){let a=e.charCodeAt(s+1),c=e.charCodeAt(s+2);if(Zye(a,c)===void 0)t=!0;else{if(r=!0,a===50&&c===53)t=!0,e=e.slice(0,s+1)+"25"+e.slice(s+1),s+=2;s+=2}}else if(i===63||i===59||i===35){n=e.slice(s+1),e=e.slice(0,s);break}}return{path:t?decodeURI(e):e,querystring:n,shouldDecodeParam:r}}function Vye(e){let t=e.indexOf("%");if(t===-1)return e;let r="",n=t;for(let o=t;o<e.length;o++)if(e.charCodeAt(o)===37){let s=e.charCodeAt(o+1),i=e.charCodeAt(o+2),a=Zye(s,i);r+=e.slice(n,o)+a,n=o+3}return e.slice(0,t)+r+e.slice(n)}var X8e=["ACL","BIND","CHECKOUT","CONNECT","COPY","DELETE","GET","HEAD","LINK","LOCK","M-SEARCH","MERGE","MKACTIVITY","MKCALENDAR","MKCOL","MOVE","NOTIFY","OPTIONS","PATCH","POST","PROPFIND","PROPPATCH","PURGE","PUT","REBIND","REPORT","SEARCH","SOURCE","SUBSCRIBE","TRACE","UNBIND","UNLINK","UNLOCK","UNSUBSCRIBE"];var Xye=Jye;var nCe=(e,t)=>{let r=t.definitionPath??"#/$defs/",n=(a)=>r+a,o=t.target??"jsonSchema7",s=t.topLevelReferenceStrategy??"keep",i=t.additionalPropertiesStrategy??"strict";return In(e,t.definitions,"handle-identifier",[],{getRef:n,target:o,topLevelReferenceStrategy:s,additionalPropertiesStrategy:i},"handle-annotation","handle-errors")},EB={$id:"/schemas/never",not:{}},bm={$id:"/schemas/any"},oCe={$id:"/schemas/unknown"},sCe={$id:"/schemas/void"},r6e={$id:"/schemas/object",anyOf:[{type:"object"},{type:"array"}]},n6e={$id:"/schemas/%7B%7D",anyOf:[{type:"object"},{type:"array"}]};function iCe(e){if(e!==void 0)return pt(cf(e))}function aCe(e){if(e!==void 0)return pt(PS(e))}function cCe(e){if(e!==void 0)return D7(e);return T()}function o6e(e,t){return O0(e,!1)(t)}function lCe(e){if(e!==void 0)return pt(k7(e))}function s6e(e,t){let r=O0(e,!1),n=rp(t,(o)=>r(o).pipe(qs(AF)));return n.length>0?n:void 0}function eCe(e,t,r){if(t!==void 0)switch(e._tag){case"StringKeyword":return t!==QE.annotations[r]?t:void 0;case"NumberKeyword":return t!==wE.annotations[r]?t:void 0;case"BooleanKeyword":return t!==RE.annotations[r]?t:void 0}return t}function AF(e,t=new Set){if(e===null||typeof e==="string"||typeof e==="number"||typeof e==="boolean")return!0;if(Array.isArray(e)||typeof e==="object"){if(t.has(e))return!1;t.add(e);try{if(Array.isArray(e))return e.every((n)=>AF(n,t));let r=Object.getPrototypeOf(e);if(r!==null&&r!==Object.prototype)return!1;if(Object.getOwnPropertySymbols(e).length>0)return!1;return Object.values(e).every((n)=>AF(n,t))}finally{t.delete(e)}}return!1}function uCe(e,t,r,n,o){let s={};if(t!==void 0)s.description=t;if(r!==void 0)s.title=r;if(de(n)){let i=o6e(e,n.value);if(de(i)&&AF(i.value))s.default=i.value}if(o!==void 0){let i=s6e(e,o);if(i!==void 0)s.examples=i}if(Object.keys(s).length===0)return;return s}function zV(e,t){return uCe(e,iCe(t),aCe(t),cCe(t),lCe(t))}function pCe(e){return uCe(e,eCe(e,iCe(e),Wi),eCe(e,aCe(e),Eo),cCe(e),lCe(e))}function jV(e,t){if(t){if("$ref"in e)return{allOf:[e],...t};return{...e,...t}}return e}var dF=(e)=>{if($e(MH(e)))return zH(e,dF,(t)=>dF(t.from))},i6e=(e)=>e.annotations[th]===y0,a6e=(e,t)=>{if(Uc(e)){if(e.annotations[th]===d0)return"type"in t&&t.type!=="integer"}return"type"in t||"oneOf"in t||"anyOf"in t||"$ref"in t},c6e=(e,t,r)=>{let n={...e,...pCe(r),...t};n.allOf??=[];let o=(s,i)=>{if(s in t&&s in e)n.allOf.unshift({[s]:e[s]}),n.allOf=n.allOf.filter(i)};if(o("minLength",(s)=>s.minLength>t.minLength),o("maxLength",(s)=>s.maxLength<t.maxLength),o("pattern",(s)=>s.pattern!==t.pattern),o("minItems",(s)=>s.minItems>t.minItems),o("maxItems",(s)=>s.maxItems<t.maxItems),o("minimum",(s)=>s.minimum>t.minimum),o("maximum",(s)=>s.maximum<t.maximum),o("exclusiveMinimum",(s)=>s.exclusiveMinimum>t.exclusiveMinimum),o("exclusiveMaximum",(s)=>s.exclusiveMaximum<t.exclusiveMaximum),o("multipleOf",(s)=>s.multipleOf!==t.multipleOf),n.allOf.length===0)delete n.allOf;return n};function l6e(e){switch(e.target){case"jsonSchema7":return!1;case"jsonSchema2019-09":case"jsonSchema2020-12":case"openApi3.1":return!0}}function u6e(e){switch(e.additionalPropertiesStrategy){case"allow":return!0;case"strict":return!1}}function cr(e,t){return fCe(e,pCe(t))}function fCe(e,t){if(t===void 0||Object.keys(t).length===0)return e;if("$ref"in e)return{allOf:[e],...t};return{...e,...t}}function $V(e){let t=pt(_H(e));if(t===void 0){if(WH(e))return $V(e.f());if(w0(e)&&qS(e.from)&&N7(e.to)){let r=e.to,n=Zl(r);if(de(n))return $V(r)}}return t}function In(e,t,r,n,o,s,i){if(r==="handle-identifier"&&(o.topLevelReferenceStrategy!=="skip"||WH(e))){let c=$V(e);if(c!==void 0){let l=c.replace(/~/ig,"~0").replace(/\//ig,"~1"),u={$ref:o.getRef(l)};if(!nN(t,c))t[c]=u,t[c]=In(e,t,"ignore-identifier",n,o,"handle-annotation",i);return u}}if(s==="handle-annotation"){let c=MH(e);if(de(c)){let l=c.value;if(a6e(e,l))switch(e._tag){case"Declaration":return cr(l,e);default:return l}else switch(e._tag){case"Refinement":{let u=NS(e);if(u===void 0)return c6e(In(e.from,t,r,n,o,"handle-annotation",i),l,e);else return In(u,t,r,n,o,"handle-annotation",i)}default:return{...In(e,t,r,n,o,"ignore-annotation",i),...l}}}}let a=Zl(e);if(de(a))return In(a.value,t,r,n,o,"handle-annotation",i);switch(e._tag){case"Declaration":case"UndefinedKeyword":case"BigIntKeyword":case"UniqueSymbol":case"SymbolKeyword":{if(i==="ignore-errors")return cr(bm,e);throw Error(mH(n,e))}case"Suspend":{if(r==="handle-identifier"){if(i==="ignore-errors")return cr(bm,e);throw Error(c7(n,e))}return In(e.f(),t,"ignore-identifier",n,o,"handle-annotation",i)}case"NeverKeyword":return cr(EB,e);case"VoidKeyword":return cr(sCe,e);case"UnknownKeyword":return cr(oCe,e);case"AnyKeyword":return cr(bm,e);case"ObjectKeyword":return cr(r6e,e);case"StringKeyword":return cr({type:"string"},e);case"NumberKeyword":return cr({type:"number"},e);case"BooleanKeyword":return cr({type:"boolean"},e);case"Literal":{let c=e.literal;if(c===null)return cr({type:"null"},e);else if(Gt(c))return cr({type:"string",enum:[c]},e);else if(eo(c))return cr({type:"number",enum:[c]},e);else if(Ps(c))return cr({type:"boolean",enum:[c]},e);if(i==="ignore-errors")return cr(bm,e);throw Error(mH(n,e))}case"Enums":{let c=e.enums.map((l)=>({type:eo(l[1])?"number":"string",title:l[0],enum:[l[1]]}));return c.length>=1?cr({$comment:"/schemas/enums",anyOf:c},e):cr(EB,e)}case"TupleType":{let c=e.elements.map((A,d)=>jV(In(A.type,t,"handle-identifier",n.concat(d),o,"handle-annotation",i),zV(A.type,A))),l=e.rest.map((A)=>jV(In(A.type,t,"handle-identifier",n,o,"handle-annotation",i),zV(A.type,A))),u={type:"array"},p=e.elements.length;if(p>0)if(u.minItems=p-e.elements.filter((A)=>A.isOptional).length,o.target==="jsonSchema7")u.items=c;else u.prefixItems=c;let f=l.length;if(f>0){let A=l[0];if(f===1&&e.elements.every((g)=>g.type===e.rest[0].type))if(o.target==="jsonSchema7")u.items=A;else u.items=A,delete u.prefixItems;else if(o.target==="jsonSchema7")u.additionalItems=A;else u.items=A;if(f>1){if(i==="ignore-errors")return cr(bm,e);throw Error(l7(n))}}else if(p>0)if(o.target==="jsonSchema7")u.additionalItems=!1;else u.items=!1;else u.maxItems=0;return cr(u,e)}case"TypeLiteral":{if(e.propertySignatures.length===0&&e.indexSignatures.length===0)return cr(n6e,e);let c={type:"object",required:[],properties:{},additionalProperties:u6e(o)},l=void 0,u=void 0;for(let p of e.indexSignatures){let f=dF(p.type)??p.type,A=p.parameter;switch(A._tag){case"StringKeyword":{c.additionalProperties=In(f,t,"handle-identifier",n,o,"handle-annotation",i);break}case"TemplateLiteral":{l=In(f,t,"handle-identifier",n,o,"handle-annotation",i),u={type:"string",pattern:vE(A).source};break}case"Refinement":{l=In(f,t,"handle-identifier",n,o,"handle-annotation",i),u=In(A,t,"handle-identifier",n,o,"handle-annotation",i);break}case"SymbolKeyword":{let d=n.concat("[symbol]");c.additionalProperties=In(f,t,"handle-identifier",d,o,"handle-annotation",i),u=In(A,t,"handle-identifier",d,o,"handle-annotation",i);break}}}for(let p=0;p<e.propertySignatures.length;p++){let f=e.propertySignatures[p],A=f.name;if(Gt(A)){let d=dF(f.type),g=d??f.type;if(c.properties[A]=jV(In(g,t,"handle-identifier",n.concat(f.name),o,"handle-annotation",i),zV(g,f)),!f.isOptional&&d===void 0)c.required.push(A)}else{if(i==="ignore-errors")return cr(bm,e);throw Error(u7(A,n))}}if(l!==void 0)delete c.additionalProperties,c.patternProperties={"":l};if(u!==void 0)c.propertyNames=u;return cr(c,e)}case"Union":{let c=e.types.map((u)=>In(u,t,"handle-identifier",n,o,"handle-annotation",i)),l=h6e(c);switch(l.length){case 0:return EB;case 1:return cr(l[0],e);default:return cr({anyOf:l},e)}}case"Refinement":return In(e.from,t,r,n,o,"handle-annotation",i);case"TemplateLiteral":{let c=vE(e);return cr({type:"string",title:String(e),description:"a template literal",pattern:c.source},e)}case"Transformation":{if(i6e(e.from)){let l={type:"string",contentMediaType:"application/json"};if(l6e(o))l.contentSchema=In(e.to,t,r,n,o,"handle-annotation",i);return l}let c=In(e.from,t,r,n,o,"handle-annotation",i);if(e.transformation._tag==="TypeLiteralTransformation"&&tCe(c)){let l=In(e.to,{},"ignore-identifier",n,o,"handle-annotation","ignore-errors");if(tCe(l))for(let u of e.transformation.propertySignatureTransformations){let{to:p,from:f}=u;if(Gt(p)&&Gt(f)){let A=l.properties[p];if(zu(A)){let d=c.properties[f];if(zu(d)){let g={};if(Gt(A.title))g.title=A.title;if(Gt(A.description))g.description=A.description;if(Array.isArray(A.examples))g.examples=A.examples;if(Object.hasOwn(A,"default")&&A.default!==void 0)g.default=A.default;c.properties[f]=fCe(d,g)}}}}}return cr(c,e)}}}function tCe(e){return zu(e)&&e.type==="object"&&zu(e.properties)}function p6e(e){return e===EB||ee(e,"$id")&&e.$id===EB.$id&&Object.keys(e).length===3&&e.title===sh.annotations[Eo]}function f6e(e){return"$id"in e&&e.$id===bm.$id}function A6e(e){return"$id"in e&&e.$id===oCe.$id}function d6e(e){return"$id"in e&&e.$id===sCe.$id}function rCe(e){return ee(e,"enum")&&"type"in e&&Object.keys(e).length===2}function h6e(e){let t=[];for(let r of e){if(p6e(r))continue;if(f6e(r)||A6e(r)||d6e(r))return[r];if(rCe(r)&&t.length>0){let n=t[t.length-1];if(rCe(n)&&n.type===r.type){t[t.length-1]={type:n.type,enum:[...n.enum,...r.enum]};continue}}t.push(r)}return t}var g6e={add(...e){return dA({requests:ACe(...this.requests.values(),...e),annotations:this.annotations})},merge(...e){let t=new Map(this.requests),r=new Map(this.annotations.unsafeMap);for(let n of e){for(let[o,s]of n.requests)t.set(o,s);for(let[o,s]of n.annotations.unsafeMap)r.set(o,s)}return dA({requests:t,annotations:fp(r)})},middleware(e){let t=new Map;for(let[r,n]of this.requests)t.set(r,n.middleware(e));return dA({requests:t,annotations:this.annotations})},toHandlersContext(e){return _e(this,function*(){let t=yield*vn(),r=tn(e)?yield*e:e,n=new Map;for(let[o,s]of Object.entries(r)){let i=this.requests.get(o);n.set(i.key,{handler:s,context:t})}return fp(n)})},prefix(e){let t=new Map;for(let r of this.requests.values()){let n=r.prefix(e);t.set(n._tag,n)}return dA({requests:t,annotations:this.annotations})},toLayer(e){return RS(this.toHandlersContext(e))},of:X,toLayerHandler(e,t){return RS(_e(this,function*(){let r=yield*vn(),n=tn(t)?yield*t:t,o=new Map,s=this.requests.get(e);return o.set(s.key,{handler:n,context:r}),fp(o)}))},accessHandler(e){return qP((t)=>{let r=this.requests.get(e),{context:n,handler:o}=t.unsafeMap.get(r.key);return(s,i)=>{let a=o(s,i),c=_ye(a)?a.value:a;return tn(c)?Jn(c,n):jD(c,n)}})},annotate(e,t){return dA({requests:this.requests,annotations:dr(this.annotations,e,t)})},annotateRpcs(e,t){return this.annotateRpcsContext(wl(e,t))},annotateContext(e){return dA({requests:this.requests,annotations:wr(this.annotations,e)})},annotateRpcsContext(e){let t=new Map;for(let[r,n]of this.requests)t.set(r,n.annotateContext(wr(e,n.annotations)));return dA({requests:t,annotations:this.annotations})}},dA=(e)=>Object.assign(function(){},g6e,{requests:e.requests,annotations:e.annotations}),ACe=(...e)=>{let t=new Map;for(let r of e)t.set(r._tag,On(r)?Nye(r):r);return t},dCe=(...e)=>dA({requests:ACe(...e),annotations:Pr()});var x6e=Ie(m,re),hCe=Ie(m,re);class Fu extends b({_meta:U(b({progressToken:U(hCe)}))}){}class hA extends b({_meta:U(Fn({key:m,value:Tt}))}){}class mA extends b({_meta:U(Fn({key:m,value:Tt}))}){}var mCe=m;class y6e extends b({...Fu.fields,cursor:U(mCe)}){}class xB extends b({...hA.fields,nextCursor:U(mCe)}){}var gCe=_("user","assistant");class Bm extends b({audience:U(Re(gCe)),priority:U(re.pipe(q0(0,1)))}){}class KV extends b({name:m,title:U(m),version:m}){}class ECe extends Oe("@effect/ai/McpSchema/ClientCapabilities")({experimental:U(Fn({key:m,value:b({})})),roots:U(b({listChanged:U(ae)})),sampling:U(b({})),elicitation:U(b({}))}){}class xCe extends b({experimental:U(Fn({key:m,value:b({})})),logging:U(b({})),completions:U(b({})),prompts:U(b({listChanged:U(ae)})),resources:U(b({subscribe:U(ae),listChanged:U(ae)})),tools:U(b({listChanged:U(ae)}))}){}class Us extends Oe("@effect/ai/McpSchema/McpError")({code:re,message:m,data:U(Tt)}){}var C6e=-32600,S6e=-32601,I6e=-32602,b6e=-32603,B6e=-32700;class Q6e extends ot()("ParseError",{...Us.fields,code:Yi(B6e)}){}class w6e extends ot()("InvalidRequest",{...Us.fields,code:Yi(C6e)}){}class R6e extends ot()("MethodNotFound",{...Us.fields,code:Yi(S6e)}){}class yB extends ot()("InvalidParams",{...Us.fields,code:Yi(I6e)}){}class my extends ot()("InternalError",{...Us.fields,code:Yi(b6e)}){static notImplemented=new my({message:"Not implemented"})}class yCe extends Oe("@effect/ai/McpSchema/InitializeResult")({...hA.fields,protocolVersion:m,capabilities:xCe,serverInfo:KV,instructions:U(m)}){}class k6e extends Wo("initialize",{success:yCe,error:Us,payload:{...Fu.fields,protocolVersion:m,capabilities:ECe,clientInfo:KV}}){}class CCe extends Wo("notifications/cancelled",{payload:{...mA.fields,requestId:x6e,reason:U(m)}}){}class SCe extends Wo("notifications/progress",{payload:{...mA.fields,progressToken:hCe,progress:U(re),total:U(re),message:U(m)}}){}class CB extends Oe("@effect/ai/McpSchema/Resource")({uri:m,name:m,title:U(m),description:U(m),mimeType:U(m),annotations:U(Bm),size:U(re)}){}class hF extends Oe("@effect/ai/McpSchema/ResourceTemplate")({uriTemplate:m,name:m,title:U(m),description:U(m),mimeType:U(m),annotations:U(Bm)}){}class ZV extends b({uri:m,mimeType:U(m)}){}class XV extends b({...ZV.fields,text:m}){}class eJ extends b({...ZV.fields,blob:V0}){}class ICe extends Oe("@effect/ai/McpSchema/ListResourcesResult")({...xB.fields,resources:Re(CB)}){}class bCe extends Oe("@effect/ai/McpSchema/ListResourceTemplatesResult")({...xB.fields,resourceTemplates:Re(hF)}){}class BCe extends b({...hA.fields,contents:Re(Ie(XV,eJ))}){}class D6e extends Wo("resources/read",{success:BCe,error:Us,payload:{...Fu.fields,uri:m}}){}class QCe extends Wo("notifications/resources/list_changed",{payload:nu(mA)}){}class T6e extends Wo("resources/subscribe",{error:Us,payload:{...Fu.fields,uri:m}}){}class v6e extends Wo("resources/unsubscribe",{error:Us,payload:{...Fu.fields,uri:m}}){}class wCe extends Wo("notifications/resources/updated",{payload:{...mA.fields,uri:m}}){}class RCe extends b({name:m,title:U(m),description:U(m),required:U(ae)}){}class tJ extends Oe("@effect/ai/McpSchema/Prompt")({name:m,title:U(m),description:U(m),arguments:U(Re(RCe))}){}class rJ extends b({type:Yi("text"),text:m,annotations:U(Bm)}){}class kCe extends b({type:Yi("image"),data:V0,mimeType:m,annotations:U(Bm)}){}class DCe extends b({type:Yi("audio"),data:V0,mimeType:m,annotations:U(Bm)}){}class TCe extends b({type:Yi("resource"),resource:Ie(XV,eJ),annotations:U(Bm)}){}class vCe extends b({...CB.fields,type:Yi("resource_link")}){}class nJ extends Ie(rJ,kCe,DCe,TCe,vCe){}class OCe extends b({role:gCe,content:nJ}){}class FCe extends Oe("@effect/ai/McpSchema/ListPromptsResult")({...xB.fields,prompts:Re(tJ)}){}class oJ extends Oe("@effect/ai/McpSchema/GetPromptResult")({...hA.fields,messages:Re(OCe),description:U(m)}){}class O6e extends Wo("prompts/get",{success:oJ,error:Us,payload:{...Fu.fields,name:m,title:U(m),arguments:U(Fn({key:m,value:m}))}}){}class MCe extends Wo("notifications/prompts/list_changed",{payload:nu(mA)}){}class mF extends Oe("@effect/ai/McpSchema/ToolAnnotations")({title:U(m),readOnlyHint:C(ae,{default:()=>!1}),destructiveHint:C(ae,{default:()=>!0}),idempotentHint:C(ae,{default:()=>!1}),openWorldHint:C(ae,{default:()=>!0})}){}class gF extends Oe("@effect/ai/McpSchema/Tool")({name:m,title:U(m),description:U(m),inputSchema:Tt,annotations:U(mF)}){}class NCe extends Oe("@effect/ai/McpSchema/ListToolsResult")({...xB.fields,tools:Re(gF)}){}class SB extends Oe("@effect/ai/McpSchema/CallToolResult")({...hA.fields,content:Re(nJ),structuredContent:U(Tt),isError:U(ae)}){}class F6e extends Wo("tools/call",{success:SB,error:Us,payload:{...Fu.fields,name:m,arguments:Fn({key:m,value:Tt})}}){}class _Ce extends Wo("notifications/tools/list_changed",{payload:nu(mA)}){}var UCe=_("debug","info","notice","warning","error","critical","alert","emergency");class M6e extends Wo("logging/setLevel",{payload:{...Fu.fields,level:UCe},error:Us}){}class LCe extends Wo("notifications/message",{payload:b({...mA.fields,level:UCe,logger:U(m),data:Tt})}){}class IB extends Oe("@effect/ai/McpSchema/CompleteResult")({completion:b({values:Re(m),total:U(re),hasMore:U(ae)})}){static empty=IB.make({completion:{values:[],total:0,hasMore:!1}})}class PCe extends Oe("@effect/ai/McpSchema/ElicitAcceptResult")({...hA.fields,action:_("accept"),content:Tt}){}class HCe extends Oe("@effect/ai/McpSchema/ElicitDeclineResult")({...hA.fields,action:_("cancel","decline")}){}var N6e=Ie(PCe,HCe);class sJ extends Wo("elicitation/create",{success:N6e,error:Us,payload:{message:m,requestedSchema:Tt}}){}class WCe extends ot("@effect/ai/McpSchema/ElicitationDeclined")("ElicitationDeclined",{request:sJ.payloadSchema,cause:U(bt)}){}class iJ extends dCe(CCe,SCe,LCe,wCe,QCe,_Ce,MCe){}var qCe=Symbol.for("@effect/ai/McpSchema/ParamNameId");var _6e="~@effect/ai/Tool",GCe="~@effect/ai/Tool/ProviderDefined";var YCe={[_6e]:{_Requirements:X},pipe(){return W(this,arguments)},addDependency(){return gA({...this})},setParameters(e){return gA({...this,parametersSchema:On(e)?e:b(e)})},setSuccess(e){return gA({...this,successSchema:e})},setFailure(e){return gA({...this,failureSchema:e})},annotate(e,t){return gA({...this,annotations:dr(this.annotations,e,t)})},annotateContext(e){return gA({...this,annotations:wr(this.annotations,e)})}},SLt={...YCe,[GCe]:GCe},gA=(e)=>{let t=Object.assign(Object.create(YCe),e);return t.id=`@effect/ai/Tool/${e.name}`,t};var U6e=b({}),aJ=(e,t)=>{let r=t?.success??qE,n=t?.failure??Af;return gA({name:e,description:t?.description,parametersSchema:t?.parameters?b(t?.parameters):U6e,successSchema:r,failureSchema:n,failureMode:t?.failureMode??"error",annotations:Pr()})};var VCe=(e)=>gA({name:e._tag,description:pt(cf(e.ast.to)),parametersSchema:e,successSchema:e.success,failureSchema:e.failure,failureMode:"error",annotations:Pr()});class cJ extends wi("@effect/ai/Tool/Title")(){}class gy extends hr()("@effect/ai/Tool/Readonly",{defaultValue:tr}){}class Ey extends hr()("@effect/ai/Tool/Destructive",{defaultValue:Io}){}class lJ extends hr()("@effect/ai/Tool/Idempotent",{defaultValue:tr}){}class uJ extends hr()("@effect/ai/Tool/OpenWorld",{defaultValue:Io}){}class Al extends wi("@effect/ai/McpServer")(){static make=_e(function*(){let e=H6e(),t=dn(),r=new Map,n=[],o=[],s=[],i=new Map,a=new Map,c=yield*Df(),l=new Map,u=yield*Pye(iJ,{spanPrefix:"McpServer/Notifications",onFromClient(p){let f=p.message;if(f._tag!=="Request")return Y;if(f.tag.includes("list_changed")){if(!l.has(f.tag))l.set(f.tag,setTimeout(()=>{c.unsafeOffer(f),l.delete(f.tag)},0))}else c.unsafeOffer(f);return u.write({clientId:0,requestId:f.id,_tag:"Exit",exit:Fi})}});return Al.of({notifications:u.client,notificationsMailbox:c,initializedClients:new Set,get tools(){return t},addTool:(p)=>Te(()=>(t.push(p.tool),r.set(p.tool.name,p.handle),u.client["notifications/tools/list_changed"]({}))),callTool:(p)=>Te(()=>{let f=r.get(p.name);if(!f)return ce(new yB({message:`Tool '${p.name}' not found`}));return f(p.arguments)}),get resources(){return n},get resourceTemplates(){return o},addResource:(p,f)=>Te(()=>(n.push(p),e.add(p.uri,{_tag:"Resource",effect:f}),u.client["notifications/resources/list_changed"]({}))),addResourceTemplate:({completions:p,handle:f,routerPath:A,template:d})=>Te(()=>{o.push(d),e.add(A,{_tag:"ResourceTemplate",handle:f});for(let[g,x]of Object.entries(p))a.set(`ref/resource/${d.uriTemplate}/${g}`,x);return u.client["notifications/resources/list_changed"]({})}),findResource:(p)=>Te(()=>{let f=e.find(p);if(!f)return Z({contents:[]});else if(f.handler._tag==="Resource")return f.handler.effect;let A=[];for(let d of Object.keys(f.params))A[Number(d)]=f.params[d];return f.handler.handle(p,A)}),get prompts(){return s},addPrompt:(p)=>Te(()=>{s.push(p.prompt),i.set(p.prompt.name,p.handle);for(let[f,A]of Object.entries(p.completions))a.set(`ref/prompt/${p.prompt.name}/${f}`,A);return u.client["notifications/prompts/list_changed"]({})}),getPromptResult:Ht(function*({arguments:p,name:f}){let A=i.get(f);if(!A)return yield*new yB({message:`Prompt '${f}' not found`});return yield*A(p??{})}),completion:Ht(function*(p){let f=p.ref,A=f.type==="ref/resource"?`ref/resource/${f.uri}/${p.argument.name}`:`ref/prompt/${f.name}/${p.argument.name}`,d=a.get(A);return d?yield*d(p.argument.value):IB.empty})})});static layer=Oc(Al,Al.make)}var L6e=Ht(function*(e){let t=yield*Al,r=yield*e,n=yield*vn();for(let o of Object.values(r.tools)){let s=new gF({name:o.name,description:o.description,inputSchema:q6e(o.parametersSchema.ast),annotations:new mF({...Jo(o.annotations,cJ).pipe(jt((i)=>({title:i})),pt),readOnlyHint:Ot(o.annotations,gy),destructiveHint:Ot(o.annotations,Ey),idempotentHint:Ot(o.annotations,lJ),openWorldHint:Ot(o.annotations,uJ)})});yield*t.addTool({tool:s,handle(i){return r.handle(o.name,i).pipe(Jn(n),Xk({onFailure:(a)=>new SB({isError:!0,structuredContent:typeof a==="object"?a:void 0,content:[{type:"text",text:JSON.stringify(a)}]}),onSuccess:(a)=>new SB({isError:!1,structuredContent:typeof a.encodedResult==="object"?a.encodedResult:void 0,content:[{type:"text",text:JSON.stringify(a.encodedResult)}]})}))}})}}),P6e=(e)=>r0(L6e(e)).pipe(no(Al.layer)),JCe=function(){if(arguments.length===1){let o=arguments[0];return _e(function*(){let s=yield*vn();yield*(yield*Al).addResource(new CB({...o,annotations:o}),o.content.pipe(Jn(s),z((a)=>zCe(o.uri,a)),rn((a)=>{let c=gk(a)[0];return new my({message:c.message})})))})}let{params:e,routerPath:t,schema:r,uriPath:n}=W6e(...arguments);return Ht(function*(o){let s=yield*vn(),i=yield*Al,a=is(r),c=new hF({...o,uriTemplate:n,annotations:o}),l={};for(let[u,p]of Object.entries(o.completion??{})){let f=hh(Re(e[u])),A=(d)=>p(d).pipe(w(f),z((g)=>new IB({completion:{values:g,total:g.length,hasMore:!1}})),rn((g)=>{let x=gk(g)[0];return new my({message:x.message})}),Jn(s));l[u]=A}yield*i.addResourceTemplate({template:c,routerPath:t,completions:l,handle:(u,p)=>a(p).pipe(De((f)=>new yB({message:f.message})),w((f)=>o.content(u,...f).pipe(z((A)=>zCe(u,A)),rn((A)=>{let d=gk(A)[0];return new my({message:d.message})}))),Jn(s))})})},jCe=function(){if(arguments.length===1)return r0(JCe(arguments[0])).pipe(no(Al.layer));let e=JCe(...arguments);return(t)=>r0(e(t)).pipe(no(Al.layer))};var H6e=()=>{let e=Xye({ignoreTrailingSlash:!0,ignoreDuplicateSlashes:!0,caseSensitive:!0});return{add:(n,o)=>{e.on("GET",n,o)},find:(n)=>e.find("GET",n)}},W6e=(e,...t)=>{let r=e[0].replace(":","::"),n=e[0],o={},s=oI();if(t.length>0){let i=[];for(let a=0;a<t.length;a++){let c=t[a],l=e[a+1],u=String(a);i.push(c),r+=`:${u}${l.replace(":","::")}`;let p=yn(qCe)(c.ast).pipe(je(()=>`param${u}`));o[p]=c,n+=`{${p}}${l}`}s=oI(...i)}return{routerPath:r,uriPath:n,schema:s,params:o}};var q6e=(e)=>{if(MS(e).length===0)return{type:"object",properties:{},required:[],additionalProperties:!1};let r={},n=nCe(e,{definitions:r,topLevelReferenceStrategy:"skip"});if(Object.keys(r).length===0)return n;return n.$defs=r,n},zCe=(e,t)=>{if(typeof t==="string")return{contents:[{uri:e,text:t}]};else if(t instanceof Uint8Array)return{contents:[{uri:e,blob:t}]};return t};var EF="~@effect/ai/AiError";class xF extends ot("@effect/ai/AiError/MalformedInput")("MalformedInput",{module:m,method:m,description:U(m),cause:U(bt)}){[EF]=EF}class BB extends ot("@effect/ai/AiError/MalformedOutput")("MalformedOutput",{module:m,method:m,description:U(m),cause:U(bt)}){[EF]=EF;static fromParseError({error:e,...t}){return new BB({...t,cause:e})}}var Y6e={...Pg,...Ws,of:X,toContext(e){return _e(this,function*(){let t=yield*vn(),r=tn(e)?yield*e:e,n=new Map;for(let[o,s]of Object.entries(r)){let i=this.tools[o];n.set(i.id,{handler:s,context:t})}return fp(n)})},toLayer(e){return RS(this.toContext(e))},commit(){return _e(this,function*(){let e=this.tools,t=yield*vn(),r=new WeakMap,n=(s)=>{let i=r.get(s);if(Wy(i)){let a=t.unsafeMap.get(s.id),c=is(s.parametersSchema),l=Ie(s.successSchema,s.failureSchema),u=Uee(l),p=hh(l);i={context:a.context,handler:a.handler,decodeParameters:c,validateResult:u,encodeResult:p},r.set(s,i)}return i},o=we("Toolkit.handle",{captureStackTrace:!1})(function*(s,i){yield*u6({tool:s,parameters:i});let a=e[s];if(Wy(a)){let A=Object.keys(e).join(",");return yield*new BB({module:"Toolkit",method:`${s}.handle`,description:`Failed to find tool with name '${s}' in toolkit - available tools: ${A}`})}let c=n(a),l=yield*De(c.decodeParameters(i),(A)=>new BB({module:"Toolkit",method:`${s}.handle`,description:`Failed to decode tool call parameters for tool '${s}' from:
|
|
183
|
+
`)});class M8e extends vc()("@expandai/cli/Install/ConfigIo",{dependencies:[Dh,hB],effect:_e(function*(){let e=yield*Cn,t=yield*Jr,r=we("ConfigIo.read")(function*(a,c){let l=yield*F8e(a).pipe(nn(Cn,e));return yield*P0(c)(l)}),n=we("ConfigIo.write")(function*(a,c,l){let u=yield*hh(l)(c);yield*wye(a,u).pipe(nn(Cn,e),nn(Jr,t))}),o=we("ConfigIo.exists")(function*(a){return yield*e.exists(a)}),s=we("ConfigIo.readText")(function*(a){return(yield*e.exists(a))?yield*e.readFileString(a):""}),i=we("ConfigIo.writeText")(function*(a,c){yield*wye(a,c).pipe(nn(Cn,e),nn(Jr,t))});return{read:r,write:n,exists:o,readText:s,writeText:i}})}){}class N8e extends vc()("@expandai/cli/Install/SkillIo",{dependencies:[Dh,hB],effect:_e(function*(){let e=yield*Cn,t=yield*Jr,r=yield*t.fromFileUrl(Bye),n=we("SkillIo.install")(function*(a){return yield*e.makeDirectory(t.dirname(a),{recursive:!0}),yield*e.copy(r,a,{overwrite:!0}),a}),o=we("SkillIo.uninstall")(function*(a){if(yield*e.exists(a))yield*e.remove(a,{recursive:!0});return a}),s=we("SkillIo.isCurrent")(function*(a){let c=t.join(a,"SKILL.md");if(!(yield*e.exists(c)))return!1;let[l,u]=yield*wc([e.readFileString(c),e.readFileString(t.join(r,"SKILL.md"))]);return l===u}),i=we("SkillIo.isInstalled")(function*(a){return yield*e.exists(t.join(a,"SKILL.md"))});return{install:n,uninstall:o,isCurrent:s,isInstalled:i}})}){}var mB="0.1.5";var Dye=Symbol.for("effect/PrimaryKey");var GV=Symbol.for("@effect/rpc/RpcSchema/Stream"),vye=(e)=>e.ast.annotations[th]===GV;var Oye=({failure:e,success:t})=>Object.assign(ni([t,e],{decode:(r,n)=>Tye(Lc(S2(r)),Lc(n)),encode:(r,n)=>Tye(Pc(S2(r)),Pc(n))},{schemaId:GV,[GV]:{success:t,failure:e}}),{success:t,failure:e}),U8e=(e)=>ee(e,B1),Tye=(e,t)=>(r,n,o)=>w(vn(),(s)=>{if(!U8e(r))return ce(new Fr(o,r));return Z(r.pipe(Cne((i)=>e(i,n)),Q1((i)=>{if(NE(i))return hne(i);return of(t(i,n),{onFailure:Mo,onSuccess:ce})}),jD(s)))});var Mye=Symbol.for("@effect/rpc/Rpc");var P8e={[Mye]:Mye,pipe(){return W(this,arguments)},setSuccess(e){return Ou({_tag:this._tag,payloadSchema:this.payloadSchema,successSchema:e,errorSchema:this.errorSchema,defectSchema:this.defectSchema,annotations:this.annotations,middlewares:this.middlewares})},setError(e){return Ou({_tag:this._tag,payloadSchema:this.payloadSchema,successSchema:this.successSchema,errorSchema:e,defectSchema:this.defectSchema,annotations:this.annotations,middlewares:this.middlewares})},setPayload(e){return Ou({_tag:this._tag,payloadSchema:On(e)?e:b(e),successSchema:this.successSchema,errorSchema:this.errorSchema,defectSchema:this.defectSchema,annotations:this.annotations,middlewares:this.middlewares})},middleware(e){return Ou({_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 Ou({_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 Ou({_tag:this._tag,payloadSchema:this.payloadSchema,successSchema:this.successSchema,errorSchema:this.errorSchema,defectSchema:this.defectSchema,middlewares:this.middlewares,annotations:dr(this.annotations,e,t)})},annotateContext(e){return Ou({_tag:this._tag,payloadSchema:this.payloadSchema,successSchema:this.successSchema,errorSchema:this.errorSchema,defectSchema:this.defectSchema,middlewares:this.middlewares,annotations:wr(this.annotations,e)})}},Ou=(e)=>{function t(){}return Object.setPrototypeOf(t,P8e),Object.assign(t,e),t.key=`@effect/rpc/Rpc/${e._tag}`,t},Wo=(e,t)=>{let r=t?.success??qE,n=t?.error??Af,o;if(t?.primaryKey)o=class extends Oe(`@effect/rpc/Rpc/${e}`)(t.payload){[Dye](){return t.primaryKey(this)}};else o=On(t?.payload)?t?.payload:t?.payload?b(t?.payload):qE;return Ou({_tag:e,payloadSchema:o,successSchema:t?.stream?Oye({success:r,failure:n}):r,errorSchema:t?.stream?Af:n,defectSchema:t?.defect??bt,annotations:Pr(),middlewares:new Set})},Nye=(e)=>Ou({_tag:e._tag,payloadSchema:e,successSchema:e.success,errorSchema:e.failure,defectSchema:bt,annotations:Pr(),middlewares:new Set});var H8e=Symbol.for("@effect/rpc/Rpc/Wrapper"),_ye=(e)=>(H8e in e);var W8e=BigInt(0),Pye=Ht(function*(e,t){let r=t?.spanPrefix??"RpcClient",n=t?.supportsAck??!0,o=t?.disableTracing??!1,s=t?.generateRequestId??(()=>W8e++),i=yield*vn(),a=Ot(i,iE),c=new Map,l=!1;yield*Qs(a,Te(()=>(l=!0,u(PZ(q8e)))));let u=Ht(function*(S){for(let[I,B]of c)if(c.delete(I),B._tag==="Mailbox")yield*B.mailbox.done(S);else B.resume(S)}),p=(S)=>{let I=vye(S.successSchema),B=d(S);return(R,Q)=>{let P=Q?.headers?Kn(Q.headers):oi,F=Q?.context??Pr();if(!I){let V=(G)=>f(S,B,G,S.payloadSchema.make?S.payloadSchema.make(R):R,P,F,Q?.discard??!1);return o?V(void 0):CE(`${r}.${S._tag}`,{captureStackTrace:!1,attributes:t.spanAttributes},V)}let D=A(S,B,S.payloadSchema.make?S.payloadSchema.make(R):R,P,Q?.streamBufferSize??16,F);if(Q?.asMailbox)return D;return Wc(z(D,vse))}},f=(S,I,B,R,Q,P,F)=>mr((D)=>{if(l)return es;let V=s(),G=I({_tag:"Request",id:V,tag:S._tag,payload:R,traceId:B?.traceId,spanId:B?.spanId,sampled:B?.sampled,headers:Ka(D.getFiberRef(Lye),Q)});if(F)return w(G,(v)=>t.onFromClient({message:v,context:P,discard:F}));let le=l0({context:D.currentContext,fiberRefs:D.getFiberRefs(),runtimeFlags:SE.runtimeFlags}),Be,Fe=!1;return Vk(Dt((v)=>{let O={_tag:"Effect",rpc:S,context:P,resume(H){if(Fe=!0,v(H),Be&&!Be.unsafePoll())D.currentScheduler.scheduleTask(()=>{Be.unsafeInterruptAsFork(D.id())},0,Be)}};c.set(V,O),Be=G.pipe(w((H)=>t.onFromClient({message:H,context:P,discard:F})),B?jd(B):X,rs(le)),Be.addObserver((H)=>{if(H._tag==="Failure")return v(H)})}),(v)=>{if(Fe)return Y;c.delete(V);let O=Array.from(v).flatMap((H)=>Array.from(jN(H)));return ve(Xo(Be),g(V,O,P))})}),A=Ht(function*(S,I,B,R,Q,P){if(l)return yield*es;let F=o?void 0:yield*p6(`${r}.${S._tag}`,{captureStackTrace:!1,attributes:t.spanAttributes}),D=HA(aP()),V=s(),G=Ro(D.currentContext,iE);yield*Ik(G,(Be)=>{if(!c.has(V))return Y;return c.delete(V),g(V,vo(Be)?Array.from(Ak(Be.cause)).flatMap((Fe)=>Array.from(jN(Fe))):[],P)});let le=yield*Df(Q);return c.set(V,{_tag:"Mailbox",rpc:S,mailbox:le,scope:G,context:P}),yield*I({_tag:"Request",id:V,tag:S._tag,traceId:F?.traceId,payload:B,spanId:F?.spanId,sampled:F?.sampled,headers:Ka(D.getFiberRef(Lye),R)}).pipe(w((Be)=>t.onFromClient({message:Be,context:P,discard:!1})),F?jd(F):X,rn((Be)=>le.failCause(Be)),gr,Xs(G)),le}),d=(S)=>{let I=[];for(let B of S.middlewares.values()){let R=i.unsafeMap.get(`${B.key}/Client`);if(!R)continue;I.push(R)}return I.length===0?Z:function(B){let R=0;return z(BS({while:()=>R<I.length,body:()=>I[R]({rpc:S,request:B}),step(Q){B=Q,R++}}),()=>B)}},g=(S,I,B)=>Dt((R)=>{let Q=HA(aP()),P=l0({context:Q.currentContext,fiberRefs:Q.getFiberRefs(),runtimeFlags:SE.runtimeFlags});t.onFromClient({message:{_tag:"Interrupt",requestId:S,interruptors:I},context:B,discard:!1}).pipe(nf(1000),rs(P)).addObserver(()=>{R(Y)})}),x=(S)=>{switch(S._tag){case"Chunk":{let I=S.requestId,B=c.get(I);if(!B||B._tag!=="Mailbox")return Y;return B.mailbox.offerAll(S.values).pipe(n?ve(t.onFromClient({message:{_tag:"Ack",requestId:S.requestId},context:B.context,discard:!1})):X,rn((R)=>B.mailbox.done(En(R))))}case"Exit":{let I=S.requestId,B=c.get(I);if(!B)return Y;if(c.delete(I),B._tag==="Effect")return B.resume(S.exit),Y;return B.mailbox.done(UZ(S.exit))}case"Defect":return u(Zg(S.defect));case"ClientEnd":return Y}},y;if(t.flatten){let S=new Map;y=function(B,R,Q){let P=S.get(B);if(!P)P=p(e.requests.get(B)),S.set(B,P);return P(R,Q)}}else{y={};for(let S of e.requests.values()){let I=S._tag.indexOf("."),B=I===-1?void 0:S._tag.slice(0,I);if(B!==void 0&&!(B in y))y[B]={};let R=B!==void 0?y[B]:y,Q=B!==void 0?S._tag.slice(I+1):S._tag;R[Q]=p(S)}}return{client:y,write:x}}),q8e=cg(-503,0);var Lye=Ae("@effect/rpc/RpcClient/currentHeaders",()=>Pi(oi));var Hye=/\+/g,Wye=function(){};Wye.prototype=Object.create(null);function qye(e){let t=new Wye;if(typeof e!=="string")return t;let r=e.length,n="",o="",s=-1,i=-1,a=!1,c=!1,l=!1,u=!1,p=!1,f=0;for(let A=0;A<r+1;A++)if(f=A!==r?e.charCodeAt(A):38,f===38){if(p=i>s,!p)i=A;if(n=e.slice(s+1,i),p||n.length>0){if(l)n=n.replace(Hye," ");if(a)try{n=decodeURIComponent(n)||n}catch{}if(p){if(o=e.slice(i+1,A),u)o=o.replace(Hye," ");if(c)try{o=decodeURIComponent(o)||o}catch{}}let d=t[n];if(d===void 0)t[n]=o;else if(d.pop)d.push(o);else t[n]=[d,o]}o="",s=A,i=A,a=!1,c=!1,l=!1,u=!1}else if(f===61)if(i<=s)i=A;else c=!0;else if(f===43)if(i>s)u=!0;else l=!0;else if(f===37)if(i>s)c=!0;else a=!0;return t}var V8e=/^https?:\/\/.*?\//,YV=/(\/:[^/()]*?)\?(\/?)/,Jye=(e={})=>new zye(e);class zye{constructor(e={}){this.options={ignoreTrailingSlash:!0,ignoreDuplicateSlashes:!0,caseSensitive:!1,maxParamLength:100,...e}}options;routes=[];trees={};on(e,t,r){let n=t.match(YV);if(n&&n.index!==void 0){J8e(t.length===n.index+n[0].length,"Optional Parameter needs to be the last parameter of the path");let s=t.replace(YV,"$1$2"),i=t.replace(YV,"$2");this.on(e,s,r),this.on(e,i,r);return}if(this.options.ignoreDuplicateSlashes)t=Gye(t);if(this.options.ignoreTrailingSlash)t=Yye(t);let o=typeof e==="string"?[e]:e;for(let s of o)this._on(s,t,r)}all(e,t){this.on(X8e,e,t)}_on(e,t,r){if(this.trees[e]===void 0)this.trees[e]=new gB("/");let n=t;if(n==="*"&&this.trees[e].prefix.length!==0){let c=this.trees[e];this.trees[e]=new gB(""),this.trees[e].staticChildren["/"]=c}let o=this.trees[e].prefix.length,s=this.trees[e],i=[];for(let c=0;c<=n.length;c++){if(n.charCodeAt(c)===58&&n.charCodeAt(c+1)===58){c++;continue}let l=n.charCodeAt(c)===58&&n.charCodeAt(c+1)!==58,u=n.charCodeAt(c)===42;if(l||u||c===n.length&&c!==o){let p=n.slice(o,c);if(!this.options.caseSensitive)p=p.toLowerCase();p=p.split("::").join(":"),p=p.split("%").join("%25"),s=s.createStaticChild(p)}if(l){let p=!1,f=[],A=c+1;for(let d=A;;d++){let g=n.charCodeAt(d),x=g===40,y=g===45||g===46,S=g===47||d===n.length;if(x||y||S){let I=n.slice(A,d);if(i.push(I),p=p||x||y,x){let Q=j8e(n,d),P=n.slice(d,Q+1);f.push($8e(P)),d=Q+1}else f.push("(.*?)");let B=d;for(;d<n.length;d++){let Q=n.charCodeAt(d);if(Q===47)break;if(Q===58)if(n.charCodeAt(d+1)===58)d++;else break}let R=n.slice(B,d);if(R)R=R.split("::").join(":"),R=R.split("%").join("%25"),f.push(K8e(R));if(A=d+1,S||n.charCodeAt(d)===47||d===n.length){let Q=p?"()"+R:R,P=n.slice(c,d);n=n.slice(0,c+1)+Q+n.slice(d),c+=Q.length;let F=p?new RegExp("^"+f.join("")+"$"):void 0;s=s.createParametricChild(F,R,P),o=c+1;break}}}}else if(u){if(i.push("*"),s=s.createWildcardChild(),o=c+1,c!==n.length-1)throw Error("Wildcard must be the last character in the route")}}if(!this.options.caseSensitive)n=n.toLowerCase();if(n==="*")n="/*";for(let c of this.routes)if(c.method===e&&c.pattern===n)throw Error(`Method '${e}' already declared for route '${n}'`);let a={method:e,path:t,pattern:n,params:i,handler:r};this.routes.push(a),s.addRoute(a)}has(e,t){let r=this.trees[e];if(r===void 0)return!1;let n=r.getStaticChild(t);if(n===void 0)return!1;return n.isLeafNode}find(e,t){let r=this.trees[e];if(r===void 0)return;if(t.charCodeAt(0)!==47)t=t.replace(V8e,"/");if(this.options.ignoreDuplicateSlashes)t=Gye(t);let n,o,s;try{n=Z8e(t),t=n.path,o=n.querystring,s=n.shouldDecodeParam}catch(f){return}if(this.options.ignoreTrailingSlash)t=Yye(t);let i=t;if(this.options.caseSensitive===!1)t=t.toLowerCase();let a=this.options.maxParamLength,c=r.prefix.length,l=[],u=t.length,p=[];while(!0){if(c===u&&r.isLeafNode){let A=r.handlerStorage?.find();if(A!==void 0)return{handler:A.handler,params:A.createParams(l),searchParams:qye(o)}}let f=r.getNextNode(t,c,p,l.length);if(f===void 0){if(p.length===0)return;let A=p.pop();c=A.brotherPathIndex,l.splice(A.paramsCount),f=A.brotherNode}if(r=f,r._tag==="StaticNode"){c+=r.prefix.length;continue}if(r._tag==="WildcardNode"){let A=i.slice(c);if(s)A=Vye(A);l.push(A),c=u;continue}if(r._tag==="ParametricNode"){let A=i.indexOf("/",c);if(A===-1)A=u;let d=i.slice(c,A);if(s)d=Vye(d);if(r.regex!==void 0){let g=r.regex.exec(d);if(g===null)continue;for(let x=1;x<g.length;x++){let y=g[x];if(y.length>a)return;l.push(y)}}else{if(d.length>a)return;l.push(d)}c=A}}}}class jye{handlers=[];unconstrainedHandler;find(){return this.unconstrainedHandler}add(e){let t={params:e.params,handler:e.handler,createParams:z8e(e.params)};this.handlers.push(t),this.unconstrainedHandler=this.handlers[0]}}class VV{isLeafNode=!1;routes;handlerStorage;addRoute(e){if(this.routes===void 0)this.routes=[e];else this.routes.push(e);if(this.handlerStorage===void 0)this.handlerStorage=new jye;this.isLeafNode=!0,this.handlerStorage.add(e)}}class JV extends VV{staticChildren={};findStaticMatchingChild(e,t){let r=this.staticChildren[e.charAt(t)];if(r===void 0||!r.matchPrefix(e,t))return;return r}getStaticChild(e,t=0){if(e.length===t)return this;let r=this.findStaticMatchingChild(e,t);if(r===void 0)return;return r.getStaticChild(e,t+r.prefix.length)}createStaticChild(e){if(e.length===0)return this;let t=this.staticChildren[e.charAt(0)];if(t){let n=1;for(;n<t.prefix.length;n++)if(e.charCodeAt(n)!==t.prefix.charCodeAt(n)){t=t.split(this,n);break}return t.createStaticChild(e.slice(n))}let r=e.charAt(0);return this.staticChildren[r]=new gB(e),this.staticChildren[r]}}class gB extends JV{_tag="StaticNode";constructor(e){super();this.setPrefix(e)}prefix;matchPrefix;parametricChildren=[];wildcardChild;setPrefix(e){if(this.prefix=e,e.length===1)this.matchPrefix=(t,r)=>!0;else{let t=e.length;this.matchPrefix=function(r,n){for(let o=1;o<t;o++)if(r.charCodeAt(n+o)!==this.prefix.charCodeAt(o))return!1;return!0}}}getParametricChild(e){if(e===void 0)return this.parametricChildren.find((r)=>r.isRegex===!1);let t=e.source;return this.parametricChildren.find((r)=>{if(r.regex===void 0)return!1;return r.regex.source===t})}createParametricChild(e,t,r){let n=this.getParametricChild(e);if(n!==void 0)return n.nodePaths.add(r),n;return n=new $ye(e,t,r),this.parametricChildren.push(n),this.parametricChildren.sort((o,s)=>{if(!o.isRegex)return 1;if(!s.isRegex)return-1;if(o.staticSuffix===void 0)return 1;if(s.staticSuffix===void 0)return-1;if(s.staticSuffix.endsWith(o.staticSuffix))return 1;if(o.staticSuffix.endsWith(s.staticSuffix))return-1;return 0}),n}createWildcardChild(){if(this.wildcardChild===void 0)this.wildcardChild=new Kye;return this.wildcardChild}split(e,t){let r=this.prefix.slice(0,t),n=this.prefix.slice(t);this.setPrefix(n);let o=new gB(r);return o.staticChildren[n.charAt(0)]=this,e.staticChildren[r.charAt(0)]=o,o}getNextNode(e,t,r,n){let o=this.findStaticMatchingChild(e,t),s=0;if(o===void 0){if(this.parametricChildren.length===0)return this.wildcardChild;o=this.parametricChildren[0],s=1}if(this.wildcardChild!==void 0)r.push({paramsCount:n,brotherPathIndex:t,brotherNode:this.wildcardChild});for(let i=this.parametricChildren.length-1;i>=s;i--)r.push({paramsCount:n,brotherPathIndex:t,brotherNode:this.parametricChildren[i]});return o}}class $ye extends JV{regex;staticSuffix;_tag="ParametricNode";constructor(e,t,r){super();this.regex=e,this.staticSuffix=t,this.isRegex=!!e,this.nodePaths=new Set([r])}isRegex;nodePaths;getNextNode(e,t){return this.findStaticMatchingChild(e,t)}}class Kye extends VV{_tag="WildcardNode";getNextNode(e,t,r,n){return}}var J8e=(e,t)=>{if(!e)throw Error(t)};function Gye(e){return e.replace(/\/\/+/g,"/")}function Yye(e){if(e.length>1&&e.charCodeAt(e.length-1)===47)return e.slice(0,-1);return e}function z8e(e){let t=e.length;return function(r){let n={};for(let o=0;o<t;o++)n[e[o]]=r[o];return n}}function j8e(e,t){let r=1;while(t<e.length){if(t++,e[t]==="\\"){t++;continue}if(e[t]===")")r--;else if(e[t]==="(")r++;if(!r)return t}throw TypeError('Invalid regexp expression in "'+e+'"')}function $8e(e){if(e.charCodeAt(1)===94)e=e.slice(0,1)+e.slice(2);if(e.charCodeAt(e.length-2)===36)e=e.slice(0,e.length-2)+e.slice(e.length-1);return e}function K8e(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Zye(e,t){if(e===50){if(t===53)return"%";if(t===51)return"#";if(t===52)return"$";if(t===54)return"&";if(t===66)return"+";if(t===98)return"+";if(t===67)return",";if(t===99)return",";if(t===70)return"/";if(t===102)return"/";return}if(e===51){if(t===65)return":";if(t===97)return":";if(t===66)return";";if(t===98)return";";if(t===68)return"=";if(t===100)return"=";if(t===70)return"?";if(t===102)return"?";return}if(e===52&&t===48)return"@";return}function Z8e(e){let t=!1,r=!1,n="";for(let s=1;s<e.length;s++){let i=e.charCodeAt(s);if(i===37){let a=e.charCodeAt(s+1),c=e.charCodeAt(s+2);if(Zye(a,c)===void 0)t=!0;else{if(r=!0,a===50&&c===53)t=!0,e=e.slice(0,s+1)+"25"+e.slice(s+1),s+=2;s+=2}}else if(i===63||i===59||i===35){n=e.slice(s+1),e=e.slice(0,s);break}}return{path:t?decodeURI(e):e,querystring:n,shouldDecodeParam:r}}function Vye(e){let t=e.indexOf("%");if(t===-1)return e;let r="",n=t;for(let o=t;o<e.length;o++)if(e.charCodeAt(o)===37){let s=e.charCodeAt(o+1),i=e.charCodeAt(o+2),a=Zye(s,i);r+=e.slice(n,o)+a,n=o+3}return e.slice(0,t)+r+e.slice(n)}var X8e=["ACL","BIND","CHECKOUT","CONNECT","COPY","DELETE","GET","HEAD","LINK","LOCK","M-SEARCH","MERGE","MKACTIVITY","MKCALENDAR","MKCOL","MOVE","NOTIFY","OPTIONS","PATCH","POST","PROPFIND","PROPPATCH","PURGE","PUT","REBIND","REPORT","SEARCH","SOURCE","SUBSCRIBE","TRACE","UNBIND","UNLINK","UNLOCK","UNSUBSCRIBE"];var Xye=Jye;var nCe=(e,t)=>{let r=t.definitionPath??"#/$defs/",n=(a)=>r+a,o=t.target??"jsonSchema7",s=t.topLevelReferenceStrategy??"keep",i=t.additionalPropertiesStrategy??"strict";return In(e,t.definitions,"handle-identifier",[],{getRef:n,target:o,topLevelReferenceStrategy:s,additionalPropertiesStrategy:i},"handle-annotation","handle-errors")},EB={$id:"/schemas/never",not:{}},bm={$id:"/schemas/any"},oCe={$id:"/schemas/unknown"},sCe={$id:"/schemas/void"},r6e={$id:"/schemas/object",anyOf:[{type:"object"},{type:"array"}]},n6e={$id:"/schemas/%7B%7D",anyOf:[{type:"object"},{type:"array"}]};function iCe(e){if(e!==void 0)return pt(cf(e))}function aCe(e){if(e!==void 0)return pt(PS(e))}function cCe(e){if(e!==void 0)return D7(e);return T()}function o6e(e,t){return O0(e,!1)(t)}function lCe(e){if(e!==void 0)return pt(k7(e))}function s6e(e,t){let r=O0(e,!1),n=rp(t,(o)=>r(o).pipe(qs(AF)));return n.length>0?n:void 0}function eCe(e,t,r){if(t!==void 0)switch(e._tag){case"StringKeyword":return t!==QE.annotations[r]?t:void 0;case"NumberKeyword":return t!==wE.annotations[r]?t:void 0;case"BooleanKeyword":return t!==RE.annotations[r]?t:void 0}return t}function AF(e,t=new Set){if(e===null||typeof e==="string"||typeof e==="number"||typeof e==="boolean")return!0;if(Array.isArray(e)||typeof e==="object"){if(t.has(e))return!1;t.add(e);try{if(Array.isArray(e))return e.every((n)=>AF(n,t));let r=Object.getPrototypeOf(e);if(r!==null&&r!==Object.prototype)return!1;if(Object.getOwnPropertySymbols(e).length>0)return!1;return Object.values(e).every((n)=>AF(n,t))}finally{t.delete(e)}}return!1}function uCe(e,t,r,n,o){let s={};if(t!==void 0)s.description=t;if(r!==void 0)s.title=r;if(de(n)){let i=o6e(e,n.value);if(de(i)&&AF(i.value))s.default=i.value}if(o!==void 0){let i=s6e(e,o);if(i!==void 0)s.examples=i}if(Object.keys(s).length===0)return;return s}function zV(e,t){return uCe(e,iCe(t),aCe(t),cCe(t),lCe(t))}function pCe(e){return uCe(e,eCe(e,iCe(e),Wi),eCe(e,aCe(e),Eo),cCe(e),lCe(e))}function jV(e,t){if(t){if("$ref"in e)return{allOf:[e],...t};return{...e,...t}}return e}var dF=(e)=>{if($e(MH(e)))return zH(e,dF,(t)=>dF(t.from))},i6e=(e)=>e.annotations[th]===y0,a6e=(e,t)=>{if(Uc(e)){if(e.annotations[th]===d0)return"type"in t&&t.type!=="integer"}return"type"in t||"oneOf"in t||"anyOf"in t||"$ref"in t},c6e=(e,t,r)=>{let n={...e,...pCe(r),...t};n.allOf??=[];let o=(s,i)=>{if(s in t&&s in e)n.allOf.unshift({[s]:e[s]}),n.allOf=n.allOf.filter(i)};if(o("minLength",(s)=>s.minLength>t.minLength),o("maxLength",(s)=>s.maxLength<t.maxLength),o("pattern",(s)=>s.pattern!==t.pattern),o("minItems",(s)=>s.minItems>t.minItems),o("maxItems",(s)=>s.maxItems<t.maxItems),o("minimum",(s)=>s.minimum>t.minimum),o("maximum",(s)=>s.maximum<t.maximum),o("exclusiveMinimum",(s)=>s.exclusiveMinimum>t.exclusiveMinimum),o("exclusiveMaximum",(s)=>s.exclusiveMaximum<t.exclusiveMaximum),o("multipleOf",(s)=>s.multipleOf!==t.multipleOf),n.allOf.length===0)delete n.allOf;return n};function l6e(e){switch(e.target){case"jsonSchema7":return!1;case"jsonSchema2019-09":case"jsonSchema2020-12":case"openApi3.1":return!0}}function u6e(e){switch(e.additionalPropertiesStrategy){case"allow":return!0;case"strict":return!1}}function cr(e,t){return fCe(e,pCe(t))}function fCe(e,t){if(t===void 0||Object.keys(t).length===0)return e;if("$ref"in e)return{allOf:[e],...t};return{...e,...t}}function $V(e){let t=pt(_H(e));if(t===void 0){if(WH(e))return $V(e.f());if(w0(e)&&qS(e.from)&&N7(e.to)){let r=e.to,n=Zl(r);if(de(n))return $V(r)}}return t}function In(e,t,r,n,o,s,i){if(r==="handle-identifier"&&(o.topLevelReferenceStrategy!=="skip"||WH(e))){let c=$V(e);if(c!==void 0){let l=c.replace(/~/ig,"~0").replace(/\//ig,"~1"),u={$ref:o.getRef(l)};if(!nN(t,c))t[c]=u,t[c]=In(e,t,"ignore-identifier",n,o,"handle-annotation",i);return u}}if(s==="handle-annotation"){let c=MH(e);if(de(c)){let l=c.value;if(a6e(e,l))switch(e._tag){case"Declaration":return cr(l,e);default:return l}else switch(e._tag){case"Refinement":{let u=NS(e);if(u===void 0)return c6e(In(e.from,t,r,n,o,"handle-annotation",i),l,e);else return In(u,t,r,n,o,"handle-annotation",i)}default:return{...In(e,t,r,n,o,"ignore-annotation",i),...l}}}}let a=Zl(e);if(de(a))return In(a.value,t,r,n,o,"handle-annotation",i);switch(e._tag){case"Declaration":case"UndefinedKeyword":case"BigIntKeyword":case"UniqueSymbol":case"SymbolKeyword":{if(i==="ignore-errors")return cr(bm,e);throw Error(mH(n,e))}case"Suspend":{if(r==="handle-identifier"){if(i==="ignore-errors")return cr(bm,e);throw Error(c7(n,e))}return In(e.f(),t,"ignore-identifier",n,o,"handle-annotation",i)}case"NeverKeyword":return cr(EB,e);case"VoidKeyword":return cr(sCe,e);case"UnknownKeyword":return cr(oCe,e);case"AnyKeyword":return cr(bm,e);case"ObjectKeyword":return cr(r6e,e);case"StringKeyword":return cr({type:"string"},e);case"NumberKeyword":return cr({type:"number"},e);case"BooleanKeyword":return cr({type:"boolean"},e);case"Literal":{let c=e.literal;if(c===null)return cr({type:"null"},e);else if(Gt(c))return cr({type:"string",enum:[c]},e);else if(eo(c))return cr({type:"number",enum:[c]},e);else if(Ps(c))return cr({type:"boolean",enum:[c]},e);if(i==="ignore-errors")return cr(bm,e);throw Error(mH(n,e))}case"Enums":{let c=e.enums.map((l)=>({type:eo(l[1])?"number":"string",title:l[0],enum:[l[1]]}));return c.length>=1?cr({$comment:"/schemas/enums",anyOf:c},e):cr(EB,e)}case"TupleType":{let c=e.elements.map((A,d)=>jV(In(A.type,t,"handle-identifier",n.concat(d),o,"handle-annotation",i),zV(A.type,A))),l=e.rest.map((A)=>jV(In(A.type,t,"handle-identifier",n,o,"handle-annotation",i),zV(A.type,A))),u={type:"array"},p=e.elements.length;if(p>0)if(u.minItems=p-e.elements.filter((A)=>A.isOptional).length,o.target==="jsonSchema7")u.items=c;else u.prefixItems=c;let f=l.length;if(f>0){let A=l[0];if(f===1&&e.elements.every((g)=>g.type===e.rest[0].type))if(o.target==="jsonSchema7")u.items=A;else u.items=A,delete u.prefixItems;else if(o.target==="jsonSchema7")u.additionalItems=A;else u.items=A;if(f>1){if(i==="ignore-errors")return cr(bm,e);throw Error(l7(n))}}else if(p>0)if(o.target==="jsonSchema7")u.additionalItems=!1;else u.items=!1;else u.maxItems=0;return cr(u,e)}case"TypeLiteral":{if(e.propertySignatures.length===0&&e.indexSignatures.length===0)return cr(n6e,e);let c={type:"object",required:[],properties:{},additionalProperties:u6e(o)},l=void 0,u=void 0;for(let p of e.indexSignatures){let f=dF(p.type)??p.type,A=p.parameter;switch(A._tag){case"StringKeyword":{c.additionalProperties=In(f,t,"handle-identifier",n,o,"handle-annotation",i);break}case"TemplateLiteral":{l=In(f,t,"handle-identifier",n,o,"handle-annotation",i),u={type:"string",pattern:vE(A).source};break}case"Refinement":{l=In(f,t,"handle-identifier",n,o,"handle-annotation",i),u=In(A,t,"handle-identifier",n,o,"handle-annotation",i);break}case"SymbolKeyword":{let d=n.concat("[symbol]");c.additionalProperties=In(f,t,"handle-identifier",d,o,"handle-annotation",i),u=In(A,t,"handle-identifier",d,o,"handle-annotation",i);break}}}for(let p=0;p<e.propertySignatures.length;p++){let f=e.propertySignatures[p],A=f.name;if(Gt(A)){let d=dF(f.type),g=d??f.type;if(c.properties[A]=jV(In(g,t,"handle-identifier",n.concat(f.name),o,"handle-annotation",i),zV(g,f)),!f.isOptional&&d===void 0)c.required.push(A)}else{if(i==="ignore-errors")return cr(bm,e);throw Error(u7(A,n))}}if(l!==void 0)delete c.additionalProperties,c.patternProperties={"":l};if(u!==void 0)c.propertyNames=u;return cr(c,e)}case"Union":{let c=e.types.map((u)=>In(u,t,"handle-identifier",n,o,"handle-annotation",i)),l=h6e(c);switch(l.length){case 0:return EB;case 1:return cr(l[0],e);default:return cr({anyOf:l},e)}}case"Refinement":return In(e.from,t,r,n,o,"handle-annotation",i);case"TemplateLiteral":{let c=vE(e);return cr({type:"string",title:String(e),description:"a template literal",pattern:c.source},e)}case"Transformation":{if(i6e(e.from)){let l={type:"string",contentMediaType:"application/json"};if(l6e(o))l.contentSchema=In(e.to,t,r,n,o,"handle-annotation",i);return l}let c=In(e.from,t,r,n,o,"handle-annotation",i);if(e.transformation._tag==="TypeLiteralTransformation"&&tCe(c)){let l=In(e.to,{},"ignore-identifier",n,o,"handle-annotation","ignore-errors");if(tCe(l))for(let u of e.transformation.propertySignatureTransformations){let{to:p,from:f}=u;if(Gt(p)&&Gt(f)){let A=l.properties[p];if(zu(A)){let d=c.properties[f];if(zu(d)){let g={};if(Gt(A.title))g.title=A.title;if(Gt(A.description))g.description=A.description;if(Array.isArray(A.examples))g.examples=A.examples;if(Object.hasOwn(A,"default")&&A.default!==void 0)g.default=A.default;c.properties[f]=fCe(d,g)}}}}}return cr(c,e)}}}function tCe(e){return zu(e)&&e.type==="object"&&zu(e.properties)}function p6e(e){return e===EB||ee(e,"$id")&&e.$id===EB.$id&&Object.keys(e).length===3&&e.title===sh.annotations[Eo]}function f6e(e){return"$id"in e&&e.$id===bm.$id}function A6e(e){return"$id"in e&&e.$id===oCe.$id}function d6e(e){return"$id"in e&&e.$id===sCe.$id}function rCe(e){return ee(e,"enum")&&"type"in e&&Object.keys(e).length===2}function h6e(e){let t=[];for(let r of e){if(p6e(r))continue;if(f6e(r)||A6e(r)||d6e(r))return[r];if(rCe(r)&&t.length>0){let n=t[t.length-1];if(rCe(n)&&n.type===r.type){t[t.length-1]={type:n.type,enum:[...n.enum,...r.enum]};continue}}t.push(r)}return t}var g6e={add(...e){return dA({requests:ACe(...this.requests.values(),...e),annotations:this.annotations})},merge(...e){let t=new Map(this.requests),r=new Map(this.annotations.unsafeMap);for(let n of e){for(let[o,s]of n.requests)t.set(o,s);for(let[o,s]of n.annotations.unsafeMap)r.set(o,s)}return dA({requests:t,annotations:fp(r)})},middleware(e){let t=new Map;for(let[r,n]of this.requests)t.set(r,n.middleware(e));return dA({requests:t,annotations:this.annotations})},toHandlersContext(e){return _e(this,function*(){let t=yield*vn(),r=tn(e)?yield*e:e,n=new Map;for(let[o,s]of Object.entries(r)){let i=this.requests.get(o);n.set(i.key,{handler:s,context:t})}return fp(n)})},prefix(e){let t=new Map;for(let r of this.requests.values()){let n=r.prefix(e);t.set(n._tag,n)}return dA({requests:t,annotations:this.annotations})},toLayer(e){return RS(this.toHandlersContext(e))},of:X,toLayerHandler(e,t){return RS(_e(this,function*(){let r=yield*vn(),n=tn(t)?yield*t:t,o=new Map,s=this.requests.get(e);return o.set(s.key,{handler:n,context:r}),fp(o)}))},accessHandler(e){return qP((t)=>{let r=this.requests.get(e),{context:n,handler:o}=t.unsafeMap.get(r.key);return(s,i)=>{let a=o(s,i),c=_ye(a)?a.value:a;return tn(c)?Jn(c,n):jD(c,n)}})},annotate(e,t){return dA({requests:this.requests,annotations:dr(this.annotations,e,t)})},annotateRpcs(e,t){return this.annotateRpcsContext(wl(e,t))},annotateContext(e){return dA({requests:this.requests,annotations:wr(this.annotations,e)})},annotateRpcsContext(e){let t=new Map;for(let[r,n]of this.requests)t.set(r,n.annotateContext(wr(e,n.annotations)));return dA({requests:t,annotations:this.annotations})}},dA=(e)=>Object.assign(function(){},g6e,{requests:e.requests,annotations:e.annotations}),ACe=(...e)=>{let t=new Map;for(let r of e)t.set(r._tag,On(r)?Nye(r):r);return t},dCe=(...e)=>dA({requests:ACe(...e),annotations:Pr()});var x6e=Ie(m,re),hCe=Ie(m,re);class Fu extends b({_meta:U(b({progressToken:U(hCe)}))}){}class hA extends b({_meta:U(Fn({key:m,value:Tt}))}){}class mA extends b({_meta:U(Fn({key:m,value:Tt}))}){}var mCe=m;class y6e extends b({...Fu.fields,cursor:U(mCe)}){}class xB extends b({...hA.fields,nextCursor:U(mCe)}){}var gCe=_("user","assistant");class Bm extends b({audience:U(Re(gCe)),priority:U(re.pipe(q0(0,1)))}){}class KV extends b({name:m,title:U(m),version:m}){}class ECe extends Oe("@effect/ai/McpSchema/ClientCapabilities")({experimental:U(Fn({key:m,value:b({})})),roots:U(b({listChanged:U(ae)})),sampling:U(b({})),elicitation:U(b({}))}){}class xCe extends b({experimental:U(Fn({key:m,value:b({})})),logging:U(b({})),completions:U(b({})),prompts:U(b({listChanged:U(ae)})),resources:U(b({subscribe:U(ae),listChanged:U(ae)})),tools:U(b({listChanged:U(ae)}))}){}class Us extends Oe("@effect/ai/McpSchema/McpError")({code:re,message:m,data:U(Tt)}){}var C6e=-32600,S6e=-32601,I6e=-32602,b6e=-32603,B6e=-32700;class Q6e extends ot()("ParseError",{...Us.fields,code:Yi(B6e)}){}class w6e extends ot()("InvalidRequest",{...Us.fields,code:Yi(C6e)}){}class R6e extends ot()("MethodNotFound",{...Us.fields,code:Yi(S6e)}){}class yB extends ot()("InvalidParams",{...Us.fields,code:Yi(I6e)}){}class my extends ot()("InternalError",{...Us.fields,code:Yi(b6e)}){static notImplemented=new my({message:"Not implemented"})}class yCe extends Oe("@effect/ai/McpSchema/InitializeResult")({...hA.fields,protocolVersion:m,capabilities:xCe,serverInfo:KV,instructions:U(m)}){}class k6e extends Wo("initialize",{success:yCe,error:Us,payload:{...Fu.fields,protocolVersion:m,capabilities:ECe,clientInfo:KV}}){}class CCe extends Wo("notifications/cancelled",{payload:{...mA.fields,requestId:x6e,reason:U(m)}}){}class SCe extends Wo("notifications/progress",{payload:{...mA.fields,progressToken:hCe,progress:U(re),total:U(re),message:U(m)}}){}class CB extends Oe("@effect/ai/McpSchema/Resource")({uri:m,name:m,title:U(m),description:U(m),mimeType:U(m),annotations:U(Bm),size:U(re)}){}class hF extends Oe("@effect/ai/McpSchema/ResourceTemplate")({uriTemplate:m,name:m,title:U(m),description:U(m),mimeType:U(m),annotations:U(Bm)}){}class ZV extends b({uri:m,mimeType:U(m)}){}class XV extends b({...ZV.fields,text:m}){}class eJ extends b({...ZV.fields,blob:V0}){}class ICe extends Oe("@effect/ai/McpSchema/ListResourcesResult")({...xB.fields,resources:Re(CB)}){}class bCe extends Oe("@effect/ai/McpSchema/ListResourceTemplatesResult")({...xB.fields,resourceTemplates:Re(hF)}){}class BCe extends b({...hA.fields,contents:Re(Ie(XV,eJ))}){}class D6e extends Wo("resources/read",{success:BCe,error:Us,payload:{...Fu.fields,uri:m}}){}class QCe extends Wo("notifications/resources/list_changed",{payload:nu(mA)}){}class T6e extends Wo("resources/subscribe",{error:Us,payload:{...Fu.fields,uri:m}}){}class v6e extends Wo("resources/unsubscribe",{error:Us,payload:{...Fu.fields,uri:m}}){}class wCe extends Wo("notifications/resources/updated",{payload:{...mA.fields,uri:m}}){}class RCe extends b({name:m,title:U(m),description:U(m),required:U(ae)}){}class tJ extends Oe("@effect/ai/McpSchema/Prompt")({name:m,title:U(m),description:U(m),arguments:U(Re(RCe))}){}class rJ extends b({type:Yi("text"),text:m,annotations:U(Bm)}){}class kCe extends b({type:Yi("image"),data:V0,mimeType:m,annotations:U(Bm)}){}class DCe extends b({type:Yi("audio"),data:V0,mimeType:m,annotations:U(Bm)}){}class TCe extends b({type:Yi("resource"),resource:Ie(XV,eJ),annotations:U(Bm)}){}class vCe extends b({...CB.fields,type:Yi("resource_link")}){}class nJ extends Ie(rJ,kCe,DCe,TCe,vCe){}class OCe extends b({role:gCe,content:nJ}){}class FCe extends Oe("@effect/ai/McpSchema/ListPromptsResult")({...xB.fields,prompts:Re(tJ)}){}class oJ extends Oe("@effect/ai/McpSchema/GetPromptResult")({...hA.fields,messages:Re(OCe),description:U(m)}){}class O6e extends Wo("prompts/get",{success:oJ,error:Us,payload:{...Fu.fields,name:m,title:U(m),arguments:U(Fn({key:m,value:m}))}}){}class MCe extends Wo("notifications/prompts/list_changed",{payload:nu(mA)}){}class mF extends Oe("@effect/ai/McpSchema/ToolAnnotations")({title:U(m),readOnlyHint:C(ae,{default:()=>!1}),destructiveHint:C(ae,{default:()=>!0}),idempotentHint:C(ae,{default:()=>!1}),openWorldHint:C(ae,{default:()=>!0})}){}class gF extends Oe("@effect/ai/McpSchema/Tool")({name:m,title:U(m),description:U(m),inputSchema:Tt,annotations:U(mF)}){}class NCe extends Oe("@effect/ai/McpSchema/ListToolsResult")({...xB.fields,tools:Re(gF)}){}class SB extends Oe("@effect/ai/McpSchema/CallToolResult")({...hA.fields,content:Re(nJ),structuredContent:U(Tt),isError:U(ae)}){}class F6e extends Wo("tools/call",{success:SB,error:Us,payload:{...Fu.fields,name:m,arguments:Fn({key:m,value:Tt})}}){}class _Ce extends Wo("notifications/tools/list_changed",{payload:nu(mA)}){}var UCe=_("debug","info","notice","warning","error","critical","alert","emergency");class M6e extends Wo("logging/setLevel",{payload:{...Fu.fields,level:UCe},error:Us}){}class LCe extends Wo("notifications/message",{payload:b({...mA.fields,level:UCe,logger:U(m),data:Tt})}){}class IB extends Oe("@effect/ai/McpSchema/CompleteResult")({completion:b({values:Re(m),total:U(re),hasMore:U(ae)})}){static empty=IB.make({completion:{values:[],total:0,hasMore:!1}})}class PCe extends Oe("@effect/ai/McpSchema/ElicitAcceptResult")({...hA.fields,action:_("accept"),content:Tt}){}class HCe extends Oe("@effect/ai/McpSchema/ElicitDeclineResult")({...hA.fields,action:_("cancel","decline")}){}var N6e=Ie(PCe,HCe);class sJ extends Wo("elicitation/create",{success:N6e,error:Us,payload:{message:m,requestedSchema:Tt}}){}class WCe extends ot("@effect/ai/McpSchema/ElicitationDeclined")("ElicitationDeclined",{request:sJ.payloadSchema,cause:U(bt)}){}class iJ extends dCe(CCe,SCe,LCe,wCe,QCe,_Ce,MCe){}var qCe=Symbol.for("@effect/ai/McpSchema/ParamNameId");var _6e="~@effect/ai/Tool",GCe="~@effect/ai/Tool/ProviderDefined";var YCe={[_6e]:{_Requirements:X},pipe(){return W(this,arguments)},addDependency(){return gA({...this})},setParameters(e){return gA({...this,parametersSchema:On(e)?e:b(e)})},setSuccess(e){return gA({...this,successSchema:e})},setFailure(e){return gA({...this,failureSchema:e})},annotate(e,t){return gA({...this,annotations:dr(this.annotations,e,t)})},annotateContext(e){return gA({...this,annotations:wr(this.annotations,e)})}},SLt={...YCe,[GCe]:GCe},gA=(e)=>{let t=Object.assign(Object.create(YCe),e);return t.id=`@effect/ai/Tool/${e.name}`,t};var U6e=b({}),aJ=(e,t)=>{let r=t?.success??qE,n=t?.failure??Af;return gA({name:e,description:t?.description,parametersSchema:t?.parameters?b(t?.parameters):U6e,successSchema:r,failureSchema:n,failureMode:t?.failureMode??"error",annotations:Pr()})};var VCe=(e)=>gA({name:e._tag,description:pt(cf(e.ast.to)),parametersSchema:e,successSchema:e.success,failureSchema:e.failure,failureMode:"error",annotations:Pr()});class cJ extends wi("@effect/ai/Tool/Title")(){}class gy extends hr()("@effect/ai/Tool/Readonly",{defaultValue:tr}){}class Ey extends hr()("@effect/ai/Tool/Destructive",{defaultValue:Io}){}class lJ extends hr()("@effect/ai/Tool/Idempotent",{defaultValue:tr}){}class uJ extends hr()("@effect/ai/Tool/OpenWorld",{defaultValue:Io}){}class Al extends wi("@effect/ai/McpServer")(){static make=_e(function*(){let e=H6e(),t=dn(),r=new Map,n=[],o=[],s=[],i=new Map,a=new Map,c=yield*Df(),l=new Map,u=yield*Pye(iJ,{spanPrefix:"McpServer/Notifications",onFromClient(p){let f=p.message;if(f._tag!=="Request")return Y;if(f.tag.includes("list_changed")){if(!l.has(f.tag))l.set(f.tag,setTimeout(()=>{c.unsafeOffer(f),l.delete(f.tag)},0))}else c.unsafeOffer(f);return u.write({clientId:0,requestId:f.id,_tag:"Exit",exit:Fi})}});return Al.of({notifications:u.client,notificationsMailbox:c,initializedClients:new Set,get tools(){return t},addTool:(p)=>Te(()=>(t.push(p.tool),r.set(p.tool.name,p.handle),u.client["notifications/tools/list_changed"]({}))),callTool:(p)=>Te(()=>{let f=r.get(p.name);if(!f)return ce(new yB({message:`Tool '${p.name}' not found`}));return f(p.arguments)}),get resources(){return n},get resourceTemplates(){return o},addResource:(p,f)=>Te(()=>(n.push(p),e.add(p.uri,{_tag:"Resource",effect:f}),u.client["notifications/resources/list_changed"]({}))),addResourceTemplate:({completions:p,handle:f,routerPath:A,template:d})=>Te(()=>{o.push(d),e.add(A,{_tag:"ResourceTemplate",handle:f});for(let[g,x]of Object.entries(p))a.set(`ref/resource/${d.uriTemplate}/${g}`,x);return u.client["notifications/resources/list_changed"]({})}),findResource:(p)=>Te(()=>{let f=e.find(p);if(!f)return Z({contents:[]});else if(f.handler._tag==="Resource")return f.handler.effect;let A=[];for(let d of Object.keys(f.params))A[Number(d)]=f.params[d];return f.handler.handle(p,A)}),get prompts(){return s},addPrompt:(p)=>Te(()=>{s.push(p.prompt),i.set(p.prompt.name,p.handle);for(let[f,A]of Object.entries(p.completions))a.set(`ref/prompt/${p.prompt.name}/${f}`,A);return u.client["notifications/prompts/list_changed"]({})}),getPromptResult:Ht(function*({arguments:p,name:f}){let A=i.get(f);if(!A)return yield*new yB({message:`Prompt '${f}' not found`});return yield*A(p??{})}),completion:Ht(function*(p){let f=p.ref,A=f.type==="ref/resource"?`ref/resource/${f.uri}/${p.argument.name}`:`ref/prompt/${f.name}/${p.argument.name}`,d=a.get(A);return d?yield*d(p.argument.value):IB.empty})})});static layer=Oc(Al,Al.make)}var L6e=Ht(function*(e){let t=yield*Al,r=yield*e,n=yield*vn();for(let o of Object.values(r.tools)){let s=new gF({name:o.name,description:o.description,inputSchema:q6e(o.parametersSchema.ast),annotations:new mF({...Jo(o.annotations,cJ).pipe(jt((i)=>({title:i})),pt),readOnlyHint:Ot(o.annotations,gy),destructiveHint:Ot(o.annotations,Ey),idempotentHint:Ot(o.annotations,lJ),openWorldHint:Ot(o.annotations,uJ)})});yield*t.addTool({tool:s,handle(i){return r.handle(o.name,i).pipe(Jn(n),Xk({onFailure:(a)=>new SB({isError:!0,structuredContent:typeof a==="object"?a:void 0,content:[{type:"text",text:JSON.stringify(a)}]}),onSuccess:(a)=>new SB({isError:!1,structuredContent:typeof a.encodedResult==="object"?a.encodedResult:void 0,content:[{type:"text",text:JSON.stringify(a.encodedResult)}]})}))}})}}),P6e=(e)=>r0(L6e(e)).pipe(no(Al.layer)),JCe=function(){if(arguments.length===1){let o=arguments[0];return _e(function*(){let s=yield*vn();yield*(yield*Al).addResource(new CB({...o,annotations:o}),o.content.pipe(Jn(s),z((a)=>zCe(o.uri,a)),rn((a)=>{let c=gk(a)[0];return new my({message:c.message})})))})}let{params:e,routerPath:t,schema:r,uriPath:n}=W6e(...arguments);return Ht(function*(o){let s=yield*vn(),i=yield*Al,a=is(r),c=new hF({...o,uriTemplate:n,annotations:o}),l={};for(let[u,p]of Object.entries(o.completion??{})){let f=hh(Re(e[u])),A=(d)=>p(d).pipe(w(f),z((g)=>new IB({completion:{values:g,total:g.length,hasMore:!1}})),rn((g)=>{let x=gk(g)[0];return new my({message:x.message})}),Jn(s));l[u]=A}yield*i.addResourceTemplate({template:c,routerPath:t,completions:l,handle:(u,p)=>a(p).pipe(De((f)=>new yB({message:f.message})),w((f)=>o.content(u,...f).pipe(z((A)=>zCe(u,A)),rn((A)=>{let d=gk(A)[0];return new my({message:d.message})}))),Jn(s))})})},jCe=function(){if(arguments.length===1)return r0(JCe(arguments[0])).pipe(no(Al.layer));let e=JCe(...arguments);return(t)=>r0(e(t)).pipe(no(Al.layer))};var H6e=()=>{let e=Xye({ignoreTrailingSlash:!0,ignoreDuplicateSlashes:!0,caseSensitive:!0});return{add:(n,o)=>{e.on("GET",n,o)},find:(n)=>e.find("GET",n)}},W6e=(e,...t)=>{let r=e[0].replace(":","::"),n=e[0],o={},s=oI();if(t.length>0){let i=[];for(let a=0;a<t.length;a++){let c=t[a],l=e[a+1],u=String(a);i.push(c),r+=`:${u}${l.replace(":","::")}`;let p=yn(qCe)(c.ast).pipe(je(()=>`param${u}`));o[p]=c,n+=`{${p}}${l}`}s=oI(...i)}return{routerPath:r,uriPath:n,schema:s,params:o}};var q6e=(e)=>{if(MS(e).length===0)return{type:"object",properties:{},required:[],additionalProperties:!1};let r={},n=nCe(e,{definitions:r,topLevelReferenceStrategy:"skip"});if(Object.keys(r).length===0)return n;return n.$defs=r,n},zCe=(e,t)=>{if(typeof t==="string")return{contents:[{uri:e,text:t}]};else if(t instanceof Uint8Array)return{contents:[{uri:e,blob:t}]};return t};var EF="~@effect/ai/AiError";class xF extends ot("@effect/ai/AiError/MalformedInput")("MalformedInput",{module:m,method:m,description:U(m),cause:U(bt)}){[EF]=EF}class BB extends ot("@effect/ai/AiError/MalformedOutput")("MalformedOutput",{module:m,method:m,description:U(m),cause:U(bt)}){[EF]=EF;static fromParseError({error:e,...t}){return new BB({...t,cause:e})}}var Y6e={...Pg,...Ws,of:X,toContext(e){return _e(this,function*(){let t=yield*vn(),r=tn(e)?yield*e:e,n=new Map;for(let[o,s]of Object.entries(r)){let i=this.tools[o];n.set(i.id,{handler:s,context:t})}return fp(n)})},toLayer(e){return RS(this.toContext(e))},commit(){return _e(this,function*(){let e=this.tools,t=yield*vn(),r=new WeakMap,n=(s)=>{let i=r.get(s);if(Wy(i)){let a=t.unsafeMap.get(s.id),c=is(s.parametersSchema),l=Ie(s.successSchema,s.failureSchema),u=Uee(l),p=hh(l);i={context:a.context,handler:a.handler,decodeParameters:c,validateResult:u,encodeResult:p},r.set(s,i)}return i},o=we("Toolkit.handle",{captureStackTrace:!1})(function*(s,i){yield*u6({tool:s,parameters:i});let a=e[s];if(Wy(a)){let A=Object.keys(e).join(",");return yield*new BB({module:"Toolkit",method:`${s}.handle`,description:`Failed to find tool with name '${s}' in toolkit - available tools: ${A}`})}let c=n(a),l=yield*De(c.decodeParameters(i),(A)=>new BB({module:"Toolkit",method:`${s}.handle`,description:`Failed to decode tool call parameters for tool '${s}' from:
|
|
184
184
|
'${JSON.stringify(i,void 0,2)}'`,cause:A})),{isFailure:u,result:p}=yield*c.handler(l).pipe(z((A)=>({result:A,isFailure:!1})),Vn((A)=>a.failureMode==="error"?ce(A):Z({result:A,isFailure:!0})),Er(({result:A})=>c.validateResult(A)),gE((A)=>wr(c.context,A)),De((A)=>NE(A)?new xF({module:"Toolkit",method:`${s}.handle`,description:`Failed to validate tool call result for tool '${s}'`,cause:A}):A)),f=yield*De(c.encodeResult(p),(A)=>new xF({module:"Toolkit",method:`${s}.handle`,description:`Failed to encode tool call result for tool '${s}'`,cause:A}));return{isFailure:u,result:p,encodedResult:f}});return{tools:e,handle:o}})},toJSON(){return{_id:"@effect/ai/Toolkit",tools:Array.from(Object.values(this.tools)).map((e)=>e.name)}},pipe(){return W(this,arguments)}},V6e=(e)=>Object.assign(function(){},Y6e,{tools:e}),J6e=(...e)=>{let t={};for(let r of e){let n=On(r)?VCe(r):r;t[r.name]=n}return t};var z6e=(...e)=>V6e(J6e(...e));import{homedir as U7e}from"node:os";var Qm="https://expand.land";function j6e(e){return e.replace(/\/+$/,"")}function ZCe(e){return e!==null&&e!==void 0&&Number.isInteger(e)&&e>0&&e<=2147483647?e:void 0}function KCe(e){return e!==null&&e!==void 0&&Number.isInteger(e)&&e>=0&&e<=4294967295?e:void 0}function QB(e,t="https://expand.land"){return`${j6e(t)}/s/${encodeURIComponent(e)}`}function XCe(e,t="https://expand.land"){return`${QB(e,t)}/appendix`}function eSe(e,t,r="https://expand.land"){let n=`${QB(e,r)}/content`,o=ZCe(t);return o===void 0?n:`${n}?id=${o}`}var $6e=/^[A-Za-z0-9._~-]+$/u;function tSe(e){let t=e.trim();if(t.length===0)return;if($6e.test(t))return{snapshotId:t};try{let r=new URL(t),n=/^\/s\/([^/]+)/u.exec(r.pathname);if(!n?.[1])return;return{snapshotId:decodeURIComponent(n[1]),host:r.origin}}catch{return}}function K6e(e){return new URL(e).origin}function xy(e,t){if(e==null)return t;try{return K6e(e)}catch{return t}}function yy(e,t,r,n="https://expand.land"){let o=typeof t==="string",s=o?t:void 0,i=o?typeof r==="string"?void 0:r:t,c=QB(e,o?n:typeof r==="string"?r:"https://expand.land"),l=ZCe(i?.evidenceId);if(l!==void 0)return`${c}?id=${l}`;if(s==="statejson"){let u=KCe(i?.stateJsonSourceId);return u===void 0?c:`${c}?id=${u}`}if(s==="markdown"||s==="appendix"){let u=KCe(i?.nodeIds?.[0]);return u===void 0?c:`${c}/playground#focus=${u}`}return c}var TSe=Ii(RSe(),1);class RJ extends ot()("CredentialStorageLockError",{error:bt}){get message(){return"Could not lock credential storage. Try again shortly."}}var kSe=Pi(new Set);function DSe(e,t){if(typeof e!=="object"||e===null||!("code"in e))return!1;return e.code===t}function N7e(e){return DSe(e.error,"ERELEASED")||DSe(e.error,"ENOTACQUIRED")}var Nu=Ht(function*(e,t,r=`${e}.lock`){let n=yield*iFe(kSe);if(n.has(e))return yield*t;return yield*ef(lr({try:()=>TSe.lock(e,{realpath:!1,lockfilePath:r,onCompromised:()=>{return}}),catch:(o)=>new RJ({error:o})}).pipe(CS({schedule:fH("25 millis"),times:400,while:({error:o})=>o instanceof Error&&("code"in o)&&o.code==="ELOCKED"})),()=>EE(t,kSe,new Set([...n,e])),(o)=>lr({try:()=>o(),catch:(s)=>new RJ({error:s})}).pipe(Vn((s)=>N7e(s)?Y:Mo(s))))});var kJ=we("runNonInteractiveCommand")(function*(e){let t=yield*e.pipe(XD(mne),J_e("pipe"),V_e("inherit"),Y_e),[r]=yield*wc([t.exitCode,P_e(t.stdout)],{concurrency:"unbounded"});return r},ro);function vSe(e,t,r,n){return ro(_e(function*(){let o=yield*e.open(t,{flag:"wx",mode:n}),s=yield*o.stat,i={dev:s.dev,ino:pt(s.ino),mode:s.mode,type:s.type},a=yield*Dr(o.writeAll(new TextEncoder().encode(r)).pipe(ve(o.sync)));if(vo(a))return{identity:i,writeExit:a,pathMatchesHandle:!1};let c=yield*e.stat(t),l=by(i,{exists:!0,dev:c.dev,ino:pt(c.ino),type:c.type});return{identity:i,writeExit:a,pathMatchesHandle:l}}))}function by(e,t){return t.exists&&t.dev===e.dev&&t.ino===e.ino&&t.type===e.type}import{homedir as _7e}from"node:os";var OSe=_e(function*(){let e=yield*Jr;return yield*Do("XDG_CONFIG_HOME").pipe(bd(""),Lg((t)=>t.trim()===""?e.join(_7e(),".config"):t))});var OF="https://api.expand.ai",L7e="https://expand.ai",vB=(e)=>Do(e).pipe(_l,Lg(Ge({onNone:()=>!1,onSome:(t)=>t!==""&&t!=="0"&&t!=="false"}))),_Se=(e,t)=>Do(e).pipe(_l,Lg(Bn(lh(t)))),FF=3;function P7e(e,t){if(e===0)return"accepted";if(e===FF)return"refused";return t?"tolerated":"refused"}function DJ(e){let t=e.replace(/\//g,"\\");if(!t.startsWith("\\\\"))return!1;return!/^\\\\[?.]\\[a-z]:/i.test(t)}function H7e(e,t,r){if(DJ(e))return!1;return t.filter((n)=>!DJ(n)).some((n)=>e===n||e.startsWith(`${n}${r}`))}var USe=Y0(C2.pipe($ee("ApiKey"))),vm="Re-authenticate in this shell with `expandai login --json`. When an agent is handling the task, it must run that command itself and only ask the user to approve the returned URL and code in a browser.",W7e=x2("ApiKey",{apiKey:USe}),TJ=x2("OAuth",{accessToken:Y0(m),refreshToken:U(Y0(m)),expiresAt:J0,clientId:U(m)}),q7e=b({enabled:U(ae),distinctId:U(m),noticeShown:U(ae)}),vJ=b({sessionToken:Y0(m),mintedAt:J0});class _u extends Oe("ExpandCliConfig")({apiUrl:U(W0),authMethod:U(Ie(W7e,TJ)),telemetry:U(q7e),anonymousSession:U(vJ)}){static Json=xo(_u)}function G7e(e,t){if(e._tag==="ApiKey")return"healthy";if(E6(t,e.expiresAt))return ns(e.accessToken).trim().length>0?"healthy":"unusable";let r=e.refreshToken;return r!==void 0&&ns(r).trim().length>0?"refresh_required":"unusable"}function Y7e(e,t){return G7e(e,t)!=="unusable"}var V7e=xo(b({alg:mh})),J7e=xo(b({iss:W0}));function z7e(e,t){if(e._tag!=="OAuth")return!1;let r=ns(e.accessToken).split(".");if(r.length!==3||r.some((o)=>!/^[A-Za-z0-9_-]+$/u.test(o)||zt(ZP(o))))return!1;let n=ct(r[0]).pipe(Bn((o)=>Xy(XP(o))),Bn(lh(V7e)));if($e(n))return!1;return ct(r[1]).pipe(Bn((o)=>Xy(XP(o))),Bn(lh(J7e)),WA(({iss:o})=>(o.protocol==="https:"||o.protocol==="http:")&&o.origin!==t.origin))}var j7e=Fn({key:m,value:Tt}),vF=xo(j7e);function $7e(e,t){return{...e,...t}}function K7e(e,t){return typeof e==="object"&&e!==null&&"code"in e&&e.code===t}function Z7e(e){return`'${e.replaceAll("'","''")}'`}function FSe(e,t){return`$PSModuleAutoLoadingPreference = 'None'
|
|
185
185
|
$targetPaths = @(${t.map((r)=>Z7e(r)).join(", ")})
|
|
186
186
|
function Get-CredentialItem($targetPath) {
|