bb-plugin-goal 0.0.0-stage → 0.1.3
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/LICENSE +21 -0
- package/README.md +95 -2
- package/app.tsx +805 -0
- package/components/ui/button.tsx +60 -0
- package/components/ui/coarse-pointer-sizing.ts +76 -0
- package/components/ui/input.tsx +31 -0
- package/components/ui/motion.ts +21 -0
- package/dist/app.css +2 -0
- package/dist/app.js +1 -0
- package/dist/app.meta.json +19 -0
- package/dist/package.json +1 -0
- package/dist/server.js +442 -0
- package/dist/server.js.map +6 -0
- package/dist/server.meta.json +11 -0
- package/lib/utils.ts +24 -0
- package/package.json +72 -4
- package/server.ts +1758 -0
- package/src/coordinator.ts +892 -0
- package/src/domain.ts +407 -0
- package/src/failure.ts +202 -0
- package/src/history-cursor.ts +46 -0
- package/src/progress.ts +167 -0
- package/src/repository.ts +1735 -0
- package/src/runtime.ts +189 -0
- package/src/usage-wait.ts +21 -0
package/dist/server.js
ADDED
|
@@ -0,0 +1,442 @@
|
|
|
1
|
+
import { createRequire as __createRequire } from "node:module";
|
|
2
|
+
import { dirname as __pathDirname } from "node:path";
|
|
3
|
+
import { fileURLToPath as __fileURLToPath } from "node:url";
|
|
4
|
+
const require = __createRequire(import.meta.url);
|
|
5
|
+
var __filename = __fileURLToPath(import.meta.url);
|
|
6
|
+
var __dirname = __pathDirname(__filename);
|
|
7
|
+
var tO=Object.defineProperty;var s=(e,t)=>tO(e,"name",{value:t,configurable:!0});var $t=(e,t)=>{for(var n in t)tO(e,n,{get:t[n],enumerable:!0})};import{isAbsolute as Cte,resolve as Ote}from"node:path";import{defineRpcContract as Rte}from"@get-bb/plugin-sdk";var R={};$t(R,{$brand:()=>Wy,$input:()=>_v,$output:()=>vv,INVALID:()=>en,NEVER:()=>Jy,TimePrecision:()=>Nv,ZodAny:()=>vw,ZodArray:()=>Iw,ZodBase64:()=>Pm,ZodBase64URL:()=>Nm,ZodBigInt:()=>pc,ZodBigIntFormat:()=>Fm,ZodBoolean:()=>dc,ZodCIDRv4:()=>Rm,ZodCIDRv6:()=>$m,ZodCUID:()=>Em,ZodCUID2:()=>Im,ZodCatch:()=>Vw,ZodCodec:()=>Rl,ZodCompileAsyncError:()=>gr,ZodCompileUnsupportedError:()=>we,ZodCreditCard:()=>pw,ZodCustom:()=>$l,ZodCustomStringFormat:()=>bi,ZodDate:()=>Il,ZodDefault:()=>Uw,ZodDiscriminatedUnion:()=>kw,ZodE164:()=>Dm,ZodEmail:()=>bm,ZodEmoji:()=>_m,ZodEnum:()=>uc,ZodError:()=>Z4,ZodExactOptional:()=>Gm,ZodFile:()=>Lw,ZodFirstPartyTypeKind:()=>iE,ZodFunction:()=>nE,ZodGUID:()=>vm,ZodIBAN:()=>mw,ZodIPv4:()=>Cm,ZodIPv6:()=>Om,ZodISODate:()=>bs,ZodISODateTime:()=>Ss,ZodISODuration:()=>_s,ZodISOTime:()=>vs,ZodInstanceOf:()=>sE,ZodIntersection:()=>Aw,ZodIssueCode:()=>V4,ZodJWT:()=>Lm,ZodKSUID:()=>Am,ZodLazy:()=>Qw,ZodLiteral:()=>Dw,ZodMAC:()=>dw,ZodMap:()=>Pw,ZodNaN:()=>Kw,ZodNanoID:()=>wm,ZodNever:()=>ww,ZodNonOptional:()=>jm,ZodNull:()=>Sw,ZodNullable:()=>Mw,ZodNumber:()=>fc,ZodNumberFormat:()=>vi,ZodObject:()=>kl,ZodOptional:()=>Cl,ZodPipe:()=>Ol,ZodPrefault:()=>jw,ZodPreprocess:()=>Jw,ZodPromise:()=>tE,ZodReadonly:()=>Ww,ZodRealError:()=>yn,ZodRecord:()=>cc,ZodSet:()=>Nw,ZodString:()=>lc,ZodStringFormat:()=>Fe,ZodSuccess:()=>Bw,ZodSymbol:()=>xw,ZodTemplateLiteral:()=>Xw,ZodTransform:()=>Fw,ZodTuple:()=>Ow,ZodType:()=>me,ZodULID:()=>Tm,ZodURL:()=>El,ZodUUID:()=>Hr,ZodUndefined:()=>yw,ZodUnion:()=>Al,ZodUnknown:()=>_w,ZodVoid:()=>Ew,ZodXID:()=>km,ZodXor:()=>Tw,_ZodString:()=>Sm,_default:()=>Gw,_function:()=>IR,any:()=>nR,array:()=>Tl,base64:()=>L0,base64url:()=>F0,bigint:()=>Y0,boolean:()=>gw,catch:()=>Hw,check:()=>TR,cidrv4:()=>N0,cidrv6:()=>D0,clone:()=>Pe,codec:()=>vR,coerce:()=>cE,compile:()=>Tv,config:()=>rt,core:()=>Eo,creditCard:()=>M0,cuid:()=>T0,cuid2:()=>k0,currencyCode:()=>B0,custom:()=>kR,date:()=>oR,decode:()=>sw,decodeAsync:()=>aw,deepPartial:()=>UR,describe:()=>AR,discriminatedUnion:()=>lR,e164:()=>z0,email:()=>g0,emoji:()=>E0,encode:()=>ow,encodeAsync:()=>iw,endsWith:()=>Ya,enum:()=>Mm,exactOptional:()=>zw,file:()=>xR,flattenError:()=>Hu,float32:()=>H0,float64:()=>K0,formatError:()=>Ku,fromJSONSchema:()=>zR,function:()=>IR,getDiscriminatedOption:()=>Jb,getErrorMap:()=>K4,globalRegistry:()=>Nt,gt:()=>Br,gte:()=>Nn,guid:()=>x0,hash:()=>V0,hex:()=>q0,hostname:()=>Z0,httpUrl:()=>w0,iban:()=>U0,includes:()=>Ja,input:()=>jR,instanceof:()=>OR,int:()=>xm,int32:()=>J0,int64:()=>X0,intersection:()=>Cw,invertCodec:()=>_R,ipv4:()=>R0,ipv6:()=>P0,iso:()=>Pl,json:()=>$R,jwt:()=>G0,keyof:()=>sR,ksuid:()=>O0,lazy:()=>eE,length:()=>hi,literal:()=>gR,locales:()=>ml,looseObject:()=>cR,looseRecord:()=>dR,lowercase:()=>Ha,lt:()=>qr,lte:()=>Pn,mac:()=>$0,map:()=>pR,maxLength:()=>mi,maxSize:()=>hs,memoizer:()=>dl,meta:()=>CR,mime:()=>Qa,minLength:()=>wo,minSize:()=>Vr,multipleOf:()=>ms,nan:()=>bR,nanoid:()=>I0,nativeEnum:()=>hR,negative:()=>im,never:()=>zm,nonnegative:()=>cm,nonoptional:()=>qw,nonpositive:()=>am,normalize:()=>ec,null:()=>bw,nullable:()=>wl,nullish:()=>yR,number:()=>hw,object:()=>iR,optional:()=>yi,output:()=>ZR,overwrite:()=>xr,parse:()=>ew,parseAsync:()=>tw,partialRecord:()=>fR,pipe:()=>ym,positive:()=>sm,prefault:()=>Zw,preprocess:()=>PR,prettifyError:()=>tS,promise:()=>ER,properties:()=>Xa,property:()=>um,readonly:()=>Yw,record:()=>$w,refine:()=>rE,regex:()=>Va,regexes:()=>Wn,registry:()=>Np,safeDecode:()=>uw,safeDecodeAsync:()=>fw,safeEncode:()=>cw,safeEncodeAsync:()=>lw,safeParse:()=>nw,safeParseAsync:()=>rw,set:()=>mR,setErrorMap:()=>H4,size:()=>pi,slugify:()=>oc,startsWith:()=>Wa,strictObject:()=>aR,string:()=>_l,stringFormat:()=>j0,stringbool:()=>RR,success:()=>SR,superRefine:()=>oE,symbol:()=>eR,templateLiteral:()=>wR,toJSONSchema:()=>pm,toLowerCase:()=>nc,toUpperCase:()=>rc,toZod:()=>Fu,transform:()=>Um,treeifyError:()=>eS,trim:()=>tc,tuple:()=>Rw,uint32:()=>W0,uint64:()=>Q0,ulid:()=>A0,undefined:()=>tR,union:()=>mc,unknown:()=>xi,uppercase:()=>Ka,url:()=>_0,util:()=>j,uuid:()=>y0,uuidv4:()=>S0,uuidv6:()=>b0,uuidv7:()=>v0,validate:()=>Ju,validateAsync:()=>Wu,void:()=>rR,withParser:()=>Dp,xid:()=>C0,xor:()=>uR});var Eo={};$t(Eo,{$ZodAny:()=>Ub,$ZodArray:()=>Vb,$ZodAsyncError:()=>gn,$ZodBase64:()=>Ab,$ZodBase64URL:()=>Cb,$ZodBigInt:()=>wp,$ZodBigIntFormat:()=>Lb,$ZodBoolean:()=>il,$ZodCIDRv4:()=>Tb,$ZodCIDRv6:()=>kb,$ZodCUID:()=>mb,$ZodCUID2:()=>hb,$ZodCatch:()=>fv,$ZodCheck:()=>ze,$ZodCheckBigIntFormat:()=>GS,$ZodCheckEndsWith:()=>QS,$ZodCheckGreaterThan:()=>ap,$ZodCheckIncludes:()=>YS,$ZodCheckLengthEquals:()=>HS,$ZodCheckLessThan:()=>ip,$ZodCheckLowerCase:()=>JS,$ZodCheckMaxLength:()=>BS,$ZodCheckMaxSize:()=>jS,$ZodCheckMimeType:()=>nb,$ZodCheckMinLength:()=>VS,$ZodCheckMinSize:()=>ZS,$ZodCheckMultipleOf:()=>MS,$ZodCheckNumberFormat:()=>US,$ZodCheckOverwrite:()=>rb,$ZodCheckProperties:()=>tb,$ZodCheckProperty:()=>eb,$ZodCheckRegex:()=>KS,$ZodCheckSizeEquals:()=>qS,$ZodCheckStartsWith:()=>XS,$ZodCheckStringFormat:()=>ja,$ZodCheckUpperCase:()=>WS,$ZodCodec:()=>cl,$ZodCreditCard:()=>Rb,$ZodCustom:()=>yv,$ZodCustomStringFormat:()=>Nb,$ZodCyclicError:()=>Op,$ZodDate:()=>qb,$ZodDefault:()=>av,$ZodDiscriminatedUnion:()=>Wb,$ZodE164:()=>Ob,$ZodEmail:()=>cb,$ZodEmoji:()=>db,$ZodEncodeError:()=>ds,$ZodEnum:()=>tv,$ZodError:()=>Qy,$ZodExactOptional:()=>sv,$ZodFile:()=>rv,$ZodFunction:()=>gv,$ZodGUID:()=>ib,$ZodIBAN:()=>$b,$ZodIPv4:()=>wb,$ZodIPv6:()=>Eb,$ZodISODate:()=>bb,$ZodISODateTime:()=>Sb,$ZodISODuration:()=>_b,$ZodISOTime:()=>vb,$ZodIntersection:()=>Yb,$ZodJWT:()=>Pb,$ZodKSUID:()=>yb,$ZodLazy:()=>ul,$ZodLiteral:()=>nv,$ZodMAC:()=>Ib,$ZodMap:()=>Qb,$ZodNaN:()=>dv,$ZodNanoID:()=>pb,$ZodNever:()=>jb,$ZodNonOptional:()=>uv,$ZodNull:()=>Mb,$ZodNullable:()=>iv,$ZodNumber:()=>_p,$ZodNumberFormat:()=>Db,$ZodObject:()=>LO,$ZodObjectJIT:()=>Hb,$ZodOptional:()=>Ip,$ZodPipe:()=>Tp,$ZodPrefault:()=>cv,$ZodPreprocess:()=>pv,$ZodPromise:()=>xv,$ZodReadonly:()=>mv,$ZodRealError:()=>xn,$ZodRecord:()=>Xb,$ZodRegistry:()=>Pp,$ZodSet:()=>ev,$ZodString:()=>ui,$ZodStringFormat:()=>Ne,$ZodSuccess:()=>lv,$ZodSymbol:()=>Fb,$ZodTemplateLiteral:()=>hv,$ZodTransform:()=>ov,$ZodTuple:()=>Ep,$ZodType:()=>ue,$ZodULID:()=>gb,$ZodURL:()=>fb,$ZodUUID:()=>ab,$ZodUndefined:()=>zb,$ZodUnion:()=>al,$ZodUnknown:()=>Gb,$ZodVoid:()=>Zb,$ZodXID:()=>xb,$ZodXor:()=>Kb,$brand:()=>Wy,$constructor:()=>_,$input:()=>_v,$output:()=>vv,Doc:()=>ci,INVALID:()=>en,JSONSchema:()=>p0,JSONSchemaGenerator:()=>mm,NEVER:()=>Jy,TimePrecision:()=>Nv,URL_BAD_FORMAT:()=>ub,URL_UNPARSEABLE:()=>tl,ZodCompileAsyncError:()=>gr,ZodCompileUnsupportedError:()=>we,_any:()=>Yv,_array:()=>o_,_base64:()=>tm,_base64url:()=>nm,_bigint:()=>qv,_boolean:()=>jv,_catch:()=>R4,_check:()=>YO,_cidrv4:()=>Qp,_cidrv6:()=>em,_coercedBigint:()=>Bv,_coercedBoolean:()=>Zv,_coercedDate:()=>n_,_coercedNumber:()=>Lv,_coercedString:()=>Ov,_creditCard:()=>$v,_cuid:()=>Vp,_cuid2:()=>Hp,_custom:()=>i_,_date:()=>t_,_decode:()=>Jd,_decodeAsync:()=>Yd,_default:()=>A4,_discriminatedUnion:()=>g4,_e164:()=>rm,_email:()=>zp,_emoji:()=>qp,_encode:()=>Kd,_encodeAsync:()=>Wd,_endsWith:()=>Ya,_enum:()=>_4,_file:()=>s_,_float32:()=>zv,_float64:()=>Mv,_gt:()=>Br,_gte:()=>Nn,_guid:()=>Mp,_iban:()=>Pv,_includes:()=>Ja,_int:()=>Fv,_int32:()=>Uv,_int64:()=>Vv,_intersection:()=>x4,_ipv4:()=>Yp,_ipv6:()=>Xp,_isoDate:()=>xl,_isoDateTime:()=>gl,_isoDuration:()=>Sl,_isoTime:()=>yl,_jwt:()=>om,_ksuid:()=>Wp,_lazy:()=>D4,_length:()=>hi,_literal:()=>E4,_lowercase:()=>Ha,_lt:()=>qr,_lte:()=>Pn,_mac:()=>Rv,_map:()=>b4,_max:()=>Pn,_maxLength:()=>mi,_maxSize:()=>hs,_mime:()=>Qa,_min:()=>Nn,_minLength:()=>wo,_minSize:()=>Vr,_multipleOf:()=>ms,_nan:()=>r_,_nanoid:()=>Bp,_nativeEnum:()=>w4,_negative:()=>im,_never:()=>Qv,_nonnegative:()=>cm,_nonoptional:()=>C4,_nonpositive:()=>am,_normalize:()=>ec,_null:()=>Wv,_nullable:()=>k4,_number:()=>Dv,_optional:()=>T4,_overwrite:()=>xr,_parse:()=>za,_parseAsync:()=>Ma,_pipe:()=>$4,_positive:()=>sm,_promise:()=>L4,_properties:()=>Xa,_property:()=>um,_readonly:()=>P4,_record:()=>S4,_refine:()=>a_,_regex:()=>Va,_safeDecode:()=>Qd,_safeDecodeAsync:()=>tp,_safeEncode:()=>Xd,_safeEncodeAsync:()=>ep,_safeParse:()=>Ua,_safeParseAsync:()=>Ga,_set:()=>v4,_size:()=>pi,_slugify:()=>oc,_startsWith:()=>Wa,_string:()=>Cv,_stringFormat:()=>gi,_stringbool:()=>f_,_success:()=>O4,_superRefine:()=>c_,_symbol:()=>Kv,_templateLiteral:()=>N4,_toLowerCase:()=>nc,_toUpperCase:()=>rc,_transform:()=>I4,_trim:()=>tc,_tuple:()=>y4,_uint32:()=>Gv,_uint64:()=>Hv,_ulid:()=>Kp,_undefined:()=>Jv,_union:()=>m4,_unknown:()=>Xv,_uppercase:()=>Ka,_url:()=>hl,_uuid:()=>Up,_uuidv4:()=>Gp,_uuidv6:()=>jp,_uuidv7:()=>Zp,_void:()=>e_,_xid:()=>Jp,_xor:()=>h4,base64Charset:()=>xp,base64urlCharset:()=>sl,canParseURL:()=>lb,clone:()=>Pe,compile:()=>Tv,compileFn:()=>Lp,config:()=>rt,createStandardJSONSchemaMethod:()=>sc,createToJSONSchemaMethod:()=>p_,decode:()=>vq,decodeAsync:()=>wq,describe:()=>u_,encode:()=>bq,encodeAsync:()=>_q,extractDefs:()=>xs,finalize:()=>ys,flattenError:()=>Hu,formatError:()=>Ku,getDiscriminatedOption:()=>Jb,globalConfig:()=>Et,globalRegistry:()=>Nt,handleUnrepresentable:()=>mt,initializeContext:()=>gs,isBackEdge:()=>$p,isRecursiveSchema:()=>Rp,isValidBase64:()=>ol,isValidBase64URL:()=>yp,isValidCIDRv6:()=>gp,isValidCreditCard:()=>Sp,isValidIBAN:()=>bp,isValidIPv6:()=>rl,isValidJWT:()=>vp,locales:()=>ml,memoizer:()=>dl,mergeValues:()=>Za,meta:()=>l_,parse:()=>Vd,parseAsync:()=>Hd,parseURLObject:()=>PO,prettifyError:()=>tS,process:()=>De,processSchema:()=>De,regexes:()=>Wn,registry:()=>Np,safeDecode:()=>Iq,safeDecodeAsync:()=>kq,safeEncode:()=>Eq,safeEncodeAsync:()=>Tq,safeParse:()=>hq,safeParseAsync:()=>gq,standardProps:()=>dp,stripTabAndNewline:()=>nl,toDotPath:()=>dO,toJSONSchema:()=>pm,toZod:()=>Fu,treeifyError:()=>eS,urlHostnameOk:()=>mp,urlProtocolOk:()=>hp,util:()=>j,validate:()=>Ju,validateAsync:()=>Wu,validateURL:()=>pp,version:()=>ob,withParser:()=>Dp});var j={};$t(j,{BIGINT_FORMAT_RANGES:()=>ju,CONSTANT_CATCH:()=>qd,Class:()=>zy,NUMBER_FORMAT_RANGES:()=>Gu,aborted:()=>Qt,allowsEval:()=>Gy,assert:()=>DZ,assertEqual:()=>RZ,assertIs:()=>PZ,assertNever:()=>NZ,assertNotEqual:()=>$Z,assignProp:()=>Pt,attachSchema:()=>Zu,base64ToUint8Array:()=>iO,base64urlToUint8Array:()=>eq,cached:()=>Na,captureStackTrace:()=>Gd,cleanEnum:()=>QZ,cleanRegex:()=>vo,clone:()=>Pe,cloneDef:()=>zZ,codePointLength:()=>ii,constantCatch:()=>Hy,createTransparentProxy:()=>qZ,defineLazy:()=>My,defineLazyInternal:()=>he,derived:()=>oq,esc:()=>Xt,escapeRegex:()=>Jn,explicitlyAborted:()=>qy,extend:()=>HZ,finalizeIssue:()=>hn,floatSafeRemainder:()=>zu,getElementAtPath:()=>MZ,getEnumValues:()=>$a,getLengthableOrigin:()=>Bu,getParsedType:()=>ZZ,getSizableOrigin:()=>qu,hexToUint8Array:()=>nq,hide:()=>Vu,installLazyProp:()=>cq,isObject:()=>si,isPlainObject:()=>Kn,issue:()=>Fa,joinValues:()=>Md,jsonStringifyReplacer:()=>Pa,members:()=>Vy,merge:()=>JZ,mergeDefs:()=>hr,normalizeParams:()=>N,nullish:()=>Ud,numKeys:()=>jZ,objectClone:()=>LZ,omit:()=>VZ,optionalKeys:()=>Zy,own:()=>fs,parsedType:()=>By,partial:()=>WZ,pick:()=>BZ,prefixIssues:()=>mn,primitiveTypes:()=>jy,promiseAllObject:()=>UZ,propertyKeyTypes:()=>Uu,randomString:()=>GZ,rawShape:()=>Da,required:()=>YZ,safeExtend:()=>KZ,shallowClone:()=>Mu,sizeCaps:()=>La,slugify:()=>Uy,stringifyPrimitive:()=>jd,toZod:()=>Fu,uint8ArrayToBase64:()=>aO,uint8ArrayToBase64url:()=>tq,uint8ArrayToHex:()=>rq,unwrapMessage:()=>Ra});function RZ(e){return e}s(RZ,"assertEqual");function $Z(e){return e}s($Z,"assertNotEqual");function Fu(){return e=>e}s(Fu,"toZod");function PZ(e){}s(PZ,"assertIs");function NZ(e){throw new Error("Unexpected value in exhaustive check")}s(NZ,"assertNever");function DZ(e){}s(DZ,"assert");function $a(e){let t=Object.values(e).filter(r=>typeof r=="number");return Object.entries(e).filter(([r,o])=>t.indexOf(+r)===-1).map(([r,o])=>o)}s($a,"getEnumValues");function Md(e,t="|"){return e.map(n=>jd(n)).join(t)}s(Md,"joinValues");function Pa(e,t){return typeof t=="bigint"?t.toString():t}s(Pa,"jsonStringifyReplacer");var Fy=class{static{s(this,"Cached")}constructor(t){this._getter=t,this._value=void 0}get value(){let t=this._getter;return t!==void 0&&(this._value=t(),this._getter=void 0),this._value}};function Na(e){return new Fy(e)}s(Na,"cached");function Ud(e){return e==null}s(Ud,"nullish");function vo(e){let t=e.startsWith("^")?1:0,n=e.endsWith("$")?e.length-1:e.length;return e.slice(t,n)}s(vo,"cleanRegex");function zu(e,t){let n=e/t,r=Math.round(n),o=4*Number.EPSILON*Math.max(Math.abs(n),1);return Math.abs(n-r)<o?0:n-r}s(zu,"floatSafeRemainder");var nO=Symbol("evaluating");function My(e,t,n){let r;Object.defineProperty(e,t,{get(){if(r!==nO)return r===void 0&&(r=nO,r=n()),r},set(o){Object.defineProperty(e,t,{value:o})},configurable:!0})}s(My,"defineLazy");function LZ(e){return Object.create(Object.getPrototypeOf(e),Object.getOwnPropertyDescriptors(e))}s(LZ,"objectClone");function Pt(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}s(Pt,"assignProp");function Da(e){let t=Object.getOwnPropertyDescriptor(e,"shape");return t?.get?t.get.raw:t?.value}s(Da,"rawShape");function bo(e){return Da(e._zod.def)??e._zod.def.shape}s(bo,"sourceShape");function rO(e,t,n){Object.defineProperty(e,t,{get(){let r=n();return Pt(this,t,r),r},enumerable:!0,configurable:!0})}s(rO,"deferProp");function oO(e,t,n){t in e?Pt(e,t,n):e[t]=n}s(oO,"putProp");function oi(e,t,n,r){let o=bo(t);for(let i of n){let a=Object.getOwnPropertyDescriptor(o,i);a.enumerable&&(a.get?rO(e,i,()=>{let c=t._zod.def.shape[i];return r?r(c,i):c}):oO(e,i,r?r(a.value,i):a.value))}}s(oi,"mirrorShape");function FZ(e,t){for(let n of Reflect.ownKeys(t)){let r=Object.getOwnPropertyDescriptor(t,n);r.enumerable&&(r.get?rO(e,n,()=>t[n]):oO(e,n,r.value))}}s(FZ,"mirrorProps");function hr(...e){let t={};for(let n of e){let r=Object.getOwnPropertyDescriptors(n);Object.assign(t,r)}return Object.defineProperties({},t)}s(hr,"mergeDefs");function zZ(e){return hr(e._zod.def)}s(zZ,"cloneDef");function MZ(e,t){return t?t.reduce((n,r)=>n?.[r],e):e}s(MZ,"getElementAtPath");function UZ(e){let t=Object.keys(e),n=t.map(r=>e[r]);return Promise.all(n).then(r=>{let o={};for(let i=0;i<t.length;i++)o[t[i]]=r[i];return o})}s(UZ,"promiseAllObject");function GZ(e=10){let t="abcdefghijklmnopqrstuvwxyz",n="";for(let r=0;r<e;r++)n+=t[Math.floor(Math.random()*t.length)];return n}s(GZ,"randomString");function Xt(e){return JSON.stringify(e)}s(Xt,"esc");function Uy(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}s(Uy,"slugify");var Gd="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function si(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}s(si,"isObject");var Gy=Na(()=>{if(Et.jitless||typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{let e=Function;return new e(""),!0}catch{return!1}});function Kn(e){if(si(e)===!1)return!1;let t=e.constructor;if(t===void 0||typeof t!="function")return!0;let n=t.prototype;return!(si(n)===!1||Object.prototype.hasOwnProperty.call(n,"isPrototypeOf")===!1)}s(Kn,"isPlainObject");function Mu(e){return Kn(e)?{...e}:Array.isArray(e)?[...e]:e instanceof Map?new Map(e):e instanceof Set?new Set(e):e}s(Mu,"shallowClone");function jZ(e){let t=0;for(let n in e)Object.prototype.hasOwnProperty.call(e,n)&&t++;return t}s(jZ,"numKeys");var ZZ=s(e=>{let t=typeof e;switch(t){case"undefined":return"undefined";case"string":return"string";case"number":return Number.isNaN(e)?"nan":"number";case"boolean":return"boolean";case"function":return"function";case"bigint":return"bigint";case"symbol":return"symbol";case"object":return Array.isArray(e)?"array":e===null?"null":e.then&&typeof e.then=="function"&&e.catch&&typeof e.catch=="function"?"promise":typeof Map<"u"&&e instanceof Map?"map":typeof Set<"u"&&e instanceof Set?"set":typeof Date<"u"&&e instanceof Date?"date":typeof File<"u"&&e instanceof File?"file":"object";default:throw new Error(`Unknown data type: ${t}`)}},"getParsedType"),Uu=new Set(["string","number","symbol"]),jy=new Set(["string","number","bigint","boolean","symbol","undefined"]);function Jn(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}s(Jn,"escapeRegex");function Pe(e,t,n){let r=new e._zod.constr(t??e._zod.def);return(!t||n?.parent)&&(r._zod.parent=e),r}s(Pe,"clone");function N(e){let t=e;if(!t)return{};if(typeof t=="string")return{error:s(()=>t,"error")};if(t?.message!==void 0){if(t?.error!==void 0)throw new Error("Cannot specify both `message` and `error` params");t.error=t.message}return delete t.message,typeof t.error=="string"?{...t,error:s(()=>t.error,"error")}:t}s(N,"normalizeParams");function qZ(e){let t;return new Proxy({},{get(n,r,o){return t??(t=e()),Reflect.get(t,r,o)},set(n,r,o,i){return t??(t=e()),Reflect.set(t,r,o,i)},has(n,r){return t??(t=e()),Reflect.has(t,r)},deleteProperty(n,r){return t??(t=e()),Reflect.deleteProperty(t,r)},ownKeys(n){return t??(t=e()),Reflect.ownKeys(t)},getOwnPropertyDescriptor(n,r){return t??(t=e()),Reflect.getOwnPropertyDescriptor(t,r)},defineProperty(n,r,o){return t??(t=e()),Reflect.defineProperty(t,r,o)}})}s(qZ,"createTransparentProxy");function jd(e){return typeof e=="bigint"?e.toString()+"n":typeof e=="string"?`"${e}"`:`${e}`}s(jd,"stringifyPrimitive");function Zy(e){return Object.keys(e).filter(t=>e[t]._zod.optin!==void 0&&e[t]._zod.optout==="optional")}s(Zy,"optionalKeys");var Gu={safeint:[Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]},ju={int64:[BigInt("-9223372036854775808"),BigInt("9223372036854775807")],uint64:[BigInt(0),BigInt("18446744073709551615")]};function BZ(e,t){let n=e._zod.def,r=n.checks;if(r&&r.length>0)throw new Error(".pick() cannot be used on object schemas containing refinements");let i={};return oi(i,e,Zd(e,t)),Pe(e,hr(n,{shape:i,checks:[]}))}s(BZ,"pick");function Zd(e,t){let n=bo(e),r=[];for(let o of Reflect.ownKeys(t)){if(!Object.getOwnPropertyDescriptor(n,o)?.enumerable)throw new Error(`Unrecognized key: "${String(o)}"`);t[o]&&r.push(o)}return r}s(Zd,"maskedKeys");function VZ(e,t){let n=e._zod.def,r=n.checks;if(r&&r.length>0)throw new Error(".omit() cannot be used on object schemas containing refinements");let i=new Set(Zd(e,t)),a={};return oi(a,e,Reflect.ownKeys(bo(e)).filter(c=>!i.has(c))),Pe(e,hr(n,{shape:a,checks:[]}))}s(VZ,"omit");function HZ(e,t){if(!Kn(t))throw new Error("Invalid input to extend: expected a plain object");let n=e._zod.def.checks;if(n&&n.length>0){let o=bo(e);for(let i of Reflect.ownKeys(t))if(Object.getOwnPropertyDescriptor(o,i)!==void 0)throw new Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}return Pe(e,hr(e._zod.def,{shape:sO(e,t)}))}s(HZ,"extend");function sO(e,t){let n={};return oi(n,e,Reflect.ownKeys(bo(e))),FZ(n,t),n}s(sO,"extended");function KZ(e,t){if(!Kn(t))throw new Error("Invalid input to safeExtend: expected a plain object");return Pe(e,hr(e._zod.def,{shape:sO(e,t)}))}s(KZ,"safeExtend");function JZ(e,t){if(!t?._zod?.def)throw new Error("Invalid input to merge: expected an object schema. To merge a plain shape, use `.extend()`.");if(e._zod.def.checks?.length)throw new Error(".merge() cannot be used on object schemas containing refinements. Use .safeExtend() instead.");let n={};oi(n,e,Reflect.ownKeys(bo(e))),oi(n,t,Reflect.ownKeys(bo(t)));let r=hr(e._zod.def,{shape:n,get catchall(){return t._zod.def.catchall},checks:t._zod.def.checks??[]});return Pe(e,r)}s(JZ,"merge");function WZ(e,t,n,r="partial"){let i=t._zod.def.checks;if(i&&i.length>0)throw new Error(`.${r}() cannot be used on object schemas containing refinements`);let c=n?new Set(Zd(t,n)):void 0,l={};return oi(l,t,Reflect.ownKeys(bo(t)),e&&((u,f)=>c&&!c.has(f)?u:new e({type:"optional",innerType:u}))),Pe(t,hr(t._zod.def,{shape:l,checks:[]}))}s(WZ,"partial");function YZ(e,t,n){let r=n?new Set(Zd(t,n)):void 0,o={};return oi(o,t,Reflect.ownKeys(bo(t)),(i,a)=>r&&!r.has(a)?i:new e({type:"nonoptional",innerType:i})),Pe(t,hr(t._zod.def,{shape:o}))}s(YZ,"required");function Qt(e,t=0){if(e.aborted===!0)return!0;for(let n=t;n<e.issues.length;n++)if(e.issues[n]?.continue!==!0)return!0;return!1}s(Qt,"aborted");function qy(e,t=0){if(e.aborted===!0)return!0;for(let n=t;n<e.issues.length;n++)if(e.issues[n]?.continue===!1)return!0;return!1}s(qy,"explicitlyAborted");function mn(e,t){return t.map(n=>{var r;return(r=n).path??(r.path=[]),n.path.unshift(e),n})}s(mn,"prefixIssues");function Ra(e){return typeof e=="string"?e:e?.message}s(Ra,"unwrapMessage");function La(e){let t=[];for(let n of e??[]){let r=n._zod.def;if(!/_(length|size)$|_equals$/.test(r.check))break;let o=r.maximum??r.length??r.size;o>=0&&t.push([o,n])}return t}s(La,"sizeCaps");function Zu(e,t,n){var r;for(let o=t;o<e.length;o++)(r=e[o]).schema??(r.schema=n)}s(Zu,"attachSchema");function hn(e,t,n){var r;let o=e.inst?._zod?.traits;o?.has("$ZodType")&&(o.has("$ZodCheck")?(r=e).schema??(r.schema=e.inst):e.schema=e.inst);let i=e.schema!==e.inst?e.schema?._zod.def?.error:void 0,a=e.message?e.message:Ra(e.inst?._zod.def?.error?.(e))??Ra(i?.(e))??Ra(t?.error?.(e))??Ra(n.customError?.(e))??Ra(n.localeError?.(e))??"Invalid input",c={};for(let l of Object.keys(e))l==="inst"||l==="schema"||l==="continue"||l==="input"||l==="__proto__"||(c[l]=e[l]);return c.path??(c.path=[]),c.message=a,t?.reportInput&&(c.input=e.input),c}s(hn,"finalizeIssue");function qu(e){return e instanceof Set?"set":e instanceof Map?"map":e instanceof File?"file":"unknown"}s(qu,"getSizableOrigin");var XZ=/[\uD800-\uDBFF]/;function ii(e){let t=e.length;if(!XZ.test(e))return t;let n=t;for(let r=0;r<t-1;r++)(e.charCodeAt(r)&64512)===55296&&(e.charCodeAt(r+1)&64512)===56320&&(n--,r++);return n}s(ii,"codePointLength");function Bu(e){return Array.isArray(e)?"array":typeof e=="string"?"string":"unknown"}s(Bu,"getLengthableOrigin");function By(e){let t=typeof e;switch(t){case"number":return Number.isNaN(e)?"nan":"number";case"object":{if(e===null)return"null";if(Array.isArray(e))return"array";let n=e;if(n&&Object.getPrototypeOf(n)!==Object.prototype&&"constructor"in n&&n.constructor)return n.constructor.name}}return t}s(By,"parsedType");function Fa(...e){let[t,n,r]=e;return typeof t=="string"?{message:t,code:"custom",input:n,inst:r}:{...t}}s(Fa,"issue");function QZ(e){return Object.entries(e).filter(([t,n])=>Number.isNaN(Number.parseInt(t,10))).map(t=>t[1])}s(QZ,"cleanEnum");function iO(e){let t=atob(e),n=new Uint8Array(t.length);for(let r=0;r<t.length;r++)n[r]=t.charCodeAt(r);return n}s(iO,"base64ToUint8Array");function aO(e){let t="";for(let n=0;n<e.length;n++)t+=String.fromCharCode(e[n]);return btoa(t)}s(aO,"uint8ArrayToBase64");function eq(e){let t=e.replace(/-/g,"+").replace(/_/g,"/"),n="=".repeat((4-t.length%4)%4);return iO(t+n)}s(eq,"base64urlToUint8Array");function tq(e){return aO(e).replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")}s(tq,"uint8ArrayToBase64url");function nq(e){let t=e.replace(/^0x/,"");if(t.length%2!==0)throw new Error("Invalid hex string length");let n=new Uint8Array(t.length/2);for(let r=0;r<t.length;r+=2)n[r/2]=Number.parseInt(t.slice(r,r+2),16);return n}s(nq,"hexToUint8Array");function rq(e){return Array.from(e).map(t=>t.toString(16).padStart(2,"0")).join("")}s(rq,"uint8ArrayToHex");var zy=class{static{s(this,"Class")}constructor(...t){}};function Vy(e,t){for(let n in t){let r=Object.getOwnPropertyDescriptor(t,n);r.get?Object.defineProperty(e,n,{...r,enumerable:!1}):sq(e,n,r.value)}}s(Vy,"members");function fs(e,t,n,r=!0){return Object.defineProperty(e,t,{configurable:!0,writable:!0,enumerable:r,value:n}),n}s(fs,"own");function Vu(e,t,n){return fs(e,t,n,!1)}s(Vu,"hide");function oq(e,t){for(let n in e){let r=e[n];Object.defineProperty(t,n,{configurable:!0,enumerable:!0,get(){return fs(this,n,r(this))},set(o){fs(this,n,o)}})}return t}s(oq,"derived");function sq(e,t,n){Object.defineProperty(e,t,{configurable:!0,get(){return this==null?n:fs(this,t,n.bind(this))},set(r){fs(this,t,r)}})}s(sq,"defineBound");function iq(e,t){let n=Object.getPrototypeOf(e);return t in n?void 0:n}s(iq,"claim");var Ly,ls=!1,aq={configurable:!0,get(){ls=!0}};function he(e,t,n){let r=Object.getPrototypeOf(e._zod);if(t in r&&Ly!==e._zod){Ly=void 0;return}Ly=e._zod,Object.defineProperty(r,t,{configurable:!0,get(){Object.defineProperty(this,t,aq);let o=ls;ls=!1;try{let i=n(this);return ls?delete this[t]:Object.defineProperty(this,t,{configurable:!0,writable:!0,value:i}),ls=ls||o,i}catch(i){throw delete this[t],ls=ls||o,i}},set(o){Object.defineProperty(this,t,{configurable:!0,writable:!0,value:o})}})}s(he,"defineLazyInternal");function cq(e,t,n,r){let o=iq(e,t);o&&Object.defineProperty(o,t,{configurable:!0,get(){let i={configurable:!0,writable:!0,enumerable:r,value:void 0};return Object.defineProperty(this,t,i),i.value=n(this),Object.defineProperty(this,t,i),i.value},set(i){Object.defineProperty(this,t,{configurable:!0,writable:!0,enumerable:r,value:i})}})}s(cq,"installLazyProp");var qd="~constantCatch";function Hy(e){let t=s(()=>e,"fn");return t[qd]=!0,t}s(Hy,"constantCatch");var cO,Jy=Object.freeze({status:"aborted"}),Ky={value:void 0,enumerable:!1},uO="captureStackTrace"in Error?Error:null;function uq(e){let t=uO;if(t){let n=t.stackTraceLimit;if(typeof n=="number"){try{t.stackTraceLimit=0}catch{return uO=null,new e}try{return new e}finally{t.stackTraceLimit=n}}}return new e}s(uq,"newError");function _(e,t,n,r){let o={};function i(p){this.def=p,this.constr=d,this.traits=new Set}s(i,"Internals"),i.prototype=o;let a=n,c=a&&new WeakSet;function l(p,m){if(p._zod){if(p._zod.traits.has(e))return}else{Ky.value=new i(m);try{Object.defineProperty(p,"_zod",Ky)}finally{Ky.value=void 0}}if(p._zod.traits.add(e),t(p,m),c){let x=Object.getPrototypeOf(p),S=p._zod.constr.prototype,T=x;for(;T&&T!==S;)T=Object.getPrototypeOf(T);let b=T??x;c.has(b)||(c.add(b),Vy(b,a))}let h=d.prototype;for(let x in h)Object.prototype.hasOwnProperty.call(h,x)&&(x in p||(p[x]=h[x].bind(p)))}s(l,"init");let u=r?.Parent??Object;class f extends u{static{s(this,"Definition")}}Object.defineProperty(f,"name",{value:e});function d(p){let m=r?.Parent?uq(f):this;l(m,p);let h=m._zod.deferred;if(h){for(let S of h)S();m._zod.deferred=void 0}let x=globalThis.__zod_globalConfig?.postProcessor;return x&&x(m),m}return s(d,"_"),Object.defineProperty(d,"init",{value:l}),Object.defineProperty(d,Symbol.hasInstance,{value:s(p=>r?.Parent&&p instanceof r.Parent?!0:p?._zod?.traits?.has(e),"value")}),Object.defineProperty(d,"name",{value:e}),d}s(_,"$constructor");var Wy=Symbol("zod_brand"),gn=class extends Error{static{s(this,"$ZodAsyncError")}constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}},ds=class extends Error{static{s(this,"$ZodEncodeError")}constructor(t){super(`Encountered unidirectional transform during encode: ${t}`),this.name="ZodEncodeError"}};(cO=globalThis).__zod_globalConfig??(cO.__zod_globalConfig={});var Et=globalThis.__zod_globalConfig;function rt(e){return e&&Object.assign(Et,e),Et}s(rt,"config");function lq(){let e=this._zod;return e.message??(e.message=JSON.stringify(e.def,Pa,2)),e.message}s(lq,"_getMessage");function fq(e){this._zod.message=e}s(fq,"_setMessage");var dq={get:lq,set:fq,enumerable:!0,configurable:!0},Xy={value:void 0,enumerable:!1},lO=new WeakSet([Object.prototype,Error.prototype]),fO=s((e,t)=>{e.name="$ZodError",Xy.value=t,Object.defineProperty(e,"issues",Xy),Xy.value=void 0,Object.defineProperty(e,"message",dq);let n=Object.getPrototypeOf(e);lO.has(n)||(lO.add(n),Object.defineProperty(n,"toString",{configurable:!0,enumerable:!1,get(){let r=s(()=>this.message,"value");return Object.defineProperty(this,"toString",{value:r,configurable:!0,writable:!0}),r},set(r){Object.defineProperty(this,"toString",{value:r,configurable:!0,writable:!0})}}))},"initializer"),Qy=_("$ZodError",fO),xn=_("$ZodError",fO,void 0,{Parent:Error});function pq(e,t,n){return Object.prototype.hasOwnProperty.call(e,t)||(t==="__proto__"?Object.defineProperty(e,t,{value:n(),writable:!0,enumerable:!0,configurable:!0}):e[t]=n()),e[t]}s(pq,"node");function Hu(e,t=n=>n.message){let n={},r=[];for(let o of e.issues)o.path.length>0?pq(n,o.path[0],()=>[]).push(t(o)):r.push(t(o));return{formErrors:r,fieldErrors:n}}s(Hu,"flattenError");function Ku(e,t=n=>n.message){let n={_errors:[]},r=s((o,i=[])=>{for(let a of o.issues)if(a.code==="invalid_union"&&a.errors.length)a.errors.map(c=>r({issues:c},[...i,...a.path]));else if(a.code==="invalid_key")r({issues:a.issues},[...i,...a.path]);else if(a.code==="invalid_element")r({issues:a.issues},[...i,...a.path]);else{let c=[...i,...a.path];if(c.length===0)n._errors.push(t(a));else{let l=n,u=0;for(;u<c.length;){let f=c[u],d=u===c.length-1;if(f==="_errors"){d&&l._errors.push(t(a)),u++;continue}Object.prototype.hasOwnProperty.call(l,f)||Object.defineProperty(l,f,{value:{_errors:[]},enumerable:!0,writable:!0,configurable:!0});let p=l[f];d&&p._errors.push(t(a)),l=p,u++}}}},"processError");return r(e),n}s(Ku,"formatError");function eS(e,t=n=>n.message){let n={errors:[]},r=s((o,i=[])=>{var a;for(let c of o.issues)if(c.code==="invalid_union"&&c.errors.length)c.errors.map(l=>r({issues:l},[...i,...c.path]));else if(c.code==="invalid_key")r({issues:c.issues},[...i,...c.path]);else if(c.code==="invalid_element")r({issues:c.issues},[...i,...c.path]);else{let l=[...i,...c.path];if(l.length===0){n.errors.push(t(c));continue}let u=n,f=0;for(;f<l.length;){let d=l[f],p=f===l.length-1;typeof d=="string"?(u.properties??(u.properties={}),Object.prototype.hasOwnProperty.call(u.properties,d)||Object.defineProperty(u.properties,d,{value:{errors:[]},enumerable:!0,writable:!0,configurable:!0}),u=u.properties[d]):(u.items??(u.items=[]),(a=u.items)[d]??(a[d]={errors:[]}),u=u.items[d]),p&&u.errors.push(t(c)),f++}}},"processError");return r(e),n}s(eS,"treeifyError");function dO(e){let t=[],n=e.map(r=>typeof r=="object"?r.key:r);for(let r of n)typeof r=="number"?t.push(`[${r}]`):typeof r=="symbol"?t.push(`[${JSON.stringify(String(r))}]`):/[^\w$]/.test(r)?t.push(`[${JSON.stringify(r)}]`):(t.length&&t.push("."),t.push(r));return t.join("")}s(dO,"toDotPath");function tS(e){let t=[],n=[...e.issues].sort((r,o)=>(r.path??[]).length-(o.path??[]).length);for(let r of n)t.push(`\u2716 ${r.message}`),r.path?.length&&t.push(` \u2192 at ${dO(r.path)}`);return t.join(`
|
|
8
|
+
`)}s(tS,"prettifyError");function Bd(e,t){return{callee:t?.callee??e,Err:t?.Err}}s(Bd,"finalizeParams");var za=s(e=>{let t=s((n,r,o,i)=>{let a=o?{...o,async:!1}:{async:!1},c=n._zod.run({value:r,issues:[]},a);if(c instanceof Promise)throw new gn;if(c.issues.length){let l=new(i?.Err??e)(c.issues.map(u=>hn(u,a,rt())));throw Gd(l,i?.callee??t),l}return c.value},"fn");return t},"_parse"),Vd=za(xn),Ma=s(e=>{let t=s(async(n,r,o,i)=>{let a=o?{...o,async:!0}:{async:!0},c=n._zod.run({value:r,issues:[]},a);if(c instanceof Promise&&(c=await c),c.issues.length){let l=new(i?.Err??e)(c.issues.map(u=>hn(u,a,rt())));throw Gd(l,i?.callee??t),l}return c.value},"fn");return t},"_parseAsync"),Hd=Ma(xn),Ua=s(e=>(t,n,r)=>{let o=r?{...r,async:!1}:{async:!1},i=t._zod.run({value:n,issues:[]},o);if(i instanceof Promise)throw new gn;return i.issues.length?pO(e,i.issues,o):{success:!0,data:i.value}},"_safeParse"),hq=Ua(xn);function pO(e,t,n){let r;return{success:!1,get error(){return r||(r=new e(t.map(o=>hn(o,n,rt()))),t=void 0,n=void 0),r},set error(o){r=o,t=void 0,n=void 0}}}s(pO,"failure");var Ga=s(e=>async(t,n,r)=>{let o=r?{...r,async:!0}:{async:!0},i=t._zod.run({value:n,issues:[]},o);return i instanceof Promise&&(i=await i),i.issues.length?pO(e,i.issues,o):{success:!0,data:i.value}},"_safeParseAsync"),gq=Ga(xn),xq=Symbol.for("zod.compile.invalid"),yq=Symbol.for("zod.compile.fallback"),Ju=s(((e,t,n)=>{let r=e._zod.bag.validator;if(r!==void 0){if(r(t)!==xq)return!0;if(r.definite===!0&&n===void 0)return!1}return Sq(e,t,n)}),"validate");function Sq(e,t,n){let r=n?{...n,async:!1,abortEarly:!0}:{async:!1,abortEarly:!0},o=e._zod.bag.fallbackRun,i;if(o?(r[yq]=!0,i=o({value:t,issues:[]},r)):i=e._zod.run({value:t,issues:[]},r),i instanceof Promise)throw new gn;return i.issues.length===0}s(Sq,"validateFallback");var Wu=s(async(e,t,n)=>{let r=n?{...n,async:!0,abortEarly:!0}:{async:!0,abortEarly:!0},o=e._zod.run({value:t,issues:[]},r);return o instanceof Promise&&(o=await o),o.issues.length===0},"validateAsync"),Kd=s(e=>{let t=za(e),n=s((r,o,i,a)=>{let c=i?{...i,direction:"backward"}:{direction:"backward"};return t(r,o,c,Bd(n,a))},"fn");return n},"_encode"),bq=Kd(xn),Jd=s(e=>{let t=za(e),n=s((r,o,i,a)=>t(r,o,i,Bd(n,a)),"fn");return n},"_decode"),vq=Jd(xn),Wd=s(e=>{let t=Ma(e),n=s(async(r,o,i,a)=>{let c=i?{...i,direction:"backward"}:{direction:"backward"};return await t(r,o,c,Bd(n,a))},"fn");return n},"_encodeAsync"),_q=Wd(xn),Yd=s(e=>{let t=Ma(e),n=s(async(r,o,i,a)=>await t(r,o,i,Bd(n,a)),"fn");return n},"_decodeAsync"),wq=Yd(xn),Xd=s(e=>(t,n,r)=>{let o=r?{...r,direction:"backward"}:{direction:"backward"};return Ua(e)(t,n,o)},"_safeEncode"),Eq=Xd(xn),Qd=s(e=>(t,n,r)=>Ua(e)(t,n,r),"_safeDecode"),Iq=Qd(xn),ep=s(e=>async(t,n,r)=>{let o=r?{...r,direction:"backward"}:{direction:"backward"};return Ga(e)(t,n,o)},"_safeEncodeAsync"),Tq=ep(xn),tp=s(e=>async(t,n,r)=>Ga(e)(t,n,r),"_safeDecodeAsync"),kq=tp(xn);var Wn={};$t(Wn,{anyString:()=>AS,base64:()=>SS,base64url:()=>bS,bigint:()=>OS,boolean:()=>RS,browserEmail:()=>Dq,cidrv4:()=>xS,cidrv6:()=>yS,creditCard:()=>np,cuid:()=>rS,cuid2:()=>oS,currencyCode:()=>ES,date:()=>IS,datetime:()=>kS,domain:()=>_S,duration:()=>lS,e164:()=>wS,email:()=>dS,emoji:()=>pS,extendedDuration:()=>Aq,guid:()=>fS,hex:()=>LS,hostname:()=>vS,html5Email:()=>$q,httpProtocol:()=>Yu,iban:()=>rp,idnEmail:()=>Nq,integer:()=>Xu,ipv4:()=>mS,ipv6:()=>hS,ksuid:()=>aS,lowercase:()=>NS,mac:()=>gS,md5_base64:()=>Mq,md5_base64url:()=>Uq,md5_hex:()=>zq,nanoid:()=>cS,nanoidOfLength:()=>uS,null:()=>$S,number:()=>_o,rfc5322Email:()=>Pq,sha1_base64:()=>jq,sha1_base64url:()=>Zq,sha1_hex:()=>Gq,sha256_base64:()=>Bq,sha256_base64url:()=>Vq,sha256_hex:()=>qq,sha384_base64:()=>Kq,sha384_base64url:()=>Jq,sha384_hex:()=>Hq,sha512_base64:()=>Yq,sha512_base64url:()=>Xq,sha512_hex:()=>Wq,string:()=>CS,time:()=>TS,ulid:()=>sS,undefined:()=>PS,unicodeEmail:()=>mO,uppercase:()=>DS,uuid:()=>ai,uuid4:()=>Cq,uuid6:()=>Oq,uuid7:()=>Rq,xid:()=>iS});var rS=/^[cC][0-9a-z]{6,}$/,oS=/^[0-9a-z]+$/,sS=/^[0-7][0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{25}$/,iS=/^[0-9a-vA-V]{20}$/,aS=/^[A-Za-z0-9]{27}$/,cS=/^[a-zA-Z0-9_-]{21}$/;function uS(e){return new RegExp(`^[a-zA-Z0-9_-]{${e}}$`)}s(uS,"nanoidOfLength");var lS=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,Aq=/^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/,fS=/^([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})$/,ai=s(e=>e?new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${e}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`):/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/,"uuid"),Cq=ai(4),Oq=ai(6),Rq=ai(7),dS=/^(?:[A-Za-z0-9_'+\-]+\.)*[A-Za-z0-9_'+\-]*[A-Za-z0-9_+-]@(?:[A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,$q=/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/,Pq=/^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/,mO=/^[^\s@"]{1,64}@[^\s@]{1,255}$/u,Nq=mO,Dq=/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/,Lq="^(?=[\\s\\S]*[\\p{Extended_Pictographic}\\p{Regional_Indicator}\\u20E3])[\\p{Extended_Pictographic}\\p{Emoji_Component}]+$";function pS(){return new RegExp(Lq,"u")}s(pS,"emoji");var mS=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,hS=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))$/,gS=s(e=>{let t=Jn(e??":");return new RegExp(`^(?:[0-9A-F]{2}${t}){5}[0-9A-F]{2}$|^(?:[0-9a-f]{2}${t}){5}[0-9a-f]{2}$`)},"mac"),xS=/^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/([0-9]|[1-2][0-9]|3[0-2])$/,yS=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,SS=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,bS=/^(?:[A-Za-z0-9_-]{4})*(?:[A-Za-z0-9_-]{2,3})?$/,vS=/^(?=.{1,253}\.?$)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[-0-9a-zA-Z]{0,61}[0-9a-zA-Z])?)*\.?$/,_S=/^(?=.{1,253}$)([a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?\.)+[a-zA-Z]{2,63}$/,Yu=/^https?$/,wS=/^\+[1-9]\d{6,14}$/,np=/^\d(?:[ -]?\d){11,18}$/,ES=/^(?:AED|AFN|ALL|AMD|AOA|ARS|AUD|AWG|AZN|BAM|BBD|BDT|BHD|BIF|BMD|BND|BOB|BOV|BRL|BSD|BTN|BWP|BYN|BZD|CAD|CDF|CHE|CHF|CHW|CLF|CLP|CNY|COP|COU|CRC|CUP|CVE|CZK|DJF|DKK|DOP|DZD|EGP|ERN|ETB|EUR|FJD|FKP|GBP|GEL|GHS|GIP|GMD|GNF|GTQ|GYD|HKD|HNL|HTG|HUF|IDR|ILS|INR|IQD|IRR|ISK|JMD|JOD|JPY|KES|KGS|KHR|KMF|KPW|KRW|KWD|KYD|KZT|LAK|LBP|LKR|LRD|LSL|LYD|MAD|MDL|MGA|MKD|MMK|MNT|MOP|MRU|MUR|MVR|MWK|MXN|MXV|MYR|MZN|NAD|NGN|NIO|NOK|NPR|NZD|OMR|PAB|PEN|PGK|PHP|PKR|PLN|PYG|QAR|RON|RSD|RUB|RWF|SAR|SBD|SCR|SDG|SEK|SGD|SHP|SLE|SOS|SRD|SSP|STN|SVC|SYP|SZL|THB|TJS|TMT|TND|TOP|TRY|TTD|TWD|TZS|UAH|UGX|USD|USN|UYI|UYU|UYW|UZS|VED|VES|VND|VUV|WST|XAD|XAF|XAG|XAU|XBA|XBB|XBC|XBD|XCD|XCG|XDR|XOF|XPD|XPF|XPT|XSU|XTS|XUA|XXX|YER|ZAR|ZMW|ZWG)$/,rp=/^[A-Z]{2}(?!00|01|99)\d{2}[A-Z0-9]{11,30}$/,hO="(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))";function Fq(e){return new RegExp(`^${e}$`)}s(Fq,"anchor");var IS=Fq(hO);function nS(e){let t="(?:[01]\\d|2[0-3]):[0-5]\\d";return typeof e.precision=="number"?e.precision===-1?`${t}`:e.precision===0?`${t}:[0-5]\\d`:`${t}:[0-5]\\d\\.\\d{${e.precision}}`:e.seconds?`${t}:[0-5]\\d(?:\\.\\d+)?`:`${t}(?::[0-5]\\d(?:\\.\\d+)?)?`}s(nS,"timeSource");function TS(e){return new RegExp(`^${nS(e)}$`)}s(TS,"time");function kS(e){let t=["Z"];e.offset&&t.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");let n=`${nS({precision:e.precision,seconds:!0})}(?:${t.join("|")})`,r=e.local?`${n}|${nS({precision:e.precision})}`:n;return new RegExp(`^${hO}T(?:${r})$`)}s(kS,"datetime");var AS=/^[\s\S]{0,}$/,CS=s(e=>{let t=e?`[\\s\\S]{${e?.minimum??0},${e?.maximum??""}}`:"[\\s\\S]*";return new RegExp(`^${t}$`)},"string"),OS=/^-?\d+n?$/,Xu=/^-?\d+$/,_o=/^-?\d+(?:\.\d+)?$/,RS=/^(?:true|false)$/i,$S=/^null$/i;var PS=/^undefined$/i;var NS=/^[^A-Z]*$/,DS=/^[^a-z]*$/,LS=/^[0-9a-fA-F]*$/;function Qu(e,t){return new RegExp(`^[A-Za-z0-9+/]{${e}}${t}$`)}s(Qu,"fixedBase64");function el(e){return new RegExp(`^[A-Za-z0-9_-]{${e}}$`)}s(el,"fixedBase64url");var zq=/^[0-9a-fA-F]{32}$/,Mq=Qu(22,"=="),Uq=el(22),Gq=/^[0-9a-fA-F]{40}$/,jq=Qu(27,"="),Zq=el(27),qq=/^[0-9a-fA-F]{64}$/,Bq=Qu(43,"="),Vq=el(43),Hq=/^[0-9a-fA-F]{96}$/,Kq=Qu(64,""),Jq=el(64),Wq=/^[0-9a-fA-F]{128}$/,Yq=Qu(86,"=="),Xq=el(86);var ze=_("$ZodCheck",(e,t)=>{var n;e._zod??(e._zod={}),e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])}),FS=s(e=>{let t=e.value;return!Ud(t)&&t.size!==void 0},"_whenHasSize"),zS=s(e=>{let t=e.value;return!Ud(t)&&t.length!==void 0},"_whenHasLength"),op={number:"number",bigint:"bigint",object:"date"},ip=_("$ZodCheckLessThan",(e,t)=>{ze.init(e,t);let n=op[typeof t.value];e._zod.check=r=>{(t.inclusive?r.value<=t.value:r.value<t.value)||r.issues.push({origin:op[typeof r.value]??n,code:"too_big",maximum:typeof t.value=="object"?t.value.getTime():t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),ap=_("$ZodCheckGreaterThan",(e,t)=>{ze.init(e,t);let n=op[typeof t.value];e._zod.check=r=>{(t.inclusive?r.value>=t.value:r.value>t.value)||r.issues.push({origin:op[typeof r.value]??n,code:"too_small",minimum:typeof t.value=="object"?t.value.getTime():t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),MS=_("$ZodCheckMultipleOf",(e,t)=>{ze.init(e,t),e._zod.check=n=>{if(typeof n.value!=typeof t.value)throw new Error("Cannot mix number and bigint in multiple_of check.");(typeof n.value=="bigint"?t.value!==BigInt(0)&&n.value%t.value===BigInt(0):zu(n.value,t.value)===0)||n.issues.push({origin:typeof n.value,code:"not_multiple_of",divisor:t.value,input:n.value,inst:e,continue:!t.abort})}}),US=_("$ZodCheckNumberFormat",(e,t)=>{ze.init(e,t),t.format=t.format||"float64";let n=t.format?.includes("int"),r=n?"int":"number",[o,i]=Gu[t.format];e._zod.check=a=>{let c=a.value;if(n){if(!Number.isInteger(c)){a.issues.push({expected:r,format:t.format,code:"invalid_type",continue:!1,input:c,inst:e});return}if(!Number.isSafeInteger(c)){c>0?a.issues.push({input:c,code:"too_big",maximum:Number.MAX_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:r,inclusive:!0,continue:!t.abort}):a.issues.push({input:c,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:r,inclusive:!0,continue:!t.abort});return}}c<o&&a.issues.push({origin:"number",input:c,code:"too_small",minimum:o,inclusive:!0,inst:e,continue:!t.abort}),c>i&&a.issues.push({origin:"number",input:c,code:"too_big",maximum:i,inclusive:!0,inst:e,continue:!t.abort})}}),GS=_("$ZodCheckBigIntFormat",(e,t)=>{ze.init(e,t);let[n,r]=ju[t.format];e._zod.check=o=>{let i=o.value;i<n&&o.issues.push({origin:"bigint",input:i,code:"too_small",minimum:n,inclusive:!0,inst:e,continue:!t.abort}),i>r&&o.issues.push({origin:"bigint",input:i,code:"too_big",maximum:r,inclusive:!0,inst:e,continue:!t.abort})}}),jS=_("$ZodCheckMaxSize",(e,t)=>{var n;ze.init(e,t),(n=e._zod.def).when??(n.when=FS),e._zod.check=r=>{let o=r.value;o.size<=t.maximum||r.issues.push({origin:qu(o),code:"too_big",maximum:t.maximum,inclusive:!0,input:o,inst:e,continue:!t.abort})}}),ZS=_("$ZodCheckMinSize",(e,t)=>{var n;ze.init(e,t),(n=e._zod.def).when??(n.when=FS),e._zod.check=r=>{let o=r.value;o.size>=t.minimum||r.issues.push({origin:qu(o),code:"too_small",minimum:t.minimum,inclusive:!0,input:o,inst:e,continue:!t.abort})}}),qS=_("$ZodCheckSizeEquals",(e,t)=>{var n;ze.init(e,t),(n=e._zod.def).when??(n.when=FS),e._zod.check=r=>{let o=r.value,i=o.size;if(i===t.size)return;let a=i>t.size;r.issues.push({origin:qu(o),...a?{code:"too_big",maximum:t.size}:{code:"too_small",minimum:t.size},inclusive:!0,exact:!0,input:r.value,inst:e,continue:!t.abort})}}),BS=_("$ZodCheckMaxLength",(e,t)=>{var n;ze.init(e,t),(n=e._zod.def).when??(n.when=zS),e._zod.check=r=>{let o=r.value,i=o.length;if((typeof o=="string"&&i>t.maximum?ii(o):i)<=t.maximum)return;let c=Bu(o);r.issues.push({origin:c,code:"too_big",maximum:t.maximum,inclusive:!0,input:o,inst:e,continue:!t.abort})}}),VS=_("$ZodCheckMinLength",(e,t)=>{var n;ze.init(e,t),(n=e._zod.def).when??(n.when=zS),e._zod.check=r=>{let o=r.value,i=o.length;if((typeof o=="string"&&i>=t.minimum&&i<t.minimum*2?ii(o):i)>=t.minimum)return;let c=Bu(o);r.issues.push({origin:c,code:"too_small",minimum:t.minimum,inclusive:!0,input:o,inst:e,continue:!t.abort})}}),HS=_("$ZodCheckLengthEquals",(e,t)=>{var n;ze.init(e,t),(n=e._zod.def).when??(n.when=zS),e._zod.check=r=>{let o=r.value,i=o.length,a=typeof o=="string"&&i>=t.length&&i<=t.length*2?ii(o):i;if(a===t.length)return;let c=Bu(o),l=a>t.length;r.issues.push({origin:c,...l?{code:"too_big",maximum:t.length}:{code:"too_small",minimum:t.length},inclusive:!0,exact:!0,input:r.value,inst:e,continue:!t.abort})}}),ja=_("$ZodCheckStringFormat",(e,t)=>{var n,r;ze.init(e,t),t.pattern?(n=e._zod).check??(n.check=o=>{t.pattern.lastIndex=0,!t.pattern.test(o.value)&&o.issues.push({origin:"string",code:"invalid_format",format:t.format,input:o.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(r=e._zod).check??(r.check=()=>{})}),KS=_("$ZodCheckRegex",(e,t)=>{ja.init(e,t),e._zod.check=n=>{t.pattern.lastIndex=0,!t.pattern.test(n.value)&&n.issues.push({origin:"string",code:"invalid_format",format:"regex",input:n.value,pattern:t.pattern.toString(),inst:e,continue:!t.abort})}}),JS=_("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=NS),ja.init(e,t)}),WS=_("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=DS),ja.init(e,t)}),YS=_("$ZodCheckIncludes",(e,t)=>{ze.init(e,t);let n=Jn(t.includes),r=new RegExp(typeof t.position=="number"?`^.{${t.position},}${n}`:n);t.pattern=r,e._zod.check=o=>{o.value.includes(t.includes,t.position)||o.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:t.includes,input:o.value,inst:e,continue:!t.abort})}}),XS=_("$ZodCheckStartsWith",(e,t)=>{ze.init(e,t);let n=new RegExp(`^${Jn(t.prefix)}.*`);t.pattern??(t.pattern=n),e._zod.check=r=>{r.value.startsWith(t.prefix)||r.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:t.prefix,input:r.value,inst:e,continue:!t.abort})}}),QS=_("$ZodCheckEndsWith",(e,t)=>{ze.init(e,t);let n=new RegExp(`.*${Jn(t.suffix)}$`);t.pattern??(t.pattern=n),e._zod.check=r=>{r.value.endsWith(t.suffix)||r.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:t.suffix,input:r.value,inst:e,continue:!t.abort})}});function sp(e,t,n){e.issues.length&&t.issues.push(...mn(n,e.issues))}s(sp,"handleCheckPropertyResult");var eb=_("$ZodCheckProperty",(e,t)=>{ze.init(e,t),e._zod.check=n=>{let r=t.schema._zod.run({value:n.value[t.property],issues:[]},{});if(r instanceof Promise)return r.then(o=>sp(o,n,t.property));sp(r,n,t.property)}}),tb=_("$ZodCheckProperties",(e,t)=>{ze.init(e,t),Vu(e,Symbol.iterator,function*(){yield e});let n;e._zod.check=r=>{if(r.value==null){r.issues.push({expected:"object",code:"invalid_type",input:r.value,inst:e});return}n??(n=Reflect.ownKeys(t.shape).map(a=>[a,t.shape[a]]));let o=r.value,i;for(let[a,c]of n){let l=c._zod.run({value:o[a],issues:[]},{});l instanceof Promise?(i??(i=[]),i.push(l.then(u=>sp(u,r,a)))):sp(l,r,a)}if(i)return Promise.all(i).then(()=>{})}}),nb=_("$ZodCheckMimeType",(e,t)=>{ze.init(e,t);let n=new Set(t.mime);e._zod.check=r=>{n.has(r.value.type)||r.issues.push({code:"invalid_value",values:t.mime,input:r.value.type,inst:e,continue:!t.abort})}}),rb=_("$ZodCheckOverwrite",(e,t)=>{ze.init(e,t),e._zod.check=n=>{n.value=t.tx(n.value)}});var ci=class{static{s(this,"Doc")}constructor(t=[],n={}){this.content=[],this.indent=0,this.args=t,this.closed=n}indented(t){this.indent+=1;try{t(this)}finally{this.indent-=1}}write(t){if(typeof t=="function"){t(this,{execution:"sync"}),t(this,{execution:"async"});return}let r=t.split(`
|
|
9
|
+
`).filter(a=>a),o=Math.min(...r.map(a=>a.length-a.trimStart().length)),i=r.map(a=>a.slice(o)).map(a=>" ".repeat(this.indent*2)+a);for(let a of i)this.content.push(a)}compile(){let t=Function,n=this?.content??[""];return new t(...Object.keys(this.closed),`return function (${this.args.join(", ")}) {
|
|
10
|
+
${n.join(`
|
|
11
|
+
`)}
|
|
12
|
+
};`)(...Object.values(this.closed))}};var ob={major:4,minor:6,patch:7};var ue=_("$ZodType",(e,t)=>{var n;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=ob;let r=e._zod.def.checks,o=e._zod.traits.has("$ZodCheck")?[e,...r??[]]:r?.length?[...r]:[];for(let i of o)for(let a of i._zod.onattach)a(e);if(o.length===0)(n=e._zod).deferred??(n.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{let i=s((c,l,u)=>{if(c.memo)return c;let f=Qt(c),d;for(let p of l){if(p._zod.def.when){if(qy(c)||!p._zod.def.when(c))continue}else if(f)continue;let m=c.issues.length,h=p._zod.check(c);if(h instanceof Promise&&u?.async===!1)throw new gn;if(d||h instanceof Promise)d=(d??Promise.resolve()).then(async()=>{await h,c.issues.length!==m&&(Zu(c.issues,m,e),f||(f=Qt(c,m)))});else{if(c.issues.length===m)continue;Zu(c.issues,m,e),f||(f=Qt(c,m))}}return d?d.then(()=>c):c},"runChecks"),a=s((c,l,u)=>{if(Qt(c))return c.aborted=!0,c;let f=i(l,o,u);if(f instanceof Promise){if(u.async===!1)throw new gn;return f.then(d=>e._zod.parse(d,u))}return e._zod.parse(f,u)},"handleCanaryResult");e._zod.run=(c,l)=>{if(l.skipChecks)return e._zod.parse(c,l);if(l.direction==="backward"){let f=e._zod.parse({value:c.value,issues:[]},{...l,skipChecks:!0});return f instanceof Promise?f.then(d=>a(d,c,l)):a(f,c,l)}let u=e._zod.parse(c,l);if(u instanceof Promise){if(l.async===!1)throw new gn;return u.then(f=>i(f,o,l))}return i(u,o,l)}}},{get"~standard"(){return Vu(this,"~standard",dp(this))},set"~standard"(e){fs(this,"~standard",e)}}),$O=s((e,t)=>e.issues.length?{issues:e.issues.map(n=>hn(n,t,rt()))}:{value:e.value},"toStandardResult");async function Qq(e,t){let n={async:!0};return $O(await e._zod.run({value:t,issues:[]},n),n)}s(Qq,"validateAsync");function dp(e){return{validate:s(t=>{let n={async:!1};try{let r=e._zod.run({value:t,issues:[]},n);if(!(r instanceof Promise))return $O(r,n)}catch{}return Qq(e,t)},"validate"),vendor:"zod",version:1}}s(dp,"standardProps");var ui=_("$ZodString",(e,t)=>{ue.init(e,t),e._zod.pattern=t.pattern??AS,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=String(n.value)}catch{}return typeof n.value=="string"||n.issues.push({expected:"string",code:"invalid_type",input:n.value,inst:e}),n}}),Ne=_("$ZodStringFormat",(e,t)=>{ja.init(e,t),ui.init(e,t)}),ib=_("$ZodGUID",(e,t)=>{t.pattern??(t.pattern=fS),Ne.init(e,t)}),ab=_("$ZodUUID",(e,t)=>{if(t.version){let r={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[t.version];if(r===void 0)throw new Error(`Invalid UUID version: "${t.version}"`);t.pattern??(t.pattern=ai(r))}else t.pattern??(t.pattern=ai());Ne.init(e,t)}),cb=_("$ZodEmail",(e,t)=>{t.pattern??(t.pattern=dS),Ne.init(e,t)}),ub=1,tl=2;function lb(e){try{return typeof URL<"u"&&typeof URL.canParse=="function"?URL.canParse(e):(new URL(e),!0)}catch{return!1}}s(lb,"canParseURL");function pp(e,t){return!("normalize"in t)&&!("hostname"in t)&&!("protocol"in t)?lb(e)||tl:PO(e,t)}s(pp,"validateURL");function PO(e,t){if(!t.normalize&&t.protocol?.source===Yu.source&&!/^https?:\/\//i.test(e))return ub;try{if(typeof URL<"u"){let n=URL;if(typeof n.parse=="function")return n.parse(e)??tl}return new URL(e)}catch{return tl}}s(PO,"parseURLObject");var eB=/[\t\n\r]/g;function nl(e){return e.replace(eB,"")}s(nl,"stripTabAndNewline");function mp(e,t){return t.lastIndex=0,t.test(e.hostname)}s(mp,"urlHostnameOk");function hp(e,t){return t.lastIndex=0,t.test(e.protocol.endsWith(":")?e.protocol.slice(0,-1):e.protocol)}s(hp,"urlProtocolOk");var fb=_("$ZodURL",(e,t)=>{Ne.init(e,t),e._zod.check=n=>{try{let r=n.value.trim(),o=pp(r,t);if(o===ub){n.issues.push({code:"invalid_format",format:"url",note:"Invalid URL format",input:n.value,inst:e,continue:!t.abort});return}if(o===tl){n.issues.push({code:"invalid_format",format:"url",input:n.value,inst:e,continue:!t.abort});return}if(o===!0){n.value=nl(r);return}t.hostname&&!mp(o,t.hostname)&&n.issues.push({code:"invalid_format",format:"url",note:"Invalid hostname",pattern:t.hostname.source,input:n.value,inst:e,continue:!t.abort}),t.protocol&&!hp(o,t.protocol)&&n.issues.push({code:"invalid_format",format:"url",note:"Invalid protocol",pattern:t.protocol.source,input:n.value,inst:e,continue:!t.abort}),n.value=t.normalize?o.href:nl(r);return}catch{n.issues.push({code:"invalid_format",format:"url",input:n.value,inst:e,continue:!t.abort})}}}),db=_("$ZodEmoji",(e,t)=>{t.pattern??(t.pattern=pS()),Ne.init(e,t)}),pb=_("$ZodNanoID",(e,t)=>{if(t.length!==void 0&&(!Number.isInteger(t.length)||t.length<1))throw new Error(`Invalid nanoid length: ${t.length}`);t.pattern??(t.pattern=t.length===void 0?cS:uS(t.length)),Ne.init(e,t)}),mb=_("$ZodCUID",(e,t)=>{t.pattern??(t.pattern=rS),Ne.init(e,t)}),hb=_("$ZodCUID2",(e,t)=>{t.pattern??(t.pattern=oS),Ne.init(e,t)}),gb=_("$ZodULID",(e,t)=>{t.pattern??(t.pattern=sS),Ne.init(e,t)}),xb=_("$ZodXID",(e,t)=>{t.pattern??(t.pattern=iS),Ne.init(e,t)}),yb=_("$ZodKSUID",(e,t)=>{t.pattern??(t.pattern=aS),Ne.init(e,t)}),Sb=_("$ZodISODateTime",(e,t)=>{t.pattern??(t.pattern=kS(t)),Ne.init(e,t)}),bb=_("$ZodISODate",(e,t)=>{t.pattern??(t.pattern=IS),Ne.init(e,t)}),vb=_("$ZodISOTime",(e,t)=>{t.pattern??(t.pattern=TS(t)),Ne.init(e,t)}),_b=_("$ZodISODuration",(e,t)=>{t.pattern??(t.pattern=lS),Ne.init(e,t)}),wb=_("$ZodIPv4",(e,t)=>{t.pattern??(t.pattern=mS),Ne.init(e,t)}),tB=/^[0-9a-fA-F:.]+$/;function rl(e){return tB.test(e)?lb(`http://[${e}]`):!1}s(rl,"isValidIPv6");var Eb=_("$ZodIPv6",(e,t)=>{t.pattern??(t.pattern=hS),Ne.init(e,t),e._zod.check=n=>{rl(n.value)||n.issues.push({code:"invalid_format",format:"ipv6",input:n.value,inst:e,continue:!t.abort})}}),Ib=_("$ZodMAC",(e,t)=>{t.pattern??(t.pattern=gS(t.delimiter)),Ne.init(e,t)}),Tb=_("$ZodCIDRv4",(e,t)=>{t.pattern??(t.pattern=xS),Ne.init(e,t)});function gp(e){let t=e.split("/");if(t.length!==2)return!1;let[n,r]=t;if(!r)return!1;let o=Number(r);return`${o}`!==r||o<0||o>128?!1:rl(n)}s(gp,"isValidCIDRv6");var kb=_("$ZodCIDRv6",(e,t)=>{t.pattern??(t.pattern=yS),Ne.init(e,t),e._zod.check=n=>{gp(n.value)||n.issues.push({code:"invalid_format",format:"cidrv6",input:n.value,inst:e,continue:!t.abort})}});function ol(e){if(e==="")return!0;if(/\s/.test(e)||e.length%4!==0)return!1;try{return atob(e),!0}catch{return!1}}s(ol,"isValidBase64");var xp=/^[0-9a-zA-Z+/]*={0,2}$/,Ab=_("$ZodBase64",(e,t)=>{t.pattern??(t.pattern=xp),Ne.init(e,t),e._zod.check=n=>{ol(n.value)||n.issues.push({code:"invalid_format",format:"base64",input:n.value,inst:e,continue:!t.abort})}}),sl=/^[A-Za-z0-9_-]*$/;function yp(e){if(!sl.test(e))return!1;let t=e.replace(/[-_]/g,r=>r==="-"?"+":"/"),n=t.padEnd(Math.ceil(t.length/4)*4,"=");return ol(n)}s(yp,"isValidBase64URL");var Cb=_("$ZodBase64URL",(e,t)=>{t.pattern??(t.pattern=sl),Ne.init(e,t),e._zod.check=n=>{yp(n.value)||n.issues.push({code:"invalid_format",format:"base64url",input:n.value,inst:e,continue:!t.abort})}}),Ob=_("$ZodE164",(e,t)=>{t.pattern??(t.pattern=wS),Ne.init(e,t)}),nB=/[- ]/g;function rB(e){let t=e.length,n=1,r=0;for(;t;){let o=e.charCodeAt(--t)-48;n^=1,r+=n?[0,2,4,6,8,1,3,5,7,9][o]:o}return r%10===0}s(rB,"isLuhnAlgo");function Sp(e){return np.test(e)?rB(e.replace(nB,"")):!1}s(Sp,"isValidCreditCard");var Rb=_("$ZodCreditCard",(e,t)=>{t.pattern??(t.pattern=np),Ne.init(e,t),e._zod.check=n=>{Sp(n.value)||n.issues.push({code:"invalid_format",format:"credit_card",input:n.value,inst:e,continue:!t.abort})}});function oB(e){let t=0,n=e.length;for(let r=4;r<n;r++){let o=e.charCodeAt(r);t=(o>=65?t*100+(o-55):t*10+(o-48))%97}for(let r=0;r<4;r++){let o=e.charCodeAt(r);t=(o>=65?t*100+(o-55):t*10+(o-48))%97}return t===1}s(oB,"isIso7064Mod97");function bp(e){return rp.test(e)?oB(e):!1}s(bp,"isValidIBAN");var $b=_("$ZodIBAN",(e,t)=>{t.pattern??(t.pattern=rp),Ne.init(e,t),e._zod.check=n=>{bp(n.value)||n.issues.push({code:"invalid_format",format:"iban",input:n.value,inst:e,continue:!t.abort})}});function vp(e,t=null){try{let n=e.split(".");if(n.length!==3)return!1;let[r]=n;if(!r)return!1;let o=JSON.parse(atob(r));return!("typ"in o&&o?.typ!=="JWT"||!o.alg||t&&(!("alg"in o)||o.alg!==t))}catch{return!1}}s(vp,"isValidJWT");var Pb=_("$ZodJWT",(e,t)=>{Ne.init(e,t),e._zod.check=n=>{vp(n.value,t.alg)||n.issues.push({code:"invalid_format",format:"jwt",input:n.value,inst:e,continue:!t.abort})}}),Nb=_("$ZodCustomStringFormat",(e,t)=>{Ne.init(e,t),e._zod.check=n=>{t.fn(n.value)||n.issues.push({code:"invalid_format",format:t.format,input:n.value,inst:e,continue:!t.abort})}}),_p=_("$ZodNumber",(e,t)=>{ue.init(e,t),e._zod.pattern=_o,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=Number(n.value)}catch{}let o=n.value;if(typeof o=="number"&&!Number.isNaN(o)&&Number.isFinite(o))return n;let i=typeof o=="number"?Number.isNaN(o)?"NaN":Number.isFinite(o)?void 0:String(o):void 0;return n.issues.push({expected:"number",code:"invalid_type",input:o,inst:e,...i?{received:i}:{}}),n}}),Db=_("$ZodNumberFormat",(e,t)=>{US.init(e,t),_p.init(e,t)}),il=_("$ZodBoolean",(e,t)=>{ue.init(e,t),e._zod.pattern=RS,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=!!n.value}catch{}let o=n.value;return typeof o=="boolean"||n.issues.push({expected:"boolean",code:"invalid_type",input:o,inst:e}),n}}),wp=_("$ZodBigInt",(e,t)=>{ue.init(e,t),e._zod.pattern=OS,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=BigInt(n.value)}catch{}return typeof n.value=="bigint"||n.issues.push({expected:"bigint",code:"invalid_type",input:n.value,inst:e}),n}}),Lb=_("$ZodBigIntFormat",(e,t)=>{GS.init(e,t),wp.init(e,t)}),Fb=_("$ZodSymbol",(e,t)=>{ue.init(e,t),e._zod.parse=(n,r)=>{let o=n.value;return typeof o=="symbol"||n.issues.push({expected:"symbol",code:"invalid_type",input:o,inst:e}),n}}),zb=_("$ZodUndefined",(e,t)=>{ue.init(e,t),e._zod.pattern=PS,e._zod.values=new Set([void 0]),e._zod.parse=(n,r)=>{let o=n.value;return typeof o>"u"||n.issues.push({expected:"undefined",code:"invalid_type",input:o,inst:e}),n}}),Mb=_("$ZodNull",(e,t)=>{ue.init(e,t),e._zod.pattern=$S,e._zod.values=new Set([null]),e._zod.parse=(n,r)=>{let o=n.value;return o===null||n.issues.push({expected:"null",code:"invalid_type",input:o,inst:e}),n}}),Ub=_("$ZodAny",(e,t)=>{ue.init(e,t),e._zod.parse=n=>n}),Gb=_("$ZodUnknown",(e,t)=>{ue.init(e,t),e._zod.parse=n=>n}),jb=_("$ZodNever",(e,t)=>{ue.init(e,t),e._zod.parse=(n,r)=>(n.issues.push({expected:"never",code:"invalid_type",input:n.value,inst:e}),n)}),Zb=_("$ZodVoid",(e,t)=>{ue.init(e,t),e._zod.parse=(n,r)=>{let o=n.value;return typeof o>"u"||n.issues.push({expected:"void",code:"invalid_type",input:o,inst:e}),n}}),qb=_("$ZodDate",(e,t)=>{ue.init(e,t),e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=new Date(n.value)}catch{}let o=n.value,i=o instanceof Date;return i&&!Number.isNaN(o.getTime())||n.issues.push({expected:"date",code:"invalid_type",input:o,...i?{received:"Invalid Date"}:{},inst:e}),n}});function Bb(e,t){let n=La(e._zod.def.checks);if(!n.length)return;let r=Math.min(...n.map(i=>i[0])),o=e._zod.parse;e._zod.parse=(i,a)=>{let c=t(i.value);if(c>r&&!a?.skipChecks&&a?.direction!=="backward"){for(let[l,u]of La(e._zod.def.checks))if(c>l&&u._zod.def.when(i)){let f=i.issues.length;return u._zod.check(i),i.issues[f].continue=!1,Zu(i.issues,f,e),i}}return o(i,a)}}s(Bb,"capSize");var sB=s(e=>Array.isArray(e)?e.length:-1,"arraySize"),iB=s(e=>e instanceof Map?e.size:-1,"mapSize"),aB=s(e=>e instanceof Set?e.size:-1,"setSize");function xO(e,t,n){e.issues.length&&t.issues.push(...mn(n,e.issues)),t.value[n]=e.value}s(xO,"handleArrayResult");var Vb=_("$ZodArray",(e,t)=>{ue.init(e,t);let n=Et.memoizer;n?.attach(e),e._zod.parse=(r,o)=>{let i=r.value;if(!Array.isArray(i))return r.issues.push({expected:"array",code:"invalid_type",input:i,inst:e}),r;r.value=n?n.alloc(e,r,Array(i.length),o):Array(i.length);let a=[],c=o?.abortEarly;for(let l=0;l<i.length;l++){let u=i[l],f=t.element._zod.run({value:u,issues:[]},o);if(f instanceof Promise)a.push(f.then(d=>xO(d,r,l)));else if(xO(f,r,l),c&&f.issues.length!==0&&Qt(f))break}return a.length?Promise.all(a).then(()=>r):r},Bb(e,sB)});function fp(e,t,n,r,o,i){let a=n in r,c=i==="optional";if(!(!a&&c&&o==="optional")){if(e.issues.length){if(o!==void 0&&c&&!a)return;t.issues.push(...mn(n,e.issues))}if(!a&&o===void 0){e.issues.length||t.issues.push({code:"invalid_type",expected:"nonoptional",input:void 0,path:[n]});return}e.value===void 0?(a||o==="defaulted"&&!c)&&(t.value[n]=void 0):t.value[n]=e.value}}s(fp,"handlePropertyResult");var cB=[];function NO(e){let t=Object.keys(e.shape),n=Object.getOwnPropertySymbols(e.shape),r=n.length?n:cB,o=r.length?[...t,...r]:t;for(let a of o)if(!e.shape?.[a]?._zod?.traits?.has("$ZodType"))throw new Error(`Invalid element at key "${String(a)}": expected a Zod schema`);let i=Zy(e.shape);return{...e,allKeys:o,symbolKeys:r,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(i)}}s(NO,"normalizeDef");function DO(e,t,n,r,o,i,a){let c=[],l=o.keySet,u=o.catchall._zod,f=u.def.type,d=u.optin,p=u.optout,m=0;for(let h in t){if(a&&n.issues.length!==m){if(Qt(n,m))break;m=n.issues.length}if(l.has(h))continue;if(h==="__proto__"){f==="never"&&c.push(h);continue}if(f==="never"){c.push(h);continue}let x=u.run({value:t[h],issues:[]},r);x instanceof Promise?e.push(x.then(S=>fp(S,n,h,t,d,p))):fp(x,n,h,t,d,p)}return c.length&&n.issues.push({code:"unrecognized_keys",keys:c,input:t,inst:i,continue:!0}),e.length?Promise.all(e).then(()=>n):n}s(DO,"handleCatchall");var LO=_("$ZodObject",(e,t)=>{ue.init(e,t);let n=Object.getOwnPropertyDescriptor(t,"shape"),r=n?.get?n.get.raw:t.shape??{};if(r){let u=s(()=>{let f={...r};return Object.defineProperty(t,"shape",{value:f}),u.raw=f,f},"get");u.raw=r,Object.defineProperty(t,"shape",{get:u})}let o=Na(()=>NO(t));he(e,"propValues",u=>{let f=u.def.shape,d={};for(let p in f){let m=f[p]._zod;if(m.values){Object.prototype.hasOwnProperty.call(d,p)||Pt(d,p,new Set);for(let h of m.values)d[p].add(h);m.optin!==void 0&&d[p].add(void 0)}}return d});let i=si,a=t.catchall,c,l=Et.memoizer;l?.attach(e),e._zod.parse=(u,f)=>{c??(c=o.value);let d=u.value;if(!i(d))return u.issues.push({expected:"object",code:"invalid_type",input:d,inst:e}),u;u.value=l?l.alloc(e,u,{},f):{};let p=[],m=c.shape,h=f?.abortEarly,x=u.issues.length;for(let S of c.allKeys){if(h&&u.issues.length!==x){if(Qt(u,x))break;x=u.issues.length}if(S==="__proto__")continue;let T=m[S],b=T._zod.optin,v=T._zod.optout,C=T._zod.run({value:d[S],issues:[]},f);C instanceof Promise?p.push(C.then(w=>fp(w,u,S,d,b,v))):fp(C,u,S,d,b,v)}return a?DO(p,d,u,f,o.value,e,h===!0):p.length?Promise.all(p).then(()=>u):u}}),Hb=_("$ZodObjectJIT",(e,t)=>{LO.init(e,t);let n=e._zod.parse,r=Na(()=>NO(t)),o=Et.memoizer,i=s(m=>{let h=r.value,x=h.symbolKeys,S=new ci(["payload","ctx"],{shape:m,inst:e,memo:o,syms:x}),T=s(w=>`shape[${w}]._zod.run({ value: input[${w}], issues: [] }, ctx)`,"parseStr"),b=s((w,I)=>`
|
|
13
|
+
let ${w}_ab = false;
|
|
14
|
+
for (let i = 0; i < ${w}.issues.length; i++) {
|
|
15
|
+
const iss = ${w}.issues[i];
|
|
16
|
+
iss.path = iss.path ? [${I}, ...iss.path] : [${I}];
|
|
17
|
+
payload.issues.push(iss);
|
|
18
|
+
if (iss.continue !== true) ${w}_ab = true;
|
|
19
|
+
}
|
|
20
|
+
if (${w}_ab && ctx && ctx.abortEarly) {
|
|
21
|
+
payload.value = newResult;
|
|
22
|
+
return payload;
|
|
23
|
+
}`,"prefixStr");S.write("const input = payload.value;");let v=Object.create(null),C=0;for(let w of h.allKeys)v[w]=`key_${C++}`;S.write(o?"const newResult = memo.alloc(inst, payload, {}, ctx);":"const newResult = {};");for(let w of h.allKeys){if(w==="__proto__")continue;let I=v[w],A=typeof w=="symbol"?`syms[${x.indexOf(w)}]`:Xt(w),O=`${A} in input`,L=m[w],q=L?._zod?.optin,Q=q!==void 0,E=L?._zod?.optout==="optional";if(S.write(`const ${I} = ${T(A)};`),Q&&E){let k=q==="optional"?`${I}_present`:`${I}.value !== undefined || ${I}_present`;S.write(`
|
|
24
|
+
const ${I}_present = ${O};
|
|
25
|
+
if (!${I}.issues.length || ${I}_present) {
|
|
26
|
+
if (${I}.issues.length) {${b(I,A)}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
if (${k}) {
|
|
30
|
+
newResult[${A}] = ${I}.value;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
`)}else Q?(S.write(`
|
|
35
|
+
if (${I}.issues.length) {${b(I,A)}
|
|
36
|
+
}
|
|
37
|
+
`),q==="defaulted"?S.write(`newResult[${A}] = ${I}.value;`):S.write(`
|
|
38
|
+
if (${I}.value !== undefined || ${O}) {
|
|
39
|
+
newResult[${A}] = ${I}.value;
|
|
40
|
+
}
|
|
41
|
+
`)):S.write(`
|
|
42
|
+
const ${I}_present = ${O};
|
|
43
|
+
if (${I}.issues.length) {${b(I,A)}
|
|
44
|
+
}
|
|
45
|
+
if (!${I}_present && !${I}.issues.length) {
|
|
46
|
+
payload.issues.push({
|
|
47
|
+
code: "invalid_type",
|
|
48
|
+
expected: "nonoptional",
|
|
49
|
+
input: undefined,
|
|
50
|
+
path: [${A}]
|
|
51
|
+
});
|
|
52
|
+
if (ctx && ctx.abortEarly) {
|
|
53
|
+
payload.value = newResult;
|
|
54
|
+
return payload;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
if (${I}_present) {
|
|
59
|
+
newResult[${A}] = ${I}.value;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
`)}return S.write("payload.value = newResult;"),S.write("return payload;"),S.compile()},"generateFastpass"),a,c=si,l=!Et.jitless,f=l&&Gy.value,d=t.catchall,p;e._zod.parse=(m,h)=>{p??(p=r.value);let x=m.value;return c(x)?l&&f&&h?.async===!1&&h.jitless!==!0?(a||(a=i(t.shape)),m=a(m,h),d?DO([],x,m,h,p,e,h?.abortEarly===!0):m):n(m,h):(m.issues.push({expected:"object",code:"invalid_type",input:x,inst:e}),m)}});function yO(e,t,n,r){for(let i of e)if(i.issues.length===0)return t.value=i.value,t;let o=e.filter(i=>!Qt(i));return o.length===1?(t.value=o[0].value,o[0]):(t.issues.push({code:"invalid_union",input:t.value,inst:n,errors:e.map(i=>i.issues.map(a=>hn(a,r,rt())))}),t)}s(yO,"handleUnionResults");var al=_("$ZodUnion",(e,t)=>{ue.init(e,t),he(e,"optin",r=>r.def.options.some(o=>o._zod.optin==="defaulted")?"defaulted":r.def.options.some(o=>o._zod.optin!==void 0)?"optional":void 0),he(e,"optout",r=>r.def.options.some(o=>o._zod.optout==="optional")?"optional":void 0),he(e,"values",r=>{if(r.def.options.every(o=>o._zod.values))return new Set(r.def.options.flatMap(o=>Array.from(o._zod.values)))}),he(e,"pattern",r=>{if(r.def.options.every(o=>o._zod.pattern)){let o=r.def.options.map(i=>i._zod.pattern);return new RegExp(`^(${o.map(i=>vo(i.source)).join("|")})$`)}});let n=t.options.length===1?t.options[0]._zod.run:null;e._zod.parse=(r,o)=>{if(n)return n(r,o);let i=!1,a=[];for(let c of t.options){let l=c._zod.run({value:r.value,issues:[]},o);if(l instanceof Promise)a.push(l),i=!0;else{if(l.issues.length===0)return l;a.push(l)}}return i?Promise.all(a).then(c=>yO(c,r,e,o)):yO(a,r,e,o)}});function SO(e,t,n,r){let o=[];for(let i=0;i<e.length;i++)e[i].issues.length===0&&o.push(i);return o.length===1?(t.value=e[o[0]].value,t):(o.length===0?t.issues.push({code:"invalid_union",input:t.value,inst:n,errors:e.map(i=>i.issues.map(a=>hn(a,r,rt())))}):t.issues.push({code:"invalid_union",input:t.value,inst:n,errors:[],inclusive:!1,matches:o}),t)}s(SO,"handleExclusiveUnionResults");var Kb=_("$ZodXor",(e,t)=>{al.init(e,t),t.inclusive=!1;let n=t.options.length===1?t.options[0]._zod.run:null;e._zod.parse=(r,o)=>{if(n)return n(r,o);let i=!1,a=[];for(let c of t.options){let l=c._zod.run({value:r.value,issues:[]},o);l instanceof Promise?(a.push(l),i=!0):a.push(l)}return i?Promise.all(a).then(c=>SO(c,r,e,o)):SO(a,r,e,o)}});function Jb(e,t){let n=e._zod,r=n.bag.optionsMap;r||(r=FO(n.def),n.bag.optionsMap=r);let o=r.get(t);if(o===null)throw new Error(`Ambiguous discriminator value "${String(t)}"`);return o}s(Jb,"getDiscriminatedOption");function FO(e){let t=new Map;for(let n of e.options){let r=n._zod.propValues?.[e.discriminator];if(!r||r.size===0)throw new Error(`Invalid discriminated union option at index "${e.options.indexOf(n)}"`);for(let o of r)if(t.has(o)){if(o!==void 0)throw new Error(`Duplicate discriminator value "${String(o)}"`);t.set(o,null)}else t.set(o,n)}return t}s(FO,"discriminatorMap");var Wb=_("$ZodDiscriminatedUnion",(e,t)=>{t.inclusive=!1,al.init(e,t);let n=e._zod.parse;he(e,"propValues",o=>{let i={},a=0;for(let c of o.def.options){let l=c._zod.propValues;if(!l||Object.keys(l).length===0)throw new Error(`Invalid discriminated union option at index "${o.def.options.indexOf(c)}"`);l[o.def.discriminator]?.has(void 0)&&a++;for(let[u,f]of Object.entries(l)){Object.prototype.hasOwnProperty.call(i,u)||Pt(i,u,new Set);for(let d of f)i[u].add(d)}}return!o.def.unionFallback&&a>1&&i[o.def.discriminator]?.delete(void 0),i}),t.options.forEach((o,i)=>{let a=Da(o._zod.def);if(a&&!Object.prototype.hasOwnProperty.call(a,t.discriminator))throw new Error(`Invalid discriminated union option at index "${i}"`)});let r=Na(()=>FO(t));e._zod.parse=(o,i)=>{let a=o.value;if(!si(a))return o.issues.push({code:"invalid_type",expected:"object",input:a,inst:e}),o;let c=a?.[t.discriminator],l=r.value.get(c);return l&&(c!==void 0||i.direction!=="backward")?l._zod.run(o,i):t.unionFallback||i.direction==="backward"?n(o,i):(o.issues.push({code:"invalid_union",errors:[],note:"No matching discriminator",discriminator:t.discriminator,options:Array.from(r.value.keys()).filter(u=>r.value.get(u)!==null),input:a,path:[t.discriminator],inst:e}),o)}}),Yb=_("$ZodIntersection",(e,t)=>{ue.init(e,t),e._zod.parse=(n,r)=>{let o=n.value,i=t.left._zod.run({value:o,issues:[]},r),a=t.right._zod.run({value:o,issues:[]},r);return i instanceof Promise||a instanceof Promise?Promise.all([i,a]).then(([l,u])=>bO(n,l,u)):bO(n,i,a)}});function Za(e,t){if(e===t)return{valid:!0,data:e};if(e instanceof Date&&t instanceof Date&&+e==+t)return{valid:!0,data:e};if(Kn(e)&&Kn(t)){let n=Object.keys(t),r=Object.keys(e).filter(i=>n.indexOf(i)!==-1),o={...e,...t};Object.prototype.hasOwnProperty.call(o,"__proto__")&&delete o.__proto__;for(let i of r){if(i==="__proto__")continue;let a=Za(e[i],t[i]);if(!a.valid)return{valid:!1,mergeErrorPath:[i,...a.mergeErrorPath]};o[i]=a.data}return{valid:!0,data:o}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};let n=[];for(let r=0;r<e.length;r++){let o=e[r],i=t[r],a=Za(o,i);if(!a.valid)return{valid:!1,mergeErrorPath:[r,...a.mergeErrorPath]};n.push(a.data)}return{valid:!0,data:n}}return{valid:!1,mergeErrorPath:[]}}s(Za,"mergeValues");function bO(e,t,n){let r=new Map,o,i=new Map,a=s((u,f)=>{let d;if(u.code==="unrecognized_keys"&&!u.path?.length)o??(o=u),d=u.keys;else if(u.code==="invalid_key"&&u.origin==="record"&&u.path?.length===1){let p=String(u.path[0]);i.has(p)||i.set(p,u),d=[p]}else return!1;for(let p of d)r.has(p)||r.set(p,{}),r.get(p)[f]=!0;return!0},"collect");for(let u of t.issues)a(u,"l")||e.issues.push(u);for(let u of n.issues)a(u,"r")||e.issues.push(u);let c=[...r].filter(([,u])=>u.l&&u.r).map(([u])=>u);if(c.length){let u=o?c.filter(f=>o.keys.includes(f)):[];u.length&&e.issues.push({...o,keys:u});for(let f of c)!u.includes(f)&&i.has(f)&&e.issues.push(i.get(f))}let l=Za(t.value,n.value);if(!l.valid){if(Qt(e))return e;throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(l.mergeErrorPath)}`)}return e.value=l.data,e}s(bO,"handleIntersectionResults");var Ep=_("$ZodTuple",(e,t)=>{ue.init(e,t);let n=t.items,r=Et.memoizer;r?.attach(e),e._zod.parse=(o,i)=>{let a=o.value;if(!Array.isArray(a))return o.issues.push({input:a,inst:e,expected:"tuple",code:"invalid_type"}),o;o.value=r?r.alloc(e,o,[],i):[];let c=[],l=vO(n,"optin"),u=vO(n,"optout");if(!t.rest){if(a.length<l)return o.issues.push({code:"too_small",minimum:l,inclusive:!0,input:a,inst:e,origin:"array"}),o;a.length>n.length&&o.issues.push({code:"too_big",maximum:n.length,inclusive:!0,input:a,inst:e,origin:"array"})}let f=new Array(n.length),d=t.rest?i?.abortEarly:void 0,p=!1;for(let m=0;m<n.length;m++){let h=n[m]._zod.run({value:a[m],issues:[]},i);h instanceof Promise?c.push(h.then(x=>{f[m]=x})):(f[m]=h,d&&!p&&h.issues.length&&(p=Qt(h)))}if(t.rest&&!p){let m=n.length-1,h=a.slice(n.length),x=o.issues.length;for(let S of h){if(d&&o.issues.length!==x){if(Qt(o,x))break;x=o.issues.length}m++;let T=t.rest._zod.run({value:S,issues:[]},i);T instanceof Promise?c.push(T.then(b=>_O(b,o,m))):_O(T,o,m)}}return c.length?Promise.all(c).then(()=>wO(f,o,n,a,u)):wO(f,o,n,a,u)}});function vO(e,t){for(let n=e.length-1;n>=0;n--)if(!(t==="optin"?e[n]._zod.optin!==void 0:e[n]._zod.optout==="optional"))return n+1;return 0}s(vO,"getTupleOptStart");function _O(e,t,n){e.issues.length&&t.issues.push(...mn(n,e.issues)),t.value[n]=e.value}s(_O,"handleTupleResult");function wO(e,t,n,r,o){for(let i=0;i<n.length;i++){let a=e[i],c=i<r.length;if(!c&&i>=o&&n[i]._zod.optin==="optional"){t.value.length=i;break}if(a.issues.length){if(!c&&i>=o){t.value.length=i;break}t.issues.push(...mn(i,a.issues))}t.value[i]=a.value}for(let i=t.value.length-1;i>=r.length&&(n[i]._zod.optout==="optional"&&t.value[i]===void 0);i--)t.value.length=i;return t}s(wO,"handleTupleResults");var Xb=_("$ZodRecord",(e,t)=>{ue.init(e,t);let n=Et.memoizer;n?.attach(e),e._zod.parse=(r,o)=>{let i=r.value;if(!Kn(i))return r.issues.push({expected:"record",code:"invalid_type",input:i,inst:e}),r;let a=[],c=t.keyType._zod.values;if(c&&!t.partial){r.value=n?n.alloc(e,r,{},o):{};let l=new Set;for(let f of c)if(typeof f=="string"||typeof f=="number"||typeof f=="symbol"){if(l.add(typeof f=="number"?f.toString():f),f==="__proto__")continue;let d=t.keyType._zod.run({value:f,issues:[]},o);if(d instanceof Promise)throw new Error("Async schemas not supported in object keys currently");if(d.issues.length){r.issues.push({code:"invalid_key",origin:"record",issues:d.issues.map(h=>hn(h,o,rt())),input:f,path:[f],inst:e});continue}let p=d.value;if(p==="__proto__")continue;let m=t.valueType._zod.run({value:i[f],issues:[]},o);m instanceof Promise?a.push(m.then(h=>{h.issues.length&&r.issues.push(...mn(f,h.issues)),r.value[p]=h.value})):(m.issues.length&&r.issues.push(...mn(f,m.issues)),r.value[p]=m.value)}let u;for(let f in i)if(!l.has(f))if(t.mode==="loose"){if(f==="__proto__")continue;r.value[f]=i[f]}else u=u??[],u.push(f);u&&u.length>0&&r.issues.push({code:"unrecognized_keys",input:i,inst:e,keys:u,continue:!0})}else{r.value=n?n.alloc(e,r,{},o):{};let l;for(let u of Reflect.ownKeys(i)){if(u==="__proto__"||!Object.prototype.propertyIsEnumerable.call(i,u))continue;let f=t.keyType._zod.run({value:u,issues:[]},o);if(f instanceof Promise)throw new Error("Async schemas not supported in object keys currently");if(typeof u=="string"&&_o.test(u)&&f.issues.length){let h=t.keyType._zod.run({value:Number(u),issues:[]},o);if(h instanceof Promise)throw new Error("Async schemas not supported in object keys currently");h.issues.length===0&&(f=h)}if(f.issues.length){t.mode==="loose"?r.value[u]=i[u]:c?(l=l??[],l.push(u)):r.issues.push({code:"invalid_key",origin:"record",issues:f.issues.map(h=>hn(h,o,rt())),input:u,path:[u],inst:e});continue}let p=f.value;if(p==="__proto__")continue;let m=t.valueType._zod.run({value:i[u],issues:[]},o);m instanceof Promise?a.push(m.then(h=>{h.issues.length&&r.issues.push(...mn(u,h.issues)),r.value[p]=h.value})):(m.issues.length&&r.issues.push(...mn(u,m.issues)),r.value[p]=m.value)}l&&l.length>0&&r.issues.push({code:"unrecognized_keys",input:i,inst:e,keys:l,continue:!0})}return a.length?Promise.all(a).then(()=>r):r}}),Qb=_("$ZodMap",(e,t)=>{ue.init(e,t);let n=Et.memoizer;n?.attach(e),e._zod.parse=(r,o)=>{let i=r.value;if(!(i instanceof Map))return r.issues.push({expected:"map",code:"invalid_type",input:i,inst:e}),r;let a=[];r.value=n?n.alloc(e,r,new Map,o):new Map;let c=o?.abortEarly,l=r.issues.length;for(let[u,f]of i){if(c&&r.issues.length!==l){if(Qt(r,l))break;l=r.issues.length}let d=t.keyType._zod.run({value:u,issues:[]},o),p=t.valueType._zod.run({value:f,issues:[]},o);d instanceof Promise||p instanceof Promise?a.push(Promise.all([d,p]).then(([m,h])=>{EO(m,h,r,u,i,e,o)})):EO(d,p,r,u,i,e,o)}return a.length?Promise.all(a).then(()=>r):r},Bb(e,iB)});function EO(e,t,n,r,o,i,a){e.issues.length&&(Uu.has(typeof r)?n.issues.push(...mn(r,e.issues)):n.issues.push({code:"invalid_key",origin:"map",input:o,inst:i,issues:e.issues.map(c=>hn(c,a,rt()))})),t.issues.length&&(Uu.has(typeof r)?n.issues.push(...mn(r,t.issues)):n.issues.push({origin:"map",code:"invalid_element",input:o,inst:i,key:r,issues:t.issues.map(c=>hn(c,a,rt()))})),n.value.set(e.value,t.value)}s(EO,"handleMapResult");var ev=_("$ZodSet",(e,t)=>{ue.init(e,t);let n=Et.memoizer;n?.attach(e),e._zod.parse=(r,o)=>{let i=r.value;if(!(i instanceof Set))return r.issues.push({input:i,inst:e,expected:"set",code:"invalid_type"}),r;let a=[];r.value=n?n.alloc(e,r,new Set,o):new Set;let c=o?.abortEarly,l=r.issues.length;for(let u of i){if(c&&r.issues.length!==l){if(Qt(r,l))break;l=r.issues.length}let f=t.valueType._zod.run({value:u,issues:[]},o);f instanceof Promise?a.push(f.then(d=>IO(d,r))):IO(f,r)}return a.length?Promise.all(a).then(()=>r):r},Bb(e,aB)});function IO(e,t){e.issues.length&&t.issues.push(...e.issues),t.value.add(e.value)}s(IO,"handleSetResult");var tv=_("$ZodEnum",(e,t)=>{ue.init(e,t);let n=$a(t.entries),r=new Set(n);e._zod.values=r,he(e,"pattern",o=>{let i=$a(o.def.entries).filter(a=>Uu.has(typeof a));return new RegExp(i.length?`^(${i.map(a=>Jn(a.toString())).join("|")})$`:"^[^\\s\\S]$")}),e._zod.parse=(o,i)=>{let a=o.value;return r.has(a)||o.issues.push({code:"invalid_value",values:n,input:a,inst:e}),o}}),nv=_("$ZodLiteral",(e,t)=>{ue.init(e,t);let n=new Set(t.values);e._zod.values=n,he(e,"pattern",r=>{let o=r.def.values;return new RegExp(o.length?`^(${o.map(i=>typeof i=="string"?Jn(i):i?Jn(i.toString()):String(i)).join("|")})$`:"^[^\\s\\S]$")}),e._zod.parse=(r,o)=>{let i=r.value;return n.has(i)||r.issues.push({code:"invalid_value",values:t.values,input:i,inst:e}),r}}),rv=_("$ZodFile",(e,t)=>{ue.init(e,t),e._zod.parse=(n,r)=>{let o=n.value;return o instanceof File||n.issues.push({expected:"file",code:"invalid_type",input:o,inst:e}),n}}),ov=_("$ZodTransform",(e,t)=>{ue.init(e,t),e._zod.optin="optional",Et.memoizer?.guard(e),e._zod.parse=(n,r)=>{if(r.direction==="backward")throw new ds(e.constructor.name);let o=t.transform(n.value,n);if(r.async)return(o instanceof Promise?o:Promise.resolve(o)).then(a=>(n.value=a,n));if(o instanceof Promise)throw new gn;return n.value=o,n}});function TO(e,t){return e.value=t.issues.length?void 0:t.value,e}s(TO,"handleOptionalResult");var Ip=_("$ZodOptional",(e,t)=>{ue.init(e,t),he(e,"optin",n=>n.def.innerType._zod.optin==="defaulted"?"defaulted":"optional"),e._zod.optout="optional",he(e,"values",n=>{let r=n.def.innerType._zod.values;return r?new Set([...r,void 0]):void 0}),he(e,"pattern",n=>{let r=n.def.innerType._zod.pattern;return r?new RegExp(`^(${vo(r.source)})?$`):void 0}),e._zod.parse=(n,r)=>{if(n.value===void 0){if(t.innerType._zod.optin!=="defaulted")return n;let o=t.innerType._zod.run({value:n.value,issues:[]},r);return o instanceof Promise?o.then(i=>TO(n,i)):TO(n,o)}return t.innerType._zod.run(n,r)}}),sv=_("$ZodExactOptional",(e,t)=>{Ip.init(e,t),he(e,"values",n=>n.def.innerType._zod.values),he(e,"pattern",n=>n.def.innerType._zod.pattern),e._zod.parse=(n,r)=>t.innerType._zod.run(n,r)}),iv=_("$ZodNullable",(e,t)=>{ue.init(e,t),he(e,"optin",n=>n.def.innerType._zod.optin),he(e,"optout",n=>n.def.innerType._zod.optout),he(e,"pattern",n=>{let r=n.def.innerType._zod.pattern;return r?new RegExp(`^(${vo(r.source)}|null)$`):void 0}),he(e,"values",n=>n.def.innerType._zod.values?new Set([...n.def.innerType._zod.values,null]):void 0),e._zod.parse=(n,r)=>n.value===null?n:t.innerType._zod.run(n,r)}),av=_("$ZodDefault",(e,t)=>{ue.init(e,t),e._zod.optin="defaulted",he(e,"values",n=>n.def.innerType._zod.values),e._zod.parse=(n,r)=>{if(r.direction==="backward")return t.innerType._zod.run(n,r);if(n.value===void 0)return n.value=t.defaultValue,n;let o=t.innerType._zod.run(n,r);return o instanceof Promise?o.then(i=>kO(i,t)):kO(o,t)}});function kO(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}s(kO,"handleDefaultResult");var cv=_("$ZodPrefault",(e,t)=>{ue.init(e,t),e._zod.optin="defaulted",he(e,"values",n=>n.def.innerType._zod.values),e._zod.parse=(n,r)=>(r.direction==="backward"||n.value===void 0&&(n.value=t.defaultValue),t.innerType._zod.run(n,r))}),uv=_("$ZodNonOptional",(e,t)=>{ue.init(e,t),he(e,"values",n=>{let r=n.def.innerType._zod.values;return r?new Set([...r].filter(o=>o!==void 0)):void 0}),e._zod.parse=(n,r)=>{let o=t.innerType._zod.run(n,r);return o instanceof Promise?o.then(i=>AO(i,e)):AO(o,e)}});function AO(e,t){return!e.issues.length&&e.value===void 0&&e.issues.push({code:"invalid_type",expected:"nonoptional",input:e.value,inst:t}),e}s(AO,"handleNonOptionalResult");var lv=_("$ZodSuccess",(e,t)=>{ue.init(e,t),e._zod.parse=(n,r)=>{if(r.direction==="backward")throw new ds("ZodSuccess");let o=t.innerType._zod.run(n,r);return o instanceof Promise?o.then(i=>(n.value=i.issues.length===0,n)):(n.value=o.issues.length===0,n)}});function CO(e,t,n,r){return t.issues.length?(e.value=n.catchValue({...t,value:e.value,error:{issues:t.issues.map(o=>hn(o,r,rt()))},input:e.value}),e):(e.value=t.value,t.memo&&(e.memo=!0),e)}s(CO,"handleCatchResult");var fv=_("$ZodCatch",(e,t)=>{ue.init(e,t),he(e,"optin",n=>n.def.innerType._zod.optin==="defaulted"?"defaulted":"optional"),he(e,"optout",n=>n.def.innerType._zod.optout),he(e,"values",n=>n.def.innerType._zod.values),e._zod.parse=(n,r)=>{if(r.direction==="backward")return t.innerType._zod.run(n,r);let o=t.innerType._zod.run({value:n.value,issues:[]},r);return o instanceof Promise?o.then(i=>CO(n,i,t,r)):CO(n,o,t,r)}}),dv=_("$ZodNaN",(e,t)=>{ue.init(e,t),e._zod.parse=(n,r)=>((typeof n.value!="number"||!Number.isNaN(n.value))&&n.issues.push({input:n.value,inst:e,expected:"nan",code:"invalid_type"}),n)}),Tp=_("$ZodPipe",(e,t)=>{ue.init(e,t),he(e,"values",n=>n.def.in._zod.values),he(e,"optin",n=>n.def.in._zod.optin),he(e,"optout",n=>n.def.out._zod.optout),he(e,"propValues",n=>n.def.in._zod.propValues),e._zod.parse=(n,r)=>{if(r.direction==="backward"){let i=t.out._zod.run(n,r);return i instanceof Promise?i.then(a=>cp(a,t.in,r)):cp(i,t.in,r)}let o=t.in._zod.run(n,r);return o instanceof Promise?o.then(i=>cp(i,t.out,r)):cp(o,t.out,r)}});function cp(e,t,n){return e.issues.some(r=>r.code!=="unrecognized_keys")?(e.aborted=!0,e):t._zod.run({value:e.value,issues:e.issues},n)}s(cp,"handlePipeResult");var cl=_("$ZodCodec",(e,t)=>{ue.init(e,t),he(e,"values",n=>n.def.in._zod.values),he(e,"optin",n=>n.def.in._zod.optin),he(e,"optout",n=>n.def.out._zod.optout),he(e,"propValues",n=>n.def.in._zod.propValues),e._zod.parse=(n,r)=>{if((r.direction||"forward")==="forward"){let i=t.in._zod.run(n,r);return i instanceof Promise?i.then(a=>up(a,t,r)):up(i,t,r)}else{let i=t.out._zod.run(n,r);return i instanceof Promise?i.then(a=>up(a,t,r)):up(i,t,r)}}});function up(e,t,n){if(e.issues.length)return e.aborted=!0,e;if((n.direction||"forward")==="forward"){let o=t.transform(e.value,e);return o instanceof Promise?o.then(i=>lp(e,i,t.out,n)):lp(e,o,t.out,n)}else{let o=t.reverseTransform(e.value,e);return o instanceof Promise?o.then(i=>lp(e,i,t.in,n)):lp(e,o,t.in,n)}}s(up,"handleCodecAResult");function lp(e,t,n,r){return e.issues.length?(e.aborted=!0,e):n._zod.run({value:t,issues:e.issues},r)}s(lp,"handleCodecTxResult");var pv=_("$ZodPreprocess",(e,t)=>{Tp.init(e,t)}),mv=_("$ZodReadonly",(e,t)=>{ue.init(e,t),he(e,"propValues",n=>n.def.innerType._zod.propValues),he(e,"values",n=>n.def.innerType._zod.values),he(e,"optin",n=>n.def.innerType?._zod?.optin),he(e,"optout",n=>n.def.innerType?._zod?.optout),e._zod.parse=(n,r)=>{if(r.direction==="backward")return t.innerType._zod.run(n,r);let o=t.innerType._zod.run(n,r);return o instanceof Promise?o.then(OO):OO(o)}});function OO(e){return e.memo||(e.value=Object.freeze(e.value)),e}s(OO,"handleReadonlyResult");function uB(e){let t=e._zod.def,n=t.pattern,r=!!t.format?.includes("int"),o,i;for(let c of t.checks??[]){let l=c._zod.def;l.pattern&&(n=l.pattern),r||(r=!!l.format?.includes("int"));let u=l.minimum??l.length,f=l.maximum??l.length;u!==void 0&&(o===void 0||u>o)&&(o=u),f!==void 0&&(i===void 0||f<i)&&(i=f)}if(n)return n.source;if(o!==void 0&&i!==void 0&&o>i)return"(?!)";if(o!==void 0||i!==void 0)return CS({minimum:o,maximum:i}).source;let a=e._zod.pattern;return(r&&a===_o?Xu:a)?.source}s(uB,"leafPattern");function sb(e){let t=e._zod.def,n=e._zod.pattern?.source,r=t.innerType??e._zod.innerType;if(r){let o=r._zod.pattern?.source,i=sb(r);return n&&o&&i&&i!==o?n.replace(vo(o),()=>vo(i)):n}if(t.options){let o=t.options.map(sb);if(o.every(Boolean))return`^(${o.map(i=>vo(i)).join("|")})$`}return uB(e)}s(sb,"partPattern");var hv=_("$ZodTemplateLiteral",(e,t)=>{ue.init(e,t);let n=[];for(let r of t.parts)if(typeof r=="object"&&r!==null){let o=sb(r);if(!o)throw new Error(`Invalid template literal part, no pattern found: ${[...r._zod.traits].shift()}`);n.push(vo(o))}else if(r===null||jy.has(typeof r))n.push(Jn(`${r}`));else throw new Error(`Invalid template literal part: ${r}`);e._zod.pattern=new RegExp(`^${n.join("")}$`),e._zod.parse=(r,o)=>typeof r.value!="string"?(r.issues.push({input:r.value,inst:e,expected:"string",code:"invalid_type"}),r):(e._zod.pattern.lastIndex=0,e._zod.pattern.test(r.value)||r.issues.push({input:r.value,inst:e,code:"invalid_format",format:t.format??"template_literal",pattern:e._zod.pattern.source}),r)}),gv=_("$ZodFunction",(e,t)=>(ue.init(e,t),Object.defineProperty(e,"_def",{value:t}),e._zod.def=t,e.implement=n=>{if(typeof n!="function")throw new Error("implement() must be called with a function");return Object.defineProperty(function(...r){let o=e._def.input?Vd(e._def.input,r):r,i=Reflect.apply(n,this,o);return e._def.output?Vd(e._def.output,i):i},"_zod",{value:e._zod,enumerable:!1})},e.implementAsync=n=>{if(typeof n!="function")throw new Error("implementAsync() must be called with a function");return Object.defineProperty(async function(...r){let o=e._def.input?await Hd(e._def.input,r):r,i=await Reflect.apply(n,this,o);return e._def.output?await Hd(e._def.output,i):i},"_zod",{value:e._zod,enumerable:!1})},e._zod.parse=(n,r)=>typeof n.value!="function"?(n.issues.push({code:"invalid_type",expected:"function",input:n.value,inst:e}),n):(e._def.output&&e._def.output._zod.def.type==="promise"?n.value=e.implementAsync(n.value):n.value=e.implement(n.value),n),e.input=(...n)=>{let r=e.constructor;return Array.isArray(n[0])?new r({type:"function",input:new Ep({type:"tuple",items:n[0],rest:n[1]}),output:e._def.output}):new r({type:"function",input:n[0],output:e._def.output})},e.output=n=>{let r=e.constructor;return new r({type:"function",input:e._def.input,output:n})},e)),xv=_("$ZodPromise",(e,t)=>{ue.init(e,t),e._zod.parse=(n,r)=>Promise.resolve(n.value).then(o=>t.innerType._zod.run({value:o,issues:[]},r))}),ul=_("$ZodLazy",(e,t)=>{ue.init(e,t),My(e._zod,"innerType",()=>{let n=t;return n._cachedInner||(n._cachedInner=t.getter()),n._cachedInner}),he(e,"pattern",n=>n.innerType?._zod?.pattern),he(e,"propValues",n=>n.innerType?._zod?.propValues),he(e,"optin",n=>n.innerType?._zod?.optin??void 0),he(e,"optout",n=>n.innerType?._zod?.optout??void 0),e._zod.parse=(n,r)=>e._zod.innerType._zod.run(n,r)}),yv=_("$ZodCustom",(e,t)=>{ze.init(e,t),ue.init(e,t),e._zod.parse=(n,r)=>n,e._zod.check=n=>{let r=n.value,o=t.fn(r);if(o instanceof Promise)return o.then(i=>RO(i,n,r,e));RO(o,n,r,e)}});function RO(e,t,n,r){if(!e){let o={code:"custom",input:n,inst:r,path:[...r._zod.def.path??[]],continue:!r._zod.def.abort};r._zod.def.params&&(o.params=r._zod.def.params),t.issues.push(Fa(o))}}s(RO,"handleRefineResult");var Op=class extends Error{static{s(this,"$ZodCyclicError")}constructor(){super("Cannot parse a reference cycle that closes through a transform"),this.name="ZodCyclicError"}},bv="~memo",MO=[];function UO(e){return e!==null&&typeof e=="object"}s(UO,"isRef");function Sv(e){return e.map(t=>t.path?{...t,path:t.path.slice()}:{...t})}s(Sv,"cloneIssues");var GO=new WeakMap,qa=0,Cp=1,ll=2;function fl(e,t,n){let r=GO.get(e);if(r!==void 0)return r?ll:qa;if(t.has(e))return ll;t.add(e);let o=qa,i=s(f=>{if(o!==ll&&f?._zod){let d=fl(f,t,n);d>o&&(o=d)}},"check"),a=s((f,d)=>{let p=qa;for(let m of Reflect.ownKeys(f)){let h=Object.getOwnPropertyDescriptor(f,m);if(d&&!h.enumerable)continue;let x=h.get?Cp:h.value?._zod?fl(h.value,t,n):qa;x>p&&(p=x)}return p},"shape"),c=s(f=>{f>o&&(o=f)},"merge"),l=e._zod.def,u=l.type;switch(u){case"object":{let f=Da(l);c(f?a(f,!0):Cp),i(l.catchall);break}case"array":i(l.element);break;case"tuple":for(let f of l.items)i(f);i(l.rest);break;case"record":case"map":i(l.keyType),i(l.valueType);break;case"set":i(l.valueType);break;case"union":for(let f of l.options)i(f);break;case"intersection":i(l.left),i(l.right);break;case"optional":case"nullable":case"default":case"prefault":case"catch":case"readonly":case"nonoptional":case"promise":case"success":i(l.innerType);break;case"pipe":i(l.in),i(l.out);break;case"function":i(l.input),i(l.output);break;case"lazy":{let f=l._cachedInner??(n?e._zod.innerType:void 0);c(f?fl(f,t,!1):Cp);break}case"template_literal":case"string":case"number":case"int":case"boolean":case"bigint":case"symbol":case"undefined":case"null":case"void":case"never":case"any":case"unknown":case"date":case"nan":case"enum":case"literal":case"file":case"transform":case"custom":break;default:for(let f in l){let d=Object.getOwnPropertyDescriptor(l,f);if(!d||d.get)continue;let p=d.value;if(!(!p||typeof p!="object")){if(p._zod)i(p);else if(Array.isArray(p))for(let m of p)i(m)}}}return t.delete(e),lB(e,o)}s(fl,"isRecursive");function lB(e,t){return t!==Cp&&GO.set(e,t===ll),t}s(lB,"settle");function Rp(e){return fl(e,new Set,!0)!==qa}s(Rp,"isRecursiveSchema");function fB(e,t){let n=e.buckets.get(t);return n||(n=new WeakMap,e.buckets.set(t,n)),n}s(fB,"bucketFor");var kp,Ap=[],dB={alloc(e,t,n){let r=kp;if(!r)return n;kp=void 0;let o={value:n,issues:null};return r.set(t.value,o),Ap.push(o),n},guard(e){var t;(t=e._zod).deferred??(t.deferred=[]),e._zod.deferred.push(()=>{let n=e._zod.parse,r=s((o,i)=>{if(i.direction!=="backward"&&$p(i,o.value))throw new Op;return n(o,i)},"wrapped");e._zod.parse=r,e._zod.run===n&&(e._zod.run=r)})},attach(e){var t;let n,r=!1,o,i;(t=e._zod).deferred??(t.deferred=[]),e._zod.deferred.push(()=>{let a=e._zod.parse,c=s((l,u)=>{if(n===void 0){let T=fl(e,new Set,!1);if(T===qa)return e._zod.parse=a,e._zod.run===c&&(e._zod.run=a),a(l,u);T===ll||r?n=!0:r=!0}let f=l.value;if(!UO(f))return a(l,u);let d=u[bv];d||(d={buckets:new WeakMap,backEdges:void 0},u[bv]=d);let p;o===u?p=i:(p=fB(d,e),o=u,i=p);let m=p.get(f);if(m)return l.value=m.value,m.issues?m.issues.length&&l.issues.push(...Sv(m.issues)):(l.memo=!0,d.backEdges??(d.backEdges=new WeakSet),d.backEdges.add(m.value)),l;kp=p;let h=Ap.length,x=a(l,u);kp=void 0;let S=Ap.length>h?Ap.pop():void 0;return x instanceof Promise?x.then(T=>(S&&(S.issues=T.issues.length?Sv(T.issues):MO),T)):(S&&(S.issues=x.issues.length?Sv(x.issues):MO),x)},"wrapped");e._zod.parse=c,e._zod.run===a&&(e._zod.run=c)})}};function dl(){return dB}s(dl,"memoizer");function $p(e,t){let n=e[bv]?.backEdges;return n!==void 0&&UO(t)&&n.has(t)}s($p,"isBackEdge");var ml={};$t(ml,{en:()=>pl});var pB=s(()=>{let e={string:{unit:"characters",verb:"to have"},file:{unit:"bytes",verb:"to have"},array:{unit:"items",verb:"to have"},set:{unit:"items",verb:"to have"},map:{unit:"entries",verb:"to have"}};function t(i){return e[i]??null}s(t,"getSizing");let n={regex:"input",email:"email address",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO datetime",date:"ISO date",time:"ISO time",duration:"ISO duration",ipv4:"IPv4 address",ipv6:"IPv6 address",mac:"MAC address",cidrv4:"IPv4 range",cidrv6:"IPv6 range",base64:"base64-encoded string",base64url:"base64url-encoded string",json_string:"JSON string",e164:"E.164 number",currency_code:"currency code",credit_card:"credit card number",iban:"IBAN",jwt:"JWT",template_literal:"input"},r={nan:"NaN"};function o(i,a){return i==="number"&&typeof a=="number"&&!Number.isFinite(a)?String(a):r[i]??i}return s(o,"getTypeName"),i=>{switch(i.code){case"invalid_type":{let a=o(i.expected),c=By(i.input),l=o(c,i.input);return`Invalid input: expected ${a}, received ${l}`}case"invalid_value":return i.values.length===1?`Invalid input: expected ${jd(i.values[0])}`:`Invalid option: expected one of ${Md(i.values,"|")}`;case"too_big":{let a=i.exact?"exactly ":i.inclusive?"<=":"<",c=t(i.origin);return c?`Too big: expected ${i.origin??"value"} to have ${a}${i.maximum.toString()} ${c.unit??"elements"}`:`Too big: expected ${i.origin??"value"} to be ${a}${i.maximum.toString()}`}case"too_small":{let a=i.exact?"exactly ":i.inclusive?">=":">",c=t(i.origin);return c?`Too small: expected ${i.origin} to have ${a}${i.minimum.toString()} ${c.unit}`:`Too small: expected ${i.origin} to be ${a}${i.minimum.toString()}`}case"invalid_format":{let a=i;return a.format==="starts_with"?`Invalid string: must start with "${a.prefix}"`:a.format==="ends_with"?`Invalid string: must end with "${a.suffix}"`:a.format==="includes"?`Invalid string: must include "${a.includes}"`:a.format==="regex"?`Invalid string: must match pattern ${a.pattern}`:`Invalid ${n[a.format]??i.format}`}case"not_multiple_of":return`Invalid number: must be a multiple of ${i.divisor}`;case"unrecognized_keys":return`Unrecognized key${i.keys.length>1?"s":""}: ${Md(i.keys,", ")}`;case"invalid_key":return`Invalid key in ${i.origin}`;case"invalid_union":return i.options&&Array.isArray(i.options)&&i.options.length>0?`Invalid discriminator value. Expected ${i.options.map(c=>`'${c}'`).join(" | ")}`:i.inclusive===!1?"Invalid input: more than one option matched":"Invalid input";case"invalid_element":return`Invalid value in ${i.origin}`;default:return"Invalid input"}}},"error");function pl(){return{localeError:pB()}}s(pl,"default");var jO,vv=Symbol("ZodOutput"),_v=Symbol("ZodInput"),Pp=class{static{s(this,"$ZodRegistry")}constructor(){this._map=new WeakMap,this._idmap=new Map}add(t,...n){let r=n[0];return this._map.set(t,r),r&&typeof r=="object"&&"id"in r&&this._idmap.set(r.id,t),this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(t){let n=this._map.get(t);return n&&typeof n=="object"&&"id"in n&&this._idmap.delete(n.id),this._map.delete(t),this}get(t){let n=t._zod.parent;if(n){let r={...this.get(n)??{}};delete r.id;let o={...r,...this._map.get(t)};return Object.keys(o).length?o:void 0}return this._map.get(t)}has(t){return this._map.has(t)}};function Np(){return new Pp}s(Np,"registry");(jO=globalThis).__zod_globalRegistry??(jO.__zod_globalRegistry=Np());var Nt=globalThis.__zod_globalRegistry;var en=Symbol.for("zod.compile.invalid"),ZO=Symbol.for("zod.compile.fallback"),gr=class extends Error{static{s(this,"ZodCompileAsyncError")}constructor(t="z.compile does not support async refinements, transforms, or checks"){super(t),this.name="ZodCompileAsyncError"}},we=class extends Error{static{s(this,"ZodCompileUnsupportedError")}constructor(t,n=!0){super(`z.compile does not support ${t}; this schema must use the runtime parser`),this.name="ZodCompileUnsupportedError",this.islandable=n}};function hB(e,t){try{return Lp(e,{assertOnly:!0})}catch{return t}}s(hB,"compileValidator");function Tv(e,t){try{let n=Lp(e),r=Dp(e,n);return r._zod.bag.validator=hB(e,n),r}catch(n){if(t?.strict)throw n;return e}}s(Tv,"compile");function Dp(e,t){if(Rp(e))throw new we("a schema whose subtree contains a reference cycle");let n=Pe(e),r=e._zod.run,o=r.__originalRun??r,i=s((a,c)=>{if(c?.async||c?.direction==="backward"||c?.skipChecks||c?.[ZO]||c&&$p(c,a.value))return o(a,c);let l=t(a.value);return l!==en?(a.value=l,a):(c&&(c[ZO]=!0),o(a,c))},"wrapped");return i.__originalRun=o,n._zod.bag.fallbackRun=o,n._zod.bag.validator=t,n._zod.run=i,r.__originalRun||gB(n,e,t),n}s(Dp,"withParser");function gB(e,t,n){let r=e,o=t;if(typeof o.safeParse=="function"){let i=o.safeParse;r.safeParse=(a,c)=>{let l=n(a);return l!==en?{success:!0,data:l}:i(a,c)}}if(typeof o.parse=="function"){let i=o.parse;r.parse=(a,c)=>{let l=n(a);return l!==en?l:i(a,c)}}}s(gB,"installCompiledUserMethods");function Lp(e,t){let n=!0;try{n=Rp(e)}catch{}if(n)throw new we("a schema whose subtree contains a reference cycle");let r={constants:new Map,constantCounter:0,varCounter:0,definite:!0},o=new ci(["input"]),i=Je(o,r,e,"input",!t?.assertOnly);o.write(i===null?"return true;":`return ${i};`);let a=["INVALID",...r.constants.keys()],c=[en,...r.constants.values()],l=o.content.join(`
|
|
63
|
+
`),u=t?.debug?a.length>0?`// Constants: ${a.join(", ")}
|
|
64
|
+
${l}`:l:"",f=Function,d=`return (input) => {
|
|
65
|
+
${l}
|
|
66
|
+
}`,p;try{p=new f(...a,d)(...c)}catch(m){throw new we(`this schema (generated code failed to evaluate: ${m.message})`)}return t?.debug&&(p.code=u),p.definite=r.definite,p}s(Lp,"compileFn");function ne(e,t){for(let[r,o]of e.constants)if(o===t)return r;let n=`c${e.constantCounter++}`;return e.constants.set(n,t),n}s(ne,"addConstant");function fi(e,t){return e.definite=!1,ne(e,t)}s(fi,"addUserConstant");function Y(e){return`v${e.varCounter++}`}s(Y,"newVar");function xB(e,t){let n=e._zod.run({value:t,issues:[]},{});if(n&&typeof n.then=="function")return en;let r=n;return r.issues.length===0?r.value:en}s(xB,"runtimeRun");function qt(e,t,n,r,o=!0){let i=e.content.length,a=t.constants.size,c=t.constantCounter,l=t.varCounter;try{return Je(e,t,n,r,o)}catch(u){if(!(u instanceof we)||!u.islandable)throw u;if(e.content.length=i,t.constants.size>a){let f=Array.from(t.constants.keys()).slice(a);for(let d of f)t.constants.delete(d)}return t.constantCounter=c,t.varCounter=l,yB(e,t,n,r)}}s(qt,"compileChild");function yB(e,t,n,r){t.definite=!1;let o=ne(t,n),i=ne(t,xB),a=Y(t);return e.write(`const ${a} = ${i}(${o}, ${r});`),e.write(`if (${a} === INVALID) return INVALID;`),a}s(yB,"emitRuntimeIsland");var SB=new Set(["max_size","min_size","size_equals","max_length","min_length","length_equals"]);function bB(e,t,n,r){let o=n._zod.def.checks;if(!o||o.length===0)return r;let i=r;for(let a of o){let c=a._zod.def;if(c.when&&!SB.has(c.check))throw new we('check with a custom "when" condition');switch(c.check){case"greater_than":vB(e,t,c,i);break;case"less_than":_B(e,t,c,i);break;case"multiple_of":wB(e,t,c,i);break;case"number_format":JO(e,c,i);break;case"min_length":{let l=ps(c.minimum,"min_length"),u=wv(e,t,i,`${i}.length >= ${l} && ${i}.length < ${c.minimum*2}`);e.write(`if (${u} < ${l}) return INVALID;`);break}case"max_length":{let l=ps(c.maximum,"max_length"),u=wv(e,t,i,`${i}.length > ${l}`);e.write(`if (${u} > ${l}) return INVALID;`);break}case"length_equals":{let l=ps(c.length,"length_equals"),u=wv(e,t,i,`${i}.length >= ${l} && ${i}.length <= ${c.length*2}`);e.write(`if (${u} !== ${l}) return INVALID;`);break}case"min_size":e.write(`if (${i}.size < ${ps(c.minimum,"min_size")}) return INVALID;`);break;case"max_size":e.write(`if (${i}.size > ${ps(c.maximum,"max_size")}) return INVALID;`);break;case"size_equals":e.write(`if (${i}.size !== ${ps(c.size,"size_equals")}) return INVALID;`);break;case"string_format":i=WO(e,t,c,i);break;case"custom":i=CB(e,t,a,i);break;case"bigint_format":EB(e,c,i);break;case"mime_type":IB(e,t,c,i);break;case"property":kB(e,t,c,i);break;case"properties":TB(e,t,c,i);break;case"overwrite":{let l=Y(t);AB(e,t,a,i,l),i=l;break}default:throw new we(`check type ${c.check}`)}}return i}s(bB,"generateChecks");function wv(e,t,n,r){let o=ne(t,ii),i=Y(t);return e.write(`const ${i} = typeof ${n} === "string" && ${r} ? ${o}(${n}) : ${n}.length;`),i}s(wv,"codePointLengthVar");function ps(e,t){if(typeof e!="number"||!Number.isFinite(e))throw new we(`${t} bound of type ${typeof e}`);return`${e}`}s(ps,"numericOperand");function KO(e,t){if(typeof t=="bigint")return`${t}n`;if(typeof t=="number"){if(Number.isNaN(t))throw new we("comparison check with NaN bound");return`${t}`}if(t instanceof Date){if(Number.isNaN(t.getTime()))throw new we("comparison check with Invalid Date bound");return ne(e,t)}throw new we(`comparison check bound of type ${typeof t}`)}s(KO,"comparisonOperand");function vB(e,t,n,r){let o=n.inclusive?"<":"<=";e.write(`if (${r} ${o} ${KO(t,n.value)}) return INVALID;`)}s(vB,"generateGreaterThanCheck");function _B(e,t,n,r){let o=n.inclusive?">":">=";e.write(`if (${r} ${o} ${KO(t,n.value)}) return INVALID;`)}s(_B,"generateLessThanCheck");function wB(e,t,n,r){if(typeof n.value=="bigint"){if(n.value===BigInt(0))throw new we("multiple_of check with a zero divisor");e.write(`if (${r} % ${n.value}n !== 0n) return INVALID;`)}else{let o=ne(t,zu);e.write(`if (${o}(${r}, ${ps(n.value,"multiple_of")}) !== 0) return INVALID;`)}}s(wB,"generateMultipleOfCheck");function JO(e,t,n){let r=t.format;switch(r){case"safeint":e.write(`if (!Number.isSafeInteger(${n})) return INVALID;`);break;case"int32":e.write(`if (!Number.isInteger(${n}) || ${n} < -2147483648 || ${n} > 2147483647) return INVALID;`);break;case"uint32":e.write(`if (!Number.isInteger(${n}) || ${n} < 0 || ${n} > 4294967295) return INVALID;`);break;case"float32":e.write(`if (!Number.isFinite(${n}) || ${n} < -3.4028234663852886e38 || ${n} > 3.4028234663852886e38) return INVALID;`);break;case"float64":e.write(`if (!Number.isFinite(${n})) return INVALID;`);break;default:throw new we(`number format ${r}`)}}s(JO,"generateNumberFormatCheck");function EB(e,t,n){let r=t.format;if(r)switch(r){case"int64":e.write(`if (${n} < -9223372036854775808n || ${n} > 9223372036854775807n) return INVALID;`);break;case"uint64":e.write(`if (${n} < 0n || ${n} > 18446744073709551615n) return INVALID;`);break;default:throw new we(`bigint format ${r}`)}}s(EB,"generateBigIntFormatCheck");function IB(e,t,n,r){let o=n.mime;if(o&&o.length>0){let i=ne(t,new Set(o));e.write(`if (!${i}.has(${r}.type)) return INVALID;`)}}s(IB,"generateMimeTypeCheck");function TB(e,t,n,r){if(n.when)throw new we('check with a custom "when" condition');e.write(`if (${r} == null) return INVALID;`);let o=n.shape;for(let i of Reflect.ownKeys(o)){let a=typeof i=="symbol"?ne(t,i):Xt(i),c=Y(t);e.write(`const ${c} = ${r}[${a}];`),qt(e,t,o[i],c,!1)}}s(TB,"generatePropertiesChecks");function kB(e,t,n,r){let o=`${r}[${JSON.stringify(n.property)}]`;Je(e,t,n.schema,o)}s(kB,"generatePropertyCheck");function AB(e,t,n,r,o){let i=n._zod.def.tx;if(!i)throw new we("overwrite check without a transform function");if(di(i))throw new gr("z.compile: async overwrite transforms are not supported");let a=ne(t,i);e.write(`const ${o} = ${a}(${r});`)}s(AB,"generateOverwriteCheck");function Ev(){throw new gn}s(Ev,"throwAsync");function kv(e){this.issues.push(e)}s(kv,"pushIssue");function CB(e,t,n,r){let o=n._zod.def;if(o.fn){if(di(o.fn))throw new gr("z.compile: async .refine() predicates are not supported");let i=fi(t,o.fn),a=ne(t,Ev),c=Y(t);return e.write(`const ${c} = ${i}(${r});`),e.write(`if (${c} instanceof Promise) ${a}();`),e.write(`if (!${c}) return INVALID;`),r}if(n._zod.check){if(di(n._zod.check))throw new gr("z.compile: async .superRefine() / check functions are not supported");let i=n._zod.check,c=fi(t,s(u=>{let f={value:u,issues:[],addIssue:kv};return i(f)instanceof Promise&&Ev(),f.issues.length===0?f.value:en},"helperFn")),l=Y(t);return e.write(`const ${l} = ${c}(${r});`),e.write(`if (${l} === INVALID) return INVALID;`),l}throw new we("custom check without a predicate or check function")}s(CB,"generateCustomRefineCheck");var OB=new Set(["cidrv4","cuid","cuid2","date","datetime","duration","e164","email","emoji","ends_with","guid","includes","ipv4","ksuid","lowercase","mac","nanoid","regex","starts_with","time","ulid","uppercase","uuid","xid"]);function WO(e,t,n,r,o=!0){let i=n.format;if(i==="base64"){let u=ne(t,ol);return e.write(`if (!${u}(${r})) return INVALID;`),r}if(i==="base64url"){let u=ne(t,yp);return e.write(`if (!${u}(${r})) return INVALID;`),r}if(i==="jwt"){let u=ne(t,vp),f=ne(t,n.alg??null);return e.write(`if (!${u}(${r}, ${f})) return INVALID;`),r}if(i==="ipv6"){let u=ne(t,rl);return e.write(`if (!${u}(${r})) return INVALID;`),r}if(i==="cidrv6"){let u=ne(t,gp);return e.write(`if (!${u}(${r})) return INVALID;`),r}if(i==="credit_card"){let u=ne(t,Sp);return e.write(`if (!${u}(${r})) return INVALID;`),r}if(i==="iban"){let u=ne(t,bp);return e.write(`if (!${u}(${r})) return INVALID;`),r}let a=n;if(i==="url"||i==="httpurl"||a.normalize||a.hostname!==void 0||a.protocol!==void 0){let u=ne(t,pp),f=ne(t,n),d=Y(t),p=Y(t);if(e.write(`const ${d} = ${r}.trim();`),e.write(`const ${p} = ${u}(${d}, ${f});`),e.write(`if (typeof ${p} === "number") return INVALID;`),a.hostname!==void 0){let x=ne(t,mp);e.write(`if (!${x}(${p}, ${f}.hostname)) return INVALID;`)}if(a.protocol!==void 0){let x=ne(t,hp);e.write(`if (!${x}(${p}, ${f}.protocol)) return INVALID;`)}if(!o)return null;let m=Y(t),h=a.normalize?`${p}.href`:`${ne(t,nl)}(${d})`;return e.write(`const ${m} = ${h};`),m}let c=n.fn;if(c){if(di(c))throw new we(`async string format ${i}`);let u=ne(t,c);return e.write(`if (!${u}(${r})) return INVALID;`),r}if(OB.has(i)&&n.pattern){let u=ne(t,n.pattern);return e.write(`${u}.lastIndex = 0;`),e.write(`if (!${u}.test(${r})) return INVALID;`),r}let l=n.format;switch(l){case"regex":throw new we("regex format without a pattern");case"lowercase":e.write(`if (${r} !== ${r}.toLowerCase()) return INVALID;`);break;case"uppercase":e.write(`if (${r} !== ${r}.toUpperCase()) return INVALID;`);break;case"includes":e.write(`if (!${r}.includes(${Xt(n.includes)})) return INVALID;`);break;case"starts_with":{let u=n.prefix;e.write(`if (${r}.slice(0, ${u.length}) !== ${Xt(u)}) return INVALID;`);break}case"ends_with":{let u=n.suffix;e.write(`if (${r}.slice(-${u.length}) !== ${Xt(u)}) return INVALID;`);break}default:throw new we(`string format ${l}`)}return r}s(WO,"generateStringFormatCheck");function Je(e,t,n,r,o=!0){let i=n._zod.def,a=i.type;if(i.coerce)throw new we(`coercion (z.coerce.${a}())`);let c=o||!!i.checks?.length,l;switch(a){case"string":l=RB(e,t,n,r,c);break;case"number":l=$B(e,n,r);break;case"boolean":l=PB(e,r);break;case"bigint":l=NB(e,n,r);break;case"symbol":l=DB(e,r);break;case"undefined":l=LB(e,r);break;case"null":l=FB(e,r);break;case"any":case"unknown":l=r;break;case"never":e.write("return INVALID;"),l=r;break;case"void":l=zB(e,r);break;case"nan":l=MB(e,r);break;case"date":l=UB(e,r);break;case"object":l=GB(e,t,n,r,c);break;case"optional":l=jB(e,t,n,r,c);break;case"nullable":l=BB(e,t,n,r,c);break;case"array":l=VB(e,t,n,r,c);break;case"literal":l=HB(e,t,n,r);break;case"enum":l=KB(e,t,n,r);break;case"readonly":{let u=BO(e,t,n,r),f=Y(t);e.write(`const ${f} = Object.freeze(${u});`),l=f;break}case"success":BO(e,t,n,r),l="true";break;case"default":case"prefault":l=JB(e,t,n,r);break;case"nonoptional":l=WB(e,t,n,r);break;case"tuple":l=YB(e,t,n,r);break;case"union":l=XB(e,t,n,r);break;case"intersection":l=t4(e,t,n,r);break;case"record":l=n4(e,t,n,r);break;case"map":l=o4(e,t,n,r);break;case"set":l=s4(e,t,n,r);break;case"file":l=i4(e,r);break;case"template_literal":l=a4(e,t,n,r);break;case"lazy":l=c4(e,t,n,r);break;case"pipe":l=u4(e,t,n,r);break;case"custom":l=l4(e,t,n,r);break;case"transform":l=p4(e,t,n,r);break;case"catch":l=d4(e,t,n,r);break;default:throw new we(`schema type ${a}`)}return l===null?null:bB(e,t,n,l)}s(Je,"generateCheck");function RB(e,t,n,r,o=!0){e.write(`if (typeof ${r} !== "string") return INVALID;`);let i=n._zod.def;return i.format===void 0?r:WO(e,t,i,r,o)}s(RB,"generateStringCheck");function $B(e,t,n){e.write(`if (typeof ${n} !== "number" || !Number.isFinite(${n})) return INVALID;`);let r=t._zod.def;return r.check==="number_format"&&r.format&&JO(e,{format:r.format},n),n}s($B,"generateNumberCheck");function PB(e,t){return e.write(`if (typeof ${t} !== "boolean") return INVALID;`),t}s(PB,"generateBooleanCheck");function NB(e,t,n){e.write(`if (typeof ${n} !== "bigint") return INVALID;`);let r=t._zod.def;if(r.format)switch(r.format){case"int64":e.write(`if (${n} < -9223372036854775808n || ${n} > 9223372036854775807n) return INVALID;`);break;case"uint64":e.write(`if (${n} < 0n || ${n} > 18446744073709551615n) return INVALID;`);break}return n}s(NB,"generateBigIntCheck");function DB(e,t){return e.write(`if (typeof ${t} !== "symbol") return INVALID;`),t}s(DB,"generateSymbolCheck");function LB(e,t){return e.write(`if (${t} !== undefined) return INVALID;`),t}s(LB,"generateUndefinedCheck");function FB(e,t){return e.write(`if (${t} !== null) return INVALID;`),t}s(FB,"generateNullCheck");function zB(e,t){return e.write(`if (${t} !== undefined) return INVALID;`),t}s(zB,"generateVoidCheck");function MB(e,t){return e.write(`if (typeof ${t} !== "number" || !Number.isNaN(${t})) return INVALID;`),t}s(MB,"generateNaNCheck");function UB(e,t){return e.write(`if (!(${t} instanceof Date) || Number.isNaN(${t}.getTime())) return INVALID;`),t}s(UB,"generateDateCheck");function GB(e,t,n,r,o=!0){let i=n._zod.def;e.write(`if (typeof ${r} !== "object" || ${r} === null || Array.isArray(${r})) return INVALID;`);let a=i.shape,c=Object.keys(a),l=Object.getOwnPropertySymbols(a),u=l.length?[...c,...l]:c,f=s(b=>typeof b=="symbol"?ne(t,b):Xt(b),"keyExpr"),d=s(b=>typeof b=="symbol"?`[${f(b)}]`:Xt(b),"propKey"),p=a;if(c.includes("__proto__"))throw new we('object shape key "__proto__"');let m=new Map;for(let b of u){let v=p[b],C=f(b),w=Y(t);if(e.write(`const ${w} = ${r}[${C}];`),v._zod.optin!==void 0){let I=Y(t);e.write(`let ${I} = (() => {`),e.indented(A=>{let O=qt(A,t,v,w);A.write(`return ${O};`)}),e.write("})();"),v._zod.optout==="optional"?(e.write(`if (${I} === INVALID) {`),e.indented(A=>{A.write(`if (${C} in ${r}) return INVALID;`),A.write(`${I} = undefined;`)}),e.write("}")):e.write(`if (${I} === INVALID) return INVALID;`),m.set(b,I)}else{qB(v)&&e.write(`if (!(${C} in ${r})) return INVALID;`);let I=qt(e,t,v,w,o);I!==null&&m.set(b,I)}}let h=i.catchall,x="none";if(h){let b=h._zod.def.type;if(b==="never"){let v=c.map(C=>`k !== ${Xt(C)}`).join(" && ")||"true";e.write(`for (const k in ${r}) {`),e.indented(C=>{C.write(`if (${v}) return INVALID;`)}),e.write("}")}else(b==="unknown"||b==="any")&&!h._zod.def.checks?.length?x="passthrough":x="schema"}let S=Y(t),T=u.some(b=>qO(p[b])||Iv(p[b]));if(!o){if(x==="schema"){let b=c.length>0?ne(t,new Set(c)):null;e.write(`for (const k in ${r}) {`),e.indented(v=>{v.write('if (k === "__proto__") continue;'),b&&v.write(`if (${b}.has(k)) continue;`);let C=Y(t);v.write(`const ${C} = ${r}[k];`),qt(v,t,h,C,!1)}),e.write("}")}return null}if(T){e.write(`const ${S} = {};`);for(let b of u){let v=f(b),C=m.get(b);Iv(p[b])?e.write(`if (${v} in ${r}) ${S}[${v}] = ${C};`):qO(p[b])?e.write(`if (${C} !== undefined || ${v} in ${r}) ${S}[${v}] = ${C};`):e.write(`${S}[${v}] = ${C};`)}}else{let b=u.map(v=>`${d(v)}: ${m.get(v)}`).join(", ");e.write(`const ${S} = { ${b} };`)}if(x!=="none"){let b=c.length>0?ne(t,new Set(c)):null;e.write(`for (const k in ${r}) {`),e.indented(v=>{if(v.write('if (k === "__proto__") continue;'),b&&v.write(`if (${b}.has(k)) continue;`),x==="passthrough")v.write(`${S}[k] = ${r}[k];`);else{let C=Y(t);v.write(`const ${C} = ${r}[k];`);let w=qt(v,t,h,C);v.write(`${S}[k] = ${w};`)}}),e.write("}")}return S}s(GB,"generateObjectCheck");function jB(e,t,n,r,o=!0){let i=n._zod.def;if(ZB(n))return Je(e,t,i.innerType,r,o);if(i.innerType._zod.optin==="defaulted"){let c=Y(t),l=Y(t);return e.write(`let ${c};`),e.write(`if (${r} === undefined) {`),e.indented(u=>{u.write(`const ${l} = (() => {`),u.indented(f=>{let d=Je(f,t,i.innerType,r);f.write(`return ${d};`)}),u.write("})();"),u.write(`if (${l} !== INVALID) ${c} = ${l};`)}),e.write("} else {"),e.indented(u=>{let f=Je(u,t,i.innerType,r);u.write(`${c} = ${f};`)}),e.write("}"),c}let a=o?Y(t):null;return a&&e.write(`let ${a};`),e.write(`if (${r} !== undefined) {`),e.indented(c=>{let l=Je(c,t,i.innerType,r,o);a&&l!==null&&c.write(`${a} = ${l};`)}),e.write("}"),a}s(jB,"generateOptionalCheck");function ZB(e){return e._zod.traits?.has("$ZodExactOptional")===!0}s(ZB,"isExactOptional");function qB(e){return e._zod.optin===void 0&&li(e)}s(qB,"requiresPresenceCheck");function li(e){if(e._zod.def.coerce)return!0;let t=e._zod.def;switch(t.type){case"any":case"unknown":case"undefined":case"void":case"default":case"prefault":case"transform":case"custom":case"lazy":return!0;case"string":case"number":case"boolean":case"bigint":case"symbol":case"null":case"never":case"nan":case"date":case"object":case"array":case"tuple":case"record":case"map":case"set":case"file":case"template_literal":return!1;case"nonoptional":return t.innerType?li(t.innerType):!1;case"literal":return!!t.values?.includes(void 0);case"enum":return!!e._zod.values?.has(void 0);case"optional":case"nullable":case"readonly":case"success":return t.innerType?li(t.innerType):!0;case"catch":return!0;case"union":return t.options?t.options.some(li):!0;case"intersection":return!t.left||!t.right?!0:li(t.left)&&li(t.right);case"pipe":return t.in?li(t.in):!0;default:return!0}}s(li,"fastPathAcceptsAbsence");function Iv(e){return e._zod.optin==="optional"&&e._zod.optout==="optional"}s(Iv,"dropsWhenAbsent");function qO(e){return(e._zod.optin!=="defaulted"||e._zod.optout==="optional")&&Ba(e)}s(qO,"mayOmitUndefined");function Ba(e){let t=e._zod.def;switch(t.type){case"string":case"number":case"boolean":case"bigint":case"symbol":case"null":case"nan":case"date":case"object":case"array":case"tuple":case"record":case"map":case"set":case"file":case"template_literal":case"never":case"success":return!1;case"literal":return!!t.values?.includes(void 0);case"enum":return!!e._zod.values?.has(void 0);case"optional":return!0;case"nullable":case"readonly":case"nonoptional":return t.innerType?Ba(t.innerType):!0;case"union":return t.options?t.options.some(Ba):!0;case"intersection":return!t.left||!t.right||Ba(t.left)||Ba(t.right);case"pipe":return t.out?Ba(t.out):!0;default:return!0}}s(Ba,"mayOutputUndefined");function BB(e,t,n,r,o=!0){let i=n._zod.def,a=o?Y(t):null;return a&&e.write(`let ${a} = null;`),e.write(`if (${r} !== null) {`),e.indented(c=>{let l=Je(c,t,i.innerType,r,o);a&&l!==null&&c.write(`${a} = ${l};`)}),e.write("}"),a}s(BB,"generateNullableCheck");function Av(e,t,n){for(let[r,o]of La(t._zod.def.checks))e.write(`if (${n} > ${ps(r,o._zod.def.check)}) return INVALID;`)}s(Av,"generateSizeGate");function VB(e,t,n,r,o=!0){let i=n._zod.def;e.write(`if (!Array.isArray(${r})) return INVALID;`),Av(e,n,`${r}.length`);let a=o?Y(t):null,c=Y(t),l=Y(t);return a&&e.write(`const ${a} = new Array(${r}.length);`),e.write(`for (let ${c} = 0; ${c} < ${r}.length; ${c}++) {`),e.indented(u=>{u.write(`const ${l} = ${r}[${c}];`);let f=qt(u,t,i.element,l,o);a&&f!==null&&u.write(`${a}[${c}] = ${f};`)}),e.write("}"),a}s(VB,"generateArrayCheck");function HB(e,t,n,r){let i=n._zod.def.values;if(i.length!==1){let c=ne(t,new Set(i));return e.write(`if (!${c}.has(${r})) return INVALID;`),r}let a=i[0];if(typeof a=="number"&&Number.isNaN(a)){let c=ne(t,new Set(i));return e.write(`if (!${c}.has(${r})) return INVALID;`),r}if(typeof a=="string")e.write(`if (${r} !== ${Xt(a)}) return INVALID;`);else if(typeof a=="number"||typeof a=="boolean")e.write(`if (${r} !== ${a}) return INVALID;`);else if(a===null)e.write(`if (${r} !== null) return INVALID;`);else if(a===void 0)e.write(`if (${r} !== undefined) return INVALID;`);else if(typeof a=="bigint")e.write(`if (${r} !== ${a}n) return INVALID;`);else throw new we(`literal type ${typeof a}`);return r}s(HB,"generateLiteralCheck");function KB(e,t,n,r){let o=n._zod.values;if(!o)throw new we("enum schema without enumerated values");let i=ne(t,o);return e.write(`if (!${i}.has(${r})) return INVALID;`),r}s(KB,"generateEnumCheck");function BO(e,t,n,r){let o=n._zod.def;return Je(e,t,o.innerType,r)}s(BO,"generateWrapperCheck");function JB(e,t,n,r){let o=n._zod.def,a=Object.getOwnPropertyDescriptor(n._zod.def,"defaultValue")?()=>n._zod.def.defaultValue:void 0;if(n._zod.def.type==="prefault"){if(!a)return Je(e,t,o.innerType,r);let l=ne(t,a),u=Y(t);return e.write(`let ${u} = ${r};`),e.write(`if (${r} === undefined) ${u} = ${l}();`),Je(e,t,o.innerType,u)}let c=Y(t);if(a){let l=ne(t,a),u=ne(t,Mu);e.write(`let ${c};`),e.write(`if (${r} === undefined) {`),e.indented(f=>{f.write(`${c} = ${u}(${l}());`)}),e.write("} else {"),e.indented(f=>{let d=Je(f,t,o.innerType,r);f.write(`${c} = ${d} === undefined ? ${u}(${l}()) : ${d};`)}),e.write("}")}else e.write(`let ${c};`),e.write(`if (${r} !== undefined) {`),e.indented(l=>{let u=Je(l,t,o.innerType,r);l.write(`${c} = ${u};`)}),e.write("}");return c}s(JB,"generateDefaultCheck");function WB(e,t,n,r){let o=n._zod.def,i=Je(e,t,o.innerType,r),a=Y(t);return e.write(`const ${a} = ${i};`),e.write(`if (${a} === undefined) return INVALID;`),a}s(WB,"generateNonOptionalCheck");function YB(e,t,n,r){let o=n._zod.def,i=o.items,a=o.rest;e.write(`if (!Array.isArray(${r})) return INVALID;`);let c=VO(i,"optin"),l=VO(i,"optout");a?e.write(`if (${r}.length < ${c}) return INVALID;`):e.write(`if (${r}.length < ${c} || ${r}.length > ${i.length}) return INVALID;`);let u=Y(t);e.write(`const ${u} = [];`);for(let f=0;f<i.length;f++){let d=i[f];if(f>=l)e.write(`if (${u}.length === ${f}) {`),e.indented(p=>{p.write(`if (${f} < ${r}.length) {`),p.indented(m=>{let h=Y(t);m.write(`const ${h} = ${r}[${f}];`);let x=qt(m,t,d,h);m.write(`${u}[${f}] = ${x};`)}),p.write("} else {"),p.indented(m=>{if(Iv(d)){m.write(`${u}.length = ${f};`);return}let h=Y(t),x=Y(t);m.write(`const ${h} = undefined;`),m.write(`const ${x} = (() => {`),m.indented(S=>{let T=qt(S,t,d,h);S.write(`return ${T};`)}),m.write("})();"),m.write(`if (${x} === INVALID || ${x} === undefined) ${u}.length = ${f};`),m.write(`else ${u}[${f}] = ${x};`)}),p.write("}")}),e.write("}");else{let p=Y(t);e.write(`const ${p} = ${r}[${f}];`);let m=qt(e,t,d,p);e.write(`${u}[${f}] = ${m};`)}}if(a){let f=Y(t),d=Y(t);e.write(`for (let ${f} = ${i.length}; ${f} < ${r}.length; ${f}++) {`),e.indented(p=>{p.write(`const ${d} = ${r}[${f}];`);let m=qt(p,t,a,d);p.write(`${u}[${f}] = ${m};`)}),e.write("}")}return u}s(YB,"generateTupleCheck");function VO(e,t){for(let n=e.length-1;n>=0;n--)if(!(t==="optin"?e[n]._zod.optin!==void 0:e[n]._zod.optout==="optional"))return n+1;return 0}s(VO,"getTupleOptStart");function XB(e,t,n,r){let o=n._zod.def,i=o.options;if(o.discriminator)return QB(e,t,o,r);if(o.inclusive===!1)throw new we("exclusive unions (z.xor)");if(i.length===0)return e.write("return INVALID;"),r;if(i.length===1)return Je(e,t,i[0],r);if(i.every(l=>l._zod.def.type==="literal"&&!l._zod.def.checks?.length)){let l=new Set(i.flatMap(f=>f._zod.def.values)),u=ne(t,l);return e.write(`if (!${u}.has(${r})) return INVALID;`),r}let c=Y(t);e.write(`let ${c};`);for(let l=0;l<i.length;l++){let u=i[l];l===0?e.write(`${c} = (() => {`):e.write(`if (${c} === INVALID) ${c} = (() => {`),e.indented(f=>{let d=Je(f,t,u,r);f.write(`return ${d};`)}),e.write("})();")}return e.write(`if (${c} === INVALID) return INVALID;`),c}s(XB,"generateUnionCheck");function QB(e,t,n,r){if(n.unionFallback)throw new we("discriminated union with unionFallback");if(n.options.length===0)return e.write("return INVALID;"),r;let o=Y(t),i=Y(t);e.write(`const ${o} = ${r}?.[${Xt(n.discriminator)}];`),e.write(`let ${i};`);let a=!0,c=new Set;for(let l of n.options){let u=l._zod.propValues?.[n.discriminator];if(!u||u.size===0)throw new we("discriminated union option without static discriminator values");for(let p of u){if(c.has(p))throw new we(`duplicate discriminator value ${String(p)}`);c.add(p)}let f=Array.from(u,p=>e4(t,o,p)),d=a?"if":"else if";e.write(`${d} (${f.join(" || ")}) {`),e.indented(p=>{let m=Je(p,t,l,r);p.write(`${i} = ${m};`)}),e.write("}"),a=!1}return e.write("else { return INVALID; }"),i}s(QB,"generateDiscriminatedUnionCheck");function e4(e,t,n){if(typeof n=="string")return`${t} === ${Xt(n)}`;if(typeof n=="number")return Number.isNaN(n)?`Number.isNaN(${t})`:`${t} === ${n}`;if(typeof n=="boolean")return`${t} === ${n}`;if(n===null)return`${t} === null`;if(n===void 0)return`${t} === undefined`;if(typeof n=="bigint")return`${t} === ${n}n`;if(typeof n=="symbol"){let r=ne(e,n);return`${t} === ${r}`}throw new we(`literal discriminator value ${String(n)}`)}s(e4,"literalEquality");function t4(e,t,n,r){let o=n._zod.def;t.definite=!1;let i=qt(e,t,o.left,r),a=qt(e,t,o.right,r),c=ne(t,Za),l=Y(t);return e.write(`const ${l} = ${c}(${i}, ${a});`),e.write(`if (!${l}.valid) return INVALID;`),`${l}.data`}s(t4,"generateIntersectionCheck");function n4(e,t,n,r){let o=n._zod.def,i=ne(t,Kn);e.write(`if (!${i}(${r})) return INVALID;`);let a=Y(t),c=Y(t),l=Y(t);e.write(`const ${a} = {};`);let u=o,f=u.partial?void 0:o.keyType._zod.values;if(f){let m=[];for(let x of f){if(!(typeof x=="string"||typeof x=="number"||typeof x=="symbol"))throw new we(`record key value ${String(x)}`);let S=typeof x=="number"?x.toString():x;if(S==="__proto__")throw new we('record key "__proto__"');m.push(S);let T=ne(t,x),b=Je(e,t,o.keyType,T),v=Y(t);e.write(`const ${v} = ${r}[${r4(t,S)}];`);let C=qt(e,t,o.valueType,v);e.write(`${a}[${b}] = ${C};`)}let h=ne(t,new Set(m));return e.write(`for (const ${c} in ${r}) {`),e.indented(x=>{x.write(`if (${h}.has(${c})) continue;`),u.mode==="loose"?x.write(`if (${c} !== "__proto__") ${a}[${c}] = ${r}[${c}];`):x.write("return INVALID;")}),e.write("}"),a}let d=o.keyType._zod.def;if(!(d.type==="string"&&d.format===void 0&&!d.coerce&&(d.checks?.length??0)===0)){let m=o.mode==="loose",h=Lp(o.keyType);h.definite===!1&&(t.definite=!1);let x=ne(t,h),S=ne(t,_o),T=Y(t);return HO(e,t,r,c,b=>{b.write(`let ${T} = ${x}(${c});`),b.write(`if (${T} === INVALID && typeof ${c} === "string" && ${S}.test(${c})) ${T} = ${x}(Number(${c}));`),m?b.write(`if (${T} === INVALID) { ${a}[${c}] = ${r}[${c}]; continue; }`):b.write(`if (${T} === INVALID) return INVALID;`),b.write(`if (${T} === "__proto__") continue;`);let v=Y(t);b.write(`const ${v} = ${r}[${c}];`);let C=qt(b,t,o.valueType,v);b.write(`${a}[${T}] = ${C};`)}),a}return HO(e,t,r,c,m=>{m.write(`const ${l} = ${r}[${c}];`);let h=qt(m,t,o.valueType,l);m.write(`${a}[${c}] = ${h};`)},"return INVALID;"),a}s(n4,"generateRecordCheck");function HO(e,t,n,r,o,i){let a=ne(t,Object.prototype.propertyIsEnumerable),c=Y(t),l=Y(t),u=Y(t);e.write(`const ${c} = Object.getOwnPropertySymbols(${n});`),e.write(`const ${l} = Object.getOwnPropertyNames(${n});`),e.write(`for (let ${u} = 0; ${u} < ${l}.length; ${u}++) {`),e.indented(f=>{f.write(`const ${r} = ${l}[${u}];`),f.write(`if (${r} === "__proto__" || !${a}.call(${n}, ${r})) continue;`),o(f)}),e.write("}"),e.write(`for (let ${u} = 0; ${u} < ${c}.length; ${u}++) {`),e.indented(f=>{f.write(`const ${r} = ${c}[${u}];`),f.write(`if (!${a}.call(${n}, ${r})) continue;`),i?f.write(i):o(f)}),e.write("}")}s(HO,"emitOwnKeys");function r4(e,t){return typeof t=="string"?Xt(t):ne(e,t)}s(r4,"literalPropertyKey");function o4(e,t,n,r){let o=n._zod.def;e.write(`if (!(${r} instanceof Map)) return INVALID;`),Av(e,n,`${r}.size`);let i=Y(t),a=Y(t),c=Y(t);return e.write(`const ${i} = new Map();`),e.write(`for (const [${a}, ${c}] of ${r}) {`),e.indented(l=>{let u=Je(l,t,o.keyType,a),f=Je(l,t,o.valueType,c);l.write(`${i}.set(${u}, ${f});`)}),e.write("}"),i}s(o4,"generateMapCheck");function s4(e,t,n,r){let o=n._zod.def;e.write(`if (!(${r} instanceof Set)) return INVALID;`),Av(e,n,`${r}.size`);let i=Y(t),a=Y(t);return e.write(`const ${i} = new Set();`),e.write(`for (const ${a} of ${r}) {`),e.indented(c=>{let l=Je(c,t,o.valueType,a);c.write(`${i}.add(${l});`)}),e.write("}"),i}s(s4,"generateSetCheck");function i4(e,t){return e.write(`if (!(${t} instanceof File)) return INVALID;`),t}s(i4,"generateFileCheck");function a4(e,t,n,r){e.write(`if (typeof ${r} !== "string") return INVALID;`);let o=n._zod.pattern;if(o){let i=ne(t,o);e.write(`${i}.lastIndex = 0;`),e.write(`if (!${i}.test(${r})) return INVALID;`)}return r}s(a4,"generateTemplateLiteralCheck");function c4(e,t,n,r){let o=n._zod.def,i=fi(t,o.getter),a=ne(t,{parser:null});e.write(`if (!${a}.parser) {`),e.indented(l=>{l.write(`const inner = ${i}();`),l.write(`${a}.parser = function(input) {`),l.indented(u=>{u.write("const result = inner._zod.run({ value: input, issues: [] }, {});"),u.write("return result.issues.length === 0 ? result.value : INVALID;")}),l.write("};")}),e.write("}");let c=Y(t);return e.write(`const ${c} = ${a}.parser(${r});`),e.write(`if (${c} === INVALID) return INVALID;`),c}s(c4,"generateLazyCheck");function u4(e,t,n,r){let o=n._zod.def,i=Je(e,t,o.in,r);if(o.transform){if(di(o.transform))throw new gr("z.compile: async transforms in pipes are not supported");let a=o.transform,l=fi(t,s(f=>{let d={value:f,issues:[],addIssue:kv},p=a(f,d);return p instanceof Promise?en:d.issues.length===0?p:en},"helperFn")),u=Y(t);return e.write(`const ${u} = ${l}(${i});`),e.write(`if (${u} === INVALID) return INVALID;`),Je(e,t,o.out,u)}else return Je(e,t,o.out,i)}s(u4,"generatePipeCheck");function di(e){return typeof e=="function"&&(e.constructor.name==="AsyncFunction"||e[Symbol.toStringTag]==="AsyncFunction")}s(di,"isAsyncFunction");function l4(e,t,n,r){let o=n._zod.def;if(o.fn){if(di(o.fn))throw new gr("z.compile: async custom predicates are not supported");let i=fi(t,o.fn),a=ne(t,Ev),c=Y(t);e.write(`const ${c} = ${i}(${r});`),e.write(`if (${c} instanceof Promise) ${a}();`),e.write(`if (!${c}) return INVALID;`)}else throw new we("custom schema without a predicate function");return r}s(l4,"generateCustomCheck");function f4(e,t,n){let r=e._zod.run({value:n,issues:[]},{});if(r&&typeof r.then=="function")return en;let o=r;return o.issues.length===0?o.value:t()}s(f4,"runtimeCatch");function d4(e,t,n,r){let o=n._zod.def;if(!o.catchValue[qd])throw new we("catch with a callback (only a constant catch value compiles)",!1);let i=Y(t);e.write(`let ${i} = (() => {`),e.indented(u=>{let f=qt(u,t,o.innerType,r);u.write(`return ${f};`)}),e.write("})();");let a=ne(t,o.innerType),c=fi(t,o.catchValue),l=ne(t,f4);return e.write(`if (${i} === INVALID) {`),e.indented(u=>{u.write(`${i} = ${l}(${a}, ${c}, ${r});`),u.write(`if (${i} === INVALID) return INVALID;`)}),e.write("}"),i}s(d4,"generateCatchCheck");function p4(e,t,n,r){let o=n._zod.def;if(o.transform){if(di(o.transform))throw new gr("z.compile: async transforms are not supported");let i=o.transform,c=fi(t,s(u=>{let f={value:u,issues:[],addIssue:kv},d=i(u,f);return d instanceof Promise?en:f.issues.length===0?d:en},"helperFn")),l=Y(t);return e.write(`const ${l} = ${c}(${r});`),e.write(`if (${l} === INVALID) return INVALID;`),l}return r}s(p4,"generateTransformCheck");function Fp(e){return e.checks&&(e.checks=[...e.checks]),e}s(Fp,"snapshotChecks");function Cv(e,t){return new e(Fp({type:"string",...N(t)}))}s(Cv,"_string");function Ov(e,t){return new e(Fp({type:"string",coerce:!0,...N(t)}))}s(Ov,"_coercedString");function zp(e,t){return new e({type:"string",format:"email",check:"string_format",abort:!1,...N(t)})}s(zp,"_email");function Mp(e,t){return new e({type:"string",format:"guid",check:"string_format",abort:!1,...N(t)})}s(Mp,"_guid");function Up(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,...N(t)})}s(Up,"_uuid");function Gp(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...N(t)})}s(Gp,"_uuidv4");function jp(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...N(t)})}s(jp,"_uuidv6");function Zp(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...N(t)})}s(Zp,"_uuidv7");function hl(e,t){return new e({type:"string",format:"url",check:"string_format",abort:!1,...N(t)})}s(hl,"_url");function qp(e,t){return new e({type:"string",format:"emoji",check:"string_format",abort:!1,...N(t)})}s(qp,"_emoji");function Bp(e,t){return new e({type:"string",format:"nanoid",check:"string_format",abort:!1,...N(t)})}s(Bp,"_nanoid");function Vp(e,t){return new e({type:"string",format:"cuid",check:"string_format",abort:!1,...N(t)})}s(Vp,"_cuid");function Hp(e,t){return new e({type:"string",format:"cuid2",check:"string_format",abort:!1,...N(t)})}s(Hp,"_cuid2");function Kp(e,t){return new e({type:"string",format:"ulid",check:"string_format",abort:!1,...N(t)})}s(Kp,"_ulid");function Jp(e,t){return new e({type:"string",format:"xid",check:"string_format",abort:!1,...N(t)})}s(Jp,"_xid");function Wp(e,t){return new e({type:"string",format:"ksuid",check:"string_format",abort:!1,...N(t)})}s(Wp,"_ksuid");function Yp(e,t){return new e({type:"string",format:"ipv4",check:"string_format",abort:!1,...N(t)})}s(Yp,"_ipv4");function Xp(e,t){return new e({type:"string",format:"ipv6",check:"string_format",abort:!1,...N(t)})}s(Xp,"_ipv6");function Rv(e,t){return new e({type:"string",format:"mac",check:"string_format",abort:!1,...N(t)})}s(Rv,"_mac");function Qp(e,t){return new e({type:"string",format:"cidrv4",check:"string_format",abort:!1,...N(t)})}s(Qp,"_cidrv4");function em(e,t){return new e({type:"string",format:"cidrv6",check:"string_format",abort:!1,...N(t)})}s(em,"_cidrv6");function tm(e,t){return new e({type:"string",format:"base64",check:"string_format",abort:!1,...N(t)})}s(tm,"_base64");function nm(e,t){return new e({type:"string",format:"base64url",check:"string_format",abort:!1,...N(t)})}s(nm,"_base64url");function rm(e,t){return new e({type:"string",format:"e164",check:"string_format",abort:!1,...N(t)})}s(rm,"_e164");function $v(e,t){return new e({type:"string",format:"credit_card",check:"string_format",abort:!1,...N(t)})}s($v,"_creditCard");function Pv(e,t){return new e({type:"string",format:"iban",check:"string_format",abort:!1,...N(t)})}s(Pv,"_iban");function om(e,t){return new e({type:"string",format:"jwt",check:"string_format",abort:!1,...N(t)})}s(om,"_jwt");var Nv={Any:null,Minute:-1,Second:0,Millisecond:3,Microsecond:6};function gl(e,t){return new e({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...N(t)})}s(gl,"_isoDateTime");function xl(e,t){return new e({type:"string",format:"date",check:"string_format",...N(t)})}s(xl,"_isoDate");function yl(e,t){return new e({type:"string",format:"time",check:"string_format",precision:null,...N(t)})}s(yl,"_isoTime");function Sl(e,t){return new e({type:"string",format:"duration",check:"string_format",...N(t)})}s(Sl,"_isoDuration");function Dv(e,t){return new e(Fp({type:"number",checks:[],...N(t)}))}s(Dv,"_number");function Lv(e,t){return new e(Fp({type:"number",coerce:!0,checks:[],...N(t)}))}s(Lv,"_coercedNumber");function Fv(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"safeint",...N(t)})}s(Fv,"_int");function zv(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"float32",...N(t)})}s(zv,"_float32");function Mv(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"float64",...N(t)})}s(Mv,"_float64");function Uv(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"int32",...N(t)})}s(Uv,"_int32");function Gv(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"uint32",...N(t)})}s(Gv,"_uint32");function jv(e,t){return new e({type:"boolean",...N(t)})}s(jv,"_boolean");function Zv(e,t){return new e({type:"boolean",coerce:!0,...N(t)})}s(Zv,"_coercedBoolean");function qv(e,t){return new e({type:"bigint",...N(t)})}s(qv,"_bigint");function Bv(e,t){return new e({type:"bigint",coerce:!0,...N(t)})}s(Bv,"_coercedBigint");function Vv(e,t){return new e({type:"bigint",check:"bigint_format",abort:!1,format:"int64",...N(t)})}s(Vv,"_int64");function Hv(e,t){return new e({type:"bigint",check:"bigint_format",abort:!1,format:"uint64",...N(t)})}s(Hv,"_uint64");function Kv(e,t){return new e({type:"symbol",...N(t)})}s(Kv,"_symbol");function Jv(e,t){return new e({type:"undefined",...N(t)})}s(Jv,"_undefined");function Wv(e,t){return new e({type:"null",...N(t)})}s(Wv,"_null");function Yv(e){return new e({type:"any"})}s(Yv,"_any");function Xv(e){return new e({type:"unknown"})}s(Xv,"_unknown");function Qv(e,t){return new e({type:"never",...N(t)})}s(Qv,"_never");function e_(e,t){return new e({type:"void",...N(t)})}s(e_,"_void");function t_(e,t){return new e({type:"date",...N(t)})}s(t_,"_date");function n_(e,t){return new e({type:"date",coerce:!0,...N(t)})}s(n_,"_coercedDate");function r_(e,t){return new e({type:"nan",...N(t)})}s(r_,"_nan");function qr(e,t){return new ip({check:"less_than",...N(t),value:e,inclusive:!1})}s(qr,"_lt");function Pn(e,t){return new ip({check:"less_than",...N(t),value:e,inclusive:!0})}s(Pn,"_lte");function Br(e,t){return new ap({check:"greater_than",...N(t),value:e,inclusive:!1})}s(Br,"_gt");function Nn(e,t){return new ap({check:"greater_than",...N(t),value:e,inclusive:!0})}s(Nn,"_gte");function sm(e){return Br(0,e)}s(sm,"_positive");function im(e){return qr(0,e)}s(im,"_negative");function am(e){return Pn(0,e)}s(am,"_nonpositive");function cm(e){return Nn(0,e)}s(cm,"_nonnegative");function ms(e,t){return new MS({check:"multiple_of",...N(t),value:e})}s(ms,"_multipleOf");function hs(e,t){return new jS({check:"max_size",...N(t),maximum:e})}s(hs,"_maxSize");function Vr(e,t){return new ZS({check:"min_size",...N(t),minimum:e})}s(Vr,"_minSize");function pi(e,t){return new qS({check:"size_equals",...N(t),size:e})}s(pi,"_size");function mi(e,t){return new BS({check:"max_length",...N(t),maximum:e})}s(mi,"_maxLength");function wo(e,t){return new VS({check:"min_length",...N(t),minimum:e})}s(wo,"_minLength");function hi(e,t){return new HS({check:"length_equals",...N(t),length:e})}s(hi,"_length");function Va(e,t){return new KS({check:"string_format",format:"regex",...N(t),pattern:e})}s(Va,"_regex");function Ha(e){return new JS({check:"string_format",format:"lowercase",...N(e)})}s(Ha,"_lowercase");function Ka(e){return new WS({check:"string_format",format:"uppercase",...N(e)})}s(Ka,"_uppercase");function Ja(e,t){return new YS({check:"string_format",format:"includes",...N(t),includes:e})}s(Ja,"_includes");function Wa(e,t){return new XS({check:"string_format",format:"starts_with",...N(t),prefix:e})}s(Wa,"_startsWith");function Ya(e,t){return new QS({check:"string_format",format:"ends_with",...N(t),suffix:e})}s(Ya,"_endsWith");function um(e,t,n){return new eb({check:"property",property:e,schema:t,...N(n)})}s(um,"_property");function Xa(e,t){return new tb({check:"properties",shape:e,...N(t)})}s(Xa,"_properties");function Qa(e,t){return new nb({check:"mime_type",mime:e,...N(t)})}s(Qa,"_mime");function xr(e){return new rb({check:"overwrite",tx:e})}s(xr,"_overwrite");function ec(e){return xr(t=>t.normalize(e))}s(ec,"_normalize");function tc(){return xr(e=>e.trim())}s(tc,"_trim");function nc(){return xr(e=>e.toLowerCase())}s(nc,"_toLowerCase");function rc(){return xr(e=>e.toUpperCase())}s(rc,"_toUpperCase");function oc(){return xr(e=>Uy(e))}s(oc,"_slugify");function o_(e,t,n){return new e({type:"array",element:t,...N(n)})}s(o_,"_array");function m4(e,t,n){return new e({type:"union",options:t,...N(n)})}s(m4,"_union");function h4(e,t,n){return new e({type:"union",options:t,inclusive:!1,...N(n)})}s(h4,"_xor");function g4(e,t,n,r){return new e({type:"union",options:n,discriminator:t,...N(r)})}s(g4,"_discriminatedUnion");function x4(e,t,n){return new e({type:"intersection",left:t,right:n})}s(x4,"_intersection");function y4(e,t,n,r){let o=n instanceof ue,i=o?r:n,a=o?n:null;return new e({type:"tuple",items:t,rest:a,...N(i)})}s(y4,"_tuple");function S4(e,t,n,r){return new e({type:"record",keyType:t,valueType:n,...N(r)})}s(S4,"_record");function b4(e,t,n,r){return new e({type:"map",keyType:t,valueType:n,...N(r)})}s(b4,"_map");function v4(e,t,n){return new e({type:"set",valueType:t,...N(n)})}s(v4,"_set");function _4(e,t,n){let r=Array.isArray(t)?Object.fromEntries(t.map(o=>[o,o])):t;return new e({type:"enum",entries:r,...N(n)})}s(_4,"_enum");function w4(e,t,n){return new e({type:"enum",entries:t,...N(n)})}s(w4,"_nativeEnum");function E4(e,t,n){return new e({type:"literal",values:Array.isArray(t)?t:[t],...N(n)})}s(E4,"_literal");function s_(e,t){return new e({type:"file",...N(t)})}s(s_,"_file");function I4(e,t){return new e({type:"transform",transform:t})}s(I4,"_transform");function T4(e,t){return new e({type:"optional",innerType:t})}s(T4,"_optional");function k4(e,t){return new e({type:"nullable",innerType:t})}s(k4,"_nullable");function A4(e,t,n){return new e({type:"default",innerType:t,get defaultValue(){return typeof n=="function"?n():Mu(n)}})}s(A4,"_default");function C4(e,t,n){return new e({type:"nonoptional",innerType:t,...N(n)})}s(C4,"_nonoptional");function O4(e,t){return new e({type:"success",innerType:t})}s(O4,"_success");function R4(e,t,n){return new e({type:"catch",innerType:t,catchValue:typeof n=="function"?n:Hy(n)})}s(R4,"_catch");function $4(e,t,n){return new e({type:"pipe",in:t,out:n})}s($4,"_pipe");function P4(e,t){return new e({type:"readonly",innerType:t})}s(P4,"_readonly");function N4(e,t,n){return new e({type:"template_literal",parts:t,...N(n)})}s(N4,"_templateLiteral");function D4(e,t){return new e({type:"lazy",getter:t})}s(D4,"_lazy");function L4(e,t){return new e({type:"promise",innerType:t})}s(L4,"_promise");function i_(e,t,n){let r=N(n);return r.abort??(r.abort=!0),new e({type:"custom",check:"custom",fn:t,...r})}s(i_,"_custom");function a_(e,t,n){return new e({type:"custom",check:"custom",fn:t,...N(n)})}s(a_,"_refine");function c_(e,t){let n=YO(r=>(r.addIssue=o=>{if(typeof o=="string")r.issues.push(Fa(o,r.value,n._zod.def));else{let i=o;i.fatal&&(i.continue=!1),i.code??(i.code="custom"),"input"in i||(i.input=r.value),i.inst??(i.inst=n),i.continue??(i.continue=!n._zod.def.abort),r.issues.push(Fa(i))}},e(r.value,r)),t);return n}s(c_,"_superRefine");function YO(e,t){let n=new ze({check:"custom",...N(t)});return n._zod.check=e,n}s(YO,"_check");function u_(e){let t=new ze({check:"describe"});return t._zod.onattach=[n=>{let r=Nt.get(n)??{};Nt.add(n,{...r,description:e})}],t._zod.check=()=>{},t}s(u_,"describe");function l_(e){let t=new ze({check:"meta"});return t._zod.onattach=[n=>{let r=Nt.get(n)??{};Nt.add(n,{...r,...e})}],t._zod.check=()=>{},t}s(l_,"meta");function f_(e,t){let n=N(t),r=n.truthy??["true","1","yes","on","y","enabled"],o=n.falsy??["false","0","no","off","n","disabled"];n.case!=="sensitive"&&(r=r.map(m=>typeof m=="string"?m.toLowerCase():m),o=o.map(m=>typeof m=="string"?m.toLowerCase():m));let i=new Set(r),a=new Set(o),c=e.Codec??cl,l=e.Boolean??il,u=e.String??ui,f=new u({type:"string",error:n.error}),d=new l({type:"boolean",error:n.error}),p=new c({type:"pipe",in:f,out:d,transform:s(((m,h)=>{let x=m;return n.case!=="sensitive"&&(x=x.toLowerCase()),i.has(x)?!0:a.has(x)?!1:(h.issues.push({code:"invalid_value",expected:"stringbool",values:[...i,...a],input:h.value,inst:p,continue:!1}),{})}),"transform"),reverseTransform:s(((m,h)=>m===!0?r[0]||"true":o[0]||"false"),"reverseTransform"),error:n.error});return p._zod.bag.truthy=r,p._zod.bag.falsy=o,p._zod.bag.case=n.case??"insensitive",p}s(f_,"_stringbool");function gi(e,t,n,r={}){let o=N(r),i={check:"string_format",type:"string",format:t,fn:typeof n=="function"?n:c=>n.test(c),...o};return n instanceof RegExp&&(i.pattern=n),new e(i)}s(gi,"_stringFormat");function bl(e,...t){for(let n of t)for(let r of Reflect.ownKeys(n))Object.prototype.propertyIsEnumerable.call(n,r)&&Pt(e,r,n[r]);return e}s(bl,"assignProps");function gs(e){let t=e?.target??"draft-2020-12";return t==="draft-4"&&(t="draft-04"),t==="draft-7"&&(t="draft-07"),{processors:e.processors??{},metadataRegistry:e?.metadata??Nt,target:t,unrepresentable:e?.unrepresentable??"throw",override:e?.override??(()=>{}),io:e?.io??"output",counter:0,seen:new Map,sharedDefsExtractedFor:void 0,sharedEmitDoneFor:void 0,cycles:e?.cycles??"ref",reused:e?.reused??"inline",intersections:[],deferred:[],external:e?.external??void 0}}s(gs,"initializeContext");function mt(e,t,n,r,o){let i=typeof t.unrepresentable=="function"?t.unrepresentable({zodSchema:e,path:r.path,message:o}):t.unrepresentable;if(i==="any")return!1;if(i===void 0||i==="throw")throw new Error(o);return Object.assign(n,i),!0}s(mt,"handleUnrepresentable");function De(e,t,n={path:[],schemaPath:[]}){var r;let o=e._zod.def,i=t.seen.get(e);if(i)return i.count++,n.schemaPath.includes(e)&&(i.cycle=n.path),i.schema;let a={schema:{},count:1,cycle:void 0,path:n.path};t.seen.set(e,a),t.sharedDefsExtractedFor=void 0,t.sharedEmitDoneFor=void 0;let c=e._zod.toJSONSchema?.();if(c)a.schema=c;else{let f={...n,schemaPath:[...n.schemaPath,e],path:n.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,a.schema,f);else{let p=a.schema,m=t.processors[o.type];if(!m)throw new Error(`[toJSONSchema]: Non-representable type encountered: ${o.type}`);m(e,t,p,f)}let d=e._zod.parent;d&&(a.ref||(a.ref=d),De(d,t,f),t.seen.get(d).isParent=!0)}let l=t.metadataRegistry.get(e);return l&&bl(a.schema,l),t.io==="input"&&tn(e)&&(delete a.schema.examples,delete a.schema.default),t.io==="input"&&"_prefault"in a.schema&&((r=a.schema).default??(r.default=a.schema._prefault)),delete a.schema._prefault,t.seen.get(e).schema}s(De,"processSchema");function XO(e){return e.replace(/~/g,"~0").replace(/\//g,"~1")}s(XO,"encodeJSONPointerSegment");function xs(e,t){let n=e.seen.get(t);if(!n)throw new Error("Unprocessed schema. This is a bug in Zod.");if(e.external&&e.sharedDefsExtractedFor===e.external)return;let r=new Map;for(let a of e.seen.entries()){let c=e.metadataRegistry.get(a[0])?.id;if(c){let l=r.get(c);if(l&&l!==a[0])throw new Error(`Duplicate schema id "${c}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);r.set(c,a[0])}}let o=s(a=>{let c=e.target==="draft-2020-12"?"$defs":"definitions";if(e.external){let d=e.external.registry.get(a[0])?.id,p=e.external.uri??(h=>h);if(d)return{ref:p(d)};let m=a[1].defId??a[1].schema.id??`schema${e.counter++}`;return a[1].defId=m,{defId:m,ref:`${p("__shared")}#/${c}/${XO(m)}`}}let l="#",u=`${l}/${c}/`;if(a[1]===n&&!a[1].schema.id)return{ref:l};let f=a[1].schema.id??`__schema${e.counter++}`;return{defId:f,ref:u+XO(f)}},"makeURI"),i=s(a=>{if(a[1].schema.$ref)return;let c=a[1],{ref:l,defId:u}=o(a);c.def={...c.schema},u&&(c.defId=u);let f=c.schema;for(let d in f)delete f[d];f.$ref=l},"extractToDef");if(e.cycles==="throw")for(let a of e.seen.entries()){let c=a[1];if(c.cycle)throw new Error(`Cycle detected: #/${c.cycle?.join("/")}/<root>
|
|
67
|
+
|
|
68
|
+
Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(let a of e.seen.entries()){let c=a[1];if(t===a[0]){i(a);continue}if(e.external){let u=e.external.registry.get(a[0])?.id;if(t!==a[0]&&u){i(a);continue}}if(e.metadataRegistry.get(a[0])?.id){i(a);continue}if(c.cycle){i(a);continue}c.count>1&&e.reused==="ref"&&i(a)}e.external&&(e.sharedDefsExtractedFor=e.external)}s(xs,"extractDefs");function t0(e){let t=e.anyOf;if(!Array.isArray(t)||t.length===0||e.type!==void 0)return;let n=[];for(let r of t){if(!r||typeof r!="object")return;t0(r);let o=Object.keys(r);if(o.length!==1||o[0]!=="type")return;let i=r.type;for(let a of Array.isArray(i)?i:[i]){if(typeof a!="string")return;n.includes(a)||n.push(a)}}delete e.anyOf,e.type=n.length===1?n[0]:n}s(t0,"compactTypeUnion");var n0=new Set(["type","properties","required","additionalProperties"]),QO=["oneOf","anyOf"];function e0(e){let t=e.additionalProperties;return t===void 0||t===!1||typeof t!="object"||t===null?null:Object.keys(t).length?t:null}s(e0,"undeclaredConstraint");function d_(e){let t=[];for(let i of e){if(typeof i!="object"||i.type!=="object")return null;for(let a in i)if(!n0.has(a))return null;t.push(i)}let n={},r=new Set;for(let i of t){for(let a in i.properties){if(Object.prototype.hasOwnProperty.call(n,a))continue;let c=[];for(let u of t){let f=u.properties?.[a]??e0(u);f!=null&&(c.some(d=>JSON.stringify(d)===JSON.stringify(f))||c.push(f))}let l=c.length===1?c[0]:d_(c)??{allOf:c};Pt(n,a,l)}for(let a of i.required??[])r.add(a)}let o={type:"object",properties:n};if(r.size&&(o.required=[...r]),t.every(i=>i.additionalProperties===!1))o.additionalProperties=!1;else{let i=[];for(let a of t){let c=e0(a);c&&!i.some(l=>JSON.stringify(l)===JSON.stringify(c))&&i.push(c)}i.length===1?o.additionalProperties=i[0]:i.length>1&&(o.additionalProperties={allOf:i})}return o}s(d_,"foldObjects");function F4(e){let t=e.allOf;if(!Array.isArray(t)||t.length<2)return;for(let o of n0)if(o in e)return;let n=t.filter(o=>QO.some(i=>Array.isArray(o[i]))),r=null;if(!n.length)r=d_(t);else{let o=n[0],i=QO.find(l=>Array.isArray(o[l]));if(Object.keys(o).length!==1)return;let a=t.filter(l=>l!==o),c=o[i].map(l=>d_([...a,l]));if(c.some(l=>!l))return;r={[i]:c}}r&&(delete e.allOf,bl(e,r))}s(F4,"foldIntersection");function ys(e,t){let n=e.seen.get(t);if(!n)throw new Error("Unprocessed schema. This is a bug in Zod.");let r=s(c=>{let l=e.seen.get(c);if(l.ref===null)return;let u=l.def??l.schema,f={...u},d=l.ref;if(l.ref=null,d){r(d);let m=e.seen.get(d),h=m.schema;if(h.$ref&&(e.target==="draft-07"||e.target==="draft-04"||e.target==="openapi-3.0")?(u.allOf=u.allOf??[],u.allOf.push(h)):bl(u,h),bl(u,f),c._zod.parent===d)for(let S in u)S==="$ref"||S==="allOf"||S in f||delete u[S];if(h.$ref&&m.def)for(let S in u)S==="$ref"||S==="allOf"||S in m.def&&JSON.stringify(u[S])===JSON.stringify(m.def[S])&&delete u[S]}let p=c._zod.parent;if(p&&p!==d){r(p);let m=e.seen.get(p);if(m?.schema.$ref&&(u.$ref=m.schema.$ref,m.def))for(let h in u)h==="$ref"||h==="allOf"||h in m.def&&JSON.stringify(u[h])===JSON.stringify(m.def[h])&&delete u[h]}e.override({zodSchema:c,jsonSchema:u,path:l.path??[]})},"flattenRef");if(!e.external||e.sharedEmitDoneFor!==e.external){for(let c of[...e.seen.entries()].reverse())r(c[0]);if(e.target!=="openapi-3.0")for(let c of e.seen.entries())t0(c[1].def??c[1].schema);for(let c of e.deferred)c();if(e.intersections.length){let c=new Map;for(let l of e.seen.values())for(let u of[l.schema,l.def]){let f=u?.allOf;if(!Array.isArray(f))continue;let d=c.get(f);d?d.push(u):c.set(f,[u])}for(let l of e.intersections)for(let u of c.get(l)??[])F4(u)}}let o={};if(e.target==="draft-2020-12"?o.$schema="https://json-schema.org/draft/2020-12/schema":e.target==="draft-07"?o.$schema="http://json-schema.org/draft-07/schema#":e.target==="draft-04"?o.$schema="http://json-schema.org/draft-04/schema#":e.target,e.external?.uri){let c=e.external.registry.get(t)?.id;if(!c)throw new Error("Schema is missing an `id` property");o.$id=e.external.uri(c)}bl(o,n.defId?n.schema:n.def??n.schema);let i=e.metadataRegistry.get(t)?.id;i!==void 0&&o.id===i&&delete o.id;let a=e.external?.defs??{};if(!e.external||e.sharedEmitDoneFor!==e.external)for(let c of e.seen.entries()){let l=c[1];l.def&&l.defId&&(l.def.id===l.defId&&delete l.def.id,Pt(a,l.defId,l.def))}e.external&&(e.sharedEmitDoneFor=e.external),e.external||Object.keys(a).length>0&&(e.target==="draft-2020-12"?o.$defs=a:o.definitions=a);try{let c=JSON.parse(JSON.stringify(o));return Object.defineProperty(c,"~standard",{value:{...t["~standard"],jsonSchema:{input:sc(t,"input",e.processors),output:sc(t,"output",e.processors)}},enumerable:!1,writable:!1}),c}catch{throw new Error("Error converting schema to JSON.")}}s(ys,"finalize");function tn(e,t){let n=t??{seen:new Set};if(n.seen.has(e))return!1;n.seen.add(e);let r=e._zod.def;if(r.type==="transform")return!0;if(r.type==="array")return tn(r.element,n);if(r.type==="set")return tn(r.valueType,n);if(r.type==="lazy")return tn(r.getter(),n);if(r.type==="promise"||r.type==="optional"||r.type==="nonoptional"||r.type==="nullable"||r.type==="readonly"||r.type==="default"||r.type==="prefault"||r.type==="catch")return tn(r.innerType,n);if(r.type==="intersection")return tn(r.left,n)||tn(r.right,n);if(r.type==="record"||r.type==="map")return tn(r.keyType,n)||tn(r.valueType,n);if(r.type==="pipe")return e._zod.traits.has("$ZodCodec")?!0:tn(r.in,n)||tn(r.out,n);if(r.type==="object"){for(let o in r.shape)if(tn(r.shape[o],n))return!0;return!1}if(r.type==="union"){for(let o of r.options)if(tn(o,n))return!0;return!1}if(r.type==="tuple"){for(let o of r.items)if(tn(o,n))return!0;return!!(r.rest&&tn(r.rest,n))}return!1}s(tn,"isTransforming");var p_=s((e,t={})=>n=>{let r=gs({...n,processors:t});return De(e,r),xs(r,e),ys(r,e)},"createToJSONSchemaMethod"),sc=s((e,t,n={})=>r=>{let{libraryOptions:o,target:i}=r??{},a=gs({...o??{},target:i,io:t,processors:n});return De(e,a),xs(a,e),ys(a,e)},"createStandardJSONSchemaMethod");var ic=s((e,t,n)=>{(e[t]===void 0||n>e[t])&&(e[t]=n)},"narrowMin"),ac=s((e,t,n)=>{(e[t]===void 0||n<e[t])&&(e[t]=n)},"narrowMax"),r0=s((e,t)=>{ic(e,"minimum",t),ac(e,"maximum",t)},"narrowBoth"),a0=s((e,t)=>{e.multipleOf??(e.multipleOf=[]),e.multipleOf.includes(t)||e.multipleOf.push(t)},"addDivisor"),c0=s((e,t)=>{e.patterns??(e.patterns=new Set),e.patterns.add(t)},"addPattern"),u0=s((e,t)=>{e.mime=e.mime?e.mime.filter(n=>t.includes(n)):[...t]},"intersectMime"),l0=s((e,t)=>{e.format=t,t.includes("int")&&(e.isInt=!0)},"setFormat"),o0=s((e,t)=>ic(e,"minimum",t.minimum),"minContributor"),s0=s((e,t)=>ac(e,"maximum",t.maximum),"maxContributor"),i0=s(e=>(t,n)=>{l0(t,n.format);let[r,o]=e[n.format];ic(t,"minimum",r),ac(t,"maximum",o)},"formatContributor"),z4={greater_than:s((e,t)=>ic(e,t.inclusive?"minimum":"exclusiveMinimum",t.value),"greater_than"),less_than:s((e,t)=>ac(e,t.inclusive?"maximum":"exclusiveMaximum",t.value),"less_than"),multiple_of:s((e,t)=>a0(e,t.value),"multiple_of"),number_format:i0(Gu),bigint_format:i0(ju),min_length:o0,max_length:s0,length_equals:s((e,t)=>r0(e,t.length),"length_equals"),min_size:o0,max_size:s0,size_equals:s((e,t)=>r0(e,t.size),"size_equals"),string_format:s((e,t)=>{l0(e,t.format),t.pattern&&c0(e,t.pattern),(t.format==="base64"||t.format==="base64url")&&(e.contentEncoding=t.format),(t.local||t.precision===-1)&&(e.laxFormat=!0)},"string_format"),mime_type:s((e,t)=>u0(e,t.mime),"mime_type")};function ht(e){let t={},n=e._zod.def,r=e._zod.traits.has("$ZodCheck")?[e,...n.checks??[]]:n.checks??[];for(let i of r)z4[i._zod.def.check]?.(t,i._zod.def);let o=e._zod.bag;o.minimum!==void 0&&ic(t,"minimum",o.minimum),o.exclusiveMinimum!==void 0&&ic(t,"exclusiveMinimum",o.exclusiveMinimum),o.maximum!==void 0&&ac(t,"maximum",o.maximum),o.exclusiveMaximum!==void 0&&ac(t,"exclusiveMaximum",o.exclusiveMaximum),o.multipleOf!==void 0&&a0(t,o.multipleOf),o.format!==void 0&&(t.format??(t.format=o.format),o.format.includes("int")&&(t.isInt=!0)),o.mime&&u0(t,o.mime);for(let i of o.patterns??[])c0(t,i);return t}s(ht,"aggregateChecks");var M4={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},U4=new Map([[xp,SS],[sl,bS]]),f0=s(e=>U4.get(e)??e,"exactPattern"),g_=s((e,t,n,r)=>{let o=n;o.type="string";let{minimum:i,maximum:a,format:c,patterns:l,contentEncoding:u,laxFormat:f}=ht(e);if(typeof i=="number"&&(o.minLength=i),typeof a=="number"&&(o.maxLength=a),c&&(o.format=M4[c]??c,o.format===""&&delete o.format,(c==="time"||f)&&delete o.format),u&&(o.contentEncoding=u),l&&l.size>0){let d=[...l].map(f0);d.length===1?o.pattern=d[0].source:d.length>1&&(o.allOf=[...d.map(p=>({...t.target==="draft-07"||t.target==="draft-04"||t.target==="openapi-3.0"?{type:"string"}:{},pattern:p.source}))])}},"stringProcessor"),x_=s((e,t,n,r)=>{let o=n,{minimum:i,maximum:a,multipleOf:c,exclusiveMaximum:l,exclusiveMinimum:u,isInt:f}=ht(e);o.type=f?"integer":"number";let d=typeof u=="number"&&u>=(i??Number.NEGATIVE_INFINITY),p=typeof l=="number"&&l<=(a??Number.POSITIVE_INFINITY),m=t.target==="draft-04"||t.target==="openapi-3.0";if(d?m?(o.minimum=u,o.exclusiveMinimum=!0):o.exclusiveMinimum=u:typeof i=="number"&&(o.minimum=i),p?m?(o.maximum=l,o.exclusiveMaximum=!0):o.exclusiveMaximum=l:typeof a=="number"&&(o.maximum=a),c){let h=new Set;for(let T of c)Number.isFinite(T)&&T!==0?h.add(Math.abs(T)):mt(e,t,o,r,`A multipleOf divisor of ${T} cannot be represented in JSON Schema`);let[x,...S]=h;x!==void 0&&(o.multipleOf=x),S.length&&(o.allOf=[...o.allOf??[],...S.map(T=>({multipleOf:T}))])}},"numberProcessor"),y_=s((e,t,n,r)=>{n.type="boolean"},"booleanProcessor"),S_=s((e,t,n,r)=>{mt(e,t,n,r,"BigInt cannot be represented in JSON Schema")},"bigintProcessor"),b_=s((e,t,n,r)=>{mt(e,t,n,r,"Symbols cannot be represented in JSON Schema")},"symbolProcessor"),v_=s((e,t,n,r)=>{t.target==="openapi-3.0"?(n.type="string",n.nullable=!0,n.enum=[null]):n.type="null"},"nullProcessor"),__=s((e,t,n,r)=>{mt(e,t,n,r,"Undefined cannot be represented in JSON Schema")},"undefinedProcessor"),w_=s((e,t,n,r)=>{mt(e,t,n,r,"Void cannot be represented in JSON Schema")},"voidProcessor"),E_=s((e,t,n,r)=>{n.not={}},"neverProcessor"),I_=s((e,t,n,r)=>{},"anyProcessor"),T_=s((e,t,n,r)=>{},"unknownProcessor"),k_=s((e,t,n,r)=>{mt(e,t,n,r,"Date cannot be represented in JSON Schema")},"dateProcessor"),A_=s((e,t,n,r)=>{let o=e._zod.def,i=$a(o.entries);if(i.length===0){n.not={};return}i.every(a=>typeof a=="number")&&(n.type="number"),i.every(a=>typeof a=="string")&&(n.type="string"),n.enum=i},"enumProcessor"),C_=s((e,t,n,r)=>{let o=e._zod.def;if(o.values.length===0){n.not={};return}let i=[];for(let a of o.values)if(a===void 0){if(mt(e,t,n,r,"Literal `undefined` cannot be represented in JSON Schema"))return}else if(typeof a=="bigint"){if(mt(e,t,n,r,"BigInt literals cannot be represented in JSON Schema"))return;i.push(Number(a))}else i.push(a);if(i.length!==0)if(i.length===1){let a=i[0];n.type=a===null?"null":typeof a,t.target==="draft-04"||t.target==="openapi-3.0"?n.enum=[a]:n.const=a}else i.every(a=>typeof a=="number")&&(n.type="number"),i.every(a=>typeof a=="string")&&(n.type="string"),i.every(a=>typeof a=="boolean")&&(n.type="boolean"),i.every(a=>a===null)&&(n.type="null"),n.enum=i},"literalProcessor"),O_=s((e,t,n,r)=>{mt(e,t,n,r,"NaN cannot be represented in JSON Schema")},"nanProcessor"),R_=s((e,t,n,r)=>{let o=n,i=e._zod.pattern;if(!i)throw new Error("Pattern not found in template literal");o.type="string",o.pattern=i.source},"templateLiteralProcessor"),$_=s((e,t,n,r)=>{let o=n;o.type="string",o.format="binary",o.contentEncoding="binary";let{minimum:i,maximum:a,mime:c}=ht(e);i!==void 0&&(o.minLength=i),a!==void 0&&(o.maxLength=a),c&&(c.length===0?o.not={}:c.length===1?o.contentMediaType=c[0]:o.anyOf=c.map(l=>({contentMediaType:l})))},"fileProcessor"),P_=s((e,t,n,r)=>{n.type="boolean"},"successProcessor"),N_=s((e,t,n,r)=>{mt(e,t,n,r,"Custom types cannot be represented in JSON Schema")},"customProcessor"),D_=s((e,t,n,r)=>{mt(e,t,n,r,"Function types cannot be represented in JSON Schema")},"functionProcessor"),L_=s((e,t,n,r)=>{mt(e,t,n,r,"Transforms cannot be represented in JSON Schema")},"transformProcessor"),F_=s((e,t,n,r)=>{mt(e,t,n,r,"Map cannot be represented in JSON Schema")},"mapProcessor"),z_=s((e,t,n,r)=>{mt(e,t,n,r,"Set cannot be represented in JSON Schema")},"setProcessor"),M_=s((e,t,n,r)=>{let o=n,i=e._zod.def,{minimum:a,maximum:c}=ht(e);typeof a=="number"&&(o.minItems=a),typeof c=="number"&&(o.maxItems=c),o.type="array",o.items=De(i.element,t,{...r,path:[...r.path,"items"]})},"arrayProcessor");function vl(e){let t=e._zod.def;return t.type==="pipe"&&t.in._zod.traits.has("$ZodTransform")?vl(t.out):t.type==="catch"?vl(t.innerType):e._zod.optin}s(vl,"inputOptin");var U_=s((e,t,n,r)=>{let o=n,i=e._zod.def,a=i.shape;if(Object.getOwnPropertySymbols(a).length&&mt(e,t,o,r,"Symbol keys cannot be represented in JSON Schema"))return;o.type="object",o.properties={};for(let u in a)Pt(o.properties,u,De(a[u],t,{...r,path:[...r.path,"properties",u]}));let l=[];for(let u of Object.keys(a)){let f=i.shape[u];(t.io==="input"?vl(f)===void 0:f._zod.optout===void 0)&&l.push(u)}l.length>0&&(o.required=l),i.catchall?._zod.def.type==="never"?o.additionalProperties=!1:i.catchall?i.catchall&&(o.additionalProperties=De(i.catchall,t,{...r,path:[...r.path,"additionalProperties"]})):t.io==="output"&&(o.additionalProperties=!1)},"objectProcessor"),fm=s((e,t,n,r)=>{let o=e._zod.def,i=o.inclusive===!1,a=o.options.map((c,l)=>De(c,t,{...r,path:[...r.path,i?"oneOf":"anyOf",l]}));i?n.oneOf=a:n.anyOf=a},"unionProcessor"),G_=s((e,t,n,r)=>{let o=e._zod.def,i=De(o.left,t,{...r,path:[...r.path,"allOf",0]}),a=De(o.right,t,{...r,path:[...r.path,"allOf",1]}),c=s(u=>"allOf"in u&&Object.keys(u).length===1,"isSimpleIntersection"),l=[...c(i)?i.allOf:[i],...c(a)?a.allOf:[a]];n.allOf=l,t.intersections.push(l)},"intersectionProcessor"),j_=s((e,t,n,r)=>{let o=n,i=e._zod.def;o.type="array";let a=t.target==="draft-2020-12"?"prefixItems":"items",c=t.target==="draft-2020-12"||t.target==="openapi-3.0"?"items":"additionalItems",l=i.items.map((x,S)=>De(x,t,{...r,path:[...r.path,a,S]})),u=i.rest?De(i.rest,t,{...r,path:[...r.path,c,...t.target==="openapi-3.0"?[i.items.length]:[]]}):null,f=i.items.length;for(;f>0;){let x=i.items[f-1];if(!(t.io==="input"?vl(x)!==void 0:x._zod.optout==="optional"))break;f--}let d=i.items.length,p=!i.rest;t.target==="draft-2020-12"?(o.prefixItems=l,p?o.items=!1:u&&(o.items=u),f>0&&(o.minItems=f),p&&(o.maxItems=d)):t.target==="openapi-3.0"?(o.items={anyOf:l},u&&o.items.anyOf.push(u),f>0&&(o.minItems=f),p&&(o.maxItems=d)):(o.items=l,p?o.additionalItems=!1:u&&(o.additionalItems=u),f>0&&(o.minItems=f),p&&(o.maxItems=d));let{minimum:m,maximum:h}=ht(e);typeof m=="number"&&(o.minItems=m),typeof h=="number"&&(o.maxItems=h)},"tupleProcessor");function m_(e,t,n){if(t.$ref){if(n.has(t))return t;n.add(t);let h=e.get(t)?.def;if(!h)return t;let x=m_(e,h,n);return x===h?t:x}for(let h of["anyOf","oneOf"]){let x=t[h];if(!Array.isArray(x))continue;let S=x.map(T=>m_(e,T,n));S.some((T,b)=>T!==x[b])&&(t={...t,[h]:S})}let r=Array.isArray(t.type)?t.type:[t.type],o=!r.includes("string")&&r.some(h=>h==="number"||h==="integer"),i=t.enum??(t.const!==void 0?[t.const]:void 0);if(!o&&!i?.some(h=>typeof h=="number"))return t;let{minimum:a,maximum:c,exclusiveMinimum:l,exclusiveMaximum:u,multipleOf:f,format:d,id:p,...m}=t;return m.enum?m.enum=m.enum.map(h=>typeof h=="number"?String(h):h):typeof m.const=="number"&&(m.const=String(m.const)),o&&(m.type="string",i||(m.pattern=(r.includes("number")?_o:Xu).source)),m}s(m_,"stringifyKeyNames");var h_=new WeakMap;function G4(e){let t=new Map;for(let r of e.seen.values())r.def&&!t.has(r.schema)&&t.set(r.schema,r);let n=new Map;for(let r of h_.get(e)??[]){let o=e.seen.get(r),i=(o?.def??o?.schema)?.propertyNames;if(!i||i===!0||n.has(i))continue;let a=m_(t,i,new Set);a!==i&&n.set(i,a)}if(n.size)for(let r of e.seen.values())for(let o of[r.schema,r.def]){let i=o&&n.get(o.propertyNames);i&&(o.propertyNames=i)}}s(G4,"rewriteKeyNames");var Z_=s((e,t,n,r)=>{let o=n,i=e._zod.def;o.type="object";let a=i.keyType,c=ht(a).patterns;if(i.mode==="loose"&&c&&c.size>0){let f=De(i.valueType,t,{...r,path:[...r.path,"patternProperties","*"]});o.patternProperties={};for(let d of c)Pt(o.patternProperties,f0(d).source,f)}else{if(t.target==="draft-07"||t.target==="draft-2020-12"){o.propertyNames=De(i.keyType,t,{...r,path:[...r.path,"propertyNames"]});let f=h_.get(t);f||(f=[],h_.set(t,f),t.deferred.push(()=>G4(t))),f.push(e)}o.additionalProperties=De(i.valueType,t,{...r,path:[...r.path,"additionalProperties"]})}let l=a._zod.values,u=t.io==="input"&&vl(i.valueType)!==void 0;if(l&&!i.partial&&!u){let f=[...l].filter(d=>typeof d=="string"||typeof d=="number");f.length>0&&(o.required=f.map(String))}},"recordProcessor"),q_=s((e,t,n,r)=>{let o=e._zod.def,i=De(o.innerType,t,r),a=t.seen.get(e);t.target==="openapi-3.0"?(a.ref=o.innerType,n.nullable=!0):n.anyOf=[i,{type:"null"}]},"nullableProcessor"),B_=s((e,t,n,r)=>{let o=e._zod.def;De(o.innerType,t,r);let i=t.seen.get(e);i.ref=o.innerType},"nonoptionalProcessor"),V_=Symbol();function d0(e,t,n,r,o){let i=!1,a=JSON.stringify(e,(c,l)=>typeof l!="bigint"?l:(i=!0,null));return i?(mt(t,n,r,o,"BigInt defaults cannot be represented in JSON Schema"),V_):JSON.parse(a)}s(d0,"serializeDefaultValue");var H_=s((e,t,n,r)=>{let o=e._zod.def;De(o.innerType,t,r);let i=t.seen.get(e);i.ref=o.innerType;let a=d0(o.defaultValue,e,t,n,r);a!==V_&&(n.default=a)},"defaultProcessor"),K_=s((e,t,n,r)=>{let o=e._zod.def;De(o.innerType,t,r);let i=t.seen.get(e);if(i.ref=o.innerType,t.io!=="input")return;let a=d0(o.defaultValue,e,t,n,r);a!==V_&&(n._prefault=a)},"prefaultProcessor"),J_=s((e,t,n,r)=>{let o=e._zod.def;De(o.innerType,t,r);let i=t.seen.get(e);i.ref=o.innerType;let a;try{a=o.catchValue(void 0)}catch{mt(e,t,n,r,"Dynamic catch values are not supported in JSON Schema");return}n.default=a},"catchProcessor"),W_=s((e,t,n,r)=>{let o=e._zod.def,i=o.in._zod.traits.has("$ZodTransform"),a=t.io==="input"?i?o.out:o.in:o.out;De(a,t,r);let c=t.seen.get(e);c.ref=a},"pipeProcessor"),Y_=s((e,t,n,r)=>{let o=e._zod.def;De(o.innerType,t,r);let i=t.seen.get(e);i.ref=o.innerType,n.readOnly=!0},"readonlyProcessor"),X_=s((e,t,n,r)=>{let o=e._zod.def;De(o.innerType,t,r);let i=t.seen.get(e);i.ref=o.innerType},"promiseProcessor"),dm=s((e,t,n,r)=>{let o=e._zod.def;De(o.innerType,t,r);let i=t.seen.get(e);i.ref=o.innerType},"optionalProcessor"),Q_=s((e,t,n,r)=>{let o=e._zod.innerType;De(o,t,r);let i=t.seen.get(e);i.ref=o},"lazyProcessor"),lm={string:g_,number:x_,boolean:y_,bigint:S_,symbol:b_,null:v_,undefined:__,void:w_,never:E_,any:I_,unknown:T_,date:k_,enum:A_,literal:C_,nan:O_,template_literal:R_,file:$_,success:P_,custom:N_,function:D_,transform:L_,map:F_,set:z_,array:M_,object:U_,union:fm,intersection:G_,tuple:j_,record:Z_,nullable:q_,nonoptional:B_,default:H_,prefault:K_,catch:J_,pipe:W_,readonly:Y_,promise:X_,optional:dm,lazy:Q_};function pm(e,t){if("_idmap"in e){let r=e,o=gs({...t,processors:lm}),i={};for(let l of r._idmap.entries()){let[u,f]=l;De(f,o)}let a={},c={registry:r,uri:t?.uri,defs:i};o.external=c;for(let l of r._idmap.entries()){let[u,f]=l;xs(o,f),Pt(a,u,ys(o,f))}if(Object.keys(i).length>0){let l=o.target==="draft-2020-12"?"$defs":"definitions";a.__shared={[l]:i}}return{schemas:a}}let n=gs({...t,processors:lm});return De(e,n),xs(n,e),ys(n,e)}s(pm,"toJSONSchema");var mm=class{static{s(this,"JSONSchemaGenerator")}get metadataRegistry(){return this.ctx.metadataRegistry}get target(){return this.ctx.target}get unrepresentable(){return this.ctx.unrepresentable}get override(){return this.ctx.override}get io(){return this.ctx.io}get counter(){return this.ctx.counter}set counter(t){this.ctx.counter=t}get seen(){return this.ctx.seen}constructor(t){let n=t?.target??"draft-2020-12";n==="draft-4"&&(n="draft-04"),n==="draft-7"&&(n="draft-07"),this.ctx=gs({processors:lm,target:n,...t?.metadata&&{metadata:t.metadata},...t?.unrepresentable&&{unrepresentable:t.unrepresentable},...t?.override&&{override:t.override},...t?.io&&{io:t.io}})}process(t,n={path:[],schemaPath:[]}){return De(t,this.ctx,n)}emit(t,n){n&&(n.cycles&&(this.ctx.cycles=n.cycles),n.reused&&(this.ctx.reused=n.reused),n.external&&(this.ctx.external=n.external)),this.ctx.sharedDefsExtractedFor=void 0,this.ctx.sharedEmitDoneFor=void 0,xs(this.ctx,t);let r=ys(this.ctx,t),{"~standard":o,...i}=r;return i}};var p0={};var hc={};$t(hc,{ZodAny:()=>vw,ZodArray:()=>Iw,ZodBase64:()=>Pm,ZodBase64URL:()=>Nm,ZodBigInt:()=>pc,ZodBigIntFormat:()=>Fm,ZodBoolean:()=>dc,ZodCIDRv4:()=>Rm,ZodCIDRv6:()=>$m,ZodCUID:()=>Em,ZodCUID2:()=>Im,ZodCatch:()=>Vw,ZodCodec:()=>Rl,ZodCreditCard:()=>pw,ZodCustom:()=>$l,ZodCustomStringFormat:()=>bi,ZodDate:()=>Il,ZodDefault:()=>Uw,ZodDiscriminatedUnion:()=>kw,ZodE164:()=>Dm,ZodEmail:()=>bm,ZodEmoji:()=>_m,ZodEnum:()=>uc,ZodExactOptional:()=>Gm,ZodFile:()=>Lw,ZodFunction:()=>nE,ZodGUID:()=>vm,ZodIBAN:()=>mw,ZodIPv4:()=>Cm,ZodIPv6:()=>Om,ZodISODate:()=>bs,ZodISODateTime:()=>Ss,ZodISODuration:()=>_s,ZodISOTime:()=>vs,ZodInstanceOf:()=>sE,ZodIntersection:()=>Aw,ZodJWT:()=>Lm,ZodKSUID:()=>Am,ZodLazy:()=>Qw,ZodLiteral:()=>Dw,ZodMAC:()=>dw,ZodMap:()=>Pw,ZodNaN:()=>Kw,ZodNanoID:()=>wm,ZodNever:()=>ww,ZodNonOptional:()=>jm,ZodNull:()=>Sw,ZodNullable:()=>Mw,ZodNumber:()=>fc,ZodNumberFormat:()=>vi,ZodObject:()=>kl,ZodOptional:()=>Cl,ZodPipe:()=>Ol,ZodPrefault:()=>jw,ZodPreprocess:()=>Jw,ZodPromise:()=>tE,ZodReadonly:()=>Ww,ZodRecord:()=>cc,ZodSet:()=>Nw,ZodString:()=>lc,ZodStringFormat:()=>Fe,ZodSuccess:()=>Bw,ZodSymbol:()=>xw,ZodTemplateLiteral:()=>Xw,ZodTransform:()=>Fw,ZodTuple:()=>Ow,ZodType:()=>me,ZodULID:()=>Tm,ZodURL:()=>El,ZodUUID:()=>Hr,ZodUndefined:()=>yw,ZodUnion:()=>Al,ZodUnknown:()=>_w,ZodVoid:()=>Ew,ZodXID:()=>km,ZodXor:()=>Tw,_ZodString:()=>Sm,_default:()=>Gw,_function:()=>IR,any:()=>nR,array:()=>Tl,base64:()=>L0,base64url:()=>F0,bigint:()=>Y0,boolean:()=>gw,catch:()=>Hw,check:()=>TR,cidrv4:()=>N0,cidrv6:()=>D0,codec:()=>vR,creditCard:()=>M0,cuid:()=>T0,cuid2:()=>k0,currencyCode:()=>B0,custom:()=>kR,date:()=>oR,describe:()=>AR,discriminatedUnion:()=>lR,e164:()=>z0,email:()=>g0,emoji:()=>E0,enum:()=>Mm,exactOptional:()=>zw,file:()=>xR,float32:()=>H0,float64:()=>K0,function:()=>IR,guid:()=>x0,hash:()=>V0,hex:()=>q0,hostname:()=>Z0,httpUrl:()=>w0,iban:()=>U0,instanceof:()=>OR,int:()=>xm,int32:()=>J0,int64:()=>X0,intersection:()=>Cw,invertCodec:()=>_R,ipv4:()=>R0,ipv6:()=>P0,json:()=>$R,jwt:()=>G0,keyof:()=>sR,ksuid:()=>O0,lazy:()=>eE,literal:()=>gR,looseObject:()=>cR,looseRecord:()=>dR,mac:()=>$0,map:()=>pR,meta:()=>CR,nan:()=>bR,nanoid:()=>I0,nativeEnum:()=>hR,never:()=>zm,nonoptional:()=>qw,null:()=>bw,nullable:()=>wl,nullish:()=>yR,number:()=>hw,object:()=>iR,optional:()=>yi,partialRecord:()=>fR,pipe:()=>ym,prefault:()=>Zw,preprocess:()=>PR,promise:()=>ER,readonly:()=>Yw,record:()=>$w,refine:()=>rE,set:()=>mR,strictObject:()=>aR,string:()=>_l,stringFormat:()=>j0,stringbool:()=>RR,success:()=>SR,superRefine:()=>oE,symbol:()=>eR,templateLiteral:()=>wR,transform:()=>Um,tuple:()=>Rw,uint32:()=>W0,uint64:()=>Q0,ulid:()=>A0,undefined:()=>tR,union:()=>mc,unknown:()=>xi,url:()=>_0,uuid:()=>y0,uuidv4:()=>S0,uuidv6:()=>b0,uuidv7:()=>v0,void:()=>rR,xid:()=>C0,xor:()=>uR});var hm={};$t(hm,{endsWith:()=>Ya,gt:()=>Br,gte:()=>Nn,includes:()=>Ja,length:()=>hi,lowercase:()=>Ha,lt:()=>qr,lte:()=>Pn,maxLength:()=>mi,maxSize:()=>hs,mime:()=>Qa,minLength:()=>wo,minSize:()=>Vr,multipleOf:()=>ms,negative:()=>im,nonnegative:()=>cm,nonpositive:()=>am,normalize:()=>ec,overwrite:()=>xr,positive:()=>sm,properties:()=>Xa,property:()=>um,regex:()=>Va,size:()=>pi,slugify:()=>oc,startsWith:()=>Wa,toLowerCase:()=>nc,toUpperCase:()=>rc,trim:()=>tc,uppercase:()=>Ka});var m0=new WeakSet([Object.prototype,Error.prototype]);function gm(e,t,n){Object.defineProperty(e,t,{configurable:!0,enumerable:!1,get(){let r=n(this);return Object.defineProperty(this,t,{value:r,configurable:!0,writable:!0}),r},set(r){Object.defineProperty(this,t,{value:r,configurable:!0,writable:!0})}})}s(gm,"_lazyMethod");var h0=s((e,t)=>{Qy.init(e,t),e.name="ZodError";let n=Object.getPrototypeOf(e);m0.has(n)||(m0.add(n),gm(n,"format",r=>o=>Ku(r,o)),gm(n,"flatten",r=>o=>Hu(r,o)),gm(n,"addIssue",r=>o=>{r.issues.push(o),r.message=JSON.stringify(r.issues,Pa,2)}),gm(n,"addIssues",r=>o=>{r.issues.push(...o),r.message=JSON.stringify(r.issues,Pa,2)}),Object.defineProperty(n,"isEmpty",{configurable:!0,enumerable:!1,get(){return this.issues.length===0}}))},"initializer"),Z4=_("ZodError",h0),yn=_("ZodError",h0,void 0,{Parent:Error});var ew=za(yn),tw=Ma(yn),nw=Ua(yn),rw=Ga(yn),ow=Kd(yn),sw=Jd(yn),iw=Wd(yn),aw=Yd(yn),cw=Xd(yn),uw=Qd(yn),lw=ep(yn),fw=tp(yn);function B4(){Et.localeError||rt(pl())}s(B4,"_ensureDefaultLocale");function Si(){Et.memoizer||rt({memoizer:dl()})}s(Si,"_ensureDefaultMemoizer");var me=_("ZodType",(e,t)=>(B4(),ue.init(e,t),e.def=t,e.type=t.type,e),{check(...e){let t=this.def;return this.clone(j.mergeDefs(t,{checks:[...t.checks??[],...e.map(n=>typeof n=="function"?{_zod:{check:n,def:{check:"custom"},onattach:[]}}:n)]}),{parent:!0})},with(...e){return this.check(...e)},clone(e,t){return Pe(this,e,t)},brand(){return this},register(e,t){return e.add(this,t),this},refine(e,t){return this.check(rE(e,t))},superRefine(e,t){return this.check(oE(e,t))},overwrite(e){return this.check(xr(e))},optional(){return yi(this)},exactOptional(){return zw(this)},nullable(){return wl(this)},nullish(){return yi(wl(this))},nonoptional(e){return qw(this,e)},array(){return Tl(this)},or(e){return mc([this,e])},and(e){return Cw(this,e)},transform(e){return ym(this,Um(e))},default(e){return Gw(this,e)},prefault(e){return Zw(this,e)},catch(e){return Hw(this,e)},pipe(e){return ym(this,e)},readonly(){return Yw(this)},describe(e){let t=this.clone();return Nt.add(t,{description:e}),t},meta(...e){if(e.length===0)return Nt.get(this);let t=this.clone();return Nt.add(t,e[0]),t},isOptional(){return this.safeParse(void 0).success},isNullable(){return this.safeParse(null).success},apply(e,...t){return t.length===0?e(this):e(this,...t)},get"~standard"(){return j.hide(this,"~standard",{...dp(this),jsonSchema:{input:sc(this,"input"),output:sc(this,"output")}})},set"~standard"(e){j.own(this,"~standard",e)},parse:s(function e(t,n){return ew(this,t,n,{callee:e})},"_parse"),parseAsync:s(async function e(t,n){return await tw(this,t,n,{callee:e})},"_parseAsync"),safeParse(e,t){return nw(this,e,t)},async safeParseAsync(e,t){return rw(this,e,t)},get spa(){return this?.safeParseAsync},set spa(e){j.own(this,"spa",e)},validate(e,t){return Ju(this,e,t)},validateAsync(e,t){return Wu(this,e,t)},encode:s(function e(t,n){return ow(this,t,n,{callee:e})},"_encode"),decode:s(function e(t,n){return sw(this,t,n,{callee:e})},"_decode"),encodeAsync:s(async function e(t,n){return await iw(this,t,n,{callee:e})},"_encodeAsync"),decodeAsync:s(async function e(t,n){return await aw(this,t,n,{callee:e})},"_decodeAsync"),safeEncode(e,t){return cw(this,e,t)},safeDecode(e,t){return uw(this,e,t)},async safeEncodeAsync(e,t){return lw(this,e,t)},async safeDecodeAsync(e,t){return fw(this,e,t)},toJSONSchema(e){return p_(this,{})(e)},get description(){return Nt.get(this)?.description},get _def(){return this._zod.def}}),Sm=_("_ZodString",(e,t)=>{ui.init(e,t),me.init(e,t),e._zod.processJSONSchema=(n,r,o)=>g_(e,n,r,o)},j.derived({format:s(e=>ht(e).format??null,"format"),minLength:s(e=>ht(e).minimum??null,"minLength"),maxLength:s(e=>ht(e).maximum??null,"maxLength")},{regex(...e){return this.check(Va(...e))},includes(...e){return this.check(Ja(...e))},startsWith(...e){return this.check(Wa(...e))},endsWith(...e){return this.check(Ya(...e))},min(...e){return this.check(wo(...e))},max(...e){return this.check(mi(...e))},length(...e){return this.check(hi(...e))},nonempty(...e){return this.check(wo(1,...e))},lowercase(e){return this.check(Ha(e))},uppercase(e){return this.check(Ka(e))},trim(){return this.check(tc())},normalize(...e){return this.check(ec(...e))},toLowerCase(){return this.check(nc())},toUpperCase(){return this.check(rc())},slugify(){return this.check(oc())}})),lc=_("ZodString",(e,t)=>{ui.init(e,t),Sm.init(e,t)},{email(e){return this.check(zp(bm,e))},url(e){return this.check(hl(El,e))},jwt(e){return this.check(om(Lm,e))},emoji(e){return this.check(qp(_m,e))},guid(e){return this.check(Mp(vm,e))},uuid(e){return this.check(Up(Hr,e))},uuidv4(e){return this.check(Gp(Hr,e))},uuidv6(e){return this.check(jp(Hr,e))},uuidv7(e){return this.check(Zp(Hr,e))},nanoid(e){return this.check(Bp(wm,e))},cuid(e){return this.check(Vp(Em,e))},cuid2(e){return this.check(Hp(Im,e))},ulid(e){return this.check(Kp(Tm,e))},base64(e){return this.check(tm(Pm,e))},base64url(e){return this.check(nm(Nm,e))},xid(e){return this.check(Jp(km,e))},ksuid(e){return this.check(Wp(Am,e))},ipv4(e){return this.check(Yp(Cm,e))},ipv6(e){return this.check(Xp(Om,e))},cidrv4(e){return this.check(Qp(Rm,e))},cidrv6(e){return this.check(em($m,e))},e164(e){return this.check(rm(Dm,e))},datetime(e){return this.check(gl(Ss,e))},date(e){return this.check(xl(bs,e))},time(e){return this.check(yl(vs,e))},duration(e){return this.check(Sl(_s,e))}});function _l(e){return Cv(lc,e)}s(_l,"string");var Fe=_("ZodStringFormat",(e,t)=>{Ne.init(e,t),Sm.init(e,t)}),Ss=_("ZodISODateTime",(e,t)=>{Sb.init(e,t),Fe.init(e,t)}),bs=_("ZodISODate",(e,t)=>{bb.init(e,t),Fe.init(e,t)}),vs=_("ZodISOTime",(e,t)=>{vb.init(e,t),Fe.init(e,t)}),_s=_("ZodISODuration",(e,t)=>{_b.init(e,t),Fe.init(e,t)}),bm=_("ZodEmail",(e,t)=>{cb.init(e,t),Fe.init(e,t)});function g0(e){return zp(bm,e)}s(g0,"email");var vm=_("ZodGUID",(e,t)=>{ib.init(e,t),Fe.init(e,t)});function x0(e){return Mp(vm,e)}s(x0,"guid");var Hr=_("ZodUUID",(e,t)=>{ab.init(e,t),Fe.init(e,t)});function y0(e){return Up(Hr,e)}s(y0,"uuid");function S0(e){return Gp(Hr,e)}s(S0,"uuidv4");function b0(e){return jp(Hr,e)}s(b0,"uuidv6");function v0(e){return Zp(Hr,e)}s(v0,"uuidv7");var El=_("ZodURL",(e,t)=>{fb.init(e,t),Fe.init(e,t)});function _0(e){return hl(El,e)}s(_0,"url");function w0(e){return hl(El,{protocol:Yu,hostname:_S,...j.normalizeParams(e)})}s(w0,"httpUrl");var _m=_("ZodEmoji",(e,t)=>{db.init(e,t),Fe.init(e,t)});function E0(e){return qp(_m,e)}s(E0,"emoji");var wm=_("ZodNanoID",(e,t)=>{pb.init(e,t),Fe.init(e,t)});function I0(e){return Bp(wm,e)}s(I0,"nanoid");var Em=_("ZodCUID",(e,t)=>{mb.init(e,t),Fe.init(e,t)});function T0(e){return Vp(Em,e)}s(T0,"cuid");var Im=_("ZodCUID2",(e,t)=>{hb.init(e,t),Fe.init(e,t)});function k0(e){return Hp(Im,e)}s(k0,"cuid2");var Tm=_("ZodULID",(e,t)=>{gb.init(e,t),Fe.init(e,t)});function A0(e){return Kp(Tm,e)}s(A0,"ulid");var km=_("ZodXID",(e,t)=>{xb.init(e,t),Fe.init(e,t)});function C0(e){return Jp(km,e)}s(C0,"xid");var Am=_("ZodKSUID",(e,t)=>{yb.init(e,t),Fe.init(e,t)});function O0(e){return Wp(Am,e)}s(O0,"ksuid");var Cm=_("ZodIPv4",(e,t)=>{wb.init(e,t),Fe.init(e,t)});function R0(e){return Yp(Cm,e)}s(R0,"ipv4");var dw=_("ZodMAC",(e,t)=>{Ib.init(e,t),Fe.init(e,t)});function $0(e){return Rv(dw,e)}s($0,"mac");var Om=_("ZodIPv6",(e,t)=>{Eb.init(e,t),Fe.init(e,t)});function P0(e){return Xp(Om,e)}s(P0,"ipv6");var Rm=_("ZodCIDRv4",(e,t)=>{Tb.init(e,t),Fe.init(e,t)});function N0(e){return Qp(Rm,e)}s(N0,"cidrv4");var $m=_("ZodCIDRv6",(e,t)=>{kb.init(e,t),Fe.init(e,t)});function D0(e){return em($m,e)}s(D0,"cidrv6");var Pm=_("ZodBase64",(e,t)=>{Ab.init(e,t),Fe.init(e,t)});function L0(e){return tm(Pm,e)}s(L0,"base64");var Nm=_("ZodBase64URL",(e,t)=>{Cb.init(e,t),Fe.init(e,t)});function F0(e){return nm(Nm,e)}s(F0,"base64url");var Dm=_("ZodE164",(e,t)=>{Ob.init(e,t),Fe.init(e,t)});function z0(e){return rm(Dm,e)}s(z0,"e164");var pw=_("ZodCreditCard",(e,t)=>{Rb.init(e,t),Fe.init(e,t)});function M0(e){return $v(pw,e)}s(M0,"creditCard");var mw=_("ZodIBAN",(e,t)=>{$b.init(e,t),Fe.init(e,t)});function U0(e){return Pv(mw,e)}s(U0,"iban");var Lm=_("ZodJWT",(e,t)=>{Pb.init(e,t),Fe.init(e,t)});function G0(e){return om(Lm,e)}s(G0,"jwt");var bi=_("ZodCustomStringFormat",(e,t)=>{Nb.init(e,t),Fe.init(e,t)});function j0(e,t,n={}){return gi(bi,e,t,n)}s(j0,"stringFormat");function Z0(e){return gi(bi,"hostname",vS,e)}s(Z0,"hostname");function q0(e){return gi(bi,"hex",LS,e)}s(q0,"hex");function B0(e){return gi(bi,"currency_code",ES,e)}s(B0,"currencyCode");function V0(e,t){let n=t?.enc??"hex",r=`${e}_${n}`,o=Wn[r];if(!o)throw new Error(`Unrecognized hash format: ${r}`);return gi(bi,r,o,t)}s(V0,"hash");var fc=_("ZodNumber",(e,t)=>{_p.init(e,t),me.init(e,t),e._zod.processJSONSchema=(n,r,o)=>x_(e,n,r,o),e.isFinite=!0},j.derived({minValue:s(e=>{let{minimum:t,exclusiveMinimum:n}=ht(e);return Math.max(t??Number.NEGATIVE_INFINITY,n??Number.NEGATIVE_INFINITY)},"minValue"),maxValue:s(e=>{let{maximum:t,exclusiveMaximum:n}=ht(e);return Math.min(t??Number.POSITIVE_INFINITY,n??Number.POSITIVE_INFINITY)},"maxValue"),isInt:s(e=>{let{isInt:t,multipleOf:n}=ht(e);return!!t||!!n?.some(Number.isSafeInteger)},"isInt"),format:s(e=>ht(e).format??null,"format")},{gt(e,t){return this.check(Br(e,t))},gte(e,t){return this.check(Nn(e,t))},min(e,t){return this.check(Nn(e,t))},lt(e,t){return this.check(qr(e,t))},lte(e,t){return this.check(Pn(e,t))},max(e,t){return this.check(Pn(e,t))},int(e){return this.check(xm(e))},safe(e){return this.check(xm(e))},positive(e){return this.check(Br(0,e))},nonnegative(e){return this.check(Nn(0,e))},negative(e){return this.check(qr(0,e))},nonpositive(e){return this.check(Pn(0,e))},multipleOf(e,t){return this.check(ms(e,t))},step(e,t){return this.check(ms(e,t))},finite(){return this}}));function hw(e){return Dv(fc,e)}s(hw,"number");var vi=_("ZodNumberFormat",(e,t)=>{Db.init(e,t),fc.init(e,t)});function xm(e){return Fv(vi,e)}s(xm,"int");function H0(e){return zv(vi,e)}s(H0,"float32");function K0(e){return Mv(vi,e)}s(K0,"float64");function J0(e){return Uv(vi,e)}s(J0,"int32");function W0(e){return Gv(vi,e)}s(W0,"uint32");var dc=_("ZodBoolean",(e,t)=>{il.init(e,t),me.init(e,t),e._zod.processJSONSchema=(n,r,o)=>y_(e,n,r,o)});function gw(e){return jv(dc,e)}s(gw,"boolean");var pc=_("ZodBigInt",(e,t)=>{wp.init(e,t),me.init(e,t),e._zod.processJSONSchema=(n,r,o)=>S_(e,n,r,o)},j.derived({minValue:s(e=>ht(e).minimum??null,"minValue"),maxValue:s(e=>ht(e).maximum??null,"maxValue"),format:s(e=>ht(e).format??null,"format")},{gte(e,t){return this.check(Nn(e,t))},min(e,t){return this.check(Nn(e,t))},gt(e,t){return this.check(Br(e,t))},lt(e,t){return this.check(qr(e,t))},lte(e,t){return this.check(Pn(e,t))},max(e,t){return this.check(Pn(e,t))},positive(e){return this.check(Br(BigInt(0),e))},negative(e){return this.check(qr(BigInt(0),e))},nonpositive(e){return this.check(Pn(BigInt(0),e))},nonnegative(e){return this.check(Nn(BigInt(0),e))},multipleOf(e,t){return this.check(ms(e,t))}}));function Y0(e){return qv(pc,e)}s(Y0,"bigint");var Fm=_("ZodBigIntFormat",(e,t)=>{Lb.init(e,t),pc.init(e,t)});function X0(e){return Vv(Fm,e)}s(X0,"int64");function Q0(e){return Hv(Fm,e)}s(Q0,"uint64");var xw=_("ZodSymbol",(e,t)=>{Fb.init(e,t),me.init(e,t),e._zod.processJSONSchema=(n,r,o)=>b_(e,n,r,o)});function eR(e){return Kv(xw,e)}s(eR,"symbol");var yw=_("ZodUndefined",(e,t)=>{zb.init(e,t),me.init(e,t),e._zod.processJSONSchema=(n,r,o)=>__(e,n,r,o)});function tR(e){return Jv(yw,e)}s(tR,"_undefined");var Sw=_("ZodNull",(e,t)=>{Mb.init(e,t),me.init(e,t),e._zod.processJSONSchema=(n,r,o)=>v_(e,n,r,o)});function bw(e){return Wv(Sw,e)}s(bw,"_null");var vw=_("ZodAny",(e,t)=>{Ub.init(e,t),me.init(e,t),e._zod.processJSONSchema=(n,r,o)=>I_(e,n,r,o)});function nR(){return Yv(vw)}s(nR,"any");var _w=_("ZodUnknown",(e,t)=>{Gb.init(e,t),me.init(e,t),e._zod.processJSONSchema=(n,r,o)=>T_(e,n,r,o)});function xi(){return Xv(_w)}s(xi,"unknown");var ww=_("ZodNever",(e,t)=>{jb.init(e,t),me.init(e,t),e._zod.processJSONSchema=(n,r,o)=>E_(e,n,r,o)});function zm(e){return Qv(ww,e)}s(zm,"never");var Ew=_("ZodVoid",(e,t)=>{Zb.init(e,t),me.init(e,t),e._zod.processJSONSchema=(n,r,o)=>w_(e,n,r,o)});function rR(e){return e_(Ew,e)}s(rR,"_void");var Il=_("ZodDate",(e,t)=>{qb.init(e,t),me.init(e,t),e._zod.processJSONSchema=(n,r,o)=>k_(e,n,r,o),e.min=(n,r)=>e.check(Nn(n,r)),e.max=(n,r)=>e.check(Pn(n,r))},j.derived({minDate:s(e=>{let{minimum:t}=ht(e);return t?new Date(t):null},"minDate"),maxDate:s(e=>{let{maximum:t}=ht(e);return t?new Date(t):null},"maxDate")},{}));function oR(e){return t_(Il,e)}s(oR,"date");var Iw=_("ZodArray",(e,t)=>{Si(),Vb.init(e,t),me.init(e,t),e._zod.processJSONSchema=(n,r,o)=>M_(e,n,r,o),e.element=t.element},{min(e,t){return this.check(wo(e,t))},nonempty(e){return this.check(wo(1,e))},max(e,t){return this.check(mi(e,t))},length(e,t){return this.check(hi(e,t))},unwrap(){return this.element}});function Tl(e,t){return o_(Iw,e,t)}s(Tl,"array");function sR(e){let t=e._zod.def.shape;return Mm(Object.keys(t))}s(sR,"keyof");var kl=_("ZodObject",(e,t)=>{Si(),Hb.init(e,t),me.init(e,t),e._zod.processJSONSchema=(n,r,o)=>U_(e,n,r,o),j.installLazyProp(e,"shape",n=>n._zod.def.shape,!1)},{keyof(){return Mm(Object.keys(this._zod.def.shape))},catchall(e){return this.clone(j.mergeDefs(this._zod.def,{catchall:e}))},passthrough(){return this.clone(j.mergeDefs(this._zod.def,{catchall:xi()}))},loose(){return this.clone(j.mergeDefs(this._zod.def,{catchall:xi()}))},strict(){return this.clone(j.mergeDefs(this._zod.def,{catchall:zm()}))},strip(){return this.clone(j.mergeDefs(this._zod.def,{catchall:void 0}))},extend(e){return j.extend(this,e)},safeExtend(e){return j.safeExtend(this,e)},merge(e){return j.merge(this,e)},pick(e){return j.pick(this,e)},omit(e){return j.omit(this,e)},partial(...e){return j.partial(Cl,this,e[0])},exactPartial(...e){return j.partial(Gm,this,e[0],"exactPartial")},required(...e){return j.required(jm,this,e[0])}});function iR(e,t){let n={type:"object",shape:e??{},...j.normalizeParams(t)};return new kl(n)}s(iR,"object");function aR(e,t){return new kl({type:"object",shape:e,catchall:zm(),...j.normalizeParams(t)})}s(aR,"strictObject");function cR(e,t){return new kl({type:"object",shape:e,catchall:xi(),...j.normalizeParams(t)})}s(cR,"looseObject");var Al=_("ZodUnion",(e,t)=>{al.init(e,t),me.init(e,t),e._zod.processJSONSchema=(n,r,o)=>fm(e,n,r,o),e.options=t.options});function mc(e,t){return new Al({type:"union",options:e,...j.normalizeParams(t)})}s(mc,"union");var Tw=_("ZodXor",(e,t)=>{Al.init(e,t),Kb.init(e,t),e._zod.processJSONSchema=(n,r,o)=>fm(e,n,r,o),e.options=t.options});function uR(e,t){return new Tw({type:"union",options:e,inclusive:!1,...j.normalizeParams(t)})}s(uR,"xor");var kw=_("ZodDiscriminatedUnion",(e,t)=>{Al.init(e,t),Wb.init(e,t)});function lR(e,t,n){return new kw({type:"union",options:t,discriminator:e,...j.normalizeParams(n)})}s(lR,"discriminatedUnion");var Aw=_("ZodIntersection",(e,t)=>{Yb.init(e,t),me.init(e,t),e._zod.processJSONSchema=(n,r,o)=>G_(e,n,r,o)});function Cw(e,t){return new Aw({type:"intersection",left:e,right:t})}s(Cw,"intersection");var Ow=_("ZodTuple",(e,t)=>{Si(),Ep.init(e,t),me.init(e,t),e._zod.processJSONSchema=(n,r,o)=>j_(e,n,r,o)},{rest(e){return this.clone({...this._zod.def,rest:e})},partial(){let e=this._zod.def;if(e.checks?.length)throw new Error(".partial() cannot be used on tuple schemas containing refinements");return this.clone({...e,items:e.items.map(t=>new Cl({type:"optional",innerType:t}))})}});function Rw(e,t,n){let r=t instanceof ue,o=r?n:t,i=r?t:null;return new Ow({type:"tuple",items:e,rest:i,...j.normalizeParams(o)})}s(Rw,"tuple");var cc=_("ZodRecord",(e,t)=>{Si(),Xb.init(e,t),me.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Z_(e,n,r,o),e.keyType=t.keyType,e.valueType=t.valueType});function $w(e,t,n){return!t||!t._zod?new cc({type:"record",keyType:_l(),valueType:e,...j.normalizeParams(t)}):new cc({type:"record",keyType:e,valueType:t,...j.normalizeParams(n)})}s($w,"record");function fR(e,t,n){return new cc({type:"record",keyType:e,valueType:t,...j.normalizeParams(n),partial:!0})}s(fR,"partialRecord");function dR(e,t,n){return new cc({type:"record",keyType:e,valueType:t,mode:"loose",...j.normalizeParams(n)})}s(dR,"looseRecord");var Pw=_("ZodMap",(e,t)=>{Si(),Qb.init(e,t),me.init(e,t),e._zod.processJSONSchema=(n,r,o)=>F_(e,n,r,o),e.keyType=t.keyType,e.valueType=t.valueType,e.min=(...n)=>e.check(Vr(...n)),e.nonempty=n=>e.check(Vr(1,n)),e.max=(...n)=>e.check(hs(...n)),e.size=(...n)=>e.check(pi(...n))});function pR(e,t,n){return new Pw({type:"map",keyType:e,valueType:t,...j.normalizeParams(n)})}s(pR,"map");var Nw=_("ZodSet",(e,t)=>{Si(),ev.init(e,t),me.init(e,t),e._zod.processJSONSchema=(n,r,o)=>z_(e,n,r,o),e.min=(...n)=>e.check(Vr(...n)),e.nonempty=n=>e.check(Vr(1,n)),e.max=(...n)=>e.check(hs(...n)),e.size=(...n)=>e.check(pi(...n))});function mR(e,t){return new Nw({type:"set",valueType:e,...j.normalizeParams(t)})}s(mR,"set");var uc=_("ZodEnum",(e,t)=>{tv.init(e,t),me.init(e,t),e._zod.processJSONSchema=(r,o,i)=>A_(e,r,o,i),e.enum=t.entries,e.options=[...e._zod.values];let n=new Set(Object.keys(t.entries));e.extract=(r,o)=>{let i={};for(let a of r)if(n.has(a))i[a]=t.entries[a];else throw new Error(`Key ${a} not found in enum`);return new uc({...t,checks:[],...j.normalizeParams(o),entries:i})},e.exclude=(r,o)=>{let i={...t.entries};for(let a of r)if(n.has(a))delete i[a];else throw new Error(`Key ${a} not found in enum`);return new uc({...t,checks:[],...j.normalizeParams(o),entries:i})}});function Mm(e,t){let n=Array.isArray(e)?Object.fromEntries(e.map(r=>[r,r])):e;return new uc({type:"enum",entries:n,...j.normalizeParams(t)})}s(Mm,"_enum");function hR(e,t){return new uc({type:"enum",entries:e,...j.normalizeParams(t)})}s(hR,"nativeEnum");var Dw=_("ZodLiteral",(e,t)=>{nv.init(e,t),me.init(e,t),e._zod.processJSONSchema=(n,r,o)=>C_(e,n,r,o),e.values=new Set(t.values),Object.defineProperty(e,"value",{get(){if(t.values.length>1)throw new Error("This schema contains multiple valid literal values. Use `.values` instead.");return t.values[0]}})});function gR(e,t){return new Dw({type:"literal",values:Array.isArray(e)?e:[e],...j.normalizeParams(t)})}s(gR,"literal");var Lw=_("ZodFile",(e,t)=>{rv.init(e,t),me.init(e,t),e._zod.processJSONSchema=(n,r,o)=>$_(e,n,r,o),e.min=(n,r)=>e.check(Vr(n,r)),e.max=(n,r)=>e.check(hs(n,r)),e.mime=(n,r)=>e.check(Qa(Array.isArray(n)?n:[n],r))});function xR(e){return s_(Lw,e)}s(xR,"file");var Fw=_("ZodTransform",(e,t)=>{Si(),ov.init(e,t),me.init(e,t),e._zod.processJSONSchema=(n,r,o)=>L_(e,n,r,o),e._zod.parse=(n,r)=>{if(r.direction==="backward")throw new ds(e.constructor.name);n.addIssue=i=>{if(typeof i=="string")n.issues.push(j.issue(i,n.value,t));else{let a=i;a.fatal&&(a.continue=!1),a.code??(a.code="custom"),"input"in a||(a.input=n.value),a.inst??(a.inst=e),n.issues.push(j.issue(a))}};let o=t.transform(n.value,n);return o instanceof Promise?o.then(i=>(n.value=i,n)):(n.value=o,n)}});function Um(e){return new Fw({type:"transform",transform:e})}s(Um,"transform");var Cl=_("ZodOptional",(e,t)=>{Ip.init(e,t),me.init(e,t),e._zod.processJSONSchema=(n,r,o)=>dm(e,n,r,o),e.unwrap=()=>e._zod.def.innerType});function yi(e){return new Cl({type:"optional",innerType:e})}s(yi,"optional");var Gm=_("ZodExactOptional",(e,t)=>{sv.init(e,t),me.init(e,t),e._zod.processJSONSchema=(n,r,o)=>dm(e,n,r,o),e.unwrap=()=>e._zod.def.innerType});function zw(e){return new Gm({type:"optional",innerType:e})}s(zw,"exactOptional");var Mw=_("ZodNullable",(e,t)=>{iv.init(e,t),me.init(e,t),e._zod.processJSONSchema=(n,r,o)=>q_(e,n,r,o),e.unwrap=()=>e._zod.def.innerType});function wl(e){return new Mw({type:"nullable",innerType:e})}s(wl,"nullable");function yR(e){return yi(wl(e))}s(yR,"nullish");var Uw=_("ZodDefault",(e,t)=>{av.init(e,t),me.init(e,t),e._zod.processJSONSchema=(n,r,o)=>H_(e,n,r,o),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function Gw(e,t){return new Uw({type:"default",innerType:e,get defaultValue(){return typeof t=="function"?t():j.shallowClone(t)}})}s(Gw,"_default");var jw=_("ZodPrefault",(e,t)=>{cv.init(e,t),me.init(e,t),e._zod.processJSONSchema=(n,r,o)=>K_(e,n,r,o),e.unwrap=()=>e._zod.def.innerType});function Zw(e,t){return new jw({type:"prefault",innerType:e,get defaultValue(){return typeof t=="function"?t():j.shallowClone(t)}})}s(Zw,"prefault");var jm=_("ZodNonOptional",(e,t)=>{uv.init(e,t),me.init(e,t),e._zod.processJSONSchema=(n,r,o)=>B_(e,n,r,o),e.unwrap=()=>e._zod.def.innerType});function qw(e,t){return new jm({type:"nonoptional",innerType:e,...j.normalizeParams(t)})}s(qw,"nonoptional");var Bw=_("ZodSuccess",(e,t)=>{lv.init(e,t),me.init(e,t),e._zod.processJSONSchema=(n,r,o)=>P_(e,n,r,o),e.unwrap=()=>e._zod.def.innerType});function SR(e){return new Bw({type:"success",innerType:e})}s(SR,"success");var Vw=_("ZodCatch",(e,t)=>{fv.init(e,t),me.init(e,t),e._zod.processJSONSchema=(n,r,o)=>J_(e,n,r,o),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function Hw(e,t){return new Vw({type:"catch",innerType:e,catchValue:typeof t=="function"?t:j.constantCatch(t)})}s(Hw,"_catch");var Kw=_("ZodNaN",(e,t)=>{dv.init(e,t),me.init(e,t),e._zod.processJSONSchema=(n,r,o)=>O_(e,n,r,o)});function bR(e){return r_(Kw,e)}s(bR,"nan");var Ol=_("ZodPipe",(e,t)=>{Tp.init(e,t),me.init(e,t),e._zod.processJSONSchema=(n,r,o)=>W_(e,n,r,o),e.in=t.in,e.out=t.out});function ym(e,t){return new Ol({type:"pipe",in:e,out:t})}s(ym,"pipe");var Rl=_("ZodCodec",(e,t)=>{Ol.init(e,t),cl.init(e,t)});function vR(e,t,n){return new Rl({type:"pipe",in:e,out:t,transform:n.decode,reverseTransform:n.encode})}s(vR,"codec");function _R(e){let t=e._zod.def;return new Rl({type:"pipe",in:t.out,out:t.in,transform:t.reverseTransform,reverseTransform:t.transform})}s(_R,"invertCodec");var Jw=_("ZodPreprocess",(e,t)=>{Ol.init(e,t),pv.init(e,t)}),Ww=_("ZodReadonly",(e,t)=>{mv.init(e,t),me.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Y_(e,n,r,o),e.unwrap=()=>e._zod.def.innerType});function Yw(e){return new Ww({type:"readonly",innerType:e})}s(Yw,"readonly");var Xw=_("ZodTemplateLiteral",(e,t)=>{hv.init(e,t),me.init(e,t),e._zod.processJSONSchema=(n,r,o)=>R_(e,n,r,o)});function wR(e,t){return new Xw({type:"template_literal",parts:e,...j.normalizeParams(t)})}s(wR,"templateLiteral");var Qw=_("ZodLazy",(e,t)=>{ul.init(e,t),me.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Q_(e,n,r,o),e.unwrap=()=>e._zod.def.getter()});function eE(e){return new Qw({type:"lazy",getter:e})}s(eE,"lazy");var tE=_("ZodPromise",(e,t)=>{xv.init(e,t),me.init(e,t),e._zod.processJSONSchema=(n,r,o)=>X_(e,n,r,o),e.unwrap=()=>e._zod.def.innerType});function ER(e){return new tE({type:"promise",innerType:e})}s(ER,"promise");var nE=_("ZodFunction",(e,t)=>{gv.init(e,t),me.init(e,t),e._zod.processJSONSchema=(n,r,o)=>D_(e,n,r,o)});function IR(e){return new nE({type:"function",input:Array.isArray(e?.input)?Rw(e?.input):e?.input??Tl(xi()),output:e?.output??xi()})}s(IR,"_function");var $l=_("ZodCustom",(e,t)=>{yv.init(e,t),me.init(e,t),e._zod.processJSONSchema=(n,r,o)=>N_(e,n,r,o)});function TR(e){let t=new ze({check:"custom"});return t._zod.check=e,t}s(TR,"check");function kR(e,t){return i_($l,e??(()=>!0),t)}s(kR,"custom");function rE(e,t={}){return a_($l,e,t)}s(rE,"refine");function oE(e,t){return c_(e,t)}s(oE,"superRefine");var AR=u_,CR=l_,sE=_("ZodInstanceOf",(e,t)=>{$l.init(e,t)},{properties(e,t){return this.check(Xa(e,t))}});function OR(e,t={}){let n=new sE({type:"custom",check:"custom",fn:s(r=>r instanceof e,"fn"),abort:!0,...j.normalizeParams(t)});return n._zod.bag.Class=e,n._zod.check=r=>{r.value instanceof e||r.issues.push({code:"invalid_type",expected:e.name,input:r.value,inst:n,path:[...n._zod.def.path??[]]})},n}s(OR,"_instanceof");var RR=s((...e)=>f_({Codec:Rl,Boolean:dc,String:lc},...e),"stringbool");function $R(e){let t=eE(()=>mc([_l(e),hw(),gw(),bw(),Tl(t),$w(_l(),t)]));return t}s($R,"json");function PR(e,t){return new Jw({type:"pipe",in:Um(e),out:t})}s(PR,"preprocess");var V4={invalid_type:"invalid_type",too_big:"too_big",too_small:"too_small",invalid_format:"invalid_format",not_multiple_of:"not_multiple_of",unrecognized_keys:"unrecognized_keys",invalid_union:"invalid_union",invalid_key:"invalid_key",invalid_element:"invalid_element",invalid_value:"invalid_value",custom:"custom"};function H4(e){rt({customError:e})}s(H4,"setErrorMap");function K4(){return rt().customError}s(K4,"getErrorMap");var iE;iE||(iE={});var Pl={};$t(Pl,{ZodISODate:()=>bs,ZodISODateTime:()=>Ss,ZodISODuration:()=>_s,ZodISOTime:()=>vs,date:()=>W4,datetime:()=>J4,duration:()=>X4,time:()=>Y4});function J4(e){return gl(Ss,e)}s(J4,"datetime");function W4(e){return xl(bs,e)}s(W4,"date");function Y4(e){return yl(vs,e)}s(Y4,"time");function X4(e){return Sl(_s,e)}s(X4,"duration");var F={...hc,...hm,iso:Pl},Q4=new Set(["$schema","$ref","$defs","definitions","$id","id","$comment","$anchor","$vocabulary","$dynamicRef","$dynamicAnchor","type","enum","const","anyOf","oneOf","allOf","not","properties","required","additionalProperties","patternProperties","propertyNames","minProperties","maxProperties","items","prefixItems","additionalItems","minItems","maxItems","uniqueItems","contains","minContains","maxContains","minLength","maxLength","pattern","format","minimum","maximum","exclusiveMinimum","exclusiveMaximum","multipleOf","description","default","contentEncoding","contentMediaType","contentSchema","unevaluatedItems","unevaluatedProperties","if","then","else","dependentSchemas","dependentRequired","nullable","readOnly"]);function e6(e,t){let n=e.$schema;return n==="https://json-schema.org/draft/2020-12/schema"?"draft-2020-12":n==="http://json-schema.org/draft-07/schema#"?"draft-7":n==="http://json-schema.org/draft-04/schema#"?"draft-4":t??"draft-2020-12"}s(e6,"detectVersion");function NR(e,t){return e.map((n,r)=>r<t?n:n.optional())}s(NR,"applyMinItems");function t6(e){return e.replace(/~1/g,"/").replace(/~0/g,"~")}s(t6,"decodeJSONPointerSegment");function n6(e,t){if(!e.startsWith("#"))throw new Error("External $ref is not supported, only local refs (#/...) are allowed");let n=e.slice(1).split("/").filter(Boolean);if(n.length===0)return t.rootSchema;let r=t.version==="draft-2020-12"?"$defs":"definitions";if(n[0]===r){let o=n[1]===void 0?void 0:t6(n[1]);if(!o||!t.defs[o])throw new Error(`Reference not found: ${e}`);return t.defs[o]}throw new Error(`Reference not found: ${e}`)}s(n6,"resolveRef");function r6(e,t){return F.transform(r=>r).check(r=>{let o=r.value;if(typeof o!="object"||o===null||Array.isArray(o))return;let i=Object.getOwnPropertyNames(o);if(t.minProperties!==void 0&&i.length<t.minProperties&&r.issues.push({origin:"object",code:"too_small",minimum:t.minProperties,inclusive:!0,message:`Too small: expected object to have >=${t.minProperties} properties`,input:o,inst:e,continue:!0}),t.maxProperties!==void 0&&i.length>t.maxProperties&&r.issues.push({origin:"object",code:"too_big",maximum:t.maxProperties,inclusive:!0,message:`Too big: expected object to have <=${t.maxProperties} properties`,input:o,inst:e,continue:!0}),t.keySchema)for(let a of i){let c=t.keySchema.safeParse(a);c.success||r.issues.push({code:"invalid_key",origin:"record",issues:c.error.issues,input:a,path:[a],continue:!0})}}).pipe(e)}s(r6,"checkObjectGuards");function aE(e,t){if(e===null)return"z";let n=typeof e;if(n!=="object"){if(n==="number"&&Number.isNaN(e))return null;let r=String(e);return`${n[0]}${r.length}:${r}`}if(t.has(e))return null;t.add(e);try{if(Array.isArray(e)){let i=[];for(let a of e){let c=aE(a,t);if(c===null)return null;i.push(c)}return`a${i.length}:[${i.join(",")}]`}let r=Object.keys(e).sort(),o=[];for(let i of r){let a=aE(e[i],t);if(a===null)return null;o.push(`${i.length}:${i}=${a}`)}return`o${o.length}:{${o.join(",")}}`}finally{t.delete(e)}}s(aE,"canonicalKey");var o6=new Set(["items","prefixItems","additionalItems","additionalProperties","contains","propertyNames","not","if","then","else","allOf","anyOf","oneOf","unevaluatedItems","unevaluatedProperties","contentSchema"]),s6=new Set(["properties","patternProperties","dependentSchemas","dependencies","$defs","definitions"]);function Nl(e){return typeof e!="object"||e===null?!1:Array.isArray(e)?e.some(Nl):typeof e.$ref=="string"?!0:Object.entries(e).some(([t,n])=>o6.has(t)?Nl(n):!s6.has(t)||typeof n!="object"||n===null?!1:Object.values(n).some(Nl))}s(Nl,"containsRef");function DR(e){return e===1?"element":"elements"}s(DR,"plural");function i6(e,t){return F.transform(r=>r).check(r=>{let o=r.value;if(Array.isArray(o)){if(t.uniqueItems===!0){let i=new Map;for(let a=0;a<o.length;a++){let c=aE(o[a],new Set);if(c===null)continue;let l=i.get(c);if(l===void 0){i.set(c,a);continue}r.issues.push({code:"custom",message:`Array items must be unique: element at index ${a} duplicates the one at index ${l}`,input:o,path:[a],continue:!0})}}if(t.containsSchema){let i=t.minContains??1,a=t.maxContains!==void 0?t.maxContains+1:Number.POSITIVE_INFINITY,c=0;for(let l of o)if(t.containsSchema.safeParse(l).success&&++c>=a)break;c<i&&r.issues.push({code:"custom",message:`Array must contain at least ${i} matching ${DR(i)}; found ${c}`,input:o,continue:!0}),t.maxContains!==void 0&&c>t.maxContains&&r.issues.push({code:"custom",message:`Array must contain at most ${t.maxContains} matching ${DR(t.maxContains)}`,input:o,continue:!0})}}}).pipe(e)}s(i6,"checkArrayGuards");function LR(e,t){if(e!==!1)return e===void 0||e===!0?F.any():nn(e,t)}s(LR,"getTupleRest");var a6=/^(?:[01]\d|2[0-3]):[0-5]\d:[0-5]\d(?:\.\d+)?(?:Z|[+-](?:[01]\d|2[0-3]):[0-5]\d)$/;function FR(e,t){if(e.not!==void 0){if(typeof e.not=="object"&&Object.keys(e.not).length===0)return F.never();throw new Error("not is not supported in Zod (except { not: {} } for never)")}if(e.unevaluatedItems!==void 0)throw new Error("unevaluatedItems is not supported");if(e.unevaluatedProperties!==void 0)throw new Error("unevaluatedProperties is not supported");if(e.if!==void 0||e.then!==void 0||e.else!==void 0)throw new Error("Conditional schemas (if/then/else) are not supported");if(e.dependentSchemas!==void 0||e.dependentRequired!==void 0)throw new Error("dependentSchemas and dependentRequired are not supported");if(e.$ref){let o=e.$ref;if(t.refs.has(o))return t.refs.get(o);if(t.processing.has(o))return F.lazy(()=>{if(!t.refs.has(o))throw new Error(`Circular reference not resolved: ${o}`);return t.refs.get(o)});t.processing.add(o);let i=n6(o,t),a=nn(i,t);return t.refs.set(o,a),t.processing.delete(o),a}if(e.enum!==void 0){let o=e.enum;if(t.version==="openapi-3.0"&&e.nullable===!0&&o.length===1&&o[0]===null)return F.null();if(o.length===0)return F.never();if(o.length===1)return F.literal(o[0]);if(o.every(a=>typeof a=="string"))return F.enum(o);let i=o.map(a=>F.literal(a));return i.length<2?i[0]:F.union([i[0],i[1],...i.slice(2)])}if(e.const!==void 0)return F.literal(e.const);let n=e.type;if(Array.isArray(n)){let o=n.map(i=>{let a={...e,type:i};return FR(a,t)});return o.length===0?F.never():o.length===1?o[0]:F.union(o)}if(!n)return F.any();let r;switch(n){case"string":{let o=F.string();if(e.format){let i=e.format;i==="email"?o=o.check(F.email()):i==="uri"||i==="uri-reference"?o=o.check(F.url()):i==="uuid"||i==="guid"?o=o.check(F.uuid()):i==="date-time"?o=o.check(F.iso.datetime({offset:!0})):i==="date"?o=o.check(F.iso.date()):i==="time"?o=o.check(F.regex(a6)):i==="duration"?o=o.check(F.iso.duration()):i==="hostname"?o=o.check(F.hostname()):i==="ipv4"?o=o.check(F.ipv4()):i==="ipv6"?o=o.check(F.ipv6()):i==="mac"?o=o.check(F.mac()):i==="cidr"?o=o.check(F.cidrv4()):i==="cidr-v6"?o=o.check(F.cidrv6()):i==="base64"?o=o.check(F.base64()):i==="base64url"?o=o.check(F.base64url()):i==="e164"?o=o.check(F.e164()):i==="credit_card"?o=o.check(F.creditCard()):i==="iban"?o=o.check(F.iban()):i==="jwt"?o=o.check(F.jwt()):i==="emoji"?o=o.check(F.emoji()):i==="nanoid"?o=o.check(F.nanoid()):i==="cuid"?o=o.check(F.cuid()):i==="cuid2"?o=o.check(F.cuid2()):i==="ulid"?o=o.check(F.ulid()):i==="xid"?o=o.check(F.xid()):i==="ksuid"&&(o=o.check(F.ksuid()))}typeof e.minLength=="number"&&(o=o.min(e.minLength)),typeof e.maxLength=="number"&&(o=o.max(e.maxLength)),e.pattern&&(o=o.regex(new RegExp(e.pattern))),r=o;break}case"number":case"integer":{let o=n==="integer"?F.number().int():F.number();typeof e.minimum=="number"&&e.exclusiveMinimum!==!0&&(o=o.min(e.minimum)),typeof e.maximum=="number"&&e.exclusiveMaximum!==!0&&(o=o.max(e.maximum)),typeof e.exclusiveMinimum=="number"?o=o.gt(e.exclusiveMinimum):e.exclusiveMinimum===!0&&typeof e.minimum=="number"&&(o=o.gt(e.minimum)),typeof e.exclusiveMaximum=="number"?o=o.lt(e.exclusiveMaximum):e.exclusiveMaximum===!0&&typeof e.maximum=="number"&&(o=o.lt(e.maximum)),typeof e.multipleOf=="number"&&(o=o.multipleOf(e.multipleOf)),r=o;break}case"boolean":{r=F.boolean();break}case"null":{r=F.null();break}case"object":{let o={},i=e.properties||{},a=new Set(e.required||[]),c=typeof e.additionalProperties=="object"?nn(e.additionalProperties,t):void 0;for(let[d,p]of Object.entries(i)){let m=nn(p,t);Pt(o,d,a.has(d)?m:m.optional())}if(e.patternProperties){let d=e.patternProperties,p=Object.keys(d),m=[];for(let x of p){let S=nn(d[x],t),T=F.string().regex(new RegExp(x));m.push(F.looseRecord(T,S))}let h=[];if(Object.keys(o).length>0&&h.push(F.object(o).passthrough()),h.push(...m),h.length===0)r=F.object({}).passthrough();else if(h.length===1)r=h[0];else{let x=F.intersection(h[0],h[1]);for(let S=2;S<h.length;S++)x=F.intersection(x,h[S]);r=x}if(e.additionalProperties===!1){let x=Object.keys(o),S=p.map(b=>new RegExp(b)),T=r;r=r.check(b=>{if(!Kn(b.value))return;let v=[];for(let C of Object.keys(b.value))x.includes(C)||S.some(w=>w.test(C))||v.push(C);v.length&&b.issues.push({code:"unrecognized_keys",keys:v,input:b.value,inst:T})})}}else{let d=F.object(o);e.additionalProperties===!1?r=d.strict():c?r=d.catchall(c):r=d.passthrough()}let l=e.propertyNames!==void 0&&e.propertyNames!==!0,u=typeof e.minProperties=="number"?e.minProperties:void 0,f=typeof e.maxProperties=="number"?e.maxProperties:void 0;if(l||u!==void 0||f!==void 0){let d;if(l){let p=typeof e.propertyNames=="object"&&e.propertyNames.type===void 0?{type:"string",...e.propertyNames}:e.propertyNames;d=nn(p,t)}r=r6(r,{keySchema:d,minProperties:u,maxProperties:f})}break}case"array":{let o=e.prefixItems,i=e.items;if(o&&Array.isArray(o)){let a=typeof e.minItems=="number"?e.minItems:0,c=o.map(d=>nn(d,t)),l=NR(c,a),u=Array.isArray(i)?void 0:LR(i,t),f=F.tuple(l);r=u?f.rest(u):f,typeof e.minItems=="number"&&(r=r.check(F.minLength(e.minItems))),typeof e.maxItems=="number"&&(r=r.check(F.maxLength(e.maxItems)))}else if(Array.isArray(i)){let a=typeof e.minItems=="number"?e.minItems:0,c=i.map(d=>nn(d,t)),l=NR(c,a),u=LR(e.additionalItems,t),f=F.tuple(l);r=u?f.rest(u):f,typeof e.minItems=="number"&&(r=r.check(F.minLength(e.minItems))),typeof e.maxItems=="number"&&(r=r.check(F.maxLength(e.maxItems)))}else if(i!==void 0){let a=nn(i,t),c=F.array(a);typeof e.minItems=="number"&&(c=c.min(e.minItems)),typeof e.maxItems=="number"&&(c=c.max(e.maxItems)),r=c}else r=F.array(F.any());(e.uniqueItems===!0||e.contains!==void 0)&&(r=i6(r,{uniqueItems:e.uniqueItems===!0,containsSchema:e.contains!==void 0?nn(e.contains,t):void 0,minContains:typeof e.minContains=="number"?e.minContains:void 0,maxContains:typeof e.maxContains=="number"?e.maxContains:void 0}));break}default:throw new Error(`Unsupported type: ${n}`)}return r}s(FR,"convertBaseSchema");function nn(e,t){if(typeof e=="boolean")return e?F.any():F.never();let n=FR(e,t),r=e.type||e.enum!==void 0||e.const!==void 0;if(e.anyOf&&Array.isArray(e.anyOf)){let c=e.anyOf.map(u=>nn(u,t)),l=F.union(c);n=r?F.intersection(n,l):l}if(e.oneOf&&Array.isArray(e.oneOf)){let c=e.oneOf.map(u=>nn(u,t)),l=F.xor(c);n=r?F.intersection(n,l):l}if(e.allOf&&Array.isArray(e.allOf))if(e.allOf.length===0)n=r?n:F.any();else{let c=r?n:nn(e.allOf[0],t),l=r?0:1;for(let u=l;u<e.allOf.length;u++)c=F.intersection(c,nn(e.allOf[u],t));n=c}e.nullable===!0&&t.version==="openapi-3.0"&&(n=F.nullable(n)),e.readOnly===!0&&(n=F.readonly(n)),e.default!==void 0&&(n=n.default(e.default));let o={},i=["$id","id","$comment","$anchor","$vocabulary","$dynamicRef","$dynamicAnchor"];for(let c of i)c in e&&(o[c]=e[c]);let a=["contentEncoding","contentMediaType","contentSchema"];for(let c of a)c in e&&(o[c]=e[c]);if(e.type==="object"&&e.$ref===void 0){e.propertyNames!==void 0&&!Nl(e.propertyNames)&&(o.propertyNames=e.propertyNames);for(let c of["minProperties","maxProperties"])e[c]!==void 0&&(o[c]=e[c])}if(e.type==="array"&&e.$ref===void 0){e.contains!==void 0&&!Nl(e.contains)&&(o.contains=e.contains);for(let c of["uniqueItems","minContains","maxContains"])e[c]!==void 0&&(o[c]=e[c])}for(let c of Object.keys(e))Q4.has(c)||Pt(o,c,e[c]);return Object.keys(o).length>0&&t.registry.add(n,o),e.description&&(n=n.describe(e.description)),n}s(nn,"convertSchema");function zR(e,t){if(typeof e=="boolean")return e?F.any():F.never();let n;try{n=JSON.parse(JSON.stringify(e))}catch{throw new Error("fromJSONSchema input is not valid JSON (possibly cyclic); use $defs/$ref for recursive schemas")}let r=e6(n,t?.defaultTarget),o=n.$defs||n.definitions||{},i={version:r,defs:o,refs:new Map,processing:new Set,rootSchema:n,registry:t?.registry??Nt};return nn(n,i)}s(zR,"fromJSONSchema");var MR=Symbol("z.visit/resolving");function Dl(e,t){let n=typeof t=="function"?t:(a,c)=>{let l=t[a._zod.def.type];return l?l(a,c):a},r=new Map;function o(a){let c=r.get(a);if(c===MR)return new ul({type:"lazy",getter:s(()=>r.get(a),"getter")});if(c!==void 0)return c;r.set(a,MR);let l=i(a),u=n(l,l!==a);return r.set(a,u),u}s(o,"run");function i(a){let c=a._zod.def,l=c.type;switch(l){case"object":{let u=c.shape,f=Object.keys(u),d=!1,p={};for(let h of f){let x=o(u[h]);x!==u[h]&&(d=!0),p[h]=x}let m=c.catchall;return c.catchall&&(m=o(c.catchall),m!==c.catchall&&(d=!0)),d?Pe(a,{...c,shape:p,catchall:m}):a}case"array":{let u=o(c.element);return u===c.element?a:Pe(a,{...c,element:u})}case"tuple":{let u=c.items,f=!1,d=[];for(let m of u){let h=o(m);h!==m&&(f=!0),d.push(h)}let p=c.rest;return c.rest&&(p=o(c.rest),p!==c.rest&&(f=!0)),f?Pe(a,{...c,items:d,rest:p}):a}case"record":case"map":{let u=o(c.keyType),f=o(c.valueType);return u===c.keyType&&f===c.valueType?a:Pe(a,{...c,keyType:u,valueType:f})}case"set":{let u=o(c.valueType);return u===c.valueType?a:Pe(a,{...c,valueType:u})}case"union":{let u=c.options,f=!1,d=[];for(let p of u){let m=o(p);m!==p&&(f=!0),d.push(m)}return f?Pe(a,{...c,options:d}):a}case"intersection":{let u=o(c.left),f=o(c.right);return u===c.left&&f===c.right?a:Pe(a,{...c,left:u,right:f})}case"optional":case"nullable":case"default":case"prefault":case"catch":case"readonly":case"nonoptional":case"promise":case"success":{let u=o(c.innerType);return u===c.innerType?a:Pe(a,{...c,innerType:u})}case"pipe":{let u=o(c.in),f=o(c.out);return u===c.in&&f===c.out?a:Pe(a,{...c,in:u,out:f})}case"function":{let u=o(c.input),f=o(c.output);return u===c.input&&f===c.output?a:Pe(a,{...c,input:u,output:f})}case"lazy":{let u=c.getter,{_cachedInner:f,...d}=c;return Pe(a,{...d,getter:s(()=>o(u()),"getter")})}case"template_literal":case"string":case"number":case"int":case"boolean":case"bigint":case"symbol":case"undefined":case"null":case"void":case"never":case"any":case"unknown":case"date":case"nan":case"enum":case"literal":case"file":case"transform":case"custom":return a;default:return a}}return s(i,"mapInner"),o(e)}s(Dl,"visit");function UR(e){return Dl(e,{object:s(t=>t.partial(),"object"),union:s(t=>{let n=t._zod.def;return n.discriminator===void 0?t:mc(n.options)},"union")})}s(UR,"deepPartial");function c6(e,t){if(!t?.length)return e;let n=e._zod.def;return Pe(e,hr(n,{checks:[...n.checks??[],...t]}),{parent:!0})}s(c6,"withChecks");function GR(e){return c6(e.out,e.checks)}s(GR,"outSide");function u6(e){return e.in._zod.traits.has("$ZodTransform")?GR(e):e.in}s(u6,"inSide");function jR(e){return Dl(e,{pipe:s(t=>u6(t._zod.def),"pipe"),default:s((t,n)=>n?yi(t._zod.def.innerType):t,"default"),catch:s((t,n)=>n?t._zod.def.innerType:t,"catch")})}s(jR,"input");function ZR(e){return Dl(e,{pipe:s(t=>GR(t._zod.def),"pipe"),prefault:s((t,n)=>n?t._zod.def.innerType:t,"prefault")})}s(ZR,"output");var cE={};$t(cE,{bigint:()=>p6,boolean:()=>d6,date:()=>m6,number:()=>f6,string:()=>l6});function l6(e){return Ov(lc,e)}s(l6,"string");function f6(e){return Lv(fc,e)}s(f6,"number");function d6(e){return Zv(dc,e)}s(d6,"boolean");function p6(e){return Bv(pc,e)}s(p6,"bigint");function m6(e){return n_(Il,e)}s(m6,"date");var be=s((e,t)=>{switch(t.length){case 0:return e;case 1:return t[0](e);case 2:return t[1](t[0](e));case 3:return t[2](t[1](t[0](e)));case 4:return t[3](t[2](t[1](t[0](e))));case 5:return t[4](t[3](t[2](t[1](t[0](e)))));case 6:return t[5](t[4](t[3](t[2](t[1](t[0](e))))));case 7:return t[6](t[5](t[4](t[3](t[2](t[1](t[0](e)))))));case 8:return t[7](t[6](t[5](t[4](t[3](t[2](t[1](t[0](e))))))));case 9:return t[8](t[7](t[6](t[5](t[4](t[3](t[2](t[1](t[0](e)))))))));default:{let n=e;for(let r=0,o=t.length;r<o;r++)n=t[r](n);return n}}},"pipeArguments"),h6={pipe(){return be(this,arguments)}},_i=(function(){function e(){}return s(e,"PipeableBase"),e.prototype=h6,e})();var y=s(function(e,t){if(typeof e=="function")return function(){return e(arguments)?t.apply(this,arguments):n=>t(n,...arguments)};switch(e){case 0:case 1:throw new RangeError(`Invalid arity ${e}`);case 2:return function(n,r){return arguments.length>=2?t(n,r):function(o){return t(o,n)}};case 3:return function(n,r,o){return arguments.length>=3?t(n,r,o):function(i){return t(i,n,r)}};default:return function(){if(arguments.length>=e)return t.apply(this,arguments);let n=arguments;return function(r){return t(r,...n)}}}},"dual");var J=s(e=>e,"identity");var It=s(e=>()=>e,"constant"),Io=It(!0),Zm=It(!1),qm=It(null),Yn=It(void 0),Bm=Yn;function uE(e,...t){return be(e,t)}s(uE,"pipe");function qR(e,t,n,r,o,i,a,c,l){switch(arguments.length){case 1:return e;case 2:return function(){return t(e.apply(this,arguments))};case 3:return function(){return n(t(e.apply(this,arguments)))};case 4:return function(){return r(n(t(e.apply(this,arguments))))};case 5:return function(){return o(r(n(t(e.apply(this,arguments)))))};case 6:return function(){return i(o(r(n(t(e.apply(this,arguments))))))};case 7:return function(){return a(i(o(r(n(t(e.apply(this,arguments)))))))};case 8:return function(){return c(a(i(o(r(n(t(e.apply(this,arguments))))))))};case 9:return function(){return l(c(a(i(o(r(n(t(e.apply(this,arguments)))))))))}}}s(qR,"flow");function Bt(e){let t=new WeakMap;return n=>{let r=t.get(n);if(r!==void 0)return r;let o=e(n);return t.set(n,o),o}}s(Bt,"memoize");function wi(e){let t=new WeakMap;return n=>{let r=t.get(n);if(r!==void 0)return r;let o=e(n);return t.set(n,o),t.set(o,o),o}}s(wi,"memoizeIdempotent");var Ll=s(e=>{let t=new Set(Reflect.ownKeys(e));if(e.constructor===Object)return t;e instanceof Error&&t.delete("stack");let n=Object.getPrototypeOf(e),r=n;for(;r!==null&&r!==Object.prototype;){let o=Reflect.ownKeys(r);for(let i=0;i<o.length;i++)t.add(o[i]);r=Object.getPrototypeOf(r)}return t.has("constructor")&&typeof e.constructor=="function"&&n===e.constructor.prototype&&t.delete("constructor"),t},"getAllObjectKeys"),xc=new WeakSet;function yr(e){return typeof e=="string"}s(yr,"isString");function Fl(e){return typeof e=="number"}s(Fl,"isNumber");function BR(e){return typeof e=="boolean"}s(BR,"isBoolean");function VR(e){return typeof e=="bigint"}s(VR,"isBigInt");function lE(e){return typeof e=="symbol"}s(lE,"isSymbol");function Vm(e){return yr(e)||Fl(e)||lE(e)}s(Vm,"isPropertyKey");function Sn(e){return typeof e=="function"}s(Sn,"isFunction");function HR(e){return e===void 0}s(HR,"isUndefined");function rn(e){return e!==void 0}s(rn,"isNotUndefined");function Hm(e){return e!=null}s(Hm,"isNotNullish");function KR(e){return!1}s(KR,"isNever");function fE(e){return!0}s(fE,"isUnknown");function Sr(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}s(Sr,"isObject");function zl(e){return typeof e=="object"&&e!==null||Sn(e)}s(zl,"isObjectKeyword");var U=y(2,(e,t)=>zl(e)&&t in e),Ei=y(2,(e,t)=>U(e,"_tag")&&e._tag===t);function JR(e){return e instanceof Error}s(JR,"isError");function To(e){return U(e,Symbol.iterator)||yr(e)}s(To,"isIterable");var Te="~effect/interfaces/Hash",pe=s(e=>{switch(typeof e){case"number":return br(e);case"bigint":return Be(e.toString(10));case"boolean":return Be(String(e));case"symbol":return Be(String(e));case"string":return Be(e);case"undefined":return Be("undefined");case"function":case"object":{if(e===null)return Be("null");if(e instanceof Date)return Number.isNaN(e.getTime())?Be("Invalid Date"):Be(e.toISOString());if(e instanceof RegExp)return Be(e.toString());{if(xc.has(e))return Km(e);if(pE.has(e))return pE.get(e);let t=b6(e,()=>x6(e)?e[Te]():typeof e=="function"?Km(e):e instanceof DataView?yc(new Uint8Array(e.buffer,e.byteOffset,e.byteLength)):Array.isArray(e)||ArrayBuffer.isView(e)?yc(e):e instanceof Map?y6(e):e instanceof Set?S6(e):gE(e));return pE.set(e,t),t}}default:throw new Error(`BUG: unhandled typeof ${typeof e} - please report an issue at https://github.com/Effect-TS/effect/issues`)}},"hash"),Km=s(e=>(dE.has(e)||dE.set(e,br(Math.floor(Math.random()*Number.MAX_SAFE_INTEGER))),dE.get(e)),"random"),gt=y(2,(e,t)=>e*53^t),Jm=s(e=>e&3221225471|e>>>1&1073741824,"optimize"),x6=s(e=>U(e,Te),"isHash"),br=s(e=>{if(e!==e)return Be("NaN");if(e===1/0)return Be("Infinity");if(e===-1/0)return Be("-Infinity");let t=e|0;for(t!==e&&(t^=e*4294967295);e>4294967295;)t^=e/=4294967295;return Jm(t)},"number"),Be=s(e=>{let t=5381,n=e.length;for(;n;)t=t*33^e.charCodeAt(--n);return Jm(t)},"string"),hE=s((e,t)=>{let n=12289;for(let r of t)n^=gt(pe(r),pe(e[r]));return Jm(n)},"structureKeys"),gE=s(e=>hE(e,Ll(e)),"structure"),xE=s((e,t)=>n=>{let r=e;for(let o of n)r^=t(o);return Jm(r)},"iterableWith"),yc=xE(6151,pe),y6=xE(Be("Map"),([e,t])=>gt(pe(e),pe(t))),S6=xE(Be("Set"),pe),dE=new WeakMap,pE=new WeakMap,mE=new WeakSet;function b6(e,t){if(mE.has(e))return Be("[Circular]");mE.add(e);let n=t();return mE.delete(e),n}s(b6,"withVisitedTracking");var ke="~effect/interfaces/Equal";function re(){return arguments.length===1?e=>Ii(e,arguments[0]):Ii(arguments[0],arguments[1])}s(re,"equals");function Ii(e,t){if(e===t)return!0;if(e==null||t==null)return!1;let n=typeof e;return n!==typeof t?!1:n==="number"&&e!==e&&t!==t?!0:n!=="object"&&n!=="function"||xc.has(e)||xc.has(t)?!1:w6(e,t,_6)}s(Ii,"compareBoth");function v6(e,t,n){let r=yE.has(e),o=SE.has(t);if(r&&o)return!0;if(r||o)return!1;yE.add(e),SE.add(t);let i=n();return yE.delete(e),SE.delete(t),i}s(v6,"withVisitedTracking");var yE=new WeakSet,SE=new WeakSet;function _6(e,t){if(pe(e)!==pe(t))return!1;if(e instanceof Date){if(!(t instanceof Date))return!1;let i=e.getTime(),a=t.getTime();return i===a||Number.isNaN(i)&&Number.isNaN(a)}else if(e instanceof RegExp)return t instanceof RegExp?e.toString()===t.toString():!1;let n=YR(e),r=YR(t);if(n!==r)return!1;let o=n&&r;return typeof e=="function"&&!o?!1:v6(e,t,()=>{if(o)return e[ke](t);if(Array.isArray(e))return!Array.isArray(t)||e.length!==t.length?!1:E6(e,t);if(ArrayBuffer.isView(e)){let i=e instanceof DataView;if(!ArrayBuffer.isView(t)||e.byteLength!==t.byteLength||i!==t instanceof DataView)return!1;if(i){let a=t;return WR(new Uint8Array(e.buffer,e.byteOffset,e.byteLength),new Uint8Array(a.buffer,a.byteOffset,a.byteLength))}return WR(e,t)}else{if(e instanceof Map)return!(t instanceof Map)||e.size!==t.size?!1:T6(e,t);if(e instanceof Set)return!(t instanceof Set)||e.size!==t.size?!1:k6(e,t)}return I6(e,t)})}s(_6,"compareObjects");function w6(e,t,n){let r=Wm.get(e);if(!r)r=new WeakMap,Wm.set(e,r);else if(r.has(t))return r.get(t);let o=n(e,t);r.set(t,o);let i=Wm.get(t);return i||(i=new WeakMap,Wm.set(t,i)),i.set(e,o),o}s(w6,"withCache");var Wm=new WeakMap;function E6(e,t){for(let n=0;n<e.length;n++)if(!Ii(e[n],t[n]))return!1;return!0}s(E6,"compareArrays");function WR(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}s(WR,"compareTypedArrays");function I6(e,t){let n=Ll(e),r=Ll(t);if(n.size!==r.size)return!1;for(let o of n)if(!r.has(o)||!Ii(e[o],t[o]))return!1;return!0}s(I6,"compareRecords");function Ym(e,t){return s(function(r,o){let i=Array.from(o);for(let[a,c]of r){let l=!1;for(let u=0;u<i.length;u++){let[f,d]=i[u];if(e(a,f)&&t(c,d)){i[u]=i[i.length-1],i.pop(),l=!0;break}}if(!l)return!1}return!0},"compareMaps")}s(Ym,"makeCompareMap");var T6=Ym(Ii,Ii);function Xm(e){return s(function(n,r){let o=Array.from(r);for(let i of n){let a=!1;for(let c=0;c<o.length;c++){let l=o[c];if(e(i,l)){o[c]=o[o.length-1],o.pop(),a=!0;break}}if(!a)return!1}return!0},"compareSets")}s(Xm,"makeCompareSet");var k6=Xm(Ii),YR=s(e=>U(e,ke),"isEqual");var XR=s(e=>(xc.add(e),e),"byReferenceUnsafe");function vr(e,t,n){return{combine:e,initialValue:t,combineAll:n??(r=>{let o=t;for(let i of r)o=e(o,i);return o})}}s(vr,"make");var Tt=s(e=>(t,n)=>t===n||e(t,n),"make"),A6=s((e,t)=>e===t,"isStrictEquivalent"),QR=s(()=>A6,"strictEqual");function e$(e){return Tt((t,n)=>{if(t.length!==n.length)return!1;for(let r=0;r<t.length;r++)if(!e(t[r],n[r]))return!1;return!0})}s(e$,"Array_");var bE=s(e=>e.length>0,"isArrayNonEmpty");var Qm=s(e=>y(3,(t,n,r)=>e(t,o=>({...o,[n]:r(o)}))),"let_"),eh=s(e=>y(2,(t,n)=>e(t,r=>({[n]:r}))),"bindTo"),th=s((e,t)=>y(3,(n,r,o)=>t(n,i=>e(o(i),a=>({...i,[r]:a})))),"bind");function V(e,t,n){t==="__proto__"?Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0}):e[t]=n}s(V,"assignProperty");function nh(e,t){for(let n of Reflect.ownKeys(t))Object.prototype.propertyIsEnumerable.call(t,n)&&V(e,n,t[n])}s(nh,"assignProperties");function rh(e){return{combine:e}}s(rh,"make");function n$(e){return rh((t,n)=>e(t,n)===-1?t:n)}s(n$,"min");function r$(e){return rh((t,n)=>e(t,n)===1?t:n)}s(r$,"max");var oh=Symbol.for("~effect/Redactable"),O6=s(e=>U(e,oh),"isRedactable");function Ml(e){return O6(e)?_E(e):e}s(Ml,"redact");function _E(e){return e[oh](globalThis[bc]?.context??R6)}s(_E,"getRedacted");var bc="~effect/Fiber/currentFiber",o$=new Map,R6={"~effect/Context":{},base:o$,depth:0,mapUnsafe:o$,pipe(){return be(this,arguments)}};function z(e,t){let n=t?.space??0,r=new WeakSet,o=n?typeof n=="number"?" ".repeat(n):n:"",i=s(u=>o.repeat(u),"ind"),a=s((u,f)=>{let d=u?.constructor;return d&&d!==Object.prototype.constructor&&d.name?`${d.name}(${f})`:f},"wrap"),c=s(u=>{try{return Reflect.ownKeys(u)}catch{return["[ownKeys threw]"]}},"ownKeys");function l(u,f=0){if(Array.isArray(u)){if(r.has(u))return s$;r.add(u);let d=!o||u.length<=1?`[${u.map(p=>l(p,f)).join(",")}]`:`[
|
|
69
|
+
${i(f+1)}${u.map(p=>l(p,f+1)).join(`,
|
|
70
|
+
`+i(f+1))}
|
|
71
|
+
${i(f)}]`;return r.delete(u),d}if(u instanceof Date)return wE(u);if(!t?.ignoreToString&&U(u,"toString")&&typeof u.toString=="function"&&u.toString!==Object.prototype.toString&&u.toString!==Array.prototype.toString){let d=P6(u);return u instanceof Error&&u.cause?`${d} (cause: ${l(u.cause,f)})`:d}if(typeof u=="string")return JSON.stringify(u);if(typeof u=="number"||u==null||typeof u=="boolean"||typeof u=="symbol")return String(u);if(typeof u=="bigint")return String(u)+"n";if(typeof u=="object"||typeof u=="function"){if(r.has(u))return s$;r.add(u);let d;if(oh in u)d=z(_E(u));else if(Symbol.iterator in u)d=`${u.constructor.name}(${l(Array.from(u),f)})`;else{let p=c(u);if(!o||p.length<=1){let m=`{${p.map(h=>`${Ao(h)}:${l(u[h],f)}`).join(",")}}`;d=a(u,m)}else{let m=`{
|
|
72
|
+
${p.map(h=>`${i(f+1)}${Ao(h)}: ${l(u[h],f+1)}`).join(`,
|
|
73
|
+
`)}
|
|
74
|
+
${i(f)}}`;d=a(u,m)}}return r.delete(u),d}return String(u)}return s(l,"recur"),l(e,0)}s(z,"format");var s$="[Circular]";function Ao(e){return typeof e=="string"?JSON.stringify(e):String(e)}s(Ao,"formatPropertyKey");function sh(e){return e.map(t=>`[${Ao(t)}]`).join("")}s(sh,"formatPath");function wE(e){try{return e.toISOString()}catch{return"Invalid Date"}}s(wE,"formatDate");function P6(e){try{let t=e.toString();return typeof t=="string"?t:String(t)}catch{return"[toString threw]"}}s(P6,"safeToString");function Ti(e,t){let n=[];return JSON.stringify(e,function(r,o){let i=Ml(o);if(typeof i!="object"||i===null)return i;for(;n.length>0&&n[n.length-1]!==this;)n.pop();if(!n.includes(i))return n.push(i),i},t?.space)??"null"}s(Ti,"formatJson");var yt=Symbol.for("nodejs.util.inspect.custom"),Vt=s(e=>{try{if(U(e,"toJSON")&&Sn(e.toJSON)&&e.toJSON.length===0)return e.toJSON();if(Array.isArray(e))return e.map(Vt)}catch{return"[toJSON threw]"}return Ml(e)},"toJson"),a$=s((e,t=2)=>{if(typeof e=="string")return e;try{return typeof e=="object"?Ti(e,{space:t}):String(e)}catch{return String(e)}},"toStringUnknown"),Toe={toJSON(){return Vt(this)},[yt](){return this.toJSON()},toString(){return z(this.toJSON())}},i$=class{static{s(this,"Class")}[yt](){return this.toJSON()}toString(){return z(this.toJSON())}};var ws=class e{static{s(this,"SingleShotGen")}called=!1;self;constructor(t){this.self=t}next(t){return this.called?{value:t,done:!0}:(this.called=!0,{value:this.self,done:!1})}[Symbol.iterator](){return new e(this.self)}},D6=s(()=>{let e="~effect/Utils/internal",t={[e]:o=>o()},n={[e]:o=>o()};return t[e](()=>new Error().stack)?.includes(e)===!0?t[e]:n[e]},"pickInternalCall"),Ie=D6();var Wr="~effect/Effect",ki="~effect/Exit",F6={_A:J,_E:J,_R:J},l$=`${Wr}/identifier`,ee=`${Wr}/args`,ot=`${Wr}/evaluate`,sn=`${Wr}/successCont`,Xn=`${Wr}/failureCont`,Es=`${Wr}/ensureCont`,Ci=Symbol.for("effect/Effect/Yield"),Co={pipe(){return be(this,arguments)},toJSON(){return{...this}},toString(){return z(this.toJSON(),{ignoreToString:!0,space:2})},[yt](){return this.toJSON()}},f$={[Te](){return hE(this,Object.keys(this))},[ke](e){let t=Object.keys(this),n=Object.keys(e);if(t.length!==n.length)return!1;for(let r=0;r<t.length;r++)if(t[r]!==n[r]||!re(this[t[r]],e[t[r]]))return!1;return!0}},z6={[Wr]:F6,...Co,[Symbol.iterator](){return new ws(this)},toJSON(){return{_id:"Effect",op:this[l$],...ee in this?{args:this[ee]}:void 0}}},oe=s(e=>U(e,Wr),"isEffect"),EE=s(e=>U(e,ki),"isExit"),Ul="~effect/Cause",Gl="~effect/Cause/Reason",wc=s(e=>U(e,Ul),"isCause"),d$=s(e=>U(e,Gl),"isCauseReason"),Kr=class{static{s(this,"CauseImpl")}[Ul];reasons;constructor(t){this[Ul]=Ul,this.reasons=t}pipe(){return be(this,arguments)}toJSON(){return{_id:"Cause",failures:this.reasons.map(t=>t.toJSON())}}toString(){return`Cause(${z(this.reasons)})`}[yt](){return this.toJSON()}[ke](t){return wc(t)&&this.reasons.length===t.reasons.length&&this.reasons.every((n,r)=>re(n,t.reasons[r]))}[Te](){return yc(this.reasons)}},u$=new WeakMap,vc=class{static{s(this,"ReasonBase")}[Gl];annotations;_tag;constructor(t,n,r){if(this[Gl]=Gl,this._tag=t,n!==Zl&&typeof r=="object"&&r!==null&&n.size>0){let o=u$.get(r);o&&(n=new Map([...o,...n])),u$.set(r,n)}this.annotations=n}annotate(t,n){if(t.mapUnsafe.size===0)return this;let r=new Map(this.annotations);t.mapUnsafe.forEach((i,a)=>{n?.overwrite!==!0&&r.has(a)||r.set(a,i)});let o=Object.assign(Object.create(Object.getPrototypeOf(this)),this);return o.annotations=r,o}pipe(){return be(this,arguments)}toString(){return z(this)}[yt](){return this.toString()}},Zl=new Map,Ai=class extends vc{static{s(this,"Fail")}error;constructor(t,n=Zl){super("Fail",n,t),this.error=t}toString(){return`Fail(${z(this.error)})`}toJSON(){return{_tag:"Fail",error:this.error}}[ke](t){return Oi(t)&&re(this.error,t.error)&&re(this.annotations,t.annotations)}[Te](){return gt(Be(this._tag))(gt(pe(this.error))(pe(this.annotations)))}},Oo=s(e=>new Kr(e),"causeFromReasons"),ah=new Kr([]),p$=s(e=>new Kr([new Ai(e)]),"causeFail"),jl=class extends vc{static{s(this,"Die")}defect;constructor(t,n=Zl){super("Die",n,t),this.defect=t}toString(){return`Die(${z(this.defect)})`}toJSON(){return{_tag:"Die",defect:this.defect}}[ke](t){return Bl(t)&&re(this.defect,t.defect)&&re(this.annotations,t.annotations)}[Te](){return gt(Be(this._tag))(gt(pe(this.defect))(pe(this.annotations)))}},m$=s(e=>new Kr([new jl(e)]),"causeDie"),ql=y(e=>wc(e[0]),(e,t,n)=>t.mapUnsafe.size===0?e:new Kr(e.reasons.map(r=>r.annotate(t,n)))),Oi=s(e=>e._tag==="Fail","isFailReason"),Bl=s(e=>e._tag==="Die","isDieReason"),ch=s(e=>e._tag==="Interrupt","isInterruptReason");function M6(e){return Xr("Effect.evaluate: Not implemented")}s(M6,"defaultEvaluate");var Ro=s(e=>({...z6,[l$]:e.op,[ot]:e[ot]??M6,[sn]:e[sn],[Xn]:e[Xn],[Es]:e[Es]}),"makePrimitiveProto"),Qn=s(e=>{let t=Ro(e);return function(){let n=Object.create(t);return n[ee]=e.single===!1?arguments:arguments[0],n}},"makePrimitive"),h$=s(e=>{let t={[ki]:ki,_tag:e.op,get[e.prop](){return this[ee]},...Ro(e),toString(){return`${e.op}(${z(this[ee])})`},toJSON(){return{_id:"Exit",_tag:e.op,[e.prop]:this[ee]}},[ke](n){return EE(n)&&n._tag===this._tag&&re(this[ee],n[ee])},[Te](){return gt(Be(e.op),pe(this[ee]))}};return function(n){let r=Object.create(t);return r[ee]=n,r}},"makeExit"),St=h$({op:"Success",prop:"value",[ot](e){let t=e.getCont(sn);return t?t[sn](this[ee],e,this):e.yieldWith(this)}}),uh={key:"effect/Cause/StackTrace"},IE={key:"effect/Cause/InterruptorStackTrace"},Dn=h$({op:"Failure",prop:"cause",[ot](e){let t=this[ee],n=!1;e.currentStackFrame&&(t=ql(t,{mapUnsafe:new Map([[uh.key,e.currentStackFrame]])}),n=!0);let r=e.getCont(Xn);for(;e.interruptible&&e._interruptedCause&&r;)r=e.getCont(Xn);return r?r[Xn](t,e,n?void 0:this):e.yieldWith(n?Dn(t):this)}}),Yr=s(e=>Dn(p$(e)),"exitFail"),Xr=s(e=>Dn(m$(e)),"exitDie"),fe=Qn({op:"WithFiber",[ot](e){return this[ee](e)}}),U6=(function(){class e extends globalThis.Error{static{s(this,"YieldableError")}}let t=Ro({op:"YieldableError",[ot](){return Yr(this)}});return delete t.toString,Object.assign(e.prototype,t),e})(),lh=(function(){let e=Symbol.for("effect/Data/Error/plainArgs");return class extends U6{static{s(this,"Base")}constructor(n){super(n?.message,n?.cause?{cause:n.cause}:void 0),n&&(nh(this,n),Object.defineProperty(this,e,{value:n,enumerable:!1}))}toJSON(){return{...this[e],...this}}}})(),$o=s(e=>{class t extends lh{static{s(this,"Base")}_tag=e}return t.prototype.name=e,t},"TaggedError"),ih="~effect/Cause/NoSuchElementError",TE=s(e=>U(e,ih),"isNoSuchElementError"),Jr=class extends $o("NoSuchElementError"){static{s(this,"NoSuchElementError")}[ih]=ih;constructor(t){super({message:t})}},_c="~effect/Cause/Done",Vl=s(e=>U(e,_c),"isDone"),g$={[_c]:_c,_tag:"Done",value:void 0},x$=s(e=>e===void 0?g$:{[_c]:_c,_tag:"Done",value:e},"Done"),G6=Yr(g$),y$=s(e=>e===void 0?G6:Yr(x$(e)),"done");var S$="~effect/data/Option",b$={[S$]:{_A:s(e=>e,"_A")},...Co,[Symbol.iterator](){return new ws(this)}},j6=Object.defineProperty(Object.assign(Object.create(b$),{_tag:"Some",_op:"Some",[ke](e){return fh(e)&&kE(e)&&re(this.value,e.value)},[Te](){return gt(pe(this._tag))(pe(this.value))},toString(){return`some(${z(this.value)})`},toJSON(){return{_id:"Option",_tag:this._tag,value:Vt(this.value)}}}),"valueOrUndefined",{get(){return this.value}}),Z6=pe("None"),q6=Object.assign(Object.create(b$),{_tag:"None",_op:"None",valueOrUndefined:void 0,[ke](e){return fh(e)&&Ts(e)},[Te](){return Z6},toString(){return"none()"},toJSON(){return{_id:"Option",_tag:this._tag}}}),fh=s(e=>U(e,S$),"isOption"),Ts=s(e=>e._tag==="None","isNone"),kE=s(e=>e._tag==="Some","isSome"),Ri=Object.create(q6),Po=s(e=>{let t=Object.create(j6);return t.value=e,t},"some");var v$="~effect/data/Result",_$={[v$]:{_A:s(e=>e,"_A"),_E:s(e=>e,"_E")},...Co,[Symbol.iterator](){return new ws(this)}},B6=Object.assign(Object.create(_$),{_tag:"Success",_op:"Success",[ke](e){return dh(e)&&mh(e)&&re(this.success,e.success)},[Te](){return gt(pe(this._tag))(pe(this.success))},toString(){return`success(${z(this.success)})`},toJSON(){return{_id:"Result",_tag:this._tag,value:Vt(this.success)}}}),V6=Object.assign(Object.create(_$),{_tag:"Failure",_op:"Failure",[ke](e){return dh(e)&&ph(e)&&re(this.failure,e.failure)},[Te](){return gt(pe(this._tag))(pe(this.failure))},toString(){return`failure(${z(this.failure)})`},toJSON(){return{_id:"Result",_tag:this._tag,failure:Vt(this.failure)}}}),dh=s(e=>U(e,v$),"isResult"),ph=s(e=>e._tag==="Failure","isFailure"),mh=s(e=>e._tag==="Success","isSuccess"),CE=s(e=>{let t=Object.create(V6);return t.failure=e,t},"fail"),OE=s(e=>{let t=Object.create(B6);return t.success=e,t},"succeed"),w$=s(e=>mh(e)?Ri:Po(e.failure),"getFailure"),E$=s(e=>ph(e)?Ri:Po(e.success),"getSuccess"),I$=y(2,(e,t)=>Ts(e)?CE(t()):OE(e.value));function No(e){return(t,n)=>t===n?0:e(t,n)}s(No,"make");var Ln=No((e,t)=>globalThis.Number.isNaN(e)&&globalThis.Number.isNaN(t)?0:globalThis.Number.isNaN(e)?-1:globalThis.Number.isNaN(t)?1:e<t?-1:1);var er=No((e,t)=>e<t?-1:1);var RE=y(2,(e,t)=>No((n,r)=>e(t(n),t(r)))),$i=RE(Ln,e=>e.getTime());var Qr=s(e=>y(2,(t,n)=>e(t,n)===-1),"isLessThan"),tr=s(e=>y(2,(t,n)=>e(t,n)===1),"isGreaterThan"),ks=s(e=>y(2,(t,n)=>e(t,n)!==1),"isLessThanOrEqualTo"),As=s(e=>y(2,(t,n)=>e(t,n)!==-1),"isGreaterThanOrEqualTo"),Ec=s(e=>y(2,(t,n)=>t===n||e(t,n)<1?t:n),"min"),Ic=s(e=>y(2,(t,n)=>t===n||e(t,n)>-1?t:n),"max"),Hl=s(e=>y(2,(t,n)=>Ec(e)(n.maximum,Ic(e)(n.minimum,t))),"clamp"),Kl=s(e=>y(2,(t,n)=>!Qr(e)(t,n.minimum)&&!tr(e)(t,n.maximum)),"isBetween");var te=s(()=>Ri,"none"),H=Po,hh=fh,Xe=Ts,an=kE,_r=y(2,(e,{onNone:t,onSome:n})=>Xe(e)?t():n(e.value));var gh=y(2,(e,t)=>Xe(e)?t():e.value);var T$=s(e=>e==null?te():H(e),"fromNullishOr"),k$=s(e=>e===void 0?te():H(e),"fromUndefinedOr"),A$=s(e=>e===null?te():H(e),"fromNullOr");var $E=gh(qm),Ni=gh(Yn),Di=s(e=>(...t)=>{try{return H(e(...t))}catch{return te()}},"liftThrowable");var Tc=y(2,(e,t)=>Xe(e)?te():H(t(e.value)));var K6=y(2,(e,t)=>Xe(e)?te():t(e.value));var kc=K6(J);var Ac=y(2,(e,t)=>Xe(e)?te():t(e.value)?H(e.value):te()),C$=s(e=>Tt((t,n)=>Xe(t)?Xe(n):Xe(n)?!1:e(t.value,n.value)),"makeEquivalence");var Lt={};$t(Lt,{Do:()=>pV,all:()=>lV,andThen:()=>uV,bind:()=>mV,bindTo:()=>hV,fail:()=>ie,failVoid:()=>W6,filterOrFail:()=>rV,flatMap:()=>Os,flip:()=>fV,fromNullishOr:()=>Y6,fromOption:()=>X6,gen:()=>dV,getFailure:()=>eV,getOrElse:()=>Cs,getOrNull:()=>sV,getOrThrow:()=>aV,getOrThrowWith:()=>O$,getOrUndefined:()=>iV,getSuccess:()=>Q6,isFailure:()=>ye,isResult:()=>xh,isSuccess:()=>kt,let:()=>gV,liftPredicate:()=>nV,makeEquivalence:()=>NE,map:()=>Fn,mapBoth:()=>tV,mapError:()=>Jl,match:()=>vn,merge:()=>oV,orElse:()=>cV,succeed:()=>X,succeedNone:()=>DE,succeedSome:()=>SV,tap:()=>bV,transposeMapOption:()=>yV,transposeOption:()=>xV,try:()=>PE,void:()=>J6});var X=OE,ie=CE,J6=X(void 0);var W6=ie(void 0),Y6=y(2,(e,t)=>e==null?ie(t(e)):X(e)),X6=I$,PE=s(e=>{if(Sn(e))try{return X(e())}catch(t){return ie(t)}else try{return X(e.try())}catch(t){return ie(e.catch(t))}},"try_");var xh=dh,ye=ph,kt=mh,Q6=E$,eV=w$,NE=s((e,t)=>Tt((n,r)=>ye(n)?ye(r)&&t(n.failure,r.failure):kt(r)&&e(n.success,r.success)),"makeEquivalence"),tV=y(2,(e,{onFailure:t,onSuccess:n})=>ye(e)?ie(t(e.failure)):X(n(e.success))),Jl=y(2,(e,t)=>ye(e)?ie(t(e.failure)):e),Fn=y(2,(e,t)=>kt(e)?X(t(e.success)):e),vn=y(2,(e,{onFailure:t,onSuccess:n})=>ye(e)?t(e.failure):n(e.success)),nV=y(3,(e,t,n)=>t(e)?X(e):ie(n(e))),rV=y(3,(e,t,n)=>Os(e,r=>t(r)?X(r):ie(n(r)))),oV=vn({onFailure:J,onSuccess:J}),Cs=y(2,(e,t)=>ye(e)?t(e.failure):e.success),sV=Cs(qm),iV=Cs(Yn),O$=y(2,(e,t)=>{if(kt(e))return e.success;throw t(e.failure)}),aV=O$(J),cV=y(2,(e,t)=>ye(e)?t(e.failure):X(e.success)),Os=y(2,(e,t)=>ye(e)?ie(e.failure):t(e.success)),uV=y(2,(e,t)=>Os(e,n=>{let r=Sn(t)?t(n):t;return xh(r)?r:X(r)})),lV=s(e=>{if(Symbol.iterator in e){let n=[];for(let r of e){if(ye(r))return r;n.push(r.success)}return X(n)}let t={};for(let n of Object.keys(e)){let r=e[n];if(ye(r))return r;V(t,n,r.success)}return X(t)},"all"),fV=s(e=>ye(e)?X(e.failure):ie(e.success),"flip"),dV=s((...e)=>{let n=(e.length===1?e[0]:e[1].bind(e[0]))(),r=n.next();for(;!r.done;){let o=r.value;if(ye(o))return o;r=n.next(o.success)}return X(r.value)},"gen"),pV=X({}),mV=th(Fn,Os),hV=eh(Fn),gV=Qm(Fn);var xV=s(e=>Ts(e)?DE:Fn(e.value,Po),"transposeOption"),yV=y(2,(e,t)=>Ts(e)?DE:Fn(t(e.value),Po)),DE=X(Ri),SV=s(e=>X(Po(e)),"succeedSome"),bV=y(2,(e,t)=>(kt(e)&&t(e.success),e));var R$=y(2,(e,t)=>({[Symbol.iterator](){let n=e[Symbol.iterator](),r=0;return{next(){let o=n.next();for(;!o.done;){if(t(o.value,r++))return{done:!1,value:o.value};o=n.next()}return{done:!0,value:void 0}}}}}));var Wl=y(2,(e,t)=>{let n={...e};for(let r of vV(e))V(n,r,t(e[r],r));return n});var vV=s(e=>Object.keys(e),"keys");var yh=globalThis.Array;var Kt=s(e=>yh.isArray(e)?e:yh.from(e),"fromIterable"),P$=s(e=>yh.isArray(e)?e:[e],"ensure");var FE=y(2,(e,t)=>[...e,t]),_V=y(2,(e,t)=>Kt(e).concat(Kt(t)));var lse=yh.isArray;var Cc=bE,Rs=bE;var N$=y(2,(e,t)=>{let n=0,r=[];for(let o of e){if(!t(o,n))break;r.push(o),n++}return r});var wV=s((e,t)=>{let n=pe(t),r=e.get(n);if(r===void 0)return e.set(n,[t]),!0;for(let o of r)if(re(o,t))return!1;return r.push(t),!0},"hashBucketsAdd");var zE=y(2,(e,t)=>{let n=Kt(e),r=Kt(t);return Rs(n)?Rs(r)?bh(_V(n,r)):n:r});var Sh=s(()=>[],"empty");var $s=y(2,(e,t)=>e.map(t));var ME=s(e=>{let t=[];for(let n of e)an(n)&&t.push(n.value);return t},"getSomes");var UE=y(2,(e,t)=>{let n=[],r=[],o=0;for(let i of e){let a=t(i,o++);kt(a)?r.push(a.success):n.push(a.failure)}return[n,r]});var bh=s(e=>{let t=Kt(e);if(t.length<2)return[...t];let n=new Map,r=[];for(let o of t)wV(n,o)&&r.push(o);return r},"dedupe");var EV=vr((e,t)=>e.concat(t),[]);function D$(){return EV}s(D$,"makeReducerConcat");var L$=/^[+-]?\d+$/,GE="~effect/BigDecimal",IV={[GE]:GE,[Te](){let e=jE(this);return gt(pe(e.value),br(e.scale))},[ke](e){return _h(e)&&RV(this,e)},toString(){return`BigDecimal(${eo(this)})`},toJSON(){return{_id:"BigDecimal",value:String(this.value),scale:this.scale}},[yt](){return this.toJSON()},pipe(){return be(this,arguments)}},_h=s(e=>U(e,GE),"isBigDecimal"),_n=s((e,t)=>{let n=Object.create(IV);return n.value=e,n.scale=t,n},"make"),z$=s((e,t)=>{if(e!==zn&&e%vh===zn)throw new RangeError("Value must be normalized");let n=_n(e,t);return n.normalized=n,n},"makeNormalizedUnsafe"),zn=BigInt(0),TV=BigInt(1),kV=BigInt(-1);var vh=BigInt(10),M$=z$(zn,0);var jE=s(e=>{if(e.normalized===void 0)if(e.value===zn)e.normalized=M$;else{let t=`${e.value}`,n=0;for(let i=t.length-1;i>=0&&t[i]==="0";i--)n++;n===0&&(e.normalized=e);let r=BigInt(t.substring(0,t.length-n)),o=e.scale-n;e.normalized=z$(r,o)}return e.normalized},"normalize"),Ps=y(2,(e,t)=>t>e.scale?_n(e.value*vh**BigInt(t-e.scale),t):t<e.scale?_n(e.value/vh**BigInt(e.scale-t),t):e),U$=y(2,(e,t)=>t.value===zn?e:e.value===zn?t:e.scale>t.scale?_n(Ps(t,e.scale).value+e.value,e.scale):e.scale<t.scale?_n(Ps(e,t.scale).value+t.value,t.scale):_n(e.value+t.value,e.scale));var Lo=No((e,t)=>{let n=Ln(F$(e),F$(t));return n!==0?n:e.scale>t.scale?er(e.value,Ps(t,e.scale).value):e.scale<t.scale?er(Ps(e,t.scale).value,t.value):er(e.value,t.value)}),AV=Qr(Lo);var CV=tr(Lo);var F$=s(e=>e.value===zn?0:e.value<zn?-1:1,"sign"),OV=s(e=>e.value<zn?_n(-e.value,e.scale):e,"abs");var ZE=Tt((e,t)=>e.scale>t.scale?Ps(t,e.scale).value===e.value:e.scale<t.scale?Ps(e,t.scale).value===t.value:e.value===t.value),RV=y(2,(e,t)=>ZE(e,t));var G$=s(e=>{if(e==="")return H(M$);let t,n,r=e.search(/[eE]/);if(r!==-1){let l=e.slice(r+1);if(t=e.slice(0,r),n=Number(l),t===""||!Number.isSafeInteger(n)||!L$.test(l))return te()}else t=e,n=0;let o,i,a=t.search(/\./);if(a!==-1){let l=t.slice(0,a),u=t.slice(a+1);o=`${l}${u}`,i=u.length}else o=t,i=0;if(!L$.test(o))return te();let c=i-n;return Number.isSafeInteger(c)?H(_n(BigInt(o),c)):te()},"fromString");var eo=s(e=>{let t=jE(e);if(Math.abs(t.scale)>=16)return $V(t);let n=t.value<zn,r=n?`${t.value}`.substring(1):`${t.value}`,o,i;if(t.scale>=r.length)o="0",i="0".repeat(t.scale-r.length)+r;else{let c=r.length-t.scale;if(c>r.length){let l=c-r.length;o=`${r}${"0".repeat(l)}`,i=""}else i=r.slice(c),o=r.slice(0,c)}let a=i===""?o:`${o}.${i}`;return n?`-${a}`:a},"format"),$V=s(e=>{if(PV(e))return"0e+0";let t=jE(e),n=`${OV(t).value}`,r=n.slice(0,1),o=n.slice(1),i=`${j$(t)?"-":""}${r}`;o!==""&&(i+=`.${o}`);let a=o.length-t.scale;return`${i}e${a>=0?"+":""}${a}`},"toExponential");var PV=s(e=>e.value===zn,"isZero"),j$=s(e=>e.value<zn,"isNegative"),NV=s(e=>e.value>zn,"isPositive"),qE=s(e=>_h(e[0]),"isBigDecimalArgs");var Z$=y(qE,(e,t=0)=>e.scale<=t?e:_n(e.value/vh**BigInt(e.scale-t),t)),BE=y(qE,(e,t=0)=>{let n=Z$(e,t);return NV(e)&&AV(n,e)?U$(n,_n(TV,t)):n});var VE=y(qE,(e,t=0)=>{let n=Z$(e,t);return j$(e)&&CV(n,e)?U$(n,_n(kV,t)):n});var yse=globalThis.Boolean;var q$=vr((e,t)=>e||t,!1);var st={};$t(st,{Reference:()=>Ce,Service:()=>Mn,ServiceTypeId:()=>wh,add:()=>ln,addOrOmit:()=>GV,empty:()=>un,get:()=>cn,getOption:()=>tI,getOrElse:()=>jV,getOrUndefined:()=>QE,getOrUndefinedUnsafe:()=>Oc,getUnsafe:()=>nr,hasSameCache:()=>XE,isContext:()=>Ih,isKey:()=>MV,isReference:()=>Th,make:()=>to,makeUnsafe:()=>Li,merge:()=>Rc,mergeAll:()=>nI,omit:()=>X$,pick:()=>qV});var V$=s(e=>Ro({op:e.label,[ot]:e.evaluate}),"Prototype");var wh="~effect/Context/Service",Mn=s(function(){function e(){}s(e,"KeyClass");let t=e;Object.setPrototypeOf(t,DV);let n=s((r,o)=>(t.key=r,o?.defaultValue&&(t[JE]=JE,t.defaultValue=o.defaultValue),o?.make&&(t.make=o.make),o?.fiberCached&&K$.add(r),t),"init");return arguments.length>0?n(arguments[0],arguments[1]):n},"Service"),DV={[wh]:wh,...V$({label:"Service",evaluate(e){return St(cn(e.context,this))}}),toJSON(){return{_id:"Service",key:this.key}},of(e){return e},context(e){return to(this,e)},use(e){return fe(t=>e(cn(t.context,this)))},useSync(e){return fe(t=>St(e(cn(t.context,this))))}},K$=new Set,JE="~effect/Context/Reference",J$="~effect/Context",LV=8,FV=8,WE=s((e,t,n,r)=>{let o=Object.create(zV);return o.cacheRoot=e??o,o.base=t,o.overlay=n,o.depth=r,o._flat=void 0,o.baseHits=0,o},"makeImpl"),W$=s((e,t)=>{t&&(W$(e,t.parent),e.set(t.key,t.value))},"applyOverlays"),Y$=s(e=>{if(e._flat)return e._flat;if(!e.overlay)return e._flat=e.base;let t=new Map(e.base);return W$(t,e.overlay),e._flat=t},"flatten"),YE=s((e,t)=>{let n=new Map(e.mapUnsafe);return t(n),Li(n)},"withFlat"),Yl=Symbol(),Eh=s((e,t)=>{let n=e;for(let o=n.overlay;o;o=o.parent)if(o.key===t)return o.value;let r=n.base.get(t);return r===void 0&&!n.base.has(t)?Yl:(n.overlay&&++n.baseHits>=FV&&(n.base=Y$(n),n.overlay=void 0,n.depth=0),r)},"lookup"),Li=s(e=>WE(void 0,e,void 0,0),"makeUnsafe"),zV={...Co,[J$]:{_Services:s(e=>e,"_Services")},get mapUnsafe(){return Y$(this)},toJSON(){return{_id:"Context",services:Array.from(this.mapUnsafe).map(([e,t])=>({key:e,value:t}))}},[ke](e){if(!Ih(e))return!1;let t=this.mapUnsafe,n=e.mapUnsafe;if(t.size!==n.size)return!1;for(let[r,o]of t)if(!n.has(r)||!re(o,n.get(r)))return!1;return!0},[Te](){return br(this.mapUnsafe.size)}},XE=s((e,t)=>e.cacheRoot===t.cacheRoot,"hasSameCache"),Ih=s(e=>U(e,J$),"isContext"),MV=s(e=>U(e,wh),"isKey"),Th=s(e=>!!e[JE],"isReference"),un=s(()=>UV,"empty"),UV=Li(new Map),to=s((e,t)=>Li(new Map([[e.key,t]])),"make"),ln=y(3,(e,t,n)=>{let r=e,o=K$.has(t.key)?void 0:r.cacheRoot;if(r.depth>=LV){let i=new Map(r.mapUnsafe);return i.set(t.key,n),WE(o,i,void 0,0)}return WE(o,r.base,{key:t.key,value:n,parent:r.overlay},r.depth+1)}),GV=y(3,(e,t,n)=>n._tag==="None"?X$(t)(e):ln(e,t,n.value)),jV=y(3,(e,t,n)=>{let r=Eh(e,t.key);return r!==Yl?r:Th(t)?eI(t):n()}),QE=y(2,(e,t)=>Oc(e,t.key)),Oc=s((e,t)=>{let n=Eh(e,t);return n===Yl?void 0:n},"getOrUndefinedUnsafe"),nr=y(2,(e,t)=>{let n=Eh(e,t.key);if(n===Yl){if(Th(t))return eI(t);throw ZV(t)}return n}),cn=nr,KE="~effect/Context/defaultValue",eI=s(e=>KE in e?e[KE]:e[KE]=e.defaultValue(),"getDefaultValue"),ZV=s(e=>{let t=new Error(`Service not found${e.key?`: ${String(e.key)}`:""}`);if(t.stack){let n=t.stack.split(`
|
|
75
|
+
`);n.splice(1,3),t.stack=n.join(`
|
|
76
|
+
`)}return t},"serviceNotFoundError"),tI=y(2,(e,t)=>{let n=Eh(e,t.key);return n!==Yl?H(n):Th(t)?H(eI(t)):te()}),Rc=y(2,(e,t)=>e.mapUnsafe.size===0?t:t.mapUnsafe.size===0?e:YE(e,n=>t.mapUnsafe.forEach((r,o)=>n.set(o,r)))),nI=s((...e)=>{let t=new Map;for(let n=0;n<e.length;n++)e[n].mapUnsafe.forEach((r,o)=>{t.set(o,r)});return Li(t)},"mergeAll"),qV=s((...e)=>t=>{let n=new Set(e.map(r=>r.key));return YE(t,r=>r.forEach((o,i)=>{n.has(i)||r.delete(i)}))},"pick"),X$=s((...e)=>t=>YE(t,n=>{for(let r=0;r<e.length;r++)n.delete(e[r].key)}),"omit"),Ce=Mn;var Ir={};$t(Ir,{CombinerMax:()=>gH,CombinerMin:()=>xH,Equivalence:()=>Ph,Order:()=>Er,ReducerSum:()=>hH,abs:()=>cP,between:()=>aH,clamp:()=>cH,days:()=>dP,divide:()=>uH,divideUnsafe:()=>lH,equals:()=>xP,format:()=>SP,fromInput:()=>oI,fromInputUnsafe:()=>ct,hours:()=>fP,infinity:()=>lt,isDuration:()=>$h,isFinite:()=>YV,isGreaterThan:()=>pH,isGreaterThanOrEqualTo:()=>mH,isLessThan:()=>dH,isLessThanOrEqualTo:()=>gP,isNegative:()=>aP,isPositive:()=>XV,isZero:()=>iP,match:()=>ro,matchPair:()=>Ql,max:()=>hP,micros:()=>eH,millis:()=>wr,min:()=>mP,minutes:()=>lP,nanos:()=>Un,negate:()=>QV,negativeInfinity:()=>Ft,parts:()=>yP,seconds:()=>uP,subtract:()=>iI,sum:()=>aI,times:()=>fH,toDays:()=>oH,toHours:()=>rH,toHrTime:()=>iH,toMillis:()=>no,toMinutes:()=>nH,toNanos:()=>sI,toNanosUnsafe:()=>Xl,toSeconds:()=>tH,toWeeks:()=>sH,weeks:()=>pP,zero:()=>At});var Ah="~effect/time/Duration",rr=BigInt(0),Ch=BigInt(1),BV=BigInt(2),VV=BigInt(10),Q$=BigInt(24),kh=BigInt(60),Oh=BigInt(1e3),eP=BigInt(1e6),tP=BigInt(1e9),Rh=s(e=>BigInt(e<0?Math.ceil(e-.5):Math.floor(e+.5)),"roundTiesAwayFromZero"),rI=s(e=>Rh(e*1e6),"roundMillisToNanos"),nP=s((e,t)=>{let n=e.indexOf(".");if(n===-1)return BigInt(e)*t;let r=e[0]==="-",o=e.slice(n+1),i=VV**BigInt(o.length),a=(BigInt(e.slice(r?1:0,n))*i+BigInt(o))*t,c=a/i+(a%i*BV>=i?Ch:rr);return r?-c:c},"parseNanos"),rP=s(e=>{let t=e<rr?-Ch:Ch,n=e<rr?-e:e;return[Number(t*(n/tP)),Number(t*(n%tP))]},"nanosToHrTime"),HV=/^(-?\d+(?:\.\d+)?)\s+(nanos?|micros?|millis?|seconds?|minutes?|hours?|days?|weeks?)$/,ct=s(e=>{switch(typeof e){case"number":return wr(e);case"bigint":return Un(e);case"string":{if(e==="Infinity")return lt;if(e==="-Infinity")return Ft;let t=HV.exec(e);if(!t)break;let[n,r,o]=t;if(o==="nano"||o==="nanos")return Un(nP(r,Ch));if(o==="micro"||o==="micros")return Un(nP(r,Oh));let i=Number(r);switch(o){case"milli":case"millis":return wr(i);case"second":case"seconds":return uP(i);case"minute":case"minutes":return lP(i);case"hour":case"hours":return fP(i);case"day":case"days":return dP(i);case"week":case"weeks":return pP(i)}break}case"object":{if(e===null)break;if(Ah in e)return e;if(Array.isArray(e))return e.length!==2||!e.every(Fl)?oP(e):Number.isNaN(e[0])||Number.isNaN(e[1])?At:e[0]===-1/0||e[1]===-1/0?Ft:e[0]===1/0||e[1]===1/0?lt:Me(Rh(e[0]*1e9+e[1]));let t=e,n=0;return t.weeks&&(n+=t.weeks*6048e5),t.days&&(n+=t.days*864e5),t.hours&&(n+=t.hours*36e5),t.minutes&&(n+=t.minutes*6e4),t.seconds&&(n+=t.seconds*1e3),t.milliseconds&&(n+=t.milliseconds),!t.microseconds&&!t.nanoseconds?Me(n):Me(Rh(n*1e6+(t.microseconds??0)*1e3+(t.nanoseconds??0)))}}return oP(e)},"fromInputUnsafe"),oP=s(e=>{throw new Error(`Invalid Input: ${e}`)},"invalid"),oI=Di(ct),sP={_tag:"Millis",millis:0},KV={_tag:"Infinity"},JV={_tag:"NegativeInfinity"},WV={[Ah]:Ah,[Te](){switch(this.value._tag){case"Millis":{let e=this.value.millis*1e6;return Number.isFinite(e)?pe(Rh(e)):br(this.value.millis)}case"Nanos":return pe(this.value.nanos);default:return gE(this.value)}},[ke](e){return $h(e)&&xP(this,e)},toString(){switch(this.value._tag){case"Infinity":return"Infinity";case"NegativeInfinity":return"-Infinity";case"Nanos":return`${this.value.nanos} nanos`;case"Millis":return`${this.value.millis} millis`}},toJSON(){switch(this.value._tag){case"Millis":return{_id:"Duration",_tag:"Millis",millis:this.value.millis};case"Nanos":return{_id:"Duration",_tag:"Nanos",nanos:String(this.value.nanos)};case"Infinity":return{_id:"Duration",_tag:"Infinity"};case"NegativeInfinity":return{_id:"Duration",_tag:"NegativeInfinity"}}},[yt](){return this.toJSON()},pipe(){return be(this,arguments)}},Me=s(e=>{let t=Object.create(WV);return typeof e=="number"?isNaN(e)||e===0||Object.is(e,-0)?t.value=sP:Number.isFinite(e)?Number.isInteger(e)?t.value={_tag:"Millis",millis:e}:t.value={_tag:"Nanos",nanos:rI(e)}:t.value=e>0?KV:JV:e===rr?t.value=sP:t.value={_tag:"Nanos",nanos:e},t},"make"),$h=s(e=>U(e,Ah),"isDuration"),YV=s(e=>e.value._tag!=="Infinity"&&e.value._tag!=="NegativeInfinity","isFinite"),iP=s(e=>{switch(e.value._tag){case"Millis":return e.value.millis===0;case"Nanos":return e.value.nanos===rr;case"Infinity":case"NegativeInfinity":return!1}},"isZero"),aP=s(e=>{switch(e.value._tag){case"Millis":return e.value.millis<0;case"Nanos":return e.value.nanos<rr;case"NegativeInfinity":return!0;case"Infinity":return!1}},"isNegative"),XV=s(e=>{switch(e.value._tag){case"Millis":return e.value.millis>0;case"Nanos":return e.value.nanos>rr;case"Infinity":return!0;case"NegativeInfinity":return!1}},"isPositive"),cP=s(e=>{switch(e.value._tag){case"Infinity":case"NegativeInfinity":return lt;case"Millis":return e.value.millis<0?Me(-e.value.millis):e;case"Nanos":return e.value.nanos<rr?Me(-e.value.nanos):e}},"abs"),QV=s(e=>{switch(e.value._tag){case"Infinity":return Ft;case"NegativeInfinity":return lt;case"Millis":return e.value.millis===0?e:Me(-e.value.millis);case"Nanos":return e.value.nanos===rr?e:Me(-e.value.nanos)}},"negate"),At=Me(0),lt=Me(1/0),Ft=Me(-1/0),Un=s(e=>Me(e),"nanos"),eH=s(e=>Me(e*Oh),"micros"),wr=s(e=>Me(e),"millis"),uP=s(e=>Me(e*1e3),"seconds"),lP=s(e=>Me(e*6e4),"minutes"),fP=s(e=>Me(e*36e5),"hours"),dP=s(e=>Me(e*864e5),"days"),pP=s(e=>Me(e*6048e5),"weeks"),no=s(e=>ro(ct(e),{onMillis:J,onNanos:s(t=>Number(t)/1e6,"onNanos"),onInfinity:s(()=>1/0,"onInfinity"),onNegativeInfinity:s(()=>-1/0,"onNegativeInfinity")}),"toMillis"),tH=s(e=>ro(ct(e),{onMillis:s(t=>t/1e3,"onMillis"),onNanos:s(t=>Number(t)/1e9,"onNanos"),onInfinity:s(()=>1/0,"onInfinity"),onNegativeInfinity:s(()=>-1/0,"onNegativeInfinity")}),"toSeconds"),nH=s(e=>ro(ct(e),{onMillis:s(t=>t/6e4,"onMillis"),onNanos:s(t=>Number(t)/6e10,"onNanos"),onInfinity:s(()=>1/0,"onInfinity"),onNegativeInfinity:s(()=>-1/0,"onNegativeInfinity")}),"toMinutes"),rH=s(e=>ro(ct(e),{onMillis:s(t=>t/36e5,"onMillis"),onNanos:s(t=>Number(t)/36e11,"onNanos"),onInfinity:s(()=>1/0,"onInfinity"),onNegativeInfinity:s(()=>-1/0,"onNegativeInfinity")}),"toHours"),oH=s(e=>ro(ct(e),{onMillis:s(t=>t/864e5,"onMillis"),onNanos:s(t=>Number(t)/864e11,"onNanos"),onInfinity:s(()=>1/0,"onInfinity"),onNegativeInfinity:s(()=>-1/0,"onNegativeInfinity")}),"toDays"),sH=s(e=>ro(ct(e),{onMillis:s(t=>t/6048e5,"onMillis"),onNanos:s(t=>Number(t)/6048e11,"onNanos"),onInfinity:s(()=>1/0,"onInfinity"),onNegativeInfinity:s(()=>-1/0,"onNegativeInfinity")}),"toWeeks"),Xl=s(e=>{let t=ct(e);switch(t.value._tag){case"Infinity":case"NegativeInfinity":throw new Error("Cannot convert infinite duration to nanos");case"Nanos":return t.value.nanos;case"Millis":return rI(t.value.millis)}},"toNanosUnsafe"),sI=Di(Xl),iH=s(e=>{let t=ct(e);switch(t.value._tag){case"Infinity":return[1/0,0];case"NegativeInfinity":return[-1/0,0];case"Nanos":return rP(t.value.nanos);case"Millis":return rP(rI(t.value.millis))}},"toHrTime"),ro=y(2,(e,t)=>{switch(e.value._tag){case"Millis":return t.onMillis(e.value.millis);case"Nanos":return t.onNanos(e.value.nanos);case"Infinity":return t.onInfinity();case"NegativeInfinity":return(t.onNegativeInfinity??t.onInfinity)()}}),Ql=y(3,(e,t,n)=>e.value._tag==="Infinity"||e.value._tag==="NegativeInfinity"||t.value._tag==="Infinity"||t.value._tag==="NegativeInfinity"?n.onInfinity(e,t):e.value._tag==="Millis"?t.value._tag==="Millis"?n.onMillis(e.value.millis,t.value.millis):n.onNanos(Xl(e),t.value.nanos):n.onNanos(e.value.nanos,Xl(t))),Er=No((e,t)=>Ql(e,t,{onMillis:s((n,r)=>n<r?-1:n>r?1:0,"onMillis"),onNanos:s((n,r)=>n<r?-1:n>r?1:0,"onNanos"),onInfinity:s((n,r)=>n.value._tag===r.value._tag?0:n.value._tag==="Infinity"?1:n.value._tag==="NegativeInfinity"||r.value._tag==="Infinity"?-1:1,"onInfinity")})),aH=Kl(Er),Ph=s((e,t)=>Ql(e,t,{onMillis:s((n,r)=>n===r,"onMillis"),onNanos:s((n,r)=>n===r,"onNanos"),onInfinity:s((n,r)=>n.value._tag===r.value._tag,"onInfinity")}),"Equivalence"),mP=Ec(Er),hP=Ic(Er),cH=Hl(Er),uH=y(2,(e,t)=>Number.isFinite(t)?t===0||Object.is(t,-0)?te():ro(e,{onMillis:s(n=>H(Me(n/t)),"onMillis"),onNanos:s(n=>{try{return H(Me(n/BigInt(t)))}catch{return te()}},"onNanos"),onInfinity:s(()=>H(t>0?lt:Ft),"onInfinity"),onNegativeInfinity:s(()=>H(t>0?Ft:lt),"onNegativeInfinity")}):te()),lH=y(2,(e,t)=>Number.isFinite(t)?ro(e,{onMillis:s(n=>Me(n/t),"onMillis"),onNanos:s(n=>{if(Object.is(t,0)||Object.is(t,-0)){if(n===rr)return At;let r=n>rr,o=Object.is(t,0);return r===o?lt:Ft}try{return Me(n/BigInt(t))}catch{return At}},"onNanos"),onInfinity:s(()=>t>0?lt:t<0?Ft:At,"onInfinity"),onNegativeInfinity:s(()=>t>0?Ft:t<0?lt:At,"onNegativeInfinity")}):At),fH=y(2,(e,t)=>ro(e,{onMillis:s(n=>Me(n*t),"onMillis"),onNanos:s(n=>Me(n*BigInt(t)),"onNanos"),onInfinity:s(()=>t>0?lt:t<0?Ft:At,"onInfinity"),onNegativeInfinity:s(()=>t>0?Ft:t<0?lt:At,"onNegativeInfinity")})),iI=y(2,(e,t)=>Ql(e,t,{onMillis:s((n,r)=>Me(n-r),"onMillis"),onNanos:s((n,r)=>Me(n-r),"onNanos"),onInfinity:s((n,r)=>{let o=n.value._tag,i=r.value._tag;return o==="Infinity"?i==="Infinity"?At:lt:o==="NegativeInfinity"?i==="NegativeInfinity"?At:Ft:i==="Infinity"?Ft:lt},"onInfinity")})),aI=y(2,(e,t)=>Ql(e,t,{onMillis:s((n,r)=>Me(n+r),"onMillis"),onNanos:s((n,r)=>Me(n+r),"onNanos"),onInfinity:s((n,r)=>{let o=n.value._tag,i=r.value._tag;return o==="Infinity"&&i==="NegativeInfinity"||o==="NegativeInfinity"&&i==="Infinity"?At:o==="Infinity"||i==="Infinity"?lt:o==="NegativeInfinity"||i==="NegativeInfinity"?Ft:At},"onInfinity")})),dH=Qr(Er),gP=ks(Er),pH=tr(Er),mH=As(Er),xP=y(2,(e,t)=>Ph(e,t)),yP=s(e=>{if(e.value._tag==="Infinity")return{days:1/0,hours:1/0,minutes:1/0,seconds:1/0,millis:1/0,nanos:1/0};if(e.value._tag==="NegativeInfinity")return{days:-1/0,hours:-1/0,minutes:-1/0,seconds:-1/0,millis:-1/0,nanos:-1/0};let t=Xl(e),n=t<rr,r=n?-t:t,o=r/eP,i=o/Oh,a=i/kh,c=a/kh,l=c/Q$,u=n?-1:1;return{days:u*Number(l),hours:u*Number(c%Q$),minutes:u*Number(a%kh),seconds:u*Number(i%kh),millis:u*Number(o%Oh),nanos:u*Number(r%eP)}},"parts"),SP=s(e=>{if(e.value._tag==="Infinity")return"Infinity";if(e.value._tag==="NegativeInfinity")return"-Infinity";if(iP(e))return"0";if(aP(e))return"-"+SP(cP(e));let t=yP(e),n=[];return t.days!==0&&n.push(`${t.days}d`),t.hours!==0&&n.push(`${t.hours}h`),t.minutes!==0&&n.push(`${t.minutes}m`),t.seconds!==0&&n.push(`${t.seconds}s`),t.millis!==0&&n.push(`${t.millis}ms`),t.nanos!==0&&n.push(`${t.nanos}ns`),n.join(" ")},"format"),hH=vr(aI,At),gH=r$(Er),xH=n$(Er);var cI=y(2,(e,t)=>n=>{let r=e(n);if(ye(r))return ie(n);let o=t(r.success);return ye(o)?ie(n):o});var ef=Ce("effect/Scheduler",{fiberCached:!0,defaultValue:s(()=>new Fi,"defaultValue")}),vP="setImmediate"in globalThis?e=>{let t=globalThis.setImmediate(e);return()=>globalThis.clearImmediate(t)}:e=>{let t=setTimeout(e,0);return()=>clearTimeout(t)},yH=s(e=>{let t=!1;return queueMicrotask(()=>{t||e()}),()=>{t=!0}},"setMicrotask"),uI=class{static{s(this,"PriorityBuckets")}buckets=[];scheduleTask(t,n){let r=this.buckets,o=r.length,i,a=0;for(;a<o&&!(r[a][0]>n);a++)i=r[a];i&&i[0]===n?i[1].push(t):a===o?r.push([n,[t]]):r.splice(a,0,[n,[t]])}drain(){let t=this.buckets;return this.buckets=[],t}},Fi=class{static{s(this,"MixedScheduler")}executionMode;setImmediate;constructor(t="async",n){this.executionMode=t,this.setImmediate=n??(t==="sync"?yH:vP)}shouldYield(t){return t.currentOpCount>=t.maxOpsBeforeYield}makeDispatcher(){return new lI(this.setImmediate)}},lI=class{static{s(this,"MixedSchedulerDispatcher")}tasks=new uI;running=void 0;setImmediate;constructor(t=vP){this.setImmediate=t}scheduleTask(t,n){this.tasks.scheduleTask(t,n),this.running===void 0&&(this.running=this.setImmediate(this.afterScheduled))}afterScheduled=s(()=>{this.running=void 0,this.runTasks()},"afterScheduled");runTasks(){let t=this.tasks.drain();for(let n=0;n<t.length;n++){let r=t[n][1];for(let o=0;o<r.length;o++)r[o]()}}flush(){for(;this.tasks.buckets.length>0;)this.running!==void 0&&(this.running(),this.running=void 0),this.runTasks()}},_P=Ce("effect/Scheduler/MaxOpsBeforeYield",{fiberCached:!0,defaultValue:s(()=>2048,"defaultValue")}),wP=Ce("effect/Scheduler/PreventSchedulerYield",{fiberCached:!0,defaultValue:s(()=>!1,"defaultValue")});var pI="effect/Tracer/ParentSpan",Ns=class extends Mn()(pI,{fiberCached:!0}){static{s(this,"ParentSpan")}},SH=s(e=>e,"make");var Nh=Ce("effect/Tracer/DisablePropagation",{defaultValue:Zm}),IP=Ce("effect/Tracer/CurrentTraceLevel",{defaultValue:s(()=>"Info","defaultValue")}),TP=Ce("effect/Tracer/MinimumTraceLevel",{defaultValue:s(()=>"All","defaultValue")}),mI="effect/Tracer",Dh=Ce(mI,{fiberCached:!0,defaultValue:s(()=>SH({span:s(e=>new dI(e),"span")}),"defaultValue")}),dI=class{static{s(this,"NativeSpan")}_tag="Span";spanId;traceId="native";sampled;name;parent;annotations;links;startTime;kind;status;attributes;events=[];constructor(t){this.name=t.name,this.parent=t.parent,this.annotations=t.annotations,this.links=t.links,this.startTime=t.startTime,this.kind=t.kind,this.sampled=t.sampled,this.status={_tag:"Started",startTime:t.startTime},this.attributes=new Map,this.traceId=Ni(t.parent)?.traceId??EP(32),this.spanId=EP(16)}end(t,n){this.status={_tag:"Ended",endTime:t,exit:n,startTime:this.status.startTime}}attribute(t,n){this.attributes.set(t,n)}event(t,n,r){this.events.push([t,n,r??{}])}addLinks(t){this.links.push(...t)}},EP=(function(){let e="abcdef0123456789",t=e.length;return function(n){let r="";for(let o=0;o<n;o++)r+=e.charAt(Math.floor(Math.random()*t));return r}})();var kP="effect/observability/Metric/FiberRuntimeMetricsKey";var AP=Ce("effect/ErrorReporter/CurrentErrorReporters",{defaultValue:s(()=>new Set,"defaultValue")}),$c=Ce("effect/References/CurrentStackFrame",{fiberCached:!0,defaultValue:Yn}),Lh=Ce("effect/References/TracerEnabled",{defaultValue:Io}),Pc=Ce("effect/References/TracerTimingEnabled",{defaultValue:Io}),tf=Ce("effect/References/TracerSpanAnnotations",{defaultValue:s(()=>({}),"defaultValue")}),nf=Ce("effect/References/TracerSpanLinks",{defaultValue:s(()=>[],"defaultValue")}),Fo=Ce("effect/References/CurrentLogAnnotations",{defaultValue:s(()=>({}),"defaultValue")}),gI=Ce("effect/References/CurrentLogLevel",{fiberCached:!0,defaultValue:s(()=>"Info","defaultValue")}),xI=Ce("effect/References/MinimumLogLevel",{fiberCached:!0,defaultValue:s(()=>"Info","defaultValue")});var Fh=Ce("effect/References/CurrentLogSpans",{defaultValue:s(()=>[],"defaultValue")});var _H=s(()=>{let e=Object.getOwnPropertyDescriptor(Error,"stackTraceLimit");return e===void 0?Object.isExtensible(Error):Object.hasOwn(e,"writable")?e.writable===!0:e.set!==void 0},"isStackTraceLimitWritable"),wH=_H(),Ds=s(()=>Error.stackTraceLimit,"getStackTraceLimit"),Gn=s(e=>{wH&&(Error.stackTraceLimit=e)},"setStackTraceLimit");var Ls=s(e=>{if(e?.captureStackTrace===!1)return e;if(e?.captureStackTrace!==void 0&&typeof e.captureStackTrace!="boolean")return e;let t=Ds();Gn(3);let n=new Error;return Gn(t),{...e,captureStackTrace:EH(()=>n.stack)}},"addSpanStackTrace"),yI=s(e=>t=>{let n;return()=>{if(n!==void 0)return n;let r=t();if(!r)return;let o=r.split(`
|
|
77
|
+
`);if(o[e]!==void 0)return n=o[e].trim(),n}},"makeStackCleaner"),EH=yI(3);var zh=class extends vc{static{s(this,"Interrupt")}fiberId;constructor(t,n=Zl){super("Interrupt",n,"Interrupted"),this.fiberId=t}toString(){return`Interrupt(${this.fiberId})`}toJSON(){return{_tag:"Interrupt",fiberId:this.fiberId}}[ke](t){return ch(t)&&this.fiberId===t.fiberId&&this.annotations===t.annotations}[Te](){return gt(Be(`${this._tag}:${this.fiberId}`))(Km(this.annotations))}},DP=s(e=>new zh(e),"makeInterruptReason"),qh=s(e=>new Kr([new zh(e)]),"causeInterrupt");var LP=s(e=>{let t=e.reasons.find(Oi);return t?X(t):ie(e)},"findFail"),so=s(e=>{for(let t=0;t<e.reasons.length;t++){let n=e.reasons[t];if(n._tag==="Fail")return X(n.error)}return ie(e)},"findError");var FP=s(e=>e.reasons.some(Bl),"hasDies");var NI=s(e=>{let t=e.reasons.find(Bl);return t?X(t.defect):ie(e)},"findDefect"),zP=s(e=>e.reasons.some(ch),"hasInterrupts");var MP=s(e=>{let t;for(let n=0;n<e.reasons.length;n++){let r=e.reasons[n];r._tag==="Interrupt"&&(t??=new Set,r.fiberId!==void 0&&t.add(r.fiberId))}return t?X(t):ie(e)},"causeFilterInterruptors");var UP=y(2,(e,t)=>{if(e.reasons.length===0)return t;if(t.reasons.length===0)return e;let n=new Kr(zE(e.reasons,t.reasons));return re(e,n)?e:n}),GP=y(2,(e,t)=>{let n=!1,r=e.reasons.map(o=>Oi(o)?(n=!0,new Ai(t(o.error),o.annotations)):o);return n?Oo(r):e}),TH=s(e=>{let t={Fail:[],Die:[],Interrupt:[]};for(let n=0;n<e.reasons.length;n++)t[e.reasons[n]._tag].push(e.reasons[n]);return t},"causePartition"),DI=s(e=>{let t=TH(e);return t.Fail.length>0?t.Fail[0].error:t.Die.length>0?t.Die[0].defect:t.Interrupt.length>0?new globalThis.Error("All fibers interrupted without error"):new globalThis.Error("Empty cause")},"causeSquash"),jP=s((e,t)=>{let n=[],r=[];if(e.reasons.length===0)return n;let o=Ds();Gn(1);for(let i of e.reasons){if(i._tag==="Interrupt"){r.push(i);continue}n.push(bI(i._tag==="Die"?i.defect:i.error,i.annotations,t))}if(n.length===0){let i=new Error("The fiber was interrupted by:");i.name="InterruptCause",i.stack=OH(i,r);let a=new globalThis.Error("All fibers interrupted without error",{cause:i});a.name="InterruptError",a.stack=`${a.name}: ${a.message}`,n.push(bI(a,r[0].annotations,t))}return Gn(o),n},"causePrettyErrors"),bI=s((e,t,n)=>{let r=typeof e,o;if(e&&r==="object"){if(o=new globalThis.Error(kH(e),{cause:e.cause?bI(e.cause):void 0}),typeof e.name=="string"&&(o.name=e.name),typeof e.stack=="string")o.stack=CH(e.stack,o,t);else{let i=`${o.name}: ${o.message}`;o.stack=t?ZP(i,t):i}n?.includeCauseInStack&&(o.stack=BP(o));for(let i of Object.keys(e))i in o||(o[i]=e[i])}else o=new globalThis.Error(e?r==="string"?e:Ti(e):`Unknown error: ${e}`);return o},"causePrettyError"),kH=s(e=>{if(typeof e.message=="string")return e.message;if(typeof e.toString=="function"&&e.toString!==Object.prototype.toString&&e.toString!==Array.prototype.toString)try{return e.toString()}catch{}return Ti(e)},"causePrettyMessage"),AH=/\((.*)\)/g,CH=s((e,t,n)=>{let r=`${t.name}: ${t.message}`,o=(e.startsWith(r)?e.slice(r.length):e).split(`
|
|
78
|
+
`),i=[r];for(let a=1;a<o.length&&!/(?:Generator\.next|~effect\/Effect)/.test(o[a]);a++)i.push(o[a]);return n?ZP(i.join(`
|
|
79
|
+
`),n):i.join(`
|
|
80
|
+
`)},"cleanErrorStack"),ZP=s((e,t)=>{let n=t?.get(uh.key);return n&&(e=`${e}
|
|
81
|
+
${qP(n)}`),e},"addStackAnnotations"),OH=s((e,t)=>{let n=[`${e.name}: ${e.message}`];for(let r of t){let o=r.fiberId!==void 0?`#${r.fiberId}`:"unknown",i=r.annotations.get(IE.key);n.push(` at fiber (${o})`),i&&n.push(qP(i))}return n.join(`
|
|
82
|
+
`)},"interruptCauseStack"),qP=s(e=>{let t=[],n=e,r=0;for(;n&&r<10;){let o=n.stack();if(o){let i=o.matchAll(AH),a=!1;for(let[,c]of i)a=!0,t.push(` at ${n.name} (${c})`);a||t.push(` at ${n.name} (${o.replace(/^at /,"")})`)}else t.push(` at ${n.name}`);n=n.parent,r++}return t.join(`
|
|
83
|
+
`)},"currentStackTrace"),Bh=s(e=>jP(e).map(BP).join(`
|
|
84
|
+
`),"causePretty"),BP=s(e=>e.cause?`${e.stack} {
|
|
85
|
+
${VP(e.cause," ")}
|
|
86
|
+
}`:e.stack,"renderPrettyError"),VP=s((e,t)=>{let n=e.stack.split(`
|
|
87
|
+
`),r=`${t}[cause]: ${n[0]}`;for(let o=1,i=n.length;o<i;o++)r+=`
|
|
88
|
+
${t}${n[o]}`;return e.cause&&(r+=` {
|
|
89
|
+
${VP(e.cause,`${t} `)}
|
|
90
|
+
${t}}`),r},"renderErrorCause"),Mh="~effect/Fiber",RH={_A:J,_E:J},$H={id:0},af=s(()=>globalThis[bc],"getCurrentFiber"),Uh=class{static{s(this,"FiberImpl")}constructor(t,n=!0){this[Mh]=RH,this.setContext(t),this.id=++$H.id,this.currentOpCount=0,this.interruptible=n,this._stack=[],this._observers=[],this._exit=void 0,this._children=void 0,this._interruptedCause=void 0,this._yielded=void 0,this._running=!1,this._deferredInterrupt=!1,this.runtimeMetrics?.recordFiberStart(this.context)}[Mh];id;interruptible;currentOpCount;_stack;_observers;_exit;_children;_interruptedCause;_yielded;_running;_deferredInterrupt;context;currentScheduler;currentTracerContext;currentSpan;currentLogLevel;minimumLogLevel;currentStackFrame;runtimeMetrics;maxOpsBeforeYield;currentPreventYield;_dispatcher=void 0;get currentDispatcher(){return this._dispatcher??=this.currentScheduler.makeDispatcher()}getRef(t){return cn(this.context,t)}addObserver(t){return this._exit?(t(this._exit),Bm):(this._observers.push(t),()=>{let n=this._observers.indexOf(t);n>=0&&this._observers.splice(n,1)})}interruptUnsafe(t,n){if(this._exit)return;let r=qh(t);this.currentStackFrame&&(r=ql(r,to(uh,this.currentStackFrame))),n&&(r=ql(r,n)),this._interruptedCause=this._interruptedCause?UP(this._interruptedCause,r):r,this.interruptible&&(this._running?this._deferredInterrupt=!0:this.evaluate(Le(this._interruptedCause)))}pollUnsafe(){return this._exit}evaluate(t){if(this._exit)return;if(this._yielded!==void 0){let o=this._yielded;this._yielded=void 0,o()}let n=this.runLoop(t);if(n===Ci)return;let r=vI.interruptChildren&&vI.interruptChildren(this);if(r!==void 0)return this.evaluate(G(r,()=>n));this._exit=n,this.runtimeMetrics?.recordFiberEnd(this.context,this._exit);for(let o=0;o<this._observers.length;o++)this._observers[o](n);this._observers.length=0,this._stack.length=0,this._children=void 0,this.context=un()}runLoop(t){let n=globalThis[bc];globalThis[bc]=this;let r=this._running;this._running=!0;let o=!1,i=t;this.currentOpCount=0;try{for(;;){if(this._deferredInterrupt&&(this._deferredInterrupt=!1,i=Le(this._interruptedCause)),this.currentOpCount++,!o&&!this.currentPreventYield&&this.currentScheduler.shouldYield(this)){o=!0;let a=i;i=G(Fc,()=>a)}if(i=this.currentTracerContext?this.currentTracerContext(i,this):i[ot](this),i===Ci){let a=this._yielded;if(ki in a)return this._deferredInterrupt=!1,this._yielded=void 0,a;if(this._deferredInterrupt){this._yielded=void 0,a();continue}return Ci}}}catch(a){return U(i,ot)?this.runLoop(Xr(a)):Xr(`Fiber.runLoop: Not a valid effect: ${String(i)}`)}finally{this._running=r,globalThis[bc]=n}}getCont(t){if(this._deferredInterrupt)return this._deferredInterrupt=!1,PH;for(;;){let n=this._stack.pop();if(!n)return;let r=n[Es]&&n[Es](this);if(r)return r[t]=r,r;if(n[t])return n}}yieldWith(t){return this._yielded=t,Ci}children(){return this._children??=new Set}pipe(){return be(this,arguments)}setContext(t){let n=this.context;if(this.context=t,n!==void 0&&XE(n,t))return;let r=this.getRef(ef);r!==this.currentScheduler&&(this.currentScheduler=r,this._dispatcher=void 0),this.currentSpan=Oc(t,pI),this.currentLogLevel=this.getRef(gI),this.minimumLogLevel=this.getRef(xI),this.currentStackFrame=this.getRef($c),this.maxOpsBeforeYield=this.getRef(_P),this.currentPreventYield=this.getRef(wP),this.runtimeMetrics=Oc(t,kP);let o=Oc(t,mI);this.currentTracerContext=o?o.context:void 0}get currentSpanLocal(){return this.currentSpan?._tag==="Span"?this.currentSpan:void 0}},PH={[sn](e,t){return Le(t._interruptedCause)},[Xn](e,t){return Le(t._interruptedCause)}},vI={interruptChildren:void 0},Vh=s(e=>{if(!e.currentStackFrame)return;let t=new Map;return t.set(IE.key,e.currentStackFrame),Li(t)},"fiberStackAnnotations"),NH=s(e=>{if(!(e._children===void 0||e._children.size===0))return zs(e._children)},"fiberInterruptChildren"),LI=s(e=>{let t=e;return t._exit?M(t._exit):wn(n=>t._exit?n(M(t._exit)):ge(e.addObserver(r=>n(M(r)))))},"fiberAwait"),Hh=s(e=>wn(t=>{let n=e[Symbol.iterator](),r=[],o;function i(){let a=n.next();for(;!a.done;){if(a.value._exit){r.push(a.value._exit),a=n.next();continue}o=a.value.addObserver(c=>{r.push(c),i()});return}t(M(r))}return s(i,"loop"),i(),ge(()=>o?.())}),"fiberAwaitAll");var FI=s(e=>fe(t=>HP(e,t.id)),"fiberInterrupt"),HP=y(e=>U(e[0],Mh),(e,t,n)=>fe(r=>{let o=Vh(r);return o=o&&n?Rc(o,n):o??n,e.interruptUnsafe(t,o),lf(LI(e))})),zs=s(e=>fe(t=>{let n=Vh(t),r=Sh();for(let o of e)o.interruptUnsafe(t.id,n),r.push(o);return lf(Hh(r))}),"fiberInterruptAll");var M=St,Le=Dn,Ue=Yr,ge=Qn({op:"Sync",[ot](e){let t=this[ee](),n=e.getCont(sn);return n?n[sn](t,e):e.yieldWith(St(t))}}),de=Qn({op:"Suspend",[ot](e){return this[ee]()}}),KP=y(e=>e.length>=2||hh(e[0]),(e,t)=>Xe(e)?Ue(t?t():new Jr("Effect.fromOption: Option.none")):M(e.value)),Lc=vn({onFailure:Ue,onSuccess:M}),JP=s(e=>e==null?Ue(new Jr):M(e),"fromNullishOr"),zI=Qn({op:"Yield",[ot](e){let t=!1;return e.currentDispatcher.scheduleTask(()=>{t||e.evaluate(Zn)},this[ee]??0),e.yieldWith(()=>{t=!0})}}),Fc=zI(0),MI=s(e=>M(H(e)),"succeedSome"),cf=M(te()),WP=s(e=>Xe(e)?cf:ve(e.value,H),"transposeOption"),YP=s(e=>de(()=>Le(Ie(e))),"failCauseSync"),zo=s(e=>Xr(e),"die"),Kh=s(e=>de(()=>Ue(Ie(e))),"failSync"),Se=M(void 0);var Jh=s(e=>{let t=typeof e=="function"?e:e.try,n=typeof e=="function"?r=>new sf(r,"An error occurred in Effect.try"):e.catch;return de(()=>{try{return M(Ie(t))}catch(r){return Ue(Ie(()=>n(r)))}})},"try_");var UI=s(e=>GI(function(t,n){Ie(()=>e(n)).then(r=>t(M(r)),r=>t(zo(r)))},e.length!==0),"promise"),XP=s(e=>{let t=typeof e=="function"?e:e.try,n=typeof e=="function"?r=>new sf(r,"An error occurred in Effect.tryPromise"):e.catch;return GI(function(r,o){let i=s(a=>{try{r(Ue(Ie(()=>n(a))))}catch(c){r(zo(c))}},"failWithCatch");try{Ie(()=>t(o)).then(a=>r(M(a)),i)}catch(a){i(a)}},t.length!==0)},"tryPromise"),QP=s(e=>fe(t=>e(t.id)),"withFiberId"),eN=fe(M),tN=QP(M),GI=Qn({op:"Async",single:!1,[ot](e){let t=Ie(()=>this[ee][0].bind(e.currentScheduler)),n=!1,r=!1,o=this[ee][1]?new AbortController:void 0,i=t(a=>{n||(n=!0,r?e.evaluate(a):r=a)},o?.signal);return r!==!1?r:(r=!0,e._yielded=()=>{n=!0},o===void 0&&i===void 0?Ci:(e._stack.push(DH(()=>(n=!0,o?.abort(),i??Zn))),Ci))}}),DH=Qn({op:"AsyncFinalizer",[Es](e){e.interruptible&&(e.interruptible=!1,e._stack.push(lg))},[Xn](e,t){return zP(e)?G(this[ee](),()=>Le(e)):Le(e)}}),wn=s(e=>GI(e,e.length>=2),"callback"),uf=wn(Bm),nN=s((...e)=>de(()=>Nc(e.length===1?e[0]():e[1].call(e[0].self))),"gen"),jI=s((e,...t)=>{let n=t.length===0?function(){return de(()=>Nc(e.apply(this,arguments)))}:function(){let r=de(()=>Nc(e.apply(this,arguments)));for(let o=0;o<t.length;o++)r=t[o](r,...arguments);return r};return ZI(e.length,n)},"fnUntraced"),ZI=s((e,t)=>Object.defineProperty(t,"length",{value:e,configurable:!0}),"defineFunctionLength"),CP=yI(2),rN=s(function(){let e=typeof arguments[0]=="string",t=e?arguments[0]:"Effect.fn",n=e?arguments[1]:void 0,r=Ds();Gn(2);let o=new globalThis.Error;return Gn(r),e?(i,...a)=>OP(t,i,o,a,e,n):OP(t,arguments[0],o,Array.prototype.slice.call(arguments,1),e,n)},"fn"),OP=s((e,t,n,r,o,i)=>{let a=typeof t=="function"?t:r.pop().bind(t.self);return ZI(a.length,function(...c){let l=de(()=>{let d=a.apply(this,arguments);return oe(d)?d:Nc(d)});for(let d=0;d<r.length;d++)l=r[d](l,...c);if(!oe(l))return l;let u=Ds();Gn(2);let f=new globalThis.Error;return Gn(u),Mo(o?of(e,i,d=>TI(l,d)):l,$c,d=>({name:e,stack:CP(()=>f.stack),parent:{name:`${e} (definition)`,stack:CP(()=>n.stack),parent:d}}))})},"makeFn"),oN=s((e,...t)=>ZI(e.length,t.length===0?function(){return RP(()=>e.apply(this,arguments))}:function(){let n=RP(()=>e.apply(this,arguments));for(let r of t)n=r(n);return n}),"fnUntracedEager"),RP=s(e=>{try{let t=e(),n;for(;;){let r=t.next(n);if(r.done)return M(r.value);let o=r.value;if(o&&o._tag==="Success"){n=o.value;continue}else{if(o&&o._tag==="Failure")return r.value;{let i=!0;return de(()=>i?(i=!1,G(r.value,a=>Nc(t,a))):de(()=>Nc(e())))}}}}catch(t){return zo(t)}},"fromIteratorEagerUnsafe"),Nc=Qn({op:"Iterator",single:!1,[sn](e,t){let n=this[ee][0];for(;;){let r=n.next(e);if(r.done)return M(r.value);if(Ve(r.value)){if(r.value._tag==="Failure")return r.value}else return t._stack.push(this),r.value;e=r.value.value}},[ot](e){return this[sn](this[ee][1],e)}}),zt=y(2,(e,t)=>{let n=M(t);return G(e,r=>n)}),Wh=s(e=>ve(e,H),"asSome"),sN=s(e=>Mi(e,{onFailure:M,onSuccess:Ue}),"flip"),kr=y(2,(e,t)=>G(e,n=>oe(t)?t:Ie(()=>t(n)))),io=y(2,(e,t)=>G(e,n=>zt(oe(t)?t:Ie(()=>t(n)),n))),lf=s(e=>G(e,t=>Zn),"asVoid"),iN=s(e=>En(e,Ue),"sandbox"),qI=s((e,t)=>fe(n=>wn(r=>{let o=Kt(e),i=o.length,a=0,c=!1,l=new Set,u=[],f=s((d,p,m)=>{if(a++,d._tag==="Failure"){u.push(...d.cause.reasons),a>=i&&r(Le(Oo(u)));return}let h=!c;c=!0,r(l.size===0?d:G(jo(zs(l)),()=>d)),h&&t?.onWinner&&t.onWinner({fiber:p,index:m,parentFiber:n})},"onExit");for(let d=0;d<i;d++){let p=Gi(n,o[d],!0,!0,!1);if(l.add(p),p.addObserver(m=>{l.delete(p),f(m,p,d)}),c)break}return zs(l)})),"raceAll"),BI=s((e,t)=>fe(n=>wn(r=>{let o=!1,i=new Set,a=s(l=>{o=!0,r(i.size===0?l:G(jo(zs(i)),()=>l))},"onExit"),c=0;for(let l of e){if(o)break;let u=c++,f=Gi(n,l,!0,!0,!1);i.add(f),f.addObserver(d=>{i.delete(f);let p=!o;a(d),p&&t?.onWinner&&t.onWinner({fiber:f,index:u,parentFiber:n})})}return zs(i)})),"raceAllFirst"),aN=y(e=>oe(e[1]),(e,t,n)=>qI([e,t],n)),Yh=y(e=>oe(e[1]),(e,t,n)=>BI([e,t],n)),G=y(2,(e,t)=>{let n=Object.create(LH);return n[ee]=e,n[sn]=t.length!==1?r=>t(r):t,n}),LH=Ro({op:"OnSuccess",[ot](e){return e._stack.push(this),this[ee]}}),cN=y(2,(e,t)=>Ve(e)?e._tag==="Success"?t.onSuccess(e.value):t.onFailure(e.cause):oo(e,t)),Ve=s(e=>ki in e,"effectIsExit"),uN=y(2,(e,t)=>Ve(e)?e._tag==="Success"?t(e.value):e:G(e,t)),lN=s(e=>G(e,J),"flatten"),ve=y(2,(e,t)=>G(e,n=>M(Ie(()=>t(n))))),fN=y(2,(e,t)=>Ve(e)?xN(e,t):ve(e,t)),dN=y(2,(e,t)=>Ve(e)?yN(e,t):XI(e,t)),pN=y(2,(e,t)=>Ve(e)?SN(e,t):QI(e,t)),mN=y(2,(e,t)=>{if(Ve(e)){if(e._tag==="Success")return e;let n=so(e.cause);return ye(n)?e:t(n.success)}return fn(e,t)});var VI=s(e=>e._tag==="Success","exitIsSuccess");var hN=s(e=>e._tag==="Failure","exitIsFailure");var gN=s(e=>e._tag==="Failure"?X(e.cause):ie(e),"exitFilterCause");var Zn=St(void 0),xN=y(2,(e,t)=>e._tag==="Success"?St(t(e.value)):e),yN=y(2,(e,t)=>{if(e._tag==="Success")return e;let n=so(e.cause);return ye(n)?e:Yr(t(n.success))}),SN=y(2,(e,t)=>{if(e._tag==="Success")return St(t.onSuccess(e.value));let n=so(e.cause);return ye(n)?e:Yr(t.onFailure(n.success))});var bN=s(e=>{let t=[];for(let n of e)n._tag==="Failure"&&t.push(...n.cause.reasons);return t.length===0?Zn:Dn(Oo(t))},"exitAsVoidAll");var vN=s(e=>e,"service"),_N=s(e=>fe(t=>M(tI(t.context,e))),"serviceOption"),FH=s(e=>fe(t=>t.context.mapUnsafe.has(e.key)?M(nr(t.context,e)):Ue(new Jr)),"serviceOptional"),zc=y(2,(e,t)=>fe(n=>{let r=n.context,o=t(r);return r===o?e:(n.setContext(o),Gc(e,()=>{n.setContext(r)}))})),Mo=y(3,(e,t,n)=>zc(e,r=>{let o=nr(r,t),i=n(o);return o===i?r:ln(r,t,i)})),wN=s((e,t,n)=>jo(fe(r=>{let o=nr(r.context,e),i=t(o);return r.setContext(ln(r.context,e,i)),Go(nr(r.context,Us),a=>{let c=nr(r.context,e),l;if(n?.reset===void 0){if(c!==i)return Se;l=o}else l=n.reset(o,i,c);return r.setContext(ln(r.context,e,l)),Se})})),"updateServiceScoped"),HI=s(()=>zH,"context"),zH=fe(e=>M(e.context)),Ms=s(e=>fe(t=>e(t.context)),"contextWith"),EN=y(2,(e,t)=>zc(e,It(t))),Uo=y(2,(e,t)=>Ve(e)?e:zc(e,Rc(t))),Mt=s(function(){return arguments.length===1?y(2,(e,t)=>$P(e,arguments[0],t)):y(3,(e,t,n)=>$P(e,t,n)).apply(this,arguments)},"provideService"),$P=s((e,t,n)=>zc(e,r=>r.mapUnsafe.get(t.key)===n?r:ln(r,t,n)),"provideServiceImpl"),Xh=y(3,(e,t,n)=>G(n,r=>Mt(e,t,r))),IN=y(e=>oe(e[1]),(e,t,n)=>KI(e,t,(r,o)=>[r,o],n)),KI=y(e=>oe(e[1]),(e,t,n,r)=>r?.concurrent?ve(gf([e,t],{concurrency:2}),([o,i])=>Ie(()=>n(o,i))):G(e,o=>ve(t,i=>Ie(()=>n(o,i))))),TN=y(e=>oe(e[0]),(e,t,n)=>pT(e,t,n?r=>Ue(n(r)):()=>Ue(new Jr))),kN=y(2,(e,t)=>G(t,n=>n?Wh(e):cf)),JI=y(2,(e,t)=>Array.from({length:t},()=>e)),AN=y(e=>oe(e[0]),(e,t,n)=>gf(JI(e,t),n)),Qh=y(e=>oe(e[0]),(e,t)=>Zo({while:Io,body:It(t?.disableYield?e:G(e,n=>Fc)),step:Bm})),En=y(2,(e,t)=>{let n=Object.create(MH);return n[ee]=e,n[Xn]=t.length!==1?r=>t(r):t,n}),MH=Ro({op:"OnFailure",[ot](e){return e._stack.push(this),this[ee]}}),WI=y(3,(e,t,n)=>En(e,r=>t(r)?Ie(()=>n(r)):Le(r))),Mc=y(3,(e,t,n)=>En(e,r=>{let o=t(r);return ye(o)?Le(o.failure):Ie(()=>n(o.success,r))})),fn=y(2,(e,t)=>Mc(e,so,n=>t(n))),CN=s(e=>Mi(e,{onFailure:s(t=>TE(t)?cf:Ue(t),"onFailure"),onSuccess:MI}),"catchNoSuchElement"),ON=y(2,(e,t)=>Mc(e,NI,t)),RN=y(2,(e,t)=>En(e,n=>kr(Ie(()=>t(n)),Le(n)))),$N=y(3,(e,t,n)=>WI(e,t,r=>kr(Ie(()=>n(r)),Le(r)))),eg=y(3,(e,t,n)=>En(e,r=>{let o=t(r);return ye(o)?Le(r):kr(Ie(()=>n(o.success,r)),Le(r))})),YI=y(2,(e,t)=>eg(e,so,n=>t(n))),PN=y(3,(e,t,n)=>{let r=Array.isArray(t)?o=>U(o,"_tag")&&t.includes(o._tag):Ei(t);return YI(e,o=>r(o)?n(o):Se)}),NN=y(2,(e,t)=>eg(e,NI,n=>t(n))),ff=y(e=>oe(e[0]),(e,t,n,r)=>En(e,o=>{let i=so(o);return ye(i)?Le(i.failure):t(i.success)?Ie(()=>n(i.success)):r?Ie(()=>r(i.success)):Le(o)})),tg=y(e=>oe(e[0]),(e,t,n,r)=>En(e,o=>{let i=so(o);if(ye(i))return Le(i.failure);let a=t(i.success);return ye(a)?r?Ie(()=>r(a.failure)):Le(o):Ie(()=>n(a.success))})),ng=y(e=>oe(e[0]),(e,t,n,r)=>{let o=Array.isArray(t)?i=>U(i,"_tag")&&t.includes(i._tag):Ei(t);return ff(e,o,n,r)}),DN=y(e=>oe(e[0]),(e,t,n)=>{let r;return tg(e,o=>(r??=Object.keys(t),U(o,"_tag")&&yr(o._tag)&&r.includes(o._tag)?X(o):ie(o)),o=>Ie(()=>t[o._tag](o)),n)}),LN=y(e=>oe(e[0]),(e,t,n,r,o)=>ff(e,i=>Ei(i,t)&&U(i,"reason"),i=>{let a=i.reason;return Ei(a,n)?r(a,i):o?Ie(()=>o(a,i)):Ue(i)})),FN=y(e=>oe(e[0]),(e,t,n,r)=>{let o;return ff(e,i=>Ei(i,t)&&U(i,"reason")&&U(i.reason,"_tag")&&yr(i.reason._tag),i=>{let a=i.reason;return o??=Object.keys(n),o.includes(a._tag)?Ie(()=>n[a._tag](a,i)):r?Ie(()=>r(a,i)):Ue(i)})}),zN=y(2,(e,t)=>tg(e,n=>Ei(n,t)&&U(n,"reason")?X(n.reason):ie(n),Ue)),XI=y(2,(e,t)=>fn(e,n=>Kh(()=>t(n)))),QI=y(2,(e,t)=>Mi(e,{onFailure:s(n=>Kh(()=>t.onFailure(n)),"onFailure"),onSuccess:s(n=>ge(()=>t.onSuccess(n)),"onSuccess")})),rg=s(e=>fn(e,zo),"orDie"),MN=y(2,(e,t)=>fn(e,n=>ge(t))),UN=s(e=>de(()=>{let t=e[Symbol.iterator](),n=t.next();if(n.done)return zo(new Error("Received an empty collection of effects"));function r(o){let i=t.next();return i.done?o.value:fn(o.value,a=>r(i))}return s(r,"loop"),r(n)}),"firstSuccessOf"),eT=s(e=>fn(e,t=>G(Fc,()=>eT(e))),"eventually"),GN=y(e=>oe(e[0]),(e,t)=>{if(!t?.log)return Mi(e,{onFailure:s(r=>Se,"onFailure"),onSuccess:s(r=>Se,"onSuccess")});let n=Cr(t.log===!0?void 0:t.log);return oo(e,{onFailure(r){let o=LP(r);return ye(o)?Le(o.failure):t.message===void 0?n(r):n(t.message,r)},onSuccess:s(r=>Se,"onSuccess")})}),og=y(e=>oe(e[0]),(e,t)=>{if(!t?.log)return oo(e,{onFailure:s(r=>Se,"onFailure"),onSuccess:s(r=>Se,"onSuccess")});let n=Cr(t.log===!0?void 0:t.log);return oo(e,{onFailure:s(r=>t.message===void 0?n(r):n(t.message,r),"onFailure"),onSuccess:s(r=>Se,"onSuccess")})}),jN=s(e=>sg(e,{onFailure:te,onSuccess:H}),"option"),Fs=s(e=>df(e,{onFailure:ie,onSuccess:X}),"result"),oo=y(2,(e,t)=>{let n=Object.create(UH);return n[ee]=e,n[sn]=t.onSuccess.length!==1?r=>t.onSuccess(r):t.onSuccess,n[Xn]=t.onFailure.length!==1?r=>t.onFailure(r):t.onFailure,n}),UH=Ro({op:"OnSuccessAndFailure",[ot](e){return e._stack.push(this),this[ee]}}),tT=y(2,(e,t)=>oo(e,{onFailure:s(n=>ge(()=>t.onFailure(n)),"onFailure"),onSuccess:s(n=>ge(()=>t.onSuccess(n)),"onSuccess")})),Mi=y(2,(e,t)=>oo(e,{onFailure:s(n=>{let r=n.reasons.find(Oi);return r?Ie(()=>t.onFailure(r.error)):Le(n)},"onFailure"),onSuccess:t.onSuccess})),sg=y(2,(e,t)=>Mi(e,{onFailure:s(n=>ge(()=>t.onFailure(n)),"onFailure"),onSuccess:s(n=>ge(()=>t.onSuccess(n)),"onSuccess")})),df=y(2,(e,t)=>{if(Ve(e)){if(e._tag==="Success")return St(t.onSuccess(e.value));let n=so(e.cause);return ye(n)?e:St(t.onFailure(n.success))}return sg(e,t)}),ZN=y(2,(e,t)=>Ve(e)?e._tag==="Success"?St(t.onSuccess(e.value)):St(t.onFailure(e.cause)):tT(e,t)),pf=s(e=>Ve(e)?St(e):GH(e),"exit"),GH=Qn({op:"Exit",[ot](e){return e._stack.push(this),this[ee]},[sn](e,t,n){return M(n??St(e))},[Xn](e,t,n){return M(n??Dn(e))}}),qN=df({onFailure:s(()=>!0,"onFailure"),onSuccess:s(()=>!1,"onSuccess")}),BN=df({onFailure:s(()=>!1,"onFailure"),onSuccess:s(()=>!0,"onSuccess")}),VN=y(2,(e,t)=>kr(ji(t),e)),nT=y(2,(e,t)=>Yh(e,G(ji(t.duration),t.orElse))),HN=y(2,(e,t)=>nT(e,{duration:t,orElse:s(()=>Ue(new Gh),"orElse")})),KN=y(2,(e,t)=>Yh(Wh(e),zt(ji(t),te()))),JN=s(e=>Ar(t=>{let n=t.monotonicTimeNanosUnsafe();return ve(e,r=>[Un(t.monotonicTimeNanosUnsafe()-n),r])}),"timed"),_I="~effect/Scope",wI="~effect/Scope/Closeable",Us=Mn("effect/Scope"),rT=s((e,t)=>de(()=>ig(e,t)??Se),"scopeClose"),ig=s((e,t)=>{if(e.state._tag==="Closed")return;let n={_tag:"Closed",exit:t};if(e.state._tag==="Empty"){e.state=n;return}let{finalizers:r}=e.state;if(e.state=n,r.size!==0)return r.size===1?r.values().next().value(t):jH(e,r,t)},"scopeCloseUnsafe"),jH=jI(function*(e,t,n){let r=[],o=[],i=Array.from(t.values()),a=af();for(let c=i.length-1;c>=0;c--){let l=i[c];e.strategy==="sequential"?r.push(yield*pf(l(n))):o.push(Gi(a,l(n),!0,!0,"inherit"))}return o.length>0&&(r=yield*Hh(o)),yield*bN(r)});var WN=s((e,t)=>{let n=mf(t);if(e.state._tag==="Closed")return n.state=e.state,n;let r={};return rf(e,r,o=>rT(n,o)),rf(n,r,o=>ge(()=>oT(e,r))),n},"scopeForkUnsafe"),Go=s((e,t)=>de(()=>e.state._tag==="Closed"?t(e.state.exit):(rf(e,{},t),Se)),"scopeAddFinalizerExit");var rf=s((e,t,n)=>{e.state._tag==="Empty"?e.state={_tag:"Open",finalizers:new Map([[t,n]])}:e.state._tag==="Open"&&e.state.finalizers.set(t,n)},"scopeAddFinalizerUnsafe"),oT=s((e,t)=>{e.state._tag==="Open"&&e.state.finalizers.delete(t)},"scopeRemoveFinalizerUnsafe"),mf=s((e="sequential")=>({[wI]:wI,[_I]:_I,strategy:e,state:ZH}),"scopeMakeUnsafe"),ZH={_tag:"Empty"};var hf=Us,YN=Mt(Us),ag=s(e=>fe(t=>{let n=t.context,r=mf();return t.setContext(ln(t.context,Us,r)),Gc(e,o=>(t.setContext(n),ig(r,o)))}),"scoped");var cg=s(e=>de(()=>{let t=mf();return Ut(e(t),n=>de(()=>ig(t,n)??Se))}),"scopedWith"),ug=s((e,t,n)=>Ms(r=>Ui(o=>G(hf,i=>io(n?.interruptible?o(e):e,a=>Go(i,c=>Uo(t(a,c),r)))))),"acquireRelease"),Uc=s(e=>G(hf,t=>Ms(n=>Go(t,r=>Uo(e(r),n)))),"addFinalizer"),Gc=Qn({op:"OnExit",single:!1,[ot](e){return e._stack.push(this),this[ee][0]},[Es](e){e.interruptible&&this[ee][2]!==!0&&(e._stack.push(lg),e.interruptible=!1)},[sn](e,t,n){n??=St(e);let r=this[ee][1](n);return r?G(r,o=>n):n},[Xn](e,t,n){n??=Dn(e);let r=this[ee][1](n);return r?G(r,o=>n):n}}),Ut=y(2,Gc),XN=y(2,(e,t)=>Ut(e,n=>t)),sT=y(3,(e,t,n)=>Ut(e,r=>t(r)?n(r):Se)),iT=y(3,(e,t,n)=>Ut(e,r=>{let o=t(r);return ye(o)?Se:n(o.success,r)})),aT=y(2,(e,t)=>iT(e,gN,t)),QN=y(3,(e,t,n)=>sT(e,r=>r._tag!=="Failure"?!1:t(r.cause),r=>n(r.cause))),cT=y(3,(e,t,n)=>Ut(e,r=>{if(r._tag!=="Failure")return Se;let o=t(r.cause);return ye(o)?Se:n(o.success,r.cause)})),eD=y(2,(e,t)=>cT(MP,t)(e)),tD=s((e,t,n)=>Ui(r=>G(e,o=>Gc(r(t(o)),i=>n(o,i),!0))),"acquireUseRelease"),nD=s(e=>ug(e,t=>U(t,Symbol.asyncDispose)?UI(()=>t[Symbol.asyncDispose]()):ge(()=>t[Symbol.dispose]())),"acquireDisposable"),uT=y(2,(e,t)=>ge(()=>{let n=no(ct(t)),r=Number.isFinite(n),o=HH(!1),i=0,a=!1,c,l=G(o.await,()=>c);return[fe(u=>{let f=u.getRef(ao),d=r?f.currentTimeMillisUnsafe():0;return a||d<i?c??l:(a=!0,o.closeUnsafe(),c=void 0,Ut(e,p=>ge(()=>{a=!1,i=f.currentTimeMillisUnsafe()+n,c=p,o.openUnsafe()})))}),ge(()=>{i=0,o.closeUnsafe(),c=void 0})]})),lT=y(2,(e,t)=>ve(uT(e,t),n=>n[0])),rD=s(e=>lT(e,lt),"cached"),oD=fe(e=>Le(qh(e.id))),jo=s(e=>fe(t=>(t.interruptible&&(t.interruptible=!1,t._stack.push(lg)),e)),"uninterruptible"),sD=Qn({op:"SetInterruptible",[Es](e){if(e.interruptible=this[ee],e._interruptedCause&&e.interruptible)return()=>Le(e._interruptedCause)}}),lg=sD(!0),qH=sD(!1),iD=s(e=>{if(e.interruptible=!0,e._stack.push(qH),e._interruptedCause)return Le(e._interruptedCause)},"setFiberInterruptible"),fT=s(e=>fe(t=>t.interruptible?e:iD(t)??e),"interruptible"),Ui=s(e=>fe(t=>t.interruptible?(t.interruptible=!1,t._stack.push(lg),e(fT)):e(J)),"uninterruptibleMask"),aD=s(e=>fe(t=>{if(t.interruptible)return e(J);let n=iD(t),r=e(jo);return n??r}),"interruptibleMask"),cD=ve(ug(ge(()=>new AbortController),e=>ge(()=>e.abort())),e=>e.signal),gf=s((e,t)=>To(e)?t?.mode==="result"?jn(e,Fs,t):jn(e,J,t):t?.discard?t.mode==="result"?jn(Object.values(e),Fs,t):jn(Object.values(e),J,t):de(()=>{let n={};return zt(jn(Object.entries(e),([r,o])=>ve(t?.mode==="result"?Fs(o):o,i=>{V(n,r,i)}),{discard:!0,concurrency:t?.concurrency}),n)}),"all"),dT=y(e=>To(e[0])&&!oe(e[0]),(e,t,n)=>ve(jn(e,(r,o)=>Fs(t(r,o)),n),r=>UE(r,J))),uD=y(3,(e,t,n)=>{let r=Kt(e);return r.length===0?ge(t):de(()=>{let o=0,i=t();return ve(Zo({while:s(()=>o<r.length,"while"),body:s(()=>n(i,r[o],o),"body"),step(a){i=a,o++}}),()=>i)})}),lD=y(e=>To(e[0])&&!oe(e[0]),(e,t,n)=>G(dT(e,t,{concurrency:n?.concurrency}),([r,o])=>Cc(r)?Ue(r):n?.discard?Se:M(o))),fD=y(e=>To(e[0])&&!oe(e[0]),(e,t)=>de(()=>{let n=e[Symbol.iterator](),r=n.next();return r.done?M(te()):dD(n,0,t,r.value)})),dD=s((e,t,n,r)=>G(n(r,t),o=>{if(o)return M(H(r));let i=e.next();return i.done?M(te()):dD(e,t+1,n,i.value)}),"findFirstLoop"),pD=y(e=>To(e[0])&&!oe(e[0]),(e,t)=>de(()=>{let n=e[Symbol.iterator](),r=n.next();return r.done?M(te()):mD(n,0,t,r.value)})),mD=s((e,t,n,r)=>G(n(r,t),o=>{if(kt(o))return M(H(o.success));let i=e.next();return i.done?M(te()):mD(e,t+1,n,i.value)}),"findFirstFilterLoop"),Zo=Qn({op:"While",[sn](e,t){return this[ee].step(e),this[ee].while()?(t._stack.push(this),this[ee].body()):Zn},[ot](e){return this[ee].while()?(e._stack.push(this),this[ee].body()):Zn}}),jn=y(e=>typeof e[1]=="function",(e,t,n)=>de(()=>{let r=n?.concurrency??1,o=r==="unbounded"?Number.POSITIVE_INFINITY:Math.max(1,r);if(o===1)return BH(e,t,n);let i=Kt(e),a=i.length;if(a===0)return n?.discard?Se:M([]);let c=n?.discard?void 0:new Array(a),l=VH({f:t,out:c},i,{concurrency:o});return l?zt(l,c):M(c)})),BH=s((e,t,n)=>de(()=>{let r=n?.discard?void 0:[],o=e[Symbol.iterator](),i=o.next(),a=0;return zt(Zo({while:s(()=>!i.done,"while"),body:s(()=>t(i.value,a++),"body"),step:s(c=>{r&&r.push(c),i=o.next()},"step")}),r)}),"forEachSequential"),hD=s(e=>{let t=e.onItem,n=e.step,r=s((o,i,a,c)=>{for(;a<c;a++){let l=i[a],u=t(o,l,a);if(!Ve(u))return G(pf(u),d=>n(o,l,d,a)??r(o,i,a+1,c)??Se);let f=n(o,l,u,a);if(f)return f._tag==="Failure"?f:void 0}},"runSequential");return(o,i,a)=>{let c=0,l=a?.end??i.length,u=a?.concurrency??1;if(u===1)return r(o,i,0,l);let f=a?.orderedStep===!0&&u>1,d=!1,p,m,h,x=!1,S,T,b=c,v=f?new Array(l):void 0,C=s(A=>{let O=Xr(A);return S=O,d=!0,x=!0,m&&m.size>0?G(jo(zs(Array.from(m))),()=>O):O},"failDefect"),w=s((A,O,L)=>{if(!f)return n(o,A,O,L);if(S)return S;for(v[L]=O;b<l;){let q=v[b];if(q===void 0)return;v[b]=void 0;let Q=b++,E=n(o,i[Q],q,Q);if(E)return E}},"runStep"),I=s(()=>{let A=!1;for(;!S&&c<l;c++){let O=i[c],L=T??t(o,O,c);if(Ve(L)){if(S=w(O,L,c),S)break}else if(p){T=void 0;let q=Gi(p,L,!0,!0,"inherit");if(q._exit){if(S=w(O,q._exit,c),S)break;continue}m.add(q);let Q=c;if(q.addObserver(E=>{m.delete(q);try{if(S){if(!x&&E._tag==="Failure")for(let k of E.cause.reasons)k._tag!=="Interrupt"&&(S._tag==="Failure"?S.cause.reasons.push(k):S=Dn(Oo([k])))}else{let k=w(O,E,Q);k&&(S=k._tag==="Failure"?Dn(Oo(k.cause.reasons.slice())):k,I())}if(A){let k=I();k&&h(k)}else d&&m.size===0&&h(S??Se)}catch(k){h(C(k))}}),m.size<u)continue;A=!0,c++;return}else return wn(q=>{p=af(),m=new Set,T=L,h=q;let Q;try{Q=I()}catch(E){return q(C(E))}return Q?q(Q):de(()=>(S=Zn,x=!0,m?zs(m):Se))})}if(d=!0,S){if(m&&m.size>0){let O=Vh(p);m.forEach(L=>L.interruptUnsafe(p.id,O));return}if(h||S._tag==="Failure")return S}else if(h)if(m)m.size===0&&h(Se);else return Zn},"go");return I()}},"iterateEagerImpl"),xf=s(()=>hD,"iterateEager"),VH=hD({onItem(e,t,n){return e.f(t,n)},step(e,t,n,r){if(n._tag==="Failure")return n;e.out&&(e.out[r]=n.value)}}),pT=y(3,(e,t,n)=>G(e,r=>t(r)?M(r):n(r))),mT=y(3,(e,t,n)=>G(e,r=>{let o=t(r);return ye(o)?n(o.failure):M(o.success)})),gD=y(e=>oe(e[0]),(e,t,n)=>mT(e,t,n?r=>Ue(n(r)):()=>Ue(new Jr))),xD=y(e=>To(e[0])&&!oe(e[0]),(e,t,n)=>de(()=>{let r=[];return zt(jn(e,(o,i)=>{let a=t(o,i);return typeof a=="boolean"?(a&&r.push(o),Se):ve(a,c=>{c&&r.push(o)})},{discard:!0,concurrency:n?.concurrency}),r)})),yD=y(e=>To(e[0])&&!oe(e[0]),(e,t)=>de(()=>{let n=[];for(let r of e){let o=t(r);kt(o)&&n.push(o.success)}return M(n)})),SD=y(e=>To(e[0])&&!oe(e[0]),(e,t,n)=>de(()=>{let r=[];return zt(jn(e,o=>ve(t(o),i=>{kt(i)&&r.push(i.success)}),{discard:!0,concurrency:n?.concurrency}),r)})),bD=M({}),vD=eh(ve),_D=th(ve,G),wD=Qm(ve);var ED=y(e=>oe(e[0]),(e,t)=>fe(n=>(uK(),M(Gi(n,e,t?.startImmediately,!1,t?.uninterruptible??!1))))),Gi=s((e,t,n=!1,r=!1,o=!1)=>{let i=e,a=o==="inherit"?i.interruptible:!o,c=new Uh(i.context,a);return n?c.evaluate(t):i.currentDispatcher.scheduleTask(()=>c.evaluate(t),0),!r&&!c._exit&&(i.children().add(c),c.addObserver(()=>i._children.delete(c))),c},"forkUnsafe"),ID=y(e=>oe(e[0]),(e,t)=>fe(n=>M(Gi(n,e,t?.startImmediately,!0,t?.uninterruptible)))),TD=s(e=>fe(t=>{let n=t._children&&new Set(t._children);return Ut(e,r=>{let o=t._children;return o===void 0||o.size===0?Se:(n&&(o=R$(o,i=>!n.has(i))),lf(Hh(o)))})}),"awaitAllChildren"),hT=y(e=>oe(e[0]),(e,t,n)=>fe(r=>{let o=Gi(r,e,n?.startImmediately,!0,n?.uninterruptible);if(!o._exit)if(t.state._tag!=="Closed"){let i={};rf(t,i,s(()=>QP(c=>c===o.id?Se:FI(o)),"finalizer")),o.addObserver(()=>oT(t,i))}else o.interruptUnsafe(r.id,Vh(r));return M(o)})),kD=y(e=>oe(e[0]),(e,t)=>G(hf,n=>hT(e,n,t))),qo=s(e=>(t,n)=>{let r=new Uh(n?.scheduler?ln(e,ef,n.scheduler):e,n?.uninterruptible!==!0);if(r.evaluate(t),r._exit)return r;if(n?.signal)if(n.signal.aborted)r.interruptUnsafe();else{let o=s(()=>r.interruptUnsafe(),"abort");n.signal.addEventListener("abort",o,{once:!0}),r.addObserver(()=>n.signal.removeEventListener("abort",o))}return n?.onFiberStart&&n.onFiberStart(r),r},"runForkWith"),AD=y(2,(e,t)=>{if(e._exit)return e;if(t.state._tag==="Closed")return e.interruptUnsafe(e.id),e;let n={};return rf(t,n,()=>FI(e)),e.addObserver(()=>oT(t,n)),e}),CD=qo(un()),gT=s(e=>{let t=qo(e);return(n,r)=>{let o=t(n,r);return r?.onExit&&o.addObserver(r.onExit),i=>o.interruptUnsafe(i)}},"runCallbackWith"),OD=gT(un()),fg=s(e=>{let t=qo(e);return(n,r)=>{let o=t(n,r);return new Promise(i=>{o.addObserver(a=>i(a))})}},"runPromiseExitWith"),RD=fg(un()),xT=s(e=>{let t=fg(e);return(n,r)=>t(n,r).then(o=>{if(o._tag==="Failure")throw DI(o.cause);return o.value})},"runPromiseWith"),$D=xT(un()),dg=s(e=>{let t=qo(e);return n=>{if(Ve(n))return n;let r=new Fi("sync"),o=t(n,{scheduler:r});return o._dispatcher?.flush(),o._exit??Xr(new Zh(o))}},"runSyncExitWith"),PD=dg(un()),yT=s(e=>{let t=dg(e);return n=>{let r=t(n);if(r._tag==="Failure")throw DI(r.cause);return r.value}},"runSyncWith"),ND=yT(un()),PP=M(!0),NP=M(!1),EI=class{static{s(this,"Latch")}waiters=[];scheduled=void 0;_isOpen;constructor(t){this._isOpen=t}scheduleUnsafe(t){if(this.waiters.length===0)return PP;if(this.scheduled===void 0)this.scheduled=this.waiters,t.currentDispatcher.scheduleTask(this.flushScheduled,0);else for(let n=0;n<this.waiters.length;n++)this.scheduled.push(this.waiters[n]);return this.waiters=[],PP}flushScheduled=s(()=>{if(this.scheduled===void 0)return;let t=this.scheduled;this.scheduled=void 0;for(let n=0;n<t.length;n++)t[n](Zn)},"flushScheduled");flushWaiters(){let t=this.waiters;this.waiters=[],this.flushScheduled();for(let n=0;n<t.length;n++)t[n](Zn)}open=fe(t=>this._isOpen?NP:(this._isOpen=!0,this.scheduleUnsafe(t)));release=fe(t=>this._isOpen?NP:this.scheduleUnsafe(t));openUnsafe(){return this._isOpen?!1:(this._isOpen=!0,this.flushWaiters(),!0)}await=wn(t=>this._isOpen?t(Se):(this.waiters.push(t),ge(()=>{let n=this.waiters.indexOf(t);n!==-1?this.waiters.splice(n,1):this.scheduled!==void 0&&(n=this.scheduled.indexOf(t),n!==-1&&this.scheduled.splice(n,1))})));closeUnsafe(){return this._isOpen?(this._isOpen=!1,!0):!1}close=ge(()=>this.closeUnsafe());whenOpen=s(t=>G(this.await,()=>t),"whenOpen");isOpen(){return this._isOpen}},HH=s(e=>new EI(e??!1),"makeLatchUnsafe");var DD=fe(e=>M(e.getRef(Dh))),LD=y(2,(e,t)=>Mt(e,Dh,t)),FD=Mt(Lh),zD=Mt(Pc),II=BigInt(0),KH={_tag:"Span",spanId:"noop",traceId:"noop",sampled:!1,status:{_tag:"Ended",startTime:II,endTime:II,exit:Zn},attributes:new Map,links:[],kind:"internal",attribute(){},event(){},end(){},addLinks(){}},JH=s(e=>Object.assign(Object.create(KH),e),"noopSpan"),MD=s(e=>e?cn(e.annotations,Nh)?e._tag==="Span"?MD(Ni(e.parent)):te():H(e):te(),"filterDisablePropagation"),ST=s((e,t,n)=>{let r=!e.getRef(Lh)||n?.annotations&&cn(n.annotations,Nh),o=n?.parent!==void 0?H(n.parent):n?.root?te():MD(e.currentSpan),i;if(r)i=JH({name:t,parent:o,annotations:ln(n?.annotations??un(),Nh,!0)});else{let a=e.getRef(Dh),c=e.getRef(ao),l=e.getRef(Pc),u=e.getRef(tf),f=e.getRef(nf),d=n?.level??e.getRef(IP),p=n?.links!==void 0?[...f,...n.links]:f.slice();i=a.span({name:t,parent:o,annotations:n?.annotations??un(),links:p,startTime:l?c.currentTimeNanosUnsafe():BigInt(0),kind:n?.kind??"internal",root:n?.root??Xe(o),sampled:n?.sampled??(an(o)&&o.value.sampled===!1?!1:!QD(e.getRef(TP),d))});for(let[m,h]of Object.entries(u))i.attribute(m,h);if(n?.attributes!==void 0)for(let[m,h]of Object.entries(n.attributes))i.attribute(m,h)}return i},"makeSpanUnsafe"),UD=s((e,t)=>fe(n=>M(ST(n,e,t))),"makeSpan"),Tr=s((e,t)=>jo(fe(n=>{let r=nr(n.context,Us),o=ST(n,e,t??{}),i=n.getRef(ao),a=n.getRef(Pc);return zt(Go(r,c=>BD(o,c,i,a)),o)})),"makeSpanScoped"),GD=s(function(){let e=typeof arguments[0]!="string",t=e?arguments[1]:arguments[0],n=Ls(e?arguments[2]:arguments[1]);if(e){let r=arguments[0];return G(Tr(t,n),o=>Dc(r,o,n))}return r=>G(Tr(t,n),o=>Dc(r,o,n))},"withSpanScoped"),WH=s((e,t)=>(t=typeof t=="function"?t:Yn,Mo($c,n=>({name:e,stack:t,parent:n}))),"provideSpanStackFrame"),jD=tf,ZD=nf,qD=y(e=>oe(e[0]),(e,t,n={})=>{let o=(Array.isArray(t)?t:[t]).map(i=>({span:i,attributes:n}));return Mo(e,nf,i=>[...i,...o])}),BD=s((e,t,n,r)=>ge(()=>{e.status._tag!=="Ended"&&e.end(r?n.currentTimeNanosUnsafe():II,t)}),"endSpan"),of=s((e,...t)=>{let n=t.length===1?void 0:t[0],r=t[t.length-1];return fe(o=>{let i=ST(o,e,n),a=o.getRef(ao),c=o.getRef(Pc);return Ut(Ie(()=>r(i)),l=>BD(i,l,a,c))})},"useSpan"),TI=Mt(Ns),Dc=s(function(){let e=oe(arguments[0]),t=e?arguments[1]:arguments[0],n=e?arguments[2]:arguments[1],r=J;return t._tag==="Span"&&(n=Ls(n),r=WH(t.name,n?.captureStackTrace)),e?TI(r(arguments[0]),t):o=>TI(r(o),t)},"withParentSpan"),VD=s(function(){let e=typeof arguments[0]!="string",t=e?arguments[1]:arguments[0],n=Ls(arguments[2]);if(e){let i=arguments[0];return of(t,arguments[2],a=>Dc(i,a,n))}let r=typeof arguments[1]=="function"?arguments[1]:void 0,o=r?void 0:arguments[1];return(i,...a)=>of(t,r?r(...a):o,c=>Dc(i,c,n))},"withSpan"),HD=y(e=>oe(e[0]),(e,...t)=>Mo(e,tf,n=>{let r=t.length===1?{...n,...t[0]}:{...n};return t.length===1||V(r,t[0],t[1]),r})),KD=s((...e)=>fe(t=>{let n=t.currentSpanLocal;if(n)if(e.length===1)for(let[r,o]of Object.entries(e[0]))n.attribute(r,o);else n.attribute(e[0],e[1]);return Se}),"annotateCurrentSpan"),JD=fe(e=>{let t=e.currentSpanLocal;return t?M(t):Ue(new Jr)}),WD=FH(Ns),ao=Ce("effect/Clock",{defaultValue:s(()=>new kI,"defaultValue")}),SI=2**31-1,kI=class{static{s(this,"ClockImpl")}currentTimeMillisUnsafe(){return Date.now()}currentTimeMillis=ge(()=>this.currentTimeMillisUnsafe());currentTimeNanosUnsafe(){return YH()}currentTimeNanos=ge(()=>this.currentTimeNanosUnsafe());monotonicTimeNanosUnsafe(){return XD()}monotonicTimeNanos=ge(()=>this.monotonicTimeNanosUnsafe());sleep(t){return this.sleepMillis(no(t))}sleepMillis(t){return t<=0?Fc:Number.isFinite(t)?wn(n=>{let r=t>SI?this.sleepMillis(t-SI):Se,o=setTimeout(()=>n(r),Math.min(t,SI));return ge(()=>clearTimeout(o))}):uf}},YD=BigInt(1e6),XD=(function(){let e=globalThis.process?.hrtime;if(typeof e?.bigint=="function")return()=>e.bigint();if(typeof performance<"u"&&typeof performance.now=="function")return()=>BigInt(Math.round(performance.now()*1e6));let t=BigInt(0);return()=>{let n=BigInt(Date.now())*YD;return n>t&&(t=n),t}})(),YH=(function(){let e=BigInt(1e9),t;return()=>{let n=XD(),r=BigInt(Date.now())*YD;if(t===void 0)t=r-n;else{let o=t+n;(r>o?r-o:o-r)>e&&(t=r-n)}return t+n}})(),Ar=s(e=>fe(t=>e(t.getRef(ao))),"clockWith"),ji=s(e=>Ar(t=>t.sleep(ct(e))),"sleep"),pg=Ar(e=>e.currentTimeMillis);var AI="~effect/Cause/TimeoutError";var Gh=class extends $o("TimeoutError"){static{s(this,"TimeoutError")}[AI]=AI;constructor(t){super({message:t})}},CI="~effect/Cause/IllegalArgumentError";var jh=class extends $o("IllegalArgumentError"){static{s(this,"IllegalArgumentError")}[CI]=CI;constructor(t){super({message:t})}},OI="~effect/Cause/ExceededCapacityError";var RI=class extends $o("ExceededCapacityError"){static{s(this,"ExceededCapacityError")}[OI]=OI;constructor(t){super({message:t})}},$I="~effect/Cause/AsyncFiberError";var Zh=class extends $o("AsyncFiberError"){static{s(this,"AsyncFiberError")}[$I]=$I;constructor(t){super({message:"An asynchronous Effect was executed with Effect.runSync",fiber:t})}},PI="~effect/Cause/UnknownError";var sf=class extends $o("UnknownError"){static{s(this,"UnknownError")}[PI]=PI;constructor(t,n){super({message:n,cause:t})}},XH=Ce("effect/Console/CurrentConsole",{defaultValue:s(()=>globalThis.console,"defaultValue")}),QH=s(e=>{switch(e){case"All":return Number.MIN_SAFE_INTEGER;case"Fatal":return 5e4;case"Error":return 4e4;case"Warn":return 3e4;case"Info":return 2e4;case"Debug":return 1e4;case"Trace":return 0;case"None":return Number.MAX_SAFE_INTEGER}},"logLevelToOrder"),eK=RE(Ln,QH),QD=tr(eK),bT=Ce("effect/Loggers/CurrentLoggers",{defaultValue:s(()=>new Set([aK,cK]),"defaultValue")}),tK=Ce("effect/Logger/LogToStderr",{defaultValue:Zm}),eL=s(function(){let e=typeof arguments[0]=="string"?[[arguments[0],arguments[1]]]:Object.entries(arguments[0]);return jo(fe(t=>{let n=t.getRef(Fo),r={...n};for(let o=0;o<e.length;o++){let[i,a]=e[o];V(r,i,a)}return t.setContext(ln(t.context,Fo,r)),Go(nr(t.context,Us),o=>{let i=t.getRef(Fo),a={...i};for(let c=0;c<e.length;c++){let[l,u]=e[c];i[l]===u&&(Object.hasOwn(n,l)?V(a,l,n[l]):delete a[l])}return t.setContext(ln(t.context,Fo,a)),Se})}))},"annotateLogsScoped"),nK="~effect/Logger",rK={[nK]:{_Message:J,_Output:J},pipe(){return be(this,arguments)}},tL=s(e=>{let t=Object.create(rK);return t.log=e,t},"loggerMake"),oK=s(e=>e.replace(/[\s="]/g,"_"),"formatLabel"),sK=s((e,t)=>`${oK(e[0])}=${t-e[1]}ms`,"formatLogSpan");var Cr=s(e=>(...t)=>{let n;for(let r=0,o=t.length;r<o;r++){let i=t[r];wc(i)&&(n?t.splice(r,1):t=t.slice(0,r).concat(t.slice(r+1)),n=n?Oo(n.reasons.concat(i.reasons)):i,r--)}return n===void 0&&(n=ah),fe(r=>{let o=e??r.currentLogLevel;if(QD(r.minimumLogLevel,o))return Se;let i=r.getRef(ao),a=r.getRef(bT);if(a.size>0){let c=new Date(i.currentTimeMillisUnsafe());for(let l of a)l.log({cause:n,fiber:r,date:c,logLevel:o,message:t})}return Se})},"logWithLevel");var zi={bold:"1",red:"31",green:"32",yellow:"33",blue:"34",cyan:"36",white:"37",gray:"90",black:"30",bgBrightRed:"101"},Qse={None:[],All:[],Trace:[zi.gray],Debug:[zi.blue],Info:[zi.green],Warn:[zi.yellow],Error:[zi.red],Fatal:[zi.bgBrightRed,zi.black]};var iK=s(e=>`${e.getHours().toString().padStart(2,"0")}:${e.getMinutes().toString().padStart(2,"0")}:${e.getSeconds().toString().padStart(2,"0")}.${e.getMilliseconds().toString().padStart(3,"0")}`,"defaultDateFormat");var aK=tL(({cause:e,date:t,fiber:n,logLevel:r,message:o})=>{let i=Array.isArray(o)?o.slice():[o];e.reasons.length>0&&i.push(Bh(e));let a=t.getTime(),c=n.getRef(Fh),l="";for(let p of c)l+=` ${sK(p,a)}`;let u=n.getRef(Fo);Object.keys(u).length>0&&i.push(u);let f=n.getRef(XH);(n.getRef(tK)?f.error:f.log)(`[${iK(t)}] ${r.toUpperCase()} (#${n.id})${l}:`,...i)}),cK=tL(({cause:e,fiber:t,logLevel:n,message:r})=>{let o=t.getRef(ao),i=t.getRef(Fo),a=t.currentSpan;if(a===void 0||a._tag==="ExternalSpan")return;let c={};for(let[l,u]of Object.entries(i))V(c,l,u);c["effect.fiberId"]=t.id,c["effect.logLevel"]=n.toUpperCase(),e.reasons.length>0&&(c["effect.cause"]=Bh(e)),a.event(a$(Array.isArray(r)&&r.length===1?r[0]:r),o.currentTimeNanosUnsafe(),c)});function uK(){vI.interruptChildren??=NH}s(uK,"interruptChildrenPatch");var vT=M(void 0);var nL=y(e=>oe(e[0]),(e,t)=>aT(e,n=>fe(r=>(lK(r,n,t?.defectsOnly),Se)))),lK=s((e,t,n)=>{let r=e.getRef(AP);if(r.size===0||n&&!FP(t))return;let o={cause:t,fiber:e,timestamp:e.getRef(ao).currentTimeNanosUnsafe()};r.forEach(i=>i.report(o))},"reportCauseUnsafe");var rL=wc,oL=d$,mg=Oi;var hg=Oo,sL=ah;var gg=s(e=>new Ai(e),"makeFailReason"),xg=s(e=>new jl(e),"makeDieReason"),yg=DP;var Gs=GP;var _T=so;var iL=Bh;var wT=Vl;var ET=y$;var Sg=jh;var $={};$t($,{Do:()=>FJ,Transaction:()=>Kc,TypeId:()=>TJ,abortSignal:()=>N3,acquireDisposable:()=>x3,acquireRelease:()=>g3,acquireUseRelease:()=>y3,addFinalizer:()=>S3,all:()=>kJ,andThen:()=>JJ,annotateCurrentSpan:()=>V3,annotateLogs:()=>E5,annotateLogsScoped:()=>I5,annotateSpans:()=>B3,as:()=>XJ,asSome:()=>QJ,asVoid:()=>eW,awaitAllChildren:()=>l5,bind:()=>UJ,bindTo:()=>zJ,cached:()=>k3,cachedInvalidateWithTTL:()=>C3,cachedWithTTL:()=>A3,callback:()=>ak,catch:()=>oW,catchCause:()=>Hs,catchCauseFilter:()=>hW,catchCauseIf:()=>mW,catchDefect:()=>lW,catchEager:()=>Xg,catchFilter:()=>dW,catchIf:()=>fW,catchNoSuchElement:()=>pW,catchReason:()=>aW,catchReasons:()=>cW,catchTag:()=>sW,catchTags:()=>iW,clockWith:()=>dz,context:()=>o3,contextWith:()=>s3,currentParentSpan:()=>K3,currentSpan:()=>H3,delay:()=>DW,die:()=>Hg,effectify:()=>F5,ensuring:()=>b3,eventually:()=>_W,exit:()=>Qc,fail:()=>W,failCause:()=>ZJ,failCauseSync:()=>Yc,failSync:()=>jJ,fiber:()=>f5,fiberId:()=>d5,filter:()=>jW,filterMap:()=>ZW,filterMapEffect:()=>qW,filterMapOrElse:()=>VW,filterMapOrFail:()=>KW,filterOrElse:()=>BW,filterOrFail:()=>HW,findFirst:()=>RJ,findFirstFilter:()=>$J,firstSuccessOf:()=>RW,flatMap:()=>In,flatMapEager:()=>qn,flatten:()=>uk,flip:()=>tW,fn:()=>m5,fnUntraced:()=>p5,fnUntracedEager:()=>Qg,forEach:()=>PJ,forever:()=>D3,forkChild:()=>i5,forkDetach:()=>u5,forkIn:()=>a5,forkScoped:()=>c5,fromNullishOr:()=>KJ,fromOption:()=>VJ,fromResult:()=>ck,gen:()=>GJ,ignore:()=>TW,ignoreCause:()=>kW,interrupt:()=>uz,interruptible:()=>O3,interruptibleMask:()=>P3,isEffect:()=>na,isFailure:()=>n3,isSuccess:()=>r3,let:()=>MJ,linkSpans:()=>Y3,log:()=>g5,logDebug:()=>v5,logError:()=>S5,logFatal:()=>x5,logInfo:()=>b5,logTrace:()=>_5,logWarning:()=>y5,logWithLevel:()=>h5,makeSpan:()=>X3,makeSpanScoped:()=>Q3,map:()=>Of,mapBoth:()=>xW,mapBothEager:()=>Ct,mapEager:()=>ra,mapError:()=>gW,mapErrorEager:()=>$f,match:()=>lk,matchCause:()=>YW,matchCauseEager:()=>XW,matchCauseEffect:()=>e3,matchCauseEffectEager:()=>QW,matchEager:()=>WW,matchEffect:()=>t3,never:()=>LJ,onError:()=>v3,onErrorFilter:()=>w3,onErrorIf:()=>_3,onExit:()=>dk,onExitFilter:()=>T3,onExitIf:()=>I3,onExitPrimitive:()=>E3,onInterrupt:()=>R3,option:()=>YJ,orDie:()=>yW,orElseSucceed:()=>OW,partition:()=>AJ,promise:()=>NJ,provide:()=>i3,provideContext:()=>fk,provideService:()=>Wg,provideServiceEffect:()=>Yg,race:()=>UW,raceAll:()=>zW,raceAllFirst:()=>MW,raceFirst:()=>GW,reduce:()=>CJ,repeat:()=>L3,repeatOrElse:()=>F3,replicate:()=>z3,replicateEffect:()=>M3,request:()=>o5,requestUnsafe:()=>s5,result:()=>WJ,retry:()=>wW,retryOrElse:()=>EW,runCallback:()=>hk,runCallbackWith:()=>mk,runFork:()=>eu,runForkWith:()=>pk,runPromise:()=>Rf,runPromiseExit:()=>tu,runPromiseExitWith:()=>xk,runPromiseWith:()=>gk,runSync:()=>yk,runSyncExit:()=>uo,runSyncExitWith:()=>bk,runSyncWith:()=>Sk,sandbox:()=>IW,satisfiesErrorType:()=>M5,satisfiesServicesType:()=>U5,satisfiesSuccessType:()=>z5,schedule:()=>U3,scheduleFrom:()=>fz,scope:()=>p3,scoped:()=>m3,scopedWith:()=>h3,service:()=>c3,serviceOption:()=>u3,setContext:()=>a3,sleep:()=>LW,spanAnnotations:()=>J3,spanLinks:()=>W3,succeed:()=>se,succeedNone:()=>Jc,succeedSome:()=>sz,suspend:()=>Vg,sync:()=>Wc,tap:()=>Jg,tapCause:()=>az,tapCauseFilter:()=>vW,tapCauseIf:()=>bW,tapDefect:()=>cz,tapError:()=>iz,tapErrorTag:()=>SW,timed:()=>FW,timeout:()=>$W,timeoutOption:()=>PW,timeoutOrElse:()=>NW,tracer:()=>G3,track:()=>k5,trackDefects:()=>O5,trackDuration:()=>R5,trackErrors:()=>C5,trackSuccesses:()=>A5,transposeOption:()=>HJ,try:()=>Xc,tryPromise:()=>ik,tx:()=>$5,txRetry:()=>L5,undefined:()=>DJ,uninterruptible:()=>$3,uninterruptibleMask:()=>lz,unwrapReason:()=>uW,updateContext:()=>l3,updateService:()=>f3,updateServiceScoped:()=>d3,useSpan:()=>e5,validate:()=>OJ,void:()=>Cf,when:()=>JW,whileLoop:()=>oz,withErrorReporting:()=>CW,withExecutionPlan:()=>AW,withFiber:()=>Kg,withLogSpan:()=>T5,withLogger:()=>w5,withParentSpan:()=>r5,withSpan:()=>t5,withSpanScoped:()=>n5,withTracer:()=>j3,withTracerEnabled:()=>Z3,withTracerTiming:()=>q3,yieldNow:()=>qJ,yieldNowWith:()=>BJ,zip:()=>nW,zipWith:()=>rW});var aL=EE,qi=St,Bo=Dn,jc=Yr;var js=Zn;var Jt=VI,cL=hN;var ft={};$t(ft,{CurrentMemoMap:()=>Vi,build:()=>_L,buildWithMemoMap:()=>Ji,buildWithScope:()=>OT,catch:()=>OK,catchCause:()=>$K,catchTag:()=>RK,effect:()=>Bc,effectContext:()=>$T,effectDiscard:()=>_K,empty:()=>vK,flatMap:()=>IL,forkMemoMap:()=>bK,forkMemoMapUnsafe:()=>CT,fresh:()=>PK,fromBuild:()=>Zs,fromBuildMemo:()=>Eg,isLayer:()=>wg,launch:()=>NK,makeMemoMap:()=>SK,makeMemoMapUnsafe:()=>qs,merge:()=>EK,mergeAll:()=>Ig,mock:()=>DK,orDie:()=>CK,parentSpan:()=>kL,provide:()=>qc,provideMerge:()=>IK,satisfiesErrorType:()=>zK,satisfiesServicesType:()=>MK,satisfiesSuccessType:()=>FK,span:()=>UK,succeed:()=>bf,succeedContext:()=>Hi,suspend:()=>wK,sync:()=>RT,syncContext:()=>TT,tap:()=>TK,tapCause:()=>AK,tapError:()=>kK,unwrap:()=>kT,updateService:()=>TL,withParentSpan:()=>AT,withSpan:()=>GK});var fK="~effect/Deferred";var dK={[fK]:{_A:J,_E:J},pipe(){return be(this,arguments)}},uL=s(()=>{let e=Object.create(dK);return e.resumes=void 0,e.effect=void 0,e},"makeUnsafe");var lL=s(e=>wn(t=>e.effect?t(e.effect):(e.resumes??=[],e.resumes.push(t),ge(()=>{let n=e.resumes.indexOf(t);e.resumes.splice(n,1)}))),"_await");var pK=y(2,(e,t)=>ge(()=>mK(e,t))),fL=pK;var mK=s((e,t)=>{if(e.effect)return!1;if(e.effect=t,e.resumes){for(let n=0;n<e.resumes.length;n++)e.resumes[n](t);e.resumes=void 0}return!0},"doneUnsafe");var pL=Fo;var mL=Fh,hL=$c;var gL=Us;var bg=mf,yf=YN;var Zc=WN,Sf=rT;var vL="~effect/Layer",xL="~effect/Layer/MemoMap",gK=s((e,t)=>(e.observers++,kr(Go(t,n=>e.finalizer(n)),e.effect)),"memoMapReuse"),wg=s(e=>U(e,vL),"isLayer"),xK={[vL]:{_ROut:J,_E:J,_RIn:J},pipe(){return be(this,arguments)}},Ki=s(e=>{let t=Object.create(xK);return t.build=e,t},"fromBuildUnsafe"),Zs=s(e=>Ki((t,n)=>{let r=Zc(n);return Ut(e(t,r),o=>o._tag==="Failure"?Sf(r,o):Se)}),"fromBuild"),Eg=s(e=>{let t=Zs((n,r)=>n.getOrElseMemoize(t,r,e));return t},"fromBuildMemo"),yK=s((e,t,n,r)=>{let o=bg(),i=uL(),a={observers:1,effect:lL(i),finalizer:s(c=>de(()=>(a.observers--,a.observers===0?(e.map.delete(t),Sf(o,c)):Se)),"finalizer")};return e.map.set(t,a),Go(n,a.finalizer).pipe(G(()=>r(e,o)),Ut(c=>(a.effect=c,fL(i,c))))},"memoMapBuild"),_g=class{static{s(this,"MemoMapImpl")}get[xL](){return xL}parent;constructor(t){this.parent=t}map=new Map;get(t,n){let r=this.map.get(t);return r?gK(r,n):this.parent?.get(t,n)}getOrElseMemoize(t,n,r){return de(()=>{let o=this.get(t,n);return o||yK(this,t,n,r)})}},qs=s(()=>new _g,"makeMemoMapUnsafe"),CT=s(e=>new _g(e),"forkMemoMapUnsafe"),SK=ge(qs),bK=s(e=>ge(()=>CT(e)),"forkMemoMap"),Vi=class e extends Mn()("effect/Layer/CurrentMemoMap"){static{s(this,"CurrentMemoMap")}static forkOrCreate(t){let n=QE(t,e);return n?CT(n):qs()}},Ji=y(3,(e,t,n)=>Mt(ve(e.build(t,n),ln(Vi,t)),Vi,t)),_L=s(e=>fe(t=>Ji(e,Vi.forkOrCreate(t.context),nr(t.context,gL))),"build"),OT=y(2,(e,t)=>fe(n=>Ji(e,Vi.forkOrCreate(n.context),t))),bf=s(function(){return arguments.length===1?e=>Hi(to(arguments[0],e)):Hi(to(arguments[0],arguments[1]))},"succeed"),Hi=s(e=>Ki(It(M(e))),"succeedContext"),vK=Hi(un()),RT=s(function(){return arguments.length===1?e=>TT(()=>to(arguments[0],e())):TT(()=>to(arguments[0],arguments[1]()))},"sync"),TT=s(e=>Eg(It(ge(e))),"syncContext"),Bc=s(function(){return arguments.length===1?e=>yL(arguments[0],e):yL(arguments[0],arguments[1])},"effect"),yL=s((e,t)=>$T(ve(t,n=>to(e,n))),"effectImpl"),$T=s(e=>Eg((t,n)=>yf(e,n)),"effectContext"),_K=s(e=>$T(zt(e,un())),"effectDiscard"),wK=s(e=>Eg((t,n)=>de(()=>e().build(t,n))),"suspend"),kT=s(e=>{let t=Mn("effect/Layer/unwrap");return IL(Bc(t)(e),cn(t))},"unwrap"),wL=s((e,t,n)=>{let r=Zc(n,"parallel");return jn(e,o=>o.build(t,Zc(r,"sequential")),{concurrency:e.length}).pipe(ve(o=>nI(...o)))},"mergeAllEffect"),Ig=s((...e)=>Zs((t,n)=>wL(e,t,n)),"mergeAll"),EK=y(2,(e,t)=>Ig(e,...Array.isArray(t)?t:[t])),EL=s((e,t,n)=>Zs((r,o)=>G(Array.isArray(t)?wL(t,r,o):t.build(r,o),i=>e.build(r,o).pipe(Uo(i),ve(a=>n(a,i))))),"provideWith"),qc=y(2,(e,t)=>EL(e,t,J)),IK=y(2,(e,t)=>EL(e,t,(n,r)=>Rc(r,n))),IL=y(2,(e,t)=>Zs((n,r)=>G(e.build(n,r),o=>t(o).build(n,r)))),TK=y(2,(e,t)=>Zs((n,r)=>G(e.build(n,r),o=>yf(zt(t(o),o),r)))),kK=y(2,(e,t)=>Zs((n,r)=>fn(e.build(n,r),o=>yf(kr(t(o),Ue(o)),r)))),AK=y(2,(e,t)=>Zs((n,r)=>En(e.build(n,r),o=>yf(kr(t(o),Le(o)),r)))),CK=s(e=>Ki((t,n)=>rg(e.build(t,n))),"orDie"),OK=y(2,(e,t)=>Ki((n,r)=>fn(e.build(n,r),o=>t(o).build(n,r))));var RK=y(3,(e,t,n)=>Ki((r,o)=>ng(e.build(r,o),t,i=>n(i).build(r,o)))),$K=y(2,(e,t)=>Ki((n,r)=>En(e.build(n,r),o=>t(o).build(n,r)))),TL=y(3,(e,t,n)=>qc(e,Bc(t,ve(t,n)))),PK=s(e=>Ki((t,n)=>e.build(qs(),n)),"fresh"),NK=s(e=>ag(kr(_L(e),uf)),"launch"),DK=s(function(){return arguments.length===1?e=>SL(arguments[0],e):SL(arguments[0],arguments[1])},"mock"),SL=s((e,t)=>bf(e)(new Proxy({...t},{get(n,r,o){if(r in n)return n[r];let i=Ds();Gn(2);let a=new Error(`${e.key}: Unimplemented method "${r.toString()}"`);return Gn(i),a.name="UnimplementedError",LK(a)},has:Io})),"mockImpl"),LK=s(e=>{let t=Object.assign(zo(e),{[bL]:bL,channel:{[vg]:vg,transform:s(()=>M(t),"transform"),pipe(){return be(this,arguments)}},[vg]:vg,transform:s(()=>M(t),"transform")});function n(){return t}return s(n,"unimplemented"),Object.assign(n,t),Object.setPrototypeOf(n,Object.getPrototypeOf(t)),n},"makeUnimplemented"),bL="~effect/Stream",vg="~effect/Channel",FK=s(()=>e=>e,"satisfiesSuccessType"),zK=s(()=>e=>e,"satisfiesErrorType"),MK=s(()=>e=>e,"satisfiesServicesType"),UK=s((e,t)=>(t=Ls(t),Bc(Ns,t?.onEnd?io(Tr(e,t),n=>Uc(r=>t.onEnd(n,r))):Tr(e,t))),"span"),kL=s(e=>Hi(Ns.context(e)),"parentSpan"),GK=s(function(){let e=typeof arguments[0]!="string",t=e?arguments[1]:arguments[0],n=Ls(e?arguments[2]:arguments[1]);if(e){let r=arguments[0];return kT(ve(n?.onEnd!==void 0?io(Tr(t,n),o=>Uc(i=>n.onEnd(o,i))):Tr(t,n),o=>AT(r,o)))}return r=>kT(ve(n?.onEnd!==void 0?io(Tr(t,n),o=>Uc(i=>n.onEnd(o,i))):Tr(t,n),o=>AT(r,o)))},"withSpan"),AT=s(function(){let e=wg(arguments[0]),t=e?arguments[1]:arguments[0],n=e?arguments[2]:arguments[1],r=J;t._tag==="Span"&&(n=Ls(n),r=jK(t.name,n?.captureStackTrace));let o=kL(t);return e?qc(r(arguments[0]),o):i=>qc(r(i),o)},"withParentSpan"),jK=s((e,t)=>(t=typeof t=="function"?t:Yn,TL(hL,n=>({name:e,stack:t,parent:n}))),"provideSpanStackFrame");var AL="~effect/ExecutionPlan";var ZK={[AL]:AL,get captureRequirements(){let e=this;return Ms(t=>M(qK(e.steps.map(n=>({...n,provide:wg(n.provide)?qc(n.provide,Hi(t)):n.provide})))))},pipe(){return be(this,arguments)}},qK=s(e=>{let t=Object.create(ZK);return t.steps=e,t},"makeProto");var CL=Ce("effect/ExecutionPlan/CurrentMetadata",{defaultValue:It({attempt:0,stepIndex:0})});var RL=class extends _i{static{s(this,"Class")}constructor(e){super(),e&&nh(this,e)}};var Tg=$o;var PT=pg;var Cg="~effect/time/DateTime",Og="~effect/time/DateTime/TimeZone",NL={[Cg]:Cg,pipe(){return be(this,arguments)},[yt](){return this.toString()},toJSON(){return Vs(this).toJSON()}},BK={...NL,_tag:"Utc",[Te](){return br(this.epochMilliseconds)},[ke](e){return Xi(e)&&e._tag==="Utc"&&this.epochMilliseconds===e.epochMilliseconds},toString(){return`DateTime.Utc(${Vs(this).toJSON()})`}},VK={...NL,_tag:"Zoned",[Te](){return gt(br(this.epochMilliseconds))(pe(this.zone))},[ke](e){return Xi(e)&&e._tag==="Zoned"&&this.epochMilliseconds===e.epochMilliseconds&&re(this.zone,e.zone)},toString(){return`DateTime.Zoned(${VT(this)})`}},DL={[Og]:Og,[yt](){return this.toString()}},HK={...DL,_tag:"Named",[Te](){return Be(`Named:${this.id}`)},[ke](e){return Qi(e)&&e._tag==="Named"&&this.id===e.id},toString(){return`TimeZone.Named(${this.id})`},toJSON(){return{_id:"TimeZone",_tag:"Named",id:this.id}}},KK={...DL,_tag:"Offset",[Te](){return Be(`Offset:${this.offset}`)},[ke](e){return Qi(e)&&e._tag==="Offset"&&this.offset===e.offset},toString(){return`TimeZone.Offset(${Ug(this.offset)})`},toJSON(){return{_id:"TimeZone",_tag:"Offset",offset:this.offset}}},or=s((e,t,n)=>{let r=Object.create(VK);return r.epochMilliseconds=e,r.zone=t,Object.defineProperty(r,"partsUtc",{value:n,enumerable:!1,writable:!0}),Object.defineProperty(r,"adjustedEpochMillis",{value:void 0,enumerable:!1,writable:!0}),Object.defineProperty(r,"partsAdjusted",{value:void 0,enumerable:!1,writable:!0}),r},"makeZonedProto"),Xi=s(e=>U(e,Cg),"isDateTime"),Or=s(e=>Xi(e[0]),"isDateTimeArgs"),Qi=s(e=>U(e,Og),"isTimeZone"),LL=s(e=>Qi(e)&&e._tag==="Offset","isTimeZoneOffset"),FL=s(e=>Qi(e)&&e._tag==="Named","isTimeZoneNamed"),zL=s(e=>e._tag==="Utc","isUtc"),NT=s(e=>e._tag==="Zoned","isZoned"),ML=Tt((e,t)=>e.epochMilliseconds===t.epochMilliseconds),co=No((e,t)=>e.epochMilliseconds<t.epochMilliseconds?-1:e.epochMilliseconds>t.epochMilliseconds?1:0),UL=Hl(co),Bs=s(e=>{let t=Object.create(BK);return t.epochMilliseconds=e,Object.defineProperty(t,"partsUtc",{value:void 0,enumerable:!1,writable:!0}),t},"makeUtc"),Wi=s(e=>{let t=e.getTime();if(Number.isNaN(t))throw new Sg("Invalid date");return Bs(t)},"fromDateUnsafe"),Pg=s(e=>{if(Xi(e))return e;if(e instanceof Date)return Wi(e);if(typeof e=="object"){if("epochMilliseconds"in e)return Wi(new Date(e.epochMilliseconds));let t=new Date(0);return UT(t,e),Wi(t)}else if(typeof e=="string"&&!JK(e))return Wi(new Date(e+"Z"));return Wi(new Date(e))},"makeUnsafe"),JK=s(e=>/Z|GMT|[+-]\d{2}$|[+-]\d{2}:?\d{2}$|\]$/.test(e),"hasZone"),WK=-864e13+720*60*1e3,YK=864e13-840*60*1e3,DT=s((e,t)=>{let n=t?.timeZone;if(n===void 0&&Xi(e)&&NT(e))return e;let r=Pg(e);if(r.epochMilliseconds<WK||r.epochMilliseconds>YK)throw new RangeError(`Epoch millis out of range: ${r.epochMilliseconds}`);n===void 0&&typeof e=="object"&&"timeZoneId"in e&&(n=e.timeZoneId);let o;if(n===void 0){let i=new Date(r.epochMilliseconds).getTimezoneOffset()*-60*1e3;o=Yi(i)}else if(Qi(n))o=n;else if(typeof n=="number")o=Yi(n);else{let i=FT(n);if(Xe(i))throw new Sg(`Invalid time zone: ${n}`);o=i.value}return t?.adjustForTimeZone!==!0?or(r.epochMilliseconds,o,r.partsUtc):GT(r.epochMilliseconds,o,t?.disambiguation??"compatible")},"makeZonedUnsafe"),Rg=Di(DT),GL=Di(Pg),XK=/^(.{17,35})\[(.+)\]$/,jL=s(e=>{let t=XK.exec(e);if(t===null){let o=jT(e);return o!==null?Rg(e,{timeZone:o}):te()}let[,n,r]=t;return Rg(n,{timeZone:r})},"makeZonedFromString"),Ng=ve(PT,Bs),ZL=ve(PT,e=>new Date(e)),Dg=s(()=>Bs(Date.now()),"nowUnsafe"),qL=s(e=>Bs(e.epochMilliseconds),"toUtc"),wf=y(Or,(e,t,n)=>n?.adjustForTimeZone===!0?GT(e.epochMilliseconds,t,n?.disambiguation??"compatible"):or(e.epochMilliseconds,t,e.partsUtc)),BL=y(Or,(e,t,n)=>wf(e,Yi(t),n)),_f=new Map,VL={day:"numeric",month:"numeric",year:"numeric",hour:"numeric",minute:"numeric",second:"numeric",timeZoneName:"longOffset",fractionalSecondDigits:3,hourCycle:"h23"},HL=s(e=>{let t=e.resolvedOptions().timeZone;if(_f.has(t))return _f.get(t);let n=Object.create(HK);return n.id=t,n.format=e,_f.set(t,n),n},"zoneMakeIntl"),Ef=s(e=>{if(_f.has(e))return _f.get(e);try{return HL(new Intl.DateTimeFormat("en-US",{...VL,timeZone:e}))}catch{throw new Sg(`Invalid time zone: ${e}`)}},"zoneMakeNamedUnsafe"),Yi=s(e=>{let t=Object.create(KK);return t.offset=e,t},"zoneMakeOffset"),Lg=Di(Ef),LT=s(e=>Jh({try:s(()=>Ef(e),"try"),catch:s(t=>t,"catch")}),"zoneMakeNamedEffect"),KL=s(()=>HL(new Intl.DateTimeFormat("en-US",VL)),"zoneMakeLocal"),QK=/^(?:GMT|[+-])/,FT=s(e=>{if(QK.test(e)){let t=jT(e);return t===null?te():H(Yi(t))}return Lg(e)},"zoneFromString"),JL=s(e=>e._tag==="Offset"?Ug(e.offset):e.id,"zoneToString"),WL=y(Or,(e,t,n)=>Tc(Lg(t),r=>wf(e,r,n))),YL=y(Or,(e,t,n)=>wf(e,Ef(t),n)),XL=y(2,(e,t)=>wr(Vc(t)-Vc(e))),QL=Ec(co),eF=Ic(co),Fg=tr(co),tF=As(co),zg=Qr(co),nF=ks(co),rF=Kl(co),oF=s(e=>ve(Ng,zg(e)),"isFuture"),sF=s(e=>zg(Dg(),e),"isFutureUnsafe"),iF=s(e=>ve(Ng,Fg(e)),"isPast"),aF=s(e=>Fg(Dg(),e),"isPastUnsafe"),Vs=s(e=>new Date(e.epochMilliseconds),"toDateUtc"),Vo=s(e=>{if(e._tag==="Utc")return new Date(e.epochMilliseconds);if(e.zone._tag==="Offset")return new Date(e.epochMilliseconds+e.zone.offset);if(e.adjustedEpochMilliseconds!==void 0)return new Date(e.adjustedEpochMilliseconds);let t=e.zone.format.formatToParts(e.epochMilliseconds).filter(r=>r.type!=="literal"),n=new Date(0);return n.setUTCFullYear(Number(t[2].value),Number(t[0].value)-1,Number(t[1].value)),n.setUTCHours(Number(t[3].value),Number(t[4].value),Number(t[5].value),Number(t[6].value)),e.adjustedEpochMilliseconds=n.getTime(),n},"toDate"),Mg=s(e=>Vo(e).getTime()-Vc(e),"zonedOffset"),Ug=s(e=>{let t=Math.abs(e),n=Math.floor(t/(3600*1e3)),r=Math.round(t%(3600*1e3)/(60*1e3));return r===60&&(n+=1,r=0),`${e<0?"-":"+"}${String(n).padStart(2,"0")}:${String(r).padStart(2,"0")}`},"offsetToString"),zT=s(e=>Ug(Mg(e)),"zonedOffsetIso"),Vc=s(e=>e.epochMilliseconds,"toEpochMillis"),cF=s(e=>Math.floor(e.epochMilliseconds/1e3),"toEpochSeconds"),uF=s(e=>Bs(e*1e3),"fromEpochSeconds"),lF=s(e=>jg(e,t=>(t.setUTCHours(0,0,0,0),Bs(t.getTime()))),"removeTime"),fF=s(e=>({millisecond:e.getUTCMilliseconds(),second:e.getUTCSeconds(),minute:e.getUTCMinutes(),hour:e.getUTCHours(),day:e.getUTCDate(),weekDay:e.getUTCDay(),month:e.getUTCMonth()+1,year:e.getUTCFullYear()}),"dateToParts"),MT=s(e=>e._tag==="Utc"?Gg(e):(e.partsAdjusted!==void 0||(e.partsAdjusted=jg(e,fF)),e.partsAdjusted),"toParts"),Gg=s(e=>(e.partsUtc!==void 0||(e.partsUtc=qT(e,fF)),e.partsUtc),"toPartsUtc"),dF=y(2,(e,t)=>Gg(e)[t]),pF=y(2,(e,t)=>MT(e)[t]),UT=s((e,t)=>{if(t.year!==void 0&&e.setUTCFullYear(t.year),t.month!==void 0&&e.setUTCMonth(t.month-1),t.day!==void 0&&e.setUTCDate(t.day),t.weekDay!==void 0){let n=t.weekDay-e.getUTCDay();e.setUTCDate(e.getUTCDate()+n)}t.hour!==void 0&&e.setUTCHours(t.hour),t.minute!==void 0&&e.setUTCMinutes(t.minute),t.second!==void 0&&e.setUTCSeconds(t.second),t.millisecond!==void 0&&e.setUTCMilliseconds(t.millisecond)},"setPartsDate"),mF=y(2,(e,t)=>ea(e,n=>UT(n,t))),hF=y(2,(e,t)=>ZT(e,n=>UT(n,t))),PL=1440*60*1e3,GT=s((e,t,n)=>{if(t._tag==="Offset")return or(e-t.offset,t);let r=vf(e-PL,e,t),o=vf(e+PL,e,t);if(r===o)return or(e-r,t);let i=r<o,a=r-o;if(i){if(vf(e-o,e,t)===o)return or(e-o,t);let u=or(e-r,t),f=Vo(u).getTime();if(e!==f)switch(n){case"reject":{let d=new Date(e).toISOString();throw new RangeError(`Gap time: ${d} does not exist in time zone ${t.id}`)}case"earlier":return or(e-o,t);case"compatible":case"later":return u}return u}if(vf(e-r,e,t)===r){if(n==="earlier"||n==="compatible"||vf(e-r+a,e+a,t)===r)return or(e-r,t);if(n==="reject"){let u=new Date(e).toISOString();throw new RangeError(`Ambiguous time: ${u} occurs twice in time zone ${t.id}`)}}return or(e-o,t)},"makeZonedFromAdjusted"),eJ=/([+-])(\d{2}):(\d{2})$/,jT=s(e=>{let t=eJ.exec(e);if(t===null)return null;let[,n,r,o]=t;return(n==="+"?1:-1)*(Number(r)*60+Number(o))*60*1e3},"parseOffset"),vf=s((e,t,n)=>{let r=n.format.formatToParts(e).find(i=>i.type==="timeZoneName")?.value??"";if(r==="GMT")return 0;let o=jT(r);return o===null?Mg(or(t,n)):o},"calculateNamedOffset"),ea=y(Or,(e,t,n)=>{if(e._tag==="Utc"){let i=Vs(e);return t(i),Bs(i.getTime())}let r=Vo(e),o=new Date(r.getTime());return t(o),GT(o.getTime(),e.zone,n?.disambiguation??"compatible")}),ZT=y(2,(e,t)=>If(e,n=>{let r=new Date(n);return t(r),r.getTime()})),If=y(2,(e,t)=>{let n=t(Vc(e));return e._tag==="Utc"?Bs(n):or(n,e.zone)}),jg=y(2,(e,t)=>t(Vo(e))),qT=y(2,(e,t)=>t(Vs(e))),gF=y(2,(e,t)=>e._tag==="Utc"?t.onUtc(e):t.onZoned(e)),xF=y(2,(e,t)=>If(e,n=>n+no(ct(t)))),yF=y(2,(e,t)=>If(e,n=>n-no(ct(t)))),Ag=s((e,t)=>{e.setTime(e.getTime()+t)},"addMillis"),BT=y(2,(e,t)=>ea(e,n=>{if(t.milliseconds&&Ag(n,t.milliseconds),t.seconds&&Ag(n,t.seconds*1e3),t.minutes&&Ag(n,t.minutes*60*1e3),t.hours&&Ag(n,t.hours*60*60*1e3),t.days&&n.setUTCDate(n.getUTCDate()+t.days),t.weeks&&n.setUTCDate(n.getUTCDate()+t.weeks*7),t.months){let r=n.getUTCDate();n.setUTCMonth(n.getUTCMonth()+t.months+1,0),r<n.getUTCDate()&&n.setUTCDate(r)}if(t.years){let r=n.getUTCDate(),o=n.getUTCMonth();n.setUTCFullYear(n.getUTCFullYear()+t.years,o+1,0),r<n.getUTCDate()&&n.setUTCDate(r)}})),SF=y(2,(e,t)=>{let n={};for(let r in t)n[r]=-1*t[r];return BT(e,n)}),bF=s((e,t,n)=>{switch(t){case"second":{e.setUTCMilliseconds(0);break}case"minute":{e.setUTCSeconds(0,0);break}case"hour":{e.setUTCMinutes(0,0,0);break}case"day":{e.setUTCHours(0,0,0,0);break}case"week":{let r=n?.weekStartsOn??0,i=(e.getUTCDay()-r+7)%7;e.setUTCDate(e.getUTCDate()-i),e.setUTCHours(0,0,0,0);break}case"month":{e.setUTCDate(1),e.setUTCHours(0,0,0,0);break}case"year":{e.setUTCMonth(0,1),e.setUTCHours(0,0,0,0);break}}},"startOfDate"),vF=y(Or,(e,t,n)=>ea(e,r=>bF(r,t,n))),_F=s((e,t,n)=>{switch(t){case"second":{e.setUTCMilliseconds(999);break}case"minute":{e.setUTCSeconds(59,999);break}case"hour":{e.setUTCMinutes(59,59,999);break}case"day":{e.setUTCHours(23,59,59,999);break}case"week":{let r=n?.weekStartsOn??0,i=(e.getUTCDay()-r+7)%7;e.setUTCDate(e.getUTCDate()-i+6),e.setUTCHours(23,59,59,999);break}case"month":{e.setUTCMonth(e.getUTCMonth()+1,0),e.setUTCHours(23,59,59,999);break}case"year":{e.setUTCMonth(11,31),e.setUTCHours(23,59,59,999);break}}},"endOfDate"),wF=y(Or,(e,t,n)=>ea(e,r=>_F(r,t,n))),EF=y(Or,(e,t,n)=>ea(e,r=>{if(t==="millisecond")return;let o=r.getTime(),i=new Date(o);bF(i,t,n);let a=i.getTime(),c=new Date(o);_F(c,t,n);let l=c.getTime()+1,u=o-a,f=l-o;u<f?r.setTime(a):r.setTime(l)})),tJ=s(e=>e._tag==="Named"?e.id:Ug(e.offset),"intlTimeZone"),IF=y(Or,(e,t)=>{try{return new Intl.DateTimeFormat(t?.locale,{timeZone:e._tag==="Utc"?"UTC":tJ(e.zone),...t}).format(e.epochMilliseconds)}catch{return new Intl.DateTimeFormat(t?.locale,{timeZone:"UTC",...t}).format(Vo(e))}}),TF=y(Or,(e,t)=>new Intl.DateTimeFormat(t?.locale,t).format(e.epochMilliseconds)),kF=y(Or,(e,t)=>new Intl.DateTimeFormat(t?.locale,{...t,timeZone:"UTC"}).format(e.epochMilliseconds)),AF=y(2,(e,t)=>t.format(e.epochMilliseconds)),CF=s(e=>Vs(e).toISOString(),"formatIso"),OF=s(e=>Vo(e).toISOString().slice(0,10),"formatIsoDate"),RF=s(e=>Vs(e).toISOString().slice(0,10),"formatIsoDateUtc"),$g=s(e=>{let t=Vo(e);return e._tag==="Utc"?t.toISOString():`${t.toISOString().slice(0,-1)}${zT(e)}`},"formatIsoOffset"),VT=s(e=>e.zone._tag==="Offset"?$g(e):`${$g(e)}[${e.zone.id}]`,"formatIsoZoned");var tae=globalThis.Number;var PF=y(2,(e,t)=>{let n=e.toString(),r=t.toString();if(n.includes("e")||r.includes("e"))return!globalThis.Number.isFinite(e)||!globalThis.Number.isFinite(t)||t===0?NaN:rJ(e,t);let o=(n.split(".")[1]||"").length,i=(r.split(".")[1]||"").length,a=o>i?o:i,c=parseInt(e.toFixed(a).replace(".","")),l=parseInt(t.toFixed(a).replace(".",""));return c%l/Math.pow(10,a)});function rJ(e,t){let[n,r]=$F(e),[o,i]=$F(t),a=Math.min(r,i),c=n*BigInt(10)**BigInt(r-a),l=o*BigInt(10)**BigInt(i-a),u=c%l;if(u===BigInt(0))return e<0||Object.is(e,-0)?-0:0;let f=globalThis.Number(`${u}e${a}`);return f===0?Math.sign(e)*globalThis.Number.MIN_VALUE:f}s(rJ,"remainderWithScientificNotation");function $F(e){let t=Math.abs(e).toExponential(),n=t.indexOf("e"),r=t.slice(0,n).replace(".","");return[BigInt(r)*(e<0?-BigInt(1):BigInt(1)),globalThis.Number(t.slice(n+1))-r.length+1]}s($F,"toScientificInteger");var NF=vr((e,t)=>Math.max(e,t),-1/0),DF=vr((e,t)=>Math.min(e,t),1/0);var rae=globalThis.String;var FF=s(e=>e.trim(),"trim");var HT=y(2,(e,t)=>Mc(e,sJ,n=>t(n)));var oJ=cI(_T,e=>wT(e)?X(e):ie(e));var sJ=cI(_T,e=>wT(e)?X(e.value):ie(e));var MF=y(2,(e,t)=>oo(e,{onSuccess:t.onSuccess,onFailure:s(n=>{let r=oJ(n);return ye(r)?t.onFailure(r.failure):t.onDone(r.success.value)},"onFailure")}));var UF="~effect/Schedule";var ta=Ce("effect/Schedule/CurrentMetadata",{defaultValue:It({input:void 0,output:void 0,duration:At,attempt:0,start:0,now:0,elapsed:0,elapsedSincePrevious:0})}),iJ={[UF]:{_Out:J,_In:J,_Env:J},pipe(){return be(this,arguments)}},JT=s(e=>U(e,UF),"isSchedule"),WT=s(e=>{let t=Object.create(iJ);return t.step=e,t},"fromStep"),YT=s(()=>{let e=0,t,n;return(r,o)=>{n===void 0&&(n=r);let i=r-n,a=t===void 0?0:r-t;return t=r,{input:o,attempt:++e,start:n,now:r,elapsed:i,elapsedSincePrevious:a}}},"metadataFn"),aJ=s(e=>WT(ve(e,t=>{let n=YT();return(r,o)=>t(n(r,o))})),"fromStepWithMetadata"),XT=s(e=>En(e.step,t=>M(()=>Le(t))),"toStep"),Zg=s(e=>Ar(t=>ve(XT(e),n=>{let r=YT();return o=>de(()=>{let i=t.currentTimeMillisUnsafe();return G(n(i,o),([a,c])=>{let l=r(i,o);return l.output=a,l.duration=c,zt(ji(c),l)})})})),"toStepWithMetadata");var QT=s(e=>WT(ve(XT(e),t=>(n,r)=>MF(t(n,r),{onSuccess:s(o=>M([r,o[1]]),"onSuccess"),onFailure:Le,onDone:s(()=>ET(r),"onDone")}))),"passthrough"),GF=s(e=>Tf(ek,({attempt:t})=>M(t<=e)),"recurs"),cJ=s(e=>{let t=ct(e);return aJ(M(n=>M([n.attempt-1,t])))},"spaced");var Tf=y(2,(e,t)=>WT(ve(XT(e),n=>{let r=YT();return(o,i)=>G(n(o,i),a=>{let[c,l]=a,u=t({...r(o,i),output:c,duration:l});return G(oe(u)?u:M(u),f=>f?M(a):ET(c))})})));var ek=cJ(At);var uJ=s((e,t,n)=>cg(r=>G(n?.local?Ji(t,qs(),r):OT(t,r),o=>Uo(e,o))),"provideLayer"),qg=y(e=>oe(e[0]),(e,t,n)=>Ih(t)?Uo(e,t):uJ(e,Array.isArray(t)?Ig(...t):t,n));var nk=y(3,(e,t,n)=>G(Zg(t),r=>{let o=ta.defaultValue();return fn(Qh(io(G(de(()=>Mt(e,ta,o)),r),i=>ge(()=>{o=i})),{disableYield:!0}),i=>Vl(i)?M(i.value):n(i,o.attempt===0?te():H(o)))})),rk=y(3,(e,t,n)=>G(Zg(t),r=>{let o=ta.defaultValue(),i,a=fn(de(()=>Mt(e,ta,o)),c=>(i=c,G(r(c),l=>(o=l,a))));return HT(a,c=>Ie(()=>n(i,c)))})),ZF=y(2,(e,t)=>{let n=typeof t=="function"?t(J):JT(t)?t:Af(t);return nk(e,n,Ue)}),kf=y(2,(e,t)=>{let n=typeof t=="function"?t(J):JT(t)?t:Af(t);return rk(e,n,Ue)}),qF=y(3,(e,t,n)=>G(Zg(n),r=>{let o=ta.defaultValue(),i=de(()=>Mt(e,ta,o));return fn(G(r(t),a=>{o=a;let c=It(G(i,r));return Zo({while:Io,body:c,step(l){o=l}})}),a=>Vl(a)?M(a.value):Ue(a))})),lJ=QT(ek),Af=s(e=>{let t=e.schedule?QT(e.schedule):lJ;return e.while&&(t=Tf(t,({input:n})=>{let r=e.while(n);return oe(r)?r:M(r)})),e.until&&(t=Tf(t,({input:n})=>{let r=e.until(n);return oe(r)?ve(r,o=>!o):M(!r)})),e.times!==void 0&&(t=Tf(t,({attempt:n})=>M(n<=e.times))),t},"buildFromOptions");var fJ=s((e,t)=>{let n=-1,r=0,o=s(i=>og(e(i)),"emit");return{begin:Ar(i=>de(()=>{let a=t();a.stepIndex!==n&&(n=a.stepIndex,r=0),r++;let c={attempt:a.attempt,stepAttempt:r,stepIndex:a.stepIndex,startNanos:i.monotonicTimeNanosUnsafe()};return zt(o({_tag:"AttemptStart",attempt:c.attempt,stepAttempt:c.stepAttempt,stepIndex:c.stepIndex}),c)})),end:s((i,a)=>Ar(c=>{let l=Un(c.monotonicTimeNanosUnsafe()-i.startNanos);return o(a._tag==="Success"?{_tag:"AttemptSuccess",attempt:i.attempt,stepAttempt:i.stepAttempt,stepIndex:i.stepIndex,duration:l}:{_tag:"AttemptFailure",attempt:i.attempt,stepAttempt:i.stepAttempt,stepIndex:i.stepIndex,duration:l,cause:a.cause})}),"end")}},"makeEventEmitter"),HF=y(e=>oe(e[0]),(e,t,n)=>de(()=>{let r=0,o={attempt:0,stepIndex:0},i=Xh(CL,ge(()=>(o={attempt:o.attempt+1,stepIndex:r},o))),a=n?.onEvent===void 0?void 0:fJ(n.onEvent,()=>o),c=a===void 0?J:u=>Ui(f=>G(a.begin,d=>Ut(f(u),p=>a.end(d,p)))),l;return G(Zo({while:s(()=>r<t.steps.length&&(l===void 0||ye(l)),"while"),body(){let u=t.steps[r],f=i(c(qg(e,u.provide)));if(l){let d=!1,p=f;f=de(()=>d?p:(d=!0,Lc(l))),f=kf(f,VF(u,!1))}else{let d=VF(u,!0);f=d?kf(f,d):f}return Fs(f)},step(u){l=u,r++}}),()=>Lc(l))})),VF=s((e,t)=>{if(t){if(e.attempts===1||!(e.schedule||e.attempts))return}else return Af({schedule:e.schedule?e.schedule:e.attempts?void 0:dJ,times:e.attempts,while:e.while});return Af({schedule:e.schedule,while:e.while,times:e.attempts?e.attempts-1:void 0})},"scheduleFromStep"),dJ=GF(1);var mJ="~effect/Request",hJ=XR({_E:s(e=>e,"_E"),_A:s(e=>e,"_A"),_R:s(e=>e,"_R")}),_ae={...f$,[mJ]:hJ};var KF=s(e=>e,"makeEntry");var WF=y(2,(e,t)=>{let n=s(r=>wn(o=>{let i=XF(r,e,o,af());return xJ(r,i)}),"withResolver");return oe(t)?G(t,n):n(t)}),YF=s((e,t)=>{let n=XF(t.resolver,e,t.onExit,{context:t.context,currentScheduler:cn(t.context,ef)});return()=>QF(t.resolver,n)},"requestUnsafe"),Bg=[],ok=new WeakMap,XF=s((e,t,n,r)=>{let o=ok.get(e);o||(o=new Map,ok.set(e,o));let i,a=!1,c=KF({request:t,context:r.context,uninterruptible:!1,completeUnsafe(u){a||(a=!0,n(u),i?.entrySet.delete(c))}});if(e.preCheck!==void 0&&!e.preCheck(c))return c;let l=e.batchKey(c);if(i=o.get(l),!i){if(Bg.length>0)i=Bg.pop(),i.key=l,i.resolver=e,i.map=o;else{let u={key:l,resolver:e,map:o,entrySet:new Set,entries:new Set,delayEffect:G(de(()=>u.resolver.delay),f=>JF(u)),run:Ut(de(()=>u.resolver.runAll(Array.from(u.entries),u.key)),f=>{for(let d of u.entrySet)d.completeUnsafe(f._tag==="Success"?Xr(new Error("Effect.request: RequestResolver did not complete request",{cause:d.request})):f);return u.entries.clear(),Bg.length<128&&(u.entrySet.clear(),u.key=void 0,u.fiber=void 0,u.resolver=void 0,u.map=void 0,Bg.push(u)),Se})};i=u}o.set(l,i),i.fiber=qo(r.context)(i.delayEffect,{scheduler:r.currentScheduler})}return i.entrySet.add(c),i.entries.add(c),i.resolver.collectWhile(i.entries)||(i.fiber.interruptUnsafe(r.id),i.fiber=qo(r.context)(JF(i),{scheduler:r.currentScheduler})),c},"addEntry"),QF=s((e,t)=>{if(t.uninterruptible)return;let n=ok.get(e);if(!n)return;let r=e.batchKey(t),o=n.get(r);o&&(o.entries.delete(t),o.entrySet.delete(t),o.entries.size===0&&(n.delete(r),o.fiber?.interruptUnsafe()))},"removeEntryUnsafe"),xJ=s((e,t)=>ge(()=>QF(e,t)),"maybeRemoveEntry");function JF(e){return e.map.has(e.key)?(e.map.delete(e.key),e.run):Se}s(JF,"runBatch");var SJ="effect/Metric/CurrentMetricAttributes",bJ=Ce(SJ,{defaultValue:s(()=>({}),"defaultValue")}),vJ="~effect/observability/Metric/MetricRegistryKey",_J=Ce(vJ,{defaultValue:s(()=>new Map,"defaultValue")}),ez="~effect/observability/Metric",tz=class{static{s(this,"Metric$")}[ez]=ez;#t=new WeakMap;#e;id;description;attributes;constructor(t,n,r){this.id=t,this.description=n,this.attributes=r}valueUnsafe(t){return this.hook(t).get(t)}modifyUnsafe(t,n){return this.hook(n).modify(t,n)}updateUnsafe(t,n){return this.hook(n).update(t,n)}hook(t){let n=cn(t,bJ);if(Object.keys(n).length===0)return rn(this.#e)?this.#e.hooks:(this.#e=this.getOrCreate(t,this.attributes),this.#e.hooks);let r=IJ(this.attributes,n),o=this.#t.get(r);return rn(o)||(o=this.getOrCreate(t,r),this.#t.set(r,o)),o.hooks}getOrCreate(t,n){let r=wJ(this,n),o=cn(t,_J);if(o.has(r))return o.get(r);let i=this.createHooks(),a={id:this.id,type:this.type,description:this.description,attributes:sk(n),hooks:i};return o.set(r,a),a}pipe(){return be(this,arguments)}};var Hc=y(2,(e,t)=>Ms(n=>ge(()=>e.updateUnsafe(t,n))));function wJ(e,t){let n=`${e.type}:${e.id}`;return rn(e.description)&&(n+=`:${e.description}`),rn(t)&&(n+=`:${EJ(t)}`),n}s(wJ,"makeKey");function EJ(e){return JSON.stringify(Array.isArray(e)?e:Object.entries(e))}s(EJ,"serializeAttributes");function IJ(e,t){return{...sk(e),...sk(t)}}s(IJ,"mergeAttributes");function sk(e){return rn(e)&&Array.isArray(e)?e.reduce((t,[n,r])=>(V(t,n,r),t),{}):e}s(sk,"attributesToRecord");var TJ=Wr,na=oe,kJ=gf,AJ=dT,CJ=uD,OJ=lD,RJ=fD,$J=pD,PJ=jn,oz=Zo,NJ=UI,ik=XP,se=M,Jc=cf,sz=MI,Vg=de,Wc=ge,Cf=Se;var DJ=vT;var ak=wn,LJ=uf,FJ=bD,zJ=vD,MJ=wD;var UJ=_D,GJ=nN,W=Ue,jJ=Kh,ZJ=Le,Yc=YP,Hg=zo,Xc=Jh;var qJ=Fc,BJ=zI,Kg=fe,ck=Lc,VJ=KP,HJ=WP,KJ=JP,In=G,uk=lN,JJ=kr,Jg=io,WJ=Fs,YJ=jN,Qc=pf,Of=ve,XJ=zt,QJ=Wh,eW=lf,tW=sN,nW=IN,rW=KI,oW=fn;var sW=ng,iW=DN,aW=LN,cW=FN,uW=zN,Hs=En,lW=ON,fW=ff,dW=tg,pW=CN,mW=WI,hW=Mc,gW=XI,xW=QI,yW=rg,iz=YI,SW=PN,az=RN,bW=$N,vW=eg,cz=NN,_W=eT,wW=kf,EW=rk,IW=iN,TW=GN,kW=og,AW=HF,CW=nL,OW=MN,RW=UN,$W=HN,PW=KN,NW=nT,DW=VN,LW=ji,FW=JN,zW=qI,MW=BI,UW=aN,GW=Yh,jW=xD,ZW=yD,qW=SD,BW=pT,VW=mT,HW=TN,KW=gD,JW=kN,lk=sg,WW=df,YW=tT,XW=ZN,QW=cN,e3=oo,t3=Mi,n3=qN,r3=BN,o3=HI,s3=Ms,i3=qg,fk=Uo,a3=EN,c3=vN,u3=_N,l3=zc,f3=Mo,d3=wN,Wg=Mt,Yg=Xh,p3=hf,m3=ag,h3=cg,g3=ug,x3=nD,y3=tD,S3=Uc,b3=XN,v3=aT,_3=QN,w3=cT,E3=Gc,dk=Ut,I3=sT,T3=iT,k3=rD,A3=lT,C3=uT,uz=oD,O3=fT,R3=eD,$3=jo,lz=Ui,P3=aD,N3=cD,D3=Qh,L3=ZF,F3=nk,z3=JI,M3=AN,U3=y(2,(e,t)=>fz(e,void 0,t)),fz=qF,G3=DD,j3=LD,Z3=FD,q3=zD,B3=HD,V3=KD,H3=JD,K3=WD,J3=jD,W3=ZD,Y3=qD,X3=UD,Q3=Tr,e5=of,t5=VD,n5=GD,r5=Dc,o5=WF,s5=YF,i5=ED,a5=hT,c5=kD,u5=ID,l5=TD,f5=eN,d5=tN,eu=CD,pk=qo,mk=gT,hk=OD,Rf=$D,gk=xT,tu=RD,xk=fg,yk=ND,Sk=yT,uo=PD,bk=dg,p5=jI,m5=rN,dz=Ar,h5=Cr,g5=Cr(),x5=Cr("Fatal"),y5=Cr("Warn"),S5=Cr("Error"),b5=Cr("Info"),v5=Cr("Debug"),_5=Cr("Trace"),w5=y(2,(e,t)=>Mo(e,bT,n=>new Set([...n,t]))),E5=y(e=>na(e[0]),(e,...t)=>Mo(e,pL,n=>{let r=t.length===1?{...n,...t[0]}:{...n};return t.length===1||V(r,t[0],t[1]),r})),I5=eL,T5=y(2,(e,t)=>G(pg,n=>Mo(e,mL,r=>[[t,n],...r]))),k5=y(e=>na(e[0]),(e,t,n)=>dk(e,r=>{let o=n===void 0?r:Ie(()=>n(r));return Hc(t,o)})),A5=y(e=>na(e[0]),(e,t,n)=>Jg(e,r=>{let o=n===void 0?r:n(r);return Hc(t,o)})),C5=y(e=>na(e[0]),(e,t,n)=>iz(e,r=>{let o=n===void 0?r:Ie(()=>n(r));return Hc(t,o)})),O5=y(e=>na(e[0]),(e,t,n)=>cz(e,r=>{let o=n===void 0?r:Ie(()=>n(r));return Hc(t,o)})),R5=y(e=>na(e[0]),(e,t,n)=>dz(r=>{let o=r.monotonicTimeNanosUnsafe();return dk(e,()=>{let i=r.monotonicTimeNanosUnsafe(),a=iI(ct(i),ct(o)),c=n===void 0?a:Ie(()=>n(a));return Hc(t,c)})})),Kc=class extends Mn()("effect/Effect/Transaction"){static{s(this,"Transaction")}},$5=s(e=>Kg(t=>{if(t.context.mapUnsafe.has(Kc.key))return e;let n={journal:new Map,retry:!1},r;return lz(o=>In(oz({while:s(()=>!r,"while"),body:It(o(e).pipe(Wg(Kc,n),az(()=>n.retry?o(N5(n)):Cf),Qc)),step(i){if(n.retry||!P5(n))return rz(n);Jt(i)?D5(t,n):rz(n),r=i}}),()=>r))}),"tx"),P5=s(e=>{for(let[t,{version:n}]of e.journal)if(t.version!==n)return!1;return!0},"isTransactionConsistent"),N5=s(e=>Vg(()=>{let t={},n=Array.from(e.journal.keys()),r=s(()=>{for(let o of n)o.pending.delete(t)},"clearPending");return ak(o=>{let i=s(()=>{r(),o(Cf)},"onCall");for(let a of n)a.pending.set(t,i);return Wc(r)})}),"awaitPendingTransaction");function D5(e,t){for(let[n,{value:r}]of t.journal){r!==n.value&&(n.version=n.version+1,n.value=r);for(let o of n.pending.values())e.currentDispatcher.scheduleTask(o,0);n.pending.clear()}}s(D5,"commitTransaction");function rz(e){e.retry=!1,e.journal.clear()}s(rz,"clearTransaction");var L5=In(Kc,e=>(e.retry=!0,uz)),F5=s((e,t,n)=>(...r)=>ak(o=>{try{e(...r,(i,a)=>{o(i?W(t?t(i,r):i):se(a))})}catch(i){o(n?W(n(i,r)):Hg(i))}}),"effectify"),z5=s(()=>e=>e,"satisfiesSuccessType"),M5=s(()=>e=>e,"satisfiesErrorType"),U5=s(()=>e=>e,"satisfiesServicesType"),ra=fN,$f=dN,Ct=pN,qn=uN,Xg=mN,Qg=oN;function Ho(e){return e.checks?e.checks[e.checks.length-1].annotations:e.annotations}s(Ho,"resolve");function Pf(e){return t=>Ho(t)?.[e]}s(Pf,"resolveAt");var Tn="~structural",oa="~identifier",Nf="~sentinels",ex="~constructor",pz=["title","description","default","examples","readOnly","writeOnly","format","contentEncoding","contentMediaType","contentSchema"],sa=Pf("identifier"),vk=Pf(oa),_k=Pf("title");var mz=Pf("brands"),tx=Bt(e=>{let t=sa(e);return typeof t=="string"?t:e.getExpected(tx)});var hz=new Set([Nf,Tn,"representation","arbitrary","brands","toJsonSchema","toCode","toArbitrary","toEquivalence","toFormatter","toCodec","toCodecJson","toCodecStringTree","toCodecIso"]);var Oe=Symbol();var lo=qi,fo=lo(Oe),bt=lo(Oe),nx=s(e=>e===Oe?te():H(e),"toOption"),wk=s(e=>e._tag==="None"?fo:lo(e.value),"fromOptionExit");var Lf="~effect/SchemaIssue/Issue";function Tk(e){return U(e,Lf)&&e[Lf]===Lf}s(Tk,"isIssue");function G5(e){return Object.hasOwn(e,"input")}s(G5,"hasInput");var Bn=class{static{s(this,"Base")}[Lf]=Lf;constructor(t,n){n?.reportInput===!0&&t!==Oe&&(this.input=t)}},ox=class extends Bn{static{s(this,"Filter")}_tag="Filter";filter;issue;constructor(t,n,r,o){super(r,o),this.filter=t,this.issue=n}},sx=class extends Bn{static{s(this,"Encoding")}_tag="Encoding";ast;issue;constructor(t,n,r,o){super(r,o),this.ast=t,this.issue=n}},Ot=class extends Bn{static{s(this,"Pointer")}_tag="Pointer";path;issue;constructor(t,n){super(),this.path=t,this.issue=n}},Ks=class extends Bn{static{s(this,"MissingKey")}_tag="MissingKey";annotations;constructor(t){super(),this.annotations=t}},zf=class extends Bn{static{s(this,"UnexpectedKey")}_tag="UnexpectedKey";ast;constructor(t,n,r){super(n,r),this.ast=t}},Qe=class extends Bn{static{s(this,"Composite")}_tag="Composite";ast;issues;constructor(t,n,r,o){super(r,o),this.ast=t,this.issues=n}},et=class extends Bn{static{s(this,"InvalidType")}_tag="InvalidType";ast;constructor(t,n,r){super(n,r),this.ast=t}},Ee=class extends Bn{static{s(this,"InvalidValue")}_tag="InvalidValue";annotations;constructor(t,n,r){super(n,r),this.annotations=t}};function kn(e,t,n,r,o){return new Qe(e,[new Ot([t],n)],r,o)}s(kn,"makeCompositeAtKey");var ca=class extends Bn{static{s(this,"Forbidden")}_tag="Forbidden";annotations;constructor(t,n,r){super(n,r),this.annotations=t}},nu=class extends Bn{static{s(this,"AnyOf")}_tag="AnyOf";ast;issues;constructor(t,n,r,o){super(r,o),this.ast=t,this.issues=n}},ix=class extends Bn{static{s(this,"OneOf")}_tag="OneOf";ast;successes;constructor(t,n,r,o){super(r,o),this.ast=t,this.successes=n}};function Ik(e,t,n){if(Tk(e))return e;if(typeof e=="string")return new Ee({message:e},t,n);let r=typeof e.issue=="string"?new Ee({message:e.issue},t,n):e.issue;return new Ot(e.path,r)}s(Ik,"makeFilterIssue");function gz(e,t,n){if(e!==void 0)return typeof e=="boolean"?e?void 0:new Ee(void 0,t,n):Ik(e,t,n)}s(gz,"makeSingle");function xz(e,t,n,r){return Array.isArray(t)?Rs(t)?t.length===1?Ik(t[0],n,r):new Qe(e,$s(t,o=>Ik(o,n,r)),n,r):void 0:gz(t,n,r)}s(xz,"normalizeFilterOutput");var yz=s(e=>{let t=Mf(e);if(t!==void 0)return t;switch(e._tag){case"InvalidType":return Ff(tx(e.ast),e);case"InvalidValue":{let n=vz(e);if(n!==void 0)return Ff(n,e);let r=rx(e);return r===void 0?"Expected a valid value":`Invalid data ${r}`}case"MissingKey":return"Missing key";case"UnexpectedKey":{let n=rx(e);return n===void 0?"Expected no excess property":`Unexpected key with value ${n}`}case"Forbidden":return"Forbidden operation";case"OneOf":{let n=rx(e);return n===void 0?"Expected exactly one member to match":`Expected exactly one member to match the input ${n}`}}},"defaultLeafHook"),Sz=s(e=>Mf(e.issue)??Mf(e),"defaultCheckHook");function bz(e){return t=>({issues:aa(t,[],e?.leafHook??yz,e?.checkHook??Sz)})}s(bz,"makeFormatterStandardSchemaV1");function rx(e){return G5(e)?z(e.input):void 0}s(rx,"formatInput");function vz(e){let t=e.annotations?.expected;return typeof t=="string"?t:void 0}s(vz,"findExpected");function Ff(e,t){let n=rx(t);return n===void 0?`Expected ${e}`:`Expected ${e}, got ${n}`}s(Ff,"getExpectedMessage");function aa(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 aa(e.issue,t,n,r);let i=vz(e.issue);return[{path:t,message:i===void 0?Ff(_z(e.filter),e):Ff(i,e.issue)}]}case"Encoding":return aa(e.issue,t,n,r);case"Pointer":return aa(e.issue,[...t,...e.path],n,r);case"Composite":return e.issues.flatMap(o=>aa(o,t,n,r));case"AnyOf":return e.issues.length===0?[{path:t,message:Mf(e)??Ff(tx(e.ast),e)}]:e.issues.flatMap(o=>aa(o,t,n,r));default:return[{path:t,message:n(e)}]}}s(aa,"toDefaultIssues");function _z(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=>_z(n)).join(" & ")}}s(_z,"formatCheck");function j5(){return e=>aa(e,[],yz,Sz).map(Z5).join(`
|
|
91
|
+
`)}s(j5,"makeFormatterDefault");var wz=j5();function Z5(e){let t=e.message;if(e.path&&e.path.length>0){let n=sh(e.path);t+=`
|
|
92
|
+
at ${n}`}return t}s(Z5,"formatDefaultIssue");function Mf(e){switch(e._tag){case"InvalidType":case"OneOf":case"Composite":case"AnyOf":return Df(e.ast.annotations);case"InvalidValue":case"Forbidden":return Df(e.annotations);case"MissingKey":return Df(e.annotations,"messageMissingKey");case"UnexpectedKey":return Df(e.ast.annotations,"messageUnexpectedKey");case"Filter":return Df(e.filter.annotations);case"Encoding":return Mf(e.issue)}}s(Mf,"findMessage");function Df(e,t="message"){let n=e?.[t];if(typeof n=="string")return n}s(Df,"getMessageAnnotation");function Uf(e){let t;for(let n of e.reasons){if(!mg(n)||!Tk(n.error))return;t??=n.error}return t}s(Uf,"getSchemaIssue");function Jo(e,t){let n=Uf(e);if(n===void 0)throw new Error(t,{cause:e});return n}s(Jo,"getSchemaIssueOrThrow");var Rr={};$t(Rr,{CurrentTimeZone:()=>sr,Equivalence:()=>cx,Order:()=>ux,add:()=>D9,addDuration:()=>P9,between:()=>i9,clamp:()=>q5,distance:()=>Q5,endOf:()=>z9,format:()=>U9,formatIntl:()=>Z9,formatIso:()=>Mk,formatIsoDate:()=>q9,formatIsoDateUtc:()=>B9,formatIsoOffset:()=>V9,formatIsoZoned:()=>qf,formatLocal:()=>G9,formatUtc:()=>j9,fromDateUnsafe:()=>$k,fromEpochSeconds:()=>V5,getPart:()=>S9,getPartUtc:()=>y9,isDateTime:()=>ax,isFuture:()=>a9,isFutureUnsafe:()=>c9,isGreaterThan:()=>n9,isGreaterThanOrEqualTo:()=>r9,isLessThan:()=>o9,isLessThanOrEqualTo:()=>s9,isPast:()=>u9,isPastUnsafe:()=>l9,isTimeZone:()=>kk,isTimeZoneNamed:()=>Ck,isTimeZoneOffset:()=>Ak,isUtc:()=>Ok,isZoned:()=>Rk,layerCurrentZone:()=>H9,layerCurrentZoneLocal:()=>W9,layerCurrentZoneNamed:()=>J9,layerCurrentZoneOffset:()=>K9,make:()=>Gf,makeUnsafe:()=>B5,makeZoned:()=>H5,makeZonedFromString:()=>Nk,makeZonedUnsafe:()=>Pk,mapEpochMillis:()=>C9,match:()=>$9,max:()=>t9,min:()=>e9,mutate:()=>k9,mutateUtc:()=>A9,nearest:()=>M9,now:()=>Iz,nowAsDate:()=>K5,nowInCurrentZone:()=>T9,nowUnsafe:()=>J5,removeTime:()=>h9,setParts:()=>b9,setPartsUtc:()=>v9,setZone:()=>Tz,setZoneCurrent:()=>Az,setZoneNamed:()=>Y5,setZoneNamedUnsafe:()=>X5,setZoneOffset:()=>W5,startOf:()=>F9,subtract:()=>L9,subtractDuration:()=>N9,toDate:()=>f9,toDateUtc:()=>Zf,toEpochMillis:()=>zk,toEpochSeconds:()=>m9,toParts:()=>g9,toPartsUtc:()=>x9,toUtc:()=>jf,withCurrentZone:()=>_9,withCurrentZoneLocal:()=>w9,withCurrentZoneNamed:()=>I9,withCurrentZoneOffset:()=>E9,withDate:()=>O9,withDateUtc:()=>R9,zoneFromString:()=>Fk,zoneMakeLocal:()=>Lk,zoneMakeNamed:()=>Dk,zoneMakeNamedEffect:()=>kz,zoneMakeNamedUnsafe:()=>lx,zoneMakeOffset:()=>ua,zoneToString:()=>Wo,zonedOffset:()=>d9,zonedOffsetIso:()=>p9});var ax=Xi,kk=Qi,Ak=LL,Ck=FL,Ok=zL,Rk=NT,cx=ML,ux=co,q5=UL,$k=Wi,B5=Pg,V5=uF,Pk=DT,H5=Rg,Gf=GL,Nk=jL,Iz=Ng,K5=ZL,J5=Dg,jf=qL,Tz=wf,W5=BL,lx=Ef,ua=Yi,Dk=Lg,kz=LT,Lk=KL,Fk=FT,Wo=JL,Y5=WL,X5=YL,Q5=XL,e9=QL,t9=eF,n9=Fg,r9=tF,o9=zg,s9=nF,i9=rF,a9=oF,c9=sF,u9=iF,l9=aF,Zf=Vs,f9=Vo,d9=Mg,p9=zT,zk=Vc,m9=cF,h9=lF,g9=MT,x9=Gg,y9=dF,S9=pF,b9=mF,v9=hF,sr=class extends Mn()("effect/DateTime/CurrentTimeZone"){static{s(this,"CurrentTimeZone")}},Az=s(e=>Of(sr,t=>Tz(e,t)),"setZoneCurrent"),_9=Mt(sr),w9=s(e=>Yg(e,sr,Wc(Lk)),"withCurrentZoneLocal"),E9=y(2,(e,t)=>Wg(e,sr,ua(t))),I9=y(2,(e,t)=>Yg(e,sr,kz(t))),T9=In(Iz,Az),k9=ea,A9=ZT,C9=If,O9=jg,R9=qT,$9=gF,P9=xF,N9=yF,D9=BT,L9=SF,F9=vF,z9=wF,M9=EF,U9=IF,G9=TF,j9=kF,Z9=AF,Mk=CF,q9=OF,B9=RF,V9=$g,qf=VT,H9=bf(sr),K9=s(e=>bf(sr)(Yi(e)),"layerCurrentZoneOffset"),J9=qR(LT,Bc(sr)),W9=RT(sr)(Lk);var Cz="~effect/encoding/EncodingError",Xo=class extends Tg("EncodingError"){static{s(this,"EncodingError")}[Cz]=Cz};var dx=s(e=>Uk(typeof e=="string"?Zk.encode(e):e),"encodeBase64"),ru=s(e=>{let t=Mz(e),n=t.length;if(n%4!==0)return ie(new Xo({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 ie(new Xo({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,i=new Uint8Array(3*(n/4)-o);for(let a=0,c=0;a<n;a+=4,c+=3){let l=fx(t.charCodeAt(a))<<18|fx(t.charCodeAt(a+1))<<12|fx(t.charCodeAt(a+2))<<6|fx(t.charCodeAt(a+3));i[c]=l>>16,i[c+1]=l>>8&255,i[c+2]=l&255}return X(i)}catch(o){return ie(new Xo({kind:"Decode",module:"Base64",input:t,message:o instanceof Error?o.message:"Invalid input"}))}},"decodeBase64"),Nz=s(e=>Fn(ru(e),t=>qk.decode(t)),"decodeBase64String"),Dz=s(e=>Rz(typeof e=="string"?Zk.encode(e):e),"encodeBase64Url"),Gk=s(e=>{let t=Mz(e),n=t.length;if(n%4===1)return ie(new Xo({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 ie(new Xo({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,"/"),ru(r)},"decodeBase64Url"),Lz=s(e=>Fn(Gk(e),t=>qk.decode(t)),"decodeBase64UrlString"),Fz=s(e=>$z(typeof e=="string"?Zk.encode(e):e),"encodeHex"),jk=s(e=>{let t=new TextEncoder().encode(e);if(t.length%2!==0)return ie(new Xo({module:"Hex",kind:"Decode",input:e,message:`Length must be a multiple of 2, but is ${t.length}`}));try{let n=t.length/2,r=new Uint8Array(n);for(let o=0;o<n;o++){let i=Pz(t[o*2]),a=Pz(t[o*2+1]);r[o]=i<<4|a}return X(r)}catch(n){return ie(new Xo({module:"Hex",kind:"Decode",input:e,message:n instanceof Error?n.message:"Invalid input"}))}},"decodeHex"),zz=s(e=>Fn(jk(e),t=>qk.decode(t)),"decodeHexString"),Zk=new TextEncoder,qk=new TextDecoder,Mz=s(e=>e.replace(/[\n\r]/g,""),"stripCrlf"),Uk=s(e=>{let t=e.length,n="",r;for(r=2;r<t;r+=3)n+=Yo[e[r-2]>>2],n+=Yo[(e[r-2]&3)<<4|e[r-1]>>4],n+=Yo[(e[r-1]&15)<<2|e[r]>>6],n+=Yo[e[r]&63];return r===t+1&&(n+=Yo[e[r-2]>>2],n+=Yo[(e[r-2]&3)<<4],n+="=="),r===t&&(n+=Yo[e[r-2]>>2],n+=Yo[(e[r-2]&3)<<4|e[r-1]>>4],n+=Yo[(e[r-1]&15)<<2],n+="="),n},"base64EncodeUint8Array");function fx(e){if(e>=Oz.length)throw new TypeError(`Invalid character ${String.fromCharCode(e)}`);let t=Oz[e];if(t===255)throw new TypeError(`Invalid character ${String.fromCharCode(e)}`);return t}s(fx,"getBase64Code");var Yo=["A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z","a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z","0","1","2","3","4","5","6","7","8","9","+","/"],Oz=[255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,62,255,255,255,63,52,53,54,55,56,57,58,59,60,61,255,255,255,0,255,255,255,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,255,255,255,255,255,255,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51],Rz=s(e=>Uk(e).replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_"),"base64UrlEncodeUint8Array"),$z=s(e=>{let t="";for(let n=0;n<e.length;++n)t+=Y9[e[n]];return t},"hexEncodeUint8Array"),Pz=s(e=>{if(48<=e&&e<=57)return e-48;if(97<=e&&e<=102)return e-97+10;if(65<=e&&e<=70)return e-65+10;throw new TypeError("Invalid input")},"fromHexChar"),Y9=["00","01","02","03","04","05","06","07","08","09","0a","0b","0c","0d","0e","0f","10","11","12","13","14","15","16","17","18","19","1a","1b","1c","1d","1e","1f","20","21","22","23","24","25","26","27","28","29","2a","2b","2c","2d","2e","2f","30","31","32","33","34","35","36","37","38","39","3a","3b","3c","3d","3e","3f","40","41","42","43","44","45","46","47","48","49","4a","4b","4c","4d","4e","4f","50","51","52","53","54","55","56","57","58","59","5a","5b","5c","5d","5e","5f","60","61","62","63","64","65","66","67","68","69","6a","6b","6c","6d","6e","6f","70","71","72","73","74","75","76","77","78","79","7a","7b","7c","7d","7e","7f","80","81","82","83","84","85","86","87","88","89","8a","8b","8c","8d","8e","8f","90","91","92","93","94","95","96","97","98","99","9a","9b","9c","9d","9e","9f","a0","a1","a2","a3","a4","a5","a6","a7","a8","a9","aa","ab","ac","ad","ae","af","b0","b1","b2","b3","b4","b5","b6","b7","b8","b9","ba","bb","bc","bd","be","bf","c0","c1","c2","c3","c4","c5","c6","c7","c8","c9","ca","cb","cc","cd","ce","cf","d0","d1","d2","d3","d4","d5","d6","d7","d8","d9","da","db","dc","dd","de","df","e0","e1","e2","e3","e4","e5","e6","e7","e8","e9","ea","eb","ec","ed","ee","ef","f0","f1","f2","f3","f4","f5","f6","f7","f8","f9","fa","fb","fc","fd","fe","ff"];var Js=class e extends _i{static{s(this,"Getter")}run;constructor(t){super(),this.run=t}map(t){return new e((n,r)=>this.run(n,r).pipe(ra(Tc(t))))}compose(t){return Uz(this)?t:Uz(t)?this:new e((n,r)=>this.run(n,r).pipe(qn(o=>t.run(o,r))))}};function X9(e){return new Js((t,n)=>W(e(t,n)))}s(X9,"fail");function Vk(e){return X9((t,n)=>{let r={message:e(t)};return an(t)?new ca(r,t.value,n):new ca(r)})}s(Vk,"forbidden");var Gz=new Js(se);function Uz(e){return e.run===Gz.run}s(Uz,"isPassthrough");function $r(){return Gz}s($r,"passthrough");function Hk(e){return new Js((t,n)=>Xe(t)?Jc:e(t.value,n))}s(Hk,"onSome");function xe(e){return px(Tc(e))}s(xe,"transform");function An(e){return Hk((t,n)=>e(t,n).pipe(ra(H)))}s(An,"transformOrFail");function px(e){return new Js(t=>se(e(t)))}s(px,"transformOptional");function Kk(){return new Js(()=>Jc)}s(Kk,"omit");function Bf(e){return new Js(t=>{let n=Ac(t,rn);return an(n)?se(n):ra(e,H)})}s(Bf,"withDefault");function la(){return xe(globalThis.String)}s(la,"String");function mx(){return xe(globalThis.Number)}s(mx,"Number");function jz(){return xe(globalThis.BigInt)}s(jz,"BigInt");function Jk(){return xe(e=>new globalThis.Date(e))}s(Jk,"Date");function Zz(){return xe(FF)}s(Zz,"trim");function qz(e){return Hk((t,n)=>Xc({try:s(()=>H(JSON.parse(t,e?.reviver)),"try"),catch:s(()=>new Ee({expected:"a valid JSON string"},t,n),"catch")}))}s(qz,"parseJson");function Bz(e){return Hk((t,n)=>Xc({try:s(()=>{let r=JSON.stringify(t,e?.replacer,e?.space);if(r===void 0)throw new TypeError("Value cannot be represented as JSON");return H(r)},"try"),catch:s(()=>new Ee({expected:"a JSON-serializable value"},t,n),"catch")}))}s(Bz,"stringifyJson");function Wk(){return xe(dx)}s(Wk,"encodeBase64");function hx(){return xe(Dz)}s(hx,"encodeBase64Url");function gx(){return xe(Fz)}s(gx,"encodeHex");function Vz(){return An((e,t)=>$f(ck(ru(e)),()=>new Ee({expected:"a valid Base64 string"},e,t)))}s(Vz,"decodeBase64");function Hz(){return An((e,t)=>vn(Nz(e),{onFailure:s(()=>W(new Ee({expected:"a valid Base64 string"},e,t)),"onFailure"),onSuccess:se}))}s(Hz,"decodeBase64String");function Kz(){return An((e,t)=>vn(Gk(e),{onFailure:s(()=>W(new Ee({expected:"a valid Base64Url string"},e,t)),"onFailure"),onSuccess:se}))}s(Kz,"decodeBase64Url");function Jz(){return An((e,t)=>vn(Lz(e),{onFailure:s(()=>W(new Ee({expected:"a valid Base64Url string"},e,t)),"onFailure"),onSuccess:se}))}s(Jz,"decodeBase64UrlString");function Wz(){return An((e,t)=>vn(jk(e),{onFailure:s(()=>W(new Ee({expected:"a valid hexadecimal string"},e,t)),"onFailure"),onSuccess:se}))}s(Wz,"decodeHex");function Yz(){return An((e,t)=>vn(zz(e),{onFailure:s(()=>W(new Ee({expected:"a valid hexadecimal string"},e,t)),"onFailure"),onSuccess:se}))}s(Yz,"decodeHexString");function Xz(){return xe(encodeURIComponent)}s(Xz,"encodeUriComponent");function Qz(){return An((e,t)=>{try{return se(globalThis.decodeURIComponent(e))}catch{return W(new Ee({expected:"a valid URI component"},e,t))}})}s(Qz,"decodeUriComponent");function Yk(){return An((e,t)=>_r(Gf(e),{onNone:s(()=>W(new Ee({message:"Invalid DateTime input"},e,t)),"onNone"),onSome:s(n=>se(jf(n)),"onSome")}))}s(Yk,"dateTimeUtcFromInput");function eM(){return xe(e=>oM(Array.from(e.entries())))}s(eM,"decodeFormData");var Q9=sM(e=>typeof e=="string"||typeof Blob<"u"&&e instanceof Blob);function tM(){return xe(e=>{let t=new FormData;return typeof e=="object"&&e!==null&&Q9(e).forEach(([r,o])=>{t.append(r,o)}),t})}s(tM,"encodeFormData");function nM(){return xe(e=>oM(Array.from(e.entries())))}s(nM,"decodeURLSearchParams");var e8=sM(yr);function rM(){return xe(e=>typeof e=="object"&&e!==null?new URLSearchParams(e8(e)):new URLSearchParams)}s(rM,"encodeURLSearchParams");var t8=/^\d+$/;function n8(e){if(e==="")return[""];let t=e.replace(/\[(.*?)\]/g,".$1"),n=t.split("."),r=t.startsWith(".")?1:0;return n.slice(r).map(o=>t8.test(o)?globalThis.Number(o):o)}s(n8,"bracketPathToTokens");function oM(e){let t={},n=new WeakSet;function r(o,i,a){let c=Object.hasOwn(o,i)?o[i]:void 0;if(n.has(c)&&Array.isArray(c)===a)return c;let l=a?[]:{};return n.add(l),V(o,i,l),l}return s(r,"getOrCreateContainer"),e.forEach(([o,i])=>{let a=n8(o),c=t;a.forEach((l,u)=>{let f=u===a.length-1;if(Array.isArray(c)&&l==="")if(f)c.push(i);else{let d=a[u+1],p=typeof d=="number"||d==="",m=c.length;c=r(c,m,p)}else if(f){let d=Object.hasOwn(c,l);d&&Array.isArray(c[l])?c[l].push(i):d?V(c,l,[c[l],i]):V(c,l,i)}else{let d=a[u+1];c=r(c,l,typeof d=="number"||d==="")}})}),t}s(oM,"makeTreeRecord");function sM(e){return t=>{let n=[];function r(o,i){if(e(i))n.push([o,i]);else if(Array.isArray(i))i.every(e)?i.forEach(c=>{n.push([o,c])}):i.forEach((c,l)=>{r(`${o}[${l}]`,c)});else if(typeof i=="object"&&i!==null)for(let[a,c]of Object.entries(i))r(`${o}[${a}]`,c)}s(r,"append");for(let[o,i]of Object.entries(t))r(o,i);return n}}s(sM,"collectBracketPathEntries");var Hf=class e{static{s(this,"Middleware")}_tag="Middleware";decode;encode;constructor(t,n){this.decode=t,this.encode=n}flip(){return new e(this.encode,this.decode)}},Vf="~effect/SchemaTransformation/Transformation",Re=class e{static{s(this,"Transformation")}[Vf]=Vf;_tag="Transformation";decode;encode;constructor(t,n){this.decode=t,this.encode=n}flip(){return new e(this.encode,this.decode)}compose(t){return new e(this.decode.compose(t.decode),t.encode.compose(this.encode))}};function r8(e){return U(e,Vf)&&e[Vf]===Vf}s(r8,"isTransformation");var yx=s(e=>r8(e)?e:new Re(e.decode,e.encode),"make");function ir(e){return new Re(An(e.decode),An(e.encode))}s(ir,"transformOrFail");function We(e){return new Re(xe(e.decode),xe(e.encode))}s(We,"transform");function Sx(e){return new Re(px(e.decode),px(e.encode))}s(Sx,"transformOptional");function iM(){return new Re(Zz(),$r())}s(iM,"trim");var o8=new Re($r(),$r());function ou(){return o8}s(ou,"passthrough");var su=new Re(mx(),la()),bx=new Re(jz(),la()),Xk=new Re(Jk(),xe(wE)),aM=new Re(Jk(),xe(e=>e.getTime())),cM=ir({decode:s((e,t)=>_r(oI(e),{onNone:s(()=>W(new Ee({expected:"a valid Duration string"},e,t)),"onNone"),onSome:se}),"decode"),encode:s(e=>se(globalThis.String(e)),"encode")}),uM=ir({decode:s(e=>se(Un(e)),"decode"),encode:s((e,t)=>_r(sI(e),{onNone:s(()=>W(new Ee({expected:"a Duration representable as a bigint"},e,t)),"onNone"),onSome:s(n=>se(n),"onSome")}),"encode")}),lM=We({decode:s(e=>wr(e),"decode"),encode:s(e=>no(e),"encode")}),s8=s(e=>Sr(e)&&typeof e.message=="string","isJsonError"),fM=s(e=>{let n=Object.hasOwn(e,"cause")?new Error(e.message,{cause:pM(e.cause)}):new Error(e.message);return typeof e.name=="string"&&e.name!=="Error"&&(n.name=e.name),typeof e.stack=="string"&&(n.stack=e.stack),n},"decodeJsonError"),i8=s(e=>{try{let t=Ti(e);return t===void 0?z(e):JSON.parse(t)}catch{return z(e)}},"encodeUnknownAsJson"),a8=s((e,t,n)=>{let r={name:e.name,message:typeof e.message=="string"?e.message:""};return t?.includeStack&&typeof e.stack=="string"&&(r.stack=e.stack),!t?.excludeCause&&e.cause!==void 0&&(r.cause=n(e.cause)),r},"encodeJsonError"),dM=s(e=>{let t=new WeakSet,n=s(r=>{if(JR(r)){if(t.has(r))return"[Circular]";t.add(r);let o=a8(r,e,n);return t.delete(r),o}return i8(r)},"encode");return n},"makeEncodeDefect"),pM=s(e=>s8(e)?fM(e):e,"decodeDefect"),mM=s(e=>We({decode:fM,encode:s(t=>dM(e)(t),"encode")}),"errorFromJsonError"),hM=s(e=>We({decode:pM,encode:dM(e)}),"defectFromJson");function gM(){return We({decode:A$,encode:$E})}s(gM,"optionFromNullOr");function xM(){return We({decode:k$,encode:Ni})}s(xM,"optionFromUndefinedOr");function yM(e){return We({decode:T$,encode:e?.onNoneEncoding===null?$E:Ni})}s(yM,"optionFromNullishOr");function SM(){return Sx({decode:H,encode:kc})}s(SM,"optionFromOptionalKey");function bM(){return Sx({decode:s(e=>e.pipe(Ac(rn),H),"decode"),encode:kc})}s(bM,"optionFromOptional");var Qk=ir({decode:s((e,t)=>URL.canParse(e)?se(new URL(e)):W(new Ee({expected:"a valid URL string"},e,t)),"decode"),encode:s(e=>se(e.href),"encode")}),eA=ir({decode:s((e,t)=>{let n=G$(e);return Xe(n)?W(new Ee({expected:"a valid BigDecimal string"},e,t)):se(n.value)},"decode"),encode:s(e=>se(eo(e)),"encode")}),tA=new Re(Vz(),Wk()),vM=new Re(Hz(),Wk()),_M=new Re(Jz(),hx()),wM=new Re(Yz(),gx()),EM=new Re(Qz(),Xz());function IM(e){return new Re(qz(e??{}),Bz(e))}s(IM,"fromJsonString");var TM=new Re(eM(),tM()),kM=new Re(nM(),rM()),AM=We({decode:s(e=>ua(e),"decode"),encode:s(e=>e.offset,"encode")}),nA=ir({decode:s((e,t)=>_r(Dk(e),{onNone:s(()=>W(new Ee({expected:"a valid IANA time zone"},e,t)),"onNone"),onSome:se}),"decode"),encode:s(e=>se(e.id),"encode")}),rA=ir({decode:s((e,t)=>_r(Fk(e),{onNone:s(()=>W(new Ee({expected:"a valid time zone"},e,t)),"onNone"),onSome:se}),"decode"),encode:s(e=>se(Wo(e)),"encode")}),oA=ir({decode:s((e,t)=>_r(Gf(e),{onNone:s(()=>W(new Ee({expected:"a valid UTC DateTime string"},e,t)),"onNone"),onSome:s(n=>se(jf(n)),"onSome")}),"decode"),encode:s(e=>se(Mk(e)),"encode")}),sA=ir({decode:s((e,t)=>_r(Nk(e),{onNone:s(()=>W(new Ee({expected:"a valid Zoned DateTime string"},e,t)),"onNone"),onSome:se}),"decode"),encode:s(e=>se(qf(e)),"encode")});function Ws(e){return t=>t._tag===e}s(Ws,"makeGuard");var mo=Ws("Declaration");var c8=Ws("Never");var iu=Ws("Literal"),aA=Ws("UniqueSymbol");var IA=Ws("Arrays"),u8=Ws("Objects"),LM=Ws("Union"),l8=Ws("Suspend"),He=class{static{s(this,"Link")}to;transformation;constructor(t,n){this.to=t,this.transformation=n}},ma={},ar=class{static{s(this,"Context")}isOptional;isMutable;constructorDefault;annotations;constructor(t,n,r=void 0,o=void 0){this.isOptional=t,this.isMutable=n,this.constructorDefault=r,this.annotations=o}},CM="~effect/Schema",tt=class{static{s(this,"Base")}[CM]=CM;annotations;checks;encoding;context;constructor(t=void 0,n=void 0,r=void 0,o=void 0){this.annotations=t,this.checks=n,this.encoding=r,this.context=o}toString(){return`<${this._tag}>`}},fa=class e extends tt{static{s(this,"Declaration")}_tag="Declaration";typeParameters;run;encodingChecks;constructor(t,n,r,o,i,a,c){super(r,o,i,a),this.typeParameters=t,this.run=n,this.encodingChecks=c}getParser(){let t;return(n,r)=>n===Oe?fo:(t??=this.run(this.typeParameters))(n,this,r)}_rebuild(t,n,r){let o=cu(this.typeParameters,t);return o===this.typeParameters&&n===this.checks&&r===this.encodingChecks?this:new e(o,this.run,this.annotations,n,void 0,this.context,r)}recur(t){return this._rebuild(t,this.checks,this.encodingChecks)}flip(t){return this._rebuild(t,this.encodingChecks,this.checks)}getExpected(){let t=this.annotations?.expected;return typeof t=="string"?t:"<Declaration>"}},cA=class extends tt{static{s(this,"Null")}_tag="Null";getParser(){return Fx(this,null)}getExpected(){return"null"}},TA=new cA;var uA=class extends tt{static{s(this,"Undefined")}_tag="Undefined";getParser(){return Fx(this,void 0)}toCodecJson(){return Ge(this,[FM])}getExpected(){return"undefined"}},FM=new He(TA,new Re(xe(()=>{}),xe(()=>null))),kA=new uA;var lA=class extends tt{static{s(this,"Void")}_tag="Void";getParser(){let t=lo(void 0);return n=>n===Oe?fo:t}toCodecJson(){return Ge(this,[FM])}getExpected(){return"void"}},zM=new lA;var fA=class extends tt{static{s(this,"Never")}_tag="Never";getParser(){return Lr(this,KR)}getExpected(){return"never"}},MM=new fA,dA=class extends tt{static{s(this,"Any")}_tag="Any";getParser(){return Lr(this,fE)}getExpected(){return"any"}},UM=new dA,pA=class extends tt{static{s(this,"Unknown")}_tag="Unknown";getParser(){return Lr(this,fE)}getExpected(){return"unknown"}},Qo=new pA,mA=class extends tt{static{s(this,"ObjectKeyword")}_tag="ObjectKeyword";getParser(){return Lr(this,zl)}getExpected(){return"object | array | function"}},GM=new mA,vx=class extends tt{static{s(this,"Enum")}_tag="Enum";enums;constructor(t,n,r,o,i){super(n,r,o,i),this.enums=t}getParser(){let t=new Set(this.enums.map(([,n])=>n));return Lr(this,n=>t.has(n))}toCodecStringTree(){if(this.enums.some(([t,n])=>typeof n=="number")){let t=Object.fromEntries(this.enums.map(([n,r])=>[globalThis.String(r),r]));return Ge(this,[new He(new dn(Object.keys(t).map(n=>new Cn(n)),"anyOf"),new Re(xe(n=>t[n]),la()))])}return this}getExpected(){return this.enums.map(([t,n])=>JSON.stringify(n)).join(" | ")}};function jM(e){switch(e._tag){case"String":case"Number":case"BigInt":return!0;case"Literal":case"TemplateLiteral":return!e.checks;case"Union":return!e.checks&&e.types.every(jM);default:return!1}}s(jM,"isTemplateLiteralPart");var _x=class extends tt{static{s(this,"TemplateLiteral")}_tag="TemplateLiteral";parts;encodedParts;literals;suffixLengths;constructor(t,n,r,o,i){super(n,r,o,i);let a=[],c=[];for(let u of t){let f=On(u);if(jM(f))a.push(f),c.push(f._tag==="Literal"?globalThis.String(f.literal):void 0);else throw new Error(`Invalid TemplateLiteral part ${f._tag}`)}let l=new Array(a.length+1);l[a.length]=0;for(let u=a.length-1;u>=0;u--)l[u]=l[u+1]+(c[u]?.length??0);this.parts=t,this.encodedParts=a,this.literals=c,this.suffixLengths=l}getParser(t){let n=t(this.asTemplateLiteralParser());return(r,o)=>{if(r===Oe)return fo;let i=n(r,o);return i._tag==="Success"?bt:Ct(i,{onSuccess:s(()=>r,"onSuccess"),onFailure:s(a=>new Qe(this,[a],r,o),"onFailure")})}}getExpected(){return"string"}matchPart(t,n){return DM(this,t,n)===void 0?void 0:t}asTemplateLiteralParser(){let t=new Nr(!1,this.parts.map(cU),[]);return Lx(po,t,new Re(An((n,r)=>{let o=DM(this,n,r);return o?se(o):W(new Ee({expected:"a string matching template literal parts"},n,r))}),xe(n=>n.join(""))))}},wx=class extends tt{static{s(this,"UniqueSymbol")}_tag="UniqueSymbol";symbol;constructor(t,n,r,o,i){super(n,r,o,i),this.symbol=t}getParser(){return Fx(this,this.symbol)}toCodecStringTree(){return Ge(this,[fU])}getExpected(){return globalThis.String(this.symbol)}},Cn=class extends tt{static{s(this,"Literal")}_tag="Literal";literal;constructor(t,n,r,o,i){if(super(n,r,o,i),typeof t=="number"&&!globalThis.Number.isFinite(t))throw new Error(`A numeric literal must be finite, got ${z(t)}`);this.literal=t}getParser(){return Fx(this,this.literal)}matchPart(t,n){return t===globalThis.String(this.literal)?this.literal:void 0}toCodecJson(){return typeof this.literal=="bigint"?OM(this):this}toCodecStringTree(){return typeof this.literal=="string"?this:OM(this)}getExpected(){return typeof this.literal=="string"?JSON.stringify(this.literal):globalThis.String(this.literal)}};function OM(e){let t=globalThis.String(e.literal);return Ge(e,[new He(new Cn(t),new Re(xe(()=>e.literal),xe(()=>t)))])}s(OM,"literalToString");var hA=class extends tt{static{s(this,"String")}_tag="String";getParser(){return Lr(this,yr)}matchPart(t,n){let r=this.checks;return r&&!n.disableChecks&&Fr(r,t,void 0,this,n)?void 0:t}getExpected(){return"string"}},po=new hA,gA=class extends tt{static{s(this,"Number")}_tag="Number";getParser(){return Lr(this,Fl)}matchKey(t,n){return this._match(w8,t,n)}matchPart(t,n){return this._match(_A,t,n)}_match(t,n,r){if(!t.test(n))return;let o=globalThis.Number(n);return r.disableChecks||!this.checks?o:Fr(this.checks,o,void 0,this,r)?void 0:o}toCodecJson(){return this.checks&&(xA(this.checks,"effect/schema/isFinite")||xA(this.checks,"effect/schema/isInt"))?this:Ge(this,[f8(this.checks)])}toCodecStringTree(){return this.toCodecJson()===this?Ge(this,[E8]):Ge(this,[I8])}getExpected(){return"number"}};function xA(e,t){return e.some(n=>n.annotations?.representation?.id===t||n._tag==="FilterGroup"&&xA(n.checks,t))}s(xA,"hasCheck");function f8(e){let t=e?Dr(kx,e):kx;return new He(new dn([t,JM],"anyOf"),new Re(mx(),xe(n=>globalThis.Number.isFinite(n)?n:globalThis.String(n))))}s(f8,"numberToJson");var AA=new gA,yA=class extends tt{static{s(this,"Boolean")}_tag="Boolean";getParser(){return Lr(this,BR)}getExpected(){return"boolean"}},ZM=new yA,SA=class extends tt{static{s(this,"Symbol")}_tag="Symbol";getParser(){return Lr(this,lE)}matchKey(t,n){return n.disableChecks||!this.checks?t:Fr(this.checks,t,void 0,this,n)?void 0:t}toCodecStringTree(){return Ge(this,[fU])}getExpected(){return"symbol"}},qM=new SA,bA=class extends tt{static{s(this,"BigInt")}_tag="BigInt";getParser(){return Lr(this,VR)}matchPart(t,n){if(!wA.test(t))return;let r=globalThis.BigInt(t);return n.disableChecks||!this.checks?r:Fr(this.checks,r,void 0,this,n)?void 0:r}toCodecStringTree(){return Ge(this,[k8])}getExpected(){return"bigint"}},BM=new bA,Nr=class e extends tt{static{s(this,"Arrays")}_tag="Arrays";isMutable;elements;rest;encodingChecks;constructor(t,n,r,o,i,a,c,l){super(o,i,a,c),this.isMutable=t,this.elements=n,this.rest=r,this.encodingChecks=l;let u=!1;for(let f=0;f<n.length;f++)if(it(n[f]))u=!0;else if(u)throw new Error("A required element cannot follow an optional element. ts(1257)");if(u&&r.length>1)throw new Error("A required element cannot follow an optional element. ts(1257)");for(let f=1;f<r.length;f++)if(it(r[f]))throw new Error("An optional element cannot follow a rest element. ts(1266)")}getParser(t,n=t){let r=this,o,i,a=r.elements.length,c=Math.max(0,r.rest.length-1);function l(u,f){return f<a?o[f]:f>=u?i[f-u+1]:i[0]}return s(l,"getParser"),Qg(function*(u,f){if(u===Oe)return Oe;if(!Array.isArray(u))return yield*W(new et(r,u,f));o||(o=r.elements.map(x=>({ast:x,parser:n(x)})),i=r.rest.map(x=>({ast:x,parser:n(x)})));let d=u.length,p={ast:r,getParser:l,input:u,len:d,tailThreshold:Math.max(a,d-c),output:new globalThis.Array(d),issues:void 0,options:f},m=CA(f?.concurrency),h=d8(p,u,{concurrency:m?.concurrency,end:r.rest.length===0?a:Math.max(d,a+c)});if(h&&(yield*h),r.rest.length===0&&d>a)for(let x=a;x<=d-1;x++){let S=new zf(r,u[x],f),T=new Ot([x],S);if(f.errors==="all")p.issues?p.issues.push(T):p.issues=[T];else return yield*W(new Qe(r,[T],u,f))}return p.issues?yield*W(new Qe(r,p.issues,u,f)):p.output})}_rebuild(t,n,r){let o=cu(this.elements,t),i=cu(this.rest,t);return o===this.elements&&i===this.rest&&n===this.checks&&r===this.encodingChecks?this:new e(this.isMutable,o,i,this.annotations,n,void 0,this.context,r)}recur(t){return this._rebuild(t,this.checks,this.encodingChecks)}flip(t){return this._rebuild(t,this.encodingChecks,this.checks)}getExpected(){return"array"}},d8=xf()({onItem(e,t,n){let r=n<e.len?t:Oe;return e.getParser(e.tailThreshold,n).parser(r,e.options)},step(e,t,n,r){if(n._tag==="Failure")return Ex(e,e.ast,r,n);let o=n===bt?t:n[ee];if(o!==Oe)e.output[r]=o;else{let i=e.getParser(e.tailThreshold,r);if(it(i.ast))return;let a=new Ot([r],new Ks(i.ast.context?.annotations));if(e.options.errors==="all")e.issues?e.issues.push(a):e.issues=[a];else return jc(new Qe(e.ast,[a],e.input,e.options))}}}),CA=s(e=>(e=e==="unbounded"?1/0:e??1,e>1?{concurrency:e}:void 0),"resolveConcurrency"),Ex=s((e,t,n,r)=>{if(r.cause.reasons.length===0)return r;let o=Uf(r.cause);if(o===void 0)return Bo(Gs(r.cause,a=>new Qe(t,[new Ot([n],a)],e.input,e.options)));let i=new Ot([n],o);if(e.options.errors==="all")e.issues?e.issues.push(i):e.issues=[i];else return jc(new Qe(t,[i],e.input,e.options))},"wrapPropertyKeyIssue"),Ax="[+-]?\\d*\\.?\\d+(?:[Ee][+-]?\\d+)?";function da(e,t,n=ma){let r,o;function i(a){switch(a._tag){case"String":case"TemplateLiteral":return(r??=Object.keys(e)).filter(c=>a.matchPart(c,n)!==void 0);case"Number":return(r??=Object.keys(e)).filter(c=>a.matchKey(c,n)!==void 0);case"Symbol":return(o??=Object.getOwnPropertySymbols(e)).filter(c=>a.matchKey(c,n)!==void 0);case"Union":return[...new Set(a.types.flatMap(i))];default:return[]}}return s(i,"go"),i(FA(On(t)))}s(da,"getIndexSignatureKeys");var Jf=class{static{s(this,"PropertySignature")}name;type;constructor(t,n){this.name=t,this.type=n}};function vA(e){switch(e._tag){case"String":case"Number":case"Symbol":case"TemplateLiteral":return!0;case"Union":return e.types.every(vA);default:return!1}}s(vA,"isIndexSignatureParameterSide");function p8(e){return vA(e)&&vA(On(e))}s(p8,"isIndexSignatureParameter");var Wf=class{static{s(this,"IndexSignature")}parameter;type;constructor(t,n){if(!p8(t))throw new Error(`Invalid index signature parameter ${t._tag}`);if(this.parameter=t,this.type=n,it(n)&&!iU(n))throw new Error("Cannot use `Schema.optionalKey` with index signatures, use `Schema.optional` instead.")}},au=class e extends tt{static{s(this,"Objects")}_tag="Objects";propertySignatures;indexSignatures;encodingChecks;constructor(t,n,r,o,i,a,c){super(r,o,i,a),this.propertySignatures=t,this.indexSignatures=n,this.encodingChecks=c;let l=t.map(u=>u.name).filter((u,f,d)=>d.indexOf(u)!==f);if(l.length>0)throw new Error(`Duplicate identifiers: ${JSON.stringify(l)}. ts(2300)`)}getParser(t,n=t){let r=this,o=[];for(let h of r.propertySignatures)o.push(h.name);let i=o.length,a=r.indexSignatures.length,c=i&&a?new Set(o):void 0;if(!i&&!a)return Lr(r,Hm);let l,u,f=s((h,x,S,T,b)=>{if(b._tag==="Failure")return Ex(h,r,x,b)??js;let v=b===bt?T:b[ee];if(S!==Oe&&v!==Oe){if(i&&(c.has(x)||c.has(S)))return js;V(h.out,S,v)}return js},"finishIndex"),d=s((h,x,S,T)=>{if(!T){let w=S.parserKey(x,h.options);if(!Ve(w))return In(Qc(w),I=>d(h,x,S,I));T=w}if(T._tag==="Failure")return Ex(h,r,x,T)??js;let b=T===bt?x:T[ee],v=h.input[x],C=S.parserValue(v,h.options);return Ve(C)?f(h,x,b,v,C):In(Qc(C),w=>f(h,x,b,v,w))},"parseIndex"),p=s((h,x,S)=>{let T=h.input[x],b=S.parserValue(T,h.options);return Ve(b)?f(h,x,x,T,b):In(Qc(b),v=>f(h,x,x,T,v))},"parseStringIndex"),m=a?xf()({onItem:s((h,[x,S])=>d(h,x,S),"onItem"),step:s((h,x,S)=>S._tag==="Failure"?S:void 0,"step")}):void 0;return Qg(function*(h,x){if(h===Oe)return Oe;if(!(typeof h=="object"&&h!==null&&!Array.isArray(h)))return yield*W(new et(r,h,x));l||(l=r.propertySignatures.map(O=>({parser:n(O.type),name:O.name,type:O.type})),u=a?r.indexSignatures.map(O=>({is:O,parserKey:t(FA(O.parameter)),parserValue:n(O.type)})):void 0);let S=h,T={},b={ast:r,input:S,out:T,issues:void 0,options:x},v=x.errors==="all",C=x.onExcessProperty==="error",w=x.onExcessProperty==="preserve",I;if(!a&&(C||w)){c??=new Set(o),I=Reflect.ownKeys(S);for(let O=0;O<I.length;O++){let L=I[O];if(!c.has(L))if(C){let q=new zf(r,S[L],x),Q=new Ot([L],q);if(v){b.issues?b.issues.push(Q):b.issues=[Q];continue}else return yield*W(new Qe(r,[Q],h,x))}else V(T,L,S[L])}}let A=CA(x?.concurrency);if(i){let O=m8(b,l,A);O&&(yield*O)}if(a&&!A)for(let O=0;O<a;O++){let L=u[O],q=L.is.parameter===po?p:d,Q=L.is.parameter===po?Object.keys(S):da(S,L.is.parameter,x);for(let E=0;E<Q.length;E++){let k=q(b,Q[E],L);if(!Ve(k))yield*k;else if(k._tag==="Failure")return yield*k}}else if(m){let O=Sh();for(let q=0;q<a;q++){let Q=u[q],E=da(S,Q.is.parameter,x);for(let k=0;k<E.length;k++)O.push([E[k],Q])}let L=m(b,O,A);L&&(yield*L)}if(b.issues)return yield*W(new Qe(r,b.issues,h,x));if(x.propertyOrder==="original"){let O=(I??Reflect.ownKeys(S)).concat(o),L={};for(let q of O)Object.hasOwn(T,q)&&V(L,q,T[q]);return L}return T})}_rebuild(t,n,r,o){let i=cu(this.propertySignatures,c=>{let l=t(c.type);return l===c.type?c:new Jf(c.name,l)}),a=cu(this.indexSignatures,c=>{let l=n(c.parameter),u=t(c.type);return l===c.parameter&&u===c.type?c:new Wf(l,u)});return i===this.propertySignatures&&a===this.indexSignatures&&r===this.checks&&o===this.encodingChecks?this:new e(i,a,this.annotations,r,void 0,this.context,o)}flip(t){return this._rebuild(t,t,this.encodingChecks,this.checks)}recur(t,n=t){return this._rebuild(t,n,this.checks,this.encodingChecks)}getExpected(){return this.propertySignatures.length===0&&this.indexSignatures.length===0?"object | array":"object"}},m8=xf()({onItem(e,t){if(!Object.hasOwn(e.input,t.name))return t.parser(Oe,e.options);let n=e.input[t.name];return V(e.out,t.name,n),t.parser(n,e.options)},step(e,t,n){if(n._tag==="Failure")return Ex(e,e.ast,t.name,n);if(n===bt)return;let r=n[ee];if(r!==Oe){V(e.out,t.name,r);return}if(delete e.out[t.name],!it(t.type)){let o=new Ot([t.name],new Ks(t.type.context?.annotations));if(e.options.errors==="all"){e.issues?e.issues.push(o):e.issues=[o];return}else return jc(new Qe(e.ast,[o],e.input,e.options))}}});function OA(e,t){return e?t?[...e,...t]:e:t}s(OA,"combineChecks");function Cx(e,t,n){return new au(Reflect.ownKeys(e).map(r=>new Jf(r,e[r].ast)),[],n,t)}s(Cx,"struct");function Yf(e){return e.ast}s(Yf,"getAST");function RA(e,t=void 0){return new Nr(!1,e.map(n=>n.ast),[],void 0,t)}s(RA,"tuple");function Ox(e,t,n){return new dn(e.map(Yf),t,void 0,n)}s(Ox,"union");function VM(e,t){if(e.encoding||t.some(i=>i.encoding))throw new Error("StructWithRest does not support encodings");let n=e.propertySignatures,r=e.indexSignatures,o=e.checks;for(let i of t)n=n.concat(i.propertySignatures),r=r.concat(i.indexSignatures),o=OA(o,i.checks);return new au(n,r,void 0,o)}s(VM,"structWithRest");function HM(e,t){if(e.encoding)throw new Error("TupleWithRest does not support encodings");return new Nr(e.isMutable,e.elements,t,void 0,e.checks)}s(HM,"tupleWithRest");var $A=wi(e=>{for(;;){if(l8(e))return Qo;let t=e.encoding;if(!t)return e.recur?.($A,J)??e;if(t.some(n=>n.transformation._tag==="Middleware"&&n.transformation.decode!==J))return Qo;e=t[t.length-1].to}});function KM(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(KM)));default:return["null","undefined","string","number","boolean","symbol","bigint","object","array","function"]}}s(KM,"getCandidateTypes");function Xf(e){switch(e._tag){default:return[];case"Declaration":{let t=e.annotations?.[Nf];return Array.isArray(t)?t:[]}case"Objects":return e.propertySignatures.flatMap(t=>{let n=t.type;if(!it(n)){if(iu(n))return[{key:t.name,literal:n.literal}];if(aA(n))return[{key:t.name,literal:n.symbol}]}return[]});case"Arrays":return e.elements.flatMap((t,n)=>{if(!it(t)){if(iu(t))return[{key:n,literal:t.literal}];if(aA(t))return[{key:n,literal:t.symbol}]}return[]});case"Suspend":return Xf(e.thunk())}}s(Xf,"collectSentinels");var RM=new WeakMap,Kf=Object.freeze([]);function h8(e){let t=RM.get(e);if(t)return t;t={};let n;for(let r=0;r<e.length;r++){let o=e[r],i=$A(o);if(c8(i))continue;if(n!==null)if(iu(i)||aA(i)){n??=new Map;let c=iu(i)?i.literal:i.symbol,l=n.get(c);l||n.set(c,l=[]),l.push(o)}else n=null;let a=Xf(i);if(a.length){t.bySentinel??=new Map;for(let{key:c,literal:l}of a){let u=t.bySentinel.get(c);u||t.bySentinel.set(c,u=new Map);let f=u.get(l);f||u.set(l,f=[]),f[f.length-1]!==r&&f.push(r)}}else{t.otherwise??={};let c=KM(i);for(let l of c)(t.otherwise[l]??=[]).push(r)}}if(n)n.forEach(Object.freeze),t=s(r=>n.get(r)??Kf,"idx");else if(t.bySentinel?.size===1&&!t.otherwise)for(let[r,o]of t.bySentinel){let i=o;for(let[a,c]of o)i.set(a,Object.freeze(c.map(l=>e[l])));t=s((a,c)=>{if(zl(a)){let l=Object.hasOwn(a,r)?a[r]:void 0;if(l!==void 0)return i.get(l)??Kf;if(c)return e}return Kf},"idx")}return RM.set(e,t),t}s(h8,"getIndex");function g8(e){return t=>{let n=$A(t);return n._tag==="Literal"?n.literal===e:n._tag==="UniqueSymbol"?n.symbol===e:!0}}s(g8,"filterLiterals");function Qf(e,t,n=!1){let r=h8(t);if(typeof r=="function")return r(e,n);let o=e===null?"null":Array.isArray(e)?"array":typeof e;if(r.bySentinel){let i=r.otherwise?.[o]??Kf;if(zl(e)){let a=new Set(i);for(let[c,l]of r.bySentinel){let u=Object.hasOwn(e,c)?e[c]:void 0;if(u!==void 0){let f=l.get(u);if(f)for(let d of f)a.add(d)}else if(n)for(let f of l.values())for(let d of f)a.add(d)}return Array.from(a).sort((c,l)=>c-l).map(c=>t[c])}return i.map(a=>t[a])}return(r.otherwise?.[o]??Kf).map(i=>t[i]).filter(g8(e))}s(Qf,"getCandidates");var dn=class e extends tt{static{s(this,"Union")}_tag="Union";types;mode;encodingChecks;constructor(t,n,r,o,i,a,c){super(r,o,i,a),this.types=t,this.mode=n,this.encodingChecks=c}getParser(t,n){let r=this;return(o,i)=>{if(o===Oe)return fo;let a=Qf(o,r.types,n!==void 0);if(a.length===1){let f=t(a[0])(o,i);return f._tag==="Success"?f:Ve(f)?$M(r,f.cause,o,i):Hs(f,d=>$M(r,d,o,i))}let c={ast:r,compile:t,input:o,out:void 0,successes:r.mode==="oneOf"?[]:void 0,issues:void 0,options:i},l=CA(i?.concurrency),u=x8(c,a,l?{...l,orderedStep:!0}:void 0);return u?qn(u,f=>c.out===bt?se(o):c.out?c.out:W(new nu(r,c.issues??[],o,i))):c.out?c.out:W(new nu(r,c.issues??[],o,i))}}_rebuild(t,n,r){let o=cu(this.types,t);return o===this.types&&n===this.checks&&r===this.encodingChecks?this:new e(o,this.mode,this.annotations,n,void 0,this.context,r)}recur(t){return this._rebuild(t,this.checks,this.encodingChecks)}flip(t){return this._rebuild(t,this.encodingChecks,this.checks)}matchPart(t,n){for(let r of this.types){let o=r.matchPart(t,n);if(o!==void 0)return o}}getExpected(t){let n=this.annotations?.expected;if(typeof n=="string")return n;if(this.types.length===0)return"never";let r=this.types.map(o=>{let i=On(o);switch(i._tag){case"Arrays":{let a=i.elements.filter(iu);if(a.length>0)return`${PM(i.isMutable)}[ ${a.map(c=>t(c)+NM(c.context?.isOptional)).join(", ")}, ... ]`;break}case"Objects":{let a=i.propertySignatures.filter(c=>iu(c.type));if(a.length>0)return`{ ${a.map(c=>`${PM(c.type.context?.isMutable)}${Ao(c.name)}${NM(c.type.context?.isOptional)}: ${t(c.type)}`).join(", ")}, ... }`;break}}return t(i)});return Array.from(new Set(r)).join(" | ")}};function $M(e,t,n,r){let o=Uf(t);return o?jc(new nu(e,[o],n,r)):Bo(t)}s($M,"failSingleUnionCandidate");var x8=xf()({onItem(e,t){return e.compile(t)(e.input,e.options)},step(e,t,n){if(n._tag==="Failure"){let r=Uf(n.cause);if(r===void 0)return n;e.issues?e.issues.push(r):e.issues=[r]}else{if(e.out&&e.successes)return e.successes.push(t),jc(new ix(e.ast,e.successes,e.input,e.options));if(e.out=n,e.successes)e.successes.push(t);else return js}}}),JM=new dn([new Cn("Infinity"),new Cn("-Infinity"),new Cn("NaN")],"anyOf");function PM(e){return e?"":"readonly "}s(PM,"formatIsMutable");function NM(e){return e?"?":""}s(NM,"formatIsOptional");function ha(e){let t=!1,n;return()=>(t||(n=e(),t=!0),n)}s(ha,"memoizeThunk");var Ix=class e extends tt{static{s(this,"Suspend")}_tag="Suspend";thunk;constructor(t,n,r,o,i){if(r)throw new Error("Cannot add checks to Suspend");super(n,void 0,o,i),this.thunk=ha(t)}getParser(t){let n;return(r,o)=>(n??=t(this.thunk()))(r,o)}recur(t){return new e(()=>t(this.thunk()),this.annotations,void 0,void 0,this.context)}getExpected(t){return t(this.thunk())}},Tx=class e extends _i{static{s(this,"Filter")}_tag="Filter";run;annotations;aborted;constructor(t,n=void 0,r=!1){super(),this.run=t,this.annotations=n,this.aborted=r}annotate(t){return new e(this.run,{...this.annotations,...t},this.aborted)}abort(){return new e(this.run,this.annotations,!0)}and(t,n){return new pa([this,t],n)}},pa=class e extends _i{static{s(this,"FilterGroup")}_tag="FilterGroup";checks;annotations;constructor(t,n=void 0){super(),this.checks=t,this.annotations=n}annotate(t){return new e(this.checks,{...this.annotations,...t})}and(t,n){return new e([this,t],n)}};function Rx(e,t,n=!1){return new Tx((r,o,i)=>xz(o,e(r,o,i),r,i),t,n)}s(Rx,"makeFilter");function $x(e,t){return new Tx((n,r,o)=>e(n)?void 0:new Ee(void 0,n,o),t,!0)}s($x,"makeFilterByGuard");function PA(e){return Rx(t=>globalThis.Number.isFinite(t),{expected:"a finite number",representation:{id:"effect/schema/isFinite",payload:null},toJsonSchema:s(()=>({type:"number"}),"toJsonSchema"),toCode:s(()=>({runtime:"Schema.isFinite()"}),"toCode"),arbitrary:{constraint:{noInfinity:!0,noNaN:!0}},...e})}s(PA,"isFinite");var kx=Dr(AA,[PA()]);function ed(e,t){let n=e.source,r=new globalThis.RegExp(n,e.flags);return Rx(o=>(r.lastIndex=0,r.test(o)),{expected:`a string matching the RegExp ${n}`,representation:{id:"effect/schema/isPattern",payload:{source:n,flags:e.flags}},toJsonSchema:s(()=>({pattern:n}),"toJsonSchema"),arbitrary:{constraint:{patterns:[e.source]}},...t})}s(ed,"isPattern");function td(e,t){let n=Object.getOwnPropertyDescriptors(e);return t(n),Object.create(Object.getPrototypeOf(e),n)}s(td,"modifyOwnPropertyDescriptors");var WM=new WeakMap;function Px(e){return WM.get(e)??e}s(Px,"getContextOwner");function Ge(e,t){return e.encoding===t?e:td(e,n=>{n.encoding.value=t})}s(Ge,"replaceEncoding");function nd(e,t){if(e.context===t)return e;let n=Px(e);if(n.context===t)return n;let r=td(e,o=>{o.context.value=t});return WM.set(r,n),r}s(nd,"replaceContext");function lu(e){return e.encoding?lu(e.encoding[e.encoding.length-1].to):e}s(lu,"getLastEncoding");function cr(e,t){if(e.checks){let n=e.checks[e.checks.length-1];return Nx(e,FE(e.checks.slice(0,-1),n.annotate(t)))}return td(e,n=>{n.annotations.value={...n.annotations.value,...t}})}s(cr,"annotate");function Nx(e,t){if(e._tag==="Suspend"&&t)throw new Error("Cannot add checks to Suspend");return e.checks===t?e:td(e,n=>{n.checks.value=t})}s(Nx,"replaceChecks");function Dr(e,t){return Nx(e,OA(e.checks,t))}s(Dr,"appendChecks");function fu(e,t){let n=t(e.to);return n===e.to?e:new He(n,e.transformation)}s(fu,"mapLink");function YM(e,t){let n=e,r=n[n.length-1],o=fu(r,t);return o===r?e:FE(e.slice(0,e.length-1),o)}s(YM,"updateLastLink");function NA(e){return t=>t.encoding?Ge(t,YM(t.encoding,e)):t}s(NA,"applyToLastLink");function Dx(e,t){return NA(n=>nd(n,t))(e)}s(Dx,"replaceContextLastLink");function ga(e,t){function n(r){if(r.encoding){let o=r.encoding[r.encoding.length-1];return t?.stopAt?.(o)?r:Ge(r,YM(r.encoding,n))}return e(r)}return s(n,"out"),wi(n)}s(ga,"applyToSelfOrLastLinkEncodingIdempotent");function XM(e,t){return DA(e,t,jt(e))}s(XM,"middlewareDecoding");function QM(e,t){return DA(On(e),t,e)}s(QM,"middlewareEncoding");function DA(e,t,n){let r=new He(e,t);return Ge(n,n.encoding?[...n.encoding,r]:[r])}s(DA,"appendTransformation");function eU(e,t){let n=mz(e),r=n?[...n,t]:[t];return cr(e,{brands:r})}s(eU,"brand");function cu(e,t){let n=!1,r=new Array(e.length);for(let o=0;o<e.length;o++){let i=e[o],a=t(i);a!==i&&(n=!0),r[o]=a}return n?r:e}s(cu,"mapOrSame");function rd(e,t){let n=e.context?new ar(e.context.isOptional,e.context.isMutable,e.context.constructorDefault,{...e.context.annotations,...t}):new ar(!1,!1,void 0,t);return nd(e,n)}s(rd,"annotateKey");var du=wi(e=>{let t=e.context?e.context.isOptional===!1?new ar(!0,e.context.isMutable,e.context.constructorDefault,e.context.annotations):e.context:new ar(!0,!1);return y8(nd(e,t))}),y8=NA(du),tU=Bt(e=>du(new dn([e,kA],"anyOf"))),LA=wi(e=>{let t=e.context?e.context.isMutable===!1?new ar(e.context.isOptional,!0,e.context.constructorDefault,e.context.annotations):e.context:new ar(!1,!0);return S8(nd(e,t))}),S8=NA(LA);function nU(e,t){let n=new Re(Bf(t),$r()),r=new He(Qo,n),o=e.context?new ar(e.context.isOptional,e.context.isMutable,r,e.context.annotations):new ar(!1,!1,r);return nd(e,o)}s(nU,"withConstructorDefault");function Lx(e,t,n){return DA(e,n,t)}s(Lx,"decodeTo");function b8(e){let t=[],n=[];function r(o){switch(o._tag){case"Literal":Vm(o.literal)&&t.push(o.literal);return;case"UniqueSymbol":t.push(o.symbol);return;case"Never":return;case"Union":for(let i=0;i<o.types.length;i++)r(o.types[i]);return;default:n.push(o)}}return s(r,"go"),r(e),{literals:t,parameters:n}}s(b8,"parseParameter");function rU(e,t){let{literals:n,parameters:r}=b8(e);return new au(n.map(o=>new Jf(o,t)),r.map(o=>new Wf(o,t)))}s(rU,"record");function it(e){return e.context?.isOptional??!1}s(it,"isOptional");function oU(e){return e.context?.isMutable??!1}s(oU,"isMutable");function sU(e){return e.annotations?.[Tn]===!0||e._tag==="FilterGroup"&&e.checks.every(sU)}s(sU,"isStructuralCheck");function v8(e){function t(r){return sU(r)?[r]:r._tag==="FilterGroup"?r.checks.flatMap(t):[]}s(t,"extract");let n=e.flatMap(t);return Cc(n)?n:void 0}s(v8,"extractStructuralChecks");var jt=wi(e=>{if(e.encoding)return jt(Ge(e,void 0));let t=e,n=t.recur?.(jt)??t,r=n.encodingChecks;if(r){let o=n===e?r:IA(n)||u8(n)||mo(n)&&n.typeParameters.length>0?v8(r):void 0;return td(n,i=>{i.encodingChecks.value=void 0,i.checks.value=OA(n.checks,o)})}return n}),On=wi(e=>jt(Pr(e)));function _8(e,t){let n=t,r=n.length,o=n[r-1],i=[new He(Pr(Ge(e,void 0)),n[0].transformation.flip())];for(let c=1;c<r;c++)i.unshift(new He(Pr(n[c-1].to),n[c].transformation.flip()));let a=Pr(o.to);return a.encoding?Ge(a,[...a.encoding,...i]):Ge(a,i)}s(_8,"flipEncoding");var Pr=Bt(e=>{if(e.encoding)return _8(e,e.encoding);let t=e;return t.flip?.(Pr)??t.recur?.(Pr)??t});function iU(e){switch(e._tag){case"Undefined":return!0;case"Union":return e.types.some(iU);default:return!1}}s(iU,"containsUndefined");function Fx(e,t){let n=lo(t);return(r,o)=>r===Oe?fo:r===t?n:W(new et(e,r,o))}s(Fx,"fromConst");function Lr(e,t){return(n,r)=>n===Oe?fo:t(n)?bt:W(new et(e,n,r))}s(Lr,"fromRefinement");function DM(e,t,n){let r=e.encodedParts,o=e.literals,i=t.length;for(let u=0;u<o.length;u++){let f=o[u];if(f&&!t.includes(f))return}if(e.suffixLengths[0]>i)return;let a=new Array(r.length),c;function l(u,f){if(u===r.length)return f===i;if(c?.has(u*(i+1)+f))return!1;let d=r[u];if(u===r.length-1){let p=t.slice(f);if(d.matchPart(p,n)!==void 0)return a[u]=p,!0}else if(d._tag==="Literal"){let p=o[u];if(t.startsWith(p,f)&&l(u+1,f+p.length))return a[u]=p,!0}else{let p=i-e.suffixLengths[u+1],m=o[u+1],h=m===void 0?p:t.lastIndexOf(m,p);for(;h>=f;){let x=t.slice(f,h);if(d.matchPart(x,n)!==void 0&&l(u+1,h))return a[u]=x,!0;if(h===0)break;h=m===void 0?h-1:t.lastIndexOf(m,h-1)}}return c??=new Set,c.add(u*(i+1)+f),!1}return s(l,"go"),l(0,0)?a:void 0}s(DM,"segmentTemplateLiteralParts");var aU=Bt(e=>new dn(e.enums.map(t=>new Cn(t[1],{title:t[0]})),"anyOf")),FA=ga(e=>{switch(e._tag){default:return e;case"Number":return e.toCodecStringTree();case"Union":return e.recur(FA)}}),zx=ga(e=>{switch(e._tag){default:return e;case"Symbol":case"UniqueSymbol":return e.toCodecStringTree();case"Union":return e.recur(zx)}}),cU=ga(e=>{switch(e._tag){default:return e;case"Number":case"Literal":case"BigInt":return e.toCodecStringTree();case"Union":return e.recur(cU)}}),uU="[\\s\\S]*?",_A=new globalThis.RegExp(`^${Ax}$`),w8=new globalThis.RegExp(`^(?:${Ax}|Infinity|-Infinity|NaN)$`);function zA(e){return ed(_A,{expected:"a string representing a finite number",representation:{id:"effect/schema/isStringFinite",payload:null},toJsonSchema:s(()=>({pattern:_A.source}),"toJsonSchema"),...e})}s(zA,"isStringFinite");var lU=Dr(po,[zA()]),E8=new He(lU,su),I8=new He(new dn([lU,JM],"anyOf"),su),T8="-?\\d+",wA=new globalThis.RegExp(`^${T8}$`);function MA(e){return ed(wA,{expected:"a string representing a bigint",representation:{id:"effect/schema/isStringBigInt",payload:null},toJsonSchema:s(()=>({pattern:wA.source}),"toJsonSchema"),...e})}s(MA,"isStringBigInt");var UA=Dr(po,[MA({expected:"a string representing a bigint"})]),k8=new He(UA,bx),A8="Symbol\\((.*)\\)",EA=new globalThis.RegExp(`^${A8}$`),C8=Dr(po,[GA()]),fU=new He(C8,new Re(xe(e=>globalThis.Symbol.for(EA.exec(e)[1])),An((e,t)=>globalThis.Symbol.keyFor(e)!==void 0?se(globalThis.String(e)):W(new ca({message:"cannot serialize to string, Symbol is not registered"},e,t)))));function GA(e){return ed(EA,{expected:"a string representing a symbol",representation:{id:"effect/schema/isStringSymbol",payload:null},toJsonSchema:s(()=>({pattern:EA.source}),"toJsonSchema"),...e})}s(GA,"isStringSymbol");function Fr(e,t,n,r,o){for(let i=0;i<e.length;i++){let a=e[i];if(a._tag==="FilterGroup"){if(n=Fr(a.checks,t,n,r,o),n&&(o.errors!=="all"||n[n.length-1].filter.aborted))return n}else{let c=a.run(t,r,o);if(c){let l=new ox(a,c,t,o);if(n?n.push(l):n=[l],o.errors!=="all"||a.aborted)return n}}}return n}s(Fr,"collectIssues");function dU(e,t){let n=Fr(e,t,void 0,Qo,{errors:"all"});if(n){let r=new Qe(Qo,n);return ie(r)}return X(t)}s(dU,"runChecks");function pU(e){if(!mo(e))return;let t=e.annotations?.[ex];return Sn(t)?t(e.typeParameters):void 0}s(pU,"getConstructorDescriptor");function O8(e){return e===null||typeof e=="string"||typeof e=="boolean"||typeof e=="number"&&globalThis.Number.isFinite(e)}s(O8,"isJsonLeaf");function R8(e){return e===void 0||typeof e=="string"}s(R8,"isStringTreeLeaf");function mU(e,t){let n=new WeakMap,r=[];e:for(;;){if(typeof e!="object"||e===null){if(!t(e))return!1}else{let o=e,i=n.get(o);if(i===!1)return!1;if(i===void 0){let a=Array.isArray(o);if(!a){let c=Object.getPrototypeOf(o);if(c!==null&&c!==Object.prototype&&Object.getPrototypeOf(c)!==null)return!1}n.set(o,!1),r.push({value:o,keys:a?o.length:Object.keys(o),index:0})}}for(;r.length>0;){let o=r[r.length-1],i=o.keys;if(typeof i=="number"){if(o.index<i){e=o.value[o.index++];continue e}}else if(o.index<i.length){e=o.value[i[o.index++]];continue e}n.set(o.value,!0),r.pop()}return!0}}s(mU,"isTree");function pu(e){return mU(e,O8)}s(pu,"isJson");var uu=new fa([],()=>(e,t,n)=>pu(e)?bt:W(new et(t,e,n)),{representation:{id:"effect/schema/Json",payload:null},expected:"JSON value",toCodecJson:s(()=>{},"toCodecJson"),toCodecStringTree:s(()=>ZA,"toCodecStringTree"),toArbitrary:s(()=>e=>e.jsonValue(),"toArbitrary")}),hU=cr(uu,{representation:{id:"effect/schema/MutableJson",payload:null}}),jA=new He(uu,ou()),gU=new He(new dn([new Nr(!1,[],[uu]),new au([],[new Wf(po,uu)])],"anyOf"),ou());function $8(e){return mU(e,R8)}s($8,"isStringTree");var P8=new fa([],()=>(e,t,n)=>$8(e)?bt:W(new et(t,e,n)),{expected:"StringTree",toCodecStringTree:s(()=>{},"toCodecStringTree")}),ZA=new He(P8,ou());var xU="~effect/collections/Chunk";function N8(e,t,n,r,o){for(let i=t;i<Math.min(e.length,t+o);i++)n[r+i-t]=e[i];return n}s(N8,"copy");var yU=[],BA=s(e=>Tt((t,n)=>t.length===n.length&&od(t).every((r,o)=>e(r,sd(n,o)))),"makeEquivalence"),D8=BA(re),L8={[xU]:{_A:s(e=>e,"_A")},toString(){return`Chunk(${z(od(this))})`},toJSON(){return{_id:"Chunk",values:Vt(od(this))}},[yt](){return this.toJSON()},[ke](e){return Mx(e)&&D8(this,e)},[Te](){return yc(od(this))},[Symbol.iterator](){switch(this.backing._tag){case"IArray":return this.backing.array[Symbol.iterator]();case"IEmpty":return yU[Symbol.iterator]();default:return od(this)[Symbol.iterator]()}},pipe(){return be(this,arguments)}},VA=s(e=>{let t=Object.create(L8);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=ts,t.right=ts;break}case"ISingleton":{t.length=1,t.depth=0,t.left=ts,t.right=ts;break}case"ISlice":{t.length=e.length,t.depth=e.chunk.depth+1,t.left=ts,t.right=ts;break}}return t},"makeChunk"),Mx=s(e=>U(e,xU),"isChunk"),ts=VA({_tag:"IEmpty"}),F8=s(()=>ts,"empty");var z8=s(e=>VA({_tag:"ISingleton",a:e}),"of"),Ux=s(e=>Mx(e)?e:U8(Kt(e)),"fromIterable"),qA=s((e,t,n)=>{switch(e.backing._tag){case"IArray":{N8(e.backing.array,0,t,n,e.length);break}case"IConcat":{qA(e.left,t,n),qA(e.right,t,n+e.left.length);break}case"ISingleton":{t[n]=e.backing.a;break}case"ISlice":{let r=0,o=n;for(;r<e.length;)t[o]=sd(e,r),r+=1,o+=1;break}}},"copyToArray");var M8=s(e=>{switch(e.backing._tag){case"IEmpty":return yU;case"IArray":return e.backing.array;default:{let t=new Array(e.length);return qA(e,t,0),e.backing={_tag:"IArray",array:t},e.left=ts,e.right=ts,e.depth=0,t}}},"toReadonlyArray_"),od=M8;var U8=s(e=>e.length===0?F8():e.length===1?z8(e[0]):VA({_tag:"IArray",array:e}),"fromArrayUnsafe");var sd=y(2,(e,t)=>{let n=Math.floor(t);switch(e.backing._tag){case"IEmpty":throw new Error(`Index out of bounds: ${n}`);case"ISingleton":{if(t!==0)throw new Error(`Index out of bounds: ${n}`);return e.backing.a}case"IArray":{if(n>=e.length||n<0)throw new Error(`Index out of bounds: ${n}`);return e.backing.array[n]}case"IConcat":return n<e.left.length?sd(e.left,n):sd(e.right,n-e.left.length);case"ISlice":return sd(e.backing.chunk,n+e.backing.offset)}});var SU=s(e=>e.length,"size");var vU=LI;var _U=AD;var P={};$t(P,{Any:()=>OY,Array:()=>dt,ArrayEnsure:()=>GY,BigDecimal:()=>UC,BigDecimalFromString:()=>LQ,BigDecimalReviver:()=>DQ,BigInt:()=>go,BigIntFromString:()=>VQ,Boolean:()=>IG,BooleanFromBit:()=>QQ,Cause:()=>fy,CauseReason:()=>ly,CauseReasonReviver:()=>cQ,CauseReviver:()=>uQ,Char:()=>JX,Chunk:()=>Z2,ChunkReviver:()=>SQ,Class:()=>oj,Date:()=>jr,DateFromMillis:()=>IQ,DateFromString:()=>EQ,DateReviver:()=>wQ,DateTimeUtc:()=>Rd,DateTimeUtcFromDate:()=>see,DateTimeUtcFromMillis:()=>aee,DateTimeUtcFromString:()=>iee,DateTimeUtcReviver:()=>oee,DateTimeZoned:()=>VC,DateTimeZonedFromString:()=>mee,DateTimeZonedReviver:()=>pee,Defect:()=>pQ,Duration:()=>Cd,DurationFromMillis:()=>OQ,DurationFromNanos:()=>CQ,DurationFromString:()=>AQ,DurationReviver:()=>TQ,Enum:()=>AY,Error:()=>sj,ErrorInstance:()=>D2,ErrorInstanceReviver:()=>dQ,Exit:()=>L2,ExitReviver:()=>mQ,File:()=>GC,FileReviver:()=>MQ,Finite:()=>Gr,FiniteFromString:()=>BQ,FormData:()=>jC,FormDataReviver:()=>UQ,HashMap:()=>U2,HashMapReviver:()=>gQ,HashSet:()=>j2,HashSetReviver:()=>yQ,Int:()=>Ta,Json:()=>wy,JsonReviver:()=>Qee,Literal:()=>Ye,Literals:()=>xy,MutableJson:()=>xj,MutableJsonReviver:()=>tte,Natural:()=>Vn,Never:()=>CY,NonEmptyArray:()=>UY,NonEmptyString:()=>KX,Null:()=>$e,NullOr:()=>AC,NullishOr:()=>OG,Number:()=>gy,NumberFromString:()=>qQ,ObjectKeyword:()=>$Y,Opaque:()=>tX,Option:()=>ti,OptionFromNullOr:()=>YX,OptionFromNullishOr:()=>QX,OptionFromOptional:()=>tQ,OptionFromOptionalKey:()=>eQ,OptionFromOptionalNullOr:()=>nQ,OptionFromUndefinedOr:()=>XX,OptionReviver:()=>WX,PropertyKey:()=>wC,ReadonlyMap:()=>M2,ReadonlyMapReviver:()=>hQ,ReadonlySet:()=>G2,ReadonlySetReviver:()=>xQ,Record:()=>kG,Redacted:()=>FC,RedactedFromValue:()=>aQ,RedactedReviver:()=>iQ,RegExp:()=>q2,RegExpReviver:()=>bQ,Result:()=>T2,ResultReviver:()=>rQ,SchemaError:()=>Qs,StandardSchemaV1FailureResult:()=>XQ,String:()=>ce,StringFromBase64:()=>KQ,StringFromBase64Url:()=>JQ,StringFromHex:()=>WQ,StringFromUriComponent:()=>YQ,Struct:()=>K,StructWithRest:()=>zY,Symbol:()=>TG,TaggedClass:()=>yee,TaggedError:()=>See,TaggedStruct:()=>Sy,TaggedUnion:()=>eX,TemplateLiteral:()=>TY,TemplateLiteralParser:()=>kY,TimeZone:()=>BC,TimeZoneFromString:()=>dee,TimeZoneNamed:()=>qC,TimeZoneNamedFromString:()=>lee,TimeZoneNamedReviver:()=>uee,TimeZoneOffset:()=>Q2,TimeZoneOffsetReviver:()=>cee,TimeZoneReviver:()=>fee,Tree:()=>Xee,Trim:()=>HQ,Trimmed:()=>Y2,Tuple:()=>vu,TupleWithRest:()=>MY,URL:()=>zC,URLFromString:()=>_Q,URLReviver:()=>vQ,URLSearchParams:()=>ZC,URLSearchParamsReviver:()=>jQ,Uint8Array:()=>Od,Uint8ArrayFromBase64:()=>tee,Uint8ArrayFromBase64Url:()=>nee,Uint8ArrayFromHex:()=>ree,Uint8ArrayReviver:()=>eee,Undefined:()=>TC,UndefinedOr:()=>yy,Union:()=>pt,UniqueArray:()=>jY,UniqueSymbol:()=>PY,Unknown:()=>IC,UnknownFromJsonString:()=>zQ,Void:()=>RY,annotate:()=>tY,annotateEncoded:()=>nY,annotateKey:()=>rY,asserts:()=>aY,brand:()=>$G,catchDecoding:()=>HY,catchDecodingWithContext:()=>DG,catchEncoding:()=>KY,catchEncodingWithContext:()=>LG,check:()=>qY,declare:()=>dr,declareConstructor:()=>Hn,decode:()=>JY,decodeEffect:()=>cY,decodeExit:()=>uY,decodeOption:()=>fY,decodePromise:()=>pY,decodeResult:()=>dY,decodeSync:()=>mY,decodeTo:()=>ae,decodeUnknownEffect:()=>py,decodeUnknownExit:()=>mG,decodeUnknownOption:()=>lY,decodeUnknownPromise:()=>xG,decodeUnknownResult:()=>gG,decodeUnknownSync:()=>yG,encode:()=>WY,encodeEffect:()=>SG,encodeExit:()=>hY,encodeKeys:()=>LY,encodeOption:()=>xY,encodePromise:()=>SY,encodeResult:()=>yY,encodeSync:()=>bY,encodeTo:()=>CC,encodeUnknownEffect:()=>my,encodeUnknownExit:()=>bG,encodeUnknownOption:()=>gY,encodeUnknownPromise:()=>_G,encodeUnknownResult:()=>vG,encodeUnknownSync:()=>wG,extendTo:()=>FY,fieldsAssign:()=>NY,flip:()=>vC,fromBrand:()=>VY,fromFormData:()=>GQ,fromJsonString:()=>W2,fromURLSearchParams:()=>ZQ,instanceOf:()=>ei,is:()=>uG,isBase64:()=>$C,isBase64Reviver:()=>pX,isBase64Url:()=>HG,isBase64UrlReviver:()=>mX,isBetween:()=>by,isBetweenBigDecimal:()=>LX,isBetweenBigInt:()=>g2,isBetweenBigIntReviver:()=>Vee,isBetweenDate:()=>f2,isBetweenDateReviver:()=>Gee,isBetweenReviver:()=>kX,isCapitalized:()=>QG,isCapitalizedReviver:()=>bX,isEndsWith:()=>JG,isEndsWithReviver:()=>gX,isFinite:()=>t2,isFiniteReviver:()=>_X,isGUID:()=>BG,isGUIDReviver:()=>fX,isGreaterThan:()=>r2,isGreaterThanBigDecimal:()=>$X,isGreaterThanBigInt:()=>d2,isGreaterThanBigIntReviver:()=>jee,isGreaterThanDate:()=>a2,isGreaterThanDateReviver:()=>Fee,isGreaterThanOrEqualTo:()=>PC,isGreaterThanOrEqualToBigDecimal:()=>PX,isGreaterThanOrEqualToBigInt:()=>p2,isGreaterThanOrEqualToBigIntReviver:()=>Zee,isGreaterThanOrEqualToDate:()=>c2,isGreaterThanOrEqualToDateReviver:()=>zee,isGreaterThanOrEqualToReviver:()=>EX,isGreaterThanReviver:()=>wX,isIncludes:()=>WG,isIncludesReviver:()=>xX,isInt:()=>Ad,isInt32:()=>OX,isIntReviver:()=>CX,isLengthBetween:()=>DC,isLengthBetweenReviver:()=>MX,isLessThan:()=>o2,isLessThanBigDecimal:()=>NX,isLessThanBigInt:()=>m2,isLessThanBigIntReviver:()=>qee,isLessThanDate:()=>u2,isLessThanDateReviver:()=>Mee,isLessThanOrEqualTo:()=>s2,isLessThanOrEqualToBigDecimal:()=>DX,isLessThanOrEqualToBigInt:()=>h2,isLessThanOrEqualToBigIntReviver:()=>Bee,isLessThanOrEqualToDate:()=>l2,isLessThanOrEqualToDateReviver:()=>Uee,isLessThanOrEqualToReviver:()=>TX,isLessThanReviver:()=>IX,isLowercased:()=>XG,isLowercasedReviver:()=>SX,isMaxLength:()=>y2,isMaxLengthReviver:()=>zX,isMaxProperties:()=>w2,isMaxPropertiesReviver:()=>qX,isMaxSize:()=>b2,isMaxSizeReviver:()=>GX,isMinLength:()=>NC,isMinLengthReviver:()=>FX,isMinProperties:()=>_2,isMinPropertiesReviver:()=>ZX,isMinSize:()=>S2,isMinSizeReviver:()=>UX,isMultipleOf:()=>i2,isMultipleOfReviver:()=>AX,isNonEmpty:()=>x2,isPattern:()=>Ia,isPatternReviver:()=>sX,isPropertiesLengthBetween:()=>E2,isPropertiesLengthBetweenReviver:()=>BX,isPropertyNames:()=>I2,isPropertyNamesReviver:()=>VX,isSchema:()=>hy,isSchemaError:()=>bC,isSizeBetween:()=>v2,isSizeBetweenReviver:()=>jX,isStartsWith:()=>KG,isStartsWithReviver:()=>hX,isStringBigInt:()=>jG,isStringBigIntReviver:()=>aX,isStringFinite:()=>GG,isStringFiniteReviver:()=>iX,isStringSymbol:()=>ZG,isStringSymbolReviver:()=>cX,isTrimmed:()=>RC,isTrimmedReviver:()=>rX,isULID:()=>VG,isULIDReviver:()=>dX,isUUID:()=>qG,isUUIDReviver:()=>lX,isUint32:()=>RX,isUncapitalized:()=>e2,isUncapitalizedReviver:()=>vX,isUnique:()=>LC,isUniqueReviver:()=>HX,isUppercased:()=>YG,isUppercasedReviver:()=>yX,link:()=>qe,make:()=>Z,makeFilter:()=>je,makeFilterGroup:()=>nX,makeIsBetween:()=>kd,makeIsGreaterThan:()=>wd,makeIsGreaterThanOrEqualTo:()=>Ed,makeIsLessThan:()=>Id,makeIsLessThanOrEqualTo:()=>Td,makeIsMultipleOf:()=>n2,middlewareDecoding:()=>PG,middlewareEncoding:()=>NG,mutable:()=>ZY,mutableKey:()=>wY,optional:()=>fr,optionalKey:()=>wa,overrideToCodecIso:()=>Wee,overrideToEquivalence:()=>wee,overrideToFormatter:()=>vee,readonlyKey:()=>EY,refine:()=>BY,required:()=>_Y,requiredKey:()=>vY,resolveAnnotations:()=>nte,resolveAnnotationsKey:()=>rte,revealBottom:()=>eY,revealCodec:()=>oY,suspend:()=>RG,tag:()=>Ea,tagDefaultOmit:()=>QY,toArbitrary:()=>bee,toCodecArrayFromSingle:()=>Cee,toCodecIso:()=>lj,toCodecJson:()=>aj,toCodecJsonAST:()=>_y,toCodecStringTree:()=>dj,toDifferJsonPatch:()=>Yee,toEncoded:()=>Iu,toEncoderXml:()=>Oee,toEquivalence:()=>Eee,toFormatter:()=>_ee,toIso:()=>Hee,toIsoFocus:()=>Jee,toIsoSource:()=>Kee,toJsonSchemaDocument:()=>ij,toRepresentation:()=>Iee,toStandardJSONSchemaV1:()=>iY,toStandardSchemaV1:()=>sY,toTaggedUnion:()=>UG,toType:()=>pn,withConstructorDefault:()=>FG,withDecodingDefault:()=>MG,withDecodingDefaultKey:()=>OC,withDecodingDefaultType:()=>XY,withDecodingDefaultTypeKey:()=>YY});var jx="~effect/collections/HashMap",zr=5,ad=1<<zr,G8=ad/4,EU=ad/2,j8=ad-1,Z8=s(e=>(e=e-(e>>>1&1431655765),e=(e&858993459)+(e>>>2&858993459),(e+(e>>>4)&252645135)*16843009>>>24),"popcount"),id=s((e,t)=>e>>>t&j8,"mask"),Ys=s((e,t)=>1<<id(e,t),"bitpos"),Gx=s((e,t)=>Z8(e&t-1),"index");function IU(e,t,n,r,o,i){if(t>32)throw new Error("HashMap: max depth exceeded");let a=Ys(n,t),c=Ys(o,t);if(a===c){let f=IU(e,t+zr,n,r,o,i);return new Sa(e,a,[f])}let l=a|c,u=a>>>0<c>>>0?[r,i]:[i,r];return new Sa(e,l,u)}s(IU,"mergeLeaves");var xa=class{static{s(this,"Node")}canEdit(t){return this.edit===t}},HA=class extends xa{static{s(this,"EmptyNode")}_tag="EmptyNode";edit=0;get size(){return 0}get(t,n,r){return te()}has(t,n,r){return!1}set(t,n,r,o,i,a){return a.value=!0,new ya(t,r,o,i)}remove(t,n,r,o,i){return this}iterator(){return[][Symbol.iterator]()}[Symbol.iterator](){return this.iterator()}canEdit(t){return!1}},ya=class e extends xa{static{s(this,"LeafNode")}_tag="LeafNode";edit;hash;key;value;constructor(t,n,r,o){super(),this.edit=t,this.hash=n,this.key=r,this.value=o}get size(){return 1}get(t,n,r){return this.hash===n&&re(this.key,r)?H(this.value):te()}has(t,n,r){return this.hash===n&&re(this.key,r)}set(t,n,r,o,i,a){if(this.hash===r&&re(this.key,o))return re(this.value,i)?this:this.canEdit(t)?(this.value=i,this):new e(t,r,o,i);if(a.value=!0,this.hash===r)return new KA(t,r,[[this.key,this.value],[o,i]]);let c=Ys(r,n),l=Ys(this.hash,n);if(c===l)return new Sa(t,c,[this.set(t,n+zr,r,o,i,a)]);let u=c|l,f=c>>>0<l>>>0?[new e(t,r,o,i),this]:[this,new e(t,r,o,i)];return new Sa(t,u,f)}remove(t,n,r,o,i){if(this.hash===r&&re(this.key,o)){i.value=!0;return}return this}iterator(){return[[this.key,this.value]][Symbol.iterator]()}[Symbol.iterator](){return this.iterator()}},KA=class e extends xa{static{s(this,"CollisionNode")}_tag="CollisionNode";edit;hash;entries;constructor(t,n,r){super(),this.edit=t,this.hash=n,this.entries=r}get size(){return this.entries.length}get(t,n,r){if(this.hash!==n)return te();for(let[o,i]of this.entries)if(re(o,r))return H(i);return te()}has(t,n,r){if(this.hash!==n)return!1;for(let[o]of this.entries)if(re(o,r))return!0;return!1}set(t,n,r,o,i,a){if(this.hash!==r)return a.value=!0,IU(t,n,this.hash,this,r,new ya(t,r,o,i));for(let c=0;c<this.entries.length;c++)if(re(this.entries[c][0],o)){if(re(this.entries[c][1],i))return this;if(this.canEdit(t))return this.entries[c]=[o,i],this;let l=[...this.entries];return l[c]=[o,i],new e(t,this.hash,l)}return a.value=!0,this.canEdit(t)?(this.entries.push([o,i]),this):new e(t,this.hash,[...this.entries,[o,i]])}remove(t,n,r,o,i){if(this.hash!==r)return this;let a=this.entries.findIndex(([l])=>re(l,o));if(a===-1)return this;if(i.value=!0,this.entries.length===1)return;if(this.entries.length===2){let l=this.entries[a===0?1:0];return new ya(t,this.hash,l[0],l[1])}if(this.canEdit(t))return this.entries.splice(a,1),this;let c=[...this.entries];return c.splice(a,1),new e(t,this.hash,c)}iterator(){return this.entries[Symbol.iterator]()}[Symbol.iterator](){return this.iterator()}},Sa=class e extends xa{static{s(this,"IndexedNode")}_tag="IndexedNode";edit;_size;bitmap;children;constructor(t,n,r){super(),this.edit=t,this.bitmap=n,this.children=r}get size(){return this._size===void 0&&(this._size=this.children.reduce((t,n)=>t+n.size,0)),this._size}get(t,n,r){let o=Ys(n,t);if((this.bitmap&o)===0)return te();let i=Gx(this.bitmap,o);return this.children[i].get(t+zr,n,r)}has(t,n,r){let o=Ys(n,t);if((this.bitmap&o)===0)return!1;let i=Gx(this.bitmap,o);return this.children[i].has(t+zr,n,r)}set(t,n,r,o,i,a){let c=Ys(r,n),l=Gx(this.bitmap,c);if((this.bitmap&c)!==0){let u=this.children[l],f=u.set(t,n+zr,r,o,i,a);if(u===f)return this;if(this.canEdit(t))return this.children[l]=f,this;let d=[...this.children];return d[l]=f,new e(t,this.bitmap,d)}else{a.value=!0;let u=new ya(t,r,o,i),f=this.bitmap|c;if(this.canEdit(t))return this.children.splice(l,0,u),this.bitmap=f,this._size=void 0,this.children.length>EU?this.expand(t,f,this.children):this;let d=[...this.children];return d.splice(l,0,u),d.length>EU?this.expand(t,f,d):new e(t,f,d)}}remove(t,n,r,o,i){let a=Ys(r,n);if((this.bitmap&a)===0)return this;let c=Gx(this.bitmap,a),l=this.children[c],u=l.remove(t,n+zr,r,o,i);if(!i.value)return this;if(u===void 0){let d=this.bitmap^a;if(d===0)return;if(this.children.length===2){let m=this.children[c===0?1:0];if(m._tag==="LeafNode")return m}if(this.canEdit(t))return this.children.splice(c,1),this.bitmap=d,this._size=void 0,this;let p=[...this.children];return p.splice(c,1),new e(t,d,p)}if(l===u)return this;if(this.canEdit(t))return this.children[c]=u,this;let f=[...this.children];return f[c]=u,new e(t,this.bitmap,f)}expand(t,n,r){let o=new globalThis.Array(ad),i=0;for(let a=0;a<ad;a++)(n&1<<a)!==0&&(o[a]=r[i++]);return new JA(t,r.length,o)}iterator(){let t=0,n;return{next:s(()=>{for(;t<this.children.length;){n||(n=this.children[t].iterator());let r=n.next();if(!r.done)return r;n=void 0,t++}return{done:!0,value:void 0}},"next")}}[Symbol.iterator](){return this.iterator()}},JA=class e extends xa{static{s(this,"ArrayNode")}_tag="ArrayNode";edit;_size;count;children;constructor(t,n,r){super(),this.edit=t,this.count=n,this.children=r}get size(){return this._size===void 0&&(this._size=this.children.reduce((t,n)=>t+(n?.size??0),0)),this._size}get(t,n,r){let o=id(n,t),i=this.children[o];return i?i.get(t+zr,n,r):te()}has(t,n,r){let o=id(n,t),i=this.children[o];return i?i.has(t+zr,n,r):!1}set(t,n,r,o,i,a){let c=id(r,n),l=this.children[c];if(l){let u=l.set(t,n+zr,r,o,i,a);if(l===u)return this;if(this.canEdit(t))return this.children[c]=u,this;let f=[...this.children];return f[c]=u,new e(t,this.count,f)}else{a.value=!0;let u=new ya(t,r,o,i);if(this.canEdit(t))return this.children[c]=u,this.count++,this._size=void 0,this;let f=[...this.children];return f[c]=u,new e(t,this.count+1,f)}}remove(t,n,r,o,i){let a=id(r,n),c=this.children[a];if(!c)return this;let l=c.remove(t,n+zr,r,o,i);if(!i.value)return this;let u=this.count-(l?0:1);if(u<G8)return this.pack(t,a,l);if(c===l)return this;if(this.canEdit(t))return this.children[a]=l,l||(this.count=u),this._size=void 0,this;let f=[...this.children];return f[a]=l,new e(t,u,f)}pack(t,n,r){let o=[],i=0,a=1;for(let c=0;c<this.children.length;c++){let l=c===n?r:this.children[c];l&&(o.push(l),i|=a),a<<=1}return new Sa(t,i,o)}iterator(){let t=0,n;return{next:s(()=>{for(;t<this.children.length;){let r=this.children[t];if(!r){t++;continue}n||(n=r.iterator());let o=n.next();if(!o.done)return o;n=void 0,t++}return{done:!0,value:void 0}},"next")}}[Symbol.iterator](){return this.iterator()}},cd=class{static{s(this,"HashMapImpl")}[jx]=jx;_editable;_edit;_root;_size;constructor(t,n,r,o){this._editable=t,this._edit=n,this._root=r,this._size=o}get size(){return this._size}[Symbol.iterator](){return this._root.iterator()}[ke](t){if(WA(t)){let n=t;if(this.size!==n.size)return!1;for(let[r,o]of this){let i=uE(t,AU(r));if(Xe(i)||!re(o,i.value))return!1}return!0}return!1}[Te](){let t=Be("HashMap");for(let[n,r]of this)t=t^pe(n)+pe(r);return t}[yt](){return Vt(this)}toString(){return`HashMap(${z(Array.from(this))})`}toJSON(){return{_id:"HashMap",values:Array.from(this).map(([t,n])=>[Vt(t),Vt(n)])}}pipe(){return be(this,arguments)}},TU=new HA,WA=s(e=>U(e,jx),"isHashMap"),YA=s(()=>new cd(!1,0,TU,0),"empty");var kU=s(e=>{let t=TU,n=0,r={value:!1};for(let[o,i]of e){let a=pe(o);r.value=!1,t=t.set(NaN,0,a,o,i,r),r.value&&n++}return new cd(!1,0,t,n)},"fromIterable");var AU=y(2,(e,t)=>e._root.get(0,pe(t),t));var XA=y(2,(e,t)=>e._root.has(0,pe(t),t));var q8=s((e,t,n,r)=>{let o=e,i={value:!1},a=o._editable?o._edit:NaN,c=o._root.set(a,0,n,t,r,i);return o._editable?(o._root=c,i.value&&o._size++,e):o._root===c?e:new cd(!1,o._edit,c,o._size+(i.value?1:0))},"setHash"),QA=y(3,(e,t,n)=>q8(e,t,pe(t),n)),eC=s(e=>{let t=e[Symbol.iterator]();return{[Symbol.iterator](){return this},next(){let n=t.next();return n.done?{done:!0,value:void 0}:{done:!1,value:n.value[0]}}}},"keys");var CU=s(e=>{let t=e[Symbol.iterator]();return{[Symbol.iterator](){return this},next(){return t.next()}}},"entries"),Zx=s(e=>e.size,"size");var RU=WA;var qx=kU;var H8=CU,Bx=s(e=>Array.from(H8(e)),"toEntries"),$U=Zx;var ud="~effect/collections/HashSet",K8={[Te](){return pe(ud)},[ke](e){return tC(e)&&Vx(this)===Vx(e)&&LU(this,t=>DU(e,t))},[Symbol.iterator](){return eC(nC(this))},toString(){return`HashSet(${z(Array.from(this))})`},toJSON(){return{_id:"HashSet",values:Vt(Array.from(this))}},[yt](){return this.toJSON()},pipe(){return be(this,arguments)}},J8=s(e=>{let t=Object.create(K8);return t[ud]=ud,t.keyMap=e,t},"makeImpl"),tC=s(e=>U(e,ud),"isHashSet"),nC=s(e=>e.keyMap,"keyMap");var NU=s(e=>{let t=YA();for(let n of e)t=QA(t,n,!0);return J8(t)},"fromIterable"),DU=s((e,t)=>XA(nC(e),t),"has");var Vx=s(e=>Zx(nC(e)),"size");var LU=s((e,t)=>{for(let n of e)if(!t(n))return!1;return!0},"every");var Hx=NU,FU=tC;var zU=Vx;function Kx(e){let t=YU(Wx,jt(e.ast));return(n,r)=>t(n,r?.disableChecks?r?.parseOptions?{...r.parseOptions,disableChecks:!0}:{disableChecks:!0}:r?.parseOptions)}s(Kx,"makeEffect");function Jx(e){let t=Kx(e);return(n,r)=>{let o=uo(t(n,r));return Jt(o)?H(o.value):(Jo(o.cause,"Option adapter can only return none for schema issues"),te())}}s(Jx,"makeOption");function GU(e){let t=Kx(e);return(n,r)=>{let o=uo(t(n,r));if(Jt(o))return o.value;let i=Jo(o.cause,"Constructor adapter can only throw schema issues");throw new Error("Schema validation failed",{cause:i})}}s(GU,"make");function jU(e){return fd(e.ast)}s(jU,"is");function fd(e){let t=ba(dd(jt(e)));return n=>{let r=t(n,ma);return Jt(r)?!0:(Jo(r.cause,"Type guard adapter can only return false for schema issues"),!1)}}s(fd,"_is");function ZU(e){let t=dd(e);return(n,r)=>{let o=uo(t(n,r));if(!Jt(o))return Jo(o.cause,"Issue adapter can only return schema issues")}}s(ZU,"_issue");function qU(e,t){let r=ba(dd(jt(e.ast)))(t,ma);if(cL(r)){let o=Jo(r.cause,"Assertion adapter can only throw schema issues");throw new Error("Schema validation failed",{cause:o})}}s(qU,"asserts");function ut(e,t){let n=dd(e.ast);return t===void 0?n:(r,o)=>n(r,ld(t,o))}s(ut,"decodeUnknownEffect");var rC=ut;function BU(e,t){return ba(ut(e,t))}s(BU,"decodeUnknownExit");function oC(e,t){return XU(ut(e,t))}s(oC,"decodeUnknownOption");var VU=oC;function HU(e,t){return QU(ut(e,t))}s(HU,"decodeUnknownResult");function Y8(e,t){return e1(ut(e,t))}s(Y8,"decodeUnknownSync");var sC=Y8;function mu(e,t){let n=dd(Pr(e.ast));return t===void 0?n:(r,o)=>n(r,ld(t,o))}s(mu,"encodeUnknownEffect");function KU(e,t){return ba(mu(e,t))}s(KU,"encodeUnknownExit");function iC(e,t){return XU(mu(e,t))}s(iC,"encodeUnknownOption");var JU=iC;function WU(e,t){return QU(mu(e,t))}s(WU,"encodeUnknownResult");function X8(e,t){return e1(mu(e,t))}s(X8,"encodeUnknownSync");var aC=X8,ld=s((e,t)=>t?{...e,...t}:e,"mergeParseOptions"),UU=s(e=>e===Oe?W(new Ee):se(e),"getValue");function dd(e){return YU(t1,e)}s(dd,"run");function YU(e,t){let n;return(r,o)=>{let i=(n??=e(t))(r,o??ma);return i===bt?se(r):Ve(i)?i[ee]===Oe?UU(Oe):i:qn(i,UU)}}s(YU,"runWithCompiler");function ba(e){return(t,n)=>uo(e(t,n))}s(ba,"asExit");function XU(e){let t=ba(e);return(n,r)=>{let o=t(n,r);return Jt(o)?H(o.value):(Jo(o.cause,"Option adapter can only return none for schema issues"),te())}}s(XU,"asOption");function QU(e){let t=ba(e);return(n,r)=>{let o=t(n,r);return Jt(o)?X(o.value):ie(Jo(o.cause,"Result adapter can only return schema issues"))}}s(QU,"asResult");function e1(e){let t=ba(e);return(n,r)=>{let o=t(n,r);if(Jt(o))return o.value;let i=Jo(o.cause,"Sync adapter can only throw schema issues");throw new Error("Schema validation failed",{cause:i})}}s(e1,"asSync");var t1=Bt(e=>cC(e,t1)),Wx=Bt(e=>cC(e,Wx,n1)),Q8=Bt(e=>cC(e,Wx,n1,e.context?.constructorDefault));function n1(e){return e.context?.constructorDefault?Q8(e):Wx(e)}s(n1,"compileConstructorDefault");function r1(e,t,n,r){let o;if(Ve(e)&&e._tag==="Success"){let i=nx(e===bt?t:e[ee]);o=n._tag==="Transformation"?n.decode.run(i,r):n.decode(lo(i),r)}else n._tag==="Transformation"?o=qn(e,i=>n.decode.run(nx(i),r)):o=n.decode(ra(e,nx),r);return Ve(o)&&o._tag==="Success"?wk(o[ee]):qn(o,wk)}s(r1,"applyTransformation");function e7(e,t){let n;return(r,o)=>{if(r===Oe)return fo;if(e.isConstructed(r))return bt;let i=(n??=t(e.link.to))(r,o);return r1(i,r,e.link.transformation,o)}}s(e7,"makeConstructorParser");function cC(e,t,n,r){let o=n?pU(e):void 0,i=o?e7(o,t):e.getParser(t,n),a=e.checks,c=r?e.encoding?[...e.encoding,r]:[r]:e.encoding,l=e.encodingChecks,u=(a?a[a.length-1].annotations:e.annotations)?.parseOptions;if(!c&&!a&&!l)return u?(p,m)=>i(p,ld(m,u)):i;let f,d=s((p,m)=>{let h=i(p,m);if(l&&!m.disableChecks)if(Ve(h)){if(h._tag==="Success"){let x=h===bt?p:h[ee];if(p!==Oe&&x!==Oe){let S=Fr(l,p,void 0,e,m);S&&(h=W(new Qe(e,S,p,m)))}}}else h=In(h,x=>{if(p!==Oe&&x!==Oe){let S=Fr(l,p,void 0,e,m);if(S)return W(new Qe(e,S,p,m))}return se(x)});if(a&&!m.disableChecks)if(Ve(h)){if(h._tag==="Success"){let x=h===bt?p:h[ee];if(x===Oe)return h;let S=Fr(a,x,void 0,e,m);S&&(h=W(new Qe(e,S,x,m)))}}else h=In(h,x=>{if(x!==Oe){let S=Fr(a,x,void 0,e,m);if(S)return W(new Qe(e,S,x,m))}return se(x)});return h},"parseLocal");return c?(p,m)=>{u&&(m=ld(m,u));let h=f??=c.map(T=>t(T.to)),x=p,S=h[h.length-1](p,m);for(let T=c.length-1;T>=0;T--)if(S=r1(S,x,c[T].transformation,m),T!==0){let b=h[T-1];S._tag==="Success"?(x=S[ee],S=b(x,m)):S=qn(S,v=>{let C=b(v,m);return C===bt?lo(v):C})}if(S._tag==="Success"){let T=S[ee],b=d(T,m);return b===bt?S:b}return S=Hs(S,T=>Yc(()=>Gs(T,b=>new sx(e,b,p,m)))),qn(S,T=>{let b=d(T,m);return b===bt?lo(T):b})}:u?(p,m)=>d(p,ld(m,u)):d}s(cC,"makeParser");var Xx="~effect/Schema/Schema";function Rn(e,t,n){return{id:e,payloadSchema:t,revive:n}}s(Rn,"makeDeclarationReviver");function le(e,t,n){return{id:e,payloadSchema:t,revive:n}}s(le,"makeFilterReviver");var t7={[Xx]:Xx,pipe(){return be(this,arguments)},annotate(e){return this.rebuild(cr(this.ast,e))},annotateKey(e){return this.rebuild(rd(this.ast,e))},check(...e){return this.rebuild(Dr(this.ast,e))}};function pd(e,t){function n(){}s(n,"Schema");let r=Object.defineProperties(Object.setPrototypeOf(n,t7),Object.getOwnPropertyDescriptors({...t}));return r.ast=e,r.rebuild=o=>pd(o,t),r.makeEffect=Kx(r),r.make=GU(r),r.makeOption=Jx(r),r}s(pd,"make");var o1=y(2,(e,t)=>lC(e,(n,r)=>t.includes(n)?[n,r]:void 0)),s1=y(2,(e,t)=>lC(e,(n,r)=>t.includes(n)?void 0:[n,r])),i1=y(2,(e,t)=>({...e,...t}));var uC=y(2,(e,t)=>lC(e,(n,r)=>[Object.hasOwn(t,n)?t[n]:n,r]));var Wt=s(e=>e,"lambda");function lC(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[i,a]=o;V(n,i,a)}}return n}s(lC,"buildStruct");function a1(e,t){let n=t?.omitKeyWhen??(()=>!1);return rh((r,o)=>{let i=Reflect.ownKeys(e),a={};for(let c of i){let l=e[c].combine(r[c],o[c]);n(l)||V(a,c,l)}return a})}s(a1,"makeCombiner");function md(e){return vr((t,n)=>t===void 0?n:n===void 0?t:e.combine(t,n),void 0)}s(md,"makeReducer");function ho(e,t){return t.length>0&&(e+=`
|
|
93
|
+
at ${sh(t)}`),new Error(e)}s(ho,"errorWithPath");var u1=new WeakMap,l1=new WeakMap,f1=[];function ns(e){return new Error(`Unable to derive an arbitrary for ${e}`)}s(ns,"arbitraryError");var d1=s(([e],[t])=>re(e,t),"entryComparator");function r7(e,t,n){return t.reduce((r,o)=>r.filter(i=>o.run(i,e,ma)===void 0),n)}s(r7,"applyChecks");function _1(e,t){if(e?.minLength!==void 0&&e.maxLength!==void 0&&e.minLength>e.maxLength)throw ns(`${t} constraints`)}s(_1,"validateArrayConstraints");function w1(e){return e===void 0||e.minLength===void 0&&e.maxLength===void 0?void 0:{...e.minLength!==void 0?{minLength:e.minLength}:{},...e.maxLength!==void 0?{maxLength:e.maxLength}:{}}}s(w1,"lengthToFastCheckConstraints");function fC(e,t,n,r){return r?e.uniqueArray(t,{...n,comparator:r}):e.array(t,n)}s(fC,"arrayWithConstraints");function p1(e,t,n,r=!1){let o=t.constraint,i=w1(o);return _1(i,"array"),fC(e,n,r?{...i,maxLength:i?.minLength??0}:i,o?.unique?re:void 0)}s(p1,"array");function ey(e,t,n,r){return t.chain(o=>o.length<n?e.constant(o):r.map(i=>[...o,...i]))}s(ey,"appendArray");function m1(e,t){return e.chain(n=>t.map(r=>({...Object.fromEntries(r),...n})))}s(m1,"appendObjectEntries");var o7=md(NF),s7=md(DF),ty=md(q$),i7=md(D$()),a7=a1({integer:ty,maxLength:s7,minLength:o7,noInfinity:ty,noNaN:ty,patterns:i7,unique:ty},{omitKeyWhen:HR});function h1(e,t,n,r,o,i){if(r===void 0||t===void 0)return r===void 0?[t,n]:[r,o];let a=e(t,r);return a===i?[r,o]:a===0?[t,n||o]:[t,n]}s(h1,"mergeOrderedBound");function c7(e,t){if(e===void 0)return t;if(e.order!==t.order)throw new Error("Cannot merge ordered arbitrary constraints with different Order instances");let[n,r]=h1(e.order,e.minimum,e.exclusiveMinimum,t.minimum,t.exclusiveMinimum,-1),[o,i]=h1(e.order,e.maximum,e.exclusiveMaximum,t.maximum,t.exclusiveMaximum,1);return{order:e.order,...n!==void 0?{minimum:n}:{},...r!==void 0?{exclusiveMinimum:r}:{},...o!==void 0?{maximum:o}:{},...i!==void 0?{exclusiveMaximum:i}:{}}}s(c7,"mergeOrderedConstraints");function u7(e,t){let{ordered:n,...r}=e??{},{ordered:o,...i}=t,a=o===void 0?n:c7(n,o);return{...a7.combine(r,i),...a===void 0?{}:{ordered:a}}}s(u7,"mergeConstraint");function g1(e){let t=[],n=[];function r(o){if(o.annotations?.arbitrary&&n.push(o.annotations.arbitrary),o._tag!=="Filter")for(let i of o.checks)r(i);else t.push(o)}return s(r,"visit"),e?.forEach(r),{filters:t,arbitraries:n}}s(g1,"collectChecks");function l7(e){let t=e.map(({constraint:n})=>n).filter(rn);return n=>{let r=t.reduce((o,i)=>u7(o,i),n.constraint);return{...n,constraint:r}}}s(l7,"constraintContext");function hd(e){return{...e,constraint:void 0}}s(hd,"resetContext");function x1(e,t,n){if(t===void 0||t.minLength===void 0&&t.maxLength===void 0)return;if(t.minLength!==void 0&&e.indexSignatures.length===0&&t.minLength>e.propertySignatures.length)throw ns("object property constraints");let r={};if(t.minLength!==void 0&&(r.minLength=Math.max(0,t.minLength-n)),t.maxLength!==void 0&&(r.maxLength=t.maxLength-n,r.maxLength<0))throw ns("object property constraints");return _1(r,"object property"),r}s(x1,"objectEntriesConstraints");function f7(e,t,n,r,o,i){let a=r.length;if(i.maxLength!==void 0&&i.maxLength<a)throw ns("object property constraints");let c=i.minLength===void 0?0:Math.max(0,i.minLength-a),l=i.maxLength===void 0?o.length:Math.min(o.length,i.maxLength-a);if(c>l)throw ns("object property constraints");let u=e.record(t,{requiredKeys:[...r,...o]}),f=e.shuffledSubarray([...o],{minLength:c,maxLength:l});return e.tuple(u,f).map(([d,p])=>{let m=new Set([...r,...p]),h={};for(let x of n)m.has(x)&&V(h,x,d[x]);return h})}s(f7,"objectWithOptionalCount");function E1(e,t,n,r){let o={};if(e?.minimum!==void 0&&(o.min=t(e.minimum,e.exclusiveMinimum===!0)),e?.maximum!==void 0&&(o.max=n(e.maximum,e.exclusiveMaximum===!0)),o.min!==void 0&&o.max!==void 0&&o.min>o.max)throw ns(r);return o}s(E1,"toRangeConstraints");function d7(e){return E1(e,(t,n)=>n?Math.floor(t)+1:Math.ceil(t),(t,n)=>n?Math.ceil(t)-1:Math.floor(t),"integer constraints")}s(d7,"toIntegerConstraints");function p7(e,t){let n={...e?.noInfinity?{noDefaultInfinity:!0}:{},...e?.noNaN?{noNaN:!0}:{},...t?.minimum!==void 0?{min:t.minimum}:{},...t?.exclusiveMinimum!==void 0?{minExcluded:t.exclusiveMinimum}:{},...t?.maximum!==void 0?{max:t.maximum}:{},...t?.exclusiveMaximum!==void 0?{maxExcluded:t.exclusiveMaximum}:{}};if(n.min!==void 0&&n.max!==void 0&&(n.min>n.max||n.min===n.max&&(n.minExcluded||n.maxExcluded)))throw ns("number constraints");return n}s(p7,"toFloatConstraints");function m7(e){return E1(e,(t,n)=>n?t+BigInt(1):t,(t,n)=>n?t-BigInt(1):t,"the ordered bigint constraints")}s(m7,"toBigIntConstraints");function hu(e,t){let n=s((r,o,i=f1)=>e(r,o,i),"out");return n.terminal=(r,o,i=f1)=>t(r,o,i),n}s(hu,"makeLazy");function ur(e){return hu(e,e)}s(ur,"same");function y1(e,t){let n=l1.get(t)??e.createDepthIdentifier();return l1.set(t,n),{maxDepth:2,depthIdentifier:n}}s(y1,"getSuspendRecursion");function S1(e,t){return t.length===0?void 0:t.length===1?t[0]:e.oneof(...t)}s(S1,"oneOf");var h7={noInfinity:!0,noNaN:!0};function g7(e){return{...e,constraint:h7}}s(g7,"finiteNumberContext");function x7(e,t,n,r){let o=r===void 0?[]:[{arbitrary:r,weight:1}];for(let{candidate:i}of n){if(!i)continue;let a=i.make(e,t);if(a===void 0)continue;let c=i.weight??1;if(!globalThis.Number.isInteger(c)||c<=0)throw ns("a candidate with an invalid weight");o.push({arbitrary:a,weight:c})}return o.length===0?void 0:o.length===1?o[0].arbitrary:e.oneof(...o)}s(x7,"applyCandidates");function b1(e,t,n,r,o){let i=x7(n,r,t.arbitraries,o);return i===void 0?void 0:r7(e,t.filters,i)}s(b1,"applyFilterLayer");function y7(e,t){if(!(typeof e=="object"&&e!==null&&"arbitrary"in e))return{arbitrary:e,terminal:t?void 0:e};let n="terminal"in e?e.terminal:t?void 0:e.arbitrary;return{arbitrary:e.arbitrary,terminal:n}}s(y7,"normalizeDerivation");function S7(e,t,n,r,o){return e.map(i=>({arbitrary:o?t.constant(null).chain(()=>i(t,n,r)):i(t,n,r),terminal:i.terminal(t,n,r)}))}s(S7,"makeTypeParameters");function v1(e,t,n,r){let o=l7(t.arbitraries);return hu((i,a,c)=>{let l=o(a);return b1(e,t,i,l,n(i,a,l,c))},(i,a,c)=>{let l=o(a);return b1(e,t,i,l,r(i,a,l,c))})}s(v1,"filterLayer");var I1=Bt(e=>lr(e,[]));function lr(e,t){let n=Ho(e)?.toArbitrary;if(n){let r=mo(e)?e.typeParameters.map(a=>lr(a,t)):[],o=g1(e.checks),i=s(a=>(c,l,u,f)=>y7(n(S7(r,c,hd(l),f,a))(c,u),r.length>0)[a?"terminal":"arbitrary"],"derive");return v1(e,o,i(!1),i(!0))}if(e.checks){let r=g1(e.checks),o=lr(Nx(e,void 0),t);return v1(e,r,(i,a,c,l)=>o(i,c,l),(i,a,c,l)=>o.terminal(i,c,l))}return b7(e,t)}s(lr,"recur");function b7(e,t){switch(e._tag){case"Never":case"Declaration":throw ho(`Unsupported AST ${e._tag}`,t);case"Null":return ur(n=>n.constant(null));case"Void":case"Undefined":return ur(n=>n.constant(void 0));case"Unknown":case"Any":return ur(n=>n.anything());case"String":return ur((n,r)=>{let o=r.constraint,i=o?.patterns;return i?n.oneof(...i.map(a=>n.stringMatching(new RegExp(a)))):n.string(w1(o))});case"Number":return ur((n,r)=>{let o=r.constraint,i=o?.ordered?.order===Ln?o.ordered:void 0;return o?.integer?n.integer(d7(i)):n.float(p7(o,i))});case"Boolean":return ur(n=>n.boolean());case"BigInt":return ur((n,r)=>{let o=r.constraint?.ordered?.order===er?r.constraint.ordered:void 0;return n.bigInt(m7(o))});case"Symbol":return ur(n=>n.string().map(Symbol.for));case"Literal":return ur(n=>n.constant(e.literal));case"UniqueSymbol":return ur(n=>n.constant(e.symbol));case"ObjectKeyword":return ur(n=>n.oneof(n.object(),n.array(n.anything())));case"Enum":return lr(aU(e),t);case"TemplateLiteral":{let n=e.parts.map((r,o)=>lr(On(r),[...t,o]));return ur((r,o,i)=>r.tuple(...n.map(a=>a(r,g7(o),i))).map(a=>a.map(c=>globalThis.String(c)).join("")))}case"Arrays":{let n=e.elements.map((a,c)=>({ast:a,arbitrary:lr(a,[...t,c])})),r=e.elements.length,o=e.rest.map((a,c)=>({ast:a,arbitrary:lr(a,[...t,r+c])})),i=s((a,c,l)=>{let u=hd(c),f=[],d=[],p=0;for(let b of n){let v=b.arbitrary.terminal(a,u,l);if(it(b.ast)){d.push(v);continue}if(v===void 0)return;p++,f.push(v.map(H))}let m=c.constraint?.minLength??0,x=Rs(o)&&m>p+d.length?d.length:Math.max(0,m-p),S=0;for(let b of d){if(S>=x||b===void 0){f.push(a.constant(te()));continue}S++,p++,f.push(b.map(H))}if(S<x)return;let T=a.tuple(...f).map(ME);if(Rs(o)){let[b,...v]=o,C=e.elements.length===0?c:u,w=Math.max(0,m-p-v.length),I=w===0?void 0:b.arbitrary.terminal(a,u,l);if(w>0&&I===void 0)return;let A=w===0?a.constant([]):p1(a,{...C,constraint:{...C.constraint,minLength:w}},I,!0);if(T=ey(a,T,r,A),v.length>0){let O=[];for(let q of v){let Q=q.arbitrary.terminal(a,u,l);if(Q===void 0)return;O.push(Q)}let L=a.tuple(...O);T=ey(a,T,r,L)}}return T},"terminal");return hu((a,c,l)=>{let u=hd(c),f=n.map(({ast:p,arbitrary:m})=>{let h=m(a,u,l);return it(p)?h.chain(x=>a.boolean().map(S=>S?H(x):te())):h.map(H)}),d=a.tuple(...f).map(p=>ME(N$(p,an)));if(Rs(o)){let[p,...m]=o.map(({arbitrary:x})=>x(a,u,l)),h=p1(a,e.elements.length===0?c:u,p);if(d=ey(a,d,r,h),m.length>0){let x=a.tuple(...m);d=ey(a,d,r,x)}}if(c.recursion){let p=i(a,c,l);if(p!==void 0)return a.oneof(c.recursion,p,d)}return d},i)}case"Objects":{let n=e.propertySignatures.map(i=>({ps:i,arbitrary:lr(i.type,[...t,i.name])})),r=e.indexSignatures.map(i=>({is:i,parameter:lr(i.parameter,t),type:lr(i.type,t)}));return hu((i,a,c)=>{let l=hd(a),u={},f=[],d=[],p=[];for(let{ps:S,arbitrary:T}of n){let b=S.name;f.push(b),it(S.type)?p.push(b):d.push(b),V(u,b,T(i,l,c))}let m=a.constraint;if(p.length>0&&r.length===0&&m!==void 0&&(m.minLength!==void 0||m.maxLength!==void 0))return f7(i,u,f,d,p,m);let h=i.record(u,{requiredKeys:d}),x=x1(e,a.constraint,d.length);for(let{parameter:S,type:T}of r){let b=i.tuple(S(i,l,c),T(i,l,c)),v=fC(i,b,x,d1);h=m1(h,v)}return h},s((i,a,c)=>{let l=hd(a),u={},f=[],d=[];for(let{ps:S,arbitrary:T}of n){let b=S.name,v=T.terminal(i,l,c);if(it(S.type)){v!==void 0&&d.push([b,v]);continue}if(v===void 0)return;f.push(b),V(u,b,v)}let p=Math.max(0,(a.constraint?.minLength??0)-f.length);for(let[S,T]of d){if(p===0)break;p--,f.push(S),V(u,S,T)}if(p>0&&e.indexSignatures.length===0)return;let m=i.record(u,{requiredKeys:f}),h=x1(e,a.constraint,f.length),x=h?.minLength??0;for(let{parameter:S,type:T}of r){let b;if(x===0)b=i.constant([]);else{let v=S.terminal(i,l,c),C=T.terminal(i,l,c);if(v===void 0||C===void 0)return;b=fC(i,i.tuple(v,C),{...h,maxLength:x},d1)}m=m1(m,b)}return m},"terminal"))}case"Union":{let n=e.types.map(o=>lr(o,t)),r=s((o,i,a)=>S1(o,n.map(c=>c.terminal(o,i,a)).filter(rn)),"terminal");return hu((o,i,a)=>{let c=n.map(u=>u(o,i,a));if(i.recursion){let u=r(o,i,a);if(u!==void 0)return o.oneof(i.recursion,u,...c)}let l=S1(o,c);if(l===void 0)throw ns("a union with no members");return l},r)}case"Suspend":{let n=u1.get(e);if(n)return n;let r=ha(()=>lr(e.thunk(),t)),o=hu((i,a,c)=>{let l=y1(i,e),u={...a,recursion:l},f=c.includes(e)?c:[...c,e],d=r().terminal(i,u,f);if(d===void 0)throw ho("Unable to derive an arbitrary for a recursive schema without a finite generation path",t);return i.oneof(l,d,i.constant(null).chain(()=>r()(i,u,f)))},(i,a,c)=>{if(c.includes(e))return;let l=y1(i,e);return r().terminal(i,{...a,recursion:l},[...c,e])});return u1.set(e,o),o}}}s(b7,"base");var T1=Bt(e=>Xs(e,[]));function Xs(e,t){let n=Ho(e)?.toEquivalence;if(n)return n(mo(e)?e.typeParameters.map(r=>Xs(r,t)):[]);switch(e._tag){case"Never":return QR();case"Declaration":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 re;case"Arrays":{let r=e.elements.map((a,c)=>Xs(a,[...t,c])),o=e.elements.length,i=e.rest.map((a,c)=>Xs(a,[...t,o+c]));return Tt((a,c)=>{if(!Array.isArray(a)||!Array.isArray(c))return!1;let l=a.length;if(l!==c.length)return!1;let u=0;for(;u<Math.min(l,e.elements.length);u++)if(!r[u](a[u],c[u]))return!1;if(i.length>0){let[f,...d]=i;for(;u<l-d.length;u++)if(!f(a[u],c[u]))return!1;for(let p=0;p<d.length;p++)if(!d[p](a[u+p],c[u+p]))return!1}return!0})}case"Objects":{if(e.propertySignatures.length===0&&e.indexSignatures.length===0)return re;let r=e.propertySignatures.map(i=>Xs(i.type,[...t,i.name])),o=e.indexSignatures.map(i=>Xs(i.type,t));return Tt((i,a)=>{if(!Sr(i)||!Sr(a))return!1;for(let c=0;c<r.length;c++){let l=e.propertySignatures[c],u=l.name,f=Object.hasOwn(i,u),d=Object.hasOwn(a,u);if(it(l.type)&&f!==d||f&&d&&!r[c](i[u],a[u]))return!1}for(let c=0;c<o.length;c++){let l=e.indexSignatures[c],u=da(i,l.parameter),f=da(a,l.parameter);if(u.length!==f.length)return!1;for(let d=0;d<u.length;d++){let p=u[d];if(!Object.hasOwn(a,p)||!o[c](i[p],a[p]))return!1}}return!0})}case"Union":{let r=jt(e).types,o=new Map(r.map((i,a)=>[i,[fd(i),Xs(e.types[a],t)]]));return Tt((i,a)=>{let c=Qf(i,r);for(let l=0;l<c.length;l++){let[u,f]=o.get(c[l]);if(u(i)&&u(a))return f(i,a)}return!1})}case"Suspend":{let r=ha(()=>Xs(e.thunk(),t));return Tt((o,i)=>r()(o,i))}}}s(Xs,"recur");function gd(e){return e.replace(/~/g,"~0").replace(/\//g,"~1")}s(gd,"escapeToken");function ny(e){return e.replace(/~1/g,"/").replace(/~0/g,"~")}s(ny,"unescapeToken");var E7=/^#\/\$defs(?=\/|$)/;var I7=new Set(["$ref","type","required","enum","title","description","default","format","pattern","minLength","maxLength","minItems","maxItems","minProperties","maxProperties","multipleOf","uniqueItems"]),T7=new Set([...I7,"const","examples","readOnly","writeOnly","minimum","maximum","exclusiveMinimum","exclusiveMaximum"]);var k7=new Set(["not","additionalProperties","propertyNames"]),A7=new Set(["properties","patternProperties"]),C7=new Set(["allOf","anyOf","oneOf"]);function A1(e){return{dialect:"draft-07",schema:k1(e.schema),definitions:Wl(e.definitions,k1)}}s(A1,"toDocumentDraft07");function k1(e){return C1(e,t=>{R1(t,a=>a.replace(E7,"#/definitions"));let n={},r,o;for(let a of Object.keys(t)){let c=t[a];if(!(a==="required"&&Array.isArray(c)&&c.length===0)){if(T7.has(a)){n[a]=c;continue}if(A7.has(a)||C7.has(a)||k7.has(a)){n[a]=c;continue}switch(a){case"prefixItems":r=c;break;case"items":o=c;break;default:break}}}r!==void 0?Array.isArray(r)?(n.items=r,o!==void 0&&(n.additionalItems=o)):n.items=r:o!==void 0&&(n.items=o);let i=n.$ref;return typeof i=="string"&&Object.keys(n).length>1&&(delete n.$ref,n.allOf=[{$ref:i},...Array.isArray(n.allOf)?n.allOf:[]]),n})}s(k1,"toSchemaDraft07");function C1(e,t){return n(e);function n(r){if(!Sr(r))return r;let o={};for(let i of Object.keys(r)){let a=r[i],c=a;switch(i){case"$defs":case"properties":case"patternProperties":case"dependentSchemas":c=O7(a,n)??a;break;case"allOf":case"anyOf":case"oneOf":case"prefixItems":c=Array.isArray(a)?a.map(n):a;break;case"not":case"additionalProperties":case"propertyNames":case"unevaluatedProperties":case"items":case"contains":case"unevaluatedItems":case"if":case"then":case"else":case"contentSchema":c=n(a)}V(o,i,c)}return t(o)}}s(C1,"transformSchema");function O1(e,t){return C1(e,n=>R1(n,t))}s(O1,"rewriteRefs");function R1(e,t){return typeof e.$ref=="string"&&V(e,"$ref",t(e.$ref)),e}s(R1,"rewriteSchemaRef");function O7(e,t){return Sr(e)?Wl(e,t):void 0}s(O7,"mapObject");var ule=globalThis.RegExp;var gu=s(e=>e.replace(/[/\\^$*+?.()|[\]{}]/g,"\\$&"),"escape");var R7=new Set([...hz,oa,...pz]),P1={isAnonymousReferenceAllowed:s(e=>!mo(e),"isAnonymousReferenceAllowed")};function xd(e,t){if(e===void 0)return;let n={},r=e.title;typeof r=="string"&&(n.title=r);let o=e.description,i=e.expected;typeof o=="string"?n.description=o:t?.generateDescriptions===!0&&typeof i=="string"&&(n.description=i);let a=e.default;pu(a)&&(n.default=a);let c=e.examples;Array.isArray(c)&&pu(c)&&(n.examples=c);let l=e.readOnly;typeof l=="boolean"&&(n.readOnly=l);let u=e.writeOnly;typeof u=="boolean"&&(n.writeOnly=u);let f=e.format;typeof f=="string"&&(n.format=f);let d=e.contentEncoding;typeof d=="string"&&(n.contentEncoding=d);let p=e.contentMediaType;typeof p=="string"&&(n.contentMediaType=p);let m=e.contentSchema;if(pu(m)&&(n.contentSchema=m),t?.includeAnnotationKey!==void 0)for(let[h,x]of Object.entries(e))R7.has(h)||!t.includeAnnotationKey(h)||pu(x)&&V(n,h,x);return Object.keys(n).length===0?void 0:n}s(xd,"collectJsonSchemaAnnotations");function N1(e){let t=e.type==="number"||e.type==="integer"?e.type:void 0,n=e;if(t!==void 0&&(n={...e},delete n.type),Array.isArray(n.allOf)){let r=[],o=!1;for(let i of n.allOf){let a=N1(i);a.type!==void 0&&(o=!0,(t===void 0||a.type==="integer")&&(t=a.type)),Object.keys(a.schema).length>0&&r.push(a.schema)}if(o){let{allOf:i,...a}=n;n=r.length===0?a:{...a,allOf:r}}}return{type:t,schema:n}}s(N1,"extractJsonSchemaNumberType");function $7(e){return Array.isArray(e.anyOf)&&e.anyOf.length===4&&e.anyOf[0]?.type==="number"&&e.anyOf.slice(1).every(t=>t.type==="string")}s($7,"isJsonSchemaNumberEncoding");function ry(e,t){if(Object.keys(e).length===0)return t;let n=Object.keys(t);if(n.length===0)return e;let r=e.type==="number"||e.type==="integer"?e.type:void 0,o=$7(e);if(r!==void 0||o){let a=N1(t);if(a.type!==void 0){let c=r==="integer"||a.type==="integer"?"integer":"number",l={...e,type:c};return o&&delete l.anyOf,Object.keys(a.schema).length===0?l:ry(l,a.schema)}}let i=Array.isArray(t.allOf)&&n.length===1?t.allOf:[t];return Array.isArray(e.allOf)?{...e,allOf:[...e.allOf,...i]}:typeof e.$ref=="string"?{allOf:[e,...i]}:{...e,allOf:i}}s(ry,"appendJsonSchema");function P7(e,t,n,r){let o=new Map,i=new WeakMap,a=new Map,c=!1,l=Object.keys(n);for(let v of l)d(v,["references",v]);let u=$s(e,(v,C)=>p(S(v,t[C]))),f={};for(let v of l){let C=o.get(v);typeof C!="string"&&V(f,v,p(C))}return{dialect:"draft-2020-12",schemas:u,definitions:f};function d(v,C){let w=o.get(v);if(w!==void 0)return typeof w=="string"?w:v;if(!Object.hasOwn(n,v))throw ho(`Invalid reference ${v}`,[...C,"$ref"]);o.set(v,null);let I=n[v],A=S(I,["references",v]),O=m(I);if(O!==void 0){let L=a.get(O),q=L?.find(Q=>re(o.get(Q),A));if(q===void 0)L===void 0?a.set(O,[v]):L.push(v);else return c=!0,o.set(v,q),q}return o.set(v,A),v}function p(v){return c?O1(v,C=>C.replace(/^#\/\$defs\/([^/]*)/,(w,I)=>{let A=o.get(ny(I));return typeof A=="string"?`#/$defs/${gd(A)}`:w})):v}function m(v){if(v._tag==="Reference")return;let C=v.checks.length===0?v.annotations:v.checks[v.checks.length-1].annotations;return typeof C?.identifier!="string"&&typeof C?.[oa]=="string"?C[oa]:void 0}function h(v,C){return v?.schemas?.map((w,I)=>S(w,[...C,"schemas",I]))??[]}function x(v,C,w){let I=v.annotations,A=I?.toJsonSchema;if(A!==void 0){let q=h(v.representation,[...w,"representation"]),Q=A({type:C,schemas:q}),E=xd(I,r);return E===void 0?Q:{...Q,...E}}if(v._tag==="Filter")return;let O=v.checks.map((q,Q)=>x(q,C,[...w,"checks",Q])).filter(q=>q!==void 0);if(O.length===0)return;let L=xd(I,r);return L===void 0?{allOf:O}:{allOf:O,...L}}function S(v,C){if(v._tag==="Reference"){let O=d(v.$ref,C);return{$ref:`#/$defs/${gd(O)}`}}let w=i.get(v);if(w!==void 0)return w;let I=T(v,C),A=xd(v.annotations,r);A!==void 0&&(I={...I,...A});for(let O=0;O<v.checks.length;O++){let L=typeof I.type=="string"&&N7(I.type)?I.type:void 0,q=x(v.checks[O],L,[...C,"checks",O]);q!==void 0&&(I=ry(I,q))}return i.set(v,I),I}function T(v,C){switch(v._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":case"UniqueSymbol":return{type:"string",allOf:[{pattern:"^Symbol\\((.*)\\)$"}]};case"Declaration":return{};case"Suspend":return S(v.thunk,[...C,"thunk"]);case"Never":return{not:{}};case"String":return{type:"string"};case"Number":return{anyOf:[{type:"number"},{type:"string",enum:["NaN"]},{type:"string",enum:["Infinity"]},{type:"string",enum:["-Infinity"]}]};case"Boolean":return{type:"boolean"};case"Literal":{let w=v.literal;return typeof w=="bigint"?{type:"string",enum:[globalThis.String(w)]}:{type:typeof w,enum:[w]}}case"Enum":{let w=v.enums.map(([I,A])=>typeof A=="number"&&!globalThis.Number.isFinite(A)?{type:"string",enum:[globalThis.String(A)],title:I}:{type:typeof A,enum:[A],title:I});return w.length===0?{not:{}}:{anyOf:w}}case"TemplateLiteral":return{type:"string",pattern:`^${v.parts.map(oy).join("")}$`};case"Arrays":{if(v.rest.length>1)throw ho("Invalid schema representation document",[...C,"rest"]);let w={type:"array"},I=v.elements.length,A=v.elements.map((O,L)=>{O.isOptional&&I--;let q=S(O.type,[...C,"elements",L,"type"]),Q=xd(O.annotations,r);return Q===void 0?q:ry(q,Q)});if(A.length>0?(w.prefixItems=A,w.maxItems=v.elements.length,I>0&&(w.minItems=I)):w.items=!1,v.rest.length===1){delete w.maxItems;let O=S(v.rest[0],[...C,"rest",0]);Object.keys(O).length>0?w.items=O:delete w.items}return w}case"Objects":{if(v.propertySignatures.length===0&&v.indexSignatures.length===0)return{anyOf:[{type:"object"},{type:"array"}]};let w={type:"object"},I={},A=[];for(let L=0;L<v.propertySignatures.length;L++){let q=v.propertySignatures[L];if(typeof q.name!="string")throw ho("Invalid schema representation document",[...C,"propertySignatures",L,"name"]);let Q=q.name,E=S(q.type,[...C,"propertySignatures",L,"type"]),k=xd(q.annotations,r);V(I,Q,k===void 0?E:ry(E,k)),q.isOptional||A.push(Q)}v.propertySignatures.length>0&&(w.properties=I),A.length>0&&(w.required=A),w.additionalProperties=r?.additionalProperties??!1;let O={};for(let L=0;L<v.indexSignatures.length;L++){let q=v.indexSignatures[L],Q=S(q.type,[...C,"indexSignatures",L,"type"]);Object.keys(Q).length===1&&"not"in Q&&(Q=!1);let E=b(q.parameter,[...C,"indexSignatures",L,"parameter"],new Set);if(E.length===0)w.additionalProperties=Q;else for(let k of E)V(O,k,Q)}return Object.keys(O).length>0&&(w.patternProperties=O,delete w.additionalProperties),typeof w.additionalProperties=="object"&&w.additionalProperties!==null&&Object.keys(w.additionalProperties).length===0&&delete w.additionalProperties,w}case"Union":{let w=v.types.map((I,A)=>S(I,[...C,"types",A]));if(w.length===0)return{not:{}};if(w.length>1){let I=D7(w);if(I!==void 0)return I}return v.mode==="anyOf"?{anyOf:w}:{oneOf:w}}}}function b(v,C,w){switch(v._tag){case"Reference":{if(!Object.hasOwn(n,v.$ref))throw ho(`Invalid reference ${v.$ref}`,[...C,"$ref"]);if(d(v.$ref,C),w.has(v.$ref))return[];let I=new Set(w).add(v.$ref);return b(n[v.$ref],["references",v.$ref],I)}case"String":return D1(S(v,C));case"TemplateLiteral":return[`^${v.parts.map(oy).join("")}$`];case"Union":return v.types.flatMap((I,A)=>b(I,[...C,"types",A],w));default:throw ho("Invalid schema representation document",C)}}}s(P7,"compileJsonSchema");function N7(e){return e==="string"||e==="number"||e==="boolean"||e==="array"||e==="object"||e==="null"||e==="integer"}s(N7,"isJsonSchemaType");function D7(e){let t,n=[];for(let r of e){if(Object.keys(r).length!==2||r.type===void 0||!Array.isArray(r.enum)||r.enum.length===0)return;if(t===void 0)t=r.type;else if(r.type!==t)return;n.push(...r.enum)}return{type:t,enum:n}}s(D7,"compactEnums");function D1(e){let t=[];typeof e.pattern=="string"&&t.push(e.pattern);for(let n of["allOf","anyOf","oneOf"]){let r=e[n];if(Array.isArray(r))for(let o of r)typeof o=="object"&&o!==null&&!Array.isArray(o)&&t.push(...D1(o))}return t}s(D1,"collectPatterns");function oy(e){switch(e._tag){case"Literal":return gu(globalThis.String(e.literal));case"String":return uU;case"Number":return Ax;case"TemplateLiteral":return e.parts.map(oy).join("");case"Union":return e.types.map(oy).join("|");default:throw ho("Invalid schema representation document",[])}}s(oy,"getPartPattern");function L1(e,t){let n=P7([e.representation],[["representation"]],e.references,t);return{dialect:n.dialect,schema:n.schemas[0],definitions:n.definitions}}s(L1,"toJsonSchemaDocument");function pC(e,t){let{references:n,representations:r}=F7([e],t);return{representation:r[0],references:n}}s(pC,"toRepresentation");function F7(e,t){return U7(e,t)}s(F7,"toRepresentations");function Mr(e){return e===void 0?void 0:{annotations:e}}s(Mr,"annotationsField");function F1(e,t){if(t?.(e)===!1)return!1;switch(e._tag){case"Arrays":case"Objects":case"Suspend":return!0;case"Declaration":return!0;case"Union":return e.types.some(n=>F1(n,t));default:return!1}}s(F1,"hasShareableStructure");function sy(e,t){return t*e>e+t+1}s(sy,"isWorthReferencing");function z7(e,t,n){if(n?.(e)===!1)return!1;if(F1(e,n))return!0;switch(e._tag){case"Union":return sy(e.types.length+1,t);case"Enum":return sy(e.enums.length+1,t);case"TemplateLiteral":return sy(e.parts.length+1,t);case"Literal":return typeof e.literal=="string"&&sy(e.literal.length/32+1,t);default:return!1}}s(z7,"isAnonymousReferenceEligible");function M7(e,t){let n=sa(t);if(n!==void 0)return{identifier:n};let r=(t!==e?sa(e):void 0)??vk(t);return r===void 0?void 0:{identifier:`${r}Encoded`,fallback:r}}s(M7,"resolveReferenceIdentifier");function U7(e,t){let n={},r=new Map,o=new Map,i=new Set,a=new Set,c=new Map,l=new Set;for(let w of e)m(w);return{representations:$s(e,w=>x(w)),references:n};function f(w,I,A="_"){let O=w,L=0;for(;o.has(O);){if(o.get(O)===I)return O;O=`${w}${A}${++L}`}return o.set(O,I),O}function d(w,I,A){let O=I.fallback;return O!==void 0?vk(w)===O?w:cr(w,{[oa]:O}):A===I.identifier?w:cr(w,{identifier:A})}function p(w,I){if(!Object.hasOwn(n,w)&&!i.has(w)){i.add(w);let A=S(I);i.delete(w),V(n,w,A)}return{_tag:"Reference",$ref:w}}function m(w){let I=lu(w),A=Px(I),O=(c.get(A)??0)+1;if(c.set(A,O),O>1){!l.has(A)&&z7(A,O,t?.isAnonymousReferenceAllowed)&&l.add(A);return}switch(h(I.checks),I._tag){case"Declaration":case"Arrays":case"Objects":case"Union":I.recur(L=>(m(L),L));break;case"TemplateLiteral":I.parts.forEach(m);break;case"Suspend":m(I.thunk());break}}function h(w){w?.forEach(I=>{I.annotations?.representation?.schemas?.forEach(A=>m(jt(A))),I._tag==="FilterGroup"&&h(I.checks)})}function x(w){let I=lu(w),A=Px(I),O=M7(w,I);if(O!==void 0){let k=f(O.identifier,A);return p(k,d(I,O,k))}let L=r.get(A);if(L!==void 0)return{_tag:"Reference",$ref:L};let q=l.has(A);if(q||a.has(A)){let k=f(`${I._tag}_`,A,"");return r.set(A,k),q?p(k,I):{_tag:"Reference",$ref:k}}a.add(A);let Q=S(I);a.delete(A);let E=r.get(A);return E!==void 0?(V(n,E,Q),{_tag:"Reference",$ref:E}):Q}function S(w){let I=T(w.checks);switch(w._tag){case"Declaration":return{_tag:"Declaration",typeParameters:w.typeParameters.map(A=>x(A)),checks:I,...v(w.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:w._tag,checks:I,...Mr(w.annotations)};case"Literal":return{_tag:"Literal",literal:w.literal,checks:I,...Mr(w.annotations)};case"UniqueSymbol":return{_tag:"UniqueSymbol",symbol:w.symbol,checks:I,...Mr(w.annotations)};case"Enum":return{_tag:"Enum",enums:w.enums,checks:I,...Mr(w.annotations)};case"TemplateLiteral":return{_tag:"TemplateLiteral",parts:w.parts.map(A=>x(A)),checks:I,...Mr(w.annotations)};case"Arrays":return{_tag:"Arrays",elements:w.elements.map(A=>{let O=lu(A),L=O.context?.annotations;return{isOptional:it(O),type:x(A),...Mr(L)}}),rest:w.rest.map(A=>x(A)),checks:I,...Mr(w.annotations)};case"Objects":return{_tag:"Objects",propertySignatures:w.propertySignatures.map(A=>{let O=lu(A.type),L=O.context?.annotations;return{name:A.name,type:x(A.type),isOptional:it(O),isMutable:oU(O),...Mr(L)}}),indexSignatures:w.indexSignatures.map(A=>({parameter:x(A.parameter),type:x(A.type)})),checks:I,...Mr(w.annotations)};case"Union":return{_tag:"Union",types:w.types.map(A=>x(A)),mode:w.mode,checks:I,...Mr(w.annotations)};case"Suspend":return{_tag:"Suspend",checks:[],thunk:x(w.thunk()),...Mr(w.annotations)}}}function T(w){return w?.map(b)??[]}function b(w){switch(w._tag){case"Filter":return{_tag:"Filter",aborted:w.aborted,...C(w.annotations)};case"FilterGroup":return{_tag:"FilterGroup",checks:$s(w.checks,b),...C(w.annotations)}}}function v(w){if(w===void 0)return;let{representation:I,...A}=w;return{...I===void 0?void 0:{representation:I},...Object.keys(A).length===0?void 0:{annotations:A}}}function C(w){if(w===void 0)return;let{representation:I,...A}=w,O=I===void 0?void 0:I.schemas===void 0?I:{...I,schemas:I.schemas.map(L=>x(jt(L)))};return{...O===void 0?void 0:{representation:O},...Object.keys(A).length===0?void 0:{annotations:A}}}}s(U7,"fromASTs");function M1(e,t){let n=[];return mC(e,t,"",n),n}s(M1,"get");function mC(e,t,n,r){if(!Object.is(e,t)){if(Array.isArray(e)&&Array.isArray(t)){let o=e.length,i=t.length,a=Math.min(o,i);for(let c=0;c<a;c++)mC(e[c],t[c],`${n}/${c}`,r);for(let c=o-1;c>=i;c--)r.push({op:"remove",path:`${n}/${c}`});for(let c=o;c<i;c++)r.push({op:"add",path:`${n}/${c}`,value:t[c]});return}if(iy(e)&&iy(t)){let o=Object.keys(e),i=Object.keys(t),a=Array.from(new Set([...o,...i])).sort();for(let c of a){let l=`${n}/${gd(c)}`,u=Object.hasOwn(e,c),f=Object.hasOwn(t,c);u&&f?mC(e[c],t[c],l,r):!u&&f?r.push({op:"add",path:l,value:t[c]}):r.push({op:"remove",path:l})}return}r.push({op:"replace",path:n,value:t})}}s(mC,"getLoop");function U1(e,t){let n=t;for(let r of e)n=Z7(n,r);return n}s(U1,"apply");function iy(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}s(iy,"isJsonObject");function j7(e){if(e==="")return[];if(e.charCodeAt(0)!==47)throw new Error(`Invalid JSON Pointer, it must start with "/": ${JSON.stringify(e)}`);return e.split("/").slice(1).map(ny)}s(j7,"tokenize");function G1(e){if(!/^(0|[1-9]\d*)$/.test(e))throw new Error(`Invalid array index: "${e}"`);return Number(e)}s(G1,"toIndex");function Z7(e,t){if(t.path===""){if(t.op==="remove")throw new Error("Unsupported operation at the root");return t.value}let n=q7(e,t.path);if(n===null)throw new Error(`Cannot ${t.op} at "${t.path}" (parent not found or not a container).`);let{lastToken:r,parent:o,stack:i}=n;if(Array.isArray(o)){if(r==="-"&&t.op!=="add")throw new Error(`"-" is not valid for ${t.op} at "${t.path}".`);let a=r==="-"?o.length:G1(r),c=t.op==="add"?o.length:o.length-1;if(a>c)throw new Error(`Array index out of bounds at "${t.path}".`);let l=o.slice();return t.op==="add"?l.splice(a,0,t.value):t.op==="remove"?l.splice(a,1):l[a]=t.value,z1(i,l)}if(iy(o)){if(t.op!=="add"&&!Object.hasOwn(o,r))throw new Error(`Property "${r}" does not exist at "${t.path}".`);let a={...o};return t.op==="remove"?delete a[r]:V(a,r,t.value),z1(i,a)}throw new Error(`Cannot ${t.op} at "${t.path}" (parent not found or not a container).`)}s(Z7,"applyOperation");function q7(e,t){let n=j7(t);if(n.length===0)return null;let r=n[n.length-1],o=[],i=e;for(let a=0;a<n.length-1;a++){let c=n[a];if(Array.isArray(i)){let l=G1(c);if(l>=i.length)return null;o.push({container:i,token:l}),i=i[l];continue}if(iy(i)){if(!Object.hasOwn(i,c))return null;o.push({container:i,token:c}),i=i[c];continue}return null}return{stack:o,parent:i,lastToken:r}}s(q7,"resolveParent");function z1(e,t){let n=t;for(let r=e.length-1;r>=0;r--){let{container:o,token:i}=e[r];if(Array.isArray(o)){let a=o.slice();a[i]=n,n=a}else{let a={...o};V(a,i,n),n=a}}return n}s(z1,"rebuildFromStack");function B1(e,t){return Ur(xu("Iso",e,t))}s(B1,"makeIso");function Z1(e,t){return Ur(xu("Lens",e,t))}s(Z1,"makeLens");function xu(e,t,n){return[{_tag:"PrimitiveNode",kind:e,get:t,set:n}]}s(xu,"primitiveNode");var B7={kind:"Iso",get:J,set:J},ay=class{static{s(this,"PathNode")}_tag="PathNode";kind="Lens";path;get;set;constructor(t){this.path=t,this.get=n=>{let r=n;for(let o=0;o<t.length;o++)r=r[t[o]];return r},this.set=(n,r)=>{let o=cy(r),i=o,a=0;for(;a<t.length-1;a++){let c=t[a];V(i,c,cy(i[c])),i=i[c]}return V(i,t[a],n),o}}},yd=class{static{s(this,"CheckNode")}_tag="CheckNode";kind="Prism";checks;get;set=J;constructor(t){this.checks=t,this.get=n=>dU(t,n)}};function va(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],i=n[n.length-1];i._tag==="PathNode"&&o._tag==="PathNode"?n[n.length-1]=new ay([...i.path,...o.path]):i._tag==="CheckNode"&&o._tag==="CheckNode"?n[n.length-1]=new yd([...i.checks,...o.checks]):n.push(o)}return n}s(va,"compose");function V7(e,t){return Ur(xu("Optional",e,t))}s(V7,"makeOptional");var yu=class{static{s(this,"OptionalImpl")}node;getResult;replaceResult;constructor(t,n,r){this.node=t,this.getResult=n,this.replaceResult=r}replace(t,n){return Cs(this.replaceResult(t,n),()=>n)}modify(t){return n=>Cs(Os(this.getResult(n),r=>this.replaceResult(t(r),n)),()=>n)}compose(t){return Ur(va(this.node,t.node))}key(t){return Ur(va(this.node,[new ay([t])]))}optionalKey(t){return Ur(va(this.node,xu("Lens",n=>n[t],(n,r)=>{let o=cy(r);return n===void 0?Array.isArray(o)&&typeof t=="number"?o.splice(t,1):delete o[t]:V(o,t,n),o})))}check(...t){return Ur(va(this.node,[new yd(t)]))}refine(t,n){return Ur(va(this.node,[new yd([$x(t,n)])]))}tag(t){let n=ie(new Ee({expected:`${JSON.stringify(t)} tag`}));return Ur(va(this.node,xu("Prism",r=>r._tag===t?X(r):n,J)))}at(t,...n){let r=ie(new Ot([t],new Ks(void 0)));return Ur(va(this.node,xu("Optional",o=>Object.hasOwn(o,t)?X(o[t]):r,(o,i)=>{if(Object.hasOwn(i,t)){let a=cy(i);return V(a,t,o),X(a)}else return r})))}pick(t){return this.compose(Z1(o1(t),(n,r)=>({...r,...n})))}omit(t){return this.compose(Z1(s1(t),(n,r)=>({...r,...n})))}notUndefined(){return this.refine(rn,{expected:"a value other than `undefined`"})}forEach(t){let n=t(uy());return V7(r=>Fn(this.getResult(r),o=>{let i=[];for(let a=0;a<o.length;a++){let c=n.getResult(o[a]);kt(c)&&i.push(c.success)}return i}),(r,o)=>Os(this.getResult(o),i=>{let a=[];for(let l=0;l<i.length;l++)kt(n.getResult(i[l]))&&a.push(l);if(r.length!==a.length)return ie(new Ee({message:`each: replacement length mismatch: ${r.length} !== ${a.length}`}));let c=i.slice();for(let l=0;l<a.length;l++){let u=a[l],f=n.replaceResult(r[l],i[u]);if(ye(f))return ie(new Ot([u],f.failure));c[u]=f.success}return this.replaceResult(c,o)}))}modifyAll(t){return n=>Cs(Os(this.getResult(n),r=>this.replaceResult(r.map(t),n)),()=>n)}},hC=class extends yu{static{s(this,"IsoImpl")}get;set;constructor(t,n,r){super(t,o=>X(n(o)),o=>X(r(o))),this.get=n,this.set=r}replace(t,n){return this.set(t)}modify(t){return n=>this.set(t(this.get(n)))}},gC=class extends yu{static{s(this,"LensImpl")}get;constructor(t,n,r){super(t,o=>X(n(o)),(o,i)=>X(r(o,i))),this.get=n,this.replace=r}modify(t){return n=>this.replace(t(this.get(n)),n)}},xC=class extends yu{static{s(this,"PrismImpl")}set;constructor(t,n,r){super(t,n,(o,i)=>X(r(o))),this.set=r}replace(t,n){return this.set(t)}modify(t){return n=>Cs(Fn(this.getResult(n),r=>this.set(t(r))),()=>n)}};function Ur(e){let t=e[0]??B7;if(e.length>1){let n=e.reduce((r,o)=>J7(r,o.kind),"Iso");t={kind:n,get:H7(e,n),set:K7(e,n)}}switch(t.kind){case"Iso":return new hC(e,t.get,t.set);case"Lens":return new gC(e,t.get,t.set);case"Prism":return new xC(e,t.get,t.set);case"Optional":return new yu(e,t.get,t.set)}}s(Ur,"make");function cy(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 new Error("Cannot clone object with non-Object constructor or null prototype");return{...e}}return e}s(cy,"cloneShallow");function H7(e,t){return n=>{for(let r=0;r<e.length;r++){let o=e[r],i=o.get(n);if(yC(o.kind)){if(ye(i))return i;n=i.success}else n=i}return yC(t)?X(n):n}}s(H7,"compileGet");function K7(e,t){return q1(t)?n=>{for(let r=e.length-1;r>=0;r--)n=e[r].set(n);return n}:(n,r)=>{let o=e.length,i=new Array(o);for(let a=0;a<o;a++){i[a]=r;let c=e[a];if(yC(c.kind)){let l=c.get(r);if(ye(l))return l;r=l.success}else r=c.get(r)}for(let a=o-1;a>=0;a--){let c=e[a];if(q1(c.kind))n=c.set(n);else if(c.kind==="Lens")n=c.set(n,i[a]);else{let l=c.set(n,i[a]);if(ye(l))return l;n=l.success}}return t==="Optional"?X(n):n}}s(K7,"compileSet");function yC(e){return e==="Prism"||e==="Optional"}s(yC,"hasFailingGet");function q1(e){return e==="Iso"||e==="Prism"}s(q1,"hasSourceFreeSet");function J7(e,t){return e==="Iso"?t:t==="Iso"||e===t?e:"Optional"}s(J7,"composeKind");var W7=Ur([]);function uy(){return W7}s(uy,"id");var _a=new WeakMap,H1=s(e=>{if(_a.has(e))return _a.get(e);throw new Error("Unable to get redacted value"+(e.label?` with label: "${e.label}"`:""))},"value");var K1="~effect/data/Redacted",SC=s(e=>U(e,K1),"isRedacted"),Sd=s((e,t)=>{let n=Object.create(X7);return t?.label&&(n.label=t.label),_a.set(n,e),n},"make"),X7={[K1]:{_A:s(e=>e,"_A")},label:void 0,...Co,toJSON(){return this.toString()},toString(){return`<redacted${yr(this.label)?":"+this.label:""}>`},[Te](){return pe(_a.get(this))},[ke](e){return SC(e)&&re(_a.get(this),_a.get(e))}},Su=H1;var J1=s(e=>Tt((t,n)=>e(Su(t),Su(n))),"makeEquivalence");var bd="~effect/SchemaError/SchemaError",Qs=class extends Tg("SchemaError"){static{s(this,"SchemaError")}[bd]=bd;constructor(t){super({issue:t})}get message(){return wz(this.issue)}toString(){return`SchemaError(${this.message})`}};function bC(e){return U(e,bd)&&e[bd]===bd}s(bC,"isSchemaError");var vd=Xx;function Hn(){return(e,t,n)=>Z(new fa(e.map(Yf),r=>t(r.map(o=>Z(o))),n))}s(Hn,"declareConstructor");function dr(e,t){return Hn()([],()=>(n,r,o)=>e(n)?se(n):W(new et(r,n,o)),t)}s(dr,"declare");function eY(e){return e}s(eY,"revealBottom");function tY(e){return t=>t.annotate(e)}s(tY,"annotate");function nY(e){return t=>vC(vC(t).annotate(e))}s(nY,"annotateEncoded");function rY(e){return t=>t.rebuild(rd(t.ast,e))}s(rY,"annotateKey");function oY(e){return e}s(oY,"revealCodec");function Y1(e){return Jt(e)?e.value:{issues:[{message:iL(e.cause)}]}}s(Y1,"makeStandardResult");function sY(e,t){let n=ut(e),r={errors:"all",...t?.parseOptions},o=bz(t),i=s(a=>{let c=new Fi("sync"),l=eu(lk(n(a,r),{onFailure:o,onSuccess:s(f=>({value:f}),"onSuccess")}),{scheduler:c});l.currentDispatcher?.flush();let u=l.pollUnsafe();return u?Y1(u):new Promise(f=>{l.addObserver(d=>{f(Y1(d))})})},"validate");if("~standard"in e){let a=e;return"validate"in a["~standard"]||Object.assign(a["~standard"],{validate:i}),a}else return Object.assign(e,{"~standard":{version:1,vendor:"effect",validate:i}})}s(sY,"toStandardSchemaV1");function X1(e,t){let n=ij(e);if(t==="draft-2020-12"){let r=n.schema;return Object.keys(n.definitions).length>0&&(r.$defs=n.definitions),r}else if(t==="draft-07"){let r=A1(n),o=r.schema;return Object.keys(r.definitions).length>0&&(o.definitions=r.definitions),o}throw new globalThis.Error(`Unsupported target: ${t}`)}s(X1,"toBaseStandardJSONSchemaV1");function iY(e){let t={input(n){return X1(e,n.target)},output(n){return X1(pn(e),n.target)}};if("~standard"in e){let n=e;return"jsonSchema"in n["~standard"]||Object.assign(n["~standard"],{jsonSchema:t}),n}else return Object.assign(e,{"~standard":{version:1,vendor:"effect",jsonSchema:t}})}s(iY,"toStandardJSONSchemaV1");var uG=jU,aY=qU;function py(e,t){let n=ut(e,t);return(r,o)=>lG(n(r,o))}s(py,"decodeUnknownEffect");function lG(e){return Hs(e,t=>Yc(()=>Gs(t,n=>new Qs(n))))}s(lG,"fromIssueEffect");var cY=py;function fG(e,t){let n;for(let r of e.reasons){if(!mg(r)||!bC(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}s(fG,"getSchemaErrorOrThrow");function dG(e){return tu(e).then(t=>{if(Jt(t))return t.value;throw fG(t.cause,"Promise adapter can only reject schema errors")})}s(dG,"runSchemaErrorPromise");function pG(e){let t=uo(e);if(Jt(t))return t.value;throw fG(t.cause,"Sync adapter can only throw schema errors")}s(pG,"runSchemaErrorSync");function mG(e,t){let n=BU(e,t);return(r,o)=>hG(n(r,o))}s(mG,"decodeUnknownExit");function hG(e){return Jt(e)?e:Bo(Gs(e.cause,t=>new Qs(t)))}s(hG,"fromIssueExit");var uY=mG,lY=oC,fY=VU;function gG(e,t){let n=HU(e,t);return(r,o)=>Jl(n(r,o),i=>new Qs(i))}s(gG,"decodeUnknownResult");var dY=gG;function xG(e,t){let n=py(e,t);return(r,o)=>dG(n(r,o))}s(xG,"decodeUnknownPromise");var pY=xG;function yG(e,t){let n=py(e,t);return(r,o)=>pG(n(r,o))}s(yG,"decodeUnknownSync");var mY=yG;function my(e,t){let n=mu(e,t);return(r,o)=>lG(n(r,o))}s(my,"encodeUnknownEffect");var SG=my;function bG(e,t){let n=KU(e,t);return(r,o)=>hG(n(r,o))}s(bG,"encodeUnknownExit");var hY=bG,gY=iC,xY=JU;function vG(e,t){let n=WU(e,t);return(r,o)=>Jl(n(r,o),i=>new Qs(i))}s(vG,"encodeUnknownResult");var yY=vG;function _G(e,t){let n=my(e,t);return(r,o)=>dG(n(r,o))}s(_G,"encodeUnknownPromise");var SY=_G;function wG(e,t){let n=my(e,t);return(r,o)=>pG(n(r,o))}s(wG,"encodeUnknownSync");var bY=wG,Z=pd;function hy(e){return U(e,vd)&&e[vd]===vd}s(hy,"isSchema");var wa=Wt(e=>Z(du(e.ast),{schema:e})),vY=Wt(e=>e.schema),fr=Wt(e=>{let t=yy(e);return Z(tU(e.ast),{schema:t})}),_Y=Wt(e=>e.schema.members[0]),wY=Wt(e=>Z(LA(e.ast),{schema:e})),EY=Wt(e=>e.schema),pn=Wt(e=>Z(jt(e.ast),{schema:e})),Iu=Wt(e=>Z(On(e.ast),{schema:e})),_d="~effect/Schema/flip";function IY(e){return U(e,_d)&&e[_d]===_d}s(IY,"isFlip$");function vC(e){return IY(e)?e.schema.rebuild(Pr(e.ast)):Z(Pr(e.ast),{[_d]:_d,schema:e})}s(vC,"flip");function Ye(e){let t=Z(new Cn(e),{literal:e,transform(n){return t.pipe(ae(Ye(n),{decode:xe(()=>n),encode:xe(()=>e)}))}});return t}s(Ye,"Literal");function EG(e){return new _x(e.map(t=>hy(t)?t.ast:new Cn(t)))}s(EG,"templateLiteralFromParts");function TY(e){return Z(EG(e),{parts:e})}s(TY,"TemplateLiteral");function kY(e){return Z(EG(e).asTemplateLiteralParser(),{parts:e})}s(kY,"TemplateLiteralParser");function AY(e){return Z(new vx(Object.keys(e).filter(t=>typeof e[e[t]]!="number").map(t=>[t,e[t]])),{enums:e})}s(AY,"Enum");var CY=Z(MM),OY=Z(UM),IC=Z(Qo),$e=Z(TA),TC=Z(kA),ce=Z(po),gy=Z(AA),IG=Z(ZM),TG=Z(qM),go=Z(BM),RY=Z(zM),$Y=Z(GM);function PY(e){return Z(new wx(e))}s(PY,"UniqueSymbol");function kC(e,t){return Z(e,{fields:t,mapFields(n,r){let o=n(this.fields);return kC(Cx(o,r?.unsafePreserveChecks?this.ast.checks:void 0),o)}})}s(kC,"makeStruct");function K(e){return kC(Cx(e,void 0),e)}s(K,"Struct");function NY(e){return Wt(t=>t.mapFields(i1(e)))}s(NY,"fieldsAssign");var DY=s(e=>typeof e=="symbol"?e:globalThis.String(e),"canonicalPropertyKey");function LY(e){return function(t){let n={},r=Object.create(null),o=Object.create(null),i=new Set;for(let a of Reflect.ownKeys(t.fields)){let c=Iu(t.fields[a]),l=Object.hasOwn(e,a),u=l?e[a]:a,f=DY(u);if(i.has(f))throw new globalThis.Error(`Duplicate encoded keys: ${Ao(u)}`);i.add(f),V(n,u,c),l&&(r[a]=u,o[u]=a)}return K(n).pipe(ae(t,We({decode:uC(o),encode:uC(r)})))}}s(LY,"encodeKeys");function FY(e,t){return n=>{let r=Wl(n.fields,pn),o=K({...r,...e});return n.pipe(ae(o,We({decode:s(i=>{let a={...i};for(let c in e){let l=t[c],u=l(i);an(u)&&V(a,c,u.value)}return a},"decode"),encode:s(i=>{let a={...i};for(let c in e)delete a[c];return a},"encode")})))}}s(FY,"extendTo");function kG(e,t){return Z(rU(e.ast,t.ast),{key:e,value:t})}s(kG,"Record");function zY(e,t){return Z(VM(e.ast,t.map(Yf)),{schema:e,records:t})}s(zY,"StructWithRest");function AG(e,t){return Z(e,{elements:t,mapElements(n,r){let o=n(this.elements);return AG(RA(o,r?.unsafePreserveChecks?this.ast.checks:void 0),o)}})}s(AG,"makeTuple");function vu(e){return AG(RA(e),e)}s(vu,"Tuple");function MY(e,t){return Z(HM(e.ast,t.map(Yf)),{schema:e,rest:t})}s(MY,"TupleWithRest");var dt=Wt(e=>Z(new Nr(!1,[],[e.ast]),{value:e}));var UY=Wt(e=>Z(new Nr(!1,[e.ast],[e.ast]),{value:e}));function GY(e){return pt([e,dt(e)]).pipe(ae(dt(pn(e)),We({decode:P$,encode:s(t=>t.length===1?t[0]:t,"encode")})))}s(GY,"ArrayEnsure");function jY(e){return dt(e).check(LC())}s(jY,"UniqueArray");var ZY=Wt(e=>Z(new Nr(!0,e.ast.elements,e.ast.rest),{schema:e}));function CG(e,t){return Z(e,{members:t,mapMembers(n,r){let o=n(this.members);return CG(Ox(o,this.ast.mode,r?.unsafePreserveChecks?this.ast.checks:void 0),o)}})}s(CG,"makeUnion");function pt(e,t){return CG(Ox(e,t?.mode??"anyOf",void 0),e)}s(pt,"Union");function xy(e){let t=e.map(Ye);return Z(Ox(t,"anyOf",void 0),{literals:e,members:t,mapMembers(n){return pt(n(this.members))},pick(n){return xy(n)},transform(n){return pt(t.map((r,o)=>r.transform(n[o])))}})}s(xy,"Literals");var AC=Wt(e=>pt([e,$e])),yy=Wt(e=>pt([e,TC])),OG=Wt(e=>pt([e,$e,TC]));function RG(e){return Z(new Ix(()=>e().ast))}s(RG,"suspend");function qY(...e){return t=>t.check(...e)}s(qY,"check");function BY(e,t){return n=>Z(Dr(n.ast,[$x(e,t)]),{schema:n})}s(BY,"refine");function $G(e){return t=>Z(eU(t.ast,e),{schema:t,identifier:e})}s($G,"brand");function VY(e,t){return n=>(t.checks?n.check(...t.checks):n).pipe($G(e))}s(VY,"fromBrand");function PG(e){return t=>Z(XM(t.ast,new Hf(e,J)),{schema:t})}s(PG,"middlewareDecoding");function NG(e){return t=>Z(QM(t.ast,new Hf(J,e)),{schema:t})}s(NG,"middlewareEncoding");function HY(e){return DG(e)}s(HY,"catchDecoding");function DG(e){return t=>PG(Xg(e))(t)}s(DG,"catchDecodingWithContext");function KY(e){return LG(e)}s(KY,"catchEncoding");function LG(e){return t=>NG(Xg(e))(t)}s(LG,"catchEncodingWithContext");function ae(e,t){return n=>Z(Lx(n.ast,e.ast,t?yx(t):ou()),{from:n,to:e})}s(ae,"decodeTo");function JY(e){return t=>ae(pn(t),e)(t)}s(JY,"decode");function CC(e,t){return n=>t?ae(n,t)(e):ae(n)(e)}s(CC,"encodeTo");function WY(e){return t=>ae(t,e)(Iu(t))}s(WY,"encode");function FG(e){return t=>Z(nU(t.ast,e),{schema:t})}s(FG,"withConstructorDefault");function zG(e){return Hs(e,t=>Yc(()=>Gs(t,n=>n.issue)))}s(zG,"toIssueEffect");function OC(e,t){let n=t?.encodingStrategy==="omit"?Kk():$r();return r=>wa(Iu(r)).pipe(ae(r,{decode:Bf(zG(e)),encode:n}))}s(OC,"withDecodingDefaultKey");function YY(e,t){return n=>pn(n).pipe(OC(e,t),CC(wa(n)))}s(YY,"withDecodingDefaultTypeKey");function MG(e,t){let n=t?.encodingStrategy==="omit"?Kk():$r();return r=>fr(Iu(r)).pipe(ae(r,{decode:Bf(zG(e)),encode:n}))}s(MG,"withDecodingDefault");function XY(e,t){return n=>pn(n).pipe(MG(e,t),CC(fr(n)))}s(XY,"withDecodingDefaultType");function Ea(e){return Ye(e).pipe(FG(se(e)))}s(Ea,"tag");function QY(e){return Ea(e).pipe(OC(se(e),{encodingStrategy:"omit"}))}s(QY,"tagDefaultOmit");function Sy(e,t){return K({_tag:Ea(e),...t})}s(Sy,"TaggedStruct");function UG(e){return t=>{let n={},r=[],o=new Set,i={},a=s(u=>f=>u.includes(f[e]),"isAnyOf");return c(t),Object.assign(t,{cases:n,discriminants:r,isAnyOf:a,guards:i,match:l});function c(u){let f=u.ast;if(LM(f)&&"members"in u&&globalThis.Array.isArray(u.members)&&u.members.every(hy))return u.members.forEach(c);let d=Xf(f);if(d.length>0){let p=d.find(m=>m.key===e)?.literal;if(Vm(p)){let m=typeof p=="number"?globalThis.String(p):p;if(o.has(m))throw new globalThis.Error(`Duplicate discriminant: ${globalThis.String(p)}`);o.add(m),r.push(p),V(n,p,u),V(i,p,uG(pn(u)));return}}throw new globalThis.Error("No literal or unique symbol found")}s(c,"walk");function l(){if(arguments.length===1){let m=arguments[0];return function(h){let x=h[e];return(Object.hasOwn(m,x)?m[x]:void 0)(h)}}let u=arguments[0],f=arguments[1],d=u[e];return(Object.hasOwn(f,d)?f[d]:void 0)(u)}s(l,"match")}}s(UG,"toTaggedUnion");function eX(e){let t={},n=[];for(let c of Object.keys(e)){let l=Sy(c,e[c]);V(t,c,l),n.push(l)}let r=pt(n),{guards:o,isAnyOf:i,match:a}=UG("_tag")(r);return Z(r.ast,{cases:t,isAnyOf:i,guards:o,match:a})}s(eX,"TaggedUnion");function tX(){return e=>e}s(tX,"Opaque");function ei(e,t){return dr(n=>n instanceof e,t)}s(ei,"instanceOf");function qe(){return(e,t)=>new He(e.ast,yx(t))}s(qe,"link");var je=Rx;function nX(e,t=void 0){return new pa(e,t)}s(nX,"makeFilterGroup");function Yt(e,t){return Rn(e,$e,({annotations:n})=>n===void 0?t:t.annotate(n))}s(Yt,"makeFixedDeclarationReviver");var Q1="^\\S[\\s\\S]*\\S$|^\\S$|^$";function RC(e){let t=new globalThis.RegExp(Q1);return je(n=>n.trim()===n,{expected:"a string with no leading or trailing whitespace",representation:{id:"effect/schema/isTrimmed",payload:null},toJsonSchema:s(()=>({pattern:t.source}),"toJsonSchema"),toCode:s(()=>({runtime:"Schema.isTrimmed()"}),"toCode"),arbitrary:{constraint:{patterns:[Q1]}},...e})}s(RC,"isTrimmed");var rX=le("effect/schema/isTrimmed",$e,({annotations:e})=>RC(e));function Ia(e,t){let n=e.source,r=e.flags,o=r===""?`new RegExp(${z(n)})`:`new RegExp(${z(n)}, ${z(r)})`;return ed(e,{toCode:s(()=>({runtime:`Schema.isPattern(${o})`}),"toCode"),...t})}s(Ia,"isPattern");var oX=K({source:ce,flags:ce}).check(je(e=>{let t=PE(()=>new globalThis.RegExp(e.source,e.flags));return kt(t)&&t.success.source===e.source&&t.success.flags===e.flags})),sX={id:"effect/schema/isPattern",payloadSchema:oX,revive:s(({annotations:e,payload:t})=>Ia(new globalThis.RegExp(t.source,t.flags),e),"revive")};function GG(e){return zA({toCode:s(()=>({runtime:"Schema.isStringFinite()"}),"toCode"),...e})}s(GG,"isStringFinite");var iX=le("effect/schema/isStringFinite",$e,({annotations:e})=>GG(e));function jG(e){return MA({toCode:s(()=>({runtime:"Schema.isStringBigInt()"}),"toCode"),...e})}s(jG,"isStringBigInt");var aX=le("effect/schema/isStringBigInt",$e,({annotations:e})=>jG(e));function ZG(e){return GA({toCode:s(()=>({runtime:"Schema.isStringSymbol()"}),"toCode"),...e})}s(ZG,"isStringSymbol");var cX=le("effect/schema/isStringSymbol",$e,({annotations:e})=>ZG(e)),uX=s(e=>e?new globalThis.RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${e}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`):/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|[fF]{8}-[fF]{4}-[fF]{4}-[fF]{4}-[fF]{12})$/,"getUUIDRegExp");function qG(e,t){let n=uX(e);return Ia(n,{expected:e?`a UUID v${e}`:"a UUID",representation:{id:"effect/schema/isUUID",payload:{version:e??null}},toJsonSchema:s(()=>({pattern:n.source,format:"uuid"}),"toJsonSchema"),toCode:s(()=>({runtime:e===void 0?"Schema.isUUID()":`Schema.isUUID(${e})`}),"toCode"),...t})}s(qG,"isUUID");var lX=le("effect/schema/isUUID",K({version:pt([xy([1,2,3,4,5,6,7,8]),$e])}),({annotations:e,payload:t})=>qG(t.version??void 0,e)),eG=/^([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 BG(e){return Ia(eG,{expected:"a GUID",representation:{id:"effect/schema/isGUID",payload:null},toJsonSchema:s(()=>({pattern:eG.source}),"toJsonSchema"),toCode:s(()=>({runtime:"Schema.isGUID()"}),"toCode"),...e})}s(BG,"isGUID");var fX=le("effect/schema/isGUID",$e,({annotations:e})=>BG(e));function VG(e){let t=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/;return Ia(t,{representation:{id:"effect/schema/isULID",payload:null},toJsonSchema:s(()=>({pattern:t.source}),"toJsonSchema"),toCode:s(()=>({runtime:"Schema.isULID()"}),"toCode"),...e})}s(VG,"isULID");var dX=le("effect/schema/isULID",$e,({annotations:e})=>VG(e));function $C(e){let t=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/;return Ia(t,{expected:"a base64 encoded string",representation:{id:"effect/schema/isBase64",payload:null},toJsonSchema:s(()=>({pattern:t.source}),"toJsonSchema"),toCode:s(()=>({runtime:"Schema.isBase64()"}),"toCode"),...e})}s($C,"isBase64");var pX=le("effect/schema/isBase64",$e,({annotations:e})=>$C(e));function HG(e){let t=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/;return Ia(t,{expected:"a base64url encoded string",representation:{id:"effect/schema/isBase64Url",payload:null},toJsonSchema:s(()=>({pattern:t.source}),"toJsonSchema"),toCode:s(()=>({runtime:"Schema.isBase64Url()"}),"toCode"),...e})}s(HG,"isBase64Url");var mX=le("effect/schema/isBase64Url",$e,({annotations:e})=>HG(e));function KG(e,t){let n=JSON.stringify(e),r=new globalThis.RegExp(`^${gu(e)}`);return je(o=>o.startsWith(e),{expected:`a string starting with ${n}`,representation:{id:"effect/schema/isStartsWith",payload:{startsWith:e}},toJsonSchema:s(()=>({pattern:r.source}),"toJsonSchema"),toCode:s(()=>({runtime:`Schema.isStartsWith(${z(e)})`}),"toCode"),arbitrary:{constraint:{patterns:[r.source]}},...t})}s(KG,"isStartsWith");var hX=le("effect/schema/isStartsWith",K({startsWith:ce}),({annotations:e,payload:t})=>KG(t.startsWith,e));function JG(e,t){let n=JSON.stringify(e),r=new globalThis.RegExp(`${gu(e)}$`);return je(o=>o.endsWith(e),{expected:`a string ending with ${n}`,representation:{id:"effect/schema/isEndsWith",payload:{endsWith:e}},toJsonSchema:s(()=>({pattern:r.source}),"toJsonSchema"),toCode:s(()=>({runtime:`Schema.isEndsWith(${z(e)})`}),"toCode"),arbitrary:{constraint:{patterns:[r.source]}},...t})}s(JG,"isEndsWith");var gX=le("effect/schema/isEndsWith",K({endsWith:ce}),({annotations:e,payload:t})=>JG(t.endsWith,e));function WG(e,t){let n=JSON.stringify(e),r=new globalThis.RegExp(gu(e));return je(o=>o.includes(e),{expected:`a string including ${n}`,representation:{id:"effect/schema/isIncludes",payload:{includes:e}},toJsonSchema:s(()=>({pattern:r.source}),"toJsonSchema"),toCode:s(()=>({runtime:`Schema.isIncludes(${z(e)})`}),"toCode"),arbitrary:{constraint:{patterns:[r.source]}},...t})}s(WG,"isIncludes");var xX=le("effect/schema/isIncludes",K({includes:ce}),({annotations:e,payload:t})=>WG(t.includes,e)),tG="^[^a-z]*$";function YG(e){let t=new globalThis.RegExp(tG);return je(n=>n.toUpperCase()===n,{expected:"a string with all characters in uppercase",representation:{id:"effect/schema/isUppercased",payload:null},toJsonSchema:s(()=>({pattern:t.source}),"toJsonSchema"),toCode:s(()=>({runtime:"Schema.isUppercased()"}),"toCode"),arbitrary:{constraint:{patterns:[tG]}},...e})}s(YG,"isUppercased");var yX=le("effect/schema/isUppercased",$e,({annotations:e})=>YG(e)),nG="^[^A-Z]*$";function XG(e){let t=new globalThis.RegExp(nG);return je(n=>n.toLowerCase()===n,{expected:"a string with all characters in lowercase",representation:{id:"effect/schema/isLowercased",payload:null},toJsonSchema:s(()=>({pattern:t.source}),"toJsonSchema"),toCode:s(()=>({runtime:"Schema.isLowercased()"}),"toCode"),arbitrary:{constraint:{patterns:[nG]}},...e})}s(XG,"isLowercased");var SX=le("effect/schema/isLowercased",$e,({annotations:e})=>XG(e)),rG="^[^a-z]?.*$";function QG(e){let t=new globalThis.RegExp(rG);return je(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:s(()=>({pattern:t.source}),"toJsonSchema"),toCode:s(()=>({runtime:"Schema.isCapitalized()"}),"toCode"),arbitrary:{constraint:{patterns:[rG]}},...e})}s(QG,"isCapitalized");var bX=le("effect/schema/isCapitalized",$e,({annotations:e})=>QG(e)),oG="^[^A-Z]?.*$";function e2(e){let t=new globalThis.RegExp(oG);return je(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:s(()=>({pattern:t.source}),"toJsonSchema"),toCode:s(()=>({runtime:"Schema.isUncapitalized()"}),"toCode"),arbitrary:{constraint:{patterns:[oG]}},...e})}s(e2,"isUncapitalized");var vX=le("effect/schema/isUncapitalized",$e,({annotations:e})=>e2(e)),Gr=Z(kx),t2=PA,_X=le("effect/schema/isFinite",$e,({annotations:e})=>t2(e));function wd(e){let t=tr(e.order),n=e.formatter??z;return(r,o)=>je(i=>t(i,r),{expected:`a value greater than ${n(r)}`,arbitrary:{constraint:{ordered:{order:e.order,minimum:r,exclusiveMinimum:!0}}},...e.annotate?.(r),...o})}s(wd,"makeIsGreaterThan");function Ed(e){let t=As(e.order),n=e.formatter??z;return(r,o)=>je(i=>t(i,r),{expected:`a value greater than or equal to ${n(r)}`,arbitrary:{constraint:{ordered:{order:e.order,minimum:r}}},...e.annotate?.(r),...o})}s(Ed,"makeIsGreaterThanOrEqualTo");function Id(e){let t=Qr(e.order),n=e.formatter??z;return(r,o)=>je(i=>t(i,r),{expected:`a value less than ${n(r)}`,arbitrary:{constraint:{ordered:{order:e.order,maximum:r,exclusiveMaximum:!0}}},...e.annotate?.(r),...o})}s(Id,"makeIsLessThan");function Td(e){let t=ks(e.order),n=e.formatter??z;return(r,o)=>je(i=>t(i,r),{expected:`a value less than or equal to ${n(r)}`,arbitrary:{constraint:{ordered:{order:e.order,maximum:r}}},...e.annotate?.(r),...o})}s(Td,"makeIsLessThanOrEqualTo");function kd(e){let t=As(e.order),n=tr(e.order),r=ks(e.order),o=Qr(e.order),i=e.formatter??z;return(a,c)=>{let l=a.exclusiveMinimum?n:t,u=a.exclusiveMaximum?o:r;return je(f=>l(f,a.minimum)&&u(f,a.maximum),{expected:`a value between ${i(a.minimum)}${a.exclusiveMinimum?" (excluded)":""} and ${i(a.maximum)}${a.exclusiveMaximum?" (excluded)":""}`,arbitrary:{constraint:{ordered:{order:e.order,minimum:a.minimum,maximum:a.maximum,...a.exclusiveMinimum&&{exclusiveMinimum:!0},...a.exclusiveMaximum&&{exclusiveMaximum:!0}}}},...e.annotate?.(a),...c})}}s(kd,"makeIsBetween");function n2(e){return(t,n)=>{let r=e.formatter??z;return je(o=>e.remainder(o,t)===e.zero,{expected:`a value that is a multiple of ${r(t)}`,...e.annotate?.(t),...n})}}s(n2,"makeIsMultipleOf");function _u(e){if(!globalThis.Number.isFinite(e))throw new globalThis.RangeError(`Expected a finite number, got ${z(e)}`);return e}s(_u,"encodeNumberPayload");var r2=wd({order:Ln,annotate:s(e=>({representation:{id:"effect/schema/isGreaterThan",payload:{exclusiveMinimum:_u(e)}},toJsonSchema:s(()=>({exclusiveMinimum:e}),"toJsonSchema"),toCode:s(()=>({runtime:`Schema.isGreaterThan(${z(e)})`}),"toCode")}),"annotate")}),wX=le("effect/schema/isGreaterThan",K({exclusiveMinimum:Gr}),({annotations:e,payload:t})=>r2(t.exclusiveMinimum,e)),PC=Ed({order:Ln,annotate:s(e=>({representation:{id:"effect/schema/isGreaterThanOrEqualTo",payload:{minimum:_u(e)}},toJsonSchema:s(()=>({minimum:e}),"toJsonSchema"),toCode:s(()=>({runtime:`Schema.isGreaterThanOrEqualTo(${z(e)})`}),"toCode")}),"annotate")}),EX=le("effect/schema/isGreaterThanOrEqualTo",K({minimum:Gr}),({annotations:e,payload:t})=>PC(t.minimum,e)),o2=Id({order:Ln,annotate:s(e=>({representation:{id:"effect/schema/isLessThan",payload:{exclusiveMaximum:_u(e)}},toJsonSchema:s(()=>({exclusiveMaximum:e}),"toJsonSchema"),toCode:s(()=>({runtime:`Schema.isLessThan(${z(e)})`}),"toCode")}),"annotate")}),IX=le("effect/schema/isLessThan",K({exclusiveMaximum:Gr}),({annotations:e,payload:t})=>o2(t.exclusiveMaximum,e)),s2=Td({order:Ln,annotate:s(e=>({representation:{id:"effect/schema/isLessThanOrEqualTo",payload:{maximum:_u(e)}},toJsonSchema:s(()=>({maximum:e}),"toJsonSchema"),toCode:s(()=>({runtime:`Schema.isLessThanOrEqualTo(${z(e)})`}),"toCode")}),"annotate")}),TX=le("effect/schema/isLessThanOrEqualTo",K({maximum:Gr}),({annotations:e,payload:t})=>s2(t.maximum,e)),by=kd({order:Ln,annotate:s(e=>{let t=e.exclusiveMinimum?!0:void 0,n=e.exclusiveMaximum?!0:void 0;return{representation:{id:"effect/schema/isBetween",payload:{minimum:_u(e.minimum),maximum:_u(e.maximum),...t&&{exclusiveMinimum:t},...n&&{exclusiveMaximum:n}}},toJsonSchema:s(()=>({[t?"exclusiveMinimum":"minimum"]:e.minimum,[n?"exclusiveMaximum":"maximum"]:e.maximum}),"toJsonSchema"),toCode:s(()=>({runtime:`Schema.isBetween({ minimum: ${z(e.minimum)}, maximum: ${z(e.maximum)}, exclusiveMinimum: ${z(t)}, exclusiveMaximum: ${z(n)} })`}),"toCode")}},"annotate")}),kX=le("effect/schema/isBetween",K({minimum:Gr,maximum:Gr,exclusiveMinimum:fr(Ye(!0)),exclusiveMaximum:fr(Ye(!0))}),({annotations:e,payload:t})=>by(t,e)),i2=n2({remainder:PF,zero:0,annotate:s(e=>({expected:`a value that is a multiple of ${e}`,representation:{id:"effect/schema/isMultipleOf",payload:{divisor:e}},toJsonSchema:s(()=>({multipleOf:e}),"toJsonSchema"),toCode:s(()=>({runtime:`Schema.isMultipleOf(${z(e)})`}),"toCode")}),"annotate")}),AX=le("effect/schema/isMultipleOf",K({divisor:Gr}),({annotations:e,payload:t})=>i2(t.divisor,e));function Ad(e){return je(t=>globalThis.Number.isSafeInteger(t),{expected:"an integer",representation:{id:"effect/schema/isInt",payload:null},toJsonSchema:s(()=>({type:"integer"}),"toJsonSchema"),toCode:s(()=>({runtime:"Schema.isInt()"}),"toCode"),arbitrary:{constraint:{integer:!0}},...e})}s(Ad,"isInt");var CX=le("effect/schema/isInt",$e,({annotations:e})=>Ad(e)),Ta=gy.check(Ad()),Vn=Ta.check(PC(0));function OX(e){return new pa([Ad(),by({minimum:-2147483648,maximum:2147483647})],{expected:"a 32-bit integer",...e})}s(OX,"isInt32");function RX(e){return new pa([Ad(),by({minimum:0,maximum:4294967295})],{expected:"a 32-bit unsigned integer",...e})}s(RX,"isUint32");function wu(e){if(globalThis.Number.isNaN(e.getTime()))throw new globalThis.RangeError(`Expected a valid Date, got ${z(e)}`);return e.toISOString()}s(wu,"encodeDatePayload");function Eu(e){return`new Date(${z(e.getTime())})`}s(Eu,"formatDateRuntime");var a2=wd({order:$i,annotate:s(e=>({representation:{id:"effect/schema/isGreaterThanDate",payload:{exclusiveMinimum:wu(e)}},toJsonSchema:s(()=>({}),"toJsonSchema"),toCode:s(()=>({runtime:`Schema.isGreaterThanDate(${Eu(e)})`}),"toCode")}),"annotate")}),c2=Ed({order:$i,annotate:s(e=>({representation:{id:"effect/schema/isGreaterThanOrEqualToDate",payload:{minimum:wu(e)}},toJsonSchema:s(()=>({}),"toJsonSchema"),toCode:s(()=>({runtime:`Schema.isGreaterThanOrEqualToDate(${Eu(e)})`}),"toCode")}),"annotate")}),u2=Id({order:$i,annotate:s(e=>({representation:{id:"effect/schema/isLessThanDate",payload:{exclusiveMaximum:wu(e)}},toJsonSchema:s(()=>({}),"toJsonSchema"),toCode:s(()=>({runtime:`Schema.isLessThanDate(${Eu(e)})`}),"toCode")}),"annotate")}),l2=Td({order:$i,annotate:s(e=>({representation:{id:"effect/schema/isLessThanOrEqualToDate",payload:{maximum:wu(e)}},toJsonSchema:s(()=>({}),"toJsonSchema"),toCode:s(()=>({runtime:`Schema.isLessThanOrEqualToDate(${Eu(e)})`}),"toCode")}),"annotate")}),f2=kd({order:$i,annotate:s(e=>{let t=e.exclusiveMinimum?!0:void 0,n=e.exclusiveMaximum?!0:void 0;return{representation:{id:"effect/schema/isBetweenDate",payload:{minimum:wu(e.minimum),maximum:wu(e.maximum),...t&&{exclusiveMinimum:t},...n&&{exclusiveMaximum:n}}},toJsonSchema:s(()=>({}),"toJsonSchema"),toCode:s(()=>({runtime:`Schema.isBetweenDate({ minimum: ${Eu(e.minimum)}, maximum: ${Eu(e.maximum)}, exclusiveMinimum: ${z(t)}, exclusiveMaximum: ${z(n)} })`}),"toCode")}},"annotate")}),d2=wd({order:er,annotate:s(e=>({representation:{id:"effect/schema/isGreaterThanBigInt",payload:{exclusiveMinimum:e.toString(10)}},toJsonSchema:s(()=>({}),"toJsonSchema"),toCode:s(()=>({runtime:`Schema.isGreaterThanBigInt(${z(e)})`}),"toCode")}),"annotate")}),p2=Ed({order:er,annotate:s(e=>({representation:{id:"effect/schema/isGreaterThanOrEqualToBigInt",payload:{minimum:e.toString(10)}},toJsonSchema:s(()=>({}),"toJsonSchema"),toCode:s(()=>({runtime:`Schema.isGreaterThanOrEqualToBigInt(${z(e)})`}),"toCode")}),"annotate")}),m2=Id({order:er,annotate:s(e=>({representation:{id:"effect/schema/isLessThanBigInt",payload:{exclusiveMaximum:e.toString(10)}},toJsonSchema:s(()=>({}),"toJsonSchema"),toCode:s(()=>({runtime:`Schema.isLessThanBigInt(${z(e)})`}),"toCode")}),"annotate")}),h2=Td({order:er,annotate:s(e=>({representation:{id:"effect/schema/isLessThanOrEqualToBigInt",payload:{maximum:e.toString(10)}},toJsonSchema:s(()=>({}),"toJsonSchema"),toCode:s(()=>({runtime:`Schema.isLessThanOrEqualToBigInt(${z(e)})`}),"toCode")}),"annotate")}),g2=kd({order:er,annotate:s(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:s(()=>({}),"toJsonSchema"),toCode:s(()=>({runtime:`Schema.isBetweenBigInt({ minimum: ${z(e.minimum)}, maximum: ${z(e.maximum)}, exclusiveMinimum: ${z(t)}, exclusiveMaximum: ${z(n)} })`}),"toCode")}},"annotate")}),$X=wd({order:Lo,formatter:s(e=>eo(e),"formatter")}),PX=Ed({order:Lo,formatter:s(e=>eo(e),"formatter")}),NX=Id({order:Lo,formatter:s(e=>eo(e),"formatter")}),DX=Td({order:Lo,formatter:s(e=>eo(e),"formatter")}),LX=kd({order:Lo,formatter:s(e=>eo(e),"formatter")});function NC(e,t){return e=Math.max(0,Math.floor(e)),je(n=>n.length>=e,{expected:`a value with a length of at least ${e}`,representation:{id:"effect/schema/isMinLength",payload:{minLength:e}},toJsonSchema:s(({type:n})=>n==="array"?{minItems:e}:{minLength:e},"toJsonSchema"),toCode:s(()=>({runtime:`Schema.isMinLength(${e})`}),"toCode"),[Tn]:!0,arbitrary:{constraint:{minLength:e}},...t})}s(NC,"isMinLength");var FX=le("effect/schema/isMinLength",K({minLength:Vn}),({annotations:e,payload:t})=>NC(t.minLength,e));function x2(e){return NC(1,e)}s(x2,"isNonEmpty");function y2(e,t){return e=Math.max(0,Math.floor(e)),je(n=>n.length<=e,{expected:`a value with a length of at most ${e}`,representation:{id:"effect/schema/isMaxLength",payload:{maxLength:e}},toJsonSchema:s(({type:n})=>n==="array"?{maxItems:e}:{maxLength:e},"toJsonSchema"),toCode:s(()=>({runtime:`Schema.isMaxLength(${e})`}),"toCode"),[Tn]:!0,arbitrary:{constraint:{maxLength:e}},...t})}s(y2,"isMaxLength");var zX=le("effect/schema/isMaxLength",K({maxLength:Vn}),({annotations:e,payload:t})=>y2(t.maxLength,e));function DC(e,t,n){return e=Math.max(0,Math.floor(e)),t=Math.max(0,Math.floor(t)),je(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/isLengthBetween",payload:{minimum:e,maximum:t}},toJsonSchema:s(({type:r})=>r==="array"?{allOf:[{minItems:e},{maxItems:t}]}:{allOf:[{minLength:e},{maxLength:t}]},"toJsonSchema"),toCode:s(()=>({runtime:`Schema.isLengthBetween(${e}, ${t})`}),"toCode"),[Tn]:!0,arbitrary:{constraint:{minLength:e,maxLength:t}},...n})}s(DC,"isLengthBetween");var MX=le("effect/schema/isLengthBetween",K({minimum:Vn,maximum:Vn}),({annotations:e,payload:t})=>DC(t.minimum,t.maximum,e));function S2(e,t){return e=Math.max(0,Math.floor(e)),je(n=>n.size>=e,{expected:`a value with a size of at least ${e}`,representation:{id:"effect/schema/isMinSize",payload:{minSize:e}},toJsonSchema:s(()=>({}),"toJsonSchema"),toCode:s(()=>({runtime:`Schema.isMinSize(${e})`}),"toCode"),[Tn]:!0,arbitrary:{constraint:{minLength:e}},...t})}s(S2,"isMinSize");var UX=le("effect/schema/isMinSize",K({minSize:Vn}),({annotations:e,payload:t})=>S2(t.minSize,e));function b2(e,t){return e=Math.max(0,Math.floor(e)),je(n=>n.size<=e,{expected:`a value with a size of at most ${e}`,representation:{id:"effect/schema/isMaxSize",payload:{maxSize:e}},toJsonSchema:s(()=>({}),"toJsonSchema"),toCode:s(()=>({runtime:`Schema.isMaxSize(${e})`}),"toCode"),[Tn]:!0,arbitrary:{constraint:{maxLength:e}},...t})}s(b2,"isMaxSize");var GX=le("effect/schema/isMaxSize",K({maxSize:Vn}),({annotations:e,payload:t})=>b2(t.maxSize,e));function v2(e,t,n){return e=Math.max(0,Math.floor(e)),t=Math.max(0,Math.floor(t)),je(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/isSizeBetween",payload:{minimum:e,maximum:t}},toJsonSchema:s(()=>({}),"toJsonSchema"),toCode:s(()=>({runtime:`Schema.isSizeBetween(${e}, ${t})`}),"toCode"),[Tn]:!0,arbitrary:{constraint:{minLength:e,maxLength:t}},...n})}s(v2,"isSizeBetween");var jX=le("effect/schema/isSizeBetween",K({minimum:Vn,maximum:Vn}),({annotations:e,payload:t})=>v2(t.minimum,t.maximum,e));function _2(e,t){return e=Math.max(0,Math.floor(e)),je(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:s(()=>({minProperties:e}),"toJsonSchema"),toCode:s(()=>({runtime:`Schema.isMinProperties(${e})`}),"toCode"),[Tn]:!0,arbitrary:{constraint:{minLength:e}},...t})}s(_2,"isMinProperties");var ZX=le("effect/schema/isMinProperties",K({minProperties:Vn}),({annotations:e,payload:t})=>_2(t.minProperties,e));function w2(e,t){return e=Math.max(0,Math.floor(e)),je(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:s(()=>({maxProperties:e}),"toJsonSchema"),toCode:s(()=>({runtime:`Schema.isMaxProperties(${e})`}),"toCode"),[Tn]:!0,arbitrary:{constraint:{maxLength:e}},...t})}s(w2,"isMaxProperties");var qX=le("effect/schema/isMaxProperties",K({maxProperties:Vn}),({annotations:e,payload:t})=>w2(t.maxProperties,e));function E2(e,t,n){return e=Math.max(0,Math.floor(e)),t=Math.max(0,Math.floor(t)),je(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/isPropertiesLengthBetween",payload:{minimum:e,maximum:t}},toJsonSchema:s(()=>({minProperties:e,maxProperties:t}),"toJsonSchema"),toCode:s(()=>({runtime:`Schema.isPropertiesLengthBetween(${e}, ${t})`}),"toCode"),[Tn]:!0,arbitrary:{constraint:{minLength:e,maxLength:t}},...n})}s(E2,"isPropertiesLengthBetween");var BX=le("effect/schema/isPropertiesLengthBetween",K({minimum:Vn,maximum:Vn}),({annotations:e,payload:t})=>E2(t.minimum,t.maximum,e));function I2(e,t){let n=Iu(e),r=ZU(n.ast);return je((o,i,a)=>{let c=Reflect.ownKeys(o),l=[];for(let u of c){let f=r(u,a);if(f!==void 0&&(l.push(new Ot([u],f)),a.errors==="first"))break}return Cc(l)?new Qe(i,l,o,a):!0},{expected:"an object with property names matching the schema",representation:{id:"effect/schema/isPropertyNames",payload:null,schemas:[n.ast]},toJsonSchema:s(({schemas:o})=>({propertyNames:o[0]}),"toJsonSchema"),toCode:s(({schemas:o})=>({runtime:`Schema.isPropertyNames(${o[0].runtime})`}),"toCode"),[Tn]:!0,...t})}s(I2,"isPropertyNames");var VX=le("effect/schema/isPropertyNames",$e,({annotations:e,schemas:t})=>I2(t[0],e));function LC(e){return je(t=>bh(t).length===t.length,{expected:"an array with unique items",representation:{id:"effect/schema/isUnique",payload:null},toJsonSchema:s(()=>({uniqueItems:!0}),"toJsonSchema"),toCode:s(()=>({runtime:"Schema.isUnique()"}),"toCode"),arbitrary:{constraint:{unique:!0}},...e})}s(LC,"isUnique");var HX=le("effect/schema/isUnique",$e,({annotations:e})=>LC(e)),KX=ce.check(x2()),JX=ce.check(DC(1,1));function ti(e){let t=Hn()([e],([n])=>(r,o,i)=>hh(r)?Xe(r)?Jc:Ct(ut(n)(r.value,i),{onSuccess:H,onFailure:s(a=>kn(o,"value",a,r,i),"onFailure")}):W(new et(o,r,i)),{representation:{id:"effect/schema/Option",payload:null},toCode:s(({typeParameters:n})=>({runtime:`Schema.Option(${n[0].runtime})`,Type:`Option.Option<${n[0].Type}>`,importDeclarations:['import * as Option from "effect/Option"']}),"toCode"),expected:"Option",toCodec:s(([n])=>qe()(pt([K({_tag:Ye("Some"),value:n}),K({_tag:Ye("None")})]),We({decode:s(r=>r._tag==="None"?te():H(r.value),"decode"),encode:s(r=>an(r)?{_tag:"Some",value:r.value}:{_tag:"None"},"encode")})),"toCodec"),toArbitrary:s(([n])=>(r,o)=>{let i=r.constant(te()),a=r.oneof(i,n.arbitrary.map(H));return Tu(r,o,i,a)},"toArbitrary"),toEquivalence:s(([n])=>C$(n),"toEquivalence"),toFormatter:s(([n])=>_r({onNone:s(()=>"none()","onNone"),onSome:s(r=>`some(${n(r)})`,"onSome")}),"toFormatter")});return Z(t.ast,{value:e})}s(ti,"Option");var WX=Rn("effect/schema/Option",$e,({annotations:e,typeParameters:t})=>{let n=ti(t[0]);return e===void 0?n:n.annotate(e)});function YX(e){return AC(e).pipe(ae(ti(pn(e)),gM()))}s(YX,"OptionFromNullOr");function XX(e){return yy(e).pipe(ae(ti(pn(e)),xM()))}s(XX,"OptionFromUndefinedOr");function QX(e,t){return OG(e).pipe(ae(ti(pn(e)),yM(t)))}s(QX,"OptionFromNullishOr");function eQ(e){return wa(e).pipe(ae(ti(pn(e)),SM()))}s(eQ,"OptionFromOptionalKey");function tQ(e){return fr(e).pipe(ae(ti(pn(e)),bM()))}s(tQ,"OptionFromOptional");function nQ(e,t){let n=t===void 0?"omit":t.onNoneEncoding,r=n===null?null:void 0;return fr(AC(e)).pipe(ae(ti(pn(e)),Sx({decode:s(o=>o.pipe(Ac(Hm),H),"decode"),encode:n==="omit"?kc:o=>H(gh(kc(o),()=>r))})))}s(nQ,"OptionFromOptionalNullOr");function T2(e,t){let n=Hn()([e,t],([r,o])=>(i,a,c)=>{if(!xh(i))return W(new et(a,i,c));switch(i._tag){case"Success":return Ct(rC(r)(i.success,c),{onSuccess:X,onFailure:s(l=>kn(a,"success",l,i,c),"onFailure")});case"Failure":return Ct(rC(o)(i.failure,c),{onSuccess:ie,onFailure:s(l=>kn(a,"failure",l,i,c),"onFailure")})}},{representation:{id:"effect/schema/Result",payload:null},toCode:s(({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"']}),"toCode"),expected:"Result",toCodec:s(([r,o])=>qe()(pt([K({_tag:Ye("Success"),success:r}),K({_tag:Ye("Failure"),failure:o})]),We({decode:s(i=>i._tag==="Success"?X(i.success):ie(i.failure),"decode"),encode:s(i=>kt(i)?{_tag:"Success",success:i.success}:{_tag:"Failure",failure:i.failure},"encode")})),"toCodec"),toArbitrary:s(([r,o])=>(i,a)=>{let c=F2(i,r.terminal?.map(u=>X(u)),o.terminal?.map(u=>ie(u))),l=i.oneof(r.arbitrary.map(u=>X(u)),o.arbitrary.map(u=>ie(u)));return Tu(i,a,c,l)},"toArbitrary"),toEquivalence:s(([r,o])=>NE(r,o),"toEquivalence"),toFormatter:s(([r,o])=>vn({onSuccess:s(i=>`success(${r(i)})`,"onSuccess"),onFailure:s(i=>`failure(${o(i)})`,"onFailure")}),"toFormatter")});return Z(n.ast,{success:e,failure:t})}s(T2,"Result");var rQ=Rn("effect/schema/Result",$e,({annotations:e,typeParameters:t})=>{let n=T2(t[0],t[1]);return e===void 0?n:n.annotate(e)}),oQ=dr(e=>{if(!Sr(e))return!1;let t=globalThis.Object.keys(e);return t.length>0&&t.every(n=>{switch(n){case"label":return typeof e[n]=="string";case"disallowJsonEncode":return e[n]===!0;default:return!1}})}),sQ=pt([$e,oQ]);function FC(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,i=n!==void 0?ut(Ye(n)):void 0,a=Hn()([e],([c])=>(l,u,f)=>{if(SC(l)){let d=i!==void 0?$f(i(l.label,f),p=>new Ot(["label"],p)):Cf;return qn(d,()=>Ct(ut(c)(Su(l),f),{onSuccess:s(()=>l,"onSuccess"),onFailure:s(()=>new Qe(u,[new Ot(["value"],new Ee(void 0,l,f))],l,f),"onFailure")}))}return W(new et(u,l,f))},{representation:{id:"effect/schema/Redacted",payload:o??null},toCode:s(({typeParameters:c})=>({runtime:o!==void 0?`Schema.Redacted(${c[0].runtime}, ${z(o)})`:`Schema.Redacted(${c[0].runtime})`,Type:`Redacted.Redacted<${c[0].Type}>`,importDeclarations:['import * as Redacted from "effect/Redacted"']}),"toCode"),expected:"Redacted",toCodecJson:s(([c])=>qe()(c,{decode:xe(l=>Sd(l,{label:n})),encode:r?Vk(l=>"Cannot serialize Redacted"+(an(l)&&typeof l.value.label=="string"?` with label: "${l.value.label}"`:"")):xe(Su)}),"toCodecJson"),toArbitrary:s(([c])=>()=>({arbitrary:c.arbitrary.map(l=>Sd(l,{label:n})),terminal:c.terminal?.map(l=>Sd(l,{label:n}))}),"toArbitrary"),toFormatter:s(()=>globalThis.String,"toFormatter"),toEquivalence:s(([c])=>J1(c),"toEquivalence")});return Z(a.ast,{value:e})}s(FC,"Redacted");var iQ=Rn("effect/schema/Redacted",sQ,({annotations:e,payload:t,typeParameters:n})=>{let r=FC(n[0],t??void 0);return e===void 0?r:r.annotate(e)});function aQ(e,t){return ae(FC(pn(e),{label:t?.label,disallowJsonEncode:t?.disallowEncode}),{decode:xe(n=>Sd(n,{label:t?.label})),encode:t?.disallowEncode?Vk(n=>"Cannot encode Redacted"+(an(n)&&typeof n.value.label=="string"?` with label: "${n.value.label}"`:"")):xe(Su)})(e)}s(aQ,"RedactedFromValue");function ly(e,t){let n=Hn()([e,t],([r,o])=>(i,a,c)=>{if(!oL(i))return W(new et(a,i,c));switch(i._tag){case"Fail":return Ct(ut(r)(i.error,c),{onSuccess:gg,onFailure:s(l=>kn(a,"error",l,i,c),"onFailure")});case"Die":return Ct(ut(o)(i.defect,c),{onSuccess:xg,onFailure:s(l=>kn(a,"defect",l,i,c),"onFailure")});case"Interrupt":return se(i)}},{representation:{id:"effect/schema/CauseReason",payload:null},toCode:s(({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"']}),"toCode"),expected:"Cause.Failure",toCodec:s(([r,o])=>qe()(pt([K({_tag:Ye("Fail"),error:r}),K({_tag:Ye("Die"),defect:o}),K({_tag:Ye("Interrupt"),fiberId:yy(Gr)})]),We({decode:s(i=>{switch(i._tag){case"Fail":return gg(i.error);case"Die":return xg(i.defect);case"Interrupt":return yg(i.fiberId)}},"decode"),encode:J})),"toCodec"),toArbitrary:s(([r,o])=>k2(r,o),"toArbitrary"),toEquivalence:s(([r,o])=>A2(r,o),"toEquivalence"),toFormatter:s(([r,o])=>C2(r,o),"toFormatter")});return Z(n.ast,{error:e,defect:t})}s(ly,"CauseReason");var cQ=Rn("effect/schema/CauseReason",$e,({annotations:e,typeParameters:t})=>{let n=ly(t[0],t[1]);return e===void 0?n:n.annotate(e)});function k2(e,t){return(n,r)=>{let o=n.constant(yg()),i=n.oneof(o,n.integer({min:1}).map(yg),e.arbitrary.map(a=>gg(a)),t.arbitrary.map(a=>xg(a)));return Tu(n,r,o,i)}}s(k2,"causeReasonToArbitrary");function A2(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}}}s(A2,"causeReasonToEquivalence");function C2(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"}}}s(C2,"causeReasonToFormatter");function fy(e,t){let n=Hn()([e,t],([r,o])=>{let i=dt(ly(r,o));return(a,c,l)=>rL(a)?Ct(ut(i)(a.reasons,l),{onSuccess:hg,onFailure:s(u=>kn(c,"failures",u,a,l),"onFailure")}):W(new et(c,a,l))},{representation:{id:"effect/schema/Cause",payload:null},toCode:s(({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"']}),"toCode"),expected:"Cause",toCodec:s(([r,o])=>qe()(dt(ly(r,o)),We({decode:hg,encode:s(({reasons:i})=>i,"encode")})),"toCodec"),toArbitrary:s(([r,o])=>O2(r,o),"toArbitrary"),toEquivalence:s(([r,o])=>R2(r,o),"toEquivalence"),toFormatter:s(([r,o])=>$2(r,o),"toFormatter")});return Z(n.ast,{error:e,defect:t})}s(fy,"Cause");var uQ=Rn("effect/schema/Cause",$e,({annotations:e,typeParameters:t})=>{let n=fy(t[0],t[1]);return e===void 0?n:n.annotate(e)});function O2(e,t){return(n,r)=>{let o=k2(e,t)(n,r),i=n.constant(sL),a=n.array(o.arbitrary).map(hg);return Tu(n,r,i,a)}}s(O2,"causeToArbitrary");function R2(e,t){let n=e$(A2(e,t));return(r,o)=>n(r.reasons,o.reasons)}s(R2,"causeToEquivalence");function $2(e,t){let n=C2(e,t);return r=>`Cause([${r.reasons.map(n).join(", ")}])`}s($2,"causeToFormatter");var lQ=dr(e=>{if(!Sr(e))return!1;let t=globalThis.Object.keys(e);return t.length>0&&t.every(n=>(n==="includeStack"||n==="excludeCause")&&e[n]===!0)}),fQ=pt([$e,lQ]),P2=s(e=>(e?.includeStack===!0?1:0)|(e?.excludeCause===!0?2:0),"getErrorOptionsKey"),N2=s(e=>{switch(e){case 0:return;case 1:return{includeStack:!0};case 2:return{excludeCause:!0};case 3:return{includeStack:!0,excludeCause:!0}}},"getErrorOptions"),sG=[];function D2(e){let t=P2(e),n=sG[t];if(n!==void 0)return n;let r=N2(t),o=ei(globalThis.Error,{representation:{id:"effect/schema/Error",payload:r??null},toCode:s(()=>({runtime:r!==void 0?`Schema.ErrorInstance(${z(r)})`:"Schema.ErrorInstance()",Type:"globalThis.Error"}),"toCode"),expected:"Error",toCodecJson:s(()=>qe()(ete,mM(r)),"toCodecJson"),toArbitrary:s(()=>i=>i.string().map(a=>new globalThis.Error(a)),"toArbitrary")});return sG[t]=o,o}s(D2,"ErrorInstance");var dQ=Rn("effect/schema/Error",fQ,({annotations:e,payload:t})=>{let n=D2(t??void 0);return e===void 0?n:n.annotate(e)}),iG=[];function pQ(e){let t=P2(e),n=iG[t];if(n!==void 0)return n;let r=wy.pipe(ae(IC,hM(N2(t))));return iG[t]=r,r}s(pQ,"Defect");function L2(e,t,n){let r=Hn()([e,t,n],([o,i,a])=>{let c=fy(i,a);return(l,u,f)=>{if(!aL(l))return W(new et(u,l,f));switch(l._tag){case"Success":return Ct(ut(o)(l.value,f),{onSuccess:qi,onFailure:s(d=>kn(u,"value",d,l,f),"onFailure")});case"Failure":return Ct(ut(c)(l.cause,f),{onSuccess:Bo,onFailure:s(d=>kn(u,"cause",d,l,f),"onFailure")})}}},{representation:{id:"effect/schema/Exit",payload:null},toCode:s(({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"']}),"toCode"),expected:"Exit",toCodec:s(([o,i,a])=>qe()(pt([K({_tag:Ye("Success"),value:o}),K({_tag:Ye("Failure"),cause:fy(i,a)})]),We({decode:s(c=>c._tag==="Success"?qi(c.value):Bo(c.cause),"decode"),encode:s(c=>Jt(c)?{_tag:"Success",value:c.value}:{_tag:"Failure",cause:c.cause},"encode")})),"toCodec"),toArbitrary:s(([o,i,a])=>(c,l)=>{let u=O2(i,a)(c,l),f=F2(c,o.terminal?.map(p=>qi(p)),u.terminal?.map(p=>Bo(p))),d=c.oneof(o.arbitrary.map(p=>qi(p)),u.arbitrary.map(p=>Bo(p)));return Tu(c,l,f,d)},"toArbitrary"),toEquivalence:s(([o,i,a])=>{let c=R2(i,a);return(l,u)=>{if(l._tag!==u._tag)return!1;switch(l._tag){case"Success":return o(l.value,u.value);case"Failure":return c(l.cause,u.cause)}}},"toEquivalence"),toFormatter:s(([o,i,a])=>{let c=$2(i,a);return l=>{switch(l._tag){case"Success":return`Exit.Success(${o(l.value)})`;case"Failure":return`Exit.Failure(${c(l.cause)})`}}},"toFormatter")});return Z(r.ast,{value:e,error:t,defect:n})}s(L2,"Exit");var mQ=Rn("effect/schema/Exit",$e,({annotations:e,typeParameters:t})=>{let n=L2(t[0],t[1],t[2]);return e===void 0?n:n.annotate(e)});function F2(e,t,n){return t===void 0?n:n===void 0?t:e.oneof(t,n)}s(F2,"oneOfArbitraries");function Tu(e,t,n,r){return{arbitrary:n===void 0||t.recursion===void 0?r:e.oneof(t.recursion,n,r),terminal:n}}s(Tu,"withRecursion");function aG(e,t,n,r){return r===void 0?e.array(t,n):e.uniqueArray(t,{...n,comparator:r})}s(aG,"arrayFromItems");function vy(e,t,n,r,o,i){let a=t.constraint,c=a===void 0||a.minLength===void 0&&a.maxLength===void 0?void 0:{...a.minLength!==void 0?{minLength:a.minLength}:{},...a.maxLength!==void 0?{maxLength:a.maxLength}:{}};if(c?.minLength!==void 0&&c.maxLength!==void 0&&c.minLength>c.maxLength)throw new globalThis.Error("Unable to derive an arbitrary for size constraints");let l=c?.minLength??0,u=l===0?e.constant([]):r===void 0?void 0:aG(e,r,{...c,maxLength:l},i),f=Tu(e,t,u,aG(e,n,c,i));return{arbitrary:f.arbitrary.map(o),terminal:f.terminal?.map(o)}}s(vy,"collectionArbitrary");function z2(e,t,n,r,o){return vy(e,t,e.tuple(n.arbitrary,r.arbitrary),n.terminal===void 0||r.terminal===void 0?void 0:e.tuple(n.terminal,r.terminal),o,([i],[a])=>re(i,a))}s(z2,"entriesArbitrary");function M2(e,t){let n=Hn()([e,t],([r,o])=>{let i=dt(vu([r,o]));return(a,c,l)=>a instanceof globalThis.Map?Ct(ut(i)([...a],l),{onSuccess:s(u=>new globalThis.Map(u),"onSuccess"),onFailure:s(u=>kn(c,"entries",u,a,l),"onFailure")}):W(new et(c,a,l))},{representation:{id:"effect/schema/ReadonlyMap",payload:null},toCode:s(({typeParameters:r})=>({runtime:`Schema.ReadonlyMap(${r[0].runtime}, ${r[1].runtime})`,Type:`globalThis.ReadonlyMap<${r[0].Type}, ${r[1].Type}>`}),"toCode"),expected:"ReadonlyMap",toCodec:s(([r,o])=>qe()(dt(vu([r,o])),We({decode:s(i=>new globalThis.Map(i),"decode"),encode:s(i=>[...i.entries()],"encode")})),"toCodec"),toArbitrary:s(([r,o])=>(i,a)=>z2(i,a,r,o,c=>new globalThis.Map(c)),"toArbitrary"),toEquivalence:s(([r,o])=>Ym(r,o),"toEquivalence"),toFormatter:s(([r,o])=>i=>{let a=i.size;if(a===0)return"ReadonlyMap(0) {}";let c=globalThis.Array.from(i.entries()).sort().map(([l,u])=>`${r(l)} => ${o(u)}`);return`ReadonlyMap(${a}) { ${c.join(", ")} }`},"toFormatter")});return Z(n.ast,{key:e,value:t})}s(M2,"ReadonlyMap");var hQ=Rn("effect/schema/ReadonlyMap",$e,({annotations:e,typeParameters:t})=>{let n=M2(t[0],t[1]);return e===void 0?n:n.annotate(e)});function U2(e,t){let n=Hn()([e,t],([r,o])=>{let i=dt(vu([r,o]));return(a,c,l)=>RU(a)?Ct(ut(i)(Bx(a),l),{onSuccess:qx,onFailure:s(u=>kn(c,"entries",u,a,l),"onFailure")}):W(new et(c,a,l))},{representation:{id:"effect/schema/HashMap",payload:null},toCode:s(({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"']}),"toCode"),expected:"HashMap",toCodec:s(([r,o])=>qe()(dt(vu([r,o])),We({decode:qx,encode:Bx})),"toCodec"),toArbitrary:s(([r,o])=>(i,a)=>z2(i,a,r,o,qx),"toArbitrary"),toEquivalence:s(([r,o])=>Ym(r,o),"toEquivalence"),toFormatter:s(([r,o])=>i=>{let a=$U(i);if(a===0)return"HashMap(0) {}";let c=Bx(i).sort().map(([l,u])=>`${r(l)} => ${o(u)}`);return`HashMap(${a}) { ${c.join(", ")} }`},"toFormatter")});return Z(n.ast,{key:e,value:t})}s(U2,"HashMap");var gQ=Rn("effect/schema/HashMap",$e,({annotations:e,typeParameters:t})=>{let n=U2(t[0],t[1]);return e===void 0?n:n.annotate(e)});function G2(e){let t=Hn()([e],([n])=>{let r=dt(n);return(o,i,a)=>o instanceof globalThis.Set?Ct(ut(r)([...o],a),{onSuccess:s(c=>new globalThis.Set(c),"onSuccess"),onFailure:s(c=>kn(i,"values",c,o,a),"onFailure")}):W(new et(i,o,a))},{representation:{id:"effect/schema/ReadonlySet",payload:null},toCode:s(({typeParameters:n})=>({runtime:`Schema.ReadonlySet(${n[0].runtime})`,Type:`globalThis.ReadonlySet<${n[0].Type}>`}),"toCode"),expected:"ReadonlySet",toCodec:s(([n])=>qe()(dt(n),We({decode:s(r=>new globalThis.Set(r),"decode"),encode:s(r=>[...r.values()],"encode")})),"toCodec"),toArbitrary:s(([n])=>(r,o)=>vy(r,o,n.arbitrary,n.terminal,i=>new globalThis.Set(i),re),"toArbitrary"),toEquivalence:s(([n])=>Xm(n),"toEquivalence"),toFormatter:s(([n])=>r=>{let o=r.size;if(o===0)return"ReadonlySet(0) {}";let i=globalThis.Array.from(r.values()).sort().map(a=>`${n(a)}`);return`ReadonlySet(${o}) { ${i.join(", ")} }`},"toFormatter")});return Z(t.ast,{value:e})}s(G2,"ReadonlySet");var xQ=Rn("effect/schema/ReadonlySet",$e,({annotations:e,typeParameters:t})=>{let n=G2(t[0]);return e===void 0?n:n.annotate(e)});function j2(e){let t=Hn()([e],([n])=>{let r=dt(n);return(o,i,a)=>FU(o)?Ct(ut(r)(Kt(o),a),{onSuccess:Hx,onFailure:s(c=>kn(i,"values",c,o,a),"onFailure")}):W(new et(i,o,a))},{representation:{id:"effect/schema/HashSet",payload:null},toCode:s(({typeParameters:n})=>({runtime:`Schema.HashSet(${n[0].runtime})`,Type:`HashSet.HashSet<${n[0].Type}>`}),"toCode"),expected:"HashSet",toCodec:s(([n])=>qe()(dt(n),We({decode:Hx,encode:Kt})),"toCodec"),toArbitrary:s(([n])=>(r,o)=>vy(r,o,n.arbitrary,n.terminal,Hx,re),"toArbitrary"),toEquivalence:s(([n])=>Xm(n),"toEquivalence"),toFormatter:s(([n])=>r=>{let o=zU(r);if(o===0)return"HashSet(0) {}";let i=globalThis.Array.from(r).sort().map(a=>`${n(a)}`);return`HashSet(${o}) { ${i.join(", ")} }`},"toFormatter")});return Z(t.ast,{value:e})}s(j2,"HashSet");var yQ=Rn("effect/schema/HashSet",$e,({annotations:e,typeParameters:t})=>{let n=j2(t[0]);return e===void 0?n:n.annotate(e)});function Z2(e){let t=Hn()([e],([n])=>{let r=dt(n);return(o,i,a)=>Mx(o)?Ct(ut(r)(Kt(o),a),{onSuccess:Ux,onFailure:s(c=>kn(i,"values",c,o,a),"onFailure")}):W(new et(i,o,a))},{representation:{id:"effect/schema/Chunk",payload:null},toCode:s(({typeParameters:n})=>({runtime:`Schema.Chunk(${n[0].runtime})`,Type:`Chunk.Chunk<${n[0].Type}>`}),"toCode"),expected:"Chunk",toCodec:s(([n])=>qe()(dt(n),We({decode:Ux,encode:Kt})),"toCodec"),toArbitrary:s(([n])=>(r,o)=>vy(r,o,n.arbitrary,n.terminal,Ux),"toArbitrary"),toEquivalence:s(([n])=>BA(n),"toEquivalence"),toFormatter:s(([n])=>r=>{let o=SU(r);if(o===0)return"Chunk(0) {}";let i=globalThis.Array.from(r).sort().map(a=>`${n(a)}`);return`Chunk(${o}) { ${i.join(", ")} }`},"toFormatter")});return Z(t.ast,{value:e})}s(Z2,"Chunk");var SQ=Rn("effect/schema/Chunk",$e,({annotations:e,typeParameters:t})=>{let n=Z2(t[0]);return e===void 0?n:n.annotate(e)}),q2=ei(globalThis.RegExp,{representation:{id:"effect/schema/RegExp",payload:null},toCode:s(()=>({runtime:"Schema.RegExp",Type:"globalThis.RegExp"}),"toCode"),expected:"RegExp",toCodecJson:s(()=>qe()(K({source:ce,flags:ce}),ir({decode:s((e,t)=>Xc({try:s(()=>new globalThis.RegExp(e.source,e.flags),"try"),catch:s(()=>new Ee({expected:"valid RegExp source and flags"},e,t),"catch")}),"decode"),encode:s(e=>se({source:e.source,flags:e.flags}),"encode")})),"toCodecJson"),toArbitrary:s(()=>e=>e.tuple(e.constantFrom(".",".*","\\d+","\\w+","[a-z]+","[A-Z]+","[0-9]+","^[a-zA-Z0-9]+$","^\\d{4}-\\d{2}-\\d{2}$"),e.uniqueArray(e.constantFrom("g","i","m","s","u","y"),{minLength:0,maxLength:6}).map(t=>t.join(""))).map(([t,n])=>new globalThis.RegExp(t,n)),"toArbitrary"),toEquivalence:s(()=>(e,t)=>e.source===t.source&&e.flags===t.flags,"toEquivalence")}),bQ=Yt("effect/schema/RegExp",q2),B2=ce.annotate({expected:"a string that will be decoded as a URL"}),zC=ei(globalThis.URL,{representation:{id:"effect/schema/URL",payload:null},toCode:s(()=>({runtime:"Schema.URL",Type:"globalThis.URL"}),"toCode"),expected:"URL",toCodecJson:s(()=>qe()(B2,Qk),"toCodecJson"),toArbitrary:s(()=>e=>e.webUrl().map(t=>new globalThis.URL(t)),"toArbitrary"),toEquivalence:s(()=>(e,t)=>e.toString()===t.toString(),"toEquivalence")}),vQ=Yt("effect/schema/URL",zC),_Q=B2.pipe(ae(zC,Qk));function MC(e,t,n){let r={...t};if(e?.minimum!==void 0){let o=n===void 0?e.minimum:n(e.minimum),i=e.exclusiveMinimum?new globalThis.Date(o.getTime()+1):o;(r.min===void 0||i.getTime()>r.min.getTime())&&(r.min=i)}if(e?.maximum!==void 0){let o=n===void 0?e.maximum:n(e.maximum),i=e.exclusiveMaximum?new globalThis.Date(o.getTime()-1):o;(r.max===void 0||i.getTime()<r.max.getTime())&&(r.max=i)}return r}s(MC,"dateArbitraryConstraints");var V2=ce.annotate({expected:"a string that will be decoded as a Date"}),jr=dr(e=>e instanceof globalThis.Date&&!globalThis.Number.isNaN(e.getTime()),{representation:{id:"effect/schema/Date",payload:null},toCode:s(()=>({runtime:"Schema.Date",Type:"globalThis.Date"}),"toCode"),expected:"a valid Date",toCodecJson:s(()=>qe()(V2,Xk),"toCodecJson"),toArbitrary:s(()=>(e,t)=>e.date(MC(t?.constraint?.ordered?.order===$i?t.constraint.ordered:void 0,{noInvalidDate:!0})),"toArbitrary")}),wQ=Yt("effect/schema/Date",jr),EQ=V2.pipe(ae(jr,Xk)),IQ=Ta.pipe(ae(jr,aM)),Cd=dr($h,{representation:{id:"effect/schema/Duration",payload:null},toCode:s(()=>({runtime:"Schema.Duration",Type:"Duration.Duration",importDeclarations:['import * as Duration from "effect/Duration"']}),"toCode"),expected:"Duration",toCodecJson:s(()=>qe()(pt([K({_tag:Ye("Infinity")}),K({_tag:Ye("NegativeInfinity")}),K({_tag:Ye("Nanos"),value:go}),K({_tag:Ye("Millis"),value:Ta})]),We({decode:s(e=>{switch(e._tag){case"Infinity":return lt;case"NegativeInfinity":return Ft;case"Nanos":return Un(e.value);case"Millis":return wr(e.value)}},"decode"),encode:s(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}}},"encode")})),"toCodecJson"),toArbitrary:s(()=>e=>e.oneof(e.constant(lt),e.constant(Ft),e.bigInt().map(Un),e.maxSafeInteger().map(wr)),"toArbitrary"),toFormatter:s(()=>globalThis.String,"toFormatter"),toEquivalence:s(()=>Ph,"toEquivalence")}),TQ=Yt("effect/schema/Duration",Cd),kQ=ce.annotate({expected:"a string that will be decoded as a Duration"}),AQ=kQ.pipe(ae(Cd,cM)),CQ=go.pipe(ae(Cd,uM)),OQ=gy.pipe(ae(Cd,lM)),H2=ce.annotate({expected:"a string that will be decoded as a BigDecimal"}),K2=20,J2="Unable to derive an arbitrary for the ordered BigDecimal constraints";function dy(e,t){return Ps(e,t).value}s(dy,"bigDecimalScaleValueAtScale");function RQ(e,t,n){return n?dy(VE(e,t),t)+globalThis.BigInt(1):dy(BE(e,t),t)}s(RQ,"bigDecimalMinValueAtScale");function $Q(e,t,n){return n?dy(BE(e,t),t)-globalThis.BigInt(1):dy(VE(e,t),t)}s($Q,"bigDecimalMaxValueAtScale");function PQ(e){return Math.max(K2,e.minimum?.scale??0,e.maximum?.scale??0,e.exclusiveMinimum&&e.minimum!==void 0?e.minimum.scale+1:0,e.exclusiveMaximum&&e.maximum!==void 0?e.maximum.scale+1:0)}s(PQ,"bigDecimalMaxScale");function _C(e,t){let n={};if(e.minimum!==void 0&&(n.min=RQ(e.minimum,t,e.exclusiveMinimum===!0)),e.maximum!==void 0&&(n.max=$Q(e.maximum,t,e.exclusiveMaximum===!0)),!(n.min!==void 0&&n.max!==void 0&&n.min>n.max))return n}s(_C,"bigDecimalValueConstraintsAtScale");function NQ(e){let t=PQ(e);if(_C(e,t)===void 0)throw new globalThis.Error(J2);let n=0,r=t;for(;n<r;){let o=n+Math.floor((r-n)/2);_C(e,o)===void 0?n=o+1:r=o}return{min:n,max:t}}s(NQ,"bigDecimalScaleConstraints");var UC=dr(_h,{representation:{id:"effect/schema/BigDecimal",payload:null},toCode:s(()=>({runtime:"Schema.BigDecimal",Type:"BigDecimal.BigDecimal",importDeclarations:['import * as BigDecimal from "effect/BigDecimal"']}),"toCode"),expected:"BigDecimal",toCodecJson:s(()=>qe()(H2,eA),"toCodecJson"),toArbitrary:s(()=>(e,t)=>{let n=t.constraint?.ordered?.order===Lo?t.constraint.ordered:void 0;return n===void 0?e.tuple(e.bigInt(),e.integer({min:0,max:K2})).map(([r,o])=>_n(r,o)):e.integer(NQ(n)).chain(r=>{let o=_C(n,r);if(o===void 0)throw new globalThis.Error(J2);return e.bigInt(o).map(i=>_n(i,r))})},"toArbitrary"),toFormatter:s(()=>e=>eo(e),"toFormatter"),toEquivalence:s(()=>ZE,"toEquivalence")}),DQ=Yt("effect/schema/BigDecimal",UC),LQ=H2.pipe(ae(UC,eA)),FQ=ce.annotate({expected:"a string that will be decoded as JSON",contentMediaType:"application/json"});function W2(e,t){return FQ.pipe(ae(e,IM(t)))}s(W2,"fromJsonString");var zQ=W2(IC),GC=ei(globalThis.File,{representation:{id:"effect/schema/File",payload:null},toCode:s(()=>({runtime:"Schema.File",Type:"globalThis.File"}),"toCode"),expected:"File",toCodecJson:s(()=>qe()(K({data:ce.check($C()),type:ce,name:ce,lastModified:Ta}),ir({decode:s((e,t)=>vn(ru(e.data),{onFailure:s(()=>W(new Ee({expected:"a valid Base64 string"},e.data,t)),"onFailure"),onSuccess:s(n=>{let r=new globalThis.Uint8Array(n);return se(new globalThis.File([r],e.name,{type:e.type,lastModified:e.lastModified}))},"onSuccess")}),"decode"),encode:s((e,t)=>ik({try:s(async()=>{let n=new globalThis.Uint8Array(await e.arrayBuffer());return{data:dx(n),type:e.type,name:e.name,lastModified:e.lastModified}},"try"),catch:s(()=>new Ee({expected:"a readable File"},e,t),"catch")}),"encode")})),"toCodecJson")}),MQ=Yt("effect/schema/File",GC),jC=ei(globalThis.FormData,{representation:{id:"effect/schema/FormData",payload:null},toCode:s(()=>({runtime:"Schema.FormData",Type:"globalThis.FormData"}),"toCode"),expected:"FormData",toCodecJson:s(()=>qe()(dt(vu([ce,pt([K({_tag:Ea("String"),value:ce}),K({_tag:Ea("File"),value:GC})])])),ir({decode:s(e=>{let t=new globalThis.FormData;for(let[n,r]of e)t.append(n,r.value);return se(t)},"decode"),encode:s(e=>se(globalThis.Array.from(e.entries()).map(([t,n])=>typeof n=="string"?[t,{_tag:"String",value:n}]:[t,{_tag:"File",value:n}])),"encode")})),"toCodecJson")}),UQ=Yt("effect/schema/FormData",jC);function GQ(e){return jC.pipe(ae(e,TM))}s(GQ,"fromFormData");var ZC=ei(globalThis.URLSearchParams,{representation:{id:"effect/schema/URLSearchParams",payload:null},toCode:s(()=>({runtime:"Schema.URLSearchParams",Type:"globalThis.URLSearchParams"}),"toCode"),expected:"URLSearchParams",toCodecJson:s(()=>qe()(ce.annotate({expected:"a query string that will be decoded as URLSearchParams"}),We({decode:s(e=>new globalThis.URLSearchParams(e),"decode"),encode:s(e=>e.toString(),"encode")})),"toCodecJson")}),jQ=Yt("effect/schema/URLSearchParams",ZC);function ZQ(e){return ZC.pipe(ae(e,kM))}s(ZQ,"fromURLSearchParams");var qQ=ce.annotate({expected:"a string that will be decoded as a number"}).pipe(ae(gy,su)),BQ=ce.annotate({expected:"a string that will be decoded as a finite number"}).pipe(ae(Gr,su)),VQ=Z(UA).pipe(ae(go,bx)),Y2=ce.check(RC()),HQ=ce.annotate({expected:"a string that will be decoded as a trimmed string"}).pipe(ae(Y2,iM())),KQ=ce.annotate({expected:"a base64 encoded string that will be decoded as a UTF-8 string"}).pipe(ae(ce,vM)),JQ=ce.annotate({expected:"a base64 (URL) encoded string that will be decoded as a UTF-8 string"}).pipe(ae(ce,_M)),WQ=ce.annotate({expected:"a hex encoded string that will be decoded as a UTF-8 string"}).pipe(ae(ce,wM)),YQ=ce.annotate({expected:"a URI component encoded string that will be decoded as a UTF-8 string"}).pipe(ae(ce,EM)),wC=pt([Gr,TG,ce]),XQ=K({issues:dt(K({message:ce,path:fr(dt(pt([wC,K({key:wC})])))}))}),QQ=xy([0,1]).pipe(ae(IG,We({decode:s(e=>e===1,"decode"),encode:s(e=>e?1:0,"encode")}))),X2=ce.annotate({expected:"a base64 encoded string that will be decoded as Uint8Array",format:"byte",contentEncoding:"base64"}),Od=ei(globalThis.Uint8Array,{representation:{id:"effect/schema/Uint8Array",payload:null},toCode:s(()=>({runtime:"Schema.Uint8Array",Type:"globalThis.Uint8Array"}),"toCode"),expected:"Uint8Array",toCodecJson:s(()=>qe()(X2,tA),"toCodecJson"),toArbitrary:s(()=>e=>e.uint8Array(),"toArbitrary")}),eee=Yt("effect/schema/Uint8Array",Od),tee=X2.pipe(ae(Od,tA)),nee=ce.annotate({expected:"a base64 (URL) encoded string that will be decoded as a Uint8Array"}).pipe(ae(Od,{decode:Kz(),encode:hx()})),ree=ce.annotate({expected:"a hex encoded string that will be decoded as a Uint8Array"}).pipe(ae(Od,{decode:Wz(),encode:gx()})),Rd=dr(e=>ax(e)&&Ok(e),{representation:{id:"effect/schema/DateTimeUtc",payload:null},toCode:s(()=>({runtime:"Schema.DateTimeUtc",Type:"DateTime.Utc",importDeclarations:['import * as DateTime from "effect/DateTime"']}),"toCode"),expected:"DateTime.Utc",toCodecJson:s(()=>qe()(ce,oA),"toCodecJson"),toArbitrary:s(()=>(e,t)=>e.date(MC(t?.constraint?.ordered?.order===ux?t.constraint.ordered:void 0,{noInvalidDate:!0},Zf)).map(n=>$k(n)),"toArbitrary"),toFormatter:s(()=>e=>e.toString(),"toFormatter"),toEquivalence:s(()=>cx,"toEquivalence")}),oee=Yt("effect/schema/DateTimeUtc",Rd),see=jr.pipe(ae(Rd,{decode:Yk(),encode:xe(Zf)})),iee=ce.annotate({expected:"a string that will be decoded as a DateTime.Utc"}).pipe(ae(Rd,oA)),aee=Ta.pipe(ae(Rd,{decode:Yk(),encode:xe(zk)})),Q2=dr(Ak,{representation:{id:"effect/schema/TimeZoneOffset",payload:null},toCode:s(()=>({runtime:"Schema.TimeZoneOffset",Type:"DateTime.TimeZone.Offset",importDeclarations:['import * as DateTime from "effect/DateTime"']}),"toCode"),expected:"DateTime.TimeZone.Offset",toCodecJson:s(()=>qe()(Ta,AM),"toCodecJson"),toArbitrary:s(()=>e=>e.integer({min:-720*60*1e3,max:840*60*1e3}).map(t=>ua(t)),"toArbitrary"),toFormatter:s(()=>e=>Wo(e),"toFormatter"),toEquivalence:s(()=>(e,t)=>e.offset===t.offset,"toEquivalence")}),cee=Yt("effect/schema/TimeZoneOffset",Q2),ej=ce.annotate({expected:"an IANA time zone identifier"}),qC=dr(Ck,{representation:{id:"effect/schema/TimeZoneNamed",payload:null},toCode:s(()=>({runtime:"Schema.TimeZoneNamed",Type:"DateTime.TimeZone.Named",importDeclarations:['import * as DateTime from "effect/DateTime"']}),"toCode"),expected:"DateTime.TimeZone.Named",toCodecJson:s(()=>qe()(ej,nA),"toCodecJson"),toArbitrary:s(()=>e=>e.constantFrom(...["UTC","Europe/London","America/New_York","Asia/Tokyo","Australia/Sydney"].map(lx)),"toArbitrary"),toFormatter:s(()=>e=>Wo(e),"toFormatter"),toEquivalence:s(()=>(e,t)=>e.id===t.id,"toEquivalence")}),uee=Yt("effect/schema/TimeZoneNamed",qC),lee=ej.pipe(ae(qC,nA)),tj=ce.annotate({expected:"a time zone string (IANA identifier or offset like +03:00)"}),BC=dr(kk,{representation:{id:"effect/schema/TimeZone",payload:null},toCode:s(()=>({runtime:"Schema.TimeZone",Type:"DateTime.TimeZone",importDeclarations:['import * as DateTime from "effect/DateTime"']}),"toCode"),expected:"DateTime.TimeZone",toCodecJson:s(()=>qe()(tj,rA),"toCodecJson"),toArbitrary:s(()=>e=>e.oneof(e.integer({min:-720*60*1e3,max:840*60*1e3}).map(t=>ua(t)),e.constantFrom(...["UTC","Europe/London","America/New_York","Asia/Tokyo","Australia/Sydney"].map(lx))),"toArbitrary"),toFormatter:s(()=>e=>Wo(e),"toFormatter"),toEquivalence:s(()=>(e,t)=>Wo(e)===Wo(t),"toEquivalence")}),fee=Yt("effect/schema/TimeZone",BC),dee=tj.pipe(ae(BC,rA)),nj=ce.annotate({expected:"a zoned DateTime string (e.g. 2024-01-01T00:00:00.000+00:00[Europe/London])"}),VC=dr(e=>ax(e)&&Rk(e),{representation:{id:"effect/schema/DateTimeZoned",payload:null},toCode:s(()=>({runtime:"Schema.DateTimeZoned",Type:"DateTime.Zoned",importDeclarations:['import * as DateTime from "effect/DateTime"']}),"toCode"),expected:"DateTime.Zoned",toCodecJson:s(()=>qe()(nj,sA),"toCodecJson"),toArbitrary:s(()=>(e,t)=>e.tuple(e.date(MC(t?.constraint?.ordered?.order===ux?t.constraint.ordered:void 0,{max:new globalThis.Date(864e13-840*60*1e3),min:new globalThis.Date(-864e13+840*60*1e3),noInvalidDate:!0},Zf)),e.constantFrom("UTC","Europe/London","America/New_York","Asia/Tokyo","Australia/Sydney")).map(([n,r])=>Pk(n,{timeZone:r})),"toArbitrary"),toFormatter:s(()=>e=>qf(e),"toFormatter"),toEquivalence:s(()=>cx,"toEquivalence")}),pee=Yt("effect/schema/DateTimeZoned",VC),mee=nj.pipe(ae(VC,sA)),hee=globalThis.Symbol.for("immer-draftable"),EC={};function HC(e,t,n,r,o){let i=xee(n,t,r),a=rj(t),c=class extends e{static{s(this,"out")}constructor(...[l,u]){let d=u?.["~payload"],p=d?.token===EC?d.value:n.make(l??{},u);super(p,{...u,disableChecks:!0,"~payload":{token:EC,value:p}})}static[vd]=vd;get[a](){return a}static[hee]=!0;static identifier=t;static fields=n.fields;static get ast(){return i(this).ast}static pipe(){return be(this,arguments)}static rebuild(l){return i(this).rebuild(l)}static make(l,u){return new this(l,u)}static makeOption(l,u){return Jx(i(this))(l??{},u)}static makeEffect(l,u){return i(this).makeEffect(l??{},u)}static annotate(l){return this.rebuild(cr(this.ast,l))}static annotateKey(l){return this.rebuild(rd(this.ast,l))}static check(...l){return this.rebuild(Dr(this.ast,l))}static extend(l){return(u,f)=>{let d=$d(u)?u:K(u),p={...n.fields,...d.fields},m=Cx(p,n.ast.checks,{identifier:l});return HC(this,l,kC(Dr(m,d.ast.checks),p),f,o)}}static mapFields(l,u){return n.mapFields(l,u)}};return o!==void 0&&Object.assign(c.prototype,o(t)),c}s(HC,"makeClass");function gee(e){return new Re(xe(t=>new e(t,{"~payload":{token:EC,value:t}})),$r())}s(gee,"getClassTransformation");function rj(e){return`~effect/Schema/Class/${e}`}s(rj,"getClassTypeId");function xee(e,t,n){let r;return o=>{if(r!==void 0)return r;let i=rj(t),a=s(u=>u instanceof o||U(u,i),"isClassValue"),c=gee(o),l=Z(new fa([e.ast],()=>(u,f,d)=>a(u)?se(u):W(new et(f,u,d)),{identifier:t,[ex]:([u])=>({isConstructed:a,link:new He(u,c)}),toCodec:s(([u])=>new He(u.ast,c),"toCodec"),toArbitrary:s(([u])=>()=>({arbitrary:u.arbitrary.map(f=>new o(f)),terminal:u.terminal?.map(f=>new o(f))}),"toArbitrary"),toFormatter:s(([u])=>f=>`${o.identifier}(${u(f)})`,"toFormatter"),[Nf]:Xf(e.ast),...n}));return r=ae(l,c)(e)}}s(xee,"getClassSchemaFactory");function $d(e){return hy(e)}s($d,"isStruct");var oj=s(e=>(t,n)=>{let r=$d(t)?t:K(t);return HC(RL,e,r,n,o=>({toString(){return`${o}(${z({...this})})`}}))},"Class"),yee=s(e=>(t,n,r)=>{let o=$d(n)?n.mapFields(i=>({_tag:Ea(t),...i}),{unsafePreserveChecks:!0}):Sy(t,n);return oj(e??t)(o,r)},"TaggedClass"),sj=s(e=>(t,n)=>{let r=$d(t)?t:K(t);return HC(lh,e,r,n,i=>({name:i}))},"Error"),See=s(e=>(t,n,r)=>{let o=$d(n)?n.mapFields(i=>({_tag:Ea(t),...i}),{unsafePreserveChecks:!0}):Sy(t,n);return sj(e??t)(o,r)},"TaggedError");function bee(e){let t=I1(e.ast);return n=>t(n,{})}s(bee,"toArbitrary");function vee(e){return t=>t.annotate({toFormatter:e})}s(vee,"overrideToFormatter");function _ee(e,t){return n(e.ast);function n(o){let i=Ho(o)?.toFormatter;if(typeof i=="function")return i(mo(o)?o.typeParameters.map(n):[]);if(t?.onBefore){let a=t.onBefore(o,n);if(a!==void 0)return a}return r(o)}function r(o){switch(o._tag){default:return z;case"Never":return()=>"never";case"Void":return()=>"void";case"Arrays":{let i=o.elements.map(n),a=o.rest.map(n);return c=>{let l=[],u=0;for(;u<i.length;u++)if(c.length<u+1){if(it(o.elements[u]))continue}else l.push(i[u](c[u]));if(a.length>0){let[f,...d]=a;for(;u<c.length-d.length;u++)l.push(f(c[u]));for(let p=0;p<d.length;p++)l.push(d[p](c[u+p]))}return"["+l.join(", ")+"]"}}case"Objects":{let i=o.propertySignatures.map(c=>n(c.type)),a=o.indexSignatures.map(c=>n(c.type));return o.propertySignatures.length===0&&o.indexSignatures.length===0?z:c=>{let l=[],u=new Set;for(let f=0;f<i.length;f++){let d=o.propertySignatures[f],p=d.name;u.add(p),!(it(d.type)&&!Object.hasOwn(c,p))&&l.push(`${Ao(p)}: ${i[f](c[p])}`)}for(let f=0;f<a.length;f++){let d=da(c,o.indexSignatures[f].parameter);for(let p of d)u.has(p)||(u.add(p),l.push(`${Ao(p)}: ${a[f](c[p])}`))}return l.length>0?"{ "+l.join(", ")+" }":"{}"}}case"Union":{let i=jt(o).types,a=s(l=>Qf(l,i),"getCandidates"),c=new Map(i.map((l,u)=>[l,[fd(l),n(o.types[u])]]));return l=>{let u=a(l);for(let f=0;f<u.length;f++){let[d,p]=c.get(u[f]);if(d(l))return p(l)}return z(l)}}case"Suspend":{let i=ha(()=>n(o.thunk()));return a=>i()(a)}}}}s(_ee,"toFormatter");function wee(e){return t=>t.annotate({toEquivalence:e})}s(wee,"overrideToEquivalence");function Eee(e){return T1(e.ast)}s(Eee,"toEquivalence");function Iee(e){return pC(e.ast)}s(Iee,"toRepresentation");function ij(e,t){let n=pC(_y(e.ast),P1);return L1(n,t)}s(ij,"toJsonSchemaDocument");function aj(e){return Z(_y(e.ast),{schema:e})}s(aj,"toCodecJson");var _y=ga(e=>{let t=kee(e,_y),n=e.context;return t===e||n===void 0?t:Dx(t,KC(n))});function KC(e){return e.constructorDefault===void 0?e:new ar(e.isOptional,e.isMutable,void 0,e.annotations)}s(KC,"withoutConstructorDefault");function cj(e){if(e.propertySignatures.some(t=>typeof t.name!="string"))throw new globalThis.Error("Objects property names must be strings",{cause:e})}s(cj,"validateCanonicalObjectPropertyNames");function uj(e){return t=>{let n=new Map;for(let i=0;i<t.length;i++)n.set(On(t[i]),i);let r=[...t].sort((i,a)=>{i=On(i),a=On(a);let c=e(i),l=e(a);return c!==l?c-l:n.get(i)-n.get(a)});return r.some((i,a)=>i!==t[a])?r:t}}s(uj,"makeReorder");var Tee=uj(e=>{switch(e._tag){case"BigInt":case"Symbol":case"UniqueSymbol":return 0;default:return 1}});function kee(e,t){switch(e._tag){case"Declaration":{let n=e.annotations?.toCodecJson??e.annotations?.toCodec;if(!Sn(n))return Ge(e,[jA]);let r=e.typeParameters.map(i=>pd(On(i))),o=n(r);return o===void 0?e:Ge(e,[fu(o,t)])}case"Unknown":return Ge(e,[jA]);case"ObjectKeyword":return Ge(e,[gU]);case"Undefined":case"Void":case"Literal":case"Number":return e.toCodecJson();case"UniqueSymbol":case"Symbol":case"BigInt":return e.toCodecStringTree();case"Objects":return cj(e),e.recur(t,zx);case"Union":{let n=Tee(e.types);return n!==e.types?new dn(n,e.mode,e.annotations,e.checks,e.encoding,e.context,e.encodingChecks).recur(t):e.recur(t)}case"Arrays":case"Suspend":return e.recur(t)}return e}s(kee,"toCodecJsonASTStep");function lj(e){return Z(fj(jt(e.ast)))}s(lj,"toCodecIso");var fj=Bt(e=>{let t=Aee(e,fj);return t!==e&&e.context!==void 0?Dx(t,KC(e.context)):t});function Aee(e,t){switch(e._tag){case"Declaration":{let n=e.annotations?.toCodecIso??e.annotations?.toCodec;if(Sn(n)){let r=n(e.typeParameters.map(o=>pd(o)));return Ge(e,[fu(r,t)])}return e}case"Arrays":case"Objects":case"Union":case"Suspend":return e.recur(t)}return e}s(Aee,"toCodecIsoASTStep");function dj(e){return Z(hj(e.ast),{schema:e})}s(dj,"toCodecStringTree");function Cee(e){return Z(gj(e.ast))}s(Cee,"toCodecArrayFromSingle");function Oee(e,t){let n=sa(e.ast)??_k(e.ast),r=SG(dj(e));return o=>r(o).pipe(Of(i=>Ree(i,{rootName:n,...t})))}s(Oee,"toEncoderXml");function Ree(e,t){let n=t.rootName??"root",r=t.arrayItemName??"item",o=t.pretty??!0,i=t.indent??" ",a=t.sortKeys??!0,c=new Set,l=[];return f(n,e,0),l.join(o?`
|
|
94
|
+
`:"");function u(d,p){l.push(o?i.repeat(d)+p:p)}s(u,"push");function f(d,p,m,h){let{attrs:x,safe:S}=bu.tagInfo(d,h);if(p===void 0)u(m,`<${S}${x}/>`);else if(typeof p=="string")u(m,`<${S}${x}>${bu.escapeText(p)}</${S}>`);else if(typeof p!="object"||p===null)u(m,`<${S}${x}>${bu.escapeText(z(p))}</${S}>`);else{if(c.has(p))throw new globalThis.Error("Cycle detected while serializing to XML.",{cause:p});c.add(p);try{if(globalThis.globalThis.Array.isArray(p)){if(p.length===0){u(m,`<${S}${x}/>`);return}u(m,`<${S}${x}>`);for(let v of p)f(r,v,m+1);u(m,`</${S}>`);return}let T=p,b=Object.keys(T);if(a&&b.sort(),b.length===0){u(m,`<${S}${x}/>`);return}u(m,`<${S}${x}>`);for(let v of b)f(bu.parseTagName(v).safe,T[v],m+1,v);u(m,`</${S}>`)}finally{c.delete(p)}}}s(f,"recur")}s(Ree,"stringTreeToXml");var bu={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;return/^[A-Za-z_]/.test(n)||(n="_"+n),n=n.replace(/[^A-Za-z0-9._-]/g,"_"),/^xml/i.test(n)&&(n="_"+n),{safe:n,changed:n!==t}},tagInfo(e,t){let{changed:n,safe:r}=bu.parseTagName(e),i=n||t&&t!==e?` data-name="${bu.escapeAttribute(t??e)}"`:"";return{safe:r,attrs:i}}},$ee=uj(e=>{switch(e._tag){case"Null":case"Boolean":case"Number":case"BigInt":case"Symbol":case"UniqueSymbol":return 0;default:return 1}});function Pee(e,t,n){switch(e._tag){case"Declaration":{let r=e.typeParameters.map(u=>Z(t(On(u)))),o=e.annotations?.toCodecStringTree;if(Sn(o)){let u=o(r);return u===void 0?e:Ge(e,[fu(u,t)])}let i=e.annotations?.toCodecJson,a=Sn(i)?i(r):void 0,c=a===void 0?e.annotations?.toCodec:void 0,l=a??(Sn(c)?c(r):void 0);return l===void 0?n(e):Ge(e,[fu(l,t)])}case"Null":return Ge(e,[Nee]);case"Boolean":return Ge(e,[Dee]);case"Unknown":case"ObjectKeyword":return Ge(e,[ZA]);case"Enum":case"Number":case"Literal":case"UniqueSymbol":case"Symbol":case"BigInt":return e.toCodecStringTree();case"Objects":return cj(e),e.recur(t,zx);case"Union":{let r=$ee(e.types);return r!==e.types?new dn(r,e.mode,e.annotations,e.checks,e.encoding,e.context,e.encodingChecks).recur(t):e.recur(t)}case"Arrays":case"Suspend":return e.recur(t)}return e}s(Pee,"toCodecStringTreeASTStep");var Nee=new He(new Cn("null"),new Re(xe(()=>null),xe(()=>"null"))),Dee=new He(new dn([new Cn("true"),new Cn("false")],"anyOf"),new Re(xe(e=>e==="true"),la())),pj=new Re(xe(e=>typeof e=="string"?[e]:e),$r()),mj=s(e=>e.transformation===pj,"isCodecArrayFromSingleLink"),hj=ga(e=>{let t=Pee(e,hj,n=>{throw new globalThis.Error("Missing structural codec for StringTree",{cause:n})});return t!==e&&e.context!==void 0?Dx(t,KC(e.context)):t},{stopAt:mj}),cG=s(e=>it(e)?du(Qo):Qo,"toArrayFromSingleInputElement"),gj=ga(e=>{let t=Lee(e);if(IA(t)){let n=Lx(new dn([new Nr(t.isMutable,t.elements.map(cG),t.rest.map(cG)),po],"anyOf"),t,pj);return it(e)?du(n):n}return t},{stopAt:mj});function Lee(e){return e._tag==="Declaration"||e._tag==="Arrays"||e._tag==="Objects"||e._tag==="Union"||e._tag==="Suspend"?e.recur(gj):e}s(Lee,"toCodecArrayFromSingleASTStep");var Fee=le("effect/schema/isGreaterThanDate",K({exclusiveMinimum:jr}),({annotations:e,payload:t})=>a2(t.exclusiveMinimum,e)),zee=le("effect/schema/isGreaterThanOrEqualToDate",K({minimum:jr}),({annotations:e,payload:t})=>c2(t.minimum,e)),Mee=le("effect/schema/isLessThanDate",K({exclusiveMaximum:jr}),({annotations:e,payload:t})=>u2(t.exclusiveMaximum,e)),Uee=le("effect/schema/isLessThanOrEqualToDate",K({maximum:jr}),({annotations:e,payload:t})=>l2(t.maximum,e)),Gee=le("effect/schema/isBetweenDate",K({minimum:jr,maximum:jr,exclusiveMinimum:fr(Ye(!0)),exclusiveMaximum:fr(Ye(!0))}),({annotations:e,payload:t})=>f2(t,e)),jee=le("effect/schema/isGreaterThanBigInt",K({exclusiveMinimum:go}),({annotations:e,payload:t})=>d2(t.exclusiveMinimum,e)),Zee=le("effect/schema/isGreaterThanOrEqualToBigInt",K({minimum:go}),({annotations:e,payload:t})=>p2(t.minimum,e)),qee=le("effect/schema/isLessThanBigInt",K({exclusiveMaximum:go}),({annotations:e,payload:t})=>m2(t.exclusiveMaximum,e)),Bee=le("effect/schema/isLessThanOrEqualToBigInt",K({maximum:go}),({annotations:e,payload:t})=>h2(t.maximum,e)),Vee=le("effect/schema/isBetweenBigInt",K({minimum:go,maximum:go,exclusiveMinimum:fr(Ye(!0)),exclusiveMaximum:fr(Ye(!0))}),({annotations:e,payload:t})=>g2(t,e));function Hee(e){let t=lj(e);return B1(aC(t),sC(t))}s(Hee,"toIso");function Kee(e){return uy()}s(Kee,"toIsoSource");function Jee(e){return uy()}s(Jee,"toIsoFocus");function Wee(e,t){return n=>Z(cr(n.ast,{toCodecIso:s(()=>new He(e.ast,yx(t)),"toCodecIso")}),{schema:n})}s(Wee,"overrideToCodecIso");function Yee(e){let t=aj(e),n=aC(t),r=sC(t);return{empty:[],diff:s((o,i)=>M1(n(o),n(i)),"diff"),combine:s((o,i)=>[...o,...i],"combine"),patch:s((o,i)=>{let a=n(o),c=U1(i,a);return Object.is(c,a)?o:r(c)},"patch")}}s(Yee,"toDifferJsonPatch");function Xee(e){let t=RG(()=>n),n=pt([e,dt(t),kG(ce,t)]);return n}s(Xee,"Tree");var wy=Z(cr(uu,{toCode:s(()=>({runtime:"Schema.Json",Type:"Schema.Json"}),"toCode")})),Qee=Yt("effect/schema/Json",wy),ete=K({message:ce,name:wa(ce),stack:wa(ce),cause:wa(wy)}),xj=Z(cr(hU,{toCode:s(()=>({runtime:"Schema.MutableJson",Type:"Schema.MutableJson"}),"toCode")})),tte=Yt("effect/schema/MutableJson",xj);function nte(e){return Ho(e.ast)}s(nte,"resolveAnnotations");function rte(e){return e.ast.context?.annotations}s(rte,"resolveAnnotationsKey");var Ey={};$t(Ey,{isManagedRuntime:()=>ote,make:()=>ste});var JC="~effect/ManagedRuntime",ote=s(e=>U(e,JC),"isManagedRuntime"),ste=s((e,t)=>{let n=t?.memoMap??qs(),r=bg("parallel"),o=Zc(r,"sequential"),i={onFiberStart:_U(r)},a=s(f=>f?{...f,onFiberStart:f.onFiberStart?d=>{i.onFiberStart(d),f.onFiberStart(d)}:i.onFiberStart}:i,"mergeRunOptions"),c,l=Kg(f=>(c||(c=eu(Jg(Ji(e,n,o),d=>Wc(()=>{u.cachedContext=d})),{...i,scheduler:f.currentScheduler})),uk(vU(c)))),u={[JC]:JC,memoMap:n,scope:r,contextEffect:l,cachedContext:void 0,context(){return u.cachedContext===void 0?Rf(u.contextEffect):Promise.resolve(u.cachedContext)},dispose(){return Rf(u.disposeEffect)},[Symbol.asyncDispose](){return u.dispose()},disposeEffect:Vg(()=>(u.contextEffect=Hg("ManagedRuntime disposed"),u.cachedContext=void 0,Sf(u.scope,js))),runFork(f,d){return u.cachedContext===void 0?eu(ku(u,f),a(d)):pk(u.cachedContext)(f,a(d))},runCallback(f,d){return u.cachedContext===void 0?hk(ku(u,f),a(d)):mk(u.cachedContext)(f,a(d))},runSyncExit(f){return u.cachedContext===void 0?uo(ku(u,f)):bk(u.cachedContext)(f)},runSync(f){return u.cachedContext===void 0?yk(ku(u,f)):Sk(u.cachedContext)(f)},runPromiseExit(f,d){return u.cachedContext===void 0?tu(ku(u,f),a(d)):xk(u.cachedContext)(f,a(d))},runPromise(f,d){return u.cachedContext===void 0?Rf(ku(u,f),a(d)):gk(u.cachedContext)(f,a(d))}};return u},"make");function ku(e,t){return In(e.contextEffect,n=>fk(t,n))}s(ku,"provide");var Oy=["active","paused","waiting","completed","blocked","canceled"],ite=["edit","pause","resume","cancel"],ate=["manual","archived","failure","usage-limit","no-progress"],WC=["subscription-window","credits","spend-control","unknown"],cte=["tool-call","file-mutation","external-action","pending-interaction","changed-assistant-result"],ute=P.Struct({continuationId:P.String,requestEventId:P.String,requestSeq:P.Int,requestId:P.String,acceptedEventId:P.String,acceptedSeq:P.Int,turnId:P.String,terminalEventId:P.String,terminalSeq:P.Int,signals:P.Array(P.Literals(cte)),assistantResultFingerprint:P.NullOr(P.String),previousAssistantResultFingerprint:P.NullOr(P.String),assessment:P.Literals(["progress","no-progress"]),observedAt:P.String}),lte=[...ite,"complete","block"],yj=20,ka=100,Sj=P.Struct({id:P.String,threadId:P.String,objective:P.String,state:P.Literals(Oy),revision:P.Int,createdAt:P.String,updatedAt:P.String,finishedAt:P.NullOr(P.String),completionSummary:P.NullOr(P.String),verificationEvidence:P.NullOr(P.String),blockageExternalAction:P.NullOr(P.String),blockageEvidence:P.NullOr(P.String),blockageRepeatedTurns:P.NullOr(P.Int),pauseReasonCode:P.NullOr(P.Literals(ate)),pauseReason:P.NullOr(P.String),usageLimitKind:P.NullOr(P.Literals(WC)),usageResetAt:P.NullOr(P.String),noProgressConsecutiveCount:P.Int,noProgressLastContinuationId:P.NullOr(P.String),noProgressAssistantResultFingerprint:P.NullOr(P.String),noProgressEvidence:P.NullOr(ute)}),Iy=class extends P.TaggedError()("GoalAlreadyExists",{threadId:P.String,goalId:P.String}){static{s(this,"GoalAlreadyExists")}},rs=class extends P.TaggedError()("GoalNotFound",{threadId:P.String,goalId:P.String}){static{s(this,"GoalNotFound")}},os=class extends P.TaggedError()("GoalStaleGuard",{goalId:P.String,expectedRevision:P.Int,actualRevision:P.Int}){static{s(this,"GoalStaleGuard")}},Au=class extends P.TaggedError()("GoalInvalidTransition",{goalId:P.String,action:P.Literals(lte),state:P.Literals(Oy)}){static{s(this,"GoalInvalidTransition")}},Cu=class extends P.TaggedError()("GoalThreadNotFound",{threadId:P.String}){static{s(this,"GoalThreadNotFound")}},Ty=class extends P.TaggedError()("GoalThreadArchived",{threadId:P.String}){static{s(this,"GoalThreadArchived")}},ky=class extends P.TaggedError()("GoalRecordNotFound",{goalId:P.String}){static{s(this,"GoalRecordNotFound")}},Ou=class extends P.TaggedError()("GoalInvalidCursor",{message:P.String}){static{s(this,"GoalInvalidCursor")}},Ay=class extends P.TaggedError()("GoalInvalidHistoryQuery",{message:P.String}){static{s(this,"GoalInvalidHistoryQuery")}},Pd=class extends P.TaggedError()("GoalInvalidObjective",{message:P.String}){static{s(this,"GoalInvalidObjective")}},Cy=class extends P.TaggedError()("GoalInvalidCompletion",{message:P.String}){static{s(this,"GoalInvalidCompletion")}},ni=class extends P.TaggedError()("GoalInvalidBlockage",{message:P.String}){static{s(this,"GoalInvalidBlockage")}},Ke=class extends P.TaggedError()("GoalPersistenceError",{message:P.String}){static{s(this,"GoalPersistenceError")}},pr=class extends P.TaggedError()("GoalGatewayError",{message:P.String}){static{s(this,"GoalGatewayError")}};function bj(e){switch(e._tag){case"GoalAlreadyExists":return{code:"goal_already_exists",message:`Thread ${e.threadId} already has unfinished Goal ${e.goalId}.`};case"GoalNotFound":return{code:"goal_not_found",message:`Goal ${e.goalId} was not found on thread ${e.threadId}.`};case"GoalStaleGuard":return{code:"stale_goal",message:`Goal ${e.goalId} changed from revision ${e.expectedRevision} to ${e.actualRevision}. Refresh and retry.`};case"GoalInvalidTransition":return{code:"invalid_transition",message:`Cannot ${e.action} Goal ${e.goalId} while it is ${e.state}.`};case"GoalThreadNotFound":return{code:"thread_not_found",message:`Thread ${e.threadId} was not found.`};case"GoalThreadArchived":return{code:"thread_archived",message:`Thread ${e.threadId} is archived. Unarchive it before starting or resuming a Goal.`};case"GoalRecordNotFound":return{code:"goal_not_found",message:`Goal ${e.goalId} was not found.`};case"GoalInvalidCursor":return{code:"invalid_cursor",message:e.message};case"GoalInvalidHistoryQuery":return{code:"invalid_arguments",message:e.message};case"GoalInvalidObjective":return{code:"invalid_objective",message:e.message};case"GoalInvalidCompletion":return{code:"invalid_completion",message:e.message};case"GoalInvalidBlockage":return{code:"invalid_blockage",message:e.message};case"GoalPersistenceError":return{code:"persistence_error",message:e.message};case"GoalGatewayError":return{code:"gateway_error",message:e.message}}}s(bj,"goalErrorToDto");var fte=P.Struct({version:P.Literals([1]),threadId:P.NonEmptyString,sequence:P.Int.check(P.isGreaterThan(0))}),dte=P.decodeUnknownSync(fte);function vj(e){return Buffer.from(JSON.stringify({version:1,...e}),"utf8").toString("base64url")}s(vj,"encodeGoalHistoryCursor");var _j=$.fn("decodeGoalHistoryCursor")(e=>$.try({try:s(()=>{let t=Buffer.from(e,"base64url");if(t.length===0||t.toString("base64url")!==e)throw new Error("Cursor is not canonical base64url.");let n=dte(JSON.parse(t.toString("utf8")));return{threadId:n.threadId,sequence:n.sequence}},"try"),catch:s(()=>new Ou({message:"The Goal history cursor is invalid or expired."}),"catch")}));var Ej=[`CREATE TABLE IF NOT EXISTS goals (
|
|
95
|
+
id TEXT PRIMARY KEY,
|
|
96
|
+
thread_id TEXT NOT NULL,
|
|
97
|
+
objective TEXT NOT NULL CHECK (length(objective) > 0),
|
|
98
|
+
state TEXT NOT NULL CHECK (state IN ('active', 'paused', 'waiting', 'completed', 'blocked', 'canceled')),
|
|
99
|
+
revision INTEGER NOT NULL CHECK (revision >= 1),
|
|
100
|
+
created_at TEXT NOT NULL,
|
|
101
|
+
updated_at TEXT NOT NULL,
|
|
102
|
+
finished_at TEXT
|
|
103
|
+
)`,`CREATE UNIQUE INDEX IF NOT EXISTS goals_one_unfinished_per_thread
|
|
104
|
+
ON goals(thread_id)
|
|
105
|
+
WHERE finished_at IS NULL`,`CREATE TABLE IF NOT EXISTS goal_history_order (
|
|
106
|
+
goal_id TEXT PRIMARY KEY,
|
|
107
|
+
thread_id TEXT NOT NULL,
|
|
108
|
+
sequence INTEGER NOT NULL CHECK (sequence >= 1),
|
|
109
|
+
UNIQUE(thread_id, sequence)
|
|
110
|
+
);
|
|
111
|
+
INSERT OR IGNORE INTO goal_history_order (goal_id, thread_id, sequence)
|
|
112
|
+
SELECT id, thread_id,
|
|
113
|
+
ROW_NUMBER() OVER (PARTITION BY thread_id ORDER BY created_at, rowid)
|
|
114
|
+
FROM goals;
|
|
115
|
+
CREATE TABLE IF NOT EXISTS goal_history_counters (
|
|
116
|
+
thread_id TEXT PRIMARY KEY,
|
|
117
|
+
last_sequence INTEGER NOT NULL CHECK (last_sequence >= 1)
|
|
118
|
+
);
|
|
119
|
+
INSERT INTO goal_history_counters (thread_id, last_sequence)
|
|
120
|
+
SELECT thread_id, MAX(sequence)
|
|
121
|
+
FROM goal_history_order
|
|
122
|
+
GROUP BY thread_id
|
|
123
|
+
ON CONFLICT(thread_id) DO UPDATE SET
|
|
124
|
+
last_sequence = MAX(last_sequence, excluded.last_sequence);
|
|
125
|
+
CREATE INDEX IF NOT EXISTS goals_history_by_thread
|
|
126
|
+
ON goal_history_order(thread_id, sequence DESC)`,`ALTER TABLE goals ADD COLUMN completion_summary TEXT;
|
|
127
|
+
ALTER TABLE goals ADD COLUMN verification_evidence TEXT`,`ALTER TABLE goals ADD COLUMN blockage_external_action TEXT;
|
|
128
|
+
ALTER TABLE goals ADD COLUMN blockage_evidence TEXT;
|
|
129
|
+
ALTER TABLE goals ADD COLUMN blockage_repeated_turns INTEGER`,`CREATE TABLE IF NOT EXISTS goal_blockage_qualifications (
|
|
130
|
+
goal_id TEXT PRIMARY KEY,
|
|
131
|
+
thread_id TEXT NOT NULL,
|
|
132
|
+
goal_revision INTEGER NOT NULL CHECK (goal_revision >= 1),
|
|
133
|
+
blocker_key TEXT NOT NULL,
|
|
134
|
+
external_action TEXT NOT NULL,
|
|
135
|
+
evidence TEXT NOT NULL,
|
|
136
|
+
repeated_turns INTEGER NOT NULL CHECK (repeated_turns >= 1),
|
|
137
|
+
updated_at TEXT NOT NULL
|
|
138
|
+
)`,`CREATE TABLE IF NOT EXISTS goal_continuations (
|
|
139
|
+
id TEXT PRIMARY KEY,
|
|
140
|
+
thread_id TEXT NOT NULL,
|
|
141
|
+
goal_id TEXT NOT NULL,
|
|
142
|
+
goal_revision INTEGER NOT NULL CHECK (goal_revision >= 1),
|
|
143
|
+
opportunity_key TEXT NOT NULL,
|
|
144
|
+
attempt INTEGER NOT NULL CHECK (attempt >= 0),
|
|
145
|
+
state TEXT NOT NULL CHECK (state IN ('pending', 'claimed', 'sending', 'resolved')),
|
|
146
|
+
outcome TEXT CHECK (outcome IS NULL OR outcome IN ('sent', 'released', 'expired')),
|
|
147
|
+
lease_expires_at TEXT,
|
|
148
|
+
outcome_reason TEXT,
|
|
149
|
+
created_at TEXT NOT NULL,
|
|
150
|
+
updated_at TEXT NOT NULL,
|
|
151
|
+
UNIQUE(thread_id, opportunity_key)
|
|
152
|
+
);
|
|
153
|
+
CREATE INDEX IF NOT EXISTS goal_continuations_pending
|
|
154
|
+
ON goal_continuations(state, lease_expires_at, created_at)`,"ALTER TABLE goal_continuations ADD COLUMN delivery_marker TEXT",`ALTER TABLE goals ADD COLUMN pause_reason_code TEXT;
|
|
155
|
+
ALTER TABLE goals ADD COLUMN pause_reason TEXT;
|
|
156
|
+
ALTER TABLE goals ADD COLUMN usage_limit_kind TEXT;
|
|
157
|
+
ALTER TABLE goals ADD COLUMN usage_reset_at TEXT`,`CREATE TABLE IF NOT EXISTS goal_failure_events (
|
|
158
|
+
thread_id TEXT NOT NULL,
|
|
159
|
+
event_id TEXT NOT NULL,
|
|
160
|
+
event_seq INTEGER CHECK (event_seq IS NULL OR event_seq >= 0),
|
|
161
|
+
event_created_at INTEGER NOT NULL,
|
|
162
|
+
observed_at TEXT NOT NULL,
|
|
163
|
+
PRIMARY KEY (thread_id, event_id)
|
|
164
|
+
);
|
|
165
|
+
CREATE INDEX IF NOT EXISTS goal_failure_events_by_sequence
|
|
166
|
+
ON goal_failure_events(thread_id, event_seq DESC)`,"ALTER TABLE goal_failure_events ADD COLUMN turn_id TEXT",`ALTER TABLE goals ADD COLUMN no_progress_consecutive_count INTEGER NOT NULL DEFAULT 0;
|
|
167
|
+
ALTER TABLE goals ADD COLUMN no_progress_last_continuation_id TEXT;
|
|
168
|
+
ALTER TABLE goals ADD COLUMN no_progress_assistant_result_fingerprint TEXT;
|
|
169
|
+
ALTER TABLE goals ADD COLUMN no_progress_evidence_json TEXT;
|
|
170
|
+
ALTER TABLE goal_continuations ADD COLUMN progress_assessed_at TEXT;
|
|
171
|
+
ALTER TABLE goal_continuations ADD COLUMN progress_evidence_json TEXT;
|
|
172
|
+
CREATE INDEX IF NOT EXISTS goal_continuations_unassessed_sent
|
|
173
|
+
ON goal_continuations(outcome, progress_assessed_at, created_at)`];var Aa=class extends st.Service()("bb-plugin-goal/GoalRepository"){static{s(this,"GoalRepository")}},pte=P.decodeUnknownSync(Sj);function wj(e){return e}s(wj,"decodeContinuation");function Ru(e){return pte({...e,noProgressEvidence:e.noProgressEvidence===null?null:JSON.parse(e.noProgressEvidence)})}s(Ru,"decodeGoalRow");function at(e){return e instanceof Error?e.message:String(e)}s(at,"messageFromCause");function mte(e){return e.trim().replace(/\s+/g," ").toLocaleLowerCase()}s(mte,"normalizeBlocker");function hte(e,t){switch(t){case"edit":case"cancel":return e.finishedAt===null;case"complete":case"block":return e.state==="active";case"pause":return e.state==="active"||e.state==="waiting";case"resume":return e.state==="paused"||e.state==="waiting"}}s(hte,"permitsMutation");function gte(e){return e instanceof rs||e instanceof os||e instanceof Au||e instanceof ni?e:new Ke({message:`Could not mutate Goal state: ${at(e)}`})}s(gte,"mutationErrorFromCause");function xte(e){return e instanceof rs||e instanceof os?e:new Ke({message:`Could not delete Goal: ${at(e)}`})}s(xte,"deleteErrorFromCause");var Nd=`SELECT
|
|
174
|
+
id,
|
|
175
|
+
thread_id AS threadId,
|
|
176
|
+
objective,
|
|
177
|
+
state,
|
|
178
|
+
revision,
|
|
179
|
+
created_at AS createdAt,
|
|
180
|
+
updated_at AS updatedAt,
|
|
181
|
+
finished_at AS finishedAt,
|
|
182
|
+
completion_summary AS completionSummary,
|
|
183
|
+
verification_evidence AS verificationEvidence,
|
|
184
|
+
blockage_external_action AS blockageExternalAction,
|
|
185
|
+
blockage_evidence AS blockageEvidence,
|
|
186
|
+
blockage_repeated_turns AS blockageRepeatedTurns,
|
|
187
|
+
pause_reason_code AS pauseReasonCode,
|
|
188
|
+
pause_reason AS pauseReason,
|
|
189
|
+
usage_limit_kind AS usageLimitKind,
|
|
190
|
+
usage_reset_at AS usageResetAt,
|
|
191
|
+
no_progress_consecutive_count AS noProgressConsecutiveCount,
|
|
192
|
+
no_progress_last_continuation_id AS noProgressLastContinuationId,
|
|
193
|
+
no_progress_assistant_result_fingerprint AS noProgressAssistantResultFingerprint,
|
|
194
|
+
no_progress_evidence_json AS noProgressEvidence
|
|
195
|
+
FROM goals`;function Ij(e){let t=e.prepare(`${Nd}
|
|
196
|
+
WHERE thread_id = ? AND finished_at IS NULL
|
|
197
|
+
ORDER BY created_at DESC
|
|
198
|
+
LIMIT 1`);return{current(n){let r=t.get(n);return r===void 0?null:Ru(r)}}}s(Ij,"makeCurrentGoalSnapshotReader");function Tj(e){return ft.effect(Aa,$.sync(()=>{let t=e.prepare(`${Nd}
|
|
199
|
+
WHERE thread_id = ? AND finished_at IS NULL
|
|
200
|
+
ORDER BY created_at DESC
|
|
201
|
+
LIMIT 1`),n=`SELECT
|
|
202
|
+
goals.id,
|
|
203
|
+
goals.thread_id AS threadId,
|
|
204
|
+
goals.objective,
|
|
205
|
+
goals.state,
|
|
206
|
+
goals.revision,
|
|
207
|
+
goals.created_at AS createdAt,
|
|
208
|
+
goals.updated_at AS updatedAt,
|
|
209
|
+
goals.finished_at AS finishedAt,
|
|
210
|
+
goals.completion_summary AS completionSummary,
|
|
211
|
+
goals.verification_evidence AS verificationEvidence,
|
|
212
|
+
goals.blockage_external_action AS blockageExternalAction,
|
|
213
|
+
goals.blockage_evidence AS blockageEvidence,
|
|
214
|
+
goals.blockage_repeated_turns AS blockageRepeatedTurns,
|
|
215
|
+
goals.pause_reason_code AS pauseReasonCode,
|
|
216
|
+
goals.pause_reason AS pauseReason,
|
|
217
|
+
goals.usage_limit_kind AS usageLimitKind,
|
|
218
|
+
goals.usage_reset_at AS usageResetAt,
|
|
219
|
+
goals.no_progress_consecutive_count AS noProgressConsecutiveCount,
|
|
220
|
+
goals.no_progress_last_continuation_id AS noProgressLastContinuationId,
|
|
221
|
+
goals.no_progress_assistant_result_fingerprint AS noProgressAssistantResultFingerprint,
|
|
222
|
+
goals.no_progress_evidence_json AS noProgressEvidence,
|
|
223
|
+
goal_history_order.sequence AS historySequence
|
|
224
|
+
FROM goals
|
|
225
|
+
INNER JOIN goal_history_order
|
|
226
|
+
ON goal_history_order.goal_id = goals.id`,r=e.prepare(`${Nd} WHERE id = ? AND thread_id = ? LIMIT 1`),o=e.prepare(`${Nd} WHERE id = ? LIMIT 1`),i=e.prepare(`${n}
|
|
227
|
+
WHERE goal_history_order.thread_id = ?
|
|
228
|
+
ORDER BY goal_history_order.sequence DESC
|
|
229
|
+
LIMIT ?`),a=e.prepare(`${n}
|
|
230
|
+
WHERE goal_history_order.thread_id = ?
|
|
231
|
+
AND goal_history_order.sequence < ?
|
|
232
|
+
ORDER BY goal_history_order.sequence DESC
|
|
233
|
+
LIMIT ?`),c=e.prepare(`INSERT INTO goal_history_counters (thread_id, last_sequence)
|
|
234
|
+
VALUES (?, 1)
|
|
235
|
+
ON CONFLICT(thread_id) DO UPDATE SET
|
|
236
|
+
last_sequence = last_sequence + 1
|
|
237
|
+
RETURNING last_sequence AS sequence`),l=e.prepare(`INSERT INTO goal_history_order (goal_id, thread_id, sequence)
|
|
238
|
+
VALUES (?, ?, ?)`),u=e.prepare(`INSERT INTO goals (
|
|
239
|
+
id, thread_id, objective, state, revision,
|
|
240
|
+
created_at, updated_at, finished_at
|
|
241
|
+
) VALUES (?, ?, ?, 'active', 1, ?, ?, NULL)`),f=e.prepare(`UPDATE goals
|
|
242
|
+
SET objective = ?, revision = revision + 1, updated_at = ?,
|
|
243
|
+
no_progress_consecutive_count = 0,
|
|
244
|
+
no_progress_last_continuation_id = NULL,
|
|
245
|
+
no_progress_assistant_result_fingerprint = NULL,
|
|
246
|
+
no_progress_evidence_json = NULL
|
|
247
|
+
WHERE id = ? AND thread_id = ? AND revision = ? AND finished_at IS NULL`),d=e.prepare(`UPDATE goals
|
|
248
|
+
SET state = 'paused', revision = revision + 1, updated_at = ?,
|
|
249
|
+
pause_reason_code = 'manual', pause_reason = 'Paused by user',
|
|
250
|
+
usage_limit_kind = NULL, usage_reset_at = NULL
|
|
251
|
+
WHERE id = ? AND thread_id = ? AND revision = ?
|
|
252
|
+
AND state IN ('active', 'waiting') AND finished_at IS NULL`),p=e.prepare(`UPDATE goals
|
|
253
|
+
SET state = 'active', revision = revision + 1, updated_at = ?,
|
|
254
|
+
pause_reason_code = NULL, pause_reason = NULL,
|
|
255
|
+
usage_limit_kind = NULL, usage_reset_at = NULL,
|
|
256
|
+
no_progress_consecutive_count = 0,
|
|
257
|
+
no_progress_last_continuation_id = NULL,
|
|
258
|
+
no_progress_assistant_result_fingerprint = NULL,
|
|
259
|
+
no_progress_evidence_json = NULL
|
|
260
|
+
WHERE id = ? AND thread_id = ? AND revision = ? AND state IN ('paused', 'waiting') AND finished_at IS NULL`),m=e.prepare(`UPDATE goals
|
|
261
|
+
SET state = ?, revision = revision + 1, updated_at = ?,
|
|
262
|
+
pause_reason_code = ?, pause_reason = ?, usage_limit_kind = ?,
|
|
263
|
+
usage_reset_at = ?
|
|
264
|
+
WHERE id = ? AND thread_id = ?
|
|
265
|
+
AND (
|
|
266
|
+
state = 'active' OR
|
|
267
|
+
(state IN ('paused', 'waiting')
|
|
268
|
+
AND pause_reason_code IN ('failure', 'usage-limit'))
|
|
269
|
+
)
|
|
270
|
+
AND finished_at IS NULL`),h=e.prepare(`INSERT OR IGNORE INTO goal_failure_events (
|
|
271
|
+
thread_id, event_id, event_seq, event_created_at, turn_id, observed_at
|
|
272
|
+
) VALUES (?, ?, ?, ?, ?, ?)`),x=e.prepare(`SELECT MAX(event_seq) AS eventSeq FROM goal_failure_events
|
|
273
|
+
WHERE thread_id = ?`),S=e.prepare(`SELECT event_id AS eventId FROM goal_failure_events
|
|
274
|
+
WHERE thread_id = ? AND turn_id = ?
|
|
275
|
+
LIMIT 1`),T=e.prepare(`UPDATE goals
|
|
276
|
+
SET state = 'active', revision = revision + 1, updated_at = ?,
|
|
277
|
+
pause_reason_code = NULL, pause_reason = NULL,
|
|
278
|
+
usage_limit_kind = NULL, usage_reset_at = NULL
|
|
279
|
+
WHERE id = ? AND thread_id = ? AND revision = ? AND state = 'waiting'
|
|
280
|
+
AND pause_reason_code = 'usage-limit'
|
|
281
|
+
AND usage_reset_at IS NOT NULL AND usage_reset_at <= ?
|
|
282
|
+
AND finished_at IS NULL`),b=e.prepare(`${Nd} WHERE state = 'waiting'
|
|
283
|
+
AND pause_reason_code = 'usage-limit'
|
|
284
|
+
AND usage_reset_at IS NOT NULL AND usage_reset_at <= ?
|
|
285
|
+
AND finished_at IS NULL
|
|
286
|
+
ORDER BY usage_reset_at, id`),v=e.prepare(`SELECT MIN(usage_reset_at) AS usageResetAt FROM goals
|
|
287
|
+
WHERE state = 'waiting' AND pause_reason_code = 'usage-limit'
|
|
288
|
+
AND usage_reset_at IS NOT NULL AND finished_at IS NULL`),C=e.prepare(`UPDATE goals
|
|
289
|
+
SET state = 'canceled', revision = revision + 1, updated_at = ?, finished_at = ?
|
|
290
|
+
WHERE id = ? AND thread_id = ? AND revision = ? AND finished_at IS NULL`),w=e.prepare(`UPDATE goals
|
|
291
|
+
SET state = 'completed', revision = revision + 1,
|
|
292
|
+
updated_at = ?, finished_at = ?, completion_summary = ?,
|
|
293
|
+
verification_evidence = ?
|
|
294
|
+
WHERE id = ? AND thread_id = ? AND revision = ?
|
|
295
|
+
AND state = 'active' AND finished_at IS NULL`),I=e.prepare(`UPDATE goals
|
|
296
|
+
SET state = 'blocked', revision = revision + 1,
|
|
297
|
+
updated_at = ?, finished_at = ?, blockage_external_action = ?,
|
|
298
|
+
blockage_evidence = ?, blockage_repeated_turns = ?
|
|
299
|
+
WHERE id = ? AND thread_id = ? AND revision = ?
|
|
300
|
+
AND state = 'active' AND finished_at IS NULL`),A=e.prepare(`SELECT goal_revision AS goalRevision,
|
|
301
|
+
blocker_key AS blockerKey, repeated_turns AS repeatedTurns
|
|
302
|
+
FROM goal_blockage_qualifications
|
|
303
|
+
WHERE goal_id = ? AND thread_id = ?`),O=e.prepare(`INSERT INTO goal_blockage_qualifications (
|
|
304
|
+
goal_id, thread_id, goal_revision, blocker_key, external_action,
|
|
305
|
+
evidence, repeated_turns, updated_at
|
|
306
|
+
) VALUES (?, ?, ?, ?, ?, ?, ?, ?)
|
|
307
|
+
ON CONFLICT(goal_id) DO UPDATE SET
|
|
308
|
+
goal_revision = excluded.goal_revision,
|
|
309
|
+
blocker_key = excluded.blocker_key,
|
|
310
|
+
external_action = excluded.external_action,
|
|
311
|
+
evidence = excluded.evidence,
|
|
312
|
+
repeated_turns = excluded.repeated_turns,
|
|
313
|
+
updated_at = excluded.updated_at`),L=e.prepare("DELETE FROM goal_blockage_qualifications WHERE goal_id = ?"),q=e.prepare(`DELETE FROM goals
|
|
314
|
+
WHERE id = ? AND thread_id = ? AND revision = ?`),Q=e.prepare("DELETE FROM goal_history_order WHERE goal_id = ?"),E=e.prepare(`UPDATE goals
|
|
315
|
+
SET state = 'paused', revision = revision + 1, updated_at = ?,
|
|
316
|
+
pause_reason_code = 'archived',
|
|
317
|
+
pause_reason = 'Paused because the owning thread was archived',
|
|
318
|
+
usage_limit_kind = NULL, usage_reset_at = NULL
|
|
319
|
+
WHERE thread_id = ? AND state IN ('active', 'waiting')
|
|
320
|
+
AND finished_at IS NULL`),k=e.prepare(`UPDATE goal_continuations
|
|
321
|
+
SET state = 'resolved', outcome = 'released', lease_expires_at = NULL,
|
|
322
|
+
outcome_reason = 'Owning thread archived', updated_at = ?
|
|
323
|
+
WHERE thread_id = ? AND state IN ('pending', 'claimed', 'sending')`),B=e.prepare(`UPDATE goal_continuations
|
|
324
|
+
SET progress_assessed_at = ?,
|
|
325
|
+
progress_evidence_json = '{"assessment":"ignored","reason":"Owning thread archived"}',
|
|
326
|
+
updated_at = ?
|
|
327
|
+
WHERE thread_id = ? AND state = 'resolved' AND outcome = 'sent'
|
|
328
|
+
AND progress_assessed_at IS NULL`),_e=e.prepare("DELETE FROM goals WHERE thread_id = ?"),nt=e.prepare("DELETE FROM goal_history_order WHERE thread_id = ?"),yo=e.prepare("DELETE FROM goal_history_counters WHERE thread_id = ?"),vt=e.prepare("DELETE FROM goal_blockage_qualifications WHERE thread_id = ?"),Oa=e.prepare("DELETE FROM goal_continuations WHERE thread_id = ?"),Py=e.prepare("DELETE FROM goal_failure_events WHERE thread_id = ?"),Uj=e.prepare(`SELECT thread_id AS threadId FROM goals
|
|
329
|
+
UNION SELECT thread_id FROM goal_history_order
|
|
330
|
+
UNION SELECT thread_id FROM goal_history_counters
|
|
331
|
+
UNION SELECT thread_id FROM goal_blockage_qualifications
|
|
332
|
+
UNION SELECT thread_id FROM goal_continuations
|
|
333
|
+
UNION SELECT thread_id FROM goal_failure_events
|
|
334
|
+
ORDER BY threadId`),Nu=`SELECT
|
|
335
|
+
id,
|
|
336
|
+
thread_id AS threadId,
|
|
337
|
+
goal_id AS goalId,
|
|
338
|
+
goal_revision AS goalRevision,
|
|
339
|
+
opportunity_key AS opportunityKey,
|
|
340
|
+
delivery_marker AS deliveryMarker,
|
|
341
|
+
attempt,
|
|
342
|
+
state,
|
|
343
|
+
outcome,
|
|
344
|
+
lease_expires_at AS leaseExpiresAt,
|
|
345
|
+
outcome_reason AS outcomeReason,
|
|
346
|
+
created_at AS createdAt,
|
|
347
|
+
updated_at AS updatedAt,
|
|
348
|
+
progress_assessed_at AS progressAssessedAt
|
|
349
|
+
FROM goal_continuations`,Gj=e.prepare(`
|
|
350
|
+
INSERT INTO goal_continuations (
|
|
351
|
+
id, thread_id, goal_id, goal_revision, opportunity_key,
|
|
352
|
+
delivery_marker, attempt, state, outcome, lease_expires_at,
|
|
353
|
+
outcome_reason, created_at, updated_at
|
|
354
|
+
) VALUES (?, ?, ?, ?, ?, ?, 0, 'pending', NULL, NULL, NULL, ?, ?)
|
|
355
|
+
ON CONFLICT DO NOTHING
|
|
356
|
+
`),Ny=e.prepare(`${Nu} WHERE id = ?`),jj=e.prepare(`${Nu}
|
|
357
|
+
WHERE state = 'pending'
|
|
358
|
+
ORDER BY created_at, id
|
|
359
|
+
LIMIT 1`),Zj=e.prepare(`
|
|
360
|
+
UPDATE goal_continuations
|
|
361
|
+
SET state = 'pending', outcome = 'expired', lease_expires_at = NULL,
|
|
362
|
+
outcome_reason = 'claim lease expired', updated_at = ?
|
|
363
|
+
WHERE state = 'claimed' AND lease_expires_at IS NOT NULL
|
|
364
|
+
AND lease_expires_at <= ?
|
|
365
|
+
`),qj=e.prepare(`
|
|
366
|
+
${Nu}
|
|
367
|
+
WHERE state = 'sending'
|
|
368
|
+
ORDER BY updated_at, id
|
|
369
|
+
`),Bj=e.prepare(`
|
|
370
|
+
${Nu}
|
|
371
|
+
WHERE state = 'resolved' AND outcome = 'sent'
|
|
372
|
+
AND progress_assessed_at IS NULL
|
|
373
|
+
ORDER BY created_at, id
|
|
374
|
+
`),Vj=e.prepare(`
|
|
375
|
+
UPDATE goal_continuations
|
|
376
|
+
SET state = 'pending', outcome = 'expired', lease_expires_at = NULL,
|
|
377
|
+
outcome_reason = 'claim recovered after restart', updated_at = ?
|
|
378
|
+
WHERE state = 'claimed'
|
|
379
|
+
`),Hj=e.prepare(`
|
|
380
|
+
UPDATE goal_continuations
|
|
381
|
+
SET state = 'claimed', attempt = attempt + 1,
|
|
382
|
+
lease_expires_at = ?, updated_at = ?
|
|
383
|
+
WHERE id = ? AND state = 'pending'
|
|
384
|
+
`),Kj=e.prepare(`
|
|
385
|
+
UPDATE goal_continuations
|
|
386
|
+
SET state = 'sending', delivery_marker = ?, lease_expires_at = ?,
|
|
387
|
+
updated_at = ?
|
|
388
|
+
WHERE id = ? AND state = 'claimed'
|
|
389
|
+
`),Jj=e.prepare(`
|
|
390
|
+
UPDATE goal_continuations
|
|
391
|
+
SET state = 'pending', delivery_marker = ?, outcome = 'expired',
|
|
392
|
+
lease_expires_at = NULL, outcome_reason = ?, updated_at = ?
|
|
393
|
+
WHERE id = ? AND state = 'sending'
|
|
394
|
+
`),Wj=e.prepare(`
|
|
395
|
+
UPDATE goal_continuations
|
|
396
|
+
SET state = 'resolved', outcome = ?, lease_expires_at = NULL,
|
|
397
|
+
outcome_reason = ?, updated_at = ?
|
|
398
|
+
WHERE id = ? AND state IN ('claimed', 'sending')
|
|
399
|
+
`),eO=e.prepare(`UPDATE goal_continuations
|
|
400
|
+
SET progress_assessed_at = ?, progress_evidence_json = ?, updated_at = ?
|
|
401
|
+
WHERE id = ? AND state = 'resolved' AND outcome = 'sent'
|
|
402
|
+
AND progress_assessed_at IS NULL`),Yj=e.prepare(`UPDATE goals
|
|
403
|
+
SET no_progress_consecutive_count = 0,
|
|
404
|
+
no_progress_last_continuation_id = ?,
|
|
405
|
+
no_progress_assistant_result_fingerprint = ?,
|
|
406
|
+
no_progress_evidence_json = ?, updated_at = ?
|
|
407
|
+
WHERE id = ? AND thread_id = ? AND revision = ?
|
|
408
|
+
AND state = 'active' AND finished_at IS NULL`),Xj=e.prepare(`UPDATE goals
|
|
409
|
+
SET no_progress_consecutive_count = no_progress_consecutive_count + 1,
|
|
410
|
+
no_progress_last_continuation_id = ?,
|
|
411
|
+
no_progress_assistant_result_fingerprint = ?,
|
|
412
|
+
no_progress_evidence_json = ?, updated_at = ?,
|
|
413
|
+
state = CASE WHEN no_progress_consecutive_count + 1 >= 3 THEN 'paused' ELSE state END,
|
|
414
|
+
revision = CASE WHEN no_progress_consecutive_count + 1 >= 3 THEN revision + 1 ELSE revision END,
|
|
415
|
+
pause_reason_code = CASE WHEN no_progress_consecutive_count + 1 >= 3 THEN 'no-progress' ELSE pause_reason_code END,
|
|
416
|
+
pause_reason = CASE WHEN no_progress_consecutive_count + 1 >= 3 THEN 'Paused after 3 consecutive automatic Continuations made no observable progress' ELSE pause_reason END
|
|
417
|
+
WHERE id = ? AND thread_id = ? AND revision = ?
|
|
418
|
+
AND state = 'active' AND finished_at IS NULL`),Qj=e.prepare(`UPDATE goal_continuations
|
|
419
|
+
SET state = 'resolved', outcome = 'released', lease_expires_at = NULL,
|
|
420
|
+
outcome_reason = 'Goal paused by no-progress protection', updated_at = ?
|
|
421
|
+
WHERE goal_id = ? AND goal_revision = ?
|
|
422
|
+
AND state IN ('pending', 'claimed', 'sending')`),Zr=s(g=>{let D=t.get(g);return D===void 0?null:Ru(D)},"readCurrent"),Du=s((g,D)=>{let Ae=r.get(g,D);return Ae===void 0?null:Ru(Ae)},"readByThreadAndId"),Dy=s(g=>{let D=o.get(g);return D===void 0?null:Ru(D)},"readById"),eZ=e.transaction(g=>{let D=Zr(g.threadId);if(D!==null)return{conflict:D};try{u.run(g.id,g.threadId,g.objective,g.now,g.now)}catch(Zt){let wt=Zr(g.threadId);if(wt!==null)return{conflict:wt};throw Zt}let Ae=c.get(g.threadId);if(Ae===void 0)throw new Error("Goal history sequence was not allocated.");l.run(g.id,g.threadId,Ae.sequence);let _t=Zr(g.threadId);if(_t===null)throw new Error("Goal insert completed without a readable record.");return _t}),tZ=e.transaction(({command:g,now:D})=>{let Ae=Du(g.goalId,g.threadId);if(Ae===null)throw new rs({threadId:g.threadId,goalId:g.goalId});if(Ae.revision!==g.expectedRevision)throw new os({goalId:g.goalId,expectedRevision:g.expectedRevision,actualRevision:Ae.revision});if(!hte(Ae,g.type))throw new Au({goalId:g.goalId,action:g.type,state:Ae.state});if(g.type==="block"){let wt=A.get(g.goalId,g.threadId),Rt=wt===void 0||wt.goalRevision!==g.expectedRevision?void 0:wt,So=Rt===void 0?1:Rt.repeatedTurns+1,Lu=mte(g.externalAction);if(Rt!==void 0&&Rt.blockerKey!==Lu)throw new ni({message:"Goal Blockage requires the same external blocker across consecutive reports."});if(g.repeatedTurns!==So)throw new ni({message:`Goal Blockage report ${g.repeatedTurns} is out of sequence; expected report ${So}.`});if(O.run(g.goalId,g.threadId,g.expectedRevision,Lu,g.externalAction,g.evidence,g.repeatedTurns,D),g.repeatedTurns<3)return Ae}if((()=>{switch(g.type){case"edit":return f.run(g.objective,D,g.goalId,g.threadId,g.expectedRevision);case"pause":return d.run(D,g.goalId,g.threadId,g.expectedRevision);case"resume":return p.run(D,g.goalId,g.threadId,g.expectedRevision);case"cancel":return C.run(D,D,g.goalId,g.threadId,g.expectedRevision);case"complete":return w.run(D,D,g.summary,g.verificationEvidence,g.goalId,g.threadId,g.expectedRevision);case"block":return I.run(D,D,g.externalAction,g.evidence,g.repeatedTurns,g.goalId,g.threadId,g.expectedRevision)}})().changes!==1){let wt=Du(g.goalId,g.threadId);throw wt===null?new rs({threadId:g.threadId,goalId:g.goalId}):wt.revision!==g.expectedRevision?new os({goalId:g.goalId,expectedRevision:g.expectedRevision,actualRevision:wt.revision}):new Au({goalId:g.goalId,action:g.type,state:wt.state})}g.type!=="block"&&L.run(g.goalId);let Zt=Du(g.goalId,g.threadId);if(Zt===null)throw new Error("Goal update completed without a readable record.");return Zt}),nZ=e.transaction(g=>{let D=g.event===void 0?null:x.get(g.threadId)?.eventSeq??null,Ae=[...g.observedEvents??[],...g.event===void 0?[]:[g.event]],_t=g.event?.turnId===void 0||g.event.turnId===null?void 0:S.get(g.threadId,g.event.turnId),Zt=g.event===void 0&&_t===void 0,wt=new Set;for(let mr of Ae){if(wt.has(mr.id))continue;wt.add(mr.id);let Fd=h.run(g.threadId,mr.id,mr.seq,mr.createdAt,mr.turnId??null,g.now);g.event?.id===mr.id&&(Zt=Fd.changes===1&&_t===void 0)}let Rt=Zr(g.threadId);if(Rt===null||g.event!==void 0&&!Zt||g.event!==void 0&&g.event.seq!==null&&D!==null&&g.event.seq<=D||g.event!==void 0&&g.event.createdAt<Date.parse(Rt.createdAt)||Rt.state!=="active"&&(Rt.pauseReasonCode==="manual"||g.event===void 0))return Rt;let So=g.failure.kind==="usage-limit"&&g.failure.limitKind==="subscription-window"&&g.failure.resetAt!==null&&g.failure.resetAt>g.now;return m.run(So?"waiting":"paused",g.now,g.failure.kind==="usage-limit"?"usage-limit":"failure",g.failure.reason,g.failure.kind==="usage-limit"?g.failure.limitKind:null,So?g.failure.resetAt:null,Rt.id,g.threadId).changes!==1,Zr(g.threadId)}),rZ=e.transaction(g=>{let D=Ny.get(g.continuationId);if(D===void 0||D.progressAssessedAt!==null||D.outcome!=="sent"||D.goalId!==g.goalId||D.goalRevision!==g.goalRevision||D.threadId!==g.threadId)return Zr(g.threadId);let Ae=Zr(g.threadId),_t=Ae?.noProgressEvidence??null,Zt=Ae!==null&&Ae.id===g.goalId&&Ae.revision===g.goalRevision&&Ae.state==="active";if(!Zt||_t!==null&&g.observation.terminalSeq<=_t.terminalSeq){let OZ=JSON.stringify({assessment:"ignored",continuationId:g.continuationId,terminalEventId:g.observation.terminalEventId,terminalSeq:g.observation.terminalSeq,observedAt:g.now,reason:Zt?"A later Continuation was already assessed":"Goal identity, revision, or state changed"});return eO.run(g.now,OZ,g.now,g.continuationId),Ae}let wt=Ae.noProgressAssistantResultFingerprint,Rt=g.observation.assistantResultFingerprint!==null&&g.observation.assistantResultFingerprint!==wt,So=[...g.observation.signals,...Rt?["changed-assistant-result"]:[]],Lu={continuationId:g.continuationId,...g.observation,signals:So,previousAssistantResultFingerprint:wt,assessment:So.length>0?"progress":"no-progress",observedAt:g.now},mr=JSON.stringify(Lu),Fd=g.observation.assistantResultFingerprint??wt;if((So.length>0?Yj.run(g.continuationId,Fd,mr,g.now,g.goalId,g.threadId,g.goalRevision):Xj.run(g.continuationId,Fd,mr,g.now,g.goalId,g.threadId,g.goalRevision)).changes!==1)throw new Error("Goal changed while assessing Continuation progress.");let zd=Dy(g.goalId);if(zd!==null&&zd.pauseReasonCode==="no-progress"&&zd.noProgressConsecutiveCount===3&&Qj.run(g.now,g.goalId,g.goalRevision),eO.run(g.now,mr,g.now,g.continuationId).changes!==1)throw new Error("Continuation assessment was not recorded.");return zd}),oZ=e.transaction(g=>T.run(g.now,g.goalId,g.threadId,g.expectedRevision,g.now).changes===1?Dy(g.goalId):null),sZ=e.transaction(g=>{let D=Du(g.goalId,g.threadId);if(D===null)throw new rs({threadId:g.threadId,goalId:g.goalId});if(D.revision!==g.expectedRevision)throw new os({goalId:g.goalId,expectedRevision:g.expectedRevision,actualRevision:D.revision});if(q.run(g.goalId,g.threadId,g.expectedRevision).changes!==1){let _t=Du(g.goalId,g.threadId);throw _t===null?new rs({threadId:g.threadId,goalId:g.goalId}):new os({goalId:g.goalId,expectedRevision:g.expectedRevision,actualRevision:_t.revision})}return Q.run(g.goalId),L.run(g.goalId),D}),iZ=e.transaction(g=>(E.run(g.now,g.threadId),k.run(g.now,g.threadId),B.run(g.now,g.now,g.threadId),Zr(g.threadId))),aZ=e.transaction(g=>{Oa.run(g),vt.run(g),Py.run(g),nt.run(g),yo.run(g),_e.run(g)}),cZ=$.fn("GoalRepository.current")(g=>$.try({try:s(()=>Zr(g),"try"),catch:s(D=>new Ke({message:`Could not read Goal state: ${at(D)}`}),"catch")})),uZ=$.fn("GoalRepository.history")(g=>$.try({try:s(()=>{let D=g.limit+1,Ae=g.boundary===null?i.all(g.threadId,D):a.all(g.threadId,g.boundary.sequence,D),_t=Ae.slice(0,g.limit).map(Ru),Zt=Ae.at(g.limit-1);return{goals:_t,nextCursor:Ae.length>g.limit&&Zt!==void 0?vj({threadId:g.threadId,sequence:Zt.historySequence}):null}},"try"),catch:s(D=>new Ke({message:`Could not read Goal history: ${at(D)}`}),"catch")})),lZ=$.fn("GoalRepository.find")(g=>$.try({try:s(()=>Dy(g),"try"),catch:s(D=>new Ke({message:`Could not read Goal: ${at(D)}`}),"catch")}).pipe($.flatMap(D=>D===null?$.fail(new ky({goalId:g})):$.succeed(D)))),fZ=$.fn("GoalRepository.start")(g=>$.try({try:s(()=>eZ(g),"try"),catch:s(D=>new Ke({message:`Could not persist Goal state: ${at(D)}`}),"catch")}).pipe($.flatMap(D=>"conflict"in D?$.fail(new Iy({threadId:g.threadId,goalId:D.conflict.id})):$.succeed(D)))),dZ=$.fn("GoalRepository.mutate")(g=>$.try({try:s(()=>tZ(g),"try"),catch:gte})),pZ=$.fn("GoalRepository.delete")(g=>$.try({try:s(()=>sZ(g),"try"),catch:xte})),mZ=$.fn("GoalRepository.recordFailure")(g=>$.try({try:s(()=>nZ(g),"try"),catch:s(D=>new Ke({message:`Could not persist Goal failure: ${at(D)}`}),"catch")})),hZ=$.fn("GoalRepository.dueUsageLimits")(g=>$.try({try:s(()=>b.all(g).map(Ru),"try"),catch:s(D=>new Ke({message:`Could not read due Goal usage limits: ${at(D)}`}),"catch")})),gZ=$.fn("GoalRepository.recoverUsageLimit")(g=>$.try({try:s(()=>oZ(g),"try"),catch:s(D=>new Ke({message:`Could not recover Goal usage limit: ${at(D)}`}),"catch")})),xZ=$.fn("GoalRepository.nextUsageLimitReset")(()=>$.try({try:s(()=>v.get()?.usageResetAt??null,"try"),catch:s(g=>new Ke({message:`Could not read Goal usage resets: ${at(g)}`}),"catch")})),yZ=$.fn("GoalRepository.enqueueContinuation")(g=>$.try({try:s(()=>{let D=Gj.run(g.id,g.threadId,g.goalId,g.goalRevision,g.opportunityKey,g.deliveryMarker,g.now,g.now),Ae=Ny.get(g.id);if(Ae!==void 0)return Ae;if(D.changes===0){let _t=e.prepare(`${Nu}
|
|
423
|
+
WHERE thread_id = ? AND opportunity_key = ?`).get(g.threadId,g.opportunityKey);return _t===void 0?null:_t}throw new Error("Continuation insert completed without a readable record.")},"try"),catch:s(D=>new Ke({message:`Could not persist Continuation claim: ${at(D)}`}),"catch")})),SZ=$.fn("GoalRepository.recoverContinuations")(g=>$.try({try:s(()=>{e.transaction(()=>{Vj.run(g)})()},"try"),catch:s(D=>new Ke({message:`Could not recover Continuations: ${at(D)}`}),"catch")})),bZ=$.fn("GoalRepository.sendingContinuations")(()=>$.try({try:s(()=>qj.all().map(wj),"try"),catch:s(g=>new Ke({message:`Could not list sending Continuations: ${at(g)}`}),"catch")})),vZ=$.fn("GoalRepository.unassessedSentContinuations")(()=>$.try({try:s(()=>Bj.all().map(wj),"try"),catch:s(g=>new Ke({message:`Could not list unassessed Continuations: ${at(g)}`}),"catch")})),_Z=$.fn("GoalRepository.assessContinuation")(g=>$.try({try:s(()=>rZ(g),"try"),catch:s(D=>new Ke({message:`Could not assess Continuation progress: ${at(D)}`}),"catch")})),wZ=$.fn("GoalRepository.requeueContinuation")(g=>$.try({try:s(()=>Jj.run(g.deliveryMarker,g.reason,g.now,g.id).changes===1,"try"),catch:s(D=>new Ke({message:`Could not requeue Continuation: ${at(D)}`}),"catch")})),EZ=$.fn("GoalRepository.claimContinuation")(g=>$.try({try:s(()=>e.transaction(()=>{Zj.run(g.now,g.now);let Ae=jj.get();if(Ae===void 0||Hj.run(g.leaseExpiresAt,g.now,Ae.id).changes!==1)return null;let Zt=Ny.get(Ae.id);return Zt===void 0?null:Zt})(),"try"),catch:s(D=>new Ke({message:`Could not claim Continuation: ${at(D)}`}),"catch")})),IZ=$.fn("GoalRepository.markContinuationSending")(g=>$.try({try:s(()=>Kj.run(g.deliveryMarker,g.leaseExpiresAt,g.now,g.id).changes===1,"try"),catch:s(D=>new Ke({message:`Could not mark Continuation as sending: ${at(D)}`}),"catch")})),TZ=$.fn("GoalRepository.resolveContinuation")(g=>$.try({try:s(()=>Wj.run(g.outcome,g.reason,g.now,g.id).changes===1,"try"),catch:s(D=>new Ke({message:`Could not resolve Continuation: ${at(D)}`}),"catch")})),kZ=$.fn("GoalRepository.archiveThread")(g=>$.try({try:s(()=>iZ(g),"try"),catch:s(D=>new Ke({message:`Could not archive thread Goal state: ${at(D)}`}),"catch")})),AZ=$.fn("GoalRepository.deleteThread")(g=>$.try({try:s(()=>aZ(g),"try"),catch:s(D=>new Ke({message:`Could not delete thread Goal state: ${at(D)}`}),"catch")})),CZ=$.fn("GoalRepository.ownedThreadIds")(()=>$.try({try:s(()=>Uj.all().map(g=>g.threadId),"try"),catch:s(g=>new Ke({message:`Could not list thread-owned Goal state: ${at(g)}`}),"catch")}));return Aa.of({current:cZ,history:uZ,find:lZ,start:fZ,mutate:dZ,delete:pZ,archiveThread:kZ,deleteThread:AZ,ownedThreadIds:CZ,recordFailure:mZ,dueUsageLimits:hZ,recoverUsageLimit:gZ,nextUsageLimitReset:xZ,enqueueContinuation:yZ,recoverContinuations:SZ,sendingContinuations:bZ,requeueContinuation:wZ,claimContinuation:EZ,markContinuationSending:IZ,resolveContinuation:TZ,unassessedSentContinuations:vZ,assessContinuation:_Z})}))}s(Tj,"makeGoalRepositoryLayer");import{randomUUID as yte}from"node:crypto";function YC(e){return e.deleted===!0?{eligible:!1,reason:{code:"thread-deleted",message:"thread is deleted"}}:e.archived===!0?{eligible:!1,reason:{code:"thread-archived",message:"thread is archived"}}:e.queuedMessageCount>0?{eligible:!1,reason:{code:"queued-user-message",message:`${e.queuedMessageCount} queued user message(s)`}}:e.status!=="idle"?{eligible:!1,reason:{code:"thread-status",message:`thread status is ${e.status}`}}:e.runtimeStatus!=="idle"?{eligible:!1,reason:{code:"thread-runtime-status",message:`thread runtime status is ${e.runtimeStatus}`}}:e.activePromptMode==="plan"?{eligible:!1,reason:{code:"plan-mode",message:"Plan mode is active"}}:e.pendingInteractionCount>0?{eligible:!1,reason:{code:"pending-interaction",message:`${e.pendingInteractionCount} pending interaction(s)`}}:{eligible:!0,reason:null}}s(YC,"goalContinuationEligibility");function Ry(e){return`bb-goal-continuation:${e}`}s(Ry,"goalContinuationMarker");function Ste(e){return/^(?:continue(?: working| debugging)?|debug|investigate|keep trying|try again|none|no blocker|unknown|uncertain)$/i.test(e)}s(Ste,"isRecoverableBlocker");var $u=class extends st.Service()("bb-plugin-goal/GoalThreadGateway"){static{s(this,"GoalThreadGateway")}};function kj(e){return ft.succeed($u,$u.of({requireThread:$.fn("GoalThreadGateway.requireThread")(function*(t){if(!(yield*$.tryPromise({try:s(()=>e.threadExists(t),"try"),catch:s(r=>new pr({message:`Could not inspect thread ${t}: ${r instanceof Error?r.message:String(r)}`}),"catch")})))return yield*new Cu({threadId:t})}),readThread:$.fn("GoalThreadGateway.readThread")(function*(t,n){return e.readThread===void 0?yield*new pr({message:"The BB thread gateway cannot read thread state."}):yield*$.tryPromise({try:s(()=>e.readThread(t,n),"try"),catch:s(r=>new pr({message:`Could not read thread ${t}: ${r instanceof Error?r.message:String(r)}`}),"catch")})}),requireUnarchivedThread:$.fn("GoalThreadGateway.requireUnarchivedThread")(function*(t){if(e.readThreadOwnership===void 0)return(yield*$.tryPromise({try:s(()=>e.threadExists(t),"try"),catch:s(o=>new pr({message:`Could not inspect thread ${t}: ${o instanceof Error?o.message:String(o)}`}),"catch")}))?void 0:yield*new Cu({threadId:t});let n=yield*$.tryPromise({try:s(()=>e.readThreadOwnership(t),"try"),catch:s(r=>new pr({message:`Could not read thread ${t}: ${r instanceof Error?r.message:String(r)}`}),"catch")});if(!n.exists||n.deleted===!0)return yield*new Cu({threadId:t});if(n.archived===!0)return yield*new Ty({threadId:t})}),sendContinuation:$.fn("GoalThreadGateway.sendContinuation")(function*(t,n,r){return e.sendContinuation===void 0?yield*new pr({message:"The BB thread gateway cannot send a Continuation."}):yield*$.tryPromise({try:s(()=>e.sendContinuation(t,n,r),"try"),catch:s(o=>new pr({message:`Could not send a Continuation for thread ${t}: ${o instanceof Error?o.message:String(o)}`}),"catch")})}),reconcileContinuation:$.fn("GoalThreadGateway.reconcileContinuation")(function*(t,n,r){return e.reconcileContinuation===void 0?!1:yield*$.tryPromise({try:s(()=>e.reconcileContinuation(t,n,r),"try"),catch:s(o=>new pr({message:`Could not reconcile Continuation for thread ${t}: ${o instanceof Error?o.message:String(o)}`}),"catch")})}),observeContinuation:$.fn("GoalThreadGateway.observeContinuation")(function*(t,n,r){return e.observeContinuation===void 0?null:yield*$.tryPromise({try:s(()=>e.observeContinuation(t,n,r),"try"),catch:s(o=>new pr({message:`Could not observe Continuation for thread ${t}: ${o instanceof Error?o.message:String(o)}`}),"catch")})})}))}s(kj,"makeGoalThreadGatewayLayer");var ss=class extends st.Service()("bb-plugin-goal/GoalIdGenerator"){static{s(this,"GoalIdGenerator")}},Aj=ft.succeed(ss,ss.of({next:$.sync(()=>`goal_${yte()}`)})),is=class extends st.Service()("bb-plugin-goal/GoalClock"){static{s(this,"GoalClock")}},Cj=ft.succeed(is,is.of({nowIso:Rr.now.pipe($.map(Rr.formatIso))})),bte=30,as=class e extends st.Service()("bb-plugin-goal/GoalCoordinator"){static{s(this,"GoalCoordinator")}static layer=ft.effect(e,$.gen(function*(){let t=yield*Aa,n=yield*$u,r=yield*ss,o=yield*is,i=$.fn("GoalCoordinator.execute")(function*(u){if(u.type==="show")return{goal:yield*t.find(u.goalId)};if(u.type==="start"||u.type==="resume"||u.type==="complete"||u.type==="block"||u.type==="failure"?yield*n.requireUnarchivedThread(u.threadId):yield*n.requireThread(u.threadId),u.type==="status")return{goal:yield*t.current(u.threadId)};if(u.type==="failure")return{goal:yield*t.recordFailure({threadId:u.threadId,failure:u.failure,now:yield*o.nowIso,event:u.event,observedEvents:u.observedEvents})};if(u.type==="history"){if(!Number.isInteger(u.limit)||u.limit<1||u.limit>ka)return yield*new Ay({message:`Goal history limit must be between 1 and ${ka}.`});let p=u.cursor===null?null:yield*_j(u.cursor);return p!==null&&p.threadId!==u.threadId?yield*new Ou({message:"The Goal history cursor is invalid or expired."}):{page:yield*t.history({threadId:u.threadId,limit:u.limit,boundary:p})}}if(u.type==="start"){let p=u.objective.trim();if(p.length===0)return yield*new Pd({message:"A Goal objective cannot be empty."});let m=yield*r.next,h=yield*o.nowIso;return{goal:yield*t.start({id:m,threadId:u.threadId,objective:p,now:h})}}if(u.type==="delete")return{goal:yield*t.delete({threadId:u.threadId,goalId:u.goalId,expectedRevision:u.expectedRevision})};if(u.type==="complete"){let p=u.summary.trim(),m=u.verificationEvidence.trim();if(p.length===0||m.length===0)return yield*new Cy({message:"Goal Completion requires a summary and verification evidence."});let h=yield*o.nowIso;return{goal:yield*t.mutate({command:{...u,summary:p,verificationEvidence:m},now:h})}}if(u.type==="block"){let p=u.externalAction.trim(),m=u.evidence.trim();if(p.length===0||m.length===0||Ste(p)||!Number.isInteger(u.repeatedTurns)||u.repeatedTurns<1)return yield*new ni({message:"Goal Blockage requires an external action, concrete evidence, and a positive consecutive-turn count."});let h=yield*o.nowIso;return{goal:yield*t.mutate({command:{...u,externalAction:p,evidence:m},now:h})}}let f=u.type==="edit"?{...u,objective:u.objective.trim()}:u;if(f.type==="edit"&&f.objective.length===0)return yield*new Pd({message:"A Goal objective cannot be empty."});let d=yield*o.nowIso;return{goal:yield*t.mutate({command:f,now:d})}}),a=$.fn("GoalCoordinator.archiveThread")(function*(u){return yield*t.archiveThread({threadId:u,now:yield*o.nowIso})}),c=$.fn("GoalCoordinator.deleteThread")(u=>t.deleteThread(u)),l=$.fn("GoalCoordinator.ownedThreadIds")(()=>t.ownedThreadIds());return e.of({execute:i,archiveThread:a,deleteThread:c,ownedThreadIds:l})}))},xo=class e extends st.Service()("bb-plugin-goal/GoalContinuationCoordinator"){static{s(this,"GoalContinuationCoordinator")}static layer=ft.effect(e,$.gen(function*(){let t=yield*Aa,n=yield*$u,r=yield*ss,o=yield*is,i=$.gen(function*(){let p=yield*o.nowIso,m=Rr.formatIso(Rr.addDuration(Rr.makeUnsafe(p),Ir.seconds(bte)));return{now:p,leaseExpiresAt:m}}),a=$.fn("GoalContinuationCoordinator.enqueueIdle")(function*(p){let m=yield*t.current(p.threadId);if(m===null||m.state!=="active")return null;let h=yield*o.nowIso,x=yield*r.next;return yield*t.enqueueContinuation({id:x,threadId:p.threadId,goalId:m.id,goalRevision:m.revision,opportunityKey:p.opportunityKey,deliveryMarker:Ry(x),now:h})}),c=$.fn("GoalContinuationCoordinator.recover")(function*(){let p=yield*o.nowIso;yield*t.recoverContinuations(p);let m=yield*t.sendingContinuations();for(let h of m){let x=h.deliveryMarker??Ry(h.id);(yield*n.reconcileContinuation(h.threadId,x))?yield*t.resolveContinuation({id:h.id,now:p,outcome:"sent",reason:"Delivery marker reconciled after restart"}):yield*t.requeueContinuation({id:h.id,deliveryMarker:x,now:p,reason:"Delivery marker absent after restart"})}}),l=$.fn("GoalContinuationCoordinator.recoverUsageLimits")(function*(){let p=yield*o.nowIso,m=yield*t.dueUsageLimits(p),h=[];for(let x of m){let S=yield*n.readThread(x.threadId);if(!YC(S).eligible)continue;let T={goalId:x.id,threadId:x.threadId,expectedRevision:x.revision,now:p},b=yield*t.recoverUsageLimit(T);b!==null&&h.push(b)}return h}),u=$.fn("GoalContinuationCoordinator.nextUsageLimitReset")(()=>t.nextUsageLimitReset()),f=$.fn("GoalContinuationCoordinator.assessSettled")(function*(p){let m=yield*t.unassessedSentContinuations(),h=[];for(let x of m){if(p?.aborted===!0)break;let S=yield*n.readThread(x.threadId,p);if(S.deleted===!0){yield*t.deleteThread(x.threadId);continue}if(S.archived===!0){let C=yield*t.archiveThread({threadId:x.threadId,now:yield*o.nowIso});C!==null&&h.push(C);continue}let T=x.deliveryMarker??Ry(x.id),b=yield*n.observeContinuation(x.threadId,T,p);if(b===null)continue;let v=yield*t.assessContinuation({continuationId:x.id,goalId:x.goalId,goalRevision:x.goalRevision,threadId:x.threadId,observation:b,now:yield*o.nowIso});v?.noProgressLastContinuationId===x.id&&h.push(v)}return h}),d=$.fn("GoalContinuationCoordinator.process")(function*(p){let m=yield*i,h=yield*t.claimContinuation(m);if(h===null)return{kind:"idle"};let x=s(L=>t.resolveContinuation({id:h.id,now:m.now,outcome:"released",reason:L}),"release"),S=yield*t.current(h.threadId),T=yield*n.readThread(h.threadId,p),b=YC(T);if(p?.aborted===!0)return yield*x("plugin cancellation"),{kind:"released",continuation:h};if(S===null)return yield*x("Goal no longer exists"),{kind:"released",continuation:h};if(S.id!==h.goalId)return yield*x("A different Goal is active"),{kind:"released",continuation:h};if(S.revision!==h.goalRevision)return yield*x("Goal revision changed"),{kind:"released",continuation:h};if(S.state!=="active")return yield*x(`Goal state is ${S.state}`),{kind:"released",continuation:h};if(!b.eligible)return yield*x(`Suspended before claim delivery: ${b.reason.message}`),{kind:"released",continuation:h};let v=h.deliveryMarker??Ry(h.id);if(!(yield*t.markContinuationSending({id:h.id,deliveryMarker:v,now:m.now,leaseExpiresAt:m.leaseExpiresAt})))return{kind:"released",continuation:h};let w=yield*n.readThread(h.threadId,p),I=yield*t.current(h.threadId),A=YC(w);if(p!==void 0&&p.aborted)return yield*x("plugin cancellation"),{kind:"released",continuation:h};if(I===null)return yield*x("Goal no longer exists before send"),{kind:"released",continuation:h};if(I.id!==h.goalId)return yield*x("A different Goal is active before send"),{kind:"released",continuation:h};if(I.revision!==h.goalRevision)return yield*x("Goal revision changed before send"),{kind:"released",continuation:h};if(I.state!=="active")return yield*x(`Goal state is ${I.state} before send`),{kind:"released",continuation:h};if(!A.eligible)return yield*x(`Suspended immediately before send: ${A.reason.message}`),{kind:"released",continuation:h};let O=yield*$.result(n.sendContinuation(h.threadId,v,p));if(Lt.isFailure(O)){let L=O.failure.message,q=yield*t.recordFailure({threadId:h.threadId,failure:{kind:"ordinary",source:"plugin",reason:`Continuation delivery failed: ${L}`},now:m.now});return yield*x(L),q===null?{kind:"released",continuation:h}:{kind:"released",continuation:h,changedGoal:q}}return yield*t.resolveContinuation({id:h.id,now:m.now,outcome:"sent",reason:"Continuation sent"}),{kind:"sent",continuation:h}});return e.of({enqueueIdle:a,recover:c,assessSettled:f,recoverUsageLimits:l,nextUsageLimitReset:u,process:d})}))};function Oj(e,t,n={}){let r=n.nextGoalId===void 0?Aj:ft.succeed(ss,ss.of({next:$.sync(n.nextGoalId)})),o=n.nowIso===void 0?Cj:ft.succeed(is,is.of({nowIso:$.sync(n.nowIso)})),i=ft.mergeAll(Tj(e),kj(t),r,o),a=ft.mergeAll(as.layer,xo.layer).pipe(ft.provide(i)),c=Ey.make(a),l=!1;return{async run(u){let f=await c.runPromise(as.use(d=>d.execute(u)).pipe($.result));return Lt.isFailure(f)?{ok:!1,error:bj(f.failure)}:{ok:!0,...f.success}},async enqueueIdle(u,f){await c.runPromise(xo.use(d=>d.enqueueIdle({threadId:u,opportunityKey:f})))},async recordFailure(u,f,d,p){let m=await c.runPromise(as.use(h=>h.execute({type:"failure",threadId:u,failure:f,event:d,observedEvents:p})));return"goal"in m?m.goal:null},archiveThread(u){return c.runPromise(as.use(f=>f.archiveThread(u)))},deleteThread(u){return c.runPromise(as.use(f=>f.deleteThread(u)))},ownedThreadIds(){return c.runPromise(as.use(u=>u.ownedThreadIds()))},async recoverContinuations(){await c.runPromise(xo.use(u=>u.recover()))},async assessSettledContinuations(u){return c.runPromise(xo.use(f=>f.assessSettled(u)))},async recoverUsageLimits(){return c.runPromise(xo.use(u=>u.recoverUsageLimits()))},async nextUsageLimitReset(){return c.runPromise(xo.use(u=>u.nextUsageLimitReset()))},async processContinuation(u,f){let d=await c.runPromise(xo.use(p=>p.process(u)));return d.kind==="released"&&d.changedGoal!==void 0&&f?.(d.changedGoal),d.kind!=="idle"},async dispose(){l||(l=!0,await c.dispose())}}}s(Oj,"makeGoalRuntime");var vte=new Set(["provider/error","system/error"]),_te=R.object({message:R.string().optional(),willRetry:R.boolean().optional(),errorInfo:R.object({category:R.string(),providerCode:R.string().nullable().optional()}).optional()}).passthrough(),wte=R.object({rateLimits:R.object({kind:R.enum(WC),status:R.enum(["allowed","blocked","unknown","warning"]),reachedReason:R.string().nullable().optional(),windows:R.array(R.object({status:R.enum(["allowed","blocked","unknown","warning"]),resetsAtMs:R.number().finite().nullable(),label:R.string().nullable().optional()}).passthrough()).optional()}).passthrough()}).passthrough();function Rj(e,t,n){return{kind:"usage-limit",limitKind:e,reason:t,resetAt:n}}s(Rj,"usageFailure");function Ete(e,t){if(e==null||e<=t)return null;let n=new Date(e);return Number.isNaN(n.getTime())?null:n.toISOString()}s(Ete,"validResetAt");function $j(e,t){return e.reduce((n,r)=>t(r)&&(n===null||r.seq>n.seq)?r:n,null)}s($j,"latestEvent");function Ite(e,t){if(e===null)return null;let n=wte.safeParse(e.data);if(!n.success||n.data.rateLimits.status!=="blocked")return null;let r=n.data.rateLimits,o=(r.windows??[]).filter(u=>u.status==="blocked"),i=o.map(u=>u.resetsAtMs),a=i.some(u=>u===null),c=i.filter(u=>u!==null),l=o.length===0||a?null:Ete(Math.max(...c),t);return{kind:r.kind,reason:r.reachedReason??"Provider usage limit reached.",resetAt:l}}s(Ite,"blockedRateLimits");function Pj(e,t,n=null){let r=$j(e,c=>vte.has(c.type)),o=$j(e,c=>c.type==="provider/rateLimits/updated"),i=Ite(o,t);if(r?.type==="provider/error"){let c=_te.safeParse(r.data);if(c.success){let l=c.data.errorInfo;if(l?.category==="rate-limit"&&c.data.willRetry!==!0)return{event:r,failure:i===null?Rj("unknown",c.data.message??"Provider rate limit reached.",null):Rj(i.kind,i.reason,i.resetAt)};let u=l?.category??"unknown",f=l?.providerCode===null?null:l?.providerCode;return{event:r,failure:{kind:"ordinary",source:"provider",reason:`Provider ${u}${f==null?"":` (${f})`}: ${c.data.message??"request failed"}`}}}}let a=r?.type==="system/error"?R.object({message:R.string().optional()}).passthrough().safeParse(r.data):null;return{event:r,failure:{kind:"ordinary",source:"turn",reason:a?.success&&a.data.message!==void 0?a.data.message:n??"The Goal turn failed."}}}s(Pj,"classifyGoalFailureWithIdentity");function Nj(e,t){if(e===null)return null;let n=Date.parse(e);if(!Number.isFinite(n))return null;let r=n-t;return r>0?r:5e3}s(Nj,"usageResetWaitMs");import{createHash as Tte}from"node:crypto";function cs(e){return typeof e=="object"&&e!==null?e:null}s(cs,"record");function kte(e,t){let n=cs(e)?.input;return Array.isArray(n)&&n.some(r=>{let o=cs(r);return o?.type==="text"&&typeof o.text=="string"&&o.text.includes(t)})}s(kte,"markerIsInInput");function Dj(e){return`Continue working toward the active BB Goal. Re-read the objective and make the next meaningful step. Do not stop unless the Goal is complete or genuinely blocked. Internal delivery marker: ${e}`}s(Dj,"continuationPrompt");function Ate(e){let t=e.normalize("NFKC").trim().replace(/\s+/g," ");return Tte("sha256").update(t).digest("hex")}s(Ate,"fingerprintAssistantResult");function Lj(e,t){let n=[...e].sort((d,p)=>d.seq-p.seq),r=n.find(d=>{if(d.type!=="client/turn/requested")return!1;let p=cs(d.data),m=cs(p?.target);return p?.initiator==="system"&&m?.kind==="auto"&&typeof p.requestId=="string"&&kte(p,t)});if(r===void 0)return null;let o=cs(r.data)?.requestId;if(typeof o!="string")return null;let i=n.find(d=>{let p=cs(d.data);return d.seq>r.seq&&d.type==="turn/input/accepted"&&d.scope.kind==="turn"&&p?.clientRequestId===o});if(i===void 0||i.scope.kind!=="turn")return null;let a=i.scope.turnId,c=n.find(d=>{let p=cs(d.data);return d.seq>i.seq&&d.type==="turn/completed"&&d.scope.kind==="turn"&&d.scope.turnId===a&&p?.status==="completed"});if(c===void 0)return null;let l=n.filter(d=>d.seq>i.seq&&d.seq<c.seq&&d.scope.kind==="turn"&&d.scope.turnId===a),u=new Set,f=null;for(let d of l){let p=cs(d.data),m=cs(p?.item);(d.type==="item/started"||d.type==="item/completed")&&(m?.type==="commandExecution"||m?.type==="toolCall")&&u.add("tool-call"),((d.type==="item/started"||d.type==="item/completed")&&m?.type==="fileChange"&&Array.isArray(m.changes)&&m.changes.length>0||d.type==="turn/diff/updated"&&typeof p?.diff=="string"&&p.diff.length>0)&&u.add("file-mutation"),(d.type==="item/started"||d.type==="item/completed")&&["webSearch","webFetch","imageView","backgroundTask"].includes(String(m?.type))&&u.add("external-action"),(d.type==="system/permissionGrant/lifecycle"||d.type==="system/userQuestion/lifecycle")&&p?.status==="pending"&&u.add("pending-interaction"),d.type==="item/completed"&&m?.type==="agentMessage"&&typeof m.text=="string"&&(f=Ate(m.text))}return{requestEventId:r.id,requestSeq:r.seq,requestId:o,acceptedEventId:i.id,acceptedSeq:i.seq,turnId:a,terminalEventId:c.id,terminalSeq:c.seq,signals:[...u],assistantResultFingerprint:f}}s(Lj,"observeSettledContinuation");var Fj="goal.changed",us=R.object({id:R.string(),threadId:R.string(),objective:R.string(),state:R.enum(Oy),revision:R.number().int().positive(),createdAt:R.string(),updatedAt:R.string(),finishedAt:R.string().nullable(),completionSummary:R.string().nullable(),verificationEvidence:R.string().nullable(),blockageExternalAction:R.string().nullable(),blockageEvidence:R.string().nullable(),blockageRepeatedTurns:R.number().int().nullable(),pauseReasonCode:R.enum(["manual","archived","failure","usage-limit","no-progress"]).nullable(),pauseReason:R.string().nullable(),usageLimitKind:R.enum(["subscription-window","credits","spend-control","unknown"]).nullable(),usageResetAt:R.string().nullable(),noProgressConsecutiveCount:R.number().int().min(0),noProgressLastContinuationId:R.string().nullable(),noProgressAssistantResultFingerprint:R.string().nullable(),noProgressEvidence:R.object({continuationId:R.string(),requestEventId:R.string(),requestSeq:R.number().int(),requestId:R.string(),acceptedEventId:R.string(),acceptedSeq:R.number().int(),turnId:R.string(),terminalEventId:R.string(),terminalSeq:R.number().int(),signals:R.array(R.enum(["tool-call","file-mutation","external-action","pending-interaction","changed-assistant-result"])),assistantResultFingerprint:R.string().nullable(),previousAssistantResultFingerprint:R.string().nullable(),assessment:R.enum(["progress","no-progress"]),observedAt:R.string()}).strict().nullable()}).strict(),$te=R.object({goalId:R.string().min(1),expectedRevision:R.number().int().positive(),summary:R.string().trim().min(1),verificationEvidence:R.string().trim().min(1)}).strict(),Pte=R.object({goalId:R.string().min(1),expectedRevision:R.number().int().positive(),externalAction:R.string().trim().min(1),evidence:R.string().trim().min(1),repeatedTurns:R.number().int().min(1)}).strict(),Dd={threadId:R.string().min(1),goalId:R.string().min(1),expectedRevision:R.number().int().positive()},Nte=Rte({start:{input:R.object({threadId:R.string().min(1),objective:R.string().min(1)}).strict(),output:R.object({goal:us}).strict()},status:{input:R.object({threadId:R.string().min(1)}).strict(),output:R.object({goal:us.nullable()}).strict()},edit:{input:R.object({...Dd,objective:R.string().min(1)}).strict(),output:R.object({goal:us}).strict()},pause:{input:R.object(Dd).strict(),output:R.object({goal:us}).strict()},resume:{input:R.object(Dd).strict(),output:R.object({goal:us}).strict()},cancel:{input:R.object(Dd).strict(),output:R.object({goal:us}).strict()},history:{input:R.object({threadId:R.string().min(1),limit:R.number().int().min(1).max(ka),cursor:R.string().min(1).nullable()}).strict(),output:R.object({goals:R.array(us),nextCursor:R.string().nullable()}).strict()},show:{input:R.object({goalId:R.string().min(1)}).strict(),output:R.object({goal:us}).strict()},delete:{input:R.object(Dd).strict(),output:R.object({goal:us}).strict()}}),Dte={makeRuntime:Oj},Ze=class extends Error{static{s(this,"CliUsageError")}};function Ca(e){if(!e.ok)throw new Error(`[${e.error.code}] ${e.error.message}`);if(!("goal"in e))throw new Error("Goal command returned history instead of a Goal.");return e.goal}s(Ca,"requireGoalSuccessful");function Lte(e){if(!e.ok)throw new Error(`[${e.error.code}] ${e.error.message}`);if(!("page"in e))throw new Error("Goal history command returned a Goal instead of history.");return e.page}s(Lte,"requireHistorySuccessful");function zj(e,t){return[t,`ID: ${e.id}`,`Thread: ${e.threadId}`,`State: ${e.state}`,`Revision: ${e.revision}`,`Objective: ${e.objective}`,...e.completionSummary===null?[]:[`Completion summary: ${e.completionSummary}`],...e.verificationEvidence===null?[]:[`Verification evidence: ${e.verificationEvidence}`],...e.blockageExternalAction===null?[]:[`External action required: ${e.blockageExternalAction}`],...e.blockageEvidence===null?[]:[`Blockage evidence: ${e.blockageEvidence}`],...e.blockageRepeatedTurns===null?[]:[`Repeated blocker turns: ${e.blockageRepeatedTurns}`],...e.pauseReason===null?[]:[`Pause reason: ${e.pauseReason}`],...e.usageLimitKind===null?[]:[`Usage limit: ${e.usageLimitKind}`],...e.usageResetAt===null?e.pauseReasonCode==="usage-limit"?["Manual resume required: yes"]:[]:[`Usage reset at: ${e.usageResetAt}`],`Consecutive no-progress Continuations: ${e.noProgressConsecutiveCount}`,...e.noProgressLastContinuationId===null?[]:[`Last assessed Continuation: ${e.noProgressLastContinuationId}`],...e.noProgressEvidence===null?[]:[`No-progress evidence: ${e.noProgressEvidence.assessment}; turn ${e.noProgressEvidence.turnId}; terminal sequence ${e.noProgressEvidence.terminalSeq}; signals ${e.noProgressEvidence.signals.join(", ")||"none"}`]].join(`
|
|
424
|
+
`)}s(zj,"formatGoal");function Ld(e){return`${JSON.stringify(e)}
|
|
425
|
+
`}s(Ld,"jsonLine");function Mj(e){if(e.ok)return 0;switch(e.error.code){case"invalid_arguments":case"invalid_cursor":case"invalid_objective":case"invalid_completion":case"invalid_blockage":return 2;case"thread_not_found":case"goal_not_found":return 3;case"goal_already_exists":case"stale_goal":case"invalid_transition":case"thread_archived":return 4;case"persistence_error":case"gateway_error":return 1}}s(Mj,"resultExitCode");function ri(e,t,n,r){let o=Mj(e);return e.ok?"goal"in e?t?{exitCode:0,stdout:Ld({goal:e.goal})}:{exitCode:0,stdout:e.goal===null?`${r}
|
|
426
|
+
`:`${zj(e.goal,n)}
|
|
427
|
+
`}:{exitCode:1,stderr:`Goal command returned invalid output.
|
|
428
|
+
`}:{exitCode:o,stderr:t?Ld({ok:!1,error:e.error}):`${e.error.message}
|
|
429
|
+
`}}s(ri,"commandResult");function Fte(e,t,n){let r=Mj(e);return e.ok?"page"in e?t?{exitCode:0,stdout:Ld(e.page)}:e.page.goals.length===0?{exitCode:0,stdout:`No Goal history for thread ${n}.
|
|
430
|
+
`}:{exitCode:0,stdout:`${e.page.goals.map((i,a)=>zj(i,a===0?"Goal History":"---")).join(`
|
|
431
|
+
`)}${e.page.nextCursor===null?"":`
|
|
432
|
+
Next cursor: ${e.page.nextCursor}`}
|
|
433
|
+
`}:{exitCode:1,stderr:`Goal history returned invalid output.
|
|
434
|
+
`}:{exitCode:r,stderr:t?Ld({ok:!1,error:e.error}):`${e.error.message}
|
|
435
|
+
`}}s(Fte,"historyResult");function Pu(e,t={}){let n=!1,r=null,o=null,i=null,a=!1,c=[],l=s((u,f)=>{let d=e[u+1];if(d===void 0||d.startsWith("--"))throw new Ze(`${f} requires a value.`);return d},"takeValue");for(let u=0;u<e.length;u+=1){let f=e[u];if(f==="--json"){n=!0;continue}if(f==="--yes"){if(!t.yes)throw new Ze("--yes is valid only for goal delete.");a=!0;continue}if(f==="--objective-file"||f.startsWith("--objective-file=")){if(!t.objectiveFile)throw new Ze("--objective-file is valid only for goal start.");if(r!==null)throw new Ze("--objective-file may be provided only once.");if(r=f.includes("=")?f.slice(17):l(u,"--objective-file"),f.includes("=")||(u+=1),r.length===0)throw new Ze("--objective-file requires a path.");continue}if(f==="--limit"||f.startsWith("--limit=")){if(!t.pagination)throw new Ze("--limit is valid only for goal history.");if(o!==null)throw new Ze("--limit may be provided only once.");let d=f.includes("=")?f.slice(8):l(u,"--limit");if(f.includes("=")||(u+=1),o=Number(d),!Number.isInteger(o)||o<1||o>ka)throw new Ze(`--limit must be an integer between 1 and ${ka}.`);continue}if(f==="--cursor"||f.startsWith("--cursor=")){if(!t.pagination)throw new Ze("--cursor is valid only for goal history.");if(i!==null)throw new Ze("--cursor may be provided only once.");if(i=f.includes("=")?f.slice(9):l(u,"--cursor"),f.includes("=")||(u+=1),i.length===0)throw new Ze("--cursor requires a value.");continue}if(f.startsWith("--"))throw new Ze(`Unknown option ${f}.`);c.push(f)}return{json:n,objectiveFile:r,limit:o,cursor:i,yes:a,positional:c}}s(Pu,"parseOptions");function $y(e,t){let n=e??t.threadId;if(n===void 0)throw new Ze("No thread ID was provided and no current BB thread context is available.");return n}s($y,"resolveThreadId");async function zte(e,t){if(t.threadId===void 0)return;let n=await e.sdk.threads.get({threadId:t.threadId,signal:t.signal});return n.environmentId===null?void 0:(await e.sdk.environments.get({environmentId:n.environmentId,signal:t.signal})).hostId}s(zte,"invokingHostId");async function Mte(e,t,n){let r=Cte(t)?t:n.cwd===void 0?(()=>{throw new Ze("A relative objective file requires CLI working-directory context.")})():Ote(n.cwd,t),o=await zte(e,n),i=await e.sdk.files.read({...o===void 0?{}:{hostId:o},path:r,signal:n.signal});return i.contentEncoding==="base64"?Buffer.from(i.content,"base64").toString("utf8"):i.content}s(Mte,"readObjectiveFile");function Ute(e){let t=["An active BB Goal governs this thread.",`Exact Goal ID: ${e.id}`,`Goal revision: ${e.revision}`,"Keep working until the full objective is complete. Do not stop after only a plan or partial progress.","Only the user may edit, pause, resume, cancel, or delete this Goal.","Call bb_goal_complete only after every requirement is satisfied and verified. Pass the exact Goal ID and revision shown here, a concrete completion summary, and verification evidence.","Call bb_goal_blocked only for a genuine external impasse that requires a user or external action. Do not use it for ordinary difficulty, uncertainty, provider failures, usage limits, pending interactions, or a blocker that changed. The same external blocker must persist for at least three consecutive Goal turns. Pass the exact Goal ID and revision, the required external action, concrete evidence, and the repeated-turn count.","A stale Goal ID or revision cannot complete or block an edited, terminal, or replacement Goal.","Objective:"].join(`
|
|
436
|
+
`),r=Math.max(0,4096-t.length-1),o=`
|
|
437
|
+
[Objective truncated by BB limit]`,i=e.objective.length<=r?e.objective:`${e.objective.slice(0,Math.max(0,r-o.length))}${o}`;return`${t}
|
|
438
|
+
${i}`}s(Ute,"goalAgentInstructions");function Gte(e){return{type:"object",additionalProperties:!1,required:["goalId","expectedRevision","summary","verificationEvidence"],properties:{goalId:{type:"string",const:e.id},expectedRevision:{type:"integer",const:e.revision},summary:{type:"string",minLength:1},verificationEvidence:{type:"string",minLength:1}}}}s(Gte,"goalCompleteParameters");function jte(e){return{type:"object",additionalProperties:!1,required:["goalId","expectedRevision","externalAction","evidence","repeatedTurns"],properties:{goalId:{type:"string",const:e.id},expectedRevision:{type:"integer",const:e.revision},externalAction:{type:"string",minLength:1},evidence:{type:"string",minLength:1},repeatedTurns:{type:"integer",minimum:1}}}}s(jte,"goalBlockedParameters");function $n(e,t,n=!1){e.realtime.publish(Fj,{threadId:t.threadId,goalId:t.id,revision:t.revision,state:t.state,pauseReasonCode:t.pauseReasonCode,noProgressConsecutiveCount:t.noProgressConsecutiveCount,noProgressEvidence:t.noProgressEvidence,deleted:n})}s($n,"publishGoalChanged");function XC(e,t,n){e.realtime.publish(Fj,{threadId:t,goalId:null,revision:null,state:null,pauseReasonCode:n==="archived"?"archived":null,noProgressConsecutiveCount:null,noProgressEvidence:null,deleted:n==="deleted",lifecycle:n})}s(XC,"publishThreadInvalidation");function Zte(e){return e instanceof Error&&/(?:not found|\b404\b)/i.test(e.message)}s(Zte,"isThreadMissingError");async function qte(e,t,n,r){let o=Pu(n,{objectiveFile:!0}),i=o.positional[0]?.startsWith("thr_")??!1,a=i?o.positional[0]:void 0,c=o.positional.slice(i?1:0);if(o.objectiveFile!==null&&c.length>0)throw new Ze("Provide an objective as text or with --objective-file, not both.");if(o.objectiveFile===null&&c.length===0)throw new Ze("Usage: bb goal start [thread-id] <objective> [--objective-file <path>] [--json]");let l=$y(a,r),u=o.objectiveFile===null?c.join(" "):await Mte(e,o.objectiveFile,r),f=await t.run({type:"start",threadId:l,objective:u});return f.ok&&"goal"in f&&f.goal!==null&&$n(e,f.goal),ri(f,o.json,"Started Goal",`No unfinished Goal for thread ${l}.`)}s(qte,"runStart");async function Bte(e,t,n){let r=Pu(t);if(r.positional.length>1)throw new Ze("Usage: bb goal status [thread-id] [--json]");let o=$y(r.positional[0],n),i=await e.run({type:"status",threadId:o});return ri(i,r.json,"Active Goal",`No unfinished Goal for thread ${o}.`)}s(Bte,"runStatus");function Vte(e){return{ok:!1,error:{code:"goal_not_found",message:`No unfinished Goal for thread ${e}.`}}}s(Vte,"missingCurrentGoal");async function Hte(e,t,n,r,o){let i=Pu(r),a=i.positional[0]?.startsWith("thr_")??!1,c=a?i.positional[0]:void 0,l=i.positional.slice(a?1:0);if(n==="edit"){if(l.length===0)throw new Ze("Usage: bb goal edit [thread-id] <objective> [--json]")}else if(l.length>0)throw new Ze(`Usage: bb goal ${n} [thread-id] [--json]`);let u=$y(c,o),f=await t.run({type:"status",threadId:u});if(!f.ok)return ri(f,i.json,"","");if(!("goal"in f))return{exitCode:1,stderr:`Goal status returned invalid output.
|
|
439
|
+
`};if(f.goal===null)return ri(Vte(u),i.json,"","");let d={threadId:u,goalId:f.goal.id,expectedRevision:f.goal.revision},p=n==="edit"?await t.run({type:n,...d,objective:l.join(" ")}):await t.run({type:n,...d});p.ok&&"goal"in p&&p.goal!==null&&$n(e,p.goal);let m={edit:"Edited Goal",pause:"Paused Goal",resume:"Resumed Goal",cancel:"Canceled Goal"};return ri(p,i.json,m[n],"")}s(Hte,"runMutation");async function Kte(e,t,n){let r=Pu(t,{pagination:!0});if(r.positional.length>1)throw new Ze("Usage: bb goal history [thread-id] [--limit <n>] [--cursor <cursor>] [--json]");let o=$y(r.positional[0],n),i=await e.run({type:"history",threadId:o,limit:r.limit??yj,cursor:r.cursor});return Fte(i,r.json,o)}s(Kte,"runHistory");async function Jte(e,t){let n=Pu(t);if(n.positional.length!==1)throw new Ze("Usage: bb goal show <goal-id> [--json]");let r=await e.run({type:"show",goalId:n.positional[0]});return ri(r,n.json,"Goal","")}s(Jte,"runShow");async function Wte(e,t,n){let r=Pu(n,{yes:!0});if(r.positional.length!==1)throw new Ze("Usage: bb goal delete <goal-id> --yes [--json]");if(!r.yes)throw new Ze("Deleting a Goal requires --yes.");let o=await t.run({type:"show",goalId:r.positional[0]});if(!o.ok)return ri(o,r.json,"","");if(!("goal"in o)||o.goal===null)return{exitCode:1,stderr:`Goal show returned invalid output.
|
|
440
|
+
`};let i=await t.run({type:"delete",threadId:o.goal.threadId,goalId:o.goal.id,expectedRevision:o.goal.revision});return i.ok&&"goal"in i&&i.goal!==null&&$n(e,i.goal,!0),ri(i,r.json,"Deleted Goal","")}s(Wte,"runDelete");async function Yte(e,t,n,r){let o=n.includes("--json");try{let[i,...a]=n;if(i==="start")return await qte(e,t,a,r);if(i==="status")return await Bte(t,a,r);if(i==="history")return await Kte(t,a,r);if(i==="show")return await Jte(t,a);if(i==="delete")return await Wte(e,t,a);if(i==="edit"||i==="pause"||i==="resume"||i==="cancel")return await Hte(e,t,i,a,r);throw new Ze("Usage: bb goal <start|status|edit|pause|resume|cancel|history|show|delete> ...")}catch(i){let a=i instanceof Error?i.message:String(i);return{exitCode:i instanceof Ze?2:1,stderr:o?Ld({ok:!1,error:{code:i instanceof Ze?"invalid_arguments":"adapter_error",message:a}}):`${a}
|
|
441
|
+
`}}}s(Yte,"runCli");function QC(e){return typeof e=="object"&&e!==null?e:null}s(QC,"objectData");var Xte=["client/turn/requested","turn/input/accepted","turn/completed","item/started","item/completed","turn/diff/updated","system/permissionGrant/lifecycle","system/userQuestion/lifecycle"];async function Qte(e,t,n,r){let o=[],i;for(;;){let a=await e.sdk.threads.events.list({threadId:t,...i===void 0?{}:{beforeSeq:i},order:"desc",limit:"500",types:Xte,signal:r});o.push(...a.map(u=>({id:u.id,seq:u.seq,createdAt:u.createdAt,scope:u.scope,type:u.type,data:u.data})));let c=Lj(o,n);if(c!==null||a.length<500)return c;let l=a.at(-1);if(l===void 0)return null;i=String(l.seq)}}s(Qte,"observeThreadContinuation");async function ene(e,t,n,r,o){let i=["client/turn/requested","provider/error","provider/rateLimits/updated","system/error","turn/completed","turn/input/accepted"],a=await e.sdk.threads.events.list({threadId:t,order:"desc",limit:"1",types:["client/turn/requested"],signal:o}),c=a.find(b=>b.type==="client/turn/requested"),l=[...a];if(c!==void 0){let b=String(c.seq);for(;;){let v=await e.sdk.threads.events.list({threadId:t,afterSeq:b,order:"asc",limit:"500",types:i,signal:o});if(l.push(...v),v.length<500)break;let C=v.at(-1);if(C===void 0)break;b=String(C.seq)}}else l.push(...await e.sdk.threads.events.list({threadId:t,order:"desc",limit:"500",types:["provider/error","provider/rateLimits/updated","system/error","turn/completed","turn/input/accepted"],signal:o}));let u=[...new Map(l.map(b=>[b.id,b])).values()].map(b=>({id:b.id,seq:b.seq,createdAt:b.createdAt,scope:b.scope,type:b.type,data:b.data})),d=u.filter(b=>b.type==="client/turn/requested").filter(b=>typeof QC(b.data)?.requestId=="string").sort((b,v)=>b.seq-v.seq).at(-1),p=new Map,m=new Map;for(let b of u){let v=QC(b.data);b.type==="turn/input/accepted"&&b.scope.kind==="turn"&&typeof v?.clientRequestId=="string"&&(p.has(v.clientRequestId)||p.set(v.clientRequestId,b)),b.type==="turn/completed"&&b.scope.kind==="turn"&&v?.status==="failed"&&m.set(b.scope.turnId,b)}let h=null;if(d!==void 0){let b=QC(d.data)?.requestId;if(typeof b=="string"){let v=p.get(b);if(v!==void 0&&v.seq>d.seq&&v.scope.kind==="turn"){let C=v.scope.turnId,w=m.get(C);w!==void 0&&w.seq>v.seq&&(h={requestSeq:d.seq,completedSeq:w.seq,turnId:C})}}}let x=u.filter(b=>["provider/error","provider/rateLimits/updated","system/error"].includes(b.type)).filter(b=>h!==null&&b.seq>=h.requestSeq&&b.seq<=h.completedSeq).map(b=>({id:b.id,seq:b.seq,createdAt:b.createdAt,turnId:h?.turnId??(b.scope.kind==="turn"?b.scope.turnId:null),type:b.type,data:b.data})),S={id:`thread.failed:${t}:${h?.completedSeq??r}`,seq:null,createdAt:r,turnId:h?.turnId??null},T=Pj(x,Date.now(),n);return{...T,event:T.event??S,observedEvents:[...x,S].map(({id:b,seq:v,createdAt:C,turnId:w})=>({id:b,seq:v,createdAt:C,turnId:w}))}}s(ene,"classifyThreadFailure");function tne(e=Dte){return s(async function(n){let r=n.storage.database();n.storage.migrate(r,[...Ej]);let o=e.makeRuntime(r,{async threadExists(E){try{return(await n.sdk.threads.get({threadId:E})).deletedAt===null}catch{return!1}},async readThreadOwnership(E){try{let k=await n.sdk.threads.get({threadId:E});return{exists:k.deletedAt===null,archived:k.archivedAt!==null,deleted:k.deletedAt!==null}}catch{return{exists:!1,archived:!1,deleted:!0}}},async readThread(E,k){let B=await n.sdk.threads.get({threadId:E,signal:k});if(B.archivedAt!==null||B.deletedAt!==null)return{status:B.status,runtimeStatus:B.runtime.displayStatus,queuedMessageCount:0,activePromptMode:null,pendingInteractionCount:0,archived:B.archivedAt!==null,deleted:B.deletedAt!==null};let[_e,nt,yo]=await Promise.all([n.sdk.threads.queuedMessages.list({threadId:E,signal:k}),n.sdk.threads.interactions.list({threadId:E,signal:k}),n.sdk.threads.timeline({threadId:E,signal:k,segmentLimit:"1",summaryOnly:"false"})]);return{status:B.status,runtimeStatus:B.runtime.displayStatus,queuedMessageCount:_e.length,activePromptMode:yo.activePromptMode?.mode??null,pendingInteractionCount:nt.filter(vt=>vt.status!=="resolved"&&vt.status!=="interrupted").length,archived:!1,deleted:!1}},async sendContinuation(E,k,B){if(B?.aborted===!0)throw new Error("Goal plugin is shutting down.");let _e=await n.sdk.threads.get({threadId:E,signal:B});if(_e.archivedAt!==null||_e.deletedAt!==null)throw new Error("The owning thread is archived or deleted.");await n.sdk.threads.send({threadId:E,mode:"auto",input:[{type:"text",text:Dj(k),mentions:[],visibility:"agent-only"}]})},async reconcileContinuation(E,k,B){return(await n.sdk.threads.timeline({threadId:E,signal:B,segmentLimit:"100",summaryOnly:"false"})).rows.some(nt=>"text"in nt&&nt.text.includes(k))},observeContinuation(E,k,B){return Qte(n,E,k,B)}}),i=25,a=1e3,c=25,l=1e3,u=!1,f=new AbortController,d=null,p=!1,m=new Map,h=new Map,x=new Set,S=s((E,k)=>`${E}\0${k}`,"pendingIdleEventKey"),T=s(E=>{for(let[k,B]of m)B.threadId===E&&m.delete(k)},"clearPendingIdleEvents"),b=s(()=>{let E=d;if(E===null){p=!0;return}d=null,E()},"wake"),v=s((E,k=null)=>E.aborted?Promise.resolve():p?(p=!1,Promise.resolve()):new Promise(B=>{let _e,nt=s(()=>{_e!==void 0&&clearTimeout(_e),E.removeEventListener("abort",nt),d===nt&&(d=null),B()},"finish");d=nt,E.addEventListener("abort",nt,{once:!0}),k!==null&&(_e=setTimeout(nt,k))}),"waitForWork"),C=s(async E=>{for(let[k,B]of m){if(E.aborted)return;let _e=await o.assessSettledContinuations(E);for(let nt of _e)$n(n,nt);await o.enqueueIdle(B.threadId,B.opportunityKey),m.delete(k)}},"retryPendingIdleEvents"),w=s(E=>{let k=h.get(E),B=Date.now();h.set(E,{threadId:E,attempt:k?.attempt??0,nextAttemptAt:Math.min(k?.nextAttemptAt??B,B)}),b()},"queueOwnershipReconciliation"),I=s(async(E,k)=>{let B;try{B=await n.sdk.threads.get({threadId:E,signal:k})}catch(_e){if(!Zte(_e))throw _e;if(k.aborted||u||(T(E),await o.deleteThread(E),k.aborted||u))return;XC(n,E,"deleted");return}if(!(k.aborted||u)){if(B.deletedAt!==null){if(T(E),await o.deleteThread(E),k.aborted||u)return;XC(n,E,"deleted");return}if(B.archivedAt!==null){T(E);let _e=await o.archiveThread(E);if(k.aborted||u)return;_e===null?XC(n,E,"archived"):$n(n,_e)}}},"reconcileOneThreadOwnership"),A=s(async(E,k)=>{let B=h.get(E);if(!(B===void 0||B.nextAttemptAt>Date.now()||x.has(E)||k.aborted||u)){x.add(E);try{await I(E,k),!k.aborted&&!u&&h.get(E)===B&&h.delete(E)}catch(_e){if(k.aborted||u)return;let nt=B.attempt+1,yo=Math.min(c*2**Math.min(nt-1,20),l);h.set(E,{threadId:E,attempt:nt,nextAttemptAt:Date.now()+yo}),n.log.error(`Could not reconcile Goal ownership for thread ${E}; retry ${nt} in ${yo}ms: ${_e instanceof Error?_e.message:String(_e)}`)}finally{x.delete(E),h.has(E)&&b()}}},"retryOneOwnershipReconciliation"),O=s(async E=>{for(let{threadId:k}of h.values()){if(E.aborted||u)return;await A(k,E)}},"retryPendingOwnershipReconciliations"),L=s(()=>{let E=null;for(let k of h.values())x.has(k.threadId)||(E=E===null?k.nextAttemptAt:Math.min(E,k.nextAttemptAt));return E===null?null:Math.max(0,E-Date.now())},"nextOwnershipRetryWaitMs");n.events.on("thread.idle",async({thread:E})=>{if(u)return;let k=`idle:${E.updatedAt}`,B=S(E.id,k);try{let _e=await o.assessSettledContinuations();for(let nt of _e)$n(n,nt);await o.enqueueIdle(E.id,k),m.delete(B),b()}catch(_e){if(u)return;m.set(B,{threadId:E.id,opportunityKey:k}),n.log.error(`Could not enqueue idle Continuation: ${_e instanceof Error?_e.message:String(_e)}`),b()}}),n.events.on("thread.created",async()=>{}),n.events.on("thread.archived",async({thread:E})=>{u||(w(E.id),await A(E.id,f.signal))}),n.events.on("thread.deleted",async({thread:E})=>{u||(w(E.id),await A(E.id,f.signal))}),n.events.on("thread.failed",async({thread:E,error:k})=>{if(!u)try{let B=await ene(n,E.id,k,E.updatedAt),_e=await o.recordFailure(E.id,B.failure,B.event??void 0,B.observedEvents);_e!==null&&$n(n,_e),b()}catch(B){u||n.log.error(`Could not record failed Goal turn: ${B instanceof Error?B.message:String(B)}`)}}),n.background.service("continuations",{async start(E){let k=i,B=!1;for(;!E.aborted&&!u;)try{if(!B){for(let vt of await o.ownedThreadIds())w(vt);B=!0}await O(E),await C(E);let _e=await o.recoverUsageLimits();for(let vt of _e)await o.enqueueIdle(vt.threadId,`usage-reset:${vt.id}:${vt.revision}`);await o.recoverContinuations();let nt=await o.assessSettledContinuations(E);for(let vt of nt)$n(n,vt);let yo=!1;do yo=await o.processContinuation(E,vt=>$n(n,vt));while(yo&&!E.aborted);if(k=i,!E.aborted&&!u){let vt=Nj(await o.nextUsageLimitReset(),Date.now()),Oa=L(),Py=vt===null?Oa:Oa===null?vt:Math.min(vt,Oa);if(m.size>0||Oa===0)continue;await v(E,Py)}}catch(_e){if(E.aborted)break;n.log.error(`Continuation worker recovered from an error: ${_e instanceof Error?_e.message:String(_e)}`),await v(E,k),k=Math.min(k*2,a)}}});let q=Ij(r);n.agents.registerTool({name:"bb_goal_complete",description:"Mark the active BB Goal completed after all required work is done and verified.",instructions:"Use only for the active BB Goal. Include its exact ID and revision, a completion summary, and concrete verification evidence.",presentation:{label:{pending:"Completing Goal",completed:"Completed Goal"}},parameters:$te,async execute(E,k){let B=Ca(await o.run({type:"complete",threadId:k.threadId,...E}));if(B===null)throw new Error("Goal Completion returned no Goal.");return $n(n,B),{content:[{type:"text",text:JSON.stringify({goal:B})}]}}}),n.agents.registerTool({name:"bb_goal_blocked",description:"Report a genuine external Blockage after the same blocker persists for at least three consecutive Goal turns.",instructions:"Use only for a genuine external impasse. Include the exact Goal ID and revision, the required external action, concrete evidence, and the repeated-turn count. Do not use for ordinary difficulty, uncertainty, failures, usage limits, pending interactions, or changed blockers.",presentation:{label:{pending:"Reporting Goal Blockage",completed:"Reported Goal Blockage"}},parameters:Pte,async execute(E,k){let B=Ca(await o.run({type:"block",threadId:k.threadId,...E}));if(B===null)throw new Error("Goal Blockage returned no Goal.");return $n(n,B),{content:[{type:"text",text:JSON.stringify({goal:B,blockageReport:B.state==="blocked"?{status:"blocked",repeatedTurns:E.repeatedTurns}:{status:"qualifying",repeatedTurns:E.repeatedTurns,turnsRemaining:3-E.repeatedTurns}})}]}}}),n.agents.configure(E=>{let k=q.current(E.thread.id);return k===null||k.state!=="active"?{tools:[],skills:[]}:{tools:[{name:"bb_goal_complete",parameters:Gte(k)},{name:"bb_goal_blocked",parameters:jte(k)}],skills:[],instructions:Ute(k)}});async function Q(E){let k=Ca(await o.run(E));if(k===null)throw new Error(`Goal ${E.type} returned no Goal.`);return $n(n,k),{goal:k}}s(Q,"mutate"),n.rpc.register(Nte,{async start(E){let k=Ca(await o.run({type:"start",threadId:E.threadId,objective:E.objective}));if(k===null)throw new Error("Goal start returned no Goal.");return $n(n,k),{goal:k}},async status(E){return{goal:Ca(await o.run({type:"status",threadId:E.threadId}))}},edit:s(E=>Q({type:"edit",...E}),"edit"),pause:s(E=>Q({type:"pause",...E}),"pause"),resume:s(E=>Q({type:"resume",...E}),"resume"),cancel:s(E=>Q({type:"cancel",...E}),"cancel"),async history(E){let k=Lte(await o.run({type:"history",...E}));return{goals:[...k.goals],nextCursor:k.nextCursor}},async show(E){let k=Ca(await o.run({type:"show",goalId:E.goalId}));if(k===null)throw new Error("Goal show returned no Goal.");return{goal:k}},async delete(E){let k=Ca(await o.run({type:"delete",...E}));if(k===null)throw new Error("Goal delete returned no Goal.");return $n(n,k,!0),{goal:k}}}),n.cli.register({name:"goal",summary:"Start, inspect, and control durable thread Goals",commands:[{name:"start",summary:"Start a Goal on an existing thread",usage:"bb goal start [thread-id] <objective> [--objective-file <path>] [--json]"},{name:"status",summary:"Inspect the unfinished Goal for a thread",usage:"bb goal status [thread-id] [--json]"},{name:"edit",summary:"Edit the unfinished Goal objective",usage:"bb goal edit [thread-id] <objective> [--json]"},{name:"pause",summary:"Pause an active Goal",usage:"bb goal pause [thread-id] [--json]"},{name:"resume",summary:"Resume a paused Goal",usage:"bb goal resume [thread-id] [--json]"},{name:"cancel",summary:"Cancel an unfinished Goal",usage:"bb goal cancel [thread-id] [--json]"},{name:"history",summary:"Browse a thread's Goal history",usage:"bb goal history [thread-id] [--limit <n>] [--cursor <cursor>] [--json]"},{name:"show",summary:"Inspect one Goal by ID",usage:"bb goal show <goal-id> [--json]"},{name:"delete",summary:"Delete one Goal after explicit confirmation",usage:"bb goal delete <goal-id> --yes [--json]"}],run:s((E,k)=>Yte(n,o,E,k),"run")}),n.onDispose(()=>(u=!0,f.abort(),b(),o.dispose())),n.log.info("Goal coordinator loaded")},"goalPlugin")}s(tne,"createPlugin");var jde=tne();export{Fj as GOAL_REALTIME_CHANNEL,tne as createPlugin,jde as default,Pte as goalBlockedInputSchema,$te as goalCompleteInputSchema,Nte as rpcContract};
|
|
442
|
+
//# sourceMappingURL=server.js.map
|