barejs 0.1.49 → 0.1.51
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/README.md +257 -98
- package/dist/index.js +157 -94
- package/dist/types/client/index.d.ts +24 -22
- package/dist/types/core/bare.d.ts +83 -3
- package/dist/types/core/context.d.ts +47 -1
- package/dist/types/core/radix.d.ts +1 -0
- package/dist/types/core/router.d.ts +21 -10
- package/dist/types/index.d.ts +16 -8
- package/dist/types/security/auth.d.ts +10 -1
- package/dist/types/security/cors.d.ts +7 -3
- package/dist/types/security/csrf.d.ts +12 -0
- package/dist/types/security/idempotency.d.ts +22 -0
- package/dist/types/security/resilience.d.ts +17 -0
- package/dist/types/security/timeout.d.ts +6 -0
- package/dist/types/security/validators.d.ts +18 -0
- package/dist/types/utils/compress.d.ts +12 -0
- package/dist/types/utils/health.d.ts +17 -0
- package/dist/types/utils/logger.d.ts +22 -0
- package/dist/types/utils/openapi.d.ts +23 -1
- package/dist/types/utils/static.d.ts +5 -1
- package/llms.txt +138 -0
- package/package.json +3 -1
- package/src/client/index.ts +61 -18
- package/src/core/bare.ts +409 -49
- package/src/core/context.ts +266 -32
- package/src/core/radix.ts +37 -3
- package/src/core/router.ts +43 -16
- package/src/index.ts +25 -9
- package/src/security/auth.ts +68 -11
- package/src/security/cors.ts +85 -31
- package/src/security/csrf.ts +84 -0
- package/src/security/hash.ts +8 -2
- package/src/security/headers.ts +12 -3
- package/src/security/idempotency.ts +118 -0
- package/src/security/rateLimit.ts +1 -6
- package/src/security/resilience.ts +91 -0
- package/src/security/timeout.ts +32 -0
- package/src/security/validators.ts +201 -5
- package/src/utils/compress.ts +49 -0
- package/src/utils/health.ts +65 -0
- package/src/utils/logger.ts +66 -0
- package/src/utils/openapi.ts +59 -14
- package/src/utils/static.ts +71 -5
package/dist/index.js
CHANGED
|
@@ -1,38 +1,67 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
var{defineProperty:fi,getOwnPropertyNames:Zc,getOwnPropertyDescriptor:eu}=Object,tu=Object.prototype.hasOwnProperty;function ru(e){return this[e]}var nu=(e)=>{var t=(ss??=new WeakMap).get(e),r;if(t)return t;if(t=fi({},"__esModule",{value:!0}),e&&typeof e==="object"||typeof e==="function"){for(var n of Zc(e))if(!tu.call(t,n))fi(t,n,{get:ru.bind(e,n),enumerable:!(r=eu(e,n))||r.enumerable})}return ss.set(e,t),t},ss;var ou=(e)=>e;function iu(e,t){this[e]=ou.bind(null,t)}var mi=(e,t)=>{for(var r in t)fi(e,r,{get:t[r],enumerable:!0,configurable:!0,set:iu.bind(t,r)})};var su=(e,t,r)=>()=>{if(e)try{t=e(e=0)}catch(n){r=[n]}if(r)throw r[0];return t};var tc={};mi(tc,{BARE_CONFIG:()=>gn,initConfig:()=>Xo});var Bi,gn,Xo=(e={})=>(gn={...Bi,...e,hash:{...Bi.hash,...e.hash}},gn);var Qo=su(()=>{Bi={hash:{algorithm:"argon2id",memoryCost:65536,timeCost:2},port:3000},gn=Bi});var Li={};mi(Li,{Any:()=>sr,Argument:()=>As,Array:()=>tn,AsyncIterator:()=>rn,Awaited:()=>un,BigInt:()=>an,Boolean:()=>Mo,Capitalize:()=>Pa,Composite:()=>Qs,Const:()=>Zs,Constructor:()=>nn,ConstructorParameters:()=>ea,Date:()=>Lo,Enum:()=>ta,Exclude:()=>pn,Extends:()=>dn,Extract:()=>ln,Function:()=>Nt,Index:()=>ar,InstanceType:()=>ba,Instantiate:()=>Oa,Integer:()=>$a,Intersect:()=>Ne,Iterator:()=>cn,KeyOf:()=>fn,Literal:()=>V,Lowercase:()=>Ta,Mapped:()=>Vs,Module:()=>va,Never:()=>M,Not:()=>qa,Null:()=>Bo,Number:()=>et,Object:()=>J,Omit:()=>fr,Optional:()=>Ce,Parameters:()=>Ha,Partial:()=>yn,Pick:()=>mr,Promise:()=>Eo,Readonly:()=>De,ReadonlyOptional:()=>zo,Record:()=>Wo,Recursive:()=>Va,Ref:()=>nt,RegExp:()=>za,Required:()=>xn,Rest:()=>Wa,ReturnType:()=>Ja,String:()=>It,Symbol:()=>Go,TemplateLiteral:()=>jo,Transform:()=>Qa,Tuple:()=>tt,Uint8Array:()=>vo,Uncapitalize:()=>Aa,Undefined:()=>Do,Union:()=>z,Unknown:()=>cr,Unsafe:()=>Za,Uppercase:()=>ka,Void:()=>ec});var si={};mi(si,{BRAND:()=>Ux,DIRTY:()=>Kr,EMPTY_PATH:()=>lx,INVALID:()=>T,NEVER:()=>bg,OK:()=>je,ParseStatus:()=>ke,Schema:()=>U,ZodAny:()=>Br,ZodArray:()=>Rt,ZodBigInt:()=>xr,ZodBoolean:()=>wn,ZodBranded:()=>ii,ZodCatch:()=>Mn,ZodDate:()=>Lr,ZodDefault:()=>Sn,ZodDiscriminatedUnion:()=>oi,ZodEffects:()=>Pt,ZodEnum:()=>gr,ZodError:()=>qe,ZodFirstPartyTypeKind:()=>A,ZodFunction:()=>Rn,ZodIntersection:()=>An,ZodIssueCode:()=>g,ZodLazy:()=>kn,ZodLiteral:()=>Cn,ZodMap:()=>no,ZodNaN:()=>oo,ZodNativeEnum:()=>Nn,ZodNever:()=>jt,ZodNull:()=>Pn,ZodNullable:()=>Qt,ZodNumber:()=>yr,ZodObject:()=>pe,ZodOptional:()=>wt,ZodParsedType:()=>O,ZodPipeline:()=>io,ZodPromise:()=>Dr,ZodReadonly:()=>jn,ZodRecord:()=>ro,ZodSchema:()=>U,ZodSet:()=>Gr,ZodString:()=>$t,ZodSymbol:()=>eo,ZodTransformer:()=>Pt,ZodTuple:()=>Ut,ZodType:()=>U,ZodUndefined:()=>Fn,ZodUnion:()=>Tn,ZodUnknown:()=>lr,ZodVoid:()=>to,addIssueToContext:()=>h,any:()=>Hx,array:()=>Jx,bigint:()=>Bx,boolean:()=>kc,coerce:()=>hg,custom:()=>Pc,date:()=>Gx,datetimeRegex:()=>wc,defaultErrorMap:()=>Yt,discriminatedUnion:()=>Zx,effect:()=>mg,enum:()=>cg,function:()=>ig,getErrorMap:()=>_n,getParsedType:()=>Mt,instanceof:()=>Kx,intersection:()=>eg,isAborted:()=>ri,isAsync:()=>On,isDirty:()=>ni,isValid:()=>pr,late:()=>Ex,lazy:()=>sg,literal:()=>ag,makeIssue:()=>Zn,map:()=>ng,nan:()=>Lx,nativeEnum:()=>ug,never:()=>zx,null:()=>qx,nullable:()=>pg,number:()=>Ac,object:()=>Yx,objectUtil:()=>Yi,oboolean:()=>Ig,onumber:()=>gg,optional:()=>dg,ostring:()=>xg,pipeline:()=>yg,preprocess:()=>lg,promise:()=>fg,quotelessJson:()=>mx,record:()=>rg,set:()=>og,setErrorMap:()=>px,strictObject:()=>Xx,string:()=>Tc,symbol:()=>Dx,transformer:()=>mg,tuple:()=>tg,undefined:()=>vx,union:()=>Qx,unknown:()=>Vx,util:()=>L,void:()=>Wx});class zr{prefix;groupMiddleware;routes=[];constructor(e="",t=[]){this.prefix=e;this.groupMiddleware=t}_add(e,t,r){let n=(this.prefix+"/"+t).replace(/\/+/g,"/");if(n.endsWith("/"))n=n.slice(0,-1);return this.routes.push({method:e.toUpperCase(),path:n||"",handlers:[...this.groupMiddleware,...r]}),this}get=(e,...t)=>this._add("GET",e,t);post=(e,...t)=>this._add("POST",e,t);put=(e,...t)=>this._add("PUT",e,t);patch=(e,...t)=>this._add("PATCH",e,t);delete=(e,...t)=>this._add("DELETE",e,t);options=(e,...t)=>this._add("OPTIONS",e,t);group=(e,...t)=>{let r=t.pop(),n=t,o=(this.prefix+"/"+e).replace(/\/+/g,"/"),i=new zr(o,[...this.groupMiddleware,...n]);return r(i),this.routes.push(...i.routes),this};use(e){if(e instanceof zr||e&&e.routes)this.routes.push(...e.routes);else this.groupMiddleware.push(e);return this}}class Wr{children={};staticKeys=[];paramNode=null;paramName=null;handlers={};insert(e,t,r){let n=this,o=e.split("/").filter(Boolean);for(let i of o)if(i.startsWith(":")){if(!n.paramNode)n.paramNode=new Wr;n.paramName=i.slice(1),n=n.paramNode}else{if(!n.children[i])n.children[i]=new Wr,n.staticKeys.push(i);n=n.children[i]}n.handlers[t]=r}lookup(e,t,r,n){let o=this,i=r===-1?0:r,s=t.length;if(t[i]==="/")i++;for(let a in n.params)delete n.params[a];while(i<s){let a=t.indexOf("/",i);if(a===-1)a=s;let c=a-i,m=!1,x=o.staticKeys,I=x.length;if(I===1){let k=x[0];if(k.length===c){let j=!0;for(let P=0;P<c;P++)if(k[P]!==t[i+P]){j=!1;break}if(j)o=o.children[k],m=!0}}else for(let k=0;k<I;k++){let j=x[k];if(j.length===c){let P=!0;for(let ye=0;ye<c;ye++)if(j[ye]!==t[i+ye]){P=!1;break}if(P){o=o.children[j],m=!0;break}}}if(!m)if(o.paramNode)n.params[o.paramName]=t.slice(i,a),o=o.paramNode;else return null;i=a+1}return o.handlers[e]||null}jitCompile(e,t=0,r="url",n="s",o=[]){let i="",s=" ".repeat(t);if(Object.keys(this.handlers).length>0){if(i+=`${s}if (${n} >= urlLen) {
|
|
3
|
-
`,
|
|
4
|
-
`}
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
`,i+=`${s}}
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
2
|
+
var{defineProperty:$s,getOwnPropertyNames:du,getOwnPropertyDescriptor:fu}=Object,mu=Object.prototype.hasOwnProperty;function pu(e){return this[e]}var lu=(e)=>{var t=(Oi??=new WeakMap).get(e),r;if(t)return t;if(t=$s({},"__esModule",{value:!0}),e&&typeof e==="object"||typeof e==="function"){for(var n of du(e))if(!mu.call(t,n))$s(t,n,{get:pu.bind(e,n),enumerable:!(r=fu(e,n))||r.enumerable})}return Oi.set(e,t),t},Oi;var yu=(e)=>e;function gu(e,t){this[e]=yu.bind(null,t)}var ks=(e,t)=>{for(var r in t)$s(e,r,{get:t[r],enumerable:!0,configurable:!0,set:gu.bind(t,r)})};var hu=(e,t,r)=>()=>{if(e)try{t=e(e=0)}catch(n){r=[n]}if(r)throw r[0];return t};var Qc={};ks(Qc,{BARE_CONFIG:()=>Jn,initConfig:()=>Is});var pi,Jn,Is=(e={})=>(Jn={...pi,...e,hash:{...pi.hash,...e.hash}},Jn);var bs=hu(()=>{pi={hash:{algorithm:"argon2id",memoryCost:65536,timeCost:2},port:3000},Jn=pi});var cs={};ks(cs,{BRAND:()=>Hl,DIRTY:()=>Qr,EMPTY_PATH:()=>Ol,INVALID:()=>S,NEVER:()=>Fy,OK:()=>Je,ParseStatus:()=>qe,Schema:()=>K,ZodAny:()=>en,ZodArray:()=>Kt,ZodBigInt:()=>Pr,ZodBoolean:()=>Pn,ZodBranded:()=>as,ZodCatch:()=>Bn,ZodDate:()=>Zr,ZodDefault:()=>Kn,ZodDiscriminatedUnion:()=>is,ZodEffects:()=>vt,ZodEnum:()=>Sr,ZodError:()=>at,ZodFirstPartyTypeKind:()=>N,ZodFunction:()=>Tn,ZodIntersection:()=>jn,ZodIssueCode:()=>I,ZodLazy:()=>En,ZodLiteral:()=>Un,ZodMap:()=>ho,ZodNaN:()=>xo,ZodNativeEnum:()=>Ln,ZodNever:()=>Xt,ZodNull:()=>Nn,ZodNullable:()=>lr,ZodNumber:()=>Tr,ZodObject:()=>Oe,ZodOptional:()=>Bt,ZodParsedType:()=>w,ZodPipeline:()=>Io,ZodPromise:()=>rn,ZodReadonly:()=>Dn,ZodRecord:()=>go,ZodSchema:()=>K,ZodSet:()=>tn,ZodString:()=>Lt,ZodSymbol:()=>lo,ZodTransformer:()=>vt,ZodTuple:()=>Qt,ZodType:()=>K,ZodUndefined:()=>Sn,ZodUnion:()=>Mn,ZodUnknown:()=>Fr,ZodVoid:()=>yo,addIssueToContext:()=>_,any:()=>ey,array:()=>oy,bigint:()=>Jl,boolean:()=>ec,coerce:()=>Ay,custom:()=>Xa,date:()=>Yl,datetimeRegex:()=>Ja,defaultErrorMap:()=>mr,discriminatedUnion:()=>cy,effect:()=>by,enum:()=>hy,function:()=>ly,getErrorMap:()=>Cn,getParsedType:()=>Yt,instanceof:()=>zl,intersection:()=>uy,isAborted:()=>os,isAsync:()=>An,isDirty:()=>ss,isValid:()=>Ar,late:()=>Vl,lazy:()=>yy,literal:()=>gy,makeIssue:()=>po,map:()=>my,nan:()=>Wl,nativeEnum:()=>xy,never:()=>ry,null:()=>Zl,nullable:()=>Ry,number:()=>Za,object:()=>sy,objectUtil:()=>ri,oboolean:()=>Cy,onumber:()=>ky,optional:()=>_y,ostring:()=>$y,pipeline:()=>wy,preprocess:()=>Oy,promise:()=>Iy,quotelessJson:()=>bl,record:()=>fy,set:()=>py,setErrorMap:()=>Rl,strictObject:()=>iy,string:()=>Qa,symbol:()=>Xl,transformer:()=>by,tuple:()=>dy,undefined:()=>Ql,union:()=>ay,unknown:()=>ty,util:()=>v,void:()=>ny});var mi={};ks(mi,{Any:()=>Or,Argument:()=>cc,Array:()=>mn,AsyncIterator:()=>pn,Awaited:()=>Gn,BigInt:()=>xn,Boolean:()=>qo,Capitalize:()=>$c,Composite:()=>dc,Const:()=>fc,Constructor:()=>ln,ConstructorParameters:()=>mc,Date:()=>us,Enum:()=>pc,Exclude:()=>Hn,Extends:()=>kn,Extract:()=>Vn,Function:()=>Wt,Index:()=>_r,InstanceType:()=>xc,Instantiate:()=>bc,Integer:()=>_c,Intersect:()=>Ve,Iterator:()=>In,KeyOf:()=>bn,Literal:()=>X,Lowercase:()=>kc,Mapped:()=>na,Module:()=>Dc,Never:()=>L,Not:()=>vc,Null:()=>ds,Number:()=>ht,Object:()=>re,Omit:()=>Nr,Optional:()=>He,Parameters:()=>qc,Partial:()=>zn,Pick:()=>Mr,Promise:()=>Vo,Readonly:()=>ot,ReadonlyOptional:()=>ys,Record:()=>gs,Recursive:()=>Gc,Ref:()=>bt,RegExp:()=>Hc,Required:()=>Wn,Rest:()=>Vc,ReturnType:()=>zc,String:()=>St,Symbol:()=>fs,TemplateLiteral:()=>Ho,Transform:()=>Yc,Tuple:()=>xt,Uint8Array:()=>ps,Uncapitalize:()=>Cc,Undefined:()=>ms,Union:()=>ee,Unknown:()=>wr,Unsafe:()=>Pi,Uppercase:()=>Ac,Void:()=>Xc});function Ao(e){return tt(e)&&globalThis.Symbol.asyncIterator in e}function Fo(e){return tt(e)&&globalThis.Symbol.iterator in e}function To(e){return e instanceof globalThis.Promise}function un(e){return e instanceof Date&&globalThis.Number.isFinite(e.getTime())}function dn(e){return e instanceof globalThis.Uint8Array}function Po(e,t){return t in e}function tt(e){return e!==null&&typeof e==="object"}function Ce(e){return globalThis.Array.isArray(e)&&!globalThis.ArrayBuffer.isView(e)}function Ye(e){return e===void 0}function jr(e){return e===null}function Er(e){return typeof e==="boolean"}function j(e){return typeof e==="number"}function So(e){return globalThis.Number.isInteger(e)}function ut(e){return typeof e==="bigint"}function je(e){return typeof e==="string"}function No(e){return typeof e==="function"}function Ur(e){return typeof e==="symbol"}function Mo(e){return ut(e)||Er(e)||jr(e)||j(e)||je(e)||Ur(e)||Ye(e)}var ae;(function(e){e.InstanceMode="default",e.ExactOptionalPropertyTypes=!1,e.AllowArrayObject=!1,e.AllowNaN=!1,e.AllowNullVoid=!1;function t(i,a){return e.ExactOptionalPropertyTypes?a in i:i[a]!==void 0}e.IsExactOptionalProperty=t;function r(i){let a=tt(i);return e.AllowArrayObject?a:a&&!Ce(i)}e.IsObjectLike=r;function n(i){return r(i)&&!(i instanceof Date)&&!(i instanceof Uint8Array)}e.IsRecordLike=n;function o(i){return e.AllowNaN?j(i):Number.isFinite(i)}e.IsNumberLike=o;function s(i){let a=Ye(i);return e.AllowNullVoid?a||i===null:a}e.IsVoidLike=s})(ae||(ae={}));var wi=new Map;function Cs(e){return wi.has(e)}function As(e){return wi.get(e)}var $i=new Map;function Yn(e){return $i.has(e)}function Fs(e){return $i.get(e)}function ki(e){return fe(e)&&!Ae(e)&&!hr(e)&&Symbol.asyncIterator in e}function Ae(e){return Array.isArray(e)}function Uo(e){return typeof e==="bigint"}function gr(e){return typeof e==="boolean"}function fn(e){return e instanceof globalThis.Date}function Ci(e){return typeof e==="function"}function Ai(e){return fe(e)&&!Ae(e)&&!hr(e)&&Symbol.iterator in e}function Fi(e){return e===null}function dt(e){return typeof e==="number"}function fe(e){return typeof e==="object"&&e!==null}function Lo(e){return e instanceof globalThis.RegExp}function ce(e){return typeof e==="string"}function Ti(e){return typeof e==="symbol"}function hr(e){return e instanceof globalThis.Uint8Array}function ue(e){return e===void 0}function xu(e){return globalThis.Object.freeze(e).map((t)=>Xn(t))}function Iu(e){return e}function bu(e){return e}function _u(e){return e}function Ru(e){let t={};for(let r of Object.getOwnPropertyNames(e))t[r]=Xn(e[r]);for(let r of Object.getOwnPropertySymbols(e))t[r]=Xn(e[r]);return globalThis.Object.freeze(t)}function Xn(e){return Ae(e)?xu(e):fn(e)?Iu(e):hr(e)?bu(e):Lo(e)?_u(e):fe(e)?Ru(e):e}function Ou(e){return e.map((t)=>Ko(t))}function wu(e){return new Date(e.getTime())}function $u(e){return new Uint8Array(e)}function ku(e){return new RegExp(e.source,e.flags)}function Cu(e){let t={};for(let r of Object.getOwnPropertyNames(e))t[r]=Ko(e[r]);for(let r of Object.getOwnPropertySymbols(e))t[r]=Ko(e[r]);return t}function Ko(e){return Ae(e)?Ou(e):fn(e)?wu(e):hr(e)?$u(e):Lo(e)?ku(e):fe(e)?Cu(e):e}function me(e){return Ko(e)}function y(e,t){let r=t!==void 0?{...t,...e}:e;switch(ae.InstanceMode){case"freeze":return Xn(r);case"clone":return me(r);default:return r}}var ge=Symbol.for("TypeBox.Transform"),Vt=Symbol.for("TypeBox.Readonly"),Be=Symbol.for("TypeBox.Optional"),zt=Symbol.for("TypeBox.Hint"),h=Symbol.for("TypeBox.Kind");function Pi(e={}){return y({[h]:e[h]??"Unsafe"},e)}class Y extends Error{constructor(e){super(e)}}function z(e){return y({[h]:"MappedResult",properties:e})}function Au(e,t){let{[t]:r,...n}=e;return n}function be(e,t){return t.reduce((r,n)=>Au(r,n),e)}function mn(e,t){return y({[h]:"Array",type:"array",items:e},t)}function pn(e,t){return y({[h]:"AsyncIterator",type:"AsyncIterator",items:e},t)}function ln(e,t,r){return y({[h]:"Constructor",type:"Constructor",parameters:e,returns:t},r)}function Wt(e,t,r){return y({[h]:"Function",type:"Function",parameters:e,returns:t},r)}function de(e,t,r){return y({[h]:"Computed",target:e,parameters:t},r)}function L(e){return y({[h]:"Never",not:{}},e)}function yn(e){return fe(e)&&e[Vt]==="Readonly"}function rt(e){return fe(e)&&e[Be]==="Optional"}function Ts(e){return G(e,"Any")}function Ps(e){return G(e,"Argument")}function kt(e){return G(e,"Array")}function Kr(e){return G(e,"AsyncIterator")}function Br(e){return G(e,"BigInt")}function tr(e){return G(e,"Boolean")}function Ct(e){return G(e,"Computed")}function At(e){return G(e,"Constructor")}function Fu(e){return G(e,"Date")}function Ft(e){return G(e,"Function")}function Tt(e){return G(e,"Integer")}function _e(e){return G(e,"Intersect")}function Dr(e){return G(e,"Iterator")}function G(e,t){return fe(e)&&h in e&&e[h]===t}function Bo(e){return gr(e)||dt(e)||ce(e)}function ft(e){return G(e,"Literal")}function mt(e){return G(e,"MappedKey")}function pe(e){return G(e,"MappedResult")}function xr(e){return G(e,"Never")}function Tu(e){return G(e,"Not")}function Qn(e){return G(e,"Null")}function Pt(e){return G(e,"Number")}function ke(e){return G(e,"Object")}function vr(e){return G(e,"Promise")}function qr(e){return G(e,"Record")}function we(e){return G(e,"Ref")}function Ss(e){return G(e,"RegExp")}function rr(e){return G(e,"String")}function Zn(e){return G(e,"Symbol")}function pt(e){return G(e,"TemplateLiteral")}function Pu(e){return G(e,"This")}function J(e){return fe(e)&&ge in e}function lt(e){return G(e,"Tuple")}function nr(e){return G(e,"Undefined")}function V(e){return G(e,"Union")}function Su(e){return G(e,"Uint8Array")}function Nu(e){return G(e,"Unknown")}function Mu(e){return G(e,"Unsafe")}function ju(e){return G(e,"Void")}function Eu(e){return fe(e)&&h in e&&ce(e[h])}function he(e){return Ts(e)||Ps(e)||kt(e)||tr(e)||Br(e)||Kr(e)||Ct(e)||At(e)||Fu(e)||Ft(e)||Tt(e)||_e(e)||Dr(e)||ft(e)||mt(e)||pe(e)||xr(e)||Tu(e)||Qn(e)||Pt(e)||ke(e)||vr(e)||qr(e)||we(e)||Ss(e)||rr(e)||Zn(e)||pt(e)||Pu(e)||lt(e)||nr(e)||V(e)||Su(e)||Nu(e)||Mu(e)||ju(e)||Eu(e)}function Uu(e){return y(be(e,[Be]))}function Lu(e){return y({...e,[Be]:"Optional"})}function Ku(e,t){return t===!1?Uu(e):Lu(e)}function He(e,t){let r=t??!0;return pe(e)?Si(e,r):Ku(e,r)}function Bu(e,t){let r={};for(let n of globalThis.Object.getOwnPropertyNames(e))r[n]=He(e[n],t);return r}function Du(e,t){return Bu(e.properties,t)}function Si(e,t){let r=Du(e,t);return z(r)}function eo(e,t={}){let r=e.every((o)=>ke(o)),n=he(t.unevaluatedProperties)?{unevaluatedProperties:t.unevaluatedProperties}:{};return y(t.unevaluatedProperties===!1||he(t.unevaluatedProperties)||r?{...n,[h]:"Intersect",type:"object",allOf:e}:{...n,[h]:"Intersect",allOf:e},t)}function vu(e){return e.every((t)=>rt(t))}function qu(e){return be(e,[Be])}function Ni(e){return e.map((t)=>rt(t)?qu(t):t)}function Gu(e,t){return vu(e)?He(eo(Ni(e),t)):eo(Ni(e),t)}function Do(e,t={}){if(e.length===1)return y(e[0],t);if(e.length===0)return L(t);if(e.some((r)=>J(r)))throw Error("Cannot intersect transform types");return Gu(e,t)}function Ve(e,t){if(e.length===1)return y(e[0],t);if(e.length===0)return L(t);if(e.some((r)=>J(r)))throw Error("Cannot intersect transform types");return eo(e,t)}function to(e,t){return y({[h]:"Union",anyOf:e},t)}function Hu(e){return e.some((t)=>rt(t))}function Mi(e){return e.map((t)=>rt(t)?Vu(t):t)}function Vu(e){return be(e,[Be])}function zu(e,t){return Hu(e)?He(to(Mi(e),t)):to(Mi(e),t)}function Jt(e,t){return e.length===1?y(e[0],t):e.length===0?L(t):zu(e,t)}function ee(e,t){return e.length===0?L(t):e.length===1?y(e[0],t):to(e,t)}class Ns extends Y{}function Wu(e){return e.replace(/\\\$/g,"$").replace(/\\\*/g,"*").replace(/\\\^/g,"^").replace(/\\\|/g,"|").replace(/\\\(/g,"(").replace(/\\\)/g,")")}function Ms(e,t,r){return e[t]===r&&e.charCodeAt(t-1)!==92}function sr(e,t){return Ms(e,t,"(")}function ro(e,t){return Ms(e,t,")")}function ji(e,t){return Ms(e,t,"|")}function Ju(e){if(!(sr(e,0)&&ro(e,e.length-1)))return!1;let t=0;for(let r=0;r<e.length;r++){if(sr(e,r))t+=1;if(ro(e,r))t-=1;if(t===0&&r!==e.length-1)return!1}return!0}function Yu(e){return e.slice(1,e.length-1)}function Xu(e){let t=0;for(let r=0;r<e.length;r++){if(sr(e,r))t+=1;if(ro(e,r))t-=1;if(ji(e,r)&&t===0)return!0}return!1}function Qu(e){for(let t=0;t<e.length;t++)if(sr(e,t))return!0;return!1}function Zu(e){let[t,r]=[0,0],n=[];for(let s=0;s<e.length;s++){if(sr(e,s))t+=1;if(ro(e,s))t-=1;if(ji(e,s)&&t===0){let i=e.slice(r,s);if(i.length>0)n.push(gn(i));r=s+1}}let o=e.slice(r);if(o.length>0)n.push(gn(o));if(n.length===0)return{type:"const",const:""};if(n.length===1)return n[0];return{type:"or",expr:n}}function ed(e){function t(o,s){if(!sr(o,s))throw new Ns("TemplateLiteralParser: Index must point to open parens");let i=0;for(let a=s;a<o.length;a++){if(sr(o,a))i+=1;if(ro(o,a))i-=1;if(i===0)return[s,a]}throw new Ns("TemplateLiteralParser: Unclosed group parens in expression")}function r(o,s){for(let i=s;i<o.length;i++)if(sr(o,i))return[s,i];return[s,o.length]}let n=[];for(let o=0;o<e.length;o++)if(sr(e,o)){let[s,i]=t(e,o),a=e.slice(s,i+1);n.push(gn(a)),o=i}else{let[s,i]=r(e,o),a=e.slice(s,i);if(a.length>0)n.push(gn(a));o=i-1}return n.length===0?{type:"const",const:""}:n.length===1?n[0]:{type:"and",expr:n}}function gn(e){return Ju(e)?gn(Yu(e)):Xu(e)?Zu(e):Qu(e)?ed(e):{type:"const",const:Wu(e)}}function hn(e){return gn(e.slice(1,e.length-1))}class Ei extends Y{}function td(e){return e.type==="or"&&e.expr.length===2&&e.expr[0].type==="const"&&e.expr[0].const==="0"&&e.expr[1].type==="const"&&e.expr[1].const==="[1-9][0-9]*"}function rd(e){return e.type==="or"&&e.expr.length===2&&e.expr[0].type==="const"&&e.expr[0].const==="true"&&e.expr[1].type==="const"&&e.expr[1].const==="false"}function nd(e){return e.type==="const"&&e.const===".*"}function Gr(e){return td(e)||nd(e)?!1:rd(e)?!0:e.type==="and"?e.expr.every((t)=>Gr(t)):e.type==="or"?e.expr.every((t)=>Gr(t)):e.type==="const"?!0:(()=>{throw new Ei("Unknown expression type")})()}function Ui(e){let t=hn(e.pattern);return Gr(t)}class Li extends Y{}function*Ki(e){if(e.length===1)return yield*e[0];for(let t of e[0])for(let r of Ki(e.slice(1)))yield`${t}${r}`}function*od(e){return yield*Ki(e.expr.map((t)=>[...no(t)]))}function*sd(e){for(let t of e.expr)yield*no(t)}function*id(e){return yield e.const}function*no(e){return e.type==="and"?yield*od(e):e.type==="or"?yield*sd(e):e.type==="const"?yield*id(e):(()=>{throw new Li("Unknown expression")})()}function vo(e){let t=hn(e.pattern);return Gr(t)?[...no(t)]:[]}function X(e,t){return y({[h]:"Literal",const:e,type:typeof e},t)}function qo(e){return y({[h]:"Boolean",type:"boolean"},e)}function xn(e){return y({[h]:"BigInt",type:"bigint"},e)}function ht(e){return y({[h]:"Number",type:"number"},e)}function St(e){return y({[h]:"String",type:"string"},e)}function*ad(e){let t=e.trim().replace(/"|'/g,"");return t==="boolean"?yield qo():t==="number"?yield ht():t==="bigint"?yield xn():t==="string"?yield St():yield(()=>{let r=t.split("|").map((n)=>X(n.trim()));return r.length===0?L():r.length===1?r[0]:Jt(r)})()}function*cd(e){if(e[1]!=="{"){let t=X("$"),r=js(e.slice(1));return yield*[t,...r]}for(let t=2;t<e.length;t++)if(e[t]==="}"){let r=ad(e.slice(2,t)),n=js(e.slice(t+1));return yield*[...r,...n]}yield X(e)}function*js(e){for(let t=0;t<e.length;t++)if(e[t]==="$"){let r=X(e.slice(0,t)),n=cd(e.slice(t));return yield*[r,...n]}yield X(e)}function Bi(e){return[...js(e)]}var Di="(true|false)",Go="(0|[1-9][0-9]*)",vi="(.*)";var Ir="^(0|[1-9][0-9]*)$",br="^(.*)$",qi="^(?!.*)$";class Gi extends Y{}function ud(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Hi(e,t){return pt(e)?e.pattern.slice(1,e.pattern.length-1):V(e)?`(${e.anyOf.map((r)=>Hi(r,t)).join("|")})`:Pt(e)?`${t}${Go}`:Tt(e)?`${t}${Go}`:Br(e)?`${t}${Go}`:rr(e)?`${t}${vi}`:ft(e)?`${t}${ud(e.const.toString())}`:tr(e)?`${t}${Di}`:(()=>{throw new Gi(`Unexpected Kind '${e[h]}'`)})()}function Es(e){return`^${e.map((t)=>Hi(t,"")).join("")}$`}function Hr(e){let r=vo(e).map((n)=>X(n));return Jt(r)}function Ho(e,t){let r=ce(e)?Es(Bi(e)):Es(e);return y({[h]:"TemplateLiteral",type:"string",pattern:r},t)}function dd(e){return vo(e).map((r)=>r.toString())}function fd(e){let t=[];for(let r of e)t.push(...nt(r));return t}function md(e){return[e.toString()]}function nt(e){return[...new Set(pt(e)?dd(e):V(e)?fd(e.anyOf):ft(e)?md(e.const):Pt(e)?["[number]"]:Tt(e)?["[number]"]:[])]}function pd(e,t,r){let n={};for(let o of Object.getOwnPropertyNames(t))n[o]=_r(e,nt(t[o]),r);return n}function ld(e,t,r){return pd(e,t.properties,r)}function Vi(e,t,r){let n=ld(e,t,r);return z(n)}function Wi(e,t){return e.map((r)=>Ji(r,t))}function yd(e){return e.filter((t)=>!xr(t))}function gd(e,t){return Do(yd(Wi(e,t)))}function hd(e){return e.some((t)=>xr(t))?[]:e}function xd(e,t){return Jt(hd(Wi(e,t)))}function Id(e,t){return t in e?e[t]:t==="[number]"?Jt(e):L()}function bd(e,t){return t==="[number]"?e:L()}function _d(e,t){return t in e?e[t]:L()}function Ji(e,t){return _e(e)?gd(e.allOf,t):V(e)?xd(e.anyOf,t):lt(e)?Id(e.items??[],t):kt(e)?bd(e.items,t):ke(e)?_d(e.properties,t):L()}function oo(e,t){return t.map((r)=>Ji(e,r))}function zi(e,t){return Jt(oo(e,t))}function _r(e,t,r){if(we(e)||we(t)){if(!he(e)||!he(t))throw new Y("Index types using Ref parameters require both Type and Key to be of TSchema");return de("Index",[e,t])}if(pe(t))return Vi(e,t,r);if(mt(t))return Yi(e,t,r);return y(he(t)?zi(e,nt(t)):zi(e,t),r)}function Rd(e,t,r){return{[t]:_r(e,[t],me(r))}}function Od(e,t,r){return t.reduce((n,o)=>({...n,...Rd(e,o,r)}),{})}function wd(e,t,r){return Od(e,t.keys,r)}function Yi(e,t,r){let n=wd(e,t,r);return z(n)}function In(e,t){return y({[h]:"Iterator",type:"Iterator",items:e},t)}function $d(e){return globalThis.Object.keys(e).filter((t)=>!rt(e[t]))}function kd(e,t){let r=$d(e),n=r.length>0?{[h]:"Object",type:"object",required:r,properties:e}:{[h]:"Object",type:"object",properties:e};return y(n,t)}var re=kd;function Vo(e,t){return y({[h]:"Promise",type:"Promise",item:e},t)}function Cd(e){return y(be(e,[Vt]))}function Ad(e){return y({...e,[Vt]:"Readonly"})}function Fd(e,t){return t===!1?Cd(e):Ad(e)}function ot(e,t){let r=t??!0;return pe(e)?Xi(e,r):Fd(e,r)}function Td(e,t){let r={};for(let n of globalThis.Object.getOwnPropertyNames(e))r[n]=ot(e[n],t);return r}function Pd(e,t){return Td(e.properties,t)}function Xi(e,t){let r=Pd(e,t);return z(r)}function xt(e,t){return y(e.length>0?{[h]:"Tuple",type:"array",items:e,additionalItems:!1,minItems:e.length,maxItems:e.length}:{[h]:"Tuple",type:"array",minItems:e.length,maxItems:e.length},t)}function Qi(e,t){return e.includes(t)}function Zi(e){return[...new Set(e)]}function Sd(e,t){return e.filter((r)=>t.includes(r))}function Nd(e,t){return e.reduce((r,n)=>Sd(r,n),t)}function ea(e){return e.length===1?e[0]:e.length>1?Nd(e.slice(1),e[0]):[]}function ta(e){let t=[];for(let r of e)t.push(...r);return t}function ra(e,t){return e in t?It(e,t[e]):z(t)}function Md(e){return{[e]:X(e)}}function jd(e){let t={};for(let r of e)t[r]=X(r);return t}function Ed(e,t){return Qi(t,e)?Md(e):jd(t)}function Ud(e,t){let r=Ed(e,t);return ra(e,r)}function so(e,t){return t.map((r)=>It(e,r))}function Ld(e,t){let r={};for(let n of globalThis.Object.getOwnPropertyNames(t))r[n]=It(e,t[n]);return r}function It(e,t){let r={...t};return rt(t)?He(It(e,be(t,[Be]))):yn(t)?ot(It(e,be(t,[Vt]))):pe(t)?ra(e,t.properties):mt(t)?Ud(e,t.keys):At(t)?ln(so(e,t.parameters),It(e,t.returns),r):Ft(t)?Wt(so(e,t.parameters),It(e,t.returns),r):Kr(t)?pn(It(e,t.items),r):Dr(t)?In(It(e,t.items),r):_e(t)?Ve(so(e,t.allOf),r):V(t)?ee(so(e,t.anyOf),r):lt(t)?xt(so(e,t.items??[]),r):ke(t)?re(Ld(e,t.properties),r):kt(t)?mn(It(e,t.items),r):vr(t)?Vo(It(e,t.item),r):t}function Kd(e,t){let r={};for(let n of e)r[n]=It(n,t);return r}function na(e,t,r){let n=he(e)?nt(e):e,o=t({[h]:"MappedKey",keys:n}),s=Kd(n,o);return re(s,r)}function bt(...e){let[t,r]=typeof e[0]==="string"?[e[0],e[1]]:[e[0].$id,e[1]];if(typeof t!=="string")throw new Y("Ref: $ref must be a string");return y({[h]:"Ref",$ref:t},r)}function oa(e){let t=[];for(let r of e)t.push(_t(r));return t}function Bd(e){let t=oa(e);return ta(t)}function Dd(e){let t=oa(e);return ea(t)}function vd(e){return e.map((t,r)=>r.toString())}function qd(e){return["[number]"]}function Gd(e){return globalThis.Object.getOwnPropertyNames(e)}function Hd(e){if(!Us)return[];return globalThis.Object.getOwnPropertyNames(e).map((r)=>r[0]==="^"&&r[r.length-1]==="$"?r.slice(1,r.length-1):r)}function _t(e){return _e(e)?Bd(e.allOf):V(e)?Dd(e.anyOf):lt(e)?vd(e.items??[]):kt(e)?qd(e.items):ke(e)?Gd(e.properties):qr(e)?Hd(e.patternProperties):[]}var Us=!1;function ir(e){Us=!0;let t=_t(e);return Us=!1,`^(${t.map((n)=>`(${n})`).join("|")})$`}function Vd(e,t){return de("KeyOf",[de(e,t)])}function zd(e){return de("KeyOf",[bt(e)])}function Wd(e,t){let r=_t(e),n=Jd(r),o=Jt(n);return y(o,t)}function Jd(e){return e.map((t)=>t==="[number]"?ht():X(t))}function bn(e,t){return Ct(e)?Vd(e.target,e.parameters):we(e)?zd(e.$ref):pe(e)?sa(e,t):Wd(e,t)}function Yd(e,t){let r={};for(let n of globalThis.Object.getOwnPropertyNames(e))r[n]=bn(e[n],me(t));return r}function Xd(e,t){return Yd(e.properties,t)}function sa(e,t){let r=Xd(e,t);return z(r)}function zo(e){let t=_t(e),r=oo(e,t);return t.map((n,o)=>[t[o],r[o]])}function Qd(e){return e.allOf.every((t)=>ar(t))}function Zd(e){return e.anyOf.some((t)=>ar(t))}function ef(e){return!ar(e.not)}function ar(e){return e[h]==="Intersect"?Qd(e):e[h]==="Union"?Zd(e):e[h]==="Not"?ef(e):e[h]==="Undefined"?!0:!1}function tf(e){switch(e.errorType){case p.ArrayContains:return"Expected array to contain at least one matching value";case p.ArrayMaxContains:return`Expected array to contain no more than ${e.schema.maxContains} matching values`;case p.ArrayMinContains:return`Expected array to contain at least ${e.schema.minContains} matching values`;case p.ArrayMaxItems:return`Expected array length to be less or equal to ${e.schema.maxItems}`;case p.ArrayMinItems:return`Expected array length to be greater or equal to ${e.schema.minItems}`;case p.ArrayUniqueItems:return"Expected array elements to be unique";case p.Array:return"Expected array";case p.AsyncIterator:return"Expected AsyncIterator";case p.BigIntExclusiveMaximum:return`Expected bigint to be less than ${e.schema.exclusiveMaximum}`;case p.BigIntExclusiveMinimum:return`Expected bigint to be greater than ${e.schema.exclusiveMinimum}`;case p.BigIntMaximum:return`Expected bigint to be less or equal to ${e.schema.maximum}`;case p.BigIntMinimum:return`Expected bigint to be greater or equal to ${e.schema.minimum}`;case p.BigIntMultipleOf:return`Expected bigint to be a multiple of ${e.schema.multipleOf}`;case p.BigInt:return"Expected bigint";case p.Boolean:return"Expected boolean";case p.DateExclusiveMinimumTimestamp:return`Expected Date timestamp to be greater than ${e.schema.exclusiveMinimumTimestamp}`;case p.DateExclusiveMaximumTimestamp:return`Expected Date timestamp to be less than ${e.schema.exclusiveMaximumTimestamp}`;case p.DateMinimumTimestamp:return`Expected Date timestamp to be greater or equal to ${e.schema.minimumTimestamp}`;case p.DateMaximumTimestamp:return`Expected Date timestamp to be less or equal to ${e.schema.maximumTimestamp}`;case p.DateMultipleOfTimestamp:return`Expected Date timestamp to be a multiple of ${e.schema.multipleOfTimestamp}`;case p.Date:return"Expected Date";case p.Function:return"Expected function";case p.IntegerExclusiveMaximum:return`Expected integer to be less than ${e.schema.exclusiveMaximum}`;case p.IntegerExclusiveMinimum:return`Expected integer to be greater than ${e.schema.exclusiveMinimum}`;case p.IntegerMaximum:return`Expected integer to be less or equal to ${e.schema.maximum}`;case p.IntegerMinimum:return`Expected integer to be greater or equal to ${e.schema.minimum}`;case p.IntegerMultipleOf:return`Expected integer to be a multiple of ${e.schema.multipleOf}`;case p.Integer:return"Expected integer";case p.IntersectUnevaluatedProperties:return"Unexpected property";case p.Intersect:return"Expected all values to match";case p.Iterator:return"Expected Iterator";case p.Literal:return`Expected ${typeof e.schema.const==="string"?`'${e.schema.const}'`:e.schema.const}`;case p.Never:return"Never";case p.Not:return"Value should not match";case p.Null:return"Expected null";case p.NumberExclusiveMaximum:return`Expected number to be less than ${e.schema.exclusiveMaximum}`;case p.NumberExclusiveMinimum:return`Expected number to be greater than ${e.schema.exclusiveMinimum}`;case p.NumberMaximum:return`Expected number to be less or equal to ${e.schema.maximum}`;case p.NumberMinimum:return`Expected number to be greater or equal to ${e.schema.minimum}`;case p.NumberMultipleOf:return`Expected number to be a multiple of ${e.schema.multipleOf}`;case p.Number:return"Expected number";case p.Object:return"Expected object";case p.ObjectAdditionalProperties:return"Unexpected property";case p.ObjectMaxProperties:return`Expected object to have no more than ${e.schema.maxProperties} properties`;case p.ObjectMinProperties:return`Expected object to have at least ${e.schema.minProperties} properties`;case p.ObjectRequiredProperty:return"Expected required property";case p.Promise:return"Expected Promise";case p.RegExp:return"Expected string to match regular expression";case p.StringFormatUnknown:return`Unknown format '${e.schema.format}'`;case p.StringFormat:return`Expected string to match '${e.schema.format}' format`;case p.StringMaxLength:return`Expected string length less or equal to ${e.schema.maxLength}`;case p.StringMinLength:return`Expected string length greater or equal to ${e.schema.minLength}`;case p.StringPattern:return`Expected string to match '${e.schema.pattern}'`;case p.String:return"Expected string";case p.Symbol:return"Expected symbol";case p.TupleLength:return`Expected tuple to have ${e.schema.maxItems||0} elements`;case p.Tuple:return"Expected tuple";case p.Uint8ArrayMaxByteLength:return`Expected byte length less or equal to ${e.schema.maxByteLength}`;case p.Uint8ArrayMinByteLength:return`Expected byte length greater or equal to ${e.schema.minByteLength}`;case p.Uint8Array:return"Expected Uint8Array";case p.Undefined:return"Expected undefined";case p.Union:return"Expected union value";case p.Void:return"Expected void";case p.Kind:return`Expected kind '${e.schema[h]}'`;default:return"Unknown error type"}}var rf=tf;function ia(){return rf}class aa extends Y{constructor(e){super(`Unable to dereference schema with $id '${e.$ref}'`);this.schema=e}}function nf(e,t){let r=t.find((n)=>n.$id===e.$ref);if(r===void 0)throw new aa(e);return Ee(r,t)}function Rr(e,t){if(!je(e.$id)||t.some((r)=>r.$id===e.$id))return t;return t.push(e),t}function Ee(e,t){return e[h]==="This"||e[h]==="Ref"?nf(e,t):e}class ca extends Y{constructor(e){super("Unable to hash value");this.value=e}}var yt;(function(e){e[e.Undefined=0]="Undefined",e[e.Null=1]="Null",e[e.Boolean=2]="Boolean",e[e.Number=3]="Number",e[e.String=4]="String",e[e.Object=5]="Object",e[e.Array=6]="Array",e[e.Date=7]="Date",e[e.Uint8Array=8]="Uint8Array",e[e.Symbol=9]="Symbol",e[e.BigInt=10]="BigInt"})(yt||(yt={}));var _n=BigInt("14695981039346656037"),[of,sf]=[BigInt("1099511628211"),BigInt("18446744073709551616")],af=Array.from({length:256}).map((e,t)=>BigInt(t)),ua=new Float64Array(1),da=new DataView(ua.buffer),fa=new Uint8Array(ua.buffer);function*cf(e){let t=e===0?1:Math.ceil(Math.floor(Math.log2(e)+1)/8);for(let r=0;r<t;r++)yield e>>8*(t-1-r)&255}function uf(e){ze(yt.Array);for(let t of e)Rn(t)}function df(e){ze(yt.Boolean),ze(e?1:0)}function ff(e){ze(yt.BigInt),da.setBigInt64(0,e);for(let t of fa)ze(t)}function mf(e){ze(yt.Date),Rn(e.getTime())}function pf(e){ze(yt.Null)}function lf(e){ze(yt.Number),da.setFloat64(0,e);for(let t of fa)ze(t)}function yf(e){ze(yt.Object);for(let t of globalThis.Object.getOwnPropertyNames(e).sort())Rn(t),Rn(e[t])}function gf(e){ze(yt.String);for(let t=0;t<e.length;t++)for(let r of cf(e.charCodeAt(t)))ze(r)}function hf(e){ze(yt.Symbol),Rn(e.description)}function xf(e){ze(yt.Uint8Array);for(let t=0;t<e.length;t++)ze(e[t])}function If(e){return ze(yt.Undefined)}function Rn(e){if(Ce(e))return uf(e);if(Er(e))return df(e);if(ut(e))return ff(e);if(un(e))return mf(e);if(jr(e))return pf(e);if(j(e))return lf(e);if(tt(e))return yf(e);if(je(e))return gf(e);if(Ur(e))return hf(e);if(dn(e))return xf(e);if(Ye(e))return If(e);throw new ca(e)}function ze(e){_n=_n^af[e],_n=_n*of%sf}function On(e){return _n=BigInt("14695981039346656037"),Rn(e),_n}function Or(e){return y({[h]:"Any"},e)}function wr(e){return y({[h]:"Unknown"},e)}var bf=["Argument","Any","Array","AsyncIterator","BigInt","Boolean","Computed","Constructor","Date","Enum","Function","Integer","Intersect","Iterator","Literal","MappedKey","MappedResult","Not","Null","Number","Object","Promise","Record","Ref","RegExp","String","Symbol","TemplateLiteral","This","Tuple","Undefined","Union","Uint8Array","Unknown","Void"];function ma(e){try{return new RegExp(e),!0}catch{return!1}}function Ls(e){if(!ce(e))return!1;for(let t=0;t<e.length;t++){let r=e.charCodeAt(t);if(r>=7&&r<=13||r===27||r===127)return!1}return!0}function pa(e){return Ks(e)||xe(e)}function io(e){return ue(e)||Uo(e)}function se(e){return ue(e)||dt(e)}function Ks(e){return ue(e)||gr(e)}function ne(e){return ue(e)||ce(e)}function _f(e){return ue(e)||ce(e)&&Ls(e)&&ma(e)}function Rf(e){return ue(e)||ce(e)&&Ls(e)}function la(e){return ue(e)||xe(e)}function Wo(e){return fe(e)&&e[Be]==="Optional"}function Nt(e){return H(e,"Any")&&ne(e.$id)}function Of(e){return H(e,"Argument")&&dt(e.index)}function Vr(e){return H(e,"Array")&&e.type==="array"&&ne(e.$id)&&xe(e.items)&&se(e.minItems)&&se(e.maxItems)&&Ks(e.uniqueItems)&&la(e.contains)&&se(e.minContains)&&se(e.maxContains)}function Bs(e){return H(e,"AsyncIterator")&&e.type==="AsyncIterator"&&ne(e.$id)&&xe(e.items)}function Jo(e){return H(e,"BigInt")&&e.type==="bigint"&&ne(e.$id)&&io(e.exclusiveMaximum)&&io(e.exclusiveMinimum)&&io(e.maximum)&&io(e.minimum)&&io(e.multipleOf)}function zr(e){return H(e,"Boolean")&&e.type==="boolean"&&ne(e.$id)}function wf(e){return H(e,"Computed")&&ce(e.target)&&Ae(e.parameters)&&e.parameters.every((t)=>xe(t))}function Yo(e){return H(e,"Constructor")&&e.type==="Constructor"&&ne(e.$id)&&Ae(e.parameters)&&e.parameters.every((t)=>xe(t))&&xe(e.returns)}function Xo(e){return H(e,"Date")&&e.type==="Date"&&ne(e.$id)&&se(e.exclusiveMaximumTimestamp)&&se(e.exclusiveMinimumTimestamp)&&se(e.maximumTimestamp)&&se(e.minimumTimestamp)&&se(e.multipleOfTimestamp)}function Qo(e){return H(e,"Function")&&e.type==="Function"&&ne(e.$id)&&Ae(e.parameters)&&e.parameters.every((t)=>xe(t))&&xe(e.returns)}function cr(e){return H(e,"Integer")&&e.type==="integer"&&ne(e.$id)&&se(e.exclusiveMaximum)&&se(e.exclusiveMinimum)&&se(e.maximum)&&se(e.minimum)&&se(e.multipleOf)}function ya(e){return fe(e)&&Object.entries(e).every(([t,r])=>Ls(t)&&xe(r))}function Wr(e){return H(e,"Intersect")&&(ce(e.type)&&e.type!=="object"?!1:!0)&&Ae(e.allOf)&&e.allOf.every((t)=>xe(t)&&!Tf(t))&&ne(e.type)&&(Ks(e.unevaluatedProperties)||la(e.unevaluatedProperties))&&ne(e.$id)}function Ds(e){return H(e,"Iterator")&&e.type==="Iterator"&&ne(e.$id)&&xe(e.items)}function H(e,t){return fe(e)&&h in e&&e[h]===t}function ga(e){return $r(e)&&ce(e.const)}function ha(e){return $r(e)&&dt(e.const)}function xa(e){return $r(e)&&gr(e.const)}function $r(e){return H(e,"Literal")&&ne(e.$id)&&$f(e.const)}function $f(e){return gr(e)||dt(e)||ce(e)}function kf(e){return H(e,"MappedKey")&&Ae(e.keys)&&e.keys.every((t)=>dt(t)||ce(t))}function Cf(e){return H(e,"MappedResult")&&ya(e.properties)}function kr(e){return H(e,"Never")&&fe(e.not)&&Object.getOwnPropertyNames(e.not).length===0}function wn(e){return H(e,"Not")&&xe(e.not)}function vs(e){return H(e,"Null")&&e.type==="null"&&ne(e.$id)}function st(e){return H(e,"Number")&&e.type==="number"&&ne(e.$id)&&se(e.exclusiveMaximum)&&se(e.exclusiveMinimum)&&se(e.maximum)&&se(e.minimum)&&se(e.multipleOf)}function Re(e){return H(e,"Object")&&e.type==="object"&&ne(e.$id)&&ya(e.properties)&&pa(e.additionalProperties)&&se(e.minProperties)&&se(e.maxProperties)}function qs(e){return H(e,"Promise")&&e.type==="Promise"&&ne(e.$id)&&xe(e.item)}function De(e){return H(e,"Record")&&e.type==="object"&&ne(e.$id)&&pa(e.additionalProperties)&&fe(e.patternProperties)&&((t)=>{let r=Object.getOwnPropertyNames(t.patternProperties);return r.length===1&&ma(r[0])&&fe(t.patternProperties)&&xe(t.patternProperties[r[0]])})(e)}function Af(e){return H(e,"Ref")&&ne(e.$id)&&ce(e.$ref)}function ao(e){return H(e,"RegExp")&&ne(e.$id)&&ce(e.source)&&ce(e.flags)&&se(e.maxLength)&&se(e.minLength)}function Mt(e){return H(e,"String")&&e.type==="string"&&ne(e.$id)&&se(e.minLength)&&se(e.maxLength)&&_f(e.pattern)&&Rf(e.format)}function co(e){return H(e,"Symbol")&&e.type==="symbol"&&ne(e.$id)}function uo(e){return H(e,"TemplateLiteral")&&e.type==="string"&&ce(e.pattern)&&e.pattern[0]==="^"&&e.pattern[e.pattern.length-1]==="$"}function Ff(e){return H(e,"This")&&ne(e.$id)&&ce(e.$ref)}function Tf(e){return fe(e)&&ge in e}function Zo(e){return H(e,"Tuple")&&e.type==="array"&&ne(e.$id)&&dt(e.minItems)&&dt(e.maxItems)&&e.minItems===e.maxItems&&(ue(e.items)&&ue(e.additionalItems)&&e.minItems===0||Ae(e.items)&&e.items.every((t)=>xe(t)))}function Jr(e){return H(e,"Undefined")&&e.type==="undefined"&&ne(e.$id)}function ur(e){return H(e,"Union")&&ne(e.$id)&&fe(e)&&Ae(e.anyOf)&&e.anyOf.every((t)=>xe(t))}function fo(e){return H(e,"Uint8Array")&&e.type==="Uint8Array"&&ne(e.$id)&&se(e.minByteLength)&&se(e.maxByteLength)}function jt(e){return H(e,"Unknown")&&ne(e.$id)}function Pf(e){return H(e,"Unsafe")}function es(e){return H(e,"Void")&&e.type==="void"&&ne(e.$id)}function Sf(e){return fe(e)&&h in e&&ce(e[h])&&!bf.includes(e[h])}function xe(e){return fe(e)&&(Nt(e)||Of(e)||Vr(e)||zr(e)||Jo(e)||Bs(e)||wf(e)||Yo(e)||Xo(e)||Qo(e)||cr(e)||Wr(e)||Ds(e)||$r(e)||kf(e)||Cf(e)||kr(e)||wn(e)||vs(e)||st(e)||Re(e)||qs(e)||De(e)||Af(e)||ao(e)||Mt(e)||co(e)||uo(e)||Ff(e)||Zo(e)||Jr(e)||ur(e)||fo(e)||jt(e)||Pf(e)||es(e)||Sf(e))}class wa extends Y{}var g;(function(e){e[e.Union=0]="Union",e[e.True=1]="True",e[e.False=2]="False"})(g||(g={}));function Rt(e){return e===g.False?e:g.True}function $n(e){throw new wa(e)}function Fe(e){return kr(e)||Wr(e)||ur(e)||jt(e)||Nt(e)}function Te(e,t){return kr(t)?Ca(e,t):Wr(t)?ts(e,t):ur(t)?Ws(e,t):jt(t)?Pa(e,t):Nt(t)?zs(e,t):$n("StructuralRight")}function zs(e,t){return g.True}function Nf(e,t){return Wr(t)?ts(e,t):ur(t)&&t.anyOf.some((r)=>Nt(r)||jt(r))?g.True:ur(t)?g.Union:jt(t)?g.True:Nt(t)?g.True:g.Union}function Mf(e,t){return jt(e)?g.False:Nt(e)?g.Union:kr(e)?g.True:g.False}function jf(e,t){return Re(t)&&rs(t)?g.True:Fe(t)?Te(e,t):!Vr(t)?g.False:Rt(oe(e.items,t.items))}function Ef(e,t){return Fe(t)?Te(e,t):!Bs(t)?g.False:Rt(oe(e.items,t.items))}function Uf(e,t){return Fe(t)?Te(e,t):Re(t)?We(e,t):De(t)?Ot(e,t):Jo(t)?g.True:g.False}function $a(e,t){return xa(e)?g.True:zr(e)?g.True:g.False}function Lf(e,t){return Fe(t)?Te(e,t):Re(t)?We(e,t):De(t)?Ot(e,t):zr(t)?g.True:g.False}function Kf(e,t){return Fe(t)?Te(e,t):Re(t)?We(e,t):!Yo(t)?g.False:e.parameters.length>t.parameters.length?g.False:!e.parameters.every((r,n)=>Rt(oe(t.parameters[n],r))===g.True)?g.False:Rt(oe(e.returns,t.returns))}function Bf(e,t){return Fe(t)?Te(e,t):Re(t)?We(e,t):De(t)?Ot(e,t):Xo(t)?g.True:g.False}function Df(e,t){return Fe(t)?Te(e,t):Re(t)?We(e,t):!Qo(t)?g.False:e.parameters.length>t.parameters.length?g.False:!e.parameters.every((r,n)=>Rt(oe(t.parameters[n],r))===g.True)?g.False:Rt(oe(e.returns,t.returns))}function ka(e,t){return $r(e)&&dt(e.const)?g.True:st(e)||cr(e)?g.True:g.False}function vf(e,t){return cr(t)||st(t)?g.True:Fe(t)?Te(e,t):Re(t)?We(e,t):De(t)?Ot(e,t):g.False}function ts(e,t){return t.allOf.every((r)=>oe(e,r)===g.True)?g.True:g.False}function qf(e,t){return e.allOf.some((r)=>oe(r,t)===g.True)?g.True:g.False}function Gf(e,t){return Fe(t)?Te(e,t):!Ds(t)?g.False:Rt(oe(e.items,t.items))}function Hf(e,t){return $r(t)&&t.const===e.const?g.True:Fe(t)?Te(e,t):Re(t)?We(e,t):De(t)?Ot(e,t):Mt(t)?Ta(e,t):st(t)?Aa(e,t):cr(t)?ka(e,t):zr(t)?$a(e,t):g.False}function Ca(e,t){return g.False}function Vf(e,t){return g.True}function ba(e){let[t,r]=[e,0];while(!0){if(!wn(t))break;t=t.not,r+=1}return r%2===0?t:wr()}function zf(e,t){return wn(e)?oe(ba(e),t):wn(t)?oe(e,ba(t)):$n("Invalid fallthrough for Not")}function Wf(e,t){return Fe(t)?Te(e,t):Re(t)?We(e,t):De(t)?Ot(e,t):vs(t)?g.True:g.False}function Aa(e,t){return ha(e)?g.True:st(e)||cr(e)?g.True:g.False}function Jf(e,t){return Fe(t)?Te(e,t):Re(t)?We(e,t):De(t)?Ot(e,t):cr(t)||st(t)?g.True:g.False}function it(e,t){return Object.getOwnPropertyNames(e.properties).length===t}function _a(e){return rs(e)}function Ra(e){return it(e,0)||it(e,1)&&"description"in e.properties&&ur(e.properties.description)&&e.properties.description.anyOf.length===2&&(Mt(e.properties.description.anyOf[0])&&Jr(e.properties.description.anyOf[1])||Mt(e.properties.description.anyOf[1])&&Jr(e.properties.description.anyOf[0]))}function Gs(e){return it(e,0)}function Oa(e){return it(e,0)}function Yf(e){return it(e,0)}function Xf(e){return it(e,0)}function Qf(e){return rs(e)}function Zf(e){let t=ht();return it(e,0)||it(e,1)&&"length"in e.properties&&Rt(oe(e.properties.length,t))===g.True}function em(e){return it(e,0)}function rs(e){let t=ht();return it(e,0)||it(e,1)&&"length"in e.properties&&Rt(oe(e.properties.length,t))===g.True}function tm(e){let t=Wt([Or()],Or());return it(e,0)||it(e,1)&&"then"in e.properties&&Rt(oe(e.properties.then,t))===g.True}function Fa(e,t){return oe(e,t)===g.False?g.False:Wo(e)&&!Wo(t)?g.False:g.True}function We(e,t){return jt(e)?g.False:Nt(e)?g.Union:kr(e)||ga(e)&&_a(t)||ha(e)&&Gs(t)||xa(e)&&Oa(t)||co(e)&&Ra(t)||Jo(e)&&Yf(t)||Mt(e)&&_a(t)||co(e)&&Ra(t)||st(e)&&Gs(t)||cr(e)&&Gs(t)||zr(e)&&Oa(t)||fo(e)&&Qf(t)||Xo(e)&&Xf(t)||Yo(e)&&em(t)||Qo(e)&&Zf(t)?g.True:De(e)&&Mt(Hs(e))?(()=>t[zt]==="Record"?g.True:g.False)():De(e)&&st(Hs(e))?(()=>it(t,0)?g.True:g.False)():g.False}function rm(e,t){return Fe(t)?Te(e,t):De(t)?Ot(e,t):!Re(t)?g.False:(()=>{for(let r of Object.getOwnPropertyNames(t.properties)){if(!(r in e.properties)&&!Wo(t.properties[r]))return g.False;if(Wo(t.properties[r]))return g.True;if(Fa(e.properties[r],t.properties[r])===g.False)return g.False}return g.True})()}function nm(e,t){return Fe(t)?Te(e,t):Re(t)&&tm(t)?g.True:!qs(t)?g.False:Rt(oe(e.item,t.item))}function Hs(e){return Ir in e.patternProperties?ht():(br in e.patternProperties)?St():$n("Unknown record key pattern")}function Vs(e){return Ir in e.patternProperties?e.patternProperties[Ir]:(br in e.patternProperties)?e.patternProperties[br]:$n("Unable to get record value schema")}function Ot(e,t){let[r,n]=[Hs(t),Vs(t)];return ga(e)&&st(r)&&Rt(oe(e,n))===g.True?g.True:fo(e)&&st(r)?oe(e,n):Mt(e)&&st(r)?oe(e,n):Vr(e)&&st(r)?oe(e,n):Re(e)?(()=>{for(let o of Object.getOwnPropertyNames(e.properties))if(Fa(n,e.properties[o])===g.False)return g.False;return g.True})():g.False}function om(e,t){return Fe(t)?Te(e,t):Re(t)?We(e,t):!De(t)?g.False:oe(Vs(e),Vs(t))}function sm(e,t){let r=ao(e)?St():e,n=ao(t)?St():t;return oe(r,n)}function Ta(e,t){return $r(e)&&ce(e.const)?g.True:Mt(e)?g.True:g.False}function im(e,t){return Fe(t)?Te(e,t):Re(t)?We(e,t):De(t)?Ot(e,t):Mt(t)?g.True:g.False}function am(e,t){return Fe(t)?Te(e,t):Re(t)?We(e,t):De(t)?Ot(e,t):co(t)?g.True:g.False}function cm(e,t){return uo(e)?oe(Hr(e),t):uo(t)?oe(e,Hr(t)):$n("Invalid fallthrough for TemplateLiteral")}function um(e,t){return Vr(t)&&e.items!==void 0&&e.items.every((r)=>oe(r,t.items)===g.True)}function dm(e,t){return kr(e)?g.True:jt(e)?g.False:Nt(e)?g.Union:g.False}function fm(e,t){return Fe(t)?Te(e,t):Re(t)&&rs(t)?g.True:Vr(t)&&um(e,t)?g.True:!Zo(t)?g.False:ue(e.items)&&!ue(t.items)||!ue(e.items)&&ue(t.items)?g.False:ue(e.items)&&!ue(t.items)?g.True:e.items.every((r,n)=>oe(r,t.items[n])===g.True)?g.True:g.False}function mm(e,t){return Fe(t)?Te(e,t):Re(t)?We(e,t):De(t)?Ot(e,t):fo(t)?g.True:g.False}function pm(e,t){return Fe(t)?Te(e,t):Re(t)?We(e,t):De(t)?Ot(e,t):es(t)?gm(e,t):Jr(t)?g.True:g.False}function Ws(e,t){return t.anyOf.some((r)=>oe(e,r)===g.True)?g.True:g.False}function lm(e,t){return e.anyOf.every((r)=>oe(r,t)===g.True)?g.True:g.False}function Pa(e,t){return g.True}function ym(e,t){return kr(t)?Ca(e,t):Wr(t)?ts(e,t):ur(t)?Ws(e,t):Nt(t)?zs(e,t):Mt(t)?Ta(e,t):st(t)?Aa(e,t):cr(t)?ka(e,t):zr(t)?$a(e,t):Vr(t)?Mf(e,t):Zo(t)?dm(e,t):Re(t)?We(e,t):jt(t)?g.True:g.False}function gm(e,t){return Jr(e)?g.True:Jr(e)?g.True:g.False}function hm(e,t){return Wr(t)?ts(e,t):ur(t)?Ws(e,t):jt(t)?Pa(e,t):Nt(t)?zs(e,t):Re(t)?We(e,t):es(t)?g.True:g.False}function oe(e,t){return uo(e)||uo(t)?cm(e,t):ao(e)||ao(t)?sm(e,t):wn(e)||wn(t)?zf(e,t):Nt(e)?Nf(e,t):Vr(e)?jf(e,t):Jo(e)?Uf(e,t):zr(e)?Lf(e,t):Bs(e)?Ef(e,t):Yo(e)?Kf(e,t):Xo(e)?Bf(e,t):Qo(e)?Df(e,t):cr(e)?vf(e,t):Wr(e)?qf(e,t):Ds(e)?Gf(e,t):$r(e)?Hf(e,t):kr(e)?Vf(e,t):vs(e)?Wf(e,t):st(e)?Jf(e,t):Re(e)?rm(e,t):De(e)?om(e,t):Mt(e)?im(e,t):co(e)?am(e,t):Zo(e)?fm(e,t):qs(e)?nm(e,t):fo(e)?mm(e,t):Jr(e)?pm(e,t):ur(e)?lm(e,t):jt(e)?ym(e,t):es(e)?hm(e,t):$n(`Unknown left type operand '${e[h]}'`)}function Cr(e,t){return oe(e,t)}function xm(e,t,r,n,o){let s={};for(let i of globalThis.Object.getOwnPropertyNames(e))s[i]=kn(e[i],t,r,n,me(o));return s}function Im(e,t,r,n,o){return xm(e.properties,t,r,n,o)}function Sa(e,t,r,n,o){let s=Im(e,t,r,n,o);return z(s)}function bm(e,t,r,n){let o=Cr(e,t);return o===g.Union?ee([r,n]):o===g.True?r:n}function kn(e,t,r,n,o){return pe(e)?Sa(e,t,r,n,o):mt(e)?y(Na(e,t,r,n,o)):y(bm(e,t,r,n),o)}function _m(e,t,r,n,o){return{[e]:kn(X(e),t,r,n,me(o))}}function Rm(e,t,r,n,o){return e.reduce((s,i)=>({...s,..._m(i,t,r,n,o)}),{})}function Om(e,t,r,n,o){return Rm(e.keys,t,r,n,o)}function Na(e,t,r,n,o){let s=Om(e,t,r,n,o);return z(s)}class Ma extends Y{constructor(e){super("Unknown type");this.schema=e}}function wm(e){return e[h]==="Any"||e[h]==="Unknown"}function B(e){return e!==void 0}function $m(e,t,r){return!0}function km(e,t,r){return!0}function Cm(e,t,r){if(!Ce(r))return!1;if(B(e.minItems)&&!(r.length>=e.minItems))return!1;if(B(e.maxItems)&&!(r.length<=e.maxItems))return!1;if(!r.every((s)=>Ue(e.items,t,s)))return!1;if(e.uniqueItems===!0&&!function(){let s=new Set;for(let i of r){let a=On(i);if(s.has(a))return!1;else s.add(a)}return!0}())return!1;if(!(B(e.contains)||j(e.minContains)||j(e.maxContains)))return!0;let n=B(e.contains)?e.contains:L(),o=r.reduce((s,i)=>Ue(n,t,i)?s+1:s,0);if(o===0)return!1;if(j(e.minContains)&&o<e.minContains)return!1;if(j(e.maxContains)&&o>e.maxContains)return!1;return!0}function Am(e,t,r){return Ao(r)}function Fm(e,t,r){if(!ut(r))return!1;if(B(e.exclusiveMaximum)&&!(r<e.exclusiveMaximum))return!1;if(B(e.exclusiveMinimum)&&!(r>e.exclusiveMinimum))return!1;if(B(e.maximum)&&!(r<=e.maximum))return!1;if(B(e.minimum)&&!(r>=e.minimum))return!1;if(B(e.multipleOf)&&r%e.multipleOf!==BigInt(0))return!1;return!0}function Tm(e,t,r){return Er(r)}function Pm(e,t,r){return Ue(e.returns,t,r.prototype)}function Sm(e,t,r){if(!un(r))return!1;if(B(e.exclusiveMaximumTimestamp)&&!(r.getTime()<e.exclusiveMaximumTimestamp))return!1;if(B(e.exclusiveMinimumTimestamp)&&!(r.getTime()>e.exclusiveMinimumTimestamp))return!1;if(B(e.maximumTimestamp)&&!(r.getTime()<=e.maximumTimestamp))return!1;if(B(e.minimumTimestamp)&&!(r.getTime()>=e.minimumTimestamp))return!1;if(B(e.multipleOfTimestamp)&&r.getTime()%e.multipleOfTimestamp!==0)return!1;return!0}function Nm(e,t,r){return No(r)}function Mm(e,t,r){let n=globalThis.Object.values(e.$defs),o=e.$defs[e.$ref];return Ue(o,[...t,...n],r)}function jm(e,t,r){if(!So(r))return!1;if(B(e.exclusiveMaximum)&&!(r<e.exclusiveMaximum))return!1;if(B(e.exclusiveMinimum)&&!(r>e.exclusiveMinimum))return!1;if(B(e.maximum)&&!(r<=e.maximum))return!1;if(B(e.minimum)&&!(r>=e.minimum))return!1;if(B(e.multipleOf)&&r%e.multipleOf!==0)return!1;return!0}function Em(e,t,r){let n=e.allOf.every((o)=>Ue(o,t,r));if(e.unevaluatedProperties===!1){let o=new RegExp(ir(e)),s=Object.getOwnPropertyNames(r).every((i)=>o.test(i));return n&&s}else if(he(e.unevaluatedProperties)){let o=new RegExp(ir(e)),s=Object.getOwnPropertyNames(r).every((i)=>o.test(i)||Ue(e.unevaluatedProperties,t,r[i]));return n&&s}else return n}function Um(e,t,r){return Fo(r)}function Lm(e,t,r){return r===e.const}function Km(e,t,r){return!1}function Bm(e,t,r){return!Ue(e.not,t,r)}function Dm(e,t,r){return jr(r)}function vm(e,t,r){if(!ae.IsNumberLike(r))return!1;if(B(e.exclusiveMaximum)&&!(r<e.exclusiveMaximum))return!1;if(B(e.exclusiveMinimum)&&!(r>e.exclusiveMinimum))return!1;if(B(e.minimum)&&!(r>=e.minimum))return!1;if(B(e.maximum)&&!(r<=e.maximum))return!1;if(B(e.multipleOf)&&r%e.multipleOf!==0)return!1;return!0}function qm(e,t,r){if(!ae.IsObjectLike(r))return!1;if(B(e.minProperties)&&!(Object.getOwnPropertyNames(r).length>=e.minProperties))return!1;if(B(e.maxProperties)&&!(Object.getOwnPropertyNames(r).length<=e.maxProperties))return!1;let n=Object.getOwnPropertyNames(e.properties);for(let o of n){let s=e.properties[o];if(e.required&&e.required.includes(o)){if(!Ue(s,t,r[o]))return!1;if((ar(s)||wm(s))&&!(o in r))return!1}else if(ae.IsExactOptionalProperty(r,o)&&!Ue(s,t,r[o]))return!1}if(e.additionalProperties===!1){let o=Object.getOwnPropertyNames(r);if(e.required&&e.required.length===n.length&&o.length===n.length)return!0;else return o.every((s)=>n.includes(s))}else if(typeof e.additionalProperties==="object")return Object.getOwnPropertyNames(r).every((s)=>n.includes(s)||Ue(e.additionalProperties,t,r[s]));else return!0}function Gm(e,t,r){return To(r)}function Hm(e,t,r){if(!ae.IsRecordLike(r))return!1;if(B(e.minProperties)&&!(Object.getOwnPropertyNames(r).length>=e.minProperties))return!1;if(B(e.maxProperties)&&!(Object.getOwnPropertyNames(r).length<=e.maxProperties))return!1;let[n,o]=Object.entries(e.patternProperties)[0],s=new RegExp(n),i=Object.entries(r).every(([u,m])=>s.test(u)?Ue(o,t,m):!0),a=typeof e.additionalProperties==="object"?Object.entries(r).every(([u,m])=>!s.test(u)?Ue(e.additionalProperties,t,m):!0):!0,c=e.additionalProperties===!1?Object.getOwnPropertyNames(r).every((u)=>s.test(u)):!0;return i&&a&&c}function Vm(e,t,r){return Ue(Ee(e,t),t,r)}function zm(e,t,r){let n=new RegExp(e.source,e.flags);if(B(e.minLength)){if(!(r.length>=e.minLength))return!1}if(B(e.maxLength)){if(!(r.length<=e.maxLength))return!1}return n.test(r)}function Wm(e,t,r){if(!je(r))return!1;if(B(e.minLength)){if(!(r.length>=e.minLength))return!1}if(B(e.maxLength)){if(!(r.length<=e.maxLength))return!1}if(B(e.pattern)){if(!new RegExp(e.pattern).test(r))return!1}if(B(e.format)){if(!Cs(e.format))return!1;return As(e.format)(r)}return!0}function Jm(e,t,r){return Ur(r)}function Ym(e,t,r){return je(r)&&new RegExp(e.pattern).test(r)}function Xm(e,t,r){return Ue(Ee(e,t),t,r)}function Qm(e,t,r){if(!Ce(r))return!1;if(e.items===void 0&&r.length!==0)return!1;if(r.length!==e.maxItems)return!1;if(!e.items)return!0;for(let n=0;n<e.items.length;n++)if(!Ue(e.items[n],t,r[n]))return!1;return!0}function Zm(e,t,r){return Ye(r)}function ep(e,t,r){return e.anyOf.some((n)=>Ue(n,t,r))}function tp(e,t,r){if(!dn(r))return!1;if(B(e.maxByteLength)&&!(r.length<=e.maxByteLength))return!1;if(B(e.minByteLength)&&!(r.length>=e.minByteLength))return!1;return!0}function rp(e,t,r){return!0}function np(e,t,r){return ae.IsVoidLike(r)}function op(e,t,r){if(!Yn(e[h]))return!1;return Fs(e[h])(e,r)}function Ue(e,t,r){let n=B(e.$id)?Rr(e,t):t,o=e;switch(o[h]){case"Any":return $m(o,n,r);case"Argument":return km(o,n,r);case"Array":return Cm(o,n,r);case"AsyncIterator":return Am(o,n,r);case"BigInt":return Fm(o,n,r);case"Boolean":return Tm(o,n,r);case"Constructor":return Pm(o,n,r);case"Date":return Sm(o,n,r);case"Function":return Nm(o,n,r);case"Import":return Mm(o,n,r);case"Integer":return jm(o,n,r);case"Intersect":return Em(o,n,r);case"Iterator":return Um(o,n,r);case"Literal":return Lm(o,n,r);case"Never":return Km(o,n,r);case"Not":return Bm(o,n,r);case"Null":return Dm(o,n,r);case"Number":return vm(o,n,r);case"Object":return qm(o,n,r);case"Promise":return Gm(o,n,r);case"Record":return Hm(o,n,r);case"Ref":return Vm(o,n,r);case"RegExp":return zm(o,n,r);case"String":return Wm(o,n,r);case"Symbol":return Jm(o,n,r);case"TemplateLiteral":return Ym(o,n,r);case"This":return Xm(o,n,r);case"Tuple":return Qm(o,n,r);case"Undefined":return Zm(o,n,r);case"Union":return ep(o,n,r);case"Uint8Array":return tp(o,n,r);case"Unknown":return rp(o,n,r);case"Void":return np(o,n,r);default:if(!Yn(o[h]))throw new Ma(o);return op(o,n,r)}}function Yr(...e){return e.length===3?Ue(e[0],e[1],e[2]):Ue(e[0],[],e[1])}var p;(function(e){e[e.ArrayContains=0]="ArrayContains",e[e.ArrayMaxContains=1]="ArrayMaxContains",e[e.ArrayMaxItems=2]="ArrayMaxItems",e[e.ArrayMinContains=3]="ArrayMinContains",e[e.ArrayMinItems=4]="ArrayMinItems",e[e.ArrayUniqueItems=5]="ArrayUniqueItems",e[e.Array=6]="Array",e[e.AsyncIterator=7]="AsyncIterator",e[e.BigIntExclusiveMaximum=8]="BigIntExclusiveMaximum",e[e.BigIntExclusiveMinimum=9]="BigIntExclusiveMinimum",e[e.BigIntMaximum=10]="BigIntMaximum",e[e.BigIntMinimum=11]="BigIntMinimum",e[e.BigIntMultipleOf=12]="BigIntMultipleOf",e[e.BigInt=13]="BigInt",e[e.Boolean=14]="Boolean",e[e.DateExclusiveMaximumTimestamp=15]="DateExclusiveMaximumTimestamp",e[e.DateExclusiveMinimumTimestamp=16]="DateExclusiveMinimumTimestamp",e[e.DateMaximumTimestamp=17]="DateMaximumTimestamp",e[e.DateMinimumTimestamp=18]="DateMinimumTimestamp",e[e.DateMultipleOfTimestamp=19]="DateMultipleOfTimestamp",e[e.Date=20]="Date",e[e.Function=21]="Function",e[e.IntegerExclusiveMaximum=22]="IntegerExclusiveMaximum",e[e.IntegerExclusiveMinimum=23]="IntegerExclusiveMinimum",e[e.IntegerMaximum=24]="IntegerMaximum",e[e.IntegerMinimum=25]="IntegerMinimum",e[e.IntegerMultipleOf=26]="IntegerMultipleOf",e[e.Integer=27]="Integer",e[e.IntersectUnevaluatedProperties=28]="IntersectUnevaluatedProperties",e[e.Intersect=29]="Intersect",e[e.Iterator=30]="Iterator",e[e.Kind=31]="Kind",e[e.Literal=32]="Literal",e[e.Never=33]="Never",e[e.Not=34]="Not",e[e.Null=35]="Null",e[e.NumberExclusiveMaximum=36]="NumberExclusiveMaximum",e[e.NumberExclusiveMinimum=37]="NumberExclusiveMinimum",e[e.NumberMaximum=38]="NumberMaximum",e[e.NumberMinimum=39]="NumberMinimum",e[e.NumberMultipleOf=40]="NumberMultipleOf",e[e.Number=41]="Number",e[e.ObjectAdditionalProperties=42]="ObjectAdditionalProperties",e[e.ObjectMaxProperties=43]="ObjectMaxProperties",e[e.ObjectMinProperties=44]="ObjectMinProperties",e[e.ObjectRequiredProperty=45]="ObjectRequiredProperty",e[e.Object=46]="Object",e[e.Promise=47]="Promise",e[e.RegExp=48]="RegExp",e[e.StringFormatUnknown=49]="StringFormatUnknown",e[e.StringFormat=50]="StringFormat",e[e.StringMaxLength=51]="StringMaxLength",e[e.StringMinLength=52]="StringMinLength",e[e.StringPattern=53]="StringPattern",e[e.String=54]="String",e[e.Symbol=55]="Symbol",e[e.TupleLength=56]="TupleLength",e[e.Tuple=57]="Tuple",e[e.Uint8ArrayMaxByteLength=58]="Uint8ArrayMaxByteLength",e[e.Uint8ArrayMinByteLength=59]="Uint8ArrayMinByteLength",e[e.Uint8Array=60]="Uint8Array",e[e.Undefined=61]="Undefined",e[e.Union=62]="Union",e[e.Void=63]="Void"})(p||(p={}));class ja extends Y{constructor(e){super("Unknown type");this.schema=e}}function dr(e){return e.replace(/~/g,"~0").replace(/\//g,"~1")}function D(e){return e!==void 0}class Js{constructor(e){this.iterator=e}[Symbol.iterator](){return this.iterator}First(){let e=this.iterator.next();return e.done?void 0:e.value}}function R(e,t,r,n,o=[]){return{type:e,schema:t,path:r,value:n,message:ia()({errorType:e,path:r,schema:t,value:n,errors:o}),errors:o}}function*sp(e,t,r,n){}function*ip(e,t,r,n){}function*ap(e,t,r,n){if(!Ce(n))return yield R(p.Array,e,r,n);if(D(e.minItems)&&!(n.length>=e.minItems))yield R(p.ArrayMinItems,e,r,n);if(D(e.maxItems)&&!(n.length<=e.maxItems))yield R(p.ArrayMaxItems,e,r,n);for(let i=0;i<n.length;i++)yield*Le(e.items,t,`${r}/${i}`,n[i]);if(e.uniqueItems===!0&&!function(){let i=new Set;for(let a of n){let c=On(a);if(i.has(c))return!1;else i.add(c)}return!0}())yield R(p.ArrayUniqueItems,e,r,n);if(!(D(e.contains)||D(e.minContains)||D(e.maxContains)))return;let o=D(e.contains)?e.contains:L(),s=n.reduce((i,a,c)=>Le(o,t,`${r}${c}`,a).next().done===!0?i+1:i,0);if(s===0)yield R(p.ArrayContains,e,r,n);if(j(e.minContains)&&s<e.minContains)yield R(p.ArrayMinContains,e,r,n);if(j(e.maxContains)&&s>e.maxContains)yield R(p.ArrayMaxContains,e,r,n)}function*cp(e,t,r,n){if(!Ao(n))yield R(p.AsyncIterator,e,r,n)}function*up(e,t,r,n){if(!ut(n))return yield R(p.BigInt,e,r,n);if(D(e.exclusiveMaximum)&&!(n<e.exclusiveMaximum))yield R(p.BigIntExclusiveMaximum,e,r,n);if(D(e.exclusiveMinimum)&&!(n>e.exclusiveMinimum))yield R(p.BigIntExclusiveMinimum,e,r,n);if(D(e.maximum)&&!(n<=e.maximum))yield R(p.BigIntMaximum,e,r,n);if(D(e.minimum)&&!(n>=e.minimum))yield R(p.BigIntMinimum,e,r,n);if(D(e.multipleOf)&&n%e.multipleOf!==BigInt(0))yield R(p.BigIntMultipleOf,e,r,n)}function*dp(e,t,r,n){if(!Er(n))yield R(p.Boolean,e,r,n)}function*fp(e,t,r,n){yield*Le(e.returns,t,r,n.prototype)}function*mp(e,t,r,n){if(!un(n))return yield R(p.Date,e,r,n);if(D(e.exclusiveMaximumTimestamp)&&!(n.getTime()<e.exclusiveMaximumTimestamp))yield R(p.DateExclusiveMaximumTimestamp,e,r,n);if(D(e.exclusiveMinimumTimestamp)&&!(n.getTime()>e.exclusiveMinimumTimestamp))yield R(p.DateExclusiveMinimumTimestamp,e,r,n);if(D(e.maximumTimestamp)&&!(n.getTime()<=e.maximumTimestamp))yield R(p.DateMaximumTimestamp,e,r,n);if(D(e.minimumTimestamp)&&!(n.getTime()>=e.minimumTimestamp))yield R(p.DateMinimumTimestamp,e,r,n);if(D(e.multipleOfTimestamp)&&n.getTime()%e.multipleOfTimestamp!==0)yield R(p.DateMultipleOfTimestamp,e,r,n)}function*pp(e,t,r,n){if(!No(n))yield R(p.Function,e,r,n)}function*lp(e,t,r,n){let o=globalThis.Object.values(e.$defs),s=e.$defs[e.$ref];yield*Le(s,[...t,...o],r,n)}function*yp(e,t,r,n){if(!So(n))return yield R(p.Integer,e,r,n);if(D(e.exclusiveMaximum)&&!(n<e.exclusiveMaximum))yield R(p.IntegerExclusiveMaximum,e,r,n);if(D(e.exclusiveMinimum)&&!(n>e.exclusiveMinimum))yield R(p.IntegerExclusiveMinimum,e,r,n);if(D(e.maximum)&&!(n<=e.maximum))yield R(p.IntegerMaximum,e,r,n);if(D(e.minimum)&&!(n>=e.minimum))yield R(p.IntegerMinimum,e,r,n);if(D(e.multipleOf)&&n%e.multipleOf!==0)yield R(p.IntegerMultipleOf,e,r,n)}function*gp(e,t,r,n){let o=!1;for(let s of e.allOf)for(let i of Le(s,t,r,n))o=!0,yield i;if(o)return yield R(p.Intersect,e,r,n);if(e.unevaluatedProperties===!1){let s=new RegExp(ir(e));for(let i of Object.getOwnPropertyNames(n))if(!s.test(i))yield R(p.IntersectUnevaluatedProperties,e,`${r}/${i}`,n)}if(typeof e.unevaluatedProperties==="object"){let s=new RegExp(ir(e));for(let i of Object.getOwnPropertyNames(n))if(!s.test(i)){let a=Le(e.unevaluatedProperties,t,`${r}/${i}`,n[i]).next();if(!a.done)yield a.value}}}function*hp(e,t,r,n){if(!Fo(n))yield R(p.Iterator,e,r,n)}function*xp(e,t,r,n){if(n!==e.const)yield R(p.Literal,e,r,n)}function*Ip(e,t,r,n){yield R(p.Never,e,r,n)}function*bp(e,t,r,n){if(Le(e.not,t,r,n).next().done===!0)yield R(p.Not,e,r,n)}function*_p(e,t,r,n){if(!jr(n))yield R(p.Null,e,r,n)}function*Rp(e,t,r,n){if(!ae.IsNumberLike(n))return yield R(p.Number,e,r,n);if(D(e.exclusiveMaximum)&&!(n<e.exclusiveMaximum))yield R(p.NumberExclusiveMaximum,e,r,n);if(D(e.exclusiveMinimum)&&!(n>e.exclusiveMinimum))yield R(p.NumberExclusiveMinimum,e,r,n);if(D(e.maximum)&&!(n<=e.maximum))yield R(p.NumberMaximum,e,r,n);if(D(e.minimum)&&!(n>=e.minimum))yield R(p.NumberMinimum,e,r,n);if(D(e.multipleOf)&&n%e.multipleOf!==0)yield R(p.NumberMultipleOf,e,r,n)}function*Op(e,t,r,n){if(!ae.IsObjectLike(n))return yield R(p.Object,e,r,n);if(D(e.minProperties)&&!(Object.getOwnPropertyNames(n).length>=e.minProperties))yield R(p.ObjectMinProperties,e,r,n);if(D(e.maxProperties)&&!(Object.getOwnPropertyNames(n).length<=e.maxProperties))yield R(p.ObjectMaxProperties,e,r,n);let o=Array.isArray(e.required)?e.required:[],s=Object.getOwnPropertyNames(e.properties),i=Object.getOwnPropertyNames(n);for(let a of o){if(i.includes(a))continue;yield R(p.ObjectRequiredProperty,e.properties[a],`${r}/${dr(a)}`,void 0)}if(e.additionalProperties===!1){for(let a of i)if(!s.includes(a))yield R(p.ObjectAdditionalProperties,e,`${r}/${dr(a)}`,n[a])}if(typeof e.additionalProperties==="object")for(let a of i){if(s.includes(a))continue;yield*Le(e.additionalProperties,t,`${r}/${dr(a)}`,n[a])}for(let a of s){let c=e.properties[a];if(e.required&&e.required.includes(a)){if(yield*Le(c,t,`${r}/${dr(a)}`,n[a]),ar(e)&&!(a in n))yield R(p.ObjectRequiredProperty,c,`${r}/${dr(a)}`,void 0)}else if(ae.IsExactOptionalProperty(n,a))yield*Le(c,t,`${r}/${dr(a)}`,n[a])}}function*wp(e,t,r,n){if(!To(n))yield R(p.Promise,e,r,n)}function*$p(e,t,r,n){if(!ae.IsRecordLike(n))return yield R(p.Object,e,r,n);if(D(e.minProperties)&&!(Object.getOwnPropertyNames(n).length>=e.minProperties))yield R(p.ObjectMinProperties,e,r,n);if(D(e.maxProperties)&&!(Object.getOwnPropertyNames(n).length<=e.maxProperties))yield R(p.ObjectMaxProperties,e,r,n);let[o,s]=Object.entries(e.patternProperties)[0],i=new RegExp(o);for(let[a,c]of Object.entries(n))if(i.test(a))yield*Le(s,t,`${r}/${dr(a)}`,c);if(typeof e.additionalProperties==="object"){for(let[a,c]of Object.entries(n))if(!i.test(a))yield*Le(e.additionalProperties,t,`${r}/${dr(a)}`,c)}if(e.additionalProperties===!1)for(let[a,c]of Object.entries(n)){if(i.test(a))continue;return yield R(p.ObjectAdditionalProperties,e,`${r}/${dr(a)}`,c)}}function*kp(e,t,r,n){yield*Le(Ee(e,t),t,r,n)}function*Cp(e,t,r,n){if(!je(n))return yield R(p.String,e,r,n);if(D(e.minLength)&&!(n.length>=e.minLength))yield R(p.StringMinLength,e,r,n);if(D(e.maxLength)&&!(n.length<=e.maxLength))yield R(p.StringMaxLength,e,r,n);if(!new RegExp(e.source,e.flags).test(n))return yield R(p.RegExp,e,r,n)}function*Ap(e,t,r,n){if(!je(n))return yield R(p.String,e,r,n);if(D(e.minLength)&&!(n.length>=e.minLength))yield R(p.StringMinLength,e,r,n);if(D(e.maxLength)&&!(n.length<=e.maxLength))yield R(p.StringMaxLength,e,r,n);if(je(e.pattern)){if(!new RegExp(e.pattern).test(n))yield R(p.StringPattern,e,r,n)}if(je(e.format)){if(!Cs(e.format))yield R(p.StringFormatUnknown,e,r,n);else if(!As(e.format)(n))yield R(p.StringFormat,e,r,n)}}function*Fp(e,t,r,n){if(!Ur(n))yield R(p.Symbol,e,r,n)}function*Tp(e,t,r,n){if(!je(n))return yield R(p.String,e,r,n);if(!new RegExp(e.pattern).test(n))yield R(p.StringPattern,e,r,n)}function*Pp(e,t,r,n){yield*Le(Ee(e,t),t,r,n)}function*Sp(e,t,r,n){if(!Ce(n))return yield R(p.Tuple,e,r,n);if(e.items===void 0&&n.length!==0)return yield R(p.TupleLength,e,r,n);if(n.length!==e.maxItems)return yield R(p.TupleLength,e,r,n);if(!e.items)return;for(let o=0;o<e.items.length;o++)yield*Le(e.items[o],t,`${r}/${o}`,n[o])}function*Np(e,t,r,n){if(!Ye(n))yield R(p.Undefined,e,r,n)}function*Mp(e,t,r,n){if(Yr(e,t,n))return;let o=e.anyOf.map((s)=>new Js(Le(s,t,r,n)));yield R(p.Union,e,r,n,o)}function*jp(e,t,r,n){if(!dn(n))return yield R(p.Uint8Array,e,r,n);if(D(e.maxByteLength)&&!(n.length<=e.maxByteLength))yield R(p.Uint8ArrayMaxByteLength,e,r,n);if(D(e.minByteLength)&&!(n.length>=e.minByteLength))yield R(p.Uint8ArrayMinByteLength,e,r,n)}function*Ep(e,t,r,n){}function*Up(e,t,r,n){if(!ae.IsVoidLike(n))yield R(p.Void,e,r,n)}function*Lp(e,t,r,n){if(!Fs(e[h])(e,n))yield R(p.Kind,e,r,n)}function*Le(e,t,r,n){let o=D(e.$id)?[...t,e]:t,s=e;switch(s[h]){case"Any":return yield*sp(s,o,r,n);case"Argument":return yield*ip(s,o,r,n);case"Array":return yield*ap(s,o,r,n);case"AsyncIterator":return yield*cp(s,o,r,n);case"BigInt":return yield*up(s,o,r,n);case"Boolean":return yield*dp(s,o,r,n);case"Constructor":return yield*fp(s,o,r,n);case"Date":return yield*mp(s,o,r,n);case"Function":return yield*pp(s,o,r,n);case"Import":return yield*lp(s,o,r,n);case"Integer":return yield*yp(s,o,r,n);case"Intersect":return yield*gp(s,o,r,n);case"Iterator":return yield*hp(s,o,r,n);case"Literal":return yield*xp(s,o,r,n);case"Never":return yield*Ip(s,o,r,n);case"Not":return yield*bp(s,o,r,n);case"Null":return yield*_p(s,o,r,n);case"Number":return yield*Rp(s,o,r,n);case"Object":return yield*Op(s,o,r,n);case"Promise":return yield*wp(s,o,r,n);case"Record":return yield*$p(s,o,r,n);case"Ref":return yield*kp(s,o,r,n);case"RegExp":return yield*Cp(s,o,r,n);case"String":return yield*Ap(s,o,r,n);case"Symbol":return yield*Fp(s,o,r,n);case"TemplateLiteral":return yield*Tp(s,o,r,n);case"This":return yield*Pp(s,o,r,n);case"Tuple":return yield*Sp(s,o,r,n);case"Undefined":return yield*Np(s,o,r,n);case"Union":return yield*Mp(s,o,r,n);case"Uint8Array":return yield*jp(s,o,r,n);case"Unknown":return yield*Ep(s,o,r,n);case"Void":return yield*Up(s,o,r,n);default:if(!Yn(s[h]))throw new ja(e);return yield*Lp(s,o,r,n)}}function Ea(...e){let t=e.length===3?Le(e[0],e[1],"",e[2]):Le(e[0],[],"",e[1]);return new Js(t)}class Ys extends Y{constructor(e,t,r){super("Unable to decode value as it does not match the expected schema");this.schema=e,this.value=t,this.error=r}}class Ua extends Y{constructor(e,t,r,n){super(n instanceof Error?n.message:"Unknown error");this.schema=e,this.path=t,this.value=r,this.error=n}}function Ie(e,t,r){try{return J(e)?e[ge].Decode(r):r}catch(n){throw new Ua(e,t,r,n)}}function Kp(e,t,r,n){return Ce(n)?Ie(e,r,n.map((o,s)=>Et(e.items,t,`${r}/${s}`,o))):Ie(e,r,n)}function Bp(e,t,r,n){if(!tt(n)||Mo(n))return Ie(e,r,n);let o=zo(e),s=o.map((m)=>m[0]),i={...n};for(let[m,l]of o)if(m in i)i[m]=Et(l,t,`${r}/${m}`,i[m]);if(!J(e.unevaluatedProperties))return Ie(e,r,i);let a=Object.getOwnPropertyNames(i),c=e.unevaluatedProperties,u={...i};for(let m of a)if(!s.includes(m))u[m]=Ie(c,`${r}/${m}`,u[m]);return Ie(e,r,u)}function Dp(e,t,r,n){let o=globalThis.Object.values(e.$defs),s=e.$defs[e.$ref],i=Et(s,[...t,...o],r,n);return Ie(e,r,i)}function vp(e,t,r,n){return Ie(e,r,Et(e.not,t,r,n))}function qp(e,t,r,n){if(!tt(n))return Ie(e,r,n);let o=_t(e),s={...n};for(let u of o){if(!Po(s,u))continue;if(Ye(s[u])&&(!nr(e.properties[u])||ae.IsExactOptionalProperty(s,u)))continue;s[u]=Et(e.properties[u],t,`${r}/${u}`,s[u])}if(!he(e.additionalProperties))return Ie(e,r,s);let i=Object.getOwnPropertyNames(s),a=e.additionalProperties,c={...s};for(let u of i)if(!o.includes(u))c[u]=Ie(a,`${r}/${u}`,c[u]);return Ie(e,r,c)}function Gp(e,t,r,n){if(!tt(n))return Ie(e,r,n);let o=Object.getOwnPropertyNames(e.patternProperties)[0],s=new RegExp(o),i={...n};for(let m of Object.getOwnPropertyNames(n))if(s.test(m))i[m]=Et(e.patternProperties[o],t,`${r}/${m}`,i[m]);if(!he(e.additionalProperties))return Ie(e,r,i);let a=Object.getOwnPropertyNames(i),c=e.additionalProperties,u={...i};for(let m of a)if(!s.test(m))u[m]=Ie(c,`${r}/${m}`,u[m]);return Ie(e,r,u)}function Hp(e,t,r,n){let o=Ee(e,t);return Ie(e,r,Et(o,t,r,n))}function Vp(e,t,r,n){let o=Ee(e,t);return Ie(e,r,Et(o,t,r,n))}function zp(e,t,r,n){return Ce(n)&&Ce(e.items)?Ie(e,r,e.items.map((o,s)=>Et(o,t,`${r}/${s}`,n[s]))):Ie(e,r,n)}function Wp(e,t,r,n){for(let o of e.anyOf){if(!Yr(o,t,n))continue;let s=Et(o,t,r,n);return Ie(e,r,s)}return Ie(e,r,n)}function Et(e,t,r,n){let o=Rr(e,t),s=e;switch(e[h]){case"Array":return Kp(s,o,r,n);case"Import":return Dp(s,o,r,n);case"Intersect":return Bp(s,o,r,n);case"Not":return vp(s,o,r,n);case"Object":return qp(s,o,r,n);case"Record":return Gp(s,o,r,n);case"Ref":return Hp(s,o,r,n);case"Symbol":return Ie(s,r,n);case"This":return Vp(s,o,r,n);case"Tuple":return zp(s,o,r,n);case"Union":return Wp(s,o,r,n);default:return Ie(s,r,n)}}function La(e,t,r){return Et(e,t,"",r)}class Xs extends Y{constructor(e,t,r){super("The encoded value does not match the expected schema");this.schema=e,this.value=t,this.error=r}}class Ka extends Y{constructor(e,t,r,n){super(`${n instanceof Error?n.message:"Unknown error"}`);this.schema=e,this.path=t,this.value=r,this.error=n}}function ve(e,t,r){try{return J(e)?e[ge].Encode(r):r}catch(n){throw new Ka(e,t,r,n)}}function Jp(e,t,r,n){let o=ve(e,r,n);return Ce(o)?o.map((s,i)=>Ut(e.items,t,`${r}/${i}`,s)):o}function Yp(e,t,r,n){let o=globalThis.Object.values(e.$defs),s=e.$defs[e.$ref],i=ve(e,r,n);return Ut(s,[...t,...o],r,i)}function Xp(e,t,r,n){let o=ve(e,r,n);if(!tt(n)||Mo(n))return o;let s=zo(e),i=s.map((l)=>l[0]),a={...o};for(let[l,x]of s)if(l in a)a[l]=Ut(x,t,`${r}/${l}`,a[l]);if(!J(e.unevaluatedProperties))return a;let c=Object.getOwnPropertyNames(a),u=e.unevaluatedProperties,m={...a};for(let l of c)if(!i.includes(l))m[l]=ve(u,`${r}/${l}`,m[l]);return m}function Qp(e,t,r,n){return ve(e.not,r,ve(e,r,n))}function Zp(e,t,r,n){let o=ve(e,r,n);if(!tt(o))return o;let s=_t(e),i={...o};for(let m of s){if(!Po(i,m))continue;if(Ye(i[m])&&(!nr(e.properties[m])||ae.IsExactOptionalProperty(i,m)))continue;i[m]=Ut(e.properties[m],t,`${r}/${m}`,i[m])}if(!he(e.additionalProperties))return i;let a=Object.getOwnPropertyNames(i),c=e.additionalProperties,u={...i};for(let m of a)if(!s.includes(m))u[m]=ve(c,`${r}/${m}`,u[m]);return u}function el(e,t,r,n){let o=ve(e,r,n);if(!tt(n))return o;let s=Object.getOwnPropertyNames(e.patternProperties)[0],i=new RegExp(s),a={...o};for(let l of Object.getOwnPropertyNames(n))if(i.test(l))a[l]=Ut(e.patternProperties[s],t,`${r}/${l}`,a[l]);if(!he(e.additionalProperties))return a;let c=Object.getOwnPropertyNames(a),u=e.additionalProperties,m={...a};for(let l of c)if(!i.test(l))m[l]=ve(u,`${r}/${l}`,m[l]);return m}function tl(e,t,r,n){let o=Ee(e,t),s=Ut(o,t,r,n);return ve(e,r,s)}function rl(e,t,r,n){let o=Ee(e,t),s=Ut(o,t,r,n);return ve(e,r,s)}function nl(e,t,r,n){let o=ve(e,r,n);return Ce(e.items)?e.items.map((s,i)=>Ut(s,t,`${r}/${i}`,o[i])):[]}function ol(e,t,r,n){for(let o of e.anyOf){if(!Yr(o,t,n))continue;let s=Ut(o,t,r,n);return ve(e,r,s)}for(let o of e.anyOf){let s=Ut(o,t,r,n);if(!Yr(e,t,s))continue;return ve(e,r,s)}return ve(e,r,n)}function Ut(e,t,r,n){let o=Rr(e,t),s=e;switch(e[h]){case"Array":return Jp(s,o,r,n);case"Import":return Yp(s,o,r,n);case"Intersect":return Xp(s,o,r,n);case"Not":return Qp(s,o,r,n);case"Object":return Zp(s,o,r,n);case"Record":return el(s,o,r,n);case"Ref":return tl(s,o,r,n);case"This":return rl(s,o,r,n);case"Tuple":return nl(s,o,r,n);case"Union":return ol(s,o,r,n);default:return ve(s,r,n)}}function Ba(e,t,r){return Ut(e,t,"",r)}function sl(e,t){return J(e)||Ne(e.items,t)}function il(e,t){return J(e)||Ne(e.items,t)}function al(e,t){return J(e)||Ne(e.returns,t)||e.parameters.some((r)=>Ne(r,t))}function cl(e,t){return J(e)||Ne(e.returns,t)||e.parameters.some((r)=>Ne(r,t))}function ul(e,t){return J(e)||J(e.unevaluatedProperties)||e.allOf.some((r)=>Ne(r,t))}function dl(e,t){let r=globalThis.Object.getOwnPropertyNames(e.$defs).reduce((o,s)=>[...o,e.$defs[s]],[]),n=e.$defs[e.$ref];return J(e)||Ne(n,[...r,...t])}function fl(e,t){return J(e)||Ne(e.items,t)}function ml(e,t){return J(e)||Ne(e.not,t)}function pl(e,t){return J(e)||Object.values(e.properties).some((r)=>Ne(r,t))||he(e.additionalProperties)&&Ne(e.additionalProperties,t)}function ll(e,t){return J(e)||Ne(e.item,t)}function yl(e,t){let r=Object.getOwnPropertyNames(e.patternProperties)[0],n=e.patternProperties[r];return J(e)||Ne(n,t)||he(e.additionalProperties)&&J(e.additionalProperties)}function gl(e,t){if(J(e))return!0;return Ne(Ee(e,t),t)}function hl(e,t){if(J(e))return!0;return Ne(Ee(e,t),t)}function xl(e,t){return J(e)||!Ye(e.items)&&e.items.some((r)=>Ne(r,t))}function Il(e,t){return J(e)||e.anyOf.some((r)=>Ne(r,t))}function Ne(e,t){let r=Rr(e,t),n=e;if(e.$id&&Qs.has(e.$id))return!1;if(e.$id)Qs.add(e.$id);switch(e[h]){case"Array":return sl(n,r);case"AsyncIterator":return il(n,r);case"Constructor":return al(n,r);case"Function":return cl(n,r);case"Import":return dl(n,r);case"Intersect":return ul(n,r);case"Iterator":return fl(n,r);case"Not":return ml(n,r);case"Object":return pl(n,r);case"Promise":return ll(n,r);case"Record":return yl(n,r);case"Ref":return gl(n,r);case"This":return hl(n,r);case"Tuple":return xl(n,r);case"Union":return Il(n,r);default:return J(e)}}var Qs=new Set;function Da(e,t){return Qs.clear(),Ne(e,t)}class va{constructor(e,t,r,n){this.schema=e,this.references=t,this.checkFunc=r,this.code=n,this.hasTransform=Da(e,t)}Code(){return this.code}Schema(){return this.schema}References(){return this.references}Errors(e){return Ea(this.schema,this.references,e)}Check(e){return this.checkFunc(e)}Decode(e){if(!this.checkFunc(e))throw new Ys(this.schema,e,this.Errors(e).First());return this.hasTransform?La(this.schema,this.references,e):e}Encode(e){let t=this.hasTransform?Ba(this.schema,this.references,e):e;if(!this.checkFunc(t))throw new Xs(this.schema,e,this.Errors(e).First());return t}}var fr;(function(e){function t(s){return s===36}e.DollarSign=t;function r(s){return s===95}e.IsUnderscore=r;function n(s){return s>=65&&s<=90||s>=97&&s<=122}e.IsAlpha=n;function o(s){return s>=48&&s<=57}e.IsNumeric=o})(fr||(fr={}));var ns;(function(e){function t(s){if(s.length===0)return!1;return fr.IsNumeric(s.charCodeAt(0))}function r(s){if(t(s))return!1;for(let i=0;i<s.length;i++){let a=s.charCodeAt(i);if(!(fr.IsAlpha(a)||fr.IsNumeric(a)||fr.DollarSign(a)||fr.IsUnderscore(a)))return!1}return!0}function n(s){return s.replace(/'/g,"\\'")}function o(s,i){return r(i)?`${s}.${i}`:`${s}['${n(i)}']`}e.Encode=o})(ns||(ns={}));var Zs;(function(e){function t(r){let n=[];for(let o=0;o<r.length;o++){let s=r.charCodeAt(o);if(fr.IsNumeric(s)||fr.IsAlpha(s))n.push(r.charAt(o));else n.push(`_${s}_`)}return n.join("").replace(/__/g,"_")}e.Encode=t})(Zs||(Zs={}));var ei;(function(e){function t(r){return r.replace(/'/g,"\\'")}e.Escape=t})(ei||(ei={}));class qa extends Y{constructor(e){super("Unknown type");this.schema=e}}class ti extends Y{constructor(e){super("Preflight validation check failed to guard for the given schema");this.schema=e}}var Xr;(function(e){function t(i,a,c){return ae.ExactOptionalPropertyTypes?`('${a}' in ${i} ? ${c} : true)`:`(${ns.Encode(i,a)} !== undefined ? ${c} : true)`}e.IsExactOptionalProperty=t;function r(i){return!ae.AllowArrayObject?`(typeof ${i} === 'object' && ${i} !== null && !Array.isArray(${i}))`:`(typeof ${i} === 'object' && ${i} !== null)`}e.IsObjectLike=r;function n(i){return!ae.AllowArrayObject?`(typeof ${i} === 'object' && ${i} !== null && !Array.isArray(${i}) && !(${i} instanceof Date) && !(${i} instanceof Uint8Array))`:`(typeof ${i} === 'object' && ${i} !== null && !(${i} instanceof Date) && !(${i} instanceof Uint8Array))`}e.IsRecordLike=n;function o(i){return ae.AllowNaN?`typeof ${i} === 'number'`:`Number.isFinite(${i})`}e.IsNumberLike=o;function s(i){return ae.AllowNullVoid?`(${i} === undefined || ${i} === null)`:`${i} === undefined`}e.IsVoidLike=s})(Xr||(Xr={}));var mo;(function(e){function t(d){return d[h]==="Any"||d[h]==="Unknown"}function*r(d,O,f){yield"true"}function*n(d,O,f){yield"true"}function*o(d,O,f){yield`Array.isArray(${f})`;let[M,k]=[ko("value","any"),ko("acc","number")];if(j(d.maxItems))yield`${f}.length <= ${d.maxItems}`;if(j(d.minItems))yield`${f}.length >= ${d.minItems}`;let F=wt(d.items,O,"value");if(yield`${f}.every((${M}) => ${F})`,xe(d.contains)||j(d.minContains)||j(d.maxContains)){let ie=xe(d.contains)?d.contains:L(),et=wt(ie,O,"value"),er=j(d.minContains)?[`(count >= ${d.minContains})`]:[],$t=j(d.maxContains)?[`(count <= ${d.maxContains})`]:[],Ht=`const count = value.reduce((${k}, ${M}) => ${et} ? acc + 1 : acc, 0)`,Co=["(count > 0)",...er,...$t].join(" && ");yield`((${M}) => { ${Ht}; return ${Co}})(${f})`}if(d.uniqueItems===!0)yield`((${M}) => { const set = new Set(); for(const element of value) { const hashed = hash(element); if(set.has(hashed)) { return false } else { set.add(hashed) } } return true } )(${f})`}function*s(d,O,f){yield`(typeof value === 'object' && Symbol.asyncIterator in ${f})`}function*i(d,O,f){if(yield`(typeof ${f} === 'bigint')`,ut(d.exclusiveMaximum))yield`${f} < BigInt(${d.exclusiveMaximum})`;if(ut(d.exclusiveMinimum))yield`${f} > BigInt(${d.exclusiveMinimum})`;if(ut(d.maximum))yield`${f} <= BigInt(${d.maximum})`;if(ut(d.minimum))yield`${f} >= BigInt(${d.minimum})`;if(ut(d.multipleOf))yield`(${f} % BigInt(${d.multipleOf})) === 0`}function*a(d,O,f){yield`(typeof ${f} === 'boolean')`}function*c(d,O,f){yield*an(d.returns,O,`${f}.prototype`)}function*u(d,O,f){if(yield`(${f} instanceof Date) && Number.isFinite(${f}.getTime())`,j(d.exclusiveMaximumTimestamp))yield`${f}.getTime() < ${d.exclusiveMaximumTimestamp}`;if(j(d.exclusiveMinimumTimestamp))yield`${f}.getTime() > ${d.exclusiveMinimumTimestamp}`;if(j(d.maximumTimestamp))yield`${f}.getTime() <= ${d.maximumTimestamp}`;if(j(d.minimumTimestamp))yield`${f}.getTime() >= ${d.minimumTimestamp}`;if(j(d.multipleOfTimestamp))yield`(${f}.getTime() % ${d.multipleOfTimestamp}) === 0`}function*m(d,O,f){yield`(typeof ${f} === 'function')`}function*l(d,O,f){let M=globalThis.Object.getOwnPropertyNames(d.$defs).reduce((k,F)=>[...k,d.$defs[F]],[]);yield*an(bt(d.$ref),[...O,...M],f)}function*x(d,O,f){if(yield`Number.isInteger(${f})`,j(d.exclusiveMaximum))yield`${f} < ${d.exclusiveMaximum}`;if(j(d.exclusiveMinimum))yield`${f} > ${d.exclusiveMinimum}`;if(j(d.maximum))yield`${f} <= ${d.maximum}`;if(j(d.minimum))yield`${f} >= ${d.minimum}`;if(j(d.multipleOf))yield`(${f} % ${d.multipleOf}) === 0`}function*b(d,O,f){let M=d.allOf.map((k)=>wt(k,O,f)).join(" && ");if(d.unevaluatedProperties===!1){let k=cn(`${new RegExp(ir(d))};`),F=`Object.getOwnPropertyNames(${f}).every(key => ${k}.test(key))`;yield`(${M} && ${F})`}else if(xe(d.unevaluatedProperties)){let k=cn(`${new RegExp(ir(d))};`),F=`Object.getOwnPropertyNames(${f}).every(key => ${k}.test(key) || ${wt(d.unevaluatedProperties,O,`${f}[key]`)})`;yield`(${M} && ${F})`}else yield`(${M})`}function*T(d,O,f){yield`(typeof value === 'object' && Symbol.iterator in ${f})`}function*C(d,O,f){if(typeof d.const==="number"||typeof d.const==="boolean")yield`(${f} === ${d.const})`;else yield`(${f} === '${ei.Escape(d.const)}')`}function*Q(d,O,f){yield"false"}function*le(d,O,f){yield`(!${wt(d.not,O,f)})`}function*q(d,O,f){yield`(${f} === null)`}function*Ge(d,O,f){if(yield Xr.IsNumberLike(f),j(d.exclusiveMaximum))yield`${f} < ${d.exclusiveMaximum}`;if(j(d.exclusiveMinimum))yield`${f} > ${d.exclusiveMinimum}`;if(j(d.maximum))yield`${f} <= ${d.maximum}`;if(j(d.minimum))yield`${f} >= ${d.minimum}`;if(j(d.multipleOf))yield`(${f} % ${d.multipleOf}) === 0`}function*ye(d,O,f){if(yield Xr.IsObjectLike(f),j(d.minProperties))yield`Object.getOwnPropertyNames(${f}).length >= ${d.minProperties}`;if(j(d.maxProperties))yield`Object.getOwnPropertyNames(${f}).length <= ${d.maxProperties}`;let M=Object.getOwnPropertyNames(d.properties);for(let k of M){let F=ns.Encode(f,k),ie=d.properties[k];if(d.required&&d.required.includes(k)){if(yield*an(ie,O,F),ar(ie)||t(ie))yield`('${k}' in ${f})`}else{let et=wt(ie,O,F);yield Xr.IsExactOptionalProperty(f,k,et)}}if(d.additionalProperties===!1)if(d.required&&d.required.length===M.length)yield`Object.getOwnPropertyNames(${f}).length === ${M.length}`;else{let k=`[${M.map((F)=>`'${F}'`).join(", ")}]`;yield`Object.getOwnPropertyNames(${f}).every(key => ${k}.includes(key))`}if(typeof d.additionalProperties==="object"){let k=wt(d.additionalProperties,O,`${f}[key]`),F=`[${M.map((ie)=>`'${ie}'`).join(", ")}]`;yield`(Object.getOwnPropertyNames(${f}).every(key => ${F}.includes(key) || ${k}))`}}function*W(d,O,f){yield`${f} instanceof Promise`}function*Me(d,O,f){if(yield Xr.IsRecordLike(f),j(d.minProperties))yield`Object.getOwnPropertyNames(${f}).length >= ${d.minProperties}`;if(j(d.maxProperties))yield`Object.getOwnPropertyNames(${f}).length <= ${d.maxProperties}`;let[M,k]=Object.entries(d.patternProperties)[0],F=cn(`${new RegExp(M)}`),ie=wt(k,O,"value"),et=xe(d.additionalProperties)?wt(d.additionalProperties,O,f):d.additionalProperties===!1?"false":"true",er=`(${F}.test(key) ? ${ie} : ${et})`;yield`(Object.entries(${f}).every(([key, value]) => ${er}))`}function*$e(d,O,f){let M=Ee(d,O);if(Ke.functions.has(d.$ref))return yield`${$o(d.$ref)}(${f})`;yield*an(M,O,f)}function*Pe(d,O,f){let M=cn(`${new RegExp(d.source,d.flags)};`);if(yield`(typeof ${f} === 'string')`,j(d.maxLength))yield`${f}.length <= ${d.maxLength}`;if(j(d.minLength))yield`${f}.length >= ${d.minLength}`;yield`${M}.test(${f})`}function*A(d,O,f){if(yield`(typeof ${f} === 'string')`,j(d.maxLength))yield`${f}.length <= ${d.maxLength}`;if(j(d.minLength))yield`${f}.length >= ${d.minLength}`;if(d.pattern!==void 0)yield`${cn(`${new RegExp(d.pattern)};`)}.test(${f})`;if(d.format!==void 0)yield`format('${d.format}', ${f})`}function*Z(d,O,f){yield`(typeof ${f} === 'symbol')`}function*Qe(d,O,f){yield`(typeof ${f} === 'string')`,yield`${cn(`${new RegExp(d.pattern)};`)}.test(${f})`}function*te(d,O,f){yield`${$o(d.$ref)}(${f})`}function*U(d,O,f){if(yield`Array.isArray(${f})`,d.items===void 0)return yield`${f}.length === 0`;yield`(${f}.length === ${d.maxItems})`;for(let M=0;M<d.items.length;M++)yield`${wt(d.items[M],O,`${f}[${M}]`)}`}function*Se(d,O,f){yield`${f} === undefined`}function*ct(d,O,f){yield`(${d.anyOf.map((k)=>wt(k,O,f)).join(" || ")})`}function*Ze(d,O,f){if(yield`${f} instanceof Uint8Array`,j(d.maxByteLength))yield`(${f}.length <= ${d.maxByteLength})`;if(j(d.minByteLength))yield`(${f}.length >= ${d.minByteLength})`}function*Zt(d,O,f){yield"true"}function*sn(d,O,f){yield Xr.IsVoidLike(f)}function*ws(d,O,f){let M=Ke.instances.size;Ke.instances.set(M,d),yield`kind('${d[h]}', ${M}, ${f})`}function*an(d,O,f,M=!0){let k=je(d.$id)?[...O,d]:O,F=d;if(M&&je(d.$id)){let ie=$o(d.$id);if(Ke.functions.has(ie))return yield`${ie}(${f})`;else{Ke.functions.set(ie,"<deferred>");let et=bi(ie,d,O,"value",!1);return Ke.functions.set(ie,et),yield`${ie}(${f})`}}switch(F[h]){case"Any":return yield*r(F,k,f);case"Argument":return yield*n(F,k,f);case"Array":return yield*o(F,k,f);case"AsyncIterator":return yield*s(F,k,f);case"BigInt":return yield*i(F,k,f);case"Boolean":return yield*a(F,k,f);case"Constructor":return yield*c(F,k,f);case"Date":return yield*u(F,k,f);case"Function":return yield*m(F,k,f);case"Import":return yield*l(F,k,f);case"Integer":return yield*x(F,k,f);case"Intersect":return yield*b(F,k,f);case"Iterator":return yield*T(F,k,f);case"Literal":return yield*C(F,k,f);case"Never":return yield*Q(F,k,f);case"Not":return yield*le(F,k,f);case"Null":return yield*q(F,k,f);case"Number":return yield*Ge(F,k,f);case"Object":return yield*ye(F,k,f);case"Promise":return yield*W(F,k,f);case"Record":return yield*Me(F,k,f);case"Ref":return yield*$e(F,k,f);case"RegExp":return yield*Pe(F,k,f);case"String":return yield*A(F,k,f);case"Symbol":return yield*Z(F,k,f);case"TemplateLiteral":return yield*Qe(F,k,f);case"This":return yield*te(F,k,f);case"Tuple":return yield*U(F,k,f);case"Undefined":return yield*Se(F,k,f);case"Union":return yield*ct(F,k,f);case"Uint8Array":return yield*Ze(F,k,f);case"Unknown":return yield*Zt(F,k,f);case"Void":return yield*sn(F,k,f);default:if(!Yn(F[h]))throw new qa(d);return yield*ws(F,k,f)}}let Ke={language:"javascript",functions:new Map,variables:new Map,instances:new Map};function wt(d,O,f,M=!0){return`(${[...an(d,O,f,M)].join(" && ")})`}function $o(d){return`check_${Zs.Encode(d)}`}function cn(d){let O=`local_${Ke.variables.size}`;return Ke.variables.set(O,`const ${O} = ${d}`),O}function bi(d,O,f,M,k=!0){let[F,ie]=[`
|
|
3
|
+
`,(Ht)=>"".padStart(Ht," ")],et=ko("value","any"),er=_i("boolean"),$t=[...an(O,f,M,k)].map((Ht)=>`${ie(4)}${Ht}`).join(` &&${F}`);return`function ${d}(${et})${er} {${F}${ie(2)}return (${F}${$t}${F}${ie(2)})
|
|
4
|
+
}`}function ko(d,O){let f=Ke.language==="typescript"?`: ${O}`:"";return`${d}${f}`}function _i(d){return Ke.language==="typescript"?`: ${d}`:""}function iu(d,O,f){let M=bi("check",d,O,"value"),k=ko("value","any"),F=_i("boolean"),ie=[...Ke.functions.values()],et=[...Ke.variables.values()],er=je(d.$id)?`return function check(${k})${F} {
|
|
5
|
+
return ${$o(d.$id)}(value)
|
|
6
|
+
}`:`return ${M}`;return[...et,...ie,er].join(`
|
|
7
|
+
`)}function Ri(...d){let O={language:"javascript"},[f,M,k]=d.length===2&&Ce(d[1])?[d[0],d[1],O]:d.length===2&&!Ce(d[1])?[d[0],[],d[1]]:d.length===3?[d[0],d[1],d[2]]:d.length===1?[d[0],[],O]:[null,[],O];if(Ke.language=k.language,Ke.variables.clear(),Ke.functions.clear(),Ke.instances.clear(),!xe(f))throw new ti(f);for(let F of M)if(!xe(F))throw new ti(F);return iu(f,M,k)}e.Code=Ri;function au(d,O=[]){let f=Ri(d,O,{language:"javascript"}),M=globalThis.Function("kind","format","hash",f),k=new Map(Ke.instances);function F($t,Ht,Co){if(!Yn($t)||!k.has(Ht))return!1;let cu=Fs($t),uu=k.get(Ht);return cu(uu,Co)}function ie($t,Ht){if(!Cs($t))return!1;return As($t)(Ht)}function et($t){return On($t)}let er=M(F,ie,et);return new va(d,O,er,f)}e.Compile=au})(mo||(mo={}));var v;(function(e){e.assertEqual=(o)=>{};function t(o){}e.assertIs=t;function r(o){throw Error()}e.assertNever=r,e.arrayToEnum=(o)=>{let s={};for(let i of o)s[i]=i;return s},e.getValidEnumValues=(o)=>{let s=e.objectKeys(o).filter((a)=>typeof o[o[a]]!=="number"),i={};for(let a of s)i[a]=o[a];return e.objectValues(i)},e.objectValues=(o)=>e.objectKeys(o).map(function(s){return o[s]}),e.objectKeys=typeof Object.keys==="function"?(o)=>Object.keys(o):(o)=>{let s=[];for(let i in o)if(Object.prototype.hasOwnProperty.call(o,i))s.push(i);return s},e.find=(o,s)=>{for(let i of o)if(s(i))return i;return},e.isInteger=typeof Number.isInteger==="function"?(o)=>Number.isInteger(o):(o)=>typeof o==="number"&&Number.isFinite(o)&&Math.floor(o)===o;function n(o,s=" | "){return o.map((i)=>typeof i==="string"?`'${i}'`:i).join(s)}e.joinValues=n,e.jsonStringifyReplacer=(o,s)=>{if(typeof s==="bigint")return s.toString();return s}})(v||(v={}));var ri;(function(e){e.mergeShapes=(t,r)=>({...t,...r})})(ri||(ri={}));var w=v.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),Yt=(e)=>{switch(typeof e){case"undefined":return w.undefined;case"string":return w.string;case"number":return Number.isNaN(e)?w.nan:w.number;case"boolean":return w.boolean;case"function":return w.function;case"bigint":return w.bigint;case"symbol":return w.symbol;case"object":if(Array.isArray(e))return w.array;if(e===null)return w.null;if(e.then&&typeof e.then==="function"&&e.catch&&typeof e.catch==="function")return w.promise;if(typeof Map<"u"&&e instanceof Map)return w.map;if(typeof Set<"u"&&e instanceof Set)return w.set;if(typeof Date<"u"&&e instanceof Date)return w.date;return w.object;default:return w.unknown}};var I=v.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]),bl=(e)=>JSON.stringify(e,null,2).replace(/"([^"]+)":/g,"$1:");class at extends Error{get errors(){return this.issues}constructor(e){super();this.issues=[],this.addIssue=(r)=>{this.issues=[...this.issues,r]},this.addIssues=(r=[])=>{this.issues=[...this.issues,...r]};let t=new.target.prototype;if(Object.setPrototypeOf)Object.setPrototypeOf(this,t);else this.__proto__=t;this.name="ZodError",this.issues=e}format(e){let t=e||function(o){return o.message},r={_errors:[]},n=(o)=>{for(let s of o.issues)if(s.code==="invalid_union")s.unionErrors.map(n);else if(s.code==="invalid_return_type")n(s.returnTypeError);else if(s.code==="invalid_arguments")n(s.argumentsError);else if(s.path.length===0)r._errors.push(t(s));else{let i=r,a=0;while(a<s.path.length){let c=s.path[a];if(a!==s.path.length-1)i[c]=i[c]||{_errors:[]};else i[c]=i[c]||{_errors:[]},i[c]._errors.push(t(s));i=i[c],a++}}};return n(this),r}static assert(e){if(!(e instanceof at))throw Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,v.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=(t)=>t.message){let t={},r=[];for(let n of this.issues)if(n.path.length>0){let o=n.path[0];t[o]=t[o]||[],t[o].push(e(n))}else r.push(e(n));return{formErrors:r,fieldErrors:t}}get formErrors(){return this.flatten()}}at.create=(e)=>new at(e);var _l=(e,t)=>{let r;switch(e.code){case I.invalid_type:if(e.received===w.undefined)r="Required";else r=`Expected ${e.expected}, received ${e.received}`;break;case I.invalid_literal:r=`Invalid literal value, expected ${JSON.stringify(e.expected,v.jsonStringifyReplacer)}`;break;case I.unrecognized_keys:r=`Unrecognized key(s) in object: ${v.joinValues(e.keys,", ")}`;break;case I.invalid_union:r="Invalid input";break;case I.invalid_union_discriminator:r=`Invalid discriminator value. Expected ${v.joinValues(e.options)}`;break;case I.invalid_enum_value:r=`Invalid enum value. Expected ${v.joinValues(e.options)}, received '${e.received}'`;break;case I.invalid_arguments:r="Invalid function arguments";break;case I.invalid_return_type:r="Invalid function return type";break;case I.invalid_date:r="Invalid date";break;case I.invalid_string:if(typeof e.validation==="object")if("includes"in e.validation){if(r=`Invalid input: must include "${e.validation.includes}"`,typeof e.validation.position==="number")r=`${r} at one or more positions greater than or equal to ${e.validation.position}`}else if("startsWith"in e.validation)r=`Invalid input: must start with "${e.validation.startsWith}"`;else if("endsWith"in e.validation)r=`Invalid input: must end with "${e.validation.endsWith}"`;else v.assertNever(e.validation);else if(e.validation!=="regex")r=`Invalid ${e.validation}`;else r="Invalid";break;case I.too_small:if(e.type==="array")r=`Array must contain ${e.exact?"exactly":e.inclusive?"at least":"more than"} ${e.minimum} element(s)`;else if(e.type==="string")r=`String must contain ${e.exact?"exactly":e.inclusive?"at least":"over"} ${e.minimum} character(s)`;else if(e.type==="number")r=`Number must be ${e.exact?"exactly equal to ":e.inclusive?"greater than or equal to ":"greater than "}${e.minimum}`;else if(e.type==="bigint")r=`Number must be ${e.exact?"exactly equal to ":e.inclusive?"greater than or equal to ":"greater than "}${e.minimum}`;else if(e.type==="date")r=`Date must be ${e.exact?"exactly equal to ":e.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(e.minimum))}`;else r="Invalid input";break;case I.too_big:if(e.type==="array")r=`Array must contain ${e.exact?"exactly":e.inclusive?"at most":"less than"} ${e.maximum} element(s)`;else if(e.type==="string")r=`String must contain ${e.exact?"exactly":e.inclusive?"at most":"under"} ${e.maximum} character(s)`;else if(e.type==="number")r=`Number must be ${e.exact?"exactly":e.inclusive?"less than or equal to":"less than"} ${e.maximum}`;else if(e.type==="bigint")r=`BigInt must be ${e.exact?"exactly":e.inclusive?"less than or equal to":"less than"} ${e.maximum}`;else if(e.type==="date")r=`Date must be ${e.exact?"exactly":e.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(e.maximum))}`;else r="Invalid input";break;case I.custom:r="Invalid input";break;case I.invalid_intersection_types:r="Intersection results could not be merged";break;case I.not_multiple_of:r=`Number must be a multiple of ${e.multipleOf}`;break;case I.not_finite:r="Number must be finite";break;default:r=t.defaultError,v.assertNever(e)}return{message:r}},mr=_l;var Ga=mr;function Rl(e){Ga=e}function Cn(){return Ga}var po=(e)=>{let{data:t,path:r,errorMaps:n,issueData:o}=e,s=[...r,...o.path||[]],i={...o,path:s};if(o.message!==void 0)return{...o,path:s,message:o.message};let a="",c=n.filter((u)=>!!u).slice().reverse();for(let u of c)a=u(i,{data:t,defaultError:a}).message;return{...o,path:s,message:a}},Ol=[];function _(e,t){let r=Cn(),n=po({issueData:t,data:e.data,path:e.path,errorMaps:[e.common.contextualErrorMap,e.schemaErrorMap,r,r===mr?void 0:mr].filter((o)=>!!o)});e.common.issues.push(n)}class qe{constructor(){this.value="valid"}dirty(){if(this.value==="valid")this.value="dirty"}abort(){if(this.value!=="aborted")this.value="aborted"}static mergeArray(e,t){let r=[];for(let n of t){if(n.status==="aborted")return S;if(n.status==="dirty")e.dirty();r.push(n.value)}return{status:e.value,value:r}}static async mergeObjectAsync(e,t){let r=[];for(let n of t){let o=await n.key,s=await n.value;r.push({key:o,value:s})}return qe.mergeObjectSync(e,r)}static mergeObjectSync(e,t){let r={};for(let n of t){let{key:o,value:s}=n;if(o.status==="aborted")return S;if(s.status==="aborted")return S;if(o.status==="dirty")e.dirty();if(s.status==="dirty")e.dirty();if(o.value!=="__proto__"&&(typeof s.value<"u"||n.alwaysSet))r[o.value]=s.value}return{status:e.value,value:r}}}var S=Object.freeze({status:"aborted"}),Qr=(e)=>({status:"dirty",value:e}),Je=(e)=>({status:"valid",value:e}),os=(e)=>e.status==="aborted",ss=(e)=>e.status==="dirty",Ar=(e)=>e.status==="valid",An=(e)=>typeof Promise<"u"&&e instanceof Promise;var P;(function(e){e.errToObj=(t)=>typeof t==="string"?{message:t}:t||{},e.toString=(t)=>typeof t==="string"?t:t?.message})(P||(P={}));class Dt{constructor(e,t,r,n){this._cachedPath=[],this.parent=e,this.data=t,this._path=r,this._key=n}get path(){if(!this._cachedPath.length)if(Array.isArray(this._key))this._cachedPath.push(...this._path,...this._key);else this._cachedPath.push(...this._path,this._key);return this._cachedPath}}var Ha=(e,t)=>{if(Ar(t))return{success:!0,data:t.value};else{if(!e.common.issues.length)throw Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;let r=new at(e.common.issues);return this._error=r,this._error}}}};function E(e){if(!e)return{};let{errorMap:t,invalid_type_error:r,required_error:n,description:o}=e;if(t&&(r||n))throw Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);if(t)return{errorMap:t,description:o};return{errorMap:(i,a)=>{let{message:c}=e;if(i.code==="invalid_enum_value")return{message:c??a.defaultError};if(typeof a.data>"u")return{message:c??n??a.defaultError};if(i.code!=="invalid_type")return{message:a.defaultError};return{message:c??r??a.defaultError}},description:o}}class K{get description(){return this._def.description}_getType(e){return Yt(e.data)}_getOrReturnCtx(e,t){return t||{common:e.parent.common,data:e.data,parsedType:Yt(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new qe,ctx:{common:e.parent.common,data:e.data,parsedType:Yt(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){let t=this._parse(e);if(An(t))throw Error("Synchronous parse encountered promise.");return t}_parseAsync(e){let t=this._parse(e);return Promise.resolve(t)}parse(e,t){let r=this.safeParse(e,t);if(r.success)return r.data;throw r.error}safeParse(e,t){let r={common:{issues:[],async:t?.async??!1,contextualErrorMap:t?.errorMap},path:t?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:Yt(e)},n=this._parseSync({data:e,path:r.path,parent:r});return Ha(r,n)}"~validate"(e){let t={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:Yt(e)};if(!this["~standard"].async)try{let r=this._parseSync({data:e,path:[],parent:t});return Ar(r)?{value:r.value}:{issues:t.common.issues}}catch(r){if(r?.message?.toLowerCase()?.includes("encountered"))this["~standard"].async=!0;t.common={issues:[],async:!0}}return this._parseAsync({data:e,path:[],parent:t}).then((r)=>Ar(r)?{value:r.value}:{issues:t.common.issues})}async parseAsync(e,t){let r=await this.safeParseAsync(e,t);if(r.success)return r.data;throw r.error}async safeParseAsync(e,t){let r={common:{issues:[],contextualErrorMap:t?.errorMap,async:!0},path:t?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:Yt(e)},n=this._parse({data:e,path:r.path,parent:r}),o=await(An(n)?n:Promise.resolve(n));return Ha(r,o)}refine(e,t){let r=(n)=>{if(typeof t==="string"||typeof t>"u")return{message:t};else if(typeof t==="function")return t(n);else return t};return this._refinement((n,o)=>{let s=e(n),i=()=>o.addIssue({code:I.custom,...r(n)});if(typeof Promise<"u"&&s instanceof Promise)return s.then((a)=>{if(!a)return i(),!1;else return!0});if(!s)return i(),!1;else return!0})}refinement(e,t){return this._refinement((r,n)=>{if(!e(r))return n.addIssue(typeof t==="function"?t(r,n):t),!1;else return!0})}_refinement(e){return new vt({schema:this,typeName:N.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}constructor(e){this.spa=this.safeParseAsync,this._def=e,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this),this["~standard"]={version:1,vendor:"zod",validate:(t)=>this["~validate"](t)}}optional(){return Bt.create(this,this._def)}nullable(){return lr.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return Kt.create(this)}promise(){return rn.create(this,this._def)}or(e){return Mn.create([this,e],this._def)}and(e){return jn.create(this,e,this._def)}transform(e){return new vt({...E(this._def),schema:this,typeName:N.ZodEffects,effect:{type:"transform",transform:e}})}default(e){let t=typeof e==="function"?e:()=>e;return new Kn({...E(this._def),innerType:this,defaultValue:t,typeName:N.ZodDefault})}brand(){return new as({typeName:N.ZodBranded,type:this,...E(this._def)})}catch(e){let t=typeof e==="function"?e:()=>e;return new Bn({...E(this._def),innerType:this,catchValue:t,typeName:N.ZodCatch})}describe(e){return new this.constructor({...this._def,description:e})}pipe(e){return Io.create(this,e)}readonly(){return Dn.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}var wl=/^c[^\s-]{8,}$/i,$l=/^[0-9a-z]+$/,kl=/^[0-9A-HJKMNP-TV-Z]{26}$/i,Cl=/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i,Al=/^[a-z0-9_-]{21}$/i,Fl=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,Tl=/^[-+]?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)?)??$/,Pl=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,Sl="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$",ni,Nl=/^(?:(?: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])$/,Ml=/^(?:(?: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])\/(3[0-2]|[12]?[0-9])$/,jl=/^(([0-9a-fA-F]{1,4}:){7,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}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/,El=/^(([0-9a-fA-F]{1,4}:){7,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}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,Ul=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,Ll=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,za="((\\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])))",Kl=new RegExp(`^${za}$`);function Wa(e){let t="[0-5]\\d";if(e.precision)t=`${t}\\.\\d{${e.precision}}`;else if(e.precision==null)t=`${t}(\\.\\d+)?`;let r=e.precision?"+":"?";return`([01]\\d|2[0-3]):[0-5]\\d(:${t})${r}`}function Bl(e){return new RegExp(`^${Wa(e)}$`)}function Ja(e){let t=`${za}T${Wa(e)}`,r=[];if(r.push(e.local?"Z?":"Z"),e.offset)r.push("([+-]\\d{2}:?\\d{2})");return t=`${t}(${r.join("|")})`,new RegExp(`^${t}$`)}function Dl(e,t){if((t==="v4"||!t)&&Nl.test(e))return!0;if((t==="v6"||!t)&&jl.test(e))return!0;return!1}function vl(e,t){if(!Fl.test(e))return!1;try{let[r]=e.split(".");if(!r)return!1;let n=r.replace(/-/g,"+").replace(/_/g,"/").padEnd(r.length+(4-r.length%4)%4,"="),o=JSON.parse(atob(n));if(typeof o!=="object"||o===null)return!1;if("typ"in o&&o?.typ!=="JWT")return!1;if(!o.alg)return!1;if(t&&o.alg!==t)return!1;return!0}catch{return!1}}function ql(e,t){if((t==="v4"||!t)&&Ml.test(e))return!0;if((t==="v6"||!t)&&El.test(e))return!0;return!1}class Lt extends K{_parse(e){if(this._def.coerce)e.data=String(e.data);if(this._getType(e)!==w.string){let o=this._getOrReturnCtx(e);return _(o,{code:I.invalid_type,expected:w.string,received:o.parsedType}),S}let r=new qe,n=void 0;for(let o of this._def.checks)if(o.kind==="min"){if(e.data.length<o.value)n=this._getOrReturnCtx(e,n),_(n,{code:I.too_small,minimum:o.value,type:"string",inclusive:!0,exact:!1,message:o.message}),r.dirty()}else if(o.kind==="max"){if(e.data.length>o.value)n=this._getOrReturnCtx(e,n),_(n,{code:I.too_big,maximum:o.value,type:"string",inclusive:!0,exact:!1,message:o.message}),r.dirty()}else if(o.kind==="length"){let s=e.data.length>o.value,i=e.data.length<o.value;if(s||i){if(n=this._getOrReturnCtx(e,n),s)_(n,{code:I.too_big,maximum:o.value,type:"string",inclusive:!0,exact:!0,message:o.message});else if(i)_(n,{code:I.too_small,minimum:o.value,type:"string",inclusive:!0,exact:!0,message:o.message});r.dirty()}}else if(o.kind==="email"){if(!Pl.test(e.data))n=this._getOrReturnCtx(e,n),_(n,{validation:"email",code:I.invalid_string,message:o.message}),r.dirty()}else if(o.kind==="emoji"){if(!ni)ni=new RegExp(Sl,"u");if(!ni.test(e.data))n=this._getOrReturnCtx(e,n),_(n,{validation:"emoji",code:I.invalid_string,message:o.message}),r.dirty()}else if(o.kind==="uuid"){if(!Cl.test(e.data))n=this._getOrReturnCtx(e,n),_(n,{validation:"uuid",code:I.invalid_string,message:o.message}),r.dirty()}else if(o.kind==="nanoid"){if(!Al.test(e.data))n=this._getOrReturnCtx(e,n),_(n,{validation:"nanoid",code:I.invalid_string,message:o.message}),r.dirty()}else if(o.kind==="cuid"){if(!wl.test(e.data))n=this._getOrReturnCtx(e,n),_(n,{validation:"cuid",code:I.invalid_string,message:o.message}),r.dirty()}else if(o.kind==="cuid2"){if(!$l.test(e.data))n=this._getOrReturnCtx(e,n),_(n,{validation:"cuid2",code:I.invalid_string,message:o.message}),r.dirty()}else if(o.kind==="ulid"){if(!kl.test(e.data))n=this._getOrReturnCtx(e,n),_(n,{validation:"ulid",code:I.invalid_string,message:o.message}),r.dirty()}else if(o.kind==="url")try{new URL(e.data)}catch{n=this._getOrReturnCtx(e,n),_(n,{validation:"url",code:I.invalid_string,message:o.message}),r.dirty()}else if(o.kind==="regex"){if(o.regex.lastIndex=0,!o.regex.test(e.data))n=this._getOrReturnCtx(e,n),_(n,{validation:"regex",code:I.invalid_string,message:o.message}),r.dirty()}else if(o.kind==="trim")e.data=e.data.trim();else if(o.kind==="includes"){if(!e.data.includes(o.value,o.position))n=this._getOrReturnCtx(e,n),_(n,{code:I.invalid_string,validation:{includes:o.value,position:o.position},message:o.message}),r.dirty()}else if(o.kind==="toLowerCase")e.data=e.data.toLowerCase();else if(o.kind==="toUpperCase")e.data=e.data.toUpperCase();else if(o.kind==="startsWith"){if(!e.data.startsWith(o.value))n=this._getOrReturnCtx(e,n),_(n,{code:I.invalid_string,validation:{startsWith:o.value},message:o.message}),r.dirty()}else if(o.kind==="endsWith"){if(!e.data.endsWith(o.value))n=this._getOrReturnCtx(e,n),_(n,{code:I.invalid_string,validation:{endsWith:o.value},message:o.message}),r.dirty()}else if(o.kind==="datetime"){if(!Ja(o).test(e.data))n=this._getOrReturnCtx(e,n),_(n,{code:I.invalid_string,validation:"datetime",message:o.message}),r.dirty()}else if(o.kind==="date"){if(!Kl.test(e.data))n=this._getOrReturnCtx(e,n),_(n,{code:I.invalid_string,validation:"date",message:o.message}),r.dirty()}else if(o.kind==="time"){if(!Bl(o).test(e.data))n=this._getOrReturnCtx(e,n),_(n,{code:I.invalid_string,validation:"time",message:o.message}),r.dirty()}else if(o.kind==="duration"){if(!Tl.test(e.data))n=this._getOrReturnCtx(e,n),_(n,{validation:"duration",code:I.invalid_string,message:o.message}),r.dirty()}else if(o.kind==="ip"){if(!Dl(e.data,o.version))n=this._getOrReturnCtx(e,n),_(n,{validation:"ip",code:I.invalid_string,message:o.message}),r.dirty()}else if(o.kind==="jwt"){if(!vl(e.data,o.alg))n=this._getOrReturnCtx(e,n),_(n,{validation:"jwt",code:I.invalid_string,message:o.message}),r.dirty()}else if(o.kind==="cidr"){if(!ql(e.data,o.version))n=this._getOrReturnCtx(e,n),_(n,{validation:"cidr",code:I.invalid_string,message:o.message}),r.dirty()}else if(o.kind==="base64"){if(!Ul.test(e.data))n=this._getOrReturnCtx(e,n),_(n,{validation:"base64",code:I.invalid_string,message:o.message}),r.dirty()}else if(o.kind==="base64url"){if(!Ll.test(e.data))n=this._getOrReturnCtx(e,n),_(n,{validation:"base64url",code:I.invalid_string,message:o.message}),r.dirty()}else v.assertNever(o);return{status:r.value,value:e.data}}_regex(e,t,r){return this.refinement((n)=>e.test(n),{validation:t,code:I.invalid_string,...P.errToObj(r)})}_addCheck(e){return new Lt({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...P.errToObj(e)})}url(e){return this._addCheck({kind:"url",...P.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...P.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...P.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",...P.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...P.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...P.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...P.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",...P.errToObj(e)})}base64url(e){return this._addCheck({kind:"base64url",...P.errToObj(e)})}jwt(e){return this._addCheck({kind:"jwt",...P.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...P.errToObj(e)})}cidr(e){return this._addCheck({kind:"cidr",...P.errToObj(e)})}datetime(e){if(typeof e==="string")return this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:e});return this._addCheck({kind:"datetime",precision:typeof e?.precision>"u"?null:e?.precision,offset:e?.offset??!1,local:e?.local??!1,...P.errToObj(e?.message)})}date(e){return this._addCheck({kind:"date",message:e})}time(e){if(typeof e==="string")return this._addCheck({kind:"time",precision:null,message:e});return this._addCheck({kind:"time",precision:typeof e?.precision>"u"?null:e?.precision,...P.errToObj(e?.message)})}duration(e){return this._addCheck({kind:"duration",...P.errToObj(e)})}regex(e,t){return this._addCheck({kind:"regex",regex:e,...P.errToObj(t)})}includes(e,t){return this._addCheck({kind:"includes",value:e,position:t?.position,...P.errToObj(t?.message)})}startsWith(e,t){return this._addCheck({kind:"startsWith",value:e,...P.errToObj(t)})}endsWith(e,t){return this._addCheck({kind:"endsWith",value:e,...P.errToObj(t)})}min(e,t){return this._addCheck({kind:"min",value:e,...P.errToObj(t)})}max(e,t){return this._addCheck({kind:"max",value:e,...P.errToObj(t)})}length(e,t){return this._addCheck({kind:"length",value:e,...P.errToObj(t)})}nonempty(e){return this.min(1,P.errToObj(e))}trim(){return new Lt({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new Lt({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new Lt({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find((e)=>e.kind==="datetime")}get isDate(){return!!this._def.checks.find((e)=>e.kind==="date")}get isTime(){return!!this._def.checks.find((e)=>e.kind==="time")}get isDuration(){return!!this._def.checks.find((e)=>e.kind==="duration")}get isEmail(){return!!this._def.checks.find((e)=>e.kind==="email")}get isURL(){return!!this._def.checks.find((e)=>e.kind==="url")}get isEmoji(){return!!this._def.checks.find((e)=>e.kind==="emoji")}get isUUID(){return!!this._def.checks.find((e)=>e.kind==="uuid")}get isNANOID(){return!!this._def.checks.find((e)=>e.kind==="nanoid")}get isCUID(){return!!this._def.checks.find((e)=>e.kind==="cuid")}get isCUID2(){return!!this._def.checks.find((e)=>e.kind==="cuid2")}get isULID(){return!!this._def.checks.find((e)=>e.kind==="ulid")}get isIP(){return!!this._def.checks.find((e)=>e.kind==="ip")}get isCIDR(){return!!this._def.checks.find((e)=>e.kind==="cidr")}get isBase64(){return!!this._def.checks.find((e)=>e.kind==="base64")}get isBase64url(){return!!this._def.checks.find((e)=>e.kind==="base64url")}get minLength(){let e=null;for(let t of this._def.checks)if(t.kind==="min"){if(e===null||t.value>e)e=t.value}return e}get maxLength(){let e=null;for(let t of this._def.checks)if(t.kind==="max"){if(e===null||t.value<e)e=t.value}return e}}Lt.create=(e)=>new Lt({checks:[],typeName:N.ZodString,coerce:e?.coerce??!1,...E(e)});function Gl(e,t){let r=(e.toString().split(".")[1]||"").length,n=(t.toString().split(".")[1]||"").length,o=r>n?r:n,s=Number.parseInt(e.toFixed(o).replace(".","")),i=Number.parseInt(t.toFixed(o).replace(".",""));return s%i/10**o}class Tr extends K{constructor(){super(...arguments);this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(e){if(this._def.coerce)e.data=Number(e.data);if(this._getType(e)!==w.number){let o=this._getOrReturnCtx(e);return _(o,{code:I.invalid_type,expected:w.number,received:o.parsedType}),S}let r=void 0,n=new qe;for(let o of this._def.checks)if(o.kind==="int"){if(!v.isInteger(e.data))r=this._getOrReturnCtx(e,r),_(r,{code:I.invalid_type,expected:"integer",received:"float",message:o.message}),n.dirty()}else if(o.kind==="min"){if(o.inclusive?e.data<o.value:e.data<=o.value)r=this._getOrReturnCtx(e,r),_(r,{code:I.too_small,minimum:o.value,type:"number",inclusive:o.inclusive,exact:!1,message:o.message}),n.dirty()}else if(o.kind==="max"){if(o.inclusive?e.data>o.value:e.data>=o.value)r=this._getOrReturnCtx(e,r),_(r,{code:I.too_big,maximum:o.value,type:"number",inclusive:o.inclusive,exact:!1,message:o.message}),n.dirty()}else if(o.kind==="multipleOf"){if(Gl(e.data,o.value)!==0)r=this._getOrReturnCtx(e,r),_(r,{code:I.not_multiple_of,multipleOf:o.value,message:o.message}),n.dirty()}else if(o.kind==="finite"){if(!Number.isFinite(e.data))r=this._getOrReturnCtx(e,r),_(r,{code:I.not_finite,message:o.message}),n.dirty()}else v.assertNever(o);return{status:n.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,P.toString(t))}gt(e,t){return this.setLimit("min",e,!1,P.toString(t))}lte(e,t){return this.setLimit("max",e,!0,P.toString(t))}lt(e,t){return this.setLimit("max",e,!1,P.toString(t))}setLimit(e,t,r,n){return new Tr({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:r,message:P.toString(n)}]})}_addCheck(e){return new Tr({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:P.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:P.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:P.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:P.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:P.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:P.toString(t)})}finite(e){return this._addCheck({kind:"finite",message:P.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:P.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:P.toString(e)})}get minValue(){let e=null;for(let t of this._def.checks)if(t.kind==="min"){if(e===null||t.value>e)e=t.value}return e}get maxValue(){let e=null;for(let t of this._def.checks)if(t.kind==="max"){if(e===null||t.value<e)e=t.value}return e}get isInt(){return!!this._def.checks.find((e)=>e.kind==="int"||e.kind==="multipleOf"&&v.isInteger(e.value))}get isFinite(){let e=null,t=null;for(let r of this._def.checks)if(r.kind==="finite"||r.kind==="int"||r.kind==="multipleOf")return!0;else if(r.kind==="min"){if(t===null||r.value>t)t=r.value}else if(r.kind==="max"){if(e===null||r.value<e)e=r.value}return Number.isFinite(t)&&Number.isFinite(e)}}Tr.create=(e)=>new Tr({checks:[],typeName:N.ZodNumber,coerce:e?.coerce||!1,...E(e)});class Pr extends K{constructor(){super(...arguments);this.min=this.gte,this.max=this.lte}_parse(e){if(this._def.coerce)try{e.data=BigInt(e.data)}catch{return this._getInvalidInput(e)}if(this._getType(e)!==w.bigint)return this._getInvalidInput(e);let r=void 0,n=new qe;for(let o of this._def.checks)if(o.kind==="min"){if(o.inclusive?e.data<o.value:e.data<=o.value)r=this._getOrReturnCtx(e,r),_(r,{code:I.too_small,type:"bigint",minimum:o.value,inclusive:o.inclusive,message:o.message}),n.dirty()}else if(o.kind==="max"){if(o.inclusive?e.data>o.value:e.data>=o.value)r=this._getOrReturnCtx(e,r),_(r,{code:I.too_big,type:"bigint",maximum:o.value,inclusive:o.inclusive,message:o.message}),n.dirty()}else if(o.kind==="multipleOf"){if(e.data%o.value!==BigInt(0))r=this._getOrReturnCtx(e,r),_(r,{code:I.not_multiple_of,multipleOf:o.value,message:o.message}),n.dirty()}else v.assertNever(o);return{status:n.value,value:e.data}}_getInvalidInput(e){let t=this._getOrReturnCtx(e);return _(t,{code:I.invalid_type,expected:w.bigint,received:t.parsedType}),S}gte(e,t){return this.setLimit("min",e,!0,P.toString(t))}gt(e,t){return this.setLimit("min",e,!1,P.toString(t))}lte(e,t){return this.setLimit("max",e,!0,P.toString(t))}lt(e,t){return this.setLimit("max",e,!1,P.toString(t))}setLimit(e,t,r,n){return new Pr({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:r,message:P.toString(n)}]})}_addCheck(e){return new Pr({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:P.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:P.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:P.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:P.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:P.toString(t)})}get minValue(){let e=null;for(let t of this._def.checks)if(t.kind==="min"){if(e===null||t.value>e)e=t.value}return e}get maxValue(){let e=null;for(let t of this._def.checks)if(t.kind==="max"){if(e===null||t.value<e)e=t.value}return e}}Pr.create=(e)=>new Pr({checks:[],typeName:N.ZodBigInt,coerce:e?.coerce??!1,...E(e)});class Pn extends K{_parse(e){if(this._def.coerce)e.data=Boolean(e.data);if(this._getType(e)!==w.boolean){let r=this._getOrReturnCtx(e);return _(r,{code:I.invalid_type,expected:w.boolean,received:r.parsedType}),S}return Je(e.data)}}Pn.create=(e)=>new Pn({typeName:N.ZodBoolean,coerce:e?.coerce||!1,...E(e)});class Zr extends K{_parse(e){if(this._def.coerce)e.data=new Date(e.data);if(this._getType(e)!==w.date){let o=this._getOrReturnCtx(e);return _(o,{code:I.invalid_type,expected:w.date,received:o.parsedType}),S}if(Number.isNaN(e.data.getTime())){let o=this._getOrReturnCtx(e);return _(o,{code:I.invalid_date}),S}let r=new qe,n=void 0;for(let o of this._def.checks)if(o.kind==="min"){if(e.data.getTime()<o.value)n=this._getOrReturnCtx(e,n),_(n,{code:I.too_small,message:o.message,inclusive:!0,exact:!1,minimum:o.value,type:"date"}),r.dirty()}else if(o.kind==="max"){if(e.data.getTime()>o.value)n=this._getOrReturnCtx(e,n),_(n,{code:I.too_big,message:o.message,inclusive:!0,exact:!1,maximum:o.value,type:"date"}),r.dirty()}else v.assertNever(o);return{status:r.value,value:new Date(e.data.getTime())}}_addCheck(e){return new Zr({...this._def,checks:[...this._def.checks,e]})}min(e,t){return this._addCheck({kind:"min",value:e.getTime(),message:P.toString(t)})}max(e,t){return this._addCheck({kind:"max",value:e.getTime(),message:P.toString(t)})}get minDate(){let e=null;for(let t of this._def.checks)if(t.kind==="min"){if(e===null||t.value>e)e=t.value}return e!=null?new Date(e):null}get maxDate(){let e=null;for(let t of this._def.checks)if(t.kind==="max"){if(e===null||t.value<e)e=t.value}return e!=null?new Date(e):null}}Zr.create=(e)=>new Zr({checks:[],coerce:e?.coerce||!1,typeName:N.ZodDate,...E(e)});class lo extends K{_parse(e){if(this._getType(e)!==w.symbol){let r=this._getOrReturnCtx(e);return _(r,{code:I.invalid_type,expected:w.symbol,received:r.parsedType}),S}return Je(e.data)}}lo.create=(e)=>new lo({typeName:N.ZodSymbol,...E(e)});class Sn extends K{_parse(e){if(this._getType(e)!==w.undefined){let r=this._getOrReturnCtx(e);return _(r,{code:I.invalid_type,expected:w.undefined,received:r.parsedType}),S}return Je(e.data)}}Sn.create=(e)=>new Sn({typeName:N.ZodUndefined,...E(e)});class Nn extends K{_parse(e){if(this._getType(e)!==w.null){let r=this._getOrReturnCtx(e);return _(r,{code:I.invalid_type,expected:w.null,received:r.parsedType}),S}return Je(e.data)}}Nn.create=(e)=>new Nn({typeName:N.ZodNull,...E(e)});class en extends K{constructor(){super(...arguments);this._any=!0}_parse(e){return Je(e.data)}}en.create=(e)=>new en({typeName:N.ZodAny,...E(e)});class Fr extends K{constructor(){super(...arguments);this._unknown=!0}_parse(e){return Je(e.data)}}Fr.create=(e)=>new Fr({typeName:N.ZodUnknown,...E(e)});class Xt extends K{_parse(e){let t=this._getOrReturnCtx(e);return _(t,{code:I.invalid_type,expected:w.never,received:t.parsedType}),S}}Xt.create=(e)=>new Xt({typeName:N.ZodNever,...E(e)});class yo extends K{_parse(e){if(this._getType(e)!==w.undefined){let r=this._getOrReturnCtx(e);return _(r,{code:I.invalid_type,expected:w.void,received:r.parsedType}),S}return Je(e.data)}}yo.create=(e)=>new yo({typeName:N.ZodVoid,...E(e)});class Kt extends K{_parse(e){let{ctx:t,status:r}=this._processInputParams(e),n=this._def;if(t.parsedType!==w.array)return _(t,{code:I.invalid_type,expected:w.array,received:t.parsedType}),S;if(n.exactLength!==null){let s=t.data.length>n.exactLength.value,i=t.data.length<n.exactLength.value;if(s||i)_(t,{code:s?I.too_big:I.too_small,minimum:i?n.exactLength.value:void 0,maximum:s?n.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:n.exactLength.message}),r.dirty()}if(n.minLength!==null){if(t.data.length<n.minLength.value)_(t,{code:I.too_small,minimum:n.minLength.value,type:"array",inclusive:!0,exact:!1,message:n.minLength.message}),r.dirty()}if(n.maxLength!==null){if(t.data.length>n.maxLength.value)_(t,{code:I.too_big,maximum:n.maxLength.value,type:"array",inclusive:!0,exact:!1,message:n.maxLength.message}),r.dirty()}if(t.common.async)return Promise.all([...t.data].map((s,i)=>n.type._parseAsync(new Dt(t,s,t.path,i)))).then((s)=>qe.mergeArray(r,s));let o=[...t.data].map((s,i)=>n.type._parseSync(new Dt(t,s,t.path,i)));return qe.mergeArray(r,o)}get element(){return this._def.type}min(e,t){return new Kt({...this._def,minLength:{value:e,message:P.toString(t)}})}max(e,t){return new Kt({...this._def,maxLength:{value:e,message:P.toString(t)}})}length(e,t){return new Kt({...this._def,exactLength:{value:e,message:P.toString(t)}})}nonempty(e){return this.min(1,e)}}Kt.create=(e,t)=>new Kt({type:e,minLength:null,maxLength:null,exactLength:null,typeName:N.ZodArray,...E(t)});function Fn(e){if(e instanceof Oe){let t={};for(let r in e.shape){let n=e.shape[r];t[r]=Bt.create(Fn(n))}return new Oe({...e._def,shape:()=>t})}else if(e instanceof Kt)return new Kt({...e._def,type:Fn(e.element)});else if(e instanceof Bt)return Bt.create(Fn(e.unwrap()));else if(e instanceof lr)return lr.create(Fn(e.unwrap()));else if(e instanceof Qt)return Qt.create(e.items.map((t)=>Fn(t)));else return e}class Oe extends K{constructor(){super(...arguments);this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;let e=this._def.shape(),t=v.objectKeys(e);return this._cached={shape:e,keys:t},this._cached}_parse(e){if(this._getType(e)!==w.object){let c=this._getOrReturnCtx(e);return _(c,{code:I.invalid_type,expected:w.object,received:c.parsedType}),S}let{status:r,ctx:n}=this._processInputParams(e),{shape:o,keys:s}=this._getCached(),i=[];if(!(this._def.catchall instanceof Xt&&this._def.unknownKeys==="strip")){for(let c in n.data)if(!s.includes(c))i.push(c)}let a=[];for(let c of s){let u=o[c],m=n.data[c];a.push({key:{status:"valid",value:c},value:u._parse(new Dt(n,m,n.path,c)),alwaysSet:c in n.data})}if(this._def.catchall instanceof Xt){let c=this._def.unknownKeys;if(c==="passthrough")for(let u of i)a.push({key:{status:"valid",value:u},value:{status:"valid",value:n.data[u]}});else if(c==="strict"){if(i.length>0)_(n,{code:I.unrecognized_keys,keys:i}),r.dirty()}else if(c==="strip");else throw Error("Internal ZodObject error: invalid unknownKeys value.")}else{let c=this._def.catchall;for(let u of i){let m=n.data[u];a.push({key:{status:"valid",value:u},value:c._parse(new Dt(n,m,n.path,u)),alwaysSet:u in n.data})}}if(n.common.async)return Promise.resolve().then(async()=>{let c=[];for(let u of a){let m=await u.key,l=await u.value;c.push({key:m,value:l,alwaysSet:u.alwaysSet})}return c}).then((c)=>qe.mergeObjectSync(r,c));else return qe.mergeObjectSync(r,a)}get shape(){return this._def.shape()}strict(e){return P.errToObj,new Oe({...this._def,unknownKeys:"strict",...e!==void 0?{errorMap:(t,r)=>{let n=this._def.errorMap?.(t,r).message??r.defaultError;if(t.code==="unrecognized_keys")return{message:P.errToObj(e).message??n};return{message:n}}}:{}})}strip(){return new Oe({...this._def,unknownKeys:"strip"})}passthrough(){return new Oe({...this._def,unknownKeys:"passthrough"})}extend(e){return new Oe({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new Oe({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:N.ZodObject})}setKey(e,t){return this.augment({[e]:t})}catchall(e){return new Oe({...this._def,catchall:e})}pick(e){let t={};for(let r of v.objectKeys(e))if(e[r]&&this.shape[r])t[r]=this.shape[r];return new Oe({...this._def,shape:()=>t})}omit(e){let t={};for(let r of v.objectKeys(this.shape))if(!e[r])t[r]=this.shape[r];return new Oe({...this._def,shape:()=>t})}deepPartial(){return Fn(this)}partial(e){let t={};for(let r of v.objectKeys(this.shape)){let n=this.shape[r];if(e&&!e[r])t[r]=n;else t[r]=n.optional()}return new Oe({...this._def,shape:()=>t})}required(e){let t={};for(let r of v.objectKeys(this.shape))if(e&&!e[r])t[r]=this.shape[r];else{let o=this.shape[r];while(o instanceof Bt)o=o._def.innerType;t[r]=o}return new Oe({...this._def,shape:()=>t})}keyof(){return Ya(v.objectKeys(this.shape))}}Oe.create=(e,t)=>new Oe({shape:()=>e,unknownKeys:"strip",catchall:Xt.create(),typeName:N.ZodObject,...E(t)});Oe.strictCreate=(e,t)=>new Oe({shape:()=>e,unknownKeys:"strict",catchall:Xt.create(),typeName:N.ZodObject,...E(t)});Oe.lazycreate=(e,t)=>new Oe({shape:e,unknownKeys:"strip",catchall:Xt.create(),typeName:N.ZodObject,...E(t)});class Mn extends K{_parse(e){let{ctx:t}=this._processInputParams(e),r=this._def.options;function n(o){for(let i of o)if(i.result.status==="valid")return i.result;for(let i of o)if(i.result.status==="dirty")return t.common.issues.push(...i.ctx.common.issues),i.result;let s=o.map((i)=>new at(i.ctx.common.issues));return _(t,{code:I.invalid_union,unionErrors:s}),S}if(t.common.async)return Promise.all(r.map(async(o)=>{let s={...t,common:{...t.common,issues:[]},parent:null};return{result:await o._parseAsync({data:t.data,path:t.path,parent:s}),ctx:s}})).then(n);else{let o=void 0,s=[];for(let a of r){let c={...t,common:{...t.common,issues:[]},parent:null},u=a._parseSync({data:t.data,path:t.path,parent:c});if(u.status==="valid")return u;else if(u.status==="dirty"&&!o)o={result:u,ctx:c};if(c.common.issues.length)s.push(c.common.issues)}if(o)return t.common.issues.push(...o.ctx.common.issues),o.result;let i=s.map((a)=>new at(a));return _(t,{code:I.invalid_union,unionErrors:i}),S}}get options(){return this._def.options}}Mn.create=(e,t)=>new Mn({options:e,typeName:N.ZodUnion,...E(t)});var pr=(e)=>{if(e instanceof En)return pr(e.schema);else if(e instanceof vt)return pr(e.innerType());else if(e instanceof Un)return[e.value];else if(e instanceof Sr)return e.options;else if(e instanceof Ln)return v.objectValues(e.enum);else if(e instanceof Kn)return pr(e._def.innerType);else if(e instanceof Sn)return[void 0];else if(e instanceof Nn)return[null];else if(e instanceof Bt)return[void 0,...pr(e.unwrap())];else if(e instanceof lr)return[null,...pr(e.unwrap())];else if(e instanceof as)return pr(e.unwrap());else if(e instanceof Dn)return pr(e.unwrap());else if(e instanceof Bn)return pr(e._def.innerType);else return[]};class is extends K{_parse(e){let{ctx:t}=this._processInputParams(e);if(t.parsedType!==w.object)return _(t,{code:I.invalid_type,expected:w.object,received:t.parsedType}),S;let r=this.discriminator,n=t.data[r],o=this.optionsMap.get(n);if(!o)return _(t,{code:I.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[r]}),S;if(t.common.async)return o._parseAsync({data:t.data,path:t.path,parent:t});else return o._parseSync({data:t.data,path:t.path,parent:t})}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,t,r){let n=new Map;for(let o of t){let s=pr(o.shape[e]);if(!s.length)throw Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);for(let i of s){if(n.has(i))throw Error(`Discriminator property ${String(e)} has duplicate value ${String(i)}`);n.set(i,o)}}return new is({typeName:N.ZodDiscriminatedUnion,discriminator:e,options:t,optionsMap:n,...E(r)})}}function oi(e,t){let r=Yt(e),n=Yt(t);if(e===t)return{valid:!0,data:e};else if(r===w.object&&n===w.object){let o=v.objectKeys(t),s=v.objectKeys(e).filter((a)=>o.indexOf(a)!==-1),i={...e,...t};for(let a of s){let c=oi(e[a],t[a]);if(!c.valid)return{valid:!1};i[a]=c.data}return{valid:!0,data:i}}else if(r===w.array&&n===w.array){if(e.length!==t.length)return{valid:!1};let o=[];for(let s=0;s<e.length;s++){let i=e[s],a=t[s],c=oi(i,a);if(!c.valid)return{valid:!1};o.push(c.data)}return{valid:!0,data:o}}else if(r===w.date&&n===w.date&&+e===+t)return{valid:!0,data:e};else return{valid:!1}}class jn extends K{_parse(e){let{status:t,ctx:r}=this._processInputParams(e),n=(o,s)=>{if(os(o)||os(s))return S;let i=oi(o.value,s.value);if(!i.valid)return _(r,{code:I.invalid_intersection_types}),S;if(ss(o)||ss(s))t.dirty();return{status:t.value,value:i.data}};if(r.common.async)return Promise.all([this._def.left._parseAsync({data:r.data,path:r.path,parent:r}),this._def.right._parseAsync({data:r.data,path:r.path,parent:r})]).then(([o,s])=>n(o,s));else return n(this._def.left._parseSync({data:r.data,path:r.path,parent:r}),this._def.right._parseSync({data:r.data,path:r.path,parent:r}))}}jn.create=(e,t,r)=>new jn({left:e,right:t,typeName:N.ZodIntersection,...E(r)});class Qt extends K{_parse(e){let{status:t,ctx:r}=this._processInputParams(e);if(r.parsedType!==w.array)return _(r,{code:I.invalid_type,expected:w.array,received:r.parsedType}),S;if(r.data.length<this._def.items.length)return _(r,{code:I.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),S;if(!this._def.rest&&r.data.length>this._def.items.length)_(r,{code:I.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),t.dirty();let o=[...r.data].map((s,i)=>{let a=this._def.items[i]||this._def.rest;if(!a)return null;return a._parse(new Dt(r,s,r.path,i))}).filter((s)=>!!s);if(r.common.async)return Promise.all(o).then((s)=>qe.mergeArray(t,s));else return qe.mergeArray(t,o)}get items(){return this._def.items}rest(e){return new Qt({...this._def,rest:e})}}Qt.create=(e,t)=>{if(!Array.isArray(e))throw Error("You must pass an array of schemas to z.tuple([ ... ])");return new Qt({items:e,typeName:N.ZodTuple,rest:null,...E(t)})};class go extends K{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:t,ctx:r}=this._processInputParams(e);if(r.parsedType!==w.object)return _(r,{code:I.invalid_type,expected:w.object,received:r.parsedType}),S;let n=[],o=this._def.keyType,s=this._def.valueType;for(let i in r.data)n.push({key:o._parse(new Dt(r,i,r.path,i)),value:s._parse(new Dt(r,r.data[i],r.path,i)),alwaysSet:i in r.data});if(r.common.async)return qe.mergeObjectAsync(t,n);else return qe.mergeObjectSync(t,n)}get element(){return this._def.valueType}static create(e,t,r){if(t instanceof K)return new go({keyType:e,valueType:t,typeName:N.ZodRecord,...E(r)});return new go({keyType:Lt.create(),valueType:e,typeName:N.ZodRecord,...E(t)})}}class ho extends K{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:t,ctx:r}=this._processInputParams(e);if(r.parsedType!==w.map)return _(r,{code:I.invalid_type,expected:w.map,received:r.parsedType}),S;let n=this._def.keyType,o=this._def.valueType,s=[...r.data.entries()].map(([i,a],c)=>({key:n._parse(new Dt(r,i,r.path,[c,"key"])),value:o._parse(new Dt(r,a,r.path,[c,"value"]))}));if(r.common.async){let i=new Map;return Promise.resolve().then(async()=>{for(let a of s){let c=await a.key,u=await a.value;if(c.status==="aborted"||u.status==="aborted")return S;if(c.status==="dirty"||u.status==="dirty")t.dirty();i.set(c.value,u.value)}return{status:t.value,value:i}})}else{let i=new Map;for(let a of s){let{key:c,value:u}=a;if(c.status==="aborted"||u.status==="aborted")return S;if(c.status==="dirty"||u.status==="dirty")t.dirty();i.set(c.value,u.value)}return{status:t.value,value:i}}}}ho.create=(e,t,r)=>new ho({valueType:t,keyType:e,typeName:N.ZodMap,...E(r)});class tn extends K{_parse(e){let{status:t,ctx:r}=this._processInputParams(e);if(r.parsedType!==w.set)return _(r,{code:I.invalid_type,expected:w.set,received:r.parsedType}),S;let n=this._def;if(n.minSize!==null){if(r.data.size<n.minSize.value)_(r,{code:I.too_small,minimum:n.minSize.value,type:"set",inclusive:!0,exact:!1,message:n.minSize.message}),t.dirty()}if(n.maxSize!==null){if(r.data.size>n.maxSize.value)_(r,{code:I.too_big,maximum:n.maxSize.value,type:"set",inclusive:!0,exact:!1,message:n.maxSize.message}),t.dirty()}let o=this._def.valueType;function s(a){let c=new Set;for(let u of a){if(u.status==="aborted")return S;if(u.status==="dirty")t.dirty();c.add(u.value)}return{status:t.value,value:c}}let i=[...r.data.values()].map((a,c)=>o._parse(new Dt(r,a,r.path,c)));if(r.common.async)return Promise.all(i).then((a)=>s(a));else return s(i)}min(e,t){return new tn({...this._def,minSize:{value:e,message:P.toString(t)}})}max(e,t){return new tn({...this._def,maxSize:{value:e,message:P.toString(t)}})}size(e,t){return this.min(e,t).max(e,t)}nonempty(e){return this.min(1,e)}}tn.create=(e,t)=>new tn({valueType:e,minSize:null,maxSize:null,typeName:N.ZodSet,...E(t)});class Tn extends K{constructor(){super(...arguments);this.validate=this.implement}_parse(e){let{ctx:t}=this._processInputParams(e);if(t.parsedType!==w.function)return _(t,{code:I.invalid_type,expected:w.function,received:t.parsedType}),S;function r(i,a){return po({data:i,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,Cn(),mr].filter((c)=>!!c),issueData:{code:I.invalid_arguments,argumentsError:a}})}function n(i,a){return po({data:i,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,Cn(),mr].filter((c)=>!!c),issueData:{code:I.invalid_return_type,returnTypeError:a}})}let o={errorMap:t.common.contextualErrorMap},s=t.data;if(this._def.returns instanceof rn){let i=this;return Je(async function(...a){let c=new at([]),u=await i._def.args.parseAsync(a,o).catch((x)=>{throw c.addIssue(r(a,x)),c}),m=await Reflect.apply(s,this,u);return await i._def.returns._def.type.parseAsync(m,o).catch((x)=>{throw c.addIssue(n(m,x)),c})})}else{let i=this;return Je(function(...a){let c=i._def.args.safeParse(a,o);if(!c.success)throw new at([r(a,c.error)]);let u=Reflect.apply(s,this,c.data),m=i._def.returns.safeParse(u,o);if(!m.success)throw new at([n(u,m.error)]);return m.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new Tn({...this._def,args:Qt.create(e).rest(Fr.create())})}returns(e){return new Tn({...this._def,returns:e})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,t,r){return new Tn({args:e?e:Qt.create([]).rest(Fr.create()),returns:t||Fr.create(),typeName:N.ZodFunction,...E(r)})}}class En extends K{get schema(){return this._def.getter()}_parse(e){let{ctx:t}=this._processInputParams(e);return this._def.getter()._parse({data:t.data,path:t.path,parent:t})}}En.create=(e,t)=>new En({getter:e,typeName:N.ZodLazy,...E(t)});class Un extends K{_parse(e){if(e.data!==this._def.value){let t=this._getOrReturnCtx(e);return _(t,{received:t.data,code:I.invalid_literal,expected:this._def.value}),S}return{status:"valid",value:e.data}}get value(){return this._def.value}}Un.create=(e,t)=>new Un({value:e,typeName:N.ZodLiteral,...E(t)});function Ya(e,t){return new Sr({values:e,typeName:N.ZodEnum,...E(t)})}class Sr extends K{_parse(e){if(typeof e.data!=="string"){let t=this._getOrReturnCtx(e),r=this._def.values;return _(t,{expected:v.joinValues(r),received:t.parsedType,code:I.invalid_type}),S}if(!this._cache)this._cache=new Set(this._def.values);if(!this._cache.has(e.data)){let t=this._getOrReturnCtx(e),r=this._def.values;return _(t,{received:t.data,code:I.invalid_enum_value,options:r}),S}return Je(e.data)}get options(){return this._def.values}get enum(){let e={};for(let t of this._def.values)e[t]=t;return e}get Values(){let e={};for(let t of this._def.values)e[t]=t;return e}get Enum(){let e={};for(let t of this._def.values)e[t]=t;return e}extract(e,t=this._def){return Sr.create(e,{...this._def,...t})}exclude(e,t=this._def){return Sr.create(this.options.filter((r)=>!e.includes(r)),{...this._def,...t})}}Sr.create=Ya;class Ln extends K{_parse(e){let t=v.getValidEnumValues(this._def.values),r=this._getOrReturnCtx(e);if(r.parsedType!==w.string&&r.parsedType!==w.number){let n=v.objectValues(t);return _(r,{expected:v.joinValues(n),received:r.parsedType,code:I.invalid_type}),S}if(!this._cache)this._cache=new Set(v.getValidEnumValues(this._def.values));if(!this._cache.has(e.data)){let n=v.objectValues(t);return _(r,{received:r.data,code:I.invalid_enum_value,options:n}),S}return Je(e.data)}get enum(){return this._def.values}}Ln.create=(e,t)=>new Ln({values:e,typeName:N.ZodNativeEnum,...E(t)});class rn extends K{unwrap(){return this._def.type}_parse(e){let{ctx:t}=this._processInputParams(e);if(t.parsedType!==w.promise&&t.common.async===!1)return _(t,{code:I.invalid_type,expected:w.promise,received:t.parsedType}),S;let r=t.parsedType===w.promise?t.data:Promise.resolve(t.data);return Je(r.then((n)=>this._def.type.parseAsync(n,{path:t.path,errorMap:t.common.contextualErrorMap})))}}rn.create=(e,t)=>new rn({type:e,typeName:N.ZodPromise,...E(t)});class vt extends K{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===N.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){let{status:t,ctx:r}=this._processInputParams(e),n=this._def.effect||null,o={addIssue:(s)=>{if(_(r,s),s.fatal)t.abort();else t.dirty()},get path(){return r.path}};if(o.addIssue=o.addIssue.bind(o),n.type==="preprocess"){let s=n.transform(r.data,o);if(r.common.async)return Promise.resolve(s).then(async(i)=>{if(t.value==="aborted")return S;let a=await this._def.schema._parseAsync({data:i,path:r.path,parent:r});if(a.status==="aborted")return S;if(a.status==="dirty")return Qr(a.value);if(t.value==="dirty")return Qr(a.value);return a});else{if(t.value==="aborted")return S;let i=this._def.schema._parseSync({data:s,path:r.path,parent:r});if(i.status==="aborted")return S;if(i.status==="dirty")return Qr(i.value);if(t.value==="dirty")return Qr(i.value);return i}}if(n.type==="refinement"){let s=(i)=>{let a=n.refinement(i,o);if(r.common.async)return Promise.resolve(a);if(a instanceof Promise)throw Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return i};if(r.common.async===!1){let i=this._def.schema._parseSync({data:r.data,path:r.path,parent:r});if(i.status==="aborted")return S;if(i.status==="dirty")t.dirty();return s(i.value),{status:t.value,value:i.value}}else return this._def.schema._parseAsync({data:r.data,path:r.path,parent:r}).then((i)=>{if(i.status==="aborted")return S;if(i.status==="dirty")t.dirty();return s(i.value).then(()=>({status:t.value,value:i.value}))})}if(n.type==="transform")if(r.common.async===!1){let s=this._def.schema._parseSync({data:r.data,path:r.path,parent:r});if(!Ar(s))return S;let i=n.transform(s.value,o);if(i instanceof Promise)throw Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:t.value,value:i}}else return this._def.schema._parseAsync({data:r.data,path:r.path,parent:r}).then((s)=>{if(!Ar(s))return S;return Promise.resolve(n.transform(s.value,o)).then((i)=>({status:t.value,value:i}))});v.assertNever(n)}}vt.create=(e,t,r)=>new vt({schema:e,typeName:N.ZodEffects,effect:t,...E(r)});vt.createWithPreprocess=(e,t,r)=>new vt({schema:t,effect:{type:"preprocess",transform:e},typeName:N.ZodEffects,...E(r)});class Bt extends K{_parse(e){if(this._getType(e)===w.undefined)return Je(void 0);return this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}Bt.create=(e,t)=>new Bt({innerType:e,typeName:N.ZodOptional,...E(t)});class lr extends K{_parse(e){if(this._getType(e)===w.null)return Je(null);return this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}lr.create=(e,t)=>new lr({innerType:e,typeName:N.ZodNullable,...E(t)});class Kn extends K{_parse(e){let{ctx:t}=this._processInputParams(e),r=t.data;if(t.parsedType===w.undefined)r=this._def.defaultValue();return this._def.innerType._parse({data:r,path:t.path,parent:t})}removeDefault(){return this._def.innerType}}Kn.create=(e,t)=>new Kn({innerType:e,typeName:N.ZodDefault,defaultValue:typeof t.default==="function"?t.default:()=>t.default,...E(t)});class Bn extends K{_parse(e){let{ctx:t}=this._processInputParams(e),r={...t,common:{...t.common,issues:[]}},n=this._def.innerType._parse({data:r.data,path:r.path,parent:{...r}});if(An(n))return n.then((o)=>({status:"valid",value:o.status==="valid"?o.value:this._def.catchValue({get error(){return new at(r.common.issues)},input:r.data})}));else return{status:"valid",value:n.status==="valid"?n.value:this._def.catchValue({get error(){return new at(r.common.issues)},input:r.data})}}removeCatch(){return this._def.innerType}}Bn.create=(e,t)=>new Bn({innerType:e,typeName:N.ZodCatch,catchValue:typeof t.catch==="function"?t.catch:()=>t.catch,...E(t)});class xo extends K{_parse(e){if(this._getType(e)!==w.nan){let r=this._getOrReturnCtx(e);return _(r,{code:I.invalid_type,expected:w.nan,received:r.parsedType}),S}return{status:"valid",value:e.data}}}xo.create=(e)=>new xo({typeName:N.ZodNaN,...E(e)});var Hl=Symbol("zod_brand");class as extends K{_parse(e){let{ctx:t}=this._processInputParams(e),r=t.data;return this._def.type._parse({data:r,path:t.path,parent:t})}unwrap(){return this._def.type}}class Io extends K{_parse(e){let{status:t,ctx:r}=this._processInputParams(e);if(r.common.async)return(async()=>{let o=await this._def.in._parseAsync({data:r.data,path:r.path,parent:r});if(o.status==="aborted")return S;if(o.status==="dirty")return t.dirty(),Qr(o.value);else return this._def.out._parseAsync({data:o.value,path:r.path,parent:r})})();else{let n=this._def.in._parseSync({data:r.data,path:r.path,parent:r});if(n.status==="aborted")return S;if(n.status==="dirty")return t.dirty(),{status:"dirty",value:n.value};else return this._def.out._parseSync({data:n.value,path:r.path,parent:r})}}static create(e,t){return new Io({in:e,out:t,typeName:N.ZodPipeline})}}class Dn extends K{_parse(e){let t=this._def.innerType._parse(e),r=(n)=>{if(Ar(n))n.value=Object.freeze(n.value);return n};return An(t)?t.then((n)=>r(n)):r(t)}unwrap(){return this._def.innerType}}Dn.create=(e,t)=>new Dn({innerType:e,typeName:N.ZodReadonly,...E(t)});function Va(e,t){let r=typeof e==="function"?e(t):typeof e==="string"?{message:e}:e;return typeof r==="string"?{message:r}:r}function Xa(e,t={},r){if(e)return en.create().superRefine((n,o)=>{let s=e(n);if(s instanceof Promise)return s.then((i)=>{if(!i){let a=Va(t,n),c=a.fatal??r??!0;o.addIssue({code:"custom",...a,fatal:c})}});if(!s){let i=Va(t,n),a=i.fatal??r??!0;o.addIssue({code:"custom",...i,fatal:a})}return});return en.create()}var Vl={object:Oe.lazycreate},N;(function(e){e.ZodString="ZodString",e.ZodNumber="ZodNumber",e.ZodNaN="ZodNaN",e.ZodBigInt="ZodBigInt",e.ZodBoolean="ZodBoolean",e.ZodDate="ZodDate",e.ZodSymbol="ZodSymbol",e.ZodUndefined="ZodUndefined",e.ZodNull="ZodNull",e.ZodAny="ZodAny",e.ZodUnknown="ZodUnknown",e.ZodNever="ZodNever",e.ZodVoid="ZodVoid",e.ZodArray="ZodArray",e.ZodObject="ZodObject",e.ZodUnion="ZodUnion",e.ZodDiscriminatedUnion="ZodDiscriminatedUnion",e.ZodIntersection="ZodIntersection",e.ZodTuple="ZodTuple",e.ZodRecord="ZodRecord",e.ZodMap="ZodMap",e.ZodSet="ZodSet",e.ZodFunction="ZodFunction",e.ZodLazy="ZodLazy",e.ZodLiteral="ZodLiteral",e.ZodEnum="ZodEnum",e.ZodEffects="ZodEffects",e.ZodNativeEnum="ZodNativeEnum",e.ZodOptional="ZodOptional",e.ZodNullable="ZodNullable",e.ZodDefault="ZodDefault",e.ZodCatch="ZodCatch",e.ZodPromise="ZodPromise",e.ZodBranded="ZodBranded",e.ZodPipeline="ZodPipeline",e.ZodReadonly="ZodReadonly"})(N||(N={}));var zl=(e,t={message:`Input not instance of ${e.name}`})=>Xa((r)=>r instanceof e,t),Qa=Lt.create,Za=Tr.create,Wl=xo.create,Jl=Pr.create,ec=Pn.create,Yl=Zr.create,Xl=lo.create,Ql=Sn.create,Zl=Nn.create,ey=en.create,ty=Fr.create,ry=Xt.create,ny=yo.create,oy=Kt.create,{create:sy,strictCreate:iy}=Oe,ay=Mn.create,cy=is.create,uy=jn.create,dy=Qt.create,fy=go.create,my=ho.create,py=tn.create,ly=Tn.create,yy=En.create,gy=Un.create,hy=Sr.create,xy=Ln.create,Iy=rn.create,by=vt.create,_y=Bt.create,Ry=lr.create,Oy=vt.createWithPreprocess,wy=Io.create,$y=()=>Qa().optional(),ky=()=>Za().optional(),Cy=()=>ec().optional(),Ay={string:(e)=>Lt.create({...e,coerce:!0}),number:(e)=>Tr.create({...e,coerce:!0}),boolean:(e)=>Pn.create({...e,coerce:!0}),bigint:(e)=>Pr.create({...e,coerce:!0}),date:(e)=>Zr.create({...e,coerce:!0})};var Fy=S;var Ty=cs,Xe=(e,t=400)=>Response.json(e,{status:t,headers:{"Content-Type":"application/json"}}),rc=(e)=>{let t=mo.Compile(e),r=async(n,o)=>{try{let s=n instanceof Object&&"req"in n,i=s?await n.jsonBody():await n.json();if(!t.Check(i)){let a=t.Errors(i).First();return Xe({status:"error",code:"VALIDATION_FAILED",message:a?.message||"Invalid input",path:a?.path||"body"})}if(s)n.body=i;return o?o():void 0}catch{return Xe({status:"error",message:"Malformed JSON payload"})}};return r.__schema=e,r},nc=(e)=>{let t=e.properties||{},r=Object.keys(t),n=r.length,o=Array.isArray(e.required)?new Set(e.required):null,s=async(i,a)=>{try{let c=i instanceof Object&&"req"in i,u=c?await i.jsonBody():await i.json();if(!u||typeof u!=="object"||Array.isArray(u))return Xe({status:"error",message:"Invalid JSON object payload"});for(let m=0;m<n;m++){let l=r[m];if(!(Object.hasOwn(u,l)&&u[l]!==void 0)){if(!o||o.has(l))return Xe({status:"error",code:"TYPE_MISMATCH",message:`Field '${l}' must be of type ${t[l]?.type}`,field:l});continue}if(typeof u[l]!==t[l]?.type)return Xe({status:"error",code:"TYPE_MISMATCH",message:`Field '${l}' must be of type ${t[l]?.type}`,field:l})}if(c)i.body=u;return a?a():void 0}catch{return Xe({status:"error",message:"Invalid JSON payload"})}};return s.__schema=e,s},oc=(e)=>{let t=async(r,n)=>{try{let o=r instanceof Object&&"req"in r,s=o?await r.jsonBody():await r.json(),i=await e.safeParseAsync(s);if(!i.success)return Xe({status:"error",code:"ZOD_ERROR",errors:i.error.flatten()});if(o)r.body=i.data;return n?n():void 0}catch{return Xe({status:"error",message:"Invalid JSON payload"})}};return t.__schema=e,t},Py=(e)=>{if(e&&"_def"in e)return oc(e);if(e&&(e.kind||e.type||e[Symbol.for("TypeBox.Kind")]))return rc(e);return nc(e)};var bo=(e)=>{if(e&&"_def"in e)return(r)=>{let n=e.safeParse(r);return n.success?{ok:!0,data:n.data}:{ok:!1,error:n.error.flatten()}};let t=mo.Compile(e);return(r)=>{if(t.Check(r))return{ok:!0,data:r};let n=t.Errors(r).First();return{ok:!1,error:{message:n?.message||"Invalid input",path:n?.path}}}},si=(e,t)=>{let r=e?.properties;if(!r||typeof r!=="object")return null;let n=[];for(let[o,s]of Object.entries(r)){let i=JSON.stringify(o),a=`${t}[${i}]`,c=si(s,a);if(c)n.push(`${i}: (${a} && typeof ${a} === 'object' && !Array.isArray(${a})) ? ${c} : ${a}`);else n.push(`${i}: ${a}`)}return`{ ${n.join(", ")} }`},sc=(e)=>{if(!e||"_def"in e)return null;if(e.type==="array"&&e.items){let r=si(e.items,"item");if(!r)return null;return Function(`return function(arr) {
|
|
8
|
+
if (!Array.isArray(arr)) return arr;
|
|
9
|
+
const len = arr.length;
|
|
10
|
+
const out = new Array(len);
|
|
11
|
+
for (let i = 0; i < len; i++) {
|
|
12
|
+
const item = arr[i];
|
|
13
|
+
out[i] = (item && typeof item === 'object' && !Array.isArray(item)) ? ${r} : item;
|
|
14
|
+
}
|
|
15
|
+
return out;
|
|
16
|
+
}`)()}let t=si(e,"o");if(!t)return null;return Function(`return function(o) {
|
|
17
|
+
if (!o || typeof o !== 'object' || Array.isArray(o)) return o;
|
|
18
|
+
return ${t};
|
|
19
|
+
}`)()},ic=(e)=>{let t=bo(e),r=sc(e);return(n)=>{if(n instanceof Response)return n;let o=r?r(n):n,s=t(o);if(!s.ok)return Xe({status:"error",code:"RESPONSE_VALIDATION_FAILED",error:s.error},500);return s.data}},tc=(e,t)=>{let r=t?.properties||(t?._def?.shape?typeof t._def.shape==="function"?t._def.shape():t._def.shape:null);if(!r)return e;let n={...e};for(let[o,s]of Object.entries(r)){if(!Object.hasOwn(n,o))continue;let i=n[o];if(typeof i!=="string")continue;let a=s?.type||s?._def?.typeName;if(a==="number"||a==="integer"||a==="ZodNumber"){if(i.trim()!==""){let c=Number(i);if(!Number.isNaN(c))n[o]=c}}else if(a==="boolean"||a==="ZodBoolean"){if(i==="true")n[o]=!0;else if(i==="false")n[o]=!1}}return n},ii=(e)=>{let t=e.body?bo(e.body):null,r=e.query?bo(e.query):null,n=e.params?bo(e.params):null,o=e.headers?bo(e.headers):null,s=e.stripUnknown&&e.body?sc(e.body):null,i=e.response?ic(e.response):null,a=e.maxBodySize??1048576,c=(m)=>{if(n){let l=tc(m.params,e.params),x=n(l);if(!x.ok)return Xe({status:"error",code:"PARAMS_INVALID",error:x.error});m.params=x.data}if(r){let l=tc(m.query,e.query),x=r(l);if(!x.ok)return Xe({status:"error",code:"QUERY_INVALID",error:x.error});m._query=x.data}if(o){let l={};m.req.headers.forEach((b,T)=>{l[T.toLowerCase()]=b});let x=o(l);if(!x.ok)return Xe({status:"error",code:"HEADERS_INVALID",error:x.error})}return};if(!t){let m=(l,x)=>{let b=c(l);if(b)return b;return x?x():void 0};if(m.__routeSchemas=e,i)m.__responseFilter=i;return m}let u=async(m,l)=>{let x=c(m);if(x)return x;let b;try{b=await m.jsonBody(a)}catch(C){if(C?.status===413)return Xe({status:"error",code:"PAYLOAD_TOO_LARGE",message:"Payload Too Large"},413);return Xe({status:"error",message:"Malformed JSON payload"})}let T=t(b);if(!T.ok)return Xe({status:"error",code:"VALIDATION_FAILED",error:T.error});return m.body=s?s(T.data):T.data,l?l():void 0};if(u.__schema=e.body,u.__routeSchemas=e,i)u.__responseFilter=i;return u};class vn{prefix;groupMiddleware;routes=[];constructor(e="",t=[]){this.prefix=e;this.groupMiddleware=t}_add(e,t,r){let n=(this.prefix+"/"+t).replace(/\/+/g,"/");if(n.endsWith("/"))n=n.slice(0,-1);let o=[];for(let s=0;s<r.length;s++){let i=r[s];if(typeof i==="function")o.push(i);else if(i&&typeof i==="object")o.push(ii(i))}return this.routes.push({method:e.toUpperCase(),path:n||"",handlers:[...this.groupMiddleware,...o]}),this}get=(e,...t)=>this._add("GET",e,t);post=(e,...t)=>this._add("POST",e,t);put=(e,...t)=>this._add("PUT",e,t);patch=(e,...t)=>this._add("PATCH",e,t);delete=(e,...t)=>this._add("DELETE",e,t);options=(e,...t)=>this._add("OPTIONS",e,t);head=(e,...t)=>this._add("HEAD",e,t);all=(e,...t)=>{for(let r of["GET","POST","PUT","PATCH","DELETE","OPTIONS","HEAD"])this._add(r,e,t);return this};group=(e,...t)=>{let r=t.pop(),n=t,o=(this.prefix+"/"+e).replace(/\/+/g,"/"),s=new vn(o,[...this.groupMiddleware,...n]);return r(s),this.routes.push(...s.routes),this};use(e){if(e instanceof vn||e&&e.routes)this.routes.push(...e.routes);else if(e&&typeof e.install==="function")e.install(this);else this.groupMiddleware.push(e);return this}}class nn{children={};staticKeys=[];paramNode=null;paramName=null;wildcardNode=null;handlers={};insert(e,t,r){let n=this,o=e.split("/").filter(Boolean);for(let s of o)if(s==="*"){if(!n.wildcardNode)n.wildcardNode=new nn;n=n.wildcardNode;break}else if(s.startsWith(":")){if(!n.paramNode)n.paramNode=new nn;n.paramName=s.slice(1),n=n.paramNode}else{if(!n.children[s])n.children[s]=new nn,n.staticKeys.push(s);n=n.children[s]}n.handlers[t]=r}lookup(e,t,r,n){let o=this,s=r===-1?0:r,i=t.length;if(t[s]==="/")s++;for(let a in n.params)delete n.params[a];while(s<i){let a=t.indexOf("/",s);if(a===-1)a=i;let c=a-s,u=!1,m=o.staticKeys,l=m.length;if(l===1){let x=m[0];if(x.length===c){let b=!0;for(let T=0;T<c;T++)if(x[T]!==t[s+T]){b=!1;break}if(b)o=o.children[x],u=!0}}else for(let x=0;x<l;x++){let b=m[x];if(b.length===c){let T=!0;for(let C=0;C<c;C++)if(b[C]!==t[s+C]){T=!1;break}if(T){o=o.children[b],u=!0;break}}}if(!u)if(o.paramNode)n.params[o.paramName]=t.slice(s,a),o=o.paramNode;else if(o.wildcardNode)return n.params["*"]=t.slice(s),o.wildcardNode.handlers[e]||null;else return null;s=a+1}return o.handlers[e]||null}jitCompile(e,t=0,r="url",n="s",o=[]){let s="",i=" ".repeat(t);if(Object.keys(this.handlers).length>0){if(s+=`${i}if (${n} >= urlLen) {
|
|
20
|
+
`,o.length>0){let a=o.map((c)=>`${JSON.stringify(c.name)}: ${c.varName}`).join(", ");s+=`${i} ctx.params = { ${a} };
|
|
21
|
+
`}s+=`${i} switch(method) {
|
|
22
|
+
`;for(let[a,c]of Object.entries(this.handlers)){let u=e(c);s+=`${i} case ${JSON.stringify(a)}: return ${u}(ctx);
|
|
23
|
+
`}s+=`${i} }
|
|
24
|
+
`,s+=`${i}}
|
|
25
|
+
`}if(this.staticKeys.length>0)if(this.staticKeys.length===1){let a=this.staticKeys[0],c=a.length,u=`nextIdxL${t}`;s+=`${i}if (${r}.startsWith(${JSON.stringify(a)}, ${n})) {
|
|
26
|
+
`,s+=`${i} const ${u} = ${n} + ${c};
|
|
27
|
+
`,s+=`${i} if (${u} === urlLen || ${r}.charCodeAt(${u}) === 47) {
|
|
28
|
+
`;let m=this.children[a],l=`newIdxL${t}`;s+=`${i} const ${l} = ${u} === urlLen ? urlLen : (${u} + 1);
|
|
29
|
+
`,s+=m.jitCompile(e,t+1,r,l,o),s+=`${i} }
|
|
30
|
+
`,s+=`${i}}
|
|
31
|
+
`}else if(this.staticKeys.length>4){s+=`${i}let slash${t} = ${r}.indexOf('/', ${n});
|
|
32
|
+
`,s+=`${i}if (slash${t} === -1 || slash${t} > urlLen) slash${t} = urlLen;
|
|
33
|
+
`,s+=`${i}switch (${r}.slice(${n}, slash${t})) {
|
|
34
|
+
`;for(let a of this.staticKeys){s+=`${i} case ${JSON.stringify(a)}: {
|
|
35
|
+
`;let c=this.children[a];s+=c.jitCompile(e,t+1,r,`slash${t} + 1`,o),s+=`${i} break;
|
|
36
|
+
`,s+=`${i} }
|
|
37
|
+
`}s+=`${i}}
|
|
38
|
+
`}else{s+=`${i}let slash${t} = ${r}.indexOf('/', ${n});
|
|
39
|
+
`,s+=`${i}if (slash${t} === -1 || slash${t} > urlLen) slash${t} = urlLen;
|
|
40
|
+
`,s+=`${i}const len${t} = slash${t} - (${n});
|
|
17
41
|
|
|
18
|
-
`;let a=new Map;for(let c of this.staticKeys){let
|
|
19
|
-
`;for(let[c,
|
|
20
|
-
`;for(let
|
|
21
|
-
`;else
|
|
22
|
-
`;let
|
|
23
|
-
`}
|
|
24
|
-
`}
|
|
25
|
-
`}if(this.paramNode){let a=this.paramNode;if(this.staticKeys.length
|
|
26
|
-
`,
|
|
27
|
-
`;let c=`pL${t}`;
|
|
28
|
-
`;let
|
|
42
|
+
`;let a=new Map;for(let c of this.staticKeys){let u=a.get(c.length);if(!u)u=[],a.set(c.length,u);u.push(c)}s+=`${i}switch(len${t}) {
|
|
43
|
+
`;for(let[c,u]of a){s+=`${i} case ${c}:
|
|
44
|
+
`;for(let m of u){if(c===1)s+=`${i} if (${r}.charCodeAt(${n}) === ${m.charCodeAt(0)}) {
|
|
45
|
+
`;else s+=`${i} if (${r}.startsWith(${JSON.stringify(m)}, ${n})) {
|
|
46
|
+
`;let l=this.children[m];s+=l.jitCompile(e,t+1,r,`slash${t} + 1`,o),s+=`${i} }
|
|
47
|
+
`}s+=`${i} break;
|
|
48
|
+
`}s+=`${i}}
|
|
49
|
+
`}if(this.paramNode){let a=this.paramNode;if(this.staticKeys.length<=1)s+=`${i}let slash${t} = ${r}.indexOf('/', ${n});
|
|
50
|
+
`,s+=`${i}if (slash${t} === -1 || slash${t} > urlLen) slash${t} = urlLen;
|
|
51
|
+
`;let c=`pL${t}`;s+=`${i}const ${c} = ${r}.slice(${n}, slash${t});
|
|
52
|
+
`;let u=[...o,{name:this.paramName,varName:c}];s+=a.jitCompile(e,t+1,r,`slash${t} + 1`,u)}if(this.wildcardNode&&Object.keys(this.wildcardNode.handlers).length>0){let a=`wL${t}`;s+=`${i}const ${a} = ${r}.slice(${n}, urlLen);
|
|
53
|
+
`;let u=[...o,{name:"*",varName:a}].map((m)=>`${JSON.stringify(m.name)}: ${m.varName}`).join(", ");s+=`${i}ctx.params = { ${u} };
|
|
54
|
+
`,s+=`${i}switch(method) {
|
|
55
|
+
`;for(let[m,l]of Object.entries(this.wildcardNode.handlers)){let x=e(l);s+=`${i} case ${JSON.stringify(m)}: return ${x}(ctx);
|
|
56
|
+
`}s+=`${i}}
|
|
57
|
+
`}return s}id=Math.random().toString(36).slice(2)}import{createHmac as ac,timingSafeEqual as Sy}from"crypto";class _o{req;params={};_status=200;_headers=void 0;store=new Map;body=void 0;_query=void 0;_cookies=void 0;_setCookies=void 0;_requestId=void 0;_peerIp=void 0;_trustProxy=!0;constructor(){}get query(){if(this._query!==void 0)return this._query;let e={},t=this.req?.url;if(t){let r=t.indexOf("?");if(r!==-1){let n=r+1,o=t.length;while(n<o){let s=t.indexOf("&",n);if(s===-1)s=o;if(s>n){let i=t.indexOf("=",n),a,c;if(i!==-1&&i<s)a=t.slice(n,i),c=t.slice(i+1,s);else a=t.slice(n,s),c="";if(a.indexOf("+")!==-1)a=a.replaceAll("+"," ");if(a.indexOf("%")!==-1)try{a=decodeURIComponent(a)}catch{}if(c.indexOf("+")!==-1)c=c.replaceAll("+"," ");if(c.indexOf("%")!==-1)try{c=decodeURIComponent(c)}catch{}if(a!=="__proto__"&&a!=="constructor"&&a!=="prototype")e[a]=c}n=s+1}}}return this._query=e,e}getQuery(e){return this.query[e]}get cookies(){if(this._cookies!==void 0)return this._cookies;let e={},t=this.req?.headers?.get("cookie");if(t){let r=0,n=t.length;while(r<n){let o=t.indexOf(";",r);if(o===-1)o=n;let s=t.indexOf("=",r);if(s!==-1&&s<o){let i=t.slice(r,s).trim(),a=t.slice(s+1,o).trim();try{a=decodeURIComponent(a)}catch{}if(i&&i!=="__proto__"&&i!=="constructor"&&i!=="prototype")e[i]=a}r=o+1}}return this._cookies=e,e}setCookie(e,t,r={}){let n=t;if(r.secret){let s=ac("sha256",r.secret).update(t).digest("base64url");n=`${t}.${s}`}let o=`${e}=${encodeURIComponent(n)}`;if(o+=`; Path=${r.path??"/"}`,r.domain)o+=`; Domain=${r.domain}`;if(r.maxAge!==void 0)o+=`; Max-Age=${Math.floor(r.maxAge)}`;if(r.expires)o+=`; Expires=${r.expires.toUTCString()}`;if(r.httpOnly!==!1)o+="; HttpOnly";if(r.secure)o+="; Secure";if(o+=`; SameSite=${r.sameSite??"Lax"}`,!this._setCookies)this._setCookies=[];return this._setCookies.push(o),this}getSignedCookie(e,t){let r=this.cookies[e];if(!r)return null;let n=r.lastIndexOf(".");if(n<=0)return null;let o=r.slice(0,n),s=r.slice(n+1),i=ac("sha256",t).update(o).digest(),a=Buffer.from(s,"base64url");if(a.length!==i.length||!Sy(a,i))return null;return o}deleteCookie(e,t={}){return this.setCookie(e,"",{...t,maxAge:0,expires:new Date(0)})}async jsonBody(e=1048576){if(this.body!==void 0)return this.body;let t=this.req.headers.get("content-type");if(t&&t.includes("application/json")){let r=this.req.headers.get("content-length");if(r!==null){if(Number(r)>e){let o=Error("Payload Too Large");throw o.status=413,o}try{return this.body=await this.req.json()}catch{return this.body=null}}try{let n=await this.req.text();if(Buffer.byteLength(n,"utf-8")>e){let o=Error("Payload Too Large");throw o.status=413,o}return this.body=JSON.parse(n)}catch(n){if(n?.status===413)throw n;return this.body=null}}return this.body=null}reset(e){if(this.req=e,this._status=200,this._headers=void 0,this.store.size>0)this.store.clear();return this.params={},this._query=void 0,this._cookies=void 0,this._setCookies=void 0,this.body=void 0,this._peerIp=void 0,this}status(e){return this._status=e,this}json(e){let t=this._status||200,r;if(!this._headers)r=Response.json(e,{status:t});else{if(this._headers["content-type"]===void 0)this._headers["content-type"]="application/json";r=Response.json(e,{status:t,headers:this._headers})}if(this._setCookies)for(let n=0;n<this._setCookies.length;n++)r.headers.append("Set-Cookie",this._setCookies[n]);return r}set(e,t){return this.store.set(e,t),this}get(e){return this.store.get(e)}setHeader(e,t){if(!this._headers)this._headers={};else if(Object.isFrozen(this._headers))this._headers={...this._headers};return this._headers[e.toLowerCase()]=t,this}get user(){return this.store.get("user")}send(e,t={}){let r=this._status>=400;return this.json({status:r?"error":"success",msg:e,...t})}html(e,t){let r={"content-type":"text/html; charset=utf-8",...this._headers||{}};return new Response(e,{status:t??this._status,headers:r})}text(e,t){let r={"content-type":"text/plain; charset=utf-8",...this._headers||{}};return new Response(e,{status:t??this._status,headers:r})}redirect(e,t=302){let r={location:e,...this._headers||{}};return new Response(null,{status:t,headers:r})}sse(e){let t=new TextEncoder,r=(s)=>{if(typeof s==="string")return t.encode(`data: ${s}
|
|
29
58
|
|
|
30
|
-
`);let
|
|
31
|
-
`;if(
|
|
32
|
-
`;if(
|
|
33
|
-
`;let a=typeof
|
|
59
|
+
`);let i="";if(s.id!==void 0)i+=`id: ${s.id}
|
|
60
|
+
`;if(s.event!==void 0)i+=`event: ${s.event}
|
|
61
|
+
`;if(s.retry!==void 0)i+=`retry: ${s.retry}
|
|
62
|
+
`;let a=typeof s.data==="string"?s.data:JSON.stringify(s.data);return i+=`data: ${a}
|
|
34
63
|
|
|
35
|
-
`,t.encode(s)},n=new ReadableStream({async start(i){try{if(typeof e==="function"){let s=!1,a=(m,x,I)=>{if(!s)i.enqueue(r({data:m,event:x,id:I}))},c=()=>{if(!s)s=!0,i.close()};await e(a,c),c()}else{for await(let s of e)i.enqueue(r(s));i.close()}}catch(s){i.error(s)}}}),o={"content-type":"text/event-stream; charset=utf-8","cache-control":"no-cache, no-transform",connection:"keep-alive",...this._headers||{}};return new Response(n,{status:this._status||200,headers:o})}}function as(e){return ne(e)&&!ge(e)&&!er(e)&&Symbol.asyncIterator in e}function ge(e){return Array.isArray(e)}function mo(e){return typeof e==="bigint"}function Zt(e){return typeof e==="boolean"}function Jr(e){return e instanceof globalThis.Date}function cs(e){return typeof e==="function"}function us(e){return ne(e)&&!ge(e)&&!er(e)&&Symbol.iterator in e}function fs(e){return e===null}function He(e){return typeof e==="number"}function ne(e){return typeof e==="object"&&e!==null}function po(e){return e instanceof globalThis.RegExp}function Z(e){return typeof e==="string"}function ms(e){return typeof e==="symbol"}function er(e){return e instanceof globalThis.Uint8Array}function ee(e){return e===void 0}function au(e){return e.map((t)=>lo(t))}function cu(e){return new Date(e.getTime())}function uu(e){return new Uint8Array(e)}function fu(e){return new RegExp(e.source,e.flags)}function mu(e){let t={};for(let r of Object.getOwnPropertyNames(e))t[r]=lo(e[r]);for(let r of Object.getOwnPropertySymbols(e))t[r]=lo(e[r]);return t}function lo(e){return ge(e)?au(e):Jr(e)?cu(e):er(e)?uu(e):po(e)?fu(e):ne(e)?mu(e):e}function oe(e){return lo(e)}function Yr(e,t){return t===void 0?oe(e):oe({...t,...e})}function yo(e){return Ke(e)&&globalThis.Symbol.asyncIterator in e}function xo(e){return Ke(e)&&globalThis.Symbol.iterator in e}function go(e){return e instanceof globalThis.Promise}function Xr(e){return e instanceof Date&&globalThis.Number.isFinite(e.getTime())}function Qr(e){return e instanceof globalThis.Uint8Array}function Io(e,t){return t in e}function Ke(e){return e!==null&&typeof e==="object"}function Ie(e){return globalThis.Array.isArray(e)&&!globalThis.ArrayBuffer.isView(e)}function Ue(e){return e===void 0}function _r(e){return e===null}function Or(e){return typeof e==="boolean"}function N(e){return typeof e==="number"}function ho(e){return globalThis.Number.isInteger(e)}function Ve(e){return typeof e==="bigint"}function Oe(e){return typeof e==="string"}function bo(e){return typeof e==="function"}function $r(e){return typeof e==="symbol"}function _o(e){return Ve(e)||Or(e)||_r(e)||N(e)||Oe(e)||$r(e)||Ue(e)}var te;(function(e){e.InstanceMode="default",e.ExactOptionalPropertyTypes=!1,e.AllowArrayObject=!1,e.AllowNaN=!1,e.AllowNullVoid=!1;function t(s,a){return e.ExactOptionalPropertyTypes?a in s:s[a]!==void 0}e.IsExactOptionalProperty=t;function r(s){let a=Ke(s);return e.AllowArrayObject?a:a&&!Ie(s)}e.IsObjectLike=r;function n(s){return r(s)&&!(s instanceof Date)&&!(s instanceof Uint8Array)}e.IsRecordLike=n;function o(s){return e.AllowNaN?N(s):Number.isFinite(s)}e.IsNumberLike=o;function i(s){let a=Ue(s);return e.AllowNullVoid?a||s===null:a}e.IsVoidLike=i})(te||(te={}));function du(e){return globalThis.Object.freeze(e).map((t)=>Un(t))}function pu(e){return e}function lu(e){return e}function yu(e){return e}function xu(e){let t={};for(let r of Object.getOwnPropertyNames(e))t[r]=Un(e[r]);for(let r of Object.getOwnPropertySymbols(e))t[r]=Un(e[r]);return globalThis.Object.freeze(t)}function Un(e){return ge(e)?du(e):Jr(e)?pu(e):er(e)?lu(e):po(e)?yu(e):ne(e)?xu(e):e}function p(e,t){let r=t!==void 0?{...t,...e}:e;switch(te.InstanceMode){case"freeze":return Un(r);case"clone":return oe(r);default:return r}}class H extends Error{constructor(e){super(e)}}var se=Symbol.for("TypeBox.Transform"),kt=Symbol.for("TypeBox.Readonly"),Pe=Symbol.for("TypeBox.Optional"),Ct=Symbol.for("TypeBox.Hint"),y=Symbol.for("TypeBox.Kind");function Zr(e){return ne(e)&&e[kt]==="Readonly"}function Le(e){return ne(e)&&e[Pe]==="Optional"}function di(e){return B(e,"Any")}function pi(e){return B(e,"Argument")}function ut(e){return B(e,"Array")}function Rr(e){return B(e,"AsyncIterator")}function wr(e){return B(e,"BigInt")}function Lt(e){return B(e,"Boolean")}function ft(e){return B(e,"Computed")}function mt(e){return B(e,"Constructor")}function gu(e){return B(e,"Date")}function dt(e){return B(e,"Function")}function pt(e){return B(e,"Integer")}function fe(e){return B(e,"Intersect")}function Fr(e){return B(e,"Iterator")}function B(e,t){return ne(e)&&y in e&&e[y]===t}function Oo(e){return Zt(e)||He(e)||Z(e)}function ze(e){return B(e,"Literal")}function We(e){return B(e,"MappedKey")}function ie(e){return B(e,"MappedResult")}function tr(e){return B(e,"Never")}function Iu(e){return B(e,"Not")}function En(e){return B(e,"Null")}function lt(e){return B(e,"Number")}function xe(e){return B(e,"Object")}function Pr(e){return B(e,"Promise")}function Tr(e){return B(e,"Record")}function le(e){return B(e,"Ref")}function li(e){return B(e,"RegExp")}function Bt(e){return B(e,"String")}function Kn(e){return B(e,"Symbol")}function Je(e){return B(e,"TemplateLiteral")}function hu(e){return B(e,"This")}function q(e){return ne(e)&&se in e}function Ye(e){return B(e,"Tuple")}function Gt(e){return B(e,"Undefined")}function D(e){return B(e,"Union")}function bu(e){return B(e,"Uint8Array")}function _u(e){return B(e,"Unknown")}function Ou(e){return B(e,"Unsafe")}function $u(e){return B(e,"Void")}function Ru(e){return ne(e)&&y in e&&Z(e[y])}function ae(e){return di(e)||pi(e)||ut(e)||Lt(e)||wr(e)||Rr(e)||ft(e)||mt(e)||gu(e)||dt(e)||pt(e)||fe(e)||Fr(e)||ze(e)||We(e)||ie(e)||tr(e)||Iu(e)||En(e)||lt(e)||xe(e)||Pr(e)||Tr(e)||le(e)||li(e)||Bt(e)||Kn(e)||Je(e)||hu(e)||Ye(e)||Gt(e)||D(e)||bu(e)||_u(e)||Ou(e)||$u(e)||Ru(e)}var wu=["Argument","Any","Array","AsyncIterator","BigInt","Boolean","Computed","Constructor","Date","Enum","Function","Integer","Intersect","Iterator","Literal","MappedKey","MappedResult","Not","Null","Number","Object","Promise","Record","Ref","RegExp","String","Symbol","TemplateLiteral","This","Tuple","Undefined","Union","Uint8Array","Unknown","Void"];function ds(e){try{return new RegExp(e),!0}catch{return!1}}function yi(e){if(!Z(e))return!1;for(let t=0;t<e.length;t++){let r=e.charCodeAt(t);if(r>=7&&r<=13||r===27||r===127)return!1}return!0}function ps(e){return xi(e)||ce(e)}function Ln(e){return ee(e)||mo(e)}function X(e){return ee(e)||He(e)}function xi(e){return ee(e)||Zt(e)}function W(e){return ee(e)||Z(e)}function Fu(e){return ee(e)||Z(e)&&yi(e)&&ds(e)}function Pu(e){return ee(e)||Z(e)&&yi(e)}function ls(e){return ee(e)||ce(e)}function $o(e){return ne(e)&&e[Pe]==="Optional"}function yt(e){return G(e,"Any")&&W(e.$id)}function Tu(e){return G(e,"Argument")&&He(e.index)}function Ar(e){return G(e,"Array")&&e.type==="array"&&W(e.$id)&&ce(e.items)&&X(e.minItems)&&X(e.maxItems)&&xi(e.uniqueItems)&&ls(e.contains)&&X(e.minContains)&&X(e.maxContains)}function gi(e){return G(e,"AsyncIterator")&&e.type==="AsyncIterator"&&W(e.$id)&&ce(e.items)}function Ro(e){return G(e,"BigInt")&&e.type==="bigint"&&W(e.$id)&&Ln(e.exclusiveMaximum)&&Ln(e.exclusiveMinimum)&&Ln(e.maximum)&&Ln(e.minimum)&&Ln(e.multipleOf)}function kr(e){return G(e,"Boolean")&&e.type==="boolean"&&W(e.$id)}function Au(e){return G(e,"Computed")&&Z(e.target)&&ge(e.parameters)&&e.parameters.every((t)=>ce(t))}function wo(e){return G(e,"Constructor")&&e.type==="Constructor"&&W(e.$id)&&ge(e.parameters)&&e.parameters.every((t)=>ce(t))&&ce(e.returns)}function Fo(e){return G(e,"Date")&&e.type==="Date"&&W(e.$id)&&X(e.exclusiveMaximumTimestamp)&&X(e.exclusiveMinimumTimestamp)&&X(e.maximumTimestamp)&&X(e.minimumTimestamp)&&X(e.multipleOfTimestamp)}function Po(e){return G(e,"Function")&&e.type==="Function"&&W(e.$id)&&ge(e.parameters)&&e.parameters.every((t)=>ce(t))&&ce(e.returns)}function vt(e){return G(e,"Integer")&&e.type==="integer"&&W(e.$id)&&X(e.exclusiveMaximum)&&X(e.exclusiveMinimum)&&X(e.maximum)&&X(e.minimum)&&X(e.multipleOf)}function ys(e){return ne(e)&&Object.entries(e).every(([t,r])=>yi(t)&&ce(r))}function Cr(e){return G(e,"Intersect")&&(Z(e.type)&&e.type!=="object"?!1:!0)&&ge(e.allOf)&&e.allOf.every((t)=>ce(t)&&!ju(t))&&W(e.type)&&(xi(e.unevaluatedProperties)||ls(e.unevaluatedProperties))&&W(e.$id)}function Ii(e){return G(e,"Iterator")&&e.type==="Iterator"&&W(e.$id)&&ce(e.items)}function G(e,t){return ne(e)&&y in e&&e[y]===t}function xs(e){return rr(e)&&Z(e.const)}function gs(e){return rr(e)&&He(e.const)}function Is(e){return rr(e)&&Zt(e.const)}function rr(e){return G(e,"Literal")&&W(e.$id)&&ku(e.const)}function ku(e){return Zt(e)||He(e)||Z(e)}function Cu(e){return G(e,"MappedKey")&&ge(e.keys)&&e.keys.every((t)=>He(t)||Z(t))}function Nu(e){return G(e,"MappedResult")&&ys(e.properties)}function nr(e){return G(e,"Never")&&ne(e.not)&&Object.getOwnPropertyNames(e.not).length===0}function en(e){return G(e,"Not")&&ce(e.not)}function hi(e){return G(e,"Null")&&e.type==="null"&&W(e.$id)}function Be(e){return G(e,"Number")&&e.type==="number"&&W(e.$id)&&X(e.exclusiveMaximum)&&X(e.exclusiveMinimum)&&X(e.maximum)&&X(e.minimum)&&X(e.multipleOf)}function me(e){return G(e,"Object")&&e.type==="object"&&W(e.$id)&&ys(e.properties)&&ps(e.additionalProperties)&&X(e.minProperties)&&X(e.maxProperties)}function bi(e){return G(e,"Promise")&&e.type==="Promise"&&W(e.$id)&&ce(e.item)}function Te(e){return G(e,"Record")&&e.type==="object"&&W(e.$id)&&ps(e.additionalProperties)&&ne(e.patternProperties)&&((t)=>{let r=Object.getOwnPropertyNames(t.patternProperties);return r.length===1&&ds(r[0])&&ne(t.patternProperties)&&ce(t.patternProperties[r[0]])})(e)}function Su(e){return G(e,"Ref")&&W(e.$id)&&Z(e.$ref)}function Bn(e){return G(e,"RegExp")&&W(e.$id)&&Z(e.source)&&Z(e.flags)&&X(e.maxLength)&&X(e.minLength)}function xt(e){return G(e,"String")&&e.type==="string"&&W(e.$id)&&X(e.minLength)&&X(e.maxLength)&&Fu(e.pattern)&&Pu(e.format)}function Gn(e){return G(e,"Symbol")&&e.type==="symbol"&&W(e.$id)}function Dn(e){return G(e,"TemplateLiteral")&&e.type==="string"&&Z(e.pattern)&&e.pattern[0]==="^"&&e.pattern[e.pattern.length-1]==="$"}function Mu(e){return G(e,"This")&&W(e.$id)&&Z(e.$ref)}function ju(e){return ne(e)&&se in e}function To(e){return G(e,"Tuple")&&e.type==="array"&&W(e.$id)&&He(e.minItems)&&He(e.maxItems)&&e.minItems===e.maxItems&&(ee(e.items)&&ee(e.additionalItems)&&e.minItems===0||ge(e.items)&&e.items.every((t)=>ce(t)))}function Nr(e){return G(e,"Undefined")&&e.type==="undefined"&&W(e.$id)}function qt(e){return G(e,"Union")&&W(e.$id)&&ne(e)&&ge(e.anyOf)&&e.anyOf.every((t)=>ce(t))}function vn(e){return G(e,"Uint8Array")&&e.type==="Uint8Array"&&W(e.$id)&&X(e.minByteLength)&&X(e.maxByteLength)}function gt(e){return G(e,"Unknown")&&W(e.$id)}function Uu(e){return G(e,"Unsafe")}function Ao(e){return G(e,"Void")&&e.type==="void"&&W(e.$id)}function Eu(e){return ne(e)&&y in e&&Z(e[y])&&!wu.includes(e[y])}function ce(e){return ne(e)&&(yt(e)||Tu(e)||Ar(e)||kr(e)||Ro(e)||gi(e)||Au(e)||wo(e)||Fo(e)||Po(e)||vt(e)||Cr(e)||Ii(e)||rr(e)||Cu(e)||Nu(e)||nr(e)||en(e)||hi(e)||Be(e)||me(e)||bi(e)||Te(e)||Su(e)||Bn(e)||xt(e)||Gn(e)||Dn(e)||Mu(e)||To(e)||Nr(e)||qt(e)||vn(e)||gt(e)||Uu(e)||Ao(e)||Eu(e))}var bs="(true|false)",ko="(0|[1-9][0-9]*)",_s="(.*)";var or="^(0|[1-9][0-9]*)$",ir="^(.*)$",Os="^(?!.*)$";var $s=new Map;function _i(e){return $s.has(e)}function Oi(e){return $s.get(e)}var Rs=new Map;function qn(e){return Rs.has(e)}function $i(e){return Rs.get(e)}function ws(e,t){return e.includes(t)}function Fs(e){return[...new Set(e)]}function Ku(e,t){return e.filter((r)=>t.includes(r))}function Lu(e,t){return e.reduce((r,n)=>Ku(r,n),t)}function Ps(e){return e.length===1?e[0]:e.length>1?Lu(e.slice(1),e[0]):[]}function Ts(e){let t=[];for(let r of e)t.push(...r);return t}function sr(e){return p({[y]:"Any"},e)}function tn(e,t){return p({[y]:"Array",type:"array",items:e},t)}function As(e){return p({[y]:"Argument",index:e})}function rn(e,t){return p({[y]:"AsyncIterator",type:"AsyncIterator",items:e},t)}function re(e,t,r){return p({[y]:"Computed",target:e,parameters:t},r)}function Bu(e,t){let{[t]:r,...n}=e;return n}function de(e,t){return t.reduce((r,n)=>Bu(r,n),e)}function M(e){return p({[y]:"Never",not:{}},e)}function v(e){return p({[y]:"MappedResult",properties:e})}function nn(e,t,r){return p({[y]:"Constructor",type:"Constructor",parameters:e,returns:t},r)}function Nt(e,t,r){return p({[y]:"Function",type:"Function",parameters:e,returns:t},r)}function Hn(e,t){return p({[y]:"Union",anyOf:e},t)}function Gu(e){return e.some((t)=>Le(t))}function ks(e){return e.map((t)=>Le(t)?Du(t):t)}function Du(e){return de(e,[Pe])}function vu(e,t){return Gu(e)?Ce(Hn(ks(e),t)):Hn(ks(e),t)}function St(e,t){return e.length===1?p(e[0],t):e.length===0?M(t):vu(e,t)}function z(e,t){return e.length===0?M(t):e.length===1?p(e[0],t):Hn(e,t)}class Ri extends H{}function qu(e){return e.replace(/\\\$/g,"$").replace(/\\\*/g,"*").replace(/\\\^/g,"^").replace(/\\\|/g,"|").replace(/\\\(/g,"(").replace(/\\\)/g,")")}function wi(e,t,r){return e[t]===r&&e.charCodeAt(t-1)!==92}function Ht(e,t){return wi(e,t,"(")}function Vn(e,t){return wi(e,t,")")}function Cs(e,t){return wi(e,t,"|")}function Hu(e){if(!(Ht(e,0)&&Vn(e,e.length-1)))return!1;let t=0;for(let r=0;r<e.length;r++){if(Ht(e,r))t+=1;if(Vn(e,r))t-=1;if(t===0&&r!==e.length-1)return!1}return!0}function Vu(e){return e.slice(1,e.length-1)}function zu(e){let t=0;for(let r=0;r<e.length;r++){if(Ht(e,r))t+=1;if(Vn(e,r))t-=1;if(Cs(e,r)&&t===0)return!0}return!1}function Wu(e){for(let t=0;t<e.length;t++)if(Ht(e,t))return!0;return!1}function Ju(e){let[t,r]=[0,0],n=[];for(let i=0;i<e.length;i++){if(Ht(e,i))t+=1;if(Vn(e,i))t-=1;if(Cs(e,i)&&t===0){let s=e.slice(r,i);if(s.length>0)n.push(on(s));r=i+1}}let o=e.slice(r);if(o.length>0)n.push(on(o));if(n.length===0)return{type:"const",const:""};if(n.length===1)return n[0];return{type:"or",expr:n}}function Yu(e){function t(o,i){if(!Ht(o,i))throw new Ri("TemplateLiteralParser: Index must point to open parens");let s=0;for(let a=i;a<o.length;a++){if(Ht(o,a))s+=1;if(Vn(o,a))s-=1;if(s===0)return[i,a]}throw new Ri("TemplateLiteralParser: Unclosed group parens in expression")}function r(o,i){for(let s=i;s<o.length;s++)if(Ht(o,s))return[i,s];return[i,o.length]}let n=[];for(let o=0;o<e.length;o++)if(Ht(e,o)){let[i,s]=t(e,o),a=e.slice(i,s+1);n.push(on(a)),o=s}else{let[i,s]=r(e,o),a=e.slice(i,s);if(a.length>0)n.push(on(a));o=s-1}return n.length===0?{type:"const",const:""}:n.length===1?n[0]:{type:"and",expr:n}}function on(e){return Hu(e)?on(Vu(e)):zu(e)?Ju(e):Wu(e)?Yu(e):{type:"const",const:qu(e)}}function sn(e){return on(e.slice(1,e.length-1))}class Ns extends H{}function Xu(e){return e.type==="or"&&e.expr.length===2&&e.expr[0].type==="const"&&e.expr[0].const==="0"&&e.expr[1].type==="const"&&e.expr[1].const==="[1-9][0-9]*"}function Qu(e){return e.type==="or"&&e.expr.length===2&&e.expr[0].type==="const"&&e.expr[0].const==="true"&&e.expr[1].type==="const"&&e.expr[1].const==="false"}function Zu(e){return e.type==="const"&&e.const===".*"}function Sr(e){return Xu(e)||Zu(e)?!1:Qu(e)?!0:e.type==="and"?e.expr.every((t)=>Sr(t)):e.type==="or"?e.expr.every((t)=>Sr(t)):e.type==="const"?!0:(()=>{throw new Ns("Unknown expression type")})()}function Ss(e){let t=sn(e.pattern);return Sr(t)}class Ms extends H{}function*js(e){if(e.length===1)return yield*e[0];for(let t of e[0])for(let r of js(e.slice(1)))yield`${t}${r}`}function*ef(e){return yield*js(e.expr.map((t)=>[...zn(t)]))}function*tf(e){for(let t of e.expr)yield*zn(t)}function*rf(e){return yield e.const}function*zn(e){return e.type==="and"?yield*ef(e):e.type==="or"?yield*tf(e):e.type==="const"?yield*rf(e):(()=>{throw new Ms("Unknown expression")})()}function So(e){let t=sn(e.pattern);return Sr(t)?[...zn(t)]:[]}function V(e,t){return p({[y]:"Literal",const:e,type:typeof e},t)}function Mo(e){return p({[y]:"Boolean",type:"boolean"},e)}function an(e){return p({[y]:"BigInt",type:"bigint"},e)}function et(e){return p({[y]:"Number",type:"number"},e)}function It(e){return p({[y]:"String",type:"string"},e)}function*nf(e){let t=e.trim().replace(/"|'/g,"");return t==="boolean"?yield Mo():t==="number"?yield et():t==="bigint"?yield an():t==="string"?yield It():yield(()=>{let r=t.split("|").map((n)=>V(n.trim()));return r.length===0?M():r.length===1?r[0]:St(r)})()}function*of(e){if(e[1]!=="{"){let t=V("$"),r=Fi(e.slice(1));return yield*[t,...r]}for(let t=2;t<e.length;t++)if(e[t]==="}"){let r=nf(e.slice(2,t)),n=Fi(e.slice(t+1));return yield*[...r,...n]}yield V(e)}function*Fi(e){for(let t=0;t<e.length;t++)if(e[t]==="$"){let r=V(e.slice(0,t)),n=of(e.slice(t));return yield*[r,...n]}yield V(e)}function Us(e){return[...Fi(e)]}class Es extends H{}function sf(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Ks(e,t){return Je(e)?e.pattern.slice(1,e.pattern.length-1):D(e)?`(${e.anyOf.map((r)=>Ks(r,t)).join("|")})`:lt(e)?`${t}${ko}`:pt(e)?`${t}${ko}`:wr(e)?`${t}${ko}`:Bt(e)?`${t}${_s}`:ze(e)?`${t}${sf(e.const.toString())}`:Lt(e)?`${t}${bs}`:(()=>{throw new Es(`Unexpected Kind '${e[y]}'`)})()}function Pi(e){return`^${e.map((t)=>Ks(t,"")).join("")}$`}function Mr(e){let r=So(e).map((n)=>V(n));return St(r)}function jo(e,t){let r=Z(e)?Pi(Us(e)):Pi(e);return p({[y]:"TemplateLiteral",type:"string",pattern:r},t)}function af(e){return So(e).map((r)=>r.toString())}function cf(e){let t=[];for(let r of e)t.push(...Ge(r));return t}function uf(e){return[e.toString()]}function Ge(e){return[...new Set(Je(e)?af(e):D(e)?cf(e.anyOf):ze(e)?uf(e.const):lt(e)?["[number]"]:pt(e)?["[number]"]:[])]}function ff(e,t,r){let n={};for(let o of Object.getOwnPropertyNames(t))n[o]=ar(e,Ge(t[o]),r);return n}function mf(e,t,r){return ff(e,t.properties,r)}function Ls(e,t,r){let n=mf(e,t,r);return v(n)}function Gs(e,t){return e.map((r)=>Ds(r,t))}function df(e){return e.filter((t)=>!tr(t))}function pf(e,t){return Uo(df(Gs(e,t)))}function lf(e){return e.some((t)=>tr(t))?[]:e}function yf(e,t){return St(lf(Gs(e,t)))}function xf(e,t){return t in e?e[t]:t==="[number]"?St(e):M()}function gf(e,t){return t==="[number]"?e:M()}function If(e,t){return t in e?e[t]:M()}function Ds(e,t){return fe(e)?pf(e.allOf,t):D(e)?yf(e.anyOf,t):Ye(e)?xf(e.items??[],t):ut(e)?gf(e.items,t):xe(e)?If(e.properties,t):M()}function Wn(e,t){return t.map((r)=>Ds(e,r))}function Bs(e,t){return St(Wn(e,t))}function ar(e,t,r){if(le(e)||le(t)){if(!ae(e)||!ae(t))throw new H("Index types using Ref parameters require both Type and Key to be of TSchema");return re("Index",[e,t])}if(ie(t))return Ls(e,t,r);if(We(t))return vs(e,t,r);return p(ae(t)?Bs(e,Ge(t)):Bs(e,t),r)}function hf(e,t,r){return{[t]:ar(e,[t],oe(r))}}function bf(e,t,r){return t.reduce((n,o)=>({...n,...hf(e,o,r)}),{})}function _f(e,t,r){return bf(e,t.keys,r)}function vs(e,t,r){let n=_f(e,t,r);return v(n)}function cn(e,t){return p({[y]:"Iterator",type:"Iterator",items:e},t)}function Of(e){return globalThis.Object.keys(e).filter((t)=>!Le(e[t]))}function $f(e,t){let r=Of(e),n=r.length>0?{[y]:"Object",type:"object",required:r,properties:e}:{[y]:"Object",type:"object",properties:e};return p(n,t)}var J=$f;function Eo(e,t){return p({[y]:"Promise",type:"Promise",item:e},t)}function Rf(e){return p(de(e,[kt]))}function wf(e){return p({...e,[kt]:"Readonly"})}function Ff(e,t){return t===!1?Rf(e):wf(e)}function De(e,t){let r=t??!0;return ie(e)?qs(e,r):Ff(e,r)}function Pf(e,t){let r={};for(let n of globalThis.Object.getOwnPropertyNames(e))r[n]=De(e[n],t);return r}function Tf(e,t){return Pf(e.properties,t)}function qs(e,t){let r=Tf(e,t);return v(r)}function tt(e,t){return p(e.length>0?{[y]:"Tuple",type:"array",items:e,additionalItems:!1,minItems:e.length,maxItems:e.length}:{[y]:"Tuple",type:"array",minItems:e.length,maxItems:e.length},t)}function Hs(e,t){return e in t?rt(e,t[e]):v(t)}function Af(e){return{[e]:V(e)}}function kf(e){let t={};for(let r of e)t[r]=V(r);return t}function Cf(e,t){return ws(t,e)?Af(e):kf(t)}function Nf(e,t){let r=Cf(e,t);return Hs(e,r)}function Jn(e,t){return t.map((r)=>rt(e,r))}function Sf(e,t){let r={};for(let n of globalThis.Object.getOwnPropertyNames(t))r[n]=rt(e,t[n]);return r}function rt(e,t){let r={...t};return Le(t)?Ce(rt(e,de(t,[Pe]))):Zr(t)?De(rt(e,de(t,[kt]))):ie(t)?Hs(e,t.properties):We(t)?Nf(e,t.keys):mt(t)?nn(Jn(e,t.parameters),rt(e,t.returns),r):dt(t)?Nt(Jn(e,t.parameters),rt(e,t.returns),r):Rr(t)?rn(rt(e,t.items),r):Fr(t)?cn(rt(e,t.items),r):fe(t)?Ne(Jn(e,t.allOf),r):D(t)?z(Jn(e,t.anyOf),r):Ye(t)?tt(Jn(e,t.items??[]),r):xe(t)?J(Sf(e,t.properties),r):ut(t)?tn(rt(e,t.items),r):Pr(t)?Eo(rt(e,t.item),r):t}function Mf(e,t){let r={};for(let n of e)r[n]=rt(n,t);return r}function Vs(e,t,r){let n=ae(e)?Ge(e):e,o=t({[y]:"MappedKey",keys:n}),i=Mf(n,o);return J(i,r)}function jf(e){return p(de(e,[Pe]))}function Uf(e){return p({...e,[Pe]:"Optional"})}function Ef(e,t){return t===!1?jf(e):Uf(e)}function Ce(e,t){let r=t??!0;return ie(e)?zs(e,r):Ef(e,r)}function Kf(e,t){let r={};for(let n of globalThis.Object.getOwnPropertyNames(e))r[n]=Ce(e[n],t);return r}function Lf(e,t){return Kf(e.properties,t)}function zs(e,t){let r=Lf(e,t);return v(r)}function Yn(e,t={}){let r=e.every((o)=>xe(o)),n=ae(t.unevaluatedProperties)?{unevaluatedProperties:t.unevaluatedProperties}:{};return p(t.unevaluatedProperties===!1||ae(t.unevaluatedProperties)||r?{...n,[y]:"Intersect",type:"object",allOf:e}:{...n,[y]:"Intersect",allOf:e},t)}function Bf(e){return e.every((t)=>Le(t))}function Gf(e){return de(e,[Pe])}function Ws(e){return e.map((t)=>Le(t)?Gf(t):t)}function Df(e,t){return Bf(e)?Ce(Yn(Ws(e),t)):Yn(Ws(e),t)}function Uo(e,t={}){if(e.length===1)return p(e[0],t);if(e.length===0)return M(t);if(e.some((r)=>q(r)))throw Error("Cannot intersect transform types");return Df(e,t)}function Ne(e,t){if(e.length===1)return p(e[0],t);if(e.length===0)return M(t);if(e.some((r)=>q(r)))throw Error("Cannot intersect transform types");return Yn(e,t)}function nt(...e){let[t,r]=typeof e[0]==="string"?[e[0],e[1]]:[e[0].$id,e[1]];if(typeof t!=="string")throw new H("Ref: $ref must be a string");return p({[y]:"Ref",$ref:t},r)}function vf(e,t){return re("Awaited",[re(e,t)])}function qf(e){return re("Awaited",[nt(e)])}function Hf(e){return Ne(Js(e))}function Vf(e){return z(Js(e))}function zf(e){return un(e)}function Js(e){return e.map((t)=>un(t))}function un(e,t){return p(ft(e)?vf(e.target,e.parameters):fe(e)?Hf(e.allOf):D(e)?Vf(e.anyOf):Pr(e)?zf(e.item):le(e)?qf(e.$ref):e,t)}function Ys(e){let t=[];for(let r of e)t.push(ot(r));return t}function Wf(e){let t=Ys(e);return Ts(t)}function Jf(e){let t=Ys(e);return Ps(t)}function Yf(e){return e.map((t,r)=>r.toString())}function Xf(e){return["[number]"]}function Qf(e){return globalThis.Object.getOwnPropertyNames(e)}function Zf(e){if(!Ti)return[];return globalThis.Object.getOwnPropertyNames(e).map((r)=>r[0]==="^"&&r[r.length-1]==="$"?r.slice(1,r.length-1):r)}function ot(e){return fe(e)?Wf(e.allOf):D(e)?Jf(e.anyOf):Ye(e)?Yf(e.items??[]):ut(e)?Xf(e.items):xe(e)?Qf(e.properties):Tr(e)?Zf(e.patternProperties):[]}var Ti=!1;function Vt(e){Ti=!0;let t=ot(e);return Ti=!1,`^(${t.map((n)=>`(${n})`).join("|")})$`}function em(e,t){return re("KeyOf",[re(e,t)])}function tm(e){return re("KeyOf",[nt(e)])}function rm(e,t){let r=ot(e),n=nm(r),o=St(n);return p(o,t)}function nm(e){return e.map((t)=>t==="[number]"?et():V(t))}function fn(e,t){return ft(e)?em(e.target,e.parameters):le(e)?tm(e.$ref):ie(e)?Xs(e,t):rm(e,t)}function om(e,t){let r={};for(let n of globalThis.Object.getOwnPropertyNames(e))r[n]=fn(e[n],oe(t));return r}function im(e,t){return om(e.properties,t)}function Xs(e,t){let r=im(e,t);return v(r)}function Ko(e){let t=ot(e),r=Wn(e,t);return t.map((n,o)=>[t[o],r[o]])}function sm(e){let t=[];for(let r of e)t.push(...ot(r));return Fs(t)}function am(e){return e.filter((t)=>!tr(t))}function cm(e,t){let r=[];for(let n of e)r.push(...Wn(n,[t]));return am(r)}function um(e,t){let r={};for(let n of t)r[n]=Uo(cm(e,n));return r}function Qs(e,t){let r=sm(e),n=um(e,r);return J(n,t)}function Lo(e){return p({[y]:"Date",type:"Date"},e)}function Bo(e){return p({[y]:"Null",type:"null"},e)}function Go(e){return p({[y]:"Symbol",type:"symbol"},e)}function Do(e){return p({[y]:"Undefined",type:"undefined"},e)}function vo(e){return p({[y]:"Uint8Array",type:"Uint8Array"},e)}function cr(e){return p({[y]:"Unknown"},e)}function fm(e){return e.map((t)=>Ai(t,!1))}function mm(e){let t={};for(let r of globalThis.Object.getOwnPropertyNames(e))t[r]=De(Ai(e[r],!1));return t}function qo(e,t){return t===!0?e:De(e)}function Ai(e,t){return as(e)?qo(sr(),t):us(e)?qo(sr(),t):ge(e)?De(tt(fm(e))):er(e)?vo():Jr(e)?Lo():ne(e)?qo(J(mm(e)),t):cs(e)?qo(Nt([],cr()),t):ee(e)?Do():fs(e)?Bo():ms(e)?Go():mo(e)?an():He(e)?V(e):Zt(e)?V(e):Z(e)?V(e):J({})}function Zs(e,t){return p(Ai(e,!0),t)}function ea(e,t){return mt(e)?tt(e.parameters,t):M(t)}function ta(e,t){if(ee(e))throw Error("Enum undefined or empty");let r=globalThis.Object.getOwnPropertyNames(e).filter((i)=>isNaN(i)).map((i)=>e[i]),o=[...new Set(r)].map((i)=>V(i));return z(o,{...t,[Ct]:"Enum"})}class sa extends H{}var l;(function(e){e[e.Union=0]="Union",e[e.True=1]="True",e[e.False=2]="False"})(l||(l={}));function it(e){return e===l.False?e:l.True}function mn(e){throw new sa(e)}function he(e){return nr(e)||Cr(e)||qt(e)||gt(e)||yt(e)}function be(e,t){return nr(t)?ua(e,t):Cr(t)?Ho(e,t):qt(t)?Mi(e,t):gt(t)?pa(e,t):yt(t)?Si(e,t):mn("StructuralRight")}function Si(e,t){return l.True}function dm(e,t){return Cr(t)?Ho(e,t):qt(t)&&t.anyOf.some((r)=>yt(r)||gt(r))?l.True:qt(t)?l.Union:gt(t)?l.True:yt(t)?l.True:l.Union}function pm(e,t){return gt(e)?l.False:yt(e)?l.Union:nr(e)?l.True:l.False}function lm(e,t){return me(t)&&Vo(t)?l.True:he(t)?be(e,t):!Ar(t)?l.False:it(Y(e.items,t.items))}function ym(e,t){return he(t)?be(e,t):!gi(t)?l.False:it(Y(e.items,t.items))}function xm(e,t){return he(t)?be(e,t):me(t)?Se(e,t):Te(t)?st(e,t):Ro(t)?l.True:l.False}function aa(e,t){return Is(e)?l.True:kr(e)?l.True:l.False}function gm(e,t){return he(t)?be(e,t):me(t)?Se(e,t):Te(t)?st(e,t):kr(t)?l.True:l.False}function Im(e,t){return he(t)?be(e,t):me(t)?Se(e,t):!wo(t)?l.False:e.parameters.length>t.parameters.length?l.False:!e.parameters.every((r,n)=>it(Y(t.parameters[n],r))===l.True)?l.False:it(Y(e.returns,t.returns))}function hm(e,t){return he(t)?be(e,t):me(t)?Se(e,t):Te(t)?st(e,t):Fo(t)?l.True:l.False}function bm(e,t){return he(t)?be(e,t):me(t)?Se(e,t):!Po(t)?l.False:e.parameters.length>t.parameters.length?l.False:!e.parameters.every((r,n)=>it(Y(t.parameters[n],r))===l.True)?l.False:it(Y(e.returns,t.returns))}function ca(e,t){return rr(e)&&He(e.const)?l.True:Be(e)||vt(e)?l.True:l.False}function _m(e,t){return vt(t)||Be(t)?l.True:he(t)?be(e,t):me(t)?Se(e,t):Te(t)?st(e,t):l.False}function Ho(e,t){return t.allOf.every((r)=>Y(e,r)===l.True)?l.True:l.False}function Om(e,t){return e.allOf.some((r)=>Y(r,t)===l.True)?l.True:l.False}function $m(e,t){return he(t)?be(e,t):!Ii(t)?l.False:it(Y(e.items,t.items))}function Rm(e,t){return rr(t)&&t.const===e.const?l.True:he(t)?be(e,t):me(t)?Se(e,t):Te(t)?st(e,t):xt(t)?da(e,t):Be(t)?fa(e,t):vt(t)?ca(e,t):kr(t)?aa(e,t):l.False}function ua(e,t){return l.False}function wm(e,t){return l.True}function ra(e){let[t,r]=[e,0];while(!0){if(!en(t))break;t=t.not,r+=1}return r%2===0?t:cr()}function Fm(e,t){return en(e)?Y(ra(e),t):en(t)?Y(e,ra(t)):mn("Invalid fallthrough for Not")}function Pm(e,t){return he(t)?be(e,t):me(t)?Se(e,t):Te(t)?st(e,t):hi(t)?l.True:l.False}function fa(e,t){return gs(e)?l.True:Be(e)||vt(e)?l.True:l.False}function Tm(e,t){return he(t)?be(e,t):me(t)?Se(e,t):Te(t)?st(e,t):vt(t)||Be(t)?l.True:l.False}function ve(e,t){return Object.getOwnPropertyNames(e.properties).length===t}function na(e){return Vo(e)}function oa(e){return ve(e,0)||ve(e,1)&&"description"in e.properties&&qt(e.properties.description)&&e.properties.description.anyOf.length===2&&(xt(e.properties.description.anyOf[0])&&Nr(e.properties.description.anyOf[1])||xt(e.properties.description.anyOf[1])&&Nr(e.properties.description.anyOf[0]))}function ki(e){return ve(e,0)}function ia(e){return ve(e,0)}function Am(e){return ve(e,0)}function km(e){return ve(e,0)}function Cm(e){return Vo(e)}function Nm(e){let t=et();return ve(e,0)||ve(e,1)&&"length"in e.properties&&it(Y(e.properties.length,t))===l.True}function Sm(e){return ve(e,0)}function Vo(e){let t=et();return ve(e,0)||ve(e,1)&&"length"in e.properties&&it(Y(e.properties.length,t))===l.True}function Mm(e){let t=Nt([sr()],sr());return ve(e,0)||ve(e,1)&&"then"in e.properties&&it(Y(e.properties.then,t))===l.True}function ma(e,t){return Y(e,t)===l.False?l.False:$o(e)&&!$o(t)?l.False:l.True}function Se(e,t){return gt(e)?l.False:yt(e)?l.Union:nr(e)||xs(e)&&na(t)||gs(e)&&ki(t)||Is(e)&&ia(t)||Gn(e)&&oa(t)||Ro(e)&&Am(t)||xt(e)&&na(t)||Gn(e)&&oa(t)||Be(e)&&ki(t)||vt(e)&&ki(t)||kr(e)&&ia(t)||vn(e)&&Cm(t)||Fo(e)&&km(t)||wo(e)&&Sm(t)||Po(e)&&Nm(t)?l.True:Te(e)&&xt(Ci(e))?(()=>t[Ct]==="Record"?l.True:l.False)():Te(e)&&Be(Ci(e))?(()=>ve(t,0)?l.True:l.False)():l.False}function jm(e,t){return he(t)?be(e,t):Te(t)?st(e,t):!me(t)?l.False:(()=>{for(let r of Object.getOwnPropertyNames(t.properties)){if(!(r in e.properties)&&!$o(t.properties[r]))return l.False;if($o(t.properties[r]))return l.True;if(ma(e.properties[r],t.properties[r])===l.False)return l.False}return l.True})()}function Um(e,t){return he(t)?be(e,t):me(t)&&Mm(t)?l.True:!bi(t)?l.False:it(Y(e.item,t.item))}function Ci(e){return or in e.patternProperties?et():(ir in e.patternProperties)?It():mn("Unknown record key pattern")}function Ni(e){return or in e.patternProperties?e.patternProperties[or]:(ir in e.patternProperties)?e.patternProperties[ir]:mn("Unable to get record value schema")}function st(e,t){let[r,n]=[Ci(t),Ni(t)];return xs(e)&&Be(r)&&it(Y(e,n))===l.True?l.True:vn(e)&&Be(r)?Y(e,n):xt(e)&&Be(r)?Y(e,n):Ar(e)&&Be(r)?Y(e,n):me(e)?(()=>{for(let o of Object.getOwnPropertyNames(e.properties))if(ma(n,e.properties[o])===l.False)return l.False;return l.True})():l.False}function Em(e,t){return he(t)?be(e,t):me(t)?Se(e,t):!Te(t)?l.False:Y(Ni(e),Ni(t))}function Km(e,t){let r=Bn(e)?It():e,n=Bn(t)?It():t;return Y(r,n)}function da(e,t){return rr(e)&&Z(e.const)?l.True:xt(e)?l.True:l.False}function Lm(e,t){return he(t)?be(e,t):me(t)?Se(e,t):Te(t)?st(e,t):xt(t)?l.True:l.False}function Bm(e,t){return he(t)?be(e,t):me(t)?Se(e,t):Te(t)?st(e,t):Gn(t)?l.True:l.False}function Gm(e,t){return Dn(e)?Y(Mr(e),t):Dn(t)?Y(e,Mr(t)):mn("Invalid fallthrough for TemplateLiteral")}function Dm(e,t){return Ar(t)&&e.items!==void 0&&e.items.every((r)=>Y(r,t.items)===l.True)}function vm(e,t){return nr(e)?l.True:gt(e)?l.False:yt(e)?l.Union:l.False}function qm(e,t){return he(t)?be(e,t):me(t)&&Vo(t)?l.True:Ar(t)&&Dm(e,t)?l.True:!To(t)?l.False:ee(e.items)&&!ee(t.items)||!ee(e.items)&&ee(t.items)?l.False:ee(e.items)&&!ee(t.items)?l.True:e.items.every((r,n)=>Y(r,t.items[n])===l.True)?l.True:l.False}function Hm(e,t){return he(t)?be(e,t):me(t)?Se(e,t):Te(t)?st(e,t):vn(t)?l.True:l.False}function Vm(e,t){return he(t)?be(e,t):me(t)?Se(e,t):Te(t)?st(e,t):Ao(t)?Jm(e,t):Nr(t)?l.True:l.False}function Mi(e,t){return t.anyOf.some((r)=>Y(e,r)===l.True)?l.True:l.False}function zm(e,t){return e.anyOf.every((r)=>Y(r,t)===l.True)?l.True:l.False}function pa(e,t){return l.True}function Wm(e,t){return nr(t)?ua(e,t):Cr(t)?Ho(e,t):qt(t)?Mi(e,t):yt(t)?Si(e,t):xt(t)?da(e,t):Be(t)?fa(e,t):vt(t)?ca(e,t):kr(t)?aa(e,t):Ar(t)?pm(e,t):To(t)?vm(e,t):me(t)?Se(e,t):gt(t)?l.True:l.False}function Jm(e,t){return Nr(e)?l.True:Nr(e)?l.True:l.False}function Ym(e,t){return Cr(t)?Ho(e,t):qt(t)?Mi(e,t):gt(t)?pa(e,t):yt(t)?Si(e,t):me(t)?Se(e,t):Ao(t)?l.True:l.False}function Y(e,t){return Dn(e)||Dn(t)?Gm(e,t):Bn(e)||Bn(t)?Km(e,t):en(e)||en(t)?Fm(e,t):yt(e)?dm(e,t):Ar(e)?lm(e,t):Ro(e)?xm(e,t):kr(e)?gm(e,t):gi(e)?ym(e,t):wo(e)?Im(e,t):Fo(e)?hm(e,t):Po(e)?bm(e,t):vt(e)?_m(e,t):Cr(e)?Om(e,t):Ii(e)?$m(e,t):rr(e)?Rm(e,t):nr(e)?wm(e,t):hi(e)?Pm(e,t):Be(e)?Tm(e,t):me(e)?jm(e,t):Te(e)?Em(e,t):xt(e)?Lm(e,t):Gn(e)?Bm(e,t):To(e)?qm(e,t):bi(e)?Um(e,t):vn(e)?Hm(e,t):Nr(e)?Vm(e,t):qt(e)?zm(e,t):gt(e)?Wm(e,t):Ao(e)?Ym(e,t):mn(`Unknown left type operand '${e[y]}'`)}function ur(e,t){return Y(e,t)}function Xm(e,t,r,n,o){let i={};for(let s of globalThis.Object.getOwnPropertyNames(e))i[s]=dn(e[s],t,r,n,oe(o));return i}function Qm(e,t,r,n,o){return Xm(e.properties,t,r,n,o)}function la(e,t,r,n,o){let i=Qm(e,t,r,n,o);return v(i)}function Zm(e,t,r,n){let o=ur(e,t);return o===l.Union?z([r,n]):o===l.True?r:n}function dn(e,t,r,n,o){return ie(e)?la(e,t,r,n,o):We(e)?p(ya(e,t,r,n,o)):p(Zm(e,t,r,n),o)}function ed(e,t,r,n,o){return{[e]:dn(V(e),t,r,n,oe(o))}}function td(e,t,r,n,o){return e.reduce((i,s)=>({...i,...ed(s,t,r,n,o)}),{})}function rd(e,t,r,n,o){return td(e.keys,t,r,n,o)}function ya(e,t,r,n,o){let i=rd(e,t,r,n,o);return v(i)}function nd(e){return e.allOf.every((t)=>zt(t))}function od(e){return e.anyOf.some((t)=>zt(t))}function id(e){return!zt(e.not)}function zt(e){return e[y]==="Intersect"?nd(e):e[y]==="Union"?od(e):e[y]==="Not"?id(e):e[y]==="Undefined"?!0:!1}function xa(e,t){return pn(Mr(e),t)}function sd(e,t){let r=e.filter((n)=>ur(n,t)===l.False);return r.length===1?r[0]:z(r)}function pn(e,t,r={}){if(Je(e))return p(xa(e,t),r);if(ie(e))return p(ga(e,t),r);return p(D(e)?sd(e.anyOf,t):ur(e,t)!==l.False?M():e,r)}function ad(e,t){let r={};for(let n of globalThis.Object.getOwnPropertyNames(e))r[n]=pn(e[n],t);return r}function cd(e,t){return ad(e.properties,t)}function ga(e,t){let r=cd(e,t);return v(r)}function Ia(e,t){return ln(Mr(e),t)}function ud(e,t){let r=e.filter((n)=>ur(n,t)!==l.False);return r.length===1?r[0]:z(r)}function ln(e,t,r){if(Je(e))return p(Ia(e,t),r);if(ie(e))return p(ha(e,t),r);return p(D(e)?ud(e.anyOf,t):ur(e,t)!==l.False?e:M(),r)}function fd(e,t){let r={};for(let n of globalThis.Object.getOwnPropertyNames(e))r[n]=ln(e[n],t);return r}function md(e,t){return fd(e.properties,t)}function ha(e,t){let r=md(e,t);return v(r)}function ba(e,t){return mt(e)?p(e.returns,t):M(t)}function zo(e){return De(Ce(e))}function jr(e,t,r){return p({[y]:"Record",type:"object",patternProperties:{[e]:t}},r)}function ji(e,t,r){let n={};for(let o of e)n[o]=t;return J(n,{...r,[Ct]:"Record"})}function dd(e,t,r){return Ss(e)?ji(Ge(e),t,r):jr(e.pattern,t,r)}function pd(e,t,r){return ji(Ge(z(e)),t,r)}function ld(e,t,r){return ji([e.toString()],t,r)}function yd(e,t,r){return jr(e.source,t,r)}function xd(e,t,r){let n=ee(e.pattern)?ir:e.pattern;return jr(n,t,r)}function gd(e,t,r){return jr(ir,t,r)}function Id(e,t,r){return jr(Os,t,r)}function hd(e,t,r){return J({true:t,false:t},r)}function bd(e,t,r){return jr(or,t,r)}function _d(e,t,r){return jr(or,t,r)}function Wo(e,t,r={}){return D(e)?pd(e.anyOf,t,r):Je(e)?dd(e,t,r):ze(e)?ld(e.const,t,r):Lt(e)?hd(e,t,r):pt(e)?bd(e,t,r):lt(e)?_d(e,t,r):li(e)?yd(e,t,r):Bt(e)?xd(e,t,r):di(e)?gd(e,t,r):tr(e)?Id(e,t,r):M(r)}function Jo(e){return globalThis.Object.getOwnPropertyNames(e.patternProperties)[0]}function _a(e){let t=Jo(e);return t===ir?It():t===or?et():It({pattern:t})}function Yo(e){return e.patternProperties[Jo(e)]}function Od(e,t){return t.parameters=Xn(e,t.parameters),t.returns=ht(e,t.returns),t}function $d(e,t){return t.parameters=Xn(e,t.parameters),t.returns=ht(e,t.returns),t}function Rd(e,t){return t.allOf=Xn(e,t.allOf),t}function wd(e,t){return t.anyOf=Xn(e,t.anyOf),t}function Fd(e,t){if(ee(t.items))return t;return t.items=Xn(e,t.items),t}function Pd(e,t){return t.items=ht(e,t.items),t}function Td(e,t){return t.items=ht(e,t.items),t}function Ad(e,t){return t.items=ht(e,t.items),t}function kd(e,t){return t.item=ht(e,t.item),t}function Cd(e,t){let r=jd(e,t.properties);return{...t,...J(r)}}function Nd(e,t){let r=ht(e,_a(t)),n=ht(e,Yo(t)),o=Wo(r,n);return{...t,...o}}function Sd(e,t){return t.index in e?e[t.index]:cr()}function Md(e,t){let r=Zr(t),n=Le(t),o=ht(e,t);return r&&n?zo(o):r&&!n?De(o):!r&&n?Ce(o):o}function jd(e,t){return globalThis.Object.getOwnPropertyNames(t).reduce((r,n)=>({...r,[n]:Md(e,t[n])}),{})}function Xn(e,t){return t.map((r)=>ht(e,r))}function ht(e,t){return mt(t)?Od(e,t):dt(t)?$d(e,t):fe(t)?Rd(e,t):D(t)?wd(e,t):Ye(t)?Fd(e,t):ut(t)?Pd(e,t):Rr(t)?Td(e,t):Fr(t)?Ad(e,t):Pr(t)?kd(e,t):xe(t)?Cd(e,t):Tr(t)?Nd(e,t):pi(t)?Sd(e,t):t}function Oa(e,t){return ht(t,Yr(e))}function $a(e){return p({[y]:"Integer",type:"integer"},e)}function Ud(e,t,r){return{[e]:bt(V(e),t,oe(r))}}function Ed(e,t,r){return e.reduce((o,i)=>({...o,...Ud(i,t,r)}),{})}function Kd(e,t,r){return Ed(e.keys,t,r)}function Ra(e,t,r){let n=Kd(e,t,r);return v(n)}function Ld(e){let[t,r]=[e.slice(0,1),e.slice(1)];return[t.toLowerCase(),r].join("")}function Bd(e){let[t,r]=[e.slice(0,1),e.slice(1)];return[t.toUpperCase(),r].join("")}function Gd(e){return e.toUpperCase()}function Dd(e){return e.toLowerCase()}function vd(e,t,r){let n=sn(e.pattern);if(!Sr(n))return{...e,pattern:wa(e.pattern,t)};let s=[...zn(n)].map((m)=>V(m)),a=Fa(s,t),c=z(a);return jo([c],r)}function wa(e,t){return typeof e==="string"?t==="Uncapitalize"?Ld(e):t==="Capitalize"?Bd(e):t==="Uppercase"?Gd(e):t==="Lowercase"?Dd(e):e:e.toString()}function Fa(e,t){return e.map((r)=>bt(r,t))}function bt(e,t,r={}){return We(e)?Ra(e,t,r):Je(e)?vd(e,t,r):D(e)?z(Fa(e.anyOf,t),r):ze(e)?V(wa(e.const,t),r):p(e,r)}function Pa(e,t={}){return bt(e,"Capitalize",t)}function Ta(e,t={}){return bt(e,"Lowercase",t)}function Aa(e,t={}){return bt(e,"Uncapitalize",t)}function ka(e,t={}){return bt(e,"Uppercase",t)}function qd(e,t,r){let n={};for(let o of globalThis.Object.getOwnPropertyNames(e))n[o]=fr(e[o],t,oe(r));return n}function Hd(e,t,r){return qd(e.properties,t,r)}function Ca(e,t,r){let n=Hd(e,t,r);return v(n)}function Vd(e,t){return e.map((r)=>Ui(r,t))}function zd(e,t){return e.map((r)=>Ui(r,t))}function Wd(e,t){let{[t]:r,...n}=e;return n}function Jd(e,t){return t.reduce((r,n)=>Wd(r,n),e)}function Yd(e,t,r){let n=de(e,[se,"$id","required","properties"]),o=Jd(r,t);return J(o,n)}function Xd(e){let t=e.reduce((r,n)=>Oo(n)?[...r,V(n)]:r,[]);return z(t)}function Ui(e,t){return fe(e)?Ne(Vd(e.allOf,t)):D(e)?z(zd(e.anyOf,t)):xe(e)?Yd(e,t,e.properties):J({})}function fr(e,t,r){let n=ge(t)?Xd(t):t,o=ae(t)?Ge(t):t,i=le(e),s=le(t);return ie(e)?Ca(e,o,r):We(t)?Na(e,t,r):i&&s?re("Omit",[e,n],r):!i&&s?re("Omit",[e,n],r):i&&!s?re("Omit",[e,n],r):p({...Ui(e,o),...r})}function Qd(e,t,r){return{[t]:fr(e,[t],oe(r))}}function Zd(e,t,r){return t.reduce((n,o)=>({...n,...Qd(e,o,r)}),{})}function ep(e,t,r){return Zd(e,t.keys,r)}function Na(e,t,r){let n=ep(e,t,r);return v(n)}function tp(e,t,r){let n={};for(let o of globalThis.Object.getOwnPropertyNames(e))n[o]=mr(e[o],t,oe(r));return n}function rp(e,t,r){return tp(e.properties,t,r)}function Sa(e,t,r){let n=rp(e,t,r);return v(n)}function np(e,t){return e.map((r)=>Ei(r,t))}function op(e,t){return e.map((r)=>Ei(r,t))}function ip(e,t){let r={};for(let n of t)if(n in e)r[n]=e[n];return r}function sp(e,t,r){let n=de(e,[se,"$id","required","properties"]),o=ip(r,t);return J(o,n)}function ap(e){let t=e.reduce((r,n)=>Oo(n)?[...r,V(n)]:r,[]);return z(t)}function Ei(e,t){return fe(e)?Ne(np(e.allOf,t)):D(e)?z(op(e.anyOf,t)):xe(e)?sp(e,t,e.properties):J({})}function mr(e,t,r){let n=ge(t)?ap(t):t,o=ae(t)?Ge(t):t,i=le(e),s=le(t);return ie(e)?Sa(e,o,r):We(t)?Ma(e,t,r):i&&s?re("Pick",[e,n],r):!i&&s?re("Pick",[e,n],r):i&&!s?re("Pick",[e,n],r):p({...Ei(e,o),...r})}function cp(e,t,r){return{[t]:mr(e,[t],oe(r))}}function up(e,t,r){return t.reduce((n,o)=>({...n,...cp(e,o,r)}),{})}function fp(e,t,r){return up(e,t.keys,r)}function Ma(e,t,r){let n=fp(e,t,r);return v(n)}function mp(e,t){return re("Partial",[re(e,t)])}function dp(e){return re("Partial",[nt(e)])}function pp(e){let t={};for(let r of globalThis.Object.getOwnPropertyNames(e))t[r]=Ce(e[r]);return t}function lp(e,t){let r=de(e,[se,"$id","required","properties"]),n=pp(t);return J(n,r)}function ja(e){return e.map((t)=>Ua(t))}function Ua(e){return ft(e)?mp(e.target,e.parameters):le(e)?dp(e.$ref):fe(e)?Ne(ja(e.allOf)):D(e)?z(ja(e.anyOf)):xe(e)?lp(e,e.properties):wr(e)?e:Lt(e)?e:pt(e)?e:ze(e)?e:En(e)?e:lt(e)?e:Bt(e)?e:Kn(e)?e:Gt(e)?e:J({})}function yn(e,t){if(ie(e))return Ea(e,t);else return p({...Ua(e),...t})}function yp(e,t){let r={};for(let n of globalThis.Object.getOwnPropertyNames(e))r[n]=yn(e[n],oe(t));return r}function xp(e,t){return yp(e.properties,t)}function Ea(e,t){let r=xp(e,t);return v(r)}function gp(e,t){return re("Required",[re(e,t)])}function Ip(e){return re("Required",[nt(e)])}function hp(e){let t={};for(let r of globalThis.Object.getOwnPropertyNames(e))t[r]=de(e[r],[Pe]);return t}function bp(e,t){let r=de(e,[se,"$id","required","properties"]),n=hp(t);return J(n,r)}function Ka(e){return e.map((t)=>La(t))}function La(e){return ft(e)?gp(e.target,e.parameters):le(e)?Ip(e.$ref):fe(e)?Ne(Ka(e.allOf)):D(e)?z(Ka(e.anyOf)):xe(e)?bp(e,e.properties):wr(e)?e:Lt(e)?e:pt(e)?e:ze(e)?e:En(e)?e:lt(e)?e:Bt(e)?e:Kn(e)?e:Gt(e)?e:J({})}function xn(e,t){if(ie(e))return Ba(e,t);else return p({...La(e),...t})}function _p(e,t){let r={};for(let n of globalThis.Object.getOwnPropertyNames(e))r[n]=xn(e[n],t);return r}function Op(e,t){return _p(e.properties,t)}function Ba(e,t){let r=Op(e,t);return v(r)}function $p(e,t){return t.map((r)=>le(r)?Ki(e,r.$ref):Xe(e,r))}function Ki(e,t){return t in e?le(e[t])?Ki(e,e[t].$ref):Xe(e,e[t]):M()}function Rp(e){return un(e[0])}function wp(e){return ar(e[0],e[1])}function Fp(e){return fn(e[0])}function Pp(e){return yn(e[0])}function Tp(e){return fr(e[0],e[1])}function Ap(e){return mr(e[0],e[1])}function kp(e){return xn(e[0])}function Cp(e,t,r){let n=$p(e,r);return t==="Awaited"?Rp(n):t==="Index"?wp(n):t==="KeyOf"?Fp(n):t==="Partial"?Pp(n):t==="Omit"?Tp(n):t==="Pick"?Ap(n):t==="Required"?kp(n):M()}function Np(e,t){return tn(Xe(e,t))}function Sp(e,t){return rn(Xe(e,t))}function Mp(e,t,r){return nn(Qn(e,t),Xe(e,r))}function jp(e,t,r){return Nt(Qn(e,t),Xe(e,r))}function Up(e,t){return Ne(Qn(e,t))}function Ep(e,t){return cn(Xe(e,t))}function Kp(e,t){return J(globalThis.Object.keys(t).reduce((r,n)=>({...r,[n]:Xe(e,t[n])}),{}))}function Lp(e,t){let[r,n]=[Xe(e,Yo(t)),Jo(t)],o=Yr(t);return o.patternProperties[n]=r,o}function Bp(e,t){return le(t)?{...Ki(e,t.$ref),[se]:t[se]}:t}function Gp(e,t){return tt(Qn(e,t))}function Dp(e,t){return z(Qn(e,t))}function Qn(e,t){return t.map((r)=>Xe(e,r))}function Xe(e,t){return Le(t)?p(Xe(e,de(t,[Pe])),t):Zr(t)?p(Xe(e,de(t,[kt])),t):q(t)?p(Bp(e,t),t):ut(t)?p(Np(e,t.items),t):Rr(t)?p(Sp(e,t.items),t):ft(t)?p(Cp(e,t.target,t.parameters)):mt(t)?p(Mp(e,t.parameters,t.returns),t):dt(t)?p(jp(e,t.parameters,t.returns),t):fe(t)?p(Up(e,t.allOf),t):Fr(t)?p(Ep(e,t.items),t):xe(t)?p(Kp(e,t.properties),t):Tr(t)?p(Lp(e,t)):Ye(t)?p(Gp(e,t.items||[]),t):D(t)?p(Dp(e,t.anyOf),t):t}function vp(e,t){return t in e?Xe(e,e[t]):M()}function Ga(e){return globalThis.Object.getOwnPropertyNames(e).reduce((t,r)=>({...t,[r]:vp(e,r)}),{})}class Da{constructor(e){let t=Ga(e),r=this.WithIdentifiers(t);this.$defs=r}Import(e,t){let r={...this.$defs,[e]:p(this.$defs[e],t)};return p({[y]:"Import",$defs:r,$ref:e})}WithIdentifiers(e){return globalThis.Object.getOwnPropertyNames(e).reduce((t,r)=>({...t,[r]:{...e[r],$id:r}}),{})}}function va(e){return new Da(e)}function qa(e,t){return p({[y]:"Not",not:e},t)}function Ha(e,t){return dt(e)?tt(e.parameters,t):M()}var qp=0;function Va(e,t={}){if(ee(t.$id))t.$id=`T${qp++}`;let r=Yr(e({[y]:"This",$ref:`${t.$id}`}));return r.$id=t.$id,p({[Ct]:"Recursive",...r},t)}function za(e,t){let r=Z(e)?new globalThis.RegExp(e):e;return p({[y]:"RegExp",type:"RegExp",source:r.source,flags:r.flags},t)}function Hp(e){return fe(e)?e.allOf:D(e)?e.anyOf:Ye(e)?e.items??[]:[]}function Wa(e){return Hp(e)}function Ja(e,t){return dt(e)?p(e.returns,t):M(t)}class Ya{constructor(e){this.schema=e}Decode(e){return new Xa(this.schema,e)}}class Xa{constructor(e,t){this.schema=e,this.decode=t}EncodeTransform(e,t){let o={Encode:(i)=>t[se].Encode(e(i)),Decode:(i)=>this.decode(t[se].Decode(i))};return{...t,[se]:o}}EncodeSchema(e,t){let r={Decode:this.decode,Encode:e};return{...t,[se]:r}}Encode(e){return q(this.schema)?this.EncodeTransform(e,this.schema):this.EncodeSchema(e,this.schema)}}function Qa(e){return new Ya(e)}function Za(e={}){return p({[y]:e[y]??"Unsafe"},e)}function ec(e){return p({[y]:"Void",type:"void"},e)}var Vp=Li;import{join as Jp}from"path";import{readFileSync as Yp}from"fs";Qo();import{join as zp}from"path";async function rc(){let e=zp(process.cwd(),"bare.config.ts");try{let t=await import(e);return Xo(t.default)}catch{return Xo()}}var Zo=(e)=>{if(!e||!e._def)return{type:"object"};let t=e._def,r=t.typeName;if(r==="ZodObject"){let n=typeof t.shape==="function"?t.shape():t.shape,o={},i=[];for(let[s,a]of Object.entries(n||{})){let c=a;if(o[s]=Zo(c),c?._def?.typeName!=="ZodOptional"&&c?._def?.typeName!=="ZodDefault")i.push(s)}return{type:"object",properties:o,...i.length?{required:i}:{}}}if(r==="ZodString")return{type:"string"};if(r==="ZodNumber")return{type:"number"};if(r==="ZodBoolean")return{type:"boolean"};if(r==="ZodArray")return{type:"array",items:Zo(t.type)};if(r==="ZodOptional"||r==="ZodDefault")return Zo(t.innerType);if(r==="ZodEnum")return{type:"string",enum:t.values};return{type:"object"}},Wp=(e)=>{if(!e)return{type:"object"};if("_def"in e)return Zo(e);return JSON.parse(JSON.stringify(e))},Gi=(e,t={})=>{let r={};for(let n of e){if(n.path==="/docs"||n.path==="/docs/json")continue;let o=("/"+n.path).replace(/\/+/g,"/").replace(/:([a-zA-Z0-9_]+)/g,"{$1}");if(!r[o])r[o]={};let i=n.method.toLowerCase(),s=[],a=n.path.matchAll(/:([a-zA-Z0-9_]+)/g);for(let m of a)s.push({name:m[1],in:"path",required:!0,schema:{type:"string"}});let c=void 0;for(let m of n.handlers)if(m&&m.__schema){c={required:!0,content:{"application/json":{schema:Wp(m.__schema)}}};break}r[o][i]={summary:`${n.method} ${o}`,...s.length?{parameters:s}:{},...c?{requestBody:c}:{},responses:{"200":{description:"Success"}}}}return{openapi:"3.1.0",info:{title:t.title||"BareJS API",version:t.version||"1.0.0",...t.description?{description:t.description}:{}},paths:r}},Di=(e,t="BareJS API Docs")=>{let r=t.replace(/[<>&"]/g,""),n=JSON.stringify(e);return`<!doctype html>
|
|
64
|
+
`,t.encode(i)},n=new ReadableStream({async start(s){try{if(typeof e==="function"){let i=!1,a=(u,m,l)=>{if(!i)s.enqueue(r({data:u,event:m,id:l}))},c=()=>{if(!i)i=!0,s.close()};await e(a,c),c()}else{for await(let i of e)s.enqueue(r(i));s.close()}}catch(i){s.error(i)}}}),o={"content-type":"text/event-stream; charset=utf-8","cache-control":"no-cache, no-transform",connection:"keep-alive",...this._headers||{}};return new Response(n,{status:this._status||200,headers:o})}get requestId(){if(this._requestId!==void 0)return this._requestId;let e=this.req?.headers?.get("x-request-id");return this._requestId=e&&e.length>0&&e.length<=128?e:crypto.randomUUID(),this._requestId}get ip(){if(this._trustProxy){let e=this.req?.headers?.get("x-forwarded-for");if(e)return e.split(",")[0].trim();let t=this.req?.headers?.get("x-real-ip")||this.req?.headers?.get("cf-connecting-ip");if(t)return t}return this._peerIp||"127.0.0.1"}async upload(e={}){let t=e.maxFileSize??5242880,r=e.maxFiles??10,n=e.allowedTypes?new Set(e.allowedTypes):null;if(!(this.req?.headers?.get("content-type")||"").includes("multipart/form-data"))throw Object.assign(Error("Expected multipart/form-data"),{status:400});if(Number(this.req?.headers?.get("content-length")||0)>t*r+65536)throw Object.assign(Error("Payload Too Large"),{status:413});let i=await this.req.formData(),a={},c=[];for(let[u,m]of i.entries()){if(typeof m==="string"){if(u!=="__proto__"&&u!=="constructor"&&u!=="prototype")a[u]=m;continue}let l=m;if(c.length>=r)throw Object.assign(Error(`Too many files (max ${r})`),{status:413});if(l.size>t)throw Object.assign(Error(`File exceeds max size of ${t} bytes`),{status:413});let x=(l.type||"").split(";")[0].trim().toLowerCase();if(n&&!n.has(x))throw Object.assign(Error(`Unsupported file type: ${l.type||"unknown"}`),{status:415});let b=l.name||"file",C=(b.split(/[\\/]/).pop()||"file").replace(/[^a-zA-Z0-9._-]/g,"_").replace(/^\.+/,"")||"file";c.push({fieldName:u,filename:b,safeName:C,type:l.type,size:l.size,file:l})}return{fields:a,files:c}}}function qn(e,t){return t===void 0?me(e):me({...t,...e})}function cc(e){return y({[h]:"Argument",index:e})}function Ny(e,t){return de("Awaited",[de(e,t)])}function My(e){return de("Awaited",[bt(e)])}function jy(e){return Ve(uc(e))}function Ey(e){return ee(uc(e))}function Uy(e){return Gn(e)}function uc(e){return e.map((t)=>Gn(t))}function Gn(e,t){return y(Ct(e)?Ny(e.target,e.parameters):_e(e)?jy(e.allOf):V(e)?Ey(e.anyOf):vr(e)?Uy(e.item):we(e)?My(e.$ref):e,t)}function Ly(e){let t=[];for(let r of e)t.push(..._t(r));return Zi(t)}function Ky(e){return e.filter((t)=>!xr(t))}function By(e,t){let r=[];for(let n of e)r.push(...oo(n,[t]));return Ky(r)}function Dy(e,t){let r={};for(let n of t)r[n]=Do(By(e,n));return r}function dc(e,t){let r=Ly(e),n=Dy(e,r);return re(n,t)}function us(e){return y({[h]:"Date",type:"Date"},e)}function ds(e){return y({[h]:"Null",type:"null"},e)}function fs(e){return y({[h]:"Symbol",type:"symbol"},e)}function ms(e){return y({[h]:"Undefined",type:"undefined"},e)}function ps(e){return y({[h]:"Uint8Array",type:"Uint8Array"},e)}function vy(e){return e.map((t)=>ai(t,!1))}function qy(e){let t={};for(let r of globalThis.Object.getOwnPropertyNames(e))t[r]=ot(ai(e[r],!1));return t}function ls(e,t){return t===!0?e:ot(e)}function ai(e,t){return ki(e)?ls(Or(),t):Ai(e)?ls(Or(),t):Ae(e)?ot(xt(vy(e))):hr(e)?ps():fn(e)?us():fe(e)?ls(re(qy(e)),t):Ci(e)?ls(Wt([],wr()),t):ue(e)?ms():Fi(e)?ds():Ti(e)?fs():Uo(e)?xn():dt(e)?X(e):gr(e)?X(e):ce(e)?X(e):re({})}function fc(e,t){return y(ai(e,!0),t)}function mc(e,t){return At(e)?xt(e.parameters,t):L(t)}function pc(e,t){if(ue(e))throw Error("Enum undefined or empty");let r=globalThis.Object.getOwnPropertyNames(e).filter((s)=>isNaN(s)).map((s)=>e[s]),o=[...new Set(r)].map((s)=>X(s));return ee(o,{...t,[zt]:"Enum"})}function lc(e,t){return Hn(Hr(e),t)}function Gy(e,t){let r=e.filter((n)=>Cr(n,t)===g.False);return r.length===1?r[0]:ee(r)}function Hn(e,t,r={}){if(pt(e))return y(lc(e,t),r);if(pe(e))return y(yc(e,t),r);return y(V(e)?Gy(e.anyOf,t):Cr(e,t)!==g.False?L():e,r)}function Hy(e,t){let r={};for(let n of globalThis.Object.getOwnPropertyNames(e))r[n]=Hn(e[n],t);return r}function Vy(e,t){return Hy(e.properties,t)}function yc(e,t){let r=Vy(e,t);return z(r)}function gc(e,t){return Vn(Hr(e),t)}function zy(e,t){let r=e.filter((n)=>Cr(n,t)!==g.False);return r.length===1?r[0]:ee(r)}function Vn(e,t,r){if(pt(e))return y(gc(e,t),r);if(pe(e))return y(hc(e,t),r);return y(V(e)?zy(e.anyOf,t):Cr(e,t)!==g.False?e:L(),r)}function Wy(e,t){let r={};for(let n of globalThis.Object.getOwnPropertyNames(e))r[n]=Vn(e[n],t);return r}function Jy(e,t){return Wy(e.properties,t)}function hc(e,t){let r=Jy(e,t);return z(r)}function xc(e,t){return At(e)?y(e.returns,t):L(t)}function ys(e){return ot(He(e))}function on(e,t,r){return y({[h]:"Record",type:"object",patternProperties:{[e]:t}},r)}function ci(e,t,r){let n={};for(let o of e)n[o]=t;return re(n,{...r,[zt]:"Record"})}function Yy(e,t,r){return Ui(e)?ci(nt(e),t,r):on(e.pattern,t,r)}function Xy(e,t,r){return ci(nt(ee(e)),t,r)}function Qy(e,t,r){return ci([e.toString()],t,r)}function Zy(e,t,r){return on(e.source,t,r)}function eg(e,t,r){let n=ue(e.pattern)?br:e.pattern;return on(n,t,r)}function tg(e,t,r){return on(br,t,r)}function rg(e,t,r){return on(qi,t,r)}function ng(e,t,r){return re({true:t,false:t},r)}function og(e,t,r){return on(Ir,t,r)}function sg(e,t,r){return on(Ir,t,r)}function gs(e,t,r={}){return V(e)?Xy(e.anyOf,t,r):pt(e)?Yy(e,t,r):ft(e)?Qy(e.const,t,r):tr(e)?ng(e,t,r):Tt(e)?og(e,t,r):Pt(e)?sg(e,t,r):Ss(e)?Zy(e,t,r):rr(e)?eg(e,t,r):Ts(e)?tg(e,t,r):xr(e)?rg(e,t,r):L(r)}function hs(e){return globalThis.Object.getOwnPropertyNames(e.patternProperties)[0]}function Ic(e){let t=hs(e);return t===br?St():t===Ir?ht():St({pattern:t})}function xs(e){return e.patternProperties[hs(e)]}function ig(e,t){return t.parameters=Ro(e,t.parameters),t.returns=qt(e,t.returns),t}function ag(e,t){return t.parameters=Ro(e,t.parameters),t.returns=qt(e,t.returns),t}function cg(e,t){return t.allOf=Ro(e,t.allOf),t}function ug(e,t){return t.anyOf=Ro(e,t.anyOf),t}function dg(e,t){if(ue(t.items))return t;return t.items=Ro(e,t.items),t}function fg(e,t){return t.items=qt(e,t.items),t}function mg(e,t){return t.items=qt(e,t.items),t}function pg(e,t){return t.items=qt(e,t.items),t}function lg(e,t){return t.item=qt(e,t.item),t}function yg(e,t){let r=Ig(e,t.properties);return{...t,...re(r)}}function gg(e,t){let r=qt(e,Ic(t)),n=qt(e,xs(t)),o=gs(r,n);return{...t,...o}}function hg(e,t){return t.index in e?e[t.index]:wr()}function xg(e,t){let r=yn(t),n=rt(t),o=qt(e,t);return r&&n?ys(o):r&&!n?ot(o):!r&&n?He(o):o}function Ig(e,t){return globalThis.Object.getOwnPropertyNames(t).reduce((r,n)=>({...r,[n]:xg(e,t[n])}),{})}function Ro(e,t){return t.map((r)=>qt(e,r))}function qt(e,t){return At(t)?ig(e,t):Ft(t)?ag(e,t):_e(t)?cg(e,t):V(t)?ug(e,t):lt(t)?dg(e,t):kt(t)?fg(e,t):Kr(t)?mg(e,t):Dr(t)?pg(e,t):vr(t)?lg(e,t):ke(t)?yg(e,t):qr(t)?gg(e,t):Ps(t)?hg(e,t):t}function bc(e,t){return qt(t,qn(e))}function _c(e){return y({[h]:"Integer",type:"integer"},e)}function bg(e,t,r){return{[e]:Gt(X(e),t,me(r))}}function _g(e,t,r){return e.reduce((o,s)=>({...o,...bg(s,t,r)}),{})}function Rg(e,t,r){return _g(e.keys,t,r)}function Rc(e,t,r){let n=Rg(e,t,r);return z(n)}function Og(e){let[t,r]=[e.slice(0,1),e.slice(1)];return[t.toLowerCase(),r].join("")}function wg(e){let[t,r]=[e.slice(0,1),e.slice(1)];return[t.toUpperCase(),r].join("")}function $g(e){return e.toUpperCase()}function kg(e){return e.toLowerCase()}function Cg(e,t,r){let n=hn(e.pattern);if(!Gr(n))return{...e,pattern:Oc(e.pattern,t)};let i=[...no(n)].map((u)=>X(u)),a=wc(i,t),c=ee(a);return Ho([c],r)}function Oc(e,t){return typeof e==="string"?t==="Uncapitalize"?Og(e):t==="Capitalize"?wg(e):t==="Uppercase"?$g(e):t==="Lowercase"?kg(e):e:e.toString()}function wc(e,t){return e.map((r)=>Gt(r,t))}function Gt(e,t,r={}){return mt(e)?Rc(e,t,r):pt(e)?Cg(e,t,r):V(e)?ee(wc(e.anyOf,t),r):ft(e)?X(Oc(e.const,t),r):y(e,r)}function $c(e,t={}){return Gt(e,"Capitalize",t)}function kc(e,t={}){return Gt(e,"Lowercase",t)}function Cc(e,t={}){return Gt(e,"Uncapitalize",t)}function Ac(e,t={}){return Gt(e,"Uppercase",t)}function Ag(e,t,r){let n={};for(let o of globalThis.Object.getOwnPropertyNames(e))n[o]=Nr(e[o],t,me(r));return n}function Fg(e,t,r){return Ag(e.properties,t,r)}function Fc(e,t,r){let n=Fg(e,t,r);return z(n)}function Tg(e,t){return e.map((r)=>ui(r,t))}function Pg(e,t){return e.map((r)=>ui(r,t))}function Sg(e,t){let{[t]:r,...n}=e;return n}function Ng(e,t){return t.reduce((r,n)=>Sg(r,n),e)}function Mg(e,t,r){let n=be(e,[ge,"$id","required","properties"]),o=Ng(r,t);return re(o,n)}function jg(e){let t=e.reduce((r,n)=>Bo(n)?[...r,X(n)]:r,[]);return ee(t)}function ui(e,t){return _e(e)?Ve(Tg(e.allOf,t)):V(e)?ee(Pg(e.anyOf,t)):ke(e)?Mg(e,t,e.properties):re({})}function Nr(e,t,r){let n=Ae(t)?jg(t):t,o=he(t)?nt(t):t,s=we(e),i=we(t);return pe(e)?Fc(e,o,r):mt(t)?Tc(e,t,r):s&&i?de("Omit",[e,n],r):!s&&i?de("Omit",[e,n],r):s&&!i?de("Omit",[e,n],r):y({...ui(e,o),...r})}function Eg(e,t,r){return{[t]:Nr(e,[t],me(r))}}function Ug(e,t,r){return t.reduce((n,o)=>({...n,...Eg(e,o,r)}),{})}function Lg(e,t,r){return Ug(e,t.keys,r)}function Tc(e,t,r){let n=Lg(e,t,r);return z(n)}function Kg(e,t,r){let n={};for(let o of globalThis.Object.getOwnPropertyNames(e))n[o]=Mr(e[o],t,me(r));return n}function Bg(e,t,r){return Kg(e.properties,t,r)}function Pc(e,t,r){let n=Bg(e,t,r);return z(n)}function Dg(e,t){return e.map((r)=>di(r,t))}function vg(e,t){return e.map((r)=>di(r,t))}function qg(e,t){let r={};for(let n of t)if(n in e)r[n]=e[n];return r}function Gg(e,t,r){let n=be(e,[ge,"$id","required","properties"]),o=qg(r,t);return re(o,n)}function Hg(e){let t=e.reduce((r,n)=>Bo(n)?[...r,X(n)]:r,[]);return ee(t)}function di(e,t){return _e(e)?Ve(Dg(e.allOf,t)):V(e)?ee(vg(e.anyOf,t)):ke(e)?Gg(e,t,e.properties):re({})}function Mr(e,t,r){let n=Ae(t)?Hg(t):t,o=he(t)?nt(t):t,s=we(e),i=we(t);return pe(e)?Pc(e,o,r):mt(t)?Sc(e,t,r):s&&i?de("Pick",[e,n],r):!s&&i?de("Pick",[e,n],r):s&&!i?de("Pick",[e,n],r):y({...di(e,o),...r})}function Vg(e,t,r){return{[t]:Mr(e,[t],me(r))}}function zg(e,t,r){return t.reduce((n,o)=>({...n,...Vg(e,o,r)}),{})}function Wg(e,t,r){return zg(e,t.keys,r)}function Sc(e,t,r){let n=Wg(e,t,r);return z(n)}function Jg(e,t){return de("Partial",[de(e,t)])}function Yg(e){return de("Partial",[bt(e)])}function Xg(e){let t={};for(let r of globalThis.Object.getOwnPropertyNames(e))t[r]=He(e[r]);return t}function Qg(e,t){let r=be(e,[ge,"$id","required","properties"]),n=Xg(t);return re(n,r)}function Nc(e){return e.map((t)=>Mc(t))}function Mc(e){return Ct(e)?Jg(e.target,e.parameters):we(e)?Yg(e.$ref):_e(e)?Ve(Nc(e.allOf)):V(e)?ee(Nc(e.anyOf)):ke(e)?Qg(e,e.properties):Br(e)?e:tr(e)?e:Tt(e)?e:ft(e)?e:Qn(e)?e:Pt(e)?e:rr(e)?e:Zn(e)?e:nr(e)?e:re({})}function zn(e,t){if(pe(e))return jc(e,t);else return y({...Mc(e),...t})}function Zg(e,t){let r={};for(let n of globalThis.Object.getOwnPropertyNames(e))r[n]=zn(e[n],me(t));return r}function eh(e,t){return Zg(e.properties,t)}function jc(e,t){let r=eh(e,t);return z(r)}function th(e,t){return de("Required",[de(e,t)])}function rh(e){return de("Required",[bt(e)])}function nh(e){let t={};for(let r of globalThis.Object.getOwnPropertyNames(e))t[r]=be(e[r],[Be]);return t}function oh(e,t){let r=be(e,[ge,"$id","required","properties"]),n=nh(t);return re(n,r)}function Ec(e){return e.map((t)=>Uc(t))}function Uc(e){return Ct(e)?th(e.target,e.parameters):we(e)?rh(e.$ref):_e(e)?Ve(Ec(e.allOf)):V(e)?ee(Ec(e.anyOf)):ke(e)?oh(e,e.properties):Br(e)?e:tr(e)?e:Tt(e)?e:ft(e)?e:Qn(e)?e:Pt(e)?e:rr(e)?e:Zn(e)?e:nr(e)?e:re({})}function Wn(e,t){if(pe(e))return Lc(e,t);else return y({...Uc(e),...t})}function sh(e,t){let r={};for(let n of globalThis.Object.getOwnPropertyNames(e))r[n]=Wn(e[n],t);return r}function ih(e,t){return sh(e.properties,t)}function Lc(e,t){let r=ih(e,t);return z(r)}function ah(e,t){return t.map((r)=>we(r)?fi(e,r.$ref):gt(e,r))}function fi(e,t){return t in e?we(e[t])?fi(e,e[t].$ref):gt(e,e[t]):L()}function ch(e){return Gn(e[0])}function uh(e){return _r(e[0],e[1])}function dh(e){return bn(e[0])}function fh(e){return zn(e[0])}function mh(e){return Nr(e[0],e[1])}function ph(e){return Mr(e[0],e[1])}function lh(e){return Wn(e[0])}function yh(e,t,r){let n=ah(e,r);return t==="Awaited"?ch(n):t==="Index"?uh(n):t==="KeyOf"?dh(n):t==="Partial"?fh(n):t==="Omit"?mh(n):t==="Pick"?ph(n):t==="Required"?lh(n):L()}function gh(e,t){return mn(gt(e,t))}function hh(e,t){return pn(gt(e,t))}function xh(e,t,r){return ln(Oo(e,t),gt(e,r))}function Ih(e,t,r){return Wt(Oo(e,t),gt(e,r))}function bh(e,t){return Ve(Oo(e,t))}function _h(e,t){return In(gt(e,t))}function Rh(e,t){return re(globalThis.Object.keys(t).reduce((r,n)=>({...r,[n]:gt(e,t[n])}),{}))}function Oh(e,t){let[r,n]=[gt(e,xs(t)),hs(t)],o=qn(t);return o.patternProperties[n]=r,o}function wh(e,t){return we(t)?{...fi(e,t.$ref),[ge]:t[ge]}:t}function $h(e,t){return xt(Oo(e,t))}function kh(e,t){return ee(Oo(e,t))}function Oo(e,t){return t.map((r)=>gt(e,r))}function gt(e,t){return rt(t)?y(gt(e,be(t,[Be])),t):yn(t)?y(gt(e,be(t,[Vt])),t):J(t)?y(wh(e,t),t):kt(t)?y(gh(e,t.items),t):Kr(t)?y(hh(e,t.items),t):Ct(t)?y(yh(e,t.target,t.parameters)):At(t)?y(xh(e,t.parameters,t.returns),t):Ft(t)?y(Ih(e,t.parameters,t.returns),t):_e(t)?y(bh(e,t.allOf),t):Dr(t)?y(_h(e,t.items),t):ke(t)?y(Rh(e,t.properties),t):qr(t)?y(Oh(e,t)):lt(t)?y($h(e,t.items||[]),t):V(t)?y(kh(e,t.anyOf),t):t}function Ch(e,t){return t in e?gt(e,e[t]):L()}function Kc(e){return globalThis.Object.getOwnPropertyNames(e).reduce((t,r)=>({...t,[r]:Ch(e,r)}),{})}class Bc{constructor(e){let t=Kc(e),r=this.WithIdentifiers(t);this.$defs=r}Import(e,t){let r={...this.$defs,[e]:y(this.$defs[e],t)};return y({[h]:"Import",$defs:r,$ref:e})}WithIdentifiers(e){return globalThis.Object.getOwnPropertyNames(e).reduce((t,r)=>({...t,[r]:{...e[r],$id:r}}),{})}}function Dc(e){return new Bc(e)}function vc(e,t){return y({[h]:"Not",not:e},t)}function qc(e,t){return Ft(e)?xt(e.parameters,t):L()}var Ah=0;function Gc(e,t={}){if(ue(t.$id))t.$id=`T${Ah++}`;let r=qn(e({[h]:"This",$ref:`${t.$id}`}));return r.$id=t.$id,y({[zt]:"Recursive",...r},t)}function Hc(e,t){let r=ce(e)?new globalThis.RegExp(e):e;return y({[h]:"RegExp",type:"RegExp",source:r.source,flags:r.flags},t)}function Fh(e){return _e(e)?e.allOf:V(e)?e.anyOf:lt(e)?e.items??[]:[]}function Vc(e){return Fh(e)}function zc(e,t){return Ft(e)?y(e.returns,t):L(t)}class Wc{constructor(e){this.schema=e}Decode(e){return new Jc(this.schema,e)}}class Jc{constructor(e,t){this.schema=e,this.decode=t}EncodeTransform(e,t){let o={Encode:(s)=>t[ge].Encode(e(s)),Decode:(s)=>this.decode(t[ge].Decode(s))};return{...t,[ge]:o}}EncodeSchema(e,t){let r={Decode:this.decode,Encode:e};return{...t,[ge]:r}}Encode(e){return J(this.schema)?this.EncodeTransform(e,this.schema):this.EncodeSchema(e,this.schema)}}function Yc(e){return new Wc(e)}function Xc(e){return y({[h]:"Void",type:"void"},e)}var Th=mi;import{join as Sh}from"path";import{readFileSync as Nh}from"fs";bs();import{join as Ph}from"path";async function Zc(){let e=Ph(process.cwd(),"bare.config.ts");try{let t=await import(e);return Is(t.default)}catch{return Is()}}var _s=(e)=>{if(!e||!e._def)return{type:"object"};let t=e._def,r=t.typeName;if(r==="ZodObject"){let n=typeof t.shape==="function"?t.shape():t.shape,o={},s=[];for(let[i,a]of Object.entries(n||{})){let c=a;if(o[i]=_s(c),c?._def?.typeName!=="ZodOptional"&&c?._def?.typeName!=="ZodDefault")s.push(i)}return{type:"object",properties:o,...s.length?{required:s}:{}}}if(r==="ZodString")return{type:"string"};if(r==="ZodNumber")return{type:"number"};if(r==="ZodBoolean")return{type:"boolean"};if(r==="ZodArray")return{type:"array",items:_s(t.type)};if(r==="ZodOptional"||r==="ZodDefault")return _s(t.innerType);if(r==="ZodEnum")return{type:"string",enum:t.values};return{type:"object"}},wo=(e)=>{if(!e)return{type:"object"};if("_def"in e)return _s(e);return JSON.parse(JSON.stringify(e))},li=(e,t={})=>{let r={};for(let n of e){if(n.path==="/docs"||n.path==="/docs/json")continue;let o=("/"+n.path).replace(/\/+/g,"/").replace(/:([a-zA-Z0-9_]+)/g,"{$1}");if(!r[o])r[o]={};let s=n.method.toLowerCase(),i=[],a=void 0,c=void 0,u=void 0,m=null;for(let x of n.handlers){if(!x)continue;let b=x.__routeSchemas;if(b){if(b.detail)u=b.detail;if(b.params)m=wo(b.params);if(b.query){let T=wo(b.query),C=new Set(T.required||[]);for(let[Q,le]of Object.entries(T.properties||{}))i.push({name:Q,in:"query",required:C.has(Q),schema:le})}if(b.headers){let T=wo(b.headers),C=new Set(T.required||[]);for(let[Q,le]of Object.entries(T.properties||{}))i.push({name:Q,in:"header",required:C.has(Q),schema:le})}if(b.response)c=wo(b.response)}if(x.__schema&&!a)a={required:!0,content:{"application/json":{schema:wo(x.__schema)}}}}let l=n.path.matchAll(/:([a-zA-Z0-9_]+)/g);for(let x of l){let b=x[1],T=m?.properties?.[b]||{type:"string"};i.unshift({name:b,in:"path",required:!0,schema:T})}r[o][s]={summary:u?.summary||`${n.method} ${o}`,...u?.description?{description:u.description}:{},...u?.tags?{tags:u.tags}:{},...i.length?{parameters:i}:{},...a?{requestBody:a}:{},responses:{"200":{description:"Success",...c?{content:{"application/json":{schema:c}}}:{}}}}}return{openapi:"3.1.0",info:{title:t.title||"BareJS API",version:t.version||"1.0.0",...t.description?{description:t.description}:{}},...t.servers?.length?{servers:t.servers}:{},...t.tags?.length?{tags:t.tags}:{},...t.securitySchemes?{components:{securitySchemes:t.securitySchemes}}:{},...t.security?.length?{security:t.security}:{},paths:r}},yi=(e,t="BareJS API Docs")=>{let r=t.replace(/[<>&"]/g,""),n=JSON.stringify(e);return`<!doctype html>
|
|
36
65
|
<html>
|
|
37
66
|
<head>
|
|
38
67
|
<title>${r}</title>
|
|
@@ -43,68 +72,111 @@ var{defineProperty:fi,getOwnPropertyNames:Zc,getOwnPropertyDescriptor:eu}=Object
|
|
|
43
72
|
<script id="api-reference" data-url=${n}></script>
|
|
44
73
|
<script src="https://cdn.jsdelivr.net/npm/@scalar/api-reference"></script>
|
|
45
74
|
</body>
|
|
46
|
-
</html>`};class
|
|
75
|
+
</html>`};class eu extends vn{tree=new nn;pool=[];hotFetch;compiled=!1;poolMask;_useLog=!1;errorHandler;wsRoutes=new Map;startHooks=[];stopHooks=[];crons=[];server;shutdownHandler;wsAdapter={open(e){e.data?.open?.(e)},message(e,t){e.data?.message?.(e,t)},close(e,t,r){e.data?.close?.(e,t,r)},drain(e){e.data?.drain?.(e)}};useLog(e=!0){return this._useLog=e,this}onStart(e){return this.startHooks.push(e),this}onStop(e){return this.stopHooks.push(e),this}cron(e,t,r,n={}){let o=!1,s=async()=>{if(o)return;o=!0;try{await r()}catch(a){n.onError?.(a)}finally{o=!1}},i=setInterval(s,t);if(this.crons.push({name:e,timer:i}),n.runOnStart)s();return this}async stop(e=!1){for(let t of this.crons)clearInterval(t.timer);if(this.crons.length=0,this.shutdownHandler)process.off("SIGINT",this.shutdownHandler),process.off("SIGTERM",this.shutdownHandler),this.shutdownHandler=void 0;if(this.server)this.server.stop(e),this.server=void 0;for(let t of this.stopHooks)await t()}constructor(e=1024){super();Zc();let t=Math.pow(2,Math.ceil(Math.log2(e)));this.poolMask=t-1;for(let r=0;r<t;r++)this.pool.push(new _o);try{let r=Sh(process.cwd(),"package.json"),n=JSON.parse(Nh(r,"utf-8"));if(n.name)this.name=n.name.split(/[-_]/).map((o)=>o.charAt(0).toUpperCase()+o.slice(1)).join(" ")}catch{this.name="App"}}notFoundHandler=()=>({status:404,message:"Route not found"});setNotFound(e){this.notFoundHandler=e}onError(e){return this.errorHandler=e,this}ws(e,t){let r=("/"+e).replace(/\/+/g,"/").replace(/\/$/,"")||"/";return this.wsRoutes.set(r,t),this}docs(e="/docs",t={}){let r=("/"+e).replace(/\/+/g,"/").replace(/\/$/,"")||"/docs",n=`${r}/json`,o=null,s=yi(n,t.title||`${this.name} API Docs`);return this.get(n,()=>{if(!o)o=JSON.stringify(li(this.routes,{title:this.name,...t}));return new Response(o,{status:200,headers:{"content-type":"application/json"}})}),this.get(r,()=>new Response(s,{status:200,headers:{"content-type":"text/html; charset=utf-8"}})),this}rpc(e,t){let r=async(n,o)=>{if(!n||n.jsonrpc!=="2.0"||typeof n.method!=="string")return{jsonrpc:"2.0",error:{code:-32600,message:"Invalid Request"},id:n?.id??null};let s=Object.hasOwn(t,n.method)?t[n.method]:void 0;if(!s)return{jsonrpc:"2.0",error:{code:-32601,message:"Method not found"},id:n.id??null};try{let i=await s(n.params,o);if(n.id===void 0)return null;return{jsonrpc:"2.0",result:i,id:n.id}}catch(i){return{jsonrpc:"2.0",error:{code:-32603,message:i?.message||"Internal error"},id:n.id??null}}};return this.post(e,async(n)=>{let o=await n.jsonBody();if(!o)return n.status(400).json({jsonrpc:"2.0",error:{code:-32700,message:"Parse error"},id:null});if(Array.isArray(o)){if(o.length===0)return n.status(400).json({jsonrpc:"2.0",error:{code:-32600,message:"Invalid Request"},id:null});let i=(await Promise.all(o.map((a)=>r(a,n)))).filter(Boolean);return i.length>0?i:new Response(null,{status:204})}let s=await r(o,n);return s===null?new Response(null,{status:204}):s}),this}_hasDerive=!1;derive(e){return this._hasDerive=!0,this.use(async(t,r)=>{let n=await e(t);if(n&&typeof n==="object"){let o=Object.keys(n);if(!t._derivedKeys)t._derivedKeys=[];for(let s=0;s<o.length;s++){let i=o[s];if(i!=="__proto__"&&i!=="constructor"&&i!=="prototype")t[i]=n[i],t._derivedKeys.push(i)}}return r()}),this}compileHandler(e,t){let r=e.find((A)=>A?.__timeout);if(r){let{ms:A,status:Z,message:Qe}=r.__timeout,te=e.filter((Se)=>!Se?.__timeout),U=this.compileHandler(te,t);return async(Se,ct)=>{let Ze=U(Se,ct);if(!Ze||!Ze.then)return Ze;let Zt;try{let sn=new Promise((ws)=>{Zt=setTimeout(()=>{ws(Response.json({status:"error",code:"REQUEST_TIMEOUT",message:Qe},{status:Z}))},A)});return await Promise.race([Ze,sn])}finally{if(Zt!==void 0)clearTimeout(Zt)}}}let n=e.find((A)=>A?.__circuitBreaker);if(n){let A=n.__circuitBreaker,Z=e.filter((te)=>!te?.__circuitBreaker),Qe=this.compileHandler(Z,t);return(te,U)=>A(()=>Qe(te,U))}let o=e.find((A)=>A?.__compress);if(o){let A=o.__compress,Z=e.filter((te)=>!te?.__compress),Qe=this.compileHandler(Z,t);return async(te,U)=>{let Se=await Qe(te,U);return A(te,Se)}}let s=e.length,a=e.find((A)=>A?.__responseFilter)?.__responseFilter,c=e.find((A)=>A?.__idempotencyCommit),u=c?.__idempotencyCommit,m=c?.__idempotencyRelease,l={status:200,headers:{"content-type":"application/json"}},x={status:200,headers:{"content-type":"text/plain"}},C=`
|
|
76
|
+
${a?"res = rFilter(res);":""}
|
|
47
77
|
if (res instanceof Response) {
|
|
78
|
+
${m?"idemRelease(ctx);":""}
|
|
79
|
+
if (ctx._headers) {
|
|
80
|
+
for (const k in ctx._headers) {
|
|
81
|
+
if (!res.headers.has(k)) res.headers.set(k, ctx._headers[k]);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
if (ctx._setCookies) {
|
|
85
|
+
for (let i = 0; i < ctx._setCookies.length; i++) res.headers.append('Set-Cookie', ctx._setCookies[i]);
|
|
86
|
+
}
|
|
48
87
|
${t?"doLog(res.status);":""}
|
|
49
88
|
return res;
|
|
50
89
|
}
|
|
51
90
|
|
|
52
91
|
const finalStatus = ctx._status || 200;
|
|
92
|
+
${u?"idemCommit(ctx, res, finalStatus);":""}
|
|
53
93
|
${t?"doLog(finalStatus);":""}
|
|
54
94
|
|
|
95
|
+
let outRes;
|
|
55
96
|
if (typeof res === 'string') {
|
|
56
|
-
if (finalStatus === 200 && !ctx._headers)
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
97
|
+
if (finalStatus === 200 && !ctx._headers) {
|
|
98
|
+
outRes = new Response(res, text200);
|
|
99
|
+
} else {
|
|
100
|
+
outRes = new Response(res, {
|
|
101
|
+
status: finalStatus,
|
|
102
|
+
headers: ctx._headers || text200.headers
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
} else if (finalStatus === 200 && !ctx._headers) {
|
|
106
|
+
outRes = Response.json(res ?? null, json200);
|
|
107
|
+
} else {
|
|
108
|
+
outRes = Response.json(res ?? null, {
|
|
60
109
|
status: finalStatus,
|
|
61
|
-
headers:
|
|
110
|
+
headers: ctx._headers || json200.headers
|
|
62
111
|
});
|
|
63
112
|
}
|
|
64
|
-
|
|
65
|
-
if (
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
return
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
`,
|
|
78
|
-
`,
|
|
79
|
-
`,
|
|
80
|
-
`,
|
|
81
|
-
`;
|
|
82
|
-
let res = fn${
|
|
113
|
+
|
|
114
|
+
if (ctx._setCookies) {
|
|
115
|
+
for (let i = 0; i < ctx._setCookies.length; i++) outRes.headers.append('Set-Cookie', ctx._setCookies[i]);
|
|
116
|
+
}
|
|
117
|
+
return outRes;
|
|
118
|
+
`,Q=t?"ctx, doLog":"ctx",le=[...a?["rFilter"]:[],...u?["idemCommit"]:[],...m?["idemRelease"]:[]],q=[...a?[a]:[],...u?[u]:[],...m?[m]:[]],Ge=(A)=>{if(!m)return A;return(Z,Qe)=>{try{let te=A(Z,Qe);if(te&&typeof te.then==="function")return te.then((U)=>U,(U)=>{throw m(Z),U});return te}catch(te){throw m(Z),te}}};if(s===1){let A=e[0];if(A.constructor.name==="AsyncFunction")return Ge(Function("fn0","json200","text200",...le,`return async function(${Q}) {
|
|
119
|
+
const res = await fn0(ctx);
|
|
120
|
+
${C}
|
|
121
|
+
}`)(A,l,x,...q));return Ge(Function("fn0","json200","text200",...le,`return function(${Q}) {
|
|
122
|
+
const res = fn0(ctx);
|
|
123
|
+
if (res && res.then) return res.then(v => { const res = v; ${C} });
|
|
124
|
+
${C}
|
|
125
|
+
}`)(A,l,x,...q))}let ye=e.some((A)=>A.constructor.name==="AsyncFunction"),W="",Me=e.map((A,Z)=>`fn${Z}`);if(ye){for(let A=0;A<s-1;A++)W+=`let r${A} = fn${A}(ctx, noop);
|
|
126
|
+
`,W+=`if (r${A}) {
|
|
127
|
+
`,W+=` if (r${A}.then) r${A} = await r${A};
|
|
128
|
+
`,W+=` if (r${A} instanceof Response) { ${t?"doLog(r"+A+".status);":""} return r${A}; }
|
|
129
|
+
`,W+=`}
|
|
130
|
+
`;W+=`
|
|
131
|
+
let res = fn${s-1}(ctx);
|
|
83
132
|
if (res && res.then) res = await res;
|
|
84
|
-
${
|
|
85
|
-
`}else{for(let
|
|
86
|
-
`,
|
|
87
|
-
`;
|
|
88
|
-
|
|
89
|
-
if (res && res.then) return res.then(v => {
|
|
90
|
-
${
|
|
91
|
-
`}let
|
|
133
|
+
${C}
|
|
134
|
+
`}else{for(let A=0;A<s-1;A++)W+=`const r${A} = fn${A}(ctx, noop);
|
|
135
|
+
`,W+=`if (r${A} && r${A} instanceof Response) { ${t?"doLog(r"+A+".status);":""} return r${A}; }
|
|
136
|
+
`;W+=`
|
|
137
|
+
let res = fn${s-1}(ctx);
|
|
138
|
+
if (res && res.then) return res.then(v => { let res = v; ${C} });
|
|
139
|
+
${C}
|
|
140
|
+
`}let $e=()=>{},Pe=ye?`return async function(${Q})`:`return function(${Q})`;return Ge(Function(...Me,"noop","json200","text200",...le,`${Pe} { ${W} }`)(...e,$e,l,x,...q))}compile(){let e=this._useLog;this.tree=new nn;for(let U of this.routes)this.tree.insert(U.path,U.method,this.compileHandler(U.handlers,e));let t=this.tree,r=this.pool,n=r.length,o=this.notFoundHandler,s=this.errorHandler,i=(U,Se)=>{if(s){let ct=s(U,Se);if(ct instanceof Response)return ct;let Ze=Se._status>=400?Se._status:500;if(typeof ct==="string")return new Response(ct,{status:Ze});return Response.json(ct??null,{status:Ze})}if(U?.status>=400&&U?.status<500)return Response.json({status:U.status,message:U.message||"Bad Request"},{status:U.status});return Response.json({status:500,message:U?.message||"Internal Server Error",stack:U?.stack},{status:500})},a=[],c=(U)=>{let Se=`h${a.length}`;return a.push(U),Se},u=t.jitCompile(c),m=Object.freeze({}),l=a.map((U,Se)=>`h${Se}`),x=this.routes.some((U)=>U.handlers.some((Se)=>Se?.__idempotencyCommit)),C=`
|
|
92
141
|
if (ctx.store.size > 0) ctx.store.clear();
|
|
142
|
+
${this._hasDerive?"if (ctx._derivedKeys) { for (let i = 0; i < ctx._derivedKeys.length; i++) delete ctx[ctx._derivedKeys[i]]; ctx._derivedKeys = undefined; }":""}
|
|
143
|
+
${x?"if (ctx._idempotencyKey) { ctx._idemInFlight.delete(ctx._idempotencyKey); ctx._idempotencyKey = undefined; ctx._idemInFlight = undefined; }":""}
|
|
93
144
|
ctx.req = undefined;
|
|
145
|
+
ctx._status = 200;
|
|
94
146
|
ctx.body = undefined;
|
|
95
147
|
ctx._query = undefined;
|
|
148
|
+
ctx._cookies = undefined;
|
|
149
|
+
ctx._setCookies = undefined;
|
|
96
150
|
ctx._headers = undefined;
|
|
151
|
+
ctx._requestId = undefined;
|
|
97
152
|
ctx.params = EMPTY_PARAMS;
|
|
98
153
|
if (poolTop < maxPool) pool[poolTop++] = ctx;
|
|
99
|
-
`,
|
|
100
|
-
if (out && out.then) return out.then((v) => { ${
|
|
101
|
-
${
|
|
102
|
-
return out;`),
|
|
103
|
-
out = hOptions${
|
|
104
|
-
if (out && out.then) return out.then((v) => { ${
|
|
105
|
-
${
|
|
154
|
+
`,Q=e?"(ctx, doLog)":"(ctx)",le=u.replace(/return (h\d+)\(ctx\);/g,`out = $1${Q};
|
|
155
|
+
if (out && out.then) return out.then((v) => { ${C} return v; }, (e) => { const errRes = hError(e, ctx); ${C} ${e?"doLog(errRes.status || 500);":""} return errRes; });
|
|
156
|
+
${C}
|
|
157
|
+
return out;`),q=this.groupMiddleware.length>0,Ge=q?this.compileHandler(this.groupMiddleware,e):void 0,ye=q?`if (method === 'OPTIONS') {
|
|
158
|
+
out = hOptions${Q};
|
|
159
|
+
if (out && out.then) return out.then((v) => { ${C} return v; }, (e) => { const errRes = hError(e, ctx); ${C} ${e?"doLog(errRes.status || 500);":""} return errRes; });
|
|
160
|
+
${C}
|
|
106
161
|
return out;
|
|
107
|
-
}`:"",
|
|
162
|
+
}`:"",W=this.groupMiddleware.filter((U)=>U.__isStatic),Me=W.length>0,$e=Me?async(U)=>{let Se=()=>{};for(let ct=0;ct<W.length;ct++){let Ze=await W[ct](U,Se);if(Ze instanceof Response){if(U._headers)for(let Zt in U._headers){let sn=U._headers[Zt];if(sn!==void 0&&!Ze.headers.has(Zt))Ze.headers.set(Zt,sn)}return Ze}}return}:void 0,Pe=Me?`if (method === 'GET' || method === 'HEAD') {
|
|
163
|
+
out = runStatic(ctx);
|
|
164
|
+
if (out && out.then) {
|
|
165
|
+
return out.then((v) => {
|
|
166
|
+
if (v instanceof Response) { ${e?"doLog(v.status);":""} ${C} return v; }
|
|
167
|
+
const errorBody = hNotFound();
|
|
168
|
+
const status = errorBody.status || 404;
|
|
169
|
+
${e?"doLog(status);":""}
|
|
170
|
+
${C}
|
|
171
|
+
return Response.json(errorBody, { status });
|
|
172
|
+
}, (e) => {
|
|
173
|
+
const errRes = hError(e, ctx);
|
|
174
|
+
${C}
|
|
175
|
+
${e?"doLog(errRes.status || 500);":""}
|
|
176
|
+
return errRes;
|
|
177
|
+
});
|
|
178
|
+
}
|
|
179
|
+
}`:"",A=["pool","maxPool","Context","hNotFound","hError","EMPTY_PARAMS",...q?["hOptions"]:[],...Me?["runStatic"]:[],...l],Z=[r,n,_o,o,i,m,...q?[Ge]:[],...Me?[$e]:[],...a],te=`
|
|
108
180
|
let poolTop = maxPool;
|
|
109
181
|
return function(req) {
|
|
110
182
|
const url = req.url;
|
|
@@ -121,31 +193,27 @@ var{defineProperty:fi,getOwnPropertyNames:Zc,getOwnPropertyDescriptor:eu}=Object
|
|
|
121
193
|
|
|
122
194
|
try {
|
|
123
195
|
ctx.req = req;
|
|
124
|
-
ctx._status = 200;
|
|
125
|
-
ctx._headers = undefined;
|
|
126
|
-
if (ctx.store.size > 0) ctx.store.clear();
|
|
127
|
-
ctx.params = EMPTY_PARAMS;
|
|
128
|
-
ctx.body = undefined;
|
|
129
|
-
ctx._query = undefined;
|
|
130
196
|
|
|
131
|
-
${
|
|
197
|
+
${le}
|
|
198
|
+
|
|
199
|
+
${ye}
|
|
132
200
|
|
|
133
|
-
${
|
|
201
|
+
${Pe}
|
|
134
202
|
|
|
135
203
|
const errorBody = hNotFound();
|
|
136
204
|
const status = errorBody.status || 404;
|
|
137
205
|
${e?"doLog(status);":""}
|
|
138
|
-
${
|
|
206
|
+
${C}
|
|
139
207
|
return Response.json(errorBody, { status });
|
|
140
208
|
|
|
141
209
|
} catch (e) {
|
|
142
210
|
const errRes = hError(e, ctx);
|
|
143
211
|
${e?"doLog(errRes.status || 500);":""}
|
|
144
|
-
${
|
|
212
|
+
${C}
|
|
145
213
|
return errRes;
|
|
146
214
|
}
|
|
147
215
|
}
|
|
148
|
-
`;this.hotFetch=Function(...
|
|
216
|
+
`;this.hotFetch=Function(...A,te)(...Z),this.compiled=!0,this.fetch=this.hotFetch}fetch=(e)=>{if(!this.compiled)return this.compile(),this.hotFetch(e);return this.hotFetch(e)};name="App";trustProxy(e=!0){for(let t=0;t<this.pool.length;t++)this.pool[t]._trustProxy=e;return this}listen(e,t="0.0.0.0",r=!0,n={}){if(!this.compiled)this.compile();if(n.trustProxy!==void 0)this.trustProxy(n.trustProxy);let o=n.maxRequestBodySize??10485760,{BARE_CONFIG:s}=(bs(),lu(Qc)),i=e||s.port||3000;if(!0)console.log(`
|
|
149
217
|
\x1B[33m ____ _ _____ \x1B[0m
|
|
150
218
|
\x1B[33m | __ ) __ _ _ __ ___ | | ____|\x1B[0m
|
|
151
219
|
\x1B[33m | _ \\ / _\` | '__/ _ \\ _ | | _| \x1B[0m
|
|
@@ -153,14 +221,9 @@ var{defineProperty:fi,getOwnPropertyNames:Zc,getOwnPropertyDescriptor:eu}=Object
|
|
|
153
221
|
\x1B[33m |____/ \\__,_|_| \\___| \\___/|_____|\x1B[0m
|
|
154
222
|
|
|
155
223
|
\x1B[32m\uD83D\uDE80 ${this.name} is running in development mode\x1B[0m
|
|
156
|
-
\x1B[90m\u2699\uFE0F Pool Size: ${this.pool.length} | JIT: Enabled | Port: ${
|
|
157
|
-
\x1B[36m\uD83D\uDEE1\uFE0F Hash: ${
|
|
158
|
-
`);let
|
|
159
|
-
\x1B[31m${
|
|
160
|
-
`),
|
|
161
|
-
`)}process.exit(0)};return process.on("SIGINT",x),process.on("SIGTERM",x),m}}function Xp(e){switch(e.errorType){case d.ArrayContains:return"Expected array to contain at least one matching value";case d.ArrayMaxContains:return`Expected array to contain no more than ${e.schema.maxContains} matching values`;case d.ArrayMinContains:return`Expected array to contain at least ${e.schema.minContains} matching values`;case d.ArrayMaxItems:return`Expected array length to be less or equal to ${e.schema.maxItems}`;case d.ArrayMinItems:return`Expected array length to be greater or equal to ${e.schema.minItems}`;case d.ArrayUniqueItems:return"Expected array elements to be unique";case d.Array:return"Expected array";case d.AsyncIterator:return"Expected AsyncIterator";case d.BigIntExclusiveMaximum:return`Expected bigint to be less than ${e.schema.exclusiveMaximum}`;case d.BigIntExclusiveMinimum:return`Expected bigint to be greater than ${e.schema.exclusiveMinimum}`;case d.BigIntMaximum:return`Expected bigint to be less or equal to ${e.schema.maximum}`;case d.BigIntMinimum:return`Expected bigint to be greater or equal to ${e.schema.minimum}`;case d.BigIntMultipleOf:return`Expected bigint to be a multiple of ${e.schema.multipleOf}`;case d.BigInt:return"Expected bigint";case d.Boolean:return"Expected boolean";case d.DateExclusiveMinimumTimestamp:return`Expected Date timestamp to be greater than ${e.schema.exclusiveMinimumTimestamp}`;case d.DateExclusiveMaximumTimestamp:return`Expected Date timestamp to be less than ${e.schema.exclusiveMaximumTimestamp}`;case d.DateMinimumTimestamp:return`Expected Date timestamp to be greater or equal to ${e.schema.minimumTimestamp}`;case d.DateMaximumTimestamp:return`Expected Date timestamp to be less or equal to ${e.schema.maximumTimestamp}`;case d.DateMultipleOfTimestamp:return`Expected Date timestamp to be a multiple of ${e.schema.multipleOfTimestamp}`;case d.Date:return"Expected Date";case d.Function:return"Expected function";case d.IntegerExclusiveMaximum:return`Expected integer to be less than ${e.schema.exclusiveMaximum}`;case d.IntegerExclusiveMinimum:return`Expected integer to be greater than ${e.schema.exclusiveMinimum}`;case d.IntegerMaximum:return`Expected integer to be less or equal to ${e.schema.maximum}`;case d.IntegerMinimum:return`Expected integer to be greater or equal to ${e.schema.minimum}`;case d.IntegerMultipleOf:return`Expected integer to be a multiple of ${e.schema.multipleOf}`;case d.Integer:return"Expected integer";case d.IntersectUnevaluatedProperties:return"Unexpected property";case d.Intersect:return"Expected all values to match";case d.Iterator:return"Expected Iterator";case d.Literal:return`Expected ${typeof e.schema.const==="string"?`'${e.schema.const}'`:e.schema.const}`;case d.Never:return"Never";case d.Not:return"Value should not match";case d.Null:return"Expected null";case d.NumberExclusiveMaximum:return`Expected number to be less than ${e.schema.exclusiveMaximum}`;case d.NumberExclusiveMinimum:return`Expected number to be greater than ${e.schema.exclusiveMinimum}`;case d.NumberMaximum:return`Expected number to be less or equal to ${e.schema.maximum}`;case d.NumberMinimum:return`Expected number to be greater or equal to ${e.schema.minimum}`;case d.NumberMultipleOf:return`Expected number to be a multiple of ${e.schema.multipleOf}`;case d.Number:return"Expected number";case d.Object:return"Expected object";case d.ObjectAdditionalProperties:return"Unexpected property";case d.ObjectMaxProperties:return`Expected object to have no more than ${e.schema.maxProperties} properties`;case d.ObjectMinProperties:return`Expected object to have at least ${e.schema.minProperties} properties`;case d.ObjectRequiredProperty:return"Expected required property";case d.Promise:return"Expected Promise";case d.RegExp:return"Expected string to match regular expression";case d.StringFormatUnknown:return`Unknown format '${e.schema.format}'`;case d.StringFormat:return`Expected string to match '${e.schema.format}' format`;case d.StringMaxLength:return`Expected string length less or equal to ${e.schema.maxLength}`;case d.StringMinLength:return`Expected string length greater or equal to ${e.schema.minLength}`;case d.StringPattern:return`Expected string to match '${e.schema.pattern}'`;case d.String:return"Expected string";case d.Symbol:return"Expected symbol";case d.TupleLength:return`Expected tuple to have ${e.schema.maxItems||0} elements`;case d.Tuple:return"Expected tuple";case d.Uint8ArrayMaxByteLength:return`Expected byte length less or equal to ${e.schema.maxByteLength}`;case d.Uint8ArrayMinByteLength:return`Expected byte length greater or equal to ${e.schema.minByteLength}`;case d.Uint8Array:return"Expected Uint8Array";case d.Undefined:return"Expected undefined";case d.Union:return"Expected union value";case d.Void:return"Expected void";case d.Kind:return`Expected kind '${e.schema[y]}'`;default:return"Unknown error type"}}var Qp=Xp;function oc(){return Qp}class ic extends H{constructor(e){super(`Unable to dereference schema with $id '${e.$ref}'`);this.schema=e}}function Zp(e,t){let r=t.find((n)=>n.$id===e.$ref);if(r===void 0)throw new ic(e);return $e(r,t)}function dr(e,t){if(!Oe(e.$id)||t.some((r)=>r.$id===e.$id))return t;return t.push(e),t}function $e(e,t){return e[y]==="This"||e[y]==="Ref"?Zp(e,t):e}class sc extends H{constructor(e){super("Unable to hash value");this.value=e}}var Qe;(function(e){e[e.Undefined=0]="Undefined",e[e.Null=1]="Null",e[e.Boolean=2]="Boolean",e[e.Number=3]="Number",e[e.String=4]="String",e[e.Object=5]="Object",e[e.Array=6]="Array",e[e.Date=7]="Date",e[e.Uint8Array=8]="Uint8Array",e[e.Symbol=9]="Symbol",e[e.BigInt=10]="BigInt"})(Qe||(Qe={}));var In=BigInt("14695981039346656037"),[el,tl]=[BigInt("1099511628211"),BigInt("18446744073709551616")],rl=Array.from({length:256}).map((e,t)=>BigInt(t)),ac=new Float64Array(1),cc=new DataView(ac.buffer),uc=new Uint8Array(ac.buffer);function*nl(e){let t=e===0?1:Math.ceil(Math.floor(Math.log2(e)+1)/8);for(let r=0;r<t;r++)yield e>>8*(t-1-r)&255}function ol(e){Me(Qe.Array);for(let t of e)hn(t)}function il(e){Me(Qe.Boolean),Me(e?1:0)}function sl(e){Me(Qe.BigInt),cc.setBigInt64(0,e);for(let t of uc)Me(t)}function al(e){Me(Qe.Date),hn(e.getTime())}function cl(e){Me(Qe.Null)}function ul(e){Me(Qe.Number),cc.setFloat64(0,e);for(let t of uc)Me(t)}function fl(e){Me(Qe.Object);for(let t of globalThis.Object.getOwnPropertyNames(e).sort())hn(t),hn(e[t])}function ml(e){Me(Qe.String);for(let t=0;t<e.length;t++)for(let r of nl(e.charCodeAt(t)))Me(r)}function dl(e){Me(Qe.Symbol),hn(e.description)}function pl(e){Me(Qe.Uint8Array);for(let t=0;t<e.length;t++)Me(e[t])}function ll(e){return Me(Qe.Undefined)}function hn(e){if(Ie(e))return ol(e);if(Or(e))return il(e);if(Ve(e))return sl(e);if(Xr(e))return al(e);if(_r(e))return cl(e);if(N(e))return ul(e);if(Ke(e))return fl(e);if(Oe(e))return ml(e);if($r(e))return dl(e);if(Qr(e))return pl(e);if(Ue(e))return ll(e);throw new sc(e)}function Me(e){In=In^rl[e],In=In*el%tl}function bn(e){return In=BigInt("14695981039346656037"),hn(e),In}class fc extends H{constructor(e){super("Unknown type");this.schema=e}}function yl(e){return e[y]==="Any"||e[y]==="Unknown"}function E(e){return e!==void 0}function xl(e,t,r){return!0}function gl(e,t,r){return!0}function Il(e,t,r){if(!Ie(r))return!1;if(E(e.minItems)&&!(r.length>=e.minItems))return!1;if(E(e.maxItems)&&!(r.length<=e.maxItems))return!1;if(!r.every((i)=>Re(e.items,t,i)))return!1;if(e.uniqueItems===!0&&!function(){let i=new Set;for(let s of r){let a=bn(s);if(i.has(a))return!1;else i.add(a)}return!0}())return!1;if(!(E(e.contains)||N(e.minContains)||N(e.maxContains)))return!0;let n=E(e.contains)?e.contains:M(),o=r.reduce((i,s)=>Re(n,t,s)?i+1:i,0);if(o===0)return!1;if(N(e.minContains)&&o<e.minContains)return!1;if(N(e.maxContains)&&o>e.maxContains)return!1;return!0}function hl(e,t,r){return yo(r)}function bl(e,t,r){if(!Ve(r))return!1;if(E(e.exclusiveMaximum)&&!(r<e.exclusiveMaximum))return!1;if(E(e.exclusiveMinimum)&&!(r>e.exclusiveMinimum))return!1;if(E(e.maximum)&&!(r<=e.maximum))return!1;if(E(e.minimum)&&!(r>=e.minimum))return!1;if(E(e.multipleOf)&&r%e.multipleOf!==BigInt(0))return!1;return!0}function _l(e,t,r){return Or(r)}function Ol(e,t,r){return Re(e.returns,t,r.prototype)}function $l(e,t,r){if(!Xr(r))return!1;if(E(e.exclusiveMaximumTimestamp)&&!(r.getTime()<e.exclusiveMaximumTimestamp))return!1;if(E(e.exclusiveMinimumTimestamp)&&!(r.getTime()>e.exclusiveMinimumTimestamp))return!1;if(E(e.maximumTimestamp)&&!(r.getTime()<=e.maximumTimestamp))return!1;if(E(e.minimumTimestamp)&&!(r.getTime()>=e.minimumTimestamp))return!1;if(E(e.multipleOfTimestamp)&&r.getTime()%e.multipleOfTimestamp!==0)return!1;return!0}function Rl(e,t,r){return bo(r)}function wl(e,t,r){let n=globalThis.Object.values(e.$defs),o=e.$defs[e.$ref];return Re(o,[...t,...n],r)}function Fl(e,t,r){if(!ho(r))return!1;if(E(e.exclusiveMaximum)&&!(r<e.exclusiveMaximum))return!1;if(E(e.exclusiveMinimum)&&!(r>e.exclusiveMinimum))return!1;if(E(e.maximum)&&!(r<=e.maximum))return!1;if(E(e.minimum)&&!(r>=e.minimum))return!1;if(E(e.multipleOf)&&r%e.multipleOf!==0)return!1;return!0}function Pl(e,t,r){let n=e.allOf.every((o)=>Re(o,t,r));if(e.unevaluatedProperties===!1){let o=new RegExp(Vt(e)),i=Object.getOwnPropertyNames(r).every((s)=>o.test(s));return n&&i}else if(ae(e.unevaluatedProperties)){let o=new RegExp(Vt(e)),i=Object.getOwnPropertyNames(r).every((s)=>o.test(s)||Re(e.unevaluatedProperties,t,r[s]));return n&&i}else return n}function Tl(e,t,r){return xo(r)}function Al(e,t,r){return r===e.const}function kl(e,t,r){return!1}function Cl(e,t,r){return!Re(e.not,t,r)}function Nl(e,t,r){return _r(r)}function Sl(e,t,r){if(!te.IsNumberLike(r))return!1;if(E(e.exclusiveMaximum)&&!(r<e.exclusiveMaximum))return!1;if(E(e.exclusiveMinimum)&&!(r>e.exclusiveMinimum))return!1;if(E(e.minimum)&&!(r>=e.minimum))return!1;if(E(e.maximum)&&!(r<=e.maximum))return!1;if(E(e.multipleOf)&&r%e.multipleOf!==0)return!1;return!0}function Ml(e,t,r){if(!te.IsObjectLike(r))return!1;if(E(e.minProperties)&&!(Object.getOwnPropertyNames(r).length>=e.minProperties))return!1;if(E(e.maxProperties)&&!(Object.getOwnPropertyNames(r).length<=e.maxProperties))return!1;let n=Object.getOwnPropertyNames(e.properties);for(let o of n){let i=e.properties[o];if(e.required&&e.required.includes(o)){if(!Re(i,t,r[o]))return!1;if((zt(i)||yl(i))&&!(o in r))return!1}else if(te.IsExactOptionalProperty(r,o)&&!Re(i,t,r[o]))return!1}if(e.additionalProperties===!1){let o=Object.getOwnPropertyNames(r);if(e.required&&e.required.length===n.length&&o.length===n.length)return!0;else return o.every((i)=>n.includes(i))}else if(typeof e.additionalProperties==="object")return Object.getOwnPropertyNames(r).every((i)=>n.includes(i)||Re(e.additionalProperties,t,r[i]));else return!0}function jl(e,t,r){return go(r)}function Ul(e,t,r){if(!te.IsRecordLike(r))return!1;if(E(e.minProperties)&&!(Object.getOwnPropertyNames(r).length>=e.minProperties))return!1;if(E(e.maxProperties)&&!(Object.getOwnPropertyNames(r).length<=e.maxProperties))return!1;let[n,o]=Object.entries(e.patternProperties)[0],i=new RegExp(n),s=Object.entries(r).every(([m,x])=>i.test(m)?Re(o,t,x):!0),a=typeof e.additionalProperties==="object"?Object.entries(r).every(([m,x])=>!i.test(m)?Re(e.additionalProperties,t,x):!0):!0,c=e.additionalProperties===!1?Object.getOwnPropertyNames(r).every((m)=>i.test(m)):!0;return s&&a&&c}function El(e,t,r){return Re($e(e,t),t,r)}function Kl(e,t,r){let n=new RegExp(e.source,e.flags);if(E(e.minLength)){if(!(r.length>=e.minLength))return!1}if(E(e.maxLength)){if(!(r.length<=e.maxLength))return!1}return n.test(r)}function Ll(e,t,r){if(!Oe(r))return!1;if(E(e.minLength)){if(!(r.length>=e.minLength))return!1}if(E(e.maxLength)){if(!(r.length<=e.maxLength))return!1}if(E(e.pattern)){if(!new RegExp(e.pattern).test(r))return!1}if(E(e.format)){if(!_i(e.format))return!1;return Oi(e.format)(r)}return!0}function Bl(e,t,r){return $r(r)}function Gl(e,t,r){return Oe(r)&&new RegExp(e.pattern).test(r)}function Dl(e,t,r){return Re($e(e,t),t,r)}function vl(e,t,r){if(!Ie(r))return!1;if(e.items===void 0&&r.length!==0)return!1;if(r.length!==e.maxItems)return!1;if(!e.items)return!0;for(let n=0;n<e.items.length;n++)if(!Re(e.items[n],t,r[n]))return!1;return!0}function ql(e,t,r){return Ue(r)}function Hl(e,t,r){return e.anyOf.some((n)=>Re(n,t,r))}function Vl(e,t,r){if(!Qr(r))return!1;if(E(e.maxByteLength)&&!(r.length<=e.maxByteLength))return!1;if(E(e.minByteLength)&&!(r.length>=e.minByteLength))return!1;return!0}function zl(e,t,r){return!0}function Wl(e,t,r){return te.IsVoidLike(r)}function Jl(e,t,r){if(!qn(e[y]))return!1;return $i(e[y])(e,r)}function Re(e,t,r){let n=E(e.$id)?dr(e,t):t,o=e;switch(o[y]){case"Any":return xl(o,n,r);case"Argument":return gl(o,n,r);case"Array":return Il(o,n,r);case"AsyncIterator":return hl(o,n,r);case"BigInt":return bl(o,n,r);case"Boolean":return _l(o,n,r);case"Constructor":return Ol(o,n,r);case"Date":return $l(o,n,r);case"Function":return Rl(o,n,r);case"Import":return wl(o,n,r);case"Integer":return Fl(o,n,r);case"Intersect":return Pl(o,n,r);case"Iterator":return Tl(o,n,r);case"Literal":return Al(o,n,r);case"Never":return kl(o,n,r);case"Not":return Cl(o,n,r);case"Null":return Nl(o,n,r);case"Number":return Sl(o,n,r);case"Object":return Ml(o,n,r);case"Promise":return jl(o,n,r);case"Record":return Ul(o,n,r);case"Ref":return El(o,n,r);case"RegExp":return Kl(o,n,r);case"String":return Ll(o,n,r);case"Symbol":return Bl(o,n,r);case"TemplateLiteral":return Gl(o,n,r);case"This":return Dl(o,n,r);case"Tuple":return vl(o,n,r);case"Undefined":return ql(o,n,r);case"Union":return Hl(o,n,r);case"Uint8Array":return Vl(o,n,r);case"Unknown":return zl(o,n,r);case"Void":return Wl(o,n,r);default:if(!qn(o[y]))throw new fc(o);return Jl(o,n,r)}}function Ur(...e){return e.length===3?Re(e[0],e[1],e[2]):Re(e[0],[],e[1])}var d;(function(e){e[e.ArrayContains=0]="ArrayContains",e[e.ArrayMaxContains=1]="ArrayMaxContains",e[e.ArrayMaxItems=2]="ArrayMaxItems",e[e.ArrayMinContains=3]="ArrayMinContains",e[e.ArrayMinItems=4]="ArrayMinItems",e[e.ArrayUniqueItems=5]="ArrayUniqueItems",e[e.Array=6]="Array",e[e.AsyncIterator=7]="AsyncIterator",e[e.BigIntExclusiveMaximum=8]="BigIntExclusiveMaximum",e[e.BigIntExclusiveMinimum=9]="BigIntExclusiveMinimum",e[e.BigIntMaximum=10]="BigIntMaximum",e[e.BigIntMinimum=11]="BigIntMinimum",e[e.BigIntMultipleOf=12]="BigIntMultipleOf",e[e.BigInt=13]="BigInt",e[e.Boolean=14]="Boolean",e[e.DateExclusiveMaximumTimestamp=15]="DateExclusiveMaximumTimestamp",e[e.DateExclusiveMinimumTimestamp=16]="DateExclusiveMinimumTimestamp",e[e.DateMaximumTimestamp=17]="DateMaximumTimestamp",e[e.DateMinimumTimestamp=18]="DateMinimumTimestamp",e[e.DateMultipleOfTimestamp=19]="DateMultipleOfTimestamp",e[e.Date=20]="Date",e[e.Function=21]="Function",e[e.IntegerExclusiveMaximum=22]="IntegerExclusiveMaximum",e[e.IntegerExclusiveMinimum=23]="IntegerExclusiveMinimum",e[e.IntegerMaximum=24]="IntegerMaximum",e[e.IntegerMinimum=25]="IntegerMinimum",e[e.IntegerMultipleOf=26]="IntegerMultipleOf",e[e.Integer=27]="Integer",e[e.IntersectUnevaluatedProperties=28]="IntersectUnevaluatedProperties",e[e.Intersect=29]="Intersect",e[e.Iterator=30]="Iterator",e[e.Kind=31]="Kind",e[e.Literal=32]="Literal",e[e.Never=33]="Never",e[e.Not=34]="Not",e[e.Null=35]="Null",e[e.NumberExclusiveMaximum=36]="NumberExclusiveMaximum",e[e.NumberExclusiveMinimum=37]="NumberExclusiveMinimum",e[e.NumberMaximum=38]="NumberMaximum",e[e.NumberMinimum=39]="NumberMinimum",e[e.NumberMultipleOf=40]="NumberMultipleOf",e[e.Number=41]="Number",e[e.ObjectAdditionalProperties=42]="ObjectAdditionalProperties",e[e.ObjectMaxProperties=43]="ObjectMaxProperties",e[e.ObjectMinProperties=44]="ObjectMinProperties",e[e.ObjectRequiredProperty=45]="ObjectRequiredProperty",e[e.Object=46]="Object",e[e.Promise=47]="Promise",e[e.RegExp=48]="RegExp",e[e.StringFormatUnknown=49]="StringFormatUnknown",e[e.StringFormat=50]="StringFormat",e[e.StringMaxLength=51]="StringMaxLength",e[e.StringMinLength=52]="StringMinLength",e[e.StringPattern=53]="StringPattern",e[e.String=54]="String",e[e.Symbol=55]="Symbol",e[e.TupleLength=56]="TupleLength",e[e.Tuple=57]="Tuple",e[e.Uint8ArrayMaxByteLength=58]="Uint8ArrayMaxByteLength",e[e.Uint8ArrayMinByteLength=59]="Uint8ArrayMinByteLength",e[e.Uint8Array=60]="Uint8Array",e[e.Undefined=61]="Undefined",e[e.Union=62]="Union",e[e.Void=63]="Void"})(d||(d={}));class mc extends H{constructor(e){super("Unknown type");this.schema=e}}function Wt(e){return e.replace(/~/g,"~0").replace(/\//g,"~1")}function K(e){return e!==void 0}class vi{constructor(e){this.iterator=e}[Symbol.iterator](){return this.iterator}First(){let e=this.iterator.next();return e.done?void 0:e.value}}function b(e,t,r,n,o=[]){return{type:e,schema:t,path:r,value:n,message:oc()({errorType:e,path:r,schema:t,value:n,errors:o}),errors:o}}function*Yl(e,t,r,n){}function*Xl(e,t,r,n){}function*Ql(e,t,r,n){if(!Ie(n))return yield b(d.Array,e,r,n);if(K(e.minItems)&&!(n.length>=e.minItems))yield b(d.ArrayMinItems,e,r,n);if(K(e.maxItems)&&!(n.length<=e.maxItems))yield b(d.ArrayMaxItems,e,r,n);for(let s=0;s<n.length;s++)yield*we(e.items,t,`${r}/${s}`,n[s]);if(e.uniqueItems===!0&&!function(){let s=new Set;for(let a of n){let c=bn(a);if(s.has(c))return!1;else s.add(c)}return!0}())yield b(d.ArrayUniqueItems,e,r,n);if(!(K(e.contains)||K(e.minContains)||K(e.maxContains)))return;let o=K(e.contains)?e.contains:M(),i=n.reduce((s,a,c)=>we(o,t,`${r}${c}`,a).next().done===!0?s+1:s,0);if(i===0)yield b(d.ArrayContains,e,r,n);if(N(e.minContains)&&i<e.minContains)yield b(d.ArrayMinContains,e,r,n);if(N(e.maxContains)&&i>e.maxContains)yield b(d.ArrayMaxContains,e,r,n)}function*Zl(e,t,r,n){if(!yo(n))yield b(d.AsyncIterator,e,r,n)}function*ey(e,t,r,n){if(!Ve(n))return yield b(d.BigInt,e,r,n);if(K(e.exclusiveMaximum)&&!(n<e.exclusiveMaximum))yield b(d.BigIntExclusiveMaximum,e,r,n);if(K(e.exclusiveMinimum)&&!(n>e.exclusiveMinimum))yield b(d.BigIntExclusiveMinimum,e,r,n);if(K(e.maximum)&&!(n<=e.maximum))yield b(d.BigIntMaximum,e,r,n);if(K(e.minimum)&&!(n>=e.minimum))yield b(d.BigIntMinimum,e,r,n);if(K(e.multipleOf)&&n%e.multipleOf!==BigInt(0))yield b(d.BigIntMultipleOf,e,r,n)}function*ty(e,t,r,n){if(!Or(n))yield b(d.Boolean,e,r,n)}function*ry(e,t,r,n){yield*we(e.returns,t,r,n.prototype)}function*ny(e,t,r,n){if(!Xr(n))return yield b(d.Date,e,r,n);if(K(e.exclusiveMaximumTimestamp)&&!(n.getTime()<e.exclusiveMaximumTimestamp))yield b(d.DateExclusiveMaximumTimestamp,e,r,n);if(K(e.exclusiveMinimumTimestamp)&&!(n.getTime()>e.exclusiveMinimumTimestamp))yield b(d.DateExclusiveMinimumTimestamp,e,r,n);if(K(e.maximumTimestamp)&&!(n.getTime()<=e.maximumTimestamp))yield b(d.DateMaximumTimestamp,e,r,n);if(K(e.minimumTimestamp)&&!(n.getTime()>=e.minimumTimestamp))yield b(d.DateMinimumTimestamp,e,r,n);if(K(e.multipleOfTimestamp)&&n.getTime()%e.multipleOfTimestamp!==0)yield b(d.DateMultipleOfTimestamp,e,r,n)}function*oy(e,t,r,n){if(!bo(n))yield b(d.Function,e,r,n)}function*iy(e,t,r,n){let o=globalThis.Object.values(e.$defs),i=e.$defs[e.$ref];yield*we(i,[...t,...o],r,n)}function*sy(e,t,r,n){if(!ho(n))return yield b(d.Integer,e,r,n);if(K(e.exclusiveMaximum)&&!(n<e.exclusiveMaximum))yield b(d.IntegerExclusiveMaximum,e,r,n);if(K(e.exclusiveMinimum)&&!(n>e.exclusiveMinimum))yield b(d.IntegerExclusiveMinimum,e,r,n);if(K(e.maximum)&&!(n<=e.maximum))yield b(d.IntegerMaximum,e,r,n);if(K(e.minimum)&&!(n>=e.minimum))yield b(d.IntegerMinimum,e,r,n);if(K(e.multipleOf)&&n%e.multipleOf!==0)yield b(d.IntegerMultipleOf,e,r,n)}function*ay(e,t,r,n){let o=!1;for(let i of e.allOf)for(let s of we(i,t,r,n))o=!0,yield s;if(o)return yield b(d.Intersect,e,r,n);if(e.unevaluatedProperties===!1){let i=new RegExp(Vt(e));for(let s of Object.getOwnPropertyNames(n))if(!i.test(s))yield b(d.IntersectUnevaluatedProperties,e,`${r}/${s}`,n)}if(typeof e.unevaluatedProperties==="object"){let i=new RegExp(Vt(e));for(let s of Object.getOwnPropertyNames(n))if(!i.test(s)){let a=we(e.unevaluatedProperties,t,`${r}/${s}`,n[s]).next();if(!a.done)yield a.value}}}function*cy(e,t,r,n){if(!xo(n))yield b(d.Iterator,e,r,n)}function*uy(e,t,r,n){if(n!==e.const)yield b(d.Literal,e,r,n)}function*fy(e,t,r,n){yield b(d.Never,e,r,n)}function*my(e,t,r,n){if(we(e.not,t,r,n).next().done===!0)yield b(d.Not,e,r,n)}function*dy(e,t,r,n){if(!_r(n))yield b(d.Null,e,r,n)}function*py(e,t,r,n){if(!te.IsNumberLike(n))return yield b(d.Number,e,r,n);if(K(e.exclusiveMaximum)&&!(n<e.exclusiveMaximum))yield b(d.NumberExclusiveMaximum,e,r,n);if(K(e.exclusiveMinimum)&&!(n>e.exclusiveMinimum))yield b(d.NumberExclusiveMinimum,e,r,n);if(K(e.maximum)&&!(n<=e.maximum))yield b(d.NumberMaximum,e,r,n);if(K(e.minimum)&&!(n>=e.minimum))yield b(d.NumberMinimum,e,r,n);if(K(e.multipleOf)&&n%e.multipleOf!==0)yield b(d.NumberMultipleOf,e,r,n)}function*ly(e,t,r,n){if(!te.IsObjectLike(n))return yield b(d.Object,e,r,n);if(K(e.minProperties)&&!(Object.getOwnPropertyNames(n).length>=e.minProperties))yield b(d.ObjectMinProperties,e,r,n);if(K(e.maxProperties)&&!(Object.getOwnPropertyNames(n).length<=e.maxProperties))yield b(d.ObjectMaxProperties,e,r,n);let o=Array.isArray(e.required)?e.required:[],i=Object.getOwnPropertyNames(e.properties),s=Object.getOwnPropertyNames(n);for(let a of o){if(s.includes(a))continue;yield b(d.ObjectRequiredProperty,e.properties[a],`${r}/${Wt(a)}`,void 0)}if(e.additionalProperties===!1){for(let a of s)if(!i.includes(a))yield b(d.ObjectAdditionalProperties,e,`${r}/${Wt(a)}`,n[a])}if(typeof e.additionalProperties==="object")for(let a of s){if(i.includes(a))continue;yield*we(e.additionalProperties,t,`${r}/${Wt(a)}`,n[a])}for(let a of i){let c=e.properties[a];if(e.required&&e.required.includes(a)){if(yield*we(c,t,`${r}/${Wt(a)}`,n[a]),zt(e)&&!(a in n))yield b(d.ObjectRequiredProperty,c,`${r}/${Wt(a)}`,void 0)}else if(te.IsExactOptionalProperty(n,a))yield*we(c,t,`${r}/${Wt(a)}`,n[a])}}function*yy(e,t,r,n){if(!go(n))yield b(d.Promise,e,r,n)}function*xy(e,t,r,n){if(!te.IsRecordLike(n))return yield b(d.Object,e,r,n);if(K(e.minProperties)&&!(Object.getOwnPropertyNames(n).length>=e.minProperties))yield b(d.ObjectMinProperties,e,r,n);if(K(e.maxProperties)&&!(Object.getOwnPropertyNames(n).length<=e.maxProperties))yield b(d.ObjectMaxProperties,e,r,n);let[o,i]=Object.entries(e.patternProperties)[0],s=new RegExp(o);for(let[a,c]of Object.entries(n))if(s.test(a))yield*we(i,t,`${r}/${Wt(a)}`,c);if(typeof e.additionalProperties==="object"){for(let[a,c]of Object.entries(n))if(!s.test(a))yield*we(e.additionalProperties,t,`${r}/${Wt(a)}`,c)}if(e.additionalProperties===!1)for(let[a,c]of Object.entries(n)){if(s.test(a))continue;return yield b(d.ObjectAdditionalProperties,e,`${r}/${Wt(a)}`,c)}}function*gy(e,t,r,n){yield*we($e(e,t),t,r,n)}function*Iy(e,t,r,n){if(!Oe(n))return yield b(d.String,e,r,n);if(K(e.minLength)&&!(n.length>=e.minLength))yield b(d.StringMinLength,e,r,n);if(K(e.maxLength)&&!(n.length<=e.maxLength))yield b(d.StringMaxLength,e,r,n);if(!new RegExp(e.source,e.flags).test(n))return yield b(d.RegExp,e,r,n)}function*hy(e,t,r,n){if(!Oe(n))return yield b(d.String,e,r,n);if(K(e.minLength)&&!(n.length>=e.minLength))yield b(d.StringMinLength,e,r,n);if(K(e.maxLength)&&!(n.length<=e.maxLength))yield b(d.StringMaxLength,e,r,n);if(Oe(e.pattern)){if(!new RegExp(e.pattern).test(n))yield b(d.StringPattern,e,r,n)}if(Oe(e.format)){if(!_i(e.format))yield b(d.StringFormatUnknown,e,r,n);else if(!Oi(e.format)(n))yield b(d.StringFormat,e,r,n)}}function*by(e,t,r,n){if(!$r(n))yield b(d.Symbol,e,r,n)}function*_y(e,t,r,n){if(!Oe(n))return yield b(d.String,e,r,n);if(!new RegExp(e.pattern).test(n))yield b(d.StringPattern,e,r,n)}function*Oy(e,t,r,n){yield*we($e(e,t),t,r,n)}function*$y(e,t,r,n){if(!Ie(n))return yield b(d.Tuple,e,r,n);if(e.items===void 0&&n.length!==0)return yield b(d.TupleLength,e,r,n);if(n.length!==e.maxItems)return yield b(d.TupleLength,e,r,n);if(!e.items)return;for(let o=0;o<e.items.length;o++)yield*we(e.items[o],t,`${r}/${o}`,n[o])}function*Ry(e,t,r,n){if(!Ue(n))yield b(d.Undefined,e,r,n)}function*wy(e,t,r,n){if(Ur(e,t,n))return;let o=e.anyOf.map((i)=>new vi(we(i,t,r,n)));yield b(d.Union,e,r,n,o)}function*Fy(e,t,r,n){if(!Qr(n))return yield b(d.Uint8Array,e,r,n);if(K(e.maxByteLength)&&!(n.length<=e.maxByteLength))yield b(d.Uint8ArrayMaxByteLength,e,r,n);if(K(e.minByteLength)&&!(n.length>=e.minByteLength))yield b(d.Uint8ArrayMinByteLength,e,r,n)}function*Py(e,t,r,n){}function*Ty(e,t,r,n){if(!te.IsVoidLike(n))yield b(d.Void,e,r,n)}function*Ay(e,t,r,n){if(!$i(e[y])(e,n))yield b(d.Kind,e,r,n)}function*we(e,t,r,n){let o=K(e.$id)?[...t,e]:t,i=e;switch(i[y]){case"Any":return yield*Yl(i,o,r,n);case"Argument":return yield*Xl(i,o,r,n);case"Array":return yield*Ql(i,o,r,n);case"AsyncIterator":return yield*Zl(i,o,r,n);case"BigInt":return yield*ey(i,o,r,n);case"Boolean":return yield*ty(i,o,r,n);case"Constructor":return yield*ry(i,o,r,n);case"Date":return yield*ny(i,o,r,n);case"Function":return yield*oy(i,o,r,n);case"Import":return yield*iy(i,o,r,n);case"Integer":return yield*sy(i,o,r,n);case"Intersect":return yield*ay(i,o,r,n);case"Iterator":return yield*cy(i,o,r,n);case"Literal":return yield*uy(i,o,r,n);case"Never":return yield*fy(i,o,r,n);case"Not":return yield*my(i,o,r,n);case"Null":return yield*dy(i,o,r,n);case"Number":return yield*py(i,o,r,n);case"Object":return yield*ly(i,o,r,n);case"Promise":return yield*yy(i,o,r,n);case"Record":return yield*xy(i,o,r,n);case"Ref":return yield*gy(i,o,r,n);case"RegExp":return yield*Iy(i,o,r,n);case"String":return yield*hy(i,o,r,n);case"Symbol":return yield*by(i,o,r,n);case"TemplateLiteral":return yield*_y(i,o,r,n);case"This":return yield*Oy(i,o,r,n);case"Tuple":return yield*$y(i,o,r,n);case"Undefined":return yield*Ry(i,o,r,n);case"Union":return yield*wy(i,o,r,n);case"Uint8Array":return yield*Fy(i,o,r,n);case"Unknown":return yield*Py(i,o,r,n);case"Void":return yield*Ty(i,o,r,n);default:if(!qn(i[y]))throw new mc(e);return yield*Ay(i,o,r,n)}}function dc(...e){let t=e.length===3?we(e[0],e[1],"",e[2]):we(e[0],[],"",e[1]);return new vi(t)}class qi extends H{constructor(e,t,r){super("Unable to decode value as it does not match the expected schema");this.schema=e,this.value=t,this.error=r}}class pc extends H{constructor(e,t,r,n){super(n instanceof Error?n.message:"Unknown error");this.schema=e,this.path=t,this.value=r,this.error=n}}function ue(e,t,r){try{return q(e)?e[se].Decode(r):r}catch(n){throw new pc(e,t,r,n)}}function ky(e,t,r,n){return Ie(n)?ue(e,r,n.map((o,i)=>_t(e.items,t,`${r}/${i}`,o))):ue(e,r,n)}function Cy(e,t,r,n){if(!Ke(n)||_o(n))return ue(e,r,n);let o=Ko(e),i=o.map((x)=>x[0]),s={...n};for(let[x,I]of o)if(x in s)s[x]=_t(I,t,`${r}/${x}`,s[x]);if(!q(e.unevaluatedProperties))return ue(e,r,s);let a=Object.getOwnPropertyNames(s),c=e.unevaluatedProperties,m={...s};for(let x of a)if(!i.includes(x))m[x]=ue(c,`${r}/${x}`,m[x]);return ue(e,r,m)}function Ny(e,t,r,n){let o=globalThis.Object.values(e.$defs),i=e.$defs[e.$ref],s=_t(i,[...t,...o],r,n);return ue(e,r,s)}function Sy(e,t,r,n){return ue(e,r,_t(e.not,t,r,n))}function My(e,t,r,n){if(!Ke(n))return ue(e,r,n);let o=ot(e),i={...n};for(let m of o){if(!Io(i,m))continue;if(Ue(i[m])&&(!Gt(e.properties[m])||te.IsExactOptionalProperty(i,m)))continue;i[m]=_t(e.properties[m],t,`${r}/${m}`,i[m])}if(!ae(e.additionalProperties))return ue(e,r,i);let s=Object.getOwnPropertyNames(i),a=e.additionalProperties,c={...i};for(let m of s)if(!o.includes(m))c[m]=ue(a,`${r}/${m}`,c[m]);return ue(e,r,c)}function jy(e,t,r,n){if(!Ke(n))return ue(e,r,n);let o=Object.getOwnPropertyNames(e.patternProperties)[0],i=new RegExp(o),s={...n};for(let x of Object.getOwnPropertyNames(n))if(i.test(x))s[x]=_t(e.patternProperties[o],t,`${r}/${x}`,s[x]);if(!ae(e.additionalProperties))return ue(e,r,s);let a=Object.getOwnPropertyNames(s),c=e.additionalProperties,m={...s};for(let x of a)if(!i.test(x))m[x]=ue(c,`${r}/${x}`,m[x]);return ue(e,r,m)}function Uy(e,t,r,n){let o=$e(e,t);return ue(e,r,_t(o,t,r,n))}function Ey(e,t,r,n){let o=$e(e,t);return ue(e,r,_t(o,t,r,n))}function Ky(e,t,r,n){return Ie(n)&&Ie(e.items)?ue(e,r,e.items.map((o,i)=>_t(o,t,`${r}/${i}`,n[i]))):ue(e,r,n)}function Ly(e,t,r,n){for(let o of e.anyOf){if(!Ur(o,t,n))continue;let i=_t(o,t,r,n);return ue(e,r,i)}return ue(e,r,n)}function _t(e,t,r,n){let o=dr(e,t),i=e;switch(e[y]){case"Array":return ky(i,o,r,n);case"Import":return Ny(i,o,r,n);case"Intersect":return Cy(i,o,r,n);case"Not":return Sy(i,o,r,n);case"Object":return My(i,o,r,n);case"Record":return jy(i,o,r,n);case"Ref":return Uy(i,o,r,n);case"Symbol":return ue(i,r,n);case"This":return Ey(i,o,r,n);case"Tuple":return Ky(i,o,r,n);case"Union":return Ly(i,o,r,n);default:return ue(i,r,n)}}function lc(e,t,r){return _t(e,t,"",r)}class Hi extends H{constructor(e,t,r){super("The encoded value does not match the expected schema");this.schema=e,this.value=t,this.error=r}}class yc extends H{constructor(e,t,r,n){super(`${n instanceof Error?n.message:"Unknown error"}`);this.schema=e,this.path=t,this.value=r,this.error=n}}function Ae(e,t,r){try{return q(e)?e[se].Encode(r):r}catch(n){throw new yc(e,t,r,n)}}function By(e,t,r,n){let o=Ae(e,r,n);return Ie(o)?o.map((i,s)=>Ot(e.items,t,`${r}/${s}`,i)):o}function Gy(e,t,r,n){let o=globalThis.Object.values(e.$defs),i=e.$defs[e.$ref],s=Ae(e,r,n);return Ot(i,[...t,...o],r,s)}function Dy(e,t,r,n){let o=Ae(e,r,n);if(!Ke(n)||_o(n))return o;let i=Ko(e),s=i.map((I)=>I[0]),a={...o};for(let[I,k]of i)if(I in a)a[I]=Ot(k,t,`${r}/${I}`,a[I]);if(!q(e.unevaluatedProperties))return a;let c=Object.getOwnPropertyNames(a),m=e.unevaluatedProperties,x={...a};for(let I of c)if(!s.includes(I))x[I]=Ae(m,`${r}/${I}`,x[I]);return x}function vy(e,t,r,n){return Ae(e.not,r,Ae(e,r,n))}function qy(e,t,r,n){let o=Ae(e,r,n);if(!Ke(o))return o;let i=ot(e),s={...o};for(let x of i){if(!Io(s,x))continue;if(Ue(s[x])&&(!Gt(e.properties[x])||te.IsExactOptionalProperty(s,x)))continue;s[x]=Ot(e.properties[x],t,`${r}/${x}`,s[x])}if(!ae(e.additionalProperties))return s;let a=Object.getOwnPropertyNames(s),c=e.additionalProperties,m={...s};for(let x of a)if(!i.includes(x))m[x]=Ae(c,`${r}/${x}`,m[x]);return m}function Hy(e,t,r,n){let o=Ae(e,r,n);if(!Ke(n))return o;let i=Object.getOwnPropertyNames(e.patternProperties)[0],s=new RegExp(i),a={...o};for(let I of Object.getOwnPropertyNames(n))if(s.test(I))a[I]=Ot(e.patternProperties[i],t,`${r}/${I}`,a[I]);if(!ae(e.additionalProperties))return a;let c=Object.getOwnPropertyNames(a),m=e.additionalProperties,x={...a};for(let I of c)if(!s.test(I))x[I]=Ae(m,`${r}/${I}`,x[I]);return x}function Vy(e,t,r,n){let o=$e(e,t),i=Ot(o,t,r,n);return Ae(e,r,i)}function zy(e,t,r,n){let o=$e(e,t),i=Ot(o,t,r,n);return Ae(e,r,i)}function Wy(e,t,r,n){let o=Ae(e,r,n);return Ie(e.items)?e.items.map((i,s)=>Ot(i,t,`${r}/${s}`,o[s])):[]}function Jy(e,t,r,n){for(let o of e.anyOf){if(!Ur(o,t,n))continue;let i=Ot(o,t,r,n);return Ae(e,r,i)}for(let o of e.anyOf){let i=Ot(o,t,r,n);if(!Ur(e,t,i))continue;return Ae(e,r,i)}return Ae(e,r,n)}function Ot(e,t,r,n){let o=dr(e,t),i=e;switch(e[y]){case"Array":return By(i,o,r,n);case"Import":return Gy(i,o,r,n);case"Intersect":return Dy(i,o,r,n);case"Not":return vy(i,o,r,n);case"Object":return qy(i,o,r,n);case"Record":return Hy(i,o,r,n);case"Ref":return Vy(i,o,r,n);case"This":return zy(i,o,r,n);case"Tuple":return Wy(i,o,r,n);case"Union":return Jy(i,o,r,n);default:return Ae(i,r,n)}}function xc(e,t,r){return Ot(e,t,"",r)}function Yy(e,t){return q(e)||_e(e.items,t)}function Xy(e,t){return q(e)||_e(e.items,t)}function Qy(e,t){return q(e)||_e(e.returns,t)||e.parameters.some((r)=>_e(r,t))}function Zy(e,t){return q(e)||_e(e.returns,t)||e.parameters.some((r)=>_e(r,t))}function ex(e,t){return q(e)||q(e.unevaluatedProperties)||e.allOf.some((r)=>_e(r,t))}function tx(e,t){let r=globalThis.Object.getOwnPropertyNames(e.$defs).reduce((o,i)=>[...o,e.$defs[i]],[]),n=e.$defs[e.$ref];return q(e)||_e(n,[...r,...t])}function rx(e,t){return q(e)||_e(e.items,t)}function nx(e,t){return q(e)||_e(e.not,t)}function ox(e,t){return q(e)||Object.values(e.properties).some((r)=>_e(r,t))||ae(e.additionalProperties)&&_e(e.additionalProperties,t)}function ix(e,t){return q(e)||_e(e.item,t)}function sx(e,t){let r=Object.getOwnPropertyNames(e.patternProperties)[0],n=e.patternProperties[r];return q(e)||_e(n,t)||ae(e.additionalProperties)&&q(e.additionalProperties)}function ax(e,t){if(q(e))return!0;return _e($e(e,t),t)}function cx(e,t){if(q(e))return!0;return _e($e(e,t),t)}function ux(e,t){return q(e)||!Ue(e.items)&&e.items.some((r)=>_e(r,t))}function fx(e,t){return q(e)||e.anyOf.some((r)=>_e(r,t))}function _e(e,t){let r=dr(e,t),n=e;if(e.$id&&Vi.has(e.$id))return!1;if(e.$id)Vi.add(e.$id);switch(e[y]){case"Array":return Yy(n,r);case"AsyncIterator":return Xy(n,r);case"Constructor":return Qy(n,r);case"Function":return Zy(n,r);case"Import":return tx(n,r);case"Intersect":return ex(n,r);case"Iterator":return rx(n,r);case"Not":return nx(n,r);case"Object":return ox(n,r);case"Promise":return ix(n,r);case"Record":return sx(n,r);case"Ref":return ax(n,r);case"This":return cx(n,r);case"Tuple":return ux(n,r);case"Union":return fx(n,r);default:return q(e)}}var Vi=new Set;function gc(e,t){return Vi.clear(),_e(e,t)}class Ic{constructor(e,t,r,n){this.schema=e,this.references=t,this.checkFunc=r,this.code=n,this.hasTransform=gc(e,t)}Code(){return this.code}Schema(){return this.schema}References(){return this.references}Errors(e){return dc(this.schema,this.references,e)}Check(e){return this.checkFunc(e)}Decode(e){if(!this.checkFunc(e))throw new qi(this.schema,e,this.Errors(e).First());return this.hasTransform?lc(this.schema,this.references,e):e}Encode(e){let t=this.hasTransform?xc(this.schema,this.references,e):e;if(!this.checkFunc(t))throw new Hi(this.schema,e,this.Errors(e).First());return t}}var Jt;(function(e){function t(i){return i===36}e.DollarSign=t;function r(i){return i===95}e.IsUnderscore=r;function n(i){return i>=65&&i<=90||i>=97&&i<=122}e.IsAlpha=n;function o(i){return i>=48&&i<=57}e.IsNumeric=o})(Jt||(Jt={}));var ei;(function(e){function t(i){if(i.length===0)return!1;return Jt.IsNumeric(i.charCodeAt(0))}function r(i){if(t(i))return!1;for(let s=0;s<i.length;s++){let a=i.charCodeAt(s);if(!(Jt.IsAlpha(a)||Jt.IsNumeric(a)||Jt.DollarSign(a)||Jt.IsUnderscore(a)))return!1}return!0}function n(i){return i.replace(/'/g,"\\'")}function o(i,s){return r(s)?`${i}.${s}`:`${i}['${n(s)}']`}e.Encode=o})(ei||(ei={}));var zi;(function(e){function t(r){let n=[];for(let o=0;o<r.length;o++){let i=r.charCodeAt(o);if(Jt.IsNumeric(i)||Jt.IsAlpha(i))n.push(r.charAt(o));else n.push(`_${i}_`)}return n.join("").replace(/__/g,"_")}e.Encode=t})(zi||(zi={}));var Wi;(function(e){function t(r){return r.replace(/'/g,"\\'")}e.Escape=t})(Wi||(Wi={}));class hc extends H{constructor(e){super("Unknown type");this.schema=e}}class Ji extends H{constructor(e){super("Preflight validation check failed to guard for the given schema");this.schema=e}}var Er;(function(e){function t(s,a,c){return te.ExactOptionalPropertyTypes?`('${a}' in ${s} ? ${c} : true)`:`(${ei.Encode(s,a)} !== undefined ? ${c} : true)`}e.IsExactOptionalProperty=t;function r(s){return!te.AllowArrayObject?`(typeof ${s} === 'object' && ${s} !== null && !Array.isArray(${s}))`:`(typeof ${s} === 'object' && ${s} !== null)`}e.IsObjectLike=r;function n(s){return!te.AllowArrayObject?`(typeof ${s} === 'object' && ${s} !== null && !Array.isArray(${s}) && !(${s} instanceof Date) && !(${s} instanceof Uint8Array))`:`(typeof ${s} === 'object' && ${s} !== null && !(${s} instanceof Date) && !(${s} instanceof Uint8Array))`}e.IsRecordLike=n;function o(s){return te.AllowNaN?`typeof ${s} === 'number'`:`Number.isFinite(${s})`}e.IsNumberLike=o;function i(s){return te.AllowNullVoid?`(${s} === undefined || ${s} === null)`:`${s} === undefined`}e.IsVoidLike=i})(Er||(Er={}));var ti;(function(e){function t(u){return u[y]==="Any"||u[y]==="Unknown"}function*r(u,_,f){yield"true"}function*n(u,_,f){yield"true"}function*o(u,_,f){yield`Array.isArray(${f})`;let[C,R]=[co("value","any"),co("acc","number")];if(N(u.maxItems))yield`${f}.length <= ${u.maxItems}`;if(N(u.minItems))yield`${f}.length >= ${u.minItems}`;let w=at(u.items,_,"value");if(yield`${f}.every((${C}) => ${w})`,ce(u.contains)||N(u.minContains)||N(u.maxContains)){let Q=ce(u.contains)?u.contains:M(),Ee=at(Q,_,"value"),Kt=N(u.minContains)?[`(count >= ${u.minContains})`]:[],ct=N(u.maxContains)?[`(count <= ${u.maxContains})`]:[],At=`const count = value.reduce((${R}, ${C}) => ${Ee} ? acc + 1 : acc, 0)`,uo=["(count > 0)",...Kt,...ct].join(" && ");yield`((${C}) => { ${At}; return ${uo}})(${f})`}if(u.uniqueItems===!0)yield`((${C}) => { const set = new Set(); for(const element of value) { const hashed = hash(element); if(set.has(hashed)) { return false } else { set.add(hashed) } } return true } )(${f})`}function*i(u,_,f){yield`(typeof value === 'object' && Symbol.asyncIterator in ${f})`}function*s(u,_,f){if(yield`(typeof ${f} === 'bigint')`,Ve(u.exclusiveMaximum))yield`${f} < BigInt(${u.exclusiveMaximum})`;if(Ve(u.exclusiveMinimum))yield`${f} > BigInt(${u.exclusiveMinimum})`;if(Ve(u.maximum))yield`${f} <= BigInt(${u.maximum})`;if(Ve(u.minimum))yield`${f} >= BigInt(${u.minimum})`;if(Ve(u.multipleOf))yield`(${f} % BigInt(${u.multipleOf})) === 0`}function*a(u,_,f){yield`(typeof ${f} === 'boolean')`}function*c(u,_,f){yield*Hr(u.returns,_,`${f}.prototype`)}function*m(u,_,f){if(yield`(${f} instanceof Date) && Number.isFinite(${f}.getTime())`,N(u.exclusiveMaximumTimestamp))yield`${f}.getTime() < ${u.exclusiveMaximumTimestamp}`;if(N(u.exclusiveMinimumTimestamp))yield`${f}.getTime() > ${u.exclusiveMinimumTimestamp}`;if(N(u.maximumTimestamp))yield`${f}.getTime() <= ${u.maximumTimestamp}`;if(N(u.minimumTimestamp))yield`${f}.getTime() >= ${u.minimumTimestamp}`;if(N(u.multipleOfTimestamp))yield`(${f}.getTime() % ${u.multipleOfTimestamp}) === 0`}function*x(u,_,f){yield`(typeof ${f} === 'function')`}function*I(u,_,f){let C=globalThis.Object.getOwnPropertyNames(u.$defs).reduce((R,w)=>[...R,u.$defs[w]],[]);yield*Hr(nt(u.$ref),[..._,...C],f)}function*k(u,_,f){if(yield`Number.isInteger(${f})`,N(u.exclusiveMaximum))yield`${f} < ${u.exclusiveMaximum}`;if(N(u.exclusiveMinimum))yield`${f} > ${u.exclusiveMinimum}`;if(N(u.maximum))yield`${f} <= ${u.maximum}`;if(N(u.minimum))yield`${f} >= ${u.minimum}`;if(N(u.multipleOf))yield`(${f} % ${u.multipleOf}) === 0`}function*j(u,_,f){let C=u.allOf.map((R)=>at(R,_,f)).join(" && ");if(u.unevaluatedProperties===!1){let R=Vr(`${new RegExp(Vt(u))};`),w=`Object.getOwnPropertyNames(${f}).every(key => ${R}.test(key))`;yield`(${C} && ${w})`}else if(ce(u.unevaluatedProperties)){let R=Vr(`${new RegExp(Vt(u))};`),w=`Object.getOwnPropertyNames(${f}).every(key => ${R}.test(key) || ${at(u.unevaluatedProperties,_,`${f}[key]`)})`;yield`(${C} && ${w})`}else yield`(${C})`}function*P(u,_,f){yield`(typeof value === 'object' && Symbol.iterator in ${f})`}function*ye(u,_,f){if(typeof u.const==="number"||typeof u.const==="boolean")yield`(${f} === ${u.const})`;else yield`(${f} === '${Wi.Escape(u.const)}')`}function*Tt(u,_,f){yield"false"}function*Ir(u,_,f){yield`(!${at(u.not,_,f)})`}function*qr(u,_,f){yield`(${f} === null)`}function*ci(u,_,f){if(yield Er.IsNumberLike(f),N(u.exclusiveMaximum))yield`${f} < ${u.exclusiveMaximum}`;if(N(u.exclusiveMinimum))yield`${f} > ${u.exclusiveMinimum}`;if(N(u.maximum))yield`${f} <= ${u.maximum}`;if(N(u.minimum))yield`${f} >= ${u.minimum}`;if(N(u.multipleOf))yield`(${f} % ${u.multipleOf}) === 0`}function*rs(u,_,f){if(yield Er.IsObjectLike(f),N(u.minProperties))yield`Object.getOwnPropertyNames(${f}).length >= ${u.minProperties}`;if(N(u.maxProperties))yield`Object.getOwnPropertyNames(${f}).length <= ${u.maxProperties}`;let C=Object.getOwnPropertyNames(u.properties);for(let R of C){let w=ei.Encode(f,R),Q=u.properties[R];if(u.required&&u.required.includes(R)){if(yield*Hr(Q,_,w),zt(Q)||t(Q))yield`('${R}' in ${f})`}else{let Ee=at(Q,_,w);yield Er.IsExactOptionalProperty(f,R,Ee)}}if(u.additionalProperties===!1)if(u.required&&u.required.length===C.length)yield`Object.getOwnPropertyNames(${f}).length === ${C.length}`;else{let R=`[${C.map((w)=>`'${w}'`).join(", ")}]`;yield`Object.getOwnPropertyNames(${f}).every(key => ${R}.includes(key))`}if(typeof u.additionalProperties==="object"){let R=at(u.additionalProperties,_,`${f}[key]`),w=`[${C.map((Q)=>`'${Q}'`).join(", ")}]`;yield`(Object.getOwnPropertyNames(${f}).every(key => ${w}.includes(key) || ${R}))`}}function*ui(u,_,f){yield`${f} instanceof Promise`}function*Ze(u,_,f){if(yield Er.IsRecordLike(f),N(u.minProperties))yield`Object.getOwnPropertyNames(${f}).length >= ${u.minProperties}`;if(N(u.maxProperties))yield`Object.getOwnPropertyNames(${f}).length <= ${u.maxProperties}`;let[C,R]=Object.entries(u.patternProperties)[0],w=Vr(`${new RegExp(C)}`),Q=at(R,_,"value"),Ee=ce(u.additionalProperties)?at(u.additionalProperties,_,f):u.additionalProperties===!1?"false":"true",Kt=`(${w}.test(key) ? ${Q} : ${Ee})`;yield`(Object.entries(${f}).every(([key, value]) => ${Kt}))`}function*Et(u,_,f){let C=$e(u,_);if(Fe.functions.has(u.$ref))return yield`${ao(u.$ref)}(${f})`;yield*Hr(C,_,f)}function*hr(u,_,f){let C=Vr(`${new RegExp(u.source,u.flags)};`);if(yield`(typeof ${f} === 'string')`,N(u.maxLength))yield`${f}.length <= ${u.maxLength}`;if(N(u.minLength))yield`${f}.length >= ${u.minLength}`;yield`${C}.test(${f})`}function*so(u,_,f){if(yield`(typeof ${f} === 'string')`,N(u.maxLength))yield`${f}.length <= ${u.maxLength}`;if(N(u.minLength))yield`${f}.length >= ${u.minLength}`;if(u.pattern!==void 0)yield`${Vr(`${new RegExp(u.pattern)};`)}.test(${f})`;if(u.format!==void 0)yield`format('${u.format}', ${f})`}function*Lc(u,_,f){yield`(typeof ${f} === 'symbol')`}function*Bc(u,_,f){yield`(typeof ${f} === 'string')`,yield`${Vr(`${new RegExp(u.pattern)};`)}.test(${f})`}function*Gc(u,_,f){yield`${ao(u.$ref)}(${f})`}function*Dc(u,_,f){if(yield`Array.isArray(${f})`,u.items===void 0)return yield`${f}.length === 0`;yield`(${f}.length === ${u.maxItems})`;for(let C=0;C<u.items.length;C++)yield`${at(u.items[C],_,`${f}[${C}]`)}`}function*vc(u,_,f){yield`${f} === undefined`}function*qc(u,_,f){yield`(${u.anyOf.map((R)=>at(R,_,f)).join(" || ")})`}function*Hc(u,_,f){if(yield`${f} instanceof Uint8Array`,N(u.maxByteLength))yield`(${f}.length <= ${u.maxByteLength})`;if(N(u.minByteLength))yield`(${f}.length >= ${u.minByteLength})`}function*Vc(u,_,f){yield"true"}function*zc(u,_,f){yield Er.IsVoidLike(f)}function*Wc(u,_,f){let C=Fe.instances.size;Fe.instances.set(C,u),yield`kind('${u[y]}', ${C}, ${f})`}function*Hr(u,_,f,C=!0){let R=Oe(u.$id)?[..._,u]:_,w=u;if(C&&Oe(u.$id)){let Q=ao(u.$id);if(Fe.functions.has(Q))return yield`${Q}(${f})`;else{Fe.functions.set(Q,"<deferred>");let Ee=ns(Q,u,_,"value",!1);return Fe.functions.set(Q,Ee),yield`${Q}(${f})`}}switch(w[y]){case"Any":return yield*r(w,R,f);case"Argument":return yield*n(w,R,f);case"Array":return yield*o(w,R,f);case"AsyncIterator":return yield*i(w,R,f);case"BigInt":return yield*s(w,R,f);case"Boolean":return yield*a(w,R,f);case"Constructor":return yield*c(w,R,f);case"Date":return yield*m(w,R,f);case"Function":return yield*x(w,R,f);case"Import":return yield*I(w,R,f);case"Integer":return yield*k(w,R,f);case"Intersect":return yield*j(w,R,f);case"Iterator":return yield*P(w,R,f);case"Literal":return yield*ye(w,R,f);case"Never":return yield*Tt(w,R,f);case"Not":return yield*Ir(w,R,f);case"Null":return yield*qr(w,R,f);case"Number":return yield*ci(w,R,f);case"Object":return yield*rs(w,R,f);case"Promise":return yield*ui(w,R,f);case"Record":return yield*Ze(w,R,f);case"Ref":return yield*Et(w,R,f);case"RegExp":return yield*hr(w,R,f);case"String":return yield*so(w,R,f);case"Symbol":return yield*Lc(w,R,f);case"TemplateLiteral":return yield*Bc(w,R,f);case"This":return yield*Gc(w,R,f);case"Tuple":return yield*Dc(w,R,f);case"Undefined":return yield*vc(w,R,f);case"Union":return yield*qc(w,R,f);case"Uint8Array":return yield*Hc(w,R,f);case"Unknown":return yield*Vc(w,R,f);case"Void":return yield*zc(w,R,f);default:if(!qn(w[y]))throw new hc(u);return yield*Wc(w,R,f)}}let Fe={language:"javascript",functions:new Map,variables:new Map,instances:new Map};function at(u,_,f,C=!0){return`(${[...Hr(u,_,f,C)].join(" && ")})`}function ao(u){return`check_${zi.Encode(u)}`}function Vr(u){let _=`local_${Fe.variables.size}`;return Fe.variables.set(_,`const ${_} = ${u}`),_}function ns(u,_,f,C,R=!0){let[w,Q]=[`
|
|
162
|
-
`,(At)=>"".padStart(At," ")],Ee=co("value","any"),Kt=os("boolean"),ct=[...Hr(_,f,C,R)].map((At)=>`${Q(4)}${At}`).join(` &&${w}`);return`function ${u}(${Ee})${Kt} {${w}${Q(2)}return (${w}${ct}${w}${Q(2)})
|
|
163
|
-
}`}function co(u,_){let f=Fe.language==="typescript"?`: ${_}`:"";return`${u}${f}`}function os(u){return Fe.language==="typescript"?`: ${u}`:""}function Jc(u,_,f){let C=ns("check",u,_,"value"),R=co("value","any"),w=os("boolean"),Q=[...Fe.functions.values()],Ee=[...Fe.variables.values()],Kt=Oe(u.$id)?`return function check(${R})${w} {
|
|
164
|
-
return ${ao(u.$id)}(value)
|
|
165
|
-
}`:`return ${C}`;return[...Ee,...Q,Kt].join(`
|
|
166
|
-
`)}function is(...u){let _={language:"javascript"},[f,C,R]=u.length===2&&Ie(u[1])?[u[0],u[1],_]:u.length===2&&!Ie(u[1])?[u[0],[],u[1]]:u.length===3?[u[0],u[1],u[2]]:u.length===1?[u[0],[],_]:[null,[],_];if(Fe.language=R.language,Fe.variables.clear(),Fe.functions.clear(),Fe.instances.clear(),!ce(f))throw new Ji(f);for(let w of C)if(!ce(w))throw new Ji(w);return Jc(f,C,R)}e.Code=is;function Yc(u,_=[]){let f=is(u,_,{language:"javascript"}),C=globalThis.Function("kind","format","hash",f),R=new Map(Fe.instances);function w(ct,At,uo){if(!qn(ct)||!R.has(At))return!1;let Xc=$i(ct),Qc=R.get(At);return Xc(Qc,uo)}function Q(ct,At){if(!_i(ct))return!1;return Oi(ct)(At)}function Ee(ct){return bn(ct)}let Kt=C(w,Q,Ee);return new Ic(u,_,Kt,f)}e.Compile=Yc})(ti||(ti={}));var L;(function(e){e.assertEqual=(o)=>{};function t(o){}e.assertIs=t;function r(o){throw Error()}e.assertNever=r,e.arrayToEnum=(o)=>{let i={};for(let s of o)i[s]=s;return i},e.getValidEnumValues=(o)=>{let i=e.objectKeys(o).filter((a)=>typeof o[o[a]]!=="number"),s={};for(let a of i)s[a]=o[a];return e.objectValues(s)},e.objectValues=(o)=>e.objectKeys(o).map(function(i){return o[i]}),e.objectKeys=typeof Object.keys==="function"?(o)=>Object.keys(o):(o)=>{let i=[];for(let s in o)if(Object.prototype.hasOwnProperty.call(o,s))i.push(s);return i},e.find=(o,i)=>{for(let s of o)if(i(s))return s;return},e.isInteger=typeof Number.isInteger==="function"?(o)=>Number.isInteger(o):(o)=>typeof o==="number"&&Number.isFinite(o)&&Math.floor(o)===o;function n(o,i=" | "){return o.map((s)=>typeof s==="string"?`'${s}'`:s).join(i)}e.joinValues=n,e.jsonStringifyReplacer=(o,i)=>{if(typeof i==="bigint")return i.toString();return i}})(L||(L={}));var Yi;(function(e){e.mergeShapes=(t,r)=>({...t,...r})})(Yi||(Yi={}));var O=L.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),Mt=(e)=>{switch(typeof e){case"undefined":return O.undefined;case"string":return O.string;case"number":return Number.isNaN(e)?O.nan:O.number;case"boolean":return O.boolean;case"function":return O.function;case"bigint":return O.bigint;case"symbol":return O.symbol;case"object":if(Array.isArray(e))return O.array;if(e===null)return O.null;if(e.then&&typeof e.then==="function"&&e.catch&&typeof e.catch==="function")return O.promise;if(typeof Map<"u"&&e instanceof Map)return O.map;if(typeof Set<"u"&&e instanceof Set)return O.set;if(typeof Date<"u"&&e instanceof Date)return O.date;return O.object;default:return O.unknown}};var g=L.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]),mx=(e)=>JSON.stringify(e,null,2).replace(/"([^"]+)":/g,"$1:");class qe extends Error{get errors(){return this.issues}constructor(e){super();this.issues=[],this.addIssue=(r)=>{this.issues=[...this.issues,r]},this.addIssues=(r=[])=>{this.issues=[...this.issues,...r]};let t=new.target.prototype;if(Object.setPrototypeOf)Object.setPrototypeOf(this,t);else this.__proto__=t;this.name="ZodError",this.issues=e}format(e){let t=e||function(o){return o.message},r={_errors:[]},n=(o)=>{for(let i of o.issues)if(i.code==="invalid_union")i.unionErrors.map(n);else if(i.code==="invalid_return_type")n(i.returnTypeError);else if(i.code==="invalid_arguments")n(i.argumentsError);else if(i.path.length===0)r._errors.push(t(i));else{let s=r,a=0;while(a<i.path.length){let c=i.path[a];if(a!==i.path.length-1)s[c]=s[c]||{_errors:[]};else s[c]=s[c]||{_errors:[]},s[c]._errors.push(t(i));s=s[c],a++}}};return n(this),r}static assert(e){if(!(e instanceof qe))throw Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,L.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=(t)=>t.message){let t={},r=[];for(let n of this.issues)if(n.path.length>0){let o=n.path[0];t[o]=t[o]||[],t[o].push(e(n))}else r.push(e(n));return{formErrors:r,fieldErrors:t}}get formErrors(){return this.flatten()}}qe.create=(e)=>new qe(e);var dx=(e,t)=>{let r;switch(e.code){case g.invalid_type:if(e.received===O.undefined)r="Required";else r=`Expected ${e.expected}, received ${e.received}`;break;case g.invalid_literal:r=`Invalid literal value, expected ${JSON.stringify(e.expected,L.jsonStringifyReplacer)}`;break;case g.unrecognized_keys:r=`Unrecognized key(s) in object: ${L.joinValues(e.keys,", ")}`;break;case g.invalid_union:r="Invalid input";break;case g.invalid_union_discriminator:r=`Invalid discriminator value. Expected ${L.joinValues(e.options)}`;break;case g.invalid_enum_value:r=`Invalid enum value. Expected ${L.joinValues(e.options)}, received '${e.received}'`;break;case g.invalid_arguments:r="Invalid function arguments";break;case g.invalid_return_type:r="Invalid function return type";break;case g.invalid_date:r="Invalid date";break;case g.invalid_string:if(typeof e.validation==="object")if("includes"in e.validation){if(r=`Invalid input: must include "${e.validation.includes}"`,typeof e.validation.position==="number")r=`${r} at one or more positions greater than or equal to ${e.validation.position}`}else if("startsWith"in e.validation)r=`Invalid input: must start with "${e.validation.startsWith}"`;else if("endsWith"in e.validation)r=`Invalid input: must end with "${e.validation.endsWith}"`;else L.assertNever(e.validation);else if(e.validation!=="regex")r=`Invalid ${e.validation}`;else r="Invalid";break;case g.too_small:if(e.type==="array")r=`Array must contain ${e.exact?"exactly":e.inclusive?"at least":"more than"} ${e.minimum} element(s)`;else if(e.type==="string")r=`String must contain ${e.exact?"exactly":e.inclusive?"at least":"over"} ${e.minimum} character(s)`;else if(e.type==="number")r=`Number must be ${e.exact?"exactly equal to ":e.inclusive?"greater than or equal to ":"greater than "}${e.minimum}`;else if(e.type==="bigint")r=`Number must be ${e.exact?"exactly equal to ":e.inclusive?"greater than or equal to ":"greater than "}${e.minimum}`;else if(e.type==="date")r=`Date must be ${e.exact?"exactly equal to ":e.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(e.minimum))}`;else r="Invalid input";break;case g.too_big:if(e.type==="array")r=`Array must contain ${e.exact?"exactly":e.inclusive?"at most":"less than"} ${e.maximum} element(s)`;else if(e.type==="string")r=`String must contain ${e.exact?"exactly":e.inclusive?"at most":"under"} ${e.maximum} character(s)`;else if(e.type==="number")r=`Number must be ${e.exact?"exactly":e.inclusive?"less than or equal to":"less than"} ${e.maximum}`;else if(e.type==="bigint")r=`BigInt must be ${e.exact?"exactly":e.inclusive?"less than or equal to":"less than"} ${e.maximum}`;else if(e.type==="date")r=`Date must be ${e.exact?"exactly":e.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(e.maximum))}`;else r="Invalid input";break;case g.custom:r="Invalid input";break;case g.invalid_intersection_types:r="Intersection results could not be merged";break;case g.not_multiple_of:r=`Number must be a multiple of ${e.multipleOf}`;break;case g.not_finite:r="Number must be finite";break;default:r=t.defaultError,L.assertNever(e)}return{message:r}},Yt=dx;var bc=Yt;function px(e){bc=e}function _n(){return bc}var Zn=(e)=>{let{data:t,path:r,errorMaps:n,issueData:o}=e,i=[...r,...o.path||[]],s={...o,path:i};if(o.message!==void 0)return{...o,path:i,message:o.message};let a="",c=n.filter((m)=>!!m).slice().reverse();for(let m of c)a=m(s,{data:t,defaultError:a}).message;return{...o,path:i,message:a}},lx=[];function h(e,t){let r=_n(),n=Zn({issueData:t,data:e.data,path:e.path,errorMaps:[e.common.contextualErrorMap,e.schemaErrorMap,r,r===Yt?void 0:Yt].filter((o)=>!!o)});e.common.issues.push(n)}class ke{constructor(){this.value="valid"}dirty(){if(this.value==="valid")this.value="dirty"}abort(){if(this.value!=="aborted")this.value="aborted"}static mergeArray(e,t){let r=[];for(let n of t){if(n.status==="aborted")return T;if(n.status==="dirty")e.dirty();r.push(n.value)}return{status:e.value,value:r}}static async mergeObjectAsync(e,t){let r=[];for(let n of t){let o=await n.key,i=await n.value;r.push({key:o,value:i})}return ke.mergeObjectSync(e,r)}static mergeObjectSync(e,t){let r={};for(let n of t){let{key:o,value:i}=n;if(o.status==="aborted")return T;if(i.status==="aborted")return T;if(o.status==="dirty")e.dirty();if(i.status==="dirty")e.dirty();if(o.value!=="__proto__"&&(typeof i.value<"u"||n.alwaysSet))r[o.value]=i.value}return{status:e.value,value:r}}}var T=Object.freeze({status:"aborted"}),Kr=(e)=>({status:"dirty",value:e}),je=(e)=>({status:"valid",value:e}),ri=(e)=>e.status==="aborted",ni=(e)=>e.status==="dirty",pr=(e)=>e.status==="valid",On=(e)=>typeof Promise<"u"&&e instanceof Promise;var F;(function(e){e.errToObj=(t)=>typeof t==="string"?{message:t}:t||{},e.toString=(t)=>typeof t==="string"?t:t?.message})(F||(F={}));class Ft{constructor(e,t,r,n){this._cachedPath=[],this.parent=e,this.data=t,this._path=r,this._key=n}get path(){if(!this._cachedPath.length)if(Array.isArray(this._key))this._cachedPath.push(...this._path,...this._key);else this._cachedPath.push(...this._path,this._key);return this._cachedPath}}var _c=(e,t)=>{if(pr(t))return{success:!0,data:t.value};else{if(!e.common.issues.length)throw Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;let r=new qe(e.common.issues);return this._error=r,this._error}}}};function S(e){if(!e)return{};let{errorMap:t,invalid_type_error:r,required_error:n,description:o}=e;if(t&&(r||n))throw Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);if(t)return{errorMap:t,description:o};return{errorMap:(s,a)=>{let{message:c}=e;if(s.code==="invalid_enum_value")return{message:c??a.defaultError};if(typeof a.data>"u")return{message:c??n??a.defaultError};if(s.code!=="invalid_type")return{message:a.defaultError};return{message:c??r??a.defaultError}},description:o}}class U{get description(){return this._def.description}_getType(e){return Mt(e.data)}_getOrReturnCtx(e,t){return t||{common:e.parent.common,data:e.data,parsedType:Mt(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new ke,ctx:{common:e.parent.common,data:e.data,parsedType:Mt(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){let t=this._parse(e);if(On(t))throw Error("Synchronous parse encountered promise.");return t}_parseAsync(e){let t=this._parse(e);return Promise.resolve(t)}parse(e,t){let r=this.safeParse(e,t);if(r.success)return r.data;throw r.error}safeParse(e,t){let r={common:{issues:[],async:t?.async??!1,contextualErrorMap:t?.errorMap},path:t?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:Mt(e)},n=this._parseSync({data:e,path:r.path,parent:r});return _c(r,n)}"~validate"(e){let t={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:Mt(e)};if(!this["~standard"].async)try{let r=this._parseSync({data:e,path:[],parent:t});return pr(r)?{value:r.value}:{issues:t.common.issues}}catch(r){if(r?.message?.toLowerCase()?.includes("encountered"))this["~standard"].async=!0;t.common={issues:[],async:!0}}return this._parseAsync({data:e,path:[],parent:t}).then((r)=>pr(r)?{value:r.value}:{issues:t.common.issues})}async parseAsync(e,t){let r=await this.safeParseAsync(e,t);if(r.success)return r.data;throw r.error}async safeParseAsync(e,t){let r={common:{issues:[],contextualErrorMap:t?.errorMap,async:!0},path:t?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:Mt(e)},n=this._parse({data:e,path:r.path,parent:r}),o=await(On(n)?n:Promise.resolve(n));return _c(r,o)}refine(e,t){let r=(n)=>{if(typeof t==="string"||typeof t>"u")return{message:t};else if(typeof t==="function")return t(n);else return t};return this._refinement((n,o)=>{let i=e(n),s=()=>o.addIssue({code:g.custom,...r(n)});if(typeof Promise<"u"&&i instanceof Promise)return i.then((a)=>{if(!a)return s(),!1;else return!0});if(!i)return s(),!1;else return!0})}refinement(e,t){return this._refinement((r,n)=>{if(!e(r))return n.addIssue(typeof t==="function"?t(r,n):t),!1;else return!0})}_refinement(e){return new Pt({schema:this,typeName:A.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}constructor(e){this.spa=this.safeParseAsync,this._def=e,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this),this["~standard"]={version:1,vendor:"zod",validate:(t)=>this["~validate"](t)}}optional(){return wt.create(this,this._def)}nullable(){return Qt.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return Rt.create(this)}promise(){return Dr.create(this,this._def)}or(e){return Tn.create([this,e],this._def)}and(e){return An.create(this,e,this._def)}transform(e){return new Pt({...S(this._def),schema:this,typeName:A.ZodEffects,effect:{type:"transform",transform:e}})}default(e){let t=typeof e==="function"?e:()=>e;return new Sn({...S(this._def),innerType:this,defaultValue:t,typeName:A.ZodDefault})}brand(){return new ii({typeName:A.ZodBranded,type:this,...S(this._def)})}catch(e){let t=typeof e==="function"?e:()=>e;return new Mn({...S(this._def),innerType:this,catchValue:t,typeName:A.ZodCatch})}describe(e){return new this.constructor({...this._def,description:e})}pipe(e){return io.create(this,e)}readonly(){return jn.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}var yx=/^c[^\s-]{8,}$/i,xx=/^[0-9a-z]+$/,gx=/^[0-9A-HJKMNP-TV-Z]{26}$/i,Ix=/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i,hx=/^[a-z0-9_-]{21}$/i,bx=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,_x=/^[-+]?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)?)??$/,Ox=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,$x="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$",Xi,Rx=/^(?:(?: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])$/,wx=/^(?:(?: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])\/(3[0-2]|[12]?[0-9])$/,Fx=/^(([0-9a-fA-F]{1,4}:){7,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}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/,Px=/^(([0-9a-fA-F]{1,4}:){7,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}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,Tx=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,Ax=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,$c="((\\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])))",kx=new RegExp(`^${$c}$`);function Rc(e){let t="[0-5]\\d";if(e.precision)t=`${t}\\.\\d{${e.precision}}`;else if(e.precision==null)t=`${t}(\\.\\d+)?`;let r=e.precision?"+":"?";return`([01]\\d|2[0-3]):[0-5]\\d(:${t})${r}`}function Cx(e){return new RegExp(`^${Rc(e)}$`)}function wc(e){let t=`${$c}T${Rc(e)}`,r=[];if(r.push(e.local?"Z?":"Z"),e.offset)r.push("([+-]\\d{2}:?\\d{2})");return t=`${t}(${r.join("|")})`,new RegExp(`^${t}$`)}function Nx(e,t){if((t==="v4"||!t)&&Rx.test(e))return!0;if((t==="v6"||!t)&&Fx.test(e))return!0;return!1}function Sx(e,t){if(!bx.test(e))return!1;try{let[r]=e.split(".");if(!r)return!1;let n=r.replace(/-/g,"+").replace(/_/g,"/").padEnd(r.length+(4-r.length%4)%4,"="),o=JSON.parse(atob(n));if(typeof o!=="object"||o===null)return!1;if("typ"in o&&o?.typ!=="JWT")return!1;if(!o.alg)return!1;if(t&&o.alg!==t)return!1;return!0}catch{return!1}}function Mx(e,t){if((t==="v4"||!t)&&wx.test(e))return!0;if((t==="v6"||!t)&&Px.test(e))return!0;return!1}class $t extends U{_parse(e){if(this._def.coerce)e.data=String(e.data);if(this._getType(e)!==O.string){let o=this._getOrReturnCtx(e);return h(o,{code:g.invalid_type,expected:O.string,received:o.parsedType}),T}let r=new ke,n=void 0;for(let o of this._def.checks)if(o.kind==="min"){if(e.data.length<o.value)n=this._getOrReturnCtx(e,n),h(n,{code:g.too_small,minimum:o.value,type:"string",inclusive:!0,exact:!1,message:o.message}),r.dirty()}else if(o.kind==="max"){if(e.data.length>o.value)n=this._getOrReturnCtx(e,n),h(n,{code:g.too_big,maximum:o.value,type:"string",inclusive:!0,exact:!1,message:o.message}),r.dirty()}else if(o.kind==="length"){let i=e.data.length>o.value,s=e.data.length<o.value;if(i||s){if(n=this._getOrReturnCtx(e,n),i)h(n,{code:g.too_big,maximum:o.value,type:"string",inclusive:!0,exact:!0,message:o.message});else if(s)h(n,{code:g.too_small,minimum:o.value,type:"string",inclusive:!0,exact:!0,message:o.message});r.dirty()}}else if(o.kind==="email"){if(!Ox.test(e.data))n=this._getOrReturnCtx(e,n),h(n,{validation:"email",code:g.invalid_string,message:o.message}),r.dirty()}else if(o.kind==="emoji"){if(!Xi)Xi=new RegExp($x,"u");if(!Xi.test(e.data))n=this._getOrReturnCtx(e,n),h(n,{validation:"emoji",code:g.invalid_string,message:o.message}),r.dirty()}else if(o.kind==="uuid"){if(!Ix.test(e.data))n=this._getOrReturnCtx(e,n),h(n,{validation:"uuid",code:g.invalid_string,message:o.message}),r.dirty()}else if(o.kind==="nanoid"){if(!hx.test(e.data))n=this._getOrReturnCtx(e,n),h(n,{validation:"nanoid",code:g.invalid_string,message:o.message}),r.dirty()}else if(o.kind==="cuid"){if(!yx.test(e.data))n=this._getOrReturnCtx(e,n),h(n,{validation:"cuid",code:g.invalid_string,message:o.message}),r.dirty()}else if(o.kind==="cuid2"){if(!xx.test(e.data))n=this._getOrReturnCtx(e,n),h(n,{validation:"cuid2",code:g.invalid_string,message:o.message}),r.dirty()}else if(o.kind==="ulid"){if(!gx.test(e.data))n=this._getOrReturnCtx(e,n),h(n,{validation:"ulid",code:g.invalid_string,message:o.message}),r.dirty()}else if(o.kind==="url")try{new URL(e.data)}catch{n=this._getOrReturnCtx(e,n),h(n,{validation:"url",code:g.invalid_string,message:o.message}),r.dirty()}else if(o.kind==="regex"){if(o.regex.lastIndex=0,!o.regex.test(e.data))n=this._getOrReturnCtx(e,n),h(n,{validation:"regex",code:g.invalid_string,message:o.message}),r.dirty()}else if(o.kind==="trim")e.data=e.data.trim();else if(o.kind==="includes"){if(!e.data.includes(o.value,o.position))n=this._getOrReturnCtx(e,n),h(n,{code:g.invalid_string,validation:{includes:o.value,position:o.position},message:o.message}),r.dirty()}else if(o.kind==="toLowerCase")e.data=e.data.toLowerCase();else if(o.kind==="toUpperCase")e.data=e.data.toUpperCase();else if(o.kind==="startsWith"){if(!e.data.startsWith(o.value))n=this._getOrReturnCtx(e,n),h(n,{code:g.invalid_string,validation:{startsWith:o.value},message:o.message}),r.dirty()}else if(o.kind==="endsWith"){if(!e.data.endsWith(o.value))n=this._getOrReturnCtx(e,n),h(n,{code:g.invalid_string,validation:{endsWith:o.value},message:o.message}),r.dirty()}else if(o.kind==="datetime"){if(!wc(o).test(e.data))n=this._getOrReturnCtx(e,n),h(n,{code:g.invalid_string,validation:"datetime",message:o.message}),r.dirty()}else if(o.kind==="date"){if(!kx.test(e.data))n=this._getOrReturnCtx(e,n),h(n,{code:g.invalid_string,validation:"date",message:o.message}),r.dirty()}else if(o.kind==="time"){if(!Cx(o).test(e.data))n=this._getOrReturnCtx(e,n),h(n,{code:g.invalid_string,validation:"time",message:o.message}),r.dirty()}else if(o.kind==="duration"){if(!_x.test(e.data))n=this._getOrReturnCtx(e,n),h(n,{validation:"duration",code:g.invalid_string,message:o.message}),r.dirty()}else if(o.kind==="ip"){if(!Nx(e.data,o.version))n=this._getOrReturnCtx(e,n),h(n,{validation:"ip",code:g.invalid_string,message:o.message}),r.dirty()}else if(o.kind==="jwt"){if(!Sx(e.data,o.alg))n=this._getOrReturnCtx(e,n),h(n,{validation:"jwt",code:g.invalid_string,message:o.message}),r.dirty()}else if(o.kind==="cidr"){if(!Mx(e.data,o.version))n=this._getOrReturnCtx(e,n),h(n,{validation:"cidr",code:g.invalid_string,message:o.message}),r.dirty()}else if(o.kind==="base64"){if(!Tx.test(e.data))n=this._getOrReturnCtx(e,n),h(n,{validation:"base64",code:g.invalid_string,message:o.message}),r.dirty()}else if(o.kind==="base64url"){if(!Ax.test(e.data))n=this._getOrReturnCtx(e,n),h(n,{validation:"base64url",code:g.invalid_string,message:o.message}),r.dirty()}else L.assertNever(o);return{status:r.value,value:e.data}}_regex(e,t,r){return this.refinement((n)=>e.test(n),{validation:t,code:g.invalid_string,...F.errToObj(r)})}_addCheck(e){return new $t({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...F.errToObj(e)})}url(e){return this._addCheck({kind:"url",...F.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...F.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...F.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",...F.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...F.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...F.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...F.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",...F.errToObj(e)})}base64url(e){return this._addCheck({kind:"base64url",...F.errToObj(e)})}jwt(e){return this._addCheck({kind:"jwt",...F.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...F.errToObj(e)})}cidr(e){return this._addCheck({kind:"cidr",...F.errToObj(e)})}datetime(e){if(typeof e==="string")return this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:e});return this._addCheck({kind:"datetime",precision:typeof e?.precision>"u"?null:e?.precision,offset:e?.offset??!1,local:e?.local??!1,...F.errToObj(e?.message)})}date(e){return this._addCheck({kind:"date",message:e})}time(e){if(typeof e==="string")return this._addCheck({kind:"time",precision:null,message:e});return this._addCheck({kind:"time",precision:typeof e?.precision>"u"?null:e?.precision,...F.errToObj(e?.message)})}duration(e){return this._addCheck({kind:"duration",...F.errToObj(e)})}regex(e,t){return this._addCheck({kind:"regex",regex:e,...F.errToObj(t)})}includes(e,t){return this._addCheck({kind:"includes",value:e,position:t?.position,...F.errToObj(t?.message)})}startsWith(e,t){return this._addCheck({kind:"startsWith",value:e,...F.errToObj(t)})}endsWith(e,t){return this._addCheck({kind:"endsWith",value:e,...F.errToObj(t)})}min(e,t){return this._addCheck({kind:"min",value:e,...F.errToObj(t)})}max(e,t){return this._addCheck({kind:"max",value:e,...F.errToObj(t)})}length(e,t){return this._addCheck({kind:"length",value:e,...F.errToObj(t)})}nonempty(e){return this.min(1,F.errToObj(e))}trim(){return new $t({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new $t({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new $t({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find((e)=>e.kind==="datetime")}get isDate(){return!!this._def.checks.find((e)=>e.kind==="date")}get isTime(){return!!this._def.checks.find((e)=>e.kind==="time")}get isDuration(){return!!this._def.checks.find((e)=>e.kind==="duration")}get isEmail(){return!!this._def.checks.find((e)=>e.kind==="email")}get isURL(){return!!this._def.checks.find((e)=>e.kind==="url")}get isEmoji(){return!!this._def.checks.find((e)=>e.kind==="emoji")}get isUUID(){return!!this._def.checks.find((e)=>e.kind==="uuid")}get isNANOID(){return!!this._def.checks.find((e)=>e.kind==="nanoid")}get isCUID(){return!!this._def.checks.find((e)=>e.kind==="cuid")}get isCUID2(){return!!this._def.checks.find((e)=>e.kind==="cuid2")}get isULID(){return!!this._def.checks.find((e)=>e.kind==="ulid")}get isIP(){return!!this._def.checks.find((e)=>e.kind==="ip")}get isCIDR(){return!!this._def.checks.find((e)=>e.kind==="cidr")}get isBase64(){return!!this._def.checks.find((e)=>e.kind==="base64")}get isBase64url(){return!!this._def.checks.find((e)=>e.kind==="base64url")}get minLength(){let e=null;for(let t of this._def.checks)if(t.kind==="min"){if(e===null||t.value>e)e=t.value}return e}get maxLength(){let e=null;for(let t of this._def.checks)if(t.kind==="max"){if(e===null||t.value<e)e=t.value}return e}}$t.create=(e)=>new $t({checks:[],typeName:A.ZodString,coerce:e?.coerce??!1,...S(e)});function jx(e,t){let r=(e.toString().split(".")[1]||"").length,n=(t.toString().split(".")[1]||"").length,o=r>n?r:n,i=Number.parseInt(e.toFixed(o).replace(".","")),s=Number.parseInt(t.toFixed(o).replace(".",""));return i%s/10**o}class yr extends U{constructor(){super(...arguments);this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(e){if(this._def.coerce)e.data=Number(e.data);if(this._getType(e)!==O.number){let o=this._getOrReturnCtx(e);return h(o,{code:g.invalid_type,expected:O.number,received:o.parsedType}),T}let r=void 0,n=new ke;for(let o of this._def.checks)if(o.kind==="int"){if(!L.isInteger(e.data))r=this._getOrReturnCtx(e,r),h(r,{code:g.invalid_type,expected:"integer",received:"float",message:o.message}),n.dirty()}else if(o.kind==="min"){if(o.inclusive?e.data<o.value:e.data<=o.value)r=this._getOrReturnCtx(e,r),h(r,{code:g.too_small,minimum:o.value,type:"number",inclusive:o.inclusive,exact:!1,message:o.message}),n.dirty()}else if(o.kind==="max"){if(o.inclusive?e.data>o.value:e.data>=o.value)r=this._getOrReturnCtx(e,r),h(r,{code:g.too_big,maximum:o.value,type:"number",inclusive:o.inclusive,exact:!1,message:o.message}),n.dirty()}else if(o.kind==="multipleOf"){if(jx(e.data,o.value)!==0)r=this._getOrReturnCtx(e,r),h(r,{code:g.not_multiple_of,multipleOf:o.value,message:o.message}),n.dirty()}else if(o.kind==="finite"){if(!Number.isFinite(e.data))r=this._getOrReturnCtx(e,r),h(r,{code:g.not_finite,message:o.message}),n.dirty()}else L.assertNever(o);return{status:n.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,F.toString(t))}gt(e,t){return this.setLimit("min",e,!1,F.toString(t))}lte(e,t){return this.setLimit("max",e,!0,F.toString(t))}lt(e,t){return this.setLimit("max",e,!1,F.toString(t))}setLimit(e,t,r,n){return new yr({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:r,message:F.toString(n)}]})}_addCheck(e){return new yr({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:F.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:F.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:F.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:F.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:F.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:F.toString(t)})}finite(e){return this._addCheck({kind:"finite",message:F.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:F.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:F.toString(e)})}get minValue(){let e=null;for(let t of this._def.checks)if(t.kind==="min"){if(e===null||t.value>e)e=t.value}return e}get maxValue(){let e=null;for(let t of this._def.checks)if(t.kind==="max"){if(e===null||t.value<e)e=t.value}return e}get isInt(){return!!this._def.checks.find((e)=>e.kind==="int"||e.kind==="multipleOf"&&L.isInteger(e.value))}get isFinite(){let e=null,t=null;for(let r of this._def.checks)if(r.kind==="finite"||r.kind==="int"||r.kind==="multipleOf")return!0;else if(r.kind==="min"){if(t===null||r.value>t)t=r.value}else if(r.kind==="max"){if(e===null||r.value<e)e=r.value}return Number.isFinite(t)&&Number.isFinite(e)}}yr.create=(e)=>new yr({checks:[],typeName:A.ZodNumber,coerce:e?.coerce||!1,...S(e)});class xr extends U{constructor(){super(...arguments);this.min=this.gte,this.max=this.lte}_parse(e){if(this._def.coerce)try{e.data=BigInt(e.data)}catch{return this._getInvalidInput(e)}if(this._getType(e)!==O.bigint)return this._getInvalidInput(e);let r=void 0,n=new ke;for(let o of this._def.checks)if(o.kind==="min"){if(o.inclusive?e.data<o.value:e.data<=o.value)r=this._getOrReturnCtx(e,r),h(r,{code:g.too_small,type:"bigint",minimum:o.value,inclusive:o.inclusive,message:o.message}),n.dirty()}else if(o.kind==="max"){if(o.inclusive?e.data>o.value:e.data>=o.value)r=this._getOrReturnCtx(e,r),h(r,{code:g.too_big,type:"bigint",maximum:o.value,inclusive:o.inclusive,message:o.message}),n.dirty()}else if(o.kind==="multipleOf"){if(e.data%o.value!==BigInt(0))r=this._getOrReturnCtx(e,r),h(r,{code:g.not_multiple_of,multipleOf:o.value,message:o.message}),n.dirty()}else L.assertNever(o);return{status:n.value,value:e.data}}_getInvalidInput(e){let t=this._getOrReturnCtx(e);return h(t,{code:g.invalid_type,expected:O.bigint,received:t.parsedType}),T}gte(e,t){return this.setLimit("min",e,!0,F.toString(t))}gt(e,t){return this.setLimit("min",e,!1,F.toString(t))}lte(e,t){return this.setLimit("max",e,!0,F.toString(t))}lt(e,t){return this.setLimit("max",e,!1,F.toString(t))}setLimit(e,t,r,n){return new xr({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:r,message:F.toString(n)}]})}_addCheck(e){return new xr({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:F.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:F.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:F.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:F.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:F.toString(t)})}get minValue(){let e=null;for(let t of this._def.checks)if(t.kind==="min"){if(e===null||t.value>e)e=t.value}return e}get maxValue(){let e=null;for(let t of this._def.checks)if(t.kind==="max"){if(e===null||t.value<e)e=t.value}return e}}xr.create=(e)=>new xr({checks:[],typeName:A.ZodBigInt,coerce:e?.coerce??!1,...S(e)});class wn extends U{_parse(e){if(this._def.coerce)e.data=Boolean(e.data);if(this._getType(e)!==O.boolean){let r=this._getOrReturnCtx(e);return h(r,{code:g.invalid_type,expected:O.boolean,received:r.parsedType}),T}return je(e.data)}}wn.create=(e)=>new wn({typeName:A.ZodBoolean,coerce:e?.coerce||!1,...S(e)});class Lr extends U{_parse(e){if(this._def.coerce)e.data=new Date(e.data);if(this._getType(e)!==O.date){let o=this._getOrReturnCtx(e);return h(o,{code:g.invalid_type,expected:O.date,received:o.parsedType}),T}if(Number.isNaN(e.data.getTime())){let o=this._getOrReturnCtx(e);return h(o,{code:g.invalid_date}),T}let r=new ke,n=void 0;for(let o of this._def.checks)if(o.kind==="min"){if(e.data.getTime()<o.value)n=this._getOrReturnCtx(e,n),h(n,{code:g.too_small,message:o.message,inclusive:!0,exact:!1,minimum:o.value,type:"date"}),r.dirty()}else if(o.kind==="max"){if(e.data.getTime()>o.value)n=this._getOrReturnCtx(e,n),h(n,{code:g.too_big,message:o.message,inclusive:!0,exact:!1,maximum:o.value,type:"date"}),r.dirty()}else L.assertNever(o);return{status:r.value,value:new Date(e.data.getTime())}}_addCheck(e){return new Lr({...this._def,checks:[...this._def.checks,e]})}min(e,t){return this._addCheck({kind:"min",value:e.getTime(),message:F.toString(t)})}max(e,t){return this._addCheck({kind:"max",value:e.getTime(),message:F.toString(t)})}get minDate(){let e=null;for(let t of this._def.checks)if(t.kind==="min"){if(e===null||t.value>e)e=t.value}return e!=null?new Date(e):null}get maxDate(){let e=null;for(let t of this._def.checks)if(t.kind==="max"){if(e===null||t.value<e)e=t.value}return e!=null?new Date(e):null}}Lr.create=(e)=>new Lr({checks:[],coerce:e?.coerce||!1,typeName:A.ZodDate,...S(e)});class eo extends U{_parse(e){if(this._getType(e)!==O.symbol){let r=this._getOrReturnCtx(e);return h(r,{code:g.invalid_type,expected:O.symbol,received:r.parsedType}),T}return je(e.data)}}eo.create=(e)=>new eo({typeName:A.ZodSymbol,...S(e)});class Fn extends U{_parse(e){if(this._getType(e)!==O.undefined){let r=this._getOrReturnCtx(e);return h(r,{code:g.invalid_type,expected:O.undefined,received:r.parsedType}),T}return je(e.data)}}Fn.create=(e)=>new Fn({typeName:A.ZodUndefined,...S(e)});class Pn extends U{_parse(e){if(this._getType(e)!==O.null){let r=this._getOrReturnCtx(e);return h(r,{code:g.invalid_type,expected:O.null,received:r.parsedType}),T}return je(e.data)}}Pn.create=(e)=>new Pn({typeName:A.ZodNull,...S(e)});class Br extends U{constructor(){super(...arguments);this._any=!0}_parse(e){return je(e.data)}}Br.create=(e)=>new Br({typeName:A.ZodAny,...S(e)});class lr extends U{constructor(){super(...arguments);this._unknown=!0}_parse(e){return je(e.data)}}lr.create=(e)=>new lr({typeName:A.ZodUnknown,...S(e)});class jt extends U{_parse(e){let t=this._getOrReturnCtx(e);return h(t,{code:g.invalid_type,expected:O.never,received:t.parsedType}),T}}jt.create=(e)=>new jt({typeName:A.ZodNever,...S(e)});class to extends U{_parse(e){if(this._getType(e)!==O.undefined){let r=this._getOrReturnCtx(e);return h(r,{code:g.invalid_type,expected:O.void,received:r.parsedType}),T}return je(e.data)}}to.create=(e)=>new to({typeName:A.ZodVoid,...S(e)});class Rt extends U{_parse(e){let{ctx:t,status:r}=this._processInputParams(e),n=this._def;if(t.parsedType!==O.array)return h(t,{code:g.invalid_type,expected:O.array,received:t.parsedType}),T;if(n.exactLength!==null){let i=t.data.length>n.exactLength.value,s=t.data.length<n.exactLength.value;if(i||s)h(t,{code:i?g.too_big:g.too_small,minimum:s?n.exactLength.value:void 0,maximum:i?n.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:n.exactLength.message}),r.dirty()}if(n.minLength!==null){if(t.data.length<n.minLength.value)h(t,{code:g.too_small,minimum:n.minLength.value,type:"array",inclusive:!0,exact:!1,message:n.minLength.message}),r.dirty()}if(n.maxLength!==null){if(t.data.length>n.maxLength.value)h(t,{code:g.too_big,maximum:n.maxLength.value,type:"array",inclusive:!0,exact:!1,message:n.maxLength.message}),r.dirty()}if(t.common.async)return Promise.all([...t.data].map((i,s)=>n.type._parseAsync(new Ft(t,i,t.path,s)))).then((i)=>ke.mergeArray(r,i));let o=[...t.data].map((i,s)=>n.type._parseSync(new Ft(t,i,t.path,s)));return ke.mergeArray(r,o)}get element(){return this._def.type}min(e,t){return new Rt({...this._def,minLength:{value:e,message:F.toString(t)}})}max(e,t){return new Rt({...this._def,maxLength:{value:e,message:F.toString(t)}})}length(e,t){return new Rt({...this._def,exactLength:{value:e,message:F.toString(t)}})}nonempty(e){return this.min(1,e)}}Rt.create=(e,t)=>new Rt({type:e,minLength:null,maxLength:null,exactLength:null,typeName:A.ZodArray,...S(t)});function $n(e){if(e instanceof pe){let t={};for(let r in e.shape){let n=e.shape[r];t[r]=wt.create($n(n))}return new pe({...e._def,shape:()=>t})}else if(e instanceof Rt)return new Rt({...e._def,type:$n(e.element)});else if(e instanceof wt)return wt.create($n(e.unwrap()));else if(e instanceof Qt)return Qt.create($n(e.unwrap()));else if(e instanceof Ut)return Ut.create(e.items.map((t)=>$n(t)));else return e}class pe extends U{constructor(){super(...arguments);this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;let e=this._def.shape(),t=L.objectKeys(e);return this._cached={shape:e,keys:t},this._cached}_parse(e){if(this._getType(e)!==O.object){let c=this._getOrReturnCtx(e);return h(c,{code:g.invalid_type,expected:O.object,received:c.parsedType}),T}let{status:r,ctx:n}=this._processInputParams(e),{shape:o,keys:i}=this._getCached(),s=[];if(!(this._def.catchall instanceof jt&&this._def.unknownKeys==="strip")){for(let c in n.data)if(!i.includes(c))s.push(c)}let a=[];for(let c of i){let m=o[c],x=n.data[c];a.push({key:{status:"valid",value:c},value:m._parse(new Ft(n,x,n.path,c)),alwaysSet:c in n.data})}if(this._def.catchall instanceof jt){let c=this._def.unknownKeys;if(c==="passthrough")for(let m of s)a.push({key:{status:"valid",value:m},value:{status:"valid",value:n.data[m]}});else if(c==="strict"){if(s.length>0)h(n,{code:g.unrecognized_keys,keys:s}),r.dirty()}else if(c==="strip");else throw Error("Internal ZodObject error: invalid unknownKeys value.")}else{let c=this._def.catchall;for(let m of s){let x=n.data[m];a.push({key:{status:"valid",value:m},value:c._parse(new Ft(n,x,n.path,m)),alwaysSet:m in n.data})}}if(n.common.async)return Promise.resolve().then(async()=>{let c=[];for(let m of a){let x=await m.key,I=await m.value;c.push({key:x,value:I,alwaysSet:m.alwaysSet})}return c}).then((c)=>ke.mergeObjectSync(r,c));else return ke.mergeObjectSync(r,a)}get shape(){return this._def.shape()}strict(e){return F.errToObj,new pe({...this._def,unknownKeys:"strict",...e!==void 0?{errorMap:(t,r)=>{let n=this._def.errorMap?.(t,r).message??r.defaultError;if(t.code==="unrecognized_keys")return{message:F.errToObj(e).message??n};return{message:n}}}:{}})}strip(){return new pe({...this._def,unknownKeys:"strip"})}passthrough(){return new pe({...this._def,unknownKeys:"passthrough"})}extend(e){return new pe({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new pe({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:A.ZodObject})}setKey(e,t){return this.augment({[e]:t})}catchall(e){return new pe({...this._def,catchall:e})}pick(e){let t={};for(let r of L.objectKeys(e))if(e[r]&&this.shape[r])t[r]=this.shape[r];return new pe({...this._def,shape:()=>t})}omit(e){let t={};for(let r of L.objectKeys(this.shape))if(!e[r])t[r]=this.shape[r];return new pe({...this._def,shape:()=>t})}deepPartial(){return $n(this)}partial(e){let t={};for(let r of L.objectKeys(this.shape)){let n=this.shape[r];if(e&&!e[r])t[r]=n;else t[r]=n.optional()}return new pe({...this._def,shape:()=>t})}required(e){let t={};for(let r of L.objectKeys(this.shape))if(e&&!e[r])t[r]=this.shape[r];else{let o=this.shape[r];while(o instanceof wt)o=o._def.innerType;t[r]=o}return new pe({...this._def,shape:()=>t})}keyof(){return Fc(L.objectKeys(this.shape))}}pe.create=(e,t)=>new pe({shape:()=>e,unknownKeys:"strip",catchall:jt.create(),typeName:A.ZodObject,...S(t)});pe.strictCreate=(e,t)=>new pe({shape:()=>e,unknownKeys:"strict",catchall:jt.create(),typeName:A.ZodObject,...S(t)});pe.lazycreate=(e,t)=>new pe({shape:e,unknownKeys:"strip",catchall:jt.create(),typeName:A.ZodObject,...S(t)});class Tn extends U{_parse(e){let{ctx:t}=this._processInputParams(e),r=this._def.options;function n(o){for(let s of o)if(s.result.status==="valid")return s.result;for(let s of o)if(s.result.status==="dirty")return t.common.issues.push(...s.ctx.common.issues),s.result;let i=o.map((s)=>new qe(s.ctx.common.issues));return h(t,{code:g.invalid_union,unionErrors:i}),T}if(t.common.async)return Promise.all(r.map(async(o)=>{let i={...t,common:{...t.common,issues:[]},parent:null};return{result:await o._parseAsync({data:t.data,path:t.path,parent:i}),ctx:i}})).then(n);else{let o=void 0,i=[];for(let a of r){let c={...t,common:{...t.common,issues:[]},parent:null},m=a._parseSync({data:t.data,path:t.path,parent:c});if(m.status==="valid")return m;else if(m.status==="dirty"&&!o)o={result:m,ctx:c};if(c.common.issues.length)i.push(c.common.issues)}if(o)return t.common.issues.push(...o.ctx.common.issues),o.result;let s=i.map((a)=>new qe(a));return h(t,{code:g.invalid_union,unionErrors:s}),T}}get options(){return this._def.options}}Tn.create=(e,t)=>new Tn({options:e,typeName:A.ZodUnion,...S(t)});var Xt=(e)=>{if(e instanceof kn)return Xt(e.schema);else if(e instanceof Pt)return Xt(e.innerType());else if(e instanceof Cn)return[e.value];else if(e instanceof gr)return e.options;else if(e instanceof Nn)return L.objectValues(e.enum);else if(e instanceof Sn)return Xt(e._def.innerType);else if(e instanceof Fn)return[void 0];else if(e instanceof Pn)return[null];else if(e instanceof wt)return[void 0,...Xt(e.unwrap())];else if(e instanceof Qt)return[null,...Xt(e.unwrap())];else if(e instanceof ii)return Xt(e.unwrap());else if(e instanceof jn)return Xt(e.unwrap());else if(e instanceof Mn)return Xt(e._def.innerType);else return[]};class oi extends U{_parse(e){let{ctx:t}=this._processInputParams(e);if(t.parsedType!==O.object)return h(t,{code:g.invalid_type,expected:O.object,received:t.parsedType}),T;let r=this.discriminator,n=t.data[r],o=this.optionsMap.get(n);if(!o)return h(t,{code:g.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[r]}),T;if(t.common.async)return o._parseAsync({data:t.data,path:t.path,parent:t});else return o._parseSync({data:t.data,path:t.path,parent:t})}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,t,r){let n=new Map;for(let o of t){let i=Xt(o.shape[e]);if(!i.length)throw Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);for(let s of i){if(n.has(s))throw Error(`Discriminator property ${String(e)} has duplicate value ${String(s)}`);n.set(s,o)}}return new oi({typeName:A.ZodDiscriminatedUnion,discriminator:e,options:t,optionsMap:n,...S(r)})}}function Qi(e,t){let r=Mt(e),n=Mt(t);if(e===t)return{valid:!0,data:e};else if(r===O.object&&n===O.object){let o=L.objectKeys(t),i=L.objectKeys(e).filter((a)=>o.indexOf(a)!==-1),s={...e,...t};for(let a of i){let c=Qi(e[a],t[a]);if(!c.valid)return{valid:!1};s[a]=c.data}return{valid:!0,data:s}}else if(r===O.array&&n===O.array){if(e.length!==t.length)return{valid:!1};let o=[];for(let i=0;i<e.length;i++){let s=e[i],a=t[i],c=Qi(s,a);if(!c.valid)return{valid:!1};o.push(c.data)}return{valid:!0,data:o}}else if(r===O.date&&n===O.date&&+e===+t)return{valid:!0,data:e};else return{valid:!1}}class An extends U{_parse(e){let{status:t,ctx:r}=this._processInputParams(e),n=(o,i)=>{if(ri(o)||ri(i))return T;let s=Qi(o.value,i.value);if(!s.valid)return h(r,{code:g.invalid_intersection_types}),T;if(ni(o)||ni(i))t.dirty();return{status:t.value,value:s.data}};if(r.common.async)return Promise.all([this._def.left._parseAsync({data:r.data,path:r.path,parent:r}),this._def.right._parseAsync({data:r.data,path:r.path,parent:r})]).then(([o,i])=>n(o,i));else return n(this._def.left._parseSync({data:r.data,path:r.path,parent:r}),this._def.right._parseSync({data:r.data,path:r.path,parent:r}))}}An.create=(e,t,r)=>new An({left:e,right:t,typeName:A.ZodIntersection,...S(r)});class Ut extends U{_parse(e){let{status:t,ctx:r}=this._processInputParams(e);if(r.parsedType!==O.array)return h(r,{code:g.invalid_type,expected:O.array,received:r.parsedType}),T;if(r.data.length<this._def.items.length)return h(r,{code:g.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),T;if(!this._def.rest&&r.data.length>this._def.items.length)h(r,{code:g.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),t.dirty();let o=[...r.data].map((i,s)=>{let a=this._def.items[s]||this._def.rest;if(!a)return null;return a._parse(new Ft(r,i,r.path,s))}).filter((i)=>!!i);if(r.common.async)return Promise.all(o).then((i)=>ke.mergeArray(t,i));else return ke.mergeArray(t,o)}get items(){return this._def.items}rest(e){return new Ut({...this._def,rest:e})}}Ut.create=(e,t)=>{if(!Array.isArray(e))throw Error("You must pass an array of schemas to z.tuple([ ... ])");return new Ut({items:e,typeName:A.ZodTuple,rest:null,...S(t)})};class ro extends U{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:t,ctx:r}=this._processInputParams(e);if(r.parsedType!==O.object)return h(r,{code:g.invalid_type,expected:O.object,received:r.parsedType}),T;let n=[],o=this._def.keyType,i=this._def.valueType;for(let s in r.data)n.push({key:o._parse(new Ft(r,s,r.path,s)),value:i._parse(new Ft(r,r.data[s],r.path,s)),alwaysSet:s in r.data});if(r.common.async)return ke.mergeObjectAsync(t,n);else return ke.mergeObjectSync(t,n)}get element(){return this._def.valueType}static create(e,t,r){if(t instanceof U)return new ro({keyType:e,valueType:t,typeName:A.ZodRecord,...S(r)});return new ro({keyType:$t.create(),valueType:e,typeName:A.ZodRecord,...S(t)})}}class no extends U{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:t,ctx:r}=this._processInputParams(e);if(r.parsedType!==O.map)return h(r,{code:g.invalid_type,expected:O.map,received:r.parsedType}),T;let n=this._def.keyType,o=this._def.valueType,i=[...r.data.entries()].map(([s,a],c)=>({key:n._parse(new Ft(r,s,r.path,[c,"key"])),value:o._parse(new Ft(r,a,r.path,[c,"value"]))}));if(r.common.async){let s=new Map;return Promise.resolve().then(async()=>{for(let a of i){let c=await a.key,m=await a.value;if(c.status==="aborted"||m.status==="aborted")return T;if(c.status==="dirty"||m.status==="dirty")t.dirty();s.set(c.value,m.value)}return{status:t.value,value:s}})}else{let s=new Map;for(let a of i){let{key:c,value:m}=a;if(c.status==="aborted"||m.status==="aborted")return T;if(c.status==="dirty"||m.status==="dirty")t.dirty();s.set(c.value,m.value)}return{status:t.value,value:s}}}}no.create=(e,t,r)=>new no({valueType:t,keyType:e,typeName:A.ZodMap,...S(r)});class Gr extends U{_parse(e){let{status:t,ctx:r}=this._processInputParams(e);if(r.parsedType!==O.set)return h(r,{code:g.invalid_type,expected:O.set,received:r.parsedType}),T;let n=this._def;if(n.minSize!==null){if(r.data.size<n.minSize.value)h(r,{code:g.too_small,minimum:n.minSize.value,type:"set",inclusive:!0,exact:!1,message:n.minSize.message}),t.dirty()}if(n.maxSize!==null){if(r.data.size>n.maxSize.value)h(r,{code:g.too_big,maximum:n.maxSize.value,type:"set",inclusive:!0,exact:!1,message:n.maxSize.message}),t.dirty()}let o=this._def.valueType;function i(a){let c=new Set;for(let m of a){if(m.status==="aborted")return T;if(m.status==="dirty")t.dirty();c.add(m.value)}return{status:t.value,value:c}}let s=[...r.data.values()].map((a,c)=>o._parse(new Ft(r,a,r.path,c)));if(r.common.async)return Promise.all(s).then((a)=>i(a));else return i(s)}min(e,t){return new Gr({...this._def,minSize:{value:e,message:F.toString(t)}})}max(e,t){return new Gr({...this._def,maxSize:{value:e,message:F.toString(t)}})}size(e,t){return this.min(e,t).max(e,t)}nonempty(e){return this.min(1,e)}}Gr.create=(e,t)=>new Gr({valueType:e,minSize:null,maxSize:null,typeName:A.ZodSet,...S(t)});class Rn extends U{constructor(){super(...arguments);this.validate=this.implement}_parse(e){let{ctx:t}=this._processInputParams(e);if(t.parsedType!==O.function)return h(t,{code:g.invalid_type,expected:O.function,received:t.parsedType}),T;function r(s,a){return Zn({data:s,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,_n(),Yt].filter((c)=>!!c),issueData:{code:g.invalid_arguments,argumentsError:a}})}function n(s,a){return Zn({data:s,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,_n(),Yt].filter((c)=>!!c),issueData:{code:g.invalid_return_type,returnTypeError:a}})}let o={errorMap:t.common.contextualErrorMap},i=t.data;if(this._def.returns instanceof Dr){let s=this;return je(async function(...a){let c=new qe([]),m=await s._def.args.parseAsync(a,o).catch((k)=>{throw c.addIssue(r(a,k)),c}),x=await Reflect.apply(i,this,m);return await s._def.returns._def.type.parseAsync(x,o).catch((k)=>{throw c.addIssue(n(x,k)),c})})}else{let s=this;return je(function(...a){let c=s._def.args.safeParse(a,o);if(!c.success)throw new qe([r(a,c.error)]);let m=Reflect.apply(i,this,c.data),x=s._def.returns.safeParse(m,o);if(!x.success)throw new qe([n(m,x.error)]);return x.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new Rn({...this._def,args:Ut.create(e).rest(lr.create())})}returns(e){return new Rn({...this._def,returns:e})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,t,r){return new Rn({args:e?e:Ut.create([]).rest(lr.create()),returns:t||lr.create(),typeName:A.ZodFunction,...S(r)})}}class kn extends U{get schema(){return this._def.getter()}_parse(e){let{ctx:t}=this._processInputParams(e);return this._def.getter()._parse({data:t.data,path:t.path,parent:t})}}kn.create=(e,t)=>new kn({getter:e,typeName:A.ZodLazy,...S(t)});class Cn extends U{_parse(e){if(e.data!==this._def.value){let t=this._getOrReturnCtx(e);return h(t,{received:t.data,code:g.invalid_literal,expected:this._def.value}),T}return{status:"valid",value:e.data}}get value(){return this._def.value}}Cn.create=(e,t)=>new Cn({value:e,typeName:A.ZodLiteral,...S(t)});function Fc(e,t){return new gr({values:e,typeName:A.ZodEnum,...S(t)})}class gr extends U{_parse(e){if(typeof e.data!=="string"){let t=this._getOrReturnCtx(e),r=this._def.values;return h(t,{expected:L.joinValues(r),received:t.parsedType,code:g.invalid_type}),T}if(!this._cache)this._cache=new Set(this._def.values);if(!this._cache.has(e.data)){let t=this._getOrReturnCtx(e),r=this._def.values;return h(t,{received:t.data,code:g.invalid_enum_value,options:r}),T}return je(e.data)}get options(){return this._def.values}get enum(){let e={};for(let t of this._def.values)e[t]=t;return e}get Values(){let e={};for(let t of this._def.values)e[t]=t;return e}get Enum(){let e={};for(let t of this._def.values)e[t]=t;return e}extract(e,t=this._def){return gr.create(e,{...this._def,...t})}exclude(e,t=this._def){return gr.create(this.options.filter((r)=>!e.includes(r)),{...this._def,...t})}}gr.create=Fc;class Nn extends U{_parse(e){let t=L.getValidEnumValues(this._def.values),r=this._getOrReturnCtx(e);if(r.parsedType!==O.string&&r.parsedType!==O.number){let n=L.objectValues(t);return h(r,{expected:L.joinValues(n),received:r.parsedType,code:g.invalid_type}),T}if(!this._cache)this._cache=new Set(L.getValidEnumValues(this._def.values));if(!this._cache.has(e.data)){let n=L.objectValues(t);return h(r,{received:r.data,code:g.invalid_enum_value,options:n}),T}return je(e.data)}get enum(){return this._def.values}}Nn.create=(e,t)=>new Nn({values:e,typeName:A.ZodNativeEnum,...S(t)});class Dr extends U{unwrap(){return this._def.type}_parse(e){let{ctx:t}=this._processInputParams(e);if(t.parsedType!==O.promise&&t.common.async===!1)return h(t,{code:g.invalid_type,expected:O.promise,received:t.parsedType}),T;let r=t.parsedType===O.promise?t.data:Promise.resolve(t.data);return je(r.then((n)=>this._def.type.parseAsync(n,{path:t.path,errorMap:t.common.contextualErrorMap})))}}Dr.create=(e,t)=>new Dr({type:e,typeName:A.ZodPromise,...S(t)});class Pt extends U{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===A.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){let{status:t,ctx:r}=this._processInputParams(e),n=this._def.effect||null,o={addIssue:(i)=>{if(h(r,i),i.fatal)t.abort();else t.dirty()},get path(){return r.path}};if(o.addIssue=o.addIssue.bind(o),n.type==="preprocess"){let i=n.transform(r.data,o);if(r.common.async)return Promise.resolve(i).then(async(s)=>{if(t.value==="aborted")return T;let a=await this._def.schema._parseAsync({data:s,path:r.path,parent:r});if(a.status==="aborted")return T;if(a.status==="dirty")return Kr(a.value);if(t.value==="dirty")return Kr(a.value);return a});else{if(t.value==="aborted")return T;let s=this._def.schema._parseSync({data:i,path:r.path,parent:r});if(s.status==="aborted")return T;if(s.status==="dirty")return Kr(s.value);if(t.value==="dirty")return Kr(s.value);return s}}if(n.type==="refinement"){let i=(s)=>{let a=n.refinement(s,o);if(r.common.async)return Promise.resolve(a);if(a instanceof Promise)throw Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return s};if(r.common.async===!1){let s=this._def.schema._parseSync({data:r.data,path:r.path,parent:r});if(s.status==="aborted")return T;if(s.status==="dirty")t.dirty();return i(s.value),{status:t.value,value:s.value}}else return this._def.schema._parseAsync({data:r.data,path:r.path,parent:r}).then((s)=>{if(s.status==="aborted")return T;if(s.status==="dirty")t.dirty();return i(s.value).then(()=>({status:t.value,value:s.value}))})}if(n.type==="transform")if(r.common.async===!1){let i=this._def.schema._parseSync({data:r.data,path:r.path,parent:r});if(!pr(i))return T;let s=n.transform(i.value,o);if(s instanceof Promise)throw Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:t.value,value:s}}else return this._def.schema._parseAsync({data:r.data,path:r.path,parent:r}).then((i)=>{if(!pr(i))return T;return Promise.resolve(n.transform(i.value,o)).then((s)=>({status:t.value,value:s}))});L.assertNever(n)}}Pt.create=(e,t,r)=>new Pt({schema:e,typeName:A.ZodEffects,effect:t,...S(r)});Pt.createWithPreprocess=(e,t,r)=>new Pt({schema:t,effect:{type:"preprocess",transform:e},typeName:A.ZodEffects,...S(r)});class wt extends U{_parse(e){if(this._getType(e)===O.undefined)return je(void 0);return this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}wt.create=(e,t)=>new wt({innerType:e,typeName:A.ZodOptional,...S(t)});class Qt extends U{_parse(e){if(this._getType(e)===O.null)return je(null);return this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}Qt.create=(e,t)=>new Qt({innerType:e,typeName:A.ZodNullable,...S(t)});class Sn extends U{_parse(e){let{ctx:t}=this._processInputParams(e),r=t.data;if(t.parsedType===O.undefined)r=this._def.defaultValue();return this._def.innerType._parse({data:r,path:t.path,parent:t})}removeDefault(){return this._def.innerType}}Sn.create=(e,t)=>new Sn({innerType:e,typeName:A.ZodDefault,defaultValue:typeof t.default==="function"?t.default:()=>t.default,...S(t)});class Mn extends U{_parse(e){let{ctx:t}=this._processInputParams(e),r={...t,common:{...t.common,issues:[]}},n=this._def.innerType._parse({data:r.data,path:r.path,parent:{...r}});if(On(n))return n.then((o)=>({status:"valid",value:o.status==="valid"?o.value:this._def.catchValue({get error(){return new qe(r.common.issues)},input:r.data})}));else return{status:"valid",value:n.status==="valid"?n.value:this._def.catchValue({get error(){return new qe(r.common.issues)},input:r.data})}}removeCatch(){return this._def.innerType}}Mn.create=(e,t)=>new Mn({innerType:e,typeName:A.ZodCatch,catchValue:typeof t.catch==="function"?t.catch:()=>t.catch,...S(t)});class oo extends U{_parse(e){if(this._getType(e)!==O.nan){let r=this._getOrReturnCtx(e);return h(r,{code:g.invalid_type,expected:O.nan,received:r.parsedType}),T}return{status:"valid",value:e.data}}}oo.create=(e)=>new oo({typeName:A.ZodNaN,...S(e)});var Ux=Symbol("zod_brand");class ii extends U{_parse(e){let{ctx:t}=this._processInputParams(e),r=t.data;return this._def.type._parse({data:r,path:t.path,parent:t})}unwrap(){return this._def.type}}class io extends U{_parse(e){let{status:t,ctx:r}=this._processInputParams(e);if(r.common.async)return(async()=>{let o=await this._def.in._parseAsync({data:r.data,path:r.path,parent:r});if(o.status==="aborted")return T;if(o.status==="dirty")return t.dirty(),Kr(o.value);else return this._def.out._parseAsync({data:o.value,path:r.path,parent:r})})();else{let n=this._def.in._parseSync({data:r.data,path:r.path,parent:r});if(n.status==="aborted")return T;if(n.status==="dirty")return t.dirty(),{status:"dirty",value:n.value};else return this._def.out._parseSync({data:n.value,path:r.path,parent:r})}}static create(e,t){return new io({in:e,out:t,typeName:A.ZodPipeline})}}class jn extends U{_parse(e){let t=this._def.innerType._parse(e),r=(n)=>{if(pr(n))n.value=Object.freeze(n.value);return n};return On(t)?t.then((n)=>r(n)):r(t)}unwrap(){return this._def.innerType}}jn.create=(e,t)=>new jn({innerType:e,typeName:A.ZodReadonly,...S(t)});function Oc(e,t){let r=typeof e==="function"?e(t):typeof e==="string"?{message:e}:e;return typeof r==="string"?{message:r}:r}function Pc(e,t={},r){if(e)return Br.create().superRefine((n,o)=>{let i=e(n);if(i instanceof Promise)return i.then((s)=>{if(!s){let a=Oc(t,n),c=a.fatal??r??!0;o.addIssue({code:"custom",...a,fatal:c})}});if(!i){let s=Oc(t,n),a=s.fatal??r??!0;o.addIssue({code:"custom",...s,fatal:a})}return});return Br.create()}var Ex={object:pe.lazycreate},A;(function(e){e.ZodString="ZodString",e.ZodNumber="ZodNumber",e.ZodNaN="ZodNaN",e.ZodBigInt="ZodBigInt",e.ZodBoolean="ZodBoolean",e.ZodDate="ZodDate",e.ZodSymbol="ZodSymbol",e.ZodUndefined="ZodUndefined",e.ZodNull="ZodNull",e.ZodAny="ZodAny",e.ZodUnknown="ZodUnknown",e.ZodNever="ZodNever",e.ZodVoid="ZodVoid",e.ZodArray="ZodArray",e.ZodObject="ZodObject",e.ZodUnion="ZodUnion",e.ZodDiscriminatedUnion="ZodDiscriminatedUnion",e.ZodIntersection="ZodIntersection",e.ZodTuple="ZodTuple",e.ZodRecord="ZodRecord",e.ZodMap="ZodMap",e.ZodSet="ZodSet",e.ZodFunction="ZodFunction",e.ZodLazy="ZodLazy",e.ZodLiteral="ZodLiteral",e.ZodEnum="ZodEnum",e.ZodEffects="ZodEffects",e.ZodNativeEnum="ZodNativeEnum",e.ZodOptional="ZodOptional",e.ZodNullable="ZodNullable",e.ZodDefault="ZodDefault",e.ZodCatch="ZodCatch",e.ZodPromise="ZodPromise",e.ZodBranded="ZodBranded",e.ZodPipeline="ZodPipeline",e.ZodReadonly="ZodReadonly"})(A||(A={}));var Kx=(e,t={message:`Input not instance of ${e.name}`})=>Pc((r)=>r instanceof e,t),Tc=$t.create,Ac=yr.create,Lx=oo.create,Bx=xr.create,kc=wn.create,Gx=Lr.create,Dx=eo.create,vx=Fn.create,qx=Pn.create,Hx=Br.create,Vx=lr.create,zx=jt.create,Wx=to.create,Jx=Rt.create,{create:Yx,strictCreate:Xx}=pe,Qx=Tn.create,Zx=oi.create,eg=An.create,tg=Ut.create,rg=ro.create,ng=no.create,og=Gr.create,ig=Rn.create,sg=kn.create,ag=Cn.create,cg=gr.create,ug=Nn.create,fg=Dr.create,mg=Pt.create,dg=wt.create,pg=Qt.create,lg=Pt.createWithPreprocess,yg=io.create,xg=()=>Tc().optional(),gg=()=>Ac().optional(),Ig=()=>kc().optional(),hg={string:(e)=>$t.create({...e,coerce:!0}),number:(e)=>yr.create({...e,coerce:!0}),boolean:(e)=>wn.create({...e,coerce:!0}),bigint:(e)=>xr.create({...e,coerce:!0}),date:(e)=>Lr.create({...e,coerce:!0})};var bg=T;var _g=si,vr=(e,t=400)=>Response.json(e,{status:t,headers:{"Content-Type":"application/json"}}),Cc=(e)=>{let t=ti.Compile(e),r=async(n,o)=>{try{let i=await n.jsonBody();if(!t.Check(i)){let s=t.Errors(i).First();return vr({status:"error",code:"VALIDATION_FAILED",message:s?.message||"Invalid input",path:s?.path||"body"})}return n.body=i,o?o():void 0}catch{return vr({status:"error",message:"Malformed JSON payload"})}};return r.__schema=e,r},Nc=(e)=>{let t=e.properties||{},r=Object.keys(t),n=r.length,o=async(i,s)=>{try{let a=i instanceof Object&&"req"in i,c=a?await i.jsonBody():await i.json();if(!c||typeof c!=="object"||Array.isArray(c))return vr({status:"error",message:"Invalid JSON object payload"});for(let m=0;m<n;m++){let x=r[m];if(!Object.hasOwn(c,x)||typeof c[x]!==t[x]?.type)return vr({status:"error",code:"TYPE_MISMATCH",message:`Field '${x}' must be of type ${t[x]?.type}`,field:x})}if(a)i.body=c;return s?s():void 0}catch{return vr({status:"error",message:"Invalid JSON payload"})}};return o.__schema=e,o},Sc=(e)=>{let t=async(r,n)=>{try{let o=r instanceof Object&&"req"in r,i=o?await r.jsonBody():await r.json(),s=await e.safeParseAsync(i);if(!s.success)return vr({status:"error",code:"ZOD_ERROR",errors:s.error.flatten()});if(o)r.body=s.data;return n?n():void 0}catch{return vr({status:"error",message:"Invalid JSON payload"})}};return t.__schema=e,t},Og=(e)=>{if(e&&"_def"in e)return Sc(e);if(e&&(e.kind||e.type||e[Symbol.for("TypeBox.Kind")]))return Cc(e);return Nc(e)};var $g=(e={})=>{let t=e.origin||"*",r=e.methods||"GET,POST,PUT,PATCH,DELETE,OPTIONS",n={"Access-Control-Allow-Origin":t,"Access-Control-Allow-Methods":r,"Access-Control-Allow-Headers":"Content-Type, Authorization"};if(t!=="*")n.Vary="Origin";let o={status:204,headers:n};return(s,a)=>{if(s.req.method==="OPTIONS")return new Response(null,o);if(s.setHeader("Access-Control-Allow-Origin",t),s.setHeader("Access-Control-Allow-Methods",r),t!=="*")s.setHeader("Vary","Origin");let c=a?.();if(c&&typeof c.then==="function")return c.then((m)=>{if(m instanceof Response){if(m.headers.set("Access-Control-Allow-Origin",t),m.headers.set("Access-Control-Allow-Methods",r),t!=="*")m.headers.set("Vary","Origin")}return m});if(c instanceof Response){if(c.headers.set("Access-Control-Allow-Origin",t),c.headers.set("Access-Control-Allow-Methods",r),t!=="*")c.headers.set("Vary","Origin")}return c}};var Rg=(e={})=>{let t=e.windowMs??60000,r=e.max??100,n=e.message??"Too many requests, please try again later.",o=e.maxEntries??1e4,i=e.keyGenerator??((a)=>a.req.headers.get("x-forwarded-for")?.split(",")[0]?.trim()||a.req.headers.get("x-real-ip")||"global"),s=new Map;return(a,c)=>{let m=Date.now(),x=i(a),I=s.get(x);if(!I||m>=I.resetAt){if(s.size>=o){for(let[j,P]of s){if(m>=P.resetAt)s.delete(j);if(s.size<o)break}if(s.size>=o){let j=s.keys().next().value;if(j!==void 0)s.delete(j)}}I={count:1,resetAt:m+t},s.set(x,I)}else I.count++;let k=Math.max(0,r-I.count);if(a.setHeader("X-RateLimit-Limit",String(r)),a.setHeader("X-RateLimit-Remaining",String(k)),a.setHeader("X-RateLimit-Reset",String(Math.ceil(I.resetAt/1000))),I.count>r){let j=Math.max(1,Math.ceil((I.resetAt-m)/1000));return Response.json({status:"error",code:"RATE_LIMITED",message:n},{status:429,headers:{"Retry-After":String(j),"X-RateLimit-Limit":String(r),"X-RateLimit-Remaining":"0","X-RateLimit-Reset":String(Math.ceil(I.resetAt/1000))}})}return c?.()}};var wg=(e={})=>{let t=[];if(e.noSniff!==!1)t.push(["X-Content-Type-Options","nosniff"]);if(e.frameOptions!==!1)t.push(["X-Frame-Options",e.frameOptions??"DENY"]);if(e.referrerPolicy!==!1)t.push(["Referrer-Policy",e.referrerPolicy??"strict-origin-when-cross-origin"]);if(e.hsts!==!1)t.push(["Strict-Transport-Security",e.hsts??"max-age=31536000; includeSubDomains"]);if(e.contentSecurityPolicy)t.push(["Content-Security-Policy",e.contentSecurityPolicy]);t.push(["X-XSS-Protection","0"]);let r=t.length;return(n,o)=>{for(let s=0;s<r;s++){let a=t[s];n.setHeader(a[0],a[1])}let i=o?.();if(i&&typeof i.then==="function")return i.then((s)=>{if(s instanceof Response)for(let a=0;a<r;a++){let c=t[a];if(!s.headers.has(c[0]))s.headers.set(c[0],c[1])}return s});if(i instanceof Response)for(let s=0;s<r;s++){let a=t[s];if(!i.headers.has(a[0]))i.headers.set(a[0],a[1])}return i}};import{resolve as Mc,sep as jc}from"path";var Fg=(e="public")=>{let t=Mc(process.cwd(),e),r=t.endsWith(jc)?t:t+jc;return async(n,o)=>{let i=n.req.method;if(i!=="GET"&&i!=="HEAD")return o();let s=n.req.url,a=s.indexOf("/",8),c=a===-1?-1:s.indexOf("?",a),m=a===-1?"":c===-1?s.slice(a):s.slice(a,c),x;try{x=decodeURIComponent(m)}catch{return n.status(400).send("Bad Request")}if(x.includes("\x00"))return n.status(400).send("Bad Request");let I=x.replace(/^\/+/,""),k=Mc(t,I);if(k!==t&&!k.startsWith(r))return n.status(403).send("Forbidden");let j=Bun.file(k);if(await j.exists())return new Response(j);return o()}};import{createHash as Pg,createHmac as Tg,timingSafeEqual as ts}from"crypto";var Ec=new TextEncoder,Zi=(e)=>typeof e==="string"?Buffer.from(e).toString("base64url"):Buffer.from(e).toString("base64url"),Uc=(e)=>Buffer.from(e,"base64url").toString("utf-8"),es=new Map,Ag=async(e)=>{if(es.has(e))return es.get(e);let t=await crypto.subtle.importKey("raw",Ec.encode(e),{name:"HMAC",hash:"SHA-256"},!1,["sign","verify"]);return es.set(e,t),t},kg=async(e,t)=>{let r=JSON.stringify({alg:"HS256",typ:"JWT"}),n=JSON.stringify(e),o=Zi(r),i=Zi(n),s=`${o}.${i}`,a=await Ag(t),c=await crypto.subtle.sign("HMAC",a,Ec.encode(s)),m=Zi(new Uint8Array(c));return`${s}.${m}`},Cg=(e)=>(t,r)=>{let n=t.req.headers.get("Authorization");if(!n?.startsWith("Bearer "))return t.status(401).send("Bearer token required");let o=n.slice(7),i=o.indexOf("."),s=i===-1?-1:o.indexOf(".",i+1);if(i===-1||s===-1||o.indexOf(".",s+1)!==-1)return t.status(401).send("Malformed JWT token");let a=o.slice(0,i),c=o.slice(i+1,s),m=o.slice(s+1),x=o.slice(0,s);try{let I=Tg("sha256",e).update(x).digest(),k=Buffer.from(m,"base64url");if(k.length!==I.length||!ts(k,I))return t.status(401).send("Invalid signature");let j=JSON.parse(Uc(a));if(!j||j.alg!=="HS256")return t.status(401).send("Unsupported token algorithm");let P=JSON.parse(Uc(c)),ye=Date.now()*0.001;if(typeof P.exp==="number"&&ye>=P.exp)return t.status(401).send("Token expired");if(typeof P.nbf==="number"&&ye<P.nbf)return t.status(401).send("Token not active");if(t.set("user",P),Array.isArray(r)){if(r.length===0)return;let[Tt,...Ir]=r;return Tt(t,Ir)}if(typeof r==="function")return r();return}catch{return t.status(401).send("Token verification failed")}},ai=(e)=>Pg("sha256").update(e).digest(),Ng=(e)=>{let t=ai(e.user),r=ai(e.pass);return async(n,o)=>{let i=n.req.headers.get("Authorization");if(!i?.startsWith("Basic "))return n.status(401).json({status:"error",message:"Basic Auth required"});let s=i.slice(6).trim();if(!s)return n.status(401).json({status:"error",message:"Missing credentials"});let a=Buffer.from(s,"base64").toString("utf-8"),c=a.indexOf(":");if(c===-1)return n.status(401).json({status:"error",message:"Invalid credentials"});let m=a.slice(0,c),x=a.slice(c+1),I=ts(ai(m),t),k=ts(ai(x),r);if(I&&k)return o();return n.status(401).json({status:"error",message:"Invalid credentials"})}},Sg=(e)=>async(t,r)=>{let n=t.get("user");if(!n||n.role!==e)return t.status(403).json({status:"error",message:`Required role: ${e}`});return r()};Qo();var Kc={make:(e)=>Bun.password.hash(e,gn.hash),verify:(e,t)=>Bun.password.verify(e,t),needsRehash:(e)=>{let{algorithm:t,memoryCost:r,timeCost:n}=gn.hash;if(t==="bcrypt"){if(!/^\$2[aby]\$/.test(e))return!0;let s=e.match(/^\$2[aby]\$(\d+)\$/);return!s||Number(s[1])!==n}if(!e.startsWith(`$${t}$`))return!0;let o=e.match(/(?:^|[,$])m=(\d+)(?:[,$]|$)/),i=e.match(/(?:^|[,$])t=(\d+)(?:[,$]|$)/);return!o||Number(o[1])!==r||!i||Number(i[1])!==n}};var Mg=(e,t,r)=>{let n=t;if(r?.params)for(let[a,c]of Object.entries(r.params))n=n.replace(`:${a}`,encodeURIComponent(String(c)));let o=e.endsWith("/")?e.slice(0,-1):e,i=n.startsWith("/")?n:`/${n}`,s=`${o}${i}`;if(r?.query){let a=new URLSearchParams;for(let[m,x]of Object.entries(r.query))if(x!==void 0)a.set(m,String(x));let c=a.toString();if(c)s+=`?${c}`}return s},jg=(e,t={})=>{let r=t.fetch??fetch,n=t.headers??{},o=async(i,s,a)=>{let c=Mg(e,s,a),m={...n,...a?.headers??{}},x={method:i,headers:m};if(a?.body!==void 0&&i!=="GET"&&i!=="HEAD"){if(!m["Content-Type"]&&!m["content-type"])m["Content-Type"]="application/json";x.body=typeof a.body==="string"?a.body:JSON.stringify(a.body)}let I=await r(c,x),j=(I.headers.get("content-type")||"").includes("application/json")?await I.json():await I.text();if(!I.ok){let P=Error(`HTTP ${I.status}`);throw P.status=I.status,P.data=j,P}return j};return{get:(i,s)=>o("GET",i,s),post:(i,s)=>o("POST",i,s),put:(i,s)=>o("PUT",i,s),patch:(i,s)=>o("PATCH",i,s),delete:(i,s)=>o("DELETE",i,s)}};export{nc as BareJS,zr as BareRouter,Kc as Hash,Kc as Password,Vp as T,Vp as Type,Vp as TypeBox,_g as Z,_g as Zod,Cg as bareAuth,jg as bareClient,Ng as basicAuth,$g as cors,kg as createToken,Gi as generateOpenAPISpec,Sg as hasRole,Nc as n,Nc as native,Rg as rateLimit,Di as renderDocsHTML,wg as securityHeaders,Fg as staticFile,Cc as t,Cc as typebox,Og as v,Og as validate,Sc as z,Sc as zod};
|
|
224
|
+
\x1B[90m\u2699\uFE0F Pool Size: ${this.pool.length} | JIT: Enabled | Port: ${i}\x1B[0m
|
|
225
|
+
\x1B[36m\uD83D\uDEE1\uFE0F Hash: ${s.hash.algorithm} (${s.hash.memoryCost/1024}MB) | Iterations: ${s.hash.timeCost}\x1B[0m
|
|
226
|
+
`);let c=this.wsRoutes,u=this.fetch,l=c.size>0?Bun.serve({port:i,hostname:t,reusePort:r,maxRequestBodySize:o,fetch(b,T){if(b.headers.get("upgrade")?.toLowerCase()==="websocket"){let C=b.url,Q=C.indexOf("/",8),le=Q===-1?-1:C.indexOf("?",Q),q=Q===-1?"/":le===-1?C.slice(Q):C.slice(Q,le),Ge=q.length>1&&q.endsWith("/")?q.slice(0,-1):q,ye=c.get(Ge),W;if(!ye){let Me=Ge.split("/").filter(Boolean);for(let[$e,Pe]of c){if(!$e.includes(":")&&!$e.includes("*"))continue;let A=$e.split("/").filter(Boolean),Z={},Qe=!0;for(let te=0;te<A.length;te++){let U=A[te];if(U==="*"){Z["*"]=Me.slice(te).join("/");break}if(te>=Me.length){Qe=!1;break}if(U.startsWith(":"))Z[U.slice(1)]=Me[te];else if(U!==Me[te]){Qe=!1;break}}if(Qe&&(A.includes("*")||A.length===Me.length)){ye=Pe,W=Z;break}}}if(ye&&T.upgrade(b,{data:W?{...ye,params:W}:ye}))return}return u(b)},websocket:this.wsAdapter}):Bun.serve({port:i,hostname:t,reusePort:r,maxRequestBodySize:o,fetch:u});this.server=l;for(let b of this.startHooks)Promise.resolve(b()).catch((T)=>console.error(`[${this.name}] onStart error:`,T));let x=async()=>{let T=this.name,C=process.stdout.isTTY;{let Q=C?"\uD83D\uDED1":"!",le=C?"\u2705":"v";process.stdout.write(`
|
|
227
|
+
\x1B[31m${Q} Stopping ${T}...\x1B[0m
|
|
228
|
+
`),await this.stop(!1),process.stdout.write(`\x1B[32m${le} ${T} has been stopped.\x1B[0m
|
|
229
|
+
`)}process.exit(0)};return this.shutdownHandler=x,process.on("SIGINT",x),process.on("SIGTERM",x),l}}var Mh=(e)=>{let t=e.indexOf("/",8);if(t===-1)return"/";let r=e.indexOf("?",t);return r===-1?e.slice(t):e.slice(t,r)},jh=(e={})=>{let t=e.format??"pretty",r=e.requestId??!0,{skip:n,onLog:o}=e;return(s,i)=>{let a=Mh(s.req.url);if(n?.(s,a))return i();let c=r?s.requestId:void 0;if(c)s.setHeader("x-request-id",c);let u={timestamp:new Date().toISOString(),method:s.req.method,path:a,...c?{requestId:c}:{},ip:s.ip};if(o)o(u);else if(t==="json")console.log(JSON.stringify(u));else{let m=c?` [${c.slice(0,8)}]`:"";console.log(`[${u.timestamp}] ${u.method} ${u.path}${m}`)}return i()}};var Eh=(e={})=>{let t=e.path??"/health",{readyPath:r,checks:n}=e,o=Date.now(),s=async()=>{let i={},a=!0;if(n){let u=Object.entries(n);await Promise.all(u.map(async([m,l])=>{try{let x=await l();if(i[m]=x?"ok":"fail",!x)a=!1}catch{i[m]="fail",a=!1}}))}let c={status:a?"ok":"degraded",uptimeMs:Date.now()-o,timestamp:new Date().toISOString()};if(e.version)c.version=e.version;if(n)c.checks=i;return Response.json(c,{status:a?200:503})};return{install(i){if(i.get(t,s),r&&r!==t)i.get(r,s)}}};var Uh=(e={})=>{let t=e.origin||"*",r=e.methods||"GET,POST,PUT,PATCH,DELETE,OPTIONS",n=Array.isArray(e.allowedHeaders)?e.allowedHeaders.join(", "):e.allowedHeaders||"Content-Type, Authorization",o=Array.isArray(e.exposedHeaders)?e.exposedHeaders.join(", "):e.exposedHeaders,s=e.credentials===!0;if(typeof t==="string"){let u={"Access-Control-Allow-Origin":t,"Access-Control-Allow-Methods":r,"Access-Control-Allow-Headers":n};if(t!=="*")u.Vary="Origin";if(s)u["Access-Control-Allow-Credentials"]="true";let m={status:204,headers:u};return(x,b)=>{if(x.req.method==="OPTIONS")return new Response(null,m);if(x.setHeader("Access-Control-Allow-Origin",t),x.setHeader("Access-Control-Allow-Methods",r),t!=="*")x.setHeader("Vary","Origin");if(s)x.setHeader("Access-Control-Allow-Credentials","true");if(o)x.setHeader("Access-Control-Expose-Headers",o);let T=b?.();if(T&&typeof T.then==="function")return T.then((C)=>{if(C instanceof Response){if(C.headers.set("Access-Control-Allow-Origin",t),C.headers.set("Access-Control-Allow-Methods",r),t!=="*")C.headers.set("Vary","Origin");if(s)C.headers.set("Access-Control-Allow-Credentials","true");if(o)C.headers.set("Access-Control-Expose-Headers",o)}return C});if(T instanceof Response){if(T.headers.set("Access-Control-Allow-Origin",t),T.headers.set("Access-Control-Allow-Methods",r),t!=="*")T.headers.set("Vary","Origin");if(s)T.headers.set("Access-Control-Allow-Credentials","true");if(o)T.headers.set("Access-Control-Expose-Headers",o)}return T}}let i=Array.isArray(t)?new Set(t):null,a=(u)=>{if(!u)return null;if(i)return i.has(u)?u:null;return t(u)?u:null};return(u,m)=>{let l=a(u.req.headers.get("origin"));if(u.req.method==="OPTIONS"){let x={"Access-Control-Allow-Methods":r,"Access-Control-Allow-Headers":n,Vary:"Origin"};if(l)x["Access-Control-Allow-Origin"]=l;if(s&&l)x["Access-Control-Allow-Credentials"]="true";return new Response(null,{status:204,headers:x})}if(u.setHeader("Vary","Origin"),u.setHeader("Access-Control-Allow-Methods",r),l){if(u.setHeader("Access-Control-Allow-Origin",l),s)u.setHeader("Access-Control-Allow-Credentials","true")}if(o)u.setHeader("Access-Control-Expose-Headers",o);return m?.()}};var Lh=new Set(["GET","HEAD","OPTIONS"]),Kh=(e={})=>{let t=e.ignoreMethods?new Set(e.ignoreMethods.map((i)=>i.toUpperCase())):Lh,r=e.allowedOrigins?new Set(e.allowedOrigins):null,n=e.cookieName||"csrf_token",o=(e.headerName||"x-csrf-token").toLowerCase(),s=e.requireToken===!0;return(i,a)=>{let c=i.req.method.toUpperCase();if(t.has(c))return a();let u=i.req.headers.get("sec-fetch-site"),m=i.req.headers.get("origin"),l=i.req.headers.get("referer");if(u==="cross-site"){if(!r||!m||!r.has(m))return Response.json({status:"error",code:"CSRF_FORBIDDEN",message:"Cross-site request blocked"},{status:403})}let x=m;if(!x&&l)try{x=new URL(l).origin}catch{return Response.json({status:"error",code:"CSRF_FORBIDDEN",message:"Invalid Referer header"},{status:403})}if(x){let b;try{b=new URL(i.req.url).origin}catch{b=""}if(!(x===b||r!==null&&r.has(x)))return Response.json({status:"error",code:"CSRF_FORBIDDEN",message:"Origin mismatch"},{status:403})}if(s){let b=i.cookies[n],T=i.req.headers.get(o);if(!b||!T||b!==T)return Response.json({status:"error",code:"CSRF_TOKEN_INVALID",message:"Invalid or missing CSRF token"},{status:403})}return a()}};var Bh=(e=1e4,t={})=>{let r=t.status??408,n=t.message??"Request Timeout",o=async(s,i)=>{let a;try{let c=new Promise((u)=>{a=setTimeout(()=>{u(Response.json({status:"error",code:"REQUEST_TIMEOUT",message:n},{status:r}))},e)});return await Promise.race([Promise.resolve(i()),c])}finally{if(a!==void 0)clearTimeout(a)}};return o.__timeout={ms:e,status:r,message:n},o};var Dh=(e={})=>{let t=e.windowMs??60000,r=e.max??100,n=e.message??"Too many requests, please try again later.",o=e.maxEntries??1e4,s=e.keyGenerator??((a)=>a.ip),i=new Map;return(a,c)=>{let u=Date.now(),m=s(a),l=i.get(m);if(!l||u>=l.resetAt){if(i.size>=o){for(let[b,T]of i){if(u>=T.resetAt)i.delete(b);if(i.size<o)break}if(i.size>=o){let b=i.keys().next().value;if(b!==void 0)i.delete(b)}}l={count:1,resetAt:u+t},i.set(m,l)}else l.count++;let x=Math.max(0,r-l.count);if(a.setHeader("X-RateLimit-Limit",String(r)),a.setHeader("X-RateLimit-Remaining",String(x)),a.setHeader("X-RateLimit-Reset",String(Math.ceil(l.resetAt/1000))),l.count>r){let b=Math.max(1,Math.ceil((l.resetAt-u)/1000));return Response.json({status:"error",code:"RATE_LIMITED",message:n},{status:429,headers:{"Retry-After":String(b),"X-RateLimit-Limit":String(r),"X-RateLimit-Remaining":"0","X-RateLimit-Reset":String(Math.ceil(l.resetAt/1000))}})}return c?.()}};var vh=(e={})=>{let t=(e.headerName||"idempotency-key").toLowerCase(),r=e.ttlMs??300000,n=e.maxKeys??1e4,o=new Map,s=new Set,i=(a)=>{let c=a.req.headers.get(t);if(!c){a._idempotencyKey=void 0;return}let u=a.req.url,m=u.indexOf("/",8),l=m===-1?-1:u.indexOf("?",m),x=m===-1?"/":l===-1?u.slice(m):u.slice(m,l),b=`${a.req.method}:${x}:${c}`,T=Date.now(),C=o.get(b);if(C){if(T<C.expiresAt)return a._idempotencyKey=void 0,Response.json(C.body,{status:C.status,headers:{"X-Idempotent-Replayed":"true"}});o.delete(b)}if(s.has(b))return a._idempotencyKey=void 0,Response.json({status:"error",code:"IDEMPOTENT_IN_FLIGHT",message:"Duplicate request is currently in flight"},{status:409});s.add(b),a._idempotencyKey=b;return};return i.__idempotencyCommit=(a,c,u)=>{let m=a._idempotencyKey;if(!m)return;if(a._idempotencyKey=void 0,s.delete(m),u>=200&&u<300&&!(c instanceof Response)){if(o.size>=n){let l=o.keys().next().value;if(l!==void 0)o.delete(l)}o.set(m,{status:u,body:c,expiresAt:Date.now()+r})}},i.__idempotencyRelease=(a)=>{let c=a._idempotencyKey;if(c)a._idempotencyKey=void 0,s.delete(c)},i},qh=()=>{let e=new Map;return async(t,r)=>{let n=e.get(t);if(n)return{data:await n,shared:!0};let o=r().finally(()=>{e.delete(t)});return e.set(t,o),{data:await o,shared:!1}}};var Gh=(e={})=>{let t=e.failureThreshold??5,r=e.resetTimeoutMs??30000,n=e.isFailure??((l,x)=>Boolean(x)||l instanceof Response&&l.status>=500),o="CLOSED",s=0,i=0,a=!1,c=(l)=>{if(o!==l){let x=o;o=l,e.onStateChange?.(x,l)}},u=async(l)=>{if(o==="OPEN"){let b=Date.now()-i;if(b<r){let T=Math.max(1,Math.ceil((r-b)/1000));return Response.json({status:"error",code:"CIRCUIT_OPEN",message:"Service temporarily unavailable"},{status:503,headers:{"Retry-After":String(T)}})}c("HALF_OPEN")}let x=!1;if(o==="HALF_OPEN"){if(a)return Response.json({status:"error",code:"CIRCUIT_OPEN",message:"Service temporarily unavailable"},{status:503,headers:{"Retry-After":"1"}});a=!0,x=!0}try{let b=await l();if(n(b)){if(s++,x||s>=t)i=Date.now(),c("OPEN")}else if(s=0,x)c("CLOSED");return b}catch(b){if(s++,x||s>=t)i=Date.now(),c("OPEN");throw b}finally{if(x)a=!1}},m=(l,x)=>u(()=>x?x():void 0);return m.__circuitBreaker=u,m};var Hh=(e={})=>{let t=[];if(e.noSniff!==!1)t.push(["X-Content-Type-Options","nosniff"]);if(e.frameOptions!==!1)t.push(["X-Frame-Options",e.frameOptions??"DENY"]);if(e.referrerPolicy!==!1)t.push(["Referrer-Policy",e.referrerPolicy??"strict-origin-when-cross-origin"]);if(e.hsts!==!1)t.push(["Strict-Transport-Security",e.hsts??"max-age=31536000; includeSubDomains"]);if(e.contentSecurityPolicy)t.push(["Content-Security-Policy",e.contentSecurityPolicy]);t.push(["X-XSS-Protection","0"]);let r=t.length,n=Object.freeze((()=>{let o={};for(let s=0;s<r;s++){let i=t[s];o[i[0].toLowerCase()]=i[1]}return o})());return(o,s)=>{if(!o._headers)o._headers=n;else o._headers={...o._headers,...n};let i=s?.();if(i&&typeof i.then==="function")return i.then((a)=>{if(a instanceof Response)for(let c=0;c<r;c++){let u=t[c];if(!a.headers.has(u[0]))a.headers.set(u[0],u[1])}return a});if(i instanceof Response)for(let a=0;a<r;a++){let c=t[a];if(!i.headers.has(c[0]))i.headers.set(c[0],c[1])}return i}};import{resolve as tu,sep as Rs}from"path";import{stat as Vh,realpath as ru}from"fs/promises";var zh=(e="public",t={})=>{let r=tu(process.cwd(),e),n=r.endsWith(Rs)?r:r+Rs,o=null,s=t.maxAge??3600,i=t.etag!==!1,a=async(c,u)=>{let m=c.req.method;if(m!=="GET"&&m!=="HEAD")return u();let l=c.req.url,x=l.indexOf("/",8),b=x===-1?-1:l.indexOf("?",x),T=x===-1?"":b===-1?l.slice(x):l.slice(x,b),C;try{C=decodeURIComponent(T)}catch{return c.status(400).send("Bad Request")}if(C.includes("\x00"))return c.status(400).send("Bad Request");let Q=C.replace(/^\/+/,""),le=tu(r,Q);if(le!==r&&!le.startsWith(n))return c.status(403).send("Forbidden");let q=0,Ge=0;try{let[$e,Pe]=await Promise.all([o??=ru(r),ru(le)]),A=$e.endsWith(Rs)?$e:$e+Rs;if(Pe!==$e&&!Pe.startsWith(A))return c.status(403).send("Forbidden");let Z=await Vh(Pe);if(Z.isDirectory())return u();q=Z.size,Ge=Math.floor(Z.mtimeMs)}catch{return u()}let ye=Bun.file(le),W={"Cache-Control":`public, max-age=${s}`,"Accept-Ranges":"bytes"};if(i){let $e=`W/"${q.toString(16)}-${Ge.toString(16)}"`;W.ETag=$e;let Pe=c.req.headers?.get?.("if-none-match");if(Pe&&Pe===$e)return new Response(null,{status:304,headers:W})}let Me=c.req.headers?.get?.("range");if(Me&&Me.startsWith("bytes=")&&q>0){let[$e,Pe]=Me.slice(6).split("-"),A=$e?Number($e):0,Z=Pe?Number(Pe):q-1;if(!$e&&Pe)A=Math.max(0,q-Number(Pe)),Z=q-1;if(!Number.isInteger(A)||!Number.isInteger(Z)||A<0||Z>=q||A>Z)return new Response(null,{status:416,headers:{...W,"Content-Range":`bytes */${q}`}});if(W["Content-Range"]=`bytes ${A}-${Z}/${q}`,W["Content-Length"]=String(Z-A+1),ye.type)W["Content-Type"]=ye.type;return new Response(m==="HEAD"?null:ye.slice(A,Z+1),{status:206,headers:W})}if(ye.type)W["Content-Type"]=ye.type;return W["Content-Length"]=String(q),new Response(m==="HEAD"?null:ye,{status:200,headers:W})};return a.__isStatic=!0,a};var Wh=(e={})=>{let t=e.minSize??1024,r=e.level??6,n=async(s,i)=>{if(s.req.method==="HEAD")return i;let a=s.req.headers.get("accept-encoding");if(!a||!a.includes("gzip"))return i;if(!(i instanceof Response))return i;if(i.status===204||i.status===304)return i;if(i.headers.has("content-encoding"))return i;if((i.headers.get("content-type")||"").includes("text/event-stream"))return i;let u=await i.arrayBuffer();if(u.byteLength<t)return new Response(u,{status:i.status,headers:i.headers});let m=Bun.gzipSync(new Uint8Array(u),{level:r}),l=new Headers(i.headers);return l.set("Content-Encoding","gzip"),l.set("Vary","Accept-Encoding"),l.delete("Content-Length"),new Response(m,{status:i.status,headers:l})},o=async(s,i)=>{let a=await(i?i():void 0);return n(s,a)};return o.__compress=n,o};import{createHash as Jh,createHmac as Yh,timingSafeEqual as xi}from"crypto";var ou=new TextEncoder,gi=(e)=>typeof e==="string"?Buffer.from(e).toString("base64url"):Buffer.from(e).toString("base64url"),nu=(e)=>Buffer.from(e,"base64url").toString("utf-8"),hi=new Map,Xh=async(e)=>{if(hi.has(e))return hi.get(e);let t=await crypto.subtle.importKey("raw",ou.encode(e),{name:"HMAC",hash:"SHA-256"},!1,["sign","verify"]);return hi.set(e,t),t},Qh=async(e,t)=>{let r=JSON.stringify({alg:"HS256",typ:"JWT"}),n=JSON.stringify(e),o=gi(r),s=gi(n),i=`${o}.${s}`,a=await Xh(t),c=await crypto.subtle.sign("HMAC",a,ou.encode(i)),u=gi(new Uint8Array(c));return`${i}.${u}`},yr=new Map,Zh=(e,t=3600000)=>{if(yr.size>=1e4){let r=Date.now();for(let[n,o]of yr)if(r>=o)yr.delete(n);if(yr.size>=1e4){let n=yr.keys().next().value;if(n!==void 0)yr.delete(n)}}yr.set(e,Date.now()+t)},Ii=(e)=>{let t=yr.get(e);if(t===void 0)return!1;if(Date.now()>=t)return yr.delete(e),!1;return!0},ex=(e)=>{let t=typeof e==="string"?e:e.secret,r=typeof e==="object"?e.isRevoked:void 0,n=(s,i,a)=>{if(s.set("user",i),Array.isArray(a)){if(a.length===0)return;let[c,...u]=a;return c(s,u)}if(typeof a==="function")return a();return},o=(s,i)=>{let a=s.req.headers.get("Authorization");if(!a?.startsWith("Bearer "))return s.status(401).send("Bearer token required");let c=a.slice(7),u=c.indexOf("."),m=u===-1?-1:c.indexOf(".",u+1);if(u===-1||m===-1||c.indexOf(".",m+1)!==-1)return s.status(401).send("Malformed JWT token");let l=c.slice(0,u),x=c.slice(u+1,m),b=c.slice(m+1),T=c.slice(0,m);try{let C=Yh("sha256",t).update(T).digest(),Q=Buffer.from(b,"base64url");if(Q.length!==C.length||!xi(Q,C))return s.status(401).send("Invalid signature");let le=JSON.parse(nu(l));if(!le||le.alg!=="HS256")return s.status(401).send("Unsupported token algorithm");let q=JSON.parse(nu(x)),Ge=Date.now()*0.001;if(typeof q.exp==="number"&&Ge>=q.exp)return s.status(401).send("Token expired");if(typeof q.nbf==="number"&&Ge<q.nbf)return s.status(401).send("Token not active");if(Ii(c)||q?.jti&&Ii(String(q.jti)))return s.status(401).send("Token revoked");if(r){let ye=r(q,c);if(ye&&typeof ye.then==="function")return ye.then((W)=>W?s.status(401).send("Token revoked"):n(s,q,i));if(ye)return s.status(401).send("Token revoked")}return n(s,q,i)}catch{return s.status(401).send("Token verification failed")}};if(r)return async(s,i)=>o(s,i);return o},Os=(e)=>Jh("sha256").update(e).digest(),tx=(e)=>{let t=Os(e.user),r=Os(e.pass);return async(n,o)=>{let s=n.req.headers.get("Authorization");if(!s?.startsWith("Basic "))return n.status(401).json({status:"error",message:"Basic Auth required"});let i=s.slice(6).trim();if(!i)return n.status(401).json({status:"error",message:"Missing credentials"});let a=Buffer.from(i,"base64").toString("utf-8"),c=a.indexOf(":");if(c===-1)return n.status(401).json({status:"error",message:"Invalid credentials"});let u=a.slice(0,c),m=a.slice(c+1),l=xi(Os(u),t),x=xi(Os(m),r);if(l&&x)return o();return n.status(401).json({status:"error",message:"Invalid credentials"})}},rx=(e)=>async(t,r)=>{let n=t.get("user");if(!n||n.role!==e)return t.status(403).json({status:"error",message:`Required role: ${e}`});return r()};bs();var su={make:(e)=>Bun.password.hash(e,Jn.hash),verify:async(e,t)=>{if(!t||typeof t!=="string")return!1;try{return await Bun.password.verify(e,t)}catch{return!1}},needsRehash:(e)=>{let{algorithm:t,memoryCost:r,timeCost:n}=Jn.hash;if(t==="bcrypt"){if(!/^\$2[aby]\$/.test(e))return!0;let i=e.match(/^\$2[aby]\$(\d+)\$/);return!i||Number(i[1])!==n}if(!e.startsWith(`$${t}$`))return!0;let o=e.match(/(?:^|[,$])m=(\d+)(?:[,$]|$)/),s=e.match(/(?:^|[,$])t=(\d+)(?:[,$]|$)/);return!o||Number(o[1])!==r||!s||Number(s[1])!==n}};var nx=(e,t,r)=>{let n=t;if(r?.params)for(let[a,c]of Object.entries(r.params))n=n.replaceAll(`:${a}`,encodeURIComponent(String(c)));let o=e.endsWith("/")?e.slice(0,-1):e,s=n.startsWith("/")?n:`/${n}`,i=`${o}${s}`;if(r?.query){let a=new URLSearchParams;for(let[u,m]of Object.entries(r.query))if(m!==void 0)a.set(u,String(m));let c=a.toString();if(c)i+=`?${c}`}return i},ox=(e,t={})=>{let r=typeof e==="object"&&e!==null&&typeof e.fetch==="function",n=r?"http://localhost":e,o=t.fetch??(r?(a,c)=>e.fetch(new Request(String(a),c)):fetch),s=t.headers??{},i=async(a,c,u)=>{let m=nx(n,c,u),l={...s,...u?.headers??{}},x={method:a,headers:l};if(u?.body!==void 0&&a!=="GET"&&a!=="HEAD"){if(!l["Content-Type"]&&!l["content-type"])l["Content-Type"]="application/json";x.body=typeof u.body==="string"?u.body:JSON.stringify(u.body)}let b=await o(m,x),T=null;if(b.status!==204&&b.status!==205&&b.status!==304)if((b.headers.get("content-type")||"").includes("application/json")){let Q=await b.text();T=Q?JSON.parse(Q):null}else T=await b.text();if(!b.ok){let C=Error(`HTTP ${b.status}`);throw C.status=b.status,C.data=T,C}return T};return{get:(a,c)=>i("GET",a,c),post:(a,c)=>i("POST",a,c),put:(a,c)=>i("PUT",a,c),patch:(a,c)=>i("PATCH",a,c),delete:(a,c)=>i("DELETE",a,c)}};export{eu as BareJS,vn as BareRouter,_o as Context,su as Hash,su as Password,Th as T,Th as Type,Th as TypeBox,Ty as Z,Ty as Zod,ex as bareAuth,ox as bareClient,tx as basicAuth,Gh as circuitBreaker,Wh as compress,Uh as cors,ic as createResponseFilter,qh as createSingleflight,Qh as createToken,Kh as csrf,li as generateOpenAPISpec,rx as hasRole,Eh as healthcheck,vh as idempotency,Ii as isTokenRevoked,jh as logger,nc as n,nc as native,Dh as rateLimit,yi as renderDocsHTML,Zh as revokeToken,ii as schemaValidator,Hh as securityHeaders,zh as staticFile,rc as t,Bh as timeout,rc as typebox,Py as v,Py as validate,oc as z,oc as zod};
|