@fungi.computer/grove 0.6.0 → 0.6.1

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.
Files changed (26) hide show
  1. package/dist/assets/{anthropic-messages-CPEaUutD.js → anthropic-messages-CDm0hoBV.js} +3 -3
  2. package/dist/assets/{azure-openai-responses-v3mj5CZZ.js → azure-openai-responses-BjoRAOlM.js} +1 -1
  3. package/dist/assets/burger-DGewjCsv.js +1 -0
  4. package/dist/assets/cat-CRMM8U8H.js +1 -0
  5. package/dist/assets/{compat-CwkWF6ok.js → compat-tatm8WJ0.js} +2 -2
  6. package/dist/assets/{extension-hook-Br5iAg1w.js → extension-hook-CmoMuW6C.js} +2 -2
  7. package/dist/assets/{extensions-CjtnEhJO.js → extensions-CrmxvtfG.js} +1 -1
  8. package/dist/assets/{google-generative-ai-Cr31vBXM.js → google-generative-ai-xdelq2ko.js} +1 -1
  9. package/dist/assets/{google-shared-B7c3mJMP.js → google-shared-P7z8Pe9d.js} +1 -1
  10. package/dist/assets/{google-vertex-DkitNPeW.js → google-vertex-8hsu6Eaf.js} +1 -1
  11. package/dist/assets/{index-CKEriJXp.js → index-CCJvRnqn.js} +4 -4
  12. package/dist/assets/{mistral-conversations-BP4PIzHA.js → mistral-conversations-JKMpJrPb.js} +1 -1
  13. package/dist/assets/{mushroom-DWyBmJbK.js → mushroom-ur0TNKww.js} +1 -1
  14. package/dist/assets/{node.browser-Dxo8S8wh.js → node.browser-GHKlzSn3.js} +1 -1
  15. package/dist/assets/{openai-codex-responses-BIR4H8vE.js → openai-codex-responses-CidQ12Xa.js} +1 -1
  16. package/dist/assets/{openai-completions-rOTfBeMc.js → openai-completions-D9RzypE9.js} +1 -1
  17. package/dist/assets/{openai-responses-CDJo-fey.js → openai-responses-BXeaL2BV.js} +1 -1
  18. package/dist/assets/{openai-responses-shared-mHodHbGd.js → openai-responses-shared-Da1jFqQB.js} +1 -1
  19. package/dist/assets/{parakeet-conversation-C7vaUI2C.js → parakeet-conversation-DYlN7oL9.js} +1 -1
  20. package/dist/assets/{renderer-BMvbFBH6.js → renderer-BKCye2Ev.js} +1 -1
  21. package/dist/assets/{runtime-core-BCAZGL-z.js → runtime-core-DKpk6tKT.js} +1 -1
  22. package/dist/assets/{transform-messages-CiA_d5H1.js → transform-messages-YmXk5TtR.js} +1 -1
  23. package/dist/index.html +2 -2
  24. package/package.json +9 -9
  25. package/dist/assets/burger-CPCRQtwa.js +0 -1
  26. package/dist/assets/cat-BxITknTO.js +0 -1
@@ -1,4 +1,4 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/compat-CwkWF6ok.js","assets/preload-helper-DY31Aviq.js","assets/index-CKEriJXp.js","assets/rolldown-runtime-hePW80VL.js","assets/Effect-CtszBD7f.js","assets/document-Bagsf-XI.js","assets/base-face-DzmOsdaJ.js","assets/index-DVjf7FkJ.css","assets/provider-env-CcCbsTJq.js","assets/diagnostics-CxvqSC4Q.js","assets/models-BM_0GHMS.js","assets/json-parse-M7s0500m.js","assets/openai-codex-responses-BIR4H8vE.js","assets/headers-FK4rgixo.js","assets/transform-messages-CiA_d5H1.js","assets/runtime-core-BCAZGL-z.js","assets/extensions-CjtnEhJO.js","assets/error-body-pkrba6pf.js","assets/openai-prompt-cache-DXo9f3w5.js","assets/openai-responses-shared-mHodHbGd.js","assets/sanitize-unicode-DmIE6hZJ.js","assets/hash-yQufAZII.js","assets/abort-signals-joV34wzR.js"])))=>i.map(i=>d[i]);
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/compat-tatm8WJ0.js","assets/preload-helper-DY31Aviq.js","assets/index-CCJvRnqn.js","assets/rolldown-runtime-hePW80VL.js","assets/Effect-CtszBD7f.js","assets/document-Bagsf-XI.js","assets/base-face-DzmOsdaJ.js","assets/index-DVjf7FkJ.css","assets/provider-env-CcCbsTJq.js","assets/diagnostics-CxvqSC4Q.js","assets/models-BM_0GHMS.js","assets/json-parse-M7s0500m.js","assets/openai-codex-responses-CidQ12Xa.js","assets/headers-FK4rgixo.js","assets/transform-messages-YmXk5TtR.js","assets/runtime-core-DKpk6tKT.js","assets/extensions-CrmxvtfG.js","assets/error-body-pkrba6pf.js","assets/openai-prompt-cache-DXo9f3w5.js","assets/openai-responses-shared-Da1jFqQB.js","assets/sanitize-unicode-DmIE6hZJ.js","assets/hash-yQufAZII.js","assets/abort-signals-joV34wzR.js"])))=>i.map(i=>d[i]);
2
2
  import{$ as e,$r as t,$t as n,A as r,Ai as i,An as a,Ar as o,At as s,B as c,Bn as l,Br as u,Bt as d,C as f,Ci as p,Cn as m,Cr as ee,Ct as h,D as te,Di as g,Dn as ne,Dr as re,Dt as ie,E as ae,Ei as oe,Er as se,Et as ce,Fn as le,Fr as ue,Ft as de,G as fe,Gn as pe,Gr as me,Gt as he,H as ge,Hn as _e,Hr as ve,Ht as ye,I as be,Ir as xe,It as Se,J as Ce,Ja as we,Ji as Te,Jn as Ee,Jt as De,K as Oe,Ki as ke,Kn as Ae,Kr as je,Kt as Me,L as Ne,Ln as Pe,Lr as Fe,Lt as Ie,M as Le,Mi as Re,Mn as ze,Mr as Be,Mt as Ve,N as He,Ni as Ue,Nn as We,Nr as Ge,Nt as Ke,O as qe,Or as Je,Ot as Ye,P as Xe,Pi as Ze,Pn as Qe,Pr as $e,Pt as et,Qi as tt,Qr as nt,Qt as rt,R as it,Rn as at,Rr as ot,Rt as st,S as ct,Sa as lt,Si as ut,Sn as dt,St as ft,T as pt,Ti as mt,Tn as ht,Tr as gt,Tt as _t,U as vt,Ur as yt,Ut as bt,V as xt,Vn as St,Vr as Ct,Vt as wt,W as Tt,Wr as _,Wt as Et,X as Dt,Xi as Ot,Xn as kt,Xr as At,Xt as jt,Y as Mt,Yi as Nt,Yr as v,Yt as Pt,Z as Ft,Za as It,Zi as Lt,Zn as Rt,Zt as zt,_ as Bt,_a as Vt,_i as Ht,_n as Ut,_r as Wt,_t as Gt,a as y,aa as Kt,ai as qt,an as Jt,ar as Yt,at as Xt,b as Zt,bi as Qt,bn as $t,bt as en,c as tn,ca as nn,ci as rn,cn as an,cr as on,ct as sn,d as cn,da as ln,di as un,dn,dt as fn,ea as pn,ei as mn,en as hn,eo as gn,et as _n,f as vn,fa as yn,fi as bn,fn as xn,fr as Sn,ft as b,g as x,ga as Cn,gi as wn,gn as Tn,gr as En,h as Dn,hi as On,hn as kn,hr as An,ht as jn,i as Mn,ia as Nn,in as Pn,ir as Fn,it as In,j as S,ji as Ln,jn as Rn,jr as zn,jt as Bn,k as Vn,ki as Hn,kn as Un,kr as Wn,kt as Gn,l as Kn,la as C,li as qn,ln as Jn,lt as Yn,m as Xn,ma as Zn,mi as Qn,mn as $n,mr as er,mt as w,na as tr,ni as nr,nn as rr,nr as ir,nt as ar,o as or,oi as sr,on as cr,ot as lr,p as ur,pa as dr,pi as fr,pn as pr,pr as mr,pt as hr,q as gr,qn as _r,qr as vr,qt as yr,r as br,ra as xr,ri as Sr,rn as Cr,rr as wr,rt as Tr,s as Er,sa as Dr,si as Or,sn as kr,sr as Ar,t as jr,ti as Mr,tn as Nr,tr as Pr,tt as Fr,u as Ir,ua as Lr,ui as Rr,un as zr,ur as Br,v as Vr,va as T,vi as Hr,vn as Ur,vr as Wr,vt as Gr,w as Kr,wi as qr,wn as Jr,wr as Yr,wt as Xr,x as Zr,xa as Qr,xi as $r,xn as ei,xr as ti,xt as ni,y as E,ya as ri,yi as ii,yn as ai,yr as oi,yt as si,z as ci,zr as li,zt as ui}from"./Effect-CtszBD7f.js";import{l as di,t as fi}from"./preload-helper-DY31Aviq.js";var pi=e=>e>0?Math.floor(e):0,mi=e=>Math.max(1,pi(e)),hi=e=>{let t=e[Symbol.iterator]().next();if(t.done)throw Error(`headUnsafe: empty iterable`);return t.value},gi=`~effect/BigDecimal`,_i={[gi]:gi,[qn](){let e=Ti(this);return qt(rn(String(e.value)),Or(e.scale))},[Sr](e){return vi(e)&&Ai(this,e)===0},toString(){return`BigDecimal(${Mi(this)})`},toJSON(){return{_id:`BigDecimal`,value:String(this.value),scale:this.scale}},[yt](){return this.toJSON()},pipe(){return Ze(this,arguments)}},vi=e=>Rr(e,gi),yi=(e,t)=>{if(!Number.isSafeInteger(t))throw RangeError(`Scale must be a safe integer, got ${t}`);let n=Object.create(_i);return n.value=e,n.scale=t,n},bi=(e,t)=>{let n=yi(e,t);return n.normalized=n,n},xi=BigInt(0),Si=BigInt(1),Ci=BigInt(10),wi=bi(xi,0),Ti=e=>{if(e.normalized===void 0){if(e.value===xi)e.normalized=wi;else{let t=`${e.value}`,n=t.length;for(;t[n-1]===`0`;)n--;e.normalized=bi(BigInt(t.slice(0,n)),e.scale-(t.length-n))}}return e.normalized},Ei=100,Di=[Si],Oi=(e,t)=>e===t?0:e<t?-1:1,ki=(e,t)=>{let n=`${e.value<xi?-e.value:e.value}`,r=`${t.value<xi?-t.value:t.value}`,i=BigInt(n.length-r.length)-BigInt(e.scale)+BigInt(t.scale);if(i!==xi)return i<xi?-1:1;let a=Math.max(n.length,r.length);return An(n.padEnd(a,`0`),r.padEnd(a,`0`))},Ai=(e,t)=>{if(e.scale===t.scale)return Oi(e.value,t.value);let n=ji(e),r=ji(t);if(n!==r)return n<r?-1:1;if(n===0)return 0;let i=e.scale-t.scale,a=Math.abs(i);if(a>Ei)return n===-1?ki(t,e):ki(e,t);let o=Di[a]??=Ci**BigInt(a);return i>0?Oi(e.value,t.value*o):Oi(e.value*o,t.value)},ji=e=>e.value===xi?0:e.value<xi?-1:1,Mi=e=>{let t=Ti(e);if(Math.abs(t.scale)>=16)return Ni(t);let n=t.value<xi,r=`${n?-t.value:t.value}`,i=t.scale>0?r.padStart(t.scale+1,`0`):r.padEnd(r.length-t.scale,`0`),a=i.length-t.scale,o=t.scale>0?`${i.slice(0,a)}.${i.slice(a)}`:i;return n?`-${o}`:o},Ni=e=>{if(Pi(e))return`0e+0`;let t=Ti(e),n=`${t.value}`,r=t.value<xi?2:1,i=n.slice(0,r),a=n.slice(r),o=a.length-t.scale;return`${i}${a===``?``:`.${a}`}e${o>=0?`+`:``}${o}`},Pi=e=>e.value===xi,Fi=Yr,Ii=`~effect/encoding/EncodingError`,Li=class extends Fi(`EncodingError`){[Ii]=Ii},Ri=Fe,zi=Je,Bi=re,Vi=se,Hi=hn,Ui=Ve,Wi=et,Gi=jt,Ki=zt,qi=Pt,Ji=Ke,Yi=ue,Xi=Wn,Zi=ie;a()(`effect/Cause/StackTrace`),a()(`effect/Cause/InterruptorStackTrace`);var Qi=$e,$i=Ge,ea=Be,ta=zn,na=bt,ra=wt,ia=d,aa=ye,oa=st,sa={"~effect/Deferred":{_A:Hn,_E:Hn},pipe(){return Ze(this,arguments)}},ca=function(){this.resumes=void 0,this.effect=void 0};ca.prototype=sa;var la=()=>new ca,ua=()=>ai(()=>la()),da=e=>s(t=>e.effect?t(e.effect):(e.resumes??=[],e.resumes.push(t),ai(()=>{let n=e.resumes;if(n===void 0)return;let r=n.indexOf(t);r>=0&&n.splice(r,1)}))),fa=g(2,(e,t)=>ai(()=>ha(e,t))),pa=g(2,(e,t)=>fa(e,Be(t))),ma=g(2,(e,t)=>fa(e,$e(t))),ha=(e,t)=>{if(e.effect)return!1;if(e.effect=t,e.resumes){let n=e.resumes;e.resumes=void 0;for(let e=0;e<n.length;e++)n[e](t)}return!0},ga=kn,_a=pr,va=$n,ya=cr,ba=Jn,xa=an,Sa=dn,Ca=xn,wa=zr,Ta=ce,Ea=Se,Da=`~effect/DateTime`,Oa=`~effect/DateTime/TimeZone`,ka={[Da]:Da,pipe(){return Ze(this,arguments)},[yt](){return this.toString()},toJSON(){return Ba(this).toJSON()}},Aa={...ka,_tag:`Utc`,[qn](){return Or(this.epochMilliseconds)},[Sr](e){return Ma(e)&&e._tag===`Utc`&&this.epochMilliseconds===e.epochMilliseconds},toString(){return`DateTime.Utc(${Ba(this).toJSON()})`}};({...ka});var ja={[Oa]:Oa,[yt](){return this.toString()}};({...ja}),{...ja};var Ma=e=>Rr(e,Da),Na=e=>e._tag===`Utc`,Pa=e=>{let t=Object.create(Aa);return t.epochMilliseconds=e,Object.defineProperty(t,"partsUtc",{value:void 0,enumerable:!1,writable:!0}),t},Fa=e=>{let t=e.getTime();if(Number.isNaN(t))throw new Zi(`Invalid date`);return Pa(t)},Ia=e=>{if(Ma(e))return e;if(e instanceof Date)return Fa(e);if(typeof e==`object`){if(`epochMilliseconds`in e)return Fa(new Date(e.epochMilliseconds));let t=new Date(0);return Va(t,e),Fa(t)}return typeof e==`string`&&!La(e)?Fa(new Date(e+`Z`)):Fa(new Date(e))},La=e=>/Z|GMT|[+-]\d{2}$|[+-]\d{2}:?\d{2}$|\]$/.test(e),Ra=Yt(Ia),za=e=>Pa(e.epochMilliseconds),Ba=e=>new Date(e.epochMilliseconds),Va=(e,t)=>{if((t.year!==void 0||t.month!==void 0||t.day!==void 0)&&e.setUTCFullYear(t.year??e.getUTCFullYear(),t.month===void 0?e.getUTCMonth():t.month-1,t.day??e.getUTCDate()),t.weekDay!==void 0){let n=t.weekDay-e.getUTCDay();e.setUTCDate(e.getUTCDate()+n)}t.hour!==void 0&&e.setUTCHours(t.hour),t.minute!==void 0&&e.setUTCMinutes(t.minute),t.second!==void 0&&e.setUTCSeconds(t.second),t.millisecond!==void 0&&e.setUTCMilliseconds(t.millisecond)},Ha=e=>Ba(e).toISOString();globalThis.Number;var Ua=g(2,(e,t)=>{if(!globalThis.Number.isFinite(e)||!globalThis.Number.isFinite(t)||t===0)return NaN;if(globalThis.Number.isInteger(e)&&globalThis.Number.isInteger(t))return e%t;let[n,r]=Wa(e),[i,a]=Wa(t),o=Math.min(r,a),s=n*BigInt(10)**BigInt(r-o)%(i*BigInt(10)**BigInt(a-o));if(s===BigInt(0))return e<0||Object.is(e,-0)?-0:0;let c=globalThis.Number(`${s}e${o}`);return c===0?Math.sign(e)*globalThis.Number.MIN_VALUE:c});function Wa(e){if(globalThis.Number.isInteger(e))return[BigInt(e),0];let t=Math.abs(e).toExponential(),n=t.indexOf(`e`),r=t.slice(0,n).replace(`.`,``);return[BigInt(r)*(e<0?-BigInt(1):BigInt(1)),globalThis.Number(t.slice(n+1))-r.length+1]}globalThis.String;var Ga=e=>e.trim(),Ka=g(2,(e,t)=>Bn(e,Xa,e=>t(e))),qa=e=>e.reasons.some(Ja),Ja=e=>e._tag===`Fail`&&Yi(e.error),Ya=e=>{let t,n=!1;for(let r of e.reasons)Ja(r)?t??=r.error:r._tag!==`Interrupt`&&(n=!0);return t===void 0?_e(e):n?_e(zi(e.reasons.filter(e=>!Ja(e)))):kt(t)},Xa=e=>{let t=Ya(e);return pe(t)?t:kt(t.success.value)},Za=e=>{let t=Ya(e);return pe(t)?$i(t.failure):Qi(t.success.value)},Qa=Un(`effect/Metric/CurrentMetricAttributes`,{defaultValue:()=>({})}),$a=Un(`effect/Metric/MetricRegistry`,{defaultValue:()=>new Map}),eo=`~effect/Metric`,to=class{[eo]=eo;#e;#t=``;id;description;attributes;constructor(e,t,n){this.id=e,this.description=t,this.attributes=n}valueUnsafe(e){return this.hook(e).get(e)}modifyUnsafe(e,t){return this.hook(t).modify(e,t)}updateUnsafe(e,t){return this.hook(t).update(e,t)}hook(e){let t=We(e,Qa);t!==this.#e&&(this.#e=t,this.#t=co(this,uo(this.attributes,t)));let n=We(e,$a),r=n.get(this.#t);return p(r)&&(r={id:this.id,type:this.type,description:this.description,attributes:Object.keys(t).length>0?uo(this.attributes,t):this.attributes,hooks:this.createHooks()},n.set(this.#t,r)),r.hooks}pipe(){return Ze(this,arguments)}},no=BigInt(0),ro=class extends to{type=`Counter`;#e;#t;constructor(e,t){super(e,t?.description,fo(t?.attributes)),this.#e=t?.bigint??!1,this.#t=t?.incremental??!1}createHooks(){let e=this.#e?no:0,t=this.#t?this.#e?e=>e>=no:e=>e>=0:e=>!0;return lo(()=>({count:e,incremental:this.#t}),n=>{t(n)&&(e+=n)})}},io=class extends to{type;metric;valueUnsafe;updateUnsafe;modifyUnsafe;constructor(e,t,n,r){super(e.id,e.description,e.attributes),this.metric=e,this.valueUnsafe=t,this.updateUnsafe=n,this.modifyUnsafe=r,this.type=e.type}createHooks(){return this.metric.createHooks()}},ao=(e,t)=>new ro(e,t),oo=g(2,(e,t)=>de(n=>ai(()=>e.updateUnsafe(t,n)))),so=g(2,(e,t)=>{let n=po(t);return new io(e,t=>e.valueUnsafe(n(t)),(t,r)=>e.updateUnsafe(t,n(r)),(t,r)=>e.modifyUnsafe(t,n(r)))});function co(e,t){let n=Object.entries(t).sort((e,t)=>e[0]<t[0]?-1:+(e[0]>t[0]));return JSON.stringify([e.type,e.id,e.description,n])}function lo(e,t,n){return{get:e,update:t,modify:n??t}}function uo(e,t){return{...fo(e),...fo(t)}}function fo(e){return wn(e)&&Array.isArray(e)?e.reduce((e,[t,n])=>(v(e,t,n),e),{}):e}function po(e){let t,n={};return r=>{let i=We(r,Qa);return i!==t&&(t=i,n=uo(i,e)),Rn(r,Qa,n)}}var mo=Ma,ho=Na,go=Ia,_o=Ra,vo=za;a()(`effect/DateTime/CurrentTimeZone`);var yo=Ha,bo=e=>So(typeof e==`string`?Co.encode(e):e),xo=e=>{let t=wo(e),n=t.length;if(n%4!=0)return _e(new Li({kind:`Decode`,module:`Base64`,input:t,message:`Length must be a multiple of 4, but is ${n}`}));let r=t.indexOf(`=`);if(r!==-1&&(r<n-2||r===n-2&&t[n-1]!==`=`))return _e(new Li({kind:`Decode`,module:`Base64`,input:t,message:`Found a '=' character, but it is not at the end`}));try{let e=t.endsWith(`==`)?2:+!!t.endsWith(`=`),r=new Uint8Array(n/4*3-e);for(let e=0,i=0;e<n;e+=4,i+=3){let n=Do(t.charCodeAt(e))<<18|Do(t.charCodeAt(e+1))<<12|Do(t.charCodeAt(e+2))<<6|Do(t.charCodeAt(e+3));r[i]=n>>16,r[i+1]=n>>8&255,r[i+2]=n&255}return kt(r)}catch(e){return _e(new Li({kind:`Decode`,module:`Base64`,input:t,message:e instanceof Error?e.message:`Invalid input`}))}},So=e=>{let t=e.length,n=``,r;for(r=2;r<t;r+=3)n+=To[e[r-2]>>2],n+=To[(e[r-2]&3)<<4|e[r-1]>>4],n+=To[(e[r-1]&15)<<2|e[r]>>6],n+=To[e[r]&63];return r===t+1&&(n+=To[e[r-2]>>2],n+=To[(e[r-2]&3)<<4],n+=`==`),r===t&&(n+=To[e[r-2]>>2],n+=To[(e[r-2]&3)<<4|e[r-1]>>4],n+=To[(e[r-1]&15)<<2],n+=`=`),n},Co=new TextEncoder,wo=e=>e.replace(/[\n\r]/g,``),To=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/`,Eo=new Uint8Array(123).fill(255);for(let e=0;e<64;e++)Eo[To.charCodeAt(e)]=e;Eo[61]=0;var Do=e=>{if(e>=Eo.length||Eo[e]===255)throw TypeError(`Invalid character ${String.fromCharCode(e)}`);return Eo[e]};Fi(`CookiesError`),{...ve},{...ve};var Oo=new WeakMap,ko=`~effect/Redacted`,Ao=e=>Rr(e,ko),jo=(e,t)=>{let n=Object.create(Mo);return t?.label&&(n.label=t.label),Oo.set(n,e),n},Mo={[ko]:{_A:e=>e},label:void 0,...ee,toJSON(){return this.toString()},toString(){return`<redacted${$r(this.label)?`:`+this.label:``}>`},[qn](){return sr(Oo.get(this))},[Sr](e){return Ao(e)&&mn(Oo.get(this),Oo.get(e))}};({...ee});function No(e){return e.checks?e.checks[e.checks.length-1].annotations:e.annotations}function Po(e){return t=>No(t)?.[e]}var Fo=`~structural`,Io=`~identifier`,Lo=`~sentinels`,Ro=`~constructor`,zo=[`title`,`description`,`default`,`examples`,`readOnly`,`writeOnly`,`format`,`contentEncoding`,`contentMediaType`,`contentSchema`],Bo=Po(`identifier`),Vo=Po(Io),Ho=Po(`title`),Uo=Po(`description`),Wo=i(e=>{let t=No(e)?.identifier;return typeof t==`string`?t:e.getExpected(Wo)}),Go=new Set([Lo,Fo,`representation`,`arbitraryConstraint`,`toJsonSchema`,`toCode`,`toEquivalence`,`toFormatter`,`toCodec`,`toCodecJson`,`toCodecStringTree`,`toCodecIso`,`toCodecArbitrary`]),D=Symbol(),Ko=Qi,qo=Ko(D),Jo=Ko(D),Yo=e=>e===D?on():Br(e),Xo=e=>e._tag===`None`?qo:Ko(e.value),Zo=`~effect/SchemaIssue/Issue`;function Qo(e){return Rr(e,Zo)&&e[Zo]===Zo}function $o(e){return Object.hasOwn(e,`input`)}var es=class{[Zo]=Zo;constructor(e,t){t?.reportInput===!0&&e!==D&&(this.input=e)}},ts=class extends es{_tag=`Filter`;filter;issue;constructor(e,t,n,r){super(n,r),this.filter=e,this.issue=t}},ns=class extends es{_tag=`Encoding`;ast;issue;constructor(e,t,n,r){super(n,r),this.ast=e,this.issue=t}},rs=class extends es{_tag=`Pointer`;path;issue;constructor(e,t){super(),this.path=e,this.issue=t}},is=class extends es{_tag=`MissingKey`;annotations;constructor(e){super(),this.annotations=e}},as=class extends es{_tag=`UnexpectedKey`;ast;constructor(e,t,n){super(t,n),this.ast=e}},os=class extends es{_tag=`Composite`;ast;issues;constructor(e,t,n,r){super(n,r),this.ast=e,this.issues=t}},ss=class extends es{_tag=`InvalidType`;ast;constructor(e,t,n){super(t,n),this.ast=e}},cs=class extends es{_tag=`InvalidValue`;annotations;constructor(e,t,n){super(t,n),this.annotations=e}},ls=class extends es{_tag=`Forbidden`;annotations;constructor(e,t,n){super(t,n),this.annotations=e}},us=class extends es{_tag=`AnyOf`;ast;issues;constructor(e,t,n,r){super(n,r),this.ast=e,this.issues=t}},ds=class extends es{_tag=`OneOf`;ast;successes;constructor(e,t,n,r){super(n,r),this.ast=e,this.successes=t}};function fs(e,t,n){if(Qo(e))return e;if(typeof e==`string`)return new cs({message:e},t,n);let r=typeof e.issue==`string`?new cs({message:e.issue},t,n):e.issue;return new rs(e.path,r)}function ps(e,t,n){if(e!==void 0)return typeof e==`boolean`?e?void 0:new cs(void 0,t,n):fs(e,t,n)}function ms(e,t,n,r){return Array.isArray(t)?at(t)?t.length===1?fs(t[0],n,r):new os(e,l(t,e=>fs(e,n,r)),n,r):void 0:ps(t,n,r)}var hs=e=>{let t=Es(e);if(t!==void 0)return t;switch(e._tag){case`InvalidType`:return bs(Wo(e.ast),e);case`InvalidValue`:{let t=ys(e);if(t!==void 0)return bs(t,e);let n=vs(e);return n===void 0?`Expected a valid value`:`Invalid data ${n}`}case`MissingKey`:return`Missing key`;case`UnexpectedKey`:{let t=vs(e);return t===void 0?`Expected no excess property`:`Unexpected key with value ${t}`}case`Forbidden`:return`Forbidden operation`;case`OneOf`:{let t=vs(e);return t===void 0?`Expected exactly one member to match`:`Expected exactly one member to match the input ${t}`}}},gs=e=>Es(e.issue)??Es(e);function _s(e){return t=>({issues:xs(t,[],e?.leafHook??hs,e?.checkHook??gs)})}function vs(e){return $o(e)?_(e.input):void 0}function ys(e){let t=e.annotations?.expected;return typeof t==`string`?t:void 0}function bs(e,t){let n=vs(t);return n===void 0?`Expected ${e}`:`Expected ${e}, got ${n}`}function xs(e,t,n,r){switch(e._tag){case`Filter`:{let i=r(e);if(i!==void 0)return[{path:t,message:i}];if(e.issue._tag!==`InvalidValue`)return xs(e.issue,t,n,r);let a=ys(e.issue);return[{path:t,message:a===void 0?bs(Ss(e.filter),e):bs(a,e.issue)}]}case`Encoding`:return xs(e.issue,t,n,r);case`Pointer`:return xs(e.issue,[...t,...e.path],n,r);case`Composite`:return e.issues.flatMap(e=>xs(e,t,n,r));case`AnyOf`:return e.issues.length===0?[{path:t,message:Es(e)??bs(Wo(e.ast),e)}]:e.issues.flatMap(e=>xs(e,t,n,r));default:return[{path:t,message:n(e)}]}}function Ss(e){let t=e.annotations?.expected;if(typeof t==`string`)return t;switch(e._tag){case`Filter`:return`<filter>`;case`FilterGroup`:return e.checks.map(e=>Ss(e)).join(` & `)}}function Cs(){return e=>Ts(e,``)}var ws=Cs();function Ts(e,t){let n;switch(e._tag){case`Filter`:{let r=gs(e);if(r!==void 0)n=r;else{if(e.issue._tag!==`InvalidValue`)return Ts(e.issue,t);let r=ys(e.issue);n=r===void 0?bs(Ss(e.filter),e):bs(r,e.issue)}break}case`Encoding`:return Ts(e.issue,t);case`Pointer`:return Ts(e.issue,t+je(e.path));case`Composite`:case`AnyOf`:if(e._tag===`Composite`||e.issues.length>0)return e.issues.map(e=>Ts(e,t)).join(`
3
3
  `);n=Es(e)??bs(Wo(e.ast),e);break;default:n=hs(e)}return t?`${n}\n at ${t}`:n}function Es(e){if(e._tag===`Pointer`)return;if(e._tag===`Encoding`)return Es(e.issue);let t=(e._tag===`Filter`?e.filter.annotations:`annotations`in e?e.annotations:e.ast.annotations)?.[e._tag===`MissingKey`?`messageMissingKey`:e._tag===`UnexpectedKey`?`messageUnexpectedKey`:`message`];if(typeof t==`string`)return t}function Ds(e){let t;for(let n of e.reasons){if(!Ri(n)||!Qo(n.error))return;t??=n.error}return t}function Os(e,t){let n=Ds(e);if(n===void 0)throw Error(t,{cause:e});return n}var ks=e=>bo(e).replace(/=/g,``).replace(/\+/g,`-`).replace(/\//g,`_`),As=e=>{let t=e.replace(/[\n\r]/g,``),n=t.length;if(n%4==1)return _e(new Li({module:`Base64Url`,kind:`Decode`,input:t,message:`Length should be a multiple of 4, but is ${n}`}));if(!/^[-_A-Z0-9]*?={0,2}$/i.test(t))return _e(new Li({module:`Base64Url`,kind:`Decode`,input:t,message:`Invalid input`}));let r=n%4==2?`${t}==`:n%4==3?`${t}=`:t;return r=r.replace(/-/g,`+`).replace(/_/g,`/`),xo(r)},js=e=>Object.assign(Object.create(Ue),e);function Ms(e){return Vs((t,n)=>x(e(t,n)))}function Ns(e){return Ms((t,n)=>{let r={message:e(t)};return Fn(t)?new ls(r,t.value,n):new ls(r)})}var Ps=Ns(()=>`Encoding is not supported`),Fs=js({_tag:`Passthrough`});function Is(){return Fs}function Ls(){return Fs}function Rs(e){return js({_tag:`Transform`,transform:e})}function zs(e){return js({_tag:`TransformEffect`,transform:e})}function Bs(e){return js({_tag:`TransformOptional`,transform:e})}function Vs(e){return js({_tag:`TransformOptionalEffect`,transform:e})}function Hs(){return Bs(()=>on())}function Us(e){return Vs(t=>{let n=Rt(t,wn);return Fn(n)?b(n):Ne(e,Br)})}function Ws(){return Rs(globalThis.String)}function Gs(){return Rs(globalThis.Number)}function Ks(){return Rs(globalThis.BigInt)}function qs(){return Rs(e=>new globalThis.Date(e))}function Js(){return Rs(Ga)}function Ys(e){return zs((t,n)=>en({try:()=>JSON.parse(t,e?.reviver),catch:()=>new cs({expected:`a valid JSON string`},t,n)}))}function Xs(e){return zs((t,n)=>en({try:()=>{let n=JSON.stringify(t,e?.replacer,e?.space);if(n===void 0)throw TypeError(`Value cannot be represented as JSON`);return n},catch:()=>new cs({expected:`a JSON-serializable value`},t,n)}))}function Zs(){return Rs(bo)}function Qs(){return zs((e,t)=>ci(r(xo(e)),()=>new cs({expected:`a valid Base64 string`},e,t)))}var $s=class extends Re{_tag=`Middleware`;decode;encode;constructor(e,t){super(),this.decode=e,this.encode=t}flip(){return new $s(this.encode,this.decode)}},ec=`~effect/SchemaTransformation/Transformation`,tc=class extends Re{[ec]=ec;_tag=`Transformation`;decode;encode;constructor(e,t){super(),this.decode=e,this.encode=t}flip(){return new tc(this.encode,this.decode)}};function nc(e){return Rr(e,ec)&&e[ec]===ec}var rc=e=>nc(e)?e:new tc(e.decode,e.encode);function ic(e){return new tc(zs(e.decode),zs(e.encode))}function ac(){return new tc(Js(),Is())}var oc=new tc(Is(),Is());function sc(){return oc}var cc=new tc(Gs(),Ws()),lc=new tc(Ks(),Ws()),uc=new tc(qs(),Rs(me)),dc=new tc(Qs(),Zs());function fc(e){return new tc(Ys(e??{}),Xs(e))}function pc(e){return t=>t._tag===e}var mc=pc(`Declaration`),hc=pc(`Null`),gc=pc(`Undefined`),_c=pc(`Never`),vc=pc(`String`),yc=pc(`Number`),bc=pc(`Boolean`),xc=pc(`Literal`),Sc=pc(`UniqueSymbol`),Cc=pc(`Arrays`),wc=pc(`Objects`),Tc=pc(`Union`),Ec=pc(`Suspend`),Dc=class{to;transformation;constructor(e,t){this.to=e,this.transformation=t}},Oc={},kc=class{isOptional;isMutable;constructorDefault;annotations;constructor(e,t,n=void 0,r=void 0){this.isOptional=e,this.isMutable=t,this.constructorDefault=n,this.annotations=r}},Ac=`~effect/Schema`,jc=class{[Ac]=Ac;annotations;checks;encoding;context;constructor(e=void 0,t=void 0,n=void 0,r=void 0){this.annotations=e,this.checks=t,this.encoding=n,this.context=r}toString(){return`<${this._tag}>`}},Mc=class extends jc{_tag=`Declaration`;typeParameters;run;encodingChecks;encodingRun;constructor(e,t,n,r,i,a,o,s){super(n,r,i,a),this.typeParameters=e,this.run=t,this.encodingChecks=o,this.encodingRun=s}getParser(){let e;return(t,n)=>t===D?qo:(e??=this.run(this.typeParameters))(t,this,n)}_rebuild(e,t,n,r,i){let a=au(this.typeParameters,e);return a===this.typeParameters&&t===this.checks&&n===this.encodingChecks&&r===this.run&&i===this.encodingRun?this:new Mc(a,r,this.annotations,t,void 0,this.context,n,i)}recur(e){return this._rebuild(e,this.checks,this.encodingChecks,this.run,this.encodingRun)}flip(e){return this._rebuild(e,this.encodingChecks,this.checks,this.encodingRun??this.run,this.run)}getExpected(){let e=this.annotations?.expected;return typeof e==`string`?e:`<Declaration>`}},Nc=new class extends jc{_tag=`Null`;getParser(){return Eu(this,null)}getExpected(){return`null`}},Pc=class extends jc{_tag=`Undefined`;getParser(){return Eu(this,void 0)}toCodecJson(){return ql(this,[Fc])}getExpected(){return`undefined`}},Fc=new Dc(Nc,new tc(Rs(()=>void 0),Rs(()=>null))),Ic=new Pc,Lc=new class extends jc{_tag=`Never`;getParser(){return Du(this,Qn)}getExpected(){return`never`}},Rc=new class extends jc{_tag=`Unknown`;getParser(){return Du(this,qr)}getExpected(){return`unknown`}},zc=class extends jc{_tag=`Literal`;literal;constructor(e,t,n,r,i){if(super(t,n,r,i),typeof e==`number`&&!globalThis.Number.isFinite(e))throw Error(`A numeric literal must be finite, got ${_(e)}`);this.literal=e}getParser(){return Eu(this,this.literal)}matchPart(e,t){return e===globalThis.String(this.literal)?this.literal:void 0}toCodecJson(){return typeof this.literal==`bigint`?Bc(this):this}toCodecStringTree(){return typeof this.literal==`string`?this:Bc(this)}getExpected(){return typeof this.literal==`string`?JSON.stringify(this.literal):globalThis.String(this.literal)}};function Bc(e){let t=globalThis.String(e.literal);return ql(e,[new Dc(new zc(t),new tc(Rs(()=>e.literal),Rs(()=>t)))])}var Vc=new class extends jc{_tag=`String`;getParser(){return Du(this,$r)}matchPart(e,t){let n=this.checks;return n&&!t.disableChecks&&Uu(n,e,void 0,this,t)?void 0:e}getExpected(){return`string`}},Hc=class extends jc{_tag=`Number`;getParser(){return Du(this,Ht)}matchKey(e,t){return this._match(Mu,e,t)}matchPart(e,t){return this._match(ju,e,t)}_match(e,t,n){if(!e.test(t))return;let r=globalThis.Number(t);return n.disableChecks||!this.checks?r:Uu(this.checks,r,void 0,this,n)?void 0:r}toCodecJson(){return this.checks&&(Uc(this.checks,`effect/schema/isFinite`)||Uc(this.checks,`effect/schema/isInt`))?this:ql(this,[Hl])}toCodecStringTree(){return this.toCodecJson()===this?ql(this,[Fu]):ql(this,[Iu])}getExpected(){return`number`}};function Uc(e,t){return e.some(e=>e.annotations?.representation?.id===t||e._tag===`FilterGroup`&&Uc(e.checks,t))}var Wc=new Hc,Gc=new class extends jc{_tag=`Boolean`;getParser(){return Du(this,bn)}getExpected(){return`boolean`}},Kc=new class extends jc{_tag=`Symbol`;getParser(){return Du(this,ut)}matchKey(e,t){return t.disableChecks||!this.checks?e:Uu(this.checks,e,void 0,this,t)?void 0:e}toCodecStringTree(){return ql(this,[Vu])}getExpected(){return`symbol`}},qc=new class extends jc{_tag=`BigInt`;getParser(){return Du(this,un)}matchPart(e,t){if(!Lu.test(e))return;let n=globalThis.BigInt(e);return t.disableChecks||!this.checks?n:Uu(this.checks,n,void 0,this,t)?void 0:n}toCodecStringTree(){return ql(this,[zu])}getExpected(){return`bigint`}},Jc=class extends jc{_tag=`Arrays`;isMutable;elements;rest;encodingChecks;constructor(e,t,n,r,i,a,o,s){super(r,i,a,o),this.isMutable=e,this.elements=t,this.rest=n,this.encodingChecks=s;let c=!1;for(let e=0;e<t.length;e++)if(gu(t[e]))c=!0;else if(c)throw Error(`A required element cannot follow an optional element. ts(1257)`);if(c&&n.length>1)throw Error(`A required element cannot follow an optional element. ts(1257)`);for(let e=1;e<n.length;e++)if(gu(n[e]))throw Error(`An optional element cannot follow a rest element. ts(1266)`)}getParser(e,t=e){let n=this,r,i,a=n.elements.length,o=Math.max(0,n.rest.length-1);function s(e,t){return t<a?r[t]:t>=e?i[t-e+1]:i[0]}let c=e=>{let{input:t,len:r,options:i}=e;if(n.rest.length===0&&r>a)for(let o=a;o<r;o++){let r=new as(n,t[o],i),a=new rs([o],r);if(i.errors===`all`)e.issues?e.issues.push(a):e.issues=[a];else return x(new os(n,[a],t,i))}return e.issues?x(new os(n,e.issues,t,i)):Ko(e.output)},l=(e,t)=>{let r=e.length,i={ast:n,getParser:s,input:e,len:r,tailThreshold:Math.max(a,r-o),output:new globalThis.Array(r),issues:void 0,options:t},u=n.rest.length===0?a:Math.max(r,a+o),d=t.concurrency===void 0?1:kr(t.concurrency),f=d===1?Zc(i,e,0,u):Qc(i,e,{concurrency:d,end:u});if(!f)return c(i);if(Ie(f))return Zt(f,()=>c(i));let p=!0;return hr(()=>p?(p=!1,E(f,()=>c(i))):l(e,t))};return(e,a)=>{if(e===D)return qo;try{return Array.isArray(e)?(r||(r=n.elements.map(e=>({ast:e,parser:t(e)})),i=n.rest.map(e=>({ast:e,parser:t(e)}))),l(e,a)):x(new ss(n,e,a))}catch(e){return ur(e)}}}_rebuild(e,t,n){let r=au(this.elements,e),i=au(this.rest,e);return r===this.elements&&i===this.rest&&t===this.checks&&n===this.encodingChecks?this:new Jc(this.isMutable,r,i,this.annotations,t,void 0,this.context,n)}recur(e){return this._rebuild(e,this.checks,this.encodingChecks)}flip(e){return this._rebuild(e,this.encodingChecks,this.checks)}getExpected(){return`array`}};function Yc(e,t,n,r){if(n._tag===`Failure`)return $c(e,e.ast,r,n);let i=n===Jo?t:n[gt];if(i!==D)e.output[r]=i;else{let t=e.getParser(e.tailThreshold,r);if(gu(t.ast))return;let n=new rs([r],new is(t.ast.context?.annotations));if(e.options.errors===`all`)e.issues?e.issues.push(n):e.issues=[n];else return ea(new os(e.ast,[n],e.input,e.options))}}var Xc={onItem(e,t,n){let r=n<e.len?t:D;return e.getParser(e.tailThreshold,n).parser(r,e.options)},step:Yc},Zc=rr()(Xc),Qc=Nr()(Xc),$c=(e,t,n,r)=>{if(r.cause.reasons.length===0)return r;let i=Ds(r.cause);if(i===void 0)return $i(Ui(r.cause,r=>new os(t,[new rs([n],r)],e.input,e.options)));let a=new rs([n],i);if(e.options.errors===`all`)e.issues?e.issues.push(a):e.issues=[a];else return ea(new os(t,[a],e.input,e.options))},el=`[+-]?\\d*\\.?\\d+(?:[Ee][+-]?\\d+)?`;function tl(e,t,n=Oc){let r,i;function a(t){switch(t._tag){case`String`:case`TemplateLiteral`:return(r??=Object.keys(e)).filter(e=>t.matchPart(e,n)!==void 0);case`Number`:return(r??=Object.keys(e)).filter(e=>t.matchKey(e,n)!==void 0);case`Symbol`:return(i??=Object.getOwnPropertySymbols(e)).filter(r=>Object.prototype.propertyIsEnumerable.call(e,r)&&t.matchKey(r,n)!==void 0);case`Union`:return[...new Set(t.types.flatMap(a))];default:return[]}}return a(Ou(Su(t)))}var nl=class{name;type;constructor(e,t){this.name=e,this.type=t}};function rl(e){switch(e._tag){case`String`:case`Number`:case`Symbol`:case`TemplateLiteral`:return!0;case`Union`:return e.types.every(rl);default:return!1}}function il(e){let t=Yl(e);switch(t._tag){case`String`:case`Number`:case`Symbol`:case`TemplateLiteral`:return!0;case`Union`:return t.types.every(il);default:return!1}}function al(e){return rl(e)&&il(e)}var ol=class{parameter;type;constructor(e,t){if(!al(e))throw Error(`Invalid index signature parameter ${e._tag}`);if(this.parameter=e,this.type=t,gu(t)&&!Tu(t))throw Error("Cannot use `Schema.optionalKey` with index signatures, use `Schema.optional` instead.")}},sl=class extends jc{_tag=`Objects`;propertySignatures;indexSignatures;encodingChecks;constructor(e,t,n,r,i,a,o){super(n,r,i,a),this.propertySignatures=e,this.indexSignatures=t,this.encodingChecks=o}getParser(e,t=e){let n=this,r=n.propertySignatures.length,i=n.indexSignatures.length;if(!r&&!i)return Du(n,On);let a,o,s=()=>(a||(a=n.propertySignatures.map(e=>({parser:t(e.type),name:e.name,type:e.type})),o=i?n.indexSignatures.map(n=>({is:n,parserKey:e(Ou(n.parameter)),parserValue:t(n.type)})):void 0),a),c=()=>{let e=new Set(n.propertySignatures.map(e=>typeof e.name==`number`?globalThis.String(e.name):e.name)),t=(t,i,a,o,s)=>{if(s._tag===`Failure`)return $c(t,n,i,s)??na;let c=s===Jo?o:s[gt];if(a!==D&&c!==D){if(r&&(e.has(i)||e.has(typeof a==`number`?globalThis.String(a):a)))return na;v(t.out,a,c)}return na},c=(e,r,i,a)=>{if(!a){let t=i.parserKey(r,e.options);if(!Ie(t))return E(Dn(t),t=>c(e,r,i,t));a=t}if(a._tag===`Failure`)return $c(e,n,r,a)??na;let o=a===Jo?r:a[gt],s=e.input[r],l=i.parserValue(s,e.options);return Ie(l)?t(e,r,o,s,l):E(Dn(l),n=>t(e,r,o,s,n))},l=(e,n,r)=>{let i=e.input[n],a=r.parserValue(i,e.options);return Ie(a)?t(e,n,n,i,a):E(Dn(a),r=>t(e,n,n,i,r))},u=i?Nr()({onItem:(e,[t,n])=>n.is.parameter===Vc?l(e,t,n):c(e,t,n),step:(e,t,n)=>n._tag===`Failure`?n:void 0}):void 0;return f(function*(t,d){if(t===D)return D;if(!(typeof t==`object`&&t&&!Array.isArray(t)))return yield*x(new ss(n,t,d));s();let f=t,p={},m={ast:n,input:f,out:p,issues:void 0,options:d},ee=d.errors===`all`,h=d.onExcessProperty===`error`,te=d.concurrency===void 0?1:kr(d.concurrency),g=i&&h?n.indexSignatures.map(e=>tl(f,e.parameter,d)):void 0;if(h){let r=g?new Set(e):e;if(g)for(let e of g)for(let t of e)r.add(t);let i=Reflect.ownKeys(f);for(let e=0;e<i.length;e++){let a=i[e];if(!r.has(a)&&Object.prototype.propertyIsEnumerable.call(f,a)){let e=new as(n,f[a],d),r=new rs([a],e);if(ee){m.issues?m.issues.push(r):m.issues=[r];continue}return yield*x(new os(n,[r],t,d))}}}if(r){let e=te===1?ul(m,a):dl(m,a,{concurrency:te});e&&(yield*e)}if(i&&te===1)for(let e=0;e<i;e++){let t=o[e],n=t.is.parameter===Vc?l:c,r=g?.[e]??(t.is.parameter===Vc?Object.keys(f):tl(f,t.is.parameter,d));for(let e=0;e<r.length;e++){let i=n(m,r[e],t);if(!Ie(i))yield*i;else if(i._tag===`Failure`)return yield*i}}else if(u){let e=le();for(let t=0;t<i;t++){let n=o[t],r=g?.[t]??(n.is.parameter===Vc?Object.keys(f):tl(f,n.is.parameter,d));for(let t=0;t<r.length;t++)e.push([r[t],n])}let t=u(m,e,{concurrency:te});t&&(yield*t)}return m.issues?yield*x(new os(n,m.issues,t,d)):p})};if(i)return c();let l,u=(e,t,n)=>{let r=a[t];return E(Dn(n),n=>{let i=cl(e,r,n);if(i)return i;let o=()=>Ko(e.out),s=ul(e,a.slice(t+1));return s?Zt(s,o):o()})};return(e,t)=>{if(e===D)return qo;if(t.errors===`all`||t.onExcessProperty!==void 0||t.concurrency!==void 0&&kr(t.concurrency)!==1)return(l??=c())(e,t);if(!(typeof e==`object`&&e&&!Array.isArray(e)))return x(new ss(n,e,t));let r=s(),i=e,a={},o={ast:n,input:i,out:a,issues:void 0,options:t};try{for(let e=0;e<r.length;e++){let n=r[e],s=n.name,c=wl(i,s),l=c?i[s]:D,d=n.parser(l,t);if(!Ie(d))return u(o,e,d);if(d===Jo){c&&v(a,s,l);continue}let f=cl(o,n,d);if(f)return f}}catch(e){return ur(e)}return Ko(a)}}_rebuild(e,t,n,r){let i=au(this.propertySignatures,t=>{let n=e(t.type);return n===t.type?t:new nl(t.name,n)}),a=au(this.indexSignatures,n=>{let r=t(n.parameter),i=e(n.type);return r===n.parameter&&i===n.type?n:new ol(r,i)});return i===this.propertySignatures&&a===this.indexSignatures&&n===this.checks&&r===this.encodingChecks?this:new sl(i,a,this.annotations,n,void 0,this.context,r)}flip(e){return this._rebuild(e,e,this.encodingChecks,this.checks)}recur(e,t=e){return this._rebuild(e,t,this.checks,this.encodingChecks)}getExpected(){return this.propertySignatures.length===0&&this.indexSignatures.length===0?`object | array`:`object`}};function cl(e,t,n){if(n._tag===`Failure`)return $c(e,e.ast,t.name,n);if(n===Jo)return;let r=n[gt];if(r!==D){v(e.out,t.name,r);return}if(delete e.out[t.name],!gu(t.type)){let n=new rs([t.name],new is(t.type.context?.annotations));if(e.options.errors===`all`){e.issues?e.issues.push(n):e.issues=[n];return}return ea(new os(e.ast,[n],e.input,e.options))}}var ll={onItem(e,t){if(!wl(e.input,t.name))return t.parser(D,e.options);let n=e.input[t.name];return v(e.out,t.name,n),t.parser(n,e.options)},step:cl},ul=rr()(ll),dl=Nr()(ll);function fl(e,t){return e?t?[...e,...t]:e:t}function pl(e,t,n){return new sl(Reflect.ownKeys(e).map(t=>new nl(t,e[t].ast)),[],n,t)}function ml(e){return e.ast}function hl(e,t=void 0){return new Jc(!1,e.map(e=>e.ast),[],void 0,t)}function gl(e,t,n){return new El(e.map(ml),t,void 0,n)}function _l(e){if(e.encoding)throw Error(`mutable does not support encodings`);return new Jc(!0,e.elements,e.rest,e.annotations,e.checks,void 0,e.context,e.encodingChecks)}var vl=Ln(e=>{for(;;){if(Ec(e))return Rc;let t=e.encoding;if(!t)return e.recur?.(vl,Hn)??e;if(t.some(e=>e.transformation._tag===`Middleware`&&e.transformation.decode!==Hn))return Rc;e=t[t.length-1].to}});function yl(e){switch(e._tag){case`Null`:return[`null`];case`Undefined`:return[`undefined`];case`String`:case`TemplateLiteral`:return[`string`];case`Number`:return[`number`];case`Boolean`:return[`boolean`];case`Symbol`:case`UniqueSymbol`:return[`symbol`];case`BigInt`:return[`bigint`];case`Arrays`:return[`array`];case`ObjectKeyword`:return[`object`,`array`,`function`];case`Objects`:return e.propertySignatures.length||e.indexSignatures.length?[`object`]:[`string`,`number`,`boolean`,`symbol`,`bigint`,`object`,`array`,`function`];case`Enum`:return Array.from(new Set(e.enums.map(([,e])=>typeof e)));case`Literal`:return[typeof e.literal];case`Union`:return Array.from(new Set(e.types.flatMap(yl)));default:return[`null`,`undefined`,`string`,`number`,`boolean`,`symbol`,`bigint`,`object`,`array`,`function`]}}function bl(e){switch(e._tag){default:return[];case`Declaration`:{let t=e.annotations?.[Lo];return Array.isArray(t)?t:[]}case`Objects`:return e.propertySignatures.flatMap(e=>{let t=e.type;if(!gu(t)){if(xc(t))return[{key:e.name,literal:t.literal}];if(Sc(t))return[{key:e.name,literal:t.symbol}]}return[]});case`Arrays`:return e.elements.flatMap((e,t)=>{if(!gu(e)){if(xc(e))return[{key:t,literal:e.literal}];if(Sc(e))return[{key:t,literal:e.symbol}]}return[]});case`Union`:{if(e.types.length===0)return[];let t=e.types.map(e=>bl(vl(e)));return t[0].filter(e=>t.every(t=>t.some(t=>t.key===e.key&&t.literal===e.literal)))}case`Suspend`:return bl(e.thunk())}}var xl=new WeakMap,Sl=Object.freeze([]),Cl=e=>e===null?`null`:Array.isArray(e)?`array`:typeof e,wl=(e,t)=>t===`__proto__`?Object.hasOwn(e,t):t in e;function Tl(e){let t=xl.get(e);if(t)return t;let n,r=0,i,a,o=!0,s=[];for(let t=0;t<e.length;t++){let c=e[t],l=vl(c);if(_c(l))continue;if(xc(l)||Sc(l)){a??=new Map;let e=xc(l)?l.literal:l.symbol;s[t]=e;let n=a.get(e);n||a.set(e,n=[]),n.push(t)}else o=!1;let u=bl(l);if(u.length){n??=new Map,r++;for(let{key:e,literal:r}of u){let i=n.get(e);i||n.set(e,i=[new Map,new Set]),i[1].add(t);let a=i[0].get(r);a||i[0].set(r,a=new Set),a.add(t)}}else{i??={};let e=yl(l);for(let n of e)(i[n]??=[]).push(t)}}let c={},l=e=>c[e]??=Object.freeze(i?.[e]??Sl);if(o&&a)a.forEach(Object.freeze),t=e=>a.get(e)??Sl;else if(n?.size===1&&!i){let[r,[i]]=n.entries().next().value,a=new Map;for(let[e,t]of i)a.set(e,Object.freeze(Array.from(t)));let o=Object.freeze(e.map((e,t)=>t));t=(e,t)=>{if(ii(e)){let n=wl(e,r)?e[r]:void 0;if(n!==void 0)return a.get(n)??Sl;if(t)return o}return Sl}}else if(n){let e;for(let t of n)(!e||t[1][0].size>e[1][0].size)&&t[1][1].size===r&&(e=t);t=(t,r)=>{let a=Cl(t);if(!ii(t))return l(a);let o=new Set(i?.[a]),s;if(e){let[n,[i]]=e,c=wl(t,n),u=c?t[n]:void 0;if(c&&(!r||u!==void 0)){let e=i.get(u);if(!e)return l(a);for(let t of e)o.add(t);s=n}}if(s===void 0)for(let[e,[i,a]]of n){let n=wl(t,e),s=n?t[e]:void 0;if(n&&(!r||s!==void 0)){let e=i.get(s);if(e)for(let t of e)o.add(t)}else if(r)for(let e of a)o.add(e)}for(let[e,[i,a]]of n){if(e===s)continue;let n=wl(t,e),c=n?t[e]:void 0;if(n&&(!r||c!==void 0)){let e=i.get(c);for(let t of o)a.has(t)&&!e?.has(t)&&o.delete(t)}}return Array.from(o).sort((e,t)=>e-t)}}else t=e=>{let t=l(Cl(e));return a?t.filter(t=>s[t]===void 0||s[t]===e):t};return xl.set(e,t),t}var El=class extends jc{_tag=`Union`;types;options;encodingChecks;constructor(e,t,n,r,i,a,o){super(n,r,i,a),this.types=e,this.options=t,this.encodingChecks=o}getParser(e,t){let n=this,r=t!==void 0,i=[],a=t=>i[t]??=e(n.types[t]),o;return(e,t)=>{if(e===D)return qo;let i=(o??=Tl(n.types))(e,r);if(i.length===0)return x(new us(n,[],e,t));if(i.length===1){let r=a(i[0])(e,t);return r._tag===`Success`?r:Ie(r)?Dl(n,r.cause,e,t):Ol(n,r,e,t)}return kl(n,a,i,e,t)}}_rebuild(e,t,n){let r=au(this.types,e);return r===this.types&&t===this.checks&&n===this.encodingChecks?this:new El(r,this.options,this.annotations,t,void 0,this.context,n)}recur(e){return this._rebuild(e,this.checks,this.encodingChecks)}flip(e){return this._rebuild(e,this.encodingChecks,this.checks)}matchPart(e,t){for(let n of this.types){let r=n.matchPart(e,t);if(r!==void 0)return r}}getExpected(e){let t=this.annotations?.expected;if(typeof t==`string`)return t;if(this.types.length===0)return`never`;let n=this.types.map(t=>{let n=Su(t);switch(n._tag){case`Arrays`:{let t=n.elements.filter(xc);if(t.length>0)return`${Nl(n.isMutable)}[ ${t.map(t=>e(t)+Pl(t.context?.isOptional)).join(`, `)}, ... ]`;break}case`Objects`:{let t=n.propertySignatures.filter(e=>xc(e.type));if(t.length>0)return`{ ${t.map(t=>`${Nl(t.type.context?.isMutable)}${vr(t.name)}${Pl(t.type.context?.isOptional)}: ${e(t.type)}`).join(`, `)}, ... }`;break}}return e(n)});return Array.from(new Set(n)).join(` | `)}};function Dl(e,t,n,r){let i=Ds(t);return i?ea(new us(e,[i],n,r)):$i(t)}function Ol(e,t,n,r){return Ir(t,t=>Dl(e,t,n,r))}function kl(e,t,n,r,i){let a={ast:e,parser:t,input:r,out:void 0,successes:e.options?.mode===`oneOf`?[]:void 0,issues:void 0,options:i},o=jl(a,n);if(!o)return a.out?a.out:x(new us(e,a.issues??[],r,i));if(Ie(o))return Al(o,a);let s=!0;return hr(()=>s?(s=!1,Al(o,a)):kl(e,t,n,r,i))}function Al(e,t){return Zt(e,e=>t.out===Jo?b(t.input):t.out?t.out:x(new us(t.ast,t.issues??[],t.input,t.options)))}var jl=rr()({onItem(e,t){return e.parser(t)(e.input,e.options)},step(e,t,n){if(n._tag===`Failure`){let t=Ds(n.cause);if(t===void 0)return n;e.issues?e.issues.push(t):e.issues=[t]}else{if(e.out&&e.successes)return e.successes.push(e.ast.types[t]),ea(new ds(e.ast,e.successes,e.input,e.options));if(e.out=n,e.successes)e.successes.push(e.ast.types[t]);else return na}}}),Ml=new El([new zc(`Infinity`),new zc(`-Infinity`),new zc(`NaN`)]);function Nl(e){return e?``:`readonly `}function Pl(e){return e?`?`:``}var Fl=class extends jc{_tag=`Suspend`;thunk;constructor(e,t,n,r,i){if(n)throw Error(`Cannot add checks to Suspend`);super(t,void 0,r,i);let a;this.thunk=()=>a??=e()}getParser(e){let t;return(n,r)=>(t??=e(this.thunk()))(n,r)}recur(e){return new Fl(()=>e(this.thunk()),this.annotations,void 0,void 0,this.context)}getExpected(e){return e(this.thunk())}},Il=class extends Re{_tag=`Filter`;run;annotations;aborted;constructor(e,t=void 0,n=!1){super(),this.run=e,this.annotations=t,this.aborted=n}annotate(e){return new Il(this.run,{...this.annotations,...e},this.aborted)}abort(){return new Il(this.run,this.annotations,!0)}and(e,t){return new Ll([this,e],t)}},Ll=class extends Re{_tag=`FilterGroup`;checks;annotations;constructor(e,t=void 0){super(),this.checks=e,this.annotations=t}annotate(e){return new Ll(this.checks,{...this.annotations,...e})}and(e,t){return new Ll([this,e],t)}};function Rl(e,t,n=!1){return new Il((t,n,r)=>ms(n,e(t,n,r),t,r),t,n)}function zl(e,t){return new Il((t,n,r)=>e(t)?void 0:new cs(void 0,t,r),t,!0)}function Bl(e){return Rl(e=>globalThis.Number.isFinite(e),{expected:`a finite number`,representation:{id:`effect/schema/isFinite`,payload:null},toJsonSchema:()=>({type:`number`}),toCode:()=>({runtime:`Schema.isFinite()`}),arbitraryConstraint:{number:`finite`},...e})}var Vl=Ql(Wc,[Bl()]),Hl=new Dc(new El([Vl,Ml]),new tc(Gs(),Rs(e=>globalThis.Number.isFinite(e)?e:globalThis.String(e))));function Ul(e,t){let n=new globalThis.RegExp(e),r={source:n.source,flags:n.flags};return Rl(e=>(n.lastIndex=0,n.test(e)),{expected:`a string matching the RegExp ${r.source}`,representation:{id:`effect/schema/isPattern`,payload:r},toJsonSchema:()=>[{},!0],arbitraryConstraint:{patterns:[r]},...t})}var Wl=new WeakMap;function Gl(e,t){let n=Object.assign(Object.create(Object.getPrototypeOf(e)),e,t);return Reflect.ownKeys(t).every(e=>e===`context`||e===`encoding`)&&Wl.set(n,Kl(e)),n}function Kl(e){let t=Wl.get(e);if(t!==void 0)return t;if(e.encoding===void 0)return e;let n=Object.assign(Object.create(Object.getPrototypeOf(e)),e,{encoding:void 0});return Wl.set(e,n),n}function ql(e,t){return e.encoding===t?e:Gl(e,{encoding:t})}function Jl(e,t){if(e.context===t)return e;let n=Kl(e);return n.context===t&&n.encoding===e.encoding?n:Gl(e,{context:t})}function Yl(e){return e.encoding?Yl(e.encoding[e.encoding.length-1].to):e}function Xl(e,t){if(e.checks){let n=e.checks[e.checks.length-1];return Zl(e,Qe(e.checks.slice(0,-1),n.annotate(t)))}return Gl(e,{annotations:{...e.annotations,...t}})}function Zl(e,t){if(e._tag===`Suspend`&&t)throw Error(`Cannot add checks to Suspend`);return e.checks===t?e:Gl(e,{checks:t})}function Ql(e,t){return Zl(e,fl(e.checks,t))}function $l(e,t){let n=t(e.to);return n===e.to?e:new Dc(n,e.transformation)}function eu(e,t){let n=e,r=n[n.length-1],i=$l(r,t);return i===r?e:Qe(e.slice(0,e.length-1),i)}function tu(e){return t=>t.encoding?ql(t,eu(t.encoding,e)):t}function nu(e,t){return tu(e=>Jl(e,t))(e)}function ru(e,t){function n(r){if(r.encoding){let e=r.encoding[r.encoding.length-1];return t?.stopAt?.(e)?r:ql(r,eu(r.encoding,n))}return e(r)}return Ln(n)}function iu(e,t,n){let r=new Dc(e,t);return ql(n,n.encoding?[...n.encoding,r]:[r])}function au(e,t){let n;for(let r=0;r<e.length;r++){let i=e[r],a=t(i);if(n)n[r]=a;else if(a!==i){n=Array(e.length);for(let t=0;t<r;t++)n[t]=e[t];n[r]=a}}return n??e}function ou(e,t){return Jl(e,e.context?new kc(e.context.isOptional,e.context.isMutable,e.context.constructorDefault,{...e.context.annotations,...t}):new kc(!1,!1,void 0,t))}var su=Ln(e=>cu(Jl(e,e.context?e.context.isOptional===!1?new kc(!0,e.context.isMutable,e.context.constructorDefault,e.context.annotations):e.context:new kc(!0,!1)))),cu=tu(su),lu=i(e=>su(new El([e,Ic]))),uu=Ln(e=>du(Jl(e,e.context?e.context.isMutable===!1?new kc(e.context.isOptional,!0,e.context.constructorDefault,e.context.annotations):e.context:new kc(!1,!0)))),du=tu(uu);function fu(e,t){return Jl(e,e.context?new kc(e.context.isOptional,e.context.isMutable,t,e.context.annotations):new kc(!1,!1,t))}function pu(e,t,n){return iu(e,n,t)}function mu(e){let t=[],n=[];function r(e){switch(e._tag){case`Literal`:Qt(e.literal)&&!t.includes(e.literal)&&t.push(e.literal);return;case`UniqueSymbol`:t.includes(e.symbol)||t.push(e.symbol);return;case`Never`:return;case`Union`:for(let t=0;t<e.types.length;t++)r(e.types[t]);return;default:n.push(e)}}return r(e),{literals:t,parameters:n}}function hu(e,t){let{literals:n,parameters:r}=mu(e);return new sl(n.map(e=>new nl(e,t)),r.map(e=>new ol(e,t)))}function gu(e){return e.context?.isOptional??!1}function _u(e){return e.context?.isMutable??!1}function vu(e){return e.annotations?.[`~structural`]===!0||e._tag===`FilterGroup`&&e.checks.every(vu)}function yu(e){function t(e){return vu(e)?[e]:e._tag===`FilterGroup`?e.checks.flatMap(t):[]}let n=e.flatMap(t);return Pe(n)?n:void 0}function bu(e){let t=!0;function n(e){return t=t&&!e.encoding&&!Ec(e),t&&`recur`in e&&e.recur(n),e}return`recur`in e&&e.recur(n),t}var xu=Ln(e=>{let t=Kl(e);if(t!==e){let n=xu(t);return n===t&&e.encoding===void 0?e:Jl(n,e.context)}let n=`recur`in e?e.recur(xu):e;if(`encodingChecks`in n&&n.encodingChecks){let t=bu(e)?n.encodingChecks:Cc(n)||wc(n)||mc(n)&&n.typeParameters.length>0?yu(n.encodingChecks):void 0;return Gl(n,{encodingChecks:void 0,checks:fl(n.checks,t)})}return n}),Su=Ln(e=>xu(wu(e)));function Cu(e,t){let n=t,r=n.length,i=n[r-1],a=[new Dc(wu(ql(e,void 0)),n[0].transformation.flip())];for(let e=1;e<r;e++)a.unshift(new Dc(wu(n[e-1].to),n[e].transformation.flip()));let o=wu(i.to);return o.encoding?ql(o,[...o.encoding,...a]):ql(o,a)}var wu=i(e=>{if(e.encoding)return Cu(e,e.encoding);let t=Kl(e);if(t!==e){let n=wu(t);return n===t?e:Jl(n,e.context)}return`flip`in e?e.flip(wu):`recur`in e?e.recur(wu):e});function Tu(e){switch(e._tag){case`Undefined`:return!0;case`Union`:return e.types.some(Tu);default:return!1}}function Eu(e,t){let n=t===0?Jo:Ko(t);return(r,i)=>r===D?qo:r===t?n:x(new ss(e,r,i))}function Du(e,t){return(n,r)=>n===D?qo:t(n)?Jo:x(new ss(e,n,r))}var Ou=ru(e=>{switch(e._tag){default:return e;case`Number`:return e.toCodecStringTree();case`Union`:return e.recur(Ou)}}),ku=ru(e=>{switch(e._tag){default:return e;case`Symbol`:case`UniqueSymbol`:return e.toCodecStringTree();case`Union`:return e.recur(ku)}}),Au=`[\\s\\S]*?`,ju=new globalThis.RegExp(`^${el}$`),Mu=new globalThis.RegExp(`^(?:${el}|Infinity|-Infinity|NaN)$`);function Nu(e){return Ul(ju,{expected:`a string representing a finite number`,representation:{id:`effect/schema/isStringFinite`,payload:null},toJsonSchema:()=>({pattern:ju.source}),...e})}var Pu=Ql(Vc,[Nu()]),Fu=new Dc(Pu,cc),Iu=new Dc(new El([Pu,Ml]),cc),Lu=new globalThis.RegExp(`^-?\\d+$`);function Ru(e){return Ul(Lu,{expected:`a string representing a bigint`,representation:{id:`effect/schema/isStringBigInt`,payload:null},toJsonSchema:()=>({pattern:Lu.source}),...e})}var zu=new Dc(Ql(Vc,[Ru({expected:`a string representing a bigint`})]),lc),Bu=new globalThis.RegExp(`^Symbol\\(([\\s\\S]*)\\)$`),Vu=new Dc(Ql(Vc,[Hu()]),new tc(Rs(e=>globalThis.Symbol.for(Bu.exec(e)[1])),zs((e,t)=>globalThis.Symbol.keyFor(e)===void 0?x(new ls({message:`cannot serialize to string, Symbol is not registered`},e,t)):b(globalThis.String(e)))));function Hu(e){return Ul(Bu,{expected:`a string representing a symbol`,representation:{id:`effect/schema/isStringSymbol`,payload:null},toJsonSchema:()=>({pattern:Bu.source}),...e})}function Uu(e,t,n,r,i){for(let a=0;a<e.length;a++){let o=e[a];if(o._tag===`FilterGroup`){if(n=Uu(o.checks,t,n,r,i),n&&(i.errors!==`all`||n[n.length-1].filter.aborted))return n}else{let e=o.run(t,r,i);if(e){let r=new ts(o,e,t,i);if(n?n.push(r):n=[r],i.errors!==`all`||o.aborted)return n}}}return n}function Wu(e){if(!mc(e))return;let t=e.annotations?.[Ro];return fr(t)?t(e.typeParameters):void 0}var Gu=No,Ku=Ho,qu=Uo;function Ju(e){return e===null||typeof e==`string`||typeof e==`boolean`||typeof e==`number`&&globalThis.Number.isFinite(e)}function Yu(e){return e===void 0||typeof e==`string`}function Xu(e,t){let n=new WeakMap,r=[];outer:for(;;){if(typeof e!=`object`||!e){if(!t(e))return!1}else{let t=e,i=n.get(t);if(i===!1)return!1;if(i===void 0){let e=Array.isArray(t);if(!e){let e=Object.getPrototypeOf(t);if(e!==null&&e!==Object.prototype&&Object.getPrototypeOf(e)!==null)return!1}n.set(t,!1),r.push({value:t,keys:e?t.length:Object.keys(t),index:0})}}for(;r.length>0;){let t=r[r.length-1],i=t.keys;if(typeof i==`number`){if(t.index<i){e=t.value[t.index++];continue outer}}else if(t.index<i.length){e=t.value[i[t.index++]];continue outer}n.set(t.value,!0),r.pop()}return!0}}function Zu(e){return Xu(e,Ju)}var Qu=new Mc([],()=>(e,t,n)=>Zu(e)?Jo:x(new ss(t,e,n)),{representation:{id:`effect/schema/Json`,payload:null},expected:`JSON value`,toCodecJson:()=>void 0,toCodecStringTree:()=>nd}),$u=new Dc(Qu,sc()),ed=new Dc(new El([new Jc(!1,[],[Qu]),new sl([],[new ol(Vc,Qu)])]),sc());function td(e){return Xu(e,Yu)}var nd=new Dc(new Mc([],()=>(e,t,n)=>td(e)?Jo:x(new ss(t,e,n)),{expected:`StringTree`,toCodecStringTree:()=>void 0}),sc()),rd=(e,t,n)=>e===Jo?n(t):Zt(e,n);function id(e){if(e._tag===`Middleware`)return(t,n,r)=>ad(t===Jo?e.decode(Ko(Yo(n)),r):e.decode(Ne(t,Yo),r));let t=e.decode;switch(t._tag){case`Passthrough`:return(e,t)=>e===Jo?Ko(t):e;case`Transform`:{let e=e=>e===D?qo:Ko(t.transform(e));return(t,n)=>rd(t,n,e)}case`TransformOptional`:{let e=e=>Xo(t.transform(Yo(e)));return(t,n)=>rd(t,n,e)}case`TransformEffect`:return(e,n,r)=>rd(e,n,e=>e===D?qo:t.transform(e,r));case`TransformOptionalEffect`:return(e,n,r)=>rd(e,n,e=>ad(t.transform(Yo(e),r)))}}var ad=e=>Zt(e,Xo),od=(e,t,n,r)=>Ir(r,r=>Vr(()=>Ui(r,r=>new ns(e,r,t,n))));function sd(e,t){let n=id(e.link.transformation),r;return(i,a)=>{if(i===D)return qo;if(e.isConstructed(i))return Jo;let o=(r??=t(e.link.to))(i,a);return n(o,i,a)}}function cd(e,t){let n=e.context.constructorDefault;return(r,i)=>{if(r!==D&&r!==void 0)return t(r,i);let a=n;if(Ie(a)&&a._tag===`Success`){let e=t(a[gt],i);return e===Jo?a:e}return Zt(od(e,r,i,a),e=>{let n=t(e,i);return n===Jo?Ko(e):n})}}function ld(e,t){let n=t(e);return e.context?.constructorDefault===void 0?n:cd(e,n)}function ud(e,t,n,r,i){if(e._tag===`Declaration`)for(let n of e.typeParameters)t(n);let a=n?Wu(e):void 0,o=a?sd(a,t):r??e.getParser(t,n),s=e.checks,c=e.encoding,l=c?.map(e=>id(e.transformation)),u=e.encodingChecks;if(!c&&!s&&!u)return o;let d,f=(t,n)=>{let r=o(t,n);if(u&&!n.disableChecks){if(Ie(r)){if(r._tag===`Success`){let i=r===Jo?t:r[gt];if(t!==D&&i!==D){let i=Uu(u,t,void 0,e,n);i&&(r=x(new os(e,i,t,n)))}}}else r=E(r,r=>{if(t!==D&&r!==D){let r=Uu(u,t,void 0,e,n);if(r)return x(new os(e,r,t,n))}return b(r)})}if(s&&!n.disableChecks){if(Ie(r)){if(r._tag===`Success`){let i=r===Jo?t:r[gt];if(i===D)return r;let a=Uu(s,i,void 0,e,n);a&&(r=x(new os(e,a,i,n)))}}else r=E(r,t=>{if(t!==D){let r=Uu(s,t,void 0,e,n);if(r)return x(new os(e,r,t,n))}return b(t)})}return r},p=i===void 0?f:i(f);return c?(n,r)=>{let i=d??=c.map(e=>t(e.to)),a=n,o=i[i.length-1](n,r);for(let e=c.length-1;e>=0;e--)if(o=l[e](o,a,r),e!==0){let t=i[e-1];o._tag===`Success`?(a=o[gt],o=t(a,r)):o=Zt(o,e=>{let n=t(e,r);return n===Jo?Ko(e):n})}if(o._tag===`Success`){let e=o[gt],t=p(e,r);return t===Jo?o:t}return o=od(e,n,r,o),Zt(o,e=>{let t=p(e,r);return t===Jo?Ko(e):t})}:p}var dd=Symbol(),fd=new WeakMap,pd=e=>_d(e).parser,md=e=>_d(e).makeEffect,hd=e=>ld(e,md),gd=class{ast;constructor(e){this.ast=e}get decodeEffect(){return this.cachedDecodeEffect??=ud(this.ast,pd)}get parser(){return this.decodeEffect}get makeEffect(){return this.cachedMakeEffect??=ud(this.ast,md,hd)}};function _d(e){let t=fd.get(e);if(t!==void 0)return t;let n=new gd(e);return fd.set(e,n),n}function vd(e){let t=e.ast,n;return(e,r)=>(n??=Fd(Hd,xu(t)))(e,r?.disableChecks?r?.parseOptions?{...r.parseOptions,disableChecks:!0}:{disableChecks:!0}:r?.parseOptions)}function yd(e){let t=vd(e);return(e,n)=>{let r=lr(t(e,n));return ra(r)?Br(r.value):(Os(r.cause,`Option adapter can only return none for schema issues`),on())}}function bd(e){return Bd(xu(e.ast))}function xd(e){return Cd(e.ast)}function Sd(e){{let t=Id(Nd(e));return e=>{let n=t(e,Oc);return ra(n)?!0:(Os(n.cause,`Type guard adapter can only return false for schema issues`),!1)}}}function Cd(e){let t=xu(e),n=e=>(n=Sd(t),n(e));return e=>n(e)}function wd(e,t){let n=Nd(e.ast);return t===void 0?n:(e,r)=>n(e,jd(t,r))}function Td(e,t){return Id(wd(e,t))}function Ed(e,t){return Ld(wd(e,t))}function Dd(e,t){return Rd(wd(e,t))}function Od(e,t){let n=Nd(wu(e.ast));return t===void 0?n:(e,r)=>n(e,jd(t,r))}function kd(e,t){return Id(Od(e,t))}function Ad(e,t){return Rd(Od(e,t))}var jd=(e,t)=>t?{...e,...t}:e,Md=e=>e===D?x(new cs):b(e);function Nd(e){return Fd(Vd,e)}function Pd(e,t){return e===Jo?b(t):Ie(e)?e[gt]===D?Md(D):e:Zt(e,Md)}function Fd(e,t){let n;return(r,i)=>{let a=(n??=e(t))(r,i??Oc);return a===Jo?b(r):Ie(a)?a[gt]===D?Md(D):a:Zt(a,Md)}}function Id(e){return(t,n)=>lr(e(t,n))}function Ld(e){let t=Id(e);return(e,n)=>{let r=t(e,n);return ra(r)?Br(r.value):(Os(r.cause,`Option adapter can only return none for schema issues`),on())}}function Rd(e){let t=Id(e);return(e,n)=>{let r=t(e,n);return ra(r)?kt(r.value):_e(Os(r.cause,`Result adapter can only return schema issues`))}}function zd(e,t){let n=lr(e);if(ra(n))return n.value;let r=Os(n.cause,t);throw Error(`Schema validation failed`,{cause:r})}function Bd(e){let t,n;return(r,i)=>{t??=_d(e);let a=i?.disableChecks?i.parseOptions?{...i.parseOptions,disableChecks:!0}:{disableChecks:!0}:i?.parseOptions??Oc,o=t.make;if(o!==void 0&&r!==D){let e;try{e=o(r,a)}catch(e){throw Os(Vi(e),`Constructor adapter can only throw schema issues`),e}if(e!==dd&&e!==D)return e}return zd(Pd((n??=t.makeEffect)(r,a),r),`Constructor adapter can only throw schema issues`)}}var Vd=e=>_d(e).parser,Hd=e=>_d(e).makeEffect,Ud=`~effect/Schema/Schema`,Wd=Symbol(),Gd={[Ud]:Ud,get make(){let e=bd(this);return Object.defineProperty(this,"make",{value:e,enumerable:!0}),e},get makeEffect(){let e=vd(this);return Object.defineProperty(this,"makeEffect",{value:e,enumerable:!0}),e},get makeOption(){let e=yd(this);return Object.defineProperty(this,"makeOption",{value:e,enumerable:!0}),e},pipe(){return Ze(this,arguments)},annotate(e){return this.rebuild(Xl(this.ast,e))},annotateKey(e){return this.rebuild(ou(this.ast,e))},check(...e){return this.rebuild(Ql(this.ast,e))},rebuild(e){return Kd(e,this[Wd])}};function Kd(e,t){function n(){}let r=Object.setPrototypeOf(n,Gd);return t&&(Object.hasOwn(t,`name`)||Object.hasOwn(t,`length`)||Object.hasOwn(t,`__proto__`))?Object.defineProperties(r,Object.getOwnPropertyDescriptors({...t})):Object.assign(r,t),r[Wd]=t,r.ast=e,r}function qd(e){return e.replace(/~/g,`~0`).replace(/\//g,`~1`)}function Jd(e){return e.replace(/~1/g,`/`).replace(/~0/g,`~`)}function Yd(e){return encodeURI(qd(e)).replace(/#/g,`%23`)}function Xd(e){if(e.length===0||e===`#`)return``;if(!e.startsWith(`#`))return;let t=e.slice(1);try{if(encodeURI(t).replace(/%25/g,`%`).replace(/#/g,`%23`)!==t)return;let e=decodeURIComponent(t);return e.startsWith(`/`)&&!/~(?:[^01]|$)/.test(e)?e:void 0}catch{return}}function Zd(e){let t=Xd(e);return t===void 0?void 0:t.length===0?[]:t.slice(1).split(`/`).map(Jd)}function Qd(e){return e.reduce((e,t)=>`${e}/${Yd(t)}`,`#`)}var $d=`http://json-schema.org/draft-07/schema#`;function ef(e,t){return e===t||e===(t.endsWith(`#`)?t.slice(0,-1):`${t}#`)}function tf(e){return{dialect:`draft-07`,...mf(e,Ef)}}function nf(e,t){return n(e,!1,!0);function n(e,r,i=!1){if(!Hr(e))return e;let a=r||!i&&pf(e.$id),o={};for(let t of Object.keys(e)){let r=e[t],i=r;switch(t){case`$defs`:case`properties`:case`patternProperties`:case`dependentSchemas`:i=of(r,e=>n(e,a))??r;break;case`allOf`:case`anyOf`:case`oneOf`:case`prefixItems`:i=Array.isArray(r)?r.map(e=>n(e,a)):r;break;case`not`:case`additionalProperties`:case`propertyNames`:case`unevaluatedProperties`:case`items`:case`contains`:case`unevaluatedItems`:case`if`:case`then`:case`else`:case`contentSchema`:i=n(r,a)}v(o,t,i)}return t(o,a),o}}function rf(e,t){return nf(e,e=>{af(e,t)})}function af(e,t){typeof e.$ref==`string`&&v(e,`$ref`,t(e.$ref,`$ref`)),typeof e.$dynamicRef==`string`&&v(e,`$dynamicRef`,t(e.$dynamicRef,`$dynamicRef`))}function of(e,t){if(!Hr(e))return;let n={};for(let r of Object.keys(e))v(n,r,t(e[r],r));return n}function sf(e,t,n){let r=new Map,i=[],a=cf;function o(e,n=[],r=[]){return n.length===0&&t?.trackIds&&(a=uf(Hr(e)?u(e):void 0,cf)??cf),l(e,n,r,{sourceRoot:[],targetRoot:[],uri:a})}function s(){for(let[e,t,n]of i){let i=t,a=lf(t,n);if(a!==void 0){let e=Zd(a.hash);if(a.hash=``,e!==void 0){let n=r.get(ff(a.href,e));n!==void 0&&(i=df(t,n))}}v(e,`$ref`,i)}}let c=n(o);return s(),c;function l(n,r,a,o){if(typeof n==`boolean`)return d(r,a,o),t?.booleanAdapter?.(n)??n;if(!Hr(n))return n;let s=o,c=u(n);if(r.length>0&&t?.trackIds&&pf(c)){let e=uf(c,o.uri);e!==void 0&&(s={parent:o,sourceRoot:r,targetRoot:a,uri:e})}d(r,a,s);let f=s.uri;return e(n,{isDocumentRoot:r.length===0,schema(e,t,n=t){return l(e,[...r,t],[...a,n],s)},schemaAt(e,t,n){return l(e,[...r,...t],[...a,...n],s)},schemaArray(e,t,n=t){return Array.isArray(e)?e.map((e,i)=>l(e,[...r,t,String(i)],[...a,n,String(i)],s)):e},schemaMap(e,t,n=t){return Hr(e)?of(e,(e,i)=>l(e,[...r,t,i],[...a,n,i],s)):e},reference(e,t){typeof t==`string`?i.push([e,t,f]):v(e,`$ref`,t)}})}function u(e){return t?.ignoreRefSiblings===!0&&typeof e.$ref==`string`?void 0:e.$id}function d(e,t,n){n.parent!==void 0&&d(e,t,n.parent),r.set(ff(n.uri,e.slice(n.sourceRoot.length)),t.slice(n.targetRoot.length))}}var cf=`https://effect.invalid/.json-schema/`;function lf(e,t){return URL.canParse(e,t)?new URL(e,t):void 0}function uf(e,t){if(typeof e!=`string`)return;let n=lf(e,t);if(n!==void 0)return n.hash=``,n.href}function df(e,t){let n=e.indexOf(`#`);return n===-1&&t.length===0?e:`${n===-1?e:e.slice(0,n)}${Qd(t)}`}function ff(e,t){return`${e}\u0000${JSON.stringify(t)}`}function pf(e){return typeof e==`string`&&e.length>0&&e[0]!==`#`}function mf(e,t,n){return sf(t,{...n,trackIds:!0},t=>({schema:t(e.schema),definitions:of(e.definitions,(e,n)=>t(e,[`$defs`,n],[`definitions`,n]))}))}var hf=new Set([`properties`,`patternProperties`]),gf=new Set([`allOf`,`anyOf`,`oneOf`]),_f=new Set([`not`,`additionalProperties`,`propertyNames`,`contains`,`if`,`then`,`else`,`contentSchema`]);function vf(e,t,n,r,i,a=hf){let o;if(a.has(t))o=r.schemaMap(n,t);else if(gf.has(t))o=r.schemaArray(n,t);else if(i.has(t))o=r.schema(n,t);else return!1;return v(e,t,o),!0}var yf=[`$anchor`,`$defs`,`$dynamicAnchor`,`$dynamicRef`,`$vocabulary`,`contentSchema`,`dependentRequired`,`dependentSchemas`,`maxContains`,`minContains`,`prefixItems`,`unevaluatedItems`,`unevaluatedProperties`];[...yf],[...yf];var bf=/^[A-Za-z_][-A-Za-z0-9._]*$/,xf=/^[A-Za-z][-A-Za-z0-9._:]*$/;function Sf(e,t,n){throw Error(`Cannot convert JSON Schema keyword "${e}" to ${t}: ${n}`)}function Cf(e,t,n,r){for(let i of t)Object.hasOwn(e,i)&&Sf(i,n,`it is not active in ${r} but would become active in the target`)}var wf=[`additionalItems`,`definitions`,`dependencies`];function Tf(e,t,n,r,i){n.isDocumentRoot?v(e,`$schema`,ef(t,`https://json-schema.org/draft/2020-12/schema`)?r:t):ef(t,`https://json-schema.org/draft/2020-12/schema`)||Sf(`$schema`,i,`an embedded resource cannot declare a different dialect`)}function Ef(e,t){Cf(e,wf,`Draft-07`,`Draft 2020-12`);let n={},r,i,a;for(let o of Object.keys(e)){let s=e[o];if(!vf(n,o,s,t,_f))switch(o){case`$ref`:r=s;break;case`$schema`:Tf(n,s,t,$d,`Draft-07`);break;case`$id`:case`$anchor`:break;case`$defs`:v(n,`definitions`,t.schemaMap(s,o,`definitions`));break;case`prefixItems`:i=s;break;case`items`:a=s;break;case`dependentRequired`:case`dependentSchemas`:case`minContains`:case`maxContains`:break;case`$dynamicRef`:case`$dynamicAnchor`:case`$vocabulary`:case`unevaluatedProperties`:case`unevaluatedItems`:Sf(o,`Draft-07`,`the target dialect has no equivalent`);case`required`:if(Array.isArray(s)&&s.length===0)break;v(n,o,s);break;default:v(n,o,s)}}if(Df(n,i,a,t),Object.hasOwn(e,`contains`)){let t=e.minContains,r=e.maxContains;(t!==void 0&&t!==1||r!==void 0)&&Sf(`minContains/maxContains`,`Draft-07`,`contains cardinality cannot be represented`),Object.hasOwn(e,`minContains`)&&v(n,`minContains`,t)}else Object.hasOwn(e,`minContains`)&&v(n,`minContains`,e.minContains),Object.hasOwn(e,`maxContains`)&&v(n,`maxContains`,e.maxContains);return kf(e,n,t,`draft-07`),jf(e,n,`$id`,`Draft-07`),Of(n,r,t),n}function Df(e,t,n,r){if(t===void 0){n!==void 0&&v(e,`items`,r.schema(n,`items`));return}v(e,`items`,r.schemaArray(t,`prefixItems`,`items`)),n!==void 0&&v(e,`additionalItems`,r.schema(n,`items`,`additionalItems`))}function Of(e,t,n){if(t!==void 0){if(typeof t==`string`&&Object.keys(e).length>0){let r={};n.reference(r,t),Af(e,r)}else n.reference(e,t)}}function kf(e,t,n,r){let i=Hr(e.dependentRequired)?e.dependentRequired:void 0,a=Hr(e.dependentSchemas)?e.dependentSchemas:void 0;if(i===void 0&&a===void 0)return;let o={},s=new Set([...Object.keys(i??{}),...Object.keys(a??{})]);for(let e of s){let t=i?.[e],s=a?.[e],c=r===`draft-04`&&Array.isArray(t)&&t.length===0;s===void 0?c||v(o,e,t):t===void 0||c?v(o,e,n.schemaAt(s,[`dependentSchemas`,e],[`dependencies`,e])):v(o,e,{allOf:[n.schemaAt(s,[`dependentSchemas`,e],[`dependencies`,e,`allOf`,`0`]),{required:t}]})}Object.keys(o).length>0&&v(t,`dependencies`,o)}function Af(e,t){Array.isArray(e.allOf)?e.allOf.push(t):v(e,`allOf`,[t])}function jf(e,t,n,r){let i=e.$id,a=e.$anchor;if(a===void 0){i!==void 0&&v(t,n,i);return}(typeof a!=`string`||!bf.test(a))&&Sf(`$anchor`,r,`the anchor is not valid`),xf.test(a)||Sf(`$anchor`,r,`the anchor cannot be represented as a plain-name fragment identifier`),i===void 0?v(t,n,`#${a}`):Sf(`$anchor`,r,`it cannot be combined with the schema $id`)}function Mf(e){return Kd(Nf(e.ast),{schema:e})}var Nf=ru(e=>{let t=Rf(e,Nf),n=e.context;return t===e||n===void 0?t:nu(t,Pf(n))});function Pf(e){return e.constructorDefault===void 0?e:new kc(e.isOptional,e.isMutable,void 0,e.annotations)}function Ff(e){if(e.propertySignatures.some(e=>typeof e.name!=`string`))throw new globalThis.Error(`Objects property names must be strings`,{cause:e})}function If(e){return t=>{let n=[...t].sort((t,n)=>e(Su(t))-e(Su(n)));return n.some((e,n)=>e!==t[n])?n:t}}var Lf=If(e=>{switch(e._tag){case`BigInt`:case`Symbol`:case`UniqueSymbol`:return 0;default:return 1}});function Rf(e,t){switch(e._tag){case`Declaration`:{let n=e.annotations?.toCodecJson??e.annotations?.toCodec;if(!fr(n))return ql(e,[$u]);let r=n(e.typeParameters.map(e=>Kd(Su(e))));return r===void 0?e:ql(e,[$l(r,t)])}case`Unknown`:return ql(e,[$u]);case`ObjectKeyword`:return ql(e,[ed]);case`Undefined`:case`Void`:case`Literal`:case`Number`:return e.toCodecJson();case`UniqueSymbol`:case`Symbol`:case`BigInt`:return e.toCodecStringTree();case`Objects`:return Ff(e),e.recur(t,ku);case`Union`:{let n=Lf(e.types);return n===e.types?e.recur(t):new El(n,e.options,e.annotations,e.checks,e.encoding,e.context,e.encodingChecks).recur(t)}case`Arrays`:case`Suspend`:return e.recur(t)}return e}globalThis.RegExp;var zf=e=>e.replace(/[/\\^$*+?.()|[\]{}]/g,`\\$&`);function Bf(e,t){return t.length>0&&(e+=`\n at ${je(t)}`),Error(e)}function Vf(e){return`#/$defs/${Yd(e)}`}var Hf=new Set([...Go,Io,...zo]);function Uf(e,t){if(e===void 0)return;let n={},r=e.title;typeof r==`string`&&(n.title=r);let i=e.description,a=e.expected;typeof i==`string`?n.description=i:t?.generateDescriptions===!0&&typeof a==`string`&&(n.description=a);let o=e.default;Zu(o)&&(n.default=o);let s=e.examples;Array.isArray(s)&&Zu(s)&&(n.examples=s);let c=e.readOnly;typeof c==`boolean`&&(n.readOnly=c);let l=e.writeOnly;typeof l==`boolean`&&(n.writeOnly=l);let u=e.format;typeof u==`string`&&(n.format=u);let d=e.contentEncoding;typeof d==`string`&&(n.contentEncoding=d);let f=e.contentMediaType;typeof f==`string`&&(n.contentMediaType=f);let p=e.contentSchema;if(Zu(p)&&(n.contentSchema=p),t?.includeAnnotationKey!==void 0)for(let[r,i]of Object.entries(e))Hf.has(r)||!t.includeAnnotationKey(r)||Zu(i)&&v(n,r,i);return Object.keys(n).length===0?void 0:n}function Wf(e){let t=e.type===`number`||e.type===`integer`?e.type:void 0,n=e;if(t!==void 0&&(n={...e},delete n.type),Array.isArray(n.allOf)){let e=[],r=!1;for(let i of n.allOf){let n=Wf(i);n.type!==void 0&&(r=!0,(t===void 0||n.type===`integer`)&&(t=n.type)),Object.keys(n.schema).length>0&&e.push(n.schema)}if(r){let{allOf:t,...r}=n;n=e.length===0?r:{...r,allOf:e}}}return{type:t,schema:n}}function Gf(e){if(!Array.isArray(e.anyOf)||e.anyOf.length!==2||e.anyOf[0]?.type!==`number`)return!1;let t=e.anyOf[1];return t?.type===`string`&&Array.isArray(t.enum)&&t.enum.length===3&&t.enum.includes(`NaN`)&&t.enum.includes(`Infinity`)&&t.enum.includes(`-Infinity`)}var Kf=`|type|format|pattern|multipleOf|minimum|maximum|exclusiveMinimum|exclusiveMaximum|minLength|maxLength|minItems|maxItems|uniqueItems|minProperties|maxProperties|propertyNames|`;function qf(e,t){return Object.keys(e).every(e=>t.includes(`|${e}|`))}function Jf(e,t){return typeof e.$ref!=`string`&&t.every(t=>!Object.hasOwn(e,t))}var Yf=`|title|description|default|examples|readOnly|writeOnly|`,Xf=Kf+Yf;function Zf(e,t,n){if(Object.keys(e).length===0)return t;let r=Object.keys(t);if(r.length===0)return e;let i=e.type===`number`||e.type===`integer`?e.type:void 0,a=Gf(e);if(i!==void 0||a){let r=Wf(t);if(r.type!==void 0){let t=i===`integer`||r.type===`integer`?`integer`:`number`,o={...e,type:t};a&&delete o.anyOf;let s=Object.keys(r.schema);return s.length===0?o:qf(r.schema,Yf)&&Jf(o,s)?{...o,...r.schema}:Zf(o,r.schema,n)}}if(n&&Jf(e,r))return{...e,...t};let o=Array.isArray(t.allOf)&&r.length===1?t.allOf:[t];return Array.isArray(e.allOf)?{...e,allOf:[...e.allOf,...o]}:typeof e.$ref==`string`?{allOf:[e,...o]}:{...e,allOf:o}}function Qf(e,t=new Set){return typeof e==`boolean`?e:t.has(e)?!0:(t.add(e),e.every(e=>Qf(e,t)))}function $f(e){return Array.isArray(e)}function ep(e,t,n,r){let i=new Map,a=new Map,o=new WeakMap,s=new Map,c=new Map,u=Object.keys(n);for(let e of u)ee(e,[`references`,e]);let d=l(e,(e,n)=>ne(e,t[n],[]));for(let[e,t]of s.values())if(!Qf(e))for(let e of t)Array.isArray(e.oneOf)&&(e.anyOf=e.oneOf,delete e.oneOf);for(let e of u){let t=n[e],r=te(t);if(r===void 0)continue;let o=i.get(e)[0],s=c.get(r),l=s?.find(e=>mn(i.get(e)[0],o));l===void 0?s===void 0?c.set(r,[e]):s.push(e):a.set(e,l)}let f=l(d,h),p={};for(let e of u)a.has(e)||v(p,e,h(i.get(e)[0]));return{dialect:`draft-2020-12`,schemas:f,definitions:p};function m(e){return Array.isArray(e.oneOf)&&s.get(e.oneOf)?.[1].push(e),e}function ee(e,t){if(!Object.hasOwn(n,e))throw Bf(`Invalid reference ${e}`,[...t,`$ref`]);let r=i.get(e);if(r!==void 0)return r;let a=[{},[]];return i.set(e,a),a[0]=ne(n[e],[`references`,e],a[1]),a}function h(e){return rf(e,e=>{let t=Xd(e);if(t===void 0){if(/^#(?:\/|%2f)/i.test(e))throw Error(`Invalid JSON Pointer URI fragment ${JSON.stringify(e)}`);return e}if(!t.startsWith(`/$defs/`))return e;let n=t.indexOf(`/`,7),r=a.get(Jd(t.slice(7,n<0?void 0:n)));return r===void 0?e:e.replace(/^#(?:\/|%2f).*?(?:\/|%2f).*?(?=\/|%2f|$)/i,Vf(r))})}function te(e){if(e._tag===`Reference`)return;let t=e.checks.length===0?e.annotations:e.checks[e.checks.length-1].annotations;return typeof t?.identifier!=`string`&&typeof t?.[`~identifier`]==`string`?t[Io]:void 0}function g(e,t,n,i){let a=e.annotations,o=a?.toJsonSchema;if(o!==void 0){let s=o({type:t,schemas:e.representation?.schemas?.map((e,t)=>ne(e,[...n,`representation`,`schemas`,t],i))??[]}),c=$f(s);c&&i.push(!1);let l=c?s[0]:s,u=Uf(a,r),d=u===void 0?l:{...l,...u},f=u===void 0?Kf:Xf;return[d,e._tag===`Filter`&&qf(d,f)&&(u===void 0||qf(u,Yf))?!0:void 0]}if(e._tag===`Filter`){i.push(!1);return}let s=e.checks.flatMap((e,r)=>{let a=g(e,t,[...n,`checks`,r],i);return a===void 0?[]:[a[0]]});if(s.length===0)return;let c=Uf(a,r),l={allOf:s};return[c===void 0?l:{...l,...c}]}function ne(e,t,n){if(e._tag===`Reference`)return n.push(ee(e.$ref,t)[1]),{$ref:Vf(e.$ref)};let i=o.get(e);if(i!==void 0)return n.push(i[1]),i[0];let a=[];n.push(a);let s=re(e,t,a),c=Uf(e.annotations,r);c!==void 0&&(s={...s,...c});for(let n=0;n<e.checks.length;n++){let r=typeof s.type==`string`&&tp(s.type)?s.type:void 0,i=g(e.checks[n],r,[...t,`checks`,n],a);i!==void 0&&(s=Zf(s,...i))}return o.set(e,[s,a]),m(s)}function re(e,t,n){switch(e._tag){case`Any`:case`Unknown`:return{};case`ObjectKeyword`:return{anyOf:[{type:`object`},{type:`array`}]};case`Void`:case`Undefined`:case`Null`:return{type:`null`};case`BigInt`:return{type:`string`,allOf:[{pattern:`^-?\\d+$`}]};case`Symbol`:return{type:`string`,allOf:[{pattern:`^Symbol\\(([\\s\\S]*)\\)$`}]};case`UniqueSymbol`:return globalThis.Symbol.keyFor(e.symbol)===void 0?{not:{}}:{type:`string`,enum:[globalThis.String(e.symbol)]};case`Declaration`:return n.push(!1),{};case`Suspend`:return ne(e.thunk,[...t,`thunk`],n);case`Never`:return{not:{}};case`String`:return{type:`string`};case`Number`:return{anyOf:[{type:`number`},{type:`string`,enum:[`NaN`,`Infinity`,`-Infinity`]}]};case`Boolean`:return{type:`boolean`};case`Literal`:{let t=e.literal;return typeof t==`bigint`?{type:`string`,enum:[globalThis.String(t)]}:{type:typeof t,enum:[t]}}case`Enum`:{let n=e.enums.map(([e,n],r)=>{if(typeof n==`number`&&!globalThis.Number.isFinite(n))throw Bf(`Invalid numeric enum value ${globalThis.String(n)}`,[...t,`enums`,r,1]);return{type:typeof n,enum:[n],title:e}});return n.length===0?{not:{}}:{anyOf:n}}case`TemplateLiteral`:return{type:`string`,pattern:`^${e.parts.map(rp).join(``)}$`};case`Arrays`:{if(e.rest.length>1)throw Bf(`Invalid schema representation document`,[...t,`rest`]);let i={type:`array`},a=e.elements.length,o=e.elements.map((e,i)=>{e.isOptional&&a--;let o=ne(e.type,[...t,`elements`,i,`type`],n),s=Uf(e.annotations,r);return s===void 0?o:m(Zf(o,s))});if(o.length>0?(i.prefixItems=o,i.maxItems=e.elements.length,a>0&&(i.minItems=a)):i.items=!1,e.rest.length===1){delete i.maxItems;let r=ne(e.rest[0],[...t,`rest`,0],n);Object.keys(r).length>0?i.items=r:delete i.items}return i}case`Objects`:{if(e.propertySignatures.length===0&&e.indexSignatures.length===0)return{not:{type:`null`}};let i={type:`object`},a={},o=[];for(let i=0;i<e.propertySignatures.length;i++){let s=e.propertySignatures[i];if(typeof s.name!=`string`)throw Bf(`Invalid schema representation document`,[...t,`propertySignatures`,i,`name`]);let c=s.name,l=ne(s.type,[...t,`propertySignatures`,i,`type`],n),u=Uf(s.annotations,r);v(a,c,u===void 0?l:m(Zf(l,u))),s.isOptional||o.push(c)}e.propertySignatures.length>0&&(i.properties=a),o.length>0&&(i.required=o);let s={},c=[],l=[],u=!1;for(let r=0;r<e.indexSignatures.length;r++){let i=e.indexSignatures[r],a=ne(i.type,[...t,`indexSignatures`,r,`type`],n);mn(a,{not:{}})&&(a=!1),l.push(a);let o=ie(i.parameter,[...t,`indexSignatures`,r,`parameter`],new Set);if(o===void 0){u=!0,n.push(!1);continue}if(o.length===0)c.push(a);else for(let e of o){let t=s[e];v(s,e,t===void 0?a:t===!1||a===!1?!1:m(Zf(t,a)))}}let d=Object.keys(s).length>0;if(d&&(i.patternProperties=s),u&&r?.onExcessProperty===`error`){let r=[];e.propertySignatures.length>0&&r.push({enum:Object.keys(a)});for(let i=0;i<e.indexSignatures.length;i++)r.push(ne(e.indexSignatures[i].parameter,[...t,`indexSignatures`,i,`parameter`],n));i.propertyNames=r.length===1?r[0]:{anyOf:r},i.additionalProperties=l.length===1?l[0]:{anyOf:l},c.length>0&&(i.allOf=c.map(e=>({type:`object`,additionalProperties:e})))}else c.length===0?i.additionalProperties=u||r?.onExcessProperty!==`error`:c.length===1&&e.propertySignatures.length===0&&!d?i.additionalProperties=c[0]:c.length>0&&(i.allOf=c.map(e=>({type:`object`,additionalProperties:e})));return typeof i.additionalProperties==`object`&&i.additionalProperties!==null&&Object.keys(i.additionalProperties).length===0&&delete i.additionalProperties,i}case`Union`:{let r=[],i=e.types.map((e,n)=>ne(e,[...t,`types`,n],r));if(n.push(r),i.length===0)return{not:{}};let a=e.options?.mode??`anyOf`;if(a===`anyOf`&&i.length>1){let e=np(i);if(e!==void 0)return e}return a===`oneOf`&&s.set(i,[r,[]]),{[a]:i}}}}function ie(e,t,r){switch(e._tag){case`Reference`:{if(!Object.hasOwn(n,e.$ref))throw Bf(`Invalid reference ${e.$ref}`,[...t,`$ref`]);if(ee(e.$ref,t),r.has(e.$ref))return;let i=new Set(r).add(e.$ref);return ie(n[e.$ref],[`references`,e.$ref],i)}case`String`:{if(e.checks.length===0)return[];if(e.checks.length!==1||e.checks[0]._tag!==`Filter`||e.checks[0].annotations?.toJsonSchema===void 0)return;let n=[],r=ne(e,t,n);return Qf(n)&&r.type===`string`&&typeof r.pattern==`string`&&qf(r,`|type|pattern|title|description|default|examples|readOnly|writeOnly|`)?[r.pattern]:void 0}case`TemplateLiteral`:return e.checks.length===0?[`^${e.parts.map(rp).join(``)}$`]:void 0;case`Union`:{if(e.types.length===0||e.checks.length>0||e.options?.mode===`oneOf`)return;let n=[];for(let i=0;i<e.types.length;i++){let a=ie(e.types[i],[...t,`types`,i],r);if(a===void 0)return;if(a.length===0)return[];n.push(...a)}return n}default:throw Bf(`Invalid schema representation document`,t)}}}function tp(e){return e===`string`||e===`number`||e===`boolean`||e===`array`||e===`object`||e===`null`||e===`integer`}function np(e){let t,n=[];for(let r of e){if(Object.keys(r).length!==2||r.type===void 0||!Array.isArray(r.enum)||r.enum.length===0)return;if(t===void 0)t=r.type;else if(r.type!==t)return;for(let e of r.enum){if(n.includes(e))return;n.push(e)}}return{type:t,enum:n}}function rp(e){switch(e._tag){case`Literal`:return zf(globalThis.String(e.literal));case`String`:return Au;case`Number`:return el;case`TemplateLiteral`:return e.parts.map(rp).join(``);case`Union`:return`(?:${e.types.map(rp).join(`|`)})`;default:throw Bf(`Invalid schema representation document`,[])}}function ip(e,t){let n=ep([e.representation],[[`representation`]],e.references,t);return{dialect:n.dialect,schema:n.schemas[0],definitions:n.definitions}}var ap=({identifier:e})=>e;function op(e){return e===void 0?void 0:{annotations:e}}function sp(e,t){let{references:n,representations:r}=cp([e],t);return{representation:r[0],references:n}}function cp(e,t){let n={},r=new Map,i=new Set,a=new Map,o=new Set;for(let t of e)p(t);let s=t?.referencePolicy??ap;for(let e of a.values())for(let t of e.values()){let e=s({ast:t.ast,occurrences:t.occurrences,identifier:t.identifier});e===void 0?t.isRecursive&&(t.reference=c(`${t.ast._tag}_`,t,``)):t.reference=c(e,t,e===t.identifier||!e.endsWith(`_`)?`_`:``)}return{representations:l(e,e=>ee(e)),references:n};function c(e,t,n=`_`){let i=e,a=0;for(;r.has(i);){if(r.get(i)===t)return i;i=`${e}${n}${++a}`}return r.set(i,t),i}function u(e,t,n){let r=t.fallback;return r===void 0?n===t.identifier?e:Xl(e,{identifier:n}):Vo(e)===r?e:Xl(e,{[Io]:r})}function d(e,t){if(!Object.hasOwn(n,e)&&!i.has(e)){i.add(e);let r=h(t);i.delete(e),v(n,e,r)}return{_tag:`Reference`,$ref:e}}function f(e){let t=Yl(e),n=Kl(t),r=Bo(t),i=r===void 0?(t===e?void 0:Bo(e))??Vo(t):void 0;i!==void 0&&(r=`${i}Encoded`);let o=a.get(n);o===void 0&&(o=new Map,a.set(n,o));let s=o.get(r);return s===void 0&&(s={ast:n,identifier:r,fallback:i,occurrences:0,isRecursive:!1,reference:void 0},o.set(r,s)),s}function p(e){let t=f(e),n=t.ast;if(t.occurrences++,o.has(t)){t.isRecursive=!0;return}if(!(t.occurrences>1)){switch(o.add(t),m(n.checks),n._tag){case`Declaration`:case`Arrays`:case`Objects`:case`Union`:n.recur(e=>(p(e),e));break;case`TemplateLiteral`:n.parts.forEach(p);break;case`Suspend`:p(n.thunk())}o.delete(t)}}function m(e){e?.forEach(e=>{e.annotations?.representation?.schemas?.forEach(e=>p(xu(e))),e._tag===`FilterGroup`&&m(e.checks)})}function ee(e){let t=f(e),n=t.ast,r=t.reference;return r===void 0?h(n):d(r,t.identifier===void 0?n:u(n,t,r))}function h(e){let t=te(e.checks);switch(e._tag){case`Declaration`:return{_tag:`Declaration`,typeParameters:e.typeParameters.map(e=>ee(e)),checks:t,...ne(e.annotations)};case`Null`:case`Undefined`:case`Void`:case`Never`:case`Unknown`:case`Any`:case`String`:case`Boolean`:case`Number`:case`BigInt`:case`Symbol`:case`ObjectKeyword`:return{_tag:e._tag,checks:t,...op(e.annotations)};case`Literal`:return{_tag:`Literal`,literal:e.literal,checks:t,...op(e.annotations)};case`UniqueSymbol`:return{_tag:`UniqueSymbol`,symbol:e.symbol,checks:t,...op(e.annotations)};case`Enum`:return{_tag:`Enum`,enums:e.enums,checks:t,...op(e.annotations)};case`TemplateLiteral`:return{_tag:`TemplateLiteral`,parts:e.parts.map(e=>ee(e)),checks:t,...op(e.annotations)};case`Arrays`:return{_tag:`Arrays`,elements:e.elements.map(e=>{let t=Yl(e),n=t.context?.annotations;return{isOptional:gu(t),type:ee(e),...op(n)}}),rest:e.rest.map(e=>ee(e)),checks:t,...op(e.annotations)};case`Objects`:return{_tag:`Objects`,propertySignatures:e.propertySignatures.map(e=>{let t=Yl(e.type),n=t.context?.annotations;return{name:e.name,type:ee(e.type),isOptional:gu(t),isMutable:_u(t),...op(n)}}),indexSignatures:e.indexSignatures.map(e=>({parameter:ee(e.parameter),type:ee(e.type)})),checks:t,...op(e.annotations)};case`Union`:return{_tag:`Union`,types:e.types.map(e=>ee(e)),...e.options===void 0?{}:{options:e.options},checks:t,...op(e.annotations)};case`Suspend`:return{_tag:`Suspend`,checks:[],thunk:ee(e.thunk()),...op(e.annotations)}}}function te(e){return e?.map(g)??[]}function g(e){switch(e._tag){case`Filter`:return{_tag:`Filter`,aborted:e.aborted,...re(e.annotations)};case`FilterGroup`:return{_tag:`FilterGroup`,checks:l(e.checks,g),...re(e.annotations)}}}function ne(e){if(e===void 0)return;let{representation:t,...n}=e;return{...t===void 0?void 0:{representation:t},...Object.keys(n).length===0?void 0:{annotations:n}}}function re(e){if(e===void 0)return;let{representation:t,...n}=e,r=t===void 0?void 0:t.schemas===void 0?t:{...t,schemas:t.schemas.map(e=>ee(xu(e)))};return{...r===void 0?void 0:{representation:r},...Object.keys(n).length===0?void 0:{annotations:n}}}}function lp(e){return ra(e)?e.value:{issues:[{message:Ji(e.cause)}]}}function up(e,t){let n=wd(e),r={errors:`all`,...t?.parseOptions},i=_s(t),a=e=>{let t=new dt(`sync`),a=Fr(c(n(e,r),{onFailure:i,onSuccess:e=>({value:e})}),{scheduler:t});a.currentDispatcher?.flush();let o=a.pollUnsafe();return o?lp(o):new Promise(e=>{a.addObserver(t=>{e(lp(t))})})};if(Object.hasOwn(e,`~standard`)){let t=e;return`validate`in t[`~standard`]||Object.assign(t[`~standard`],{validate:a}),t}return Object.assign(e,{"~standard":{version:1,vendor:`effect`,validate:a}})}function dp(e){return ip(sp(Nf(e)))}function fp(e,t){let n=dp(e);if(t===`draft-2020-12`){let e=n.schema;return Object.keys(n.definitions).length>0&&(e.$defs=n.definitions),e}if(t===`draft-07`){let e=tf(n),t=e.schema;return Object.keys(e.definitions).length>0&&(t.definitions=e.definitions),t}throw new globalThis.Error(`Unsupported target: ${t}`)}function pp(e){let t={input(t){return fp(e.ast,t.target)},output(t){return fp(xu(e.ast),t.target)}};if(Object.hasOwn(e,`~standard`)){let n=e;return`jsonSchema`in n[`~standard`]||Object.assign(n[`~standard`],{jsonSchema:t}),n}return Object.assign(e,{"~standard":{version:1,vendor:`effect`,jsonSchema:t}})}var mp=i(e=>hp(e));function hp(e){let n=No(e)?.toEquivalence;if(n)return n(mc(e)?e.typeParameters.map(hp):[]);switch(e._tag){case`Never`:return t();case`Declaration`:return gp(e);case`Null`:case`Undefined`:case`Void`:case`Unknown`:case`Any`:case`String`:case`Number`:case`Boolean`:case`BigInt`:case`Symbol`:case`Literal`:case`UniqueSymbol`:case`ObjectKeyword`:case`Enum`:case`TemplateLiteral`:return mn;case`Arrays`:{let t=e.elements.map(hp),n=e.rest.map(hp),[r,...i]=n,a=i.length;return nt((o,s)=>{if(!Array.isArray(o)||!Array.isArray(s))return!1;let c=o.length;if(c!==s.length)return!1;let l=0;for(;l<Math.min(c,e.elements.length);l++)if(!t[l](o[l],s[l]))return!1;if(n.length>0){for(;l<c-a;l++)if(!r(o[l],s[l]))return!1;for(let e=0;e<a;e++)if(!i[e](o[l+e],s[l+e]))return!1}return!0})}case`Objects`:{if(e.propertySignatures.length===0&&e.indexSignatures.length===0)return mn;let t=e.propertySignatures.map(e=>hp(e.type)),n=e.indexSignatures.map(e=>hp(e.type));return nt((r,i)=>{if(!Hr(r)||!Hr(i))return!1;for(let n=0;n<t.length;n++){let a=e.propertySignatures[n],o=a.name,s=Object.hasOwn(r,o),c=Object.hasOwn(i,o);if(gu(a.type)&&s!==c||s&&c&&!t[n](r[o],i[o]))return!1}for(let t=0;t<n.length;t++){let a=e.indexSignatures[t],o=tl(r,a.parameter),s=tl(i,a.parameter);if(o.length!==s.length)return!1;for(let e=0;e<o.length;e++){let a=o[e];if(!Object.hasOwn(i,a)||!n[t](r[a],i[a]))return!1}}return!0})}case`Union`:{let t=xu(e).types,n=Tl(t),r=t.map((t,n)=>[Cd(t),hp(e.types[n])]);return nt((e,t)=>{let i=n(e,!1);for(let n=0;n<i.length;n++){let[a,o]=r[i[n]];if(a(e)&&a(t))return o(e,t)}return!1})}case`Suspend`:{let t;return nt((n,r)=>(t??=mp(e.thunk()))(n,r))}}}function gp(e){let t=e.annotations?.representation;if(t===void 0)return mn;switch(t.id){case`effect/schema/Option`:{let[t]=_p(e);return(e,n)=>e._tag===n._tag&&(e._tag===`None`||t(e.value,n.value))}case`effect/schema/Result`:{let[t,n]=_p(e);return(e,r)=>e._tag===r._tag&&(e._tag===`Success`?t(e.success,r.success):n(e.failure,r.failure))}case`effect/schema/CauseReason`:{let[t,n]=_p(e);return vp(t,n)}case`effect/schema/Cause`:{let[t,n]=_p(e);return yp(t,n)}case`effect/schema/Exit`:{let[t,n,r]=_p(e),i=yp(n,r);return(e,n)=>e._tag===n._tag&&(e._tag===`Success`?t(e.value,n.value):i(e.cause,n.cause))}case`effect/schema/ReadonlyMap`:{let[t,n]=_p(e);return Mr(t,n)}case`effect/schema/ReadonlySet`:return nr(_p(e)[0]);case`effect/schema/RegExp`:return(e,t)=>e.source===t.source&&e.flags===t.flags;case`effect/schema/URL`:return(e,t)=>e.toString()===t.toString();default:return mn}}function _p(e){return e.typeParameters.map(hp)}function vp(e,t){return(n,r)=>{if(n._tag!==r._tag)return!1;switch(n._tag){case`Fail`:return e(n.error,r.error);case`Die`:return t(n.defect,r.defect);case`Interrupt`:return n.fiberId===r.fiberId}}}function yp(e,t){let n=At(vp(e,t));return(e,t)=>n(e.reasons,t.reasons)}var bp=g(2,(e,t)=>({...e,...t})),xp=e=>e,Sp=`~effect/Schema/SchemaError`;function Cp(e){return Rr(e,`~effect/Schema/SchemaError`)&&e[`~effect/Schema/SchemaError`]===`~effect/Schema/SchemaError`}var wp=Ud;function Tp(){return(e,t,n)=>qp(new Mc(e.map(ml),e=>t(e.map(e=>qp(e))),n))}function Ep(e,t){return Tp()([],()=>(t,n,r)=>e(t)?b(t):x(new ss(n,t,r)),t)}var Dp=class extends Fi(`SchemaError`){[Sp]=Sp;constructor(e){let t=u();Ct(0);try{super({issue:e})}finally{Ct(t)}}get message(){return ws(this.issue)}toString(){return`SchemaError(${this.message})`}};function Op(e){return Cp(e)}function kp(e){return Ie(e)?Ap(e):Ir(e,e=>Vr(()=>Ui(e,e=>new Dp(e))))}function Ap(e){return ra(e)?e:$i(Ui(e.cause,e=>new Dp(e)))}function jp(e,t){let n;for(let r of e.reasons){if(!Ri(r)||!Op(r.error))throw new globalThis.Error(t,{cause:e});n??=r.error}if(n===void 0)throw new globalThis.Error(t,{cause:e});return n}function Mp(e){let t=lr(e);if(ra(t))return t.value;throw jp(t.cause,`Sync adapter can only throw schema errors`)}function Np(e,t){return up(e,t)}function Pp(e){return pp(e)}var Fp=xd;function Ip(e,t){let n=wd(e,t);return(e,t)=>kp(n(e,t))}function Lp(e,t){let n=Td(e,t);return(e,t)=>Ap(n(e,t))}var Rp=Ed;function O(e,t){let n=Dd(e,t);return(e,t)=>Ee(n(e,t),e=>new Dp(e))}var zp=O;function k(e,t){let n=Ip(e,t);return(e,t)=>Mp(n(e,t))}var Bp=k;function Vp(e,t){let n=Od(e,t);return(e,t)=>kp(n(e,t))}function Hp(e,t){let n=kd(e,t);return(e,t)=>Ap(n(e,t))}function Up(e,t){let n=Ad(e,t);return(e,t)=>Ee(n(e,t),e=>new Dp(e))}var Wp=Up;function Gp(e,t){let n=Vp(e,t);return(e,t)=>Mp(n(e,t))}var Kp=Gp,qp=Kd;function Jp(e){return Rr(e,wp)&&e[wp]===wp}var A=xp(e=>qp(su(e.ast),{schema:e})),j=xp(e=>{let t=fm(e);return qp(lu(e.ast),{schema:t})}),Yp=xp(e=>qp(uu(e.ast),{schema:e})),Xp=xp(e=>qp(xu(e.ast),{schema:e})),Zp=xp(e=>qp(Su(e.ast),{schema:e}));function M(e){let t=qp(new zc(e),{literal:e,transform(n){return t.pipe(gm(M(n),{decode:Rs(()=>n),encode:Rs(()=>e)}))}});return t}var Qp=qp(Lc),$p=qp(Rc),em=qp(Nc),tm=qp(Ic),N=qp(Vc),P=qp(Wc),nm=qp(Gc),rm=qp(Kc),im=qp(qc);function am(e,t){return qp(e,{fields:t,mapFields(e,t){let n=e(this.fields);return am(pl(n,t?.unsafePreserveChecks?this.ast.checks:void 0),n)}})}function F(e){return am(pl(e,void 0),e)}function om(e,t){return qp(hu(e.ast,t.ast),{key:e,value:t})}function sm(e,t){return qp(e,{elements:t,mapElements(e,t){let n=e(this.elements);return sm(hl(n,t?.unsafePreserveChecks?this.ast.checks:void 0),n)}})}function cm(e){return sm(hl(e),e)}var I=xp(e=>qp(new Jc(!1,[],[e.ast]),{value:e})),lm=xp(e=>qp(new Jc(!1,[e.ast],[e.ast]),{value:e})),um=xp(e=>qp(_l(e.ast),{schema:e}));function dm(e,t){return qp(e,{members:t,mapMembers(e,t){let n=e(this.members);return dm(gl(n,this.ast.options,t?.unsafePreserveChecks?this.ast.checks:void 0),n)}})}function L(e,t){return dm(gl(e,t,void 0),e)}function R(e){let t=e.map(M);return qp(gl(t,void 0,void 0),{literals:e,members:t,mapMembers(e){return L(e(this.members))},pick(e){return R(e)},transform(e){return L(t.map((t,n)=>t.transform(e[n])))}})}var z=xp(e=>L([e,em])),fm=xp(e=>L([e,tm]));function pm(e){return qp(new Fl(()=>e().ast))}function B(...e){return t=>t.check(...e)}function mm(e,t){return n=>qp(Ql(n.ast,[zl(e,t)]),{schema:n})}function hm(e){return t=>qp(t.ast,{schema:t,identifier:e})}function gm(e,t){return n=>qp(pu(n.ast,e.ast,t?rc(t):sc()),{from:n,to:e})}function _m(){return(e,t)=>Tm()(e,{decode:t,encode:Ps})}function vm(e,t){return n=>t?gm(n,t)(e):gm(n)(e)}function ym(e){return t=>qp(fu(t.ast,e),{schema:t})}function bm(e){return Ir(e,e=>Vr(()=>Ui(e,e=>e.issue)))}function xm(e,t){let n=t?.encodingStrategy===`omit`?Hs():Is();return t=>j(Zp(t)).pipe(gm(t,{decode:Us(bm(e)),encode:n}))}function Sm(e,t){return n=>Xp(n).pipe(xm(e,t),vm(j(n)))}function Cm(e){return M(e).pipe(ym(b(e)))}function wm(e,t){return Ep(t=>t instanceof e,t)}function Tm(){return(e,t)=>new Dc(e.ast,rc(t))}var V=Rl,Em=`^\\S[\\s\\S]*\\S$|^\\S$|^$`;function Dm(e){let t=new globalThis.RegExp(Em);return V(e=>e.trim()===e,{expected:`a string with no leading or trailing whitespace`,representation:{id:`effect/schema/isTrimmed`,payload:null},toJsonSchema:()=>({pattern:t.source}),toCode:()=>({runtime:`Schema.isTrimmed()`}),arbitraryConstraint:{patterns:[{source:Em,flags:``}]},...e})}function Om(e,t){let n=e.source,r=e.flags,i=/^[dg]*uy?$/.test(r),a=r===``?`new RegExp(${_(n)})`:`new RegExp(${_(n)}, ${_(r)})`;return Ul(e,{toJsonSchema:()=>i?{pattern:r.endsWith(`y`)?`^(?:${n})`:n}:[{},!0],toCode:()=>({runtime:`Schema.isPattern(${a})`}),...t})}var km=e=>e?new globalThis.RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${e}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`):/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|[fF]{8}-[fF]{4}-[fF]{4}-[fF]{4}-[fF]{12})$/;function Am(e,t){let n=km(e);return Om(n,{expected:e?`a UUID v${e}`:`a UUID`,representation:{id:`effect/schema/isUUID`,payload:{version:e??null}},toJsonSchema:()=>({pattern:n.source,format:`uuid`}),toCode:()=>({runtime:e===void 0?`Schema.isUUID()`:`Schema.isUUID(${e})`}),...t})}function jm(e){let t=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/;return Om(t,{expected:`a base64 encoded string`,representation:{id:`effect/schema/isBase64`,payload:null},toJsonSchema:()=>({pattern:t.source}),toCode:()=>({runtime:`Schema.isBase64()`}),...e})}function Mm(e,t,n){if(e.length===0)return t.length===0?{}:[{},!0];let r={pattern:new globalThis.RegExp(n).source};return e===t?r:[r,!0]}function Nm(e,t){let n=JSON.stringify(e),r=new globalThis.RegExp(`^${zf(e)}`),i=e.replace(/[\uD800-\uDBFF]$/,``);return V(t=>t.startsWith(e),{expected:`a string starting with ${n}`,representation:{id:`effect/schema/isStartingWith`,payload:{startsWith:e}},toJsonSchema:()=>Mm(i,e,`^${zf(i)}`),toCode:()=>({runtime:`Schema.isStartingWith(${_(e)})`}),arbitraryConstraint:{patterns:[{source:r.source,flags:r.flags}]},...t})}function Pm(e,t){let n=JSON.stringify(e),r=new globalThis.RegExp(`${zf(e)}$`),i=e.replace(/^[\uDC00-\uDFFF]/,``);return V(t=>t.endsWith(e),{expected:`a string ending with ${n}`,representation:{id:`effect/schema/isEndingWith`,payload:{endsWith:e}},toJsonSchema:()=>Mm(i,e,`${zf(i)}$`),toCode:()=>({runtime:`Schema.isEndingWith(${_(e)})`}),arbitraryConstraint:{patterns:[{source:r.source,flags:r.flags}]},...t})}function Fm(e,t){let n=JSON.stringify(e),r=new globalThis.RegExp(zf(e)),i=e.replace(/^[\uDC00-\uDFFF]|[\uD800-\uDBFF]$/g,``);return V(t=>t.includes(e),{expected:`a string including ${n}`,representation:{id:`effect/schema/isIncluding`,payload:{includes:e}},toJsonSchema:()=>Mm(i,e,zf(i)),toCode:()=>({runtime:`Schema.isIncluding(${_(e)})`}),arbitraryConstraint:{patterns:[{source:r.source,flags:r.flags}]},...t})}var Im=qp(Vl),Lm=Bl;function Rm(e){let t=En(e.order),n=e.formatter??_;return(r,i)=>V(e=>t(e,r),{expected:`a value greater than ${n(r)}`,arbitraryConstraint:{order:e.order,minimum:r,exclusiveMinimum:!0},...e.annotate?.(r),...i})}function zm(e){let t=Wt(e.order),n=e.formatter??_;return(r,i)=>V(e=>t(e,r),{expected:`a value greater than or equal to ${n(r)}`,arbitraryConstraint:{order:e.order,minimum:r},...e.annotate?.(r),...i})}function Bm(e){let t=Wr(e.order),n=e.formatter??_;return(r,i)=>V(e=>t(e,r),{expected:`a value less than ${n(r)}`,arbitraryConstraint:{order:e.order,maximum:r,exclusiveMaximum:!0},...e.annotate?.(r),...i})}function Vm(e){let t=oi(e.order),n=e.formatter??_;return(r,i)=>V(e=>t(e,r),{expected:`a value less than or equal to ${n(r)}`,arbitraryConstraint:{order:e.order,maximum:r},...e.annotate?.(r),...i})}function Hm(e){let t=Wt(e.order),n=En(e.order),r=oi(e.order),i=Wr(e.order),a=e.formatter??_;return(o,s)=>{let c=o.exclusiveMinimum?n:t,l=o.exclusiveMaximum?i:r;return V(e=>c(e,o.minimum)&&l(e,o.maximum),{expected:`a value between ${a(o.minimum)}${o.exclusiveMinimum?` (excluded)`:``} and ${a(o.maximum)}${o.exclusiveMaximum?` (excluded)`:``}`,arbitraryConstraint:{order:e.order,minimum:o.minimum,maximum:o.maximum,...o.exclusiveMinimum&&{exclusiveMinimum:!0},...o.exclusiveMaximum&&{exclusiveMaximum:!0}},...e.annotate?.(o),...s})}}function Um(e){if(!globalThis.Number.isFinite(e))throw new globalThis.RangeError(`Expected a finite number, got ${_(e)}`);return e}var Wm=Rm({order:er,annotate:e=>({representation:{id:`effect/schema/isGreaterThan`,payload:{exclusiveMinimum:Um(e)}},toJsonSchema:()=>({exclusiveMinimum:e}),toCode:()=>({runtime:`Schema.isGreaterThan(${_(e)})`})})}),H=zm({order:er,annotate:e=>({representation:{id:`effect/schema/isGreaterThanOrEqualTo`,payload:{minimum:Um(e)}},toJsonSchema:()=>({minimum:e}),toCode:()=>({runtime:`Schema.isGreaterThanOrEqualTo(${_(e)})`})})}),Gm=Bm({order:er,annotate:e=>({representation:{id:`effect/schema/isLessThan`,payload:{exclusiveMaximum:Um(e)}},toJsonSchema:()=>({exclusiveMaximum:e}),toCode:()=>({runtime:`Schema.isLessThan(${_(e)})`})})}),Km=Vm({order:er,annotate:e=>({representation:{id:`effect/schema/isLessThanOrEqualTo`,payload:{maximum:Um(e)}},toJsonSchema:()=>({maximum:e}),toCode:()=>({runtime:`Schema.isLessThanOrEqualTo(${_(e)})`})})}),qm=Hm({order:er,annotate:e=>{let t=e.exclusiveMinimum?!0:void 0,n=e.exclusiveMaximum?!0:void 0;return{representation:{id:`effect/schema/isBetween`,payload:{minimum:Um(e.minimum),maximum:Um(e.maximum),...t&&{exclusiveMinimum:t},...n&&{exclusiveMaximum:n}}},toJsonSchema:()=>({[t?`exclusiveMinimum`:`minimum`]:e.minimum,[n?`exclusiveMaximum`:`maximum`]:e.maximum}),toCode:()=>({runtime:`Schema.isBetween({ minimum: ${_(e.minimum)}, maximum: ${_(e.maximum)}, exclusiveMinimum: ${_(t)}, exclusiveMaximum: ${_(n)} })`})}}});function Jm(e,t){if(!globalThis.Number.isFinite(e)||e===0)throw new globalThis.RangeError(`Expected a finite non-zero number, got ${globalThis.String(e)}`);return e=globalThis.Math.abs(e),V(t=>Ua(t,e)===0,{expected:`a value that is a multiple of ${e}`,representation:{id:`effect/schema/isMultipleOf`,payload:{divisor:e}},toJsonSchema:()=>({multipleOf:e}),toCode:()=>({runtime:`Schema.isMultipleOf(${_(e)})`}),...t})}function Ym(e){return V(e=>globalThis.Number.isSafeInteger(e),{expected:`an integer`,representation:{id:`effect/schema/isInt`,payload:null},toJsonSchema:()=>[{type:`integer`},!0],toCode:()=>({runtime:`Schema.isInt()`}),arbitraryConstraint:{number:`integer`},...e})}var U=P.check(Ym()),Xm=U.check(H(0));function Zm(e){if(globalThis.Number.isNaN(e.getTime()))throw new globalThis.RangeError(`Expected a valid Date, got ${_(e)}`);return e.toISOString()}function Qm(e){return`new Date(${_(e.getTime())})`}var $m=Rm({order:mr,annotate:e=>({representation:{id:`effect/schema/isGreaterThanDate`,payload:{exclusiveMinimum:Zm(e)}},toJsonSchema:()=>[{},!0],toCode:()=>({runtime:`Schema.isGreaterThanDate(${Qm(e)})`})})}),eh=zm({order:mr,annotate:e=>({representation:{id:`effect/schema/isGreaterThanOrEqualToDate`,payload:{minimum:Zm(e)}},toJsonSchema:()=>[{},!0],toCode:()=>({runtime:`Schema.isGreaterThanOrEqualToDate(${Qm(e)})`})})}),th=Bm({order:mr,annotate:e=>({representation:{id:`effect/schema/isLessThanDate`,payload:{exclusiveMaximum:Zm(e)}},toJsonSchema:()=>[{},!0],toCode:()=>({runtime:`Schema.isLessThanDate(${Qm(e)})`})})}),nh=Vm({order:mr,annotate:e=>({representation:{id:`effect/schema/isLessThanOrEqualToDate`,payload:{maximum:Zm(e)}},toJsonSchema:()=>[{},!0],toCode:()=>({runtime:`Schema.isLessThanOrEqualToDate(${Qm(e)})`})})}),rh=Hm({order:mr,annotate:e=>{let t=e.exclusiveMinimum?!0:void 0,n=e.exclusiveMaximum?!0:void 0;return{representation:{id:`effect/schema/isBetweenDate`,payload:{minimum:Zm(e.minimum),maximum:Zm(e.maximum),...t&&{exclusiveMinimum:t},...n&&{exclusiveMaximum:n}}},toJsonSchema:()=>[{},!0],toCode:()=>({runtime:`Schema.isBetweenDate({ minimum: ${Qm(e.minimum)}, maximum: ${Qm(e.maximum)}, exclusiveMinimum: ${_(t)}, exclusiveMaximum: ${_(n)} })`})}}}),ih=Rm({order:Sn,annotate:e=>({representation:{id:`effect/schema/isGreaterThanBigInt`,payload:{exclusiveMinimum:e.toString(10)}},toJsonSchema:()=>[{},!0],toCode:()=>({runtime:`Schema.isGreaterThanBigInt(${_(e)})`})})}),ah=zm({order:Sn,annotate:e=>({representation:{id:`effect/schema/isGreaterThanOrEqualToBigInt`,payload:{minimum:e.toString(10)}},toJsonSchema:()=>[{},!0],toCode:()=>({runtime:`Schema.isGreaterThanOrEqualToBigInt(${_(e)})`})})}),oh=Bm({order:Sn,annotate:e=>({representation:{id:`effect/schema/isLessThanBigInt`,payload:{exclusiveMaximum:e.toString(10)}},toJsonSchema:()=>[{},!0],toCode:()=>({runtime:`Schema.isLessThanBigInt(${_(e)})`})})}),sh=Vm({order:Sn,annotate:e=>({representation:{id:`effect/schema/isLessThanOrEqualToBigInt`,payload:{maximum:e.toString(10)}},toJsonSchema:()=>[{},!0],toCode:()=>({runtime:`Schema.isLessThanOrEqualToBigInt(${_(e)})`})})}),ch=Hm({order:Sn,annotate:e=>{let t=e.exclusiveMinimum?!0:void 0,n=e.exclusiveMaximum?!0:void 0;return{representation:{id:`effect/schema/isBetweenBigInt`,payload:{minimum:e.minimum.toString(10),maximum:e.maximum.toString(10),...t&&{exclusiveMinimum:t},...n&&{exclusiveMaximum:n}}},toJsonSchema:()=>[{},!0],toCode:()=>({runtime:`Schema.isBetweenBigInt({ minimum: ${_(e.minimum)}, maximum: ${_(e.maximum)}, exclusiveMinimum: ${_(t)}, exclusiveMaximum: ${_(n)} })`})}}});function lh(e,t){return e=vh(e),uh(e,Math.ceil(e/2),t)}function uh(e,t,n){return V(t=>t.length>=e,{expected:`a value with a length of at least ${e}`,representation:{id:`effect/schema/isMinLength`,payload:{minLength:e}},toJsonSchema:({type:n})=>n===`string`?e<=1?{minLength:t}:[{minLength:t},!0]:n===`array`?{minItems:e}:n===void 0?[{minLength:t,minItems:e},!0]:[{},!0],toCode:()=>({runtime:`Schema.isMinLength(${e})`}),[Fo]:!0,arbitraryConstraint:{minLength:e},...n})}function dh(e){return uh(1,1,e)}function fh(e,t){return e=vh(e),V(t=>t.length<=e,{expected:`a value with a length of at most ${e}`,representation:{id:`effect/schema/isMaxLength`,payload:{maxLength:e}},toJsonSchema:({type:t})=>t===`string`?e===0?{maxLength:e}:[{maxLength:e},!0]:t===`array`?{maxItems:e}:t===void 0?[{maxLength:e,maxItems:e},!0]:[{},!0],toCode:()=>({runtime:`Schema.isMaxLength(${e})`}),[Fo]:!0,arbitraryConstraint:{maxLength:e},...t})}function ph(e,t,n){return e=vh(e),t=vh(t),V(n=>n.length>=e&&n.length<=t,{expected:e===t?`a value with a length of ${e}`:`a value with a length between ${e} and ${t}`,representation:{id:`effect/schema/isBetweenLength`,payload:{minimum:e,maximum:t}},toJsonSchema:({type:n})=>n===`string`?t===0||Math.ceil(e/2)>t?{minLength:Math.ceil(e/2),maxLength:t}:[{minLength:Math.ceil(e/2),maxLength:t},!0]:n===`array`?{minItems:e,maxItems:t}:n===void 0?[{minLength:Math.ceil(e/2),maxLength:t,minItems:e,maxItems:t},!0]:[{},!0],toCode:()=>({runtime:`Schema.isBetweenLength(${e}, ${t})`}),[Fo]:!0,arbitraryConstraint:{minLength:e,maxLength:t},...n})}function mh(e,t){return e=vh(e),V(t=>_h(t,e)>=e,{expected:`a string with at least ${e} code points`,representation:{id:`effect/schema/isMinCodePoints`,payload:{minCodePoints:e}},toJsonSchema:()=>({minLength:e}),toCode:()=>({runtime:`Schema.isMinCodePoints(${e})`}),arbitraryConstraint:{minCodePoints:e},...t})}function hh(e,t){return e=vh(e),V(t=>_h(t,e+1)<=e,{expected:`a string with at most ${e} code points`,representation:{id:`effect/schema/isMaxCodePoints`,payload:{maxCodePoints:e}},toJsonSchema:()=>({maxLength:e}),toCode:()=>({runtime:`Schema.isMaxCodePoints(${e})`}),arbitraryConstraint:{maxCodePoints:e},...t})}function gh(e,t,n){return e=vh(e),t=vh(t),V(n=>{let r=_h(n,t+1);return r>=e&&r<=t},{expected:e===t?`a string with ${e} code points`:`a string with between ${e} and ${t} code points`,representation:{id:`effect/schema/isBetweenCodePoints`,payload:{minimum:e,maximum:t}},toJsonSchema:()=>({allOf:[{minLength:e},{maxLength:t}]}),toCode:()=>({runtime:`Schema.isBetweenCodePoints(${e}, ${t})`}),arbitraryConstraint:{minCodePoints:e,maxCodePoints:t},...n})}function _h(e,t){if(t===0)return 0;let n=0;for(let r of e)if(++n>=t)break;return n}function vh(e){if(!globalThis.Number.isFinite(e))throw new globalThis.RangeError(`Expected a finite number, got ${e}`);return Math.max(0,Math.floor(e))}function yh(e,t){return e=vh(e),V(t=>t.size>=e,{expected:`a value with a size of at least ${e}`,representation:{id:`effect/schema/isMinSize`,payload:{minSize:e}},toJsonSchema:()=>[{},!0],toCode:()=>({runtime:`Schema.isMinSize(${e})`}),[Fo]:!0,arbitraryConstraint:{minSize:e},...t})}function bh(e,t){return e=vh(e),V(t=>t.size<=e,{expected:`a value with a size of at most ${e}`,representation:{id:`effect/schema/isMaxSize`,payload:{maxSize:e}},toJsonSchema:()=>[{},!0],toCode:()=>({runtime:`Schema.isMaxSize(${e})`}),[Fo]:!0,arbitraryConstraint:{maxSize:e},...t})}function xh(e,t,n){return e=vh(e),t=vh(t),V(n=>n.size>=e&&n.size<=t,{expected:e===t?`a value with a size of ${e}`:`a value with a size between ${e} and ${t}`,representation:{id:`effect/schema/isBetweenSize`,payload:{minimum:e,maximum:t}},toJsonSchema:()=>[{},!0],toCode:()=>({runtime:`Schema.isBetweenSize(${e}, ${t})`}),[Fo]:!0,arbitraryConstraint:{minSize:e,maxSize:t},...n})}function Sh(e,t){return e=vh(e),V(t=>Reflect.ownKeys(t).length>=e,{expected:`a value with at least ${e===1?`1 entry`:`${e} entries`}`,representation:{id:`effect/schema/isMinProperties`,payload:{minProperties:e}},toJsonSchema:({type:t})=>t===`object`?{minProperties:e}:[{minProperties:e},!0],toCode:()=>({runtime:`Schema.isMinProperties(${e})`}),[Fo]:!0,arbitraryConstraint:{minProperties:e},...t})}function Ch(e,t){return e=vh(e),V(t=>Reflect.ownKeys(t).length<=e,{expected:`a value with at most ${e===1?`1 entry`:`${e} entries`}`,representation:{id:`effect/schema/isMaxProperties`,payload:{maxProperties:e}},toJsonSchema:({type:t})=>t===`object`?{maxProperties:e}:[{maxProperties:e},!0],toCode:()=>({runtime:`Schema.isMaxProperties(${e})`}),[Fo]:!0,arbitraryConstraint:{maxProperties:e},...t})}function wh(e,t,n){return e=vh(e),t=vh(t),V(n=>Reflect.ownKeys(n).length>=e&&Reflect.ownKeys(n).length<=t,{expected:e===t?`a value with exactly ${e===1?`1 entry`:`${e} entries`}`:`a value with between ${e} and ${t} entries`,representation:{id:`effect/schema/isBetweenProperties`,payload:{minimum:e,maximum:t}},toJsonSchema:({type:n})=>n===`object`?{minProperties:e,maxProperties:t}:[{minProperties:e,maxProperties:t},!0],toCode:()=>({runtime:`Schema.isBetweenProperties(${e}, ${t})`}),[Fo]:!0,arbitraryConstraint:{minProperties:e,maxProperties:t},...n})}var Th=N.check(dh());globalThis.RegExp,globalThis.URL;var Eh=N.annotate({expected:`a string that will be decoded as a Date`}),Dh=Ep(e=>e instanceof globalThis.Date&&!globalThis.Number.isNaN(e.getTime()),{representation:{id:`effect/schema/Date`,payload:null},toCode:()=>({runtime:`Schema.Date`,Type:`globalThis.Date`}),expected:`a valid Date`,toCodecJson:()=>Tm()(Eh,uc)}),Oh=N.annotate({expected:`a string that will be decoded as JSON`,contentMediaType:`application/json`});function W(e,t){return Oh.pipe(gm(e,fc(t)))}globalThis.File,globalThis.FormData,globalThis.URLSearchParams;var kh=N.annotate({expected:`a string that will be decoded as a number`}).pipe(gm(P,cc)),Ah=N.check(Dm()),jh=N.annotate({expected:`a string that will be decoded as a trimmed string`}).pipe(gm(Ah,ac())),Mh=N.annotate({expected:`a base64 encoded string that will be decoded as Uint8Array`,format:`byte`,contentEncoding:`base64`}),Nh=wm(globalThis.Uint8Array,{representation:{id:`effect/schema/Uint8Array`,payload:null},toCode:()=>({runtime:`Schema.Uint8Array`,Type:`globalThis.Uint8Array`}),expected:`Uint8Array`,toCodecJson:()=>Tm()(Mh,dc)}),Ph=ic({decode:(e,t)=>Ar(_o(e),{onNone:()=>x(new cs({expected:`a valid UTC DateTime string`},e,t)),onSome:e=>b(vo(e))}),encode:e=>b(yo(e))}),Fh=-864e13,Ih=864e13;function Lh(e,t,n){let r=Math.max(t,e?.minimum===void 0?t:e.minimum.epochMilliseconds+ +(e.exclusiveMinimum===!0)),i=Math.min(n,e?.maximum===void 0?n:e.maximum.epochMilliseconds-+(e.exclusiveMaximum===!0));return r<=i?[r,i]:[t,n]}function Rh(e,t){return U.check(qm({minimum:e,maximum:t}))}var zh=Ep(e=>mo(e)&&ho(e),{representation:{id:`effect/schema/DateTimeUtc`,payload:null},toCode:()=>({runtime:`Schema.DateTimeUtc`,Type:`DateTime.Utc`,importDeclarations:[`import * as DateTime from "effect/DateTime"`]}),expected:`DateTime.Utc`,toCodecArbitrary:({constraint:e})=>{let[t,n]=Lh(e,Fh,Ih);return _m()(Rh(t,n),Rs(go))},toCodecJson:()=>Tm()(N,Ph),toFormatter:()=>e=>e.toString()}),Bh=N.annotate({expected:`a string that will be decoded as a DateTime.Utc`}).pipe(gm(zh,Ph));function Vh(e){return mp(e.ast)}function Hh(e,t){return sp(e.ast,t)}function Uh(e,t){return ip(sp(Nf(e.ast),t),t)}var Wh=Mf,Gh=qp(Xl(Qu,{toCode:()=>({runtime:`Schema.Json`,Type:`Schema.Json`})})),Kh=om(N,Gh),qh=C(()=>Vt({id:T().min(1).max(256),name:T().min(1).max(128),kind:Lr(`agent`).optional()})),Jh=C(()=>T().min(1).max(256)),Yh=C(()=>Vt({agentId:Jh,sessionId:Jh,commandId:Jh,outcome:Te([`completed`,`failed`,`interrupted`,`cancelled`,`outcome_unknown`]),diagnostic:T().min(1).max(200).optional(),waitingOnYou:pn(Vt({itemId:Jh,kind:T().min(1).max(64),summary:T().min(1).max(200)})).min(1).max(8).optional()})),Xh=Vt({author:qh.optional(),sourceRequestId:Jh.optional(),delegation:Vt({ancestors:pn(Jh).max(8),maxDepth:dr().int().min(1).max(8),steer:Lr(!0).optional(),goal:Qr([T().min(1).max(4e3),Lr(!1)]).optional(),reply:Yh.optional()}).optional()});function Zh(e){let t=Xh.safeParse(e);return t.success?t.data.author:void 0}var Qh=e=>crypto.getRandomValues(new Uint8Array(e)),$h=(e,t,n)=>{let r=256-256%e.length;if(r===256){let r=e.length-1;return(i=t)=>{if(!i)return``;let a=``;for(;;){let t=n(i),o=i;for(;o--;)if(a+=e[t[o]&r],a.length>=i)return a}}}let i=Math.ceil(409.6*t/r);return(a=t)=>{if(!a)return``;let o=``;for(;;){let t=n(i),s=i;for(;s--;)if(t[s]<r&&(o+=e[t[s]%e.length],o.length>=a))return o}}},eg=(e,t=21)=>$h(e,t|0,Qh),tg=`abcdefghijklmnopqrstuvwxyz0123456789`;function ng(e=21){if(e===1/0||e===-1/0)throw RangeError(`nanoid length must be finite`);return eg(tg,e)()}var rg=/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/,ig=/^[a-z][a-z0-9]*(?:_[a-z][a-z0-9]*)*$/,ag=T().min(1).max(64).regex(rg),og=T().min(1).max(64).regex(rg),sg=T().min(1).max(32).regex(ig),cg=Zn({prefix:sg}),lg=Zn({family:ag,version:Lr(1),kinds:Cn(og,cg)}).superRefine((e,t)=>{let n=Object.entries(e.kinds);if(n.length<1||n.length>64){t.addIssue({code:`custom`,message:`Identifier families must declare between one and 64 kinds`});return}let r=new Set;for(let[,e]of n){if(r.has(e.prefix)){t.addIssue({code:`custom`,message:`Identifier kind prefixes must be distinct`});return}r.add(e.prefix)}}),ug=T(),dg=/^[a-z0-9]+$/,fg=new TextEncoder;function pg(e){return e===32||e>=9&&e<=13}function mg(e){let t=0,n=e.length;for(;t<n&&pg(e.charCodeAt(t));)t+=1;for(;n>t&&pg(e.charCodeAt(n-1));)--n;return e.slice(t,n).replace(/[A-Z]/g,e=>String.fromCharCode(e.charCodeAt(0)+32))}function hg(e){let t=`${e.prefix}_`;function n(e){if(!e.startsWith(t))return!1;let n=e.slice(t.length);return n.length===21&&dg.test(n)}let r=C(()=>Nn(e=>{let t=ug.safeParse(e);return t.success&&n(t.data)}));function i(i){let a,o=i,s=fg.encode(o).byteLength,c=r.safeParse(o),l=o.startsWith(t)?o.slice(t.length):void 0;if(s<3||s>96)a=`bounds`;else if(l!==void 0&&Array.from(l).length!==21)a=`bounds`;else if(c.success)return{ok:!0,value:c.data};else a=n(mg(o))?`non_canonical`:`grammar`;return{ok:!1,error:{code:`invalid_id`,family:e.family,kind:e.kind,version:1,reason:a}}}let a=C(()=>ug.transform((e,t)=>{let n=i(e);return n.ok?n.value:(t.addIssue({code:`custom`,message:n.error.reason}),gn)}));function o(){let n;try{n=ng(21)}catch{throw e.entropyUnavailable()}return r.parse(`${t}${n}`)}return{family:e.family,kind:e.kind,version:1,generate:o,schema:a,parse:i,is:e=>i(e).ok}}var gg=Cn(T(),Zn({family:T(),kind:T(),version:Lr(1),generate:Nt(),schema:Ot(ke),parse:Nt(),is:Nt()})),_g=class extends Error{name=`CairnDefinitionError`;code=`invalid_definition`;constructor(){super(`Cairn identifier family definition is invalid`)}},vg=class extends Error{name=`CairnGenerationError`;code=`entropy_unavailable`;family;kind;version=1;constructor(e){super(`Cairn entropy source is unavailable`),this.family=e.family,this.kind=e.kind}};function yg(e){let t;try{t=lg.safeParse(e)}catch{throw new _g}if(!t.success)throw new _g;let n=t.data,r={};for(let[t,i]of Object.entries(n.kinds)){let a=i.prefix;r[t]=hg({family:e.family,kind:t,prefix:a,entropyUnavailable:()=>new vg({family:n.family,kind:t})})}let i=Nn(e=>{let t=gg.safeParse(e);if(!t.success)return!1;let r=Object.entries(t.data);return r.length===Object.keys(n.kinds).length&&r.every(([e,t])=>Object.hasOwn(n.kinds,e)&&t.kind===e&&t.family===n.family)}).safeParse(r);if(!i.success)throw new _g;return i.data}var bg=Symbol.for(`effect/MutableList/Empty`),xg=()=>({head:void 0,tail:void 0,length:0}),Sg=e=>{let t=e.head;t.offset>=1024&&t===e.tail&&t.mutable&&(t.array.length-t.offset)*8<=t.offset&&(e.head=e.tail={array:t.array.slice(t.offset),mutable:!0,offset:0,next:void 0})},Cg=()=>({array:[],mutable:!0,offset:0,next:void 0}),wg=(e,t)=>{e.tail?e.tail.mutable||(e.tail.next=Cg(),e.tail=e.tail.next):e.head=e.tail=Cg(),e.tail.array.push(t),e.length++},Tg=e=>{e.head=e.tail=void 0,e.length=0},Eg=(e,t)=>{if(t=pi(t),t<=0||!e.head)return[];if(t=Math.min(t,e.length),t===e.length&&e.head?.offset===0&&!e.head.next){let t=e.head.array;return Tg(e),t}let n=Array(t),r=0,i=e.head;for(;i;){for(;i.offset<i.array.length;)if(n[r++]=i.array[i.offset],i.mutable&&(i.array[i.offset]=void 0),i.offset++,r===t)return e.head=i.offset===i.array.length&&i.next?i.next:i,e.length-=t,e.length===0?Tg(e):Sg(e),n;i=i.next}return Tg(e),n},Dg=e=>Eg(e,e.length),Og=e=>{if(!e.head)return bg;let t=e.head.array[e.head.offset];return e.head.mutable&&(e.head.array[e.head.offset]=void 0),e.head.offset++,e.length--,e.head.offset===e.head.array.length?e.head.next?e.head=e.head.next:Tg(e):Sg(e),t},kg=`~effect/Queue`,Ag=`~effect/Queue/Enqueue`,jg=`~effect/Queue/Dequeue`,Mg={_A:Hn,_E:Hn},Ng={[kg]:Mg,[Ag]:Mg,[jg]:Mg,...ee,toJSON(){return{_id:`effect/Queue`,state:this.state._tag,size:Xg(this)}}},Pg=e=>li(t=>{let n=Object.create(Ng);return n.dispatcher=t.currentDispatcher,n.capacity=e?.capacity??1/0,n.strategy=e?.strategy??`suspend`,n.messages=xg(),n.scheduleRunning=!1,n.state={_tag:`Open`,takers:new Set,offers:new Set,awaiters:new Set},Tn(n)}),Fg=e=>Pg({capacity:e}),Ig=e=>Pg({capacity:e,strategy:`dropping`}),Lg=g(2,(e,t)=>Ur(()=>Rg(e,t)?Qg:e.state._tag===`Open`&&e.strategy===`suspend`?s_(e,t):Zg)),Rg=(e,t)=>e.state._tag===`Open`?e.messages.length>=e.capacity?e.strategy===`sliding`?(Og(e.messages),wg(e.messages,t),!0):e.capacity<=0&&e.state.takers.size>0&&(wg(e.messages,t),t_(e),!0):(wg(e.messages,t),n_(e),!0):!1,zg=g(2,(e,t)=>Bg(e,re(t))),Bg=g(2,(e,t)=>ai(()=>Vg(e,t))),Vg=(e,t)=>{if(e.state._tag!==`Open`)return!1;let n=Ge(t),r=Et(n,$g);return e.state.offers.size===0&&e.messages.length===0?(p_(e,r),!0):(e.state={...e.state,_tag:`Closing`,exit:r},n_(e),!0)},Hg=e=>Vg(e,re(ti())),Ug=e=>ai(()=>Wg(e)),Wg=e=>{if(e.state._tag===`Done`)return!1;Tg(e.messages);let t=e.state.offers;p_(e,e.state._tag===`Open`?e_:e.state.exit);for(let e of t)l_(e);return!0},Gg=e=>i_(()=>{if(e.state._tag===`Done`)return Ka(e.state.exit,()=>Tn([]));let t=f_(e);return d_(e),Tn(t)}),Kg=e=>qg(e,1,1/0),qg=g(3,(e,t,n)=>(t=pi(t),n=pi(n),i_(()=>r_(e,t,n)??Ye(o_(e,()=>a_(e,t)),qg(e,t,n))))),Jg=e=>i_(()=>Yg(e)??Ye(o_(e,()=>a_(e,1)),Jg(e))),Yg=e=>{if(e.state._tag===`Done`)return e.state.exit;if(e.messages.length>0){let t=Og(e.messages);return d_(e),$e(t)}if(e.capacity<=0&&e.state.offers.size>0){let t=u_(e.state.offers);return d_(e),$e(t)}},Xg=e=>e.state._tag===`Done`?0:e.messages.length,Zg=$e(!1),Qg=$e(!0),$g=Be(ti()),e_=ui(),t_=e=>{if(e.state._tag!==`Done`&&e.state.takers.size!==0){for(let t of e.state.takers)if(t.ready()&&(e.state.takers.delete(t),t.resume(bt),e.messages.length===0))break}},n_=e=>{e.scheduleRunning||e.state._tag===`Done`||e.state.takers.size===0||(e.scheduleRunning=!0,e.dispatcher.scheduleTask(()=>{e.scheduleRunning=!1,t_(e)},0))},r_=(e,t,n)=>{if(e.state._tag===`Done`)return e.state.exit;if(n<=0||t<=0)return $e([]);if(!a_(e,t))return;let r=e.messages.length>0?Eg(e.messages,n):[u_(e.state.offers)];return d_(e),$e(r)},i_=ot({op:`QueueTake`,[o](e){let t=this[gt]();return xe(t)?t[o](e):t}}),a_=(e,t)=>e.messages.length>=(e.state._tag===`Closing`?1:Math.min(t,e.capacity||1))||e.capacity<=0&&e.state._tag!==`Done`&&e.state.offers.size>0,o_=(e,t)=>s(n=>{if(e.state._tag===`Done`)return n(e.state.exit);if(t())return n(bt);let r={ready:t,resume:n};return e.state.takers.add(r),ai(()=>{e.state._tag!==`Done`&&e.state.takers.delete(r)})}),s_=(e,t)=>s(n=>Rg(e,t)?n(Qg):c_(e,{_tag:`Single`,message:t,resume:n})),c_=(e,t)=>{if(e.state._tag!==`Open`)return l_(t);let n=e.state.offers;return n.add(t),ai(()=>{e.state._tag!==`Done`&&(n.delete(t),e.state._tag===`Closing`&&n.size===0&&e.messages.length===0&&p_(e,e.state.exit))})},l_=e=>e._tag===`Single`?e.resume(Zg):e.resume($e(e.remaining.slice(e.offset))),u_=e=>{let t=e.values().next().value;if(t._tag===`Single`)return e.delete(t),t.resume(Qg),t.message;let n=t.remaining[t.offset++];return t.offset===t.remaining.length&&(e.delete(t),t.resume($e([]))),n},d_=e=>{if(e.state._tag===`Done`)return qa(e.state.exit.cause);if(e.state.offers.size===0)return e.state._tag===`Closing`&&e.messages.length===0&&(p_(e,e.state.exit),qa(e.state.exit.cause));for(let t of e.state.offers){let n=e.capacity-e.messages.length;if(n<=0)break;if(t._tag===`Single`)wg(e.messages,t.message),e.state.offers.delete(t),t.resume(Qg);else{for(;t.offset<t.remaining.length;t.offset++){if(n===0)return!1;wg(e.messages,t.remaining[t.offset]),n--}e.state.offers.delete(t),t.resume($e([]))}let r=e.state;if(r._tag===`Done`)return qa(r.exit.cause)}return!1},f_=e=>{if(e.messages.length>0){let t=Dg(e.messages);return d_(e),t}if(e.state._tag!==`Done`&&e.state.offers.size>0){let t=[u_(e.state.offers)];return d_(e),t}return[]},p_=(e,t)=>{if(e.state._tag===`Done`)return;let n=e.state;e.state={_tag:`Done`,exit:t};for(let e of n.takers)e.resume(t);n.takers.clear();for(let e of n.awaiters)e(t);n.awaiters.clear()},m_=he,h_=yr,g_=Me,__=n,v_=De,y_=Pn,b_=Cr,x_=e=>new C_(e),S_=(e,t,n)=>s(r=>{if(e.free>=t)return r(n);let i=()=>{e.free<t||(e.waiters.delete(i),r(n))};return e.waiters.add(i),ai(()=>{e.waiters.delete(i)})}),C_=class{waiters=new Set;taken=0;permits;constructor(e){this.permits=e}get free(){return this.permits-this.taken}take(e){let t=Ur(()=>this.free<e?S_(this,e,t):(this.taken+=e,Tn(e)));return t}takeIfAvailable(e){return Ur(()=>this.free<e?Tn(!1):(this.taken+=e,Tn(!0)))}releaseUnsafe(e,t){return this.taken-=t,this.waiters.size>0&&e.currentDispatcher.scheduleTask(()=>{for(let e of this.waiters){if(this.free<=0)break;e()}},0),this.free}resize(e){return li(t=>(this.permits=e,this.free<0||this.releaseUnsafe(t,0),ei))}release(e){return li(t=>Tn(this.releaseUnsafe(t,e)))}get releaseAll(){return li(e=>Tn(this.releaseUnsafe(e,this.taken)))}withPermits(e){return t=>$t(r=>{let i=Ur(()=>{if(this.free<e){let t=S_(this,e,ei);return rt(r(t),()=>i)}return this.taken+=e,Jt(r(t),()=>{this.releaseUnsafe(n(),e)},!0)});return i})}withPermit=this.withPermits(1);withPermitsIfAvailable(e){return t=>$t(r=>this.free<e?Ut:(this.taken+=e,Jt(r(Gn(t)),()=>{this.releaseUnsafe(n(),e)},!0)))}},w_=e=>ai(()=>new C_(e)),T_=`~effect/Channel`,E_=e=>Rr(e,T_),D_={[T_]:{_Env:Hn,_InErr:Hn,_InElem:Hn,_OutErr:Hn,_OutElem:Hn},pipe(){return Ze(this,arguments)}},O_=e=>{let t=Object.create(D_);return t.transform=(t,n)=>Ir(e(t,n),e=>b(Bt(e))),t},k_=(e,t)=>O_((n,r)=>E(M_(e)(n,r),e=>t(e,r))),A_=e=>O_((t,n)=>e),j_=e=>O_(ct(function*(t,n){let r=Ca(n),i=e=>wa(r,Za(e)),a=yield*fe(e(t,n,r),i);return fe(a,i)})),M_=e=>e.transform,N_=4096,P_=(e,t,n)=>Pg({capacity:n?.bufferSize,strategy:n?.strategy}).pipe(jn(t=>xa(e,Ug(t))),jn(n=>ya(t(n),e).pipe(Ir(e=>Bg(n,e)),qe(e)))),F_=(e,t)=>O_((n,r)=>be(P_(r,e,t),Kg)),I_=e=>O_((t,n)=>hr(()=>M_(e())(t,n))),L_=e=>A_(w(()=>{let t=e();return hr(()=>{let e=t.next();return e.done?Xi(e.value):b(e.value)})})),R_=(e,t=N_)=>{let n=mi(t);return A_(w(()=>{let t=e(),r=on();return hr(()=>{if(r._tag===`Some`)return Xi(r.value);let e=[];for(;e.length<n;){let n=t.next();if(n.done){if(e.length===0)return Xi(n.value);r=Br(n.value);break}e.push(n.value)}return b(e)})}))},z_=(e,t=N_)=>R_(()=>e[Symbol.iterator](),t),B_=e=>W_(b(e)),V_=A_(b(Xi())),H_=e=>A_(b(x(e))),U_=e=>A_(Bt(e)),W_=e=>A_(w(()=>{let t=!1;return hr(()=>t?Xi():(t=!0,e))})),G_=e=>A_(b(Kg(e))),K_=(e,t)=>O_(ct(function*(n,r){let i=e[Symbol.asyncIterator]();return i.return&&(yield*xa(r,Dt(()=>i.return()))),E(si({try:()=>i.next(),catch:t}),e=>e.done?Xi(e.value):b(e.value))})),q_=(e,t)=>J_(K_(e,t),St),J_=g(2,(e,t)=>k_(e,e=>w(()=>{let n=0;return be(e,e=>t(e,n++))}))),Y_=e=>e===void 0||e!==`unbounded`&&e<=1,X_=g(e=>E_(e[0]),(e,t,n)=>Y_(n?.concurrency)?Z_(e,t):Q_(e,t,n)),Z_=(e,t)=>O_((n,r)=>{let i=0;return be(M_(e)(n,r),E(e=>t(e,i++)))}),Q_=(e,t,n)=>j_(ct(function*(r,i,a){let o=0,s=yield*M_(e)(r,i),c=n.concurrency===`unbounded`?2**53-1:n.concurrency,l=yield*Fg(0);yield*xa(a,Ug(l));let u=ar(yield*vn()),d=v_(a);if(n.unordered){let e=x_(c),n=oe(e.release(1)),r=xt({onFailure:e=>E(Bg(l,e),n),onSuccess:e=>E(Lg(l,e),n)});yield*e.take(1).pipe(E(()=>s),E(e=>{let n=o++;return d(u(r(hr(()=>t(e,n))))),h}),pt({disableYield:!0}),Ir(t=>e.withPermits(c-1)(Bg(l,t))),qe(a))}else{let e=yield*Fg(c-2);yield*xa(a,Ug(e)),yield*Jg(e).pipe(Zr,E(e=>Lg(l,e)),pt({disableYield:!0}),Ir(e=>Bg(l,e)),qe(a));let n,r=e=>{e._tag!==`Success`&&(n=e.cause,Vg(l,e.cause))};yield*s.pipe(E(i=>{if(n)return Bt(n);let a=o++,s=u(hr(()=>t(i,a)));return d(s),s.addObserver(r),Lg(e,h_(s))}),pt({disableYield:!0}),Ir(t=>Lg(e,$i(t)).pipe(y(Bg(e,t)))),qe(a))}return Jg(l)})),$_=g(e=>E_(e[0]),(e,t,n)=>Y_(n?.concurrency)?ev(e,t):tv(e,t,n)),ev=(e,t)=>O_((n,r)=>be(M_(e)(n,r),e=>{let i,a,o=E(e,e=>(a??=Ca(r),Zt(M_(t(e))(n,a),e=>(i=s(e),i)))),s=Ka(e=>{if(i=void 0,a.state._tag===`Empty`)return o;let t=wa(a,na);return a=void 0,E(t,()=>o)});return hr(()=>i??o)})),tv=(e,t,n)=>e.pipe(J_(t),cv(n)),nv=e=>$_(e,Hn),rv=e=>k_(e,e=>{let t,n=0,r=hr(function r(){if(t===void 0)return E(e,e=>{switch(e.length){case 0:return r();case 1:return b(e[0]);default:return t=e,b(e[n++])}});let i=t[n++];return n>=t.length&&(t=void 0,n=0),b(i)});return b(r)}),iv=g(2,(e,t)=>k_(e,e=>b(E(e,function n(r){let i=[];for(let e=0;e<r.length;e++)t(r[e])&&i.push(r[e]);return at(i)?b(i):E(e,n)})))),av=g(2,(e,t)=>O_((n,r)=>{let i=Ca(r);return be(M_(e)(n,i),e=>{let a=e.pipe(Ir(e=>{if(qa(e))return Bt(e);let o=i;return i=Ca(r),wa(o,$i(e)).pipe(y(M_(t(e))(n,i)),E(e=>(a=e,e)))}));return hr(()=>a)})})),ov=g(3,(e,t,n)=>av(e,e=>{let r=t(e);return pe(r)?U_(r.failure):n(r.success,e)})),sv=g(2,(e,t)=>ov(e,Gi,e=>t(e))),cv=g(2,(t,{bufferSize:n=16,concurrency:r,switch:i=!1})=>j_(ct(function*(a,o,s){let c=r===`unbounded`?2**53-1:Math.max(1,r),l=i?void 0:x_(c),u=yield*b_(!0),d=new Set,f=yield*Fg(n);yield*xa(s,Ug(f));let p=yield*M_(t)(a,o);return yield*S(function*(){for(;;){let t;l&&(d.size<c?yield*l.take(1):(t=yield*ae(p),yield*e(l.take(1),y(h_(t),Tt))));let n=t===void 0?yield*p:yield*h_(t),r=Ca(s),i=yield*M_(n)(a,r);for(;d.size>=c;){let e=hi(d);d.delete(e),d.size===0&&(yield*u.open),yield*g_(e)}let o=yield*i.pipe(jn(()=>_t),E(e=>Lg(f,e)),pt({disableYield:!0}),fe(ct(function*(e){let t=Za(e),n=yield*Dn(wa(r,t));if(!d.has(o))return;let i=oa([t,n]);ia(i)&&(yield*Bg(f,i.cause)),d.delete(o),l&&(yield*l.release(1)),d.size===0&&(yield*u.open)})),ae);u.closeUnsafe(),d.add(o)}}).pipe(Ir(e=>{let t=Ya(e);return Ae(t)?u.whenOpen(Bg(f,e)):Bg(f,e)}),qe(s)),Jg(f)}))),lv=g(e=>E_(e[0])&&E_(e[1]),(e,t,n)=>j_(ct(function*(r,i,a){let o=n?.haltStrategy??`both`,s=yield*Fg(0);yield*xa(a,Ug(s));let c=0;function l(e,t){if(c++,!qa(t))return Bg(s,t);switch(o){case`both`:return c===2?Bg(s,t):h;case`left`:case`right`:return e===o?Bg(s,t):h;case`either`:return Bg(s,t)}}let u=(e,t,n)=>M_(t)(r,n).pipe(E(e=>e.pipe(E(e=>Lg(s,e)),pt)),fe(t=>gr(Za(t),e=>wa(n,e)).pipe(xt({onFailure:t=>l(e,t),onSuccess:()=>l(e,t)}))),qe(a));return yield*u(`left`,e,Ca(a)),yield*u(`right`,t,Ca(a)),Jg(s)}))),uv=e=>O_((t,n)=>{let r;return b(hr(()=>r||e.pipe(ya(n),E(e=>M_(e)(t,n)),E(e=>r=e))))}),dv=g(2,(e,t)=>lv(e,A_(b(E(t,Xi))),{haltStrategy:`either`})),fv=g(2,(e,t)=>j_((n,r,i)=>ba(i,t).pipe(y(M_(e)(n,r))))),pv=g(2,(e,t)=>fv(e,e=>t)),mv=(e,t,n)=>hr(()=>{let r=va(),i=M_(e)(Xi(),r);return Ka(E(i,t),n||b).pipe(Oe(e=>wa(r,e)))}),hv=g(2,(e,t)=>mv(e,e=>pt(E(e,t),{disableYield:!0}))),gv=ct(function*(e){let t=x_(1),n=yield*vn(),r=We(n,ga);return(yield*M_(e)(Xi(),r)).pipe(Ft(n),t.withPermits(1))},Ir(e=>b(Bt(e)))),_v=(e,t)=>M_(e)(Xi(),t),vv=`~effect/Stream`,yv={_R:Hn,_E:Hn,_A:Hn},bv=function(e){this.channel=e};bv.prototype={[vv]:yv,pipe(){return Ze(this,arguments)}};var xv=e=>new bv(e),Sv=`~effect/Sink`,Cv={_A:Hn,_In:Hn,_L:Hn,_E:Hn,_R:Hn},wv={[Sv]:Cv,pipe(){return Ze(this,arguments)}},Tv=e=>{let t=Object.create(wv);return t.transform=e,t},Ev=((e,t,n)=>Tv(r=>{let i=e(),a;return t(i)?r.pipe(E(e=>{for(let r=0;r<e.length;r++)if(i=n(i,e[r]),!t(i))return r+1<e.length&&(a=e.slice(r+1)),Xi();return h}),pt({disableYield:!0}),Ka(()=>b([i,a]))):b([i])}))(on,ir,(e,t)=>Br(t)),Dv=()=>Ev,Ov=`~effect/Stream`,kv=e=>Rr(e,Ov),Av=xv,jv=e=>Av(W_(be(e,St))),Mv=e=>Pv(b(E(e,()=>Xi()))),Nv=e=>Pv(b(be(e,St))),Pv=e=>Av(A_(e)),Fv=(e,t)=>Av(O_((n,r)=>E(_v(e.channel,r),e=>t(e,r)))),Iv=e=>e.channel,Lv=(e,t)=>Av(F_(e,t)),Rv=Av(V_),zv=e=>Av(B_(St(e))),Bv=e=>Av(I_(()=>e().channel)),Vv=e=>Av(H_(e)),Hv=e=>Av(U_(e)),Uv=(e,t)=>Array.isArray(e)&&t?.chunkSize===void 0?Wv(e):Av(z_(e,t?.chunkSize)),Wv=e=>at(e)?Av(B_(e)):Rv,Gv=e=>Av(G_(e)),Kv=(e,t)=>Av(q_(e,t)),qv=(e,t)=>Pv(w(()=>{let n=e,r=!1;return hr(function e(){return r?Xi():E(t(n),([t,i])=>(ir(i)?r=!0:n=i.value,at(t)?b(t):e()))})})),Jv=e=>Av(uv(be(e,Iv))),Yv=g(2,(e,t)=>Bv(()=>{let n=0;return Av(J_(e.channel,l(e=>t(e,n++))))})),Xv=g(e=>kv(e[0]),(e,t,n)=>e.channel.pipe(rv,X_(t,n),J_(St),Av)),Zv=e=>e.pipe(Yv(kt),cy(e=>zv(_e(e)))),Qv=g(e=>kv(e[0]),(e,t,n)=>e.channel.pipe(rv,$_(e=>t(e).channel,n),Av)),$v=g(2,(e,t)=>{let n=m(t.duration);if(!Jr(n))return e;if(ht(n))return Bv(t.orElse);let r=Symbol();return sy(Bv(()=>{let t=__().getRef(Ta),i=ne(n),a,o=y_(!1);return iy(Fv(e,(e,n)=>hr(()=>(a=t.currentTimeMillisUnsafe()+i,o.openUnsafe(),e)).pipe(be(e=>(o.closeUnsafe(),a=void 0,e)),b)),Mv(S(function*(){for(;;)if(yield*o.await,a!==void 0&&(yield*fn(a-t.currentTimeMillisUnsafe()),a!==void 0&&!(a-t.currentTimeMillisUnsafe()>0)))return yield*ur(r)})),{haltStrategy:`left`})}),e=>e.reasons.find(e=>e._tag===`Die`&&e.defect===r)?t.orElse():Hv(e))}),ey=e=>Qv(e,Uv),ty=g(2,(e,t)=>{let n=Av(nv(L_(()=>ry(e,t))));return ny.set(n,[e,t]),n}),ny=new WeakMap;function*ry(e,t){let n=[t,e];for(;n.length>0;){let e=n.pop(),t=ny.get(e);t===void 0?yield e.channel:n.push(t[1],t[0])}}var iy=g(e=>kv(e[0])&&kv(e[1]),(e,t,n)=>Av(lv(Iv(e),Iv(t),n))),ay=g(2,(e,t)=>Av(iv(Iv(e),t))),oy=g(2,ct(function*(e,t){let n,r=yield*gv(e.channel),i=Ir(r,e=>(n=e,Bt(e))),[a,o]=yield*Yn(e=>t.transform(i,e)),s=n?Rv:Pv(b(r));return o&&(s=ty(Wv(o),s)),[a,s]})),sy=g(2,(e,t)=>e.channel.pipe(av(e=>t(e).channel),Av)),cy=g(2,(e,t)=>Av(sv(e.channel,e=>t(e).channel))),ly=g(e=>kv(e[0]),(e,t,n)=>Fv(e,(e,r)=>w(()=>{let r=0,i=!1;return E(hr(()=>i?Xi():e),e=>{let a=e.findIndex(e=>t(e,r++));if(a>=0){i=!0;let t=e.slice(0,n?.excludeLast?a:a+1);return at(t)?b(t):Xi()}return b(e)})}))),uy=g(2,(e,t)=>Av(dv(e.channel,t))),dy=g(2,(e,t)=>Av(pv(e.channel,t))),fy=g(2,(e,t)=>hv(e.channel,e=>{let n=0;return Xr({while:()=>n<e.length,body:()=>t(e[n++]),step:mt})})),py=g(2,(e,t)=>({[Symbol.asyncIterator](){let n=In(t),r=ar(t),i=va(),a,o,s,c,l=e=>{if(c)return c;let t=s;return c=n(Er(y(t?g_(t):h,wa(i,e)),{done:!0,value:void 0})),c},u=async e=>{try{await l(e)}catch(e){await n(Xe(`Suppressed error while closing Stream async iterator`,e))}};return{async next(){if(c)return c;if(o){let e=o.next();if(!e.done)return e;o=void 0}let t=r(a??E(_v(e.channel,i),e=>(a=e,e)));s=t;let d=await n(m_(t));if(s===t&&(s=void 0),ra(d))return o=d.value[Symbol.iterator](),o.next();if(qa(d.cause))return l(na);if(c&&Hi(d.cause))return c;throw await u(d),Wi(d.cause)},return(){return l(na)},async throw(e){throw await u(ta(e)),e}}}})),my=e=>py(e,ze()),hy=15e3,gy=45e3,_y=Th.check(fh(256)),vy=U.check(H(0)),yy=F({agentId:_y,sessionId:_y,name:_y}),by=F({id:_y,kind:Th.check(fh(64)),summary:Th.check(fh(200)),since:vy,expiresAt:j(vy),inbox:j(M(!1)),waitingOn:j(yy)}),xy=by.mapFields(e=>({...e,extensionId:_y})),Sy=4096,Cy=I(xy).check(fh(64)),wy=N.pipe(B(lh(1)),B(fh(256))),Ty=F({providerId:wy,modelId:wy,reasoning:j(R([`minimal`,`low`,`medium`,`high`,`xhigh`,`max`]))}),Ey=k(z(Ty)),Dy=k(W(z(Ty))),Oy=R([`contract`,`extensions`,`instructions`,`model`,`runtime`,`store`,`tools`]),ky=R([`closed`,`conflict`,`incompatible`,`invalid`,`rejected`,`unavailable`,`state_reset_required`,`storage_pressure`,`archived`]),Ay=N.pipe(B(lh(1)),B(fh(256))),jy=F({_tag:M(`ShiitakeError`),boundary:Oy,cause:ky,message:N,requestId:A(Ay)}),G=class extends Error{boundary;requestId;_tag=`ShiitakeError`;cause;underlying;constructor(e,t,n,r,i){super(n),this.boundary=e,this.requestId=r,this.name=`ShiitakeError`,this.cause=t,this.underlying=i}},My=new TextEncoder;function Ny(e){return N.check(lh(1),fh(e),V(t=>My.encode(t).byteLength<=e))}var Py=/\p{Cs}/u,Fy=Ny(256).check(V(e=>!Py.test(e))),Iy=Ny(262144),Ly=F({type:M(`image`),data:N.check(lh(1),fh(1048576),jm()),mimeType:N.check(V(e=>[`image/png`,`image/jpeg`,`image/gif`,`image/webp`].includes(e)))}),Ry=I(Ly).check(lh(1),fh(8)),zy=R([`steer`,`followUp`]),By=Fy,Vy=O(F({commandId:Fy,timeoutMs:U.check(H(0),Km(3e4))}),{onExcessProperty:`error`});O(F({commandId:Fy,timeoutMs:kh.check(Ym(),qm({minimum:0,maximum:3e4}))}),{onExcessProperty:`error`});var Hy=O(Ny(512)),Uy=F({requestId:Fy}),Wy=F({delivery:zy,requestId:Fy,type:M(`prompt`),text:N.check(fh(262144),V(e=>My.encode(e).byteLength<=262144)),images:A(Ry)}).check(V(e=>(e.text.length>0||(e.images?.length??0)>0)&&My.encode(e.text).byteLength+(e.images??[]).reduce((e,t)=>e+t.data.length,0)<=1048576)),Gy=F({type:M(`abort`)}),Ky=F({commandId:Fy,onlyIfPending:j(nm),type:M(`cancel`)}),qy=F({type:M(`operator`),requestId:Fy,author:R([`operator`,`party`]),text:Iy}),Jy=F({type:M(`branch`),entryId:Fy}),Yy=F({type:M(`fork`),entryId:Fy}),Xy=N.check(lh(1),fh(4096)),Zy=F({type:M(`compact`),requestId:Fy,instructions:A(Xy)}),Qy=L([Wy,Zy]),$y=N.check(V(e=>e.length>0&&e.trim()===e&&!/\p{Cc}/u.test(e)&&Array.from(e).length<=120)),eb=L([Wy,Gy,Ky,Jy,Yy,qy,Zy,F({type:M(`title`),title:z($y)})]),tb=F({command:eb}),nb=F({includeSandboxFailures:j(nm),limit:j(U.check(qm({minimum:1,maximum:200}))),before:j(Ny(512))}),rb=F({includeSandboxFailures:j(M(`true`)),limit:j(kh.check(Ym(),qm({minimum:1,maximum:200}))),before:j(Ny(512))}),ib=F({includeSandboxFailures:j(nm),after:j(N)}),ab=F({includeSandboxFailures:j(M(`true`)),mode:j(M(`subscribe`)),after:j(N),limit:j(kh.check(Ym(),qm({minimum:1,maximum:200})))}),ob={onExcessProperty:`error`},sb=O(By,ob),cb=O(Uy,ob),lb=O(Qy,ob);O(Fy);var ub=O(eb,ob);O(tb,ob);var db=O(L([nb,tm]),ob);O(rb,ob);var fb=O(ib,ob);O(ab,ob);function pb(e){let t=sb(e);if(t._tag===`Failure`)throw new G(`contract`,`invalid`,`Session id is invalid`);return t.success}function mb(e){let t=Hy(e);if(t._tag===`Failure`)throw new G(`contract`,`invalid`,`Session cursor is invalid`);return t.success}function hb(e){let t=cb(e);if(t._tag===`Failure`)throw new G(`contract`,`invalid`,`Session creation request is invalid`);return t.success.requestId}function gb(e){let t=db(e);if(t._tag===`Failure`)throw new G(`contract`,`invalid`,`Read options are invalid`);let n=t.success??{},r={limit:n.limit??200};return n.before!==void 0&&(r={...r,before:n.before}),n.includeSandboxFailures!==void 0&&(r={...r,includeSandboxFailures:n.includeSandboxFailures}),Object.freeze(r)}function _b(e){let t=fb(e);if(t._tag===`Failure`)throw new G(`contract`,`invalid`,`Subscribe options are invalid`);let n={};return t.success.after!==void 0&&(n={...n,after:t.success.after}),t.success.includeSandboxFailures!==void 0&&(n={...n,includeSandboxFailures:t.success.includeSandboxFailures}),Object.freeze(n)}function vb(e,t){if(pe(e))throw new G(`contract`,`invalid`,t);return e.success}var yb=nn();function bb(e){return e!==null&&!Array.isArray(e)&&typeof e==`object`}function xb(e,t){if(e===t)return 0;let n=Math.min(e.length,t.length);for(let r=0;r<n;r+=1){let n=e.charCodeAt(r)-t.charCodeAt(r);if(n!==0)return n}return e.length-t.length}function Sb(e){return e.replace(/([a-z])([A-Z])/g,`$1 $2`).replace(/([A-Z]+)([A-Z][a-z])/g,`$1 $2`).replace(/[_./:-]/g,` `).toLowerCase().trim()}function Cb(e){return e.split(/[^a-zA-Z0-9]+/).filter(e=>e.length>0)}var wb=new Set([`the`,`a`,`an`,`for`,`to`,`of`,`that`,`this`,`with`,`in`,`on`]);function Tb(e){return wb.has(e)}function Eb(e){let t=[],n=n=>{n!==e&&n.length>=3&&!t.includes(n)&&t.push(n)};return e.endsWith(`ing`)&&e.length>4&&n(e.slice(0,-3)),e.endsWith(`ed`)&&e.length>3&&n(e.slice(0,-2)),e.endsWith(`ation`)&&e.length>6&&n(`${e.slice(0,-3)}e`),e.endsWith(`ies`)&&e.length>4&&(n(e.slice(0,-3)),n(`${e.slice(0,-3)}y`)),e.endsWith(`es`)&&e.length>3&&n(e.slice(0,-2)),e.endsWith(`s`)&&!e.endsWith(`ss`)&&e.length>3&&n(e.slice(0,-1)),t}function Db(e){let t=8997,n=33826,r=40164,i=52210;for(let a=0;a<e.length;a+=1){let o=t^e.charCodeAt(a),s=o*435,c=n*435+(s>>>16),l=r*435+(c>>>16)+(o<<8),u=i*435+(l>>>16)+(n<<8);t=s&65535,n=c&65535,r=l&65535,i=u&65535}return i.toString(16).padStart(4,`0`)+r.toString(16).padStart(4,`0`)+n.toString(16).padStart(4,`0`)+t.toString(16).padStart(4,`0`)}function Ob(e){return e.slice(e.indexOf(`.`)+1)}function kb(e){return e.slice(0,e.indexOf(`.`))}var Ab=/^[A-Za-z][A-Za-z0-9_]*(?:\.[A-Za-z][A-Za-z0-9_]*)+$/,jb=1e3,Mb=221;function Nb(e,t){if(t>16)return t;if(Array.isArray(e)){let n=t;for(let r of e)n=Math.max(n,Nb(r,t+1));return n}if(!bb(e))return t;let n=t;for(let r of Object.values(e))n=Math.max(n,Nb(r,t+1));return n}var Pb=C(()=>Cn(T(),nn()).superRefine((e,t)=>{Object.keys(e).length>100&&t.addIssue({code:`custom`,message:`Sample exceeds the entry bound`}),JSON.stringify(e).length>4e3&&t.addIssue({code:`custom`,message:`Sample exceeds the byte bound`}),Nb(e,0)>16&&t.addIssue({code:`custom`,message:`Sample exceeds the depth bound`})})),Fb=C(()=>Zn({query:T().max(200),maxResults:dr().int().min(1).max(50).default(50)})),Ib=C(()=>Zn({path:T().max(160),detail:Te([`index`,`full`]).default(`full`),methods:pn(T().max(80)).max(50).optional()})),Lb=Zn({cursor:T().max(400).optional(),limit:dr().int().min(1).max(50).default(50),namespace:T().min(1).max(160).regex(/^[A-Za-z][A-Za-z0-9_]*(?:\.[A-Za-z][A-Za-z0-9_]*)*$/).optional()}),Rb=C(()=>Zn({path:T().max(160),capabilityNotes:T().max(500).optional()})),zb=Zn({path:T().max(160),description:T().max(1e3).optional(),score:dr().min(0).max(Mb),matchReason:T().max(500).optional(),sample:Pb.optional(),capabilityNotes:T().max(500).optional(),peers:pn(Rb).max(1e3).optional()}),Bb=C(()=>Zn({results:pn(zb).max(50),total:dr().int().min(0).max(jb),truncated:xr(),topScore:dr().min(0).max(Mb),margin:dr().min(0).max(Mb),catalogStamp:T().length(16).regex(/^[0-9a-f]{16}$/)})),Vb=Zn({results:pn(zb).max(50),total:dr().int().min(0).max(jb),nextCursor:T().max(400).nullable(),catalogStamp:T().length(16).regex(/^[0-9a-f]{16}$/)}),Hb=C(()=>Zn({path:T().max(160),description:T().max(1e3).optional(),types:T().max(2e4),inputSchema:nn().refine(e=>JSON.stringify(e).length<=2e4&&Nb(e,0)<=16,`Input schema exceeds the description bounds`).optional(),kind:Te([`module`,`operation`]),usage:T().max(300).optional()}));C(()=>Zn({code:Te([`empty_query`,`empty_catalog`,`unknown_target`,`duplicate_operation`,`invalid_input`]),message:T().max(1e3)}));var Ub=C(()=>Zn({"~standard":Zn({jsonSchema:Zn({input:Ot(Function),output:Ot(Function)})})})),Wb=C(()=>Nn(e=>Ub.safeParse(e).success,`Expected a Standard JSON Schema`)),Gb=C(()=>Zn({path:T().min(3).max(160).regex(Ab),description:T().max(1e3).optional(),input:Wb,output:Wb.optional(),capabilityNotes:T().max(500).optional(),instructions:T().max(1e3).optional()})),Kb=C(()=>Zn({revision:T().min(1).max(160),operations:pn(Gb).max(jb)})),qb=class extends Error{code;failure;constructor(e,t,n){let r=t.slice(0,1e3);super(r,n),this.name=`ForageError`,this.code=e,this.failure={code:e,message:r}}},Jb=Qr([ln({$ref:T().optional(),$defs:Cn(T(),lt()).optional(),definitions:Cn(T(),lt()).optional(),const:lt().optional(),enum:pn(lt()).optional(),oneOf:pn(lt()).optional(),anyOf:pn(lt()).optional(),allOf:pn(lt()).optional(),type:Qr([T(),pn(T())]).optional(),properties:Cn(T(),lt()).optional(),additionalProperties:lt().optional(),required:pn(T()).optional(),prefixItems:pn(lt()).optional(),items:lt().optional(),examples:pn(lt()).optional(),default:lt().optional()}),xr()]),Yb=new WeakMap;function Xb(e,t){let n=Yb.get(e),r=n?.[t];if(r!==void 0)return r;let i;try{i=e[`~standard`].jsonSchema[t]({target:`draft-2020-12`})}catch{throw new qb(`invalid_input`,`Schema cannot be projected to JSON Schema`)}$b(i);let a={raw:i};return n===void 0&&(n={},Yb.set(e,n)),n[t]=a,a}function Zb(e,t){return Xb(e,t).raw}function Qb(e,t){let n=Xb(e,t);try{return n.text??=JSON.stringify(n.raw),n.text}catch{throw new qb(`invalid_input`,`Schema cannot be projected to JSON Schema`)}}function $b(e){let t=Jb.safeParse(e);if(!t.success)throw new qb(`invalid_input`,`Schema cannot be projected to JSON Schema`);return t.data}var ex=256,tx=/^#\/(?:\$defs|definitions)\/([^/]+)$/u;function nx(e,t,n){let r=tx.exec(e)?.[1];if(r===void 0||n.expanding.has(r))return`unknown`;let i=n.definitions[r];if(i===void 0)return`unknown`;if(n.budget.expansions+=1,n.budget.expansions>ex)throw new qb(`invalid_input`,`Schema references expand more than ${String(ex)} times; flatten its shared definitions`);return ix($b(i),t,{definitions:n.definitions,expanding:new Set([...n.expanding,r]),budget:n.budget})}function rx(e,t){if(e===!0||e===!1)return!1;if(e.$ref!==void 0){let n=tx.exec(e.$ref)?.[1],r=n===void 0||t.expanding.has(n)?void 0:t.definitions[n];return n!==void 0&&r!==void 0&&rx($b(r),{definitions:t.definitions,expanding:new Set([...t.expanding,n]),budget:t.budget})}return e.const===void 0?e.enum!==void 0&&e.enum.length>1||e.oneOf!==void 0&&e.oneOf.length>1||e.anyOf!==void 0&&e.anyOf.length>1:!1}function ix(e,t,n){if(t>12||e===!0||e===!1)return`unknown`;let r=n??{definitions:{...e.definitions,...e.$defs},expanding:new Set,budget:{expansions:0}};if(e.$ref)return nx(e.$ref,t,r);if(e.const!==void 0)return JSON.stringify(e.const);if(e.enum)return e.enum.map(e=>JSON.stringify(e)).join(` | `);if(e.oneOf)return e.oneOf.map(e=>ix($b(e),t+1,r)).join(` | `);if(e.anyOf)return e.anyOf.map(e=>ix($b(e),t+1,r)).join(` | `);if(e.allOf)return e.allOf.map(e=>{let n=$b(e),i=ix(n,t+1,r);return rx(n,r)?`(${i})`:i}).join(` & `);if(e.type===`object`||e.properties){let n=Object.entries(e.properties??{}).sort(([e],[t])=>xb(e,t));if(n.length===0){let n=e.additionalProperties;return n===!1?`Record<string, never>`:n&&n!==!0?`Record<string, ${ix($b(n),t+1,r)}>`:`Record<string, unknown>`}let i=new Set(e.required??[]);return`{
4
4
  ${n.map(([e,n])=>{let a=ix($b(n),t+1,r),o=i.has(e)?``:`?`,s=/^[A-Za-z_$][A-Za-z0-9_$]*$/.test(e)?e:JSON.stringify(e);return`${` `.repeat(t+1)}${s}${o}: ${a};`}).join(`
@@ -15,7 +15,7 @@ Defaulting to 2020, but this will stop working in the future.`)),t.ecmaVersion=1
15
15
  `;break;default:e+=String.fromCharCode(n)}this.options.locations&&(++this.curLine,this.lineStart=this.pos),t=this.pos}else++this.pos}},Q.readInvalidTemplateToken=function(){for(;this.pos<this.input.length;this.pos++)switch(this.input[this.pos]){case`\\`:++this.pos;break;case`$`:if(this.input[this.pos+1]!==`{`)break;case"`":return this.finishToken(J.invalidTemplate,this.input.slice(this.start,this.pos));case`\r`:this.input[this.pos+1]===`
16
16
  `&&++this.pos;case`
17
17
  `:case`\u2028`:case`\u2029`:++this.curLine,this.lineStart=this.pos+1}this.raise(this.start,`Unterminated template`)},Q.readEscapedChar=function(e){var t=this.input.charCodeAt(++this.pos);switch(++this.pos,t){case 110:return`
18
- `;case 114:return`\r`;case 120:return String.fromCharCode(this.readHexChar(2));case 117:return oC(this.readCodePoint());case 116:return` `;case 98:return`\b`;case 118:return`\v`;case 102:return`\f`;case 13:this.input.charCodeAt(this.pos)===10&&++this.pos;case 10:return this.options.locations&&(this.lineStart=this.pos,++this.curLine),``;case 56:case 57:if(this.strict&&this.invalidStringToken(this.pos-1,`Invalid escape sequence`),e){var n=this.pos-1;this.invalidStringToken(n,`Invalid escape sequence in template string`)}default:if(t>=48&&t<=55){var r=this.input.substr(this.pos-1,3).match(/^[0-7]+/)[0],i=parseInt(r,8);return i>255&&(r=r.slice(0,-1),i=parseInt(r,8)),this.pos+=r.length-1,t=this.input.charCodeAt(this.pos),(r!==`0`||t===56||t===57)&&(this.strict||e)&&this.invalidStringToken(this.pos-1-r.length,e?`Octal literal in template string`:`Octal literal in strict mode`),String.fromCharCode(i)}return YS(t)?(this.options.locations&&(this.lineStart=this.pos,++this.curLine),``):String.fromCharCode(t)}},Q.readHexChar=function(e){var t=this.pos,n=this.readInt(16,e);return n===null&&this.invalidStringToken(t,`Bad character escape sequence`),n},Q.readWord1=function(){this.containsEsc=!1;for(var e=``,t=!0,n=this.pos,r=this.options.ecmaVersion>=6;this.pos<this.input.length;){var i=this.fullCharCodeAtPos();if(VS(i,r))this.pos+=i<=65535?1:2;else if(i===92){this.containsEsc=!0,e+=this.input.slice(n,this.pos);var a=this.pos;this.input.charCodeAt(++this.pos)!==117&&this.invalidStringToken(this.pos,`Expecting Unicode escape sequence \\uXXXX`),++this.pos;var o=this.readCodePoint();(t?BS:VS)(o,r)||this.invalidStringToken(a,`Invalid Unicode escape`),e+=oC(o),n=this.pos}else break;t=!1}return e+this.input.slice(n,this.pos)},Q.readWord=function(){var e=this.readWord1(),t=J.name;return this.keywords.test(e)&&(t=KS[e]),this.finishToken(t,e)},PC.acorn={Parser:PC,version:`8.18.0`,defaultOptions:dC,Position:cC,SourceLocation:lC,getLineInfo:uC,Node:rw,TokenType:HS,tokTypes:J,keywordTypes:KS,TokContext:JC,tokContexts:YC,isIdentifierChar:VS,isIdentifierStart:BS,Token:Jw,isNewLine:YS,lineBreak:qS,lineBreakG:JS,nonASCIIwhitespace:ZS};function Qw(e,t){return PC.parse(e,t)}C(()=>Kt(`ok`,[Vt({ok:Lr(!0),value:lt()}),Vt({ok:Lr(!1),error:Vt({kind:Lr(`guest_threw`),name:T().max(80),message:T().max(512),transportMessage:T().max(512).optional()})})]));var $w=C(()=>T().regex(/^[A-Za-z][A-Za-z0-9_]*$/u)),eT=$w.refine(e=>{if(e===`env`)return!1;try{return Qw(`let ${e};`,{ecmaVersion:`latest`,sourceType:`module`}),!0}catch(e){if(!(e instanceof SyntaxError))throw e;return!1}},`Invalid sandbox transport alias`);C(()=>Cn(eT,pn($w).min(1))),C(()=>Cn(eT,pn(T().regex(/^[A-Za-z][A-Za-z0-9_]*(?:\.[A-Za-z][A-Za-z0-9_]*)*$/u))));var tT=R([`read`,`write`]),nT=nm,rT=F({access:j(tT),confirm:j(nT)}),iT=R([`none`,`read`,`write`]),aT=O(rT),oT=O(iT);function sT(e){let t=aT({access:e.access,confirm:e.confirm});if(pe(t))throw new K(`Access labels must be access: "read" | "write" and confirm: boolean`);return{access:t.success.access??`write`,confirm:t.success.confirm??!1}}function cT(e,t){let n=`${t.module}.${t.operation}`;switch(e){case`not-granted`:return`${n} is not granted to this Agent.`;case`read-only`:return`${n} changes something, and this Agent has read-only access to ${t.module}.`;case`confirmation-unavailable`:return`${n} needs a person's approval, and no one can be asked here.`;case`declined`:return`${n} was not approved.`}}function lT(e,t){return Object.freeze({refused:!0,module:t.module,operation:t.operation,reason:e,message:cT(e,t)})}function uT(e,t,n){let r=e.sessionGrants?.(t),i=r!==void 0&&Object.hasOwn(r,n)?r:e.grants;if(i===void 0||!Object.hasOwn(i,n))return e.required?.includes(n)===!0?`none`:e.defaultGrant??`write`;let a=oT(i[n]);return Ae(a)?a.success:`none`}async function dT(e,t,n,r,i){let a=await fT(e,t,n,r,i);return a!==void 0&&e.onRefused?.(a,t),a}async function fT(e,t,n,r,i){await e.beforeCall?.(i),i.throwIfAborted();let a=pT(e,t,n);if(a!==void 0)return a;if(!(!n.confirm&&(e.confirmWrites!==!0||n.access===`read`)))return e.confirm===void 0?lT(`confirmation-unavailable`,n):await e.confirm({module:n.module,operation:n.operation,access:n.access,sessionId:t.sessionId,input:r},i)?(await e.beforeCall?.(i),i.throwIfAborted(),pT(e,t,n)):lT(`declined`,n)}function pT(e,t,n){let r=uT(e,t,n.module);if(r===`none`)return lT(`not-granted`,n);if(r===`read`&&n.access!==`read`)return lT(`read-only`,n)}function mT(e,t,n){let r={module:e.module,operation:e.descriptor.name,...sT(e)};return{...e,prepare:i=>si({try:e=>dT(t,n,r,i.arguments,e),catch:()=>({message:`Access check failed`})}).pipe(E(t=>t===void 0?e.prepare(i):b({execute:()=>zv({type:`result`,result:{content:[{type:`text`,text:JSON.stringify(t)}],isError:!1}})})))}}var hT=_s();async function gT(e){let t=await Tr(e);if(ra(t))return{value:t.value};let n=Gi(t.cause);if(pe(n))throw Wi(t.cause);return{issues:hT(n.success.issue).issues}}function _T(e){let t=Wh(e),n=Pp(t)[`~standard`].jsonSchema,r=Ip(t),i=Vp(t);return Object.freeze({description:{"~standard":{jsonSchema:{input:n.input,output:n.input}}},decode:e=>gT(r(e)),encode:e=>gT(i(e))})}function vT(e){let t=async t=>e[`~standard`].validate(t);return Object.freeze({description:e,decode:t,encode:t})}function yT(e){return Jp(e)?_T(e):vT(e)}var bT=Symbol(`mycelium.operation`),xT=Symbol(`mycelium.module`),ST=new WeakMap,CT=new WeakMap;function wT(e){let t=Object.freeze({[bT]:!0}),n=yT(e.input),r=e.output===void 0?void 0:yT(e.output),i={replay:e.replay??`unsafe`,...sT(e),input:n.description,invoke:async(t,i)=>{let a=await n.decode(t);if(a.issues!==void 0)throw new eS(a.issues);let o=await e.execute(a.value,i);if(r===void 0)return o;let s=await r.encode(o);if(s.issues!==void 0)throw new lS({reason:`Capability output failed its declared schema`,rawCause:new tS(s.issues)});return s.value}};e.description!==void 0&&(i.description=e.description),r!==void 0&&(i.output=r.description);let a=Object.freeze(i);return ST.set(t,a),t}function TT(e){let t=pn($w).safeParse(e.namespace??[]);if(!t.success)throw new K(`Invalid module namespace`);let n=Object.freeze({[xT]:!0}),r={id:e.id,grantKey:e.id,name:e.name??e.id,namespace:Object.freeze(t.data),operations:Object.freeze({...e.operations})};e.description!==void 0&&(r.description=e.description);let i=Object.freeze(r);return CT.set(n,i),n}function ET(e){return CT.has(e)}function DT(e){return ST.get(e)}function OT(e){return CT.get(e)}function kT(e,t,n){let r=OT(e);if(r===void 0)throw new K(`Unknown module registration`);let i={};for(let[e,a]of Object.entries(r.operations)){let r=n===``?e:`${n}.${e}`;if(ET(a)){let n=OT(a);if(n===void 0)throw new K(`Unknown child module registration`);i[e]=kT(a,t,[r,...n.namespace].join(`.`));continue}let o=DT(a);if(o===void 0)throw new K(`Unknown operation registration: ${e}`);let s=Object.freeze({[bT]:!0});ST.set(s,Object.freeze({...o,invoke:async(e,n)=>{let i=await t({operation:r,context:n});return i.kind===`refuse`?i.value:await o.invoke(e,n)}})),i[e]=s}return AT(TT(r.description===void 0?{id:r.id,name:r.name,namespace:r.namespace,operations:i}:{id:r.id,name:r.name,namespace:r.namespace,description:r.description,operations:i}),r.grantKey)}function AT(e,t){let n=OT(e);if(n===void 0)throw new K(`Unknown module registration`);let r=Object.freeze({[xT]:!0});return CT.set(r,Object.freeze({...n,grantKey:t})),r}function jT(e,t){if(t.length===0||t.length>160)throw new K(`Grant key must be non-empty and bounded`);return AT(e,t)}function MT(e,t){return kT(e,t,``)}function NT(e,t){return e<t?-1:+(e>t)}function PT(e){return e instanceof Error?e.message:`Capability declarations could not be compiled`}var FT=160;function IT(e){if(e.length===0||e.length>FT)throw new K(`Module id must be non-empty and bounded`)}function LT(e){if(!e.split(`.`).every(e=>$w.safeParse(e).success))throw new K(`Operation key must be a path segment or a dotted relative path`)}function RT(e){let t=e.replace(/[^A-Za-z0-9_]/g,`_`);return/^[A-Za-z]/.test(t)?t:`module_${t}`}function zT(e){let t=RT(e);return eT.safeParse(t).success?t:`module_${t}`}function BT(e,t){let n=new Set([`forage`,`env`]),r=new Map;for(let i of e){let e=t===`logical`?i.namespace:[],a=t===`logical`?RT(i.name):zT(i.name),o=t=>[...e,t].join(`.`),s=a,c=2;for(;n.has(o(s));)s=`${a}_${String(c)}`,c+=1;n.add(o(s)),r.set(i.id,s)}return r}var VT=14695981039346656037n,HT=1099511628211n,UT=18446744073709551615n;function WT(e,t){let n=e,r=BigInt(t.length);for(let e=0;e<8;e+=1)n=(n^r&255n)*HT&UT,r>>=8n;for(let e=0;e<t.length;e+=1){let r=t.charCodeAt(e);n=(n^BigInt(r&255))*HT&UT,n=(n^BigInt(r>>>8&255))*HT&UT}return n}function GT(e,t,n){let r=WT(VT,e),i=[...t.entries()].sort(([e],[t])=>NT(e,t));for(let[e,t]of i)r=WT(r,e),r=WT(r,t);let a=[...n].sort((e,t)=>NT(e.id,t.id));for(let e of a)r=WT(r,e.id),r=WT(r,e.version);return`installed-${r.toString(16).padStart(16,`0`)}`}function KT(){return[qx,Kx,Jx]}function qT(e,t,n,r,i,a=[]){return Object.entries(t.operations).flatMap(([t,o])=>{if(LT(t),ET(o)){let s=OT(o);if(s===void 0)throw new K(`Unknown child module registration`);return qT(e,s,n,[...r,t,...s.namespace],s.description??i,[...a,t,...s.namespace])}let s=DT(o);if(s===void 0)throw new K(`Unknown operation registration: ${[...r,t].join(`.`)}`);return[Object.freeze({grantKey:e,path:[...r,t].join(`.`),namespace:n,name:[...a,t].join(`.`),moduleDescription:i,operation:s})]})}function JT(e,t=[]){let n=e.map(e=>{let t=OT(e);if(t===void 0)throw new K(`Unknown module registration`);return IT(t.id),t}).sort((e,t)=>NT(e.id,t.id)),r=new Set;for(let e of n){if(r.has(e.id))throw new K(`Duplicate module id: ${e.id}`);r.add(e.id)}let i=BT(n,`transport`),a=BT(n,`logical`),o=Object.freeze(Object.fromEntries(n.map(e=>{let t=i.get(e.id);if(t===void 0)throw new K(`Missing module alias: ${e.id}`);let n=a.get(e.id);if(n===void 0)throw new K(`Missing logical alias: ${e.id}`);return[t,Object.freeze([...e.namespace,n])]}))),s=n.flatMap(e=>{let t=i.get(e.id);if(t===void 0)throw new K(`Missing module alias: ${e.id}`);let n=o[t];if(n===void 0)throw new K(`Missing namespace path: ${e.id}`);return qT(e.grantKey,e,t,n,e.description)}).sort((e,t)=>NT(e.path,t.path)),c=new Set(s.map(e=>e.path));if(c.size!==s.length)throw new K(`Duplicate operation path`);for(let e of KT()){if(c.has(e.path))throw new K(`Reserved intrinsic path: ${e.path}`);c.add(e.path)}for(let e of c){let t=e.split(`.`);for(let n=1;n<t.length;n+=1)if(c.has(t.slice(0,n).join(`.`)))throw new K(`Operation conflicts with namespace: ${e}`)}let l;try{l=Hx({revision:`prepared-content-stamp`,operations:[...s.map(({path:e,moduleDescription:t,operation:n})=>{let r={path:e,input:n.input};return n.description!==void 0&&(r.description=n.description),n.output!==void 0&&(r.output=n.output),t!==void 0&&(r.instructions=t),r}),...KT()]})}catch(e){throw new K(PT(e))}let u=GT(l.stamp(),i,t),d=Object.freeze({revision:u,search:l.search,describe:l.describe,list:l.list,stamp:l.stamp}),f=Object.freeze(Object.fromEntries([...i.entries()].map(([e,t])=>[t,e])));return Object.freeze({revision:u,catalog:d,operations:Object.freeze(s),moduleAliases:f,namespacePaths:o})}function YT(){return null}var XT=nn(),ZT=C(()=>Qr([Lt(),T(),xr(),dr()])),QT=C(()=>Cn(T(),lt())),$T=C(()=>DS.extend({timeoutMs:dr().int().min(1).max(9e5).optional(),abortGraceMs:dr().int().min(1).max(3e4).optional()}).optional()),eE=64,tE=262144,nE=new TextEncoder,rE=e=>{e(b(void 0))};function iE(e){let t=$T.safeParse(e);if(!t.success)throw new K(`Execution policy is invalid`);let n=t.data?.timeoutMs??18e4;return Object.freeze({timeoutMs:n,abortGraceMs:t.data?.abortGraceMs??5e3,...OS({sandboxCapacity:t.data?.sandboxCapacity,admissionWaitMs:t.data?.admissionWaitMs??n},(t.data?.sandboxCapacity,void 0))})}function aE(e){return S(function*(){let t=yield*w_(e);return Object.freeze({createGroup:()=>{let e=0,n=new Set,r=Kn(t=>e===0?(t(b(void 0)),w(()=>void 0)):(n.add(t),w(()=>n.delete(t))));return Object.freeze({start:r=>ft(i=>w(()=>{e+=1}).pipe(y(te(i(t.withPermits(1)(r)).pipe(Xn(w(()=>{if(--e,e===0){let e=[...n];n.clear(),e.forEach(rE)}}))))))),awaitIdle:r})}})})}function oE(e,t=0){if(t>eE)throw Error(`JSON value exceeds the nesting bound`);let n=ZT.safeParse(e);if(n.success)return n.data;if(Array.isArray(e))return e.map(e=>oE(e,t+1));let r=QT.safeParse(e);if(!r.success)throw r.error;return Object.fromEntries(Object.entries(r.data).filter(([,e])=>e!==void 0).map(([e,n])=>[e,oE(n,t+1)]))}function sE(e){return XT.parse(oE(e))}function cE(e){let t=JSON.stringify(sE(e)),n=nE.encode(t).byteLength;if(n>tE)throw new uS({size:n});return Object.freeze({text:t})}function lE(e,t){return Object.freeze(Object.fromEntries(Object.entries(e).map(([e,n])=>[e,Object.freeze(Object.fromEntries(Object.entries(n).map(([n,r])=>[n,async i=>{t();try{return sE(await r(i))}catch(t){throw vS(t)?t:t instanceof qb?new fS({namespace:e,operation:n,cause:{kind:`Forage`,message:t.message},rawCause:t}):t instanceof eS?new fS({namespace:e,operation:n,cause:{kind:`InvalidInput`,message:`Invalid operation input: ${we({issues:t.issues})}; use forage.describe`},rawCause:t}):t}}])))])))}function uE(e){return Kn(t=>{let n=t.bind(void 0,h);return e.aborted?n():e.addEventListener(`abort`,n,{once:!0}),w(e.removeEventListener.bind(e,`abort`,n))})}function dE(e,t){if(e===void 0)return()=>void 0;let n=t.bind(void 0);return e.aborted?(n(),()=>void 0):(e.addEventListener(`abort`,n,{once:!0}),e.removeEventListener.bind(e,`abort`,n))}function fE(e,t,n){return e===`deadline_exceeded`?new iS({limitMs:t,elapsedMs:n??0}):new oS({by:`caller`})}function pE(e){return Ea.pipe(be(t=>t-e))}function mE(t){return Ea.pipe(E(n=>hr(()=>{let r=t.executionId,i=new AbortController,a=n,o={kind:`waiting`},s,c=e=>{s===void 0&&o.kind!==`refused`&&(s=e,i.abort())},l=e=>{let n=new aS({capacity:t.policy.capacity,waitedMs:Math.max(0,e-a)});return o={kind:`refused`,failure:n},n},u=()=>{if(i.signal.aborted)throw fE(s,t.policy.timeoutMs)},d=dE(t.callerSignal,()=>{c(`cancelled`)}),f=n+t.policy.timeoutMs,p={executionId:r,deadlineAt:f,signal:i.signal,images:t.images};t.toolCallId!==void 0&&Object.assign(p,{toolCallId:t.toolCallId}),t.output!==void 0&&Object.assign(p,{output:t.output});let m=Object.freeze(p),ee=hr(()=>Ea.pipe(E(e=>o.kind===`refused`?x(o.failure):(e>=f&&c(`deadline_exceeded`),i.signal.aborted?pE(n).pipe(E(e=>x(fE(s,t.policy.timeoutMs,e)))):e>=a+t.policy.waitMs?x(l(e)):(o={kind:`admitted`},t.sandbox.execute(Object.freeze({executionId:r,code:t.code,timeoutMs:t.policy.timeoutMs,bindings:lE(t.createBindings(m),u),modules:t.modules,namespacePaths:t.namespacePaths,sessionId:t.sessionId}),i.signal).pipe(Ir(e=>Hi(e)?Bt(e):x(yS(Wi(e)))))))))),te=e=>g_(e).pipe(Gr({duration:t.policy.abortGraceMs,orElse:()=>x(s===`deadline_exceeded`?new iS({limitMs:t.policy.timeoutMs,elapsedMs:t.policy.timeoutMs,acknowledged:!1}):new oS({by:`caller`,acknowledged:!1}))})),g,ne=!1,re=e=>(ne=!0,pE(n).pipe(E(n=>{let i=yS(e),a=i instanceof iS?new iS({limitMs:i.limitMs,elapsedMs:n,acknowledged:i.acknowledged}):i,o=mS(a,r),s=Cn(T(),nn()).parse(xS(a));s.ref=r;let c={kind:`sandbox_failure`,ref:r,executionId:r,adapter:t.sandbox.adapter??`effect`,buildSha:t.sandbox.buildSha??YT(),tag:o._tag,fields:s,healthAlert:o._tag===`Unknown`},l=hr(()=>t.sandbox.onFailure?.(c)??h);return Xe(`sandbox_failure`,c).pipe(or({executionId:r,ref:r,adapter:c.adapter,tag:c.tag,buildSha:c.buildSha}),y(o._tag===`Unknown`?oo(so(ao(`sandbox_unknown`),{adapter:c.adapter}),1).pipe(y(Xe(`sandbox_health_alert`).pipe(or({ref:r,adapter:c.adapter})))):h),y(l.pipe(Ir(e=>Xe(`sandbox_failure_record_failed`,e)))),Er(o))})));return S(function*(){if(i.signal.aborted){let e=yield*pE(n);return yield*x(fE(s,t.policy.timeoutMs,e))}a=yield*Ea,g=yield*t.backingWork.start(ee);let r=yield*Ea,u=fn(Math.max(0,a+t.policy.waitMs-r)).pipe(y(Ea),E(e=>o.kind===`admitted`?Tt:o.kind===`refused`?b({kind:`busy`,failure:o.failure}):i.signal.aborted?b({kind:`cancelled`}):e>=f?(c(`deadline_exceeded`),b({kind:`deadline`})):b({kind:`busy`,failure:l(e)}))),d=yield*e(m_(g).pipe(be(e=>Object.freeze({kind:`settled`,exit:e}))),e(fn(Math.max(0,f-r)).pipe(y(w(()=>(c(`deadline_exceeded`),Object.freeze({kind:`deadline`}))))),e(uE(i.signal).pipe(Er(Object.freeze({kind:`cancelled`}))),u))),p=o.kind===`refused`?o.failure:d.kind===`busy`?d.failure:void 0;if(p!==void 0)return yield*te(g).pipe(y(x(p)));if(d.kind===`settled`)return yield*ge(d.exit,{onFailure:e=>s===void 0?Bt(e):pE(n).pipe(E(e=>x(fE(s,t.policy.timeoutMs,e)))),onSuccess:e=>en({try:()=>cE(e),catch:t=>vS(t)?t:new dS({kind:bS(e),rawCause:t})})});d.kind===`deadline`&&c(`deadline_exceeded`);let m=yield*pE(n);return yield*te(g).pipe(y(x(fE(s,t.policy.timeoutMs,m))))}).pipe(Ce(()=>(c(`cancelled`),(g===void 0?h:g_(g).pipe(Gt(t.policy.abortGraceMs),tn)).pipe(y(hr(()=>ne?h:re(new oS({by:`operator`})).pipe(tn))))))).pipe(cn(e=>re(e).pipe(E(x))),Xn(w(d)))})))}var hE=pm(()=>L([tm,em,nm,P,N,Nh,wm(AbortSignal),I(hE),gE])),gE=om(N,hE);function _E(e){return k(gE)(e)}var vE=om(N,Gh),yE=k(F({samplingParams:A(vE),samplingParamsByThinkingLevel:A(F({off:A(vE),minimal:A(vE),low:A(vE),medium:A(vE),high:A(vE),xhigh:A(vE),max:A(vE)}))}));function bE(e){return{...e,...yE(e)}}function xE(e){if(e===void 0)return;let{onPayload:t,onProviderStreamEvent:n,onResponse:r,...i}=e,a={...i};return t!==void 0&&(a.onPayload=(e,n)=>t(_E(e),bE(n))),n!==void 0&&(a.onProviderStreamEvent=(e,t)=>n(_E(e),bE(t))),r!==void 0&&(a.onResponse=(e,t)=>r(e,bE(t))),a}var SE=async(e,t,n)=>{let{streamSimple:r}=await fi(async()=>{let{streamSimple:e}=await import(`./compat-CwkWF6ok.js`);return{streamSimple:e}},__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22]));return r(e,di(t),xE(n))},CE=F({error:F({code:j(N),type:j(N)})});Rp(F({type:M(`response.failed`),response:CE})),Rp(W(CE)),Rp(F({type:M(`error`),status:j(P.check(Ym(),qm({minimum:100,maximum:599}))),code:j(N),error:j(CE.fields.error)})),k(wm(Uint8Array)),Rp(kh.check(qm({minimum:0,maximum:60}))),Rp(kh.check(Ym(),qm({minimum:0,maximum:864e10}))),Rp(R([`five_hour`,`seven_day`,`seven_day_opus`,`seven_day_sonnet`])),Rp(M(`rejected`)),Rp(M(`0`)),Rp(Bh),Rp(F({type:M(`error`),error:F({type:M(`overloaded_error`)})}));var wE=[/prompt (?:is )?too long/i,/prompt exceeds max length/i,/request_too_large/i,/input is too long for requested model/i,/exceeds the context window/i,/exceeds (?:the )?(?:model'?s )?maximum context length(?: of [\d,]+ tokens?|\s*\([\d,]+\))/i,/input token count.*exceeds the maximum/i,/maximum prompt length is \d+/i,/reduce the length of the messages/i,/maximum context length is \d+ tokens/i,/exceeds (?:the )?maximum allowed input length of [\d,]+ tokens?/i,/input \(\d+ tokens\) is longer than the model'?s context length \(\d+ tokens\)/i,/exceeds the limit of \d+/i,/exceeds the available context size/i,/greater than the context length/i,/context window exceeds limit/i,/exceeded model token limit/i,/too large for model with \d+ maximum context length/i,/prompt has [\d,]+ tokens?, but the configured context size is [\d,]+ tokens?/i,/model_context_window_exceeded/i,/prompt too long; exceeded (?:max )?context length/i,/range of input length should be/i,/context[_ ]length[_ ]exceeded/i,/too many tokens/i,/token limit exceeded/i],TE=/^4(?:00|13)\s*(?:status code)?\s*\(no body\)/i,EE=[/^(Throttling error|Service unavailable):/i,/rate limit/i,/too many requests/i];function DE(e,t){return!!(e.stopReason===`error`&&e.errorMessage&&!EE.some(t=>t.test(e.errorMessage))&&(wE.some(t=>t.test(e.errorMessage))||e.provider===`cerebras`&&TE.test(e.errorMessage))||t&&e.stopReason===`stop`&&e.usage.input+e.usage.cacheRead>t||t&&e.stopReason===`length`&&e.usage.output===0&&e.usage.input+e.usage.cacheRead>=t*.99)}function OE(e,t){return e.stopReason===`length`&&t>0&&e.usage.output<t}function kE(e){return new RegExp(e.join(`|`),`i`)}var AE=kE([`GoUsageLimitError`,`FreeUsageLimitError`,`Monthly usage limit reached`,`available balance`,`insufficient_quota`,`out of budget`,`quota exceeded`,`billing`,`subscription_sharing_usage_limit_exceeded`]),jE=kE(`overloaded,server_busy,servers are currently busy,currently experiencing high demand,model is at capacity,rate.?limit,too many requests,429,500,502,503,504,520,524,service.?(?:is.?)?(?:temporarily.?)?unavailable,server.?error,internal.?error,provider.?returned.?(?:an.?)?error,exceeded request buffer limit while retrying upstream,unable to forward upstream,network.?error,connection.?error,connection.?refused,connection.?lost,other side closed,fetch failed,getaddrinfo,ENOTFOUND,EAI_AGAIN,upstream.?connect,reset before headers,socket hang up,socket connection was closed,timed? out,timeout,terminated,websocket.?closed,websocket.?error,ended without,stream ended before message_stop,stream ended before a terminal response event,http2 request did not get a response,pending stream has been canceled,retry delay,you can retry your request,try your request again,please retry your request,ResourceExhausted,subscription_sharing_usage_unavailable,subscription_sharing_user_unavailable`.split(`,`)),ME=6e4;function NE(e,t){let n=e.baseDelayMs*2**Math.max(0,t-1);return Math.min(Number.isSafeInteger(n)?n:2**53-1,e.maxAgentDelayMs??6e4)}var PE=class extends Error{constructor(){super(`Aborted`)}};function FE(e,t){return new Promise((n,r)=>{if(t?.aborted){r(new PE);return}let i=setTimeout(n,e);t?.addEventListener(`abort`,()=>{clearTimeout(i),r(new PE)},{once:!0})})}async function IE(e,t,n,r){let i=t?.enabled?t.maxRetries:0,a=0,o;for(;;){let s=await e();if(s.stopReason===`aborted`)return o&&await r?.onRetryFinished?.(!1,o.attempt),s;if(s.stopReason!==`error`)return o&&await r?.onRetryFinished?.(!0,o.attempt),s;if(a>=i||!LE(s))return o&&await r?.onRetryFinished?.(!1,o.attempt,s.errorMessage),s;a++,o={attempt:a,errorMessage:s.errorMessage||`Unknown error`};let c=NE(t,a);await r?.onRetryScheduled?.(a,i,c,o.errorMessage);try{await FE(c,n)}catch(e){if(await r?.onRetryFinished?.(!1,a,o.errorMessage),e instanceof PE){let{errorMessage:e,...t}=s;return{...t,stopReason:`aborted`}}throw e}await r?.onRetryAttemptStart?.()}}function LE(e){if(e.stopReason!==`error`||!e.errorMessage)return!1;let t=e.errorMessage;return!AE.test(t)&&jE.test(t)}var RE={assign:0,create:0,clone:0,discard:0,update:0};function zE(e){return VE(e,null)}function BE(e){return VE(typeof e,`object`)&&!zE(e)}function VE(e,t){return e===t}function HE(e){return VE(e,`__proto__`)||VE(e,`constructor`)||VE(e,`prototype`)}function UE(e,t){return HE(t)?Object.prototype.hasOwnProperty.call(e,t):t in e}function WE(e){return Object.getOwnPropertyNames(e)}var GE={immutableTypes:!1,maxErrors:8,maxInstantiationCount:128,useAcceleration:!0,exactOptionalPropertyTypes:!1,enumerableKind:!1,correctiveParse:!1,unionPrioritySort:!0};function KE(){return GE}function qE(e){return KE().immutableTypes?Object.freeze(e):e}function JE(e,t){for(let n of Object.keys(t))Object.defineProperty(e,n,{configurable:!0,writable:!0,enumerable:!1,value:t[n]});return e}function YE(e,t){return{...e,...t}}function XE(e,t,n={}){RE.create+=1;let r=YE(t,n);return qE(KE().enumerableKind?YE(r,e):JE(r,e))}function ZE(e){return BE(e)}function QE(e){return ZE(e)&&UE(e,`~optional`)}function $E(e){return WE(e).filter(t=>!QE(e[t]))}function eD(e,t={}){let n=$E(e);return XE({"~kind":`Object`},{type:`object`,...n.length>0?{required:n}:{},properties:e},t)}var tD;(function(e){e[e.Array=0]=`Array`,e[e.BigInt=1]=`BigInt`,e[e.Boolean=2]=`Boolean`,e[e.Date=3]=`Date`,e[e.Constructor=4]=`Constructor`,e[e.Function=5]=`Function`,e[e.Null=6]=`Null`,e[e.Number=7]=`Number`,e[e.Object=8]=`Object`,e[e.RegExp=9]=`RegExp`,e[e.String=10]=`String`,e[e.Symbol=11]=`Symbol`,e[e.TypeArray=12]=`TypeArray`,e[e.Undefined=13]=`Undefined`})(tD||={}),Array.from({length:256}).map((e,t)=>BigInt(t));var nD=new Float64Array(1);new DataView(nD.buffer),new Uint8Array(nD.buffer),new TextEncoder;var rD=`-?(?:0|[1-9][0-9]*)`,iD=`-?(?:0|[1-9][0-9]*)(?:\\.[0-9]+)?`;function aD(e){return XE({"~kind":`String`},{type:`string`},e)}var oD=`^${rD}$`;`${iD}`;function sD(e,t){return Array.from({length:t-e+1},(t,n)=>String.fromCharCode(e+n))}var cD=[...sD(97,122),...sD(65,90)],lD=[`0`,...sD(49,57)];[...lD],[...cD,...lD],[...lD],new RegExp(oD);var uD={enabled:!0,maxRetries:3,baseDelayMs:2e3,maxAgentDelayMs:6e4},dD={firstEventMs:6e4,idleMs:12e4,attemptMs:6e5,outputBytes:2097152},fD=1e3,pD=Symbol(`Mule model limit`);function mD(e,t){return DE(e,t)}var hD=(e,t,n)=>({_tag:`MuleError`,phase:e,message:t,cause:n}),gD=(e,t)=>({kind:e,value:`mule_${e}_${ng()}`,parent:t}),_D=()=>h;function vD(e,t){let n={role:`toolResult`,toolCallId:e.id,toolName:e.name,content:t.content,isError:t.isError,timestamp:Date.now()};return t.usage!==void 0&&(n.usage=t.usage),n}var yD=(e,t)=>({content:[{type:`text`,text:e}],isError:!0,terminate:t});function bD(e,t){return e.find(e=>e.descriptor.name===t.name)}function xD(e,t,n,r){return r({type:`tool_execution_end`,run:t,turn:n,toolCall:e.identity,call:e.call,result:e.result})}function SD(e,t,n,r,i){let a=gD(`tool_call`,r);return S(function*(){if(yield*i({type:`tool_execution_start`,replay:e?.replay??`unsafe`,run:n,turn:r,toolCall:a,call:t}),e===void 0){let e=yD(`Tool "${t.name}" not found`),o={call:t,identity:a,result:e};return yield*xD(o,n,r,i),{kind:`finalized`,value:o}}let o=yield*_n(e.prepare(t));if(pe(o)){let e=yD(o.failure.message,o.failure.terminate),s={call:t,identity:a,result:e};return yield*xD(s,n,r,i),{kind:`finalized`,value:s}}return{kind:`prepared`,call:t,identity:a,tool:o.success}})}function CD(e,t,n,r){return S(function*(){let i,a;yield*fy(Zv(e.tool.execute()),o=>pe(o)?(a=o.failure,h):i===void 0?o.success.type===`result`?(i=o.success.result,h):r({type:`tool_execution_update`,run:t,turn:n,toolCall:e.identity,call:e.call,result:o.success.result}):h);let o=a===void 0?i??yD(`Tool "${e.call.name}" returned no result`):yD(a.message),s={call:e.call,identity:e.identity,result:o};return yield*xD(s,t,n,r),s})}function wD(e,t,n,r){let i=vD(e.call,e.result),a=gD(`tool_result`,e.identity);return S(function*(){return yield*r({type:`message_start`,run:t,turn:n,message:a,value:i}),yield*r({type:`message_end`,run:t,turn:n,message:a,value:i,data:e.result.data}),i})}function TD(e,t,n,r,i){let a=t.tools??[],o=t.toolExecution===`sequential`||e.some(e=>bD(a,e)?.executionMode===`sequential`);return S(function*(){let t=e=>e.kind===`finalized`?b(e.value):CD(e,n,r,i),s=o?yield*Kr(e,e=>E(SD(bD(a,e),e,n,r,i),t)):yield*S(function*(){let o=yield*Kr(e,e=>SD(bD(a,e),e,n,r,i));return yield*Mn(o.map(t),{concurrency:`unbounded`})});return{messages:yield*Kr(s,e=>wD(e,n,r,i)),terminate:s.length>0&&s.every(e=>e.result.terminate===!0)}})}var ED=e=>yD(`Tool call "${e.name}" was not executed: the response hit the output token limit, so its arguments may be truncated. Re-issue the tool call with complete arguments.`);function DD(e,t,n,r){return S(function*(){let i=yield*Kr(e,e=>S(function*(){let i=gD(`tool_call`,n),a={call:e,identity:i,result:ED(e)};return yield*r({type:`tool_execution_start`,replay:`unsafe`,run:t,turn:n,toolCall:i,call:e}),yield*xD(a,t,n,r),a}));return yield*Kr(i,e=>wD(e,t,n,r))})}function OD(e,t){return si({try:n=>{let r=()=>{t.abort(n.reason)};return n.aborted?r():n.addEventListener(`abort`,r,{once:!0}),Promise.resolve(e.next()).finally(()=>{n.removeEventListener(`abort`,r)})},catch:e=>hD(`model`,`Pi model stream failed`,e)})}function kD(e,t,n){return e.pipe(Gr({duration:t,orElse:()=>x(hD(`model`,n(),pD))}))}function AD(e,t,n,r,i,a){let o=gD(`message`,r),s,c={started:!1,terminal:void 0};return sn(S(function*(){let l=e.modelStreamLimits,u=Math.min(l?.firstEventMs??dD.firstEventMs,dD.firstEventMs),d=Math.min(l?.attemptMs??dD.attemptMs,dD.attemptMs),f=Math.min(l?.outputBytes??dD.outputBytes,dD.outputBytes);if([u,d,f,e.modelStreamIdleTimeoutMs??1].some(e=>!Number.isSafeInteger(e)||e<=0))return yield*x(hD(`model`,`Model stream limits must be positive safe integers`));let p=Date.now(),m=p,ee=0,te=0,g=new TextEncoder,ne=!1,re=e=>hD(`model`,`Model ${e} after ${String(Date.now()-p)} ms (max provider gap ${String(Math.max(ee,Date.now()-m))} ms, streamed ${String(te)} bytes)`,pD),ie=t=>{let n=Date.now()-p,r=d-n,i=Math.min(ne?dD.idleMs:u,e.modelStreamIdleTimeoutMs??dD.idleMs)-(Date.now()-m),a=r<=i?`attempt timed out`:ne?`stream timed out (silence)`:`first event timed out`;return kD(t,Math.max(0,Math.min(r,i)),()=>re(a).message)},ae=new AbortController;yield*br(()=>w(()=>{ae.abort(`Mule model scope closed`)}));let oe=(e.resolveApiKey===void 0?void 0:yield*e.resolveApiKey(e.model.provider))??e.streamOptions?.apiKey,se={...e.streamOptions,maxRetries:0,signal:ae.signal};oe!==void 0&&(se.apiKey=oe);let ce=e.prepareSystemPrompt===void 0?e.systemPrompt:yield*e.prepareSystemPrompt();e.prepareSystemPrompt!==void 0&&(yield*i({type:`model_prompt`,run:n,turn:r,attempt:a,systemPrompt:ce}));let le={systemPrompt:ce,messages:t},ue=(e.tools??[]).map(e=>e.descriptor);ue.length>0&&(le.tools=ue);let de=yield*ie(si({try:async()=>(e.stream??SE)(e.model,di(le),se),catch:e=>hD(`model`,`Pi model stream could not start`,e)})),fe=yield*jr(w(()=>de[Symbol.asyncIterator]()),e=>si({try:()=>(ae.abort(`Mule model stream closed`),new Promise(t=>{let n=setTimeout(t,fD);Promise.resolve(e.return?.()).then(()=>{clearTimeout(n),t()},()=>{clearTimeout(n),t()})})),catch:e=>hD(`model`,`Pi model stream failed`,e)}).pipe(Le)),pe=e=>{let a=Date.now();if(ee=Math.max(ee,a-m),m=a,ne=!0,(e.type===`text_delta`||e.type===`thinking_delta`||e.type===`toolcall_delta`)&&(te+=g.encode(e.delta).byteLength,te>f))return x(re(`output limit exceeded`));switch(`partial`in e&&(s=e.partial),e.type){case`start`:return t.push(e.partial),c.started=!0,i({type:`message_start`,run:n,turn:r,message:o,value:e.partial});case`text_start`:case`text_delta`:case`text_end`:case`thinking_start`:case`thinking_delta`:case`thinking_end`:case`toolcall_start`:case`toolcall_delta`:case`toolcall_end`:return c.started&&(t[t.length-1]=e.partial),i({type:`message_update`,run:n,turn:r,message:o,value:e.partial,event:e});case`done`:return c.terminal=e.message,h;case`error`:return c.terminal=e.error,h}},me=()=>ie(OD(fe,ae)),he=yield*me();for(;!he.done;)yield*pe(he.value),he=yield*me();let ge=c.terminal??(yield*ie(si({try:()=>de.result(),catch:e=>hD(`model`,`Pi model stream did not settle`,e)})));return c.started?t[t.length-1]=ge:(t.push(ge),yield*i({type:`message_start`,run:n,turn:r,message:o,value:ge})),yield*i({type:`message_end`,run:n,turn:r,message:o,value:ge}),{identity:o,message:ge}}).pipe(cn(l=>{if(l.cause!==pD)return x(l);let u={role:`assistant`,content:s?.content??[],api:e.model.api,provider:e.model.provider,model:e.model.id,usage:s?.usage??{input:0,output:0,cacheRead:0,cacheWrite:0,totalTokens:0,cost:{input:0,output:0,cacheRead:0,cacheWrite:0,total:0}},stopReason:`error`,timestamp:Date.now(),errorMessage:e.retry?.enabled&&a>e.retry.maxRetries?`The model failed ${String(a)} times on this conversation: ${l.message}`:l.message};return S(function*(){return c.started?t[t.length-1]=u:(t.push(u),yield*i({type:`message_start`,run:n,turn:r,message:o,value:u})),yield*i({type:`message_end`,run:n,turn:r,message:o,value:u}),{identity:o,message:u,limitReached:!0}})})))}function jD(e,t,n,r,i){return S(function*(){let a=e.retry===void 0?void 0:{...e.retry};if(a?.enabled&&[a.maxRetries,a.baseDelayMs,a.maxAgentDelayMs??6e4].some(e=>!Number.isSafeInteger(e)||e<0))return yield*x(hD(`model`,`Retry policy requires non-negative safe-integer counts and delays`));let o,s=0,c=0,l=!1,u,d=t=>e.onRetry===void 0?h:e.onRetry(t),f=(e,t)=>S(function*(){l=!0,yield*d(t===void 0?{type:`retry_finished`,run:n,turn:r,attempt:c,success:e}:{type:`retry_finished`,run:n,turn:r,attempt:c,success:e,finalError:t})});return yield*S(function*(){for(;;){if(o!==void 0){let e=t.indexOf(o.message);e!==-1&&t.splice(e,1)}o=yield*AD(e,t,n,r,i,++s);let l=o.message;if(l.stopReason!==`error`||a===void 0||!a.enabled||c>=a.maxRetries)return c>0&&(yield*f(l.stopReason!==`error`&&l.stopReason!==`aborted`,l.stopReason===`error`?l.errorMessage:void 0)),o;if(!(yield*en({try:()=>o?.limitReached===!0||e.retryable(l),catch:e=>hD(`model`,`Typed model retry decision failed`,e)})))return c>0&&(yield*f(!1,l.errorMessage)),o;c++,u=l.errorMessage??`Unknown error`;let p=yield*en({try:()=>e.retryAfterMs?.(l),catch:e=>hD(`model`,`Model retry delay observation failed`,e)}),m=Math.max(NE(a,c),p!==void 0&&Number.isSafeInteger(p)&&p>=0&&p<=6e4?p:0),ee=Math.min(1e3,m/4,Math.max(0,6e4-m)),h=m+Math.floor(Math.random()*ee);yield*d({type:`retry_scheduled`,run:n,turn:r,attempt:c,maxAttempts:a.maxRetries,delayMs:h,errorMessage:u}),yield*fn(h),yield*d({type:`retry_attempt_started`,run:n,turn:r,attempt:c})}}).pipe(Ce(()=>c===0||l?h:f(!1,u)))})}var MD=e=>e.stopReason===`aborted`?`cancelled`:e.stopReason===`error`?`failed`:`completed`;function ND(e,t,n,r,i,a){return Kr(e,e=>S(function*(){let o=gD(`message`,i);t.push(e),n.push(e),yield*a({type:`message_start`,run:r,turn:i,message:o,value:e}),yield*a({type:`message_end`,run:r,turn:i,message:o,value:e})})).pipe(tn)}function PD(e,t,n,r,i,a,o){return S(function*(){yield*o({type:`turn_start`,run:r,turn:i}),yield*ND(a,t,n,r,i,o);let s=yield*jD(e,t,r,i,o),c=MD(s.message)!==`completed`,l=s.message.content.filter(e=>e.type===`toolCall`),u=l.length===0||c?{messages:[],terminate:!1}:s.message.stopReason===`length`?{messages:yield*DD(l,r,i,o),terminate:!1}:yield*TD(l,e,r,i,o);t.push(...u.messages),n.push(s.message,...u.messages),yield*o({type:`turn_end`,run:r,turn:i,message:s.message,toolResults:u.messages});let d={message:s.message,toolResults:u.messages,terminate:u.terminate};return s.limitReached&&s.message.errorMessage!==void 0?{...d,modelLimitReason:s.message.errorMessage}:d})}function FD(e,t,n,r,i,a){let o=gD(`turn`,i);return S(function*(){if(MD(t.message)!==`completed`)return{message:t.message,toolResults:[],terminate:!0};let s=yield*Kr(t.tools,n=>S(function*(){if(n.state===`completed`&&n.message!==void 0)return{message:n.message,terminate:n.result.terminate===!0,recorded:!0};let r=bD(e.tools??[],n.call),s;if(t.message.stopReason!==`length`&&(n.state===`pending`||n.state===`started`&&n.replay===`safe`&&r?.replay===`safe`)){let e=yield*SD(r,n.call,i,o,a);s=e.kind===`finalized`?e.value:yield*CD(e,i,o,a)}else s={call:n.call,identity:gD(`tool_call`,o),result:n.state===`completed`?n.result:n.state===`pending`&&t.message.stopReason===`length`?ED(n.call):yD(`Interrupted by a restart; it may or may not have completed; check before retrying.`)},yield*a({type:`tool_execution_start`,replay:`unsafe`,run:i,turn:o,toolCall:s.identity,call:s.call}),yield*xD(s,i,o,a);return{message:yield*wD(s,i,o,a),terminate:s.result.terminate===!0,recorded:!1}})),c=s.filter(({recorded:e})=>!e).map(({message:e})=>e);return n.push(...c),r.push(...c),{message:t.message,toolResults:s.map(({message:e})=>e),terminate:s.length>0&&s.every(({terminate:e})=>e)}})}function ID(e,t,n,r){return S(function*(){if(e.shouldStopAfterTurn!==void 0&&(yield*e.shouldStopAfterTurn({message:t.message,toolResults:t.toolResults,context:n,newMessages:r})))return{continue:!1,pending:[]};let i=e.getSteeringMessages===void 0?[]:[...yield*e.getSteeringMessages()];if(t.message.content.some(e=>e.type===`toolCall`)&&!t.terminate||i.length>0)return{continue:!0,pending:i};let a=e.getFollowUpMessages===void 0?[]:[...yield*e.getFollowUpMessages()];return{continue:a.length>0,pending:a}})}function LD(e,t,n,r,i,a,o){return S(function*(){yield*a({type:`run_end`,run:e,terminal:t,outcome:i});let s={status:i,run:e,terminal:t,message:n,messages:r};return o===void 0?s:{...s,modelLimitReason:o}})}function RD(e,t=_D){return S(function*(){let n=yield*w_(1),r={started:!1,ended:!1},i=e=>hr(()=>(e.type===`run_end`&&(r.ended=!0),n.withPermits(1)(t(e)))).pipe(jn(()=>w(()=>{e.type===`run_start`&&(r.started=!0)}))),a=gD(`run`),o=gD(`terminal`,a);return yield*BD(e,i,a,o).pipe(Oe(e=>{let t=zD(e);return!r.started||r.ended||t===void 0?h:i({type:`run_end`,run:a,terminal:o,outcome:t}).pipe(Le)}))})}function zD(e){if(ra(e))return;if(Hi(e.cause))return`cancelled`;let t=Ki(e.cause);if(!(Fn(t)&&t.value.phase===`listener`))return`failed`}function BD(e,t,n,r){return S(function*(){let i=[...e.messages],a=[],o=e.getSteeringMessages===void 0?[]:[...yield*e.getSteeringMessages()],s,c;if(yield*t({type:`run_start`,run:n}),e.resume!==void 0){let s=yield*FD(e,e.resume,i,a,n,t),c=MD(s.message),l=c===`completed`?yield*ID(e,s,i,a):{continue:!1,pending:[]};if(!l.continue&&o.length===0)return yield*LD(n,r,s.message,a,c,t);o.push(...l.pending)}do{let l=yield*PD(e,i,a,n,gD(`turn`,n),o,t);s=l.message;let u=MD(l.message);if(u!==`completed`)return yield*LD(n,r,l.message,a,u,t,l.modelLimitReason);if(e.prepareNextTurn!==void 0&&!l.terminate&&l.message.content.some(e=>e.type===`toolCall`)){let t=yield*e.prepareNextTurn({message:l.message,toolResults:l.toolResults,context:i,newMessages:a});t!==void 0&&i.splice(0,i.length,...t)}let d=yield*ID(e,l,i,a);o=[...d.pending],c=d.continue}while(c);return yield*LD(n,r,s,a,`completed`,t)})}var VD={run:RD},HD=class{#e=new Map;#t;constructor(e=8){this.#t=e}push(e,t){let n=this.#e.get(e)??[];if(n.length>=this.#t)throw new fS({namespace:`execute`,operation:`images`,cause:{kind:`Unavailable`,message:`Image collector cap reached for this execution (max ${String(this.#t)} images). Process images one at a time or write them to files.`}});let r=`img_${String(n.length)}`;return n.push(Object.freeze({...t})),this.#e.set(e,n),r}drain(e){let t=this.#e.get(e);return t===void 0?[]:(this.#e.delete(e),t)}dispose(e){this.#e.delete(e)}},UD=8192,WD=UD*4,GD=new TextEncoder,KD=()=>new TextDecoder(`utf-8`,{ignoreBOM:!0,fatal:!1}),qD=class e{wake;#e={stdout:{decoder:KD(),pending:new Uint8Array},stderr:{decoder:KD(),pending:new Uint8Array}};#t=KD();#n=Array.from({length:UD},()=>void 0);#r=0;#i=0;#a=0;#o=0;#s=0;#c=0;#l=!1;#u=!1;constructor(e){this.wake=e}static make(){return Pg({capacity:1,strategy:`dropping`}).pipe(be(t=>new e(t)))}write(e,t){if(this.#u||t.length===0)return;let n=this.#e[e];this.#c+=t.length;for(let e=0;e<t.length;e+=WD){let r=t.subarray(e,e+WD),i=n.decoder.decode(r,{stream:!0}),a=new Uint8Array(n.pending.length+r.length);a.set(n.pending),a.set(r,n.pending.length);let o=this.#f(a);n.pending=a.slice(a.length-o),this.#h(i,a.length-o,a)}this.#l=!0,Rg(this.wake,void 0)}#d(e,t){let n=this.#t.decode(e.subarray(0,t),{stream:!0});return this.#t.decode(),n}#f(e){for(let t=1;t<=Math.min(3,e.length);t++){let n=e.subarray(e.length-t);if(this.#d(n,n.length).length===0)return t}return 0}#p(){let e=this.#n[this.#r];if(e===void 0)throw Error(`Missing output ring entry`);this.#n[this.#r]=void 0,this.#r=(this.#r+1)%UD,this.#i--,this.#a-=e.textBytes,this.#o-=e.newlines,this.#s+=e.rawBytes}#m(e,t,n){let r=e.raw;if(r===null){this.#p();return}let i=e=>{let i=this.#d(r,e);return GD.encode(i).length>=t&&i.split(`
18
+ `;case 114:return`\r`;case 120:return String.fromCharCode(this.readHexChar(2));case 117:return oC(this.readCodePoint());case 116:return` `;case 98:return`\b`;case 118:return`\v`;case 102:return`\f`;case 13:this.input.charCodeAt(this.pos)===10&&++this.pos;case 10:return this.options.locations&&(this.lineStart=this.pos,++this.curLine),``;case 56:case 57:if(this.strict&&this.invalidStringToken(this.pos-1,`Invalid escape sequence`),e){var n=this.pos-1;this.invalidStringToken(n,`Invalid escape sequence in template string`)}default:if(t>=48&&t<=55){var r=this.input.substr(this.pos-1,3).match(/^[0-7]+/)[0],i=parseInt(r,8);return i>255&&(r=r.slice(0,-1),i=parseInt(r,8)),this.pos+=r.length-1,t=this.input.charCodeAt(this.pos),(r!==`0`||t===56||t===57)&&(this.strict||e)&&this.invalidStringToken(this.pos-1-r.length,e?`Octal literal in template string`:`Octal literal in strict mode`),String.fromCharCode(i)}return YS(t)?(this.options.locations&&(this.lineStart=this.pos,++this.curLine),``):String.fromCharCode(t)}},Q.readHexChar=function(e){var t=this.pos,n=this.readInt(16,e);return n===null&&this.invalidStringToken(t,`Bad character escape sequence`),n},Q.readWord1=function(){this.containsEsc=!1;for(var e=``,t=!0,n=this.pos,r=this.options.ecmaVersion>=6;this.pos<this.input.length;){var i=this.fullCharCodeAtPos();if(VS(i,r))this.pos+=i<=65535?1:2;else if(i===92){this.containsEsc=!0,e+=this.input.slice(n,this.pos);var a=this.pos;this.input.charCodeAt(++this.pos)!==117&&this.invalidStringToken(this.pos,`Expecting Unicode escape sequence \\uXXXX`),++this.pos;var o=this.readCodePoint();(t?BS:VS)(o,r)||this.invalidStringToken(a,`Invalid Unicode escape`),e+=oC(o),n=this.pos}else break;t=!1}return e+this.input.slice(n,this.pos)},Q.readWord=function(){var e=this.readWord1(),t=J.name;return this.keywords.test(e)&&(t=KS[e]),this.finishToken(t,e)},PC.acorn={Parser:PC,version:`8.18.0`,defaultOptions:dC,Position:cC,SourceLocation:lC,getLineInfo:uC,Node:rw,TokenType:HS,tokTypes:J,keywordTypes:KS,TokContext:JC,tokContexts:YC,isIdentifierChar:VS,isIdentifierStart:BS,Token:Jw,isNewLine:YS,lineBreak:qS,lineBreakG:JS,nonASCIIwhitespace:ZS};function Qw(e,t){return PC.parse(e,t)}C(()=>Kt(`ok`,[Vt({ok:Lr(!0),value:lt()}),Vt({ok:Lr(!1),error:Vt({kind:Lr(`guest_threw`),name:T().max(80),message:T().max(512),transportMessage:T().max(512).optional()})})]));var $w=C(()=>T().regex(/^[A-Za-z][A-Za-z0-9_]*$/u)),eT=$w.refine(e=>{if(e===`env`)return!1;try{return Qw(`let ${e};`,{ecmaVersion:`latest`,sourceType:`module`}),!0}catch(e){if(!(e instanceof SyntaxError))throw e;return!1}},`Invalid sandbox transport alias`);C(()=>Cn(eT,pn($w).min(1))),C(()=>Cn(eT,pn(T().regex(/^[A-Za-z][A-Za-z0-9_]*(?:\.[A-Za-z][A-Za-z0-9_]*)*$/u))));var tT=R([`read`,`write`]),nT=nm,rT=F({access:j(tT),confirm:j(nT)}),iT=R([`none`,`read`,`write`]),aT=O(rT),oT=O(iT);function sT(e){let t=aT({access:e.access,confirm:e.confirm});if(pe(t))throw new K(`Access labels must be access: "read" | "write" and confirm: boolean`);return{access:t.success.access??`write`,confirm:t.success.confirm??!1}}function cT(e,t){let n=`${t.module}.${t.operation}`;switch(e){case`not-granted`:return`${n} is not granted to this Agent.`;case`read-only`:return`${n} changes something, and this Agent has read-only access to ${t.module}.`;case`confirmation-unavailable`:return`${n} needs a person's approval, and no one can be asked here.`;case`declined`:return`${n} was not approved.`}}function lT(e,t){return Object.freeze({refused:!0,module:t.module,operation:t.operation,reason:e,message:cT(e,t)})}function uT(e,t,n){let r=e.sessionGrants?.(t),i=r!==void 0&&Object.hasOwn(r,n)?r:e.grants;if(i===void 0||!Object.hasOwn(i,n))return e.required?.includes(n)===!0?`none`:e.defaultGrant??`write`;let a=oT(i[n]);return Ae(a)?a.success:`none`}async function dT(e,t,n,r,i){let a=await fT(e,t,n,r,i);return a!==void 0&&e.onRefused?.(a,t),a}async function fT(e,t,n,r,i){await e.beforeCall?.(i),i.throwIfAborted();let a=pT(e,t,n);if(a!==void 0)return a;if(!(!n.confirm&&(e.confirmWrites!==!0||n.access===`read`)))return e.confirm===void 0?lT(`confirmation-unavailable`,n):await e.confirm({module:n.module,operation:n.operation,access:n.access,sessionId:t.sessionId,input:r},i)?(await e.beforeCall?.(i),i.throwIfAborted(),pT(e,t,n)):lT(`declined`,n)}function pT(e,t,n){let r=uT(e,t,n.module);if(r===`none`)return lT(`not-granted`,n);if(r===`read`&&n.access!==`read`)return lT(`read-only`,n)}function mT(e,t,n){let r={module:e.module,operation:e.descriptor.name,...sT(e)};return{...e,prepare:i=>si({try:e=>dT(t,n,r,i.arguments,e),catch:()=>({message:`Access check failed`})}).pipe(E(t=>t===void 0?e.prepare(i):b({execute:()=>zv({type:`result`,result:{content:[{type:`text`,text:JSON.stringify(t)}],isError:!1}})})))}}var hT=_s();async function gT(e){let t=await Tr(e);if(ra(t))return{value:t.value};let n=Gi(t.cause);if(pe(n))throw Wi(t.cause);return{issues:hT(n.success.issue).issues}}function _T(e){let t=Wh(e),n=Pp(t)[`~standard`].jsonSchema,r=Ip(t),i=Vp(t);return Object.freeze({description:{"~standard":{jsonSchema:{input:n.input,output:n.input}}},decode:e=>gT(r(e)),encode:e=>gT(i(e))})}function vT(e){let t=async t=>e[`~standard`].validate(t);return Object.freeze({description:e,decode:t,encode:t})}function yT(e){return Jp(e)?_T(e):vT(e)}var bT=Symbol(`mycelium.operation`),xT=Symbol(`mycelium.module`),ST=new WeakMap,CT=new WeakMap;function wT(e){let t=Object.freeze({[bT]:!0}),n=yT(e.input),r=e.output===void 0?void 0:yT(e.output),i={replay:e.replay??`unsafe`,...sT(e),input:n.description,invoke:async(t,i)=>{let a=await n.decode(t);if(a.issues!==void 0)throw new eS(a.issues);let o=await e.execute(a.value,i);if(r===void 0)return o;let s=await r.encode(o);if(s.issues!==void 0)throw new lS({reason:`Capability output failed its declared schema`,rawCause:new tS(s.issues)});return s.value}};e.description!==void 0&&(i.description=e.description),r!==void 0&&(i.output=r.description);let a=Object.freeze(i);return ST.set(t,a),t}function TT(e){let t=pn($w).safeParse(e.namespace??[]);if(!t.success)throw new K(`Invalid module namespace`);let n=Object.freeze({[xT]:!0}),r={id:e.id,grantKey:e.id,name:e.name??e.id,namespace:Object.freeze(t.data),operations:Object.freeze({...e.operations})};e.description!==void 0&&(r.description=e.description);let i=Object.freeze(r);return CT.set(n,i),n}function ET(e){return CT.has(e)}function DT(e){return ST.get(e)}function OT(e){return CT.get(e)}function kT(e,t,n){let r=OT(e);if(r===void 0)throw new K(`Unknown module registration`);let i={};for(let[e,a]of Object.entries(r.operations)){let r=n===``?e:`${n}.${e}`;if(ET(a)){let n=OT(a);if(n===void 0)throw new K(`Unknown child module registration`);i[e]=kT(a,t,[r,...n.namespace].join(`.`));continue}let o=DT(a);if(o===void 0)throw new K(`Unknown operation registration: ${e}`);let s=Object.freeze({[bT]:!0});ST.set(s,Object.freeze({...o,invoke:async(e,n)=>{let i=await t({operation:r,context:n});return i.kind===`refuse`?i.value:await o.invoke(e,n)}})),i[e]=s}return AT(TT(r.description===void 0?{id:r.id,name:r.name,namespace:r.namespace,operations:i}:{id:r.id,name:r.name,namespace:r.namespace,description:r.description,operations:i}),r.grantKey)}function AT(e,t){let n=OT(e);if(n===void 0)throw new K(`Unknown module registration`);let r=Object.freeze({[xT]:!0});return CT.set(r,Object.freeze({...n,grantKey:t})),r}function jT(e,t){if(t.length===0||t.length>160)throw new K(`Grant key must be non-empty and bounded`);return AT(e,t)}function MT(e,t){return kT(e,t,``)}function NT(e,t){return e<t?-1:+(e>t)}function PT(e){return e instanceof Error?e.message:`Capability declarations could not be compiled`}var FT=160;function IT(e){if(e.length===0||e.length>FT)throw new K(`Module id must be non-empty and bounded`)}function LT(e){if(!e.split(`.`).every(e=>$w.safeParse(e).success))throw new K(`Operation key must be a path segment or a dotted relative path`)}function RT(e){let t=e.replace(/[^A-Za-z0-9_]/g,`_`);return/^[A-Za-z]/.test(t)?t:`module_${t}`}function zT(e){let t=RT(e);return eT.safeParse(t).success?t:`module_${t}`}function BT(e,t){let n=new Set([`forage`,`env`]),r=new Map;for(let i of e){let e=t===`logical`?i.namespace:[],a=t===`logical`?RT(i.name):zT(i.name),o=t=>[...e,t].join(`.`),s=a,c=2;for(;n.has(o(s));)s=`${a}_${String(c)}`,c+=1;n.add(o(s)),r.set(i.id,s)}return r}var VT=14695981039346656037n,HT=1099511628211n,UT=18446744073709551615n;function WT(e,t){let n=e,r=BigInt(t.length);for(let e=0;e<8;e+=1)n=(n^r&255n)*HT&UT,r>>=8n;for(let e=0;e<t.length;e+=1){let r=t.charCodeAt(e);n=(n^BigInt(r&255))*HT&UT,n=(n^BigInt(r>>>8&255))*HT&UT}return n}function GT(e,t,n){let r=WT(VT,e),i=[...t.entries()].sort(([e],[t])=>NT(e,t));for(let[e,t]of i)r=WT(r,e),r=WT(r,t);let a=[...n].sort((e,t)=>NT(e.id,t.id));for(let e of a)r=WT(r,e.id),r=WT(r,e.version);return`installed-${r.toString(16).padStart(16,`0`)}`}function KT(){return[qx,Kx,Jx]}function qT(e,t,n,r,i,a=[]){return Object.entries(t.operations).flatMap(([t,o])=>{if(LT(t),ET(o)){let s=OT(o);if(s===void 0)throw new K(`Unknown child module registration`);return qT(e,s,n,[...r,t,...s.namespace],s.description??i,[...a,t,...s.namespace])}let s=DT(o);if(s===void 0)throw new K(`Unknown operation registration: ${[...r,t].join(`.`)}`);return[Object.freeze({grantKey:e,path:[...r,t].join(`.`),namespace:n,name:[...a,t].join(`.`),moduleDescription:i,operation:s})]})}function JT(e,t=[]){let n=e.map(e=>{let t=OT(e);if(t===void 0)throw new K(`Unknown module registration`);return IT(t.id),t}).sort((e,t)=>NT(e.id,t.id)),r=new Set;for(let e of n){if(r.has(e.id))throw new K(`Duplicate module id: ${e.id}`);r.add(e.id)}let i=BT(n,`transport`),a=BT(n,`logical`),o=Object.freeze(Object.fromEntries(n.map(e=>{let t=i.get(e.id);if(t===void 0)throw new K(`Missing module alias: ${e.id}`);let n=a.get(e.id);if(n===void 0)throw new K(`Missing logical alias: ${e.id}`);return[t,Object.freeze([...e.namespace,n])]}))),s=n.flatMap(e=>{let t=i.get(e.id);if(t===void 0)throw new K(`Missing module alias: ${e.id}`);let n=o[t];if(n===void 0)throw new K(`Missing namespace path: ${e.id}`);return qT(e.grantKey,e,t,n,e.description)}).sort((e,t)=>NT(e.path,t.path)),c=new Set(s.map(e=>e.path));if(c.size!==s.length)throw new K(`Duplicate operation path`);for(let e of KT()){if(c.has(e.path))throw new K(`Reserved intrinsic path: ${e.path}`);c.add(e.path)}for(let e of c){let t=e.split(`.`);for(let n=1;n<t.length;n+=1)if(c.has(t.slice(0,n).join(`.`)))throw new K(`Operation conflicts with namespace: ${e}`)}let l;try{l=Hx({revision:`prepared-content-stamp`,operations:[...s.map(({path:e,moduleDescription:t,operation:n})=>{let r={path:e,input:n.input};return n.description!==void 0&&(r.description=n.description),n.output!==void 0&&(r.output=n.output),t!==void 0&&(r.instructions=t),r}),...KT()]})}catch(e){throw new K(PT(e))}let u=GT(l.stamp(),i,t),d=Object.freeze({revision:u,search:l.search,describe:l.describe,list:l.list,stamp:l.stamp}),f=Object.freeze(Object.fromEntries([...i.entries()].map(([e,t])=>[t,e])));return Object.freeze({revision:u,catalog:d,operations:Object.freeze(s),moduleAliases:f,namespacePaths:o})}function YT(){return null}var XT=nn(),ZT=C(()=>Qr([Lt(),T(),xr(),dr()])),QT=C(()=>Cn(T(),lt())),$T=C(()=>DS.extend({timeoutMs:dr().int().min(1).max(9e5).optional(),abortGraceMs:dr().int().min(1).max(3e4).optional()}).optional()),eE=64,tE=262144,nE=new TextEncoder,rE=e=>{e(b(void 0))};function iE(e){let t=$T.safeParse(e);if(!t.success)throw new K(`Execution policy is invalid`);let n=t.data?.timeoutMs??18e4;return Object.freeze({timeoutMs:n,abortGraceMs:t.data?.abortGraceMs??5e3,...OS({sandboxCapacity:t.data?.sandboxCapacity,admissionWaitMs:t.data?.admissionWaitMs??n},(t.data?.sandboxCapacity,void 0))})}function aE(e){return S(function*(){let t=yield*w_(e);return Object.freeze({createGroup:()=>{let e=0,n=new Set,r=Kn(t=>e===0?(t(b(void 0)),w(()=>void 0)):(n.add(t),w(()=>n.delete(t))));return Object.freeze({start:r=>ft(i=>w(()=>{e+=1}).pipe(y(te(i(t.withPermits(1)(r)).pipe(Xn(w(()=>{if(--e,e===0){let e=[...n];n.clear(),e.forEach(rE)}}))))))),awaitIdle:r})}})})}function oE(e,t=0){if(t>eE)throw Error(`JSON value exceeds the nesting bound`);let n=ZT.safeParse(e);if(n.success)return n.data;if(Array.isArray(e))return e.map(e=>oE(e,t+1));let r=QT.safeParse(e);if(!r.success)throw r.error;return Object.fromEntries(Object.entries(r.data).filter(([,e])=>e!==void 0).map(([e,n])=>[e,oE(n,t+1)]))}function sE(e){return XT.parse(oE(e))}function cE(e){let t=JSON.stringify(sE(e)),n=nE.encode(t).byteLength;if(n>tE)throw new uS({size:n});return Object.freeze({text:t})}function lE(e,t){return Object.freeze(Object.fromEntries(Object.entries(e).map(([e,n])=>[e,Object.freeze(Object.fromEntries(Object.entries(n).map(([n,r])=>[n,async i=>{t();try{return sE(await r(i))}catch(t){throw vS(t)?t:t instanceof qb?new fS({namespace:e,operation:n,cause:{kind:`Forage`,message:t.message},rawCause:t}):t instanceof eS?new fS({namespace:e,operation:n,cause:{kind:`InvalidInput`,message:`Invalid operation input: ${we({issues:t.issues})}; use forage.describe`},rawCause:t}):t}}])))])))}function uE(e){return Kn(t=>{let n=t.bind(void 0,h);return e.aborted?n():e.addEventListener(`abort`,n,{once:!0}),w(e.removeEventListener.bind(e,`abort`,n))})}function dE(e,t){if(e===void 0)return()=>void 0;let n=t.bind(void 0);return e.aborted?(n(),()=>void 0):(e.addEventListener(`abort`,n,{once:!0}),e.removeEventListener.bind(e,`abort`,n))}function fE(e,t,n){return e===`deadline_exceeded`?new iS({limitMs:t,elapsedMs:n??0}):new oS({by:`caller`})}function pE(e){return Ea.pipe(be(t=>t-e))}function mE(t){return Ea.pipe(E(n=>hr(()=>{let r=t.executionId,i=new AbortController,a=n,o={kind:`waiting`},s,c=e=>{s===void 0&&o.kind!==`refused`&&(s=e,i.abort())},l=e=>{let n=new aS({capacity:t.policy.capacity,waitedMs:Math.max(0,e-a)});return o={kind:`refused`,failure:n},n},u=()=>{if(i.signal.aborted)throw fE(s,t.policy.timeoutMs)},d=dE(t.callerSignal,()=>{c(`cancelled`)}),f=n+t.policy.timeoutMs,p={executionId:r,deadlineAt:f,signal:i.signal,images:t.images};t.toolCallId!==void 0&&Object.assign(p,{toolCallId:t.toolCallId}),t.output!==void 0&&Object.assign(p,{output:t.output});let m=Object.freeze(p),ee=hr(()=>Ea.pipe(E(e=>o.kind===`refused`?x(o.failure):(e>=f&&c(`deadline_exceeded`),i.signal.aborted?pE(n).pipe(E(e=>x(fE(s,t.policy.timeoutMs,e)))):e>=a+t.policy.waitMs?x(l(e)):(o={kind:`admitted`},t.sandbox.execute(Object.freeze({executionId:r,code:t.code,timeoutMs:t.policy.timeoutMs,bindings:lE(t.createBindings(m),u),modules:t.modules,namespacePaths:t.namespacePaths,sessionId:t.sessionId}),i.signal).pipe(Ir(e=>Hi(e)?Bt(e):x(yS(Wi(e)))))))))),te=e=>g_(e).pipe(Gr({duration:t.policy.abortGraceMs,orElse:()=>x(s===`deadline_exceeded`?new iS({limitMs:t.policy.timeoutMs,elapsedMs:t.policy.timeoutMs,acknowledged:!1}):new oS({by:`caller`,acknowledged:!1}))})),g,ne=!1,re=e=>(ne=!0,pE(n).pipe(E(n=>{let i=yS(e),a=i instanceof iS?new iS({limitMs:i.limitMs,elapsedMs:n,acknowledged:i.acknowledged}):i,o=mS(a,r),s=Cn(T(),nn()).parse(xS(a));s.ref=r;let c={kind:`sandbox_failure`,ref:r,executionId:r,adapter:t.sandbox.adapter??`effect`,buildSha:t.sandbox.buildSha??YT(),tag:o._tag,fields:s,healthAlert:o._tag===`Unknown`},l=hr(()=>t.sandbox.onFailure?.(c)??h);return Xe(`sandbox_failure`,c).pipe(or({executionId:r,ref:r,adapter:c.adapter,tag:c.tag,buildSha:c.buildSha}),y(o._tag===`Unknown`?oo(so(ao(`sandbox_unknown`),{adapter:c.adapter}),1).pipe(y(Xe(`sandbox_health_alert`).pipe(or({ref:r,adapter:c.adapter})))):h),y(l.pipe(Ir(e=>Xe(`sandbox_failure_record_failed`,e)))),Er(o))})));return S(function*(){if(i.signal.aborted){let e=yield*pE(n);return yield*x(fE(s,t.policy.timeoutMs,e))}a=yield*Ea,g=yield*t.backingWork.start(ee);let r=yield*Ea,u=fn(Math.max(0,a+t.policy.waitMs-r)).pipe(y(Ea),E(e=>o.kind===`admitted`?Tt:o.kind===`refused`?b({kind:`busy`,failure:o.failure}):i.signal.aborted?b({kind:`cancelled`}):e>=f?(c(`deadline_exceeded`),b({kind:`deadline`})):b({kind:`busy`,failure:l(e)}))),d=yield*e(m_(g).pipe(be(e=>Object.freeze({kind:`settled`,exit:e}))),e(fn(Math.max(0,f-r)).pipe(y(w(()=>(c(`deadline_exceeded`),Object.freeze({kind:`deadline`}))))),e(uE(i.signal).pipe(Er(Object.freeze({kind:`cancelled`}))),u))),p=o.kind===`refused`?o.failure:d.kind===`busy`?d.failure:void 0;if(p!==void 0)return yield*te(g).pipe(y(x(p)));if(d.kind===`settled`)return yield*ge(d.exit,{onFailure:e=>s===void 0?Bt(e):pE(n).pipe(E(e=>x(fE(s,t.policy.timeoutMs,e)))),onSuccess:e=>en({try:()=>cE(e),catch:t=>vS(t)?t:new dS({kind:bS(e),rawCause:t})})});d.kind===`deadline`&&c(`deadline_exceeded`);let m=yield*pE(n);return yield*te(g).pipe(y(x(fE(s,t.policy.timeoutMs,m))))}).pipe(Ce(()=>(c(`cancelled`),(g===void 0?h:g_(g).pipe(Gt(t.policy.abortGraceMs),tn)).pipe(y(hr(()=>ne?h:re(new oS({by:`operator`})).pipe(tn))))))).pipe(cn(e=>re(e).pipe(E(x))),Xn(w(d)))})))}var hE=pm(()=>L([tm,em,nm,P,N,Nh,wm(AbortSignal),I(hE),gE])),gE=om(N,hE);function _E(e){return k(gE)(e)}var vE=om(N,Gh),yE=k(F({samplingParams:A(vE),samplingParamsByThinkingLevel:A(F({off:A(vE),minimal:A(vE),low:A(vE),medium:A(vE),high:A(vE),xhigh:A(vE),max:A(vE)}))}));function bE(e){return{...e,...yE(e)}}function xE(e){if(e===void 0)return;let{onPayload:t,onProviderStreamEvent:n,onResponse:r,...i}=e,a={...i};return t!==void 0&&(a.onPayload=(e,n)=>t(_E(e),bE(n))),n!==void 0&&(a.onProviderStreamEvent=(e,t)=>n(_E(e),bE(t))),r!==void 0&&(a.onResponse=(e,t)=>r(e,bE(t))),a}var SE=async(e,t,n)=>{let{streamSimple:r}=await fi(async()=>{let{streamSimple:e}=await import(`./compat-tatm8WJ0.js`);return{streamSimple:e}},__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22]));return r(e,di(t),xE(n))},CE=F({error:F({code:j(N),type:j(N)})});Rp(F({type:M(`response.failed`),response:CE})),Rp(W(CE)),Rp(F({type:M(`error`),status:j(P.check(Ym(),qm({minimum:100,maximum:599}))),code:j(N),error:j(CE.fields.error)})),k(wm(Uint8Array)),Rp(kh.check(qm({minimum:0,maximum:60}))),Rp(kh.check(Ym(),qm({minimum:0,maximum:864e10}))),Rp(R([`five_hour`,`seven_day`,`seven_day_opus`,`seven_day_sonnet`])),Rp(M(`rejected`)),Rp(M(`0`)),Rp(Bh),Rp(F({type:M(`error`),error:F({type:M(`overloaded_error`)})}));var wE=[/prompt (?:is )?too long/i,/prompt exceeds max length/i,/request_too_large/i,/input is too long for requested model/i,/exceeds the context window/i,/exceeds (?:the )?(?:model'?s )?maximum context length(?: of [\d,]+ tokens?|\s*\([\d,]+\))/i,/input token count.*exceeds the maximum/i,/maximum prompt length is \d+/i,/reduce the length of the messages/i,/maximum context length is \d+ tokens/i,/exceeds (?:the )?maximum allowed input length of [\d,]+ tokens?/i,/input \(\d+ tokens\) is longer than the model'?s context length \(\d+ tokens\)/i,/exceeds the limit of \d+/i,/exceeds the available context size/i,/greater than the context length/i,/context window exceeds limit/i,/exceeded model token limit/i,/too large for model with \d+ maximum context length/i,/prompt has [\d,]+ tokens?, but the configured context size is [\d,]+ tokens?/i,/model_context_window_exceeded/i,/prompt too long; exceeded (?:max )?context length/i,/range of input length should be/i,/context[_ ]length[_ ]exceeded/i,/too many tokens/i,/token limit exceeded/i],TE=/^4(?:00|13)\s*(?:status code)?\s*\(no body\)/i,EE=[/^(Throttling error|Service unavailable):/i,/rate limit/i,/too many requests/i];function DE(e,t){return!!(e.stopReason===`error`&&e.errorMessage&&!EE.some(t=>t.test(e.errorMessage))&&(wE.some(t=>t.test(e.errorMessage))||e.provider===`cerebras`&&TE.test(e.errorMessage))||t&&e.stopReason===`stop`&&e.usage.input+e.usage.cacheRead>t||t&&e.stopReason===`length`&&e.usage.output===0&&e.usage.input+e.usage.cacheRead>=t*.99)}function OE(e,t){return e.stopReason===`length`&&t>0&&e.usage.output<t}function kE(e){return new RegExp(e.join(`|`),`i`)}var AE=kE([`GoUsageLimitError`,`FreeUsageLimitError`,`Monthly usage limit reached`,`available balance`,`insufficient_quota`,`out of budget`,`quota exceeded`,`billing`,`subscription_sharing_usage_limit_exceeded`]),jE=kE(`overloaded,server_busy,servers are currently busy,currently experiencing high demand,model is at capacity,rate.?limit,too many requests,429,500,502,503,504,520,524,service.?(?:is.?)?(?:temporarily.?)?unavailable,server.?error,internal.?error,provider.?returned.?(?:an.?)?error,exceeded request buffer limit while retrying upstream,unable to forward upstream,network.?error,connection.?error,connection.?refused,connection.?lost,other side closed,fetch failed,getaddrinfo,ENOTFOUND,EAI_AGAIN,upstream.?connect,reset before headers,socket hang up,socket connection was closed,timed? out,timeout,terminated,websocket.?closed,websocket.?error,ended without,stream ended before message_stop,stream ended before a terminal response event,http2 request did not get a response,pending stream has been canceled,retry delay,you can retry your request,try your request again,please retry your request,ResourceExhausted,subscription_sharing_usage_unavailable,subscription_sharing_user_unavailable`.split(`,`)),ME=6e4;function NE(e,t){let n=e.baseDelayMs*2**Math.max(0,t-1);return Math.min(Number.isSafeInteger(n)?n:2**53-1,e.maxAgentDelayMs??6e4)}var PE=class extends Error{constructor(){super(`Aborted`)}};function FE(e,t){return new Promise((n,r)=>{if(t?.aborted){r(new PE);return}let i=setTimeout(n,e);t?.addEventListener(`abort`,()=>{clearTimeout(i),r(new PE)},{once:!0})})}async function IE(e,t,n,r){let i=t?.enabled?t.maxRetries:0,a=0,o;for(;;){let s=await e();if(s.stopReason===`aborted`)return o&&await r?.onRetryFinished?.(!1,o.attempt),s;if(s.stopReason!==`error`)return o&&await r?.onRetryFinished?.(!0,o.attempt),s;if(a>=i||!LE(s))return o&&await r?.onRetryFinished?.(!1,o.attempt,s.errorMessage),s;a++,o={attempt:a,errorMessage:s.errorMessage||`Unknown error`};let c=NE(t,a);await r?.onRetryScheduled?.(a,i,c,o.errorMessage);try{await FE(c,n)}catch(e){if(await r?.onRetryFinished?.(!1,a,o.errorMessage),e instanceof PE){let{errorMessage:e,...t}=s;return{...t,stopReason:`aborted`}}throw e}await r?.onRetryAttemptStart?.()}}function LE(e){if(e.stopReason!==`error`||!e.errorMessage)return!1;let t=e.errorMessage;return!AE.test(t)&&jE.test(t)}var RE={assign:0,create:0,clone:0,discard:0,update:0};function zE(e){return VE(e,null)}function BE(e){return VE(typeof e,`object`)&&!zE(e)}function VE(e,t){return e===t}function HE(e){return VE(e,`__proto__`)||VE(e,`constructor`)||VE(e,`prototype`)}function UE(e,t){return HE(t)?Object.prototype.hasOwnProperty.call(e,t):t in e}function WE(e){return Object.getOwnPropertyNames(e)}var GE={immutableTypes:!1,maxErrors:8,maxInstantiationCount:128,useAcceleration:!0,exactOptionalPropertyTypes:!1,enumerableKind:!1,correctiveParse:!1,unionPrioritySort:!0};function KE(){return GE}function qE(e){return KE().immutableTypes?Object.freeze(e):e}function JE(e,t){for(let n of Object.keys(t))Object.defineProperty(e,n,{configurable:!0,writable:!0,enumerable:!1,value:t[n]});return e}function YE(e,t){return{...e,...t}}function XE(e,t,n={}){RE.create+=1;let r=YE(t,n);return qE(KE().enumerableKind?YE(r,e):JE(r,e))}function ZE(e){return BE(e)}function QE(e){return ZE(e)&&UE(e,`~optional`)}function $E(e){return WE(e).filter(t=>!QE(e[t]))}function eD(e,t={}){let n=$E(e);return XE({"~kind":`Object`},{type:`object`,...n.length>0?{required:n}:{},properties:e},t)}var tD;(function(e){e[e.Array=0]=`Array`,e[e.BigInt=1]=`BigInt`,e[e.Boolean=2]=`Boolean`,e[e.Date=3]=`Date`,e[e.Constructor=4]=`Constructor`,e[e.Function=5]=`Function`,e[e.Null=6]=`Null`,e[e.Number=7]=`Number`,e[e.Object=8]=`Object`,e[e.RegExp=9]=`RegExp`,e[e.String=10]=`String`,e[e.Symbol=11]=`Symbol`,e[e.TypeArray=12]=`TypeArray`,e[e.Undefined=13]=`Undefined`})(tD||={}),Array.from({length:256}).map((e,t)=>BigInt(t));var nD=new Float64Array(1);new DataView(nD.buffer),new Uint8Array(nD.buffer),new TextEncoder;var rD=`-?(?:0|[1-9][0-9]*)`,iD=`-?(?:0|[1-9][0-9]*)(?:\\.[0-9]+)?`;function aD(e){return XE({"~kind":`String`},{type:`string`},e)}var oD=`^${rD}$`;`${iD}`;function sD(e,t){return Array.from({length:t-e+1},(t,n)=>String.fromCharCode(e+n))}var cD=[...sD(97,122),...sD(65,90)],lD=[`0`,...sD(49,57)];[...lD],[...cD,...lD],[...lD],new RegExp(oD);var uD={enabled:!0,maxRetries:3,baseDelayMs:2e3,maxAgentDelayMs:6e4},dD={firstEventMs:6e4,idleMs:12e4,attemptMs:6e5,outputBytes:2097152},fD=1e3,pD=Symbol(`Mule model limit`);function mD(e,t){return DE(e,t)}var hD=(e,t,n)=>({_tag:`MuleError`,phase:e,message:t,cause:n}),gD=(e,t)=>({kind:e,value:`mule_${e}_${ng()}`,parent:t}),_D=()=>h;function vD(e,t){let n={role:`toolResult`,toolCallId:e.id,toolName:e.name,content:t.content,isError:t.isError,timestamp:Date.now()};return t.usage!==void 0&&(n.usage=t.usage),n}var yD=(e,t)=>({content:[{type:`text`,text:e}],isError:!0,terminate:t});function bD(e,t){return e.find(e=>e.descriptor.name===t.name)}function xD(e,t,n,r){return r({type:`tool_execution_end`,run:t,turn:n,toolCall:e.identity,call:e.call,result:e.result})}function SD(e,t,n,r,i){let a=gD(`tool_call`,r);return S(function*(){if(yield*i({type:`tool_execution_start`,replay:e?.replay??`unsafe`,run:n,turn:r,toolCall:a,call:t}),e===void 0){let e=yD(`Tool "${t.name}" not found`),o={call:t,identity:a,result:e};return yield*xD(o,n,r,i),{kind:`finalized`,value:o}}let o=yield*_n(e.prepare(t));if(pe(o)){let e=yD(o.failure.message,o.failure.terminate),s={call:t,identity:a,result:e};return yield*xD(s,n,r,i),{kind:`finalized`,value:s}}return{kind:`prepared`,call:t,identity:a,tool:o.success}})}function CD(e,t,n,r){return S(function*(){let i,a;yield*fy(Zv(e.tool.execute()),o=>pe(o)?(a=o.failure,h):i===void 0?o.success.type===`result`?(i=o.success.result,h):r({type:`tool_execution_update`,run:t,turn:n,toolCall:e.identity,call:e.call,result:o.success.result}):h);let o=a===void 0?i??yD(`Tool "${e.call.name}" returned no result`):yD(a.message),s={call:e.call,identity:e.identity,result:o};return yield*xD(s,t,n,r),s})}function wD(e,t,n,r){let i=vD(e.call,e.result),a=gD(`tool_result`,e.identity);return S(function*(){return yield*r({type:`message_start`,run:t,turn:n,message:a,value:i}),yield*r({type:`message_end`,run:t,turn:n,message:a,value:i,data:e.result.data}),i})}function TD(e,t,n,r,i){let a=t.tools??[],o=t.toolExecution===`sequential`||e.some(e=>bD(a,e)?.executionMode===`sequential`);return S(function*(){let t=e=>e.kind===`finalized`?b(e.value):CD(e,n,r,i),s=o?yield*Kr(e,e=>E(SD(bD(a,e),e,n,r,i),t)):yield*S(function*(){let o=yield*Kr(e,e=>SD(bD(a,e),e,n,r,i));return yield*Mn(o.map(t),{concurrency:`unbounded`})});return{messages:yield*Kr(s,e=>wD(e,n,r,i)),terminate:s.length>0&&s.every(e=>e.result.terminate===!0)}})}var ED=e=>yD(`Tool call "${e.name}" was not executed: the response hit the output token limit, so its arguments may be truncated. Re-issue the tool call with complete arguments.`);function DD(e,t,n,r){return S(function*(){let i=yield*Kr(e,e=>S(function*(){let i=gD(`tool_call`,n),a={call:e,identity:i,result:ED(e)};return yield*r({type:`tool_execution_start`,replay:`unsafe`,run:t,turn:n,toolCall:i,call:e}),yield*xD(a,t,n,r),a}));return yield*Kr(i,e=>wD(e,t,n,r))})}function OD(e,t){return si({try:n=>{let r=()=>{t.abort(n.reason)};return n.aborted?r():n.addEventListener(`abort`,r,{once:!0}),Promise.resolve(e.next()).finally(()=>{n.removeEventListener(`abort`,r)})},catch:e=>hD(`model`,`Pi model stream failed`,e)})}function kD(e,t,n){return e.pipe(Gr({duration:t,orElse:()=>x(hD(`model`,n(),pD))}))}function AD(e,t,n,r,i,a){let o=gD(`message`,r),s,c={started:!1,terminal:void 0};return sn(S(function*(){let l=e.modelStreamLimits,u=Math.min(l?.firstEventMs??dD.firstEventMs,dD.firstEventMs),d=Math.min(l?.attemptMs??dD.attemptMs,dD.attemptMs),f=Math.min(l?.outputBytes??dD.outputBytes,dD.outputBytes);if([u,d,f,e.modelStreamIdleTimeoutMs??1].some(e=>!Number.isSafeInteger(e)||e<=0))return yield*x(hD(`model`,`Model stream limits must be positive safe integers`));let p=Date.now(),m=p,ee=0,te=0,g=new TextEncoder,ne=!1,re=e=>hD(`model`,`Model ${e} after ${String(Date.now()-p)} ms (max provider gap ${String(Math.max(ee,Date.now()-m))} ms, streamed ${String(te)} bytes)`,pD),ie=t=>{let n=Date.now()-p,r=d-n,i=Math.min(ne?dD.idleMs:u,e.modelStreamIdleTimeoutMs??dD.idleMs)-(Date.now()-m),a=r<=i?`attempt timed out`:ne?`stream timed out (silence)`:`first event timed out`;return kD(t,Math.max(0,Math.min(r,i)),()=>re(a).message)},ae=new AbortController;yield*br(()=>w(()=>{ae.abort(`Mule model scope closed`)}));let oe=(e.resolveApiKey===void 0?void 0:yield*e.resolveApiKey(e.model.provider))??e.streamOptions?.apiKey,se={...e.streamOptions,maxRetries:0,signal:ae.signal};oe!==void 0&&(se.apiKey=oe);let ce=e.prepareSystemPrompt===void 0?e.systemPrompt:yield*e.prepareSystemPrompt();e.prepareSystemPrompt!==void 0&&(yield*i({type:`model_prompt`,run:n,turn:r,attempt:a,systemPrompt:ce}));let le={systemPrompt:ce,messages:t},ue=(e.tools??[]).map(e=>e.descriptor);ue.length>0&&(le.tools=ue);let de=yield*ie(si({try:async()=>(e.stream??SE)(e.model,di(le),se),catch:e=>hD(`model`,`Pi model stream could not start`,e)})),fe=yield*jr(w(()=>de[Symbol.asyncIterator]()),e=>si({try:()=>(ae.abort(`Mule model stream closed`),new Promise(t=>{let n=setTimeout(t,fD);Promise.resolve(e.return?.()).then(()=>{clearTimeout(n),t()},()=>{clearTimeout(n),t()})})),catch:e=>hD(`model`,`Pi model stream failed`,e)}).pipe(Le)),pe=e=>{let a=Date.now();if(ee=Math.max(ee,a-m),m=a,ne=!0,(e.type===`text_delta`||e.type===`thinking_delta`||e.type===`toolcall_delta`)&&(te+=g.encode(e.delta).byteLength,te>f))return x(re(`output limit exceeded`));switch(`partial`in e&&(s=e.partial),e.type){case`start`:return t.push(e.partial),c.started=!0,i({type:`message_start`,run:n,turn:r,message:o,value:e.partial});case`text_start`:case`text_delta`:case`text_end`:case`thinking_start`:case`thinking_delta`:case`thinking_end`:case`toolcall_start`:case`toolcall_delta`:case`toolcall_end`:return c.started&&(t[t.length-1]=e.partial),i({type:`message_update`,run:n,turn:r,message:o,value:e.partial,event:e});case`done`:return c.terminal=e.message,h;case`error`:return c.terminal=e.error,h}},me=()=>ie(OD(fe,ae)),he=yield*me();for(;!he.done;)yield*pe(he.value),he=yield*me();let ge=c.terminal??(yield*ie(si({try:()=>de.result(),catch:e=>hD(`model`,`Pi model stream did not settle`,e)})));return c.started?t[t.length-1]=ge:(t.push(ge),yield*i({type:`message_start`,run:n,turn:r,message:o,value:ge})),yield*i({type:`message_end`,run:n,turn:r,message:o,value:ge}),{identity:o,message:ge}}).pipe(cn(l=>{if(l.cause!==pD)return x(l);let u={role:`assistant`,content:s?.content??[],api:e.model.api,provider:e.model.provider,model:e.model.id,usage:s?.usage??{input:0,output:0,cacheRead:0,cacheWrite:0,totalTokens:0,cost:{input:0,output:0,cacheRead:0,cacheWrite:0,total:0}},stopReason:`error`,timestamp:Date.now(),errorMessage:e.retry?.enabled&&a>e.retry.maxRetries?`The model failed ${String(a)} times on this conversation: ${l.message}`:l.message};return S(function*(){return c.started?t[t.length-1]=u:(t.push(u),yield*i({type:`message_start`,run:n,turn:r,message:o,value:u})),yield*i({type:`message_end`,run:n,turn:r,message:o,value:u}),{identity:o,message:u,limitReached:!0}})})))}function jD(e,t,n,r,i){return S(function*(){let a=e.retry===void 0?void 0:{...e.retry};if(a?.enabled&&[a.maxRetries,a.baseDelayMs,a.maxAgentDelayMs??6e4].some(e=>!Number.isSafeInteger(e)||e<0))return yield*x(hD(`model`,`Retry policy requires non-negative safe-integer counts and delays`));let o,s=0,c=0,l=!1,u,d=t=>e.onRetry===void 0?h:e.onRetry(t),f=(e,t)=>S(function*(){l=!0,yield*d(t===void 0?{type:`retry_finished`,run:n,turn:r,attempt:c,success:e}:{type:`retry_finished`,run:n,turn:r,attempt:c,success:e,finalError:t})});return yield*S(function*(){for(;;){if(o!==void 0){let e=t.indexOf(o.message);e!==-1&&t.splice(e,1)}o=yield*AD(e,t,n,r,i,++s);let l=o.message;if(l.stopReason!==`error`||a===void 0||!a.enabled||c>=a.maxRetries)return c>0&&(yield*f(l.stopReason!==`error`&&l.stopReason!==`aborted`,l.stopReason===`error`?l.errorMessage:void 0)),o;if(!(yield*en({try:()=>o?.limitReached===!0||e.retryable(l),catch:e=>hD(`model`,`Typed model retry decision failed`,e)})))return c>0&&(yield*f(!1,l.errorMessage)),o;c++,u=l.errorMessage??`Unknown error`;let p=yield*en({try:()=>e.retryAfterMs?.(l),catch:e=>hD(`model`,`Model retry delay observation failed`,e)}),m=Math.max(NE(a,c),p!==void 0&&Number.isSafeInteger(p)&&p>=0&&p<=6e4?p:0),ee=Math.min(1e3,m/4,Math.max(0,6e4-m)),h=m+Math.floor(Math.random()*ee);yield*d({type:`retry_scheduled`,run:n,turn:r,attempt:c,maxAttempts:a.maxRetries,delayMs:h,errorMessage:u}),yield*fn(h),yield*d({type:`retry_attempt_started`,run:n,turn:r,attempt:c})}}).pipe(Ce(()=>c===0||l?h:f(!1,u)))})}var MD=e=>e.stopReason===`aborted`?`cancelled`:e.stopReason===`error`?`failed`:`completed`;function ND(e,t,n,r,i,a){return Kr(e,e=>S(function*(){let o=gD(`message`,i);t.push(e),n.push(e),yield*a({type:`message_start`,run:r,turn:i,message:o,value:e}),yield*a({type:`message_end`,run:r,turn:i,message:o,value:e})})).pipe(tn)}function PD(e,t,n,r,i,a,o){return S(function*(){yield*o({type:`turn_start`,run:r,turn:i}),yield*ND(a,t,n,r,i,o);let s=yield*jD(e,t,r,i,o),c=MD(s.message)!==`completed`,l=s.message.content.filter(e=>e.type===`toolCall`),u=l.length===0||c?{messages:[],terminate:!1}:s.message.stopReason===`length`?{messages:yield*DD(l,r,i,o),terminate:!1}:yield*TD(l,e,r,i,o);t.push(...u.messages),n.push(s.message,...u.messages),yield*o({type:`turn_end`,run:r,turn:i,message:s.message,toolResults:u.messages});let d={message:s.message,toolResults:u.messages,terminate:u.terminate};return s.limitReached&&s.message.errorMessage!==void 0?{...d,modelLimitReason:s.message.errorMessage}:d})}function FD(e,t,n,r,i,a){let o=gD(`turn`,i);return S(function*(){if(MD(t.message)!==`completed`)return{message:t.message,toolResults:[],terminate:!0};let s=yield*Kr(t.tools,n=>S(function*(){if(n.state===`completed`&&n.message!==void 0)return{message:n.message,terminate:n.result.terminate===!0,recorded:!0};let r=bD(e.tools??[],n.call),s;if(t.message.stopReason!==`length`&&(n.state===`pending`||n.state===`started`&&n.replay===`safe`&&r?.replay===`safe`)){let e=yield*SD(r,n.call,i,o,a);s=e.kind===`finalized`?e.value:yield*CD(e,i,o,a)}else s={call:n.call,identity:gD(`tool_call`,o),result:n.state===`completed`?n.result:n.state===`pending`&&t.message.stopReason===`length`?ED(n.call):yD(`Interrupted by a restart; it may or may not have completed; check before retrying.`)},yield*a({type:`tool_execution_start`,replay:`unsafe`,run:i,turn:o,toolCall:s.identity,call:s.call}),yield*xD(s,i,o,a);return{message:yield*wD(s,i,o,a),terminate:s.result.terminate===!0,recorded:!1}})),c=s.filter(({recorded:e})=>!e).map(({message:e})=>e);return n.push(...c),r.push(...c),{message:t.message,toolResults:s.map(({message:e})=>e),terminate:s.length>0&&s.every(({terminate:e})=>e)}})}function ID(e,t,n,r){return S(function*(){if(e.shouldStopAfterTurn!==void 0&&(yield*e.shouldStopAfterTurn({message:t.message,toolResults:t.toolResults,context:n,newMessages:r})))return{continue:!1,pending:[]};let i=e.getSteeringMessages===void 0?[]:[...yield*e.getSteeringMessages()];if(t.message.content.some(e=>e.type===`toolCall`)&&!t.terminate||i.length>0)return{continue:!0,pending:i};let a=e.getFollowUpMessages===void 0?[]:[...yield*e.getFollowUpMessages()];return{continue:a.length>0,pending:a}})}function LD(e,t,n,r,i,a,o){return S(function*(){yield*a({type:`run_end`,run:e,terminal:t,outcome:i});let s={status:i,run:e,terminal:t,message:n,messages:r};return o===void 0?s:{...s,modelLimitReason:o}})}function RD(e,t=_D){return S(function*(){let n=yield*w_(1),r={started:!1,ended:!1},i=e=>hr(()=>(e.type===`run_end`&&(r.ended=!0),n.withPermits(1)(t(e)))).pipe(jn(()=>w(()=>{e.type===`run_start`&&(r.started=!0)}))),a=gD(`run`),o=gD(`terminal`,a);return yield*BD(e,i,a,o).pipe(Oe(e=>{let t=zD(e);return!r.started||r.ended||t===void 0?h:i({type:`run_end`,run:a,terminal:o,outcome:t}).pipe(Le)}))})}function zD(e){if(ra(e))return;if(Hi(e.cause))return`cancelled`;let t=Ki(e.cause);if(!(Fn(t)&&t.value.phase===`listener`))return`failed`}function BD(e,t,n,r){return S(function*(){let i=[...e.messages],a=[],o=e.getSteeringMessages===void 0?[]:[...yield*e.getSteeringMessages()],s,c;if(yield*t({type:`run_start`,run:n}),e.resume!==void 0){let s=yield*FD(e,e.resume,i,a,n,t),c=MD(s.message),l=c===`completed`?yield*ID(e,s,i,a):{continue:!1,pending:[]};if(!l.continue&&o.length===0)return yield*LD(n,r,s.message,a,c,t);o.push(...l.pending)}do{let l=yield*PD(e,i,a,n,gD(`turn`,n),o,t);s=l.message;let u=MD(l.message);if(u!==`completed`)return yield*LD(n,r,l.message,a,u,t,l.modelLimitReason);if(e.prepareNextTurn!==void 0&&!l.terminate&&l.message.content.some(e=>e.type===`toolCall`)){let t=yield*e.prepareNextTurn({message:l.message,toolResults:l.toolResults,context:i,newMessages:a});t!==void 0&&i.splice(0,i.length,...t)}let d=yield*ID(e,l,i,a);o=[...d.pending],c=d.continue}while(c);return yield*LD(n,r,s,a,`completed`,t)})}var VD={run:RD},HD=class{#e=new Map;#t;constructor(e=8){this.#t=e}push(e,t){let n=this.#e.get(e)??[];if(n.length>=this.#t)throw new fS({namespace:`execute`,operation:`images`,cause:{kind:`Unavailable`,message:`Image collector cap reached for this execution (max ${String(this.#t)} images). Process images one at a time or write them to files.`}});let r=`img_${String(n.length)}`;return n.push(Object.freeze({...t})),this.#e.set(e,n),r}drain(e){let t=this.#e.get(e);return t===void 0?[]:(this.#e.delete(e),t)}dispose(e){this.#e.delete(e)}},UD=8192,WD=UD*4,GD=new TextEncoder,KD=()=>new TextDecoder(`utf-8`,{ignoreBOM:!0,fatal:!1}),qD=class e{wake;#e={stdout:{decoder:KD(),pending:new Uint8Array},stderr:{decoder:KD(),pending:new Uint8Array}};#t=KD();#n=Array.from({length:UD},()=>void 0);#r=0;#i=0;#a=0;#o=0;#s=0;#c=0;#l=!1;#u=!1;constructor(e){this.wake=e}static make(){return Pg({capacity:1,strategy:`dropping`}).pipe(be(t=>new e(t)))}write(e,t){if(this.#u||t.length===0)return;let n=this.#e[e];this.#c+=t.length;for(let e=0;e<t.length;e+=WD){let r=t.subarray(e,e+WD),i=n.decoder.decode(r,{stream:!0}),a=new Uint8Array(n.pending.length+r.length);a.set(n.pending),a.set(r,n.pending.length);let o=this.#f(a);n.pending=a.slice(a.length-o),this.#h(i,a.length-o,a)}this.#l=!0,Rg(this.wake,void 0)}#d(e,t){let n=this.#t.decode(e.subarray(0,t),{stream:!0});return this.#t.decode(),n}#f(e){for(let t=1;t<=Math.min(3,e.length);t++){let n=e.subarray(e.length-t);if(this.#d(n,n.length).length===0)return t}return 0}#p(){let e=this.#n[this.#r];if(e===void 0)throw Error(`Missing output ring entry`);this.#n[this.#r]=void 0,this.#r=(this.#r+1)%UD,this.#i--,this.#a-=e.textBytes,this.#o-=e.newlines,this.#s+=e.rawBytes}#m(e,t,n){let r=e.raw;if(r===null){this.#p();return}let i=e=>{let i=this.#d(r,e);return GD.encode(i).length>=t&&i.split(`
19
19
  `).length-1>=n},a=Math.min(r.length,Math.max(4,t));for(;a<r.length&&!i(a);)a=Math.min(r.length,a*2);let o=0;for(;o<a;){let e=Math.floor((o+a)/2);i(e)?a=e:o=e+1}let s=this.#d(r,o);if(s.length===e.text.length){this.#p();return}let c=o-this.#f(r.subarray(0,o)),l=GD.encode(s).length,u=s.split(`
20
20
  `).length-1;e.raw=r.slice(c),e.text=this.#d(e.raw,e.raw.length),e.rawBytes-=c,e.textBytes-=l,e.newlines-=u,this.#a-=l,this.#o-=u,this.#s+=c}#h(e,t,n){if(e.length===0)return;let r={text:e,raw:n,rawBytes:t,textBytes:GD.encode(e).length,newlines:e.split(`
21
21
  `).length-1};for(this.#i===UD&&this.#p(),this.#n[(this.#r+this.#i)%UD]=r,this.#i++,this.#a+=r.textBytes,this.#o+=r.newlines;this.#a>UD||this.#o>=200;){let e=this.#n[this.#r];if(e===void 0)throw Error(`Missing output ring entry`);let t=Math.max(0,this.#a-UD),n=Math.max(0,this.#o-199);e.textBytes<=t||e.newlines<n?this.#p():this.#m(e,t,n)}}snapshot(){let e=``;for(let t=0;t<this.#i;t++){let n=this.#n[(this.#r+t)%UD];if(n===void 0)throw Error(`Missing output ring entry`);e+=n.text}return{tail:e,droppedBytes:this.#s,totalBytes:this.#c}}#g(){if(!this.#l)return;this.#l=!1;let{tail:e,...t}=this.snapshot();return{type:`update`,result:{isError:!1,content:[{type:`text`,text:e}],data:t}}}finish(){if(!this.#u){this.#u=!0;for(let e of[this.#e.stdout,this.#e.stderr]){let t=e.decoder.decode();this.#h(t,e.pending.length,null),e.pending=new Uint8Array,t.length>0&&(this.#l=!0)}return this.#g()}}get updates(){return Gv(this.wake).pipe(Xv(()=>fn(`100 millis`).pipe(be(()=>this.#u?void 0:this.#g()))),ay(e=>e!==void 0))}dispose(){this.#u=!0,this.#n.fill(void 0),this.#r=this.#i=this.#a=this.#o=0,this.#c=this.#s=0,this.#l=!1;for(let e of[this.#e.stdout,this.#e.stderr])e.decoder.decode(),e.pending=new Uint8Array}},JD=F({code:N}),YD='Inside execute, call forage.search, forage.list or forage.describe to discover operations and inspect their inputs. forage is available only there, not as a separate tool. Run async JavaScript in the sandbox. Each call is a fresh sandbox, not a REPL: nothing survives between calls, so redefine helpers or persist state to a file. Never shadow injected module names with local bindings. Find operations with await forage.search({ query }) using one short keyword such as read or shell, or page them all with forage.list({limit:50}), optionally by namespace, until nextCursor is null. Inspect input with await forage.describe({ path }) before calling; describe known paths directly. Call an operation as await env.<path>({ ... }) with the exact dotted path, for example await env.computers.local.exec({ command: "pwd" }); a bare computers.local.exec is not defined. Put multiline shell commands in a template literal. Code is JavaScript first, so double each backslash the shell needs (`\\\\(` passes `\\(`; `\\(` becomes `(`). For file edits, prefer Files operations when available. Explicitly return the final value. Before treating a shell or process result as success, check status, exitCode and stderr.';function XD(e,t,n,r){let i={module:e.grantKey,operation:e.name,access:e.operation.access,confirm:e.operation.confirm};return async a=>await dT(n,{sessionId:r},i,a,t.signal)??await e.operation.invoke(a,t)}function ZD(e,t,n,r){let i=0,a=new Map;for(let o of e){let e=o.namespace,s=o.name,c=a.get(e)??new Map;c.set(s,e=>XD(o,Object.freeze({...t,operationOrdinal:i++}),n,r)(e)),a.set(e,c)}return Object.freeze(Object.fromEntries([...a].map(([e,t])=>[e,Object.freeze(Object.fromEntries(t))])))}function QD(e,t){let n=e.safeParse(t);if(!n.success)throw new eS(n.error.issues);return n.data}function $D(e){return Object.freeze({list:t=>Promise.resolve().then(()=>e.list(QD(Lb,t))),describe:t=>Promise.resolve().then(()=>e.describe(QD(Ib,t))),search:t=>Promise.resolve().then(()=>e.search(QD(Fb,t)))})}function eO(e,t,n,r,i){return Object.freeze({...ZD(e,n,r,i),forage:$D(t)})}function tO(e,t,n,r,i,a,o,s){let c=n.execution??iE(void 0),l=new HD,u=(u,d,f,p,m)=>mE({executionId:u,toolCallId:p,output:m,images:Object.freeze({push:e=>l.push(u,e)}),code:d,callerSignal:f,policy:c,sandbox:n,backingWork:r,createBindings:n=>eO(e,t,Object.freeze({...n,toolCallCode:d}),s,o),modules:i,namespacePaths:a,sessionId:o}),d=(e,t)=>hr(()=>{let n=ng();return u(n,e,t).pipe(Xn(w(()=>{l.dispose(n)})))}),f=(e,t,n)=>hr(()=>{let r=ng(),i=()=>l.drain(r);return u(r,e,void 0,t,n).pipe(vt({onSuccess:e=>b(nO({text:e.text,isError:!1},i())),onFailure:e=>{let t=i();return e instanceof uS&&t.length>0?b(nO({text:hS(e),isError:!0},t)):x(rO(e))}}),Xn(w(()=>{l.dispose(r)})))}),p={replay:`unsafe`,descriptor:{name:`execute`,description:YD,parameters:eD({code:aD()},{additionalProperties:!1})},prepare:e=>Ip(JD)(e.arguments).pipe(be(({code:t})=>({execute:()=>Jv(S(function*(){let n=yield*qD.make();yield*br(()=>w(()=>{n.dispose()}));let r=yield*Vn(f(t,e.id,{write:(e,t)=>{n.write(e,t)}}),{startImmediately:!0});return iy(n.updates,jv(m_(r)).pipe(Qv(e=>{let t=n.finish();return ty(Uv(t===void 0?[]:[t]),jv(e))})),{haltStrategy:`right`}).pipe(ly(e=>e.type===`result`))}))})),it(()=>({message:`Invalid execute arguments`})))};return Object.freeze({effectTool:p,execute:d})}function nO(e,t){let n=t.map(e=>({type:`image`,data:e.data,mimeType:e.mimeType})),r=[{type:`text`,text:e.text},...n];return t.length===0?{type:`result`,result:{content:r,isError:e.isError}}:{type:`result`,result:{content:r,data:{images:t.map(e=>({bytes:e.bytes,mimeType:e.mimeType,path:e.path}))},isError:e.isError}}}function rO(e){let t={_tag:`MuleError`,phase:`tool`,message:vS(e)?hS(e):e.message};return e instanceof aS?{...t,cause:e}:t}function iO(e,t){return e<t?-1:+(e>t)}var aO=128,oO=C(()=>T().min(1).max(160)),sO=C(()=>Zn({version:T().min(1).max(160),modules:pn(lt())})),cO=1e3;function lO(e){if(e.length>aO)throw new K(`Capability source count exceeds bound`);let t=[...e].sort((e,t)=>iO(e.id,t.id)),n=new Set;for(let e of t){if(!oO.safeParse(e.id).success)throw new K(`Capability source id must be non-empty and bounded`);if(n.has(e.id))throw new K(`Duplicate capability source id: ${e.id}`);n.add(e.id)}return t}function uO(e){if(e>cO)throw new K(`Candidate module count exceeds bound`)}function dO(e,t){let n=sO.safeParse(e);if(!n.success)throw new K(`Capability source snapshot must have a non-empty bounded version`);uO(t+n.data.modules.length)}function fO(e,t,n,r,i){return ft(a=>S(function*(){let o=t=>si({try:()=>t.release(),catch:()=>new $x(e.id,`release`)}).pipe(cn(e=>w(()=>{n.push(e)}))),s=yield*en({try:()=>{let t=new AbortController;return{controller:t,outcome:e.acquire(i===void 0?{signal:t.signal,invalidate:r}:{signal:t.signal,invalidate:r,session:i}).then(e=>Qi(e),()=>ea(new $x(e.id,`acquire`)))}},catch:()=>new $x(e.id,`acquire`)});yield*xa(t,Dt(()=>s.outcome).pipe(E(e=>ra(e)?o(e.value):h)));let c=yield*a(Dt(()=>s.outcome)).pipe(Ce(()=>w(()=>{s.controller.abort()})));return ia(c)?yield*Bt(c.cause):c.value}))}function pO(e){return S(function*(){let t=yield*en({try:()=>lO(e.sources),catch:e=>e instanceof K?e:new K(`Capability sources are invalid`)});yield*en({try:()=>{uO(e.modules.length)},catch:e=>e instanceof K?e:new K(`Static capability modules are invalid`)});let n=yield*_a(),r=[],i=!1,a=[...e.modules],o=[];return yield*S(function*(){for(let s of t){let t=yield*fO(s,n,r,()=>{i=!0},e.session);yield*en({try:()=>{dO(t.snapshot,a.length)},catch:e=>e instanceof K?e:new K(`Capability source snapshot is invalid`)}),a.push(...t.snapshot.modules),o.push({id:s.id,version:t.snapshot.version})}let s=e.precompiled??(yield*en({try:()=>JT(a,o),catch:e=>e instanceof K?e:new K(`Capability compilation failed`)})),c=e.backingWork.createGroup(),l=tO(s.operations,s.catalog,e.sandbox,c,s.moduleAliases,s.namespacePaths,e.session?.sessionId??null,e.access),u=!1;return Object.freeze({compiled:s,executeDoor:l,isStale:()=>i,close:()=>S(function*(){u||(u=!0,yield*c.awaitIdle,yield*wa(n,na));let e=r[0];e!==void 0&&(yield*x(e))})})}).pipe(Oe(e=>ra(e)?h:wa(n,e)))})}var mO=2;function hO(e){return S(function*(){for(let t=0;t<mO;t+=1){let t=yield*pO(e);if(!t.isStale())return t;yield*t.close()}return yield*x(new $x(void 0,`stale`))})}function gO(e,t,n){return ft(r=>r(e.take(1)).pipe(E(()=>w(t).pipe(Xn(e.release(1)))),E(n)))}function _O(e,t){return ni(e.candidate.close().pipe(vt({onFailure:t=>pa(e.settled,t).pipe(y(x(t))),onSuccess:()=>ma(e.settled,void 0).pipe(y(w(()=>{t.delete(e)})))})))}function vO(e,t){return e.runCleanup?_O(e.installed,t):da(e.installed.settled)}function yO(e,t){return Mn(e.map(e=>vO(e,t).pipe(Dn)),{concurrency:`unbounded`}).pipe(E(e=>{let t=e.find(ia);return t===void 0?h:Bt(t.cause)}))}function bO(e){return S(function*(){let t=yield*w_(1),n=yield*en({try:()=>iE(e.execution),catch:e=>e instanceof K?e:new K(`Execution policy is invalid`)}),r=yield*aE(n.capacity),i=Object.freeze({execute:e.sandbox.execute,adapter:e.sandbox.adapter,buildSha:e.sandbox.buildSha,onFailure:e.onSandboxFailure,execution:n}),a=e.modules.length===0&&e.sources.length>0?void 0:yield*en({try:()=>JT(e.modules),catch:e=>e instanceof K?e:new K(`Capability compilation failed`)}),o=yield*en({try:()=>Object.freeze(e.tools.map(t=>mT(t,e.access,{sessionId:e.session?.sessionId??null}))),catch:e=>e instanceof K?e:new K(`Direct tool labels are invalid`)}),s,c=new Set,l=!1;if(e.sources.length===0&&a!==void 0){let t={candidate:yield*hO({...e,sandbox:i,backingWork:r,precompiled:a}),settled:yield*ua(),leases:0,retired:!1,closing:!1};s=t,c.add(t)}let u=()=>gO(t,()=>(l=!0,[...c].map(e=>{e.retired=!0;let t=e.leases===0&&!e.closing;return t&&(e.closing=!0),{installed:e,runCleanup:t}})),e=>yO(e,c));return yield*br(()=>u().pipe(Mt)),Object.freeze({acquire:()=>t.withPermits(1)(S(function*(){if(l)return yield*x(new Qx);if(s===void 0||s.candidate.isStale()){let t=yield*hO({...e,sandbox:i,backingWork:r}),n=s,a={candidate:t,settled:yield*ua(),leases:0,retired:!1,closing:!1};s=a,c.add(a),n!==void 0&&(n.retired=!0,n.leases===0&&!n.closing&&(n.closing=!0,yield*_O(n,c)))}let n=s;n.leases+=1;let a,u=()=>gO(t,()=>{if(a!==void 0)return a?{installed:n,runCleanup:!1}:void 0;if(--n.leases,a=n.retired&&n.leases===0&&!n.closing,a)return n.closing=!0,{installed:n,runCleanup:!0}},e=>e===void 0?h:vO(e,c));return yield*br(()=>u().pipe(Mt)),Object.freeze({revision:n.candidate.compiled.revision,catalog:n.candidate.compiled.catalog,executeDoor:n.candidate.executeDoor,effectExecuteTool:n.candidate.executeDoor.effectTool,tools:o,release:u})})),close:u})})}function xO(e){return Object.freeze({adapter:e.adapter??`promise`,buildSha:e.buildSha,execute:(t,n)=>ni(si({try:()=>e.execute(t,n),catch:yS}))})}function SO(e){return bO({modules:e.modules??[],sources:e.sources??[],session:e.session,execution:e.execution,sandbox:e.sandbox,onSandboxFailure:e.onSandboxFailure,tools:e.tools??[],access:e.access??{}}).pipe(be(e=>Object.freeze({acquire:()=>e.acquire().pipe(be(e=>Object.freeze({revision:e.revision,catalog:e.catalog,executeTool:e.effectExecuteTool,tools:e.tools,release:e.release}))),close:e.close})))}async function CO(e,t){let n=await Tr(e,t);if(ra(n))return n.value;let r=Ki(n.cause);if(Fn(r))throw r.value;if(Hi(n.cause))throw t?.signal?.reason instanceof Error?t.signal.reason:new DOMException(`The operation was aborted`,`AbortError`);let i=Wi(n.cause);throw i instanceof Error?i:Error(`Effect failed without an Error cause`)}async function wO(e){let t=await CO(_a()),n=e.onSandboxFailure;try{let r=await CO(bO({modules:e.modules??[],sources:e.sources??[],session:e.session,execution:e.execution,sandbox:xO(e.sandbox),onSandboxFailure:n===void 0?void 0:e=>Dt(()=>n(e)),tools:e.tools??[],access:e.access??{}}).pipe(ya(t))),i=async e=>{let t=await CO(_a());try{let n=await CO(r.acquire().pipe(ya(t)),e?.signal===void 0?void 0:{signal:e.signal}),i;return Object.freeze({revision:n.revision,catalog:n.catalog,executeTool:n.effectExecuteTool,tools:n.tools,release:()=>(i??=CO(n.release().pipe(Xn(wa(t,na)))),i)})}catch(e){throw await CO(wa(t,na)),e}},a;return Object.freeze({acquire:i,close:()=>(a??=CO(r.close().pipe(Xn(wa(t,na)))),a)})}catch(e){throw await CO(wa(t,na)),e}}var TO=pm(()=>L([em,nm,Im,N,um(I(TO)),Yp(om(N,TO))])),EO=N.check(lh(1),fh(256)),DO=N.check(lh(1),fh(128)),OO=F({kind:M(`sandbox_failure`),ref:EO,executionId:EO,adapter:DO,buildSha:z(DO),tag:R([`SourceInvalid`,`GuestThrew`,`DeadlineExceeded`,`SandboxBusy`,`Cancelled`,`DispatchLost`,`SandboxCrashed`,`BadResponse`,`ResultTooLarge`,`ResultNotJson`,`CapabilityFailed`,`Unknown`]),fields:om(N,TO),healthAlert:nm});function kO(e){return wT(e)}function AO(e){return TT(e)}var jO=Object.freeze({module:AO,operation:kO,make:wO,gate:MT,grantAs:jT}),MO=Gh,NO=4096,PO=new TextEncoder,FO=MO.check(V(e=>PO.encode(JSON.stringify(e)).byteLength<=NO)),IO=O(FO);function LO(e,t){if(Jp(e))return Ae(O(e)(t));let n=e[`~standard`].validate(t);if(Rr(n,`then`))throw new G(`contract`,`invalid`,`Host metadata schema must validate synchronously`);return n.issues===void 0}function RO(e,t){let n=IO(t);if(pe(n))throw new G(`contract`,`invalid`,`Host metadata is not JSON within 4096 bytes`);if(e!==void 0&&!LO(e.schema,n.success))throw new G(`contract`,`invalid`,`Host metadata does not match the host's schema`);return n.success}function zO(e,t){return JSON.stringify(e)===JSON.stringify(t)}function BO(e,t){Fr(Xe(`shiitake_operation_failed`,jo(t)).pipe(or({operation:e,errorKind:t instanceof Error?`error`:`non-error`})))}var VO=64,HO=256,UO=new WeakMap,WO=new TextEncoder;function GO(e){let t=UO.get(e);if(t!==void 0)return t;let n=JSON.stringify(e),r=Object.freeze({data:n,bytes:WO.encode(n).byteLength});return UO.set(e,r),r}function KO(e){if(e.kind===`update`&&e.sandboxFailures!==void 0){let t={...e};return delete t.sandboxFailures,t}if(e.kind===`reset`&&e.baseline.sandboxFailures!==void 0){let t={...e.baseline};return delete t.sandboxFailures,{...e,baseline:t}}return e}function qO(e){let t=new Set,n=!1,r,i=e=>{Xt(Gg(e.frames)),e.bytes=0};return{register(a=!1){let o={frames:Xt(Ig(256)),bytes:0,lagged:!1,closed:!1,observed:-1,includeSandboxFailures:a};t.add(o);let s=hr(()=>o.closed?b(`closed`):r===void 0?o.lagged?b(`reset`):n?b(`closed`):Jg(o.frames).pipe(Ka(()=>b(`closed`)),E(e=>r===void 0?(e!==`reset`&&e!==`closed`&&(o.bytes-=GO(e).bytes),b(e)):x(r))):x(r));return Object.freeze({take:s,checkpoint:(e=-1)=>{i(o),o.lagged=!1,o.observed=e},close:()=>{o.closed||(o.closed=!0,i(o),t.delete(o),Hg(o.frames),t.size===0&&e())}})},publish(e,r=1/0){if(n)return;let a=KO(e);for(let n of t){if(n.closed||n.lagged||r<=n.observed)continue;let t=n.includeSandboxFailures?e:a,{bytes:o}=GO(t);n.bytes+o>1048576||!Rg(n.frames,t)?(i(n),n.lagged=!0,Rg(n.frames,`reset`)):n.bytes+=o}},end(e){if(!n){n=!0,r=e;for(let e of t)i(e),e.lagged=!1,Hg(e.frames)}}}}var JO=new WeakMap;function YO(e,t){for(let n of JO.get(e)??[])if(n.observes(t))return!0;return!1}function XO(e,t){return e===`closed`||t===`closed`?`closed`:e===`reset`||t===`reset`?`reset`:e===`durable`||t===`durable`?`durable`:e===`activity`||t===`activity`?`activity`:`progress`}function ZO(e,t){if(e.pendingCount>=HO){e.pendingCount=0,e.pendingReason=void 0,e.reset=!0;return}e.pendingCount+=1,e.pendingReason=e.pendingReason===`durable`||t===`durable`?`durable`:e.pendingReason===`activity`||t===`activity`?`activity`:`progress`}function QO(e,t){if(e.closed||(e.revision+=1,e.reset))return;let n=e.wake;if(n===void 0){ZO(e,t);return}e.wake=void 0;try{n(t)}catch(t){BO(`observation-delivery`,t),e.pendingCount=0,e.pendingReason=void 0,e.reset=!0}}function $O(e,t){for(let n of e)n.queued&&!n.settlementOnly&&n.sessionId!==t&&QO(n,`activity`)}function ek(e,t,n=`durable`){let r=JO.get(e);if(r!==void 0)for(let e of r)try{e.publish({kind:`session`,sessionId:t,reason:n})}catch(e){BO(`owner-observation-publish`,e);continue}}function tk(e){let t=JO.get(e);if(t!==void 0)for(let e of t)try{e.publish({kind:`agent-execution`})}catch(e){BO(`owner-execution-change-publish`,e)}}function nk(e){let t=new Map,n=new Set,r=JO.get(e)??new Set,i=!1,a=e=>{if(e.closed)return`closed`;if(e.reset)return e.reset=!1,`reset`;if(e.pendingCount===0)return;e.pendingCount=0;let t=e.pendingReason;return e.pendingReason=void 0,t??`progress`},o=e=>{if(e.closed)return;e.closed=!0,e.pendingCount=0,e.pendingReason=void 0,e.reset=!1;let r=e.wake;e.wake=void 0,n.delete(e);let i=t.get(e.sessionId);if(i?.delete(e),i?.size===0&&t.delete(e.sessionId),r!==void 0)try{r(`closed`)}catch(e){BO(`observation-listener-close`,e)}},s={publish:e=>{if(e.kind===`agent-execution`){$O(n,null);return}e.sessionId!==null&&e.reason!==`settlement`&&$O(n,e.sessionId);let r=e.sessionId===null?n:t.get(e.sessionId);if(r!==void 0)for(let t of r)t.settlementOnly&&e.reason!==`settlement`||QO(t,e.reason===`settlement`?`durable`:e.reason)},observes:e=>[...t.get(e)??[]].some(e=>!e.closed&&!e.settlementOnly)};return r.add(s),JO.set(e,r),Object.freeze({register:(e,r)=>hr(()=>{if(i)return x(new G(`runtime`,`closed`,`Shiitake is closed`));if(n.size>=VO)return x(new G(`runtime`,`rejected`,`Observation capacity is exhausted`));let s={revision:0,sessionId:e,settlementOnly:r===`settlement`,closed:!1,pendingCount:0,pendingReason:void 0,queued:!0,reset:!1,wake:void 0},c=t.get(e)??new Set;c.add(s),t.set(e,c),n.add(s);let l=w(()=>a(s)),u=Kn(e=>{let t=a(s);if(t!==void 0){e(b(t));return}let n=t=>{e(b(t))};return s.wake=n,w(()=>{s.wake===n&&(s.wake=void 0)})});return b(Object.freeze({get revision(){return s.revision},pollSignal:l,awaitSignal:u,close:()=>{o(s)},setQueued:e=>{s.closed||(s.queued=e)}}))}),close:w(()=>{if(!i){i=!0,r.delete(s),r.size===0&&JO.delete(e);for(let e of n)o(e)}})})}var rk=200,ik={onExcessProperty:`error`},ak=new TextEncoder,ok=U.pipe(B(H(0))),sk=N.pipe(B(lh(1)),B(V(e=>ak.encode(e).byteLength<=256)));O(F({limit:A(U.pipe(B(qm({minimum:1,maximum:rk})))),after:A(N)}),ik);var ck=W(cm([ok,sk]));O(ck),Kp(ck),O(F({session_id:sk,last_activity_at:ok,state:R([`needs_you`,`running`,`errored`,`done`]),bytes:U.pipe(B(H(0)))}),ik);var lk=k(F({extension_id:N,value_json:N})),uk=k(W(by)),dk=k(xy),fk=Kp(W(by));function pk(e){e.sql.exec(`CREATE TABLE IF NOT EXISTS session_attention_grants (
@@ -1 +1 @@
1
- import{An as e}from"./Effect-CtszBD7f.js";import{Ni as t,Vi as n,c as r,cr as i,i as a,ki as o,or as s,pi as c,qn as l,sr as u,wo as d,zi as f}from"./extension-hook-Br5iAg1w.js";Object.freeze({module:s,operation:u,gate:i}),o(l),t(f(l));var p=class extends e()(`@fungi.computer/shiitake/ExtensionRead`){},m=class extends e()(`@fungi.computer/shiitake/ExtensionTx`){},h=class extends d(`ExtensionStateError`){},g=class extends d(`AdmissionError`){},_=class extends d(`ExtensionCommandError`){},v=class extends d(`ExtensionStop`){};d(`ExtensionActivationError`),t(a),t(r),n(c);export{v as a,h as i,_ as n,m as o,p as r,g as t};
1
+ import{An as e}from"./Effect-CtszBD7f.js";import{Ni as t,Vi as n,c as r,cr as i,i as a,ki as o,or as s,pi as c,qn as l,sr as u,wo as d,zi as f}from"./extension-hook-CmoMuW6C.js";Object.freeze({module:s,operation:u,gate:i}),o(l),t(f(l));var p=class extends e()(`@fungi.computer/shiitake/ExtensionRead`){},m=class extends e()(`@fungi.computer/shiitake/ExtensionTx`){},h=class extends d(`ExtensionStateError`){},g=class extends d(`AdmissionError`){},_=class extends d(`ExtensionCommandError`){},v=class extends d(`ExtensionStop`){};d(`ExtensionActivationError`),t(a),t(r),n(c);export{v as a,h as i,_ as n,m as o,p as r,g as t};