@systemfsoftware/omp-agent-discipline 1.5.0 → 1.5.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.
@@ -11,4 +11,4 @@ import{t as e}from"./rolldown-runtime-DK3Fl9T5.js";import{$ as t,$i as n,$n as r
11
11
  `),n=e.errorCall.stack.trim().split(`
12
12
  `),i=t.slice(2).join(`
13
13
  `).trim();i.includes(`(`)||(i=i.replace(/at (.*)/,`at ($1)`));let a=n.slice(2).join(`
14
- `).trim();return a.includes(`(`)||(a=a.replace(/at (.*)/,`at ($1)`)),r=`${i}\n${a}`,r}},...e.spanOptions};return _k(t,e.spanName,i)}const jk=Ja,Mk=()=>e=>e,Nk=()=>e=>e,Pk=()=>e=>e;export{MT as $,bb as $t,eT as A,ES as At,GD as B,Vb as Bt,GC as C,hc as Cn,KS as Ct,mw as D,Qo as Dn,QS as Dt,JT as E,Zo as En,ZS as Et,mT as F,fx as Ft,uD as G,Wb as Gt,oO as H,Ub as Ht,hT as I,yx as It,MO as J,Db as Jt,pD as K,Lb as Kt,HD as L,hx as Lt,DC as M,CS as Mt,kO as N,kS as Nt,Lw as O,mo as On,GS as Ot,fT as P,ux as Pt,AT as Q,yb as Qt,UD as R,vx as Rt,Ok as S,_c as Sn,qS as St,qT as T,$o as Tn,XS as Tt,OE as U,Eb as Ut,wT as V,Tb as Vt,AE as W,Ib as Wt,_O as X,Fb as Xt,IO as Y,Kb as Yt,kT as Z,qb as Zt,sw as _,Ku as _n,HO as _t,NC as a,jy as an,hD as at,sD as b,Zu as bn,WS as bt,rw as c,Py as cn,qw as ct,Nw as d,Tv as dn,iT as dt,xb as en,jT as et,dw as f,gh as fn,OO as ft,KE as g,qu as gn,VO as gt,CT as h,nd as hn,BO as ht,xT as i,Ay as in,Sw as it,qE as j,OS as jt,Qw as k,wS as kt,Ew as l,Fy as ln,Ww as lt,GE as m,yh as mn,ow as mt,Cw as n,Cb as nn,vw as nt,oT as o,My as on,bD as ot,fw as p,$ as pn,rD as pt,wD as q,Gb as qt,yT as r,vb as rn,xw as rt,lT as s,Ny as sn,Gw as st,TC as t,Sb as tn,IE as tt,Dw as u,L_ as un,rT as ut,lw as v,Yu as vn,UO as vt,GT as w,pc as wn,YS as wt,lD as x,Tc as xn,JS as xt,UT as y,Xu as yn,VS as yt,WD as z,ax as zt};
14
+ `).trim();return a.includes(`(`)||(a=a.replace(/at (.*)/,`at ($1)`)),r=`${i}\n${a}`,r}},...e.spanOptions};return _k(t,e.spanName,i)}const jk=Ja,Mk=()=>e=>e,Nk=()=>e=>e,Pk=()=>e=>e;export{AT as $,yb as $t,eT as A,wS as At,GD as B,ax as Bt,GC as C,_c as Cn,qS as Ct,mw as D,Zo as Dn,ZS as Dt,JT as E,$o as En,XS as Et,mT as F,ux as Ft,AE as G,Ib as Gt,oO as H,Tb as Ht,hT as I,fx as It,wD as J,Gb as Jt,uD as K,Wb as Kt,HD as L,yx as Lt,DC as M,OS as Mt,kO as N,CS as Nt,Lw as O,Qo as On,QS as Ot,fT as P,kS as Pt,kT as Q,qb as Qt,UD as R,hx as Rt,Ok as S,Tc as Sn,JS as St,qT as T,pc as Tn,YS as Tt,uO as U,Ub as Ut,wT as V,Vb as Vt,OE as W,Eb as Wt,IO as X,Kb as Xt,MO as Y,Db as Yt,_O as Z,Fb as Zt,sw as _,qu as _n,VO as _t,NC as a,Ay as an,Sw as at,sD as b,Xu as bn,VS as bt,rw as c,Ny as cn,Gw as ct,Nw as d,L_ as dn,rT as dt,bb as en,MT as et,dw as f,Tv as fn,iT as ft,KE as g,nd as gn,BO as gt,CT as h,yh as hn,ow as ht,xT as i,vb as in,xw as it,qE as j,ES as jt,Qw as k,mo as kn,GS as kt,Ew as l,Py as ln,qw as lt,GE as m,$ as mn,rD as mt,Cw as n,Sb as nn,IE as nt,oT as o,jy as on,hD as ot,fw as p,gh as pn,OO as pt,pD as q,Lb as qt,yT as r,Cb as rn,vw as rt,lT as s,My as sn,bD as st,TC as t,xb as tn,jT as tt,Dw as u,Fy as un,Ww as ut,lw as v,Ku as vn,HO as vt,GT as w,hc as wn,KS as wt,lD as x,Zu as xn,WS as xt,UT as y,Yu as yn,UO as yt,WD as z,vx as zt};
@@ -1,4 +1,4 @@
1
- import{Ws as e,aa as t}from"./core-CwsVf2Ey.js";import{D as n,W as r,m as i}from"./Effect-B34dlqAS.js";import{C as a,t as o,v as s,w as c,x as l}from"./dist-48FGb8Hs.js";import{a as u,i as d,r as f,t as p}from"./Match-COXzoyjd.js";const m={task:!0,agent:!0},h=e=>m[e.trim().toLowerCase()]===!0,g=e=>{let t=e.slice(8);if(t.length===0)return null;let n=t.search(/[:/]/);return n===-1?t:t.slice(0,n)},_=e=>e.split(`\\`).join(`/`),v=(e,t)=>{let n=`/skills/`+t+`/SKILL.md`;return e.endsWith(n)},y=(e,t)=>{if(e.startsWith(`skill://`)){let n=g(e);return n!==null&&t.includes(n)}let n=_(e);for(let e of t)if(v(n,e))return!0;return!1},b={hasObjective:/\bobjective\b/i,hasWriteScope:/\bwrite_scope\b/i,hasVerifyCommands:/\bverify_commands\b/i},x=e=>({hasObjective:b.hasObjective.test(e),hasWriteScope:b.hasWriteScope.test(e),hasVerifyCommands:b.hasVerifyCommands.test(e)});var S=class extends t(`DispatchDoctrineExecutorDeps`)(){};const C=Symbol.for(`@systemfsoftware/omp-agent-discipline/CheckDispatchCommand`);var w=class extends a()(`CheckDispatchCommand`,{toolName:l,doctrineLoaded:s,gateEnabled:s}){[C]=C};const T=Symbol.for(`@systemfsoftware/omp-agent-discipline/DispatchDoctrineVerdict`);var E=class extends a()(`Allow`,{}){[T]=T},D=class extends a()(`DeliverDoctrine`,{reason:l}){[T]=T};c(E,D);const O=e=>e.gateEnabled&&h(e.toolName)&&!e.doctrineLoaded,k=e=>d(O(e)).pipe(u(!0,()=>new D({reason:`Refuse monolithic dispatches: size the unit, specify it completely, then dispatch — or do the work inline.
1
+ import{Ws as e,aa as t}from"./core-CwsVf2Ey.js";import{D as n,G as r,m as i}from"./Effect-BnMIG7Ln.js";import{C as a,t as o,v as s,w as c,x as l}from"./dist-DNAOOlxn.js";import{a as u,i as d,r as f,t as p}from"./Match-COXzoyjd.js";const m={task:!0,agent:!0},h=e=>m[e.trim().toLowerCase()]===!0,g=e=>{let t=e.slice(8);if(t.length===0)return null;let n=t.search(/[:/]/);return n===-1?t:t.slice(0,n)},_=e=>e.split(`\\`).join(`/`),v=(e,t)=>{let n=`/skills/`+t+`/SKILL.md`;return e.endsWith(n)},y=(e,t)=>{if(e.startsWith(`skill://`)){let n=g(e);return n!==null&&t.includes(n)}let n=_(e);for(let e of t)if(v(n,e))return!0;return!1},b={hasObjective:/\bobjective\b/i,hasWriteScope:/\bwrite_scope\b/i,hasVerifyCommands:/\bverify_commands\b/i},x=e=>({hasObjective:b.hasObjective.test(e),hasWriteScope:b.hasWriteScope.test(e),hasVerifyCommands:b.hasVerifyCommands.test(e)});var S=class extends t(`DispatchDoctrineExecutorDeps`)(){};const C=Symbol.for(`@systemfsoftware/omp-agent-discipline/CheckDispatchCommand`);var w=class extends a()(`CheckDispatchCommand`,{toolName:l,doctrineLoaded:s,gateEnabled:s}){[C]=C};const T=Symbol.for(`@systemfsoftware/omp-agent-discipline/DispatchDoctrineVerdict`);var E=class extends a()(`Allow`,{}){[T]=T},D=class extends a()(`DeliverDoctrine`,{reason:l}){[T]=T};c(E,D);const O=e=>e.gateEnabled&&h(e.toolName)&&!e.doctrineLoaded,k=e=>d(O(e)).pipe(u(!0,()=>new D({reason:`Refuse monolithic dispatches: size the unit, specify it completely, then dispatch — or do the work inline.
2
2
 
3
3
  rules:
4
4
  - GATE: decomposition is mandatory when ANY hold — multi-subsystem; exceeds one focused session for the worker's model class; irreversible side effects; verification longer than the work; incompatible reasoning modes. Dispatching monolithically anyway is an invalid dispatch: split, or do it yourself.
@@ -6,6 +6,6 @@ rules:
6
6
  - CHECK: verifier is not the maker. Run each unit's verify commands fresh in your own context; never accept a worker's reported output or completeness claims. A verify failure rejects the unit: record the failure, re-dispatch with the evidence.
7
7
  - FENCE: parallel units need disjoint write scopes, confirmed by comparing write_scope declarations literally — never inferred from topic. Overlap forces serialization.
8
8
 
9
- Full doctrine: skill://task-decomposition — sizing calibration, the dispatch contract, rejection rules, repair-retry. Refuse monolithic dispatches: size, specify, then dispatch or refuse.`})),u(!1,()=>new E),p),A=e=>d(e).pipe(f(`DeliverDoctrine`,e=>({block:!0,reason:e.reason})),f(`Allow`,()=>void 0),p),j=e=>n(function*(){return(yield*(yield*S).load(e)).dispatch_doctrine_skills??[]});function M(e,t,r){return n(function*(){let n=yield*j(e),i=new w({toolName:t,doctrineLoaded:r,gateEnabled:n.length>0});return{skills:n,gate:A(k(i))}})}const N={extractSpecShape:x,matchesDoctrineSkillPath:y},P=r(S,n(function*(){return yield*o})),F=new Map,I=new Map,L=new Map,R=new Map,z=e=>{let t=e.sessionManager.getSessionId();return typeof t==`string`?t:``},B=e=>typeof e==`object`&&!!e&&!Array.isArray(e),V=e=>B(e)?e:{},H=(e,...t)=>{for(let n of t){let t=e[n];if(typeof t==`string`&&t.length>0)return t}return``},U=(e,t)=>{if(e!==``){if(F.has(e)){F.set(e,!0);return}if(F.size<50){F.set(e,!0);return}for(let n of F.keys())if(n!==t){F.delete(n),F.set(e,!0);return}F.set(e,!0)}},W=(e,t)=>{if(I.size>=200){let e=I.keys().next().value;typeof e==`string`&&I.delete(e)}I.set(e,t)},G=e=>{let t=import(`./run-safe.policy-CuLHWxRa.js`).then(({runSafe:t})=>t(M(e,`read`,!1).pipe(P))).then(({skills:t})=>{L.set(e,t)}).catch(()=>{L.set(e,[])}).finally(()=>{R.get(e)===t&&R.delete(e)});return R.set(e,t),t},K=(e,t,n)=>{if(e!==void 0)try{let r=e.info;typeof r==`function`&&r.call(e,t,n)}catch{}},q=e=>e===null?1:e.length,J=e=>{let t=H(e,`task`,`description`,`prompt`),n=e.tasks;if(!Array.isArray(n))return t;let r=n.map(e=>typeof e==`string`?e:H(V(e),`task`,`description`,`prompt`)).filter(e=>e.length>0).join(`
9
+ Full doctrine: skill://task-decomposition — sizing calibration, the dispatch contract, rejection rules, repair-retry. Refuse monolithic dispatches: size, specify, then dispatch or refuse.`})),u(!1,()=>new E),p),A=e=>d(e).pipe(f(`DeliverDoctrine`,e=>({block:!0,reason:e.reason})),f(`Allow`,()=>void 0),p),j=e=>n(function*(){return(yield*(yield*S).load(e)).dispatch_doctrine_skills??[]});function M(e,t,r){return n(function*(){let n=yield*j(e),i=new w({toolName:t,doctrineLoaded:r,gateEnabled:n.length>0});return{skills:n,gate:A(k(i))}})}const N={extractSpecShape:x,matchesDoctrineSkillPath:y},P=r(S,n(function*(){return yield*o})),F=new Map,I=new Map,L=new Map,R=new Map,z=e=>{let t=e.sessionManager.getSessionId();return typeof t==`string`?t:``},B=e=>typeof e==`object`&&!!e&&!Array.isArray(e),V=e=>B(e)?e:{},H=(e,...t)=>{for(let n of t){let t=e[n];if(typeof t==`string`&&t.length>0)return t}return``},U=(e,t)=>{if(e!==``){if(F.has(e)){F.set(e,!0);return}if(F.size<50){F.set(e,!0);return}for(let n of F.keys())if(n!==t){F.delete(n),F.set(e,!0);return}F.set(e,!0)}},W=(e,t)=>{if(I.size>=200){let e=I.keys().next().value;typeof e==`string`&&I.delete(e)}I.set(e,t)},G=(e,t)=>{let n=e(M(t,`read`,!1).pipe(P)).then(({skills:e})=>{L.set(t,e)}).catch(()=>{L.set(t,[])}).finally(()=>{R.get(t)===n&&R.delete(t)});return R.set(t,n),n},K=(e,t,n)=>{if(e!==void 0)try{let r=e.info;typeof r==`function`&&r.call(e,t,n)}catch{}},q=e=>e===null?1:e.length,J=e=>{let t=H(e,`task`,`description`,`prompt`),n=e.tasks;if(!Array.isArray(n))return t;let r=n.map(e=>typeof e==`string`?e:H(V(e),`task`,`description`,`prompt`)).filter(e=>e.length>0).join(`
10
10
  `);return t.length===0?r:t+`
11
- `+r},Y=e=>{let t=e.tasks;return Array.isArray(t)?t:null},X=t=>{t.on(`tool_call`,async(n,r)=>{let{runSafe:a}=await import(`./run-safe.policy-CuLHWxRa.js`),o=z(r),s=V(n.input),c=o===``?!1:F.get(o)??!1,l=await a(i(M(r.cwd,n.toolName,c)).pipe(P));if(e(l))throw l.left;let{skills:u,gate:d}=l.right;L.set(r.cwd,u);let f=q(Y(s)),p=N.extractSpecShape(J(s));if(d!==void 0)return U(o,o),K(t.logger,`agent_discipline.dispatch.blocked`,{plugin:`agent_discipline`,session_id:o,tool:n.toolName,reason:`kernel_delivered`,batch_size:f,has_objective:p.hasObjective,has_write_scope:p.hasWriteScope,has_verify_commands:p.hasVerifyCommands}),{block:!0,reason:d.reason};K(t.logger,`agent_discipline.dispatch.observed`,{plugin:`agent_discipline`,session_id:o,tool:n.toolName,batch_size:f,has_objective:p.hasObjective,has_write_scope:p.hasWriteScope,has_verify_commands:p.hasVerifyCommands})}),t.on(`tool_execution_start`,(e,t)=>{if(e.toolName!==`read`)return;let n=e.toolCallId;if(typeof n!=`string`||n.length===0)return;let r=V(e.args).path;typeof r==`string`&&(W(n,r),L.has(t.cwd)||G(t.cwd))}),t.on(`tool_execution_end`,async(e,n)=>{if(e.toolName!==`read`)return;let r=e.toolCallId;if(typeof r!=`string`||r.length===0)return;let i=I.get(r);if(I.delete(r),i===void 0||e.isError)return;let a=R.get(n.cwd);a!==void 0&&await a;let o=L.get(n.cwd);if(o===void 0||!N.matchesDoctrineSkillPath(i,o))return;let s=z(n);s!==``&&(U(s,s),K(t.logger,`agent_discipline.doctrine.loaded`,{plugin:`agent_discipline`,session_id:s,tool:e.toolName}))}),t.on(`session_start`,(e,t)=>{G(t.cwd)})};export{X as DispatchDoctrineExtension};
11
+ `+r},Y=e=>{let t=e.tasks;return Array.isArray(t)?t:null},X=(t,n)=>{t.on(`tool_call`,async(r,a)=>{let o=z(a),s=V(r.input),c=o===``?!1:F.get(o)??!1,l=await n(i(M(a.cwd,r.toolName,c)).pipe(P));if(e(l))throw l.left;let{skills:u,gate:d}=l.right;L.set(a.cwd,u);let f=q(Y(s)),p=N.extractSpecShape(J(s));if(d!==void 0)return U(o,o),K(t.logger,`agent_discipline.dispatch.blocked`,{plugin:`agent_discipline`,session_id:o,tool:r.toolName,reason:`kernel_delivered`,batch_size:f,has_objective:p.hasObjective,has_write_scope:p.hasWriteScope,has_verify_commands:p.hasVerifyCommands}),{block:!0,reason:d.reason};K(t.logger,`agent_discipline.dispatch.observed`,{plugin:`agent_discipline`,session_id:o,tool:r.toolName,batch_size:f,has_objective:p.hasObjective,has_write_scope:p.hasWriteScope,has_verify_commands:p.hasVerifyCommands})}),t.on(`tool_execution_start`,(e,t)=>{if(e.toolName!==`read`)return;let r=e.toolCallId;if(typeof r!=`string`||r.length===0)return;let i=V(e.args).path;typeof i==`string`&&(W(r,i),L.has(t.cwd)||G(n,t.cwd))}),t.on(`tool_execution_end`,async(e,n)=>{if(e.toolName!==`read`)return;let r=e.toolCallId;if(typeof r!=`string`||r.length===0)return;let i=I.get(r);if(I.delete(r),i===void 0||e.isError)return;let a=R.get(n.cwd);a!==void 0&&await a;let o=L.get(n.cwd);if(o===void 0||!N.matchesDoctrineSkillPath(i,o))return;let s=z(n);s!==``&&(U(s,s),K(t.logger,`agent_discipline.doctrine.loaded`,{plugin:`agent_discipline`,session_id:s,tool:e.toolName}))}),t.on(`session_start`,(e,t)=>{G(n,t.cwd)})};export{X as DispatchDoctrineExtension};
@@ -0,0 +1,16 @@
1
+ import{$c as e,$o as t,$s as n,Ao as r,As as i,Bc as a,Bs as o,Cc as s,Cr as c,Dc as l,Dn as u,Do as d,Ds as f,Ec as p,Es as m,Fc as h,Fi as g,Fo as ee,Fs as _,Gs as te,Hi as ne,Hs as re,Ic as ie,Io as ae,Is as v,Jc as oe,Ji as se,Jr as ce,Js as le,Ko as ue,Ks as y,Lc as de,Lr as fe,Ls as pe,Mi as me,Nc as he,Ni as ge,Nr as _e,Ns as ve,Oo as ye,Os as be,Pi as xe,Pr as Se,Ps as Ce,Qi as we,Qo as Te,Qs as b,Rc as Ee,Sc as De,So as Oe,Ss as ke,Tc as Ae,To as je,Tr as Me,Ts as Ne,Ui as Pe,Uo as Fe,Us as Ie,Vi as Le,Vo as Re,Vs as ze,Wi as Be,Wo as Ve,Ws as He,Xc as Ue,Xn as We,Xs as Ge,Yc as Ke,Yi as qe,Ys as Je,Zi as Ye,Zo as Xe,_l as x,aa as Ze,al as Qe,as as $e,b as et,bo as tt,bs as nt,ci as rt,cl as it,cr as at,ct as ot,dl as st,dt as ct,ea as lt,el as ut,fl as dt,fs as ft,ft as pt,gl as mt,go as ht,il as gt,in as _t,jc as vt,ji as yt,js as bt,k as xt,ko as St,kr as Ct,ks as wt,li as Tt,ll as Et,nl as Dt,no as Ot,oc as kt,ol as At,pl as jt,pt as Mt,qc as Nt,qi as Pt,qo as Ft,qs as It,ra as Lt,rl as Rt,rt as zt,ta as Bt,tl as Vt,ul as Ht,us as Ut,ut as Wt,vl as S,vn as Gt,vo as Kt,w as qt,wr as Jt,ws as Yt,xo as Xt,xs as Zt,yl as C,yo as Qt,ys as $t,zc as en,zo as tn,zs as w}from"./core-CwsVf2Ey.js";import{$ as nn,$t as rn,A as an,At as T,C as on,Cn as sn,Ct as cn,D as ln,Dn as un,Dt as dn,E as fn,En as pn,Et as mn,F as hn,Ft as gn,H as _n,I as vn,It as yn,J as bn,K as xn,L as Sn,Lt as Cn,M as wn,Mt as Tn,N as En,Nt as Dn,O as On,On as kn,Ot as An,P as E,Pt as jn,Q as Mn,R as Nn,Rt as Pn,S as Fn,Sn as In,St as Ln,T as Rn,Tn as zn,Tt as Bn,U as Vn,V as Hn,W as Un,X as Wn,Y as Gn,Z as Kn,_ as qn,_n as Jn,_t as Yn,a as Xn,an as Zn,at as Qn,b as D,bn as $n,bt as er,cn as tr,ct as nr,d as rr,dn as ir,dt as ar,en as or,f as sr,ft as cr,g as O,gn as lr,gt as ur,h as dr,hn as fr,ht as pr,i as mr,it as k,j as hr,jt as gr,k as _r,kn as vr,kt as yr,l as br,ln as xr,m as Sr,mn as Cr,mt as wr,n as A,nn as Tr,o as Er,on as Dr,ot as Or,p as kr,pn as Ar,q as jr,qt as Mr,r as Nr,rn as Pr,rt as j,s as Fr,sn as Ir,st as Lr,tn as Rr,tt as zr,u as Br,un as Vr,ut as Hr,v as Ur,vn as Wr,vt as M,w as Gr,wt as Kr,x as qr,xn as Jr,xt as Yr,y as Xr,yn as Zr,yt as Qr,z as $r}from"./Effect-BnMIG7Ln.js";import{a as ei,c as ti,d as ni,f as ri,i as ii,l as ai,n as oi,o as si,p as ci,r as li,s as ui,u as di}from"./Cause-CTmrUQgG.js";import{a as fi,c as pi,d as mi,f as hi,h as gi,i as _i,l as vi,m as yi,n as bi,p as xi,r as Si,s as Ci,u as wi}from"./Exit-Dq5mS6lc.js";import Ti from"node:os";const Ei=Tt,Di=e=>t=>{let n=t===void 0?Object.create(kt):Ei(t);return n._tag=e,n},Oi=rt,ki=function(){let e=Symbol.for(`effect/Data/Error/plainArgs`);return{BaseEffectError:class extends et{constructor(t){super(t?.message,t?.cause?{cause:t.cause}:void 0),t&&(Object.assign(this,t),Object.defineProperty(this,e,{value:t,enumerable:!1}))}toJSON(){return{...this[e],...this}}}}.BaseEffectError}(),Ai=e=>{let t={BaseEffectError:class extends ki{_tag=e}};return t.BaseEffectError.prototype.name=e,t.BaseEffectError},ji=Symbol.for(`effect/DateTime`),Mi=Symbol.for(`effect/DateTime/TimeZone`),Ni={[ji]:ji,pipe(){return De(this,arguments)},[s](){return this.toString()},toJSON(){return ua(this).toJSON()}},Pi={...Ni,_tag:`Utc`,[a](){return h(this,Ee(this.epochMillis))},[he](e){return Bi(e)&&e._tag===`Utc`&&this.epochMillis===e.epochMillis},toString(){return`DateTime.Utc(${ua(this).toJSON()})`}},Fi={...Ni,_tag:`Zoned`,[a](){return C(Ee(this.epochMillis),ie(de(this.zone)),h(this))},[he](e){return Bi(e)&&e._tag===`Zoned`&&this.epochMillis===e.epochMillis&&vt(this.zone,e.zone)},toString(){return`DateTime.Zoned(${wa(this)})`}},Ii={[Mi]:Mi,[s](){return this.toString()}},Li={...Ii,_tag:`Named`,[a](){return h(this,en(`Named:${this.id}`))},[he](e){return Vi(e)&&e._tag===`Named`&&this.id===e.id},toString(){return`TimeZone.Named(${this.id})`},toJSON(){return{_id:`TimeZone`,_tag:`Named`,id:this.id}}},Ri={...Ii,_tag:`Offset`,[a](){return h(this,en(`Offset:${this.offset}`))},[he](e){return Vi(e)&&e._tag===`Offset`&&this.offset===e.offset},toString(){return`TimeZone.Offset(${pa(this.offset)})`},toJSON(){return{_id:`TimeZone`,_tag:`Offset`,offset:this.offset}}},zi=(e,t,n)=>{let r=Object.create(Fi);return r.epochMillis=e,r.zone=t,Object.defineProperty(r,"partsUtc",{value:n,enumerable:!1,writable:!0}),Object.defineProperty(r,"adjustedEpochMillis",{value:void 0,enumerable:!1,writable:!0}),Object.defineProperty(r,"partsAdjusted",{value:void 0,enumerable:!1,writable:!0}),r},Bi=e=>Nt(e,ji),Vi=e=>Nt(e,Mi),Hi=e=>Vi(e)&&e._tag===`Offset`,Ui=e=>Vi(e)&&e._tag===`Named`,Wi=e=>e._tag===`Utc`,Gi=e=>e._tag===`Zoned`,Ki=jt((e,t)=>e.epochMillis===t.epochMillis),qi=e=>{let t=Object.create(Pi);return t.epochMillis=e,Object.defineProperty(t,"partsUtc",{value:void 0,enumerable:!1,writable:!0}),t},Ji=e=>{let t=e.getTime();if(Number.isNaN(t))throw new oi(`Invalid date`);return qi(t)},Yi=e=>{if(Bi(e))return e;if(e instanceof Date)return Ji(e);if(typeof e==`object`){let t=new Date(0);return ga(t,e),Ji(t)}else if(typeof e==`string`&&!Xi(e))return Ji(new Date(e+`Z`));return Ji(new Date(e))},Xi=e=>/Z|[+-]\d{2}$|[+-]\d{2}:?\d{2}$|\]$/.test(e),Zi=(e,t)=>{if(t?.timeZone===void 0&&Bi(e)&&Gi(e))return e;let n=Yi(e);if(n.epochMillis<-86399999568e5||n.epochMillis>86399999496e5)throw RangeError(`Epoch millis out of range: ${n.epochMillis}`);let r;if(t?.timeZone===void 0){let e=new Date(n.epochMillis).getTimezoneOffset()*-60*1e3;r=aa(e)}else if(Vi(t?.timeZone))r=t.timeZone;else if(typeof t?.timeZone==`number`)r=aa(t.timeZone);else{let e=ca(t.timeZone);if(wt(e))throw new oi(`Invalid time zone: ${t.timeZone}`);r=e.value}return t?.adjustForTimeZone===!0?va(n.epochMillis,r,t?.disambiguation??`compatible`):zi(n.epochMillis,r,n.partsUtc)},Qi=ve(Zi),$i=/^(.{17,35})\[(.+)\]$/,ea=e=>{let t=$i.exec(e);if(t===null){let t=ba(e);return t===null?v():Qi(e,{timeZone:t})}let[,n,r]=t;return Qi(n,{timeZone:r})},ta=st(`effect/DateTime/validZoneCache`,()=>new Map),na={day:`numeric`,month:`numeric`,year:`numeric`,hour:`numeric`,minute:`numeric`,second:`numeric`,timeZoneName:`longOffset`,fractionalSecondDigits:3,hourCycle:`h23`},ra=e=>{let t=e.resolvedOptions().timeZone;if(ta.has(t))return ta.get(t);let n=Object.create(Li);return n.id=t,n.format=e,ta.set(t,n),n},ia=e=>{if(ta.has(e))return ta.get(e);try{return ra(new Intl.DateTimeFormat(`en-US`,{...na,timeZone:e}))}catch{throw new oi(`Invalid time zone: ${e}`)}},aa=e=>{let t=Object.create(Ri);return t.offset=e,t},oa=ve(ia),sa=/^(?:GMT|[+-])/,ca=e=>{if(sa.test(e)){let t=ba(e);return t===null?v():w(aa(t))}return oa(e)},la=e=>e._tag===`Offset`?pa(e.offset):e.id,ua=e=>new Date(e.epochMillis),da=e=>{if(e._tag===`Utc`)return new Date(e.epochMillis);if(e.zone._tag===`Offset`)return new Date(e.epochMillis+e.zone.offset);if(e.adjustedEpochMillis!==void 0)return new Date(e.adjustedEpochMillis);let t=e.zone.format.formatToParts(e.epochMillis).filter(e=>e.type!==`literal`),n=new Date(0);return n.setUTCFullYear(Number(t[2].value),Number(t[0].value)-1,Number(t[1].value)),n.setUTCHours(Number(t[3].value),Number(t[4].value),Number(t[5].value),Number(t[6].value)),e.adjustedEpochMillis=n.getTime(),n},fa=e=>da(e).getTime()-ha(e),pa=e=>{let t=Math.abs(e),n=Math.floor(t/(3600*1e3)),r=Math.round(t%(3600*1e3)/(60*1e3));return r===60&&(n+=1,r=0),`${e<0?`-`:`+`}${String(n).padStart(2,`0`)}:${String(r).padStart(2,`0`)}`},ma=e=>pa(fa(e)),ha=e=>e.epochMillis,ga=(e,t)=>{if(t.year!==void 0&&e.setUTCFullYear(t.year),t.month!==void 0&&e.setUTCMonth(t.month-1),t.day!==void 0&&e.setUTCDate(t.day),t.weekDay!==void 0){let n=t.weekDay-e.getUTCDay();e.setUTCDate(e.getUTCDate()+n)}t.hours!==void 0&&e.setUTCHours(t.hours),t.minutes!==void 0&&e.setUTCMinutes(t.minutes),t.seconds!==void 0&&e.setUTCSeconds(t.seconds),t.millis!==void 0&&e.setUTCMilliseconds(t.millis)},_a=1440*60*1e3,va=(e,t,n)=>{if(t._tag===`Offset`)return zi(e-t.offset,t);let r=xa(e-_a,e,t),i=xa(e+_a,e,t);if(r===i)return zi(e-r,t);let a=r<i,o=r-i;if(a){if(xa(e-i,e,t)===i)return zi(e-i,t);let a=zi(e-r,t);if(e!==da(a).getTime())switch(n){case`reject`:{let n=new Date(e).toISOString();throw RangeError(`Gap time: ${n} does not exist in time zone ${t.id}`)}case`earlier`:return zi(e-i,t);case`compatible`:case`later`:return a}return a}if(xa(e-r,e,t)===r){if(n===`earlier`||n===`compatible`||xa(e-r+o,e+o,t)===r)return zi(e-r,t);if(n===`reject`){let n=new Date(e).toISOString();throw RangeError(`Ambiguous time: ${n} occurs twice in time zone ${t.id}`)}}return zi(e-i,t)},ya=/([+-])(\d{2}):(\d{2})$/,ba=e=>{let t=ya.exec(e);if(t===null)return null;let[,n,r,i]=t;return(n===`+`?1:-1)*(Number(r)*60+Number(i))*60*1e3},xa=(e,t,n)=>{let r=n.format.formatToParts(e).find(e=>e.type===`timeZoneName`)?.value??``;if(r===`GMT`)return 0;let i=ba(r);return i===null?fa(zi(t,n)):i},Sa=e=>ua(e).toISOString(),Ca=e=>{let t=da(e);return e._tag===`Utc`?t.toISOString():`${t.toISOString().slice(0,-1)}${ma(e)}`},wa=e=>e.zone._tag===`Offset`?Ca(e):`${Ca(e)}[${e.zone.id}]`,Ta=e=>e.toUpperCase(),Ea=e=>e.toLowerCase(),Da=e=>e.length===0?e:Ta(e[0])+e.slice(1),Oa=e=>e.length===0?e:Ea(e[0])+e.slice(1),ka=e=>e.length>0,Aa={arrays:`merge`,sets:`merge`,maps:`merge`};function ja(e,t,n){return Ma(e,t,new Set,n??Aa)}function Ma(e,t,n,r){let i={},a=new Set([...La(e),...La(t)]);for(let o of a){if(o===`__proto__`)continue;let a=e[o];if(!Object.hasOwn(t,o)){i[o]=a;continue}let s=t[o];if(Ia(a)&&Ia(s)&&!n.has(a)&&!n.has(s)){n.add(a),n.add(s),i[o]=Na(a,s,n,r);continue}i[o]=s}return i}function Na(e,t,n,r){if(Pa(e)&&Pa(t))return Ma(e,t,n,r);if(Fa(e)&&Fa(t)){if(Array.isArray(e)&&Array.isArray(t))return r.arrays===`merge`?e.concat(t):t;if(e instanceof Map&&t instanceof Map){if(r.maps===`merge`){let n=new Map(e);for(let[e,r]of t)n.set(e,r);return n}return t}if(e instanceof Set&&t instanceof Set){if(r.sets===`merge`){let n=new Set(e);for(let e of t)n.add(e);return n}return t}}return t}function Pa(e){return Object.getPrototypeOf(e)===Object.prototype}function Fa(e){return typeof e[Symbol.iterator]==`function`}function Ia(e){return typeof e==`object`&&!!e}function La(e){let t=Object.keys(e),n=Object.getOwnPropertySymbols(e);if(n.length===0)return t;for(let r of n)Object.prototype.propertyIsEnumerable.call(e,r)&&t.push(r);return t}function Ra(e){return e%4==0&&e%100!=0||e%400==0}var za=class{#e=/[ \t]/;#t=0;#n;constructor(e){this.#n=e}get position(){return this.#t}get source(){return this.#n}char(e=0){return this.#n[this.#t+e]??``}slice(e,t){return this.#n.slice(this.#t+e,this.#t+t)}next(e=1){this.#t+=e}skipWhitespaces(){for(;this.#e.test(this.char())&&!this.eof();)this.next();if(!this.isCurrentCharEOL()&&/\s/.test(this.char())){let e=`\\u`+this.char().charCodeAt(0).toString(16),t=this.#t;throw SyntaxError(`Cannot parse the TOML: It contains invalid whitespace at position '${t}': \`${e}\``)}}nextUntilChar(e={skipComments:!0}){for(;!this.eof();){let t=this.char();if(this.#e.test(t)||this.isCurrentCharEOL())this.next();else if(e.skipComments&&this.char()===`#`)for(;!this.isCurrentCharEOL()&&!this.eof();)this.next();else break}}eof(){return this.#t>=this.#n.length}isCurrentCharEOL(){return this.char()===`
2
+ `||this.startsWith(`\r
3
+ `)}startsWith(e){return this.#n.startsWith(e,this.#t)}match(e){if(!e.sticky)throw Error(`RegExp ${e} does not have a sticky 'y' flag`);return e.lastIndex=this.#t,this.#n.match(e)}};function N(e){return{ok:!0,body:e}}function P(){return{ok:!1}}function Ba(e,t={__proto__:null}){return e.reduceRight((e,t)=>({[t]:e}),t)}function Va(e){return typeof e==`object`&&!!e}function Ha(e,t){let n=t[0];if(!n)throw Error(`Cannot parse the TOML: key length is not a positive number`);return e[n]}function Ua(e,t){let{keys:n,type:r,value:i}=t,a=Ha(e,n);if(a===void 0)return Object.assign(e,Ba(n,i));if(Array.isArray(a))return Ga(a.at(-1),{type:r,keys:n.slice(1),value:i}),e;if(Va(a))return Ga(a,{type:r,keys:n.slice(1),value:i}),e;throw Error(`Unexpected assign`)}function Wa(e,t){let{type:n,keys:r,value:i}=t,a=Ha(e,r);if(a===void 0)return Object.assign(e,Ba(r,[i]));if(Array.isArray(a))return t.keys.length===1?a.push(i):Ga(a.at(-1),{type:t.type,keys:t.keys.slice(1),value:t.value}),e;if(Va(a))return Ga(a,{type:n,keys:r.slice(1),value:i}),e;throw Error(`Unexpected assign`)}function Ga(e,t){switch(t.type){case`Block`:return ja(e,t.value);case`Table`:return Ua(e,t);case`TableArray`:return Wa(e,t)}}function Ka(e){return t=>{for(let n of e){let e=n(t);if(e.ok)return e}return P()}}function qa(e,t){let n=$a(t);return r=>{let i=[],a=e(r);if(!a.ok)return N(i);for(i.push(a.body);!r.eof()&&n(r).ok;){let n=e(r);if(!n.ok)throw SyntaxError(`Invalid token after "${t}"`);i.push(n.body)}return N(i)}}function Ja(e,t){let n=$a(t);return r=>{let i=e(r);if(!i.ok)return P();let a=[i.body];for(;!r.eof()&&n(r).ok;){let n=e(r);if(!n.ok)throw SyntaxError(`Invalid token after "${t}"`);a.push(n.body)}return N(a)}}function Ya(e,t,n){let r=$a(t);return i=>{let a=i.position,o=e(i);if(!o.ok)return P();if(!r(i).ok)throw SyntaxError(`key/value pair doesn't have "${t}"`);let s=n(i);if(!s.ok){let e=i.source.indexOf(`
4
+ `,i.position),t=e>0?e:i.source.length,n=i.source.slice(a,t);throw SyntaxError(`Cannot parse value on line '${n}'`)}return N(Ba(o.body,s.body))}}function Xa(e){return t=>{let n=e(t);if(!n.ok)return P();let r={__proto__:null};for(let e of n.body)typeof e==`object`&&e&&(r=ja(r,e));return N(r)}}function Za(e){return t=>{let n=[];for(;!t.eof();){let r=e(t);if(!r.ok)break;n.push(r.body),t.nextUntilChar()}return n.length===0?P():N(n)}}function Qa(e,t,n){let r=$a(e),i=$a(n);return a=>{if(!r(a).ok)return P();let o=t(a);if(!o.ok)throw SyntaxError(`Invalid token after "${e}"`);if(!i(a).ok)throw SyntaxError(`Not closed by "${n}" after started with "${e}"`);return N(o.body)}}function $a(e){return t=>(t.skipWhitespaces(),t.startsWith(e)?(t.next(e.length),t.skipWhitespaces(),N(void 0)):P())}const eo=/[A-Za-z0-9_-]+/y;function to(e){e.skipWhitespaces();let t=e.match(eo)?.[0];return t?(e.next(t.length),N(t)):P()}function no(e){if(e.char()!==`\\`)return P();switch(e.next(),e.char()){case`b`:return e.next(),N(`\b`);case`t`:return e.next(),N(` `);case`n`:return e.next(),N(`
5
+ `);case`f`:return e.next(),N(`\f`);case`r`:return e.next(),N(`\r`);case`u`:case`U`:{let t=e.char()===`u`?4:6,n=parseInt(`0x`+e.slice(1,1+t),16),r=String.fromCodePoint(n);return e.next(t+1),N(r)}case`"`:return e.next(),N(`"`);case`\\`:return e.next(),N(`\\`);default:throw SyntaxError(`Invalid escape sequence: \\${e.char()}`)}}function ro(e){if(e.skipWhitespaces(),e.char()!==`"`)return P();e.next();let t=[];for(;e.char()!==`"`&&!e.eof();){if(e.char()===`
6
+ `)throw SyntaxError(`Single-line string cannot contain EOL`);let n=no(e);n.ok?t.push(n.body):(t.push(e.char()),e.next())}if(e.eof())throw SyntaxError(`Single-line string is not closed:\n${t.join(``)}`);return e.next(),N(t.join(``))}function io(e){if(e.skipWhitespaces(),e.char()!==`'`)return P();e.next();let t=[];for(;e.char()!==`'`&&!e.eof();){if(e.char()===`
7
+ `)throw SyntaxError(`Single-line string cannot contain EOL`);t.push(e.char()),e.next()}if(e.eof())throw SyntaxError(`Single-line string is not closed:\n${t.join(``)}`);return e.next(),N(t.join(``))}function ao(e){if(e.skipWhitespaces(),!e.startsWith(`"""`))return P();e.next(3),e.char()===`
8
+ `?e.next():e.startsWith(`\r
9
+ `)&&e.next(2);let t=[];for(;!e.startsWith(`"""`)&&!e.eof();){if(e.startsWith(`\\
10
+ `)){e.next(),e.nextUntilChar({skipComments:!1});continue}else if(e.startsWith(`\\\r
11
+ `)){e.next(),e.nextUntilChar({skipComments:!1});continue}let n=no(e);n.ok?t.push(n.body):(t.push(e.char()),e.next())}if(e.eof())throw SyntaxError(`Multi-line string is not closed:\n${t.join(``)}`);return e.char(3)===`"`&&(t.push(`"`),e.next()),e.next(3),N(t.join(``))}function oo(e){if(e.skipWhitespaces(),!e.startsWith(`'''`))return P();e.next(3),e.char()===`
12
+ `?e.next():e.startsWith(`\r
13
+ `)&&e.next(2);let t=[];for(;!e.startsWith(`'''`)&&!e.eof();)t.push(e.char()),e.next();if(e.eof())throw SyntaxError(`Multi-line string is not closed:\n${t.join(``)}`);return e.char(3)===`'`&&(t.push(`'`),e.next()),e.next(3),N(t.join(``))}const so=/(?:true|false)\b/y;function co(e){e.skipWhitespaces();let t=e.match(so);if(!t)return P();let n=t[0];return e.next(n.length),N(n===`true`)}const lo=new Map([[`inf`,1/0],[`+inf`,1/0],[`-inf`,-1/0]]),uo=/[+-]?inf\b/y;function fo(e){e.skipWhitespaces();let t=e.match(uo);if(!t)return P();let n=t[0];return e.next(n.length),N(lo.get(n))}const po=/[+-]?nan\b/y;function mo(e){e.skipWhitespaces();let t=e.match(po);if(!t)return P();let n=t[0];return e.next(n.length),N(NaN)}const ho=Ja(Ka([to,ro,io]),`.`),go=/0b[01]+(?:_[01]+)*\b/y;function _o(e){e.skipWhitespaces();let t=e.match(go)?.[0];if(!t)return P();e.next(t.length);let n=t.slice(2).replaceAll(`_`,``),r=parseInt(n,2);return isNaN(r)?P():N(r)}const vo=/0o[0-7]+(?:_[0-7]+)*\b/y;function yo(e){e.skipWhitespaces();let t=e.match(vo)?.[0];if(!t)return P();e.next(t.length);let n=t.slice(2).replaceAll(`_`,``),r=parseInt(n,8);return isNaN(r)?P():N(r)}const bo=/0x[0-9a-f]+(?:_[0-9a-f]+)*\b/iy;function xo(e){e.skipWhitespaces();let t=e.match(bo)?.[0];if(!t)return P();e.next(t.length);let n=t.slice(2).replaceAll(`_`,``),r=parseInt(n,16);return isNaN(r)?P():N(r)}const So=/[+-]?(?:0|[1-9][0-9]*(?:_[0-9]+)*)\b/y;function Co(e){e.skipWhitespaces();let t=e.match(So)?.[0];if(!t)return P();e.next(t.length);let n=t.replaceAll(`_`,``);return N(parseInt(n,10))}const wo=/[+-]?(?:0|[1-9][0-9]*(?:_[0-9]+)*)(?:\.[0-9]+(?:_[0-9]+)*)?(?:e[+-]?[0-9]+(?:_[0-9]+)*)?\b/iy;function To(e){e.skipWhitespaces();let t=e.match(wo)?.[0];if(!t)return P();e.next(t.length);let n=t.replaceAll(`_`,``),r=parseFloat(n);return isNaN(r)?P():N(r)}const Eo=/(?<year>\d{4})-(?<month>\d{2})-(?<day>\d{2})(?:[ 0-9TZ.:+-]+)?\b/y;function Do(e){e.skipWhitespaces();let t=e.match(Eo);if(!t)return P();let n=t[0];e.next(n.length);let r=t.groups;if(r.month==`02`){let e=parseInt(r.day);if(e>29)throw SyntaxError(`Invalid date string "${t}"`);let n=parseInt(r.year);if(e>28&&!Ra(n))throw SyntaxError(`Invalid date string "${t}"`)}let i=new Date(n.trim());if(isNaN(i.getTime()))throw SyntaxError(`Invalid date string "${t}"`);return N(i)}const Oo=/(\d{2}):(\d{2}):(\d{2})(?:\.[0-9]+)?\b/y;function ko(e){e.skipWhitespaces();let t=e.match(Oo)?.[0];return t?(e.next(t.length),N(t)):P()}function Ao(e){if(e.skipWhitespaces(),e.char()!==`[`)return P();e.next();let t=[];for(;!e.eof();){e.nextUntilChar();let n=Mo(e);if(!n.ok||(t.push(n.body),e.skipWhitespaces(),e.char()!==`,`))break;e.next()}if(e.nextUntilChar(),e.char()!==`]`)throw SyntaxError(`Array is not closed`);return e.next(),N(t)}function jo(e){if(e.nextUntilChar(),e.char(1)===`}`)return e.next(2),N({__proto__:null});let t=Qa(`{`,qa(No,`,`),`}`)(e);if(!t.ok)return P();let n={__proto__:null};for(let e of t.body)n=ja(n,e);return N(n)}const Mo=Ka([ao,oo,ro,io,co,fo,mo,Do,ko,_o,yo,xo,To,Co,Ao,jo]),No=Ya(ho,`=`,Mo);function Po(e){e.nextUntilChar();let t=Xa(Za(No))(e);return t.ok?N({type:`Block`,value:t.body}):P()}const Fo=Qa(`[`,ho,`]`);function Io(e){e.nextUntilChar();let t=Fo(e);if(!t.ok)return P();e.nextUntilChar();let n=Po(e);return N({type:`Table`,keys:t.body,value:n.ok?n.body.value:{__proto__:null}})}const Lo=Qa(`[[`,ho,`]]`);function Ro(e){e.nextUntilChar();let t=Lo(e);if(!t.ok)return P();e.nextUntilChar();let n=Po(e);return N({type:`TableArray`,keys:t.body,value:n.ok?n.body.value:{__proto__:null}})}function zo(e){let t=Za(Ka([Po,Ro,Io]))(e);return t.ok?N(t.body.reduce(Ga,{__proto__:null})):N({__proto__:null})}function Bo(e,t){let n=e.source.slice(0,e.position).split(`
14
+ `);return`Parse error on line ${n.length}, column ${n.at(-1)?.length??0}: ${t}`}function Vo(e){return t=>{let n=new za(t);try{let t=e(n);if(t.ok&&n.eof())return t.body;let r=`Unexpected character: "${n.char()}"`;throw SyntaxError(Bo(n,r))}catch(e){throw e instanceof Error?SyntaxError(Bo(n,e.message)):SyntaxError(Bo(n,`Invalid error type caught`))}}}function Ho(e){return Vo(zo)(e)}const Uo=(e,t)=>{switch(t._tag){case`StringKeyword`:case`TemplateLiteral`:return Object.keys(e);case`SymbolKeyword`:return Object.getOwnPropertySymbols(e);case`Refinement`:return Uo(e,t.from)}},Wo=e=>{let t=!1,n;return()=>t?n:(n=e(),t=!0,n)},Go=e=>Array.isArray(e),Ko=e=>!Array.isArray(e),qo=e=>`[${p(e)}]`,Jo=e=>Go(e)?e.map(qo).join(``):qo(e),Yo=(e,n,r,i)=>{let a=e;return r&&t(r)&&(a+=`\nat path: ${Jo(r)}`),n!==void 0&&(a+=`\ndetails: ${n}`),i&&(a+=`\nschema (${i._tag}): ${i}`),a},Xo=e=>Yo(`Invalid Argument`,e),Zo=(e,t,n)=>Yo(`Unsupported schema or overlapping types`,`cannot extend ${e} with ${t}`,n),Qo=e=>Yo(`Unsupported key schema`,void 0,void 0,e),$o=e=>Yo(`Unsupported literal`,`literal value: ${l(e)}`),es=e=>Yo(`Duplicate index signature`,`${e} index signature`),ts=Yo(`Unsupported index signature parameter`,"An index signature parameter type must be `string`, `symbol`, a template literal type or a refinement of the previous types"),ns=Yo(`Invalid element`,`A required element cannot follow an optional element. ts(1257)`),rs=e=>Yo(`Duplicate property signature transformation`,`Duplicate key ${l(e)}`),is=e=>Yo(`Duplicate property signature`,`Duplicate key ${l(e)}`),as=Symbol.for(`effect/SchemaId/DateFromSelf`),os=Symbol.for(`effect/SchemaId/GreaterThan`),ss=Symbol.for(`effect/SchemaId/GreaterThanOrEqualTo`),cs=Symbol.for(`effect/SchemaId/LessThan`),ls=Symbol.for(`effect/SchemaId/LessThanOrEqualTo`),us=Symbol.for(`effect/SchemaId/Int`),ds=Symbol.for(`effect/SchemaId/NonNaN`),fs=Symbol.for(`effect/SchemaId/Finite`),ps=Symbol.for(`effect/SchemaId/JsonNumber`),ms=Symbol.for(`effect/SchemaId/Between`),hs=Symbol.for(`effect/SchemaId/GreaterThanOrEqualToBigint`),gs=Symbol.for(`effect/SchemaId/BetweenBigint`),_s=Symbol.for(`effect/SchemaId/MinLength`),vs=Symbol.for(`effect/SchemaId/Length`),ys=Symbol.for(`effect/SchemaId/MinItems`),bs=Symbol.for(`effect/annotation/TypeConstructor`),xs=Symbol.for(`effect/annotation/Brand`),Ss=Symbol.for(`effect/annotation/SchemaId`),Cs=Symbol.for(`effect/annotation/Message`),ws=Symbol.for(`effect/annotation/MissingMessage`),Ts=Symbol.for(`effect/annotation/Identifier`),Es=Symbol.for(`effect/annotation/Title`),Ds=Symbol.for(`effect/annotation/AutoTitle`),Os=Symbol.for(`effect/annotation/Description`),ks=Symbol.for(`effect/annotation/Examples`),As=Symbol.for(`effect/annotation/Default`),js=Symbol.for(`effect/annotation/JSONSchema`),Ms=Symbol.for(`effect/annotation/Arbitrary`),Ns=Symbol.for(`effect/annotation/Pretty`),Ps=Symbol.for(`effect/annotation/Equivalence`),Fs=Symbol.for(`effect/annotation/Documentation`),Is=Symbol.for(`effect/annotation/Concurrency`),Ls=Symbol.for(`effect/annotation/Batching`),Rs=Symbol.for(`effect/annotation/ParseIssueTitle`),zs=Symbol.for(`effect/annotation/ParseOptions`),Bs=Symbol.for(`effect/annotation/DecodingFallback`),Vs=Symbol.for(`effect/annotation/Surrogate`),Hs=Symbol.for(`effect/annotation/StableFilter`),F=x(2,(e,t)=>Object.prototype.hasOwnProperty.call(e.annotations,t)?w(e.annotations[t]):v()),Us=F(xs),Ws=F(Cs),Gs=F(ws),Ks=F(Es),qs=F(Ds),Js=F(Ts),Ys=F(Os),Xs=F(Is),Zs=F(Ls),Qs=F(Rs),$s=F(zs),ec=F(Bs),tc=F(Vs),nc=F(Hs),rc=e=>$t(nc(e),e=>e===!0),ic=Symbol.for(`effect/annotation/JSONIdentifier`),ac=F(ic),oc=e=>pe(ac(e),()=>Js(e));var sc=class{typeParameters;decodeUnknown;encodeUnknown;annotations;_tag=`Declaration`;constructor(e,t,n,r={}){this.typeParameters=e,this.decodeUnknown=t,this.encodeUnknown=n,this.annotations=r}toString(){return Ne(bl(this),()=>`<declaration schema>`)}toJSON(){return{_tag:this._tag,typeParameters:this.typeParameters.map(e=>e.toJSON()),annotations:R(this.annotations)}}};const cc=e=>t=>t._tag===e;var lc=class{literal;annotations;_tag=`Literal`;constructor(e,t={}){this.literal=e,this.annotations=t}toString(){return Ne(bl(this),()=>l(this.literal))}toJSON(){return{_tag:this._tag,literal:oe(this.literal)?String(this.literal):this.literal,annotations:R(this.annotations)}}};const uc=cc(`Literal`);var dc=class{symbol;annotations;_tag=`UniqueSymbol`;constructor(e,t={}){this.symbol=e,this.annotations=t}toString(){return Ne(bl(this),()=>l(this.symbol))}toJSON(){return{_tag:this._tag,symbol:String(this.symbol),annotations:R(this.annotations)}}};const fc=new class{annotations;_tag=`UndefinedKeyword`;constructor(e={}){this.annotations=e}toString(){return _l(this)}toJSON(){return{_tag:this._tag,annotations:R(this.annotations)}}}({[Es]:`undefined`}),pc=new class{annotations;_tag=`NeverKeyword`;constructor(e={}){this.annotations=e}toString(){return _l(this)}toJSON(){return{_tag:this._tag,annotations:R(this.annotations)}}}({[Es]:`never`}),mc=new class{annotations;_tag=`UnknownKeyword`;constructor(e={}){this.annotations=e}toString(){return _l(this)}toJSON(){return{_tag:this._tag,annotations:R(this.annotations)}}}({[Es]:`unknown`}),hc=new class{annotations;_tag=`AnyKeyword`;constructor(e={}){this.annotations=e}toString(){return _l(this)}toJSON(){return{_tag:this._tag,annotations:R(this.annotations)}}}({[Es]:`any`}),gc=new class{annotations;_tag=`StringKeyword`;constructor(e={}){this.annotations=e}toString(){return _l(this)}toJSON(){return{_tag:this._tag,annotations:R(this.annotations)}}}({[Es]:`string`,[Os]:`a string`}),_c=cc(`StringKeyword`),vc=new class{annotations;_tag=`NumberKeyword`;constructor(e={}){this.annotations=e}toString(){return _l(this)}toJSON(){return{_tag:this._tag,annotations:R(this.annotations)}}}({[Es]:`number`,[Os]:`a number`}),yc=cc(`NumberKeyword`),bc=new class{annotations;_tag=`BooleanKeyword`;constructor(e={}){this.annotations=e}toString(){return _l(this)}toJSON(){return{_tag:this._tag,annotations:R(this.annotations)}}}({[Es]:`boolean`,[Os]:`a boolean`}),xc=cc(`BooleanKeyword`),Sc=new class{annotations;_tag=`BigIntKeyword`;constructor(e={}){this.annotations=e}toString(){return _l(this)}toJSON(){return{_tag:this._tag,annotations:R(this.annotations)}}}({[Es]:`bigint`,[Os]:`a bigint`}),Cc=new class{annotations;_tag=`SymbolKeyword`;constructor(e={}){this.annotations=e}toString(){return _l(this)}toJSON(){return{_tag:this._tag,annotations:R(this.annotations)}}}({[Es]:`symbol`,[Os]:`a symbol`}),wc=cc(`SymbolKeyword`);var Tc=class{type;annotations;constructor(e,t={}){this.type=e,this.annotations=t}toJSON(){return{type:this.type.toJSON(),annotations:R(this.annotations)}}toString(){return String(this.type)}},Ec=class extends Tc{isOptional;constructor(e,t,n={}){super(e,n),this.isOptional=t}toJSON(){return{type:this.type.toJSON(),isOptional:this.isOptional,annotations:R(this.annotations)}}toString(){return String(this.type)+(this.isOptional?`?`:``)}};const Dc=e=>e.map(e=>e.type);var Oc=class{elements;rest;isReadonly;annotations;_tag=`TupleType`;constructor(e,t,n,r={}){this.elements=e,this.rest=t,this.isReadonly=n,this.annotations=r;let i=!1,a=!1;for(let t of e)if(t.isOptional)i=!0;else if(i){a=!0;break}if(a||i&&t.length>1)throw Error(ns)}toString(){return Ne(bl(this),()=>kc(this))}toJSON(){return{_tag:this._tag,elements:this.elements.map(e=>e.toJSON()),rest:this.rest.map(e=>e.toJSON()),isReadonly:this.isReadonly,annotations:R(this.annotations)}}};const kc=e=>{let t=e.elements.map(String).join(`, `);return $e(e.rest,{onEmpty:()=>`readonly [${t}]`,onNonEmpty:(n,r)=>{let i=String(n),a=i.includes(` | `)?`(${i})`:i;if(r.length>0){let n=r.map(String).join(`, `);return e.elements.length>0?`readonly [${t}, ...${a}[], ${n}]`:`readonly [...${a}[], ${n}]`}else if(e.elements.length>0)return`readonly [${t}, ...${a}[]]`;else return`ReadonlyArray<${i}>`}})};var I=class extends Ec{name;isReadonly;constructor(e,t,n,r,i){super(t,n,i),this.name=e,this.isReadonly=r}toString(){return(this.isReadonly?`readonly `:``)+String(this.name)+(this.isOptional?`?`:``)+`: `+this.type}toJSON(){return{name:String(this.name),type:this.type.toJSON(),isOptional:this.isOptional,isReadonly:this.isReadonly,annotations:R(this.annotations)}}};const Ac=e=>{switch(e._tag){case`StringKeyword`:case`SymbolKeyword`:case`TemplateLiteral`:return!0;case`Refinement`:return Ac(e.from)}return!1};var jc=class{type;isReadonly;parameter;constructor(e,t,n){if(this.type=t,this.isReadonly=n,Ac(e))this.parameter=e;else throw Error(ts)}toString(){return(this.isReadonly?`readonly `:``)+`[x: ${this.parameter}]: ${this.type}`}toJSON(){return{parameter:this.parameter.toJSON(),type:this.type.toJSON(),isReadonly:this.isReadonly}}},Mc=class{annotations;_tag=`TypeLiteral`;propertySignatures;indexSignatures;constructor(e,t,n={}){this.annotations=n;let r={};for(let t=0;t<e.length;t++){let n=e[t].name;if(Object.prototype.hasOwnProperty.call(r,n))throw Error(is(n));r[n]=null}let i={string:!1,symbol:!1};for(let e=0;e<t.length;e++){let n=gl(t[e].parameter);if(_c(n)){if(i.string)throw Error(es(`string`));i.string=!0}else if(wc(n)){if(i.symbol)throw Error(es(`symbol`));i.symbol=!0}}this.propertySignatures=e,this.indexSignatures=t}toString(){return Ne(bl(this),()=>Pc(this))}toJSON(){return{_tag:this._tag,propertySignatures:this.propertySignatures.map(e=>e.toJSON()),indexSignatures:this.indexSignatures.map(e=>e.toJSON()),annotations:R(this.annotations)}}};const Nc=e=>e.map(String).join(`; `),Pc=e=>{if(e.propertySignatures.length>0){let t=e.propertySignatures.map(String).join(`; `);return e.indexSignatures.length>0?`{ ${t}; ${Nc(e.indexSignatures)} }`:`{ ${t} }`}else if(e.indexSignatures.length>0)return`{ ${Nc(e.indexSignatures)} }`;else return`{}`},Fc=cc(`TypeLiteral`),Ic=Ut(vr(un,e=>{switch(e._tag){case`AnyKeyword`:return 0;case`UnknownKeyword`:return 1;case`ObjectKeyword`:return 2;case`StringKeyword`:case`NumberKeyword`:case`BooleanKeyword`:case`BigIntKeyword`:case`SymbolKeyword`:return 3}return 4})),Lc={string:`StringKeyword`,number:`NumberKeyword`,boolean:`BooleanKeyword`,bigint:`BigIntKeyword`},Rc=e=>Ve(e,e=>Uc(e)?Rc(e.types):[e]),zc=e=>{let t=Ic(e),n=[],r={},i=[];for(let e of t)switch(e._tag){case`NeverKeyword`:break;case`AnyKeyword`:return[hc];case`UnknownKeyword`:return[mc];case`ObjectKeyword`:case`UndefinedKeyword`:case`VoidKeyword`:case`StringKeyword`:case`NumberKeyword`:case`BooleanKeyword`:case`BigIntKeyword`:case`SymbolKeyword`:r[e._tag]||(r[e._tag]=e,n.push(e));break;case`Literal`:{let t=typeof e.literal;switch(t){case`string`:case`number`:case`bigint`:case`boolean`:!r[Lc[t]]&&!i.includes(e.literal)&&(i.push(e.literal),n.push(e));break;case`object`:i.includes(e.literal)||(i.push(e.literal),n.push(e));break}break}case`UniqueSymbol`:!r.SymbolKeyword&&!i.includes(e.symbol)&&(i.push(e.symbol),n.push(e));break;case`TupleType`:r.ObjectKeyword||n.push(e);break;case`TypeLiteral`:e.propertySignatures.length===0&&e.indexSignatures.length===0?r[`{}`]||(r[`{}`]=e,n.push(e)):r.ObjectKeyword||n.push(e);break;default:n.push(e)}return n};var Bc=class e{types;annotations;static make=(t,n)=>Hc(t)?new e(t,n):t.length===1?t[0]:pc;static unify=(t,n)=>e.make(zc(Rc(t)),n);_tag=`Union`;constructor(e,t={}){this.types=e,this.annotations=t}toString(){return Ne(bl(this),()=>this.types.map(String).join(` | `))}toJSON(){return{_tag:this._tag,types:this.types.map(e=>e.toJSON()),annotations:R(this.annotations)}}};const Vc=(e,t)=>e.map(t),Hc=e=>e.length>1,Uc=cc(`Union`),Wc=st(Symbol.for(`effect/Schema/AST/toJSONMemoMap`),()=>new WeakMap);var Gc=class{f;annotations;_tag=`Suspend`;constructor(e,t={}){this.f=e,this.annotations=t,this.f=Wo(e)}toString(){return bl(this).pipe(pe(()=>Zt(ve(this.f)(),e=>bl(e))),Ne(()=>`<suspended schema>`))}toJSON(){let e=this.f(),t=Wc.get(e);return t||(Wc.set(e,{_tag:this._tag}),t={_tag:this._tag,ast:e.toJSON(),annotations:R(this.annotations)},Wc.set(e,t),t)}},Kc=class{from;filter;annotations;_tag=`Refinement`;constructor(e,t,n={}){this.from=e,this.filter=t,this.annotations=n}toString(){return Js(this).pipe(Ne(()=>_(yl(this),{onNone:()=>`{ ${this.from} | filter }`,onSome:e=>qc(this.from)?String(this.from)+` & `+e:e})))}toJSON(){return{_tag:this._tag,from:this.from.toJSON(),annotations:R(this.annotations)}}};const qc=cc(`Refinement`),Jc={};var Yc=class{from;to;transformation;annotations;_tag=`Transformation`;constructor(e,t,n,r={}){this.from=e,this.to=t,this.transformation=n,this.annotations=r}toString(){return Ne(bl(this),()=>`(${String(this.from)} <-> ${String(this.to)})`)}toJSON(){return{_tag:this._tag,from:this.from.toJSON(),to:this.to.toJSON(),annotations:R(this.annotations)}}};const Xc=cc(`Transformation`);var Zc=class{decode;encode;_tag=`FinalTransformation`;constructor(e,t){this.decode=e,this.encode=t}};const Qc=e=>t=>t._tag===e,$c=new class{_tag=`ComposeTransformation`};var el=class{from;to;decode;encode;constructor(e,t,n,r){this.from=e,this.to=t,this.decode=n,this.encode=r}},tl=class{propertySignatureTransformations;_tag=`TypeLiteralTransformation`;constructor(e){this.propertySignatureTransformations=e;let t={},n={};for(let r of e){let e=r.from;if(t[e])throw Error(rs(e));t[e]=!0;let i=r.to;if(n[i])throw Error(rs(i));n[i]=!0}}};const nl=Qc(`TypeLiteralTransformation`),rl=(e,t)=>{let n=Object.getOwnPropertyDescriptors(e),r={...e.annotations};delete r[Ts];let i={...r,...t},a=tc(e);return bt(a)&&(i[Vs]=rl(a.value,t)),n.annotations.value=i,Object.create(Object.getPrototypeOf(e),n)},il=(e,t)=>{switch(e._tag){case`Literal`:return pn(String(e.literal));case`StringKeyword`:return`[\\s\\S]*?`;case`NumberKeyword`:return`[+-]?\\d*\\.?\\d+(?:[Ee][+-]?\\d+)?`;case`TemplateLiteral`:return ol(e,t,!1);case`Union`:return e.types.map(e=>il(e,t)).join(`|`)}},al=(e,t,n,r)=>{if(Uc(e)){if(n&&!r)return`(?:${t})`}else if(!n||!r)return t;return`(${t})`},ol=(e,t,n)=>{let r=``;if(e.head!==``){let i=pn(e.head);r+=t&&n?`(${i})`:i}for(let i of e.spans){let e=il(i.type,t);if(r+=al(i.type,e,t,n),i.literal!==``){let e=pn(i.literal);r+=t&&n?`(${e})`:e}}return r},sl=e=>RegExp(`^${ol(e,!1,!0)}$`),cl=(e,t)=>{let n=[],r=[],i=e=>{switch(e._tag){case`NeverKeyword`:break;case`StringKeyword`:case`SymbolKeyword`:case`TemplateLiteral`:case`Refinement`:r.push(new jc(e,t,!0));break;case`Literal`:if(Qe(e.literal)||Vt(e.literal))n.push(new I(e.literal,t,!1,!0));else throw Error($o(e.literal));break;case`Enums`:for(let[r,i]of e.enums)n.push(new I(i,t,!1,!0));break;case`UniqueSymbol`:n.push(new I(e.symbol,t,!1,!0));break;case`Union`:e.types.forEach(i);break;default:throw Error(Qo(e))}};return i(e),{propertySignatures:n,indexSignatures:r}},ll=e=>t=>{let n;for(let r of e)Object.prototype.hasOwnProperty.call(t.annotations,r)&&(n===void 0&&(n={}),n[r]=t.annotations[r]);return n},ul=e=>t=>{let n={...t.annotations};for(let t of e)delete n[t];return n},dl=ll([ks,As,js,Ms,Ns,Ps]),L=e=>{switch(e._tag){case`Declaration`:{let t=fl(e.typeParameters,L);return t===e.typeParameters?e:new sc(t,e.decodeUnknown,e.encodeUnknown,e.annotations)}case`TupleType`:{let t=fl(e.elements,e=>{let t=L(e.type);return t===e.type?e:new Ec(t,e.isOptional)}),n=Dc(e.rest),r=fl(n,L);return t===e.elements&&r===n?e:new Oc(t,r.map(e=>new Tc(e)),e.isReadonly,e.annotations)}case`TypeLiteral`:{let t=fl(e.propertySignatures,e=>{let t=L(e.type);return t===e.type?e:new I(e.name,t,e.isOptional,e.isReadonly)}),n=fl(e.indexSignatures,e=>{let t=L(e.type);return t===e.type?e:new jc(e.parameter,t,e.isReadonly)});return t===e.propertySignatures&&n===e.indexSignatures?e:new Mc(t,n,e.annotations)}case`Union`:{let t=fl(e.types,L);return t===e.types?e:Bc.make(t,e.annotations)}case`Suspend`:return new Gc(()=>L(e.f()),e.annotations);case`Refinement`:{let t=L(e.from);return t===e.from?e:new Kc(t,e.filter,e.annotations)}case`Transformation`:{let t=dl(e);return L(t===void 0?e.to:rl(e.to,t))}}return e};function fl(e,t){let n=!1,r=ae(e.length);for(let i=0;i<e.length;i++){let a=e[i],o=t(a);o!==a&&(n=!0),r[i]=o}return n?r:e}const pl=e=>{switch(e._tag){case`Transformation`:return e.from;case`Refinement`:return pl(e.from);case`Suspend`:return pl(e.f())}},ml=(e,t)=>{switch(e._tag){case`Declaration`:{let n=fl(e.typeParameters,e=>ml(e,t));return n===e.typeParameters?e:new sc(n,e.decodeUnknown,e.encodeUnknown)}case`TupleType`:{let n=fl(e.elements,e=>{let n=ml(e.type,t);return n===e.type?e:new Ec(n,e.isOptional)}),r=Dc(e.rest),i=fl(r,e=>ml(e,t));return n===e.elements&&i===r?e:new Oc(n,i.map(e=>new Tc(e)),e.isReadonly)}case`TypeLiteral`:{let n=fl(e.propertySignatures,e=>{let n=ml(e.type,t);return n===e.type?e:new I(e.name,n,e.isOptional,e.isReadonly)}),r=fl(e.indexSignatures,e=>{let n=ml(e.type,t);return n===e.type?e:new jc(e.parameter,n,e.isReadonly)});return n===e.propertySignatures&&r===e.indexSignatures?e:new Mc(n,r)}case`Union`:{let n=fl(e.types,e=>ml(e,t));return n===e.types?e:Bc.make(n)}case`Suspend`:{let n,r=oc(e);if(bt(r)){let e=t?`Bound`:``;n={[ic]:`${r.value}Encoded${e}`}}return new Gc(()=>ml(e.f(),t),n)}case`Refinement`:{let n=ml(e.from,t);return t?n===e.from?e:pl(e.from)===void 0&&rc(e)?new Kc(n,e.filter,e.annotations):n:n}case`Transformation`:return ml(e.from,t)}return e},hl=e=>ml(e,!1),R=e=>{let t={};for(let n of Object.getOwnPropertySymbols(e))t[String(n)]=e[n];return t},gl=e=>{switch(e._tag){case`StringKeyword`:case`SymbolKeyword`:case`TemplateLiteral`:return e;case`Refinement`:return gl(e.from)}},_l=e=>Ne(bl(e),()=>e._tag);function vl(e){return _(Us(e),{onNone:()=>``,onSome:e=>e.map(e=>` & Brand<${l(e)}>`).join(``)})}const yl=e=>Ks(e).pipe(pe(()=>Ys(e)),pe(()=>qs(e)),Ce(t=>t+vl(e))),bl=e=>pe(Js(e),()=>yl(e)),xl=/^[+-]?\d+$/,Sl=Symbol.for(`effect/BigDecimal`),Cl={[Sl]:Sl,[a](){let e=Al(this);return C(de(e.value),ie(Ee(e.scale)),h(this))},[he](e){return wl(e)&&Pl(this,e)},toString(){return`BigDecimal(${Rl(this)})`},toJSON(){return{_id:`BigDecimal`,value:String(this.value),scale:this.scale}},[s](){return this.toJSON()},pipe(){return De(this,arguments)}},wl=e=>Nt(e,Sl),Tl=(e,t)=>{let n=Object.create(Cl);return n.value=e,n.scale=t,n},El=(e,t)=>{if(e!==Dl&&e%Ol===Dl)throw RangeError(`Value must be normalized`);let n=Tl(e,t);return n.normalized=n,n},Dl=BigInt(0),Ol=BigInt(10),kl=El(Dl,0),Al=e=>{if(e.normalized===void 0)if(e.value===Dl)e.normalized=kl;else{let t=`${e.value}`,n=0;for(let e=t.length-1;e>=0&&t[e]===`0`;e--)n++;n===0&&(e.normalized=e);let r=BigInt(t.substring(0,t.length-n)),i=e.scale-n;e.normalized=El(r,i)}return e.normalized},jl=x(2,(e,t)=>t>e.scale?Tl(e.value*Ol**BigInt(t-e.scale),t):t<e.scale?Tl(e.value/Ol**BigInt(e.scale-t),t):e),Ml=e=>e.value<Dl?Tl(-e.value,e.scale):e,Nl=jt((e,t)=>e.scale>t.scale?jl(t,e.scale).value===e.value:e.scale<t.scale?jl(e,t.scale).value===t.value:e.value===t.value),Pl=x(2,(e,t)=>Nl(e,t)),Fl=e=>m(Il(e),()=>RangeError(`Number must be finite, got ${e}`)),Il=e=>{if(!Number.isFinite(e))return v();let t=`${e}`;if(t.includes(`e`))return Ll(t);let[n,r=``]=t.split(`.`);return w(Tl(BigInt(`${n}${r}`),r.length))},Ll=e=>{if(e===``)return w(kl);let t,n,r=e.search(/[eE]/);if(r!==-1){let i=e.slice(r+1);if(t=e.slice(0,r),n=Number(i),t===``||!Number.isSafeInteger(n)||!xl.test(i))return v()}else t=e,n=0;let i,a,o=t.search(/\./);if(o!==-1){let e=t.slice(0,o),n=t.slice(o+1);i=`${e}${n}`,a=n.length}else i=t,a=0;if(!xl.test(i))return v();let s=a-n;return Number.isSafeInteger(s)?w(Tl(BigInt(i),s)):v()},Rl=e=>{let t=Al(e);if(Math.abs(t.scale)>=16)return zl(t);let n=t.value<Dl,r=n?`${t.value}`.substring(1):`${t.value}`,i,a;if(t.scale>=r.length)i=`0`,a=`0`.repeat(t.scale-r.length)+r;else{let e=r.length-t.scale;if(e>r.length){let t=e-r.length;i=`${r}${`0`.repeat(t)}`,a=``}else a=r.slice(e),i=r.slice(0,e)}let o=a===``?i:`${i}.${a}`;return n?`-${o}`:o},zl=e=>{if(Vl(e))return`0e+0`;let t=Al(e),n=`${Ml(t).value}`,r=n.slice(0,1),i=n.slice(1),a=`${Hl(t)?`-`:``}${r}`;i!==``&&(a+=`.${i}`);let o=i.length-t.scale;return`${a}e${o>=0?`+`:``}${o}`},Bl=e=>Number(Rl(e)),Vl=e=>e.value===Dl,Hl=e=>e.value<Dl,Ul=e=>e>BigInt(2**53-1)||e<BigInt(-(2**53-1))?v():w(Number(e)),Wl=e=>{try{return e.trim()===``?v():w(BigInt(e))}catch{return v()}},Gl=e=>{if(e>2**53-1||e<-(2**53-1))return v();try{return w(BigInt(e))}catch{return v()}},Kl=Symbol.for(`effect/Brand/Refined`),ql=()=>Object.assign(e=>e,{[Kl]:Kl,option:e=>w(e),either:e=>b(e),is:e=>!0}),Jl=gn,Yl=yn,Xl=Pn,Zl=Cn,Ql=Symbol.for(`effect/QueueEnqueue`),$l=Symbol.for(`effect/QueueDequeue`),eu=Symbol.for(`effect/QueueStrategy`),tu=Symbol.for(`effect/BackingQueue`),nu={_A:e=>e},ru={_A:e=>e},iu={_In:e=>e},au={_Out:e=>e};var ou=class extends sn{queue;takers;shutdownHook;shutdownFlag;strategy;[Ql]=iu;[$l]=au;constructor(e,t,n,r,i){super(),this.queue=e,this.takers=t,this.shutdownHook=n,this.shutdownFlag=r,this.strategy=i}pipe(){return De(this,arguments)}commit(){return this.take}capacity(){return this.queue.capacity()}get size(){return Jt(()=>xt(this.unsafeSize(),()=>u))}unsafeSize(){return Le(this.shutdownFlag)?v():w(this.queue.length()-Kr(this.takers)+this.strategy.surplusSize())}get isEmpty(){return We(this.size,e=>e<=0)}get isFull(){return We(this.size,e=>e>=this.capacity())}get shutdown(){return Ct(fe(e=>(C(this.shutdownFlag,Pe(!0)),C(ir(ku(this.takers),t=>ot(t,e.id()),!1,!1),ce(this.strategy.shutdown),Se(ct(this.shutdownHook,void 0)),qt))))}get isShutdown(){return Me(()=>Le(this.shutdownFlag))}get awaitShutdown(){return zt(this.shutdownHook)}isActive(){return!Le(this.shutdownFlag)}unsafeOffer(e){if(Le(this.shutdownFlag))return!1;let t;if(this.queue.length()===0){let n=C(this.takers,dn(er));n===er?t=!1:(Du(n,e),t=!0)}else t=!1;if(t)return!0;let n=this.queue.offer(e);return Mu(this.strategy,this.queue,this.takers),n}offer(e){return Jt(()=>{if(Le(this.shutdownFlag))return u;let t;if(this.queue.length()===0){let n=C(this.takers,dn(er));n===er?t=!1:(Du(n,e),t=!0)}else t=!1;if(t)return c(!0);let n=this.queue.offer(e);return Mu(this.strategy,this.queue,this.takers),n?c(!0):this.strategy.handleSurplus([e],this.queue,this.takers,this.shutdownFlag)})}offerAll(e){return Jt(()=>{if(Le(this.shutdownFlag))return u;let t=ue(e),n=this.queue.length()===0?ue(Au(this.takers,t.length)):Re,[r,i]=C(t,ft(n.length));for(let e=0;e<n.length;e++){let t=n[e],i=r[e];Du(t,i)}if(i.length===0)return c(!0);let a=this.queue.offerAll(i);return Mu(this.strategy,this.queue,this.takers),je(a)?c(!0):this.strategy.handleSurplus(a,this.queue,this.takers,this.shutdownFlag)})}get take(){return fe(e=>{if(Le(this.shutdownFlag))return u;let t=this.queue.poll(er);if(t!==er)return this.strategy.unsafeOnQueueEmptySpace(this.queue,this.takers),c(t);{let t=Mt(e.id());return C(Jt(()=>(C(this.takers,Bn(t)),Mu(this.strategy,this.queue,this.takers),Le(this.shutdownFlag)?u:zt(t))),at(()=>Me(()=>ju(this.takers,t))))}})}get takeAll(){return Jt(()=>Le(this.shutdownFlag)?u:Me(()=>{let e=this.queue.pollUpTo(1/0);return this.strategy.unsafeOnQueueEmptySpace(this.queue,this.takers),Oe(e)}))}takeUpTo(e){return Jt(()=>Le(this.shutdownFlag)?u:Me(()=>{let t=this.queue.pollUpTo(e);return this.strategy.unsafeOnQueueEmptySpace(this.queue,this.takers),Oe(t)}))}takeBetween(e,t){return Jt(()=>su(this,e,t,tt()))}};const su=(e,t,n,r)=>n<t?c(r):C(bu(e,n),Gt(i=>{let a=t-i.length;return a===1?C(yu(e),We(e=>C(r,Qt(i),Kt(e)))):a>1?C(yu(e),Gt(t=>su(e,a-1,n-i.length-1,C(r,Qt(i),Kt(t))))):c(C(r,Qt(i)))})),cu=e=>C(Me(()=>Yr(e)),Gt(e=>pu(hu(e),xu()))),lu=e=>C(Me(()=>Yr(e)),Gt(e=>pu(hu(e),Su()))),uu=e=>C(Me(()=>Yr(e)),Gt(e=>pu(hu(e),Cu()))),du=()=>C(Me(()=>yr()),Gt(e=>pu(hu(e),Su()))),fu=(e,t,n,r,i)=>new ou(e,t,n,r,i),pu=(e,t)=>C(Wt(),We(n=>fu(e,yr(),n,ne(!1),t)));var mu=class{mutable;[tu]=ru;constructor(e){this.mutable=e}poll(e){return dn(this.mutable,e)}pollUpTo(e){return An(this.mutable,e)}offerAll(e){return mn(this.mutable,e)}offer(e){return Bn(this.mutable,e)}capacity(){return Ln(this.mutable)}length(){return Kr(this.mutable)}};const hu=e=>new mu(e),gu=e=>e.size,_u=e=>e.shutdown,vu=x(2,(e,t)=>e.offer(t)),yu=e=>e.take,bu=x(2,(e,t)=>e.takeUpTo(t)),xu=()=>new wu,Su=()=>new Tu,Cu=()=>new Eu;var wu=class{[eu]=nu;putters=yr();surplusSize(){return Kr(this.putters)}onCompleteTakersWithEmptyQueue(e){for(;!cn(this.putters)&&!cn(e);){let t=dn(e,void 0),n=dn(this.putters,void 0);n[2]&&Du(n[1],!0),Du(t,n[0])}}get shutdown(){return C(_t,Gt(e=>C(Me(()=>ku(this.putters)),Gt(t=>ir(t,([t,n,r])=>r?C(ot(n,e),qt):_e,!1,!1)))))}handleSurplus(e,t,n,r){return fe(i=>{let a=Mt(i.id());return C(Jt(()=>(this.unsafeOffer(e,a),this.unsafeOnQueueEmptySpace(t,n),Mu(this,t,n),Le(r)?u:zt(a))),at(()=>Me(()=>this.unsafeRemove(a))))})}unsafeOnQueueEmptySpace(e,t){let n=!0;for(;n&&(e.capacity()===1/0||e.length()<e.capacity());){let r=C(this.putters,dn(er));if(r===er)n=!1;else{let n=e.offer(r[0]);n&&r[2]?Du(r[1],!0):n||Ou(this.putters,C(ku(this.putters),St(r))),Mu(this,e,t)}}}unsafeOffer(e,t){let n=ue(e);for(let e=0;e<n.length;e++){let r=n[e];e===n.length-1?C(this.putters,Bn([r,t,!0])):C(this.putters,Bn([r,t,!1]))}}unsafeRemove(e){Ou(this.putters,C(ku(this.putters),Xt(([,t])=>t!==e)))}},Tu=class{[eu]=nu;surplusSize(){return 0}get shutdown(){return _e}onCompleteTakersWithEmptyQueue(){}handleSurplus(e,t,n,r){return c(!1)}unsafeOnQueueEmptySpace(e,t){}},Eu=class{[eu]=nu;surplusSize(){return 0}get shutdown(){return _e}onCompleteTakersWithEmptyQueue(){}handleSurplus(e,t,n,r){return Me(()=>(this.unsafeOffer(t,e),Mu(this,t,n),!0))}unsafeOnQueueEmptySpace(e,t){}unsafeOffer(e,t){let n=t[Symbol.iterator](),r,i=!0;for(;!(r=n.next()).done&&i;){if(e.capacity()===0)return;e.poll(er),i=e.offer(r.value)}}};const Du=(e,t)=>pt(e,c(t)),Ou=(e,t)=>C(e,mn(t)),ku=e=>C(e,An(1/0)),Au=(e,t)=>C(e,An(t)),ju=(e,t)=>{Ou(e,C(ku(e),Xt(e=>t!==e)))},Mu=(e,t,n)=>{let r=!0;for(;r&&t.length()!==0;){let i=C(n,dn(er));if(i!==er){let a=t.poll(er);a===er?Ou(n,C(ku(n),St(i))):(Du(i,a),e.unsafeOnQueueEmptySpace(t,n)),r=!0}else r=!1}r&&t.length()===0&&!cn(n)&&e.onCompleteTakersWithEmptyQueue(n)},Nu=cu,Pu=lu,Fu=uu,Iu=du,Lu=gu,Ru=_u,zu=vu,Bu=yu,Vu=`Continue`,Hu=Symbol.for(`effect/ChannelChildExecutorDecision`),Uu={[Hu]:Hu},Wu=e=>{let t=Object.create(Uu);return t._tag=Vu,t},Gu=Symbol.for(`effect/ChannelContinuation`),Ku={_Env:e=>e,_InErr:e=>e,_InElem:e=>e,_InDone:e=>e,_OutErr:e=>e,_OutDone:e=>e,_OutErr2:e=>e,_OutElem:e=>e,_OutDone2:e=>e};var qu=class{onSuccess;onHalt;_tag=`ContinuationK`;[Gu]=Ku;constructor(e,t){this.onSuccess=e,this.onHalt=t}onExit(e){return Ci(e)?this.onHalt(e.cause):this.onSuccess(e.value)}},Ju=class{finalizer;_tag=`ContinuationFinalizer`;[Gu]=Ku;constructor(e){this.finalizer=e}};const Yu=`PullAfterNext`,Xu=Symbol.for(`effect/ChannelUpstreamPullStrategy`),Zu={_A:e=>e},Qu={[Xu]:Zu},$u=e=>{let t=Object.create(Qu);return t._tag=Yu,t.emitSeparator=e,t},ed=`BracketOut`,td=`Bridge`,nd=`ConcatAll`,rd=`Emit`,id=`Ensuring`,ad=`Fail`,od=`Fold`,sd=`FromEffect`,cd=`PipeTo`,ld=`Read`,ud=`Succeed`,dd=`SucceedNow`,fd=`Suspend`,pd=Symbol.for(`effect/Channel`),md={_Env:e=>e,_InErr:e=>e,_InElem:e=>e,_InDone:e=>e,_OutErr:e=>e,_OutElem:e=>e,_OutDone:e=>e},hd={[pd]:md,pipe(){return De(this,arguments)}},gd=e=>Nt(e,pd)||wn(e),_d=x(2,(e,t)=>{let n=Object.create(hd);return n._tag=ed,n.acquire=()=>e,n.finalizer=t,n}),vd=(e,t,n)=>{let r=Object.create(hd);return r._tag=nd,r.combineInners=t,r.combineAll=n,r.onPull=()=>$u(v()),r.onEmit=()=>Wu,r.value=()=>e,r.k=S,r},yd=x(4,(e,t,n,r)=>{let i=Object.create(hd);return i._tag=nd,i.combineInners=n,i.combineAll=r,i.onPull=()=>$u(v()),i.onEmit=()=>Wu,i.value=()=>e,i.k=t,i}),bd=x(2,(e,t)=>{let n=Object.create(hd);return n._tag=td,n.input=t,n.channel=e,n}),xd=x(2,(e,t)=>{let n=Object.create(hd);return n._tag=id,n.channel=e,n.finalizer=t,n}),Sd=e=>Cd(ii(e)),Cd=e=>wd(()=>e),wd=e=>{let t=Object.create(hd);return t._tag=ad,t.error=e,t},z=x(2,(e,t)=>{let n=Object.create(hd);return n._tag=od,n.channel=e,n.k=new qu(t,Cd),n}),B=e=>{let t=Object.create(hd);return t._tag=sd,t.effect=()=>e,t},Td=x(2,(e,t)=>{let n=Object.create(hd);return n._tag=cd,n.left=()=>e,n.right=()=>t,n}),Ed=e=>Dd({onInput:e.onInput,onFailure:t=>Ge(ei(t),{onLeft:e.onFailure,onRight:Cd}),onDone:e.onDone}),Dd=e=>{let t=Object.create(hd);return t._tag=ld,t.more=e.onInput,t.done=new qu(e.onDone,e.onFailure),t},Od=e=>jd(()=>e),kd=e=>{let t=Object.create(hd);return t._tag=dd,t.terminal=e,t},Ad=e=>{let t=Object.create(hd);return t._tag=fd,t.channel=e,t},jd=e=>{let t=Object.create(hd);return t._tag=ud,t.evaluate=e,t},Md=kd(void 0),V=e=>{let t=Object.create(hd);return t._tag=rd,t.out=e,t},Nd=`Done`,Pd=`Emit`,Fd=`FromEffect`,Id=`Read`,Ld=Symbol.for(`effect/ChannelState`),Rd={_E:e=>e,_R:e=>e},zd={[Ld]:Rd},Bd=()=>{let e=Object.create(zd);return e._tag=Nd,e},Vd=()=>{let e=Object.create(zd);return e._tag=Pd,e},Hd=e=>{let t=Object.create(zd);return t._tag=Fd,t.effect=e,t},Ud=(e,t,n,r)=>{let i=Object.create(zd);return i._tag=Id,i.upstream=e,i.onEffect=t,i.onEmit=n,i.onDone=r,i},Wd=e=>e._tag===Fd,Gd=e=>Wd(e)?e.effect:A,Kd=e=>Wd(e)?On(e.effect):void 0,qd=`PullFromChild`,Jd=`PullFromUpstream`,Yd=`DrainChildExecutors`,Xd=`Emit`;var Zd=class{childExecutor;parentSubexecutor;onEmit;_tag=qd;constructor(e,t,n){this.childExecutor=e,this.parentSubexecutor=t,this.onEmit=n}close(e){let t=this.childExecutor.close(e),n=this.parentSubexecutor.close(e);if(t!==void 0&&n!==void 0)return Qr(O(t),O(n),(e,t)=>C(e,gi(t)));if(t!==void 0)return t;if(n!==void 0)return n}enqueuePullFromChild(e){return this}},Qd=class e{upstreamExecutor;createChild;lastDone;activeChildExecutors;combineChildResults;combineWithChildResult;onPull;onEmit;_tag=Jd;constructor(e,t,n,r,i,a,o,s){this.upstreamExecutor=e,this.createChild=t,this.lastDone=n,this.activeChildExecutors=r,this.combineChildResults=i,this.combineWithChildResult=a,this.onPull=o,this.onEmit=s}close(e){let t=this.upstreamExecutor.close(e);return[...this.activeChildExecutors.map(t=>t===void 0?void 0:t.childExecutor.close(e)),t].reduce((e,t)=>{if(e!==void 0&&t!==void 0)return Qr(e,O(t),(e,t)=>gi(e,t));if(e!==void 0)return e;if(t!==void 0)return O(t)},void 0)}enqueuePullFromChild(t){return new e(this.upstreamExecutor,this.createChild,this.lastDone,[...this.activeChildExecutors,t],this.combineChildResults,this.combineWithChildResult,this.onPull,this.onEmit)}},$d=class e{upstreamExecutor;lastDone;activeChildExecutors;upstreamDone;combineChildResults;combineWithChildResult;onPull;_tag=Yd;constructor(e,t,n,r,i,a,o){this.upstreamExecutor=e,this.lastDone=t,this.activeChildExecutors=n,this.upstreamDone=r,this.combineChildResults=i,this.combineWithChildResult=a,this.onPull=o}close(e){let t=this.upstreamExecutor.close(e);return[...this.activeChildExecutors.map(t=>t===void 0?void 0:t.childExecutor.close(e)),t].reduce((e,t)=>{if(e!==void 0&&t!==void 0)return Qr(e,O(t),(e,t)=>gi(e,t));if(e!==void 0)return e;if(t!==void 0)return O(t)},void 0)}enqueuePullFromChild(t){return new e(this.upstreamExecutor,this.lastDone,[...this.activeChildExecutors,t],this.upstreamDone,this.combineChildResults,this.combineWithChildResult,this.onPull)}},ef=class{value;next;_tag=Xd;constructor(e,t){this.value=e,this.next=t}close(e){return this.next.close(e)}enqueuePullFromChild(e){return this}};const tf=Symbol.for(`effect/ChannelUpstreamPullRequest`),nf={_A:e=>e},rf={[tf]:nf},af=e=>{let t=Object.create(rf);return t._tag=`Pulled`,t.value=e,t},of=e=>{let t=Object.create(rf);return t._tag=`NoUpstream`,t.activeDownstreamCount=e,t};var sf=class e{_activeSubexecutor=void 0;_cancelled=void 0;_closeLastSubstream=void 0;_currentChannel;_done=void 0;_doneStack=[];_emitted=void 0;_executeCloseLastSubstream;_input=void 0;_inProgressFinalizer=void 0;_providedEnv;constructor(e,t,n){this._currentChannel=e,this._executeCloseLastSubstream=n,this._providedEnv=t}run(){let t;for(;t===void 0;)if(this._cancelled!==void 0)t=this.processCancellation();else if(this._activeSubexecutor!==void 0)t=this.runSubexecutor();else try{if(this._currentChannel===void 0)t=Bd();else switch(wn(this._currentChannel)&&(this._currentChannel=B(this._currentChannel)),this._currentChannel._tag){case ed:t=this.runBracketOut(this._currentChannel);break;case td:{let e=this._currentChannel.input;if(this._currentChannel=this._currentChannel.channel,this._input!==void 0){let n=this._input;this._input=void 0;let r=()=>D(e.awaitRead(),()=>k(()=>{let t=n.run();switch(t._tag){case Nd:return mi(n.getDone(),{onFailure:t=>e.error(t),onSuccess:t=>e.done(t)});case Pd:return D(e.emit(n.getEmit()),()=>r());case Fd:return $r(t.effect,{onFailure:t=>e.error(t),onSuccess:()=>r()});case Id:return uf(t,()=>r(),t=>e.error(t))}}));t=Hd(D(Gr(an(r())),e=>Qn(()=>this.addFinalizer(t=>D(Rr(e),()=>k(()=>{let e=this.restorePipe(t,n);return e===void 0?A:e}))))))}break}case nd:{let t=new e(this._currentChannel.value(),this._providedEnv,e=>Qn(()=>{let t=this._closeLastSubstream===void 0?A:this._closeLastSubstream;this._closeLastSubstream=C(t,M(e))}));t._input=this._input;let n=this._currentChannel;this._activeSubexecutor=new Qd(t,e=>n.k(e),void 0,[],(e,t)=>n.combineInners(e,t),(e,t)=>n.combineAll(e,t),e=>n.onPull(e),e=>n.onEmit(e)),this._closeLastSubstream=void 0,this._currentChannel=void 0;break}case rd:this._emitted=this._currentChannel.out,this._currentChannel=this._activeSubexecutor===void 0?Md:void 0,t=Vd();break;case id:this.runEnsuring(this._currentChannel);break;case ad:t=this.doneHalt(this._currentChannel.error());break;case od:this._doneStack.push(this._currentChannel.k),this._currentChannel=this._currentChannel.channel;break;case sd:{let e=this._providedEnv===void 0?this._currentChannel.effect():C(this._currentChannel.effect(),Un(this._providedEnv));t=Hd($r(e,{onFailure:e=>{let t=this.doneHalt(e);return t!==void 0&&Wd(t)?t.effect:A},onSuccess:e=>{let t=this.doneSucceed(e);return t!==void 0&&Wd(t)?t.effect:A}}));break}case cd:{let t=this._input,n=new e(this._currentChannel.left(),this._providedEnv,e=>this._executeCloseLastSubstream(e));n._input=t,this._input=n,this.addFinalizer(e=>{let n=this.restorePipe(e,t);return n===void 0?A:n}),this._currentChannel=this._currentChannel.right();break}case`Provide`:{let e=this._providedEnv;this._providedEnv=this._currentChannel.context(),this._currentChannel=this._currentChannel.inner,this.addFinalizer(()=>Qn(()=>{this._providedEnv=e}));break}case ld:{let e=this._currentChannel;t=Ud(this._input,S,t=>{try{this._currentChannel=e.more(t)}catch(t){this._currentChannel=e.done.onExit(Si(t))}},t=>{let n=t=>e.done.onExit(t);this._currentChannel=n(t)});break}case ud:t=this.doneSucceed(this._currentChannel.evaluate());break;case dd:t=this.doneSucceed(this._currentChannel.terminal);break;case fd:this._currentChannel=this._currentChannel.channel();break}}catch(e){this._currentChannel=Cd(li(e))}return t}getDone(){return this._done}getEmit(){return this._emitted}cancelWith(e){this._cancelled=e}clearInProgressFinalizer(){this._inProgressFinalizer=void 0}storeInProgressFinalizer(e){this._inProgressFinalizer=e}popAllFinalizers(e){let t=[],n=this._doneStack.pop();for(;n;)n._tag===`ContinuationFinalizer`&&t.push(n.finalizer),n=this._doneStack.pop();let r=t.length===0?A:lf(t,e);return this.storeInProgressFinalizer(r),r}popNextFinalizers(){let e=[];for(;this._doneStack.length!==0;){let t=this._doneStack[this._doneStack.length-1];if(t._tag===`ContinuationK`)return e;e.push(t),this._doneStack.pop()}return e}restorePipe(e,t){let n=this._input;return this._input=t,n===void 0?A:n.close(e)}close(e){let t,n=this._inProgressFinalizer;n!==void 0&&(t=C(n,dr(Qn(()=>this.clearInProgressFinalizer()))));let r,i=this.popAllFinalizers(e);i!==void 0&&(r=C(i,dr(Qn(()=>this.clearInProgressFinalizer()))));let a=this._activeSubexecutor===void 0?void 0:this._activeSubexecutor.close(e);if(a!==void 0||t!==void 0||r!==void 0)return C(O(cf(a)),ur(O(cf(t))),ur(O(cf(r))),E(([[e,t],n])=>C(e,gi(t),gi(n))),ar,D(e=>k(()=>e)))}doneSucceed(e){if(this._doneStack.length===0)return this._done=hi(e),this._currentChannel=void 0,Bd();let t=this._doneStack[this._doneStack.length-1];if(t._tag===`ContinuationK`){this._doneStack.pop(),this._currentChannel=t.onSuccess(e);return}let n=this.popNextFinalizers();if(this._doneStack.length===0)return this._doneStack=n.reverse(),this._done=hi(e),this._currentChannel=void 0,Bd();let r=lf(n.map(e=>e.finalizer),hi(e));this.storeInProgressFinalizer(r);let i=C(r,dr(Qn(()=>this.clearInProgressFinalizer())),ar,D(()=>Qn(()=>this.doneSucceed(e))));return Hd(i)}doneHalt(e){if(this._doneStack.length===0)return this._done=fi(e),this._currentChannel=void 0,Bd();let t=this._doneStack[this._doneStack.length-1];if(t._tag===`ContinuationK`){this._doneStack.pop();try{this._currentChannel=t.onHalt(e)}catch(e){this._currentChannel=Cd(li(e))}return}let n=this.popNextFinalizers();if(this._doneStack.length===0)return this._doneStack=n.reverse(),this._done=fi(e),this._currentChannel=void 0,Bd();let r=lf(n.map(e=>e.finalizer),fi(e));this.storeInProgressFinalizer(r);let i=C(r,dr(Qn(()=>this.clearInProgressFinalizer())),ar,D(()=>Qn(()=>this.doneHalt(e))));return Hd(i)}processCancellation(){return this._currentChannel=void 0,this._done=this._cancelled,this._cancelled=void 0,Bd()}runBracketOut(e){let t=ar($r(this.provide(e.acquire()),{onFailure:e=>Qn(()=>{this._currentChannel=Cd(e)}),onSuccess:t=>Qn(()=>{this.addFinalizer(n=>this.provide(e.finalizer(t,n))),this._currentChannel=V(t)})}));return Hd(t)}provide(e){return this._providedEnv===void 0?e:C(e,Un(this._providedEnv))}runEnsuring(e){this.addFinalizer(e.finalizer),this._currentChannel=e.channel}addFinalizer(e){this._doneStack.push(new Ju(e))}runSubexecutor(){let e=this._activeSubexecutor;switch(e._tag){case qd:return this.pullFromChild(e.childExecutor,e.parentSubexecutor,e.onEmit,e);case Jd:return this.pullFromUpstream(e);case Yd:return this.drainChildExecutors(e);case Xd:return this._emitted=e.value,this._activeSubexecutor=e.next,Vd()}}replaceSubexecutor(e){this._currentChannel=void 0,this._activeSubexecutor=e}finishWithExit(e){let t=mi(e,{onFailure:e=>this.doneHalt(e),onSuccess:e=>this.doneSucceed(e)});return this._activeSubexecutor=void 0,t===void 0?A:Gd(t)}finishSubexecutorWithCloseEffect(e,...t){this.addFinalizer(()=>C(t,on(t=>C(Qn(()=>t(e)),D(e=>e===void 0?A:e)),{discard:!0})));let n=C(e,mi({onFailure:e=>this.doneHalt(e),onSuccess:e=>this.doneSucceed(e)}));return this._activeSubexecutor=void 0,n}applyUpstreamPullStrategy(e,t,n){switch(n._tag){case Yu:{let r=!e||t.some(e=>e!==void 0);return[n.emitSeparator,r?[void 0,...t]:t]}case`PullAfterAllEnqueued`:{let r=!e||t.some(e=>e!==void 0);return[n.emitSeparator,r?[...t,void 0]:t]}}}pullFromChild(e,t,n,r){return Ud(e,S,i=>{let a=n(i);switch(a._tag){case Vu:break;case`Close`:this.finishWithDoneValue(e,t,a.value);break;case`Yield`:{let e=t.enqueuePullFromChild(r);this.replaceSubexecutor(e);break}}this._activeSubexecutor=new ef(i,this._activeSubexecutor)},mi({onFailure:n=>{let r=this.handleSubexecutorFailure(e,t,n);return r===void 0?void 0:Kd(r)},onSuccess:n=>{this.finishWithDoneValue(e,t,n)}}))}finishWithDoneValue(e,t,n){let r=t;switch(r._tag){case Jd:{let t=new Qd(r.upstreamExecutor,r.createChild,r.lastDone===void 0?n:r.combineChildResults(r.lastDone,n),r.activeChildExecutors,r.combineChildResults,r.combineWithChildResult,r.onPull,r.onEmit);this._closeLastSubstream=e.close(hi(n)),this.replaceSubexecutor(t);break}case Yd:{let t=new $d(r.upstreamExecutor,r.lastDone===void 0?n:r.combineChildResults(r.lastDone,n),r.activeChildExecutors,r.upstreamDone,r.combineChildResults,r.combineWithChildResult,r.onPull);this._closeLastSubstream=e.close(hi(n)),this.replaceSubexecutor(t);break}default:break}}handleSubexecutorFailure(e,t,n){return this.finishSubexecutorWithCloseEffect(fi(n),e=>t.close(e),t=>e.close(t))}pullFromUpstream(e){if(e.activeChildExecutors.length===0)return this.performPullFromUpstream(e);let t=e.activeChildExecutors[0],n=new Qd(e.upstreamExecutor,e.createChild,e.lastDone,e.activeChildExecutors.slice(1),e.combineChildResults,e.combineWithChildResult,e.onPull,e.onEmit);if(t===void 0)return this.performPullFromUpstream(n);this.replaceSubexecutor(new Zd(t.childExecutor,n,t.onEmit))}performPullFromUpstream(t){return Ud(t.upstreamExecutor,e=>{let t=this._closeLastSubstream===void 0?A:this._closeLastSubstream;return this._closeLastSubstream=void 0,C(this._executeCloseLastSubstream(t),M(e))},n=>{if(this._closeLastSubstream!==void 0){let r=this._closeLastSubstream;return this._closeLastSubstream=void 0,C(this._executeCloseLastSubstream(r),E(()=>{let r=new e(t.createChild(n),this._providedEnv,this._executeCloseLastSubstream);r._input=this._input;let[i,a]=this.applyUpstreamPullStrategy(!1,t.activeChildExecutors,t.onPull(af(n)));this._activeSubexecutor=new Zd(r,new Qd(t.upstreamExecutor,t.createChild,t.lastDone,a,t.combineChildResults,t.combineWithChildResult,t.onPull,t.onEmit),t.onEmit),bt(i)&&(this._activeSubexecutor=new ef(i.value,this._activeSubexecutor))}))}let r=new e(t.createChild(n),this._providedEnv,this._executeCloseLastSubstream);r._input=this._input;let[i,a]=this.applyUpstreamPullStrategy(!1,t.activeChildExecutors,t.onPull(af(n)));this._activeSubexecutor=new Zd(r,new Qd(t.upstreamExecutor,t.createChild,t.lastDone,a,t.combineChildResults,t.combineWithChildResult,t.onPull,t.onEmit),t.onEmit),bt(i)&&(this._activeSubexecutor=new ef(i.value,this._activeSubexecutor))},e=>{if(t.activeChildExecutors.some(e=>e!==void 0)){let e=new $d(t.upstreamExecutor,t.lastDone,[void 0,...t.activeChildExecutors],t.upstreamExecutor.getDone(),t.combineChildResults,t.combineWithChildResult,t.onPull);if(this._closeLastSubstream!==void 0){let t=this._closeLastSubstream;return this._closeLastSubstream=void 0,C(this._executeCloseLastSubstream(t),E(()=>this.replaceSubexecutor(e)))}this.replaceSubexecutor(e);return}let n=this._closeLastSubstream,r=this.finishSubexecutorWithCloseEffect(C(e,vi(e=>t.combineWithChildResult(t.lastDone,e))),()=>n,e=>t.upstreamExecutor.close(e));return r===void 0?void 0:Kd(r)})}drainChildExecutors(e){if(e.activeChildExecutors.length===0){let t=this._closeLastSubstream;return t!==void 0&&this.addFinalizer(()=>j(t)),this.finishSubexecutorWithCloseEffect(e.upstreamDone,()=>t,t=>e.upstreamExecutor.close(t))}let t=e.activeChildExecutors[0],n=e.activeChildExecutors.slice(1);if(t===void 0){let[t,r]=this.applyUpstreamPullStrategy(!0,n,e.onPull(of(n.reduce((e,t)=>t===void 0?e:e+1,0))));return this.replaceSubexecutor(new $d(e.upstreamExecutor,e.lastDone,r,e.upstreamDone,e.combineChildResults,e.combineWithChildResult,e.onPull)),bt(t)?(this._emitted=t.value,Vd()):void 0}let r=new $d(e.upstreamExecutor,e.lastDone,n,e.upstreamDone,e.combineChildResults,e.combineWithChildResult,e.onPull);this.replaceSubexecutor(new Zd(t.childExecutor,r,t.onEmit))}};const cf=e=>e===void 0?A:e,lf=(e,t)=>C(on(e,e=>O(e(t))),E(e=>C(bi(e),Ne(()=>xi))),D(e=>k(()=>e))),uf=(e,t,n)=>{let r=[e],i=()=>{let e=r.pop();if(e===void 0||e.upstream===void 0)return kr(`Unexpected end of input for channel execution`);let a=e.upstream.run();switch(a._tag){case Pd:{let a=e.onEmit(e.upstream.getEmit());return r.length===0?a===void 0?k(t):C(a,$r({onFailure:n,onSuccess:t})):a===void 0?k(()=>i()):C(a,$r({onFailure:n,onSuccess:()=>i()}))}case Nd:{let a=e.onDone(e.upstream.getDone());return r.length===0?a===void 0?k(t):C(a,$r({onFailure:n,onSuccess:t})):a===void 0?k(()=>i()):C(a,$r({onFailure:n,onSuccess:()=>i()}))}case Fd:return r.push(e),C(e.onEffect(a.effect),Br(t=>k(()=>{let n=e.onDone(fi(t));return n===void 0?A:n})),$r({onFailure:n,onSuccess:()=>i()}));case Id:return r.push(e),r.push(a),k(()=>i())}};return i()},df=x(2,(e,t)=>{let n=(t,n,r)=>mr(Qn(()=>new sf(e,void 0,S)),e=>k(()=>ff(e.run(),e).pipe(hr(t),M(T(t)),Yn(T(n)))),(e,t)=>{let n=e.close(t);return n===void 0?A:Lr(n,e=>Zn(r,Ur(e)))});return cr(e=>Xn([xr(t,In),Dn(),Dn()]).pipe(D(([r,i,a])=>e(n(i,a,r)).pipe(Rn(t),D(n=>t.addFinalizer(e=>{let t=Ci(e)?ti(e.cause):void 0;return Tn(i).pipe(D(e=>e?jn(a,void 0).pipe(M(rn(n)),M(or(n))):jn(a,void 0).pipe(M(t&&ht(t)>0?Tr(n,yt(t)):Rr(n)),M(or(n)))))}).pipe(M(e(T(i)))))))))}),ff=(e,t)=>{let n=e;switch(n._tag){case Fd:return C(n.effect,D(()=>ff(t.run(),t)));case Pd:return ff(t.run(),t);case Nd:return k(()=>t.getDone());case Id:return uf(n,()=>ff(t.run(),t),Ur)}},pf={[Symbol.for(`effect/ChannelMergeDecision`)]:{_R:e=>e,_E0:e=>e,_Z0:e=>e,_E:e=>e,_Z:e=>e}},mf=e=>{let t=Object.create(pf);return t._tag=`Await`,t.f=e,t},hf=`BothRunning`,gf=`LeftDone`,_f=`RightDone`,vf=Symbol.for(`effect/ChannelMergeState`),yf={[vf]:vf},bf=(e,t)=>{let n=Object.create(yf);return n._tag=hf,n.left=e,n.right=t,n},xf=e=>{let t=Object.create(yf);return t._tag=gf,t.f=e,t},Sf=e=>{let t=Object.create(yf);return t._tag=_f,t.f=e,t},Cf=`BackPressure`,wf=`BufferSliding`,Tf=Symbol.for(`effect/ChannelMergeStrategy`),Ef={[Tf]:Tf},Df=e=>{let t=Object.create(Ef);return t._tag=Cf,t},Of=e=>{let t=Object.create(Ef);return t._tag=wf,t},kf=x(2,(e,{onBackPressure:t,onBufferSliding:n})=>{switch(e._tag){case Cf:return t();case wf:return n()}}),Af=`Empty`,jf=`Emit`,Mf=`Error`,Nf=`Done`,Pf=e=>({_tag:Af,notifyProducer:e}),Ff=e=>({_tag:jf,notifyConsumers:e}),If=e=>({_tag:Mf,cause:e}),Lf=e=>({_tag:Nf,done:e});var Rf=class{ref;constructor(e){this.ref=e}awaitRead(){return qr(Zr(this.ref,e=>e._tag===Af?[T(e.notifyProducer),e]:[A,e]))}get close(){return Xr(e=>this.error(ui(e)))}done(e){return qr(Zr(this.ref,t=>{switch(t._tag){case Af:return[T(t.notifyProducer),t];case jf:return[on(t.notifyConsumers,t=>jn(t,y(e)),{discard:!0}),Lf(e)];case Mf:return[_r,t];case Nf:return[_r,t]}}))}emit(e){return D(Dn(),t=>qr(Zr(this.ref,n=>{switch(n._tag){case Af:return[T(n.notifyProducer),n];case jf:{let r=n.notifyConsumers[0],i=n.notifyConsumers.slice(1);if(r!==void 0)return[jn(r,b(e)),i.length===0?Pf(t):Ff(i)];throw Error(`Bug: Channel.SingleProducerAsyncInput.emit - Queue was empty! please report an issue at https://github.com/Effect-TS/effect/issues`)}case Mf:return[_r,n];case Nf:return[_r,n]}})))}error(e){return qr(Zr(this.ref,t=>{switch(t._tag){case Af:return[T(t.notifyProducer),t];case jf:return[on(t.notifyConsumers,t=>gr(t,e),{discard:!0}),If(e)];case Mf:return[_r,t];case Nf:return[_r,t]}}))}get take(){return this.takeWith(e=>fi(ni(e,y)),e=>hi(e),e=>_i(b(e)))}takeWith(e,t,n){return D(Dn(),r=>qr(Zr(this.ref,i=>{switch(i._tag){case Af:return[M(jn(i.notifyProducer,void 0),Nn(T(r),{onFailure:e,onSuccess:Ge({onLeft:n,onRight:t})})),Ff([r])];case jf:return[Nn(T(r),{onFailure:e,onSuccess:Ge({onLeft:n,onRight:t})}),Ff([...i.notifyConsumers,r])];case Mf:return[j(e(i.cause)),i];case Nf:return[j(n(i.done)),i]}})))}};const zf=()=>C(Dn(),D(e=>Wr(Pf(e))),E(e=>new Rf(e))),Bf=x(2,(e,t)=>yd(e,t,()=>void 0,()=>void 0)),Vf=e=>{let t=Dd({onInput:()=>t,onFailure:Cd,onDone:Od});return Td(e,t)},Hf=x(2,(e,t)=>xd(e,()=>t)),Uf=e=>z(e,S),Wf=e=>rp(e.takeWith(Cd,t=>z(V(t),()=>Wf(e)),Od)),Gf=x(2,(e,t)=>z(e,e=>jd(()=>t(e)))),Kf=x(2,(e,t)=>{let n=Ed({onInput:e=>z(V(t(e)),()=>n),onFailure:Sd,onDone:kd});return Td(e,n)}),qf=x(2,(e,t)=>{let n=Dd({onInput:e=>C(B(t(e)),z(V),z(()=>n)),onFailure:Cd,onDone:kd});return Td(e,n)}),Jf=e=>t=>Yf(e)(t,mt),Yf=({bufferSize:e=16,concurrency:t,mergeStrategy:n=Df()})=>(r,i)=>ap(a=>ln(function*(){let o=t===`unbounded`?2**53-1:t,s=yield*zf(),c=Wf(s),l=yield*Nu(e);yield*Zn(a,Ru(l));let u=yield*Iu();yield*Zn(a,Ru(u));let d=yield*Wr(v()),f=yield*Dn(),p=(yield*En(o)).withPermits,m=yield*tp(Td(c,r),a);function h(e){return e.pipe(D(Ge({onLeft:e=>j(w(e)),onRight:e=>Er(zu(l,j(b(e))),v())})),bn({until:e=>bt(e)}),D(e=>Jr(d,_({onNone:()=>w(e.value),onSome:t=>w(i(t,e.value))}))),Br(e=>di(e)?Ur(e):zu(l,Ur(e)).pipe(M(jn(f,void 0)),Fr)))}yield*m.pipe($r({onFailure:e=>zu(l,Ur(e)).pipe(M(j(!1))),onSuccess:Ge({onLeft:e=>jr(an(T(f)),an(p(o)(A)),{onSelfDone:(e,t)=>Er(Rr(t),!1),onOtherDone:(t,n)=>M(Rr(n),Jn(d).pipe(D(_({onNone:()=>zu(l,j(y(e))),onSome:t=>zu(l,j(y(i(t,e))))})),Er(!1)))}),onRight:e=>kf(n,{onBackPressure:()=>ln(function*(){let t=yield*Dn(),n=zr(t=>tp(Td(c,e),t).pipe(D(e=>xn(O(h(e)),O(an(T(f))))),D(S)));return yield*jn(t,void 0).pipe(M(n),p(1),Rn(a)),yield*T(t),!(yield*Tn(f))}),onBufferSliding:()=>ln(function*(){let t=yield*Dn(),n=yield*Dn(),r=yield*Lu(u);yield*Bu(u).pipe(D(e=>jn(e,void 0)),wr(()=>r>=o)),yield*zu(u,t);let i=zr(n=>tp(Td(c,e),n).pipe(D(e=>O(h(e)).pipe(xn(O(an(T(f)))),xn(O(an(T(t)))))),D(S)));return yield*jn(n,void 0).pipe(M(i),p(1),Rn(a)),yield*T(n),!(yield*Tn(f))})})})}),bn({while:e=>e}),Rn(a));let g=C(Bu(l),qr,Nn({onFailure:Cd,onSuccess:Ge({onLeft:kd,onRight:e=>z(V(e),()=>g)})}),rp);return bd(g,s)})),Xf=x(3,(e,t,n)=>Jf(n)(Kf(e,t))),Zf=x(2,(e,t)=>{function n(n){return ln(function*(){let r=yield*zf(),i=Wf(r),a=yield*tp(Td(i,e),n),o=yield*tp(Td(i,t.other),n);function s(e,t,r){return(i,a,o)=>{function s(e){let n=e;return n._tag===`Done`?j(B(M(Rr(t),n.effect))):E(rn(t),mi({onFailure:e=>B(n.f(fi(e))),onSuccess:Ge({onLeft:e=>B(n.f(hi(e))),onRight:e=>lp(V(e),c(o(n.f)))})}))}return mi(e,{onFailure:e=>s(i(fi(e))),onSuccess:Ge({onLeft:e=>s(i(hi(e))),onRight:e=>j(z(V(e),()=>z(B(Rn(an(r),n)),e=>c(a(e,t)))))})})}}function c(e){switch(e._tag){case hf:{let n=an(Pr(e.left)),r=an(Pr(e.right));return rp(jr(n,r,{onSelfDone:(n,r)=>M(Rr(r),s(n,e.right,a)(t.onSelfDone,bf,e=>xf(e))),onOtherDone:(n,r)=>M(Rr(r),s(n,e.left,o)(t.onOtherDone,(e,t)=>bf(t,e),e=>Sf(e)))}))}case gf:return rp(E(O(o),mi({onFailure:t=>B(e.f(fi(t))),onSuccess:Ge({onLeft:t=>B(e.f(hi(t))),onRight:t=>z(V(t),()=>c(xf(e.f)))})})));case _f:return rp(E(O(a),mi({onFailure:t=>B(e.f(fi(t))),onSuccess:Ge({onLeft:t=>B(e.f(hi(t))),onRight:t=>z(V(t),()=>c(Sf(e.f)))})})))}}return B(pr(e=>{let t=pr(t=>(t.transferChildren(e.scope()),A));return Qr(an(a).pipe(dr(t),Rn(n)),an(o).pipe(dr(t),Rn(n)),(e,t)=>bf(e,t))})).pipe(z(c),bd(r))})}return ap(n)}),Qf=e=>nn(t=>df(e,t)),$f=e=>rp(cr(t=>E(Vr(),n=>_d(Lr(t(tr(e,n)),e=>Ir(n,fi(e))),(e,t)=>Ir(n,t))))),ep=e=>ip(E(Mn,t=>z(B(e(t)),V))),tp=x(2,(e,t)=>ur(Qn(()=>new sf(e,void 0,S)),Kn()).pipe(Or(([e,n])=>Dr(t,t=>{let r=e.close(t);return r===void 0?A:Un(r,n)})),ar,E(([e])=>k(()=>np(e.run(),e))))),np=(e,t)=>{let n=e;switch(n._tag){case Nd:return mi(t.getDone(),{onFailure:Ur,onSuccess:e=>j(y(e))});case Pd:return j(b(t.getEmit()));case Fd:return C(n.effect,D(()=>np(t.run(),t)));case Id:return uf(n,()=>np(t.run(),t),e=>Ur(e))}},rp=e=>Uf(B(e)),ip=e=>vd($f(e),(e,t)=>e,(e,t)=>e),ap=e=>vd(ep(e),(e,t)=>e,(e,t)=>e),op=e=>sp(0,e.length,e),sp=(e,t,n)=>e===t?Md:C(V(C(n,ee(e))),z(()=>sp(e+1,t,n))),cp=x(e=>gd(e[1]),(e,t,n)=>n?.concurrent?Zf(e,{other:t,onSelfDone:e=>mf(t=>k(()=>yi(e,t))),onOtherDone:e=>mf(t=>k(()=>yi(t,e)))}):z(e,e=>Gf(t,t=>[e,t]))),lp=x(e=>gd(e[1]),(e,t,n)=>n?.concurrent?Gf(cp(e,t,{concurrent:!0}),e=>e[1]):z(e,()=>t)),up=Symbol.for(`effect/Sink`),dp={_A:e=>e,_In:e=>e,_L:e=>e,_E:e=>e,_R:e=>e};var fp=class{channel;[up]=dp;constructor(e){this.channel=e}pipe(){return De(this,arguments)}};const pp=e=>{let t=Dd({onInput:n=>C(B(on(n,t=>e(t),{discard:!0})),z(()=>t)),onFailure:Cd,onDone:()=>Md});return new fp(t)},mp=e=>new fp(B(e)),hp=e=>wn(e)?hp(mp(e)):e.channel,gp=e=>new fp(ip(e.pipe(E(e=>hp(e))))),_p=Mr,vp=e=>Object.assign(e,{chunk(e){return this(j(e))},die(e){return this(sr(e))},dieMessage(e){return this(kr(e))},done(e){return this(k(()=>wi(e,{onFailure:w,onSuccess:ye})))},end(){return this(qn(v()))},fail(e){return this(qn(w(e)))},fromEffect(e){return this(hn(e,{onFailure:w,onSuccess:ye}))},fromEffectChunk(e){return this(C(e,vn(w)))},halt(e){return this(Ur(C(e,ni(w))))},single(e){return this(j(ye(e)))}}),yp=Symbol.for(`effect/Take`),bp={_A:e=>e,_E:e=>e};var xp=class{exit;[yp]=bp;constructor(e){this.exit=e}pipe(){return De(this,arguments)}};const Sp=e=>new xp(hi(e)),Cp=e=>k(()=>e.exit),wp=new xp(_i(v())),Tp=e=>new xp(fi(C(e,ni(w)))),Ep=e=>Nn(e,{onFailure:e=>_(si(e),{onNone:()=>wp,onSome:Tp}),onSuccess:Sp}),Dp=x(2,(e,{onEnd:t,onFailure:n,onSuccess:r})=>mi(e.exit,{onFailure:e=>_(si(e),{onNone:t,onSome:n}),onSuccess:r})),Op=()=>qn(v()),kp=Symbol.for(`effect/Stream`),Ap={_R:e=>e,_E:e=>e,_A:e=>e};var jp=class{channel;[kp]=Ap;constructor(e){this.channel=e}pipe(){return De(this,arguments)}};const Mp=e=>Nt(e,kp)||wn(e),Np=e=>{if(e===`unbounded`)return Iu();if(typeof e==`number`||e===void 0)return Nu(e??16);switch(e.strategy){case`dropping`:return Pu(e.bufferSize??16);case`sliding`:return Fu(e.bufferSize??16);default:return Nu(e.bufferSize??16)}},Pp=(e,t)=>C(Nr(Np(t),e=>Ru(e)),D(t=>C(Kn(),D(n=>C(e(vp(e=>C(Ep(e),D(e=>zu(t,e)),Fr,_p(n)).then(e=>{if(Ci(e)&&!di(e.cause))throw ci(e.cause)}))),M(Wr(!1)),D(e=>C(Jn(e),E(n=>n?Op():C(Bu(t),D(Cp),Hn(()=>C($n(e,!0),M(Ru(t)))))))))))),Yp,zp(qp)),Fp=x(2,(e,t)=>{if(t.strategy===`dropping`)return Ip(e,t.capacity);if(t.strategy===`sliding`)return Lp(e,t.capacity);let n=Zp(e,t);return new jp(ip(E(n,e=>{let t=C(B(Bu(e)),z(Dp({onEnd:()=>Md,onFailure:Cd,onSuccess:e=>C(V(e),z(()=>t))})));return t})))}),Ip=x(2,(e,t)=>{let n=Nr(Pu(t),e=>Ru(e));return new jp(Rp(n,Wp(e)))}),Lp=x(2,(e,t)=>{let n=Nr(Fu(t),e=>Ru(e));return new jp(Rp(n,Wp(e)))}),Rp=(e,t)=>{let n=(e,t)=>{let r=n=>C(Jn(t),Or(T),M(Dn()),D(r=>C(zu(e,[n,r]),M($n(t,r)),M(T(r)))),Fr,B);return Dd({onInput:r=>C(Dn(),D(n=>C(zu(e,[Sp(r),n]),D(e=>C($n(t,n),wr(()=>e))))),Fr,B,z(()=>n(e,t))),onFailure:e=>r(Tp(e)),onDone:()=>r(wp)})},r=e=>{let t=C(B(Bu(e)),z(([e,n])=>lp(B(jn(n,void 0)),Dp(e,{onEnd:()=>Md,onFailure:Cd,onSuccess:e=>C(V(e),z(()=>t))}))));return t};return ip(C(e,D(e=>C(Dn(),Or(e=>jn(e,void 0)),D(i=>C(Wr(i),D(r=>C(t,Td(n(e,r)),Qf,fn)),Er(r(e))))))))},zp=x(e=>Mp(e[0]),(e,t,n)=>{let i=n?.bufferSize??16;return n?.switch?Bp(n?.concurrency,()=>Vp(e,1,i,t),n=>Vp(e,n,i,t)):Bp(n?.concurrency,()=>new jp(Bf(Wp(e),e=>C(e,d(e=>Wp(t(e))),r(Md,(e,t)=>C(e,lp(t)))))),r=>new jp(C(Wp(e),Bf(op),Xf(e=>Wp(t(e)),n))))}),Bp=(e,t,n)=>{switch(e){case void 0:return t();case`unbounded`:return n(2**53-1);default:return e>1?n(e):t()}},Vp=x(4,(e,t,n,r)=>new jp(C(Wp(e),Bf(op),Xf(e=>Wp(r(e)),{concurrency:t,mergeStrategy:Of(),bufferSize:n})))),Hp=x(e=>Mp(e[0]),(e,t)=>zp(e,S,t)),Up=e=>new jp(e),Wp=e=>{if(`channel`in e)return e.channel;if(wn(e))return Wp(Gp(e));throw TypeError(`Expected a Stream.`)},Gp=e=>C(e,vn(w),Kp),Kp=e=>new jp(rp(Sn(e,{onFailure:_({onNone:()=>Md,onSome:Sd}),onSuccess:e=>V(ye(e))}))),qp=e=>Qp(e,e=>C(E(e,t=>w([t,e])),br(_({onNone:()=>j(v()),onSome:qn})))),Jp=x(2,(e,t)=>{let n=Dd({onInput:e=>z(V(Sp(e)),()=>n),onFailure:e=>V(Tp(e)),onDone:()=>V(wp)});return C(Td(Wp(e),n),qf(e=>zu(t,e)),Vf,Qf,Fr)}),Yp=e=>new jp(Hf($f(C(e,E(ye))),A)),Xp=e=>new jp(Ad(()=>Wp(e()))),Zp=x(e=>Mp(e[0]),(e,t)=>Or(Nr(t?.strategy===`unbounded`?Iu():t?.strategy===`dropping`?Pu(t.capacity??2):t?.strategy===`sliding`?Fu(t.capacity??2):Nu(t?.capacity??2),e=>Ru(e)),t=>fn(Jp(e,t)))),Qp=(e,t)=>Xp(()=>{let n=e=>rp(E(t(e),_({onNone:()=>Md,onSome:([e,t])=>z(V(e),()=>n(t))})));return new jp(n(e))}),$p=e=>Hp(Gp(e)),em=e=>Hp(Yp(e)),tm=z,nm=Md,rm=V,im=Bi,am=Hi,om=Ui,sm=Wi,cm=Gi,lm=Ki,um=Ji,dm=Yi,fm=Zi,pm=ea,mm=ia,hm=aa,gm=ca,_m=la,vm=ua,ym=ha;Ze(`effect/DateTime/CurrentTimeZone`)();const bm=Sa,xm=wa;var H=class{path;actual;issue;_tag=`Pointer`;constructor(e,t,n){this.path=e,this.actual=t,this.issue=n}},Sm=class{actual;message;_tag=`Unexpected`;constructor(e,t){this.actual=e,this.message=t}},Cm=class{ast;message;_tag=`Missing`;actual=void 0;constructor(e,t){this.ast=e,this.message=t}},U=class{ast;actual;issues;output;_tag=`Composite`;constructor(e,t,n,r){this.ast=e,this.actual=t,this.issues=n,this.output=r}},wm=class{ast;actual;kind;issue;_tag=`Refinement`;constructor(e,t,n,r){this.ast=e,this.actual=t,this.kind=n,this.issue=r}},Tm=class{ast;actual;kind;issue;_tag=`Transformation`;constructor(e,t,n,r){this.ast=e,this.actual=t,this.kind=n,this.issue=r}},W=class{ast;actual;message;_tag=`Type`;constructor(e,t,n){this.ast=e,this.actual=t,this.message=n}},Em=class{ast;actual;message;_tag=`Forbidden`;constructor(e,t,n){this.ast=e,this.actual=t,this.message=n}};const Dm=Symbol.for(`effect/Schema/ParseErrorTypeId`);var Om=class extends Ai(`ParseError`){[Dm]=Dm;get message(){return this.toString()}toString(){return dh.formatIssueSync(this.issue)}toJSON(){return{_id:`ParseError`,message:this.toString()}}[s](){return this.toJSON()}};const km=e=>new Om({issue:e}),G=b,Am=y,jm=n,Mm=o,Nm=Ie,Pm=x(2,(e,t)=>Nm(e)?Ge(e,{onLeft:y,onRight:t}):D(e,t)),Fm=x(2,(e,t)=>Nm(e)?It(e,t):E(e,t)),Im=x(2,(e,t)=>Nm(e)?Je(e,t):vn(e,t)),Lm=x(2,(e,t)=>Nm(e)?le(e,{onLeft:t.onFailure,onRight:t.onSuccess}):hn(e,t)),Rm=x(2,(e,t)=>Nm(e)?Ge(e,{onLeft:t,onRight:b}):br(e,t)),zm=(e,t)=>t===void 0||Vt(t)?e:e===void 0?t:{...e,...t},Bm=(e,t,n)=>{let r=K(e,t);return(e,t)=>r(e,zm(n,t))},Vm=(e,t,n)=>{let r=Bm(e,t,n);return(e,t)=>re(r(e,t),km)},Hm=(e,t,n)=>{let r=Bm(e,t,n);return(e,t)=>be(r(e,t))},Um=(e,t,n)=>{let r=K(e,t);return(e,t)=>r(e,{...zm(n,t),isEffectAllowed:!0})},Wm=(e,t)=>Vm(e.ast,!0,t),Gm=(e,t)=>Hm(e.ast,!0,t),Km=(e,t)=>Um(e.ast,!0,t),qm=(e,t)=>Um(e.ast,!1,t),Jm=Wm,Ym=(e,t)=>Vm(L(e.ast),!0,t),Xm=(e,t)=>{let n=K(L(e.ast),!0);return(e,r)=>te(n(e,{exact:!0,...zm(t,r)}))},Zm=st(Symbol.for(`effect/ParseResult/decodeMemoMap`),()=>new WeakMap),Qm=st(Symbol.for(`effect/ParseResult/encodeMemoMap`),()=>new WeakMap),K=(e,t)=>{let n=t?Zm:Qm,r=n.get(e);if(r)return r;let i=th(e,t),a=$s(e),o=bt(a)?(e,t)=>i(e,zm(t,a.value)):i,s=ec(e),c=t&&bt(s)?(t,n)=>oh(Rm(o(t,n),s.value),e,t,n):o;return n.set(e,c),c},$m=e=>f(Xs(e)),eh=e=>f(Zs(e)),th=(n,r)=>{switch(n._tag){case`Refinement`:if(r){let e=K(n.from,!0);return(t,r)=>{r??=Jc;let i=r?.errors===`all`,a=Pm(Rm(e(t,r),e=>{let a=new wm(n,t,`From`,e);return i&&rc(n)&&bh(e)?_(n.filter(t,r,n),{onNone:()=>y(a),onSome:e=>y(new U(n,t,[a,new wm(n,t,`Predicate`,e)]))}):y(a)}),e=>_(n.filter(e,r,n),{onNone:()=>b(e),onSome:e=>y(new wm(n,t,`Predicate`,e))}));return oh(a,n,t,r)}}else{let e=K(L(n),!0),t=K(ah(n.from),!1);return(r,i)=>oh(Pm(e(r,i),e=>t(e,i)),n,r,i)}case`Transformation`:{let e=lh(n.transformation,r),t=r?K(n.from,!0):K(n.to,!1),i=r?K(n.to,!0):K(n.from,!1);return(a,o)=>oh(Pm(Im(t(a,o),e=>new Tm(n,a,r?`Encoded`:`Type`,e)),t=>Pm(Im(e(t,o??Jc,n,a),e=>new Tm(n,a,`Transformation`,e)),e=>Im(i(e,o),e=>new Tm(n,a,r?`Type`:`Encoded`,e)))),n,a,o)}case`Declaration`:{let e=r?n.decodeUnknown(...n.typeParameters):n.encodeUnknown(...n.typeParameters);return(t,r)=>oh(e(t,r??Jc,n),n,t,r)}case`Literal`:return nh(n,e=>e===n.literal);case`UniqueSymbol`:return nh(n,e=>e===n.symbol);case`UndefinedKeyword`:return nh(n,Ht);case`NeverKeyword`:return nh(n,e);case`UnknownKeyword`:case`AnyKeyword`:case`VoidKeyword`:return b;case`StringKeyword`:return nh(n,Qe);case`NumberKeyword`:return nh(n,Vt);case`BooleanKeyword`:return nh(n,Ke);case`BigIntKeyword`:return nh(n,oe);case`SymbolKeyword`:return nh(n,At);case`ObjectKeyword`:return nh(n,Dt);case`Enums`:return nh(n,e=>n.enums.some(([t,n])=>n===e));case`TemplateLiteral`:{let e=sl(n);return nh(n,t=>Qe(t)&&e.test(t))}case`TupleType`:{let e=n.elements.map(e=>K(e.type,r)),i=n.rest.map(e=>K(e.type,r)),a=n.elements.filter(e=>!e.isOptional);n.rest.length>0&&(a=a.concat(n.rest.slice(1)));let o=a.length,s=n.elements.length>0?n.elements.map((e,t)=>t).join(` | `):`never`,c=$m(n),l=eh(n);return(r,u)=>{if(!Xe(r))return y(new W(n,r));let d=u?.errors===`all`,f=[],p=0,m=[],h=r.length;for(let e=h;e<=o-1;e++){let t=new H(e,r,new Cm(a[e-h]));if(d){f.push([p++,t]);continue}else return y(new U(n,r,t,m))}if(n.rest.length===0)for(let e=n.elements.length;e<=h-1;e++){let t=new H(e,r,new Sm(r[e],`is unexpected, expected: ${s}`));if(d){f.push([p++,t]);continue}else return y(new U(n,r,t,m))}let g=0,ee;for(;g<e.length;g++)if(h<g+1){if(n.elements[g].isOptional)continue}else{let t=e[g],i=t(r[g],u);if(Nm(i)){if(He(i)){let e=new H(g,r,i.left);if(d){f.push([p++,e]);continue}else return y(new U(n,r,e,ch(m)))}m.push([p++,i.right])}else{let e=p++,t=g;ee||=[],ee.push(({es:a,output:o})=>D(Sr(i),i=>{if(He(i)){let s=new H(t,r,i.left);return d?(a.push([e,s]),A):y(new U(n,r,s,ch(o)))}return o.push([e,i.right]),A}))}}if(t(i)){let[e,...t]=i;for(;g<h-t.length;g++){let t=e(r[g],u);if(Nm(t))if(He(t)){let e=new H(g,r,t.left);if(d){f.push([p++,e]);continue}else return y(new U(n,r,e,ch(m)))}else m.push([p++,t.right]);else{let e=p++,i=g;ee||=[],ee.push(({es:a,output:o})=>D(Sr(t),t=>{if(He(t)){let s=new H(i,r,t.left);return d?(a.push([e,s]),A):y(new U(n,r,s,ch(o)))}else return o.push([e,t.right]),A}))}}for(let e=0;e<t.length;e++){let i=g+e;if(!(h<i+1)){let a=t[e](r[i],u);if(Nm(a)){if(He(a)){let e=new H(i,r,a.left);if(d){f.push([p++,e]);continue}else return y(new U(n,r,e,ch(m)))}m.push([p++,a.right])}else{let e=p++;ee||=[],ee.push(({es:t,output:o})=>D(Sr(a),a=>{if(He(a)){let s=new H(i,r,a.left);return d?(t.push([e,s]),A):y(new U(n,r,s,ch(o)))}return o.push([e,a.right]),A}))}}}}let _=({es:e,output:t})=>Te(e)?y(new U(n,r,ch(e),ch(t))):b(ch(t));if(ee&&ee.length>0){let e=ee;return k(()=>{let t={es:tn(f),output:tn(m)};return D(on(e,e=>e(t),{concurrency:c,batching:l,discard:!0}),()=>_(t))})}return _({output:m,es:f})}}case`TypeLiteral`:{if(n.propertySignatures.length===0&&n.indexSignatures.length===0)return nh(n,ut);let e=[],t={},i=[];for(let a of n.propertySignatures)e.push([K(a.type,r),a]),t[a.name]=null,i.push(a.name);let a=n.indexSignatures.map(e=>[K(e.parameter,r),K(e.type,r),e.parameter]),o=Bc.make(n.indexSignatures.map(e=>e.parameter).concat(i.map(e=>At(e)?new dc(e):new lc(e)))),s=K(o,r),c=$m(n),l=eh(n);return(r,u)=>{if(!Rt(r))return y(new W(n,r));let d=u?.errors===`all`,f=[],p=0,m=u?.onExcessProperty===`error`,h=u?.onExcessProperty===`preserve`,g={},ee;if(m||h){ee=Reflect.ownKeys(r);for(let e of ee){let t=s(e,u);if(Nm(t)&&He(t))if(m){let t=new H(e,r,new Sm(r[e],`is unexpected, expected: ${String(o)}`));if(d){f.push([p++,t]);continue}else return y(new U(n,r,t,g))}else g[e]=r[e]}}let _,ne=u?.exact===!0;for(let t=0;t<e.length;t++){let i=e[t][1],a=i.name,o=Object.prototype.hasOwnProperty.call(r,a);if(!o){if(i.isOptional)continue;if(ne){let e=new H(a,r,new Cm(i));if(d){f.push([p++,e]);continue}else return y(new U(n,r,e,g))}}let s=e[t][0],c=s(r[a],u);if(Nm(c)){if(He(c)){let e=new H(a,r,o?c.left:new Cm(i));if(d){f.push([p++,e]);continue}else return y(new U(n,r,e,g))}g[a]=c.right}else{let e=p++,t=a;_||=[],_.push(({es:a,output:s})=>D(Sr(c),c=>{if(He(c)){let l=new H(t,r,o?c.left:new Cm(i));return d?(a.push([e,l]),A):y(new U(n,r,l,s))}return s[t]=c.right,A}))}}for(let e=0;e<a.length;e++){let i=a[e],o=i[0],s=i[1],c=Uo(r,i[2]);for(let e of c){let i=o(e,u);if(Nm(i)&&te(i)){let i=s(r[e],u);if(Nm(i))if(He(i)){let t=new H(e,r,i.left);if(d){f.push([p++,t]);continue}else return y(new U(n,r,t,g))}else Object.prototype.hasOwnProperty.call(t,e)||(g[e]=i.right);else{let a=p++,o=e;_||=[],_.push(({es:s,output:c})=>D(Sr(i),i=>{if(He(i)){let e=new H(o,r,i.left);return d?(s.push([a,e]),A):y(new U(n,r,e,c))}else return Object.prototype.hasOwnProperty.call(t,e)||(c[e]=i.right),A}))}}}}let re=({es:e,output:t})=>{if(Te(e))return y(new U(n,r,ch(e),t));if(u?.propertyOrder===`original`){let e=ee||Reflect.ownKeys(r);for(let t of i)e.indexOf(t)===-1&&e.push(t);let n={};for(let r of e)Object.prototype.hasOwnProperty.call(t,r)&&(n[r]=t[r]);return b(n)}return b(t)};if(_&&_.length>0){let e=_;return k(()=>{let t={es:tn(f),output:Object.assign({},g)};return D(on(e,e=>e(t),{concurrency:c,batching:l,discard:!0}),()=>re(t))})}return re({es:f,output:g})}}case`Union`:{let e=ih(n.types,r),t=Reflect.ownKeys(e.keys),i=t.length,a=n.types.length,o=new Map;for(let e=0;e<a;e++)o.set(n.types[e],K(n.types[e],r));let s=$m(n)??1,c=eh(n);return(r,l)=>{let u=[],d=0,f=[];if(i>0)if(gt(r))for(let n=0;n<i;n++){let i=t[n],o=e.keys[i].buckets;if(Object.prototype.hasOwnProperty.call(r,i)){let t=String(r[i]);if(Object.prototype.hasOwnProperty.call(o,t))f=f.concat(o[t]);else{let{candidates:t,literals:n}=e.keys[i],o=Bc.make(n),s=t.length===a?new Mc([new I(i,o,!1,!0)],[]):Bc.make(t);u.push([d++,new U(s,r,new H(i,r,new W(o,r[i])))])}}else{let{candidates:t,literals:n}=e.keys[i],o=new I(i,Bc.make(n),!1,!0),s=t.length===a?new Mc([o],[]):Bc.make(t);u.push([d++,new U(s,r,new H(i,r,new Cm(o)))])}}else{let t=e.candidates.length===a?n:Bc.make(e.candidates);u.push([d++,new W(t,r)])}e.otherwise.length>0&&(f=f.concat(e.otherwise));let p;for(let e=0;e<f.length;e++){let t=f[e],n=o.get(t)(r,l);if(Nm(n)&&(!p||p.length===0)){if(te(n))return n;u.push([d++,n.left])}else{let e=d++;p||=[],p.push(t=>k(()=>`finalResult`in t?A:D(Sr(n),n=>(te(n)?t.finalResult=n:t.es.push([e,n.left]),A))))}}let m=e=>Te(e)?e.length===1&&e[0][1]._tag===`Type`?y(e[0][1]):y(new U(n,r,ch(e))):y(new W(n,r));if(p&&p.length>0){let e=p;return k(()=>{let t={es:tn(u)};return D(on(e,e=>e(t),{concurrency:s,batching:c,discard:!0}),()=>`finalResult`in t?t.finalResult:m(t.es))})}return m(u)}}case`Suspend`:{let e=Wo(()=>K(n.f(),r));return(t,n)=>e()(t,n)}}},nh=(e,t)=>n=>t(n)?b(n):y(new W(e,n)),rh=(e,t)=>{switch(e._tag){case`Declaration`:{let n=tc(e);if(bt(n))return rh(n.value,t);break}case`TypeLiteral`:{let n=[];for(let r=0;r<e.propertySignatures.length;r++){let i=e.propertySignatures[r],a=t?hl(i.type):L(i.type);uc(a)&&!i.isOptional&&n.push([i.name,a])}return n}case`TupleType`:{let n=[];for(let r=0;r<e.elements.length;r++){let i=e.elements[r],a=t?hl(i.type):L(i.type);uc(a)&&!i.isOptional&&n.push([r,a])}return n}case`Refinement`:return rh(e.from,t);case`Suspend`:return rh(e.f(),t);case`Transformation`:return rh(t?e.from:e.to,t)}return[]},ih=(e,t)=>{let n={},r=[],i=[];for(let a=0;a<e.length;a++){let o=e[a],s=rh(o,t);if(s.length>0){i.push(o);for(let e=0;e<s.length;e++){let[t,r]=s[e],i=String(r.literal);n[t]=n[t]||{buckets:{},literals:[],candidates:[]};let a=n[t].buckets;if(Object.prototype.hasOwnProperty.call(a,i)){if(e<s.length-1)continue;a[i].push(o),n[t].literals.push(r),n[t].candidates.push(o)}else{a[i]=[o],n[t].literals.push(r),n[t].candidates.push(o);break}}}else r.push(o)}return{keys:n,otherwise:r,candidates:i}},ah=e=>qc(e)?ah(e.from):e,oh=(e,t,n,r)=>{if(r?.isEffectAllowed===!0||Nm(e))return e;let i=new lr,a=Gn(e,{scheduler:i});i.flush();let o=a.unsafePoll();if(o){if(pi(o))return b(o.value);let e=o.cause;return ai(e)?y(e.error):y(new Em(t,n,ri(e)))}return y(new Em(t,n,`cannot be be resolved synchronously, this is caused by using runSync on an effect that performs async work`))},sh=([e],[t])=>e>t?1:e<t?-1:0;function ch(e){return e.sort(sh).map(e=>e[1])}const lh=(e,t)=>{switch(e._tag){case`FinalTransformation`:return t?e.decode:e.encode;case`ComposeTransformation`:return b;case`TypeLiteralTransformation`:return n=>{let r=b(n);for(let n of e.propertySignatureTransformations){let[e,i]=t?[n.from,n.to]:[n.to,n.from],a=t?n.decode:n.encode;r=Fm(r,t=>{let n=a(Object.prototype.hasOwnProperty.call(t,e)?w(t[e]):v());return delete t[e],bt(n)&&(t[i]=n.value),t})}return r}}},uh=(e,t=[])=>({value:e,forest:t}),dh={formatIssue:e=>Fm(Mh(e),fh),formatIssueSync:e=>{let t=dh.formatIssue(e);return Nm(t)?ze(t):Wn(t)},formatError:e=>dh.formatIssue(e.issue),formatErrorSync:e=>dh.formatIssueSync(e.issue)},fh=e=>e.value+ph(`
15
+ `,e.forest),ph=(e,t)=>{let n=``,r=t.length,i;for(let a=0;a<r;a++){i=t[a];let o=a===r-1;n+=e+(o?`└`:`├`)+`─ `+i.value,n+=ph(e+(r>1&&!o?`│ `:` `),i.forest)}return n},mh=e=>{switch(e){case`Encoded`:return`Encoded side transformation failure`;case`Transformation`:return`Transformation process failure`;case`Type`:return`Type side transformation failure`}},hh=e=>{switch(e){case`From`:return`From side refinement failure`;case`Predicate`:return`Predicate refinement failure`}},gh=e=>`ast`in e?w(e.ast):v(),_h=b(void 0),vh=e=>gh(e).pipe(Zt(Ws),_({onNone:()=>_h,onSome:t=>{let n=t(e);return Qe(n)?b({message:n,override:!1}):wn(n)?E(n,e=>({message:e,override:!1})):Qe(n.message)?b({message:n.message,override:n.override}):E(n.message,e=>({message:e,override:n.override}))}})),yh=e=>t=>t._tag===e,bh=yh(`Composite`),xh=yh(`Refinement`),Sh=yh(`Transformation`),Ch=e=>Pm(vh(e),t=>t===void 0?_h:!t.override&&(bh(e)||xh(e)&&e.kind===`From`||Sh(e)&&e.kind!==`Transformation`)?Sh(e)||xh(e)?Ch(e.issue):_h:b(t.message)),wh=e=>gh(e).pipe(Zt(Qs),ke(t=>t(e)),f);function Th(e){return Ys(e).pipe(pe(()=>Ks(e)),pe(()=>qs(e)),pe(()=>Js(e)),Ne(()=>`{ ${e.from} | filter }`))}function Eh(e){return e.message===void 0?`Expected ${qc(e.ast)?Th(e.ast):String(e.ast)}, actual ${l(e.actual)}`:e.message}const Dh=e=>Fm(Ch(e),t=>t??wh(e)??Eh(e)),Oh=e=>wh(e)??String(e.ast),kh=e=>e.message??`is forbidden`,Ah=e=>e.message??`is unexpected`,jh=e=>{let t=Gs(e.ast);if(bt(t)){let e=t.value();return Qe(e)?b(e):e}return b(e.message??`is missing`)},Mh=e=>{switch(e._tag){case`Type`:return Fm(Dh(e),uh);case`Forbidden`:return b(uh(Oh(e),[uh(kh(e))]));case`Unexpected`:return b(uh(Ah(e)));case`Missing`:return Fm(jh(e),uh);case`Transformation`:return Pm(Ch(e),t=>t===void 0?Fm(Mh(e.issue),t=>uh(Oh(e),[uh(mh(e.kind),[t])])):b(uh(t)));case`Refinement`:return Pm(Ch(e),t=>t===void 0?Fm(Mh(e.issue),t=>uh(Oh(e),[uh(hh(e.kind),[t])])):b(uh(t)));case`Pointer`:return Fm(Mh(e.issue),t=>uh(Jo(e.path),[t]));case`Composite`:return Pm(Ch(e),t=>{if(t!==void 0)return b(uh(t));let n=Oh(e);return Go(e.issues)?Fm(on(e.issues,Mh),e=>uh(n,e)):Fm(Mh(e.issues),e=>uh(n,[e]))})}},Nh=x(e=>Dt(e[0]),(e,...t)=>{let n={};for(let r of t)r in e&&(n[r]=e[r]);return n}),Ph=x(e=>Dt(e[0]),(e,...t)=>{let n={...e};for(let e of t)delete n[e];return n}),Fh=Symbol.for(`effect/Schema`);function q(e){return class{[Fh]=Ih;static ast=e;static annotations(e){return q(zh(this.ast,e))}static pipe(){return De(this,arguments)}static toString(){return String(e)}static Type;static Encoded;static Context;static[Fh]=Ih}}const Ih={_A:e=>e,_I:e=>e,_R:e=>e},Lh={typeConstructor:bs,schemaId:Ss,message:Cs,missingMessage:ws,identifier:Ts,title:Es,description:Os,examples:ks,default:As,documentation:Fs,jsonSchema:js,arbitrary:Ms,pretty:Ns,equivalence:Ps,concurrency:Is,batching:Ls,parseIssueTitle:Rs,parseOptions:zs,decodingFallback:Bs},Rh=e=>{if(!e)return{};let t={...e};for(let n in Lh)if(n in e){let r=Lh[n];t[r]=e[n],delete t[n]}return t},zh=(e,t)=>rl(e,Rh(t)),Bh=e=>String(e.ast),Vh=e=>q(hl(e.ast)),Hh=e=>q(L(e.ast)),Uh=(e,t)=>{let n=Km(e,t);return(e,t)=>Im(n(e,t),km)},Wh=e=>Nt(e,Fh)&&Dt(e[Fh]);function Gh(e){return Hc(e)?Bc.make(Vc(e,e=>new lc(e))):new lc(e[0])}function Kh(e,t=Gh(e)){return class extends q(t){static annotations(e){return Kh(this.literals,zh(this.ast,e))}static literals=[...e]}}function qh(...e){return t(e)?Kh(e):tg}const Jh=(e,t,n)=>Xh(e,new sc(e.map(e=>e.ast),(...e)=>t.decode(...e.map(q)),(...e)=>t.encode(...e.map(q)),Rh(n))),Yh=(e,t)=>{let n=()=>(t,n,r)=>e(t)?G(t):Am(new W(r,t));return Xh([],new sc([],n,n,Rh(t)))};function Xh(e,t){return class extends q(t){static annotations(e){return Xh(this.typeParameters,zh(this.ast,e))}static typeParameters=[...e]}}const Zh=function(){if(Array.isArray(arguments[0])){let e=arguments[0],t=arguments[1],n=arguments[2];return Jh(e,t,n)}let e=arguments[0],t=arguments[1];return Yh(e,t)},Qh=Symbol.for(`effect/SchemaId/InstanceOf`),$h=(e,t)=>Zh(t=>t instanceof e,{title:e.name,description:`an instance of ${e.name}`,pretty:()=>String,schemaId:Qh,[Qh]:{constructor:e},...t});var eg=class extends q(fc){},tg=class extends q(pc){},ng=class extends q(mc){},rg=class extends q(Sc){},ig=class extends q(Cc){},J=class extends q(gc){},Y=class extends q(vc){},ag=class extends q(bc){};const og=e=>Bc.make(e.map(e=>e.ast));function sg(e,t=og(e)){return class extends q(t){static annotations(e){return sg(this.members,zh(this.ast,e))}static members=[...e]}}function cg(...e){return Hc(e)?sg(e):t(e)?e[0]:tg}const lg=e=>cg(e,eg),ug=e=>new dg(new Ec(e.ast,!1),e);var dg=class e{ast;from;[Fh];_Token;constructor(e,t){this.ast=e,this.from=t}annotations(t){return new e(new Ec(this.ast.type,this.ast.isOptional,{...this.ast.annotations,...Rh(t)}),this.from)}toString(){return`${this.ast.type}${this.ast.isOptional?`?`:``}`}};const fg=(e,t)=>new Oc(e.map(e=>Wh(e)?new Ec(e.ast,!1):e.ast),t.map(e=>Wh(e)?new Tc(e.ast):e.ast),!0);function pg(e,t,n=fg(e,t)){return class extends q(n){static annotations(e){return pg(this.elements,this.rest,zh(this.ast,e))}static elements=[...e];static rest=[...t]}}function mg(...e){return Array.isArray(e[0])?pg(e[0],e.slice(1)):pg(e,[])}function hg(e,t){return class extends pg([],[e],t){static annotations(e){return hg(this.value,zh(this.ast,e))}static value=e}}const gg=e=>hg(e),_g=e=>e?`"?:"`:`":"`;var vg=class extends Ec{isReadonly;defaultValue;_tag=`PropertySignatureDeclaration`;constructor(e,t,n,r,i){super(e,t,r),this.isReadonly=n,this.defaultValue=i}toString(){let e=_g(this.isOptional),t=String(this.type);return`PropertySignature<${e}, ${t}, never, ${e}, ${t}>`}};(class extends Ec{isReadonly;fromKey;constructor(e,t,n,r,i){super(e,t,r),this.isReadonly=n,this.fromKey=i}});var yg=class extends Ec{isReadonly;defaultValue;constructor(e,t,n,r,i){super(e,t,r),this.isReadonly=n,this.defaultValue=i}};const bg=e=>e===void 0?`never`:Qe(e)?JSON.stringify(e):String(e);var xg=class{from;to;decode;encode;_tag=`PropertySignatureTransformation`;constructor(e,t,n,r){this.from=e,this.to=t,this.decode=n,this.encode=r}toString(){return`PropertySignature<${_g(this.to.isOptional)}, ${this.to.type}, ${bg(this.from.fromKey)}, ${_g(this.from.isOptional)}, ${this.from.type}>`}};const Sg=(e,t)=>{switch(e._tag){case`PropertySignatureDeclaration`:return new vg(e.type,e.isOptional,e.isReadonly,{...e.annotations,...t},e.defaultValue);case`PropertySignatureTransformation`:return new xg(e.from,new yg(e.to.type,e.to.isOptional,e.to.isReadonly,{...e.to.annotations,...t},e.to.defaultValue),e.decode,e.encode)}},Cg=Symbol.for(`effect/PropertySignature`),wg=e=>Nt(e,Cg);var Tg=class e{ast;[Fh];[Cg]=null;_TypeToken;_Key;_EncodedToken;_HasDefault;constructor(e){this.ast=e}pipe(){return De(this,arguments)}annotations(t){return new e(Sg(this.ast,Rh(t)))}toString(){return String(this.ast)}};const Eg=e=>new Tg(e);var Dg=class e extends Tg{from;constructor(e,t){super(e),this.from=t}annotations(t){return new e(Sg(this.ast,Rh(t)),this.from)}};const Og=e=>new Dg(new vg(e.ast,!1,!0,{},void 0),e),kg=x(2,(e,t)=>{let n=e.ast;switch(n._tag){case`PropertySignatureDeclaration`:return Eg(new vg(n.type,n.isOptional,n.isReadonly,n.annotations,t));case`PropertySignatureTransformation`:return Eg(new xg(n.from,new yg(n.to.type,n.to.isOptional,n.to.isReadonly,n.to.annotations,t),n.decode,n.encode))}}),Ag=e=>new Dg(new vg(e.ast===fc||e.ast===pc?fc:lg(e).ast,!0,!0,{},void 0),e),jg=ll([ws]),Mg=(e,n)=>{let r=Reflect.ownKeys(e),i=[];if(r.length>0){let a=[],o=[],s=[];for(let t=0;t<r.length;t++){let n=r[t],c=e[n];if(wg(c)){let e=c.ast;switch(e._tag){case`PropertySignatureDeclaration`:{let t=e.type,r=e.isOptional,s=e.annotations;a.push(new I(n,t,r,!0,jg(e))),o.push(new I(n,L(t),r,!0,s)),i.push(new I(n,t,r,!0,s));break}case`PropertySignatureTransformation`:{let t=e.from.fromKey??n;a.push(new I(t,e.from.type,e.from.isOptional,!0,e.from.annotations)),o.push(new I(n,e.to.type,e.to.isOptional,!0,e.to.annotations)),s.push(new el(t,n,e.decode,e.encode));break}}}else a.push(new I(n,c.ast,!1,!0)),o.push(new I(n,L(c.ast),!1,!0)),i.push(new I(n,c.ast,!1,!0))}if(t(s)){let e=[],t=[];for(let r of n){let{indexSignatures:n,propertySignatures:i}=cl(r.key.ast,r.value.ast);i.forEach(e=>{a.push(e),o.push(new I(e.name,L(e.type),e.isOptional,e.isReadonly,e.annotations))}),n.forEach(n=>{e.push(n),t.push(new jc(n.parameter,L(n.type),n.isReadonly))})}return new Yc(new Mc(a,e,{[Ds]:`Struct (Encoded side)`}),new Mc(o,t,{[Ds]:`Struct (Type side)`}),new tl(s))}}let a=[];for(let e of n){let{indexSignatures:t,propertySignatures:n}=cl(e.key.ast,e.value.ast);n.forEach(e=>i.push(e)),t.forEach(e=>a.push(e))}return new Mc(i,a)},Ng=(e,t)=>{let n=Reflect.ownKeys(e);for(let r of n){let n=e[r];if(t[r]===void 0&&wg(n)){let e=n.ast,i=e._tag===`PropertySignatureDeclaration`?e.defaultValue:e.to.defaultValue;i!==void 0&&(t[r]=i())}}return t};function Pg(e,t,n=Mg(e,t)){return class extends q(n){static annotations(e){return Pg(this.fields,this.records,zh(this.ast,e))}static fields={...e};static records=[...t];static make=(t,n)=>{let r=Ng(e,{...t});return Zv(n)?r:Ym(this)(r)};static pick(...t){return X(Nh(e,...t))}static omit(...t){return X(Ph(e,...t))}}}function X(e,...t){return Pg(e,t)}const Fg=e=>qh(e).pipe(Og,kg(()=>e)),Ig=(e,t)=>X({_tag:Fg(e),...t});function Lg(e,t,n){return class extends Pg({},[{key:e,value:t}],n){static annotations(n){return Lg(e,t,zh(this.ast,n))}static key=e;static value=t}}const Rg=e=>Lg(e.key,e.value);function zg(e,t){return class extends q(t){static annotations(e){return zg(this.from,zh(this.ast,e))}static make=(e,t)=>Zv(t)?e:Ym(this)(e);static from=e}}const Bg=(e,t)=>n=>{let r=_(Us(n.ast),{onNone:()=>[e],onSome:t=>[...t,e]});return zg(n,rl(n.ast,Rh({[xs]:r,...t})))},Vg=(e,t,n)=>{if(Fc(e)&&Fc(t)){let r=[...e.propertySignatures];for(let e of t.propertySignatures){let t=e.name,i=r.findIndex(e=>e.name===t);if(i===-1)r.push(e);else{let{isOptional:a,type:o}=r[i];r[i]=new I(t,Wg(o,e.type,n.concat(t)),a,!0)}}return new Mc(r,e.indexSignatures.concat(t.indexSignatures))}throw Error(Zo(e,t,n))},Hg=ul([Ts]),Ug=(e,t)=>t.map(t=>new Kc(t,e.filter,Hg(e))),Wg=(e,t,n)=>Bc.make(Kg([e],[t],n)),Gg=e=>Uc(e)?e.types:[e],Kg=(e,t,n)=>Ve(e,e=>Ve(t,t=>{switch(t._tag){case`Literal`:if(Qe(t.literal)&&_c(e)||Vt(t.literal)&&yc(e)||Ke(t.literal)&&xc(e))return[t];break;case`StringKeyword`:if(t===gc){if(_c(e)||uc(e)&&Qe(e.literal))return[e];if(qc(e))return Ug(e,Kg(Gg(e.from),[t],n))}else if(e===gc)return[t];break;case`NumberKeyword`:if(t===vc){if(yc(e)||uc(e)&&Vt(e.literal))return[e];if(qc(e))return Ug(e,Kg(Gg(e.from),[t],n))}else if(e===vc)return[t];break;case`BooleanKeyword`:if(t===bc){if(xc(e)||uc(e)&&Ke(e.literal))return[e];if(qc(e))return Ug(e,Kg(Gg(e.from),[t],n))}else if(e===bc)return[t];break;case`Union`:return Kg(Gg(e),t.types,n);case`Suspend`:return[new Gc(()=>Wg(e,t.f(),n))];case`Refinement`:return Ug(t,Kg(Gg(e),Gg(t.from),n));case`TypeLiteral`:switch(e._tag){case`Union`:return Kg(e.types,[t],n);case`Suspend`:return[new Gc(()=>Wg(e.f(),t,n))];case`Refinement`:return Ug(e,Kg(Gg(e.from),[t],n));case`TypeLiteral`:return[Vg(e,t,n)];case`Transformation`:{let r=e.transformation,i=Vg(e.from,t,n),a=Vg(e.to,L(t),n);switch(r._tag){case`TypeLiteralTransformation`:return[new Yc(i,a,new tl(r.propertySignatureTransformations))];case`ComposeTransformation`:return[new Yc(i,a,$c)];case`FinalTransformation`:return[new Yc(i,a,new Zc((e,t,n,i)=>Fm(r.decode(e,t,n,i),t=>({...e,...t})),(e,t,n,i)=>Fm(r.encode(e,t,n,i),t=>({...e,...t}))))]}}}break;case`Transformation`:if(Xc(e)){if(nl(t.transformation)&&nl(e.transformation))return[new Yc(Vg(e.from,t.from,n),Vg(e.to,t.to,n),new tl(t.transformation.propertySignatureTransformations.concat(e.transformation.propertySignatureTransformations)))]}else return Kg([t],[e],n);break}throw Error(Zo(e,t,n))})),qg=x(2,(e,t)=>q(Wg(e.ast,t.ast,[]))),Jg=e=>q(new Gc(()=>e().ast)),Yg=Symbol.for(`effect/SchemaId/Refine`);function Xg(e,t,n){return class extends q(n){static annotations(e){return Xg(this.from,this.filter,zh(this.ast,e))}static[Yg]=e;static from=e;static filter=t;static make=(e,t)=>Zv(t)?e:Ym(this)(e)}}const Zg=(e,n,r)=>{if(Ke(e))return e?v():w(new W(n,r));if(Qe(e))return w(new W(n,r,e));if(e!==void 0){if(`_tag`in e)return w(e);let i=new W(n,r,e.message);return w(t(e.path)?new H(e.path,r,i):i)}return v()},Qg=(e,n,r)=>{if(Ko(e))return Zg(e,n,r);if(t(e)){let i=Fe(e,e=>Zg(e,n,r));if(t(i))return w(i.length===1?i[0]:new U(n,r,i))}return v()};function Z(e,t){return n=>{function r(t,n,r){return Qg(e(t,n,r),r,t)}return Xg(n,r,new Kc(n.ast,r,Rh(t)))}}function $g(e,t,n){return class extends q(n){static annotations(e){return $g(this.from,this.to,zh(this.ast,e))}static from=e;static to=t}}const Q=x(e=>Wh(e[0])&&Wh(e[1]),(e,t,n)=>$g(e,t,new Yc(e.ast,t.ast,new Zc(n.decode,n.encode)))),$=x(e=>Wh(e[0])&&Wh(e[1]),(e,t,n)=>Q(e,t,{strict:!0,decode:(e,t,r,i)=>G(n.decode(e,i)),encode:(e,t,r,i)=>G(n.encode(e,i))})),e_=x(2,(e,t)=>e.annotations(t)),t_=Symbol.for(`effect/SchemaId/Trimmed`),n_=e=>t=>t.pipe(Z(e=>e===e.trim(),{schemaId:t_,title:`trimmed`,description:`a string with no leading or trailing whitespace`,jsonSchema:{pattern:`^\\S[\\s\\S]*\\S$|^\\S$|^$`},...e})),r_=_s,i_=(e,t)=>n=>n.pipe(Z(t=>t.length>=e,{schemaId:r_,title:`minLength(${e})`,description:`a string at least ${e} character(s) long`,jsonSchema:{minLength:e},...t})),a_=vs,o_=(e,t)=>n=>{let r=Dt(e)?Math.max(0,Math.floor(e.min)):Math.max(0,Math.floor(e)),i=Dt(e)?Math.max(r,Math.floor(e.max)):r;return r===i?n.pipe(Z(e=>e.length===r,{schemaId:a_,title:`length(${r})`,description:r===1?`a single character`:`a string ${r} character(s) long`,jsonSchema:{minLength:r,maxLength:r},...t})):n.pipe(Z(e=>e.length>=r&&e.length<=i,{schemaId:a_,title:`length({ min: ${r}, max: ${i})`,description:`a string at least ${r} character(s) and at most ${i} character(s) long`,jsonSchema:{minLength:r,maxLength:i},...t}))},s_=Symbol.for(`effect/SchemaId/Pattern`),c_=(e,t)=>n=>{let r=e.source;return n.pipe(Z(t=>(e.lastIndex=0,e.test(t)),{schemaId:s_,[s_]:{regex:e},description:`a string matching the pattern ${r}`,jsonSchema:{pattern:r},...t}))},l_=Symbol.for(`effect/SchemaId/Lowercased`),u_=e=>t=>t.pipe(Z(e=>e===e.toLowerCase(),{schemaId:l_,title:`lowercased`,description:`a lowercase string`,jsonSchema:{pattern:`^[^A-Z]*$`},...e}));var d_=class extends J.pipe(u_({identifier:`Lowercased`})){};const f_=Symbol.for(`effect/SchemaId/Uppercased`),p_=e=>t=>t.pipe(Z(e=>e===e.toUpperCase(),{schemaId:f_,title:`uppercased`,description:`an uppercase string`,jsonSchema:{pattern:`^[^a-z]*$`},...e}));var m_=class extends J.pipe(p_({identifier:`Uppercased`})){};const h_=Symbol.for(`effect/SchemaId/Capitalized`),g_=e=>t=>t.pipe(Z(e=>e[0]?.toUpperCase()===e[0],{schemaId:h_,title:`capitalized`,description:`a capitalized string`,jsonSchema:{pattern:`^[^a-z]?.*$`},...e}));var __=class extends J.pipe(g_({identifier:`Capitalized`})){};const v_=Symbol.for(`effect/SchemaId/Uncapitalized`),y_=e=>t=>t.pipe(Z(e=>e[0]?.toLowerCase()===e[0],{schemaId:v_,title:`uncapitalized`,description:`a uncapitalized string`,jsonSchema:{pattern:`^[^A-Z]?.*$`},...e}));var b_=class extends J.pipe(y_({identifier:`Uncapitalized`})){};J.pipe(o_(1,{identifier:`Char`}));const x_=e=>i_(1,{title:`nonEmptyString`,description:`a non empty string`,...e});$(J.annotations({description:`a string that will be converted to lowercase`}),d_,{strict:!0,decode:e=>e.toLowerCase(),encode:S}).annotations({identifier:`Lowercase`}),$(J.annotations({description:`a string that will be converted to uppercase`}),m_,{strict:!0,decode:e=>e.toUpperCase(),encode:S}).annotations({identifier:`Uppercase`}),$(J.annotations({description:`a string that will be converted to a capitalized format`}),__,{strict:!0,decode:e=>Da(e),encode:S}).annotations({identifier:`Capitalize`}),$(J.annotations({description:`a string that will be converted to an uncapitalized format`}),b_,{strict:!0,decode:e=>Oa(e),encode:S}).annotations({identifier:`Uncapitalize`});var S_=class extends J.pipe(n_({identifier:`Trimmed`})){},C_=class extends S_.pipe(x_({identifier:`NonEmptyTrimmedString`})){};$(J.annotations({description:`a string that will be trimmed`}),S_,{strict:!0,decode:e=>e.trim(),encode:S}).annotations({identifier:`Trim`});const w_=e=>e instanceof Error?e.message:String(e);J.pipe(x_({identifier:`NonEmptyString`}));const T_=Symbol.for(`effect/SchemaId/UUID`),E_=/^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$/i;J.pipe(c_(E_,{schemaId:T_,identifier:`UUID`,jsonSchema:{format:`uuid`,pattern:E_.source},description:`a Universally Unique Identifier`,arbitrary:()=>e=>e.uuid()}));const D_=Symbol.for(`effect/SchemaId/ULID`);J.pipe(c_(/^[0-7][0-9A-HJKMNP-TV-Z]{25}$/i,{schemaId:D_,identifier:`ULID`,description:`a Universally Unique Lexicographically Sortable Identifier`,arbitrary:()=>e=>e.ulid()}));var O_=class extends $h(URL,{typeConstructor:{_tag:`URL`},identifier:`URLFromSelf`,arbitrary:()=>e=>e.webUrl().map(e=>new URL(e)),pretty:()=>e=>e.toString()}){};Q(J.annotations({description:`a string to be decoded into a URL`}),O_,{strict:!0,decode:(e,t,n)=>jm({try:()=>new URL(e),catch:t=>new W(n,e,`Unable to decode ${JSON.stringify(e)} into a URL. ${w_(t)}`)}),encode:e=>G(e.toString())}).annotations({identifier:`URL`,pretty:()=>e=>e.toString()});const k_=fs,A_=e=>t=>t.pipe(Z(Number.isFinite,{schemaId:k_,title:`finite`,description:`a finite number`,jsonSchema:{},...e})),j_=os,M_=(e,t)=>n=>n.pipe(Z(t=>t>e,{schemaId:j_,title:`greaterThan(${e})`,description:e===0?`a positive number`:`a number greater than ${e}`,jsonSchema:{exclusiveMinimum:e},...t})),N_=ss,P_=(e,t)=>n=>n.pipe(Z(t=>t>=e,{schemaId:N_,title:`greaterThanOrEqualTo(${e})`,description:e===0?`a non-negative number`:`a number greater than or equal to ${e}`,jsonSchema:{minimum:e},...t})),F_=us,I_=e=>t=>t.pipe(Z(e=>Number.isSafeInteger(e),{schemaId:F_,title:`int`,description:`an integer`,jsonSchema:{type:`integer`},...e})),L_=cs,R_=(e,t)=>n=>n.pipe(Z(t=>t<e,{schemaId:L_,title:`lessThan(${e})`,description:e===0?`a negative number`:`a number less than ${e}`,jsonSchema:{exclusiveMaximum:e},...t})),z_=ls,B_=(e,t)=>n=>n.pipe(Z(t=>t<=e,{schemaId:z_,title:`lessThanOrEqualTo(${e})`,description:e===0?`a non-positive number`:`a number less than or equal to ${e}`,jsonSchema:{maximum:e},...t})),V_=ms,H_=(e,t,n)=>r=>r.pipe(Z(n=>n>=e&&n<=t,{schemaId:V_,title:`between(${e}, ${t})`,description:`a number between ${e} and ${t}`,jsonSchema:{minimum:e,maximum:t},...n})),U_=ds,W_=e=>t=>t.pipe(Z(e=>!Number.isNaN(e),{schemaId:U_,title:`nonNaN`,description:`a number excluding NaN`,...e})),G_=e=>M_(0,{title:`positive`,...e}),K_=e=>R_(0,{title:`negative`,...e}),q_=e=>B_(0,{title:`nonPositive`,...e}),J_=e=>P_(0,{title:`nonNegative`,...e});function Y_(e){return Q(e,Y,{strict:!1,decode:(e,t,n)=>Mm(kn(e),()=>new W(n,e,`Unable to decode ${JSON.stringify(e)} into a number`)),encode:e=>G(String(e))})}Y_(J.annotations({description:`a string to be decoded into a number`})).annotations({identifier:`NumberFromString`}),Y.pipe(A_({identifier:`Finite`}));var X_=class extends Y.pipe(I_({identifier:`Int`})){};Y.pipe(W_({identifier:`NonNaN`})),Y.pipe(G_({identifier:`Positive`})),Y.pipe(K_({identifier:`Negative`})),Y.pipe(q_({identifier:`NonPositive`}));var Z_=class extends Y.pipe(J_({identifier:`NonNegative`})){};const Q_=ps;Y.pipe(A_({schemaId:Q_,identifier:`JsonNumber`})),$(ag.annotations({description:`a boolean that will be negated`}),ag,{strict:!0,decode:e=>zn(e),encode:e=>zn(e)});const $_=(e,t)=>{let n=Symbol.keyFor(e);return n===void 0?Am(new W(t,e,`Unable to encode a unique symbol ${String(e)} into a string`)):G(n)},ev=e=>G(Symbol.for(e));Q(J.annotations({description:`a string to be decoded into a globally shared symbol`}),ig,{strict:!1,decode:e=>ev(e),encode:(e,t,n)=>$_(e,n)}).annotations({identifier:`Symbol`});const tv=hs,nv=(e,t)=>n=>n.pipe(Z(t=>t>=e,{schemaId:tv,[tv]:{min:e},title:`greaterThanOrEqualToBigInt(${e})`,description:e===0n?`a non-negative bigint`:`a bigint greater than or equal to ${e}n`,...t})),rv=gs,iv=(e,t,n)=>r=>r.pipe(Z(n=>n>=e&&n<=t,{schemaId:rv,[rv]:{min:e,max:t},title:`betweenBigInt(${e}, ${t})`,description:`a bigint between ${e}n and ${t}n`,...n})),av=e=>nv(0n,{title:`nonNegativeBigInt`,...e});var ov=class extends Q(J.annotations({description:`a string to be decoded into a bigint`}),rg,{strict:!0,decode:(e,t,n)=>Mm(Wl(e),()=>new W(n,e,`Unable to decode ${JSON.stringify(e)} into a bigint`)),encode:e=>G(String(e))}).annotations({identifier:`BigInt`}){};const sv=rg.pipe(av({identifier:`NonNegativeBigintFromSelf`}));Q(Y.annotations({description:`a number to be decoded into a bigint`}),rg.pipe(iv(BigInt(-(2**53-1)),BigInt(2**53-1))),{strict:!0,decode:(e,t,n)=>Mm(Gl(e),()=>new W(n,e,`Unable to decode ${e} into a bigint`)),encode:(e,t,n)=>Mm(Ul(e),()=>new W(n,e,`Unable to encode ${e}n into a number`))}).annotations({identifier:`BigIntFromNumber`});const cv=(e,t,n,r)=>Lm(e,{onFailure:e=>new U(n,r,e),onSuccess:t});var lv=class extends Zh(se,{typeConstructor:{_tag:`effect/Duration`},identifier:`DurationFromSelf`,pretty:()=>String,arbitrary:()=>e=>e.oneof(e.constant(Pt),e.bigInt({min:0n}).map(e=>we(e)),e.maxSafeNat().map(e=>Ye(e))),equivalence:()=>Be}){};Q(sv.annotations({description:`a bigint to be decoded into a Duration`}),lv.pipe(Z(e=>qe(e),{description:`a finite duration`})),{strict:!0,decode:e=>G(we(e)),encode:(e,t,n)=>_(Bt(e),{onNone:()=>Am(new W(n,e,`Unable to encode ${e} into a bigint`)),onSome:e=>G(e)})}).annotations({identifier:`DurationFromNanos`});const uv=Z_.pipe(I_()).annotations({identifier:`NonNegativeInt`});$(Z_.annotations({description:`a non-negative number to be decoded into a Duration`}),lv,{strict:!0,decode:e=>Ye(e),encode:e=>lt(e)}).annotations({identifier:`DurationFromMillis`});const dv=Ig(`Millis`,{millis:uv}),fv=Ig(`Nanos`,{nanos:ov}),pv=Ig(`Infinity`,{}),mv=pv.make({}),hv=cg(dv,fv,pv).annotations({identifier:`DurationValue`,description:`an JSON-compatible tagged union to be decoded into a Duration`}),gv=cg(mg(ug(uv).annotations({title:`seconds`}),ug(uv).annotations({title:`nanos`})).annotations({identifier:`FiniteHRTime`}),mg(qh(-1),qh(0)).annotations({identifier:`InfiniteHRTime`})).annotations({identifier:`HRTime`,description:`a tuple of seconds and nanos to be decoded into a Duration`}),_v=e=>typeof e==`object`;$(cg(hv,gv),lv,{strict:!0,decode:e=>{if(_v(e))switch(e._tag){case`Millis`:return Ye(e.millis);case`Nanos`:return we(e.nanos);case`Infinity`:return Pt}let[t,n]=e;return t===-1?Pt:we(BigInt(t)*BigInt(1e9)+BigInt(n))},encode:e=>{switch(e.value._tag){case`Millis`:return dv.make({millis:e.value.millis});case`Nanos`:return fv.make({nanos:e.value.nanos});case`Infinity`:return mv}}}).annotations({identifier:`Duration`});var vv=class extends Zh(Et,{typeConstructor:{_tag:`Uint8Array`},identifier:`Uint8ArrayFromSelf`,pretty:()=>e=>`new Uint8Array(${JSON.stringify(Array.from(e))})`,arbitrary:()=>e=>e.uint8Array(),equivalence:()=>Ft(vt)}){};$(gg(class extends Y.pipe(H_(0,255,{identifier:`Uint8`,description:`a 8-bit unsigned integer`})){}).annotations({description:`an array of 8-bit unsigned integers to be decoded into a Uint8Array`}),vv,{strict:!0,decode:e=>Uint8Array.from(e),encode:e=>Array.from(e)}).annotations({identifier:`Uint8Array`});const yv=ys,bv=(e,t)=>n=>{let r=Math.floor(e);if(r<1)throw Error(Xo(`Expected an integer greater than or equal to 1, actual ${e}`));return n.pipe(Z(e=>e.length>=r,{schemaId:yv,title:`minItems(${r})`,description:`an array of at least ${r} item(s)`,jsonSchema:{minItems:r},[Hs]:!0,...t}))},xv=Symbol.for(`effect/SchemaId/ValidDate`),Sv=e=>t=>t.pipe(Z(e=>!Number.isNaN(e.getTime()),{schemaId:xv,[xv]:{noInvalidDate:!0},title:`validDate`,description:`a valid Date`,...e})),Cv=as;var wv=class extends Zh(Ue,{typeConstructor:{_tag:`Date`},identifier:`DateFromSelf`,schemaId:Cv,[Cv]:{noInvalidDate:!1},description:`a potentially invalid Date instance`,pretty:()=>e=>`new Date(${JSON.stringify(e)})`,arbitrary:()=>e=>e.date({noInvalidDate:!1}),equivalence:()=>dt}){};wv.pipe(Sv({identifier:`ValidDateFromSelf`,description:`a valid Date instance`})),class extends $(J.annotations({description:`a string to be decoded into a Date`}),wv,{strict:!0,decode:e=>new Date(e),encode:e=>Ae(e)}).annotations({identifier:`DateFromString`}){}.pipe(Sv({identifier:`Date`})),$(Y.annotations({description:`a number to be decoded into a Date`}),wv,{strict:!0,decode:e=>new Date(e),encode:e=>e.getTime()}).annotations({identifier:`DateFromNumber`});var Tv=class extends Zh(e=>im(e)&&sm(e),{typeConstructor:{_tag:`effect/DateTime.Utc`},identifier:`DateTimeUtcFromSelf`,description:`a DateTime.Utc instance`,pretty:()=>e=>e.toString(),arbitrary:()=>e=>e.date({noInvalidDate:!0}).map(e=>um(e)),equivalence:()=>lm}){};const Ev=(e,t)=>jm({try:()=>dm(e),catch:()=>new W(t,e,`Unable to decode ${l(e)} into a DateTime.Utc`)});Q(Y.annotations({description:`a number to be decoded into a DateTime.Utc`}),Tv,{strict:!0,decode:(e,t,n)=>Ev(e,n),encode:e=>G(ym(e))}).annotations({identifier:`DateTimeUtcFromNumber`}),Q(wv.annotations({description:`a Date to be decoded into a DateTime.Utc`}),Tv,{strict:!0,decode:(e,t,n)=>Ev(e,n),encode:e=>G(vm(e))}).annotations({identifier:`DateTimeUtcFromDate`}),Q(J.annotations({description:`a string to be decoded into a DateTime.Utc`}),Tv,{strict:!0,decode:(e,t,n)=>Ev(e,n),encode:e=>G(bm(e))}).annotations({identifier:`DateTimeUtc`});const Dv=()=>e=>e.integer({min:-720*60*1e3,max:840*60*1e3}).map(hm);var Ov=class extends Zh(am,{typeConstructor:{_tag:`effect/DateTime.TimeZone.Offset`},identifier:`TimeZoneOffsetFromSelf`,description:`a TimeZone.Offset instance`,pretty:()=>e=>e.toString(),arbitrary:Dv}){};$(Y.annotations({description:`a number to be decoded into a TimeZone.Offset`}),Ov,{strict:!0,decode:e=>hm(e),encode:e=>e.offset}).annotations({identifier:`TimeZoneOffset`});const kv=()=>e=>e.constantFrom(...Intl.supportedValuesOf(`timeZone`)).map(mm);var Av=class extends Zh(om,{typeConstructor:{_tag:`effect/DateTime.TimeZone.Named`},identifier:`TimeZoneNamedFromSelf`,description:`a TimeZone.Named instance`,pretty:()=>e=>e.toString(),arbitrary:kv}){};Q(J.annotations({description:`a string to be decoded into a TimeZone.Named`}),Av,{strict:!0,decode:(e,t,n)=>jm({try:()=>mm(e),catch:()=>new W(n,e,`Unable to decode ${JSON.stringify(e)} into a TimeZone.Named`)}),encode:e=>G(e.id)}).annotations({identifier:`TimeZoneNamed`});var jv=class extends cg(Ov,Av){};Q(J.annotations({description:`a string to be decoded into a TimeZone`}),jv,{strict:!0,decode:(e,t,n)=>_(gm(e),{onNone:()=>Am(new W(n,e,`Unable to decode ${JSON.stringify(e)} into a TimeZone`)),onSome:G}),encode:e=>G(_m(e))}).annotations({identifier:`TimeZone`});const Mv=e=>e.oneof(Dv()(e),kv()(e));var Nv=class extends Zh(e=>im(e)&&cm(e),{typeConstructor:{_tag:`effect/DateTime.Zoned`},identifier:`DateTimeZonedFromSelf`,description:`a DateTime.Zoned instance`,pretty:()=>e=>e.toString(),arbitrary:()=>e=>e.tuple(e.integer({min:-31536e9,max:31536e9}),Mv(e)).map(([e,t])=>fm(e,{timeZone:t})),equivalence:()=>lm}){};Q(J.annotations({description:`a string to be decoded into a DateTime.Zoned`}),Nv,{strict:!0,decode:(e,t,n)=>_(pm(e),{onNone:()=>Am(new W(n,e,`Unable to decode ${JSON.stringify(e)} into a DateTime.Zoned`)),onSome:G}),encode:e=>G(xm(e))}).annotations({identifier:`DateTimeZoned`});const Pv=e=>e._tag===`None`?v():w(e.value),Fv=(e,t)=>n=>n.oneof(t,n.record({_tag:n.constant(`None`)}),n.record({_tag:n.constant(`Some`),value:e(n)})).map(Pv),Iv=e=>_({onNone:()=>`none()`,onSome:t=>`some(${e(t)})`}),Lv=e=>(t,n,r)=>i(t)?wt(t)?G(v()):cv(e(t.value,n),w,r,t):Am(new W(r,t)),Rv=e=>Zh([e],{decode:e=>Lv(Km(e)),encode:e=>Lv(qm(e))},{typeConstructor:{_tag:`effect/Option`},pretty:Iv,arbitrary:Fv,equivalence:Yt});$(J,(e=>Rv(e).annotations({description:`Option<${Bh(e)}>`}))(C_),{strict:!0,decode:e=>nt(w(e.trim()),ka),encode:e=>Ne(e,()=>``)});const zv=()=>e=>`BigDecimal(${Rl(Al(e))})`,Bv=()=>e=>e.tuple(e.bigInt(),e.integer({min:-18,max:18})).map(([e,t])=>Tl(e,t));var Vv=class extends Zh(wl,{typeConstructor:{_tag:`effect/BigDecimal`},identifier:`BigDecimalFromSelf`,pretty:zv,arbitrary:Bv,equivalence:()=>Nl}){};Q(J.annotations({description:`a string to be decoded into a BigDecimal`}),Vv,{strict:!0,decode:(e,t,n)=>Ll(e).pipe(_({onNone:()=>Am(new W(n,e,`Unable to decode ${JSON.stringify(e)} into a BigDecimal`)),onSome:e=>G(Al(e))})),encode:e=>G(Rl(Al(e)))}).annotations({identifier:`BigDecimal`}),$(Y.annotations({description:`a number to be decoded into a BigDecimal`}),Vv,{strict:!0,decode:e=>Fl(e),encode:e=>Bl(e)}).annotations({identifier:`BigDecimalFromNumber`});const Hv=e=>Wh(e)||wg(e),Uv=e=>Reflect.ownKeys(e).every(t=>Hv(e[t])),Wv=e=>`fields`in e?e.fields:Wv(e[Yg]),Gv=e=>Uv(e)?X(e):Wh(e)?e:X(Wv(e)),Kv=e=>Uv(e)?e:Wv(e),qv=e=>kg(Og(qh(e)),()=>e),Jv=e=>(t,n,r)=>{let i=Kv(n),a=Gv(n),o={_tag:qv(t)},s=Xv(o,i);return class extends ey({kind:`TaggedClass`,identifier:e??t,schema:qg(a,X(o)),fields:s,Base:Oi,annotations:r}){static _tag=t}},Yv=e=>(t,n,r)=>{class i extends ki{}i.prototype.name=t;let a=Kv(n),o=Gv(n),s={_tag:qv(t)},c=Xv(s,a),u=`message`in c;class d extends ey({kind:`TaggedError`,identifier:e??t,schema:qg(o,X(s)),fields:c,Base:i,annotations:r,disableToString:!0}){static _tag=t}return u||Object.defineProperty(d.prototype,"message",{get(){return`{ ${Reflect.ownKeys(a).map(e=>`${p(e)}: ${l(this[e])}`).join(`, `)} }`},enumerable:!1,configurable:!0}),d},Xv=(e,t)=>{let n={...e};for(let r of Reflect.ownKeys(t)){if(r in e)throw Error(is(r));n[r]=t[r]}return n};function Zv(e){return Ke(e)?e:e?.disableValidation??!1}const Qv=st(`effect/Schema/astCache`,()=>new WeakMap),$v=e=>e===void 0?[]:Array.isArray(e)?e:[e],ey=({Base:e,annotations:t,disableToString:n,fields:r,identifier:i,kind:a,schema:o})=>{let s=Symbol.for(`effect/Schema/${a}/${i}`),[c,u,d]=$v(t),f=Hh(o),m=f.annotations({identifier:i,...c}),h=f.annotations({[Ds]:`${i} (Type side)`,...c}),g=o.annotations({[Ds]:`${i} (Constructor)`,...c}),ee=o.annotations({[Ds]:`${i} (Encoded side)`,...d}),_=o.annotations({...d,...c,...u}),te=e=>Nt(e,s)&&Xm(h)(e),ne=class extends e{constructor(e={},t=!1){e={...e},a!==`Class`&&delete e._tag,e=Ng(r,e),Zv(t)||(e=Ym(g)(e)),super(e,!0)}static[Fh]=Ih;static get ast(){let e=Qv.get(this);if(e)return e;let t=Zh([o],{decode:()=>(e,t,n)=>e instanceof this||te(e)?G(e):Am(new W(n,e)),encode:()=>(e,t)=>e instanceof this?G(e):Fm(qm(h)(e,t),e=>new this(e,!0))},{identifier:i,pretty:e=>t=>`${i}(${e(t)})`,arbitrary:e=>t=>e(t).map(e=>new this(e)),equivalence:S,[Vs]:m.ast,...c});return e=$(ee,t,{strict:!0,decode:e=>new this(e,!0),encode:S}).annotations({[Vs]:_.ast,...u}).ast,Qv.set(this,e),e}static pipe(){return De(this,arguments)}static annotations(e){return q(this.ast).annotations(e)}static toString(){return`(${String(ee)} <-> ${i})`}static make(...e){return new this(...e)}static fields={...r};static identifier=i;static extend(e){return(t,n)=>{let i=Kv(t),s=Gv(t),c=Xv(r,i);return ey({kind:a,identifier:e,schema:qg(o,s),fields:c,Base:this,annotations:n})}}static transformOrFail(e){return(t,n,i)=>{let s=Xv(r,t);return ey({kind:a,identifier:e,schema:Q(o,Hh(X(s)),n),fields:s,Base:this,annotations:i})}}static transformOrFailFrom(e){return(t,n,i)=>{let s=Xv(r,t);return ey({kind:a,identifier:e,schema:Q(Vh(o),X(s),n),fields:s,Base:this,annotations:i})}}get[s](){return s}};return n!==!0&&Object.defineProperty(ne.prototype,"toString",{value(){return`${i}({ ${Reflect.ownKeys(r).map(e=>`${p(e)}: ${l(this[e])}`).join(`, `)} })`},configurable:!0,writable:!0}),ne},ty=cg(X({_tag:qh(`None`)}).annotations({identifier:`FiberIdNoneEncoded`}),X({_tag:qh(`Runtime`),id:X_,startTimeMillis:X_}).annotations({identifier:`FiberIdRuntimeEncoded`}),X({_tag:qh(`Composite`),left:Jg(()=>ty),right:Jg(()=>ty)}).annotations({identifier:`FiberIdCompositeEncoded`})).annotations({identifier:`FiberIdEncoded`}),ny=e=>e.letrec(t=>({None:e.record({_tag:e.constant(`None`)}),Runtime:e.record({_tag:e.constant(`Runtime`),id:e.integer(),startTimeMillis:e.integer()}),Composite:e.record({_tag:e.constant(`Composite`),left:t(`FiberId`),right:t(`FiberId`)}),FiberId:e.oneof(t(`None`),t(`Runtime`),t(`Composite`))})).FiberId.map(ay),ry=e=>{switch(e._tag){case`None`:return`FiberId.none`;case`Runtime`:return`FiberId.runtime(${e.id}, ${e.startTimeMillis})`;case`Composite`:return`FiberId.composite(${ry(e.right)}, ${ry(e.left)})`}};var iy=class extends Zh(ge,{typeConstructor:{_tag:`effect/FiberId`},identifier:`FiberIdFromSelf`,pretty:()=>ry,arbitrary:()=>ny}){};const ay=e=>{switch(e._tag){case`None`:return xe;case`Runtime`:return g(e.id,e.startTimeMillis);case`Composite`:return me(ay(e.left),ay(e.right))}},oy=e=>{switch(e._tag){case`None`:return{_tag:`None`};case`Runtime`:return{_tag:`Runtime`,id:e.id,startTimeMillis:e.startTimeMillis};case`Composite`:return{_tag:`Composite`,left:oy(e.left),right:oy(e.right)}}};$(ty,iy,{strict:!0,decode:e=>ay(e),encode:e=>oy(e)}).annotations({identifier:`FiberId`});var sy=class extends $(ng,ng,{strict:!0,decode:e=>{if(Dt(e)&&`message`in e&&typeof e.message==`string`){let t=Error(e.message,{cause:e});return`name`in e&&typeof e.name==`string`&&(t.name=e.name),t.stack=`stack`in e&&typeof e.stack==`string`?e.stack:``,t}return Ot(e)},encode:e=>e instanceof Error?{name:e.name,message:e.message}:Ot(e)}).annotations({identifier:`Defect`}){};$(ng,ag,{strict:!0,decode:e=>it(e),encode:S}).annotations({identifier:`BooleanFromUnknown`}),$(qh(`true`,`false`).annotations({description:`a string to be decoded into a boolean`}),ag,{strict:!0,decode:e=>e===`true`,encode:e=>e?`true`:`false`}).annotations({identifier:`BooleanFromString`});const cy=Ig(`symbol`,{key:J}).annotations({description:`an object to be decoded into a globally shared symbol`}),ly=Q(cy,ig,{strict:!0,decode:e=>ev(e.key),encode:(e,t,n)=>Fm($_(e,n),e=>cy.make({key:e}))});var uy=class extends cg(J,Y,ly).annotations({identifier:`PropertyKey`}){};X({_tag:Og(qh(`Pointer`,`Unexpected`,`Missing`,`Composite`,`Refinement`,`Transformation`,`Type`,`Forbidden`)).annotations({description:`The tag identifying the type of parse issue`}),path:Og(gg(uy)).annotations({description:`The path to the property where the issue occurred`}),message:Og(J).annotations({description:`A descriptive message explaining the issue`})}).annotations({identifier:`ArrayFormatterIssue`,description:`Represents an issue returned by the ArrayFormatter formatter`});const dy=pp,fy=gp,py=Pp,my=Fp,hy=Up,gy=$p,_y=em,vy=Symbol.for(`@effect/platform/Error`),yy=qh(`Clipboard`,`Command`,`FileSystem`,`KeyValueStore`,`Path`,`Stream`,`Terminal`);var by=class extends Yv(`@effect/platform/Error/BadArgument`)(`BadArgument`,{module:yy,method:J,description:Ag(J),cause:Ag(sy)}){[vy]=vy;get message(){return`${this.module}.${this.method}${this.description?`: ${this.description}`:``}`}};const xy=qh(`AlreadyExists`,`BadResource`,`Busy`,`InvalidData`,`NotFound`,`PermissionDenied`,`TimedOut`,`UnexpectedEof`,`Unknown`,`WouldBlock`,`WriteZero`);var Sy=class extends Yv(`@effect/platform/Error/SystemError`)(`SystemError`,{reason:xy,module:yy,method:J,description:Ag(J),syscall:Ag(J),pathOrDescriptor:Ag(cg(J,Y)),cause:Ag(sy)}){[vy]=vy;get message(){return`${this.reason}: ${this.module}.${this.method}${this.pathOrDescriptor===void 0?``:` (${this.pathOrDescriptor})`}${this.description?`: ${this.description}`:``}`}};const Cy=Lt(`@effect/platform/FileSystem`),wy=e=>typeof e==`bigint`?e:BigInt(e),Ty=BigInt(1024);Ty*Ty*Ty*Ty*Ty;const Ey=e=>Cy.of({...e,exists:t=>C(e.access(t),Er(!0),rr(`SystemError`,e=>e.reason===`NotFound`?j(!1):qn(e))),readFileString:(t,n)=>nr(e.readFile(t),{try:e=>new TextDecoder(n).decode(e),catch:e=>new by({module:`FileSystem`,method:`readFileString`,description:`invalid encoding`,cause:e})}),stream:(t,n)=>C(e.open(t,{flag:`r`}),n?.offset?Or(e=>e.seek(n.offset,`start`)):S,E(e=>Dy(e,n)),_y),sink:(t,n)=>C(e.open(t,{flag:`w`,...n}),E(e=>dy(t=>e.writeAll(t))),fy),writeFileString:(t,n,r)=>D(Hr({try:()=>new TextEncoder().encode(n),catch:e=>new by({module:`FileSystem`,method:`writeFileString`,description:`could not encode string`,cause:e})}),n=>e.writeFile(t,n,r))}),Dy=(e,{bufferSize:t=16,bytesToRead:n,chunkSize:r=wy(64*1024)}={})=>{let i=n===void 0?void 0:wy(n),a=wy(r);function o(t){if(i!==void 0&&i<=t)return nm;let n=i!==void 0&&i-t<a?i-t:a;return tm(e.readAlloc(n),_({onNone:()=>nm,onSome:e=>tm(rm(ye(e)),n=>o(t+BigInt(e.length)))}))}return my(hy(o(BigInt(0))),{capacity:t})},Oy=wy,ky=Cy,Ay=Ey,jy=Symbol.for(`@effect/platform/FileSystem/File`),My=ql(),Ny=Di(`Create`),Py=Di(`Update`),Fy=Di(`Remove`);var Iy=class extends Ze(`@effect/platform/FileSystem/WatchBackend`)(){};const Ly=Symbol.for(`@effect/platform/Path`),Ry=Lt(`@effect/platform/Path`);function zy(e,t){let n=``,r=0,i=-1,a=0,o;for(let s=0;s<=e.length;++s){if(s<e.length)o=e.charCodeAt(s);else if(o===47)break;else o=47;if(o===47){if(i!==s-1&&a!==1)if(i!==s-1&&a===2){if(n.length<2||r!==2||n.charCodeAt(n.length-1)!==46||n.charCodeAt(n.length-2)!==46){if(n.length>2){let e=n.lastIndexOf(`/`);if(e!==n.length-1){e===-1?(n=``,r=0):(n=n.slice(0,e),r=n.length-1-n.lastIndexOf(`/`)),i=s,a=0;continue}}else if(n.length===2||n.length===1){n=``,r=0,i=s,a=0;continue}}t&&(n.length>0?n+=`/..`:n=`..`,r=2)}else n.length>0?n+=`/`+e.slice(i+1,s):n=e.slice(i+1,s),r=s-i-1;i=s,a=0}else o===46&&a!==-1?++a:a=-1}return n}function By(e,t){let n=t.dir||t.root,r=t.base||(t.name||``)+(t.ext||``);return n?n===t.root?n+r:n+e+r:r}function Vy(e){if(e.protocol!==`file:`)return qn(new by({module:`Path`,method:`fromFileUrl`,description:`URL must be of scheme file`}));if(e.hostname!==``)return qn(new by({module:`Path`,method:`fromFileUrl`,description:`Invalid file URL host`}));let t=e.pathname;for(let e=0;e<t.length;e++)if(t[e]===`%`){let n=t.codePointAt(e+2)|32;if(t[e+1]===`2`&&n===102)return qn(new by({module:`Path`,method:`fromFileUrl`,description:`must not include encoded / characters`}))}return j(decodeURIComponent(t))}const Hy=function(){let e=``,t=!1,n;for(let r=arguments.length-1;r>=-1&&!t;r--){let i;if(r>=0)i=arguments[r];else{let e=globalThis.process;n===void 0&&`process`in globalThis&&typeof e==`object`&&e&&typeof e.cwd==`function`&&(n=e.cwd()),i=n}i.length!==0&&(e=i+`/`+e,t=i.charCodeAt(0)===47)}return e=zy(e,!t),t?e.length>0?`/`+e:`/`:e.length>0?e:`.`};function Uy(e){let t=new URL(`file://`),n=Hy(e);return e.charCodeAt(e.length-1)===47&&n[n.length-1]!==`/`&&(n+=`/`),t.pathname=Yy(n),j(t)}const Wy=/%/g,Gy=/\\/g,Ky=/\n/g,qy=/\r/g,Jy=/\t/g;function Yy(e){return e.includes(`%`)&&(e=e.replace(Wy,`%25`)),e.includes(`\\`)&&(e=e.replace(Gy,`%5C`)),e.includes(`
16
+ `)&&(e=e.replace(Ky,`%0A`)),e.includes(`\r`)&&(e=e.replace(qy,`%0D`)),e.includes(` `)&&(e=e.replace(Jy,`%09`)),e}const Xy=Ry.of({[Ly]:Ly,resolve:Hy,normalize(e){if(e.length===0)return`.`;let t=e.charCodeAt(0)===47,n=e.charCodeAt(e.length-1)===47;return e=zy(e,!t),e.length===0&&!t&&(e=`.`),e.length>0&&n&&(e+=`/`),t?`/`+e:e},isAbsolute(e){return e.length>0&&e.charCodeAt(0)===47},join(){if(arguments.length===0)return`.`;let e;for(let t=0;t<arguments.length;++t){let n=arguments[t];n.length>0&&(e===void 0?e=n:e+=`/`+n)}return e===void 0?`.`:Xy.normalize(e)},relative(e,t){if(e===t||(e=Xy.resolve(e),t=Xy.resolve(t),e===t))return``;let n=1;for(;n<e.length&&e.charCodeAt(n)===47;++n);let r=e.length,i=r-n,a=1;for(;a<t.length&&t.charCodeAt(a)===47;++a);let o=t.length-a,s=i<o?i:o,c=-1,l=0;for(;l<=s;++l){if(l===s){if(o>s){if(t.charCodeAt(a+l)===47)return t.slice(a+l+1);if(l===0)return t.slice(a+l)}else i>s&&(e.charCodeAt(n+l)===47?c=l:l===0&&(c=0));break}let r=e.charCodeAt(n+l);if(r!==t.charCodeAt(a+l))break;r===47&&(c=l)}let u=``;for(l=n+c+1;l<=r;++l)(l===r||e.charCodeAt(l)===47)&&(u.length===0?u+=`..`:u+=`/..`);return u.length>0?u+t.slice(a+c):(a+=c,t.charCodeAt(a)===47&&++a,t.slice(a))},dirname(e){if(e.length===0)return`.`;let t=e.charCodeAt(0),n=t===47,r=-1,i=!0;for(let n=e.length-1;n>=1;--n)if(t=e.charCodeAt(n),t===47){if(!i){r=n;break}}else i=!1;return r===-1?n?`/`:`.`:n&&r===1?`//`:e.slice(0,r)},basename(e,t){let n=0,r=-1,i=!0,a;if(t!==void 0&&t.length>0&&t.length<=e.length){if(t.length===e.length&&t===e)return``;let o=t.length-1,s=-1;for(a=e.length-1;a>=0;--a){let c=e.charCodeAt(a);if(c===47){if(!i){n=a+1;break}}else s===-1&&(i=!1,s=a+1),o>=0&&(c===t.charCodeAt(o)?--o===-1&&(r=a):(o=-1,r=s))}return n===r?r=s:r===-1&&(r=e.length),e.slice(n,r)}else{for(a=e.length-1;a>=0;--a)if(e.charCodeAt(a)===47){if(!i){n=a+1;break}}else r===-1&&(i=!1,r=a+1);return r===-1?``:e.slice(n,r)}},extname(e){let t=-1,n=0,r=-1,i=!0,a=0;for(let o=e.length-1;o>=0;--o){let s=e.charCodeAt(o);if(s===47){if(!i){n=o+1;break}continue}r===-1&&(i=!1,r=o+1),s===46?t===-1?t=o:a!==1&&(a=1):t!==-1&&(a=-1)}return t===-1||r===-1||a===0||a===1&&t===r-1&&t===n+1?``:e.slice(t,r)},format:function(e){if(typeof e!=`object`||!e)throw TypeError(`The "pathObject" argument must be of type Object. Received type `+typeof e);return By(`/`,e)},parse(e){let t={root:``,dir:``,base:``,ext:``,name:``};if(e.length===0)return t;let n=e.charCodeAt(0),r=n===47,i;r?(t.root=`/`,i=1):i=0;let a=-1,o=0,s=-1,c=!0,l=e.length-1,u=0;for(;l>=i;--l){if(n=e.charCodeAt(l),n===47){if(!c){o=l+1;break}continue}s===-1&&(c=!1,s=l+1),n===46?a===-1?a=l:u!==1&&(u=1):a!==-1&&(u=-1)}return a===-1||s===-1||u===0||u===1&&a===s-1&&a===o+1?s!==-1&&(o===0&&r?t.base=t.name=e.slice(1,s):t.base=t.name=e.slice(o,s)):(o===0&&r?(t.name=e.slice(1,a),t.base=e.slice(1,s)):(t.name=e.slice(o,a),t.base=e.slice(o,s)),t.ext=e.slice(a,s)),o>0?t.dir=e.slice(0,o-1):r&&(t.dir=`/`),t},sep:`/`,fromFileUrl:Vy,toFileUrl:Uy,toNamespacedPath:S}),Zy=Xl(Ry,Xy),Qy=Ry,$y=Zy,eb=Rg({key:J,value:gg(J)}).pipe(Bg(`TomlConfig`));Q(J,Hh(eb),{strict:!0,decode:e=>jm({try:()=>Ho(e),catch:e=>new Sm(e,`TOML parse error`)}).pipe(Pm(e=>Km(eb)(e))),encode:(e,t,n)=>Am(new Em(n,e,`TomlConfigFromText is decode-only`))});const tb=`systemfsoftware.toml`,nb=Jm(eb)({});var rb=class extends Ze(`@systemfsoftware/omp-utils/toml-loader.adapter/TomlLoader`)(){};const ib=e=>{let t={};for(let n of e)for(let[e,r]of Object.entries(n))t[e]=r;return t},ab=e=>jm({try:()=>Ho(e),catch:e=>new Sm(e,`TOML parse error`)}).pipe(Pm(e=>Km(eb)(e))),ob=(e,t,n)=>e.exists(n).pipe(D(t=>t?e.readFileString(n).pipe(D(ab),Vn(()=>nb)):j(nb))),sb=Jl(rb,D(Qn(()=>{let e=process.env.OMP_USER_CONFIG_HOME;return typeof e==`string`&&e.length>0?e:Ti.homedir()}),e=>ln(function*(){let t=yield*Wr(Ar()),n=yield*ky,r=yield*Qy,i=r.join(e,`.config/systemfsoftware`,tb);return rb.of({load:Fn(`TomlLoader.load`)(function*(e){let a=Cr(yield*Jn(t),e);if(bt(a))return a.value;let o=r.join(e,tb),s=r.join(e,`systemfsoftware.local.toml`),c=yield*ob(n,r,i),l=yield*ob(n,r,o),u=yield*ob(n,r,s),d=yield*Uh(eb)(ib([c,l,u])).pipe(_n);return yield*Jr(t,t=>(fr(t,e,d),t)),d})})})));Xm(gg(X({old_text:Ag(ng),new_text:Ag(ng)}).pipe(Z(e=>`old_text`in e||`new_text`in e))).pipe(bv(1))),Xm(gg(X({old_string:Ag(ng),new_string:Ag(ng)}).pipe(Z(e=>`old_string`in e||`new_string`in e)))),Gm(Rg({key:J,value:ng}));export{Jv as C,Yl as D,Jl as E,Zl as O,X as S,e_ as T,gg as _,ky as a,Rg as b,Iy as c,Py as d,Ay as f,gy as g,py as h,My as i,Ny as l,Sy as m,sb as n,jy as o,by as p,$y as r,Oy as s,rb as t,Fy as u,ag as v,cg as w,J as x,qh as y};
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- const e=(e,t)=>{e(e=>{e.setTimeout(()=>{t()},0)});let n=()=>{t().then(({default:e})=>e.dispose())};process.on(`SIGINT`,n),process.on(`SIGTERM`,n)};async function t(t){let{DispatchDoctrineExtension:n}=await import(`./dispatch-doctrine.handler-NRKrXs4u.js`);n(t);let{NoSkillDelegationExtension:r}=await import(`./no-skill-delegation.handler-nw3V3mgg.js`);r(t);let{XdRetryGuardExtension:i}=await import(`./xd-retry-guard.middleware-CY-8-JSN.js`);i(t),e(e=>t.on(`session_start`,(t,n)=>e(n)),()=>import(`./runtime.kernel-DDie4TJ9.js`))}export{t as default};
1
+ const e=(e,t)=>{e(e=>{e.setTimeout(()=>{t()},0)});let n=()=>{t().then(({default:e})=>e.dispose())};process.on(`SIGINT`,n),process.on(`SIGTERM`,n)},t=async e=>{let[t,n,r,i]=await Promise.all([import(`./runtime.kernel-CRPIbSEi.js`).then(e=>e.default),import(`./Cause-CTmrUQgG.js`).then(e=>e.t),import(`./Effect-BnMIG7Ln.js`).then(e=>e.t),import(`./Exit-Dq5mS6lc.js`).then(e=>e.t)]),a=e.pipe(r.exit),o=await t.runPromise(a);if(i.isFailure(o))throw n.squash(o.cause);return o.value};async function n(n){let{DispatchDoctrineExtension:r}=await import(`./dispatch-doctrine.handler-DJbzbddE.js`);r(n,t);let{NoSkillDelegationExtension:i}=await import(`./no-skill-delegation.handler-43h7y77U.js`);i(n,t);let{XdRetryGuardExtension:a}=await import(`./xd-retry-guard.middleware-CY-8-JSN.js`);a(n),e(e=>n.on(`session_start`,(t,n)=>e(n)),()=>import(`./runtime.kernel-CRPIbSEi.js`))}export{n as default};
@@ -1,2 +1,2 @@
1
- import{Cs as e,Ms as t,Ps as n,Ws as r,aa as i}from"./core-CwsVf2Ey.js";import{D as a,W as o,m as s}from"./Effect-B34dlqAS.js";import{C as c,S as ee,T as l,_ as u,b as te,t as d,w as f,x as p,y as m}from"./dist-48FGb8Hs.js";import{a as h,i as g,n as _,r as v,t as y}from"./Match-COXzoyjd.js";var b=class extends i(`NoSkillDelegationExecutorDeps`)(){};const x=m(`subagent_type`,`prompt`),S=Symbol.for(`@systemfsoftware/omp-agent-discipline/DelegationVerdict`);var C=class extends c()(`Allow`,{}){[S]=S},w=class extends c()(`Block`,{reason:p,how:x,skill:p}){[S]=S};f(C,w);const T=ee({protectedSkills:u(p),delegationVerbs:u(p),referenceVerbs:u(p),mentionPatterns:te({key:p,value:p})}).pipe(l({arbitrary:()=>e=>e.constant({protectedSkills:[`ce-work`],delegationVerbs:["\\binvoke\\s+(?:the\\s+)?[`/]?ce-work\\b","\\bdispatch\\s+(?:to\\s+)?(?:the\\s+)?[`/]?ce-work\\b","\\buse\\s+(?:the\\s+)?[`/]?ce-work\\b","\\bspawn\\s+(?:a\\s+)?(?:task|agent|subagent|worker)\\s+(?:with|using)\\s+(?:the\\s+)?[`/]?ce-work\\b","\\bcall\\s+(?:the\\s+)?[`/]?ce-work\\b","\\brun\\s+(?:the\\s+)?[`/]?ce-work\\b"],referenceVerbs:["\\bsee\\s+(?:the\\s+)?[`/]?ce-work\\b","\\bread\\s+(?:the\\s+)?[`/]?ce-work\\b"],mentionPatterns:{"ce-work":'(?:^|[\\s/.`"])ce-work(?=$|[\\s/.`"]|\\b)'}})})),E=f(T,m(null)),D=Symbol.for(`@systemfsoftware/omp-agent-discipline/CheckDelegationCommand`);var ne=class extends c()(`CheckDelegationCommand`,{toolName:p,subagentType:p,prompt:p,guard:E}){[D]=D};const O=Symbol.for(`@systemfsoftware/omp-agent-discipline/ClassifiedInput`);var k=class extends c()(`NoGuard`,{}){[O]=O},A=class extends c()(`NonDelegatedTool`,{}){[O]=O},j=class extends c()(`ProtectedSubagent`,{skill:p}){[O]=O},M=class extends c()(`EmptyPrompt`,{}){[O]=O},N=class extends c()(`Prompted`,{guard:T,prompt:p}){[O]=O};f(k,A,j,M,N);const P=Symbol.for(`@systemfsoftware/omp-agent-discipline/PromptAnalysis`);var F=class extends c()(`Delegated`,{skill:p,excerpt:p}){[P]=P},I=class extends c()(`Referenced`,{}){[P]=P},L=class extends c()(`NoDelegation`,{}){[P]=P};f(F,I,L);function R(e,t,n){return[`⛔ BLOCKED: "`+e+`" must not be delegated to a subagent.`,`Detected in `+t+`: `+n,``,`REQUIRED: invoke `+e+` directly in THIS session via the host Skill / Tool call,`,`then pass its return envelope to the next step. Do NOT wrap it in a task / Agent dispatch.`,``,`WHY: a subagent reproduces the shape but loses the skill protocol — plan-path gate,`,`headless review contract, and pipeline-vs-chat mode. The contract does not survive the hop.`,``,`RULE: root AGENTS.md §"Skill invocations" (SK1/SK2).`].join(`
2
- `)}function z(e,t){return new RegExp(e,`i`).test(t)}function B(e,t){return e.map(e=>new RegExp(e,`i`).exec(t)).find(e=>e!==null)??null}const V=e=>t(e=>e!==``)(e),H=(e,t)=>g(V(e.prompt)).pipe(v(`Some`,({value:e})=>new N({guard:t,prompt:e})),v(`None`,()=>new M),y),U=(e,n)=>t(e=>e!==``&&n.protectedSkills.includes(e))(e.subagentType),W=(e,t)=>g(U(e,t)).pipe(v(`Some`,({value:e})=>new j({skill:e})),v(`None`,()=>H(e,t)),y),G=t=>e(t.guard),K=(e,r)=>t(e=>e===`task`||e===`agent`)(e.toolName.toLowerCase()).pipe(n(()=>W(e,r))),q=e=>g(G(e)).pipe(v(`None`,()=>new k),v(`Some`,({value:t})=>g(K(e,t)).pipe(v(`None`,()=>new A),v(`Some`,({value:e})=>e),y)),y),J=(e,n)=>{let r=Object.entries(e.mentionPatterns).filter(([,e])=>z(e,n)).map(([e])=>e);return t(e=>e.length>0)(r)},Y=(e,t)=>g(J(e,t)).pipe(v(`None`,()=>new L),v(`Some`,({value:n})=>{let r=n[0];return g({hasReference:e.referenceVerbs.some(e=>z(e,t)),hasDelegation:e.delegationVerbs.some(e=>z(e,t))}).pipe(h({hasReference:!0},()=>new I),h({hasDelegation:!1},()=>new L),_(()=>{let n=B(e.delegationVerbs,t),i=n===null?t.slice(0,120):n[0];return new F({skill:r,excerpt:i})}))}),y),X=e=>g(q(e)).pipe(v(`NoGuard`,()=>new C),v(`NonDelegatedTool`,()=>new C),v(`ProtectedSubagent`,({skill:e})=>new w({reason:R(e,`subagent_type`,e),how:`subagent_type`,skill:e})),v(`EmptyPrompt`,()=>new C),v(`Prompted`,({guard:e,prompt:t})=>g(Y(e,t)).pipe(v(`Delegated`,({skill:e,excerpt:t})=>new w({reason:R(e,`prompt`,t),how:`prompt`,skill:e})),v(`Referenced`,()=>new C),v(`NoDelegation`,()=>new C),y)),y);function Z(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}function re(e){if(e.length===0)return null;let t=`(?:`+e.map(Z).join(`|`)+`)`;return{protectedSkills:e.slice(),delegationVerbs:["\\binvoke\\s+(?:the\\s+)?[`/]?"+t+`\\b`,"\\bdispatch\\s+(?:to\\s+)?(?:the\\s+)?[`/]?"+t+`\\b`,"\\bwrap\\s+(?:the\\s+)?[`/]?"+t+`\\s+in\\s+(?:a\\s+)?(?:task|agent|subagent)\\b`,"\\bdelegate\\s+(?:the\\s+)?[`/]?"+t+`\\b`,"\\brun\\s+(?:the\\s+)?[`/]?"+t+`\\s+(?:via|in)\\s+(?:a\\s+)?(?:subagent|task|agent)\\b`,"\\b(?:run|execute|launch)\\s+(?:the\\s+)?[`/]?"+t+`\\b`,"\\bskill:\\s*[`/]?"+t+`\\b`,`\\bskill:\\/\\/`+t+`\\b`,`(?:^|\\W)/`+t+`(?=$|\\b|\\W)`,"\\buse\\s+(?:the\\s+)?[`/]?"+t+`\\b`,"\\bload\\s+(?:the\\s+)?[`/]?"+t+`\\b`,"\\bspawn\\s+(?:a\\s+)?(?:task|agent|subagent|worker)\\s+(?:with|using)\\s+(?:the\\s+)?[`/]?"+t+`\\b`,"\\bcall\\s+(?:the\\s+)?[`/]?"+t+`\\b`,"\\bsend\\s+(?:the\\s+)?[`/]?"+t+`\\b`,"\\bcreate\\s+(?:a\\s+)?(?:task|agent|subagent)\\s+(?:with|using)\\s+(?:the\\s+)?[`/]?"+t+`\\b`,"\\bstart\\s+(?:the\\s+)?[`/]?"+t+`\\b`],referenceVerbs:["\\bsee\\s+(?:the\\s+)?[`/]?"+t+`\\b`,"\\bper\\s+(?:the\\s+)?[`/]?"+t+`\\b`,"\\bread\\s+(?:the\\s+)?[`/]?"+t+`\\b`,"\\baccording\\s+to\\s+(?:the\\s+)?[`/]?"+t+`\\b`],mentionPatterns:Object.fromEntries(e.map(e=>[e,'(?:^|[\\s/.`"])'+Z(e)+'(?=$|[\\s/.`"]|\\b)']))}}function Q(e){return g(e).pipe(v(`Block`,e=>({block:!0,reason:e.reason,how:e.how,skill:e.skill})),v(`Allow`,()=>void 0),y)}function ie(e){return a(function*(){return re((yield*(yield*b).load(e)).no_delegate_skills??[])})}function ae(e,t,n,r){return a(function*(){let i=new ne({toolName:t,subagentType:n,prompt:r,guard:yield*ie(e)});return Q(X(i))})}const oe=o(b,a(function*(){return yield*d})),se=e=>typeof e==`object`&&!!e&&!Array.isArray(e),ce=e=>se(e)?e:{};function $(e,...t){for(let n of t){let t=e[n];if(typeof t==`string`&&t.length>0)return t}return``}const le=e=>{e.on(`tool_call`,async(e,t)=>{let{runSafe:n}=await import(`./run-safe.policy-CuLHWxRa.js`),i=ce(e.input),a=$(i,`subagent_type`,`agent`),o=$(i,`prompt`,`task`,`description`),c=await n(s(ae(t.cwd,e.toolName,a,o)).pipe(oe));if(r(c))throw c.left;return c.right})};export{le as NoSkillDelegationExtension};
1
+ import{Cs as e,Ms as t,Ps as n,Ws as r,aa as i}from"./core-CwsVf2Ey.js";import{D as a,G as o,m as s}from"./Effect-BnMIG7Ln.js";import{C as c,S as ee,T as l,_ as u,b as te,t as d,w as f,x as p,y as m}from"./dist-DNAOOlxn.js";import{a as h,i as g,n as _,r as v,t as y}from"./Match-COXzoyjd.js";var b=class extends i(`NoSkillDelegationExecutorDeps`)(){};const x=m(`subagent_type`,`prompt`),S=Symbol.for(`@systemfsoftware/omp-agent-discipline/DelegationVerdict`);var C=class extends c()(`Allow`,{}){[S]=S},w=class extends c()(`Block`,{reason:p,how:x,skill:p}){[S]=S};f(C,w);const T=ee({protectedSkills:u(p),delegationVerbs:u(p),referenceVerbs:u(p),mentionPatterns:te({key:p,value:p})}).pipe(l({arbitrary:()=>e=>e.constant({protectedSkills:[`ce-work`],delegationVerbs:["\\binvoke\\s+(?:the\\s+)?[`/]?ce-work\\b","\\bdispatch\\s+(?:to\\s+)?(?:the\\s+)?[`/]?ce-work\\b","\\buse\\s+(?:the\\s+)?[`/]?ce-work\\b","\\bspawn\\s+(?:a\\s+)?(?:task|agent|subagent|worker)\\s+(?:with|using)\\s+(?:the\\s+)?[`/]?ce-work\\b","\\bcall\\s+(?:the\\s+)?[`/]?ce-work\\b","\\brun\\s+(?:the\\s+)?[`/]?ce-work\\b"],referenceVerbs:["\\bsee\\s+(?:the\\s+)?[`/]?ce-work\\b","\\bread\\s+(?:the\\s+)?[`/]?ce-work\\b"],mentionPatterns:{"ce-work":'(?:^|[\\s/.`"])ce-work(?=$|[\\s/.`"]|\\b)'}})})),E=f(T,m(null)),D=Symbol.for(`@systemfsoftware/omp-agent-discipline/CheckDelegationCommand`);var ne=class extends c()(`CheckDelegationCommand`,{toolName:p,subagentType:p,prompt:p,guard:E}){[D]=D};const O=Symbol.for(`@systemfsoftware/omp-agent-discipline/ClassifiedInput`);var k=class extends c()(`NoGuard`,{}){[O]=O},A=class extends c()(`NonDelegatedTool`,{}){[O]=O},j=class extends c()(`ProtectedSubagent`,{skill:p}){[O]=O},M=class extends c()(`EmptyPrompt`,{}){[O]=O},N=class extends c()(`Prompted`,{guard:T,prompt:p}){[O]=O};f(k,A,j,M,N);const P=Symbol.for(`@systemfsoftware/omp-agent-discipline/PromptAnalysis`);var F=class extends c()(`Delegated`,{skill:p,excerpt:p}){[P]=P},I=class extends c()(`Referenced`,{}){[P]=P},L=class extends c()(`NoDelegation`,{}){[P]=P};f(F,I,L);function R(e,t,n){return[`⛔ BLOCKED: "`+e+`" must not be delegated to a subagent.`,`Detected in `+t+`: `+n,``,`REQUIRED: invoke `+e+` directly in THIS session via the host Skill / Tool call,`,`then pass its return envelope to the next step. Do NOT wrap it in a task / Agent dispatch.`,``,`WHY: a subagent reproduces the shape but loses the skill protocol — plan-path gate,`,`headless review contract, and pipeline-vs-chat mode. The contract does not survive the hop.`,``,`RULE: root AGENTS.md §"Skill invocations" (SK1/SK2).`].join(`
2
+ `)}function z(e,t){return new RegExp(e,`i`).test(t)}function B(e,t){return e.map(e=>new RegExp(e,`i`).exec(t)).find(e=>e!==null)??null}const V=e=>t(e=>e!==``)(e),H=(e,t)=>g(V(e.prompt)).pipe(v(`Some`,({value:e})=>new N({guard:t,prompt:e})),v(`None`,()=>new M),y),U=(e,n)=>t(e=>e!==``&&n.protectedSkills.includes(e))(e.subagentType),W=(e,t)=>g(U(e,t)).pipe(v(`Some`,({value:e})=>new j({skill:e})),v(`None`,()=>H(e,t)),y),G=t=>e(t.guard),K=(e,r)=>t(e=>e===`task`||e===`agent`)(e.toolName.toLowerCase()).pipe(n(()=>W(e,r))),q=e=>g(G(e)).pipe(v(`None`,()=>new k),v(`Some`,({value:t})=>g(K(e,t)).pipe(v(`None`,()=>new A),v(`Some`,({value:e})=>e),y)),y),J=(e,n)=>{let r=Object.entries(e.mentionPatterns).filter(([,e])=>z(e,n)).map(([e])=>e);return t(e=>e.length>0)(r)},Y=(e,t)=>g(J(e,t)).pipe(v(`None`,()=>new L),v(`Some`,({value:n})=>{let r=n[0];return g({hasReference:e.referenceVerbs.some(e=>z(e,t)),hasDelegation:e.delegationVerbs.some(e=>z(e,t))}).pipe(h({hasReference:!0},()=>new I),h({hasDelegation:!1},()=>new L),_(()=>{let n=B(e.delegationVerbs,t),i=n===null?t.slice(0,120):n[0];return new F({skill:r,excerpt:i})}))}),y),X=e=>g(q(e)).pipe(v(`NoGuard`,()=>new C),v(`NonDelegatedTool`,()=>new C),v(`ProtectedSubagent`,({skill:e})=>new w({reason:R(e,`subagent_type`,e),how:`subagent_type`,skill:e})),v(`EmptyPrompt`,()=>new C),v(`Prompted`,({guard:e,prompt:t})=>g(Y(e,t)).pipe(v(`Delegated`,({skill:e,excerpt:t})=>new w({reason:R(e,`prompt`,t),how:`prompt`,skill:e})),v(`Referenced`,()=>new C),v(`NoDelegation`,()=>new C),y)),y);function Z(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}function re(e){if(e.length===0)return null;let t=`(?:`+e.map(Z).join(`|`)+`)`;return{protectedSkills:e.slice(),delegationVerbs:["\\binvoke\\s+(?:the\\s+)?[`/]?"+t+`\\b`,"\\bdispatch\\s+(?:to\\s+)?(?:the\\s+)?[`/]?"+t+`\\b`,"\\bwrap\\s+(?:the\\s+)?[`/]?"+t+`\\s+in\\s+(?:a\\s+)?(?:task|agent|subagent)\\b`,"\\bdelegate\\s+(?:the\\s+)?[`/]?"+t+`\\b`,"\\brun\\s+(?:the\\s+)?[`/]?"+t+`\\s+(?:via|in)\\s+(?:a\\s+)?(?:subagent|task|agent)\\b`,"\\b(?:run|execute|launch)\\s+(?:the\\s+)?[`/]?"+t+`\\b`,"\\bskill:\\s*[`/]?"+t+`\\b`,`\\bskill:\\/\\/`+t+`\\b`,`(?:^|\\W)/`+t+`(?=$|\\b|\\W)`,"\\buse\\s+(?:the\\s+)?[`/]?"+t+`\\b`,"\\bload\\s+(?:the\\s+)?[`/]?"+t+`\\b`,"\\bspawn\\s+(?:a\\s+)?(?:task|agent|subagent|worker)\\s+(?:with|using)\\s+(?:the\\s+)?[`/]?"+t+`\\b`,"\\bcall\\s+(?:the\\s+)?[`/]?"+t+`\\b`,"\\bsend\\s+(?:the\\s+)?[`/]?"+t+`\\b`,"\\bcreate\\s+(?:a\\s+)?(?:task|agent|subagent)\\s+(?:with|using)\\s+(?:the\\s+)?[`/]?"+t+`\\b`,"\\bstart\\s+(?:the\\s+)?[`/]?"+t+`\\b`],referenceVerbs:["\\bsee\\s+(?:the\\s+)?[`/]?"+t+`\\b`,"\\bper\\s+(?:the\\s+)?[`/]?"+t+`\\b`,"\\bread\\s+(?:the\\s+)?[`/]?"+t+`\\b`,"\\baccording\\s+to\\s+(?:the\\s+)?[`/]?"+t+`\\b`],mentionPatterns:Object.fromEntries(e.map(e=>[e,'(?:^|[\\s/.`"])'+Z(e)+'(?=$|[\\s/.`"]|\\b)']))}}function Q(e){return g(e).pipe(v(`Block`,e=>({block:!0,reason:e.reason,how:e.how,skill:e.skill})),v(`Allow`,()=>void 0),y)}function ie(e){return a(function*(){return re((yield*(yield*b).load(e)).no_delegate_skills??[])})}function ae(e,t,n,r){return a(function*(){let i=new ne({toolName:t,subagentType:n,prompt:r,guard:yield*ie(e)});return Q(X(i))})}const oe=o(b,a(function*(){return yield*d})),se=e=>typeof e==`object`&&!!e&&!Array.isArray(e),ce=e=>se(e)?e:{};function $(e,...t){for(let n of t){let t=e[n];if(typeof t==`string`&&t.length>0)return t}return``}const le=(e,t)=>{e.on(`tool_call`,async(e,n)=>{let i=ce(e.input),a=$(i,`subagent_type`,`agent`),o=$(i,`prompt`,`task`,`description`),c=await t(s(ae(n.cwd,e.toolName,a,o)).pipe(oe));if(r(c))throw c.left;return c.right})};export{le as NoSkillDelegationExtension};
@@ -1 +1 @@
1
- import{Cs as e,Er as t,Is as n,Kt as r,Lr as i,Sc as a,Ts as o,mr as s,mt as c,vn as l,wr as u,xs as ee,yl as d,yn as te,zs as f}from"./core-CwsVf2Ey.js";import{$ as ne,B as re,Bt as p,Cn as ie,Gt as m,H as h,Ht as g,Jt as ae,Kt as oe,P as _,Rt as se,Ut as v,Vt as y,Wt as ce,Xt as le,Yt as b,Zt as ue,_ as x,at as de,b as S,c as C,ct as fe,dn as pe,f as me,ft as he,hn as ge,ht as _e,it as w,n as T,nt as E,on as ve,qt as ye,r as D,rn as O,rt as k,sn as A,tt as j,zt as M}from"./Effect-B34dlqAS.js";import{D as N,E as P,O as F,a as be,c as xe,d as Se,f as Ce,g as we,h as Te,i as Ee,l as De,m as I,n as Oe,o as L,p as ke,r as R,s as z,u as Ae}from"./dist-48FGb8Hs.js";import*as je from"node:os";import*as Me from"node:crypto";import*as B from"node:path";import*as V from"node:fs";function H(e,t){return l(e.runtimeEffect,e=>i(n=>(n.setFiberRefs(e.fiberRefs),n.currentRuntimeFlags=e.runtimeFlags,s(t,e.context))))}const Ne={...ie,[O]:O,pipe(){return a(this,arguments)},commit(){return this.runtimeEffect}},Pe=(e,n)=>{n??=M();let i=b(pe()),a,o=u(()=>{if(!a){let r=new ge;a=g(t(A(se(e,n),i),e=>{s.cachedRuntime=e}),{scope:i,scheduler:r}),r.flush()}return te(a.await)}),s=Object.assign(Object.create(Ne),{memoMap:n,scope:i,runtimeEffect:o,cachedRuntime:void 0,runtime(){return s.cachedRuntime===void 0?m(s.runtimeEffect):Promise.resolve(s.cachedRuntime)},dispose(){return m(s.disposeEffect)},disposeEffect:u(()=>(s.runtimeEffect=c(`ManagedRuntime disposed`),s.cachedRuntime=void 0,ve(s.scope,r))),runFork(e,t){return s.cachedRuntime===void 0?g(H(s,e),t):y(s.cachedRuntime)(e,t)},runSyncExit(e){return s.cachedRuntime===void 0?ue(H(s,e)):le(s.cachedRuntime)(e)},runSync(e){return s.cachedRuntime===void 0?b(H(s,e)):ae(s.cachedRuntime)(e)},runPromiseExit(e,t){return s.cachedRuntime===void 0?ye(H(s,e),t):oe(s.cachedRuntime)(e,t)},runCallback(e,t){return s.cachedRuntime===void 0?v(p)(H(s,e),t):v(s.cachedRuntime)(e,t)},runPromise(e,t){return s.cachedRuntime===void 0?m(H(s,e),t):ce(s.cachedRuntime)(e,t)}});return s},U=(e,t)=>(n,[r])=>{let i=`Unknown`;switch(n.code){case`ENOENT`:i=`NotFound`;break;case`EACCES`:i=`PermissionDenied`;break;case`EEXIST`:i=`AlreadyExists`;break;case`EISDIR`:i=`BadResource`;break;case`ENOTDIR`:i=`BadResource`;break;case`EBUSY`:i=`Busy`;break;case`ELOOP`:i=`BadResource`;break}return new I({reason:i,module:e,method:t,pathOrDescriptor:r,syscall:n.syscall,description:n.message,cause:n})},W=(e,t,n)=>(...r)=>C(i=>{try{e(...r,(e,n)=>{i(e?x(t?t(e,r):e):E(n))})}catch(e){i(n?x(n(e,r)):me(e))}}),G=e=>t=>new ke({module:`FileSystem`,method:e,cause:t}),Fe=(()=>{let e=W(V.access,U(`FileSystem`,`access`),G(`access`));return(t,n)=>{let r=V.constants.F_OK;return n?.readable&&(r|=V.constants.R_OK),n?.writable&&(r|=V.constants.W_OK),e(t,r)}})(),Ie=(()=>{let e=W(V.cp,U(`FileSystem`,`copy`),G(`copy`));return(t,n,r)=>e(t,n,{force:r?.overwrite??!1,preserveTimestamps:r?.preserveTimestamps??!1,recursive:!0})})(),Le=(()=>{let e=W(V.copyFile,U(`FileSystem`,`copyFile`),G(`copyFile`));return(t,n)=>e(t,n)})(),Re=(()=>{let e=W(V.chmod,U(`FileSystem`,`chmod`),G(`chmod`));return(t,n)=>e(t,n)})(),ze=(()=>{let e=W(V.chown,U(`FileSystem`,`chown`),G(`chown`));return(t,n,r)=>e(t,n,r)})(),Be=(()=>{let e=W(V.link,U(`FileSystem`,`link`),G(`link`));return(t,n)=>e(t,n)})(),Ve=(()=>{let e=W(V.mkdir,U(`FileSystem`,`makeDirectory`),G(`makeDirectory`));return(t,n)=>e(t,{recursive:n?.recursive??!1,mode:n?.mode})})(),K=e=>{let t=W(V.mkdtemp,U(`FileSystem`,e),G(e));return e=>k(()=>{let n=e?.prefix??``,r=typeof e?.directory==`string`?B.join(e.directory,`.`):je.tmpdir();return t(n?B.join(r,n):r+`/`)})},He=K(`makeTempDirectory`),q=e=>{let t=W(V.rm,U(`FileSystem`,e),G(e));return(e,n)=>t(e,{recursive:n?.recursive??!1,force:n?.force??!1})},Ue=q(`remove`),We=(()=>{let e=K(`makeTempDirectoryScoped`),t=q(`makeTempDirectoryScoped`);return n=>D(e(n),e=>h(t(e,{recursive:!0})))})(),J=e=>{let t=W(V.open,U(`FileSystem`,e),G(e)),n=W(V.close,U(`FileSystem`,e),G(e));return(e,r)=>d(D(t(e,r?.flag??`r`,r?.mode),e=>h(n(e))),_(e=>Ke(Ee(e),r?.flag?.startsWith(`a`)??!1)))},Ge=J(`open`),Ke=(()=>{let e=e=>W(V.read,U(`FileSystem`,e),G(e)),t=e(`read`),r=e(`readAlloc`),i=W(V.fstat,U(`FileSystem`,`stat`),G(`stat`)),a=W(V.ftruncate,U(`FileSystem`,`truncate`),G(`truncate`)),o=W(V.fsync,U(`FileSystem`,`sync`),G(`sync`)),s=e=>W(V.write,U(`FileSystem`,e),G(e)),c=s(`write`),l=s(`writeAll`);class u{fd;append;[L];semaphore=he(1);position=0n;constructor(e,t){this.fd=e,this.append=t,this[L]=L}get stat(){return _(i(this.fd),Z)}get sync(){return o(this.fd)}seek(e,t){let n=z(e);return this.semaphore.withPermits(1)(w(()=>(t===`start`?this.position=n:t===`current`&&(this.position+=n),this.position)))}read(e){return this.semaphore.withPermits(1)(_(k(()=>t(this.fd,{buffer:e,position:this.position})),e=>{let t=z(e);return this.position+=t,t}))}readAlloc(e){let t=Number(e);return this.semaphore.withPermits(1)(S(w(()=>Buffer.allocUnsafeSlow(t)),e=>_(r(this.fd,{buffer:e,position:this.position}),r=>{if(r===0)return n();if(this.position+=BigInt(r),r===t)return f(e);let i=Buffer.allocUnsafeSlow(r);return e.copy(i,0,0,r),f(i)})))}truncate(e){return this.semaphore.withPermits(1)(_(a(this.fd,e?Number(e):void 0),()=>{if(!this.append){let t=BigInt(e??0);this.position>t&&(this.position=t)}}))}write(e){return this.semaphore.withPermits(1)(_(k(()=>c(this.fd,e,void 0,void 0,this.append?void 0:Number(this.position))),e=>{let t=z(e);return this.append||(this.position+=t),t}))}writeAllChunk(e){return S(k(()=>l(this.fd,e,void 0,void 0,this.append?void 0:Number(this.position))),t=>t===0?x(new I({module:`FileSystem`,method:`writeAll`,reason:`WriteZero`,pathOrDescriptor:this.fd,description:`write returned 0 bytes written`})):(this.append||(this.position+=BigInt(t)),t<e.length?this.writeAllChunk(e.subarray(t)):T))}writeAll(e){return this.semaphore.withPermits(1)(this.writeAllChunk(e))}}return(e,t)=>new u(e,t)})(),Y=e=>{let t=K(e),n=J(e),r=e=>w(()=>Me.randomBytes(e).toString(`hex`));return e=>d(_e(t(e),r(6)),_(([t,n])=>B.join(t,n+(e?.suffix??``))),de(e=>ne(n(e,{flag:`w+`}))))},qe=Y(`makeTempFile`),Je=(()=>{let e=Y(`makeTempFileScoped`),t=q(`makeTempFileScoped`);return n=>D(e(n),e=>h(t(B.dirname(e),{recursive:!0})))})(),Ye=(e,t)=>fe({try:()=>V.promises.readdir(e,t),catch:t=>U(`FileSystem`,`readDirectory`)(t,[e])}),Xe=e=>C((t,n)=>{try{V.readFile(e,{signal:n},(n,r)=>{t(n?x(U(`FileSystem`,`readFile`)(n,[e])):E(r))})}catch(e){t(x(G(`readFile`)(e)))}}),Ze=(()=>{let e=W(V.readlink,U(`FileSystem`,`readLink`),G(`readLink`));return t=>e(t)})(),X=(()=>{let e=W(V.realpath,U(`FileSystem`,`realPath`),G(`realPath`));return t=>e(t)})(),Qe=(()=>{let e=W(V.rename,U(`FileSystem`,`rename`),G(`rename`));return(t,n)=>e(t,n)})(),Z=t=>({type:t.isFile()?`File`:t.isDirectory()?`Directory`:t.isSymbolicLink()?`SymbolicLink`:t.isBlockDevice()?`BlockDevice`:t.isCharacterDevice()?`CharacterDevice`:t.isFIFO()?`FIFO`:t.isSocket()?`Socket`:`Unknown`,mtime:e(t.mtime),atime:e(t.atime),birthtime:e(t.birthtime),dev:t.dev,rdev:e(t.rdev),ino:e(t.ino),mode:t.mode,nlink:e(t.nlink),uid:e(t.uid),gid:e(t.gid),size:z(t.size),blksize:e(z(t.blksize)),blocks:e(t.blocks)}),Q=(()=>{let e=W(V.stat,U(`FileSystem`,`stat`),G(`stat`));return t=>_(e(t),Z)})(),$e=(()=>{let e=W(V.symlink,U(`FileSystem`,`symlink`),G(`symlink`));return(t,n)=>e(t,n)})(),et=(()=>{let e=W(V.truncate,U(`FileSystem`,`truncate`),G(`truncate`));return(t,n)=>e(t,n===void 0?void 0:Number(n))})(),tt=(()=>{let e=W(V.utimes,U(`FileSystem`,`utime`),G(`utime`));return(t,n,r)=>e(t,n,r)})(),nt=(e,t)=>Te(n=>D(w(()=>{let r=V.watch(e,{recursive:t?.recursive},(e,t)=>{if(t)switch(e){case`rename`:n.fromEffect(re(Q(t),{onSuccess:e=>E(De({path:t})),onFailure:e=>e._tag===`SystemError`&&e.reason===`NotFound`?E(Ae({path:t})):x(e)}));return;case`change`:n.single(Se({path:t}));return}});return r.on(`error`,t=>{n.fail(new I({module:`FileSystem`,reason:`Unknown`,method:`watch`,pathOrDescriptor:e,cause:t}))}),r.on(`close`,()=>{n.end()}),r}),e=>w(()=>e.close()))),rt=(e,t,n)=>Q(t).pipe(_(r=>e.pipe(ee(e=>e.register(t,r,n)),o(()=>nt(t,n)))),we),it=(e,t,n)=>C((r,i)=>{try{V.writeFile(e,t,{signal:i,flag:n?.flag,mode:n?.mode},t=>{r(t?x(U(`FileSystem`,`writeFile`)(t,[e])):T)})}catch(e){r(x(G(`writeFile`)(e)))}}),$=P(be,_(j(xe),e=>Ce({access:Fe,chmod:Re,chown:ze,copy:Ie,copyFile:Le,link:Be,makeDirectory:Ve,makeTempDirectory:He,makeTempDirectoryScoped:We,makeTempFile:qe,makeTempFileScoped:Je,open:Ge,readDirectory:Ye,readFile:Xe,readLink:Ze,realPath:X,remove:Ue,rename:Qe,stat:Q,symlink:$e,truncate:et,utimes:tt,watch(t,n){return rt(e,t,n)},writeFile:it}))),at=Pe(N($,R,Oe.pipe(F($),F(R))));export{at as default};
1
+ import{Cs as e,Er as t,Is as n,Kt as r,Lr as i,Sc as a,Ts as o,mr as s,mt as c,vn as l,wr as u,xs as ee,yl as d,yn as f,zs as p}from"./core-CwsVf2Ey.js";import{B as te,Bt as ne,Gt as m,H as h,Ht as re,Jt as ie,Kt as g,P as _,Qt as ae,Ut as v,Vt as oe,Wt as y,Xt as b,Yt as se,Zt as ce,_ as x,at as S,b as C,c as w,cn as le,et as ue,f as de,fn as fe,gn as pe,gt as me,in as T,it as E,lt as he,n as D,nt as ge,ot as _e,pt as ve,qt as ye,r as O,rt as k,sn as A,wn as j,zt as M}from"./Effect-BnMIG7Ln.js";import{D as N,E as P,O as F,a as be,c as xe,d as Se,f as Ce,g as we,h as Te,i as Ee,l as De,m as I,n as Oe,o as L,p as ke,r as R,s as z,u as Ae}from"./dist-DNAOOlxn.js";import*as je from"node:os";import*as Me from"node:crypto";import*as B from"node:path";import*as V from"node:fs";function H(e,t){return l(e.runtimeEffect,e=>i(n=>(n.setFiberRefs(e.fiberRefs),n.currentRuntimeFlags=e.runtimeFlags,s(t,e.context))))}const Ne={...j,[T]:T,pipe(){return a(this,arguments)},commit(){return this.runtimeEffect}},Pe=(e,n)=>{n??=ne();let i=b(fe()),a,o=u(()=>{if(!a){let r=new pe;a=v(t(le(M(e,n),i),e=>{s.cachedRuntime=e}),{scope:i,scheduler:r}),r.flush()}return f(a.await)}),s=Object.assign(Object.create(Ne),{memoMap:n,scope:i,runtimeEffect:o,cachedRuntime:void 0,runtime(){return s.cachedRuntime===void 0?g(s.runtimeEffect):Promise.resolve(s.cachedRuntime)},dispose(){return g(s.disposeEffect)},disposeEffect:u(()=>(s.runtimeEffect=c(`ManagedRuntime disposed`),s.cachedRuntime=void 0,A(s.scope,r))),runFork(e,t){return s.cachedRuntime===void 0?v(H(s,e),t):re(s.cachedRuntime)(e,t)},runSyncExit(e){return s.cachedRuntime===void 0?ae(H(s,e)):ce(s.cachedRuntime)(e)},runSync(e){return s.cachedRuntime===void 0?b(H(s,e)):se(s.cachedRuntime)(e)},runPromiseExit(e,t){return s.cachedRuntime===void 0?ie(H(s,e),t):ye(s.cachedRuntime)(e,t)},runCallback(e,t){return s.cachedRuntime===void 0?y(oe)(H(s,e),t):y(s.cachedRuntime)(e,t)},runPromise(e,t){return s.cachedRuntime===void 0?g(H(s,e),t):m(s.cachedRuntime)(e,t)}});return s},U=(e,t)=>(n,[r])=>{let i=`Unknown`;switch(n.code){case`ENOENT`:i=`NotFound`;break;case`EACCES`:i=`PermissionDenied`;break;case`EEXIST`:i=`AlreadyExists`;break;case`EISDIR`:i=`BadResource`;break;case`ENOTDIR`:i=`BadResource`;break;case`EBUSY`:i=`Busy`;break;case`ELOOP`:i=`BadResource`;break}return new I({reason:i,module:e,method:t,pathOrDescriptor:r,syscall:n.syscall,description:n.message,cause:n})},W=(e,t,n)=>(...r)=>w(i=>{try{e(...r,(e,n)=>{i(e?x(t?t(e,r):e):k(n))})}catch(e){i(n?x(n(e,r)):de(e))}}),G=e=>t=>new ke({module:`FileSystem`,method:e,cause:t}),Fe=(()=>{let e=W(V.access,U(`FileSystem`,`access`),G(`access`));return(t,n)=>{let r=V.constants.F_OK;return n?.readable&&(r|=V.constants.R_OK),n?.writable&&(r|=V.constants.W_OK),e(t,r)}})(),Ie=(()=>{let e=W(V.cp,U(`FileSystem`,`copy`),G(`copy`));return(t,n,r)=>e(t,n,{force:r?.overwrite??!1,preserveTimestamps:r?.preserveTimestamps??!1,recursive:!0})})(),Le=(()=>{let e=W(V.copyFile,U(`FileSystem`,`copyFile`),G(`copyFile`));return(t,n)=>e(t,n)})(),Re=(()=>{let e=W(V.chmod,U(`FileSystem`,`chmod`),G(`chmod`));return(t,n)=>e(t,n)})(),ze=(()=>{let e=W(V.chown,U(`FileSystem`,`chown`),G(`chown`));return(t,n,r)=>e(t,n,r)})(),Be=(()=>{let e=W(V.link,U(`FileSystem`,`link`),G(`link`));return(t,n)=>e(t,n)})(),Ve=(()=>{let e=W(V.mkdir,U(`FileSystem`,`makeDirectory`),G(`makeDirectory`));return(t,n)=>e(t,{recursive:n?.recursive??!1,mode:n?.mode})})(),K=e=>{let t=W(V.mkdtemp,U(`FileSystem`,e),G(e));return e=>E(()=>{let n=e?.prefix??``,r=typeof e?.directory==`string`?B.join(e.directory,`.`):je.tmpdir();return t(n?B.join(r,n):r+`/`)})},He=K(`makeTempDirectory`),q=e=>{let t=W(V.rm,U(`FileSystem`,e),G(e));return(e,n)=>t(e,{recursive:n?.recursive??!1,force:n?.force??!1})},Ue=q(`remove`),We=(()=>{let e=K(`makeTempDirectoryScoped`),t=q(`makeTempDirectoryScoped`);return n=>O(e(n),e=>h(t(e,{recursive:!0})))})(),J=e=>{let t=W(V.open,U(`FileSystem`,e),G(e)),n=W(V.close,U(`FileSystem`,e),G(e));return(e,r)=>d(O(t(e,r?.flag??`r`,r?.mode),e=>h(n(e))),_(e=>Ke(Ee(e),r?.flag?.startsWith(`a`)??!1)))},Ge=J(`open`),Ke=(()=>{let e=e=>W(V.read,U(`FileSystem`,e),G(e)),t=e(`read`),r=e(`readAlloc`),i=W(V.fstat,U(`FileSystem`,`stat`),G(`stat`)),a=W(V.ftruncate,U(`FileSystem`,`truncate`),G(`truncate`)),o=W(V.fsync,U(`FileSystem`,`sync`),G(`sync`)),s=e=>W(V.write,U(`FileSystem`,e),G(e)),c=s(`write`),l=s(`writeAll`);class u{fd;append;[L];semaphore=ve(1);position=0n;constructor(e,t){this.fd=e,this.append=t,this[L]=L}get stat(){return _(i(this.fd),Z)}get sync(){return o(this.fd)}seek(e,t){let n=z(e);return this.semaphore.withPermits(1)(S(()=>(t===`start`?this.position=n:t===`current`&&(this.position+=n),this.position)))}read(e){return this.semaphore.withPermits(1)(_(E(()=>t(this.fd,{buffer:e,position:this.position})),e=>{let t=z(e);return this.position+=t,t}))}readAlloc(e){let t=Number(e);return this.semaphore.withPermits(1)(C(S(()=>Buffer.allocUnsafeSlow(t)),e=>_(r(this.fd,{buffer:e,position:this.position}),r=>{if(r===0)return n();if(this.position+=BigInt(r),r===t)return p(e);let i=Buffer.allocUnsafeSlow(r);return e.copy(i,0,0,r),p(i)})))}truncate(e){return this.semaphore.withPermits(1)(_(a(this.fd,e?Number(e):void 0),()=>{if(!this.append){let t=BigInt(e??0);this.position>t&&(this.position=t)}}))}write(e){return this.semaphore.withPermits(1)(_(E(()=>c(this.fd,e,void 0,void 0,this.append?void 0:Number(this.position))),e=>{let t=z(e);return this.append||(this.position+=t),t}))}writeAllChunk(e){return C(E(()=>l(this.fd,e,void 0,void 0,this.append?void 0:Number(this.position))),t=>t===0?x(new I({module:`FileSystem`,method:`writeAll`,reason:`WriteZero`,pathOrDescriptor:this.fd,description:`write returned 0 bytes written`})):(this.append||(this.position+=BigInt(t)),t<e.length?this.writeAllChunk(e.subarray(t)):D))}writeAll(e){return this.semaphore.withPermits(1)(this.writeAllChunk(e))}}return(e,t)=>new u(e,t)})(),Y=e=>{let t=K(e),n=J(e),r=e=>S(()=>Me.randomBytes(e).toString(`hex`));return e=>d(me(t(e),r(6)),_(([t,n])=>B.join(t,n+(e?.suffix??``))),_e(e=>ue(n(e,{flag:`w+`}))))},qe=Y(`makeTempFile`),Je=(()=>{let e=Y(`makeTempFileScoped`),t=q(`makeTempFileScoped`);return n=>O(e(n),e=>h(t(B.dirname(e),{recursive:!0})))})(),Ye=(e,t)=>he({try:()=>V.promises.readdir(e,t),catch:t=>U(`FileSystem`,`readDirectory`)(t,[e])}),Xe=e=>w((t,n)=>{try{V.readFile(e,{signal:n},(n,r)=>{t(n?x(U(`FileSystem`,`readFile`)(n,[e])):k(r))})}catch(e){t(x(G(`readFile`)(e)))}}),Ze=(()=>{let e=W(V.readlink,U(`FileSystem`,`readLink`),G(`readLink`));return t=>e(t)})(),X=(()=>{let e=W(V.realpath,U(`FileSystem`,`realPath`),G(`realPath`));return t=>e(t)})(),Qe=(()=>{let e=W(V.rename,U(`FileSystem`,`rename`),G(`rename`));return(t,n)=>e(t,n)})(),Z=t=>({type:t.isFile()?`File`:t.isDirectory()?`Directory`:t.isSymbolicLink()?`SymbolicLink`:t.isBlockDevice()?`BlockDevice`:t.isCharacterDevice()?`CharacterDevice`:t.isFIFO()?`FIFO`:t.isSocket()?`Socket`:`Unknown`,mtime:e(t.mtime),atime:e(t.atime),birthtime:e(t.birthtime),dev:t.dev,rdev:e(t.rdev),ino:e(t.ino),mode:t.mode,nlink:e(t.nlink),uid:e(t.uid),gid:e(t.gid),size:z(t.size),blksize:e(z(t.blksize)),blocks:e(t.blocks)}),Q=(()=>{let e=W(V.stat,U(`FileSystem`,`stat`),G(`stat`));return t=>_(e(t),Z)})(),$e=(()=>{let e=W(V.symlink,U(`FileSystem`,`symlink`),G(`symlink`));return(t,n)=>e(t,n)})(),et=(()=>{let e=W(V.truncate,U(`FileSystem`,`truncate`),G(`truncate`));return(t,n)=>e(t,n===void 0?void 0:Number(n))})(),tt=(()=>{let e=W(V.utimes,U(`FileSystem`,`utime`),G(`utime`));return(t,n,r)=>e(t,n,r)})(),nt=(e,t)=>Te(n=>O(S(()=>{let r=V.watch(e,{recursive:t?.recursive},(e,t)=>{if(t)switch(e){case`rename`:n.fromEffect(te(Q(t),{onSuccess:e=>k(De({path:t})),onFailure:e=>e._tag===`SystemError`&&e.reason===`NotFound`?k(Ae({path:t})):x(e)}));return;case`change`:n.single(Se({path:t}));return}});return r.on(`error`,t=>{n.fail(new I({module:`FileSystem`,reason:`Unknown`,method:`watch`,pathOrDescriptor:e,cause:t}))}),r.on(`close`,()=>{n.end()}),r}),e=>S(()=>e.close()))),rt=(e,t,n)=>Q(t).pipe(_(r=>e.pipe(ee(e=>e.register(t,r,n)),o(()=>nt(t,n)))),we),it=(e,t,n)=>w((r,i)=>{try{V.writeFile(e,t,{signal:i,flag:n?.flag,mode:n?.mode},t=>{r(t?x(U(`FileSystem`,`writeFile`)(t,[e])):D)})}catch(e){r(x(G(`writeFile`)(e)))}}),$=P(be,_(ge(xe),e=>Ce({access:Fe,chmod:Re,chown:ze,copy:Ie,copyFile:Le,link:Be,makeDirectory:Ve,makeTempDirectory:He,makeTempDirectoryScoped:We,makeTempFile:qe,makeTempFileScoped:Je,open:Ge,readDirectory:Ye,readFile:Xe,readLink:Ze,realPath:X,remove:Ue,rename:Qe,stat:Q,symlink:$e,truncate:et,utimes:tt,watch(t,n){return rt(e,t,n)},writeFile:it}))),at=Pe(N($,R,Oe.pipe(F($),F(R))));export{at as default};
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@systemfsoftware/omp-agent-discipline",
3
3
  "license": "MIT",
4
- "version": "1.5.0",
4
+ "version": "1.5.1",
5
5
  "author": "Ryan Lee <drdgvhbh@gmail.com>",
6
6
  "description": "OMP agent discipline: mechanical enforcement of rules prose can't hold (xd:// retry guard, ...)",
7
7
  "type": "module",
@@ -30,11 +30,11 @@
30
30
  "tsdown": "^0.22.9",
31
31
  "typescript": "^7",
32
32
  "vitest": "^4",
33
- "@systemfsoftware/effect-memfs": "^1.0.8",
34
- "@systemfsoftware/oxlint-config": "^0.1.0",
33
+ "@systemfsoftware/effect-gherkin-spec": "^0.5.0",
34
+ "@systemfsoftware/effect-memfs": "^1.1.0",
35
35
  "@systemfsoftware/omp-utils": "^0.0.0",
36
- "@systemfsoftware/tsconfig": "^1.2.6",
37
- "@systemfsoftware/effect-gherkin-spec": "^0.4.1"
36
+ "@systemfsoftware/tsconfig": "^1.3.0",
37
+ "@systemfsoftware/oxlint-config": "^0.1.0"
38
38
  },
39
39
  "omp": {
40
40
  "extensions": [
@@ -1,16 +0,0 @@
1
- import{$c as e,$o as t,$s as n,Ao as r,As as i,Bc as a,Bs as o,Cc as s,Cr as c,Dc as l,Dn as u,Do as d,Ds as f,Ec as p,Es as m,Fc as h,Fi as g,Fo as ee,Fs as _,Gs as te,Hi as ne,Hs as re,Ic as ie,Io as ae,Is as v,Jc as oe,Ji as se,Jr as ce,Js as le,Ko as ue,Ks as y,Lc as de,Lr as fe,Ls as pe,Mi as me,Nc as he,Ni as ge,Nr as _e,Ns as ve,Oo as ye,Os as be,Pi as xe,Pr as Se,Ps as Ce,Qi as we,Qo as Te,Qs as b,Rc as Ee,Sc as De,So as Oe,Ss as ke,Tc as Ae,To as je,Tr as Me,Ts as Ne,Ui as Pe,Uo as Fe,Us as Ie,Vi as Le,Vo as Re,Vs as ze,Wi as Be,Wo as Ve,Ws as He,Xc as Ue,Xn as We,Xs as Ge,Yc as Ke,Yi as qe,Ys as Je,Zi as Ye,Zo as Xe,_l as x,aa as Ze,al as Qe,as as $e,b as et,bo as tt,bs as nt,ci as rt,cl as it,cr as at,ct as ot,dl as st,dt as ct,ea as lt,el as ut,fl as dt,fs as ft,ft as pt,gl as mt,go as ht,il as gt,in as _t,jc as vt,ji as yt,js as bt,k as xt,ko as St,kr as Ct,ks as wt,li as Tt,ll as Et,nl as Dt,no as Ot,oc as kt,ol as At,pl as jt,pt as Mt,qc as Nt,qi as Pt,qo as Ft,qs as It,ra as Lt,rl as Rt,rt as zt,ta as Bt,tl as Vt,ul as Ht,us as Ut,ut as Wt,vl as S,vn as Gt,vo as Kt,w as qt,wr as Jt,ws as Yt,xo as Xt,xs as Zt,yl as C,yo as Qt,ys as $t,zc as en,zo as tn,zs as w}from"./core-CwsVf2Ey.js";import{$t as nn,A as rn,At as an,C as on,Ct as sn,D as cn,Dn as ln,Dt as un,E as dn,En as fn,Et as pn,F as mn,Ft as hn,G as gn,I as _n,It as vn,J as yn,K as bn,Kt as xn,L as Sn,Lt as Cn,M as wn,Mt as Tn,N as En,Nt as Dn,O as On,On as kn,Ot as An,P as T,Pt as jn,Q as Mn,Qt as Nn,R as Pn,S as Fn,Sn as In,St as Ln,T as Rn,Tn as zn,Tt as Bn,U as Vn,V as Hn,X as Un,Y as Wn,Z as Gn,_ as Kn,_n as qn,_t as E,a as Jn,an as Yn,at as Xn,b as D,bn as Zn,bt as Qn,cn as $n,d as er,dt as tr,en as nr,et as rr,f as ir,fn as ar,g as O,gn as or,gt as sr,h as cr,hn as lr,ht as ur,i as dr,in as fr,it as pr,j as mr,jt as hr,k as gr,kt as k,l as _r,ln as vr,lt as yr,m as br,mn as xr,mt as Sr,n as A,nn as Cr,nt as j,o as wr,on as Tr,ot as Er,p as Dr,pn as Or,pt as kr,q as Ar,r as jr,rt as M,s as Mr,sn as Nr,st as Pr,tn as Fr,u as Ir,un as Lr,ut as Rr,v as zr,vn as Br,vt as Vr,w as Hr,wn as Ur,wt as Wr,x as Gr,xn as Kr,xt as qr,y as Jr,yn as Yr,yt as Xr,z as Zr}from"./Effect-B34dlqAS.js";import{a as Qr,c as $r,d as ei,f as ti,i as ni,l as ri,n as ii,o as ai,p as oi,r as si,s as ci,u as li}from"./Cause-CTmrUQgG.js";import{a as ui,c as di,d as fi,f as pi,h as mi,i as hi,l as gi,m as _i,n as vi,p as yi,r as bi,s as xi,u as Si}from"./Exit-Dq5mS6lc.js";import Ci from"node:os";const wi=Tt,Ti=e=>t=>{let n=t===void 0?Object.create(kt):wi(t);return n._tag=e,n},Ei=rt,Di=function(){let e=Symbol.for(`effect/Data/Error/plainArgs`);return{BaseEffectError:class extends et{constructor(t){super(t?.message,t?.cause?{cause:t.cause}:void 0),t&&(Object.assign(this,t),Object.defineProperty(this,e,{value:t,enumerable:!1}))}toJSON(){return{...this[e],...this}}}}.BaseEffectError}(),Oi=e=>{let t={BaseEffectError:class extends Di{_tag=e}};return t.BaseEffectError.prototype.name=e,t.BaseEffectError},ki=Symbol.for(`effect/DateTime`),Ai=Symbol.for(`effect/DateTime/TimeZone`),ji={[ki]:ki,pipe(){return De(this,arguments)},[s](){return this.toString()},toJSON(){return ca(this).toJSON()}},Mi={...ji,_tag:`Utc`,[a](){return h(this,Ee(this.epochMillis))},[he](e){return Ri(e)&&e._tag===`Utc`&&this.epochMillis===e.epochMillis},toString(){return`DateTime.Utc(${ca(this).toJSON()})`}},Ni={...ji,_tag:`Zoned`,[a](){return C(Ee(this.epochMillis),ie(de(this.zone)),h(this))},[he](e){return Ri(e)&&e._tag===`Zoned`&&this.epochMillis===e.epochMillis&&vt(this.zone,e.zone)},toString(){return`DateTime.Zoned(${Sa(this)})`}},Pi={[Ai]:Ai,[s](){return this.toString()}},Fi={...Pi,_tag:`Named`,[a](){return h(this,en(`Named:${this.id}`))},[he](e){return zi(e)&&e._tag===`Named`&&this.id===e.id},toString(){return`TimeZone.Named(${this.id})`},toJSON(){return{_id:`TimeZone`,_tag:`Named`,id:this.id}}},Ii={...Pi,_tag:`Offset`,[a](){return h(this,en(`Offset:${this.offset}`))},[he](e){return zi(e)&&e._tag===`Offset`&&this.offset===e.offset},toString(){return`TimeZone.Offset(${da(this.offset)})`},toJSON(){return{_id:`TimeZone`,_tag:`Offset`,offset:this.offset}}},Li=(e,t,n)=>{let r=Object.create(Ni);return r.epochMillis=e,r.zone=t,Object.defineProperty(r,"partsUtc",{value:n,enumerable:!1,writable:!0}),Object.defineProperty(r,"adjustedEpochMillis",{value:void 0,enumerable:!1,writable:!0}),Object.defineProperty(r,"partsAdjusted",{value:void 0,enumerable:!1,writable:!0}),r},Ri=e=>Nt(e,ki),zi=e=>Nt(e,Ai),Bi=e=>zi(e)&&e._tag===`Offset`,Vi=e=>zi(e)&&e._tag===`Named`,Hi=e=>e._tag===`Utc`,Ui=e=>e._tag===`Zoned`,Wi=jt((e,t)=>e.epochMillis===t.epochMillis),Gi=e=>{let t=Object.create(Mi);return t.epochMillis=e,Object.defineProperty(t,"partsUtc",{value:void 0,enumerable:!1,writable:!0}),t},Ki=e=>{let t=e.getTime();if(Number.isNaN(t))throw new ii(`Invalid date`);return Gi(t)},qi=e=>{if(Ri(e))return e;if(e instanceof Date)return Ki(e);if(typeof e==`object`){let t=new Date(0);return ma(t,e),Ki(t)}else if(typeof e==`string`&&!Ji(e))return Ki(new Date(e+`Z`));return Ki(new Date(e))},Ji=e=>/Z|[+-]\d{2}$|[+-]\d{2}:?\d{2}$|\]$/.test(e),Yi=(e,t)=>{if(t?.timeZone===void 0&&Ri(e)&&Ui(e))return e;let n=qi(e);if(n.epochMillis<-86399999568e5||n.epochMillis>86399999496e5)throw RangeError(`Epoch millis out of range: ${n.epochMillis}`);let r;if(t?.timeZone===void 0){let e=new Date(n.epochMillis).getTimezoneOffset()*-60*1e3;r=ra(e)}else if(zi(t?.timeZone))r=t.timeZone;else if(typeof t?.timeZone==`number`)r=ra(t.timeZone);else{let e=oa(t.timeZone);if(wt(e))throw new ii(`Invalid time zone: ${t.timeZone}`);r=e.value}return t?.adjustForTimeZone===!0?ga(n.epochMillis,r,t?.disambiguation??`compatible`):Li(n.epochMillis,r,n.partsUtc)},Xi=ve(Yi),Zi=/^(.{17,35})\[(.+)\]$/,Qi=e=>{let t=Zi.exec(e);if(t===null){let t=va(e);return t===null?v():Xi(e,{timeZone:t})}let[,n,r]=t;return Xi(n,{timeZone:r})},$i=st(`effect/DateTime/validZoneCache`,()=>new Map),ea={day:`numeric`,month:`numeric`,year:`numeric`,hour:`numeric`,minute:`numeric`,second:`numeric`,timeZoneName:`longOffset`,fractionalSecondDigits:3,hourCycle:`h23`},ta=e=>{let t=e.resolvedOptions().timeZone;if($i.has(t))return $i.get(t);let n=Object.create(Fi);return n.id=t,n.format=e,$i.set(t,n),n},na=e=>{if($i.has(e))return $i.get(e);try{return ta(new Intl.DateTimeFormat(`en-US`,{...ea,timeZone:e}))}catch{throw new ii(`Invalid time zone: ${e}`)}},ra=e=>{let t=Object.create(Ii);return t.offset=e,t},ia=ve(na),aa=/^(?:GMT|[+-])/,oa=e=>{if(aa.test(e)){let t=va(e);return t===null?v():w(ra(t))}return ia(e)},sa=e=>e._tag===`Offset`?da(e.offset):e.id,ca=e=>new Date(e.epochMillis),la=e=>{if(e._tag===`Utc`)return new Date(e.epochMillis);if(e.zone._tag===`Offset`)return new Date(e.epochMillis+e.zone.offset);if(e.adjustedEpochMillis!==void 0)return new Date(e.adjustedEpochMillis);let t=e.zone.format.formatToParts(e.epochMillis).filter(e=>e.type!==`literal`),n=new Date(0);return n.setUTCFullYear(Number(t[2].value),Number(t[0].value)-1,Number(t[1].value)),n.setUTCHours(Number(t[3].value),Number(t[4].value),Number(t[5].value),Number(t[6].value)),e.adjustedEpochMillis=n.getTime(),n},ua=e=>la(e).getTime()-pa(e),da=e=>{let t=Math.abs(e),n=Math.floor(t/(3600*1e3)),r=Math.round(t%(3600*1e3)/(60*1e3));return r===60&&(n+=1,r=0),`${e<0?`-`:`+`}${String(n).padStart(2,`0`)}:${String(r).padStart(2,`0`)}`},fa=e=>da(ua(e)),pa=e=>e.epochMillis,ma=(e,t)=>{if(t.year!==void 0&&e.setUTCFullYear(t.year),t.month!==void 0&&e.setUTCMonth(t.month-1),t.day!==void 0&&e.setUTCDate(t.day),t.weekDay!==void 0){let n=t.weekDay-e.getUTCDay();e.setUTCDate(e.getUTCDate()+n)}t.hours!==void 0&&e.setUTCHours(t.hours),t.minutes!==void 0&&e.setUTCMinutes(t.minutes),t.seconds!==void 0&&e.setUTCSeconds(t.seconds),t.millis!==void 0&&e.setUTCMilliseconds(t.millis)},ha=1440*60*1e3,ga=(e,t,n)=>{if(t._tag===`Offset`)return Li(e-t.offset,t);let r=ya(e-ha,e,t),i=ya(e+ha,e,t);if(r===i)return Li(e-r,t);let a=r<i,o=r-i;if(a){if(ya(e-i,e,t)===i)return Li(e-i,t);let a=Li(e-r,t);if(e!==la(a).getTime())switch(n){case`reject`:{let n=new Date(e).toISOString();throw RangeError(`Gap time: ${n} does not exist in time zone ${t.id}`)}case`earlier`:return Li(e-i,t);case`compatible`:case`later`:return a}return a}if(ya(e-r,e,t)===r){if(n===`earlier`||n===`compatible`||ya(e-r+o,e+o,t)===r)return Li(e-r,t);if(n===`reject`){let n=new Date(e).toISOString();throw RangeError(`Ambiguous time: ${n} occurs twice in time zone ${t.id}`)}}return Li(e-i,t)},_a=/([+-])(\d{2}):(\d{2})$/,va=e=>{let t=_a.exec(e);if(t===null)return null;let[,n,r,i]=t;return(n===`+`?1:-1)*(Number(r)*60+Number(i))*60*1e3},ya=(e,t,n)=>{let r=n.format.formatToParts(e).find(e=>e.type===`timeZoneName`)?.value??``;if(r===`GMT`)return 0;let i=va(r);return i===null?ua(Li(t,n)):i},ba=e=>ca(e).toISOString(),xa=e=>{let t=la(e);return e._tag===`Utc`?t.toISOString():`${t.toISOString().slice(0,-1)}${fa(e)}`},Sa=e=>e.zone._tag===`Offset`?xa(e):`${xa(e)}[${e.zone.id}]`,Ca=e=>e.toUpperCase(),wa=e=>e.toLowerCase(),Ta=e=>e.length===0?e:Ca(e[0])+e.slice(1),Ea=e=>e.length===0?e:wa(e[0])+e.slice(1),Da=e=>e.length>0,Oa={arrays:`merge`,sets:`merge`,maps:`merge`};function ka(e,t,n){return Aa(e,t,new Set,n??Oa)}function Aa(e,t,n,r){let i={},a=new Set([...Fa(e),...Fa(t)]);for(let o of a){if(o===`__proto__`)continue;let a=e[o];if(!Object.hasOwn(t,o)){i[o]=a;continue}let s=t[o];if(Pa(a)&&Pa(s)&&!n.has(a)&&!n.has(s)){n.add(a),n.add(s),i[o]=ja(a,s,n,r);continue}i[o]=s}return i}function ja(e,t,n,r){if(Ma(e)&&Ma(t))return Aa(e,t,n,r);if(Na(e)&&Na(t)){if(Array.isArray(e)&&Array.isArray(t))return r.arrays===`merge`?e.concat(t):t;if(e instanceof Map&&t instanceof Map){if(r.maps===`merge`){let n=new Map(e);for(let[e,r]of t)n.set(e,r);return n}return t}if(e instanceof Set&&t instanceof Set){if(r.sets===`merge`){let n=new Set(e);for(let e of t)n.add(e);return n}return t}}return t}function Ma(e){return Object.getPrototypeOf(e)===Object.prototype}function Na(e){return typeof e[Symbol.iterator]==`function`}function Pa(e){return typeof e==`object`&&!!e}function Fa(e){let t=Object.keys(e),n=Object.getOwnPropertySymbols(e);if(n.length===0)return t;for(let r of n)Object.prototype.propertyIsEnumerable.call(e,r)&&t.push(r);return t}function Ia(e){return e%4==0&&e%100!=0||e%400==0}var La=class{#e=/[ \t]/;#t=0;#n;constructor(e){this.#n=e}get position(){return this.#t}get source(){return this.#n}char(e=0){return this.#n[this.#t+e]??``}slice(e,t){return this.#n.slice(this.#t+e,this.#t+t)}next(e=1){this.#t+=e}skipWhitespaces(){for(;this.#e.test(this.char())&&!this.eof();)this.next();if(!this.isCurrentCharEOL()&&/\s/.test(this.char())){let e=`\\u`+this.char().charCodeAt(0).toString(16),t=this.#t;throw SyntaxError(`Cannot parse the TOML: It contains invalid whitespace at position '${t}': \`${e}\``)}}nextUntilChar(e={skipComments:!0}){for(;!this.eof();){let t=this.char();if(this.#e.test(t)||this.isCurrentCharEOL())this.next();else if(e.skipComments&&this.char()===`#`)for(;!this.isCurrentCharEOL()&&!this.eof();)this.next();else break}}eof(){return this.#t>=this.#n.length}isCurrentCharEOL(){return this.char()===`
2
- `||this.startsWith(`\r
3
- `)}startsWith(e){return this.#n.startsWith(e,this.#t)}match(e){if(!e.sticky)throw Error(`RegExp ${e} does not have a sticky 'y' flag`);return e.lastIndex=this.#t,this.#n.match(e)}};function N(e){return{ok:!0,body:e}}function P(){return{ok:!1}}function Ra(e,t={__proto__:null}){return e.reduceRight((e,t)=>({[t]:e}),t)}function za(e){return typeof e==`object`&&!!e}function Ba(e,t){let n=t[0];if(!n)throw Error(`Cannot parse the TOML: key length is not a positive number`);return e[n]}function Va(e,t){let{keys:n,type:r,value:i}=t,a=Ba(e,n);if(a===void 0)return Object.assign(e,Ra(n,i));if(Array.isArray(a))return Ua(a.at(-1),{type:r,keys:n.slice(1),value:i}),e;if(za(a))return Ua(a,{type:r,keys:n.slice(1),value:i}),e;throw Error(`Unexpected assign`)}function Ha(e,t){let{type:n,keys:r,value:i}=t,a=Ba(e,r);if(a===void 0)return Object.assign(e,Ra(r,[i]));if(Array.isArray(a))return t.keys.length===1?a.push(i):Ua(a.at(-1),{type:t.type,keys:t.keys.slice(1),value:t.value}),e;if(za(a))return Ua(a,{type:n,keys:r.slice(1),value:i}),e;throw Error(`Unexpected assign`)}function Ua(e,t){switch(t.type){case`Block`:return ka(e,t.value);case`Table`:return Va(e,t);case`TableArray`:return Ha(e,t)}}function Wa(e){return t=>{for(let n of e){let e=n(t);if(e.ok)return e}return P()}}function Ga(e,t){let n=Za(t);return r=>{let i=[],a=e(r);if(!a.ok)return N(i);for(i.push(a.body);!r.eof()&&n(r).ok;){let n=e(r);if(!n.ok)throw SyntaxError(`Invalid token after "${t}"`);i.push(n.body)}return N(i)}}function Ka(e,t){let n=Za(t);return r=>{let i=e(r);if(!i.ok)return P();let a=[i.body];for(;!r.eof()&&n(r).ok;){let n=e(r);if(!n.ok)throw SyntaxError(`Invalid token after "${t}"`);a.push(n.body)}return N(a)}}function qa(e,t,n){let r=Za(t);return i=>{let a=i.position,o=e(i);if(!o.ok)return P();if(!r(i).ok)throw SyntaxError(`key/value pair doesn't have "${t}"`);let s=n(i);if(!s.ok){let e=i.source.indexOf(`
4
- `,i.position),t=e>0?e:i.source.length,n=i.source.slice(a,t);throw SyntaxError(`Cannot parse value on line '${n}'`)}return N(Ra(o.body,s.body))}}function Ja(e){return t=>{let n=e(t);if(!n.ok)return P();let r={__proto__:null};for(let e of n.body)typeof e==`object`&&e&&(r=ka(r,e));return N(r)}}function Ya(e){return t=>{let n=[];for(;!t.eof();){let r=e(t);if(!r.ok)break;n.push(r.body),t.nextUntilChar()}return n.length===0?P():N(n)}}function Xa(e,t,n){let r=Za(e),i=Za(n);return a=>{if(!r(a).ok)return P();let o=t(a);if(!o.ok)throw SyntaxError(`Invalid token after "${e}"`);if(!i(a).ok)throw SyntaxError(`Not closed by "${n}" after started with "${e}"`);return N(o.body)}}function Za(e){return t=>(t.skipWhitespaces(),t.startsWith(e)?(t.next(e.length),t.skipWhitespaces(),N(void 0)):P())}const Qa=/[A-Za-z0-9_-]+/y;function $a(e){e.skipWhitespaces();let t=e.match(Qa)?.[0];return t?(e.next(t.length),N(t)):P()}function eo(e){if(e.char()!==`\\`)return P();switch(e.next(),e.char()){case`b`:return e.next(),N(`\b`);case`t`:return e.next(),N(` `);case`n`:return e.next(),N(`
5
- `);case`f`:return e.next(),N(`\f`);case`r`:return e.next(),N(`\r`);case`u`:case`U`:{let t=e.char()===`u`?4:6,n=parseInt(`0x`+e.slice(1,1+t),16),r=String.fromCodePoint(n);return e.next(t+1),N(r)}case`"`:return e.next(),N(`"`);case`\\`:return e.next(),N(`\\`);default:throw SyntaxError(`Invalid escape sequence: \\${e.char()}`)}}function to(e){if(e.skipWhitespaces(),e.char()!==`"`)return P();e.next();let t=[];for(;e.char()!==`"`&&!e.eof();){if(e.char()===`
6
- `)throw SyntaxError(`Single-line string cannot contain EOL`);let n=eo(e);n.ok?t.push(n.body):(t.push(e.char()),e.next())}if(e.eof())throw SyntaxError(`Single-line string is not closed:\n${t.join(``)}`);return e.next(),N(t.join(``))}function no(e){if(e.skipWhitespaces(),e.char()!==`'`)return P();e.next();let t=[];for(;e.char()!==`'`&&!e.eof();){if(e.char()===`
7
- `)throw SyntaxError(`Single-line string cannot contain EOL`);t.push(e.char()),e.next()}if(e.eof())throw SyntaxError(`Single-line string is not closed:\n${t.join(``)}`);return e.next(),N(t.join(``))}function ro(e){if(e.skipWhitespaces(),!e.startsWith(`"""`))return P();e.next(3),e.char()===`
8
- `?e.next():e.startsWith(`\r
9
- `)&&e.next(2);let t=[];for(;!e.startsWith(`"""`)&&!e.eof();){if(e.startsWith(`\\
10
- `)){e.next(),e.nextUntilChar({skipComments:!1});continue}else if(e.startsWith(`\\\r
11
- `)){e.next(),e.nextUntilChar({skipComments:!1});continue}let n=eo(e);n.ok?t.push(n.body):(t.push(e.char()),e.next())}if(e.eof())throw SyntaxError(`Multi-line string is not closed:\n${t.join(``)}`);return e.char(3)===`"`&&(t.push(`"`),e.next()),e.next(3),N(t.join(``))}function io(e){if(e.skipWhitespaces(),!e.startsWith(`'''`))return P();e.next(3),e.char()===`
12
- `?e.next():e.startsWith(`\r
13
- `)&&e.next(2);let t=[];for(;!e.startsWith(`'''`)&&!e.eof();)t.push(e.char()),e.next();if(e.eof())throw SyntaxError(`Multi-line string is not closed:\n${t.join(``)}`);return e.char(3)===`'`&&(t.push(`'`),e.next()),e.next(3),N(t.join(``))}const ao=/(?:true|false)\b/y;function oo(e){e.skipWhitespaces();let t=e.match(ao);if(!t)return P();let n=t[0];return e.next(n.length),N(n===`true`)}const so=new Map([[`inf`,1/0],[`+inf`,1/0],[`-inf`,-1/0]]),co=/[+-]?inf\b/y;function lo(e){e.skipWhitespaces();let t=e.match(co);if(!t)return P();let n=t[0];return e.next(n.length),N(so.get(n))}const uo=/[+-]?nan\b/y;function fo(e){e.skipWhitespaces();let t=e.match(uo);if(!t)return P();let n=t[0];return e.next(n.length),N(NaN)}const po=Ka(Wa([$a,to,no]),`.`),mo=/0b[01]+(?:_[01]+)*\b/y;function ho(e){e.skipWhitespaces();let t=e.match(mo)?.[0];if(!t)return P();e.next(t.length);let n=t.slice(2).replaceAll(`_`,``),r=parseInt(n,2);return isNaN(r)?P():N(r)}const go=/0o[0-7]+(?:_[0-7]+)*\b/y;function _o(e){e.skipWhitespaces();let t=e.match(go)?.[0];if(!t)return P();e.next(t.length);let n=t.slice(2).replaceAll(`_`,``),r=parseInt(n,8);return isNaN(r)?P():N(r)}const vo=/0x[0-9a-f]+(?:_[0-9a-f]+)*\b/iy;function yo(e){e.skipWhitespaces();let t=e.match(vo)?.[0];if(!t)return P();e.next(t.length);let n=t.slice(2).replaceAll(`_`,``),r=parseInt(n,16);return isNaN(r)?P():N(r)}const bo=/[+-]?(?:0|[1-9][0-9]*(?:_[0-9]+)*)\b/y;function xo(e){e.skipWhitespaces();let t=e.match(bo)?.[0];if(!t)return P();e.next(t.length);let n=t.replaceAll(`_`,``);return N(parseInt(n,10))}const So=/[+-]?(?:0|[1-9][0-9]*(?:_[0-9]+)*)(?:\.[0-9]+(?:_[0-9]+)*)?(?:e[+-]?[0-9]+(?:_[0-9]+)*)?\b/iy;function Co(e){e.skipWhitespaces();let t=e.match(So)?.[0];if(!t)return P();e.next(t.length);let n=t.replaceAll(`_`,``),r=parseFloat(n);return isNaN(r)?P():N(r)}const wo=/(?<year>\d{4})-(?<month>\d{2})-(?<day>\d{2})(?:[ 0-9TZ.:+-]+)?\b/y;function To(e){e.skipWhitespaces();let t=e.match(wo);if(!t)return P();let n=t[0];e.next(n.length);let r=t.groups;if(r.month==`02`){let e=parseInt(r.day);if(e>29)throw SyntaxError(`Invalid date string "${t}"`);let n=parseInt(r.year);if(e>28&&!Ia(n))throw SyntaxError(`Invalid date string "${t}"`)}let i=new Date(n.trim());if(isNaN(i.getTime()))throw SyntaxError(`Invalid date string "${t}"`);return N(i)}const Eo=/(\d{2}):(\d{2}):(\d{2})(?:\.[0-9]+)?\b/y;function Do(e){e.skipWhitespaces();let t=e.match(Eo)?.[0];return t?(e.next(t.length),N(t)):P()}function Oo(e){if(e.skipWhitespaces(),e.char()!==`[`)return P();e.next();let t=[];for(;!e.eof();){e.nextUntilChar();let n=Ao(e);if(!n.ok||(t.push(n.body),e.skipWhitespaces(),e.char()!==`,`))break;e.next()}if(e.nextUntilChar(),e.char()!==`]`)throw SyntaxError(`Array is not closed`);return e.next(),N(t)}function ko(e){if(e.nextUntilChar(),e.char(1)===`}`)return e.next(2),N({__proto__:null});let t=Xa(`{`,Ga(jo,`,`),`}`)(e);if(!t.ok)return P();let n={__proto__:null};for(let e of t.body)n=ka(n,e);return N(n)}const Ao=Wa([ro,io,to,no,oo,lo,fo,To,Do,ho,_o,yo,Co,xo,Oo,ko]),jo=qa(po,`=`,Ao);function Mo(e){e.nextUntilChar();let t=Ja(Ya(jo))(e);return t.ok?N({type:`Block`,value:t.body}):P()}const No=Xa(`[`,po,`]`);function Po(e){e.nextUntilChar();let t=No(e);if(!t.ok)return P();e.nextUntilChar();let n=Mo(e);return N({type:`Table`,keys:t.body,value:n.ok?n.body.value:{__proto__:null}})}const Fo=Xa(`[[`,po,`]]`);function Io(e){e.nextUntilChar();let t=Fo(e);if(!t.ok)return P();e.nextUntilChar();let n=Mo(e);return N({type:`TableArray`,keys:t.body,value:n.ok?n.body.value:{__proto__:null}})}function Lo(e){let t=Ya(Wa([Mo,Io,Po]))(e);return t.ok?N(t.body.reduce(Ua,{__proto__:null})):N({__proto__:null})}function Ro(e,t){let n=e.source.slice(0,e.position).split(`
14
- `);return`Parse error on line ${n.length}, column ${n.at(-1)?.length??0}: ${t}`}function zo(e){return t=>{let n=new La(t);try{let t=e(n);if(t.ok&&n.eof())return t.body;let r=`Unexpected character: "${n.char()}"`;throw SyntaxError(Ro(n,r))}catch(e){throw e instanceof Error?SyntaxError(Ro(n,e.message)):SyntaxError(Ro(n,`Invalid error type caught`))}}}function Bo(e){return zo(Lo)(e)}const Vo=(e,t)=>{switch(t._tag){case`StringKeyword`:case`TemplateLiteral`:return Object.keys(e);case`SymbolKeyword`:return Object.getOwnPropertySymbols(e);case`Refinement`:return Vo(e,t.from)}},Ho=e=>{let t=!1,n;return()=>t?n:(n=e(),t=!0,n)},Uo=e=>Array.isArray(e),Wo=e=>!Array.isArray(e),Go=e=>`[${p(e)}]`,Ko=e=>Uo(e)?e.map(Go).join(``):Go(e),qo=(e,n,r,i)=>{let a=e;return r&&t(r)&&(a+=`\nat path: ${Ko(r)}`),n!==void 0&&(a+=`\ndetails: ${n}`),i&&(a+=`\nschema (${i._tag}): ${i}`),a},Jo=e=>qo(`Invalid Argument`,e),Yo=(e,t,n)=>qo(`Unsupported schema or overlapping types`,`cannot extend ${e} with ${t}`,n),Xo=e=>qo(`Unsupported key schema`,void 0,void 0,e),Zo=e=>qo(`Unsupported literal`,`literal value: ${l(e)}`),Qo=e=>qo(`Duplicate index signature`,`${e} index signature`),$o=qo(`Unsupported index signature parameter`,"An index signature parameter type must be `string`, `symbol`, a template literal type or a refinement of the previous types"),es=qo(`Invalid element`,`A required element cannot follow an optional element. ts(1257)`),ts=e=>qo(`Duplicate property signature transformation`,`Duplicate key ${l(e)}`),ns=e=>qo(`Duplicate property signature`,`Duplicate key ${l(e)}`),rs=Symbol.for(`effect/SchemaId/DateFromSelf`),is=Symbol.for(`effect/SchemaId/GreaterThan`),as=Symbol.for(`effect/SchemaId/GreaterThanOrEqualTo`),os=Symbol.for(`effect/SchemaId/LessThan`),ss=Symbol.for(`effect/SchemaId/LessThanOrEqualTo`),cs=Symbol.for(`effect/SchemaId/Int`),ls=Symbol.for(`effect/SchemaId/NonNaN`),us=Symbol.for(`effect/SchemaId/Finite`),ds=Symbol.for(`effect/SchemaId/JsonNumber`),fs=Symbol.for(`effect/SchemaId/Between`),ps=Symbol.for(`effect/SchemaId/GreaterThanOrEqualToBigint`),ms=Symbol.for(`effect/SchemaId/BetweenBigint`),hs=Symbol.for(`effect/SchemaId/MinLength`),gs=Symbol.for(`effect/SchemaId/Length`),_s=Symbol.for(`effect/SchemaId/MinItems`),vs=Symbol.for(`effect/annotation/TypeConstructor`),ys=Symbol.for(`effect/annotation/Brand`),bs=Symbol.for(`effect/annotation/SchemaId`),xs=Symbol.for(`effect/annotation/Message`),Ss=Symbol.for(`effect/annotation/MissingMessage`),Cs=Symbol.for(`effect/annotation/Identifier`),ws=Symbol.for(`effect/annotation/Title`),Ts=Symbol.for(`effect/annotation/AutoTitle`),Es=Symbol.for(`effect/annotation/Description`),Ds=Symbol.for(`effect/annotation/Examples`),Os=Symbol.for(`effect/annotation/Default`),ks=Symbol.for(`effect/annotation/JSONSchema`),As=Symbol.for(`effect/annotation/Arbitrary`),js=Symbol.for(`effect/annotation/Pretty`),Ms=Symbol.for(`effect/annotation/Equivalence`),Ns=Symbol.for(`effect/annotation/Documentation`),Ps=Symbol.for(`effect/annotation/Concurrency`),Fs=Symbol.for(`effect/annotation/Batching`),Is=Symbol.for(`effect/annotation/ParseIssueTitle`),Ls=Symbol.for(`effect/annotation/ParseOptions`),Rs=Symbol.for(`effect/annotation/DecodingFallback`),zs=Symbol.for(`effect/annotation/Surrogate`),Bs=Symbol.for(`effect/annotation/StableFilter`),F=x(2,(e,t)=>Object.prototype.hasOwnProperty.call(e.annotations,t)?w(e.annotations[t]):v()),Vs=F(ys),Hs=F(xs),Us=F(Ss),Ws=F(ws),Gs=F(Ts),Ks=F(Cs),qs=F(Es),Js=F(Ps),Ys=F(Fs),Xs=F(Is),Zs=F(Ls),Qs=F(Rs),$s=F(zs),ec=F(Bs),tc=e=>$t(ec(e),e=>e===!0),nc=Symbol.for(`effect/annotation/JSONIdentifier`),rc=F(nc),ic=e=>pe(rc(e),()=>Ks(e));var ac=class{typeParameters;decodeUnknown;encodeUnknown;annotations;_tag=`Declaration`;constructor(e,t,n,r={}){this.typeParameters=e,this.decodeUnknown=t,this.encodeUnknown=n,this.annotations=r}toString(){return Ne(vl(this),()=>`<declaration schema>`)}toJSON(){return{_tag:this._tag,typeParameters:this.typeParameters.map(e=>e.toJSON()),annotations:R(this.annotations)}}};const oc=e=>t=>t._tag===e;var sc=class{literal;annotations;_tag=`Literal`;constructor(e,t={}){this.literal=e,this.annotations=t}toString(){return Ne(vl(this),()=>l(this.literal))}toJSON(){return{_tag:this._tag,literal:oe(this.literal)?String(this.literal):this.literal,annotations:R(this.annotations)}}};const cc=oc(`Literal`);var lc=class{symbol;annotations;_tag=`UniqueSymbol`;constructor(e,t={}){this.symbol=e,this.annotations=t}toString(){return Ne(vl(this),()=>l(this.symbol))}toJSON(){return{_tag:this._tag,symbol:String(this.symbol),annotations:R(this.annotations)}}};const uc=new class{annotations;_tag=`UndefinedKeyword`;constructor(e={}){this.annotations=e}toString(){return hl(this)}toJSON(){return{_tag:this._tag,annotations:R(this.annotations)}}}({[ws]:`undefined`}),dc=new class{annotations;_tag=`NeverKeyword`;constructor(e={}){this.annotations=e}toString(){return hl(this)}toJSON(){return{_tag:this._tag,annotations:R(this.annotations)}}}({[ws]:`never`}),fc=new class{annotations;_tag=`UnknownKeyword`;constructor(e={}){this.annotations=e}toString(){return hl(this)}toJSON(){return{_tag:this._tag,annotations:R(this.annotations)}}}({[ws]:`unknown`}),pc=new class{annotations;_tag=`AnyKeyword`;constructor(e={}){this.annotations=e}toString(){return hl(this)}toJSON(){return{_tag:this._tag,annotations:R(this.annotations)}}}({[ws]:`any`}),mc=new class{annotations;_tag=`StringKeyword`;constructor(e={}){this.annotations=e}toString(){return hl(this)}toJSON(){return{_tag:this._tag,annotations:R(this.annotations)}}}({[ws]:`string`,[Es]:`a string`}),hc=oc(`StringKeyword`),gc=new class{annotations;_tag=`NumberKeyword`;constructor(e={}){this.annotations=e}toString(){return hl(this)}toJSON(){return{_tag:this._tag,annotations:R(this.annotations)}}}({[ws]:`number`,[Es]:`a number`}),_c=oc(`NumberKeyword`),vc=new class{annotations;_tag=`BooleanKeyword`;constructor(e={}){this.annotations=e}toString(){return hl(this)}toJSON(){return{_tag:this._tag,annotations:R(this.annotations)}}}({[ws]:`boolean`,[Es]:`a boolean`}),yc=oc(`BooleanKeyword`),bc=new class{annotations;_tag=`BigIntKeyword`;constructor(e={}){this.annotations=e}toString(){return hl(this)}toJSON(){return{_tag:this._tag,annotations:R(this.annotations)}}}({[ws]:`bigint`,[Es]:`a bigint`}),xc=new class{annotations;_tag=`SymbolKeyword`;constructor(e={}){this.annotations=e}toString(){return hl(this)}toJSON(){return{_tag:this._tag,annotations:R(this.annotations)}}}({[ws]:`symbol`,[Es]:`a symbol`}),Sc=oc(`SymbolKeyword`);var Cc=class{type;annotations;constructor(e,t={}){this.type=e,this.annotations=t}toJSON(){return{type:this.type.toJSON(),annotations:R(this.annotations)}}toString(){return String(this.type)}},wc=class extends Cc{isOptional;constructor(e,t,n={}){super(e,n),this.isOptional=t}toJSON(){return{type:this.type.toJSON(),isOptional:this.isOptional,annotations:R(this.annotations)}}toString(){return String(this.type)+(this.isOptional?`?`:``)}};const Tc=e=>e.map(e=>e.type);var Ec=class{elements;rest;isReadonly;annotations;_tag=`TupleType`;constructor(e,t,n,r={}){this.elements=e,this.rest=t,this.isReadonly=n,this.annotations=r;let i=!1,a=!1;for(let t of e)if(t.isOptional)i=!0;else if(i){a=!0;break}if(a||i&&t.length>1)throw Error(es)}toString(){return Ne(vl(this),()=>Dc(this))}toJSON(){return{_tag:this._tag,elements:this.elements.map(e=>e.toJSON()),rest:this.rest.map(e=>e.toJSON()),isReadonly:this.isReadonly,annotations:R(this.annotations)}}};const Dc=e=>{let t=e.elements.map(String).join(`, `);return $e(e.rest,{onEmpty:()=>`readonly [${t}]`,onNonEmpty:(n,r)=>{let i=String(n),a=i.includes(` | `)?`(${i})`:i;if(r.length>0){let n=r.map(String).join(`, `);return e.elements.length>0?`readonly [${t}, ...${a}[], ${n}]`:`readonly [...${a}[], ${n}]`}else if(e.elements.length>0)return`readonly [${t}, ...${a}[]]`;else return`ReadonlyArray<${i}>`}})};var I=class extends wc{name;isReadonly;constructor(e,t,n,r,i){super(t,n,i),this.name=e,this.isReadonly=r}toString(){return(this.isReadonly?`readonly `:``)+String(this.name)+(this.isOptional?`?`:``)+`: `+this.type}toJSON(){return{name:String(this.name),type:this.type.toJSON(),isOptional:this.isOptional,isReadonly:this.isReadonly,annotations:R(this.annotations)}}};const Oc=e=>{switch(e._tag){case`StringKeyword`:case`SymbolKeyword`:case`TemplateLiteral`:return!0;case`Refinement`:return Oc(e.from)}return!1};var kc=class{type;isReadonly;parameter;constructor(e,t,n){if(this.type=t,this.isReadonly=n,Oc(e))this.parameter=e;else throw Error($o)}toString(){return(this.isReadonly?`readonly `:``)+`[x: ${this.parameter}]: ${this.type}`}toJSON(){return{parameter:this.parameter.toJSON(),type:this.type.toJSON(),isReadonly:this.isReadonly}}},Ac=class{annotations;_tag=`TypeLiteral`;propertySignatures;indexSignatures;constructor(e,t,n={}){this.annotations=n;let r={};for(let t=0;t<e.length;t++){let n=e[t].name;if(Object.prototype.hasOwnProperty.call(r,n))throw Error(ns(n));r[n]=null}let i={string:!1,symbol:!1};for(let e=0;e<t.length;e++){let n=ml(t[e].parameter);if(hc(n)){if(i.string)throw Error(Qo(`string`));i.string=!0}else if(Sc(n)){if(i.symbol)throw Error(Qo(`symbol`));i.symbol=!0}}this.propertySignatures=e,this.indexSignatures=t}toString(){return Ne(vl(this),()=>Mc(this))}toJSON(){return{_tag:this._tag,propertySignatures:this.propertySignatures.map(e=>e.toJSON()),indexSignatures:this.indexSignatures.map(e=>e.toJSON()),annotations:R(this.annotations)}}};const jc=e=>e.map(String).join(`; `),Mc=e=>{if(e.propertySignatures.length>0){let t=e.propertySignatures.map(String).join(`; `);return e.indexSignatures.length>0?`{ ${t}; ${jc(e.indexSignatures)} }`:`{ ${t} }`}else if(e.indexSignatures.length>0)return`{ ${jc(e.indexSignatures)} }`;else return`{}`},Nc=oc(`TypeLiteral`),Pc=Ut(kn(fn,e=>{switch(e._tag){case`AnyKeyword`:return 0;case`UnknownKeyword`:return 1;case`ObjectKeyword`:return 2;case`StringKeyword`:case`NumberKeyword`:case`BooleanKeyword`:case`BigIntKeyword`:case`SymbolKeyword`:return 3}return 4})),Fc={string:`StringKeyword`,number:`NumberKeyword`,boolean:`BooleanKeyword`,bigint:`BigIntKeyword`},Ic=e=>Ve(e,e=>Vc(e)?Ic(e.types):[e]),Lc=e=>{let t=Pc(e),n=[],r={},i=[];for(let e of t)switch(e._tag){case`NeverKeyword`:break;case`AnyKeyword`:return[pc];case`UnknownKeyword`:return[fc];case`ObjectKeyword`:case`UndefinedKeyword`:case`VoidKeyword`:case`StringKeyword`:case`NumberKeyword`:case`BooleanKeyword`:case`BigIntKeyword`:case`SymbolKeyword`:r[e._tag]||(r[e._tag]=e,n.push(e));break;case`Literal`:{let t=typeof e.literal;switch(t){case`string`:case`number`:case`bigint`:case`boolean`:!r[Fc[t]]&&!i.includes(e.literal)&&(i.push(e.literal),n.push(e));break;case`object`:i.includes(e.literal)||(i.push(e.literal),n.push(e));break}break}case`UniqueSymbol`:!r.SymbolKeyword&&!i.includes(e.symbol)&&(i.push(e.symbol),n.push(e));break;case`TupleType`:r.ObjectKeyword||n.push(e);break;case`TypeLiteral`:e.propertySignatures.length===0&&e.indexSignatures.length===0?r[`{}`]||(r[`{}`]=e,n.push(e)):r.ObjectKeyword||n.push(e);break;default:n.push(e)}return n};var Rc=class e{types;annotations;static make=(t,n)=>Bc(t)?new e(t,n):t.length===1?t[0]:dc;static unify=(t,n)=>e.make(Lc(Ic(t)),n);_tag=`Union`;constructor(e,t={}){this.types=e,this.annotations=t}toString(){return Ne(vl(this),()=>this.types.map(String).join(` | `))}toJSON(){return{_tag:this._tag,types:this.types.map(e=>e.toJSON()),annotations:R(this.annotations)}}};const zc=(e,t)=>e.map(t),Bc=e=>e.length>1,Vc=oc(`Union`),Hc=st(Symbol.for(`effect/Schema/AST/toJSONMemoMap`),()=>new WeakMap);var Uc=class{f;annotations;_tag=`Suspend`;constructor(e,t={}){this.f=e,this.annotations=t,this.f=Ho(e)}toString(){return vl(this).pipe(pe(()=>Zt(ve(this.f)(),e=>vl(e))),Ne(()=>`<suspended schema>`))}toJSON(){let e=this.f(),t=Hc.get(e);return t||(Hc.set(e,{_tag:this._tag}),t={_tag:this._tag,ast:e.toJSON(),annotations:R(this.annotations)},Hc.set(e,t),t)}},Wc=class{from;filter;annotations;_tag=`Refinement`;constructor(e,t,n={}){this.from=e,this.filter=t,this.annotations=n}toString(){return Ks(this).pipe(Ne(()=>_(_l(this),{onNone:()=>`{ ${this.from} | filter }`,onSome:e=>Gc(this.from)?String(this.from)+` & `+e:e})))}toJSON(){return{_tag:this._tag,from:this.from.toJSON(),annotations:R(this.annotations)}}};const Gc=oc(`Refinement`),Kc={};var qc=class{from;to;transformation;annotations;_tag=`Transformation`;constructor(e,t,n,r={}){this.from=e,this.to=t,this.transformation=n,this.annotations=r}toString(){return Ne(vl(this),()=>`(${String(this.from)} <-> ${String(this.to)})`)}toJSON(){return{_tag:this._tag,from:this.from.toJSON(),to:this.to.toJSON(),annotations:R(this.annotations)}}};const Jc=oc(`Transformation`);var Yc=class{decode;encode;_tag=`FinalTransformation`;constructor(e,t){this.decode=e,this.encode=t}};const Xc=e=>t=>t._tag===e,Zc=new class{_tag=`ComposeTransformation`};var Qc=class{from;to;decode;encode;constructor(e,t,n,r){this.from=e,this.to=t,this.decode=n,this.encode=r}},$c=class{propertySignatureTransformations;_tag=`TypeLiteralTransformation`;constructor(e){this.propertySignatureTransformations=e;let t={},n={};for(let r of e){let e=r.from;if(t[e])throw Error(ts(e));t[e]=!0;let i=r.to;if(n[i])throw Error(ts(i));n[i]=!0}}};const el=Xc(`TypeLiteralTransformation`),tl=(e,t)=>{let n=Object.getOwnPropertyDescriptors(e),r={...e.annotations};delete r[Cs];let i={...r,...t},a=$s(e);return bt(a)&&(i[zs]=tl(a.value,t)),n.annotations.value=i,Object.create(Object.getPrototypeOf(e),n)},nl=(e,t)=>{switch(e._tag){case`Literal`:return zn(String(e.literal));case`StringKeyword`:return`[\\s\\S]*?`;case`NumberKeyword`:return`[+-]?\\d*\\.?\\d+(?:[Ee][+-]?\\d+)?`;case`TemplateLiteral`:return il(e,t,!1);case`Union`:return e.types.map(e=>nl(e,t)).join(`|`)}},rl=(e,t,n,r)=>{if(Vc(e)){if(n&&!r)return`(?:${t})`}else if(!n||!r)return t;return`(${t})`},il=(e,t,n)=>{let r=``;if(e.head!==``){let i=zn(e.head);r+=t&&n?`(${i})`:i}for(let i of e.spans){let e=nl(i.type,t);if(r+=rl(i.type,e,t,n),i.literal!==``){let e=zn(i.literal);r+=t&&n?`(${e})`:e}}return r},al=e=>RegExp(`^${il(e,!1,!0)}$`),ol=(e,t)=>{let n=[],r=[],i=e=>{switch(e._tag){case`NeverKeyword`:break;case`StringKeyword`:case`SymbolKeyword`:case`TemplateLiteral`:case`Refinement`:r.push(new kc(e,t,!0));break;case`Literal`:if(Qe(e.literal)||Vt(e.literal))n.push(new I(e.literal,t,!1,!0));else throw Error(Zo(e.literal));break;case`Enums`:for(let[r,i]of e.enums)n.push(new I(i,t,!1,!0));break;case`UniqueSymbol`:n.push(new I(e.symbol,t,!1,!0));break;case`Union`:e.types.forEach(i);break;default:throw Error(Xo(e))}};return i(e),{propertySignatures:n,indexSignatures:r}},sl=e=>t=>{let n;for(let r of e)Object.prototype.hasOwnProperty.call(t.annotations,r)&&(n===void 0&&(n={}),n[r]=t.annotations[r]);return n},cl=e=>t=>{let n={...t.annotations};for(let t of e)delete n[t];return n},ll=sl([Ds,Os,ks,As,js,Ms]),L=e=>{switch(e._tag){case`Declaration`:{let t=ul(e.typeParameters,L);return t===e.typeParameters?e:new ac(t,e.decodeUnknown,e.encodeUnknown,e.annotations)}case`TupleType`:{let t=ul(e.elements,e=>{let t=L(e.type);return t===e.type?e:new wc(t,e.isOptional)}),n=Tc(e.rest),r=ul(n,L);return t===e.elements&&r===n?e:new Ec(t,r.map(e=>new Cc(e)),e.isReadonly,e.annotations)}case`TypeLiteral`:{let t=ul(e.propertySignatures,e=>{let t=L(e.type);return t===e.type?e:new I(e.name,t,e.isOptional,e.isReadonly)}),n=ul(e.indexSignatures,e=>{let t=L(e.type);return t===e.type?e:new kc(e.parameter,t,e.isReadonly)});return t===e.propertySignatures&&n===e.indexSignatures?e:new Ac(t,n,e.annotations)}case`Union`:{let t=ul(e.types,L);return t===e.types?e:Rc.make(t,e.annotations)}case`Suspend`:return new Uc(()=>L(e.f()),e.annotations);case`Refinement`:{let t=L(e.from);return t===e.from?e:new Wc(t,e.filter,e.annotations)}case`Transformation`:{let t=ll(e);return L(t===void 0?e.to:tl(e.to,t))}}return e};function ul(e,t){let n=!1,r=ae(e.length);for(let i=0;i<e.length;i++){let a=e[i],o=t(a);o!==a&&(n=!0),r[i]=o}return n?r:e}const dl=e=>{switch(e._tag){case`Transformation`:return e.from;case`Refinement`:return dl(e.from);case`Suspend`:return dl(e.f())}},fl=(e,t)=>{switch(e._tag){case`Declaration`:{let n=ul(e.typeParameters,e=>fl(e,t));return n===e.typeParameters?e:new ac(n,e.decodeUnknown,e.encodeUnknown)}case`TupleType`:{let n=ul(e.elements,e=>{let n=fl(e.type,t);return n===e.type?e:new wc(n,e.isOptional)}),r=Tc(e.rest),i=ul(r,e=>fl(e,t));return n===e.elements&&i===r?e:new Ec(n,i.map(e=>new Cc(e)),e.isReadonly)}case`TypeLiteral`:{let n=ul(e.propertySignatures,e=>{let n=fl(e.type,t);return n===e.type?e:new I(e.name,n,e.isOptional,e.isReadonly)}),r=ul(e.indexSignatures,e=>{let n=fl(e.type,t);return n===e.type?e:new kc(e.parameter,n,e.isReadonly)});return n===e.propertySignatures&&r===e.indexSignatures?e:new Ac(n,r)}case`Union`:{let n=ul(e.types,e=>fl(e,t));return n===e.types?e:Rc.make(n)}case`Suspend`:{let n,r=ic(e);if(bt(r)){let e=t?`Bound`:``;n={[nc]:`${r.value}Encoded${e}`}}return new Uc(()=>fl(e.f(),t),n)}case`Refinement`:{let n=fl(e.from,t);return t?n===e.from?e:dl(e.from)===void 0&&tc(e)?new Wc(n,e.filter,e.annotations):n:n}case`Transformation`:return fl(e.from,t)}return e},pl=e=>fl(e,!1),R=e=>{let t={};for(let n of Object.getOwnPropertySymbols(e))t[String(n)]=e[n];return t},ml=e=>{switch(e._tag){case`StringKeyword`:case`SymbolKeyword`:case`TemplateLiteral`:return e;case`Refinement`:return ml(e.from)}},hl=e=>Ne(vl(e),()=>e._tag);function gl(e){return _(Vs(e),{onNone:()=>``,onSome:e=>e.map(e=>` & Brand<${l(e)}>`).join(``)})}const _l=e=>Ws(e).pipe(pe(()=>qs(e)),pe(()=>Gs(e)),Ce(t=>t+gl(e))),vl=e=>pe(Ks(e),()=>_l(e)),yl=/^[+-]?\d+$/,bl=Symbol.for(`effect/BigDecimal`),xl={[bl]:bl,[a](){let e=Ol(this);return C(de(e.value),ie(Ee(e.scale)),h(this))},[he](e){return Sl(e)&&Ml(this,e)},toString(){return`BigDecimal(${Il(this)})`},toJSON(){return{_id:`BigDecimal`,value:String(this.value),scale:this.scale}},[s](){return this.toJSON()},pipe(){return De(this,arguments)}},Sl=e=>Nt(e,bl),Cl=(e,t)=>{let n=Object.create(xl);return n.value=e,n.scale=t,n},wl=(e,t)=>{if(e!==Tl&&e%El===Tl)throw RangeError(`Value must be normalized`);let n=Cl(e,t);return n.normalized=n,n},Tl=BigInt(0),El=BigInt(10),Dl=wl(Tl,0),Ol=e=>{if(e.normalized===void 0)if(e.value===Tl)e.normalized=Dl;else{let t=`${e.value}`,n=0;for(let e=t.length-1;e>=0&&t[e]===`0`;e--)n++;n===0&&(e.normalized=e);let r=BigInt(t.substring(0,t.length-n)),i=e.scale-n;e.normalized=wl(r,i)}return e.normalized},kl=x(2,(e,t)=>t>e.scale?Cl(e.value*El**BigInt(t-e.scale),t):t<e.scale?Cl(e.value/El**BigInt(e.scale-t),t):e),Al=e=>e.value<Tl?Cl(-e.value,e.scale):e,jl=jt((e,t)=>e.scale>t.scale?kl(t,e.scale).value===e.value:e.scale<t.scale?kl(e,t.scale).value===t.value:e.value===t.value),Ml=x(2,(e,t)=>jl(e,t)),Nl=e=>m(Pl(e),()=>RangeError(`Number must be finite, got ${e}`)),Pl=e=>{if(!Number.isFinite(e))return v();let t=`${e}`;if(t.includes(`e`))return Fl(t);let[n,r=``]=t.split(`.`);return w(Cl(BigInt(`${n}${r}`),r.length))},Fl=e=>{if(e===``)return w(Dl);let t,n,r=e.search(/[eE]/);if(r!==-1){let i=e.slice(r+1);if(t=e.slice(0,r),n=Number(i),t===``||!Number.isSafeInteger(n)||!yl.test(i))return v()}else t=e,n=0;let i,a,o=t.search(/\./);if(o!==-1){let e=t.slice(0,o),n=t.slice(o+1);i=`${e}${n}`,a=n.length}else i=t,a=0;if(!yl.test(i))return v();let s=a-n;return Number.isSafeInteger(s)?w(Cl(BigInt(i),s)):v()},Il=e=>{let t=Ol(e);if(Math.abs(t.scale)>=16)return Ll(t);let n=t.value<Tl,r=n?`${t.value}`.substring(1):`${t.value}`,i,a;if(t.scale>=r.length)i=`0`,a=`0`.repeat(t.scale-r.length)+r;else{let e=r.length-t.scale;if(e>r.length){let t=e-r.length;i=`${r}${`0`.repeat(t)}`,a=``}else a=r.slice(e),i=r.slice(0,e)}let o=a===``?i:`${i}.${a}`;return n?`-${o}`:o},Ll=e=>{if(zl(e))return`0e+0`;let t=Ol(e),n=`${Al(t).value}`,r=n.slice(0,1),i=n.slice(1),a=`${Bl(t)?`-`:``}${r}`;i!==``&&(a+=`.${i}`);let o=i.length-t.scale;return`${a}e${o>=0?`+`:``}${o}`},Rl=e=>Number(Il(e)),zl=e=>e.value===Tl,Bl=e=>e.value<Tl,Vl=e=>e>BigInt(2**53-1)||e<BigInt(-(2**53-1))?v():w(Number(e)),Hl=e=>{try{return e.trim()===``?v():w(BigInt(e))}catch{return v()}},Ul=e=>{if(e>2**53-1||e<-(2**53-1))return v();try{return w(BigInt(e))}catch{return v()}},Wl=Symbol.for(`effect/Brand/Refined`),Gl=()=>Object.assign(e=>e,{[Wl]:Wl,option:e=>w(e),either:e=>b(e),is:e=>!0}),Kl=jn,ql=hn,Jl=Cn,Yl=vn,Xl=Symbol.for(`effect/QueueEnqueue`),Zl=Symbol.for(`effect/QueueDequeue`),Ql=Symbol.for(`effect/QueueStrategy`),$l=Symbol.for(`effect/BackingQueue`),eu={_A:e=>e},tu={_A:e=>e},nu={_In:e=>e},ru={_Out:e=>e};var iu=class extends In{queue;takers;shutdownHook;shutdownFlag;strategy;[Xl]=nu;[Zl]=ru;constructor(e,t,n,r,i){super(),this.queue=e,this.takers=t,this.shutdownHook=n,this.shutdownFlag=r,this.strategy=i}pipe(){return De(this,arguments)}commit(){return this.take}capacity(){return this.queue.capacity()}get size(){return Jt(()=>xt(this.unsafeSize(),()=>u))}unsafeSize(){return Le(this.shutdownFlag)?v():w(this.queue.length()-sn(this.takers)+this.strategy.surplusSize())}get isEmpty(){return We(this.size,e=>e<=0)}get isFull(){return We(this.size,e=>e>=this.capacity())}get shutdown(){return Ct(fe(e=>(C(this.shutdownFlag,Pe(!0)),C(Lr(Du(this.takers),t=>ot(t,e.id()),!1,!1),ce(this.strategy.shutdown),Se(ct(this.shutdownHook,void 0)),qt))))}get isShutdown(){return Me(()=>Le(this.shutdownFlag))}get awaitShutdown(){return zt(this.shutdownHook)}isActive(){return!Le(this.shutdownFlag)}unsafeOffer(e){if(Le(this.shutdownFlag))return!1;let t;if(this.queue.length()===0){let n=C(this.takers,pn(Xr));n===Xr?t=!1:(Tu(n,e),t=!0)}else t=!1;if(t)return!0;let n=this.queue.offer(e);return Au(this.strategy,this.queue,this.takers),n}offer(e){return Jt(()=>{if(Le(this.shutdownFlag))return u;let t;if(this.queue.length()===0){let n=C(this.takers,pn(Xr));n===Xr?t=!1:(Tu(n,e),t=!0)}else t=!1;if(t)return c(!0);let n=this.queue.offer(e);return Au(this.strategy,this.queue,this.takers),n?c(!0):this.strategy.handleSurplus([e],this.queue,this.takers,this.shutdownFlag)})}offerAll(e){return Jt(()=>{if(Le(this.shutdownFlag))return u;let t=ue(e),n=this.queue.length()===0?ue(Ou(this.takers,t.length)):Re,[r,i]=C(t,ft(n.length));for(let e=0;e<n.length;e++){let t=n[e],i=r[e];Tu(t,i)}if(i.length===0)return c(!0);let a=this.queue.offerAll(i);return Au(this.strategy,this.queue,this.takers),je(a)?c(!0):this.strategy.handleSurplus(a,this.queue,this.takers,this.shutdownFlag)})}get take(){return fe(e=>{if(Le(this.shutdownFlag))return u;let t=this.queue.poll(Xr);if(t!==Xr)return this.strategy.unsafeOnQueueEmptySpace(this.queue,this.takers),c(t);{let t=Mt(e.id());return C(Jt(()=>(C(this.takers,Wr(t)),Au(this.strategy,this.queue,this.takers),Le(this.shutdownFlag)?u:zt(t))),at(()=>Me(()=>ku(this.takers,t))))}})}get takeAll(){return Jt(()=>Le(this.shutdownFlag)?u:Me(()=>{let e=this.queue.pollUpTo(1/0);return this.strategy.unsafeOnQueueEmptySpace(this.queue,this.takers),Oe(e)}))}takeUpTo(e){return Jt(()=>Le(this.shutdownFlag)?u:Me(()=>{let t=this.queue.pollUpTo(e);return this.strategy.unsafeOnQueueEmptySpace(this.queue,this.takers),Oe(t)}))}takeBetween(e,t){return Jt(()=>au(this,e,t,tt()))}};const au=(e,t,n,r)=>n<t?c(r):C(vu(e,n),Gt(i=>{let a=t-i.length;return a===1?C(_u(e),We(e=>C(r,Qt(i),Kt(e)))):a>1?C(_u(e),Gt(t=>au(e,a-1,n-i.length-1,C(r,Qt(i),Kt(t))))):c(C(r,Qt(i)))})),ou=e=>C(Me(()=>Qn(e)),Gt(e=>du(pu(e),yu()))),su=e=>C(Me(()=>Qn(e)),Gt(e=>du(pu(e),bu()))),cu=e=>C(Me(()=>Qn(e)),Gt(e=>du(pu(e),xu()))),lu=()=>C(Me(()=>An()),Gt(e=>du(pu(e),bu()))),uu=(e,t,n,r,i)=>new iu(e,t,n,r,i),du=(e,t)=>C(Wt(),We(n=>uu(e,An(),n,ne(!1),t)));var fu=class{mutable;[$l]=tu;constructor(e){this.mutable=e}poll(e){return pn(this.mutable,e)}pollUpTo(e){return un(this.mutable,e)}offerAll(e){return Bn(this.mutable,e)}offer(e){return Wr(this.mutable,e)}capacity(){return qr(this.mutable)}length(){return sn(this.mutable)}};const pu=e=>new fu(e),mu=e=>e.size,hu=e=>e.shutdown,gu=x(2,(e,t)=>e.offer(t)),_u=e=>e.take,vu=x(2,(e,t)=>e.takeUpTo(t)),yu=()=>new Su,bu=()=>new Cu,xu=()=>new wu;var Su=class{[Ql]=eu;putters=An();surplusSize(){return sn(this.putters)}onCompleteTakersWithEmptyQueue(e){for(;!Ln(this.putters)&&!Ln(e);){let t=pn(e,void 0),n=pn(this.putters,void 0);n[2]&&Tu(n[1],!0),Tu(t,n[0])}}get shutdown(){return C(_t,Gt(e=>C(Me(()=>Du(this.putters)),Gt(t=>Lr(t,([t,n,r])=>r?C(ot(n,e),qt):_e,!1,!1)))))}handleSurplus(e,t,n,r){return fe(i=>{let a=Mt(i.id());return C(Jt(()=>(this.unsafeOffer(e,a),this.unsafeOnQueueEmptySpace(t,n),Au(this,t,n),Le(r)?u:zt(a))),at(()=>Me(()=>this.unsafeRemove(a))))})}unsafeOnQueueEmptySpace(e,t){let n=!0;for(;n&&(e.capacity()===1/0||e.length()<e.capacity());){let r=C(this.putters,pn(Xr));if(r===Xr)n=!1;else{let n=e.offer(r[0]);n&&r[2]?Tu(r[1],!0):n||Eu(this.putters,C(Du(this.putters),St(r))),Au(this,e,t)}}}unsafeOffer(e,t){let n=ue(e);for(let e=0;e<n.length;e++){let r=n[e];e===n.length-1?C(this.putters,Wr([r,t,!0])):C(this.putters,Wr([r,t,!1]))}}unsafeRemove(e){Eu(this.putters,C(Du(this.putters),Xt(([,t])=>t!==e)))}},Cu=class{[Ql]=eu;surplusSize(){return 0}get shutdown(){return _e}onCompleteTakersWithEmptyQueue(){}handleSurplus(e,t,n,r){return c(!1)}unsafeOnQueueEmptySpace(e,t){}},wu=class{[Ql]=eu;surplusSize(){return 0}get shutdown(){return _e}onCompleteTakersWithEmptyQueue(){}handleSurplus(e,t,n,r){return Me(()=>(this.unsafeOffer(t,e),Au(this,t,n),!0))}unsafeOnQueueEmptySpace(e,t){}unsafeOffer(e,t){let n=t[Symbol.iterator](),r,i=!0;for(;!(r=n.next()).done&&i;){if(e.capacity()===0)return;e.poll(Xr),i=e.offer(r.value)}}};const Tu=(e,t)=>pt(e,c(t)),Eu=(e,t)=>C(e,Bn(t)),Du=e=>C(e,un(1/0)),Ou=(e,t)=>C(e,un(t)),ku=(e,t)=>{Eu(e,C(Du(e),Xt(e=>t!==e)))},Au=(e,t,n)=>{let r=!0;for(;r&&t.length()!==0;){let i=C(n,pn(Xr));if(i!==Xr){let a=t.poll(Xr);a===Xr?Eu(n,C(Du(n),St(i))):(Tu(i,a),e.unsafeOnQueueEmptySpace(t,n)),r=!0}else r=!1}r&&t.length()===0&&!Ln(n)&&e.onCompleteTakersWithEmptyQueue(n)},ju=ou,Mu=su,Nu=cu,Pu=lu,Fu=mu,Iu=hu,Lu=gu,Ru=_u,zu=`Continue`,Bu=Symbol.for(`effect/ChannelChildExecutorDecision`),Vu={[Bu]:Bu},Hu=e=>{let t=Object.create(Vu);return t._tag=zu,t},Uu=Symbol.for(`effect/ChannelContinuation`),Wu={_Env:e=>e,_InErr:e=>e,_InElem:e=>e,_InDone:e=>e,_OutErr:e=>e,_OutDone:e=>e,_OutErr2:e=>e,_OutElem:e=>e,_OutDone2:e=>e};var Gu=class{onSuccess;onHalt;_tag=`ContinuationK`;[Uu]=Wu;constructor(e,t){this.onSuccess=e,this.onHalt=t}onExit(e){return xi(e)?this.onHalt(e.cause):this.onSuccess(e.value)}},Ku=class{finalizer;_tag=`ContinuationFinalizer`;[Uu]=Wu;constructor(e){this.finalizer=e}};const qu=`PullAfterNext`,Ju=Symbol.for(`effect/ChannelUpstreamPullStrategy`),Yu={_A:e=>e},Xu={[Ju]:Yu},Zu=e=>{let t=Object.create(Xu);return t._tag=qu,t.emitSeparator=e,t},Qu=`BracketOut`,$u=`Bridge`,ed=`ConcatAll`,td=`Emit`,nd=`Ensuring`,rd=`Fail`,id=`Fold`,ad=`FromEffect`,od=`PipeTo`,sd=`Read`,cd=`Succeed`,ld=`SucceedNow`,ud=`Suspend`,dd=Symbol.for(`effect/Channel`),fd={_Env:e=>e,_InErr:e=>e,_InElem:e=>e,_InDone:e=>e,_OutErr:e=>e,_OutElem:e=>e,_OutDone:e=>e},pd={[dd]:fd,pipe(){return De(this,arguments)}},md=e=>Nt(e,dd)||wn(e),hd=x(2,(e,t)=>{let n=Object.create(pd);return n._tag=Qu,n.acquire=()=>e,n.finalizer=t,n}),gd=(e,t,n)=>{let r=Object.create(pd);return r._tag=ed,r.combineInners=t,r.combineAll=n,r.onPull=()=>Zu(v()),r.onEmit=()=>Hu,r.value=()=>e,r.k=S,r},_d=x(4,(e,t,n,r)=>{let i=Object.create(pd);return i._tag=ed,i.combineInners=n,i.combineAll=r,i.onPull=()=>Zu(v()),i.onEmit=()=>Hu,i.value=()=>e,i.k=t,i}),vd=x(2,(e,t)=>{let n=Object.create(pd);return n._tag=$u,n.input=t,n.channel=e,n}),yd=x(2,(e,t)=>{let n=Object.create(pd);return n._tag=nd,n.channel=e,n.finalizer=t,n}),bd=e=>xd(ni(e)),xd=e=>Sd(()=>e),Sd=e=>{let t=Object.create(pd);return t._tag=rd,t.error=e,t},z=x(2,(e,t)=>{let n=Object.create(pd);return n._tag=id,n.channel=e,n.k=new Gu(t,xd),n}),B=e=>{let t=Object.create(pd);return t._tag=ad,t.effect=()=>e,t},Cd=x(2,(e,t)=>{let n=Object.create(pd);return n._tag=od,n.left=()=>e,n.right=()=>t,n}),wd=e=>Td({onInput:e.onInput,onFailure:t=>Ge(Qr(t),{onLeft:e.onFailure,onRight:xd}),onDone:e.onDone}),Td=e=>{let t=Object.create(pd);return t._tag=sd,t.more=e.onInput,t.done=new Gu(e.onDone,e.onFailure),t},Ed=e=>kd(()=>e),Dd=e=>{let t=Object.create(pd);return t._tag=ld,t.terminal=e,t},Od=e=>{let t=Object.create(pd);return t._tag=ud,t.channel=e,t},kd=e=>{let t=Object.create(pd);return t._tag=cd,t.evaluate=e,t},Ad=Dd(void 0),V=e=>{let t=Object.create(pd);return t._tag=td,t.out=e,t},jd=`Done`,Md=`Emit`,Nd=`FromEffect`,Pd=`Read`,Fd=Symbol.for(`effect/ChannelState`),Id={_E:e=>e,_R:e=>e},Ld={[Fd]:Id},Rd=()=>{let e=Object.create(Ld);return e._tag=jd,e},zd=()=>{let e=Object.create(Ld);return e._tag=Md,e},Bd=e=>{let t=Object.create(Ld);return t._tag=Nd,t.effect=e,t},Vd=(e,t,n,r)=>{let i=Object.create(Ld);return i._tag=Pd,i.upstream=e,i.onEffect=t,i.onEmit=n,i.onDone=r,i},Hd=e=>e._tag===Nd,Ud=e=>Hd(e)?e.effect:A,Wd=e=>Hd(e)?On(e.effect):void 0,Gd=`PullFromChild`,Kd=`PullFromUpstream`,qd=`DrainChildExecutors`,Jd=`Emit`;var Yd=class{childExecutor;parentSubexecutor;onEmit;_tag=Gd;constructor(e,t,n){this.childExecutor=e,this.parentSubexecutor=t,this.onEmit=n}close(e){let t=this.childExecutor.close(e),n=this.parentSubexecutor.close(e);if(t!==void 0&&n!==void 0)return Vr(O(t),O(n),(e,t)=>C(e,mi(t)));if(t!==void 0)return t;if(n!==void 0)return n}enqueuePullFromChild(e){return this}},Xd=class e{upstreamExecutor;createChild;lastDone;activeChildExecutors;combineChildResults;combineWithChildResult;onPull;onEmit;_tag=Kd;constructor(e,t,n,r,i,a,o,s){this.upstreamExecutor=e,this.createChild=t,this.lastDone=n,this.activeChildExecutors=r,this.combineChildResults=i,this.combineWithChildResult=a,this.onPull=o,this.onEmit=s}close(e){let t=this.upstreamExecutor.close(e);return[...this.activeChildExecutors.map(t=>t===void 0?void 0:t.childExecutor.close(e)),t].reduce((e,t)=>{if(e!==void 0&&t!==void 0)return Vr(e,O(t),(e,t)=>mi(e,t));if(e!==void 0)return e;if(t!==void 0)return O(t)},void 0)}enqueuePullFromChild(t){return new e(this.upstreamExecutor,this.createChild,this.lastDone,[...this.activeChildExecutors,t],this.combineChildResults,this.combineWithChildResult,this.onPull,this.onEmit)}},Zd=class e{upstreamExecutor;lastDone;activeChildExecutors;upstreamDone;combineChildResults;combineWithChildResult;onPull;_tag=qd;constructor(e,t,n,r,i,a,o){this.upstreamExecutor=e,this.lastDone=t,this.activeChildExecutors=n,this.upstreamDone=r,this.combineChildResults=i,this.combineWithChildResult=a,this.onPull=o}close(e){let t=this.upstreamExecutor.close(e);return[...this.activeChildExecutors.map(t=>t===void 0?void 0:t.childExecutor.close(e)),t].reduce((e,t)=>{if(e!==void 0&&t!==void 0)return Vr(e,O(t),(e,t)=>mi(e,t));if(e!==void 0)return e;if(t!==void 0)return O(t)},void 0)}enqueuePullFromChild(t){return new e(this.upstreamExecutor,this.lastDone,[...this.activeChildExecutors,t],this.upstreamDone,this.combineChildResults,this.combineWithChildResult,this.onPull)}},Qd=class{value;next;_tag=Jd;constructor(e,t){this.value=e,this.next=t}close(e){return this.next.close(e)}enqueuePullFromChild(e){return this}};const $d=Symbol.for(`effect/ChannelUpstreamPullRequest`),ef={_A:e=>e},tf={[$d]:ef},nf=e=>{let t=Object.create(tf);return t._tag=`Pulled`,t.value=e,t},rf=e=>{let t=Object.create(tf);return t._tag=`NoUpstream`,t.activeDownstreamCount=e,t};var af=class e{_activeSubexecutor=void 0;_cancelled=void 0;_closeLastSubstream=void 0;_currentChannel;_done=void 0;_doneStack=[];_emitted=void 0;_executeCloseLastSubstream;_input=void 0;_inProgressFinalizer=void 0;_providedEnv;constructor(e,t,n){this._currentChannel=e,this._executeCloseLastSubstream=n,this._providedEnv=t}run(){let t;for(;t===void 0;)if(this._cancelled!==void 0)t=this.processCancellation();else if(this._activeSubexecutor!==void 0)t=this.runSubexecutor();else try{if(this._currentChannel===void 0)t=Rd();else switch(wn(this._currentChannel)&&(this._currentChannel=B(this._currentChannel)),this._currentChannel._tag){case Qu:t=this.runBracketOut(this._currentChannel);break;case $u:{let e=this._currentChannel.input;if(this._currentChannel=this._currentChannel.channel,this._input!==void 0){let n=this._input;this._input=void 0;let r=()=>D(e.awaitRead(),()=>M(()=>{let t=n.run();switch(t._tag){case jd:return fi(n.getDone(),{onFailure:t=>e.error(t),onSuccess:t=>e.done(t)});case Md:return D(e.emit(n.getEmit()),()=>r());case Nd:return Zr(t.effect,{onFailure:t=>e.error(t),onSuccess:()=>r()});case Pd:return cf(t,()=>r(),t=>e.error(t))}}));t=Bd(D(Hr(rn(r())),e=>pr(()=>this.addFinalizer(t=>D(nr(e),()=>M(()=>{let e=this.restorePipe(t,n);return e===void 0?A:e}))))))}break}case ed:{let t=new e(this._currentChannel.value(),this._providedEnv,e=>pr(()=>{let t=this._closeLastSubstream===void 0?A:this._closeLastSubstream;this._closeLastSubstream=C(t,E(e))}));t._input=this._input;let n=this._currentChannel;this._activeSubexecutor=new Xd(t,e=>n.k(e),void 0,[],(e,t)=>n.combineInners(e,t),(e,t)=>n.combineAll(e,t),e=>n.onPull(e),e=>n.onEmit(e)),this._closeLastSubstream=void 0,this._currentChannel=void 0;break}case td:this._emitted=this._currentChannel.out,this._currentChannel=this._activeSubexecutor===void 0?Ad:void 0,t=zd();break;case nd:this.runEnsuring(this._currentChannel);break;case rd:t=this.doneHalt(this._currentChannel.error());break;case id:this._doneStack.push(this._currentChannel.k),this._currentChannel=this._currentChannel.channel;break;case ad:{let e=this._providedEnv===void 0?this._currentChannel.effect():C(this._currentChannel.effect(),Vn(this._providedEnv));t=Bd(Zr(e,{onFailure:e=>{let t=this.doneHalt(e);return t!==void 0&&Hd(t)?t.effect:A},onSuccess:e=>{let t=this.doneSucceed(e);return t!==void 0&&Hd(t)?t.effect:A}}));break}case od:{let t=this._input,n=new e(this._currentChannel.left(),this._providedEnv,e=>this._executeCloseLastSubstream(e));n._input=t,this._input=n,this.addFinalizer(e=>{let n=this.restorePipe(e,t);return n===void 0?A:n}),this._currentChannel=this._currentChannel.right();break}case`Provide`:{let e=this._providedEnv;this._providedEnv=this._currentChannel.context(),this._currentChannel=this._currentChannel.inner,this.addFinalizer(()=>pr(()=>{this._providedEnv=e}));break}case sd:{let e=this._currentChannel;t=Vd(this._input,S,t=>{try{this._currentChannel=e.more(t)}catch(t){this._currentChannel=e.done.onExit(bi(t))}},t=>{let n=t=>e.done.onExit(t);this._currentChannel=n(t)});break}case cd:t=this.doneSucceed(this._currentChannel.evaluate());break;case ld:t=this.doneSucceed(this._currentChannel.terminal);break;case ud:this._currentChannel=this._currentChannel.channel();break}}catch(e){this._currentChannel=xd(si(e))}return t}getDone(){return this._done}getEmit(){return this._emitted}cancelWith(e){this._cancelled=e}clearInProgressFinalizer(){this._inProgressFinalizer=void 0}storeInProgressFinalizer(e){this._inProgressFinalizer=e}popAllFinalizers(e){let t=[],n=this._doneStack.pop();for(;n;)n._tag===`ContinuationFinalizer`&&t.push(n.finalizer),n=this._doneStack.pop();let r=t.length===0?A:sf(t,e);return this.storeInProgressFinalizer(r),r}popNextFinalizers(){let e=[];for(;this._doneStack.length!==0;){let t=this._doneStack[this._doneStack.length-1];if(t._tag===`ContinuationK`)return e;e.push(t),this._doneStack.pop()}return e}restorePipe(e,t){let n=this._input;return this._input=t,n===void 0?A:n.close(e)}close(e){let t,n=this._inProgressFinalizer;n!==void 0&&(t=C(n,cr(pr(()=>this.clearInProgressFinalizer()))));let r,i=this.popAllFinalizers(e);i!==void 0&&(r=C(i,cr(pr(()=>this.clearInProgressFinalizer()))));let a=this._activeSubexecutor===void 0?void 0:this._activeSubexecutor.close(e);if(a!==void 0||t!==void 0||r!==void 0)return C(O(of(a)),ur(O(of(t))),ur(O(of(r))),T(([[e,t],n])=>C(e,mi(t),mi(n))),Rr,D(e=>M(()=>e)))}doneSucceed(e){if(this._doneStack.length===0)return this._done=pi(e),this._currentChannel=void 0,Rd();let t=this._doneStack[this._doneStack.length-1];if(t._tag===`ContinuationK`){this._doneStack.pop(),this._currentChannel=t.onSuccess(e);return}let n=this.popNextFinalizers();if(this._doneStack.length===0)return this._doneStack=n.reverse(),this._done=pi(e),this._currentChannel=void 0,Rd();let r=sf(n.map(e=>e.finalizer),pi(e));this.storeInProgressFinalizer(r);let i=C(r,cr(pr(()=>this.clearInProgressFinalizer())),Rr,D(()=>pr(()=>this.doneSucceed(e))));return Bd(i)}doneHalt(e){if(this._doneStack.length===0)return this._done=ui(e),this._currentChannel=void 0,Rd();let t=this._doneStack[this._doneStack.length-1];if(t._tag===`ContinuationK`){this._doneStack.pop();try{this._currentChannel=t.onHalt(e)}catch(e){this._currentChannel=xd(si(e))}return}let n=this.popNextFinalizers();if(this._doneStack.length===0)return this._doneStack=n.reverse(),this._done=ui(e),this._currentChannel=void 0,Rd();let r=sf(n.map(e=>e.finalizer),ui(e));this.storeInProgressFinalizer(r);let i=C(r,cr(pr(()=>this.clearInProgressFinalizer())),Rr,D(()=>pr(()=>this.doneHalt(e))));return Bd(i)}processCancellation(){return this._currentChannel=void 0,this._done=this._cancelled,this._cancelled=void 0,Rd()}runBracketOut(e){let t=Rr(Zr(this.provide(e.acquire()),{onFailure:e=>pr(()=>{this._currentChannel=xd(e)}),onSuccess:t=>pr(()=>{this.addFinalizer(n=>this.provide(e.finalizer(t,n))),this._currentChannel=V(t)})}));return Bd(t)}provide(e){return this._providedEnv===void 0?e:C(e,Vn(this._providedEnv))}runEnsuring(e){this.addFinalizer(e.finalizer),this._currentChannel=e.channel}addFinalizer(e){this._doneStack.push(new Ku(e))}runSubexecutor(){let e=this._activeSubexecutor;switch(e._tag){case Gd:return this.pullFromChild(e.childExecutor,e.parentSubexecutor,e.onEmit,e);case Kd:return this.pullFromUpstream(e);case qd:return this.drainChildExecutors(e);case Jd:return this._emitted=e.value,this._activeSubexecutor=e.next,zd()}}replaceSubexecutor(e){this._currentChannel=void 0,this._activeSubexecutor=e}finishWithExit(e){let t=fi(e,{onFailure:e=>this.doneHalt(e),onSuccess:e=>this.doneSucceed(e)});return this._activeSubexecutor=void 0,t===void 0?A:Ud(t)}finishSubexecutorWithCloseEffect(e,...t){this.addFinalizer(()=>C(t,on(t=>C(pr(()=>t(e)),D(e=>e===void 0?A:e)),{discard:!0})));let n=C(e,fi({onFailure:e=>this.doneHalt(e),onSuccess:e=>this.doneSucceed(e)}));return this._activeSubexecutor=void 0,n}applyUpstreamPullStrategy(e,t,n){switch(n._tag){case qu:{let r=!e||t.some(e=>e!==void 0);return[n.emitSeparator,r?[void 0,...t]:t]}case`PullAfterAllEnqueued`:{let r=!e||t.some(e=>e!==void 0);return[n.emitSeparator,r?[...t,void 0]:t]}}}pullFromChild(e,t,n,r){return Vd(e,S,i=>{let a=n(i);switch(a._tag){case zu:break;case`Close`:this.finishWithDoneValue(e,t,a.value);break;case`Yield`:{let e=t.enqueuePullFromChild(r);this.replaceSubexecutor(e);break}}this._activeSubexecutor=new Qd(i,this._activeSubexecutor)},fi({onFailure:n=>{let r=this.handleSubexecutorFailure(e,t,n);return r===void 0?void 0:Wd(r)},onSuccess:n=>{this.finishWithDoneValue(e,t,n)}}))}finishWithDoneValue(e,t,n){let r=t;switch(r._tag){case Kd:{let t=new Xd(r.upstreamExecutor,r.createChild,r.lastDone===void 0?n:r.combineChildResults(r.lastDone,n),r.activeChildExecutors,r.combineChildResults,r.combineWithChildResult,r.onPull,r.onEmit);this._closeLastSubstream=e.close(pi(n)),this.replaceSubexecutor(t);break}case qd:{let t=new Zd(r.upstreamExecutor,r.lastDone===void 0?n:r.combineChildResults(r.lastDone,n),r.activeChildExecutors,r.upstreamDone,r.combineChildResults,r.combineWithChildResult,r.onPull);this._closeLastSubstream=e.close(pi(n)),this.replaceSubexecutor(t);break}default:break}}handleSubexecutorFailure(e,t,n){return this.finishSubexecutorWithCloseEffect(ui(n),e=>t.close(e),t=>e.close(t))}pullFromUpstream(e){if(e.activeChildExecutors.length===0)return this.performPullFromUpstream(e);let t=e.activeChildExecutors[0],n=new Xd(e.upstreamExecutor,e.createChild,e.lastDone,e.activeChildExecutors.slice(1),e.combineChildResults,e.combineWithChildResult,e.onPull,e.onEmit);if(t===void 0)return this.performPullFromUpstream(n);this.replaceSubexecutor(new Yd(t.childExecutor,n,t.onEmit))}performPullFromUpstream(t){return Vd(t.upstreamExecutor,e=>{let t=this._closeLastSubstream===void 0?A:this._closeLastSubstream;return this._closeLastSubstream=void 0,C(this._executeCloseLastSubstream(t),E(e))},n=>{if(this._closeLastSubstream!==void 0){let r=this._closeLastSubstream;return this._closeLastSubstream=void 0,C(this._executeCloseLastSubstream(r),T(()=>{let r=new e(t.createChild(n),this._providedEnv,this._executeCloseLastSubstream);r._input=this._input;let[i,a]=this.applyUpstreamPullStrategy(!1,t.activeChildExecutors,t.onPull(nf(n)));this._activeSubexecutor=new Yd(r,new Xd(t.upstreamExecutor,t.createChild,t.lastDone,a,t.combineChildResults,t.combineWithChildResult,t.onPull,t.onEmit),t.onEmit),bt(i)&&(this._activeSubexecutor=new Qd(i.value,this._activeSubexecutor))}))}let r=new e(t.createChild(n),this._providedEnv,this._executeCloseLastSubstream);r._input=this._input;let[i,a]=this.applyUpstreamPullStrategy(!1,t.activeChildExecutors,t.onPull(nf(n)));this._activeSubexecutor=new Yd(r,new Xd(t.upstreamExecutor,t.createChild,t.lastDone,a,t.combineChildResults,t.combineWithChildResult,t.onPull,t.onEmit),t.onEmit),bt(i)&&(this._activeSubexecutor=new Qd(i.value,this._activeSubexecutor))},e=>{if(t.activeChildExecutors.some(e=>e!==void 0)){let e=new Zd(t.upstreamExecutor,t.lastDone,[void 0,...t.activeChildExecutors],t.upstreamExecutor.getDone(),t.combineChildResults,t.combineWithChildResult,t.onPull);if(this._closeLastSubstream!==void 0){let t=this._closeLastSubstream;return this._closeLastSubstream=void 0,C(this._executeCloseLastSubstream(t),T(()=>this.replaceSubexecutor(e)))}this.replaceSubexecutor(e);return}let n=this._closeLastSubstream,r=this.finishSubexecutorWithCloseEffect(C(e,gi(e=>t.combineWithChildResult(t.lastDone,e))),()=>n,e=>t.upstreamExecutor.close(e));return r===void 0?void 0:Wd(r)})}drainChildExecutors(e){if(e.activeChildExecutors.length===0){let t=this._closeLastSubstream;return t!==void 0&&this.addFinalizer(()=>j(t)),this.finishSubexecutorWithCloseEffect(e.upstreamDone,()=>t,t=>e.upstreamExecutor.close(t))}let t=e.activeChildExecutors[0],n=e.activeChildExecutors.slice(1);if(t===void 0){let[t,r]=this.applyUpstreamPullStrategy(!0,n,e.onPull(rf(n.reduce((e,t)=>t===void 0?e:e+1,0))));return this.replaceSubexecutor(new Zd(e.upstreamExecutor,e.lastDone,r,e.upstreamDone,e.combineChildResults,e.combineWithChildResult,e.onPull)),bt(t)?(this._emitted=t.value,zd()):void 0}let r=new Zd(e.upstreamExecutor,e.lastDone,n,e.upstreamDone,e.combineChildResults,e.combineWithChildResult,e.onPull);this.replaceSubexecutor(new Yd(t.childExecutor,r,t.onEmit))}};const of=e=>e===void 0?A:e,sf=(e,t)=>C(on(e,e=>O(e(t))),T(e=>C(vi(e),Ne(()=>yi))),D(e=>M(()=>e))),cf=(e,t,n)=>{let r=[e],i=()=>{let e=r.pop();if(e===void 0||e.upstream===void 0)return Dr(`Unexpected end of input for channel execution`);let a=e.upstream.run();switch(a._tag){case Md:{let a=e.onEmit(e.upstream.getEmit());return r.length===0?a===void 0?M(t):C(a,Zr({onFailure:n,onSuccess:t})):a===void 0?M(()=>i()):C(a,Zr({onFailure:n,onSuccess:()=>i()}))}case jd:{let a=e.onDone(e.upstream.getDone());return r.length===0?a===void 0?M(t):C(a,Zr({onFailure:n,onSuccess:t})):a===void 0?M(()=>i()):C(a,Zr({onFailure:n,onSuccess:()=>i()}))}case Nd:return r.push(e),C(e.onEffect(a.effect),Ir(t=>M(()=>{let n=e.onDone(ui(t));return n===void 0?A:n})),Zr({onFailure:n,onSuccess:()=>i()}));case Pd:return r.push(e),r.push(a),M(()=>i())}};return i()},lf=x(2,(e,t)=>{let n=(t,n,r)=>dr(pr(()=>new af(e,void 0,S)),e=>M(()=>uf(e.run(),e).pipe(mr(t),E(k(t)),sr(k(n)))),(e,t)=>{let n=e.close(t);return n===void 0?A:Er(n,e=>fr(r,zr(e)))});return tr(e=>Jn([$n(t,Kr),Tn(),Tn()]).pipe(D(([r,i,a])=>e(n(i,a,r)).pipe(Rn(t),D(n=>t.addFinalizer(e=>{let t=xi(e)?$r(e.cause):void 0;return hr(i).pipe(D(e=>e?Dn(a,void 0).pipe(E(Nn(n)),E(nn(n))):Dn(a,void 0).pipe(E(t&&ht(t)>0?Fr(n,yt(t)):nr(n)),E(nn(n)))))}).pipe(E(e(k(i)))))))))}),uf=(e,t)=>{let n=e;switch(n._tag){case Nd:return C(n.effect,D(()=>uf(t.run(),t)));case Md:return uf(t.run(),t);case jd:return M(()=>t.getDone());case Pd:return cf(n,()=>uf(t.run(),t),zr)}},df={[Symbol.for(`effect/ChannelMergeDecision`)]:{_R:e=>e,_E0:e=>e,_Z0:e=>e,_E:e=>e,_Z:e=>e}},ff=e=>{let t=Object.create(df);return t._tag=`Await`,t.f=e,t},pf=`BothRunning`,mf=`LeftDone`,hf=`RightDone`,gf=Symbol.for(`effect/ChannelMergeState`),_f={[gf]:gf},vf=(e,t)=>{let n=Object.create(_f);return n._tag=pf,n.left=e,n.right=t,n},yf=e=>{let t=Object.create(_f);return t._tag=mf,t.f=e,t},bf=e=>{let t=Object.create(_f);return t._tag=hf,t.f=e,t},xf=`BackPressure`,Sf=`BufferSliding`,Cf=Symbol.for(`effect/ChannelMergeStrategy`),wf={[Cf]:Cf},Tf=e=>{let t=Object.create(wf);return t._tag=xf,t},Ef=e=>{let t=Object.create(wf);return t._tag=Sf,t},Df=x(2,(e,{onBackPressure:t,onBufferSliding:n})=>{switch(e._tag){case xf:return t();case Sf:return n()}}),Of=`Empty`,kf=`Emit`,Af=`Error`,jf=`Done`,Mf=e=>({_tag:Of,notifyProducer:e}),Nf=e=>({_tag:kf,notifyConsumers:e}),Pf=e=>({_tag:Af,cause:e}),Ff=e=>({_tag:jf,done:e});var If=class{ref;constructor(e){this.ref=e}awaitRead(){return Gr(Br(this.ref,e=>e._tag===Of?[k(e.notifyProducer),e]:[A,e]))}get close(){return Jr(e=>this.error(ci(e)))}done(e){return Gr(Br(this.ref,t=>{switch(t._tag){case Of:return[k(t.notifyProducer),t];case kf:return[on(t.notifyConsumers,t=>Dn(t,y(e)),{discard:!0}),Ff(e)];case Af:return[gr,t];case jf:return[gr,t]}}))}emit(e){return D(Tn(),t=>Gr(Br(this.ref,n=>{switch(n._tag){case Of:return[k(n.notifyProducer),n];case kf:{let r=n.notifyConsumers[0],i=n.notifyConsumers.slice(1);if(r!==void 0)return[Dn(r,b(e)),i.length===0?Mf(t):Nf(i)];throw Error(`Bug: Channel.SingleProducerAsyncInput.emit - Queue was empty! please report an issue at https://github.com/Effect-TS/effect/issues`)}case Af:return[gr,n];case jf:return[gr,n]}})))}error(e){return Gr(Br(this.ref,t=>{switch(t._tag){case Of:return[k(t.notifyProducer),t];case kf:return[on(t.notifyConsumers,t=>an(t,e),{discard:!0}),Pf(e)];case Af:return[gr,t];case jf:return[gr,t]}}))}get take(){return this.takeWith(e=>ui(ei(e,y)),e=>pi(e),e=>hi(b(e)))}takeWith(e,t,n){return D(Tn(),r=>Gr(Br(this.ref,i=>{switch(i._tag){case Of:return[E(Dn(i.notifyProducer,void 0),Pn(k(r),{onFailure:e,onSuccess:Ge({onLeft:n,onRight:t})})),Nf([r])];case kf:return[Pn(k(r),{onFailure:e,onSuccess:Ge({onLeft:n,onRight:t})}),Nf([...i.notifyConsumers,r])];case Af:return[j(e(i.cause)),i];case jf:return[j(n(i.done)),i]}})))}};const Lf=()=>C(Tn(),D(e=>qn(Mf(e))),T(e=>new If(e))),Rf=x(2,(e,t)=>_d(e,t,()=>void 0,()=>void 0)),zf=e=>{let t=Td({onInput:()=>t,onFailure:xd,onDone:Ed});return Cd(e,t)},Bf=x(2,(e,t)=>yd(e,()=>t)),Vf=e=>z(e,S),Hf=e=>tp(e.takeWith(xd,t=>z(V(t),()=>Hf(e)),Ed)),Uf=x(2,(e,t)=>z(e,e=>kd(()=>t(e)))),Wf=x(2,(e,t)=>{let n=wd({onInput:e=>z(V(t(e)),()=>n),onFailure:bd,onDone:Dd});return Cd(e,n)}),Gf=x(2,(e,t)=>{let n=Td({onInput:e=>C(B(t(e)),z(V),z(()=>n)),onFailure:xd,onDone:Dd});return Cd(e,n)}),Kf=e=>t=>qf(e)(t,mt),qf=({bufferSize:e=16,concurrency:t,mergeStrategy:n=Tf()})=>(r,i)=>rp(a=>cn(function*(){let o=t===`unbounded`?2**53-1:t,s=yield*Lf(),c=Hf(s),l=yield*ju(e);yield*fr(a,Iu(l));let u=yield*Pu();yield*fr(a,Iu(u));let d=yield*qn(v()),f=yield*Tn(),p=(yield*En(o)).withPermits,m=yield*$f(Cd(c,r),a);function h(e){return e.pipe(D(Ge({onLeft:e=>j(w(e)),onRight:e=>wr(Lu(l,j(b(e))),v())})),Ar({until:e=>bt(e)}),D(e=>Zn(d,_({onNone:()=>w(e.value),onSome:t=>w(i(t,e.value))}))),Ir(e=>li(e)?zr(e):Lu(l,zr(e)).pipe(E(Dn(f,void 0)),Mr)))}yield*m.pipe(Zr({onFailure:e=>Lu(l,zr(e)).pipe(E(j(!1))),onSuccess:Ge({onLeft:e=>bn(rn(k(f)),rn(p(o)(A)),{onSelfDone:(e,t)=>wr(nr(t),!1),onOtherDone:(t,n)=>E(nr(n),or(d).pipe(D(_({onNone:()=>Lu(l,j(y(e))),onSome:t=>Lu(l,j(y(i(t,e))))})),wr(!1)))}),onRight:e=>Df(n,{onBackPressure:()=>cn(function*(){let t=yield*Tn(),n=rr(t=>$f(Cd(c,e),t).pipe(D(e=>gn(O(h(e)),O(rn(k(f))))),D(S)));return yield*Dn(t,void 0).pipe(E(n),p(1),Rn(a)),yield*k(t),!(yield*hr(f))}),onBufferSliding:()=>cn(function*(){let t=yield*Tn(),n=yield*Tn(),r=yield*Fu(u);yield*Ru(u).pipe(D(e=>Dn(e,void 0)),kr(()=>r>=o)),yield*Lu(u,t);let i=rr(n=>$f(Cd(c,e),n).pipe(D(e=>O(h(e)).pipe(gn(O(rn(k(f)))),gn(O(rn(k(t)))))),D(S)));return yield*Dn(n,void 0).pipe(E(i),p(1),Rn(a)),yield*k(n),!(yield*hr(f))})})})}),Ar({while:e=>e}),Rn(a));let g=C(Ru(l),Gr,Pn({onFailure:xd,onSuccess:Ge({onLeft:Dd,onRight:e=>z(V(e),()=>g)})}),tp);return vd(g,s)})),Jf=x(3,(e,t,n)=>Kf(n)(Wf(e,t))),Yf=x(2,(e,t)=>{function n(n){return cn(function*(){let r=yield*Lf(),i=Hf(r),a=yield*$f(Cd(i,e),n),o=yield*$f(Cd(i,t.other),n);function s(e,t,r){return(i,a,o)=>{function s(e){let n=e;return n._tag===`Done`?j(B(E(nr(t),n.effect))):T(Nn(t),fi({onFailure:e=>B(n.f(ui(e))),onSuccess:Ge({onLeft:e=>B(n.f(pi(e))),onRight:e=>sp(V(e),c(o(n.f)))})}))}return fi(e,{onFailure:e=>s(i(ui(e))),onSuccess:Ge({onLeft:e=>s(i(pi(e))),onRight:e=>j(z(V(e),()=>z(B(Rn(rn(r),n)),e=>c(a(e,t)))))})})}}function c(e){switch(e._tag){case pf:{let n=rn(Cr(e.left)),r=rn(Cr(e.right));return tp(bn(n,r,{onSelfDone:(n,r)=>E(nr(r),s(n,e.right,a)(t.onSelfDone,vf,e=>yf(e))),onOtherDone:(n,r)=>E(nr(r),s(n,e.left,o)(t.onOtherDone,(e,t)=>vf(t,e),e=>bf(e)))}))}case mf:return tp(T(O(o),fi({onFailure:t=>B(e.f(ui(t))),onSuccess:Ge({onLeft:t=>B(e.f(pi(t))),onRight:t=>z(V(t),()=>c(yf(e.f)))})})));case hf:return tp(T(O(a),fi({onFailure:t=>B(e.f(ui(t))),onSuccess:Ge({onLeft:t=>B(e.f(pi(t))),onRight:t=>z(V(t),()=>c(bf(e.f)))})})))}}return B(Sr(e=>{let t=Sr(t=>(t.transferChildren(e.scope()),A));return Vr(rn(a).pipe(cr(t),Rn(n)),rn(o).pipe(cr(t),Rn(n)),(e,t)=>vf(e,t))})).pipe(z(c),vd(r))})}return rp(n)}),Xf=e=>Mn(t=>lf(e,t)),Zf=e=>tp(tr(t=>T(vr(),n=>hd(Er(t(Nr(e,n)),e=>Tr(n,ui(e))),(e,t)=>Tr(n,t))))),Qf=e=>np(T(Gn,t=>z(B(e(t)),V))),$f=x(2,(e,t)=>ur(pr(()=>new af(e,void 0,S)),Un()).pipe(Xn(([e,n])=>Yn(t,t=>{let r=e.close(t);return r===void 0?A:Vn(r,n)})),Rr,T(([e])=>M(()=>ep(e.run(),e))))),ep=(e,t)=>{let n=e;switch(n._tag){case jd:return fi(t.getDone(),{onFailure:zr,onSuccess:e=>j(y(e))});case Md:return j(b(t.getEmit()));case Nd:return C(n.effect,D(()=>ep(t.run(),t)));case Pd:return cf(n,()=>ep(t.run(),t),e=>zr(e))}},tp=e=>Vf(B(e)),np=e=>gd(Zf(e),(e,t)=>e,(e,t)=>e),rp=e=>gd(Qf(e),(e,t)=>e,(e,t)=>e),ip=e=>ap(0,e.length,e),ap=(e,t,n)=>e===t?Ad:C(V(C(n,ee(e))),z(()=>ap(e+1,t,n))),op=x(e=>md(e[1]),(e,t,n)=>n?.concurrent?Yf(e,{other:t,onSelfDone:e=>ff(t=>M(()=>_i(e,t))),onOtherDone:e=>ff(t=>M(()=>_i(t,e)))}):z(e,e=>Uf(t,t=>[e,t]))),sp=x(e=>md(e[1]),(e,t,n)=>n?.concurrent?Uf(op(e,t,{concurrent:!0}),e=>e[1]):z(e,()=>t)),cp=Symbol.for(`effect/Sink`),lp={_A:e=>e,_In:e=>e,_L:e=>e,_E:e=>e,_R:e=>e};var up=class{channel;[cp]=lp;constructor(e){this.channel=e}pipe(){return De(this,arguments)}};const dp=e=>{let t=Td({onInput:n=>C(B(on(n,t=>e(t),{discard:!0})),z(()=>t)),onFailure:xd,onDone:()=>Ad});return new up(t)},fp=e=>new up(B(e)),pp=e=>wn(e)?pp(fp(e)):e.channel,mp=e=>new up(np(e.pipe(T(e=>pp(e))))),hp=xn,gp=e=>Object.assign(e,{chunk(e){return this(j(e))},die(e){return this(ir(e))},dieMessage(e){return this(Dr(e))},done(e){return this(M(()=>Si(e,{onFailure:w,onSuccess:ye})))},end(){return this(Kn(v()))},fail(e){return this(Kn(w(e)))},fromEffect(e){return this(mn(e,{onFailure:w,onSuccess:ye}))},fromEffectChunk(e){return this(C(e,_n(w)))},halt(e){return this(zr(C(e,ei(w))))},single(e){return this(j(ye(e)))}}),_p=Symbol.for(`effect/Take`),vp={_A:e=>e,_E:e=>e};var yp=class{exit;[_p]=vp;constructor(e){this.exit=e}pipe(){return De(this,arguments)}};const bp=e=>new yp(pi(e)),xp=e=>M(()=>e.exit),Sp=new yp(hi(v())),Cp=e=>new yp(ui(C(e,ei(w)))),wp=e=>Pn(e,{onFailure:e=>_(ai(e),{onNone:()=>Sp,onSome:Cp}),onSuccess:bp}),Tp=x(2,(e,{onEnd:t,onFailure:n,onSuccess:r})=>fi(e.exit,{onFailure:e=>_(ai(e),{onNone:t,onSome:n}),onSuccess:r})),Ep=()=>Kn(v()),Dp=Symbol.for(`effect/Stream`),Op={_R:e=>e,_E:e=>e,_A:e=>e};var kp=class{channel;[Dp]=Op;constructor(e){this.channel=e}pipe(){return De(this,arguments)}};const Ap=e=>Nt(e,Dp)||wn(e),jp=e=>{if(e===`unbounded`)return Pu();if(typeof e==`number`||e===void 0)return ju(e??16);switch(e.strategy){case`dropping`:return Mu(e.bufferSize??16);case`sliding`:return Nu(e.bufferSize??16);default:return ju(e.bufferSize??16)}},Mp=(e,t)=>C(jr(jp(t),e=>Iu(e)),D(t=>C(Un(),D(n=>C(e(gp(e=>C(wp(e),D(e=>Lu(t,e)),Mr,hp(n)).then(e=>{if(xi(e)&&!li(e.cause))throw oi(e.cause)}))),E(qn(!1)),D(e=>C(or(e),T(n=>n?Ep():C(Ru(t),D(xp),Hn(()=>C(Yr(e,!0),E(Iu(t)))))))))))),qp,Lp(Gp)),Np=x(2,(e,t)=>{if(t.strategy===`dropping`)return Pp(e,t.capacity);if(t.strategy===`sliding`)return Fp(e,t.capacity);let n=Yp(e,t);return new kp(np(T(n,e=>{let t=C(B(Ru(e)),z(Tp({onEnd:()=>Ad,onFailure:xd,onSuccess:e=>C(V(e),z(()=>t))})));return t})))}),Pp=x(2,(e,t)=>{let n=jr(Mu(t),e=>Iu(e));return new kp(Ip(n,Hp(e)))}),Fp=x(2,(e,t)=>{let n=jr(Nu(t),e=>Iu(e));return new kp(Ip(n,Hp(e)))}),Ip=(e,t)=>{let n=(e,t)=>{let r=n=>C(or(t),Xn(k),E(Tn()),D(r=>C(Lu(e,[n,r]),E(Yr(t,r)),E(k(r)))),Mr,B);return Td({onInput:r=>C(Tn(),D(n=>C(Lu(e,[bp(r),n]),D(e=>C(Yr(t,n),kr(()=>e))))),Mr,B,z(()=>n(e,t))),onFailure:e=>r(Cp(e)),onDone:()=>r(Sp)})},r=e=>{let t=C(B(Ru(e)),z(([e,n])=>sp(B(Dn(n,void 0)),Tp(e,{onEnd:()=>Ad,onFailure:xd,onSuccess:e=>C(V(e),z(()=>t))}))));return t};return np(C(e,D(e=>C(Tn(),Xn(e=>Dn(e,void 0)),D(i=>C(qn(i),D(r=>C(t,Cd(n(e,r)),Xf,dn)),wr(r(e))))))))},Lp=x(e=>Ap(e[0]),(e,t,n)=>{let i=n?.bufferSize??16;return n?.switch?Rp(n?.concurrency,()=>zp(e,1,i,t),n=>zp(e,n,i,t)):Rp(n?.concurrency,()=>new kp(Rf(Hp(e),e=>C(e,d(e=>Hp(t(e))),r(Ad,(e,t)=>C(e,sp(t)))))),r=>new kp(C(Hp(e),Rf(ip),Jf(e=>Hp(t(e)),n))))}),Rp=(e,t,n)=>{switch(e){case void 0:return t();case`unbounded`:return n(2**53-1);default:return e>1?n(e):t()}},zp=x(4,(e,t,n,r)=>new kp(C(Hp(e),Rf(ip),Jf(e=>Hp(r(e)),{concurrency:t,mergeStrategy:Ef(),bufferSize:n})))),Bp=x(e=>Ap(e[0]),(e,t)=>Lp(e,S,t)),Vp=e=>new kp(e),Hp=e=>{if(`channel`in e)return e.channel;if(wn(e))return Hp(Up(e));throw TypeError(`Expected a Stream.`)},Up=e=>C(e,_n(w),Wp),Wp=e=>new kp(tp(Sn(e,{onFailure:_({onNone:()=>Ad,onSome:bd}),onSuccess:e=>V(ye(e))}))),Gp=e=>Xp(e,e=>C(T(e,t=>w([t,e])),_r(_({onNone:()=>j(v()),onSome:Kn})))),Kp=x(2,(e,t)=>{let n=Td({onInput:e=>z(V(bp(e)),()=>n),onFailure:e=>V(Cp(e)),onDone:()=>V(Sp)});return C(Cd(Hp(e),n),Gf(e=>Lu(t,e)),zf,Xf,Mr)}),qp=e=>new kp(Bf(Zf(C(e,T(ye))),A)),Jp=e=>new kp(Od(()=>Hp(e()))),Yp=x(e=>Ap(e[0]),(e,t)=>Xn(jr(t?.strategy===`unbounded`?Pu():t?.strategy===`dropping`?Mu(t.capacity??2):t?.strategy===`sliding`?Nu(t.capacity??2):ju(t?.capacity??2),e=>Iu(e)),t=>dn(Kp(e,t)))),Xp=(e,t)=>Jp(()=>{let n=e=>tp(T(t(e),_({onNone:()=>Ad,onSome:([e,t])=>z(V(e),()=>n(t))})));return new kp(n(e))}),Zp=e=>Bp(Up(e)),Qp=e=>Bp(qp(e)),$p=z,em=Ad,tm=V,nm=Ri,rm=Bi,im=Vi,am=Hi,om=Ui,sm=Wi,cm=Ki,lm=qi,um=Yi,dm=Qi,fm=na,pm=ra,mm=oa,hm=sa,gm=ca,_m=pa;Ze(`effect/DateTime/CurrentTimeZone`)();const vm=ba,ym=Sa;var H=class{path;actual;issue;_tag=`Pointer`;constructor(e,t,n){this.path=e,this.actual=t,this.issue=n}},bm=class{actual;message;_tag=`Unexpected`;constructor(e,t){this.actual=e,this.message=t}},xm=class{ast;message;_tag=`Missing`;actual=void 0;constructor(e,t){this.ast=e,this.message=t}},U=class{ast;actual;issues;output;_tag=`Composite`;constructor(e,t,n,r){this.ast=e,this.actual=t,this.issues=n,this.output=r}},Sm=class{ast;actual;kind;issue;_tag=`Refinement`;constructor(e,t,n,r){this.ast=e,this.actual=t,this.kind=n,this.issue=r}},Cm=class{ast;actual;kind;issue;_tag=`Transformation`;constructor(e,t,n,r){this.ast=e,this.actual=t,this.kind=n,this.issue=r}},W=class{ast;actual;message;_tag=`Type`;constructor(e,t,n){this.ast=e,this.actual=t,this.message=n}},wm=class{ast;actual;message;_tag=`Forbidden`;constructor(e,t,n){this.ast=e,this.actual=t,this.message=n}};const Tm=Symbol.for(`effect/Schema/ParseErrorTypeId`);var Em=class extends Oi(`ParseError`){[Tm]=Tm;get message(){return this.toString()}toString(){return lh.formatIssueSync(this.issue)}toJSON(){return{_id:`ParseError`,message:this.toString()}}[s](){return this.toJSON()}};const Dm=e=>new Em({issue:e}),G=b,Om=y,km=n,Am=o,jm=Ie,Mm=x(2,(e,t)=>jm(e)?Ge(e,{onLeft:y,onRight:t}):D(e,t)),Nm=x(2,(e,t)=>jm(e)?It(e,t):T(e,t)),Pm=x(2,(e,t)=>jm(e)?Je(e,t):_n(e,t)),Fm=x(2,(e,t)=>jm(e)?le(e,{onLeft:t.onFailure,onRight:t.onSuccess}):mn(e,t)),Im=x(2,(e,t)=>jm(e)?Ge(e,{onLeft:t,onRight:b}):_r(e,t)),Lm=(e,t)=>t===void 0||Vt(t)?e:e===void 0?t:{...e,...t},Rm=(e,t,n)=>{let r=K(e,t);return(e,t)=>r(e,Lm(n,t))},zm=(e,t,n)=>{let r=Rm(e,t,n);return(e,t)=>re(r(e,t),Dm)},Bm=(e,t,n)=>{let r=Rm(e,t,n);return(e,t)=>be(r(e,t))},Vm=(e,t,n)=>{let r=K(e,t);return(e,t)=>r(e,{...Lm(n,t),isEffectAllowed:!0})},Hm=(e,t)=>zm(e.ast,!0,t),Um=(e,t)=>Bm(e.ast,!0,t),Wm=(e,t)=>Vm(e.ast,!0,t),Gm=(e,t)=>Vm(e.ast,!1,t),Km=Hm,qm=(e,t)=>zm(L(e.ast),!0,t),Jm=(e,t)=>{let n=K(L(e.ast),!0);return(e,r)=>te(n(e,{exact:!0,...Lm(t,r)}))},Ym=st(Symbol.for(`effect/ParseResult/decodeMemoMap`),()=>new WeakMap),Xm=st(Symbol.for(`effect/ParseResult/encodeMemoMap`),()=>new WeakMap),K=(e,t)=>{let n=t?Ym:Xm,r=n.get(e);if(r)return r;let i=$m(e,t),a=Zs(e),o=bt(a)?(e,t)=>i(e,Lm(t,a.value)):i,s=Qs(e),c=t&&bt(s)?(t,n)=>ih(Im(o(t,n),s.value),e,t,n):o;return n.set(e,c),c},Zm=e=>f(Js(e)),Qm=e=>f(Ys(e)),$m=(n,r)=>{switch(n._tag){case`Refinement`:if(r){let e=K(n.from,!0);return(t,r)=>{r??=Kc;let i=r?.errors===`all`,a=Mm(Im(e(t,r),e=>{let a=new Sm(n,t,`From`,e);return i&&tc(n)&&vh(e)?_(n.filter(t,r,n),{onNone:()=>y(a),onSome:e=>y(new U(n,t,[a,new Sm(n,t,`Predicate`,e)]))}):y(a)}),e=>_(n.filter(e,r,n),{onNone:()=>b(e),onSome:e=>y(new Sm(n,t,`Predicate`,e))}));return ih(a,n,t,r)}}else{let e=K(L(n),!0),t=K(rh(n.from),!1);return(r,i)=>ih(Mm(e(r,i),e=>t(e,i)),n,r,i)}case`Transformation`:{let e=sh(n.transformation,r),t=r?K(n.from,!0):K(n.to,!1),i=r?K(n.to,!0):K(n.from,!1);return(a,o)=>ih(Mm(Pm(t(a,o),e=>new Cm(n,a,r?`Encoded`:`Type`,e)),t=>Mm(Pm(e(t,o??Kc,n,a),e=>new Cm(n,a,`Transformation`,e)),e=>Pm(i(e,o),e=>new Cm(n,a,r?`Type`:`Encoded`,e)))),n,a,o)}case`Declaration`:{let e=r?n.decodeUnknown(...n.typeParameters):n.encodeUnknown(...n.typeParameters);return(t,r)=>ih(e(t,r??Kc,n),n,t,r)}case`Literal`:return eh(n,e=>e===n.literal);case`UniqueSymbol`:return eh(n,e=>e===n.symbol);case`UndefinedKeyword`:return eh(n,Ht);case`NeverKeyword`:return eh(n,e);case`UnknownKeyword`:case`AnyKeyword`:case`VoidKeyword`:return b;case`StringKeyword`:return eh(n,Qe);case`NumberKeyword`:return eh(n,Vt);case`BooleanKeyword`:return eh(n,Ke);case`BigIntKeyword`:return eh(n,oe);case`SymbolKeyword`:return eh(n,At);case`ObjectKeyword`:return eh(n,Dt);case`Enums`:return eh(n,e=>n.enums.some(([t,n])=>n===e));case`TemplateLiteral`:{let e=al(n);return eh(n,t=>Qe(t)&&e.test(t))}case`TupleType`:{let e=n.elements.map(e=>K(e.type,r)),i=n.rest.map(e=>K(e.type,r)),a=n.elements.filter(e=>!e.isOptional);n.rest.length>0&&(a=a.concat(n.rest.slice(1)));let o=a.length,s=n.elements.length>0?n.elements.map((e,t)=>t).join(` | `):`never`,c=Zm(n),l=Qm(n);return(r,u)=>{if(!Xe(r))return y(new W(n,r));let d=u?.errors===`all`,f=[],p=0,m=[],h=r.length;for(let e=h;e<=o-1;e++){let t=new H(e,r,new xm(a[e-h]));if(d){f.push([p++,t]);continue}else return y(new U(n,r,t,m))}if(n.rest.length===0)for(let e=n.elements.length;e<=h-1;e++){let t=new H(e,r,new bm(r[e],`is unexpected, expected: ${s}`));if(d){f.push([p++,t]);continue}else return y(new U(n,r,t,m))}let g=0,ee;for(;g<e.length;g++)if(h<g+1){if(n.elements[g].isOptional)continue}else{let t=e[g],i=t(r[g],u);if(jm(i)){if(He(i)){let e=new H(g,r,i.left);if(d){f.push([p++,e]);continue}else return y(new U(n,r,e,oh(m)))}m.push([p++,i.right])}else{let e=p++,t=g;ee||=[],ee.push(({es:a,output:o})=>D(br(i),i=>{if(He(i)){let s=new H(t,r,i.left);return d?(a.push([e,s]),A):y(new U(n,r,s,oh(o)))}return o.push([e,i.right]),A}))}}if(t(i)){let[e,...t]=i;for(;g<h-t.length;g++){let t=e(r[g],u);if(jm(t))if(He(t)){let e=new H(g,r,t.left);if(d){f.push([p++,e]);continue}else return y(new U(n,r,e,oh(m)))}else m.push([p++,t.right]);else{let e=p++,i=g;ee||=[],ee.push(({es:a,output:o})=>D(br(t),t=>{if(He(t)){let s=new H(i,r,t.left);return d?(a.push([e,s]),A):y(new U(n,r,s,oh(o)))}else return o.push([e,t.right]),A}))}}for(let e=0;e<t.length;e++){let i=g+e;if(!(h<i+1)){let a=t[e](r[i],u);if(jm(a)){if(He(a)){let e=new H(i,r,a.left);if(d){f.push([p++,e]);continue}else return y(new U(n,r,e,oh(m)))}m.push([p++,a.right])}else{let e=p++;ee||=[],ee.push(({es:t,output:o})=>D(br(a),a=>{if(He(a)){let s=new H(i,r,a.left);return d?(t.push([e,s]),A):y(new U(n,r,s,oh(o)))}return o.push([e,a.right]),A}))}}}}let _=({es:e,output:t})=>Te(e)?y(new U(n,r,oh(e),oh(t))):b(oh(t));if(ee&&ee.length>0){let e=ee;return M(()=>{let t={es:tn(f),output:tn(m)};return D(on(e,e=>e(t),{concurrency:c,batching:l,discard:!0}),()=>_(t))})}return _({output:m,es:f})}}case`TypeLiteral`:{if(n.propertySignatures.length===0&&n.indexSignatures.length===0)return eh(n,ut);let e=[],t={},i=[];for(let a of n.propertySignatures)e.push([K(a.type,r),a]),t[a.name]=null,i.push(a.name);let a=n.indexSignatures.map(e=>[K(e.parameter,r),K(e.type,r),e.parameter]),o=Rc.make(n.indexSignatures.map(e=>e.parameter).concat(i.map(e=>At(e)?new lc(e):new sc(e)))),s=K(o,r),c=Zm(n),l=Qm(n);return(r,u)=>{if(!Rt(r))return y(new W(n,r));let d=u?.errors===`all`,f=[],p=0,m=u?.onExcessProperty===`error`,h=u?.onExcessProperty===`preserve`,g={},ee;if(m||h){ee=Reflect.ownKeys(r);for(let e of ee){let t=s(e,u);if(jm(t)&&He(t))if(m){let t=new H(e,r,new bm(r[e],`is unexpected, expected: ${String(o)}`));if(d){f.push([p++,t]);continue}else return y(new U(n,r,t,g))}else g[e]=r[e]}}let _,ne=u?.exact===!0;for(let t=0;t<e.length;t++){let i=e[t][1],a=i.name,o=Object.prototype.hasOwnProperty.call(r,a);if(!o){if(i.isOptional)continue;if(ne){let e=new H(a,r,new xm(i));if(d){f.push([p++,e]);continue}else return y(new U(n,r,e,g))}}let s=e[t][0],c=s(r[a],u);if(jm(c)){if(He(c)){let e=new H(a,r,o?c.left:new xm(i));if(d){f.push([p++,e]);continue}else return y(new U(n,r,e,g))}g[a]=c.right}else{let e=p++,t=a;_||=[],_.push(({es:a,output:s})=>D(br(c),c=>{if(He(c)){let l=new H(t,r,o?c.left:new xm(i));return d?(a.push([e,l]),A):y(new U(n,r,l,s))}return s[t]=c.right,A}))}}for(let e=0;e<a.length;e++){let i=a[e],o=i[0],s=i[1],c=Vo(r,i[2]);for(let e of c){let i=o(e,u);if(jm(i)&&te(i)){let i=s(r[e],u);if(jm(i))if(He(i)){let t=new H(e,r,i.left);if(d){f.push([p++,t]);continue}else return y(new U(n,r,t,g))}else Object.prototype.hasOwnProperty.call(t,e)||(g[e]=i.right);else{let a=p++,o=e;_||=[],_.push(({es:s,output:c})=>D(br(i),i=>{if(He(i)){let e=new H(o,r,i.left);return d?(s.push([a,e]),A):y(new U(n,r,e,c))}else return Object.prototype.hasOwnProperty.call(t,e)||(c[e]=i.right),A}))}}}}let re=({es:e,output:t})=>{if(Te(e))return y(new U(n,r,oh(e),t));if(u?.propertyOrder===`original`){let e=ee||Reflect.ownKeys(r);for(let t of i)e.indexOf(t)===-1&&e.push(t);let n={};for(let r of e)Object.prototype.hasOwnProperty.call(t,r)&&(n[r]=t[r]);return b(n)}return b(t)};if(_&&_.length>0){let e=_;return M(()=>{let t={es:tn(f),output:Object.assign({},g)};return D(on(e,e=>e(t),{concurrency:c,batching:l,discard:!0}),()=>re(t))})}return re({es:f,output:g})}}case`Union`:{let e=nh(n.types,r),t=Reflect.ownKeys(e.keys),i=t.length,a=n.types.length,o=new Map;for(let e=0;e<a;e++)o.set(n.types[e],K(n.types[e],r));let s=Zm(n)??1,c=Qm(n);return(r,l)=>{let u=[],d=0,f=[];if(i>0)if(gt(r))for(let n=0;n<i;n++){let i=t[n],o=e.keys[i].buckets;if(Object.prototype.hasOwnProperty.call(r,i)){let t=String(r[i]);if(Object.prototype.hasOwnProperty.call(o,t))f=f.concat(o[t]);else{let{candidates:t,literals:n}=e.keys[i],o=Rc.make(n),s=t.length===a?new Ac([new I(i,o,!1,!0)],[]):Rc.make(t);u.push([d++,new U(s,r,new H(i,r,new W(o,r[i])))])}}else{let{candidates:t,literals:n}=e.keys[i],o=new I(i,Rc.make(n),!1,!0),s=t.length===a?new Ac([o],[]):Rc.make(t);u.push([d++,new U(s,r,new H(i,r,new xm(o)))])}}else{let t=e.candidates.length===a?n:Rc.make(e.candidates);u.push([d++,new W(t,r)])}e.otherwise.length>0&&(f=f.concat(e.otherwise));let p;for(let e=0;e<f.length;e++){let t=f[e],n=o.get(t)(r,l);if(jm(n)&&(!p||p.length===0)){if(te(n))return n;u.push([d++,n.left])}else{let e=d++;p||=[],p.push(t=>M(()=>`finalResult`in t?A:D(br(n),n=>(te(n)?t.finalResult=n:t.es.push([e,n.left]),A))))}}let m=e=>Te(e)?e.length===1&&e[0][1]._tag===`Type`?y(e[0][1]):y(new U(n,r,oh(e))):y(new W(n,r));if(p&&p.length>0){let e=p;return M(()=>{let t={es:tn(u)};return D(on(e,e=>e(t),{concurrency:s,batching:c,discard:!0}),()=>`finalResult`in t?t.finalResult:m(t.es))})}return m(u)}}case`Suspend`:{let e=Ho(()=>K(n.f(),r));return(t,n)=>e()(t,n)}}},eh=(e,t)=>n=>t(n)?b(n):y(new W(e,n)),th=(e,t)=>{switch(e._tag){case`Declaration`:{let n=$s(e);if(bt(n))return th(n.value,t);break}case`TypeLiteral`:{let n=[];for(let r=0;r<e.propertySignatures.length;r++){let i=e.propertySignatures[r],a=t?pl(i.type):L(i.type);cc(a)&&!i.isOptional&&n.push([i.name,a])}return n}case`TupleType`:{let n=[];for(let r=0;r<e.elements.length;r++){let i=e.elements[r],a=t?pl(i.type):L(i.type);cc(a)&&!i.isOptional&&n.push([r,a])}return n}case`Refinement`:return th(e.from,t);case`Suspend`:return th(e.f(),t);case`Transformation`:return th(t?e.from:e.to,t)}return[]},nh=(e,t)=>{let n={},r=[],i=[];for(let a=0;a<e.length;a++){let o=e[a],s=th(o,t);if(s.length>0){i.push(o);for(let e=0;e<s.length;e++){let[t,r]=s[e],i=String(r.literal);n[t]=n[t]||{buckets:{},literals:[],candidates:[]};let a=n[t].buckets;if(Object.prototype.hasOwnProperty.call(a,i)){if(e<s.length-1)continue;a[i].push(o),n[t].literals.push(r),n[t].candidates.push(o)}else{a[i]=[o],n[t].literals.push(r),n[t].candidates.push(o);break}}}else r.push(o)}return{keys:n,otherwise:r,candidates:i}},rh=e=>Gc(e)?rh(e.from):e,ih=(e,t,n,r)=>{if(r?.isEffectAllowed===!0||jm(e))return e;let i=new lr,a=yn(e,{scheduler:i});i.flush();let o=a.unsafePoll();if(o){if(di(o))return b(o.value);let e=o.cause;return ri(e)?y(e.error):y(new wm(t,n,ti(e)))}return y(new wm(t,n,`cannot be be resolved synchronously, this is caused by using runSync on an effect that performs async work`))},ah=([e],[t])=>e>t?1:e<t?-1:0;function oh(e){return e.sort(ah).map(e=>e[1])}const sh=(e,t)=>{switch(e._tag){case`FinalTransformation`:return t?e.decode:e.encode;case`ComposeTransformation`:return b;case`TypeLiteralTransformation`:return n=>{let r=b(n);for(let n of e.propertySignatureTransformations){let[e,i]=t?[n.from,n.to]:[n.to,n.from],a=t?n.decode:n.encode;r=Nm(r,t=>{let n=a(Object.prototype.hasOwnProperty.call(t,e)?w(t[e]):v());return delete t[e],bt(n)&&(t[i]=n.value),t})}return r}}},ch=(e,t=[])=>({value:e,forest:t}),lh={formatIssue:e=>Nm(Ah(e),uh),formatIssueSync:e=>{let t=lh.formatIssue(e);return jm(t)?ze(t):Wn(t)},formatError:e=>lh.formatIssue(e.issue),formatErrorSync:e=>lh.formatIssueSync(e.issue)},uh=e=>e.value+dh(`
15
- `,e.forest),dh=(e,t)=>{let n=``,r=t.length,i;for(let a=0;a<r;a++){i=t[a];let o=a===r-1;n+=e+(o?`└`:`├`)+`─ `+i.value,n+=dh(e+(r>1&&!o?`│ `:` `),i.forest)}return n},fh=e=>{switch(e){case`Encoded`:return`Encoded side transformation failure`;case`Transformation`:return`Transformation process failure`;case`Type`:return`Type side transformation failure`}},ph=e=>{switch(e){case`From`:return`From side refinement failure`;case`Predicate`:return`Predicate refinement failure`}},mh=e=>`ast`in e?w(e.ast):v(),hh=b(void 0),gh=e=>mh(e).pipe(Zt(Hs),_({onNone:()=>hh,onSome:t=>{let n=t(e);return Qe(n)?b({message:n,override:!1}):wn(n)?T(n,e=>({message:e,override:!1})):Qe(n.message)?b({message:n.message,override:n.override}):T(n.message,e=>({message:e,override:n.override}))}})),_h=e=>t=>t._tag===e,vh=_h(`Composite`),yh=_h(`Refinement`),bh=_h(`Transformation`),xh=e=>Mm(gh(e),t=>t===void 0?hh:!t.override&&(vh(e)||yh(e)&&e.kind===`From`||bh(e)&&e.kind!==`Transformation`)?bh(e)||yh(e)?xh(e.issue):hh:b(t.message)),Sh=e=>mh(e).pipe(Zt(Xs),ke(t=>t(e)),f);function Ch(e){return qs(e).pipe(pe(()=>Ws(e)),pe(()=>Gs(e)),pe(()=>Ks(e)),Ne(()=>`{ ${e.from} | filter }`))}function wh(e){return e.message===void 0?`Expected ${Gc(e.ast)?Ch(e.ast):String(e.ast)}, actual ${l(e.actual)}`:e.message}const Th=e=>Nm(xh(e),t=>t??Sh(e)??wh(e)),Eh=e=>Sh(e)??String(e.ast),Dh=e=>e.message??`is forbidden`,Oh=e=>e.message??`is unexpected`,kh=e=>{let t=Us(e.ast);if(bt(t)){let e=t.value();return Qe(e)?b(e):e}return b(e.message??`is missing`)},Ah=e=>{switch(e._tag){case`Type`:return Nm(Th(e),ch);case`Forbidden`:return b(ch(Eh(e),[ch(Dh(e))]));case`Unexpected`:return b(ch(Oh(e)));case`Missing`:return Nm(kh(e),ch);case`Transformation`:return Mm(xh(e),t=>t===void 0?Nm(Ah(e.issue),t=>ch(Eh(e),[ch(fh(e.kind),[t])])):b(ch(t)));case`Refinement`:return Mm(xh(e),t=>t===void 0?Nm(Ah(e.issue),t=>ch(Eh(e),[ch(ph(e.kind),[t])])):b(ch(t)));case`Pointer`:return Nm(Ah(e.issue),t=>ch(Ko(e.path),[t]));case`Composite`:return Mm(xh(e),t=>{if(t!==void 0)return b(ch(t));let n=Eh(e);return Uo(e.issues)?Nm(on(e.issues,Ah),e=>ch(n,e)):Nm(Ah(e.issues),e=>ch(n,[e]))})}},jh=x(e=>Dt(e[0]),(e,...t)=>{let n={};for(let r of t)r in e&&(n[r]=e[r]);return n}),Mh=x(e=>Dt(e[0]),(e,...t)=>{let n={...e};for(let e of t)delete n[e];return n}),Nh=Symbol.for(`effect/Schema`);function q(e){return class{[Nh]=Ph;static ast=e;static annotations(e){return q(Lh(this.ast,e))}static pipe(){return De(this,arguments)}static toString(){return String(e)}static Type;static Encoded;static Context;static[Nh]=Ph}}const Ph={_A:e=>e,_I:e=>e,_R:e=>e},Fh={typeConstructor:vs,schemaId:bs,message:xs,missingMessage:Ss,identifier:Cs,title:ws,description:Es,examples:Ds,default:Os,documentation:Ns,jsonSchema:ks,arbitrary:As,pretty:js,equivalence:Ms,concurrency:Ps,batching:Fs,parseIssueTitle:Is,parseOptions:Ls,decodingFallback:Rs},Ih=e=>{if(!e)return{};let t={...e};for(let n in Fh)if(n in e){let r=Fh[n];t[r]=e[n],delete t[n]}return t},Lh=(e,t)=>tl(e,Ih(t)),Rh=e=>String(e.ast),zh=e=>q(pl(e.ast)),Bh=e=>q(L(e.ast)),Vh=e=>Nt(e,Nh)&&Dt(e[Nh]);function Hh(e){return Bc(e)?Rc.make(zc(e,e=>new sc(e))):new sc(e[0])}function Uh(e,t=Hh(e)){return class extends q(t){static annotations(e){return Uh(this.literals,Lh(this.ast,e))}static literals=[...e]}}function Wh(...e){return t(e)?Uh(e):Qh}const Gh=(e,t,n)=>qh(e,new ac(e.map(e=>e.ast),(...e)=>t.decode(...e.map(q)),(...e)=>t.encode(...e.map(q)),Ih(n))),Kh=(e,t)=>{let n=()=>(t,n,r)=>e(t)?G(t):Om(new W(r,t));return qh([],new ac([],n,n,Ih(t)))};function qh(e,t){return class extends q(t){static annotations(e){return qh(this.typeParameters,Lh(this.ast,e))}static typeParameters=[...e]}}const Jh=function(){if(Array.isArray(arguments[0])){let e=arguments[0],t=arguments[1],n=arguments[2];return Gh(e,t,n)}let e=arguments[0],t=arguments[1];return Kh(e,t)},Yh=Symbol.for(`effect/SchemaId/InstanceOf`),Xh=(e,t)=>Jh(t=>t instanceof e,{title:e.name,description:`an instance of ${e.name}`,pretty:()=>String,schemaId:Yh,[Yh]:{constructor:e},...t});var Zh=class extends q(uc){},Qh=class extends q(dc){},$h=class extends q(fc){},eg=class extends q(bc){},tg=class extends q(xc){},J=class extends q(mc){},Y=class extends q(gc){},ng=class extends q(vc){};const rg=e=>Rc.make(e.map(e=>e.ast));function ig(e,t=rg(e)){return class extends q(t){static annotations(e){return ig(this.members,Lh(this.ast,e))}static members=[...e]}}function ag(...e){return Bc(e)?ig(e):t(e)?e[0]:Qh}const og=e=>ag(e,Zh),sg=e=>new cg(new wc(e.ast,!1),e);var cg=class e{ast;from;[Nh];_Token;constructor(e,t){this.ast=e,this.from=t}annotations(t){return new e(new wc(this.ast.type,this.ast.isOptional,{...this.ast.annotations,...Ih(t)}),this.from)}toString(){return`${this.ast.type}${this.ast.isOptional?`?`:``}`}};const lg=(e,t)=>new Ec(e.map(e=>Vh(e)?new wc(e.ast,!1):e.ast),t.map(e=>Vh(e)?new Cc(e.ast):e.ast),!0);function ug(e,t,n=lg(e,t)){return class extends q(n){static annotations(e){return ug(this.elements,this.rest,Lh(this.ast,e))}static elements=[...e];static rest=[...t]}}function dg(...e){return Array.isArray(e[0])?ug(e[0],e.slice(1)):ug(e,[])}function fg(e,t){return class extends ug([],[e],t){static annotations(e){return fg(this.value,Lh(this.ast,e))}static value=e}}const pg=e=>fg(e),mg=e=>e?`"?:"`:`":"`;var hg=class extends wc{isReadonly;defaultValue;_tag=`PropertySignatureDeclaration`;constructor(e,t,n,r,i){super(e,t,r),this.isReadonly=n,this.defaultValue=i}toString(){let e=mg(this.isOptional),t=String(this.type);return`PropertySignature<${e}, ${t}, never, ${e}, ${t}>`}};(class extends wc{isReadonly;fromKey;constructor(e,t,n,r,i){super(e,t,r),this.isReadonly=n,this.fromKey=i}});var gg=class extends wc{isReadonly;defaultValue;constructor(e,t,n,r,i){super(e,t,r),this.isReadonly=n,this.defaultValue=i}};const _g=e=>e===void 0?`never`:Qe(e)?JSON.stringify(e):String(e);var vg=class{from;to;decode;encode;_tag=`PropertySignatureTransformation`;constructor(e,t,n,r){this.from=e,this.to=t,this.decode=n,this.encode=r}toString(){return`PropertySignature<${mg(this.to.isOptional)}, ${this.to.type}, ${_g(this.from.fromKey)}, ${mg(this.from.isOptional)}, ${this.from.type}>`}};const yg=(e,t)=>{switch(e._tag){case`PropertySignatureDeclaration`:return new hg(e.type,e.isOptional,e.isReadonly,{...e.annotations,...t},e.defaultValue);case`PropertySignatureTransformation`:return new vg(e.from,new gg(e.to.type,e.to.isOptional,e.to.isReadonly,{...e.to.annotations,...t},e.to.defaultValue),e.decode,e.encode)}},bg=Symbol.for(`effect/PropertySignature`),xg=e=>Nt(e,bg);var Sg=class e{ast;[Nh];[bg]=null;_TypeToken;_Key;_EncodedToken;_HasDefault;constructor(e){this.ast=e}pipe(){return De(this,arguments)}annotations(t){return new e(yg(this.ast,Ih(t)))}toString(){return String(this.ast)}};const Cg=e=>new Sg(e);var wg=class e extends Sg{from;constructor(e,t){super(e),this.from=t}annotations(t){return new e(yg(this.ast,Ih(t)),this.from)}};const Tg=e=>new wg(new hg(e.ast,!1,!0,{},void 0),e),Eg=x(2,(e,t)=>{let n=e.ast;switch(n._tag){case`PropertySignatureDeclaration`:return Cg(new hg(n.type,n.isOptional,n.isReadonly,n.annotations,t));case`PropertySignatureTransformation`:return Cg(new vg(n.from,new gg(n.to.type,n.to.isOptional,n.to.isReadonly,n.to.annotations,t),n.decode,n.encode))}}),Dg=e=>new wg(new hg(e.ast===uc||e.ast===dc?uc:og(e).ast,!0,!0,{},void 0),e),Og=sl([Ss]),kg=(e,n)=>{let r=Reflect.ownKeys(e),i=[];if(r.length>0){let a=[],o=[],s=[];for(let t=0;t<r.length;t++){let n=r[t],c=e[n];if(xg(c)){let e=c.ast;switch(e._tag){case`PropertySignatureDeclaration`:{let t=e.type,r=e.isOptional,s=e.annotations;a.push(new I(n,t,r,!0,Og(e))),o.push(new I(n,L(t),r,!0,s)),i.push(new I(n,t,r,!0,s));break}case`PropertySignatureTransformation`:{let t=e.from.fromKey??n;a.push(new I(t,e.from.type,e.from.isOptional,!0,e.from.annotations)),o.push(new I(n,e.to.type,e.to.isOptional,!0,e.to.annotations)),s.push(new Qc(t,n,e.decode,e.encode));break}}}else a.push(new I(n,c.ast,!1,!0)),o.push(new I(n,L(c.ast),!1,!0)),i.push(new I(n,c.ast,!1,!0))}if(t(s)){let e=[],t=[];for(let r of n){let{indexSignatures:n,propertySignatures:i}=ol(r.key.ast,r.value.ast);i.forEach(e=>{a.push(e),o.push(new I(e.name,L(e.type),e.isOptional,e.isReadonly,e.annotations))}),n.forEach(n=>{e.push(n),t.push(new kc(n.parameter,L(n.type),n.isReadonly))})}return new qc(new Ac(a,e,{[Ts]:`Struct (Encoded side)`}),new Ac(o,t,{[Ts]:`Struct (Type side)`}),new $c(s))}}let a=[];for(let e of n){let{indexSignatures:t,propertySignatures:n}=ol(e.key.ast,e.value.ast);n.forEach(e=>i.push(e)),t.forEach(e=>a.push(e))}return new Ac(i,a)},Ag=(e,t)=>{let n=Reflect.ownKeys(e);for(let r of n){let n=e[r];if(t[r]===void 0&&xg(n)){let e=n.ast,i=e._tag===`PropertySignatureDeclaration`?e.defaultValue:e.to.defaultValue;i!==void 0&&(t[r]=i())}}return t};function jg(e,t,n=kg(e,t)){return class extends q(n){static annotations(e){return jg(this.fields,this.records,Lh(this.ast,e))}static fields={...e};static records=[...t];static make=(t,n)=>{let r=Ag(e,{...t});return Jv(n)?r:qm(this)(r)};static pick(...t){return X(jh(e,...t))}static omit(...t){return X(Mh(e,...t))}}}function X(e,...t){return jg(e,t)}const Mg=e=>Wh(e).pipe(Tg,Eg(()=>e)),Ng=(e,t)=>X({_tag:Mg(e),...t});function Pg(e,t,n){return class extends jg({},[{key:e,value:t}],n){static annotations(n){return Pg(e,t,Lh(this.ast,n))}static key=e;static value=t}}const Fg=e=>Pg(e.key,e.value);function Ig(e,t){return class extends q(t){static annotations(e){return Ig(this.from,Lh(this.ast,e))}static make=(e,t)=>Jv(t)?e:qm(this)(e);static from=e}}const Lg=(e,t)=>n=>{let r=_(Vs(n.ast),{onNone:()=>[e],onSome:t=>[...t,e]});return Ig(n,tl(n.ast,Ih({[ys]:r,...t})))},Rg=(e,t,n)=>{if(Nc(e)&&Nc(t)){let r=[...e.propertySignatures];for(let e of t.propertySignatures){let t=e.name,i=r.findIndex(e=>e.name===t);if(i===-1)r.push(e);else{let{isOptional:a,type:o}=r[i];r[i]=new I(t,Vg(o,e.type,n.concat(t)),a,!0)}}return new Ac(r,e.indexSignatures.concat(t.indexSignatures))}throw Error(Yo(e,t,n))},zg=cl([Cs]),Bg=(e,t)=>t.map(t=>new Wc(t,e.filter,zg(e))),Vg=(e,t,n)=>Rc.make(Ug([e],[t],n)),Hg=e=>Vc(e)?e.types:[e],Ug=(e,t,n)=>Ve(e,e=>Ve(t,t=>{switch(t._tag){case`Literal`:if(Qe(t.literal)&&hc(e)||Vt(t.literal)&&_c(e)||Ke(t.literal)&&yc(e))return[t];break;case`StringKeyword`:if(t===mc){if(hc(e)||cc(e)&&Qe(e.literal))return[e];if(Gc(e))return Bg(e,Ug(Hg(e.from),[t],n))}else if(e===mc)return[t];break;case`NumberKeyword`:if(t===gc){if(_c(e)||cc(e)&&Vt(e.literal))return[e];if(Gc(e))return Bg(e,Ug(Hg(e.from),[t],n))}else if(e===gc)return[t];break;case`BooleanKeyword`:if(t===vc){if(yc(e)||cc(e)&&Ke(e.literal))return[e];if(Gc(e))return Bg(e,Ug(Hg(e.from),[t],n))}else if(e===vc)return[t];break;case`Union`:return Ug(Hg(e),t.types,n);case`Suspend`:return[new Uc(()=>Vg(e,t.f(),n))];case`Refinement`:return Bg(t,Ug(Hg(e),Hg(t.from),n));case`TypeLiteral`:switch(e._tag){case`Union`:return Ug(e.types,[t],n);case`Suspend`:return[new Uc(()=>Vg(e.f(),t,n))];case`Refinement`:return Bg(e,Ug(Hg(e.from),[t],n));case`TypeLiteral`:return[Rg(e,t,n)];case`Transformation`:{let r=e.transformation,i=Rg(e.from,t,n),a=Rg(e.to,L(t),n);switch(r._tag){case`TypeLiteralTransformation`:return[new qc(i,a,new $c(r.propertySignatureTransformations))];case`ComposeTransformation`:return[new qc(i,a,Zc)];case`FinalTransformation`:return[new qc(i,a,new Yc((e,t,n,i)=>Nm(r.decode(e,t,n,i),t=>({...e,...t})),(e,t,n,i)=>Nm(r.encode(e,t,n,i),t=>({...e,...t}))))]}}}break;case`Transformation`:if(Jc(e)){if(el(t.transformation)&&el(e.transformation))return[new qc(Rg(e.from,t.from,n),Rg(e.to,t.to,n),new $c(t.transformation.propertySignatureTransformations.concat(e.transformation.propertySignatureTransformations)))]}else return Ug([t],[e],n);break}throw Error(Yo(e,t,n))})),Wg=x(2,(e,t)=>q(Vg(e.ast,t.ast,[]))),Gg=e=>q(new Uc(()=>e().ast)),Kg=Symbol.for(`effect/SchemaId/Refine`);function qg(e,t,n){return class extends q(n){static annotations(e){return qg(this.from,this.filter,Lh(this.ast,e))}static[Kg]=e;static from=e;static filter=t;static make=(e,t)=>Jv(t)?e:qm(this)(e)}}const Jg=(e,n,r)=>{if(Ke(e))return e?v():w(new W(n,r));if(Qe(e))return w(new W(n,r,e));if(e!==void 0){if(`_tag`in e)return w(e);let i=new W(n,r,e.message);return w(t(e.path)?new H(e.path,r,i):i)}return v()},Yg=(e,n,r)=>{if(Wo(e))return Jg(e,n,r);if(t(e)){let i=Fe(e,e=>Jg(e,n,r));if(t(i))return w(i.length===1?i[0]:new U(n,r,i))}return v()};function Z(e,t){return n=>{function r(t,n,r){return Yg(e(t,n,r),r,t)}return qg(n,r,new Wc(n.ast,r,Ih(t)))}}function Xg(e,t,n){return class extends q(n){static annotations(e){return Xg(this.from,this.to,Lh(this.ast,e))}static from=e;static to=t}}const Q=x(e=>Vh(e[0])&&Vh(e[1]),(e,t,n)=>Xg(e,t,new qc(e.ast,t.ast,new Yc(n.decode,n.encode)))),$=x(e=>Vh(e[0])&&Vh(e[1]),(e,t,n)=>Q(e,t,{strict:!0,decode:(e,t,r,i)=>G(n.decode(e,i)),encode:(e,t,r,i)=>G(n.encode(e,i))})),Zg=x(2,(e,t)=>e.annotations(t)),Qg=Symbol.for(`effect/SchemaId/Trimmed`),$g=e=>t=>t.pipe(Z(e=>e===e.trim(),{schemaId:Qg,title:`trimmed`,description:`a string with no leading or trailing whitespace`,jsonSchema:{pattern:`^\\S[\\s\\S]*\\S$|^\\S$|^$`},...e})),e_=hs,t_=(e,t)=>n=>n.pipe(Z(t=>t.length>=e,{schemaId:e_,title:`minLength(${e})`,description:`a string at least ${e} character(s) long`,jsonSchema:{minLength:e},...t})),n_=gs,r_=(e,t)=>n=>{let r=Dt(e)?Math.max(0,Math.floor(e.min)):Math.max(0,Math.floor(e)),i=Dt(e)?Math.max(r,Math.floor(e.max)):r;return r===i?n.pipe(Z(e=>e.length===r,{schemaId:n_,title:`length(${r})`,description:r===1?`a single character`:`a string ${r} character(s) long`,jsonSchema:{minLength:r,maxLength:r},...t})):n.pipe(Z(e=>e.length>=r&&e.length<=i,{schemaId:n_,title:`length({ min: ${r}, max: ${i})`,description:`a string at least ${r} character(s) and at most ${i} character(s) long`,jsonSchema:{minLength:r,maxLength:i},...t}))},i_=Symbol.for(`effect/SchemaId/Pattern`),a_=(e,t)=>n=>{let r=e.source;return n.pipe(Z(t=>(e.lastIndex=0,e.test(t)),{schemaId:i_,[i_]:{regex:e},description:`a string matching the pattern ${r}`,jsonSchema:{pattern:r},...t}))},o_=Symbol.for(`effect/SchemaId/Lowercased`),s_=e=>t=>t.pipe(Z(e=>e===e.toLowerCase(),{schemaId:o_,title:`lowercased`,description:`a lowercase string`,jsonSchema:{pattern:`^[^A-Z]*$`},...e}));var c_=class extends J.pipe(s_({identifier:`Lowercased`})){};const l_=Symbol.for(`effect/SchemaId/Uppercased`),u_=e=>t=>t.pipe(Z(e=>e===e.toUpperCase(),{schemaId:l_,title:`uppercased`,description:`an uppercase string`,jsonSchema:{pattern:`^[^a-z]*$`},...e}));var d_=class extends J.pipe(u_({identifier:`Uppercased`})){};const f_=Symbol.for(`effect/SchemaId/Capitalized`),p_=e=>t=>t.pipe(Z(e=>e[0]?.toUpperCase()===e[0],{schemaId:f_,title:`capitalized`,description:`a capitalized string`,jsonSchema:{pattern:`^[^a-z]?.*$`},...e}));var m_=class extends J.pipe(p_({identifier:`Capitalized`})){};const h_=Symbol.for(`effect/SchemaId/Uncapitalized`),g_=e=>t=>t.pipe(Z(e=>e[0]?.toLowerCase()===e[0],{schemaId:h_,title:`uncapitalized`,description:`a uncapitalized string`,jsonSchema:{pattern:`^[^A-Z]?.*$`},...e}));var __=class extends J.pipe(g_({identifier:`Uncapitalized`})){};J.pipe(r_(1,{identifier:`Char`}));const v_=e=>t_(1,{title:`nonEmptyString`,description:`a non empty string`,...e});$(J.annotations({description:`a string that will be converted to lowercase`}),c_,{strict:!0,decode:e=>e.toLowerCase(),encode:S}).annotations({identifier:`Lowercase`}),$(J.annotations({description:`a string that will be converted to uppercase`}),d_,{strict:!0,decode:e=>e.toUpperCase(),encode:S}).annotations({identifier:`Uppercase`}),$(J.annotations({description:`a string that will be converted to a capitalized format`}),m_,{strict:!0,decode:e=>Ta(e),encode:S}).annotations({identifier:`Capitalize`}),$(J.annotations({description:`a string that will be converted to an uncapitalized format`}),__,{strict:!0,decode:e=>Ea(e),encode:S}).annotations({identifier:`Uncapitalize`});var y_=class extends J.pipe($g({identifier:`Trimmed`})){},b_=class extends y_.pipe(v_({identifier:`NonEmptyTrimmedString`})){};$(J.annotations({description:`a string that will be trimmed`}),y_,{strict:!0,decode:e=>e.trim(),encode:S}).annotations({identifier:`Trim`});const x_=e=>e instanceof Error?e.message:String(e);J.pipe(v_({identifier:`NonEmptyString`}));const S_=Symbol.for(`effect/SchemaId/UUID`),C_=/^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$/i;J.pipe(a_(C_,{schemaId:S_,identifier:`UUID`,jsonSchema:{format:`uuid`,pattern:C_.source},description:`a Universally Unique Identifier`,arbitrary:()=>e=>e.uuid()}));const w_=Symbol.for(`effect/SchemaId/ULID`);J.pipe(a_(/^[0-7][0-9A-HJKMNP-TV-Z]{25}$/i,{schemaId:w_,identifier:`ULID`,description:`a Universally Unique Lexicographically Sortable Identifier`,arbitrary:()=>e=>e.ulid()}));var T_=class extends Xh(URL,{typeConstructor:{_tag:`URL`},identifier:`URLFromSelf`,arbitrary:()=>e=>e.webUrl().map(e=>new URL(e)),pretty:()=>e=>e.toString()}){};Q(J.annotations({description:`a string to be decoded into a URL`}),T_,{strict:!0,decode:(e,t,n)=>km({try:()=>new URL(e),catch:t=>new W(n,e,`Unable to decode ${JSON.stringify(e)} into a URL. ${x_(t)}`)}),encode:e=>G(e.toString())}).annotations({identifier:`URL`,pretty:()=>e=>e.toString()});const E_=us,D_=e=>t=>t.pipe(Z(Number.isFinite,{schemaId:E_,title:`finite`,description:`a finite number`,jsonSchema:{},...e})),O_=is,k_=(e,t)=>n=>n.pipe(Z(t=>t>e,{schemaId:O_,title:`greaterThan(${e})`,description:e===0?`a positive number`:`a number greater than ${e}`,jsonSchema:{exclusiveMinimum:e},...t})),A_=as,j_=(e,t)=>n=>n.pipe(Z(t=>t>=e,{schemaId:A_,title:`greaterThanOrEqualTo(${e})`,description:e===0?`a non-negative number`:`a number greater than or equal to ${e}`,jsonSchema:{minimum:e},...t})),M_=cs,N_=e=>t=>t.pipe(Z(e=>Number.isSafeInteger(e),{schemaId:M_,title:`int`,description:`an integer`,jsonSchema:{type:`integer`},...e})),P_=os,F_=(e,t)=>n=>n.pipe(Z(t=>t<e,{schemaId:P_,title:`lessThan(${e})`,description:e===0?`a negative number`:`a number less than ${e}`,jsonSchema:{exclusiveMaximum:e},...t})),I_=ss,L_=(e,t)=>n=>n.pipe(Z(t=>t<=e,{schemaId:I_,title:`lessThanOrEqualTo(${e})`,description:e===0?`a non-positive number`:`a number less than or equal to ${e}`,jsonSchema:{maximum:e},...t})),R_=fs,z_=(e,t,n)=>r=>r.pipe(Z(n=>n>=e&&n<=t,{schemaId:R_,title:`between(${e}, ${t})`,description:`a number between ${e} and ${t}`,jsonSchema:{minimum:e,maximum:t},...n})),B_=ls,V_=e=>t=>t.pipe(Z(e=>!Number.isNaN(e),{schemaId:B_,title:`nonNaN`,description:`a number excluding NaN`,...e})),H_=e=>k_(0,{title:`positive`,...e}),U_=e=>F_(0,{title:`negative`,...e}),W_=e=>L_(0,{title:`nonPositive`,...e}),G_=e=>j_(0,{title:`nonNegative`,...e});function K_(e){return Q(e,Y,{strict:!1,decode:(e,t,n)=>Am(ln(e),()=>new W(n,e,`Unable to decode ${JSON.stringify(e)} into a number`)),encode:e=>G(String(e))})}K_(J.annotations({description:`a string to be decoded into a number`})).annotations({identifier:`NumberFromString`}),Y.pipe(D_({identifier:`Finite`}));var q_=class extends Y.pipe(N_({identifier:`Int`})){};Y.pipe(V_({identifier:`NonNaN`})),Y.pipe(H_({identifier:`Positive`})),Y.pipe(U_({identifier:`Negative`})),Y.pipe(W_({identifier:`NonPositive`}));var J_=class extends Y.pipe(G_({identifier:`NonNegative`})){};const Y_=ds;Y.pipe(D_({schemaId:Y_,identifier:`JsonNumber`})),$(ng.annotations({description:`a boolean that will be negated`}),ng,{strict:!0,decode:e=>Ur(e),encode:e=>Ur(e)});const X_=(e,t)=>{let n=Symbol.keyFor(e);return n===void 0?Om(new W(t,e,`Unable to encode a unique symbol ${String(e)} into a string`)):G(n)},Z_=e=>G(Symbol.for(e));Q(J.annotations({description:`a string to be decoded into a globally shared symbol`}),tg,{strict:!1,decode:e=>Z_(e),encode:(e,t,n)=>X_(e,n)}).annotations({identifier:`Symbol`});const Q_=ps,$_=(e,t)=>n=>n.pipe(Z(t=>t>=e,{schemaId:Q_,[Q_]:{min:e},title:`greaterThanOrEqualToBigInt(${e})`,description:e===0n?`a non-negative bigint`:`a bigint greater than or equal to ${e}n`,...t})),ev=ms,tv=(e,t,n)=>r=>r.pipe(Z(n=>n>=e&&n<=t,{schemaId:ev,[ev]:{min:e,max:t},title:`betweenBigInt(${e}, ${t})`,description:`a bigint between ${e}n and ${t}n`,...n})),nv=e=>$_(0n,{title:`nonNegativeBigInt`,...e});var rv=class extends Q(J.annotations({description:`a string to be decoded into a bigint`}),eg,{strict:!0,decode:(e,t,n)=>Am(Hl(e),()=>new W(n,e,`Unable to decode ${JSON.stringify(e)} into a bigint`)),encode:e=>G(String(e))}).annotations({identifier:`BigInt`}){};const iv=eg.pipe(nv({identifier:`NonNegativeBigintFromSelf`}));Q(Y.annotations({description:`a number to be decoded into a bigint`}),eg.pipe(tv(BigInt(-(2**53-1)),BigInt(2**53-1))),{strict:!0,decode:(e,t,n)=>Am(Ul(e),()=>new W(n,e,`Unable to decode ${e} into a bigint`)),encode:(e,t,n)=>Am(Vl(e),()=>new W(n,e,`Unable to encode ${e}n into a number`))}).annotations({identifier:`BigIntFromNumber`});const av=(e,t,n,r)=>Fm(e,{onFailure:e=>new U(n,r,e),onSuccess:t});var ov=class extends Jh(se,{typeConstructor:{_tag:`effect/Duration`},identifier:`DurationFromSelf`,pretty:()=>String,arbitrary:()=>e=>e.oneof(e.constant(Pt),e.bigInt({min:0n}).map(e=>we(e)),e.maxSafeNat().map(e=>Ye(e))),equivalence:()=>Be}){};Q(iv.annotations({description:`a bigint to be decoded into a Duration`}),ov.pipe(Z(e=>qe(e),{description:`a finite duration`})),{strict:!0,decode:e=>G(we(e)),encode:(e,t,n)=>_(Bt(e),{onNone:()=>Om(new W(n,e,`Unable to encode ${e} into a bigint`)),onSome:e=>G(e)})}).annotations({identifier:`DurationFromNanos`});const sv=J_.pipe(N_()).annotations({identifier:`NonNegativeInt`});$(J_.annotations({description:`a non-negative number to be decoded into a Duration`}),ov,{strict:!0,decode:e=>Ye(e),encode:e=>lt(e)}).annotations({identifier:`DurationFromMillis`});const cv=Ng(`Millis`,{millis:sv}),lv=Ng(`Nanos`,{nanos:rv}),uv=Ng(`Infinity`,{}),dv=uv.make({}),fv=ag(cv,lv,uv).annotations({identifier:`DurationValue`,description:`an JSON-compatible tagged union to be decoded into a Duration`}),pv=ag(dg(sg(sv).annotations({title:`seconds`}),sg(sv).annotations({title:`nanos`})).annotations({identifier:`FiniteHRTime`}),dg(Wh(-1),Wh(0)).annotations({identifier:`InfiniteHRTime`})).annotations({identifier:`HRTime`,description:`a tuple of seconds and nanos to be decoded into a Duration`}),mv=e=>typeof e==`object`;$(ag(fv,pv),ov,{strict:!0,decode:e=>{if(mv(e))switch(e._tag){case`Millis`:return Ye(e.millis);case`Nanos`:return we(e.nanos);case`Infinity`:return Pt}let[t,n]=e;return t===-1?Pt:we(BigInt(t)*BigInt(1e9)+BigInt(n))},encode:e=>{switch(e.value._tag){case`Millis`:return cv.make({millis:e.value.millis});case`Nanos`:return lv.make({nanos:e.value.nanos});case`Infinity`:return dv}}}).annotations({identifier:`Duration`});var hv=class extends Jh(Et,{typeConstructor:{_tag:`Uint8Array`},identifier:`Uint8ArrayFromSelf`,pretty:()=>e=>`new Uint8Array(${JSON.stringify(Array.from(e))})`,arbitrary:()=>e=>e.uint8Array(),equivalence:()=>Ft(vt)}){};$(pg(class extends Y.pipe(z_(0,255,{identifier:`Uint8`,description:`a 8-bit unsigned integer`})){}).annotations({description:`an array of 8-bit unsigned integers to be decoded into a Uint8Array`}),hv,{strict:!0,decode:e=>Uint8Array.from(e),encode:e=>Array.from(e)}).annotations({identifier:`Uint8Array`});const gv=_s,_v=(e,t)=>n=>{let r=Math.floor(e);if(r<1)throw Error(Jo(`Expected an integer greater than or equal to 1, actual ${e}`));return n.pipe(Z(e=>e.length>=r,{schemaId:gv,title:`minItems(${r})`,description:`an array of at least ${r} item(s)`,jsonSchema:{minItems:r},[Bs]:!0,...t}))},vv=Symbol.for(`effect/SchemaId/ValidDate`),yv=e=>t=>t.pipe(Z(e=>!Number.isNaN(e.getTime()),{schemaId:vv,[vv]:{noInvalidDate:!0},title:`validDate`,description:`a valid Date`,...e})),bv=rs;var xv=class extends Jh(Ue,{typeConstructor:{_tag:`Date`},identifier:`DateFromSelf`,schemaId:bv,[bv]:{noInvalidDate:!1},description:`a potentially invalid Date instance`,pretty:()=>e=>`new Date(${JSON.stringify(e)})`,arbitrary:()=>e=>e.date({noInvalidDate:!1}),equivalence:()=>dt}){};xv.pipe(yv({identifier:`ValidDateFromSelf`,description:`a valid Date instance`})),class extends $(J.annotations({description:`a string to be decoded into a Date`}),xv,{strict:!0,decode:e=>new Date(e),encode:e=>Ae(e)}).annotations({identifier:`DateFromString`}){}.pipe(yv({identifier:`Date`})),$(Y.annotations({description:`a number to be decoded into a Date`}),xv,{strict:!0,decode:e=>new Date(e),encode:e=>e.getTime()}).annotations({identifier:`DateFromNumber`});var Sv=class extends Jh(e=>nm(e)&&am(e),{typeConstructor:{_tag:`effect/DateTime.Utc`},identifier:`DateTimeUtcFromSelf`,description:`a DateTime.Utc instance`,pretty:()=>e=>e.toString(),arbitrary:()=>e=>e.date({noInvalidDate:!0}).map(e=>cm(e)),equivalence:()=>sm}){};const Cv=(e,t)=>km({try:()=>lm(e),catch:()=>new W(t,e,`Unable to decode ${l(e)} into a DateTime.Utc`)});Q(Y.annotations({description:`a number to be decoded into a DateTime.Utc`}),Sv,{strict:!0,decode:(e,t,n)=>Cv(e,n),encode:e=>G(_m(e))}).annotations({identifier:`DateTimeUtcFromNumber`}),Q(xv.annotations({description:`a Date to be decoded into a DateTime.Utc`}),Sv,{strict:!0,decode:(e,t,n)=>Cv(e,n),encode:e=>G(gm(e))}).annotations({identifier:`DateTimeUtcFromDate`}),Q(J.annotations({description:`a string to be decoded into a DateTime.Utc`}),Sv,{strict:!0,decode:(e,t,n)=>Cv(e,n),encode:e=>G(vm(e))}).annotations({identifier:`DateTimeUtc`});const wv=()=>e=>e.integer({min:-720*60*1e3,max:840*60*1e3}).map(pm);var Tv=class extends Jh(rm,{typeConstructor:{_tag:`effect/DateTime.TimeZone.Offset`},identifier:`TimeZoneOffsetFromSelf`,description:`a TimeZone.Offset instance`,pretty:()=>e=>e.toString(),arbitrary:wv}){};$(Y.annotations({description:`a number to be decoded into a TimeZone.Offset`}),Tv,{strict:!0,decode:e=>pm(e),encode:e=>e.offset}).annotations({identifier:`TimeZoneOffset`});const Ev=()=>e=>e.constantFrom(...Intl.supportedValuesOf(`timeZone`)).map(fm);var Dv=class extends Jh(im,{typeConstructor:{_tag:`effect/DateTime.TimeZone.Named`},identifier:`TimeZoneNamedFromSelf`,description:`a TimeZone.Named instance`,pretty:()=>e=>e.toString(),arbitrary:Ev}){};Q(J.annotations({description:`a string to be decoded into a TimeZone.Named`}),Dv,{strict:!0,decode:(e,t,n)=>km({try:()=>fm(e),catch:()=>new W(n,e,`Unable to decode ${JSON.stringify(e)} into a TimeZone.Named`)}),encode:e=>G(e.id)}).annotations({identifier:`TimeZoneNamed`});var Ov=class extends ag(Tv,Dv){};Q(J.annotations({description:`a string to be decoded into a TimeZone`}),Ov,{strict:!0,decode:(e,t,n)=>_(mm(e),{onNone:()=>Om(new W(n,e,`Unable to decode ${JSON.stringify(e)} into a TimeZone`)),onSome:G}),encode:e=>G(hm(e))}).annotations({identifier:`TimeZone`});const kv=e=>e.oneof(wv()(e),Ev()(e));var Av=class extends Jh(e=>nm(e)&&om(e),{typeConstructor:{_tag:`effect/DateTime.Zoned`},identifier:`DateTimeZonedFromSelf`,description:`a DateTime.Zoned instance`,pretty:()=>e=>e.toString(),arbitrary:()=>e=>e.tuple(e.integer({min:-31536e9,max:31536e9}),kv(e)).map(([e,t])=>um(e,{timeZone:t})),equivalence:()=>sm}){};Q(J.annotations({description:`a string to be decoded into a DateTime.Zoned`}),Av,{strict:!0,decode:(e,t,n)=>_(dm(e),{onNone:()=>Om(new W(n,e,`Unable to decode ${JSON.stringify(e)} into a DateTime.Zoned`)),onSome:G}),encode:e=>G(ym(e))}).annotations({identifier:`DateTimeZoned`});const jv=e=>e._tag===`None`?v():w(e.value),Mv=(e,t)=>n=>n.oneof(t,n.record({_tag:n.constant(`None`)}),n.record({_tag:n.constant(`Some`),value:e(n)})).map(jv),Nv=e=>_({onNone:()=>`none()`,onSome:t=>`some(${e(t)})`}),Pv=e=>(t,n,r)=>i(t)?wt(t)?G(v()):av(e(t.value,n),w,r,t):Om(new W(r,t)),Fv=e=>Jh([e],{decode:e=>Pv(Wm(e)),encode:e=>Pv(Gm(e))},{typeConstructor:{_tag:`effect/Option`},pretty:Nv,arbitrary:Mv,equivalence:Yt});$(J,(e=>Fv(e).annotations({description:`Option<${Rh(e)}>`}))(b_),{strict:!0,decode:e=>nt(w(e.trim()),Da),encode:e=>Ne(e,()=>``)});const Iv=()=>e=>`BigDecimal(${Il(Ol(e))})`,Lv=()=>e=>e.tuple(e.bigInt(),e.integer({min:-18,max:18})).map(([e,t])=>Cl(e,t));var Rv=class extends Jh(Sl,{typeConstructor:{_tag:`effect/BigDecimal`},identifier:`BigDecimalFromSelf`,pretty:Iv,arbitrary:Lv,equivalence:()=>jl}){};Q(J.annotations({description:`a string to be decoded into a BigDecimal`}),Rv,{strict:!0,decode:(e,t,n)=>Fl(e).pipe(_({onNone:()=>Om(new W(n,e,`Unable to decode ${JSON.stringify(e)} into a BigDecimal`)),onSome:e=>G(Ol(e))})),encode:e=>G(Il(Ol(e)))}).annotations({identifier:`BigDecimal`}),$(Y.annotations({description:`a number to be decoded into a BigDecimal`}),Rv,{strict:!0,decode:e=>Nl(e),encode:e=>Rl(e)}).annotations({identifier:`BigDecimalFromNumber`});const zv=e=>Vh(e)||xg(e),Bv=e=>Reflect.ownKeys(e).every(t=>zv(e[t])),Vv=e=>`fields`in e?e.fields:Vv(e[Kg]),Hv=e=>Bv(e)?X(e):Vh(e)?e:X(Vv(e)),Uv=e=>Bv(e)?e:Vv(e),Wv=e=>Eg(Tg(Wh(e)),()=>e),Gv=e=>(t,n,r)=>{let i=Uv(n),a=Hv(n),o={_tag:Wv(t)},s=qv(o,i);return class extends Zv({kind:`TaggedClass`,identifier:e??t,schema:Wg(a,X(o)),fields:s,Base:Ei,annotations:r}){static _tag=t}},Kv=e=>(t,n,r)=>{class i extends Di{}i.prototype.name=t;let a=Uv(n),o=Hv(n),s={_tag:Wv(t)},c=qv(s,a),u=`message`in c;class d extends Zv({kind:`TaggedError`,identifier:e??t,schema:Wg(o,X(s)),fields:c,Base:i,annotations:r,disableToString:!0}){static _tag=t}return u||Object.defineProperty(d.prototype,"message",{get(){return`{ ${Reflect.ownKeys(a).map(e=>`${p(e)}: ${l(this[e])}`).join(`, `)} }`},enumerable:!1,configurable:!0}),d},qv=(e,t)=>{let n={...e};for(let r of Reflect.ownKeys(t)){if(r in e)throw Error(ns(r));n[r]=t[r]}return n};function Jv(e){return Ke(e)?e:e?.disableValidation??!1}const Yv=st(`effect/Schema/astCache`,()=>new WeakMap),Xv=e=>e===void 0?[]:Array.isArray(e)?e:[e],Zv=({Base:e,annotations:t,disableToString:n,fields:r,identifier:i,kind:a,schema:o})=>{let s=Symbol.for(`effect/Schema/${a}/${i}`),[c,u,d]=Xv(t),f=Bh(o),m=f.annotations({identifier:i,...c}),h=f.annotations({[Ts]:`${i} (Type side)`,...c}),g=o.annotations({[Ts]:`${i} (Constructor)`,...c}),ee=o.annotations({[Ts]:`${i} (Encoded side)`,...d}),_=o.annotations({...d,...c,...u}),te=e=>Nt(e,s)&&Jm(h)(e),ne=class extends e{constructor(e={},t=!1){e={...e},a!==`Class`&&delete e._tag,e=Ag(r,e),Jv(t)||(e=qm(g)(e)),super(e,!0)}static[Nh]=Ph;static get ast(){let e=Yv.get(this);if(e)return e;let t=Jh([o],{decode:()=>(e,t,n)=>e instanceof this||te(e)?G(e):Om(new W(n,e)),encode:()=>(e,t)=>e instanceof this?G(e):Nm(Gm(h)(e,t),e=>new this(e,!0))},{identifier:i,pretty:e=>t=>`${i}(${e(t)})`,arbitrary:e=>t=>e(t).map(e=>new this(e)),equivalence:S,[zs]:m.ast,...c});return e=$(ee,t,{strict:!0,decode:e=>new this(e,!0),encode:S}).annotations({[zs]:_.ast,...u}).ast,Yv.set(this,e),e}static pipe(){return De(this,arguments)}static annotations(e){return q(this.ast).annotations(e)}static toString(){return`(${String(ee)} <-> ${i})`}static make(...e){return new this(...e)}static fields={...r};static identifier=i;static extend(e){return(t,n)=>{let i=Uv(t),s=Hv(t),c=qv(r,i);return Zv({kind:a,identifier:e,schema:Wg(o,s),fields:c,Base:this,annotations:n})}}static transformOrFail(e){return(t,n,i)=>{let s=qv(r,t);return Zv({kind:a,identifier:e,schema:Q(o,Bh(X(s)),n),fields:s,Base:this,annotations:i})}}static transformOrFailFrom(e){return(t,n,i)=>{let s=qv(r,t);return Zv({kind:a,identifier:e,schema:Q(zh(o),X(s),n),fields:s,Base:this,annotations:i})}}get[s](){return s}};return n!==!0&&Object.defineProperty(ne.prototype,"toString",{value(){return`${i}({ ${Reflect.ownKeys(r).map(e=>`${p(e)}: ${l(this[e])}`).join(`, `)} })`},configurable:!0,writable:!0}),ne},Qv=ag(X({_tag:Wh(`None`)}).annotations({identifier:`FiberIdNoneEncoded`}),X({_tag:Wh(`Runtime`),id:q_,startTimeMillis:q_}).annotations({identifier:`FiberIdRuntimeEncoded`}),X({_tag:Wh(`Composite`),left:Gg(()=>Qv),right:Gg(()=>Qv)}).annotations({identifier:`FiberIdCompositeEncoded`})).annotations({identifier:`FiberIdEncoded`}),$v=e=>e.letrec(t=>({None:e.record({_tag:e.constant(`None`)}),Runtime:e.record({_tag:e.constant(`Runtime`),id:e.integer(),startTimeMillis:e.integer()}),Composite:e.record({_tag:e.constant(`Composite`),left:t(`FiberId`),right:t(`FiberId`)}),FiberId:e.oneof(t(`None`),t(`Runtime`),t(`Composite`))})).FiberId.map(ny),ey=e=>{switch(e._tag){case`None`:return`FiberId.none`;case`Runtime`:return`FiberId.runtime(${e.id}, ${e.startTimeMillis})`;case`Composite`:return`FiberId.composite(${ey(e.right)}, ${ey(e.left)})`}};var ty=class extends Jh(ge,{typeConstructor:{_tag:`effect/FiberId`},identifier:`FiberIdFromSelf`,pretty:()=>ey,arbitrary:()=>$v}){};const ny=e=>{switch(e._tag){case`None`:return xe;case`Runtime`:return g(e.id,e.startTimeMillis);case`Composite`:return me(ny(e.left),ny(e.right))}},ry=e=>{switch(e._tag){case`None`:return{_tag:`None`};case`Runtime`:return{_tag:`Runtime`,id:e.id,startTimeMillis:e.startTimeMillis};case`Composite`:return{_tag:`Composite`,left:ry(e.left),right:ry(e.right)}}};$(Qv,ty,{strict:!0,decode:e=>ny(e),encode:e=>ry(e)}).annotations({identifier:`FiberId`});var iy=class extends $($h,$h,{strict:!0,decode:e=>{if(Dt(e)&&`message`in e&&typeof e.message==`string`){let t=Error(e.message,{cause:e});return`name`in e&&typeof e.name==`string`&&(t.name=e.name),t.stack=`stack`in e&&typeof e.stack==`string`?e.stack:``,t}return Ot(e)},encode:e=>e instanceof Error?{name:e.name,message:e.message}:Ot(e)}).annotations({identifier:`Defect`}){};$($h,ng,{strict:!0,decode:e=>it(e),encode:S}).annotations({identifier:`BooleanFromUnknown`}),$(Wh(`true`,`false`).annotations({description:`a string to be decoded into a boolean`}),ng,{strict:!0,decode:e=>e===`true`,encode:e=>e?`true`:`false`}).annotations({identifier:`BooleanFromString`});const ay=Ng(`symbol`,{key:J}).annotations({description:`an object to be decoded into a globally shared symbol`}),oy=Q(ay,tg,{strict:!0,decode:e=>Z_(e.key),encode:(e,t,n)=>Nm(X_(e,n),e=>ay.make({key:e}))});var sy=class extends ag(J,Y,oy).annotations({identifier:`PropertyKey`}){};X({_tag:Tg(Wh(`Pointer`,`Unexpected`,`Missing`,`Composite`,`Refinement`,`Transformation`,`Type`,`Forbidden`)).annotations({description:`The tag identifying the type of parse issue`}),path:Tg(pg(sy)).annotations({description:`The path to the property where the issue occurred`}),message:Tg(J).annotations({description:`A descriptive message explaining the issue`})}).annotations({identifier:`ArrayFormatterIssue`,description:`Represents an issue returned by the ArrayFormatter formatter`});const cy=dp,ly=mp,uy=Mp,dy=Np,fy=Vp,py=Zp,my=Qp,hy=Symbol.for(`@effect/platform/Error`),gy=Wh(`Clipboard`,`Command`,`FileSystem`,`KeyValueStore`,`Path`,`Stream`,`Terminal`);var _y=class extends Kv(`@effect/platform/Error/BadArgument`)(`BadArgument`,{module:gy,method:J,description:Dg(J),cause:Dg(iy)}){[hy]=hy;get message(){return`${this.module}.${this.method}${this.description?`: ${this.description}`:``}`}};const vy=Wh(`AlreadyExists`,`BadResource`,`Busy`,`InvalidData`,`NotFound`,`PermissionDenied`,`TimedOut`,`UnexpectedEof`,`Unknown`,`WouldBlock`,`WriteZero`);var yy=class extends Kv(`@effect/platform/Error/SystemError`)(`SystemError`,{reason:vy,module:gy,method:J,description:Dg(J),syscall:Dg(J),pathOrDescriptor:Dg(ag(J,Y)),cause:Dg(iy)}){[hy]=hy;get message(){return`${this.reason}: ${this.module}.${this.method}${this.pathOrDescriptor===void 0?``:` (${this.pathOrDescriptor})`}${this.description?`: ${this.description}`:``}`}};const by=Lt(`@effect/platform/FileSystem`),xy=e=>typeof e==`bigint`?e:BigInt(e),Sy=BigInt(1024);Sy*Sy*Sy*Sy*Sy;const Cy=e=>by.of({...e,exists:t=>C(e.access(t),wr(!0),er(`SystemError`,e=>e.reason===`NotFound`?j(!1):Kn(e))),readFileString:(t,n)=>Pr(e.readFile(t),{try:e=>new TextDecoder(n).decode(e),catch:e=>new _y({module:`FileSystem`,method:`readFileString`,description:`invalid encoding`,cause:e})}),stream:(t,n)=>C(e.open(t,{flag:`r`}),n?.offset?Xn(e=>e.seek(n.offset,`start`)):S,T(e=>wy(e,n)),my),sink:(t,n)=>C(e.open(t,{flag:`w`,...n}),T(e=>cy(t=>e.writeAll(t))),ly),writeFileString:(t,n,r)=>D(yr({try:()=>new TextEncoder().encode(n),catch:e=>new _y({module:`FileSystem`,method:`writeFileString`,description:`could not encode string`,cause:e})}),n=>e.writeFile(t,n,r))}),wy=(e,{bufferSize:t=16,bytesToRead:n,chunkSize:r=xy(64*1024)}={})=>{let i=n===void 0?void 0:xy(n),a=xy(r);function o(t){if(i!==void 0&&i<=t)return em;let n=i!==void 0&&i-t<a?i-t:a;return $p(e.readAlloc(n),_({onNone:()=>em,onSome:e=>$p(tm(ye(e)),n=>o(t+BigInt(e.length)))}))}return dy(fy(o(BigInt(0))),{capacity:t})},Ty=xy,Ey=by,Dy=Cy,Oy=Symbol.for(`@effect/platform/FileSystem/File`),ky=Gl(),Ay=Ti(`Create`),jy=Ti(`Update`),My=Ti(`Remove`);var Ny=class extends Ze(`@effect/platform/FileSystem/WatchBackend`)(){};const Py=Symbol.for(`@effect/platform/Path`),Fy=Lt(`@effect/platform/Path`);function Iy(e,t){let n=``,r=0,i=-1,a=0,o;for(let s=0;s<=e.length;++s){if(s<e.length)o=e.charCodeAt(s);else if(o===47)break;else o=47;if(o===47){if(i!==s-1&&a!==1)if(i!==s-1&&a===2){if(n.length<2||r!==2||n.charCodeAt(n.length-1)!==46||n.charCodeAt(n.length-2)!==46){if(n.length>2){let e=n.lastIndexOf(`/`);if(e!==n.length-1){e===-1?(n=``,r=0):(n=n.slice(0,e),r=n.length-1-n.lastIndexOf(`/`)),i=s,a=0;continue}}else if(n.length===2||n.length===1){n=``,r=0,i=s,a=0;continue}}t&&(n.length>0?n+=`/..`:n=`..`,r=2)}else n.length>0?n+=`/`+e.slice(i+1,s):n=e.slice(i+1,s),r=s-i-1;i=s,a=0}else o===46&&a!==-1?++a:a=-1}return n}function Ly(e,t){let n=t.dir||t.root,r=t.base||(t.name||``)+(t.ext||``);return n?n===t.root?n+r:n+e+r:r}function Ry(e){if(e.protocol!==`file:`)return Kn(new _y({module:`Path`,method:`fromFileUrl`,description:`URL must be of scheme file`}));if(e.hostname!==``)return Kn(new _y({module:`Path`,method:`fromFileUrl`,description:`Invalid file URL host`}));let t=e.pathname;for(let e=0;e<t.length;e++)if(t[e]===`%`){let n=t.codePointAt(e+2)|32;if(t[e+1]===`2`&&n===102)return Kn(new _y({module:`Path`,method:`fromFileUrl`,description:`must not include encoded / characters`}))}return j(decodeURIComponent(t))}const zy=function(){let e=``,t=!1,n;for(let r=arguments.length-1;r>=-1&&!t;r--){let i;if(r>=0)i=arguments[r];else{let e=globalThis.process;n===void 0&&`process`in globalThis&&typeof e==`object`&&e&&typeof e.cwd==`function`&&(n=e.cwd()),i=n}i.length!==0&&(e=i+`/`+e,t=i.charCodeAt(0)===47)}return e=Iy(e,!t),t?e.length>0?`/`+e:`/`:e.length>0?e:`.`};function By(e){let t=new URL(`file://`),n=zy(e);return e.charCodeAt(e.length-1)===47&&n[n.length-1]!==`/`&&(n+=`/`),t.pathname=Ky(n),j(t)}const Vy=/%/g,Hy=/\\/g,Uy=/\n/g,Wy=/\r/g,Gy=/\t/g;function Ky(e){return e.includes(`%`)&&(e=e.replace(Vy,`%25`)),e.includes(`\\`)&&(e=e.replace(Hy,`%5C`)),e.includes(`
16
- `)&&(e=e.replace(Uy,`%0A`)),e.includes(`\r`)&&(e=e.replace(Wy,`%0D`)),e.includes(` `)&&(e=e.replace(Gy,`%09`)),e}const qy=Fy.of({[Py]:Py,resolve:zy,normalize(e){if(e.length===0)return`.`;let t=e.charCodeAt(0)===47,n=e.charCodeAt(e.length-1)===47;return e=Iy(e,!t),e.length===0&&!t&&(e=`.`),e.length>0&&n&&(e+=`/`),t?`/`+e:e},isAbsolute(e){return e.length>0&&e.charCodeAt(0)===47},join(){if(arguments.length===0)return`.`;let e;for(let t=0;t<arguments.length;++t){let n=arguments[t];n.length>0&&(e===void 0?e=n:e+=`/`+n)}return e===void 0?`.`:qy.normalize(e)},relative(e,t){if(e===t||(e=qy.resolve(e),t=qy.resolve(t),e===t))return``;let n=1;for(;n<e.length&&e.charCodeAt(n)===47;++n);let r=e.length,i=r-n,a=1;for(;a<t.length&&t.charCodeAt(a)===47;++a);let o=t.length-a,s=i<o?i:o,c=-1,l=0;for(;l<=s;++l){if(l===s){if(o>s){if(t.charCodeAt(a+l)===47)return t.slice(a+l+1);if(l===0)return t.slice(a+l)}else i>s&&(e.charCodeAt(n+l)===47?c=l:l===0&&(c=0));break}let r=e.charCodeAt(n+l);if(r!==t.charCodeAt(a+l))break;r===47&&(c=l)}let u=``;for(l=n+c+1;l<=r;++l)(l===r||e.charCodeAt(l)===47)&&(u.length===0?u+=`..`:u+=`/..`);return u.length>0?u+t.slice(a+c):(a+=c,t.charCodeAt(a)===47&&++a,t.slice(a))},dirname(e){if(e.length===0)return`.`;let t=e.charCodeAt(0),n=t===47,r=-1,i=!0;for(let n=e.length-1;n>=1;--n)if(t=e.charCodeAt(n),t===47){if(!i){r=n;break}}else i=!1;return r===-1?n?`/`:`.`:n&&r===1?`//`:e.slice(0,r)},basename(e,t){let n=0,r=-1,i=!0,a;if(t!==void 0&&t.length>0&&t.length<=e.length){if(t.length===e.length&&t===e)return``;let o=t.length-1,s=-1;for(a=e.length-1;a>=0;--a){let c=e.charCodeAt(a);if(c===47){if(!i){n=a+1;break}}else s===-1&&(i=!1,s=a+1),o>=0&&(c===t.charCodeAt(o)?--o===-1&&(r=a):(o=-1,r=s))}return n===r?r=s:r===-1&&(r=e.length),e.slice(n,r)}else{for(a=e.length-1;a>=0;--a)if(e.charCodeAt(a)===47){if(!i){n=a+1;break}}else r===-1&&(i=!1,r=a+1);return r===-1?``:e.slice(n,r)}},extname(e){let t=-1,n=0,r=-1,i=!0,a=0;for(let o=e.length-1;o>=0;--o){let s=e.charCodeAt(o);if(s===47){if(!i){n=o+1;break}continue}r===-1&&(i=!1,r=o+1),s===46?t===-1?t=o:a!==1&&(a=1):t!==-1&&(a=-1)}return t===-1||r===-1||a===0||a===1&&t===r-1&&t===n+1?``:e.slice(t,r)},format:function(e){if(typeof e!=`object`||!e)throw TypeError(`The "pathObject" argument must be of type Object. Received type `+typeof e);return Ly(`/`,e)},parse(e){let t={root:``,dir:``,base:``,ext:``,name:``};if(e.length===0)return t;let n=e.charCodeAt(0),r=n===47,i;r?(t.root=`/`,i=1):i=0;let a=-1,o=0,s=-1,c=!0,l=e.length-1,u=0;for(;l>=i;--l){if(n=e.charCodeAt(l),n===47){if(!c){o=l+1;break}continue}s===-1&&(c=!1,s=l+1),n===46?a===-1?a=l:u!==1&&(u=1):a!==-1&&(u=-1)}return a===-1||s===-1||u===0||u===1&&a===s-1&&a===o+1?s!==-1&&(o===0&&r?t.base=t.name=e.slice(1,s):t.base=t.name=e.slice(o,s)):(o===0&&r?(t.name=e.slice(1,a),t.base=e.slice(1,s)):(t.name=e.slice(o,a),t.base=e.slice(o,s)),t.ext=e.slice(a,s)),o>0?t.dir=e.slice(0,o-1):r&&(t.dir=`/`),t},sep:`/`,fromFileUrl:Ry,toFileUrl:By,toNamespacedPath:S}),Jy=Jl(Fy,qy),Yy=Fy,Xy=Jy,Zy=Fg({key:J,value:pg(J)}).pipe(Lg(`TomlConfig`));Q(J,Bh(Zy),{strict:!0,decode:e=>km({try:()=>Bo(e),catch:e=>new bm(e,`TOML parse error`)}).pipe(Mm(e=>Wm(Zy)(e))),encode:(e,t,n)=>Om(new wm(n,e,`TomlConfigFromText is decode-only`))});const Qy=`systemfsoftware.toml`,$y=Km(Zy)({});var eb=class extends Ze(`TomlLoader`)(){};const tb=e=>{let t={};for(let n of e)for(let[e,r]of Object.entries(n))t[e]=r;return t},nb=e=>km({try:()=>Bo(e),catch:e=>new bm(e,`TOML parse error`)}).pipe(Mm(e=>Wm(Zy)(e))),rb=(e,t,n)=>e.exists(n).pipe(D(t=>t?e.readFileString(n).pipe(D(nb),_r(()=>j($y))):j($y))),ib=Kl(eb,D(pr(()=>{let e=process.env.OMP_USER_CONFIG_HOME;return typeof e==`string`&&e.length>0?e:Ci.homedir()}),e=>cn(function*(){let t=yield*qn(ar()),n=yield*Ey,r=yield*Yy,i=r.join(e,`.config/systemfsoftware`,Qy);return eb.of({load:Fn(`TomlLoader.load`)(function*(e){let a=Or(yield*or(t),e);if(bt(a))return a.value;let o=r.join(e,Qy),s=r.join(e,`systemfsoftware.local.toml`),c=yield*rb(n,r,i),l=yield*rb(n,r,o),u=yield*rb(n,r,s),d=Km(Zy)(tb([c,l,u]));return yield*Zn(t,t=>(xr(t,e,d),t)),d})})})));Jm(pg(X({old_text:Dg($h),new_text:Dg($h)}).pipe(Z(e=>`old_text`in e||`new_text`in e))).pipe(_v(1))),Jm(pg(X({old_string:Dg($h),new_string:Dg($h)}).pipe(Z(e=>`old_string`in e||`new_string`in e)))),Um(Fg({key:J,value:$h}));export{Gv as C,ql as D,Kl as E,Yl as O,X as S,Zg as T,pg as _,Ey as a,Fg as b,Ny as c,jy as d,Dy as f,py as g,uy as h,ky as i,Ay as l,yy as m,ib as n,Oy as o,_y as p,Xy as r,Ty as s,eb as t,My as u,ng as v,ag as w,J as x,Wh as y};
@@ -1 +0,0 @@
1
- const e=async e=>{let[t,n,r,i]=await Promise.all([import(`./runtime.kernel-DDie4TJ9.js`).then(e=>e.default),import(`./Cause-CTmrUQgG.js`).then(e=>e.t),import(`./Effect-B34dlqAS.js`).then(e=>e.t),import(`./Exit-Dq5mS6lc.js`).then(e=>e.t)]),a=e.pipe(r.exit),o=await t.runPromise(a);if(i.isFailure(o))throw n.squash(o.cause);return o.value};export{e as runSafe};