@rizom/brain 0.2.0-alpha.878 → 0.2.0-alpha.879
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/brain.js +27 -10
- package/dist/chunks/{app-x91r4ts9.js → app-msfm6evr.js} +2 -2
- package/dist/chunks/{client-vp512n1p.js → client-6s8fzpc6.js} +11 -11
- package/dist/chunks/{client-vp512n1p.js.map → client-6s8fzpc6.js.map} +1 -1
- package/dist/chunks/{index-s0nnawsk.js → index-bz1bfr0b.js} +2 -2
- package/dist/chunks/{index-8amdydan.js → index-mwgj2e1h.js} +3 -3
- package/dist/chunks/{index-8amdydan.js.map → index-mwgj2e1h.js.map} +1 -1
- package/dist/chunks/{package-7zpaarzx.js → package-eenvyv7d.js} +3 -3
- package/dist/chunks/{package-7zpaarzx.js.map → package-eenvyv7d.js.map} +1 -1
- package/dist/model.js +206 -189
- package/dist/model.js.map +4 -4
- package/dist/testing.js +1 -1
- package/package.json +1 -1
- /package/dist/chunks/{app-x91r4ts9.js.map → app-msfm6evr.js.map} +0 -0
- /package/dist/chunks/{index-s0nnawsk.js.map → index-bz1bfr0b.js.map} +0 -0
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{_d as dU,ae as UE,be as na,ce as Wc}from"./index-hmpxsbxe.js";import{$A as ns,$B as $s,$u as Le,$v as bw,$w as hn,$x as TC,$y as kv,$z as Ec,AA as nt,AB as aU,Au as Ds,Av as Kr,Aw as Bt,Ax as Dp,Ay as Zo,Az as wb,BA as Dy,BB as FS,Bu as Mn,Bv as ZC,Bw as At,Bx as _y,By as xn,Bz as kb,CA as lr,CB as mm,Cu as bh,Cv as QC,Cw as qx,Cx as Ns,Cy as en,Cz as Tb,DA as S_,DB as Eu,Du as ja,Dv as mr,Dw as vr,Dx as To,Dy as So,Dz as ZT,EA as bc,EB as Ne,Eu as Ln,Ev as WT,Ew as Pr,Ex as Ao,Ey as Xp,Ez as MC,FA as De,FB as Ro,Fu as ya,Fv as vp,Fw as Mf,Fx as cv,Fy as xp,Fz as Bp,GA as _v,GB as DS,Gu as Eh,Gv as Ar,Gw as rf,Gx as Co,Gy as Ye,Gz as VI,HA as tU,HB as Fl,Hu as ys,Hv as da,Hw as Tt,Hx as Bs,Hy as $e,Hz as lt,IA as pP,IB as Fn,Iu as Zw,Iv as Y0,Iw as wI,Ix as fv,Iy as bo,Iz as es,JA as Fu,JB as k_,Ju as Qw,Jv as LE,Jw as l_,Jx as Ay,Jy as QO,Jz as Py,KA as ls,KB as T_,Ku as Yw,Kv as zE,Kw as hv,Kx as Su,Ky as Iv,Kz as lP,LA as Ny,LB as Gg,Lu as Xw,Lv as Zi,Lw as Cd,Lx as qt,Ly as Yt,Lz as Uy,MA as CE,MB as Uc,Mu as il,Mv as Qi,Mw as EI,Mx as YC,My as pu,Mz as Cv,NA as US,NB as Jo,Nu as On,Nv as Yi,Nw as nS,Nx as Cy,Ny as YO,Nz as Qr,OA as nU,OB as re,Ou as ws,Ov as ad,Ow as _t,Ox as XC,Oy as hy,Oz as g_,PA as vE,PB as Ru,Pu as qM,Pv as id,Pw as _E,Px as YR,Py as Da,Pz as Sc,QA as rU,QB as ku,Qu as cl,Qv as cd,Qw as Md,Qx as XR,Qy as wv,Qz as Iu,RA as oU,RB as em,Ru as ek,Rv as fd,Rw as $h,Rx as eP,Ry as rP,Rz as XM,SA as Im,SB as OE,Su as Sg,Sv as ne,Sw as gv,Sx as yu,Sy as ut,Sz as eU,TA as Ks,TB as qd,Tu as Ku,Tv as oe,Tw as Sn,Tx as tP,Ty as ko,Tz as Du,UA as Ws,UB as Hd,Uu as st,Uv as Xi,Uw as Ke,Ux as nP,Uy as In,Uz as x_,VA as E_,VB as Ht,Vu as rl,Vv as Tn,Vw as $d,Vx as hm,Vy as dr,Vz as wu,WA as za,WB as Pt,Wu as V,Wv as ve,Ww as p_,Wx as Na,Wy as Me,Wz as y_,XA as Rv,XB as Hx,Xu as vo,Xv as zt,Xw as Yp,Xx as ol,Xy as HS,Xz as rS,YA as Pv,YB as tk,Yu as xw,Yv as JT,Yw as fh,Yx as fl,Yy as cn,Yz as fm,ZA as gy,ZB as Y,Zu as Be,Zv as Zd,Zw as Xt,Zx as ul,Zy as Te,Zz as Jr,_A as q0,_B as A_,_u as We,_v as Ew,_w as pe,_x as kC,_y as Jn,_z as gr,aA as fr,aB as Qn,aC as C_,av as mo,aw as sg,ax as md,ay as yv,az as Tv,bA as b,bB as Gr,bC as fn,bv as Bn,bw as Ef,bx as kI,by as Sv,bz as Av,cA as Si,cB as ER,cC as Fo,cv as mn,cw as rh,cx as hd,cy as rc,cz as Ys,dA as vv,dB as Jt,dC as js,dv as yI,dw as d_,dx as Zt,dy as oc,dz as HM,eA as M,eB as b_,ev as oi,ew as qo,ex as GT,ey as Ld,ez as Dc,fA as L,fB as _c,fC as Pu,fv as ze,fw as bi,fx as tc,fy as Gf,fz as kS,gA as R,gB as Qs,gC as Mo,gv as he,gw as yi,gx as xs,gy as Fi,gz as Zn,hA as xm,hB as sU,hC as Mu,hv as Nl,hx as _u,hy as Kf,hz as h_,iA as Gn,iB as zs,iC as Tc,iv as Bl,iw as Ft,ix as VO,iy as Vf,iz as sb,jA as Hs,jB as Yn,jC as Qp,jv as SI,jw as Ac,jx as nc,jy as Yf,jz as ab,kA as je,kB as Ja,kC as XO,kv as ui,kw as mv,kx as Yl,ky as m_,kz as ib,lA as _,lB as I_,lv as K,lw as Do,lx as Zf,ly as Ts,lz as cb,mA as Fy,mB as xr,mv as Sa,mw as SR,mx as Qf,my as Oc,mz as fb,nA as He,nB as _o,nv as Bd,nw as Un,nx as rI,ny as Ev,nz as ub,oA as Os,oB as Vn,ov as yw,ow as um,ox as Wn,oy as bu,oz as db,pA as _n,pB as w_,pv as Sw,pw as Cc,px as oI,py as Np,pz as lb,qA as Mr,qB as yr,qC as PE,qv as Re,qw as Lt,qx as KT,qy as AE,qz as pb,rA as Lp,rB as MS,rv as lo,rw as er,rx as z0,ry as YM,rz as mb,sA as dt,sB as Kn,sv as ho,sw as sf,sx as VT,sy as $0,sz as hb,tA as ZI,tB as is,tC as ME,tv as HR,tw as kt,tx as sI,ty as My,tz as gb,uA as A,uB as Ic,uu as de,uv as jT,uw as ht,ux as Qt,uy as bv,uz as xb,vA as Ov,vB as Xo,vu as WI,vv as Fx,vw as qs,vx as aa,vy as ee,vz as yb,wA as gt,wB as Xn,wu as Ei,wv as q,ww as ue,wx as JI,wy as ZO,wz as Sb,xA as xt,xB as Ze,xu as y,xv as gn,xw as ge,xx as GI,xz as Eb,yA as or,yB as oP,yu as Q,yv as Ss,yw as ql,yx as KI,yy as Uo,yz as bb,zA as B,zB as Mv,zu as pr,zv as Ty,zw as ec,zx as xv,zz as Ib}from"./index-rwrp530c.js";import{LD as F}from"./index-njqkf4cd.js";import{SD as Ps}from"./index-cyq5dhvm.js";var sn={};Ps(sn,{Any:()=>iB,Array:()=>Oe,ArrayEnsure:()=>xB,BigDecimal:()=>JA,BigDecimalFromString:()=>YL,BigInt:()=>ic,BigIntFromString:()=>DL,Boolean:()=>ru,BooleanFromBit:()=>HL,BooleanLiterals:()=>kB,ByteSize:()=>cp,ByteSizeFromBigInt:()=>e2,ByteSizeFromNumber:()=>t2,ByteSizeFromString:()=>XL,Cause:()=>Lx,CauseReason:()=>Bx,Char:()=>IL,Chunk:()=>n2,Class:()=>lp,Cookie:()=>SC,Cookies:()=>EC,Date:()=>ip,DateFromMillis:()=>OL,DateFromString:()=>vL,DateTimeUtc:()=>fp,DateTimeUtcFromDate:()=>c2,DateTimeUtcFromMillis:()=>u2,DateTimeUtcFromString:()=>f2,DateTimeZoned:()=>fC,DateTimeZonedFromString:()=>m2,Defect:()=>bt,Duration:()=>dp,DurationFromMillis:()=>oz,DurationFromNanos:()=>rz,DurationFromString:()=>nz,Enum:()=>aB,Error:()=>Ct,ErrorInstance:()=>wL,Exit:()=>ay,FalseLiterals:()=>EA,File:()=>LA,Finite:()=>op,FiniteFromString:()=>FL,FormData:()=>zA,Graph:()=>cz,HashMap:()=>fz,HashSet:()=>uz,Headers:()=>hz,InetAddress:()=>xC,InetAddressFromString:()=>V2,InetAddressV4:()=>G2,InetAddressV6:()=>K2,Int:()=>wo,IpAddress:()=>Pa,IpAddressFromString:()=>pc,IpInterface:()=>pC,IpInterfaceFromString:()=>H2,IpLinkLocalAddress:()=>O2,IpLinkLocalAddressFromString:()=>_2,IpLoopbackAddress:()=>C2,IpLoopbackAddressFromString:()=>v2,IpMulticastAddress:()=>h2,IpMulticastAddressFromString:()=>g2,IpNetwork:()=>gC,IpNetworkFromString:()=>J2,IpUnicastAddress:()=>S2,IpUnicastAddressFromString:()=>E2,IpUnspecifiedAddress:()=>R2,IpUnspecifiedAddressFromString:()=>P2,Ipv4Address:()=>up,Ipv4AddressFromString:()=>oy,Ipv4BroadcastAddress:()=>w2,Ipv4BroadcastAddressFromString:()=>k2,Ipv4Interface:()=>dC,Ipv4InterfaceFromString:()=>$2,Ipv4Network:()=>mC,Ipv4NetworkFromString:()=>j2,Ipv4PrivateAddress:()=>M2,Ipv4PrivateAddressFromString:()=>U2,Ipv6Address:()=>sy,Ipv6AddressFromString:()=>uC,Ipv6Interface:()=>lC,Ipv6InterfaceFromString:()=>q2,Ipv6Network:()=>hC,Ipv6NetworkFromString:()=>W2,Ipv6UniqueLocalAddress:()=>F2,Ipv6UniqueLocalAddressFromString:()=>D2,Json:()=>pp,JsonFromUrlParamsField:()=>gz,JsonObject:()=>Hz,Literal:()=>pt,Literals:()=>ur,MacAddress:()=>Ra,MacAddressFromString:()=>lc,MacBroadcastAddress:()=>T2,MacBroadcastAddressFromString:()=>A2,MacLocallyAdministeredAddress:()=>N2,MacLocallyAdministeredAddressFromString:()=>B2,MacMulticastAddress:()=>x2,MacMulticastAddressFromString:()=>y2,MacUnicastAddress:()=>b2,MacUnicastAddressFromString:()=>I2,MacUniversallyAdministeredAddress:()=>L2,MacUniversallyAdministeredAddressFromString:()=>z2,MutableJson:()=>Wz,Natural:()=>Aa,Never:()=>tu,NonEmptyArray:()=>fc,NonEmptyString:()=>bL,Null:()=>ep,NullOr:()=>Vx,NullishOr:()=>dA,Number:()=>Oa,NumberFromString:()=>UL,ObjectKeyword:()=>fB,Opaque:()=>RB,Option:()=>Ma,OptionFromNullOr:()=>dz,OptionFromNullishOr:()=>pz,OptionFromOptional:()=>Sz,OptionFromOptionalKey:()=>yz,OptionFromOptionalNullOr:()=>Ez,OptionFromUndefinedOr:()=>lz,PropertyKey:()=>Nx,ReadonlyMap:()=>kL,ReadonlySet:()=>TL,Record:()=>_a,RecordFromCookies:()=>mz,RecordFromUrlParams:()=>xz,Redacted:()=>bC,RedactedFromValue:()=>bz,RegExp:()=>AL,Result:()=>Iz,SchemaError:()=>Rn,SocketAddress:()=>Q2,StandardSchemaV1FailureResult:()=>qL,String:()=>z,StringForLiteralAutocomplete:()=>cB,StringFromBase64:()=>BL,StringFromBase64Url:()=>LL,StringFromHex:()=>zL,StringFromUriComponent:()=>$L,Struct:()=>ae,StructWithRest:()=>hB,Symbol:()=>cA,TaggedClass:()=>Az,TaggedError:()=>fy,TaggedStruct:()=>rp,TaggedUnion:()=>_B,TemplateLiteral:()=>oB,TemplateLiteralParser:()=>sB,TimeZone:()=>iC,TimeZoneFromString:()=>p2,TimeZoneNamed:()=>sC,TimeZoneNamedFromString:()=>l2,TimeZoneOffset:()=>d2,Tree:()=>qz,Trim:()=>NL,Trimmed:()=>qA,TrueLiterals:()=>SA,Tuple:()=>cr,TupleWithRest:()=>gB,URL:()=>NA,URLFromString:()=>CL,URLSearchParams:()=>$A,Uint8Array:()=>Hr,Uint8ArrayFromBase64:()=>jL,Uint8ArrayFromBase64Url:()=>WL,Uint8ArrayFromHex:()=>JL,Undefined:()=>Gx,UndefinedOr:()=>np,Union:()=>Ie,UniqueArray:()=>yB,UniqueSymbol:()=>uB,UnixPathAddress:()=>yC,UnixPathAddressFromString:()=>Z2,Unknown:()=>nu,UnknownFromJsonString:()=>RL,UrlParams:()=>iy,Void:()=>cc,annotate:()=>M1,annotateEncoded:()=>U1,annotateKey:()=>F1,asserts:()=>z1,brand:()=>mA,catchDecoding:()=>IB,catchDecodingWithContext:()=>xA,catchEncoding:()=>wB,catchEncodingWithContext:()=>yA,check:()=>EB,declare:()=>we,declareConstructor:()=>Wt,decode:()=>TB,decodeEffect:()=>$1,decodeExit:()=>q1,decodeOption:()=>j1,decodePromise:()=>J1,decodeResult:()=>W1,decodeSync:()=>Wx,decodeTo:()=>Z,decodeUnknownEffect:()=>Ms,decodeUnknownExit:()=>tA,decodeUnknownOption:()=>H1,decodeUnknownPromise:()=>rA,decodeUnknownResult:()=>nA,decodeUnknownSync:()=>Xl,encode:()=>AB,encodeEffect:()=>Jx,encodeExit:()=>G1,encodeKeys:()=>pB,encodeOption:()=>V1,encodePromise:()=>Q1,encodeResult:()=>Z1,encodeSync:()=>Y1,encodeTo:()=>Zx,encodeUnknownEffect:()=>Xf,encodeUnknownExit:()=>oA,encodeUnknownOption:()=>K1,encodeUnknownPromise:()=>aA,encodeUnknownResult:()=>sA,encodeUnknownSync:()=>eu,extendTo:()=>mB,fieldsAssign:()=>dB,flip:()=>Dx,fromBrand:()=>bB,fromFormData:()=>PL,fromJsonString:()=>ny,fromURLSearchParams:()=>ML,instanceOf:()=>Us,is:()=>L1,isBase64:()=>AA,isBase64Url:()=>zB,isBetween:()=>sp,isBetweenBigDecimal:()=>QL,isBetweenBigInt:()=>uL,isBetweenCodePoints:()=>pL,isBetweenDate:()=>aL,isBetweenLength:()=>Xx,isBetweenProperties:()=>SL,isBetweenSize:()=>gL,isCapitalized:()=>JB,isEndingWith:()=>qB,isFinite:()=>KB,isGUID:()=>BB,isGreaterThan:()=>ZB,isGreaterThanBigDecimal:()=>GL,isGreaterThanBigInt:()=>iL,isGreaterThanDate:()=>nL,isGreaterThanOrEqualTo:()=>CA,isGreaterThanOrEqualToBigDecimal:()=>KL,isGreaterThanOrEqualToBigInt:()=>vA,isGreaterThanOrEqualToDate:()=>rL,isIncluding:()=>HB,isInt:()=>ap,isInt32:()=>eL,isLessThan:()=>QB,isLessThanBigDecimal:()=>VL,isLessThanBigInt:()=>cL,isLessThanDate:()=>oL,isLessThanOrEqualTo:()=>YB,isLessThanOrEqualToBigDecimal:()=>ZL,isLessThanOrEqualToBigInt:()=>fL,isLessThanOrEqualToDate:()=>sL,isLowercased:()=>WB,isMaxCodePoints:()=>lL,isMaxLength:()=>PA,isMaxProperties:()=>yL,isMaxSize:()=>hL,isMinCodePoints:()=>dL,isMinLength:()=>OA,isMinProperties:()=>xL,isMinSize:()=>mL,isMultipleOf:()=>XB,isNonEmpty:()=>RA,isPattern:()=>dc,isPropertyNames:()=>EL,isSchema:()=>va,isSchemaError:()=>sc,isStartingWith:()=>$B,isStringBigInt:()=>UB,isStringFinite:()=>MB,isStringSymbol:()=>FB,isTrimmed:()=>TA,isULID:()=>LB,isUUID:()=>NB,isUint32:()=>tL,isUncapitalized:()=>GB,isUnique:()=>ty,isUniqueKey:()=>MA,isUppercased:()=>jB,link:()=>Se,linkDecoding:()=>uc,make:()=>H,makeFilter:()=>ke,makeFilterGroup:()=>PB,makeIsBetween:()=>cu,makeIsGreaterThan:()=>ou,makeIsGreaterThanOrEqualTo:()=>su,makeIsLessThan:()=>au,makeIsLessThanOrEqualTo:()=>iu,makeIsMultipleOf:()=>VB,middlewareDecoding:()=>hA,middlewareEncoding:()=>gA,mutable:()=>SB,mutableKey:()=>tB,optional:()=>mt,optionalKey:()=>Ca,overrideToCodecIso:()=>zz,overrideToEquivalence:()=>Oz,overrideToFormatter:()=>Cz,readonlyKey:()=>nB,refine:()=>pA,required:()=>eB,requiredKey:()=>X1,resolveAnnotations:()=>Jz,resolveAnnotationsKey:()=>Gz,revealBottom:()=>P1,revealCodec:()=>D1,suspend:()=>lA,tag:()=>ye,tagDefaultOmit:()=>OB,toCodecArrayFromSingle:()=>Fz,toCodecIso:()=>Mz,toCodecJson:()=>uu,toCodecStringTree:()=>Uz,toDifferJsonPatch:()=>$z,toEncoded:()=>ac,toEncoderXml:()=>Dz,toEquivalence:()=>_z,toFormatter:()=>vz,toIso:()=>Nz,toIsoFocus:()=>Lz,toIsoSource:()=>Bz,toJsonSchemaDocument:()=>Pz,toRepresentation:()=>Rz,toStandardJSONSchemaV1:()=>B1,toStandardSchemaV1:()=>N1,toTaggedUnion:()=>kA,toType:()=>Pn,withArrayLengthConstraints:()=>tp,withConstructorDefault:()=>bA,withDecodingDefault:()=>wA,withDecodingDefaultKey:()=>Qx,withDecodingDefaultType:()=>vB,withDecodingDefaultTypeKey:()=>CB});var DE=/^[+-]?\d+$/,nh="~effect/BigDecimal",OU={[nh]:nh,[Be](){let e=Gc(this);return Le(mn(String(e.value)),Bn(e.scale))},[ze](e){return ra(e)&&HE(this,e)===0},toString(){return`BigDecimal(${Lo(this)})`},toJSON(){return{_id:"BigDecimal",value:String(this.value),scale:this.scale}},[Re](){return this.toJSON()},pipe(){return de(this,arguments)}},ra=(e)=>V(e,nh),ud=(e,t)=>{if(!Number.isSafeInteger(t))throw RangeError(`Scale must be a safe integer, got ${t}`);let n=Object.create(OU);return n.value=e,n.scale=t,n},$E=(e,t)=>{let n=ud(e,t);return n.normalized=n,n};var Tr=BigInt(0),_U=BigInt(1);var RU=BigInt(10),qE=$E(Tr,0);var Gc=(e)=>{if(e.normalized===void 0)if(e.value===Tr)e.normalized=qE;else{let t=`${e.value}`,n=t.length;while(t[n-1]==="0")n--;e.normalized=$E(BigInt(t.slice(0,n)),e.scale-(t.length-n))}return e.normalized};var PU=100,MU=[_U],th=(e,t)=>e===t?0:e<t?-1:1,NE=(e,t)=>{let n=`${e.value<Tr?-e.value:e.value}`,r=`${t.value<Tr?-t.value:t.value}`,o=BigInt(n.length-r.length)-BigInt(e.scale)+BigInt(t.scale);if(o!==Tr)return o<Tr?-1:1;let s=Math.max(n.length,r.length);return zE(n.padEnd(s,"0"),r.padEnd(s,"0"))},HE=(e,t)=>{if(e.scale===t.scale)return th(e.value,t.value);let n=BE(e),r=BE(t);if(n!==r)return n<r?-1:1;if(n===0)return 0;let o=e.scale-t.scale,s=Math.abs(o);if(s>PU)return n===-1?NE(t,e):NE(e,t);let a=MU[s]??=RU**BigInt(s);return o>0?th(e.value,t.value*a):th(e.value*a,t.value)},ni=LE(HE);var BE=(e)=>e.value===Tr?0:e.value<Tr?-1:1;var jE=(e)=>{if(e==="")return oe(qE);let t,n,r=e.search(/[eE]/);if(r!==-1){let c=e.slice(r+1);if(t=e.slice(0,r),n=Number(c),t===""||!Number.isSafeInteger(n)||!DE.test(c))return ne()}else t=e,n=0;let o,s,a=t.search(/\./);if(a!==-1){let c=t.slice(0,a),f=t.slice(a+1);o=`${c}${f}`,s=f.length}else o=t,s=0;if(!DE.test(o))return ne();let i=s-n;if(!Number.isSafeInteger(i))return ne();return oe(ud(BigInt(o),i))};var Lo=(e)=>{let t=Gc(e);if(Math.abs(t.scale)>=16)return UU(t);let n=t.value<Tr,r=`${n?-t.value:t.value}`,o=t.scale>0?r.padStart(t.scale+1,"0"):r.padEnd(r.length-t.scale,"0"),s=o.length-t.scale,a=t.scale>0?`${o.slice(0,s)}.${o.slice(s)}`:o;return n?`-${a}`:a},UU=(e)=>{if(FU(e))return"0e+0";let t=Gc(e),n=`${t.value}`,r=t.value<Tr?2:1,o=n.slice(0,r),s=n.slice(r),a=s.length-t.scale;return`${o}${s===""?"":`.${s}`}e${a>=0?"+":""}${a}`};var FU=(e)=>e.value===Tr;var JE=globalThis.BigInt;var GE=(e)=>{if(e>JE(Number.MAX_SAFE_INTEGER)||e<JE(Number.MIN_SAFE_INTEGER))return ne();return oe(Number(e))};var oh=BigInt(0),NU=BigInt(1),uo=BigInt(1000),hs=BigInt(1024),KE=[{symbol:"B",factor:NU,names:["B","byte","bytes"]},{symbol:"kB",factor:uo,names:["kB","kilobyte","kilobytes"]},{symbol:"MB",factor:uo**BigInt(2),names:["MB","megabyte","megabytes"]},{symbol:"GB",factor:uo**BigInt(3),names:["GB","gigabyte","gigabytes"]},{symbol:"TB",factor:uo**BigInt(4),names:["TB","terabyte","terabytes"]},{symbol:"PB",factor:uo**BigInt(5),names:["PB","petabyte","petabytes"]},{symbol:"EB",factor:uo**BigInt(6),names:["EB","exabyte","exabytes"]},{symbol:"ZB",factor:uo**BigInt(7),names:["ZB","zettabyte","zettabytes"]},{symbol:"YB",factor:uo**BigInt(8),names:["YB","yottabyte","yottabytes"]},{symbol:"RB",factor:uo**BigInt(9),names:["RB","ronnabyte","ronnabytes"]},{symbol:"QB",factor:uo**BigInt(10),names:["QB","quettabyte","quettabytes"]}],BU=[KE[0],{symbol:"KiB",factor:hs,names:["KiB","kibibyte","kibibytes"]},{symbol:"MiB",factor:hs**BigInt(2),names:["MiB","mebibyte","mebibytes"]},{symbol:"GiB",factor:hs**BigInt(3),names:["GiB","gibibyte","gibibytes"]},{symbol:"TiB",factor:hs**BigInt(4),names:["TiB","tebibyte","tebibytes"]},{symbol:"PiB",factor:hs**BigInt(5),names:["PiB","pebibyte","pebibytes"]},{symbol:"EiB",factor:hs**BigInt(6),names:["EiB","exbibyte","exbibytes"]},{symbol:"ZiB",factor:hs**BigInt(7),names:["ZiB","zebibyte","zebibytes"]},{symbol:"YiB",factor:hs**BigInt(8),names:["YiB","yobibyte","yobibytes"]}],LU=[...KE,...BU.slice(1)],zU=new Map(LU.flatMap((e)=>e.names.map((t)=>[t,e])));var sh=(e)=>e;var ri=(e)=>{throw Error(`Invalid ByteSize: ${e}`)},VE=(e)=>{if(!Number.isSafeInteger(e)||e<0)return ri(`expected a non-negative safe integer, received ${e}`);return sh(BigInt(e))};var ZE=(e)=>{let t=/^\s*(\d+)(?:\.(\d+))?\s*([A-Za-z]+)\s*$/.exec(e);if(t===null)return ri(`unsupported syntax ${JSON.stringify(e)}`);let n=zU.get(t[3]);if(n===void 0)return ri(`unsupported unit ${JSON.stringify(t[3])}`);let r=t[2]??"",o=BigInt(10)**BigInt(r.length),s=BigInt(t[1]+r)*n.factor;if(s%o!==oh)return ri(`${JSON.stringify(e)} does not represent an integral number of bytes`);return sh(s/o)},QE=rh(ZE),dd=(e)=>{switch(typeof e){case"bigint":if(e<oh)return ri(`expected a non-negative bigint, received ${e}`);return sh(e);case"number":return VE(e);case"string":return ZE(e)}return ri(`unsupported input ${e}`)},ah=rh(dd),YE=(e)=>typeof e==="bigint"?dd(e):VE(e);var XE=(e)=>typeof e==="bigint"&&e>=oh;var ld=(e)=>e,eb=GE;var nb="~effect/Chunk";function tb(e,t,n,r,o){for(let s=t;s<Math.min(e.length,t+o);s++)n[r+s-t]=e[s];return n}var rb=[],uh=(e)=>Ar((t,n)=>{if(t.length!==n.length)return!1;let r=oa(t),o=oa(n);for(let s=0;s<r.length;s++)if(!e(r[s],o[s]))return!1;return!0}),HU=uh(he),jU={[nb]:{_A:(e)=>e},toString(){return`Chunk(${K(oa(this))})`},toJSON(){return{_id:"Chunk",values:lo(oa(this))}},[Re](){return this.toJSON()},[ze](e){return si(e)&&HU(this,e)},[Be](){return oi(oa(this))},[Symbol.iterator](){switch(this.backing._tag){case"IArray":return this.backing.array[Symbol.iterator]();case"IEmpty":return rb[Symbol.iterator]();default:return oa(this)[Symbol.iterator]()}},pipe(){return de(this,arguments)}},dh=(e)=>{let t=Object.create(jU);switch(t.backing=e,e._tag){case"IEmpty":{t.length=0,t.depth=0,t.left=t,t.right=t;break}case"IConcat":{t.length=e.left.length+e.right.length,t.depth=1+Math.max(e.left.depth,e.right.depth),t.left=e.left,t.right=e.right;break}case"IArray":{t.length=e.array.length,t.depth=0,t.left=zo,t.right=zo;break}case"ISingleton":{t.length=1,t.depth=0,t.left=zo,t.right=zo;break}case"ISlice":{t.length=e.length,t.depth=0,t.left=zo,t.right=zo;break}}return t},si=(e)=>V(e,nb),zo=dh({_tag:"IEmpty"}),WU=()=>zo;var JU=(e)=>dh({_tag:"ISingleton",a:e}),lh=(e)=>si(e)?e:KU(_t(e)),ch=(e,t,n)=>{switch(e.backing._tag){case"IArray":{tb(e.backing.array,0,t,n,e.length);break}case"IConcat":{ch(e.left,t,n),ch(e.right,t,n+e.left.length);break}case"ISingleton":{t[n]=e.backing.a;break}case"ISlice":{tb(oa(e.backing.chunk),e.backing.offset,t,n,e.length);break}}};var GU=(e)=>{switch(e.backing._tag){case"IEmpty":return rb;case"IArray":return e.backing.array;default:{let t=Array(e.length);return ch(e,t,0),e.backing={_tag:"IArray",array:t},e.left=zo,e.right=zo,e.depth=0,t}}},oa=GU;var KU=(e)=>e.length===0?WU():e.length===1?JU(e[0]):dh({_tag:"IArray",array:e});var ob=(e)=>e.length;var sa=sb,Ab=ab,Cb=ib,vb=cb,Ob=fb,_b=ub,Rb=db;var gd=lb;var xd=pb;var mh=mb,Pb=hb;var hh=gb;var gh=xb,xh=yb,Mb=Sb;var Ub=Eb,Kc=bb;var Fb=Ib;var Db=wb;var Nb=kb;var yh=Tb;var ai=(e)=>VU(typeof e==="string"?ZU.encode(e):e),ia=(e)=>{let t=YU(e),n=t.length;if(n%4!==0)return ge(new aa({kind:"Decode",module:"Base64",input:t,message:`Length must be a multiple of 4, but is ${n}`}));let r=t.indexOf("=");if(r!==-1&&(r<n-2||r===n-2&&t[n-1]!=="="))return ge(new aa({kind:"Decode",module:"Base64",input:t,message:"Found a '=' character, but it is not at the end"}));try{let o=t.endsWith("==")?2:t.endsWith("=")?1:0,s=new Uint8Array(3*(n/4)-o);for(let a=0,i=0;a<n;a+=4,i+=3){let c=yd(t.charCodeAt(a))<<18|yd(t.charCodeAt(a+1))<<12|yd(t.charCodeAt(a+2))<<6|yd(t.charCodeAt(a+3));s[i]=c>>16,s[i+1]=c>>8&255,s[i+2]=c&255}return ue(s)}catch(o){return ge(new aa({kind:"Decode",module:"Base64",input:t,message:o instanceof Error?o.message:"Invalid input"}))}},Lb=(e)=>vr(ia(e),(t)=>QU.decode(t)),VU=(e)=>{let t=e.length,n="",r;for(r=2;r<t;r+=3)n+=Cr[e[r-2]>>2],n+=Cr[(e[r-2]&3)<<4|e[r-1]>>4],n+=Cr[(e[r-1]&15)<<2|e[r]>>6],n+=Cr[e[r]&63];if(r===t+1)n+=Cr[e[r-2]>>2],n+=Cr[(e[r-2]&3)<<4],n+="==";if(r===t)n+=Cr[e[r-2]>>2],n+=Cr[(e[r-2]&3)<<4|e[r-1]>>4],n+=Cr[(e[r-1]&15)<<2],n+="=";return n},ZU=new TextEncoder,QU=new TextDecoder,YU=(e)=>e.replace(/[\n\r]/g,""),Cr="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",Vc=new Uint8Array(123).fill(255);for(let e=0;e<Cr.length;e++)Vc[Cr.charCodeAt(e)]=e;Vc[61]=0;var yd=(e)=>{if(e>=Vc.length||Vc[e]===255)throw TypeError(`Invalid character ${String.fromCharCode(e)}`);return Vc[e]};var Ed="~effect/HashMap",Or=5,Xc=1<<Or,XU=Xc/4,zb=Xc/2,eF=Xc-1,tF=(e)=>(e=e-(e>>>1&1431655765),e=(e&858993459)+(e>>>2&858993459),(e+(e>>>4)&252645135)*16843009>>>24),Zc=(e,t)=>e>>>t&eF,gs=(e,t)=>1<<Zc(e,t),Sd=(e,t)=>tF(e&t-1);function $b(e,t,n,r,o,s){if(t>32)throw Error("HashMap: max depth exceeded");let a=gs(n,t),i=gs(o,t);if(a===i){let u=$b(e,t+Or,n,r,o,s);return new po(e,a,[u])}let c=a|i,f=a>>>0<i>>>0?[r,s]:[s,r];return new po(e,c,f)}var nF=mn("HashMap"),qb=(e,t)=>Le(We(e),We(t)),Hb=(e)=>{let t=0;for(let n=0;n<e.length;n++){let r=e[n];if(r)t^=r.subtreeHash()}return t};class ii{canEdit(e){return this.edit===e}subtreeHash(){let e=this._hash;if(e===void 0){let t=Eh;if(e=this.computeHash(),t===Eh)this._hash=e}return e}}class jb extends ii{_tag="EmptyNode";edit=0;get size(){return 0}get(e,t,n){return ne()}has(e,t,n){return!1}set(e,t,n,r,o,s){return s.value=!0,new $o(e,n,r,o)}remove(e,t,n,r,o){return this}canEdit(e){return!1}computeHash(){return 0}}class $o extends ii{_tag="LeafNode";edit;hash;key;value;constructor(e,t,n,r){super();this.edit=e,this.hash=t,this.key=n,this.value=r}get size(){return 1}get(e,t,n){if(this.hash===t&&he(this.key,n))return oe(this.value);return ne()}has(e,t,n){return this.hash===t&&he(this.key,n)}set(e,t,n,r,o,s){if(this.canEdit(e))this._hash=void 0;if(this.hash===n&&he(this.key,r)){if(he(this.value,o))return this;if(this.canEdit(e))return this.value=o,this;return new $o(e,n,r,o)}if(s.value=!0,this.hash===n)return new Qc(e,n,[[this.key,this.value],[r,o]]);let a=gs(n,t),i=gs(this.hash,t);if(a===i)return new po(e,a,[this.set(e,t+Or,n,r,o,s)]);let c=a|i,f=a>>>0<i>>>0?[new $o(e,n,r,o),this]:[this,new $o(e,n,r,o)];return new po(e,c,f)}remove(e,t,n,r,o){if(this.hash===n&&he(this.key,r)){o.value=!0;return}return this}computeHash(){return qb(this.key,this.value)}}class Qc extends ii{_tag="CollisionNode";edit;hash;entries;constructor(e,t,n){super();this.edit=e,this.hash=t,this.entries=n}get size(){return this.entries.length}get(e,t,n){if(this.hash!==t)return ne();for(let[r,o]of this.entries)if(he(r,n))return oe(o);return ne()}has(e,t,n){if(this.hash!==t)return!1;for(let[r]of this.entries)if(he(r,n))return!0;return!1}set(e,t,n,r,o,s){if(this.canEdit(e))this._hash=void 0;if(this.hash!==n)return s.value=!0,$b(e,t,this.hash,this,n,new $o(e,n,r,o));for(let a=0;a<this.entries.length;a++)if(he(this.entries[a][0],r)){if(he(this.entries[a][1],o))return this;if(this.canEdit(e))return this.entries[a]=[r,o],this;let i=[...this.entries];return i[a]=[r,o],new Qc(e,this.hash,i)}if(s.value=!0,this.canEdit(e))return this.entries.push([r,o]),this;return new Qc(e,this.hash,[...this.entries,[r,o]])}remove(e,t,n,r,o){if(this.canEdit(e))this._hash=void 0;if(this.hash!==n)return this;let s=this.entries.findIndex(([i])=>he(i,r));if(s===-1)return this;if(o.value=!0,this.entries.length===1)return;if(this.entries.length===2){let i=this.entries[s===0?1:0];return new $o(e,this.hash,i[0],i[1])}if(this.canEdit(e))return this.entries.splice(s,1),this;let a=[...this.entries];return a.splice(s,1),new Qc(e,this.hash,a)}computeHash(){let e=0,t=this.entries;for(let n=0;n<t.length;n++)e^=qb(t[n][0],t[n][1]);return e}}class po extends ii{_tag="IndexedNode";edit;_size;bitmap;children;constructor(e,t,n){super();this.edit=e,this.bitmap=t,this.children=n}get size(){if(this._size===void 0)this._size=this.children.reduce((e,t)=>e+t.size,0);return this._size}get(e,t,n){let r=gs(t,e);if((this.bitmap&r)===0)return ne();let o=Sd(this.bitmap,r);return this.children[o].get(e+Or,t,n)}has(e,t,n){let r=gs(t,e);if((this.bitmap&r)===0)return!1;let o=Sd(this.bitmap,r);return this.children[o].has(e+Or,t,n)}set(e,t,n,r,o,s){if(this.canEdit(e))this._hash=void 0;let a=gs(n,t),i=Sd(this.bitmap,a);if((this.bitmap&a)!==0){let c=this.children[i],f=c.set(e,t+Or,n,r,o,s);if(c===f)return this;if(this.canEdit(e))return this.children[i]=f,this;let u=[...this.children];return u[i]=f,new po(e,this.bitmap,u)}else{s.value=!0;let c=new $o(e,n,r,o),f=this.bitmap|a;if(this.canEdit(e)){if(this.children.splice(i,0,c),this.bitmap=f,this._size=void 0,this.children.length>zb)return this.expand(e,f,this.children);return this}let u=[...this.children];if(u.splice(i,0,c),u.length>zb)return this.expand(e,f,u);return new po(e,f,u)}}remove(e,t,n,r,o){if(this.canEdit(e))this._hash=void 0;let s=gs(n,t);if((this.bitmap&s)===0)return this;let a=Sd(this.bitmap,s),i=this.children[a],c=i.remove(e,t+Or,n,r,o);if(!o.value)return this;if(c===void 0){let u=this.bitmap^s;if(u===0)return;if(this.children.length===2){let l=this.children[a===0?1:0];if(l._tag==="LeafNode")return l}if(this.canEdit(e))return this.children.splice(a,1),this.bitmap=u,this._size=void 0,this;let d=[...this.children];return d.splice(a,1),new po(e,u,d)}if(i===c)return this;if(this.canEdit(e))return this.children[a]=c,this;let f=[...this.children];return f[a]=c,new po(e,this.bitmap,f)}expand(e,t,n){let r=new globalThis.Array(Xc),o=0;for(let s=0;s<Xc;s++)if((t&1<<s)!==0)r[s]=n[o++];return new Yc(e,n.length,r)}computeHash(){return Hb(this.children)}}class Yc extends ii{_tag="ArrayNode";edit;_size;count;children;constructor(e,t,n){super();this.edit=e,this.count=t,this.children=n}get size(){if(this._size===void 0)this._size=this.children.reduce((e,t)=>e+(t?.size??0),0);return this._size}get(e,t,n){let r=Zc(t,e),o=this.children[r];return o?o.get(e+Or,t,n):ne()}has(e,t,n){let r=Zc(t,e),o=this.children[r];return o?o.has(e+Or,t,n):!1}set(e,t,n,r,o,s){if(this.canEdit(e))this._hash=void 0;let a=Zc(n,t),i=this.children[a];if(i){let c=i.set(e,t+Or,n,r,o,s);if(i===c)return this;if(this.canEdit(e))return this.children[a]=c,this;let f=[...this.children];return f[a]=c,new Yc(e,this.count,f)}else{s.value=!0;let c=new $o(e,n,r,o);if(this.canEdit(e))return this.children[a]=c,this.count++,this._size=void 0,this;let f=[...this.children];return f[a]=c,new Yc(e,this.count+1,f)}}remove(e,t,n,r,o){if(this.canEdit(e))this._hash=void 0;let s=Zc(n,t),a=this.children[s];if(!a)return this;let i=a.remove(e,t+Or,n,r,o);if(!o.value)return this;let c=this.count-(i?0:1);if(c<XU)return this.pack(e,s,i);if(a===i)return this;if(this.canEdit(e)){if(this.children[s]=i,!i)this.count=c;return this._size=void 0,this}let f=[...this.children];return f[s]=i,new Yc(e,c,f)}pack(e,t,n){let r=[],o=0,s=1;for(let a=0;a<this.children.length;a++){let i=a===t?n:this.children[a];if(i)r.push(i),o|=s;s<<=1}return new po(e,o,r)}computeHash(){return Hb(this.children)}}class Ih{stack;project;entries=[];index=0;constructor(e,t){this.stack=[e],this.project=t}next(){while(!0){if(this.index<this.entries.length){let t=this.entries[this.index++];return{done:!1,value:this.project(t[0],t[1])}}if(this.stack.length===0)return{done:!0,value:void 0};let e=this.stack.pop();switch(e._tag){case"LeafNode":{let t=e;return{done:!1,value:this.project(t.key,t.value)}}case"CollisionNode":{this.entries=e.entries,this.index=0;break}case"IndexedNode":case"ArrayNode":{let t=e.children;for(let n=t.length-1;n>=0;n--){let r=t[n];if(r)this.stack.push(r)}}}}}[Symbol.iterator](){return this}}var rF=(e,t)=>[e,t];class bd{[Ed]=Ed;_editable;_edit;_root;_size;constructor(e,t,n,r){this._editable=e,this._edit=t,this._root=n,this._size=r}get size(){return this._size}[Symbol.iterator](){return new Ih(this._root,rF)}[ze](e){if(wh(e)){let t=e;if(this.size!==t.size)return!1;for(let[n,r]of this){let o=bh(e,Gb(n));if(Tn(o)||!he(r,o.value))return!1}return!0}return!1}[Be](){return mo(nF^this._root.subtreeHash())}[Re](){return lo(this)}toString(){return`HashMap(${K(Array.from(this))})`}toJSON(){return{_id:"HashMap",values:Array.from(this).map(([e,t])=>[lo(e),lo(t)])}}pipe(){return de(this,arguments)}}var Wb=new jb,wh=(e)=>V(e,Ed),kh=()=>new bd(!1,0,Wb,0);var Jb=(e)=>{let t=Wb,n=0,r={value:!1};for(let[o,s]of e){let a=We(o);if(r.value=!1,t=t.set(NaN,0,a,o,s,r),r.value)n++}return new bd(!1,0,t,n)};var Gb=y(2,(e,t)=>e._root.get(0,We(t),t));var Th=y(2,(e,t)=>e._root.has(0,We(t),t));var oF=(e,t,n,r)=>{let o=e,s={value:!1},a=o._editable?o._edit:NaN,i=o._root.set(a,0,n,t,r,s);if(o._editable){if(o._root=i,s.value)o._size++;return e}if(o._root===i)return e;return new bd(!1,o._edit,i,o._size+(s.value?1:0))},Ah=y(3,(e,t,n)=>oF(e,t,We(t),n)),Ch=(e)=>new Ih(e._root,Q);var Kb=(e)=>e[Symbol.iterator](),Id=(e)=>e.size;var wd=wh;var vh=Jb;var iF=Kb,ef=(e)=>Array.from(iF(e)),Zb=Id;var tf="~effect/HashSet",cF=mn(tf),fF={[Be](){return mo(Le(cF,We(kd(this))))},[ze](e){return _h(e)&&Td(this)===Td(e)&&Xb(this,(t)=>Yb(e,t))},[Symbol.iterator](){return Ch(kd(this))},toString(){return`HashSet(${K(Array.from(this))})`},toJSON(){return{_id:"HashSet",values:lo(Array.from(this))}},[Re](){return this.toJSON()},pipe(){return de(this,arguments)}},uF=(e)=>{let t=Object.create(fF);return t[tf]=tf,t.keyMap=e,t},_h=(e)=>V(e,tf),kd=(e)=>e.keyMap;var Qb=(e)=>{let t=kh();for(let n of e)t=Ah(t,n,!0);return uF(t)},Yb=(e,t)=>Th(kd(e),t);var Td=(e)=>Id(kd(e));var Xb=(e,t)=>{for(let n of e)if(!t(n))return!1;return!0};var Rh=Qb,Ad=_h;var eI=Td;var Mh="~effect/http/Cookies",aI=(e)=>V(e,Mh),Uh="~effect/http/Cookies/Cookie",iI=(e)=>V(e,Uh),tI="~effect/http/Cookies/CookieError";class cI extends sI{}class ca extends Qt("CookiesError"){static fromReason(e,t){return new ca({reason:new cI({_tag:e,cause:t})})}[tI]=tI;get message(){return this.reason._tag}}var lF={[Mh]:Mh,...ho,toJSON(){return{_id:"effect/Cookies",cookies:Cd(this.cookies,(e)=>e.toJSON())}},pipe(){return de(this,arguments)}},Dh=(e)=>{let t=Object.create(lF);return t.cookies=e,t},Nh=(e)=>{let t={};for(let n of e)q(t,n.name,n);return Dh(t)},vd=(e)=>{let t=typeof e==="string"?[e]:e,n=[];for(let r of t){let o=pF(r.trim());if(o)n.push(o)}return Nh(n)};function pF(e){let t=e.split(";").map((i)=>i.trim()).filter((i)=>i!=="");if(t.length===0)return;let n=t[0].indexOf("=");if(n===-1)return;let r=t[0].slice(0,n);if(!fI.test(r))return;let o=t[0].slice(n+1),s=SF(o);if(t.length===1)return Object.assign(Object.create(Fh),{name:r,value:s,valueEncoded:o});let a={};for(let i=1;i<t.length;i++){let c=t[i],f=c.indexOf("="),u=f===-1?c:c.slice(0,f).trim(),d=f===-1?void 0:c.slice(f+1).trim();switch(u.toLowerCase()){case"domain":{if(d===void 0)break;let l=d.trim().replace(/^\./,"");if(l)a.domain=l;break}case"expires":{if(d===void 0)break;let l=new Date(d);if(!isNaN(l.getTime()))a.expires=l;break}case"max-age":{if(d===void 0)break;let l=parseInt(d,10);if(!isNaN(l))a.maxAge=rI(l);break}case"path":{if(d===void 0)break;if(d[0]==="/")a.path=d;break}case"priority":{if(d===void 0)break;switch(d.toLowerCase()){case"low":a.priority="low";break;case"medium":a.priority="medium";break;case"high":a.priority="high";break}break}case"httponly":{a.httpOnly=!0;break}case"secure":{a.secure=!0;break}case"partitioned":{a.partitioned=!0;break}case"samesite":{if(d===void 0)break;switch(d.toLowerCase()){case"lax":a.sameSite="lax";break;case"strict":a.sameSite="strict";break;case"none":a.sameSite="none";break}break}}}return Object.assign(Object.create(Fh),{name:r,value:s,valueEncoded:o,options:Object.keys(a).length>0?a:void 0})}var mF=/^[\u0009\u0020-\u007e\u0080-\u00ff]+$/,fI=/^[!#$%&'*+\-.^_`|~0-9A-Za-z]+$/,hF=/^[\u0009\u0020-\u003a\u003c-\u007e\u0080-\u00ff]+$/,gF=/^[\u0020-\u003a\u003c-\u007e]+$/,Fh={[Uh]:Uh,...ho,toJSON(){return{_id:"effect/Cookies/Cookie",name:this.name,value:this.value,options:this.options}}};function xF(e,t,n){let r=encodeURIComponent(t),o=uI(e,r,n);if(o!==void 0)return ge(o);return ue(Object.assign(Object.create(Fh),{name:e,value:t,valueEncoded:r,options:n}))}function uI(e,t,n){if(!fI.test(e))return ca.fromReason("InvalidCookieName");if(t&&!mF.test(t))return ca.fromReason("InvalidCookieValue");if(n?.domain!==void 0&&!hF.test(n.domain))return ca.fromReason("InvalidCookieDomain");if(n?.path!==void 0&&!gF.test(n.path))return ca.fromReason("InvalidCookiePath");if(n?.maxAge!==void 0&&!xs(Zt(n.maxAge)))return ca.fromReason("CookieInfinityMaxAge")}var dI=(e,t,n)=>rf(xF(e,t,n));function yF(e){let t=uI(e.name,e.valueEncoded,e.options);if(t!==void 0)throw t;let n=e.name+"="+e.valueEncoded;if(e.options===void 0)return n;let r=e.options;if(r.maxAge!==void 0){let o=oI(Zt(r.maxAge));n+="; Max-Age="+Math.trunc(o)}if(r.domain!==void 0)n+="; Domain="+r.domain;if(r.path!==void 0)n+="; Path="+r.path;if(r.priority!==void 0)switch(r.priority){case"low":n+="; Priority=Low";break;case"medium":n+="; Priority=Medium";break;case"high":n+="; Priority=High";break}if(r.expires!==void 0)n+="; Expires="+r.expires.toUTCString();if(r.httpOnly)n+="; HttpOnly";if(r.secure)n+="; Secure";if(r.partitioned)n+="; Partitioned";if(r.sameSite!==void 0)switch(r.sameSite){case"lax":n+="; SameSite=Lax";break;case"strict":n+="; SameSite=Strict";break;case"none":n+="; SameSite=None";break}return n}var lI=(e)=>{let t={},n=Object.values(e.cookies);for(let r=0;r<n.length;r++){let o=n[r];q(t,o.name,o.value)}return t},pI=(e)=>Object.values(e.cookies).map(yF);var SF=(e)=>{try{return decodeURIComponent(e)}catch(t){return e}};var fa=new WeakMap,hI=(e)=>{if(fa.has(e))return fa.get(e);else throw Error("Unable to get redacted value"+(e.label?` with label: "${e.label}"`:""))};var gI="~effect/Redacted",of=(e)=>V(e,gI),ua=(e,t)=>{let n=Object.create(bF);if(t?.label)n.label=t.label;return fa.set(n,e),n},bF={[gI]:{_A:(e)=>e},label:void 0,...Ss,toJSON(){return this.toString()},toString(){return`<redacted${ys(this.label)?":"+this.label:""}>`},[Be](){return We(fa.get(this))},[ze](e){return of(e)&&he(fa.get(this),fa.get(e))}},Rr=hI;var xI=(e)=>Ar((t,n)=>e(Rr(t),Rr(n)));var Bh=Symbol.for("~effect/http/Headers"),bI=(e)=>V(e,Bh),_d=Object.defineProperties(Object.create(null),{[Bh]:{value:Bh},[SI]:{value(e){return IF(this,Lt(e,wF))}},toJSON:{value(){return ui(this)}},[ze]:{value(e){return Lh(this,e)}},[Be]:{value(){return yI(this)}},toString:{value:ho.toString},[Re]:{value:ho[Re]}}),Rd=(e)=>Object.assign(Object.create(_d),e),Lh=EI(da()),di=Object.create(_d),Es=(e)=>{if(e===void 0)return di;else if(Symbol.iterator in e){let n=Object.create(_d);for(let[r,o]of e)n[r.toLowerCase()]=o;return n}let t=Object.create(_d);for(let[n,r]of Object.entries(e))if(Array.isArray(r))t[n.toLowerCase()]=r.join(", ");else if(r!==void 0)t[n.toLowerCase()]=r;return t};var af=y(3,(e,t,n)=>{let r=Rd(e);return r[t.toLowerCase()]=n,r}),II=y(2,(e,t)=>Rd({...e,...Es(t)})),Pd=y(2,(e,t)=>{let n=Rd(e);return Object.assign(n,t),n}),li=y(2,(e,t)=>{let n=Rd(e);return delete n[t.toLowerCase()],n});var IF=y(2,(e,t)=>{let n={...e},r=(o)=>{if(typeof o==="string"){let s=o.toLowerCase();if(s in e)n[s]=ua(e[s])}else for(let s in e)if(s.search(o)!==-1)n[s]=ua(e[s])};if(Array.isArray(t))for(let o=0;o<t.length;o++)r(t[o]);else r(t);return n});var wF=sf("effect/Headers/CurrentRedactedNames",{defaultValue:()=>["authorization","cookie","set-cookie","x-api-key"]});var zh="~effect/http/UrlParams",qh=(e)=>V(e,zh),kF={...Ss,[zh]:zh,[Symbol.iterator](){return this.params[Symbol.iterator]()},toJSON(){return{_id:"UrlParams",params:Object.fromEntries(this.params)}},[ze](e){return Hh(this,e)},[Be](){return oi(this.params.flat())}},pi=(e)=>{let t=Object.create(kF);return t.params=e,t},la=(e)=>{if(qh(e))return e;let t=TI(e),n=[];for(let r=0;r<t.length;r++)if(Array.isArray(t[r][0])){let[o,s]=t[r];n.push([`${o[0]}[${o.slice(1).join("][")}]`,s])}else n.push(t[r]);return pi(n)},TI=(e)=>{let t=typeof e[Symbol.iterator]==="function"?_t(e):Object.entries(e),n=[];for(let[r,o]of t)if(Array.isArray(o)){for(let s=0;s<o.length;s++)if(o[s]!==void 0)n.push([r,String(o[s])])}else if(o!==null&&typeof o==="object"){let s=TI(o);for(let[a,i]of s)n.push([[r,...typeof a==="string"?[a]:a],i])}else if(o!==void 0)n.push([r,String(o)]);return n},Hh=Ar((e,t)=>TF(e.params,t.params)),TF=kI(wI([da(),da()])),AI=pi([]);var CI=y(2,(e,t)=>fh(e.params,([n])=>n===t).pipe(qo(([,n])=>n)));var vI=y(2,(e,t)=>{let n=la(t).params.slice(),r=new Set;for(let o=0;o<n.length;o++)r.add(n[o][0]);for(let o=0;o<e.params.length;o++){if(r.has(e.params[o][0]))continue;n.push(e.params[o])}return pi(n)});var AF=(e)=>{let t={};for(let[n,r]of e.params)if(!Object.hasOwn(t,n))q(t,n,r);else{let o=t[n];if(typeof o==="string")q(t,n,[o,r]);else o.push(r)}return t},OI=AF;var Wh="~effect/Graph",Jh=(e)=>V(e,Wh),_I=(e)=>e;var CF=(e,t,n)=>(e==="directed"?t.source===n.source&&t.target===n.target:t.source===n.source&&t.target===n.target||t.source===n.target&&t.target===n.source)&&he(t.data,n.data),vF=(e,t)=>e==="directed"?We(t):mo(Le(We(t.data),OF(t.source,t.target))),OF=(e,t)=>Le(0,We(e))+Le(0,We(t)),_F=mn("Graph"),RF={[Wh]:{_N:(e)=>e,_E:(e)=>e},[Symbol.iterator](){return this.nodes[Symbol.iterator]()},[Re](){return this.toJSON()},[ze](e){if(V(e,Wh)){let t=_I(e);if(this.nodes.size!==t.nodes.size||this.edges.size!==t.edges.size||this.type!==t.type)return!1;for(let[n,r]of this.nodes)if(!t.nodes.has(n)||!he(r,t.nodes.get(n)))return!1;for(let[n,r]of this.edges){let o=t.edges.get(n);if(o===void 0||!CF(this.type,r,o))return!1}return!0}return!1},[Be](){let e=_F;e=e^mn(this.type),e=e^Bn(this.nodes.size),e=e^Bn(this.edges.size);for(let[t,n]of this.nodes)e^=Le(We(t),We(n));for(let[t,n]of this.edges)e^=Le(We(t),vF(this.type,n));return mo(e)},toJSON(){return{_id:"Graph",nodeCount:this.nodes.size,edgeCount:this.edges.size,type:this.type}},toString(){return`Graph(${this.type}, ${this.nodes.size}, ${this.edges.size})`},pipe(){return de(this,arguments)}},PF=(e,t)=>{let n=Object.create(RF);return n.type=e,n.mutable=t,n.transforming=!1,n.nodes=new Map,n.edges=new Map,n.adjacency=new Map,n.reverseAdjacency=new Map,n.nextNodeIndex=0,n.nextEdgeIndex=0,n.acyclic=oe(!0),n};var ff=(e)=>{let t=_I(e);return{type:e.type,nodes:Array.from(t.nodes,([n,r])=>({index:n,data:r})).sort((n,r)=>n.index-r.index),edges:Array.from(t.edges,([n,r])=>({index:n,source:r.source,target:r.target,data:r.data})).sort((n,r)=>n.index-r.index)}},Ud=(e)=>{let t=PF(e.type,!1);for(let n of e.nodes)t.nodes.set(n.index,n.data),t.adjacency.set(n.index,[]),t.reverseAdjacency.set(n.index,[]);for(let n of e.edges)if(t.edges.set(n.index,{source:n.source,target:n.target,data:n.data}),t.adjacency.get(n.source).push(n.index),t.reverseAdjacency.get(n.target).push(n.index),e.type==="undirected")t.adjacency.get(n.target).push(n.index),t.reverseAdjacency.get(n.source).push(n.index);return t.nextNodeIndex=e.nodes.length===0?0:e.nodes[e.nodes.length-1].index+1,t.nextEdgeIndex=e.edges.length===0?0:e.edges[e.edges.length-1].index+1,t.acyclic=ne(),t};function Ho(e){return e.checks?e.checks[e.checks.length-1].annotations:e.annotations}function Fd(e){return(t)=>Ho(t)?.[e]}var An="~structural",pa="~identifier",uf="~sentinels",Dd="~constructor",RI=["title","description","default","examples","readOnly","writeOnly","format","contentEncoding","contentMediaType","contentSchema"],mi=Fd("identifier"),Gh=Fd(pa),Kh=Fd("title");var df=Ln((e)=>{let t=Ho(e)?.identifier;if(typeof t==="string")return t;return e.getExpected(df)}),PI=new Set([uf,An,"representation","arbitraryConstraint","toJsonSchema","toCode","toEquivalence","toFormatter","toCodec","toCodecJson","toCodecStringTree","toCodecIso","toCodecArbitrary"]);var ce=Symbol();var Rt=xn,Cn=Rt(ce),Ce=Rt(ce),lf=(e)=>e===ce?ne():oe(e),Vh=(e)=>e._tag==="None"?Cn:Rt(e.value);var mf="~effect/SchemaIssue/Issue";function Qh(e){return V(e,mf)&&e[mf]===mf}function UF(e){return Object.hasOwn(e,"input")}class nr{[mf]=mf;constructor(e,t){if(t?.reportInput===!0&&e!==ce)this.input=e}}var MI=class extends nr{_tag="Filter";filter;issue;constructor(e,t,n,r){super(n,r);this.filter=e,this.issue=t}},UI=class extends nr{_tag="Encoding";ast;issue;constructor(e,t,n,r){super(n,r);this.ast=e,this.issue=t}},Qe=class extends nr{_tag="Pointer";path;issue;constructor(e,t){super();this.path=e,this.issue=t}},ot=class extends nr{_tag="MissingKey";annotations;constructor(e){super();this.annotations=e}},ma=class extends nr{_tag="UnexpectedKey";ast;constructor(e,t,n){super(t,n);this.ast=e}},tt=class extends nr{_tag="Composite";ast;issues;constructor(e,t,n,r){super(n,r);this.ast=e,this.issues=t}},Fe=class extends nr{_tag="InvalidType";ast;constructor(e,t,n){super(t,n);this.ast=e}},te=class extends nr{_tag="InvalidValue";annotations;constructor(e,t,n){super(t,n);this.annotations=e}};function vn(e,t,n,r,o){return new tt(e,[new Qe([t],n)],r,o)}var hf=class extends nr{_tag="Forbidden";annotations;constructor(e,t,n){super(t,n);this.annotations=e}},gf=class extends nr{_tag="AnyOf";ast;issues;constructor(e,t,n,r){super(n,r);this.ast=e,this.issues=t}},FI=class extends nr{_tag="OneOf";ast;successes;constructor(e,t,n,r){super(n,r);this.ast=e,this.successes=t}};function Zh(e,t,n){if(Qh(e))return e;if(typeof e==="string")return new te({message:e},t,n);let r=typeof e.issue==="string"?new te({message:e.issue},t,n):e.issue;return new Qe(e.path,r)}function DI(e,t,n){if(e===void 0)return;if(typeof e==="boolean")return e?void 0:new te(void 0,t,n);return Zh(e,t,n)}function NI(e,t,n,r){if(Array.isArray(t)){if(!Ke(t))return;return t.length===1?Zh(t[0],n,r):new tt(e,hn(t,(o)=>Zh(o,n,r)),n,r)}return DI(t,n,r)}var BI=(e)=>{let t=xi(e);if(t!==void 0)return t;switch(e._tag){case"InvalidType":return Is(df(e.ast),e);case"InvalidValue":{let n=Yh(e);if(n!==void 0)return Is(n,e);let r=Nd(e);return r===void 0?"Expected a valid value":`Invalid data ${r}`}case"MissingKey":return"Missing key";case"UnexpectedKey":{let n=Nd(e);return n===void 0?"Expected no excess property":`Unexpected key with value ${n}`}case"Forbidden":return"Forbidden operation";case"OneOf":{let n=Nd(e);return n===void 0?"Expected exactly one member to match":`Expected exactly one member to match the input ${n}`}}},LI=(e)=>xi(e.issue)??xi(e);function zI(e){return(t)=>({issues:gi(t,[],e?.leafHook??BI,e?.checkHook??LI)})}function Nd(e){return UF(e)?K(e.input):void 0}function Yh(e){let t=e.annotations?.expected;return typeof t==="string"?t:void 0}function Is(e,t){let n=Nd(t);return n===void 0?`Expected ${e}`:`Expected ${e}, got ${n}`}function gi(e,t,n,r){switch(e._tag){case"Filter":{let o=r(e);if(o!==void 0)return[{path:t,message:o}];if(e.issue._tag!=="InvalidValue")return gi(e.issue,t,n,r);let s=Yh(e.issue);return[{path:t,message:s===void 0?Is(Xh(e.filter),e):Is(s,e.issue)}]}case"Encoding":return gi(e.issue,t,n,r);case"Pointer":return gi(e.issue,[...t,...e.path],n,r);case"Composite":return e.issues.flatMap((o)=>gi(o,t,n,r));case"AnyOf":{if(e.issues.length===0)return[{path:t,message:xi(e)??Is(df(e.ast),e)}];return e.issues.flatMap((o)=>gi(o,t,n,r))}default:return[{path:t,message:n(e)}]}}function Xh(e){let t=e.annotations?.expected;if(typeof t==="string")return t;switch(e._tag){case"Filter":return"<filter>";case"FilterGroup":return e.checks.map((n)=>Xh(n)).join(" & ")}}function FF(){return(e)=>pf(e,"")}var $I=FF();function pf(e,t){let n;switch(e._tag){case"Filter":{let r=LI(e);if(r!==void 0)n=r;else{if(e.issue._tag!=="InvalidValue")return pf(e.issue,t);let o=Yh(e.issue);n=o===void 0?Is(Xh(e.filter),e):Is(o,e.issue)}break}case"Encoding":return pf(e.issue,t);case"Pointer":return pf(e.issue,t+Bd(e.path));case"Composite":case"AnyOf":{if(e._tag==="Composite"||e.issues.length>0)return e.issues.map((r)=>pf(r,t)).join(`
|
|
3
|
-
`);n=xi(e)??Is(df(e.ast),e);break}default:n=
|
|
4
|
-
at ${t}`:n}function xi(e){if(e._tag==="Pointer")return;if(e._tag==="Encoding")return xi(e.issue);let n=(e._tag==="Filter"?e.filter.annotations:("annotations"in e)?e.annotations:e.ast.annotations)?.[e._tag==="MissingKey"?"messageMissingKey":e._tag==="UnexpectedKey"?"messageUnexpectedKey":"message"];if(typeof n==="string")return n}function xf(e){let t;for(let n of e.reasons){if(!Ld(n)||!Qh(n.error))return;t??=n.error}return t}function zn(e,t){let n=xf(e);if(n===void 0)throw Error(t,{cause:e});return n}var HI=(e)=>ai(e).replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_"),eg=(e)=>{let t=e.replace(/[\n\r]/g,""),n=t.length;if(n%4===1)return ge(new aa({module:"Base64Url",kind:"Decode",input:t,message:`Length should be a multiple of 4, but is ${n}`}));if(!/^[-_A-Z0-9]*?={0,2}$/i.test(t))return ge(new aa({module:"Base64Url",kind:"Decode",input:t,message:"Invalid input"}));let r=n%4===2?`${t}==`:n%4===3?`${t}=`:t;return r=r.replace(/-/g,"+").replace(/_/g,"/"),ia(r)},jI=(e)=>vr(eg(e),(t)=>DF.decode(t)),DF=new TextDecoder;var yf=(e)=>Object.assign(Object.create(WI),e);function LF(e){return YI((t,n)=>_(e(t,n)))}function jd(e){return LF((t,n)=>{let r={message:e(t)};return ve(t)?new hf(r,t.value,n):new hf(r)})}var QI=jd(()=>"Encoding is not supported"),zF=yf({_tag:"Passthrough"});function xo(){return zF}function se(e){return yf({_tag:"Transform",transform:e})}function $t(e){return yf({_tag:"TransformEffect",transform:e})}function Wd(e){return yf({_tag:"TransformOptional",transform:e})}function YI(e){return yf({_tag:"TransformOptionalEffect",transform:e})}function tg(){return Wd(()=>ne())}function ng(e){return YI((t)=>{let n=yi(t,ws);return ve(n)?b(n):qd(e,oe)})}function ha(){return se(globalThis.String)}function Jd(){return se(globalThis.Number)}function XI(){return se(globalThis.BigInt)}function rg(){return se((e)=>new globalThis.Date(e))}function ew(){return se(VI)}function tw(e){return $t((t,n)=>Mr({try:()=>JSON.parse(t,e?.reviver),catch:()=>new te({expected:"a valid JSON string"},t,n)}))}function nw(e){return $t((t,n)=>Mr({try:()=>{let r=JSON.stringify(t,e?.replacer,e?.space);if(r===void 0)throw TypeError("Value cannot be represented as JSON");return r},catch:()=>new te({expected:"a JSON-serializable value"},t,n)}))}function og(){return se(ai)}function Gd(){return se(HI)}function Kd(){return se(JI)}function rw(){return $t((e,t)=>Hd(ZI(ia(e)),()=>new te({expected:"a valid Base64 string"},e,t)))}function ow(){return $t((e,t)=>Pr(Lb(e),{onFailure:()=>_(new te({expected:"a valid Base64 string"},e,t)),onSuccess:b}))}function sw(){return $t((e,t)=>Pr(eg(e),{onFailure:()=>_(new te({expected:"a valid Base64Url string"},e,t)),onSuccess:b}))}function aw(){return $t((e,t)=>Pr(jI(e),{onFailure:()=>_(new te({expected:"a valid Base64Url string"},e,t)),onSuccess:b}))}function iw(){return $t((e,t)=>Pr(GI(e),{onFailure:()=>_(new te({expected:"a valid hexadecimal string"},e,t)),onSuccess:b}))}function cw(){return $t((e,t)=>Pr(KI(e),{onFailure:()=>_(new te({expected:"a valid hexadecimal string"},e,t)),onSuccess:b}))}function fw(){return se(encodeURIComponent)}function uw(){return $t((e,t)=>{try{return b(globalThis.decodeURIComponent(e))}catch{return _(new te({expected:"a valid URI component"},e,t))}})}function dw(){return se((e)=>hw(Array.from(e.entries())))}var $F=gw((e)=>typeof e==="string"||typeof Blob<"u"&&e instanceof Blob);function lw(){return se((e)=>{let t=new FormData;if(typeof e==="object"&&e!==null)$F(e).forEach(([r,o])=>{t.append(r,o)});return t})}function pw(){return se((e)=>hw(Array.from(e.entries())))}var qF=gw(ys);function mw(){return se((e)=>{if(typeof e==="object"&&e!==null)return new URLSearchParams(qF(e));return new URLSearchParams})}function HF(e){if(e==="")return[""];let t=e.replace(/\[(.*?)\]/g,".$1"),n=t.split("."),r=t.startsWith(".")?1:0;return n.slice(r).map((o)=>$d(o)?globalThis.Number(o):o)}function hw(e){let t={},n=new WeakSet,r=new WeakSet;function o(s,a,i){let c=Object.hasOwn(s,a)?s[a]:void 0;if(n.has(c)&&Array.isArray(c)===i)return c;let f=i?[]:{};return n.add(f),q(s,a,f),f}return e.forEach(([s,a])=>{let i=HF(s),c=t;i.forEach((f,u)=>{let d=u===i.length-1;if(Array.isArray(c)&&f==="")if(d)c.push(a);else{let l=i[u+1],m=typeof l==="number"||l==="",p=c.length;c=o(c,p,m)}else if(d){let l=Object.hasOwn(c,f);if(l&&Array.isArray(c[f])&&(n.has(c[f])||r.has(c[f])))c[f].push(a);else if(l){let m=[c[f],a];r.add(m),q(c,f,m)}else q(c,f,a)}else{let l=i[u+1];c=o(c,f,typeof l==="number"||l==="")}})}),t}function gw(e){return(t)=>{let n=[];function r(o,s){if(e(s))n.push([o,s]);else if(Array.isArray(s))if(s.every(e))s.forEach((i)=>{n.push([o,i])});else s.forEach((i,c)=>{r(`${o}[${c}]`,i)});else if(typeof s==="object"&&s!==null)for(let[a,i]of Object.entries(s))r(`${o}[${a}]`,i)}for(let[o,s]of Object.entries(t))r(o,s);return n}}var Qd=class extends Ei{_tag="Middleware";decode;encode;constructor(e,t){super();this.decode=e,this.encode=t}flip(){return new Qd(this.encode,this.decode)}},Sf="~effect/SchemaTransformation/Transformation",be=class extends Ei{[Sf]=Sf;_tag="Transformation";decode;encode;constructor(e,t){super();this.decode=e,this.encode=t}flip(){return new be(this.encode,this.decode)}};function jF(e){return V(e,Sf)&&e[Sf]===Sf}var Yd=(e)=>{if(jF(e))return e;return new be(e.decode,e.encode)};function Et(e){return new be($t(e.decode),$t(e.encode))}function xe(e){return new be(se(e.decode),se(e.encode))}function Xd(e){return new be(Wd(e.decode),Wd(e.encode))}function Iw(){return new be(ew(),xo())}var WF=new be(xo(),xo());function Ii(){return WF}var wi=new be(Jd(),ha()),el=new be(XI(),ha()),ag=new be(rg(),se(yw)),ww=new be(rg(),se((e)=>e.getTime()));var ig=Et({decode:(e,t)=>zt(QE(e),{onNone:()=>_(new te({expected:"a valid ByteSize string"},e,t)),onSome:b}),encode:(e)=>b(`${e} ${e===BigInt(1)?"byte":"bytes"}`)}),kw=Et({decode:(e,t)=>zt(ah(e),{onNone:()=>_(new te({expected:"a non-negative bigint byte count"},e,t)),onSome:b}),encode:(e)=>b(ld(e))}),Tw=Et({decode:(e,t)=>zt(ah(e),{onNone:()=>_(new te({expected:"a non-negative safe-integer byte count"},e,t)),onSome:b}),encode:(e,t)=>zt(eb(e),{onNone:()=>_(new te({expected:"a ByteSize representable as a safe integer"},e,t)),onSome:b})}),JF=(e)=>st(e)&&typeof e.message==="string",Aw=(e)=>{let n=Object.hasOwn(e,"cause")?Error(e.message,{cause:vw(e.cause)}):Error(e.message);if(typeof e.name==="string"&&e.name!=="Error")n.name=e.name;if(typeof e.stack==="string")n.stack=e.stack;return n},GF=(e)=>{try{let t=Sw(e);return t===void 0?K(e):JSON.parse(t)}catch{return K(e)}},KF=(e,t,n)=>{let r={name:e.name,message:typeof e.message==="string"?e.message:""};if(t?.includeStack&&typeof e.stack==="string")r.stack=e.stack;if(!t?.excludeCause&&e.cause!==void 0)r.cause=n(e.cause);return r},Cw=(e)=>{let t=new WeakSet,n=(r)=>{if(xw(r)){if(t.has(r))return"[Circular]";t.add(r);let o=KF(r,e,n);return t.delete(r),o}return GF(r)};return n},vw=(e)=>JF(e)?Aw(e):e,Ow=(e)=>xe({decode:Aw,encode:(t)=>Cw(e)(t)}),_w=(e)=>xe({decode:vw,encode:Cw(e)});function Rw(){return xe({decode:bw,encode:sg})}function Pw(){return xe({decode:Ew,encode:Ef})}function Mw(e){return xe({decode:Zd,encode:e?.onNoneEncoding===null?sg:Ef})}function Uw(){return Xd({decode:oe,encode:bi})}function Fw(){return Xd({decode:(e)=>e.pipe(yi(ws),oe),encode:bi})}var cg=Et({decode:(e,t)=>URL.canParse(e)?b(new URL(e)):_(new te({expected:"a valid URL string"},e,t)),encode:(e)=>b(e.href)});var fg=new be(rw(),og()),Dw=new be(ow(),og()),Nw=new be(aw(),Gd()),Bw=new be(cw(),Kd()),Lw=new be(uw(),fw());function zw(e){return new be(tw(e??{}),nw(e))}var $w=new be(dw(),lw()),qw=new be(pw(),mw());function As(e){return(t)=>t._tag===e}var Ci=As("Declaration");var VF=As("Never");var Ti=As("Literal"),dg=As("UniqueSymbol");var Eg=As("Arrays"),ZF=As("Objects"),nk=As("Union"),rk=As("Suspend"),Xe=class{to;transformation;constructor(e,t){this.to=e,this.transformation=t}},jt={},sr=class{isOptional;isMutable;constructorDefault;annotations;constructor(e,t,n=void 0,r=void 0){this.isOptional=e,this.isMutable=t,this.constructorDefault=n,this.annotations=r}},Hw="~effect/Schema";class at{[Hw]=Hw;annotations;checks;encoding;context;constructor(e=void 0,t=void 0,n=void 0,r=void 0){this.annotations=e,this.checks=t,this.encoding=n,this.context=r}toString(){return`<${this._tag}>`}}var Cs=class extends at{_tag="Declaration";typeParameters;run;encodingChecks;encodingRun;constructor(e,t,n,r,o,s,a,i){super(n,r,o,s);this.typeParameters=e,this.run=t,this.encodingChecks=a,this.encodingRun=i}getParser(){let e;return(t,n)=>{if(t===ce)return Cn;return(e??=this.run(this.typeParameters))(t,this,n)}}_rebuild(e,t,n,r,o){let s=xa(this.typeParameters,e);return s===this.typeParameters&&t===this.checks&&n===this.encodingChecks&&r===this.run&&o===this.encodingRun?this:new Cs(s,r,this.annotations,t,void 0,this.context,n,o)}recur(e){return this._rebuild(e,this.checks,this.encodingChecks,this.run,this.encodingRun)}flip(e){return this._rebuild(e,this.encodingChecks,this.checks,this.encodingRun??this.run,this.run)}getExpected(){let e=this.annotations?.expected;if(typeof e==="string")return e;return"<Declaration>"}},QF=class extends at{_tag="Null";getParser(){return xl(this,null)}getExpected(){return"null"}},bg=new QF;var YF=class extends at{_tag="Undefined";getParser(){return xl(this,void 0)}toCodecJson(){return Pe(this,[ok])}getExpected(){return"undefined"}},ok=new Xe(bg,new be(se(()=>{return}),se(()=>null))),Ig=new YF;var XF=class extends at{_tag="Void";getParser(){let e=Rt(void 0);return(t)=>t===ce?Cn:e}toCodecJson(){return Pe(this,[ok])}getExpected(){return"void"}},sk=new XF;var eD=class extends at{_tag="Never";getParser(){return Fr(this,ek)}getExpected(){return"never"}},wg=new eD,tD=class extends at{_tag="Any";getParser(){return Fr(this,Sg)}getExpected(){return"any"}},ak=new tD,nD=class extends at{_tag="Unknown";getParser(){return Fr(this,Sg)}getExpected(){return"unknown"}},jo=new nD,rD=class extends at{_tag="ObjectKeyword";getParser(){return Fr(this,rl)}getExpected(){return"object | array | function"}},ik=new rD,ck=class extends at{_tag="Enum";enums;constructor(e,t,n,r,o){super(t,n,r,o);for(let[,s]of e)if(typeof s==="number"&&!globalThis.Number.isFinite(s))throw Error(`A numeric enum value must be finite, got ${K(s)}`);this.enums=e}getParser(){let e=new Set(this.enums.map(([,t])=>t));return Fr(this,(t)=>e.has(t))}toCodecStringTree(){if(this.enums.some(([e,t])=>typeof t==="number")){let e=Object.fromEntries(this.enums.map(([t,n])=>[globalThis.String(n),n]));return Pe(this,[new Xe(new tn(Object.keys(e).map((t)=>new yn(t))),new be(se((t)=>e[t]),ha()))])}return this}getExpected(){return this.enums.map(([e,t])=>JSON.stringify(t)).join(" | ")}};function ug(e){return typeof e==="number"?`parts[${e}]`:e}function lg(e,t,n){if(n.has(e))return!0;if(e.encoding)throw Error(`TemplateLiteral parts cannot have an encoding at ${ug(t)}`);let r;switch(e._tag){case"String":case"Number":case"BigInt":r=!0;break;case"Literal":r=!e.checks;break;case"TemplateLiteral":{let o=ug(t);r=!e.checks&&e.parts.every((s,a)=>lg(s,`${o}.parts[${a}]`,n));break}case"Union":{let o=ug(t);r=!e.checks&&e.types.every((s,a)=>lg(s,`${o}.types[${a}]`,n));break}default:return!1}if(r)n.add(e);return r}var kg=class extends at{_tag="TemplateLiteral";parts;encodedParts;literals;suffixLengths;constructor(e,t,n,r,o){super(t,n,r,o);let s=[],a=[],i=new Set;for(let f=0;f<e.length;f++){let u=e[f];if(!lg(u,f,i))throw Error(`Invalid TemplateLiteral part ${u._tag}`);s.push(u),a.push(u._tag==="Literal"?globalThis.String(u.literal):void 0)}let c=Array(s.length+1);c[s.length]=0;for(let f=s.length-1;f>=0;f--)c[f]=c[f+1]+(a[f]?.length??0);this.parts=e,this.encodedParts=s,this.literals=a,this.suffixLengths=c}getParser(e){let t=new ar(!1,this.parts.map(Ng),[]),n=e(Pi($n,t,uk(this)));return(r,o)=>{if(r===ce)return Cn;let s=n(r,o);if(s._tag==="Success")return Ce;return Ht(s,{onSuccess:()=>r,onFailure:(a)=>new tt(this,[a],r,o)})}}getExpected(){return"string"}matchPart(e,t){return Fk(this,e,t)===void 0?void 0:e}};function fk(e){let t=Ln((o)=>{if(o._tag!=="Union")return o;let s=xa(o.types,t);return(o.options?.mode??"anyOf")==="anyOf"&&s===o.types?o:new tn(s,o.options===void 0?void 0:{...o.options,mode:"anyOf"},o.annotations,o.checks,void 0,o.context)}),n=new kg(e.map((o)=>t(En(o)))),r=new ar(!1,e.map(Ng),[]);return Pi(n,r,uk(n))}function uk(e){return new be($t((t,n)=>{let r=Fk(e,t,n);if(r)return b(r);return _(new te({expected:"a string matching template literal parts"},t,n))}),se((t)=>t.join("")))}var dk=class extends at{_tag="UniqueSymbol";symbol;constructor(e,t,n,r,o){super(t,n,r,o);this.symbol=e}getParser(){return xl(this,this.symbol)}toCodecStringTree(){let e=globalThis.Symbol.keyFor(this.symbol);return Pe(this,[new Xe(e===void 0?wg:new yn(globalThis.String(this.symbol)),Bk.transformation)])}getExpected(){return globalThis.String(this.symbol)}},yn=class extends at{_tag="Literal";literal;constructor(e,t,n,r,o){super(t,n,r,o);if(typeof e==="number"&&!globalThis.Number.isFinite(e))throw Error(`A numeric literal must be finite, got ${K(e)}`);this.literal=e}getParser(){return xl(this,this.literal)}matchPart(e,t){return e===globalThis.String(this.literal)?this.literal:void 0}toCodecJson(){return typeof this.literal==="bigint"?jw(this):this}toCodecStringTree(){return typeof this.literal==="string"?this:jw(this)}getExpected(){return typeof this.literal==="string"?JSON.stringify(this.literal):globalThis.String(this.literal)}};function jw(e){let t=globalThis.String(e.literal);return Pe(e,[new Xe(new yn(t),new be(se(()=>e.literal),se(()=>t)))])}var oD=class extends at{_tag="String";getParser(){return Fr(this,ys)}matchPart(e,t){let n=this.checks;return n&&!t.disableChecks&&Dr(n,e,void 0,this,t)?void 0:e}getExpected(){return"string"}},$n=new oD,sD=class extends at{_tag="Number";getParser(){return Fr(this,Zw)}matchKey(e,t){return this._match(TD,e,t)}matchPart(e,t){return this._match(gg,e,t)}_match(e,t,n){if(!e.test(t))return;let r=globalThis.Number(t);if(n.disableChecks||!this.checks)return r;return Dr(this.checks,r,void 0,this,n)?void 0:r}toCodecJson(){if(this.checks&&(pg(this.checks,"effect/schema/isFinite")||pg(this.checks,"effect/schema/isInt")))return this;return Pe(this,[yD])}toCodecStringTree(){if(this.toCodecJson()===this)return Pe(this,[AD]);return Pe(this,[CD])}getExpected(){return"number"}};function pg(e,t){return e.some((n)=>n.annotations?.representation?.id===t||n._tag==="FilterGroup"&&pg(n.checks,t))}var Tg=new sD,aD=class extends at{_tag="Boolean";getParser(){return Fr(this,Qw)}getExpected(){return"boolean"}},lk=new aD,iD=class extends at{_tag="Symbol";getParser(){return Fr(this,Xw)}matchKey(e,t){if(t.disableChecks||!this.checks)return e;return Dr(this.checks,e,void 0,this,t)?void 0:e}toCodecStringTree(){return Pe(this,[Bk])}getExpected(){return"symbol"}},pk=new iD,cD=class extends at{_tag="BigInt";getParser(){return Fr(this,Yw)}matchPart(e,t){if(!xg.test(e))return;let n=globalThis.BigInt(e);if(t.disableChecks||!this.checks)return n;return Dr(this.checks,n,void 0,this,t)?void 0:n}toCodecStringTree(){return Pe(this,[OD])}getExpected(){return"bigint"}},mk=new cD,ar=class extends at{_tag="Arrays";isMutable;elements;rest;encodingChecks;constructor(e,t,n,r,o,s,a,i){super(r,o,s,a);this.isMutable=e,this.elements=t,this.rest=n,this.encodingChecks=i;let c=!1;for(let f=0;f<t.length;f++)if(Mt(t[f]))c=!0;else if(c)throw Error("A required element cannot follow an optional element. ts(1257)");if(c&&n.length>1)throw Error("A required element cannot follow an optional element. ts(1257)");for(let f=1;f<n.length;f++)if(Mt(n[f]))throw Error("An optional element cannot follow a rest element. ts(1266)")}getParser(e,t=e){let n=this,r,o,s=n.elements.length,a=Math.max(0,n.rest.length-1);function i(u,d){if(d<s)return r[d];else if(d>=u)return o[d-u+1];return o[0]}let c=(u)=>{let{input:d,len:l,options:m}=u;if(n.rest.length===0&&l>s)for(let p=s;p<l;p++){let g=new ma(n,d[p],m),h=new Qe([p],g);if(m.errors==="all")if(u.issues)u.issues.push(h);else u.issues=[h];else return _(new tt(n,[h],d,m))}if(u.issues)return _(new tt(n,u.issues,d,m));return Rt(u.output)},f=(u,d)=>{let l=u.length,m={ast:n,getParser:i,input:u,len:l,tailThreshold:Math.max(s,l-a),output:new globalThis.Array(l),issues:void 0,options:d},p=n.rest.length===0?s:Math.max(l,s+a),g=d.concurrency===void 0?1:ol(d.concurrency),h=g===1?uD(m,u,0,p):dD(m,u,{concurrency:g,end:p});if(!h)return c(m);if(qt(h))return Pt(h,()=>c(m));let E=!0;return M(()=>{if(!E)return f(u,d);return E=!1,A(h,()=>c(m))})};return(u,d)=>{if(u===ce)return Cn;try{if(!Array.isArray(u))return _(new Fe(n,u,d));if(!r)r=n.elements.map((l)=>({ast:l,parser:t(l)})),o=n.rest.map((l)=>({ast:l,parser:t(l)}));return f(u,d)}catch(l){return _n(l)}}}_rebuild(e,t,n){let r=xa(this.elements,e),o=xa(this.rest,e);return r===this.elements&&o===this.rest&&t===this.checks&&n===this.encodingChecks?this:new ar(this.isMutable,r,o,this.annotations,t,void 0,this.context,n)}recur(e){return this._rebuild(e,this.checks,this.encodingChecks)}flip(e){return this._rebuild(e,this.encodingChecks,this.checks)}getExpected(){return"array"}};function fD(e,t,n,r){if(n._tag==="Failure")return sl(e,e.ast,r,n);let o=n===Ce?t:n[gn];if(o!==ce)e.output[r]=o;else{let s=e.getParser(e.tailThreshold,r);if(Mt(s.ast))return;let a=new Qe([r],new ot(s.ast.context?.annotations));if(e.options.errors==="all")if(e.issues)e.issues.push(a);else e.issues=[a];else return So(new tt(e.ast,[a],e.input,e.options))}}var hk={onItem(e,t,n){let r=n<e.len?t:ce;return e.getParser(e.tailThreshold,n).parser(r,e.options)},step:fD},uD=fl()(hk),dD=ul()(hk),sl=(e,t,n,r)=>{if(r.cause.reasons.length===0)return r;let o=xf(r.cause);if(o===void 0)return en(Ts(r.cause,(a)=>new tt(t,[new Qe([n],a)],e.input,e.options)));let s=new Qe([n],o);if(e.options.errors==="all")if(e.issues)e.issues.push(s);else e.issues=[s];else return So(new tt(t,[s],e.input,e.options))},dl="[+-]?\\d*\\.?\\d+(?:[Ee][+-]?\\d+)?";function yo(e,t,n=jt){let r,o;function s(a){switch(a._tag){case"String":case"TemplateLiteral":return(r??=Object.keys(e)).filter((i)=>a.matchPart(i,n)!==void 0);case"Number":return(r??=Object.keys(e)).filter((i)=>a.matchKey(i,n)!==void 0);case"Symbol":return(o??=Object.getOwnPropertySymbols(e)).filter((i)=>Object.prototype.propertyIsEnumerable.call(e,i)&&a.matchKey(i,n)!==void 0);case"Union":return[...new Set(a.types.flatMap(s))];default:return[]}}return s(Dg(En(t)))}var Ag=class{name;type;constructor(e,t){this.name=e,this.type=t}};function gk(e){switch(e._tag){case"String":case"Number":case"Symbol":case"TemplateLiteral":return!0;case"Union":return e.types.every(gk);default:return!1}}function xk(e){let t=Oi(e);switch(t._tag){case"String":case"Number":case"Symbol":case"TemplateLiteral":return!0;case"Union":return t.types.every(xk);default:return!1}}function lD(e){return gk(e)&&xk(e)}var Cg=class{parameter;type;constructor(e,t){if(!lD(e))throw Error(`Invalid index signature parameter ${e._tag}`);if(this.parameter=e,this.type=t,Mt(t)&&!Uk(t))throw Error("Cannot use `Schema.optionalKey` with index signatures, use `Schema.optional` instead.")}},bf=class extends at{_tag="Objects";propertySignatures;indexSignatures;encodingChecks;constructor(e,t,n,r,o,s,a){super(n,r,o,s);this.propertySignatures=e,this.indexSignatures=t,this.encodingChecks=a}getParser(e,t=e){let n=this,r=n.propertySignatures.length,o=n.indexSignatures.length;if(!r&&!o)return Fr(n,cl);let s,a,i=()=>{if(!s)s=n.propertySignatures.map((d)=>({parser:t(d.type),name:d.name,type:d.type})),a=o?n.indexSignatures.map((d)=>({is:d,parserKey:e(Dg(d.parameter)),parserValue:t(d.type)})):void 0;return s},c=()=>{let d=new Set(n.propertySignatures.map((h)=>typeof h.name==="number"?globalThis.String(h.name):h.name)),l=(h,E,S,k,I)=>{if(I._tag==="Failure")return sl(h,n,E,I)??Ye;let x=I===Ce?k:I[gn];if(S!==ce&&x!==ce){if(r&&(d.has(E)||d.has(typeof S==="number"?globalThis.String(S):S)))return Ye;q(h.out,S,x)}return Ye},m=(h,E,S,k)=>{if(!k){let C=S.parserKey(E,h.options);if(!qt(C))return A(or(C),(T)=>m(h,E,S,T));k=C}if(k._tag==="Failure")return sl(h,n,E,k)??Ye;let I=k===Ce?E:k[gn],x=h.input[E],w=S.parserValue(x,h.options);return qt(w)?l(h,E,I,x,w):A(or(w),(C)=>l(h,E,I,x,C))},p=(h,E,S)=>{let k=h.input[E],I=S.parserValue(k,h.options);return qt(I)?l(h,E,E,k,I):A(or(I),(x)=>l(h,E,E,k,x))},g=o?ul()({onItem:(h,[E,S])=>S.is.parameter===$n?p(h,E,S):m(h,E,S),step:(h,E,S)=>S._tag==="Failure"?S:void 0}):void 0;return tk(function*(h,E){if(h===ce)return ce;if(!(typeof h==="object"&&h!==null&&!Array.isArray(h)))return yield*_(new Fe(n,h,E));i();let S=h,k={},I={ast:n,input:S,out:k,issues:void 0,options:E},x=E.errors==="all",w=E.onExcessProperty==="error",C=E.concurrency===void 0?1:ol(E.concurrency),T=o&&w?n.indexSignatures.map((v)=>yo(S,v.parameter,E)):void 0;if(w){let v=T?new Set(d):d;if(T)for(let U of T)for(let j of U)v.add(j);let O=Reflect.ownKeys(S);for(let U=0;U<O.length;U++){let j=O[U];if(!v.has(j)&&Object.prototype.propertyIsEnumerable.call(S,j)){let X=new ma(n,S[j],E),J=new Qe([j],X);if(x){if(I.issues)I.issues.push(J);else I.issues=[J];continue}else return yield*_(new tt(n,[J],h,E))}}}if(r){let v=C===1?Ww(I,s):pD(I,s,{concurrency:C});if(v)yield*v}if(o&&C===1)for(let v=0;v<o;v++){let O=a[v],U=O.is.parameter===$n?p:m,j=T?.[v]??(O.is.parameter===$n?Object.keys(S):yo(S,O.is.parameter,E));for(let X=0;X<j.length;X++){let J=U(I,j[X],O);if(!qt(J))yield*J;else if(J._tag==="Failure")return yield*J}}else if(g){let v=Xt();for(let U=0;U<o;U++){let j=a[U],X=T?.[U]??(j.is.parameter===$n?Object.keys(S):yo(S,j.is.parameter,E));for(let J=0;J<X.length;J++)v.push([X[J],j])}let O=g(I,v,{concurrency:C});if(O)yield*O}if(I.issues)return yield*_(new tt(n,I.issues,h,E));return k})};if(o)return c();let f,u=(d,l,m)=>{let p=s[l];return A(or(m),(g)=>{let h=mg(d,p,g);if(h)return h;let E=()=>Rt(d.out),S=Ww(d,s.slice(l+1));return S?Pt(S,E):E()})};return(d,l)=>{if(d===ce)return Cn;if(l.errors==="all"||l.onExcessProperty!==void 0||l.concurrency!==void 0&&ol(l.concurrency)!==1)return(f??=c())(d,l);if(!(typeof d==="object"&&d!==null&&!Array.isArray(d)))return _(new Fe(n,d,l));let m=i(),p=d,g={},h={ast:n,input:p,out:g,issues:void 0,options:l};try{for(let E=0;E<m.length;E++){let S=m[E],k=S.name,I=ki(p,k),x=I?p[k]:ce,w=S.parser(x,l);if(!qt(w))return u(h,E,w);if(w===Ce){if(I)q(g,k,x);continue}let C=mg(h,S,w);if(C)return C}}catch(E){return _n(E)}return Rt(g)}}_rebuild(e,t,n,r){let o=xa(this.propertySignatures,(a)=>{let i=e(a.type);return i===a.type?a:new Ag(a.name,i)}),s=xa(this.indexSignatures,(a)=>{let i=t(a.parameter),c=e(a.type);return i===a.parameter&&c===a.type?a:new Cg(i,c)});return o===this.propertySignatures&&s===this.indexSignatures&&n===this.checks&&r===this.encodingChecks?this:new bf(o,s,this.annotations,n,void 0,this.context,r)}flip(e){return this._rebuild(e,e,this.encodingChecks,this.checks)}recur(e,t=e){return this._rebuild(e,t,this.checks,this.encodingChecks)}getExpected(){if(this.propertySignatures.length===0&&this.indexSignatures.length===0)return"object | array";return"object"}};function mg(e,t,n){if(n._tag==="Failure")return sl(e,e.ast,t.name,n);if(n===Ce)return;let r=n[gn];if(r!==ce){q(e.out,t.name,r);return}if(delete e.out[t.name],!Mt(t.type)){let o=new Qe([t.name],new ot(t.type.context?.annotations));if(e.options.errors==="all"){if(e.issues)e.issues.push(o);else e.issues=[o];return}else return So(new tt(e.ast,[o],e.input,e.options))}}var yk={onItem(e,t){if(!ki(e.input,t.name))return t.parser(ce,e.options);let n=e.input[t.name];return q(e.out,t.name,n),t.parser(n,e.options)},step:mg},Ww=fl()(yk),pD=ul()(yk);function vg(e,t){if(!e)return t;if(!t)return e;return[...e,...t]}function ll(e,t,n){return new bf(Reflect.ownKeys(e).map((r)=>new Ag(r,e[r].ast)),[],n,t)}function If(e){return e.ast}function Og(e,t=void 0){return new ar(!1,e.map((n)=>n.ast),[],void 0,t)}function pl(e,t,n){return new tn(e.map(If),t,void 0,n)}function Sk(e,t){if(e.encoding||t.some((s)=>s.encoding))throw Error("StructWithRest does not support encodings");let{propertySignatures:n,indexSignatures:r,checks:o}=e;for(let s of t){for(let a of s.propertySignatures)if(n.some((i)=>i.name===a.name))throw Error(`Duplicate identifier: ${JSON.stringify(a.name)}. ts(2300)`);n=n.concat(s.propertySignatures),r=r.concat(s.indexSignatures),o=vg(o,s.checks)}return new bf(n,r,void 0,o)}function Ek(e,t){if(e.encoding)throw Error("TupleWithRest does not support encodings");return new ar(e.isMutable,e.elements,t,void 0,e.checks)}function bk(e){if(e.encoding)throw Error("mutable does not support encodings");return new ar(!0,e.elements,e.rest,e.annotations,e.checks,void 0,e.context,e.encodingChecks)}var _g=ya((e)=>{while(!0){if(rk(e))return jo;let t=e.encoding;if(!t)return e.recur?.(_g,Q)??e;if(t.some((n)=>n.transformation._tag==="Middleware"&&n.transformation.decode!==Q))return jo;e=t[t.length-1].to}});function Ik(e){switch(e._tag){case"Null":return["null"];case"Undefined":return["undefined"];case"String":case"TemplateLiteral":return["string"];case"Number":return["number"];case"Boolean":return["boolean"];case"Symbol":case"UniqueSymbol":return["symbol"];case"BigInt":return["bigint"];case"Arrays":return["array"];case"ObjectKeyword":return["object","array","function"];case"Objects":return e.propertySignatures.length||e.indexSignatures.length?["object"]:["string","number","boolean","symbol","bigint","object","array","function"];case"Enum":return Array.from(new Set(e.enums.map(([,t])=>typeof t)));case"Literal":return[typeof e.literal];case"Union":return Array.from(new Set(e.types.flatMap(Ik)));default:return["null","undefined","string","number","boolean","symbol","bigint","object","array","function"]}}function ks(e){switch(e._tag){default:return[];case"Declaration":{let t=e.annotations?.[uf];return Array.isArray(t)?t:[]}case"Objects":return e.propertySignatures.flatMap((t)=>{let n=t.type;if(!Mt(n)){if(Ti(n))return[{key:t.name,literal:n.literal}];if(dg(n))return[{key:t.name,literal:n.symbol}]}return[]});case"Arrays":return e.elements.flatMap((t,n)=>{if(!Mt(t)){if(Ti(t))return[{key:n,literal:t.literal}];if(dg(t))return[{key:n,literal:t.symbol}]}return[]});case"Union":{if(e.types.length===0)return[];let t=e.types.map((n)=>ks(_g(n)));return t[0].filter((n)=>t.every((r)=>r.some((o)=>o.key===n.key&&o.literal===n.literal)))}case"Suspend":return ks(e.thunk())}}var Jw=new WeakMap,nl=Object.freeze([]),Gw=(e)=>e===null?"null":Array.isArray(e)?"array":typeof e,ki=(e,t)=>t==="__proto__"?Object.hasOwn(e,t):(t in e);function wf(e){let t=Jw.get(e);if(t)return t;let n,r=0,o,s,a=!0,i=[];for(let u=0;u<e.length;u++){let d=e[u],l=_g(d);if(VF(l))continue;if(Ti(l)||dg(l)){s??=new Map;let p=Ti(l)?l.literal:l.symbol;i[u]=p;let g=s.get(p);if(!g)s.set(p,g=[]);g.push(u)}else a=!1;let m=ks(l);if(m.length){n??=new Map,r++;for(let{key:p,literal:g}of m){let h=n.get(p);if(!h)n.set(p,h=[new Map,new Set]);h[1].add(u);let E=h[0].get(g);if(!E)h[0].set(g,E=new Set);E.add(u)}}else{o??={};let p=Ik(l);for(let g of p)(o[g]??=[]).push(u)}}let c={},f=(u)=>c[u]??=Object.freeze(o?.[u]??nl);if(a&&s)s.forEach(Object.freeze),t=(u)=>s.get(u)??nl;else if(n?.size===1&&!o){let[u,[d]]=n.entries().next().value,l=new Map;for(let[p,g]of d)l.set(p,Object.freeze(Array.from(g)));let m=Object.freeze(e.map((p,g)=>g));t=(p,g)=>{if(rl(p)){let h=ki(p,u)?p[u]:void 0;if(h!==void 0)return l.get(h)??nl;if(g)return m}return nl}}else if(n){let u;for(let d of n)if((!u||d[1][0].size>u[1][0].size)&&d[1][1].size===r)u=d;t=(d,l)=>{let m=Gw(d);if(!rl(d))return f(m);let p=new Set(o?.[m]),g;if(u){let[h,[E]]=u,S=ki(d,h),k=S?d[h]:void 0;if(S&&(!l||k!==void 0)){let I=E.get(k);if(!I)return f(m);for(let x of I)p.add(x);g=h}}if(g===void 0)for(let[h,[E,S]]of n){let k=ki(d,h),I=k?d[h]:void 0;if(k&&(!l||I!==void 0)){let x=E.get(I);if(x)for(let w of x)p.add(w)}else if(l)for(let x of S)p.add(x)}for(let[h,[E,S]]of n){if(h===g)continue;let k=ki(d,h),I=k?d[h]:void 0;if(k&&(!l||I!==void 0)){let x=E.get(I);for(let w of p)if(S.has(w)&&!x?.has(w))p.delete(w)}}return Array.from(p).sort((h,E)=>h-E)}}else t=(u)=>{let d=f(Gw(u));return s?d.filter((l)=>i[l]===void 0||i[l]===u):d};return Jw.set(e,t),t}var tn=class extends at{_tag="Union";types;options;encodingChecks;constructor(e,t,n,r,o,s,a){super(n,r,o,s);this.types=e,this.options=t,this.encodingChecks=a}getParser(e,t){let n=this,r=t!==void 0,o=[],s=(i)=>o[i]??=e(n.types[i]),a;return(i,c)=>{if(i===ce)return Cn;let f=(a??=wf(n.types))(i,r);if(f.length===0)return _(new gf(n,[],i,c));if(f.length===1){let u=s(f[0])(i,c);if(u._tag==="Success")return u;return qt(u)?wk(n,u.cause,i,c):mD(n,u,i,c)}return hD(n,s,f,i,c)}}_rebuild(e,t,n){let r=xa(this.types,e);return r===this.types&&t===this.checks&&n===this.encodingChecks?this:new tn(r,this.options,this.annotations,t,void 0,this.context,n)}recur(e){return this._rebuild(e,this.checks,this.encodingChecks)}flip(e){return this._rebuild(e,this.encodingChecks,this.checks)}matchPart(e,t){for(let n of this.types){let r=n.matchPart(e,t);if(r!==void 0)return r}return}getExpected(e){let t=this.annotations?.expected;if(typeof t==="string")return t;if(this.types.length===0)return"never";let n=this.types.map((r)=>{let o=En(r);switch(o._tag){case"Arrays":{let s=o.elements.filter(Ti);if(s.length>0)return`${Kw(o.isMutable)}[ ${s.map((a)=>e(a)+Vw(a.context?.isOptional)).join(", ")}, ... ]`;break}case"Objects":{let s=o.propertySignatures.filter((a)=>Ti(a.type));if(s.length>0)return`{ ${s.map((a)=>`${Kw(a.type.context?.isMutable)}${Sa(a.name)}${Vw(a.type.context?.isOptional)}: ${e(a.type)}`).join(", ")}, ... }`;break}}return e(o)});return Array.from(new Set(n)).join(" | ")}};function wk(e,t,n,r){let o=xf(t);if(!o)return en(t);return So(new gf(e,[o],n,r))}function mD(e,t,n,r){return De(t,(o)=>wk(e,o,n,r))}function hD(e,t,n,r,o){let s={ast:e,parser:t,input:r,out:void 0,successes:e.options?.mode==="oneOf"?[]:void 0,issues:void 0,options:o},a=xD(s,n);if(!a){if(s.out)return s.out;return _(new gf(e,s.issues??[],r,o))}return gD(a,s)}function gD(e,t){return Pt(e,(n)=>{if(t.out===Ce)return b(t.input);if(t.out)return t.out;return _(new gf(t.ast,t.issues??[],t.input,t.options))})}var xD=fl()({onItem(e,t){return e.parser(t)(e.input,e.options)},step(e,t,n){if(n._tag==="Failure"){let r=xf(n.cause);if(r===void 0)return n;if(e.issues)e.issues.push(r);else e.issues=[r]}else{if(e.out&&e.successes)return e.successes.push(e.ast.types[t]),So(new FI(e.ast,e.successes,e.input,e.options));if(e.out=n,e.successes)e.successes.push(e.ast.types[t]);else return Ye}}}),kk=new tn([new yn("Infinity"),new yn("-Infinity"),new yn("NaN")]);function Kw(e){return e?"":"readonly "}function Vw(e){return e?"?":""}var Rg=class extends at{_tag="Suspend";thunk;constructor(e,t,n,r,o){if(n)throw Error("Cannot add checks to Suspend");super(t,void 0,r,o);let s;this.thunk=()=>s??=e()}getParser(e){let t;return(n,r)=>(t??=e(this.thunk()))(n,r)}recur(e){return new Rg(()=>e(this.thunk()),this.annotations,void 0,void 0,this.context)}getExpected(e){return e(this.thunk())}},al=class extends Ei{_tag="Filter";run;annotations;aborted;constructor(e,t=void 0,n=!1){super();this.run=e,this.annotations=t,this.aborted=n}annotate(e){return new al(this.run,{...this.annotations,...e},this.aborted)}abort(){return new al(this.run,this.annotations,!0)}and(e,t){return new ga([this,e],t)}},ga=class extends Ei{_tag="FilterGroup";checks;annotations;constructor(e,t=void 0){super();this.checks=e,this.annotations=t}annotate(e){return new ga(this.checks,{...this.annotations,...e})}and(e,t){return new ga([this,e],t)}};function ml(e,t,n=!1){return new al((r,o,s)=>NI(o,e(r,o,s),r,s),t,n)}function hl(e,t){return new al((n,r,o)=>e(n)?void 0:new te(void 0,n,o),t,!0)}function Pg(e){return ml((t)=>globalThis.Number.isFinite(t),{expected:"a finite number",representation:{id:"effect/schema/isFinite",payload:null},toJsonSchema:()=>({type:"number"}),toCode:()=>({runtime:"Schema.isFinite()"}),arbitraryConstraint:{number:"finite"},...e})}var Mg=Eo(Tg,[Pg()]),yD=new Xe(new tn([Mg,kk]),new be(Jd(),se((e)=>globalThis.Number.isFinite(e)?e:globalThis.String(e))));function kf(e,t){let n=new globalThis.RegExp(e),r={source:n.source,flags:n.flags};return ml((o)=>(n.lastIndex=0,n.test(o)),{expected:`a string matching the RegExp ${r.source}`,representation:{id:"effect/schema/isPattern",payload:r},toJsonSchema:()=>[{},!0],arbitraryConstraint:{patterns:[r]},...t})}var hg=new WeakMap;function Tf(e,t){let n=Object.assign(Object.create(Object.getPrototypeOf(e)),e,t);if(Reflect.ownKeys(t).every((r)=>r==="context"||r==="encoding"))hg.set(n,vi(e));return n}function vi(e){let t=hg.get(e);if(t!==void 0)return t;if(e.encoding===void 0)return e;let n=Object.assign(Object.create(Object.getPrototypeOf(e)),e,{encoding:void 0});return hg.set(e,n),n}function Pe(e,t){return e.encoding===t?e:Tf(e,{encoding:t})}function Ea(e,t){if(e.context===t)return e;let n=vi(e);if(n.context===t&&n.encoding===e.encoding)return n;return Tf(e,{context:t})}function Oi(e){return e.encoding?Oi(e.encoding[e.encoding.length-1].to):e}function Ur(e,t){if(e.checks){let n=e.checks[e.checks.length-1];return Tk(e,Md(e.checks.slice(0,-1),n.annotate(t)))}return Tf(e,{annotations:{...e.annotations,...t}})}function Tk(e,t){if(e._tag==="Suspend"&&t)throw Error("Cannot add checks to Suspend");if(e.checks===t)return e;return Tf(e,{checks:t})}function Eo(e,t){return Tk(e,vg(e.checks,t))}function vs(e,t){let n=t(e.to);return n===e.to?e:new Xe(n,e.transformation)}function Ak(e,t){let n=e,r=n[n.length-1],o=vs(r,t);return o===r?e:Md(e.slice(0,e.length-1),o)}function gl(e){return(t)=>t.encoding?Pe(t,Ak(t.encoding,e)):t}function _i(e,t){return gl((n)=>Ea(n,t))(e)}function Wo(e,t){function n(r){if(r.encoding){let o=r.encoding[r.encoding.length-1];return t?.stopAt?.(o)?r:Pe(r,Ak(r.encoding,n))}return e(r)}return ya(n)}function Ck(e,t){return Ug(e,t,Ve(e))}function vk(e,t){return Ug(En(e),t,e)}function Ug(e,t,n){let r=new Xe(e,t);return Pe(n,n.encoding?[...n.encoding,r]:[r])}function xa(e,t){let n;for(let r=0;r<e.length;r++){let o=e[r],s=t(o);if(n)n[r]=s;else if(s!==o){n=Array(e.length);for(let a=0;a<r;a++)n[a]=e[a];n[r]=s}}return n??e}function Ri(e,t){let n=e.context?new sr(e.context.isOptional,e.context.isMutable,e.context.constructorDefault,{...e.context.annotations,...t}):new sr(!1,!1,void 0,t);return Ea(e,n)}var ba=ya((e)=>{let t=e.context?e.context.isOptional===!1?new sr(!0,e.context.isMutable,e.context.constructorDefault,e.context.annotations):e.context:new sr(!0,!1);return SD(Ea(e,t))}),SD=gl(ba),Ok=Ln((e)=>ba(new tn([e,Ig]))),Fg=ya((e)=>{let t=e.context?e.context.isMutable===!1?new sr(e.context.isOptional,!0,e.context.constructorDefault,e.context.annotations):e.context:new sr(!1,!0);return ED(Ea(e,t))}),ED=gl(Fg);function _k(e,t){let n=e.context?new sr(e.context.isOptional,e.context.isMutable,t,e.context.annotations):new sr(!1,!1,t);return Ea(e,n)}function Pi(e,t,n){return Ug(e,n,t)}function bD(e){let t=[],n=[];function r(o){switch(o._tag){case"Literal":if(il(o.literal)&&!t.includes(o.literal))t.push(o.literal);return;case"UniqueSymbol":if(!t.includes(o.symbol))t.push(o.symbol);return;case"Never":return;case"Union":for(let s=0;s<o.types.length;s++)r(o.types[s]);return;default:n.push(o)}}return r(e),{literals:t,parameters:n}}function Rk(e,t){let{literals:n,parameters:r}=bD(e);return new bf(n.map((o)=>new Ag(o,t)),r.map((o)=>new Cg(o,t)))}function Mt(e){return e.context?.isOptional??!1}function Pk(e){return e.context?.isMutable??!1}function Mk(e){return e.annotations?.[An]===!0||e._tag==="FilterGroup"&&e.checks.every(Mk)}function ID(e){function t(r){if(Mk(r))return[r];return r._tag==="FilterGroup"?r.checks.flatMap(t):[]}let n=e.flatMap(t);return Sn(n)?n:void 0}function wD(e){let t=!0;function n(r){if(t=t&&!r.encoding&&!rk(r),t&&"recur"in r)r.recur(n);return r}if("recur"in e)e.recur(n);return t}var Ve=ya((e)=>{let t=vi(e);if(t!==e){let r=Ve(t);return r===t&&e.encoding===void 0?e:Ea(r,e.context)}let n="recur"in e?e.recur(Ve):e;if("encodingChecks"in n&&n.encodingChecks){let r=wD(e)?n.encodingChecks:Eg(n)||ZF(n)||Ci(n)&&n.typeParameters.length>0?ID(n.encodingChecks):void 0;return Tf(n,{encodingChecks:void 0,checks:vg(n.checks,r)})}return n}),En=ya((e)=>Ve(qn(e)));function kD(e,t){let n=t,r=n.length,o=n[r-1],s=[new Xe(qn(Pe(e,void 0)),n[0].transformation.flip())];for(let i=1;i<r;i++)s.unshift(new Xe(qn(n[i-1].to),n[i].transformation.flip()));let a=qn(o.to);if(a.encoding)return Pe(a,[...a.encoding,...s]);else return Pe(a,s)}var qn=Ln((e)=>{if(e.encoding)return kD(e,e.encoding);let t=vi(e);if(t!==e){let n=qn(t);return n===t?e:Ea(n,e.context)}return"flip"in e?e.flip(qn):("recur"in e)?e.recur(qn):e});function Uk(e){switch(e._tag){case"Undefined":return!0;case"Union":return e.types.some(Uk);default:return!1}}function xl(e,t){let n=t===0?Ce:Rt(t);return(r,o)=>{if(r===ce)return Cn;if(r===t)return n;return _(new Fe(e,r,o))}}function Fr(e,t){return(n,r)=>{if(n===ce)return Cn;if(t(n))return Ce;return _(new Fe(e,n,r))}}function Fk(e,t,n){let{encodedParts:r,literals:o}=e,s=t.length;for(let f=0;f<o.length;f++){let u=o[f];if(u&&!t.includes(u))return}if(e.suffixLengths[0]>s)return;let a=Array(r.length),i;function c(f,u){if(f===r.length)return u===s;if(i?.has(f*(s+1)+u))return!1;let d=r[f];if(f===r.length-1){let l=t.slice(u);if(d.matchPart(l,n)!==void 0)return a[f]=l,!0}else if(d._tag==="Literal"){let l=o[f];if(t.startsWith(l,u)&&c(f+1,u+l.length))return a[f]=l,!0}else{let l=s-e.suffixLengths[f+1],m=o[f+1],p=m===void 0?l:t.lastIndexOf(m,l);while(p>=u){let g=t.slice(u,p);if(d.matchPart(g,n)!==void 0&&c(f+1,p))return a[f]=g,!0;if(p===0)break;p=m===void 0?p-1:t.lastIndexOf(m,p-1)}}return i??=new Set,i.add(f*(s+1)+u),!1}return c(0,0)?a:void 0}var Dg=Wo((e)=>{switch(e._tag){default:return e;case"Number":return e.toCodecStringTree();case"Union":return e.recur(Dg)}}),yl=Wo((e)=>{switch(e._tag){default:return e;case"Symbol":case"UniqueSymbol":return e.toCodecStringTree();case"Union":return e.recur(yl)}}),Ng=Wo((e)=>{switch(e._tag){default:return e;case"Number":case"Literal":case"BigInt":return e.toCodecStringTree();case"Union":return e.recur(Ng)}}),Dk="[\\s\\S]*?",gg=new globalThis.RegExp(`^${dl}$`),TD=new globalThis.RegExp(`^(?:${dl}|Infinity|-Infinity|NaN)$`);function Bg(e){return kf(gg,{expected:"a string representing a finite number",representation:{id:"effect/schema/isStringFinite",payload:null},toJsonSchema:()=>({pattern:gg.source}),...e})}var Nk=Eo($n,[Bg()]),AD=new Xe(Nk,wi),CD=new Xe(new tn([Nk,kk]),wi),vD="-?\\d+",xg=new globalThis.RegExp(`^${vD}$`);function Lg(e){return kf(xg,{expected:"a string representing a bigint",representation:{id:"effect/schema/isStringBigInt",payload:null},toJsonSchema:()=>({pattern:xg.source}),...e})}var zg=Eo($n,[Lg({expected:"a string representing a bigint"})]),OD=new Xe(zg,el),_D="Symbol\\(([\\s\\S]*)\\)",yg=new globalThis.RegExp(`^${_D}$`),RD=Eo($n,[$g()]),Bk=new Xe(RD,new be(se((e)=>globalThis.Symbol.for(yg.exec(e)[1])),$t((e,t)=>{if(globalThis.Symbol.keyFor(e)!==void 0)return b(globalThis.String(e));return _(new hf({message:"cannot serialize to string, Symbol is not registered"},e,t))})));function $g(e){return kf(yg,{expected:"a string representing a symbol",representation:{id:"effect/schema/isStringSymbol",payload:null},toJsonSchema:()=>({pattern:yg.source}),...e})}function Dr(e,t,n,r,o){for(let s=0;s<e.length;s++){let a=e[s];if(a._tag==="FilterGroup"){if(n=Dr(a.checks,t,n,r,o),n&&(o.errors!=="all"||n[n.length-1].filter.aborted))return n}else{let i=a.run(t,r,o);if(i){let c=new MI(a,i,t,o);if(n)n.push(c);else n=[c];if(o.errors!=="all"||a.aborted)return n}}}return n}function Lk(e,t){let n=Dr(e,t,void 0,jo,{errors:"all"});if(n){let r=new tt(jo,n);return ge(r)}return ue(t)}function zk(e){if(!Ci(e))return;let t=e.annotations?.[Dd];return On(t)?t(e.typeParameters):void 0}function PD(e){return e===null||typeof e==="string"||typeof e==="boolean"||typeof e==="number"&&globalThis.Number.isFinite(e)}function MD(e){return e===void 0||typeof e==="string"}function $k(e,t){let n=new WeakMap,r=[];e:while(!0){if(typeof e!=="object"||e===null){if(!t(e))return!1}else{let o=e,s=n.get(o);if(s===!1)return!1;if(s===void 0){let a=Array.isArray(o);if(!a){let i=Object.getPrototypeOf(o);if(i!==null&&i!==Object.prototype&&Object.getPrototypeOf(i)!==null)return!1}n.set(o,!1),r.push({value:o,keys:a?o.length:Object.keys(o),index:0})}}while(r.length>0){let o=r[r.length-1],s=o.keys;if(typeof s==="number"){if(o.index<s){e=o.value[o.index++];continue e}}else if(o.index<s.length){e=o.value[s[o.index++]];continue e}n.set(o.value,!0),r.pop()}return!0}}function Mi(e){return $k(e,PD)}var Ai=new Cs([],()=>(e,t,n)=>Mi(e)?Ce:_(new Fe(t,e,n)),{representation:{id:"effect/schema/Json",payload:null},expected:"JSON value",toCodecJson:()=>{return},toCodecStringTree:()=>Hg}),qk=Ur(Ai,{representation:{id:"effect/schema/MutableJson",payload:null}}),qg=new Xe(Ai,Ii()),Hk=new Xe(new tn([new ar(!1,[],[Ai]),new bf([],[new Cg($n,Ai)])]),Ii());function UD(e){return $k(e,MD)}var FD=new Cs([],()=>(e,t,n)=>UD(e)?Ce:_(new Fe(t,e,n)),{expected:"StringTree",toCodecStringTree:()=>{return}}),Hg=new Xe(FD,Ii());var Sl=(e,t,n)=>e===Ce?n(t):Pt(e,n);function Wk(e){if(e._tag==="Middleware")return(n,r,o)=>{let s=n===Ce?e.decode(Rt(lf(r)),o):e.decode(qd(n,lf),o);return jk(s)};let t=e.decode;switch(t._tag){case"Passthrough":return(n,r)=>n===Ce?Rt(r):n;case"Transform":{let n=(r)=>r===ce?Cn:Rt(t.transform(r));return(r,o)=>Sl(r,o,n)}case"TransformOptional":{let n=(r)=>Vh(t.transform(lf(r)));return(r,o)=>Sl(r,o,n)}case"TransformEffect":return(n,r,o)=>Sl(n,r,(s)=>s===ce?Cn:t.transform(s,o));case"TransformOptionalEffect":return(n,r,o)=>Sl(n,r,(s)=>jk(t.transform(lf(s),o)))}}var jk=(e)=>Pt(e,Vh),Jk=(e,t,n,r)=>De(r,(o)=>Os(()=>Ts(o,(s)=>new UI(e,s,t,n))));function DD(e,t){let n=Wk(e.link.transformation),r;return(o,s)=>{if(o===ce)return Cn;if(e.isConstructed(o))return Ce;let a=(r??=t(e.link.to))(o,s);return n(a,o,s)}}function ND(e,t){let n=e.context.constructorDefault;return(r,o)=>{if(r!==ce&&r!==void 0)return t(r,o);let s=n;if(qt(s)&&s._tag==="Success"){let a=t(s[gn],o);return a===Ce?s:a}return Pt(Jk(e,r,o,s),(a)=>{let i=t(a,o);return i===Ce?Rt(a):i})}}function jg(e,t){let n=t(e);return e.context?.constructorDefault===void 0?n:ND(e,n)}function Af(e,t,n,r,o){if(e._tag==="Declaration")for(let p of e.typeParameters)t(p);let s=n?zk(e):void 0,a=s?DD(s,t):r??e.getParser(t,n),i=e.checks,c=e.encoding,f=c?.map((p)=>Wk(p.transformation)),u=e.encodingChecks;if(!c&&!i&&!u)return a;let d,l=(p,g)=>{let h=a(p,g);if(u&&!g.disableChecks)if(qt(h)){if(h._tag==="Success"){let E=h===Ce?p:h[gn];if(p!==ce&&E!==ce){let S=Dr(u,p,void 0,e,g);if(S)h=_(new tt(e,S,p,g))}}}else h=A(h,(E)=>{if(p!==ce&&E!==ce){let S=Dr(u,p,void 0,e,g);if(S)return _(new tt(e,S,p,g))}return b(E)});if(i&&!g.disableChecks)if(qt(h)){if(h._tag==="Success"){let E=h===Ce?p:h[gn];if(E===ce)return h;let S=Dr(i,E,void 0,e,g);if(S)h=_(new tt(e,S,E,g))}}else h=A(h,(E)=>{if(E!==ce){let S=Dr(i,E,void 0,e,g);if(S)return _(new tt(e,S,E,g))}return b(E)});return h},m=o===void 0?l:o(l);if(!c)return m;return(p,g)=>{let h=d??=c.map((k)=>t(k.to)),E=p,S=h[h.length-1](p,g);for(let k=c.length-1;k>=0;k--)if(S=f[k](S,E,g),k!==0){let I=h[k-1];if(S._tag==="Success")E=S[gn],S=I(E,g);else S=Pt(S,(x)=>{let w=I(x,g);return w===Ce?Rt(x):w})}if(S._tag==="Success"){let k=S[gn],I=m(k,g);return I===Ce?S:I}return S=Jk(e,p,g,S),Pt(S,(k)=>{let I=m(k,g);return I===Ce?Rt(k):I})}}var bl=Symbol(),Gk=new WeakMap,Kk,Ui=!1;var LD=(e)=>Ui?El(Hn,e,"parser"):Hn(e).parser,Vk=(e)=>Ui?El(Hn,e,"makeEffect"):Hn(e).makeEffect,zD=(e)=>jg(e,Vk);class Wg{ast;constructor(e){this.ast=e}get decodeEffect(){return this.cachedDecodeEffect??=Af(this.ast,LD)}get parser(){return this.decodeEffect}get makeEffect(){return this.cachedMakeEffect??=Af(this.ast,Vk,zD)}}class Zk extends Wg{compiled;resolve;constructor(e,t,n){super(e);this.compiled=t,this.resolve=n}save(e,t){return Object.defineProperty(this,e,{value:t}),t}operation(e){let t=this.compiled;return typeof t==="function"?t(this.ast,this.resolve,e):t?.[e]}get is(){return this.save("is",this.operation("is"))}get decode(){return this.save("decode",this.operation("decode"))}get make(){return this.save("make",this.operation("make"))}get decodeEffect(){return this.save("decodeEffect",this.operation("decodeEffect")??Af(this.ast,(e)=>El(this.resolve,e,"parser")))}get parser(){let e=this.decode;return e===void 0?this.decodeEffect:this.save("parser",$D(e,()=>this.decodeEffect))}get makeEffect(){let e=this.operation("makeEffect");if(e!==void 0)return this.save("makeEffect",e);let t=(n)=>El(this.resolve,n,"makeEffect");return this.save("makeEffect",Af(this.ast,t,(n)=>jg(n,t)))}}function $D(e,t){let n;return(r,o)=>{if(r!==ce)try{let s=e(r,o);if(s!==bl)return s===r?Ce:Rt(s)}catch(s){return _n(s)}return(n??=t())(r,o)}}function El(e,t,n){let r=e(t);if(r.compiled===void 0||Object.hasOwn(r,n))return r[n];let o;return(s,a)=>(o??=r[n])(s,a)}function Hn(e){let t=Gk.get(e);if(t!==void 0)return t;let n=Kk===void 0?new Wg(e):new Zk(e,Kk(e,Hn),Hn);return Gk.set(e,n),n}function Kg(e){let t=e.ast,n;return(r,o)=>(n??=tx(ZD,Ve(t)))(r,o?.disableChecks?o?.parseOptions?{...o.parseOptions,disableChecks:!0}:{disableChecks:!0}:o?.parseOptions)}function wl(e){let t=Kg(e);return(n,r)=>{let o=Jo(t(n,r));if($e(o))return oe(o.value);return zn(o.cause,"Option adapter can only return none for schema issues"),ne()}}function kl(e){return KD(Ve(e.ast))}function Vg(e){return Cf(e.ast)}function HD(e){if(!Ui){let o=Di(Cl(e));return(s)=>{let a=o(s,jt);if($e(a))return!0;return zn(a.cause,"Type guard adapter can only return false for schema issues"),!1}}let t=Hn(e),n=t.is;if(n!==void 0)return(o)=>{try{return n(o,jt)}catch(s){return zn(Fi(s),"Type guard adapter can only return false for schema issues"),!1}};let r=t.parser;return(o)=>{let s=Jo(ex(r(o,jt),o));if($e(s))return!0;return zn(s.cause,"Type guard adapter can only return false for schema issues"),!1}}function Cf(e){let t=Ve(e),n=(r)=>(n=HD(t),n(r));return(r)=>n(r)}function Qk(e){let t=Cl(e);return(n,r)=>{let o=Jo(t(n,r));if($e(o))return;return zn(o.cause,"Issue adapter can only return schema issues")}}function Yk(e,t){let n=Ve(e.ast),r=Hn(n).parser(t,jt),o=Jo(ex(r,t));if(bo(o)){let s=zn(o.cause,"Assertion adapter can only throw schema issues");throw Error("Schema validation failed",{cause:s})}}function qe(e,t){let n=Cl(e.ast);return t===void 0?n:(r,o)=>n(r,Xg(t,o))}var Zg=qe;function Xk(e,t){return Di(qe(e,t))}function Qg(e,t){return a0(qe(e,t))}var e0=Qg;function t0(e,t){return i0(qe(e,t))}function jD(e,t){return Ui?c0(e.ast,t):nx(qe(e,t))}var Tl=jD;function Ia(e,t){let n=Cl(qn(e.ast));return t===void 0?n:(r,o)=>n(r,Xg(t,o))}var n0=Ia;function r0(e,t){return Di(Ia(e,t))}function Yg(e,t){return a0(Ia(e,t))}var o0=Yg;function s0(e,t){return i0(Ia(e,t))}function WD(e,t){return Ui?c0(qn(e.ast),t):nx(Ia(e,t))}var Al=WD,Xg=(e,t)=>t?{...e,...t}:e,Il=(e)=>{if(e===ce)return _(new te);return b(e)};function Cl(e){return tx(VD,e)}function ex(e,t){if(e===Ce)return b(t);if(!qt(e))return Pt(e,Il);return e[gn]===ce?Il(ce):e}function tx(e,t){let n;return(r,o)=>{let s=(n??=e(t))(r,o??jt);if(s===Ce)return b(r);if(!qt(s))return Pt(s,Il);return s[gn]===ce?Il(ce):s}}function Di(e){return(t,n)=>Jo(e(t,n))}function a0(e){let t=Di(e);return(n,r)=>{let o=t(n,r);if($e(o))return oe(o.value);return zn(o.cause,"Option adapter can only return none for schema issues"),ne()}}function i0(e){let t=Di(e);return(n,r)=>{let o=t(n,r);if($e(o))return ue(o.value);return ge(zn(o.cause,"Result adapter can only return schema issues"))}}function c0(e,t){let n;return(r,o)=>(n??=JD(Hn(e),t))(r,o)}function JD(e,t){let n=e.decode,r,o=n===void 0?(s,a=jt)=>(r??=Jg(e))(s,a):(s,a=jt)=>{if(s===ce)return(r??=Jg(e))(s,a);let i;try{i=n(s,a)}catch(c){throw zn(Fi(c),"Sync adapter can only throw schema issues"),c}if(i!==bl)return i;return(r??=Jg(e))(s,a)};return t===void 0?o:(s,a)=>o(s,Xg(t,a))}function Jg(e){return nx(tx(()=>e.decodeEffect,e.ast))}function nx(e){let t=Di(e);return(n,r)=>{let o=t(n,r);if($e(o))return o.value;let s=zn(o.cause,"Sync adapter can only throw schema issues");throw Error("Schema validation failed",{cause:s})}}function GD(e,t){let n=Jo(e);if($e(n))return n.value;let r=zn(n.cause,t);throw Error("Schema validation failed",{cause:r})}function KD(e){let t,n;return(r,o)=>{t??=Hn(e);let s=o?.disableChecks?o.parseOptions?{...o.parseOptions,disableChecks:!0}:{disableChecks:!0}:o?.parseOptions??jt,a=t.make;if(a!==void 0&&r!==ce){let c;try{c=a(r,s)}catch(f){throw zn(Fi(f),"Constructor adapter can only throw schema issues"),f}if(c!==bl&&c!==ce)return c}let i=(n??=t.makeEffect)(r,s);return GD(ex(i,r),"Constructor adapter can only throw schema issues")}}var VD=(e)=>Hn(e).parser,ZD=(e)=>Hn(e).makeEffect;var vl="~effect/Schema/Schema",f0=Symbol(),QD={[vl]:vl,get make(){let e=kl(this);return Object.defineProperty(this,"make",{value:e,enumerable:!0}),e},get makeEffect(){let e=Kg(this);return Object.defineProperty(this,"makeEffect",{value:e,enumerable:!0}),e},get makeOption(){let e=wl(this);return Object.defineProperty(this,"makeOption",{value:e,enumerable:!0}),e},pipe(){return de(this,arguments)},annotate(e){return this.rebuild(Ur(this.ast,e))},annotateKey(e){return this.rebuild(Ri(this.ast,e))},check(...e){return this.rebuild(Eo(this.ast,e))},rebuild(e){return Nr(e,this[f0])}};function Nr(e,t){function n(){}let r=Object.setPrototypeOf(n,QD);if(t&&(Object.hasOwn(t,"name")||Object.hasOwn(t,"length")||Object.hasOwn(t,"__proto__")))Object.defineProperties(r,Object.getOwnPropertyDescriptors({...t}));else Object.assign(r,t);return r[f0]=t,r.ast=e,r}function rx(e){return e.replace(/~/g,"~0").replace(/\//g,"~1")}function vf(e){return e.replace(/~1/g,"/").replace(/~0/g,"~")}function ox(e){return encodeURI(rx(e)).replace(/#/g,"%23")}function sx(e){if(e.length===0||e==="#")return"";if(!e.startsWith("#"))return;let t=e.slice(1);try{if(encodeURI(t).replace(/%25/g,"%").replace(/#/g,"%23")!==t)return;let n=decodeURIComponent(t);return n.startsWith("/")&&!/~(?:[^01]|$)/.test(n)?n:void 0}catch{return}}function d0(e){let t=sx(e);return t===void 0?void 0:t.length===0?[]:t.slice(1).split("/").map(vf)}function l0(e){return e.reduce((t,n)=>`${t}/${ox(n)}`,"#")}var YD="http://json-schema.org/draft-07/schema#",p0="https://json-schema.org/draft/2020-12/schema";function m0(e,t){return e===t||e===(t.endsWith("#")?t.slice(0,-1):`${t}#`)}function x0(e){return{dialect:"draft-07",...rN(e,pN)}}function XD(e,t){return n(e,!1,!0);function n(r,o,s=!1){if(!st(r))return r;let a=o||!s&&E0(r.$id),i={};for(let c of Object.keys(r)){let f=r[c],u=f;switch(c){case"$defs":case"properties":case"patternProperties":case"dependentSchemas":u=ix(f,(d)=>n(d,a))??f;break;case"allOf":case"anyOf":case"oneOf":case"prefixItems":u=Array.isArray(f)?f.map((d)=>n(d,a)):f;break;case"not":case"additionalProperties":case"propertyNames":case"unevaluatedProperties":case"items":case"contains":case"unevaluatedItems":case"if":case"then":case"else":case"contentSchema":u=n(f,a)}q(i,c,u)}return t(i,a),i}}function y0(e,t){return XD(e,(n)=>{eN(n,t)})}function eN(e,t){if(typeof e.$ref==="string")q(e,"$ref",t(e.$ref,"$ref"));if(typeof e.$dynamicRef==="string")q(e,"$dynamicRef",t(e.$dynamicRef,"$dynamicRef"))}function ix(e,t){if(!st(e))return;let n={};for(let r of Object.keys(e))q(n,r,t(e[r],r));return n}function tN(e,t,n){let r=new Map,o=[],s=ax;function a(l,m=[],p=[]){if(m.length===0&&t?.trackIds){let g=st(l)?u(l):void 0;s=h0(g,ax)??ax}return f(l,m,p,{sourceRoot:[],targetRoot:[],uri:s})}function i(){for(let[l,m,p]of o){let g=m,h=S0(m,p);if(h!==void 0){let E=d0(h.hash);if(h.hash="",E!==void 0){let S=r.get(g0(h.href,E));if(S!==void 0)g=nN(m,S)}}q(l,"$ref",g)}}let c=n(a);return i(),c;function f(l,m,p,g){if(typeof l==="boolean")return d(m,p,g),t?.booleanAdapter?.(l)??l;if(!st(l))return l;let h=g,E=u(l);if(m.length>0&&t?.trackIds&&E0(E)){let I=h0(E,g.uri);if(I!==void 0)h={parent:g,sourceRoot:m,targetRoot:p,uri:I}}d(m,p,h);let S=h.uri,k={isDocumentRoot:m.length===0,schema(I,x,w=x){return f(I,[...m,x],[...p,w],h)},schemaAt(I,x,w){return f(I,[...m,...x],[...p,...w],h)},schemaArray(I,x,w=x){return Array.isArray(I)?I.map((C,T)=>f(C,[...m,x,String(T)],[...p,w,String(T)],h)):I},schemaMap(I,x,w=x){if(!st(I))return I;return ix(I,(C,T)=>f(C,[...m,x,T],[...p,w,T],h))},reference(I,x){if(typeof x==="string")o.push([I,x,S]);else q(I,"$ref",x)}};return e(l,k)}function u(l){return t?.ignoreRefSiblings===!0&&typeof l.$ref==="string"?void 0:l.$id}function d(l,m,p){if(p.parent!==void 0)d(l,m,p.parent);r.set(g0(p.uri,l.slice(p.sourceRoot.length)),m.slice(p.targetRoot.length))}}var ax="https://effect.invalid/.json-schema/";function S0(e,t){return URL.canParse(e,t)?new URL(e,t):void 0}function h0(e,t){if(typeof e!=="string")return;let n=S0(e,t);if(n===void 0)return;return n.hash="",n.href}function nN(e,t){let n=e.indexOf("#");if(n===-1&&t.length===0)return e;return`${n===-1?e:e.slice(0,n)}${l0(t)}`}function g0(e,t){return`${e}\x00${JSON.stringify(t)}`}function E0(e){return typeof e==="string"&&e.length>0&&e[0]!=="#"}function rN(e,t,n){return tN(t,{...n,trackIds:!0},(r)=>({schema:r(e.schema),definitions:ix(e.definitions,(o,s)=>r(o,["$defs",s],["definitions",s]))}))}var oN=new Set(["properties","patternProperties"]),sN=new Set(["allOf","anyOf","oneOf"]),aN=new Set(["not","additionalProperties","propertyNames","contains","if","then","else","contentSchema"]);function iN(e,t,n,r,o,s=oN){let a;if(s.has(t))a=r.schemaMap(n,t);else if(sN.has(t))a=r.schemaArray(n,t);else if(o.has(t))a=r.schema(n,t);else return!1;return q(e,t,a),!0}var b0=["$anchor","$defs","$dynamicAnchor","$dynamicRef","$vocabulary","contentSchema","dependentRequired","dependentSchemas","maxContains","minContains","prefixItems","unevaluatedItems","unevaluatedProperties"],q8=[...b0,"deprecated"],H8=[...b0,"$comment","$id","$schema","const","contains","contentEncoding","contentMediaType","else","examples","if","patternProperties","propertyNames","then"],cN=/^[A-Za-z_][-A-Za-z0-9._]*$/,fN=/^[A-Za-z][-A-Za-z0-9._:]*$/;function wa(e,t,n){throw Error(`Cannot convert JSON Schema keyword "${e}" to ${t}: ${n}`)}function uN(e,t,n,r){for(let o of t)if(Object.hasOwn(e,o))wa(o,n,`it is not active in ${r} but would become active in the target`)}var dN=["additionalItems","definitions","dependencies"];function lN(e,t,n,r,o){if(n.isDocumentRoot)q(e,"$schema",m0(t,p0)?r:t);else if(!m0(t,p0))wa("$schema",o,"an embedded resource cannot declare a different dialect")}function pN(e,t){uN(e,dN,"Draft-07","Draft 2020-12");let n={},r=void 0,o=void 0,s=void 0;for(let a of Object.keys(e)){let i=e[a];if(iN(n,a,i,t,aN))continue;switch(a){case"$ref":r=i;break;case"$schema":lN(n,i,t,YD,"Draft-07");break;case"$id":case"$anchor":break;case"$defs":q(n,"definitions",t.schemaMap(i,a,"definitions"));break;case"prefixItems":o=i;break;case"items":s=i;break;case"dependentRequired":case"dependentSchemas":case"minContains":case"maxContains":break;case"$dynamicRef":case"$dynamicAnchor":case"$vocabulary":case"unevaluatedProperties":case"unevaluatedItems":wa(a,"Draft-07","the target dialect has no equivalent");case"required":if(Array.isArray(i)&&i.length===0)break;q(n,a,i);break;default:q(n,a,i)}}if(mN(n,o,s,t),Object.hasOwn(e,"contains")){let{minContains:a,maxContains:i}=e;if(a!==void 0&&a!==1||i!==void 0)wa("minContains/maxContains","Draft-07","contains cardinality cannot be represented");if(Object.hasOwn(e,"minContains"))q(n,"minContains",a)}else{if(Object.hasOwn(e,"minContains"))q(n,"minContains",e.minContains);if(Object.hasOwn(e,"maxContains"))q(n,"maxContains",e.maxContains)}return gN(e,n,t,"draft-07"),yN(e,n,"$id","Draft-07"),hN(n,r,t),n}function mN(e,t,n,r){if(t===void 0){if(n!==void 0)q(e,"items",r.schema(n,"items"));return}if(q(e,"items",r.schemaArray(t,"prefixItems","items")),n!==void 0)q(e,"additionalItems",r.schema(n,"items","additionalItems"))}function hN(e,t,n){if(t===void 0)return;if(typeof t==="string"&&Object.keys(e).length>0){let r={};n.reference(r,t),xN(e,r)}else n.reference(e,t)}function gN(e,t,n,r){let o=st(e.dependentRequired)?e.dependentRequired:void 0,s=st(e.dependentSchemas)?e.dependentSchemas:void 0;if(o===void 0&&s===void 0)return;let a={},i=new Set([...Object.keys(o??{}),...Object.keys(s??{})]);for(let c of i){let f=o?.[c],u=s?.[c],d=r==="draft-04"&&Array.isArray(f)&&f.length===0;if(u===void 0){if(!d)q(a,c,f)}else if(f===void 0||d)q(a,c,n.schemaAt(u,["dependentSchemas",c],["dependencies",c]));else q(a,c,{allOf:[n.schemaAt(u,["dependentSchemas",c],["dependencies",c,"allOf","0"]),{required:f}]})}if(Object.keys(a).length>0)q(t,"dependencies",a)}function xN(e,t){if(Array.isArray(e.allOf))e.allOf.push(t);else q(e,"allOf",[t])}function yN(e,t,n,r){let{$id:o,$anchor:s}=e;if(s===void 0){if(o!==void 0)q(t,n,o);return}if(typeof s!=="string"||!cN.test(s))wa("$anchor",r,"the anchor is not valid");if(!fN.test(s))wa("$anchor",r,"the anchor cannot be represented as a plain-name fragment identifier");if(o===void 0)q(t,n,`#${s}`);else wa("$anchor",r,"it cannot be combined with the schema $id")}function Ol(e){return Nr(Ni(e.ast),{schema:e})}var Ni=Wo((e)=>{let t=bN(e,Ni),n=e.context;if(t===e||n===void 0)return t;return _i(t,cx(n))});function cx(e){return e.constructorDefault===void 0?e:new sr(e.isOptional,e.isMutable,void 0,e.annotations)}function w0(e){if(e.propertySignatures.some((t)=>typeof t.name!=="string"))throw new globalThis.Error("Objects property names must be strings",{cause:e})}function k0(e){return(t)=>{let n=[...t].sort((o,s)=>e(En(o))-e(En(s)));if(!n.some((o,s)=>o!==t[s]))return t;return n}}var EN=k0((e)=>{switch(e._tag){case"BigInt":case"Symbol":case"UniqueSymbol":return 0;default:return 1}});function bN(e,t){switch(e._tag){case"Declaration":{let n=e.annotations?.toCodecJson??e.annotations?.toCodec;if(!On(n))return Pe(e,[qg]);let r=e.typeParameters.map((s)=>Nr(En(s))),o=n(r);return o===void 0?e:Pe(e,[vs(o,t)])}case"Unknown":return Pe(e,[qg]);case"ObjectKeyword":return Pe(e,[Hk]);case"Undefined":case"Void":case"Literal":case"Number":return e.toCodecJson();case"UniqueSymbol":case"Symbol":case"BigInt":return e.toCodecStringTree();case"Objects":return w0(e),e.recur(t,yl);case"Union":{let n=EN(e.types);if(n!==e.types)return new tn(n,e.options,e.annotations,e.checks,e.encoding,e.context,e.encodingChecks).recur(t);return e.recur(t)}case"Arrays":case"Suspend":return e.recur(t)}return e}function _l(e){return Nr(T0(Ve(e.ast)))}var T0=Ln((e)=>{let t=IN(e,T0);return t!==e&&e.context!==void 0?_i(t,cx(e.context)):t});function IN(e,t){switch(e._tag){case"Declaration":{let n=e.annotations?.toCodecIso??e.annotations?.toCodec;if(On(n)){let r=n(e.typeParameters.map((o)=>Nr(o)));return Pe(e,[vs(r,t)])}return e}case"Arrays":case"Objects":case"Union":case"Suspend":return e.recur(t)}return e}function Rl(e){return Nr(O0(e.ast),{schema:e})}function A0(e){return Nr(_0(e.ast))}var wN=k0((e)=>{switch(e._tag){case"Null":case"Boolean":case"Number":case"BigInt":case"Symbol":case"UniqueSymbol":return 0;default:return 1}});function kN(e,t,n){switch(e._tag){case"Declaration":{let r=e.typeParameters.map((f)=>Nr(t(En(f)))),o=e.annotations?.toCodecStringTree;if(On(o)){let f=o(r);if(f===void 0)return e;return Pe(e,[vs(f,t)])}let s=e.annotations?.toCodecJson,a=On(s)?s(r):void 0,i=a===void 0?e.annotations?.toCodec:void 0,c=a??(On(i)?i(r):void 0);return c===void 0?n(e):Pe(e,[vs(c,t)])}case"Null":return Pe(e,[TN]);case"Boolean":return Pe(e,[AN]);case"Unknown":case"ObjectKeyword":return Pe(e,[Hg]);case"Enum":case"Number":case"Literal":case"UniqueSymbol":case"Symbol":case"BigInt":return e.toCodecStringTree();case"Objects":return w0(e),e.recur(t,yl);case"Union":{let r=wN(e.types);if(r!==e.types)return new tn(r,e.options,e.annotations,e.checks,e.encoding,e.context,e.encodingChecks).recur(t);return e.recur(t)}case"Arrays":case"Suspend":return e.recur(t)}return e}var TN=new Xe(new yn("null"),new be(se(()=>null),se(()=>"null"))),AN=new Xe(new tn([new yn("true"),new yn("false")]),new be(se((e)=>e==="true"),ha())),C0=new be(se((e)=>typeof e==="string"?[e]:e),xo()),v0=(e)=>e.transformation===C0,O0=Wo((e)=>{let t=kN(e,O0,(n)=>{throw new globalThis.Error("Missing structural codec for StringTree",{cause:n})});if(t!==e&&e.context!==void 0)return _i(t,cx(e.context));return t},{stopAt:v0}),I0=(e)=>Mt(e)?ba(jo):jo,_0=Wo((e)=>{let t=CN(e);if(Eg(t)){let n=Pi(new tn([new ar(t.isMutable,t.elements.map(I0),t.rest.map(I0)),$n],{mode:"anyOf"}),t,C0);return Mt(e)?ba(n):n}return t},{stopAt:v0});function CN(e){return e._tag==="Declaration"||e._tag==="Arrays"||e._tag==="Objects"||e._tag==="Union"||e._tag==="Suspend"?e.recur(_0):e}var W8=globalThis.RegExp;var Ko=(e)=>e.replace(/[/\\^$*+?.()|[\]{}]/g,"\\$&");function _s(e,t){if(t.length>0)e+=`
|
|
5
|
-
at ${Bd(t)}`;return Error(e)}function P0(e){return`#/$defs/${ox(e)}`}var vN=new Set([...PI,pa,...RI]);function _f(e,t){if(e===void 0)return;let n={},r=e.title;if(typeof r==="string")n.title=r;let{description:o,expected:s}=e;if(typeof o==="string")n.description=o;else if(t?.generateDescriptions===!0&&typeof s==="string")n.description=s;let a=e.default;if(Mi(a))n.default=a;let i=e.examples;if(Array.isArray(i)&&Mi(i))n.examples=i;let c=e.readOnly;if(typeof c==="boolean")n.readOnly=c;let f=e.writeOnly;if(typeof f==="boolean")n.writeOnly=f;let u=e.format;if(typeof u==="string")n.format=u;let d=e.contentEncoding;if(typeof d==="string")n.contentEncoding=d;let l=e.contentMediaType;if(typeof l==="string")n.contentMediaType=l;let m=e.contentSchema;if(Mi(m))n.contentSchema=m;if(t?.includeAnnotationKey!==void 0)for(let[p,g]of Object.entries(e)){if(vN.has(p)||!t.includeAnnotationKey(p))continue;if(Mi(g))q(n,p,g)}return Object.keys(n).length===0?void 0:n}function U0(e){let t=e.type==="number"||e.type==="integer"?e.type:void 0,n=e;if(t!==void 0)n={...e},delete n.type;if(Array.isArray(n.allOf)){let r=[],o=!1;for(let s of n.allOf){let a=U0(s);if(a.type!==void 0){if(o=!0,t===void 0||a.type==="integer")t=a.type}if(Object.keys(a.schema).length>0)r.push(a.schema)}if(o){let{allOf:s,...a}=n;n=r.length===0?a:{...a,allOf:r}}}return{type:t,schema:n}}function ON(e){if(!Array.isArray(e.anyOf)||e.anyOf.length!==2||e.anyOf[0]?.type!=="number")return!1;let t=e.anyOf[1];return t?.type==="string"&&Array.isArray(t.enum)&&t.enum.length===3&&t.enum.includes("NaN")&&t.enum.includes("Infinity")&&t.enum.includes("-Infinity")}var F0="|type|format|pattern|multipleOf|minimum|maximum|exclusiveMinimum|exclusiveMaximum|minLength|maxLength|minItems|maxItems|uniqueItems|minProperties|maxProperties|propertyNames|";function Pl(e,t){return Object.keys(e).every((n)=>t.includes(`|${n}|`))}function M0(e,t){return typeof e.$ref!=="string"&&t.every((n)=>!Object.hasOwn(e,n))}var ux="|title|description|default|examples|readOnly|writeOnly|",_N=F0+ux;function Rf(e,t,n){if(Object.keys(e).length===0)return t;let r=Object.keys(t);if(r.length===0)return e;let o=e.type==="number"||e.type==="integer"?e.type:void 0,s=ON(e);if(o!==void 0||s){let i=U0(t);if(i.type!==void 0){let c=o==="integer"||i.type==="integer"?"integer":"number",f={...e,type:c};if(s)delete f.anyOf;let u=Object.keys(i.schema);if(u.length===0)return f;return Pl(i.schema,ux)&&M0(f,u)?{...f,...i.schema}:Rf(f,i.schema,n)}}if(n&&M0(e,r))return{...e,...t};let a=Array.isArray(t.allOf)&&r.length===1?t.allOf:[t];if(Array.isArray(e.allOf))return{...e,allOf:[...e.allOf,...a]};if(typeof e.$ref==="string")return{allOf:[e,...a]};return{...e,allOf:a}}function fx(e,t=new Set){if(typeof e==="boolean")return e;if(t.has(e))return!0;return t.add(e),e.every((n)=>fx(n,t))}function RN(e){return Array.isArray(e)}function PN(e,t,n,r){let o=new Map,s=new Map,a=new WeakMap,i=new Map,c=new Map,f=Object.keys(n);for(let x of f)p(x,["references",x]);let u=hn(e,(x,w)=>S(x,t[w],[]));for(let[x,w]of i.values())if(!fx(x)){for(let C of w)if(Array.isArray(C.oneOf))C.anyOf=C.oneOf,delete C.oneOf}for(let x of f){let w=n[x],C=h(w);if(C===void 0)continue;let T=o.get(x)[0],v=c.get(C),O=v?.find((U)=>he(o.get(U)[0],T));if(O===void 0)if(v===void 0)c.set(C,[x]);else v.push(x);else s.set(x,O)}let d=hn(u,g),l={};for(let x of f)if(!s.has(x))q(l,x,g(o.get(x)[0]));return{dialect:"draft-2020-12",schemas:d,definitions:l};function m(x){if(Array.isArray(x.oneOf))i.get(x.oneOf)?.[1].push(x);return x}function p(x,w){if(!Object.hasOwn(n,x))throw _s(`Invalid reference ${x}`,[...w,"$ref"]);let C=o.get(x);if(C!==void 0)return C;let T=[{},[]];return o.set(x,T),T[0]=S(n[x],["references",x],T[1]),T}function g(x){return y0(x,(w)=>{let C=sx(w);if(C===void 0){if(/^#(?:\/|%2f)/i.test(w))throw Error(`Invalid JSON Pointer URI fragment ${JSON.stringify(w)}`);return w}if(!C.startsWith("/$defs/"))return w;let T=C.indexOf("/",7),v=s.get(vf(C.slice(7,T<0?void 0:T)));if(v===void 0)return w;return w.replace(/^#(?:\/|%2f).*?(?:\/|%2f).*?(?=\/|%2f|$)/i,P0(v))})}function h(x){if(x._tag==="Reference")return;let w=x.checks.length===0?x.annotations:x.checks[x.checks.length-1].annotations;return typeof w?.identifier!=="string"&&typeof w?.[pa]==="string"?w[pa]:void 0}function E(x,w,C,T){let v=x.annotations,O=v?.toJsonSchema;if(O!==void 0){let J=x.representation?.schemas?.map((wt,ti)=>S(wt,[...C,"representation","schemas",ti],T))??[],N=O({type:w,schemas:J}),G=RN(N);if(G)T.push(!1);let fe=G?N[0]:N,Ge=_f(v,r),Ot=Ge===void 0?fe:{...fe,...Ge},et=Ge===void 0?F0:_N;return[Ot,x._tag==="Filter"&&Pl(Ot,et)&&(Ge===void 0||Pl(Ge,ux))?!0:void 0]}if(x._tag==="Filter"){T.push(!1);return}let U=x.checks.flatMap((J,N)=>{let G=E(J,w,[...C,"checks",N],T);return G===void 0?[]:[G[0]]});if(U.length===0)return;let j=_f(v,r),X={allOf:U};return[j===void 0?X:{...X,...j}]}function S(x,w,C){if(x._tag==="Reference")return C.push(p(x.$ref,w)[1]),{$ref:P0(x.$ref)};let T=a.get(x);if(T!==void 0)return C.push(T[1]),T[0];let v=[];C.push(v);let O=k(x,w,v),U=_f(x.annotations,r);if(U!==void 0)O={...O,...U};for(let j=0;j<x.checks.length;j++){let X=typeof O.type==="string"&&MN(O.type)?O.type:void 0,J=E(x.checks[j],X,[...w,"checks",j],v);if(J!==void 0)O=Rf(O,...J)}return a.set(x,[O,v]),m(O)}function k(x,w,C){switch(x._tag){case"Any":case"Unknown":return{};case"ObjectKeyword":return{anyOf:[{type:"object"},{type:"array"}]};case"Void":case"Undefined":case"Null":return{type:"null"};case"BigInt":return{type:"string",allOf:[{pattern:"^-?\\d+$"}]};case"Symbol":return{type:"string",allOf:[{pattern:"^Symbol\\(([\\s\\S]*)\\)$"}]};case"UniqueSymbol":return globalThis.Symbol.keyFor(x.symbol)===void 0?{not:{}}:{type:"string",enum:[globalThis.String(x.symbol)]};case"Declaration":return C.push(!1),{};case"Suspend":return S(x.thunk,[...w,"thunk"],C);case"Never":return{not:{}};case"String":return{type:"string"};case"Number":return{anyOf:[{type:"number"},{type:"string",enum:["NaN","Infinity","-Infinity"]}]};case"Boolean":return{type:"boolean"};case"Literal":{let T=x.literal;return typeof T==="bigint"?{type:"string",enum:[globalThis.String(T)]}:{type:typeof T,enum:[T]}}case"Enum":{let T=x.enums.map(([v,O],U)=>{if(typeof O==="number"&&!globalThis.Number.isFinite(O))throw _s(`Invalid numeric enum value ${globalThis.String(O)}`,[...w,"enums",U,1]);return{type:typeof O,enum:[O],title:v}});return T.length===0?{not:{}}:{anyOf:T}}case"TemplateLiteral":return{type:"string",pattern:`^${x.parts.map(Ml).join("")}$`};case"Arrays":{if(x.rest.length>1)throw _s("Invalid schema representation document",[...w,"rest"]);let T={type:"array"},v=x.elements.length,O=x.elements.map((U,j)=>{if(U.isOptional)v--;let X=S(U.type,[...w,"elements",j,"type"],C),J=_f(U.annotations,r);return J===void 0?X:m(Rf(X,J))});if(O.length>0){if(T.prefixItems=O,T.maxItems=x.elements.length,v>0)T.minItems=v}else T.items=!1;if(x.rest.length===1){delete T.maxItems;let U=S(x.rest[0],[...w,"rest",0],C);if(Object.keys(U).length>0)T.items=U;else delete T.items}return T}case"Objects":{if(x.propertySignatures.length===0&&x.indexSignatures.length===0)return{not:{type:"null"}};let T={type:"object"},v={},O=[];for(let G=0;G<x.propertySignatures.length;G++){let fe=x.propertySignatures[G];if(typeof fe.name!=="string")throw _s("Invalid schema representation document",[...w,"propertySignatures",G,"name"]);let Ge=fe.name,Ot=S(fe.type,[...w,"propertySignatures",G,"type"],C),et=_f(fe.annotations,r);if(q(v,Ge,et===void 0?Ot:m(Rf(Ot,et))),!fe.isOptional)O.push(Ge)}if(x.propertySignatures.length>0)T.properties=v;if(O.length>0)T.required=O;let U={},j=[],X=[],J=!1;for(let G=0;G<x.indexSignatures.length;G++){let fe=x.indexSignatures[G],Ge=S(fe.type,[...w,"indexSignatures",G,"type"],C);if(he(Ge,{not:{}}))Ge=!1;X.push(Ge);let Ot=I(fe.parameter,[...w,"indexSignatures",G,"parameter"],new Set);if(Ot===void 0){J=!0,C.push(!1);continue}if(Ot.length===0)j.push(Ge);else for(let et of Ot){let wt=U[et];q(U,et,wt===void 0?Ge:wt===!1||Ge===!1?!1:m(Rf(wt,Ge)))}}let N=Object.keys(U).length>0;if(N)T.patternProperties=U;if(J&&r?.onExcessProperty==="error"){let G=[];if(x.propertySignatures.length>0)G.push({enum:Object.keys(v)});for(let fe=0;fe<x.indexSignatures.length;fe++)G.push(S(x.indexSignatures[fe].parameter,[...w,"indexSignatures",fe,"parameter"],C));if(T.propertyNames=G.length===1?G[0]:{anyOf:G},T.additionalProperties=X.length===1?X[0]:{anyOf:X},j.length>0)T.allOf=j.map((fe)=>({type:"object",additionalProperties:fe}))}else if(j.length===0)T.additionalProperties=J||r?.onExcessProperty!=="error";else if(j.length===1&&x.propertySignatures.length===0&&!N)T.additionalProperties=j[0];else if(j.length>0)T.allOf=j.map((G)=>({type:"object",additionalProperties:G}));if(typeof T.additionalProperties==="object"&&T.additionalProperties!==null&&Object.keys(T.additionalProperties).length===0)delete T.additionalProperties;return T}case"Union":{let T=[],v=x.types.map((U,j)=>S(U,[...w,"types",j],T));if(C.push(T),v.length===0)return{not:{}};let O=x.options?.mode??"anyOf";if(O==="anyOf"&&v.length>1){let U=UN(v);if(U!==void 0)return U}if(O==="oneOf")i.set(v,[T,[]]);return{[O]:v}}}}function I(x,w,C){switch(x._tag){case"Reference":{if(!Object.hasOwn(n,x.$ref))throw _s(`Invalid reference ${x.$ref}`,[...w,"$ref"]);if(p(x.$ref,w),C.has(x.$ref))return;let T=new Set(C).add(x.$ref);return I(n[x.$ref],["references",x.$ref],T)}case"String":{if(x.checks.length===0)return[];if(x.checks.length!==1||x.checks[0]._tag!=="Filter"||x.checks[0].annotations?.toJsonSchema===void 0)return;let T=[],v=S(x,w,T);if(!fx(T))return;return v.type==="string"&&typeof v.pattern==="string"&&Pl(v,"|type|pattern|title|description|default|examples|readOnly|writeOnly|")?[v.pattern]:void 0}case"TemplateLiteral":return x.checks.length===0?[`^${x.parts.map(Ml).join("")}$`]:void 0;case"Union":{if(x.types.length===0||x.checks.length>0||x.options?.mode==="oneOf")return;let T=[];for(let v=0;v<x.types.length;v++){let O=I(x.types[v],[...w,"types",v],C);if(O===void 0)return;if(O.length===0)return[];T.push(...O)}return T}default:throw _s("Invalid schema representation document",w)}}}function MN(e){return e==="string"||e==="number"||e==="boolean"||e==="array"||e==="object"||e==="null"||e==="integer"}function UN(e){let t=void 0,n=[];for(let r of e){if(Object.keys(r).length!==2||r.type===void 0||!Array.isArray(r.enum)||r.enum.length===0)return;if(t===void 0)t=r.type;else if(r.type!==t)return;for(let s of r.enum){if(n.includes(s))return;n.push(s)}}return{type:t,enum:n}}function Ml(e){switch(e._tag){case"Literal":return Ko(globalThis.String(e.literal));case"String":return Dk;case"Number":return dl;case"TemplateLiteral":return e.parts.map(Ml).join("");case"Union":return`(?:${e.types.map(Ml).join("|")})`;default:throw _s("Invalid schema representation document",[])}}function Ul(e,t){let n=PN([e.representation],[["representation"]],e.references,t);return{dialect:n.dialect,schema:n.schemas[0],definitions:n.definitions}}var FN=({identifier:e})=>e;function Br(e){return e===void 0?void 0:{annotations:e}}function Pf(e,t){let{references:n,representations:r}=DN([e],t);return{representation:r[0],references:n}}function DN(e,t){let n={},r=new Map,o=new Set,s=new Map,a=new Set;for(let x of e)m(x);let i=t?.referencePolicy??FN;for(let x of s.values())for(let w of x.values()){let C=i({ast:w.ast,occurrences:w.occurrences,identifier:w.identifier});if(C!==void 0){let T=C===w.identifier||!C.endsWith("_")?"_":"";w.reference=f(C,w,T)}else if(w.isRecursive)w.reference=f(`${w.ast._tag}_`,w,"")}return{representations:hn(e,(x)=>g(x)),references:n};function f(x,w,C="_"){let T=x,v=0;while(r.has(T)){if(r.get(T)===w)return T;T=`${x}${C}${++v}`}return r.set(T,w),T}function u(x,w,C){let T=w.fallback;if(T!==void 0)return Gh(x)===T?x:Ur(x,{[pa]:T});return C===w.identifier?x:Ur(x,{identifier:C})}function d(x,w){if(!Object.hasOwn(n,x)&&!o.has(x)){o.add(x);let C=h(w);o.delete(x),q(n,x,C)}return{_tag:"Reference",$ref:x}}function l(x){let w=Oi(x),C=vi(w),T=mi(w),v=T===void 0?(w!==x?mi(x):void 0)??Gh(w):void 0;if(v!==void 0)T=`${v}Encoded`;let O=s.get(C);if(O===void 0)O=new Map,s.set(C,O);let U=O.get(T);if(U===void 0)U={ast:C,identifier:T,fallback:v,occurrences:0,isRecursive:!1,reference:void 0},O.set(T,U);return U}function m(x){let w=l(x),C=w.ast;if(w.occurrences++,a.has(w)){w.isRecursive=!0;return}if(w.occurrences>1)return;switch(a.add(w),p(C.checks),C._tag){case"Declaration":case"Arrays":case"Objects":case"Union":C.recur((T)=>(m(T),T));break;case"TemplateLiteral":C.parts.forEach(m);break;case"Suspend":m(C.thunk());break}a.delete(w)}function p(x){x?.forEach((w)=>{if(w.annotations?.representation?.schemas?.forEach((C)=>m(Ve(C))),w._tag==="FilterGroup")p(w.checks)})}function g(x){let w=l(x),C=w.ast,T=w.reference;if(T!==void 0){let v=w.identifier===void 0?C:u(C,w,T);return d(T,v)}return h(C)}function h(x){let w=E(x.checks);switch(x._tag){case"Declaration":return{_tag:"Declaration",typeParameters:x.typeParameters.map((C)=>g(C)),checks:w,...k(x.annotations)};case"Null":case"Undefined":case"Void":case"Never":case"Unknown":case"Any":case"String":case"Boolean":case"Number":case"BigInt":case"Symbol":case"ObjectKeyword":return{_tag:x._tag,checks:w,...Br(x.annotations)};case"Literal":return{_tag:"Literal",literal:x.literal,checks:w,...Br(x.annotations)};case"UniqueSymbol":return{_tag:"UniqueSymbol",symbol:x.symbol,checks:w,...Br(x.annotations)};case"Enum":return{_tag:"Enum",enums:x.enums,checks:w,...Br(x.annotations)};case"TemplateLiteral":return{_tag:"TemplateLiteral",parts:x.parts.map((C)=>g(C)),checks:w,...Br(x.annotations)};case"Arrays":return{_tag:"Arrays",elements:x.elements.map((C)=>{let T=Oi(C),v=T.context?.annotations;return{isOptional:Mt(T),type:g(C),...Br(v)}}),rest:x.rest.map((C)=>g(C)),checks:w,...Br(x.annotations)};case"Objects":return{_tag:"Objects",propertySignatures:x.propertySignatures.map((C)=>{let T=Oi(C.type),v=T.context?.annotations;return{name:C.name,type:g(C.type),isOptional:Mt(T),isMutable:Pk(T),...Br(v)}}),indexSignatures:x.indexSignatures.map((C)=>({parameter:g(C.parameter),type:g(C.type)})),checks:w,...Br(x.annotations)};case"Union":return{_tag:"Union",types:x.types.map((C)=>g(C)),...x.options===void 0?{}:{options:x.options},checks:w,...Br(x.annotations)};case"Suspend":return{_tag:"Suspend",checks:[],thunk:g(x.thunk()),...Br(x.annotations)}}}function E(x){return x?.map(S)??[]}function S(x){switch(x._tag){case"Filter":return{_tag:"Filter",aborted:x.aborted,...I(x.annotations)};case"FilterGroup":return{_tag:"FilterGroup",checks:hn(x.checks,S),...I(x.annotations)}}}function k(x){if(x===void 0)return;let{representation:w,...C}=x;return{...w===void 0?void 0:{representation:w},...Object.keys(C).length===0?void 0:{annotations:C}}}function I(x){if(x===void 0)return;let{representation:w,...C}=x,T=w===void 0?void 0:w.schemas===void 0?w:{...w,schemas:w.schemas.map((v)=>g(Ve(v)))};return{...T===void 0?void 0:{representation:T},...Object.keys(C).length===0?void 0:{annotations:C}}}}function B0(e){return $e(e)?e.value:{issues:[{message:$0(e.cause)}]}}function H0(e,t){let n=qe(e),r={errors:"all",...t?.parseOptions},o=zI(t),s=(a)=>{let i=new z0("sync"),c=Fl(q0(n(a,r),{onFailure:o,onSuccess:(u)=>({value:u})}),{scheduler:i});c.currentDispatcher?.flush();let f=c.pollUnsafe();if(f)return B0(f);return new Promise((u)=>{c.addObserver((d)=>{u(B0(d))})})};if("~standard"in e){let a=e;if("validate"in a["~standard"])return a;return Object.assign(a["~standard"],{validate:s}),a}return Object.assign(e,{"~standard":{version:1,vendor:"effect",validate:s}})}function NN(e){let t=Pf(Ni(e));return Ul(t)}function L0(e,t){let n=NN(e);if(t==="draft-2020-12"){let r=n.schema;if(Object.keys(n.definitions).length>0)r.$defs=n.definitions;return r}else if(t==="draft-07"){let r=x0(n),o=r.schema;if(Object.keys(r.definitions).length>0)o.definitions=r.definitions;return o}throw new globalThis.Error(`Unsupported target: ${t}`)}function j0(e){let t={input(n){return L0(e.ast,n.target)},output(n){return L0(Ve(e.ast),n.target)}};if("~standard"in e){let n=e;if("jsonSchema"in n["~standard"])return n;return Object.assign(n["~standard"],{jsonSchema:t}),n}return Object.assign(e,{"~standard":{version:1,vendor:"effect",jsonSchema:t}})}function J0(e,t){let n=[];return dx(e,t,"",n),n}function dx(e,t,n,r){if(Object.is(e,t))return;if(Array.isArray(e)&&Array.isArray(t)){let o=e.length,s=t.length,a=Math.min(o,s);for(let i=0;i<a;i++)dx(e[i],t[i],`${n}/${i}`,r);for(let i=o-1;i>=s;i--)r.push({op:"remove",path:`${n}/${i}`});for(let i=o;i<s;i++)r.push({op:"add",path:`${n}/${i}`,value:t[i]});return}if(Dl(e)&&Dl(t)){let o=Object.keys(e),s=Object.keys(t),a=Array.from(new Set([...o,...s])).sort();for(let i of a){let c=`${n}/${rx(i)}`,f=Object.hasOwn(e,i),u=Object.hasOwn(t,i);if(f&&u)dx(e[i],t[i],c,r);else if(!f&&u)r.push({op:"add",path:c,value:t[i]});else r.push({op:"remove",path:c})}return}r.push({op:"replace",path:n,value:t})}function G0(e,t){let n=t;for(let r of e)n=zN(n,r);return n}function Dl(e){return typeof e==="object"&&e!==null&&!Array.isArray(e)}function LN(e){if(e==="")return[];if(e.charCodeAt(0)!==47)throw Error(`Invalid JSON Pointer, it must start with "/": ${JSON.stringify(e)}`);return e.split("/").slice(1).map(vf)}function K0(e){if(!/^(0|[1-9]\d*)$/.test(e))throw Error(`Invalid array index: "${e}"`);return Number(e)}function zN(e,t){if(t.path===""){if(t.op==="remove")throw Error("Unsupported operation at the root");return t.value}let n=$N(e,t.path);if(n===null)throw Error(`Cannot ${t.op} at "${t.path}" (parent not found or not a container).`);let{lastToken:r,parent:o,stack:s}=n;if(Array.isArray(o)){if(r==="-"&&t.op!=="add")throw Error(`"-" is not valid for ${t.op} at "${t.path}".`);let a=r==="-"?o.length:K0(r),i=t.op==="add"?o.length:o.length-1;if(a>i)throw Error(`Array index out of bounds at "${t.path}".`);let c=o.slice();if(t.op==="add")c.splice(a,0,t.value);else if(t.op==="remove")c.splice(a,1);else c[a]=t.value;return W0(s,c)}if(Dl(o)){if(t.op!=="add"&&!Object.hasOwn(o,r))throw Error(`Property "${r}" does not exist at "${t.path}".`);let a={...o};if(t.op==="remove")delete a[r];else q(a,r,t.value);return W0(s,a)}throw Error(`Cannot ${t.op} at "${t.path}" (parent not found or not a container).`)}function $N(e,t){let n=LN(t);if(n.length===0)return null;let r=n[n.length-1],o=[],s=e;for(let a=0;a<n.length-1;a++){let i=n[a];if(Array.isArray(s)){let c=K0(i);if(c>=s.length)return null;o.push({container:s,token:c}),s=s[c];continue}if(Dl(s)){if(!Object.hasOwn(s,i))return null;o.push({container:s,token:i}),s=s[i];continue}return null}return{stack:o,parent:s,lastToken:r}}function W0(e,t){let n=t;for(let r=e.length-1;r>=0;r--){let{container:o,token:s}=e[r];if(Array.isArray(o)){let a=o.slice();a[s]=n,n=a}else{let a={...o};q(a,s,n),n=a}}return n}function V0(e){let t=Ol(e),n=Al(t),r=Tl(t);return{empty:[],diff:(o,s)=>J0(n(o),n(s)),combine:(o,s)=>[...o,...s],patch:(o,s)=>{let a=n(o),i=G0(s,a);return Object.is(i,a)?o:r(i)}}}function Z0(e,t){let n=mi(e.ast)??Kh(e.ast),r=n0(Rl(e));return(o)=>r(o).pipe(B((s)=>jN(s,{rootName:n,...t})))}function jN(e,t){let n=t.rootName??"root",r=t.arrayItemName??"item",o=t.pretty??!0,s=t.indent??" ",a=t.sortKeys??!0,i=new Set,c=[];return u(n,e,0),c.join(o?`
|
|
6
|
-
`:"");function f(d,l){c.push(o?s.repeat(d)+l:l)}function u(d,l,m,p){let{attrs:g,safe:h}=Bi.tagInfo(d,p);if(l===void 0)f(m,`<${h}${g}/>`);else if(typeof l==="string")f(m,`<${h}${g}>${Bi.escapeText(l)}</${h}>`);else if(typeof l!=="object"||l===null)f(m,`<${h}${g}>${Bi.escapeText(K(l))}</${h}>`);else{if(i.has(l))throw new globalThis.Error("Cycle detected while serializing to XML.",{cause:l});i.add(l);try{if(globalThis.Array.isArray(l)){if(l.length===0){f(m,`<${h}${g}/>`);return}f(m,`<${h}${g}>`);for(let k of l)u(r,k,m+1);f(m,`</${h}>`);return}let E=l,S=Object.keys(E);if(a)S.sort();if(S.length===0){f(m,`<${h}${g}/>`);return}f(m,`<${h}${g}>`);for(let k of S)u(Bi.parseTagName(k).safe,E[k],m+1,k);f(m,`</${h}>`)}finally{i.delete(l)}}}}var Bi={escapeText(e){return e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">")},escapeAttribute(e){return e.replace(/&/g,"&").replace(/"/g,""").replace(/</g,"<").replace(/>/g,">")},parseTagName(e){let t=e,n=e;if(!/^[A-Za-z_]/.test(n))n="_"+n;if(n=n.replace(/[^A-Za-z0-9._-]/g,"_"),/^xml/i.test(n))n="_"+n;return{safe:n,changed:n!==t}},tagInfo(e,t){let{changed:n,safe:r}=Bi.parseTagName(e),s=n||t&&t!==e?` data-name="${Bi.escapeAttribute(t??e)}"`:"";return{safe:r,attrs:s}}};var lx=Ln((e)=>Rs(e));function Rs(e){let t=Ho(e)?.toEquivalence;if(t)return t(Ci(e)?e.typeParameters.map(Rs):[]);switch(e._tag){case"Never":return da();case"Declaration":return JN(e);case"Null":case"Undefined":case"Void":case"Unknown":case"Any":case"String":case"Number":case"Boolean":case"BigInt":case"Symbol":case"Literal":case"UniqueSymbol":case"ObjectKeyword":case"Enum":case"TemplateLiteral":return he;case"Arrays":{let n=e.elements.map(Rs),r=e.rest.map(Rs),[o,...s]=r,a=s.length;return Ar((i,c)=>{if(!Array.isArray(i)||!Array.isArray(c))return!1;let f=i.length;if(f!==c.length)return!1;let u=0;for(;u<Math.min(f,e.elements.length);u++)if(!n[u](i[u],c[u]))return!1;if(r.length>0){for(;u<f-a;u++)if(!o(i[u],c[u]))return!1;for(let d=0;d<a;d++)if(!s[d](i[u+d],c[u+d]))return!1}return!0})}case"Objects":{if(e.propertySignatures.length===0&&e.indexSignatures.length===0)return he;let n=e.propertySignatures.map((o)=>Rs(o.type)),r=e.indexSignatures.map((o)=>Rs(o.type));return Ar((o,s)=>{if(!st(o)||!st(s))return!1;for(let a=0;a<n.length;a++){let i=e.propertySignatures[a],c=i.name,f=Object.hasOwn(o,c),u=Object.hasOwn(s,c);if(Mt(i.type)){if(f!==u)return!1}if(f&&u&&!n[a](o[c],s[c]))return!1}for(let a=0;a<r.length;a++){let i=e.indexSignatures[a],c=yo(o,i.parameter),f=yo(s,i.parameter);if(c.length!==f.length)return!1;for(let u=0;u<c.length;u++){let d=c[u];if(!Object.hasOwn(s,d)||!r[a](o[d],s[d]))return!1}}return!0})}case"Union":{let n=Ve(e).types,r=wf(n),o=n.map((s,a)=>[Cf(s),Rs(e.types[a])]);return Ar((s,a)=>{let i=r(s,!1);for(let c=0;c<i.length;c++){let[f,u]=o[i[c]];if(f(s)&&f(a))return u(s,a)}return!1})}case"Suspend":{let n;return Ar((r,o)=>(n??=lx(e.thunk()))(r,o))}}}function JN(e){let t=e.annotations?.representation;if(t===void 0)return he;switch(t.id){case"effect/schema/Option":{let[n]=ka(e);return(r,o)=>r._tag===o._tag&&(r._tag==="None"||n(r.value,o.value))}case"effect/schema/Result":{let[n,r]=ka(e);return(o,s)=>o._tag===s._tag&&(o._tag==="Success"?n(o.success,s.success):r(o.failure,s.failure))}case"effect/schema/CauseReason":{let[n,r]=ka(e);return X0(n,r)}case"effect/schema/Cause":{let[n,r]=ka(e);return Q0(n,r)}case"effect/schema/Exit":{let[n,r,o]=ka(e),s=Q0(r,o);return(a,i)=>a._tag===i._tag&&(a._tag==="Success"?n(a.value,i.value):s(a.cause,i.cause))}case"effect/schema/ReadonlyMap":{let[n,r]=ka(e);return Nl(n,r)}case"effect/schema/ReadonlySet":return Bl(ka(e)[0]);case"effect/schema/RegExp":return(n,r)=>n.source===r.source&&n.flags===r.flags;case"effect/schema/URL":return(n,r)=>n.toString()===r.toString();default:return he}}function ka(e){return e.typeParameters.map(Rs)}function X0(e,t){return(n,r)=>{if(n._tag!==r._tag)return!1;switch(n._tag){case"Fail":return e(n.error,r.error);case"Die":return t(n.defect,r.defect);case"Interrupt":return n.fiberId===r.fiberId}}}function Q0(e,t){let n=Y0(X0(e,t));return(r,o)=>n(r.reasons,o.reasons)}function tT(e,t){return(n)=>{switch(n._tag){case"Fail":return`Fail(${e(n.error)})`;case"Die":return`Die(${t(n.defect)})`;case"Interrupt":return"Interrupt"}}}function eT(e,t){let n=tT(e,t);return(r)=>`Cause([${r.reasons.map(n).join(", ")}])`}function nT(e,t){let n=new Map;return r(e);function r(a){let i=n.get(a);if(i===void 0)i=o(a),n.set(a,i);return i}function o(a){let i=Ho(a)?.toFormatter;if(typeof i==="function")return i(Ci(a)?a.typeParameters.map(r):[]);if(t?.onBefore){let c=t.onBefore(a,r);if(c!==void 0)return c}return s(a)}function s(a){switch(a._tag){default:return K;case"Never":return()=>"never";case"Void":return()=>"void";case"Declaration":{let i=a.annotations?.representation;if(i===void 0)return K;let c=a.typeParameters.map(r);switch(i.id){case"effect/schema/Option":{let[f]=c;return zt({onNone:()=>"none()",onSome:(u)=>`some(${f(u)})`})}case"effect/schema/Result":{let[f,u]=c;return Pr({onSuccess:(d)=>`success(${f(d)})`,onFailure:(d)=>`failure(${u(d)})`})}case"effect/schema/CauseReason":return tT(c[0],c[1]);case"effect/schema/Cause":return eT(c[0],c[1]);case"effect/schema/Exit":{let[f,u,d]=c,l=eT(u,d);return(m)=>{switch(m._tag){case"Success":return`Exit.Success(${f(m.value)})`;case"Failure":return`Exit.Failure(${l(m.cause)})`}}}case"effect/schema/ReadonlyMap":{let[f,u]=c;return(d)=>{let l=d.size;if(l===0)return"ReadonlyMap(0) {}";let m=globalThis.Array.from(d.entries()).sort().map(([p,g])=>`${f(p)} => ${u(g)}`);return`ReadonlyMap(${l}) { ${m.join(", ")} }`}}case"effect/schema/HashMap":{let[f,u]=c;return(d)=>{let l=Zb(d);if(l===0)return"HashMap(0) {}";let m=ef(d).sort().map(([p,g])=>`${f(p)} => ${u(g)}`);return`HashMap(${l}) { ${m.join(", ")} }`}}case"effect/schema/ReadonlySet":{let[f]=c;return(u)=>{let d=u.size;if(d===0)return"ReadonlySet(0) {}";let l=globalThis.Array.from(u.values()).sort().map((m)=>`${f(m)}`);return`ReadonlySet(${d}) { ${l.join(", ")} }`}}case"effect/schema/HashSet":{let[f]=c;return(u)=>{let d=eI(u);if(d===0)return"HashSet(0) {}";let l=globalThis.Array.from(u).sort().map((m)=>`${f(m)}`);return`HashSet(${d}) { ${l.join(", ")} }`}}case"effect/schema/Chunk":{let[f]=c;return(u)=>{let d=ob(u);if(d===0)return"Chunk(0) {}";let l=globalThis.Array.from(u).sort().map((m)=>`${f(m)}`);return`Chunk(${d}) { ${l.join(", ")} }`}}default:return K}}case"Arrays":{let i=a.elements.map((l)=>r(l)),c=a.rest.map(r),[f,...u]=c,d=u.length;return(l)=>{let m=[],p=0;for(;p<i.length;p++)if(l.length<p+1){if(Mt(a.elements[p]))continue}else m.push(i[p](l[p]));if(c.length>0){for(;p<l.length-d;p++)m.push(f(l[p]));for(let g=0;g<d;g++)m.push(u[g](l[p+g]))}return"["+m.join(", ")+"]"}}case"Objects":{let i=a.propertySignatures.map((f)=>r(f.type)),c=a.indexSignatures.map((f)=>r(f.type));if(a.propertySignatures.length===0&&a.indexSignatures.length===0)return K;return(f)=>{let u=[],d=new Set;for(let l=0;l<i.length;l++){let m=a.propertySignatures[l],p=m.name;if(d.add(p),Mt(m.type)&&!Object.hasOwn(f,p))continue;u.push(`${Sa(p)}: ${i[l](f[p])}`)}for(let l=0;l<c.length;l++){let m=yo(f,a.indexSignatures[l].parameter);for(let p of m){if(d.has(p))continue;d.add(p),u.push(`${Sa(p)}: ${c[l](f[p])}`)}}return u.length>0?"{ "+u.join(", ")+" }":"{}"}}case"Union":{let i=Ve(a).types,c=wf(i),f=i.map((u,d)=>[Cf(u),r(a.types[d])]);return(u)=>{let d=c(u,!1);for(let l=0;l<d.length;l++){let[m,p]=f[d[l]];if(m(u))return p(u)}return K(u)}}case"Suspend":{let i;return(c)=>(i??=r(a.thunk()))(c)}}}}var px=y(2,(e,t)=>gx(e,(n,r)=>oT(t,n)?[n,r]:void 0)),mx=y(2,(e,t)=>gx(e,(n,r)=>!oT(t,n)?[n,r]:void 0)),rT=y(2,(e,t)=>({...e,...t}));var hx=y(2,(e,t)=>gx(e,(n,r)=>[Object.hasOwn(t,n)?t[n]:n,r]));var nn=(e)=>e;function oT(e,t){return e.some((n)=>n===t||typeof n==="number"&&String(n)===t)}function gx(e,t){let n={};for(let r of Reflect.ownKeys(e)){if(!Object.prototype.propertyIsEnumerable.call(e,r))continue;let o=t(r,e[r]);if(o){let[s,a]=o;q(n,s,a)}}return n}function cT(e,t){return Lr(Li("Iso",e,t))}function aT(e,t){return Lr(Li("Lens",e,t))}function Li(e,t,n){return[{_tag:"PrimitiveNode",kind:e,get:t,set:n}]}var VN={kind:"Iso",get:Q,set:Q};class yx{_tag="PathNode";kind="Lens";path;get;set;constructor(e){this.path=e,this.get=(t)=>{let n=t;for(let r=0;r<e.length;r++)n=n[e[r]];return n},this.set=(t,n)=>{let r=zl(n),o=r,s=0;for(;s<e.length-1;s++){let a=e[s];q(o,a,zl(o[a])),o=o[a]}return q(o,e[s],t),r}}}class Ll{_tag="CheckNode";kind="Prism";checks;get;set=Q;constructor(e){this.checks=e,this.get=(t)=>Lk(e,t)}}function Ta(e,t){if(e.length===0)return t;if(t.length===0)return e;let n=e.slice();for(let r=0;r<t.length;r++){let o=t[r],s=n[n.length-1];if(s._tag==="PathNode"&&o._tag==="PathNode")n[n.length-1]=new yx([...s.path,...o.path]);else if(s._tag==="CheckNode"&&o._tag==="CheckNode")n[n.length-1]=new Ll([...s.checks,...o.checks]);else n.push(o)}return n}function ZN(e,t){return Lr(Li("Optional",e,t))}class Uf{node;getResult;replaceResult;constructor(e,t,n){this.node=e,this.getResult=t,this.replaceResult=n}replace(e,t){return Mf(this.replaceResult(e,t),()=>t)}modify(e){return(t)=>Mf(Tt(this.getResult(t),(n)=>this.replaceResult(e(n),t)),()=>t)}compose(e){return Lr(Ta(this.node,e.node))}key(e){return Lr(Ta(this.node,[new yx([e])]))}optionalKey(e){return Lr(Ta(this.node,Li("Lens",(t)=>t[e],(t,n)=>{let r=zl(n);if(t===void 0)if(Array.isArray(r)&&(typeof e==="number"||typeof e==="string"&&$d(e)))r.splice(Number(e),1);else delete r[e];else q(r,e,t);return r})))}check(...e){return Lr(Ta(this.node,[new Ll(e)]))}refine(e,t){return Lr(Ta(this.node,[new Ll([hl(e,t)])]))}tag(e){let t=ge(new te({expected:`${JSON.stringify(e)} tag`}));return Lr(Ta(this.node,Li("Prism",(n)=>n._tag===e?ue(n):t,Q)))}at(e,...t){let n=ge(new Qe([e],new ot(void 0)));return Lr(Ta(this.node,Li("Optional",(r)=>Object.hasOwn(r,e)?ue(r[e]):n,(r,o)=>{if(Object.hasOwn(o,e)){let s=zl(o);return q(s,e,r),ue(s)}else return n})))}pick(e){return this.compose(aT(px(e),(t,n)=>({...mx(n,e),...t})))}omit(e){return this.compose(aT(mx(e),(t,n)=>({...px(n,e),...t})))}notUndefined(){return this.refine(ws,{expected:"a value other than `undefined`"})}forEach(e){let t=e($l());return ZN((n)=>vr(this.getResult(n),(r)=>{let o=[];for(let s=0;s<r.length;s++){let a=t.getResult(r[s]);if(At(a))o.push(a.success)}return o}),(n,r)=>Tt(this.getResult(r),(o)=>{let s=[];for(let i=0;i<o.length;i++)if(At(t.getResult(o[i])))s.push(i);if(n.length!==s.length)return ge(new te({message:`each: replacement length mismatch: ${n.length} !== ${s.length}`}));let a=o.slice();for(let i=0;i<s.length;i++){let c=s[i],f=t.replaceResult(n[i],o[c]);if(Bt(f))return ge(new Qe([c],f.failure));a[c]=f.success}return this.replaceResult(a,r)}))}modifyAll(e){return(t)=>Mf(Tt(this.getResult(t),(n)=>this.replaceResult(n.map(e),t)),()=>t)}}class fT extends Uf{get;set;constructor(e,t,n){super(e,(r)=>ue(t(r)),(r)=>ue(n(r)));this.get=t,this.set=n}replace(e,t){return this.set(e)}modify(e){return(t)=>this.set(e(this.get(t)))}}class uT extends Uf{get;constructor(e,t,n){super(e,(r)=>ue(t(r)),(r,o)=>ue(n(r,o)));this.get=t,this.replace=n}modify(e){return(t)=>this.replace(e(this.get(t)),t)}}class dT extends Uf{set;constructor(e,t,n){super(e,t,(r,o)=>ue(n(r)));this.set=n}replace(e,t){return this.set(e)}modify(e){return(t)=>Mf(vr(this.getResult(t),(n)=>this.set(e(n))),()=>t)}}function Lr(e){let t=e[0]??VN;if(e.length>1){let n=e.reduce((r,o)=>XN(r,o.kind),"Iso");t={kind:n,get:QN(e,n),set:YN(e,n)}}switch(t.kind){case"Iso":return new fT(e,t.get,t.set);case"Lens":return new uT(e,t.get,t.set);case"Prism":return new dT(e,t.get,t.set);case"Optional":return new Uf(e,t.get,t.set)}}function zl(e){if(Array.isArray(e))return e.slice();if(typeof e==="object"&&e!==null){let t=Object.getPrototypeOf(e);if(t!==Object.prototype&&t!==null)throw Error("Cannot clone object with non-Object constructor or null prototype");return{...e}}return e}function QN(e,t){return(n)=>{for(let r=0;r<e.length;r++){let o=e[r],s=o.get(n);if(xx(o.kind)){if(Bt(s))return s;n=s.success}else n=s}return xx(t)?ue(n):n}}function YN(e,t){if(iT(t))return(n)=>{for(let r=e.length-1;r>=0;r--)n=e[r].set(n);return n};return(n,r)=>{let o=e.length,s=Array(o);for(let a=0;a<o;a++){s[a]=r;let i=e[a];if(xx(i.kind)){let c=i.get(r);if(Bt(c))return c;r=c.success}else r=i.get(r)}for(let a=o-1;a>=0;a--){let i=e[a];if(iT(i.kind))n=i.set(n);else if(i.kind==="Lens")n=i.set(n,s[a]);else{let c=i.set(n,s[a]);if(Bt(c))return c;n=c.success}}return t==="Optional"?ue(n):n}}function xx(e){return e==="Prism"||e==="Optional"}function iT(e){return e==="Iso"||e==="Prism"}function XN(e,t){if(e==="Iso")return t;if(t==="Iso"||e===t)return e;return"Optional"}var e1=Lr([]);function $l(){return e1}function lT(e){let t=_l(e);return cT(Al(t),Tl(t))}function pT(e){return $l()}function mT(e){return $l()}var zi="~effect/Schema/SchemaError";function hT(e){return V(e,zi)&&e[zi]===zi}var jn="~effect/net/NetAddress";var zr=(e)=>e.value,$r=(e)=>e,Vo=(e)=>e.bytes;class $i extends Qt("NetAddressError"){}var qi=(e)=>V(e,jn),rn=(e)=>qi(e)&&e._tag==="Ipv4Address",Io=(e)=>qi(e)&&e._tag==="Ipv6Address",gT=(e)=>rn(e)||Io(e),Hi=(e)=>rn(e)?32:128,ji=(e)=>qi(e)&&e._tag==="MacAddress",Df=(e)=>qi(e)&&e._tag==="InetAddressV4",Nf=(e)=>qi(e)&&e._tag==="InetAddressV6",Sx=(e)=>Df(e)||Nf(e),Hl=(e)=>qi(e)&&e._tag==="UnixPathAddress",xT=(e)=>Sx(e)||Hl(e),r1={_tag:"Ipv4Address",[jn]:jn,[ze](e){return rn(e)&&zr(this)===zr(e)},[Be](){return mo(Le(i1,zr(this)|0))},toString(){return qr(this)},toJSON(){return this.toString()},[Re](){return this.toJSON()}},o1={_tag:"Ipv6Address",[jn]:jn,[ze](e){if(!Io(e))return!1;let t=$r(this),n=$r(e);return t.w0===n.w0&&t.w1===n.w1&&t.w2===n.w2&&t.w3===n.w3},[Be](){let e=$r(this),t=Le(c1,e.w0|0);return t=Le(t,e.w1|0),t=Le(t,e.w2|0),mo(Le(t,e.w3|0))},toString(){return qr(this)},toJSON(){return this.toString()},[Re](){return this.toJSON()}},s1={_tag:"MacAddress",[jn]:jn,[ze](e){return ji(e)&&a1(Vo(this),Vo(e))},[Be](){return Le(f1,oi(Vo(this)))},toString(){return bx(this)},toJSON(){return this.toString()},[Re](){return this.toJSON()}},a1=(e,t)=>{if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;return!0},i1=mn("Ipv4Address"),c1=mn("Ipv6Address"),f1=mn("MacAddress"),u1=(e)=>{let t=Object.create(r1);return t.value=e>>>0,Object.freeze(t)},d1=(e,t,n,r)=>{let o=Object.create(o1);return o.w0=e>>>0,o.w1=t>>>0,o.w2=n>>>0,o.w3=r>>>0,Object.freeze(o)},l1=(e,t,n,r)=>(e<<24|t<<16|n<<8|r)>>>0;var Ff=(e)=>[e>>>24,e>>>16&255,e>>>8&255,e&255],p1=(e)=>{let t=Object.assign(Object.create(s1),{bytes:new Uint8Array(e)});return Object.freeze(t)};var it=(e,t)=>ge(new $i({input:e,message:t})),m1=(e)=>{if(!e.every((t)=>Number.isInteger(t)&&t>=0&&t<=255))return it(e,"octets must be integers from 0 through 255");return ue(u1(l1(e[0],e[1],e[2],e[3])))},h1=(e)=>{if(!e.every((t)=>Number.isInteger(t)&&t>=0&&t<=65535))return it(e,"segments must be integers from 0 through 65535");return ue(d1(e[0]*65536+e[1],e[2]*65536+e[3],e[4]*65536+e[5],e[6]*65536+e[7]))};var yT=(e)=>{if(!/^(?:[0-9a-fA-F]{2}:){5}[0-9a-fA-F]{2}$/.test(e))return it(e,"expected six two-digit hexadecimal octets separated by colons");return ue(p1(new Uint8Array(e.split(":").map((t)=>Number.parseInt(t,16)))))};var Wi=(e)=>{let t=e.split(".");if(t.length!==4||t.some((r)=>!/^\d{1,3}$/.test(r)))return it(e,"expected exactly four decimal octets");if(t.some((r)=>r.length>1&&r[0]==="0"))return it(e,"leading zeroes are not allowed");let n=t.map(Number);if(n.some((r)=>r>255))return it(e,"octets must be at most 255");return m1([n[0],n[1],n[2],n[3]])},g1=(e)=>{if(e.includes("[")||e.includes("]")||e.includes("%"))return it(e,"brackets and zone identifiers are not valid in a bare IPv6 address");let t=e.split("::");if(t.length>2)return it(e,"only one compression marker is allowed");let n=t[0]===""?[]:t[0].split(":"),r=t.length===2&&t[1]!==""?t[1].split(":"):[];if(n.some((u)=>u==="")||r.some((u)=>u===""))return it(e,"empty segments are only valid in the compression marker");let o=r.length>0?r[r.length-1]:n.length>0?n[n.length-1]:"",s;if(o.includes(".")){if(t.length===2&&r.length===0)return it(e,"embedded IPv4 syntax must be trailing");let u=vr(Wi(o),(d)=>{let l=zr(d);return[l>>>16,l&65535]});if(Bt(u))return u;if(s=u.success,r.length>0)r.pop();else n.pop()}let a=n.length+r.length+(s?2:0);if(t.length===1?a!==8:a>=8)return it(e,t.length===1?"expected eight segments":"compression must replace at least one segment");let i=(u)=>/^[0-9a-fA-F]{1,4}$/.test(u)?Number.parseInt(u,16):void 0,c=n.map(i),f=r.map(i);if(c.some((u)=>u===void 0)||f.some((u)=>u===void 0))return it(e,"segments must contain one through four hexadecimal digits");return ue([...c,...Array(8-a).fill(0),...f,...s??[]])},Bf=(e)=>Tt(g1(e),(t)=>h1(t)),Lf=(e)=>e.includes(":")?Bf(e):Wi(e);var Ex=(e)=>Ff(zr(e)),x1=(e)=>{let{w0:t,w1:n,w2:r,w3:o}=$r(e);return[t>>>16,t&65535,n>>>16,n&65535,r>>>16,r&65535,o>>>16,o&65535]},ST=(e)=>{let{w0:t,w1:n,w2:r,w3:o}=$r(e);return[...Ff(t),...Ff(n),...Ff(r),...Ff(o)]};var bx=(e)=>Array.from(Vo(e),(t)=>t.toString(16).padStart(2,"0")).join(":"),jl=(e)=>Vo(e).every((t)=>t===255),y1=(e)=>(Vo(e)[0]&1)!==0,Wl=(e)=>(Vo(e)[0]&1)===0,Ix=(e)=>(Vo(e)[0]&2)!==0,wx=(e)=>(Vo(e)[0]&2)===0;var qr=(e)=>{if(rn(e))return Ex(e).join(".");let t=x1(e);if(S1(e))return`::ffff:${t[6]>>8}.${t[6]&255}.${t[7]>>8}.${t[7]&255}`;let n=-1,r=0,o=-1;for(let i=0;i<=8;i++)if(i<8&&t[i]===0){if(o===-1)o=i}else if(o!==-1){if(i-o>r)n=o,r=i-o;o=-1}if(r<2)return t.map((i)=>i.toString(16)).join(":");let s=t.slice(0,n).map((i)=>i.toString(16)).join(":"),a=t.slice(n+r).map((i)=>i.toString(16)).join(":");return`${s}::${a}`},Jl=(e)=>{if(rn(e))return zr(e)===0;let{w0:t,w1:n,w2:r,w3:o}=$r(e);return t===0&&n===0&&r===0&&o===0},kx=(e)=>{if(rn(e))return zr(e)>>>24===127;let{w0:t,w1:n,w2:r,w3:o}=$r(e);return t===0&&n===0&&r===0&&o===1},Ji=(e)=>{if(ji(e))return y1(e);if(rn(e))return zr(e)>>>28===14;return $r(e).w0>>>24===255},Gl=(e)=>ji(e)?jl(e):zr(e)===4294967295,Tx=(e)=>{if(ji(e))return Wl(e);return!Ji(e)&&!Jl(e)&&(!rn(e)||!Gl(e))},Ax=(e)=>{if(rn(e))return zr(e)>>>16===43518;return($r(e).w0>>>16&65472)===65152},Cx=(e)=>{let t=zr(e);return t>>>24===10||(t>>>16&65520)===44048||t>>>16===49320},vx=(e)=>($r(e).w0>>>24&254)===252,S1=(e)=>{let{w0:t,w1:n,w2:r}=$r(e);return t===0&&n===0&&r===65535};var E1={_tag:"InetAddressV4",[jn]:jn,[ze](e){return Df(e)&&this.port===e.port&&he(this.address,e.address)},[Be](){return Le(We(this.address),Bn(this.port))},toString(){return Kl(this)},toJSON(){return this.toString()},[Re](){return this.toJSON()}},b1={_tag:"InetAddressV6",[jn]:jn,[ze](e){return Nf(e)&&this.port===e.port&&this.scopeId===e.scopeId&&he(this.address,e.address)},[Be](){return Le(Le(We(this.address),Bn(this.port)),Bn(this.scopeId))},toString(){return Kl(this)},toJSON(){return this.toString()},[Re](){return this.toJSON()}},ET=(e)=>Number.isInteger(e)&&e>=0&&e<=65535,I1=(e,t)=>{if(!ET(t))return it(e,"port must be an integer from 0 through 65535");let n=Object.create(E1);return n.address=e,n.port=t,ue(Object.freeze(n))},w1=(e,t,n)=>{if(!ET(t))return it(e,"port must be an integer from 0 through 65535");let r=n?.scopeId??0;if(!Number.isInteger(r)||r<0||r>4294967295)return it(e,"scopeId must be an unsigned 32-bit integer");let o=Object.create(b1);return o.address=e,o.port=t,o.scopeId=r,ue(Object.freeze(o))};var bT=(e)=>{let t,n,r=0,o=e.startsWith("[");if(o){let s=e.indexOf("]");if(s<0||e[s+1]!==":"||e.indexOf("]",s+1)!==-1)return it(e,"expected [IPv6]:port");t=e.slice(1,s),n=e.slice(s+2);let a=t.indexOf("%");if(a!==-1){let i=t.slice(a+1);if(t.indexOf("%",a+1)!==-1||!/^\d+$/.test(i))return it(e,"scope identifier must be decimal");if(r=Number(i),!Number.isInteger(r)||r>4294967295)return it(e,"scope identifier must be an unsigned 32-bit integer");t=t.slice(0,a)}}else{let s=e.lastIndexOf(":");if(s<0)return it(e,"expected host:port or [IPv6]:port");if(e.indexOf(":")!==s)return it(e,"IPv6 addresses must be bracketed");t=e.slice(0,s),n=e.slice(s+1)}if(!/^(0|[1-9]\d*)$/.test(n))return it(e,"port must be an unpadded decimal integer");return Tt(Lf(t),(s)=>{if(o!==Io(s))return it(e,"only IPv6 addresses use brackets");return Io(s)?w1(s,Number(n),{scopeId:r}):I1(s,Number(n))})};var k1=(e)=>qr(e.address)+(Nf(e)&&e.scopeId!==0?`%${e.scopeId}`:"");var Kl=(e)=>{let t=k1(e);return Df(e)?`${t}:${e.port}`:`[${t}]:${e.port}`};var T1={_tag:"UnixPathAddress",[jn]:jn,[ze](e){return Hl(e)&&this.path===e.path},[Be](){return Le(mn("UnixPathAddress"),mn(this.path))},toString(){return this.path},toJSON(){return this.toString()},[Re](){return this.toJSON()}},IT=(e)=>{let t=Object.create(T1);return t.path=e,Object.freeze(t)};var _x="~effect/net/IpInterface",wT=(e)=>zf(e)&&rn(e.address),kT=(e)=>zf(e)&&Io(e.address),zf=(e)=>V(e,_x),A1={_tag:"IpInterface",[_x]:_x,[ze](e){return zf(e)&&this.prefixLength===e.prefixLength&&he(this.address,e.address)},[Be](){return Le(We(this.address),Bn(this.prefixLength))},toString(){return qf(this)},toJSON(){return this.toString()},[Re](){return this.toJSON()}},Rx=(e,t)=>ge(new $i({input:e,message:t})),$f=(e,t)=>{let n=Hi(e);if(!Number.isInteger(t)||t<0||t>n)return Rx(e,`prefix length must be an integer from 0 through ${n}`);let r=Object.assign(Object.create(A1),{address:e,prefixLength:t});return ue(Object.freeze(r))},Px=(e,t)=>{let n=e.indexOf("/");if(n===-1&&t?.prefix!=="required")return ue({address:e,prefixLength:void 0});if(n<=0||n!==e.lastIndexOf("/")||n===e.length-1)return Rx(e,"expected an address and prefix length separated by one slash");let r=e.slice(n+1);if(!/^(0|[1-9][0-9]*)$/.test(r))return Rx(e,"prefix length must be an unpadded ASCII decimal integer");return ue({address:e.slice(0,n),prefixLength:Number(r)})},Vl=(e,t)=>Tt(Px(e,t),(n)=>Tt(Wi(n.address),(r)=>$f(r,n.prefixLength??Hi(r)))),Zl=(e,t)=>Tt(Px(e,t),(n)=>Tt(Bf(n.address),(r)=>$f(r,n.prefixLength??Hi(r)))),Ql=(e,t)=>Tt(Px(e,t),(n)=>Tt(Lf(n.address),(r)=>$f(r,n.prefixLength??Hi(r))));var qf=(e)=>`${qr(e.address)}/${e.prefixLength}`;var Mx="~effect/net/IpNetwork",AT=(e)=>Hf(e)&&rn(e.address),CT=(e)=>Hf(e)&&Io(e.address),Hf=(e)=>V(e,Mx),C1={_tag:"IpNetwork",[Mx]:Mx,[ze](e){return Hf(e)&&this.prefixLength===e.prefixLength&&he(this.address,e.address)},[Be](){return Le(We(this.address),Bn(this.prefixLength))},toString(){return jf(this)},toJSON(){return this.toString()},[Re](){return this.toJSON()}},v1=(e)=>{let t=Object.assign(Object.create(C1),{address:e.address,prefixLength:e.prefixLength});return Object.freeze(t)},O1=(e)=>rn(e)?Ex(e):ST(e);var _1=(e,t)=>{let n=Math.floor(t/8),r=t%8;return e.map((o,s)=>{if(s<n)return o;if(s===n&&r!==0)return o&(255<<8-r&255);return 0})},Ux=(e,t)=>Tt($f(e,t),(n)=>{let r=O1(e),o=_1(r,t);if(r.some((s,a)=>s!==o[a]))return ge(new $i({input:e,message:"address has non-zero host bits"}));return ue(v1(n))});var vT=(e)=>Tt(Vl(e,{prefix:"required"}),(t)=>Ux(t.address,t.prefixLength)),OT=(e)=>Tt(Zl(e,{prefix:"required"}),(t)=>Ux(t.address,t.prefixLength)),_T=(e)=>Tt(Ql(e,{prefix:"required"}),(t)=>Ux(t.address,t.prefixLength));var jf=(e)=>`${qr(e.address)}/${e.prefixLength}`;var Wf=vl;function Wt(){return(e,t,n)=>H(new Cs(e.map(If),(r)=>t(r.map((o)=>H(o))),n))}function we(e,t){return Wt()([],()=>(n,r,o)=>e(n)?b(n):_(new Fe(r,n,o)),t)}function P1(e){return e}function M1(e){return(t)=>t.annotate(e)}function U1(e){return(t)=>Dx(Dx(t).annotate(e))}function F1(e){return(t)=>t.rebuild(Ri(t.ast,e))}function D1(e){return e}class Rn extends Qt("SchemaError"){[zi]=zi;constructor(e){let t=jT();Fx(0);try{super({issue:e})}finally{Fx(t)}}get message(){return $I(this.issue)}toString(){return`SchemaError(${this.message})`}}function sc(e){return hT(e)}function QT(e){if(qt(e))return jx(e);return De(e,(t)=>Os(()=>Ts(t,(n)=>new Rn(n))))}function jx(e){return $e(e)?e:en(Ts(e.cause,(t)=>new Rn(t)))}function YT(e,t){let n;for(let r of e.reasons){if(!Ld(r)||!sc(r.error))throw new globalThis.Error(t,{cause:e});n??=r.error}if(n===void 0)throw new globalThis.Error(t,{cause:e});return n}function XT(e){return Gg(e).then((t)=>{if($e(t))return t.value;throw YT(t.cause,"Promise adapter can only reject schema errors")})}function eA(e){let t=Jo(e);if($e(t))return t.value;throw YT(t.cause,"Sync adapter can only throw schema errors")}function N1(e,t){return H0(e,t)}function B1(e){return j0(e)}var L1=Vg,z1=Yk;function Ms(e,t){let n=qe(e,t);return(r,o)=>QT(n(r,o))}var $1=Ms;function tA(e,t){let n=Xk(e,t);return(r,o)=>jx(n(r,o))}var q1=tA,H1=Qg,j1=e0;function nA(e,t){let n=t0(e,t);return(r,o)=>qx(n(r,o),(s)=>new Rn(s))}var W1=nA;function rA(e,t){let n=Ms(e,t);return(r,o)=>XT(n(r,o))}var J1=rA;function Xl(e,t){let n=Ms(e,t);return(r,o)=>eA(n(r,o))}var Wx=Xl;function Xf(e,t){let n=Ia(e,t);return(r,o)=>QT(n(r,o))}var Jx=Xf;function oA(e,t){let n=r0(e,t);return(r,o)=>jx(n(r,o))}var G1=oA,K1=Yg,V1=o0;function sA(e,t){let n=s0(e,t);return(r,o)=>qx(n(r,o),(s)=>new Rn(s))}var Z1=sA;function aA(e,t){let n=Xf(e,t);return(r,o)=>XT(n(r,o))}var Q1=aA;function eu(e,t){let n=Xf(e,t);return(r,o)=>eA(n(r,o))}var Y1=eu,H=Nr;function va(e){return V(e,Wf)&&e[Wf]===Wf}var Ca=nn((e)=>H(ba(e.ast),{schema:e})),X1=nn((e)=>e.schema),mt=nn((e)=>{let t=np(e);return H(Ok(e.ast),{schema:t})}),eB=nn((e)=>e.schema.members[0]),tB=nn((e)=>H(Fg(e.ast),{schema:e})),nB=nn((e)=>e.schema),Pn=nn((e)=>H(Ve(e.ast),{schema:e})),ac=nn((e)=>H(En(e.ast),{schema:e})),Jf="~effect/Schema/flip";function rB(e){return V(e,Jf)&&e[Jf]===Jf}function Dx(e){if(rB(e))return e.schema.rebuild(qn(e.ast));return H(qn(e.ast),{[Jf]:Jf,schema:e})}function pt(e){let t=H(new yn(e),{literal:e,transform(n){return t.pipe(Z(pt(n),{decode:se(()=>n),encode:se(()=>e)}))}});return t}function iA(e){return e.map((t)=>va(t)?t.ast:new yn(t))}function oB(e){return H(new kg(iA(e)),{parts:e})}function sB(e){return H(fk(iA(e)),{parts:e})}function aB(e){return H(new ck(Object.keys(e).filter((t)=>typeof e[e[t]]!=="number").map((t)=>[t,e[t]])),{enums:e})}var tu=H(wg),iB=H(ak),nu=H(jo),ep=H(bg),Gx=H(Ig),z=H($n),cB=z,Oa=H(Tg),ru=H(lk),cA=H(pk),ic=H(mk),cc=H(sk),fB=H(ik);function uB(e){return H(new dk(e))}function Kx(e,t){return H(e,{fields:t,mapFields(n,r){let o=n(this.fields);return Kx(ll(o,r?.unsafePreserveChecks?this.ast.checks:void 0),o)}})}function ae(e){return Kx(ll(e,void 0),e)}function dB(e){return nn((t)=>t.mapFields(rT(e)))}var lB=(e)=>typeof e==="symbol"?e:globalThis.String(e);function pB(e){return function(t){let n={},r=Object.create(null),o=Object.create(null),s=new Set;for(let a of Reflect.ownKeys(t.fields)){let i=ac(t.fields[a]),c=Object.hasOwn(e,a),f=c?e[a]:a,u=lB(f);if(s.has(u))throw new globalThis.Error(`Duplicate encoded keys: ${Sa(f)}`);if(s.add(u),q(n,f,i),c)r[a]=f,o[f]=a}return ae(n).pipe(Z(t,xe({decode:hx(o),encode:hx(r)})))}}function mB(e,t){return(n)=>{let r=Cd(n.fields,Pn),o=ae({...r,...e});return n.pipe(Z(o,xe({decode:(s)=>{let a={...s};for(let i in e){let c=t[i],f=c(s);if(ve(f))q(a,i,f.value)}return a},encode:(s)=>{let a={...s};for(let i in e)delete a[i];return a}})))}}function _a(e,t){return H(Rk(e.ast,t.ast),{key:e,value:t})}function hB(e,t){return H(Sk(e.ast,t.map(If)),{schema:e,records:t})}function fA(e,t){return H(e,{elements:t,mapElements(n,r){let o=n(this.elements);return fA(Og(o,r?.unsafePreserveChecks?this.ast.checks:void 0),o)}})}function cr(e){return fA(Og(e),e)}function gB(e,t){return H(Ek(e.ast,t.map(If)),{schema:e,rest:t})}var Oe=nn((e)=>H(new ar(!1,[],[e.ast]),{value:e}));function tp(e,t,n){if(t!==void 0&&n!==void 0)return e.check(Xx(t,n));if(t!==void 0)return e.check(OA(t));if(n!==void 0)return e.check(PA(n));return e}var fc=nn((e)=>H(new ar(!1,[e.ast],[e.ast]),{value:e}));function xB(e){let t=Oe(e),n=Oe(Pn(e)),r=Z(cr([nu]),xe({decode:(o)=>[o],encode:([o])=>o}))(e);return H(Ie([r,t]).pipe(Z(n)).ast,{from:Ie([e,t]),to:n})}function yB(e){return Oe(e).check(ty())}var SB=nn((e)=>H(bk(e.ast),{schema:e}));function uA(e,t){return H(e,{members:t,mapMembers(n,r){let o=n(this.members);return uA(pl(o,this.ast.options,r?.unsafePreserveChecks?this.ast.checks:void 0),o)}})}function Ie(e,t){return uA(pl(e,t,void 0),e)}function ur(e){let t=e.map(pt);return H(pl(t,void 0,void 0),{literals:e,members:t,mapMembers(n){return Ie(n(this.members))},pick(n){return ur(n)},transform(n){return Ie(t.map((r,o)=>r.transform(n[o])))}})}var Vx=nn((e)=>Ie([e,ep])),np=nn((e)=>Ie([e,Gx])),dA=nn((e)=>Ie([e,ep,Gx]));function lA(e){return H(new Rg(()=>e().ast))}function EB(...e){return(t)=>t.check(...e)}function pA(e,t){return(n)=>H(Eo(n.ast,[hl(e,t)]),{schema:n})}function mA(e){return(t)=>H(t.ast,{schema:t,identifier:e})}function bB(e,t){return(n)=>(t.checks?n.check(...t.checks):n).pipe(mA(e))}function hA(e){return(t)=>H(Ck(t.ast,new Qd(e,Q)),{schema:t})}function gA(e){return(t)=>H(vk(t.ast,new Qd(Q,e)),{schema:t})}function IB(e){return xA(e)}function xA(e){return(t)=>hA(Hx(e))(t)}function wB(e){return yA(e)}function yA(e){return(t)=>gA(Hx(e))(t)}function Z(e,t){return(n)=>H(Pi(n.ast,e.ast,t?Yd(t):Ii()),{from:n,to:e})}function uc(){return(e,t)=>Se()(e,{decode:t,encode:QI})}var SA=ur(["true","yes","on","1","y"]),EA=ur(["false","no","off","0","n"]),kB=ur([...SA.literals,...EA.literals]).pipe(Z(ru,xe({decode:(e)=>e==="true"||e==="yes"||e==="on"||e==="1"||e==="y",encode:(e)=>e?"true":"false"})));function TB(e){return(t)=>Z(Pn(t),e)(t)}function Zx(e,t){return(n)=>t?Z(n,t)(e):Z(n)(e)}function AB(e){return(t)=>Z(t,e)(ac(t))}function bA(e){return(t)=>H(_k(t.ast,e),{schema:t})}function IA(e){return De(e,(t)=>Os(()=>Ts(t,(n)=>n.issue)))}function Qx(e,t){let n=t?.encodingStrategy==="omit"?tg():xo();return(r)=>Ca(ac(r)).pipe(Z(r,{decode:ng(IA(e)),encode:n}))}function CB(e,t){return(n)=>Pn(n).pipe(Qx(e,t),Zx(Ca(n)))}function wA(e,t){let n=t?.encodingStrategy==="omit"?tg():xo();return(r)=>mt(ac(r)).pipe(Z(r,{decode:ng(IA(e)),encode:n}))}function vB(e,t){return(n)=>Pn(n).pipe(wA(e,t),Zx(mt(n)))}function ye(e){return pt(e).pipe(bA(b(e)))}function OB(e){return ye(e).pipe(Qx(b(e),{encodingStrategy:"omit"}))}function rp(e,t){return ae({_tag:ye(e),...t})}function kA(e){return(t)=>{let n={},r=[],o=new Set,s={},a=(u)=>(d)=>u.includes(d[e]);return i(t),Object.assign(t,{cases:n,discriminants:r,isAnyOf:a,guards:s,match:c,matchOrElse:f});function i(u){let d=u.ast;if(nk(d)&&"members"in u&&globalThis.Array.isArray(u.members)&&u.members.every(va))return u.members.forEach(i);let l=ks(d);if(l.length>0){let m=l.find((p)=>p.key===e)?.literal;if(il(m)){let p=typeof m==="number"?globalThis.String(m):m;if(o.has(p))throw new globalThis.Error(`Duplicate discriminant: ${globalThis.String(m)}`);o.add(p),r.push(m),q(n,m,u),q(s,m,Vg(Pn(u)));return}}throw new globalThis.Error("No literal or unique symbol found")}function c(){if(arguments.length===1){let p=arguments[0];return function(g){let h=g[e];return(Object.hasOwn(p,h)?p[h]:void 0)(g)}}let u=arguments[0],d=arguments[1],l=u[e];return(Object.hasOwn(d,l)?d[l]:void 0)(u)}function f(){if(arguments.length===2){let g=arguments[0],h=arguments[1];return function(E){let S=E[e];return(Object.hasOwn(g,S)?g[S]??h:h)(E)}}let u=arguments[0],d=arguments[1],l=arguments[2],m=u[e];return(Object.hasOwn(d,m)?d[m]??l:l)(u)}}}function _B(e){let t={},n=[];for(let c of Object.keys(e)){let f=rp(c,e[c]);q(t,c,f),n.push(f)}let r=Ie(n),{guards:o,isAnyOf:s,match:a,matchOrElse:i}=kA("_tag")(r);return H(r.ast,{cases:t,isAnyOf:s,guards:o,match:a,matchOrElse:i})}function RB(){return(e)=>e}function Us(e,t){return we((n)=>n instanceof e,t)}function Se(){return(e,t)=>new Xe(e.ast,Yd(t))}var ke=ml;function PB(e,t=void 0){return new ga(e,t)}var RT="^\\S[\\s\\S]*\\S$|^\\S$|^$";function TA(e){let t=new globalThis.RegExp(RT);return ke((n)=>n.trim()===n,{expected:"a string with no leading or trailing whitespace",representation:{id:"effect/schema/isTrimmed",payload:null},toJsonSchema:()=>({pattern:t.source}),toCode:()=>({runtime:"Schema.isTrimmed()"}),arbitraryConstraint:{patterns:[{source:RT,flags:""}]},...e})}function dc(e,t){let{source:n,flags:r}=e,o=/^[dg]*uy?$/.test(r),s=r===""?`new RegExp(${K(n)})`:`new RegExp(${K(n)}, ${K(r)})`;return kf(e,{toJsonSchema:()=>o?{pattern:r.endsWith("y")?`^(?:${n})`:n}:[{},!0],toCode:()=>({runtime:`Schema.isPattern(${s})`}),...t})}function MB(e){return Bg({toCode:()=>({runtime:"Schema.isStringFinite()"}),...e})}function UB(e){return Lg({toCode:()=>({runtime:"Schema.isStringBigInt()"}),...e})}function FB(e){return $g({toCode:()=>({runtime:"Schema.isStringSymbol()"}),...e})}var DB=(e)=>{if(e)return new globalThis.RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${e}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`);return/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|[fF]{8}-[fF]{4}-[fF]{4}-[fF]{4}-[fF]{12})$/};function NB(e,t){let n=DB(e);return dc(n,{expected:e?`a UUID v${e}`:"a UUID",representation:{id:"effect/schema/isUUID",payload:{version:e??null}},toJsonSchema:()=>({pattern:n.source,format:"uuid"}),toCode:()=>({runtime:e===void 0?"Schema.isUUID()":`Schema.isUUID(${e})`}),...t})}var PT=/^([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})$/;function BB(e){return dc(PT,{expected:"a GUID",representation:{id:"effect/schema/isGUID",payload:null},toJsonSchema:()=>({pattern:PT.source}),toCode:()=>({runtime:"Schema.isGUID()"}),...e})}function LB(e){let t=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/;return dc(t,{representation:{id:"effect/schema/isULID",payload:null},toJsonSchema:()=>({pattern:t.source}),toCode:()=>({runtime:"Schema.isULID()"}),...e})}function AA(e){let t=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/;return dc(t,{expected:"a base64 encoded string",representation:{id:"effect/schema/isBase64",payload:null},toJsonSchema:()=>({pattern:t.source}),toCode:()=>({runtime:"Schema.isBase64()"}),...e})}function zB(e){let t=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/;return dc(t,{expected:"a base64url encoded string",representation:{id:"effect/schema/isBase64Url",payload:null},toJsonSchema:()=>({pattern:t.source}),toCode:()=>({runtime:"Schema.isBase64Url()"}),...e})}function Yx(e,t,n){if(e.length===0)return t.length===0?{}:[{},!0];let r={pattern:new globalThis.RegExp(n).source};return e===t?r:[r,!0]}function $B(e,t){let n=JSON.stringify(e),r=new globalThis.RegExp(`^${Ko(e)}`),o=e.replace(/[\uD800-\uDBFF]$/,"");return ke((s)=>s.startsWith(e),{expected:`a string starting with ${n}`,representation:{id:"effect/schema/isStartingWith",payload:{startsWith:e}},toJsonSchema:()=>Yx(o,e,`^${Ko(o)}`),toCode:()=>({runtime:`Schema.isStartingWith(${K(e)})`}),arbitraryConstraint:{patterns:[{source:r.source,flags:r.flags}]},...t})}function qB(e,t){let n=JSON.stringify(e),r=new globalThis.RegExp(`${Ko(e)}$`),o=e.replace(/^[\uDC00-\uDFFF]/,"");return ke((s)=>s.endsWith(e),{expected:`a string ending with ${n}`,representation:{id:"effect/schema/isEndingWith",payload:{endsWith:e}},toJsonSchema:()=>Yx(o,e,`${Ko(o)}$`),toCode:()=>({runtime:`Schema.isEndingWith(${K(e)})`}),arbitraryConstraint:{patterns:[{source:r.source,flags:r.flags}]},...t})}function HB(e,t){let n=JSON.stringify(e),r=new globalThis.RegExp(Ko(e)),o=e.replace(/^[\uDC00-\uDFFF]|[\uD800-\uDBFF]$/g,"");return ke((s)=>s.includes(e),{expected:`a string including ${n}`,representation:{id:"effect/schema/isIncluding",payload:{includes:e}},toJsonSchema:()=>Yx(o,e,Ko(o)),toCode:()=>({runtime:`Schema.isIncluding(${K(e)})`}),arbitraryConstraint:{patterns:[{source:r.source,flags:r.flags}]},...t})}var MT="^[^a-z]*$";function jB(e){let t=new globalThis.RegExp(MT);return ke((n)=>n.toUpperCase()===n,{expected:"a string with all characters in uppercase",representation:{id:"effect/schema/isUppercased",payload:null},toJsonSchema:()=>[{pattern:t.source},!0],toCode:()=>({runtime:"Schema.isUppercased()"}),arbitraryConstraint:{patterns:[{source:MT,flags:""}]},...e})}var UT="^[^A-Z]*$";function WB(e){let t=new globalThis.RegExp(UT);return ke((n)=>n.toLowerCase()===n,{expected:"a string with all characters in lowercase",representation:{id:"effect/schema/isLowercased",payload:null},toJsonSchema:()=>[{pattern:t.source},!0],toCode:()=>({runtime:"Schema.isLowercased()"}),arbitraryConstraint:{patterns:[{source:UT,flags:""}]},...e})}var FT="^(?:[^a-z][\\s\\S]*)?$";function JB(e){let t=new globalThis.RegExp(FT);return ke((n)=>n.charAt(0).toUpperCase()===n.charAt(0),{expected:"a string with the first character in uppercase",representation:{id:"effect/schema/isCapitalized",payload:null},toJsonSchema:()=>[{pattern:t.source},!0],toCode:()=>({runtime:"Schema.isCapitalized()"}),arbitraryConstraint:{patterns:[{source:FT,flags:""}]},...e})}var DT="^(?:[^A-Z][\\s\\S]*)?$";function GB(e){let t=new globalThis.RegExp(DT);return ke((n)=>n.charAt(0).toLowerCase()===n.charAt(0),{expected:"a string with the first character in lowercase",representation:{id:"effect/schema/isUncapitalized",payload:null},toJsonSchema:()=>[{pattern:t.source},!0],toCode:()=>({runtime:"Schema.isUncapitalized()"}),arbitraryConstraint:{patterns:[{source:DT,flags:""}]},...e})}var op=H(Mg),KB=Pg;function ou(e){let t=id(e.order),n=e.formatter??K;return(r,o)=>ke((s)=>t(s,r),{expected:`a value greater than ${n(r)}`,arbitraryConstraint:{order:e.order,minimum:r,exclusiveMinimum:!0},...e.annotate?.(r),...o})}function su(e){let t=fd(e.order),n=e.formatter??K;return(r,o)=>ke((s)=>t(s,r),{expected:`a value greater than or equal to ${n(r)}`,arbitraryConstraint:{order:e.order,minimum:r},...e.annotate?.(r),...o})}function au(e){let t=ad(e.order),n=e.formatter??K;return(r,o)=>ke((s)=>t(s,r),{expected:`a value less than ${n(r)}`,arbitraryConstraint:{order:e.order,maximum:r,exclusiveMaximum:!0},...e.annotate?.(r),...o})}function iu(e){let t=cd(e.order),n=e.formatter??K;return(r,o)=>ke((s)=>t(s,r),{expected:`a value less than or equal to ${n(r)}`,arbitraryConstraint:{order:e.order,maximum:r},...e.annotate?.(r),...o})}function cu(e){let t=fd(e.order),n=id(e.order),r=cd(e.order),o=ad(e.order),s=e.formatter??K;return(a,i)=>{let c=a.exclusiveMinimum?n:t,f=a.exclusiveMaximum?o:r;return ke((u)=>c(u,a.minimum)&&f(u,a.maximum),{expected:`a value between ${s(a.minimum)}${a.exclusiveMinimum?" (excluded)":""} and ${s(a.maximum)}${a.exclusiveMaximum?" (excluded)":""}`,arbitraryConstraint:{order:e.order,minimum:a.minimum,maximum:a.maximum,...a.exclusiveMinimum&&{exclusiveMinimum:!0},...a.exclusiveMaximum&&{exclusiveMaximum:!0}},...e.annotate?.(a),...i})}}function VB(e){return(t,n)=>{let r=e.formatter??K;return ke((o)=>e.remainder(o,t)===e.zero,{expected:`a value that is a multiple of ${r(t)}`,...e.annotate?.(t),...n})}}function Gi(e){if(!globalThis.Number.isFinite(e))throw new globalThis.RangeError(`Expected a finite number, got ${K(e)}`);return e}var ZB=ou({order:Zi,annotate:(e)=>({representation:{id:"effect/schema/isGreaterThan",payload:{exclusiveMinimum:Gi(e)}},toJsonSchema:()=>({exclusiveMinimum:e}),toCode:()=>({runtime:`Schema.isGreaterThan(${K(e)})`})})}),CA=su({order:Zi,annotate:(e)=>({representation:{id:"effect/schema/isGreaterThanOrEqualTo",payload:{minimum:Gi(e)}},toJsonSchema:()=>({minimum:e}),toCode:()=>({runtime:`Schema.isGreaterThanOrEqualTo(${K(e)})`})})}),QB=au({order:Zi,annotate:(e)=>({representation:{id:"effect/schema/isLessThan",payload:{exclusiveMaximum:Gi(e)}},toJsonSchema:()=>({exclusiveMaximum:e}),toCode:()=>({runtime:`Schema.isLessThan(${K(e)})`})})}),YB=iu({order:Zi,annotate:(e)=>({representation:{id:"effect/schema/isLessThanOrEqualTo",payload:{maximum:Gi(e)}},toJsonSchema:()=>({maximum:e}),toCode:()=>({runtime:`Schema.isLessThanOrEqualTo(${K(e)})`})})}),sp=cu({order:Zi,annotate:(e)=>{let t=e.exclusiveMinimum?!0:void 0,n=e.exclusiveMaximum?!0:void 0;return{representation:{id:"effect/schema/isBetween",payload:{minimum:Gi(e.minimum),maximum:Gi(e.maximum),...t&&{exclusiveMinimum:t},...n&&{exclusiveMaximum:n}}},toJsonSchema:()=>({[t?"exclusiveMinimum":"minimum"]:e.minimum,[n?"exclusiveMaximum":"maximum"]:e.maximum}),toCode:()=>({runtime:`Schema.isBetween({ minimum: ${K(e.minimum)}, maximum: ${K(e.maximum)}, exclusiveMinimum: ${K(t)}, exclusiveMaximum: ${K(n)} })`})}}});function XB(e,t){if(!globalThis.Number.isFinite(e)||e===0)throw new globalThis.RangeError(`Expected a finite non-zero number, got ${globalThis.String(e)}`);return e=globalThis.Math.abs(e),ke((n)=>ZT(n,e)===0,{expected:`a value that is a multiple of ${e}`,representation:{id:"effect/schema/isMultipleOf",payload:{divisor:e}},toJsonSchema:()=>({multipleOf:e}),toCode:()=>({runtime:`Schema.isMultipleOf(${K(e)})`}),...t})}function ap(e){return ke((t)=>globalThis.Number.isSafeInteger(t),{expected:"an integer",representation:{id:"effect/schema/isInt",payload:null},toJsonSchema:()=>[{type:"integer"},!0],toCode:()=>({runtime:"Schema.isInt()"}),arbitraryConstraint:{number:"integer"},...e})}var wo=Oa.check(ap()),Aa=wo.check(CA(0));function eL(e){return new ga([ap(),sp({minimum:-2147483648,maximum:2147483647})],{expected:"a 32-bit integer",...e})}function tL(e){return new ga([ap(),sp({minimum:0,maximum:4294967295})],{expected:"a 32-bit unsigned integer",...e})}function Ki(e){if(globalThis.Number.isNaN(e.getTime()))throw new globalThis.RangeError(`Expected a valid Date, got ${K(e)}`);return e.toISOString()}function Vi(e){return`new Date(${K(e.getTime())})`}var nL=ou({order:Yi,annotate:(e)=>({representation:{id:"effect/schema/isGreaterThanDate",payload:{exclusiveMinimum:Ki(e)}},toJsonSchema:()=>[{},!0],toCode:()=>({runtime:`Schema.isGreaterThanDate(${Vi(e)})`})})}),rL=su({order:Yi,annotate:(e)=>({representation:{id:"effect/schema/isGreaterThanOrEqualToDate",payload:{minimum:Ki(e)}},toJsonSchema:()=>[{},!0],toCode:()=>({runtime:`Schema.isGreaterThanOrEqualToDate(${Vi(e)})`})})}),oL=au({order:Yi,annotate:(e)=>({representation:{id:"effect/schema/isLessThanDate",payload:{exclusiveMaximum:Ki(e)}},toJsonSchema:()=>[{},!0],toCode:()=>({runtime:`Schema.isLessThanDate(${Vi(e)})`})})}),sL=iu({order:Yi,annotate:(e)=>({representation:{id:"effect/schema/isLessThanOrEqualToDate",payload:{maximum:Ki(e)}},toJsonSchema:()=>[{},!0],toCode:()=>({runtime:`Schema.isLessThanOrEqualToDate(${Vi(e)})`})})}),aL=cu({order:Yi,annotate:(e)=>{let t=e.exclusiveMinimum?!0:void 0,n=e.exclusiveMaximum?!0:void 0;return{representation:{id:"effect/schema/isBetweenDate",payload:{minimum:Ki(e.minimum),maximum:Ki(e.maximum),...t&&{exclusiveMinimum:t},...n&&{exclusiveMaximum:n}}},toJsonSchema:()=>[{},!0],toCode:()=>({runtime:`Schema.isBetweenDate({ minimum: ${Vi(e.minimum)}, maximum: ${Vi(e.maximum)}, exclusiveMinimum: ${K(t)}, exclusiveMaximum: ${K(n)} })`})}}}),iL=ou({order:Qi,annotate:(e)=>({representation:{id:"effect/schema/isGreaterThanBigInt",payload:{exclusiveMinimum:e.toString(10)}},toJsonSchema:()=>[{},!0],toCode:()=>({runtime:`Schema.isGreaterThanBigInt(${K(e)})`})})}),vA=su({order:Qi,annotate:(e)=>({representation:{id:"effect/schema/isGreaterThanOrEqualToBigInt",payload:{minimum:e.toString(10)}},toJsonSchema:()=>[{},!0],toCode:()=>({runtime:`Schema.isGreaterThanOrEqualToBigInt(${K(e)})`})})}),cL=au({order:Qi,annotate:(e)=>({representation:{id:"effect/schema/isLessThanBigInt",payload:{exclusiveMaximum:e.toString(10)}},toJsonSchema:()=>[{},!0],toCode:()=>({runtime:`Schema.isLessThanBigInt(${K(e)})`})})}),fL=iu({order:Qi,annotate:(e)=>({representation:{id:"effect/schema/isLessThanOrEqualToBigInt",payload:{maximum:e.toString(10)}},toJsonSchema:()=>[{},!0],toCode:()=>({runtime:`Schema.isLessThanOrEqualToBigInt(${K(e)})`})})}),uL=cu({order:Qi,annotate:(e)=>{let t=e.exclusiveMinimum?!0:void 0,n=e.exclusiveMaximum?!0:void 0;return{representation:{id:"effect/schema/isBetweenBigInt",payload:{minimum:e.minimum.toString(10),maximum:e.maximum.toString(10),...t&&{exclusiveMinimum:t},...n&&{exclusiveMaximum:n}}},toJsonSchema:()=>[{},!0],toCode:()=>({runtime:`Schema.isBetweenBigInt({ minimum: ${K(e.minimum)}, maximum: ${K(e.maximum)}, exclusiveMinimum: ${K(t)}, exclusiveMaximum: ${K(n)} })`})}}});function OA(e,t){return e=on(e),_A(e,Math.ceil(e/2),t)}function _A(e,t,n){return ke((r)=>r.length>=e,{expected:`a value with a length of at least ${e}`,representation:{id:"effect/schema/isMinLength",payload:{minLength:e}},toJsonSchema:({type:r})=>r==="string"?e<=1?{minLength:t}:[{minLength:t},!0]:r==="array"?{minItems:e}:r===void 0?[{minLength:t,minItems:e},!0]:[{},!0],toCode:()=>({runtime:`Schema.isMinLength(${e})`}),[An]:!0,arbitraryConstraint:{minLength:e},...n})}function RA(e){return _A(1,1,e)}function PA(e,t){return e=on(e),ke((n)=>n.length<=e,{expected:`a value with a length of at most ${e}`,representation:{id:"effect/schema/isMaxLength",payload:{maxLength:e}},toJsonSchema:({type:n})=>n==="string"?e===0?{maxLength:e}:[{maxLength:e},!0]:n==="array"?{maxItems:e}:n===void 0?[{maxLength:e,maxItems:e},!0]:[{},!0],toCode:()=>({runtime:`Schema.isMaxLength(${e})`}),[An]:!0,arbitraryConstraint:{maxLength:e},...t})}function Xx(e,t,n){return e=on(e),t=on(t),ke((r)=>r.length>=e&&r.length<=t,{expected:e===t?`a value with a length of ${e}`:`a value with a length between ${e} and ${t}`,representation:{id:"effect/schema/isBetweenLength",payload:{minimum:e,maximum:t}},toJsonSchema:({type:r})=>r==="string"?t===0||Math.ceil(e/2)>t?{minLength:Math.ceil(e/2),maxLength:t}:[{minLength:Math.ceil(e/2),maxLength:t},!0]:r==="array"?{minItems:e,maxItems:t}:r===void 0?[{minLength:Math.ceil(e/2),maxLength:t,minItems:e,maxItems:t},!0]:[{},!0],toCode:()=>({runtime:`Schema.isBetweenLength(${e}, ${t})`}),[An]:!0,arbitraryConstraint:{minLength:e,maxLength:t},...n})}function dL(e,t){return e=on(e),ke((n)=>ey(n,e)>=e,{expected:`a string with at least ${e} code points`,representation:{id:"effect/schema/isMinCodePoints",payload:{minCodePoints:e}},toJsonSchema:()=>({minLength:e}),toCode:()=>({runtime:`Schema.isMinCodePoints(${e})`}),arbitraryConstraint:{minCodePoints:e},...t})}function lL(e,t){return e=on(e),ke((n)=>ey(n,e+1)<=e,{expected:`a string with at most ${e} code points`,representation:{id:"effect/schema/isMaxCodePoints",payload:{maxCodePoints:e}},toJsonSchema:()=>({maxLength:e}),toCode:()=>({runtime:`Schema.isMaxCodePoints(${e})`}),arbitraryConstraint:{maxCodePoints:e},...t})}function pL(e,t,n){return e=on(e),t=on(t),ke((r)=>{let o=ey(r,t+1);return o>=e&&o<=t},{expected:e===t?`a string with ${e} code points`:`a string with between ${e} and ${t} code points`,representation:{id:"effect/schema/isBetweenCodePoints",payload:{minimum:e,maximum:t}},toJsonSchema:()=>({allOf:[{minLength:e},{maxLength:t}]}),toCode:()=>({runtime:`Schema.isBetweenCodePoints(${e}, ${t})`}),arbitraryConstraint:{minCodePoints:e,maxCodePoints:t},...n})}function ey(e,t){if(t===0)return 0;let n=0;for(let r of e)if(++n>=t)break;return n}function on(e){if(!globalThis.Number.isFinite(e))throw new globalThis.RangeError(`Expected a finite number, got ${e}`);return Math.max(0,Math.floor(e))}function mL(e,t){return e=on(e),ke((n)=>n.size>=e,{expected:`a value with a size of at least ${e}`,representation:{id:"effect/schema/isMinSize",payload:{minSize:e}},toJsonSchema:()=>[{},!0],toCode:()=>({runtime:`Schema.isMinSize(${e})`}),[An]:!0,arbitraryConstraint:{minSize:e},...t})}function hL(e,t){return e=on(e),ke((n)=>n.size<=e,{expected:`a value with a size of at most ${e}`,representation:{id:"effect/schema/isMaxSize",payload:{maxSize:e}},toJsonSchema:()=>[{},!0],toCode:()=>({runtime:`Schema.isMaxSize(${e})`}),[An]:!0,arbitraryConstraint:{maxSize:e},...t})}function gL(e,t,n){return e=on(e),t=on(t),ke((r)=>r.size>=e&&r.size<=t,{expected:e===t?`a value with a size of ${e}`:`a value with a size between ${e} and ${t}`,representation:{id:"effect/schema/isBetweenSize",payload:{minimum:e,maximum:t}},toJsonSchema:()=>[{},!0],toCode:()=>({runtime:`Schema.isBetweenSize(${e}, ${t})`}),[An]:!0,arbitraryConstraint:{minSize:e,maxSize:t},...n})}function xL(e,t){return e=on(e),ke((n)=>Reflect.ownKeys(n).length>=e,{expected:`a value with at least ${e===1?"1 entry":`${e} entries`}`,representation:{id:"effect/schema/isMinProperties",payload:{minProperties:e}},toJsonSchema:({type:n})=>n==="object"?{minProperties:e}:[{minProperties:e},!0],toCode:()=>({runtime:`Schema.isMinProperties(${e})`}),[An]:!0,arbitraryConstraint:{minProperties:e},...t})}function yL(e,t){return e=on(e),ke((n)=>Reflect.ownKeys(n).length<=e,{expected:`a value with at most ${e===1?"1 entry":`${e} entries`}`,representation:{id:"effect/schema/isMaxProperties",payload:{maxProperties:e}},toJsonSchema:({type:n})=>n==="object"?{maxProperties:e}:[{maxProperties:e},!0],toCode:()=>({runtime:`Schema.isMaxProperties(${e})`}),[An]:!0,arbitraryConstraint:{maxProperties:e},...t})}function SL(e,t,n){return e=on(e),t=on(t),ke((r)=>Reflect.ownKeys(r).length>=e&&Reflect.ownKeys(r).length<=t,{expected:e===t?`a value with exactly ${e===1?"1 entry":`${e} entries`}`:`a value with between ${e} and ${t} entries`,representation:{id:"effect/schema/isBetweenProperties",payload:{minimum:e,maximum:t}},toJsonSchema:({type:r})=>r==="object"?{minProperties:e,maxProperties:t}:[{minProperties:e,maxProperties:t},!0],toCode:()=>({runtime:`Schema.isBetweenProperties(${e}, ${t})`}),[An]:!0,arbitraryConstraint:{minProperties:e,maxProperties:t},...n})}function EL(e,t){let n=ac(e),r=Qk(n.ast);return ke((o,s,a)=>{let i=Reflect.ownKeys(o),c=[];for(let f of i){let u=r(f,a);if(u!==void 0){if(c.push(new Qe([f],u)),a.errors==="first")break}}if(Sn(c))return new tt(s,c,o,a);return!0},{expected:"an object with property names matching the schema",representation:{id:"effect/schema/isPropertyNames",payload:null,schemas:[n.ast]},toJsonSchema:({schemas:o,type:s})=>s==="object"?{propertyNames:o[0]}:[{propertyNames:o[0]},!0],toCode:({schemas:o})=>({runtime:`Schema.isPropertyNames(${o[0].runtime})`}),[An]:!0,...t})}function ty(e){return ke((t)=>hd(t).length===t.length,{expected:"an array with unique items",representation:{id:"effect/schema/isUnique",payload:null},toJsonSchema:()=>({uniqueItems:!0}),toCode:()=>({runtime:"Schema.isUnique()"}),arbitraryConstraint:{uniqueBy:Q},...e})}function MA(e){return ke((t)=>hd(t.map(([n])=>n)).length===t.length,{expected:"an array with unique keys",representation:{id:"effect/schema/isUniqueKey",payload:null},toCode:()=>({runtime:"Schema.isUniqueKey()"}),arbitraryConstraint:{uniqueBy:(t)=>t[0]},...e})}var bL=z.check(RA()),IL=z.check(Xx(1,1)),UA=(e)=>(e?.includeStack===!0?1:0)|(e?.excludeCause===!0?2:0),FA=(e)=>{switch(e){case 0:return;case 1:return{includeStack:!0};case 2:return{excludeCause:!0};case 3:return{includeStack:!0,excludeCause:!0}}},NT=[];function wL(e){let t=UA(e),n=NT[t];if(n!==void 0)return n;let r=FA(t),o=Us(globalThis.Error,{representation:{id:"effect/schema/Error",payload:r??null},toCode:()=>({runtime:r!==void 0?`Schema.ErrorInstance(${K(r)})`:"Schema.ErrorInstance()",Type:"globalThis.Error"}),expected:"Error",toCodecJson:()=>Se()(jz,Ow(r))});return NT[t]=o,o}var BT=[];function bt(e){let t=UA(e),n=BT[t];if(n!==void 0)return n;let r=pp.pipe(Z(nu,_w(FA(t))));return BT[t]=r,r}function kL(e,t){let n=Wt()([e,t],([r,o])=>{let s=Oe(cr([r,o]));return(a,i,c)=>{if(a instanceof globalThis.Map)return Ht(qe(s)([...a],c),{onSuccess:(f)=>new globalThis.Map(f),onFailure:(f)=>vn(i,"entries",f,a,c)});return _(new Fe(i,a,c))}},{representation:{id:"effect/schema/ReadonlyMap",payload:null},toCode:({typeParameters:r})=>({runtime:`Schema.ReadonlyMap(${r[0].runtime}, ${r[1].runtime})`,Type:`globalThis.ReadonlyMap<${r[0].Type}, ${r[1].Type}>`}),expected:"ReadonlyMap",toCodec:([r,o])=>Se()(Oe(cr([r,o])),xe({decode:(s)=>new globalThis.Map(s),encode:(s)=>[...s.entries()]}))});return H(n.ast,{key:e,value:t})}function TL(e){let t=Wt()([e],([n])=>{let r=Oe(n);return(o,s,a)=>{if(o instanceof globalThis.Set)return Ht(qe(r)([...o],a),{onSuccess:(i)=>new globalThis.Set(i),onFailure:(i)=>vn(s,"values",i,o,a)});return _(new Fe(s,o,a))}},{representation:{id:"effect/schema/ReadonlySet",payload:null},toCode:({typeParameters:n})=>({runtime:`Schema.ReadonlySet(${n[0].runtime})`,Type:`globalThis.ReadonlySet<${n[0].Type}>`}),expected:"ReadonlySet",toCodec:([n])=>Se()(Oe(n),xe({decode:(r)=>new globalThis.Set(r),encode:(r)=>[...r.values()]}))});return H(t.ast,{value:e})}var AL=Us(globalThis.RegExp,{representation:{id:"effect/schema/RegExp",payload:null},toCode:()=>({runtime:"Schema.RegExp",Type:"globalThis.RegExp"}),expected:"RegExp",toCodecJson:()=>Se()(ae({source:z,flags:z}),Et({decode:(e,t)=>Mr({try:()=>new globalThis.RegExp(e.source,e.flags),catch:()=>new te({expected:"valid RegExp source and flags"},e,t)}),encode:(e)=>b({source:e.source,flags:e.flags})}))}),DA=z.annotate({expected:"a string that will be decoded as a URL"}),NA=Us(globalThis.URL,{representation:{id:"effect/schema/URL",payload:null},toCode:()=>({runtime:"Schema.URL",Type:"globalThis.URL"}),expected:"URL",toCodecJson:()=>Se()(DA,cg)}),CL=DA.pipe(Z(NA,cg)),BA=z.annotate({expected:"a string that will be decoded as a Date"}),ip=we((e)=>e instanceof globalThis.Date&&!globalThis.Number.isNaN(e.getTime()),{representation:{id:"effect/schema/Date",payload:null},toCode:()=>({runtime:"Schema.Date",Type:"globalThis.Date"}),expected:"a valid Date",toCodecJson:()=>Se()(BA,ag)}),vL=BA.pipe(Z(ip,ag)),OL=wo.pipe(Z(ip,ww)),_L=z.annotate({expected:"a string that will be decoded as JSON",contentMediaType:"application/json"});function ny(e,t){return _L.pipe(Z(e,zw(t)))}var RL=ny(nu),LA=Us(globalThis.File,{representation:{id:"effect/schema/File",payload:null},toCode:()=>({runtime:"Schema.File",Type:"globalThis.File"}),expected:"File",toCodecJson:()=>Se()(ae({data:z.check(AA()),type:z,name:z,lastModified:wo}),Et({decode:(e,t)=>Pr(ia(e.data),{onFailure:()=>_(new te({expected:"a valid Base64 string"},e.data,t)),onSuccess:(n)=>{let r=new globalThis.Uint8Array(n);return b(new globalThis.File([r],e.name,{type:e.type,lastModified:e.lastModified}))}}),encode:(e,t)=>fr({try:async()=>{let n=new globalThis.Uint8Array(await e.arrayBuffer());return{data:ai(n),type:e.type,name:e.name,lastModified:e.lastModified}},catch:()=>new te({expected:"a readable File"},e,t)})}))}),zA=Us(globalThis.FormData,{representation:{id:"effect/schema/FormData",payload:null},toCode:()=>({runtime:"Schema.FormData",Type:"globalThis.FormData"}),expected:"FormData",toCodecJson:()=>Se()(Oe(cr([z,Ie([ae({_tag:ye("String"),value:z}),ae({_tag:ye("File"),value:LA})])])),Et({decode:(e)=>{let t=new globalThis.FormData;for(let[n,r]of e)t.append(n,r.value);return b(t)},encode:(e)=>b(globalThis.Array.from(e.entries()).map(([t,n])=>{if(typeof n==="string")return[t,{_tag:"String",value:n}];else return[t,{_tag:"File",value:n}]}))}))});function PL(e){return zA.pipe(Z(e,$w))}var $A=Us(globalThis.URLSearchParams,{representation:{id:"effect/schema/URLSearchParams",payload:null},toCode:()=>({runtime:"Schema.URLSearchParams",Type:"globalThis.URLSearchParams"}),expected:"URLSearchParams",toCodecJson:()=>Se()(z.annotate({expected:"a query string that will be decoded as URLSearchParams"}),xe({decode:(e)=>new globalThis.URLSearchParams(e),encode:(e)=>e.toString()}))});function ML(e){return $A.pipe(Z(e,qw))}var UL=z.annotate({expected:"a string that will be decoded as a number"}).pipe(Z(Oa,wi)),FL=z.annotate({expected:"a string that will be decoded as a finite number"}).pipe(Z(op,wi)),DL=H(zg).pipe(Z(ic,el)),qA=z.check(TA()),NL=z.annotate({expected:"a string that will be decoded as a trimmed string"}).pipe(Z(qA,Iw())),BL=z.annotate({expected:"a base64 encoded string that will be decoded as a UTF-8 string"}).pipe(Z(z,Dw)),LL=z.annotate({expected:"a base64 (URL) encoded string that will be decoded as a UTF-8 string"}).pipe(Z(z,Nw)),zL=z.annotate({expected:"a hex encoded string that will be decoded as a UTF-8 string"}).pipe(Z(z,Bw)),$L=z.annotate({expected:"a URI component encoded string that will be decoded as a UTF-8 string"}).pipe(Z(z,Lw)),Nx=Ie([op,cA,z]),qL=ae({issues:Oe(ae({message:z,path:mt(Oe(Ie([Nx,ae({key:Nx})])))}))}),HL=ur([0,1]).pipe(Z(ru,xe({decode:(e)=>e===1,encode:(e)=>e?1:0}))),HA=z.annotate({expected:"a base64 encoded string that will be decoded as Uint8Array",format:"byte",contentEncoding:"base64"}),Hr=Us(globalThis.Uint8Array,{representation:{id:"effect/schema/Uint8Array",payload:null},toCode:()=>({runtime:"Schema.Uint8Array",Type:"globalThis.Uint8Array"}),expected:"Uint8Array",toCodecJson:()=>Se()(HA,fg)}),jL=HA.pipe(Z(Hr,fg)),WL=z.annotate({expected:"a base64 (URL) encoded string that will be decoded as a Uint8Array"}).pipe(Z(Hr,{decode:sw(),encode:Gd()})),JL=z.annotate({expected:"a hex encoded string that will be decoded as a Uint8Array"}).pipe(Z(Hr,{decode:iw(),encode:Kd()})),jA=Et({decode:(e,t)=>{let n=jE(e);return Tn(n)?_(new te({expected:"a valid BigDecimal string"},e,t)):b(n.value)},encode:(e)=>b(Lo(e))}),GL=ou({order:ni,formatter:(e)=>Lo(e)}),KL=su({order:ni,formatter:(e)=>Lo(e)}),VL=au({order:ni,formatter:(e)=>Lo(e)}),ZL=iu({order:ni,formatter:(e)=>Lo(e)}),QL=cu({order:ni,formatter:(e)=>Lo(e)}),WA=z.annotate({expected:"a string that will be decoded as a BigDecimal"}),JA=we(ra,{representation:{id:"effect/schema/BigDecimal",payload:null},toCode:()=>({runtime:"Schema.BigDecimal",Type:"BigDecimal.BigDecimal",importDeclarations:['import * as BigDecimal from "effect/BigDecimal"']}),expected:"BigDecimal",toCodecJson:()=>Se()(WA,jA),toFormatter:()=>(e)=>Lo(e)}),YL=WA.pipe(Z(JA,jA)),cp=we(XE,{representation:{id:"effect/schema/ByteSize",payload:null},toCode:()=>({runtime:"Schema.ByteSize",Type:"ByteSize.ByteSize",importDeclarations:['import * as ByteSize from "effect/ByteSize"']}),expected:"ByteSize",toCodecJson:()=>Se()(ic.check(vA(globalThis.BigInt(0))),xe({decode:YE,encode:ld})),toCodecStringTree:()=>Se()(GA,ig)}),GA=z.annotate({expected:"a string that will be decoded as a ByteSize"}),XL=GA.pipe(Z(cp,ig)),e2=ic.pipe(Z(cp,kw)),t2=Oa.pipe(Z(cp,Tw));function Bx(e,t){let n=Wt()([e,t],([r,o])=>(s,a,i)=>{if(!oc(s))return _(new Fe(a,s,i));switch(s._tag){case"Fail":return Ht(qe(r)(s.error,i),{onSuccess:Kf,onFailure:(c)=>vn(a,"error",c,s,i)});case"Die":return Ht(qe(o)(s.defect,i),{onSuccess:Vf,onFailure:(c)=>vn(a,"defect",c,s,i)});case"Interrupt":return b(s)}},{representation:{id:"effect/schema/CauseReason",payload:null},toCode:({typeParameters:r})=>({runtime:`Schema.CauseReason(${r[0].runtime}, ${r[1].runtime})`,Type:`Cause.Failure<${r[0].Type}, ${r[1].Type}>`,importDeclarations:['import * as Cause from "effect/Cause"']}),expected:"Cause.Failure",toCodec:([r,o])=>Se()(Ie([ae({_tag:pt("Fail"),error:r}),ae({_tag:pt("Die"),defect:o}),ae({_tag:pt("Interrupt"),fiberId:np(op)})]),xe({decode:(s)=>{switch(s._tag){case"Fail":return Kf(s.error);case"Die":return Vf(s.defect);case"Interrupt":return Yf(s.fiberId)}},encode:(s)=>{switch(s._tag){case"Fail":return{_tag:"Fail",error:s.error};case"Die":return{_tag:"Die",defect:s.defect};case"Interrupt":return{_tag:"Interrupt",fiberId:s.fiberId}}}}))});return H(n.ast,{error:e,defect:t})}function Lx(e,t){let n=Wt()([e,t],([r,o])=>{let s=Oe(Bx(r,o));return(a,i,c)=>{if(!rc(a))return _(new Fe(i,a,c));return Ht(qe(s)(a.reasons,c),{onSuccess:Gf,onFailure:(f)=>vn(i,"failures",f,a,c)})}},{representation:{id:"effect/schema/Cause",payload:null},toCode:({typeParameters:r})=>({runtime:`Schema.Cause(${r[0].runtime}, ${r[1].runtime})`,Type:`Cause.Cause<${r[0].Type}, ${r[1].Type}>`,importDeclarations:['import * as Cause from "effect/Cause"']}),expected:"Cause",toCodec:([r,o])=>Se()(Oe(Bx(r,o)),xe({decode:Gf,encode:({reasons:s})=>s}))});return H(n.ast,{error:e,defect:t})}function LT(e){return Se()(e,xe({decode:lh,encode:_t}))}function n2(e){let t=Wt()([e],([n])=>{let r=Oe(n);return(o,s,a)=>{if(si(o))return Ht(qe(r)(_t(o),a),{onSuccess:lh,onFailure:(i)=>vn(s,"values",i,o,a)});return _(new Fe(s,o,a))}},{representation:{id:"effect/schema/Chunk",payload:null},toCode:({typeParameters:n})=>({runtime:`Schema.Chunk(${n[0].runtime})`,Type:`Chunk.Chunk<${n[0].Type}>`}),expected:"Chunk",toCodec:([n])=>LT(Oe(n)),toCodecArbitrary:({constraint:n,typeParameters:[r]})=>LT(tp(Oe(r),n?.minLength,n?.maxLength)),toEquivalence:([n])=>uh(n)});return H(t.ast,{value:e})}function KA(){return $t((e,t)=>zt(mh(e),{onNone:()=>_(new te({message:"Invalid DateTime input"},e,t)),onSome:(n)=>b(hh(n))}))}var r2=xe({decode:(e)=>xh(e),encode:(e)=>e.offset}),VA=Et({decode:(e,t)=>zt(Mb(e),{onNone:()=>_(new te({expected:"a valid IANA time zone"},e,t)),onSome:b}),encode:(e)=>b(e.id)}),ZA=Et({decode:(e,t)=>zt(Ub(e),{onNone:()=>_(new te({expected:"a valid time zone"},e,t)),onSome:b}),encode:(e)=>b(Kc(e))}),QA=Et({decode:(e,t)=>zt(mh(e),{onNone:()=>_(new te({expected:"a valid UTC DateTime string"},e,t)),onSome:(n)=>b(hh(n))}),encode:(e)=>b(Nb(e))}),YA=Et({decode:(e,t)=>zt(Pb(e),{onNone:()=>_(new te({expected:"a valid Zoned DateTime string"},e,t)),onSome:b}),encode:(e)=>b(yh(e))}),XA=-8640000000000000,eC=8640000000000000,o2=XA+50400000,s2=eC-50400000,a2=-43200000,i2=50400000,tC=["UTC","Europe/London","America/New_York","Asia/Tokyo","Australia/Sydney"];function nC(e,t,n){let r=Math.max(t,e?.minimum===void 0?t:e.minimum.epochMilliseconds+(e.exclusiveMinimum===!0?1:0)),o=Math.min(n,e?.maximum===void 0?n:e.maximum.epochMilliseconds-(e.exclusiveMaximum===!0?1:0));return r<=o?[r,o]:[t,n]}function ry(e,t){return wo.check(sp({minimum:e,maximum:t}))}function rC(){return Ie([ry(a2,i2),ur(tC)])}var fp=we((e)=>sa(e)&&Ob(e),{representation:{id:"effect/schema/DateTimeUtc",payload:null},toCode:()=>({runtime:"Schema.DateTimeUtc",Type:"DateTime.Utc",importDeclarations:['import * as DateTime from "effect/DateTime"']}),expected:"DateTime.Utc",toCodecArbitrary:({constraint:e})=>{let[t,n]=nC(e,XA,eC);return uc()(ry(t,n),se(gd))},toCodecJson:()=>Se()(z,QA),toFormatter:()=>(e)=>e.toString()}),c2=ip.pipe(Z(fp,{decode:KA(),encode:se(Fb)})),f2=z.annotate({expected:"a string that will be decoded as a DateTime.Utc"}).pipe(Z(fp,QA)),u2=wo.pipe(Z(fp,{decode:KA(),encode:se(Db)})),d2=we(Cb,{representation:{id:"effect/schema/TimeZoneOffset",payload:null},toCode:()=>({runtime:"Schema.TimeZoneOffset",Type:"DateTime.TimeZone.Offset",importDeclarations:['import * as DateTime from "effect/DateTime"']}),expected:"DateTime.TimeZone.Offset",toCodecJson:()=>Se()(wo,r2),toFormatter:()=>(e)=>Kc(e)}),oC=z.annotate({expected:"an IANA time zone identifier"}),sC=we(vb,{representation:{id:"effect/schema/TimeZoneNamed",payload:null},toCode:()=>({runtime:"Schema.TimeZoneNamed",Type:"DateTime.TimeZone.Named",importDeclarations:['import * as DateTime from "effect/DateTime"']}),expected:"DateTime.TimeZone.Named",toCodecArbitrary:()=>uc()(ur(tC),se(gh)),toCodecJson:()=>Se()(oC,VA),toFormatter:()=>(e)=>Kc(e)}),l2=oC.pipe(Z(sC,VA)),aC=z.annotate({expected:"a time zone string (IANA identifier or offset like +03:00)"}),iC=we(Ab,{representation:{id:"effect/schema/TimeZone",payload:null},toCode:()=>({runtime:"Schema.TimeZone",Type:"DateTime.TimeZone",importDeclarations:['import * as DateTime from "effect/DateTime"']}),expected:"DateTime.TimeZone",toCodecArbitrary:()=>uc()(rC(),se((e)=>typeof e==="number"?xh(e):gh(e))),toCodecJson:()=>Se()(aC,ZA),toFormatter:()=>(e)=>Kc(e)}),p2=aC.pipe(Z(iC,ZA)),cC=z.annotate({expected:"a zoned DateTime string (e.g. 2024-01-01T00:00:00.000+00:00[Europe/London])"}),fC=we((e)=>sa(e)&&_b(e),{representation:{id:"effect/schema/DateTimeZoned",payload:null},toCode:()=>({runtime:"Schema.DateTimeZoned",Type:"DateTime.Zoned",importDeclarations:['import * as DateTime from "effect/DateTime"']}),expected:"DateTime.Zoned",toCodecArbitrary:({constraint:e})=>{let[t,n]=nC(e,o2,s2);return uc()(ae({epochMilliseconds:ry(t,n),timeZone:rC()}),se(({epochMilliseconds:r,timeZone:o})=>xd(r,{timeZone:o})))},toCodecJson:()=>Se()(cC,YA),toFormatter:()=>(e)=>yh(e),toEquivalence:()=>Rb}),m2=cC.pipe(Z(fC,YA)),jr=(e,t,n,r)=>z.pipe(Z(e,Et({decode:(o,s)=>{let a=t(o);return At(a)?b(a.success):_(new te({message:a.failure.message},o,s))},encode:(o)=>b(n(o))}))).annotate({identifier:r}),Ra=we(ji,{identifier:"MacAddress"}),lc=jr(Ra,yT,bx,"MacAddressFromString"),up=we(rn,{identifier:"Ipv4Address"}),oy=jr(up,Wi,qr,"Ipv4AddressFromString"),sy=we(Io,{identifier:"Ipv6Address"}),uC=jr(sy,Bf,qr,"Ipv6AddressFromString"),Pa=we(gT,{identifier:"IpAddress"}),pc=jr(Pa,Lf,qr,"IpAddressFromString"),Je=(e,t,n,r)=>pA(t,{expected:n})(e).annotate({identifier:r}),h2=Je(Pa,Ji,"a multicast address","IpMulticastAddress"),g2=Je(pc,Ji,"a multicast address","IpMulticastAddressFromString"),x2=Je(Ra,Ji,"a multicast address","MacMulticastAddress"),y2=Je(lc,Ji,"a multicast address","MacMulticastAddressFromString"),S2=Je(Pa,Tx,"a unicast address","IpUnicastAddress"),E2=Je(pc,Tx,"a unicast address","IpUnicastAddressFromString"),b2=Je(Ra,Wl,"a unicast address","MacUnicastAddress"),I2=Je(lc,Wl,"a unicast address","MacUnicastAddressFromString"),w2=Je(up,Gl,"a broadcast address","Ipv4BroadcastAddress"),k2=Je(oy,Gl,"a broadcast address","Ipv4BroadcastAddressFromString"),T2=Je(Ra,jl,"a broadcast address","MacBroadcastAddress"),A2=Je(lc,jl,"a broadcast address","MacBroadcastAddressFromString"),C2=Je(Pa,kx,"a loopback address","IpLoopbackAddress"),v2=Je(pc,kx,"a loopback address","IpLoopbackAddressFromString"),O2=Je(Pa,Ax,"a link-local address","IpLinkLocalAddress"),_2=Je(pc,Ax,"a link-local address","IpLinkLocalAddressFromString"),R2=Je(Pa,Jl,"an unspecified address","IpUnspecifiedAddress"),P2=Je(pc,Jl,"an unspecified address","IpUnspecifiedAddressFromString"),M2=Je(up,Cx,"a private address","Ipv4PrivateAddress"),U2=Je(oy,Cx,"a private address","Ipv4PrivateAddressFromString"),F2=Je(sy,vx,"a unique-local address","Ipv6UniqueLocalAddress"),D2=Je(uC,vx,"a unique-local address","Ipv6UniqueLocalAddressFromString"),N2=Je(Ra,Ix,"a locally administered address","MacLocallyAdministeredAddress"),B2=Je(lc,Ix,"a locally administered address","MacLocallyAdministeredAddressFromString"),L2=Je(Ra,wx,"a universally administered address","MacUniversallyAdministeredAddress"),z2=Je(lc,wx,"a universally administered address","MacUniversallyAdministeredAddressFromString"),dC=we(wT,{identifier:"Ipv4Interface"}),$2=jr(dC,Vl,qf,"Ipv4InterfaceFromString"),lC=we(kT,{identifier:"Ipv6Interface"}),q2=jr(lC,Zl,qf,"Ipv6InterfaceFromString"),pC=we(zf,{identifier:"IpInterface"}),H2=jr(pC,Ql,qf,"IpInterfaceFromString"),mC=we(AT,{identifier:"Ipv4Network"}),j2=jr(mC,vT,jf,"Ipv4NetworkFromString"),hC=we(CT,{identifier:"Ipv6Network"}),W2=jr(hC,OT,jf,"Ipv6NetworkFromString"),gC=we(Hf,{identifier:"IpNetwork"}),J2=jr(gC,_T,jf,"IpNetworkFromString"),G2=we(Df,{identifier:"InetAddressV4"}),K2=we(Nf,{identifier:"InetAddressV6"}),xC=we(Sx,{identifier:"InetAddress"}),V2=jr(xC,bT,Kl,"InetAddressFromString"),yC=we(Hl,{identifier:"UnixPathAddress"}),Z2=z.pipe(Z(yC,xe({decode:IT,encode:(e)=>e.path}))).annotate({identifier:"UnixPathAddressFromString"}),Q2=we(xT,{identifier:"SocketAddress"}),Y2=Et({decode:(e,t)=>zt(GT(e),{onNone:()=>_(new te({expected:"a valid Duration string"},e,t)),onSome:b}),encode:(e)=>b(globalThis.String(e))}),X2=Et({decode:(e)=>b(Zf(e)),encode:(e,t)=>zt(KT(e),{onNone:()=>_(new te({expected:"a Duration representable as a bigint"},e,t)),onSome:(n)=>b(n)})}),ez=xe({decode:(e)=>Qf(e),encode:(e)=>Wn(e)}),dp=we(tc,{representation:{id:"effect/schema/Duration",payload:null},toCode:()=>({runtime:"Schema.Duration",Type:"Duration.Duration",importDeclarations:['import * as Duration from "effect/Duration"']}),expected:"Duration",toCodecJson:()=>Se()(Ie([ae({_tag:pt("Infinity")}),ae({_tag:pt("NegativeInfinity")}),ae({_tag:pt("Nanos"),value:ic}),ae({_tag:pt("Millis"),value:wo})]),xe({decode:(e)=>{switch(e._tag){case"Infinity":return nc;case"NegativeInfinity":return Yl;case"Nanos":return Zf(e.value);case"Millis":return Qf(e.value)}},encode:(e)=>{switch(e.value._tag){case"Infinity":return{_tag:"Infinity"};case"NegativeInfinity":return{_tag:"NegativeInfinity"};case"Nanos":return{_tag:"Nanos",value:e.value.nanos};case"Millis":return{_tag:"Millis",value:e.value.millis}}}}))}),tz=z.annotate({expected:"a string that will be decoded as a Duration"}),nz=tz.pipe(Z(dp,Y2)),rz=ic.pipe(Z(dp,X2)),oz=Oa.pipe(Z(dp,ez));function ay(e,t,n){let r=Wt()([e,t,n],([o,s,a])=>{let i=Lx(s,a);return(c,f,u)=>{if(!Zo(c))return _(new Fe(f,c,u));switch(c._tag){case"Success":return Ht(qe(o)(c.value,u),{onSuccess:xn,onFailure:(d)=>vn(f,"value",d,c,u)});case"Failure":return Ht(qe(i)(c.cause,u),{onSuccess:en,onFailure:(d)=>vn(f,"cause",d,c,u)})}}},{representation:{id:"effect/schema/Exit",payload:null},toCode:({typeParameters:o})=>({runtime:`Schema.Exit(${o[0].runtime}, ${o[1].runtime}, ${o[2].runtime})`,Type:`Exit.Exit<${o[0].Type}, ${o[1].Type}, ${o[2].Type}>`,importDeclarations:['import * as Exit from "effect/Exit"']}),expected:"Exit",toCodec:([o,s,a])=>Se()(Ie([ae({_tag:pt("Success"),value:o}),ae({_tag:pt("Failure"),cause:Lx(s,a)})]),xe({decode:(i)=>i._tag==="Success"?xn(i.value):en(i.cause),encode:(i)=>$e(i)?{_tag:"Success",value:i.value}:{_tag:"Failure",cause:i.cause}}))});return H(r.ast,{value:e,error:t,defect:n})}function zT(e,t,n){return ae({type:pt(e),nodes:Oe(ae({index:Aa,data:t})),edges:Oe(ae({index:Aa,source:Aa,target:Aa,data:n}))})}function $T(e,t){let n=-1,r=new Set;for(let o=0;o<e.nodes.length;o++){let s=e.nodes[o].index;if(s<=n)return _(new Qe(["nodes",o,"index"],new te({expected:"a strictly increasing node index"},s,t)));n=s,r.add(s)}n=-1;for(let o=0;o<e.edges.length;o++){let s=e.edges[o];if(s.index<=n)return _(new Qe(["edges",o,"index"],new te({expected:"a strictly increasing edge index"},s.index,t)));if(n=s.index,!r.has(s.source))return _(new Qe(["edges",o,"source"],new te({expected:"an encoded node index"},s.source,t)));if(!r.has(s.target))return _(new Qe(["edges",o,"target"],new te({expected:"an encoded node index"},s.target,t)))}return b(Ud(e))}function sz(e,t,n){if(!Jh(e)||e.mutable||e.type!==t)return _(new te({expected:`an immutable ${t} Graph`},e,n));return b(ff(e))}function az(e,t){return(n,r)=>{let o=ff(n),s=ff(r);if(o.type!==s.type||o.nodes.length!==s.nodes.length||o.edges.length!==s.edges.length)return!1;for(let a=0;a<o.nodes.length;a++)if(o.nodes[a].index!==s.nodes[a].index||!e(o.nodes[a].data,s.nodes[a].data))return!1;for(let a=0;a<o.edges.length;a++){let i=o.edges[a],c=s.edges[a],f=o.type==="directed"?i.source===c.source&&i.target===c.target:i.source===c.source&&i.target===c.target||i.source===c.target&&i.target===c.source;if(i.index!==c.index||!f||!t(i.data,c.data))return!1}return!0}}function iz(e,t,n){return uc()(Ie([ep,ae({nodes:fc(t),edges:Oe(cr([Aa,Aa,n]))})]),se((r)=>{if(r===null)return Ud({type:e,nodes:[],edges:[]});let o=r.nodes.map((s,a)=>({index:a,data:s}));return Ud({type:e,nodes:o,edges:r.edges.map(([s,a,i],c)=>({index:c,source:s%o.length,target:a%o.length,data:i}))})}))}function cz(e,t,n){let r=Wt()([t,n],([o,s])=>{let a=zT(e,o,s);return(i,c,f)=>{if(!Jh(i)||i.mutable||i.type!==e)return _(new Fe(c,i,f));return A(qe(a)(ff(i),f),(u)=>$T(u,f))}},{representation:{id:"effect/schema/Graph",payload:e},toCode:({typeParameters:o})=>({runtime:`Schema.Graph(${K(e)}, ${o[0].runtime}, ${o[1].runtime})`,Type:`Graph.Graph<${o[0].Type}, ${o[1].Type}, ${K(e)}>`,importDeclarations:['import * as Graph from "effect/Graph"']}),expected:`an immutable ${e} Graph`,toCodec:([o,s])=>Se()(zT(e,o,s),Et({decode:$T,encode:(a,i)=>sz(a,e,i)})),toCodecArbitrary:({typeParameters:[o,s]})=>iz(e,o,s),toEquivalence:([o,s])=>az(o,s)});return H(r.ast,{type:e,node:t,edge:n})}function qT(e){return Se()(e,xe({decode:vh,encode:ef}))}function fz(e,t){let n=Wt()([e,t],([r,o])=>{let s=Oe(cr([r,o]));return(a,i,c)=>{if(wd(a))return Ht(qe(s)(ef(a),c),{onSuccess:vh,onFailure:(f)=>vn(i,"entries",f,a,c)});return _(new Fe(i,a,c))}},{representation:{id:"effect/schema/HashMap",payload:null},toCode:({typeParameters:r})=>({runtime:`Schema.HashMap(${r[0].runtime}, ${r[1].runtime})`,Type:`HashMap.HashMap<${r[0].Type}, ${r[1].Type}>`,importDeclarations:['import * as HashMap from "effect/HashMap"']}),expected:"HashMap",toCodec:([r,o])=>qT(Oe(cr([r,o]))),toCodecArbitrary:({constraint:r,typeParameters:[o,s]})=>qT(tp(Oe(cr([o,s])).check(MA()),r?.minSize,r?.maxSize)),toEquivalence:([r,o])=>Nl(r,o)});return H(n.ast,{key:e,value:t})}function HT(e){return Se()(e,xe({decode:Rh,encode:_t}))}function uz(e){let t=Wt()([e],([n])=>{let r=Oe(n);return(o,s,a)=>{if(Ad(o))return Ht(qe(r)(_t(o),a),{onSuccess:Rh,onFailure:(i)=>vn(s,"values",i,o,a)});return _(new Fe(s,o,a))}},{representation:{id:"effect/schema/HashSet",payload:null},toCode:({typeParameters:n})=>({runtime:`Schema.HashSet(${n[0].runtime})`,Type:`HashSet.HashSet<${n[0].Type}>`}),expected:"HashSet",toCodec:([n])=>HT(Oe(n)),toCodecArbitrary:({constraint:n,typeParameters:[r]})=>HT(tp(Oe(r).check(ty()),n?.minSize,n?.maxSize)),toEquivalence:([n])=>Bl(n)});return H(t.ast,{value:e})}function Ma(e){let t=Wt()([e],([n])=>(r,o,s)=>{if(Xi(r)){if(Tn(r))return Si;return Ht(qe(n)(r.value,s),{onSuccess:oe,onFailure:(a)=>vn(o,"value",a,r,s)})}return _(new Fe(o,r,s))},{representation:{id:"effect/schema/Option",payload:null},toCode:({typeParameters:n})=>({runtime:`Schema.Option(${n[0].runtime})`,Type:`Option.Option<${n[0].Type}>`,importDeclarations:['import * as Option from "effect/Option"']}),expected:"Option",toCodec:([n])=>Se()(Ie([ae({_tag:pt("Some"),value:n}),ae({_tag:pt("None")})]),xe({decode:(r)=>r._tag==="None"?ne():oe(r.value),encode:(r)=>ve(r)?{_tag:"Some",value:r.value}:{_tag:"None"}}))});return H(t.ast,{value:e})}function dz(e){return Vx(e).pipe(Z(Ma(Pn(e)),Rw()))}function lz(e){return np(e).pipe(Z(Ma(Pn(e)),Pw()))}function pz(e,t){return dA(e).pipe(Z(Ma(Pn(e)),Mw(t)))}var SC=we(iI,{representation:{id:"effect/http/Cookie",payload:null},toCode:()=>({runtime:"Schema.Cookie",Type:"Cookies.Cookie",importDeclarations:['import * as Cookies from "effect/http/Cookies"']}),expected:"Cookie"}),EC=we(aI,{representation:{id:"effect/http/Cookies",payload:null},toCode:()=>({runtime:"Schema.Cookies",Type:"Cookies.Cookies",importDeclarations:['import * as Cookies from "effect/http/Cookies"']}),expected:"Cookies",toCodecJson:()=>Se()(Oe(z),xe({decode:vd,encode:pI})),toCodecIso:()=>Se()(_a(z,SC),xe({decode:Dh,encode:(e)=>e.cookies}))}),mz=EC.pipe(Z(_a(z,z),xe({decode:lI,encode:(e)=>Nh(globalThis.Object.entries(e).map(([t,n])=>dI(t,n)))}))),hz=we(bI,{representation:{id:"effect/http/Headers",payload:null},toCode:()=>({runtime:"Schema.Headers",Type:"Headers.Headers",importDeclarations:['import * as Headers from "effect/http/Headers"']}),expected:"Headers",toEquivalence:()=>Lh,toCodec:()=>Se()(_a(z,z),xe({decode:Es,encode:(e)=>({...e})}))}),iy=we(qh,{representation:{id:"effect/http/UrlParams",payload:null},toCode:()=>({runtime:"Schema.UrlParams",Type:"UrlParams.UrlParams",importDeclarations:['import * as UrlParams from "effect/http/UrlParams"']}),expected:"UrlParams",toEquivalence:()=>Hh,toCodec:()=>Se()(Oe(cr([z,z])),xe({decode:pi,encode:(e)=>e.params}))}),gz=(e,t)=>iy.pipe(Z(ny(nu,t),Et({decode:(n)=>zt(CI(n,e),{onNone:()=>_(new Qe([e],new ot(void 0))),onSome:b}),encode:(n)=>b(pi([[e,n]]))}))),xz=iy.pipe(Z(_a(z,Ie([z,fc(z)])),xe({decode:OI,encode:la})));function yz(e){return Ca(e).pipe(Z(Ma(Pn(e)),Uw()))}function Sz(e){return mt(e).pipe(Z(Ma(Pn(e)),Fw()))}function Ez(e,t){let n=t===void 0?"omit":t.onNoneEncoding,r=n===null?null:void 0;return mt(Vx(e)).pipe(Z(Ma(Pn(e)),Xd({decode:(o)=>o.pipe(yi(cl),oe),encode:n==="omit"?bi:(o)=>oe(JT(bi(o),()=>r))})))}function bC(e,t){let n=typeof t?.label==="string"?t.label:void 0,r=t?.disallowJsonEncode===!0,o=n!==void 0?r?{label:n,disallowJsonEncode:!0}:{label:n}:r?{disallowJsonEncode:!0}:void 0,s=n!==void 0?qe(pt(n)):void 0,a=Wt()([e],([i])=>(c,f,u)=>{if(of(c)){let d=s!==void 0?Hd(s(c.label,u),(l)=>new Qe(["label"],l)):R;return Pt(d,()=>Ht(qe(i)(Rr(c),u),{onSuccess:(l)=>ua(l,{label:c.label}),onFailure:()=>new tt(f,[new Qe(["value"],new te(void 0,c,u))],c,u)}))}return _(new Fe(f,c,u))},{representation:{id:"effect/schema/Redacted",payload:o??null},toCode:({typeParameters:i})=>({runtime:o!==void 0?`Schema.Redacted(${i[0].runtime}, ${K(o)})`:`Schema.Redacted(${i[0].runtime})`,Type:`Redacted.Redacted<${i[0].Type}>`,importDeclarations:['import * as Redacted from "effect/Redacted"']}),expected:"Redacted",toCodecJson:([i])=>Se()(i,{decode:se((c)=>ua(c,{label:n})),encode:r?jd((c)=>"Cannot serialize Redacted"+(ve(c)&&typeof c.value.label==="string"?` with label: "${c.value.label}"`:"")):se(Rr)}),toEquivalence:([i])=>xI(i)});return H(a.ast,{value:e})}function bz(e,t){return Z(bC(Pn(e),{label:t?.label,disallowJsonEncode:t?.disallowEncode}),{decode:se((n)=>ua(n,{label:t?.label})),encode:t?.disallowEncode?jd((n)=>"Cannot encode Redacted"+(ve(n)&&typeof n.value.label==="string"?` with label: "${n.value.label}"`:"")):se(Rr)})(e)}function Iz(e,t){let n=Wt()([e,t],([r,o])=>(s,a,i)=>{if(!ec(s))return _(new Fe(a,s,i));switch(s._tag){case"Success":return Ht(Zg(r)(s.success,i),{onSuccess:ue,onFailure:(c)=>vn(a,"success",c,s,i)});case"Failure":return Ht(Zg(o)(s.failure,i),{onSuccess:ge,onFailure:(c)=>vn(a,"failure",c,s,i)})}},{representation:{id:"effect/schema/Result",payload:null},toCode:({typeParameters:r})=>({runtime:`Schema.Result(${r[0].runtime}, ${r[1].runtime})`,Type:`Result.Result<${r[0].Type}, ${r[1].Type}>`,importDeclarations:['import * as Result from "effect/Result"']}),expected:"Result",toCodec:([r,o])=>Se()(Ie([ae({_tag:pt("Success"),success:r}),ae({_tag:pt("Failure"),failure:o})]),xe({decode:(s)=>s._tag==="Success"?ue(s.success):ge(s.failure),encode:(s)=>At(s)?{_tag:"Success",success:s.success}:{_tag:"Failure",failure:s.failure}}))});return H(n.ast,{success:e,failure:t})}var wz=globalThis.Symbol.for("immer-draftable"),zx={};function cy(e,t,n,r,o){let s=Tz(n,t,r),a=IC(t),i=class extends e{constructor(...[c,f]){let d=f?.["~payload"],l=d?.token===zx?d.value:n.make(c??{},f);super(l,{...f,disableChecks:!0,"~payload":{token:zx,value:l}})}static[Wf]=Wf;get[a](){return a}static[wz]=!0;static identifier=t;static fields=n.fields;static get ast(){return s(this).ast}static pipe(){return de(this,arguments)}static rebuild(c){return s(this).rebuild(c)}static make(c,f){return kl(s(this))(c??{},f)}static makeOption(c,f){return wl(s(this))(c??{},f)}static makeEffect(c,f){return s(this).makeEffect(c??{},f)}static annotate(c){return this.rebuild(Ur(this.ast,c))}static annotateKey(c){return this.rebuild(Ri(this.ast,c))}static check(...c){return this.rebuild(Eo(this.ast,c))}static extend(c){return(f,u)=>{let d=fu(f)?f:ae(f),l={...n.fields,...d.fields},m=ll(l,n.ast.checks,{identifier:c});return cy(this,c,Kx(Eo(m,d.ast.checks),l),u,o)}}static mapFields(c,f){return n.mapFields(c,f)}};if(o!==void 0)Object.assign(i.prototype,o(t));return i}function kz(e){return new be(se((t)=>new e(t,{"~payload":{token:zx,value:t}})),xo())}function IC(e){return`~effect/Schema/Class/${e}`}function Tz(e,t,n){let r;return(o)=>{if(r!==void 0)return r;let s=IC(t),a=(f)=>f instanceof o||V(f,s),i=kz(o),c=H(new Cs([e.ast],()=>(f,u,d)=>a(f)?b(f):_(new Fe(u,f,d)),{identifier:t,[Dd]:([f])=>({isConstructed:a,link:new Xe(f,i)}),toCodec:([f])=>new Xe(f.ast,i),toEquivalence:([f])=>f,toFormatter:([f])=>(u)=>`${o.identifier}(${f(u)})`,[uf]:ks(e.ast),...n}));return r=Z(c,i)(e)}}function fu(e){return va(e)}var lp=(e)=>(t,n)=>{let r=fu(t)?t:ae(t);return cy(VT,e,r,n,(o)=>({toString(){return`${o}(${K({...this})})`}}))},Az=(e)=>(t,n,r)=>{let o=fu(n)?n.mapFields((s)=>({_tag:ye(t),...s}),{unsafePreserveChecks:!0}):rp(t,n);return lp(e??t)(o,r)},Ct=(e)=>(t,n)=>{let r=fu(t)?t:ae(t);return cy(WT,e,r,n,(s)=>({name:s}))},fy=(e)=>(t,n,r)=>{let o=fu(n)?n.mapFields((s)=>({_tag:ye(t),...s}),{unsafePreserveChecks:!0}):rp(t,n);return Ct(e??t)(o,r)};function Cz(e){return(t)=>t.annotate({toFormatter:e})}function vz(e,t){return nT(e.ast,t)}function Oz(e){return(t)=>t.annotate({toEquivalence:e})}function _z(e){return lx(e.ast)}function Rz(e,t){return Pf(e.ast,t)}function Pz(e,t){let n=Pf(Ni(e.ast),t);return Ul(n,t)}var uu=Ol,Mz=_l,Uz=Rl,Fz=A0;function Dz(e,t){return Z0(e,t)}function Nz(e){return lT(e)}function Bz(e){return pT(e)}function Lz(e){return mT(e)}function zz(e,t){return(n)=>H(Ur(n.ast,{toCodecIso:()=>new Xe(e.ast,Yd(t))}),{schema:n})}function $z(e){return V0(e)}function qz(e){let t=lA(()=>n),n=Ie([e,Oe(t),_a(z,t)]);return n}var pp=H(Ur(Ai,{toCode:()=>({runtime:"Schema.Json",Type:"Schema.Json"})})),Hz=_a(z,pp),jz=ae({message:z,name:Ca(z),stack:Ca(z),cause:Ca(pp)}),Wz=H(Ur(qk,{toCode:()=>({runtime:"Schema.MutableJson",Type:"Schema.MutableJson"})}));function Jz(e){return Ho(e.ast)}function Gz(e){return e.ast.context?.annotations}var ss={};Ps(ss,{ServerClient:()=>xR,custom:()=>Qj,exitSchema:()=>wS,fork:()=>e4,isRpc:()=>Vj,isWrapper:()=>Pc,make:()=>yR,uninterruptible:()=>t4,unwrap:()=>Yj,wrap:()=>cm,wrapMap:()=>Xj});var wC="~effect/PrimaryKey";var so={};Ps(so,{DefaultChunkSize:()=>O_,Do:()=>wj,TypeId:()=>v_,accumulate:()=>cj,aggregate:()=>ej,aggregateWithin:()=>pS,as:()=>gq,bind:()=>Tj,bindEffect:()=>Aj,bindTo:()=>Cj,broadcast:()=>rR,broadcastN:()=>tj,buffer:()=>iH,bufferArray:()=>cH,callback:()=>P_,catch:()=>Bu,catchCause:()=>H_,catchCauseFilter:()=>yH,catchCauseIf:()=>xH,catchDefect:()=>fH,catchFilter:()=>dS,catchIf:()=>W_,catchReason:()=>mH,catchReasons:()=>hH,catchTag:()=>lH,catchTags:()=>pH,changes:()=>fj,changesWith:()=>oR,changesWithEffect:()=>uj,chunks:()=>Y_,collect:()=>ij,combine:()=>NH,combineArray:()=>BH,concat:()=>vc,cross:()=>zq,crossWith:()=>$_,debounce:()=>jH,decodeText:()=>dj,die:()=>X$,drain:()=>Tq,drainFork:()=>Aq,drop:()=>lS,dropRight:()=>UH,dropUntil:()=>RH,dropUntilEffect:()=>PH,dropWhile:()=>Z_,dropWhileEffect:()=>Q_,dropWhileFilter:()=>MH,empty:()=>os,encodeText:()=>lj,ensuring:()=>mS,fail:()=>Js,failCause:()=>M_,failCauseSync:()=>eq,failSync:()=>Y$,filter:()=>Xq,filterEffect:()=>tH,filterMap:()=>eH,filterMapEffect:()=>nH,flatMap:()=>Rc,flatten:()=>B_,flattenArray:()=>kq,flattenEffect:()=>yq,flattenIterable:()=>Pq,flattenTake:()=>Mq,forever:()=>Rq,fromArray:()=>nm,fromArrayEffect:()=>oq,fromArrays:()=>sq,fromAsyncIterable:()=>iq,fromChannel:()=>P,fromEffect:()=>tm,fromEffectDrain:()=>__,fromEffectRepeat:()=>R_,fromEffectSchedule:()=>K$,fromEventListener:()=>uq,fromIterable:()=>Ga,fromIterableEffect:()=>nq,fromIterableEffectRepeat:()=>rq,fromIteratorSucceed:()=>tq,fromPubSub:()=>aq,fromPubSubTake:()=>U_,fromPull:()=>oo,fromQueue:()=>Gs,fromReadableStream:()=>sS,fromSchedule:()=>cq,fromSubscription:()=>fq,groupAdjacentBy:()=>YH,groupBy:()=>ZH,groupByKey:()=>QH,grouped:()=>KH,groupedWithin:()=>VH,haltWhen:()=>xj,ignore:()=>IH,ignoreCause:()=>wH,interleave:()=>hj,interleaveWith:()=>aR,interruptWhen:()=>gj,intersperse:()=>sR,intersperseAffixes:()=>mj,isStream:()=>le,iterate:()=>lq,let:()=>kj,limitBytes:()=>CH,make:()=>Z$,map:()=>Dn,mapAccum:()=>LH,mapAccumArray:()=>Ka,mapAccumArrayEffect:()=>$H,mapAccumEffect:()=>zH,mapArray:()=>D_,mapArrayEffect:()=>Sq,mapBoth:()=>xq,mapEffect:()=>Nu,mapError:()=>J_,merge:()=>aS,mergeAll:()=>Lq,mergeEffect:()=>rm,mergeLeft:()=>Nq,mergeResult:()=>Dq,mergeRight:()=>Bq,mkArrayBuffer:()=>Bj,mkString:()=>Nj,mkUint8Array:()=>Lj,never:()=>mq,onEnd:()=>Sj,onError:()=>yj,onExit:()=>iR,onFirst:()=>fR,onStart:()=>cR,orDie:()=>bH,orElseIfEmpty:()=>SH,orElseSucceed:()=>EH,paginate:()=>dq,partition:()=>oH,partitionEffect:()=>rH,partitionQueue:()=>fS,peel:()=>aH,pipeThrough:()=>aj,pipeThroughChannel:()=>oj,pipeThroughChannelOrFail:()=>sj,prepend:()=>Fq,provide:()=>uR,provideContext:()=>hS,provideService:()=>Ej,provideServiceEffect:()=>gS,race:()=>Yq,raceAll:()=>q_,range:()=>pq,rechunk:()=>X_,repeat:()=>Cq,repeatElements:()=>_q,result:()=>Eq,retry:()=>kH,run:()=>lR,runCollect:()=>pR,runCount:()=>vj,runDrain:()=>am,runFold:()=>_j,runFoldEffect:()=>Rj,runForEach:()=>Uj,runForEachArray:()=>sm,runForEachWhile:()=>Fj,runHead:()=>Pj,runIntoPubSub:()=>jj,runIntoQueue:()=>Gj,runLast:()=>Mj,runSum:()=>Oj,scan:()=>qH,scanEffect:()=>HH,schedule:()=>vq,scoped:()=>hq,service:()=>J$,serviceOption:()=>G$,share:()=>rj,sliding:()=>FH,slidingSize:()=>eR,split:()=>DH,splitLines:()=>pj,succeed:()=>Wa,suspend:()=>dn,switchMap:()=>wq,sync:()=>Q$,take:()=>AH,takeRight:()=>vH,takeUntil:()=>G_,takeUntilEffect:()=>K_,takeWhile:()=>V_,takeWhileEffect:()=>_H,takeWhileFilter:()=>OH,tap:()=>N_,tapBoth:()=>bq,tapCause:()=>j_,tapDefect:()=>dH,tapError:()=>uS,tapErrorTag:()=>uH,tapSink:()=>Iq,throttle:()=>GH,throttleEffect:()=>tR,tick:()=>V$,timeout:()=>Oq,timeoutOrElse:()=>L_,toAsyncIterable:()=>Hj,toAsyncIterableEffect:()=>qj,toAsyncIterableWith:()=>yS,toChannel:()=>Sr,toPubSub:()=>Wj,toPubSubTake:()=>mR,toPull:()=>Dj,toQueue:()=>Jj,toReadableStream:()=>zj,toReadableStreamEffect:()=>$j,toReadableStreamWith:()=>xS,transduce:()=>XH,transformPull:()=>It,transformPullBracket:()=>oS,unfold:()=>F_,unwrap:()=>ro,unwrapReason:()=>gH,updateContext:()=>dR,updateService:()=>bj,when:()=>sH,withExecutionPlan:()=>TH,withSpan:()=>Ij,zip:()=>qq,zipFlatten:()=>Wq,zipLatest:()=>Zq,zipLatestAll:()=>cS,zipLatestWith:()=>Qq,zipLeft:()=>Hq,zipRight:()=>jq,zipWith:()=>iS,zipWithArray:()=>om,zipWithIndex:()=>Jq,zipWithNext:()=>Gq,zipWithPrevious:()=>Kq,zipWithPreviousAndNext:()=>Vq});var ct=kC,AC=TC;var CC="~effect/MutableRef",Vz={[CC]:CC,...Ss,toJSON(){return{_id:"MutableRef",current:lo(this.current)}}},hc=(e)=>{let t=Object.create(Vz);return t.current=e,t};var vC=(e)=>e.current;var mp=y(2,(e,t)=>(e.current=t,e));var an=Symbol.for("effect/MutableList/Empty"),Yo=()=>({head:void 0,tail:void 0,length:0}),dy=(e)=>{let t=e.head;if(t.offset>=1024&&t===e.tail&&t.mutable&&(t.array.length-t.offset)*8<=t.offset)e.head=e.tail={array:t.array.slice(t.offset),mutable:!0,offset:0,next:void 0}},_C=()=>({array:[],mutable:!0,offset:0,next:void 0}),Wr=(e,t)=>{if(!e.tail)e.head=e.tail=_C();else if(!e.tail.mutable)e.tail.next=_C(),e.tail=e.tail.next;e.tail.array.push(t),e.length++},ly=(e,t)=>{if(e.head={array:[t],mutable:!0,offset:0,next:e.head},!e.tail)e.tail=e.head;e.length++};var hp=(e,t)=>gp(e,_t(t),!Array.isArray(t)),gp=(e,t,n=!1)=>{if(t.length===0)return 0;let r={array:t,mutable:n,offset:0,next:void 0};if(e.head)e.tail=e.tail.next=r;else e.head=e.tail=r;return e.length+=t.length,t.length},Qo=(e)=>{e.head=e.tail=void 0,e.length=0},Ua=(e,t)=>{if(t=ht(t),t<=0||!e.head)return[];if(t=Math.min(t,e.length),t===e.length&&e.head?.offset===0&&!e.head.next){let s=e.head.array;return Qo(e),s}let n=Array(t),r=0,o=e.head;while(o){while(o.offset<o.array.length){if(n[r++]=o.array[o.offset],o.mutable)o.array[o.offset]=void 0;if(o.offset++,r===t){if(e.head=o.offset===o.array.length&&o.next?o.next:o,e.length-=t,e.length===0)Qo(e);else dy(e);return n}}o=o.next}return Qo(e),n},lu=(e,t)=>{if(t=ht(t),t<=0||!e.head)return;if(t=Math.min(t,e.length),t===e.length&&e.head?.offset===0&&!e.head.next){Qo(e);return}let n=0,r=e.head;while(r){let o=r.array.length-r.offset;if(n+o>t){r.offset+=t-n,e.head=r,e.length-=t,dy(e);return}n+=o,r=r.next}Qo(e);return},Fs=(e)=>Ua(e,e.length),Fa=(e)=>{if(!e.head)return an;let t=e.head.array[e.head.offset];if(e.head.mutable)e.head.array[e.head.offset]=void 0;if(e.head.offset++,e.length--,e.head.offset===e.head.array.length)if(e.head.next)e.head=e.head.next;else Qo(e);else dy(e);return t},RC=(e,t)=>{if(t=ht(t),t<=0)return[];let n=Math.min(t,e.length),r=Array(n),o=0,s=e.head;while(s){for(let a=s.offset;a<s.array.length;a++)if(r[o++]=s.array[a],o===n)return r;s=s.next}return r};var py=(e,t)=>{let n=[],r=e.head,o=0;while(r){for(let s=r.offset;s<r.array.length;s++)if(t(r.array[s],o++))n.push(r.array[s]);r=r.next}if(n.length===0){Qo(e);return}e.head=e.tail={array:n,mutable:!0,offset:0,next:void 0},e.length=n.length},PC=(e,t)=>py(e,(n)=>n!==t);var Qz="~effect/PubSub";var Yz="~effect/PubSub/Subscription",yp=(e)=>L(()=>o$(e.atomicPubSub(),new Map,ko(),ct(!1),hc(!1),e.strategy(),hc(ne()))),Sp=(e)=>yp({atomicPubSub:()=>xy(e),strategy:()=>new yy}),Ep=(e)=>yp({atomicPubSub:()=>xy(e),strategy:()=>new Sy}),bp=(e)=>yp({atomicPubSub:()=>xy(e),strategy:()=>new KC}),Ip=(e)=>yp({atomicPubSub:()=>UC(e),strategy:()=>new Sy}),xy=(e)=>{let t=typeof e==="number"?{capacity:e}:e;if(s$(t.capacity),t.capacity===1/0)return UC(t);let n=t.replay&&t.replay>0?new Iy(Math.ceil(t.replay)):void 0;if(t.capacity===1)return new qC(n);else if(MC(t.capacity)===t.capacity)return new zC(t.capacity,n);else return new BC(t.capacity,n)},UC=(e)=>{let t=e?.replay;return new jC(t&&t>0?new Iy(Math.ceil(t)):void 0)};var mu=(e)=>Xo(dt((t)=>(mp(e.shutdownFlag,!0),Te(e.scope,xp(t.id)).pipe(gt(e.strategy.shutdown),gy(e.shutdownHook.open),lr)))),wp=y(2,(e,t)=>L(()=>Xz(e,t))),Xz=y(2,(e,t)=>{if(e.shutdownFlag.current||ve(e.ended.current))return!1;if(mp(e.ended,oe(t)),e.strategy instanceof yy){for(let[r,o,s]of Fs(e.strategy.publishers))if(s)Da(o,xn(!1))}let n=xn(t);for(let r of e.subscribers.values())for(let o of r){let s;while((s=Fa(o))!==an)Da(s,n)}return e.subscribers.clear(),!0});var kp=y(2,(e,t)=>M(()=>{if(e.shutdownFlag.current||ve(e.ended.current))return b(!1);if(e.pubsub.publish(t))return e.strategy.completeSubscribersUnsafe(e.pubsub,e.subscribers),b(!0);return e.strategy.handleSurplus(e.pubsub,e.subscribers,[t],e.shutdownFlag)}));var FC=y(2,(e,t)=>M(()=>{if(e.shutdownFlag.current||ve(e.ended.current))return b(!1);let n=e.pubsub.publishAll(t);if(e.strategy.completeSubscribersUnsafe(e.pubsub,e.subscribers),n.length===0)return b(!0);return e.strategy.handleSurplus(e.pubsub,e.subscribers,n,e.shutdownFlag)})),hu=(e)=>Xo(Gr((t)=>{let n=Lt(t,ut),r=cn(e.scope),o=r$(e.pubsub,e.subscribers,e.strategy,e.ended);return Me(r,e$(o)).pipe(gt(dr(n,(s)=>Te(r,s))),nt(o))})),e$=(e)=>Xo(dt((t)=>(mp(e.shutdownFlag,!0),Jr(Fs(e.pollers),(n)=>hy(n,t.id),{discard:!0,concurrency:"unbounded"}).pipe(xt(()=>L(()=>{e.subscribers.delete(e.subscription),e.subscription.unsubscribe(),e.replayWindow.close(),e.strategy.onPubSubEmptySpaceUnsafe(e.pubsub,e.subscribers)})),gy(e.shutdownHook.open),lr)))),Tp=(e)=>M(()=>{if(e.shutdownFlag.current)return Kn;if(e.replayWindow.remaining>0){let n=e.replayWindow.take();return b(n)}let t=e.pollers.length===0?e.subscription.poll():an;if(t===an)return NC(e);else return e.strategy.onPubSubEmptySpaceUnsafe(e.pubsub,e.subscribers),b(t)}),DC=(e)=>M(function t(n){if(e.shutdownFlag.current)return Kn;let r=e.pollers.length===0?e.subscription.pollUpTo(Number.POSITIVE_INFINITY):[];if(n)r=n.concat(r);if(e.strategy.onPubSubEmptySpaceUnsafe(e.pubsub,e.subscribers),e.replayWindow.remaining>0)return b(e.replayWindow.takeAll().concat(r));else if(!Sn(r))return A(NC(e),(o)=>t([o]));return b(r)}),NC=(e)=>Gn((t)=>{if(e.shutdownFlag.current)return t(Kn);if(ve(e.ended.current))return t(b(e.ended.current.value));let n=pu(),r=e.subscribers.get(e.subscription);if(!r)r=new Set,e.subscribers.set(e.subscription,r);if(r.add(e.pollers),Wr(e.pollers,n),e.strategy.completePollersUnsafe(e.pubsub,e.subscribers,e.subscription,e.pollers),n.effect)return t(n.effect);return n.resumes=[t],L(()=>PC(e.pollers,n))});var ft=Symbol.for("effect/PubSub/AbsentValue"),t$=(e,t,n)=>{if(!e.has(t))e.set(t,new Set);e.get(t).add(n)},n$=(e,t,n)=>{if(!e.has(t))return;let r=e.get(t);if(r.delete(n),r.size===0)e.delete(t)},r$=(e,t,n,r)=>new JC(e,t,e.subscribe(),Yo(),ct(!1),hc(!1),n,e.replayWindow(),r);class BC{array;replayIndices;publisherIndex=0;subscribers;subscriberCount=0;subscribersIndex=0;capacity;replayBuffer;constructor(e,t){this.capacity=e,this.replayBuffer=t,this.array=Array.from({length:e}),this.replayIndices=t?Array.from({length:e}):[],this.subscribers=Array.from({length:e})}replayWindow(){return this.replayBuffer?new gu(this.replayBuffer):Ap}isEmpty(){return this.publisherIndex===this.subscribersIndex}isFull(){return this.publisherIndex===this.subscribersIndex+this.capacity}size(){return this.publisherIndex-this.subscribersIndex}publish(e){if(this.isFull())return!1;let t=this.replayBuffer?.offer(e);if(this.subscriberCount!==0){let n=this.publisherIndex%this.capacity;if(this.array[n]=e,t!==void 0)this.replayIndices[n]=t;this.subscribers[n]=this.subscriberCount,this.publisherIndex+=1}return!0}publishAll(e){if(this.subscriberCount===0){if(this.replayBuffer)this.replayBuffer.offerAll(e);return[]}let t=_t(e),n=t.length,r=this.publisherIndex-this.subscribersIndex,o=this.capacity-r,s=Math.min(n,o);if(s===0)return t;let a=0,i=this.publisherIndex+s;while(this.publisherIndex!==i){let c=t[a++],f=this.publisherIndex%this.capacity;this.array[f]=c;let u=this.replayBuffer?.offer(c);if(u!==void 0)this.replayIndices[f]=u;this.subscribers[f]=this.subscriberCount,this.publisherIndex+=1}return t.slice(a)}slide(){if(this.subscribersIndex!==this.publisherIndex){let e=this.subscribersIndex%this.capacity,t=this.array[e];this.array[e]=ft,this.subscribers[e]=0,this.subscribersIndex+=1,this.replayBuffer?.slide(t,this.replayIndices[e])}}subscribe(){return this.subscriberCount+=1,new LC(this,this.publisherIndex,!1)}}class LC{self;subscriberIndex;unsubscribed;constructor(e,t,n){this.self=e,this.subscriberIndex=t,this.unsubscribed=n}isEmpty(){return this.unsubscribed||this.self.publisherIndex===this.subscriberIndex||this.self.publisherIndex===this.self.subscribersIndex}size(){if(this.unsubscribed)return 0;return this.self.publisherIndex-Math.max(this.subscriberIndex,this.self.subscribersIndex)}poll(){if(this.unsubscribed)return an;if(this.subscriberIndex=Math.max(this.subscriberIndex,this.self.subscribersIndex),this.subscriberIndex!==this.self.publisherIndex){let e=this.subscriberIndex%this.self.capacity,t=this.self.array[e];if(this.self.subscribers[e]-=1,this.self.subscribers[e]===0)this.self.array[e]=ft,this.self.subscribersIndex+=1;return this.subscriberIndex+=1,t}return an}pollUpTo(e){if(e=ht(e),this.unsubscribed)return[];this.subscriberIndex=Math.max(this.subscriberIndex,this.self.subscribersIndex);let t=this.self.publisherIndex-this.subscriberIndex,n=Math.min(e,t);if(n<=0)return[];let r=[],o=this.subscriberIndex+n;while(this.subscriberIndex!==o){let s=this.subscriberIndex%this.self.capacity,a=this.self.array[s];if(this.self.subscribers[s]-=1,this.self.subscribers[s]===0)this.self.array[s]=ft,this.self.subscribersIndex+=1;r.push(a),this.subscriberIndex+=1}return r}unsubscribe(){if(!this.unsubscribed){this.unsubscribed=!0,this.self.subscriberCount-=1,this.subscriberIndex=Math.max(this.subscriberIndex,this.self.subscribersIndex);while(this.subscriberIndex!==this.self.publisherIndex){let e=this.subscriberIndex%this.self.capacity;if(this.self.subscribers[e]-=1,this.self.subscribers[e]===0)this.self.array[e]=ft,this.self.subscribersIndex+=1;this.subscriberIndex+=1}}}}class zC{array;replayIndices;mask;publisherIndex=0;subscribers;subscriberCount=0;subscribersIndex=0;capacity;replayBuffer;constructor(e,t){this.capacity=e,this.replayBuffer=t,this.array=Array.from({length:e}),this.replayIndices=t?Array.from({length:e}):[],this.mask=e-1,this.subscribers=Array.from({length:e})}replayWindow(){return this.replayBuffer?new gu(this.replayBuffer):Ap}isEmpty(){return this.publisherIndex===this.subscribersIndex}isFull(){return this.publisherIndex===this.subscribersIndex+this.capacity}size(){return this.publisherIndex-this.subscribersIndex}publish(e){if(this.isFull())return!1;let t=this.replayBuffer?.offer(e);if(this.subscriberCount!==0){let n=this.publisherIndex&this.mask;if(this.array[n]=e,t!==void 0)this.replayIndices[n]=t;this.subscribers[n]=this.subscriberCount,this.publisherIndex+=1}return!0}publishAll(e){if(this.subscriberCount===0){if(this.replayBuffer)this.replayBuffer.offerAll(e);return[]}let t=_t(e),n=t.length,r=this.publisherIndex-this.subscribersIndex,o=this.capacity-r,s=Math.min(n,o);if(s===0)return t;let a=0,i=this.publisherIndex+s;while(this.publisherIndex!==i){let c=t[a++],f=this.publisherIndex&this.mask;this.array[f]=c;let u=this.replayBuffer?.offer(c);if(u!==void 0)this.replayIndices[f]=u;this.subscribers[f]=this.subscriberCount,this.publisherIndex+=1}return t.slice(a)}slide(){if(this.subscribersIndex!==this.publisherIndex){let e=this.subscribersIndex&this.mask,t=this.array[e];this.array[e]=ft,this.subscribers[e]=0,this.subscribersIndex+=1,this.replayBuffer?.slide(t,this.replayIndices[e])}}subscribe(){return this.subscriberCount+=1,new $C(this,this.publisherIndex,!1)}}class $C{self;subscriberIndex;unsubscribed;constructor(e,t,n){this.self=e,this.subscriberIndex=t,this.unsubscribed=n}isEmpty(){return this.unsubscribed||this.self.publisherIndex===this.subscriberIndex||this.self.publisherIndex===this.self.subscribersIndex}size(){if(this.unsubscribed)return 0;return this.self.publisherIndex-Math.max(this.subscriberIndex,this.self.subscribersIndex)}poll(){if(this.unsubscribed)return an;if(this.subscriberIndex=Math.max(this.subscriberIndex,this.self.subscribersIndex),this.subscriberIndex!==this.self.publisherIndex){let e=this.subscriberIndex&this.self.mask,t=this.self.array[e];if(this.self.subscribers[e]-=1,this.self.subscribers[e]===0)this.self.array[e]=ft,this.self.subscribersIndex+=1;return this.subscriberIndex+=1,t}return an}pollUpTo(e){if(e=ht(e),this.unsubscribed)return[];this.subscriberIndex=Math.max(this.subscriberIndex,this.self.subscribersIndex);let t=this.self.publisherIndex-this.subscriberIndex,n=Math.min(e,t);if(n<=0)return[];let r=[],o=this.subscriberIndex+n;while(this.subscriberIndex!==o){let s=this.subscriberIndex&this.self.mask,a=this.self.array[s];if(this.self.subscribers[s]-=1,this.self.subscribers[s]===0)this.self.array[s]=ft,this.self.subscribersIndex+=1;r.push(a),this.subscriberIndex+=1}return r}unsubscribe(){if(!this.unsubscribed){this.unsubscribed=!0,this.self.subscriberCount-=1,this.subscriberIndex=Math.max(this.subscriberIndex,this.self.subscribersIndex);while(this.subscriberIndex!==this.self.publisherIndex){let e=this.subscriberIndex&this.self.mask;if(this.self.subscribers[e]-=1,this.self.subscribers[e]===0)this.self.array[e]=ft,this.self.subscribersIndex+=1;this.subscriberIndex+=1}}}}class qC{publisherIndex=0;subscriberCount=0;subscribers=0;value=ft;replayIndex=0;capacity=1;replayBuffer;constructor(e){this.replayBuffer=e}replayWindow(){return this.replayBuffer?new gu(this.replayBuffer):Ap}pipe(){return de(this,arguments)}isEmpty(){return this.subscribers===0}isFull(){return!this.isEmpty()}size(){return this.isEmpty()?0:1}publish(e){if(this.isFull())return!1;let t=this.replayBuffer?.offer(e);if(this.subscriberCount!==0){if(this.value=e,t!==void 0)this.replayIndex=t;this.subscribers=this.subscriberCount,this.publisherIndex+=1}return!0}publishAll(e){if(this.subscriberCount===0){if(this.replayBuffer)this.replayBuffer.offerAll(e);return[]}let t=_t(e);if(t.length===0)return t;if(this.publish(t[0]))return t.slice(1);else return t}slide(){if(this.isFull()){let e=this.value;this.subscribers=0,this.value=ft,this.replayBuffer?.slide(e,this.replayIndex)}}subscribe(){return this.subscriberCount+=1,new HC(this,this.publisherIndex,!1)}}class HC{self;subscriberIndex;unsubscribed;constructor(e,t,n){this.self=e,this.subscriberIndex=t,this.unsubscribed=n}isEmpty(){return this.unsubscribed||this.self.subscribers===0||this.subscriberIndex===this.self.publisherIndex}size(){return this.isEmpty()?0:1}poll(){if(this.isEmpty())return an;let e=this.self.value;if(this.self.subscribers-=1,this.self.subscribers===0)this.self.value=ft;return this.subscriberIndex=this.self.publisherIndex,e}pollUpTo(e){if(ht(e)<1||this.isEmpty())return[];return[this.poll()]}unsubscribe(){if(!this.unsubscribed){if(this.unsubscribed=!0,this.self.subscriberCount-=1,this.self.subscribers!==0&&this.subscriberIndex!==this.self.publisherIndex){if(this.self.subscribers-=1,this.self.subscribers===0)this.self.value=ft}}}}class jC{publisherHead={value:ft,replayIndex:void 0,subscribers:0,next:null};publisherTail=this.publisherHead;publisherIndex=0;subscribersIndex=0;capacity=Number.MAX_SAFE_INTEGER;replayBuffer;constructor(e){this.replayBuffer=e}replayWindow(){return this.replayBuffer?new gu(this.replayBuffer):Ap}isEmpty(){return this.publisherHead===this.publisherTail}isFull(){return!1}size(){return this.publisherIndex-this.subscribersIndex}publish(e){let t=this.replayBuffer?.offer(e),n=this.publisherTail.subscribers;if(n!==0){let r={value:e,replayIndex:t,subscribers:n,next:null};this.publisherTail.next=r,this.publisherTail=this.publisherTail.next,this.publisherIndex+=1}return!0}publishAll(e){if(this.publisherTail.subscribers!==0)for(let t of e)this.publish(t);else if(this.replayBuffer)this.replayBuffer.offerAll(e);return[]}slide(){if(this.publisherHead!==this.publisherTail){let e=this.publisherHead.next,t=e.value;this.publisherHead=this.publisherHead.next,this.publisherHead.value=ft,this.subscribersIndex+=1,this.replayBuffer?.slide(t,e.replayIndex)}}subscribe(){return this.publisherTail.subscribers+=1,new WC(this,this.publisherTail,this.publisherIndex,!1)}}class WC{self;subscriberHead;subscriberIndex;unsubscribed;constructor(e,t,n,r){this.self=e,this.subscriberHead=t,this.subscriberIndex=n,this.unsubscribed=r}isEmpty(){if(this.unsubscribed)return!0;let e=!0,t=!0;while(t)if(this.subscriberHead===this.self.publisherTail)t=!1;else if(this.subscriberHead.next.value!==ft)e=!1,t=!1;else this.subscriberHead=this.subscriberHead.next,this.subscriberIndex+=1;return e}size(){if(this.unsubscribed)return 0;return this.self.publisherIndex-Math.max(this.subscriberIndex,this.self.subscribersIndex)}poll(){if(this.unsubscribed)return an;let e=!0,t=an;while(e)if(this.subscriberHead===this.self.publisherTail)e=!1;else{let n=this.subscriberHead.next.value;if(n!==ft){if(t=n,this.subscriberHead.subscribers-=1,this.subscriberHead.subscribers===0)this.self.publisherHead=this.self.publisherHead.next,this.self.publisherHead.value=ft,this.self.subscribersIndex+=1;e=!1}this.subscriberHead=this.subscriberHead.next,this.subscriberIndex+=1}return t}pollUpTo(e){e=ht(e);let t=[],n=0;while(n!==e){let r=this.poll();if(r===an)n=e;else t.push(r),n+=1}return t}unsubscribe(){if(!this.unsubscribed){this.unsubscribed=!0,this.self.publisherTail.subscribers-=1;while(this.subscriberHead!==this.self.publisherTail){if(this.subscriberHead.next.value!==ft){if(this.subscriberHead.subscribers-=1,this.subscriberHead.subscribers===0)this.self.publisherHead=this.self.publisherHead.next,this.self.publisherHead.value=ft,this.self.subscribersIndex+=1}this.subscriberHead=this.subscriberHead.next}}}}class JC{[Yz]={_A:Q};pubsub;subscribers;subscription;pollers;shutdownHook;shutdownFlag;strategy;replayWindow;ended;constructor(e,t,n,r,o,s,a,i,c){this.pubsub=e,this.subscribers=t,this.subscription=n,this.pollers=r,this.shutdownHook=o,this.shutdownFlag=s,this.strategy=a,this.replayWindow=i,this.ended=c}pipe(){return de(this,arguments)}}class GC{[Qz]={_A:Q};pubsub;subscribers;scope;shutdownHook;shutdownFlag;strategy;ended;constructor(e,t,n,r,o,s,a){this.pubsub=e,this.subscribers=t,this.scope=n,this.shutdownHook=r,this.shutdownFlag=o,this.strategy=s,this.ended=a}pipe(){return de(this,arguments)}}var o$=(e,t,n,r,o,s,a)=>new GC(e,t,n,r,o,s,a),s$=(e)=>{if(e<=0)throw Error(`Cannot construct PubSub with capacity of ${e}`)};class yy{publishers=Yo();get shutdown(){return dt((e)=>Jr(Fs(this.publishers),([t,n,r])=>r?hy(n,e.id):R,{concurrency:"unbounded",discard:!0}))}handleSurplus(e,t,n,r){return Gn((o)=>{let s=pu();if(this.offerUnsafe(n,s),this.onPubSubEmptySpaceUnsafe(e,t),this.completeSubscribersUnsafe(e,t),vC(r))return this.removeUnsafe(s),o(Kn);if(s.effect)return o(s.effect);return s.resumes=[o],L(()=>this.removeUnsafe(s))})}onPubSubEmptySpaceUnsafe(e,t){let n=!0;while(n&&!e.isFull()){let r=Fa(this.publishers);if(r===an)n=!1;else{let[o,s]=r,a=e.publish(o);if(a&&r[2])Da(s,xn(!0));else if(!a)ly(this.publishers,r);this.completeSubscribersUnsafe(e,t)}}}completePollersUnsafe(e,t,n,r){return Ey(this,e,t,n,r)}completeSubscribersUnsafe(e,t){return by(this,e,t)}offerUnsafe(e,t){let n=e[Symbol.iterator](),r=n.next();if(!r.done)while(!0){let o=r.value;if(r=n.next(),r.done){Wr(this.publishers,[o,t,!0]);break}Wr(this.publishers,[o,t,!1])}}removeUnsafe(e){py(this.publishers,([t,n])=>n!==e)}}class Sy{get shutdown(){return R}handleSurplus(e,t,n,r){return b(!1)}onPubSubEmptySpaceUnsafe(e,t){}completePollersUnsafe(e,t,n,r){return Ey(this,e,t,n,r)}completeSubscribersUnsafe(e,t){return by(this,e,t)}}class KC{get shutdown(){return R}handleSurplus(e,t,n,r){return L(()=>(this.slidingPublishUnsafe(e,n),this.completeSubscribersUnsafe(e,t),!0))}onPubSubEmptySpaceUnsafe(e,t){}completePollersUnsafe(e,t,n,r){return Ey(this,e,t,n,r)}completeSubscribersUnsafe(e,t){return by(this,e,t)}slidingPublishUnsafe(e,t){let n=t[Symbol.iterator](),r=n.next();if(!r.done&&e.capacity>0){let o=r.value,s=!0;while(s){e.slide();let a=e.publish(o);if(a&&(r=n.next())&&!r.done)o=r.value;else if(a)s=!1}}}}var Ey=(e,t,n,r,o)=>{let s=!0;while(s&&!r.isEmpty()){let a=Fa(o);if(a===an)if(n$(n,r,o),o.length===0)s=!1;else t$(n,r,o);else{let i=r.poll();if(i===an)ly(o,a);else Da(a,xn(i)),e.onPubSubEmptySpaceUnsafe(t,n)}}},by=(e,t,n)=>{for(let[r,o]of n)for(let s of o)e.completePollersUnsafe(t,n,r,s)};class Iy{capacity;head={value:ft,index:0,next:null};tail=this.head;slideValues=[];size=0;index=0;publisherIndex=0;constructor(e){this.capacity=e}slide(e,t){this.slideValues[this.index%this.capacity]={value:e,index:t},this.index++}offer(e){let t=this.publisherIndex++;if(this.tail.value=e,this.tail.index=t,this.tail.next={value:ft,index:0,next:null},this.tail=this.tail.next,this.size===this.capacity)this.head=this.head.next;else this.size+=1;return t}offerAll(e){for(let t of e)this.offer(t)}}class gu{buffer;values;index=0;remaining;slideIndex;newestIndex=-1;constructor(e){this.buffer=e,this.remaining=e.size,this.slideIndex=e.index,this.values=Array(this.remaining);let t=e.head;for(let n=0;n<this.remaining;n++)this.values[n]=t.value,this.newestIndex=t.index,t=t.next}close(){this.values.length=0,this.remaining=0}sync(){let e=this.buffer.index-this.slideIndex;if(e===0||this.remaining===0)return;let t=Math.min(e,this.buffer.capacity),n=this.buffer.index-t;for(let r=0;r<t;r++){let o=this.buffer.slideValues[(n+r)%this.buffer.capacity];if(o.index>this.newestIndex)this.index=(this.index+1)%this.values.length,this.values[(this.index+this.remaining-1)%this.values.length]=o.value,this.newestIndex=o.index}this.slideIndex=this.buffer.index}take(){if(this.remaining===0)return;this.sync();let e=this.values[this.index];if(this.values[this.index]=ft,this.index=(this.index+1)%this.values.length,this.remaining--,this.remaining===0)this.close();return e}takeN(e){e=ht(e);let t=Math.min(e,this.remaining),n=Array(t);for(let r=0;r<t;r++)n[r]=this.take();return n}takeAll(){return this.takeN(this.remaining)}}var Ap={remaining:0,take:()=>{return},takeN:()=>[],takeAll:()=>[],close:()=>{return}};var a$="~effect/Queue",i$="~effect/Queue/Enqueue",c$="~effect/Queue/Dequeue";var wy={_A:Q,_E:Q},f$={[a$]:wy,[i$]:wy,[c$]:wy,...Ss,toJSON(){return{_id:"effect/Queue",state:this.state._tag,size:d$(this)}}},hr=(e)=>mr((t)=>{let n=Object.create(f$);return n.dispatcher=t.currentDispatcher,n.capacity=e?.capacity??Number.POSITIVE_INFINITY,n.strategy=e?.strategy??"suspend",n.messages=Yo(),n.scheduleRunning=!1,n.state={_tag:"Open",takers:new Set,offers:new Set,awaiters:new Set},Ns(n)}),Ba=(e)=>hr({capacity:e});var _p=()=>hr(),bn=y(2,(e,t)=>Ao(()=>Rp(e,t)?Up:e.state._tag==="Open"&&e.strategy==="suspend"?h$(e,t):tv)),Rp=(e,t)=>{if(e.state._tag!=="Open")return!1;else if(e.messages.length>=e.capacity){if(e.strategy==="sliding")return Fa(e.messages),Wr(e.messages,t),!0;else if(e.capacity<=0&&e.state.takers.size>0)return Wr(e.messages,t),nv(e),!0;return!1}return Wr(e.messages,t),Cp(e),!0},ts=y(2,(e,t)=>Bs((n)=>{let r=Pp(e,t);if(r.length===0||e.strategy==="dropping")return n(Kr(r));return ov(e,{_tag:"Array",remaining:r,offset:0,resume:n})})),Pp=(e,t)=>{if(e.state._tag!=="Open")return _t(t);else if(e.capacity===Number.POSITIVE_INFINITY||e.strategy==="sliding"){if(hp(e.messages,t),e.strategy==="sliding")Ua(e.messages,e.messages.length-e.capacity);return Cp(e),[]}let n=e.capacity<=0?e.state.takers.size:e.capacity-e.messages.length;if(n===0)return _t(t);let r=[],o=0;for(let s of t){if(o<n)Wr(e.messages,s);else r.push(s);o++}return Cp(e),r};var rt=y(2,(e,t)=>To(()=>Ls(e,t))),Ls=(e,t)=>{if(e.state._tag!=="Open")return!1;let n=ZC(t),r=XC(n,l$);if(e.state.offers.size===0&&e.messages.length===0)return Fp(e,r),!0;return e.state={...e.state,_tag:"Closing",exit:r},Cp(e),!0},gc=(e)=>rt(e,Ty(vp())),Mp=(e)=>Ls(e,Ty(vp()));var Vr=(e)=>To(()=>vy(e)),vy=(e)=>{if(e.state._tag==="Done")return!1;Qo(e.messages);let t=e.state.offers;Fp(e,e.state._tag==="Open"?p$:e.state.exit);for(let n of t)sv(n);return!0};var xc=(e)=>ev(e,1,Number.POSITIVE_INFINITY);var ev=y(3,(e,t,n)=>(t=ht(t),n=ht(n),Ao(()=>m$(e,t,n)??Ay(rv(e,()=>Oy(e,t)),ev(e,t,n))))),Zr=(e)=>Ao(()=>u$(e)??Ay(rv(e,()=>Oy(e,1)),Zr(e)));var u$=(e)=>{if(e.state._tag==="Done")return e.state.exit;if(e.messages.length>0){let t=Fa(e.messages);return ky(e),Kr(t)}else if(e.capacity<=0&&e.state.offers.size>0){let t=av(e.state.offers);return ky(e),Kr(t)}return};var d$=(e)=>e.state._tag==="Done"?0:e.messages.length;var tv=Kr(!1),Up=Kr(!0),l$=QC(vp()),p$=YC(),nv=(e)=>{if(e.state._tag==="Done"||e.state.takers.size===0)return;for(let t of e.state.takers){if(!t.ready())continue;if(e.state.takers.delete(t),t.resume(Cy),e.messages.length===0)break}},Cp=(e)=>{if(e.scheduleRunning||e.state._tag==="Done"||e.state.takers.size===0)return;e.scheduleRunning=!0,e.dispatcher.scheduleTask(()=>{e.scheduleRunning=!1,nv(e)},0)},m$=(e,t,n)=>{if(e.state._tag==="Done")return e.state.exit;else if(n<=0||t<=0)return Kr([]);else if(!Oy(e,t))return;let r=e.messages.length>0?Ua(e.messages,n):[av(e.state.offers)];return ky(e),Kr(r)},Oy=(e,t)=>e.messages.length>=(e.state._tag==="Closing"?1:Math.min(t,e.capacity||1))||e.capacity<=0&&e.state._tag!=="Done"&&e.state.offers.size>0,rv=(e,t)=>Bs((n)=>{if(e.state._tag==="Done")return n(e.state.exit);if(t())return n(Cy);let r={ready:t,resume:n};return e.state.takers.add(r),To(()=>{if(e.state._tag!=="Done")e.state.takers.delete(r)})}),h$=(e,t)=>Bs((n)=>Rp(e,t)?n(Up):ov(e,{_tag:"Single",message:t,resume:n})),ov=(e,t)=>{if(e.state._tag!=="Open")return sv(t);let n=e.state.offers;return n.add(t),To(()=>{if(e.state._tag==="Done")return;if(n.delete(t),e.state._tag==="Closing"&&n.size===0&&e.messages.length===0)Fp(e,e.state.exit)})},sv=(e)=>e._tag==="Single"?e.resume(tv):e.resume(Kr(e.remaining.slice(e.offset))),av=(e)=>{let t=e.values().next().value;if(t._tag==="Single")return e.delete(t),t.resume(Up),t.message;let n=t.remaining[t.offset++];if(t.offset===t.remaining.length)e.delete(t),t.resume(Kr([]));return n},ky=(e)=>{if(e.state._tag==="Done")return es(e.state.exit.cause);else if(e.state.offers.size===0){if(e.state._tag==="Closing"&&e.messages.length===0)return Fp(e,e.state.exit),es(e.state.exit.cause);return!1}for(let t of e.state.offers){let n=e.capacity-e.messages.length;if(n<=0)break;else if(t._tag==="Single")Wr(e.messages,t.message),e.state.offers.delete(t),t.resume(Up);else{for(;t.offset<t.remaining.length;t.offset++){if(n===0)return!1;Wr(e.messages,t.remaining[t.offset]),n--}e.state.offers.delete(t),t.resume(Kr([]))}}return!1};var Fp=(e,t)=>{if(e.state._tag==="Done")return;let n=e.state;e.state={_tag:"Done",exit:t};for(let r of n.takers)r.resume(t);n.takers.clear();for(let r of n.awaiters)r(t);n.awaiters.clear()};var La=(e)=>new uv(e),iv=(e,t,n)=>Bs((r)=>{if(e.free>=t)return r(n);let o=()=>{if(e.free<t)return;e.waiters.delete(o),r(n)};return e.waiters.add(o),To(()=>{e.waiters.delete(o)})});class uv{waiters=new Set;taken=0;permits;constructor(e){this.permits=e}get free(){return this.permits-this.taken}take(e){let t=Ao(()=>{if(this.free<e)return iv(this,e,t);return this.taken+=e,Ns(e)});return t}takeIfAvailable(e){return Ao(()=>{if(this.free<e)return Ns(!1);return this.taken+=e,Ns(!0)})}releaseUnsafe(e,t){if(this.taken-=t,this.waiters.size>0)e.currentDispatcher.scheduleTask(()=>{for(let n of this.waiters){if(this.free<=0)break;n()}},0);return this.free}resize(e){return mr((t)=>{if(this.permits=e,this.free<0)return Co;return this.releaseUnsafe(t,0),Co})}release(e){return mr((t)=>Ns(this.releaseUnsafe(t,e)))}get releaseAll(){return mr((e)=>Ns(this.releaseUnsafe(e,this.taken)))}withPermits(e){return(t)=>Na((n)=>{let r=Ao(()=>{if(this.free<e){let o=iv(this,e,Co);return Su(n(o),()=>r)}return this.taken+=e,yu(n(t),()=>{this.releaseUnsafe(_y(),e);return},!0)});return r})}withPermit=this.withPermits(1);withPermitsIfAvailable(e){return(t)=>Na((n)=>{if(this.free<e)return cv;return this.taken+=e,yu(n(fv(t)),()=>{this.releaseUnsafe(_y(),e);return},!0)})}}var Ry=(e)=>Zo(e)?$e(e)?ee(e.value):e:b(e);var Uv="~effect/Channel",Gt=(e)=>V(e,Uv),y$={[Uv]:{_Env:Q,_InErr:Q,_InElem:Q,_OutErr:Q,_OutElem:Q},pipe(){return de(this,arguments)}},me=(e)=>{let t=Object.create(y$);return t.transform=(n,r)=>De(e(n,r),(o)=>b(He(o))),t},Xr=(e,t)=>me((n,r)=>A(ie(e)(n,r),(o)=>t(o,r))),Ut=(e)=>me((t,n)=>e),eo=(e)=>me(re(function*(t,n){let r=cn(n),o=(a)=>Te(r,Uy(a)),s=yield*Vn(e(t,n,r),o);return Vn(s,o)})),ie=(e)=>e.transform,Au=4096,S$=(e,t,n)=>hr({capacity:n?.bufferSize,strategy:n?.strategy}).pipe(xt((r)=>Me(e,Vr(r))),xt((r)=>Ne(In(t(r),e),e)));var Fv=(e,t)=>me((n,r)=>B(S$(r,e,t),xc)),zp=(e)=>me((t,n)=>M(()=>ie(e())(t,n))),E$=(e,t,n)=>eo(re(function*(r,o,s){let a=ne();yield*dr(s,(c)=>ve(a)?n(a.value,c):R);let i=yield*Xo(e);return a=oe(i),yield*ie(t(i))(r,o)}));var Dv=(e)=>Ut(L(()=>{let t=e();return M(()=>{let n=t.next();return n.done?ee(n.value):b(n.value)})})),By=(e)=>Ut(L(()=>{let t=0;return M(()=>t>=e.length?ee():b(e[t++]))}));var Ly=(e,t=Au)=>{let n=qs(t);return Ut(L(()=>{let r=e(),o=ne();return M(()=>{if(o._tag==="Some")return ee(o.value);let s=[];while(s.length<n){let a=r.next();if(a.done){if(s.length===0)return ee(a.value);o=oe(a.value);break}s.push(a.value)}return b(s)})}))};var Nv=(e,t=Au)=>Ly(()=>e[Symbol.iterator](),t),$p=(e)=>qp(b(e));var Bv=(e)=>qp(L(e)),yc=Ut(b(ee())),Lv=Ut(b(Hs)),Oo=(e)=>Ut(b(_(e))),zv=(e)=>Ut(Fy(e)),Cu=(e)=>Ut(He(e)),$v=(e)=>Ut(Os(e)),zy=(e)=>Cu(Fi(e)),qp=(e)=>Ut(L(()=>{let t=!1;return M(()=>{if(t)return ee();return t=!0,e})}));var qv=(e)=>Ut(A(e,()=>ee())),$y=(e)=>Ut(b(A(e,Ry)));var Hv=(e)=>Ut(b(xc(e)));var qy=(e)=>Ut(b(Ic(DC(e),()=>ee())));var jv=(e)=>no(B(hu(e),qy)),Wv=(e)=>no(B(hu(e),(t)=>$y(Tp(t))));var Jv=(e)=>me((t,n)=>b$({scope:n,readable:e.evaluate(),onError:e.onError,releaseLockOnEnd:e.releaseLockOnEnd}));var b$=(e)=>{let t=e.readable.getReader(),n=e.exit??hc(void 0),r=M(()=>{if(n.current)return n.current;return ns(fr({try:()=>t.read(),catch:e.onError}),{onFailure:(o)=>n.current??He(o),onSuccess:({done:o,value:s})=>{if(n.current)return n.current;return o?ee():b(pe(s))}})});return nt(Me(e.scope,e.releaseLockOnEnd?L(()=>t.releaseLock()):Ec(()=>t.cancel().catch(Mn))),r)},I$=(e,t)=>me(re(function*(n,r){let o=e[Symbol.asyncIterator]();if(o.return)yield*Me(r,Ec(()=>o.return()));return A(fr({try:()=>o.next(),catch:t}),(s)=>s.done?ee(s.value):b(s.value))})),Gv=(e,t)=>to(I$(e,t),pe),to=y(2,(e,t)=>Xr(e,(n)=>L(()=>{let r=0;return B(n,(o)=>t(o,r++))})));var Kv=(e)=>e===void 0||e!=="unbounded"&&e<=1,Hp=y((e)=>Gt(e[0]),(e,t,n)=>Kv(n?.concurrency)?Vv(e,t):w$(e,t,n)),Vv=(e,t)=>me((n,r)=>{let o=0;return B(ie(e)(n,r),A((s)=>t(s,o++)))}),w$=(e,t,n)=>eo(re(function*(r,o,s){let a=0,i=yield*ie(e)(r,o),c=n.concurrency==="unbounded"?Number.MAX_SAFE_INTEGER:n.concurrency,f=yield*Ba(0);yield*Me(s,Vr(f));let u=Fn(yield*Qn()),d=js(s);if(n.unordered){let l=La(c),m=pr(l.release(1)),p=ns({onFailure:(g)=>A(rt(f,g),m),onSuccess:(g)=>A(bn(f,g),m)});yield*l.take(1).pipe(A(()=>i),A((g)=>{let h=a++;return d(u(p(M(()=>t(g,h))))),R}),Ze({disableYield:!0}),De((g)=>l.withPermits(c-1)(rt(f,g))),Ne(s))}else{let l=yield*Ba(c-2);yield*Me(s,Vr(l)),yield*Zr(l).pipe(Ov,A((g)=>bn(f,g)),Ze({disableYield:!0}),De((g)=>rt(f,g)),Ne(s));let m,p=(g)=>{if(g._tag==="Success")return;m=g.cause,Ls(f,g.cause)};yield*i.pipe(A((g)=>{if(m)return He(m);let h=a++,E=u(M(()=>t(g,h)));return d(E),E.addObserver(p),bn(l,$s(E))}),Ze({disableYield:!0}),De((g)=>bn(l,en(g)).pipe(gt(rt(l,g)))),Ne(s))}return Zr(f)}));var Hy=y((e)=>Gt(e[0]),(e,t,n)=>Kv(n?.concurrency)?k$(e,t):T$(e,t,n)),k$=(e,t)=>me((n,r)=>B(ie(e)(n,r),(o)=>{let s,a,i=A(o,(f)=>(a??=cn(r),Pt(ie(t(f))(n,a),(u)=>(s=c(u),s)))),c=lt((f)=>{if(s=void 0,a.state._tag==="Empty")return i;let u=Te(a,Ye);return a=void 0,A(u,()=>i)});return M(()=>s??i)})),T$=(e,t,n)=>e.pipe(to(t),Jp(n)),Zv=y(2,(e,t)=>me((n,r)=>L(()=>{let o,s=cn(r),a=A(ie(e)(n,s),(i)=>(o=lt(i,(c)=>Te(s,Ye).pipe(A(()=>ie(t(c))(n,r)),A((f)=>(o=f,f)))),o));return M(()=>o??a)})));var jy=y(4,(e,t,n,r)=>me(re(function*(o,s){let a=yield*ie(e)(o,s),i=yield*ie(t)(o,s),c=n();return M(()=>{let f=r(c,a,i);return B(f,([u,d])=>(c=d,u))})}))),Qv=y(2,(e,t)=>me((n,r)=>L(()=>{let o,s=cn(r),a=A(ie(e)(n,s),(i)=>{let c=i.pipe(xt(()=>(o=i,R)),lt((f)=>Te(s,xn(f)).pipe(gt(ie(t(f))(n,r)),A((u)=>(o=u,u)))));return o=c,c});return M(()=>o??a)}))),Yv=(e)=>Hy(e,Q),un=(e)=>Xr(e,(t)=>{let n,r=0,o=M(function s(){if(n===void 0)return A(t,(i)=>{switch(i.length){case 0:return s();case 1:return b(i[0]);default:return n=i,b(i[r++])}});let a=n[r++];if(r>=n.length)n=void 0,r=0;return b(a)});return b(o)}),Xv=(e)=>Vv(e,Ry),eO=(e)=>Xr(e,(t)=>b(Ze(t,{disableYield:!0}))),tO=y(2,(e,t)=>Sc(typeof t==="function"?t(Q):t).pipe(B((n)=>{let r=Qr.defaultValue();return nO(Zp(e,Qr,L(()=>r)),(o)=>n(o).pipe(B((s)=>{r=s}),lt(()=>ee(o))))}),no)),nO=(e,t)=>me((n,r)=>L(()=>{let o,s=()=>{let a=cn(r);return A(ie(e)(n,a),(i)=>(o=lt(i,(c)=>Te(a,Ye).pipe(A(()=>t(c)),A(s))),o))};return M(()=>o??s())})),rO=(e)=>nO(e,()=>R),oO=y(2,(e,t)=>Xr(e,(n,r)=>B(Iu(t),(o)=>xt(n,o)))),sO=y(2,(e,t)=>me((n,r)=>B(ie(e)(n,r),(o)=>A(o,function s(a){return t(a)?b(a):A(o,s)}))));var aO=y(2,(e,t)=>Xr(e,(n)=>b(A(n,function r(o){let s=[];for(let a=0;a<o.length;a++)if(t(o[a]))s.push(o[a]);return Ke(s)?b(s):A(n,r)})))),iO=y(2,(e,t)=>Xr(e,(n)=>b(A(n,function r(o){let s=[];for(let a=0;a<o.length;a++){let i=t(o[a]);if(At(i))s.push(i.success)}return Ke(s)?b(s):A(n,r)})))),cO=y(2,(e,t)=>Xr(e,(n)=>{let r=A(n,(o)=>Rv(o,t));return b(A(r,function o(s){return Ke(s)?b(s):A(r,o)}))})),fO=y(2,(e,t)=>Xr(e,(n)=>b(A(n,function r(o){return A(Pv(o,t),(s)=>Ke(s)?b(s):A(n,r))})))),wc=y((e)=>Gt(e[0]),(e,t,n,r)=>me((o,s)=>B(ie(e)(o,s),(a)=>{let i=t(),c,f=0,u,d=ns(a,{onFailure(m){u=m;let p=r?.onHalt&&r.onHalt(i);return p&&p.length>0?b([i,p]):He(m)},onSuccess(m){let p=n(i,m);return gv(p)?b(p):p}});return M(function m(){if(c===void 0){if(u)return He(u);return A(d,([g,h])=>{if(i=g,h.length===0)return m();else if(h.length===1)return b(h[0]);return c=h,m()})}let p=c[f++];if(f>=c.length)c=void 0,f=0;return b(p)})})));var uO=y(3,(e,t,n)=>me((r,o)=>B(ie(e)(r,o),(s)=>{let a=t,i=!0;return M(()=>{if(i)return i=!1,b(a);return B(A(s,(c)=>n(a,c)),(c)=>(a=c,a))})}))),kc=y(2,(e,t)=>me((n,r)=>{let o=cn(r);return B(ie(e)(n,o),(s)=>{let a=s.pipe(De((i)=>{if(es(i))return He(i);let c=o;return o=cn(r),Te(c,en(i)).pipe(gt(ie(t(i))(n,o)),A((f)=>(a=f,f)))}));return M(()=>a)})})),dO=y(2,(e,t)=>Wp(e,Np,t)),jp=y(2,(e,t)=>kc(e,(n)=>qv(A(t(n),(r)=>He(n))))),lO=y(3,(e,t,n)=>kc(e,(r)=>t(r)?n(r):Cu(r))),Wp=y(3,(e,t,n)=>kc(e,(r)=>{let o=t(r);return Bt(o)?Cu(o.failure):n(o.success,r)})),Yr=y(2,(e,t)=>Wp(e,bu,(n)=>t(n)));var pO=y(2,(e,t)=>Xr(e,(n)=>b(Ny(n,(r)=>My(r)?R:lr(t(r)))))),mO=y((e)=>Gt(e[0]),(e,t,n,r)=>Yr(e,(o)=>t(o)?n(o):r?r(o):Oo(o))),hO=y((e)=>Gt(e[0]),(e,t,n,r)=>Yr(e,(o)=>{let s=t(o);return Bt(s)?r?r(s.failure):Oo(s.failure):n(s.success)}));var gO=y((e)=>Gt(e[0]),(e,t,n,r,o)=>Yr(e,(s)=>{if(vo(s,t)&&V(s,"reason")){let a=s.reason;if(vo(a,n))return r(a,s);return o?o(a,s):Oo(s)}return Oo(s)})),xO=y((e)=>Gt(e[0]),(e,t,n,r)=>{let o;return Yr(e,(s)=>{if(vo(s,t)&&V(s,"reason")&&V(s.reason,"_tag")&&Bp(s.reason._tag)){let a=s.reason;if(o??=new Set(Object.keys(n)),o.has(a._tag))return n[a._tag](a,s);return r?r(a,s):Oo(s)}return Oo(s)})});var yO=y(2,(e,t)=>Yr(e,(n)=>Oo(t(n)))),SO=(e)=>Yr(e,zy),EO=y((e)=>Gt(e[0]),(e,t)=>{if(!t?.log)return Yr(e,()=>yc);let n=ku(t.log===!0?void 0:t.log);return Yr(jp(e,(r)=>Ev(r)?n(r):R),()=>yc)}),lv=(e)=>kc(e,()=>yc),bO=y((e)=>Gt(e[0]),(e,t)=>{if(!t?.log)return lv(e);let n=ku(t.log===!0?void 0:t.log);return lv(jp(e,(r)=>n(r)))}),IO=y(2,(e,t)=>zp(()=>{let n=void 0,r=Qr.defaultValue(),o=Zp(e,Qr,L(()=>r)),s=Gy(o,()=>(n=void 0,R)),a=typeof t==="function"?t(Q):t,i=Yr(s,re(function*(c){if(!n)n=yield*Sc(a);return r=yield*n(c),i},(c,f)=>lt(c,()=>b(Oo(f))),no));return i})),wO=y((e)=>Gt(e[0]),(e,t,n)=>e.pipe(to(t),Jp({...n,concurrency:n?.concurrency??1,switch:!0}))),Jp=y(2,(e,{bufferSize:t=16,concurrency:n,switch:r=!1})=>eo(re(function*(o,s,a){let i=n==="unbounded"?Number.MAX_SAFE_INTEGER:Math.max(1,n),c=r?void 0:La(i),f=yield*AC(!0),u=new Set,d=yield*Ba(t);yield*Me(a,Vr(d));let l=yield*ie(e)(o,s);return yield*je(function*(){while(!0){let m;if(c)if(u.size<i)yield*c.take(1);else m=yield*Eu(l),yield*za(c.take(1),gt($s(m),Hs));let p=m===void 0?yield*l:yield*$s(m),g=cn(a),h=yield*ie(p)(o,g);while(u.size>=i){let S=hv(u);if(u.delete(S),u.size===0)yield*f.open;yield*fn(S)}let E=yield*h.pipe(xt(()=>Lp),A((S)=>bn(d,S)),Ze({disableYield:!0}),Vn(re(function*(S){let k=Py(S);if(yield*or(Te(g,!Bt(k)?xn(k.success.value):en(k.failure))),!u.has(E))return;if(u.delete(E),c)yield*c.release(1);if(u.size===0)yield*f.open;if(At(k))return;return yield*rt(d,S)})),Eu);f.closeUnsafe(),u.add(E)}}).pipe(De((m)=>{let p=Py(m);if(At(p))return f.whenOpen(rt(d,m));return rt(d,m)}),Ne(a)),Zr(d)}))),Gp=y((e)=>Gt(e[0])&&Gt(e[1]),(e,t,n)=>eo(re(function*(r,o,s){let a=n?.haltStrategy??"both",i=yield*Ba(0);yield*Me(s,Vr(i));let c=0;function f(d,l){if(c++,!es(l))return rt(i,l);switch(a){case"both":return c===2?rt(i,l):R;case"left":case"right":return d===a?rt(i,l):R;case"either":return rt(i,l)}}let u=(d,l,m)=>ie(l)(r,m).pipe(A((p)=>p.pipe(A((g)=>bn(i,g)),Ze)),Vn((p)=>gt(Te(m,Uy(p)),f(d,p))),Ne(s));return yield*u("left",e,cn(s)),yield*u("right",t,cn(s)),Zr(i)}))),kO=y(2,(e,t)=>Gp(e,qv(t),{haltStrategy:"left"})),TO=()=>me((e,t)=>L(()=>{let n="",r=!1,o=ne();function s(c){let f=[];function u(d){if(n.length===0)f.push(d);else f.push(n+d),n=""}for(let d=0;d<c.length;d++){let l=c[d];if(l.length!==0){let m=0,p=l.indexOf("\r"),g=l.indexOf(`
|
|
2
|
+
import{_d as uU,ae as ME,be as na,ce as Wc}from"./index-hmpxsbxe.js";import{$A as ns,$B as $s,$u as Le,$v as Ew,$w as hn,$x as kC,$y as wv,$z as Ec,AA as nt,AB as sU,Au as Ds,Av as Kr,Aw as Bt,Ax as Dp,Ay as Zo,Az as Ib,BA as Dy,BB as FS,Bu as Mn,Bv as VC,Bw as At,Bx as _y,By as xn,Bz as wb,CA as lr,CB as mm,Cu as bh,Cv as ZC,Cw as qx,Cx as Ns,Cy as en,Cz as kb,DA as y_,DB as Eu,Du as ja,Dv as mr,Dw as vr,Dx as To,Dy as So,Dz as VT,EA as bc,EB as Ne,Eu as Ln,Ev as jT,Ew as Pr,Ex as Ao,Ey as Xp,Ez as PC,FA as De,FB as Ro,Fu as ya,Fv as vp,Fw as Mf,Fx as iv,Fy as xp,Fz as Bp,GA as Ov,GB as DS,Gu as Eh,Gv as Ar,Gw as rf,Gx as Co,Gy as Ye,Gz as KI,HA as eU,HB as Fl,Hu as ys,Hv as da,Hw as Tt,Hx as Bs,Hy as $e,Hz as lt,IA as lP,IB as Fn,Iu as Vw,Iv as Q0,Iw as II,Ix as cv,Iy as bo,Iz as es,JA as Fu,JB as w_,Ju as Zw,Jv as BE,Jw as d_,Jx as Ay,Jy as ZO,Jz as Py,KA as ls,KB as k_,Ku as Qw,Kv as LE,Kw as mv,Kx as Su,Ky as bv,Kz as dP,LA as Ny,LB as Gg,Lu as Yw,Lv as Zi,Lw as Cd,Lx as qt,Ly as Yt,Lz as Uy,MA as CE,MB as Uc,Mu as il,Mv as Qi,Mw as SI,Mx as QC,My as pu,Mz as Av,NA as US,NB as Jo,Nu as On,Nv as Yi,Nw as nS,Nx as Cy,Ny as QO,Nz as Qr,OA as tU,OB as re,Ou as ws,Ov as ad,Ow as _t,Ox as YC,Oy as hy,Oz as h_,PA as vE,PB as Ru,Pu as $M,Pv as id,Pw as _E,Px as QR,Py as Da,Pz as Sc,QA as nU,QB as ku,Qu as cl,Qv as cd,Qw as Md,Qx as YR,Qy as Iv,Qz as Iu,RA as rU,RB as em,Ru as Xw,Rv as fd,Rw as $h,Rx as XR,Ry as nP,Rz as YM,SA as Im,SB as OE,Su as Sg,Sv as ne,Sw as hv,Sx as yu,Sy as ut,Sz as XM,TA as Ks,TB as qd,Tu as Ku,Tv as oe,Tw as Sn,Tx as eP,Ty as ko,Tz as Du,UA as Ws,UB as Hd,Uu as st,Uv as Xi,Uw as Ke,Ux as tP,Uy as In,Uz as g_,VA as S_,VB as Ht,Vu as rl,Vv as Tn,Vw as $d,Vx as hm,Vy as dr,Vz as wu,WA as za,WB as Pt,Wu as V,Wv as ve,Ww as l_,Wx as Na,Wy as Me,Wz as x_,XA as _v,XB as Hx,Xu as vo,Xv as zt,Xw as Yp,Xx as ol,Xy as HS,Xz as rS,YA as Rv,YB as ek,Yu as gw,Yv as WT,Yw as fh,Yx as fl,Yy as cn,Yz as fm,ZA as gy,ZB as Y,Zu as Be,Zv as Zd,Zw as Xt,Zx as ul,Zy as Te,Zz as Jr,_A as $0,_B as T_,_u as We,_v as Sw,_w as pe,_x as wC,_y as Jn,_z as gr,aA as fr,aB as Qn,aC as A_,av as mo,aw as sg,ax as md,ay as xv,az as kv,bA as b,bB as Gr,bC as fn,bv as Bn,bw as Ef,bx as wI,by as yv,bz as Tv,cA as Si,cB as SR,cC as Fo,cv as mn,cw as rh,cx as hd,cy as rc,cz as Ys,dA as Cv,dB as Jt,dC as js,dv as xI,dw as u_,dx as Zt,dy as oc,dz as qM,eA as M,eB as E_,ev as oi,ew as qo,ex as JT,ey as Ld,ez as Dc,fA as L,fB as _c,fC as Pu,fv as ze,fw as bi,fx as tc,fy as Gf,fz as kS,gA as R,gB as Qs,gC as Mo,gv as he,gw as yi,gx as xs,gy as Fi,gz as Zn,hA as xm,hB as oU,hC as Mu,hv as Nl,hx as _u,hy as Kf,hz as m_,iA as Gn,iB as zs,iC as Tc,iv as Bl,iw as Ft,ix as KO,iy as Vf,iz as ob,jA as Hs,jB as Yn,jC as Qp,jv as yI,jw as Ac,jx as nc,jy as Yf,jz as sb,kA as je,kB as Ja,kC as YO,kv as ui,kw as pv,kx as Yl,ky as p_,kz as ab,lA as _,lB as b_,lv as K,lw as Do,lx as Zf,ly as Ts,lz as ib,mA as Fy,mB as xr,mv as Sa,mw as yR,mx as Qf,my as Oc,mz as cb,nA as He,nB as _o,nv as Bd,nw as Un,nx as nI,ny as Sv,nz as fb,oA as Os,oB as Vn,ov as xw,ow as um,ox as Wn,oy as bu,oz as ub,pA as _n,pB as I_,pv as yw,pw as Cc,px as rI,py as Np,pz as db,qA as Mr,qB as yr,qC as RE,qv as Re,qw as Lt,qx as GT,qy as AE,qz as lb,rA as Lp,rB as MS,rv as lo,rw as er,rx as L0,ry as QM,rz as pb,sA as dt,sB as Kn,sv as ho,sw as sf,sx as KT,sy as z0,sz as mb,tA as VI,tB as is,tC as PE,tv as qR,tw as kt,tx as oI,ty as My,tz as hb,uA as A,uB as Ic,uu as de,uv as HT,uw as ht,ux as Qt,uy as Ev,uz as gb,vA as vv,vB as Xo,vu as jI,vv as Fx,vw as qs,vx as aa,vy as ee,vz as xb,wA as gt,wB as Xn,wu as Ei,wv as q,ww as ue,wx as WI,wy as VO,wz as yb,xA as xt,xB as Ze,xu as y,xv as gn,xw as ge,xx as JI,xz as Sb,yA as or,yB as rP,yu as Q,yv as Ss,yw as ql,yx as GI,yy as Uo,yz as Eb,zA as B,zB as Pv,zu as pr,zv as Ty,zw as ec,zx as gv,zz as bb}from"./index-rwrp530c.js";import{LD as F}from"./index-njqkf4cd.js";import{SD as Ps}from"./index-cyq5dhvm.js";var sn={};Ps(sn,{Any:()=>iB,Array:()=>Oe,ArrayEnsure:()=>xB,BigDecimal:()=>WA,BigDecimalFromString:()=>YL,BigInt:()=>ic,BigIntFromString:()=>DL,Boolean:()=>ru,BooleanFromBit:()=>HL,BooleanLiterals:()=>kB,ByteSize:()=>cp,ByteSizeFromBigInt:()=>e2,ByteSizeFromNumber:()=>t2,ByteSizeFromString:()=>XL,Cause:()=>Lx,CauseReason:()=>Bx,Char:()=>IL,Chunk:()=>n2,Class:()=>lp,Cookie:()=>yC,Cookies:()=>SC,Date:()=>ip,DateFromMillis:()=>OL,DateFromString:()=>vL,DateTimeUtc:()=>fp,DateTimeUtcFromDate:()=>c2,DateTimeUtcFromMillis:()=>u2,DateTimeUtcFromString:()=>f2,DateTimeZoned:()=>cC,DateTimeZonedFromString:()=>m2,Defect:()=>bt,Duration:()=>dp,DurationFromMillis:()=>oz,DurationFromNanos:()=>rz,DurationFromString:()=>nz,Enum:()=>aB,Error:()=>Ct,ErrorInstance:()=>wL,Exit:()=>ay,FalseLiterals:()=>SA,File:()=>BA,Finite:()=>op,FiniteFromString:()=>FL,FormData:()=>LA,Graph:()=>cz,HashMap:()=>fz,HashSet:()=>uz,Headers:()=>hz,InetAddress:()=>gC,InetAddressFromString:()=>V2,InetAddressV4:()=>G2,InetAddressV6:()=>K2,Int:()=>wo,IpAddress:()=>Pa,IpAddressFromString:()=>pc,IpInterface:()=>lC,IpInterfaceFromString:()=>H2,IpLinkLocalAddress:()=>O2,IpLinkLocalAddressFromString:()=>_2,IpLoopbackAddress:()=>C2,IpLoopbackAddressFromString:()=>v2,IpMulticastAddress:()=>h2,IpMulticastAddressFromString:()=>g2,IpNetwork:()=>hC,IpNetworkFromString:()=>J2,IpUnicastAddress:()=>S2,IpUnicastAddressFromString:()=>E2,IpUnspecifiedAddress:()=>R2,IpUnspecifiedAddressFromString:()=>P2,Ipv4Address:()=>up,Ipv4AddressFromString:()=>oy,Ipv4BroadcastAddress:()=>w2,Ipv4BroadcastAddressFromString:()=>k2,Ipv4Interface:()=>uC,Ipv4InterfaceFromString:()=>$2,Ipv4Network:()=>pC,Ipv4NetworkFromString:()=>j2,Ipv4PrivateAddress:()=>M2,Ipv4PrivateAddressFromString:()=>U2,Ipv6Address:()=>sy,Ipv6AddressFromString:()=>fC,Ipv6Interface:()=>dC,Ipv6InterfaceFromString:()=>q2,Ipv6Network:()=>mC,Ipv6NetworkFromString:()=>W2,Ipv6UniqueLocalAddress:()=>F2,Ipv6UniqueLocalAddressFromString:()=>D2,Json:()=>pp,JsonFromUrlParamsField:()=>gz,JsonObject:()=>Hz,Literal:()=>pt,Literals:()=>ur,MacAddress:()=>Ra,MacAddressFromString:()=>lc,MacBroadcastAddress:()=>T2,MacBroadcastAddressFromString:()=>A2,MacLocallyAdministeredAddress:()=>N2,MacLocallyAdministeredAddressFromString:()=>B2,MacMulticastAddress:()=>x2,MacMulticastAddressFromString:()=>y2,MacUnicastAddress:()=>b2,MacUnicastAddressFromString:()=>I2,MacUniversallyAdministeredAddress:()=>L2,MacUniversallyAdministeredAddressFromString:()=>z2,MutableJson:()=>Wz,Natural:()=>Aa,Never:()=>tu,NonEmptyArray:()=>fc,NonEmptyString:()=>bL,Null:()=>ep,NullOr:()=>Vx,NullishOr:()=>uA,Number:()=>Oa,NumberFromString:()=>UL,ObjectKeyword:()=>fB,Opaque:()=>RB,Option:()=>Ma,OptionFromNullOr:()=>dz,OptionFromNullishOr:()=>pz,OptionFromOptional:()=>Sz,OptionFromOptionalKey:()=>yz,OptionFromOptionalNullOr:()=>Ez,OptionFromUndefinedOr:()=>lz,PropertyKey:()=>Nx,ReadonlyMap:()=>kL,ReadonlySet:()=>TL,Record:()=>_a,RecordFromCookies:()=>mz,RecordFromUrlParams:()=>xz,Redacted:()=>EC,RedactedFromValue:()=>bz,RegExp:()=>AL,Result:()=>Iz,SchemaError:()=>Rn,SocketAddress:()=>Q2,StandardSchemaV1FailureResult:()=>qL,String:()=>z,StringForLiteralAutocomplete:()=>cB,StringFromBase64:()=>BL,StringFromBase64Url:()=>LL,StringFromHex:()=>zL,StringFromUriComponent:()=>$L,Struct:()=>ae,StructWithRest:()=>hB,Symbol:()=>iA,TaggedClass:()=>Az,TaggedError:()=>fy,TaggedStruct:()=>rp,TaggedUnion:()=>_B,TemplateLiteral:()=>oB,TemplateLiteralParser:()=>sB,TimeZone:()=>aC,TimeZoneFromString:()=>p2,TimeZoneNamed:()=>oC,TimeZoneNamedFromString:()=>l2,TimeZoneOffset:()=>d2,Tree:()=>qz,Trim:()=>NL,Trimmed:()=>$A,TrueLiterals:()=>yA,Tuple:()=>cr,TupleWithRest:()=>gB,URL:()=>DA,URLFromString:()=>CL,URLSearchParams:()=>zA,Uint8Array:()=>Hr,Uint8ArrayFromBase64:()=>jL,Uint8ArrayFromBase64Url:()=>WL,Uint8ArrayFromHex:()=>JL,Undefined:()=>Gx,UndefinedOr:()=>np,Union:()=>Ie,UniqueArray:()=>yB,UniqueSymbol:()=>uB,UnixPathAddress:()=>xC,UnixPathAddressFromString:()=>Z2,Unknown:()=>nu,UnknownFromJsonString:()=>RL,UrlParams:()=>iy,Void:()=>cc,annotate:()=>M1,annotateEncoded:()=>U1,annotateKey:()=>F1,asserts:()=>z1,brand:()=>pA,catchDecoding:()=>IB,catchDecodingWithContext:()=>gA,catchEncoding:()=>wB,catchEncodingWithContext:()=>xA,check:()=>EB,declare:()=>we,declareConstructor:()=>Wt,decode:()=>TB,decodeEffect:()=>$1,decodeExit:()=>q1,decodeOption:()=>j1,decodePromise:()=>J1,decodeResult:()=>W1,decodeSync:()=>Wx,decodeTo:()=>Z,decodeUnknownEffect:()=>Ms,decodeUnknownExit:()=>eA,decodeUnknownOption:()=>H1,decodeUnknownPromise:()=>nA,decodeUnknownResult:()=>tA,decodeUnknownSync:()=>Xl,encode:()=>AB,encodeEffect:()=>Jx,encodeExit:()=>G1,encodeKeys:()=>pB,encodeOption:()=>V1,encodePromise:()=>Q1,encodeResult:()=>Z1,encodeSync:()=>Y1,encodeTo:()=>Zx,encodeUnknownEffect:()=>Xf,encodeUnknownExit:()=>rA,encodeUnknownOption:()=>K1,encodeUnknownPromise:()=>sA,encodeUnknownResult:()=>oA,encodeUnknownSync:()=>eu,extendTo:()=>mB,fieldsAssign:()=>dB,flip:()=>Dx,fromBrand:()=>bB,fromFormData:()=>PL,fromJsonString:()=>ny,fromURLSearchParams:()=>ML,instanceOf:()=>Us,is:()=>L1,isBase64:()=>TA,isBase64Url:()=>zB,isBetween:()=>sp,isBetweenBigDecimal:()=>QL,isBetweenBigInt:()=>uL,isBetweenCodePoints:()=>pL,isBetweenDate:()=>aL,isBetweenLength:()=>Xx,isBetweenProperties:()=>SL,isBetweenSize:()=>gL,isCapitalized:()=>JB,isEndingWith:()=>qB,isFinite:()=>KB,isGUID:()=>BB,isGreaterThan:()=>ZB,isGreaterThanBigDecimal:()=>GL,isGreaterThanBigInt:()=>iL,isGreaterThanDate:()=>nL,isGreaterThanOrEqualTo:()=>AA,isGreaterThanOrEqualToBigDecimal:()=>KL,isGreaterThanOrEqualToBigInt:()=>CA,isGreaterThanOrEqualToDate:()=>rL,isIncluding:()=>HB,isInt:()=>ap,isInt32:()=>eL,isLessThan:()=>QB,isLessThanBigDecimal:()=>VL,isLessThanBigInt:()=>cL,isLessThanDate:()=>oL,isLessThanOrEqualTo:()=>YB,isLessThanOrEqualToBigDecimal:()=>ZL,isLessThanOrEqualToBigInt:()=>fL,isLessThanOrEqualToDate:()=>sL,isLowercased:()=>WB,isMaxCodePoints:()=>lL,isMaxLength:()=>RA,isMaxProperties:()=>yL,isMaxSize:()=>hL,isMinCodePoints:()=>dL,isMinLength:()=>vA,isMinProperties:()=>xL,isMinSize:()=>mL,isMultipleOf:()=>XB,isNonEmpty:()=>_A,isPattern:()=>dc,isPropertyNames:()=>EL,isSchema:()=>va,isSchemaError:()=>sc,isStartingWith:()=>$B,isStringBigInt:()=>UB,isStringFinite:()=>MB,isStringSymbol:()=>FB,isTrimmed:()=>kA,isULID:()=>LB,isUUID:()=>NB,isUint32:()=>tL,isUncapitalized:()=>GB,isUnique:()=>ty,isUniqueKey:()=>PA,isUppercased:()=>jB,link:()=>Se,linkDecoding:()=>uc,make:()=>H,makeFilter:()=>ke,makeFilterGroup:()=>PB,makeIsBetween:()=>cu,makeIsGreaterThan:()=>ou,makeIsGreaterThanOrEqualTo:()=>su,makeIsLessThan:()=>au,makeIsLessThanOrEqualTo:()=>iu,makeIsMultipleOf:()=>VB,middlewareDecoding:()=>mA,middlewareEncoding:()=>hA,mutable:()=>SB,mutableKey:()=>tB,optional:()=>mt,optionalKey:()=>Ca,overrideToCodecIso:()=>zz,overrideToEquivalence:()=>Oz,overrideToFormatter:()=>Cz,readonlyKey:()=>nB,refine:()=>lA,required:()=>eB,requiredKey:()=>X1,resolveAnnotations:()=>Jz,resolveAnnotationsKey:()=>Gz,revealBottom:()=>P1,revealCodec:()=>D1,suspend:()=>dA,tag:()=>ye,tagDefaultOmit:()=>OB,toCodecArrayFromSingle:()=>Fz,toCodecIso:()=>Mz,toCodecJson:()=>uu,toCodecStringTree:()=>Uz,toDifferJsonPatch:()=>$z,toEncoded:()=>ac,toEncoderXml:()=>Dz,toEquivalence:()=>_z,toFormatter:()=>vz,toIso:()=>Nz,toIsoFocus:()=>Lz,toIsoSource:()=>Bz,toJsonSchemaDocument:()=>Pz,toRepresentation:()=>Rz,toStandardJSONSchemaV1:()=>B1,toStandardSchemaV1:()=>N1,toTaggedUnion:()=>wA,toType:()=>Pn,withArrayLengthConstraints:()=>tp,withConstructorDefault:()=>EA,withDecodingDefault:()=>IA,withDecodingDefaultKey:()=>Qx,withDecodingDefaultType:()=>vB,withDecodingDefaultTypeKey:()=>CB});var FE=/^[+-]?\d+$/,nh="~effect/BigDecimal",OU={[nh]:nh,[Be](){let e=Gc(this);return Le(mn(String(e.value)),Bn(e.scale))},[ze](e){return ra(e)&&qE(this,e)===0},toString(){return`BigDecimal(${Lo(this)})`},toJSON(){return{_id:"BigDecimal",value:String(this.value),scale:this.scale}},[Re](){return this.toJSON()},pipe(){return de(this,arguments)}},ra=(e)=>V(e,nh),ud=(e,t)=>{if(!Number.isSafeInteger(t))throw RangeError(`Scale must be a safe integer, got ${t}`);let n=Object.create(OU);return n.value=e,n.scale=t,n},zE=(e,t)=>{let n=ud(e,t);return n.normalized=n,n};var Tr=BigInt(0),_U=BigInt(1);var RU=BigInt(10),$E=zE(Tr,0);var Gc=(e)=>{if(e.normalized===void 0)if(e.value===Tr)e.normalized=$E;else{let t=`${e.value}`,n=t.length;while(t[n-1]==="0")n--;e.normalized=zE(BigInt(t.slice(0,n)),e.scale-(t.length-n))}return e.normalized};var PU=100,MU=[_U],th=(e,t)=>e===t?0:e<t?-1:1,DE=(e,t)=>{let n=`${e.value<Tr?-e.value:e.value}`,r=`${t.value<Tr?-t.value:t.value}`,o=BigInt(n.length-r.length)-BigInt(e.scale)+BigInt(t.scale);if(o!==Tr)return o<Tr?-1:1;let s=Math.max(n.length,r.length);return LE(n.padEnd(s,"0"),r.padEnd(s,"0"))},qE=(e,t)=>{if(e.scale===t.scale)return th(e.value,t.value);let n=NE(e),r=NE(t);if(n!==r)return n<r?-1:1;if(n===0)return 0;let o=e.scale-t.scale,s=Math.abs(o);if(s>PU)return n===-1?DE(t,e):DE(e,t);let a=MU[s]??=RU**BigInt(s);return o>0?th(e.value,t.value*a):th(e.value*a,t.value)},ni=BE(qE);var NE=(e)=>e.value===Tr?0:e.value<Tr?-1:1;var HE=(e)=>{if(e==="")return oe($E);let t,n,r=e.search(/[eE]/);if(r!==-1){let c=e.slice(r+1);if(t=e.slice(0,r),n=Number(c),t===""||!Number.isSafeInteger(n)||!FE.test(c))return ne()}else t=e,n=0;let o,s,a=t.search(/\./);if(a!==-1){let c=t.slice(0,a),f=t.slice(a+1);o=`${c}${f}`,s=f.length}else o=t,s=0;if(!FE.test(o))return ne();let i=s-n;if(!Number.isSafeInteger(i))return ne();return oe(ud(BigInt(o),i))};var Lo=(e)=>{let t=Gc(e);if(Math.abs(t.scale)>=16)return UU(t);let n=t.value<Tr,r=`${n?-t.value:t.value}`,o=t.scale>0?r.padStart(t.scale+1,"0"):r.padEnd(r.length-t.scale,"0"),s=o.length-t.scale,a=t.scale>0?`${o.slice(0,s)}.${o.slice(s)}`:o;return n?`-${a}`:a},UU=(e)=>{if(FU(e))return"0e+0";let t=Gc(e),n=`${t.value}`,r=t.value<Tr?2:1,o=n.slice(0,r),s=n.slice(r),a=s.length-t.scale;return`${o}${s===""?"":`.${s}`}e${a>=0?"+":""}${a}`};var FU=(e)=>e.value===Tr;var WE=globalThis.BigInt;var JE=(e)=>{if(e>WE(Number.MAX_SAFE_INTEGER)||e<WE(Number.MIN_SAFE_INTEGER))return ne();return oe(Number(e))};var oh=BigInt(0),NU=BigInt(1),uo=BigInt(1000),hs=BigInt(1024),GE=[{symbol:"B",factor:NU,names:["B","byte","bytes"]},{symbol:"kB",factor:uo,names:["kB","kilobyte","kilobytes"]},{symbol:"MB",factor:uo**BigInt(2),names:["MB","megabyte","megabytes"]},{symbol:"GB",factor:uo**BigInt(3),names:["GB","gigabyte","gigabytes"]},{symbol:"TB",factor:uo**BigInt(4),names:["TB","terabyte","terabytes"]},{symbol:"PB",factor:uo**BigInt(5),names:["PB","petabyte","petabytes"]},{symbol:"EB",factor:uo**BigInt(6),names:["EB","exabyte","exabytes"]},{symbol:"ZB",factor:uo**BigInt(7),names:["ZB","zettabyte","zettabytes"]},{symbol:"YB",factor:uo**BigInt(8),names:["YB","yottabyte","yottabytes"]},{symbol:"RB",factor:uo**BigInt(9),names:["RB","ronnabyte","ronnabytes"]},{symbol:"QB",factor:uo**BigInt(10),names:["QB","quettabyte","quettabytes"]}],BU=[GE[0],{symbol:"KiB",factor:hs,names:["KiB","kibibyte","kibibytes"]},{symbol:"MiB",factor:hs**BigInt(2),names:["MiB","mebibyte","mebibytes"]},{symbol:"GiB",factor:hs**BigInt(3),names:["GiB","gibibyte","gibibytes"]},{symbol:"TiB",factor:hs**BigInt(4),names:["TiB","tebibyte","tebibytes"]},{symbol:"PiB",factor:hs**BigInt(5),names:["PiB","pebibyte","pebibytes"]},{symbol:"EiB",factor:hs**BigInt(6),names:["EiB","exbibyte","exbibytes"]},{symbol:"ZiB",factor:hs**BigInt(7),names:["ZiB","zebibyte","zebibytes"]},{symbol:"YiB",factor:hs**BigInt(8),names:["YiB","yobibyte","yobibytes"]}],LU=[...GE,...BU.slice(1)],zU=new Map(LU.flatMap((e)=>e.names.map((t)=>[t,e])));var sh=(e)=>e;var ri=(e)=>{throw Error(`Invalid ByteSize: ${e}`)},KE=(e)=>{if(!Number.isSafeInteger(e)||e<0)return ri(`expected a non-negative safe integer, received ${e}`);return sh(BigInt(e))};var VE=(e)=>{let t=/^\s*(\d+)(?:\.(\d+))?\s*([A-Za-z]+)\s*$/.exec(e);if(t===null)return ri(`unsupported syntax ${JSON.stringify(e)}`);let n=zU.get(t[3]);if(n===void 0)return ri(`unsupported unit ${JSON.stringify(t[3])}`);let r=t[2]??"",o=BigInt(10)**BigInt(r.length),s=BigInt(t[1]+r)*n.factor;if(s%o!==oh)return ri(`${JSON.stringify(e)} does not represent an integral number of bytes`);return sh(s/o)},ZE=rh(VE),dd=(e)=>{switch(typeof e){case"bigint":if(e<oh)return ri(`expected a non-negative bigint, received ${e}`);return sh(e);case"number":return KE(e);case"string":return VE(e)}return ri(`unsupported input ${e}`)},ah=rh(dd),QE=(e)=>typeof e==="bigint"?dd(e):KE(e);var YE=(e)=>typeof e==="bigint"&&e>=oh;var ld=(e)=>e,XE=JE;var tb="~effect/Chunk";function eb(e,t,n,r,o){for(let s=t;s<Math.min(e.length,t+o);s++)n[r+s-t]=e[s];return n}var nb=[],uh=(e)=>Ar((t,n)=>{if(t.length!==n.length)return!1;let r=oa(t),o=oa(n);for(let s=0;s<r.length;s++)if(!e(r[s],o[s]))return!1;return!0}),HU=uh(he),jU={[tb]:{_A:(e)=>e},toString(){return`Chunk(${K(oa(this))})`},toJSON(){return{_id:"Chunk",values:lo(oa(this))}},[Re](){return this.toJSON()},[ze](e){return si(e)&&HU(this,e)},[Be](){return oi(oa(this))},[Symbol.iterator](){switch(this.backing._tag){case"IArray":return this.backing.array[Symbol.iterator]();case"IEmpty":return nb[Symbol.iterator]();default:return oa(this)[Symbol.iterator]()}},pipe(){return de(this,arguments)}},dh=(e)=>{let t=Object.create(jU);switch(t.backing=e,e._tag){case"IEmpty":{t.length=0,t.depth=0,t.left=t,t.right=t;break}case"IConcat":{t.length=e.left.length+e.right.length,t.depth=1+Math.max(e.left.depth,e.right.depth),t.left=e.left,t.right=e.right;break}case"IArray":{t.length=e.array.length,t.depth=0,t.left=zo,t.right=zo;break}case"ISingleton":{t.length=1,t.depth=0,t.left=zo,t.right=zo;break}case"ISlice":{t.length=e.length,t.depth=0,t.left=zo,t.right=zo;break}}return t},si=(e)=>V(e,tb),zo=dh({_tag:"IEmpty"}),WU=()=>zo;var JU=(e)=>dh({_tag:"ISingleton",a:e}),lh=(e)=>si(e)?e:KU(_t(e)),ch=(e,t,n)=>{switch(e.backing._tag){case"IArray":{eb(e.backing.array,0,t,n,e.length);break}case"IConcat":{ch(e.left,t,n),ch(e.right,t,n+e.left.length);break}case"ISingleton":{t[n]=e.backing.a;break}case"ISlice":{eb(oa(e.backing.chunk),e.backing.offset,t,n,e.length);break}}};var GU=(e)=>{switch(e.backing._tag){case"IEmpty":return nb;case"IArray":return e.backing.array;default:{let t=Array(e.length);return ch(e,t,0),e.backing={_tag:"IArray",array:t},e.left=zo,e.right=zo,e.depth=0,t}}},oa=GU;var KU=(e)=>e.length===0?WU():e.length===1?JU(e[0]):dh({_tag:"IArray",array:e});var rb=(e)=>e.length;var sa=ob,Tb=sb,Ab=ab,Cb=ib,vb=cb,Ob=fb,_b=ub;var gd=db;var xd=lb;var mh=pb,Rb=mb;var hh=hb;var gh=gb,xh=xb,Pb=yb;var Mb=Sb,Kc=Eb;var Ub=bb;var Fb=Ib;var Db=wb;var yh=kb;var ai=(e)=>VU(typeof e==="string"?ZU.encode(e):e),ia=(e)=>{let t=YU(e),n=t.length;if(n%4!==0)return ge(new aa({kind:"Decode",module:"Base64",input:t,message:`Length must be a multiple of 4, but is ${n}`}));let r=t.indexOf("=");if(r!==-1&&(r<n-2||r===n-2&&t[n-1]!=="="))return ge(new aa({kind:"Decode",module:"Base64",input:t,message:"Found a '=' character, but it is not at the end"}));try{let o=t.endsWith("==")?2:t.endsWith("=")?1:0,s=new Uint8Array(3*(n/4)-o);for(let a=0,i=0;a<n;a+=4,i+=3){let c=yd(t.charCodeAt(a))<<18|yd(t.charCodeAt(a+1))<<12|yd(t.charCodeAt(a+2))<<6|yd(t.charCodeAt(a+3));s[i]=c>>16,s[i+1]=c>>8&255,s[i+2]=c&255}return ue(s)}catch(o){return ge(new aa({kind:"Decode",module:"Base64",input:t,message:o instanceof Error?o.message:"Invalid input"}))}},Bb=(e)=>vr(ia(e),(t)=>QU.decode(t)),VU=(e)=>{let t=e.length,n="",r;for(r=2;r<t;r+=3)n+=Cr[e[r-2]>>2],n+=Cr[(e[r-2]&3)<<4|e[r-1]>>4],n+=Cr[(e[r-1]&15)<<2|e[r]>>6],n+=Cr[e[r]&63];if(r===t+1)n+=Cr[e[r-2]>>2],n+=Cr[(e[r-2]&3)<<4],n+="==";if(r===t)n+=Cr[e[r-2]>>2],n+=Cr[(e[r-2]&3)<<4|e[r-1]>>4],n+=Cr[(e[r-1]&15)<<2],n+="=";return n},ZU=new TextEncoder,QU=new TextDecoder,YU=(e)=>e.replace(/[\n\r]/g,""),Cr="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",Vc=new Uint8Array(123).fill(255);for(let e=0;e<Cr.length;e++)Vc[Cr.charCodeAt(e)]=e;Vc[61]=0;var yd=(e)=>{if(e>=Vc.length||Vc[e]===255)throw TypeError(`Invalid character ${String.fromCharCode(e)}`);return Vc[e]};var Ed="~effect/HashMap",Or=5,Xc=1<<Or,XU=Xc/4,Lb=Xc/2,eF=Xc-1,tF=(e)=>(e=e-(e>>>1&1431655765),e=(e&858993459)+(e>>>2&858993459),(e+(e>>>4)&252645135)*16843009>>>24),Zc=(e,t)=>e>>>t&eF,gs=(e,t)=>1<<Zc(e,t),Sd=(e,t)=>tF(e&t-1);function zb(e,t,n,r,o,s){if(t>32)throw Error("HashMap: max depth exceeded");let a=gs(n,t),i=gs(o,t);if(a===i){let u=zb(e,t+Or,n,r,o,s);return new po(e,a,[u])}let c=a|i,f=a>>>0<i>>>0?[r,s]:[s,r];return new po(e,c,f)}var nF=mn("HashMap"),$b=(e,t)=>Le(We(e),We(t)),qb=(e)=>{let t=0;for(let n=0;n<e.length;n++){let r=e[n];if(r)t^=r.subtreeHash()}return t};class ii{canEdit(e){return this.edit===e}subtreeHash(){let e=this._hash;if(e===void 0){let t=Eh;if(e=this.computeHash(),t===Eh)this._hash=e}return e}}class Hb extends ii{_tag="EmptyNode";edit=0;get size(){return 0}get(e,t,n){return ne()}has(e,t,n){return!1}set(e,t,n,r,o,s){return s.value=!0,new $o(e,n,r,o)}remove(e,t,n,r,o){return this}canEdit(e){return!1}computeHash(){return 0}}class $o extends ii{_tag="LeafNode";edit;hash;key;value;constructor(e,t,n,r){super();this.edit=e,this.hash=t,this.key=n,this.value=r}get size(){return 1}get(e,t,n){if(this.hash===t&&he(this.key,n))return oe(this.value);return ne()}has(e,t,n){return this.hash===t&&he(this.key,n)}set(e,t,n,r,o,s){if(this.canEdit(e))this._hash=void 0;if(this.hash===n&&he(this.key,r)){if(he(this.value,o))return this;if(this.canEdit(e))return this.value=o,this;return new $o(e,n,r,o)}if(s.value=!0,this.hash===n)return new Qc(e,n,[[this.key,this.value],[r,o]]);let a=gs(n,t),i=gs(this.hash,t);if(a===i)return new po(e,a,[this.set(e,t+Or,n,r,o,s)]);let c=a|i,f=a>>>0<i>>>0?[new $o(e,n,r,o),this]:[this,new $o(e,n,r,o)];return new po(e,c,f)}remove(e,t,n,r,o){if(this.hash===n&&he(this.key,r)){o.value=!0;return}return this}computeHash(){return $b(this.key,this.value)}}class Qc extends ii{_tag="CollisionNode";edit;hash;entries;constructor(e,t,n){super();this.edit=e,this.hash=t,this.entries=n}get size(){return this.entries.length}get(e,t,n){if(this.hash!==t)return ne();for(let[r,o]of this.entries)if(he(r,n))return oe(o);return ne()}has(e,t,n){if(this.hash!==t)return!1;for(let[r]of this.entries)if(he(r,n))return!0;return!1}set(e,t,n,r,o,s){if(this.canEdit(e))this._hash=void 0;if(this.hash!==n)return s.value=!0,zb(e,t,this.hash,this,n,new $o(e,n,r,o));for(let a=0;a<this.entries.length;a++)if(he(this.entries[a][0],r)){if(he(this.entries[a][1],o))return this;if(this.canEdit(e))return this.entries[a]=[r,o],this;let i=[...this.entries];return i[a]=[r,o],new Qc(e,this.hash,i)}if(s.value=!0,this.canEdit(e))return this.entries.push([r,o]),this;return new Qc(e,this.hash,[...this.entries,[r,o]])}remove(e,t,n,r,o){if(this.canEdit(e))this._hash=void 0;if(this.hash!==n)return this;let s=this.entries.findIndex(([i])=>he(i,r));if(s===-1)return this;if(o.value=!0,this.entries.length===1)return;if(this.entries.length===2){let i=this.entries[s===0?1:0];return new $o(e,this.hash,i[0],i[1])}if(this.canEdit(e))return this.entries.splice(s,1),this;let a=[...this.entries];return a.splice(s,1),new Qc(e,this.hash,a)}computeHash(){let e=0,t=this.entries;for(let n=0;n<t.length;n++)e^=$b(t[n][0],t[n][1]);return e}}class po extends ii{_tag="IndexedNode";edit;_size;bitmap;children;constructor(e,t,n){super();this.edit=e,this.bitmap=t,this.children=n}get size(){if(this._size===void 0)this._size=this.children.reduce((e,t)=>e+t.size,0);return this._size}get(e,t,n){let r=gs(t,e);if((this.bitmap&r)===0)return ne();let o=Sd(this.bitmap,r);return this.children[o].get(e+Or,t,n)}has(e,t,n){let r=gs(t,e);if((this.bitmap&r)===0)return!1;let o=Sd(this.bitmap,r);return this.children[o].has(e+Or,t,n)}set(e,t,n,r,o,s){if(this.canEdit(e))this._hash=void 0;let a=gs(n,t),i=Sd(this.bitmap,a);if((this.bitmap&a)!==0){let c=this.children[i],f=c.set(e,t+Or,n,r,o,s);if(c===f)return this;if(this.canEdit(e))return this.children[i]=f,this;let u=[...this.children];return u[i]=f,new po(e,this.bitmap,u)}else{s.value=!0;let c=new $o(e,n,r,o),f=this.bitmap|a;if(this.canEdit(e)){if(this.children.splice(i,0,c),this.bitmap=f,this._size=void 0,this.children.length>Lb)return this.expand(e,f,this.children);return this}let u=[...this.children];if(u.splice(i,0,c),u.length>Lb)return this.expand(e,f,u);return new po(e,f,u)}}remove(e,t,n,r,o){if(this.canEdit(e))this._hash=void 0;let s=gs(n,t);if((this.bitmap&s)===0)return this;let a=Sd(this.bitmap,s),i=this.children[a],c=i.remove(e,t+Or,n,r,o);if(!o.value)return this;if(c===void 0){let u=this.bitmap^s;if(u===0)return;if(this.children.length===2){let l=this.children[a===0?1:0];if(l._tag==="LeafNode")return l}if(this.canEdit(e))return this.children.splice(a,1),this.bitmap=u,this._size=void 0,this;let d=[...this.children];return d.splice(a,1),new po(e,u,d)}if(i===c)return this;if(this.canEdit(e))return this.children[a]=c,this;let f=[...this.children];return f[a]=c,new po(e,this.bitmap,f)}expand(e,t,n){let r=new globalThis.Array(Xc),o=0;for(let s=0;s<Xc;s++)if((t&1<<s)!==0)r[s]=n[o++];return new Yc(e,n.length,r)}computeHash(){return qb(this.children)}}class Yc extends ii{_tag="ArrayNode";edit;_size;count;children;constructor(e,t,n){super();this.edit=e,this.count=t,this.children=n}get size(){if(this._size===void 0)this._size=this.children.reduce((e,t)=>e+(t?.size??0),0);return this._size}get(e,t,n){let r=Zc(t,e),o=this.children[r];return o?o.get(e+Or,t,n):ne()}has(e,t,n){let r=Zc(t,e),o=this.children[r];return o?o.has(e+Or,t,n):!1}set(e,t,n,r,o,s){if(this.canEdit(e))this._hash=void 0;let a=Zc(n,t),i=this.children[a];if(i){let c=i.set(e,t+Or,n,r,o,s);if(i===c)return this;if(this.canEdit(e))return this.children[a]=c,this;let f=[...this.children];return f[a]=c,new Yc(e,this.count,f)}else{s.value=!0;let c=new $o(e,n,r,o);if(this.canEdit(e))return this.children[a]=c,this.count++,this._size=void 0,this;let f=[...this.children];return f[a]=c,new Yc(e,this.count+1,f)}}remove(e,t,n,r,o){if(this.canEdit(e))this._hash=void 0;let s=Zc(n,t),a=this.children[s];if(!a)return this;let i=a.remove(e,t+Or,n,r,o);if(!o.value)return this;let c=this.count-(i?0:1);if(c<XU)return this.pack(e,s,i);if(a===i)return this;if(this.canEdit(e)){if(this.children[s]=i,!i)this.count=c;return this._size=void 0,this}let f=[...this.children];return f[s]=i,new Yc(e,c,f)}pack(e,t,n){let r=[],o=0,s=1;for(let a=0;a<this.children.length;a++){let i=a===t?n:this.children[a];if(i)r.push(i),o|=s;s<<=1}return new po(e,o,r)}computeHash(){return qb(this.children)}}class Ih{stack;project;entries=[];index=0;constructor(e,t){this.stack=[e],this.project=t}next(){while(!0){if(this.index<this.entries.length){let t=this.entries[this.index++];return{done:!1,value:this.project(t[0],t[1])}}if(this.stack.length===0)return{done:!0,value:void 0};let e=this.stack.pop();switch(e._tag){case"LeafNode":{let t=e;return{done:!1,value:this.project(t.key,t.value)}}case"CollisionNode":{this.entries=e.entries,this.index=0;break}case"IndexedNode":case"ArrayNode":{let t=e.children;for(let n=t.length-1;n>=0;n--){let r=t[n];if(r)this.stack.push(r)}}}}}[Symbol.iterator](){return this}}var rF=(e,t)=>[e,t];class bd{[Ed]=Ed;_editable;_edit;_root;_size;constructor(e,t,n,r){this._editable=e,this._edit=t,this._root=n,this._size=r}get size(){return this._size}[Symbol.iterator](){return new Ih(this._root,rF)}[ze](e){if(wh(e)){let t=e;if(this.size!==t.size)return!1;for(let[n,r]of this){let o=bh(e,Jb(n));if(Tn(o)||!he(r,o.value))return!1}return!0}return!1}[Be](){return mo(nF^this._root.subtreeHash())}[Re](){return lo(this)}toString(){return`HashMap(${K(Array.from(this))})`}toJSON(){return{_id:"HashMap",values:Array.from(this).map(([e,t])=>[lo(e),lo(t)])}}pipe(){return de(this,arguments)}}var jb=new Hb,wh=(e)=>V(e,Ed),kh=()=>new bd(!1,0,jb,0);var Wb=(e)=>{let t=jb,n=0,r={value:!1};for(let[o,s]of e){let a=We(o);if(r.value=!1,t=t.set(NaN,0,a,o,s,r),r.value)n++}return new bd(!1,0,t,n)};var Jb=y(2,(e,t)=>e._root.get(0,We(t),t));var Th=y(2,(e,t)=>e._root.has(0,We(t),t));var oF=(e,t,n,r)=>{let o=e,s={value:!1},a=o._editable?o._edit:NaN,i=o._root.set(a,0,n,t,r,s);if(o._editable){if(o._root=i,s.value)o._size++;return e}if(o._root===i)return e;return new bd(!1,o._edit,i,o._size+(s.value?1:0))},Ah=y(3,(e,t,n)=>oF(e,t,We(t),n)),Ch=(e)=>new Ih(e._root,Q);var Gb=(e)=>e[Symbol.iterator](),Id=(e)=>e.size;var wd=wh;var vh=Wb;var iF=Gb,ef=(e)=>Array.from(iF(e)),Vb=Id;var tf="~effect/HashSet",cF=mn(tf),fF={[Be](){return mo(Le(cF,We(kd(this))))},[ze](e){return _h(e)&&Td(this)===Td(e)&&Yb(this,(t)=>Qb(e,t))},[Symbol.iterator](){return Ch(kd(this))},toString(){return`HashSet(${K(Array.from(this))})`},toJSON(){return{_id:"HashSet",values:lo(Array.from(this))}},[Re](){return this.toJSON()},pipe(){return de(this,arguments)}},uF=(e)=>{let t=Object.create(fF);return t[tf]=tf,t.keyMap=e,t},_h=(e)=>V(e,tf),kd=(e)=>e.keyMap;var Zb=(e)=>{let t=kh();for(let n of e)t=Ah(t,n,!0);return uF(t)},Qb=(e,t)=>Th(kd(e),t);var Td=(e)=>Id(kd(e));var Yb=(e,t)=>{for(let n of e)if(!t(n))return!1;return!0};var Rh=Zb,Ad=_h;var Xb=Td;var Mh="~effect/http/Cookies",sI=(e)=>V(e,Mh),Uh="~effect/http/Cookies/Cookie",aI=(e)=>V(e,Uh),eI="~effect/http/Cookies/CookieError";class iI extends oI{}class ca extends Qt("CookiesError"){static fromReason(e,t){return new ca({reason:new iI({_tag:e,cause:t})})}[eI]=eI;get message(){return this.reason._tag}}var lF={[Mh]:Mh,...ho,toJSON(){return{_id:"effect/Cookies",cookies:Cd(this.cookies,(e)=>e.toJSON())}},pipe(){return de(this,arguments)}},Dh=(e)=>{let t=Object.create(lF);return t.cookies=e,t},Nh=(e)=>{let t={};for(let n of e)q(t,n.name,n);return Dh(t)},vd=(e)=>{let t=typeof e==="string"?[e]:e,n=[];for(let r of t){let o=pF(r.trim());if(o)n.push(o)}return Nh(n)};function pF(e){let t=e.split(";").map((i)=>i.trim()).filter((i)=>i!=="");if(t.length===0)return;let n=t[0].indexOf("=");if(n===-1)return;let r=t[0].slice(0,n);if(!cI.test(r))return;let o=t[0].slice(n+1),s=SF(o);if(t.length===1)return Object.assign(Object.create(Fh),{name:r,value:s,valueEncoded:o});let a={};for(let i=1;i<t.length;i++){let c=t[i],f=c.indexOf("="),u=f===-1?c:c.slice(0,f).trim(),d=f===-1?void 0:c.slice(f+1).trim();switch(u.toLowerCase()){case"domain":{if(d===void 0)break;let l=d.trim().replace(/^\./,"");if(l)a.domain=l;break}case"expires":{if(d===void 0)break;let l=new Date(d);if(!isNaN(l.getTime()))a.expires=l;break}case"max-age":{if(d===void 0)break;let l=parseInt(d,10);if(!isNaN(l))a.maxAge=nI(l);break}case"path":{if(d===void 0)break;if(d[0]==="/")a.path=d;break}case"priority":{if(d===void 0)break;switch(d.toLowerCase()){case"low":a.priority="low";break;case"medium":a.priority="medium";break;case"high":a.priority="high";break}break}case"httponly":{a.httpOnly=!0;break}case"secure":{a.secure=!0;break}case"partitioned":{a.partitioned=!0;break}case"samesite":{if(d===void 0)break;switch(d.toLowerCase()){case"lax":a.sameSite="lax";break;case"strict":a.sameSite="strict";break;case"none":a.sameSite="none";break}break}}}return Object.assign(Object.create(Fh),{name:r,value:s,valueEncoded:o,options:Object.keys(a).length>0?a:void 0})}var mF=/^[\u0009\u0020-\u007e\u0080-\u00ff]+$/,cI=/^[!#$%&'*+\-.^_`|~0-9A-Za-z]+$/,hF=/^[\u0009\u0020-\u003a\u003c-\u007e\u0080-\u00ff]+$/,gF=/^[\u0020-\u003a\u003c-\u007e]+$/,Fh={[Uh]:Uh,...ho,toJSON(){return{_id:"effect/Cookies/Cookie",name:this.name,value:this.value,options:this.options}}};function xF(e,t,n){let r=encodeURIComponent(t),o=fI(e,r,n);if(o!==void 0)return ge(o);return ue(Object.assign(Object.create(Fh),{name:e,value:t,valueEncoded:r,options:n}))}function fI(e,t,n){if(!cI.test(e))return ca.fromReason("InvalidCookieName");if(t&&!mF.test(t))return ca.fromReason("InvalidCookieValue");if(n?.domain!==void 0&&!hF.test(n.domain))return ca.fromReason("InvalidCookieDomain");if(n?.path!==void 0&&!gF.test(n.path))return ca.fromReason("InvalidCookiePath");if(n?.maxAge!==void 0&&!xs(Zt(n.maxAge)))return ca.fromReason("CookieInfinityMaxAge")}var uI=(e,t,n)=>rf(xF(e,t,n));function yF(e){let t=fI(e.name,e.valueEncoded,e.options);if(t!==void 0)throw t;let n=e.name+"="+e.valueEncoded;if(e.options===void 0)return n;let r=e.options;if(r.maxAge!==void 0){let o=rI(Zt(r.maxAge));n+="; Max-Age="+Math.trunc(o)}if(r.domain!==void 0)n+="; Domain="+r.domain;if(r.path!==void 0)n+="; Path="+r.path;if(r.priority!==void 0)switch(r.priority){case"low":n+="; Priority=Low";break;case"medium":n+="; Priority=Medium";break;case"high":n+="; Priority=High";break}if(r.expires!==void 0)n+="; Expires="+r.expires.toUTCString();if(r.httpOnly)n+="; HttpOnly";if(r.secure)n+="; Secure";if(r.partitioned)n+="; Partitioned";if(r.sameSite!==void 0)switch(r.sameSite){case"lax":n+="; SameSite=Lax";break;case"strict":n+="; SameSite=Strict";break;case"none":n+="; SameSite=None";break}return n}var dI=(e)=>{let t={},n=Object.values(e.cookies);for(let r=0;r<n.length;r++){let o=n[r];q(t,o.name,o.value)}return t},lI=(e)=>Object.values(e.cookies).map(yF);var SF=(e)=>{try{return decodeURIComponent(e)}catch(t){return e}};var fa=new WeakMap,mI=(e)=>{if(fa.has(e))return fa.get(e);else throw Error("Unable to get redacted value"+(e.label?` with label: "${e.label}"`:""))};var hI="~effect/Redacted",of=(e)=>V(e,hI),ua=(e,t)=>{let n=Object.create(bF);if(t?.label)n.label=t.label;return fa.set(n,e),n},bF={[hI]:{_A:(e)=>e},label:void 0,...Ss,toJSON(){return this.toString()},toString(){return`<redacted${ys(this.label)?":"+this.label:""}>`},[Be](){return We(fa.get(this))},[ze](e){return of(e)&&he(fa.get(this),fa.get(e))}},Rr=mI;var gI=(e)=>Ar((t,n)=>e(Rr(t),Rr(n)));var Bh=Symbol.for("~effect/http/Headers"),EI=(e)=>V(e,Bh),_d=Object.defineProperties(Object.create(null),{[Bh]:{value:Bh},[yI]:{value(e){return IF(this,Lt(e,wF))}},toJSON:{value(){return ui(this)}},[ze]:{value(e){return Lh(this,e)}},[Be]:{value(){return xI(this)}},toString:{value:ho.toString},[Re]:{value:ho[Re]}}),Rd=(e)=>Object.assign(Object.create(_d),e),Lh=SI(da()),di=Object.create(_d),Es=(e)=>{if(e===void 0)return di;else if(Symbol.iterator in e){let n=Object.create(_d);for(let[r,o]of e)n[r.toLowerCase()]=o;return n}let t=Object.create(_d);for(let[n,r]of Object.entries(e))if(Array.isArray(r))t[n.toLowerCase()]=r.join(", ");else if(r!==void 0)t[n.toLowerCase()]=r;return t};var af=y(3,(e,t,n)=>{let r=Rd(e);return r[t.toLowerCase()]=n,r}),bI=y(2,(e,t)=>Rd({...e,...Es(t)})),Pd=y(2,(e,t)=>{let n=Rd(e);return Object.assign(n,t),n}),li=y(2,(e,t)=>{let n=Rd(e);return delete n[t.toLowerCase()],n});var IF=y(2,(e,t)=>{let n={...e},r=(o)=>{if(typeof o==="string"){let s=o.toLowerCase();if(s in e)n[s]=ua(e[s])}else for(let s in e)if(s.search(o)!==-1)n[s]=ua(e[s])};if(Array.isArray(t))for(let o=0;o<t.length;o++)r(t[o]);else r(t);return n});var wF=sf("effect/Headers/CurrentRedactedNames",{defaultValue:()=>["authorization","cookie","set-cookie","x-api-key"]});var zh="~effect/http/UrlParams",qh=(e)=>V(e,zh),kF={...Ss,[zh]:zh,[Symbol.iterator](){return this.params[Symbol.iterator]()},toJSON(){return{_id:"UrlParams",params:Object.fromEntries(this.params)}},[ze](e){return Hh(this,e)},[Be](){return oi(this.params.flat())}},pi=(e)=>{let t=Object.create(kF);return t.params=e,t},la=(e)=>{if(qh(e))return e;let t=kI(e),n=[];for(let r=0;r<t.length;r++)if(Array.isArray(t[r][0])){let[o,s]=t[r];n.push([`${o[0]}[${o.slice(1).join("][")}]`,s])}else n.push(t[r]);return pi(n)},kI=(e)=>{let t=typeof e[Symbol.iterator]==="function"?_t(e):Object.entries(e),n=[];for(let[r,o]of t)if(Array.isArray(o)){for(let s=0;s<o.length;s++)if(o[s]!==void 0)n.push([r,String(o[s])])}else if(o!==null&&typeof o==="object"){let s=kI(o);for(let[a,i]of s)n.push([[r,...typeof a==="string"?[a]:a],i])}else if(o!==void 0)n.push([r,String(o)]);return n},Hh=Ar((e,t)=>TF(e.params,t.params)),TF=wI(II([da(),da()])),TI=pi([]);var AI=y(2,(e,t)=>fh(e.params,([n])=>n===t).pipe(qo(([,n])=>n)));var CI=y(2,(e,t)=>{let n=la(t).params.slice(),r=new Set;for(let o=0;o<n.length;o++)r.add(n[o][0]);for(let o=0;o<e.params.length;o++){if(r.has(e.params[o][0]))continue;n.push(e.params[o])}return pi(n)});var AF=(e)=>{let t={};for(let[n,r]of e.params)if(!Object.hasOwn(t,n))q(t,n,r);else{let o=t[n];if(typeof o==="string")q(t,n,[o,r]);else o.push(r)}return t},vI=AF;var Wh="~effect/Graph",Jh=(e)=>V(e,Wh),OI=(e)=>e;var CF=(e,t,n)=>(e==="directed"?t.source===n.source&&t.target===n.target:t.source===n.source&&t.target===n.target||t.source===n.target&&t.target===n.source)&&he(t.data,n.data),vF=(e,t)=>e==="directed"?We(t):mo(Le(We(t.data),OF(t.source,t.target))),OF=(e,t)=>Le(0,We(e))+Le(0,We(t)),_F=mn("Graph"),RF={[Wh]:{_N:(e)=>e,_E:(e)=>e},[Symbol.iterator](){return this.nodes[Symbol.iterator]()},[Re](){return this.toJSON()},[ze](e){if(V(e,Wh)){let t=OI(e);if(this.nodes.size!==t.nodes.size||this.edges.size!==t.edges.size||this.type!==t.type)return!1;for(let[n,r]of this.nodes)if(!t.nodes.has(n)||!he(r,t.nodes.get(n)))return!1;for(let[n,r]of this.edges){let o=t.edges.get(n);if(o===void 0||!CF(this.type,r,o))return!1}return!0}return!1},[Be](){let e=_F;e=e^mn(this.type),e=e^Bn(this.nodes.size),e=e^Bn(this.edges.size);for(let[t,n]of this.nodes)e^=Le(We(t),We(n));for(let[t,n]of this.edges)e^=Le(We(t),vF(this.type,n));return mo(e)},toJSON(){return{_id:"Graph",nodeCount:this.nodes.size,edgeCount:this.edges.size,type:this.type}},toString(){return`Graph(${this.type}, ${this.nodes.size}, ${this.edges.size})`},pipe(){return de(this,arguments)}},PF=(e,t)=>{let n=Object.create(RF);return n.type=e,n.mutable=t,n.transforming=!1,n.nodes=new Map,n.edges=new Map,n.adjacency=new Map,n.reverseAdjacency=new Map,n.nextNodeIndex=0,n.nextEdgeIndex=0,n.acyclic=oe(!0),n};var ff=(e)=>{let t=OI(e);return{type:e.type,nodes:Array.from(t.nodes,([n,r])=>({index:n,data:r})).sort((n,r)=>n.index-r.index),edges:Array.from(t.edges,([n,r])=>({index:n,source:r.source,target:r.target,data:r.data})).sort((n,r)=>n.index-r.index)}},Ud=(e)=>{let t=PF(e.type,!1);for(let n of e.nodes)t.nodes.set(n.index,n.data),t.adjacency.set(n.index,[]),t.reverseAdjacency.set(n.index,[]);for(let n of e.edges)if(t.edges.set(n.index,{source:n.source,target:n.target,data:n.data}),t.adjacency.get(n.source).push(n.index),t.reverseAdjacency.get(n.target).push(n.index),e.type==="undirected")t.adjacency.get(n.target).push(n.index),t.reverseAdjacency.get(n.source).push(n.index);return t.nextNodeIndex=e.nodes.length===0?0:e.nodes[e.nodes.length-1].index+1,t.nextEdgeIndex=e.edges.length===0?0:e.edges[e.edges.length-1].index+1,t.acyclic=ne(),t};function Ho(e){return e.checks?e.checks[e.checks.length-1].annotations:e.annotations}function Fd(e){return(t)=>Ho(t)?.[e]}var An="~structural",pa="~identifier",uf="~sentinels",Dd="~constructor",_I=["title","description","default","examples","readOnly","writeOnly","format","contentEncoding","contentMediaType","contentSchema"],mi=Fd("identifier"),Gh=Fd(pa),Kh=Fd("title");var df=Ln((e)=>{let t=Ho(e)?.identifier;if(typeof t==="string")return t;return e.getExpected(df)}),RI=new Set([uf,An,"representation","arbitraryConstraint","toJsonSchema","toCode","toEquivalence","toFormatter","toCodec","toCodecJson","toCodecStringTree","toCodecIso","toCodecArbitrary"]);var ce=Symbol();var Rt=xn,Cn=Rt(ce),Ce=Rt(ce),lf=(e)=>e===ce?ne():oe(e),Vh=(e)=>e._tag==="None"?Cn:Rt(e.value);var mf="~effect/SchemaIssue/Issue";function Qh(e){return V(e,mf)&&e[mf]===mf}function UF(e){return Object.hasOwn(e,"input")}class nr{[mf]=mf;constructor(e,t){if(t?.reportInput===!0&&e!==ce)this.input=e}}var PI=class extends nr{_tag="Filter";filter;issue;constructor(e,t,n,r){super(n,r);this.filter=e,this.issue=t}},MI=class extends nr{_tag="Encoding";ast;issue;constructor(e,t,n,r){super(n,r);this.ast=e,this.issue=t}},Qe=class extends nr{_tag="Pointer";path;issue;constructor(e,t){super();this.path=e,this.issue=t}},ot=class extends nr{_tag="MissingKey";annotations;constructor(e){super();this.annotations=e}},ma=class extends nr{_tag="UnexpectedKey";ast;constructor(e,t,n){super(t,n);this.ast=e}},tt=class extends nr{_tag="Composite";ast;issues;constructor(e,t,n,r){super(n,r);this.ast=e,this.issues=t}},Fe=class extends nr{_tag="InvalidType";ast;constructor(e,t,n){super(t,n);this.ast=e}},te=class extends nr{_tag="InvalidValue";annotations;constructor(e,t,n){super(t,n);this.annotations=e}};function vn(e,t,n,r,o){return new tt(e,[new Qe([t],n)],r,o)}var hf=class extends nr{_tag="Forbidden";annotations;constructor(e,t,n){super(t,n);this.annotations=e}},gf=class extends nr{_tag="AnyOf";ast;issues;constructor(e,t,n,r){super(n,r);this.ast=e,this.issues=t}},UI=class extends nr{_tag="OneOf";ast;successes;constructor(e,t,n,r){super(n,r);this.ast=e,this.successes=t}};function Zh(e,t,n){if(Qh(e))return e;if(typeof e==="string")return new te({message:e},t,n);let r=typeof e.issue==="string"?new te({message:e.issue},t,n):e.issue;return new Qe(e.path,r)}function FI(e,t,n){if(e===void 0)return;if(typeof e==="boolean")return e?void 0:new te(void 0,t,n);return Zh(e,t,n)}function DI(e,t,n,r){if(Array.isArray(t)){if(!Ke(t))return;return t.length===1?Zh(t[0],n,r):new tt(e,hn(t,(o)=>Zh(o,n,r)),n,r)}return FI(t,n,r)}var NI=(e)=>{let t=xi(e);if(t!==void 0)return t;switch(e._tag){case"InvalidType":return Is(df(e.ast),e);case"InvalidValue":{let n=Yh(e);if(n!==void 0)return Is(n,e);let r=Nd(e);return r===void 0?"Expected a valid value":`Invalid data ${r}`}case"MissingKey":return"Missing key";case"UnexpectedKey":{let n=Nd(e);return n===void 0?"Expected no excess property":`Unexpected key with value ${n}`}case"Forbidden":return"Forbidden operation";case"OneOf":{let n=Nd(e);return n===void 0?"Expected exactly one member to match":`Expected exactly one member to match the input ${n}`}}},BI=(e)=>xi(e.issue)??xi(e);function LI(e){return(t)=>({issues:gi(t,[],e?.leafHook??NI,e?.checkHook??BI)})}function Nd(e){return UF(e)?K(e.input):void 0}function Yh(e){let t=e.annotations?.expected;return typeof t==="string"?t:void 0}function Is(e,t){let n=Nd(t);return n===void 0?`Expected ${e}`:`Expected ${e}, got ${n}`}function gi(e,t,n,r){switch(e._tag){case"Filter":{let o=r(e);if(o!==void 0)return[{path:t,message:o}];if(e.issue._tag!=="InvalidValue")return gi(e.issue,t,n,r);let s=Yh(e.issue);return[{path:t,message:s===void 0?Is(Xh(e.filter),e):Is(s,e.issue)}]}case"Encoding":return gi(e.issue,t,n,r);case"Pointer":return gi(e.issue,[...t,...e.path],n,r);case"Composite":return e.issues.flatMap((o)=>gi(o,t,n,r));case"AnyOf":{if(e.issues.length===0)return[{path:t,message:xi(e)??Is(df(e.ast),e)}];return e.issues.flatMap((o)=>gi(o,t,n,r))}default:return[{path:t,message:n(e)}]}}function Xh(e){let t=e.annotations?.expected;if(typeof t==="string")return t;switch(e._tag){case"Filter":return"<filter>";case"FilterGroup":return e.checks.map((n)=>Xh(n)).join(" & ")}}function FF(){return(e)=>pf(e,"")}var zI=FF();function pf(e,t){let n;switch(e._tag){case"Filter":{let r=BI(e);if(r!==void 0)n=r;else{if(e.issue._tag!=="InvalidValue")return pf(e.issue,t);let o=Yh(e.issue);n=o===void 0?Is(Xh(e.filter),e):Is(o,e.issue)}break}case"Encoding":return pf(e.issue,t);case"Pointer":return pf(e.issue,t+Bd(e.path));case"Composite":case"AnyOf":{if(e._tag==="Composite"||e.issues.length>0)return e.issues.map((r)=>pf(r,t)).join(`
|
|
3
|
+
`);n=xi(e)??Is(df(e.ast),e);break}default:n=NI(e);break}return t?`${n}
|
|
4
|
+
at ${t}`:n}function xi(e){if(e._tag==="Pointer")return;if(e._tag==="Encoding")return xi(e.issue);let n=(e._tag==="Filter"?e.filter.annotations:("annotations"in e)?e.annotations:e.ast.annotations)?.[e._tag==="MissingKey"?"messageMissingKey":e._tag==="UnexpectedKey"?"messageUnexpectedKey":"message"];if(typeof n==="string")return n}function xf(e){let t;for(let n of e.reasons){if(!Ld(n)||!Qh(n.error))return;t??=n.error}return t}function zn(e,t){let n=xf(e);if(n===void 0)throw Error(t,{cause:e});return n}var qI=(e)=>ai(e).replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_"),eg=(e)=>{let t=e.replace(/[\n\r]/g,""),n=t.length;if(n%4===1)return ge(new aa({module:"Base64Url",kind:"Decode",input:t,message:`Length should be a multiple of 4, but is ${n}`}));if(!/^[-_A-Z0-9]*?={0,2}$/i.test(t))return ge(new aa({module:"Base64Url",kind:"Decode",input:t,message:"Invalid input"}));let r=n%4===2?`${t}==`:n%4===3?`${t}=`:t;return r=r.replace(/-/g,"+").replace(/_/g,"/"),ia(r)},HI=(e)=>vr(eg(e),(t)=>DF.decode(t)),DF=new TextDecoder;var yf=(e)=>Object.assign(Object.create(jI),e);function LF(e){return QI((t,n)=>_(e(t,n)))}function jd(e){return LF((t,n)=>{let r={message:e(t)};return ve(t)?new hf(r,t.value,n):new hf(r)})}var ZI=jd(()=>"Encoding is not supported"),zF=yf({_tag:"Passthrough"});function xo(){return zF}function se(e){return yf({_tag:"Transform",transform:e})}function $t(e){return yf({_tag:"TransformEffect",transform:e})}function Wd(e){return yf({_tag:"TransformOptional",transform:e})}function QI(e){return yf({_tag:"TransformOptionalEffect",transform:e})}function tg(){return Wd(()=>ne())}function ng(e){return QI((t)=>{let n=yi(t,ws);return ve(n)?b(n):qd(e,oe)})}function ha(){return se(globalThis.String)}function Jd(){return se(globalThis.Number)}function YI(){return se(globalThis.BigInt)}function rg(){return se((e)=>new globalThis.Date(e))}function XI(){return se(KI)}function ew(e){return $t((t,n)=>Mr({try:()=>JSON.parse(t,e?.reviver),catch:()=>new te({expected:"a valid JSON string"},t,n)}))}function tw(e){return $t((t,n)=>Mr({try:()=>{let r=JSON.stringify(t,e?.replacer,e?.space);if(r===void 0)throw TypeError("Value cannot be represented as JSON");return r},catch:()=>new te({expected:"a JSON-serializable value"},t,n)}))}function og(){return se(ai)}function Gd(){return se(qI)}function Kd(){return se(WI)}function nw(){return $t((e,t)=>Hd(VI(ia(e)),()=>new te({expected:"a valid Base64 string"},e,t)))}function rw(){return $t((e,t)=>Pr(Bb(e),{onFailure:()=>_(new te({expected:"a valid Base64 string"},e,t)),onSuccess:b}))}function ow(){return $t((e,t)=>Pr(eg(e),{onFailure:()=>_(new te({expected:"a valid Base64Url string"},e,t)),onSuccess:b}))}function sw(){return $t((e,t)=>Pr(HI(e),{onFailure:()=>_(new te({expected:"a valid Base64Url string"},e,t)),onSuccess:b}))}function aw(){return $t((e,t)=>Pr(JI(e),{onFailure:()=>_(new te({expected:"a valid hexadecimal string"},e,t)),onSuccess:b}))}function iw(){return $t((e,t)=>Pr(GI(e),{onFailure:()=>_(new te({expected:"a valid hexadecimal string"},e,t)),onSuccess:b}))}function cw(){return se(encodeURIComponent)}function fw(){return $t((e,t)=>{try{return b(globalThis.decodeURIComponent(e))}catch{return _(new te({expected:"a valid URI component"},e,t))}})}function uw(){return se((e)=>mw(Array.from(e.entries())))}var $F=hw((e)=>typeof e==="string"||typeof Blob<"u"&&e instanceof Blob);function dw(){return se((e)=>{let t=new FormData;if(typeof e==="object"&&e!==null)$F(e).forEach(([r,o])=>{t.append(r,o)});return t})}function lw(){return se((e)=>mw(Array.from(e.entries())))}var qF=hw(ys);function pw(){return se((e)=>{if(typeof e==="object"&&e!==null)return new URLSearchParams(qF(e));return new URLSearchParams})}function HF(e){if(e==="")return[""];let t=e.replace(/\[(.*?)\]/g,".$1"),n=t.split("."),r=t.startsWith(".")?1:0;return n.slice(r).map((o)=>$d(o)?globalThis.Number(o):o)}function mw(e){let t={},n=new WeakSet,r=new WeakSet;function o(s,a,i){let c=Object.hasOwn(s,a)?s[a]:void 0;if(n.has(c)&&Array.isArray(c)===i)return c;let f=i?[]:{};return n.add(f),q(s,a,f),f}return e.forEach(([s,a])=>{let i=HF(s),c=t;i.forEach((f,u)=>{let d=u===i.length-1;if(Array.isArray(c)&&f==="")if(d)c.push(a);else{let l=i[u+1],m=typeof l==="number"||l==="",p=c.length;c=o(c,p,m)}else if(d){let l=Object.hasOwn(c,f);if(l&&Array.isArray(c[f])&&(n.has(c[f])||r.has(c[f])))c[f].push(a);else if(l){let m=[c[f],a];r.add(m),q(c,f,m)}else q(c,f,a)}else{let l=i[u+1];c=o(c,f,typeof l==="number"||l==="")}})}),t}function hw(e){return(t)=>{let n=[];function r(o,s){if(e(s))n.push([o,s]);else if(Array.isArray(s))if(s.every(e))s.forEach((i)=>{n.push([o,i])});else s.forEach((i,c)=>{r(`${o}[${c}]`,i)});else if(typeof s==="object"&&s!==null)for(let[a,i]of Object.entries(s))r(`${o}[${a}]`,i)}for(let[o,s]of Object.entries(t))r(o,s);return n}}var Qd=class extends Ei{_tag="Middleware";decode;encode;constructor(e,t){super();this.decode=e,this.encode=t}flip(){return new Qd(this.encode,this.decode)}},Sf="~effect/SchemaTransformation/Transformation",be=class extends Ei{[Sf]=Sf;_tag="Transformation";decode;encode;constructor(e,t){super();this.decode=e,this.encode=t}flip(){return new be(this.encode,this.decode)}};function jF(e){return V(e,Sf)&&e[Sf]===Sf}var Yd=(e)=>{if(jF(e))return e;return new be(e.decode,e.encode)};function Et(e){return new be($t(e.decode),$t(e.encode))}function xe(e){return new be(se(e.decode),se(e.encode))}function Xd(e){return new be(Wd(e.decode),Wd(e.encode))}function bw(){return new be(XI(),xo())}var WF=new be(xo(),xo());function Ii(){return WF}var wi=new be(Jd(),ha()),el=new be(YI(),ha()),ag=new be(rg(),se(xw)),Iw=new be(rg(),se((e)=>e.getTime()));var ig=Et({decode:(e,t)=>zt(ZE(e),{onNone:()=>_(new te({expected:"a valid ByteSize string"},e,t)),onSome:b}),encode:(e)=>b(`${e} ${e===BigInt(1)?"byte":"bytes"}`)}),ww=Et({decode:(e,t)=>zt(ah(e),{onNone:()=>_(new te({expected:"a non-negative bigint byte count"},e,t)),onSome:b}),encode:(e)=>b(ld(e))}),kw=Et({decode:(e,t)=>zt(ah(e),{onNone:()=>_(new te({expected:"a non-negative safe-integer byte count"},e,t)),onSome:b}),encode:(e,t)=>zt(XE(e),{onNone:()=>_(new te({expected:"a ByteSize representable as a safe integer"},e,t)),onSome:b})}),JF=(e)=>st(e)&&typeof e.message==="string",Tw=(e)=>{let n=Object.hasOwn(e,"cause")?Error(e.message,{cause:Cw(e.cause)}):Error(e.message);if(typeof e.name==="string"&&e.name!=="Error")n.name=e.name;if(typeof e.stack==="string")n.stack=e.stack;return n},GF=(e)=>{try{let t=yw(e);return t===void 0?K(e):JSON.parse(t)}catch{return K(e)}},KF=(e,t,n)=>{let r={name:e.name,message:typeof e.message==="string"?e.message:""};if(t?.includeStack&&typeof e.stack==="string")r.stack=e.stack;if(!t?.excludeCause&&e.cause!==void 0)r.cause=n(e.cause);return r},Aw=(e)=>{let t=new WeakSet,n=(r)=>{if(gw(r)){if(t.has(r))return"[Circular]";t.add(r);let o=KF(r,e,n);return t.delete(r),o}return GF(r)};return n},Cw=(e)=>JF(e)?Tw(e):e,vw=(e)=>xe({decode:Tw,encode:(t)=>Aw(e)(t)}),Ow=(e)=>xe({decode:Cw,encode:Aw(e)});function _w(){return xe({decode:Ew,encode:sg})}function Rw(){return xe({decode:Sw,encode:Ef})}function Pw(e){return xe({decode:Zd,encode:e?.onNoneEncoding===null?sg:Ef})}function Mw(){return Xd({decode:oe,encode:bi})}function Uw(){return Xd({decode:(e)=>e.pipe(yi(ws),oe),encode:bi})}var cg=Et({decode:(e,t)=>URL.canParse(e)?b(new URL(e)):_(new te({expected:"a valid URL string"},e,t)),encode:(e)=>b(e.href)});var fg=new be(nw(),og()),Fw=new be(rw(),og()),Dw=new be(sw(),Gd()),Nw=new be(iw(),Kd()),Bw=new be(fw(),cw());function Lw(e){return new be(ew(e??{}),tw(e))}var zw=new be(uw(),dw()),$w=new be(lw(),pw());function As(e){return(t)=>t._tag===e}var Ci=As("Declaration");var VF=As("Never");var Ti=As("Literal"),dg=As("UniqueSymbol");var Eg=As("Arrays"),ZF=As("Objects"),tk=As("Union"),nk=As("Suspend"),Xe=class{to;transformation;constructor(e,t){this.to=e,this.transformation=t}},jt={},sr=class{isOptional;isMutable;constructorDefault;annotations;constructor(e,t,n=void 0,r=void 0){this.isOptional=e,this.isMutable=t,this.constructorDefault=n,this.annotations=r}},qw="~effect/Schema";class at{[qw]=qw;annotations;checks;encoding;context;constructor(e=void 0,t=void 0,n=void 0,r=void 0){this.annotations=e,this.checks=t,this.encoding=n,this.context=r}toString(){return`<${this._tag}>`}}var Cs=class extends at{_tag="Declaration";typeParameters;run;encodingChecks;encodingRun;constructor(e,t,n,r,o,s,a,i){super(n,r,o,s);this.typeParameters=e,this.run=t,this.encodingChecks=a,this.encodingRun=i}getParser(){let e;return(t,n)=>{if(t===ce)return Cn;return(e??=this.run(this.typeParameters))(t,this,n)}}_rebuild(e,t,n,r,o){let s=xa(this.typeParameters,e);return s===this.typeParameters&&t===this.checks&&n===this.encodingChecks&&r===this.run&&o===this.encodingRun?this:new Cs(s,r,this.annotations,t,void 0,this.context,n,o)}recur(e){return this._rebuild(e,this.checks,this.encodingChecks,this.run,this.encodingRun)}flip(e){return this._rebuild(e,this.encodingChecks,this.checks,this.encodingRun??this.run,this.run)}getExpected(){let e=this.annotations?.expected;if(typeof e==="string")return e;return"<Declaration>"}},QF=class extends at{_tag="Null";getParser(){return xl(this,null)}getExpected(){return"null"}},bg=new QF;var YF=class extends at{_tag="Undefined";getParser(){return xl(this,void 0)}toCodecJson(){return Pe(this,[rk])}getExpected(){return"undefined"}},rk=new Xe(bg,new be(se(()=>{return}),se(()=>null))),Ig=new YF;var XF=class extends at{_tag="Void";getParser(){let e=Rt(void 0);return(t)=>t===ce?Cn:e}toCodecJson(){return Pe(this,[rk])}getExpected(){return"void"}},ok=new XF;var eD=class extends at{_tag="Never";getParser(){return Fr(this,Xw)}getExpected(){return"never"}},wg=new eD,tD=class extends at{_tag="Any";getParser(){return Fr(this,Sg)}getExpected(){return"any"}},sk=new tD,nD=class extends at{_tag="Unknown";getParser(){return Fr(this,Sg)}getExpected(){return"unknown"}},jo=new nD,rD=class extends at{_tag="ObjectKeyword";getParser(){return Fr(this,rl)}getExpected(){return"object | array | function"}},ak=new rD,ik=class extends at{_tag="Enum";enums;constructor(e,t,n,r,o){super(t,n,r,o);for(let[,s]of e)if(typeof s==="number"&&!globalThis.Number.isFinite(s))throw Error(`A numeric enum value must be finite, got ${K(s)}`);this.enums=e}getParser(){let e=new Set(this.enums.map(([,t])=>t));return Fr(this,(t)=>e.has(t))}toCodecStringTree(){if(this.enums.some(([e,t])=>typeof t==="number")){let e=Object.fromEntries(this.enums.map(([t,n])=>[globalThis.String(n),n]));return Pe(this,[new Xe(new tn(Object.keys(e).map((t)=>new yn(t))),new be(se((t)=>e[t]),ha()))])}return this}getExpected(){return this.enums.map(([e,t])=>JSON.stringify(t)).join(" | ")}};function ug(e){return typeof e==="number"?`parts[${e}]`:e}function lg(e,t,n){if(n.has(e))return!0;if(e.encoding)throw Error(`TemplateLiteral parts cannot have an encoding at ${ug(t)}`);let r;switch(e._tag){case"String":case"Number":case"BigInt":r=!0;break;case"Literal":r=!e.checks;break;case"TemplateLiteral":{let o=ug(t);r=!e.checks&&e.parts.every((s,a)=>lg(s,`${o}.parts[${a}]`,n));break}case"Union":{let o=ug(t);r=!e.checks&&e.types.every((s,a)=>lg(s,`${o}.types[${a}]`,n));break}default:return!1}if(r)n.add(e);return r}var kg=class extends at{_tag="TemplateLiteral";parts;encodedParts;literals;suffixLengths;constructor(e,t,n,r,o){super(t,n,r,o);let s=[],a=[],i=new Set;for(let f=0;f<e.length;f++){let u=e[f];if(!lg(u,f,i))throw Error(`Invalid TemplateLiteral part ${u._tag}`);s.push(u),a.push(u._tag==="Literal"?globalThis.String(u.literal):void 0)}let c=Array(s.length+1);c[s.length]=0;for(let f=s.length-1;f>=0;f--)c[f]=c[f+1]+(a[f]?.length??0);this.parts=e,this.encodedParts=s,this.literals=a,this.suffixLengths=c}getParser(e){let t=new ar(!1,this.parts.map(Ng),[]),n=e(Pi($n,t,fk(this)));return(r,o)=>{if(r===ce)return Cn;let s=n(r,o);if(s._tag==="Success")return Ce;return Ht(s,{onSuccess:()=>r,onFailure:(a)=>new tt(this,[a],r,o)})}}getExpected(){return"string"}matchPart(e,t){return Uk(this,e,t)===void 0?void 0:e}};function ck(e){let t=Ln((o)=>{if(o._tag!=="Union")return o;let s=xa(o.types,t);return(o.options?.mode??"anyOf")==="anyOf"&&s===o.types?o:new tn(s,o.options===void 0?void 0:{...o.options,mode:"anyOf"},o.annotations,o.checks,void 0,o.context)}),n=new kg(e.map((o)=>t(En(o)))),r=new ar(!1,e.map(Ng),[]);return Pi(n,r,fk(n))}function fk(e){return new be($t((t,n)=>{let r=Uk(e,t,n);if(r)return b(r);return _(new te({expected:"a string matching template literal parts"},t,n))}),se((t)=>t.join("")))}var uk=class extends at{_tag="UniqueSymbol";symbol;constructor(e,t,n,r,o){super(t,n,r,o);this.symbol=e}getParser(){return xl(this,this.symbol)}toCodecStringTree(){let e=globalThis.Symbol.keyFor(this.symbol);return Pe(this,[new Xe(e===void 0?wg:new yn(globalThis.String(this.symbol)),Nk.transformation)])}getExpected(){return globalThis.String(this.symbol)}},yn=class extends at{_tag="Literal";literal;constructor(e,t,n,r,o){super(t,n,r,o);if(typeof e==="number"&&!globalThis.Number.isFinite(e))throw Error(`A numeric literal must be finite, got ${K(e)}`);this.literal=e}getParser(){return xl(this,this.literal)}matchPart(e,t){return e===globalThis.String(this.literal)?this.literal:void 0}toCodecJson(){return typeof this.literal==="bigint"?Hw(this):this}toCodecStringTree(){return typeof this.literal==="string"?this:Hw(this)}getExpected(){return typeof this.literal==="string"?JSON.stringify(this.literal):globalThis.String(this.literal)}};function Hw(e){let t=globalThis.String(e.literal);return Pe(e,[new Xe(new yn(t),new be(se(()=>e.literal),se(()=>t)))])}var oD=class extends at{_tag="String";getParser(){return Fr(this,ys)}matchPart(e,t){let n=this.checks;return n&&!t.disableChecks&&Dr(n,e,void 0,this,t)?void 0:e}getExpected(){return"string"}},$n=new oD,sD=class extends at{_tag="Number";getParser(){return Fr(this,Vw)}matchKey(e,t){return this._match(TD,e,t)}matchPart(e,t){return this._match(gg,e,t)}_match(e,t,n){if(!e.test(t))return;let r=globalThis.Number(t);if(n.disableChecks||!this.checks)return r;return Dr(this.checks,r,void 0,this,n)?void 0:r}toCodecJson(){if(this.checks&&(pg(this.checks,"effect/schema/isFinite")||pg(this.checks,"effect/schema/isInt")))return this;return Pe(this,[yD])}toCodecStringTree(){if(this.toCodecJson()===this)return Pe(this,[AD]);return Pe(this,[CD])}getExpected(){return"number"}};function pg(e,t){return e.some((n)=>n.annotations?.representation?.id===t||n._tag==="FilterGroup"&&pg(n.checks,t))}var Tg=new sD,aD=class extends at{_tag="Boolean";getParser(){return Fr(this,Zw)}getExpected(){return"boolean"}},dk=new aD,iD=class extends at{_tag="Symbol";getParser(){return Fr(this,Yw)}matchKey(e,t){if(t.disableChecks||!this.checks)return e;return Dr(this.checks,e,void 0,this,t)?void 0:e}toCodecStringTree(){return Pe(this,[Nk])}getExpected(){return"symbol"}},lk=new iD,cD=class extends at{_tag="BigInt";getParser(){return Fr(this,Qw)}matchPart(e,t){if(!xg.test(e))return;let n=globalThis.BigInt(e);if(t.disableChecks||!this.checks)return n;return Dr(this.checks,n,void 0,this,t)?void 0:n}toCodecStringTree(){return Pe(this,[OD])}getExpected(){return"bigint"}},pk=new cD,ar=class extends at{_tag="Arrays";isMutable;elements;rest;encodingChecks;constructor(e,t,n,r,o,s,a,i){super(r,o,s,a);this.isMutable=e,this.elements=t,this.rest=n,this.encodingChecks=i;let c=!1;for(let f=0;f<t.length;f++)if(Mt(t[f]))c=!0;else if(c)throw Error("A required element cannot follow an optional element. ts(1257)");if(c&&n.length>1)throw Error("A required element cannot follow an optional element. ts(1257)");for(let f=1;f<n.length;f++)if(Mt(n[f]))throw Error("An optional element cannot follow a rest element. ts(1266)")}getParser(e,t=e){let n=this,r,o,s=n.elements.length,a=Math.max(0,n.rest.length-1);function i(u,d){if(d<s)return r[d];else if(d>=u)return o[d-u+1];return o[0]}let c=(u)=>{let{input:d,len:l,options:m}=u;if(n.rest.length===0&&l>s)for(let p=s;p<l;p++){let g=new ma(n,d[p],m),h=new Qe([p],g);if(m.errors==="all")if(u.issues)u.issues.push(h);else u.issues=[h];else return _(new tt(n,[h],d,m))}if(u.issues)return _(new tt(n,u.issues,d,m));return Rt(u.output)},f=(u,d)=>{let l=u.length,m={ast:n,getParser:i,input:u,len:l,tailThreshold:Math.max(s,l-a),output:new globalThis.Array(l),issues:void 0,options:d},p=n.rest.length===0?s:Math.max(l,s+a),g=d.concurrency===void 0?1:ol(d.concurrency),h=g===1?uD(m,u,0,p):dD(m,u,{concurrency:g,end:p});if(!h)return c(m);if(qt(h))return Pt(h,()=>c(m));let E=!0;return M(()=>{if(!E)return f(u,d);return E=!1,A(h,()=>c(m))})};return(u,d)=>{if(u===ce)return Cn;try{if(!Array.isArray(u))return _(new Fe(n,u,d));if(!r)r=n.elements.map((l)=>({ast:l,parser:t(l)})),o=n.rest.map((l)=>({ast:l,parser:t(l)}));return f(u,d)}catch(l){return _n(l)}}}_rebuild(e,t,n){let r=xa(this.elements,e),o=xa(this.rest,e);return r===this.elements&&o===this.rest&&t===this.checks&&n===this.encodingChecks?this:new ar(this.isMutable,r,o,this.annotations,t,void 0,this.context,n)}recur(e){return this._rebuild(e,this.checks,this.encodingChecks)}flip(e){return this._rebuild(e,this.encodingChecks,this.checks)}getExpected(){return"array"}};function fD(e,t,n,r){if(n._tag==="Failure")return sl(e,e.ast,r,n);let o=n===Ce?t:n[gn];if(o!==ce)e.output[r]=o;else{let s=e.getParser(e.tailThreshold,r);if(Mt(s.ast))return;let a=new Qe([r],new ot(s.ast.context?.annotations));if(e.options.errors==="all")if(e.issues)e.issues.push(a);else e.issues=[a];else return So(new tt(e.ast,[a],e.input,e.options))}}var mk={onItem(e,t,n){let r=n<e.len?t:ce;return e.getParser(e.tailThreshold,n).parser(r,e.options)},step:fD},uD=fl()(mk),dD=ul()(mk),sl=(e,t,n,r)=>{if(r.cause.reasons.length===0)return r;let o=xf(r.cause);if(o===void 0)return en(Ts(r.cause,(a)=>new tt(t,[new Qe([n],a)],e.input,e.options)));let s=new Qe([n],o);if(e.options.errors==="all")if(e.issues)e.issues.push(s);else e.issues=[s];else return So(new tt(t,[s],e.input,e.options))},dl="[+-]?\\d*\\.?\\d+(?:[Ee][+-]?\\d+)?";function yo(e,t,n=jt){let r,o;function s(a){switch(a._tag){case"String":case"TemplateLiteral":return(r??=Object.keys(e)).filter((i)=>a.matchPart(i,n)!==void 0);case"Number":return(r??=Object.keys(e)).filter((i)=>a.matchKey(i,n)!==void 0);case"Symbol":return(o??=Object.getOwnPropertySymbols(e)).filter((i)=>Object.prototype.propertyIsEnumerable.call(e,i)&&a.matchKey(i,n)!==void 0);case"Union":return[...new Set(a.types.flatMap(s))];default:return[]}}return s(Dg(En(t)))}var Ag=class{name;type;constructor(e,t){this.name=e,this.type=t}};function hk(e){switch(e._tag){case"String":case"Number":case"Symbol":case"TemplateLiteral":return!0;case"Union":return e.types.every(hk);default:return!1}}function gk(e){let t=Oi(e);switch(t._tag){case"String":case"Number":case"Symbol":case"TemplateLiteral":return!0;case"Union":return t.types.every(gk);default:return!1}}function lD(e){return hk(e)&&gk(e)}var Cg=class{parameter;type;constructor(e,t){if(!lD(e))throw Error(`Invalid index signature parameter ${e._tag}`);if(this.parameter=e,this.type=t,Mt(t)&&!Mk(t))throw Error("Cannot use `Schema.optionalKey` with index signatures, use `Schema.optional` instead.")}},bf=class extends at{_tag="Objects";propertySignatures;indexSignatures;encodingChecks;constructor(e,t,n,r,o,s,a){super(n,r,o,s);this.propertySignatures=e,this.indexSignatures=t,this.encodingChecks=a}getParser(e,t=e){let n=this,r=n.propertySignatures.length,o=n.indexSignatures.length;if(!r&&!o)return Fr(n,cl);let s,a,i=()=>{if(!s)s=n.propertySignatures.map((d)=>({parser:t(d.type),name:d.name,type:d.type})),a=o?n.indexSignatures.map((d)=>({is:d,parserKey:e(Dg(d.parameter)),parserValue:t(d.type)})):void 0;return s},c=()=>{let d=new Set(n.propertySignatures.map((h)=>typeof h.name==="number"?globalThis.String(h.name):h.name)),l=(h,E,S,k,I)=>{if(I._tag==="Failure")return sl(h,n,E,I)??Ye;let x=I===Ce?k:I[gn];if(S!==ce&&x!==ce){if(r&&(d.has(E)||d.has(typeof S==="number"?globalThis.String(S):S)))return Ye;q(h.out,S,x)}return Ye},m=(h,E,S,k)=>{if(!k){let C=S.parserKey(E,h.options);if(!qt(C))return A(or(C),(T)=>m(h,E,S,T));k=C}if(k._tag==="Failure")return sl(h,n,E,k)??Ye;let I=k===Ce?E:k[gn],x=h.input[E],w=S.parserValue(x,h.options);return qt(w)?l(h,E,I,x,w):A(or(w),(C)=>l(h,E,I,x,C))},p=(h,E,S)=>{let k=h.input[E],I=S.parserValue(k,h.options);return qt(I)?l(h,E,E,k,I):A(or(I),(x)=>l(h,E,E,k,x))},g=o?ul()({onItem:(h,[E,S])=>S.is.parameter===$n?p(h,E,S):m(h,E,S),step:(h,E,S)=>S._tag==="Failure"?S:void 0}):void 0;return ek(function*(h,E){if(h===ce)return ce;if(!(typeof h==="object"&&h!==null&&!Array.isArray(h)))return yield*_(new Fe(n,h,E));i();let S=h,k={},I={ast:n,input:S,out:k,issues:void 0,options:E},x=E.errors==="all",w=E.onExcessProperty==="error",C=E.concurrency===void 0?1:ol(E.concurrency),T=o&&w?n.indexSignatures.map((v)=>yo(S,v.parameter,E)):void 0;if(w){let v=T?new Set(d):d;if(T)for(let U of T)for(let j of U)v.add(j);let O=Reflect.ownKeys(S);for(let U=0;U<O.length;U++){let j=O[U];if(!v.has(j)&&Object.prototype.propertyIsEnumerable.call(S,j)){let X=new ma(n,S[j],E),J=new Qe([j],X);if(x){if(I.issues)I.issues.push(J);else I.issues=[J];continue}else return yield*_(new tt(n,[J],h,E))}}}if(r){let v=C===1?jw(I,s):pD(I,s,{concurrency:C});if(v)yield*v}if(o&&C===1)for(let v=0;v<o;v++){let O=a[v],U=O.is.parameter===$n?p:m,j=T?.[v]??(O.is.parameter===$n?Object.keys(S):yo(S,O.is.parameter,E));for(let X=0;X<j.length;X++){let J=U(I,j[X],O);if(!qt(J))yield*J;else if(J._tag==="Failure")return yield*J}}else if(g){let v=Xt();for(let U=0;U<o;U++){let j=a[U],X=T?.[U]??(j.is.parameter===$n?Object.keys(S):yo(S,j.is.parameter,E));for(let J=0;J<X.length;J++)v.push([X[J],j])}let O=g(I,v,{concurrency:C});if(O)yield*O}if(I.issues)return yield*_(new tt(n,I.issues,h,E));return k})};if(o)return c();let f,u=(d,l,m)=>{let p=s[l];return A(or(m),(g)=>{let h=mg(d,p,g);if(h)return h;let E=()=>Rt(d.out),S=jw(d,s.slice(l+1));return S?Pt(S,E):E()})};return(d,l)=>{if(d===ce)return Cn;if(l.errors==="all"||l.onExcessProperty!==void 0||l.concurrency!==void 0&&ol(l.concurrency)!==1)return(f??=c())(d,l);if(!(typeof d==="object"&&d!==null&&!Array.isArray(d)))return _(new Fe(n,d,l));let m=i(),p=d,g={},h={ast:n,input:p,out:g,issues:void 0,options:l};try{for(let E=0;E<m.length;E++){let S=m[E],k=S.name,I=ki(p,k),x=I?p[k]:ce,w=S.parser(x,l);if(!qt(w))return u(h,E,w);if(w===Ce){if(I)q(g,k,x);continue}let C=mg(h,S,w);if(C)return C}}catch(E){return _n(E)}return Rt(g)}}_rebuild(e,t,n,r){let o=xa(this.propertySignatures,(a)=>{let i=e(a.type);return i===a.type?a:new Ag(a.name,i)}),s=xa(this.indexSignatures,(a)=>{let i=t(a.parameter),c=e(a.type);return i===a.parameter&&c===a.type?a:new Cg(i,c)});return o===this.propertySignatures&&s===this.indexSignatures&&n===this.checks&&r===this.encodingChecks?this:new bf(o,s,this.annotations,n,void 0,this.context,r)}flip(e){return this._rebuild(e,e,this.encodingChecks,this.checks)}recur(e,t=e){return this._rebuild(e,t,this.checks,this.encodingChecks)}getExpected(){if(this.propertySignatures.length===0&&this.indexSignatures.length===0)return"object | array";return"object"}};function mg(e,t,n){if(n._tag==="Failure")return sl(e,e.ast,t.name,n);if(n===Ce)return;let r=n[gn];if(r!==ce){q(e.out,t.name,r);return}if(delete e.out[t.name],!Mt(t.type)){let o=new Qe([t.name],new ot(t.type.context?.annotations));if(e.options.errors==="all"){if(e.issues)e.issues.push(o);else e.issues=[o];return}else return So(new tt(e.ast,[o],e.input,e.options))}}var xk={onItem(e,t){if(!ki(e.input,t.name))return t.parser(ce,e.options);let n=e.input[t.name];return q(e.out,t.name,n),t.parser(n,e.options)},step:mg},jw=fl()(xk),pD=ul()(xk);function vg(e,t){if(!e)return t;if(!t)return e;return[...e,...t]}function ll(e,t,n){return new bf(Reflect.ownKeys(e).map((r)=>new Ag(r,e[r].ast)),[],n,t)}function If(e){return e.ast}function Og(e,t=void 0){return new ar(!1,e.map((n)=>n.ast),[],void 0,t)}function pl(e,t,n){return new tn(e.map(If),t,void 0,n)}function yk(e,t){if(e.encoding||t.some((s)=>s.encoding))throw Error("StructWithRest does not support encodings");let{propertySignatures:n,indexSignatures:r,checks:o}=e;for(let s of t){for(let a of s.propertySignatures)if(n.some((i)=>i.name===a.name))throw Error(`Duplicate identifier: ${JSON.stringify(a.name)}. ts(2300)`);n=n.concat(s.propertySignatures),r=r.concat(s.indexSignatures),o=vg(o,s.checks)}return new bf(n,r,void 0,o)}function Sk(e,t){if(e.encoding)throw Error("TupleWithRest does not support encodings");return new ar(e.isMutable,e.elements,t,void 0,e.checks)}function Ek(e){if(e.encoding)throw Error("mutable does not support encodings");return new ar(!0,e.elements,e.rest,e.annotations,e.checks,void 0,e.context,e.encodingChecks)}var _g=ya((e)=>{while(!0){if(nk(e))return jo;let t=e.encoding;if(!t)return e.recur?.(_g,Q)??e;if(t.some((n)=>n.transformation._tag==="Middleware"&&n.transformation.decode!==Q))return jo;e=t[t.length-1].to}});function bk(e){switch(e._tag){case"Null":return["null"];case"Undefined":return["undefined"];case"String":case"TemplateLiteral":return["string"];case"Number":return["number"];case"Boolean":return["boolean"];case"Symbol":case"UniqueSymbol":return["symbol"];case"BigInt":return["bigint"];case"Arrays":return["array"];case"ObjectKeyword":return["object","array","function"];case"Objects":return e.propertySignatures.length||e.indexSignatures.length?["object"]:["string","number","boolean","symbol","bigint","object","array","function"];case"Enum":return Array.from(new Set(e.enums.map(([,t])=>typeof t)));case"Literal":return[typeof e.literal];case"Union":return Array.from(new Set(e.types.flatMap(bk)));default:return["null","undefined","string","number","boolean","symbol","bigint","object","array","function"]}}function ks(e){switch(e._tag){default:return[];case"Declaration":{let t=e.annotations?.[uf];return Array.isArray(t)?t:[]}case"Objects":return e.propertySignatures.flatMap((t)=>{let n=t.type;if(!Mt(n)){if(Ti(n))return[{key:t.name,literal:n.literal}];if(dg(n))return[{key:t.name,literal:n.symbol}]}return[]});case"Arrays":return e.elements.flatMap((t,n)=>{if(!Mt(t)){if(Ti(t))return[{key:n,literal:t.literal}];if(dg(t))return[{key:n,literal:t.symbol}]}return[]});case"Union":{if(e.types.length===0)return[];let t=e.types.map((n)=>ks(_g(n)));return t[0].filter((n)=>t.every((r)=>r.some((o)=>o.key===n.key&&o.literal===n.literal)))}case"Suspend":return ks(e.thunk())}}var Ww=new WeakMap,nl=Object.freeze([]),Jw=(e)=>e===null?"null":Array.isArray(e)?"array":typeof e,ki=(e,t)=>t==="__proto__"?Object.hasOwn(e,t):(t in e);function wf(e){let t=Ww.get(e);if(t)return t;let n,r=0,o,s,a=!0,i=[];for(let u=0;u<e.length;u++){let d=e[u],l=_g(d);if(VF(l))continue;if(Ti(l)||dg(l)){s??=new Map;let p=Ti(l)?l.literal:l.symbol;i[u]=p;let g=s.get(p);if(!g)s.set(p,g=[]);g.push(u)}else a=!1;let m=ks(l);if(m.length){n??=new Map,r++;for(let{key:p,literal:g}of m){let h=n.get(p);if(!h)n.set(p,h=[new Map,new Set]);h[1].add(u);let E=h[0].get(g);if(!E)h[0].set(g,E=new Set);E.add(u)}}else{o??={};let p=bk(l);for(let g of p)(o[g]??=[]).push(u)}}let c={},f=(u)=>c[u]??=Object.freeze(o?.[u]??nl);if(a&&s)s.forEach(Object.freeze),t=(u)=>s.get(u)??nl;else if(n?.size===1&&!o){let[u,[d]]=n.entries().next().value,l=new Map;for(let[p,g]of d)l.set(p,Object.freeze(Array.from(g)));let m=Object.freeze(e.map((p,g)=>g));t=(p,g)=>{if(rl(p)){let h=ki(p,u)?p[u]:void 0;if(h!==void 0)return l.get(h)??nl;if(g)return m}return nl}}else if(n){let u;for(let d of n)if((!u||d[1][0].size>u[1][0].size)&&d[1][1].size===r)u=d;t=(d,l)=>{let m=Jw(d);if(!rl(d))return f(m);let p=new Set(o?.[m]),g;if(u){let[h,[E]]=u,S=ki(d,h),k=S?d[h]:void 0;if(S&&(!l||k!==void 0)){let I=E.get(k);if(!I)return f(m);for(let x of I)p.add(x);g=h}}if(g===void 0)for(let[h,[E,S]]of n){let k=ki(d,h),I=k?d[h]:void 0;if(k&&(!l||I!==void 0)){let x=E.get(I);if(x)for(let w of x)p.add(w)}else if(l)for(let x of S)p.add(x)}for(let[h,[E,S]]of n){if(h===g)continue;let k=ki(d,h),I=k?d[h]:void 0;if(k&&(!l||I!==void 0)){let x=E.get(I);for(let w of p)if(S.has(w)&&!x?.has(w))p.delete(w)}}return Array.from(p).sort((h,E)=>h-E)}}else t=(u)=>{let d=f(Jw(u));return s?d.filter((l)=>i[l]===void 0||i[l]===u):d};return Ww.set(e,t),t}var tn=class extends at{_tag="Union";types;options;encodingChecks;constructor(e,t,n,r,o,s,a){super(n,r,o,s);this.types=e,this.options=t,this.encodingChecks=a}getParser(e,t){let n=this,r=t!==void 0,o=[],s=(i)=>o[i]??=e(n.types[i]),a;return(i,c)=>{if(i===ce)return Cn;let f=(a??=wf(n.types))(i,r);if(f.length===0)return _(new gf(n,[],i,c));if(f.length===1){let u=s(f[0])(i,c);if(u._tag==="Success")return u;return qt(u)?Ik(n,u.cause,i,c):mD(n,u,i,c)}return hD(n,s,f,i,c)}}_rebuild(e,t,n){let r=xa(this.types,e);return r===this.types&&t===this.checks&&n===this.encodingChecks?this:new tn(r,this.options,this.annotations,t,void 0,this.context,n)}recur(e){return this._rebuild(e,this.checks,this.encodingChecks)}flip(e){return this._rebuild(e,this.encodingChecks,this.checks)}matchPart(e,t){for(let n of this.types){let r=n.matchPart(e,t);if(r!==void 0)return r}return}getExpected(e){let t=this.annotations?.expected;if(typeof t==="string")return t;if(this.types.length===0)return"never";let n=this.types.map((r)=>{let o=En(r);switch(o._tag){case"Arrays":{let s=o.elements.filter(Ti);if(s.length>0)return`${Gw(o.isMutable)}[ ${s.map((a)=>e(a)+Kw(a.context?.isOptional)).join(", ")}, ... ]`;break}case"Objects":{let s=o.propertySignatures.filter((a)=>Ti(a.type));if(s.length>0)return`{ ${s.map((a)=>`${Gw(a.type.context?.isMutable)}${Sa(a.name)}${Kw(a.type.context?.isOptional)}: ${e(a.type)}`).join(", ")}, ... }`;break}}return e(o)});return Array.from(new Set(n)).join(" | ")}};function Ik(e,t,n,r){let o=xf(t);if(!o)return en(t);return So(new gf(e,[o],n,r))}function mD(e,t,n,r){return De(t,(o)=>Ik(e,o,n,r))}function hD(e,t,n,r,o){let s={ast:e,parser:t,input:r,out:void 0,successes:e.options?.mode==="oneOf"?[]:void 0,issues:void 0,options:o},a=xD(s,n);if(!a){if(s.out)return s.out;return _(new gf(e,s.issues??[],r,o))}return gD(a,s)}function gD(e,t){return Pt(e,(n)=>{if(t.out===Ce)return b(t.input);if(t.out)return t.out;return _(new gf(t.ast,t.issues??[],t.input,t.options))})}var xD=fl()({onItem(e,t){return e.parser(t)(e.input,e.options)},step(e,t,n){if(n._tag==="Failure"){let r=xf(n.cause);if(r===void 0)return n;if(e.issues)e.issues.push(r);else e.issues=[r]}else{if(e.out&&e.successes)return e.successes.push(e.ast.types[t]),So(new UI(e.ast,e.successes,e.input,e.options));if(e.out=n,e.successes)e.successes.push(e.ast.types[t]);else return Ye}}}),wk=new tn([new yn("Infinity"),new yn("-Infinity"),new yn("NaN")]);function Gw(e){return e?"":"readonly "}function Kw(e){return e?"?":""}var Rg=class extends at{_tag="Suspend";thunk;constructor(e,t,n,r,o){if(n)throw Error("Cannot add checks to Suspend");super(t,void 0,r,o);let s;this.thunk=()=>s??=e()}getParser(e){let t;return(n,r)=>(t??=e(this.thunk()))(n,r)}recur(e){return new Rg(()=>e(this.thunk()),this.annotations,void 0,void 0,this.context)}getExpected(e){return e(this.thunk())}},al=class extends Ei{_tag="Filter";run;annotations;aborted;constructor(e,t=void 0,n=!1){super();this.run=e,this.annotations=t,this.aborted=n}annotate(e){return new al(this.run,{...this.annotations,...e},this.aborted)}abort(){return new al(this.run,this.annotations,!0)}and(e,t){return new ga([this,e],t)}},ga=class extends Ei{_tag="FilterGroup";checks;annotations;constructor(e,t=void 0){super();this.checks=e,this.annotations=t}annotate(e){return new ga(this.checks,{...this.annotations,...e})}and(e,t){return new ga([this,e],t)}};function ml(e,t,n=!1){return new al((r,o,s)=>DI(o,e(r,o,s),r,s),t,n)}function hl(e,t){return new al((n,r,o)=>e(n)?void 0:new te(void 0,n,o),t,!0)}function Pg(e){return ml((t)=>globalThis.Number.isFinite(t),{expected:"a finite number",representation:{id:"effect/schema/isFinite",payload:null},toJsonSchema:()=>({type:"number"}),toCode:()=>({runtime:"Schema.isFinite()"}),arbitraryConstraint:{number:"finite"},...e})}var Mg=Eo(Tg,[Pg()]),yD=new Xe(new tn([Mg,wk]),new be(Jd(),se((e)=>globalThis.Number.isFinite(e)?e:globalThis.String(e))));function kf(e,t){let n=new globalThis.RegExp(e),r={source:n.source,flags:n.flags};return ml((o)=>(n.lastIndex=0,n.test(o)),{expected:`a string matching the RegExp ${r.source}`,representation:{id:"effect/schema/isPattern",payload:r},toJsonSchema:()=>[{},!0],arbitraryConstraint:{patterns:[r]},...t})}var hg=new WeakMap;function Tf(e,t){let n=Object.assign(Object.create(Object.getPrototypeOf(e)),e,t);if(Reflect.ownKeys(t).every((r)=>r==="context"||r==="encoding"))hg.set(n,vi(e));return n}function vi(e){let t=hg.get(e);if(t!==void 0)return t;if(e.encoding===void 0)return e;let n=Object.assign(Object.create(Object.getPrototypeOf(e)),e,{encoding:void 0});return hg.set(e,n),n}function Pe(e,t){return e.encoding===t?e:Tf(e,{encoding:t})}function Ea(e,t){if(e.context===t)return e;let n=vi(e);if(n.context===t&&n.encoding===e.encoding)return n;return Tf(e,{context:t})}function Oi(e){return e.encoding?Oi(e.encoding[e.encoding.length-1].to):e}function Ur(e,t){if(e.checks){let n=e.checks[e.checks.length-1];return kk(e,Md(e.checks.slice(0,-1),n.annotate(t)))}return Tf(e,{annotations:{...e.annotations,...t}})}function kk(e,t){if(e._tag==="Suspend"&&t)throw Error("Cannot add checks to Suspend");if(e.checks===t)return e;return Tf(e,{checks:t})}function Eo(e,t){return kk(e,vg(e.checks,t))}function vs(e,t){let n=t(e.to);return n===e.to?e:new Xe(n,e.transformation)}function Tk(e,t){let n=e,r=n[n.length-1],o=vs(r,t);return o===r?e:Md(e.slice(0,e.length-1),o)}function gl(e){return(t)=>t.encoding?Pe(t,Tk(t.encoding,e)):t}function _i(e,t){return gl((n)=>Ea(n,t))(e)}function Wo(e,t){function n(r){if(r.encoding){let o=r.encoding[r.encoding.length-1];return t?.stopAt?.(o)?r:Pe(r,Tk(r.encoding,n))}return e(r)}return ya(n)}function Ak(e,t){return Ug(e,t,Ve(e))}function Ck(e,t){return Ug(En(e),t,e)}function Ug(e,t,n){let r=new Xe(e,t);return Pe(n,n.encoding?[...n.encoding,r]:[r])}function xa(e,t){let n;for(let r=0;r<e.length;r++){let o=e[r],s=t(o);if(n)n[r]=s;else if(s!==o){n=Array(e.length);for(let a=0;a<r;a++)n[a]=e[a];n[r]=s}}return n??e}function Ri(e,t){let n=e.context?new sr(e.context.isOptional,e.context.isMutable,e.context.constructorDefault,{...e.context.annotations,...t}):new sr(!1,!1,void 0,t);return Ea(e,n)}var ba=ya((e)=>{let t=e.context?e.context.isOptional===!1?new sr(!0,e.context.isMutable,e.context.constructorDefault,e.context.annotations):e.context:new sr(!0,!1);return SD(Ea(e,t))}),SD=gl(ba),vk=Ln((e)=>ba(new tn([e,Ig]))),Fg=ya((e)=>{let t=e.context?e.context.isMutable===!1?new sr(e.context.isOptional,!0,e.context.constructorDefault,e.context.annotations):e.context:new sr(!1,!0);return ED(Ea(e,t))}),ED=gl(Fg);function Ok(e,t){let n=e.context?new sr(e.context.isOptional,e.context.isMutable,t,e.context.annotations):new sr(!1,!1,t);return Ea(e,n)}function Pi(e,t,n){return Ug(e,n,t)}function bD(e){let t=[],n=[];function r(o){switch(o._tag){case"Literal":if(il(o.literal)&&!t.includes(o.literal))t.push(o.literal);return;case"UniqueSymbol":if(!t.includes(o.symbol))t.push(o.symbol);return;case"Never":return;case"Union":for(let s=0;s<o.types.length;s++)r(o.types[s]);return;default:n.push(o)}}return r(e),{literals:t,parameters:n}}function _k(e,t){let{literals:n,parameters:r}=bD(e);return new bf(n.map((o)=>new Ag(o,t)),r.map((o)=>new Cg(o,t)))}function Mt(e){return e.context?.isOptional??!1}function Rk(e){return e.context?.isMutable??!1}function Pk(e){return e.annotations?.[An]===!0||e._tag==="FilterGroup"&&e.checks.every(Pk)}function ID(e){function t(r){if(Pk(r))return[r];return r._tag==="FilterGroup"?r.checks.flatMap(t):[]}let n=e.flatMap(t);return Sn(n)?n:void 0}function wD(e){let t=!0;function n(r){if(t=t&&!r.encoding&&!nk(r),t&&"recur"in r)r.recur(n);return r}if("recur"in e)e.recur(n);return t}var Ve=ya((e)=>{let t=vi(e);if(t!==e){let r=Ve(t);return r===t&&e.encoding===void 0?e:Ea(r,e.context)}let n="recur"in e?e.recur(Ve):e;if("encodingChecks"in n&&n.encodingChecks){let r=wD(e)?n.encodingChecks:Eg(n)||ZF(n)||Ci(n)&&n.typeParameters.length>0?ID(n.encodingChecks):void 0;return Tf(n,{encodingChecks:void 0,checks:vg(n.checks,r)})}return n}),En=ya((e)=>Ve(qn(e)));function kD(e,t){let n=t,r=n.length,o=n[r-1],s=[new Xe(qn(Pe(e,void 0)),n[0].transformation.flip())];for(let i=1;i<r;i++)s.unshift(new Xe(qn(n[i-1].to),n[i].transformation.flip()));let a=qn(o.to);if(a.encoding)return Pe(a,[...a.encoding,...s]);else return Pe(a,s)}var qn=Ln((e)=>{if(e.encoding)return kD(e,e.encoding);let t=vi(e);if(t!==e){let n=qn(t);return n===t?e:Ea(n,e.context)}return"flip"in e?e.flip(qn):("recur"in e)?e.recur(qn):e});function Mk(e){switch(e._tag){case"Undefined":return!0;case"Union":return e.types.some(Mk);default:return!1}}function xl(e,t){let n=t===0?Ce:Rt(t);return(r,o)=>{if(r===ce)return Cn;if(r===t)return n;return _(new Fe(e,r,o))}}function Fr(e,t){return(n,r)=>{if(n===ce)return Cn;if(t(n))return Ce;return _(new Fe(e,n,r))}}function Uk(e,t,n){let{encodedParts:r,literals:o}=e,s=t.length;for(let f=0;f<o.length;f++){let u=o[f];if(u&&!t.includes(u))return}if(e.suffixLengths[0]>s)return;let a=Array(r.length),i;function c(f,u){if(f===r.length)return u===s;if(i?.has(f*(s+1)+u))return!1;let d=r[f];if(f===r.length-1){let l=t.slice(u);if(d.matchPart(l,n)!==void 0)return a[f]=l,!0}else if(d._tag==="Literal"){let l=o[f];if(t.startsWith(l,u)&&c(f+1,u+l.length))return a[f]=l,!0}else{let l=s-e.suffixLengths[f+1],m=o[f+1],p=m===void 0?l:t.lastIndexOf(m,l);while(p>=u){let g=t.slice(u,p);if(d.matchPart(g,n)!==void 0&&c(f+1,p))return a[f]=g,!0;if(p===0)break;p=m===void 0?p-1:t.lastIndexOf(m,p-1)}}return i??=new Set,i.add(f*(s+1)+u),!1}return c(0,0)?a:void 0}var Dg=Wo((e)=>{switch(e._tag){default:return e;case"Number":return e.toCodecStringTree();case"Union":return e.recur(Dg)}}),yl=Wo((e)=>{switch(e._tag){default:return e;case"Symbol":case"UniqueSymbol":return e.toCodecStringTree();case"Union":return e.recur(yl)}}),Ng=Wo((e)=>{switch(e._tag){default:return e;case"Number":case"Literal":case"BigInt":return e.toCodecStringTree();case"Union":return e.recur(Ng)}}),Fk="[\\s\\S]*?",gg=new globalThis.RegExp(`^${dl}$`),TD=new globalThis.RegExp(`^(?:${dl}|Infinity|-Infinity|NaN)$`);function Bg(e){return kf(gg,{expected:"a string representing a finite number",representation:{id:"effect/schema/isStringFinite",payload:null},toJsonSchema:()=>({pattern:gg.source}),...e})}var Dk=Eo($n,[Bg()]),AD=new Xe(Dk,wi),CD=new Xe(new tn([Dk,wk]),wi),vD="-?\\d+",xg=new globalThis.RegExp(`^${vD}$`);function Lg(e){return kf(xg,{expected:"a string representing a bigint",representation:{id:"effect/schema/isStringBigInt",payload:null},toJsonSchema:()=>({pattern:xg.source}),...e})}var zg=Eo($n,[Lg({expected:"a string representing a bigint"})]),OD=new Xe(zg,el),_D="Symbol\\(([\\s\\S]*)\\)",yg=new globalThis.RegExp(`^${_D}$`),RD=Eo($n,[$g()]),Nk=new Xe(RD,new be(se((e)=>globalThis.Symbol.for(yg.exec(e)[1])),$t((e,t)=>{if(globalThis.Symbol.keyFor(e)!==void 0)return b(globalThis.String(e));return _(new hf({message:"cannot serialize to string, Symbol is not registered"},e,t))})));function $g(e){return kf(yg,{expected:"a string representing a symbol",representation:{id:"effect/schema/isStringSymbol",payload:null},toJsonSchema:()=>({pattern:yg.source}),...e})}function Dr(e,t,n,r,o){for(let s=0;s<e.length;s++){let a=e[s];if(a._tag==="FilterGroup"){if(n=Dr(a.checks,t,n,r,o),n&&(o.errors!=="all"||n[n.length-1].filter.aborted))return n}else{let i=a.run(t,r,o);if(i){let c=new PI(a,i,t,o);if(n)n.push(c);else n=[c];if(o.errors!=="all"||a.aborted)return n}}}return n}function Bk(e,t){let n=Dr(e,t,void 0,jo,{errors:"all"});if(n){let r=new tt(jo,n);return ge(r)}return ue(t)}function Lk(e){if(!Ci(e))return;let t=e.annotations?.[Dd];return On(t)?t(e.typeParameters):void 0}function PD(e){return e===null||typeof e==="string"||typeof e==="boolean"||typeof e==="number"&&globalThis.Number.isFinite(e)}function MD(e){return e===void 0||typeof e==="string"}function zk(e,t){let n=new WeakMap,r=[];e:while(!0){if(typeof e!=="object"||e===null){if(!t(e))return!1}else{let o=e,s=n.get(o);if(s===!1)return!1;if(s===void 0){let a=Array.isArray(o);if(!a){let i=Object.getPrototypeOf(o);if(i!==null&&i!==Object.prototype&&Object.getPrototypeOf(i)!==null)return!1}n.set(o,!1),r.push({value:o,keys:a?o.length:Object.keys(o),index:0})}}while(r.length>0){let o=r[r.length-1],s=o.keys;if(typeof s==="number"){if(o.index<s){e=o.value[o.index++];continue e}}else if(o.index<s.length){e=o.value[s[o.index++]];continue e}n.set(o.value,!0),r.pop()}return!0}}function Mi(e){return zk(e,PD)}var Ai=new Cs([],()=>(e,t,n)=>Mi(e)?Ce:_(new Fe(t,e,n)),{representation:{id:"effect/schema/Json",payload:null},expected:"JSON value",toCodecJson:()=>{return},toCodecStringTree:()=>Hg}),$k=Ur(Ai,{representation:{id:"effect/schema/MutableJson",payload:null}}),qg=new Xe(Ai,Ii()),qk=new Xe(new tn([new ar(!1,[],[Ai]),new bf([],[new Cg($n,Ai)])]),Ii());function UD(e){return zk(e,MD)}var FD=new Cs([],()=>(e,t,n)=>UD(e)?Ce:_(new Fe(t,e,n)),{expected:"StringTree",toCodecStringTree:()=>{return}}),Hg=new Xe(FD,Ii());var Sl=(e,t,n)=>e===Ce?n(t):Pt(e,n);function jk(e){if(e._tag==="Middleware")return(n,r,o)=>{let s=n===Ce?e.decode(Rt(lf(r)),o):e.decode(qd(n,lf),o);return Hk(s)};let t=e.decode;switch(t._tag){case"Passthrough":return(n,r)=>n===Ce?Rt(r):n;case"Transform":{let n=(r)=>r===ce?Cn:Rt(t.transform(r));return(r,o)=>Sl(r,o,n)}case"TransformOptional":{let n=(r)=>Vh(t.transform(lf(r)));return(r,o)=>Sl(r,o,n)}case"TransformEffect":return(n,r,o)=>Sl(n,r,(s)=>s===ce?Cn:t.transform(s,o));case"TransformOptionalEffect":return(n,r,o)=>Sl(n,r,(s)=>Hk(t.transform(lf(s),o)))}}var Hk=(e)=>Pt(e,Vh),Wk=(e,t,n,r)=>De(r,(o)=>Os(()=>Ts(o,(s)=>new MI(e,s,t,n))));function DD(e,t){let n=jk(e.link.transformation),r;return(o,s)=>{if(o===ce)return Cn;if(e.isConstructed(o))return Ce;let a=(r??=t(e.link.to))(o,s);return n(a,o,s)}}function ND(e,t){let n=e.context.constructorDefault;return(r,o)=>{if(r!==ce&&r!==void 0)return t(r,o);let s=n;if(qt(s)&&s._tag==="Success"){let a=t(s[gn],o);return a===Ce?s:a}return Pt(Wk(e,r,o,s),(a)=>{let i=t(a,o);return i===Ce?Rt(a):i})}}function jg(e,t){let n=t(e);return e.context?.constructorDefault===void 0?n:ND(e,n)}function Af(e,t,n,r,o){if(e._tag==="Declaration")for(let p of e.typeParameters)t(p);let s=n?Lk(e):void 0,a=s?DD(s,t):r??e.getParser(t,n),i=e.checks,c=e.encoding,f=c?.map((p)=>jk(p.transformation)),u=e.encodingChecks;if(!c&&!i&&!u)return a;let d,l=(p,g)=>{let h=a(p,g);if(u&&!g.disableChecks)if(qt(h)){if(h._tag==="Success"){let E=h===Ce?p:h[gn];if(p!==ce&&E!==ce){let S=Dr(u,p,void 0,e,g);if(S)h=_(new tt(e,S,p,g))}}}else h=A(h,(E)=>{if(p!==ce&&E!==ce){let S=Dr(u,p,void 0,e,g);if(S)return _(new tt(e,S,p,g))}return b(E)});if(i&&!g.disableChecks)if(qt(h)){if(h._tag==="Success"){let E=h===Ce?p:h[gn];if(E===ce)return h;let S=Dr(i,E,void 0,e,g);if(S)h=_(new tt(e,S,E,g))}}else h=A(h,(E)=>{if(E!==ce){let S=Dr(i,E,void 0,e,g);if(S)return _(new tt(e,S,E,g))}return b(E)});return h},m=o===void 0?l:o(l);if(!c)return m;return(p,g)=>{let h=d??=c.map((k)=>t(k.to)),E=p,S=h[h.length-1](p,g);for(let k=c.length-1;k>=0;k--)if(S=f[k](S,E,g),k!==0){let I=h[k-1];if(S._tag==="Success")E=S[gn],S=I(E,g);else S=Pt(S,(x)=>{let w=I(x,g);return w===Ce?Rt(x):w})}if(S._tag==="Success"){let k=S[gn],I=m(k,g);return I===Ce?S:I}return S=Wk(e,p,g,S),Pt(S,(k)=>{let I=m(k,g);return I===Ce?Rt(k):I})}}var bl=Symbol(),Jk=new WeakMap,Gk,Ui=!1;var LD=(e)=>Ui?El(Hn,e,"parser"):Hn(e).parser,Kk=(e)=>Ui?El(Hn,e,"makeEffect"):Hn(e).makeEffect,zD=(e)=>jg(e,Kk);class Wg{ast;constructor(e){this.ast=e}get decodeEffect(){return this.cachedDecodeEffect??=Af(this.ast,LD)}get parser(){return this.decodeEffect}get makeEffect(){return this.cachedMakeEffect??=Af(this.ast,Kk,zD)}}class Vk extends Wg{compiled;resolve;constructor(e,t,n){super(e);this.compiled=t,this.resolve=n}save(e,t){return Object.defineProperty(this,e,{value:t}),t}operation(e){let t=this.compiled;return typeof t==="function"?t(this.ast,this.resolve,e):t?.[e]}get is(){return this.save("is",this.operation("is"))}get decode(){return this.save("decode",this.operation("decode"))}get make(){return this.save("make",this.operation("make"))}get decodeEffect(){return this.save("decodeEffect",this.operation("decodeEffect")??Af(this.ast,(e)=>El(this.resolve,e,"parser")))}get parser(){let e=this.decode;return e===void 0?this.decodeEffect:this.save("parser",$D(e,()=>this.decodeEffect))}get makeEffect(){let e=this.operation("makeEffect");if(e!==void 0)return this.save("makeEffect",e);let t=(n)=>El(this.resolve,n,"makeEffect");return this.save("makeEffect",Af(this.ast,t,(n)=>jg(n,t)))}}function $D(e,t){let n;return(r,o)=>{if(r!==ce)try{let s=e(r,o);if(s!==bl)return s===r?Ce:Rt(s)}catch(s){return _n(s)}return(n??=t())(r,o)}}function El(e,t,n){let r=e(t);if(r.compiled===void 0||Object.hasOwn(r,n))return r[n];let o;return(s,a)=>(o??=r[n])(s,a)}function Hn(e){let t=Jk.get(e);if(t!==void 0)return t;let n=Gk===void 0?new Wg(e):new Vk(e,Gk(e,Hn),Hn);return Jk.set(e,n),n}function Kg(e){let t=e.ast,n;return(r,o)=>(n??=tx(ZD,Ve(t)))(r,o?.disableChecks?o?.parseOptions?{...o.parseOptions,disableChecks:!0}:{disableChecks:!0}:o?.parseOptions)}function wl(e){let t=Kg(e);return(n,r)=>{let o=Jo(t(n,r));if($e(o))return oe(o.value);return zn(o.cause,"Option adapter can only return none for schema issues"),ne()}}function kl(e){return KD(Ve(e.ast))}function Vg(e){return Cf(e.ast)}function HD(e){if(!Ui){let o=Di(Cl(e));return(s)=>{let a=o(s,jt);if($e(a))return!0;return zn(a.cause,"Type guard adapter can only return false for schema issues"),!1}}let t=Hn(e),n=t.is;if(n!==void 0)return(o)=>{try{return n(o,jt)}catch(s){return zn(Fi(s),"Type guard adapter can only return false for schema issues"),!1}};let r=t.parser;return(o)=>{let s=Jo(ex(r(o,jt),o));if($e(s))return!0;return zn(s.cause,"Type guard adapter can only return false for schema issues"),!1}}function Cf(e){let t=Ve(e),n=(r)=>(n=HD(t),n(r));return(r)=>n(r)}function Zk(e){let t=Cl(e);return(n,r)=>{let o=Jo(t(n,r));if($e(o))return;return zn(o.cause,"Issue adapter can only return schema issues")}}function Qk(e,t){let n=Ve(e.ast),r=Hn(n).parser(t,jt),o=Jo(ex(r,t));if(bo(o)){let s=zn(o.cause,"Assertion adapter can only throw schema issues");throw Error("Schema validation failed",{cause:s})}}function qe(e,t){let n=Cl(e.ast);return t===void 0?n:(r,o)=>n(r,Xg(t,o))}var Zg=qe;function Yk(e,t){return Di(qe(e,t))}function Qg(e,t){return s0(qe(e,t))}var Xk=Qg;function e0(e,t){return a0(qe(e,t))}function jD(e,t){return Ui?i0(e.ast,t):nx(qe(e,t))}var Tl=jD;function Ia(e,t){let n=Cl(qn(e.ast));return t===void 0?n:(r,o)=>n(r,Xg(t,o))}var t0=Ia;function n0(e,t){return Di(Ia(e,t))}function Yg(e,t){return s0(Ia(e,t))}var r0=Yg;function o0(e,t){return a0(Ia(e,t))}function WD(e,t){return Ui?i0(qn(e.ast),t):nx(Ia(e,t))}var Al=WD,Xg=(e,t)=>t?{...e,...t}:e,Il=(e)=>{if(e===ce)return _(new te);return b(e)};function Cl(e){return tx(VD,e)}function ex(e,t){if(e===Ce)return b(t);if(!qt(e))return Pt(e,Il);return e[gn]===ce?Il(ce):e}function tx(e,t){let n;return(r,o)=>{let s=(n??=e(t))(r,o??jt);if(s===Ce)return b(r);if(!qt(s))return Pt(s,Il);return s[gn]===ce?Il(ce):s}}function Di(e){return(t,n)=>Jo(e(t,n))}function s0(e){let t=Di(e);return(n,r)=>{let o=t(n,r);if($e(o))return oe(o.value);return zn(o.cause,"Option adapter can only return none for schema issues"),ne()}}function a0(e){let t=Di(e);return(n,r)=>{let o=t(n,r);if($e(o))return ue(o.value);return ge(zn(o.cause,"Result adapter can only return schema issues"))}}function i0(e,t){let n;return(r,o)=>(n??=JD(Hn(e),t))(r,o)}function JD(e,t){let n=e.decode,r,o=n===void 0?(s,a=jt)=>(r??=Jg(e))(s,a):(s,a=jt)=>{if(s===ce)return(r??=Jg(e))(s,a);let i;try{i=n(s,a)}catch(c){throw zn(Fi(c),"Sync adapter can only throw schema issues"),c}if(i!==bl)return i;return(r??=Jg(e))(s,a)};return t===void 0?o:(s,a)=>o(s,Xg(t,a))}function Jg(e){return nx(tx(()=>e.decodeEffect,e.ast))}function nx(e){let t=Di(e);return(n,r)=>{let o=t(n,r);if($e(o))return o.value;let s=zn(o.cause,"Sync adapter can only throw schema issues");throw Error("Schema validation failed",{cause:s})}}function GD(e,t){let n=Jo(e);if($e(n))return n.value;let r=zn(n.cause,t);throw Error("Schema validation failed",{cause:r})}function KD(e){let t,n;return(r,o)=>{t??=Hn(e);let s=o?.disableChecks?o.parseOptions?{...o.parseOptions,disableChecks:!0}:{disableChecks:!0}:o?.parseOptions??jt,a=t.make;if(a!==void 0&&r!==ce){let c;try{c=a(r,s)}catch(f){throw zn(Fi(f),"Constructor adapter can only throw schema issues"),f}if(c!==bl&&c!==ce)return c}let i=(n??=t.makeEffect)(r,s);return GD(ex(i,r),"Constructor adapter can only throw schema issues")}}var VD=(e)=>Hn(e).parser,ZD=(e)=>Hn(e).makeEffect;var vl="~effect/Schema/Schema",c0=Symbol(),QD={[vl]:vl,get make(){let e=kl(this);return Object.defineProperty(this,"make",{value:e,enumerable:!0}),e},get makeEffect(){let e=Kg(this);return Object.defineProperty(this,"makeEffect",{value:e,enumerable:!0}),e},get makeOption(){let e=wl(this);return Object.defineProperty(this,"makeOption",{value:e,enumerable:!0}),e},pipe(){return de(this,arguments)},annotate(e){return this.rebuild(Ur(this.ast,e))},annotateKey(e){return this.rebuild(Ri(this.ast,e))},check(...e){return this.rebuild(Eo(this.ast,e))},rebuild(e){return Nr(e,this[c0])}};function Nr(e,t){function n(){}let r=Object.setPrototypeOf(n,QD);if(t&&(Object.hasOwn(t,"name")||Object.hasOwn(t,"length")||Object.hasOwn(t,"__proto__")))Object.defineProperties(r,Object.getOwnPropertyDescriptors({...t}));else Object.assign(r,t);return r[c0]=t,r.ast=e,r}function rx(e){return e.replace(/~/g,"~0").replace(/\//g,"~1")}function vf(e){return e.replace(/~1/g,"/").replace(/~0/g,"~")}function ox(e){return encodeURI(rx(e)).replace(/#/g,"%23")}function sx(e){if(e.length===0||e==="#")return"";if(!e.startsWith("#"))return;let t=e.slice(1);try{if(encodeURI(t).replace(/%25/g,"%").replace(/#/g,"%23")!==t)return;let n=decodeURIComponent(t);return n.startsWith("/")&&!/~(?:[^01]|$)/.test(n)?n:void 0}catch{return}}function u0(e){let t=sx(e);return t===void 0?void 0:t.length===0?[]:t.slice(1).split("/").map(vf)}function d0(e){return e.reduce((t,n)=>`${t}/${ox(n)}`,"#")}var YD="http://json-schema.org/draft-07/schema#",l0="https://json-schema.org/draft/2020-12/schema";function p0(e,t){return e===t||e===(t.endsWith("#")?t.slice(0,-1):`${t}#`)}function g0(e){return{dialect:"draft-07",...rN(e,pN)}}function XD(e,t){return n(e,!1,!0);function n(r,o,s=!1){if(!st(r))return r;let a=o||!s&&S0(r.$id),i={};for(let c of Object.keys(r)){let f=r[c],u=f;switch(c){case"$defs":case"properties":case"patternProperties":case"dependentSchemas":u=ix(f,(d)=>n(d,a))??f;break;case"allOf":case"anyOf":case"oneOf":case"prefixItems":u=Array.isArray(f)?f.map((d)=>n(d,a)):f;break;case"not":case"additionalProperties":case"propertyNames":case"unevaluatedProperties":case"items":case"contains":case"unevaluatedItems":case"if":case"then":case"else":case"contentSchema":u=n(f,a)}q(i,c,u)}return t(i,a),i}}function x0(e,t){return XD(e,(n)=>{eN(n,t)})}function eN(e,t){if(typeof e.$ref==="string")q(e,"$ref",t(e.$ref,"$ref"));if(typeof e.$dynamicRef==="string")q(e,"$dynamicRef",t(e.$dynamicRef,"$dynamicRef"))}function ix(e,t){if(!st(e))return;let n={};for(let r of Object.keys(e))q(n,r,t(e[r],r));return n}function tN(e,t,n){let r=new Map,o=[],s=ax;function a(l,m=[],p=[]){if(m.length===0&&t?.trackIds){let g=st(l)?u(l):void 0;s=m0(g,ax)??ax}return f(l,m,p,{sourceRoot:[],targetRoot:[],uri:s})}function i(){for(let[l,m,p]of o){let g=m,h=y0(m,p);if(h!==void 0){let E=u0(h.hash);if(h.hash="",E!==void 0){let S=r.get(h0(h.href,E));if(S!==void 0)g=nN(m,S)}}q(l,"$ref",g)}}let c=n(a);return i(),c;function f(l,m,p,g){if(typeof l==="boolean")return d(m,p,g),t?.booleanAdapter?.(l)??l;if(!st(l))return l;let h=g,E=u(l);if(m.length>0&&t?.trackIds&&S0(E)){let I=m0(E,g.uri);if(I!==void 0)h={parent:g,sourceRoot:m,targetRoot:p,uri:I}}d(m,p,h);let S=h.uri,k={isDocumentRoot:m.length===0,schema(I,x,w=x){return f(I,[...m,x],[...p,w],h)},schemaAt(I,x,w){return f(I,[...m,...x],[...p,...w],h)},schemaArray(I,x,w=x){return Array.isArray(I)?I.map((C,T)=>f(C,[...m,x,String(T)],[...p,w,String(T)],h)):I},schemaMap(I,x,w=x){if(!st(I))return I;return ix(I,(C,T)=>f(C,[...m,x,T],[...p,w,T],h))},reference(I,x){if(typeof x==="string")o.push([I,x,S]);else q(I,"$ref",x)}};return e(l,k)}function u(l){return t?.ignoreRefSiblings===!0&&typeof l.$ref==="string"?void 0:l.$id}function d(l,m,p){if(p.parent!==void 0)d(l,m,p.parent);r.set(h0(p.uri,l.slice(p.sourceRoot.length)),m.slice(p.targetRoot.length))}}var ax="https://effect.invalid/.json-schema/";function y0(e,t){return URL.canParse(e,t)?new URL(e,t):void 0}function m0(e,t){if(typeof e!=="string")return;let n=y0(e,t);if(n===void 0)return;return n.hash="",n.href}function nN(e,t){let n=e.indexOf("#");if(n===-1&&t.length===0)return e;return`${n===-1?e:e.slice(0,n)}${d0(t)}`}function h0(e,t){return`${e}\x00${JSON.stringify(t)}`}function S0(e){return typeof e==="string"&&e.length>0&&e[0]!=="#"}function rN(e,t,n){return tN(t,{...n,trackIds:!0},(r)=>({schema:r(e.schema),definitions:ix(e.definitions,(o,s)=>r(o,["$defs",s],["definitions",s]))}))}var oN=new Set(["properties","patternProperties"]),sN=new Set(["allOf","anyOf","oneOf"]),aN=new Set(["not","additionalProperties","propertyNames","contains","if","then","else","contentSchema"]);function iN(e,t,n,r,o,s=oN){let a;if(s.has(t))a=r.schemaMap(n,t);else if(sN.has(t))a=r.schemaArray(n,t);else if(o.has(t))a=r.schema(n,t);else return!1;return q(e,t,a),!0}var E0=["$anchor","$defs","$dynamicAnchor","$dynamicRef","$vocabulary","contentSchema","dependentRequired","dependentSchemas","maxContains","minContains","prefixItems","unevaluatedItems","unevaluatedProperties"],z8=[...E0,"deprecated"],$8=[...E0,"$comment","$id","$schema","const","contains","contentEncoding","contentMediaType","else","examples","if","patternProperties","propertyNames","then"],cN=/^[A-Za-z_][-A-Za-z0-9._]*$/,fN=/^[A-Za-z][-A-Za-z0-9._:]*$/;function wa(e,t,n){throw Error(`Cannot convert JSON Schema keyword "${e}" to ${t}: ${n}`)}function uN(e,t,n,r){for(let o of t)if(Object.hasOwn(e,o))wa(o,n,`it is not active in ${r} but would become active in the target`)}var dN=["additionalItems","definitions","dependencies"];function lN(e,t,n,r,o){if(n.isDocumentRoot)q(e,"$schema",p0(t,l0)?r:t);else if(!p0(t,l0))wa("$schema",o,"an embedded resource cannot declare a different dialect")}function pN(e,t){uN(e,dN,"Draft-07","Draft 2020-12");let n={},r=void 0,o=void 0,s=void 0;for(let a of Object.keys(e)){let i=e[a];if(iN(n,a,i,t,aN))continue;switch(a){case"$ref":r=i;break;case"$schema":lN(n,i,t,YD,"Draft-07");break;case"$id":case"$anchor":break;case"$defs":q(n,"definitions",t.schemaMap(i,a,"definitions"));break;case"prefixItems":o=i;break;case"items":s=i;break;case"dependentRequired":case"dependentSchemas":case"minContains":case"maxContains":break;case"$dynamicRef":case"$dynamicAnchor":case"$vocabulary":case"unevaluatedProperties":case"unevaluatedItems":wa(a,"Draft-07","the target dialect has no equivalent");case"required":if(Array.isArray(i)&&i.length===0)break;q(n,a,i);break;default:q(n,a,i)}}if(mN(n,o,s,t),Object.hasOwn(e,"contains")){let{minContains:a,maxContains:i}=e;if(a!==void 0&&a!==1||i!==void 0)wa("minContains/maxContains","Draft-07","contains cardinality cannot be represented");if(Object.hasOwn(e,"minContains"))q(n,"minContains",a)}else{if(Object.hasOwn(e,"minContains"))q(n,"minContains",e.minContains);if(Object.hasOwn(e,"maxContains"))q(n,"maxContains",e.maxContains)}return gN(e,n,t,"draft-07"),yN(e,n,"$id","Draft-07"),hN(n,r,t),n}function mN(e,t,n,r){if(t===void 0){if(n!==void 0)q(e,"items",r.schema(n,"items"));return}if(q(e,"items",r.schemaArray(t,"prefixItems","items")),n!==void 0)q(e,"additionalItems",r.schema(n,"items","additionalItems"))}function hN(e,t,n){if(t===void 0)return;if(typeof t==="string"&&Object.keys(e).length>0){let r={};n.reference(r,t),xN(e,r)}else n.reference(e,t)}function gN(e,t,n,r){let o=st(e.dependentRequired)?e.dependentRequired:void 0,s=st(e.dependentSchemas)?e.dependentSchemas:void 0;if(o===void 0&&s===void 0)return;let a={},i=new Set([...Object.keys(o??{}),...Object.keys(s??{})]);for(let c of i){let f=o?.[c],u=s?.[c],d=r==="draft-04"&&Array.isArray(f)&&f.length===0;if(u===void 0){if(!d)q(a,c,f)}else if(f===void 0||d)q(a,c,n.schemaAt(u,["dependentSchemas",c],["dependencies",c]));else q(a,c,{allOf:[n.schemaAt(u,["dependentSchemas",c],["dependencies",c,"allOf","0"]),{required:f}]})}if(Object.keys(a).length>0)q(t,"dependencies",a)}function xN(e,t){if(Array.isArray(e.allOf))e.allOf.push(t);else q(e,"allOf",[t])}function yN(e,t,n,r){let{$id:o,$anchor:s}=e;if(s===void 0){if(o!==void 0)q(t,n,o);return}if(typeof s!=="string"||!cN.test(s))wa("$anchor",r,"the anchor is not valid");if(!fN.test(s))wa("$anchor",r,"the anchor cannot be represented as a plain-name fragment identifier");if(o===void 0)q(t,n,`#${s}`);else wa("$anchor",r,"it cannot be combined with the schema $id")}function Ol(e){return Nr(Ni(e.ast),{schema:e})}var Ni=Wo((e)=>{let t=bN(e,Ni),n=e.context;if(t===e||n===void 0)return t;return _i(t,cx(n))});function cx(e){return e.constructorDefault===void 0?e:new sr(e.isOptional,e.isMutable,void 0,e.annotations)}function I0(e){if(e.propertySignatures.some((t)=>typeof t.name!=="string"))throw new globalThis.Error("Objects property names must be strings",{cause:e})}function w0(e){return(t)=>{let n=[...t].sort((o,s)=>e(En(o))-e(En(s)));if(!n.some((o,s)=>o!==t[s]))return t;return n}}var EN=w0((e)=>{switch(e._tag){case"BigInt":case"Symbol":case"UniqueSymbol":return 0;default:return 1}});function bN(e,t){switch(e._tag){case"Declaration":{let n=e.annotations?.toCodecJson??e.annotations?.toCodec;if(!On(n))return Pe(e,[qg]);let r=e.typeParameters.map((s)=>Nr(En(s))),o=n(r);return o===void 0?e:Pe(e,[vs(o,t)])}case"Unknown":return Pe(e,[qg]);case"ObjectKeyword":return Pe(e,[qk]);case"Undefined":case"Void":case"Literal":case"Number":return e.toCodecJson();case"UniqueSymbol":case"Symbol":case"BigInt":return e.toCodecStringTree();case"Objects":return I0(e),e.recur(t,yl);case"Union":{let n=EN(e.types);if(n!==e.types)return new tn(n,e.options,e.annotations,e.checks,e.encoding,e.context,e.encodingChecks).recur(t);return e.recur(t)}case"Arrays":case"Suspend":return e.recur(t)}return e}function _l(e){return Nr(k0(Ve(e.ast)))}var k0=Ln((e)=>{let t=IN(e,k0);return t!==e&&e.context!==void 0?_i(t,cx(e.context)):t});function IN(e,t){switch(e._tag){case"Declaration":{let n=e.annotations?.toCodecIso??e.annotations?.toCodec;if(On(n)){let r=n(e.typeParameters.map((o)=>Nr(o)));return Pe(e,[vs(r,t)])}return e}case"Arrays":case"Objects":case"Union":case"Suspend":return e.recur(t)}return e}function Rl(e){return Nr(v0(e.ast),{schema:e})}function T0(e){return Nr(O0(e.ast))}var wN=w0((e)=>{switch(e._tag){case"Null":case"Boolean":case"Number":case"BigInt":case"Symbol":case"UniqueSymbol":return 0;default:return 1}});function kN(e,t,n){switch(e._tag){case"Declaration":{let r=e.typeParameters.map((f)=>Nr(t(En(f)))),o=e.annotations?.toCodecStringTree;if(On(o)){let f=o(r);if(f===void 0)return e;return Pe(e,[vs(f,t)])}let s=e.annotations?.toCodecJson,a=On(s)?s(r):void 0,i=a===void 0?e.annotations?.toCodec:void 0,c=a??(On(i)?i(r):void 0);return c===void 0?n(e):Pe(e,[vs(c,t)])}case"Null":return Pe(e,[TN]);case"Boolean":return Pe(e,[AN]);case"Unknown":case"ObjectKeyword":return Pe(e,[Hg]);case"Enum":case"Number":case"Literal":case"UniqueSymbol":case"Symbol":case"BigInt":return e.toCodecStringTree();case"Objects":return I0(e),e.recur(t,yl);case"Union":{let r=wN(e.types);if(r!==e.types)return new tn(r,e.options,e.annotations,e.checks,e.encoding,e.context,e.encodingChecks).recur(t);return e.recur(t)}case"Arrays":case"Suspend":return e.recur(t)}return e}var TN=new Xe(new yn("null"),new be(se(()=>null),se(()=>"null"))),AN=new Xe(new tn([new yn("true"),new yn("false")]),new be(se((e)=>e==="true"),ha())),A0=new be(se((e)=>typeof e==="string"?[e]:e),xo()),C0=(e)=>e.transformation===A0,v0=Wo((e)=>{let t=kN(e,v0,(n)=>{throw new globalThis.Error("Missing structural codec for StringTree",{cause:n})});if(t!==e&&e.context!==void 0)return _i(t,cx(e.context));return t},{stopAt:C0}),b0=(e)=>Mt(e)?ba(jo):jo,O0=Wo((e)=>{let t=CN(e);if(Eg(t)){let n=Pi(new tn([new ar(t.isMutable,t.elements.map(b0),t.rest.map(b0)),$n],{mode:"anyOf"}),t,A0);return Mt(e)?ba(n):n}return t},{stopAt:C0});function CN(e){return e._tag==="Declaration"||e._tag==="Arrays"||e._tag==="Objects"||e._tag==="Union"||e._tag==="Suspend"?e.recur(O0):e}var H8=globalThis.RegExp;var Ko=(e)=>e.replace(/[/\\^$*+?.()|[\]{}]/g,"\\$&");function _s(e,t){if(t.length>0)e+=`
|
|
5
|
+
at ${Bd(t)}`;return Error(e)}function R0(e){return`#/$defs/${ox(e)}`}var vN=new Set([...RI,pa,..._I]);function _f(e,t){if(e===void 0)return;let n={},r=e.title;if(typeof r==="string")n.title=r;let{description:o,expected:s}=e;if(typeof o==="string")n.description=o;else if(t?.generateDescriptions===!0&&typeof s==="string")n.description=s;let a=e.default;if(Mi(a))n.default=a;let i=e.examples;if(Array.isArray(i)&&Mi(i))n.examples=i;let c=e.readOnly;if(typeof c==="boolean")n.readOnly=c;let f=e.writeOnly;if(typeof f==="boolean")n.writeOnly=f;let u=e.format;if(typeof u==="string")n.format=u;let d=e.contentEncoding;if(typeof d==="string")n.contentEncoding=d;let l=e.contentMediaType;if(typeof l==="string")n.contentMediaType=l;let m=e.contentSchema;if(Mi(m))n.contentSchema=m;if(t?.includeAnnotationKey!==void 0)for(let[p,g]of Object.entries(e)){if(vN.has(p)||!t.includeAnnotationKey(p))continue;if(Mi(g))q(n,p,g)}return Object.keys(n).length===0?void 0:n}function M0(e){let t=e.type==="number"||e.type==="integer"?e.type:void 0,n=e;if(t!==void 0)n={...e},delete n.type;if(Array.isArray(n.allOf)){let r=[],o=!1;for(let s of n.allOf){let a=M0(s);if(a.type!==void 0){if(o=!0,t===void 0||a.type==="integer")t=a.type}if(Object.keys(a.schema).length>0)r.push(a.schema)}if(o){let{allOf:s,...a}=n;n=r.length===0?a:{...a,allOf:r}}}return{type:t,schema:n}}function ON(e){if(!Array.isArray(e.anyOf)||e.anyOf.length!==2||e.anyOf[0]?.type!=="number")return!1;let t=e.anyOf[1];return t?.type==="string"&&Array.isArray(t.enum)&&t.enum.length===3&&t.enum.includes("NaN")&&t.enum.includes("Infinity")&&t.enum.includes("-Infinity")}var U0="|type|format|pattern|multipleOf|minimum|maximum|exclusiveMinimum|exclusiveMaximum|minLength|maxLength|minItems|maxItems|uniqueItems|minProperties|maxProperties|propertyNames|";function Pl(e,t){return Object.keys(e).every((n)=>t.includes(`|${n}|`))}function P0(e,t){return typeof e.$ref!=="string"&&t.every((n)=>!Object.hasOwn(e,n))}var ux="|title|description|default|examples|readOnly|writeOnly|",_N=U0+ux;function Rf(e,t,n){if(Object.keys(e).length===0)return t;let r=Object.keys(t);if(r.length===0)return e;let o=e.type==="number"||e.type==="integer"?e.type:void 0,s=ON(e);if(o!==void 0||s){let i=M0(t);if(i.type!==void 0){let c=o==="integer"||i.type==="integer"?"integer":"number",f={...e,type:c};if(s)delete f.anyOf;let u=Object.keys(i.schema);if(u.length===0)return f;return Pl(i.schema,ux)&&P0(f,u)?{...f,...i.schema}:Rf(f,i.schema,n)}}if(n&&P0(e,r))return{...e,...t};let a=Array.isArray(t.allOf)&&r.length===1?t.allOf:[t];if(Array.isArray(e.allOf))return{...e,allOf:[...e.allOf,...a]};if(typeof e.$ref==="string")return{allOf:[e,...a]};return{...e,allOf:a}}function fx(e,t=new Set){if(typeof e==="boolean")return e;if(t.has(e))return!0;return t.add(e),e.every((n)=>fx(n,t))}function RN(e){return Array.isArray(e)}function PN(e,t,n,r){let o=new Map,s=new Map,a=new WeakMap,i=new Map,c=new Map,f=Object.keys(n);for(let x of f)p(x,["references",x]);let u=hn(e,(x,w)=>S(x,t[w],[]));for(let[x,w]of i.values())if(!fx(x)){for(let C of w)if(Array.isArray(C.oneOf))C.anyOf=C.oneOf,delete C.oneOf}for(let x of f){let w=n[x],C=h(w);if(C===void 0)continue;let T=o.get(x)[0],v=c.get(C),O=v?.find((U)=>he(o.get(U)[0],T));if(O===void 0)if(v===void 0)c.set(C,[x]);else v.push(x);else s.set(x,O)}let d=hn(u,g),l={};for(let x of f)if(!s.has(x))q(l,x,g(o.get(x)[0]));return{dialect:"draft-2020-12",schemas:d,definitions:l};function m(x){if(Array.isArray(x.oneOf))i.get(x.oneOf)?.[1].push(x);return x}function p(x,w){if(!Object.hasOwn(n,x))throw _s(`Invalid reference ${x}`,[...w,"$ref"]);let C=o.get(x);if(C!==void 0)return C;let T=[{},[]];return o.set(x,T),T[0]=S(n[x],["references",x],T[1]),T}function g(x){return x0(x,(w)=>{let C=sx(w);if(C===void 0){if(/^#(?:\/|%2f)/i.test(w))throw Error(`Invalid JSON Pointer URI fragment ${JSON.stringify(w)}`);return w}if(!C.startsWith("/$defs/"))return w;let T=C.indexOf("/",7),v=s.get(vf(C.slice(7,T<0?void 0:T)));if(v===void 0)return w;return w.replace(/^#(?:\/|%2f).*?(?:\/|%2f).*?(?=\/|%2f|$)/i,R0(v))})}function h(x){if(x._tag==="Reference")return;let w=x.checks.length===0?x.annotations:x.checks[x.checks.length-1].annotations;return typeof w?.identifier!=="string"&&typeof w?.[pa]==="string"?w[pa]:void 0}function E(x,w,C,T){let v=x.annotations,O=v?.toJsonSchema;if(O!==void 0){let J=x.representation?.schemas?.map((wt,ti)=>S(wt,[...C,"representation","schemas",ti],T))??[],N=O({type:w,schemas:J}),G=RN(N);if(G)T.push(!1);let fe=G?N[0]:N,Ge=_f(v,r),Ot=Ge===void 0?fe:{...fe,...Ge},et=Ge===void 0?U0:_N;return[Ot,x._tag==="Filter"&&Pl(Ot,et)&&(Ge===void 0||Pl(Ge,ux))?!0:void 0]}if(x._tag==="Filter"){T.push(!1);return}let U=x.checks.flatMap((J,N)=>{let G=E(J,w,[...C,"checks",N],T);return G===void 0?[]:[G[0]]});if(U.length===0)return;let j=_f(v,r),X={allOf:U};return[j===void 0?X:{...X,...j}]}function S(x,w,C){if(x._tag==="Reference")return C.push(p(x.$ref,w)[1]),{$ref:R0(x.$ref)};let T=a.get(x);if(T!==void 0)return C.push(T[1]),T[0];let v=[];C.push(v);let O=k(x,w,v),U=_f(x.annotations,r);if(U!==void 0)O={...O,...U};for(let j=0;j<x.checks.length;j++){let X=typeof O.type==="string"&&MN(O.type)?O.type:void 0,J=E(x.checks[j],X,[...w,"checks",j],v);if(J!==void 0)O=Rf(O,...J)}return a.set(x,[O,v]),m(O)}function k(x,w,C){switch(x._tag){case"Any":case"Unknown":return{};case"ObjectKeyword":return{anyOf:[{type:"object"},{type:"array"}]};case"Void":case"Undefined":case"Null":return{type:"null"};case"BigInt":return{type:"string",allOf:[{pattern:"^-?\\d+$"}]};case"Symbol":return{type:"string",allOf:[{pattern:"^Symbol\\(([\\s\\S]*)\\)$"}]};case"UniqueSymbol":return globalThis.Symbol.keyFor(x.symbol)===void 0?{not:{}}:{type:"string",enum:[globalThis.String(x.symbol)]};case"Declaration":return C.push(!1),{};case"Suspend":return S(x.thunk,[...w,"thunk"],C);case"Never":return{not:{}};case"String":return{type:"string"};case"Number":return{anyOf:[{type:"number"},{type:"string",enum:["NaN","Infinity","-Infinity"]}]};case"Boolean":return{type:"boolean"};case"Literal":{let T=x.literal;return typeof T==="bigint"?{type:"string",enum:[globalThis.String(T)]}:{type:typeof T,enum:[T]}}case"Enum":{let T=x.enums.map(([v,O],U)=>{if(typeof O==="number"&&!globalThis.Number.isFinite(O))throw _s(`Invalid numeric enum value ${globalThis.String(O)}`,[...w,"enums",U,1]);return{type:typeof O,enum:[O],title:v}});return T.length===0?{not:{}}:{anyOf:T}}case"TemplateLiteral":return{type:"string",pattern:`^${x.parts.map(Ml).join("")}$`};case"Arrays":{if(x.rest.length>1)throw _s("Invalid schema representation document",[...w,"rest"]);let T={type:"array"},v=x.elements.length,O=x.elements.map((U,j)=>{if(U.isOptional)v--;let X=S(U.type,[...w,"elements",j,"type"],C),J=_f(U.annotations,r);return J===void 0?X:m(Rf(X,J))});if(O.length>0){if(T.prefixItems=O,T.maxItems=x.elements.length,v>0)T.minItems=v}else T.items=!1;if(x.rest.length===1){delete T.maxItems;let U=S(x.rest[0],[...w,"rest",0],C);if(Object.keys(U).length>0)T.items=U;else delete T.items}return T}case"Objects":{if(x.propertySignatures.length===0&&x.indexSignatures.length===0)return{not:{type:"null"}};let T={type:"object"},v={},O=[];for(let G=0;G<x.propertySignatures.length;G++){let fe=x.propertySignatures[G];if(typeof fe.name!=="string")throw _s("Invalid schema representation document",[...w,"propertySignatures",G,"name"]);let Ge=fe.name,Ot=S(fe.type,[...w,"propertySignatures",G,"type"],C),et=_f(fe.annotations,r);if(q(v,Ge,et===void 0?Ot:m(Rf(Ot,et))),!fe.isOptional)O.push(Ge)}if(x.propertySignatures.length>0)T.properties=v;if(O.length>0)T.required=O;let U={},j=[],X=[],J=!1;for(let G=0;G<x.indexSignatures.length;G++){let fe=x.indexSignatures[G],Ge=S(fe.type,[...w,"indexSignatures",G,"type"],C);if(he(Ge,{not:{}}))Ge=!1;X.push(Ge);let Ot=I(fe.parameter,[...w,"indexSignatures",G,"parameter"],new Set);if(Ot===void 0){J=!0,C.push(!1);continue}if(Ot.length===0)j.push(Ge);else for(let et of Ot){let wt=U[et];q(U,et,wt===void 0?Ge:wt===!1||Ge===!1?!1:m(Rf(wt,Ge)))}}let N=Object.keys(U).length>0;if(N)T.patternProperties=U;if(J&&r?.onExcessProperty==="error"){let G=[];if(x.propertySignatures.length>0)G.push({enum:Object.keys(v)});for(let fe=0;fe<x.indexSignatures.length;fe++)G.push(S(x.indexSignatures[fe].parameter,[...w,"indexSignatures",fe,"parameter"],C));if(T.propertyNames=G.length===1?G[0]:{anyOf:G},T.additionalProperties=X.length===1?X[0]:{anyOf:X},j.length>0)T.allOf=j.map((fe)=>({type:"object",additionalProperties:fe}))}else if(j.length===0)T.additionalProperties=J||r?.onExcessProperty!=="error";else if(j.length===1&&x.propertySignatures.length===0&&!N)T.additionalProperties=j[0];else if(j.length>0)T.allOf=j.map((G)=>({type:"object",additionalProperties:G}));if(typeof T.additionalProperties==="object"&&T.additionalProperties!==null&&Object.keys(T.additionalProperties).length===0)delete T.additionalProperties;return T}case"Union":{let T=[],v=x.types.map((U,j)=>S(U,[...w,"types",j],T));if(C.push(T),v.length===0)return{not:{}};let O=x.options?.mode??"anyOf";if(O==="anyOf"&&v.length>1){let U=UN(v);if(U!==void 0)return U}if(O==="oneOf")i.set(v,[T,[]]);return{[O]:v}}}}function I(x,w,C){switch(x._tag){case"Reference":{if(!Object.hasOwn(n,x.$ref))throw _s(`Invalid reference ${x.$ref}`,[...w,"$ref"]);if(p(x.$ref,w),C.has(x.$ref))return;let T=new Set(C).add(x.$ref);return I(n[x.$ref],["references",x.$ref],T)}case"String":{if(x.checks.length===0)return[];if(x.checks.length!==1||x.checks[0]._tag!=="Filter"||x.checks[0].annotations?.toJsonSchema===void 0)return;let T=[],v=S(x,w,T);if(!fx(T))return;return v.type==="string"&&typeof v.pattern==="string"&&Pl(v,"|type|pattern|title|description|default|examples|readOnly|writeOnly|")?[v.pattern]:void 0}case"TemplateLiteral":return x.checks.length===0?[`^${x.parts.map(Ml).join("")}$`]:void 0;case"Union":{if(x.types.length===0||x.checks.length>0||x.options?.mode==="oneOf")return;let T=[];for(let v=0;v<x.types.length;v++){let O=I(x.types[v],[...w,"types",v],C);if(O===void 0)return;if(O.length===0)return[];T.push(...O)}return T}default:throw _s("Invalid schema representation document",w)}}}function MN(e){return e==="string"||e==="number"||e==="boolean"||e==="array"||e==="object"||e==="null"||e==="integer"}function UN(e){let t=void 0,n=[];for(let r of e){if(Object.keys(r).length!==2||r.type===void 0||!Array.isArray(r.enum)||r.enum.length===0)return;if(t===void 0)t=r.type;else if(r.type!==t)return;for(let s of r.enum){if(n.includes(s))return;n.push(s)}}return{type:t,enum:n}}function Ml(e){switch(e._tag){case"Literal":return Ko(globalThis.String(e.literal));case"String":return Fk;case"Number":return dl;case"TemplateLiteral":return e.parts.map(Ml).join("");case"Union":return`(?:${e.types.map(Ml).join("|")})`;default:throw _s("Invalid schema representation document",[])}}function Ul(e,t){let n=PN([e.representation],[["representation"]],e.references,t);return{dialect:n.dialect,schema:n.schemas[0],definitions:n.definitions}}var FN=({identifier:e})=>e;function Br(e){return e===void 0?void 0:{annotations:e}}function Pf(e,t){let{references:n,representations:r}=DN([e],t);return{representation:r[0],references:n}}function DN(e,t){let n={},r=new Map,o=new Set,s=new Map,a=new Set;for(let x of e)m(x);let i=t?.referencePolicy??FN;for(let x of s.values())for(let w of x.values()){let C=i({ast:w.ast,occurrences:w.occurrences,identifier:w.identifier});if(C!==void 0){let T=C===w.identifier||!C.endsWith("_")?"_":"";w.reference=f(C,w,T)}else if(w.isRecursive)w.reference=f(`${w.ast._tag}_`,w,"")}return{representations:hn(e,(x)=>g(x)),references:n};function f(x,w,C="_"){let T=x,v=0;while(r.has(T)){if(r.get(T)===w)return T;T=`${x}${C}${++v}`}return r.set(T,w),T}function u(x,w,C){let T=w.fallback;if(T!==void 0)return Gh(x)===T?x:Ur(x,{[pa]:T});return C===w.identifier?x:Ur(x,{identifier:C})}function d(x,w){if(!Object.hasOwn(n,x)&&!o.has(x)){o.add(x);let C=h(w);o.delete(x),q(n,x,C)}return{_tag:"Reference",$ref:x}}function l(x){let w=Oi(x),C=vi(w),T=mi(w),v=T===void 0?(w!==x?mi(x):void 0)??Gh(w):void 0;if(v!==void 0)T=`${v}Encoded`;let O=s.get(C);if(O===void 0)O=new Map,s.set(C,O);let U=O.get(T);if(U===void 0)U={ast:C,identifier:T,fallback:v,occurrences:0,isRecursive:!1,reference:void 0},O.set(T,U);return U}function m(x){let w=l(x),C=w.ast;if(w.occurrences++,a.has(w)){w.isRecursive=!0;return}if(w.occurrences>1)return;switch(a.add(w),p(C.checks),C._tag){case"Declaration":case"Arrays":case"Objects":case"Union":C.recur((T)=>(m(T),T));break;case"TemplateLiteral":C.parts.forEach(m);break;case"Suspend":m(C.thunk());break}a.delete(w)}function p(x){x?.forEach((w)=>{if(w.annotations?.representation?.schemas?.forEach((C)=>m(Ve(C))),w._tag==="FilterGroup")p(w.checks)})}function g(x){let w=l(x),C=w.ast,T=w.reference;if(T!==void 0){let v=w.identifier===void 0?C:u(C,w,T);return d(T,v)}return h(C)}function h(x){let w=E(x.checks);switch(x._tag){case"Declaration":return{_tag:"Declaration",typeParameters:x.typeParameters.map((C)=>g(C)),checks:w,...k(x.annotations)};case"Null":case"Undefined":case"Void":case"Never":case"Unknown":case"Any":case"String":case"Boolean":case"Number":case"BigInt":case"Symbol":case"ObjectKeyword":return{_tag:x._tag,checks:w,...Br(x.annotations)};case"Literal":return{_tag:"Literal",literal:x.literal,checks:w,...Br(x.annotations)};case"UniqueSymbol":return{_tag:"UniqueSymbol",symbol:x.symbol,checks:w,...Br(x.annotations)};case"Enum":return{_tag:"Enum",enums:x.enums,checks:w,...Br(x.annotations)};case"TemplateLiteral":return{_tag:"TemplateLiteral",parts:x.parts.map((C)=>g(C)),checks:w,...Br(x.annotations)};case"Arrays":return{_tag:"Arrays",elements:x.elements.map((C)=>{let T=Oi(C),v=T.context?.annotations;return{isOptional:Mt(T),type:g(C),...Br(v)}}),rest:x.rest.map((C)=>g(C)),checks:w,...Br(x.annotations)};case"Objects":return{_tag:"Objects",propertySignatures:x.propertySignatures.map((C)=>{let T=Oi(C.type),v=T.context?.annotations;return{name:C.name,type:g(C.type),isOptional:Mt(T),isMutable:Rk(T),...Br(v)}}),indexSignatures:x.indexSignatures.map((C)=>({parameter:g(C.parameter),type:g(C.type)})),checks:w,...Br(x.annotations)};case"Union":return{_tag:"Union",types:x.types.map((C)=>g(C)),...x.options===void 0?{}:{options:x.options},checks:w,...Br(x.annotations)};case"Suspend":return{_tag:"Suspend",checks:[],thunk:g(x.thunk()),...Br(x.annotations)}}}function E(x){return x?.map(S)??[]}function S(x){switch(x._tag){case"Filter":return{_tag:"Filter",aborted:x.aborted,...I(x.annotations)};case"FilterGroup":return{_tag:"FilterGroup",checks:hn(x.checks,S),...I(x.annotations)}}}function k(x){if(x===void 0)return;let{representation:w,...C}=x;return{...w===void 0?void 0:{representation:w},...Object.keys(C).length===0?void 0:{annotations:C}}}function I(x){if(x===void 0)return;let{representation:w,...C}=x,T=w===void 0?void 0:w.schemas===void 0?w:{...w,schemas:w.schemas.map((v)=>g(Ve(v)))};return{...T===void 0?void 0:{representation:T},...Object.keys(C).length===0?void 0:{annotations:C}}}}function N0(e){return $e(e)?e.value:{issues:[{message:z0(e.cause)}]}}function q0(e,t){let n=qe(e),r={errors:"all",...t?.parseOptions},o=LI(t),s=(a)=>{let i=new L0("sync"),c=Fl($0(n(a,r),{onFailure:o,onSuccess:(u)=>({value:u})}),{scheduler:i});c.currentDispatcher?.flush();let f=c.pollUnsafe();if(f)return N0(f);return new Promise((u)=>{c.addObserver((d)=>{u(N0(d))})})};if("~standard"in e){let a=e;if("validate"in a["~standard"])return a;return Object.assign(a["~standard"],{validate:s}),a}return Object.assign(e,{"~standard":{version:1,vendor:"effect",validate:s}})}function NN(e){let t=Pf(Ni(e));return Ul(t)}function B0(e,t){let n=NN(e);if(t==="draft-2020-12"){let r=n.schema;if(Object.keys(n.definitions).length>0)r.$defs=n.definitions;return r}else if(t==="draft-07"){let r=g0(n),o=r.schema;if(Object.keys(r.definitions).length>0)o.definitions=r.definitions;return o}throw new globalThis.Error(`Unsupported target: ${t}`)}function H0(e){let t={input(n){return B0(e.ast,n.target)},output(n){return B0(Ve(e.ast),n.target)}};if("~standard"in e){let n=e;if("jsonSchema"in n["~standard"])return n;return Object.assign(n["~standard"],{jsonSchema:t}),n}return Object.assign(e,{"~standard":{version:1,vendor:"effect",jsonSchema:t}})}function W0(e,t){let n=[];return dx(e,t,"",n),n}function dx(e,t,n,r){if(Object.is(e,t))return;if(Array.isArray(e)&&Array.isArray(t)){let o=e.length,s=t.length,a=Math.min(o,s);for(let i=0;i<a;i++)dx(e[i],t[i],`${n}/${i}`,r);for(let i=o-1;i>=s;i--)r.push({op:"remove",path:`${n}/${i}`});for(let i=o;i<s;i++)r.push({op:"add",path:`${n}/${i}`,value:t[i]});return}if(Dl(e)&&Dl(t)){let o=Object.keys(e),s=Object.keys(t),a=Array.from(new Set([...o,...s])).sort();for(let i of a){let c=`${n}/${rx(i)}`,f=Object.hasOwn(e,i),u=Object.hasOwn(t,i);if(f&&u)dx(e[i],t[i],c,r);else if(!f&&u)r.push({op:"add",path:c,value:t[i]});else r.push({op:"remove",path:c})}return}r.push({op:"replace",path:n,value:t})}function J0(e,t){let n=t;for(let r of e)n=zN(n,r);return n}function Dl(e){return typeof e==="object"&&e!==null&&!Array.isArray(e)}function LN(e){if(e==="")return[];if(e.charCodeAt(0)!==47)throw Error(`Invalid JSON Pointer, it must start with "/": ${JSON.stringify(e)}`);return e.split("/").slice(1).map(vf)}function G0(e){if(!/^(0|[1-9]\d*)$/.test(e))throw Error(`Invalid array index: "${e}"`);return Number(e)}function zN(e,t){if(t.path===""){if(t.op==="remove")throw Error("Unsupported operation at the root");return t.value}let n=$N(e,t.path);if(n===null)throw Error(`Cannot ${t.op} at "${t.path}" (parent not found or not a container).`);let{lastToken:r,parent:o,stack:s}=n;if(Array.isArray(o)){if(r==="-"&&t.op!=="add")throw Error(`"-" is not valid for ${t.op} at "${t.path}".`);let a=r==="-"?o.length:G0(r),i=t.op==="add"?o.length:o.length-1;if(a>i)throw Error(`Array index out of bounds at "${t.path}".`);let c=o.slice();if(t.op==="add")c.splice(a,0,t.value);else if(t.op==="remove")c.splice(a,1);else c[a]=t.value;return j0(s,c)}if(Dl(o)){if(t.op!=="add"&&!Object.hasOwn(o,r))throw Error(`Property "${r}" does not exist at "${t.path}".`);let a={...o};if(t.op==="remove")delete a[r];else q(a,r,t.value);return j0(s,a)}throw Error(`Cannot ${t.op} at "${t.path}" (parent not found or not a container).`)}function $N(e,t){let n=LN(t);if(n.length===0)return null;let r=n[n.length-1],o=[],s=e;for(let a=0;a<n.length-1;a++){let i=n[a];if(Array.isArray(s)){let c=G0(i);if(c>=s.length)return null;o.push({container:s,token:c}),s=s[c];continue}if(Dl(s)){if(!Object.hasOwn(s,i))return null;o.push({container:s,token:i}),s=s[i];continue}return null}return{stack:o,parent:s,lastToken:r}}function j0(e,t){let n=t;for(let r=e.length-1;r>=0;r--){let{container:o,token:s}=e[r];if(Array.isArray(o)){let a=o.slice();a[s]=n,n=a}else{let a={...o};q(a,s,n),n=a}}return n}function K0(e){let t=Ol(e),n=Al(t),r=Tl(t);return{empty:[],diff:(o,s)=>W0(n(o),n(s)),combine:(o,s)=>[...o,...s],patch:(o,s)=>{let a=n(o),i=J0(s,a);return Object.is(i,a)?o:r(i)}}}function V0(e,t){let n=mi(e.ast)??Kh(e.ast),r=t0(Rl(e));return(o)=>r(o).pipe(B((s)=>jN(s,{rootName:n,...t})))}function jN(e,t){let n=t.rootName??"root",r=t.arrayItemName??"item",o=t.pretty??!0,s=t.indent??" ",a=t.sortKeys??!0,i=new Set,c=[];return u(n,e,0),c.join(o?`
|
|
6
|
+
`:"");function f(d,l){c.push(o?s.repeat(d)+l:l)}function u(d,l,m,p){let{attrs:g,safe:h}=Bi.tagInfo(d,p);if(l===void 0)f(m,`<${h}${g}/>`);else if(typeof l==="string")f(m,`<${h}${g}>${Bi.escapeText(l)}</${h}>`);else if(typeof l!=="object"||l===null)f(m,`<${h}${g}>${Bi.escapeText(K(l))}</${h}>`);else{if(i.has(l))throw new globalThis.Error("Cycle detected while serializing to XML.",{cause:l});i.add(l);try{if(globalThis.Array.isArray(l)){if(l.length===0){f(m,`<${h}${g}/>`);return}f(m,`<${h}${g}>`);for(let k of l)u(r,k,m+1);f(m,`</${h}>`);return}let E=l,S=Object.keys(E);if(a)S.sort();if(S.length===0){f(m,`<${h}${g}/>`);return}f(m,`<${h}${g}>`);for(let k of S)u(Bi.parseTagName(k).safe,E[k],m+1,k);f(m,`</${h}>`)}finally{i.delete(l)}}}}var Bi={escapeText(e){return e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">")},escapeAttribute(e){return e.replace(/&/g,"&").replace(/"/g,""").replace(/</g,"<").replace(/>/g,">")},parseTagName(e){let t=e,n=e;if(!/^[A-Za-z_]/.test(n))n="_"+n;if(n=n.replace(/[^A-Za-z0-9._-]/g,"_"),/^xml/i.test(n))n="_"+n;return{safe:n,changed:n!==t}},tagInfo(e,t){let{changed:n,safe:r}=Bi.parseTagName(e),s=n||t&&t!==e?` data-name="${Bi.escapeAttribute(t??e)}"`:"";return{safe:r,attrs:s}}};var lx=Ln((e)=>Rs(e));function Rs(e){let t=Ho(e)?.toEquivalence;if(t)return t(Ci(e)?e.typeParameters.map(Rs):[]);switch(e._tag){case"Never":return da();case"Declaration":return JN(e);case"Null":case"Undefined":case"Void":case"Unknown":case"Any":case"String":case"Number":case"Boolean":case"BigInt":case"Symbol":case"Literal":case"UniqueSymbol":case"ObjectKeyword":case"Enum":case"TemplateLiteral":return he;case"Arrays":{let n=e.elements.map(Rs),r=e.rest.map(Rs),[o,...s]=r,a=s.length;return Ar((i,c)=>{if(!Array.isArray(i)||!Array.isArray(c))return!1;let f=i.length;if(f!==c.length)return!1;let u=0;for(;u<Math.min(f,e.elements.length);u++)if(!n[u](i[u],c[u]))return!1;if(r.length>0){for(;u<f-a;u++)if(!o(i[u],c[u]))return!1;for(let d=0;d<a;d++)if(!s[d](i[u+d],c[u+d]))return!1}return!0})}case"Objects":{if(e.propertySignatures.length===0&&e.indexSignatures.length===0)return he;let n=e.propertySignatures.map((o)=>Rs(o.type)),r=e.indexSignatures.map((o)=>Rs(o.type));return Ar((o,s)=>{if(!st(o)||!st(s))return!1;for(let a=0;a<n.length;a++){let i=e.propertySignatures[a],c=i.name,f=Object.hasOwn(o,c),u=Object.hasOwn(s,c);if(Mt(i.type)){if(f!==u)return!1}if(f&&u&&!n[a](o[c],s[c]))return!1}for(let a=0;a<r.length;a++){let i=e.indexSignatures[a],c=yo(o,i.parameter),f=yo(s,i.parameter);if(c.length!==f.length)return!1;for(let u=0;u<c.length;u++){let d=c[u];if(!Object.hasOwn(s,d)||!r[a](o[d],s[d]))return!1}}return!0})}case"Union":{let n=Ve(e).types,r=wf(n),o=n.map((s,a)=>[Cf(s),Rs(e.types[a])]);return Ar((s,a)=>{let i=r(s,!1);for(let c=0;c<i.length;c++){let[f,u]=o[i[c]];if(f(s)&&f(a))return u(s,a)}return!1})}case"Suspend":{let n;return Ar((r,o)=>(n??=lx(e.thunk()))(r,o))}}}function JN(e){let t=e.annotations?.representation;if(t===void 0)return he;switch(t.id){case"effect/schema/Option":{let[n]=ka(e);return(r,o)=>r._tag===o._tag&&(r._tag==="None"||n(r.value,o.value))}case"effect/schema/Result":{let[n,r]=ka(e);return(o,s)=>o._tag===s._tag&&(o._tag==="Success"?n(o.success,s.success):r(o.failure,s.failure))}case"effect/schema/CauseReason":{let[n,r]=ka(e);return Y0(n,r)}case"effect/schema/Cause":{let[n,r]=ka(e);return Z0(n,r)}case"effect/schema/Exit":{let[n,r,o]=ka(e),s=Z0(r,o);return(a,i)=>a._tag===i._tag&&(a._tag==="Success"?n(a.value,i.value):s(a.cause,i.cause))}case"effect/schema/ReadonlyMap":{let[n,r]=ka(e);return Nl(n,r)}case"effect/schema/ReadonlySet":return Bl(ka(e)[0]);case"effect/schema/RegExp":return(n,r)=>n.source===r.source&&n.flags===r.flags;case"effect/schema/URL":return(n,r)=>n.toString()===r.toString();default:return he}}function ka(e){return e.typeParameters.map(Rs)}function Y0(e,t){return(n,r)=>{if(n._tag!==r._tag)return!1;switch(n._tag){case"Fail":return e(n.error,r.error);case"Die":return t(n.defect,r.defect);case"Interrupt":return n.fiberId===r.fiberId}}}function Z0(e,t){let n=Q0(Y0(e,t));return(r,o)=>n(r.reasons,o.reasons)}function eT(e,t){return(n)=>{switch(n._tag){case"Fail":return`Fail(${e(n.error)})`;case"Die":return`Die(${t(n.defect)})`;case"Interrupt":return"Interrupt"}}}function X0(e,t){let n=eT(e,t);return(r)=>`Cause([${r.reasons.map(n).join(", ")}])`}function tT(e,t){let n=new Map;return r(e);function r(a){let i=n.get(a);if(i===void 0)i=o(a),n.set(a,i);return i}function o(a){let i=Ho(a)?.toFormatter;if(typeof i==="function")return i(Ci(a)?a.typeParameters.map(r):[]);if(t?.onBefore){let c=t.onBefore(a,r);if(c!==void 0)return c}return s(a)}function s(a){switch(a._tag){default:return K;case"Never":return()=>"never";case"Void":return()=>"void";case"Declaration":{let i=a.annotations?.representation;if(i===void 0)return K;let c=a.typeParameters.map(r);switch(i.id){case"effect/schema/Option":{let[f]=c;return zt({onNone:()=>"none()",onSome:(u)=>`some(${f(u)})`})}case"effect/schema/Result":{let[f,u]=c;return Pr({onSuccess:(d)=>`success(${f(d)})`,onFailure:(d)=>`failure(${u(d)})`})}case"effect/schema/CauseReason":return eT(c[0],c[1]);case"effect/schema/Cause":return X0(c[0],c[1]);case"effect/schema/Exit":{let[f,u,d]=c,l=X0(u,d);return(m)=>{switch(m._tag){case"Success":return`Exit.Success(${f(m.value)})`;case"Failure":return`Exit.Failure(${l(m.cause)})`}}}case"effect/schema/ReadonlyMap":{let[f,u]=c;return(d)=>{let l=d.size;if(l===0)return"ReadonlyMap(0) {}";let m=globalThis.Array.from(d.entries()).sort().map(([p,g])=>`${f(p)} => ${u(g)}`);return`ReadonlyMap(${l}) { ${m.join(", ")} }`}}case"effect/schema/HashMap":{let[f,u]=c;return(d)=>{let l=Vb(d);if(l===0)return"HashMap(0) {}";let m=ef(d).sort().map(([p,g])=>`${f(p)} => ${u(g)}`);return`HashMap(${l}) { ${m.join(", ")} }`}}case"effect/schema/ReadonlySet":{let[f]=c;return(u)=>{let d=u.size;if(d===0)return"ReadonlySet(0) {}";let l=globalThis.Array.from(u.values()).sort().map((m)=>`${f(m)}`);return`ReadonlySet(${d}) { ${l.join(", ")} }`}}case"effect/schema/HashSet":{let[f]=c;return(u)=>{let d=Xb(u);if(d===0)return"HashSet(0) {}";let l=globalThis.Array.from(u).sort().map((m)=>`${f(m)}`);return`HashSet(${d}) { ${l.join(", ")} }`}}case"effect/schema/Chunk":{let[f]=c;return(u)=>{let d=rb(u);if(d===0)return"Chunk(0) {}";let l=globalThis.Array.from(u).sort().map((m)=>`${f(m)}`);return`Chunk(${d}) { ${l.join(", ")} }`}}default:return K}}case"Arrays":{let i=a.elements.map((l)=>r(l)),c=a.rest.map(r),[f,...u]=c,d=u.length;return(l)=>{let m=[],p=0;for(;p<i.length;p++)if(l.length<p+1){if(Mt(a.elements[p]))continue}else m.push(i[p](l[p]));if(c.length>0){for(;p<l.length-d;p++)m.push(f(l[p]));for(let g=0;g<d;g++)m.push(u[g](l[p+g]))}return"["+m.join(", ")+"]"}}case"Objects":{let i=a.propertySignatures.map((f)=>r(f.type)),c=a.indexSignatures.map((f)=>r(f.type));if(a.propertySignatures.length===0&&a.indexSignatures.length===0)return K;return(f)=>{let u=[],d=new Set;for(let l=0;l<i.length;l++){let m=a.propertySignatures[l],p=m.name;if(d.add(p),Mt(m.type)&&!Object.hasOwn(f,p))continue;u.push(`${Sa(p)}: ${i[l](f[p])}`)}for(let l=0;l<c.length;l++){let m=yo(f,a.indexSignatures[l].parameter);for(let p of m){if(d.has(p))continue;d.add(p),u.push(`${Sa(p)}: ${c[l](f[p])}`)}}return u.length>0?"{ "+u.join(", ")+" }":"{}"}}case"Union":{let i=Ve(a).types,c=wf(i),f=i.map((u,d)=>[Cf(u),r(a.types[d])]);return(u)=>{let d=c(u,!1);for(let l=0;l<d.length;l++){let[m,p]=f[d[l]];if(m(u))return p(u)}return K(u)}}case"Suspend":{let i;return(c)=>(i??=r(a.thunk()))(c)}}}}var px=y(2,(e,t)=>gx(e,(n,r)=>rT(t,n)?[n,r]:void 0)),mx=y(2,(e,t)=>gx(e,(n,r)=>!rT(t,n)?[n,r]:void 0)),nT=y(2,(e,t)=>({...e,...t}));var hx=y(2,(e,t)=>gx(e,(n,r)=>[Object.hasOwn(t,n)?t[n]:n,r]));var nn=(e)=>e;function rT(e,t){return e.some((n)=>n===t||typeof n==="number"&&String(n)===t)}function gx(e,t){let n={};for(let r of Reflect.ownKeys(e)){if(!Object.prototype.propertyIsEnumerable.call(e,r))continue;let o=t(r,e[r]);if(o){let[s,a]=o;q(n,s,a)}}return n}function iT(e,t){return Lr(Li("Iso",e,t))}function sT(e,t){return Lr(Li("Lens",e,t))}function Li(e,t,n){return[{_tag:"PrimitiveNode",kind:e,get:t,set:n}]}var VN={kind:"Iso",get:Q,set:Q};class yx{_tag="PathNode";kind="Lens";path;get;set;constructor(e){this.path=e,this.get=(t)=>{let n=t;for(let r=0;r<e.length;r++)n=n[e[r]];return n},this.set=(t,n)=>{let r=zl(n),o=r,s=0;for(;s<e.length-1;s++){let a=e[s];q(o,a,zl(o[a])),o=o[a]}return q(o,e[s],t),r}}}class Ll{_tag="CheckNode";kind="Prism";checks;get;set=Q;constructor(e){this.checks=e,this.get=(t)=>Bk(e,t)}}function Ta(e,t){if(e.length===0)return t;if(t.length===0)return e;let n=e.slice();for(let r=0;r<t.length;r++){let o=t[r],s=n[n.length-1];if(s._tag==="PathNode"&&o._tag==="PathNode")n[n.length-1]=new yx([...s.path,...o.path]);else if(s._tag==="CheckNode"&&o._tag==="CheckNode")n[n.length-1]=new Ll([...s.checks,...o.checks]);else n.push(o)}return n}function ZN(e,t){return Lr(Li("Optional",e,t))}class Uf{node;getResult;replaceResult;constructor(e,t,n){this.node=e,this.getResult=t,this.replaceResult=n}replace(e,t){return Mf(this.replaceResult(e,t),()=>t)}modify(e){return(t)=>Mf(Tt(this.getResult(t),(n)=>this.replaceResult(e(n),t)),()=>t)}compose(e){return Lr(Ta(this.node,e.node))}key(e){return Lr(Ta(this.node,[new yx([e])]))}optionalKey(e){return Lr(Ta(this.node,Li("Lens",(t)=>t[e],(t,n)=>{let r=zl(n);if(t===void 0)if(Array.isArray(r)&&(typeof e==="number"||typeof e==="string"&&$d(e)))r.splice(Number(e),1);else delete r[e];else q(r,e,t);return r})))}check(...e){return Lr(Ta(this.node,[new Ll(e)]))}refine(e,t){return Lr(Ta(this.node,[new Ll([hl(e,t)])]))}tag(e){let t=ge(new te({expected:`${JSON.stringify(e)} tag`}));return Lr(Ta(this.node,Li("Prism",(n)=>n._tag===e?ue(n):t,Q)))}at(e,...t){let n=ge(new Qe([e],new ot(void 0)));return Lr(Ta(this.node,Li("Optional",(r)=>Object.hasOwn(r,e)?ue(r[e]):n,(r,o)=>{if(Object.hasOwn(o,e)){let s=zl(o);return q(s,e,r),ue(s)}else return n})))}pick(e){return this.compose(sT(px(e),(t,n)=>({...mx(n,e),...t})))}omit(e){return this.compose(sT(mx(e),(t,n)=>({...px(n,e),...t})))}notUndefined(){return this.refine(ws,{expected:"a value other than `undefined`"})}forEach(e){let t=e($l());return ZN((n)=>vr(this.getResult(n),(r)=>{let o=[];for(let s=0;s<r.length;s++){let a=t.getResult(r[s]);if(At(a))o.push(a.success)}return o}),(n,r)=>Tt(this.getResult(r),(o)=>{let s=[];for(let i=0;i<o.length;i++)if(At(t.getResult(o[i])))s.push(i);if(n.length!==s.length)return ge(new te({message:`each: replacement length mismatch: ${n.length} !== ${s.length}`}));let a=o.slice();for(let i=0;i<s.length;i++){let c=s[i],f=t.replaceResult(n[i],o[c]);if(Bt(f))return ge(new Qe([c],f.failure));a[c]=f.success}return this.replaceResult(a,r)}))}modifyAll(e){return(t)=>Mf(Tt(this.getResult(t),(n)=>this.replaceResult(n.map(e),t)),()=>t)}}class cT extends Uf{get;set;constructor(e,t,n){super(e,(r)=>ue(t(r)),(r)=>ue(n(r)));this.get=t,this.set=n}replace(e,t){return this.set(e)}modify(e){return(t)=>this.set(e(this.get(t)))}}class fT extends Uf{get;constructor(e,t,n){super(e,(r)=>ue(t(r)),(r,o)=>ue(n(r,o)));this.get=t,this.replace=n}modify(e){return(t)=>this.replace(e(this.get(t)),t)}}class uT extends Uf{set;constructor(e,t,n){super(e,t,(r,o)=>ue(n(r)));this.set=n}replace(e,t){return this.set(e)}modify(e){return(t)=>Mf(vr(this.getResult(t),(n)=>this.set(e(n))),()=>t)}}function Lr(e){let t=e[0]??VN;if(e.length>1){let n=e.reduce((r,o)=>XN(r,o.kind),"Iso");t={kind:n,get:QN(e,n),set:YN(e,n)}}switch(t.kind){case"Iso":return new cT(e,t.get,t.set);case"Lens":return new fT(e,t.get,t.set);case"Prism":return new uT(e,t.get,t.set);case"Optional":return new Uf(e,t.get,t.set)}}function zl(e){if(Array.isArray(e))return e.slice();if(typeof e==="object"&&e!==null){let t=Object.getPrototypeOf(e);if(t!==Object.prototype&&t!==null)throw Error("Cannot clone object with non-Object constructor or null prototype");return{...e}}return e}function QN(e,t){return(n)=>{for(let r=0;r<e.length;r++){let o=e[r],s=o.get(n);if(xx(o.kind)){if(Bt(s))return s;n=s.success}else n=s}return xx(t)?ue(n):n}}function YN(e,t){if(aT(t))return(n)=>{for(let r=e.length-1;r>=0;r--)n=e[r].set(n);return n};return(n,r)=>{let o=e.length,s=Array(o);for(let a=0;a<o;a++){s[a]=r;let i=e[a];if(xx(i.kind)){let c=i.get(r);if(Bt(c))return c;r=c.success}else r=i.get(r)}for(let a=o-1;a>=0;a--){let i=e[a];if(aT(i.kind))n=i.set(n);else if(i.kind==="Lens")n=i.set(n,s[a]);else{let c=i.set(n,s[a]);if(Bt(c))return c;n=c.success}}return t==="Optional"?ue(n):n}}function xx(e){return e==="Prism"||e==="Optional"}function aT(e){return e==="Iso"||e==="Prism"}function XN(e,t){if(e==="Iso")return t;if(t==="Iso"||e===t)return e;return"Optional"}var e1=Lr([]);function $l(){return e1}function dT(e){let t=_l(e);return iT(Al(t),Tl(t))}function lT(e){return $l()}function pT(e){return $l()}var zi="~effect/Schema/SchemaError";function mT(e){return V(e,zi)&&e[zi]===zi}var jn="~effect/net/NetAddress";var zr=(e)=>e.value,$r=(e)=>e,Vo=(e)=>e.bytes;class $i extends Qt("NetAddressError"){}var qi=(e)=>V(e,jn),rn=(e)=>qi(e)&&e._tag==="Ipv4Address",Io=(e)=>qi(e)&&e._tag==="Ipv6Address",hT=(e)=>rn(e)||Io(e),Hi=(e)=>rn(e)?32:128,ji=(e)=>qi(e)&&e._tag==="MacAddress",Df=(e)=>qi(e)&&e._tag==="InetAddressV4",Nf=(e)=>qi(e)&&e._tag==="InetAddressV6",Sx=(e)=>Df(e)||Nf(e),Hl=(e)=>qi(e)&&e._tag==="UnixPathAddress",gT=(e)=>Sx(e)||Hl(e),r1={_tag:"Ipv4Address",[jn]:jn,[ze](e){return rn(e)&&zr(this)===zr(e)},[Be](){return mo(Le(i1,zr(this)|0))},toString(){return qr(this)},toJSON(){return this.toString()},[Re](){return this.toJSON()}},o1={_tag:"Ipv6Address",[jn]:jn,[ze](e){if(!Io(e))return!1;let t=$r(this),n=$r(e);return t.w0===n.w0&&t.w1===n.w1&&t.w2===n.w2&&t.w3===n.w3},[Be](){let e=$r(this),t=Le(c1,e.w0|0);return t=Le(t,e.w1|0),t=Le(t,e.w2|0),mo(Le(t,e.w3|0))},toString(){return qr(this)},toJSON(){return this.toString()},[Re](){return this.toJSON()}},s1={_tag:"MacAddress",[jn]:jn,[ze](e){return ji(e)&&a1(Vo(this),Vo(e))},[Be](){return Le(f1,oi(Vo(this)))},toString(){return bx(this)},toJSON(){return this.toString()},[Re](){return this.toJSON()}},a1=(e,t)=>{if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;return!0},i1=mn("Ipv4Address"),c1=mn("Ipv6Address"),f1=mn("MacAddress"),u1=(e)=>{let t=Object.create(r1);return t.value=e>>>0,Object.freeze(t)},d1=(e,t,n,r)=>{let o=Object.create(o1);return o.w0=e>>>0,o.w1=t>>>0,o.w2=n>>>0,o.w3=r>>>0,Object.freeze(o)},l1=(e,t,n,r)=>(e<<24|t<<16|n<<8|r)>>>0;var Ff=(e)=>[e>>>24,e>>>16&255,e>>>8&255,e&255],p1=(e)=>{let t=Object.assign(Object.create(s1),{bytes:new Uint8Array(e)});return Object.freeze(t)};var it=(e,t)=>ge(new $i({input:e,message:t})),m1=(e)=>{if(!e.every((t)=>Number.isInteger(t)&&t>=0&&t<=255))return it(e,"octets must be integers from 0 through 255");return ue(u1(l1(e[0],e[1],e[2],e[3])))},h1=(e)=>{if(!e.every((t)=>Number.isInteger(t)&&t>=0&&t<=65535))return it(e,"segments must be integers from 0 through 65535");return ue(d1(e[0]*65536+e[1],e[2]*65536+e[3],e[4]*65536+e[5],e[6]*65536+e[7]))};var xT=(e)=>{if(!/^(?:[0-9a-fA-F]{2}:){5}[0-9a-fA-F]{2}$/.test(e))return it(e,"expected six two-digit hexadecimal octets separated by colons");return ue(p1(new Uint8Array(e.split(":").map((t)=>Number.parseInt(t,16)))))};var Wi=(e)=>{let t=e.split(".");if(t.length!==4||t.some((r)=>!/^\d{1,3}$/.test(r)))return it(e,"expected exactly four decimal octets");if(t.some((r)=>r.length>1&&r[0]==="0"))return it(e,"leading zeroes are not allowed");let n=t.map(Number);if(n.some((r)=>r>255))return it(e,"octets must be at most 255");return m1([n[0],n[1],n[2],n[3]])},g1=(e)=>{if(e.includes("[")||e.includes("]")||e.includes("%"))return it(e,"brackets and zone identifiers are not valid in a bare IPv6 address");let t=e.split("::");if(t.length>2)return it(e,"only one compression marker is allowed");let n=t[0]===""?[]:t[0].split(":"),r=t.length===2&&t[1]!==""?t[1].split(":"):[];if(n.some((u)=>u==="")||r.some((u)=>u===""))return it(e,"empty segments are only valid in the compression marker");let o=r.length>0?r[r.length-1]:n.length>0?n[n.length-1]:"",s;if(o.includes(".")){if(t.length===2&&r.length===0)return it(e,"embedded IPv4 syntax must be trailing");let u=vr(Wi(o),(d)=>{let l=zr(d);return[l>>>16,l&65535]});if(Bt(u))return u;if(s=u.success,r.length>0)r.pop();else n.pop()}let a=n.length+r.length+(s?2:0);if(t.length===1?a!==8:a>=8)return it(e,t.length===1?"expected eight segments":"compression must replace at least one segment");let i=(u)=>/^[0-9a-fA-F]{1,4}$/.test(u)?Number.parseInt(u,16):void 0,c=n.map(i),f=r.map(i);if(c.some((u)=>u===void 0)||f.some((u)=>u===void 0))return it(e,"segments must contain one through four hexadecimal digits");return ue([...c,...Array(8-a).fill(0),...f,...s??[]])},Bf=(e)=>Tt(g1(e),(t)=>h1(t)),Lf=(e)=>e.includes(":")?Bf(e):Wi(e);var Ex=(e)=>Ff(zr(e)),x1=(e)=>{let{w0:t,w1:n,w2:r,w3:o}=$r(e);return[t>>>16,t&65535,n>>>16,n&65535,r>>>16,r&65535,o>>>16,o&65535]},yT=(e)=>{let{w0:t,w1:n,w2:r,w3:o}=$r(e);return[...Ff(t),...Ff(n),...Ff(r),...Ff(o)]};var bx=(e)=>Array.from(Vo(e),(t)=>t.toString(16).padStart(2,"0")).join(":"),jl=(e)=>Vo(e).every((t)=>t===255),y1=(e)=>(Vo(e)[0]&1)!==0,Wl=(e)=>(Vo(e)[0]&1)===0,Ix=(e)=>(Vo(e)[0]&2)!==0,wx=(e)=>(Vo(e)[0]&2)===0;var qr=(e)=>{if(rn(e))return Ex(e).join(".");let t=x1(e);if(S1(e))return`::ffff:${t[6]>>8}.${t[6]&255}.${t[7]>>8}.${t[7]&255}`;let n=-1,r=0,o=-1;for(let i=0;i<=8;i++)if(i<8&&t[i]===0){if(o===-1)o=i}else if(o!==-1){if(i-o>r)n=o,r=i-o;o=-1}if(r<2)return t.map((i)=>i.toString(16)).join(":");let s=t.slice(0,n).map((i)=>i.toString(16)).join(":"),a=t.slice(n+r).map((i)=>i.toString(16)).join(":");return`${s}::${a}`},Jl=(e)=>{if(rn(e))return zr(e)===0;let{w0:t,w1:n,w2:r,w3:o}=$r(e);return t===0&&n===0&&r===0&&o===0},kx=(e)=>{if(rn(e))return zr(e)>>>24===127;let{w0:t,w1:n,w2:r,w3:o}=$r(e);return t===0&&n===0&&r===0&&o===1},Ji=(e)=>{if(ji(e))return y1(e);if(rn(e))return zr(e)>>>28===14;return $r(e).w0>>>24===255},Gl=(e)=>ji(e)?jl(e):zr(e)===4294967295,Tx=(e)=>{if(ji(e))return Wl(e);return!Ji(e)&&!Jl(e)&&(!rn(e)||!Gl(e))},Ax=(e)=>{if(rn(e))return zr(e)>>>16===43518;return($r(e).w0>>>16&65472)===65152},Cx=(e)=>{let t=zr(e);return t>>>24===10||(t>>>16&65520)===44048||t>>>16===49320},vx=(e)=>($r(e).w0>>>24&254)===252,S1=(e)=>{let{w0:t,w1:n,w2:r}=$r(e);return t===0&&n===0&&r===65535};var E1={_tag:"InetAddressV4",[jn]:jn,[ze](e){return Df(e)&&this.port===e.port&&he(this.address,e.address)},[Be](){return Le(We(this.address),Bn(this.port))},toString(){return Kl(this)},toJSON(){return this.toString()},[Re](){return this.toJSON()}},b1={_tag:"InetAddressV6",[jn]:jn,[ze](e){return Nf(e)&&this.port===e.port&&this.scopeId===e.scopeId&&he(this.address,e.address)},[Be](){return Le(Le(We(this.address),Bn(this.port)),Bn(this.scopeId))},toString(){return Kl(this)},toJSON(){return this.toString()},[Re](){return this.toJSON()}},ST=(e)=>Number.isInteger(e)&&e>=0&&e<=65535,I1=(e,t)=>{if(!ST(t))return it(e,"port must be an integer from 0 through 65535");let n=Object.create(E1);return n.address=e,n.port=t,ue(Object.freeze(n))},w1=(e,t,n)=>{if(!ST(t))return it(e,"port must be an integer from 0 through 65535");let r=n?.scopeId??0;if(!Number.isInteger(r)||r<0||r>4294967295)return it(e,"scopeId must be an unsigned 32-bit integer");let o=Object.create(b1);return o.address=e,o.port=t,o.scopeId=r,ue(Object.freeze(o))};var ET=(e)=>{let t,n,r=0,o=e.startsWith("[");if(o){let s=e.indexOf("]");if(s<0||e[s+1]!==":"||e.indexOf("]",s+1)!==-1)return it(e,"expected [IPv6]:port");t=e.slice(1,s),n=e.slice(s+2);let a=t.indexOf("%");if(a!==-1){let i=t.slice(a+1);if(t.indexOf("%",a+1)!==-1||!/^\d+$/.test(i))return it(e,"scope identifier must be decimal");if(r=Number(i),!Number.isInteger(r)||r>4294967295)return it(e,"scope identifier must be an unsigned 32-bit integer");t=t.slice(0,a)}}else{let s=e.lastIndexOf(":");if(s<0)return it(e,"expected host:port or [IPv6]:port");if(e.indexOf(":")!==s)return it(e,"IPv6 addresses must be bracketed");t=e.slice(0,s),n=e.slice(s+1)}if(!/^(0|[1-9]\d*)$/.test(n))return it(e,"port must be an unpadded decimal integer");return Tt(Lf(t),(s)=>{if(o!==Io(s))return it(e,"only IPv6 addresses use brackets");return Io(s)?w1(s,Number(n),{scopeId:r}):I1(s,Number(n))})};var k1=(e)=>qr(e.address)+(Nf(e)&&e.scopeId!==0?`%${e.scopeId}`:"");var Kl=(e)=>{let t=k1(e);return Df(e)?`${t}:${e.port}`:`[${t}]:${e.port}`};var T1={_tag:"UnixPathAddress",[jn]:jn,[ze](e){return Hl(e)&&this.path===e.path},[Be](){return Le(mn("UnixPathAddress"),mn(this.path))},toString(){return this.path},toJSON(){return this.toString()},[Re](){return this.toJSON()}},bT=(e)=>{let t=Object.create(T1);return t.path=e,Object.freeze(t)};var _x="~effect/net/IpInterface",IT=(e)=>zf(e)&&rn(e.address),wT=(e)=>zf(e)&&Io(e.address),zf=(e)=>V(e,_x),A1={_tag:"IpInterface",[_x]:_x,[ze](e){return zf(e)&&this.prefixLength===e.prefixLength&&he(this.address,e.address)},[Be](){return Le(We(this.address),Bn(this.prefixLength))},toString(){return qf(this)},toJSON(){return this.toString()},[Re](){return this.toJSON()}},Rx=(e,t)=>ge(new $i({input:e,message:t})),$f=(e,t)=>{let n=Hi(e);if(!Number.isInteger(t)||t<0||t>n)return Rx(e,`prefix length must be an integer from 0 through ${n}`);let r=Object.assign(Object.create(A1),{address:e,prefixLength:t});return ue(Object.freeze(r))},Px=(e,t)=>{let n=e.indexOf("/");if(n===-1&&t?.prefix!=="required")return ue({address:e,prefixLength:void 0});if(n<=0||n!==e.lastIndexOf("/")||n===e.length-1)return Rx(e,"expected an address and prefix length separated by one slash");let r=e.slice(n+1);if(!/^(0|[1-9][0-9]*)$/.test(r))return Rx(e,"prefix length must be an unpadded ASCII decimal integer");return ue({address:e.slice(0,n),prefixLength:Number(r)})},Vl=(e,t)=>Tt(Px(e,t),(n)=>Tt(Wi(n.address),(r)=>$f(r,n.prefixLength??Hi(r)))),Zl=(e,t)=>Tt(Px(e,t),(n)=>Tt(Bf(n.address),(r)=>$f(r,n.prefixLength??Hi(r)))),Ql=(e,t)=>Tt(Px(e,t),(n)=>Tt(Lf(n.address),(r)=>$f(r,n.prefixLength??Hi(r))));var qf=(e)=>`${qr(e.address)}/${e.prefixLength}`;var Mx="~effect/net/IpNetwork",TT=(e)=>Hf(e)&&rn(e.address),AT=(e)=>Hf(e)&&Io(e.address),Hf=(e)=>V(e,Mx),C1={_tag:"IpNetwork",[Mx]:Mx,[ze](e){return Hf(e)&&this.prefixLength===e.prefixLength&&he(this.address,e.address)},[Be](){return Le(We(this.address),Bn(this.prefixLength))},toString(){return jf(this)},toJSON(){return this.toString()},[Re](){return this.toJSON()}},v1=(e)=>{let t=Object.assign(Object.create(C1),{address:e.address,prefixLength:e.prefixLength});return Object.freeze(t)},O1=(e)=>rn(e)?Ex(e):yT(e);var _1=(e,t)=>{let n=Math.floor(t/8),r=t%8;return e.map((o,s)=>{if(s<n)return o;if(s===n&&r!==0)return o&(255<<8-r&255);return 0})},Ux=(e,t)=>Tt($f(e,t),(n)=>{let r=O1(e),o=_1(r,t);if(r.some((s,a)=>s!==o[a]))return ge(new $i({input:e,message:"address has non-zero host bits"}));return ue(v1(n))});var CT=(e)=>Tt(Vl(e,{prefix:"required"}),(t)=>Ux(t.address,t.prefixLength)),vT=(e)=>Tt(Zl(e,{prefix:"required"}),(t)=>Ux(t.address,t.prefixLength)),OT=(e)=>Tt(Ql(e,{prefix:"required"}),(t)=>Ux(t.address,t.prefixLength));var jf=(e)=>`${qr(e.address)}/${e.prefixLength}`;var Wf=vl;function Wt(){return(e,t,n)=>H(new Cs(e.map(If),(r)=>t(r.map((o)=>H(o))),n))}function we(e,t){return Wt()([],()=>(n,r,o)=>e(n)?b(n):_(new Fe(r,n,o)),t)}function P1(e){return e}function M1(e){return(t)=>t.annotate(e)}function U1(e){return(t)=>Dx(Dx(t).annotate(e))}function F1(e){return(t)=>t.rebuild(Ri(t.ast,e))}function D1(e){return e}class Rn extends Qt("SchemaError"){[zi]=zi;constructor(e){let t=HT();Fx(0);try{super({issue:e})}finally{Fx(t)}}get message(){return zI(this.issue)}toString(){return`SchemaError(${this.message})`}}function sc(e){return mT(e)}function ZT(e){if(qt(e))return jx(e);return De(e,(t)=>Os(()=>Ts(t,(n)=>new Rn(n))))}function jx(e){return $e(e)?e:en(Ts(e.cause,(t)=>new Rn(t)))}function QT(e,t){let n;for(let r of e.reasons){if(!Ld(r)||!sc(r.error))throw new globalThis.Error(t,{cause:e});n??=r.error}if(n===void 0)throw new globalThis.Error(t,{cause:e});return n}function YT(e){return Gg(e).then((t)=>{if($e(t))return t.value;throw QT(t.cause,"Promise adapter can only reject schema errors")})}function XT(e){let t=Jo(e);if($e(t))return t.value;throw QT(t.cause,"Sync adapter can only throw schema errors")}function N1(e,t){return q0(e,t)}function B1(e){return H0(e)}var L1=Vg,z1=Qk;function Ms(e,t){let n=qe(e,t);return(r,o)=>ZT(n(r,o))}var $1=Ms;function eA(e,t){let n=Yk(e,t);return(r,o)=>jx(n(r,o))}var q1=eA,H1=Qg,j1=Xk;function tA(e,t){let n=e0(e,t);return(r,o)=>qx(n(r,o),(s)=>new Rn(s))}var W1=tA;function nA(e,t){let n=Ms(e,t);return(r,o)=>YT(n(r,o))}var J1=nA;function Xl(e,t){let n=Ms(e,t);return(r,o)=>XT(n(r,o))}var Wx=Xl;function Xf(e,t){let n=Ia(e,t);return(r,o)=>ZT(n(r,o))}var Jx=Xf;function rA(e,t){let n=n0(e,t);return(r,o)=>jx(n(r,o))}var G1=rA,K1=Yg,V1=r0;function oA(e,t){let n=o0(e,t);return(r,o)=>qx(n(r,o),(s)=>new Rn(s))}var Z1=oA;function sA(e,t){let n=Xf(e,t);return(r,o)=>YT(n(r,o))}var Q1=sA;function eu(e,t){let n=Xf(e,t);return(r,o)=>XT(n(r,o))}var Y1=eu,H=Nr;function va(e){return V(e,Wf)&&e[Wf]===Wf}var Ca=nn((e)=>H(ba(e.ast),{schema:e})),X1=nn((e)=>e.schema),mt=nn((e)=>{let t=np(e);return H(vk(e.ast),{schema:t})}),eB=nn((e)=>e.schema.members[0]),tB=nn((e)=>H(Fg(e.ast),{schema:e})),nB=nn((e)=>e.schema),Pn=nn((e)=>H(Ve(e.ast),{schema:e})),ac=nn((e)=>H(En(e.ast),{schema:e})),Jf="~effect/Schema/flip";function rB(e){return V(e,Jf)&&e[Jf]===Jf}function Dx(e){if(rB(e))return e.schema.rebuild(qn(e.ast));return H(qn(e.ast),{[Jf]:Jf,schema:e})}function pt(e){let t=H(new yn(e),{literal:e,transform(n){return t.pipe(Z(pt(n),{decode:se(()=>n),encode:se(()=>e)}))}});return t}function aA(e){return e.map((t)=>va(t)?t.ast:new yn(t))}function oB(e){return H(new kg(aA(e)),{parts:e})}function sB(e){return H(ck(aA(e)),{parts:e})}function aB(e){return H(new ik(Object.keys(e).filter((t)=>typeof e[e[t]]!=="number").map((t)=>[t,e[t]])),{enums:e})}var tu=H(wg),iB=H(sk),nu=H(jo),ep=H(bg),Gx=H(Ig),z=H($n),cB=z,Oa=H(Tg),ru=H(dk),iA=H(lk),ic=H(pk),cc=H(ok),fB=H(ak);function uB(e){return H(new uk(e))}function Kx(e,t){return H(e,{fields:t,mapFields(n,r){let o=n(this.fields);return Kx(ll(o,r?.unsafePreserveChecks?this.ast.checks:void 0),o)}})}function ae(e){return Kx(ll(e,void 0),e)}function dB(e){return nn((t)=>t.mapFields(nT(e)))}var lB=(e)=>typeof e==="symbol"?e:globalThis.String(e);function pB(e){return function(t){let n={},r=Object.create(null),o=Object.create(null),s=new Set;for(let a of Reflect.ownKeys(t.fields)){let i=ac(t.fields[a]),c=Object.hasOwn(e,a),f=c?e[a]:a,u=lB(f);if(s.has(u))throw new globalThis.Error(`Duplicate encoded keys: ${Sa(f)}`);if(s.add(u),q(n,f,i),c)r[a]=f,o[f]=a}return ae(n).pipe(Z(t,xe({decode:hx(o),encode:hx(r)})))}}function mB(e,t){return(n)=>{let r=Cd(n.fields,Pn),o=ae({...r,...e});return n.pipe(Z(o,xe({decode:(s)=>{let a={...s};for(let i in e){let c=t[i],f=c(s);if(ve(f))q(a,i,f.value)}return a},encode:(s)=>{let a={...s};for(let i in e)delete a[i];return a}})))}}function _a(e,t){return H(_k(e.ast,t.ast),{key:e,value:t})}function hB(e,t){return H(yk(e.ast,t.map(If)),{schema:e,records:t})}function cA(e,t){return H(e,{elements:t,mapElements(n,r){let o=n(this.elements);return cA(Og(o,r?.unsafePreserveChecks?this.ast.checks:void 0),o)}})}function cr(e){return cA(Og(e),e)}function gB(e,t){return H(Sk(e.ast,t.map(If)),{schema:e,rest:t})}var Oe=nn((e)=>H(new ar(!1,[],[e.ast]),{value:e}));function tp(e,t,n){if(t!==void 0&&n!==void 0)return e.check(Xx(t,n));if(t!==void 0)return e.check(vA(t));if(n!==void 0)return e.check(RA(n));return e}var fc=nn((e)=>H(new ar(!1,[e.ast],[e.ast]),{value:e}));function xB(e){let t=Oe(e),n=Oe(Pn(e)),r=Z(cr([nu]),xe({decode:(o)=>[o],encode:([o])=>o}))(e);return H(Ie([r,t]).pipe(Z(n)).ast,{from:Ie([e,t]),to:n})}function yB(e){return Oe(e).check(ty())}var SB=nn((e)=>H(Ek(e.ast),{schema:e}));function fA(e,t){return H(e,{members:t,mapMembers(n,r){let o=n(this.members);return fA(pl(o,this.ast.options,r?.unsafePreserveChecks?this.ast.checks:void 0),o)}})}function Ie(e,t){return fA(pl(e,t,void 0),e)}function ur(e){let t=e.map(pt);return H(pl(t,void 0,void 0),{literals:e,members:t,mapMembers(n){return Ie(n(this.members))},pick(n){return ur(n)},transform(n){return Ie(t.map((r,o)=>r.transform(n[o])))}})}var Vx=nn((e)=>Ie([e,ep])),np=nn((e)=>Ie([e,Gx])),uA=nn((e)=>Ie([e,ep,Gx]));function dA(e){return H(new Rg(()=>e().ast))}function EB(...e){return(t)=>t.check(...e)}function lA(e,t){return(n)=>H(Eo(n.ast,[hl(e,t)]),{schema:n})}function pA(e){return(t)=>H(t.ast,{schema:t,identifier:e})}function bB(e,t){return(n)=>(t.checks?n.check(...t.checks):n).pipe(pA(e))}function mA(e){return(t)=>H(Ak(t.ast,new Qd(e,Q)),{schema:t})}function hA(e){return(t)=>H(Ck(t.ast,new Qd(Q,e)),{schema:t})}function IB(e){return gA(e)}function gA(e){return(t)=>mA(Hx(e))(t)}function wB(e){return xA(e)}function xA(e){return(t)=>hA(Hx(e))(t)}function Z(e,t){return(n)=>H(Pi(n.ast,e.ast,t?Yd(t):Ii()),{from:n,to:e})}function uc(){return(e,t)=>Se()(e,{decode:t,encode:ZI})}var yA=ur(["true","yes","on","1","y"]),SA=ur(["false","no","off","0","n"]),kB=ur([...yA.literals,...SA.literals]).pipe(Z(ru,xe({decode:(e)=>e==="true"||e==="yes"||e==="on"||e==="1"||e==="y",encode:(e)=>e?"true":"false"})));function TB(e){return(t)=>Z(Pn(t),e)(t)}function Zx(e,t){return(n)=>t?Z(n,t)(e):Z(n)(e)}function AB(e){return(t)=>Z(t,e)(ac(t))}function EA(e){return(t)=>H(Ok(t.ast,e),{schema:t})}function bA(e){return De(e,(t)=>Os(()=>Ts(t,(n)=>n.issue)))}function Qx(e,t){let n=t?.encodingStrategy==="omit"?tg():xo();return(r)=>Ca(ac(r)).pipe(Z(r,{decode:ng(bA(e)),encode:n}))}function CB(e,t){return(n)=>Pn(n).pipe(Qx(e,t),Zx(Ca(n)))}function IA(e,t){let n=t?.encodingStrategy==="omit"?tg():xo();return(r)=>mt(ac(r)).pipe(Z(r,{decode:ng(bA(e)),encode:n}))}function vB(e,t){return(n)=>Pn(n).pipe(IA(e,t),Zx(mt(n)))}function ye(e){return pt(e).pipe(EA(b(e)))}function OB(e){return ye(e).pipe(Qx(b(e),{encodingStrategy:"omit"}))}function rp(e,t){return ae({_tag:ye(e),...t})}function wA(e){return(t)=>{let n={},r=[],o=new Set,s={},a=(u)=>(d)=>u.includes(d[e]);return i(t),Object.assign(t,{cases:n,discriminants:r,isAnyOf:a,guards:s,match:c,matchOrElse:f});function i(u){let d=u.ast;if(tk(d)&&"members"in u&&globalThis.Array.isArray(u.members)&&u.members.every(va))return u.members.forEach(i);let l=ks(d);if(l.length>0){let m=l.find((p)=>p.key===e)?.literal;if(il(m)){let p=typeof m==="number"?globalThis.String(m):m;if(o.has(p))throw new globalThis.Error(`Duplicate discriminant: ${globalThis.String(m)}`);o.add(p),r.push(m),q(n,m,u),q(s,m,Vg(Pn(u)));return}}throw new globalThis.Error("No literal or unique symbol found")}function c(){if(arguments.length===1){let p=arguments[0];return function(g){let h=g[e];return(Object.hasOwn(p,h)?p[h]:void 0)(g)}}let u=arguments[0],d=arguments[1],l=u[e];return(Object.hasOwn(d,l)?d[l]:void 0)(u)}function f(){if(arguments.length===2){let g=arguments[0],h=arguments[1];return function(E){let S=E[e];return(Object.hasOwn(g,S)?g[S]??h:h)(E)}}let u=arguments[0],d=arguments[1],l=arguments[2],m=u[e];return(Object.hasOwn(d,m)?d[m]??l:l)(u)}}}function _B(e){let t={},n=[];for(let c of Object.keys(e)){let f=rp(c,e[c]);q(t,c,f),n.push(f)}let r=Ie(n),{guards:o,isAnyOf:s,match:a,matchOrElse:i}=wA("_tag")(r);return H(r.ast,{cases:t,isAnyOf:s,guards:o,match:a,matchOrElse:i})}function RB(){return(e)=>e}function Us(e,t){return we((n)=>n instanceof e,t)}function Se(){return(e,t)=>new Xe(e.ast,Yd(t))}var ke=ml;function PB(e,t=void 0){return new ga(e,t)}var _T="^\\S[\\s\\S]*\\S$|^\\S$|^$";function kA(e){let t=new globalThis.RegExp(_T);return ke((n)=>n.trim()===n,{expected:"a string with no leading or trailing whitespace",representation:{id:"effect/schema/isTrimmed",payload:null},toJsonSchema:()=>({pattern:t.source}),toCode:()=>({runtime:"Schema.isTrimmed()"}),arbitraryConstraint:{patterns:[{source:_T,flags:""}]},...e})}function dc(e,t){let{source:n,flags:r}=e,o=/^[dg]*uy?$/.test(r),s=r===""?`new RegExp(${K(n)})`:`new RegExp(${K(n)}, ${K(r)})`;return kf(e,{toJsonSchema:()=>o?{pattern:r.endsWith("y")?`^(?:${n})`:n}:[{},!0],toCode:()=>({runtime:`Schema.isPattern(${s})`}),...t})}function MB(e){return Bg({toCode:()=>({runtime:"Schema.isStringFinite()"}),...e})}function UB(e){return Lg({toCode:()=>({runtime:"Schema.isStringBigInt()"}),...e})}function FB(e){return $g({toCode:()=>({runtime:"Schema.isStringSymbol()"}),...e})}var DB=(e)=>{if(e)return new globalThis.RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${e}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`);return/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|[fF]{8}-[fF]{4}-[fF]{4}-[fF]{4}-[fF]{12})$/};function NB(e,t){let n=DB(e);return dc(n,{expected:e?`a UUID v${e}`:"a UUID",representation:{id:"effect/schema/isUUID",payload:{version:e??null}},toJsonSchema:()=>({pattern:n.source,format:"uuid"}),toCode:()=>({runtime:e===void 0?"Schema.isUUID()":`Schema.isUUID(${e})`}),...t})}var RT=/^([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})$/;function BB(e){return dc(RT,{expected:"a GUID",representation:{id:"effect/schema/isGUID",payload:null},toJsonSchema:()=>({pattern:RT.source}),toCode:()=>({runtime:"Schema.isGUID()"}),...e})}function LB(e){let t=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/;return dc(t,{representation:{id:"effect/schema/isULID",payload:null},toJsonSchema:()=>({pattern:t.source}),toCode:()=>({runtime:"Schema.isULID()"}),...e})}function TA(e){let t=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/;return dc(t,{expected:"a base64 encoded string",representation:{id:"effect/schema/isBase64",payload:null},toJsonSchema:()=>({pattern:t.source}),toCode:()=>({runtime:"Schema.isBase64()"}),...e})}function zB(e){let t=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/;return dc(t,{expected:"a base64url encoded string",representation:{id:"effect/schema/isBase64Url",payload:null},toJsonSchema:()=>({pattern:t.source}),toCode:()=>({runtime:"Schema.isBase64Url()"}),...e})}function Yx(e,t,n){if(e.length===0)return t.length===0?{}:[{},!0];let r={pattern:new globalThis.RegExp(n).source};return e===t?r:[r,!0]}function $B(e,t){let n=JSON.stringify(e),r=new globalThis.RegExp(`^${Ko(e)}`),o=e.replace(/[\uD800-\uDBFF]$/,"");return ke((s)=>s.startsWith(e),{expected:`a string starting with ${n}`,representation:{id:"effect/schema/isStartingWith",payload:{startsWith:e}},toJsonSchema:()=>Yx(o,e,`^${Ko(o)}`),toCode:()=>({runtime:`Schema.isStartingWith(${K(e)})`}),arbitraryConstraint:{patterns:[{source:r.source,flags:r.flags}]},...t})}function qB(e,t){let n=JSON.stringify(e),r=new globalThis.RegExp(`${Ko(e)}$`),o=e.replace(/^[\uDC00-\uDFFF]/,"");return ke((s)=>s.endsWith(e),{expected:`a string ending with ${n}`,representation:{id:"effect/schema/isEndingWith",payload:{endsWith:e}},toJsonSchema:()=>Yx(o,e,`${Ko(o)}$`),toCode:()=>({runtime:`Schema.isEndingWith(${K(e)})`}),arbitraryConstraint:{patterns:[{source:r.source,flags:r.flags}]},...t})}function HB(e,t){let n=JSON.stringify(e),r=new globalThis.RegExp(Ko(e)),o=e.replace(/^[\uDC00-\uDFFF]|[\uD800-\uDBFF]$/g,"");return ke((s)=>s.includes(e),{expected:`a string including ${n}`,representation:{id:"effect/schema/isIncluding",payload:{includes:e}},toJsonSchema:()=>Yx(o,e,Ko(o)),toCode:()=>({runtime:`Schema.isIncluding(${K(e)})`}),arbitraryConstraint:{patterns:[{source:r.source,flags:r.flags}]},...t})}var PT="^[^a-z]*$";function jB(e){let t=new globalThis.RegExp(PT);return ke((n)=>n.toUpperCase()===n,{expected:"a string with all characters in uppercase",representation:{id:"effect/schema/isUppercased",payload:null},toJsonSchema:()=>[{pattern:t.source},!0],toCode:()=>({runtime:"Schema.isUppercased()"}),arbitraryConstraint:{patterns:[{source:PT,flags:""}]},...e})}var MT="^[^A-Z]*$";function WB(e){let t=new globalThis.RegExp(MT);return ke((n)=>n.toLowerCase()===n,{expected:"a string with all characters in lowercase",representation:{id:"effect/schema/isLowercased",payload:null},toJsonSchema:()=>[{pattern:t.source},!0],toCode:()=>({runtime:"Schema.isLowercased()"}),arbitraryConstraint:{patterns:[{source:MT,flags:""}]},...e})}var UT="^(?:[^a-z][\\s\\S]*)?$";function JB(e){let t=new globalThis.RegExp(UT);return ke((n)=>n.charAt(0).toUpperCase()===n.charAt(0),{expected:"a string with the first character in uppercase",representation:{id:"effect/schema/isCapitalized",payload:null},toJsonSchema:()=>[{pattern:t.source},!0],toCode:()=>({runtime:"Schema.isCapitalized()"}),arbitraryConstraint:{patterns:[{source:UT,flags:""}]},...e})}var FT="^(?:[^A-Z][\\s\\S]*)?$";function GB(e){let t=new globalThis.RegExp(FT);return ke((n)=>n.charAt(0).toLowerCase()===n.charAt(0),{expected:"a string with the first character in lowercase",representation:{id:"effect/schema/isUncapitalized",payload:null},toJsonSchema:()=>[{pattern:t.source},!0],toCode:()=>({runtime:"Schema.isUncapitalized()"}),arbitraryConstraint:{patterns:[{source:FT,flags:""}]},...e})}var op=H(Mg),KB=Pg;function ou(e){let t=id(e.order),n=e.formatter??K;return(r,o)=>ke((s)=>t(s,r),{expected:`a value greater than ${n(r)}`,arbitraryConstraint:{order:e.order,minimum:r,exclusiveMinimum:!0},...e.annotate?.(r),...o})}function su(e){let t=fd(e.order),n=e.formatter??K;return(r,o)=>ke((s)=>t(s,r),{expected:`a value greater than or equal to ${n(r)}`,arbitraryConstraint:{order:e.order,minimum:r},...e.annotate?.(r),...o})}function au(e){let t=ad(e.order),n=e.formatter??K;return(r,o)=>ke((s)=>t(s,r),{expected:`a value less than ${n(r)}`,arbitraryConstraint:{order:e.order,maximum:r,exclusiveMaximum:!0},...e.annotate?.(r),...o})}function iu(e){let t=cd(e.order),n=e.formatter??K;return(r,o)=>ke((s)=>t(s,r),{expected:`a value less than or equal to ${n(r)}`,arbitraryConstraint:{order:e.order,maximum:r},...e.annotate?.(r),...o})}function cu(e){let t=fd(e.order),n=id(e.order),r=cd(e.order),o=ad(e.order),s=e.formatter??K;return(a,i)=>{let c=a.exclusiveMinimum?n:t,f=a.exclusiveMaximum?o:r;return ke((u)=>c(u,a.minimum)&&f(u,a.maximum),{expected:`a value between ${s(a.minimum)}${a.exclusiveMinimum?" (excluded)":""} and ${s(a.maximum)}${a.exclusiveMaximum?" (excluded)":""}`,arbitraryConstraint:{order:e.order,minimum:a.minimum,maximum:a.maximum,...a.exclusiveMinimum&&{exclusiveMinimum:!0},...a.exclusiveMaximum&&{exclusiveMaximum:!0}},...e.annotate?.(a),...i})}}function VB(e){return(t,n)=>{let r=e.formatter??K;return ke((o)=>e.remainder(o,t)===e.zero,{expected:`a value that is a multiple of ${r(t)}`,...e.annotate?.(t),...n})}}function Gi(e){if(!globalThis.Number.isFinite(e))throw new globalThis.RangeError(`Expected a finite number, got ${K(e)}`);return e}var ZB=ou({order:Zi,annotate:(e)=>({representation:{id:"effect/schema/isGreaterThan",payload:{exclusiveMinimum:Gi(e)}},toJsonSchema:()=>({exclusiveMinimum:e}),toCode:()=>({runtime:`Schema.isGreaterThan(${K(e)})`})})}),AA=su({order:Zi,annotate:(e)=>({representation:{id:"effect/schema/isGreaterThanOrEqualTo",payload:{minimum:Gi(e)}},toJsonSchema:()=>({minimum:e}),toCode:()=>({runtime:`Schema.isGreaterThanOrEqualTo(${K(e)})`})})}),QB=au({order:Zi,annotate:(e)=>({representation:{id:"effect/schema/isLessThan",payload:{exclusiveMaximum:Gi(e)}},toJsonSchema:()=>({exclusiveMaximum:e}),toCode:()=>({runtime:`Schema.isLessThan(${K(e)})`})})}),YB=iu({order:Zi,annotate:(e)=>({representation:{id:"effect/schema/isLessThanOrEqualTo",payload:{maximum:Gi(e)}},toJsonSchema:()=>({maximum:e}),toCode:()=>({runtime:`Schema.isLessThanOrEqualTo(${K(e)})`})})}),sp=cu({order:Zi,annotate:(e)=>{let t=e.exclusiveMinimum?!0:void 0,n=e.exclusiveMaximum?!0:void 0;return{representation:{id:"effect/schema/isBetween",payload:{minimum:Gi(e.minimum),maximum:Gi(e.maximum),...t&&{exclusiveMinimum:t},...n&&{exclusiveMaximum:n}}},toJsonSchema:()=>({[t?"exclusiveMinimum":"minimum"]:e.minimum,[n?"exclusiveMaximum":"maximum"]:e.maximum}),toCode:()=>({runtime:`Schema.isBetween({ minimum: ${K(e.minimum)}, maximum: ${K(e.maximum)}, exclusiveMinimum: ${K(t)}, exclusiveMaximum: ${K(n)} })`})}}});function XB(e,t){if(!globalThis.Number.isFinite(e)||e===0)throw new globalThis.RangeError(`Expected a finite non-zero number, got ${globalThis.String(e)}`);return e=globalThis.Math.abs(e),ke((n)=>VT(n,e)===0,{expected:`a value that is a multiple of ${e}`,representation:{id:"effect/schema/isMultipleOf",payload:{divisor:e}},toJsonSchema:()=>({multipleOf:e}),toCode:()=>({runtime:`Schema.isMultipleOf(${K(e)})`}),...t})}function ap(e){return ke((t)=>globalThis.Number.isSafeInteger(t),{expected:"an integer",representation:{id:"effect/schema/isInt",payload:null},toJsonSchema:()=>[{type:"integer"},!0],toCode:()=>({runtime:"Schema.isInt()"}),arbitraryConstraint:{number:"integer"},...e})}var wo=Oa.check(ap()),Aa=wo.check(AA(0));function eL(e){return new ga([ap(),sp({minimum:-2147483648,maximum:2147483647})],{expected:"a 32-bit integer",...e})}function tL(e){return new ga([ap(),sp({minimum:0,maximum:4294967295})],{expected:"a 32-bit unsigned integer",...e})}function Ki(e){if(globalThis.Number.isNaN(e.getTime()))throw new globalThis.RangeError(`Expected a valid Date, got ${K(e)}`);return e.toISOString()}function Vi(e){return`new Date(${K(e.getTime())})`}var nL=ou({order:Yi,annotate:(e)=>({representation:{id:"effect/schema/isGreaterThanDate",payload:{exclusiveMinimum:Ki(e)}},toJsonSchema:()=>[{},!0],toCode:()=>({runtime:`Schema.isGreaterThanDate(${Vi(e)})`})})}),rL=su({order:Yi,annotate:(e)=>({representation:{id:"effect/schema/isGreaterThanOrEqualToDate",payload:{minimum:Ki(e)}},toJsonSchema:()=>[{},!0],toCode:()=>({runtime:`Schema.isGreaterThanOrEqualToDate(${Vi(e)})`})})}),oL=au({order:Yi,annotate:(e)=>({representation:{id:"effect/schema/isLessThanDate",payload:{exclusiveMaximum:Ki(e)}},toJsonSchema:()=>[{},!0],toCode:()=>({runtime:`Schema.isLessThanDate(${Vi(e)})`})})}),sL=iu({order:Yi,annotate:(e)=>({representation:{id:"effect/schema/isLessThanOrEqualToDate",payload:{maximum:Ki(e)}},toJsonSchema:()=>[{},!0],toCode:()=>({runtime:`Schema.isLessThanOrEqualToDate(${Vi(e)})`})})}),aL=cu({order:Yi,annotate:(e)=>{let t=e.exclusiveMinimum?!0:void 0,n=e.exclusiveMaximum?!0:void 0;return{representation:{id:"effect/schema/isBetweenDate",payload:{minimum:Ki(e.minimum),maximum:Ki(e.maximum),...t&&{exclusiveMinimum:t},...n&&{exclusiveMaximum:n}}},toJsonSchema:()=>[{},!0],toCode:()=>({runtime:`Schema.isBetweenDate({ minimum: ${Vi(e.minimum)}, maximum: ${Vi(e.maximum)}, exclusiveMinimum: ${K(t)}, exclusiveMaximum: ${K(n)} })`})}}}),iL=ou({order:Qi,annotate:(e)=>({representation:{id:"effect/schema/isGreaterThanBigInt",payload:{exclusiveMinimum:e.toString(10)}},toJsonSchema:()=>[{},!0],toCode:()=>({runtime:`Schema.isGreaterThanBigInt(${K(e)})`})})}),CA=su({order:Qi,annotate:(e)=>({representation:{id:"effect/schema/isGreaterThanOrEqualToBigInt",payload:{minimum:e.toString(10)}},toJsonSchema:()=>[{},!0],toCode:()=>({runtime:`Schema.isGreaterThanOrEqualToBigInt(${K(e)})`})})}),cL=au({order:Qi,annotate:(e)=>({representation:{id:"effect/schema/isLessThanBigInt",payload:{exclusiveMaximum:e.toString(10)}},toJsonSchema:()=>[{},!0],toCode:()=>({runtime:`Schema.isLessThanBigInt(${K(e)})`})})}),fL=iu({order:Qi,annotate:(e)=>({representation:{id:"effect/schema/isLessThanOrEqualToBigInt",payload:{maximum:e.toString(10)}},toJsonSchema:()=>[{},!0],toCode:()=>({runtime:`Schema.isLessThanOrEqualToBigInt(${K(e)})`})})}),uL=cu({order:Qi,annotate:(e)=>{let t=e.exclusiveMinimum?!0:void 0,n=e.exclusiveMaximum?!0:void 0;return{representation:{id:"effect/schema/isBetweenBigInt",payload:{minimum:e.minimum.toString(10),maximum:e.maximum.toString(10),...t&&{exclusiveMinimum:t},...n&&{exclusiveMaximum:n}}},toJsonSchema:()=>[{},!0],toCode:()=>({runtime:`Schema.isBetweenBigInt({ minimum: ${K(e.minimum)}, maximum: ${K(e.maximum)}, exclusiveMinimum: ${K(t)}, exclusiveMaximum: ${K(n)} })`})}}});function vA(e,t){return e=on(e),OA(e,Math.ceil(e/2),t)}function OA(e,t,n){return ke((r)=>r.length>=e,{expected:`a value with a length of at least ${e}`,representation:{id:"effect/schema/isMinLength",payload:{minLength:e}},toJsonSchema:({type:r})=>r==="string"?e<=1?{minLength:t}:[{minLength:t},!0]:r==="array"?{minItems:e}:r===void 0?[{minLength:t,minItems:e},!0]:[{},!0],toCode:()=>({runtime:`Schema.isMinLength(${e})`}),[An]:!0,arbitraryConstraint:{minLength:e},...n})}function _A(e){return OA(1,1,e)}function RA(e,t){return e=on(e),ke((n)=>n.length<=e,{expected:`a value with a length of at most ${e}`,representation:{id:"effect/schema/isMaxLength",payload:{maxLength:e}},toJsonSchema:({type:n})=>n==="string"?e===0?{maxLength:e}:[{maxLength:e},!0]:n==="array"?{maxItems:e}:n===void 0?[{maxLength:e,maxItems:e},!0]:[{},!0],toCode:()=>({runtime:`Schema.isMaxLength(${e})`}),[An]:!0,arbitraryConstraint:{maxLength:e},...t})}function Xx(e,t,n){return e=on(e),t=on(t),ke((r)=>r.length>=e&&r.length<=t,{expected:e===t?`a value with a length of ${e}`:`a value with a length between ${e} and ${t}`,representation:{id:"effect/schema/isBetweenLength",payload:{minimum:e,maximum:t}},toJsonSchema:({type:r})=>r==="string"?t===0||Math.ceil(e/2)>t?{minLength:Math.ceil(e/2),maxLength:t}:[{minLength:Math.ceil(e/2),maxLength:t},!0]:r==="array"?{minItems:e,maxItems:t}:r===void 0?[{minLength:Math.ceil(e/2),maxLength:t,minItems:e,maxItems:t},!0]:[{},!0],toCode:()=>({runtime:`Schema.isBetweenLength(${e}, ${t})`}),[An]:!0,arbitraryConstraint:{minLength:e,maxLength:t},...n})}function dL(e,t){return e=on(e),ke((n)=>ey(n,e)>=e,{expected:`a string with at least ${e} code points`,representation:{id:"effect/schema/isMinCodePoints",payload:{minCodePoints:e}},toJsonSchema:()=>({minLength:e}),toCode:()=>({runtime:`Schema.isMinCodePoints(${e})`}),arbitraryConstraint:{minCodePoints:e},...t})}function lL(e,t){return e=on(e),ke((n)=>ey(n,e+1)<=e,{expected:`a string with at most ${e} code points`,representation:{id:"effect/schema/isMaxCodePoints",payload:{maxCodePoints:e}},toJsonSchema:()=>({maxLength:e}),toCode:()=>({runtime:`Schema.isMaxCodePoints(${e})`}),arbitraryConstraint:{maxCodePoints:e},...t})}function pL(e,t,n){return e=on(e),t=on(t),ke((r)=>{let o=ey(r,t+1);return o>=e&&o<=t},{expected:e===t?`a string with ${e} code points`:`a string with between ${e} and ${t} code points`,representation:{id:"effect/schema/isBetweenCodePoints",payload:{minimum:e,maximum:t}},toJsonSchema:()=>({allOf:[{minLength:e},{maxLength:t}]}),toCode:()=>({runtime:`Schema.isBetweenCodePoints(${e}, ${t})`}),arbitraryConstraint:{minCodePoints:e,maxCodePoints:t},...n})}function ey(e,t){if(t===0)return 0;let n=0;for(let r of e)if(++n>=t)break;return n}function on(e){if(!globalThis.Number.isFinite(e))throw new globalThis.RangeError(`Expected a finite number, got ${e}`);return Math.max(0,Math.floor(e))}function mL(e,t){return e=on(e),ke((n)=>n.size>=e,{expected:`a value with a size of at least ${e}`,representation:{id:"effect/schema/isMinSize",payload:{minSize:e}},toJsonSchema:()=>[{},!0],toCode:()=>({runtime:`Schema.isMinSize(${e})`}),[An]:!0,arbitraryConstraint:{minSize:e},...t})}function hL(e,t){return e=on(e),ke((n)=>n.size<=e,{expected:`a value with a size of at most ${e}`,representation:{id:"effect/schema/isMaxSize",payload:{maxSize:e}},toJsonSchema:()=>[{},!0],toCode:()=>({runtime:`Schema.isMaxSize(${e})`}),[An]:!0,arbitraryConstraint:{maxSize:e},...t})}function gL(e,t,n){return e=on(e),t=on(t),ke((r)=>r.size>=e&&r.size<=t,{expected:e===t?`a value with a size of ${e}`:`a value with a size between ${e} and ${t}`,representation:{id:"effect/schema/isBetweenSize",payload:{minimum:e,maximum:t}},toJsonSchema:()=>[{},!0],toCode:()=>({runtime:`Schema.isBetweenSize(${e}, ${t})`}),[An]:!0,arbitraryConstraint:{minSize:e,maxSize:t},...n})}function xL(e,t){return e=on(e),ke((n)=>Reflect.ownKeys(n).length>=e,{expected:`a value with at least ${e===1?"1 entry":`${e} entries`}`,representation:{id:"effect/schema/isMinProperties",payload:{minProperties:e}},toJsonSchema:({type:n})=>n==="object"?{minProperties:e}:[{minProperties:e},!0],toCode:()=>({runtime:`Schema.isMinProperties(${e})`}),[An]:!0,arbitraryConstraint:{minProperties:e},...t})}function yL(e,t){return e=on(e),ke((n)=>Reflect.ownKeys(n).length<=e,{expected:`a value with at most ${e===1?"1 entry":`${e} entries`}`,representation:{id:"effect/schema/isMaxProperties",payload:{maxProperties:e}},toJsonSchema:({type:n})=>n==="object"?{maxProperties:e}:[{maxProperties:e},!0],toCode:()=>({runtime:`Schema.isMaxProperties(${e})`}),[An]:!0,arbitraryConstraint:{maxProperties:e},...t})}function SL(e,t,n){return e=on(e),t=on(t),ke((r)=>Reflect.ownKeys(r).length>=e&&Reflect.ownKeys(r).length<=t,{expected:e===t?`a value with exactly ${e===1?"1 entry":`${e} entries`}`:`a value with between ${e} and ${t} entries`,representation:{id:"effect/schema/isBetweenProperties",payload:{minimum:e,maximum:t}},toJsonSchema:({type:r})=>r==="object"?{minProperties:e,maxProperties:t}:[{minProperties:e,maxProperties:t},!0],toCode:()=>({runtime:`Schema.isBetweenProperties(${e}, ${t})`}),[An]:!0,arbitraryConstraint:{minProperties:e,maxProperties:t},...n})}function EL(e,t){let n=ac(e),r=Zk(n.ast);return ke((o,s,a)=>{let i=Reflect.ownKeys(o),c=[];for(let f of i){let u=r(f,a);if(u!==void 0){if(c.push(new Qe([f],u)),a.errors==="first")break}}if(Sn(c))return new tt(s,c,o,a);return!0},{expected:"an object with property names matching the schema",representation:{id:"effect/schema/isPropertyNames",payload:null,schemas:[n.ast]},toJsonSchema:({schemas:o,type:s})=>s==="object"?{propertyNames:o[0]}:[{propertyNames:o[0]},!0],toCode:({schemas:o})=>({runtime:`Schema.isPropertyNames(${o[0].runtime})`}),[An]:!0,...t})}function ty(e){return ke((t)=>hd(t).length===t.length,{expected:"an array with unique items",representation:{id:"effect/schema/isUnique",payload:null},toJsonSchema:()=>({uniqueItems:!0}),toCode:()=>({runtime:"Schema.isUnique()"}),arbitraryConstraint:{uniqueBy:Q},...e})}function PA(e){return ke((t)=>hd(t.map(([n])=>n)).length===t.length,{expected:"an array with unique keys",representation:{id:"effect/schema/isUniqueKey",payload:null},toCode:()=>({runtime:"Schema.isUniqueKey()"}),arbitraryConstraint:{uniqueBy:(t)=>t[0]},...e})}var bL=z.check(_A()),IL=z.check(Xx(1,1)),MA=(e)=>(e?.includeStack===!0?1:0)|(e?.excludeCause===!0?2:0),UA=(e)=>{switch(e){case 0:return;case 1:return{includeStack:!0};case 2:return{excludeCause:!0};case 3:return{includeStack:!0,excludeCause:!0}}},DT=[];function wL(e){let t=MA(e),n=DT[t];if(n!==void 0)return n;let r=UA(t),o=Us(globalThis.Error,{representation:{id:"effect/schema/Error",payload:r??null},toCode:()=>({runtime:r!==void 0?`Schema.ErrorInstance(${K(r)})`:"Schema.ErrorInstance()",Type:"globalThis.Error"}),expected:"Error",toCodecJson:()=>Se()(jz,vw(r))});return DT[t]=o,o}var NT=[];function bt(e){let t=MA(e),n=NT[t];if(n!==void 0)return n;let r=pp.pipe(Z(nu,Ow(UA(t))));return NT[t]=r,r}function kL(e,t){let n=Wt()([e,t],([r,o])=>{let s=Oe(cr([r,o]));return(a,i,c)=>{if(a instanceof globalThis.Map)return Ht(qe(s)([...a],c),{onSuccess:(f)=>new globalThis.Map(f),onFailure:(f)=>vn(i,"entries",f,a,c)});return _(new Fe(i,a,c))}},{representation:{id:"effect/schema/ReadonlyMap",payload:null},toCode:({typeParameters:r})=>({runtime:`Schema.ReadonlyMap(${r[0].runtime}, ${r[1].runtime})`,Type:`globalThis.ReadonlyMap<${r[0].Type}, ${r[1].Type}>`}),expected:"ReadonlyMap",toCodec:([r,o])=>Se()(Oe(cr([r,o])),xe({decode:(s)=>new globalThis.Map(s),encode:(s)=>[...s.entries()]}))});return H(n.ast,{key:e,value:t})}function TL(e){let t=Wt()([e],([n])=>{let r=Oe(n);return(o,s,a)=>{if(o instanceof globalThis.Set)return Ht(qe(r)([...o],a),{onSuccess:(i)=>new globalThis.Set(i),onFailure:(i)=>vn(s,"values",i,o,a)});return _(new Fe(s,o,a))}},{representation:{id:"effect/schema/ReadonlySet",payload:null},toCode:({typeParameters:n})=>({runtime:`Schema.ReadonlySet(${n[0].runtime})`,Type:`globalThis.ReadonlySet<${n[0].Type}>`}),expected:"ReadonlySet",toCodec:([n])=>Se()(Oe(n),xe({decode:(r)=>new globalThis.Set(r),encode:(r)=>[...r.values()]}))});return H(t.ast,{value:e})}var AL=Us(globalThis.RegExp,{representation:{id:"effect/schema/RegExp",payload:null},toCode:()=>({runtime:"Schema.RegExp",Type:"globalThis.RegExp"}),expected:"RegExp",toCodecJson:()=>Se()(ae({source:z,flags:z}),Et({decode:(e,t)=>Mr({try:()=>new globalThis.RegExp(e.source,e.flags),catch:()=>new te({expected:"valid RegExp source and flags"},e,t)}),encode:(e)=>b({source:e.source,flags:e.flags})}))}),FA=z.annotate({expected:"a string that will be decoded as a URL"}),DA=Us(globalThis.URL,{representation:{id:"effect/schema/URL",payload:null},toCode:()=>({runtime:"Schema.URL",Type:"globalThis.URL"}),expected:"URL",toCodecJson:()=>Se()(FA,cg)}),CL=FA.pipe(Z(DA,cg)),NA=z.annotate({expected:"a string that will be decoded as a Date"}),ip=we((e)=>e instanceof globalThis.Date&&!globalThis.Number.isNaN(e.getTime()),{representation:{id:"effect/schema/Date",payload:null},toCode:()=>({runtime:"Schema.Date",Type:"globalThis.Date"}),expected:"a valid Date",toCodecJson:()=>Se()(NA,ag)}),vL=NA.pipe(Z(ip,ag)),OL=wo.pipe(Z(ip,Iw)),_L=z.annotate({expected:"a string that will be decoded as JSON",contentMediaType:"application/json"});function ny(e,t){return _L.pipe(Z(e,Lw(t)))}var RL=ny(nu),BA=Us(globalThis.File,{representation:{id:"effect/schema/File",payload:null},toCode:()=>({runtime:"Schema.File",Type:"globalThis.File"}),expected:"File",toCodecJson:()=>Se()(ae({data:z.check(TA()),type:z,name:z,lastModified:wo}),Et({decode:(e,t)=>Pr(ia(e.data),{onFailure:()=>_(new te({expected:"a valid Base64 string"},e.data,t)),onSuccess:(n)=>{let r=new globalThis.Uint8Array(n);return b(new globalThis.File([r],e.name,{type:e.type,lastModified:e.lastModified}))}}),encode:(e,t)=>fr({try:async()=>{let n=new globalThis.Uint8Array(await e.arrayBuffer());return{data:ai(n),type:e.type,name:e.name,lastModified:e.lastModified}},catch:()=>new te({expected:"a readable File"},e,t)})}))}),LA=Us(globalThis.FormData,{representation:{id:"effect/schema/FormData",payload:null},toCode:()=>({runtime:"Schema.FormData",Type:"globalThis.FormData"}),expected:"FormData",toCodecJson:()=>Se()(Oe(cr([z,Ie([ae({_tag:ye("String"),value:z}),ae({_tag:ye("File"),value:BA})])])),Et({decode:(e)=>{let t=new globalThis.FormData;for(let[n,r]of e)t.append(n,r.value);return b(t)},encode:(e)=>b(globalThis.Array.from(e.entries()).map(([t,n])=>{if(typeof n==="string")return[t,{_tag:"String",value:n}];else return[t,{_tag:"File",value:n}]}))}))});function PL(e){return LA.pipe(Z(e,zw))}var zA=Us(globalThis.URLSearchParams,{representation:{id:"effect/schema/URLSearchParams",payload:null},toCode:()=>({runtime:"Schema.URLSearchParams",Type:"globalThis.URLSearchParams"}),expected:"URLSearchParams",toCodecJson:()=>Se()(z.annotate({expected:"a query string that will be decoded as URLSearchParams"}),xe({decode:(e)=>new globalThis.URLSearchParams(e),encode:(e)=>e.toString()}))});function ML(e){return zA.pipe(Z(e,$w))}var UL=z.annotate({expected:"a string that will be decoded as a number"}).pipe(Z(Oa,wi)),FL=z.annotate({expected:"a string that will be decoded as a finite number"}).pipe(Z(op,wi)),DL=H(zg).pipe(Z(ic,el)),$A=z.check(kA()),NL=z.annotate({expected:"a string that will be decoded as a trimmed string"}).pipe(Z($A,bw())),BL=z.annotate({expected:"a base64 encoded string that will be decoded as a UTF-8 string"}).pipe(Z(z,Fw)),LL=z.annotate({expected:"a base64 (URL) encoded string that will be decoded as a UTF-8 string"}).pipe(Z(z,Dw)),zL=z.annotate({expected:"a hex encoded string that will be decoded as a UTF-8 string"}).pipe(Z(z,Nw)),$L=z.annotate({expected:"a URI component encoded string that will be decoded as a UTF-8 string"}).pipe(Z(z,Bw)),Nx=Ie([op,iA,z]),qL=ae({issues:Oe(ae({message:z,path:mt(Oe(Ie([Nx,ae({key:Nx})])))}))}),HL=ur([0,1]).pipe(Z(ru,xe({decode:(e)=>e===1,encode:(e)=>e?1:0}))),qA=z.annotate({expected:"a base64 encoded string that will be decoded as Uint8Array",format:"byte",contentEncoding:"base64"}),Hr=Us(globalThis.Uint8Array,{representation:{id:"effect/schema/Uint8Array",payload:null},toCode:()=>({runtime:"Schema.Uint8Array",Type:"globalThis.Uint8Array"}),expected:"Uint8Array",toCodecJson:()=>Se()(qA,fg)}),jL=qA.pipe(Z(Hr,fg)),WL=z.annotate({expected:"a base64 (URL) encoded string that will be decoded as a Uint8Array"}).pipe(Z(Hr,{decode:ow(),encode:Gd()})),JL=z.annotate({expected:"a hex encoded string that will be decoded as a Uint8Array"}).pipe(Z(Hr,{decode:aw(),encode:Kd()})),HA=Et({decode:(e,t)=>{let n=HE(e);return Tn(n)?_(new te({expected:"a valid BigDecimal string"},e,t)):b(n.value)},encode:(e)=>b(Lo(e))}),GL=ou({order:ni,formatter:(e)=>Lo(e)}),KL=su({order:ni,formatter:(e)=>Lo(e)}),VL=au({order:ni,formatter:(e)=>Lo(e)}),ZL=iu({order:ni,formatter:(e)=>Lo(e)}),QL=cu({order:ni,formatter:(e)=>Lo(e)}),jA=z.annotate({expected:"a string that will be decoded as a BigDecimal"}),WA=we(ra,{representation:{id:"effect/schema/BigDecimal",payload:null},toCode:()=>({runtime:"Schema.BigDecimal",Type:"BigDecimal.BigDecimal",importDeclarations:['import * as BigDecimal from "effect/BigDecimal"']}),expected:"BigDecimal",toCodecJson:()=>Se()(jA,HA),toFormatter:()=>(e)=>Lo(e)}),YL=jA.pipe(Z(WA,HA)),cp=we(YE,{representation:{id:"effect/schema/ByteSize",payload:null},toCode:()=>({runtime:"Schema.ByteSize",Type:"ByteSize.ByteSize",importDeclarations:['import * as ByteSize from "effect/ByteSize"']}),expected:"ByteSize",toCodecJson:()=>Se()(ic.check(CA(globalThis.BigInt(0))),xe({decode:QE,encode:ld})),toCodecStringTree:()=>Se()(JA,ig)}),JA=z.annotate({expected:"a string that will be decoded as a ByteSize"}),XL=JA.pipe(Z(cp,ig)),e2=ic.pipe(Z(cp,ww)),t2=Oa.pipe(Z(cp,kw));function Bx(e,t){let n=Wt()([e,t],([r,o])=>(s,a,i)=>{if(!oc(s))return _(new Fe(a,s,i));switch(s._tag){case"Fail":return Ht(qe(r)(s.error,i),{onSuccess:Kf,onFailure:(c)=>vn(a,"error",c,s,i)});case"Die":return Ht(qe(o)(s.defect,i),{onSuccess:Vf,onFailure:(c)=>vn(a,"defect",c,s,i)});case"Interrupt":return b(s)}},{representation:{id:"effect/schema/CauseReason",payload:null},toCode:({typeParameters:r})=>({runtime:`Schema.CauseReason(${r[0].runtime}, ${r[1].runtime})`,Type:`Cause.Failure<${r[0].Type}, ${r[1].Type}>`,importDeclarations:['import * as Cause from "effect/Cause"']}),expected:"Cause.Failure",toCodec:([r,o])=>Se()(Ie([ae({_tag:pt("Fail"),error:r}),ae({_tag:pt("Die"),defect:o}),ae({_tag:pt("Interrupt"),fiberId:np(op)})]),xe({decode:(s)=>{switch(s._tag){case"Fail":return Kf(s.error);case"Die":return Vf(s.defect);case"Interrupt":return Yf(s.fiberId)}},encode:(s)=>{switch(s._tag){case"Fail":return{_tag:"Fail",error:s.error};case"Die":return{_tag:"Die",defect:s.defect};case"Interrupt":return{_tag:"Interrupt",fiberId:s.fiberId}}}}))});return H(n.ast,{error:e,defect:t})}function Lx(e,t){let n=Wt()([e,t],([r,o])=>{let s=Oe(Bx(r,o));return(a,i,c)=>{if(!rc(a))return _(new Fe(i,a,c));return Ht(qe(s)(a.reasons,c),{onSuccess:Gf,onFailure:(f)=>vn(i,"failures",f,a,c)})}},{representation:{id:"effect/schema/Cause",payload:null},toCode:({typeParameters:r})=>({runtime:`Schema.Cause(${r[0].runtime}, ${r[1].runtime})`,Type:`Cause.Cause<${r[0].Type}, ${r[1].Type}>`,importDeclarations:['import * as Cause from "effect/Cause"']}),expected:"Cause",toCodec:([r,o])=>Se()(Oe(Bx(r,o)),xe({decode:Gf,encode:({reasons:s})=>s}))});return H(n.ast,{error:e,defect:t})}function BT(e){return Se()(e,xe({decode:lh,encode:_t}))}function n2(e){let t=Wt()([e],([n])=>{let r=Oe(n);return(o,s,a)=>{if(si(o))return Ht(qe(r)(_t(o),a),{onSuccess:lh,onFailure:(i)=>vn(s,"values",i,o,a)});return _(new Fe(s,o,a))}},{representation:{id:"effect/schema/Chunk",payload:null},toCode:({typeParameters:n})=>({runtime:`Schema.Chunk(${n[0].runtime})`,Type:`Chunk.Chunk<${n[0].Type}>`}),expected:"Chunk",toCodec:([n])=>BT(Oe(n)),toCodecArbitrary:({constraint:n,typeParameters:[r]})=>BT(tp(Oe(r),n?.minLength,n?.maxLength)),toEquivalence:([n])=>uh(n)});return H(t.ast,{value:e})}function GA(){return $t((e,t)=>zt(mh(e),{onNone:()=>_(new te({message:"Invalid DateTime input"},e,t)),onSome:(n)=>b(hh(n))}))}var r2=xe({decode:(e)=>xh(e),encode:(e)=>e.offset}),KA=Et({decode:(e,t)=>zt(Pb(e),{onNone:()=>_(new te({expected:"a valid IANA time zone"},e,t)),onSome:b}),encode:(e)=>b(e.id)}),VA=Et({decode:(e,t)=>zt(Mb(e),{onNone:()=>_(new te({expected:"a valid time zone"},e,t)),onSome:b}),encode:(e)=>b(Kc(e))}),ZA=Et({decode:(e,t)=>zt(mh(e),{onNone:()=>_(new te({expected:"a valid UTC DateTime string"},e,t)),onSome:(n)=>b(hh(n))}),encode:(e)=>b(Db(e))}),QA=Et({decode:(e,t)=>zt(Rb(e),{onNone:()=>_(new te({expected:"a valid Zoned DateTime string"},e,t)),onSome:b}),encode:(e)=>b(yh(e))}),YA=-8640000000000000,XA=8640000000000000,o2=YA+50400000,s2=XA-50400000,a2=-43200000,i2=50400000,eC=["UTC","Europe/London","America/New_York","Asia/Tokyo","Australia/Sydney"];function tC(e,t,n){let r=Math.max(t,e?.minimum===void 0?t:e.minimum.epochMilliseconds+(e.exclusiveMinimum===!0?1:0)),o=Math.min(n,e?.maximum===void 0?n:e.maximum.epochMilliseconds-(e.exclusiveMaximum===!0?1:0));return r<=o?[r,o]:[t,n]}function ry(e,t){return wo.check(sp({minimum:e,maximum:t}))}function nC(){return Ie([ry(a2,i2),ur(eC)])}var fp=we((e)=>sa(e)&&vb(e),{representation:{id:"effect/schema/DateTimeUtc",payload:null},toCode:()=>({runtime:"Schema.DateTimeUtc",Type:"DateTime.Utc",importDeclarations:['import * as DateTime from "effect/DateTime"']}),expected:"DateTime.Utc",toCodecArbitrary:({constraint:e})=>{let[t,n]=tC(e,YA,XA);return uc()(ry(t,n),se(gd))},toCodecJson:()=>Se()(z,ZA),toFormatter:()=>(e)=>e.toString()}),c2=ip.pipe(Z(fp,{decode:GA(),encode:se(Ub)})),f2=z.annotate({expected:"a string that will be decoded as a DateTime.Utc"}).pipe(Z(fp,ZA)),u2=wo.pipe(Z(fp,{decode:GA(),encode:se(Fb)})),d2=we(Ab,{representation:{id:"effect/schema/TimeZoneOffset",payload:null},toCode:()=>({runtime:"Schema.TimeZoneOffset",Type:"DateTime.TimeZone.Offset",importDeclarations:['import * as DateTime from "effect/DateTime"']}),expected:"DateTime.TimeZone.Offset",toCodecJson:()=>Se()(wo,r2),toFormatter:()=>(e)=>Kc(e)}),rC=z.annotate({expected:"an IANA time zone identifier"}),oC=we(Cb,{representation:{id:"effect/schema/TimeZoneNamed",payload:null},toCode:()=>({runtime:"Schema.TimeZoneNamed",Type:"DateTime.TimeZone.Named",importDeclarations:['import * as DateTime from "effect/DateTime"']}),expected:"DateTime.TimeZone.Named",toCodecArbitrary:()=>uc()(ur(eC),se(gh)),toCodecJson:()=>Se()(rC,KA),toFormatter:()=>(e)=>Kc(e)}),l2=rC.pipe(Z(oC,KA)),sC=z.annotate({expected:"a time zone string (IANA identifier or offset like +03:00)"}),aC=we(Tb,{representation:{id:"effect/schema/TimeZone",payload:null},toCode:()=>({runtime:"Schema.TimeZone",Type:"DateTime.TimeZone",importDeclarations:['import * as DateTime from "effect/DateTime"']}),expected:"DateTime.TimeZone",toCodecArbitrary:()=>uc()(nC(),se((e)=>typeof e==="number"?xh(e):gh(e))),toCodecJson:()=>Se()(sC,VA),toFormatter:()=>(e)=>Kc(e)}),p2=sC.pipe(Z(aC,VA)),iC=z.annotate({expected:"a zoned DateTime string (e.g. 2024-01-01T00:00:00.000+00:00[Europe/London])"}),cC=we((e)=>sa(e)&&Ob(e),{representation:{id:"effect/schema/DateTimeZoned",payload:null},toCode:()=>({runtime:"Schema.DateTimeZoned",Type:"DateTime.Zoned",importDeclarations:['import * as DateTime from "effect/DateTime"']}),expected:"DateTime.Zoned",toCodecArbitrary:({constraint:e})=>{let[t,n]=tC(e,o2,s2);return uc()(ae({epochMilliseconds:ry(t,n),timeZone:nC()}),se(({epochMilliseconds:r,timeZone:o})=>xd(r,{timeZone:o})))},toCodecJson:()=>Se()(iC,QA),toFormatter:()=>(e)=>yh(e),toEquivalence:()=>_b}),m2=iC.pipe(Z(cC,QA)),jr=(e,t,n,r)=>z.pipe(Z(e,Et({decode:(o,s)=>{let a=t(o);return At(a)?b(a.success):_(new te({message:a.failure.message},o,s))},encode:(o)=>b(n(o))}))).annotate({identifier:r}),Ra=we(ji,{identifier:"MacAddress"}),lc=jr(Ra,xT,bx,"MacAddressFromString"),up=we(rn,{identifier:"Ipv4Address"}),oy=jr(up,Wi,qr,"Ipv4AddressFromString"),sy=we(Io,{identifier:"Ipv6Address"}),fC=jr(sy,Bf,qr,"Ipv6AddressFromString"),Pa=we(hT,{identifier:"IpAddress"}),pc=jr(Pa,Lf,qr,"IpAddressFromString"),Je=(e,t,n,r)=>lA(t,{expected:n})(e).annotate({identifier:r}),h2=Je(Pa,Ji,"a multicast address","IpMulticastAddress"),g2=Je(pc,Ji,"a multicast address","IpMulticastAddressFromString"),x2=Je(Ra,Ji,"a multicast address","MacMulticastAddress"),y2=Je(lc,Ji,"a multicast address","MacMulticastAddressFromString"),S2=Je(Pa,Tx,"a unicast address","IpUnicastAddress"),E2=Je(pc,Tx,"a unicast address","IpUnicastAddressFromString"),b2=Je(Ra,Wl,"a unicast address","MacUnicastAddress"),I2=Je(lc,Wl,"a unicast address","MacUnicastAddressFromString"),w2=Je(up,Gl,"a broadcast address","Ipv4BroadcastAddress"),k2=Je(oy,Gl,"a broadcast address","Ipv4BroadcastAddressFromString"),T2=Je(Ra,jl,"a broadcast address","MacBroadcastAddress"),A2=Je(lc,jl,"a broadcast address","MacBroadcastAddressFromString"),C2=Je(Pa,kx,"a loopback address","IpLoopbackAddress"),v2=Je(pc,kx,"a loopback address","IpLoopbackAddressFromString"),O2=Je(Pa,Ax,"a link-local address","IpLinkLocalAddress"),_2=Je(pc,Ax,"a link-local address","IpLinkLocalAddressFromString"),R2=Je(Pa,Jl,"an unspecified address","IpUnspecifiedAddress"),P2=Je(pc,Jl,"an unspecified address","IpUnspecifiedAddressFromString"),M2=Je(up,Cx,"a private address","Ipv4PrivateAddress"),U2=Je(oy,Cx,"a private address","Ipv4PrivateAddressFromString"),F2=Je(sy,vx,"a unique-local address","Ipv6UniqueLocalAddress"),D2=Je(fC,vx,"a unique-local address","Ipv6UniqueLocalAddressFromString"),N2=Je(Ra,Ix,"a locally administered address","MacLocallyAdministeredAddress"),B2=Je(lc,Ix,"a locally administered address","MacLocallyAdministeredAddressFromString"),L2=Je(Ra,wx,"a universally administered address","MacUniversallyAdministeredAddress"),z2=Je(lc,wx,"a universally administered address","MacUniversallyAdministeredAddressFromString"),uC=we(IT,{identifier:"Ipv4Interface"}),$2=jr(uC,Vl,qf,"Ipv4InterfaceFromString"),dC=we(wT,{identifier:"Ipv6Interface"}),q2=jr(dC,Zl,qf,"Ipv6InterfaceFromString"),lC=we(zf,{identifier:"IpInterface"}),H2=jr(lC,Ql,qf,"IpInterfaceFromString"),pC=we(TT,{identifier:"Ipv4Network"}),j2=jr(pC,CT,jf,"Ipv4NetworkFromString"),mC=we(AT,{identifier:"Ipv6Network"}),W2=jr(mC,vT,jf,"Ipv6NetworkFromString"),hC=we(Hf,{identifier:"IpNetwork"}),J2=jr(hC,OT,jf,"IpNetworkFromString"),G2=we(Df,{identifier:"InetAddressV4"}),K2=we(Nf,{identifier:"InetAddressV6"}),gC=we(Sx,{identifier:"InetAddress"}),V2=jr(gC,ET,Kl,"InetAddressFromString"),xC=we(Hl,{identifier:"UnixPathAddress"}),Z2=z.pipe(Z(xC,xe({decode:bT,encode:(e)=>e.path}))).annotate({identifier:"UnixPathAddressFromString"}),Q2=we(gT,{identifier:"SocketAddress"}),Y2=Et({decode:(e,t)=>zt(JT(e),{onNone:()=>_(new te({expected:"a valid Duration string"},e,t)),onSome:b}),encode:(e)=>b(globalThis.String(e))}),X2=Et({decode:(e)=>b(Zf(e)),encode:(e,t)=>zt(GT(e),{onNone:()=>_(new te({expected:"a Duration representable as a bigint"},e,t)),onSome:(n)=>b(n)})}),ez=xe({decode:(e)=>Qf(e),encode:(e)=>Wn(e)}),dp=we(tc,{representation:{id:"effect/schema/Duration",payload:null},toCode:()=>({runtime:"Schema.Duration",Type:"Duration.Duration",importDeclarations:['import * as Duration from "effect/Duration"']}),expected:"Duration",toCodecJson:()=>Se()(Ie([ae({_tag:pt("Infinity")}),ae({_tag:pt("NegativeInfinity")}),ae({_tag:pt("Nanos"),value:ic}),ae({_tag:pt("Millis"),value:wo})]),xe({decode:(e)=>{switch(e._tag){case"Infinity":return nc;case"NegativeInfinity":return Yl;case"Nanos":return Zf(e.value);case"Millis":return Qf(e.value)}},encode:(e)=>{switch(e.value._tag){case"Infinity":return{_tag:"Infinity"};case"NegativeInfinity":return{_tag:"NegativeInfinity"};case"Nanos":return{_tag:"Nanos",value:e.value.nanos};case"Millis":return{_tag:"Millis",value:e.value.millis}}}}))}),tz=z.annotate({expected:"a string that will be decoded as a Duration"}),nz=tz.pipe(Z(dp,Y2)),rz=ic.pipe(Z(dp,X2)),oz=Oa.pipe(Z(dp,ez));function ay(e,t,n){let r=Wt()([e,t,n],([o,s,a])=>{let i=Lx(s,a);return(c,f,u)=>{if(!Zo(c))return _(new Fe(f,c,u));switch(c._tag){case"Success":return Ht(qe(o)(c.value,u),{onSuccess:xn,onFailure:(d)=>vn(f,"value",d,c,u)});case"Failure":return Ht(qe(i)(c.cause,u),{onSuccess:en,onFailure:(d)=>vn(f,"cause",d,c,u)})}}},{representation:{id:"effect/schema/Exit",payload:null},toCode:({typeParameters:o})=>({runtime:`Schema.Exit(${o[0].runtime}, ${o[1].runtime}, ${o[2].runtime})`,Type:`Exit.Exit<${o[0].Type}, ${o[1].Type}, ${o[2].Type}>`,importDeclarations:['import * as Exit from "effect/Exit"']}),expected:"Exit",toCodec:([o,s,a])=>Se()(Ie([ae({_tag:pt("Success"),value:o}),ae({_tag:pt("Failure"),cause:Lx(s,a)})]),xe({decode:(i)=>i._tag==="Success"?xn(i.value):en(i.cause),encode:(i)=>$e(i)?{_tag:"Success",value:i.value}:{_tag:"Failure",cause:i.cause}}))});return H(r.ast,{value:e,error:t,defect:n})}function LT(e,t,n){return ae({type:pt(e),nodes:Oe(ae({index:Aa,data:t})),edges:Oe(ae({index:Aa,source:Aa,target:Aa,data:n}))})}function zT(e,t){let n=-1,r=new Set;for(let o=0;o<e.nodes.length;o++){let s=e.nodes[o].index;if(s<=n)return _(new Qe(["nodes",o,"index"],new te({expected:"a strictly increasing node index"},s,t)));n=s,r.add(s)}n=-1;for(let o=0;o<e.edges.length;o++){let s=e.edges[o];if(s.index<=n)return _(new Qe(["edges",o,"index"],new te({expected:"a strictly increasing edge index"},s.index,t)));if(n=s.index,!r.has(s.source))return _(new Qe(["edges",o,"source"],new te({expected:"an encoded node index"},s.source,t)));if(!r.has(s.target))return _(new Qe(["edges",o,"target"],new te({expected:"an encoded node index"},s.target,t)))}return b(Ud(e))}function sz(e,t,n){if(!Jh(e)||e.mutable||e.type!==t)return _(new te({expected:`an immutable ${t} Graph`},e,n));return b(ff(e))}function az(e,t){return(n,r)=>{let o=ff(n),s=ff(r);if(o.type!==s.type||o.nodes.length!==s.nodes.length||o.edges.length!==s.edges.length)return!1;for(let a=0;a<o.nodes.length;a++)if(o.nodes[a].index!==s.nodes[a].index||!e(o.nodes[a].data,s.nodes[a].data))return!1;for(let a=0;a<o.edges.length;a++){let i=o.edges[a],c=s.edges[a],f=o.type==="directed"?i.source===c.source&&i.target===c.target:i.source===c.source&&i.target===c.target||i.source===c.target&&i.target===c.source;if(i.index!==c.index||!f||!t(i.data,c.data))return!1}return!0}}function iz(e,t,n){return uc()(Ie([ep,ae({nodes:fc(t),edges:Oe(cr([Aa,Aa,n]))})]),se((r)=>{if(r===null)return Ud({type:e,nodes:[],edges:[]});let o=r.nodes.map((s,a)=>({index:a,data:s}));return Ud({type:e,nodes:o,edges:r.edges.map(([s,a,i],c)=>({index:c,source:s%o.length,target:a%o.length,data:i}))})}))}function cz(e,t,n){let r=Wt()([t,n],([o,s])=>{let a=LT(e,o,s);return(i,c,f)=>{if(!Jh(i)||i.mutable||i.type!==e)return _(new Fe(c,i,f));return A(qe(a)(ff(i),f),(u)=>zT(u,f))}},{representation:{id:"effect/schema/Graph",payload:e},toCode:({typeParameters:o})=>({runtime:`Schema.Graph(${K(e)}, ${o[0].runtime}, ${o[1].runtime})`,Type:`Graph.Graph<${o[0].Type}, ${o[1].Type}, ${K(e)}>`,importDeclarations:['import * as Graph from "effect/Graph"']}),expected:`an immutable ${e} Graph`,toCodec:([o,s])=>Se()(LT(e,o,s),Et({decode:zT,encode:(a,i)=>sz(a,e,i)})),toCodecArbitrary:({typeParameters:[o,s]})=>iz(e,o,s),toEquivalence:([o,s])=>az(o,s)});return H(r.ast,{type:e,node:t,edge:n})}function $T(e){return Se()(e,xe({decode:vh,encode:ef}))}function fz(e,t){let n=Wt()([e,t],([r,o])=>{let s=Oe(cr([r,o]));return(a,i,c)=>{if(wd(a))return Ht(qe(s)(ef(a),c),{onSuccess:vh,onFailure:(f)=>vn(i,"entries",f,a,c)});return _(new Fe(i,a,c))}},{representation:{id:"effect/schema/HashMap",payload:null},toCode:({typeParameters:r})=>({runtime:`Schema.HashMap(${r[0].runtime}, ${r[1].runtime})`,Type:`HashMap.HashMap<${r[0].Type}, ${r[1].Type}>`,importDeclarations:['import * as HashMap from "effect/HashMap"']}),expected:"HashMap",toCodec:([r,o])=>$T(Oe(cr([r,o]))),toCodecArbitrary:({constraint:r,typeParameters:[o,s]})=>$T(tp(Oe(cr([o,s])).check(PA()),r?.minSize,r?.maxSize)),toEquivalence:([r,o])=>Nl(r,o)});return H(n.ast,{key:e,value:t})}function qT(e){return Se()(e,xe({decode:Rh,encode:_t}))}function uz(e){let t=Wt()([e],([n])=>{let r=Oe(n);return(o,s,a)=>{if(Ad(o))return Ht(qe(r)(_t(o),a),{onSuccess:Rh,onFailure:(i)=>vn(s,"values",i,o,a)});return _(new Fe(s,o,a))}},{representation:{id:"effect/schema/HashSet",payload:null},toCode:({typeParameters:n})=>({runtime:`Schema.HashSet(${n[0].runtime})`,Type:`HashSet.HashSet<${n[0].Type}>`}),expected:"HashSet",toCodec:([n])=>qT(Oe(n)),toCodecArbitrary:({constraint:n,typeParameters:[r]})=>qT(tp(Oe(r).check(ty()),n?.minSize,n?.maxSize)),toEquivalence:([n])=>Bl(n)});return H(t.ast,{value:e})}function Ma(e){let t=Wt()([e],([n])=>(r,o,s)=>{if(Xi(r)){if(Tn(r))return Si;return Ht(qe(n)(r.value,s),{onSuccess:oe,onFailure:(a)=>vn(o,"value",a,r,s)})}return _(new Fe(o,r,s))},{representation:{id:"effect/schema/Option",payload:null},toCode:({typeParameters:n})=>({runtime:`Schema.Option(${n[0].runtime})`,Type:`Option.Option<${n[0].Type}>`,importDeclarations:['import * as Option from "effect/Option"']}),expected:"Option",toCodec:([n])=>Se()(Ie([ae({_tag:pt("Some"),value:n}),ae({_tag:pt("None")})]),xe({decode:(r)=>r._tag==="None"?ne():oe(r.value),encode:(r)=>ve(r)?{_tag:"Some",value:r.value}:{_tag:"None"}}))});return H(t.ast,{value:e})}function dz(e){return Vx(e).pipe(Z(Ma(Pn(e)),_w()))}function lz(e){return np(e).pipe(Z(Ma(Pn(e)),Rw()))}function pz(e,t){return uA(e).pipe(Z(Ma(Pn(e)),Pw(t)))}var yC=we(aI,{representation:{id:"effect/http/Cookie",payload:null},toCode:()=>({runtime:"Schema.Cookie",Type:"Cookies.Cookie",importDeclarations:['import * as Cookies from "effect/http/Cookies"']}),expected:"Cookie"}),SC=we(sI,{representation:{id:"effect/http/Cookies",payload:null},toCode:()=>({runtime:"Schema.Cookies",Type:"Cookies.Cookies",importDeclarations:['import * as Cookies from "effect/http/Cookies"']}),expected:"Cookies",toCodecJson:()=>Se()(Oe(z),xe({decode:vd,encode:lI})),toCodecIso:()=>Se()(_a(z,yC),xe({decode:Dh,encode:(e)=>e.cookies}))}),mz=SC.pipe(Z(_a(z,z),xe({decode:dI,encode:(e)=>Nh(globalThis.Object.entries(e).map(([t,n])=>uI(t,n)))}))),hz=we(EI,{representation:{id:"effect/http/Headers",payload:null},toCode:()=>({runtime:"Schema.Headers",Type:"Headers.Headers",importDeclarations:['import * as Headers from "effect/http/Headers"']}),expected:"Headers",toEquivalence:()=>Lh,toCodec:()=>Se()(_a(z,z),xe({decode:Es,encode:(e)=>({...e})}))}),iy=we(qh,{representation:{id:"effect/http/UrlParams",payload:null},toCode:()=>({runtime:"Schema.UrlParams",Type:"UrlParams.UrlParams",importDeclarations:['import * as UrlParams from "effect/http/UrlParams"']}),expected:"UrlParams",toEquivalence:()=>Hh,toCodec:()=>Se()(Oe(cr([z,z])),xe({decode:pi,encode:(e)=>e.params}))}),gz=(e,t)=>iy.pipe(Z(ny(nu,t),Et({decode:(n)=>zt(AI(n,e),{onNone:()=>_(new Qe([e],new ot(void 0))),onSome:b}),encode:(n)=>b(pi([[e,n]]))}))),xz=iy.pipe(Z(_a(z,Ie([z,fc(z)])),xe({decode:vI,encode:la})));function yz(e){return Ca(e).pipe(Z(Ma(Pn(e)),Mw()))}function Sz(e){return mt(e).pipe(Z(Ma(Pn(e)),Uw()))}function Ez(e,t){let n=t===void 0?"omit":t.onNoneEncoding,r=n===null?null:void 0;return mt(Vx(e)).pipe(Z(Ma(Pn(e)),Xd({decode:(o)=>o.pipe(yi(cl),oe),encode:n==="omit"?bi:(o)=>oe(WT(bi(o),()=>r))})))}function EC(e,t){let n=typeof t?.label==="string"?t.label:void 0,r=t?.disallowJsonEncode===!0,o=n!==void 0?r?{label:n,disallowJsonEncode:!0}:{label:n}:r?{disallowJsonEncode:!0}:void 0,s=n!==void 0?qe(pt(n)):void 0,a=Wt()([e],([i])=>(c,f,u)=>{if(of(c)){let d=s!==void 0?Hd(s(c.label,u),(l)=>new Qe(["label"],l)):R;return Pt(d,()=>Ht(qe(i)(Rr(c),u),{onSuccess:(l)=>ua(l,{label:c.label}),onFailure:()=>new tt(f,[new Qe(["value"],new te(void 0,c,u))],c,u)}))}return _(new Fe(f,c,u))},{representation:{id:"effect/schema/Redacted",payload:o??null},toCode:({typeParameters:i})=>({runtime:o!==void 0?`Schema.Redacted(${i[0].runtime}, ${K(o)})`:`Schema.Redacted(${i[0].runtime})`,Type:`Redacted.Redacted<${i[0].Type}>`,importDeclarations:['import * as Redacted from "effect/Redacted"']}),expected:"Redacted",toCodecJson:([i])=>Se()(i,{decode:se((c)=>ua(c,{label:n})),encode:r?jd((c)=>"Cannot serialize Redacted"+(ve(c)&&typeof c.value.label==="string"?` with label: "${c.value.label}"`:"")):se(Rr)}),toEquivalence:([i])=>gI(i)});return H(a.ast,{value:e})}function bz(e,t){return Z(EC(Pn(e),{label:t?.label,disallowJsonEncode:t?.disallowEncode}),{decode:se((n)=>ua(n,{label:t?.label})),encode:t?.disallowEncode?jd((n)=>"Cannot encode Redacted"+(ve(n)&&typeof n.value.label==="string"?` with label: "${n.value.label}"`:"")):se(Rr)})(e)}function Iz(e,t){let n=Wt()([e,t],([r,o])=>(s,a,i)=>{if(!ec(s))return _(new Fe(a,s,i));switch(s._tag){case"Success":return Ht(Zg(r)(s.success,i),{onSuccess:ue,onFailure:(c)=>vn(a,"success",c,s,i)});case"Failure":return Ht(Zg(o)(s.failure,i),{onSuccess:ge,onFailure:(c)=>vn(a,"failure",c,s,i)})}},{representation:{id:"effect/schema/Result",payload:null},toCode:({typeParameters:r})=>({runtime:`Schema.Result(${r[0].runtime}, ${r[1].runtime})`,Type:`Result.Result<${r[0].Type}, ${r[1].Type}>`,importDeclarations:['import * as Result from "effect/Result"']}),expected:"Result",toCodec:([r,o])=>Se()(Ie([ae({_tag:pt("Success"),success:r}),ae({_tag:pt("Failure"),failure:o})]),xe({decode:(s)=>s._tag==="Success"?ue(s.success):ge(s.failure),encode:(s)=>At(s)?{_tag:"Success",success:s.success}:{_tag:"Failure",failure:s.failure}}))});return H(n.ast,{success:e,failure:t})}var wz=globalThis.Symbol.for("immer-draftable"),zx={};function cy(e,t,n,r,o){let s=Tz(n,t,r),a=bC(t),i=class extends e{constructor(...[c,f]){let d=f?.["~payload"],l=d?.token===zx?d.value:n.make(c??{},f);super(l,{...f,disableChecks:!0,"~payload":{token:zx,value:l}})}static[Wf]=Wf;get[a](){return a}static[wz]=!0;static identifier=t;static fields=n.fields;static get ast(){return s(this).ast}static pipe(){return de(this,arguments)}static rebuild(c){return s(this).rebuild(c)}static make(c,f){return kl(s(this))(c??{},f)}static makeOption(c,f){return wl(s(this))(c??{},f)}static makeEffect(c,f){return s(this).makeEffect(c??{},f)}static annotate(c){return this.rebuild(Ur(this.ast,c))}static annotateKey(c){return this.rebuild(Ri(this.ast,c))}static check(...c){return this.rebuild(Eo(this.ast,c))}static extend(c){return(f,u)=>{let d=fu(f)?f:ae(f),l={...n.fields,...d.fields},m=ll(l,n.ast.checks,{identifier:c});return cy(this,c,Kx(Eo(m,d.ast.checks),l),u,o)}}static mapFields(c,f){return n.mapFields(c,f)}};if(o!==void 0)Object.assign(i.prototype,o(t));return i}function kz(e){return new be(se((t)=>new e(t,{"~payload":{token:zx,value:t}})),xo())}function bC(e){return`~effect/Schema/Class/${e}`}function Tz(e,t,n){let r;return(o)=>{if(r!==void 0)return r;let s=bC(t),a=(f)=>f instanceof o||V(f,s),i=kz(o),c=H(new Cs([e.ast],()=>(f,u,d)=>a(f)?b(f):_(new Fe(u,f,d)),{identifier:t,[Dd]:([f])=>({isConstructed:a,link:new Xe(f,i)}),toCodec:([f])=>new Xe(f.ast,i),toEquivalence:([f])=>f,toFormatter:([f])=>(u)=>`${o.identifier}(${f(u)})`,[uf]:ks(e.ast),...n}));return r=Z(c,i)(e)}}function fu(e){return va(e)}var lp=(e)=>(t,n)=>{let r=fu(t)?t:ae(t);return cy(KT,e,r,n,(o)=>({toString(){return`${o}(${K({...this})})`}}))},Az=(e)=>(t,n,r)=>{let o=fu(n)?n.mapFields((s)=>({_tag:ye(t),...s}),{unsafePreserveChecks:!0}):rp(t,n);return lp(e??t)(o,r)},Ct=(e)=>(t,n)=>{let r=fu(t)?t:ae(t);return cy(jT,e,r,n,(s)=>({name:s}))},fy=(e)=>(t,n,r)=>{let o=fu(n)?n.mapFields((s)=>({_tag:ye(t),...s}),{unsafePreserveChecks:!0}):rp(t,n);return Ct(e??t)(o,r)};function Cz(e){return(t)=>t.annotate({toFormatter:e})}function vz(e,t){return tT(e.ast,t)}function Oz(e){return(t)=>t.annotate({toEquivalence:e})}function _z(e){return lx(e.ast)}function Rz(e,t){return Pf(e.ast,t)}function Pz(e,t){let n=Pf(Ni(e.ast),t);return Ul(n,t)}var uu=Ol,Mz=_l,Uz=Rl,Fz=T0;function Dz(e,t){return V0(e,t)}function Nz(e){return dT(e)}function Bz(e){return lT(e)}function Lz(e){return pT(e)}function zz(e,t){return(n)=>H(Ur(n.ast,{toCodecIso:()=>new Xe(e.ast,Yd(t))}),{schema:n})}function $z(e){return K0(e)}function qz(e){let t=dA(()=>n),n=Ie([e,Oe(t),_a(z,t)]);return n}var pp=H(Ur(Ai,{toCode:()=>({runtime:"Schema.Json",Type:"Schema.Json"})})),Hz=_a(z,pp),jz=ae({message:z,name:Ca(z),stack:Ca(z),cause:Ca(pp)}),Wz=H(Ur($k,{toCode:()=>({runtime:"Schema.MutableJson",Type:"Schema.MutableJson"})}));function Jz(e){return Ho(e.ast)}function Gz(e){return e.ast.context?.annotations}var ss={};Ps(ss,{ServerClient:()=>gR,custom:()=>Qj,exitSchema:()=>wS,fork:()=>e4,isRpc:()=>Vj,isWrapper:()=>Pc,make:()=>xR,uninterruptible:()=>t4,unwrap:()=>Yj,wrap:()=>cm,wrapMap:()=>Xj});var IC="~effect/PrimaryKey";var so={};Ps(so,{DefaultChunkSize:()=>v_,Do:()=>wj,TypeId:()=>C_,accumulate:()=>cj,aggregate:()=>ej,aggregateWithin:()=>pS,as:()=>gq,bind:()=>Tj,bindEffect:()=>Aj,bindTo:()=>Cj,broadcast:()=>nR,broadcastN:()=>tj,buffer:()=>iH,bufferArray:()=>cH,callback:()=>R_,catch:()=>Bu,catchCause:()=>q_,catchCauseFilter:()=>yH,catchCauseIf:()=>xH,catchDefect:()=>fH,catchFilter:()=>dS,catchIf:()=>j_,catchReason:()=>mH,catchReasons:()=>hH,catchTag:()=>lH,catchTags:()=>pH,changes:()=>fj,changesWith:()=>rR,changesWithEffect:()=>uj,chunks:()=>Q_,collect:()=>ij,combine:()=>NH,combineArray:()=>BH,concat:()=>vc,cross:()=>zq,crossWith:()=>z_,debounce:()=>jH,decodeText:()=>dj,die:()=>X$,drain:()=>Tq,drainFork:()=>Aq,drop:()=>lS,dropRight:()=>UH,dropUntil:()=>RH,dropUntilEffect:()=>PH,dropWhile:()=>V_,dropWhileEffect:()=>Z_,dropWhileFilter:()=>MH,empty:()=>os,encodeText:()=>lj,ensuring:()=>mS,fail:()=>Js,failCause:()=>P_,failCauseSync:()=>eq,failSync:()=>Y$,filter:()=>Xq,filterEffect:()=>tH,filterMap:()=>eH,filterMapEffect:()=>nH,flatMap:()=>Rc,flatten:()=>N_,flattenArray:()=>kq,flattenEffect:()=>yq,flattenIterable:()=>Pq,flattenTake:()=>Mq,forever:()=>Rq,fromArray:()=>nm,fromArrayEffect:()=>oq,fromArrays:()=>sq,fromAsyncIterable:()=>iq,fromChannel:()=>P,fromEffect:()=>tm,fromEffectDrain:()=>O_,fromEffectRepeat:()=>__,fromEffectSchedule:()=>K$,fromEventListener:()=>uq,fromIterable:()=>Ga,fromIterableEffect:()=>nq,fromIterableEffectRepeat:()=>rq,fromIteratorSucceed:()=>tq,fromPubSub:()=>aq,fromPubSubTake:()=>M_,fromPull:()=>oo,fromQueue:()=>Gs,fromReadableStream:()=>sS,fromSchedule:()=>cq,fromSubscription:()=>fq,groupAdjacentBy:()=>YH,groupBy:()=>ZH,groupByKey:()=>QH,grouped:()=>KH,groupedWithin:()=>VH,haltWhen:()=>xj,ignore:()=>IH,ignoreCause:()=>wH,interleave:()=>hj,interleaveWith:()=>sR,interruptWhen:()=>gj,intersperse:()=>oR,intersperseAffixes:()=>mj,isStream:()=>le,iterate:()=>lq,let:()=>kj,limitBytes:()=>CH,make:()=>Z$,map:()=>Dn,mapAccum:()=>LH,mapAccumArray:()=>Ka,mapAccumArrayEffect:()=>$H,mapAccumEffect:()=>zH,mapArray:()=>F_,mapArrayEffect:()=>Sq,mapBoth:()=>xq,mapEffect:()=>Nu,mapError:()=>W_,merge:()=>aS,mergeAll:()=>Lq,mergeEffect:()=>rm,mergeLeft:()=>Nq,mergeResult:()=>Dq,mergeRight:()=>Bq,mkArrayBuffer:()=>Bj,mkString:()=>Nj,mkUint8Array:()=>Lj,never:()=>mq,onEnd:()=>Sj,onError:()=>yj,onExit:()=>aR,onFirst:()=>cR,onStart:()=>iR,orDie:()=>bH,orElseIfEmpty:()=>SH,orElseSucceed:()=>EH,paginate:()=>dq,partition:()=>oH,partitionEffect:()=>rH,partitionQueue:()=>fS,peel:()=>aH,pipeThrough:()=>aj,pipeThroughChannel:()=>oj,pipeThroughChannelOrFail:()=>sj,prepend:()=>Fq,provide:()=>fR,provideContext:()=>hS,provideService:()=>Ej,provideServiceEffect:()=>gS,race:()=>Yq,raceAll:()=>$_,range:()=>pq,rechunk:()=>Y_,repeat:()=>Cq,repeatElements:()=>_q,result:()=>Eq,retry:()=>kH,run:()=>dR,runCollect:()=>lR,runCount:()=>vj,runDrain:()=>am,runFold:()=>_j,runFoldEffect:()=>Rj,runForEach:()=>Uj,runForEachArray:()=>sm,runForEachWhile:()=>Fj,runHead:()=>Pj,runIntoPubSub:()=>jj,runIntoQueue:()=>Gj,runLast:()=>Mj,runSum:()=>Oj,scan:()=>qH,scanEffect:()=>HH,schedule:()=>vq,scoped:()=>hq,service:()=>J$,serviceOption:()=>G$,share:()=>rj,sliding:()=>FH,slidingSize:()=>X_,split:()=>DH,splitLines:()=>pj,succeed:()=>Wa,suspend:()=>dn,switchMap:()=>wq,sync:()=>Q$,take:()=>AH,takeRight:()=>vH,takeUntil:()=>J_,takeUntilEffect:()=>G_,takeWhile:()=>K_,takeWhileEffect:()=>_H,takeWhileFilter:()=>OH,tap:()=>D_,tapBoth:()=>bq,tapCause:()=>H_,tapDefect:()=>dH,tapError:()=>uS,tapErrorTag:()=>uH,tapSink:()=>Iq,throttle:()=>GH,throttleEffect:()=>eR,tick:()=>V$,timeout:()=>Oq,timeoutOrElse:()=>B_,toAsyncIterable:()=>Hj,toAsyncIterableEffect:()=>qj,toAsyncIterableWith:()=>yS,toChannel:()=>Sr,toPubSub:()=>Wj,toPubSubTake:()=>pR,toPull:()=>Dj,toQueue:()=>Jj,toReadableStream:()=>zj,toReadableStreamEffect:()=>$j,toReadableStreamWith:()=>xS,transduce:()=>XH,transformPull:()=>It,transformPullBracket:()=>oS,unfold:()=>U_,unwrap:()=>ro,unwrapReason:()=>gH,updateContext:()=>uR,updateService:()=>bj,when:()=>sH,withExecutionPlan:()=>TH,withSpan:()=>Ij,zip:()=>qq,zipFlatten:()=>Wq,zipLatest:()=>Zq,zipLatestAll:()=>cS,zipLatestWith:()=>Qq,zipLeft:()=>Hq,zipRight:()=>jq,zipWith:()=>iS,zipWithArray:()=>om,zipWithIndex:()=>Jq,zipWithNext:()=>Gq,zipWithPrevious:()=>Kq,zipWithPreviousAndNext:()=>Vq});var ct=wC,TC=kC;var AC="~effect/MutableRef",Vz={[AC]:AC,...Ss,toJSON(){return{_id:"MutableRef",current:lo(this.current)}}},hc=(e)=>{let t=Object.create(Vz);return t.current=e,t};var CC=(e)=>e.current;var mp=y(2,(e,t)=>(e.current=t,e));var an=Symbol.for("effect/MutableList/Empty"),Yo=()=>({head:void 0,tail:void 0,length:0}),dy=(e)=>{let t=e.head;if(t.offset>=1024&&t===e.tail&&t.mutable&&(t.array.length-t.offset)*8<=t.offset)e.head=e.tail={array:t.array.slice(t.offset),mutable:!0,offset:0,next:void 0}},OC=()=>({array:[],mutable:!0,offset:0,next:void 0}),Wr=(e,t)=>{if(!e.tail)e.head=e.tail=OC();else if(!e.tail.mutable)e.tail.next=OC(),e.tail=e.tail.next;e.tail.array.push(t),e.length++},ly=(e,t)=>{if(e.head={array:[t],mutable:!0,offset:0,next:e.head},!e.tail)e.tail=e.head;e.length++};var hp=(e,t)=>gp(e,_t(t),!Array.isArray(t)),gp=(e,t,n=!1)=>{if(t.length===0)return 0;let r={array:t,mutable:n,offset:0,next:void 0};if(e.head)e.tail=e.tail.next=r;else e.head=e.tail=r;return e.length+=t.length,t.length},Qo=(e)=>{e.head=e.tail=void 0,e.length=0},Ua=(e,t)=>{if(t=ht(t),t<=0||!e.head)return[];if(t=Math.min(t,e.length),t===e.length&&e.head?.offset===0&&!e.head.next){let s=e.head.array;return Qo(e),s}let n=Array(t),r=0,o=e.head;while(o){while(o.offset<o.array.length){if(n[r++]=o.array[o.offset],o.mutable)o.array[o.offset]=void 0;if(o.offset++,r===t){if(e.head=o.offset===o.array.length&&o.next?o.next:o,e.length-=t,e.length===0)Qo(e);else dy(e);return n}}o=o.next}return Qo(e),n},lu=(e,t)=>{if(t=ht(t),t<=0||!e.head)return;if(t=Math.min(t,e.length),t===e.length&&e.head?.offset===0&&!e.head.next){Qo(e);return}let n=0,r=e.head;while(r){let o=r.array.length-r.offset;if(n+o>t){r.offset+=t-n,e.head=r,e.length-=t,dy(e);return}n+=o,r=r.next}Qo(e);return},Fs=(e)=>Ua(e,e.length),Fa=(e)=>{if(!e.head)return an;let t=e.head.array[e.head.offset];if(e.head.mutable)e.head.array[e.head.offset]=void 0;if(e.head.offset++,e.length--,e.head.offset===e.head.array.length)if(e.head.next)e.head=e.head.next;else Qo(e);else dy(e);return t},_C=(e,t)=>{if(t=ht(t),t<=0)return[];let n=Math.min(t,e.length),r=Array(n),o=0,s=e.head;while(s){for(let a=s.offset;a<s.array.length;a++)if(r[o++]=s.array[a],o===n)return r;s=s.next}return r};var py=(e,t)=>{let n=[],r=e.head,o=0;while(r){for(let s=r.offset;s<r.array.length;s++)if(t(r.array[s],o++))n.push(r.array[s]);r=r.next}if(n.length===0){Qo(e);return}e.head=e.tail={array:n,mutable:!0,offset:0,next:void 0},e.length=n.length},RC=(e,t)=>py(e,(n)=>n!==t);var Qz="~effect/PubSub";var Yz="~effect/PubSub/Subscription",yp=(e)=>L(()=>o$(e.atomicPubSub(),new Map,ko(),ct(!1),hc(!1),e.strategy(),hc(ne()))),Sp=(e)=>yp({atomicPubSub:()=>xy(e),strategy:()=>new yy}),Ep=(e)=>yp({atomicPubSub:()=>xy(e),strategy:()=>new Sy}),bp=(e)=>yp({atomicPubSub:()=>xy(e),strategy:()=>new GC}),Ip=(e)=>yp({atomicPubSub:()=>MC(e),strategy:()=>new Sy}),xy=(e)=>{let t=typeof e==="number"?{capacity:e}:e;if(s$(t.capacity),t.capacity===1/0)return MC(t);let n=t.replay&&t.replay>0?new Iy(Math.ceil(t.replay)):void 0;if(t.capacity===1)return new $C(n);else if(PC(t.capacity)===t.capacity)return new LC(t.capacity,n);else return new NC(t.capacity,n)},MC=(e)=>{let t=e?.replay;return new HC(t&&t>0?new Iy(Math.ceil(t)):void 0)};var mu=(e)=>Xo(dt((t)=>(mp(e.shutdownFlag,!0),Te(e.scope,xp(t.id)).pipe(gt(e.strategy.shutdown),gy(e.shutdownHook.open),lr)))),wp=y(2,(e,t)=>L(()=>Xz(e,t))),Xz=y(2,(e,t)=>{if(e.shutdownFlag.current||ve(e.ended.current))return!1;if(mp(e.ended,oe(t)),e.strategy instanceof yy){for(let[r,o,s]of Fs(e.strategy.publishers))if(s)Da(o,xn(!1))}let n=xn(t);for(let r of e.subscribers.values())for(let o of r){let s;while((s=Fa(o))!==an)Da(s,n)}return e.subscribers.clear(),!0});var kp=y(2,(e,t)=>M(()=>{if(e.shutdownFlag.current||ve(e.ended.current))return b(!1);if(e.pubsub.publish(t))return e.strategy.completeSubscribersUnsafe(e.pubsub,e.subscribers),b(!0);return e.strategy.handleSurplus(e.pubsub,e.subscribers,[t],e.shutdownFlag)}));var UC=y(2,(e,t)=>M(()=>{if(e.shutdownFlag.current||ve(e.ended.current))return b(!1);let n=e.pubsub.publishAll(t);if(e.strategy.completeSubscribersUnsafe(e.pubsub,e.subscribers),n.length===0)return b(!0);return e.strategy.handleSurplus(e.pubsub,e.subscribers,n,e.shutdownFlag)})),hu=(e)=>Xo(Gr((t)=>{let n=Lt(t,ut),r=cn(e.scope),o=r$(e.pubsub,e.subscribers,e.strategy,e.ended);return Me(r,e$(o)).pipe(gt(dr(n,(s)=>Te(r,s))),nt(o))})),e$=(e)=>Xo(dt((t)=>(mp(e.shutdownFlag,!0),Jr(Fs(e.pollers),(n)=>hy(n,t.id),{discard:!0,concurrency:"unbounded"}).pipe(xt(()=>L(()=>{e.subscribers.delete(e.subscription),e.subscription.unsubscribe(),e.replayWindow.close(),e.strategy.onPubSubEmptySpaceUnsafe(e.pubsub,e.subscribers)})),gy(e.shutdownHook.open),lr)))),Tp=(e)=>M(()=>{if(e.shutdownFlag.current)return Kn;if(e.replayWindow.remaining>0){let n=e.replayWindow.take();return b(n)}let t=e.pollers.length===0?e.subscription.poll():an;if(t===an)return DC(e);else return e.strategy.onPubSubEmptySpaceUnsafe(e.pubsub,e.subscribers),b(t)}),FC=(e)=>M(function t(n){if(e.shutdownFlag.current)return Kn;let r=e.pollers.length===0?e.subscription.pollUpTo(Number.POSITIVE_INFINITY):[];if(n)r=n.concat(r);if(e.strategy.onPubSubEmptySpaceUnsafe(e.pubsub,e.subscribers),e.replayWindow.remaining>0)return b(e.replayWindow.takeAll().concat(r));else if(!Sn(r))return A(DC(e),(o)=>t([o]));return b(r)}),DC=(e)=>Gn((t)=>{if(e.shutdownFlag.current)return t(Kn);if(ve(e.ended.current))return t(b(e.ended.current.value));let n=pu(),r=e.subscribers.get(e.subscription);if(!r)r=new Set,e.subscribers.set(e.subscription,r);if(r.add(e.pollers),Wr(e.pollers,n),e.strategy.completePollersUnsafe(e.pubsub,e.subscribers,e.subscription,e.pollers),n.effect)return t(n.effect);return n.resumes=[t],L(()=>RC(e.pollers,n))});var ft=Symbol.for("effect/PubSub/AbsentValue"),t$=(e,t,n)=>{if(!e.has(t))e.set(t,new Set);e.get(t).add(n)},n$=(e,t,n)=>{if(!e.has(t))return;let r=e.get(t);if(r.delete(n),r.size===0)e.delete(t)},r$=(e,t,n,r)=>new WC(e,t,e.subscribe(),Yo(),ct(!1),hc(!1),n,e.replayWindow(),r);class NC{array;replayIndices;publisherIndex=0;subscribers;subscriberCount=0;subscribersIndex=0;capacity;replayBuffer;constructor(e,t){this.capacity=e,this.replayBuffer=t,this.array=Array.from({length:e}),this.replayIndices=t?Array.from({length:e}):[],this.subscribers=Array.from({length:e})}replayWindow(){return this.replayBuffer?new gu(this.replayBuffer):Ap}isEmpty(){return this.publisherIndex===this.subscribersIndex}isFull(){return this.publisherIndex===this.subscribersIndex+this.capacity}size(){return this.publisherIndex-this.subscribersIndex}publish(e){if(this.isFull())return!1;let t=this.replayBuffer?.offer(e);if(this.subscriberCount!==0){let n=this.publisherIndex%this.capacity;if(this.array[n]=e,t!==void 0)this.replayIndices[n]=t;this.subscribers[n]=this.subscriberCount,this.publisherIndex+=1}return!0}publishAll(e){if(this.subscriberCount===0){if(this.replayBuffer)this.replayBuffer.offerAll(e);return[]}let t=_t(e),n=t.length,r=this.publisherIndex-this.subscribersIndex,o=this.capacity-r,s=Math.min(n,o);if(s===0)return t;let a=0,i=this.publisherIndex+s;while(this.publisherIndex!==i){let c=t[a++],f=this.publisherIndex%this.capacity;this.array[f]=c;let u=this.replayBuffer?.offer(c);if(u!==void 0)this.replayIndices[f]=u;this.subscribers[f]=this.subscriberCount,this.publisherIndex+=1}return t.slice(a)}slide(){if(this.subscribersIndex!==this.publisherIndex){let e=this.subscribersIndex%this.capacity,t=this.array[e];this.array[e]=ft,this.subscribers[e]=0,this.subscribersIndex+=1,this.replayBuffer?.slide(t,this.replayIndices[e])}}subscribe(){return this.subscriberCount+=1,new BC(this,this.publisherIndex,!1)}}class BC{self;subscriberIndex;unsubscribed;constructor(e,t,n){this.self=e,this.subscriberIndex=t,this.unsubscribed=n}isEmpty(){return this.unsubscribed||this.self.publisherIndex===this.subscriberIndex||this.self.publisherIndex===this.self.subscribersIndex}size(){if(this.unsubscribed)return 0;return this.self.publisherIndex-Math.max(this.subscriberIndex,this.self.subscribersIndex)}poll(){if(this.unsubscribed)return an;if(this.subscriberIndex=Math.max(this.subscriberIndex,this.self.subscribersIndex),this.subscriberIndex!==this.self.publisherIndex){let e=this.subscriberIndex%this.self.capacity,t=this.self.array[e];if(this.self.subscribers[e]-=1,this.self.subscribers[e]===0)this.self.array[e]=ft,this.self.subscribersIndex+=1;return this.subscriberIndex+=1,t}return an}pollUpTo(e){if(e=ht(e),this.unsubscribed)return[];this.subscriberIndex=Math.max(this.subscriberIndex,this.self.subscribersIndex);let t=this.self.publisherIndex-this.subscriberIndex,n=Math.min(e,t);if(n<=0)return[];let r=[],o=this.subscriberIndex+n;while(this.subscriberIndex!==o){let s=this.subscriberIndex%this.self.capacity,a=this.self.array[s];if(this.self.subscribers[s]-=1,this.self.subscribers[s]===0)this.self.array[s]=ft,this.self.subscribersIndex+=1;r.push(a),this.subscriberIndex+=1}return r}unsubscribe(){if(!this.unsubscribed){this.unsubscribed=!0,this.self.subscriberCount-=1,this.subscriberIndex=Math.max(this.subscriberIndex,this.self.subscribersIndex);while(this.subscriberIndex!==this.self.publisherIndex){let e=this.subscriberIndex%this.self.capacity;if(this.self.subscribers[e]-=1,this.self.subscribers[e]===0)this.self.array[e]=ft,this.self.subscribersIndex+=1;this.subscriberIndex+=1}}}}class LC{array;replayIndices;mask;publisherIndex=0;subscribers;subscriberCount=0;subscribersIndex=0;capacity;replayBuffer;constructor(e,t){this.capacity=e,this.replayBuffer=t,this.array=Array.from({length:e}),this.replayIndices=t?Array.from({length:e}):[],this.mask=e-1,this.subscribers=Array.from({length:e})}replayWindow(){return this.replayBuffer?new gu(this.replayBuffer):Ap}isEmpty(){return this.publisherIndex===this.subscribersIndex}isFull(){return this.publisherIndex===this.subscribersIndex+this.capacity}size(){return this.publisherIndex-this.subscribersIndex}publish(e){if(this.isFull())return!1;let t=this.replayBuffer?.offer(e);if(this.subscriberCount!==0){let n=this.publisherIndex&this.mask;if(this.array[n]=e,t!==void 0)this.replayIndices[n]=t;this.subscribers[n]=this.subscriberCount,this.publisherIndex+=1}return!0}publishAll(e){if(this.subscriberCount===0){if(this.replayBuffer)this.replayBuffer.offerAll(e);return[]}let t=_t(e),n=t.length,r=this.publisherIndex-this.subscribersIndex,o=this.capacity-r,s=Math.min(n,o);if(s===0)return t;let a=0,i=this.publisherIndex+s;while(this.publisherIndex!==i){let c=t[a++],f=this.publisherIndex&this.mask;this.array[f]=c;let u=this.replayBuffer?.offer(c);if(u!==void 0)this.replayIndices[f]=u;this.subscribers[f]=this.subscriberCount,this.publisherIndex+=1}return t.slice(a)}slide(){if(this.subscribersIndex!==this.publisherIndex){let e=this.subscribersIndex&this.mask,t=this.array[e];this.array[e]=ft,this.subscribers[e]=0,this.subscribersIndex+=1,this.replayBuffer?.slide(t,this.replayIndices[e])}}subscribe(){return this.subscriberCount+=1,new zC(this,this.publisherIndex,!1)}}class zC{self;subscriberIndex;unsubscribed;constructor(e,t,n){this.self=e,this.subscriberIndex=t,this.unsubscribed=n}isEmpty(){return this.unsubscribed||this.self.publisherIndex===this.subscriberIndex||this.self.publisherIndex===this.self.subscribersIndex}size(){if(this.unsubscribed)return 0;return this.self.publisherIndex-Math.max(this.subscriberIndex,this.self.subscribersIndex)}poll(){if(this.unsubscribed)return an;if(this.subscriberIndex=Math.max(this.subscriberIndex,this.self.subscribersIndex),this.subscriberIndex!==this.self.publisherIndex){let e=this.subscriberIndex&this.self.mask,t=this.self.array[e];if(this.self.subscribers[e]-=1,this.self.subscribers[e]===0)this.self.array[e]=ft,this.self.subscribersIndex+=1;return this.subscriberIndex+=1,t}return an}pollUpTo(e){if(e=ht(e),this.unsubscribed)return[];this.subscriberIndex=Math.max(this.subscriberIndex,this.self.subscribersIndex);let t=this.self.publisherIndex-this.subscriberIndex,n=Math.min(e,t);if(n<=0)return[];let r=[],o=this.subscriberIndex+n;while(this.subscriberIndex!==o){let s=this.subscriberIndex&this.self.mask,a=this.self.array[s];if(this.self.subscribers[s]-=1,this.self.subscribers[s]===0)this.self.array[s]=ft,this.self.subscribersIndex+=1;r.push(a),this.subscriberIndex+=1}return r}unsubscribe(){if(!this.unsubscribed){this.unsubscribed=!0,this.self.subscriberCount-=1,this.subscriberIndex=Math.max(this.subscriberIndex,this.self.subscribersIndex);while(this.subscriberIndex!==this.self.publisherIndex){let e=this.subscriberIndex&this.self.mask;if(this.self.subscribers[e]-=1,this.self.subscribers[e]===0)this.self.array[e]=ft,this.self.subscribersIndex+=1;this.subscriberIndex+=1}}}}class $C{publisherIndex=0;subscriberCount=0;subscribers=0;value=ft;replayIndex=0;capacity=1;replayBuffer;constructor(e){this.replayBuffer=e}replayWindow(){return this.replayBuffer?new gu(this.replayBuffer):Ap}pipe(){return de(this,arguments)}isEmpty(){return this.subscribers===0}isFull(){return!this.isEmpty()}size(){return this.isEmpty()?0:1}publish(e){if(this.isFull())return!1;let t=this.replayBuffer?.offer(e);if(this.subscriberCount!==0){if(this.value=e,t!==void 0)this.replayIndex=t;this.subscribers=this.subscriberCount,this.publisherIndex+=1}return!0}publishAll(e){if(this.subscriberCount===0){if(this.replayBuffer)this.replayBuffer.offerAll(e);return[]}let t=_t(e);if(t.length===0)return t;if(this.publish(t[0]))return t.slice(1);else return t}slide(){if(this.isFull()){let e=this.value;this.subscribers=0,this.value=ft,this.replayBuffer?.slide(e,this.replayIndex)}}subscribe(){return this.subscriberCount+=1,new qC(this,this.publisherIndex,!1)}}class qC{self;subscriberIndex;unsubscribed;constructor(e,t,n){this.self=e,this.subscriberIndex=t,this.unsubscribed=n}isEmpty(){return this.unsubscribed||this.self.subscribers===0||this.subscriberIndex===this.self.publisherIndex}size(){return this.isEmpty()?0:1}poll(){if(this.isEmpty())return an;let e=this.self.value;if(this.self.subscribers-=1,this.self.subscribers===0)this.self.value=ft;return this.subscriberIndex=this.self.publisherIndex,e}pollUpTo(e){if(ht(e)<1||this.isEmpty())return[];return[this.poll()]}unsubscribe(){if(!this.unsubscribed){if(this.unsubscribed=!0,this.self.subscriberCount-=1,this.self.subscribers!==0&&this.subscriberIndex!==this.self.publisherIndex){if(this.self.subscribers-=1,this.self.subscribers===0)this.self.value=ft}}}}class HC{publisherHead={value:ft,replayIndex:void 0,subscribers:0,next:null};publisherTail=this.publisherHead;publisherIndex=0;subscribersIndex=0;capacity=Number.MAX_SAFE_INTEGER;replayBuffer;constructor(e){this.replayBuffer=e}replayWindow(){return this.replayBuffer?new gu(this.replayBuffer):Ap}isEmpty(){return this.publisherHead===this.publisherTail}isFull(){return!1}size(){return this.publisherIndex-this.subscribersIndex}publish(e){let t=this.replayBuffer?.offer(e),n=this.publisherTail.subscribers;if(n!==0){let r={value:e,replayIndex:t,subscribers:n,next:null};this.publisherTail.next=r,this.publisherTail=this.publisherTail.next,this.publisherIndex+=1}return!0}publishAll(e){if(this.publisherTail.subscribers!==0)for(let t of e)this.publish(t);else if(this.replayBuffer)this.replayBuffer.offerAll(e);return[]}slide(){if(this.publisherHead!==this.publisherTail){let e=this.publisherHead.next,t=e.value;this.publisherHead=this.publisherHead.next,this.publisherHead.value=ft,this.subscribersIndex+=1,this.replayBuffer?.slide(t,e.replayIndex)}}subscribe(){return this.publisherTail.subscribers+=1,new jC(this,this.publisherTail,this.publisherIndex,!1)}}class jC{self;subscriberHead;subscriberIndex;unsubscribed;constructor(e,t,n,r){this.self=e,this.subscriberHead=t,this.subscriberIndex=n,this.unsubscribed=r}isEmpty(){if(this.unsubscribed)return!0;let e=!0,t=!0;while(t)if(this.subscriberHead===this.self.publisherTail)t=!1;else if(this.subscriberHead.next.value!==ft)e=!1,t=!1;else this.subscriberHead=this.subscriberHead.next,this.subscriberIndex+=1;return e}size(){if(this.unsubscribed)return 0;return this.self.publisherIndex-Math.max(this.subscriberIndex,this.self.subscribersIndex)}poll(){if(this.unsubscribed)return an;let e=!0,t=an;while(e)if(this.subscriberHead===this.self.publisherTail)e=!1;else{let n=this.subscriberHead.next.value;if(n!==ft){if(t=n,this.subscriberHead.subscribers-=1,this.subscriberHead.subscribers===0)this.self.publisherHead=this.self.publisherHead.next,this.self.publisherHead.value=ft,this.self.subscribersIndex+=1;e=!1}this.subscriberHead=this.subscriberHead.next,this.subscriberIndex+=1}return t}pollUpTo(e){e=ht(e);let t=[],n=0;while(n!==e){let r=this.poll();if(r===an)n=e;else t.push(r),n+=1}return t}unsubscribe(){if(!this.unsubscribed){this.unsubscribed=!0,this.self.publisherTail.subscribers-=1;while(this.subscriberHead!==this.self.publisherTail){if(this.subscriberHead.next.value!==ft){if(this.subscriberHead.subscribers-=1,this.subscriberHead.subscribers===0)this.self.publisherHead=this.self.publisherHead.next,this.self.publisherHead.value=ft,this.self.subscribersIndex+=1}this.subscriberHead=this.subscriberHead.next}}}}class WC{[Yz]={_A:Q};pubsub;subscribers;subscription;pollers;shutdownHook;shutdownFlag;strategy;replayWindow;ended;constructor(e,t,n,r,o,s,a,i,c){this.pubsub=e,this.subscribers=t,this.subscription=n,this.pollers=r,this.shutdownHook=o,this.shutdownFlag=s,this.strategy=a,this.replayWindow=i,this.ended=c}pipe(){return de(this,arguments)}}class JC{[Qz]={_A:Q};pubsub;subscribers;scope;shutdownHook;shutdownFlag;strategy;ended;constructor(e,t,n,r,o,s,a){this.pubsub=e,this.subscribers=t,this.scope=n,this.shutdownHook=r,this.shutdownFlag=o,this.strategy=s,this.ended=a}pipe(){return de(this,arguments)}}var o$=(e,t,n,r,o,s,a)=>new JC(e,t,n,r,o,s,a),s$=(e)=>{if(e<=0)throw Error(`Cannot construct PubSub with capacity of ${e}`)};class yy{publishers=Yo();get shutdown(){return dt((e)=>Jr(Fs(this.publishers),([t,n,r])=>r?hy(n,e.id):R,{concurrency:"unbounded",discard:!0}))}handleSurplus(e,t,n,r){return Gn((o)=>{let s=pu();if(this.offerUnsafe(n,s),this.onPubSubEmptySpaceUnsafe(e,t),this.completeSubscribersUnsafe(e,t),CC(r))return this.removeUnsafe(s),o(Kn);if(s.effect)return o(s.effect);return s.resumes=[o],L(()=>this.removeUnsafe(s))})}onPubSubEmptySpaceUnsafe(e,t){let n=!0;while(n&&!e.isFull()){let r=Fa(this.publishers);if(r===an)n=!1;else{let[o,s]=r,a=e.publish(o);if(a&&r[2])Da(s,xn(!0));else if(!a)ly(this.publishers,r);this.completeSubscribersUnsafe(e,t)}}}completePollersUnsafe(e,t,n,r){return Ey(this,e,t,n,r)}completeSubscribersUnsafe(e,t){return by(this,e,t)}offerUnsafe(e,t){let n=e[Symbol.iterator](),r=n.next();if(!r.done)while(!0){let o=r.value;if(r=n.next(),r.done){Wr(this.publishers,[o,t,!0]);break}Wr(this.publishers,[o,t,!1])}}removeUnsafe(e){py(this.publishers,([t,n])=>n!==e)}}class Sy{get shutdown(){return R}handleSurplus(e,t,n,r){return b(!1)}onPubSubEmptySpaceUnsafe(e,t){}completePollersUnsafe(e,t,n,r){return Ey(this,e,t,n,r)}completeSubscribersUnsafe(e,t){return by(this,e,t)}}class GC{get shutdown(){return R}handleSurplus(e,t,n,r){return L(()=>(this.slidingPublishUnsafe(e,n),this.completeSubscribersUnsafe(e,t),!0))}onPubSubEmptySpaceUnsafe(e,t){}completePollersUnsafe(e,t,n,r){return Ey(this,e,t,n,r)}completeSubscribersUnsafe(e,t){return by(this,e,t)}slidingPublishUnsafe(e,t){let n=t[Symbol.iterator](),r=n.next();if(!r.done&&e.capacity>0){let o=r.value,s=!0;while(s){e.slide();let a=e.publish(o);if(a&&(r=n.next())&&!r.done)o=r.value;else if(a)s=!1}}}}var Ey=(e,t,n,r,o)=>{let s=!0;while(s&&!r.isEmpty()){let a=Fa(o);if(a===an)if(n$(n,r,o),o.length===0)s=!1;else t$(n,r,o);else{let i=r.poll();if(i===an)ly(o,a);else Da(a,xn(i)),e.onPubSubEmptySpaceUnsafe(t,n)}}},by=(e,t,n)=>{for(let[r,o]of n)for(let s of o)e.completePollersUnsafe(t,n,r,s)};class Iy{capacity;head={value:ft,index:0,next:null};tail=this.head;slideValues=[];size=0;index=0;publisherIndex=0;constructor(e){this.capacity=e}slide(e,t){this.slideValues[this.index%this.capacity]={value:e,index:t},this.index++}offer(e){let t=this.publisherIndex++;if(this.tail.value=e,this.tail.index=t,this.tail.next={value:ft,index:0,next:null},this.tail=this.tail.next,this.size===this.capacity)this.head=this.head.next;else this.size+=1;return t}offerAll(e){for(let t of e)this.offer(t)}}class gu{buffer;values;index=0;remaining;slideIndex;newestIndex=-1;constructor(e){this.buffer=e,this.remaining=e.size,this.slideIndex=e.index,this.values=Array(this.remaining);let t=e.head;for(let n=0;n<this.remaining;n++)this.values[n]=t.value,this.newestIndex=t.index,t=t.next}close(){this.values.length=0,this.remaining=0}sync(){let e=this.buffer.index-this.slideIndex;if(e===0||this.remaining===0)return;let t=Math.min(e,this.buffer.capacity),n=this.buffer.index-t;for(let r=0;r<t;r++){let o=this.buffer.slideValues[(n+r)%this.buffer.capacity];if(o.index>this.newestIndex)this.index=(this.index+1)%this.values.length,this.values[(this.index+this.remaining-1)%this.values.length]=o.value,this.newestIndex=o.index}this.slideIndex=this.buffer.index}take(){if(this.remaining===0)return;this.sync();let e=this.values[this.index];if(this.values[this.index]=ft,this.index=(this.index+1)%this.values.length,this.remaining--,this.remaining===0)this.close();return e}takeN(e){e=ht(e);let t=Math.min(e,this.remaining),n=Array(t);for(let r=0;r<t;r++)n[r]=this.take();return n}takeAll(){return this.takeN(this.remaining)}}var Ap={remaining:0,take:()=>{return},takeN:()=>[],takeAll:()=>[],close:()=>{return}};var a$="~effect/Queue",i$="~effect/Queue/Enqueue",c$="~effect/Queue/Dequeue";var wy={_A:Q,_E:Q},f$={[a$]:wy,[i$]:wy,[c$]:wy,...Ss,toJSON(){return{_id:"effect/Queue",state:this.state._tag,size:d$(this)}}},hr=(e)=>mr((t)=>{let n=Object.create(f$);return n.dispatcher=t.currentDispatcher,n.capacity=e?.capacity??Number.POSITIVE_INFINITY,n.strategy=e?.strategy??"suspend",n.messages=Yo(),n.scheduleRunning=!1,n.state={_tag:"Open",takers:new Set,offers:new Set,awaiters:new Set},Ns(n)}),Ba=(e)=>hr({capacity:e});var _p=()=>hr(),bn=y(2,(e,t)=>Ao(()=>Rp(e,t)?Up:e.state._tag==="Open"&&e.strategy==="suspend"?h$(e,t):ev)),Rp=(e,t)=>{if(e.state._tag!=="Open")return!1;else if(e.messages.length>=e.capacity){if(e.strategy==="sliding")return Fa(e.messages),Wr(e.messages,t),!0;else if(e.capacity<=0&&e.state.takers.size>0)return Wr(e.messages,t),tv(e),!0;return!1}return Wr(e.messages,t),Cp(e),!0},ts=y(2,(e,t)=>Bs((n)=>{let r=Pp(e,t);if(r.length===0||e.strategy==="dropping")return n(Kr(r));return rv(e,{_tag:"Array",remaining:r,offset:0,resume:n})})),Pp=(e,t)=>{if(e.state._tag!=="Open")return _t(t);else if(e.capacity===Number.POSITIVE_INFINITY||e.strategy==="sliding"){if(hp(e.messages,t),e.strategy==="sliding")Ua(e.messages,e.messages.length-e.capacity);return Cp(e),[]}let n=e.capacity<=0?e.state.takers.size:e.capacity-e.messages.length;if(n===0)return _t(t);let r=[],o=0;for(let s of t){if(o<n)Wr(e.messages,s);else r.push(s);o++}return Cp(e),r};var rt=y(2,(e,t)=>To(()=>Ls(e,t))),Ls=(e,t)=>{if(e.state._tag!=="Open")return!1;let n=VC(t),r=YC(n,l$);if(e.state.offers.size===0&&e.messages.length===0)return Fp(e,r),!0;return e.state={...e.state,_tag:"Closing",exit:r},Cp(e),!0},gc=(e)=>rt(e,Ty(vp())),Mp=(e)=>Ls(e,Ty(vp()));var Vr=(e)=>To(()=>vy(e)),vy=(e)=>{if(e.state._tag==="Done")return!1;Qo(e.messages);let t=e.state.offers;Fp(e,e.state._tag==="Open"?p$:e.state.exit);for(let n of t)ov(n);return!0};var xc=(e)=>XC(e,1,Number.POSITIVE_INFINITY);var XC=y(3,(e,t,n)=>(t=ht(t),n=ht(n),Ao(()=>m$(e,t,n)??Ay(nv(e,()=>Oy(e,t)),XC(e,t,n))))),Zr=(e)=>Ao(()=>u$(e)??Ay(nv(e,()=>Oy(e,1)),Zr(e)));var u$=(e)=>{if(e.state._tag==="Done")return e.state.exit;if(e.messages.length>0){let t=Fa(e.messages);return ky(e),Kr(t)}else if(e.capacity<=0&&e.state.offers.size>0){let t=sv(e.state.offers);return ky(e),Kr(t)}return};var d$=(e)=>e.state._tag==="Done"?0:e.messages.length;var ev=Kr(!1),Up=Kr(!0),l$=ZC(vp()),p$=QC(),tv=(e)=>{if(e.state._tag==="Done"||e.state.takers.size===0)return;for(let t of e.state.takers){if(!t.ready())continue;if(e.state.takers.delete(t),t.resume(Cy),e.messages.length===0)break}},Cp=(e)=>{if(e.scheduleRunning||e.state._tag==="Done"||e.state.takers.size===0)return;e.scheduleRunning=!0,e.dispatcher.scheduleTask(()=>{e.scheduleRunning=!1,tv(e)},0)},m$=(e,t,n)=>{if(e.state._tag==="Done")return e.state.exit;else if(n<=0||t<=0)return Kr([]);else if(!Oy(e,t))return;let r=e.messages.length>0?Ua(e.messages,n):[sv(e.state.offers)];return ky(e),Kr(r)},Oy=(e,t)=>e.messages.length>=(e.state._tag==="Closing"?1:Math.min(t,e.capacity||1))||e.capacity<=0&&e.state._tag!=="Done"&&e.state.offers.size>0,nv=(e,t)=>Bs((n)=>{if(e.state._tag==="Done")return n(e.state.exit);if(t())return n(Cy);let r={ready:t,resume:n};return e.state.takers.add(r),To(()=>{if(e.state._tag!=="Done")e.state.takers.delete(r)})}),h$=(e,t)=>Bs((n)=>Rp(e,t)?n(Up):rv(e,{_tag:"Single",message:t,resume:n})),rv=(e,t)=>{if(e.state._tag!=="Open")return ov(t);let n=e.state.offers;return n.add(t),To(()=>{if(e.state._tag==="Done")return;if(n.delete(t),e.state._tag==="Closing"&&n.size===0&&e.messages.length===0)Fp(e,e.state.exit)})},ov=(e)=>e._tag==="Single"?e.resume(ev):e.resume(Kr(e.remaining.slice(e.offset))),sv=(e)=>{let t=e.values().next().value;if(t._tag==="Single")return e.delete(t),t.resume(Up),t.message;let n=t.remaining[t.offset++];if(t.offset===t.remaining.length)e.delete(t),t.resume(Kr([]));return n},ky=(e)=>{if(e.state._tag==="Done")return es(e.state.exit.cause);else if(e.state.offers.size===0){if(e.state._tag==="Closing"&&e.messages.length===0)return Fp(e,e.state.exit),es(e.state.exit.cause);return!1}for(let t of e.state.offers){let n=e.capacity-e.messages.length;if(n<=0)break;else if(t._tag==="Single")Wr(e.messages,t.message),e.state.offers.delete(t),t.resume(Up);else{for(;t.offset<t.remaining.length;t.offset++){if(n===0)return!1;Wr(e.messages,t.remaining[t.offset]),n--}e.state.offers.delete(t),t.resume(Kr([]))}}return!1};var Fp=(e,t)=>{if(e.state._tag==="Done")return;let n=e.state;e.state={_tag:"Done",exit:t};for(let r of n.takers)r.resume(t);n.takers.clear();for(let r of n.awaiters)r(t);n.awaiters.clear()};var La=(e)=>new fv(e),av=(e,t,n)=>Bs((r)=>{if(e.free>=t)return r(n);let o=()=>{if(e.free<t)return;e.waiters.delete(o),r(n)};return e.waiters.add(o),To(()=>{e.waiters.delete(o)})});class fv{waiters=new Set;taken=0;permits;constructor(e){this.permits=e}get free(){return this.permits-this.taken}take(e){let t=Ao(()=>{if(this.free<e)return av(this,e,t);return this.taken+=e,Ns(e)});return t}takeIfAvailable(e){return Ao(()=>{if(this.free<e)return Ns(!1);return this.taken+=e,Ns(!0)})}releaseUnsafe(e,t){if(this.taken-=t,this.waiters.size>0)e.currentDispatcher.scheduleTask(()=>{for(let n of this.waiters){if(this.free<=0)break;n()}},0);return this.free}resize(e){return mr((t)=>{if(this.permits=e,this.free<0)return Co;return this.releaseUnsafe(t,0),Co})}release(e){return mr((t)=>Ns(this.releaseUnsafe(t,e)))}get releaseAll(){return mr((e)=>Ns(this.releaseUnsafe(e,this.taken)))}withPermits(e){return(t)=>Na((n)=>{let r=Ao(()=>{if(this.free<e){let o=av(this,e,Co);return Su(n(o),()=>r)}return this.taken+=e,yu(n(t),()=>{this.releaseUnsafe(_y(),e);return},!0)});return r})}withPermit=this.withPermits(1);withPermitsIfAvailable(e){return(t)=>Na((n)=>{if(this.free<e)return iv;return this.taken+=e,yu(n(cv(t)),()=>{this.releaseUnsafe(_y(),e);return},!0)})}}var Ry=(e)=>Zo(e)?$e(e)?ee(e.value):e:b(e);var Mv="~effect/Channel",Gt=(e)=>V(e,Mv),y$={[Mv]:{_Env:Q,_InErr:Q,_InElem:Q,_OutErr:Q,_OutElem:Q},pipe(){return de(this,arguments)}},me=(e)=>{let t=Object.create(y$);return t.transform=(n,r)=>De(e(n,r),(o)=>b(He(o))),t},Xr=(e,t)=>me((n,r)=>A(ie(e)(n,r),(o)=>t(o,r))),Ut=(e)=>me((t,n)=>e),eo=(e)=>me(re(function*(t,n){let r=cn(n),o=(a)=>Te(r,Uy(a)),s=yield*Vn(e(t,n,r),o);return Vn(s,o)})),ie=(e)=>e.transform,Au=4096,S$=(e,t,n)=>hr({capacity:n?.bufferSize,strategy:n?.strategy}).pipe(xt((r)=>Me(e,Vr(r))),xt((r)=>Ne(In(t(r),e),e)));var Uv=(e,t)=>me((n,r)=>B(S$(r,e,t),xc)),zp=(e)=>me((t,n)=>M(()=>ie(e())(t,n))),E$=(e,t,n)=>eo(re(function*(r,o,s){let a=ne();yield*dr(s,(c)=>ve(a)?n(a.value,c):R);let i=yield*Xo(e);return a=oe(i),yield*ie(t(i))(r,o)}));var Fv=(e)=>Ut(L(()=>{let t=e();return M(()=>{let n=t.next();return n.done?ee(n.value):b(n.value)})})),By=(e)=>Ut(L(()=>{let t=0;return M(()=>t>=e.length?ee():b(e[t++]))}));var Ly=(e,t=Au)=>{let n=qs(t);return Ut(L(()=>{let r=e(),o=ne();return M(()=>{if(o._tag==="Some")return ee(o.value);let s=[];while(s.length<n){let a=r.next();if(a.done){if(s.length===0)return ee(a.value);o=oe(a.value);break}s.push(a.value)}return b(s)})}))};var Dv=(e,t=Au)=>Ly(()=>e[Symbol.iterator](),t),$p=(e)=>qp(b(e));var Nv=(e)=>qp(L(e)),yc=Ut(b(ee())),Bv=Ut(b(Hs)),Oo=(e)=>Ut(b(_(e))),Lv=(e)=>Ut(Fy(e)),Cu=(e)=>Ut(He(e)),zv=(e)=>Ut(Os(e)),zy=(e)=>Cu(Fi(e)),qp=(e)=>Ut(L(()=>{let t=!1;return M(()=>{if(t)return ee();return t=!0,e})}));var $v=(e)=>Ut(A(e,()=>ee())),$y=(e)=>Ut(b(A(e,Ry)));var qv=(e)=>Ut(b(xc(e)));var qy=(e)=>Ut(b(Ic(FC(e),()=>ee())));var Hv=(e)=>no(B(hu(e),qy)),jv=(e)=>no(B(hu(e),(t)=>$y(Tp(t))));var Wv=(e)=>me((t,n)=>b$({scope:n,readable:e.evaluate(),onError:e.onError,releaseLockOnEnd:e.releaseLockOnEnd}));var b$=(e)=>{let t=e.readable.getReader(),n=e.exit??hc(void 0),r=M(()=>{if(n.current)return n.current;return ns(fr({try:()=>t.read(),catch:e.onError}),{onFailure:(o)=>n.current??He(o),onSuccess:({done:o,value:s})=>{if(n.current)return n.current;return o?ee():b(pe(s))}})});return nt(Me(e.scope,e.releaseLockOnEnd?L(()=>t.releaseLock()):Ec(()=>t.cancel().catch(Mn))),r)},I$=(e,t)=>me(re(function*(n,r){let o=e[Symbol.asyncIterator]();if(o.return)yield*Me(r,Ec(()=>o.return()));return A(fr({try:()=>o.next(),catch:t}),(s)=>s.done?ee(s.value):b(s.value))})),Jv=(e,t)=>to(I$(e,t),pe),to=y(2,(e,t)=>Xr(e,(n)=>L(()=>{let r=0;return B(n,(o)=>t(o,r++))})));var Gv=(e)=>e===void 0||e!=="unbounded"&&e<=1,Hp=y((e)=>Gt(e[0]),(e,t,n)=>Gv(n?.concurrency)?Kv(e,t):w$(e,t,n)),Kv=(e,t)=>me((n,r)=>{let o=0;return B(ie(e)(n,r),A((s)=>t(s,o++)))}),w$=(e,t,n)=>eo(re(function*(r,o,s){let a=0,i=yield*ie(e)(r,o),c=n.concurrency==="unbounded"?Number.MAX_SAFE_INTEGER:n.concurrency,f=yield*Ba(0);yield*Me(s,Vr(f));let u=Fn(yield*Qn()),d=js(s);if(n.unordered){let l=La(c),m=pr(l.release(1)),p=ns({onFailure:(g)=>A(rt(f,g),m),onSuccess:(g)=>A(bn(f,g),m)});yield*l.take(1).pipe(A(()=>i),A((g)=>{let h=a++;return d(u(p(M(()=>t(g,h))))),R}),Ze({disableYield:!0}),De((g)=>l.withPermits(c-1)(rt(f,g))),Ne(s))}else{let l=yield*Ba(c-2);yield*Me(s,Vr(l)),yield*Zr(l).pipe(vv,A((g)=>bn(f,g)),Ze({disableYield:!0}),De((g)=>rt(f,g)),Ne(s));let m,p=(g)=>{if(g._tag==="Success")return;m=g.cause,Ls(f,g.cause)};yield*i.pipe(A((g)=>{if(m)return He(m);let h=a++,E=u(M(()=>t(g,h)));return d(E),E.addObserver(p),bn(l,$s(E))}),Ze({disableYield:!0}),De((g)=>bn(l,en(g)).pipe(gt(rt(l,g)))),Ne(s))}return Zr(f)}));var Hy=y((e)=>Gt(e[0]),(e,t,n)=>Gv(n?.concurrency)?k$(e,t):T$(e,t,n)),k$=(e,t)=>me((n,r)=>B(ie(e)(n,r),(o)=>{let s,a,i=A(o,(f)=>(a??=cn(r),Pt(ie(t(f))(n,a),(u)=>(s=c(u),s)))),c=lt((f)=>{if(s=void 0,a.state._tag==="Empty")return i;let u=Te(a,Ye);return a=void 0,A(u,()=>i)});return M(()=>s??i)})),T$=(e,t,n)=>e.pipe(to(t),Jp(n)),Vv=y(2,(e,t)=>me((n,r)=>L(()=>{let o,s=cn(r),a=A(ie(e)(n,s),(i)=>(o=lt(i,(c)=>Te(s,Ye).pipe(A(()=>ie(t(c))(n,r)),A((f)=>(o=f,f)))),o));return M(()=>o??a)})));var jy=y(4,(e,t,n,r)=>me(re(function*(o,s){let a=yield*ie(e)(o,s),i=yield*ie(t)(o,s),c=n();return M(()=>{let f=r(c,a,i);return B(f,([u,d])=>(c=d,u))})}))),Zv=y(2,(e,t)=>me((n,r)=>L(()=>{let o,s=cn(r),a=A(ie(e)(n,s),(i)=>{let c=i.pipe(xt(()=>(o=i,R)),lt((f)=>Te(s,xn(f)).pipe(gt(ie(t(f))(n,r)),A((u)=>(o=u,u)))));return o=c,c});return M(()=>o??a)}))),Qv=(e)=>Hy(e,Q),un=(e)=>Xr(e,(t)=>{let n,r=0,o=M(function s(){if(n===void 0)return A(t,(i)=>{switch(i.length){case 0:return s();case 1:return b(i[0]);default:return n=i,b(i[r++])}});let a=n[r++];if(r>=n.length)n=void 0,r=0;return b(a)});return b(o)}),Yv=(e)=>Kv(e,Ry),Xv=(e)=>Xr(e,(t)=>b(Ze(t,{disableYield:!0}))),eO=y(2,(e,t)=>Sc(typeof t==="function"?t(Q):t).pipe(B((n)=>{let r=Qr.defaultValue();return tO(Zp(e,Qr,L(()=>r)),(o)=>n(o).pipe(B((s)=>{r=s}),lt(()=>ee(o))))}),no)),tO=(e,t)=>me((n,r)=>L(()=>{let o,s=()=>{let a=cn(r);return A(ie(e)(n,a),(i)=>(o=lt(i,(c)=>Te(a,Ye).pipe(A(()=>t(c)),A(s))),o))};return M(()=>o??s())})),nO=(e)=>tO(e,()=>R),rO=y(2,(e,t)=>Xr(e,(n,r)=>B(Iu(t),(o)=>xt(n,o)))),oO=y(2,(e,t)=>me((n,r)=>B(ie(e)(n,r),(o)=>A(o,function s(a){return t(a)?b(a):A(o,s)}))));var sO=y(2,(e,t)=>Xr(e,(n)=>b(A(n,function r(o){let s=[];for(let a=0;a<o.length;a++)if(t(o[a]))s.push(o[a]);return Ke(s)?b(s):A(n,r)})))),aO=y(2,(e,t)=>Xr(e,(n)=>b(A(n,function r(o){let s=[];for(let a=0;a<o.length;a++){let i=t(o[a]);if(At(i))s.push(i.success)}return Ke(s)?b(s):A(n,r)})))),iO=y(2,(e,t)=>Xr(e,(n)=>{let r=A(n,(o)=>_v(o,t));return b(A(r,function o(s){return Ke(s)?b(s):A(r,o)}))})),cO=y(2,(e,t)=>Xr(e,(n)=>b(A(n,function r(o){return A(Rv(o,t),(s)=>Ke(s)?b(s):A(n,r))})))),wc=y((e)=>Gt(e[0]),(e,t,n,r)=>me((o,s)=>B(ie(e)(o,s),(a)=>{let i=t(),c,f=0,u,d=ns(a,{onFailure(m){u=m;let p=r?.onHalt&&r.onHalt(i);return p&&p.length>0?b([i,p]):He(m)},onSuccess(m){let p=n(i,m);return hv(p)?b(p):p}});return M(function m(){if(c===void 0){if(u)return He(u);return A(d,([g,h])=>{if(i=g,h.length===0)return m();else if(h.length===1)return b(h[0]);return c=h,m()})}let p=c[f++];if(f>=c.length)c=void 0,f=0;return b(p)})})));var fO=y(3,(e,t,n)=>me((r,o)=>B(ie(e)(r,o),(s)=>{let a=t,i=!0;return M(()=>{if(i)return i=!1,b(a);return B(A(s,(c)=>n(a,c)),(c)=>(a=c,a))})}))),kc=y(2,(e,t)=>me((n,r)=>{let o=cn(r);return B(ie(e)(n,o),(s)=>{let a=s.pipe(De((i)=>{if(es(i))return He(i);let c=o;return o=cn(r),Te(c,en(i)).pipe(gt(ie(t(i))(n,o)),A((f)=>(a=f,f)))}));return M(()=>a)})})),uO=y(2,(e,t)=>Wp(e,Np,t)),jp=y(2,(e,t)=>kc(e,(n)=>$v(A(t(n),(r)=>He(n))))),dO=y(3,(e,t,n)=>kc(e,(r)=>t(r)?n(r):Cu(r))),Wp=y(3,(e,t,n)=>kc(e,(r)=>{let o=t(r);return Bt(o)?Cu(o.failure):n(o.success,r)})),Yr=y(2,(e,t)=>Wp(e,bu,(n)=>t(n)));var lO=y(2,(e,t)=>Xr(e,(n)=>b(Ny(n,(r)=>My(r)?R:lr(t(r)))))),pO=y((e)=>Gt(e[0]),(e,t,n,r)=>Yr(e,(o)=>t(o)?n(o):r?r(o):Oo(o))),mO=y((e)=>Gt(e[0]),(e,t,n,r)=>Yr(e,(o)=>{let s=t(o);return Bt(s)?r?r(s.failure):Oo(s.failure):n(s.success)}));var hO=y((e)=>Gt(e[0]),(e,t,n,r,o)=>Yr(e,(s)=>{if(vo(s,t)&&V(s,"reason")){let a=s.reason;if(vo(a,n))return r(a,s);return o?o(a,s):Oo(s)}return Oo(s)})),gO=y((e)=>Gt(e[0]),(e,t,n,r)=>{let o;return Yr(e,(s)=>{if(vo(s,t)&&V(s,"reason")&&V(s.reason,"_tag")&&Bp(s.reason._tag)){let a=s.reason;if(o??=new Set(Object.keys(n)),o.has(a._tag))return n[a._tag](a,s);return r?r(a,s):Oo(s)}return Oo(s)})});var xO=y(2,(e,t)=>Yr(e,(n)=>Oo(t(n)))),yO=(e)=>Yr(e,zy),SO=y((e)=>Gt(e[0]),(e,t)=>{if(!t?.log)return Yr(e,()=>yc);let n=ku(t.log===!0?void 0:t.log);return Yr(jp(e,(r)=>Sv(r)?n(r):R),()=>yc)}),dv=(e)=>kc(e,()=>yc),EO=y((e)=>Gt(e[0]),(e,t)=>{if(!t?.log)return dv(e);let n=ku(t.log===!0?void 0:t.log);return dv(jp(e,(r)=>n(r)))}),bO=y(2,(e,t)=>zp(()=>{let n=void 0,r=Qr.defaultValue(),o=Zp(e,Qr,L(()=>r)),s=Gy(o,()=>(n=void 0,R)),a=typeof t==="function"?t(Q):t,i=Yr(s,re(function*(c){if(!n)n=yield*Sc(a);return r=yield*n(c),i},(c,f)=>lt(c,()=>b(Oo(f))),no));return i})),IO=y((e)=>Gt(e[0]),(e,t,n)=>e.pipe(to(t),Jp({...n,concurrency:n?.concurrency??1,switch:!0}))),Jp=y(2,(e,{bufferSize:t=16,concurrency:n,switch:r=!1})=>eo(re(function*(o,s,a){let i=n==="unbounded"?Number.MAX_SAFE_INTEGER:Math.max(1,n),c=r?void 0:La(i),f=yield*TC(!0),u=new Set,d=yield*Ba(t);yield*Me(a,Vr(d));let l=yield*ie(e)(o,s);return yield*je(function*(){while(!0){let m;if(c)if(u.size<i)yield*c.take(1);else m=yield*Eu(l),yield*za(c.take(1),gt($s(m),Hs));let p=m===void 0?yield*l:yield*$s(m),g=cn(a),h=yield*ie(p)(o,g);while(u.size>=i){let S=mv(u);if(u.delete(S),u.size===0)yield*f.open;yield*fn(S)}let E=yield*h.pipe(xt(()=>Lp),A((S)=>bn(d,S)),Ze({disableYield:!0}),Vn(re(function*(S){let k=Py(S);if(yield*or(Te(g,!Bt(k)?xn(k.success.value):en(k.failure))),!u.has(E))return;if(u.delete(E),c)yield*c.release(1);if(u.size===0)yield*f.open;if(At(k))return;return yield*rt(d,S)})),Eu);f.closeUnsafe(),u.add(E)}}).pipe(De((m)=>{let p=Py(m);if(At(p))return f.whenOpen(rt(d,m));return rt(d,m)}),Ne(a)),Zr(d)}))),Gp=y((e)=>Gt(e[0])&&Gt(e[1]),(e,t,n)=>eo(re(function*(r,o,s){let a=n?.haltStrategy??"both",i=yield*Ba(0);yield*Me(s,Vr(i));let c=0;function f(d,l){if(c++,!es(l))return rt(i,l);switch(a){case"both":return c===2?rt(i,l):R;case"left":case"right":return d===a?rt(i,l):R;case"either":return rt(i,l)}}let u=(d,l,m)=>ie(l)(r,m).pipe(A((p)=>p.pipe(A((g)=>bn(i,g)),Ze)),Vn((p)=>gt(Te(m,Uy(p)),f(d,p))),Ne(s));return yield*u("left",e,cn(s)),yield*u("right",t,cn(s)),Zr(i)}))),wO=y(2,(e,t)=>Gp(e,$v(t),{haltStrategy:"left"})),kO=()=>me((e,t)=>L(()=>{let n="",r=!1,o=ne();function s(c){let f=[];function u(d){if(n.length===0)f.push(d);else f.push(n+d),n=""}for(let d=0;d<c.length;d++){let l=c[d];if(l.length!==0){let m=0,p=l.indexOf("\r"),g=l.indexOf(`
|
|
7
7
|
`);if(r){if(g===0)m=1,g=l.indexOf(`
|
|
8
8
|
`,m);r=!1}while(p!==-1||g!==-1)if(p===-1||g!==-1&&g<p)u(l.substring(m,g)),m=g+1,g=l.indexOf(`
|
|
9
9
|
`,m);else if(u(l.substring(m,p)),l.length===p+1)r=!0,m=l.length,p=-1;else m=p+(g===p+1?2:1),p=l.indexOf("\r",m),g=l.indexOf(`
|
|
10
|
-
`,m);n=n+l.substring(m)}}return Ke(f)?f:null}let a=M(()=>{if(o._tag==="Some")return ee(o.value);return Cv(e,{onSuccess:i,onFailure:He,onDone:(c)=>{if(o=oe(c),n.length>0){let f=n;return n="",r=!1,b([f])}return ee(c)}})});function i(c){let f=s(c);return f!==null?b(f):a}return a}));var Wy=y(2,(e,t)=>me((n,r)=>A(ie(e)(n,r),(o)=>ie(t)(o,r)))),Jy=y(2,(e,t)=>me((n,r)=>A(ie(e)(n,r),(o)=>{let s=De(o,(a)=>es(a)?He(a):_n(bv(a)));return B(ie(t)(s,r),(a)=>_v(a,(i)=>My(i)?He(i.value):_n(i)))}))),no=(e)=>me((t,n)=>{let r;return b(M(()=>{if(r)return r;return e.pipe(In(n),A((o)=>ie(o)(t,n)),A((o)=>r=o))}))}),AO=(e)=>eo((t,n,r)=>B(In(ie(e)(t,n),r),In(r)));var CO=y(2,(e,t)=>me(re(function*(n,r){let o=yield*ie(e)(n,r),s=yield*hr({capacity:t.capacity==="unbounded"?void 0:t.capacity,strategy:t.capacity==="unbounded"?void 0:t.strategy});return yield*Me(r,Vr(s)),yield*o.pipe(A((a)=>bn(s,a)),Ze({disableYield:!0}),Vn((a)=>rt(s,a)),Ne(r)),Zr(s)}))),vO=y(2,(e,t)=>me(re(function*(n,r){let o=yield*ie(e)(n,r),s=yield*hr({capacity:t.capacity==="unbounded"?void 0:t.capacity,strategy:t.capacity==="unbounded"?void 0:t.strategy});return yield*Me(r,Vr(s)),yield*o.pipe(A((a)=>ts(s,a)),Ze({disableYield:!0}),Vn((a)=>rt(s,a)),Ne(r)),xc(s)}))),OO=y(2,(e,t)=>Gp(e,Ut(b(A(t,ee))),{haltStrategy:"either"})),_O=y(2,(e,t)=>eo(re(function*(n,r,o){let s=yield*ie(e)(n,r),a=yield*Ne(t,o,{startImmediately:!0});return M(()=>{let i=a.pollUnsafe();return i===void 0?s:Iv(i,{onFailure:He,onSuccess:ee})})}))),RO=y(2,(e,t)=>vu(e,(n)=>bo(n)?t(n.cause):R)),vu=y(2,(e,t)=>eo((n,r,o)=>dr(o,t).pipe(gt(ie(e)(n,r))))),PO=y(2,(e,t)=>no(nt(t,e))),Gy=y(2,(e,t)=>Xr(e,(n)=>L(()=>{let r=!0,o=xt(n,(s)=>(r=!1,t(s)));return M(()=>r?o:n)}))),MO=y(2,(e,t)=>Xr(e,(n)=>b(lt(n,(r)=>A(t,()=>ee(r)))))),UO=y(2,(e,t)=>vu(e,(n)=>t)),$a=(e,t,n)=>M(()=>{let r=ko(),o=ie(e)(ee(),r);return lt(A(o,t),n?n:b).pipe(yr((s)=>Te(r,s)))});var Kp=y(2,(e,t)=>me((n,r)=>B(Jt(ie(e)(n,r),t),Jt(t)))),Vp=y(3,(e,t,n)=>me((r,o)=>B(zs(ie(e)(r,o),t,n),zs(t,n)))),Zp=y(3,(e,t,n)=>me((r,o)=>A(n,(s)=>ie(Vp(e,t,s))(r,o)))),FO=y((e)=>Gt(e[0]),(e,t,n)=>mv(t)?Kp(e,t):me((r,o)=>A(n?.local?Tv(t,kv(),o):Av(t,o),(s)=>B(Jt(ie(e)(r,o),s),Jt(s))))),DO=y(2,(e,t)=>me((n,r)=>Gr((o)=>{let s=t(o);return ie(Kp(e,s))(n,r)})));var Ky=function(){let e=Gt(arguments[0]),t=e?arguments[1]:arguments[0],n=Dp(e?arguments[2]:arguments[1]);if(e){let r=arguments[0];return pv(r,t,n)}return(r)=>pv(r,t,n)},pv=(e,t,n)=>E$(Mv(t,n),(r)=>Vp(e,xv,r),(r,o)=>dt((s)=>{let a=s.getRef(Sv),i=s.getRef(wv);return yv(r,o,a,i)}));var NO=(e)=>$a(e,(t)=>Ze(t,{disableYield:!0})),qa=y(2,(e,t)=>$a(e,(n)=>Ze(A(n,t),{disableYield:!0}))),BO=y(2,(e,t)=>$a(e,(n)=>n.pipe(A(t),A((r)=>r?R:ee()),Ze({disableYield:!0})))),Vy=(e)=>B(Ha(e,()=>({bytes:0,arrays:[]}),(t,n)=>{for(let r=0;r<n.length;r++)t.bytes+=n[r].length,t.arrays.push(n[r]);return t}),({arrays:t,bytes:n})=>{let r=new Uint8Array(n),o=0;for(let s=0;s<t.length;s++){let a=t[s];r.set(a,o),o+=a.length}return r});var LO=(e)=>M(()=>{let t=ne();return $a(e,(n)=>n.pipe(Dy,A((r)=>(t=r,ee()))),()=>b(t))}),zO=(e)=>M(()=>{let t=Symbol(),n=t;return $a(e,(r)=>Ze(A(r,(o)=>(n=o,R)),{disableYield:!0}),()=>n===t?Si:vv(n))}),Ha=y(3,(e,t,n)=>M(()=>{let r=t();return $a(e,(o)=>gr({while:Ds,body:()=>o,step:(s)=>{r=n(r,s)}}),()=>b(r))})),$O=y(3,(e,t,n)=>M(()=>{let r=t();return $a(e,(o)=>gr({while:Ds,body:pr(o.pipe(A((s)=>n(r,s)),B((s)=>{r=s}))),step:Mn}),()=>b(r))})),Zy=re(function*(e){let t=La(1),n=yield*Qn(),r=Lt(n,ut);return(yield*ie(e)(ee(),r)).pipe(Jt(n),t.withPermits(1))},De((e)=>b(He(e)))),Po=(e,t)=>ie(e)(ee(),t);var Qy=y((e)=>Gt(e[0]),(e,t)=>Xn((n)=>qa(e,(r)=>ts(t,r)).pipe(n,or,A((r)=>{if($e(r))Mp(t);else Ls(t,r.cause);return R}))));var qO=y((e)=>Gt(e[0]),re(function*(e,t){let n=yield*Yn,r=yield*hr({capacity:typeof t.capacity==="number"?t.capacity:void 0,strategy:typeof t.capacity==="number"?t.strategy:void 0});return yield*Me(n,Vr(r)),yield*Ne(Qy(e,r),n),r}));var HO=(e)=>xr(e.capacity==="unbounded"?Ip(e):e.strategy==="dropping"?Ep(e):e.strategy==="sliding"?bp(e):Sp(e),mu),jO=y(2,re(function*(e,t){let n=yield*HO(t);return yield*Ro(Yy(e,n,{shutdownOnEnd:t.shutdownOnEnd!==!1})),n})),Yy=y((e)=>Gt(e[0]),(e,t,n)=>qa(e,(r)=>FC(t,r)).pipe(n?.shutdownOnEnd===!0?_o(mu(t)):Q)),WO=y(2,re(function*(e,t){let n=yield*HO(t);return yield*qa(e,(r)=>kp(n,r)).pipe(yr((r)=>wp(n,r)),Ro),n}));var A$="~effect/Stream",C$={_R:Q,_E:Q,_A:Q},JO=function(e){this.channel=e};JO.prototype={[A$]:C$,pipe(){return de(this,arguments)}};var GO=(e)=>new JO(e);var KO="~effect/RcMap",_$=(e)=>({[KO]:KO,lookup:e.lookup,context:e.context,scope:e.scope,idleTimeToLive:e.idleTimeToLive,capacity:e.capacity,state:{_tag:"Open",map:Pu()},pipe(){return de(this,arguments)}}),e_=(e)=>dt((t)=>{let n=t.context,r=Lt(n,ut),o=_$({lookup:e.lookup,context:n,scope:r,idleTimeToLive:typeof e.idleTimeToLive==="function"?ja(e.idleTimeToLive,Zt):pr(Zt(e.idleTimeToLive??VO)),capacity:Math.max(e.capacity??Number.POSITIVE_INFINITY,0)});return nt(dr(r,()=>{if(o.state._tag==="Closed")return R;let s=o.state.map;return o.state={_tag:"Closed"},Jr(s,([,a])=>or(Ou(a))).pipe(xt(()=>L(()=>{Qp(s)})))}),o)}),eS=y(2,(e,t)=>Xn((n)=>{if(e.state._tag==="Closed")return Kn;let r=e.state,o=Fo(),s=Mo(r.map,t),a;if(s._tag==="Some")a=s.value,a.refCount++;else if(Number.isFinite(e.capacity)&&XO(e.state.map)>=e.capacity)return _(new ZO(`RcMap attempted to exceed capacity of ${e.capacity}`));else{a={deferred:pu(),scope:ko(),idleTimeToLive:e.idleTimeToLive(t),finalizer:void 0,fiber:void 0,expiresAt:0,refCount:1},a.finalizer=P$(e,t,a),Mu(r.map,t,a);let c=new Map(e.context.mapUnsafe);o.context.mapUnsafe.forEach((u,d)=>{c.set(d,u)}),c.set(ut.key,a.scope);let f=Ac(c);M(()=>e.lookup(t)).pipe(Fn(f),js(a.scope)).addObserver((u)=>{if(QO(u))R$(e,t,a,f);Da(a.deferred,u)})}let i=Cc(o.context,ut);return Me(i,a.finalizer).pipe(gt(n(YO(a.deferred))))}));var R$=(e,t,n,r)=>{if(e.state._tag==="Closed")return;let o=Mo(e.state.map,t);if(o._tag==="None"||o.value!==n)return;if(Tc(e.state.map,t),n.refCount>0)return;Ou(n).pipe(Fn(r),js(e.scope))},Ou=(e)=>e.fiber?fn(e.fiber).pipe(gt(Te(e.scope,Ye))):Te(e.scope,Ye),P$=(e,t,n)=>dt((r)=>{if(n.refCount--,n.refCount>0)return R;else if(e.state._tag==="Closed")return Ou(n);let o=Mo(e.state.map,t);if(o._tag==="None"||o.value!==n)return Ou(n);else if(_u(n.idleTimeToLive))return Tc(e.state.map,t),Ou(n);else if(!xs(n.idleTimeToLive))return R;let s=r.getRef(Uo);if(n.expiresAt=s.currentTimeMillisUnsafe()+Wn(n.idleTimeToLive),n.fiber)return R;return n.fiber=Xn(function a(i){let c=s.currentTimeMillisUnsafe(),f=n.expiresAt-c;if(f<=0){if(e.state._tag==="Closed"||n.refCount>0)return R;let u=Mo(e.state.map,t);if(u._tag==="None"||u.value!==n)return R;return Tc(e.state.map,t),Te(n.scope,Ye)}return A(i(s.sleep(Qf(f))),()=>a(i))}).pipe(_o(L(()=>{n.fiber=void 0})),Fn(r.context),js(e.scope)),R});var tS=y(2,(e,t)=>Ru((n)=>{if(e.state._tag==="Closed")return R;let r=Mo(e.state.map,t);if(r._tag==="None"||_u(r.value.idleTimeToLive))return R;let o=r.value;return o.expiresAt=n.currentTimeMillisUnsafe()+Wn(o.idleTimeToLive),R}));var U$="~effect/RcRef",Uu={_tag:"Empty"},F$={_tag:"Closed"},D$={_A:Q,_E:Q};class n_{[U$]=D$;pipe(){return de(this,arguments)}state=Uu;acquire;context;scope;idleTimeToLive;constructor(e,t,n,r){this.acquire=e,this.context=t,this.scope=n,this.idleTimeToLive=r}}var r_=(e)=>dt((t)=>{let n=t.context,r=Lt(n,ut),o=new n_(e.acquire,n,r,e.idleTimeToLive!==void 0?Zt(e.idleTimeToLive):void 0);return nt(dr(r,()=>{let s=o.state;if(o.state=F$,s._tag==="Acquired")return Te(s.scope,Ye);if(s._tag==="Acquiring")return fn(s.fiber);return R}),o)}),N$=(e,t)=>{switch(e.state._tag){case"Closed":return Kn;case"Acquired":{let n=e.state;return n.refCount++,n.fiber?nt(fn(n.fiber),n):b(n)}case"Acquiring":{let n=e.state;return n.awaiters++,t_(e,n,t)}case"Empty":{let n={_tag:"Acquiring",fiber:void 0,awaiters:1,acquired:void 0};e.state=n;let r=ko(),o=Jt(e.acquire,Un(e.context,ut,r)).pipe(A((s)=>{if(e.state!==n)return Kn;let a={_tag:"Acquired",value:s,scope:r,fiber:void 0,refCount:n.awaiters,invalidated:!1};return e.state=a,n.acquired=a,b(a)}),yr((s)=>{if($e(s))return R;if(e.state===n)e.state=Uu;return Te(r,s)}));return n.fiber=Fn(Fo().context)(o),t_(e,n,t)}}},t_=(e,t,n)=>yr(n($s(t.fiber)),(r)=>{let o=t.acquired;if(o!==void 0)return bo(r)?s_(e,o):R;if(--t.awaiters>0||e.state!==t)return R;return e.state=Uu,fn(t.fiber)}),o_=(e)=>{let t=e;return Xn((n)=>A(Yn,(r)=>A(N$(t,n),(o)=>nt(dr(r,()=>s_(t,o)),o.value))))},s_=(e,t)=>{if(t.refCount--,t.refCount>0)return R;let n=e.idleTimeToLive;if(n===void 0||t.invalidated){if(e.state===t)e.state=Uu;return Te(t.scope,Ye)}else if(!xs(n))return R;return t.fiber=Xn((r)=>A(r(Ws(n)),()=>{if(e.state===t&&t.refCount===0)return e.state=Uu,Te(t.scope,Ye);return R})).pipe(_o(L(()=>{t.fiber=void 0})),Fn(e.context),js(e.scope)),R};var a_=r_,i_=o_;var $$="~effect/Sink";var q$={_A:Q,_In:Q,_L:Q,_E:Q,_R:Q},H$={[$$]:q$,pipe(){return de(this,arguments)}};var j$=(e)=>{let t=Object.create(H$);return t.transform=e,t},c_=(e)=>me((t,n)=>b(A(e.transform(t,n),ee)));var f_=(e)=>{let t=ht(e);return j$((n)=>{let r=[];if(t===0)return b([r]);let o=void 0;return n.pipe(A((s)=>{if(r.length+s.length<=t){if(r.push(...s),r.length===t)return ee();return R}for(let a=0;a<s.length;a++)if(r.push(s[a]),r.length===t){if(a+1<s.length)o=s.slice(a+1);return ee()}return R}),Ze({disableYield:!0}),lt(()=>b([r,o])))})};var v_="~effect/Stream",le=(e)=>V(e,v_),O_=Au,P=GO,tm=(e)=>P(qp(B(e,pe))),J$=(e)=>tm(b_(e)),G$=(e)=>tm(_c(e)),__=(e)=>oo(b(A(e,()=>ee()))),R_=(e)=>oo(b(B(e,pe))),K$=(e,t)=>oo(je(function*(){let n=yield*Sc(t),r=yield*zs(e,Qr,Qr.defaultValue()),o=!0,s=M(()=>n(r)).pipe(A((a)=>zs(e,Qr,a)),B((a)=>(r=a,pe(a))));return M(()=>{if(o)return o=!1,b(pe(r));return s})})),V$=(e)=>oo(L(()=>{let t=!0,n=b(pe(void 0)),r=Ks(n,e);return M(()=>{if(t)return t=!1,n;return r})})),oo=(e)=>P(Ut(e)),It=(e,t)=>P(me((n,r)=>A(Po(e.channel,r),(o)=>t(o,r)))),oS=(e,t)=>P(eo((n,r,o)=>A(Po(e.channel,r),(s)=>t(s,r,o)))),Sr=(e)=>e.channel,P_=(e,t)=>P(Fv(e,t)),os=P(yc),Wa=(e)=>P($p(pe(e))),Z$=(...e)=>nm(e),Q$=(e)=>P(Bv(()=>pe(e()))),dn=(e)=>P(zp(()=>e().channel)),Js=(e)=>P(Oo(e)),Y$=(e)=>P(zv(e)),M_=(e)=>P(Cu(e)),X$=(e)=>P(zy(e)),eq=(e)=>P($v(e)),tq=(e,t)=>P(Ly(()=>e,t)),Ga=(e,t)=>Array.isArray(e)&&t?.chunkSize===void 0?nm(e):P(Nv(e,t?.chunkSize)),nq=(e)=>ro(B(e,Ga)),rq=(e)=>Rc(R_(e),Ga),nm=(e)=>Ke(e)?P($p(e)):os,oq=(e)=>ro(B(e,nm)),sq=(...e)=>P(By(md(e,Ke))),Gs=(e)=>P(Hv(e)),aq=(e)=>P(jv(e)),U_=(e)=>P(Wv(e)),sS=(e)=>P(Jv(e)),iq=(e,t)=>P(Gv(e,t)),cq=(e)=>oo(B(Iu(e),(t)=>lt(B(t(void 0),pe),()=>ee()))),fq=(e)=>P(qy(e)),uq=(e,t,n)=>P_((r)=>{let o=typeof n==="object"&&n.once;function s(a){if(Rp(r,a),o)Mp(r)}return xr(L(()=>e.addEventListener(t,s,n)),()=>L(()=>e.removeEventListener(t,s,n)))},{bufferSize:typeof n==="object"?n.bufferSize:void 0}),F_=(e,t)=>oo(L(()=>{let n=e;return A(M(()=>t(n)),(r)=>{if(r===void 0)return ee();return n=r[1],b(pe(r[0]))})})),dq=(e,t)=>oo(L(()=>{let n=e,r=!1;return M(function o(){if(r)return ee();return A(t(n),([s,a])=>{if(Tn(a))r=!0;else n=a.value;if(!Ke(s))return o();return b(s)})})})),lq=(e,t)=>F_(e,(n)=>b([n,t(n)])),pq=(e,t,n=Au)=>e>t?os:oo(L(()=>{let r=qs(n),o=e,s=!1;return M(()=>{if(s)return ee();let a=t-o+1;if(a>r){let c=nS(o,o+r-1);return o+=r,b(c)}let i=nS(o,o+a-1);return s=!0,b(i)})})),mq=P(Lv),ro=(e)=>P(no(B(e,Sr))),hq=(e)=>P(AO(e.channel)),Dn=y(2,(e,t)=>dn(()=>{let n=0;return P(to(e.channel,hn((r)=>t(r,n++))))})),gq=y(2,(e,t)=>Dn(e,()=>t)),xq=y(2,(e,t)=>e.pipe(Dn(t.onElement),J_(t.onError))),D_=y(2,(e,t)=>P(to(e.channel,t))),Nu=y((e)=>le(e[0]),(e,t,n)=>e.channel.pipe(un,Hp(t,n),to(pe),P)),yq=y((e)=>le(e[0]),(e,t)=>Nu(e,Q,t)),Sq=y(2,(e,t)=>P(Hp(e.channel,t))),Eq=(e)=>e.pipe(Dn(ue),Bu((t)=>Wa(ge(t)))),N_=y((e)=>le(e[0]),(e,t,n)=>Nu(e,(r)=>nt(t(r),r),n)),bq=y(2,(e,t)=>e.pipe(uS(t.onError),N_(t.onElement,{concurrency:t.concurrency}))),Iq=y(2,(e,t)=>oS(e,re(function*(n,r,o){let s=ct(),a=ct(),i=void 0,c=void 0,f=!1,u=!1,d=s.whenOpen(M(()=>{if(i){let m=i;if(i=void 0,!u)s.closeUnsafe();return nt(a.open,m)}return ee()}));yield*M(()=>t.transform(d,o)).pipe((m)=>w_(m,(p)=>{if(f=!0,bo(p))c=p.cause;return a.open},!0),Ne(o));let l=n.pipe(A((m)=>(i=m,a.closeUnsafe(),s.openUnsafe(),nt(a.await,m))),lt(()=>(u=!0,a.closeUnsafe(),s.openUnsafe(),A(a.await,()=>ee()))));return M(()=>{if(c)return He(c);else if(f)return n;return l})}))),Rc=y((e)=>le(e[0]),(e,t,n)=>e.channel.pipe(un,Hy((r)=>t(r).channel,n),P)),wq=y((e)=>le(e[0]),(e,t,n)=>e.channel.pipe(un,wO((r)=>t(r).channel,n),P)),B_=y((e)=>le(e[0]),(e,t)=>Rc(e,Q,t)),kq=(e)=>P(un(e.channel)),Tq=(e)=>P(eO(e.channel)),Aq=y(2,(e,t)=>rm(e,am(t))),Cq=y(2,(e,t)=>P(tO(e.channel,t))),vq=y(2,(e,t)=>e.channel.pipe(un,oO(t),to(pe),P)),Oq=y(2,(e,t)=>L_(e,{duration:t,orElse:()=>os})),L_=y(2,(e,t)=>{let n=Zt(t.duration);if(!xs(n))return e;if(_u(n))return dn(t.orElse);let r=Symbol();return H_(dn(()=>{let s=Fo().getRef(Uo),a=Wn(n),i=void 0,c=ct(!1);return aS(It(e,(f,u)=>M(()=>(i=s.currentTimeMillisUnsafe()+a,c.openUnsafe(),f)).pipe(B((d)=>(c.closeUnsafe(),i=void 0,d)),b)),__(je(function*(){while(!0){if(yield*c.await,i===void 0)continue;if(yield*Ws(i-s.currentTimeMillisUnsafe()),i===void 0)continue;if(i-s.currentTimeMillisUnsafe()>0)continue;return yield*_n(r)}})),{haltStrategy:"left"})}),(o)=>{if(o.reasons.find((a)=>a._tag==="Die"&&a.defect===r))return t.orElse();return M_(o)})}),_q=y(2,(e,t)=>P(me((n,r)=>B(ie(un(e.channel))(n,r),(o)=>{let s=void 0,a=je(function*(){let i=yield*o,c=pe(i);return s=(yield*Iu(t))(i).pipe(nt(c),lt((u)=>(s=void 0,a))),c});return M(()=>s??a)})))),Rq=(e)=>P(rO(e.channel)),Pq=(e)=>Rc(e,Ga),Mq=(e)=>e.channel.pipe(un,Xv,P),vc=y(2,(e,t)=>{let n=P(Yv(Dv(()=>Uq(e,t))));return z_.set(n,[e,t]),n}),z_=new WeakMap;function*Uq(e,t){let n=[t,e];while(n.length>0){let r=n.pop(),o=z_.get(r);if(o===void 0)yield r.channel;else n.push(o[1],o[0])}}var Fq=y(2,(e,t)=>vc(Ga(t),e)),aS=y((e)=>le(e[0])&&le(e[1]),(e,t,n)=>P(Gp(Sr(e),Sr(t),n))),rm=y(2,(e,t)=>e.channel.pipe(kO(t),P)),Dq=y(2,(e,t)=>aS(Dn(e,ue),Dn(t,ge))),Nq=y(2,(e,t)=>rm(e,am(t))),Bq=y(2,(e,t)=>rm(t,am(e))),Lq=y(2,(e,t)=>B_(Ga(e),t)),zq=y(2,(e,t)=>$_(e,t,(n,r)=>[n,r])),$_=y(3,(e,t,n)=>Rc(e,(r)=>Dn(t,(o)=>n(r,o)))),iS=y(3,(e,t,n)=>om(e,t,$q(n))),$q=(e)=>(t,n)=>{let r=Math.min(t.length,n.length),o=[];for(let s=0;s<r;s++)o.push(e(t[s],n[s]));return[o,t.slice(r),n.slice(r)]},om=y(3,(e,t,n)=>P(eo(re(function*(r,o){let s=yield*Po(e.channel,o),a=yield*Po(t.channel,o),i=je(function*(){let u=yield*Ne(s,o),d=yield*Ne(a,o);return yield*C_([u,d])}),c={_tag:"PullBoth"};return je(function*(){let[u,d]=c._tag==="PullBoth"?yield*i:c._tag==="PullLeft"?[yield*s,c.rightArray]:[c.leftArray,yield*a],l=n(u,d);if(Ke(l[1]))c={_tag:"PullRight",leftArray:l[1]};else if(Ke(l[2]))c={_tag:"PullLeft",rightArray:l[2]};else c={_tag:"PullBoth"};return l[0]})})))),qq=y(2,(e,t)=>iS(e,t,(n,r)=>[n,r])),Hq=y(2,(e,t)=>om(e,t,(n,r)=>{let o=Math.min(n.length,r.length),s=n.slice(0,o),a=n.slice(o),i=r.slice(o);return[s,a,i]})),jq=y(2,(e,t)=>om(e,t,(n,r)=>{let o=Math.min(n.length,r.length),s=r.slice(0,o),a=n.slice(o),i=r.slice(o);return[s,a,i]})),Wq=y(2,(e,t)=>iS(e,t,(n,r)=>[...n,r])),Jq=(e)=>Dn(e,(t,n)=>[t,n]),Gq=(e)=>Ka(e,ne,(t,n)=>{let r=0;if(t._tag==="None")r=1,t=oe(n[0]);let o=Xt();for(;r<n.length;r++){let s=t.value;t=oe(n[r]),o.push([s,t])}return[t,o]},{onHalt(t){return t._tag==="Some"?[[t.value,ne()]]:[]}}),Kq=(e)=>Ka(e,ne,(t,n)=>{let r=Xt();for(let o=0;o<n.length;o++){let s=n[o];r.push([t,s]),t=oe(n[o])}return[t,r]}),Vq=(e)=>Ka(e,()=>({prev:ne(),current:ne()}),(t,n)=>{let r=0,o;if(t.current._tag==="None")r=1,o=n[0],t.current=oe(o);else o=t.current.value;let s=Xt();for(;r<n.length;r++){let a=n[r];t.current=oe(a),s.push([t.prev,o,t.current]),t.prev=oe(o),o=a}return[t,s]},{onHalt(t){return t.current._tag==="Some"?[[t.prev,t.current.value,ne()]]:[]}}),cS=(...e)=>P(zp(()=>{let t=[],n=new Set,r=ct();return Jp(By(e.map((o,s)=>o.channel.pipe(un,Hp((a)=>{if(t[s]=a,!n.has(s)){if(n.add(s),n.size<e.length)return r.await;return nt(r.open,pe(t.slice()))}return b(pe(t.slice()))}),sO(ws)))),{concurrency:"unbounded",bufferSize:0})})),Zq=y(2,(e,t)=>cS(e,t)),Qq=y(3,(e,t,n)=>Dn(cS(e,t),([r,o])=>n(r,o))),q_=(...e)=>P(me((t,n)=>L(()=>{let r,o=E_(e.map((s)=>{let a=cn(n);return Po(s.channel,a).pipe(A((i)=>S_(b(i),i)),yr((i)=>{if(i._tag==="Success"){if(r)return Te(a,i);return r=i.value[0],R}return Te(a,i)}),B(([,i])=>i))}));return M(()=>r??o)}))),Yq=y(2,(e,t)=>q_(e,t)),Xq=y(2,(e,t)=>P(aO(Sr(e),t))),eH=y(2,(e,t)=>P(iO(Sr(e),t))),tH=y(2,(e,t)=>P(cO(Sr(e),t))),nH=y(2,(e,t)=>P(fO(Sr(e),t))),fS=y((e)=>le(e[0]),re(function*(e,t,n){let r=yield*Yn,o=yield*Po(e.channel,r),s=n?.capacity==="unbounded"?void 0:n?.capacity??O_,a=yield*hr({capacity:s}),i=yield*hr({capacity:s});return yield*je(function*(){while(!0){let c=yield*o,f=[],u=[];for(let l=0;l<c.length;l++){let m=t(c[l]);if(Bt(m))f.push(m.failure);else u.push(m.success)}let d=void 0;if(u.length>0){let l=Pp(a,u);if(l.length>0)d=yield*Eu(ts(a,l))}if(f.length>0){let l=Pp(i,f);if(l.length>0)yield*ts(i,l)}if(d)yield*$s(d)}}).pipe(Vn((c)=>(Ls(a,c),Ls(i,c),R)),Ne(r)),[a,i]})),rH=y((e)=>le(e[0]),(e,t,n)=>B(fS(Nu(e,(r)=>t(r),n),(r)=>r,n),([r,o])=>[Gs(r),Gs(o)])),oH=y((e)=>le(e[0]),(e,t,n)=>B(fS(e,t,{capacity:n?.capacity??16}),([r,o])=>[Gs(r),Gs(o)])),sH=y(2,(e,t)=>t.pipe(B((n)=>n?e:os),ro)),aH=y(2,re(function*(e,t){let n=void 0,r=yield*Zy(e.channel),o=De(r,(i)=>(n=i,He(i))),s=oo(b(o)),a=yield*lR(s,t);if(n)return[a,os];return s=oo(b(r)),[a,s]})),iH=y(2,(e,t)=>P(vO(e.channel,t))),cH=y(2,(e,t)=>P(CO(e.channel,t))),H_=y(2,(e,t)=>e.channel.pipe(kc((n)=>t(n).channel),P)),fH=y(2,(e,t)=>e.channel.pipe(dO((n)=>t(n).channel),P)),j_=y(2,(e,t)=>e.channel.pipe(jp(t),P)),Bu=y(2,(e,t)=>P(Yr(e.channel,(n)=>t(n).channel)));var uS=y(2,(e,t)=>e.channel.pipe(pO(t),P)),uH=y(3,(e,t,n)=>{let r=Array.isArray(t)?(o)=>V(o,"_tag")&&t.includes(o._tag):vo(t);return uS(e,(o)=>r(o)?n(o):R)}),dH=y(2,(e,t)=>j_(e,(n)=>{let r=Np(n);return At(r)?t(r.success):R})),W_=y((e)=>le(e[0]),(e,t,n,r)=>P(mO(Sr(e),t,(o)=>n(o).channel,r&&((o)=>r(o).channel)))),dS=y((e)=>le(e[0]),(e,t,n,r)=>P(hO(Sr(e),t,(o)=>n(o).channel,r&&((o)=>r(o).channel)))),lH=y((e)=>le(e[0]),(e,t,n,r)=>{let o=Array.isArray(t)?(s)=>V(s,"_tag")&&t.includes(s._tag):vo(t);return W_(e,o,n,r)}),pH=y((e)=>le(e[0]),(e,t,n)=>{let r;return dS(e,(o)=>(r??=Object.keys(t),V(o,"_tag")&&Bp(o._tag)&&r.includes(o._tag)?ue(o):ge(o)),(o)=>t[o._tag](o),n)}),mH=y((e)=>le(e[0]),(e,t,n,r,o)=>P(gO(Sr(e),t,n,(s,a)=>r(s,a).channel,o&&((s,a)=>o(s,a).channel)))),hH=y((e)=>le(e[0]),(e,t,n,r)=>{let o=Object.create(null);for(let a of Object.keys(n)){let i=n[a];o[a]=(c,f)=>i(c,f).channel}let s=r&&((a,i)=>r(a,i).channel);return P(xO(e.channel,t,o,s))}),gH=y(2,(e,t)=>dS(e,(n)=>{if(vo(n,t)&&V(n,"reason"))return ue(n.reason);return ge(n)},Js)),J_=y(2,(e,t)=>P(yO(e.channel,t))),xH=y(3,(e,t,n)=>P(lO(e.channel,t,(r)=>n(r).channel))),yH=y(3,(e,t,n)=>P(Wp(e.channel,t,(r,o)=>n(r,o).channel))),SH=y(2,(e,t)=>P(Qv(e.channel,(n)=>Sr(t())))),EH=y(2,(e,t)=>Bu(e,(n)=>Wa(t(n)))),bH=(e)=>P(SO(e.channel)),IH=y((e)=>le(e[0]),(e,t)=>P(EO(e.channel,t))),wH=y((e)=>le(e[0]),(e,t)=>P(bO(e.channel,t))),kH=y(2,(e,t)=>P(IO(e.channel,t))),u_=(e,t)=>ro(B(Sc(t),(n)=>{let r=Qr.defaultValue(),o=()=>Bu(gS(e,Qr,L(()=>r)),(s)=>ro(lt(B(n(s),(a)=>(r=a,ro(nt(Lp,o())))),()=>b(Js(s)))));return o()})),TH=y((e)=>le(e[0]),(e,t,n)=>dn(()=>{let r=n?.preventFallbackOnPartialStream??!1,o=0,s={attempt:0,stepIndex:0},a=gS(h_,L(()=>(s={attempt:s.attempt+1,stepIndex:o},s))),i=n?.onEvent===void 0?void 0:y_(n.onEvent,()=>s),c,f=i===void 0?Q:(l)=>iR(cR(l,B(i.begin,(m)=>{c=m})),(m)=>M(()=>{if(c===void 0)return R;let p=c;return c=void 0,i.end(p,m)})),u=ne(),d=dn(()=>{let l=t.steps[o];if(!l)return Js(d_(u));let m=a(f(uR(e,l.provide))),p=!1;if(ve(u)){let g=u.value,h=!1,E=m;m=dn(()=>{if(h)return E;return h=!0,Js(g)}),m=u_(m,rS(l,!1))}else{let g=rS(l,!0);m=g?u_(m,g):m}return Bu(r?fR(m,(g)=>(p=!0,R)):m,(g)=>{if(o++,r&&p)return Js(g);return u=oe(g),d})});return d})),AH=y(2,(e,t)=>{let n=ht(t);return n===0?os:G_(e,(r,o)=>o===n-1)}),CH=y(3,(e,t,n)=>dn(()=>{let r=dd(t),o=BigInt(0),s=!1;return vc(V_(e,(a)=>{let i=o+BigInt(a.length);if(i>r)return s=!0,!1;return o=i,!0}),dn(()=>s?n():os))})),vH=y(2,(e,t)=>{let n=ht(t);if(n===0)return os;return Ka(e,Yo,(r,o)=>{if(hp(r,o),r.length>n)lu(r,r.length-n);return[r,rs]},{onHalt(r){return Fs(r)}})}),G_=y((e)=>le(e[0]),(e,t,n)=>It(e,(r,o)=>L(()=>{let s=0,a=!1;return A(M(()=>a?ee():r),(c)=>{let f=c.findIndex((u)=>t(u,s++));if(f>=0){a=!0;let u=c.slice(0,n?.excludeLast?f:f+1);return Ke(u)?b(u):ee()}return b(c)})}))),K_=y((e)=>le(e[0]),(e,t,n)=>It(e,(r,o)=>L(()=>{let s=0,a=!1;return je(function*(){if(a)return yield*ee();let i=yield*r;for(let c=0;c<i.length;c++)if(yield*t(i[c],s++)){a=!0;let f=i.slice(0,n?.excludeLast?c:c+1);return Ke(f)?f:yield*ee()}return i})}))),V_=y(2,(e,t)=>It(e,(n,r)=>L(()=>{let o=0,s=!1,a=A(M(()=>s?ee():n),(i)=>{let c=[];for(let f=0;f<i.length;f++){if(!t(i[f],o++)){s=!0;break}c.push(i[f])}return Ke(c)?b(c):s?ee():a});return a}))),OH=y(2,(e,t)=>It(e,(n,r)=>L(()=>{let o=!1,s=A(M(()=>o?ee():n),(a)=>{let i=[];for(let c=0;c<a.length;c++){let f=t(a[c]);if(Bt(f)){o=!0;break}i.push(f.success)}return Ke(i)?b(i):o?ee():s});return s}))),_H=y(2,(e,t)=>K_(e,(n,r)=>B(t(n,r),(o)=>!o),{excludeLast:!0})),lS=y(2,(e,t)=>{let n=ht(t);if(n===0)return e;return It(e,(r,o)=>L(()=>{let s=0,a=r.pipe(A((i)=>{if(s>=n)return b(i);if(s+=i.length,s<=n)return a;return b(i.slice(n-s))}));return a}))}),RH=y(2,(e,t)=>lS(Z_(e,(n,r)=>!t(n,r)),1)),PH=y(2,(e,t)=>lS(Q_(e,(n,r)=>B(t(n,r),(o)=>!o)),1)),Z_=y(2,(e,t)=>It(e,(n,r)=>L(()=>{let o=!0,s=0,a=A(n,(i)=>{let c=i.findIndex((f)=>!t(f,s++));if(c===-1)return a;return o=!1,b(i.slice(c))});return M(()=>o?a:n)}))),MH=y(2,(e,t)=>It(e,(n,r)=>L(()=>{let o=!0,s=A(n,(a)=>{let i=a.findIndex((c)=>Bt(t(c)));if(i===-1)return s;return o=!1,b(a.slice(i))});return M(()=>o?s:n)}))),Q_=y(2,(e,t)=>It(e,(n,r)=>L(()=>{let o=!0,s=0,a=je(function*(){while(!0){let i=yield*n;for(let c=0;c<i.length;c++){if(yield*t(i[c],s++))continue;return o=!1,i.slice(c)}}});return M(()=>o?a:n)}))),UH=y(2,(e,t)=>{let n=ht(t);if(n===0)return e;return It(e,(r,o)=>L(()=>{let s=Yo(),a=A(r,(i)=>{gp(s,i);let c=s.length-n,f=Ua(s,c);return Sn(f)?b(f):a});return a}))}),Y_=(e)=>e.channel.pipe(to(pe),P),X_=y(2,(e,t)=>(t=qs(t),It(e,(n,r)=>L(()=>{let o=Xt(),s=0,a,i=!1;return M(function c(){if(i)return ee();else if(a===void 0)return A(n,(f)=>{if(o.length===0&&f.length===t)return b(f);else if(o.length+f.length<t){for(let u=0;u<f.length;u++)o.push(f[u]);return c()}return a=f,c()});for(;s<a.length;)if(o.push(a[s++]),o.length===t){let f=o;return o=[],b(f)}return s=0,a=void 0,c()}).pipe(lt(()=>{if(o.length===0)return ee();let c=o;return i=!0,o=[],b(c)}))})))),FH=y(2,(e,t)=>eR(e,t,1)),eR=y(3,(e,t,n)=>{let r=qs(t),o=qs(n);return It(e,(s,a)=>L(()=>{let i=null,c=Yo(),f=!1,u=0,d=ns(s,{onSuccess(l){if(gp(c,l),u>0){let p=c.length;lu(c,u),u=Math.max(0,u-p)}if(c.length<r)return d;f=!0;let m=[];while(c.length>=r)if(r===o)m.push(Ua(c,r));else{m.push(RC(c,r));let p=c.length;lu(c,o),u=Math.max(0,o-p)}return b(m)},onFailure(l){if(f)lu(c,r-o);if(c.length===0)return He(l);return i=l,b(pe(Fs(c)))}});return M(()=>i?He(i):d)}))}),DH=y(2,(e,t)=>Ka(e,Xt,(n,r)=>{let o=Xt();for(let s=0;s<r.length;s++)if(t(r[s])){if(Sn(n))o.push(n),n=[]}else n.push(r[s]);return[n,o]},{onHalt(n){return Sn(n)?pe(n):rs}})),NH=y(4,(e,t,n,r)=>jy(un(e.channel),un(t.channel),n,r).pipe(to(pe),P)),BH=y(4,(e,t,n,r)=>P(jy(e.channel,t.channel,n,r))),LH=y((e)=>le(e[0]),(e,t,n,r)=>P(wc(e.channel,t,(o,s)=>{let a=Xt();for(let i=0;i<s.length;i++){let[c,f]=n(o,s[i]);o=c,a.push(...f)}return[o,Sn(a)?pe(a):rs]},r?.onHalt?{onHalt(o){let s=r.onHalt(o);return Ke(s)?pe(s):rs}}:void 0))),Ka=y((e)=>le(e[0]),(e,t,n,r)=>P(wc(e.channel,t,(o,s)=>{let[a,i]=n(o,s);return o=a,[o,Ke(i)?pe(i):rs]},r?.onHalt?{onHalt(o){let s=r.onHalt(o);return Ke(s)?pe(s):rs}}:void 0))),rs=Xt(),zH=y((e)=>le(e[0]),(e,t,n,r)=>e.channel.pipe(un,wc(t,(o,s)=>B(n(o,s),([a,i])=>[a,Ke(i)?pe(i):Xt()]),r?.onHalt?{onHalt(o){let s=r.onHalt(o);return Ke(s)?pe(s):rs}}:void 0),P)),$H=y((e)=>le(e[0]),(e,t,n,r)=>e.channel.pipe(wc(t,(o,s)=>B(n(o,s),([a,i])=>[a,Ke(i)?pe(i):rs]),r?.onHalt?{onHalt(o){let s=r.onHalt(o);return Ke(s)?pe(s):rs}}:void 0),P)),qH=y(3,(e,t,n)=>dn(()=>{let r=t();return vc(Wa(r),P(wc(e.channel,()=>r,(o,s)=>{let a=Xt();for(let i=0;i<s.length;i++)o=n(o,s[i]),a.push(o);return[o,pe(a)]})))})),HH=y(3,(e,t,n)=>dn(()=>e.channel.pipe(un,uO(t(),n),to(pe),P))),jH=y(2,(e,t)=>It(e,re(function*(n,r){let o=yield*Uo,s=Wn(Zt(t)),a,i,c=1/0,f=ct(),u=ct(),d=ct();yield*n.pipe(f.whenOpen,A((m)=>(u.openUnsafe(),a=m,c=o.currentTimeMillisUnsafe()+s,R)),Ze({disableYield:!0}),Vn((m)=>(i=m,c=o.currentTimeMillisUnsafe(),u.openUnsafe(),d.openUnsafe(),R)),Ne(r));let l=M(function m(){let p=o.currentTimeMillisUnsafe(),g=c<p?s:Math.min(s,c-p);return A(za(Ws(g),d.await),()=>{if(o.currentTimeMillisUnsafe()<c)return m();else if(a){u.closeUnsafe(),f.closeUnsafe();let E=b(pe(Yp(a)));return a=void 0,E}else if(i)return He(i);return m()})});return M(()=>{if(i){if(a){let m=b(pe(Yp(a)));return a=void 0,m}return He(i)}return f.openUnsafe(),u.whenOpen(l)})}))),tR=y(2,(e,t)=>{let n=t.burst??0;if(t.strategy==="enforce")return WH(e,t.cost,t.units,t.duration,n);return JH(e,t.cost,t.units,t.duration,n)}),WH=(e,t,n,r,o)=>It(e,(s)=>Ru((a)=>{let i=Wn(Zt(r)),c=n+o<0?Number.POSITIVE_INFINITY:n+o,f=n,u=a.currentTimeMillisUnsafe();return b(A(s,function d(l){return A(t(l),(m)=>{let p=a.currentTimeMillisUnsafe(),h=(p-u)/i,E=f+h*n,S=E<0?c:Math.min(E,c);if(m<=S)return f=S-m,u=p,b(l);return A(s,d)})}))})),JH=(e,t,n,r,o)=>It(e,(s)=>Ru((a)=>{let i=Wn(Zt(r)),c=n+o<0?Number.POSITIVE_INFINITY:n+o,f=n,u=a.monotonicTimeNanosUnsafe();return b(A(s,(d)=>A(t(d),(l)=>{let m=a.monotonicTimeNanosUnsafe(),g=Number(m-u)/1e6/i,h=f+g*n,S=Math.min(h,c)-l;if(S>=0)return f=S,u=m,b(d);let k=-S/n,I=Math.max(0,k*i);if(I>0)return A(Ws(I),()=>(f=S,u=m,b(d)));return f=S,u=m,b(d)})))})),GH=y(2,(e,t)=>tR(e,{...t,cost:(n)=>b(t.cost(n))})),KH=y(2,(e,t)=>Y_(X_(e,t))),VH=y(3,(e,t,n)=>pS(e,f_(qs(t)),Du(n))),ZH=y((e)=>le(e[0]),(e,t,n)=>nR(e,re(function*(r,o,s){for(let a=0;a<r.length;a++){let[i,c]=yield*t(r[a]),f=Mo(s,i),u=ve(f)?f.value:yield*Ja(eS(o,i));yield*tS(o,i),yield*bn(u,c)}}),n)),QH=y((e)=>le(e[0]),(e,t,n)=>dn(()=>{let r=Pu();return nR(e,re(function*(o,s,a){for(let i=0;i<o.length;i++){let c=t(o[i]),f=Mo(r,c);if(Tn(f))Mu(r,c,[o[i]]);else f.value.push(o[i])}for(let[i,c]of r){let f=Mo(a,i),u=ve(f)?f.value:yield*Ja(eS(s,i));yield*tS(s,i),yield*ts(u,c)}Qp(r)}),n)})),nR=(e,t,n)=>oS(e,re(function*(r,o,s){let a=yield*_p();yield*Me(o,Vr(a));let i=Pu(),c=yield*e_({lookup:(f)=>xr(hr({capacity:n?.bufferSize??4096}).pipe(xt((u)=>(Mu(i,f,u),bn(a,[f,Gs(u)])))),(u)=>(Tc(i,f),gc(u))),idleTimeToLive:n?.idleTimeToLive??nc}).pipe(In(s));return yield*gr({while:Ds,body:pr(A(r,(f)=>t(f,c,i))),step:Mn}).pipe(De((f)=>rt(a,f)),Ne(o)),xc(a)})),YH=y(2,(e,t)=>It(e,(n,r)=>L(()=>{let o=void 0,s,a=Xt(),i=n.pipe(A((f)=>{for(let u=0;u<f.length;u++){let d=f[u],l=t(d);if(s===void 0){o=l,s=[d];continue}else if(he(l,o)){s.push(d);continue}a.push([o,s]),o=l,s=[d]}if(Sn(a)){let u=a;return a=[],b(u)}return i})),c=!1;return lt(M(()=>c?ee():i),()=>{c=!0;let f=s;return s=void 0,f&&Sn(f)?b(pe([o,f])):ee()})}))),XH=y(2,(e,t)=>It(e,(n,r)=>L(()=>{let o,s,a=M(()=>{if(s!==void 0){let c=s;return s=void 0,b(c)}return n}).pipe(bc((c)=>(o=So(c),ee()))),i=B(M(()=>t.transform(a,r)),([c,f])=>(s=f,pe(c)));return M(()=>o?o:i)}))),ej=y(2,(e,t)=>pS(e,t,x_)),pS=y(3,(e,t,n)=>P(eo(re(function*(r,o,s){let a=yield*Po(e.channel,o),i=ct(!1),c=Symbol(),f=yield*hr({capacity:0});yield*a.pipe(i.whenOpen,A((x)=>(i.closeUnsafe(),bn(f,x))),Ze,De((x)=>rt(f,x)),Ne(s));let u=yield*Uo,d=yield*g_(n),l=ct(!1),m=u.currentTimeMillisUnsafe(),p=0,g=ne(),h,E=(x)=>{if(l.openUnsafe())p=u.currentTimeMillisUnsafe();return b(x)},S=l.await.pipe(A(()=>d(m,g)),A(([,x])=>Ws(x)),A(()=>bn(f,c)),lt(()=>gc(f)),A(()=>Hs)),k=M(()=>{if(h!==void 0){let x=h;return h=void 0,E(x)}if(f.state._tag==="Open")i.openUnsafe();return A(Zr(f),(x)=>x===c?ee():E(x))}),I=A(([x,w])=>{if(l.isOpen())m+=u.currentTimeMillisUnsafe()-p;else if(f.state._tag==="Done")return ee();return g=oe(x),h=w,b(pe(x))});return M(()=>{if(f.state._tag==="Done"&&h===void 0)return f.state.exit;l.closeUnsafe();let x=I(M(()=>t.transform(k,s)));return f.state._tag==="Open"?za(x,S):x})})))),tj=y(2,re(function*(e,t){let n=ht(t.n),r=yield*nj(t),o=Array(n),s=yield*ut;for(let a=0;a<n;a++){let i=cn(s),c=yield*hu(r).pipe(zs(ut,i));o[a]=$y(Tp(c)).pipe(vu((f)=>Te(i,f)),P)}return yield*qa(e.channel,(a)=>kp(r,a)).pipe(yr((a)=>wp(r,a)),Ro),o})),nj=(e)=>xr(e.capacity==="unbounded"?Ip(e):e.strategy==="dropping"?Ep(e):e.strategy==="sliding"?bp(e):Sp(e),mu),rR=y(2,(e,t)=>B(mR(e,t),U_)),rj=y(2,(e,t)=>B(a_({acquire:rR(e,t),idleTimeToLive:t.idleTimeToLive}),(n)=>ro(i_(n)))),oj=y(2,(e,t)=>P(Wy(e.channel,t))),sj=y(2,(e,t)=>P(Jy(e.channel,t))),aj=y(2,(e,t)=>e.channel.pipe(Jy(c_(t)),Zv(([n,r])=>r?$p(r):yc),P)),ij=(e)=>tm(pR(e)),cj=(e)=>Ka(e,Xt,(t,n)=>{let r=$h(t,n);return[r,[r]]}),fj=(e)=>oR(e,he),oR=y(2,(e,t)=>It(e,(n,r)=>L(()=>{let o=!0,s;return A(n,function a(i){let c=[],f=0;if(o)o=!1,s=i[0],f=1,c.push(s);for(;f<i.length;f++){let u=i[f];if(t(u,s))continue;s=u,c.push(u)}return Sn(c)?b(c):A(n,a)})}))),uj=y(2,(e,t)=>It(e,(n,r)=>L(()=>{let o=!0,s;return A(n,re(function*a(i){let c=[],f=0;if(o)o=!1,s=i[0],f=1,c.push(s);for(;f<i.length;f++){let u=i[f];if(yield*t(u,s))continue;s=u,c.push(u)}return Sn(c)?c:yield*A(n,re(a))}))}))),dj=y((e)=>le(e[0]),(e,t)=>dn(()=>{let n=new TextDecoder(t?.encoding);return Dn(e,(r)=>n.decode(r,{stream:!0}))})),lj=(e)=>dn(()=>{let t=new TextEncoder;return Dn(e,(n)=>t.encode(n))}),pj=(e)=>e.channel.pipe(Wy(TO()),P),sR=y(2,(e,t)=>D_(e,(n,r)=>{let o=r===0?[]:[t],s=n.length-1;for(let a=0;a<n.length;a++)if(a===s)o.push(n[a]);else o.push(n[a],t);return o})),mj=y(2,(e,t)=>Wa(t.start).pipe(vc(sR(e,t.middle)),vc(Wa(t.end)))),hj=y(2,(e,t)=>aR(e,t,Ga(l_([!0,!1])))),aR=y(3,(e,t,n)=>P(me(re(function*(r,o){let s=yield*ie(un(n.channel))(r,o),a=Symbol(),i=!1,c=!1,f=(yield*ie(un(e.channel))(r,o)).pipe(lt(()=>(i=!0,b(a)))),u=(yield*ie(un(t.channel))(r,o)).pipe(lt(()=>(c=!0,b(a))));return je(function*(){while(!0){if(i&&c)return yield*ee();let d=yield*s;if(d&&i)continue;if(!d&&c)continue;let l=yield*d?f:u;if(l===a)continue;return pe(l)}})})))),gj=y(2,(e,t)=>P(OO(e.channel,t))),xj=y(2,(e,t)=>P(_O(e.channel,t))),iR=y(2,(e,t)=>P(vu(e.channel,t))),yj=y(2,(e,t)=>P(RO(e.channel,t))),cR=y(2,(e,t)=>P(PO(e.channel,t))),fR=y(2,(e,t)=>P(Gy(e.channel,(n)=>t(n[0])))),Sj=y(2,(e,t)=>P(MO(e.channel,t))),mS=y(2,(e,t)=>P(UO(e.channel,t))),uR=y((e)=>le(e[0]),(e,t,n)=>P(FO(e.channel,t,n))),hS=y(2,(e,t)=>P(Kp(e.channel,t))),Ej=y(3,(e,t,n)=>P(Vp(e.channel,t,n))),gS=y(3,(e,t,n)=>P(Zp(e.channel,t,n))),dR=y(2,(e,t)=>P(DO(e.channel,t))),bj=y(3,(e,t,n)=>dR(e,(r)=>Un(r,t,n(Lt(r,t))))),Ij=function(){let e=le(arguments[0]),t=e?arguments[1]:arguments[0],n=Dp(e?arguments[2]:arguments[1]);if(e){let r=arguments[0];return P(Ky(r.channel,t,n))}return(r)=>P(Ky(r.channel,t,n))},wj=Wa({}),kj=y(3,(e,t,n)=>Dn(e,(r)=>({...r,[t]:n(r)})));var Tj=y((e)=>le(e[0]),(e,t,n,r)=>Rc(e,(o)=>Dn(n(o),(s)=>({...o,[t]:s})),r)),Aj=y((e)=>le(e[0]),(e,t,n,r)=>Nu(e,(o)=>B(n(o),(s)=>({...o,[t]:s})),r)),Cj=y(2,(e,t)=>Dn(e,(n)=>({[t]:n}))),lR=y(2,(e,t)=>I_((n)=>Po(e.channel,n).pipe(A((r)=>t.transform(r,n)),B(([r])=>r)))),pR=(e)=>Ha(e.channel,()=>[],(t,n)=>{for(let r=0;r<n.length;r++)t.push(n[r]);return t}),vj=(e)=>Ha(e.channel,()=>0,(t,n)=>t+n.length),Oj=(e)=>Ha(e.channel,()=>0,(t,n)=>{for(let r=0;r<n.length;r++)t+=n[r];return t}),_j=y(3,(e,t,n)=>Ha(e.channel,t,(r,o)=>{for(let s=0;s<o.length;s++)r=n(r,o[s]);return r})),Rj=y(3,(e,t,n)=>$O(e.channel,t,(r,o)=>{let s=0,a=r;return B(gr({while:()=>s<o.length,body:()=>n(a,o[s]),step(i){a=i,s++}}),()=>a)})),Pj=(e)=>B(LO(e.channel),qo(p_(0))),Mj=(e)=>B(zO(e.channel),qo(Yp)),Uj=y(2,(e,t)=>qa(e.channel,(n)=>{let r=0;return gr({while:()=>r<n.length,body:()=>t(n[r++]),step:Mn})})),Fj=y(2,(e,t)=>BO(e.channel,(n)=>{let r=!1,o=0;return B(gr({while:()=>!r&&o<n.length,body:()=>t(n[o]),step(s){if(o++,!s)r=!0}}),()=>!r)})),sm=y(2,(e,t)=>qa(e.channel,t)),am=(e)=>NO(e.channel),Dj=(e)=>Zy(e.channel),Nj=(e)=>Ha(e.channel,()=>"",(t,n)=>t+n.join("")),Bj=(e)=>B(Vy(e.channel),(t)=>t.buffer),Lj=(e)=>Vy(e.channel),xS=y((e)=>le(e[0]),(e,t,n)=>{let r=void 0,o=void 0,s=ct(!1);return new ReadableStream({start(a){o=Fl(Jt(sm(e,(i)=>s.whenOpen(L(()=>{s.closeUnsafe();for(let c=0;c<i.length;c++)a.enqueue(i[c]);r(),r=void 0}))),t)),o.addObserver((i)=>{if(i._tag==="Failure")a.error(Oc(i.cause));else a.close()})},pull(){return new Promise((a)=>{r=a,s.openUnsafe()})},cancel(){if(!o)return;return k_(lr(fn(o)))}},n?.strategy)}),zj=y((e)=>le(e[0]),(e,t)=>xS(e,Do(),t)),$j=y((e)=>le(e[0]),(e,t)=>B(Qn(),(n)=>xS(e,n,t))),yS=y(2,(e,t)=>({[Symbol.asyncIterator](){let n=T_(t),r=Fn(t),o=ko(),s,a,i,c,f=(d)=>{if(c)return c;let l=i;return c=n(nt(gt(l?fn(l):R,Te(o,d)),{done:!0,value:void 0})),c},u=async(d)=>{try{await f(d)}catch(l){await n(em("Suppressed error while closing Stream async iterator",l))}};return{async next(){if(c)return c;if(a){let m=a.next();if(!m.done)return m;a=void 0}let d=r(s??A(Po(e.channel,o),(m)=>(s=m,m)));i=d;let l=await n(A_(d));if(i===d)i=void 0;if($e(l))return a=l.value[Symbol.iterator](),a.next();else if(es(l.cause))return f(Ye);if(c&&m_(l.cause))return c;throw await u(l),Oc(l.cause)},return(){return f(Ye)},async throw(d){throw await u(Xp(d)),d}}}})),qj=(e)=>B(Qn(),(t)=>yS(e,t)),Hj=(e)=>yS(e,Do()),jj=y((e)=>le(e[0]),(e,t,n)=>Yy(e.channel,t,n)),Wj=y(2,(e,t)=>jO(e.channel,t)),mR=y(2,(e,t)=>WO(e.channel,t)),Jj=y(2,(e,t)=>qO(e.channel,t)),Gj=y(2,(e,t)=>Qy(e.channel,t));var SS="~effect/rpc/RpcSchema/StreamSchema";function ES(e){return V(e,SS)}function im(e){return ES(e)?oe({success:e.success,error:e.error}):ne()}var Kj=we(le);function hR(e,t){return H(Kj.ast,{[SS]:SS,success:e,error:t})}var IS="~effect/rpc/Rpc",Vj=(e)=>V(e,IS);class xR{id;annotations;constructor(e){this.id=e,this.annotations=Do()}annotate(e,t){return this.annotations=Un(this.annotations,e,t),this}}var Zj={[IS]:IS,pipe(){return de(this,arguments)},setSuccess(e){return Vs({_tag:this._tag,payloadSchema:this.payloadSchema,successSchema:e,errorSchema:this.errorSchema,defectSchema:this.defectSchema,annotations:this.annotations,middlewares:this.middlewares})},setError(e){return Vs({_tag:this._tag,payloadSchema:this.payloadSchema,successSchema:this.successSchema,errorSchema:e,defectSchema:this.defectSchema,annotations:this.annotations,middlewares:this.middlewares})},setPayload(e){return Vs({_tag:this._tag,payloadSchema:va(e)?e:ae(e),successSchema:this.successSchema,errorSchema:this.errorSchema,defectSchema:this.defectSchema,annotations:this.annotations,middlewares:this.middlewares})},middleware(e){return Vs({_tag:this._tag,payloadSchema:this.payloadSchema,successSchema:this.successSchema,errorSchema:this.errorSchema,defectSchema:this.defectSchema,annotations:this.annotations,middlewares:new Set([...this.middlewares,e])})},prefix(e){return Vs({_tag:`${e}${this._tag}`,payloadSchema:this.payloadSchema,successSchema:this.successSchema,errorSchema:this.errorSchema,defectSchema:this.defectSchema,annotations:this.annotations,middlewares:this.middlewares})},annotate(e,t){return Vs({_tag:this._tag,payloadSchema:this.payloadSchema,successSchema:this.successSchema,errorSchema:this.errorSchema,defectSchema:this.defectSchema,middlewares:this.middlewares,annotations:Un(this.annotations,e,t)})},annotateMerge(e){return Vs({_tag:this._tag,payloadSchema:this.payloadSchema,successSchema:this.successSchema,errorSchema:this.errorSchema,defectSchema:this.defectSchema,middlewares:this.middlewares,annotations:er(this.annotations,e)})}},Vs=(e)=>{function t(){}return Object.setPrototypeOf(t,Zj),Object.assign(t,e),t.key=`effect/rpc/Rpc/${e._tag}`,t},yR=(e,t)=>{let n=t?.success??cc,r=t?.error??tu,o=t?.defect??bt(),s;if(t?.primaryKey)s=class extends lp(`effect/rpc/Rpc/${e}`)(t.payload){[wC](){return t.primaryKey(this)}};else s=va(t?.payload)?t?.payload:t?.payload?ae(t?.payload):cc;return Vs({_tag:e,payloadSchema:s,successSchema:t?.stream?hR(n,r):n,errorSchema:t?.stream?tu:r,defectSchema:o,annotations:Do(),middlewares:new Set})},Qj=(e)=>(t,n)=>{let r=n?.success??cc,o=n?.error??tu,s=n?.defect??bt(),a=e({success:r,error:o,defect:s});return yR(t,{...a,primaryKey:n?.primaryKey,payload:n?.payload,stream:n?.stream})},bS=new WeakMap,wS=(e)=>{if(bS.has(e))return bS.get(e);let t=e,n=new Set([t.errorSchema]),r=im(t.successSchema);if(ve(r))n.add(r.value.error);for(let s of t.middlewares)n.add(s.error);let o=ay(ve(r)?cc:t.successSchema,Ie([...n]),t.defectSchema);return bS.set(e,o),o},Lu="~effect/rpc/Rpc/Wrapper",Pc=(e)=>(Lu in e),cm=(e)=>(t)=>Pc(t)?{[Lu]:Lu,value:t.value,fork:e.fork??t.fork,uninterruptible:e.uninterruptible??t.uninterruptible}:{[Lu]:Lu,value:t,fork:e.fork??!1,uninterruptible:e.uninterruptible??!1},Yj=(e)=>Pc(e)?e.value:e,Xj=(e,t)=>{if(Pc(e))return cm(e)(t(e.value));return t(e)},e4=cm({fork:!0}),t4=cm({uninterruptible:!0});var dm={};Ps(dm,{make:()=>r4});var n4={add(...e){let t=new Map(this.requests);for(let n of e)t.set(n._tag,n);return as({requests:t,annotations:this.annotations})},merge(...e){let t=new Map(this.requests),n=new Map(this.annotations.mapUnsafe);for(let r of e){for(let[o,s]of r.requests)t.set(o,s);for(let[o,s]of r.annotations.mapUnsafe)n.set(o,s)}return as({requests:t,annotations:Ac(n)})},omit(...e){let t=new Map(this.requests);for(let n of e)t.delete(n);return as({requests:t,annotations:this.annotations})},middleware(e){let t=new Map;for(let[n,r]of this.requests)t.set(n,r.middleware(e));return as({requests:t,annotations:this.annotations})},toHandlers(e){let t=this;return je(function*(){let n=yield*Qn(),r=fm(e)?yield*e:e,o=new Map;return t.requests.forEach((s,a)=>{o.set(s.key,{tag:s._tag,handler:r[a],context:n})}),Ac(o)})},prefix(e){let t=new Map;for(let n of this.requests.values()){let r=n.prefix(e);t.set(r._tag,r)}return as({requests:t,annotations:this.annotations})},toLayer(e){return kS(this.toHandlers(e))},of:Q,toLayerHandler(e,t){let n=this;return kS(je(function*(){let r=yield*Qn(),o=fm(t)?yield*t:t,s=new Map,a=n.requests.get(e);return s.set(a.key,{handler:o,context:r}),Ac(s)}))},accessHandler(e){return Gr((t)=>{let n=this.requests.get(e),{handler:r,context:o}=um(t,n.key);return b((s,a)=>{a.rpc=n;let i=r(s,a),c=Pc(i)?i.value:i;return fm(c)?ER(c,o):hS(c,o)})})},annotate(e,t){return as({requests:this.requests,annotations:Un(this.annotations,e,t)})},annotateRpcs(e,t){return this.annotateRpcsMerge(SR(e,t))},annotateMerge(e){return as({requests:this.requests,annotations:er(this.annotations,e)})},annotateRpcsMerge(e){let t=new Map;for(let[n,r]of this.requests)t.set(n,r.annotateMerge(er(e,r.annotations)));return as({requests:t,annotations:this.annotations})}},as=(e)=>Object.assign(function(){},n4,{requests:e.requests,annotations:e.annotations}),r4=(...e)=>as({requests:new Map(e.map((t)=>[t._tag,t])),annotations:Do()});var ms={};Ps(ms,{ConnectionHooks:()=>Zm,CurrentHeaders:()=>Vm,Protocol:()=>ps,layerProtocolHttp:()=>tG,layerProtocolSocket:()=>oG,layerProtocolWorker:()=>sG,make:()=>YJ,makeNoSerialization:()=>iU,makeProtocolHttp:()=>cU,makeProtocolSocket:()=>fU,makeProtocolWorker:()=>uU,withHeaders:()=>eG});var TS="~effect/http/HttpBody";var bR="~effect/http/HttpBody/HttpBodyError";class o4 extends Qt("HttpBodyError"){[bR]=bR}class AS{[TS];constructor(){this[TS]=TS}[Re](){return this.toJSON()}toString(){return K(this,{ignoreToString:!0})}}class IR extends AS{_tag="Empty";toJSON(){return{_id:"effect/HttpBody",_tag:"Empty"}}}var wR=new IR;class lm extends AS{_tag="Uint8Array";contentType;contentLength;text;_body;constructor(e,t,n,r){super();this._body=e,this.text=r,this.contentType=t,this.contentLength=n}get body(){return this._body??=s4(this.text)}toJSON(){return{_id:"effect/HttpBody",_tag:"Uint8Array",body:this.contentType.startsWith("text/")||this.contentType.endsWith("json")?new TextDecoder().decode(this.body):`Uint8Array(${this.body.length})`,contentType:this.contentType,contentLength:this.contentLength}}}var CS=(e,t)=>new lm(e,t??"application/octet-stream",e.length),kR=new TextEncoder,pm=globalThis.Buffer,s4=pm!==void 0?(e)=>pm.from(e,"utf8"):(e)=>kR.encode(e),vS=(e,t)=>{if(typeof e!=="string")e=e===void 0?"":String(e);if(pm!==void 0)return new lm(void 0,t??"text/plain",pm.byteLength(e,"utf8"),e);let n=kR.encode(e);return new lm(n,t??"text/plain",n.length,e)};var OS="~effect/http/HttpClientError";class Zs extends Qt("HttpClientError"){constructor(e){if("cause"in e.reason)super({...e,cause:e.reason.cause});else super(e)}[OS]=OS;get request(){return this.reason.request}get response(){return"response"in this.reason?this.reason.response:void 0}get message(){return this.reason.message}}var AR=(e)=>e.endsWith("Error")?e.slice(0,-5):e,CR=(e,t,n)=>t?`${e}: ${t} (${n})`:`${e} error (${n})`;class Va extends Qt("DecodeError"){get methodAndUrl(){return`${this.request.method} ${this.request.url}`}get message(){let e=`${this.response.status} ${this.methodAndUrl}`;return CR(AR(this._tag),this.description,e)}}class _S extends Qt("EmptyBodyError"){get methodAndUrl(){return`${this.request.method} ${this.request.url}`}get message(){let e=`${this.response.status} ${this.methodAndUrl}`;return CR(AR(this._tag),this.description,e)}}class Mc extends Ct(OS)({_tag:ye("HttpError"),kind:ur(["EncodeError","DecodeError","TransportError","InvalidUrlError","StatusCodeError","EmptyBodyError"]),cause:mt(bt())}){static fromHttpClientError(e){return new Mc({_tag:"HttpError",kind:e.reason._tag,cause:e.reason})}}var vR=[["GET","get"],["POST","post"],["PUT","put"],["DELETE","del"],["PATCH","patch"],["HEAD","head"],["OPTIONS","options"],["TRACE","trace"],["QUERY","query"]];var OR=(e,t)=>{if(t._tag==="Empty"||t._tag==="FormData")return li(li(e,"content-type"),"content-length");return e=t.contentType===void 0?li(e,"content-type"):af(e,"content-type",t.contentType),t.contentLength===void 0?li(e,"content-length"):af(e,"content-length",t.contentLength.toString())};class RS extends Qt("UrlError"){}var _R=(e,t,n)=>ql({try:()=>{let r=new URL(e,f4());for(let o=0;o<t.params.length;o++){let[s,a]=t.params[o];if(a!==void 0)r.searchParams.append(s,a)}if(n!==void 0)r.hash=n;return r},catch:(r)=>new RS({cause:r})}),f4=()=>{if("location"in globalThis&&globalThis.location!==void 0&&globalThis.location.origin!==void 0&&globalThis.location.pathname!==void 0)return location.origin+location.pathname;return};var RR="~effect/http/HttpClientRequest";var d4={[RR]:RR,...ho,toJSON(){return{_id:"HttpClientRequest",method:this.method,url:this.url,urlParams:this.urlParams,hash:this.hash,headers:ui(this.headers),body:this.body.toJSON()}},pipe(){return de(this,arguments)}};function No(e,t,n,r,o,s){let a=Object.create(d4);return a.method=e,a.url=t,a.urlParams=n,a.hash=r,a.headers=o,a.body=s,a}var l4=No("GET","",AI,ne(),di,wR),PR=(e)=>(t,n)=>p4(l4,{method:e,url:t,...n??void 0});var p4=y(2,(e,t)=>{let n=e;if(t.method)n=MR(n,t.method);if(t.url)n=NR(n,t.url);if(t.headers)n=FR(n,t.headers);if(t.urlParams)n=g4(n,t.urlParams);if(t.hash)n=x4(n,t.hash);if(t.body)n=LR(n,t.body);if(t.accept)n=DR(n,t.accept);if(t.acceptJson)n=m4(n);return n}),MR=y(2,(e,t)=>No(t,e.url,e.urlParams,e.hash,e.headers,e.body)),UR=y(3,(e,t,n)=>No(e.method,e.url,e.urlParams,e.hash,af(e.headers,t,n),e.body)),FR=y(2,(e,t)=>No(e.method,e.url,e.urlParams,e.hash,II(e.headers,t),e.body));var DR=y(2,(e,t)=>UR(e,"Accept",t)),m4=DR("application/json"),NR=y(2,(e,t)=>{if(typeof t==="string")return No(e.method,t,e.urlParams,e.hash,e.headers,e.body);let n=new URL(t.toString()),r=la(n.searchParams),o=Zd(n.hash===""?void 0:n.hash.slice(1));return n.search="",n.hash="",No(e.method,n.toString(),r,o,e.headers,e.body)}),BR=y(2,(e,t)=>{if(t==="")return e;return No(e.method,h4(t,e.url),e.urlParams,e.hash,e.headers,e.body)});var h4=(e,t)=>{let n=e.endsWith("/"),r=t.startsWith("/");return n&&r?e+t.slice(1):!n&&!r?e+"/"+t:e+t};var g4=y(2,(e,t)=>No(e.method,e.url,vI(e.urlParams,t),e.hash,e.headers,e.body));var x4=y(2,(e,t)=>No(e.method,e.url,e.urlParams,oe(t),e.headers,e.body));var LR=y(2,(e,t)=>No(e.method,e.url,e.urlParams,e.hash,OR(e.headers,t),t));function zR(e){let t=_R(e.url,e.urlParams,Ef(e.hash));if(At(t))return oe(t.success);return ne()}var Za="~effect/http/HttpIncomingMessage";var $R=(e,t)=>{let n=e.headers["content-type"]??"",r;if(n.includes("application/json"))try{r=Uc(e.json)}catch(s){}else if(n.includes("text/")||n.includes("urlencoded"))try{r=Uc(e.text)}catch(s){}let o={...t,headers:ui(e.headers),remoteAddress:e.remoteAddress};if(r!==void 0)o.body=r;return o};var Fc="~effect/http/HttpClientResponse";class y4 extends HR{[Za];[Fc];request;source;constructor(e,t){super();this.request=e,this.source=t,this[Za]=Za,this[Fc]=Fc}toJSON(){return $R(this,{_id:"HttpClientResponse",request:this.request.toJSON(),status:this.status})}get status(){return this.source.status}get url(){if(this.source.url)return this.source.url.split("#")[0];let e=zR(this.request);if(Tn(e))return"";return e.value.hash="",e.value.href}get headers(){return Es(this.source.headers)}cachedCookies;get cookies(){if(this.cachedCookies)return this.cachedCookies;return this.cachedCookies=vd(this.source.headers.getSetCookie())}get remoteAddress(){return ne()}get stream(){return this.source.body?sS({evaluate:()=>this.source.body,onError:(e)=>new Zs({reason:new Va({request:this.request,response:this,cause:e})})}):Js(new Zs({reason:new _S({request:this.request,response:this,description:"can not create stream from empty body"})}))}get json(){return A(this.text,(e)=>Mr({try:()=>e===""?null:JSON.parse(e),catch:(t)=>new Zs({reason:new Va({request:this.request,response:this,cause:t})})}))}textBody;get text(){return this.textBody??=B(this.arrayBuffer,(e)=>new TextDecoder().decode(e))}get urlParamsBody(){return A(this.text,(e)=>Mr({try:()=>la(new URLSearchParams(e)),catch:(t)=>new Zs({reason:new Va({request:this.request,response:this,cause:t})})}))}formDataBody;get formData(){return this.formDataBody??=fr({try:()=>this.source.formData(),catch:(e)=>new Zs({reason:new Va({request:this.request,response:this,cause:e})})}).pipe(MS,Uc)}arrayBufferBody;get arrayBuffer(){if(this.arrayBufferBody)return this.arrayBufferBody;return this.arrayBufferBody=fr({try:()=>this.source.arrayBuffer(),catch:(e)=>new Zs({reason:new Va({request:this.request,response:this,cause:e})})}).pipe(MS,Uc),this.arrayBufferBody}pipe(){return de(this,arguments)}}var jR="~effect/http/HttpClient";var JR=Ft("effect/HttpClient");var E4=(e,t)=>{let n=Object.create(b4);return n.preprocess=t,n.postprocess=e,n.execute=function(r){return e(t(r))},n},b4={[jR]:jR,pipe(){return de(this,arguments)},...ho,toJSON(){return{_id:"effect/HttpClient"}},...Object.fromEntries(vR.map(([e,t])=>[t,function(n,r){return this.execute(PR(e)(n,r))}]))};var GR=y(2,(e,t)=>E4(e.postprocess,(n)=>B(e.preprocess(n),t)));var WR=(()=>{if("FinalizationRegistry"in globalThis&&globalThis.FinalizationRegistry){let t=new FinalizationRegistry((n)=>{n.abort()});return{register(n,r){t.register(n,r,n)},unregister(n){t.unregister(n)}}}let e=new Map;return{register(t,n){e.set(t,setTimeout(()=>n.abort(),5000))},unregister(t){let n=e.get(t);if(n===void 0)return;clearTimeout(n),e.delete(t)}}})();class I4{original;controller;constructor(e,t){this.original=e,this.controller=t}[Fc]=Fc;[Za]=Za;applyInterrupt(e){return M(()=>(WR.unregister(this.original),Ic(e,()=>L(()=>{this.controller.abort()}))))}get request(){return this.original.request}get url(){return this.original.url}get status(){return this.original.status}get headers(){return this.original.headers}get cookies(){return this.original.cookies}get remoteAddress(){return this.original.remoteAddress}get formData(){return this.applyInterrupt(this.original.formData)}get text(){return this.applyInterrupt(this.original.text)}get json(){return this.applyInterrupt(this.original.json)}get urlParamsBody(){return this.applyInterrupt(this.original.urlParamsBody)}get arrayBuffer(){return this.applyInterrupt(this.original.arrayBuffer)}get stream(){return dn(()=>(WR.unregister(this.original),mS(this.original.stream,L(()=>{this.controller.abort()}))))}toJSON(){return this.original.toJSON()}[Re](){return this.original[Re]()}pipe(){return de(this,arguments)}}var KR="~effect/Pool",sP=Symbol(),aP=Symbol(),BS=Symbol();var iP=(e)=>fP({...e,min:e.size,max:e.size,strategy:ym}),cP=(e)=>A(e.timeToLiveStrategy==="creation"?P4(e.timeToLive):M4(e.timeToLive),(t)=>fP({...e,strategy:t})),fP=(e)=>Xn(re(function*(t){let n=yield*Qn(),r=Lt(n,ut),o=Qs(e.acquire,(f)=>er(n,f)),s=e.concurrency??1,a={acquire:o,concurrency:s,isFixed:e.min===e.max,minSize:e.min,maxSize:e.max,strategy:e.strategy,targetUtilization:Math.min(Math.max(e.targetUtilization??1,0.1),1)},i={scope:r,isShuttingDown:!1,usage:0,resizeSemaphore:La(1),items:new Set,availableHead:void 0,availableTail:void 0,invalidated:new Set,waiters:new Set},c={[KR]:KR,[sP]:e.acquire,[aP]:n,[BS]:yield*Uo,config:a,state:i,pipe(){return de(this,arguments)}};if(yield*Me(r,k4(c)),a.minSize>0)yield*xt(DS(t(gm(c)),{startImmediately:!0}),(f)=>Me(r,fn(f)));if(e.strategy!==ym)yield*xt(DS(t(e.strategy.run(c))),(f)=>Me(r,fn(f)));return c})),k4=re(function*(e){if(e.state.isShuttingDown)return;e.state.isShuttingDown=!0;let t=e.state.items.size,n=La(t);for(let r of e.state.items)if(r.refCount>0)r.finalizer=xt(r.finalizer,n.release(1)),e.state.invalidated.add(r),yield*n.take(1);else e.state.items.delete(r),zu(e,r),e.state.invalidated.delete(r),yield*r.finalizer;if(yield*n.releaseAll,e.state.waiters.size>0){let r=Array.from(e.state.waiters);e.state.waiters.clear();for(let o of r)o()}yield*n.take(t)}),LS=(e)=>mr((t)=>{let n=e.state;if(n.isShuttingDown)return hm;if(n.availableHead?.exit._tag==="Success"){if(n.usage++,e.config.isFixed||$u(e)<=qu(e))return uP(e,n.availableHead,t);n.usage--}return T4(e,v4)});var T4=(e,t)=>Na((n)=>{let r=e.state;r.usage++;let o=Su(nP(n(_4(e)),()=>To(()=>{r.usage--})),()=>a),s=mr((i)=>{if(r.isShuttingDown)return r.usage--,hm;let c=zS(e)??($u(e)<=qu(e)?r.availableHead:void 0);if(c===void 0)return o;if(c.exit._tag==="Failure")return C4(e,c),a;return t(e,c,i,n)}),a=Ao(()=>{if(r.isShuttingDown)return r.usage--,hm;return $u(e)>qu(e)?Su(r.resizeSemaphore.withPermitsIfAvailable(1)(Ne(is(gm(e)),r.scope)),()=>s):s});return a}),A4=(e,t)=>{if(t.refCount++,t.refCount>=e.config.concurrency)zu(e,t)},C4=(e,t)=>{e.state.items.delete(t),e.state.invalidated.delete(t),zu(e,t)},uP=(e,t,n)=>{A4(e,t);let r=Cc(n.context,ut);if(r.state._tag==="Closed")tP(n,t.release);else XR(r,{},t.release);return t.exit},v4=(e,t,n)=>uP(e,t,n),O4=(e,t)=>mr((n)=>{let r=e.state;if(t.refCount--,r.usage--,t.refCount===0)t.idleSince=e[BS].currentTimeMillisUnsafe();if(r.invalidated.has(t))return qS(e,t);if(t.refCount<e.config.concurrency)R4(e,t),dP(e,n,1);return Co}),zS=(e)=>{let t=e.state.availableHead;while(t!==void 0&&t.exit._tag==="Failure")t=t.availableNext;return t},_4=(e)=>Bs((t)=>{let n=e.state;if(zS(e)!==void 0||n.isShuttingDown)return t(Co);let r=(o)=>{n.waiters.delete(r),t(o??Co)};return n.waiters.add(r),To(()=>{n.waiters.delete(r)})}),dP=(e,t,n)=>{let r=e.state.waiters;if(r.size===0)return;t.currentDispatcher.scheduleTask(()=>{let o=n,s=[];for(let a of r){if(o--<=0)break;s.push(a)}for(let a=0;a<s.length;a++)s[a]()},0)},VR=(e)=>mr((t)=>(dP(e,t,Number.POSITIVE_INFINITY),Co)),$S=new WeakMap,ZR=(e,t)=>{if(t.isAvailable||$S.has(t))return;if(t.isAvailable=!0,t.availablePrevious=e.state.availableTail,t.availableNext=void 0,e.state.availableTail!==void 0)e.state.availableTail.availableNext=t;else e.state.availableHead=t;e.state.availableTail=t},R4=(e,t)=>{if(t.isAvailable||$S.has(t))return;if(t.isAvailable=!0,t.availablePrevious=void 0,t.availableNext=e.state.availableHead,e.state.availableHead!==void 0)e.state.availableHead.availablePrevious=t;else e.state.availableTail=t;e.state.availableHead=t},zu=(e,t)=>{if(!t.isAvailable)return;if(t.isAvailable=!1,t.availablePrevious!==void 0)t.availablePrevious.availableNext=t.availableNext;else e.state.availableHead=t.availableNext;if(t.availableNext!==void 0)t.availableNext.availablePrevious=t.availablePrevious;else e.state.availableTail=t.availablePrevious;t.availablePrevious=void 0,t.availableNext=void 0};var qS=(e,t)=>M(()=>{if(!e.state.items.has(t))return R;else if(t.refCount===0)return e.state.items.delete(t),zu(e,t),e.state.invalidated.delete(t),lr(A(t.finalizer,()=>Ne(is(gm(e)),e.state.scope,{startImmediately:!0})));return e.state.invalidated.add(t),zu(e,t),lr(Ne(is(gm(e)),e.state.scope,{startImmediately:!0}))}),gm=(e)=>e.state.resizeSemaphore.withPermits(1)(NS(e)),NS=(e)=>M(()=>{let t=qu(e),n=$u(e);if(t>=n)return R;let r=n-t,o=e.config.strategy===ym?QR(e):A(e.config.strategy.reclaim(e),(a)=>a?b(a):QR(e));if(r===1){let a=xt(o,VR(e));return e.config.isFixed?lr(a):A(a,(i)=>i.exit._tag==="Failure"?R:NS(e))}let s=o.pipe(oP(r,{concurrency:r}),xt(VR(e)));return e.config.isFixed?lr(s):A(s,(a)=>a.some((i)=>i.exit._tag==="Failure")?R:NS(e))}),QR=(e)=>Na((t)=>mr((n)=>{let r=e,o=eP(),s=n.context;n.setContext(Un(r[aP],ut,o));let a=A(or(r[sP]),(i)=>{let c={exit:i,finalizer:De(Te(o,i),U4),refCount:0,idleSince:r[BS].currentTimeMillisUnsafe(),disableReclaim:!1,isAvailable:!1,availablePrevious:void 0,availableNext:void 0,release:void 0};c.release=pr(O4(e,c));let f=M(()=>e.state.items.has(c)?e.config.strategy.onAcquire(c):R);if(i._tag==="Success")return e.state.items.add(c),ZR(e,c),e.config.strategy===ym?b(c):nt(f,c);let u=zS(e)===void 0?e.state.waiters.values().next().value:void 0;if(u!==void 0)u(i);else e.state.items.add(c),ZR(e,c);return nt(Ne(gt(c.finalizer,f),e.state.scope,{startImmediately:!0}),c)});return yu(t(a),(i)=>(n.setContext(s),i._tag==="Failure"?YR(o,i):void 0),!0)})),$u=(e)=>{if(e.state.isShuttingDown)return 0;if(e.config.isFixed)return e.config.minSize;let t=e.state.usage/e.config.targetUtilization,n=Math.ceil(t/e.config.concurrency);return Math.min(Math.max(e.config.minSize,n),e.config.maxSize)},qu=(e)=>e.state.items.size-e.state.invalidated.size,ym={run:(e)=>R,onAcquire:(e)=>R,reclaim:(e)=>xm},P4=re(function*(e){let t=yield*Uo,n=yield*_p(),r=Wn(Zt(e)),o=new WeakMap;return Q({run:(s)=>{let a=(i)=>M(()=>{if(!s.state.items.has(i)||s.state.invalidated.has(i))return R;let c=t.currentTimeMillisUnsafe(),f=o.get(i),u=r-(c-f);return u>0?Ks(a(i),u):qS(s,i)});return Zr(n).pipe(xt(a),Ze({disableYield:!0}))},onAcquire:(s)=>M(()=>(o.set(s,t.currentTimeMillisUnsafe()),bn(n,s))),reclaim:(s)=>xm})}),M4=re(function*(e){let t=yield*Uo,n=Wn(Zt(e));return Q({run:(r)=>{let o=M(()=>{if(qu(r)<=$u(r))return R;let s=t.currentTimeMillisUnsafe()-n,a;for(let i of r.state.items){if(i.refCount>0||i.idleSince>s)continue;if(r.state.invalidated.has(i)||$S.has(i))continue;if(a===void 0||i.idleSince<a.idleSince)a=i}return a===void 0?R:A(qS(r,a),()=>o)});return o.pipe(Ks(e),Ze({disableYield:!0}))},onAcquire:(r)=>R,reclaim:(r)=>xm})}),U4=(e)=>dt((t)=>{let n=t.getRef(rP);if(n)return ku(n)("Unhandled error in pool finalizer",e);return R});var co={};Ps(co,{CloseEvent:()=>gP,Socket:()=>Qa,SocketCloseError:()=>fs,SocketError:()=>Ae,SocketErrorReason:()=>wm,SocketErrorTypeId:()=>Hu,SocketOpenError:()=>cs,SocketReadError:()=>ao,SocketUpgradeError:()=>io,SocketWriteError:()=>Er,TypeId:()=>Em,WebSocket:()=>EP,WebSocketConstructor:()=>Tm,fromTransformStream:()=>W4,fromWebSocket:()=>bP,isCloseEvent:()=>Nc,isSocket:()=>mP,isSocketError:()=>xP,layerWebSocket:()=>j4,layerWebSocketConstructorGlobal:()=>z4,make:()=>Wu,makeChannel:()=>L4,makeWebSocket:()=>WS,makeWebSocketChannel:()=>H4,readerBytes:()=>jS,readerString:()=>hP,toChannel:()=>SP,toChannelString:()=>N4,toChannelWith:()=>km,toStream:()=>B4});var Em="~effect/socket/Socket",mP=(e)=>V(e,Em),Qa=Ft("effect/socket/Socket"),Wu=(e)=>Qa.of({[Em]:Em,reader:e.reader,writer:e.writer}),bm=new TextEncoder,jS=(e)=>B(e.reader,({pull:t})=>B(t,(n)=>{for(let r=0;r<n.length;r++)if(typeof n[r]==="string"){let o=Array(n.length);for(let s=0;s<n.length;s++){let a=n[s];o[s]=typeof a==="string"?bm.encode(a):a}return o}return n})),hP=(e,t)=>B(e.reader,({pull:n})=>{let r=new TextDecoder(t);return B(n,(o)=>{let s=Array(o.length);for(let a=0;a<o.length;a++){let i=o[a];s[a]=typeof i==="string"?i:r.decode(i)}return s})}),Sm="~effect/socket/Socket/CloseEvent";class gP{[Sm];code;reason;constructor(e=1000,t){this[Sm]=Sm,this.code=e,this.reason=t}toString(){return this.reason?`${this.code}: ${this.reason}`:`${this.code}`}}var Nc=(e)=>V(e,Sm),Hu="~effect/socket/Socket/SocketError",xP=(e)=>V(e,Hu);class ao extends Ct("effect/socket/Socket/SocketReadError")({_tag:ye("SocketReadError"),cause:bt()}){message="An error occurred during Read"}class Er extends Ct("effect/socket/Socket/SocketWriteError")({_tag:ye("SocketWriteError"),cause:bt()}){message="An error occurred during Write"}class cs extends Ct("effect/socket/Socket/SocketOpenError")({_tag:ye("SocketOpenError"),kind:ur(["Unknown","Timeout"]),cause:bt()}){get message(){return this.kind==="Timeout"?'timeout waiting for "open"':"An error occurred during Open"}}class io extends Ct("effect/socket/Socket/SocketUpgradeError")({_tag:ye("SocketUpgradeError"),cause:mt(bt())}){static unsupported=()=>_(new Ae({reason:new io({})}));get message(){return this.cause===void 0?"Socket does not support TLS upgrade":"An error occurred during TLS upgrade"}}class fs extends Ct("effect/socket/Socket/SocketCloseError")({_tag:ye("SocketCloseError"),code:wo,closeReason:mt(z)}){get message(){if(this.closeReason)return`${this.code}: ${this.closeReason}`;return`${this.code}`}}var wm=Ie([ao,Er,cs,io,fs]);class Ae extends fy(Hu)("SocketError",{_tag:ye("SocketError"),reason:wm}){constructor(e){if("cause"in e.reason)super({...e,cause:e.reason.cause});else super(e)}[Hu]=Hu;static is(e){return xP(e)}message=this.reason.message}var ju=(e,t)=>new Ae({reason:new fs({code:e,closeReason:t})}),D4=(e,t)=>{for(let n=0;n<t.length;n++)if(Nc(t[n]))return je(function*(){for(let r=0;r<=n;r++)yield*e.write(t[r])});return e.writeAll(t)},yP=(e,t)=>me(re(function*(n,r){let o=yield*HS(r),s=yield*In(t,o),a=yield*HS(r),i=yield*In(e.writer,a),c;return yield*n.pipe(A((f)=>D4(i,f)),Ze({disableYield:!0}),pP(lP,(f)=>M(()=>(c=f,Te(o,Ye)))),_o(Te(a,Ye)),Ne(r)),De(M(()=>c!==void 0?He(c):s),(f)=>He(c??f))})),SP=(e)=>yP(e,jS(e)),N4=y((e)=>mP(e[0]),(e,t)=>yP(e,hP(e,t))),km=()=>(e)=>SP(e),B4=(e)=>P(me((t,n)=>In(jS(e),n))),L4=()=>no(B(Qa,km()));class EP extends Ft()("~effect/socket/Socket/WebSocket"){}class Tm extends Ft()("@effect/platform/Socket/WebSocketConstructor"){}var z4=Ys(Tm)((e,t)=>{if(t!==void 0&&typeof t!=="string"&&!Array.isArray(t))throw TypeError("WebSocket client options are not supported by the global WebSocket constructor");return new globalThis.WebSocket(e,t)}),WS=(e,t)=>Tm.use((n)=>bP(xr((typeof e==="string"?b(e):e).pipe(B((r)=>n(r,t?.protocols))),(r)=>L(()=>r.close(1000))),t)),$4=(e)=>("pause"in e)&&typeof e.pause==="function",bP=(e,t)=>dt((n)=>{let r,o=ct(!1),s=n.context,a=je(function*(){let u=yield*Yn,d=yield*In(e,u);if("binaryType"in d)d.binaryType="arraybuffer";let l=$4(d),m=t?.highWaterMark??(l?q4:void 0),p=d.readyState===1,g=l&&"isPaused"in d&&d.isPaused===!0,h=[],E=0,S,k,I;function x(){if(!l||g)return;d.pause(),g=!0}function w(){if(!l||!g)return;d.resume(),g=!1}function C(){let J=h;if(h=[],E=0,S===void 0)w();return J}function T(){if(k===void 0||h.length===0)return;let J=k;k=void 0,J(b(C()))}function v(J){if(h.push(J),m!==void 0)E+=typeof J==="string"?bm.encode(J).byteLength:J.byteLength;if(k!==void 0)T();if(l&&E>=m)x();else if(!l&&!k&&m!==void 0&&E>m)O(new Ae({reason:new ao({cause:Error(`Socket highWaterMark of ${m} bytes exceeded`)})}))}function O(J){if(S===void 0)S=J;if(I!==void 0){let{cleanup:N,resume:G}=I;I=void 0,N(),G(_(S))}if(k!==void 0){let N=k;k=void 0,N(h.length>0?b(C()):_(S))}}function U(J){let N=J.data;if(typeof Blob<"u"&&N instanceof Blob){N.arrayBuffer().then((G)=>v(new Uint8Array(G)),(G)=>{O(new Ae({reason:new ao({cause:G})}))});return}v(N instanceof ArrayBuffer?new Uint8Array(N):N)}function j(J){O(new Ae({reason:p?new ao({cause:J}):new cs({kind:"Unknown",cause:J})}))}function X(J){O(ju(typeof J.code==="number"?J.code:1006,J.reason))}if(d.addEventListener("message",U),d.addEventListener("error",j,{once:!0}),d.addEventListener("close",X,{once:!0}),yield*Me(u,L(()=>{if(O(ju(1006)),d.removeEventListener("message",U),d.removeEventListener("error",j),d.removeEventListener("close",X),l)try{w()}catch{}o.closeUnsafe(),r=void 0})),d.readyState>=2)return yield*_(S??ju(1006));if(!p)yield*Gn((J)=>{let N=()=>{if(I?.resume!==J)return;I=void 0,d.removeEventListener("open",N),J(R)},G=()=>d.removeEventListener("open",N);return I={resume:J,cleanup:G},d.addEventListener("open",N,{once:!0}),L(()=>{if(I?.resume===J)I=void 0;G()})}).pipe(Im({duration:t?.openTimeout??1e4,orElse:()=>_(new Ae({reason:new cs({kind:"Timeout",cause:Error('timeout waiting for "open"')})}))})),p=!0;if(S===void 0&&E<m)w();return r=d,o.openUnsafe(),{pull:Gn((J)=>{if(h.length>0)return J(b(C()));if(S!==void 0)return J(_(S));return k=J,L(()=>{if(k===J)k=void 0})}),upgrade:io.unsupported}}).pipe(Qs((u)=>er(s,u))),i=(u)=>M(()=>{let d=r;if(d===void 0)return o.whenOpen(i(u));try{if(Nc(u))d.close(u.code,u.reason);else d.send(u);return R}catch(l){return _(new Ae({reason:new Er({cause:l})}))}}),c=(u)=>M(()=>{let d=r;if(d===void 0)return o.whenOpen(c(u));try{for(let l=0;l<u.length;l++)d.send(u[l]);return R}catch(l){return _(new Ae({reason:new Er({cause:l})}))}}),f=b({write:i,writeAll:c});return b(Wu({reader:a,writer:f}))}),q4=65536,H4=(e,t)=>no(B(WS(e,t),km())),j4=ja(WS,Dc(Qa)),W4=(e)=>dt((t)=>{let n=ct(!1),r,o=t.context,s=new WeakMap,a=(d)=>{let l=s.get(d);if(!l)l=d.writable.getWriter(),s.set(d,l);return l},i=je(function*(){let d=yield*Yn,l=yield*In(e,d),m=l.readable.getReader(),p;yield*Me(d,M(()=>(n.closeUnsafe(),r=void 0,Ec(()=>m.cancel().catch(Mn))))),r={stream:l,fail(h){if(p===void 0)p=h;m.cancel().catch(Mn)}},n.openUnsafe();let g=fr({try:()=>m.read(),catch:(h)=>p??new Ae({reason:new ao({cause:h})})});return{pull:M(()=>{if(p!==void 0)return _(p);return A(g,({done:h,value:E})=>h?_(p??ju(1000)):b([E]))}),upgrade:io.unsupported}}).pipe(Qs((d)=>er(o,d))),u=xr(b({write:(d)=>n.whenOpen(M(()=>{let l=r;if(Nc(d))return L(()=>{l.fail(ju(d.code,d.reason))});return fr({try:()=>a(l.stream).write(typeof d==="string"?bm.encode(d):d),catch:(m)=>new Ae({reason:new Er({cause:m})})})})),writeAll:(d)=>n.whenOpen(fr({try:async()=>{let l=a(r.stream);for(let m=0;m<d.length;m++){let p=d[m];await l.write(typeof p==="string"?bm.encode(p):p)}},catch:(l)=>new Ae({reason:new Er({cause:l})})}))}),()=>Ec(async()=>{if(!r)return;await a(r.stream).close().catch(Mn)}));return b(Wu({reader:i,writer:u}))});class Am extends Ft()("effect/workers/Transferable/Collector"){}var IP=()=>{let e=[],t=(o)=>{e.push(...o)},n=()=>e,r=()=>{let o=e;return e=[],o};return Am.of({addAllUnsafe:t,addAll:(o)=>L(()=>t(o)),readUnsafe:n,read:L(n),clearUnsafe:r,clear:L(r)})};var JS="~effect/workers/WorkerError";class wP extends Ct("effect/workers/WorkerError/WorkerSpawnError")({_tag:ye("WorkerSpawnError"),message:z,cause:mt(bt())}){}class kP extends Ct("effect/workers/WorkerError/WorkerSendError")({_tag:ye("WorkerSendError"),message:z,cause:mt(bt())}){}class TP extends Ct("effect/workers/WorkerError/WorkerReceiveError")({_tag:ye("WorkerReceiveError"),message:z,cause:mt(bt())}){}class AP extends Ct("effect/workers/WorkerError/WorkerUnknownError")({_tag:ye("WorkerUnknownError"),message:z,cause:mt(bt())}){}var GS=Ie([wP,kP,TP,AP]);class G4 extends Ct(JS)({_tag:ye("WorkerError"),reason:GS}){constructor(e){super({...e,cause:e.reason.cause})}[JS]=JS;get message(){return this.reason.message}}class KS extends Ft()("effect/workers/Worker/WorkerPlatform"){}var Cm={};Ps(Cm,{RpcClientDefect:()=>Xs,RpcClientError:()=>us});var VS="~effect/rpc/RpcClientError";class Xs extends Ct("effect/rpc/RpcClientError/RpcClientDefect")({_tag:ye("RpcClientDefect"),message:z,cause:bt()}){}class us extends Ct(VS)({_tag:ye("RpcClientError"),reason:Ie([GS,wm,Mc,Xs])}){[VS]=VS;get message(){return`${this.reason._tag}: ${this.reason.message}`}}var ZS=(e)=>e;var CP={_tag:"Ping"};var Ju=Ie([z,Oa]),V4=ae({_tag:ye("Request"),id:Ju,tag:z,payload:Hr,headers:Oe(cr([z,z])),isNotification:mt(pt(!0)),traceId:mt(z),spanId:mt(z),sampled:mt(ru)}),QS=Ie([V4,ae({_tag:ye("Ack"),requestId:Ju}),ae({_tag:ye("Interrupt"),requestId:Ju}),ae({_tag:ye("Ping")}),ae({_tag:ye("Eof")}),ae({_tag:ye("Chunk"),requestId:Ju,values:Hr}),ae({_tag:ye("Exit"),requestId:Ju,exit:Hr}),ae({_tag:ye("Defect"),defect:Hr}),ae({_tag:ye("Pong")})]);var YS=(e)=>{switch(e._tag){case"Exit":case"Defect":case"ClientProtocolError":return!0;default:return!1}};var nd={};Ps(nd,{MaxBufferSizeExceeded:()=>kE,RpcSerialization:()=>pn,json:()=>WM,jsonRpc:()=>GM,layerJson:()=>qJ,layerJsonRpc:()=>WJ,layerNdJsonRpc:()=>JJ,layerNdjson:()=>HJ,layerNdjsonWith:()=>jJ,layerSchemaBinary:()=>GJ,makeNdjson:()=>Km,ndJsonRpc:()=>KM,ndjson:()=>JM});var Q4=new WeakMap,Y4=new WeakMap,X4=new WeakMap,eW=new WeakMap;function GP(e,t){let n=t?.fingerprint===!0?Y4:Q4,r=n.get(e);if(r!==void 0)return r;let{exact:o,layout:s,recursive:a,target:i}=zc(e),c=Xa(s,t?.fingerprint),f=o?{value:void 0}:void 0,u=eE(f===void 0?i:_J(i,f,!a),s,c,f);return n.set(e,u),u}function lE(e,t){let n=t?.fingerprint===!0?eW:X4,r=n.get(e);if(r!==void 0)return r;let{exact:o,exitSuccess:s,layout:a,target:i}=zc(e);if(!o){if(!s)return GP(e,t);let f={value:void 0},u=eE(PJ(i,f),a,Xa(a,t?.fingerprint),f,!0);return n.set(e,u),u}let c=eE(MJ(i),a,Xa(a,t?.fingerprint),void 0);return n.set(e,c),c}function eE(e,t,n,r,o=!1){return Hr.pipe(Z(e,CJ(t,n,r,o)))}function KP(e,t){let{exact:n,exitSuccess:r,layout:o}=zc(e),s=Xa(o,t?.fingerprint),a=t??jt;if(!n||a.onExcessProperty==="error"){let i=eu(GP(e,t),t);if(!r||a.onExcessProperty==="error")return i;return(c)=>{if(!Jm(c))return i(c);try{return Lm(o,c,a,s)}catch(f){throw f instanceof ds?new Rn(f.issue):f}}}return(i)=>{try{return Lm(o,i,a,s)}catch(c){throw c instanceof ds?new Rn(c.issue):c}}}function tW(e,t){let{exact:n,layout:r}=zc(e),o=t??jt;if(!n||o.onExcessProperty==="error"){let a=KP(e,t);return(i)=>nW(i.map(a))}let s=Xa(r,t?.fingerprint);return(a)=>{try{return CM(r,a,o,s)}catch(i){throw i instanceof ds?new Rn(i.issue):i}}}function nW(e){if(e.length===1)return e[0];let t=0;for(let o of e)t+=o.length;let n=new Uint8Array(t),r=0;for(let o of e)n.set(o,r),r+=o.length;return n}function VP(e,t){let{exact:n,exitSuccess:r,layout:o,target:s}=zc(e),a=t??jt,i=n?void 0:Xl(s,a),c=i!==void 0&&r?(f)=>Jm(f)?f:i(f):i;return rW(o,Xa(o,t?.fingerprint),a,t?.maxFrameSize,c,ZP(n,t))}function ZP(e,t){if(t?.dictionary!==!0)return!1;if(!e)throw Error("Binary layout: dictionary needs a schema the binary layer validates on its own");return!0}function QP(e,t){let{exact:n,layout:r,target:o}=zc(e),s=ZP(n,t),a=KP(e,t),i=tW(e,t);if(!s)return{encode:a,encodeMany:i};let c=Xa(r,t?.fingerprint),f=t??jt,u=f.onExcessProperty==="error"?eu(o,t):void 0,d=YW(),l=(m)=>{try{return m()}catch(p){throw p instanceof ds?new Rn(p.issue):p}};return{encode:(m)=>l(()=>Lm(r,u===void 0?m:u(m),f,c,d)),encodeMany:(m)=>l(()=>CM(r,u===void 0?m:m.map(u),f,c,d))}}function rW(e,t,n,r,o,s){let a=s?[]:void 0,i=new Uint8Array(0),c=0,f=0,u,d=!1,l=new qm,m=new $m(n,kW),p=()=>{l.release(),m.clear(),i=sE,c=f=0},g=(k,I)=>{throw new Rn(new te({expected:k},I,n))},h=()=>{let k=u;throw u=void 0,k},E=(k,I)=>{let x=k.length-I;if(x>i.length)i=new Uint8Array(Math.max(256,x));i.set(I===0?k:k.subarray(I),0),c=0,f=x},S={feedSync(k){if(u!==void 0)return h();if(d)return g("parser is spent");let I=f===c,x,w,C;if(I)x=k,w=0,C=k.length;else{if(k.length>0){let U=f-c,j=U+k.length;if(j>i.length){let X=new Uint8Array(Math.max(256,i.length*2,j));X.set(i.subarray(c,f)),i=X,c=0,f=U}else if(c>0)i.copyWithin(0,c,f),c=0,f=U;i.set(k,f),f+=k.length}x=i,w=c,C=f}let T=[],v=()=>{if(I){if(w<C)E(k,w)}else if(c=w,c===f)c=f=0;return T},O=(U,j)=>{d=!0;let X=new Rn(new te({expected:U},j,n));if(p(),T.length===0)throw X;return u=X,T};while(!0){let U=0,j=-1,X=C-w,J=1;for(let G=0;G<Math.min(6,X);G++){let fe=x[w+G];if(U+=(fe&127)*J,(fe&128)===0){j=G+1;break}J*=128}if(j===-1){if(X<6)return v();let G=BigInt(U);for(let fe=6;fe<Math.min(10,X);fe++){let Ge=x[w+fe];if(G|=BigInt(Ge&127)<<BigInt(fe*7),(Ge&128)===0){if(j=fe+1,G>tE)return O("safe integer length",G);U=Number(G);break}}if(j===-1){if(X>=10)return O("uvarint",x.subarray(w,w+10));return v()}}if(U===0)return O("nonzero frame length",U);if(r!==void 0&&U>r)return O("frame within maxFrameSize",U);if(j+U>X)return v();let N=W;try{W=0;let G=w+j;m.beginFrame(),l.reset(x,G,G+U,n,m,t.positional,a);let fe=DM(e,l,t);T.push(o===void 0?fe:o(fe))}catch(G){d=!0,p();let fe=G instanceof ds?new Rn(G.issue):sc(G)?G:(()=>{throw G})();if(T.length===0)throw fe;return u=fe,T}finally{W=N}w+=j+U}},endSync(){if(u!==void 0)return h();if(d)return g("parser is spent");d=!0;let k=c<f?i.subarray(c,f):void 0;if(p(),k!==void 0)return g("complete value",k)},feed:(k)=>M(()=>{try{return b(S.feedSync(k))}catch(I){if(sc(I))return _(I);throw I}}),end:M(()=>{try{return S.endSync(),R}catch(k){if(sc(k))return _(k);throw k}})};return S}var oW="~effect/encoding/SchemaBinary/fieldId",sW=32,aW=33,tE=BigInt(Number.MAX_SAFE_INTEGER),Um=BigInt(0),br=BigInt(1),iW=BigInt(2),YP=BigInt(7),vP=BigInt(127),cW=BigInt(1e6),fW=BigInt(255),OP=BigInt(4294967295),uW=BigInt(32),Bo=new TextEncoder,dW=new TextDecoder("utf-8",{fatal:!0,ignoreBOM:!0}),XP=7,_P=281474976710655,lW=4503599627370495,eM=0,tM=1,nM=2,RP=512,pW=1048576,mW=4194304,ei=0,Ya=1,Qu=2,Yu=3,Xu=4,ed=5,hW=6,gW=7,Ir=8;function pE(e){return typeof e==="number"&&Number.isInteger(e)&&e>=-_P&&e<=_P}var zm=8,nE=2199023255551,ta=[1,10,100,1000,1e4,1e5,1e6,1e7,1e8];function mE(e){for(let t=1;t<=zm;t++){let n=Math.round(e*ta[t]);if(!(n>=-nE&&n<=nE))return 0;if(n/ta[t]===e)return t}return 0}function rM(e){let t=Math.floor(e/2);return e%2===1?-t:t}var Ue={bool:1,null:2,undefined:3,number:4,string:5,bytes:6,bigint:7,int64:8,struct:9,variant:10,array:11,option:12,result:13,duration:14,bigDecimal:15,dateTimeZoned:16,json:17,exit:18,cause:19,causeReason:20};function oM(e){let t=2166136261;for(let n=0;n<e.length;n++)t=Math.imul(t^e[n],16777619);return t>>>0}var xW=BigInt("14695981039346656037"),yW=BigInt("1099511628211"),SW=BigInt("18446744073709551615");function PP(e){let t=xW;for(let n=0;n<e.length;n++)t=(t^BigInt(e[n]))*yW&SW;return t}function Fm(e,t){for(let n=0;n<t.length;n++)e.push(t[n])}function ea(e,t){while(t>127)e.push(t&127|128),t=Math.floor(t/128);e.push(t)}function Dm(e,t){e.push(t&255,t>>>8&255,t>>>16&255,t>>>24&255)}function tr(e,t){for(let n=0;n<8;n++)e.push(Number(t>>BigInt(n*8)&fW))}function sM(e,t){let n=Math.min(e.length,t.length);for(let r=0;r<n;r++)if(e[r]!==t[r])return e[r]-t[r];return e.length-t.length}class ds extends Error{issue;constructor(e){super("SchemaBinary failure");this.issue=e}}function D(e,t,n){throw yt(new te({expected:e},t,n))}var Ee=[],W=0;function yt(e){return new ds(W===0?e:new Qe(Ee.slice(0,W),e))}function EW(e){let t=new Uint8Array(aM(e)),n=0;while(e>127)t[n++]=e&127|128,e=Math.floor(e/128);return t[n]=e,t}function aM(e){let t=1;while(e>127)e=Math.floor(e/128),t++;return t}var bW=32;function IW(e,t,n,r){let o=n-t;if(o===0)return"";if(o<=bW){let s=wW(e,t,n);if(s!==void 0)return s}try{return dW.decode(e.subarray(t,n))}catch{D("utf-8",void 0,r)}}function wW(e,t,n){let r="",o=t;for(;o+16<=n;o+=16){let s=e[o],a=e[o+1],i=e[o+2],c=e[o+3],f=e[o+4],u=e[o+5],d=e[o+6],l=e[o+7],m=e[o+8],p=e[o+9],g=e[o+10],h=e[o+11],E=e[o+12],S=e[o+13],k=e[o+14],I=e[o+15];if((s|a|i|c|f|u|d|l|m|p|g|h|E|S|k|I)>127)return;r+=String.fromCharCode(s,a,i,c,f,u,d,l,m,p,g,h,E,S,k,I)}if(o+8<=n){let s=e[o],a=e[o+1],i=e[o+2],c=e[o+3],f=e[o+4],u=e[o+5],d=e[o+6],l=e[o+7];if((s|a|i|c|f|u|d|l)>127)return;r+=String.fromCharCode(s,a,i,c,f,u,d,l),o+=8}switch(n-o){case 0:return r;case 1:{let s=e[o];if(s>127)return;return r+String.fromCharCode(s)}case 2:{let s=e[o],a=e[o+1];if((s|a)>127)return;return r+String.fromCharCode(s,a)}case 3:{let s=e[o],a=e[o+1],i=e[o+2];if((s|a|i)>127)return;return r+String.fromCharCode(s,a,i)}case 4:{let s=e[o],a=e[o+1],i=e[o+2],c=e[o+3];if((s|a|i|c)>127)return;return r+String.fromCharCode(s,a,i,c)}case 5:{let s=e[o],a=e[o+1],i=e[o+2],c=e[o+3],f=e[o+4];if((s|a|i|c|f)>127)return;return r+String.fromCharCode(s,a,i,c,f)}case 6:{let s=e[o],a=e[o+1],i=e[o+2],c=e[o+3],f=e[o+4],u=e[o+5];if((s|a|i|c|f|u)>127)return;return r+String.fromCharCode(s,a,i,c,f,u)}default:{let s=e[o],a=e[o+1],i=e[o+2],c=e[o+3],f=e[o+4],u=e[o+5],d=e[o+6];if((s|a|i|c|f|u|d)>127)return;return r+String.fromCharCode(s,a,i,c,f,u,d)}}}var rE=65536,kW=256,TW=512,AW=16384;function oE(e){let t=new Uint8Array(e);return{buf:t,view:new DataView(t.buffer),offset:0,writing:!1}}var Gu=oE(rE);class hE{buf=new Uint8Array(0);view=new DataView(this.buf.buffer);arena;start=0;limit=0;len=0;reset(){let e=Gu;if(e.writing||e.offset>=e.buf.length)e=Gu=oE(rE);e.writing=!0,this.arena=e,this.buf=e.buf,this.view=e.view,this.start=e.offset,this.limit=e.buf.length-e.offset,this.len=0}ensure(e){if(this.len+e>this.limit){let t=this.arena,n=this.len+e,r=rE;while(r<n)r*=2;let o=oE(r);o.writing=!0,o.buf.set(this.buf.subarray(this.start,this.start+this.len)),t.writing=!1,this.arena=Gu=o,this.buf=o.buf,this.view=o.view,this.start=0,this.limit=o.buf.length}}byte(e){this.ensure(1),this.buf[this.start+this.len++]=e}bytes(e){this.ensure(e.length),this.buf.set(e,this.start+this.len),this.len+=e.length}uvarint(e){this.ensure(10);let t=this.buf,n=this.start+this.len;if(e<128)t[n++]=e;else if(t[n++]=e&127|128,e<16384)t[n++]=e>>>7;else{t[n++]=e>>>7&127|128,e=Math.floor(e/16384);while(e>127)t[n++]=e&127|128,e=Math.floor(e/128);t[n++]=e}this.len=n-this.start}uvarintBig(e){while(e>vP)this.byte(Number(e&vP)|128),e>>=YP;this.byte(Number(e))}zigzag(e){this.uvarintBig(e>=Um?e<<br:(-e<<br)-br)}numberVarint(e){let t=e<0||e===0&&1/e<0,n=t?-e:e;if(n<=lW)this.uvarint(n*2+(t?1:0));else this.uvarintBig(BigInt(n)*iW+(t?br:Um))}f64(e){this.ensure(8),this.view.setFloat64(this.start+this.len,e,!0),this.len+=8}i64(e){this.ensure(8),this.view.setBigInt64(this.start+this.len,e,!0),this.len+=8}u32le(e){this.ensure(4),this.view.setUint32(this.start+this.len,e>>>0,!0),this.len+=4}i32le(e){this.ensure(4),this.view.setInt32(this.start+this.len,e|0,!0),this.len+=4}idAndMark(e){let t=e.length;this.ensure(t+1);let n=this.buf,r=this.start+this.len;for(let s=0;s<t;s++)n[r++]=e[s];let o=r-this.start;return this.len=o+1,o}beginSized(){return this.ensure(1),this.len++}endSized(e){let t=this.len-e-1;if(t<128)this.buf[this.start+e]=t;else this.growSized(e,t)}endSizedRun(e){let t=(this.len-e-1)*2;if(t<128)this.buf[this.start+e]=t;else this.growSized(e,t)}growSized(e,t){let n=aM(t),r=n-1;this.ensure(r);let o=this.start+e;this.buf.copyWithin(o+n,o+1,this.start+this.len),this.len+=r;let s=t,a=o;while(s>127)this.buf[a++]=s&127|128,s=Math.floor(s/128);this.buf[a]=s}string(e){let t=e.length;if(t===0)return;this.ensure(t*3);let n=this.buf,r=this.start+this.len,o=0;for(;o+4<=t;o+=4){let s=e.charCodeAt(o),a=e.charCodeAt(o+1),i=e.charCodeAt(o+2),c=e.charCodeAt(o+3);if((s|a|i|c)>127){this.len+=Bo.encodeInto(e,n.subarray(this.start+this.len)).written;return}n[r++]=s,n[r++]=a,n[r++]=i,n[r++]=c}for(;o<t;o++){let s=e.charCodeAt(o);if(s>127){this.len+=Bo.encodeInto(e,n.subarray(this.start+this.len)).written;return}n[r++]=s}this.len=r-this.start}out(){let e=this.arena,t=new Uint8Array(e.buf.buffer,this.start,this.len);if(e===Gu)e.offset=this.start+this.len;return e.writing=!1,this.arena=void 0,t}abort(){let e=this.arena;if(e===void 0)return;if(e===Gu)e.offset=this.start;e.writing=!1,this.arena=void 0}}function CW(e){let t=En(e);return t._tag==="String"&&t.checks===void 0}function vW(e,t,n){return e.extra.find((r)=>yo({[t]:null},r.parameter,n).length>0)}class $m{entries=new WeakMap;orderLayouts;orderKeys;options;size=0;next=0;replace=!1;constructor(e,t){this.options=e,this.orderLayouts=t===void 0?void 0:Array(t),this.orderKeys=t===void 0?void 0:Array(t)}beginFrame(){this.replace=!0}find(e,t){let n=this.entries.get(e);if(n===void 0)n=new Map,this.entries.set(e,n);if(n.has(t))return n.get(t);let r=vW(e,t,this.options),o=this.orderLayouts;if(o===void 0)return n.set(t,r),r;let s=this.orderKeys;if(this.size<o.length)o[this.size]=e,s[this.size]=t,this.size++,n.set(t,r);else if(this.replace){this.replace=!1;let a=o[this.next];(a===e?n:this.entries.get(a))?.delete(s[this.next]),o[this.next]=e,s[this.next]=t,this.next=(this.next+1)%o.length,n.set(t,r)}return r}clear(){this.entries=new WeakMap,this.orderLayouts?.fill(void 0),this.orderKeys?.fill(void 0),this.size=this.next=0,this.replace=!1}}var Nm=new ArrayBuffer(0),sE=new Uint8Array(Nm),MP=new DataView(Nm);class qm{pos=0;nesting=0;buf=sE;view;viewCache=MP;viewBuffer=Nm;viewOffset=0;viewLength=0;end=0;options=jt;indexSignatures;positional=!1;intern;dict;reset(e,t,n,r,o,s,a){this.nesting=0,this.view=void 0,this.buf=e,this.pos=t,this.end=n,this.options=r,this.indexSignatures=o,this.positional=s,this.intern=void 0,this.dict=a}release(){this.pos=this.end=this.nesting=0,this.buf=sE,this.view=void 0,this.viewCache=MP,this.viewBuffer=Nm,this.viewOffset=this.viewLength=0,this.options=jt,this.indexSignatures=void 0,this.positional=!1,this.intern=void 0,this.dict=void 0}get remaining(){return this.end-this.pos}dataView(){let e=this.buf;if(e.buffer!==this.viewBuffer||e.byteOffset!==this.viewOffset||e.byteLength!==this.viewLength)this.viewBuffer=e.buffer,this.viewOffset=e.byteOffset,this.viewLength=e.byteLength,this.viewCache=new DataView(e.buffer,e.byteOffset,e.byteLength);return this.view=this.viewCache}byte(){if(this.pos>=this.end)D("complete value",void 0,this.options);return this.buf[this.pos++]}take(e){if(this.pos+e>this.end)D("complete value",void 0,this.options);let t=this.buf.subarray(this.pos,this.pos+e);return this.pos+=e,t}takeCopy(e){if(this.pos+e>this.end)D("complete value",void 0,this.options);let t=this.buf.slice(this.pos,this.pos+e);return this.pos+=e,t}enter(e){if(this.pos+e>this.end)D("complete value",void 0,this.options);let t=this.end;return this.end=this.pos+e,t}exit(e){this.pos=this.end,this.end=e}readUtf8(e){if(this.pos+e>this.end)D("complete value",void 0,this.options);let t=this.pos;return this.pos+=e,IW(this.buf,t,t+e,this.options)}uvarint(){let e=this.buf,t=this.end,n=this.pos;if(n>=t)D("complete value",void 0,this.options);let r=e[n++];if(r<128)return this.pos=n,r;let o=r&127;if(n>=t)D("complete value",void 0,this.options);if(r=e[n++],o|=(r&127)<<7,r<128)return this.pos=n,o;if(n>=t)D("complete value",void 0,this.options);if(r=e[n++],o|=(r&127)<<14,r<128)return this.pos=n,o;if(n>=t)D("complete value",void 0,this.options);if(r=e[n++],o|=(r&127)<<21,r<128)return this.pos=n,o;let s=268435456;for(let a=4;a<10;a++){if(n>=t)this.pos=n,D("complete value",void 0,this.options);r=e[n++];let i=(r&127)*s;if(i>Number.MAX_SAFE_INTEGER-o)this.pos=n,D("safe integer length",void 0,this.options);if(o+=i,r<128)return this.pos=n,o;s*=128}this.pos=n,D("uvarint",void 0,this.options)}fieldTag(){let e=this.buf,t=this.end,n=this.pos;if(n>=t)D("complete value",void 0,this.options);let r=e[n++];if(r<128)return this.pos=n,r;let o=r&127;if(n>=t)D("complete value",void 0,this.options);if(r=e[n++],o|=(r&127)<<7,r<128)return this.pos=n,o;if(n>=t)D("complete value",void 0,this.options);if(r=e[n++],o|=(r&127)<<14,r<128)return this.pos=n,o;if(n>=t)D("complete value",void 0,this.options);if(r=e[n++],o|=(r&127)<<21,r<128)return this.pos=n,o;if(n>=t)D("complete value",void 0,this.options);if(r=e[n++],this.pos=n,r>=128)D("uvarint",void 0,this.options);return o+r*268435456}uvarintBig(){let e=Um,t=Um;while(!0){let n=this.byte();if(e|=BigInt(n&127)<<t,(n&128)===0)return e;t+=YP}}numberVarint(){let e=this.buf,t=this.end,n=this.pos,r=0,o=1;for(let i=0;i<XP;i++){if(n>=t)this.pos=n,D("complete value",void 0,this.options);let c=e[n++];if(r+=(c&127)*o,c<128)return this.pos=n,rM(r);o*=128}let s=this.uvarintBig(),a=Number(s>>br);if(!Number.isFinite(a))D("safe integer length",void 0,this.options);return(s&br)===br?-a:a}zigzag(){let e=this.uvarintBig();return(e&br)===br?-(e+br>>br):e>>br}f64(){if(this.pos+8>this.end)D("complete value",void 0,this.options);let e=(this.view??this.dataView()).getFloat64(this.pos,!0);return this.pos+=8,e}i64(){if(this.pos+8>this.end)D("complete value",void 0,this.options);let e=(this.view??this.dataView()).getBigInt64(this.pos,!0);return this.pos+=8,e}u32le(){if(this.pos+4>this.end)D("complete value",void 0,this.options);let e=(this.view??this.dataView()).getUint32(this.pos,!0);return this.pos+=4,e}i32le(){if(this.pos+4>this.end)D("complete value",void 0,this.options);let e=(this.view??this.dataView()).getInt32(this.pos,!0);return this.pos+=4,e}}function UP(e,t){return{_:"literal",leaf:e,values:t,valueSet:t.length>4?new Set(t):void 0}}function td(e,t){let n=e.values;return e.valueSet!==void 0?e.valueSet.has(t):n.length===1?t===n[0]:n.includes(t)}function Hm(e){return e.values.map((t)=>typeof t==="string"?JSON.stringify(t):String(t)).join(" | ")}var _m=0,gE=1,iM=2,cM=3,fM=30,Rm=1<<fM;function jm(e){return e._==="literal"?jm(e.leaf):e._==="int"}function Wm(e){switch(e._){case"literal":return Wm(e.leaf);case"bool":return 1;case"int64":return 8;default:return}}function aE(e){return Wm(e)!==void 0||jm(e)||e._==="null"||e._==="undefined"}function uM(e){return e._==="literal"?uM(e.leaf):e._==="null"||e._==="undefined"}var Vu={"effect/schema/Date":{kind:Ue.int64,exact:!0},"effect/schema/DateTimeUtc":{kind:Ue.int64,exact:!0},"effect/schema/DateTimeZoned":{kind:Ue.dateTimeZoned,exact:!0},"effect/schema/Duration":{kind:Ue.duration,exact:!0},"effect/schema/BigDecimal":{kind:Ue.bigDecimal,exact:!0},"effect/schema/Uint8Array":{kind:Ue.bytes,exact:!0},"effect/schema/Option":{kind:Ue.option,exact:"parameters"},"effect/schema/Result":{kind:Ue.result,exact:"parameters"},"effect/schema/Exit":{kind:Ue.exit,exact:"parameters"},"effect/schema/Cause":{kind:Ue.cause,exact:"parameters"},"effect/schema/CauseReason":{kind:Ue.causeReason,exact:"parameters"}};function Lc(e){let t=e.annotations?.representation;return st(t)&&typeof t.id==="string"?t.id:void 0}var Pm=Wo((e)=>{let t=OW(e),n=e.context;if(t===e||n===void 0)return t;return _i(t,new sr(n.isOptional,n.isMutable,void 0,n.annotations))});function OW(e){switch(e._tag){case"Declaration":{let t=Lc(e);if(t!==void 0&&((t in Vu)||t==="effect/schema/Json"||t==="effect/schema/MutableJson"))return e.recur(Pm);let n=e.annotations?.toCodecJson,r=e.annotations?.toCodec;if(!On(n)&&!On(r))return e;let o=e.typeParameters.map((a)=>H(En(a))),s=(On(n)?n(o):void 0)??(On(r)?r(o):void 0);return s===void 0?e:Pe(e,[vs(s,Pm)])}case"Arrays":case"Objects":case"Union":case"Suspend":return e.recur(Pm);default:return e}}function _W(e){let t=[...e].sort((r,o)=>{let s=typeof r.key==="number",a=typeof o.key==="number";if(s!==a)return s?-1:1;if(s)return r.key-o.key;return sM(Bo.encode(r.key),Bo.encode(o.key))}),n=[];for(let r of t){let o=Bo.encode(String(r.key));n.push(typeof r.key==="number"?0:1),Dm(n,o.length),Fm(n,o);let s=r.literal,a=Bo.encode(lM(s));n.push(dM(s)),Dm(n,a.length),Fm(n,a)}return oM(n)}function dM(e){switch(typeof e){case"string":return 1;case"number":return 2;case"boolean":return 3;case"bigint":return 4;default:return 5}}function lM(e){if(typeof e==="symbol"){let t=globalThis.Symbol.keyFor(e);if(t===void 0)throw Error("Binary layout: unregistered unique symbol (Symbol.keyFor)");return t}return String(e)}function pM(e){switch(e._tag){case"Symbol":return!0;case"Union":return e.types.some(pM);default:return!1}}function mM(e){let t=Lc(e);if(t==="effect/schema/Json"||t==="effect/schema/MutableJson")return!0;return On(e.annotations?.toCodecJson)}function RW(e){let t=e.checks;if(t===void 0)return!1;let n=(r)=>{if(r.annotations?.representation?.id==="effect/schema/isInt")return!0;return r._tag==="FilterGroup"&&r.checks.some(n)};return t.some(n)}function hM(e){while(e._tag==="Suspend")e=e.thunk();return e}function gM(e){return new tn(e.enums.map((t)=>new yn(t[1],{title:t[0]})))}function FP(e){let t=[],n=new Set,r=(o)=>{let s=hM(o);if(n.has(s))return;switch(n.add(s),s._tag){case"Never":return;case"Union":s.types.forEach(r);return;case"Enum":gM(s).types.forEach(r);return;default:t.push(s)}};return e.types.forEach(r),t}function DP(e){switch(typeof e){case"string":return"string";case"number":return"number";case"boolean":return"bool";default:return"bigint"}}function Mm(e){switch(e._tag){case"String":case"TemplateLiteral":case"Symbol":return Ue.string;case"UniqueSymbol":if(globalThis.Symbol.keyFor(e.symbol)===void 0)throw Error("Binary layout: unregistered unique symbol (Symbol.keyFor)");return Ue.string;case"Boolean":return Ue.bool;case"Null":return Ue.null;case"Undefined":case"Void":return Ue.undefined;case"Number":return Ue.number;case"BigInt":return Ue.bigint;case"Literal":switch(typeof e.literal){case"string":return Ue.string;case"number":return Ue.number;case"boolean":return Ue.bool;default:return Ue.bigint}case"Unknown":case"Any":case"ObjectKeyword":return Ue.json;case"Objects":return Ue.struct;case"Arrays":return Ue.array;case"Declaration":{let t=Lc(e);if(t!==void 0&&t in Vu)return Vu[t].kind;if(mM(e))return Ue.json;throw Error(`Binary layout: declaration ${t??"<anonymous>"} has no toCodecJson or toCodec`)}case"Suspend":return Mm(hM(e));default:throw Error("Binary layout: union members are not uniquely identifiable")}}function NP(e){for(let t of e.fields){if(t.optional)continue;if(t.index<32)e.requiredMask|=1<<t.index;else e.requiredWide=!0}}function PW(e){let t=xM(e),n=!t&&MW(e);e=En(e);let r=new Map,o=!1,s=0,a=(p)=>({_:p,slot:p==="string"?s++:0});function i(p){let g=r.get(p);if(g!==void 0)return g;let h=c(p);return r.set(p,h),h}function c(p){switch(p._tag){case"String":case"TemplateLiteral":return a("string");case"Symbol":case"UniqueSymbol":return a("symbol");case"Boolean":return a("bool");case"Null":return a("null");case"Undefined":case"Void":return a("undefined");case"Number":return a(RW(p)?"int":"number");case"BigInt":return a("bigint");case"Literal":return UP(a(DP(p.literal)),[p.literal]);case"Unknown":case"Any":case"ObjectKeyword":return a("json");case"Never":return{_:"never",ast:p};case"Enum":return l(p,FP(gM(p)));case"Suspend":{o=!0;let g=i(p.thunk());return r.set(p,g),g}case"Objects":return f(p);case"Arrays":return u(p);case"Union":return l(p,FP(p));case"Declaration":return d(p)}}function f(p){let g=[],h=[],E=new Map;for(let I of p.propertySignatures){if(typeof I.name==="symbol")throw Error("Binary layout: symbol property names are illegal");let x=String(I.name),w=I.type.context?.annotations,C=w?.[oW],T=typeof C==="number"?C:oM(Bo.encode(x));if(!Number.isInteger(T)||T<0||T>4294967295)throw Error(`Binary layout: illegal field id for ${x}`);let v=E.get(T);if(v===void 0)E.set(T,[x]);else v.push(x);g.push({name:x,id:T,tagBytes:EW(T*Ir+ei),index:0,optional:I.type.context?.isOptional===!0,annotations:w,layout:void 0,wireMask:0,inline:!1}),h.push(I.type)}for(let[I,x]of E)if(I===0||x.length>1)throw Error(`Binary layout field id collision: ${I} (${x.join(", ")})`);let S=[];for(let I of p.indexSignatures){if(pM(I.parameter))throw Error("Binary layout: symbol property names are illegal");S.push({parameter:I.parameter,layout:void 0,wireMask:0})}let k={_:"struct",ast:p,fields:g,byId:new Map,extra:S,extraAll:S.length===1&&CW(S[0].parameter)?S[0]:void 0,names:new Set(g.map((I)=>I.name)),extraShape:void 0,optionalCount:0,requiredMask:0,requiredWide:!1};r.set(p,k);for(let I=0;I<g.length;I++){let x=g[I];if(x.layout=i(h[I]),x.wireMask=uE(x.layout),x.inline=aE(x.layout),x.optional)k.optionalCount++;k.byId.set(x.id,x)}g.sort((I,x)=>I.id-x.id);for(let I=0;I<g.length;I++)g[I].index=I;NP(k);for(let I=0;I<S.length;I++)S[I].layout=i(p.indexSignatures[I].type),S[I].wireMask=uE(S[I].layout);return k}function u(p){let g=p.rest.length>0||p.elements.some((k)=>k.context?.isOptional===!0),h=p.elements.filter((k)=>k.context?.isOptional!==!0).length,E=Math.max(0,p.rest.length-1),S={_:"array",ast:p,elements:[],rest:[],hasCount:g,minCount:h+E,uniform:void 0,uniformInline:!1,uniformPacked:void 0,uniformNumbers:!1,run:void 0};r.set(p,S);for(let k of p.elements)S.elements.push({optional:k.context?.isOptional===!0,layout:i(k)});for(let k of p.rest)S.rest.push(i(k));if(S.elements.length===0&&S.rest.length===1){let k=S.rest[0];S.uniform=k,S.uniformPacked=Wm(k),S.uniformNumbers=k._==="number",S.uniformInline=aE(k)}return S}function d(p){let g=Lc(p);switch(g){case"effect/schema/Date":return{_:"int64",flavor:"date"};case"effect/schema/DateTimeUtc":return{_:"int64",flavor:"utc"};case"effect/schema/DateTimeZoned":return a("dateTimeZoned");case"effect/schema/Duration":return a("duration");case"effect/schema/BigDecimal":return a("bigDecimal");case"effect/schema/Uint8Array":return a("bytes")}let h=p.typeParameters;switch(g){case"effect/schema/Option":{let E={_:"option",value:void 0};return r.set(p,E),E.value=i(h[0]),E}case"effect/schema/Result":{let E={_:"result",success:void 0,failure:void 0};return r.set(p,E),E.success=i(h[0]),E.failure=i(h[1]),E}case"effect/schema/Exit":{let E={_:"cause",error:void 0,defect:void 0},S={_:"exit",value:void 0,cause:E};return r.set(p,S),S.value=i(h[0]),E.error=i(h[1]),E.defect=i(h[2]),S}case"effect/schema/Cause":case"effect/schema/CauseReason":{let E={_:g==="effect/schema/Cause"?"cause":"causeReason",error:void 0,defect:void 0};return r.set(p,E),E.error=i(h[0]),E.defect=i(h[1]),E}}if(g!==void 0&&g in Vu)throw Error(`Binary layout: native declaration ${g} has no layout constructor`);if(mM(p))return a("json");throw Error(`Binary layout: declaration ${g??"<anonymous>"} has no toCodecJson or toCodec`)}function l(p,g){if(g.length===0)return{_:"never",ast:p};let h=[],E=[],S=new Map,k=new Map,I=(v,O)=>{let U=S.get(v);if(U!==void 0&&U._!==O._)throw Error("Binary layout: union members are not uniquely identifiable");S.set(v,O)};for(let v of g){if(v._tag==="Literal"){let O=Mm(v),U=k.get(O);if(U===void 0)k.set(O,[v.literal]);else if(!U.includes(v.literal))U.push(v.literal);continue}if(v._tag==="UniqueSymbol"){Mm(v),I(Ue.string,a("symbol"));continue}if(v._tag==="Objects"||v._tag==="Arrays"){let O=ks(v);if(O!==void 0&&O.length>0){for(let U of O)if(typeof U.key==="symbol")throw Error("Binary layout: symbol property names are illegal");h.push({member:v,sentinels:O});continue}}E.push({member:v,kind:Mm(v)})}for(let[v,O]of k)I(v,UP(a(DP(O[0])),O));if(h.length===0&&E.length===0&&S.size===1)return S.values().next().value;let x=new Set(S.keys());for(let{kind:v}of E){if(x.has(v))throw Error("Binary layout: union members are not uniquely identifiable");x.add(v)}if(h.length===0&&S.size===0&&E.length===1){let v=i(E[0].member);return r.set(p,v),v}let w=new Map,C=[];for(let{sentinels:v}of h){let O=_W(v);if(w.has(O))throw Error(`Binary layout sentinel collision: ${O}`);w.set(O,v),C.push(O)}let T={_:"union",ast:p,variants:[],byTag:new Map,discriminator:void 0,others:[],byKind:new Map,byPos:[]};r.set(p,T);for(let v=0;v<h.length;v++){let{member:O,sentinels:U}=h[v],j=C[v],X=i(O),J,N;if(O._tag==="Objects"){let fe=X,Ge=new Set(U.map((wt)=>String(wt.key))),Ot=fe.fields.filter((wt)=>!Ge.has(wt.name)),et={_:"struct",ast:fe.ast,fields:Ot,byId:new Map(Ot.map((wt)=>[wt.id,wt])),extra:fe.extra,extraAll:fe.extraAll,names:fe.names,extraShape:void 0,optionalCount:Ot.reduce((wt,ti)=>ti.optional?wt+1:wt,0),requiredMask:0,requiredWide:!1};NP(et),J=et,N=!1}else J=X,N=!0;let G={tag:j,sentinels:U,tuple:N,payload:J,position:0};T.variants.push(G),T.byTag.set(j,G)}for(let[v,O]of S)T.others.push({kind:v,layout:O,position:0}),T.byKind.set(v,O);for(let{kind:v,member:O}of E){let U=i(O);T.others.push({kind:v,layout:U,position:0}),T.byKind.set(v,U)}for(let v of[...T.variants].sort((O,U)=>O.tag-U.tag))v.position=T.byPos.length,T.byPos.push({variant:v,layout:v.payload});for(let v of[...T.others].sort((O,U)=>O.kind-U.kind))v.position=T.byPos.length,T.byPos.push({variant:void 0,layout:v.layout});return T.others.sort((v,O)=>BP(v.layout)-BP(O.layout)),T.discriminator=cJ(T.variants),T}return{layout:i(e),recursive:o,exact:t,exitSuccess:n}}function xM(e){let t=new Map,n=(r)=>{if(r.encoding!==void 0||r.checks!==void 0||r.encodingChecks!==void 0)return!1;switch(r._tag){case"String":case"Symbol":case"Boolean":case"Null":case"Undefined":case"Void":case"Number":case"BigInt":case"Literal":return!0;case"Never":return!0;case"Unknown":case"Any":return!0;case"Arrays":return r.elements.every(n)&&r.rest.every(n);case"Objects":return r.propertySignatures.every((o)=>n(o.type))&&r.indexSignatures.every((o)=>o.parameter._tag==="String"&&n(o.parameter)&&n(o.type));case"Union":return(r.options?.mode??"anyOf")==="anyOf"&&r.types.every(n);case"Suspend":{let o=t.get(r);if(o!==void 0)return o;t.set(r,!0);let s=n(r.thunk());return t.set(r,s),s}case"Declaration":{let o=Lc(r),s=o!==void 0?Vu[o]:void 0;if(s===void 0)return!1;return s.exact===!0||r.typeParameters.every(n)}default:return!1}};return n(e)}function MW(e){return e._tag==="Declaration"&&e.encoding===void 0&&e.checks===void 0&&e.encodingChecks===void 0&&Lc(e)==="effect/schema/Exit"&&xM(e.typeParameters[0])}var Nn={backEdge:0,bool:1,null:2,undefined:3,number:4,int:5,string:6,symbol:7,bytes:8,bigint:9,json:10,duration:11,bigDecimal:12,dateTimeZoned:13,date:14,dateTimeUtc:15,never:16,struct:17,array:18,union:19,option:20,result:21,exit:22,cause:23,causeReason:24,literal:25};function UW(e){let t=new Map,n=[],r=Number.MAX_SAFE_INTEGER;function o(a){let i=n.lastIndexOf(a);if(i>=0){if(i<r)r=i;let m=[Nn.backEdge];return ea(m,n.length-i),PP(m)}let c=t.get(a);if(c!==void 0)return c;let f=n.length,u=r;r=Number.MAX_SAFE_INTEGER,n.push(a);let d=PP(s(a));n.pop();let l=r>=f;if(l)t.set(a,d);return r=l?u:Math.min(u,r),d}function s(a){let i=[];switch(a._){case"bool":case"null":case"undefined":case"number":case"int":case"string":case"symbol":case"bytes":case"bigint":case"json":case"duration":case"bigDecimal":case"dateTimeZoned":return i.push(Nn[a._]),i;case"literal":{i.push(Nn.literal),Fm(i,s(a.leaf)),ea(i,a.values.length);let c=a.values.map((f)=>[dM(f),lM(f)]).sort((f,u)=>f[1]<u[1]?-1:f[1]>u[1]?1:f[0]-u[0]);for(let[f,u]of c){i.push(f);let d=Bo.encode(u);ea(i,d.length),Fm(i,d)}return i}case"int64":return i.push(a.flavor==="date"?Nn.date:Nn.dateTimeUtc),i;case"never":return i.push(Nn.never),i;case"struct":{i.push(Nn.struct),ea(i,a.fields.length);for(let c of a.fields)Dm(i,c.id),i.push(c.optional?1:0),tr(i,o(c.layout));ea(i,a.extra.length);for(let c of a.extra)tr(i,o(c.layout));return i}case"array":{i.push(Nn.array),ea(i,a.elements.length);for(let c of a.elements)i.push(c.optional?1:0),tr(i,o(c.layout));ea(i,a.rest.length);for(let c of a.rest)tr(i,o(c));return i}case"union":{i.push(Nn.union),ea(i,a.byPos.length);for(let c of a.byPos){let f=c.variant;if(f===void 0)i.push(0);else i.push(1,f.tuple?1:0),Dm(i,f.tag);tr(i,o(c.layout))}return i}case"option":return i.push(Nn.option),tr(i,o(a.value)),i;case"result":return i.push(Nn.result),tr(i,o(a.success)),tr(i,o(a.failure)),i;case"exit":return i.push(Nn.exit),tr(i,o(a.value)),tr(i,o(a.cause.error)),tr(i,o(a.cause.defect)),i;case"cause":case"causeReason":return i.push(a._==="cause"?Nn.cause:Nn.causeReason),tr(i,o(a.error)),tr(i,o(a.defect)),i}}return o(e)}function FW(e,t){let n=new Uint8Array(8);for(let r=0;r<4;r++)n[r]=e>>>r*8&255,n[r+4]=t>>>r*8&255;return n}var DW={positional:!1,envelope:sW,expectedEnvelope:"version 2 envelope, flags 0",fingerprint:new Uint8Array(8)};function NW(e){let t=UW(e);return{positional:!0,envelope:aW,expectedEnvelope:"version 2 envelope, flags 1",fingerprint:FW(Number(t&OP),Number(t>>uW&OP))}}function BP(e){switch(e._){case"json":return 2;case"struct":return 1;default:return 0}}function iE(e,t){switch(e._){case"literal":return td(e,t);case"bool":return typeof t==="boolean";case"null":return t===null;case"undefined":return t===void 0;case"number":case"int":return typeof t==="number";case"string":return typeof t==="string";case"symbol":return typeof t==="symbol";case"bigint":return typeof t==="bigint";case"bytes":return t instanceof Uint8Array;case"int64":return e.flavor==="date"?t instanceof Date:sa(t)&&t._tag==="Utc";case"dateTimeZoned":return sa(t)&&t._tag==="Zoned";case"duration":return tc(t);case"bigDecimal":return ra(t);case"option":return Xi(t);case"result":return ec(t);case"exit":return Zo(t);case"cause":return rc(t);case"causeReason":return oc(t);case"array":return Array.isArray(t);case"struct":return st(t)&&!Array.isArray(t);case"json":return!0;case"union":case"never":return!1}}function _e(e,t,n){throw yt(new te({expected:e},t,n))}function ln(e,t=new Set){if(!Ku(e))return!1;let n=Array.isArray(e),r=Object.getPrototypeOf(e);if(n||r===Object.prototype||r===null){if(t.has(e))return!0;t.add(e);try{if(n){for(let o=0;o<e.length;o++)if(ln(e[o],t))return!0}else for(let o of Object.keys(e))if(ln(e[o],t))return!0}finally{t.delete(e)}return!1}if(e instanceof Date||e instanceof Uint8Array||sa(e)||tc(e)||ra(e))return!1;if(t.has(e))return!0;t.add(e);try{if(Xi(e))return ve(e)&&ln(e.value,t);if(ec(e))return ln(At(e)?e.success:e.failure,t);if(Zo(e))return ln($e(e)?e.value:e.cause,t);if(rc(e))return e.reasons.some((o)=>ln(o,t));if(oc(e))switch(e._tag){case"Fail":return ln(e.error,t);case"Die":return ln(e.defect,t);case"Interrupt":return!1}if(si(e)){for(let o of e)if(ln(o,t))return!0;return!1}if(wd(e)){for(let[o,s]of e)if(ln(o,t)||ln(s,t))return!0;return!1}if(Ad(e)){for(let o of e)if(ln(o,t))return!0;return!1}if(of(e))return ln(Rr(e),t);for(let o of Object.keys(e))if(ln(e[o],t))return!0}finally{t.delete(e)}return!1}function Bm(e,t,n,r){let o=r.beginSized();Dt(e,t,n,r),r.endSized(o)}function BW(e,t,n){let r=globalThis.Symbol.keyFor(t);if(r===void 0)_e("registered symbol",t,e.options);n.string(r)}function LP(e,t,n,r){let o=n;switch(o._tag){case"Fail":r.byte(0),Dt(e,t.error,o.error,r);return;case"Die":r.byte(1),Dt(e,t.defect,o.defect,r);return;case"Interrupt":if(o.fiberId===void 0)r.byte(2);else r.byte(3),r.f64(o.fiberId)}}function LW(e){for(let t=0;t<e.length;t++)if(e.charCodeAt(t)>127)return!1;return!0}function zP(e,t,n){if(e.layout!==t||e.keys.length!==n.length)return!1;for(let r=0;r<n.length;r++)if(e.keys[r]!==n[r])return!1;return!0}function zW(e,t){if(e.extraAll===void 0||t.length>TW)return!1;let n=0;for(let r=0;r<t.length;r++)if(n+=t[r].length,n>AW)return!1;return!0}function xE(e,t,n){let r=Object.keys(n),o=t.extraShape;if(o!==void 0&&zP(o,t,r))return o.pairs;let s=zW(t,r),a=s?void 0:e.extraShape;if(a!==void 0&&zP(a,t,r))return a.pairs;let{names:i,extraAll:c}=t,f=[],u=!0;for(let l of r){if(i.has(l))continue;let m=c??(e.indexSignatures??=new $m(e.options)).find(t,l);if(m===void 0)continue;if(u&&!LW(l))u=!1;f.push([l,m,void 0])}if(u)f.sort((l,m)=>l[0]<m[0]?-1:l[0]>m[0]?1:0);else{for(let l of f)l[2]=Bo.encode(l[0]);f.sort((l,m)=>sM(l[2],m[2]))}if(s)for(let l of f)l[2]??=Bo.encode(l[0]);let d={layout:t,keys:r,pairs:f};if(s)t.extraShape=d;else e.extraShape=d;return f}function yE(e,t,n,r,o){for(let[s,a,i]of t){let c=i===void 0?s.length:i.length,f=n[s],u=SE(a.layout,f,e.options),d=u%Ir;if(o===void 0)r.uvarint(c*Ir+d);else{if(!o.disabled){let l=SM(o,s);if(l!==void 0){r.uvarint(l*16+d*2+1),Ee[W++]=s,cE(e,a.layout,f,u,r),W--;continue}EM(o,s)}r.uvarint(c*16+d*2)}if(i===void 0)r.string(s);else r.bytes(i);Ee[W++]=s,cE(e,a.layout,f,u,r),W--}}function SE(e,t,n){if(e._==="literal"){if(!td(e,t))_e(Hm(e),t,n);return SE(e.leaf,t,n)}switch(e._){case"bool":if(typeof t!=="boolean")_e("a boolean",t,n);return t?Xu:Yu;case"number":if(typeof t!=="number")_e("a number",t,n);if(pE(t))return Ya;{let r=mE(t);return r===0?Qu:r*Ir+ed}case"int":if(!Number.isSafeInteger(t))_e("an integer",t,n);return Ya;default:return ei}}function cE(e,t,n,r,o){switch(r%Ir){case Yu:case Xu:return;case Ya:o.numberVarint(n);return;case Qu:o.f64(n);return;case ed:{let a=Math.floor(r/Ir);o.numberVarint(Math.round(n*ta[a])),o.uvarint(a);return}default:Bm(e,t,n,o)}}function $W(e,t,n,r){let o=SE(t.layout,n,e.options),s=o%Ir;if(s===ei){let a=r.idAndMark(t.tagBytes);Dt(e,t.layout,n,r),r.endSized(a);return}r.uvarint(t.id*Ir+s),cE(e,t.layout,n,o,r)}function qW(e,t){let n=e.byName;if(n===void 0)return;let r=Object.getOwnPropertyNames(t),o=0;for(let a=0;a<r.length;a++){let i=n.get(r[a]);if(i!==void 0)o|=1<<i}let s=e.struct;if((o&s.requiredMask)!==s.requiredMask){let a=s.fields;for(let i=0;i<a.length;i++){let c=a[i];if(!c.optional&&(o&1<<i)===0)throw Ee[W++]=c.name,yt(new ot(c.annotations))}}return o}function HW(e,t,n,r){let o=n;if(t.extra.length>0){let a=e.intern;e.intern=void 0;let i=xE(e,t,o);if(i.length>0){r.uvarint(0);let c=r.beginSized();yE(e,i,o,r,a),r.endSized(c)}}let s=t.fields;for(let a=0;a<s.length;a++){let i=s[a],c=i.name;if(!Object.hasOwn(o,c)){if(i.optional)continue;throw Ee[W++]=c,yt(new ot(i.annotations))}Ee[W++]=c,$W(e,i,o[c],r),W--}}function jW(e,t,n,r){let o=n,s=e.intern;e.intern=void 0;let a=t.optionalCount+7>>3,i=0;if(a>0){i=r.len;for(let u=0;u<a;u++)r.byte(0)}let c=t.fields,f=0;for(let u=0;u<c.length;u++){let d=c[u],l=d.name,m=Object.hasOwn(o,l);if(d.optional){if(m)r.buf[r.start+i+(f>>3)]|=1<<(f&7);if(f++,!m)continue}else if(!m)throw Ee[W++]=l,yt(new ot(d.annotations));if(Ee[W++]=l,d.inline)Dt(e,d.layout,o[l],r);else Bm(e,d.layout,o[l],r);W--}if(t.extra.length>0){let u=xE(e,t,o);r.uvarint(u.length),yE(e,u,o,r,s)}}function WW(e){switch(e._){case"string":return gE;case"array":return e.uniform?._==="string"?iM:_m;case"struct":return e.extra.length>0?cM:_m;default:return _m}}function JW(e){let t=e.uniform;if(t===void 0){if(e.rest.length!==1)return;t=e.rest[0];for(let n of e.elements)if(n.optional||n.layout!==t)return}return t._==="struct"?t:void 0}function yM(e){let t=e.run;if(t!==void 0)return t;let n=JW(e);if(n===void 0)return e.run=t=null,t;let r=n.fields.map((s)=>WW(s.layout)),o=n.fields.length<=fM;return t={struct:n,intern:r,shapes:o,byName:o&&n.extra.length===0?new Map(n.fields.map((s,a)=>[s.name,a])):void 0},e.run=t,t}var GW=16,KW=64;function $P(e,t){return e[t]??={values:[],refs:void 0,hits:0,disabled:!1}}function SM(e,t){let n=e.refs;if(n!==void 0){let o=n.get(t);if(o!==void 0)e.hits++;return o}let r=e.values;for(let o=0;o<r.length;o++)if(r[o]===t)return e.hits++,o;return}function EM(e,t){let n=e.values;if(e.refs!==void 0){if(e.hits===0&&n.length>=KW){e.disabled=!0,e.refs=void 0;return}e.refs.set(t,n.length)}else if(n.length>=GW){let r=e.refs=new Map;for(let o=0;o<n.length;o++)r.set(n[o],o);r.set(t,n.length)}n.push(t)}var EE=0,VW=1,bE=2,ZW=64,QW=512;function YW(){return{slots:[],marks:[],frame:0}}function bM(e,t){return e[t]??={values:[],refs:new Map,state:EE,stamp:-1}}function IM(e,t){if(e.refs.has(t)){e.state=VW;return}if(e.refs.set(t,e.values.length),e.values.push(t),e.values.length>=ZW)e.state=bE}function wM(e,t){let n=e.values;if(n.length>=QW)return;e.refs.set(t,n.length),n.push(t)}function XW(e,t){if(t.stamp===e.frame)return;t.stamp=e.frame,e.marks.push({slot:t,length:t.values.length,state:t.state})}function eJ(e){e.marks.length=0,e.frame++}function tJ(e){let t=e.marks;for(let n=t.length-1;n>=0;n--){let{length:r,slot:o,state:s}=t[n],a=o.values;for(let i=r;i<a.length;i++)o.refs.delete(a[i]);a.length=r,o.state=s}t.length=0,e.frame++}function nJ(e,t,n,r){let o=bM(e.slots,t.slot),s=o.state;if(s===bE){r.string(n);return}if(XW(e,o),s===EE){r.string(n),IM(o,n);return}let a=o.refs.get(n);if(a!==void 0){r.uvarint(a*2+1);return}r.byte(0),wM(o,n),r.string(n)}function rJ(e,t,n){let r=bM(e,t.slot),o=r.state;if(o===bE)return n.readUtf8(n.end-n.pos);if(o===EE){let i=n.readUtf8(n.end-n.pos);return IM(r,i),i}let s=n.uvarint();if((s&1)===1){let i=(s-1)/2,c=r.values;if(i>=c.length)D("a dictionary reference",s,n.options);return c[i]}if(s!==0)D("a dictionary marker",s,n.options);let a=n.readUtf8(n.end-n.pos);return wM(r,a),a}function kM(e,t,n,r,o){if(!e.disabled){let a=SM(e,r);if(a!==void 0){o.uvarint(a*2+1);return}EM(e,r)}let s=o.beginSized();Dt(t,n,r,o),o.endSizedRun(s)}function oJ(e,t,n,r,o){let s=[],a=[];for(let i=0;i<r;i++){Ee[W++]=i;let c=o.beginSized();sJ(e,t,s,a,n[i],o),o.endSized(c),W--}}function sJ(e,t,n,r,o,s){let a=t.struct,i=o,c=a.fields,f;if(a.extra.length>0){let h=xE(e,a,i);if(h.length>0)f=h}let u=!t.shapes,d=f===void 0?0:Rm,l=qW(t,i);if(l!==void 0)d=l;else for(let h=0;h<c.length;h++){let E=c[h];if(Object.hasOwn(i,E.name)){if(!u)d|=1<<h}else if(!E.optional)throw Ee[W++]=E.name,yt(new ot(E.annotations))}let m=-1;for(let h=0;h<n.length;h++)if(n[h]===d){m=h;break}if(m>=0)s.uvarint(m+1);else if(s.uvarint(0),!u)n.push(d);let p=m<0,g=e.positional&&!u;if(p&&g)s.uvarint(d);if(f!==void 0){if(p&&!g)s.uvarint(0);let h=s.beginSized();yE(e,f,i,s),s.endSizedRun(h)}for(let h=0;h<c.length;h++){let E=c[h];if(u?!Object.hasOwn(i,E.name):(d&1<<h)===0)continue;if(p&&!g)s.uvarint(E.id);Ee[W++]=E.name;let S=t.intern[h];if(S===gE)kM($P(r,h),e,E.layout,i[E.name],s);else{if(S!==_m)e.intern=$P(r,h);let k=s.beginSized();Dt(e,E.layout,i[E.name],s),s.endSizedRun(k),e.intern=void 0}W--}}function TM(e,t,n){let r=e.elements.length;if(t<r)return e.elements[t].layout;let o=Math.max(0,e.rest.length-1),s=Math.max(r,n-o);return t>=s?e.rest[t-s+1]:e.rest[0]}function aJ(e,t,n,r){let o=n.length;if(t.rest.length===0&&o>t.elements.length)throw Ee[W++]=t.elements.length,yt(new ma(t.ast,n[t.elements.length],e.options));if(o<t.minCount)throw Ee[W++]=o,yt(new ot(void 0));if(t.hasCount)r.uvarint(o);if(o>0){let a=yM(t);if(a!==null){oJ(e,a,n,o,r);return}}let s=t.uniform;if(s!==void 0){if(t.uniformNumbers){iJ(e,n,o,r);return}let a=e.intern;if(e.intern=void 0,a!==void 0){for(let c=0;c<o;c++)Ee[W++]=c,kM(a,e,s,n[c],r),W--;return}let i=t.uniformInline;for(let c=0;c<o;c++){if(Ee[W++]=c,i)Dt(e,s,n[c],r);else Bm(e,s,n[c],r);W--}return}for(let a=0;a<o;a++){let i=TM(t,a,o);if(Ee[W++]=a,aE(i))Dt(e,i,n[a],r);else Bm(e,i,n[a],r);W--}}var qP=[];function iJ(e,t,n,r){let o=!0,s=!0;for(let a=0;a<n;a++){let i=t[a];if(typeof i!=="number")Ee[W++]=a,_e("a number",i,e.options);if(pE(i)){if((i<0?-i:i)>nE)s=!1}else{o=!1;let c=mE(i);if(c===0)s=!1;else qP[a]=c}if(!o&&!s)break}if(o){r.byte(tM);for(let a=0;a<n;a++)r.numberVarint(t[a])}else if(s){r.byte(nM);for(let a=0;a<n;a++){let i=t[a],c=Number.isInteger(i)?0:qP[a],f=c===0?i:Math.round(i*ta[c]),u=f<0||f===0&&1/f<0,d=u?-f:f;r.uvarint((d*2+(u?1:0))*16+c)}}else{r.byte(eM);for(let a=0;a<n;a++)r.f64(t[a])}}function cJ(e){if(e.length<2||e.some((t)=>t.tuple))return;for(let t of e[0].sentinels){let n=new Map;for(let r of e){let o=r.sentinels.find((s)=>s.key===t.key);if(o===void 0||n.has(o.literal)||Number.isNaN(o.literal))break;n.set(o.literal,r)}if(n.size===e.length)return{key:t.key,rows:n}}return}function fE(e,t){let n=e.sentinels;for(let r=0;r<n.length;r++){let{key:o,literal:s}=n[r];if(t[o]!==s||!Object.hasOwn(t,o))return!1}return!0}function fJ(e,t){return e.tuple?Array.isArray(t)&&fE(e,t):st(t)&&!Array.isArray(t)&&fE(e,t)}function HP(e,t,n,r){if(e.positional)r.uvarint(t.position);else r.byte(Ue.variant),r.u32le(t.tag);Dt(e,t.payload,n,r)}function uJ(e,t,n,r){let o=t.discriminator;if(o!==void 0){if(st(n)&&!Array.isArray(n)){let s=n,a=o.rows.get(s[o.key]);if(a!==void 0&&fE(a,s)){HP(e,a,n,r);return}}}else for(let s of t.variants)if(fJ(s,n)){HP(e,s,n,r);return}for(let s of t.others)if(iE(s.layout,n)){if(e.positional)r.uvarint(s.position);else r.byte(s.kind);Dt(e,s.layout,n,r);return}throw yt(new Fe(t.ast,n,e.options))}function Dt(e,t,n,r){switch(t._){case"literal":if(!td(t,n))_e(Hm(t),n,e.options);Dt(e,t.leaf,n,r);return;case"bool":if(typeof n!=="boolean")_e("a boolean",n,e.options);r.byte(n===!0?1:0);return;case"null":if(n!==null)_e("null",n,e.options);return;case"undefined":if(n!==void 0)_e("undefined",n,e.options);return;case"number":{if(typeof n!=="number")_e("a number",n,e.options);if(pE(n)){r.numberVarint(n);return}let o=mE(n);if(o>0)r.numberVarint(Math.round(n*ta[o])),r.byte(o);else r.f64(n);return}case"int":{if(!Number.isSafeInteger(n))_e("an integer",n,e.options);r.numberVarint(n);return}case"string":{if(typeof n!=="string")_e("a string",n,e.options);let o=e.dict;if(o===void 0)r.string(n);else nJ(o,t,n,r);return}case"symbol":if(typeof n!=="symbol")_e("a symbol",n,e.options);BW(e,n,r);return;case"bytes":if(!(n instanceof Uint8Array))_e("a Uint8Array",n,e.options);r.bytes(n);return;case"bigint":if(typeof n!=="bigint")_e("a bigint",n,e.options);r.zigzag(n);return;case"int64":{if(!iE(t,n))_e(t.flavor==="date"?"a Date":"a DateTime.Utc",n,e.options);let o=t.flavor==="date"?n.getTime():n.epochMilliseconds;if(Number.isNaN(o))_e("a valid Date",n,e.options);r.i64(BigInt(o));return}case"dateTimeZoned":{if(!iE(t,n))_e("a DateTime.Zoned",n,e.options);let o=n;if(r.i64(BigInt(o.epochMilliseconds)),o.zone._tag==="Offset")r.byte(0),r.i32le(o.zone.offset);else r.byte(1),r.string(o.zone.id);return}case"duration":{if(!tc(n))_e("a Duration",n,e.options);let o=n.value;switch(o._tag){case"Infinity":r.byte(1);return;case"NegativeInfinity":r.byte(2);return;case"Nanos":r.byte(0),r.zigzag(o.nanos);return;case"Millis":r.byte(0),r.zigzag(BigInt(o.millis)*cW);return}}case"bigDecimal":{if(!ra(n))_e("a BigDecimal",n,e.options);let o=Gc(n);r.zigzag(o.value),r.zigzag(BigInt(o.scale));return}case"json":{let o;try{o=JSON.stringify(n)}catch{o=void 0}if(o===void 0){if(ln(n))_e("acyclic value",n,e.options);_e("a JSON-serializable value",n,e.options)}r.string(o);return}case"option":{if(!Xi(n))_e("an Option",n,e.options);let o=n;if(o._tag==="None")r.byte(0);else r.byte(1),Dt(e,t.value,o.value,r);return}case"result":{if(!ec(n))_e("a Result",n,e.options);let o=n;if(o._tag==="Success")r.byte(0),Dt(e,t.success,o.success,r);else r.byte(1),Dt(e,t.failure,o.failure,r);return}case"exit":{if(!Zo(n))_e("an Exit",n,e.options);let o=n;if(o._tag==="Success")r.byte(0),Dt(e,t.value,o.value,r);else r.byte(1),Dt(e,t.cause,o.cause,r);return}case"cause":{if(!rc(n))_e("a Cause",n,e.options);let o=n.reasons;r.uvarint(o.length);for(let s of o){let a=r.beginSized();LP(e,t,s,r),r.endSized(a)}return}case"causeReason":{if(!oc(n))_e("a Cause.Reason",n,e.options);LP(e,t,n,r);return}case"struct":{if(!st(n)||Array.isArray(n))_e("an object",n,e.options);if(e.positional)jW(e,t,n,r);else HW(e,t,n,r);return}case"array":{if(!Array.isArray(n))_e("an array",n,e.options);aJ(e,t,n,r);return}case"union":uJ(e,t,n,r);return;case"never":throw yt(new Fe(t.ast,n,e.options))}}var vm=new hE;function jP(e,t,n,r,o){let s=o.beginSized();if(o.byte(r.envelope),r.positional)o.bytes(r.fingerprint);Dt(e,t,n,o),o.endSized(s)}function AM(e,t,n,r,o,s){let a={options:r,positional:o.positional,indexSignatures:void 0,extraShape:void 0,intern:void 0,dict:s},i=vm??new hE,c=i===vm;if(c)vm=void 0;i.reset();let f=W,u=!1;try{if(n===void 0)W=0,jP(a,e,t,o,i);else for(let l=0;l<n.length;l++)W=0,jP(a,e,n[l],o,i);let d=i.out();return u=!0,d}finally{if(s!==void 0)if(u)eJ(s);else tJ(s);if(i.abort(),W=f,c)vm=i}}function CM(e,t,n,r,o){return AM(e,void 0,t,n,r,o)}function Lm(e,t,n,r,o){return AM(e,t,void 0,n,r,o)}function Jm(e){return Zo(e)&&$e(e)}var vt=globalThis.Symbol.for("~effect/encoding/SchemaBinary/absent");function Kt(e,t){let n=Zu(e,t);if(n!==vt&&t.pos!==t.end)D("no leftover bytes",void 0,t.options);return n}function vM(e,t){let n=t.enter(t.uvarint()),r=Kt(e,t);return t.exit(n),r}function OM(e,t){if(jm(e))return Zu(e,t);let n=Wm(e),r=t.enter(n!==void 0?n:e._==="null"||e._==="undefined"?0:t.uvarint()),o=Kt(e,t);return t.exit(r),o}var dJ=8;function lJ(e,t){let n=e.set;if(n!==void 0){if(n.has(t))return!0;return n.add(t),!1}let r=e.list;if(r.includes(t))return!0;if(r.length>=dJ){let o=e.set=new Set;for(let s=0;s<r.length;s++)o.add(r[s]);o.add(t)}else r.push(t);return!1}function _M(e,t,n,r,o){let s=t.uvarint(),a=o===void 0?Math.floor(s/Ir):Math.floor(s/16),i=o===void 0?s-a*Ir:Math.floor((s-a*16)/2),c=o===void 0?t.readUtf8(a):pJ(o,s,a,t);if(e.names.has(c))D("an extra key distinct from declared fields",c,t.options);if(lJ(r,c))D("unique extra keys",void 0,t.options);let f=e.extraAll??(t.indexSignatures??=new $m(t.options)).find(e,c);if(f===void 0){IE(i,t);return}Ee[W++]=c;let u=MM(f.layout,f.wireMask,i,t);if(W--,u!==vt)q(n,c,u)}function pJ(e,t,n,r){if((t&1)===1){if(n>=e.length)D("a known back-reference",void 0,r.options);return e[n]}let o=r.readUtf8(n);return e.push(o),o}function RM(e){return new Qe([e.name],new ot(e.annotations))}function PM(e,t){throw yt(new tt(e.ast,t))}function XS(e){while((e.byte()&128)!==0);}function IE(e,t){switch(e){case ei:t.take(t.uvarint());return;case Ya:XS(t);return;case Qu:t.take(8);return;case Yu:case Xu:case gW:return;case ed:XS(t),XS(t);return;case hW:t.take(4);return}}function uE(e){if(e._==="literal")return uE(e.leaf);switch(e._){case"bool":return 1<<Yu|1<<Xu;case"number":return 1<<Ya|1<<Qu|1<<ed;case"int":return 1<<Ya;default:return 1<<ei}}function mJ(e,t){switch(e){case Yu:return!1;case Xu:return!0;case Ya:return t.numberVarint();case Qu:return t.f64();case ed:{let n=t.numberVarint(),r=t.uvarint();if(r===0||r>zm)D("a decimal scale in [1, 8]",r,t.options);return n/ta[r]}}return D("matching field wire kind",void 0,t.options)}function MM(e,t,n,r){if((t&1<<n)===0)return IE(n,r),vt;if(n!==ei){let a=mJ(n,r);if(e._==="literal"&&!td(e,a))D(Hm(e),a,r.options);return a}let o=r.enter(r.uvarint()),s=Kt(e,r);return r.exit(o),s}function hJ(e,t){let n;if(e.extra.length>0)n=t.intern,t.intern=void 0;let r={},o=0,s=0,a,i,c,f=!1,u=e.fields,d=0;while(t.pos<t.end){let l=t.fieldTag(),m=Math.floor(l/Ir),p=l-m*Ir;if(m===0){if(f)D("unique field ids",void 0,t.options);if(f=!0,p!==ei)D("extra field map",void 0,t.options);let S=t.enter(t.uvarint());FM(e,t,r,n),t.exit(S);continue}let g;if(d<u.length&&u[d].id===m)g=u[d],d++;else if(g=e.byId.get(m),g!==void 0)d=g.index+1;if(g===void 0){if(c===void 0)c=new Set;else if(c.has(m))D("unique field ids",void 0,t.options);c.add(m),IE(p,t);continue}let h=g.index;if(h<32){let S=1<<h;if((o&S)!==0)D("unique field ids",void 0,t.options);o|=S}else if(a===void 0)a=new Set([h]);else{if(a.has(h))D("unique field ids",void 0,t.options);a.add(h)}Ee[W++]=g.name;let E=MM(g.layout,g.wireMask,p,t);if(W--,E!==vt)if(q(r,g.name,E),h<32)s|=1<<h;else(i??=new Set).add(h)}return UM(e,s,i,t),r}function UM(e,t,n,r){if((t&e.requiredMask)===e.requiredMask&&!e.requiredWide)return;let o=e.fields,s;for(let a=0;a<o.length;a++){let i=o[a],c=i.index,f=c<32?(t&1<<c)!==0:n?.has(c)===!0;if(!i.optional&&!f){if((s??=[]).push(RM(i)),r.options.errors!=="all")break}}if(s!==void 0)PM(e,s)}function gJ(e,t){let n;if(e.extra.length>0)n=t.intern,t.intern=void 0;let r={},o=e.optionalCount+7>>3,s=0;if(o>0){if(t.pos+o>t.end)D("complete value",void 0,t.options);s=t.pos,t.pos+=o}let a=t.buf,i=e.fields,c=0,f;for(let u=0;u<i.length;u++){let d=i[u];if(d.optional){let m=(a[s+(c>>3)]&1<<(c&7))!==0;if(c++,!m)continue}Ee[W++]=d.name;let l=d.inline?OM(d.layout,t):vM(d.layout,t);if(W--,l!==vt)q(r,d.name,l);else if(!d.optional){if((f??=[]).push(RM(d)),t.options.errors!=="all")break}}if(f!==void 0)PM(e,f);if(e.extra.length>0){let u=t.uvarint();if(u>t.remaining)D("complete value",void 0,t.options);if(u>0){let d={list:[],set:void 0};for(let l=0;l<u;l++)_M(e,t,r,d,n)}}return r}function FM(e,t,n,r){let o={list:[],set:void 0};while(t.pos<t.end)_M(e,t,n,o,r)}function xJ(e,t,n){let r=n.uvarint();if((r&1)===1){let a=(r-1)/2;if(a>=e.length)D("a known back-reference",void 0,n.options);return e[a]}if(t._==="string"){if(n.dict!==void 0){let i=n.enter(r/2),c=Kt(t,n);return n.exit(i),e.push(c),c}let a=n.readUtf8(r/2);return e.push(a),a}let o=n.enter(r/2),s=Kt(t,n);return n.exit(o),e.push(s),s}function yJ(e,t,n){let r=Array(t),o=[],s=[];for(let a=0;a<t;a++){Ee[W++]=a;let i=n.enter(n.uvarint());r[a]=EJ(e,o,s,n),n.exit(i),W--}return r}function SJ(e,t){let n=t.uvarint(),r=e.fields,o=n&~Rm;if(n>Rm*2-1||o>>>r.length!==0)D("a known row shape",void 0,t.options);let s=[];if((n&Rm)!==0)s.push(null);for(let a=0;a<r.length;a++)if((o&1<<a)!==0)s.push(r[a]);return s}function EJ(e,t,n,r){let o=e.struct,s={},a=0,i,c=r.uvarint(),f;if(c===0){if(r.positional&&e.shapes)f=SJ(o,r),t.push(f)}else if(f=t[c-1],f===void 0)D("a known row shape",void 0,r.options);if(f!==void 0){for(let u=0;u<f.length;u++){let d=WP(e,n,f[u],s,r);if(d>=0)if(d<32)a|=1<<d;else(i??=new Set).add(d)}if(r.pos!==r.end)D("no leftover bytes",void 0,r.options)}else{let u=e.shapes?[]:void 0,d=0,l,m,p=!1;while(r.pos<r.end){let g=r.uvarint(),h;if(g===0){if(p)D("unique field ids",void 0,r.options);p=!0,h=null}else if(h=o.byId.get(g),h===void 0)if(m===void 0)m=new Set([g]);else if(m.has(g))D("unique field ids",void 0,r.options);else m.add(g);else if(h.index<32){if((d&1<<h.index)!==0)D("unique field ids",void 0,r.options);d|=1<<h.index}else if(l===void 0)l=new Set([h.index]);else{if(l.has(h.index))D("unique field ids",void 0,r.options);l.add(h.index)}u?.push(h);let E=WP(e,n,h,s,r);if(E>=0)if(E<32)a|=1<<E;else(i??=new Set).add(E)}if(u!==void 0)t.push(u)}return UM(o,a,i,r),s}function WP(e,t,n,r,o){let s=o.uvarint();if((s&1)===1){if(n===null||n===void 0)return-1;let f=t[n.index],u=(s-1)/2;if(f===void 0||u>=f.length)D("a known back-reference",void 0,o.options);let d=f[u];if(d===vt)return-1;return q(r,n.name,d),n.index}let a=o.enter(s/2);if(n===null)return FM(e.struct,o,r),o.exit(a),-1;if(n===void 0)return o.exit(a),-1;let i=e.intern[n.index];if(i===iM||i===cM)o.intern=t[n.index]??=[];Ee[W++]=n.name;let c=Kt(n.layout,o);if(W--,o.intern=void 0,o.exit(a),i===gE)(t[n.index]??=[]).push(c);if(c===vt)return-1;return q(r,n.name,c),n.index}function bJ(e,t){let n=e.elements.length,r=e.hasCount?t.uvarint():n;if(e.rest.length===0&&r>n)throw Ee[W++]=n,yt(new ma(e.ast,void 0,t.options));if(r<e.minCount)throw Ee[W++]=r,yt(new ot(void 0));if(e.hasCount){let a=e.rest.length>0&&uM(e.rest[0])?mW:t.remaining+pW;if(r>a)D("array count within allocation limit",r,t.options)}if(r>0){let a=yM(e);if(a!==null)return yJ(a,r,t)}let o=Array(r),s=e.uniform;if(s!==void 0){if(e.uniformNumbers)return IJ(o,r,t);let a=t.intern;if(t.intern=void 0,a!==void 0){for(let f=0;f<r;f++){Ee[W++]=f;let u=xJ(a,s,t);if(u===vt)throw yt(new ot(void 0));W--,o[f]=u}return o}if(jm(s)){for(let f=0;f<r;f++)Ee[W++]=f,o[f]=Zu(s,t),W--;return o}if(s._==="string"){for(let f=0;f<r;f++)Ee[W++]=f,o[f]=t.dict===void 0?t.readUtf8(t.uvarint()):vM(s,t),W--;return o}let{uniformPacked:i,uniformInline:c}=e;for(let f=0;f<r;f++){Ee[W++]=f;let u=t.enter(c?i??0:t.uvarint()),d=Kt(s,t);if(t.exit(u),d===vt)throw yt(new ot(void 0));W--,o[f]=d}return o}for(let a=0;a<r;a++){let i=TM(e,a,r),c=a<n&&e.elements[a].optional;if(!e.hasCount&&t.remaining===0&&!c&&i._!=="null"&&i._!=="undefined")throw Ee[W++]=a,yt(new ot(void 0));Ee[W++]=a;let f=OM(i,t);if(f===vt){if(c)D("known union member",void 0,t.options);throw yt(new ot(void 0))}W--,o[a]=f}if(!e.hasCount&&t.pos<t.end)throw Ee[W++]=n,yt(new ma(e.ast,void 0,t.options));return o}function IJ(e,t,n){let r=n.byte();if(r===eM){if(n.remaining!==t*8)D("f64",void 0,n.options);for(let o=0;o<t;o++)e[o]=n.f64();return e}if(r===nM){for(let o=0;o<t;o++){Ee[W++]=o;let s=n.uvarint(),a=s%16;if(a>zm)D("decimal",void 0,n.options);let i=rM((s-a)/16);e[o]=a===0?i:i/ta[a],W--}return e}if(r!==tM)D("f64",void 0,n.options);for(let o=0;o<t;o++)Ee[W++]=o,e[o]=n.numberVarint(),W--;return e}function wJ(e,t){let n=t.byte();if(n===Ue.variant){let o=t.u32le(),s=e.byTag.get(o);if(s===void 0)return t.take(t.remaining),vt;let a=Kt(s.payload,t);if(a===vt)return vt;if(!s.tuple)for(let i of s.sentinels)q(a,i.key,i.literal);return a}let r=e.byKind.get(n);if(r===void 0)return t.take(t.remaining),vt;return Kt(r,t)}function kJ(e,t){let n=e.byPos[t.uvarint()];if(n===void 0)D("known union member",void 0,t.options);let r=Kt(n.layout,t),o=n.variant;if(o!==void 0&&!o.tuple&&r!==vt)for(let s of o.sentinels)q(r,s.key,s.literal);return r}function JP(e,t){switch(t.byte()){case 0:return Kf(Bc(Kt(e.error,t)));case 1:return Vf(Bc(Kt(e.defect,t)));case 2:if(t.remaining!==0)D("empty",void 0,t.options);return Yf();case 3:{if(t.remaining!==8)D("f64",void 0,t.options);return Yf(t.f64())}default:return t.take(t.remaining),vt}}function Bc(e){if(e===vt)throw yt(new ot(void 0));return e}function Zu(e,t){if(t.nesting>=RP)D(`nesting depth at most ${RP}`,t.nesting+1,t.options);t.nesting++;try{return TJ(e,t)}finally{t.nesting--}}function TJ(e,t){switch(e._){case"literal":{let n=Zu(e.leaf,t);if(!td(e,n))D(Hm(e),n,t.options);return n}case"bool":{if(t.remaining!==1)D("bool",void 0,t.options);let n=t.byte();if(n>1)D("bool",void 0,t.options);return n===1}case"null":if(t.remaining!==0)D("empty",void 0,t.options);return null;case"undefined":if(t.remaining!==0)D("empty",void 0,t.options);return;case"number":{let n=t.remaining;if(n===8)return t.f64();if(n===0||n>XP)D("f64",void 0,t.options);let r=t.numberVarint();if(t.remaining===0)return r;let o=t.byte();if(t.remaining!==0||o===0||o>zm)D("decimal",void 0,t.options);return r/ta[o]}case"int":return t.numberVarint();case"string":{let n=t.dict;return n===void 0?t.readUtf8(t.end-t.pos):rJ(n,e,t)}case"symbol":return globalThis.Symbol.for(t.readUtf8(t.end-t.pos));case"bytes":return t.takeCopy(t.end-t.pos);case"bigint":return t.zigzag();case"int64":{if(t.remaining!==8)D("int64",void 0,t.options);let n=Number(t.i64()),r=new Date(n);if(Number.isNaN(r.getTime()))D(e.flavor==="date"?"a valid Date":"a valid DateTime",n,t.options);return e.flavor==="date"?r:gd(n)}case"dateTimeZoned":{let n=Number(t.i64()),r=t.byte(),o;if(r===0){if(t.remaining!==4)D("time zone",void 0,t.options);o=t.i32le()}else if(r===1)o=t.readUtf8(t.end-t.pos);else return D("time zone",void 0,t.options);try{return xd(n,{timeZone:o})}catch{return D("time zone",void 0,t.options)}}case"duration":switch(t.byte()){case 0:return Zf(t.zigzag());case 1:return nc;case 2:return Yl;default:return D("duration",void 0,t.options)}case"bigDecimal":{let n=t.zigzag(),r=t.zigzag();if(r>tE||-r>tE)D("safe integer length",void 0,t.options);return ud(n,Number(r))}case"json":{let n=t.readUtf8(t.end-t.pos);try{return JSON.parse(n)}catch{return D("json",void 0,t.options)}}case"option":{let n=t.byte();if(n===0){if(t.remaining!==0)D("empty",void 0,t.options);return ne()}if(n!==1)D("bool",void 0,t.options);return oe(Bc(Kt(e.value,t)))}case"result":{let n=t.byte();if(n===0)return ue(Bc(Kt(e.success,t)));if(n!==1)D("bool",void 0,t.options);return ge(Bc(Kt(e.failure,t)))}case"exit":{let n=t.byte();if(n===0)return xn(Bc(Kt(e.value,t)));if(n!==1)D("bool",void 0,t.options);let r=Zu(e.cause,t);return en(r)}case"cause":{let n=t.uvarint(),r=[];for(let o=0;o<n;o++){Ee[W++]=o;let s=t.enter(t.uvarint()),a=JP(e,t);if(t.exit(s),W--,a!==vt)r.push(a)}if(t.pos!==t.end)D("no leftover bytes",void 0,t.options);return Gf(r)}case"causeReason":return JP(e,t);case"struct":return t.positional?gJ(e,t):hJ(e,t);case"array":return bJ(e,t);case"union":return t.positional?kJ(e,t):wJ(e,t);case"never":throw yt(new Fe(e.ast,void 0,t.options))}}function DM(e,t,n){let r=t.byte();if(r!==n.envelope)D(n.expectedEnvelope,r,t.options);if(n.positional){if(t.remaining<8)D("complete value",void 0,t.options);let s=t.buf,a=n.fingerprint,i=t.pos;for(let c=0;c<8;c++)if(s[i+c]!==a[c])D("matching layout fingerprint",void 0,t.options);t.pos=i+8}let o=Kt(e,t);if(o===vt)throw yt(new ot(void 0));return o}var Om=new qm;function AJ(e,t,n,r){let o=Om??new qm,s=o===Om;if(s)Om=void 0;o.reset(t,0,t.length,n,void 0,r.positional,void 0);let a=W;W=0;try{let i=o.uvarint();if(i===0)D("nonzero frame length",void 0,n);let c=o.enter(i),f=DM(e,o,r);if(o.exit(c),o.pos!==t.length)D("no leftover bytes",void 0,n);return f}finally{if(W=a,o.release(),s)Om=o}}function CJ(e,t,n,r=!1){return Et({decode:(o,s)=>{try{let a=AJ(e,o,s,t);if(n!==void 0&&Ku(a)&&(!r||Jm(a)))n.value=a;return b(a)}catch(a){return a instanceof ds?_(a.issue):_n(a)}},encode:(o,s)=>{try{return b(Lm(e,o,s,t))}catch(a){return a instanceof ds?_(a.issue):_n(a)}}})}var vJ=Ln(NW);function Xa(e,t){return t===!0?vJ(e):DW}var OJ=Ln((e)=>{let t=H(Pm(e)),{exact:n,exitSuccess:r,layout:o,recursive:s}=PW(t.ast);return{target:s?UJ(t):t,layout:o,exact:n,exitSuccess:r,recursive:s}});function zc(e){return OJ(e.ast)}function NM(e,t){if(e.value===void 0||t!==e.value)return!1;return e.value=void 0,!0}function BM(e,t,n){let r=H(Ve(e.ast)),o=qe(r),s=(a)=>()=>(i,c,f)=>a(i,f)?Ce:o(i,f);return H(new Cs([r.ast],s(t),{identifier:"binary value"},void 0,void 0,void 0,void 0,s(n)))}function dE(e,t){return t.onExcessProperty!=="error"}function _J(e,t,n){return BM(e,(r)=>NM(t,r),n?dE:RJ)}function RJ(){return!1}function PJ(e,t){return Wt()([e],([n])=>{let r=qe(n);return(o,s,a)=>NM(t,o)||Jm(o)&&a.onExcessProperty!=="error"?b(o):r(o,a)},{identifier:"binary exit value"})}function MJ(e){return BM(e,dE,dE)}function UJ(e){let t=H(Ve(e.ast)),n=new WeakSet,r=Wt()([t],([o])=>(s,a,i)=>{if(Ku(s)&&n.delete(s))return b(s);return ln(s)?_(new Fe(a,s,i)):qe(o)(s,i)},{identifier:"acyclic value"});return Z(r,xe({decode:(o)=>{if(Ku(o))n.add(o);return o},encode:(o)=>o}))(e)}var Gm=uu,DJ,jM=(e)=>(DJ??=new TextDecoder).decode(e);class pn extends Ft()("effect/rpc/RpcSerialization"){}class kE extends Qt("MaxBufferSizeExceeded"){get message(){return`RPC serialization buffer exceeded the maximum size of ${this.maxBufferSize}`}}var NJ=16777216,LM=(e,t)=>t!=="unbounded"&&e>t,WM=pn.of({contentType:"application/json",includesFraming:!1,codecFor:Gm,makeUnsafe:()=>({decode:(e)=>{let t=JSON.parse(typeof e==="string"?e:jM(e));return Array.isArray(t)?t:[t]},encode:(e)=>JSON.stringify(e)})}),Km=(e)=>{let t=e?.maxBufferSize??NJ;return pn.of({contentType:"application/ndjson",includesFraming:!0,codecFor:Gm,makeUnsafe:()=>{let n,r="",o=(s)=>{throw r="",new kE({maxBufferSize:s})};return{decode:(s)=>{r+=typeof s==="string"?s:(n??=new TextDecoder).decode(s,{stream:!0});let a=0,i=r.indexOf(`
|
|
11
|
-
`,a),c=[];while(i!==-1){if(
|
|
12
|
-
`,a)}if(r=r.slice(a),
|
|
10
|
+
`,m);n=n+l.substring(m)}}return Ke(f)?f:null}let a=M(()=>{if(o._tag==="Some")return ee(o.value);return Av(e,{onSuccess:i,onFailure:He,onDone:(c)=>{if(o=oe(c),n.length>0){let f=n;return n="",r=!1,b([f])}return ee(c)}})});function i(c){let f=s(c);return f!==null?b(f):a}return a}));var Wy=y(2,(e,t)=>me((n,r)=>A(ie(e)(n,r),(o)=>ie(t)(o,r)))),Jy=y(2,(e,t)=>me((n,r)=>A(ie(e)(n,r),(o)=>{let s=De(o,(a)=>es(a)?He(a):_n(Ev(a)));return B(ie(t)(s,r),(a)=>Ov(a,(i)=>My(i)?He(i.value):_n(i)))}))),no=(e)=>me((t,n)=>{let r;return b(M(()=>{if(r)return r;return e.pipe(In(n),A((o)=>ie(o)(t,n)),A((o)=>r=o))}))}),TO=(e)=>eo((t,n,r)=>B(In(ie(e)(t,n),r),In(r)));var AO=y(2,(e,t)=>me(re(function*(n,r){let o=yield*ie(e)(n,r),s=yield*hr({capacity:t.capacity==="unbounded"?void 0:t.capacity,strategy:t.capacity==="unbounded"?void 0:t.strategy});return yield*Me(r,Vr(s)),yield*o.pipe(A((a)=>bn(s,a)),Ze({disableYield:!0}),Vn((a)=>rt(s,a)),Ne(r)),Zr(s)}))),CO=y(2,(e,t)=>me(re(function*(n,r){let o=yield*ie(e)(n,r),s=yield*hr({capacity:t.capacity==="unbounded"?void 0:t.capacity,strategy:t.capacity==="unbounded"?void 0:t.strategy});return yield*Me(r,Vr(s)),yield*o.pipe(A((a)=>ts(s,a)),Ze({disableYield:!0}),Vn((a)=>rt(s,a)),Ne(r)),xc(s)}))),vO=y(2,(e,t)=>Gp(e,Ut(b(A(t,ee))),{haltStrategy:"either"})),OO=y(2,(e,t)=>eo(re(function*(n,r,o){let s=yield*ie(e)(n,r),a=yield*Ne(t,o,{startImmediately:!0});return M(()=>{let i=a.pollUnsafe();return i===void 0?s:bv(i,{onFailure:He,onSuccess:ee})})}))),_O=y(2,(e,t)=>vu(e,(n)=>bo(n)?t(n.cause):R)),vu=y(2,(e,t)=>eo((n,r,o)=>dr(o,t).pipe(gt(ie(e)(n,r))))),RO=y(2,(e,t)=>no(nt(t,e))),Gy=y(2,(e,t)=>Xr(e,(n)=>L(()=>{let r=!0,o=xt(n,(s)=>(r=!1,t(s)));return M(()=>r?o:n)}))),PO=y(2,(e,t)=>Xr(e,(n)=>b(lt(n,(r)=>A(t,()=>ee(r)))))),MO=y(2,(e,t)=>vu(e,(n)=>t)),$a=(e,t,n)=>M(()=>{let r=ko(),o=ie(e)(ee(),r);return lt(A(o,t),n?n:b).pipe(yr((s)=>Te(r,s)))});var Kp=y(2,(e,t)=>me((n,r)=>B(Jt(ie(e)(n,r),t),Jt(t)))),Vp=y(3,(e,t,n)=>me((r,o)=>B(zs(ie(e)(r,o),t,n),zs(t,n)))),Zp=y(3,(e,t,n)=>me((r,o)=>A(n,(s)=>ie(Vp(e,t,s))(r,o)))),UO=y((e)=>Gt(e[0]),(e,t,n)=>pv(t)?Kp(e,t):me((r,o)=>A(n?.local?kv(t,wv(),o):Tv(t,o),(s)=>B(Jt(ie(e)(r,o),s),Jt(s))))),FO=y(2,(e,t)=>me((n,r)=>Gr((o)=>{let s=t(o);return ie(Kp(e,s))(n,r)})));var Ky=function(){let e=Gt(arguments[0]),t=e?arguments[1]:arguments[0],n=Dp(e?arguments[2]:arguments[1]);if(e){let r=arguments[0];return lv(r,t,n)}return(r)=>lv(r,t,n)},lv=(e,t,n)=>E$(Pv(t,n),(r)=>Vp(e,gv,r),(r,o)=>dt((s)=>{let a=s.getRef(yv),i=s.getRef(Iv);return xv(r,o,a,i)}));var DO=(e)=>$a(e,(t)=>Ze(t,{disableYield:!0})),qa=y(2,(e,t)=>$a(e,(n)=>Ze(A(n,t),{disableYield:!0}))),NO=y(2,(e,t)=>$a(e,(n)=>n.pipe(A(t),A((r)=>r?R:ee()),Ze({disableYield:!0})))),Vy=(e)=>B(Ha(e,()=>({bytes:0,arrays:[]}),(t,n)=>{for(let r=0;r<n.length;r++)t.bytes+=n[r].length,t.arrays.push(n[r]);return t}),({arrays:t,bytes:n})=>{let r=new Uint8Array(n),o=0;for(let s=0;s<t.length;s++){let a=t[s];r.set(a,o),o+=a.length}return r});var BO=(e)=>M(()=>{let t=ne();return $a(e,(n)=>n.pipe(Dy,A((r)=>(t=r,ee()))),()=>b(t))}),LO=(e)=>M(()=>{let t=Symbol(),n=t;return $a(e,(r)=>Ze(A(r,(o)=>(n=o,R)),{disableYield:!0}),()=>n===t?Si:Cv(n))}),Ha=y(3,(e,t,n)=>M(()=>{let r=t();return $a(e,(o)=>gr({while:Ds,body:()=>o,step:(s)=>{r=n(r,s)}}),()=>b(r))})),zO=y(3,(e,t,n)=>M(()=>{let r=t();return $a(e,(o)=>gr({while:Ds,body:pr(o.pipe(A((s)=>n(r,s)),B((s)=>{r=s}))),step:Mn}),()=>b(r))})),Zy=re(function*(e){let t=La(1),n=yield*Qn(),r=Lt(n,ut);return(yield*ie(e)(ee(),r)).pipe(Jt(n),t.withPermits(1))},De((e)=>b(He(e)))),Po=(e,t)=>ie(e)(ee(),t);var Qy=y((e)=>Gt(e[0]),(e,t)=>Xn((n)=>qa(e,(r)=>ts(t,r)).pipe(n,or,A((r)=>{if($e(r))Mp(t);else Ls(t,r.cause);return R}))));var $O=y((e)=>Gt(e[0]),re(function*(e,t){let n=yield*Yn,r=yield*hr({capacity:typeof t.capacity==="number"?t.capacity:void 0,strategy:typeof t.capacity==="number"?t.strategy:void 0});return yield*Me(n,Vr(r)),yield*Ne(Qy(e,r),n),r}));var qO=(e)=>xr(e.capacity==="unbounded"?Ip(e):e.strategy==="dropping"?Ep(e):e.strategy==="sliding"?bp(e):Sp(e),mu),HO=y(2,re(function*(e,t){let n=yield*qO(t);return yield*Ro(Yy(e,n,{shutdownOnEnd:t.shutdownOnEnd!==!1})),n})),Yy=y((e)=>Gt(e[0]),(e,t,n)=>qa(e,(r)=>UC(t,r)).pipe(n?.shutdownOnEnd===!0?_o(mu(t)):Q)),jO=y(2,re(function*(e,t){let n=yield*qO(t);return yield*qa(e,(r)=>kp(n,r)).pipe(yr((r)=>wp(n,r)),Ro),n}));var A$="~effect/Stream",C$={_R:Q,_E:Q,_A:Q},WO=function(e){this.channel=e};WO.prototype={[A$]:C$,pipe(){return de(this,arguments)}};var JO=(e)=>new WO(e);var GO="~effect/RcMap",_$=(e)=>({[GO]:GO,lookup:e.lookup,context:e.context,scope:e.scope,idleTimeToLive:e.idleTimeToLive,capacity:e.capacity,state:{_tag:"Open",map:Pu()},pipe(){return de(this,arguments)}}),XO=(e)=>dt((t)=>{let n=t.context,r=Lt(n,ut),o=_$({lookup:e.lookup,context:n,scope:r,idleTimeToLive:typeof e.idleTimeToLive==="function"?ja(e.idleTimeToLive,Zt):pr(Zt(e.idleTimeToLive??KO)),capacity:Math.max(e.capacity??Number.POSITIVE_INFINITY,0)});return nt(dr(r,()=>{if(o.state._tag==="Closed")return R;let s=o.state.map;return o.state={_tag:"Closed"},Jr(s,([,a])=>or(Ou(a))).pipe(xt(()=>L(()=>{Qp(s)})))}),o)}),eS=y(2,(e,t)=>Xn((n)=>{if(e.state._tag==="Closed")return Kn;let r=e.state,o=Fo(),s=Mo(r.map,t),a;if(s._tag==="Some")a=s.value,a.refCount++;else if(Number.isFinite(e.capacity)&&YO(e.state.map)>=e.capacity)return _(new VO(`RcMap attempted to exceed capacity of ${e.capacity}`));else{a={deferred:pu(),scope:ko(),idleTimeToLive:e.idleTimeToLive(t),finalizer:void 0,fiber:void 0,expiresAt:0,refCount:1},a.finalizer=P$(e,t,a),Mu(r.map,t,a);let c=new Map(e.context.mapUnsafe);o.context.mapUnsafe.forEach((u,d)=>{c.set(d,u)}),c.set(ut.key,a.scope);let f=Ac(c);M(()=>e.lookup(t)).pipe(Fn(f),js(a.scope)).addObserver((u)=>{if(ZO(u))R$(e,t,a,f);Da(a.deferred,u)})}let i=Cc(o.context,ut);return Me(i,a.finalizer).pipe(gt(n(QO(a.deferred))))}));var R$=(e,t,n,r)=>{if(e.state._tag==="Closed")return;let o=Mo(e.state.map,t);if(o._tag==="None"||o.value!==n)return;if(Tc(e.state.map,t),n.refCount>0)return;Ou(n).pipe(Fn(r),js(e.scope))},Ou=(e)=>e.fiber?fn(e.fiber).pipe(gt(Te(e.scope,Ye))):Te(e.scope,Ye),P$=(e,t,n)=>dt((r)=>{if(n.refCount--,n.refCount>0)return R;else if(e.state._tag==="Closed")return Ou(n);let o=Mo(e.state.map,t);if(o._tag==="None"||o.value!==n)return Ou(n);else if(_u(n.idleTimeToLive))return Tc(e.state.map,t),Ou(n);else if(!xs(n.idleTimeToLive))return R;let s=r.getRef(Uo);if(n.expiresAt=s.currentTimeMillisUnsafe()+Wn(n.idleTimeToLive),n.fiber)return R;return n.fiber=Xn(function a(i){let c=s.currentTimeMillisUnsafe(),f=n.expiresAt-c;if(f<=0){if(e.state._tag==="Closed"||n.refCount>0)return R;let u=Mo(e.state.map,t);if(u._tag==="None"||u.value!==n)return R;return Tc(e.state.map,t),Te(n.scope,Ye)}return A(i(s.sleep(Qf(f))),()=>a(i))}).pipe(_o(L(()=>{n.fiber=void 0})),Fn(r.context),js(e.scope)),R});var tS=y(2,(e,t)=>Ru((n)=>{if(e.state._tag==="Closed")return R;let r=Mo(e.state.map,t);if(r._tag==="None"||_u(r.value.idleTimeToLive))return R;let o=r.value;return o.expiresAt=n.currentTimeMillisUnsafe()+Wn(o.idleTimeToLive),R}));var U$="~effect/RcRef",Uu={_tag:"Empty"},F$={_tag:"Closed"},D$={_A:Q,_E:Q};class t_{[U$]=D$;pipe(){return de(this,arguments)}state=Uu;acquire;context;scope;idleTimeToLive;constructor(e,t,n,r){this.acquire=e,this.context=t,this.scope=n,this.idleTimeToLive=r}}var n_=(e)=>dt((t)=>{let n=t.context,r=Lt(n,ut),o=new t_(e.acquire,n,r,e.idleTimeToLive!==void 0?Zt(e.idleTimeToLive):void 0);return nt(dr(r,()=>{let s=o.state;if(o.state=F$,s._tag==="Acquired")return Te(s.scope,Ye);if(s._tag==="Acquiring")return fn(s.fiber);return R}),o)}),N$=(e,t)=>{switch(e.state._tag){case"Closed":return Kn;case"Acquired":{let n=e.state;return n.refCount++,n.fiber?nt(fn(n.fiber),n):b(n)}case"Acquiring":{let n=e.state;return n.awaiters++,e_(e,n,t)}case"Empty":{let n={_tag:"Acquiring",fiber:void 0,awaiters:1,acquired:void 0};e.state=n;let r=ko(),o=Jt(e.acquire,Un(e.context,ut,r)).pipe(A((s)=>{if(e.state!==n)return Kn;let a={_tag:"Acquired",value:s,scope:r,fiber:void 0,refCount:n.awaiters,invalidated:!1};return e.state=a,n.acquired=a,b(a)}),yr((s)=>{if($e(s))return R;if(e.state===n)e.state=Uu;return Te(r,s)}));return n.fiber=Fn(Fo().context)(o),e_(e,n,t)}}},e_=(e,t,n)=>yr(n($s(t.fiber)),(r)=>{let o=t.acquired;if(o!==void 0)return bo(r)?o_(e,o):R;if(--t.awaiters>0||e.state!==t)return R;return e.state=Uu,fn(t.fiber)}),r_=(e)=>{let t=e;return Xn((n)=>A(Yn,(r)=>A(N$(t,n),(o)=>nt(dr(r,()=>o_(t,o)),o.value))))},o_=(e,t)=>{if(t.refCount--,t.refCount>0)return R;let n=e.idleTimeToLive;if(n===void 0||t.invalidated){if(e.state===t)e.state=Uu;return Te(t.scope,Ye)}else if(!xs(n))return R;return t.fiber=Xn((r)=>A(r(Ws(n)),()=>{if(e.state===t&&t.refCount===0)return e.state=Uu,Te(t.scope,Ye);return R})).pipe(_o(L(()=>{t.fiber=void 0})),Fn(e.context),js(e.scope)),R};var s_=n_,a_=r_;var $$="~effect/Sink";var q$={_A:Q,_In:Q,_L:Q,_E:Q,_R:Q},H$={[$$]:q$,pipe(){return de(this,arguments)}};var j$=(e)=>{let t=Object.create(H$);return t.transform=e,t},i_=(e)=>me((t,n)=>b(A(e.transform(t,n),ee)));var c_=(e)=>{let t=ht(e);return j$((n)=>{let r=[];if(t===0)return b([r]);let o=void 0;return n.pipe(A((s)=>{if(r.length+s.length<=t){if(r.push(...s),r.length===t)return ee();return R}for(let a=0;a<s.length;a++)if(r.push(s[a]),r.length===t){if(a+1<s.length)o=s.slice(a+1);return ee()}return R}),Ze({disableYield:!0}),lt(()=>b([r,o])))})};var C_="~effect/Stream",le=(e)=>V(e,C_),v_=Au,P=JO,tm=(e)=>P(qp(B(e,pe))),J$=(e)=>tm(E_(e)),G$=(e)=>tm(_c(e)),O_=(e)=>oo(b(A(e,()=>ee()))),__=(e)=>oo(b(B(e,pe))),K$=(e,t)=>oo(je(function*(){let n=yield*Sc(t),r=yield*zs(e,Qr,Qr.defaultValue()),o=!0,s=M(()=>n(r)).pipe(A((a)=>zs(e,Qr,a)),B((a)=>(r=a,pe(a))));return M(()=>{if(o)return o=!1,b(pe(r));return s})})),V$=(e)=>oo(L(()=>{let t=!0,n=b(pe(void 0)),r=Ks(n,e);return M(()=>{if(t)return t=!1,n;return r})})),oo=(e)=>P(Ut(e)),It=(e,t)=>P(me((n,r)=>A(Po(e.channel,r),(o)=>t(o,r)))),oS=(e,t)=>P(eo((n,r,o)=>A(Po(e.channel,r),(s)=>t(s,r,o)))),Sr=(e)=>e.channel,R_=(e,t)=>P(Uv(e,t)),os=P(yc),Wa=(e)=>P($p(pe(e))),Z$=(...e)=>nm(e),Q$=(e)=>P(Nv(()=>pe(e()))),dn=(e)=>P(zp(()=>e().channel)),Js=(e)=>P(Oo(e)),Y$=(e)=>P(Lv(e)),P_=(e)=>P(Cu(e)),X$=(e)=>P(zy(e)),eq=(e)=>P(zv(e)),tq=(e,t)=>P(Ly(()=>e,t)),Ga=(e,t)=>Array.isArray(e)&&t?.chunkSize===void 0?nm(e):P(Dv(e,t?.chunkSize)),nq=(e)=>ro(B(e,Ga)),rq=(e)=>Rc(__(e),Ga),nm=(e)=>Ke(e)?P($p(e)):os,oq=(e)=>ro(B(e,nm)),sq=(...e)=>P(By(md(e,Ke))),Gs=(e)=>P(qv(e)),aq=(e)=>P(Hv(e)),M_=(e)=>P(jv(e)),sS=(e)=>P(Wv(e)),iq=(e,t)=>P(Jv(e,t)),cq=(e)=>oo(B(Iu(e),(t)=>lt(B(t(void 0),pe),()=>ee()))),fq=(e)=>P(qy(e)),uq=(e,t,n)=>R_((r)=>{let o=typeof n==="object"&&n.once;function s(a){if(Rp(r,a),o)Mp(r)}return xr(L(()=>e.addEventListener(t,s,n)),()=>L(()=>e.removeEventListener(t,s,n)))},{bufferSize:typeof n==="object"?n.bufferSize:void 0}),U_=(e,t)=>oo(L(()=>{let n=e;return A(M(()=>t(n)),(r)=>{if(r===void 0)return ee();return n=r[1],b(pe(r[0]))})})),dq=(e,t)=>oo(L(()=>{let n=e,r=!1;return M(function o(){if(r)return ee();return A(t(n),([s,a])=>{if(Tn(a))r=!0;else n=a.value;if(!Ke(s))return o();return b(s)})})})),lq=(e,t)=>U_(e,(n)=>b([n,t(n)])),pq=(e,t,n=Au)=>e>t?os:oo(L(()=>{let r=qs(n),o=e,s=!1;return M(()=>{if(s)return ee();let a=t-o+1;if(a>r){let c=nS(o,o+r-1);return o+=r,b(c)}let i=nS(o,o+a-1);return s=!0,b(i)})})),mq=P(Bv),ro=(e)=>P(no(B(e,Sr))),hq=(e)=>P(TO(e.channel)),Dn=y(2,(e,t)=>dn(()=>{let n=0;return P(to(e.channel,hn((r)=>t(r,n++))))})),gq=y(2,(e,t)=>Dn(e,()=>t)),xq=y(2,(e,t)=>e.pipe(Dn(t.onElement),W_(t.onError))),F_=y(2,(e,t)=>P(to(e.channel,t))),Nu=y((e)=>le(e[0]),(e,t,n)=>e.channel.pipe(un,Hp(t,n),to(pe),P)),yq=y((e)=>le(e[0]),(e,t)=>Nu(e,Q,t)),Sq=y(2,(e,t)=>P(Hp(e.channel,t))),Eq=(e)=>e.pipe(Dn(ue),Bu((t)=>Wa(ge(t)))),D_=y((e)=>le(e[0]),(e,t,n)=>Nu(e,(r)=>nt(t(r),r),n)),bq=y(2,(e,t)=>e.pipe(uS(t.onError),D_(t.onElement,{concurrency:t.concurrency}))),Iq=y(2,(e,t)=>oS(e,re(function*(n,r,o){let s=ct(),a=ct(),i=void 0,c=void 0,f=!1,u=!1,d=s.whenOpen(M(()=>{if(i){let m=i;if(i=void 0,!u)s.closeUnsafe();return nt(a.open,m)}return ee()}));yield*M(()=>t.transform(d,o)).pipe((m)=>I_(m,(p)=>{if(f=!0,bo(p))c=p.cause;return a.open},!0),Ne(o));let l=n.pipe(A((m)=>(i=m,a.closeUnsafe(),s.openUnsafe(),nt(a.await,m))),lt(()=>(u=!0,a.closeUnsafe(),s.openUnsafe(),A(a.await,()=>ee()))));return M(()=>{if(c)return He(c);else if(f)return n;return l})}))),Rc=y((e)=>le(e[0]),(e,t,n)=>e.channel.pipe(un,Hy((r)=>t(r).channel,n),P)),wq=y((e)=>le(e[0]),(e,t,n)=>e.channel.pipe(un,IO((r)=>t(r).channel,n),P)),N_=y((e)=>le(e[0]),(e,t)=>Rc(e,Q,t)),kq=(e)=>P(un(e.channel)),Tq=(e)=>P(Xv(e.channel)),Aq=y(2,(e,t)=>rm(e,am(t))),Cq=y(2,(e,t)=>P(eO(e.channel,t))),vq=y(2,(e,t)=>e.channel.pipe(un,rO(t),to(pe),P)),Oq=y(2,(e,t)=>B_(e,{duration:t,orElse:()=>os})),B_=y(2,(e,t)=>{let n=Zt(t.duration);if(!xs(n))return e;if(_u(n))return dn(t.orElse);let r=Symbol();return q_(dn(()=>{let s=Fo().getRef(Uo),a=Wn(n),i=void 0,c=ct(!1);return aS(It(e,(f,u)=>M(()=>(i=s.currentTimeMillisUnsafe()+a,c.openUnsafe(),f)).pipe(B((d)=>(c.closeUnsafe(),i=void 0,d)),b)),O_(je(function*(){while(!0){if(yield*c.await,i===void 0)continue;if(yield*Ws(i-s.currentTimeMillisUnsafe()),i===void 0)continue;if(i-s.currentTimeMillisUnsafe()>0)continue;return yield*_n(r)}})),{haltStrategy:"left"})}),(o)=>{if(o.reasons.find((a)=>a._tag==="Die"&&a.defect===r))return t.orElse();return P_(o)})}),_q=y(2,(e,t)=>P(me((n,r)=>B(ie(un(e.channel))(n,r),(o)=>{let s=void 0,a=je(function*(){let i=yield*o,c=pe(i);return s=(yield*Iu(t))(i).pipe(nt(c),lt((u)=>(s=void 0,a))),c});return M(()=>s??a)})))),Rq=(e)=>P(nO(e.channel)),Pq=(e)=>Rc(e,Ga),Mq=(e)=>e.channel.pipe(un,Yv,P),vc=y(2,(e,t)=>{let n=P(Qv(Fv(()=>Uq(e,t))));return L_.set(n,[e,t]),n}),L_=new WeakMap;function*Uq(e,t){let n=[t,e];while(n.length>0){let r=n.pop(),o=L_.get(r);if(o===void 0)yield r.channel;else n.push(o[1],o[0])}}var Fq=y(2,(e,t)=>vc(Ga(t),e)),aS=y((e)=>le(e[0])&&le(e[1]),(e,t,n)=>P(Gp(Sr(e),Sr(t),n))),rm=y(2,(e,t)=>e.channel.pipe(wO(t),P)),Dq=y(2,(e,t)=>aS(Dn(e,ue),Dn(t,ge))),Nq=y(2,(e,t)=>rm(e,am(t))),Bq=y(2,(e,t)=>rm(t,am(e))),Lq=y(2,(e,t)=>N_(Ga(e),t)),zq=y(2,(e,t)=>z_(e,t,(n,r)=>[n,r])),z_=y(3,(e,t,n)=>Rc(e,(r)=>Dn(t,(o)=>n(r,o)))),iS=y(3,(e,t,n)=>om(e,t,$q(n))),$q=(e)=>(t,n)=>{let r=Math.min(t.length,n.length),o=[];for(let s=0;s<r;s++)o.push(e(t[s],n[s]));return[o,t.slice(r),n.slice(r)]},om=y(3,(e,t,n)=>P(eo(re(function*(r,o){let s=yield*Po(e.channel,o),a=yield*Po(t.channel,o),i=je(function*(){let u=yield*Ne(s,o),d=yield*Ne(a,o);return yield*A_([u,d])}),c={_tag:"PullBoth"};return je(function*(){let[u,d]=c._tag==="PullBoth"?yield*i:c._tag==="PullLeft"?[yield*s,c.rightArray]:[c.leftArray,yield*a],l=n(u,d);if(Ke(l[1]))c={_tag:"PullRight",leftArray:l[1]};else if(Ke(l[2]))c={_tag:"PullLeft",rightArray:l[2]};else c={_tag:"PullBoth"};return l[0]})})))),qq=y(2,(e,t)=>iS(e,t,(n,r)=>[n,r])),Hq=y(2,(e,t)=>om(e,t,(n,r)=>{let o=Math.min(n.length,r.length),s=n.slice(0,o),a=n.slice(o),i=r.slice(o);return[s,a,i]})),jq=y(2,(e,t)=>om(e,t,(n,r)=>{let o=Math.min(n.length,r.length),s=r.slice(0,o),a=n.slice(o),i=r.slice(o);return[s,a,i]})),Wq=y(2,(e,t)=>iS(e,t,(n,r)=>[...n,r])),Jq=(e)=>Dn(e,(t,n)=>[t,n]),Gq=(e)=>Ka(e,ne,(t,n)=>{let r=0;if(t._tag==="None")r=1,t=oe(n[0]);let o=Xt();for(;r<n.length;r++){let s=t.value;t=oe(n[r]),o.push([s,t])}return[t,o]},{onHalt(t){return t._tag==="Some"?[[t.value,ne()]]:[]}}),Kq=(e)=>Ka(e,ne,(t,n)=>{let r=Xt();for(let o=0;o<n.length;o++){let s=n[o];r.push([t,s]),t=oe(n[o])}return[t,r]}),Vq=(e)=>Ka(e,()=>({prev:ne(),current:ne()}),(t,n)=>{let r=0,o;if(t.current._tag==="None")r=1,o=n[0],t.current=oe(o);else o=t.current.value;let s=Xt();for(;r<n.length;r++){let a=n[r];t.current=oe(a),s.push([t.prev,o,t.current]),t.prev=oe(o),o=a}return[t,s]},{onHalt(t){return t.current._tag==="Some"?[[t.prev,t.current.value,ne()]]:[]}}),cS=(...e)=>P(zp(()=>{let t=[],n=new Set,r=ct();return Jp(By(e.map((o,s)=>o.channel.pipe(un,Hp((a)=>{if(t[s]=a,!n.has(s)){if(n.add(s),n.size<e.length)return r.await;return nt(r.open,pe(t.slice()))}return b(pe(t.slice()))}),oO(ws)))),{concurrency:"unbounded",bufferSize:0})})),Zq=y(2,(e,t)=>cS(e,t)),Qq=y(3,(e,t,n)=>Dn(cS(e,t),([r,o])=>n(r,o))),$_=(...e)=>P(me((t,n)=>L(()=>{let r,o=S_(e.map((s)=>{let a=cn(n);return Po(s.channel,a).pipe(A((i)=>y_(b(i),i)),yr((i)=>{if(i._tag==="Success"){if(r)return Te(a,i);return r=i.value[0],R}return Te(a,i)}),B(([,i])=>i))}));return M(()=>r??o)}))),Yq=y(2,(e,t)=>$_(e,t)),Xq=y(2,(e,t)=>P(sO(Sr(e),t))),eH=y(2,(e,t)=>P(aO(Sr(e),t))),tH=y(2,(e,t)=>P(iO(Sr(e),t))),nH=y(2,(e,t)=>P(cO(Sr(e),t))),fS=y((e)=>le(e[0]),re(function*(e,t,n){let r=yield*Yn,o=yield*Po(e.channel,r),s=n?.capacity==="unbounded"?void 0:n?.capacity??v_,a=yield*hr({capacity:s}),i=yield*hr({capacity:s});return yield*je(function*(){while(!0){let c=yield*o,f=[],u=[];for(let l=0;l<c.length;l++){let m=t(c[l]);if(Bt(m))f.push(m.failure);else u.push(m.success)}let d=void 0;if(u.length>0){let l=Pp(a,u);if(l.length>0)d=yield*Eu(ts(a,l))}if(f.length>0){let l=Pp(i,f);if(l.length>0)yield*ts(i,l)}if(d)yield*$s(d)}}).pipe(Vn((c)=>(Ls(a,c),Ls(i,c),R)),Ne(r)),[a,i]})),rH=y((e)=>le(e[0]),(e,t,n)=>B(fS(Nu(e,(r)=>t(r),n),(r)=>r,n),([r,o])=>[Gs(r),Gs(o)])),oH=y((e)=>le(e[0]),(e,t,n)=>B(fS(e,t,{capacity:n?.capacity??16}),([r,o])=>[Gs(r),Gs(o)])),sH=y(2,(e,t)=>t.pipe(B((n)=>n?e:os),ro)),aH=y(2,re(function*(e,t){let n=void 0,r=yield*Zy(e.channel),o=De(r,(i)=>(n=i,He(i))),s=oo(b(o)),a=yield*dR(s,t);if(n)return[a,os];return s=oo(b(r)),[a,s]})),iH=y(2,(e,t)=>P(CO(e.channel,t))),cH=y(2,(e,t)=>P(AO(e.channel,t))),q_=y(2,(e,t)=>e.channel.pipe(kc((n)=>t(n).channel),P)),fH=y(2,(e,t)=>e.channel.pipe(uO((n)=>t(n).channel),P)),H_=y(2,(e,t)=>e.channel.pipe(jp(t),P)),Bu=y(2,(e,t)=>P(Yr(e.channel,(n)=>t(n).channel)));var uS=y(2,(e,t)=>e.channel.pipe(lO(t),P)),uH=y(3,(e,t,n)=>{let r=Array.isArray(t)?(o)=>V(o,"_tag")&&t.includes(o._tag):vo(t);return uS(e,(o)=>r(o)?n(o):R)}),dH=y(2,(e,t)=>H_(e,(n)=>{let r=Np(n);return At(r)?t(r.success):R})),j_=y((e)=>le(e[0]),(e,t,n,r)=>P(pO(Sr(e),t,(o)=>n(o).channel,r&&((o)=>r(o).channel)))),dS=y((e)=>le(e[0]),(e,t,n,r)=>P(mO(Sr(e),t,(o)=>n(o).channel,r&&((o)=>r(o).channel)))),lH=y((e)=>le(e[0]),(e,t,n,r)=>{let o=Array.isArray(t)?(s)=>V(s,"_tag")&&t.includes(s._tag):vo(t);return j_(e,o,n,r)}),pH=y((e)=>le(e[0]),(e,t,n)=>{let r;return dS(e,(o)=>(r??=Object.keys(t),V(o,"_tag")&&Bp(o._tag)&&r.includes(o._tag)?ue(o):ge(o)),(o)=>t[o._tag](o),n)}),mH=y((e)=>le(e[0]),(e,t,n,r,o)=>P(hO(Sr(e),t,n,(s,a)=>r(s,a).channel,o&&((s,a)=>o(s,a).channel)))),hH=y((e)=>le(e[0]),(e,t,n,r)=>{let o=Object.create(null);for(let a of Object.keys(n)){let i=n[a];o[a]=(c,f)=>i(c,f).channel}let s=r&&((a,i)=>r(a,i).channel);return P(gO(e.channel,t,o,s))}),gH=y(2,(e,t)=>dS(e,(n)=>{if(vo(n,t)&&V(n,"reason"))return ue(n.reason);return ge(n)},Js)),W_=y(2,(e,t)=>P(xO(e.channel,t))),xH=y(3,(e,t,n)=>P(dO(e.channel,t,(r)=>n(r).channel))),yH=y(3,(e,t,n)=>P(Wp(e.channel,t,(r,o)=>n(r,o).channel))),SH=y(2,(e,t)=>P(Zv(e.channel,(n)=>Sr(t())))),EH=y(2,(e,t)=>Bu(e,(n)=>Wa(t(n)))),bH=(e)=>P(yO(e.channel)),IH=y((e)=>le(e[0]),(e,t)=>P(SO(e.channel,t))),wH=y((e)=>le(e[0]),(e,t)=>P(EO(e.channel,t))),kH=y(2,(e,t)=>P(bO(e.channel,t))),f_=(e,t)=>ro(B(Sc(t),(n)=>{let r=Qr.defaultValue(),o=()=>Bu(gS(e,Qr,L(()=>r)),(s)=>ro(lt(B(n(s),(a)=>(r=a,ro(nt(Lp,o())))),()=>b(Js(s)))));return o()})),TH=y((e)=>le(e[0]),(e,t,n)=>dn(()=>{let r=n?.preventFallbackOnPartialStream??!1,o=0,s={attempt:0,stepIndex:0},a=gS(m_,L(()=>(s={attempt:s.attempt+1,stepIndex:o},s))),i=n?.onEvent===void 0?void 0:x_(n.onEvent,()=>s),c,f=i===void 0?Q:(l)=>aR(iR(l,B(i.begin,(m)=>{c=m})),(m)=>M(()=>{if(c===void 0)return R;let p=c;return c=void 0,i.end(p,m)})),u=ne(),d=dn(()=>{let l=t.steps[o];if(!l)return Js(u_(u));let m=a(f(fR(e,l.provide))),p=!1;if(ve(u)){let g=u.value,h=!1,E=m;m=dn(()=>{if(h)return E;return h=!0,Js(g)}),m=f_(m,rS(l,!1))}else{let g=rS(l,!0);m=g?f_(m,g):m}return Bu(r?cR(m,(g)=>(p=!0,R)):m,(g)=>{if(o++,r&&p)return Js(g);return u=oe(g),d})});return d})),AH=y(2,(e,t)=>{let n=ht(t);return n===0?os:J_(e,(r,o)=>o===n-1)}),CH=y(3,(e,t,n)=>dn(()=>{let r=dd(t),o=BigInt(0),s=!1;return vc(K_(e,(a)=>{let i=o+BigInt(a.length);if(i>r)return s=!0,!1;return o=i,!0}),dn(()=>s?n():os))})),vH=y(2,(e,t)=>{let n=ht(t);if(n===0)return os;return Ka(e,Yo,(r,o)=>{if(hp(r,o),r.length>n)lu(r,r.length-n);return[r,rs]},{onHalt(r){return Fs(r)}})}),J_=y((e)=>le(e[0]),(e,t,n)=>It(e,(r,o)=>L(()=>{let s=0,a=!1;return A(M(()=>a?ee():r),(c)=>{let f=c.findIndex((u)=>t(u,s++));if(f>=0){a=!0;let u=c.slice(0,n?.excludeLast?f:f+1);return Ke(u)?b(u):ee()}return b(c)})}))),G_=y((e)=>le(e[0]),(e,t,n)=>It(e,(r,o)=>L(()=>{let s=0,a=!1;return je(function*(){if(a)return yield*ee();let i=yield*r;for(let c=0;c<i.length;c++)if(yield*t(i[c],s++)){a=!0;let f=i.slice(0,n?.excludeLast?c:c+1);return Ke(f)?f:yield*ee()}return i})}))),K_=y(2,(e,t)=>It(e,(n,r)=>L(()=>{let o=0,s=!1,a=A(M(()=>s?ee():n),(i)=>{let c=[];for(let f=0;f<i.length;f++){if(!t(i[f],o++)){s=!0;break}c.push(i[f])}return Ke(c)?b(c):s?ee():a});return a}))),OH=y(2,(e,t)=>It(e,(n,r)=>L(()=>{let o=!1,s=A(M(()=>o?ee():n),(a)=>{let i=[];for(let c=0;c<a.length;c++){let f=t(a[c]);if(Bt(f)){o=!0;break}i.push(f.success)}return Ke(i)?b(i):o?ee():s});return s}))),_H=y(2,(e,t)=>G_(e,(n,r)=>B(t(n,r),(o)=>!o),{excludeLast:!0})),lS=y(2,(e,t)=>{let n=ht(t);if(n===0)return e;return It(e,(r,o)=>L(()=>{let s=0,a=r.pipe(A((i)=>{if(s>=n)return b(i);if(s+=i.length,s<=n)return a;return b(i.slice(n-s))}));return a}))}),RH=y(2,(e,t)=>lS(V_(e,(n,r)=>!t(n,r)),1)),PH=y(2,(e,t)=>lS(Z_(e,(n,r)=>B(t(n,r),(o)=>!o)),1)),V_=y(2,(e,t)=>It(e,(n,r)=>L(()=>{let o=!0,s=0,a=A(n,(i)=>{let c=i.findIndex((f)=>!t(f,s++));if(c===-1)return a;return o=!1,b(i.slice(c))});return M(()=>o?a:n)}))),MH=y(2,(e,t)=>It(e,(n,r)=>L(()=>{let o=!0,s=A(n,(a)=>{let i=a.findIndex((c)=>Bt(t(c)));if(i===-1)return s;return o=!1,b(a.slice(i))});return M(()=>o?s:n)}))),Z_=y(2,(e,t)=>It(e,(n,r)=>L(()=>{let o=!0,s=0,a=je(function*(){while(!0){let i=yield*n;for(let c=0;c<i.length;c++){if(yield*t(i[c],s++))continue;return o=!1,i.slice(c)}}});return M(()=>o?a:n)}))),UH=y(2,(e,t)=>{let n=ht(t);if(n===0)return e;return It(e,(r,o)=>L(()=>{let s=Yo(),a=A(r,(i)=>{gp(s,i);let c=s.length-n,f=Ua(s,c);return Sn(f)?b(f):a});return a}))}),Q_=(e)=>e.channel.pipe(to(pe),P),Y_=y(2,(e,t)=>(t=qs(t),It(e,(n,r)=>L(()=>{let o=Xt(),s=0,a,i=!1;return M(function c(){if(i)return ee();else if(a===void 0)return A(n,(f)=>{if(o.length===0&&f.length===t)return b(f);else if(o.length+f.length<t){for(let u=0;u<f.length;u++)o.push(f[u]);return c()}return a=f,c()});for(;s<a.length;)if(o.push(a[s++]),o.length===t){let f=o;return o=[],b(f)}return s=0,a=void 0,c()}).pipe(lt(()=>{if(o.length===0)return ee();let c=o;return i=!0,o=[],b(c)}))})))),FH=y(2,(e,t)=>X_(e,t,1)),X_=y(3,(e,t,n)=>{let r=qs(t),o=qs(n);return It(e,(s,a)=>L(()=>{let i=null,c=Yo(),f=!1,u=0,d=ns(s,{onSuccess(l){if(gp(c,l),u>0){let p=c.length;lu(c,u),u=Math.max(0,u-p)}if(c.length<r)return d;f=!0;let m=[];while(c.length>=r)if(r===o)m.push(Ua(c,r));else{m.push(_C(c,r));let p=c.length;lu(c,o),u=Math.max(0,o-p)}return b(m)},onFailure(l){if(f)lu(c,r-o);if(c.length===0)return He(l);return i=l,b(pe(Fs(c)))}});return M(()=>i?He(i):d)}))}),DH=y(2,(e,t)=>Ka(e,Xt,(n,r)=>{let o=Xt();for(let s=0;s<r.length;s++)if(t(r[s])){if(Sn(n))o.push(n),n=[]}else n.push(r[s]);return[n,o]},{onHalt(n){return Sn(n)?pe(n):rs}})),NH=y(4,(e,t,n,r)=>jy(un(e.channel),un(t.channel),n,r).pipe(to(pe),P)),BH=y(4,(e,t,n,r)=>P(jy(e.channel,t.channel,n,r))),LH=y((e)=>le(e[0]),(e,t,n,r)=>P(wc(e.channel,t,(o,s)=>{let a=Xt();for(let i=0;i<s.length;i++){let[c,f]=n(o,s[i]);o=c,a.push(...f)}return[o,Sn(a)?pe(a):rs]},r?.onHalt?{onHalt(o){let s=r.onHalt(o);return Ke(s)?pe(s):rs}}:void 0))),Ka=y((e)=>le(e[0]),(e,t,n,r)=>P(wc(e.channel,t,(o,s)=>{let[a,i]=n(o,s);return o=a,[o,Ke(i)?pe(i):rs]},r?.onHalt?{onHalt(o){let s=r.onHalt(o);return Ke(s)?pe(s):rs}}:void 0))),rs=Xt(),zH=y((e)=>le(e[0]),(e,t,n,r)=>e.channel.pipe(un,wc(t,(o,s)=>B(n(o,s),([a,i])=>[a,Ke(i)?pe(i):Xt()]),r?.onHalt?{onHalt(o){let s=r.onHalt(o);return Ke(s)?pe(s):rs}}:void 0),P)),$H=y((e)=>le(e[0]),(e,t,n,r)=>e.channel.pipe(wc(t,(o,s)=>B(n(o,s),([a,i])=>[a,Ke(i)?pe(i):rs]),r?.onHalt?{onHalt(o){let s=r.onHalt(o);return Ke(s)?pe(s):rs}}:void 0),P)),qH=y(3,(e,t,n)=>dn(()=>{let r=t();return vc(Wa(r),P(wc(e.channel,()=>r,(o,s)=>{let a=Xt();for(let i=0;i<s.length;i++)o=n(o,s[i]),a.push(o);return[o,pe(a)]})))})),HH=y(3,(e,t,n)=>dn(()=>e.channel.pipe(un,fO(t(),n),to(pe),P))),jH=y(2,(e,t)=>It(e,re(function*(n,r){let o=yield*Uo,s=Wn(Zt(t)),a,i,c=1/0,f=ct(),u=ct(),d=ct();yield*n.pipe(f.whenOpen,A((m)=>(u.openUnsafe(),a=m,c=o.currentTimeMillisUnsafe()+s,R)),Ze({disableYield:!0}),Vn((m)=>(i=m,c=o.currentTimeMillisUnsafe(),u.openUnsafe(),d.openUnsafe(),R)),Ne(r));let l=M(function m(){let p=o.currentTimeMillisUnsafe(),g=c<p?s:Math.min(s,c-p);return A(za(Ws(g),d.await),()=>{if(o.currentTimeMillisUnsafe()<c)return m();else if(a){u.closeUnsafe(),f.closeUnsafe();let E=b(pe(Yp(a)));return a=void 0,E}else if(i)return He(i);return m()})});return M(()=>{if(i){if(a){let m=b(pe(Yp(a)));return a=void 0,m}return He(i)}return f.openUnsafe(),u.whenOpen(l)})}))),eR=y(2,(e,t)=>{let n=t.burst??0;if(t.strategy==="enforce")return WH(e,t.cost,t.units,t.duration,n);return JH(e,t.cost,t.units,t.duration,n)}),WH=(e,t,n,r,o)=>It(e,(s)=>Ru((a)=>{let i=Wn(Zt(r)),c=n+o<0?Number.POSITIVE_INFINITY:n+o,f=n,u=a.currentTimeMillisUnsafe();return b(A(s,function d(l){return A(t(l),(m)=>{let p=a.currentTimeMillisUnsafe(),h=(p-u)/i,E=f+h*n,S=E<0?c:Math.min(E,c);if(m<=S)return f=S-m,u=p,b(l);return A(s,d)})}))})),JH=(e,t,n,r,o)=>It(e,(s)=>Ru((a)=>{let i=Wn(Zt(r)),c=n+o<0?Number.POSITIVE_INFINITY:n+o,f=n,u=a.monotonicTimeNanosUnsafe();return b(A(s,(d)=>A(t(d),(l)=>{let m=a.monotonicTimeNanosUnsafe(),g=Number(m-u)/1e6/i,h=f+g*n,S=Math.min(h,c)-l;if(S>=0)return f=S,u=m,b(d);let k=-S/n,I=Math.max(0,k*i);if(I>0)return A(Ws(I),()=>(f=S,u=m,b(d)));return f=S,u=m,b(d)})))})),GH=y(2,(e,t)=>eR(e,{...t,cost:(n)=>b(t.cost(n))})),KH=y(2,(e,t)=>Q_(Y_(e,t))),VH=y(3,(e,t,n)=>pS(e,c_(qs(t)),Du(n))),ZH=y((e)=>le(e[0]),(e,t,n)=>tR(e,re(function*(r,o,s){for(let a=0;a<r.length;a++){let[i,c]=yield*t(r[a]),f=Mo(s,i),u=ve(f)?f.value:yield*Ja(eS(o,i));yield*tS(o,i),yield*bn(u,c)}}),n)),QH=y((e)=>le(e[0]),(e,t,n)=>dn(()=>{let r=Pu();return tR(e,re(function*(o,s,a){for(let i=0;i<o.length;i++){let c=t(o[i]),f=Mo(r,c);if(Tn(f))Mu(r,c,[o[i]]);else f.value.push(o[i])}for(let[i,c]of r){let f=Mo(a,i),u=ve(f)?f.value:yield*Ja(eS(s,i));yield*tS(s,i),yield*ts(u,c)}Qp(r)}),n)})),tR=(e,t,n)=>oS(e,re(function*(r,o,s){let a=yield*_p();yield*Me(o,Vr(a));let i=Pu(),c=yield*XO({lookup:(f)=>xr(hr({capacity:n?.bufferSize??4096}).pipe(xt((u)=>(Mu(i,f,u),bn(a,[f,Gs(u)])))),(u)=>(Tc(i,f),gc(u))),idleTimeToLive:n?.idleTimeToLive??nc}).pipe(In(s));return yield*gr({while:Ds,body:pr(A(r,(f)=>t(f,c,i))),step:Mn}).pipe(De((f)=>rt(a,f)),Ne(o)),xc(a)})),YH=y(2,(e,t)=>It(e,(n,r)=>L(()=>{let o=void 0,s,a=Xt(),i=n.pipe(A((f)=>{for(let u=0;u<f.length;u++){let d=f[u],l=t(d);if(s===void 0){o=l,s=[d];continue}else if(he(l,o)){s.push(d);continue}a.push([o,s]),o=l,s=[d]}if(Sn(a)){let u=a;return a=[],b(u)}return i})),c=!1;return lt(M(()=>c?ee():i),()=>{c=!0;let f=s;return s=void 0,f&&Sn(f)?b(pe([o,f])):ee()})}))),XH=y(2,(e,t)=>It(e,(n,r)=>L(()=>{let o,s,a=M(()=>{if(s!==void 0){let c=s;return s=void 0,b(c)}return n}).pipe(bc((c)=>(o=So(c),ee()))),i=B(M(()=>t.transform(a,r)),([c,f])=>(s=f,pe(c)));return M(()=>o?o:i)}))),ej=y(2,(e,t)=>pS(e,t,g_)),pS=y(3,(e,t,n)=>P(eo(re(function*(r,o,s){let a=yield*Po(e.channel,o),i=ct(!1),c=Symbol(),f=yield*hr({capacity:0});yield*a.pipe(i.whenOpen,A((x)=>(i.closeUnsafe(),bn(f,x))),Ze,De((x)=>rt(f,x)),Ne(s));let u=yield*Uo,d=yield*h_(n),l=ct(!1),m=u.currentTimeMillisUnsafe(),p=0,g=ne(),h,E=(x)=>{if(l.openUnsafe())p=u.currentTimeMillisUnsafe();return b(x)},S=l.await.pipe(A(()=>d(m,g)),A(([,x])=>Ws(x)),A(()=>bn(f,c)),lt(()=>gc(f)),A(()=>Hs)),k=M(()=>{if(h!==void 0){let x=h;return h=void 0,E(x)}if(f.state._tag==="Open")i.openUnsafe();return A(Zr(f),(x)=>x===c?ee():E(x))}),I=A(([x,w])=>{if(l.isOpen())m+=u.currentTimeMillisUnsafe()-p;else if(f.state._tag==="Done")return ee();return g=oe(x),h=w,b(pe(x))});return M(()=>{if(f.state._tag==="Done"&&h===void 0)return f.state.exit;l.closeUnsafe();let x=I(M(()=>t.transform(k,s)));return f.state._tag==="Open"?za(x,S):x})})))),tj=y(2,re(function*(e,t){let n=ht(t.n),r=yield*nj(t),o=Array(n),s=yield*ut;for(let a=0;a<n;a++){let i=cn(s),c=yield*hu(r).pipe(zs(ut,i));o[a]=$y(Tp(c)).pipe(vu((f)=>Te(i,f)),P)}return yield*qa(e.channel,(a)=>kp(r,a)).pipe(yr((a)=>wp(r,a)),Ro),o})),nj=(e)=>xr(e.capacity==="unbounded"?Ip(e):e.strategy==="dropping"?Ep(e):e.strategy==="sliding"?bp(e):Sp(e),mu),nR=y(2,(e,t)=>B(pR(e,t),M_)),rj=y(2,(e,t)=>B(s_({acquire:nR(e,t),idleTimeToLive:t.idleTimeToLive}),(n)=>ro(a_(n)))),oj=y(2,(e,t)=>P(Wy(e.channel,t))),sj=y(2,(e,t)=>P(Jy(e.channel,t))),aj=y(2,(e,t)=>e.channel.pipe(Jy(i_(t)),Vv(([n,r])=>r?$p(r):yc),P)),ij=(e)=>tm(lR(e)),cj=(e)=>Ka(e,Xt,(t,n)=>{let r=$h(t,n);return[r,[r]]}),fj=(e)=>rR(e,he),rR=y(2,(e,t)=>It(e,(n,r)=>L(()=>{let o=!0,s;return A(n,function a(i){let c=[],f=0;if(o)o=!1,s=i[0],f=1,c.push(s);for(;f<i.length;f++){let u=i[f];if(t(u,s))continue;s=u,c.push(u)}return Sn(c)?b(c):A(n,a)})}))),uj=y(2,(e,t)=>It(e,(n,r)=>L(()=>{let o=!0,s;return A(n,re(function*a(i){let c=[],f=0;if(o)o=!1,s=i[0],f=1,c.push(s);for(;f<i.length;f++){let u=i[f];if(yield*t(u,s))continue;s=u,c.push(u)}return Sn(c)?c:yield*A(n,re(a))}))}))),dj=y((e)=>le(e[0]),(e,t)=>dn(()=>{let n=new TextDecoder(t?.encoding);return Dn(e,(r)=>n.decode(r,{stream:!0}))})),lj=(e)=>dn(()=>{let t=new TextEncoder;return Dn(e,(n)=>t.encode(n))}),pj=(e)=>e.channel.pipe(Wy(kO()),P),oR=y(2,(e,t)=>F_(e,(n,r)=>{let o=r===0?[]:[t],s=n.length-1;for(let a=0;a<n.length;a++)if(a===s)o.push(n[a]);else o.push(n[a],t);return o})),mj=y(2,(e,t)=>Wa(t.start).pipe(vc(oR(e,t.middle)),vc(Wa(t.end)))),hj=y(2,(e,t)=>sR(e,t,Ga(d_([!0,!1])))),sR=y(3,(e,t,n)=>P(me(re(function*(r,o){let s=yield*ie(un(n.channel))(r,o),a=Symbol(),i=!1,c=!1,f=(yield*ie(un(e.channel))(r,o)).pipe(lt(()=>(i=!0,b(a)))),u=(yield*ie(un(t.channel))(r,o)).pipe(lt(()=>(c=!0,b(a))));return je(function*(){while(!0){if(i&&c)return yield*ee();let d=yield*s;if(d&&i)continue;if(!d&&c)continue;let l=yield*d?f:u;if(l===a)continue;return pe(l)}})})))),gj=y(2,(e,t)=>P(vO(e.channel,t))),xj=y(2,(e,t)=>P(OO(e.channel,t))),aR=y(2,(e,t)=>P(vu(e.channel,t))),yj=y(2,(e,t)=>P(_O(e.channel,t))),iR=y(2,(e,t)=>P(RO(e.channel,t))),cR=y(2,(e,t)=>P(Gy(e.channel,(n)=>t(n[0])))),Sj=y(2,(e,t)=>P(PO(e.channel,t))),mS=y(2,(e,t)=>P(MO(e.channel,t))),fR=y((e)=>le(e[0]),(e,t,n)=>P(UO(e.channel,t,n))),hS=y(2,(e,t)=>P(Kp(e.channel,t))),Ej=y(3,(e,t,n)=>P(Vp(e.channel,t,n))),gS=y(3,(e,t,n)=>P(Zp(e.channel,t,n))),uR=y(2,(e,t)=>P(FO(e.channel,t))),bj=y(3,(e,t,n)=>uR(e,(r)=>Un(r,t,n(Lt(r,t))))),Ij=function(){let e=le(arguments[0]),t=e?arguments[1]:arguments[0],n=Dp(e?arguments[2]:arguments[1]);if(e){let r=arguments[0];return P(Ky(r.channel,t,n))}return(r)=>P(Ky(r.channel,t,n))},wj=Wa({}),kj=y(3,(e,t,n)=>Dn(e,(r)=>({...r,[t]:n(r)})));var Tj=y((e)=>le(e[0]),(e,t,n,r)=>Rc(e,(o)=>Dn(n(o),(s)=>({...o,[t]:s})),r)),Aj=y((e)=>le(e[0]),(e,t,n,r)=>Nu(e,(o)=>B(n(o),(s)=>({...o,[t]:s})),r)),Cj=y(2,(e,t)=>Dn(e,(n)=>({[t]:n}))),dR=y(2,(e,t)=>b_((n)=>Po(e.channel,n).pipe(A((r)=>t.transform(r,n)),B(([r])=>r)))),lR=(e)=>Ha(e.channel,()=>[],(t,n)=>{for(let r=0;r<n.length;r++)t.push(n[r]);return t}),vj=(e)=>Ha(e.channel,()=>0,(t,n)=>t+n.length),Oj=(e)=>Ha(e.channel,()=>0,(t,n)=>{for(let r=0;r<n.length;r++)t+=n[r];return t}),_j=y(3,(e,t,n)=>Ha(e.channel,t,(r,o)=>{for(let s=0;s<o.length;s++)r=n(r,o[s]);return r})),Rj=y(3,(e,t,n)=>zO(e.channel,t,(r,o)=>{let s=0,a=r;return B(gr({while:()=>s<o.length,body:()=>n(a,o[s]),step(i){a=i,s++}}),()=>a)})),Pj=(e)=>B(BO(e.channel),qo(l_(0))),Mj=(e)=>B(LO(e.channel),qo(Yp)),Uj=y(2,(e,t)=>qa(e.channel,(n)=>{let r=0;return gr({while:()=>r<n.length,body:()=>t(n[r++]),step:Mn})})),Fj=y(2,(e,t)=>NO(e.channel,(n)=>{let r=!1,o=0;return B(gr({while:()=>!r&&o<n.length,body:()=>t(n[o]),step(s){if(o++,!s)r=!0}}),()=>!r)})),sm=y(2,(e,t)=>qa(e.channel,t)),am=(e)=>DO(e.channel),Dj=(e)=>Zy(e.channel),Nj=(e)=>Ha(e.channel,()=>"",(t,n)=>t+n.join("")),Bj=(e)=>B(Vy(e.channel),(t)=>t.buffer),Lj=(e)=>Vy(e.channel),xS=y((e)=>le(e[0]),(e,t,n)=>{let r=void 0,o=void 0,s=ct(!1);return new ReadableStream({start(a){o=Fl(Jt(sm(e,(i)=>s.whenOpen(L(()=>{s.closeUnsafe();for(let c=0;c<i.length;c++)a.enqueue(i[c]);r(),r=void 0}))),t)),o.addObserver((i)=>{if(i._tag==="Failure")a.error(Oc(i.cause));else a.close()})},pull(){return new Promise((a)=>{r=a,s.openUnsafe()})},cancel(){if(!o)return;return w_(lr(fn(o)))}},n?.strategy)}),zj=y((e)=>le(e[0]),(e,t)=>xS(e,Do(),t)),$j=y((e)=>le(e[0]),(e,t)=>B(Qn(),(n)=>xS(e,n,t))),yS=y(2,(e,t)=>({[Symbol.asyncIterator](){let n=k_(t),r=Fn(t),o=ko(),s,a,i,c,f=(d)=>{if(c)return c;let l=i;return c=n(nt(gt(l?fn(l):R,Te(o,d)),{done:!0,value:void 0})),c},u=async(d)=>{try{await f(d)}catch(l){await n(em("Suppressed error while closing Stream async iterator",l))}};return{async next(){if(c)return c;if(a){let m=a.next();if(!m.done)return m;a=void 0}let d=r(s??A(Po(e.channel,o),(m)=>(s=m,m)));i=d;let l=await n(T_(d));if(i===d)i=void 0;if($e(l))return a=l.value[Symbol.iterator](),a.next();else if(es(l.cause))return f(Ye);if(c&&p_(l.cause))return c;throw await u(l),Oc(l.cause)},return(){return f(Ye)},async throw(d){throw await u(Xp(d)),d}}}})),qj=(e)=>B(Qn(),(t)=>yS(e,t)),Hj=(e)=>yS(e,Do()),jj=y((e)=>le(e[0]),(e,t,n)=>Yy(e.channel,t,n)),Wj=y(2,(e,t)=>HO(e.channel,t)),pR=y(2,(e,t)=>jO(e.channel,t)),Jj=y(2,(e,t)=>$O(e.channel,t)),Gj=y(2,(e,t)=>Qy(e.channel,t));var SS="~effect/rpc/RpcSchema/StreamSchema";function ES(e){return V(e,SS)}function im(e){return ES(e)?oe({success:e.success,error:e.error}):ne()}var Kj=we(le);function mR(e,t){return H(Kj.ast,{[SS]:SS,success:e,error:t})}var IS="~effect/rpc/Rpc",Vj=(e)=>V(e,IS);class gR{id;annotations;constructor(e){this.id=e,this.annotations=Do()}annotate(e,t){return this.annotations=Un(this.annotations,e,t),this}}var Zj={[IS]:IS,pipe(){return de(this,arguments)},setSuccess(e){return Vs({_tag:this._tag,payloadSchema:this.payloadSchema,successSchema:e,errorSchema:this.errorSchema,defectSchema:this.defectSchema,annotations:this.annotations,middlewares:this.middlewares})},setError(e){return Vs({_tag:this._tag,payloadSchema:this.payloadSchema,successSchema:this.successSchema,errorSchema:e,defectSchema:this.defectSchema,annotations:this.annotations,middlewares:this.middlewares})},setPayload(e){return Vs({_tag:this._tag,payloadSchema:va(e)?e:ae(e),successSchema:this.successSchema,errorSchema:this.errorSchema,defectSchema:this.defectSchema,annotations:this.annotations,middlewares:this.middlewares})},middleware(e){return Vs({_tag:this._tag,payloadSchema:this.payloadSchema,successSchema:this.successSchema,errorSchema:this.errorSchema,defectSchema:this.defectSchema,annotations:this.annotations,middlewares:new Set([...this.middlewares,e])})},prefix(e){return Vs({_tag:`${e}${this._tag}`,payloadSchema:this.payloadSchema,successSchema:this.successSchema,errorSchema:this.errorSchema,defectSchema:this.defectSchema,annotations:this.annotations,middlewares:this.middlewares})},annotate(e,t){return Vs({_tag:this._tag,payloadSchema:this.payloadSchema,successSchema:this.successSchema,errorSchema:this.errorSchema,defectSchema:this.defectSchema,middlewares:this.middlewares,annotations:Un(this.annotations,e,t)})},annotateMerge(e){return Vs({_tag:this._tag,payloadSchema:this.payloadSchema,successSchema:this.successSchema,errorSchema:this.errorSchema,defectSchema:this.defectSchema,middlewares:this.middlewares,annotations:er(this.annotations,e)})}},Vs=(e)=>{function t(){}return Object.setPrototypeOf(t,Zj),Object.assign(t,e),t.key=`effect/rpc/Rpc/${e._tag}`,t},xR=(e,t)=>{let n=t?.success??cc,r=t?.error??tu,o=t?.defect??bt(),s;if(t?.primaryKey)s=class extends lp(`effect/rpc/Rpc/${e}`)(t.payload){[IC](){return t.primaryKey(this)}};else s=va(t?.payload)?t?.payload:t?.payload?ae(t?.payload):cc;return Vs({_tag:e,payloadSchema:s,successSchema:t?.stream?mR(n,r):n,errorSchema:t?.stream?tu:r,defectSchema:o,annotations:Do(),middlewares:new Set})},Qj=(e)=>(t,n)=>{let r=n?.success??cc,o=n?.error??tu,s=n?.defect??bt(),a=e({success:r,error:o,defect:s});return xR(t,{...a,primaryKey:n?.primaryKey,payload:n?.payload,stream:n?.stream})},bS=new WeakMap,wS=(e)=>{if(bS.has(e))return bS.get(e);let t=e,n=new Set([t.errorSchema]),r=im(t.successSchema);if(ve(r))n.add(r.value.error);for(let s of t.middlewares)n.add(s.error);let o=ay(ve(r)?cc:t.successSchema,Ie([...n]),t.defectSchema);return bS.set(e,o),o},Lu="~effect/rpc/Rpc/Wrapper",Pc=(e)=>(Lu in e),cm=(e)=>(t)=>Pc(t)?{[Lu]:Lu,value:t.value,fork:e.fork??t.fork,uninterruptible:e.uninterruptible??t.uninterruptible}:{[Lu]:Lu,value:t,fork:e.fork??!1,uninterruptible:e.uninterruptible??!1},Yj=(e)=>Pc(e)?e.value:e,Xj=(e,t)=>{if(Pc(e))return cm(e)(t(e.value));return t(e)},e4=cm({fork:!0}),t4=cm({uninterruptible:!0});var dm={};Ps(dm,{make:()=>r4});var n4={add(...e){let t=new Map(this.requests);for(let n of e)t.set(n._tag,n);return as({requests:t,annotations:this.annotations})},merge(...e){let t=new Map(this.requests),n=new Map(this.annotations.mapUnsafe);for(let r of e){for(let[o,s]of r.requests)t.set(o,s);for(let[o,s]of r.annotations.mapUnsafe)n.set(o,s)}return as({requests:t,annotations:Ac(n)})},omit(...e){let t=new Map(this.requests);for(let n of e)t.delete(n);return as({requests:t,annotations:this.annotations})},middleware(e){let t=new Map;for(let[n,r]of this.requests)t.set(n,r.middleware(e));return as({requests:t,annotations:this.annotations})},toHandlers(e){let t=this;return je(function*(){let n=yield*Qn(),r=fm(e)?yield*e:e,o=new Map;return t.requests.forEach((s,a)=>{o.set(s.key,{tag:s._tag,handler:r[a],context:n})}),Ac(o)})},prefix(e){let t=new Map;for(let n of this.requests.values()){let r=n.prefix(e);t.set(r._tag,r)}return as({requests:t,annotations:this.annotations})},toLayer(e){return kS(this.toHandlers(e))},of:Q,toLayerHandler(e,t){let n=this;return kS(je(function*(){let r=yield*Qn(),o=fm(t)?yield*t:t,s=new Map,a=n.requests.get(e);return s.set(a.key,{handler:o,context:r}),Ac(s)}))},accessHandler(e){return Gr((t)=>{let n=this.requests.get(e),{handler:r,context:o}=um(t,n.key);return b((s,a)=>{a.rpc=n;let i=r(s,a),c=Pc(i)?i.value:i;return fm(c)?SR(c,o):hS(c,o)})})},annotate(e,t){return as({requests:this.requests,annotations:Un(this.annotations,e,t)})},annotateRpcs(e,t){return this.annotateRpcsMerge(yR(e,t))},annotateMerge(e){return as({requests:this.requests,annotations:er(this.annotations,e)})},annotateRpcsMerge(e){let t=new Map;for(let[n,r]of this.requests)t.set(n,r.annotateMerge(er(e,r.annotations)));return as({requests:t,annotations:this.annotations})}},as=(e)=>Object.assign(function(){},n4,{requests:e.requests,annotations:e.annotations}),r4=(...e)=>as({requests:new Map(e.map((t)=>[t._tag,t])),annotations:Do()});var ms={};Ps(ms,{ConnectionHooks:()=>Zm,CurrentHeaders:()=>Vm,Protocol:()=>ps,layerProtocolHttp:()=>tG,layerProtocolSocket:()=>oG,layerProtocolWorker:()=>sG,make:()=>YJ,makeNoSerialization:()=>aU,makeProtocolHttp:()=>iU,makeProtocolSocket:()=>cU,makeProtocolWorker:()=>fU,withHeaders:()=>eG});var TS="~effect/http/HttpBody";var ER="~effect/http/HttpBody/HttpBodyError";class o4 extends Qt("HttpBodyError"){[ER]=ER}class AS{[TS];constructor(){this[TS]=TS}[Re](){return this.toJSON()}toString(){return K(this,{ignoreToString:!0})}}class bR extends AS{_tag="Empty";toJSON(){return{_id:"effect/HttpBody",_tag:"Empty"}}}var IR=new bR;class lm extends AS{_tag="Uint8Array";contentType;contentLength;text;_body;constructor(e,t,n,r){super();this._body=e,this.text=r,this.contentType=t,this.contentLength=n}get body(){return this._body??=s4(this.text)}toJSON(){return{_id:"effect/HttpBody",_tag:"Uint8Array",body:this.contentType.startsWith("text/")||this.contentType.endsWith("json")?new TextDecoder().decode(this.body):`Uint8Array(${this.body.length})`,contentType:this.contentType,contentLength:this.contentLength}}}var CS=(e,t)=>new lm(e,t??"application/octet-stream",e.length),wR=new TextEncoder,pm=globalThis.Buffer,s4=pm!==void 0?(e)=>pm.from(e,"utf8"):(e)=>wR.encode(e),vS=(e,t)=>{if(typeof e!=="string")e=e===void 0?"":String(e);if(pm!==void 0)return new lm(void 0,t??"text/plain",pm.byteLength(e,"utf8"),e);let n=wR.encode(e);return new lm(n,t??"text/plain",n.length,e)};var OS="~effect/http/HttpClientError";class Zs extends Qt("HttpClientError"){constructor(e){if("cause"in e.reason)super({...e,cause:e.reason.cause});else super(e)}[OS]=OS;get request(){return this.reason.request}get response(){return"response"in this.reason?this.reason.response:void 0}get message(){return this.reason.message}}var TR=(e)=>e.endsWith("Error")?e.slice(0,-5):e,AR=(e,t,n)=>t?`${e}: ${t} (${n})`:`${e} error (${n})`;class Va extends Qt("DecodeError"){get methodAndUrl(){return`${this.request.method} ${this.request.url}`}get message(){let e=`${this.response.status} ${this.methodAndUrl}`;return AR(TR(this._tag),this.description,e)}}class _S extends Qt("EmptyBodyError"){get methodAndUrl(){return`${this.request.method} ${this.request.url}`}get message(){let e=`${this.response.status} ${this.methodAndUrl}`;return AR(TR(this._tag),this.description,e)}}class Mc extends Ct(OS)({_tag:ye("HttpError"),kind:ur(["EncodeError","DecodeError","TransportError","InvalidUrlError","StatusCodeError","EmptyBodyError"]),cause:mt(bt())}){static fromHttpClientError(e){return new Mc({_tag:"HttpError",kind:e.reason._tag,cause:e.reason})}}var CR=[["GET","get"],["POST","post"],["PUT","put"],["DELETE","del"],["PATCH","patch"],["HEAD","head"],["OPTIONS","options"],["TRACE","trace"],["QUERY","query"]];var vR=(e,t)=>{if(t._tag==="Empty"||t._tag==="FormData")return li(li(e,"content-type"),"content-length");return e=t.contentType===void 0?li(e,"content-type"):af(e,"content-type",t.contentType),t.contentLength===void 0?li(e,"content-length"):af(e,"content-length",t.contentLength.toString())};class RS extends Qt("UrlError"){}var OR=(e,t,n)=>ql({try:()=>{let r=new URL(e,f4());for(let o=0;o<t.params.length;o++){let[s,a]=t.params[o];if(a!==void 0)r.searchParams.append(s,a)}if(n!==void 0)r.hash=n;return r},catch:(r)=>new RS({cause:r})}),f4=()=>{if("location"in globalThis&&globalThis.location!==void 0&&globalThis.location.origin!==void 0&&globalThis.location.pathname!==void 0)return location.origin+location.pathname;return};var _R="~effect/http/HttpClientRequest";var d4={[_R]:_R,...ho,toJSON(){return{_id:"HttpClientRequest",method:this.method,url:this.url,urlParams:this.urlParams,hash:this.hash,headers:ui(this.headers),body:this.body.toJSON()}},pipe(){return de(this,arguments)}};function No(e,t,n,r,o,s){let a=Object.create(d4);return a.method=e,a.url=t,a.urlParams=n,a.hash=r,a.headers=o,a.body=s,a}var l4=No("GET","",TI,ne(),di,IR),RR=(e)=>(t,n)=>p4(l4,{method:e,url:t,...n??void 0});var p4=y(2,(e,t)=>{let n=e;if(t.method)n=PR(n,t.method);if(t.url)n=DR(n,t.url);if(t.headers)n=UR(n,t.headers);if(t.urlParams)n=g4(n,t.urlParams);if(t.hash)n=x4(n,t.hash);if(t.body)n=BR(n,t.body);if(t.accept)n=FR(n,t.accept);if(t.acceptJson)n=m4(n);return n}),PR=y(2,(e,t)=>No(t,e.url,e.urlParams,e.hash,e.headers,e.body)),MR=y(3,(e,t,n)=>No(e.method,e.url,e.urlParams,e.hash,af(e.headers,t,n),e.body)),UR=y(2,(e,t)=>No(e.method,e.url,e.urlParams,e.hash,bI(e.headers,t),e.body));var FR=y(2,(e,t)=>MR(e,"Accept",t)),m4=FR("application/json"),DR=y(2,(e,t)=>{if(typeof t==="string")return No(e.method,t,e.urlParams,e.hash,e.headers,e.body);let n=new URL(t.toString()),r=la(n.searchParams),o=Zd(n.hash===""?void 0:n.hash.slice(1));return n.search="",n.hash="",No(e.method,n.toString(),r,o,e.headers,e.body)}),NR=y(2,(e,t)=>{if(t==="")return e;return No(e.method,h4(t,e.url),e.urlParams,e.hash,e.headers,e.body)});var h4=(e,t)=>{let n=e.endsWith("/"),r=t.startsWith("/");return n&&r?e+t.slice(1):!n&&!r?e+"/"+t:e+t};var g4=y(2,(e,t)=>No(e.method,e.url,CI(e.urlParams,t),e.hash,e.headers,e.body));var x4=y(2,(e,t)=>No(e.method,e.url,e.urlParams,oe(t),e.headers,e.body));var BR=y(2,(e,t)=>No(e.method,e.url,e.urlParams,e.hash,vR(e.headers,t),t));function LR(e){let t=OR(e.url,e.urlParams,Ef(e.hash));if(At(t))return oe(t.success);return ne()}var Za="~effect/http/HttpIncomingMessage";var zR=(e,t)=>{let n=e.headers["content-type"]??"",r;if(n.includes("application/json"))try{r=Uc(e.json)}catch(s){}else if(n.includes("text/")||n.includes("urlencoded"))try{r=Uc(e.text)}catch(s){}let o={...t,headers:ui(e.headers),remoteAddress:e.remoteAddress};if(r!==void 0)o.body=r;return o};var Fc="~effect/http/HttpClientResponse";class y4 extends qR{[Za];[Fc];request;source;constructor(e,t){super();this.request=e,this.source=t,this[Za]=Za,this[Fc]=Fc}toJSON(){return zR(this,{_id:"HttpClientResponse",request:this.request.toJSON(),status:this.status})}get status(){return this.source.status}get url(){if(this.source.url)return this.source.url.split("#")[0];let e=LR(this.request);if(Tn(e))return"";return e.value.hash="",e.value.href}get headers(){return Es(this.source.headers)}cachedCookies;get cookies(){if(this.cachedCookies)return this.cachedCookies;return this.cachedCookies=vd(this.source.headers.getSetCookie())}get remoteAddress(){return ne()}get stream(){return this.source.body?sS({evaluate:()=>this.source.body,onError:(e)=>new Zs({reason:new Va({request:this.request,response:this,cause:e})})}):Js(new Zs({reason:new _S({request:this.request,response:this,description:"can not create stream from empty body"})}))}get json(){return A(this.text,(e)=>Mr({try:()=>e===""?null:JSON.parse(e),catch:(t)=>new Zs({reason:new Va({request:this.request,response:this,cause:t})})}))}textBody;get text(){return this.textBody??=B(this.arrayBuffer,(e)=>new TextDecoder().decode(e))}get urlParamsBody(){return A(this.text,(e)=>Mr({try:()=>la(new URLSearchParams(e)),catch:(t)=>new Zs({reason:new Va({request:this.request,response:this,cause:t})})}))}formDataBody;get formData(){return this.formDataBody??=fr({try:()=>this.source.formData(),catch:(e)=>new Zs({reason:new Va({request:this.request,response:this,cause:e})})}).pipe(MS,Uc)}arrayBufferBody;get arrayBuffer(){if(this.arrayBufferBody)return this.arrayBufferBody;return this.arrayBufferBody=fr({try:()=>this.source.arrayBuffer(),catch:(e)=>new Zs({reason:new Va({request:this.request,response:this,cause:e})})}).pipe(MS,Uc),this.arrayBufferBody}pipe(){return de(this,arguments)}}var HR="~effect/http/HttpClient";var WR=Ft("effect/HttpClient");var E4=(e,t)=>{let n=Object.create(b4);return n.preprocess=t,n.postprocess=e,n.execute=function(r){return e(t(r))},n},b4={[HR]:HR,pipe(){return de(this,arguments)},...ho,toJSON(){return{_id:"effect/HttpClient"}},...Object.fromEntries(CR.map(([e,t])=>[t,function(n,r){return this.execute(RR(e)(n,r))}]))};var JR=y(2,(e,t)=>E4(e.postprocess,(n)=>B(e.preprocess(n),t)));var jR=(()=>{if("FinalizationRegistry"in globalThis&&globalThis.FinalizationRegistry){let t=new FinalizationRegistry((n)=>{n.abort()});return{register(n,r){t.register(n,r,n)},unregister(n){t.unregister(n)}}}let e=new Map;return{register(t,n){e.set(t,setTimeout(()=>n.abort(),5000))},unregister(t){let n=e.get(t);if(n===void 0)return;clearTimeout(n),e.delete(t)}}})();class I4{original;controller;constructor(e,t){this.original=e,this.controller=t}[Fc]=Fc;[Za]=Za;applyInterrupt(e){return M(()=>(jR.unregister(this.original),Ic(e,()=>L(()=>{this.controller.abort()}))))}get request(){return this.original.request}get url(){return this.original.url}get status(){return this.original.status}get headers(){return this.original.headers}get cookies(){return this.original.cookies}get remoteAddress(){return this.original.remoteAddress}get formData(){return this.applyInterrupt(this.original.formData)}get text(){return this.applyInterrupt(this.original.text)}get json(){return this.applyInterrupt(this.original.json)}get urlParamsBody(){return this.applyInterrupt(this.original.urlParamsBody)}get arrayBuffer(){return this.applyInterrupt(this.original.arrayBuffer)}get stream(){return dn(()=>(jR.unregister(this.original),mS(this.original.stream,L(()=>{this.controller.abort()}))))}toJSON(){return this.original.toJSON()}[Re](){return this.original[Re]()}pipe(){return de(this,arguments)}}var GR="~effect/Pool",oP=Symbol(),sP=Symbol(),BS=Symbol();var aP=(e)=>cP({...e,min:e.size,max:e.size,strategy:ym}),iP=(e)=>A(e.timeToLiveStrategy==="creation"?P4(e.timeToLive):M4(e.timeToLive),(t)=>cP({...e,strategy:t})),cP=(e)=>Xn(re(function*(t){let n=yield*Qn(),r=Lt(n,ut),o=Qs(e.acquire,(f)=>er(n,f)),s=e.concurrency??1,a={acquire:o,concurrency:s,isFixed:e.min===e.max,minSize:e.min,maxSize:e.max,strategy:e.strategy,targetUtilization:Math.min(Math.max(e.targetUtilization??1,0.1),1)},i={scope:r,isShuttingDown:!1,usage:0,resizeSemaphore:La(1),items:new Set,availableHead:void 0,availableTail:void 0,invalidated:new Set,waiters:new Set},c={[GR]:GR,[oP]:e.acquire,[sP]:n,[BS]:yield*Uo,config:a,state:i,pipe(){return de(this,arguments)}};if(yield*Me(r,k4(c)),a.minSize>0)yield*xt(DS(t(gm(c)),{startImmediately:!0}),(f)=>Me(r,fn(f)));if(e.strategy!==ym)yield*xt(DS(t(e.strategy.run(c))),(f)=>Me(r,fn(f)));return c})),k4=re(function*(e){if(e.state.isShuttingDown)return;e.state.isShuttingDown=!0;let t=e.state.items.size,n=La(t);for(let r of e.state.items)if(r.refCount>0)r.finalizer=xt(r.finalizer,n.release(1)),e.state.invalidated.add(r),yield*n.take(1);else e.state.items.delete(r),zu(e,r),e.state.invalidated.delete(r),yield*r.finalizer;if(yield*n.releaseAll,e.state.waiters.size>0){let r=Array.from(e.state.waiters);e.state.waiters.clear();for(let o of r)o()}yield*n.take(t)}),LS=(e)=>mr((t)=>{let n=e.state;if(n.isShuttingDown)return hm;if(n.availableHead?.exit._tag==="Success"){if(n.usage++,e.config.isFixed||$u(e)<=qu(e))return fP(e,n.availableHead,t);n.usage--}return T4(e,v4)});var T4=(e,t)=>Na((n)=>{let r=e.state;r.usage++;let o=Su(tP(n(_4(e)),()=>To(()=>{r.usage--})),()=>a),s=mr((i)=>{if(r.isShuttingDown)return r.usage--,hm;let c=zS(e)??($u(e)<=qu(e)?r.availableHead:void 0);if(c===void 0)return o;if(c.exit._tag==="Failure")return C4(e,c),a;return t(e,c,i,n)}),a=Ao(()=>{if(r.isShuttingDown)return r.usage--,hm;return $u(e)>qu(e)?Su(r.resizeSemaphore.withPermitsIfAvailable(1)(Ne(is(gm(e)),r.scope)),()=>s):s});return a}),A4=(e,t)=>{if(t.refCount++,t.refCount>=e.config.concurrency)zu(e,t)},C4=(e,t)=>{e.state.items.delete(t),e.state.invalidated.delete(t),zu(e,t)},fP=(e,t,n)=>{A4(e,t);let r=Cc(n.context,ut);if(r.state._tag==="Closed")eP(n,t.release);else YR(r,{},t.release);return t.exit},v4=(e,t,n)=>fP(e,t,n),O4=(e,t)=>mr((n)=>{let r=e.state;if(t.refCount--,r.usage--,t.refCount===0)t.idleSince=e[BS].currentTimeMillisUnsafe();if(r.invalidated.has(t))return qS(e,t);if(t.refCount<e.config.concurrency)R4(e,t),uP(e,n,1);return Co}),zS=(e)=>{let t=e.state.availableHead;while(t!==void 0&&t.exit._tag==="Failure")t=t.availableNext;return t},_4=(e)=>Bs((t)=>{let n=e.state;if(zS(e)!==void 0||n.isShuttingDown)return t(Co);let r=(o)=>{n.waiters.delete(r),t(o??Co)};return n.waiters.add(r),To(()=>{n.waiters.delete(r)})}),uP=(e,t,n)=>{let r=e.state.waiters;if(r.size===0)return;t.currentDispatcher.scheduleTask(()=>{let o=n,s=[];for(let a of r){if(o--<=0)break;s.push(a)}for(let a=0;a<s.length;a++)s[a]()},0)},KR=(e)=>mr((t)=>(uP(e,t,Number.POSITIVE_INFINITY),Co)),$S=new WeakMap,VR=(e,t)=>{if(t.isAvailable||$S.has(t))return;if(t.isAvailable=!0,t.availablePrevious=e.state.availableTail,t.availableNext=void 0,e.state.availableTail!==void 0)e.state.availableTail.availableNext=t;else e.state.availableHead=t;e.state.availableTail=t},R4=(e,t)=>{if(t.isAvailable||$S.has(t))return;if(t.isAvailable=!0,t.availablePrevious=void 0,t.availableNext=e.state.availableHead,e.state.availableHead!==void 0)e.state.availableHead.availablePrevious=t;else e.state.availableTail=t;e.state.availableHead=t},zu=(e,t)=>{if(!t.isAvailable)return;if(t.isAvailable=!1,t.availablePrevious!==void 0)t.availablePrevious.availableNext=t.availableNext;else e.state.availableHead=t.availableNext;if(t.availableNext!==void 0)t.availableNext.availablePrevious=t.availablePrevious;else e.state.availableTail=t.availablePrevious;t.availablePrevious=void 0,t.availableNext=void 0};var qS=(e,t)=>M(()=>{if(!e.state.items.has(t))return R;else if(t.refCount===0)return e.state.items.delete(t),zu(e,t),e.state.invalidated.delete(t),lr(A(t.finalizer,()=>Ne(is(gm(e)),e.state.scope,{startImmediately:!0})));return e.state.invalidated.add(t),zu(e,t),lr(Ne(is(gm(e)),e.state.scope,{startImmediately:!0}))}),gm=(e)=>e.state.resizeSemaphore.withPermits(1)(NS(e)),NS=(e)=>M(()=>{let t=qu(e),n=$u(e);if(t>=n)return R;let r=n-t,o=e.config.strategy===ym?ZR(e):A(e.config.strategy.reclaim(e),(a)=>a?b(a):ZR(e));if(r===1){let a=xt(o,KR(e));return e.config.isFixed?lr(a):A(a,(i)=>i.exit._tag==="Failure"?R:NS(e))}let s=o.pipe(rP(r,{concurrency:r}),xt(KR(e)));return e.config.isFixed?lr(s):A(s,(a)=>a.some((i)=>i.exit._tag==="Failure")?R:NS(e))}),ZR=(e)=>Na((t)=>mr((n)=>{let r=e,o=XR(),s=n.context;n.setContext(Un(r[sP],ut,o));let a=A(or(r[oP]),(i)=>{let c={exit:i,finalizer:De(Te(o,i),U4),refCount:0,idleSince:r[BS].currentTimeMillisUnsafe(),disableReclaim:!1,isAvailable:!1,availablePrevious:void 0,availableNext:void 0,release:void 0};c.release=pr(O4(e,c));let f=M(()=>e.state.items.has(c)?e.config.strategy.onAcquire(c):R);if(i._tag==="Success")return e.state.items.add(c),VR(e,c),e.config.strategy===ym?b(c):nt(f,c);let u=zS(e)===void 0?e.state.waiters.values().next().value:void 0;if(u!==void 0)u(i);else e.state.items.add(c),VR(e,c);return nt(Ne(gt(c.finalizer,f),e.state.scope,{startImmediately:!0}),c)});return yu(t(a),(i)=>(n.setContext(s),i._tag==="Failure"?QR(o,i):void 0),!0)})),$u=(e)=>{if(e.state.isShuttingDown)return 0;if(e.config.isFixed)return e.config.minSize;let t=e.state.usage/e.config.targetUtilization,n=Math.ceil(t/e.config.concurrency);return Math.min(Math.max(e.config.minSize,n),e.config.maxSize)},qu=(e)=>e.state.items.size-e.state.invalidated.size,ym={run:(e)=>R,onAcquire:(e)=>R,reclaim:(e)=>xm},P4=re(function*(e){let t=yield*Uo,n=yield*_p(),r=Wn(Zt(e)),o=new WeakMap;return Q({run:(s)=>{let a=(i)=>M(()=>{if(!s.state.items.has(i)||s.state.invalidated.has(i))return R;let c=t.currentTimeMillisUnsafe(),f=o.get(i),u=r-(c-f);return u>0?Ks(a(i),u):qS(s,i)});return Zr(n).pipe(xt(a),Ze({disableYield:!0}))},onAcquire:(s)=>M(()=>(o.set(s,t.currentTimeMillisUnsafe()),bn(n,s))),reclaim:(s)=>xm})}),M4=re(function*(e){let t=yield*Uo,n=Wn(Zt(e));return Q({run:(r)=>{let o=M(()=>{if(qu(r)<=$u(r))return R;let s=t.currentTimeMillisUnsafe()-n,a;for(let i of r.state.items){if(i.refCount>0||i.idleSince>s)continue;if(r.state.invalidated.has(i)||$S.has(i))continue;if(a===void 0||i.idleSince<a.idleSince)a=i}return a===void 0?R:A(qS(r,a),()=>o)});return o.pipe(Ks(e),Ze({disableYield:!0}))},onAcquire:(r)=>R,reclaim:(r)=>xm})}),U4=(e)=>dt((t)=>{let n=t.getRef(nP);if(n)return ku(n)("Unhandled error in pool finalizer",e);return R});var co={};Ps(co,{CloseEvent:()=>hP,Socket:()=>Qa,SocketCloseError:()=>fs,SocketError:()=>Ae,SocketErrorReason:()=>wm,SocketErrorTypeId:()=>Hu,SocketOpenError:()=>cs,SocketReadError:()=>ao,SocketUpgradeError:()=>io,SocketWriteError:()=>Er,TypeId:()=>Em,WebSocket:()=>SP,WebSocketConstructor:()=>Tm,fromTransformStream:()=>W4,fromWebSocket:()=>EP,isCloseEvent:()=>Nc,isSocket:()=>pP,isSocketError:()=>gP,layerWebSocket:()=>j4,layerWebSocketConstructorGlobal:()=>z4,make:()=>Wu,makeChannel:()=>L4,makeWebSocket:()=>WS,makeWebSocketChannel:()=>H4,readerBytes:()=>jS,readerString:()=>mP,toChannel:()=>yP,toChannelString:()=>N4,toChannelWith:()=>km,toStream:()=>B4});var Em="~effect/socket/Socket",pP=(e)=>V(e,Em),Qa=Ft("effect/socket/Socket"),Wu=(e)=>Qa.of({[Em]:Em,reader:e.reader,writer:e.writer}),bm=new TextEncoder,jS=(e)=>B(e.reader,({pull:t})=>B(t,(n)=>{for(let r=0;r<n.length;r++)if(typeof n[r]==="string"){let o=Array(n.length);for(let s=0;s<n.length;s++){let a=n[s];o[s]=typeof a==="string"?bm.encode(a):a}return o}return n})),mP=(e,t)=>B(e.reader,({pull:n})=>{let r=new TextDecoder(t);return B(n,(o)=>{let s=Array(o.length);for(let a=0;a<o.length;a++){let i=o[a];s[a]=typeof i==="string"?i:r.decode(i)}return s})}),Sm="~effect/socket/Socket/CloseEvent";class hP{[Sm];code;reason;constructor(e=1000,t){this[Sm]=Sm,this.code=e,this.reason=t}toString(){return this.reason?`${this.code}: ${this.reason}`:`${this.code}`}}var Nc=(e)=>V(e,Sm),Hu="~effect/socket/Socket/SocketError",gP=(e)=>V(e,Hu);class ao extends Ct("effect/socket/Socket/SocketReadError")({_tag:ye("SocketReadError"),cause:bt()}){message="An error occurred during Read"}class Er extends Ct("effect/socket/Socket/SocketWriteError")({_tag:ye("SocketWriteError"),cause:bt()}){message="An error occurred during Write"}class cs extends Ct("effect/socket/Socket/SocketOpenError")({_tag:ye("SocketOpenError"),kind:ur(["Unknown","Timeout"]),cause:bt()}){get message(){return this.kind==="Timeout"?'timeout waiting for "open"':"An error occurred during Open"}}class io extends Ct("effect/socket/Socket/SocketUpgradeError")({_tag:ye("SocketUpgradeError"),cause:mt(bt())}){static unsupported=()=>_(new Ae({reason:new io({})}));get message(){return this.cause===void 0?"Socket does not support TLS upgrade":"An error occurred during TLS upgrade"}}class fs extends Ct("effect/socket/Socket/SocketCloseError")({_tag:ye("SocketCloseError"),code:wo,closeReason:mt(z)}){get message(){if(this.closeReason)return`${this.code}: ${this.closeReason}`;return`${this.code}`}}var wm=Ie([ao,Er,cs,io,fs]);class Ae extends fy(Hu)("SocketError",{_tag:ye("SocketError"),reason:wm}){constructor(e){if("cause"in e.reason)super({...e,cause:e.reason.cause});else super(e)}[Hu]=Hu;static is(e){return gP(e)}message=this.reason.message}var ju=(e,t)=>new Ae({reason:new fs({code:e,closeReason:t})}),D4=(e,t)=>{for(let n=0;n<t.length;n++)if(Nc(t[n]))return je(function*(){for(let r=0;r<=n;r++)yield*e.write(t[r])});return e.writeAll(t)},xP=(e,t)=>me(re(function*(n,r){let o=yield*HS(r),s=yield*In(t,o),a=yield*HS(r),i=yield*In(e.writer,a),c;return yield*n.pipe(A((f)=>D4(i,f)),Ze({disableYield:!0}),lP(dP,(f)=>M(()=>(c=f,Te(o,Ye)))),_o(Te(a,Ye)),Ne(r)),De(M(()=>c!==void 0?He(c):s),(f)=>He(c??f))})),yP=(e)=>xP(e,jS(e)),N4=y((e)=>pP(e[0]),(e,t)=>xP(e,mP(e,t))),km=()=>(e)=>yP(e),B4=(e)=>P(me((t,n)=>In(jS(e),n))),L4=()=>no(B(Qa,km()));class SP extends Ft()("~effect/socket/Socket/WebSocket"){}class Tm extends Ft()("@effect/platform/Socket/WebSocketConstructor"){}var z4=Ys(Tm)((e,t)=>{if(t!==void 0&&typeof t!=="string"&&!Array.isArray(t))throw TypeError("WebSocket client options are not supported by the global WebSocket constructor");return new globalThis.WebSocket(e,t)}),WS=(e,t)=>Tm.use((n)=>EP(xr((typeof e==="string"?b(e):e).pipe(B((r)=>n(r,t?.protocols))),(r)=>L(()=>r.close(1000))),t)),$4=(e)=>("pause"in e)&&typeof e.pause==="function",EP=(e,t)=>dt((n)=>{let r,o=ct(!1),s=n.context,a=je(function*(){let u=yield*Yn,d=yield*In(e,u);if("binaryType"in d)d.binaryType="arraybuffer";let l=$4(d),m=t?.highWaterMark??(l?q4:void 0),p=d.readyState===1,g=l&&"isPaused"in d&&d.isPaused===!0,h=[],E=0,S,k,I;function x(){if(!l||g)return;d.pause(),g=!0}function w(){if(!l||!g)return;d.resume(),g=!1}function C(){let J=h;if(h=[],E=0,S===void 0)w();return J}function T(){if(k===void 0||h.length===0)return;let J=k;k=void 0,J(b(C()))}function v(J){if(h.push(J),m!==void 0)E+=typeof J==="string"?bm.encode(J).byteLength:J.byteLength;if(k!==void 0)T();if(l&&E>=m)x();else if(!l&&!k&&m!==void 0&&E>m)O(new Ae({reason:new ao({cause:Error(`Socket highWaterMark of ${m} bytes exceeded`)})}))}function O(J){if(S===void 0)S=J;if(I!==void 0){let{cleanup:N,resume:G}=I;I=void 0,N(),G(_(S))}if(k!==void 0){let N=k;k=void 0,N(h.length>0?b(C()):_(S))}}function U(J){let N=J.data;if(typeof Blob<"u"&&N instanceof Blob){N.arrayBuffer().then((G)=>v(new Uint8Array(G)),(G)=>{O(new Ae({reason:new ao({cause:G})}))});return}v(N instanceof ArrayBuffer?new Uint8Array(N):N)}function j(J){O(new Ae({reason:p?new ao({cause:J}):new cs({kind:"Unknown",cause:J})}))}function X(J){O(ju(typeof J.code==="number"?J.code:1006,J.reason))}if(d.addEventListener("message",U),d.addEventListener("error",j,{once:!0}),d.addEventListener("close",X,{once:!0}),yield*Me(u,L(()=>{if(O(ju(1006)),d.removeEventListener("message",U),d.removeEventListener("error",j),d.removeEventListener("close",X),l)try{w()}catch{}o.closeUnsafe(),r=void 0})),d.readyState>=2)return yield*_(S??ju(1006));if(!p)yield*Gn((J)=>{let N=()=>{if(I?.resume!==J)return;I=void 0,d.removeEventListener("open",N),J(R)},G=()=>d.removeEventListener("open",N);return I={resume:J,cleanup:G},d.addEventListener("open",N,{once:!0}),L(()=>{if(I?.resume===J)I=void 0;G()})}).pipe(Im({duration:t?.openTimeout??1e4,orElse:()=>_(new Ae({reason:new cs({kind:"Timeout",cause:Error('timeout waiting for "open"')})}))})),p=!0;if(S===void 0&&E<m)w();return r=d,o.openUnsafe(),{pull:Gn((J)=>{if(h.length>0)return J(b(C()));if(S!==void 0)return J(_(S));return k=J,L(()=>{if(k===J)k=void 0})}),upgrade:io.unsupported}}).pipe(Qs((u)=>er(s,u))),i=(u)=>M(()=>{let d=r;if(d===void 0)return o.whenOpen(i(u));try{if(Nc(u))d.close(u.code,u.reason);else d.send(u);return R}catch(l){return _(new Ae({reason:new Er({cause:l})}))}}),c=(u)=>M(()=>{let d=r;if(d===void 0)return o.whenOpen(c(u));try{for(let l=0;l<u.length;l++)d.send(u[l]);return R}catch(l){return _(new Ae({reason:new Er({cause:l})}))}}),f=b({write:i,writeAll:c});return b(Wu({reader:a,writer:f}))}),q4=65536,H4=(e,t)=>no(B(WS(e,t),km())),j4=ja(WS,Dc(Qa)),W4=(e)=>dt((t)=>{let n=ct(!1),r,o=t.context,s=new WeakMap,a=(d)=>{let l=s.get(d);if(!l)l=d.writable.getWriter(),s.set(d,l);return l},i=je(function*(){let d=yield*Yn,l=yield*In(e,d),m=l.readable.getReader(),p;yield*Me(d,M(()=>(n.closeUnsafe(),r=void 0,Ec(()=>m.cancel().catch(Mn))))),r={stream:l,fail(h){if(p===void 0)p=h;m.cancel().catch(Mn)}},n.openUnsafe();let g=fr({try:()=>m.read(),catch:(h)=>p??new Ae({reason:new ao({cause:h})})});return{pull:M(()=>{if(p!==void 0)return _(p);return A(g,({done:h,value:E})=>h?_(p??ju(1000)):b([E]))}),upgrade:io.unsupported}}).pipe(Qs((d)=>er(o,d))),u=xr(b({write:(d)=>n.whenOpen(M(()=>{let l=r;if(Nc(d))return L(()=>{l.fail(ju(d.code,d.reason))});return fr({try:()=>a(l.stream).write(typeof d==="string"?bm.encode(d):d),catch:(m)=>new Ae({reason:new Er({cause:m})})})})),writeAll:(d)=>n.whenOpen(fr({try:async()=>{let l=a(r.stream);for(let m=0;m<d.length;m++){let p=d[m];await l.write(typeof p==="string"?bm.encode(p):p)}},catch:(l)=>new Ae({reason:new Er({cause:l})})}))}),()=>Ec(async()=>{if(!r)return;await a(r.stream).close().catch(Mn)}));return b(Wu({reader:i,writer:u}))});class Am extends Ft()("effect/workers/Transferable/Collector"){}var bP=()=>{let e=[],t=(o)=>{e.push(...o)},n=()=>e,r=()=>{let o=e;return e=[],o};return Am.of({addAllUnsafe:t,addAll:(o)=>L(()=>t(o)),readUnsafe:n,read:L(n),clearUnsafe:r,clear:L(r)})};var JS="~effect/workers/WorkerError";class IP extends Ct("effect/workers/WorkerError/WorkerSpawnError")({_tag:ye("WorkerSpawnError"),message:z,cause:mt(bt())}){}class wP extends Ct("effect/workers/WorkerError/WorkerSendError")({_tag:ye("WorkerSendError"),message:z,cause:mt(bt())}){}class kP extends Ct("effect/workers/WorkerError/WorkerReceiveError")({_tag:ye("WorkerReceiveError"),message:z,cause:mt(bt())}){}class TP extends Ct("effect/workers/WorkerError/WorkerUnknownError")({_tag:ye("WorkerUnknownError"),message:z,cause:mt(bt())}){}var GS=Ie([IP,wP,kP,TP]);class G4 extends Ct(JS)({_tag:ye("WorkerError"),reason:GS}){constructor(e){super({...e,cause:e.reason.cause})}[JS]=JS;get message(){return this.reason.message}}class KS extends Ft()("effect/workers/Worker/WorkerPlatform"){}var Cm={};Ps(Cm,{RpcClientDefect:()=>Xs,RpcClientError:()=>us});var VS="~effect/rpc/RpcClientError";class Xs extends Ct("effect/rpc/RpcClientError/RpcClientDefect")({_tag:ye("RpcClientDefect"),message:z,cause:bt()}){}class us extends Ct(VS)({_tag:ye("RpcClientError"),reason:Ie([GS,wm,Mc,Xs])}){[VS]=VS;get message(){return`${this.reason._tag}: ${this.reason.message}`}}var ZS=(e)=>e;var AP={_tag:"Ping"};var Ju=Ie([z,Oa]),V4=ae({_tag:ye("Request"),id:Ju,tag:z,payload:Hr,headers:Oe(cr([z,z])),isNotification:mt(pt(!0)),traceId:mt(z),spanId:mt(z),sampled:mt(ru)}),QS=Ie([V4,ae({_tag:ye("Ack"),requestId:Ju}),ae({_tag:ye("Interrupt"),requestId:Ju}),ae({_tag:ye("Ping")}),ae({_tag:ye("Eof")}),ae({_tag:ye("Chunk"),requestId:Ju,values:Hr}),ae({_tag:ye("Exit"),requestId:Ju,exit:Hr}),ae({_tag:ye("Defect"),defect:Hr}),ae({_tag:ye("Pong")})]);var YS=(e)=>{switch(e._tag){case"Exit":case"Defect":case"ClientProtocolError":return!0;default:return!1}};var nd={};Ps(nd,{MaxBufferSizeExceeded:()=>kE,RpcSerialization:()=>pn,json:()=>jM,jsonRpc:()=>JM,layerJson:()=>qJ,layerJsonRpc:()=>WJ,layerNdJsonRpc:()=>JJ,layerNdjson:()=>HJ,layerNdjsonWith:()=>jJ,layerSchemaBinary:()=>GJ,makeNdjson:()=>Km,ndJsonRpc:()=>GM,ndjson:()=>WM});var Q4=new WeakMap,Y4=new WeakMap,X4=new WeakMap,eW=new WeakMap;function JP(e,t){let n=t?.fingerprint===!0?Y4:Q4,r=n.get(e);if(r!==void 0)return r;let{exact:o,layout:s,recursive:a,target:i}=zc(e),c=Xa(s,t?.fingerprint),f=o?{value:void 0}:void 0,u=eE(f===void 0?i:_J(i,f,!a),s,c,f);return n.set(e,u),u}function lE(e,t){let n=t?.fingerprint===!0?eW:X4,r=n.get(e);if(r!==void 0)return r;let{exact:o,exitSuccess:s,layout:a,target:i}=zc(e);if(!o){if(!s)return JP(e,t);let f={value:void 0},u=eE(PJ(i,f),a,Xa(a,t?.fingerprint),f,!0);return n.set(e,u),u}let c=eE(MJ(i),a,Xa(a,t?.fingerprint),void 0);return n.set(e,c),c}function eE(e,t,n,r,o=!1){return Hr.pipe(Z(e,CJ(t,n,r,o)))}function GP(e,t){let{exact:n,exitSuccess:r,layout:o}=zc(e),s=Xa(o,t?.fingerprint),a=t??jt;if(!n||a.onExcessProperty==="error"){let i=eu(JP(e,t),t);if(!r||a.onExcessProperty==="error")return i;return(c)=>{if(!Jm(c))return i(c);try{return Lm(o,c,a,s)}catch(f){throw f instanceof ds?new Rn(f.issue):f}}}return(i)=>{try{return Lm(o,i,a,s)}catch(c){throw c instanceof ds?new Rn(c.issue):c}}}function tW(e,t){let{exact:n,layout:r}=zc(e),o=t??jt;if(!n||o.onExcessProperty==="error"){let a=GP(e,t);return(i)=>nW(i.map(a))}let s=Xa(r,t?.fingerprint);return(a)=>{try{return AM(r,a,o,s)}catch(i){throw i instanceof ds?new Rn(i.issue):i}}}function nW(e){if(e.length===1)return e[0];let t=0;for(let o of e)t+=o.length;let n=new Uint8Array(t),r=0;for(let o of e)n.set(o,r),r+=o.length;return n}function KP(e,t){let{exact:n,exitSuccess:r,layout:o,target:s}=zc(e),a=t??jt,i=n?void 0:Xl(s,a),c=i!==void 0&&r?(f)=>Jm(f)?f:i(f):i;return rW(o,Xa(o,t?.fingerprint),a,t?.maxFrameSize,c,VP(n,t))}function VP(e,t){if(t?.dictionary!==!0)return!1;if(!e)throw Error("Binary layout: dictionary needs a schema the binary layer validates on its own");return!0}function ZP(e,t){let{exact:n,layout:r,target:o}=zc(e),s=VP(n,t),a=GP(e,t),i=tW(e,t);if(!s)return{encode:a,encodeMany:i};let c=Xa(r,t?.fingerprint),f=t??jt,u=f.onExcessProperty==="error"?eu(o,t):void 0,d=YW(),l=(m)=>{try{return m()}catch(p){throw p instanceof ds?new Rn(p.issue):p}};return{encode:(m)=>l(()=>Lm(r,u===void 0?m:u(m),f,c,d)),encodeMany:(m)=>l(()=>AM(r,u===void 0?m:m.map(u),f,c,d))}}function rW(e,t,n,r,o,s){let a=s?[]:void 0,i=new Uint8Array(0),c=0,f=0,u,d=!1,l=new qm,m=new $m(n,kW),p=()=>{l.release(),m.clear(),i=sE,c=f=0},g=(k,I)=>{throw new Rn(new te({expected:k},I,n))},h=()=>{let k=u;throw u=void 0,k},E=(k,I)=>{let x=k.length-I;if(x>i.length)i=new Uint8Array(Math.max(256,x));i.set(I===0?k:k.subarray(I),0),c=0,f=x},S={feedSync(k){if(u!==void 0)return h();if(d)return g("parser is spent");let I=f===c,x,w,C;if(I)x=k,w=0,C=k.length;else{if(k.length>0){let U=f-c,j=U+k.length;if(j>i.length){let X=new Uint8Array(Math.max(256,i.length*2,j));X.set(i.subarray(c,f)),i=X,c=0,f=U}else if(c>0)i.copyWithin(0,c,f),c=0,f=U;i.set(k,f),f+=k.length}x=i,w=c,C=f}let T=[],v=()=>{if(I){if(w<C)E(k,w)}else if(c=w,c===f)c=f=0;return T},O=(U,j)=>{d=!0;let X=new Rn(new te({expected:U},j,n));if(p(),T.length===0)throw X;return u=X,T};while(!0){let U=0,j=-1,X=C-w,J=1;for(let G=0;G<Math.min(6,X);G++){let fe=x[w+G];if(U+=(fe&127)*J,(fe&128)===0){j=G+1;break}J*=128}if(j===-1){if(X<6)return v();let G=BigInt(U);for(let fe=6;fe<Math.min(10,X);fe++){let Ge=x[w+fe];if(G|=BigInt(Ge&127)<<BigInt(fe*7),(Ge&128)===0){if(j=fe+1,G>tE)return O("safe integer length",G);U=Number(G);break}}if(j===-1){if(X>=10)return O("uvarint",x.subarray(w,w+10));return v()}}if(U===0)return O("nonzero frame length",U);if(r!==void 0&&U>r)return O("frame within maxFrameSize",U);if(j+U>X)return v();let N=W;try{W=0;let G=w+j;m.beginFrame(),l.reset(x,G,G+U,n,m,t.positional,a);let fe=FM(e,l,t);T.push(o===void 0?fe:o(fe))}catch(G){d=!0,p();let fe=G instanceof ds?new Rn(G.issue):sc(G)?G:(()=>{throw G})();if(T.length===0)throw fe;return u=fe,T}finally{W=N}w+=j+U}},endSync(){if(u!==void 0)return h();if(d)return g("parser is spent");d=!0;let k=c<f?i.subarray(c,f):void 0;if(p(),k!==void 0)return g("complete value",k)},feed:(k)=>M(()=>{try{return b(S.feedSync(k))}catch(I){if(sc(I))return _(I);throw I}}),end:M(()=>{try{return S.endSync(),R}catch(k){if(sc(k))return _(k);throw k}})};return S}var oW="~effect/encoding/SchemaBinary/fieldId",sW=32,aW=33,tE=BigInt(Number.MAX_SAFE_INTEGER),Um=BigInt(0),br=BigInt(1),iW=BigInt(2),QP=BigInt(7),CP=BigInt(127),cW=BigInt(1e6),fW=BigInt(255),vP=BigInt(4294967295),uW=BigInt(32),Bo=new TextEncoder,dW=new TextDecoder("utf-8",{fatal:!0,ignoreBOM:!0}),YP=7,OP=281474976710655,lW=4503599627370495,XP=0,eM=1,tM=2,_P=512,pW=1048576,mW=4194304,ei=0,Ya=1,Qu=2,Yu=3,Xu=4,ed=5,hW=6,gW=7,Ir=8;function pE(e){return typeof e==="number"&&Number.isInteger(e)&&e>=-OP&&e<=OP}var zm=8,nE=2199023255551,ta=[1,10,100,1000,1e4,1e5,1e6,1e7,1e8];function mE(e){for(let t=1;t<=zm;t++){let n=Math.round(e*ta[t]);if(!(n>=-nE&&n<=nE))return 0;if(n/ta[t]===e)return t}return 0}function nM(e){let t=Math.floor(e/2);return e%2===1?-t:t}var Ue={bool:1,null:2,undefined:3,number:4,string:5,bytes:6,bigint:7,int64:8,struct:9,variant:10,array:11,option:12,result:13,duration:14,bigDecimal:15,dateTimeZoned:16,json:17,exit:18,cause:19,causeReason:20};function rM(e){let t=2166136261;for(let n=0;n<e.length;n++)t=Math.imul(t^e[n],16777619);return t>>>0}var xW=BigInt("14695981039346656037"),yW=BigInt("1099511628211"),SW=BigInt("18446744073709551615");function RP(e){let t=xW;for(let n=0;n<e.length;n++)t=(t^BigInt(e[n]))*yW&SW;return t}function Fm(e,t){for(let n=0;n<t.length;n++)e.push(t[n])}function ea(e,t){while(t>127)e.push(t&127|128),t=Math.floor(t/128);e.push(t)}function Dm(e,t){e.push(t&255,t>>>8&255,t>>>16&255,t>>>24&255)}function tr(e,t){for(let n=0;n<8;n++)e.push(Number(t>>BigInt(n*8)&fW))}function oM(e,t){let n=Math.min(e.length,t.length);for(let r=0;r<n;r++)if(e[r]!==t[r])return e[r]-t[r];return e.length-t.length}class ds extends Error{issue;constructor(e){super("SchemaBinary failure");this.issue=e}}function D(e,t,n){throw yt(new te({expected:e},t,n))}var Ee=[],W=0;function yt(e){return new ds(W===0?e:new Qe(Ee.slice(0,W),e))}function EW(e){let t=new Uint8Array(sM(e)),n=0;while(e>127)t[n++]=e&127|128,e=Math.floor(e/128);return t[n]=e,t}function sM(e){let t=1;while(e>127)e=Math.floor(e/128),t++;return t}var bW=32;function IW(e,t,n,r){let o=n-t;if(o===0)return"";if(o<=bW){let s=wW(e,t,n);if(s!==void 0)return s}try{return dW.decode(e.subarray(t,n))}catch{D("utf-8",void 0,r)}}function wW(e,t,n){let r="",o=t;for(;o+16<=n;o+=16){let s=e[o],a=e[o+1],i=e[o+2],c=e[o+3],f=e[o+4],u=e[o+5],d=e[o+6],l=e[o+7],m=e[o+8],p=e[o+9],g=e[o+10],h=e[o+11],E=e[o+12],S=e[o+13],k=e[o+14],I=e[o+15];if((s|a|i|c|f|u|d|l|m|p|g|h|E|S|k|I)>127)return;r+=String.fromCharCode(s,a,i,c,f,u,d,l,m,p,g,h,E,S,k,I)}if(o+8<=n){let s=e[o],a=e[o+1],i=e[o+2],c=e[o+3],f=e[o+4],u=e[o+5],d=e[o+6],l=e[o+7];if((s|a|i|c|f|u|d|l)>127)return;r+=String.fromCharCode(s,a,i,c,f,u,d,l),o+=8}switch(n-o){case 0:return r;case 1:{let s=e[o];if(s>127)return;return r+String.fromCharCode(s)}case 2:{let s=e[o],a=e[o+1];if((s|a)>127)return;return r+String.fromCharCode(s,a)}case 3:{let s=e[o],a=e[o+1],i=e[o+2];if((s|a|i)>127)return;return r+String.fromCharCode(s,a,i)}case 4:{let s=e[o],a=e[o+1],i=e[o+2],c=e[o+3];if((s|a|i|c)>127)return;return r+String.fromCharCode(s,a,i,c)}case 5:{let s=e[o],a=e[o+1],i=e[o+2],c=e[o+3],f=e[o+4];if((s|a|i|c|f)>127)return;return r+String.fromCharCode(s,a,i,c,f)}case 6:{let s=e[o],a=e[o+1],i=e[o+2],c=e[o+3],f=e[o+4],u=e[o+5];if((s|a|i|c|f|u)>127)return;return r+String.fromCharCode(s,a,i,c,f,u)}default:{let s=e[o],a=e[o+1],i=e[o+2],c=e[o+3],f=e[o+4],u=e[o+5],d=e[o+6];if((s|a|i|c|f|u|d)>127)return;return r+String.fromCharCode(s,a,i,c,f,u,d)}}}var rE=65536,kW=256,TW=512,AW=16384;function oE(e){let t=new Uint8Array(e);return{buf:t,view:new DataView(t.buffer),offset:0,writing:!1}}var Gu=oE(rE);class hE{buf=new Uint8Array(0);view=new DataView(this.buf.buffer);arena;start=0;limit=0;len=0;reset(){let e=Gu;if(e.writing||e.offset>=e.buf.length)e=Gu=oE(rE);e.writing=!0,this.arena=e,this.buf=e.buf,this.view=e.view,this.start=e.offset,this.limit=e.buf.length-e.offset,this.len=0}ensure(e){if(this.len+e>this.limit){let t=this.arena,n=this.len+e,r=rE;while(r<n)r*=2;let o=oE(r);o.writing=!0,o.buf.set(this.buf.subarray(this.start,this.start+this.len)),t.writing=!1,this.arena=Gu=o,this.buf=o.buf,this.view=o.view,this.start=0,this.limit=o.buf.length}}byte(e){this.ensure(1),this.buf[this.start+this.len++]=e}bytes(e){this.ensure(e.length),this.buf.set(e,this.start+this.len),this.len+=e.length}uvarint(e){this.ensure(10);let t=this.buf,n=this.start+this.len;if(e<128)t[n++]=e;else if(t[n++]=e&127|128,e<16384)t[n++]=e>>>7;else{t[n++]=e>>>7&127|128,e=Math.floor(e/16384);while(e>127)t[n++]=e&127|128,e=Math.floor(e/128);t[n++]=e}this.len=n-this.start}uvarintBig(e){while(e>CP)this.byte(Number(e&CP)|128),e>>=QP;this.byte(Number(e))}zigzag(e){this.uvarintBig(e>=Um?e<<br:(-e<<br)-br)}numberVarint(e){let t=e<0||e===0&&1/e<0,n=t?-e:e;if(n<=lW)this.uvarint(n*2+(t?1:0));else this.uvarintBig(BigInt(n)*iW+(t?br:Um))}f64(e){this.ensure(8),this.view.setFloat64(this.start+this.len,e,!0),this.len+=8}i64(e){this.ensure(8),this.view.setBigInt64(this.start+this.len,e,!0),this.len+=8}u32le(e){this.ensure(4),this.view.setUint32(this.start+this.len,e>>>0,!0),this.len+=4}i32le(e){this.ensure(4),this.view.setInt32(this.start+this.len,e|0,!0),this.len+=4}idAndMark(e){let t=e.length;this.ensure(t+1);let n=this.buf,r=this.start+this.len;for(let s=0;s<t;s++)n[r++]=e[s];let o=r-this.start;return this.len=o+1,o}beginSized(){return this.ensure(1),this.len++}endSized(e){let t=this.len-e-1;if(t<128)this.buf[this.start+e]=t;else this.growSized(e,t)}endSizedRun(e){let t=(this.len-e-1)*2;if(t<128)this.buf[this.start+e]=t;else this.growSized(e,t)}growSized(e,t){let n=sM(t),r=n-1;this.ensure(r);let o=this.start+e;this.buf.copyWithin(o+n,o+1,this.start+this.len),this.len+=r;let s=t,a=o;while(s>127)this.buf[a++]=s&127|128,s=Math.floor(s/128);this.buf[a]=s}string(e){let t=e.length;if(t===0)return;this.ensure(t*3);let n=this.buf,r=this.start+this.len,o=0;for(;o+4<=t;o+=4){let s=e.charCodeAt(o),a=e.charCodeAt(o+1),i=e.charCodeAt(o+2),c=e.charCodeAt(o+3);if((s|a|i|c)>127){this.len+=Bo.encodeInto(e,n.subarray(this.start+this.len)).written;return}n[r++]=s,n[r++]=a,n[r++]=i,n[r++]=c}for(;o<t;o++){let s=e.charCodeAt(o);if(s>127){this.len+=Bo.encodeInto(e,n.subarray(this.start+this.len)).written;return}n[r++]=s}this.len=r-this.start}out(){let e=this.arena,t=new Uint8Array(e.buf.buffer,this.start,this.len);if(e===Gu)e.offset=this.start+this.len;return e.writing=!1,this.arena=void 0,t}abort(){let e=this.arena;if(e===void 0)return;if(e===Gu)e.offset=this.start;e.writing=!1,this.arena=void 0}}function CW(e){let t=En(e);return t._tag==="String"&&t.checks===void 0}function vW(e,t,n){return e.extra.find((r)=>yo({[t]:null},r.parameter,n).length>0)}class $m{entries=new WeakMap;orderLayouts;orderKeys;options;size=0;next=0;replace=!1;constructor(e,t){this.options=e,this.orderLayouts=t===void 0?void 0:Array(t),this.orderKeys=t===void 0?void 0:Array(t)}beginFrame(){this.replace=!0}find(e,t){let n=this.entries.get(e);if(n===void 0)n=new Map,this.entries.set(e,n);if(n.has(t))return n.get(t);let r=vW(e,t,this.options),o=this.orderLayouts;if(o===void 0)return n.set(t,r),r;let s=this.orderKeys;if(this.size<o.length)o[this.size]=e,s[this.size]=t,this.size++,n.set(t,r);else if(this.replace){this.replace=!1;let a=o[this.next];(a===e?n:this.entries.get(a))?.delete(s[this.next]),o[this.next]=e,s[this.next]=t,this.next=(this.next+1)%o.length,n.set(t,r)}return r}clear(){this.entries=new WeakMap,this.orderLayouts?.fill(void 0),this.orderKeys?.fill(void 0),this.size=this.next=0,this.replace=!1}}var Nm=new ArrayBuffer(0),sE=new Uint8Array(Nm),PP=new DataView(Nm);class qm{pos=0;nesting=0;buf=sE;view;viewCache=PP;viewBuffer=Nm;viewOffset=0;viewLength=0;end=0;options=jt;indexSignatures;positional=!1;intern;dict;reset(e,t,n,r,o,s,a){this.nesting=0,this.view=void 0,this.buf=e,this.pos=t,this.end=n,this.options=r,this.indexSignatures=o,this.positional=s,this.intern=void 0,this.dict=a}release(){this.pos=this.end=this.nesting=0,this.buf=sE,this.view=void 0,this.viewCache=PP,this.viewBuffer=Nm,this.viewOffset=this.viewLength=0,this.options=jt,this.indexSignatures=void 0,this.positional=!1,this.intern=void 0,this.dict=void 0}get remaining(){return this.end-this.pos}dataView(){let e=this.buf;if(e.buffer!==this.viewBuffer||e.byteOffset!==this.viewOffset||e.byteLength!==this.viewLength)this.viewBuffer=e.buffer,this.viewOffset=e.byteOffset,this.viewLength=e.byteLength,this.viewCache=new DataView(e.buffer,e.byteOffset,e.byteLength);return this.view=this.viewCache}byte(){if(this.pos>=this.end)D("complete value",void 0,this.options);return this.buf[this.pos++]}take(e){if(this.pos+e>this.end)D("complete value",void 0,this.options);let t=this.buf.subarray(this.pos,this.pos+e);return this.pos+=e,t}takeCopy(e){if(this.pos+e>this.end)D("complete value",void 0,this.options);let t=this.buf.slice(this.pos,this.pos+e);return this.pos+=e,t}enter(e){if(this.pos+e>this.end)D("complete value",void 0,this.options);let t=this.end;return this.end=this.pos+e,t}exit(e){this.pos=this.end,this.end=e}readUtf8(e){if(this.pos+e>this.end)D("complete value",void 0,this.options);let t=this.pos;return this.pos+=e,IW(this.buf,t,t+e,this.options)}uvarint(){let e=this.buf,t=this.end,n=this.pos;if(n>=t)D("complete value",void 0,this.options);let r=e[n++];if(r<128)return this.pos=n,r;let o=r&127;if(n>=t)D("complete value",void 0,this.options);if(r=e[n++],o|=(r&127)<<7,r<128)return this.pos=n,o;if(n>=t)D("complete value",void 0,this.options);if(r=e[n++],o|=(r&127)<<14,r<128)return this.pos=n,o;if(n>=t)D("complete value",void 0,this.options);if(r=e[n++],o|=(r&127)<<21,r<128)return this.pos=n,o;let s=268435456;for(let a=4;a<10;a++){if(n>=t)this.pos=n,D("complete value",void 0,this.options);r=e[n++];let i=(r&127)*s;if(i>Number.MAX_SAFE_INTEGER-o)this.pos=n,D("safe integer length",void 0,this.options);if(o+=i,r<128)return this.pos=n,o;s*=128}this.pos=n,D("uvarint",void 0,this.options)}fieldTag(){let e=this.buf,t=this.end,n=this.pos;if(n>=t)D("complete value",void 0,this.options);let r=e[n++];if(r<128)return this.pos=n,r;let o=r&127;if(n>=t)D("complete value",void 0,this.options);if(r=e[n++],o|=(r&127)<<7,r<128)return this.pos=n,o;if(n>=t)D("complete value",void 0,this.options);if(r=e[n++],o|=(r&127)<<14,r<128)return this.pos=n,o;if(n>=t)D("complete value",void 0,this.options);if(r=e[n++],o|=(r&127)<<21,r<128)return this.pos=n,o;if(n>=t)D("complete value",void 0,this.options);if(r=e[n++],this.pos=n,r>=128)D("uvarint",void 0,this.options);return o+r*268435456}uvarintBig(){let e=Um,t=Um;while(!0){let n=this.byte();if(e|=BigInt(n&127)<<t,(n&128)===0)return e;t+=QP}}numberVarint(){let e=this.buf,t=this.end,n=this.pos,r=0,o=1;for(let i=0;i<YP;i++){if(n>=t)this.pos=n,D("complete value",void 0,this.options);let c=e[n++];if(r+=(c&127)*o,c<128)return this.pos=n,nM(r);o*=128}let s=this.uvarintBig(),a=Number(s>>br);if(!Number.isFinite(a))D("safe integer length",void 0,this.options);return(s&br)===br?-a:a}zigzag(){let e=this.uvarintBig();return(e&br)===br?-(e+br>>br):e>>br}f64(){if(this.pos+8>this.end)D("complete value",void 0,this.options);let e=(this.view??this.dataView()).getFloat64(this.pos,!0);return this.pos+=8,e}i64(){if(this.pos+8>this.end)D("complete value",void 0,this.options);let e=(this.view??this.dataView()).getBigInt64(this.pos,!0);return this.pos+=8,e}u32le(){if(this.pos+4>this.end)D("complete value",void 0,this.options);let e=(this.view??this.dataView()).getUint32(this.pos,!0);return this.pos+=4,e}i32le(){if(this.pos+4>this.end)D("complete value",void 0,this.options);let e=(this.view??this.dataView()).getInt32(this.pos,!0);return this.pos+=4,e}}function MP(e,t){return{_:"literal",leaf:e,values:t,valueSet:t.length>4?new Set(t):void 0}}function td(e,t){let n=e.values;return e.valueSet!==void 0?e.valueSet.has(t):n.length===1?t===n[0]:n.includes(t)}function Hm(e){return e.values.map((t)=>typeof t==="string"?JSON.stringify(t):String(t)).join(" | ")}var _m=0,gE=1,aM=2,iM=3,cM=30,Rm=1<<cM;function jm(e){return e._==="literal"?jm(e.leaf):e._==="int"}function Wm(e){switch(e._){case"literal":return Wm(e.leaf);case"bool":return 1;case"int64":return 8;default:return}}function aE(e){return Wm(e)!==void 0||jm(e)||e._==="null"||e._==="undefined"}function fM(e){return e._==="literal"?fM(e.leaf):e._==="null"||e._==="undefined"}var Vu={"effect/schema/Date":{kind:Ue.int64,exact:!0},"effect/schema/DateTimeUtc":{kind:Ue.int64,exact:!0},"effect/schema/DateTimeZoned":{kind:Ue.dateTimeZoned,exact:!0},"effect/schema/Duration":{kind:Ue.duration,exact:!0},"effect/schema/BigDecimal":{kind:Ue.bigDecimal,exact:!0},"effect/schema/Uint8Array":{kind:Ue.bytes,exact:!0},"effect/schema/Option":{kind:Ue.option,exact:"parameters"},"effect/schema/Result":{kind:Ue.result,exact:"parameters"},"effect/schema/Exit":{kind:Ue.exit,exact:"parameters"},"effect/schema/Cause":{kind:Ue.cause,exact:"parameters"},"effect/schema/CauseReason":{kind:Ue.causeReason,exact:"parameters"}};function Lc(e){let t=e.annotations?.representation;return st(t)&&typeof t.id==="string"?t.id:void 0}var Pm=Wo((e)=>{let t=OW(e),n=e.context;if(t===e||n===void 0)return t;return _i(t,new sr(n.isOptional,n.isMutable,void 0,n.annotations))});function OW(e){switch(e._tag){case"Declaration":{let t=Lc(e);if(t!==void 0&&((t in Vu)||t==="effect/schema/Json"||t==="effect/schema/MutableJson"))return e.recur(Pm);let n=e.annotations?.toCodecJson,r=e.annotations?.toCodec;if(!On(n)&&!On(r))return e;let o=e.typeParameters.map((a)=>H(En(a))),s=(On(n)?n(o):void 0)??(On(r)?r(o):void 0);return s===void 0?e:Pe(e,[vs(s,Pm)])}case"Arrays":case"Objects":case"Union":case"Suspend":return e.recur(Pm);default:return e}}function _W(e){let t=[...e].sort((r,o)=>{let s=typeof r.key==="number",a=typeof o.key==="number";if(s!==a)return s?-1:1;if(s)return r.key-o.key;return oM(Bo.encode(r.key),Bo.encode(o.key))}),n=[];for(let r of t){let o=Bo.encode(String(r.key));n.push(typeof r.key==="number"?0:1),Dm(n,o.length),Fm(n,o);let s=r.literal,a=Bo.encode(dM(s));n.push(uM(s)),Dm(n,a.length),Fm(n,a)}return rM(n)}function uM(e){switch(typeof e){case"string":return 1;case"number":return 2;case"boolean":return 3;case"bigint":return 4;default:return 5}}function dM(e){if(typeof e==="symbol"){let t=globalThis.Symbol.keyFor(e);if(t===void 0)throw Error("Binary layout: unregistered unique symbol (Symbol.keyFor)");return t}return String(e)}function lM(e){switch(e._tag){case"Symbol":return!0;case"Union":return e.types.some(lM);default:return!1}}function pM(e){let t=Lc(e);if(t==="effect/schema/Json"||t==="effect/schema/MutableJson")return!0;return On(e.annotations?.toCodecJson)}function RW(e){let t=e.checks;if(t===void 0)return!1;let n=(r)=>{if(r.annotations?.representation?.id==="effect/schema/isInt")return!0;return r._tag==="FilterGroup"&&r.checks.some(n)};return t.some(n)}function mM(e){while(e._tag==="Suspend")e=e.thunk();return e}function hM(e){return new tn(e.enums.map((t)=>new yn(t[1],{title:t[0]})))}function UP(e){let t=[],n=new Set,r=(o)=>{let s=mM(o);if(n.has(s))return;switch(n.add(s),s._tag){case"Never":return;case"Union":s.types.forEach(r);return;case"Enum":hM(s).types.forEach(r);return;default:t.push(s)}};return e.types.forEach(r),t}function FP(e){switch(typeof e){case"string":return"string";case"number":return"number";case"boolean":return"bool";default:return"bigint"}}function Mm(e){switch(e._tag){case"String":case"TemplateLiteral":case"Symbol":return Ue.string;case"UniqueSymbol":if(globalThis.Symbol.keyFor(e.symbol)===void 0)throw Error("Binary layout: unregistered unique symbol (Symbol.keyFor)");return Ue.string;case"Boolean":return Ue.bool;case"Null":return Ue.null;case"Undefined":case"Void":return Ue.undefined;case"Number":return Ue.number;case"BigInt":return Ue.bigint;case"Literal":switch(typeof e.literal){case"string":return Ue.string;case"number":return Ue.number;case"boolean":return Ue.bool;default:return Ue.bigint}case"Unknown":case"Any":case"ObjectKeyword":return Ue.json;case"Objects":return Ue.struct;case"Arrays":return Ue.array;case"Declaration":{let t=Lc(e);if(t!==void 0&&t in Vu)return Vu[t].kind;if(pM(e))return Ue.json;throw Error(`Binary layout: declaration ${t??"<anonymous>"} has no toCodecJson or toCodec`)}case"Suspend":return Mm(mM(e));default:throw Error("Binary layout: union members are not uniquely identifiable")}}function DP(e){for(let t of e.fields){if(t.optional)continue;if(t.index<32)e.requiredMask|=1<<t.index;else e.requiredWide=!0}}function PW(e){let t=gM(e),n=!t&&MW(e);e=En(e);let r=new Map,o=!1,s=0,a=(p)=>({_:p,slot:p==="string"?s++:0});function i(p){let g=r.get(p);if(g!==void 0)return g;let h=c(p);return r.set(p,h),h}function c(p){switch(p._tag){case"String":case"TemplateLiteral":return a("string");case"Symbol":case"UniqueSymbol":return a("symbol");case"Boolean":return a("bool");case"Null":return a("null");case"Undefined":case"Void":return a("undefined");case"Number":return a(RW(p)?"int":"number");case"BigInt":return a("bigint");case"Literal":return MP(a(FP(p.literal)),[p.literal]);case"Unknown":case"Any":case"ObjectKeyword":return a("json");case"Never":return{_:"never",ast:p};case"Enum":return l(p,UP(hM(p)));case"Suspend":{o=!0;let g=i(p.thunk());return r.set(p,g),g}case"Objects":return f(p);case"Arrays":return u(p);case"Union":return l(p,UP(p));case"Declaration":return d(p)}}function f(p){let g=[],h=[],E=new Map;for(let I of p.propertySignatures){if(typeof I.name==="symbol")throw Error("Binary layout: symbol property names are illegal");let x=String(I.name),w=I.type.context?.annotations,C=w?.[oW],T=typeof C==="number"?C:rM(Bo.encode(x));if(!Number.isInteger(T)||T<0||T>4294967295)throw Error(`Binary layout: illegal field id for ${x}`);let v=E.get(T);if(v===void 0)E.set(T,[x]);else v.push(x);g.push({name:x,id:T,tagBytes:EW(T*Ir+ei),index:0,optional:I.type.context?.isOptional===!0,annotations:w,layout:void 0,wireMask:0,inline:!1}),h.push(I.type)}for(let[I,x]of E)if(I===0||x.length>1)throw Error(`Binary layout field id collision: ${I} (${x.join(", ")})`);let S=[];for(let I of p.indexSignatures){if(lM(I.parameter))throw Error("Binary layout: symbol property names are illegal");S.push({parameter:I.parameter,layout:void 0,wireMask:0})}let k={_:"struct",ast:p,fields:g,byId:new Map,extra:S,extraAll:S.length===1&&CW(S[0].parameter)?S[0]:void 0,names:new Set(g.map((I)=>I.name)),extraShape:void 0,optionalCount:0,requiredMask:0,requiredWide:!1};r.set(p,k);for(let I=0;I<g.length;I++){let x=g[I];if(x.layout=i(h[I]),x.wireMask=uE(x.layout),x.inline=aE(x.layout),x.optional)k.optionalCount++;k.byId.set(x.id,x)}g.sort((I,x)=>I.id-x.id);for(let I=0;I<g.length;I++)g[I].index=I;DP(k);for(let I=0;I<S.length;I++)S[I].layout=i(p.indexSignatures[I].type),S[I].wireMask=uE(S[I].layout);return k}function u(p){let g=p.rest.length>0||p.elements.some((k)=>k.context?.isOptional===!0),h=p.elements.filter((k)=>k.context?.isOptional!==!0).length,E=Math.max(0,p.rest.length-1),S={_:"array",ast:p,elements:[],rest:[],hasCount:g,minCount:h+E,uniform:void 0,uniformInline:!1,uniformPacked:void 0,uniformNumbers:!1,run:void 0};r.set(p,S);for(let k of p.elements)S.elements.push({optional:k.context?.isOptional===!0,layout:i(k)});for(let k of p.rest)S.rest.push(i(k));if(S.elements.length===0&&S.rest.length===1){let k=S.rest[0];S.uniform=k,S.uniformPacked=Wm(k),S.uniformNumbers=k._==="number",S.uniformInline=aE(k)}return S}function d(p){let g=Lc(p);switch(g){case"effect/schema/Date":return{_:"int64",flavor:"date"};case"effect/schema/DateTimeUtc":return{_:"int64",flavor:"utc"};case"effect/schema/DateTimeZoned":return a("dateTimeZoned");case"effect/schema/Duration":return a("duration");case"effect/schema/BigDecimal":return a("bigDecimal");case"effect/schema/Uint8Array":return a("bytes")}let h=p.typeParameters;switch(g){case"effect/schema/Option":{let E={_:"option",value:void 0};return r.set(p,E),E.value=i(h[0]),E}case"effect/schema/Result":{let E={_:"result",success:void 0,failure:void 0};return r.set(p,E),E.success=i(h[0]),E.failure=i(h[1]),E}case"effect/schema/Exit":{let E={_:"cause",error:void 0,defect:void 0},S={_:"exit",value:void 0,cause:E};return r.set(p,S),S.value=i(h[0]),E.error=i(h[1]),E.defect=i(h[2]),S}case"effect/schema/Cause":case"effect/schema/CauseReason":{let E={_:g==="effect/schema/Cause"?"cause":"causeReason",error:void 0,defect:void 0};return r.set(p,E),E.error=i(h[0]),E.defect=i(h[1]),E}}if(g!==void 0&&g in Vu)throw Error(`Binary layout: native declaration ${g} has no layout constructor`);if(pM(p))return a("json");throw Error(`Binary layout: declaration ${g??"<anonymous>"} has no toCodecJson or toCodec`)}function l(p,g){if(g.length===0)return{_:"never",ast:p};let h=[],E=[],S=new Map,k=new Map,I=(v,O)=>{let U=S.get(v);if(U!==void 0&&U._!==O._)throw Error("Binary layout: union members are not uniquely identifiable");S.set(v,O)};for(let v of g){if(v._tag==="Literal"){let O=Mm(v),U=k.get(O);if(U===void 0)k.set(O,[v.literal]);else if(!U.includes(v.literal))U.push(v.literal);continue}if(v._tag==="UniqueSymbol"){Mm(v),I(Ue.string,a("symbol"));continue}if(v._tag==="Objects"||v._tag==="Arrays"){let O=ks(v);if(O!==void 0&&O.length>0){for(let U of O)if(typeof U.key==="symbol")throw Error("Binary layout: symbol property names are illegal");h.push({member:v,sentinels:O});continue}}E.push({member:v,kind:Mm(v)})}for(let[v,O]of k)I(v,MP(a(FP(O[0])),O));if(h.length===0&&E.length===0&&S.size===1)return S.values().next().value;let x=new Set(S.keys());for(let{kind:v}of E){if(x.has(v))throw Error("Binary layout: union members are not uniquely identifiable");x.add(v)}if(h.length===0&&S.size===0&&E.length===1){let v=i(E[0].member);return r.set(p,v),v}let w=new Map,C=[];for(let{sentinels:v}of h){let O=_W(v);if(w.has(O))throw Error(`Binary layout sentinel collision: ${O}`);w.set(O,v),C.push(O)}let T={_:"union",ast:p,variants:[],byTag:new Map,discriminator:void 0,others:[],byKind:new Map,byPos:[]};r.set(p,T);for(let v=0;v<h.length;v++){let{member:O,sentinels:U}=h[v],j=C[v],X=i(O),J,N;if(O._tag==="Objects"){let fe=X,Ge=new Set(U.map((wt)=>String(wt.key))),Ot=fe.fields.filter((wt)=>!Ge.has(wt.name)),et={_:"struct",ast:fe.ast,fields:Ot,byId:new Map(Ot.map((wt)=>[wt.id,wt])),extra:fe.extra,extraAll:fe.extraAll,names:fe.names,extraShape:void 0,optionalCount:Ot.reduce((wt,ti)=>ti.optional?wt+1:wt,0),requiredMask:0,requiredWide:!1};DP(et),J=et,N=!1}else J=X,N=!0;let G={tag:j,sentinels:U,tuple:N,payload:J,position:0};T.variants.push(G),T.byTag.set(j,G)}for(let[v,O]of S)T.others.push({kind:v,layout:O,position:0}),T.byKind.set(v,O);for(let{kind:v,member:O}of E){let U=i(O);T.others.push({kind:v,layout:U,position:0}),T.byKind.set(v,U)}for(let v of[...T.variants].sort((O,U)=>O.tag-U.tag))v.position=T.byPos.length,T.byPos.push({variant:v,layout:v.payload});for(let v of[...T.others].sort((O,U)=>O.kind-U.kind))v.position=T.byPos.length,T.byPos.push({variant:void 0,layout:v.layout});return T.others.sort((v,O)=>NP(v.layout)-NP(O.layout)),T.discriminator=cJ(T.variants),T}return{layout:i(e),recursive:o,exact:t,exitSuccess:n}}function gM(e){let t=new Map,n=(r)=>{if(r.encoding!==void 0||r.checks!==void 0||r.encodingChecks!==void 0)return!1;switch(r._tag){case"String":case"Symbol":case"Boolean":case"Null":case"Undefined":case"Void":case"Number":case"BigInt":case"Literal":return!0;case"Never":return!0;case"Unknown":case"Any":return!0;case"Arrays":return r.elements.every(n)&&r.rest.every(n);case"Objects":return r.propertySignatures.every((o)=>n(o.type))&&r.indexSignatures.every((o)=>o.parameter._tag==="String"&&n(o.parameter)&&n(o.type));case"Union":return(r.options?.mode??"anyOf")==="anyOf"&&r.types.every(n);case"Suspend":{let o=t.get(r);if(o!==void 0)return o;t.set(r,!0);let s=n(r.thunk());return t.set(r,s),s}case"Declaration":{let o=Lc(r),s=o!==void 0?Vu[o]:void 0;if(s===void 0)return!1;return s.exact===!0||r.typeParameters.every(n)}default:return!1}};return n(e)}function MW(e){return e._tag==="Declaration"&&e.encoding===void 0&&e.checks===void 0&&e.encodingChecks===void 0&&Lc(e)==="effect/schema/Exit"&&gM(e.typeParameters[0])}var Nn={backEdge:0,bool:1,null:2,undefined:3,number:4,int:5,string:6,symbol:7,bytes:8,bigint:9,json:10,duration:11,bigDecimal:12,dateTimeZoned:13,date:14,dateTimeUtc:15,never:16,struct:17,array:18,union:19,option:20,result:21,exit:22,cause:23,causeReason:24,literal:25};function UW(e){let t=new Map,n=[],r=Number.MAX_SAFE_INTEGER;function o(a){let i=n.lastIndexOf(a);if(i>=0){if(i<r)r=i;let m=[Nn.backEdge];return ea(m,n.length-i),RP(m)}let c=t.get(a);if(c!==void 0)return c;let f=n.length,u=r;r=Number.MAX_SAFE_INTEGER,n.push(a);let d=RP(s(a));n.pop();let l=r>=f;if(l)t.set(a,d);return r=l?u:Math.min(u,r),d}function s(a){let i=[];switch(a._){case"bool":case"null":case"undefined":case"number":case"int":case"string":case"symbol":case"bytes":case"bigint":case"json":case"duration":case"bigDecimal":case"dateTimeZoned":return i.push(Nn[a._]),i;case"literal":{i.push(Nn.literal),Fm(i,s(a.leaf)),ea(i,a.values.length);let c=a.values.map((f)=>[uM(f),dM(f)]).sort((f,u)=>f[1]<u[1]?-1:f[1]>u[1]?1:f[0]-u[0]);for(let[f,u]of c){i.push(f);let d=Bo.encode(u);ea(i,d.length),Fm(i,d)}return i}case"int64":return i.push(a.flavor==="date"?Nn.date:Nn.dateTimeUtc),i;case"never":return i.push(Nn.never),i;case"struct":{i.push(Nn.struct),ea(i,a.fields.length);for(let c of a.fields)Dm(i,c.id),i.push(c.optional?1:0),tr(i,o(c.layout));ea(i,a.extra.length);for(let c of a.extra)tr(i,o(c.layout));return i}case"array":{i.push(Nn.array),ea(i,a.elements.length);for(let c of a.elements)i.push(c.optional?1:0),tr(i,o(c.layout));ea(i,a.rest.length);for(let c of a.rest)tr(i,o(c));return i}case"union":{i.push(Nn.union),ea(i,a.byPos.length);for(let c of a.byPos){let f=c.variant;if(f===void 0)i.push(0);else i.push(1,f.tuple?1:0),Dm(i,f.tag);tr(i,o(c.layout))}return i}case"option":return i.push(Nn.option),tr(i,o(a.value)),i;case"result":return i.push(Nn.result),tr(i,o(a.success)),tr(i,o(a.failure)),i;case"exit":return i.push(Nn.exit),tr(i,o(a.value)),tr(i,o(a.cause.error)),tr(i,o(a.cause.defect)),i;case"cause":case"causeReason":return i.push(a._==="cause"?Nn.cause:Nn.causeReason),tr(i,o(a.error)),tr(i,o(a.defect)),i}}return o(e)}function FW(e,t){let n=new Uint8Array(8);for(let r=0;r<4;r++)n[r]=e>>>r*8&255,n[r+4]=t>>>r*8&255;return n}var DW={positional:!1,envelope:sW,expectedEnvelope:"version 2 envelope, flags 0",fingerprint:new Uint8Array(8)};function NW(e){let t=UW(e);return{positional:!0,envelope:aW,expectedEnvelope:"version 2 envelope, flags 1",fingerprint:FW(Number(t&vP),Number(t>>uW&vP))}}function NP(e){switch(e._){case"json":return 2;case"struct":return 1;default:return 0}}function iE(e,t){switch(e._){case"literal":return td(e,t);case"bool":return typeof t==="boolean";case"null":return t===null;case"undefined":return t===void 0;case"number":case"int":return typeof t==="number";case"string":return typeof t==="string";case"symbol":return typeof t==="symbol";case"bigint":return typeof t==="bigint";case"bytes":return t instanceof Uint8Array;case"int64":return e.flavor==="date"?t instanceof Date:sa(t)&&t._tag==="Utc";case"dateTimeZoned":return sa(t)&&t._tag==="Zoned";case"duration":return tc(t);case"bigDecimal":return ra(t);case"option":return Xi(t);case"result":return ec(t);case"exit":return Zo(t);case"cause":return rc(t);case"causeReason":return oc(t);case"array":return Array.isArray(t);case"struct":return st(t)&&!Array.isArray(t);case"json":return!0;case"union":case"never":return!1}}function _e(e,t,n){throw yt(new te({expected:e},t,n))}function ln(e,t=new Set){if(!Ku(e))return!1;let n=Array.isArray(e),r=Object.getPrototypeOf(e);if(n||r===Object.prototype||r===null){if(t.has(e))return!0;t.add(e);try{if(n){for(let o=0;o<e.length;o++)if(ln(e[o],t))return!0}else for(let o of Object.keys(e))if(ln(e[o],t))return!0}finally{t.delete(e)}return!1}if(e instanceof Date||e instanceof Uint8Array||sa(e)||tc(e)||ra(e))return!1;if(t.has(e))return!0;t.add(e);try{if(Xi(e))return ve(e)&&ln(e.value,t);if(ec(e))return ln(At(e)?e.success:e.failure,t);if(Zo(e))return ln($e(e)?e.value:e.cause,t);if(rc(e))return e.reasons.some((o)=>ln(o,t));if(oc(e))switch(e._tag){case"Fail":return ln(e.error,t);case"Die":return ln(e.defect,t);case"Interrupt":return!1}if(si(e)){for(let o of e)if(ln(o,t))return!0;return!1}if(wd(e)){for(let[o,s]of e)if(ln(o,t)||ln(s,t))return!0;return!1}if(Ad(e)){for(let o of e)if(ln(o,t))return!0;return!1}if(of(e))return ln(Rr(e),t);for(let o of Object.keys(e))if(ln(e[o],t))return!0}finally{t.delete(e)}return!1}function Bm(e,t,n,r){let o=r.beginSized();Dt(e,t,n,r),r.endSized(o)}function BW(e,t,n){let r=globalThis.Symbol.keyFor(t);if(r===void 0)_e("registered symbol",t,e.options);n.string(r)}function BP(e,t,n,r){let o=n;switch(o._tag){case"Fail":r.byte(0),Dt(e,t.error,o.error,r);return;case"Die":r.byte(1),Dt(e,t.defect,o.defect,r);return;case"Interrupt":if(o.fiberId===void 0)r.byte(2);else r.byte(3),r.f64(o.fiberId)}}function LW(e){for(let t=0;t<e.length;t++)if(e.charCodeAt(t)>127)return!1;return!0}function LP(e,t,n){if(e.layout!==t||e.keys.length!==n.length)return!1;for(let r=0;r<n.length;r++)if(e.keys[r]!==n[r])return!1;return!0}function zW(e,t){if(e.extraAll===void 0||t.length>TW)return!1;let n=0;for(let r=0;r<t.length;r++)if(n+=t[r].length,n>AW)return!1;return!0}function xE(e,t,n){let r=Object.keys(n),o=t.extraShape;if(o!==void 0&&LP(o,t,r))return o.pairs;let s=zW(t,r),a=s?void 0:e.extraShape;if(a!==void 0&&LP(a,t,r))return a.pairs;let{names:i,extraAll:c}=t,f=[],u=!0;for(let l of r){if(i.has(l))continue;let m=c??(e.indexSignatures??=new $m(e.options)).find(t,l);if(m===void 0)continue;if(u&&!LW(l))u=!1;f.push([l,m,void 0])}if(u)f.sort((l,m)=>l[0]<m[0]?-1:l[0]>m[0]?1:0);else{for(let l of f)l[2]=Bo.encode(l[0]);f.sort((l,m)=>oM(l[2],m[2]))}if(s)for(let l of f)l[2]??=Bo.encode(l[0]);let d={layout:t,keys:r,pairs:f};if(s)t.extraShape=d;else e.extraShape=d;return f}function yE(e,t,n,r,o){for(let[s,a,i]of t){let c=i===void 0?s.length:i.length,f=n[s],u=SE(a.layout,f,e.options),d=u%Ir;if(o===void 0)r.uvarint(c*Ir+d);else{if(!o.disabled){let l=yM(o,s);if(l!==void 0){r.uvarint(l*16+d*2+1),Ee[W++]=s,cE(e,a.layout,f,u,r),W--;continue}SM(o,s)}r.uvarint(c*16+d*2)}if(i===void 0)r.string(s);else r.bytes(i);Ee[W++]=s,cE(e,a.layout,f,u,r),W--}}function SE(e,t,n){if(e._==="literal"){if(!td(e,t))_e(Hm(e),t,n);return SE(e.leaf,t,n)}switch(e._){case"bool":if(typeof t!=="boolean")_e("a boolean",t,n);return t?Xu:Yu;case"number":if(typeof t!=="number")_e("a number",t,n);if(pE(t))return Ya;{let r=mE(t);return r===0?Qu:r*Ir+ed}case"int":if(!Number.isSafeInteger(t))_e("an integer",t,n);return Ya;default:return ei}}function cE(e,t,n,r,o){switch(r%Ir){case Yu:case Xu:return;case Ya:o.numberVarint(n);return;case Qu:o.f64(n);return;case ed:{let a=Math.floor(r/Ir);o.numberVarint(Math.round(n*ta[a])),o.uvarint(a);return}default:Bm(e,t,n,o)}}function $W(e,t,n,r){let o=SE(t.layout,n,e.options),s=o%Ir;if(s===ei){let a=r.idAndMark(t.tagBytes);Dt(e,t.layout,n,r),r.endSized(a);return}r.uvarint(t.id*Ir+s),cE(e,t.layout,n,o,r)}function qW(e,t){let n=e.byName;if(n===void 0)return;let r=Object.getOwnPropertyNames(t),o=0;for(let a=0;a<r.length;a++){let i=n.get(r[a]);if(i!==void 0)o|=1<<i}let s=e.struct;if((o&s.requiredMask)!==s.requiredMask){let a=s.fields;for(let i=0;i<a.length;i++){let c=a[i];if(!c.optional&&(o&1<<i)===0)throw Ee[W++]=c.name,yt(new ot(c.annotations))}}return o}function HW(e,t,n,r){let o=n;if(t.extra.length>0){let a=e.intern;e.intern=void 0;let i=xE(e,t,o);if(i.length>0){r.uvarint(0);let c=r.beginSized();yE(e,i,o,r,a),r.endSized(c)}}let s=t.fields;for(let a=0;a<s.length;a++){let i=s[a],c=i.name;if(!Object.hasOwn(o,c)){if(i.optional)continue;throw Ee[W++]=c,yt(new ot(i.annotations))}Ee[W++]=c,$W(e,i,o[c],r),W--}}function jW(e,t,n,r){let o=n,s=e.intern;e.intern=void 0;let a=t.optionalCount+7>>3,i=0;if(a>0){i=r.len;for(let u=0;u<a;u++)r.byte(0)}let c=t.fields,f=0;for(let u=0;u<c.length;u++){let d=c[u],l=d.name,m=Object.hasOwn(o,l);if(d.optional){if(m)r.buf[r.start+i+(f>>3)]|=1<<(f&7);if(f++,!m)continue}else if(!m)throw Ee[W++]=l,yt(new ot(d.annotations));if(Ee[W++]=l,d.inline)Dt(e,d.layout,o[l],r);else Bm(e,d.layout,o[l],r);W--}if(t.extra.length>0){let u=xE(e,t,o);r.uvarint(u.length),yE(e,u,o,r,s)}}function WW(e){switch(e._){case"string":return gE;case"array":return e.uniform?._==="string"?aM:_m;case"struct":return e.extra.length>0?iM:_m;default:return _m}}function JW(e){let t=e.uniform;if(t===void 0){if(e.rest.length!==1)return;t=e.rest[0];for(let n of e.elements)if(n.optional||n.layout!==t)return}return t._==="struct"?t:void 0}function xM(e){let t=e.run;if(t!==void 0)return t;let n=JW(e);if(n===void 0)return e.run=t=null,t;let r=n.fields.map((s)=>WW(s.layout)),o=n.fields.length<=cM;return t={struct:n,intern:r,shapes:o,byName:o&&n.extra.length===0?new Map(n.fields.map((s,a)=>[s.name,a])):void 0},e.run=t,t}var GW=16,KW=64;function zP(e,t){return e[t]??={values:[],refs:void 0,hits:0,disabled:!1}}function yM(e,t){let n=e.refs;if(n!==void 0){let o=n.get(t);if(o!==void 0)e.hits++;return o}let r=e.values;for(let o=0;o<r.length;o++)if(r[o]===t)return e.hits++,o;return}function SM(e,t){let n=e.values;if(e.refs!==void 0){if(e.hits===0&&n.length>=KW){e.disabled=!0,e.refs=void 0;return}e.refs.set(t,n.length)}else if(n.length>=GW){let r=e.refs=new Map;for(let o=0;o<n.length;o++)r.set(n[o],o);r.set(t,n.length)}n.push(t)}var EE=0,VW=1,bE=2,ZW=64,QW=512;function YW(){return{slots:[],marks:[],frame:0}}function EM(e,t){return e[t]??={values:[],refs:new Map,state:EE,stamp:-1}}function bM(e,t){if(e.refs.has(t)){e.state=VW;return}if(e.refs.set(t,e.values.length),e.values.push(t),e.values.length>=ZW)e.state=bE}function IM(e,t){let n=e.values;if(n.length>=QW)return;e.refs.set(t,n.length),n.push(t)}function XW(e,t){if(t.stamp===e.frame)return;t.stamp=e.frame,e.marks.push({slot:t,length:t.values.length,state:t.state})}function eJ(e){e.marks.length=0,e.frame++}function tJ(e){let t=e.marks;for(let n=t.length-1;n>=0;n--){let{length:r,slot:o,state:s}=t[n],a=o.values;for(let i=r;i<a.length;i++)o.refs.delete(a[i]);a.length=r,o.state=s}t.length=0,e.frame++}function nJ(e,t,n,r){let o=EM(e.slots,t.slot),s=o.state;if(s===bE){r.string(n);return}if(XW(e,o),s===EE){r.string(n),bM(o,n);return}let a=o.refs.get(n);if(a!==void 0){r.uvarint(a*2+1);return}r.byte(0),IM(o,n),r.string(n)}function rJ(e,t,n){let r=EM(e,t.slot),o=r.state;if(o===bE)return n.readUtf8(n.end-n.pos);if(o===EE){let i=n.readUtf8(n.end-n.pos);return bM(r,i),i}let s=n.uvarint();if((s&1)===1){let i=(s-1)/2,c=r.values;if(i>=c.length)D("a dictionary reference",s,n.options);return c[i]}if(s!==0)D("a dictionary marker",s,n.options);let a=n.readUtf8(n.end-n.pos);return IM(r,a),a}function wM(e,t,n,r,o){if(!e.disabled){let a=yM(e,r);if(a!==void 0){o.uvarint(a*2+1);return}SM(e,r)}let s=o.beginSized();Dt(t,n,r,o),o.endSizedRun(s)}function oJ(e,t,n,r,o){let s=[],a=[];for(let i=0;i<r;i++){Ee[W++]=i;let c=o.beginSized();sJ(e,t,s,a,n[i],o),o.endSized(c),W--}}function sJ(e,t,n,r,o,s){let a=t.struct,i=o,c=a.fields,f;if(a.extra.length>0){let h=xE(e,a,i);if(h.length>0)f=h}let u=!t.shapes,d=f===void 0?0:Rm,l=qW(t,i);if(l!==void 0)d=l;else for(let h=0;h<c.length;h++){let E=c[h];if(Object.hasOwn(i,E.name)){if(!u)d|=1<<h}else if(!E.optional)throw Ee[W++]=E.name,yt(new ot(E.annotations))}let m=-1;for(let h=0;h<n.length;h++)if(n[h]===d){m=h;break}if(m>=0)s.uvarint(m+1);else if(s.uvarint(0),!u)n.push(d);let p=m<0,g=e.positional&&!u;if(p&&g)s.uvarint(d);if(f!==void 0){if(p&&!g)s.uvarint(0);let h=s.beginSized();yE(e,f,i,s),s.endSizedRun(h)}for(let h=0;h<c.length;h++){let E=c[h];if(u?!Object.hasOwn(i,E.name):(d&1<<h)===0)continue;if(p&&!g)s.uvarint(E.id);Ee[W++]=E.name;let S=t.intern[h];if(S===gE)wM(zP(r,h),e,E.layout,i[E.name],s);else{if(S!==_m)e.intern=zP(r,h);let k=s.beginSized();Dt(e,E.layout,i[E.name],s),s.endSizedRun(k),e.intern=void 0}W--}}function kM(e,t,n){let r=e.elements.length;if(t<r)return e.elements[t].layout;let o=Math.max(0,e.rest.length-1),s=Math.max(r,n-o);return t>=s?e.rest[t-s+1]:e.rest[0]}function aJ(e,t,n,r){let o=n.length;if(t.rest.length===0&&o>t.elements.length)throw Ee[W++]=t.elements.length,yt(new ma(t.ast,n[t.elements.length],e.options));if(o<t.minCount)throw Ee[W++]=o,yt(new ot(void 0));if(t.hasCount)r.uvarint(o);if(o>0){let a=xM(t);if(a!==null){oJ(e,a,n,o,r);return}}let s=t.uniform;if(s!==void 0){if(t.uniformNumbers){iJ(e,n,o,r);return}let a=e.intern;if(e.intern=void 0,a!==void 0){for(let c=0;c<o;c++)Ee[W++]=c,wM(a,e,s,n[c],r),W--;return}let i=t.uniformInline;for(let c=0;c<o;c++){if(Ee[W++]=c,i)Dt(e,s,n[c],r);else Bm(e,s,n[c],r);W--}return}for(let a=0;a<o;a++){let i=kM(t,a,o);if(Ee[W++]=a,aE(i))Dt(e,i,n[a],r);else Bm(e,i,n[a],r);W--}}var $P=[];function iJ(e,t,n,r){let o=!0,s=!0;for(let a=0;a<n;a++){let i=t[a];if(typeof i!=="number")Ee[W++]=a,_e("a number",i,e.options);if(pE(i)){if((i<0?-i:i)>nE)s=!1}else{o=!1;let c=mE(i);if(c===0)s=!1;else $P[a]=c}if(!o&&!s)break}if(o){r.byte(eM);for(let a=0;a<n;a++)r.numberVarint(t[a])}else if(s){r.byte(tM);for(let a=0;a<n;a++){let i=t[a],c=Number.isInteger(i)?0:$P[a],f=c===0?i:Math.round(i*ta[c]),u=f<0||f===0&&1/f<0,d=u?-f:f;r.uvarint((d*2+(u?1:0))*16+c)}}else{r.byte(XP);for(let a=0;a<n;a++)r.f64(t[a])}}function cJ(e){if(e.length<2||e.some((t)=>t.tuple))return;for(let t of e[0].sentinels){let n=new Map;for(let r of e){let o=r.sentinels.find((s)=>s.key===t.key);if(o===void 0||n.has(o.literal)||Number.isNaN(o.literal))break;n.set(o.literal,r)}if(n.size===e.length)return{key:t.key,rows:n}}return}function fE(e,t){let n=e.sentinels;for(let r=0;r<n.length;r++){let{key:o,literal:s}=n[r];if(t[o]!==s||!Object.hasOwn(t,o))return!1}return!0}function fJ(e,t){return e.tuple?Array.isArray(t)&&fE(e,t):st(t)&&!Array.isArray(t)&&fE(e,t)}function qP(e,t,n,r){if(e.positional)r.uvarint(t.position);else r.byte(Ue.variant),r.u32le(t.tag);Dt(e,t.payload,n,r)}function uJ(e,t,n,r){let o=t.discriminator;if(o!==void 0){if(st(n)&&!Array.isArray(n)){let s=n,a=o.rows.get(s[o.key]);if(a!==void 0&&fE(a,s)){qP(e,a,n,r);return}}}else for(let s of t.variants)if(fJ(s,n)){qP(e,s,n,r);return}for(let s of t.others)if(iE(s.layout,n)){if(e.positional)r.uvarint(s.position);else r.byte(s.kind);Dt(e,s.layout,n,r);return}throw yt(new Fe(t.ast,n,e.options))}function Dt(e,t,n,r){switch(t._){case"literal":if(!td(t,n))_e(Hm(t),n,e.options);Dt(e,t.leaf,n,r);return;case"bool":if(typeof n!=="boolean")_e("a boolean",n,e.options);r.byte(n===!0?1:0);return;case"null":if(n!==null)_e("null",n,e.options);return;case"undefined":if(n!==void 0)_e("undefined",n,e.options);return;case"number":{if(typeof n!=="number")_e("a number",n,e.options);if(pE(n)){r.numberVarint(n);return}let o=mE(n);if(o>0)r.numberVarint(Math.round(n*ta[o])),r.byte(o);else r.f64(n);return}case"int":{if(!Number.isSafeInteger(n))_e("an integer",n,e.options);r.numberVarint(n);return}case"string":{if(typeof n!=="string")_e("a string",n,e.options);let o=e.dict;if(o===void 0)r.string(n);else nJ(o,t,n,r);return}case"symbol":if(typeof n!=="symbol")_e("a symbol",n,e.options);BW(e,n,r);return;case"bytes":if(!(n instanceof Uint8Array))_e("a Uint8Array",n,e.options);r.bytes(n);return;case"bigint":if(typeof n!=="bigint")_e("a bigint",n,e.options);r.zigzag(n);return;case"int64":{if(!iE(t,n))_e(t.flavor==="date"?"a Date":"a DateTime.Utc",n,e.options);let o=t.flavor==="date"?n.getTime():n.epochMilliseconds;if(Number.isNaN(o))_e("a valid Date",n,e.options);r.i64(BigInt(o));return}case"dateTimeZoned":{if(!iE(t,n))_e("a DateTime.Zoned",n,e.options);let o=n;if(r.i64(BigInt(o.epochMilliseconds)),o.zone._tag==="Offset")r.byte(0),r.i32le(o.zone.offset);else r.byte(1),r.string(o.zone.id);return}case"duration":{if(!tc(n))_e("a Duration",n,e.options);let o=n.value;switch(o._tag){case"Infinity":r.byte(1);return;case"NegativeInfinity":r.byte(2);return;case"Nanos":r.byte(0),r.zigzag(o.nanos);return;case"Millis":r.byte(0),r.zigzag(BigInt(o.millis)*cW);return}}case"bigDecimal":{if(!ra(n))_e("a BigDecimal",n,e.options);let o=Gc(n);r.zigzag(o.value),r.zigzag(BigInt(o.scale));return}case"json":{let o;try{o=JSON.stringify(n)}catch{o=void 0}if(o===void 0){if(ln(n))_e("acyclic value",n,e.options);_e("a JSON-serializable value",n,e.options)}r.string(o);return}case"option":{if(!Xi(n))_e("an Option",n,e.options);let o=n;if(o._tag==="None")r.byte(0);else r.byte(1),Dt(e,t.value,o.value,r);return}case"result":{if(!ec(n))_e("a Result",n,e.options);let o=n;if(o._tag==="Success")r.byte(0),Dt(e,t.success,o.success,r);else r.byte(1),Dt(e,t.failure,o.failure,r);return}case"exit":{if(!Zo(n))_e("an Exit",n,e.options);let o=n;if(o._tag==="Success")r.byte(0),Dt(e,t.value,o.value,r);else r.byte(1),Dt(e,t.cause,o.cause,r);return}case"cause":{if(!rc(n))_e("a Cause",n,e.options);let o=n.reasons;r.uvarint(o.length);for(let s of o){let a=r.beginSized();BP(e,t,s,r),r.endSized(a)}return}case"causeReason":{if(!oc(n))_e("a Cause.Reason",n,e.options);BP(e,t,n,r);return}case"struct":{if(!st(n)||Array.isArray(n))_e("an object",n,e.options);if(e.positional)jW(e,t,n,r);else HW(e,t,n,r);return}case"array":{if(!Array.isArray(n))_e("an array",n,e.options);aJ(e,t,n,r);return}case"union":uJ(e,t,n,r);return;case"never":throw yt(new Fe(t.ast,n,e.options))}}var vm=new hE;function HP(e,t,n,r,o){let s=o.beginSized();if(o.byte(r.envelope),r.positional)o.bytes(r.fingerprint);Dt(e,t,n,o),o.endSized(s)}function TM(e,t,n,r,o,s){let a={options:r,positional:o.positional,indexSignatures:void 0,extraShape:void 0,intern:void 0,dict:s},i=vm??new hE,c=i===vm;if(c)vm=void 0;i.reset();let f=W,u=!1;try{if(n===void 0)W=0,HP(a,e,t,o,i);else for(let l=0;l<n.length;l++)W=0,HP(a,e,n[l],o,i);let d=i.out();return u=!0,d}finally{if(s!==void 0)if(u)eJ(s);else tJ(s);if(i.abort(),W=f,c)vm=i}}function AM(e,t,n,r,o){return TM(e,void 0,t,n,r,o)}function Lm(e,t,n,r,o){return TM(e,t,void 0,n,r,o)}function Jm(e){return Zo(e)&&$e(e)}var vt=globalThis.Symbol.for("~effect/encoding/SchemaBinary/absent");function Kt(e,t){let n=Zu(e,t);if(n!==vt&&t.pos!==t.end)D("no leftover bytes",void 0,t.options);return n}function CM(e,t){let n=t.enter(t.uvarint()),r=Kt(e,t);return t.exit(n),r}function vM(e,t){if(jm(e))return Zu(e,t);let n=Wm(e),r=t.enter(n!==void 0?n:e._==="null"||e._==="undefined"?0:t.uvarint()),o=Kt(e,t);return t.exit(r),o}var dJ=8;function lJ(e,t){let n=e.set;if(n!==void 0){if(n.has(t))return!0;return n.add(t),!1}let r=e.list;if(r.includes(t))return!0;if(r.length>=dJ){let o=e.set=new Set;for(let s=0;s<r.length;s++)o.add(r[s]);o.add(t)}else r.push(t);return!1}function OM(e,t,n,r,o){let s=t.uvarint(),a=o===void 0?Math.floor(s/Ir):Math.floor(s/16),i=o===void 0?s-a*Ir:Math.floor((s-a*16)/2),c=o===void 0?t.readUtf8(a):pJ(o,s,a,t);if(e.names.has(c))D("an extra key distinct from declared fields",c,t.options);if(lJ(r,c))D("unique extra keys",void 0,t.options);let f=e.extraAll??(t.indexSignatures??=new $m(t.options)).find(e,c);if(f===void 0){IE(i,t);return}Ee[W++]=c;let u=PM(f.layout,f.wireMask,i,t);if(W--,u!==vt)q(n,c,u)}function pJ(e,t,n,r){if((t&1)===1){if(n>=e.length)D("a known back-reference",void 0,r.options);return e[n]}let o=r.readUtf8(n);return e.push(o),o}function _M(e){return new Qe([e.name],new ot(e.annotations))}function RM(e,t){throw yt(new tt(e.ast,t))}function XS(e){while((e.byte()&128)!==0);}function IE(e,t){switch(e){case ei:t.take(t.uvarint());return;case Ya:XS(t);return;case Qu:t.take(8);return;case Yu:case Xu:case gW:return;case ed:XS(t),XS(t);return;case hW:t.take(4);return}}function uE(e){if(e._==="literal")return uE(e.leaf);switch(e._){case"bool":return 1<<Yu|1<<Xu;case"number":return 1<<Ya|1<<Qu|1<<ed;case"int":return 1<<Ya;default:return 1<<ei}}function mJ(e,t){switch(e){case Yu:return!1;case Xu:return!0;case Ya:return t.numberVarint();case Qu:return t.f64();case ed:{let n=t.numberVarint(),r=t.uvarint();if(r===0||r>zm)D("a decimal scale in [1, 8]",r,t.options);return n/ta[r]}}return D("matching field wire kind",void 0,t.options)}function PM(e,t,n,r){if((t&1<<n)===0)return IE(n,r),vt;if(n!==ei){let a=mJ(n,r);if(e._==="literal"&&!td(e,a))D(Hm(e),a,r.options);return a}let o=r.enter(r.uvarint()),s=Kt(e,r);return r.exit(o),s}function hJ(e,t){let n;if(e.extra.length>0)n=t.intern,t.intern=void 0;let r={},o=0,s=0,a,i,c,f=!1,u=e.fields,d=0;while(t.pos<t.end){let l=t.fieldTag(),m=Math.floor(l/Ir),p=l-m*Ir;if(m===0){if(f)D("unique field ids",void 0,t.options);if(f=!0,p!==ei)D("extra field map",void 0,t.options);let S=t.enter(t.uvarint());UM(e,t,r,n),t.exit(S);continue}let g;if(d<u.length&&u[d].id===m)g=u[d],d++;else if(g=e.byId.get(m),g!==void 0)d=g.index+1;if(g===void 0){if(c===void 0)c=new Set;else if(c.has(m))D("unique field ids",void 0,t.options);c.add(m),IE(p,t);continue}let h=g.index;if(h<32){let S=1<<h;if((o&S)!==0)D("unique field ids",void 0,t.options);o|=S}else if(a===void 0)a=new Set([h]);else{if(a.has(h))D("unique field ids",void 0,t.options);a.add(h)}Ee[W++]=g.name;let E=PM(g.layout,g.wireMask,p,t);if(W--,E!==vt)if(q(r,g.name,E),h<32)s|=1<<h;else(i??=new Set).add(h)}return MM(e,s,i,t),r}function MM(e,t,n,r){if((t&e.requiredMask)===e.requiredMask&&!e.requiredWide)return;let o=e.fields,s;for(let a=0;a<o.length;a++){let i=o[a],c=i.index,f=c<32?(t&1<<c)!==0:n?.has(c)===!0;if(!i.optional&&!f){if((s??=[]).push(_M(i)),r.options.errors!=="all")break}}if(s!==void 0)RM(e,s)}function gJ(e,t){let n;if(e.extra.length>0)n=t.intern,t.intern=void 0;let r={},o=e.optionalCount+7>>3,s=0;if(o>0){if(t.pos+o>t.end)D("complete value",void 0,t.options);s=t.pos,t.pos+=o}let a=t.buf,i=e.fields,c=0,f;for(let u=0;u<i.length;u++){let d=i[u];if(d.optional){let m=(a[s+(c>>3)]&1<<(c&7))!==0;if(c++,!m)continue}Ee[W++]=d.name;let l=d.inline?vM(d.layout,t):CM(d.layout,t);if(W--,l!==vt)q(r,d.name,l);else if(!d.optional){if((f??=[]).push(_M(d)),t.options.errors!=="all")break}}if(f!==void 0)RM(e,f);if(e.extra.length>0){let u=t.uvarint();if(u>t.remaining)D("complete value",void 0,t.options);if(u>0){let d={list:[],set:void 0};for(let l=0;l<u;l++)OM(e,t,r,d,n)}}return r}function UM(e,t,n,r){let o={list:[],set:void 0};while(t.pos<t.end)OM(e,t,n,o,r)}function xJ(e,t,n){let r=n.uvarint();if((r&1)===1){let a=(r-1)/2;if(a>=e.length)D("a known back-reference",void 0,n.options);return e[a]}if(t._==="string"){if(n.dict!==void 0){let i=n.enter(r/2),c=Kt(t,n);return n.exit(i),e.push(c),c}let a=n.readUtf8(r/2);return e.push(a),a}let o=n.enter(r/2),s=Kt(t,n);return n.exit(o),e.push(s),s}function yJ(e,t,n){let r=Array(t),o=[],s=[];for(let a=0;a<t;a++){Ee[W++]=a;let i=n.enter(n.uvarint());r[a]=EJ(e,o,s,n),n.exit(i),W--}return r}function SJ(e,t){let n=t.uvarint(),r=e.fields,o=n&~Rm;if(n>Rm*2-1||o>>>r.length!==0)D("a known row shape",void 0,t.options);let s=[];if((n&Rm)!==0)s.push(null);for(let a=0;a<r.length;a++)if((o&1<<a)!==0)s.push(r[a]);return s}function EJ(e,t,n,r){let o=e.struct,s={},a=0,i,c=r.uvarint(),f;if(c===0){if(r.positional&&e.shapes)f=SJ(o,r),t.push(f)}else if(f=t[c-1],f===void 0)D("a known row shape",void 0,r.options);if(f!==void 0){for(let u=0;u<f.length;u++){let d=jP(e,n,f[u],s,r);if(d>=0)if(d<32)a|=1<<d;else(i??=new Set).add(d)}if(r.pos!==r.end)D("no leftover bytes",void 0,r.options)}else{let u=e.shapes?[]:void 0,d=0,l,m,p=!1;while(r.pos<r.end){let g=r.uvarint(),h;if(g===0){if(p)D("unique field ids",void 0,r.options);p=!0,h=null}else if(h=o.byId.get(g),h===void 0)if(m===void 0)m=new Set([g]);else if(m.has(g))D("unique field ids",void 0,r.options);else m.add(g);else if(h.index<32){if((d&1<<h.index)!==0)D("unique field ids",void 0,r.options);d|=1<<h.index}else if(l===void 0)l=new Set([h.index]);else{if(l.has(h.index))D("unique field ids",void 0,r.options);l.add(h.index)}u?.push(h);let E=jP(e,n,h,s,r);if(E>=0)if(E<32)a|=1<<E;else(i??=new Set).add(E)}if(u!==void 0)t.push(u)}return MM(o,a,i,r),s}function jP(e,t,n,r,o){let s=o.uvarint();if((s&1)===1){if(n===null||n===void 0)return-1;let f=t[n.index],u=(s-1)/2;if(f===void 0||u>=f.length)D("a known back-reference",void 0,o.options);let d=f[u];if(d===vt)return-1;return q(r,n.name,d),n.index}let a=o.enter(s/2);if(n===null)return UM(e.struct,o,r),o.exit(a),-1;if(n===void 0)return o.exit(a),-1;let i=e.intern[n.index];if(i===aM||i===iM)o.intern=t[n.index]??=[];Ee[W++]=n.name;let c=Kt(n.layout,o);if(W--,o.intern=void 0,o.exit(a),i===gE)(t[n.index]??=[]).push(c);if(c===vt)return-1;return q(r,n.name,c),n.index}function bJ(e,t){let n=e.elements.length,r=e.hasCount?t.uvarint():n;if(e.rest.length===0&&r>n)throw Ee[W++]=n,yt(new ma(e.ast,void 0,t.options));if(r<e.minCount)throw Ee[W++]=r,yt(new ot(void 0));if(e.hasCount){let a=e.rest.length>0&&fM(e.rest[0])?mW:t.remaining+pW;if(r>a)D("array count within allocation limit",r,t.options)}if(r>0){let a=xM(e);if(a!==null)return yJ(a,r,t)}let o=Array(r),s=e.uniform;if(s!==void 0){if(e.uniformNumbers)return IJ(o,r,t);let a=t.intern;if(t.intern=void 0,a!==void 0){for(let f=0;f<r;f++){Ee[W++]=f;let u=xJ(a,s,t);if(u===vt)throw yt(new ot(void 0));W--,o[f]=u}return o}if(jm(s)){for(let f=0;f<r;f++)Ee[W++]=f,o[f]=Zu(s,t),W--;return o}if(s._==="string"){for(let f=0;f<r;f++)Ee[W++]=f,o[f]=t.dict===void 0?t.readUtf8(t.uvarint()):CM(s,t),W--;return o}let{uniformPacked:i,uniformInline:c}=e;for(let f=0;f<r;f++){Ee[W++]=f;let u=t.enter(c?i??0:t.uvarint()),d=Kt(s,t);if(t.exit(u),d===vt)throw yt(new ot(void 0));W--,o[f]=d}return o}for(let a=0;a<r;a++){let i=kM(e,a,r),c=a<n&&e.elements[a].optional;if(!e.hasCount&&t.remaining===0&&!c&&i._!=="null"&&i._!=="undefined")throw Ee[W++]=a,yt(new ot(void 0));Ee[W++]=a;let f=vM(i,t);if(f===vt){if(c)D("known union member",void 0,t.options);throw yt(new ot(void 0))}W--,o[a]=f}if(!e.hasCount&&t.pos<t.end)throw Ee[W++]=n,yt(new ma(e.ast,void 0,t.options));return o}function IJ(e,t,n){let r=n.byte();if(r===XP){if(n.remaining!==t*8)D("f64",void 0,n.options);for(let o=0;o<t;o++)e[o]=n.f64();return e}if(r===tM){for(let o=0;o<t;o++){Ee[W++]=o;let s=n.uvarint(),a=s%16;if(a>zm)D("decimal",void 0,n.options);let i=nM((s-a)/16);e[o]=a===0?i:i/ta[a],W--}return e}if(r!==eM)D("f64",void 0,n.options);for(let o=0;o<t;o++)Ee[W++]=o,e[o]=n.numberVarint(),W--;return e}function wJ(e,t){let n=t.byte();if(n===Ue.variant){let o=t.u32le(),s=e.byTag.get(o);if(s===void 0)return t.take(t.remaining),vt;let a=Kt(s.payload,t);if(a===vt)return vt;if(!s.tuple)for(let i of s.sentinels)q(a,i.key,i.literal);return a}let r=e.byKind.get(n);if(r===void 0)return t.take(t.remaining),vt;return Kt(r,t)}function kJ(e,t){let n=e.byPos[t.uvarint()];if(n===void 0)D("known union member",void 0,t.options);let r=Kt(n.layout,t),o=n.variant;if(o!==void 0&&!o.tuple&&r!==vt)for(let s of o.sentinels)q(r,s.key,s.literal);return r}function WP(e,t){switch(t.byte()){case 0:return Kf(Bc(Kt(e.error,t)));case 1:return Vf(Bc(Kt(e.defect,t)));case 2:if(t.remaining!==0)D("empty",void 0,t.options);return Yf();case 3:{if(t.remaining!==8)D("f64",void 0,t.options);return Yf(t.f64())}default:return t.take(t.remaining),vt}}function Bc(e){if(e===vt)throw yt(new ot(void 0));return e}function Zu(e,t){if(t.nesting>=_P)D(`nesting depth at most ${_P}`,t.nesting+1,t.options);t.nesting++;try{return TJ(e,t)}finally{t.nesting--}}function TJ(e,t){switch(e._){case"literal":{let n=Zu(e.leaf,t);if(!td(e,n))D(Hm(e),n,t.options);return n}case"bool":{if(t.remaining!==1)D("bool",void 0,t.options);let n=t.byte();if(n>1)D("bool",void 0,t.options);return n===1}case"null":if(t.remaining!==0)D("empty",void 0,t.options);return null;case"undefined":if(t.remaining!==0)D("empty",void 0,t.options);return;case"number":{let n=t.remaining;if(n===8)return t.f64();if(n===0||n>YP)D("f64",void 0,t.options);let r=t.numberVarint();if(t.remaining===0)return r;let o=t.byte();if(t.remaining!==0||o===0||o>zm)D("decimal",void 0,t.options);return r/ta[o]}case"int":return t.numberVarint();case"string":{let n=t.dict;return n===void 0?t.readUtf8(t.end-t.pos):rJ(n,e,t)}case"symbol":return globalThis.Symbol.for(t.readUtf8(t.end-t.pos));case"bytes":return t.takeCopy(t.end-t.pos);case"bigint":return t.zigzag();case"int64":{if(t.remaining!==8)D("int64",void 0,t.options);let n=Number(t.i64()),r=new Date(n);if(Number.isNaN(r.getTime()))D(e.flavor==="date"?"a valid Date":"a valid DateTime",n,t.options);return e.flavor==="date"?r:gd(n)}case"dateTimeZoned":{let n=Number(t.i64()),r=t.byte(),o;if(r===0){if(t.remaining!==4)D("time zone",void 0,t.options);o=t.i32le()}else if(r===1)o=t.readUtf8(t.end-t.pos);else return D("time zone",void 0,t.options);try{return xd(n,{timeZone:o})}catch{return D("time zone",void 0,t.options)}}case"duration":switch(t.byte()){case 0:return Zf(t.zigzag());case 1:return nc;case 2:return Yl;default:return D("duration",void 0,t.options)}case"bigDecimal":{let n=t.zigzag(),r=t.zigzag();if(r>tE||-r>tE)D("safe integer length",void 0,t.options);return ud(n,Number(r))}case"json":{let n=t.readUtf8(t.end-t.pos);try{return JSON.parse(n)}catch{return D("json",void 0,t.options)}}case"option":{let n=t.byte();if(n===0){if(t.remaining!==0)D("empty",void 0,t.options);return ne()}if(n!==1)D("bool",void 0,t.options);return oe(Bc(Kt(e.value,t)))}case"result":{let n=t.byte();if(n===0)return ue(Bc(Kt(e.success,t)));if(n!==1)D("bool",void 0,t.options);return ge(Bc(Kt(e.failure,t)))}case"exit":{let n=t.byte();if(n===0)return xn(Bc(Kt(e.value,t)));if(n!==1)D("bool",void 0,t.options);let r=Zu(e.cause,t);return en(r)}case"cause":{let n=t.uvarint(),r=[];for(let o=0;o<n;o++){Ee[W++]=o;let s=t.enter(t.uvarint()),a=WP(e,t);if(t.exit(s),W--,a!==vt)r.push(a)}if(t.pos!==t.end)D("no leftover bytes",void 0,t.options);return Gf(r)}case"causeReason":return WP(e,t);case"struct":return t.positional?gJ(e,t):hJ(e,t);case"array":return bJ(e,t);case"union":return t.positional?kJ(e,t):wJ(e,t);case"never":throw yt(new Fe(e.ast,void 0,t.options))}}function FM(e,t,n){let r=t.byte();if(r!==n.envelope)D(n.expectedEnvelope,r,t.options);if(n.positional){if(t.remaining<8)D("complete value",void 0,t.options);let s=t.buf,a=n.fingerprint,i=t.pos;for(let c=0;c<8;c++)if(s[i+c]!==a[c])D("matching layout fingerprint",void 0,t.options);t.pos=i+8}let o=Kt(e,t);if(o===vt)throw yt(new ot(void 0));return o}var Om=new qm;function AJ(e,t,n,r){let o=Om??new qm,s=o===Om;if(s)Om=void 0;o.reset(t,0,t.length,n,void 0,r.positional,void 0);let a=W;W=0;try{let i=o.uvarint();if(i===0)D("nonzero frame length",void 0,n);let c=o.enter(i),f=FM(e,o,r);if(o.exit(c),o.pos!==t.length)D("no leftover bytes",void 0,n);return f}finally{if(W=a,o.release(),s)Om=o}}function CJ(e,t,n,r=!1){return Et({decode:(o,s)=>{try{let a=AJ(e,o,s,t);if(n!==void 0&&Ku(a)&&(!r||Jm(a)))n.value=a;return b(a)}catch(a){return a instanceof ds?_(a.issue):_n(a)}},encode:(o,s)=>{try{return b(Lm(e,o,s,t))}catch(a){return a instanceof ds?_(a.issue):_n(a)}}})}var vJ=Ln(NW);function Xa(e,t){return t===!0?vJ(e):DW}var OJ=Ln((e)=>{let t=H(Pm(e)),{exact:n,exitSuccess:r,layout:o,recursive:s}=PW(t.ast);return{target:s?UJ(t):t,layout:o,exact:n,exitSuccess:r,recursive:s}});function zc(e){return OJ(e.ast)}function DM(e,t){if(e.value===void 0||t!==e.value)return!1;return e.value=void 0,!0}function NM(e,t,n){let r=H(Ve(e.ast)),o=qe(r),s=(a)=>()=>(i,c,f)=>a(i,f)?Ce:o(i,f);return H(new Cs([r.ast],s(t),{identifier:"binary value"},void 0,void 0,void 0,void 0,s(n)))}function dE(e,t){return t.onExcessProperty!=="error"}function _J(e,t,n){return NM(e,(r)=>DM(t,r),n?dE:RJ)}function RJ(){return!1}function PJ(e,t){return Wt()([e],([n])=>{let r=qe(n);return(o,s,a)=>DM(t,o)||Jm(o)&&a.onExcessProperty!=="error"?b(o):r(o,a)},{identifier:"binary exit value"})}function MJ(e){return NM(e,dE,dE)}function UJ(e){let t=H(Ve(e.ast)),n=new WeakSet,r=Wt()([t],([o])=>(s,a,i)=>{if(Ku(s)&&n.delete(s))return b(s);return ln(s)?_(new Fe(a,s,i)):qe(o)(s,i)},{identifier:"acyclic value"});return Z(r,xe({decode:(o)=>{if(Ku(o))n.add(o);return o},encode:(o)=>o}))(e)}var Gm=uu,DJ,HM=(e)=>(DJ??=new TextDecoder).decode(e);class pn extends Ft()("effect/rpc/RpcSerialization"){}class kE extends Qt("MaxBufferSizeExceeded"){get message(){return`RPC serialization buffer exceeded the maximum size of ${this.maxBufferSize}`}}var NJ=16777216,BM=(e,t)=>t!=="unbounded"&&e>t,jM=pn.of({contentType:"application/json",includesFraming:!1,codecFor:Gm,makeUnsafe:()=>({decode:(e)=>{let t=JSON.parse(typeof e==="string"?e:HM(e));return Array.isArray(t)?t:[t]},encode:(e)=>JSON.stringify(e)})}),Km=(e)=>{let t=e?.maxBufferSize??NJ;return pn.of({contentType:"application/ndjson",includesFraming:!0,codecFor:Gm,makeUnsafe:()=>{let n,r="",o=(s)=>{throw r="",new kE({maxBufferSize:s})};return{decode:(s)=>{r+=typeof s==="string"?s:(n??=new TextDecoder).decode(s,{stream:!0});let a=0,i=r.indexOf(`
|
|
11
|
+
`,a),c=[];while(i!==-1){if(BM(i-a,t))o(t);let f=r.slice(a,i);a=i+1;try{c.push(JSON.parse(f))}catch{}i=r.indexOf(`
|
|
12
|
+
`,a)}if(r=r.slice(a),BM(r.length,t))o(t);return c},encode:(s)=>{if(Array.isArray(s)){if(s.length===0)return;let a="";for(let i=0;i<s.length;i++)a+=JSON.stringify(s[i])+`
|
|
13
13
|
`;return a}return JSON.stringify(s)+`
|
|
14
|
-
`}}}})},JM=Km(),GM=(e)=>pn.of({contentType:e?.contentType??"application/json",includesFraming:!1,codecFor:Gm,makeUnsafe:()=>{let t=new Map;return{decode:(n)=>{let r=JSON.parse(typeof n==="string"?n:jM(n));return VM(r,t)},encode:(n)=>{let r=ZM(n,t);return r&&JSON.stringify(r)}}}}),KM=(e)=>pn.of({contentType:e?.contentType??"application/json-rpc",includesFraming:!0,codecFor:Gm,makeUnsafe:()=>{let t=Km({maxBufferSize:e?.maxBufferSize}).makeUnsafe(),n=new Map;return{decode:(r)=>{let o=t.decode(r);if(o.length===0)return[];let s=[];for(let a=0;a<o.length;a++)s.push(...VM(o[a],n));return s},encode:(r)=>{let o=ZM(r,n);return o&&t.encode(o)}}}});function VM(e,t){if(Array.isArray(e)){let n={size:0,responses:new Map},r=[];for(let o=0;o<e.length;o++){let s=e[o];if(!st(s))continue;let a=zM(s);if(r.push(a),a._tag==="Request"&&!a.isNotification)n.size++,t.set(a.id,n)}return r}return st(e)?[zM(e)]:[]}function zM(e){if(Object.hasOwn(e,"method")){let r=e;if(qM(r.id)&&ys(r.method)&&r.method.startsWith("@effect/rpc/")){let o=r.method.slice(12),s=r.params?.requestId;return s!==void 0?{_tag:o,requestId:s}:{_tag:o}}return{_tag:"Request",id:r.id??"",tag:r.method,payload:r.params??null,headers:r.headers??[],...V(r,"id")?{}:{isNotification:!0},...r.spanId?{traceId:r.traceId,spanId:r.spanId,sampled:r.sampled}:{}}}let t=e,n=Object.hasOwn(t,"error");if(n&&t.error&&t.error._tag==="Defect")return{_tag:"Defect",defect:t.error.data};else if(Object.hasOwn(t,"chunk")&&t.chunk===!0)return{_tag:"Chunk",requestId:t.id??"",values:t.result};return{_tag:"Exit",requestId:t.id??"",exit:n&&t.error!=null?{_tag:"Failure",cause:t.error._tag==="Cause"?t.error.data:[{_tag:"Fail",error:t.error}]}:{_tag:"Success",value:t.result}}}function $M(e,t){if(!("requestId"in e))return wE(e);let n=t.get(e.requestId);if(n){if(t.delete(e.requestId),n.responses.set(e.requestId,e),n.size===n.responses.size)return Array.from(n.responses.values(),wE);return}return wE(e)}function ZM(e,t){if(Array.isArray(e)===!1)return $M(e,t);if(e.length===0)return;let n=[];for(let o=0;o<e.length;o++){let s=$M(e[o],t);if(s!==void 0)n.push(s)}if(n.length===0)return;if(n.length===1)return n[0];let r=[];for(let o=0;o<n.length;o++){let s=n[o];if(Array.isArray(s))r.push(...s);else r.push(s)}return r}function wE(e){switch(e._tag){case"Request":return{jsonrpc:"2.0",method:e.tag,params:e.payload,...e.isNotification?{}:{id:e.id},...e.headers?.length>0?{headers:e.headers}:{},traceId:e.traceId,spanId:e.spanId,sampled:e.sampled};case"Ping":case"Pong":case"Interrupt":case"Ack":case"Eof":return{jsonrpc:"2.0",method:`@effect/rpc/${e._tag}`,params:"requestId"in e?{requestId:e.requestId}:void 0};case"Chunk":return{jsonrpc:"2.0",chunk:!0,id:e.requestId,result:e.values};case"Exit":{if(e.exit._tag==="Success")return{jsonrpc:"2.0",id:e.requestId??void 0,result:e.exit.value};let t=e.exit.cause.find((r)=>r._tag==="Fail"),n=t?._tag==="Fail"?t.error:void 0;return{jsonrpc:"2.0",id:e.requestId??void 0,error:e.exit._tag==="Failure"?{_tag:"Cause",code:n&&V(n,"code")?Number(n.code):0,message:n&&V(n,"message")?n.message:JSON.stringify(e.exit.cause),data:e.exit.cause}:void 0}}case"Defect":return{jsonrpc:"2.0",id:BJ,error:{_tag:"Defect",code:1,message:"A defect occurred",data:e.defect}};case"ClientProtocolError":return{}}}var BJ=-32603,LJ=16777216,zJ=new TextEncoder,$J=(e)=>{let t=e?.maxFrameSize==="unbounded"?void 0:e?.maxFrameSize??LJ,n=e?.fingerprintPayloads===!0?(o)=>lE(o,{fingerprint:!0}):lE,r={fingerprint:!0};return pn.of({contentType:"application/vnd.effect.rpc+schema-binary",includesFraming:!0,codecFor:n,makeUnsafe:()=>{let o=VP(QS,{...r,maxFrameSize:t}),s=QP(QS,r);return{decode:(a)=>o.feedSync(typeof a==="string"?zJ.encode(a):a),encode:(a)=>{if(!Array.isArray(a))return s.encode(a);if(a.length===0)return;return s.encodeMany(a)}}}})},qJ=Ys(pn)(WM),HJ=Ys(pn)(JM),jJ=(e)=>Ys(pn)(Km(e)),WJ=(e)=>Ys(pn)(GM(e)),JJ=(e)=>Ys(pn)(KM(e)),GJ=(e)=>HM(pn)(()=>$J(e));class TE extends Ft()("effect/rpc/RpcWorker/InitialMessage"){}var QM=(e)=>M(()=>{let t=new Set,n=new Map,r=new Map,o=(s,a)=>Gr((i)=>{let c=n.get(s);if(!c)c=[],n.set(s,c);return c.push([a,i]),R});return B(e((s,a)=>{let i=r.get(s);if(i)return i(a);return o(s,a)},t),(s)=>({...s,run(a,i){return je(function*(){t.add(a),r.set(a,i);let c=n.get(a);if(c){n.delete(a);for(let[f,u]of c)yield*Jt(M(()=>i(f)),u)}return yield*yr(Hs,()=>(t.delete(a),r.delete(a),R))})}}))});var VJ=(e)=>vo(e,"RpcClientError"),ZJ=0,iU=re(function*(e,t){let n=t?.spanPrefix??"RpcClient",r=t?.supportsAck??!0,o=t?.disableTracing??!1,s=t?.generateRequestId??(()=>ZJ++),a=yield*Qn(),i=Lt(a,ut),c=new Map,f=!1;yield*Me(i,dt((S)=>(f=!0,u(xp(S.id)))));let u=re(function*(S){for(let[k,I]of c)if(c.delete(k),I._tag==="Queue")yield*S._tag==="Success"?gc(I.queue):rt(I.queue,S.cause);else I.resume(S)}),d=(S)=>{let k=ES(S.successSchema),I=p(S);return(x,w)=>{let C=w?.headers?Es(w.headers):di,T=w?.context??Do();if(!k){let O=(U)=>l(S,I,U,S.payloadSchema.make(x),C,T,w?.discard??!1);return o?O(void 0):FS(`${n}.${S._tag}`,{attributes:t.spanAttributes},O)}let v=m(S,I,S.payloadSchema.make(x),C,w?.streamBufferSize??16,T);if(w?.asQueue)return v;return ro(B(v,Gs))}},l=(S,k,I,x,w,C,T)=>dt((v)=>{if(f)return Kn;let O=s(),U=k((X)=>t.onFromClient({message:X,context:C,discard:T}),{_tag:"Request",id:O,tag:S._tag,payload:x,...I?{traceId:I.traceId,spanId:I.spanId,sampled:I.sampled}:{},headers:Pd(v.getRef(Vm),w)});if(T)return U;let j;return Ic(Gn((X)=>{let J={_tag:"Effect",rpc:S,context:C,resume(N){if(X(N),j&&!j.pollUnsafe())v.currentDispatcher.scheduleTask(()=>{j.interruptUnsafe(v.id)},0)}};c.set(O,J),j=U.pipe(I?mm(I,{captureStackTrace:!1}):Q,Fn(v.context)),j.addObserver((N)=>{if(N._tag==="Failure")return X(N)})}),(X)=>(c.delete(O),gt(fn(j),g(O,Array.from(X),C))))}),m=re(function*(S,k,I,x,w,C){if(f)return yield*Kn;let T=o?void 0:yield*aU(`${n}.${S._tag}`,{attributes:t.spanAttributes}),v=Fo(),O=s(),U=Cc(v.context,ut),j=yield*Ba(w);return yield*dr(U,(X)=>{if(vy(j),!c.has(O))return R;return c.delete(O),g(O,bo(X)?Array.from(YM(X.cause)):[],C)}),c.set(O,{_tag:"Queue",rpc:S,queue:j,scope:U,context:C}),yield*k((X)=>t.onFromClient({message:X,context:C,discard:!1}),{_tag:"Request",id:O,tag:S._tag,payload:I,...T?{traceId:T.traceId,spanId:T.spanId,sampled:T.sampled}:{},headers:Pd(v.getRef(Vm),x)}).pipe(T?mm(T,{captureStackTrace:!1}):Q,Vn((X)=>rt(j,X)),is,Ne(U,{startImmediately:!0})),j}),p=(S)=>{let k=[];for(let I of S.middlewares.values()){let x=um(a,`${I.key}/Client`);if(!x)continue;k.push(x)}if(k.length===0)return(I,x)=>I(x);return function I(x,w,C=k.length-1){if(C===-1)return x(w);return k[C]({rpc:S,request:w,next(T){return I(x,T,C-1)}})}},g=(S,k,I)=>Gn((x)=>{let w=Fo();t.onFromClient({message:{_tag:"Interrupt",requestId:S,interruptors:k},context:I,discard:!1}).pipe(oU(1000),Fn(w.context)).addObserver(()=>{x(R)})}),h=(S)=>{switch(S._tag){case"Chunk":{let k=S.requestId,I=c.get(k);if(!I||I._tag!=="Queue")return R;return ts(I.queue,S.values).pipe(r?A(()=>t.onFromClient({message:{_tag:"Ack",requestId:S.requestId},context:I.context,discard:!1})):Q,De((x)=>rt(I.queue,x)))}case"Exit":{let k=S.requestId,I=c.get(k);if(!I)return R;if(c.delete(k),I._tag==="Effect")return I.resume(S.exit),R;return S.exit._tag==="Success"?gc(I.queue):rt(I.queue,S.exit.cause)}case"Defect":return u(Xp(S.defect));case"ClientEnd":return R}},E;if(t.flatten){let S=new Map;E=function(I,x,w){let C=S.get(I);if(!C)C=d(e.requests.get(I)),S.set(I,C);return C(x,w)}}else E={},e.requests.forEach((S)=>{q(E,S._tag,d(S))});return{client:E,write:h}}),QJ=0,YJ=re(function*(e,t){let n=QJ++,{codecFor:r,run:o,send:s,supportsAck:a,supportsTransferables:i}=yield*ps,c=XJ(r),f=Wx(r(bt())),u=new Map,d=(p)=>{if(!u.has(p))return R;return u.delete(p),s(n,{_tag:"Interrupt",requestId:p})},{client:l,write:m}=yield*iU(e,{...t,supportsAck:a,onFromClient({message:p}){switch(p._tag){case"Request":{let g=e.requests.get(p.tag),h=i?IP():void 0,E=Fo(),S={rpc:g,context:h?Un(E.context,Am,h):E.context,schemas:c(g)};return u.set(p.id,S),S.schemas.encodePayload(p.payload).pipe(Jt(S.context),ls,A((k)=>s(n,{...p,id:p.id,payload:k,headers:Object.entries(p.headers)},h&&h.readUnsafe())))}case"Ack":{if(!u.get(p.requestId))return R;return s(n,{_tag:"Ack",requestId:p.requestId})}case"Interrupt":return d(p.requestId);case"Eof":return R}}});return yield*o(n,(p)=>{switch(p._tag){case"Chunk":{let g=ZS(p.requestId),h=u.get(g);if(!h||Tn(h.schemas.decodeChunk))return R;let E=h.schemas.decodeChunk.value;return Xn((S)=>S(E(p.values).pipe(Jt(h.context),ls,A((k)=>m({_tag:"Chunk",clientId:0,requestId:g,values:k})))).pipe(Vn((k)=>m({_tag:"Exit",clientId:0,requestId:g,exit:en(k)}).pipe(gt(AE(k)?R:vE(d(g))))),tU((k)=>!AE(k),()=>R)))}case"Exit":{let g=ZS(p.requestId),h=u.get(g);if(!h)return R;return u.delete(g),h.schemas.decodeExit(p.exit).pipe(Jt(h.context),ls,ns({onSuccess:(E)=>m({_tag:"Exit",clientId:0,requestId:g,exit:E}),onFailure:(E)=>m({_tag:"Exit",clientId:0,requestId:g,exit:en(E)})}))}case"Defect":return m({_tag:"Defect",clientId:0,defect:f(p.defect)});case"ClientProtocolError":{let g=So(p.error);return Jr(Array.from(u.keys()),(h)=>m({_tag:"Exit",clientId:0,requestId:h,exit:g}))}default:return R}}).pipe(De(em),is,Ro),l}),XJ=(e)=>{let t=new WeakMap;return(n)=>{let r=t.get(n);if(r!==void 0)return r;let o=im(n.successSchema);return r={decodeChunk:qo(o,(s)=>Ms(e(fc(s.success)))),encodePayload:Jx(e(n.payloadSchema)),decodeExit:Ms(e(wS(n)))},t.set(n,r),r}},Vm=sf("effect/rpc/RpcClient/CurrentHeaders",{defaultValue:()=>di}),eG=y(2,(e,t)=>sU(e,Vm,Pd(Es(t))));class ps extends Ft()("effect/rpc/RpcClient/Protocol"){static make=QM}var cU=(e)=>ps.make(re(function*(t){let n=yield*pn,r=n.includesFraming,o=(f)=>new us({reason:Mc.fromHttpClientError(f)}),s=(f,u)=>new us({reason:new Xs({message:f,cause:u})}),a=(f)=>s("Received empty HTTP response from RPC server",f),i=(f)=>s("HTTP response ended before RPC request completed",f);return{send:re(function*(f,u){if(u._tag!=="Request")return;let d=n.makeUnsafe(),l=d.encode(u),m=typeof l==="string"?vS(l,n.contentType):CS(l,n.contentType),p=yield*e.post("",{body:m}).pipe(Fu(o));if(!r){let E=yield*p.text.pipe(Fu(o)),S=yield*Mr({try:()=>d.decode(E),catch:(I)=>s("Error decoding HTTP response",I)});if(!Array.isArray(S))return yield*s("Expected an array of responses",S);if(S.length===0)return yield*a(u);let k=!1;for(let I=0;I<S.length;I++){let x=S[I];if(YS(x))k=!0;yield*t(f,x)}if(!k)return yield*i(u);return}let g=!1,h=!1;if(yield*sm(p.stream,(E)=>Mr({try:()=>E.flatMap(d.decode),catch:(S)=>s("Error decoding HTTP response",S)}).pipe(A((S)=>{if(S.length===0)return R;g=!0;let k=0;return gr({while:()=>k<S.length,body:()=>{let I=S[k++];if(YS(I))h=!0;return t(f,I)},step:Mn})}))).pipe(Fu((E)=>VJ(E)?E:o(E))),!g)return yield*a(u);else if(!h)return yield*i(u)}),supportsAck:!1,supportsTransferables:!1,codecFor:n.codecFor}})),tG=(e)=>Dc(ps)(A(JR,(t)=>(t=GR(t,BR(e.url)),cU(e.transformClient?e.transformClient(t):t)))),fU=(e)=>ps.make(re(function*(t,n){let r=yield*Qa,o=yield*pn,s=yield*_c(Zm),a=new Map,i=yield*r.writer,c=o.makeUnsafe(),f=yield*rG(M(()=>i.write(c.encode(CP)))),u,d=(p)=>Jr(n,(g)=>t(g,p)),l=(p)=>(u=p,d({_tag:"ClientProtocolError",error:p})),m=(p)=>{try{let g=c.decode(p);if(g.length===0)return R;let h=0;return gr({while:()=>h<g.length,body:()=>{let E=g[h++];if(E._tag==="Pong")return f.onPong(),R;if(Object.hasOwn(E,"requestId")){let S=E.requestId,k=a.get(S);if(k!==void 0){if(E._tag==="Exit")a.delete(S);return t(k,E)}}return d(E)},step:Mn})}catch(g){return d({_tag:"ClientProtocolError",error:new us({reason:new Xs({message:"Error decoding message",cause:g})})})}};return yield*M(()=>(c=o.makeUnsafe(),f.reset(),je(function*(){let{pull:p}=yield*r.reader;if(u=void 0,ve(s))yield*s.value.onConnect;while(!0){let g=yield*p;for(let h=0;h<g.length;h++)yield*m(g[h])}}).pipe(Ja,za(A(f.timeout,()=>_(new Ae({reason:new ao({cause:Error("ping timeout")})}))))))).pipe(ve(s)?_o(s.value.onDisconnect):Q,CE((p)=>{let g=bu(p),h=At(g),E=new us({reason:h?g.success.reason:new Xs({message:"Unknown socket error",cause:Oc(p)})});if(e?.retryTransientErrors&&h&&g.success.reason._tag==="SocketOpenError")return(e.onTransientError?.(E)??R).pipe(rU({log:!0,message:"RpcClient onTransientError hook failed"}));return l(E)}),nU(e?.retryPolicy??nG,(p)=>l(new us({reason:p.reason}))),OE({module:"RpcClient",method:"makeProtocolSocket"}),Ro),{send(p,g){if(u)return _(u);if(g._tag==="Request")a.set(g.id,p);let h=c.encode(g);if(h===void 0)return R;return ls(i.write(h))},supportsAck:!0,supportsTransferables:!1,codecFor:o.codecFor}})),nG=XM([eU(500,1.5),Du(5000)]),rG=re(function*(e){let t=!0,n=ct(),r=()=>{t=!0,n.closeUnsafe()},o=()=>{t=!0};return yield*M(()=>{if(!t)return n.open;return t=!1,e}).pipe(Ks("5 seconds"),vE,Ze,is,Ro),{timeout:n.await,reset:r,onPong:o}}),oG=(e)=>Dc(ps)(fU(e)),uU=(e)=>ps.make(re(function*(t,n){let r=yield*KS,o=yield*Yn,s=0,a=yield*_c(TE),i=yield*_c(Zm),c=new Map,f=(m)=>Jr(n,(p)=>t(p,m)),u=je(function*(){let m=s++,p=yield*r.spawn(m);return yield*p.run((g)=>{if(g._tag==="Exit"){let h=c.get(g.requestId);if(h)return c.delete(g.requestId),h.latch.openUnsafe(),t(h.clientId,g)}else if(g._tag==="Defect"){for(let[h,E]of c)c.delete(h),E.latch.openUnsafe();return f(g)}else if("requestId"in g){let h=c.get(g.requestId);if(h)return t(h.clientId,g)}return f(g)},{onSpawn:ve(a)?A(a.value,([g,h])=>ls(p.send({_tag:"InitialMessage",value:g},h))):void 0}).pipe(CE((g)=>{for(let[E,S]of c){if(S.worker!==p)continue;c.delete(E),S.latch.openUnsafe()}let h=bu(g);return f({_tag:"ClientProtocolError",error:new us({reason:At(h)?h.success.reason:new Xs({message:"Error in worker",cause:Oc(g)})})})}),US(Du(1000)),OE({module:"RpcClient",method:"makeProtocolWorker"}),is,Ro),p}),d="minSize"in e?yield*cP({acquire:u,min:e.minSize,max:e.maxSize,concurrency:e.concurrency,targetUtilization:e.targetUtilization,timeToLive:e.timeToLive}):yield*iP({acquire:u,size:e.size,concurrency:e.concurrency,targetUtilization:e.targetUtilization});yield*Me(o,L(()=>{for(let m of c.values())m.latch.openUnsafe();c.clear()}));let l=(m,p,g)=>{switch(p._tag){case"Request":return LS(d).pipe(A((h)=>{let E=ct(!1);return c.set(p.id,{clientId:m,worker:h,latch:E}),A(h.send(p,g),()=>E.await)}),Ja,ls);case"Interrupt":{let h=c.get(p.requestId);if(!h)return R;return c.delete(p.requestId),h.latch.openUnsafe(),ls(h.worker.send(p))}case"Ack":{let h=c.get(p.requestId);if(!h)return R;return ls(h.worker.send(p))}}return R};if(yield*Ja(LS(d)),ve(i))yield*i.value.onConnect;return{send:l,supportsAck:!0,supportsTransferables:!0,codecFor:uu}})),sG=ja(uU,Dc(ps));class Zm extends Ft()("effect/rpc/RpcClient/ConnectionHooks"){}var lU=F.string().min(8).max(64).regex(/^[A-Za-z0-9_-]+$/),pU=F.strictObject({checkoutPath:F.string().min(1),branch:F.string().min(1),remoteFingerprint:F.string().min(1)}),mU=F.strictObject({operationId:lU,checkoutPath:F.string().min(1),operation:dU}),Xm=F.strictObject({}),Ym=F.strictObject({brokerId:F.string().min(1),checkouts:F.array(F.string()),ambiguousRequestIds:F.array(lU),evidenceComplete:F.boolean(),recoveryPending:F.boolean(),admitsMutations:F.boolean()}),rd=F.strictObject({_tag:F.literal("BrokerError"),message:F.string().min(1)}),hU=F.discriminatedUnion("_tag",[F.strictObject({_tag:F.literal("Progress"),phase:F.literal("running"),observedAt:F.string().min(1).max(64)}),F.strictObject({_tag:F.literal("Result"),outcome:F.enum(["ok","error"]),value:F.unknown(),error:F.string().nullable()})]);function wr(e){return sn.declare((t)=>e.safeParse(t).success)}var gU=dm.make(ss.make("RegisterCheckout",{payload:wr(pU),success:wr(Ym),error:wr(rd)}),ss.make("QueryStatus",{payload:wr(Xm),success:wr(Ym),error:wr(rd)}),ss.make("OpenAdmission",{payload:wr(Xm),success:wr(Ym),error:wr(rd)}),ss.make("ExecuteOperation",{payload:wr(mU),success:wr(hU),error:wr(rd),stream:!0})),od=F.union([F.string().min(1).max(64),F.number().int().nonnegative().max(Number.MAX_SAFE_INTEGER)]),Qm={_tag:F.literal("Request"),id:od,headers:F.array(F.tuple([F.string(),F.string()])),traceId:F.string().optional(),spanId:F.string().optional(),sampled:F.boolean().optional()},aG=F.discriminatedUnion("tag",[F.strictObject({...Qm,tag:F.literal("RegisterCheckout"),payload:pU}),F.strictObject({...Qm,tag:F.literal("ExecuteOperation"),payload:mU}),F.strictObject({...Qm,tag:F.literal("QueryStatus"),payload:Xm}),F.strictObject({...Qm,tag:F.literal("OpenAdmission"),payload:Xm})]),iG=F.array(F.discriminatedUnion("_tag",[F.strictObject({_tag:F.literal("Fail"),error:rd}),F.strictObject({_tag:F.literal("Die"),defect:F.unknown()}),F.strictObject({_tag:F.literal("Interrupt"),fiberId:F.number().optional()})])),cG=F.discriminatedUnion("_tag",[F.strictObject({_tag:F.literal("Success"),value:Ym.nullable().optional()}),F.strictObject({_tag:F.literal("Failure"),cause:iG})]),fG=F.union([aG,F.strictObject({_tag:F.literal("Ack"),requestId:od}),F.strictObject({_tag:F.literal("Interrupt"),requestId:od}),F.strictObject({_tag:F.literal("Ping")}),F.strictObject({_tag:F.literal("Eof")})]),uG=F.union([fG,F.strictObject({_tag:F.literal("Pong")}),F.strictObject({_tag:F.literal("Chunk"),requestId:od,values:F.array(hU).min(1)}),F.strictObject({_tag:F.literal("Exit"),requestId:od,exit:cG}),F.strictObject({_tag:F.literal("Defect"),defect:F.unknown()})]);function xU(e){return uG.safeParse(e).success}import{createConnection as gG}from"net";import{Buffer as SU}from"buffer";import*as $c from"tls";import*as mG from"ws";var dG="Deno"in globalThis;var lG=(e)=>{let t=e.read();if(t===null)return;let n=e.read();if(n===null)return[t];let r=[t,n],o;while((o=e.read())!==null)r.push(o);return r},yU=(e)=>hn(_E(e),(t)=>SU.from(t));var RE=(e,t)=>dt((n)=>{let r,o=ct(!1),s=n.context,a=t?.tlsServer===!0,i=a?"secure":"secureConnect",c=je(function*(){let m=yield*Yn,p=yield*In(e,m).pipe(t?.openTimeout!==void 0?Im({duration:t.openTimeout,orElse:()=>_(new Ae({reason:new cs({kind:"Timeout",cause:Error("Connection timed out")})}))}):Q),g,h,E,S=!1,k=!1,I=!0;function x(){if(h===void 0||S)return;let N=E;if(E=void 0,N===void 0&&!k){S=!0;try{N=lG(p)}finally{S=!1}}if(k)N=void 0;if(h===void 0){E=N;return}let G=N!==void 0?b(N):g!==void 0?_(g):void 0;if(G===void 0)return;let fe=h;h=void 0,fe(G)}function w(N){g??=N,x()}function C(N){g??=N,k=!0,E=void 0,x()}function T(){w(new Ae({reason:new fs({code:1000})}))}function v(N){C(new Ae({reason:new ao({cause:N})}))}function O(N){let G=new Ae({reason:new fs({code:N?1006:1000})});if(N)C(G);else w(G)}function U(N){N.on("readable",x),N.on("end",T),N.on("error",v),N.on("close",O)}function j(N){N.off("readable",x),N.off("end",T),N.off("error",v),N.off("close",O)}if(!dG)p.pause();return U(p),yield*Me(m,L(()=>{C(new Ae({reason:new fs({code:1006})})),j(p),o.closeUnsafe(),r=void 0,I=!1})),r=p,o.openUnsafe(),{pull:Gn((N)=>{if(h=N,x(),h!==N)return;return L(()=>{if(h===N)h=void 0})}),upgrade:(N={})=>M(()=>{if(!I)return _(new Ae({reason:new io({cause:Error("socket is already upgraded or closed")})}));let G=N.key!==void 0,fe=N.cert!==void 0;if(a&&(!G||!fe)||G!==fe)return _(new Ae({reason:new io({cause:Error(a?"server TLS upgrade requires both key and cert":"TLS upgrade credentials must include both key and cert")})}));return Gn((Ge)=>{let Ot=p;j(Ot);let et;try{let Jc={secureContext:$c.createSecureContext({key:N.key===void 0?void 0:hn(_E(N.key),(AU)=>SU.from(Rr(AU))),cert:N.cert===void 0?void 0:yU(N.cert),ca:N.ca===void 0?void 0:yU(N.ca),passphrase:N.passphrase===void 0?void 0:Rr(N.passphrase)}),ALPNProtocols:N.alpnProtocols===void 0?void 0:[...N.alpnProtocols],requestCert:N.requestCert,rejectUnauthorized:N.rejectUnauthorized};et=a?new $c.TLSSocket(Ot,{...Jc,isServer:!0}):$c.connect({...Jc,socket:Ot})}catch(sd){U(Ot),Ge(_(new Ae({reason:new io({cause:sd})})));return}p=et,r=et,et.pause();function wt(){et.off(i,ti),et.off("error",eh),et.off("close",FE)}function ti(){wt(),I=!1,U(et),Ge(R)}function eh(sd){wt();let Jc=new Ae({reason:new io({cause:sd})});C(Jc),Ge(_(Jc))}function FE(){eh(Error("socket closed during TLS upgrade"))}return et.once(i,ti),et.once("error",eh),et.once("close",FE),L(()=>{wt(),C(new Ae({reason:new fs({code:1006})})),et.destroy()})})})}}).pipe(Qs((m)=>er(s,m))),f=(m)=>Gn((p)=>{function g(){m.off("drain",h),m.off("error",E),m.off("close",S)}function h(){g(),p(R)}function E(k){g(),p(_(new Ae({reason:new Er({cause:k})})))}function S(){g(),p(_(new Ae({reason:new Er({cause:Error("socket closed")})})))}return m.on("drain",h),m.on("error",E),m.on("close",S),L(g)}),u=(m)=>M(()=>{let p=r;if(p===void 0)return o.whenOpen(u(m));if(Nc(m))return p.destroy(m.code>1000?Error(`closed with code ${m.code}`):void 0),R;try{return p.write(m)?R:f(p)}catch(g){return _(new Ae({reason:new Er({cause:g})}))}}),d=(m)=>M(()=>{let p=r;if(p===void 0)return o.whenOpen(d(m));let g=!1;try{if(m.length===1)g=!p.write(m[0]);else{p.cork();try{for(let h=0;h<m.length;h++)g=!p.write(m[h])||g}finally{p.uncork()}}}catch(h){return _(new Ae({reason:new Er({cause:h})}))}return g?f(p):R}),l=xr(b({write:u,writeAll:d}),()=>L(()=>{if(!r||r.writableEnded)return;r.end()}));return b(Wu({reader:c,writer:l}))});var bQ="Deno"in globalThis;function bU(e){return Y.suspend(()=>{let t,n=Y.acquireRelease(Y.callback((r)=>{let o=gG(e);return t=o,o.once("connect",()=>r(Y.succeed(o))),o.on("error",(s)=>r(Y.fail(new Ae({reason:new cs({kind:"Unknown",cause:s})})))),Y.sync(()=>{o.destroy()})}),(r)=>Y.sync(()=>{r.destroy()}),{interruptible:!0});return Y.map(RE(n),(r)=>({socket:r,bufferedBytes:()=>t?.writableLength??0,close:()=>{t?.destroy()}}))})}var qc=2,Hc=8388608;class kr extends Error{code;constructor(e,t){super(t);this.name="ProtocolError",this.code=e}}function IU(e,t){let n=t.maxPendingBytes??Hc*2;if(!Number.isSafeInteger(n)||n<1||n>Hc*2)throw RangeError("Invalid broker RPC output limit");let r=0,o;return co.make({reader:e.reader,writer:Y.map(e.writer,(s)=>{let a=(i)=>Y.suspend(()=>{if(o)return Y.fail(o);if(co.isCloseEvent(i))return s.write(i);let c=typeof i==="string"?Buffer.byteLength(i,"utf8"):i.byteLength;if(Math.max(r,t.bufferedBytes())+c>n)return o=new co.SocketError({reason:new co.SocketWriteError({cause:Error(`RPC output backpressure exceeds the ${n}-byte pending limit`)})}),t.onOverflow(),Y.fail(o);return r+=c,s.write(i).pipe(Y.ensuring(Y.sync(()=>{r-=c})))});return{write:a,writeAll:(i)=>Y.forEach(i,a,{discard:!0})}})})}function wU(e){return Zn.effect(co.Socket,Y.map(bU({path:e}),(t)=>IU(t.socket,{bufferedBytes:t.bufferedBytes,onOverflow:t.close})))}var jc=4,xG=new TextEncoder,yG=F.strictObject({version:F.number().int().nonnegative(),message:F.unknown()});function kU(e={}){let t=e.maxFrameBytes??Hc;if(!Number.isSafeInteger(t)||t<1||t>Hc)throw RangeError("Invalid broker RPC frame limit");return{contentType:"application/x-brain-git-rpc",includesFraming:!0,codecFor:sn.toCodecJson,makeUnsafe:()=>{let n=new Uint8Array(jc),r=new TextDecoder("utf-8",{fatal:!0}),o=0,s,a=0,i=!1,c=(d)=>{if(!xU(d))throw new kr("malformed","Invalid broker RPC message");return d},f=(d)=>{let l;try{l=JSON.parse(r.decode(d))}catch{throw new kr("malformed","Frame body is not valid UTF-8 JSON")}let m=yG.safeParse(l);if(!m.success)throw new kr("malformed","Invalid broker RPC frame wrapper");if(m.data.version!==qc)throw new kr("version-mismatch",`Broker protocol version ${m.data.version} is not ${qc}`);return c(m.data.message)},u=(d)=>{let l=c(d),m=JSON.stringify({version:qc,message:l}),p=Buffer.byteLength(m,"utf8");if(p>t)throw new kr("frame-too-large",`RPC frame has ${p} bytes; limit is ${t}`);let g=new Uint8Array(jc+p);return new DataView(g.buffer).setUint32(0,p,!1),g.set(xG.encode(m),jc),g};return{get retainedBytes(){return o+(s?.byteLength??0)},decode:(d)=>{if(i)throw new kr("malformed","RPC parser is closed after a framing failure");let l=[],m=0;try{if(typeof d==="string")throw new kr("malformed","Broker RPC requires byte frames");while(m<d.length){if(!s){let g=Math.min(jc-o,d.length-m);if(n.set(d.subarray(m,m+g),o),o+=g,m+=g,o<jc)break;let h=new DataView(n.buffer).getUint32(0,!1);if(h>t)throw new kr("frame-too-large",`Frame declares ${h} bytes; limit is ${t}`);if(h===0)throw new kr("malformed","Empty RPC frame");s=new Uint8Array(h)}let p=Math.min(s.length-a,d.length-m);if(s.set(d.subarray(m,m+p),a),a+=p,m+=p,a<s.length)break;l.push(f(s)),o=0,a=0,s=void 0}return l}catch(p){throw i=!0,o=0,a=0,s=void 0,p}},encode:(d)=>{if(!Array.isArray(d))return u(d);if(d.length===0)return;let l=[],m=0;for(let h of d){let E=u(h);if(m+=E.length,m>t+jc)throw new kr("frame-too-large","RPC frame batch exceeds the output limit");l.push(E)}let p=new Uint8Array(m),g=0;for(let h of l)p.set(h,g),g+=h.length;return p}}}}}class TU{#e;#u=Y.runSync(Jn.make());#a=new AbortController;#t=new Set;#i=new Map;#c;#n=!1;constructor(e){this.#e=e}static async connect(e){let t=new TU(e),n=ME(),r=Zn.effect(ms.Protocol,ms.makeProtocolSocket({retryPolicy:wu.recurs(0)})).pipe(Zn.provide(wU(e)),Zn.provide(Zn.succeed(nd.RpcSerialization,kU())));try{return t.#c=await Y.runPromise(Jn.provide(Y.gen(function*(){let o=yield*Zn.build(r).pipe(Y.provideService(ms.ConnectionHooks,{onConnect:Y.sync(()=>n.resolve()),onDisconnect:Y.sync(()=>{let s=new na(e,"broker closed the connection");n.reject(s),t.#r(s)})}));return yield*ms.make(gU,{disableTracing:!0}).pipe(Y.provideService(ms.Protocol,kt.get(o,ms.Protocol)))}),t.#u)),await n.promise,t}catch(o){throw t.close(),o instanceof na?o:new na(e,String(o))}}onUnavailable(e){return this.#t.add(e),()=>{this.#t.delete(e)}}close(){if(this.#n)return;this.#t.clear(),this.#r(new na(this.#e,"client closed the connection"))}#r(e){if(this.#n)return;this.#n=!0,this.#a.abort(e);let t=[...this.#t];this.#t.clear(),Y.runFork(Jn.close(this.#u,Yt.void)),t.forEach((n)=>n())}#o(){if(this.#n||!this.#c)throw new na(this.#e,"connection closed");return this.#c}async#s(e,t){let n=t?AbortSignal.any([t,this.#a.signal]):this.#a.signal;try{return await Y.runPromise(e.pipe(Y.onInterrupt(()=>Y.sync(()=>{if(!n.aborted)this.#r(new na(this.#e,"broker interrupted RPC observation"))}))),{signal:n})}catch(r){if(n.aborted)throw n.reason;if(r instanceof Cm.RpcClientError){let o=new na(this.#e,String(r));throw this.#r(o),o}if(typeof r==="object"&&r!==null&&"_tag"in r&&r._tag==="BrokerError"&&"message"in r&&typeof r.message==="string")throw new Wc(r.message);throw r}}#f(e){return{...e,type:"status",version:qc,requestId:`req_${PE(12)}`}}async registerCheckout(e){return this.#f(await this.#s(this.#o().RegisterCheckout(e)))}async openAdmission(){return this.#f(await this.#s(this.#o().OpenAdmission({})))}async status(){return this.#f(await this.#s(this.#o().QueryStatus({})))}executeWithId(e,t,n,r={}){return this.#d(e,t,n,r)}async execute(e,t,n={}){return this.#d(`req_${PE(12)}`,e,t,n)}async#d(e,t,n,r){r.signal?.throwIfAborted();let o=JSON.stringify(n),s=this.#i.get(e);if(s){if(s.checkoutPath!==t||s.operationIdentity!==o)throw new Wc(`Request ${e} is already used for different Git work`);return UE(n.name,await s.reply)}let a=this.#o(),i=ME();this.#i.set(e,{checkoutPath:t,operationIdentity:o,reply:i.promise});let c,f=so.runForEach(a.ExecuteOperation({operationId:e,checkoutPath:t,operation:n}).pipe(so.takeUntil((u)=>u._tag==="Result")),(u)=>Y.sync(()=>{if(c)throw new Wc("Git RPC sent events after a terminal result");if(u._tag==="Progress")r.onProgress?.();else c=u}));this.#s(f,r.signal).then(()=>{if(!c)throw new Wc("Git RPC ended without a terminal result");if(c.outcome==="error")throw new Wc(c.error??"unknown");return c.value}).then(i.resolve,i.reject);try{return UE(n.name,await i.promise)}finally{this.#i.delete(e)}}}export{TU as BrokerConnection,Wc as BrokerOperationError,na as BrokerUnavailableError};
|
|
14
|
+
`}}}})},WM=Km(),JM=(e)=>pn.of({contentType:e?.contentType??"application/json",includesFraming:!1,codecFor:Gm,makeUnsafe:()=>{let t=new Map;return{decode:(n)=>{let r=JSON.parse(typeof n==="string"?n:HM(n));return KM(r,t)},encode:(n)=>{let r=VM(n,t);return r&&JSON.stringify(r)}}}}),GM=(e)=>pn.of({contentType:e?.contentType??"application/json-rpc",includesFraming:!0,codecFor:Gm,makeUnsafe:()=>{let t=Km({maxBufferSize:e?.maxBufferSize}).makeUnsafe(),n=new Map;return{decode:(r)=>{let o=t.decode(r);if(o.length===0)return[];let s=[];for(let a=0;a<o.length;a++)s.push(...KM(o[a],n));return s},encode:(r)=>{let o=VM(r,n);return o&&t.encode(o)}}}});function KM(e,t){if(Array.isArray(e)){let n={size:0,responses:new Map},r=[];for(let o=0;o<e.length;o++){let s=e[o];if(!st(s))continue;let a=LM(s);if(r.push(a),a._tag==="Request"&&!a.isNotification)n.size++,t.set(a.id,n)}return r}return st(e)?[LM(e)]:[]}function LM(e){if(Object.hasOwn(e,"method")){let r=e;if($M(r.id)&&ys(r.method)&&r.method.startsWith("@effect/rpc/")){let o=r.method.slice(12),s=r.params?.requestId;return s!==void 0?{_tag:o,requestId:s}:{_tag:o}}return{_tag:"Request",id:r.id??"",tag:r.method,payload:r.params??null,headers:r.headers??[],...V(r,"id")?{}:{isNotification:!0},...r.spanId?{traceId:r.traceId,spanId:r.spanId,sampled:r.sampled}:{}}}let t=e,n=Object.hasOwn(t,"error");if(n&&t.error&&t.error._tag==="Defect")return{_tag:"Defect",defect:t.error.data};else if(Object.hasOwn(t,"chunk")&&t.chunk===!0)return{_tag:"Chunk",requestId:t.id??"",values:t.result};return{_tag:"Exit",requestId:t.id??"",exit:n&&t.error!=null?{_tag:"Failure",cause:t.error._tag==="Cause"?t.error.data:[{_tag:"Fail",error:t.error}]}:{_tag:"Success",value:t.result}}}function zM(e,t){if(!("requestId"in e))return wE(e);let n=t.get(e.requestId);if(n){if(t.delete(e.requestId),n.responses.set(e.requestId,e),n.size===n.responses.size)return Array.from(n.responses.values(),wE);return}return wE(e)}function VM(e,t){if(Array.isArray(e)===!1)return zM(e,t);if(e.length===0)return;let n=[];for(let o=0;o<e.length;o++){let s=zM(e[o],t);if(s!==void 0)n.push(s)}if(n.length===0)return;if(n.length===1)return n[0];let r=[];for(let o=0;o<n.length;o++){let s=n[o];if(Array.isArray(s))r.push(...s);else r.push(s)}return r}function wE(e){switch(e._tag){case"Request":return{jsonrpc:"2.0",method:e.tag,params:e.payload,...e.isNotification?{}:{id:e.id},...e.headers?.length>0?{headers:e.headers}:{},traceId:e.traceId,spanId:e.spanId,sampled:e.sampled};case"Ping":case"Pong":case"Interrupt":case"Ack":case"Eof":return{jsonrpc:"2.0",method:`@effect/rpc/${e._tag}`,params:"requestId"in e?{requestId:e.requestId}:void 0};case"Chunk":return{jsonrpc:"2.0",chunk:!0,id:e.requestId,result:e.values};case"Exit":{if(e.exit._tag==="Success")return{jsonrpc:"2.0",id:e.requestId??void 0,result:e.exit.value};let t=e.exit.cause.find((r)=>r._tag==="Fail"),n=t?._tag==="Fail"?t.error:void 0;return{jsonrpc:"2.0",id:e.requestId??void 0,error:e.exit._tag==="Failure"?{_tag:"Cause",code:n&&V(n,"code")?Number(n.code):0,message:n&&V(n,"message")?n.message:JSON.stringify(e.exit.cause),data:e.exit.cause}:void 0}}case"Defect":return{jsonrpc:"2.0",id:BJ,error:{_tag:"Defect",code:1,message:"A defect occurred",data:e.defect}};case"ClientProtocolError":return{}}}var BJ=-32603,LJ=16777216,zJ=new TextEncoder,$J=(e)=>{let t=e?.maxFrameSize==="unbounded"?void 0:e?.maxFrameSize??LJ,n=e?.fingerprintPayloads===!0?(o)=>lE(o,{fingerprint:!0}):lE,r={fingerprint:!0};return pn.of({contentType:"application/vnd.effect.rpc+schema-binary",includesFraming:!0,codecFor:n,makeUnsafe:()=>{let o=KP(QS,{...r,maxFrameSize:t}),s=ZP(QS,r);return{decode:(a)=>o.feedSync(typeof a==="string"?zJ.encode(a):a),encode:(a)=>{if(!Array.isArray(a))return s.encode(a);if(a.length===0)return;return s.encodeMany(a)}}}})},qJ=Ys(pn)(jM),HJ=Ys(pn)(WM),jJ=(e)=>Ys(pn)(Km(e)),WJ=(e)=>Ys(pn)(JM(e)),JJ=(e)=>Ys(pn)(GM(e)),GJ=(e)=>qM(pn)(()=>$J(e));class TE extends Ft()("effect/rpc/RpcWorker/InitialMessage"){}var ZM=(e)=>M(()=>{let t=new Set,n=new Map,r=new Map,o=(s,a)=>Gr((i)=>{let c=n.get(s);if(!c)c=[],n.set(s,c);return c.push([a,i]),R});return B(e((s,a)=>{let i=r.get(s);if(i)return i(a);return o(s,a)},t),(s)=>({...s,run(a,i){return je(function*(){t.add(a),r.set(a,i);let c=n.get(a);if(c){n.delete(a);for(let[f,u]of c)yield*Jt(M(()=>i(f)),u)}return yield*yr(Hs,()=>(t.delete(a),r.delete(a),R))})}}))});var VJ=(e)=>vo(e,"RpcClientError"),ZJ=0,aU=re(function*(e,t){let n=t?.spanPrefix??"RpcClient",r=t?.supportsAck??!0,o=t?.disableTracing??!1,s=t?.generateRequestId??(()=>ZJ++),a=yield*Qn(),i=Lt(a,ut),c=new Map,f=!1;yield*Me(i,dt((S)=>(f=!0,u(xp(S.id)))));let u=re(function*(S){for(let[k,I]of c)if(c.delete(k),I._tag==="Queue")yield*S._tag==="Success"?gc(I.queue):rt(I.queue,S.cause);else I.resume(S)}),d=(S)=>{let k=ES(S.successSchema),I=p(S);return(x,w)=>{let C=w?.headers?Es(w.headers):di,T=w?.context??Do();if(!k){let O=(U)=>l(S,I,U,S.payloadSchema.make(x),C,T,w?.discard??!1);return o?O(void 0):FS(`${n}.${S._tag}`,{attributes:t.spanAttributes},O)}let v=m(S,I,S.payloadSchema.make(x),C,w?.streamBufferSize??16,T);if(w?.asQueue)return v;return ro(B(v,Gs))}},l=(S,k,I,x,w,C,T)=>dt((v)=>{if(f)return Kn;let O=s(),U=k((X)=>t.onFromClient({message:X,context:C,discard:T}),{_tag:"Request",id:O,tag:S._tag,payload:x,...I?{traceId:I.traceId,spanId:I.spanId,sampled:I.sampled}:{},headers:Pd(v.getRef(Vm),w)});if(T)return U;let j;return Ic(Gn((X)=>{let J={_tag:"Effect",rpc:S,context:C,resume(N){if(X(N),j&&!j.pollUnsafe())v.currentDispatcher.scheduleTask(()=>{j.interruptUnsafe(v.id)},0)}};c.set(O,J),j=U.pipe(I?mm(I,{captureStackTrace:!1}):Q,Fn(v.context)),j.addObserver((N)=>{if(N._tag==="Failure")return X(N)})}),(X)=>(c.delete(O),gt(fn(j),g(O,Array.from(X),C))))}),m=re(function*(S,k,I,x,w,C){if(f)return yield*Kn;let T=o?void 0:yield*sU(`${n}.${S._tag}`,{attributes:t.spanAttributes}),v=Fo(),O=s(),U=Cc(v.context,ut),j=yield*Ba(w);return yield*dr(U,(X)=>{if(vy(j),!c.has(O))return R;return c.delete(O),g(O,bo(X)?Array.from(QM(X.cause)):[],C)}),c.set(O,{_tag:"Queue",rpc:S,queue:j,scope:U,context:C}),yield*k((X)=>t.onFromClient({message:X,context:C,discard:!1}),{_tag:"Request",id:O,tag:S._tag,payload:I,...T?{traceId:T.traceId,spanId:T.spanId,sampled:T.sampled}:{},headers:Pd(v.getRef(Vm),x)}).pipe(T?mm(T,{captureStackTrace:!1}):Q,Vn((X)=>rt(j,X)),is,Ne(U,{startImmediately:!0})),j}),p=(S)=>{let k=[];for(let I of S.middlewares.values()){let x=um(a,`${I.key}/Client`);if(!x)continue;k.push(x)}if(k.length===0)return(I,x)=>I(x);return function I(x,w,C=k.length-1){if(C===-1)return x(w);return k[C]({rpc:S,request:w,next(T){return I(x,T,C-1)}})}},g=(S,k,I)=>Gn((x)=>{let w=Fo();t.onFromClient({message:{_tag:"Interrupt",requestId:S,interruptors:k},context:I,discard:!1}).pipe(rU(1000),Fn(w.context)).addObserver(()=>{x(R)})}),h=(S)=>{switch(S._tag){case"Chunk":{let k=S.requestId,I=c.get(k);if(!I||I._tag!=="Queue")return R;return ts(I.queue,S.values).pipe(r?A(()=>t.onFromClient({message:{_tag:"Ack",requestId:S.requestId},context:I.context,discard:!1})):Q,De((x)=>rt(I.queue,x)))}case"Exit":{let k=S.requestId,I=c.get(k);if(!I)return R;if(c.delete(k),I._tag==="Effect")return I.resume(S.exit),R;return S.exit._tag==="Success"?gc(I.queue):rt(I.queue,S.exit.cause)}case"Defect":return u(Xp(S.defect));case"ClientEnd":return R}},E;if(t.flatten){let S=new Map;E=function(I,x,w){let C=S.get(I);if(!C)C=d(e.requests.get(I)),S.set(I,C);return C(x,w)}}else E={},e.requests.forEach((S)=>{q(E,S._tag,d(S))});return{client:E,write:h}}),QJ=0,YJ=re(function*(e,t){let n=QJ++,{codecFor:r,run:o,send:s,supportsAck:a,supportsTransferables:i}=yield*ps,c=XJ(r),f=Wx(r(bt())),u=new Map,d=(p)=>{if(!u.has(p))return R;return u.delete(p),s(n,{_tag:"Interrupt",requestId:p})},{client:l,write:m}=yield*aU(e,{...t,supportsAck:a,onFromClient({message:p}){switch(p._tag){case"Request":{let g=e.requests.get(p.tag),h=i?bP():void 0,E=Fo(),S={rpc:g,context:h?Un(E.context,Am,h):E.context,schemas:c(g)};return u.set(p.id,S),S.schemas.encodePayload(p.payload).pipe(Jt(S.context),ls,A((k)=>s(n,{...p,id:p.id,payload:k,headers:Object.entries(p.headers)},h&&h.readUnsafe())))}case"Ack":{if(!u.get(p.requestId))return R;return s(n,{_tag:"Ack",requestId:p.requestId})}case"Interrupt":return d(p.requestId);case"Eof":return R}}});return yield*o(n,(p)=>{switch(p._tag){case"Chunk":{let g=ZS(p.requestId),h=u.get(g);if(!h||Tn(h.schemas.decodeChunk))return R;let E=h.schemas.decodeChunk.value;return Xn((S)=>S(E(p.values).pipe(Jt(h.context),ls,A((k)=>m({_tag:"Chunk",clientId:0,requestId:g,values:k})))).pipe(Vn((k)=>m({_tag:"Exit",clientId:0,requestId:g,exit:en(k)}).pipe(gt(AE(k)?R:vE(d(g))))),eU((k)=>!AE(k),()=>R)))}case"Exit":{let g=ZS(p.requestId),h=u.get(g);if(!h)return R;return u.delete(g),h.schemas.decodeExit(p.exit).pipe(Jt(h.context),ls,ns({onSuccess:(E)=>m({_tag:"Exit",clientId:0,requestId:g,exit:E}),onFailure:(E)=>m({_tag:"Exit",clientId:0,requestId:g,exit:en(E)})}))}case"Defect":return m({_tag:"Defect",clientId:0,defect:f(p.defect)});case"ClientProtocolError":{let g=So(p.error);return Jr(Array.from(u.keys()),(h)=>m({_tag:"Exit",clientId:0,requestId:h,exit:g}))}default:return R}}).pipe(De(em),is,Ro),l}),XJ=(e)=>{let t=new WeakMap;return(n)=>{let r=t.get(n);if(r!==void 0)return r;let o=im(n.successSchema);return r={decodeChunk:qo(o,(s)=>Ms(e(fc(s.success)))),encodePayload:Jx(e(n.payloadSchema)),decodeExit:Ms(e(wS(n)))},t.set(n,r),r}},Vm=sf("effect/rpc/RpcClient/CurrentHeaders",{defaultValue:()=>di}),eG=y(2,(e,t)=>oU(e,Vm,Pd(Es(t))));class ps extends Ft()("effect/rpc/RpcClient/Protocol"){static make=ZM}var iU=(e)=>ps.make(re(function*(t){let n=yield*pn,r=n.includesFraming,o=(f)=>new us({reason:Mc.fromHttpClientError(f)}),s=(f,u)=>new us({reason:new Xs({message:f,cause:u})}),a=(f)=>s("Received empty HTTP response from RPC server",f),i=(f)=>s("HTTP response ended before RPC request completed",f);return{send:re(function*(f,u){if(u._tag!=="Request")return;let d=n.makeUnsafe(),l=d.encode(u),m=typeof l==="string"?vS(l,n.contentType):CS(l,n.contentType),p=yield*e.post("",{body:m}).pipe(Fu(o));if(!r){let E=yield*p.text.pipe(Fu(o)),S=yield*Mr({try:()=>d.decode(E),catch:(I)=>s("Error decoding HTTP response",I)});if(!Array.isArray(S))return yield*s("Expected an array of responses",S);if(S.length===0)return yield*a(u);let k=!1;for(let I=0;I<S.length;I++){let x=S[I];if(YS(x))k=!0;yield*t(f,x)}if(!k)return yield*i(u);return}let g=!1,h=!1;if(yield*sm(p.stream,(E)=>Mr({try:()=>E.flatMap(d.decode),catch:(S)=>s("Error decoding HTTP response",S)}).pipe(A((S)=>{if(S.length===0)return R;g=!0;let k=0;return gr({while:()=>k<S.length,body:()=>{let I=S[k++];if(YS(I))h=!0;return t(f,I)},step:Mn})}))).pipe(Fu((E)=>VJ(E)?E:o(E))),!g)return yield*a(u);else if(!h)return yield*i(u)}),supportsAck:!1,supportsTransferables:!1,codecFor:n.codecFor}})),tG=(e)=>Dc(ps)(A(WR,(t)=>(t=JR(t,NR(e.url)),iU(e.transformClient?e.transformClient(t):t)))),cU=(e)=>ps.make(re(function*(t,n){let r=yield*Qa,o=yield*pn,s=yield*_c(Zm),a=new Map,i=yield*r.writer,c=o.makeUnsafe(),f=yield*rG(M(()=>i.write(c.encode(AP)))),u,d=(p)=>Jr(n,(g)=>t(g,p)),l=(p)=>(u=p,d({_tag:"ClientProtocolError",error:p})),m=(p)=>{try{let g=c.decode(p);if(g.length===0)return R;let h=0;return gr({while:()=>h<g.length,body:()=>{let E=g[h++];if(E._tag==="Pong")return f.onPong(),R;if(Object.hasOwn(E,"requestId")){let S=E.requestId,k=a.get(S);if(k!==void 0){if(E._tag==="Exit")a.delete(S);return t(k,E)}}return d(E)},step:Mn})}catch(g){return d({_tag:"ClientProtocolError",error:new us({reason:new Xs({message:"Error decoding message",cause:g})})})}};return yield*M(()=>(c=o.makeUnsafe(),f.reset(),je(function*(){let{pull:p}=yield*r.reader;if(u=void 0,ve(s))yield*s.value.onConnect;while(!0){let g=yield*p;for(let h=0;h<g.length;h++)yield*m(g[h])}}).pipe(Ja,za(A(f.timeout,()=>_(new Ae({reason:new ao({cause:Error("ping timeout")})}))))))).pipe(ve(s)?_o(s.value.onDisconnect):Q,CE((p)=>{let g=bu(p),h=At(g),E=new us({reason:h?g.success.reason:new Xs({message:"Unknown socket error",cause:Oc(p)})});if(e?.retryTransientErrors&&h&&g.success.reason._tag==="SocketOpenError")return(e.onTransientError?.(E)??R).pipe(nU({log:!0,message:"RpcClient onTransientError hook failed"}));return l(E)}),tU(e?.retryPolicy??nG,(p)=>l(new us({reason:p.reason}))),OE({module:"RpcClient",method:"makeProtocolSocket"}),Ro),{send(p,g){if(u)return _(u);if(g._tag==="Request")a.set(g.id,p);let h=c.encode(g);if(h===void 0)return R;return ls(i.write(h))},supportsAck:!0,supportsTransferables:!1,codecFor:o.codecFor}})),nG=YM([XM(500,1.5),Du(5000)]),rG=re(function*(e){let t=!0,n=ct(),r=()=>{t=!0,n.closeUnsafe()},o=()=>{t=!0};return yield*M(()=>{if(!t)return n.open;return t=!1,e}).pipe(Ks("5 seconds"),vE,Ze,is,Ro),{timeout:n.await,reset:r,onPong:o}}),oG=(e)=>Dc(ps)(cU(e)),fU=(e)=>ps.make(re(function*(t,n){let r=yield*KS,o=yield*Yn,s=0,a=yield*_c(TE),i=yield*_c(Zm),c=new Map,f=(m)=>Jr(n,(p)=>t(p,m)),u=je(function*(){let m=s++,p=yield*r.spawn(m);return yield*p.run((g)=>{if(g._tag==="Exit"){let h=c.get(g.requestId);if(h)return c.delete(g.requestId),h.latch.openUnsafe(),t(h.clientId,g)}else if(g._tag==="Defect"){for(let[h,E]of c)c.delete(h),E.latch.openUnsafe();return f(g)}else if("requestId"in g){let h=c.get(g.requestId);if(h)return t(h.clientId,g)}return f(g)},{onSpawn:ve(a)?A(a.value,([g,h])=>ls(p.send({_tag:"InitialMessage",value:g},h))):void 0}).pipe(CE((g)=>{for(let[E,S]of c){if(S.worker!==p)continue;c.delete(E),S.latch.openUnsafe()}let h=bu(g);return f({_tag:"ClientProtocolError",error:new us({reason:At(h)?h.success.reason:new Xs({message:"Error in worker",cause:Oc(g)})})})}),US(Du(1000)),OE({module:"RpcClient",method:"makeProtocolWorker"}),is,Ro),p}),d="minSize"in e?yield*iP({acquire:u,min:e.minSize,max:e.maxSize,concurrency:e.concurrency,targetUtilization:e.targetUtilization,timeToLive:e.timeToLive}):yield*aP({acquire:u,size:e.size,concurrency:e.concurrency,targetUtilization:e.targetUtilization});yield*Me(o,L(()=>{for(let m of c.values())m.latch.openUnsafe();c.clear()}));let l=(m,p,g)=>{switch(p._tag){case"Request":return LS(d).pipe(A((h)=>{let E=ct(!1);return c.set(p.id,{clientId:m,worker:h,latch:E}),A(h.send(p,g),()=>E.await)}),Ja,ls);case"Interrupt":{let h=c.get(p.requestId);if(!h)return R;return c.delete(p.requestId),h.latch.openUnsafe(),ls(h.worker.send(p))}case"Ack":{let h=c.get(p.requestId);if(!h)return R;return ls(h.worker.send(p))}}return R};if(yield*Ja(LS(d)),ve(i))yield*i.value.onConnect;return{send:l,supportsAck:!0,supportsTransferables:!0,codecFor:uu}})),sG=ja(fU,Dc(ps));class Zm extends Ft()("effect/rpc/RpcClient/ConnectionHooks"){}var dU=F.string().min(8).max(64).regex(/^[A-Za-z0-9_-]+$/),lU=F.strictObject({checkoutPath:F.string().min(1),branch:F.string().min(1),remoteFingerprint:F.string().min(1)}),pU=F.strictObject({operationId:dU,checkoutPath:F.string().min(1),operation:uU}),Xm=F.strictObject({}),Ym=F.strictObject({brokerId:F.string().min(1),checkouts:F.array(F.string()),ambiguousRequestIds:F.array(dU),evidenceComplete:F.boolean(),recoveryPending:F.boolean(),admitsMutations:F.boolean()}),rd=F.strictObject({_tag:F.literal("BrokerError"),message:F.string().min(1)}),mU=F.discriminatedUnion("_tag",[F.strictObject({_tag:F.literal("Progress"),phase:F.literal("running"),observedAt:F.string().min(1).max(64)}),F.strictObject({_tag:F.literal("Result"),outcome:F.enum(["ok","error"]),value:F.unknown(),error:F.string().nullable()})]);function wr(e){return sn.declare((t)=>e.safeParse(t).success)}var hU=dm.make(ss.make("RegisterCheckout",{payload:wr(lU),success:wr(Ym),error:wr(rd)}),ss.make("QueryStatus",{payload:wr(Xm),success:wr(Ym),error:wr(rd)}),ss.make("OpenAdmission",{payload:wr(Xm),success:wr(Ym),error:wr(rd)}),ss.make("ExecuteOperation",{payload:wr(pU),success:wr(mU),error:wr(rd),stream:!0})),od=F.union([F.string().min(1).max(64),F.number().int().nonnegative().max(Number.MAX_SAFE_INTEGER)]),Qm={_tag:F.literal("Request"),id:od,headers:F.array(F.tuple([F.string(),F.string()])),traceId:F.string().optional(),spanId:F.string().optional(),sampled:F.boolean().optional()},aG=F.discriminatedUnion("tag",[F.strictObject({...Qm,tag:F.literal("RegisterCheckout"),payload:lU}),F.strictObject({...Qm,tag:F.literal("ExecuteOperation"),payload:pU}),F.strictObject({...Qm,tag:F.literal("QueryStatus"),payload:Xm}),F.strictObject({...Qm,tag:F.literal("OpenAdmission"),payload:Xm})]),iG=F.array(F.discriminatedUnion("_tag",[F.strictObject({_tag:F.literal("Fail"),error:rd}),F.strictObject({_tag:F.literal("Die"),defect:F.unknown()}),F.strictObject({_tag:F.literal("Interrupt"),fiberId:F.number().optional()})])),cG=F.discriminatedUnion("_tag",[F.strictObject({_tag:F.literal("Success"),value:Ym.nullable().optional()}),F.strictObject({_tag:F.literal("Failure"),cause:iG})]),fG=F.union([aG,F.strictObject({_tag:F.literal("Ack"),requestId:od}),F.strictObject({_tag:F.literal("Interrupt"),requestId:od}),F.strictObject({_tag:F.literal("Ping")}),F.strictObject({_tag:F.literal("Eof")})]),uG=F.union([fG,F.strictObject({_tag:F.literal("Pong")}),F.strictObject({_tag:F.literal("Chunk"),requestId:od,values:F.array(mU).min(1)}),F.strictObject({_tag:F.literal("Exit"),requestId:od,exit:cG}),F.strictObject({_tag:F.literal("Defect"),defect:F.unknown()})]);function gU(e){return uG.safeParse(e).success}import{createConnection as mG}from"net";import{Buffer as yU}from"buffer";import*as $c from"tls";import*as xQ from"ws";var dG="Deno"in globalThis;var lG=(e)=>{let t=e.read();if(t===null)return;let n=e.read();if(n===null)return[t];let r=[t,n],o;while((o=e.read())!==null)r.push(o);return r},xU=(e)=>hn(_E(e),(t)=>yU.from(t));var SU=(e,t)=>dt((n)=>{let r,o=ct(!1),s=n.context,a=t?.tlsServer===!0,i=a?"secure":"secureConnect",c=je(function*(){let m=yield*Yn,p=yield*In(e,m).pipe(t?.openTimeout!==void 0?Im({duration:t.openTimeout,orElse:()=>_(new Ae({reason:new cs({kind:"Timeout",cause:Error("Connection timed out")})}))}):Q),g,h,E,S=!1,k=!1,I=!0;function x(){if(h===void 0||S)return;let N=E;if(E=void 0,N===void 0&&!k){S=!0;try{N=lG(p)}finally{S=!1}}if(k)N=void 0;if(h===void 0){E=N;return}let G=N!==void 0?b(N):g!==void 0?_(g):void 0;if(G===void 0)return;let fe=h;h=void 0,fe(G)}function w(N){g??=N,x()}function C(N){g??=N,k=!0,E=void 0,x()}function T(){w(new Ae({reason:new fs({code:1000})}))}function v(N){C(new Ae({reason:new ao({cause:N})}))}function O(N){let G=new Ae({reason:new fs({code:N?1006:1000})});if(N)C(G);else w(G)}function U(N){N.on("readable",x),N.on("end",T),N.on("error",v),N.on("close",O)}function j(N){N.off("readable",x),N.off("end",T),N.off("error",v),N.off("close",O)}if(!dG)p.pause();return U(p),yield*Me(m,L(()=>{C(new Ae({reason:new fs({code:1006})})),j(p),o.closeUnsafe(),r=void 0,I=!1})),r=p,o.openUnsafe(),{pull:Gn((N)=>{if(h=N,x(),h!==N)return;return L(()=>{if(h===N)h=void 0})}),upgrade:(N={})=>M(()=>{if(!I)return _(new Ae({reason:new io({cause:Error("socket is already upgraded or closed")})}));let G=N.key!==void 0,fe=N.cert!==void 0;if(a&&(!G||!fe)||G!==fe)return _(new Ae({reason:new io({cause:Error(a?"server TLS upgrade requires both key and cert":"TLS upgrade credentials must include both key and cert")})}));return Gn((Ge)=>{let Ot=p;j(Ot);let et;try{let Jc={secureContext:$c.createSecureContext({key:N.key===void 0?void 0:hn(_E(N.key),(AU)=>yU.from(Rr(AU))),cert:N.cert===void 0?void 0:xU(N.cert),ca:N.ca===void 0?void 0:xU(N.ca),passphrase:N.passphrase===void 0?void 0:Rr(N.passphrase)}),ALPNProtocols:N.alpnProtocols===void 0?void 0:[...N.alpnProtocols],requestCert:N.requestCert,rejectUnauthorized:N.rejectUnauthorized};et=a?new $c.TLSSocket(Ot,{...Jc,isServer:!0}):$c.connect({...Jc,socket:Ot})}catch(sd){U(Ot),Ge(_(new Ae({reason:new io({cause:sd})})));return}p=et,r=et,et.pause();function wt(){et.off(i,ti),et.off("error",eh),et.off("close",UE)}function ti(){wt(),I=!1,U(et),Ge(R)}function eh(sd){wt();let Jc=new Ae({reason:new io({cause:sd})});C(Jc),Ge(_(Jc))}function UE(){eh(Error("socket closed during TLS upgrade"))}return et.once(i,ti),et.once("error",eh),et.once("close",UE),L(()=>{wt(),C(new Ae({reason:new fs({code:1006})})),et.destroy()})})})}}).pipe(Qs((m)=>er(s,m))),f=(m)=>Gn((p)=>{function g(){m.off("drain",h),m.off("error",E),m.off("close",S)}function h(){g(),p(R)}function E(k){g(),p(_(new Ae({reason:new Er({cause:k})})))}function S(){g(),p(_(new Ae({reason:new Er({cause:Error("socket closed")})})))}return m.on("drain",h),m.on("error",E),m.on("close",S),L(g)}),u=(m)=>M(()=>{let p=r;if(p===void 0)return o.whenOpen(u(m));if(Nc(m))return p.destroy(m.code>1000?Error(`closed with code ${m.code}`):void 0),R;try{return p.write(m)?R:f(p)}catch(g){return _(new Ae({reason:new Er({cause:g})}))}}),d=(m)=>M(()=>{let p=r;if(p===void 0)return o.whenOpen(d(m));let g=!1;try{if(m.length===1)g=!p.write(m[0]);else{p.cork();try{for(let h=0;h<m.length;h++)g=!p.write(m[h])||g}finally{p.uncork()}}}catch(h){return _(new Ae({reason:new Er({cause:h})}))}return g?f(p):R}),l=xr(b({write:u,writeAll:d}),()=>L(()=>{if(!r||r.writableEnded)return;r.end()}));return b(Wu({reader:c,writer:l}))});var SQ="Deno"in globalThis;function bU(e){return Y.suspend(()=>{let t,n=Y.acquireRelease(Y.callback((r)=>{let o=mG(e);return t=o,o.once("connect",()=>r(Y.succeed(o))),o.on("error",(s)=>r(Y.fail(new Ae({reason:new cs({kind:"Unknown",cause:s})})))),Y.sync(()=>{o.destroy()})}),(r)=>Y.sync(()=>{r.destroy()}),{interruptible:!0});return Y.map(SU(n),(r)=>({socket:r,bufferedBytes:()=>t?.writableLength??0,close:()=>{t?.destroy()}}))})}var qc=2,Hc=8388608;class kr extends Error{code;constructor(e,t){super(t);this.name="ProtocolError",this.code=e}}function IU(e,t){let n=t.maxPendingBytes??Hc*2;if(!Number.isSafeInteger(n)||n<1||n>Hc*2)throw RangeError("Invalid broker RPC output limit");let r=0,o;return co.make({reader:e.reader,writer:Y.map(e.writer,(s)=>{let a=(i)=>Y.suspend(()=>{if(o)return Y.fail(o);if(co.isCloseEvent(i))return s.write(i);let c=typeof i==="string"?Buffer.byteLength(i,"utf8"):i.byteLength;if(Math.max(r,t.bufferedBytes())+c>n)return o=new co.SocketError({reason:new co.SocketWriteError({cause:Error(`RPC output backpressure exceeds the ${n}-byte pending limit`)})}),t.onOverflow(),Y.fail(o);return r+=c,s.write(i).pipe(Y.ensuring(Y.sync(()=>{r-=c})))});return{write:a,writeAll:(i)=>Y.forEach(i,a,{discard:!0})}})})}function wU(e){return Zn.effect(co.Socket,Y.map(bU({path:e}),(t)=>IU(t.socket,{bufferedBytes:t.bufferedBytes,onOverflow:t.close})))}var jc=4,hG=new TextEncoder,gG=F.strictObject({version:F.number().int().nonnegative(),message:F.unknown()});function kU(e={}){let t=e.maxFrameBytes??Hc;if(!Number.isSafeInteger(t)||t<1||t>Hc)throw RangeError("Invalid broker RPC frame limit");return{contentType:"application/x-brain-git-rpc",includesFraming:!0,codecFor:sn.toCodecJson,makeUnsafe:()=>{let n=new Uint8Array(jc),r=new TextDecoder("utf-8",{fatal:!0}),o=0,s,a=0,i=!1,c=(d)=>{if(!gU(d))throw new kr("malformed","Invalid broker RPC message");return d},f=(d)=>{let l;try{l=JSON.parse(r.decode(d))}catch{throw new kr("malformed","Frame body is not valid UTF-8 JSON")}let m=gG.safeParse(l);if(!m.success)throw new kr("malformed","Invalid broker RPC frame wrapper");if(m.data.version!==qc)throw new kr("version-mismatch",`Broker protocol version ${m.data.version} is not ${qc}`);return c(m.data.message)},u=(d)=>{let l=c(d),m=JSON.stringify({version:qc,message:l}),p=Buffer.byteLength(m,"utf8");if(p>t)throw new kr("frame-too-large",`RPC frame has ${p} bytes; limit is ${t}`);let g=new Uint8Array(jc+p);return new DataView(g.buffer).setUint32(0,p,!1),g.set(hG.encode(m),jc),g};return{get retainedBytes(){return o+(s?.byteLength??0)},decode:(d)=>{if(i)throw new kr("malformed","RPC parser is closed after a framing failure");let l=[],m=0;try{if(typeof d==="string")throw new kr("malformed","Broker RPC requires byte frames");while(m<d.length){if(!s){let g=Math.min(jc-o,d.length-m);if(n.set(d.subarray(m,m+g),o),o+=g,m+=g,o<jc)break;let h=new DataView(n.buffer).getUint32(0,!1);if(h>t)throw new kr("frame-too-large",`Frame declares ${h} bytes; limit is ${t}`);if(h===0)throw new kr("malformed","Empty RPC frame");s=new Uint8Array(h)}let p=Math.min(s.length-a,d.length-m);if(s.set(d.subarray(m,m+p),a),a+=p,m+=p,a<s.length)break;l.push(f(s)),o=0,a=0,s=void 0}return l}catch(p){throw i=!0,o=0,a=0,s=void 0,p}},encode:(d)=>{if(!Array.isArray(d))return u(d);if(d.length===0)return;let l=[],m=0;for(let h of d){let E=u(h);if(m+=E.length,m>t+jc)throw new kr("frame-too-large","RPC frame batch exceeds the output limit");l.push(E)}let p=new Uint8Array(m),g=0;for(let h of l)p.set(h,g),g+=h.length;return p}}}}}class TU{#e;#u=Y.runSync(Jn.make());#a=new AbortController;#t=new Set;#i=new Map;#c;#n=!1;constructor(e){this.#e=e}static async connect(e){let t=new TU(e),n=PE(),r=Zn.effect(ms.Protocol,ms.makeProtocolSocket({retryPolicy:wu.recurs(0)})).pipe(Zn.provide(wU(e)),Zn.provide(Zn.succeed(nd.RpcSerialization,kU())));try{return t.#c=await Y.runPromise(Jn.provide(Y.gen(function*(){let o=yield*Zn.build(r).pipe(Y.provideService(ms.ConnectionHooks,{onConnect:Y.sync(()=>n.resolve()),onDisconnect:Y.sync(()=>{let s=new na(e,"broker closed the connection");n.reject(s),t.#r(s)})}));return yield*ms.make(hU,{disableTracing:!0}).pipe(Y.provideService(ms.Protocol,kt.get(o,ms.Protocol)))}),t.#u)),await n.promise,t}catch(o){throw t.close(),o instanceof na?o:new na(e,String(o))}}onUnavailable(e){return this.#t.add(e),()=>{this.#t.delete(e)}}close(){if(this.#n)return;this.#t.clear(),this.#r(new na(this.#e,"client closed the connection"))}#r(e){if(this.#n)return;this.#n=!0,this.#a.abort(e);let t=[...this.#t];this.#t.clear(),Y.runFork(Jn.close(this.#u,Yt.void)),t.forEach((n)=>n())}#o(){if(this.#n||!this.#c)throw new na(this.#e,"connection closed");return this.#c}async#s(e,t){let n=t?AbortSignal.any([t,this.#a.signal]):this.#a.signal;try{return await Y.runPromise(e.pipe(Y.onInterrupt(()=>Y.sync(()=>{if(!n.aborted)this.#r(new na(this.#e,"broker interrupted RPC observation"))}))),{signal:n})}catch(r){if(n.aborted)throw n.reason;if(r instanceof Cm.RpcClientError){let o=new na(this.#e,String(r));throw this.#r(o),o}if(typeof r==="object"&&r!==null&&"_tag"in r&&r._tag==="BrokerError"&&"message"in r&&typeof r.message==="string")throw new Wc(r.message);throw r}}#f(e){return{...e,type:"status",version:qc,requestId:`req_${RE(12)}`}}async registerCheckout(e){return this.#f(await this.#s(this.#o().RegisterCheckout(e)))}async openAdmission(){return this.#f(await this.#s(this.#o().OpenAdmission({})))}async status(){return this.#f(await this.#s(this.#o().QueryStatus({})))}executeWithId(e,t,n,r={}){return this.#d(e,t,n,r)}async execute(e,t,n={}){return this.#d(`req_${RE(12)}`,e,t,n)}async#d(e,t,n,r){r.signal?.throwIfAborted();let o=JSON.stringify(n),s=this.#i.get(e);if(s){if(s.checkoutPath!==t||s.operationIdentity!==o)throw new Wc(`Request ${e} is already used for different Git work`);return ME(n.name,await s.reply)}let a=this.#o(),i=PE();this.#i.set(e,{checkoutPath:t,operationIdentity:o,reply:i.promise});let c,f=so.runForEach(a.ExecuteOperation({operationId:e,checkoutPath:t,operation:n}).pipe(so.takeUntil((u)=>u._tag==="Result")),(u)=>Y.sync(()=>{if(c)throw new Wc("Git RPC sent events after a terminal result");if(u._tag==="Progress")r.onProgress?.();else c=u}));this.#s(f,r.signal).then(()=>{if(!c)throw new Wc("Git RPC ended without a terminal result");if(c.outcome==="error")throw new Wc(c.error??"unknown");return c.value}).then(i.resolve,i.reject);try{return ME(n.name,await i.promise)}finally{this.#i.delete(e)}}}export{TU as BrokerConnection,Wc as BrokerOperationError,na as BrokerUnavailableError};
|
|
15
15
|
|
|
16
|
-
//# debugId=
|
|
17
|
-
//# sourceMappingURL=client-
|
|
16
|
+
//# debugId=16DC6DCAAFE4A60D64756E2164756E21
|
|
17
|
+
//# sourceMappingURL=client-6s8fzpc6.js.map
|