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
package/build/esm/main.js
CHANGED
|
@@ -194,7 +194,7 @@ ${Mt(Uu(a,8),`
|
|
|
194
194
|
`))))}}case"ShowWizard":{let a=hZ(e.summary)?pl:Sc([xc,Dt("--"),xc,e.summary]),c=mt(_e(Sc([Dt("The wizard mode will assist you with constructing commands for"),xc,fd(`${e.name} (${e.version})`),Dt(".")])),_e("Please answer all prompts provided by the wizard.")),l=sE([[Dt("Instructions"),c]]),u=Kp(Sc([fd("Wizard Mode for CLI Application:"),xc,fd(e.name),xc,fd(`(${e.version})`),a])),p=mt(u,l),f=Gr(p),d=ut(mv(e.command))[0],A=Rrt(n,d,r);return qe(f).pipe(be(Q5(n.command,A,i)),nr((m)=>qe(Gr(vrt(m)))),N((m)=>sH({message:"Would you like to run the command?",initial:!0,active:"yes",inactive:"no"}).pipe(N((g)=>{let y=XV(s,2),w=Qf(m,1),b=at(y,w);return g?qe().pipe(be(_H(e,b,o))):Z}))),Ft((m)=>{if(EZ(m)){let g=_e(kSe(`
|
|
195
195
|
|
|
196
196
|
Quitting wizard mode...`));return qe(Gr(g))}return se(m)}))}case"ShowVersion":{let a=_e(e.version);return qe(Gr(a))}}},Drt=(e)=>{let t=e,r=tt();while(t!==void 0)switch(t._tag){case"Standard":{r=rt(t.name),t=void 0;break}case"GetUserInput":{r=rt(t.name),t=void 0;break}case"Map":{t=t.command;break}case"Subcommands":{t=t.parent;break}}return r},Rrt=(e,t,r)=>{let n=b5(e.command),[o,i]=Yy(r,(a)=>!qie(n,a)),s=ws(i,{onEmpty:()=>Ja(o,(a)=>a!=="--wizard"),onNonEmpty:(a)=>so(o,a)});return at(t.split(/\s+/),s)},vrt=(e)=>{let t=x(Ja(e,(n)=>n.length>0),Mt(" ")),r=Dt("You may now execute your command directly with the following options and arguments:");return mZ([_e(tH(fd("Wizard Mode Complete!"))),_e(r),_e(Ps(Dt(" "),oE(t,eH)))])},Trt=(e)=>e&&(e==="--log-level"||e.startsWith("--log-level="));var Mrt="@effect/cli/Command",M5=Symbol.for(Mrt),_rt=(e)=>{let t=[],r=0,n=[],o=0;function i(a){let c={};for(let l in a)c[l]=s(a[l]);return c}function s(a){if(qc(a))return{_tag:"Array",children:Le(a,s)};else if(xH(a))return t.push(a),{_tag:"Args",index:r++};else if(wH(a))return n.push(a),{_tag:"Options",index:o++};else return{_tag:"ParsedConfig",tree:i(a)}}return{args:t,options:n,tree:i(e)}},vIe=(e,t,r)=>{let n={};for(let i in e)n[i]=o(e[i]);return n;function o(i){if(i._tag==="Args")return t[i.index];else if(i._tag==="Options")return r[i.index];else if(i._tag==="Array")return Le(i.children,o);else return vIe(i.tree,t,r)}},TIe={...pg,[M5]:M5,commit(){return this.tag},pipe(){return ue(this,arguments)}},_5=We("@effect/cli/Command/registeredDescriptors",()=>new WeakMap),Frt=(e)=>_5.get(e.tag)??e.descriptor,Nrt=(e,t,r,n=me)=>{let o=Object.create(TIe);return o.descriptor=e,o.handler=t,o.transform=n,o.tag=r,o},FH=(e,t)=>{let r=Object.create(TIe);return r.descriptor=t.descriptor??e.descriptor,r.handler=t.handler??e.handler,r.transform=t.transform?(n,o)=>t.transform(e.transform(n,o),o):e.transform,r.tag=e.tag,r},OIe=h((e)=>xIe(e[0]),(e,t)=>{let r=Nrt(e,t??((n)=>DJ(()=>kIe(Frt(r)))),Qt(`@effect/cli/Command/(${ut(mv(e)).join("|")})`));return r}),Lrt=(e,t)=>{let{args:r,options:n,tree:o}=_rt(t);return B5(SIe(e,Bh(n),jZ(r)),({args:i,options:s})=>vIe(o,i,s))},MIe=(e,t={},r)=>OIe(Lrt(e,t),r);var Urt=h(2,(e,t)=>FH(e,{descriptor:t(e.descriptor)}));var _Ie=h(2,(e,t)=>FH(e,{handler:t,transform:me}));var FIe=h(2,(e,t)=>FH(e,{transform:(r,n)=>rn(r,typeof t==="function"?t(n):t)}));var NIe=h(2,(e,t)=>Urt(e,bIe(t))),LIe=h(2,(e,t)=>{let r=wIe(e.descriptor,Le(t,(i)=>[i.tag,i.descriptor])),n=Bs(t,new Map,(i,s)=>(i.set(s.tag,s),_5.set(s.tag,s.descriptor),i));function o(i){if(i.subcommand._tag==="Some"){let[s,a]=i.subcommand.value,c=n.get(s),l=c.transform(c.handler(a),a);return jr(l,e.tag,i)}return e.handler(i)}return FH(e,{descriptor:r,handler:o})});var UIe=h(2,(e,t)=>{let r=RIe({...t,command:e.descriptor});_5.set(e.tag,e.descriptor);let n=(o)=>e.transform(e.handler(o),o);return(o)=>_H(r,o,n)});var fr=MIe;var PIe=FIe;var dr=NIe,dn=_Ie,Id=LIe;var Hrt=UIe;var Wrt=zt(aa,{style:"pretty"});function qrt(e){return Y(function*(){let r=yield*(yield*Xt).columns,n=yi(e.message,r),o=te(ca,yc);return n.pipe(te(o),fn(pn),zt({style:"pretty",options:{lineWidth:r}}))})}var Grt=/\r?\n/;function HIe(e,t,r,n){let o=(s)=>Be(Ye(s),Zo),i=te(t,wt);return ci(n.message.split(Grt),{onEmpty:()=>ds([i,r,e]),onNonEmpty:(s)=>{let a=Le(s,(c)=>o(c));return i.pipe(te(Us(kn(a),2)),te(wt),te(r),te(wt),te(e))}})}function Vrt(e,t){return Y(function*(){let n=yield*(yield*Xt).columns,o=yield*mo,i=Be(Ye("?"),jn),s=Be(o.pointerSmall,Mr),a=e.value?t.placeholder.defaultConfirm:t.placeholder.defaultDeny,c=Be(Ye(a),Mr),l=HIe(c,i,s,t);return ul.pipe(te(l),fn(pn),zt({style:"pretty",options:{lineWidth:n}}))})}function zrt(e,t){return Y(function*(){let n=yield*(yield*Xt).columns,o=yield*mo,i=Be(o.tick,Ls),s=Be(o.ellipsis,Mr),a=e?t.label.confirm:t.label.deny,c=Ye(a);return HIe(c,i,s,t).pipe(te(xn),fn(pn),zt({style:"pretty",options:{lineWidth:n}}))})}function Yrt(e){return(t,r)=>Oe.$match(r,{Beep:()=>M(Wrt),NextFrame:({state:n})=>Vrt(n,e),Submit:({value:n})=>zrt(n,e)})}var jrt=/^y|t$/,$rt=/^n|f$/;function Jrt(e,t){let r=Ue(e.input,()=>"");if(e.key.name==="enter"||e.key.name==="return")return M(Oe.Submit({value:t}));if(jrt.test(r.toLowerCase()))return M(Oe.Submit({value:!0}));if($rt.test(r.toLowerCase()))return M(Oe.Submit({value:!1}));return M(Oe.Beep())}var WIe=(e)=>{let t={initial:!1,...e,label:{confirm:"yes",deny:"no",...e.label},placeholder:{defaultConfirm:"(Y/n)",defaultDeny:"(y/N)",...e.placeholder}},r={value:t.initial};return Hs(r,{render:Yrt(t),process:(n)=>Jrt(n,t.initial),clear:()=>qrt(t)})};var Zrt=zt(aa,{style:"pretty"}),qIe=/\r?\n/;function GIe(e,t,r){let n=(i)=>Be(Ye(i),Zo),o=te(e,wt);return ci(r.message.split(qIe),{onEmpty:()=>ds([o,t]),onNonEmpty:(i)=>{let s=Le(i,(a)=>n(a));return o.pipe(te(Us(kn(s),2)),te(wt),te(t),te(wt))}})}function Xrt(e,t){return Te(e.error,{onNone:()=>ur,onSome:(r)=>ci(r.split(qIe),{onEmpty:()=>ur,onNonEmpty:(n)=>{let o=(a)=>Be(Ye(a),ki(Zg,mc)),i=te(Be(t,mc),wt),s=Le(n,(a)=>o(a));return rE.pipe(te(xn),te(i),te(mh(kn(s))),te(nE))}})})}function ent(e,t){if(!e.disabled&&e.description&&t)return OS("-").pipe(te(wt),te(Ye(e.description)),Be(Mr));return ur}var VIe=2;function tnt(e,t,r){let n=t.choices,o=n.length,a=e.selectedIndices.size===o?t?.selectNone??"Select None":t?.selectAll??"Select All",c=t?.inverseSelection??"Inverse Selection",l=[{title:a},{title:c}],u=[...l,...n],p=dB(e.index,u.length,t.maxPerPage),f=[];for(let d=p.startIndex;d<p.endIndex;d++){let A=u[d],m=e.index===d,g=wt;if(d===p.startIndex&&p.startIndex>0)g=r.arrowUp;else if(d===p.endIndex-1&&p.endIndex<u.length)g=r.arrowDown;if(d<l.length){let y=m?Be(Ye(A.title),jn):Ye(A.title);f.push(g.pipe(te(wt),te(y)))}else{let y=d-l.length,b=e.selectedIndices.has(y)?r.checkboxOn:r.checkboxOff,D=m?Be(b,jn):b,k=Ye(A.title),B=ent(A,m);f.push(g.pipe(te(wt),te(D),te(wt),te(k),te(wt),te(B)))}}return kn(f)}function rnt(e,t){return Y(function*(){let n=yield*(yield*Xt).columns,o=yield*mo,i=tnt(e,t,o),s=Be(Ye("?"),jn),a=Be(o.pointerSmall,Mr),c=GIe(s,a,t),l=Xrt(e,o.pointer);return ul.pipe(te(c),te(xn),te(i),te(l),zt({style:"pretty",options:{lineWidth:n}}))})}function nnt(e,t){return Y(function*(){let n=yield*(yield*Xt).columns,o=yield*mo,s=Array.from(e.selectedIndices).sort(nc).map((p)=>t.choices[p].title).join(", "),a=Ye(s),c=Be(o.tick,Ls),l=Be(o.ellipsis,Mr);return GIe(c,l,t).pipe(te(wt),te(Be(a,cd)),te(xn),zt({style:"pretty",options:{lineWidth:n}}))})}function ont(e,t){let r=e.index===0?t-1:e.index-1;return M(Oe.NextFrame({state:{...e,index:r}}))}function int(e,t){let r=(e.index+1)%t;return M(Oe.NextFrame({state:{...e,index:r}}))}function snt(e,t){let r=new Set(e.selectedIndices);if(e.index===0)if(e.selectedIndices.size===t.choices.length)r.clear();else for(let n=0;n<t.choices.length;n++)r.add(n);else if(e.index===1)for(let n=0;n<t.choices.length;n++)if(e.selectedIndices.has(n))r.delete(n);else r.add(n);else{let n=e.index-VIe;if(r.has(n))r.delete(n);else r.add(n)}return M(Oe.NextFrame({state:{...e,selectedIndices:r}}))}function ant(e){return Y(function*(){let r=yield*(yield*Xt).columns,n=te(ca,yc),o=`
|
|
197
|
-
`.repeat(Math.min(e.choices.length+2,e.maxPerPage))+e.message+1;return yi(o,r).pipe(te(n),fn(pn),zt({style:"pretty",options:{lineWidth:r}}))})}function cnt(e){return(t,r)=>{let n=e.choices.length+VIe;switch(t.key.name){case"k":case"up":return ont({...r,error:U()},n);case"j":case"down":case"tab":return int({...r,error:U()},n);case"space":return snt(r,e);case"enter":case"return":{let o=r.selectedIndices.size;if(e.min!==void 0&&o<e.min)return M(Oe.NextFrame({state:{...r,error:P(`At least ${e.min} are required`)}}));if(e.max!==void 0&&o>e.max)return M(Oe.NextFrame({state:{...r,error:P(`At most ${e.max} choices are allowed`)}}));let i=Array.from(r.selectedIndices).sort(nc).map((s)=>e.choices[s].value);return M(Oe.Submit({value:i}))}default:return M(Oe.Beep())}}}function lnt(e){return(t,r)=>Oe.$match(r,{Beep:()=>M(Zrt),NextFrame:({state:n})=>rnt(n,e),Submit:()=>nnt(t,e)})}var zIe=(e)=>{let t={maxPerPage:10,...e},r=new Set;for(let n=0;n<t.choices.length;n++)if(t.choices[n].selected===!0)r.add(n);return Hs({index:0,selectedIndices:r,error:U()},{render:lnt(t),process:cnt(t),clear:()=>ant(t)})};var pnt=WIe;var fnt=kCe;var NH=fl,YIe=zIe;var F5=Symbol.for("@effect/platform/CommandExecutor"),jIe=Symbol.for("@effect/platform/Process"),$Ie=tR(),JIe=tR(),UH=Qt("@effect/platform/CommandExecutor"),KIe=(e)=>{let t=(n)=>nd(K(e(n),(o)=>o.stdout)),r=(n,o)=>{let i=new TextDecoder(o);return eEe($ge(t(n),fA((s)=>i.decode(s))))};return{[F5]:F5,start:e,exitCode:(n)=>Tr(N(e(n),(o)=>o.exitCode)),stream:t,string:(n,o="utf-8")=>{let i=new TextDecoder(o);return x(e(n),N((s)=>rd(s.stdout,dnt)),K((s)=>i.decode(s)),Tr)},lines:(n,o="utf-8")=>x(r(n,o),Zge,K(Woe)),streamLines:r}},dnt=Lge(new Uint8Array,(e,t)=>KI(t,e,(r,n)=>{let o=new Uint8Array(r.length+n.length);return o.set(r),o.set(n,r.length),o}));var N5=Symbol.for("@effect/platform/Command");var PH=h(2,(e,t)=>{switch(e._tag){case"StandardCommand":return Ev({...e,env:Vie(e.env,Hm(Object.entries(t).filter(([r])=>r!==void 0)))});case"PipedCommand":return rbe(PH(e.left,t),PH(e.right,t))}});var XIe=(e)=>Array.from(L5(e)),L5=(e)=>{switch(e._tag){case"StandardCommand":return Kt(e);case"PipedCommand":return mn(L5(e.left),L5(e.right))}};var ebe={[N5]:N5,pipe(){return ue(this,arguments)},...Pc},Ant={...ebe,_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()}}},Ev=(e)=>Object.assign(Object.create(Ant),e),hnt={...ebe,_tag:"PipedCommand",toJSON(){return{_id:"@effect/platform/Command",_tag:this._tag,left:this.left.toJSON(),right:this.right.toJSON()}}},HH=(e)=>Object.assign(Object.create(hnt),e),tbe=(e,...t)=>Ev({command:e,args:t,env:ya(),cwd:U(),shell:!1,stdin:"pipe",stdout:"pipe",stderr:"pipe",gid:U(),uid:U()}),rbe=h(2,(e,t)=>HH({left:e,right:t})),U5=h(2,(e,t)=>{switch(e._tag){case"StandardCommand":return Ev({...e,stderr:t});case"PipedCommand":return HH({...e,right:U5(e.right,t)})}}),P5=h(2,(e,t)=>{switch(e._tag){case"StandardCommand":return Ev({...e,stdin:t});case"PipedCommand":return HH({...e,left:P5(e.left,t)})}}),H5=h(2,(e,t)=>{switch(e._tag){case"StandardCommand":return Ev({...e,stdout:t});case"PipedCommand":return HH({...e,right:H5(e.right,t)})}}),nbe=(e)=>N(UH,(t)=>t.start(e));var obe=PH;var W5=XIe;var vB=tbe;var gnt=nbe;var ibe=U5,WH=P5,sbe=H5;var gE=UH,q5=jIe,abe=$Ie,cbe=JIe,lbe=KIe;var G5=Symbol.for("@effect/platform/Cookies"),Ent=(e)=>Ee(e,G5),ube=Symbol.for("@effect/platform/Cookies/Cookie");var ynt={[G5]:G5,...Pc,toJSON(){return{_id:"@effect/platform/Cookies",cookies:aoe(this.cookies,(e)=>e.toJSON())}},pipe(){return ue(this,arguments)}},xnt=(e)=>{let t=Object.create(ynt);return t.cookies=e,t},fbe=(e)=>{let t={};for(let r of e)t[r.name]=r;return xnt(t)},OB=(e)=>{let t=typeof e==="string"?[e]:e,r=[];for(let n of t){let o=Snt(n.trim());if(ne(o))r.push(o.value)}return fbe(r)};function Snt(e){let t=e.split(";").map((a)=>a.trim()).filter((a)=>a!=="");if(t.length===0)return U();let r=t[0].indexOf("=");if(r===-1)return U();let n=t[0].slice(0,r);if(!Cnt.test(n))return U();let o=t[0].slice(r+1),i=Abe(o);if(t.length===1)return P(Object.assign(Object.create(pbe),{name:n,value:i,valueEncoded:o}));let s={};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)s.domain=f;break}case"expires":{if(p===void 0)break;let f=new Date(p);if(!isNaN(f.getTime()))s.expires=f;break}case"max-age":{if(p===void 0)break;let f=parseInt(p,10);if(!isNaN(f))s.maxAge=Yc(f);break}case"path":{if(p===void 0)break;if(p[0]==="/")s.path=p;break}case"priority":{if(p===void 0)break;switch(p.toLowerCase()){case"low":s.priority="low";break;case"medium":s.priority="medium";break;case"high":s.priority="high";break}break}case"httponly":{s.httpOnly=!0;break}case"secure":{s.secure=!0;break}case"partitioned":{s.partitioned=!0;break}case"samesite":{if(p===void 0)break;switch(p.toLowerCase()){case"lax":s.sameSite="lax";break;case"strict":s.sameSite="strict";break;case"none":s.sameSite="none";break}break}}}return P(Object.assign(Object.create(pbe),{name:n,value:i,valueEncoded:o,options:Object.keys(s).length>0?s:void 0}))}var Rh=fbe([]),V5=(e)=>KV(e.cookies),Cnt=/^[\u0009\u0020-\u007e\u0080-\u00ff]+$/,pbe={[ube]:ube,...Pc,toJSON(){return{_id:"@effect/platform/Cookies/Cookie",name:this.name,value:this.value,options:this.options}}};var Int=h((e)=>Ent(e[0]),(e,t)=>soe(e.cookies,t));function bnt(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=sk(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 qH=(e)=>Object.values(e.cookies).map(bnt);function dbe(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 i=e.indexOf("=",n);if(i===-1)break;if(i>o){n=o+1;continue}let s=e.substring(n,i++).trim();if(t[s]===void 0){let a=e.charCodeAt(i)===34?e.substring(i+1,o-1).trim():e.substring(i,o).trim();t[s]=a.indexOf("%")!==-1?Abe(a):a}n=o+1}return t}var Abe=(e)=>{try{return decodeURIComponent(e)}catch{return e}};var hbe=Symbol.for("@effect/platform/Headers");var yv=Object.assign(Object.create(null),{[hbe]:hbe,[qQ](e){return YS(this,RA(e,xv))}}),GH=(e)=>Object.assign(Object.create(yv),e);var ml=Object.create(yv),Oo=(e)=>{if(e===void 0)return ml;else if(Symbol.iterator in e){let r=Object.create(yv);for(let[n,o]of e)r[n.toLowerCase()]=o;return r}let t=Object.create(yv);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},vh=(e)=>Object.setPrototypeOf(e,yv);var yE=h(3,(e,t,r)=>{let n=GH(e);return n[t.toLowerCase()]=r,n}),z5=h(2,(e,t)=>GH({...e,...Oo(t)})),sf=h(2,(e,t)=>{let r=GH(e);return Object.assign(r,t),r}),Y5=h(2,(e,t)=>{let r=GH(e),n=(o)=>{if(typeof o==="string"){let i=o.toLowerCase();if(i in e)delete r[i]}else for(let i in e)if(o.test(i))delete r[i]};if(Array.isArray(t))for(let o=0;o<t.length;o++)n(t[o]);else n(t);return r}),YS=h(2,(e,t)=>{let r={...e},n=(o)=>{if(typeof o==="string"){let i=o.toLowerCase();if(i in e)r[i]=Fa(e[i])}else for(let i in e)if(o.test(i))r[i]=Fa(e[i])};if(Array.isArray(t))for(let o=0;o<t.length;o++)n(t[o]);else n(t);return r}),xv=We("@effect/platform/Headers/currentRedactedNames",()=>Iu(["authorization","cookie","set-cookie","x-api-key"]));var mbe=Symbol.for("@effect/platform/HttpClientError");var gbe=mbe;class gl extends sd(gbe,"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 Xo extends sd(gbe,"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 bd=(e)=>{let t=Ebe(e),r=[];for(let n=0;n<t.length;n++)if(Array.isArray(t[n][0])){let[o,i]=t[n];r.push([`${o[0]}[${o.slice(1).join("][")}]`,i])}else r.push(t[n]);return r},Ebe=(e)=>{let t=Symbol.iterator in e?ut(e):Object.entries(e),r=[];for(let[n,o]of t)if(Array.isArray(o)){for(let i=0;i<o.length;i++)if(o[i]!==void 0)r.push([n,String(o[i])])}else if(typeof o==="object"){let i=Ebe(o);for(let[s,a]of i)r.push([[n,...typeof s==="string"?[s]:s],a])}else if(o!==void 0)r.push([n,String(o)]);return r};var ybe=[];var xbe=h(2,(e,t)=>{let r=bd(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 j5=(e,t,r)=>{try{let n=new URL(e,Bnt());for(let o=0;o<t.length;o++){let[i,s]=t[o];if(s!==void 0)n.searchParams.append(i,s)}if(r._tag==="Some")n.hash=r.value;return je(n)}catch(n){return $e(n)}},Sbe=(e)=>new URLSearchParams(e).toString(),Bnt=()=>{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 Pa=Symbol.for("@effect/platform/HttpIncomingMessage"),Ws=(e,t)=>{let r=ir(e,t);return(n)=>N(n.json,r)};class xE extends Kn()("@effect/platform/HttpIncomingMessage/MaxBodySize",{defaultValue:U}){}var SE=(e,t)=>{let r=e.headers["content-type"]??"",n;if(r.includes("application/json"))try{n=or(e.json)}catch{}else if(r.includes("text/")||r.includes("urlencoded"))try{n=or(e.text)}catch{}let o={...t,headers:zl(e.headers),remoteAddress:e.remoteAddress.toJSON()};if(n!==void 0)o.body=n;return o};var Cbe=(e)=>vh({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"}`}),Ibe=(e)=>{let t=vnt(e);if(t._tag==="Some")return t;if(t=Qnt(e),t._tag==="Some")return t;return knt(e)},Qnt=(e)=>{if(!("b3"in e))return U();let t=e.b3.split("-");if(t.length<2)return U();return P(pN({traceId:t[0],spanId:t[1],sampled:t[2]?t[2]==="1":!0}))},knt=(e)=>{if(!e["x-b3-traceid"]||!e["x-b3-spanid"])return U();return P(pN({traceId:e["x-b3-traceid"],spanId:e["x-b3-spanid"],sampled:e["x-b3-sampled"]?e["x-b3-sampled"]==="1":!0}))},Dnt=/^[0-9a-f]{32}$/i,Rnt=/^[0-9a-f]{16}$/i,vnt=(e)=>{if(!e.traceparent)return U();let t=e.traceparent.split("-");if(t.length!==4)return U();let[r,n,o,i]=t;switch(r){case"00":{if(Dnt.test(n)===!1||Rnt.test(o)===!1)return U();return P(pN({traceId:n,spanId:o,sampled:(parseInt(i,16)&1)===1}))}default:return U()}};var VH=Symbol.for("@effect/platform/HttpBody"),$5=Symbol.for("@effect/platform/HttpBody/HttpBodyError"),Tnt=Hx("HttpBodyError"),wbe=(e)=>Tnt({[$5]:$5,reason:e});class zH{[VH];constructor(){this[VH]=VH}[lt](){return this.toJSON()}toString(){return St(this)}}class Bbe extends zH{_tag="Empty";toJSON(){return{_id:"@effect/platform/HttpBody",_tag:"Empty"}}}var MB=new Bbe;class Qbe extends zH{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 YH=(e,t)=>new Qbe(e,t?.contentType,t?.contentLength);class kbe extends zH{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 jH=(e,t)=>new kbe(e,t??"application/octet-stream"),Ont=new TextEncoder,_B=(e,t)=>jH(Ont.encode(e),t??"text/plain"),$H=(e,t)=>_B(JSON.stringify(e),t??"application/json"),JH=(e,t)=>qi({try:()=>$H(e,t),catch:(r)=>wbe({_tag:"JsonError",error:r})});var Dbe=Symbol.for("@effect/platform/HttpClientRequest"),Nnt={[Dbe]:Dbe,...Pc,toJSON(){return{_id:"@effect/platform/HttpClientRequest",method:this.method,url:this.url,urlParams:this.urlParams,hash:this.hash,headers:zl(this.headers),body:this.body.toJSON()}},pipe(){return ue(this,arguments)}};function wd(e,t,r,n,o,i){let s=Object.create(Nnt);return s.method=e,s.url=t,s.urlParams=r,s.hash=n,s.headers=o,s.body=i,s}var Lnt=wd("GET","",ybe,U(),ml,MB),Oh=(e)=>(t,r)=>Obe(Lnt,{method:e,url:t,...r??void 0}),KH=Oh("GET"),ZH=Oh("POST"),K5=Oh("PUT"),Z5=Oh("PATCH"),X5=Oh("DELETE"),e8=Oh("HEAD"),t8=Oh("OPTIONS"),Obe=h(2,(e,t)=>{let r=e;if(t.method)r=_be(r,t.method);if(t.url)r=n8(r,t.url);if(t.headers)r=Cv(r,t.headers);if(t.urlParams)r=o8(r,t.urlParams);if(t.hash)r=Nbe(r,t.hash);if(t.body)r=e1(r,t.body);if(t.accept)r=r8(r,t.accept);if(t.acceptJson)r=Mbe(r);return r}),XH=h(3,(e,t,r)=>wd(e.method,e.url,e.urlParams,e.hash,yE(e.headers,t,r),e.body)),Cv=h(2,(e,t)=>wd(e.method,e.url,e.urlParams,e.hash,z5(e.headers,t),e.body));var r8=h(2,(e,t)=>XH(e,"Accept",t)),Mbe=r8("application/json"),_be=h(2,(e,t)=>wd(t,e.url,e.urlParams,e.hash,e.headers,e.body)),n8=h(2,(e,t)=>{if(typeof t==="string")return wd(e.method,t,e.urlParams,e.hash,e.headers,e.body);let r=new URL(t.toString()),n=bd(r.searchParams),o=r.hash?P(r.hash.slice(1)):U();return r.search="",r.hash="",wd(e.method,r.toString(),n,o,e.headers,e.body)});var Fbe=h(2,(e,t)=>wd(e.method,t.endsWith("/")&&e.url.startsWith("/")?t+e.url.slice(1):t+e.url,e.urlParams,e.hash,e.headers,e.body));var o8=h(2,(e,t)=>wd(e.method,e.url,xbe(e.urlParams,t),e.hash,e.headers,e.body)),Nbe=h(2,(e,t)=>wd(e.method,e.url,e.urlParams,P(t),e.headers,e.body));var e1=h(2,(e,t)=>{let r=e.headers;if(t._tag==="Empty"||t._tag==="FormData")r=Y5(r,["Content-type","Content-length"]);else{let n=t.contentType;if(n)r=yE(r,"content-type",n);let o=t.contentLength;if(o)r=yE(r,"content-length",o.toString())}return wd(e.method,e.url,e.urlParams,e.hash,r,t)});var Lbe=h(2,(e,t)=>K(JH(t),(r)=>e1(e,r)));var Ube=h(2,(e,t)=>e1(e,_B(Sbe(bd(t)),"application/x-www-form-urlencoded")));var CE=Symbol.for("@effect/platform/HttpClientResponse"),i8=(e,t)=>new Hbe(e,t);class Hbe extends fp{request;source;[Pa];[CE];constructor(e,t){super();this.request=e,this.source=t,this[Pa]=Pa,this[CE]=CE}toJSON(){return SE(this,{_id:"@effect/platform/HttpClientResponse",request:this.request.toJSON(),status:this.status})}get status(){return this.source.status}get headers(){return Oo(this.source.headers)}cachedCookies;get cookies(){if(this.cachedCookies)return this.cachedCookies;return this.cachedCookies=OB(this.source.headers.getSetCookie())}get remoteAddress(){return U()}get stream(){return this.source.body?Yge(()=>this.source.body,(e)=>new Xo({request:this.request,response:this,reason:"Decode",cause:e})):cP(new Xo({request:this.request,response:this,reason:"EmptyBody",description:"can not create stream from empty body"}))}get json(){return vg(this.text,{try:(e)=>e===""?null:JSON.parse(e),catch:(e)=>new Xo({request:this.request,response:this,reason:"Decode",cause:e})})}textBody;get text(){return this.textBody??=Fn({try:()=>this.source.text(),catch:(e)=>new Xo({request:this.request,response:this,reason:"Decode",cause:e})}).pipe(Zc,or)}get urlParamsBody(){return N(this.text,(e)=>qi({try:()=>bd(new URLSearchParams(e)),catch:(t)=>new Xo({request:this.request,response:this,reason:"Decode",cause:t})}))}formDataBody;get formData(){return this.formDataBody??=Fn({try:()=>this.source.formData(),catch:(e)=>new Xo({request:this.request,response:this,reason:"Decode",cause:e})}).pipe(Zc,or)}arrayBufferBody;get arrayBuffer(){return this.arrayBufferBody??=Fn({try:()=>this.source.arrayBuffer(),catch:(e)=>new Xo({request:this.request,response:this,reason:"Decode",cause:e})}).pipe(Zc,or)}}var Wbe=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 Hnt=(e)=>`http.request.header.${e}`,Wnt="http.request.method",qnt=(e)=>`http.response.header.${e}`,Gnt="http.response.status_code",Vnt="server.address",znt="server.port",Ynt="url.full",jnt="url.path",$nt="url.scheme",Jnt="url.query",a8=Symbol.for("@effect/platform/HttpClient"),r1=Qt("@effect/platform/HttpClient"),l8=We(Symbol.for("@effect/platform/HttpClient/tracerDisabledWhen"),()=>Iu(In)),qbe=h(2,(e,t)=>o1(e,KA(l8,t))),u8=We(Symbol.for("@effect/platform/HttpClient/currentTracerPropagation"),()=>Iu(!0)),Gbe=h(2,(e,t)=>o1(e,KA(u8,t))),Vbe=Kn()("@effect/platform/HttpClient/SpanNameGenerator",{defaultValue:()=>(e)=>`http.client ${e.method}`});var Knt={[a8]:a8,pipe(){return ue(this,arguments)},...Pc,toJSON(){return{_id:"@effect/platform/HttpClient"}},get(e,t){return this.execute(KH(e,t))},head(e,t){return this.execute(e8(e,t))},post(e,t){return this.execute(ZH(e,t))},put(e,t){return this.execute(K5(e,t))},patch(e,t){return this.execute(Z5(e,t))},del(e,t){return this.execute(X5(e,t))},options(e,t){return this.execute(t8(e,t))}};var Iv=(e,t)=>{let r=Object.create(Knt);return r.preprocess=t,r.postprocess=e,r.execute=function(n){return e(t(n))},r},t1=We("@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)}}}),zbe=We("@effect/platform/HttpClient/scopedRequests",()=>new WeakMap),n1=(e)=>Iv((t)=>N(t,(r)=>_n((n)=>{let o=zbe.get(r),i=o??new AbortController,s=j5(r.url,r.urlParams,r.hash);if(s._tag==="Left")return se(new gl({request:r,reason:"InvalidUrl",cause:s.left}));let a=s.right;if(!n.getFiberRef(khe)||n.getFiberRef(l8)(r)){let u=e(r,a,i.signal,n);if(o)return u;return YA((p)=>uo(p(u),{onSuccess(f){return t1.register(f,i),M(new c8(f,i))},onFailure(f){if(zf(f))i.abort();return ln(f)}}))}let l=cr(n.currentContext,Vbe);return dw(l(r),{kind:"client",captureStackTrace:!1},(u)=>{if(u.attribute(Wnt,r.method),u.attribute(Vnt,a.origin),a.port!=="")u.attribute(znt,+a.port);u.attribute(Ynt,a.toString()),u.attribute(jnt,a.pathname),u.attribute($nt,a.protocol.slice(0,-1));let p=a.search.slice(1);if(p!=="")u.attribute(Jnt,p);let f=n.getFiberRef(xv),d=YS(r.headers,f);for(let A in d)u.attribute(Hnt(A),String(d[A]));return r=n.getFiberRef(u8)?Cv(r,Cbe(u)):r,YA((A)=>A(e(r,a,i.signal,n)).pipe(Zx(u),uo({onSuccess:(m)=>{u.attribute(Gnt,m.status);let g=YS(m.headers,f);for(let y in g)u.attribute(qnt(y),String(g[y]));if(o)return M(m);return t1.register(m,i),M(new c8(m,i))},onFailure(m){if(!o&&zf(m))i.abort();return ln(m)}})))})})),M);class c8{original;controller;constructor(e,t){this.original=e,this.controller=t}[CE]=CE;[Pa]=Pa;applyInterrupt(e){return Pe(()=>(t1.unregister(this.original),BL(e,()=>ge(()=>{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 tEe(()=>(t1.unregister(this.original),zge(this.original.stream,ge(()=>{this.controller.abort()}))))}toJSON(){return this.original.toJSON()}[lt](){return this.original[lt]()}}var Ybe=(e)=>jbe(e,(t,r)=>{let n=new AbortController;return zbe.set(r,n),be(QL((o)=>ea(o,ge(()=>n.abort()))),t)}),{del:Znt,execute:Xnt,get:eot,head:tot,options:rot,patch:not,post:oot,put:iot}=uAe(r1),jbe=h(2,(e,t)=>{let r=e;return Iv(N((n)=>t(r.postprocess(M(n)),n)),r.preprocess)});var o1=h(2,(e,t)=>{let r=e;return Iv((n)=>t(r.postprocess(n)),r.preprocess)});var $be=h(2,(e,t)=>{let r=e;return Iv(r.postprocess,(n)=>K(r.preprocess(n),t))});var i1=(e)=>bu(r1,N(wo(),(t)=>K(e,(r)=>o1(r,aw((n)=>On(t,n))))));var Kbe="@effect/platform/FetchHttpClient/Fetch",p8="@effect/platform/FetchHttpClient/FetchOptions",sot=n1((e,t,r,n)=>{let o=n.getFiberRef(Hp),i=o.unsafeMap.get(Kbe)??globalThis.fetch,s=o.unsafeMap.get(p8)??{},a=s.headers?sf(Oo(s.headers),e.headers):e.headers,c=(l)=>K(Fn({try:()=>i(t,{...s,method:e.method,headers:a,body:l,duplex:e.body._tag==="Stream"?"half":void 0,signal:r}),catch:(u)=>new gl({request:e,reason:"Transport",cause:u})}),(u)=>i8(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 N(rEe(e.body.stream),c)}return c(void 0)}),Zbe=i1(M(sot));class Xbe extends Fi(p8)(){}var cot=Zbe;var uot=YH;var Mh=r1;var s1=n1;var a1=$be;var pot=qbe;var fot=Gbe,c1=i1;var dot=Ybe;var El=Oh,f8=KH,FB=ZH;var bv=XH,d8=Cv;var l1=Fbe;var _h=o8;var yl=Lbe;var rwe=Ube;var IE=CE;var xl=Wbe;var wv=Symbol.for("@effect/platform/Etag/Generator"),NB=Qt("@effect/platform/Etag/Generator"),nwe=(e)=>{switch(e._tag){case"Weak":return`W/"${e.value}"`;case"Strong":return`"${e.value}"`}},owe=(e)=>{let t=e.mtime._tag==="Some"?e.mtime.value.getTime().toString(16):"0";return`${e.size.toString(16)}-${t}`},iwe=(e)=>`${e.size.toString(16)}-${e.lastModified.toString(16)}`,swe=ps(NB,NB.of({[wv]:wv,fromFileInfo(e){return ge(()=>({_tag:"Strong",value:owe(e)}))},fromFileWeb(e){return ge(()=>({_tag:"Strong",value:iwe(e)}))}})),awe=ps(NB,NB.of({[wv]:wv,fromFileInfo(e){return ge(()=>({_tag:"Weak",value:owe(e)}))},fromFileWeb(e){return ge(()=>({_tag:"Weak",value:iwe(e)}))}}));var A8=nwe;var cwe=NB,lwe=swe,h8=awe;var u1=Symbol.for("@effect/platform/HttpServerResponse"),hot=Symbol.for("@effect/platform/HttpServerRespondable");class Bv extends tj{status;statusText;cookies;body;[u1];headers;constructor(e,t,r,n,o){super();if(this.status=e,this.statusText=t,this.cookies=n,this.body=o,this[u1]=u1,o.contentType||o.contentLength){let i={...r};if(o.contentType)i["content-type"]=o.contentType;if(o.contentLength)i["content-length"]=o.contentLength.toString();this.headers=i}else this.headers=r}commit(){return M(this)}[hot](){return M(this)}[lt](){return this.toJSON()}toString(){return St(this)}toJSON(){return{_id:"@effect/platform/HttpServerResponse",status:this.status,statusText:this.statusText,headers:zl(this.headers),cookies:this.cookies.toJSON(),body:this.body.toJSON()}}}var Qv=(e)=>typeof e==="object"&&e!==null&&(u1 in e),LB=(e)=>new Bv(e?.status??204,e?.statusText,e?.headers?Oo(e.headers):ml,e?.cookies??Rh,MB),uwe=(e,t)=>{let r=vh({location:e.toString()});return new Bv(t?.status??302,t?.statusText,t?.headers?sf(r,Oo(t.headers)):r,t?.cookies??Rh,MB)};var pwe=(e,t)=>{let r=t?.headers?Oo(t.headers):ml;return new Bv(t?.status??200,t?.statusText,r,t?.cookies??Rh,_B(e,got(t,r)))};var mot=Qt("@effect/platform/HttpPlatform"),fwe=(e,t)=>N(mot,(r)=>r.fileResponse(e,t));var dwe=(e,t)=>new Bv(t?.status??200,t?.statusText,t?.headers?Oo(t.headers):ml,t?.cookies??Rh,YH(e,{contentType:t?.contentType,contentLength:t?.contentLength}));var got=(e,t)=>{if(e?.contentType)return e.contentType;else if(e?.headers)return t["content-type"];else return};var g8=Symbol.for("@effect/platform/HttpPlatform"),E8=Qt("@effect/platform/HttpPlatform"),hwe=(e)=>Y(function*(){let t=yield*lr,r=yield*cwe;return E8.of({[g8]:g8,fileResponse(n,o){return x(fAe(t.stat(n),"info"),pAe("etag",({info:i})=>r.fromFileInfo(i)),K(({etag:i,info:s})=>{let a=Number(o?.offset??0),c=o?.bytesToRead!==void 0?a+Number(o.bytesToRead):void 0,l=yE(o?.headers?Oo(o.headers):ml,"etag",A8(i));if(s.mtime._tag==="Some")l["last-modified"]=s.mtime.value.toUTCString();let u=c!==void 0?c-a:Number(s.size)-a;return e.fileResponse(n,o?.status??200,o?.statusText,l,a,c,u)}))},fileWebResponse(n,o){return K(r.fromFileWeb(n),(i)=>{let s=sf(o?.headers?Oo(o.headers):ml,vh({etag:A8(i),"last-modified":new Date(n.lastModified).toUTCString()}));return e.fileWebResponse(n,o?.status??200,o?.statusText,s,o)})}})});var y8=Symbol.for("@effect/platform/HttpServer"),mwe=Qt("@effect/platform/HttpServer"),yot={[y8]:y8};var gwe=(e)=>Object.assign(Object.create(yot),e);var x8=mwe,Ewe=gwe;var C8=Qv,bE=LB,Sot=uwe;var Cot=pwe;var I8=dwe;var Iot=fwe;var PB=Symbol.for("@effect/platform/HttpServerRespondable"),ywe=(e)=>Ee(e,PB),bot=bE({status:400}),wot=bE({status:404});var xwe=(e,t)=>{if(C8(e))return M(e);else if(ywe(e))return en(e[PB](),()=>M(t));else if(ww(e))return M(bot);else if(Spe(e))return M(wot);return M(t)},Swe=(e,t)=>{if(C8(e))return M(e);else if(ywe(e))return en(e[PB](),()=>M(t));return M(t)};var bwe=Symbol.for("@effect/platform/HttpServerError");var f1=We("@effect/platform/HttpServerError/clientAbortFiberId",()=>M_(-499,0)),wwe=(e)=>{let t=M(p1),r=Lx,n=!1,o=!1;ype(e,void 0,(a,c)=>{let l=HN(r)?Lx:r;switch(c._tag){case"Fail":{t=xwe(c.error,p1),r=Iwe(l,c);break}case"Die":{let u=Qv(c.defect);t=Swe(c.defect,p1),r=u?l:Iwe(l,c),o=o||u;break}case"Interrupt":{if(n=n||c.fiberId===f1,Cg(r)&&!o)r=c;break}}return U()});let i=!o&&HN(r)?M(n?Bot:Qot):t,s=!o&&HN(r)&&n?qb(f1):r;return K(i,(a)=>{if(Cg(s))return[a,Lx];return[a,Vf(s,sc(a))]})},Iwe=(e,t)=>{if(Cg(e))return t;else if(Cg(t))return e;return Vf(e,t)},Bwe=(e)=>{let t,r=Epe(e,(n)=>{if(Qv(n))return t=n,P(Lx);return U()});return[t??p1,r]},p1=LB({status:500}),Bot=LB({status:499}),Qot=LB({status:503}),Qwe=(e)=>{if(e._tag==="Success")return e.value;return Bwe(e.cause)[0]};var b8=bwe;class kv extends sd(b8,"RequestError"){[PB](){return bE({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 d1 extends sd(b8,"ResponseError"){[PB](){return bE({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 A1 extends sd(b8,"ServeError"){}var h1=f1,Dv=wwe;var kwe=Qwe;var E1=Symbol.for("effect/Mailbox"),w8=Symbol.for("effect/Mailbox/ReadonlyMailbox");var $S=Xr(),Dwe=kr($S),m1=kr(!1),g1=kr(!0),Rwe=[$S,!0];class vwe extends oc{scheduler;capacity;strategy;[E1]=E1;[w8]=w8;state={_tag:"Open",takers:new Set,offers:new Set,awaiters:new Set};messages=[];messagesChunk=Xr();constructor(e,t,r){super();this.scheduler=e,this.capacity=t,this.strategy=r}offer(e){return ct(()=>{if(this.state._tag!=="Open")return m1;else if(this.messages.length+this.messagesChunk.length>=this.capacity)switch(this.strategy){case"dropping":return m1;case"suspend":if(this.capacity<=0&&this.state.takers.size>0)return this.messages.push(e),this.releaseTaker(),g1;return this.offerRemainingSingle(e);case"sliding":return this.unsafeTake(),this.messages.push(e),g1}return this.messages.push(e),this.scheduleReleaseTaker(),g1})}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 ct(()=>{if(this.state._tag!=="Open")return xe(Ni(e));let t=this.unsafeOfferAllArray(e);if(t.length===0)return Dwe;else if(this.strategy==="dropping")return xe(co(t));return this.offerRemainingArray(t)})}unsafeOfferAll(e){return co(this.unsafeOfferAllArray(e))}unsafeOfferAllArray(e){if(this.state._tag!=="Open")return ut(e);else if(this.capacity===Number.POSITIVE_INFINITY||this.strategy==="sliding"){if(this.messages.length>0)this.messagesChunk=mn(this.messagesChunk,co(this.messages));if(this.strategy==="sliding")this.messagesChunk=this.messagesChunk.pipe(mn(Ni(e)),Sz(this.capacity));else if($y(e))this.messagesChunk=mn(this.messagesChunk,e);else this.messages=ut(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 ut(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(QA(e))}failCause(e){return this.done(br(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=he(()=>{if(this.state._tag==="Done")return!0;this.messages=[],this.messagesChunk=$S;let e=this.state.offers;if(this.finalize(this.state._tag==="Open"?bn:this.state.exit),e.size>0){for(let t of e)if(t._tag==="Single")t.resume(m1);else t.resume(kr(co(t.remaining.slice(t.offset))));e.clear()}return!0});done(e){return he(()=>this.unsafeDone(e))}end=this.done(bn);clear=ct(()=>{if(this.state._tag==="Done")return bb(this.state.exit,$S);let e=this.unsafeTakeAll();return this.releaseCapacity(),xe(e)});takeAll=ct(()=>{if(this.state._tag==="Done")return bb(this.state.exit,Rwe);let e=this.unsafeTakeAll();if(e.length===0)return Er(this.awaitTake,this.takeAll);return xe([e,this.releaseCapacity()])});takeN(e){return ct(()=>{if(this.state._tag==="Done")return bb(this.state.exit,Rwe);else if(e<=0)return xe([$S,!1]);e=Math.min(e,this.capacity);let t;if(e<=this.messagesChunk.length)t=jI(this.messagesChunk,e),this.messagesChunk=Sp(this.messagesChunk,e);else if(e<=this.messages.length+this.messagesChunk.length)this.messagesChunk=mn(this.messagesChunk,co(this.messages)),this.messages=[],t=jI(this.messagesChunk,e),this.messagesChunk=Sp(this.messagesChunk,e);else return Er(this.awaitTake,this.takeN(e));return xe([t,this.releaseCapacity()])})}unsafeTake(){if(this.state._tag==="Done")return QF(this.state.exit,QA(new xpe));let e;if(this.messagesChunk.length>0)e=JI(this.messagesChunk),this.messagesChunk=Sp(this.messagesChunk,1);else if(this.messages.length>0)e=this.messages[0],this.messagesChunk=Sp(co(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?kr(this.messages.pop()):void 0;else return;return this.releaseCapacity(),kr(e)}take=ct(()=>this.unsafeTake()??Er(this.awaitTake,this.take));await=vf((e)=>{if(this.state._tag==="Done")return e(this.state.exit);return this.state.awaiters.add(e),he(()=>{if(this.state._tag!=="Done")this.state.awaiters.delete(e)})});unsafeSize(){let e=this.messages.length+this.messagesChunk.length;return this.state._tag==="Done"?U():P(e)}size=he(()=>this.unsafeSize());commit(){return this.takeAll}pipe(){return ue(this,arguments)}toJSON(){return{_id:"effect/Mailbox",state:this.state._tag,size:this.unsafeSize().toJSON()}}toString(){return St(this)}[lt](){return St(this)}offerRemainingSingle(e){return vf((t)=>{if(this.state._tag!=="Open")return t(m1);let r={_tag:"Single",message:e,resume:t};return this.state.offers.add(r),he(()=>{if(this.state._tag==="Open")this.state.offers.delete(r)})})}offerRemainingArray(e){return vf((t)=>{if(this.state._tag!=="Open")return t(kr(co(e)));let r={_tag:"Array",remaining:e,offset:0,resume:t};return this.state.offers.add(r),he(()=>{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(g1),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(Dwe),this.state.offers.delete(t)}return!1}awaitTake=vf((e)=>{if(this.state._tag==="Done")return e(this.state.exit);return this.state.takers.add(e),he(()=>{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(bn),this.messages.length+this.messagesChunk.length===0)break};unsafeTakeAll(){if(this.messagesChunk.length>0){let e=this.messages.length>0?mn(this.messagesChunk,co(this.messages)):this.messagesChunk;return this.messagesChunk=$S,this.messages=[],e}else if(this.messages.length>0){let e=co(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,Kt(this.messages.pop());return $S}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 Twe=(e)=>Ot((t)=>xe(new vwe(t.currentScheduler,typeof e==="number"?e:e?.capacity??Number.POSITIVE_INFINITY,typeof e==="number"?"suspend":e?.strategy??"suspend")));var B8=(e)=>{let t=Lt(e.takeAll,([r,n])=>n?r.length===0?zi:wr(r):ih(wr(r),t));return t},Owe=(e)=>nP(B8(e));var Rot=E1;var Mwe=(e)=>Ee(e,Rot);var cf=Twe;var _we=B8,y1=Owe;var Fwe=/; *([!#$%&'*+.^\w`|~-]+)=("(?:[\v\u0020\u0021\u0023-\u005b\u005d-\u007e\u0080-\u00ff]|\\[\v\u0020-\u00ff])*"|[!#$%&'*+.^\w`|~-]+) */gu,Nwe=/\\([\v\u0020-\u00ff])/gu,vot=/^[!#$%&'*+.^\w|~-]+\/[!#$%&'*+.^\w|~-]+$/u,Tot=/^[!#$%&'*+.^\w|~-]+$/u,x1={value:"",parameters:Object.create(null)};function S1(e,t=!1){if(typeof e!=="string")return x1;let r=e.indexOf(";"),n=r!==-1?e.slice(0,r).trim():e.trim();if((t?Tot:vot).test(n)===!1)return x1;let i={value:n.toLowerCase(),parameters:Object.create(null)};if(r===-1)return i;let s,a,c;Fwe.lastIndex=r;while(a=Fwe.exec(e)){if(a.index!==r)return x1;if(r+=a[0].length,s=a[1].toLowerCase(),c=a[2],c[0]==='"')c=c.slice(1,c.length-1),!t&&Nwe.test(c)&&(c=c.replace(Nwe,"$1"));i.parameters[s]=c}if(r!==e.length)return x1;return i}var Pu;(function(e){e[e.key=0]="key",e[e.whitespace=1]="whitespace",e[e.value=2]="value"})(Pu||(Pu={}));var Tv={_tag:"Continue"},Mot=[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],_ot=[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 Lwe(){let e=new TextDecoder,t={state:Pu.key,headers:Object.create(null),key:"",value:void 0,crlf:0,previousChunk:void 0,pairs:0,size:0};function r(i){return t.state=Pu.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,i}function n(i,s){let a=new Uint8Array(i.length+s.length);return a.set(i),a.set(s,i.length),a}function o(i){return r({_tag:"Failure",reason:i,headers:t.headers})}return function(s,a){let c=0,l;if(t.previousChunk!==void 0){c=t.previousChunk.length,l=c;let p=new Uint8Array(s.length+c);p.set(t.previousChunk),p.set(s,c),t.previousChunk=void 0,s=p}let u=s.length;e:while(a<u){if(t.state===Pu.key){let p=a;for(;p<u;p++){if(t.size++>16384)return o("HeaderTooLarge");if(s[p]===58){if(t.key+=e.decode(s.subarray(a,p)).toLowerCase(),t.key.length===0)return o("InvalidHeaderName");if(s[p+1]===32&&s[p+2]!==32&&s[p+2]!==9)a=p+2,t.state=Pu.value,t.size++;else if(s[p+1]!==32&&s[p+1]!==9)a=p+1,t.state=Pu.value;else a=p+1,t.state=Pu.whitespace;break}else if(Mot[s[p]]!==1)return o("InvalidHeaderName")}if(p===u)return t.key+=e.decode(s.subarray(a,u)).toLowerCase(),Tv}if(t.state===Pu.whitespace){for(;a<u;a++){if(t.size++>16384)return o("HeaderTooLarge");if(s[a]!==32&&s[a]!==9){t.state=Pu.value;break}}if(a===u)return Tv}if(t.state===Pu.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(s[p]===13||t.crlf>0){let f=s[p];if(f===13&&t.crlf===0)t.crlf=1,p++,t.size++,f=s[p];if(f===10&&t.crlf===1)t.crlf=2,p++,t.size++,f=s[p];if(f===13&&t.crlf===2)t.crlf=3,p++,t.size++,f=s[p];if(f===10&&t.crlf===3)t.crlf=4,p++,t.size++;if(t.crlf<4&&p>=u)return t.previousChunk=s.subarray(a),Tv;else if(t.crlf>=2){t.value=t.value===void 0?s.subarray(a,p-t.crlf):n(t.value,s.subarray(a,p-t.crlf));let d=e.decode(t.value);if(t.headers[t.key]===void 0)t.headers[t.key]=d;else if(typeof t.headers[t.key]==="string")t.headers[t.key]=[t.headers[t.key],d];else t.headers[t.key].push(d);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=Pu.key;continue e}}else if(_ot[s[p]]!==1)return o("InvalidHeaderValue")}if(p===u)return t.value=t.value===void 0?s.subarray(a,u):n(t.value,s.subarray(a,u)),Tv}}if(a>u)t.size+=u-a;return Tv}}function Not(e){let t=new TextEncoder().encode(e),r=t.length,n={};for(let o=0;o<r;o++){let i=t[o];if(n[i]===void 0)n[i]=[];n[i].push(o)}return{needle:t,needleLength:r,indexes:n,firstByte:t[0],previousChunk:void 0,previousChunkLength:0,matchIndex:0}}function Uwe(e,t,r){let n=Not(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,d=p+n.needleLength-1;while(d<f){for(let A=n.needleLength-1,m=d;A>=0&&l[m]===u[A];A--,m--)if(A===0)return m;d+=c[l[d]]}return-1}}let i=o();function s(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=i(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]],d=-1;for(let A=0,m=f.length;A<m;A++){let g=f[A];if(c[l-1-g]===n.firstByte&&A>d)d=g}if(d===-1)if(u===0)t(n.matchIndex,c);else t(n.matchIndex,c.subarray(u));else{if(l-1-d>u)t(n.matchIndex,c.subarray(u,l-1-d));n.previousChunk=c.subarray(l-1-d),n.previousChunkLength=d+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:s,end:a}}var Nh;(function(e){e[e.headers=0]="headers",e[e.body=1]="body"})(Nh||(Nh={}));var Uot={_tag:"InvalidDisposition"},Pot={_tag:"EndNotReached"},Hot={_tag:"ReachedLimit",limit:"MaxParts"},Wot={_tag:"ReachedLimit",limit:"MaxTotalSize"},qot={_tag:"ReachedLimit",limit:"MaxPartSize"},Pwe={_tag:"ReachedLimit",limit:"MaxFieldSize"},Got=new TextEncoder().encode(`\r
|
|
197
|
+
`.repeat(Math.min(e.choices.length+2,e.maxPerPage))+e.message+1;return yi(o,r).pipe(te(n),fn(pn),zt({style:"pretty",options:{lineWidth:r}}))})}function cnt(e){return(t,r)=>{let n=e.choices.length+VIe;switch(t.key.name){case"k":case"up":return ont({...r,error:U()},n);case"j":case"down":case"tab":return int({...r,error:U()},n);case"space":return snt(r,e);case"enter":case"return":{let o=r.selectedIndices.size;if(e.min!==void 0&&o<e.min)return M(Oe.NextFrame({state:{...r,error:P(`At least ${e.min} are required`)}}));if(e.max!==void 0&&o>e.max)return M(Oe.NextFrame({state:{...r,error:P(`At most ${e.max} choices are allowed`)}}));let i=Array.from(r.selectedIndices).sort(nc).map((s)=>e.choices[s].value);return M(Oe.Submit({value:i}))}default:return M(Oe.Beep())}}}function lnt(e){return(t,r)=>Oe.$match(r,{Beep:()=>M(Zrt),NextFrame:({state:n})=>rnt(n,e),Submit:()=>nnt(t,e)})}var zIe=(e)=>{let t={maxPerPage:10,...e},r=new Set;for(let n=0;n<t.choices.length;n++)if(t.choices[n].selected===!0)r.add(n);return Hs({index:0,selectedIndices:r,error:U()},{render:lnt(t),process:cnt(t),clear:()=>ant(t)})};var pnt=WIe;var fnt=kCe;var NH=fl,YIe=zIe;var F5=Symbol.for("@effect/platform/CommandExecutor"),jIe=Symbol.for("@effect/platform/Process"),$Ie=tR(),JIe=tR(),UH=Qt("@effect/platform/CommandExecutor"),KIe=(e)=>{let t=(n)=>nd(K(e(n),(o)=>o.stdout)),r=(n,o)=>{let i=new TextDecoder(o);return eEe($ge(t(n),fA((s)=>i.decode(s))))};return{[F5]:F5,start:e,exitCode:(n)=>Tr(N(e(n),(o)=>o.exitCode)),stream:t,string:(n,o="utf-8")=>{let i=new TextDecoder(o);return x(e(n),N((s)=>rd(s.stdout,dnt)),K((s)=>i.decode(s)),Tr)},lines:(n,o="utf-8")=>x(r(n,o),Zge,K(Woe)),streamLines:r}},dnt=Lge(new Uint8Array,(e,t)=>KI(t,e,(r,n)=>{let o=new Uint8Array(r.length+n.length);return o.set(r),o.set(n,r.length),o}));var N5=Symbol.for("@effect/platform/Command");var PH=h(2,(e,t)=>{switch(e._tag){case"StandardCommand":return Ev({...e,env:Vie(e.env,Hm(Object.entries(t).filter(([r])=>r!==void 0)))});case"PipedCommand":return rbe(PH(e.left,t),PH(e.right,t))}});var XIe=(e)=>Array.from(L5(e)),L5=(e)=>{switch(e._tag){case"StandardCommand":return Kt(e);case"PipedCommand":return mn(L5(e.left),L5(e.right))}};var ebe={[N5]:N5,pipe(){return ue(this,arguments)},...Pc},Ant={...ebe,_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()}}},Ev=(e)=>Object.assign(Object.create(Ant),e),hnt={...ebe,_tag:"PipedCommand",toJSON(){return{_id:"@effect/platform/Command",_tag:this._tag,left:this.left.toJSON(),right:this.right.toJSON()}}},HH=(e)=>Object.assign(Object.create(hnt),e),tbe=(e,...t)=>Ev({command:e,args:t,env:ya(),cwd:U(),shell:!1,stdin:"pipe",stdout:"pipe",stderr:"pipe",gid:U(),uid:U()}),rbe=h(2,(e,t)=>HH({left:e,right:t})),U5=h(2,(e,t)=>{switch(e._tag){case"StandardCommand":return Ev({...e,stderr:t});case"PipedCommand":return HH({...e,right:U5(e.right,t)})}}),P5=h(2,(e,t)=>{switch(e._tag){case"StandardCommand":return Ev({...e,stdin:t});case"PipedCommand":return HH({...e,left:P5(e.left,t)})}}),H5=h(2,(e,t)=>{switch(e._tag){case"StandardCommand":return Ev({...e,stdout:t});case"PipedCommand":return HH({...e,right:H5(e.right,t)})}}),nbe=(e)=>N(UH,(t)=>t.start(e));var obe=PH;var W5=XIe;var vB=tbe;var gnt=nbe;var ibe=U5,WH=P5,sbe=H5;var gE=UH,q5=jIe,abe=$Ie,cbe=JIe,lbe=KIe;var G5=Symbol.for("@effect/platform/Cookies"),Ent=(e)=>Ee(e,G5),ube=Symbol.for("@effect/platform/Cookies/Cookie");var ynt={[G5]:G5,...Pc,toJSON(){return{_id:"@effect/platform/Cookies",cookies:aoe(this.cookies,(e)=>e.toJSON())}},pipe(){return ue(this,arguments)}},xnt=(e)=>{let t=Object.create(ynt);return t.cookies=e,t},fbe=(e)=>{let t={};for(let r of e)t[r.name]=r;return xnt(t)},OB=(e)=>{let t=typeof e==="string"?[e]:e,r=[];for(let n of t){let o=Snt(n.trim());if(ne(o))r.push(o.value)}return fbe(r)};function Snt(e){let t=e.split(";").map((a)=>a.trim()).filter((a)=>a!=="");if(t.length===0)return U();let r=t[0].indexOf("=");if(r===-1)return U();let n=t[0].slice(0,r);if(!Cnt.test(n))return U();let o=t[0].slice(r+1),i=Abe(o);if(t.length===1)return P(Object.assign(Object.create(pbe),{name:n,value:i,valueEncoded:o}));let s={};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)s.domain=f;break}case"expires":{if(p===void 0)break;let f=new Date(p);if(!isNaN(f.getTime()))s.expires=f;break}case"max-age":{if(p===void 0)break;let f=parseInt(p,10);if(!isNaN(f))s.maxAge=Yc(f);break}case"path":{if(p===void 0)break;if(p[0]==="/")s.path=p;break}case"priority":{if(p===void 0)break;switch(p.toLowerCase()){case"low":s.priority="low";break;case"medium":s.priority="medium";break;case"high":s.priority="high";break}break}case"httponly":{s.httpOnly=!0;break}case"secure":{s.secure=!0;break}case"partitioned":{s.partitioned=!0;break}case"samesite":{if(p===void 0)break;switch(p.toLowerCase()){case"lax":s.sameSite="lax";break;case"strict":s.sameSite="strict";break;case"none":s.sameSite="none";break}break}}}return P(Object.assign(Object.create(pbe),{name:n,value:i,valueEncoded:o,options:Object.keys(s).length>0?s:void 0}))}var Rh=fbe([]),V5=(e)=>KV(e.cookies),Cnt=/^[\u0009\u0020-\u007e\u0080-\u00ff]+$/,pbe={[ube]:ube,...Pc,toJSON(){return{_id:"@effect/platform/Cookies/Cookie",name:this.name,value:this.value,options:this.options}}};var Int=h((e)=>Ent(e[0]),(e,t)=>soe(e.cookies,t));function bnt(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=sk(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 qH=(e)=>Object.values(e.cookies).map(bnt);function dbe(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 i=e.indexOf("=",n);if(i===-1)break;if(i>o){n=o+1;continue}let s=e.substring(n,i++).trim();if(t[s]===void 0){let a=e.charCodeAt(i)===34?e.substring(i+1,o-1).trim():e.substring(i,o).trim();t[s]=a.indexOf("%")!==-1?Abe(a):a}n=o+1}return t}var Abe=(e)=>{try{return decodeURIComponent(e)}catch{return e}};var hbe=Symbol.for("@effect/platform/Headers");var yv=Object.assign(Object.create(null),{[hbe]:hbe,[qQ](e){return YS(this,RA(e,xv))}}),GH=(e)=>Object.assign(Object.create(yv),e);var ml=Object.create(yv),Oo=(e)=>{if(e===void 0)return ml;else if(Symbol.iterator in e){let r=Object.create(yv);for(let[n,o]of e)r[n.toLowerCase()]=o;return r}let t=Object.create(yv);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},vh=(e)=>Object.setPrototypeOf(e,yv);var yE=h(3,(e,t,r)=>{let n=GH(e);return n[t.toLowerCase()]=r,n}),z5=h(2,(e,t)=>GH({...e,...Oo(t)})),sf=h(2,(e,t)=>{let r=GH(e);return Object.assign(r,t),r}),Y5=h(2,(e,t)=>{let r=GH(e),n=(o)=>{if(typeof o==="string"){let i=o.toLowerCase();if(i in e)delete r[i]}else for(let i in e)if(o.test(i))delete r[i]};if(Array.isArray(t))for(let o=0;o<t.length;o++)n(t[o]);else n(t);return r}),YS=h(2,(e,t)=>{let r={...e},n=(o)=>{if(typeof o==="string"){let i=o.toLowerCase();if(i in e)r[i]=Fa(e[i])}else for(let i in e)if(o.test(i))r[i]=Fa(e[i])};if(Array.isArray(t))for(let o=0;o<t.length;o++)n(t[o]);else n(t);return r}),xv=We("@effect/platform/Headers/currentRedactedNames",()=>Iu(["authorization","cookie","set-cookie","x-api-key"]));var mbe=Symbol.for("@effect/platform/HttpClientError");var gbe=mbe;class gl extends sd(gbe,"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 Xo extends sd(gbe,"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 bd=(e)=>{let t=Ebe(e),r=[];for(let n=0;n<t.length;n++)if(Array.isArray(t[n][0])){let[o,i]=t[n];r.push([`${o[0]}[${o.slice(1).join("][")}]`,i])}else r.push(t[n]);return r},Ebe=(e)=>{let t=Symbol.iterator in e?ut(e):Object.entries(e),r=[];for(let[n,o]of t)if(Array.isArray(o)){for(let i=0;i<o.length;i++)if(o[i]!==void 0)r.push([n,String(o[i])])}else if(typeof o==="object"){let i=Ebe(o);for(let[s,a]of i)r.push([[n,...typeof s==="string"?[s]:s],a])}else if(o!==void 0)r.push([n,String(o)]);return r};var ybe=[];var xbe=h(2,(e,t)=>{let r=bd(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 j5=(e,t,r)=>{try{let n=new URL(e,Bnt());for(let o=0;o<t.length;o++){let[i,s]=t[o];if(s!==void 0)n.searchParams.append(i,s)}if(r._tag==="Some")n.hash=r.value;return je(n)}catch(n){return $e(n)}},Sbe=(e)=>new URLSearchParams(e).toString(),Bnt=()=>{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 Pa=Symbol.for("@effect/platform/HttpIncomingMessage"),Ws=(e,t)=>{let r=ir(e,t);return(n)=>N(n.json,r)};class xE extends Kn()("@effect/platform/HttpIncomingMessage/MaxBodySize",{defaultValue:U}){}var SE=(e,t)=>{let r=e.headers["content-type"]??"",n;if(r.includes("application/json"))try{n=or(e.json)}catch{}else if(r.includes("text/")||r.includes("urlencoded"))try{n=or(e.text)}catch{}let o={...t,headers:zl(e.headers),remoteAddress:e.remoteAddress.toJSON()};if(n!==void 0)o.body=n;return o};var Cbe=(e)=>vh({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"}`}),Ibe=(e)=>{let t=vnt(e);if(t._tag==="Some")return t;if(t=Qnt(e),t._tag==="Some")return t;return knt(e)},Qnt=(e)=>{if(!("b3"in e))return U();let t=e.b3.split("-");if(t.length<2)return U();return P(pN({traceId:t[0],spanId:t[1],sampled:t[2]?t[2]==="1":!0}))},knt=(e)=>{if(!e["x-b3-traceid"]||!e["x-b3-spanid"])return U();return P(pN({traceId:e["x-b3-traceid"],spanId:e["x-b3-spanid"],sampled:e["x-b3-sampled"]?e["x-b3-sampled"]==="1":!0}))},Dnt=/^[0-9a-f]{32}$/i,Rnt=/^[0-9a-f]{16}$/i,vnt=(e)=>{if(!e.traceparent)return U();let t=e.traceparent.split("-");if(t.length!==4)return U();let[r,n,o,i]=t;switch(r){case"00":{if(Dnt.test(n)===!1||Rnt.test(o)===!1)return U();return P(pN({traceId:n,spanId:o,sampled:(parseInt(i,16)&1)===1}))}default:return U()}};var VH=Symbol.for("@effect/platform/HttpBody"),$5=Symbol.for("@effect/platform/HttpBody/HttpBodyError"),Tnt=Hx("HttpBodyError"),wbe=(e)=>Tnt({[$5]:$5,reason:e});class zH{[VH];constructor(){this[VH]=VH}[lt](){return this.toJSON()}toString(){return St(this)}}class Bbe extends zH{_tag="Empty";toJSON(){return{_id:"@effect/platform/HttpBody",_tag:"Empty"}}}var MB=new Bbe;class Qbe extends zH{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 YH=(e,t)=>new Qbe(e,t?.contentType,t?.contentLength);class kbe extends zH{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 jH=(e,t)=>new kbe(e,t??"application/octet-stream"),Ont=new TextEncoder,_B=(e,t)=>jH(Ont.encode(e),t??"text/plain"),$H=(e,t)=>_B(JSON.stringify(e),t??"application/json"),JH=(e,t)=>qi({try:()=>$H(e,t),catch:(r)=>wbe({_tag:"JsonError",error:r})});var Dbe=Symbol.for("@effect/platform/HttpClientRequest"),Nnt={[Dbe]:Dbe,...Pc,toJSON(){return{_id:"@effect/platform/HttpClientRequest",method:this.method,url:this.url,urlParams:this.urlParams,hash:this.hash,headers:zl(this.headers),body:this.body.toJSON()}},pipe(){return ue(this,arguments)}};function wd(e,t,r,n,o,i){let s=Object.create(Nnt);return s.method=e,s.url=t,s.urlParams=r,s.hash=n,s.headers=o,s.body=i,s}var Lnt=wd("GET","",ybe,U(),ml,MB),Oh=(e)=>(t,r)=>Obe(Lnt,{method:e,url:t,...r??void 0}),KH=Oh("GET"),ZH=Oh("POST"),K5=Oh("PUT"),Z5=Oh("PATCH"),X5=Oh("DELETE"),e8=Oh("HEAD"),t8=Oh("OPTIONS"),Obe=h(2,(e,t)=>{let r=e;if(t.method)r=_be(r,t.method);if(t.url)r=n8(r,t.url);if(t.headers)r=Cv(r,t.headers);if(t.urlParams)r=o8(r,t.urlParams);if(t.hash)r=Nbe(r,t.hash);if(t.body)r=e1(r,t.body);if(t.accept)r=r8(r,t.accept);if(t.acceptJson)r=Mbe(r);return r}),XH=h(3,(e,t,r)=>wd(e.method,e.url,e.urlParams,e.hash,yE(e.headers,t,r),e.body)),Cv=h(2,(e,t)=>wd(e.method,e.url,e.urlParams,e.hash,z5(e.headers,t),e.body));var r8=h(2,(e,t)=>XH(e,"Accept",t)),Mbe=r8("application/json"),_be=h(2,(e,t)=>wd(t,e.url,e.urlParams,e.hash,e.headers,e.body)),n8=h(2,(e,t)=>{if(typeof t==="string")return wd(e.method,t,e.urlParams,e.hash,e.headers,e.body);let r=new URL(t.toString()),n=bd(r.searchParams),o=r.hash?P(r.hash.slice(1)):U();return r.search="",r.hash="",wd(e.method,r.toString(),n,o,e.headers,e.body)});var Fbe=h(2,(e,t)=>wd(e.method,t.endsWith("/")&&e.url.startsWith("/")?t+e.url.slice(1):t+e.url,e.urlParams,e.hash,e.headers,e.body));var o8=h(2,(e,t)=>wd(e.method,e.url,xbe(e.urlParams,t),e.hash,e.headers,e.body)),Nbe=h(2,(e,t)=>wd(e.method,e.url,e.urlParams,P(t),e.headers,e.body));var e1=h(2,(e,t)=>{let r=e.headers;if(t._tag==="Empty"||t._tag==="FormData")r=Y5(r,["Content-type","Content-length"]);else{let n=t.contentType;if(n)r=yE(r,"content-type",n);let o=t.contentLength;if(o)r=yE(r,"content-length",o.toString())}return wd(e.method,e.url,e.urlParams,e.hash,r,t)});var Lbe=h(2,(e,t)=>K(JH(t),(r)=>e1(e,r)));var Ube=h(2,(e,t)=>e1(e,_B(Sbe(bd(t)),"application/x-www-form-urlencoded")));var CE=Symbol.for("@effect/platform/HttpClientResponse"),i8=(e,t)=>new Hbe(e,t);class Hbe extends fp{request;source;[Pa];[CE];constructor(e,t){super();this.request=e,this.source=t,this[Pa]=Pa,this[CE]=CE}toJSON(){return SE(this,{_id:"@effect/platform/HttpClientResponse",request:this.request.toJSON(),status:this.status})}get status(){return this.source.status}get headers(){return Oo(this.source.headers)}cachedCookies;get cookies(){if(this.cachedCookies)return this.cachedCookies;return this.cachedCookies=OB(this.source.headers.getSetCookie())}get remoteAddress(){return U()}get stream(){return this.source.body?Yge(()=>this.source.body,(e)=>new Xo({request:this.request,response:this,reason:"Decode",cause:e})):cP(new Xo({request:this.request,response:this,reason:"EmptyBody",description:"can not create stream from empty body"}))}get json(){return vg(this.text,{try:(e)=>e===""?null:JSON.parse(e),catch:(e)=>new Xo({request:this.request,response:this,reason:"Decode",cause:e})})}textBody;get text(){return this.textBody??=Fn({try:()=>this.source.text(),catch:(e)=>new Xo({request:this.request,response:this,reason:"Decode",cause:e})}).pipe(Zc,or)}get urlParamsBody(){return N(this.text,(e)=>qi({try:()=>bd(new URLSearchParams(e)),catch:(t)=>new Xo({request:this.request,response:this,reason:"Decode",cause:t})}))}formDataBody;get formData(){return this.formDataBody??=Fn({try:()=>this.source.formData(),catch:(e)=>new Xo({request:this.request,response:this,reason:"Decode",cause:e})}).pipe(Zc,or)}arrayBufferBody;get arrayBuffer(){return this.arrayBufferBody??=Fn({try:()=>this.source.arrayBuffer(),catch:(e)=>new Xo({request:this.request,response:this,reason:"Decode",cause:e})}).pipe(Zc,or)}}var Wbe=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 Hnt=(e)=>`http.request.header.${e}`,Wnt="http.request.method",qnt=(e)=>`http.response.header.${e}`,Gnt="http.response.status_code",Vnt="server.address",znt="server.port",Ynt="url.full",jnt="url.path",$nt="url.scheme",Jnt="url.query",a8=Symbol.for("@effect/platform/HttpClient"),r1=Qt("@effect/platform/HttpClient"),l8=We(Symbol.for("@effect/platform/HttpClient/tracerDisabledWhen"),()=>Iu(In)),qbe=h(2,(e,t)=>o1(e,KA(l8,t))),u8=We(Symbol.for("@effect/platform/HttpClient/currentTracerPropagation"),()=>Iu(!0)),Gbe=h(2,(e,t)=>o1(e,KA(u8,t))),Vbe=Kn()("@effect/platform/HttpClient/SpanNameGenerator",{defaultValue:()=>(e)=>`http.client ${e.method}`});var Knt={[a8]:a8,pipe(){return ue(this,arguments)},...Pc,toJSON(){return{_id:"@effect/platform/HttpClient"}},get(e,t){return this.execute(KH(e,t))},head(e,t){return this.execute(e8(e,t))},post(e,t){return this.execute(ZH(e,t))},put(e,t){return this.execute(K5(e,t))},patch(e,t){return this.execute(Z5(e,t))},del(e,t){return this.execute(X5(e,t))},options(e,t){return this.execute(t8(e,t))}};var Iv=(e,t)=>{let r=Object.create(Knt);return r.preprocess=t,r.postprocess=e,r.execute=function(n){return e(t(n))},r},t1=We("@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)}}}),zbe=We("@effect/platform/HttpClient/scopedRequests",()=>new WeakMap),n1=(e)=>Iv((t)=>N(t,(r)=>_n((n)=>{let o=zbe.get(r),i=o??new AbortController,s=j5(r.url,r.urlParams,r.hash);if(s._tag==="Left")return se(new gl({request:r,reason:"InvalidUrl",cause:s.left}));let a=s.right;if(!n.getFiberRef(khe)||n.getFiberRef(l8)(r)){let u=e(r,a,i.signal,n);if(o)return u;return YA((p)=>uo(p(u),{onSuccess(f){return t1.register(f,i),M(new c8(f,i))},onFailure(f){if(zf(f))i.abort();return ln(f)}}))}let l=cr(n.currentContext,Vbe);return dw(l(r),{kind:"client",captureStackTrace:!1},(u)=>{if(u.attribute(Wnt,r.method),u.attribute(Vnt,a.origin),a.port!=="")u.attribute(znt,+a.port);u.attribute(Ynt,a.toString()),u.attribute(jnt,a.pathname),u.attribute($nt,a.protocol.slice(0,-1));let p=a.search.slice(1);if(p!=="")u.attribute(Jnt,p);let f=n.getFiberRef(xv),d=YS(r.headers,f);for(let A in d)u.attribute(Hnt(A),String(d[A]));return r=n.getFiberRef(u8)?Cv(r,Cbe(u)):r,YA((A)=>A(e(r,a,i.signal,n)).pipe(Zx(u),uo({onSuccess:(m)=>{u.attribute(Gnt,m.status);let g=YS(m.headers,f);for(let y in g)u.attribute(qnt(y),String(g[y]));if(o)return M(m);return t1.register(m,i),M(new c8(m,i))},onFailure(m){if(!o&&zf(m))i.abort();return ln(m)}})))})})),M);class c8{original;controller;constructor(e,t){this.original=e,this.controller=t}[CE]=CE;[Pa]=Pa;applyInterrupt(e){return Pe(()=>(t1.unregister(this.original),BL(e,()=>ge(()=>{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 tEe(()=>(t1.unregister(this.original),zge(this.original.stream,ge(()=>{this.controller.abort()}))))}toJSON(){return this.original.toJSON()}[lt](){return this.original[lt]()}}var Ybe=(e)=>jbe(e,(t,r)=>{let n=new AbortController;return zbe.set(r,n),be(QL((o)=>ea(o,ge(()=>n.abort()))),t)}),{del:Znt,execute:Xnt,get:eot,head:tot,options:rot,patch:not,post:oot,put:iot}=uAe(r1),jbe=h(2,(e,t)=>{let r=e;return Iv(N((n)=>t(r.postprocess(M(n)),n)),r.preprocess)});var o1=h(2,(e,t)=>{let r=e;return Iv((n)=>t(r.postprocess(n)),r.preprocess)});var $be=h(2,(e,t)=>{let r=e;return Iv(r.postprocess,(n)=>K(r.preprocess(n),t))});var i1=(e)=>bu(r1,N(wo(),(t)=>K(e,(r)=>o1(r,aw((n)=>On(t,n))))));var Kbe="@effect/platform/FetchHttpClient/Fetch",p8="@effect/platform/FetchHttpClient/FetchOptions",sot=n1((e,t,r,n)=>{let o=n.getFiberRef(Hp),i=o.unsafeMap.get(Kbe)??globalThis.fetch,s=o.unsafeMap.get(p8)??{},a=s.headers?sf(Oo(s.headers),e.headers):e.headers,c=(l)=>K(Fn({try:()=>i(t,{...s,method:e.method,headers:a,body:l,duplex:e.body._tag==="Stream"?"half":void 0,signal:r}),catch:(u)=>new gl({request:e,reason:"Transport",cause:u})}),(u)=>i8(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 N(rEe(e.body.stream),c)}return c(void 0)}),Zbe=i1(M(sot));class Xbe extends Fi(p8)(){}var cot=Zbe;var uot=YH;var Mh=r1;var s1=n1;var a1=$be;var pot=qbe;var fot=Gbe,c1=i1;var dot=Ybe;var El=Oh,f8=KH,FB=ZH;var bv=XH,d8=Cv;var l1=Fbe;var _h=o8;var yl=Lbe;var rwe=Ube;var IE=CE;var xl=Wbe;var wv=Symbol.for("@effect/platform/Etag/Generator"),NB=Qt("@effect/platform/Etag/Generator"),nwe=(e)=>{switch(e._tag){case"Weak":return`W/"${e.value}"`;case"Strong":return`"${e.value}"`}},owe=(e)=>{let t=e.mtime._tag==="Some"?e.mtime.value.getTime().toString(16):"0";return`${e.size.toString(16)}-${t}`},iwe=(e)=>`${e.size.toString(16)}-${e.lastModified.toString(16)}`,swe=ps(NB,NB.of({[wv]:wv,fromFileInfo(e){return ge(()=>({_tag:"Strong",value:owe(e)}))},fromFileWeb(e){return ge(()=>({_tag:"Strong",value:iwe(e)}))}})),awe=ps(NB,NB.of({[wv]:wv,fromFileInfo(e){return ge(()=>({_tag:"Weak",value:owe(e)}))},fromFileWeb(e){return ge(()=>({_tag:"Weak",value:iwe(e)}))}}));var A8=nwe;var cwe=NB,lwe=swe,h8=awe;var u1=Symbol.for("@effect/platform/HttpServerResponse"),hot=Symbol.for("@effect/platform/HttpServerRespondable");class Bv extends tj{status;statusText;cookies;body;[u1];headers;constructor(e,t,r,n,o){super();if(this.status=e,this.statusText=t,this.cookies=n,this.body=o,this[u1]=u1,o.contentType||o.contentLength){let i={...r};if(o.contentType)i["content-type"]=o.contentType;if(o.contentLength)i["content-length"]=o.contentLength.toString();this.headers=i}else this.headers=r}commit(){return M(this)}[hot](){return M(this)}[lt](){return this.toJSON()}toString(){return St(this)}toJSON(){return{_id:"@effect/platform/HttpServerResponse",status:this.status,statusText:this.statusText,headers:zl(this.headers),cookies:this.cookies.toJSON(),body:this.body.toJSON()}}}var Qv=(e)=>typeof e==="object"&&e!==null&&(u1 in e),LB=(e)=>new Bv(e?.status??204,e?.statusText,e?.headers?Oo(e.headers):ml,e?.cookies??Rh,MB),uwe=(e,t)=>{let r=vh({location:e.toString()});return new Bv(t?.status??302,t?.statusText,t?.headers?sf(r,Oo(t.headers)):r,t?.cookies??Rh,MB)};var pwe=(e,t)=>{let r=t?.headers?Oo(t.headers):ml;return new Bv(t?.status??200,t?.statusText,r,t?.cookies??Rh,_B(e,got(t,r)))};var mot=Qt("@effect/platform/HttpPlatform"),fwe=(e,t)=>N(mot,(r)=>r.fileResponse(e,t));var dwe=(e,t)=>new Bv(t?.status??200,t?.statusText,t?.headers?Oo(t.headers):ml,t?.cookies??Rh,YH(e,{contentType:t?.contentType,contentLength:t?.contentLength}));var got=(e,t)=>{if(e?.contentType)return e.contentType;else if(e?.headers)return t["content-type"];else return};var g8=Symbol.for("@effect/platform/HttpPlatform"),E8=Qt("@effect/platform/HttpPlatform"),hwe=(e)=>Y(function*(){let t=yield*lr,r=yield*cwe;return E8.of({[g8]:g8,fileResponse(n,o){return x(fAe(t.stat(n),"info"),pAe("etag",({info:i})=>r.fromFileInfo(i)),K(({etag:i,info:s})=>{let a=Number(o?.offset??0),c=o?.bytesToRead!==void 0?a+Number(o.bytesToRead):void 0,l=yE(o?.headers?Oo(o.headers):ml,"etag",A8(i));if(s.mtime._tag==="Some")l["last-modified"]=s.mtime.value.toUTCString();let u=c!==void 0?c-a:Number(s.size)-a;return e.fileResponse(n,o?.status??200,o?.statusText,l,a,c,u)}))},fileWebResponse(n,o){return K(r.fromFileWeb(n),(i)=>{let s=sf(o?.headers?Oo(o.headers):ml,vh({etag:A8(i),"last-modified":new Date(n.lastModified).toUTCString()}));return e.fileWebResponse(n,o?.status??200,o?.statusText,s,o)})}})});var y8=Symbol.for("@effect/platform/HttpServer"),mwe=Qt("@effect/platform/HttpServer"),yot={[y8]:y8};var gwe=(e)=>Object.assign(Object.create(yot),e);var x8=mwe,Ewe=gwe;var C8=Qv,bE=LB,Sot=uwe;var Cot=pwe;var I8=dwe;var Iot=fwe;var PB=Symbol.for("@effect/platform/HttpServerRespondable"),ywe=(e)=>Ee(e,PB),bot=bE({status:400}),wot=bE({status:404});var xwe=(e,t)=>{if(C8(e))return M(e);else if(ywe(e))return en(e[PB](),()=>M(t));else if(ww(e))return M(bot);else if(Spe(e))return M(wot);return M(t)},Swe=(e,t)=>{if(C8(e))return M(e);else if(ywe(e))return en(e[PB](),()=>M(t));return M(t)};var bwe=Symbol.for("@effect/platform/HttpServerError");var f1=We("@effect/platform/HttpServerError/clientAbortFiberId",()=>M_(-499,0)),wwe=(e)=>{let t=M(p1),r=Lx,n=!1,o=!1;ype(e,void 0,(a,c)=>{let l=HN(r)?Lx:r;switch(c._tag){case"Fail":{t=xwe(c.error,p1),r=Iwe(l,c);break}case"Die":{let u=Qv(c.defect);t=Swe(c.defect,p1),r=u?l:Iwe(l,c),o=o||u;break}case"Interrupt":{if(n=n||c.fiberId===f1,Cg(r)&&!o)r=c;break}}return U()});let i=!o&&HN(r)?M(n?Bot:Qot):t,s=!o&&HN(r)&&n?qb(f1):r;return K(i,(a)=>{if(Cg(s))return[a,Lx];return[a,Vf(s,sc(a))]})},Iwe=(e,t)=>{if(Cg(e))return t;else if(Cg(t))return e;return Vf(e,t)},Bwe=(e)=>{let t,r=Epe(e,(n)=>{if(Qv(n))return t=n,P(Lx);return U()});return[t??p1,r]},p1=LB({status:500}),Bot=LB({status:499}),Qot=LB({status:503}),Qwe=(e)=>{if(e._tag==="Success")return e.value;return Bwe(e.cause)[0]};var b8=bwe;class kv extends sd(b8,"RequestError"){[PB](){return bE({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 d1 extends sd(b8,"ResponseError"){[PB](){return bE({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 A1 extends sd(b8,"ServeError"){}var h1=f1,Dv=wwe;var kwe=Qwe;var E1=Symbol.for("effect/Mailbox"),w8=Symbol.for("effect/Mailbox/ReadonlyMailbox");var $S=Xr(),Dwe=kr($S),m1=kr(!1),g1=kr(!0),Rwe=[$S,!0];class vwe extends oc{scheduler;capacity;strategy;[E1]=E1;[w8]=w8;state={_tag:"Open",takers:new Set,offers:new Set,awaiters:new Set};messages=[];messagesChunk=Xr();constructor(e,t,r){super();this.scheduler=e,this.capacity=t,this.strategy=r}offer(e){return ct(()=>{if(this.state._tag!=="Open")return m1;else if(this.messages.length+this.messagesChunk.length>=this.capacity)switch(this.strategy){case"dropping":return m1;case"suspend":if(this.capacity<=0&&this.state.takers.size>0)return this.messages.push(e),this.releaseTaker(),g1;return this.offerRemainingSingle(e);case"sliding":return this.unsafeTake(),this.messages.push(e),g1}return this.messages.push(e),this.scheduleReleaseTaker(),g1})}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 ct(()=>{if(this.state._tag!=="Open")return xe(Ni(e));let t=this.unsafeOfferAllArray(e);if(t.length===0)return Dwe;else if(this.strategy==="dropping")return xe(co(t));return this.offerRemainingArray(t)})}unsafeOfferAll(e){return co(this.unsafeOfferAllArray(e))}unsafeOfferAllArray(e){if(this.state._tag!=="Open")return ut(e);else if(this.capacity===Number.POSITIVE_INFINITY||this.strategy==="sliding"){if(this.messages.length>0)this.messagesChunk=mn(this.messagesChunk,co(this.messages));if(this.strategy==="sliding")this.messagesChunk=this.messagesChunk.pipe(mn(Ni(e)),Sz(this.capacity));else if($y(e))this.messagesChunk=mn(this.messagesChunk,e);else this.messages=ut(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 ut(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(QA(e))}failCause(e){return this.done(br(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=he(()=>{if(this.state._tag==="Done")return!0;this.messages=[],this.messagesChunk=$S;let e=this.state.offers;if(this.finalize(this.state._tag==="Open"?bn:this.state.exit),e.size>0){for(let t of e)if(t._tag==="Single")t.resume(m1);else t.resume(kr(co(t.remaining.slice(t.offset))));e.clear()}return!0});done(e){return he(()=>this.unsafeDone(e))}end=this.done(bn);clear=ct(()=>{if(this.state._tag==="Done")return bb(this.state.exit,$S);let e=this.unsafeTakeAll();return this.releaseCapacity(),xe(e)});takeAll=ct(()=>{if(this.state._tag==="Done")return bb(this.state.exit,Rwe);let e=this.unsafeTakeAll();if(e.length===0)return Er(this.awaitTake,this.takeAll);return xe([e,this.releaseCapacity()])});takeN(e){return ct(()=>{if(this.state._tag==="Done")return bb(this.state.exit,Rwe);else if(e<=0)return xe([$S,!1]);e=Math.min(e,this.capacity);let t;if(e<=this.messagesChunk.length)t=jI(this.messagesChunk,e),this.messagesChunk=Sp(this.messagesChunk,e);else if(e<=this.messages.length+this.messagesChunk.length)this.messagesChunk=mn(this.messagesChunk,co(this.messages)),this.messages=[],t=jI(this.messagesChunk,e),this.messagesChunk=Sp(this.messagesChunk,e);else return Er(this.awaitTake,this.takeN(e));return xe([t,this.releaseCapacity()])})}unsafeTake(){if(this.state._tag==="Done")return QF(this.state.exit,QA(new xpe));let e;if(this.messagesChunk.length>0)e=JI(this.messagesChunk),this.messagesChunk=Sp(this.messagesChunk,1);else if(this.messages.length>0)e=this.messages[0],this.messagesChunk=Sp(co(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?kr(this.messages.pop()):void 0;else return;return this.releaseCapacity(),kr(e)}take=ct(()=>this.unsafeTake()??Er(this.awaitTake,this.take));await=vf((e)=>{if(this.state._tag==="Done")return e(this.state.exit);return this.state.awaiters.add(e),he(()=>{if(this.state._tag!=="Done")this.state.awaiters.delete(e)})});unsafeSize(){let e=this.messages.length+this.messagesChunk.length;return this.state._tag==="Done"?U():P(e)}size=he(()=>this.unsafeSize());commit(){return this.takeAll}pipe(){return ue(this,arguments)}toJSON(){return{_id:"effect/Mailbox",state:this.state._tag,size:this.unsafeSize().toJSON()}}toString(){return St(this)}[lt](){return St(this)}offerRemainingSingle(e){return vf((t)=>{if(this.state._tag!=="Open")return t(m1);let r={_tag:"Single",message:e,resume:t};return this.state.offers.add(r),he(()=>{if(this.state._tag==="Open")this.state.offers.delete(r)})})}offerRemainingArray(e){return vf((t)=>{if(this.state._tag!=="Open")return t(kr(co(e)));let r={_tag:"Array",remaining:e,offset:0,resume:t};return this.state.offers.add(r),he(()=>{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(g1),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(Dwe),this.state.offers.delete(t)}return!1}awaitTake=vf((e)=>{if(this.state._tag==="Done")return e(this.state.exit);return this.state.takers.add(e),he(()=>{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(bn),this.messages.length+this.messagesChunk.length===0)break};unsafeTakeAll(){if(this.messagesChunk.length>0){let e=this.messages.length>0?mn(this.messagesChunk,co(this.messages)):this.messagesChunk;return this.messagesChunk=$S,this.messages=[],e}else if(this.messages.length>0){let e=co(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,Kt(this.messages.pop());return $S}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 Twe=(e)=>Ot((t)=>xe(new vwe(t.currentScheduler,typeof e==="number"?e:e?.capacity??Number.POSITIVE_INFINITY,typeof e==="number"?"suspend":e?.strategy??"suspend")));var B8=(e)=>{let t=Lt(e.takeAll,([r,n])=>n?r.length===0?zi:wr(r):ih(wr(r),t));return t},Owe=(e)=>nP(B8(e));var Rot=E1;var Mwe=(e)=>Ee(e,Rot);var cf=Twe;var _we=B8,y1=Owe;var Fwe=/; *([!#$%&'*+.^\w`|~-]+)=("(?:[\v\u0020\u0021\u0023-\u005b\u005d-\u007e\u0080-\u{10ffff}]|\\[\v\u0020-\u{10ffff}])*"|[!#$%&'*+.^\w`|~-]+) */gu,Nwe=/\\([\v\u0020-\u{10ffff}])/gu,vot=/^[!#$%&'*+.^\w|~-]+\/[!#$%&'*+.^\w|~-]+$/u,Tot=/^[!#$%&'*+.^\w|~-]+$/u,x1={value:"",parameters:Object.create(null)};function S1(e,t=!1){if(typeof e!=="string")return x1;let r=e.indexOf(";"),n=r!==-1?e.slice(0,r).trim():e.trim();if((t?Tot:vot).test(n)===!1)return x1;let i={value:n.toLowerCase(),parameters:Object.create(null)};if(r===-1)return i;let s,a,c;Fwe.lastIndex=r;while(a=Fwe.exec(e)){if(a.index!==r)return x1;if(r+=a[0].length,s=a[1].toLowerCase(),c=a[2],c[0]==='"')c=c.slice(1,c.length-1),!t&&Nwe.test(c)&&(c=c.replace(Nwe,"$1"));i.parameters[s]=c}if(r!==e.length)return x1;return i}var Pu;(function(e){e[e.key=0]="key",e[e.whitespace=1]="whitespace",e[e.value=2]="value"})(Pu||(Pu={}));var Tv={_tag:"Continue"},Mot=[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],_ot=[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 Lwe(){let e=new TextDecoder,t={state:Pu.key,headers:Object.create(null),key:"",value:void 0,crlf:0,previousChunk:void 0,pairs:0,size:0};function r(i){return t.state=Pu.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,i}function n(i,s){let a=new Uint8Array(i.length+s.length);return a.set(i),a.set(s,i.length),a}function o(i){return r({_tag:"Failure",reason:i,headers:t.headers})}return function(s,a){let c=0,l;if(t.previousChunk!==void 0){c=t.previousChunk.length,l=c;let p=new Uint8Array(s.length+c);p.set(t.previousChunk),p.set(s,c),t.previousChunk=void 0,s=p}let u=s.length;e:while(a<u){if(t.state===Pu.key){let p=a;for(;p<u;p++){if(t.size++>16384)return o("HeaderTooLarge");if(s[p]===58){if(t.key+=e.decode(s.subarray(a,p)).toLowerCase(),t.key.length===0)return o("InvalidHeaderName");if(s[p+1]===32&&s[p+2]!==32&&s[p+2]!==9)a=p+2,t.state=Pu.value,t.size++;else if(s[p+1]!==32&&s[p+1]!==9)a=p+1,t.state=Pu.value;else a=p+1,t.state=Pu.whitespace;break}else if(Mot[s[p]]!==1)return o("InvalidHeaderName")}if(p===u)return t.key+=e.decode(s.subarray(a,u)).toLowerCase(),Tv}if(t.state===Pu.whitespace){for(;a<u;a++){if(t.size++>16384)return o("HeaderTooLarge");if(s[a]!==32&&s[a]!==9){t.state=Pu.value;break}}if(a===u)return Tv}if(t.state===Pu.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(s[p]===13||t.crlf>0){let f=s[p];if(f===13&&t.crlf===0)t.crlf=1,p++,t.size++,f=s[p];if(f===10&&t.crlf===1)t.crlf=2,p++,t.size++,f=s[p];if(f===13&&t.crlf===2)t.crlf=3,p++,t.size++,f=s[p];if(f===10&&t.crlf===3)t.crlf=4,p++,t.size++;if(t.crlf<4&&p>=u)return t.previousChunk=s.subarray(a),Tv;else if(t.crlf>=2){t.value=t.value===void 0?s.subarray(a,p-t.crlf):n(t.value,s.subarray(a,p-t.crlf));let d=e.decode(t.value);if(t.headers[t.key]===void 0)t.headers[t.key]=d;else if(typeof t.headers[t.key]==="string")t.headers[t.key]=[t.headers[t.key],d];else t.headers[t.key].push(d);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=Pu.key;continue e}}else if(_ot[s[p]]!==1)return o("InvalidHeaderValue")}if(p===u)return t.value=t.value===void 0?s.subarray(a,u):n(t.value,s.subarray(a,u)),Tv}}if(a>u)t.size+=u-a;return Tv}}function Not(e){let t=new TextEncoder().encode(e),r=t.length,n={};for(let o=0;o<r;o++){let i=t[o];if(n[i]===void 0)n[i]=[];n[i].push(o)}return{needle:t,needleLength:r,indexes:n,firstByte:t[0],previousChunk:void 0,previousChunkLength:0,matchIndex:0}}function Uwe(e,t,r){let n=Not(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,d=p+n.needleLength-1;while(d<f){for(let A=n.needleLength-1,m=d;A>=0&&l[m]===u[A];A--,m--)if(A===0)return m;d+=c[l[d]]}return-1}}let i=o();function s(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=i(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]],d=-1;for(let A=0,m=f.length;A<m;A++){let g=f[A];if(c[l-1-g]===n.firstByte&&A>d)d=g}if(d===-1)if(u===0)t(n.matchIndex,c);else t(n.matchIndex,c.subarray(u));else{if(l-1-d>u)t(n.matchIndex,c.subarray(u,l-1-d));n.previousChunk=c.subarray(l-1-d),n.previousChunkLength=d+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:s,end:a}}var Nh;(function(e){e[e.headers=0]="headers",e[e.body=1]="body"})(Nh||(Nh={}));var Uot={_tag:"InvalidDisposition"},Pot={_tag:"EndNotReached"},Hot={_tag:"ReachedLimit",limit:"MaxParts"},Wot={_tag:"ReachedLimit",limit:"MaxTotalSize"},qot={_tag:"ReachedLimit",limit:"MaxPartSize"},Pwe={_tag:"ReachedLimit",limit:"MaxFieldSize"},Got=new TextEncoder().encode(`\r
|
|
198
198
|
`);function Q8(e){return e.filename!==void 0||e.contentType==="application/octet-stream"}function Vot(e){return S1(e["content-type"]).parameters.boundary}function C1(e){}function Wwe({headers:e,onFile:t,onField:r,onError:n,onDone:o,isFile:i=Q8,maxParts:s=1/0,maxTotalSize:a=1/0,maxPartSize:c=1/0,maxFieldSize:l=1048576}){let u=Vot(e);if(u===void 0)return n({_tag:"InvalidBoundary"}),{write:C1,end(){}};let p={state:Nh.headers,index:0,parts:0,onChunk:C1,info:void 0,headerSkip:0,partSize:0,totalSize:0,isFile:!1,fieldChunks:[],fieldSize:0};function f(){p.state=Nh.body,p.isFile=!0,p.onChunk=C1}let d=Lwe(),A=Uwe(`\r
|
|
199
199
|
--${u}`,function(m,g){if(m===0){f();return}else if(m!==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),w=0;for(let b=0;b<p.fieldChunks.length;b++){let D=p.fieldChunks[b];y.set(D,w),w+=D.length}r(p.info,y)}p.fieldSize=0,p.fieldChunks=[]}if(p.state=Nh.headers,p.index=m,p.headerSkip=2,g[0]===45&&g[1]===45)return o();if(p.parts++,p.parts>s)n(Hot)}if((p.partSize+=g.length)>c)n(qot);if(p.state===Nh.headers){let y=d(g,p.headerSkip);if(p.headerSkip=0,y._tag==="Continue")return;else if(y._tag==="Failure")return f(),n({_tag:"BadHeaders",error:y});let w=S1(y.headers["content-type"]),b=S1(y.headers["content-disposition"],!0);if(b.value==="form-data"&&!("name"in b.parameters))return f(),n(Uot);let D;if("filename*"in b.parameters){let k=b.parameters["filename*"].split("''");if(k.length===2)D=decodeURIComponent(k[1])}if(p.info={name:b.parameters.name??"",filename:D??b.parameters.filename,contentType:w.value===""?b.parameters.filename!==void 0?"application/octet-stream":"text/plain":w.value,contentTypeParameters:w.parameters,contentDisposition:b.value,contentDispositionParameters:b.parameters,headers:y.headers},p.state=Nh.body,p.isFile=i(p.info),p.isFile)p.onChunk=t(p.info);if(y.endPosition<g.length)if(p.isFile)p.onChunk(g.subarray(y.endPosition));else{let k=g.subarray(y.endPosition);if((p.fieldSize+=k.length)>l)n(Pwe);p.fieldChunks.push(k)}}else if(p.isFile)p.onChunk(g);else{if((p.fieldSize+=g.length)>l)n(Pwe);p.fieldChunks.push(g)}},Got);return{write(m){if((p.totalSize+=m.length)>a)return n(Wot);return A.write(m)},end(){if(A.end(),p.state===Nh.body)n(Pot);p.state=Nh.headers,p.index=0,p.parts=0,p.onChunk=C1,p.info=void 0,p.totalSize=0,p.partSize=0,p.fieldChunks=[],p.fieldSize=0}}}var Hwe=new TextDecoder("utf-8");function zot(e){if(e==="utf-8"||e==="utf8"||e==="")return Hwe;try{return new TextDecoder(e)}catch(t){return Hwe}}function qwe(e,t){return zot(e.contentTypeParameters.charset??"utf-8").decode(t)}var k8=Wwe,Gwe=Q8,D8=qwe;var JS=Symbol.for("@effect/platform/Multipart");var zwe=Symbol.for("@effect/platform/Multipart/MultipartError");class Sl extends et()("MultipartError",{reason:V("FileTooLarge","FieldTooLarge","BodyTooLarge","TooManyParts","InternalError","Parse"),cause:Vt}){[zwe]=zwe;get message(){return this.reason}}var Ywe=(e)=>_n((t)=>{let r=cr(t.currentContext,eBe);return M({headers:e,maxParts:At(cr(t.currentContext,Kwe)),maxFieldSize:Number(cr(t.currentContext,Zwe)),maxPartSize:cr(t.currentContext,Xwe).pipe(Gt(Number),At),maxTotalSize:cr(t.currentContext,xE).pipe(Gt(Number),At),isFile:r.length===0?void 0:(n)=>!Cz(r,(o)=>n.contentType.includes(o))&&Gwe(n)})});class jwe extends fp{[JS];constructor(){super();this[JS]=JS}}var jot=(e,t)=>N(lr,(r)=>fe(rd(t.content,r.sink(e)),(n)=>new Sl({reason:"InternalError",cause:n})));var $we=(e,t=jot)=>Y(function*(){let r=yield*lr,n=yield*sr,o=yield*r.makeTempDirectoryScoped(),i=Object.create(null);return yield*IR(e,(s)=>{if(s._tag==="Field"){if(!(s.key in i))i[s.key]=s.value;else if(typeof i[s.key]==="string")i[s.key]=[i[s.key],s.value];else i[s.key].push(s.value);return Z}else if(s.name==="")return Z;let a=s,c=n.join(o,n.basename(a.name).slice(-128)),l=new Jwe(a.key,a.name,a.contentType,c);if(Array.isArray(i[s.key]))i[s.key].push(l);else i[s.key]=[l];return t(c,a)}),i}).pipe(ow({SystemError:(r)=>se(new Sl({reason:"InternalError",cause:r})),BadArgument:(r)=>se(new Sl({reason:"InternalError",cause:r}))}));class Jwe extends jwe{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 Kwe extends Kn()("@effect/platform/Multipart/MaxParts",{defaultValue:U}){}class Zwe extends Kn()("@effect/platform/Multipart/MaxFieldSize",{defaultValue:Lc(ad(10485760))}){}class Xwe extends Kn()("@effect/platform/Multipart/MaxFileSize",{defaultValue:U}){}class eBe extends Kn()("@effect/platform/Multipart/FieldMimeTypes",{defaultValue:Lc(vm("application/json"))}){}var R8=Symbol.for("effect/FiberSet"),Jot=(e)=>Ee(e,R8),Kot={[R8]:R8,[Symbol.iterator](){if(this.state._tag==="Closed")return YM();return this.state.backing[Symbol.iterator]()},toString(){return St(this.toJSON())},toJSON(){return{_id:"FiberMap",state:this.state}},[lt](){return this.toJSON()},pipe(){return ue(this,arguments)}},Zot=(e,t)=>{let r=Object.create(Kot);return r.state={_tag:"Open",backing:e},r.deferred=t,r},wE=()=>vr(K(Yr(),(e)=>Zot(new Set,e)),(e)=>_n((t)=>{let r=e.state;if(r._tag==="Closed")return Z;e.state={_tag:"Closed"};let n=r.backing;return eL(n,bp(t.id(),oBe)).pipe(jx(e.deferred))})),rBe=()=>N(wE(),(e)=>Ov(e)());var nBe=-1,oBe=hA(nBe,0),Xot=GN(void 0,{emptyCase:In,failCase:In,dieCase:In,interruptCase:(e,t)=>Lm(rx(t),nBe),sequentialCase:(e,t,r)=>t||r,parallelCase:(e,t,r)=>t||r}),KS=h((e)=>Jot(e[0]),(e,t,r)=>{if(e.state._tag==="Closed"){t.unsafeInterruptAsFork(bp(r?.interruptAs??Io,oBe));return}else if(e.state.backing.has(t))return;e.state.backing.add(t),t.addObserver((n)=>{if(e.state._tag==="Closed")return;if(e.state.backing.delete(t),$o(n)&&(r?.propagateInterruption===!0?!Xot(n.cause):!Yf(n.cause)))Pi(e.deferred,n)})});var iBe=function(){let e=void 0;return()=>{if(e===void 0)e=hu(Gi);return e}}(),sBe=function(){let e=arguments[0];if(!cn(arguments[1])){let t=arguments[1];return(r)=>tBe(e,r,t)}return tBe(e,arguments[1],arguments[2])},tBe=(e,t,r)=>vD((n)=>{if(e.state._tag==="Closed")return ge(iBe);return nr(zx(t),(o)=>KS(e,o,{...r,interruptAs:n}))}),Ov=(e)=>()=>K(Ra(),(t)=>{let r=Yi(t);return(n,o)=>{if(e.state._tag==="Closed")return iBe();let i=r(n,o);return KS(e,i),i}});var Mv=(e)=>er(e.deferred),eit=(e)=>JA({while:()=>e.state._tag==="Open"&&e.state.backing.size>0,body:()=>PA(JV(e)),step:No});var aBe=Symbol.for("@effect/platform/Socket");var cBe=Qt("@effect/platform/Socket"),tit=Symbol.for("@effect/platform/Socket/CloseEvent");var lBe=(e)=>Ee(e,tit),v8=Symbol.for("@effect/platform/Socket/SocketError"),rit=(e)=>Ee(e,v8);class I1 extends sd(v8,"SocketError"){get message(){return`An error occurred during ${this.reason}`}}class b1 extends sd(v8,"SocketError"){static is(e){return rit(e)&&e.reason==="Close"}static isClean(e){return function(t){return b1.is(t)&&e(t.code)}}get message(){if(this.closeReason)return`${this.reason}: ${this.code}: ${this.closeReason}`;return`${this.reason}: ${this.code}`}}var nit=(e)=>e!==1000&&e!==1006,oit=Qt("@effect/platform/Socket/WebSocket");var T8=(e,t)=>_n((r)=>{let n,o=ol(!1),i=r.currentContext,s=t?.closeCodeIsError??nit,a=(f,d)=>sw(Ce(function*(A){let m=yield*wE().pipe(_p(A)),g=yield*_p(e,A),y=yield*jr(Ov(m)(),oit,g),w=!1;function b(B){if(B.data instanceof Blob)return rw(()=>B.data.arrayBuffer()).pipe(AAe((Q)=>f(new Uint8Array(Q))),y);let S=f(B.data);if(cn(S))y(S)}function D(B){g.removeEventListener("message",b),g.removeEventListener("close",k),Pi(m.deferred,se(new I1({reason:w?"Read":"Open",cause:B})))}function k(B){g.removeEventListener("message",b),g.removeEventListener("error",D),Pi(m.deferred,se(new b1({reason:"Close",code:B.code,closeReason:B.reason})))}if(g.addEventListener("close",k,{once:!0}),g.addEventListener("error",D,{once:!0}),g.addEventListener("message",b),g.readyState!==1){let B=Jde(r.id());g.addEventListener("open",()=>{w=!0,Pi(B,Z)},{once:!0}),yield*er(B).pipe(TD({duration:t?.openTimeout??1e4,onTimeout:()=>new I1({reason:"OpenTimeout",cause:'timeout waiting for "open"'})}),lw(Mv(m)))}if(w=!0,n=g,yield*o.open,d?.onOpen)yield*d.onOpen;return yield*Mv(m).pipe(nw(b1.isClean((B)=>!s(B)),(B)=>Z))})).pipe(aw((A)=>On(i,A)),mi(ge(()=>{o.unsafeClose(),n=void 0})),Rr),c=new TextEncoder,l=(f,d)=>a((A)=>typeof A==="string"?f(c.encode(A)):A instanceof Uint8Array?f(A):f(new Uint8Array(A)),d),p=M((f)=>o.whenOpen(ge(()=>{let d=n;if(lBe(f))d.close(f.code,f.reason);else d.send(f)})));return M(cBe.of({[aBe]:aBe,run:l,runRaw:a,writer:p}))});var uBe=Symbol.for("@effect/platform/HttpServerRequest"),pBe=Qt("@effect/platform/HttpServerRequest");var fBe=(e)=>{let t=e.headers.host??"localhost",r=e.headers["x-forwarded-proto"]==="https"?"https":"http";try{return P(new URL(e.url,`${r}://${t}`))}catch{return U()}};var w1=uBe,lf=pBe;var dBe=fBe;import*as k1 from"node:child_process";var Sn=(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 ji({reason:o,module:e,method:t,pathOrDescriptor:n,syscall:r.syscall,description:r.message,cause:r})};import{Readable as sit}from"node:stream";var Lh=(e,t,r)=>ES(hBe(e,t,r)),ABe=(e,t)=>{let r=t.maxBytes?Number(t.maxBytes):void 0;return Kf(ge(()=>{let n=e();return n.setEncoding(t.encoding??"utf8"),n}),(n)=>qr((o)=>{let i="",s=0;n.once("error",(a)=>{o(se(t.onFailure(a)))}),n.once("end",()=>{o(M(i))}),n.on("data",(a)=>{if(i+=a,s+=Buffer.byteLength(a),r&&s>r)o(se(t.onFailure(Error("maxBytes exceeded"))))})}),(n)=>ge(()=>{if("closed"in n&&!n.closed)n.destroy()}))},B1=(e,t)=>{let r=t.maxBytes?Number(t.maxBytes):void 0;return Kf(ge(e),(n)=>qr((o)=>{let i=Buffer.alloc(0),s=0;n.once("error",(a)=>{o(se(t.onFailure(a)))}),n.once("end",()=>{o(M(i))}),n.on("data",(a)=>{if(i=Buffer.concat([i,a]),s+=a.length,r&&s>r)o(se(t.onFailure(Error("maxBytes exceeded"))))})}),(n)=>ge(()=>{if("closed"in n&&!n.closed)n.destroy()}))};var hBe=(e,t,r)=>M3(()=>cit(e(),t,Zl(void 0),r)),mBe=(e,t,{encoding:r,endOnDone:n=!0}={},o=Z)=>{let i=ait(e,r),s=n?qr((a)=>{if("closed"in e&&e.closed)a(Z);else e.once("finish",()=>a(Z)),e.end()}):Z;return{awaitRead:()=>Z,emit:i,error:(a)=>be(s,t(a)),done:(a)=>be(s,o)}},ait=(e,t)=>(r)=>r.length===0?Z:qr((n)=>{let o=r[Symbol.iterator](),i=o.next();function s(){let a=i;i=o.next();let c=e.write(a.value,t);if(i.done)n(Z);else if(c)s();else e.once("drain",s)}s()}),cit=(e,t,r,n)=>{if(!e.readable)return CR;let o=ol(!1);function i(){o.unsafeOpen()}function s(u){r.current=Hf(t(u)),o.unsafeOpen()}function a(){r.current=lu,o.unsafeOpen()}e.on("readable",i),e.on("error",s),e.on("end",a);let c=n?.chunkSize?Number(n.chunkSize):void 0,l=M3(function u(){let p=e.read(c);if(p===null){if(r.current)return Fge(r.current);return o.unsafeClose(),Gg(o.await,u)}let f=[p];while(!0){if(p=e.read(c),p===null)return Gg(iP(co(f)),u);f.push(p)}});return _ge(l,ge(()=>{if(e.off("readable",i),e.off("error",s),e.off("end",a),n?.closeOnDone!==!1&&"closed"in e&&!e.closed)e.destroy()}))};class gBe extends sit{readLatch;fiber=void 0;constructor(e,t){super({});this.readLatch=ol(!1),this.fiber=Yi(e)(this.readLatch.whenOpen(yS(t,(r)=>this.readLatch.whenOpen(ge(()=>{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,cu(r))this.push(null);else this.destroy(Ba(r.cause))})}_read(e){this.readLatch.unsafeOpen()}_destroy(e,t){if(!this.fiber)return t(e);hu(Qa(this.fiber)).addObserver((r)=>{t(r._tag==="Failure"?Ba(r.cause):e)})}}var EBe=(e)=>K(Ra(),(t)=>new gBe(t,e));var Q1=(e,t,r)=>Pge(xBe(e,t,r)),xBe=(e,t,r)=>Gg(il(ge(()=>e()),Yr()),([n,o])=>O3(lit(n,o,t),mBe(n,(i)=>$f(o,i),r,EL(o,Z)))),lit=(e,t,r)=>Pe(()=>{function n(o){Pi(t,se(r(o)))}return e.on("error",n),mi(er(t),ge(()=>{e.removeListener("error",n)}))});var pit=(e)=>typeof e==="string"?e:"pipe",SBe=(e)=>typeof e==="string"?e:"pipe",Fv=(e)=>e instanceof globalThis.Error?e:new globalThis.Error(String(e)),BE=(e,t,r)=>{let n=W5(r).reduce((o,i)=>{let s=`${i.command} ${i.args.join(" ")}`;return o.length===0?s:`${o} | ${s}`},"");return Sn("Command",e)(t,[n])},fit={[q5]:q5,...Pc,toJSON(){return{_id:"@effect/platform/CommandExecutor/Process",pid:this.pid}}},Nv=(e)=>(t)=>{switch(t._tag){case"StandardCommand":{let r=N(Yr(),(i)=>qr((s)=>{let a=k1.spawn(t.command,t.args,{stdio:[pit(t.stdin),SBe(t.stdout),SBe(t.stderr)],cwd:Ue(t.cwd,TI),shell:t.shell,env:{...process.env,...Object.fromEntries(t.env)},detached:process.platform!=="win32"});return a.on("error",(c)=>{s(se(BE("spawn",c,t)))}),a.on("exit",(...c)=>{Pi(i,M(c))}),a.on("spawn",()=>{s(M([a,i]))}),ge(()=>{a.kill("SIGTERM")})})),n=process.platform==="win32"?(i,s)=>qr((a)=>{k1.exec(`taskkill /pid ${i.pid} /T /F`,(c)=>{if(c)a(se(BE("kill",Fv(c),t)));else a(Z)})}):(i,s)=>qi({try:()=>process.kill(-i.pid,s),catch:(a)=>BE("kill",Fv(a),t)}),o=(i,s)=>Pe(()=>i.kill(s)?Z:se(BE("kill",new globalThis.Error("Failed to kill process"),t)));return x(Te(t.cwd,{onNone:()=>Z,onSome:(i)=>e.access(i)}),be(vr(r,([i,s])=>N(WA(s),(a)=>{if(!a)return n(i,"SIGTERM").pipe(Tg(()=>o(i,"SIGTERM")),be(er(s)),tn);return N(er(s),([c])=>{if(c!==0&&c!==null)return n(i,"SIGTERM").pipe(tn);return Z})}))),K(([i,s])=>{let a=Nge;if(i.stdin!==null)a=Q1(()=>i.stdin,(A)=>BE("toWritable",Fv(A),t));let c=N(er(s),([A,m])=>{if(A!==null)return M(abe(A));return se(BE("exitCode",new globalThis.Error(`Process interrupted due to receipt of signal: ${m}`),t))}),l=aAe(WA(s)),u=(A="SIGTERM")=>n(i,A).pipe(Tg(()=>o(i,A)),be(ra(er(s)))),p=cbe(i.pid),f=Lh(()=>i.stderr,(A)=>BE("fromReadable(stderr)",Fv(A),t)),d=Lh(()=>i.stdout,(A)=>BE("fromReadable(stdout)",Fv(A),t));if(typeof t.stdout!=="string")d=nEe(d,t.stdout);return Object.assign(Object.create(fit),{pid:p,exitCode:c,isRunning:l,kill:u,stdin:a,stderr:f,stdout:d})}),typeof t.stdin==="string"?me:nr((i)=>zx(rd(t.stdin,i.stdin))))}case"PipedCommand":{let r=W5(t);if(r.length===1)return x(r[0],Nv(e));let n=r[0],o=r.slice(1),i=o.slice(0,o.length-1),s=o[o.length-1],a=i.reduce((c,l)=>x(WH(l,c),Nv(e),K((u)=>u.stdout),nd),x(Nv(e)(n),K((c)=>c.stdout),nd));return x(WH(s,a),Nv(e))}}},CBe=bu(gE,x(lr,K((e)=>lbe(Nv(e)))));var D1=CBe;var Ait=D1;var wBe=(e,t,r)=>(...n)=>qr((o)=>{try{e(...n,(i,s)=>{if(i)o(se(t?t(i,n):i));else o(M(s))})}catch(i){o(r?se(r(i,n)):Hi(i))}});var go=wBe;import*as BBe from"node:crypto";import*as gt from"node:fs";import*as QBe from"node:os";import*as WB from"node:path";var ro=(e)=>(t)=>new Na({module:"FileSystem",method:e,cause:t}),mit=(()=>{let e=go(gt.access,Sn("FileSystem","access"),ro("access"));return(t,r)=>{let n=gt.constants.F_OK;if(r?.readable)n|=gt.constants.R_OK;if(r?.writable)n|=gt.constants.W_OK;return e(t,n)}})(),git=(()=>{let e=go(gt.cp,Sn("FileSystem","copy"),ro("copy"));return(t,r,n)=>e(t,r,{force:n?.overwrite??!1,preserveTimestamps:n?.preserveTimestamps??!1,recursive:!0})})(),Eit=(()=>{let e=go(gt.copyFile,Sn("FileSystem","copyFile"),ro("copyFile"));return(t,r)=>e(t,r)})(),yit=(()=>{let e=go(gt.chmod,Sn("FileSystem","chmod"),ro("chmod"));return(t,r)=>e(t,r)})(),xit=(()=>{let e=go(gt.chown,Sn("FileSystem","chown"),ro("chown"));return(t,r,n)=>e(t,r,n)})(),Sit=(()=>{let e=go(gt.link,Sn("FileSystem","link"),ro("link"));return(t,r)=>e(t,r)})(),Cit=(()=>{let e=go(gt.mkdir,Sn("FileSystem","makeDirectory"),ro("makeDirectory"));return(t,r)=>e(t,{recursive:r?.recursive??!1,mode:r?.mode})})(),M8=(e)=>{let t=go(gt.mkdtemp,Sn("FileSystem",e),ro(e));return(r)=>Pe(()=>{let n=r?.prefix??"",o=typeof r?.directory==="string"?WB.join(r.directory,"."):QBe.tmpdir();return t(n?WB.join(o,n):o+"/")})},Iit=M8("makeTempDirectory"),_8=(e)=>{let t=go(gt.rm,Sn("FileSystem",e),ro(e));return(r,n)=>t(r,{recursive:n?.recursive??!1,force:n?.force??!1})},bit=_8("remove"),wit=(()=>{let e=M8("makeTempDirectoryScoped"),t=_8("makeTempDirectoryScoped");return(r)=>vr(e(r),(n)=>tr(t(n,{recursive:!0})))})(),kBe=(e)=>{let t=go(gt.open,Sn("FileSystem",e),ro(e)),r=go(gt.close,Sn("FileSystem",e),ro(e));return(n,o)=>x(vr(t(n,o?.flag??"r",o?.mode),(i)=>tr(r(i))),K((i)=>Qit(qye(i),o?.flag?.startsWith("a")??!1)))},Bit=kBe("open"),Qit=(()=>{let e=(u)=>go(gt.read,Sn("FileSystem",u),ro(u)),t=e("read"),r=e("readAlloc"),n=go(gt.fstat,Sn("FileSystem","stat"),ro("stat")),o=go(gt.ftruncate,Sn("FileSystem","truncate"),ro("truncate")),i=go(gt.fsync,Sn("FileSystem","sync"),ro("sync")),s=(u)=>go(gt.write,Sn("FileSystem",u),ro(u)),a=s("write"),c=s("writeAll");class l{fd;append;[TP];semaphore=fw(1);position=0n;constructor(u,p){this.fd=u,this.append=p,this[TP]=TP}get stat(){return K(n(this.fd),RBe)}get sync(){return i(this.fd)}seek(u,p){let f=ad(u);return this.semaphore.withPermits(1)(ge(()=>{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)(K(Pe(()=>t(this.fd,{buffer:u,position:this.position})),(p)=>{let f=ad(p);return this.position=this.position+f,f}))}readAlloc(u){let p=Number(u);return this.semaphore.withPermits(1)(N(ge(()=>Buffer.allocUnsafeSlow(p)),(f)=>K(r(this.fd,{buffer:f,position:this.position}),(d)=>{if(d===0)return U();if(this.position=this.position+BigInt(d),d===p)return P(f);let A=Buffer.allocUnsafeSlow(d);return f.copy(A,0,0,d),P(A)})))}truncate(u){return this.semaphore.withPermits(1)(K(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)(K(Pe(()=>a(this.fd,u,void 0,void 0,this.append?void 0:Number(this.position))),(p)=>{let f=ad(p);if(!this.append)this.position=this.position+f;return f}))}writeAllChunk(u){return N(Pe(()=>c(this.fd,u,void 0,void 0,this.append?void 0:Number(this.position))),(p)=>{if(p===0)return se(new ji({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)):Z})}writeAll(u){return this.semaphore.withPermits(1)(this.writeAllChunk(u))}}return(u,p)=>new l(u,p)})(),DBe=(e)=>{let t=M8(e),r=kBe(e),n=(o)=>ge(()=>BBe.randomBytes(o).toString("hex"));return(o)=>x(il(t(o),n(6)),K(([i,s])=>WB.join(i,s+(o?.suffix??""))),nr((i)=>Tr(r(i,{flag:"w+"}))))},kit=DBe("makeTempFile"),Dit=(()=>{let e=DBe("makeTempFileScoped"),t=_8("makeTempFileScoped");return(r)=>vr(e(r),(n)=>tr(t(WB.dirname(n),{recursive:!0})))})(),Rit=(e,t)=>Fn({try:()=>gt.promises.readdir(e,t),catch:(r)=>Sn("FileSystem","readDirectory")(r,[e])}),vit=(e)=>qr((t,r)=>{try{gt.readFile(e,{signal:r},(n,o)=>{if(n)t(se(Sn("FileSystem","readFile")(n,[e])));else t(M(o))})}catch(n){t(se(ro("readFile")(n)))}}),Tit=(()=>{let e=go(gt.readlink,Sn("FileSystem","readLink"),ro("readLink"));return(t)=>e(t)})(),Oit=(()=>{let e=go(gt.realpath,Sn("FileSystem","realPath"),ro("realPath"));return(t)=>e(t)})(),Mit=(()=>{let e=go(gt.rename,Sn("FileSystem","rename"),ro("rename"));return(t,r)=>e(t,r)})(),RBe=(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:vt(e.mtime),atime:vt(e.atime),birthtime:vt(e.birthtime),dev:e.dev,rdev:vt(e.rdev),ino:vt(e.ino),mode:e.mode,nlink:vt(e.nlink),uid:vt(e.uid),gid:vt(e.gid),size:ad(e.size),blksize:Gt(vt(e.blksize),ad),blocks:vt(e.blocks)}),F8=(()=>{let e=go(gt.stat,Sn("FileSystem","stat"),ro("stat"));return(t)=>K(e(t),RBe)})(),_it=(()=>{let e=go(gt.symlink,Sn("FileSystem","symlink"),ro("symlink"));return(t,r)=>e(t,r)})(),Fit=(()=>{let e=go(gt.truncate,Sn("FileSystem","truncate"),ro("truncate"));return(t,r)=>e(t,r!==void 0?Number(r):void 0)})(),Nit=(()=>{let e=go(gt.utimes,Sn("FileSystem","utime"),ro("utime"));return(t,r,n)=>e(t,r,n)})(),Lit=(e,t)=>Wge((r)=>vr(ge(()=>{let n=gt.watch(e,{recursive:t?.recursive},(o,i)=>{if(!i)return;switch(o){case"rename":{r.fromEffect(Bo(F8(i),{onSuccess:(s)=>M(Gye({path:i})),onFailure:(s)=>s._tag==="SystemError"&&s.reason==="NotFound"?M(zye({path:i})):se(s)}));return}case"change":{r.single(Vye({path:i}));return}}});return n.on("error",(o)=>{r.fail(new ji({module:"FileSystem",reason:"Unknown",method:"watch",pathOrDescriptor:e,cause:o}))}),n.on("close",()=>{r.end()}),n}),(n)=>ge(()=>n.close()))),Uit=(e,t,r)=>F8(t).pipe(K((n)=>e.pipe(sn((o)=>o.register(t,n,r)),Ue(()=>Lit(t,r)))),bR),Pit=(e,t,r)=>qr((n,o)=>{try{gt.writeFile(e,t,{signal:o,flag:r?.flag,mode:r?.mode},(i)=>{if(i)n(se(Sn("FileSystem","writeFile")(i,[e])));else n(Z)})}catch(i){n(se(ro("writeFile")(i)))}}),Hit=K(MD(BK),(e)=>Wye({access:mit,chmod:yit,chown:xit,copy:git,copyFile:Eit,link:Sit,makeDirectory:Cit,makeTempDirectory:Iit,makeTempDirectoryScoped:wit,makeTempFile:kit,makeTempFileScoped:Dit,open:Bit,readDirectory:Rit,readFile:vit,readLink:Tit,realPath:Oit,remove:bit,rename:Mit,stat:F8,symlink:_it,truncate:Fit,utimes:Nit,watch(t,r){return Uit(e,t,r)},writeFile:Pit})),vBe=bu(lr,Hit);var R1=vBe;import*as Lv from"node:path";import*as v1 from"node:url";var N8=(e)=>qi({try:()=>v1.fileURLToPath(e),catch:(t)=>new Na({module:"Path",method:"fromFileUrl",description:`Invalid file URL: ${e}`,cause:t})}),L8=(e)=>qi({try:()=>v1.pathToFileURL(e),catch:(t)=>new Na({module:"Path",method:"toFileUrl",description:`Invalid path: ${e}`,cause:t})}),qit=ps(sr,sr.of({[LS]:LS,...Lv.posix,fromFileUrl:N8,toFileUrl:L8})),Git=ps(sr,sr.of({[LS]:LS,...Lv.win32,fromFileUrl:N8,toFileUrl:L8})),OBe=ps(sr,sr.of({[LS]:LS,...Lv,fromFileUrl:N8,toFileUrl:L8}));var T1=OBe;import*as O1 from"node:readline";var _Be=(e)=>e.key.ctrl&&(e.key.name==="c"||e.key.name==="d"),FBe=Ce(function*(e=_Be){let t=process.stdin,r=process.stdout,n=yield*zme({acquire:vr(ge(()=>{let u=O1.createInterface({input:t,escapeCodeTimeout:50});if(O1.emitKeypressEvents(t,u),t.isTTY)t.setRawMode(!0);return u}),(u)=>ge(()=>{if(t.isTTY)t.setRawMode(!1);u.close()}))}),o=ge(()=>r.columns??0),i=ge(()=>r.rows??0),s=ge(()=>Boolean(r.isTTY)),a=Y(function*(){yield*S3(n);let u=yield*cf(),p=(f,d)=>{let A={input:vt(f),key:{name:d.name??"",ctrl:!!d.ctrl,meta:!!d.meta,shift:!!d.shift}};if(u.unsafeOffer(A),e(A))u.unsafeDone(lu)};return yield*iw(()=>ge(()=>t.off("keypress",p))),t.on("keypress",p),u}),c=S3(n).pipe(N((u)=>qr((p)=>{let f=(d)=>p(M(d));return u.once("line",f),ge(()=>u.off("line",f))})),Tr),l=(u)=>ka(qr((p)=>{r.write(u,(f)=>f?p(se(new Na({module:"Terminal",method:"display",description:"Failed to write prompt to stdout",cause:f}))):p(Z))}));return Xt.of({columns:o,rows:i,isTTY:s,readInput:a,readLine:c,display:l})}),NBe=wu(Xt,FBe(_Be));var LBe=NBe;class QE extends Fi("@effect/platform/Transferable/Collector")(){}var qB=()=>{let e=[],t=(o)=>{e.push(...o)},r=()=>e,n=()=>{let o=e;return e=[],o};return QE.of({unsafeAddAll:t,addAll:(o)=>ge(()=>t(o)),unsafeRead:r,read:ge(r),unsafeClear:n,clear:ge(n)})};var UBe=Symbol.for("@effect/platform/WorkerError");var PBe=UBe;class Uh extends et()("WorkerError",{reason:V("spawn","decode","send","unknown","encode"),cause:Vt}){[PBe]=PBe;static Cause=Nye({error:this,defect:Vt});static encodeCause=Do(this.Cause);static decodeCause=Bw(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 P8=Symbol.for("@effect/platform/Worker/PlatformWorker"),M1=Qt("@effect/platform/Worker/PlatformWorker"),H8=Symbol.for("@effect/platform/Worker/WorkerManager"),W8=Qt("@effect/platform/Worker/WorkerManager"),HBe=Qt("@effect/platform/Worker/Spawner"),WBe=Y(function*(){let e=yield*M1,t=0;return W8.of({[H8]:H8,spawn({encode:r,initialMessage:n}){return Y(function*(){let o=t++,i=0,s=new Map,a=qB(),c=r?(g)=>be(a.clear,jr(r(g),QE,a)):M,l=yield*Yr(),u=yield*e.spawn(o);yield*u.run((g)=>{if(g[0]===0)return EL(l,Z);return p(g[1])}).pipe(Gx((g)=>ot(s.values(),(y)=>(Rg in y)?$f(y,g):y.failCause(g))),Da(tl),zA(AS(1000)),rl({package:"@effect/platform",module:"Worker"}),Rr,lc),yield*iw(()=>be(ot(s.values(),(g)=>(Rg in g)?wJ(g):g.end,{discard:!0}),ge(()=>s.clear())));let p=(g)=>Pe(()=>{let y=s.get(g[0]);if(!y)return Z;switch(g[1]){case 0:return Rg in y?Bi(y,g[2][0]):y.offerAll(g[2]);case 1:{if(g.length===2)return Rg in y?wJ(y):y.end;return Rg in y?Bi(y,g[2][0]):be(y.offerAll(g[2]),y.end)}case 2:case 3:{if(g[1]===2)return Rg in y?DD(y,g[2]):y.fail(g[2]);let w=Uh.decodeCause(g[2]);return Rg in y?$f(y,w):y.failCause(w)}}}),f=(g,y)=>_n((w)=>{let b=w.getFiberRef(Hp),D=Qs(b,uN).pipe(ns((B)=>B._tag==="Span")),k=i++;return y.pipe(nr((B)=>(s.set(k,B),c(g).pipe(nr((S)=>u.send([k,0,S,D._tag==="Some"?[D.value.traceId,D.value.spanId,D.value.sampled]:void 0],a.unsafeRead())),en((S)=>Mwe(B)?B.failCause(S):$f(B,S))))),K((B)=>({id:k,mailbox:B})))}),d=({id:g},y)=>{let w=ge(()=>s.delete(g));return $o(y)?be(tr(u.send([g,1])),w):w},A=(g)=>ES(Mge(f(g,cf()),({mailbox:y})=>_we(y),d)),m=(g)=>Kf(f(g,Yr()),({mailbox:y})=>er(y),d);if(yield*er(l),n)yield*ge(n).pipe(N(m),fe((g)=>new Uh({reason:"spawn",cause:g})));return{id:o,execute:A,executeEffect:m}})}})}),qBe=bu(W8,WBe);var GBe=()=>(e)=>M1.of({[P8]:P8,spawn(t){return Y(function*(){let r=yield*HBe,n,o=[];return{run:(a)=>YA((c)=>Y(function*(){let l=yield*jA,u=yield*e.setup({worker:r(t),scope:l});n=u,yield*ea(l,ge(()=>{n=void 0}));let p=(yield*Ra()).pipe(jme(Ez(bg))),f=yield*wE(),d=Yi(p);if(yield*e.listen({port:u,scope:l,emit(A){KS(f,d(a(A)))},deferred:f.deferred}),o.length>0){for(let[A,m]of o)u.postMessage([0,A],m);o.length=0}return yield*c(Mv(f))}).pipe(Tr)),send:(a,c)=>qi({try:()=>{if(n===void 0)o.push([a,c]);else n.postMessage([0,a],c)},catch:(l)=>new Uh({reason:"send",cause:l})})}})}});var VBe=GBe,zBe=M1;var YBe=qBe;var Kit=VBe()({setup({scope:e,worker:t}){return N(Yr(),(r)=>{let n="postMessage"in t?{postMessage(o,i){t.postMessage(o,i)},kill:()=>t.terminate(),worker:t}:{postMessage(o,i){t.send(o)},kill:()=>t.kill("SIGKILL"),worker:t};return t.on("exit",()=>{Pi(r,lu)}),un(ea(e,Pe(()=>(n.postMessage([1]),er(r))).pipe(Rr,$A(5000),en(()=>ge(()=>n.kill())))),n)})},listen({deferred:e,emit:t,port:r}){return r.worker.on("message",(n)=>{t(n)}),r.worker.on("messageerror",(n)=>{Pi(e,new Uh({reason:"decode",cause:n}))}),r.worker.on("error",(n)=>{Pi(e,new Uh({reason:"unknown",cause:n}))}),r.worker.on("exit",(n)=>{Pi(e,new Uh({reason:"unknown",cause:Error(`exited with code ${n}`)}))}),Z}}),jBe=ps(zBe,Kit),$Be=Ao(YBe,jBe);var JBe=$Be;var Uv=x(Fs(T1,D1,LBe,JBe),_g(R1));var Cl=R1;import*as N1 from"node:http";import*as L1 from"node:https";import{Readable as t0e}from"node:stream";import{pipeline as rst}from"node:stream/promises";var q8=Q1;var est=q8(()=>process.stdout,(e)=>new ji({module:"Stream",method:"stdout",reason:"Unknown",cause:e}));var _1=Lh;var KBe=EBe;var F1=ABe,ZBe=B1,tst=Lh(()=>process.stdin,(e)=>e,{closeOnDone:!1}).pipe(lP);class Wv extends fp{source;onError;remoteAddressOverride;[Pa];constructor(e,t,r){super();this.source=e,this.onError=t,this.remoteAddressOverride=r,this[Pa]=Pa}get headers(){return Oo(this.source.headers)}get remoteAddress(){return vt(this.remoteAddressOverride??this.source.socket.remoteAddress)}textEffect;get text(){if(this.textEffect)return this.textEffect;return this.textEffect=or(Zc(N(xE,(e)=>F1(()=>this.source,{onFailure:this.onError,maxBytes:At(e)})))),this.textEffect}get unsafeText(){return or(this.text)}get json(){return vg(this.text,{try:(e)=>e===""?null:JSON.parse(e),catch:this.onError})}get unsafeJson(){return or(this.json)}get urlParamsBody(){return N(this.text,(e)=>qi({try:()=>bd(new URLSearchParams(e)),catch:this.onError}))}get stream(){return _1(()=>this.source,this.onError)}get arrayBuffer(){return N(xE,(e)=>ZBe(()=>this.source,{onFailure:this.onError,maxBytes:At(e)}))}}var G8=Symbol.for("@effect/platform-node/Http/NodeClient/HttpAgent"),V8=Qt("@effect/platform-node/Http/NodeClient/HttpAgent"),r0e=(e)=>K(hi([vr(ge(()=>new N1.Agent(e)),(t)=>ge(()=>t.destroy())),vr(ge(()=>new L1.Agent(e)),(t)=>ge(()=>t.destroy()))]),([t,r])=>({[G8]:G8,http:t,https:r})),n0e=(e)=>wu(V8,r0e(e)),o0e=n0e(),nst=(e)=>s1((t,r,n)=>{let o=r.protocol==="https:"?L1.request(r,{agent:e.https,method:t.method,headers:t.headers,signal:n}):N1.request(r,{agent:e.http,method:t.method,headers:t.headers,signal:n});return x(be(ost(o,t,t.body),ist(o,t),{concurrent:!0}),K((i)=>new i0e(t,i)))}),ost=(e,t,r)=>Pe(()=>{switch(r._tag){case"Empty":return e.end(),XBe(e,t);case"Uint8Array":case"Raw":return e.end(r.body),XBe(e,t);case"FormData":{let n=new Response(r.formData);return n.headers.forEach((o,i)=>{e.setHeader(i,o)}),Fn({try:()=>rst(t0e.fromWeb(n.body),e),catch:(o)=>new gl({request:t,reason:"Transport",cause:o})})}case"Stream":return rd(Kge(r.stream,(n)=>new gl({request:t,reason:"Encode",cause:n})),q8(()=>e,(n)=>new gl({request:t,reason:"Transport",cause:n})))}}),ist=(e,t)=>qr((r)=>{function n(i){r(se(new gl({request:t,reason:"Transport",cause:i})))}e.on("error",n);function o(i){e.off("error",n),r(M(i))}return e.on("upgrade",o),e.on("response",o),ge(()=>{e.off("error",n),e.off("upgrade",o),e.off("response",o)})}),XBe=(e,t)=>qr((r)=>{function n(i){r(se(new gl({request:t,reason:"Transport",cause:i})))}e.once("error",n);function o(){e.off("error",n),r(Z)}return e.once("finish",o),ge(()=>{e.off("error",n),e.off("finish",o)})});class i0e extends Wv{request;[IE];constructor(e,t){super(t,(r)=>new Xo({request:e,response:this,reason:"Decode",cause:r}));this.request=e,this[IE]=IE}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=OB(e);return this.cachedCookies=Rh}get formData(){return Fn({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(t0e.toWeb(this.source),e).formData()},catch:this.onError})}toJSON(){return SE(this,{_id:"@effect/platform/HttpClientResponse",request:this.request.toJSON(),status:this.status})}}var s0e=K(V8,nst),a0e=c1(s0e),c0e=Ao(a0e,o0e);var $Ne=Vl(g7(),1);OV(HC,Vl(g7(),1));var E7=Qt("@effect/platform-node/NodeHttpClient/Dispatcher");var JNe="@effect/platform-node/NodeHttpClient/undiciOptions",KNe=(e)=>s1((t,r,n,o)=>{let s=o.getFiberRef(Hp).unsafeMap.get(JNe)??{};return HIt(t.body).pipe(N((a)=>Fn({try:()=>e.request({...s,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 gl({request:t,reason:"Transport",cause:c})})),K((a)=>new ZNe(t,a)))});function HIt(e){switch(e._tag){case"Empty":return M(null);case"Uint8Array":case"Raw":return M(e.body);case"FormData":return M(e.formData);case"Stream":return KBe(e.stream)}}function WIt(e){}class ZNe extends fp{request;source;[Pa];[IE];constructor(e,t){super();this.request=e,this.source=t,this[Pa]=Pa,this[IE]=IE,t.body.on("error",WIt)}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=OB(Array.isArray(e)?e:[e]);return this.cachedCookies=Rh}get headers(){return Oo(this.source.headers)}get remoteAddress(){return U()}get stream(){return _1(()=>this.source.body,(e)=>new Xo({request:this.request,response:this,reason:"Decode",cause:e}))}get json(){return vg(this.text,{try:(e)=>e===""?null:JSON.parse(e),catch:(e)=>new Xo({request:this.request,response:this,reason:"Decode",cause:e})})}textBody;get text(){return this.textBody??=Fn({try:()=>this.source.body.text(),catch:(e)=>new Xo({request:this.request,response:this,reason:"Decode",cause:e})}).pipe(Zc,or)}get urlParamsBody(){return N(this.text,(e)=>qi({try:()=>bd(new URLSearchParams(e)),catch:(t)=>new Xo({request:this.request,response:this,reason:"Decode",cause:t})}))}formDataBody;get formData(){return this.formDataBody??=Fn({try:()=>this.source.body.formData(),catch:(e)=>new Xo({request:this.request,response:this,reason:"Decode",cause:e})}).pipe(Zc,or)}arrayBufferBody;get arrayBuffer(){return this.arrayBufferBody??=Fn({try:()=>this.source.body.arrayBuffer(),catch:(e)=>new Xo({request:this.request,response:this,reason:"Decode",cause:e})}).pipe(Zc,or)}toJSON(){return SE(this,{_id:"@effect/platform/HttpClientResponse",request:this.request.toJSON(),status:this.status})}}var XNe=c1(K(E7,KNe));var eLe=c0e;var GIt=E7;var VIt=XNe;import{Duplex as zIt,Readable as YIt}from"node:stream";class tLe extends zIt{_parser;_canWrite=!0;_writeCallback;constructor(e){super({readableObjectMode:!0});let t,r;this._parser=k8({...e,onField:(n,o)=>{if(t!==void 0)return;let i={_tag:"Field",info:n,value:o};this.push(i),this.emit("field",i)},onFile:(n)=>{if(t!==void 0)return(i)=>{};let o=new nLe(n,this);return r=o,this.push(o),this.emit("file",o),(i)=>{if(this._canWrite=o.push(i),i===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 rLe=(e)=>new tLe(e);class nLe extends YIt{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 oLe from"node:fs";import*as iLe from"node:stream/promises";var y7=(e,t)=>x(Ywe(t),K((r)=>Lh(()=>{let n=rLe(r);return e.pipe(n),n},(n)=>JIt(n))),bR,jge($It)),sLe=(e,t)=>$we(y7(e,t),(r,n)=>Fn({try:(o)=>iLe.pipeline(n.file,oLe.createWriteStream(r),{signal:o}),catch:(o)=>new Sl({reason:"InternalError",cause:o})})),$It=(e)=>e._tag==="Field"?new aLe(e.info,e.value):new cLe(e);class x7 extends fp{[JS];constructor(){super();this[JS]=JS}}class aLe extends x7{_tag="Field";key;contentType;value;constructor(e,t){super();this.key=e.name,this.contentType=e.contentType,this.value=D8(e,t)}toJSON(){return{_id:"@effect/platform/Multipart/Part",_tag:"Field",key:this.key,value:this.value,contentType:this.contentType}}}class cLe extends x7{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=Lh(()=>e,(t)=>new Sl({reason:"InternalError",cause:t})),this.contentEffect=B1(()=>e,{onFailure:(t)=>new Sl({reason:"InternalError",cause:t})})}toJSON(){return{_id:"@effect/platform/Multipart/Part",_tag:"File",key:this.key,name:this.name,contentType:this.contentType}}}function JIt(e){switch(e._tag){case"ReachedLimit":switch(e.limit){case"MaxParts":return new Sl({reason:"TooManyParts",cause:e});case"MaxFieldSize":return new Sl({reason:"FieldTooLarge",cause:e});case"MaxPartSize":return new Sl({reason:"FileTooLarge",cause:e});case"MaxTotalSize":return new Sl({reason:"BodyTooLarge",cause:e})}default:return new Sl({reason:"Parse",cause:e})}}var lLe=y7,uLe=sLe;var pLe=We(Symbol.for("@effect/platform/HttpApp/preResponseHandlers"),()=>Iu(U()));var ebt=(e)=>e;var tbt=We(Symbol.for("@effect/platform/HttpMiddleware/tracerDisabledWhen"),()=>Iu(In));var rbt=Kn()("@effect/platform/HttpMiddleware/SpanNameGenerator",{defaultValue:()=>(e)=>`http.server ${e.method}`});var S7=ebt((e)=>_n((t)=>{let r=wi(t.currentContext,lf);if(t.getFiberRef(tbt)(r))return e;let o=At(dBe(r));if(o!==void 0&&(o.username!==""||o.password!==""))o.username="REDACTED",o.password="REDACTED";let i=t.getFiberRef(xv),s=YS(r.headers,i),a=cr(t.currentContext,rbt);return dw(a(r),{parent:At(Ibe(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 s)c.attribute(`http.request.header.${l}`,String(s[l]));if(r.remoteAddress._tag==="Some")c.attribute("client.address",r.remoteAddress.value);return N(Qn(Zx(e,c)),(l)=>{let u=kwe(l);c.attribute("http.response.status_code",u.status);let p=YS(u.headers,i);for(let f in p)c.attribute(`http.response.header.${f}`,String(p[f]));return l})})}));var _0=Symbol.for("@effect/platform/HttpApp/handled"),C7=(e,t,r)=>{let n=_n((s)=>N(e,(a)=>{let c=wi(s.currentContext,lf),l=s.getFiberRef(fLe);if(l._tag==="None")return c[_0]=!0,un(t(c,a),a);return nr(l.value(c,a),(u)=>(c[_0]=!0,t(c,u)))})),o=en(n,(s)=>_n((a)=>N(Dv(s),([c,l])=>{let u=wi(a.currentContext,lf),p=a.getFiberRef(fLe);if(p._tag==="None")return u[_0]=!0,be(t(u,c),Cg(l)?M(c):ln(l));return be(nr(p.value(u,c),(f)=>(u[_0]=!0,t(u,f))),Cg(l)?M(c):ln(l))}))),i=MH(r===void 0?S7(o):uo(S7(r(o)),{onFailure:(s)=>_n((a)=>{let c=wi(a.currentContext,lf);if(_0 in c)return Z;return uo(Dv(s),{onFailure:(l)=>t(c,bE({status:500})),onSuccess:([l])=>t(c,l)})}),onSuccess:(s)=>_n((a)=>{let c=wi(a.currentContext,lf);return _0 in c?Z:t(c,s)})}));return ka(ibt(i))};var obt=We("@effect/platform/HttpApp/ejectedScopes",()=>new WeakSet),ibt=(e)=>N(Ux(),(t)=>Vx(_p(e,t),(r)=>{if(obt.has(t))return Z;return Mp(t,r)})),fLe=pLe;import*as P7 from"node:http";import{Readable as _wt}from"node:stream";import{pipeline as Fwt}from"node:stream/promises";var Iwt=Vl(sUe(),1),bwt=Vl(UW(),1),wwt=Vl(L0(),1),Bwt=Vl(k7(),1),Qwt=Vl(R7(),1),kwt=Vl(F7(),1),zW=Vl(GW(),1),N7=Vl(fUe(),1);var dUe=E8,AUe=hwe;var L7=Vl(CUe(),1);import*as IUe from"node:fs";import{Readable as Twt}from"node:stream";var Owt=AUe({fileResponse(e,t,r,n,o,i,s){let a=IUe.createReadStream(e,{start:o,end:i});return I8(a,{headers:{...n,"content-type":n["content-type"]??L7.default.getType(e)??"application/octet-stream","content-length":s.toString()},status:t,statusText:r})},fileWebResponse(e,t,r,n,o){return I8(Twt.fromWeb(e.stream()),{headers:sf(n,vh({"content-type":n["content-type"]??L7.default.getType(e.name)??"application/octet-stream","content-length":e.size.toString()})),status:t,statusText:r})}}),bUe=x(bu(dUe,Owt),Ao(Cl),Ao(lwe));var wUe=(e,t)=>Y(function*(){let r=yield*jA,n=yield*vr(ge(e),(s)=>qr((a)=>{if(!s.listening)return a(Z);s.close((c)=>{if(c)a(Hi(c));else a(Z)})}));yield*qr((s)=>{function a(c){s(se(new A1({cause:c})))}n.on("error",a),n.listen(t,()=>{n.off("error",a),s(Z)})});let o=n.address(),i=yield*x(vr(ge(()=>new N7.default({noServer:!0})),(s)=>qr((a)=>{s.close(()=>a(Z))})),_p(r),Zc);return Ewe({address:typeof o==="string"?{_tag:"UnixAddress",path:o}:{_tag:"TcpAddress",hostname:o.address==="::"?"0.0.0.0":o.address,port:o.port},serve:(s,a)=>Y(function*(){let c=yield*BUe(s,a),l=yield*Nwt(i,s,a);yield*iw(()=>ge(()=>{n.off("request",c),n.off("upgrade",l)})),n.on("request",c),n.on("upgrade",l)})})}).pipe(jr(xE,P(ad(10485760)))),BUe=(e,t)=>{let r=C7(e,DUe,t);return K(Ra(),(n)=>{let o=Yi(n);return function(s,a){let c=o(jr(r,lf,new jW(s,a)));a.on("close",()=>{if(!a.writableEnded)c.unsafeInterruptAsFork(h1)})}})},Nwt=(e,t,r)=>{let n=C7(t,DUe,r);return K(rBe(),(o)=>function(s,a,c){let l=void 0,u=()=>{if(l===void 0)l=new P7.ServerResponse(s),l.assignSocket(a),l.on("finish",()=>{a.end()});return l},p=T8(N(e,(d)=>vr(qr((A)=>d.handleUpgrade(s,a,c,(m)=>{A(M(m))})),(A)=>ge(()=>A.close())))),f=o(jr(n,lf,new jW(s,u,p)));a.on("close",()=>{if(!a.writableEnded)f.unsafeInterruptAsFork(h1)})})};class jW extends Wv{source;response;upgradeEffect;url;headersOverride;[w1];constructor(e,t,r,n=e.url,o,i){super(e,(s)=>new kv({request:this,reason:"Decode",cause:s}),i);this.source=e,this.response=t,this.upgradeEffect=r,this.url=n,this.headersOverride=o,this[w1]=w1}cachedCookies;get cookies(){if(this.cachedCookies)return this.cachedCookies;return this.cachedCookies=dbe(this.headers.cookie??"")}get resolvedResponse(){return typeof this.response==="function"?this.response():this.response}modify(e){return new jW(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=or(Zc(uLe(this.source,this.source.headers))),this.multipartEffect}get multipartStream(){return lLe(this.source,this.source.headers)}get upgrade(){return this.upgradeEffect??se(new kv({request:this,reason:"Decode",description:"not an upgradeable ServerRequest"}))}toString(){return`ServerRequest(${this.method} ${this.url})`}toJSON(){return SE(this,{_id:"@effect/platform/HttpServerRequest",method:this.method,url:this.originalUrl})}}var QUe=Fs(bUe,h8,Uv),kUe=(e,t)=>Fs(wu(x8,wUe(e,t)),QUe);var DUe=(e,t)=>Pe(()=>{let r=e.resolvedResponse;if(r.writableEnded)return Z;let n=t.headers;if(!V5(t.cookies)){n={...n};let i=qH(t.cookies);if(n["set-cookie"]!==void 0)i.push(n["set-cookie"]);n["set-cookie"]=i}if(e.method==="HEAD")return r.writeHead(t.status,n),qr((i)=>{r.end(()=>i(Z))});let o=t.body;switch(o._tag){case"Empty":return r.writeHead(t.status,n),r.end(),Z;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 Fn({try:(i)=>Fwt(o.body,r,{signal:i,end:!0}),catch:(i)=>new d1({request:e,response:t,reason:"Decode",cause:i})}).pipe(Rr,Da(U7(r,t)));return qr((i)=>{r.end(o.body,()=>i(Z))})}case"Uint8Array":return r.writeHead(t.status,n),qr((i)=>{r.end(o.body,()=>i(Z))});case"FormData":return Pe(()=>{let i=new Response(o.formData);return r.writeHead(t.status,{...n,...Object.fromEntries(i.headers)}),qr((s,a)=>{_wt.fromWeb(i.body,{signal:a}).pipe(r).on("error",(c)=>{s(se(new d1({request:e,response:t,reason:"Decode",cause:c})))}).once("finish",()=>{s(Z)})}).pipe(Rr,Da(U7(r,t)))});case"Stream":{r.writeHead(t.status,n);let i=ol();return r.on("drain",()=>i.unsafeOpen()),o.stream.pipe(lP,yS((s)=>{let a=ao(s);if(a.length===0)return Z;let c=!1;for(let l=0;l<a.length;l++){let u=r.write(a[l]);if(!u&&!c)c=!0,i.unsafeClose();else if(u&&c)c=!1}if(!c)return Z;return i.await}),Rr,uo({onSuccess:()=>ge(()=>r.end()),onFailure:U7(r,t)}))}}}),U7=(e,t)=>(r)=>Dv(r).pipe(N(([n,o])=>{let i=e.headersSent;if(!i)e.writeHead(n.status);if(!e.writableEnded)e.end();return ln(i?Vf(r,sc(t)):o)}));var Uwt=kUe;var zd=T1;var Pwt=(e,t)=>{t($o(e)&&!Yf(e.cause)?1:0)},vUe=(e,t)=>{let r=RA(e,B4);if(!Lm(r,DB))return e;return uj(e,{fiberId:t,fiberRef:B4,value:r.pipe(ex(DB),Ip(OH))})},TUe=(e)=>h((t)=>cn(t[0]),(t,r)=>{let n=r?.disableErrorReporting===!0?hu(t,{updateRefs:r?.disablePrettyLogger===!0?void 0:vUe}):hu(Da(t,(i)=>{if(Yf(i))return Z;return Jx(i)}),{updateRefs:r?.disablePrettyLogger===!0?void 0:vUe}),o=r?.teardown??Pwt;return e({fiber:n,teardown:o})});var OUe=TUe(({fiber:e,teardown:t})=>{let r=setInterval(No,2147483647),n=!1;e.addObserver((i)=>{if(!n)process.removeListener("SIGINT",o),process.removeListener("SIGTERM",o);clearInterval(r),t(i,(s)=>{if(n||s!==0)process.exit(s)})});function o(){n=!0,process.removeListener("SIGINT",o),process.removeListener("SIGTERM",o),e.unsafeInterruptAsFork(e.id())}process.on("SIGINT",o),process.on("SIGTERM",o)});var MUe=OUe;var qwt=MUe;var H7=Symbol.for("effect/FiberMap"),Gwt=(e)=>Ee(e,H7),Vwt={[H7]:H7,[Symbol.iterator](){if(this.state._tag==="Closed")return YM();return this.state.backing[Symbol.iterator]()},toString(){return St(this.toJSON())},toJSON(){return{_id:"FiberMap",state:this.state}},[lt](){return this.toJSON()},pipe(){return ue(this,arguments)}},zwt=(e,t)=>{let r=Object.create(Vwt);return r.state={_tag:"Open",backing:e},r.deferred=t,r},Ywt=()=>vr(K(Yr(),(e)=>zwt(Ub(),e)),(e)=>_n((t)=>{let r=e.state;if(r._tag==="Closed")return Z;return e.state={_tag:"Closed"},eL(ioe(r.backing,([,n])=>n),bp(t.id(),aO)).pipe(jx(e.deferred))}));var NUe=-1,aO=hA(NUe,0),jwt=GN(void 0,{emptyCase:In,failCase:In,dieCase:In,interruptCase:(e,t)=>Lm(rx(t),NUe),sequentialCase:(e,t,r)=>t||r,parallelCase:(e,t,r)=>t||r}),$wt=h((e)=>Gwt(e[0]),(e,t,r,n)=>{if(e.state._tag==="Closed"){r.unsafeInterruptAsFork(bp(n?.interruptAs??Io,aO));return}let o=ic(e.state.backing,t);if(o._tag==="Some"){if(n?.onlyIfMissing===!0){r.unsafeInterruptAsFork(bp(n?.interruptAs??Io,aO));return}else if(o.value===r)return;o.value.unsafeInterruptAsFork(bp(n?.interruptAs??Io,aO))}qf(e.state.backing,t,r),r.addObserver((i)=>{if(e.state._tag==="Closed")return;let s=ic(e.state.backing,t);if(ne(s)&&r===s.value)rD(e.state.backing,t);if($o(i)&&(n?.propagateInterruption===!0?!jwt(i.cause):!Yf(i.cause)))Pi(e.deferred,i)})});var LUe=h(2,(e,t)=>e.state._tag==="Closed"?!1:Wf(e.state.backing,t));var Jwt=h(2,(e,t)=>_n((r)=>{if(e.state._tag==="Closed")return Z;let n=ic(e.state.backing,t);if(n._tag==="None")return Z;return ED(n.value,bp(r.id(),aO))}));var FUe=function(){let e=void 0;return()=>{if(e===void 0)e=hu(Gi);return e}}();var Kwt=(e)=>()=>K(Ra(),(t)=>{let r=Yi(t);return(n,o,i)=>{if(e.state._tag==="Closed")return FUe();else if(i?.onlyIfMissing===!0&&LUe(e,n))return FUe();let s=r(o,i);return $wt(e,n,s,i),s}});var Zwt=V("InvalidInput","NotLocal","UnsupportedProtocol","NotFound","PermissionDenied","UnsupportedFileType","Unavailable","UnsafeDirectory");class Ol extends et()("ExpandLocalTargetError",{reason:Zwt,input:E,message:E,cause:z(Vt)}){toPublicError(){return new PUe(this.message,{reason:this.reason,input:this.input,cause:this.cause})}}class cO extends et()("ExpandSdkError",{message:E,cause:z(Vt)}){toPublicError(){return new lO(this.message,{cause:this.cause})}}class Xwt extends et()("ExpandApiError",{message:E,status:de,body:z(Zt),cause:z(Vt)}){toPublicError(){return new HUe(this.message,{status:this.status,body:this.body,cause:this.cause})}}class eBt extends et()("ExpandConnectionError",{message:E,cause:z(Vt)}){toPublicError(){return new W7(this.message,{cause:this.cause})}}class tBt extends et()("ExpandTimeoutError",{message:E,timeoutMs:de,cause:z(Vt)}){toPublicError(){return new WUe(this.message,{timeoutMs:this.timeoutMs,cause:this.cause})}}class lO extends Error{constructor(e,t={}){super(e,t);this.name="ExpandClientError"}}class PUe extends lO{reason;input;constructor(e,t){super(e,t);this.name="ExpandClientLocalTargetError",this.reason=t.reason,this.input=t.input}}class HUe extends lO{status;body;constructor(e,t){super(e,t);this.name="ExpandClientApiError",this.status=t.status,this.body=t.body}}class W7 extends lO{constructor(e,t={}){super(e,t);this.name="ExpandClientConnectionError"}}class WUe extends W7{timeoutMs;constructor(e,t){super(e,t);this.name="ExpandClientTimeoutError",this.timeoutMs=t.timeoutMs}}var rBt=[["http_proxy","HTTP_PROXY"],["https_proxy","HTTPS_PROXY"]];function q7(){for(let[e,t]of rBt){let r=process.env[e]!==void 0?e:t,n=process.env[r];if(n===void 0||n==="")continue;try{new URL(n)}catch{return P(`Invalid proxy URL in the ${r} environment variable: ${JSON.stringify(n)}. Fix or unset it.`)}}return U()}var Yd=VIt.pipe(Ao(wu(GIt,vr(Pe(()=>Te(q7(),{onSome:(e)=>Hi(new cO({message:e})),onNone:()=>ge(()=>new HC.EnvHttpProxyAgent)})),(e)=>rw(()=>e.destroy())))));import{homedir as zBt}from"node:os";var VC="https://expand.land";function nBt(e){return e.replace(/\/+$/,"")}function GUe(e){return e!==null&&e!==void 0&&Number.isInteger(e)&&e>0&&e<=2147483647?e:void 0}function qUe(e){return e!==null&&e!==void 0&&Number.isInteger(e)&&e>=0&&e<=4294967295?e:void 0}function uO(e,t="https://expand.land"){return`${nBt(t)}/s/${encodeURIComponent(e)}`}function VUe(e,t="https://expand.land"){return`${uO(e,t)}/appendix`}function zUe(e,t,r="https://expand.land"){let n=`${uO(e,r)}/content`,o=GUe(t);return o===void 0?n:`${n}?id=${o}`}var oBt=/^[A-Za-z0-9._~-]+$/u;function YUe(e){let t=e.trim();if(t.length===0)return;if(oBt.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 iBt(e){return new URL(e).origin}function ly(e,t){if(e==null)return t;try{return iBt(e)}catch{return t}}function V0(e,t,r,n="https://expand.land"){let o=typeof t==="string",i=o?t:void 0,s=o?typeof r==="string"?void 0:r:t,c=uO(e,o?n:typeof r==="string"?r:"https://expand.land"),l=GUe(s?.evidenceId);if(l!==void 0)return`${c}?id=${l}`;if(i==="statejson"){let u=qUe(s?.stateJsonSourceId);return u===void 0?c:`${c}?id=${u}`}if(i==="markdown"||i==="appendix"){let u=qUe(s?.nodeIds?.[0]);return u===void 0?c:`${c}/playground#focus=${u}`}return c}var IPe=Vl(xPe(),1);class see extends et()("CredentialStorageLockError",{error:Vt}){get message(){return"Could not lock credential storage. Try again shortly."}}var SPe=Iu(new Set);function CPe(e,t){if(typeof e!=="object"||e===null||!("code"in e))return!1;return e.code===t}function GBt(e){return CPe(e.error,"ERELEASED")||CPe(e.error,"ENOTACQUIRED")}var rm=Ce(function*(e,t,r=`${e}.lock`){let n=yield*d8e(SPe);if(n.has(e))return yield*t;return yield*Kf(Fn({try:()=>IPe.lock(e,{realpath:!1,lockfilePath:r,onCompromised:()=>{return}}),catch:(o)=>new see({error:o})}).pipe(zA({schedule:AS("25 millis"),times:400,while:({error:o})=>o instanceof Error&&("code"in o)&&o.code==="ELOCKED"})),()=>KA(t,SPe,new Set([...n,e])),(o)=>Fn({try:()=>o(),catch:(i)=>new see({error:i})}).pipe(Ft((i)=>GBt(i)?Z:Hi(i))))});var aee=W("runNonInteractiveCommand")(function*(e){let t=yield*e.pipe(WH(Vge),sbe("pipe"),ibe("inherit"),gnt),[r]=yield*hi([t.exitCode,Xge(t.stdout)],{concurrency:"unbounded"});return r},Tr);function bPe(e,t,r,n){return Tr(Y(function*(){let o=yield*e.open(t,{flag:"wx",mode:n}),i=yield*o.stat,s={dev:i.dev,ino:At(i.ino),mode:i.mode,type:i.type},a=yield*Qn(o.writeAll(new TextEncoder().encode(r)).pipe(be(o.sync)));if($o(a))return{identity:s,writeExit:a,pathMatchesHandle:!1};let c=yield*e.stat(t),l=$0(s,{exists:!0,dev:c.dev,ino:At(c.ino),type:c.type});return{identity:s,writeExit:a,pathMatchesHandle:l}}))}function $0(e,t){return t.exists&&t.dev===e.dev&&t.ino===e.ino&&t.type===e.type}import{homedir as VBt}from"node:os";var J0=Y(function*(){let e=yield*sr;return yield*Ht("XDG_CONFIG_HOME").pipe(yr(""),sh((t)=>t.trim()===""?e.join(VBt(),".config"):t))});var cq="https://api.expand.ai",YBt="https://expand.ai",KC=(e)=>Ht(e).pipe(Du,sh(Te({onNone:()=>!1,onSome:(t)=>t!==""&&t!=="0"&&t!=="false"}))),uq=(e,t)=>Ht(e).pipe(Du,sh(sn(us(t)))),lq=3;function jBt(e,t){if(e===0)return"accepted";if(e===lq)return"refused";return t?"tolerated":"refused"}function cee(e){let t=e.replace(/\//g,"\\");if(!t.startsWith("\\\\"))return!1;return!/^\\\\[?.]\\[a-z]:/i.test(t)}function $Bt(e,t,r){if(cee(e))return!1;return t.filter((n)=>!cee(n)).some((n)=>e===n||e.startsWith(`${n}${r}`))}var pq=fh(QS.pipe(Cye("ApiKey"))),om="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.",lee=AK("ApiKey",{apiKey:pq}),mO=AK("OAuth",{accessToken:fh(E),refreshToken:z(fh(E)),expiresAt:id,clientId:z(E)}),JBt=q({enabled:z(Ie),distinctId:z(E),noticeShown:z(Ie)}),uee=q({sessionToken:fh(E),mintedAt:id});class nm extends Ne("ExpandCliConfig")({apiUrl:z(Kg),authMethod:z(Je(lee,mO)),telemetry:z(JBt),anonymousSession:z(uee)}){static Json=Nt(nm)}function fq(e,t){if(e._tag==="ApiKey")return"healthy";if(AP(t,e.expiresAt))return oa(e.accessToken).trim().length>0?"healthy":"unusable";let r=e.refreshToken;return r!==void 0&&oa(r).trim().length>0?"refresh_required":"unusable"}function gO(e,t){return fq(e,t)!=="unusable"}var KBt=Nt(q({alg:fs})),ZBt=Nt(q({iss:Kg}));function XBt(e,t){if(e._tag!=="OAuth")return!1;let r=oa(e.accessToken).split(".");if(r.length!==3||r.some((o)=>!/^[A-Za-z0-9_-]+$/u.test(o)||qt($3(o))))return!1;let n=vt(r[0]).pipe(sn((o)=>KQ(J3(o))),sn(us(KBt)));if(ze(n))return!1;return vt(r[1]).pipe(sn((o)=>KQ(J3(o))),sn(us(ZBt)),Rm(({iss:o})=>(o.protocol==="https:"||o.protocol==="http:")&&o.origin!==t.origin))}var e0t=Or({key:E,value:Zt}),aq=Nt(e0t);function t0t(e,t){return{...e,...t}}function r0t(e,t){return typeof e==="object"&&e!==null&&"code"in e&&e.code===t}function n0t(e){return`'${e.replaceAll("'","''")}'`}function wPe(e,t){return`$PSModuleAutoLoadingPreference = 'None'
|
|
200
200
|
$targetPaths = @(${t.map((r)=>n0t(r)).join(", ")})
|
|
@@ -298,7 +298,7 @@ foreach ($targetPath in $targetPaths) {
|
|
|
298
298
|
}
|
|
299
299
|
}
|
|
300
300
|
'SECURE'
|
|
301
|
-
`,m=[process.env.USERPROFILE,zBt()].filter((ce)=>typeof ce==="string"&&ce.trim()!==""&&!cee(ce)),g=(ce)=>r.resolve(ce).toLowerCase().replace(/\\+$/,""),y=Ce(function*(ce){let De=(Yt)=>t.realPath(Yt).pipe(Ft(()=>M(Yt)),K(g)),Fe=yield*De(ce),st=yield*ot(m,De);return $Bt(Fe,st,r.sep)}),w=Ce(function*(ce,De,Fe){if(ce===0)return;let st=yield*y(o);return yield*o0t(o,ce,st,De,Fe)}),b=(ce,De)=>w(1,ce,De),D=Ce(function*(ce){let De=yield*vB("powershell.exe","-NoLogo","-NoProfile","-NonInteractive","-Command",wPe(d,ce)).pipe(aee,jr(gE,e),Ft((Fe)=>b("could not run the Windows ACL allowlist script",String(Fe)).pipe(un(0))));yield*w(De,"the Windows ACL allowlist script did not complete",`PowerShell exited with status ${De}`)}),k=Ce(function*(ce){let De=yield*vB("powershell.exe","-NoLogo","-NoProfile","-NonInteractive","-Command",wPe(A,ce)).pipe(aee,jr(gE,e),Ft((Fe)=>b("could not inspect the Windows ACL allowlist",String(Fe)).pipe(un(0))));yield*w(De,"the Windows ACL allowlist could not be verified",`PowerShell exited with status ${De}`)}),B=W("ConfigManager.inspectSecureStorage")(function*(){let ce=yield*a(o);if(!ce.exists)return yield*Z;if(ce.type!=="Directory")return yield*i(o,"config directory is not a regular directory",Error("Invalid config directory"));let De=yield*a(n);if(De.exists&&De.type!=="File")return yield*i(n,"credential path is not a regular file",Error("Invalid file"));if(process.platform==="win32"){let st=De.exists?[o,n]:[o],Yt=yield*ot(st,a);yield*k(st);let rr=yield*ot(st,a);return yield*ot(st,(io,bi)=>c(io,Yt[bi]??{exists:!1},rr[bi]??{exists:!1}),{discard:!0}),yield*Z}if(((yield*t.stat(o).pipe(fe((st)=>i(o,"could not inspect directory mode",st)))).mode&4095)!==448)return yield*i(o,"config directory mode is not 700",Error("Invalid directory mode"));if(De.exists){if(((yield*t.stat(n).pipe(fe((Yt)=>i(n,"could not inspect credential file mode",Yt)))).mode&4095)!==384)return yield*i(n,"credential file mode is not 600",Error("Invalid file mode"))}return yield*Z}),S=W("ConfigManager.ensureSecureStorage")(function*(){yield*t.makeDirectory(o,{recursive:!0,mode:448}).pipe(fe((Fe)=>i(o,"could not create the config directory",Fe)));let ce=yield*a(o);if(!ce.exists||ce.type!=="Directory")return yield*i(o,"config directory is not a regular directory",Error("Invalid config directory"));if(!(yield*t.exists(n).pipe(fe((Fe)=>i(n,"could not inspect the credential file",Fe))))){let Fe=yield*jt(t.writeFileString(n,"{}",{flag:"wx",mode:384}));if(qt(Fe)&&(!(Fe.left instanceof ji)||Fe.left.reason!=="AlreadyExists"))return yield*i(n,"could not create the credential file",Fe.left)}if(yield*l(n),process.platform==="win32"){let Fe=[o,n],st=yield*ot(Fe,(rr)=>a(rr));yield*D(Fe);let Yt=yield*ot(Fe,(rr)=>a(rr));yield*ot(Fe,(rr,io)=>c(rr,st[io]??{exists:!1},Yt[io]??{exists:!1}),{discard:!0})}else yield*f(o,448,"Directory"),yield*f(n,384,"File");return yield*Z});function Q(){return t.makeDirectory(o,{recursive:!0,mode:448}).pipe(fe((ce)=>i(o,"could not create the config directory",ce)),be(process.platform==="win32"?D([o]):f(o,448,"Directory")),be(rm(n,S())))}let I=Ce(function*(ce){yield*Q();let De=yield*l(n),Fe=yield*d5e(0,2147483647),st=r.join(o,`.config.json.${process.pid}.${Fe.toString(16)}.tmp`),Yt=Ce(function*(Cs,js){let Is=yield*jt(l(st));if(qt(Is))return yield*new JC({path:n,temporaryPath:st,error:Is.left,operationError:js});if(!BPe(De.parent,Is.right.parent))return yield*new JC({path:n,temporaryPath:st,error:Error("Config temp parent identity changed; refusing cleanup"),operationError:js});if(!$0(Cs,Is.right.file))return yield*new JC({path:n,temporaryPath:st,error:Error("Config temp identity changed or disappeared; refusing cleanup"),operationError:js});let vI=yield*jt(t.remove(st));if(qt(vI))return yield*new JC({path:n,temporaryPath:st,error:vI.left,operationError:js})}),rr=yield*bPe(t,st,ce,384).pipe(fe(()=>new dy({path:st})));if($o(rr.writeExit)){let Cs=new dy({path:st});return yield*Yt(rr.identity,Cs),yield*Cs}if(!rr.pathMatchesHandle){let Cs=new dy({path:st});return yield*Yt(rr.identity,Cs),yield*Cs}let io=yield*jt(Y(function*(){let Cs=yield*l(st);if(yield*c(De.parentPath,De.parent,Cs.parent),!$0(rr.identity,Cs.file))return yield*i(st,"config temp identity differs from its creating handle",Error("Config temp replacement detected"));if(process.platform==="win32"){yield*D([st]);let Is=yield*l(st);if(yield*c(De.parentPath,De.parent,Is.parent),!$0(rr.identity,Is.file))return yield*i(st,"config temp changed while applying its ACL",Error("Config temp replacement detected"))}else if(((yield*t.stat(st).pipe(fe((vI)=>i(st,"could not verify config temp mode",vI)))).mode&4095)!==384)return yield*i(st,"config temp mode is not 600",Error("Invalid config temp mode"));let js=yield*l(n);yield*c(De.parentPath,De.parent,js.parent),yield*c(n,De.file,js.file),yield*t.rename(st,n).pipe(fe(()=>new dy({path:n})))}));if(qt(io))return yield*Yt(rr.identity,io.left),yield*io.left;let bi=yield*l(n);if(yield*c(De.parentPath,De.parent,bi.parent),!$0(rr.identity,bi.file))return yield*i(n,"atomic credential installation identity could not be verified",Error("Installed file identity mismatch"))});function O(ce){return Q().pipe(be(rm(n,I(ce))))}let v=Y(function*(){if(!(yield*t.exists(n)))return{config:nm.make({}),raw:{}};let De=yield*p(n),Fe=yield*Tu(aq)(De).pipe(fe((rr)=>new Ay({path:n,error:rr})));return{config:yield*ir(nm)(Fe).pipe(fe((rr)=>new Ay({path:n,error:rr}))),raw:Fe}}),H=v.pipe(K(({config:ce})=>ce)),T=W("loadConfig")(function*(){let{config:ce,noAnonymous:De}=yield*QPe,Fe=yield*H,st={env:vt(ce.apiUrl),file:vt(Fe.apiUrl)},Yt={env:vt(ce.authMethod),file:vt(Fe.authMethod)};yield*tl(`EXPAND_API_URL overrides apiUrl from ${n}`).pipe(Ms(()=>e$e(st.env,st.file,(Is,vI)=>Is.toString()!==vI.toString()).pipe(Ue(()=>!1))));let rr=yield*fc,io=ZQ([st.env,st.file]).pipe(Ue(()=>new URL(cq))),bi=Yt.file.pipe(ns((Is)=>XBt(Is,io))),Cs=Yt.file.pipe(ns((Is)=>Is._tag==="OAuth"&&gO(Is,rr)),ns(()=>ze(Yt.env)||ze(bi))),js=ZQ([Cs,Yt.env,Yt.file]);return yield*tl(`EXPAND_API_KEY is set but ${n} holds credentials from \`expandai login\` or agent setup, which take precedence. Unset EXPAND_API_KEY to silence this, or run \`expandai logout\` to use the API key.`).pipe(Ms(()=>ne(Yt.env)&&ne(Cs))),yield*tl(`Using EXPAND_API_KEY for ${io.origin} because the stored login was issued by a different API origin.`).pipe(Ms(()=>ne(Yt.env)&&ne(bi))),yield*tl(`EXPAND_API_KEY overrides the API key stored in ${n}`).pipe(Ms(()=>ne(Yt.env)&&Rm(Yt.file,(Is)=>Is._tag==="ApiKey"))),{apiUrl:io,authMethod:js,anonymousSession:vt(Fe.anonymousSession),noAnonymous:De}}),j=W("saveConfig")(function*(ce){let De=yield*vo(nm.Json)(ce);yield*O(De)}),F=W("updateConfig")(function*(ce){let De=yield*v,Fe=nm.make({...De.config,...ce}),st=yield*vo(nm.Json)(Fe).pipe(N(Tu(aq))),Yt={...t0t(De.raw,st)};if(Object.hasOwn(ce,"anonymousSession")&&ce.anonymousSession===void 0)delete Yt.anonymousSession;let rr=yield*vo(aq)(Yt);yield*O(rr)});function C(ce){return Q().pipe(be(rm(n,F(ce))))}let R=W("readConfigFile")(function*(){return yield*v.pipe(K(({config:ce})=>({config:ce,parseFailed:!1})),nl(()=>({config:nm.make({}),parseFailed:!0})))}),L=W("clearConfig")(function*(){let ce=yield*jt(v);if(qt(ce)){if(!(ce.left instanceof Ay))return yield*ce.left;yield*tl(`Could not parse ${n}; removing it. Telemetry preferences and apiUrl were not preserved.`),yield*t.remove(n).pipe(fe(()=>new dy({path:n})));return}let De={...ce.right.raw};delete De.authMethod,delete De.anonymousSession;let Fe=yield*vo(aq)(De);yield*O(Fe)});function G(){return Q().pipe(be(rm(n,L())))}let ae=W("getApiUrl")(function*(){let{config:ce}=yield*QPe,De=yield*H,Fe={env:vt(ce.apiUrl),file:vt(De.apiUrl)};return ZQ([Fe.env,Fe.file]).pipe(Ue(()=>new URL(cq)))}),Me=W("getAppUrl")(function*(){return yield*Ht("EXPAND_APP_URL").pipe(yr(YBt))}),He=W("getPlaygroundHost")(function*(){return yield*Ht("EXPAND_PLAYGROUND_HOST").pipe(yr(VC))});return{configPath:n,inspectSecureStorage:B,ensureSecureStorage:Q,loadConfig:T,saveConfig:j,updateConfig:C,clearConfig:G,readConfigFile:R,getApiUrl:ae,getAppUrl:Me,getPlaygroundHost:He}})}){}var ZC="Open the approval page in your browser, type in the code shown here, and approve. Only enter this code on the Expand approval page your terminal named — never a code someone sent you, and never on a page from a link you did not expect. When you have approved, say so, and the same command will pick the authorization up.",dq="Authorization complete. That setup code has been consumed and cannot be reused.",Aq="Expand is already authorized. Agent setup is complete.",pee="Expand is authorized, but not every harness could be configured. The harnesses that failed are listed under `failures`; the ones under `installations` are ready to use.",fee="Show these harnesses to the user and ask which to configure. Pass the chosen ones to `expandai init --harnesses`. Harnesses that are not chosen are left untouched.",dee="No supported agent harness was found on this machine. Do not ask the user to choose from an empty list. Tell them Expand supports claude-code, cursor, opencode, codex, and fx, and that setup cannot continue until one of them is installed.",ii=V("claude-code","cursor","opencode","codex","fx");class hq extends Ne("InitDetectionResult")({schemaVersion:V(1),status:V("detected"),harnesses:ve(ii),current:z(ii),userMessage:V(fee,dee)}){}var Aee=eB(ii),Va=V("project","global"),i0t=V("webfetch-hook","runtime-skill","mcp"),s0t=V("unverified","observed","reload_required","blocked"),zhr=V("authorization_required","completed"),a0t=E.pipe(yn(20),wP(256)),c0t=uh(a0t,fh(E),{strict:!0,decode:(e)=>e,encode:()=>"<redacted-redacted-setup-token>"});class mq extends Ne("InitRequest")({harnesses:Aee,scope:Va,setupToken:z(c0t)}){}var l0t=q({schemaVersion:V(1),status:V("authorization_required"),harnesses:Aee,scope:Va,userMessage:V(ZC),authorization:q({url:Kg,userCode:E,approvalExpiresAt:id})}),u0t=q({runtimeState:s0t,nextAction:E}),p0t=q({harness:ii,configured:Ie,changed:Ie,components:ve(i0t),version:E,verification:u0t}),f0t=q({harness:ii,code:E,recoverable:Ie}),d0t=q({schemaVersion:V(1),status:V("completed"),harnesses:Aee,scope:Va,userMessage:V(dq,Aq,pee),auth:q({healthy:Ie}),projectPath:z(E),installations:eB(p0t),failures:z(ve(f0t))}),EO=Je(l0t,d0t);class hy extends Ne("InitErrorEnvelope")({schemaVersion:V(1),status:V("error"),code:E,message:E,recoverable:Ie}){}var Zu="expandai-cli-browser",A0t=q({apiOrigin:E,clientId:V(Zu),purpose:z(V("login","agent-setup")),harness:V("agent-harnesses"),scope:V("project","global"),canonicalScopeRoot:E});class K0 extends Ne("PendingInitRecord")({key:A0t,deviceCode:fh(E),userCode:E,verificationUri:E,intervalSeconds:de,nextPollAt:id,approvalExpiresAt:id}){}class im extends et()("PendingInitCorrupt",{path:E,error:Vt}){recoverable=!0;get message(){return`Pending authorization state at ${this.path} is corrupt and was left unchanged.`}}class hee extends et()("PendingInitStorageError",{path:E,error:Vt}){recoverable=!0;get message(){return`Could not access pending authorization state at ${this.path}.`}}class mee extends Ne("DeviceAuthorizationCreated")({deviceCode:fh(fs),userCode:fs,verificationUri:Kg,expiresIn:hr.pipe(xK()),interval:hr.pipe(o6e())}){}var h0t=q({access_token:fh(fs),refresh_token:fh(fs),token_type:fs,expires_in:de.pipe(xK()),scope:z(E)}),m0t=V("create","poll");class Xu extends et()("DeviceAuthorizationApiError",{operation:m0t,kind:V("request_failed","rejected","invalid_response"),status:z(de),recoverable:Ie}){get message(){return this.kind==="rejected"?`Device authorization ${this.operation} was rejected. Restart authorization if the problem persists.`:`Device authorization ${this.operation} could not be completed safely. Try again.`}}class gq extends Ct()("@expandai/cli/Auth/DeviceAuthorizationClient",{dependencies:[Yd,Bt.Default],effect:Y(function*(){let e=yield*Mh,t=yield*Bt;function r(a,c,l){return new Xu({operation:a,kind:c,status:l,recoverable:c!=="invalid_response"})}let n=W("DeviceAuthorizationClient.create")(function*(a){let c=yield*t.getApiUrl(),l=yield*FB(new URL("/v1/cli-authorization/device",c)).pipe(yl(a),fe(()=>r("create","request_failed")));return yield*e.execute(l).pipe(N((u)=>Wt(u.status).pipe(Qe((p)=>p>=200&&p<300,()=>Ws(mee)(u).pipe(fe(()=>r("create","invalid_response")))),hd(()=>u.text.pipe(tn,be(r("create","rejected",u.status)))))),Ft((u)=>u instanceof Xu?u:r("create","request_failed")))}),o=q({error:E,error_description:z(E)}),i=new Set(["invalid_target","invalid_client","invalid_scope","unsupported_grant_type","unauthorized_client","invalid_request"]),s=W("DeviceAuthorizationClient.poll")(function*(a){let c=yield*t.getApiUrl(),l=FB(new URL("/api/auth/oauth2/token",c)).pipe(rwe({grant_type:"urn:ietf:params:oauth:grant-type:device_code",device_code:oa(a),client_id:Zu,resource:c.toString()}));return yield*e.execute(l).pipe(N(Ce(function*(u){return yield*Wt(u.status).pipe(Qe((p)=>p>=200&&p<300,()=>Ws(h0t)(u).pipe(fe(()=>r("poll","invalid_response")),K((p)=>({_tag:"Tokens",token:p})))),Qe((p)=>p>=500,()=>u.text.pipe(tn,be(r("poll","rejected",u.status)))),hd(()=>Ws(o)(u).pipe(fe(()=>r("poll","invalid_response")),K((p)=>Wt(p.error).pipe(Qe("authorization_pending",()=>({_tag:"Pending"})),Qe("slow_down",()=>({_tag:"SlowDown"})),Qe("access_denied",()=>({_tag:"Denied"})),Qe("expired_token",()=>({_tag:"Expired"})),hd(()=>i.has(p.error)?{_tag:"Refused",error:p.error,...p.error_description===void 0?{}:{description:p.error_description}}:{_tag:"Invalid"}))))))})),Ft((u)=>u instanceof Xu?u:r("poll","request_failed")))});return{create:n,poll:s}})}){}var Si="0.1.4";class DPe extends DS()("DeviceAuthorizationTokensSaved",{}){}class RPe extends DS()("DeviceAuthorizationPending",{}){}class vPe extends DS()("DeviceAuthorizationSlowDown",{}){}class TPe extends DS()("DeviceAuthorizationExpired",{}){}class OPe extends DS()("DeviceAuthorizationInvalid",{}){}class gf extends et()("DeviceAuthorizationDenied",{recoverable:V(!0)}){get message(){return"The authorization request was denied in the browser. Run the same command again to start a new one."}}class sm extends et()("DeviceAuthorizationRefused",{error:E,description:z(E),recoverable:V(!1)}){get message(){let e=this.description===void 0?"":` — ${this.description}`;return`Expand refused to complete this authorization: ${this.error}${e}. This is a server-side configuration problem, not something a new code can fix. Do not start authorization again; report this error.`}}class am extends et()("DeviceAuthorizationCredentialSaveFailed",{recoverable:V(!1)}){get message(){return"Authorization succeeded, but credentials could not be saved. Start authorization again."}}function kPe(e){return e.platform??process.platform}class XC extends Ct()("@expandai/cli/Auth/DeviceAuthorization",{dependencies:[Bt.Default,gq.Default],effect:Y(function*(){let e=yield*Bt,t=yield*gq,r=W("DeviceAuthorization.create")(function*(i){yield*e.ensureSecureStorage();let s={platform:kPe(i),machineLabel:`${kPe(i)}-${process.arch}`,cliVersion:Si};return yield*i.purpose==="login"?t.create({purpose:"login",harness:"agent-harnesses",scope:"global",...s}):t.create({purpose:"agent-setup",harness:i.harness,scope:i.scope,...s})}),n=Ce(function*(i){let s=yield*fc,a=yield*jt(e.updateConfig({authMethod:mO.make({accessToken:i.access_token,refreshToken:i.refresh_token,expiresAt:zw(s,Yc(i.expires_in)),clientId:Zu})}));return yield*Wn(a,{onLeft:()=>new am({recoverable:!1}),onRight:()=>Z})}),o=W("DeviceAuthorization.poll")(function*(i){let s=yield*t.poll(i);return yield*Wt(s).pipe(xr("Tokens",({token:a})=>n(a).pipe(un(new DPe))),xr("Pending",()=>M(new RPe)),xr("SlowDown",()=>M(new vPe)),xr("Denied",()=>new gf({recoverable:!0})),xr("Expired",()=>M(new TPe)),xr("Invalid",()=>M(new OPe)),xr("Refused",({error:a,description:c})=>new sm({error:a,...c===void 0?{}:{description:c},recoverable:!1})),Sr)});return{create:r,poll:o}})}){}import{createHash as g0t}from"node:crypto";var gee=Nt(K0),E0t=300000,MPe=Nt(Je(BS(E,V(Zu),V("agent-harnesses"),V("project","global"),E),BS(E,V(Zu),V("login"))));function Eee(e,t){return typeof e==="object"&&e!==null&&"code"in e&&e.code===t}function y0t(e){return e instanceof ji&&(e.reason==="AlreadyExists"||Eee(e.cause,"EEXIST"))}function x0t(e){return e instanceof ji&&(e.reason==="NotFound"||Eee(e.cause,"ENOENT"))}function S0t(e){return e.purpose==="login"?Do(MPe)([e.apiOrigin,e.clientId,e.purpose]):Do(MPe)([e.apiOrigin,e.clientId,e.harness,e.scope,e.canonicalScopeRoot])}function _Pe(e,t){let r=e.dirname(t);return r===t?[t]:[t,..._Pe(e,r)]}class cm extends Ct()("@expandai/cli/Auth/PendingInitStore",{dependencies:[Uv],effect:Y(function*(){let e=yield*lr,t=yield*sr,r=t.join(yield*J0,"expandai"),n=t.join(r,"pending-init"),o=(S,Q)=>new hee({path:S,error:Q}),i=(S,Q)=>Q.pipe(fe((I)=>o(S,I))),s=Ce(function*(S){let Q=yield*jt(e.readLink(S));if(vn(Q))return yield*o(S,Error("Symbolic links are not allowed for pending authorization"));let I=Q.left;if(I instanceof ji&&(I.reason==="InvalidData"||I.reason==="NotFound"||I.method==="readLink"&&Eee(I.cause,"EINVAL")))return;return yield*o(S,I)}),a=Ce(function*(){if(yield*s(r),yield*s(n),yield*i(n,e.makeDirectory(n,{recursive:!0,mode:448})),yield*s(r),yield*s(n),(yield*i(n,e.stat(n))).type!=="Directory")return yield*o(n,Error("Pending authorization path is not a directory"));if(process.platform!=="win32")yield*i(r,e.chmod(r,448)),yield*i(n,e.chmod(n,448))}),c=(S)=>{let Q=g0t("sha256").update(S0t(S)).digest("hex");return t.join(n,`${Q}.json`)},l=Ce(function*(S,Q){let I=yield*Tu(gee)(Q).pipe(fe(()=>new im({path:S,error:Error("Stored pending authorization did not match the expected schema")})));if(c(I.key)!==S)return yield*new im({path:S,error:Error("Stored pending authorization key did not match its file")});return I}),u=Ce(function*(S){if(yield*s(S),!(yield*i(S,e.exists(S))))return U();let I=yield*i(S,e.stat(S));if(I.type!=="File")return yield*o(S,Error("Pending state is not a regular file"));if(process.platform!=="win32"&&(I.mode&511)!==384)return yield*o(S,Error("Pending state file mode is not 600"));let O=yield*i(S,e.readFileString(S));return P(yield*l(S,O))}),p=(S)=>u(c(S)),f=Ce(function*(S){let Q=wR(yield*fc);return wR(S.approvalExpiresAt)+E0t<=Q}),d=Ce(function*(S){yield*a();let Q=c(S.key),I=yield*vo(gee)(S).pipe(fe((v)=>o(Q,v))),O=yield*jt(Tr(Y(function*(){let v=yield*e.open(Q,{flag:"wx",mode:384});yield*v.writeAll(new TextEncoder().encode(I)),yield*v.sync})));if(qt(O)){if(y0t(O.left))return!1;return yield*e.remove(Q).pipe(tn),yield*o(Q,O.left)}if(process.platform!=="win32"){let v=yield*jt(e.chmod(Q,384));if(qt(v))return yield*e.remove(Q).pipe(tn),yield*o(Q,v.left)}return!0}),A=W("PendingInitStore.replaceIfMatch")(function*(S,Q){yield*a();let I=c(Q.key);if(c(S.key)!==I)return yield*o(I,Error("Pending authorization replacement changed its key"));let O=yield*u(I);if(ze(O)||O.value.userCode!==S.userCode)return!1;let v=yield*vo(gee)(Q).pipe(fe((j)=>o(I,j))),H=`${I}.${process.pid}.${Math.random().toString(36).slice(2,10)}.tmp`,T=yield*Tr(vr(M(H),()=>e.remove(H).pipe(tn)).pipe(be(Y(function*(){yield*s(H),yield*Tr(Y(function*(){let j=yield*e.open(H,{flag:"wx",mode:384});yield*j.writeAll(new TextEncoder().encode(v)),yield*j.sync})),yield*e.rename(H,I)})))).pipe(jt);if(qt(T))return yield*o(I,T.left);return!0}),m=Ce(function*(S){let Q=c(S.key),I=yield*u(Q);if(ze(I)||I.value.userCode!==S.userCode)return!1;return yield*i(Q,e.remove(Q)),!0}),g=W("PendingInitStore.get")(function*(S){let Q=yield*p(S);if(ze(Q)||!(yield*f(Q.value)))return Q;return yield*m(Q.value),U()}),y=W("PendingInitStore.peek")(function*(S){return yield*p(S)}),w=W("PendingInitStore.putIfAbsent")(function*(S){let Q=yield*p(S.key);if(ne(Q)&&!(yield*f(Q.value)))return Q.value;if(ne(Q))yield*m(Q.value);if(yield*d(S))return S;let I=yield*p(S.key);return yield*Te(I,{onNone:()=>o(c(S.key),Error("Pending record creation lost without a winner")),onSome:M})}),b=W("PendingInitStore.removeIfMatch")((S)=>m(S)),D=W("PendingInitStore.removeCorrupt")(function*(S){let Q=c(S),I=yield*jt(u(Q));if(vn(I))return!1;if(!(I.left instanceof im))return yield*I.left;let O=yield*jt(e.remove(Q));if(qt(O)&&x0t(O.left))return!1;if(qt(O))return yield*o(Q,O.left);return!0}),k=W("PendingInitStore.pruneExpired")(function*(){if(yield*s(n),!(yield*i(n,e.exists(n))))return 0;let Q=yield*i(n,e.readDirectory(n));return(yield*ot(Q.filter((O)=>O.endsWith(".json")),(O)=>Y(function*(){let v=yield*u(t.join(n,O));if(ze(v)||!(yield*f(v.value)))return 0;return(yield*m(v.value))?1:0}).pipe(nl(()=>0)))).reduce((O,v)=>O+v,0)}),B=W("PendingInitStore.canonicalScopeRoot")(function*(S,Q=process.cwd()){if(S==="global")return"global";let I=yield*i(Q,e.realPath(Q)),v=(yield*ot(_Pe(t,I),(H)=>i(H,e.exists(t.join(H,".git"))).pipe(K((T)=>({candidate:H,exists:T}))))).find(({exists:H})=>H)?.candidate;return v===void 0?I:yield*i(v,e.realPath(v))});return{pendingPath:n,get:g,peek:y,putIfAbsent:w,replaceIfMatch:A,removeIfMatch:b,removeCorrupt:D,pruneExpired:k,canonicalScopeRoot:B}})}){}var C0t=Zu,I0t=5;class yO extends Ne("ManualAuthorizationInput")({purpose:_(V("login","agent-setup"),{default:()=>"agent-setup"}),harness:V("agent-harnesses"),scope:Va,cwd:z(E),platform:z(E)}){}class yee extends Ne("ManualAuthorizationRequired")({verificationUri:E,userCode:fs,approvalExpiresAt:id}){}class xee extends DS()("TokensSaved",{}){}class my extends DS()("AuthorizationPending",{pending:yee}){}var bmr=Je(xee,my);function Z0(e){return new yee({verificationUri:e.verificationUri,userCode:e.userCode,approvalExpiresAt:e.approvalExpiresAt})}class ep extends Ct()("@expandai/cli/Auth/ManualAuthorization",{dependencies:[Bt.Default,cm.Default,XC.Default],effect:Y(function*(){let e=yield*Bt,t=yield*cm,r=yield*XC,n=Ce(function*(l){yield*e.ensureSecureStorage(),yield*t.pruneExpired();let u=yield*e.getApiUrl(),p=yield*t.canonicalScopeRoot(l.scope,l.cwd);return{apiOrigin:u.origin,clientId:C0t,purpose:l.purpose,harness:l.harness,scope:l.scope,canonicalScopeRoot:p}}),o=Ce(function*(l,u){let p=l.platform===void 0?{}:{platform:l.platform},f=yield*r.create(l.purpose==="login"?{purpose:"login",...p}:{purpose:"agent-setup",harness:l.harness,scope:l.scope,...p}),d=yield*fc,A=new K0({key:u,deviceCode:f.deviceCode,userCode:f.userCode,verificationUri:f.verificationUri.toString(),intervalSeconds:f.interval,nextPollAt:zw(d,Yc(f.interval)),approvalExpiresAt:zw(d,Yc(f.expiresIn))}),m=yield*jt(t.putIfAbsent(A));if(qt(m))return yield*m.left;return m.right}),i=Ce(function*(l,u){let p=yield*fc,f=l.intervalSeconds+(u?I0t:0),d=new K0({...l,intervalSeconds:f,nextPollAt:zw(p,Yc(f))}),A=yield*jt(t.replaceIfMatch(l,d));if(qt(A))return l;return A.right?d:l}),s=Ce(function*(l,u){let p=yield*jt(t.get(u));if(vn(p))return p.right;if(l.purpose!=="login"||!(p.left instanceof im))return yield*p.left;return yield*t.removeCorrupt(u),yield*t.get(u)}),a=W("ManualAuthorization.advance")(function*(l){let u=yield*n(l),p=yield*s(l,u);if(ze(p)){let g=yield*o(l,u);return new my({pending:Z0(g)})}let f=p.value,d=yield*fc;if(BXe(d,f.approvalExpiresAt)){yield*t.removeIfMatch(f);let g=yield*o(l,u);return new my({pending:Z0(g)})}if(AP(d,f.nextPollAt))return new my({pending:Z0(f)});let A=yield*jt(r.poll(f.deviceCode)),m=Ce(function*(){yield*t.removeIfMatch(f);let g=yield*o(l,u);return new my({pending:Z0(g)})});return yield*Wn(A,{onLeft:(g)=>t.removeIfMatch(f).pipe(Ms(()=>g instanceof gf),be(se(g))),onRight:(g)=>Wt(g).pipe(xr("DeviceAuthorizationTokensSaved",()=>t.removeIfMatch(f).pipe(un(new xee))),xr("DeviceAuthorizationPending",()=>i(f,!1).pipe(K((y)=>new my({pending:Z0(y)})))),xr("DeviceAuthorizationSlowDown",()=>i(f,!0).pipe(K((y)=>new my({pending:Z0(y)})))),xr("DeviceAuthorizationExpired",m),xr("DeviceAuthorizationInvalid",m),Sr)})}),c=W("ManualAuthorization.redeemPreApproved")(function*(l){let u=yield*r.poll(l);function p(){return new Xu({operation:"poll",kind:"rejected",status:400,recoverable:!1})}return yield*Wt(u).pipe(xr("DeviceAuthorizationTokensSaved",()=>Z),xr("DeviceAuthorizationPending",p),xr("DeviceAuthorizationSlowDown",p),xr("DeviceAuthorizationExpired",p),xr("DeviceAuthorizationInvalid",p),Sr)});return{advance:a,redeemPreApproved:c}})}){}var FPe="Authorization complete. Expand is ready to use; retry the command that required authentication.",b0t=V("authorization_internal_error","authorization_unreachable","authorization_rejected","authorization_service_unavailable","authorization_invalid_response","authorization_denied","authorization_refused","credential_save_failed","credential_storage_insecure");class Tc extends et()("DeviceLoginError",{code:b0t,recoverable:Ie,httpStatus:z(de)}){get message(){switch(this.code){case"authorization_internal_error":return"Authorization failed for an unexpected internal reason. Do not retry in a loop; report this error.";case"authorization_unreachable":return"Could not reach the Expand API. Nothing was changed: any pending authorization is still pending, and if none existed, none was started. Do not retry until the connection is fixed; then run the same command again.";case"authorization_rejected":return"The Expand API rejected the device authorization request. Retry later; if this persists, the CLI and API versions may be incompatible.";case"authorization_service_unavailable":return`The Expand device authorization service is unavailable${this.httpStatus===void 0?"":` (HTTP ${this.httpStatus})`}. Retry later or use the staging API for an isolated test.`;case"authorization_invalid_response":return"The Expand API returned an invalid device authorization response. Do not continue with a URL or code from this response; update the CLI or report the problem.";case"authorization_denied":return"The authorization was denied in the browser. If that was unintended, run the same command again for a fresh approval code.";case"authorization_refused":return"Expand refused to complete the authorization for a reason a new code cannot fix. Do not start another authorization; report the error.";case"credential_save_failed":return"Authorization completed, but credentials could not be saved. Fix credential storage before starting again.";case"credential_storage_insecure":return"Credential storage is not secure enough to continue."}}}class yq extends Ne("DeviceLoginErrorEnvelope")({schemaVersion:V(1),status:V("error"),code:E,message:E,recoverable:Ie}){}var w0t=q({schemaVersion:V(1),status:V("authorization_required"),userMessage:V(ZC),authorization:q({url:Kg,userCode:fs,approvalExpiresAt:id})}),B0t=q({schemaVersion:V(1),status:V("completed"),userMessage:V(FPe),auth:q({healthy:V(!0)})}),Eq=Je(w0t,B0t);function Q0t(e){if(e instanceof vc)return new Tc({code:"credential_storage_insecure",recoverable:!1});if(e instanceof gf)return new Tc({code:"authorization_denied",recoverable:!0});if(e instanceof sm)return new Tc({code:"authorization_refused",recoverable:!1});if(e instanceof am)return new Tc({code:"credential_save_failed",recoverable:!1});if(e instanceof Xu)switch(e.kind){case"request_failed":return new Tc({code:"authorization_unreachable",recoverable:!0});case"rejected":if(e.status!==void 0&&e.status>=500)return new Tc({code:"authorization_service_unavailable",recoverable:!0,httpStatus:e.status});return new Tc({code:"authorization_rejected",recoverable:e.recoverable});case"invalid_response":return new Tc({code:"authorization_invalid_response",recoverable:!1})}return new Tc({code:"authorization_internal_error",recoverable:!1})}class xO extends Ct()("@expandai/cli/Auth/DeviceLogin",{dependencies:[ep.Default],effect:Y(function*(){let e=yield*ep;return{run:W("DeviceLogin.run")(function*(){let r=yield*e.advance(new yO({purpose:"login",harness:"agent-harnesses",scope:"global"})).pipe(fe(Q0t));return yield*Wt(r).pipe(xr("TokensSaved",()=>ir(Eq)({schemaVersion:1,status:"completed",userMessage:FPe,auth:{healthy:!0}}).pipe(fe(()=>new Tc({code:"authorization_internal_error",recoverable:!1})))),xr("AuthorizationPending",({pending:n})=>ir(Eq)({schemaVersion:1,status:"authorization_required",userMessage:ZC,authorization:{url:n.verificationUri,userCode:n.userCode,approvalExpiresAt:SS(n.approvalExpiresAt)}}).pipe(fe(()=>new Tc({code:"authorization_internal_error",recoverable:!1})))),Sr)})}})}){}class xq extends et()("SetupGrantAuthorizationError",{code:V("invalid_or_expired","stored_credential_conflict","request_failed","denied","credential_save_failed","refused","config_unreadable"),recoverable:Ie}){get message(){switch(this.code){case"stored_credential_conflict":return"An Expand API key is already stored on this machine, and completing this setup would replace it with no way to recover it. Nothing was changed and your setup prompt is still valid. Run `expandai logout` to clear the stored key, then run this setup command again.";case"request_failed":return"Could not reach Expand to redeem the setup token. Nothing was sent, so the same token is still good — check the network and try again.";case"denied":return"This setup authorization was denied. Copy a fresh setup prompt from the Expand dashboard.";case"config_unreadable":return"The Expand config file on this machine could not be read, so setup cannot tell whether completing it would overwrite an existing API key. Nothing was redeemed and your setup prompt is still valid. Run `expandai whoami` to see which file it is, fix or delete it, then run this setup command again.";case"refused":return"Expand refused to redeem this setup token for a reason a fresh prompt cannot fix — most likely an OAuth client, resource, or scope misconfiguration on the server. Do not request another prompt; report this.";case"credential_save_failed":return"The setup token was redeemed, but the credentials could not be saved on this machine. Fix credential storage — run `expandai whoami` to see the path it uses, and check its permissions — then copy a fresh setup prompt from the Expand dashboard.";default:return"The setup token is invalid, expired, or already used. Copy a fresh setup prompt from the Expand dashboard."}}}function eI(e){return new xq({code:e,recoverable:e!=="denied"&&e!=="credential_save_failed"&&e!=="refused"})}class X0 extends Ct()("@expandai/cli/Auth/SetupGrantAuthorization",{dependencies:[Bt.Default,ep.Default],effect:Y(function*(){let e=yield*Bt,t=yield*ep;return{authorize:W("SetupGrantAuthorization.authorize")(function*(n){let o=yield*e.readConfigFile();if(o.parseFailed)return yield*eI("config_unreadable");if(o.config.authMethod?._tag==="ApiKey")return yield*eI("stored_credential_conflict");yield*Kx({harness:n.harness,scope:n.scope}),yield*t.redeemPreApproved(n.setupToken).pipe(fe((i)=>{if(i instanceof gf)return eI("denied");if(i instanceof am)return eI("credential_save_failed");if(i instanceof sm)return eI("refused");if(i instanceof Xu&&i.kind==="request_failed")return eI("request_failed");return eI("invalid_or_expired")}))})}})}){}import oHe from"node:process";import _ee from"node:path";import{fileURLToPath as uQt}from"node:url";import pQt from"node:child_process";import fQt,{constants as dQt}from"node:fs/promises";import U0t from"node:path";import{promisify as P0t}from"node:util";import H0t from"node:child_process";import Bee,{constants as zPe}from"node:fs/promises";import UPe from"node:process";import T0t from"node:os";import bee from"node:fs";import R0t from"node:fs";import NPe from"node:fs";var See;function k0t(){try{return NPe.statSync("/.dockerenv"),!0}catch{return!1}}function D0t(){try{return NPe.readFileSync("/proc/self/cgroup","utf8").includes("docker")}catch{return!1}}function Cee(){if(See===void 0)See=k0t()||D0t();return See}var Iee,v0t=()=>{try{return R0t.statSync("/run/.containerenv"),!0}catch{return!1}};function tI(){if(Iee===void 0)Iee=v0t()||Cee();return Iee}var LPe=()=>{if(UPe.platform!=="linux")return!1;if(T0t.release().toLowerCase().includes("microsoft")){if(tI())return!1;return!0}try{if(bee.readFileSync("/proc/version","utf8").toLowerCase().includes("microsoft"))return!tI()}catch{}if(bee.existsSync("/proc/sys/fs/binfmt_misc/WSLInterop")||bee.existsSync("/run/WSL"))return!tI();return!1},jd=UPe.env.__IS_WSL_TEST__?LPe:LPe();import PPe from"node:process";import{Buffer as O0t}from"node:buffer";import{promisify as M0t}from"node:util";import _0t from"node:child_process";var F0t=M0t(_0t.execFile),wee=()=>`${PPe.env.SYSTEMROOT||PPe.env.windir||String.raw`C:\Windows`}\\System32\\WindowsPowerShell\\v1.0\\powershell.exe`;var HPe=["-NoProfile","-NonInteractive","-ExecutionPolicy","Bypass","-EncodedCommand"],WPe=(e)=>O0t.from(e,"utf16le").toString("base64"),N0t=(e)=>`'${String(e).replaceAll(/['‘’‚‛]/g,(t)=>t+t)}'`,qPe=(e)=>[...HPe,WPe(e)],L0t=(e)=>({encoding:"utf8",...e,shell:!1}),tp=async(e,t={})=>{let{powerShellPath:r,...n}=t;return F0t(r??wee(),qPe(e),L0t(n))};tp.argumentsPrefix=HPe;tp.encodeCommand=WPe;tp.escapeArgument=N0t;tp.createArguments=qPe;function GPe(e){for(let t of e.split(`
|
|
301
|
+
`,m=[process.env.USERPROFILE,zBt()].filter((ce)=>typeof ce==="string"&&ce.trim()!==""&&!cee(ce)),g=(ce)=>r.resolve(ce).toLowerCase().replace(/\\+$/,""),y=Ce(function*(ce){let De=(Yt)=>t.realPath(Yt).pipe(Ft(()=>M(Yt)),K(g)),Fe=yield*De(ce),st=yield*ot(m,De);return $Bt(Fe,st,r.sep)}),w=Ce(function*(ce,De,Fe){if(ce===0)return;let st=yield*y(o);return yield*o0t(o,ce,st,De,Fe)}),b=(ce,De)=>w(1,ce,De),D=Ce(function*(ce){let De=yield*vB("powershell.exe","-NoLogo","-NoProfile","-NonInteractive","-Command",wPe(d,ce)).pipe(aee,jr(gE,e),Ft((Fe)=>b("could not run the Windows ACL allowlist script",String(Fe)).pipe(un(0))));yield*w(De,"the Windows ACL allowlist script did not complete",`PowerShell exited with status ${De}`)}),k=Ce(function*(ce){let De=yield*vB("powershell.exe","-NoLogo","-NoProfile","-NonInteractive","-Command",wPe(A,ce)).pipe(aee,jr(gE,e),Ft((Fe)=>b("could not inspect the Windows ACL allowlist",String(Fe)).pipe(un(0))));yield*w(De,"the Windows ACL allowlist could not be verified",`PowerShell exited with status ${De}`)}),B=W("ConfigManager.inspectSecureStorage")(function*(){let ce=yield*a(o);if(!ce.exists)return yield*Z;if(ce.type!=="Directory")return yield*i(o,"config directory is not a regular directory",Error("Invalid config directory"));let De=yield*a(n);if(De.exists&&De.type!=="File")return yield*i(n,"credential path is not a regular file",Error("Invalid file"));if(process.platform==="win32"){let st=De.exists?[o,n]:[o],Yt=yield*ot(st,a);yield*k(st);let rr=yield*ot(st,a);return yield*ot(st,(io,bi)=>c(io,Yt[bi]??{exists:!1},rr[bi]??{exists:!1}),{discard:!0}),yield*Z}if(((yield*t.stat(o).pipe(fe((st)=>i(o,"could not inspect directory mode",st)))).mode&4095)!==448)return yield*i(o,"config directory mode is not 700",Error("Invalid directory mode"));if(De.exists){if(((yield*t.stat(n).pipe(fe((Yt)=>i(n,"could not inspect credential file mode",Yt)))).mode&4095)!==384)return yield*i(n,"credential file mode is not 600",Error("Invalid file mode"))}return yield*Z}),S=W("ConfigManager.ensureSecureStorage")(function*(){yield*t.makeDirectory(o,{recursive:!0,mode:448}).pipe(fe((Fe)=>i(o,"could not create the config directory",Fe)));let ce=yield*a(o);if(!ce.exists||ce.type!=="Directory")return yield*i(o,"config directory is not a regular directory",Error("Invalid config directory"));if(!(yield*t.exists(n).pipe(fe((Fe)=>i(n,"could not inspect the credential file",Fe))))){let Fe=yield*jt(t.writeFileString(n,"{}",{flag:"wx",mode:384}));if(qt(Fe)&&(!(Fe.left instanceof ji)||Fe.left.reason!=="AlreadyExists"))return yield*i(n,"could not create the credential file",Fe.left)}if(yield*l(n),process.platform==="win32"){let Fe=[o,n],st=yield*ot(Fe,(rr)=>a(rr));yield*D(Fe);let Yt=yield*ot(Fe,(rr)=>a(rr));yield*ot(Fe,(rr,io)=>c(rr,st[io]??{exists:!1},Yt[io]??{exists:!1}),{discard:!0})}else yield*f(o,448,"Directory"),yield*f(n,384,"File");return yield*Z});function Q(){return t.makeDirectory(o,{recursive:!0,mode:448}).pipe(fe((ce)=>i(o,"could not create the config directory",ce)),be(process.platform==="win32"?D([o]):f(o,448,"Directory")),be(rm(n,S())))}let I=Ce(function*(ce){yield*Q();let De=yield*l(n),Fe=yield*d5e(0,2147483647),st=r.join(o,`.config.json.${process.pid}.${Fe.toString(16)}.tmp`),Yt=Ce(function*(Cs,js){let Is=yield*jt(l(st));if(qt(Is))return yield*new JC({path:n,temporaryPath:st,error:Is.left,operationError:js});if(!BPe(De.parent,Is.right.parent))return yield*new JC({path:n,temporaryPath:st,error:Error("Config temp parent identity changed; refusing cleanup"),operationError:js});if(!$0(Cs,Is.right.file))return yield*new JC({path:n,temporaryPath:st,error:Error("Config temp identity changed or disappeared; refusing cleanup"),operationError:js});let vI=yield*jt(t.remove(st));if(qt(vI))return yield*new JC({path:n,temporaryPath:st,error:vI.left,operationError:js})}),rr=yield*bPe(t,st,ce,384).pipe(fe(()=>new dy({path:st})));if($o(rr.writeExit)){let Cs=new dy({path:st});return yield*Yt(rr.identity,Cs),yield*Cs}if(!rr.pathMatchesHandle){let Cs=new dy({path:st});return yield*Yt(rr.identity,Cs),yield*Cs}let io=yield*jt(Y(function*(){let Cs=yield*l(st);if(yield*c(De.parentPath,De.parent,Cs.parent),!$0(rr.identity,Cs.file))return yield*i(st,"config temp identity differs from its creating handle",Error("Config temp replacement detected"));if(process.platform==="win32"){yield*D([st]);let Is=yield*l(st);if(yield*c(De.parentPath,De.parent,Is.parent),!$0(rr.identity,Is.file))return yield*i(st,"config temp changed while applying its ACL",Error("Config temp replacement detected"))}else if(((yield*t.stat(st).pipe(fe((vI)=>i(st,"could not verify config temp mode",vI)))).mode&4095)!==384)return yield*i(st,"config temp mode is not 600",Error("Invalid config temp mode"));let js=yield*l(n);yield*c(De.parentPath,De.parent,js.parent),yield*c(n,De.file,js.file),yield*t.rename(st,n).pipe(fe(()=>new dy({path:n})))}));if(qt(io))return yield*Yt(rr.identity,io.left),yield*io.left;let bi=yield*l(n);if(yield*c(De.parentPath,De.parent,bi.parent),!$0(rr.identity,bi.file))return yield*i(n,"atomic credential installation identity could not be verified",Error("Installed file identity mismatch"))});function O(ce){return Q().pipe(be(rm(n,I(ce))))}let v=Y(function*(){if(!(yield*t.exists(n)))return{config:nm.make({}),raw:{}};let De=yield*p(n),Fe=yield*Tu(aq)(De).pipe(fe((rr)=>new Ay({path:n,error:rr})));return{config:yield*ir(nm)(Fe).pipe(fe((rr)=>new Ay({path:n,error:rr}))),raw:Fe}}),H=v.pipe(K(({config:ce})=>ce)),T=W("loadConfig")(function*(){let{config:ce,noAnonymous:De}=yield*QPe,Fe=yield*H,st={env:vt(ce.apiUrl),file:vt(Fe.apiUrl)},Yt={env:vt(ce.authMethod),file:vt(Fe.authMethod)};yield*tl(`EXPAND_API_URL overrides apiUrl from ${n}`).pipe(Ms(()=>e$e(st.env,st.file,(Is,vI)=>Is.toString()!==vI.toString()).pipe(Ue(()=>!1))));let rr=yield*fc,io=ZQ([st.env,st.file]).pipe(Ue(()=>new URL(cq))),bi=Yt.file.pipe(ns((Is)=>XBt(Is,io))),Cs=Yt.file.pipe(ns((Is)=>Is._tag==="OAuth"&&gO(Is,rr)),ns(()=>ze(Yt.env)||ze(bi))),js=ZQ([Cs,Yt.env,Yt.file]);return yield*tl(`EXPAND_API_KEY is set but ${n} holds credentials from \`expandai login\` or agent setup, which take precedence. Unset EXPAND_API_KEY to silence this, or run \`expandai logout\` to use the API key.`).pipe(Ms(()=>ne(Yt.env)&&ne(Cs))),yield*tl(`Using EXPAND_API_KEY for ${io.origin} because the stored login was issued by a different API origin.`).pipe(Ms(()=>ne(Yt.env)&&ne(bi))),yield*tl(`EXPAND_API_KEY overrides the API key stored in ${n}`).pipe(Ms(()=>ne(Yt.env)&&Rm(Yt.file,(Is)=>Is._tag==="ApiKey"))),{apiUrl:io,authMethod:js,anonymousSession:vt(Fe.anonymousSession),noAnonymous:De}}),j=W("saveConfig")(function*(ce){let De=yield*vo(nm.Json)(ce);yield*O(De)}),F=W("updateConfig")(function*(ce){let De=yield*v,Fe=nm.make({...De.config,...ce}),st=yield*vo(nm.Json)(Fe).pipe(N(Tu(aq))),Yt={...t0t(De.raw,st)};if(Object.hasOwn(ce,"anonymousSession")&&ce.anonymousSession===void 0)delete Yt.anonymousSession;let rr=yield*vo(aq)(Yt);yield*O(rr)});function C(ce){return Q().pipe(be(rm(n,F(ce))))}let R=W("readConfigFile")(function*(){return yield*v.pipe(K(({config:ce})=>({config:ce,parseFailed:!1})),nl(()=>({config:nm.make({}),parseFailed:!0})))}),L=W("clearConfig")(function*(){let ce=yield*jt(v);if(qt(ce)){if(!(ce.left instanceof Ay))return yield*ce.left;yield*tl(`Could not parse ${n}; removing it. Telemetry preferences and apiUrl were not preserved.`),yield*t.remove(n).pipe(fe(()=>new dy({path:n})));return}let De={...ce.right.raw};delete De.authMethod,delete De.anonymousSession;let Fe=yield*vo(aq)(De);yield*O(Fe)});function G(){return Q().pipe(be(rm(n,L())))}let ae=W("getApiUrl")(function*(){let{config:ce}=yield*QPe,De=yield*H,Fe={env:vt(ce.apiUrl),file:vt(De.apiUrl)};return ZQ([Fe.env,Fe.file]).pipe(Ue(()=>new URL(cq)))}),Me=W("getAppUrl")(function*(){return yield*Ht("EXPAND_APP_URL").pipe(yr(YBt))}),He=W("getPlaygroundHost")(function*(){return yield*Ht("EXPAND_PLAYGROUND_HOST").pipe(yr(VC))});return{configPath:n,inspectSecureStorage:B,ensureSecureStorage:Q,loadConfig:T,saveConfig:j,updateConfig:C,clearConfig:G,readConfigFile:R,getApiUrl:ae,getAppUrl:Me,getPlaygroundHost:He}})}){}var ZC="Open the approval page in your browser, type in the code shown here, and approve. Only enter this code on the Expand approval page your terminal named — never a code someone sent you, and never on a page from a link you did not expect. When you have approved, say so, and the same command will pick the authorization up.",dq="Authorization complete. That setup code has been consumed and cannot be reused.",Aq="Expand is already authorized. Agent setup is complete.",pee="Expand is authorized, but not every harness could be configured. The harnesses that failed are listed under `failures`; the ones under `installations` are ready to use.",fee="Show these harnesses to the user and ask which to configure. Pass the chosen ones to `expandai init --harnesses`. Harnesses that are not chosen are left untouched.",dee="No supported agent harness was found on this machine. Do not ask the user to choose from an empty list. Tell them Expand supports claude-code, cursor, opencode, codex, and fx, and that setup cannot continue until one of them is installed.",ii=V("claude-code","cursor","opencode","codex","fx");class hq extends Ne("InitDetectionResult")({schemaVersion:V(1),status:V("detected"),harnesses:ve(ii),current:z(ii),userMessage:V(fee,dee)}){}var Aee=eB(ii),Va=V("project","global"),i0t=V("webfetch-hook","runtime-skill","mcp"),s0t=V("unverified","observed","reload_required","blocked"),zhr=V("authorization_required","completed"),a0t=E.pipe(yn(20),wP(256)),c0t=uh(a0t,fh(E),{strict:!0,decode:(e)=>e,encode:()=>"<redacted-redacted-setup-token>"});class mq extends Ne("InitRequest")({harnesses:Aee,scope:Va,setupToken:z(c0t)}){}var l0t=q({schemaVersion:V(1),status:V("authorization_required"),harnesses:Aee,scope:Va,userMessage:V(ZC),authorization:q({url:Kg,userCode:E,approvalExpiresAt:id})}),u0t=q({runtimeState:s0t,nextAction:E}),p0t=q({harness:ii,configured:Ie,changed:Ie,components:ve(i0t),version:E,verification:u0t}),f0t=q({harness:ii,code:E,recoverable:Ie}),d0t=q({schemaVersion:V(1),status:V("completed"),harnesses:Aee,scope:Va,userMessage:V(dq,Aq,pee),auth:q({healthy:Ie}),projectPath:z(E),installations:eB(p0t),failures:z(ve(f0t))}),EO=Je(l0t,d0t);class hy extends Ne("InitErrorEnvelope")({schemaVersion:V(1),status:V("error"),code:E,message:E,recoverable:Ie}){}var Zu="expandai-cli-browser",A0t=q({apiOrigin:E,clientId:V(Zu),purpose:z(V("login","agent-setup")),harness:V("agent-harnesses"),scope:V("project","global"),canonicalScopeRoot:E});class K0 extends Ne("PendingInitRecord")({key:A0t,deviceCode:fh(E),userCode:E,verificationUri:E,intervalSeconds:de,nextPollAt:id,approvalExpiresAt:id}){}class im extends et()("PendingInitCorrupt",{path:E,error:Vt}){recoverable=!0;get message(){return`Pending authorization state at ${this.path} is corrupt and was left unchanged.`}}class hee extends et()("PendingInitStorageError",{path:E,error:Vt}){recoverable=!0;get message(){return`Could not access pending authorization state at ${this.path}.`}}class mee extends Ne("DeviceAuthorizationCreated")({deviceCode:fh(fs),userCode:fs,verificationUri:Kg,expiresIn:hr.pipe(xK()),interval:hr.pipe(o6e())}){}var h0t=q({access_token:fh(fs),refresh_token:fh(fs),token_type:fs,expires_in:de.pipe(xK()),scope:z(E)}),m0t=V("create","poll");class Xu extends et()("DeviceAuthorizationApiError",{operation:m0t,kind:V("request_failed","rejected","invalid_response"),status:z(de),recoverable:Ie}){get message(){return this.kind==="rejected"?`Device authorization ${this.operation} was rejected. Restart authorization if the problem persists.`:`Device authorization ${this.operation} could not be completed safely. Try again.`}}class gq extends Ct()("@expandai/cli/Auth/DeviceAuthorizationClient",{dependencies:[Yd,Bt.Default],effect:Y(function*(){let e=yield*Mh,t=yield*Bt;function r(a,c,l){return new Xu({operation:a,kind:c,status:l,recoverable:c!=="invalid_response"})}let n=W("DeviceAuthorizationClient.create")(function*(a){let c=yield*t.getApiUrl(),l=yield*FB(new URL("/v1/cli-authorization/device",c)).pipe(yl(a),fe(()=>r("create","request_failed")));return yield*e.execute(l).pipe(N((u)=>Wt(u.status).pipe(Qe((p)=>p>=200&&p<300,()=>Ws(mee)(u).pipe(fe(()=>r("create","invalid_response")))),hd(()=>u.text.pipe(tn,be(r("create","rejected",u.status)))))),Ft((u)=>u instanceof Xu?u:r("create","request_failed")))}),o=q({error:E,error_description:z(E)}),i=new Set(["invalid_target","invalid_client","invalid_scope","unsupported_grant_type","unauthorized_client","invalid_request"]),s=W("DeviceAuthorizationClient.poll")(function*(a){let c=yield*t.getApiUrl(),l=FB(new URL("/api/auth/oauth2/token",c)).pipe(rwe({grant_type:"urn:ietf:params:oauth:grant-type:device_code",device_code:oa(a),client_id:Zu,resource:c.toString()}));return yield*e.execute(l).pipe(N(Ce(function*(u){return yield*Wt(u.status).pipe(Qe((p)=>p>=200&&p<300,()=>Ws(h0t)(u).pipe(fe(()=>r("poll","invalid_response")),K((p)=>({_tag:"Tokens",token:p})))),Qe((p)=>p>=500,()=>u.text.pipe(tn,be(r("poll","rejected",u.status)))),hd(()=>Ws(o)(u).pipe(fe(()=>r("poll","invalid_response")),K((p)=>Wt(p.error).pipe(Qe("authorization_pending",()=>({_tag:"Pending"})),Qe("slow_down",()=>({_tag:"SlowDown"})),Qe("access_denied",()=>({_tag:"Denied"})),Qe("expired_token",()=>({_tag:"Expired"})),hd(()=>i.has(p.error)?{_tag:"Refused",error:p.error,...p.error_description===void 0?{}:{description:p.error_description}}:{_tag:"Invalid"}))))))})),Ft((u)=>u instanceof Xu?u:r("poll","request_failed")))});return{create:n,poll:s}})}){}var Si="0.1.5";class DPe extends DS()("DeviceAuthorizationTokensSaved",{}){}class RPe extends DS()("DeviceAuthorizationPending",{}){}class vPe extends DS()("DeviceAuthorizationSlowDown",{}){}class TPe extends DS()("DeviceAuthorizationExpired",{}){}class OPe extends DS()("DeviceAuthorizationInvalid",{}){}class gf extends et()("DeviceAuthorizationDenied",{recoverable:V(!0)}){get message(){return"The authorization request was denied in the browser. Run the same command again to start a new one."}}class sm extends et()("DeviceAuthorizationRefused",{error:E,description:z(E),recoverable:V(!1)}){get message(){let e=this.description===void 0?"":` — ${this.description}`;return`Expand refused to complete this authorization: ${this.error}${e}. This is a server-side configuration problem, not something a new code can fix. Do not start authorization again; report this error.`}}class am extends et()("DeviceAuthorizationCredentialSaveFailed",{recoverable:V(!1)}){get message(){return"Authorization succeeded, but credentials could not be saved. Start authorization again."}}function kPe(e){return e.platform??process.platform}class XC extends Ct()("@expandai/cli/Auth/DeviceAuthorization",{dependencies:[Bt.Default,gq.Default],effect:Y(function*(){let e=yield*Bt,t=yield*gq,r=W("DeviceAuthorization.create")(function*(i){yield*e.ensureSecureStorage();let s={platform:kPe(i),machineLabel:`${kPe(i)}-${process.arch}`,cliVersion:Si};return yield*i.purpose==="login"?t.create({purpose:"login",harness:"agent-harnesses",scope:"global",...s}):t.create({purpose:"agent-setup",harness:i.harness,scope:i.scope,...s})}),n=Ce(function*(i){let s=yield*fc,a=yield*jt(e.updateConfig({authMethod:mO.make({accessToken:i.access_token,refreshToken:i.refresh_token,expiresAt:zw(s,Yc(i.expires_in)),clientId:Zu})}));return yield*Wn(a,{onLeft:()=>new am({recoverable:!1}),onRight:()=>Z})}),o=W("DeviceAuthorization.poll")(function*(i){let s=yield*t.poll(i);return yield*Wt(s).pipe(xr("Tokens",({token:a})=>n(a).pipe(un(new DPe))),xr("Pending",()=>M(new RPe)),xr("SlowDown",()=>M(new vPe)),xr("Denied",()=>new gf({recoverable:!0})),xr("Expired",()=>M(new TPe)),xr("Invalid",()=>M(new OPe)),xr("Refused",({error:a,description:c})=>new sm({error:a,...c===void 0?{}:{description:c},recoverable:!1})),Sr)});return{create:r,poll:o}})}){}import{createHash as g0t}from"node:crypto";var gee=Nt(K0),E0t=300000,MPe=Nt(Je(BS(E,V(Zu),V("agent-harnesses"),V("project","global"),E),BS(E,V(Zu),V("login"))));function Eee(e,t){return typeof e==="object"&&e!==null&&"code"in e&&e.code===t}function y0t(e){return e instanceof ji&&(e.reason==="AlreadyExists"||Eee(e.cause,"EEXIST"))}function x0t(e){return e instanceof ji&&(e.reason==="NotFound"||Eee(e.cause,"ENOENT"))}function S0t(e){return e.purpose==="login"?Do(MPe)([e.apiOrigin,e.clientId,e.purpose]):Do(MPe)([e.apiOrigin,e.clientId,e.harness,e.scope,e.canonicalScopeRoot])}function _Pe(e,t){let r=e.dirname(t);return r===t?[t]:[t,..._Pe(e,r)]}class cm extends Ct()("@expandai/cli/Auth/PendingInitStore",{dependencies:[Uv],effect:Y(function*(){let e=yield*lr,t=yield*sr,r=t.join(yield*J0,"expandai"),n=t.join(r,"pending-init"),o=(S,Q)=>new hee({path:S,error:Q}),i=(S,Q)=>Q.pipe(fe((I)=>o(S,I))),s=Ce(function*(S){let Q=yield*jt(e.readLink(S));if(vn(Q))return yield*o(S,Error("Symbolic links are not allowed for pending authorization"));let I=Q.left;if(I instanceof ji&&(I.reason==="InvalidData"||I.reason==="NotFound"||I.method==="readLink"&&Eee(I.cause,"EINVAL")))return;return yield*o(S,I)}),a=Ce(function*(){if(yield*s(r),yield*s(n),yield*i(n,e.makeDirectory(n,{recursive:!0,mode:448})),yield*s(r),yield*s(n),(yield*i(n,e.stat(n))).type!=="Directory")return yield*o(n,Error("Pending authorization path is not a directory"));if(process.platform!=="win32")yield*i(r,e.chmod(r,448)),yield*i(n,e.chmod(n,448))}),c=(S)=>{let Q=g0t("sha256").update(S0t(S)).digest("hex");return t.join(n,`${Q}.json`)},l=Ce(function*(S,Q){let I=yield*Tu(gee)(Q).pipe(fe(()=>new im({path:S,error:Error("Stored pending authorization did not match the expected schema")})));if(c(I.key)!==S)return yield*new im({path:S,error:Error("Stored pending authorization key did not match its file")});return I}),u=Ce(function*(S){if(yield*s(S),!(yield*i(S,e.exists(S))))return U();let I=yield*i(S,e.stat(S));if(I.type!=="File")return yield*o(S,Error("Pending state is not a regular file"));if(process.platform!=="win32"&&(I.mode&511)!==384)return yield*o(S,Error("Pending state file mode is not 600"));let O=yield*i(S,e.readFileString(S));return P(yield*l(S,O))}),p=(S)=>u(c(S)),f=Ce(function*(S){let Q=wR(yield*fc);return wR(S.approvalExpiresAt)+E0t<=Q}),d=Ce(function*(S){yield*a();let Q=c(S.key),I=yield*vo(gee)(S).pipe(fe((v)=>o(Q,v))),O=yield*jt(Tr(Y(function*(){let v=yield*e.open(Q,{flag:"wx",mode:384});yield*v.writeAll(new TextEncoder().encode(I)),yield*v.sync})));if(qt(O)){if(y0t(O.left))return!1;return yield*e.remove(Q).pipe(tn),yield*o(Q,O.left)}if(process.platform!=="win32"){let v=yield*jt(e.chmod(Q,384));if(qt(v))return yield*e.remove(Q).pipe(tn),yield*o(Q,v.left)}return!0}),A=W("PendingInitStore.replaceIfMatch")(function*(S,Q){yield*a();let I=c(Q.key);if(c(S.key)!==I)return yield*o(I,Error("Pending authorization replacement changed its key"));let O=yield*u(I);if(ze(O)||O.value.userCode!==S.userCode)return!1;let v=yield*vo(gee)(Q).pipe(fe((j)=>o(I,j))),H=`${I}.${process.pid}.${Math.random().toString(36).slice(2,10)}.tmp`,T=yield*Tr(vr(M(H),()=>e.remove(H).pipe(tn)).pipe(be(Y(function*(){yield*s(H),yield*Tr(Y(function*(){let j=yield*e.open(H,{flag:"wx",mode:384});yield*j.writeAll(new TextEncoder().encode(v)),yield*j.sync})),yield*e.rename(H,I)})))).pipe(jt);if(qt(T))return yield*o(I,T.left);return!0}),m=Ce(function*(S){let Q=c(S.key),I=yield*u(Q);if(ze(I)||I.value.userCode!==S.userCode)return!1;return yield*i(Q,e.remove(Q)),!0}),g=W("PendingInitStore.get")(function*(S){let Q=yield*p(S);if(ze(Q)||!(yield*f(Q.value)))return Q;return yield*m(Q.value),U()}),y=W("PendingInitStore.peek")(function*(S){return yield*p(S)}),w=W("PendingInitStore.putIfAbsent")(function*(S){let Q=yield*p(S.key);if(ne(Q)&&!(yield*f(Q.value)))return Q.value;if(ne(Q))yield*m(Q.value);if(yield*d(S))return S;let I=yield*p(S.key);return yield*Te(I,{onNone:()=>o(c(S.key),Error("Pending record creation lost without a winner")),onSome:M})}),b=W("PendingInitStore.removeIfMatch")((S)=>m(S)),D=W("PendingInitStore.removeCorrupt")(function*(S){let Q=c(S),I=yield*jt(u(Q));if(vn(I))return!1;if(!(I.left instanceof im))return yield*I.left;let O=yield*jt(e.remove(Q));if(qt(O)&&x0t(O.left))return!1;if(qt(O))return yield*o(Q,O.left);return!0}),k=W("PendingInitStore.pruneExpired")(function*(){if(yield*s(n),!(yield*i(n,e.exists(n))))return 0;let Q=yield*i(n,e.readDirectory(n));return(yield*ot(Q.filter((O)=>O.endsWith(".json")),(O)=>Y(function*(){let v=yield*u(t.join(n,O));if(ze(v)||!(yield*f(v.value)))return 0;return(yield*m(v.value))?1:0}).pipe(nl(()=>0)))).reduce((O,v)=>O+v,0)}),B=W("PendingInitStore.canonicalScopeRoot")(function*(S,Q=process.cwd()){if(S==="global")return"global";let I=yield*i(Q,e.realPath(Q)),v=(yield*ot(_Pe(t,I),(H)=>i(H,e.exists(t.join(H,".git"))).pipe(K((T)=>({candidate:H,exists:T}))))).find(({exists:H})=>H)?.candidate;return v===void 0?I:yield*i(v,e.realPath(v))});return{pendingPath:n,get:g,peek:y,putIfAbsent:w,replaceIfMatch:A,removeIfMatch:b,removeCorrupt:D,pruneExpired:k,canonicalScopeRoot:B}})}){}var C0t=Zu,I0t=5;class yO extends Ne("ManualAuthorizationInput")({purpose:_(V("login","agent-setup"),{default:()=>"agent-setup"}),harness:V("agent-harnesses"),scope:Va,cwd:z(E),platform:z(E)}){}class yee extends Ne("ManualAuthorizationRequired")({verificationUri:E,userCode:fs,approvalExpiresAt:id}){}class xee extends DS()("TokensSaved",{}){}class my extends DS()("AuthorizationPending",{pending:yee}){}var bmr=Je(xee,my);function Z0(e){return new yee({verificationUri:e.verificationUri,userCode:e.userCode,approvalExpiresAt:e.approvalExpiresAt})}class ep extends Ct()("@expandai/cli/Auth/ManualAuthorization",{dependencies:[Bt.Default,cm.Default,XC.Default],effect:Y(function*(){let e=yield*Bt,t=yield*cm,r=yield*XC,n=Ce(function*(l){yield*e.ensureSecureStorage(),yield*t.pruneExpired();let u=yield*e.getApiUrl(),p=yield*t.canonicalScopeRoot(l.scope,l.cwd);return{apiOrigin:u.origin,clientId:C0t,purpose:l.purpose,harness:l.harness,scope:l.scope,canonicalScopeRoot:p}}),o=Ce(function*(l,u){let p=l.platform===void 0?{}:{platform:l.platform},f=yield*r.create(l.purpose==="login"?{purpose:"login",...p}:{purpose:"agent-setup",harness:l.harness,scope:l.scope,...p}),d=yield*fc,A=new K0({key:u,deviceCode:f.deviceCode,userCode:f.userCode,verificationUri:f.verificationUri.toString(),intervalSeconds:f.interval,nextPollAt:zw(d,Yc(f.interval)),approvalExpiresAt:zw(d,Yc(f.expiresIn))}),m=yield*jt(t.putIfAbsent(A));if(qt(m))return yield*m.left;return m.right}),i=Ce(function*(l,u){let p=yield*fc,f=l.intervalSeconds+(u?I0t:0),d=new K0({...l,intervalSeconds:f,nextPollAt:zw(p,Yc(f))}),A=yield*jt(t.replaceIfMatch(l,d));if(qt(A))return l;return A.right?d:l}),s=Ce(function*(l,u){let p=yield*jt(t.get(u));if(vn(p))return p.right;if(l.purpose!=="login"||!(p.left instanceof im))return yield*p.left;return yield*t.removeCorrupt(u),yield*t.get(u)}),a=W("ManualAuthorization.advance")(function*(l){let u=yield*n(l),p=yield*s(l,u);if(ze(p)){let g=yield*o(l,u);return new my({pending:Z0(g)})}let f=p.value,d=yield*fc;if(BXe(d,f.approvalExpiresAt)){yield*t.removeIfMatch(f);let g=yield*o(l,u);return new my({pending:Z0(g)})}if(AP(d,f.nextPollAt))return new my({pending:Z0(f)});let A=yield*jt(r.poll(f.deviceCode)),m=Ce(function*(){yield*t.removeIfMatch(f);let g=yield*o(l,u);return new my({pending:Z0(g)})});return yield*Wn(A,{onLeft:(g)=>t.removeIfMatch(f).pipe(Ms(()=>g instanceof gf),be(se(g))),onRight:(g)=>Wt(g).pipe(xr("DeviceAuthorizationTokensSaved",()=>t.removeIfMatch(f).pipe(un(new xee))),xr("DeviceAuthorizationPending",()=>i(f,!1).pipe(K((y)=>new my({pending:Z0(y)})))),xr("DeviceAuthorizationSlowDown",()=>i(f,!0).pipe(K((y)=>new my({pending:Z0(y)})))),xr("DeviceAuthorizationExpired",m),xr("DeviceAuthorizationInvalid",m),Sr)})}),c=W("ManualAuthorization.redeemPreApproved")(function*(l){let u=yield*r.poll(l);function p(){return new Xu({operation:"poll",kind:"rejected",status:400,recoverable:!1})}return yield*Wt(u).pipe(xr("DeviceAuthorizationTokensSaved",()=>Z),xr("DeviceAuthorizationPending",p),xr("DeviceAuthorizationSlowDown",p),xr("DeviceAuthorizationExpired",p),xr("DeviceAuthorizationInvalid",p),Sr)});return{advance:a,redeemPreApproved:c}})}){}var FPe="Authorization complete. Expand is ready to use; retry the command that required authentication.",b0t=V("authorization_internal_error","authorization_unreachable","authorization_rejected","authorization_service_unavailable","authorization_invalid_response","authorization_denied","authorization_refused","credential_save_failed","credential_storage_insecure");class Tc extends et()("DeviceLoginError",{code:b0t,recoverable:Ie,httpStatus:z(de)}){get message(){switch(this.code){case"authorization_internal_error":return"Authorization failed for an unexpected internal reason. Do not retry in a loop; report this error.";case"authorization_unreachable":return"Could not reach the Expand API. Nothing was changed: any pending authorization is still pending, and if none existed, none was started. Do not retry until the connection is fixed; then run the same command again.";case"authorization_rejected":return"The Expand API rejected the device authorization request. Retry later; if this persists, the CLI and API versions may be incompatible.";case"authorization_service_unavailable":return`The Expand device authorization service is unavailable${this.httpStatus===void 0?"":` (HTTP ${this.httpStatus})`}. Retry later or use the staging API for an isolated test.`;case"authorization_invalid_response":return"The Expand API returned an invalid device authorization response. Do not continue with a URL or code from this response; update the CLI or report the problem.";case"authorization_denied":return"The authorization was denied in the browser. If that was unintended, run the same command again for a fresh approval code.";case"authorization_refused":return"Expand refused to complete the authorization for a reason a new code cannot fix. Do not start another authorization; report the error.";case"credential_save_failed":return"Authorization completed, but credentials could not be saved. Fix credential storage before starting again.";case"credential_storage_insecure":return"Credential storage is not secure enough to continue."}}}class yq extends Ne("DeviceLoginErrorEnvelope")({schemaVersion:V(1),status:V("error"),code:E,message:E,recoverable:Ie}){}var w0t=q({schemaVersion:V(1),status:V("authorization_required"),userMessage:V(ZC),authorization:q({url:Kg,userCode:fs,approvalExpiresAt:id})}),B0t=q({schemaVersion:V(1),status:V("completed"),userMessage:V(FPe),auth:q({healthy:V(!0)})}),Eq=Je(w0t,B0t);function Q0t(e){if(e instanceof vc)return new Tc({code:"credential_storage_insecure",recoverable:!1});if(e instanceof gf)return new Tc({code:"authorization_denied",recoverable:!0});if(e instanceof sm)return new Tc({code:"authorization_refused",recoverable:!1});if(e instanceof am)return new Tc({code:"credential_save_failed",recoverable:!1});if(e instanceof Xu)switch(e.kind){case"request_failed":return new Tc({code:"authorization_unreachable",recoverable:!0});case"rejected":if(e.status!==void 0&&e.status>=500)return new Tc({code:"authorization_service_unavailable",recoverable:!0,httpStatus:e.status});return new Tc({code:"authorization_rejected",recoverable:e.recoverable});case"invalid_response":return new Tc({code:"authorization_invalid_response",recoverable:!1})}return new Tc({code:"authorization_internal_error",recoverable:!1})}class xO extends Ct()("@expandai/cli/Auth/DeviceLogin",{dependencies:[ep.Default],effect:Y(function*(){let e=yield*ep;return{run:W("DeviceLogin.run")(function*(){let r=yield*e.advance(new yO({purpose:"login",harness:"agent-harnesses",scope:"global"})).pipe(fe(Q0t));return yield*Wt(r).pipe(xr("TokensSaved",()=>ir(Eq)({schemaVersion:1,status:"completed",userMessage:FPe,auth:{healthy:!0}}).pipe(fe(()=>new Tc({code:"authorization_internal_error",recoverable:!1})))),xr("AuthorizationPending",({pending:n})=>ir(Eq)({schemaVersion:1,status:"authorization_required",userMessage:ZC,authorization:{url:n.verificationUri,userCode:n.userCode,approvalExpiresAt:SS(n.approvalExpiresAt)}}).pipe(fe(()=>new Tc({code:"authorization_internal_error",recoverable:!1})))),Sr)})}})}){}class xq extends et()("SetupGrantAuthorizationError",{code:V("invalid_or_expired","stored_credential_conflict","request_failed","denied","credential_save_failed","refused","config_unreadable"),recoverable:Ie}){get message(){switch(this.code){case"stored_credential_conflict":return"An Expand API key is already stored on this machine, and completing this setup would replace it with no way to recover it. Nothing was changed and your setup prompt is still valid. Run `expandai logout` to clear the stored key, then run this setup command again.";case"request_failed":return"Could not reach Expand to redeem the setup token. Nothing was sent, so the same token is still good — check the network and try again.";case"denied":return"This setup authorization was denied. Copy a fresh setup prompt from the Expand dashboard.";case"config_unreadable":return"The Expand config file on this machine could not be read, so setup cannot tell whether completing it would overwrite an existing API key. Nothing was redeemed and your setup prompt is still valid. Run `expandai whoami` to see which file it is, fix or delete it, then run this setup command again.";case"refused":return"Expand refused to redeem this setup token for a reason a fresh prompt cannot fix — most likely an OAuth client, resource, or scope misconfiguration on the server. Do not request another prompt; report this.";case"credential_save_failed":return"The setup token was redeemed, but the credentials could not be saved on this machine. Fix credential storage — run `expandai whoami` to see the path it uses, and check its permissions — then copy a fresh setup prompt from the Expand dashboard.";default:return"The setup token is invalid, expired, or already used. Copy a fresh setup prompt from the Expand dashboard."}}}function eI(e){return new xq({code:e,recoverable:e!=="denied"&&e!=="credential_save_failed"&&e!=="refused"})}class X0 extends Ct()("@expandai/cli/Auth/SetupGrantAuthorization",{dependencies:[Bt.Default,ep.Default],effect:Y(function*(){let e=yield*Bt,t=yield*ep;return{authorize:W("SetupGrantAuthorization.authorize")(function*(n){let o=yield*e.readConfigFile();if(o.parseFailed)return yield*eI("config_unreadable");if(o.config.authMethod?._tag==="ApiKey")return yield*eI("stored_credential_conflict");yield*Kx({harness:n.harness,scope:n.scope}),yield*t.redeemPreApproved(n.setupToken).pipe(fe((i)=>{if(i instanceof gf)return eI("denied");if(i instanceof am)return eI("credential_save_failed");if(i instanceof sm)return eI("refused");if(i instanceof Xu&&i.kind==="request_failed")return eI("request_failed");return eI("invalid_or_expired")}))})}})}){}import oHe from"node:process";import _ee from"node:path";import{fileURLToPath as uQt}from"node:url";import pQt from"node:child_process";import fQt,{constants as dQt}from"node:fs/promises";import U0t from"node:path";import{promisify as P0t}from"node:util";import H0t from"node:child_process";import Bee,{constants as zPe}from"node:fs/promises";import UPe from"node:process";import T0t from"node:os";import bee from"node:fs";import R0t from"node:fs";import NPe from"node:fs";var See;function k0t(){try{return NPe.statSync("/.dockerenv"),!0}catch{return!1}}function D0t(){try{return NPe.readFileSync("/proc/self/cgroup","utf8").includes("docker")}catch{return!1}}function Cee(){if(See===void 0)See=k0t()||D0t();return See}var Iee,v0t=()=>{try{return R0t.statSync("/run/.containerenv"),!0}catch{return!1}};function tI(){if(Iee===void 0)Iee=v0t()||Cee();return Iee}var LPe=()=>{if(UPe.platform!=="linux")return!1;if(T0t.release().toLowerCase().includes("microsoft")){if(tI())return!1;return!0}try{if(bee.readFileSync("/proc/version","utf8").toLowerCase().includes("microsoft"))return!tI()}catch{}if(bee.existsSync("/proc/sys/fs/binfmt_misc/WSLInterop")||bee.existsSync("/run/WSL"))return!tI();return!1},jd=UPe.env.__IS_WSL_TEST__?LPe:LPe();import PPe from"node:process";import{Buffer as O0t}from"node:buffer";import{promisify as M0t}from"node:util";import _0t from"node:child_process";var F0t=M0t(_0t.execFile),wee=()=>`${PPe.env.SYSTEMROOT||PPe.env.windir||String.raw`C:\Windows`}\\System32\\WindowsPowerShell\\v1.0\\powershell.exe`;var HPe=["-NoProfile","-NonInteractive","-ExecutionPolicy","Bypass","-EncodedCommand"],WPe=(e)=>O0t.from(e,"utf16le").toString("base64"),N0t=(e)=>`'${String(e).replaceAll(/['‘’‚‛]/g,(t)=>t+t)}'`,qPe=(e)=>[...HPe,WPe(e)],L0t=(e)=>({encoding:"utf8",...e,shell:!1}),tp=async(e,t={})=>{let{powerShellPath:r,...n}=t;return F0t(r??wee(),qPe(e),L0t(n))};tp.argumentsPrefix=HPe;tp.encodeCommand=WPe;tp.escapeArgument=N0t;tp.createArguments=qPe;function GPe(e){for(let t of e.split(`
|
|
302
302
|
`)){if(/^\s*#/.test(t))continue;let r=/^\s*root\s*=\s*(?<mountPoint>"[^"]*"|'[^']*'|[^#]*)/.exec(t);if(!r)continue;return r.groups.mountPoint.trim().replaceAll(/^["']|["']$/g,"")}}var W0t=P0t(H0t.execFile),q0t=(()=>{let t;return async function(){if(t)return t;let r="/etc/wsl.conf",n=!1;try{await Bee.access(r,zPe.F_OK),n=!0}catch{}if(!n)return"/mnt/";let o=await Bee.readFile(r,{encoding:"utf8"}),i=GPe(o);if(i===void 0)return"/mnt/";return t=i,t=t.endsWith("/")?t:`${t}/`,t}})(),G0t=async()=>`${await q0t()}c/Windows/System32/WindowsPowerShell/v1.0/powershell.exe`,Sq=jd?G0t:wee,VPe,YPe=async()=>(VPe??=(async()=>{try{let e=await Sq();return await Bee.access(e,zPe.X_OK),!0}catch{return!1}})(),VPe),jPe=async()=>{let e=await Sq(),t=String.raw`(Get-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\Shell\Associations\UrlAssociations\http\UserChoice").ProgId`,{stdout:r}=await tp(t,{powerShellPath:e,cwd:U0t.dirname(e)});return r.trim()},V0t=(e)=>/^[a-z]+:\/\//i.test(e),z0t=async(e,t)=>{let r=t.startsWith("-")?[e,"--",t]:[e,t];try{let{stdout:n}=await W0t("wslpath",r,{encoding:"utf8"});return n.replace(/\r?\n$/,"")||t}catch{return t}},$Pe=async(e)=>{let t=Array.isArray(e),n=await Promise.all((t?e:[e]).map((o)=>V0t(o)?o:z0t("-aw",o)));return t?n:n[0]};function rI(e,t,r){let n=(o)=>Object.defineProperty(e,t,{value:o,enumerable:!0,writable:!0});return Object.defineProperty(e,t,{configurable:!0,enumerable:!0,get(){let o=r();return n(o),o},set(o){n(o)}}),e}import{promisify as iQt}from"node:util";import vee from"node:process";import{execFile as sQt}from"node:child_process";import{promisify as Y0t}from"node:util";import j0t from"node:process";import{execFile as $0t}from"node:child_process";var J0t=Y0t($0t);async function Qee(){if(j0t.platform!=="darwin")throw Error("macOS only");let{stdout:e}=await J0t("defaults",["read","com.apple.LaunchServices/com.apple.launchservices.secure","LSHandlers"]),r=/LSHandlerRoleAll = "(?!-)(?<id>[^"]+?)";\s+?LSHandlerURLScheme = (?:http|https);/.exec(e)?.groups.id??"com.apple.Safari";if(r==="com.apple.safari")return"com.apple.Safari";return r}import K0t from"node:process";import{promisify as Z0t}from"node:util";import{execFile as X0t,execFileSync as ygr}from"node:child_process";var eQt=Z0t(X0t);async function JPe(e,{humanReadableOutput:t=!0,signal:r}={}){if(K0t.platform!=="darwin")throw Error("macOS only");let n=t?[]:["-ss"],o={};if(r)o.signal=r;let{stdout:i}=await eQt("osascript",["-e",e,n],o);return i.trim()}var tQt=/^[^\n\r"\\]+$/u;async function kee(e){if(typeof e!=="string")throw TypeError("Expected a string bundle identifier");if(!tQt.test(e))throw TypeError(`Invalid bundle identifier: ${JSON.stringify(e)}`);return JPe(`tell application "Finder" to set app_path to application file id "${e}" as string
|
|
303
303
|
tell application "System Events" to get value of property list item "CFBundleName" of property list file (app_path & ":Contents:Info.plist")`)}import KPe from"node:process";import{promisify as rQt}from"node:util";import{execFile as nQt}from"node:child_process";var oQt=rQt(nQt),Cq={MSEdgeHTM:{name:"Edge",id:"com.microsoft.edge"},MSEdgeBHTML:{name:"Edge Beta",id:"com.microsoft.edge.beta"},MSEdgeDHTML:{name:"Edge Dev",id:"com.microsoft.edge.dev"},AppXq0fevzme2pys62n3e0fbqa7peapykr8v:{name:"Edge",id:"com.microsoft.edge.old"},ChromeHTML:{name:"Chrome",id:"com.google.chrome"},ChromeBHTML:{name:"Chrome Beta",id:"com.google.chrome.beta"},ChromeDHTML:{name:"Chrome Dev",id:"com.google.chrome.dev"},ChromiumHTM:{name:"Chromium",id:"org.chromium.Chromium"},BraveHTML:{name:"Brave",id:"com.brave.Browser"},BraveBHTML:{name:"Brave Beta",id:"com.brave.Browser.beta"},BraveDHTML:{name:"Brave Dev",id:"com.brave.Browser.dev"},BraveSSHTM:{name:"Brave Nightly",id:"com.brave.Browser.nightly"},FirefoxURL:{name:"Firefox",id:"org.mozilla.firefox"},OperaStable:{name:"Opera",id:"com.operasoftware.Opera"},VivaldiHTM:{name:"Vivaldi",id:"com.vivaldi.Vivaldi"},"IE.HTTP":{name:"Internet Explorer",id:"com.microsoft.ie"}},Dee=new Map(Object.entries(Cq));class ZPe extends Error{}async function Ree(e=oQt){let t=`${KPe.env.SYSTEMROOT??KPe.env.windir??"C:\\Windows"}\\System32\\reg.exe`,{stdout:r}=await e(t,["QUERY"," HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\Shell\\Associations\\UrlAssociations\\http\\UserChoice","/v","ProgId"]),n=/ProgId\s*REG_SZ\s*(?<id>\S+)/.exec(r);if(!n)throw new ZPe(`Cannot find Windows browser in stdout: ${JSON.stringify(r)}`);let{id:o}=n.groups,i=o.lastIndexOf("."),s=o.lastIndexOf("-"),a=i===-1?void 0:o.slice(0,i),c=s===-1?void 0:o.slice(0,s);return Cq[o]??Cq[a]??Cq[c]??{name:o,id:o}}var aQt=iQt(sQt),cQt=(e)=>e.toLowerCase().replaceAll(/(?:^|\s|-)\S/g,(t)=>t.toUpperCase());async function Tee(){if(vee.platform==="darwin"){let e=await Qee();return{name:await kee(e),id:e}}if(vee.platform==="linux"){let{stdout:e}=await aQt("xdg-mime",["query","default","x-scheme-handler/http"]),t=e.trim();return{name:cQt(t.replace(/.desktop$/,"").replace("-"," ")),id:t}}if(vee.platform==="win32")return Ree();throw Error("Only macOS, Linux, and Windows are supported")}import Oee from"node:process";var lQt=Boolean(Oee.env.SSH_CONNECTION||Oee.env.SSH_CLIENT||Oee.env.SSH_TTY),XPe=lQt;var Iq=Symbol("fallbackAttempt"),Mee=import.meta.url?_ee.dirname(uQt(import.meta.url)):"",eHe=_ee.join(Mee,"xdg-open"),{platform:nI,arch:tHe}=oHe,rHe=async(e,t)=>{if(e.length===0)return;let r=[];for(let n of e)try{return await t(n)}catch(o){r.push(o)}throw AggregateError(r,"Failed to open in all supported apps")},bq=async(e)=>{e={wait:!1,background:!1,newInstance:!1,allowNonzeroExitCode:!1,...e};let t=e[Iq]===!0;if(delete e[Iq],Array.isArray(e.app))return rHe(e.app,(l)=>bq({...e,app:l,[Iq]:!0}));let{name:r,arguments:n=[]}=e.app??{};if(n=[...n],Array.isArray(r))return rHe(r,(l)=>bq({...e,app:{name:l,arguments:n},[Iq]:!0}));if(r==="browser"||r==="browserPrivate"){let l={"com.google.chrome":"chrome","google-chrome.desktop":"chrome","com.brave.browser":"brave","org.mozilla.firefox":"firefox","firefox.desktop":"firefox","com.microsoft.msedge":"edge","com.microsoft.edge":"edge","com.microsoft.edgemac":"edge","microsoft-edge.desktop":"edge","com.apple.safari":"safari"},u={chrome:"--incognito",brave:"--incognito",firefox:"--private-window",edge:"--inPrivate"},p;if(jd){let d=await jPe();p=Dee.get(d)??{}}else p=await Tee();let f=p.id?.toLowerCase();if(Object.hasOwn(l,f)){let d=l[f];if(r==="browserPrivate"){if(d==="safari")throw Error("Safari doesn't support opening in private mode via command line");n.push(u[d])}return bq({...e,app:{name:eQ[d],arguments:n}})}throw Error(`${p.name} is not supported as a default browser`)}let o,i=[],s={},a=!1;if(jd&&!tI()&&!XPe&&!r)a=await YPe();if(nI==="darwin"){if(o="open",e.wait)i.push("--wait-apps");if(e.background)i.push("--background");if(e.newInstance)i.push("--new");if(r)i.push("-a",r)}else if(nI==="win32"||a){if(o=await Sq(),i.push(...tp.argumentsPrefix),!jd)s.windowsVerbatimArguments=!0;if(jd&&e.target)e.target=await $Pe(e.target);let l=["$ProgressPreference = 'SilentlyContinue';","Start"];if(e.wait)l.push("-Wait");if(r){if(l.push(tp.escapeArgument(r)),e.target)n.push(e.target)}else if(e.target)l.push(tp.escapeArgument(e.target));if(n.length>0)n=n.map((u)=>tp.escapeArgument(u)),l.push("-ArgumentList",n.join(","));if(e.target=tp.encodeCommand(l.join(" ")),!e.wait)s.stdio="ignore";if(jd)s.cwd=_ee.dirname(o)}else{if(r)o=r;else{let l=!Mee||Mee==="/",u=!1;try{await fQt.access(eHe,dQt.X_OK),u=!0}catch{}o=oHe.versions.electron??(nI==="android"||l||!u)?"xdg-open":eHe}if(n.length>0)i.push(...n);if(!e.wait)s.stdio="ignore",s.detached=!0}if(nI==="darwin"&&n.length>0)i.push("--args",...n);if(e.target)i.push(e.target);let c=pQt.spawn(o,i,s);if(e.wait)return new Promise((l,u)=>{c.once("error",u),c.once("close",(p)=>{if(!e.allowNonzeroExitCode&&p!==0){u(Error(`Exited with code ${p}`));return}l(c)})});if(t||nI==="win32"||a)return new Promise((l,u)=>{c.once("error",u),c.once("spawn",()=>{c.once("close",(p)=>{if(c.off("error",u),t&&p!==0){u(Error(`Exited with code ${p}`));return}c.unref(),l(c)})})});return c.unref(),new Promise((l,u)=>{c.once("error",u),c.once("spawn",()=>{c.off("error",u),l(c)})})},AQt=(e,t)=>{if(typeof e!=="string")throw TypeError("Expected a `target`");return bq({...t,target:e})};function nHe(e){if(typeof e==="string"||Array.isArray(e))return e;let{[tHe]:t}=e;if(!t)throw Error(`${tHe} is not supported`);return t}function SO({[nI]:e},{wsl:t}={}){if(t&&jd)return nHe(t);if(!e)throw Error(`${nI} is not supported`);return nHe(e)}var eQ={browser:"browser",browserPrivate:"browserPrivate"};rI(eQ,"chrome",()=>SO({darwin:"google chrome",win32:"chrome",linux:["google-chrome","google-chrome-stable","chromium","chromium-browser"]},{wsl:{ia32:"/mnt/c/Program Files (x86)/Google/Chrome/Application/chrome.exe",x64:["/mnt/c/Program Files/Google/Chrome/Application/chrome.exe","/mnt/c/Program Files (x86)/Google/Chrome/Application/chrome.exe"]}}));rI(eQ,"brave",()=>SO({darwin:"brave browser",win32:"brave",linux:["brave-browser","brave"]},{wsl:{ia32:"/mnt/c/Program Files (x86)/BraveSoftware/Brave-Browser/Application/brave.exe",x64:["/mnt/c/Program Files/BraveSoftware/Brave-Browser/Application/brave.exe","/mnt/c/Program Files (x86)/BraveSoftware/Brave-Browser/Application/brave.exe"]}}));rI(eQ,"firefox",()=>SO({darwin:"firefox",win32:String.raw`C:\Program Files\Mozilla Firefox\firefox.exe`,linux:"firefox"},{wsl:"/mnt/c/Program Files/Mozilla Firefox/firefox.exe"}));rI(eQ,"edge",()=>SO({darwin:"microsoft edge",win32:"msedge",linux:["microsoft-edge","microsoft-edge-dev"]},{wsl:"/mnt/c/Program Files (x86)/Microsoft/Edge/Application/msedge.exe"}));rI(eQ,"safari",()=>SO({darwin:"Safari"}));var iHe=AQt;class sHe extends V("off","compact","detailed"){}class hQt extends q({include:_(E,{nullable:!0}),appendixMarkers:_(sHe,{nullable:!0})}){}class aHe extends V("off","compact","detailed"){}class cHe extends V("auto","never","always"){}class mQt extends Ne("FetchFetchRequest")({url:E,include:_(q({html:_(Je(Ie,Or({key:E,value:Zt})),{nullable:!0}),markdown:_(Je(Ie,Or({key:E,value:Zt})),{nullable:!0}),screenshot:_(Je(Ie,q({fullPage:_(Ie,{nullable:!0})})),{nullable:!0}),links:_(Je(Ie,q({sameDomainOnly:_(Ie,{nullable:!0,default:()=>!0}),includePatterns:_(ve(E),{nullable:!0}),excludePatterns:_(ve(E),{nullable:!0})})),{nullable:!0}),meta:_(Ie,{nullable:!0,default:()=>!0}),response:_(q({includeHeaders:_(Ie,{nullable:!0,default:()=>!1})}),{nullable:!0}),json:_(Ie,{nullable:!0,default:()=>!1}),appendix:_(Ie,{nullable:!0}),appendixMarkers:_(aHe,{nullable:!0,default:()=>"compact"})}),{nullable:!0}),highlights:_(q({query:E,maxResults:_(hr.pipe(Pr(1),sa(50)),{nullable:!0,default:()=>5}),minScore:_(de.pipe(Pr(0),sa(1)),{nullable:!0,default:()=>0.6})}),{nullable:!0}),browserConfig:_(q({scrollFullPage:_(Ie,{nullable:!0,default:()=>!1})}),{nullable:!0}),documentConfig:_(q({maxPages:_(hr.pipe(Pr(1)),{nullable:!0}),maxAudioSeconds:_(hr.pipe(Pr(1),sa(14400)),{nullable:!0,default:()=>3600}),ocr:_(cHe,{nullable:!0,default:()=>"auto"})}),{nullable:!0})}){}class lHe extends V("Pointer","Unexpected","Missing","Composite","Refinement","Transformation","Type","Forbidden"){}class uHe extends V("symbol"){}class pHe extends Je(E,de,q({_tag:uHe,key:E})){}class fHe extends q({_tag:lHe,path:ve(pHe),message:E}){}class dHe extends V("HttpApiDecodeError"){}class Ey extends q({issues:ve(fHe),message:E,_tag:dHe}){}class AHe extends V("BadRequest"){}class bO extends q({message:E,_tag:AHe}){}class wq extends Je(Ey,bO){}class hHe extends V("InvalidApiKey","InvalidToken","InvalidSession","InvalidTenant"){}class mHe extends V("AuthFailed"){}class rp extends Ne("AuthFailed")({reason:hHe,description:_(Je(E,q({message:E})),{nullable:!0}),_tag:mHe}){}class wO extends E{}class gHe extends V("FetchBlocked"){}class Bq extends q({url:E,blockedType:_(E,{nullable:!0}),_tag:gHe}){}class Qq extends Je(q({organizationId:E.pipe(yn(1)),blockedUntil:_(Je(wO,Jg),{nullable:!0}),_tag:V("AccessBlocked")}),Bq){}class EHe extends V("FetchOriginHttpError"){}class yHe extends V(404){}class CO extends Ne("FetchOriginNotFound")({_tag:EHe,url:E,statusCode:yHe,contentType:_(E,{nullable:!0})}){}class xHe extends V("FetchOriginHttpError"){}class SHe extends V(410){}class IO extends Ne("FetchOriginGone")({_tag:xHe,url:E,statusCode:SHe,contentType:_(E,{nullable:!0})}){}class CHe extends V("PayloadTooLarge"){}class np extends q({_tag:CHe}){}class IHe extends V("transfer_bytes","domsnapshot_bytes","ast_bytes","document_frame_bytes","document_pages","audio_seconds"){}class bHe extends V("FetchPageTooLarge"){}class kq extends q({url:E,limitKind:_(IHe,{nullable:!0}),limitBytes:_(de,{nullable:!0}),measuredBytes:_(de,{nullable:!0}),limit:_(de,{nullable:!0}),measured:_(de,{nullable:!0}),_tag:bHe}){}class wHe extends Je(np,kq){}class BHe extends V("FetchUnsupportedContentType"){}class tQ extends Ne("FetchUnsupportedContentType")({url:E,contentType:_(E,{nullable:!0}),_tag:BHe}){}class QHe extends V("private","removed","geoRestricted","ageRestricted","membersOnly","live","upcoming","unknown"){}class kHe extends V("FetchVideoUnavailable"){}class rQ extends Ne("FetchVideoUnavailable")({url:E,availability:QHe,message:_(E,{nullable:!0}),_tag:kHe}){}class DHe extends V(!0){}class RHe extends V("TooManyRequests"){}class gy extends q({retryable:_(DHe,{default:()=>!0}),retryAfterSeconds:_(de,{nullable:!0}),_tag:RHe}){}class vHe extends V(!0){}class THe extends V("FetchConcurrencyLimitExceeded"){}class Dq extends q({retryable:_(vHe,{default:()=>!0}),retryAfterSeconds:de,maxConcurrency:de,message:_(E,{nullable:!0}),requestId:_(E,{nullable:!0}),_tag:THe}){}class Rq extends Je(gy,Dq){}class OHe extends V(!0){}class MHe extends V("InternalError"){}class _l extends Ne("InternalError")({retryable:_(OHe,{default:()=>!0}),_tag:MHe}){}class _He extends V("pageNeverSettled","capabilityFailed"){}class FHe extends V(!1){}class NHe extends V("FetchCaptureFailed"){}class vq extends q({url:E,failureType:_He,retryable:_(FHe,{default:()=>!1}),_tag:NHe}){}class LHe extends V("browserInternalDocument"){}class UHe extends V(!1){}class PHe extends V("FetchNavigationFailed"){}class nQ extends q({url:E,failureType:LHe,retryable:_(UHe,{default:()=>!1}),_tag:PHe}){}class HHe extends V("FetchOriginHttpError"){}class Tq extends q({url:E,statusCode:de,contentType:_(E,{nullable:!0}),_tag:HHe}){}class WHe extends Je(vq,nQ,Tq){}class qHe extends V("cancelled_before_start","cancelled_after_start","unknown"){}class GHe extends V(!0){}class VHe extends V("ServiceUnavailable"){}class op extends q({message:_(E,{nullable:!0}),requestId:_(E,{nullable:!0}),dispatchOutcome:_(qHe,{nullable:!0}),retryable:_(GHe,{default:()=>!0}),_tag:VHe}){}class zHe extends V("ocr","transcription","video"){}class YHe extends V("FetchDocumentProcessingUnavailable"){}class Oq extends q({url:E,operation:zHe,message:E,_tag:YHe}){}class jHe extends Je(op,Oq){}class $He extends V(!1){}class JHe extends V("FetchCaptureTimeout"){}class yy extends Ne("FetchCaptureTimeout")({url:E,timeoutMs:_(de,{nullable:!0}),retryable:_($He,{default:()=>!1}),_tag:JHe}){}class KHe extends V(!0){}class ZHe extends V("FetchCapacityTimeout"){}class xy extends Ne("FetchCapacityTimeout")({url:E,timeoutMs:_(de,{nullable:!0}),retryable:_(KHe,{default:()=>!0}),_tag:ZHe}){}class XHe extends V("off","compact","detailed"){}class gQt extends q({include:_(E,{nullable:!0}),appendixMarkers:_(XHe,{nullable:!0})}){}class e1e extends V("off","compact","detailed"){}class t1e extends V("auto","never","always"){}class EQt extends Ne("FetchFetchJsonRequest")({url:E,include:_(q({html:_(Je(Ie,Or({key:E,value:Zt})),{nullable:!0}),markdown:_(Je(Ie,Or({key:E,value:Zt})),{nullable:!0}),screenshot:_(Je(Ie,q({fullPage:_(Ie,{nullable:!0})})),{nullable:!0}),links:_(Je(Ie,q({sameDomainOnly:_(Ie,{nullable:!0,default:()=>!0}),includePatterns:_(ve(E),{nullable:!0}),excludePatterns:_(ve(E),{nullable:!0})})),{nullable:!0}),meta:_(Ie,{nullable:!0,default:()=>!0}),response:_(q({includeHeaders:_(Ie,{nullable:!0,default:()=>!1})}),{nullable:!0}),json:_(Ie,{nullable:!0,default:()=>!1}),appendix:_(Ie,{nullable:!0}),appendixMarkers:_(e1e,{nullable:!0,default:()=>"compact"})}),{nullable:!0}),highlights:_(q({query:E,maxResults:_(hr.pipe(Pr(1),sa(50)),{nullable:!0,default:()=>5}),minScore:_(de.pipe(Pr(0),sa(1)),{nullable:!0,default:()=>0.6})}),{nullable:!0}),browserConfig:_(q({scrollFullPage:_(Ie,{nullable:!0,default:()=>!1})}),{nullable:!0}),documentConfig:_(q({maxPages:_(hr.pipe(Pr(1)),{nullable:!0}),maxAudioSeconds:_(hr.pipe(Pr(1),sa(14400)),{nullable:!0,default:()=>3600}),ocr:_(t1e,{nullable:!0,default:()=>"auto"})}),{nullable:!0})}){}class r1e extends V(1){}class lm extends hr{}class n1e extends q({sameDomain:de,external:de}){}class o1e extends q({blocks:de,approxTokens:de}){}class i1e extends q({evidenceId:_(de,{nullable:!0}),links:de,approxTokens:de,label:_(E,{nullable:!0}),preview:_(E,{nullable:!0}),moreBlocks:_(de,{nullable:!0})}){}class s1e extends q({url:E,links:n1e,omitted:_(o1e,{nullable:!0}),markers:_(ve(i1e),{nullable:!0})}){}class a1e extends q({moreTokens:de}){}class c1e extends q({url:E,moreTokens:_(de,{nullable:!0})}){}class l1e extends V(1){}class u1e extends q({version:l1e,snapshotId:E,url:E,markdownUrl:E}){}class Mq extends q({version:r1e,url:E,capturedAt:E,snapshotId:E,lang:E,pageType:E,playground:E,citationEvidenceIds:_(ve(lm).pipe(QP(3)),{nullable:!0}),title:_(E,{nullable:!0}),finalUrl:_(E,{nullable:!0}),contentType:_(E,{nullable:!0}),canonical:_(E,{nullable:!0}),description:_(E,{nullable:!0}),author:_(E,{nullable:!0}),createdAt:_(E,{nullable:!0}),updatedAt:_(E,{nullable:!0}),image:_(E,{nullable:!0}),paginationNext:_(E,{nullable:!0}),appendix:_(s1e,{nullable:!0}),stateJson:_(a1e,{nullable:!0}),markdown:_(c1e,{nullable:!0}),resources:_(u1e,{nullable:!0}),blocked:_(E,{nullable:!0}),loadingStatus:_(E,{nullable:!0})}){}class p1e extends V("inline","network"){}class f1e extends V("ld+json","next-data","nuxt","apollo-state","initial-state","application-json","script-tag","data-attribute","network-json","network-response","other"){}class d1e extends V(!0){}class A1e extends V("invalid","unsafe","too-long"){}class oQ extends q({id:de,kind:p1e,role:f1e,score:de.pipe(Pr(0)),url:_(E,{nullable:!0}),method:_(E,{nullable:!0}),moreTokens:_(de,{nullable:!0}),keys:_(ve(E),{nullable:!0}),urlRedacted:_(d1e,{nullable:!0}),urlOmitted:_(A1e,{nullable:!0})}){}class h1e extends V("data-url"){}class BO extends q({id:E,kind:h1e,placeholder:E,archiveKey:E,mimeType:E,sha256:E,bytes:de}){}class m1e extends V("pageTooLarge","modelInputTooLarge"){}class g1e extends V("domsnapshot_bytes","ast_bytes","document_frame_bytes","hfc_tokens"){}class Fee extends q({reason:m1e,skipped:ve(V("hfc")),limitKind:g1e,measuredBytes:_(hr.pipe(Pr(0)),{nullable:!0}),thresholdBytes:_(hr.pipe(Pr(0)),{nullable:!0}),measuredTokens:_(hr.pipe(Pr(0)),{nullable:!0}),thresholdTokens:_(hr.pipe(Pr(0)),{nullable:!0})}){}class _q extends q({evidenceId:_(lm,{nullable:!0}),markdownBlockId:_(E,{nullable:!0}),nodeIds:_(ve(de),{nullable:!0}),stateJsonSourceId:_(de,{nullable:!0}),jsonPath:_(E,{nullable:!0})}){}class E1e extends V("markdown","appendix","statejson"){}class y1e extends V("zeroentropy","mixedbread","local_lexical"){}class x1e extends V("timeout","error"){}class S1e extends q({source:E1e,chunkCount:hr.pipe(Pr(0)),batchCount:hr.pipe(Pr(0)),ranker:y1e,fallback:Ie,fallbackReason:_(x1e,{nullable:!0}),durationMs:de.pipe(Pr(0))}){}class Fq extends q({durationMs:de.pipe(Pr(0)),sources:ve(S1e)}){}class iQ extends q({query:E,snippets:ve(q({type:_(V("text"),{nullable:!0,default:()=>"text"}),source:V("markdown","appendix","statejson"),text:E,score:de.pipe(Pr(0),sa(1)),location:_(_q,{nullable:!0})})),meta:_(Fq,{nullable:!0})}){}class C1e extends V("youtube"){}class I1e extends V("captions","transcription"){}class b1e extends V("manual","auto"){}class w1e extends V("http"){}class B1e extends V(!1){}class Q1e extends V(!0){}class k1e extends V("FetchOriginError"){}class QO extends q({url:E,kind:w1e,contentAvailable:_(B1e,{nullable:!0}),finalUrl:_(E,{nullable:!0}),redirectLimitReached:_(Q1e,{nullable:!0}),originStatusCode:de,retryable:Ie,_tag:k1e}){}class kO extends q({meta:Mq,markdown:E,json:ve(oQ),data:_(q({assets:_(ve(BO),{nullable:!0}),degraded:_(Fee,{nullable:!0}),highlights:_(iQ,{nullable:!0}),screenshot:_(q({url:E,fullPage:Ie}),{nullable:!0}),document:_(q({url:E,contentType:E,sizeBytes:de}),{nullable:!0}),usage:_(q({documentPages:lm,ocrPages:lm,audioSeconds:de.pipe(Pr(0)),videos:_(lm,{nullable:!0})}),{nullable:!0}),video:_(q({provider:C1e,videoId:E,title:E,channel:_(E,{nullable:!0}),channelUrl:_(E,{nullable:!0}),durationSeconds:_(de,{nullable:!0}),publishedAt:_(E,{nullable:!0}),viewCount:_(de,{nullable:!0}),language:_(E,{nullable:!0}),transcript:q({source:I1e,kind:_(b1e,{nullable:!0}),language:_(E,{nullable:!0})}),segments:_(ve(q({startSeconds:de,text:E})),{nullable:!0}),chapters:_(ve(q({title:E,startSeconds:de})),{nullable:!0}),storyboard:_(q({frameWidth:hr,frameHeight:hr,rows:hr,columns:hr,sheets:ve(q({url:E,durationSeconds:de}))}),{nullable:!0})}),{nullable:!0})}),{nullable:!0}),originError:_(QO,{nullable:!0})}){}class D1e extends V("dns","tls","connectionRefused","connectionReset","connectionClosed","addressUnreachable","emptyResponse","connectionTimeout"){}class R1e extends V("FetchOriginError"){}class DO extends q({url:E,kind:D1e,upstreamError:_(E,{nullable:!0}),retryable:Ie,_tag:R1e}){}class v1e extends V("FetchOriginError"){}class T1e extends V("http"){}class O1e extends V(!1){}class M1e extends V(!0){}class RO extends q({_tag:v1e,url:E,kind:T1e,contentAvailable:O1e,finalUrl:_(E,{nullable:!0}),redirectLimitReached:_(M1e,{nullable:!0}),originStatusCode:de,retryable:Ie}){}class _1e extends Je(kO,DO,RO){}class Nq extends Je(Ey,bO){}class Lq extends Je(q({organizationId:E.pipe(yn(1)),blockedUntil:_(Je(wO,Jg),{nullable:!0}),_tag:V("AccessBlocked")}),Bq){}class Uq extends Je(np,kq){}class Pq extends Je(gy,Dq){}class Hq extends Je(vq,nQ,Tq){}class Wq extends Je(op,Oq){}class yQt extends q({"x-idempotency-key":_(E.pipe(yn(1),wP(255)),{nullable:!0})}){}class F1e extends V("off","compact","detailed"){}class N1e extends V("auto","never","always"){}class xQt extends Ne("FetchBatchedRequest")({urls:eB(E),include:_(q({html:_(Je(Ie,Or({key:E,value:Zt})),{nullable:!0}),markdown:_(Je(Ie,Or({key:E,value:Zt})),{nullable:!0}),screenshot:_(Je(Ie,q({fullPage:_(Ie,{nullable:!0})})),{nullable:!0}),links:_(Je(Ie,q({sameDomainOnly:_(Ie,{nullable:!0,default:()=>!0}),includePatterns:_(ve(E),{nullable:!0}),excludePatterns:_(ve(E),{nullable:!0})})),{nullable:!0}),meta:_(Ie,{nullable:!0,default:()=>!0}),response:_(q({includeHeaders:_(Ie,{nullable:!0,default:()=>!1})}),{nullable:!0}),json:_(Ie,{nullable:!0,default:()=>!1}),appendix:_(Ie,{nullable:!0}),appendixMarkers:_(F1e,{nullable:!0,default:()=>"compact"})}),{nullable:!0}),browserConfig:_(q({scrollFullPage:_(Ie,{nullable:!0,default:()=>!1})}),{nullable:!0}),documentConfig:_(q({maxPages:_(hr.pipe(Pr(1)),{nullable:!0}),maxAudioSeconds:_(hr.pipe(Pr(1),sa(14400)),{nullable:!0,default:()=>3600}),ocr:_(N1e,{nullable:!0,default:()=>"auto"})}),{nullable:!0})}){}class L1e extends Ne("BatchedRun")({id:E}){}class U1e extends Je(Ey,bO){}class P1e extends V("AccessBlocked"){}class H1e extends q({organizationId:E.pipe(yn(1)),blockedUntil:_(Je(wO,Jg),{nullable:!0}),_tag:P1e}){}class W1e extends V("payload_mismatch"){}class q1e extends V("BatchedIdempotencyConflict"){}class G1e extends Ne("BatchedIdempotencyConflict")({existingRunId:E,reason:W1e,_tag:q1e}){}class SQt extends q({limit:_(E,{nullable:!0}),offset:_(E,{nullable:!0}),include:_(E,{nullable:!0})}){}class V1e extends V("QUEUED","RUNNING","CANCELLING","COMPLETED","FAILED","CANCELLED"){}class z1e extends V("QUEUED","RUNNING","CANCELLING","COMPLETED","FAILED","CANCELLED"){}class Y1e extends V("QUEUED","RUNNING","SUCCEEDED","FAILED","CANCELLED"){}class j1e extends E{}class oI extends q({url:E,requestedUrl:_(j1e,{nullable:!0}),originStatusCode:_(de,{nullable:!0}),redirectStatusCode:_(de,{nullable:!0}),contentType:_(E,{nullable:!0}),headers:_(q({}),{nullable:!0})}){}class $1e extends q({href:E.pipe(yn(1)),rel:E.pipe(yn(1)),type:_(E.pipe(yn(1)),{nullable:!0}),sizes:_(E.pipe(yn(1)),{nullable:!0})}){}class J1e extends q({url:E.pipe(yn(1)),width:_(de,{nullable:!0}),height:_(de,{nullable:!0}),alt:_(E,{nullable:!0})}){}class K1e extends q({title:_(E,{nullable:!0}),description:_(E,{nullable:!0}),type:_(E.pipe(yn(1)),{nullable:!0}),url:_(E.pipe(yn(1)),{nullable:!0}),siteName:_(E,{nullable:!0}),locale:_(E,{nullable:!0}),images:_(ve(J1e),{nullable:!0})}){}class Z1e extends q({card:_(E.pipe(yn(1)),{nullable:!0}),site:_(E,{nullable:!0}),creator:_(E,{nullable:!0}),title:_(E,{nullable:!0}),description:_(E,{nullable:!0}),image:_(E.pipe(yn(1)),{nullable:!0})}){}class X1e extends q({title:_(E,{nullable:!0}),description:_(E,{nullable:!0}),canonicalUrl:_(E.pipe(yn(1)),{nullable:!0}),language:_(E.pipe(yn(1)),{nullable:!0}),charset:_(E.pipe(yn(1)),{nullable:!0}),favicon:_(E.pipe(yn(1)),{nullable:!0}),icons:_(ve($1e),{nullable:!0}),openGraph:_(K1e,{nullable:!0}),twitter:_(Z1e,{nullable:!0})}){}class Nee extends E.pipe(yn(1)){}class e2e extends V("youtube"){}class t2e extends V("captions","transcription"){}class r2e extends V("manual","auto"){}class n2e extends q({url:E,text:_(E,{nullable:!0})}){}class o2e extends V("rust"){}class i2e extends V("rust"){}class s2e extends V("rust"){}class a2e extends q({capture:_(o2e,{nullable:!0}),markdown:_(i2e,{nullable:!0}),tree:_(s2e,{nullable:!0})}){}class c2e extends q({status:Y1e,data:_(q({response:oI,meta:_(X1e,{nullable:!0}),json:_(ve(q({})),{nullable:!0}),snapshotId:_(Nee,{nullable:!0}),html:_(E.pipe(yn(1)),{nullable:!0}),markdown:_(E.pipe(yn(1)),{nullable:!0}),screenshot:_(q({url:E,fullPage:Ie}),{nullable:!0}),document:_(q({url:E,contentType:E,sizeBytes:de}),{nullable:!0}),usage:_(q({documentPages:lm,ocrPages:lm,audioSeconds:de.pipe(Pr(0)),videos:_(lm,{nullable:!0})}),{nullable:!0}),video:_(q({provider:e2e,videoId:E,title:E,channel:_(E,{nullable:!0}),channelUrl:_(E,{nullable:!0}),durationSeconds:_(de,{nullable:!0}),publishedAt:_(E,{nullable:!0}),viewCount:_(de,{nullable:!0}),language:_(E,{nullable:!0}),transcript:q({source:t2e,kind:_(r2e,{nullable:!0}),language:_(E,{nullable:!0})}),segments:_(ve(q({startSeconds:de,text:E})),{nullable:!0}),chapters:_(ve(q({title:E,startSeconds:de})),{nullable:!0}),storyboard:_(q({frameWidth:hr,frameHeight:hr,rows:hr,columns:hr,sheets:ve(q({url:E,durationSeconds:de}))}),{nullable:!0})}),{nullable:!0}),links:_(ve(n2e),{nullable:!0}),appendix:_(E.pipe(yn(1)),{nullable:!0}),renderEngines:_(a2e,{nullable:!0}),assets:_(ve(BO),{nullable:!0}),degraded:_(Fee,{nullable:!0})}),{nullable:!0}),error:_(Je(Bq,kq,nQ,tQ,Tq,Je(DO,RO),Oq,rQ,vq,yy,xy),{nullable:!0}),originError:_(QO,{nullable:!0})}){}class l2e extends q({total:de,limit:de,offset:de,hasMore:Ie}){}class u2e extends Ne("BatchedStatus")({id:E,status:V1e,batchedStatus:z1e,totalUrls:de,results:ve(c2e),pagination:l2e}){}class p2e extends V("BatchedIncludeUnsupported"){}class f2e extends q({unsupportedFields:ve(E),_tag:p2e}){}class d2e extends Je(Ey,f2e){}class A2e extends V("CANCELLING","CANCELLED"){}class h2e extends Ne("BatchedCancellation")({id:E,status:A2e}){}class m2e extends V("COMPLETED","FAILED"){}class g2e extends V("BatchedCancellationConflict"){}class E2e extends Ne("BatchedCancellationConflict")({id:E,status:m2e,_tag:g2e}){}class y2e extends V("off","compact","detailed"){}class CQt extends Ne("SnapshotHighlightsInput")({highlights:q({query:E,maxResults:_(hr.pipe(Pr(1),sa(50)),{nullable:!0,default:()=>5}),minScore:_(de.pipe(Pr(0),sa(1)),{nullable:!0,default:()=>0.6})}),include:_(q({html:_(Je(Ie,Or({key:E,value:Zt})),{nullable:!0}),markdown:_(Je(Ie,Or({key:E,value:Zt})),{nullable:!0}),screenshot:_(Je(Ie,q({fullPage:_(Ie,{nullable:!0})})),{nullable:!0}),links:_(Je(Ie,q({sameDomainOnly:_(Ie,{nullable:!0,default:()=>!0}),includePatterns:_(ve(E),{nullable:!0}),excludePatterns:_(ve(E),{nullable:!0})})),{nullable:!0}),meta:_(Ie,{nullable:!0,default:()=>!0}),response:_(q({includeHeaders:_(Ie,{nullable:!0,default:()=>!1})}),{nullable:!0}),json:_(Ie,{nullable:!0,default:()=>!1}),appendix:_(Ie,{nullable:!0}),appendixMarkers:_(y2e,{nullable:!0,default:()=>"compact"})}),{nullable:!0})}){}class x2e extends Ne("FetchSnapshotHighlightsResult")({snapshotId:E.pipe(yn(1)),response:oI,highlights:iQ,durationMs:de.pipe(Pr(0)),playground:E}){}class qq extends Je(Ey,bO){}class S2e extends V("AccessBlocked"){}class Gq extends q({organizationId:E.pipe(yn(1)),blockedUntil:_(Je(wO,Jg),{nullable:!0}),_tag:S2e}){}class C2e extends V("FetchSnapshotHighlightsNotFound"){}class Vq extends Ne("FetchSnapshotHighlightsNotFound")({snapshotId:Nee,_tag:C2e}){}class zq extends Je(gy,Dq){}class I2e extends V("json","markdown"){}class IQt extends q({format:_(I2e,{nullable:!0})}){}class b2e extends V(1){}class sQ extends Ne("SnapshotCatalog")({version:b2e,snapshotId:E,collections:q({evidence:E,network:E,assets:E,artifacts:E}),artifacts:ve(q({id:E,kind:E,url:E,preview:_(E,{nullable:!0})})),links:q({markdown:E,json:E})}){}class w2e extends V("SnapshotNotFound"){}class B2e extends Ne("SnapshotNotFound")({snapshotId:E,_tag:w2e}){}var Yq=(e,t={})=>{let r=(i,s)=>N(nl(s.text,()=>"Unexpected status code"),(a)=>se(new Xo({request:i,response:s,reason:"StatusCode",description:a}))),n=(i)=>t.transformClient?t.transformClient(i):M(i),o=(i,s)=>N(Ws(s)(i),se);return{fetchFetch:(i)=>El("POST")("/v1/fetch").pipe(_h({include:i.params.include,appendixMarkers:i.params.appendixMarkers}),(s)=>tr(yl(s,i.payload)),N((s)=>N(n(e),(a)=>N(a.execute(s),xl({"400":(c)=>o(c,wq),"401":(c)=>o(c,rp),"403":(c)=>o(c,Qq),"404":(c)=>o(c,CO),"410":(c)=>o(c,IO),"413":(c)=>o(c,wHe),"415":(c)=>o(c,tQ),"422":(c)=>o(c,rQ),"429":(c)=>o(c,Rq),"500":(c)=>o(c,_l),"502":(c)=>o(c,WHe),"503":(c)=>o(c,jHe),"504":(c)=>o(c,yy),"529":(c)=>o(c,xy),orElse:(c)=>r(s,c)}))))),fetchFetchJson:(i)=>El("POST")("/v1/fetch/json").pipe(_h({include:i.params.include,appendixMarkers:i.params.appendixMarkers}),(s)=>tr(yl(s,i.payload)),N((s)=>N(n(e),(a)=>N(a.execute(s),xl({"200":(c)=>Ws(_1e)(c),"400":(c)=>o(c,Nq),"401":(c)=>o(c,rp),"403":(c)=>o(c,Lq),"404":(c)=>o(c,CO),"410":(c)=>o(c,IO),"413":(c)=>o(c,Uq),"415":(c)=>o(c,tQ),"422":(c)=>o(c,rQ),"429":(c)=>o(c,Pq),"500":(c)=>o(c,_l),"502":(c)=>o(c,Hq),"503":(c)=>o(c,Wq),"504":(c)=>o(c,yy),"529":(c)=>o(c,xy),orElse:(c)=>r(s,c)}))))),fetchBatched:(i)=>El("POST")("/v1/fetch/batched").pipe(d8({"x-idempotency-key":i.params["x-idempotency-key"]??void 0}),(s)=>tr(yl(s,i.payload)),N((s)=>N(n(e),(a)=>N(a.execute(s),xl({"200":(c)=>Ws(L1e)(c),"400":(c)=>o(c,U1e),"401":(c)=>o(c,rp),"403":(c)=>o(c,H1e),"409":(c)=>o(c,G1e),"413":(c)=>o(c,np),"429":(c)=>o(c,gy),"500":(c)=>o(c,_l),"503":(c)=>o(c,op),orElse:(c)=>r(s,c)}))))),fetchGetBatched:(i,s)=>El("GET")(`/v1/fetch/batched/${i}`).pipe(_h({limit:s.limit,offset:s.offset,include:s.include}),M,N((a)=>N(n(e),(c)=>N(c.execute(a),xl({"200":(l)=>Ws(u2e)(l),"400":(l)=>o(l,d2e),"401":(l)=>o(l,rp),"413":(l)=>o(l,np),"429":(l)=>o(l,gy),"500":(l)=>o(l,_l),"503":(l)=>o(l,op),orElse:(l)=>r(a,l)}))))),fetchCancelBatched:(i)=>El("POST")(`/v1/fetch/batched/${i}/cancel`).pipe(M,N((s)=>N(n(e),(a)=>N(a.execute(s),xl({"200":(c)=>Ws(h2e)(c),"400":(c)=>o(c,Ey),"401":(c)=>o(c,rp),"409":(c)=>o(c,E2e),"413":(c)=>o(c,np),"429":(c)=>o(c,gy),"500":(c)=>o(c,_l),"503":(c)=>o(c,op),orElse:(c)=>r(s,c)}))))),snapshotsHighlights:(i,s)=>El("POST")(`/v1/snapshots/${i}/highlights`).pipe((a)=>tr(yl(a,s)),N((a)=>N(n(e),(c)=>N(c.execute(a),xl({"200":(l)=>Ws(x2e)(l),"400":(l)=>o(l,qq),"401":(l)=>o(l,rp),"403":(l)=>o(l,Gq),"404":(l)=>o(l,Vq),"413":(l)=>o(l,np),"429":(l)=>o(l,zq),"500":(l)=>o(l,_l),"503":(l)=>o(l,op),orElse:(l)=>r(a,l)}))))),publicSnapshotsGetCatalog:(i,s)=>El("GET")(`/v1/public/snapshots/${i}`).pipe(_h({format:s.format}),M,N((a)=>N(n(e),(c)=>N(c.execute(a),xl({"200":(l)=>Ws(sQ)(l),"400":(l)=>o(l,Ey),"404":(l)=>o(l,B2e),"413":(l)=>o(l,np),"429":(l)=>o(l,gy),"500":(l)=>o(l,_l),"503":(l)=>o(l,op),orElse:(l)=>r(a,l)})))))}};var bQt=Symbol("DecodedErrorStatus");function aQ(e,t){return N(nl(t.text,()=>"Unexpected status code"),(r)=>se(new Xo({request:e,response:t,reason:"StatusCode",description:r})))}function Wr(e,t){let r=Ws(t)(e),n=e.status===404||e.status===410?r.pipe(Wi("ParseError",()=>aQ(e.request,e))):r;return N(n,(o)=>{if(typeof o==="object"&&o!==null)Object.defineProperty(o,bQt,{value:e.status});return se(o)})}function Lee(e,t){return Ws(t)(e).pipe(Wi("ParseError",(r)=>new cO({message:"Failed to decode the API response",cause:r})))}var wQt=q({...iQ.fields.snippets.value.fields,json:_(Zt,{nullable:!0})}),Q2e=q({...iQ.fields,snippets:ve(wQt)}),BQt=q({...oQ.fields,body:_(Zt,{nullable:!0})});class k2e extends Ne("FetchObjectModeResultWithJson")({...kO.fields,json:ve(BQt),data:_(q({...kO.fields.data.from.fields,highlights:_(Q2e,{nullable:!0})}),{nullable:!0}),originError:_(QO,{nullable:!0})}){}var QQt=Je(k2e,DO,RO);function Sy(e){return"_tag"in e&&e._tag==="FetchOriginError"}class D2e extends Ne("FetchSnapshotHighlightsResultWithJson")({snapshotId:E.pipe(yn(1)),response:oI,highlights:Q2e,durationMs:de.pipe(Pr(0)),playground:E}){}var Uee=(e,t)=>El("POST")("/v1/fetch/json").pipe(_h(t.params.include!==void 0?{include:t.params.include}:{}),(r)=>tr(yl(r,t.payload)),N((r)=>N(e.execute(r),xl({"200":(n)=>Lee(n,QQt),"400":(n)=>Wr(n,Nq),"401":(n)=>Wr(n,rp),"403":(n)=>Wr(n,Lq),"404":(n)=>Wr(n,CO),"410":(n)=>Wr(n,IO),"413":(n)=>Wr(n,Uq),"415":(n)=>Wr(n,tQ),"422":(n)=>Wr(n,rQ),"429":(n)=>Wr(n,Pq),"500":(n)=>Wr(n,_l),"502":(n)=>Wr(n,Hq),"503":(n)=>Wr(n,Wq),"504":(n)=>Wr(n,yy),"529":(n)=>Wr(n,xy),orElse:(n)=>aQ(r,n)})))),R2e=(e,t,r)=>El("POST")(`/v1/snapshots/${encodeURIComponent(t)}/highlights`).pipe((n)=>tr(yl(n,r)),N((n)=>N(e.execute(n),xl({"200":(o)=>Lee(o,D2e),"400":(o)=>Wr(o,qq),"401":(o)=>Wr(o,rp),"403":(o)=>Wr(o,Gq),"404":(o)=>Wr(o,Vq),"413":(o)=>Wr(o,np),"429":(o)=>Wr(o,zq),"500":(o)=>Wr(o,_l),"503":(o)=>Wr(o,op),orElse:(o)=>aQ(n,o)}))));var Pee=class e extends Error{status;text;json;headers;constructor(t,r,n,o,i,s){super(s||`HTTP Error ${t} at ${i}: ${r??JSON.stringify(n)}`);this.url=i,this.name="FetchError",this.status=t,this.text=r,this.json=n,this.headers=o}static async fromResponse(t,r){let n=t.status,o=Object.fromEntries([...t.headers.entries()]),i=void 0,s=void 0,a=t.headers.get("content-type");if(!t.bodyUsed&&t.body!==null)if(a&&a.includes("application/json"))try{s=await t.json()}catch{i=await t.text()}else i=await t.text();return new e(n,i,s,o,r)}},_2e=class extends Error{constructor(){super("Fetch with backoff aborted");this.name="FetchBackoffAbortError"}},ha=class e extends Error{status;code;details;constructor(t,r,n,o){super(t);this.name="DurableStreamError",this.code=r,this.status=n,this.details=o}static async fromResponse(t,r){let n=t.status,o,i=t.headers.get("content-type");if(!t.bodyUsed&&t.body!==null)if(i&&i.includes("application/json"))try{o=await t.json()}catch{o=await t.text()}else o=await t.text();let s=v2e(n),a=`Durable stream error at ${r}: ${t.statusText||n}`;return new e(a,s,n,o)}static fromFetchError(t){let r=v2e(t.status);return new e(t.message,r,t.status,t.json??t.text)}};function v2e(e){switch(e){case 400:return"BAD_REQUEST";case 401:return"UNAUTHORIZED";case 403:return"FORBIDDEN";case 404:return"NOT_FOUND";case 409:return"CONFLICT_SEQ";case 429:return"RATE_LIMITED";case 503:return"BUSY";default:return"UNKNOWN"}}var kQt=class extends ha{code="STREAM_CLOSED";status=409;streamClosed=!0;finalOffset;constructor(e,t){super("Cannot append to closed stream","STREAM_CLOSED",409,e);this.name="StreamClosedError",this.finalOffset=t}};var DQt=[429,503],jq={initialDelay:100,maxDelay:60000,multiplier:1.3,maxRetries:1/0};function RQt(e){if(!e)return 0;let t=Number(e);if(Number.isFinite(t)&&t>0)return t*1000;let r=Date.parse(e);if(!isNaN(r)){let n=r-Date.now();return Math.max(0,Math.min(n,3600000))}return 0}function vQt(e,t=jq){let{initialDelay:r,maxDelay:n,multiplier:o,debug:i=!1,onFailedAttempt:s,maxRetries:a=1/0}=t;return async(...c)=>{let l=c[0],u=c[1],p=r,f=0;while(!0)try{let d=await e(...c);if(d.ok)return d;throw await Pee.fromResponse(d,l.toString())}catch(d){if(s?.(),u?.signal?.aborted)throw new _2e;else if(d instanceof Pee&&!DQt.includes(d.status)&&d.status>=400&&d.status<500)throw d;else{if(f++,f>a){if(i)console.log(`Max retries reached (${f}/${a}), giving up`);throw d}let A=d instanceof Pee?RQt(d.headers["retry-after"]):0,m=Math.random()*p,g=Math.min(m,n),y=Math.max(A,g);if(i){let w=A>0?"server+client":"client";console.log(`Retry attempt #${f} after ${y}ms (${w}, serverMin=${A}ms, clientBackoff=${g}ms)`)}await new Promise((w)=>setTimeout(w,y)),p=Math.min(p*o,n)}}}}function TQt(e){return typeof Symbol<"u"&&typeof Symbol.asyncIterator==="symbol"&&typeof e[Symbol.asyncIterator]==="function"}function OQt(e){if(typeof Symbol>"u"||typeof Symbol.asyncIterator!=="symbol")return;if(typeof e[Symbol.asyncIterator]==="function")return;let t=function(){let r=this.getReader(),n=!1,o=0;return{async next(){if(n)return{done:!0,value:void 0};o++;try{let{value:s,done:a}=await r.read();if(a)return n=!0,r.releaseLock(),{done:!0,value:void 0};return{done:!1,value:s}}catch(s){n=!0;try{r.releaseLock()}catch{}throw s}finally{o--}},async return(s){if(o>0)throw TypeError("Cannot close a readable stream reader when it has pending read requests");n=!0;let a=r.cancel(s);return r.releaseLock(),await a,{done:!0,value:void 0}},async throw(s){if(o>0)throw TypeError("Cannot close a readable stream reader when it has pending read requests");n=!0;let a=r.cancel(s);throw r.releaseLock(),await a,s},[Symbol.asyncIterator](){return this}}};try{Object.defineProperty(e,Symbol.asyncIterator,{configurable:!0,writable:!0,value:t})}catch{return}try{Object.defineProperty(e,"values",{configurable:!0,writable:!0,value:t})}catch{}}function Hee(e){if(!TQt(e))OQt(e);return e}async function*Wee(e,t){let r=e.getReader(),n=new TextDecoder,o="",i={data:[]};try{while(!0){if(t?.aborted)break;let{done:a,value:c}=await r.read();if(a)break;o+=n.decode(c,{stream:!0}),o=o.replace(/\r\n/g,`
|
|
304
304
|
`).replace(/\r/g,`
|