barejs 0.1.48 → 0.1.50

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1,82 +1,181 @@
1
1
  // @bun
2
- var{defineProperty:ni,getOwnPropertyNames:Wc,getOwnPropertyDescriptor:Jc}=Object,Yc=Object.prototype.hasOwnProperty;function Qc(e){return this[e]}var Xc=(e)=>{var t=(Ji??=new WeakMap).get(e),r;if(t)return t;if(t=ni({},"__esModule",{value:!0}),e&&typeof e==="object"||typeof e==="function"){for(var n of Wc(e))if(!Yc.call(t,n))ni(t,n,{get:Qc.bind(e,n),enumerable:!(r=Jc(e,n))||r.enumerable})}return Ji.set(e,t),t},Ji;var Zc=(e)=>e;function eu(e,t){this[e]=Zc.bind(null,t)}var oi=(e,t)=>{for(var r in t)ni(e,r,{get:t[r],enumerable:!0,configurable:!0,set:eu.bind(t,r)})};var tu=(e,t,r)=>()=>{if(e)try{t=e(e=0)}catch(n){r=[n]}if(r)throw r[0];return t};var qa={};oi(qa,{BARE_CONFIG:()=>dn,initConfig:()=>Wo});var ji,dn,Wo=(e={})=>(dn={...ji,...e,hash:{...ji.hash,...e.hash}},dn);var Jo=tu(()=>{ji={hash:{algorithm:"argon2id",memoryCost:65536,timeCost:2},port:3000},dn=ji});var Ci={};oi(Ci,{Any:()=>or,Argument:()=>Is,Array:()=>Yr,AsyncIterator:()=>Qr,Awaited:()=>nn,BigInt:()=>tn,Boolean:()=>Po,Capitalize:()=>xa,Composite:()=>Gs,Const:()=>Ds,Constructor:()=>Xr,ConstructorParameters:()=>vs,Date:()=>Uo,Enum:()=>qs,Exclude:()=>cn,Extends:()=>an,Extract:()=>un,Function:()=>Pt,Index:()=>ir,InstanceType:()=>ua,Instantiate:()=>ma,Integer:()=>da,Intersect:()=>Pe,Iterator:()=>rn,KeyOf:()=>on,Literal:()=>q,Lowercase:()=>ga,Mapped:()=>Ss,Module:()=>Ca,Never:()=>j,Not:()=>ja,Null:()=>Ko,Number:()=>Ze,Object:()=>z,Omit:()=>cr,Optional:()=>Ne,Parameters:()=>Ma,Partial:()=>fn,Pick:()=>ur,Promise:()=>Mo,Readonly:()=>Ge,ReadonlyOptional:()=>qo,Record:()=>Vo,Recursive:()=>Sa,Ref:()=>rt,RegExp:()=>Ua,Required:()=>mn,Rest:()=>Ka,ReturnType:()=>Ea,String:()=>It,Symbol:()=>Eo,TemplateLiteral:()=>Co,Transform:()=>Ga,Tuple:()=>et,Uint8Array:()=>Bo,Uncapitalize:()=>Ia,Undefined:()=>Lo,Union:()=>V,Unknown:()=>sr,Unsafe:()=>Da,Uppercase:()=>ha,Void:()=>va});var ri={};oi(ri,{BRAND:()=>Nx,DIRTY:()=>Mr,EMPTY_PATH:()=>cx,INVALID:()=>T,NEVER:()=>lg,OK:()=>Me,ParseStatus:()=>ke,Schema:()=>M,ZodAny:()=>Ur,ZodArray:()=>Ft,ZodBigInt:()=>lr,ZodBoolean:()=>bn,ZodBranded:()=>ti,ZodCatch:()=>kn,ZodDate:()=>Sr,ZodDefault:()=>An,ZodDiscriminatedUnion:()=>ei,ZodEffects:()=>Tt,ZodEnum:()=>yr,ZodError:()=>ve,ZodFirstPartyTypeKind:()=>A,ZodFunction:()=>hn,ZodIntersection:()=>Fn,ZodIssueCode:()=>x,ZodLazy:()=>wn,ZodLiteral:()=>Rn,ZodMap:()=>eo,ZodNaN:()=>to,ZodNativeEnum:()=>Tn,ZodNever:()=>Mt,ZodNull:()=>On,ZodNullable:()=>Yt,ZodNumber:()=>pr,ZodObject:()=>de,ZodOptional:()=>wt,ZodParsedType:()=>_,ZodPipeline:()=>ro,ZodPromise:()=>Er,ZodReadonly:()=>Nn,ZodRecord:()=>Zn,ZodSchema:()=>M,ZodSet:()=>Kr,ZodString:()=>$t,ZodSymbol:()=>Qn,ZodTransformer:()=>Tt,ZodTuple:()=>St,ZodType:()=>M,ZodUndefined:()=>_n,ZodUnion:()=>$n,ZodUnknown:()=>dr,ZodVoid:()=>Xn,addIssueToContext:()=>I,any:()=>Lx,array:()=>vx,bigint:()=>Mx,boolean:()=>hc,coerce:()=>pg,custom:()=>xc,date:()=>Sx,datetimeRegex:()=>lc,defaultErrorMap:()=>Wt,discriminatedUnion:()=>zx,effect:()=>ig,enum:()=>rg,function:()=>Zx,getErrorMap:()=>xn,getParsedType:()=>jt,instanceof:()=>Cx,intersection:()=>Wx,isAborted:()=>Xo,isAsync:()=>gn,isDirty:()=>Zo,isValid:()=>mr,late:()=>Px,lazy:()=>eg,literal:()=>tg,makeIssue:()=>Yn,map:()=>Qx,nan:()=>jx,nativeEnum:()=>ng,never:()=>Gx,null:()=>Ex,nullable:()=>ag,number:()=>Ic,object:()=>qx,objectUtil:()=>Gi,oboolean:()=>dg,onumber:()=>mg,optional:()=>sg,ostring:()=>fg,pipeline:()=>ug,preprocess:()=>cg,promise:()=>og,quotelessJson:()=>ix,record:()=>Yx,set:()=>Xx,setErrorMap:()=>ax,strictObject:()=>Vx,string:()=>gc,symbol:()=>Ux,transformer:()=>ig,tuple:()=>Jx,undefined:()=>Kx,union:()=>Hx,unknown:()=>Bx,util:()=>K,void:()=>Dx});class Dr{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);group=(e,...t)=>{let r=t.pop(),n=t,o=(this.prefix+"/"+e).replace(/\/+/g,"/"),i=new Dr(o,[...this.groupMiddleware,...n]);return r(i),this.routes.push(...i.routes),this};use(e){if(e instanceof Dr||e&&e.routes)this.routes.push(...e.routes);else this.groupMiddleware.push(e);return this}}class vr{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 vr;n.paramName=i.slice(1),n=n.paramNode}else{if(!n.children[i])n.children[i]=new vr,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 f=a-i,l=!1,g=o.staticKeys,R=g.length;if(R===1){let J=g[0];if(J.length===f){let be=!0;for(let P=0;P<f;P++)if(J[P]!==t[i+P]){be=!1;break}if(be)o=o.children[J],l=!0}}else for(let J=0;J<R;J++){let be=g[J];if(be.length===f){let P=!0;for(let qe=0;qe<f;qe++)if(be[qe]!==t[i+qe]){P=!1;break}if(P){o=o.children[be],l=!0;break}}}if(!l)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
- `,o.length>0){let a=o.map((f)=>`${JSON.stringify(f.name)}: ${f.varName}`).join(", ");i+=`${s} ctx.params = { ${a} };
2
+ var{defineProperty:Oi,getOwnPropertyNames:su,getOwnPropertyDescriptor:au}=Object,cu=Object.prototype.hasOwnProperty;function uu(e){return this[e]}var fu=(e)=>{var t=(Is??=new WeakMap).get(e),r;if(t)return t;if(t=Oi({},"__esModule",{value:!0}),e&&typeof e==="object"||typeof e==="function"){for(var n of su(e))if(!cu.call(t,n))Oi(t,n,{get:uu.bind(e,n),enumerable:!(r=au(e,n))||r.enumerable})}return Is.set(e,t),t},Is;var du=(e)=>e;function mu(e,t){this[e]=du.bind(null,t)}var $i=(e,t)=>{for(var r in t)Oi(e,r,{get:t[r],enumerable:!0,configurable:!0,set:mu.bind(t,r)})};var pu=(e,t,r)=>()=>{if(e)try{t=e(e=0)}catch(n){r=[n]}if(r)throw r[0];return t};var zc={};$i(zc,{BARE_CONFIG:()=>Hn,initConfig:()=>hi});var fs,Hn,hi=(e={})=>(Hn={...fs,...e,hash:{...fs.hash,...e.hash}},Hn);var Ii=pu(()=>{fs={hash:{algorithm:"argon2id",memoryCost:65536,timeCost:2},port:3000},Hn=fs});var ai={};$i(ai,{BRAND:()=>Dl,DIRTY:()=>Wr,EMPTY_PATH:()=>Il,INVALID:()=>P,NEVER:()=>Ry,OK:()=>Ge,ParseStatus:()=>Ue,Schema:()=>L,ZodAny:()=>Yr,ZodArray:()=>Mt,ZodBigInt:()=>Ar,ZodBoolean:()=>An,ZodBranded:()=>si,ZodCatch:()=>Un,ZodDate:()=>Jr,ZodDefault:()=>Mn,ZodDiscriminatedUnion:()=>ii,ZodEffects:()=>Lt,ZodEnum:()=>kr,ZodError:()=>Ze,ZodFirstPartyTypeKind:()=>N,ZodFunction:()=>Fn,ZodIntersection:()=>Pn,ZodIssueCode:()=>h,ZodLazy:()=>Nn,ZodLiteral:()=>Sn,ZodMap:()=>yo,ZodNaN:()=>go,ZodNativeEnum:()=>jn,ZodNever:()=>zt,ZodNull:()=>Cn,ZodNullable:()=>fr,ZodNumber:()=>Fr,ZodObject:()=>he,ZodOptional:()=>Ut,ZodParsedType:()=>R,ZodPipeline:()=>xo,ZodPromise:()=>Qr,ZodReadonly:()=>En,ZodRecord:()=>lo,ZodSchema:()=>L,ZodSet:()=>Xr,ZodString:()=>jt,ZodSymbol:()=>mo,ZodTransformer:()=>Lt,ZodTuple:()=>Wt,ZodType:()=>L,ZodUndefined:()=>kn,ZodUnion:()=>Tn,ZodUnknown:()=>Rr,ZodVoid:()=>po,addIssueToContext:()=>b,any:()=>Yl,array:()=>ey,bigint:()=>Hl,boolean:()=>Ya,coerce:()=>wy,custom:()=>za,date:()=>Vl,datetimeRegex:()=>Ha,defaultErrorMap:()=>cr,discriminatedUnion:()=>oy,effect:()=>gy,enum:()=>py,function:()=>fy,getErrorMap:()=>$n,getParsedType:()=>Vt,instanceof:()=>ql,intersection:()=>iy,isAborted:()=>ni,isAsync:()=>wn,isDirty:()=>oi,isValid:()=>wr,late:()=>Gl,lazy:()=>dy,literal:()=>my,makeIssue:()=>fo,map:()=>cy,nan:()=>vl,nativeEnum:()=>ly,never:()=>Ql,null:()=>Jl,nullable:()=>hy,number:()=>Ja,object:()=>ty,objectUtil:()=>Zi,oboolean:()=>$y,onumber:()=>Oy,optional:()=>xy,ostring:()=>_y,pipeline:()=>by,preprocess:()=>Iy,promise:()=>yy,quotelessJson:()=>gl,record:()=>ay,set:()=>uy,setErrorMap:()=>hl,strictObject:()=>ry,string:()=>Wa,symbol:()=>zl,transformer:()=>gy,tuple:()=>sy,undefined:()=>Wl,union:()=>ny,unknown:()=>Xl,util:()=>D,void:()=>Zl});var us={};$i(us,{Any:()=>Ir,Argument:()=>nc,Array:()=>cn,AsyncIterator:()=>un,Awaited:()=>Bn,BigInt:()=>ln,Boolean:()=>Go,Capitalize:()=>bc,Composite:()=>ic,Const:()=>sc,Constructor:()=>fn,ConstructorParameters:()=>ac,Date:()=>ci,Enum:()=>cc,Exclude:()=>Dn,Extends:()=>On,Extract:()=>Gn,Function:()=>vt,Index:()=>xr,InstanceType:()=>pc,Instantiate:()=>yc,Integer:()=>gc,Intersect:()=>Ke,Iterator:()=>yn,KeyOf:()=>gn,Literal:()=>W,Lowercase:()=>_c,Mapped:()=>Zs,Module:()=>Uc,Never:()=>E,Not:()=>Ec,Null:()=>ui,Number:()=>dt,Object:()=>X,Omit:()=>Cr,Optional:()=>Le,Parameters:()=>Lc,Partial:()=>qn,Pick:()=>Tr,Promise:()=>Ho,Readonly:()=>Ye,ReadonlyOptional:()=>li,Record:()=>yi,Recursive:()=>Kc,Ref:()=>lt,RegExp:()=>Bc,Required:()=>vn,Rest:()=>Dc,ReturnType:()=>Gc,String:()=>kt,Symbol:()=>fi,TemplateLiteral:()=>vo,Transform:()=>Hc,Tuple:()=>mt,Uint8Array:()=>mi,Uncapitalize:()=>Oc,Undefined:()=>di,Union:()=>J,Unknown:()=>br,Unsafe:()=>As,Uppercase:()=>$c,Void:()=>Vc});function Ao(e){return ze(e)&&globalThis.Symbol.asyncIterator in e}function ko(e){return ze(e)&&globalThis.Symbol.iterator in e}function Co(e){return e instanceof globalThis.Promise}function on(e){return e instanceof Date&&globalThis.Number.isFinite(e.getTime())}function sn(e){return e instanceof globalThis.Uint8Array}function To(e,t){return t in e}function ze(e){return e!==null&&typeof e==="object"}function _e(e){return globalThis.Array.isArray(e)&&!globalThis.ArrayBuffer.isView(e)}function ve(e){return e===void 0}function Pr(e){return e===null}function Nr(e){return typeof e==="boolean"}function M(e){return typeof e==="number"}function Po(e){return globalThis.Number.isInteger(e)}function nt(e){return typeof e==="bigint"}function ke(e){return typeof e==="string"}function No(e){return typeof e==="function"}function Sr(e){return typeof e==="symbol"}function So(e){return nt(e)||Nr(e)||Pr(e)||M(e)||ke(e)||Sr(e)||ve(e)}var ne;(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=ze(s);return e.AllowArrayObject?a:a&&!_e(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?M(s):Number.isFinite(s)}e.IsNumberLike=o;function i(s){let a=ve(s);return e.AllowNullVoid?a||s===null:a}e.IsVoidLike=i})(ne||(ne={}));var bs=new Map;function wi(e){return bs.has(e)}function Ri(e){return bs.get(e)}var _s=new Map;function Wn(e){return _s.has(e)}function Fi(e){return _s.get(e)}function Os(e){return ae(e)&&!Oe(e)&&!pr(e)&&Symbol.asyncIterator in e}function Oe(e){return Array.isArray(e)}function Uo(e){return typeof e==="bigint"}function mr(e){return typeof e==="boolean"}function an(e){return e instanceof globalThis.Date}function $s(e){return typeof e==="function"}function ws(e){return ae(e)&&!Oe(e)&&!pr(e)&&Symbol.iterator in e}function Rs(e){return e===null}function ot(e){return typeof e==="number"}function ae(e){return typeof e==="object"&&e!==null}function Eo(e){return e instanceof globalThis.RegExp}function oe(e){return typeof e==="string"}function Fs(e){return typeof e==="symbol"}function pr(e){return e instanceof globalThis.Uint8Array}function ie(e){return e===void 0}function lu(e){return globalThis.Object.freeze(e).map((t)=>Jn(t))}function yu(e){return e}function gu(e){return e}function xu(e){return e}function hu(e){let t={};for(let r of Object.getOwnPropertyNames(e))t[r]=Jn(e[r]);for(let r of Object.getOwnPropertySymbols(e))t[r]=Jn(e[r]);return globalThis.Object.freeze(t)}function Jn(e){return Oe(e)?lu(e):an(e)?yu(e):pr(e)?gu(e):Eo(e)?xu(e):ae(e)?hu(e):e}function Iu(e){return e.map((t)=>Lo(t))}function bu(e){return new Date(e.getTime())}function _u(e){return new Uint8Array(e)}function Ou(e){return new RegExp(e.source,e.flags)}function $u(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 Oe(e)?Iu(e):an(e)?bu(e):pr(e)?_u(e):Eo(e)?Ou(e):ae(e)?$u(e):e}function ce(e){return Lo(e)}function l(e,t){let r=t!==void 0?{...t,...e}:e;switch(ne.InstanceMode){case"freeze":return Jn(r);case"clone":return ce(r);default:return r}}var de=Symbol.for("TypeBox.Transform"),Gt=Symbol.for("TypeBox.Readonly"),Se=Symbol.for("TypeBox.Optional"),qt=Symbol.for("TypeBox.Hint"),x=Symbol.for("TypeBox.Kind");function As(e={}){return l({[x]:e[x]??"Unsafe"},e)}class z extends Error{constructor(e){super(e)}}function H(e){return l({[x]:"MappedResult",properties:e})}function wu(e,t){let{[t]:r,...n}=e;return n}function ye(e,t){return t.reduce((r,n)=>wu(r,n),e)}function cn(e,t){return l({[x]:"Array",type:"array",items:e},t)}function un(e,t){return l({[x]:"AsyncIterator",type:"AsyncIterator",items:e},t)}function fn(e,t,r){return l({[x]:"Constructor",type:"Constructor",parameters:e,returns:t},r)}function vt(e,t,r){return l({[x]:"Function",type:"Function",parameters:e,returns:t},r)}function se(e,t,r){return l({[x]:"Computed",target:e,parameters:t},r)}function E(e){return l({[x]:"Never",not:{}},e)}function dn(e){return ae(e)&&e[Gt]==="Readonly"}function We(e){return ae(e)&&e[Se]==="Optional"}function Ai(e){return G(e,"Any")}function ki(e){return G(e,"Argument")}function Ot(e){return G(e,"Array")}function Mr(e){return G(e,"AsyncIterator")}function Ur(e){return G(e,"BigInt")}function Xt(e){return G(e,"Boolean")}function $t(e){return G(e,"Computed")}function wt(e){return G(e,"Constructor")}function Ru(e){return G(e,"Date")}function Rt(e){return G(e,"Function")}function Ft(e){return G(e,"Integer")}function ge(e){return G(e,"Intersect")}function Er(e){return G(e,"Iterator")}function G(e,t){return ae(e)&&x in e&&e[x]===t}function Ko(e){return mr(e)||ot(e)||oe(e)}function it(e){return G(e,"Literal")}function st(e){return G(e,"MappedKey")}function ue(e){return G(e,"MappedResult")}function lr(e){return G(e,"Never")}function Fu(e){return G(e,"Not")}function Yn(e){return G(e,"Null")}function At(e){return G(e,"Number")}function be(e){return G(e,"Object")}function Lr(e){return G(e,"Promise")}function Kr(e){return G(e,"Record")}function Ie(e){return G(e,"Ref")}function Ci(e){return G(e,"RegExp")}function Qt(e){return G(e,"String")}function Xn(e){return G(e,"Symbol")}function at(e){return G(e,"TemplateLiteral")}function Au(e){return G(e,"This")}function V(e){return ae(e)&&de in e}function ct(e){return G(e,"Tuple")}function Zt(e){return G(e,"Undefined")}function v(e){return G(e,"Union")}function ku(e){return G(e,"Uint8Array")}function Cu(e){return G(e,"Unknown")}function Tu(e){return G(e,"Unsafe")}function Pu(e){return G(e,"Void")}function Nu(e){return ae(e)&&x in e&&oe(e[x])}function me(e){return Ai(e)||ki(e)||Ot(e)||Xt(e)||Ur(e)||Mr(e)||$t(e)||wt(e)||Ru(e)||Rt(e)||Ft(e)||ge(e)||Er(e)||it(e)||st(e)||ue(e)||lr(e)||Fu(e)||Yn(e)||At(e)||be(e)||Lr(e)||Kr(e)||Ie(e)||Ci(e)||Qt(e)||Xn(e)||at(e)||Au(e)||ct(e)||Zt(e)||v(e)||ku(e)||Cu(e)||Tu(e)||Pu(e)||Nu(e)}function Su(e){return l(ye(e,[Se]))}function ju(e){return l({...e,[Se]:"Optional"})}function Mu(e,t){return t===!1?Su(e):ju(e)}function Le(e,t){let r=t??!0;return ue(e)?ks(e,r):Mu(e,r)}function Uu(e,t){let r={};for(let n of globalThis.Object.getOwnPropertyNames(e))r[n]=Le(e[n],t);return r}function Eu(e,t){return Uu(e.properties,t)}function ks(e,t){let r=Eu(e,t);return H(r)}function Qn(e,t={}){let r=e.every((o)=>be(o)),n=me(t.unevaluatedProperties)?{unevaluatedProperties:t.unevaluatedProperties}:{};return l(t.unevaluatedProperties===!1||me(t.unevaluatedProperties)||r?{...n,[x]:"Intersect",type:"object",allOf:e}:{...n,[x]:"Intersect",allOf:e},t)}function Lu(e){return e.every((t)=>We(t))}function Ku(e){return ye(e,[Se])}function Cs(e){return e.map((t)=>We(t)?Ku(t):t)}function Bu(e,t){return Lu(e)?Le(Qn(Cs(e),t)):Qn(Cs(e),t)}function Bo(e,t={}){if(e.length===1)return l(e[0],t);if(e.length===0)return E(t);if(e.some((r)=>V(r)))throw Error("Cannot intersect transform types");return Bu(e,t)}function Ke(e,t){if(e.length===1)return l(e[0],t);if(e.length===0)return E(t);if(e.some((r)=>V(r)))throw Error("Cannot intersect transform types");return Qn(e,t)}function Zn(e,t){return l({[x]:"Union",anyOf:e},t)}function Du(e){return e.some((t)=>We(t))}function Ts(e){return e.map((t)=>We(t)?Gu(t):t)}function Gu(e){return ye(e,[Se])}function qu(e,t){return Du(e)?Le(Zn(Ts(e),t)):Zn(Ts(e),t)}function Ht(e,t){return e.length===1?l(e[0],t):e.length===0?E(t):qu(e,t)}function J(e,t){return e.length===0?E(t):e.length===1?l(e[0],t):Zn(e,t)}class Ti extends z{}function vu(e){return e.replace(/\\\$/g,"$").replace(/\\\*/g,"*").replace(/\\\^/g,"^").replace(/\\\|/g,"|").replace(/\\\(/g,"(").replace(/\\\)/g,")")}function Pi(e,t,r){return e[t]===r&&e.charCodeAt(t-1)!==92}function tr(e,t){return Pi(e,t,"(")}function eo(e,t){return Pi(e,t,")")}function Ps(e,t){return Pi(e,t,"|")}function Hu(e){if(!(tr(e,0)&&eo(e,e.length-1)))return!1;let t=0;for(let r=0;r<e.length;r++){if(tr(e,r))t+=1;if(eo(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(tr(e,r))t+=1;if(eo(e,r))t-=1;if(Ps(e,r)&&t===0)return!0}return!1}function Wu(e){for(let t=0;t<e.length;t++)if(tr(e,t))return!0;return!1}function Ju(e){let[t,r]=[0,0],n=[];for(let i=0;i<e.length;i++){if(tr(e,i))t+=1;if(eo(e,i))t-=1;if(Ps(e,i)&&t===0){let s=e.slice(r,i);if(s.length>0)n.push(mn(s));r=i+1}}let o=e.slice(r);if(o.length>0)n.push(mn(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(!tr(o,i))throw new Ti("TemplateLiteralParser: Index must point to open parens");let s=0;for(let a=i;a<o.length;a++){if(tr(o,a))s+=1;if(eo(o,a))s-=1;if(s===0)return[i,a]}throw new Ti("TemplateLiteralParser: Unclosed group parens in expression")}function r(o,i){for(let s=i;s<o.length;s++)if(tr(o,s))return[i,s];return[i,o.length]}let n=[];for(let o=0;o<e.length;o++)if(tr(e,o)){let[i,s]=t(e,o),a=e.slice(i,s+1);n.push(mn(a)),o=s}else{let[i,s]=r(e,o),a=e.slice(i,s);if(a.length>0)n.push(mn(a));o=s-1}return n.length===0?{type:"const",const:""}:n.length===1?n[0]:{type:"and",expr:n}}function mn(e){return Hu(e)?mn(Vu(e)):zu(e)?Ju(e):Wu(e)?Yu(e):{type:"const",const:vu(e)}}function pn(e){return mn(e.slice(1,e.length-1))}class Ns extends z{}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 Br(e){return Xu(e)||Zu(e)?!1:Qu(e)?!0:e.type==="and"?e.expr.every((t)=>Br(t)):e.type==="or"?e.expr.every((t)=>Br(t)):e.type==="const"?!0:(()=>{throw new Ns("Unknown expression type")})()}function Ss(e){let t=pn(e.pattern);return Br(t)}class js extends z{}function*Ms(e){if(e.length===1)return yield*e[0];for(let t of e[0])for(let r of Ms(e.slice(1)))yield`${t}${r}`}function*ef(e){return yield*Ms(e.expr.map((t)=>[...to(t)]))}function*tf(e){for(let t of e.expr)yield*to(t)}function*rf(e){return yield e.const}function*to(e){return e.type==="and"?yield*ef(e):e.type==="or"?yield*tf(e):e.type==="const"?yield*rf(e):(()=>{throw new js("Unknown expression")})()}function Do(e){let t=pn(e.pattern);return Br(t)?[...to(t)]:[]}function W(e,t){return l({[x]:"Literal",const:e,type:typeof e},t)}function Go(e){return l({[x]:"Boolean",type:"boolean"},e)}function ln(e){return l({[x]:"BigInt",type:"bigint"},e)}function dt(e){return l({[x]:"Number",type:"number"},e)}function kt(e){return l({[x]:"String",type:"string"},e)}function*nf(e){let t=e.trim().replace(/"|'/g,"");return t==="boolean"?yield Go():t==="number"?yield dt():t==="bigint"?yield ln():t==="string"?yield kt():yield(()=>{let r=t.split("|").map((n)=>W(n.trim()));return r.length===0?E():r.length===1?r[0]:Ht(r)})()}function*of(e){if(e[1]!=="{"){let t=W("$"),r=Ni(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=Ni(e.slice(t+1));return yield*[...r,...n]}yield W(e)}function*Ni(e){for(let t=0;t<e.length;t++)if(e[t]==="$"){let r=W(e.slice(0,t)),n=of(e.slice(t));return yield*[r,...n]}yield W(e)}function Us(e){return[...Ni(e)]}var Es="(true|false)",qo="(0|[1-9][0-9]*)",Ls="(.*)";var yr="^(0|[1-9][0-9]*)$",gr="^(.*)$",Ks="^(?!.*)$";class Bs extends z{}function sf(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Ds(e,t){return at(e)?e.pattern.slice(1,e.pattern.length-1):v(e)?`(${e.anyOf.map((r)=>Ds(r,t)).join("|")})`:At(e)?`${t}${qo}`:Ft(e)?`${t}${qo}`:Ur(e)?`${t}${qo}`:Qt(e)?`${t}${Ls}`:it(e)?`${t}${sf(e.const.toString())}`:Xt(e)?`${t}${Es}`:(()=>{throw new Bs(`Unexpected Kind '${e[x]}'`)})()}function Si(e){return`^${e.map((t)=>Ds(t,"")).join("")}$`}function Dr(e){let r=Do(e).map((n)=>W(n));return Ht(r)}function vo(e,t){let r=oe(e)?Si(Us(e)):Si(e);return l({[x]:"TemplateLiteral",type:"string",pattern:r},t)}function af(e){return Do(e).map((r)=>r.toString())}function cf(e){let t=[];for(let r of e)t.push(...Je(r));return t}function uf(e){return[e.toString()]}function Je(e){return[...new Set(at(e)?af(e):v(e)?cf(e.anyOf):it(e)?uf(e.const):At(e)?["[number]"]:Ft(e)?["[number]"]:[])]}function ff(e,t,r){let n={};for(let o of Object.getOwnPropertyNames(t))n[o]=xr(e,Je(t[o]),r);return n}function df(e,t,r){return ff(e,t.properties,r)}function Gs(e,t,r){let n=df(e,t,r);return H(n)}function vs(e,t){return e.map((r)=>Hs(r,t))}function mf(e){return e.filter((t)=>!lr(t))}function pf(e,t){return Bo(mf(vs(e,t)))}function lf(e){return e.some((t)=>lr(t))?[]:e}function yf(e,t){return Ht(lf(vs(e,t)))}function gf(e,t){return t in e?e[t]:t==="[number]"?Ht(e):E()}function xf(e,t){return t==="[number]"?e:E()}function hf(e,t){return t in e?e[t]:E()}function Hs(e,t){return ge(e)?pf(e.allOf,t):v(e)?yf(e.anyOf,t):ct(e)?gf(e.items??[],t):Ot(e)?xf(e.items,t):be(e)?hf(e.properties,t):E()}function ro(e,t){return t.map((r)=>Hs(e,r))}function qs(e,t){return Ht(ro(e,t))}function xr(e,t,r){if(Ie(e)||Ie(t)){if(!me(e)||!me(t))throw new z("Index types using Ref parameters require both Type and Key to be of TSchema");return se("Index",[e,t])}if(ue(t))return Gs(e,t,r);if(st(t))return Vs(e,t,r);return l(me(t)?qs(e,Je(t)):qs(e,t),r)}function If(e,t,r){return{[t]:xr(e,[t],ce(r))}}function bf(e,t,r){return t.reduce((n,o)=>({...n,...If(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 H(n)}function yn(e,t){return l({[x]:"Iterator",type:"Iterator",items:e},t)}function Of(e){return globalThis.Object.keys(e).filter((t)=>!We(e[t]))}function $f(e,t){let r=Of(e),n=r.length>0?{[x]:"Object",type:"object",required:r,properties:e}:{[x]:"Object",type:"object",properties:e};return l(n,t)}var X=$f;function Ho(e,t){return l({[x]:"Promise",type:"Promise",item:e},t)}function wf(e){return l(ye(e,[Gt]))}function Rf(e){return l({...e,[Gt]:"Readonly"})}function Ff(e,t){return t===!1?wf(e):Rf(e)}function Ye(e,t){let r=t??!0;return ue(e)?zs(e,r):Ff(e,r)}function Af(e,t){let r={};for(let n of globalThis.Object.getOwnPropertyNames(e))r[n]=Ye(e[n],t);return r}function kf(e,t){return Af(e.properties,t)}function zs(e,t){let r=kf(e,t);return H(r)}function mt(e,t){return l(e.length>0?{[x]:"Tuple",type:"array",items:e,additionalItems:!1,minItems:e.length,maxItems:e.length}:{[x]:"Tuple",type:"array",minItems:e.length,maxItems:e.length},t)}function Ws(e,t){return e.includes(t)}function Js(e){return[...new Set(e)]}function Cf(e,t){return e.filter((r)=>t.includes(r))}function Tf(e,t){return e.reduce((r,n)=>Cf(r,n),t)}function Ys(e){return e.length===1?e[0]:e.length>1?Tf(e.slice(1),e[0]):[]}function Xs(e){let t=[];for(let r of e)t.push(...r);return t}function Qs(e,t){return e in t?pt(e,t[e]):H(t)}function Pf(e){return{[e]:W(e)}}function Nf(e){let t={};for(let r of e)t[r]=W(r);return t}function Sf(e,t){return Ws(t,e)?Pf(e):Nf(t)}function jf(e,t){let r=Sf(e,t);return Qs(e,r)}function no(e,t){return t.map((r)=>pt(e,r))}function Mf(e,t){let r={};for(let n of globalThis.Object.getOwnPropertyNames(t))r[n]=pt(e,t[n]);return r}function pt(e,t){let r={...t};return We(t)?Le(pt(e,ye(t,[Se]))):dn(t)?Ye(pt(e,ye(t,[Gt]))):ue(t)?Qs(e,t.properties):st(t)?jf(e,t.keys):wt(t)?fn(no(e,t.parameters),pt(e,t.returns),r):Rt(t)?vt(no(e,t.parameters),pt(e,t.returns),r):Mr(t)?un(pt(e,t.items),r):Er(t)?yn(pt(e,t.items),r):ge(t)?Ke(no(e,t.allOf),r):v(t)?J(no(e,t.anyOf),r):ct(t)?mt(no(e,t.items??[]),r):be(t)?X(Mf(e,t.properties),r):Ot(t)?cn(pt(e,t.items),r):Lr(t)?Ho(pt(e,t.item),r):t}function Uf(e,t){let r={};for(let n of e)r[n]=pt(n,t);return r}function Zs(e,t,r){let n=me(e)?Je(e):e,o=t({[x]:"MappedKey",keys:n}),i=Uf(n,o);return X(i,r)}function lt(...e){let[t,r]=typeof e[0]==="string"?[e[0],e[1]]:[e[0].$id,e[1]];if(typeof t!=="string")throw new z("Ref: $ref must be a string");return l({[x]:"Ref",$ref:t},r)}function ea(e){let t=[];for(let r of e)t.push(yt(r));return t}function Ef(e){let t=ea(e);return Xs(t)}function Lf(e){let t=ea(e);return Ys(t)}function Kf(e){return e.map((t,r)=>r.toString())}function Bf(e){return["[number]"]}function Df(e){return globalThis.Object.getOwnPropertyNames(e)}function Gf(e){if(!ji)return[];return globalThis.Object.getOwnPropertyNames(e).map((r)=>r[0]==="^"&&r[r.length-1]==="$"?r.slice(1,r.length-1):r)}function yt(e){return ge(e)?Ef(e.allOf):v(e)?Lf(e.anyOf):ct(e)?Kf(e.items??[]):Ot(e)?Bf(e.items):be(e)?Df(e.properties):Kr(e)?Gf(e.patternProperties):[]}var ji=!1;function rr(e){ji=!0;let t=yt(e);return ji=!1,`^(${t.map((n)=>`(${n})`).join("|")})$`}function qf(e,t){return se("KeyOf",[se(e,t)])}function vf(e){return se("KeyOf",[lt(e)])}function Hf(e,t){let r=yt(e),n=Vf(r),o=Ht(n);return l(o,t)}function Vf(e){return e.map((t)=>t==="[number]"?dt():W(t))}function gn(e,t){return $t(e)?qf(e.target,e.parameters):Ie(e)?vf(e.$ref):ue(e)?ta(e,t):Hf(e,t)}function zf(e,t){let r={};for(let n of globalThis.Object.getOwnPropertyNames(e))r[n]=gn(e[n],ce(t));return r}function Wf(e,t){return zf(e.properties,t)}function ta(e,t){let r=Wf(e,t);return H(r)}function Vo(e){let t=yt(e),r=ro(e,t);return t.map((n,o)=>[t[o],r[o]])}function Jf(e){return e.allOf.every((t)=>nr(t))}function Yf(e){return e.anyOf.some((t)=>nr(t))}function Xf(e){return!nr(e.not)}function nr(e){return e[x]==="Intersect"?Jf(e):e[x]==="Union"?Yf(e):e[x]==="Not"?Xf(e):e[x]==="Undefined"?!0:!1}function Qf(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[x]}'`;default:return"Unknown error type"}}var Zf=Qf;function ra(){return Zf}class na extends z{constructor(e){super(`Unable to dereference schema with $id '${e.$ref}'`);this.schema=e}}function ed(e,t){let r=t.find((n)=>n.$id===e.$ref);if(r===void 0)throw new na(e);return Ce(r,t)}function hr(e,t){if(!ke(e.$id)||t.some((r)=>r.$id===e.$id))return t;return t.push(e),t}function Ce(e,t){return e[x]==="This"||e[x]==="Ref"?ed(e,t):e}class oa extends z{constructor(e){super("Unable to hash value");this.value=e}}var ut;(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"})(ut||(ut={}));var xn=BigInt("14695981039346656037"),[td,rd]=[BigInt("1099511628211"),BigInt("18446744073709551616")],nd=Array.from({length:256}).map((e,t)=>BigInt(t)),ia=new Float64Array(1),sa=new DataView(ia.buffer),aa=new Uint8Array(ia.buffer);function*od(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 id(e){Be(ut.Array);for(let t of e)hn(t)}function sd(e){Be(ut.Boolean),Be(e?1:0)}function ad(e){Be(ut.BigInt),sa.setBigInt64(0,e);for(let t of aa)Be(t)}function cd(e){Be(ut.Date),hn(e.getTime())}function ud(e){Be(ut.Null)}function fd(e){Be(ut.Number),sa.setFloat64(0,e);for(let t of aa)Be(t)}function dd(e){Be(ut.Object);for(let t of globalThis.Object.getOwnPropertyNames(e).sort())hn(t),hn(e[t])}function md(e){Be(ut.String);for(let t=0;t<e.length;t++)for(let r of od(e.charCodeAt(t)))Be(r)}function pd(e){Be(ut.Symbol),hn(e.description)}function ld(e){Be(ut.Uint8Array);for(let t=0;t<e.length;t++)Be(e[t])}function yd(e){return Be(ut.Undefined)}function hn(e){if(_e(e))return id(e);if(Nr(e))return sd(e);if(nt(e))return ad(e);if(on(e))return cd(e);if(Pr(e))return ud(e);if(M(e))return fd(e);if(ze(e))return dd(e);if(ke(e))return md(e);if(Sr(e))return pd(e);if(sn(e))return ld(e);if(ve(e))return yd(e);throw new oa(e)}function Be(e){xn=xn^nd[e],xn=xn*td%rd}function In(e){return xn=BigInt("14695981039346656037"),hn(e),xn}function Ir(e){return l({[x]:"Any"},e)}function br(e){return l({[x]:"Unknown"},e)}var gd=["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 ca(e){try{return new RegExp(e),!0}catch{return!1}}function Mi(e){if(!oe(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 ua(e){return Ui(e)||pe(e)}function oo(e){return ie(e)||Uo(e)}function te(e){return ie(e)||ot(e)}function Ui(e){return ie(e)||mr(e)}function Q(e){return ie(e)||oe(e)}function xd(e){return ie(e)||oe(e)&&Mi(e)&&ca(e)}function hd(e){return ie(e)||oe(e)&&Mi(e)}function fa(e){return ie(e)||pe(e)}function zo(e){return ae(e)&&e[Se]==="Optional"}function Ct(e){return q(e,"Any")&&Q(e.$id)}function Id(e){return q(e,"Argument")&&ot(e.index)}function Gr(e){return q(e,"Array")&&e.type==="array"&&Q(e.$id)&&pe(e.items)&&te(e.minItems)&&te(e.maxItems)&&Ui(e.uniqueItems)&&fa(e.contains)&&te(e.minContains)&&te(e.maxContains)}function Ei(e){return q(e,"AsyncIterator")&&e.type==="AsyncIterator"&&Q(e.$id)&&pe(e.items)}function Wo(e){return q(e,"BigInt")&&e.type==="bigint"&&Q(e.$id)&&oo(e.exclusiveMaximum)&&oo(e.exclusiveMinimum)&&oo(e.maximum)&&oo(e.minimum)&&oo(e.multipleOf)}function qr(e){return q(e,"Boolean")&&e.type==="boolean"&&Q(e.$id)}function bd(e){return q(e,"Computed")&&oe(e.target)&&Oe(e.parameters)&&e.parameters.every((t)=>pe(t))}function Jo(e){return q(e,"Constructor")&&e.type==="Constructor"&&Q(e.$id)&&Oe(e.parameters)&&e.parameters.every((t)=>pe(t))&&pe(e.returns)}function Yo(e){return q(e,"Date")&&e.type==="Date"&&Q(e.$id)&&te(e.exclusiveMaximumTimestamp)&&te(e.exclusiveMinimumTimestamp)&&te(e.maximumTimestamp)&&te(e.minimumTimestamp)&&te(e.multipleOfTimestamp)}function Xo(e){return q(e,"Function")&&e.type==="Function"&&Q(e.$id)&&Oe(e.parameters)&&e.parameters.every((t)=>pe(t))&&pe(e.returns)}function or(e){return q(e,"Integer")&&e.type==="integer"&&Q(e.$id)&&te(e.exclusiveMaximum)&&te(e.exclusiveMinimum)&&te(e.maximum)&&te(e.minimum)&&te(e.multipleOf)}function da(e){return ae(e)&&Object.entries(e).every(([t,r])=>Mi(t)&&pe(r))}function vr(e){return q(e,"Intersect")&&(oe(e.type)&&e.type!=="object"?!1:!0)&&Oe(e.allOf)&&e.allOf.every((t)=>pe(t)&&!Fd(t))&&Q(e.type)&&(Ui(e.unevaluatedProperties)||fa(e.unevaluatedProperties))&&Q(e.$id)}function Li(e){return q(e,"Iterator")&&e.type==="Iterator"&&Q(e.$id)&&pe(e.items)}function q(e,t){return ae(e)&&x in e&&e[x]===t}function ma(e){return _r(e)&&oe(e.const)}function pa(e){return _r(e)&&ot(e.const)}function la(e){return _r(e)&&mr(e.const)}function _r(e){return q(e,"Literal")&&Q(e.$id)&&_d(e.const)}function _d(e){return mr(e)||ot(e)||oe(e)}function Od(e){return q(e,"MappedKey")&&Oe(e.keys)&&e.keys.every((t)=>ot(t)||oe(t))}function $d(e){return q(e,"MappedResult")&&da(e.properties)}function Or(e){return q(e,"Never")&&ae(e.not)&&Object.getOwnPropertyNames(e.not).length===0}function bn(e){return q(e,"Not")&&pe(e.not)}function Ki(e){return q(e,"Null")&&e.type==="null"&&Q(e.$id)}function Xe(e){return q(e,"Number")&&e.type==="number"&&Q(e.$id)&&te(e.exclusiveMaximum)&&te(e.exclusiveMinimum)&&te(e.maximum)&&te(e.minimum)&&te(e.multipleOf)}function xe(e){return q(e,"Object")&&e.type==="object"&&Q(e.$id)&&da(e.properties)&&ua(e.additionalProperties)&&te(e.minProperties)&&te(e.maxProperties)}function Bi(e){return q(e,"Promise")&&e.type==="Promise"&&Q(e.$id)&&pe(e.item)}function je(e){return q(e,"Record")&&e.type==="object"&&Q(e.$id)&&ua(e.additionalProperties)&&ae(e.patternProperties)&&((t)=>{let r=Object.getOwnPropertyNames(t.patternProperties);return r.length===1&&ca(r[0])&&ae(t.patternProperties)&&pe(t.patternProperties[r[0]])})(e)}function wd(e){return q(e,"Ref")&&Q(e.$id)&&oe(e.$ref)}function io(e){return q(e,"RegExp")&&Q(e.$id)&&oe(e.source)&&oe(e.flags)&&te(e.maxLength)&&te(e.minLength)}function Tt(e){return q(e,"String")&&e.type==="string"&&Q(e.$id)&&te(e.minLength)&&te(e.maxLength)&&xd(e.pattern)&&hd(e.format)}function so(e){return q(e,"Symbol")&&e.type==="symbol"&&Q(e.$id)}function ao(e){return q(e,"TemplateLiteral")&&e.type==="string"&&oe(e.pattern)&&e.pattern[0]==="^"&&e.pattern[e.pattern.length-1]==="$"}function Rd(e){return q(e,"This")&&Q(e.$id)&&oe(e.$ref)}function Fd(e){return ae(e)&&de in e}function Qo(e){return q(e,"Tuple")&&e.type==="array"&&Q(e.$id)&&ot(e.minItems)&&ot(e.maxItems)&&e.minItems===e.maxItems&&(ie(e.items)&&ie(e.additionalItems)&&e.minItems===0||Oe(e.items)&&e.items.every((t)=>pe(t)))}function Hr(e){return q(e,"Undefined")&&e.type==="undefined"&&Q(e.$id)}function ir(e){return q(e,"Union")&&Q(e.$id)&&ae(e)&&Oe(e.anyOf)&&e.anyOf.every((t)=>pe(t))}function co(e){return q(e,"Uint8Array")&&e.type==="Uint8Array"&&Q(e.$id)&&te(e.minByteLength)&&te(e.maxByteLength)}function Pt(e){return q(e,"Unknown")&&Q(e.$id)}function Ad(e){return q(e,"Unsafe")}function Zo(e){return q(e,"Void")&&e.type==="void"&&Q(e.$id)}function kd(e){return ae(e)&&x in e&&oe(e[x])&&!gd.includes(e[x])}function pe(e){return ae(e)&&(Ct(e)||Id(e)||Gr(e)||qr(e)||Wo(e)||Ei(e)||bd(e)||Jo(e)||Yo(e)||Xo(e)||or(e)||vr(e)||Li(e)||_r(e)||Od(e)||$d(e)||Or(e)||bn(e)||Ki(e)||Xe(e)||xe(e)||Bi(e)||je(e)||wd(e)||io(e)||Tt(e)||so(e)||ao(e)||Rd(e)||Qo(e)||Hr(e)||ir(e)||co(e)||Pt(e)||Ad(e)||Zo(e)||kd(e))}class ba extends z{}var y;(function(e){e[e.Union=0]="Union",e[e.True=1]="True",e[e.False=2]="False"})(y||(y={}));function gt(e){return e===y.False?e:y.True}function _n(e){throw new ba(e)}function $e(e){return Or(e)||vr(e)||ir(e)||Pt(e)||Ct(e)}function we(e,t){return Or(t)?$a(e,t):vr(t)?ei(e,t):ir(t)?Hi(e,t):Pt(t)?Aa(e,t):Ct(t)?vi(e,t):_n("StructuralRight")}function vi(e,t){return y.True}function Cd(e,t){return vr(t)?ei(e,t):ir(t)&&t.anyOf.some((r)=>Ct(r)||Pt(r))?y.True:ir(t)?y.Union:Pt(t)?y.True:Ct(t)?y.True:y.Union}function Td(e,t){return Pt(e)?y.False:Ct(e)?y.Union:Or(e)?y.True:y.False}function Pd(e,t){return xe(t)&&ti(t)?y.True:$e(t)?we(e,t):!Gr(t)?y.False:gt(Z(e.items,t.items))}function Nd(e,t){return $e(t)?we(e,t):!Ei(t)?y.False:gt(Z(e.items,t.items))}function Sd(e,t){return $e(t)?we(e,t):xe(t)?De(e,t):je(t)?xt(e,t):Wo(t)?y.True:y.False}function _a(e,t){return la(e)?y.True:qr(e)?y.True:y.False}function jd(e,t){return $e(t)?we(e,t):xe(t)?De(e,t):je(t)?xt(e,t):qr(t)?y.True:y.False}function Md(e,t){return $e(t)?we(e,t):xe(t)?De(e,t):!Jo(t)?y.False:e.parameters.length>t.parameters.length?y.False:!e.parameters.every((r,n)=>gt(Z(t.parameters[n],r))===y.True)?y.False:gt(Z(e.returns,t.returns))}function Ud(e,t){return $e(t)?we(e,t):xe(t)?De(e,t):je(t)?xt(e,t):Yo(t)?y.True:y.False}function Ed(e,t){return $e(t)?we(e,t):xe(t)?De(e,t):!Xo(t)?y.False:e.parameters.length>t.parameters.length?y.False:!e.parameters.every((r,n)=>gt(Z(t.parameters[n],r))===y.True)?y.False:gt(Z(e.returns,t.returns))}function Oa(e,t){return _r(e)&&ot(e.const)?y.True:Xe(e)||or(e)?y.True:y.False}function Ld(e,t){return or(t)||Xe(t)?y.True:$e(t)?we(e,t):xe(t)?De(e,t):je(t)?xt(e,t):y.False}function ei(e,t){return t.allOf.every((r)=>Z(e,r)===y.True)?y.True:y.False}function Kd(e,t){return e.allOf.some((r)=>Z(r,t)===y.True)?y.True:y.False}function Bd(e,t){return $e(t)?we(e,t):!Li(t)?y.False:gt(Z(e.items,t.items))}function Dd(e,t){return _r(t)&&t.const===e.const?y.True:$e(t)?we(e,t):xe(t)?De(e,t):je(t)?xt(e,t):Tt(t)?Fa(e,t):Xe(t)?wa(e,t):or(t)?Oa(e,t):qr(t)?_a(e,t):y.False}function $a(e,t){return y.False}function Gd(e,t){return y.True}function ga(e){let[t,r]=[e,0];while(!0){if(!bn(t))break;t=t.not,r+=1}return r%2===0?t:br()}function qd(e,t){return bn(e)?Z(ga(e),t):bn(t)?Z(e,ga(t)):_n("Invalid fallthrough for Not")}function vd(e,t){return $e(t)?we(e,t):xe(t)?De(e,t):je(t)?xt(e,t):Ki(t)?y.True:y.False}function wa(e,t){return pa(e)?y.True:Xe(e)||or(e)?y.True:y.False}function Hd(e,t){return $e(t)?we(e,t):xe(t)?De(e,t):je(t)?xt(e,t):or(t)||Xe(t)?y.True:y.False}function Qe(e,t){return Object.getOwnPropertyNames(e.properties).length===t}function xa(e){return ti(e)}function ha(e){return Qe(e,0)||Qe(e,1)&&"description"in e.properties&&ir(e.properties.description)&&e.properties.description.anyOf.length===2&&(Tt(e.properties.description.anyOf[0])&&Hr(e.properties.description.anyOf[1])||Tt(e.properties.description.anyOf[1])&&Hr(e.properties.description.anyOf[0]))}function Di(e){return Qe(e,0)}function Ia(e){return Qe(e,0)}function Vd(e){return Qe(e,0)}function zd(e){return Qe(e,0)}function Wd(e){return ti(e)}function Jd(e){let t=dt();return Qe(e,0)||Qe(e,1)&&"length"in e.properties&&gt(Z(e.properties.length,t))===y.True}function Yd(e){return Qe(e,0)}function ti(e){let t=dt();return Qe(e,0)||Qe(e,1)&&"length"in e.properties&&gt(Z(e.properties.length,t))===y.True}function Xd(e){let t=vt([Ir()],Ir());return Qe(e,0)||Qe(e,1)&&"then"in e.properties&&gt(Z(e.properties.then,t))===y.True}function Ra(e,t){return Z(e,t)===y.False?y.False:zo(e)&&!zo(t)?y.False:y.True}function De(e,t){return Pt(e)?y.False:Ct(e)?y.Union:Or(e)||ma(e)&&xa(t)||pa(e)&&Di(t)||la(e)&&Ia(t)||so(e)&&ha(t)||Wo(e)&&Vd(t)||Tt(e)&&xa(t)||so(e)&&ha(t)||Xe(e)&&Di(t)||or(e)&&Di(t)||qr(e)&&Ia(t)||co(e)&&Wd(t)||Yo(e)&&zd(t)||Jo(e)&&Yd(t)||Xo(e)&&Jd(t)?y.True:je(e)&&Tt(Gi(e))?(()=>t[qt]==="Record"?y.True:y.False)():je(e)&&Xe(Gi(e))?(()=>Qe(t,0)?y.True:y.False)():y.False}function Qd(e,t){return $e(t)?we(e,t):je(t)?xt(e,t):!xe(t)?y.False:(()=>{for(let r of Object.getOwnPropertyNames(t.properties)){if(!(r in e.properties)&&!zo(t.properties[r]))return y.False;if(zo(t.properties[r]))return y.True;if(Ra(e.properties[r],t.properties[r])===y.False)return y.False}return y.True})()}function Zd(e,t){return $e(t)?we(e,t):xe(t)&&Xd(t)?y.True:!Bi(t)?y.False:gt(Z(e.item,t.item))}function Gi(e){return yr in e.patternProperties?dt():(gr in e.patternProperties)?kt():_n("Unknown record key pattern")}function qi(e){return yr in e.patternProperties?e.patternProperties[yr]:(gr in e.patternProperties)?e.patternProperties[gr]:_n("Unable to get record value schema")}function xt(e,t){let[r,n]=[Gi(t),qi(t)];return ma(e)&&Xe(r)&&gt(Z(e,n))===y.True?y.True:co(e)&&Xe(r)?Z(e,n):Tt(e)&&Xe(r)?Z(e,n):Gr(e)&&Xe(r)?Z(e,n):xe(e)?(()=>{for(let o of Object.getOwnPropertyNames(e.properties))if(Ra(n,e.properties[o])===y.False)return y.False;return y.True})():y.False}function em(e,t){return $e(t)?we(e,t):xe(t)?De(e,t):!je(t)?y.False:Z(qi(e),qi(t))}function tm(e,t){let r=io(e)?kt():e,n=io(t)?kt():t;return Z(r,n)}function Fa(e,t){return _r(e)&&oe(e.const)?y.True:Tt(e)?y.True:y.False}function rm(e,t){return $e(t)?we(e,t):xe(t)?De(e,t):je(t)?xt(e,t):Tt(t)?y.True:y.False}function nm(e,t){return $e(t)?we(e,t):xe(t)?De(e,t):je(t)?xt(e,t):so(t)?y.True:y.False}function om(e,t){return ao(e)?Z(Dr(e),t):ao(t)?Z(e,Dr(t)):_n("Invalid fallthrough for TemplateLiteral")}function im(e,t){return Gr(t)&&e.items!==void 0&&e.items.every((r)=>Z(r,t.items)===y.True)}function sm(e,t){return Or(e)?y.True:Pt(e)?y.False:Ct(e)?y.Union:y.False}function am(e,t){return $e(t)?we(e,t):xe(t)&&ti(t)?y.True:Gr(t)&&im(e,t)?y.True:!Qo(t)?y.False:ie(e.items)&&!ie(t.items)||!ie(e.items)&&ie(t.items)?y.False:ie(e.items)&&!ie(t.items)?y.True:e.items.every((r,n)=>Z(r,t.items[n])===y.True)?y.True:y.False}function cm(e,t){return $e(t)?we(e,t):xe(t)?De(e,t):je(t)?xt(e,t):co(t)?y.True:y.False}function um(e,t){return $e(t)?we(e,t):xe(t)?De(e,t):je(t)?xt(e,t):Zo(t)?mm(e,t):Hr(t)?y.True:y.False}function Hi(e,t){return t.anyOf.some((r)=>Z(e,r)===y.True)?y.True:y.False}function fm(e,t){return e.anyOf.every((r)=>Z(r,t)===y.True)?y.True:y.False}function Aa(e,t){return y.True}function dm(e,t){return Or(t)?$a(e,t):vr(t)?ei(e,t):ir(t)?Hi(e,t):Ct(t)?vi(e,t):Tt(t)?Fa(e,t):Xe(t)?wa(e,t):or(t)?Oa(e,t):qr(t)?_a(e,t):Gr(t)?Td(e,t):Qo(t)?sm(e,t):xe(t)?De(e,t):Pt(t)?y.True:y.False}function mm(e,t){return Hr(e)?y.True:Hr(e)?y.True:y.False}function pm(e,t){return vr(t)?ei(e,t):ir(t)?Hi(e,t):Pt(t)?Aa(e,t):Ct(t)?vi(e,t):xe(t)?De(e,t):Zo(t)?y.True:y.False}function Z(e,t){return ao(e)||ao(t)?om(e,t):io(e)||io(t)?tm(e,t):bn(e)||bn(t)?qd(e,t):Ct(e)?Cd(e,t):Gr(e)?Pd(e,t):Wo(e)?Sd(e,t):qr(e)?jd(e,t):Ei(e)?Nd(e,t):Jo(e)?Md(e,t):Yo(e)?Ud(e,t):Xo(e)?Ed(e,t):or(e)?Ld(e,t):vr(e)?Kd(e,t):Li(e)?Bd(e,t):_r(e)?Dd(e,t):Or(e)?Gd(e,t):Ki(e)?vd(e,t):Xe(e)?Hd(e,t):xe(e)?Qd(e,t):je(e)?em(e,t):Tt(e)?rm(e,t):so(e)?nm(e,t):Qo(e)?am(e,t):Bi(e)?Zd(e,t):co(e)?cm(e,t):Hr(e)?um(e,t):ir(e)?fm(e,t):Pt(e)?dm(e,t):Zo(e)?pm(e,t):_n(`Unknown left type operand '${e[x]}'`)}function $r(e,t){return Z(e,t)}function lm(e,t,r,n,o){let i={};for(let s of globalThis.Object.getOwnPropertyNames(e))i[s]=On(e[s],t,r,n,ce(o));return i}function ym(e,t,r,n,o){return lm(e.properties,t,r,n,o)}function ka(e,t,r,n,o){let i=ym(e,t,r,n,o);return H(i)}function gm(e,t,r,n){let o=$r(e,t);return o===y.Union?J([r,n]):o===y.True?r:n}function On(e,t,r,n,o){return ue(e)?ka(e,t,r,n,o):st(e)?l(Ca(e,t,r,n,o)):l(gm(e,t,r,n),o)}function xm(e,t,r,n,o){return{[e]:On(W(e),t,r,n,ce(o))}}function hm(e,t,r,n,o){return e.reduce((i,s)=>({...i,...xm(s,t,r,n,o)}),{})}function Im(e,t,r,n,o){return hm(e.keys,t,r,n,o)}function Ca(e,t,r,n,o){let i=Im(e,t,r,n,o);return H(i)}class Ta extends z{constructor(e){super("Unknown type");this.schema=e}}function bm(e){return e[x]==="Any"||e[x]==="Unknown"}function K(e){return e!==void 0}function _m(e,t,r){return!0}function Om(e,t,r){return!0}function $m(e,t,r){if(!_e(r))return!1;if(K(e.minItems)&&!(r.length>=e.minItems))return!1;if(K(e.maxItems)&&!(r.length<=e.maxItems))return!1;if(!r.every((i)=>Te(e.items,t,i)))return!1;if(e.uniqueItems===!0&&!function(){let i=new Set;for(let s of r){let a=In(s);if(i.has(a))return!1;else i.add(a)}return!0}())return!1;if(!(K(e.contains)||M(e.minContains)||M(e.maxContains)))return!0;let n=K(e.contains)?e.contains:E(),o=r.reduce((i,s)=>Te(n,t,s)?i+1:i,0);if(o===0)return!1;if(M(e.minContains)&&o<e.minContains)return!1;if(M(e.maxContains)&&o>e.maxContains)return!1;return!0}function wm(e,t,r){return Ao(r)}function Rm(e,t,r){if(!nt(r))return!1;if(K(e.exclusiveMaximum)&&!(r<e.exclusiveMaximum))return!1;if(K(e.exclusiveMinimum)&&!(r>e.exclusiveMinimum))return!1;if(K(e.maximum)&&!(r<=e.maximum))return!1;if(K(e.minimum)&&!(r>=e.minimum))return!1;if(K(e.multipleOf)&&r%e.multipleOf!==BigInt(0))return!1;return!0}function Fm(e,t,r){return Nr(r)}function Am(e,t,r){return Te(e.returns,t,r.prototype)}function km(e,t,r){if(!on(r))return!1;if(K(e.exclusiveMaximumTimestamp)&&!(r.getTime()<e.exclusiveMaximumTimestamp))return!1;if(K(e.exclusiveMinimumTimestamp)&&!(r.getTime()>e.exclusiveMinimumTimestamp))return!1;if(K(e.maximumTimestamp)&&!(r.getTime()<=e.maximumTimestamp))return!1;if(K(e.minimumTimestamp)&&!(r.getTime()>=e.minimumTimestamp))return!1;if(K(e.multipleOfTimestamp)&&r.getTime()%e.multipleOfTimestamp!==0)return!1;return!0}function Cm(e,t,r){return No(r)}function Tm(e,t,r){let n=globalThis.Object.values(e.$defs),o=e.$defs[e.$ref];return Te(o,[...t,...n],r)}function Pm(e,t,r){if(!Po(r))return!1;if(K(e.exclusiveMaximum)&&!(r<e.exclusiveMaximum))return!1;if(K(e.exclusiveMinimum)&&!(r>e.exclusiveMinimum))return!1;if(K(e.maximum)&&!(r<=e.maximum))return!1;if(K(e.minimum)&&!(r>=e.minimum))return!1;if(K(e.multipleOf)&&r%e.multipleOf!==0)return!1;return!0}function Nm(e,t,r){let n=e.allOf.every((o)=>Te(o,t,r));if(e.unevaluatedProperties===!1){let o=new RegExp(rr(e)),i=Object.getOwnPropertyNames(r).every((s)=>o.test(s));return n&&i}else if(me(e.unevaluatedProperties)){let o=new RegExp(rr(e)),i=Object.getOwnPropertyNames(r).every((s)=>o.test(s)||Te(e.unevaluatedProperties,t,r[s]));return n&&i}else return n}function Sm(e,t,r){return ko(r)}function jm(e,t,r){return r===e.const}function Mm(e,t,r){return!1}function Um(e,t,r){return!Te(e.not,t,r)}function Em(e,t,r){return Pr(r)}function Lm(e,t,r){if(!ne.IsNumberLike(r))return!1;if(K(e.exclusiveMaximum)&&!(r<e.exclusiveMaximum))return!1;if(K(e.exclusiveMinimum)&&!(r>e.exclusiveMinimum))return!1;if(K(e.minimum)&&!(r>=e.minimum))return!1;if(K(e.maximum)&&!(r<=e.maximum))return!1;if(K(e.multipleOf)&&r%e.multipleOf!==0)return!1;return!0}function Km(e,t,r){if(!ne.IsObjectLike(r))return!1;if(K(e.minProperties)&&!(Object.getOwnPropertyNames(r).length>=e.minProperties))return!1;if(K(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(!Te(i,t,r[o]))return!1;if((nr(i)||bm(i))&&!(o in r))return!1}else if(ne.IsExactOptionalProperty(r,o)&&!Te(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)||Te(e.additionalProperties,t,r[i]));else return!0}function Bm(e,t,r){return Co(r)}function Dm(e,t,r){if(!ne.IsRecordLike(r))return!1;if(K(e.minProperties)&&!(Object.getOwnPropertyNames(r).length>=e.minProperties))return!1;if(K(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(([u,m])=>i.test(u)?Te(o,t,m):!0),a=typeof e.additionalProperties==="object"?Object.entries(r).every(([u,m])=>!i.test(u)?Te(e.additionalProperties,t,m):!0):!0,c=e.additionalProperties===!1?Object.getOwnPropertyNames(r).every((u)=>i.test(u)):!0;return s&&a&&c}function Gm(e,t,r){return Te(Ce(e,t),t,r)}function qm(e,t,r){let n=new RegExp(e.source,e.flags);if(K(e.minLength)){if(!(r.length>=e.minLength))return!1}if(K(e.maxLength)){if(!(r.length<=e.maxLength))return!1}return n.test(r)}function vm(e,t,r){if(!ke(r))return!1;if(K(e.minLength)){if(!(r.length>=e.minLength))return!1}if(K(e.maxLength)){if(!(r.length<=e.maxLength))return!1}if(K(e.pattern)){if(!new RegExp(e.pattern).test(r))return!1}if(K(e.format)){if(!wi(e.format))return!1;return Ri(e.format)(r)}return!0}function Hm(e,t,r){return Sr(r)}function Vm(e,t,r){return ke(r)&&new RegExp(e.pattern).test(r)}function zm(e,t,r){return Te(Ce(e,t),t,r)}function Wm(e,t,r){if(!_e(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(!Te(e.items[n],t,r[n]))return!1;return!0}function Jm(e,t,r){return ve(r)}function Ym(e,t,r){return e.anyOf.some((n)=>Te(n,t,r))}function Xm(e,t,r){if(!sn(r))return!1;if(K(e.maxByteLength)&&!(r.length<=e.maxByteLength))return!1;if(K(e.minByteLength)&&!(r.length>=e.minByteLength))return!1;return!0}function Qm(e,t,r){return!0}function Zm(e,t,r){return ne.IsVoidLike(r)}function ep(e,t,r){if(!Wn(e[x]))return!1;return Fi(e[x])(e,r)}function Te(e,t,r){let n=K(e.$id)?hr(e,t):t,o=e;switch(o[x]){case"Any":return _m(o,n,r);case"Argument":return Om(o,n,r);case"Array":return $m(o,n,r);case"AsyncIterator":return wm(o,n,r);case"BigInt":return Rm(o,n,r);case"Boolean":return Fm(o,n,r);case"Constructor":return Am(o,n,r);case"Date":return km(o,n,r);case"Function":return Cm(o,n,r);case"Import":return Tm(o,n,r);case"Integer":return Pm(o,n,r);case"Intersect":return Nm(o,n,r);case"Iterator":return Sm(o,n,r);case"Literal":return jm(o,n,r);case"Never":return Mm(o,n,r);case"Not":return Um(o,n,r);case"Null":return Em(o,n,r);case"Number":return Lm(o,n,r);case"Object":return Km(o,n,r);case"Promise":return Bm(o,n,r);case"Record":return Dm(o,n,r);case"Ref":return Gm(o,n,r);case"RegExp":return qm(o,n,r);case"String":return vm(o,n,r);case"Symbol":return Hm(o,n,r);case"TemplateLiteral":return Vm(o,n,r);case"This":return zm(o,n,r);case"Tuple":return Wm(o,n,r);case"Undefined":return Jm(o,n,r);case"Union":return Ym(o,n,r);case"Uint8Array":return Xm(o,n,r);case"Unknown":return Qm(o,n,r);case"Void":return Zm(o,n,r);default:if(!Wn(o[x]))throw new Ta(o);return ep(o,n,r)}}function Vr(...e){return e.length===3?Te(e[0],e[1],e[2]):Te(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 Pa extends z{constructor(e){super("Unknown type");this.schema=e}}function sr(e){return e.replace(/~/g,"~0").replace(/\//g,"~1")}function B(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 _(e,t,r,n,o=[]){return{type:e,schema:t,path:r,value:n,message:ra()({errorType:e,path:r,schema:t,value:n,errors:o}),errors:o}}function*tp(e,t,r,n){}function*rp(e,t,r,n){}function*np(e,t,r,n){if(!_e(n))return yield _(p.Array,e,r,n);if(B(e.minItems)&&!(n.length>=e.minItems))yield _(p.ArrayMinItems,e,r,n);if(B(e.maxItems)&&!(n.length<=e.maxItems))yield _(p.ArrayMaxItems,e,r,n);for(let s=0;s<n.length;s++)yield*Pe(e.items,t,`${r}/${s}`,n[s]);if(e.uniqueItems===!0&&!function(){let s=new Set;for(let a of n){let c=In(a);if(s.has(c))return!1;else s.add(c)}return!0}())yield _(p.ArrayUniqueItems,e,r,n);if(!(B(e.contains)||B(e.minContains)||B(e.maxContains)))return;let o=B(e.contains)?e.contains:E(),i=n.reduce((s,a,c)=>Pe(o,t,`${r}${c}`,a).next().done===!0?s+1:s,0);if(i===0)yield _(p.ArrayContains,e,r,n);if(M(e.minContains)&&i<e.minContains)yield _(p.ArrayMinContains,e,r,n);if(M(e.maxContains)&&i>e.maxContains)yield _(p.ArrayMaxContains,e,r,n)}function*op(e,t,r,n){if(!Ao(n))yield _(p.AsyncIterator,e,r,n)}function*ip(e,t,r,n){if(!nt(n))return yield _(p.BigInt,e,r,n);if(B(e.exclusiveMaximum)&&!(n<e.exclusiveMaximum))yield _(p.BigIntExclusiveMaximum,e,r,n);if(B(e.exclusiveMinimum)&&!(n>e.exclusiveMinimum))yield _(p.BigIntExclusiveMinimum,e,r,n);if(B(e.maximum)&&!(n<=e.maximum))yield _(p.BigIntMaximum,e,r,n);if(B(e.minimum)&&!(n>=e.minimum))yield _(p.BigIntMinimum,e,r,n);if(B(e.multipleOf)&&n%e.multipleOf!==BigInt(0))yield _(p.BigIntMultipleOf,e,r,n)}function*sp(e,t,r,n){if(!Nr(n))yield _(p.Boolean,e,r,n)}function*ap(e,t,r,n){yield*Pe(e.returns,t,r,n.prototype)}function*cp(e,t,r,n){if(!on(n))return yield _(p.Date,e,r,n);if(B(e.exclusiveMaximumTimestamp)&&!(n.getTime()<e.exclusiveMaximumTimestamp))yield _(p.DateExclusiveMaximumTimestamp,e,r,n);if(B(e.exclusiveMinimumTimestamp)&&!(n.getTime()>e.exclusiveMinimumTimestamp))yield _(p.DateExclusiveMinimumTimestamp,e,r,n);if(B(e.maximumTimestamp)&&!(n.getTime()<=e.maximumTimestamp))yield _(p.DateMaximumTimestamp,e,r,n);if(B(e.minimumTimestamp)&&!(n.getTime()>=e.minimumTimestamp))yield _(p.DateMinimumTimestamp,e,r,n);if(B(e.multipleOfTimestamp)&&n.getTime()%e.multipleOfTimestamp!==0)yield _(p.DateMultipleOfTimestamp,e,r,n)}function*up(e,t,r,n){if(!No(n))yield _(p.Function,e,r,n)}function*fp(e,t,r,n){let o=globalThis.Object.values(e.$defs),i=e.$defs[e.$ref];yield*Pe(i,[...t,...o],r,n)}function*dp(e,t,r,n){if(!Po(n))return yield _(p.Integer,e,r,n);if(B(e.exclusiveMaximum)&&!(n<e.exclusiveMaximum))yield _(p.IntegerExclusiveMaximum,e,r,n);if(B(e.exclusiveMinimum)&&!(n>e.exclusiveMinimum))yield _(p.IntegerExclusiveMinimum,e,r,n);if(B(e.maximum)&&!(n<=e.maximum))yield _(p.IntegerMaximum,e,r,n);if(B(e.minimum)&&!(n>=e.minimum))yield _(p.IntegerMinimum,e,r,n);if(B(e.multipleOf)&&n%e.multipleOf!==0)yield _(p.IntegerMultipleOf,e,r,n)}function*mp(e,t,r,n){let o=!1;for(let i of e.allOf)for(let s of Pe(i,t,r,n))o=!0,yield s;if(o)return yield _(p.Intersect,e,r,n);if(e.unevaluatedProperties===!1){let i=new RegExp(rr(e));for(let s of Object.getOwnPropertyNames(n))if(!i.test(s))yield _(p.IntersectUnevaluatedProperties,e,`${r}/${s}`,n)}if(typeof e.unevaluatedProperties==="object"){let i=new RegExp(rr(e));for(let s of Object.getOwnPropertyNames(n))if(!i.test(s)){let a=Pe(e.unevaluatedProperties,t,`${r}/${s}`,n[s]).next();if(!a.done)yield a.value}}}function*pp(e,t,r,n){if(!ko(n))yield _(p.Iterator,e,r,n)}function*lp(e,t,r,n){if(n!==e.const)yield _(p.Literal,e,r,n)}function*yp(e,t,r,n){yield _(p.Never,e,r,n)}function*gp(e,t,r,n){if(Pe(e.not,t,r,n).next().done===!0)yield _(p.Not,e,r,n)}function*xp(e,t,r,n){if(!Pr(n))yield _(p.Null,e,r,n)}function*hp(e,t,r,n){if(!ne.IsNumberLike(n))return yield _(p.Number,e,r,n);if(B(e.exclusiveMaximum)&&!(n<e.exclusiveMaximum))yield _(p.NumberExclusiveMaximum,e,r,n);if(B(e.exclusiveMinimum)&&!(n>e.exclusiveMinimum))yield _(p.NumberExclusiveMinimum,e,r,n);if(B(e.maximum)&&!(n<=e.maximum))yield _(p.NumberMaximum,e,r,n);if(B(e.minimum)&&!(n>=e.minimum))yield _(p.NumberMinimum,e,r,n);if(B(e.multipleOf)&&n%e.multipleOf!==0)yield _(p.NumberMultipleOf,e,r,n)}function*Ip(e,t,r,n){if(!ne.IsObjectLike(n))return yield _(p.Object,e,r,n);if(B(e.minProperties)&&!(Object.getOwnPropertyNames(n).length>=e.minProperties))yield _(p.ObjectMinProperties,e,r,n);if(B(e.maxProperties)&&!(Object.getOwnPropertyNames(n).length<=e.maxProperties))yield _(p.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 _(p.ObjectRequiredProperty,e.properties[a],`${r}/${sr(a)}`,void 0)}if(e.additionalProperties===!1){for(let a of s)if(!i.includes(a))yield _(p.ObjectAdditionalProperties,e,`${r}/${sr(a)}`,n[a])}if(typeof e.additionalProperties==="object")for(let a of s){if(i.includes(a))continue;yield*Pe(e.additionalProperties,t,`${r}/${sr(a)}`,n[a])}for(let a of i){let c=e.properties[a];if(e.required&&e.required.includes(a)){if(yield*Pe(c,t,`${r}/${sr(a)}`,n[a]),nr(e)&&!(a in n))yield _(p.ObjectRequiredProperty,c,`${r}/${sr(a)}`,void 0)}else if(ne.IsExactOptionalProperty(n,a))yield*Pe(c,t,`${r}/${sr(a)}`,n[a])}}function*bp(e,t,r,n){if(!Co(n))yield _(p.Promise,e,r,n)}function*_p(e,t,r,n){if(!ne.IsRecordLike(n))return yield _(p.Object,e,r,n);if(B(e.minProperties)&&!(Object.getOwnPropertyNames(n).length>=e.minProperties))yield _(p.ObjectMinProperties,e,r,n);if(B(e.maxProperties)&&!(Object.getOwnPropertyNames(n).length<=e.maxProperties))yield _(p.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*Pe(i,t,`${r}/${sr(a)}`,c);if(typeof e.additionalProperties==="object"){for(let[a,c]of Object.entries(n))if(!s.test(a))yield*Pe(e.additionalProperties,t,`${r}/${sr(a)}`,c)}if(e.additionalProperties===!1)for(let[a,c]of Object.entries(n)){if(s.test(a))continue;return yield _(p.ObjectAdditionalProperties,e,`${r}/${sr(a)}`,c)}}function*Op(e,t,r,n){yield*Pe(Ce(e,t),t,r,n)}function*$p(e,t,r,n){if(!ke(n))return yield _(p.String,e,r,n);if(B(e.minLength)&&!(n.length>=e.minLength))yield _(p.StringMinLength,e,r,n);if(B(e.maxLength)&&!(n.length<=e.maxLength))yield _(p.StringMaxLength,e,r,n);if(!new RegExp(e.source,e.flags).test(n))return yield _(p.RegExp,e,r,n)}function*wp(e,t,r,n){if(!ke(n))return yield _(p.String,e,r,n);if(B(e.minLength)&&!(n.length>=e.minLength))yield _(p.StringMinLength,e,r,n);if(B(e.maxLength)&&!(n.length<=e.maxLength))yield _(p.StringMaxLength,e,r,n);if(ke(e.pattern)){if(!new RegExp(e.pattern).test(n))yield _(p.StringPattern,e,r,n)}if(ke(e.format)){if(!wi(e.format))yield _(p.StringFormatUnknown,e,r,n);else if(!Ri(e.format)(n))yield _(p.StringFormat,e,r,n)}}function*Rp(e,t,r,n){if(!Sr(n))yield _(p.Symbol,e,r,n)}function*Fp(e,t,r,n){if(!ke(n))return yield _(p.String,e,r,n);if(!new RegExp(e.pattern).test(n))yield _(p.StringPattern,e,r,n)}function*Ap(e,t,r,n){yield*Pe(Ce(e,t),t,r,n)}function*kp(e,t,r,n){if(!_e(n))return yield _(p.Tuple,e,r,n);if(e.items===void 0&&n.length!==0)return yield _(p.TupleLength,e,r,n);if(n.length!==e.maxItems)return yield _(p.TupleLength,e,r,n);if(!e.items)return;for(let o=0;o<e.items.length;o++)yield*Pe(e.items[o],t,`${r}/${o}`,n[o])}function*Cp(e,t,r,n){if(!ve(n))yield _(p.Undefined,e,r,n)}function*Tp(e,t,r,n){if(Vr(e,t,n))return;let o=e.anyOf.map((i)=>new Vi(Pe(i,t,r,n)));yield _(p.Union,e,r,n,o)}function*Pp(e,t,r,n){if(!sn(n))return yield _(p.Uint8Array,e,r,n);if(B(e.maxByteLength)&&!(n.length<=e.maxByteLength))yield _(p.Uint8ArrayMaxByteLength,e,r,n);if(B(e.minByteLength)&&!(n.length>=e.minByteLength))yield _(p.Uint8ArrayMinByteLength,e,r,n)}function*Np(e,t,r,n){}function*Sp(e,t,r,n){if(!ne.IsVoidLike(n))yield _(p.Void,e,r,n)}function*jp(e,t,r,n){if(!Fi(e[x])(e,n))yield _(p.Kind,e,r,n)}function*Pe(e,t,r,n){let o=B(e.$id)?[...t,e]:t,i=e;switch(i[x]){case"Any":return yield*tp(i,o,r,n);case"Argument":return yield*rp(i,o,r,n);case"Array":return yield*np(i,o,r,n);case"AsyncIterator":return yield*op(i,o,r,n);case"BigInt":return yield*ip(i,o,r,n);case"Boolean":return yield*sp(i,o,r,n);case"Constructor":return yield*ap(i,o,r,n);case"Date":return yield*cp(i,o,r,n);case"Function":return yield*up(i,o,r,n);case"Import":return yield*fp(i,o,r,n);case"Integer":return yield*dp(i,o,r,n);case"Intersect":return yield*mp(i,o,r,n);case"Iterator":return yield*pp(i,o,r,n);case"Literal":return yield*lp(i,o,r,n);case"Never":return yield*yp(i,o,r,n);case"Not":return yield*gp(i,o,r,n);case"Null":return yield*xp(i,o,r,n);case"Number":return yield*hp(i,o,r,n);case"Object":return yield*Ip(i,o,r,n);case"Promise":return yield*bp(i,o,r,n);case"Record":return yield*_p(i,o,r,n);case"Ref":return yield*Op(i,o,r,n);case"RegExp":return yield*$p(i,o,r,n);case"String":return yield*wp(i,o,r,n);case"Symbol":return yield*Rp(i,o,r,n);case"TemplateLiteral":return yield*Fp(i,o,r,n);case"This":return yield*Ap(i,o,r,n);case"Tuple":return yield*kp(i,o,r,n);case"Undefined":return yield*Cp(i,o,r,n);case"Union":return yield*Tp(i,o,r,n);case"Uint8Array":return yield*Pp(i,o,r,n);case"Unknown":return yield*Np(i,o,r,n);case"Void":return yield*Sp(i,o,r,n);default:if(!Wn(i[x]))throw new Pa(e);return yield*jp(i,o,r,n)}}function Na(...e){let t=e.length===3?Pe(e[0],e[1],"",e[2]):Pe(e[0],[],"",e[1]);return new Vi(t)}class zi extends z{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 Sa extends z{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 le(e,t,r){try{return V(e)?e[de].Decode(r):r}catch(n){throw new Sa(e,t,r,n)}}function Mp(e,t,r,n){return _e(n)?le(e,r,n.map((o,i)=>Nt(e.items,t,`${r}/${i}`,o))):le(e,r,n)}function Up(e,t,r,n){if(!ze(n)||So(n))return le(e,r,n);let o=Vo(e),i=o.map((m)=>m[0]),s={...n};for(let[m,g]of o)if(m in s)s[m]=Nt(g,t,`${r}/${m}`,s[m]);if(!V(e.unevaluatedProperties))return le(e,r,s);let a=Object.getOwnPropertyNames(s),c=e.unevaluatedProperties,u={...s};for(let m of a)if(!i.includes(m))u[m]=le(c,`${r}/${m}`,u[m]);return le(e,r,u)}function Ep(e,t,r,n){let o=globalThis.Object.values(e.$defs),i=e.$defs[e.$ref],s=Nt(i,[...t,...o],r,n);return le(e,r,s)}function Lp(e,t,r,n){return le(e,r,Nt(e.not,t,r,n))}function Kp(e,t,r,n){if(!ze(n))return le(e,r,n);let o=yt(e),i={...n};for(let u of o){if(!To(i,u))continue;if(ve(i[u])&&(!Zt(e.properties[u])||ne.IsExactOptionalProperty(i,u)))continue;i[u]=Nt(e.properties[u],t,`${r}/${u}`,i[u])}if(!me(e.additionalProperties))return le(e,r,i);let s=Object.getOwnPropertyNames(i),a=e.additionalProperties,c={...i};for(let u of s)if(!o.includes(u))c[u]=le(a,`${r}/${u}`,c[u]);return le(e,r,c)}function Bp(e,t,r,n){if(!ze(n))return le(e,r,n);let o=Object.getOwnPropertyNames(e.patternProperties)[0],i=new RegExp(o),s={...n};for(let m of Object.getOwnPropertyNames(n))if(i.test(m))s[m]=Nt(e.patternProperties[o],t,`${r}/${m}`,s[m]);if(!me(e.additionalProperties))return le(e,r,s);let a=Object.getOwnPropertyNames(s),c=e.additionalProperties,u={...s};for(let m of a)if(!i.test(m))u[m]=le(c,`${r}/${m}`,u[m]);return le(e,r,u)}function Dp(e,t,r,n){let o=Ce(e,t);return le(e,r,Nt(o,t,r,n))}function Gp(e,t,r,n){let o=Ce(e,t);return le(e,r,Nt(o,t,r,n))}function qp(e,t,r,n){return _e(n)&&_e(e.items)?le(e,r,e.items.map((o,i)=>Nt(o,t,`${r}/${i}`,n[i]))):le(e,r,n)}function vp(e,t,r,n){for(let o of e.anyOf){if(!Vr(o,t,n))continue;let i=Nt(o,t,r,n);return le(e,r,i)}return le(e,r,n)}function Nt(e,t,r,n){let o=hr(e,t),i=e;switch(e[x]){case"Array":return Mp(i,o,r,n);case"Import":return Ep(i,o,r,n);case"Intersect":return Up(i,o,r,n);case"Not":return Lp(i,o,r,n);case"Object":return Kp(i,o,r,n);case"Record":return Bp(i,o,r,n);case"Ref":return Dp(i,o,r,n);case"Symbol":return le(i,r,n);case"This":return Gp(i,o,r,n);case"Tuple":return qp(i,o,r,n);case"Union":return vp(i,o,r,n);default:return le(i,r,n)}}function ja(e,t,r){return Nt(e,t,"",r)}class Wi extends z{constructor(e,t,r){super("The encoded value does not match the expected schema");this.schema=e,this.value=t,this.error=r}}class Ma extends z{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 Me(e,t,r){try{return V(e)?e[de].Encode(r):r}catch(n){throw new Ma(e,t,r,n)}}function Hp(e,t,r,n){let o=Me(e,r,n);return _e(o)?o.map((i,s)=>St(e.items,t,`${r}/${s}`,i)):o}function Vp(e,t,r,n){let o=globalThis.Object.values(e.$defs),i=e.$defs[e.$ref],s=Me(e,r,n);return St(i,[...t,...o],r,s)}function zp(e,t,r,n){let o=Me(e,r,n);if(!ze(n)||So(n))return o;let i=Vo(e),s=i.map((g)=>g[0]),a={...o};for(let[g,I]of i)if(g in a)a[g]=St(I,t,`${r}/${g}`,a[g]);if(!V(e.unevaluatedProperties))return a;let c=Object.getOwnPropertyNames(a),u=e.unevaluatedProperties,m={...a};for(let g of c)if(!s.includes(g))m[g]=Me(u,`${r}/${g}`,m[g]);return m}function Wp(e,t,r,n){return Me(e.not,r,Me(e,r,n))}function Jp(e,t,r,n){let o=Me(e,r,n);if(!ze(o))return o;let i=yt(e),s={...o};for(let m of i){if(!To(s,m))continue;if(ve(s[m])&&(!Zt(e.properties[m])||ne.IsExactOptionalProperty(s,m)))continue;s[m]=St(e.properties[m],t,`${r}/${m}`,s[m])}if(!me(e.additionalProperties))return s;let a=Object.getOwnPropertyNames(s),c=e.additionalProperties,u={...s};for(let m of a)if(!i.includes(m))u[m]=Me(c,`${r}/${m}`,u[m]);return u}function Yp(e,t,r,n){let o=Me(e,r,n);if(!ze(n))return o;let i=Object.getOwnPropertyNames(e.patternProperties)[0],s=new RegExp(i),a={...o};for(let g of Object.getOwnPropertyNames(n))if(s.test(g))a[g]=St(e.patternProperties[i],t,`${r}/${g}`,a[g]);if(!me(e.additionalProperties))return a;let c=Object.getOwnPropertyNames(a),u=e.additionalProperties,m={...a};for(let g of c)if(!s.test(g))m[g]=Me(u,`${r}/${g}`,m[g]);return m}function Xp(e,t,r,n){let o=Ce(e,t),i=St(o,t,r,n);return Me(e,r,i)}function Qp(e,t,r,n){let o=Ce(e,t),i=St(o,t,r,n);return Me(e,r,i)}function Zp(e,t,r,n){let o=Me(e,r,n);return _e(e.items)?e.items.map((i,s)=>St(i,t,`${r}/${s}`,o[s])):[]}function el(e,t,r,n){for(let o of e.anyOf){if(!Vr(o,t,n))continue;let i=St(o,t,r,n);return Me(e,r,i)}for(let o of e.anyOf){let i=St(o,t,r,n);if(!Vr(e,t,i))continue;return Me(e,r,i)}return Me(e,r,n)}function St(e,t,r,n){let o=hr(e,t),i=e;switch(e[x]){case"Array":return Hp(i,o,r,n);case"Import":return Vp(i,o,r,n);case"Intersect":return zp(i,o,r,n);case"Not":return Wp(i,o,r,n);case"Object":return Jp(i,o,r,n);case"Record":return Yp(i,o,r,n);case"Ref":return Xp(i,o,r,n);case"This":return Qp(i,o,r,n);case"Tuple":return Zp(i,o,r,n);case"Union":return el(i,o,r,n);default:return Me(i,r,n)}}function Ua(e,t,r){return St(e,t,"",r)}function tl(e,t){return V(e)||Fe(e.items,t)}function rl(e,t){return V(e)||Fe(e.items,t)}function nl(e,t){return V(e)||Fe(e.returns,t)||e.parameters.some((r)=>Fe(r,t))}function ol(e,t){return V(e)||Fe(e.returns,t)||e.parameters.some((r)=>Fe(r,t))}function il(e,t){return V(e)||V(e.unevaluatedProperties)||e.allOf.some((r)=>Fe(r,t))}function sl(e,t){let r=globalThis.Object.getOwnPropertyNames(e.$defs).reduce((o,i)=>[...o,e.$defs[i]],[]),n=e.$defs[e.$ref];return V(e)||Fe(n,[...r,...t])}function al(e,t){return V(e)||Fe(e.items,t)}function cl(e,t){return V(e)||Fe(e.not,t)}function ul(e,t){return V(e)||Object.values(e.properties).some((r)=>Fe(r,t))||me(e.additionalProperties)&&Fe(e.additionalProperties,t)}function fl(e,t){return V(e)||Fe(e.item,t)}function dl(e,t){let r=Object.getOwnPropertyNames(e.patternProperties)[0],n=e.patternProperties[r];return V(e)||Fe(n,t)||me(e.additionalProperties)&&V(e.additionalProperties)}function ml(e,t){if(V(e))return!0;return Fe(Ce(e,t),t)}function pl(e,t){if(V(e))return!0;return Fe(Ce(e,t),t)}function ll(e,t){return V(e)||!ve(e.items)&&e.items.some((r)=>Fe(r,t))}function yl(e,t){return V(e)||e.anyOf.some((r)=>Fe(r,t))}function Fe(e,t){let r=hr(e,t),n=e;if(e.$id&&Ji.has(e.$id))return!1;if(e.$id)Ji.add(e.$id);switch(e[x]){case"Array":return tl(n,r);case"AsyncIterator":return rl(n,r);case"Constructor":return nl(n,r);case"Function":return ol(n,r);case"Import":return sl(n,r);case"Intersect":return il(n,r);case"Iterator":return al(n,r);case"Not":return cl(n,r);case"Object":return ul(n,r);case"Promise":return fl(n,r);case"Record":return dl(n,r);case"Ref":return ml(n,r);case"This":return pl(n,r);case"Tuple":return ll(n,r);case"Union":return yl(n,r);default:return V(e)}}var Ji=new Set;function Ea(e,t){return Ji.clear(),Fe(e,t)}class La{constructor(e,t,r,n){this.schema=e,this.references=t,this.checkFunc=r,this.code=n,this.hasTransform=Ea(e,t)}Code(){return this.code}Schema(){return this.schema}References(){return this.references}Errors(e){return Na(this.schema,this.references,e)}Check(e){return this.checkFunc(e)}Decode(e){if(!this.checkFunc(e))throw new zi(this.schema,e,this.Errors(e).First());return this.hasTransform?ja(this.schema,this.references,e):e}Encode(e){let t=this.hasTransform?Ua(this.schema,this.references,e):e;if(!this.checkFunc(t))throw new Wi(this.schema,e,this.Errors(e).First());return t}}var ar;(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})(ar||(ar={}));var ri;(function(e){function t(i){if(i.length===0)return!1;return ar.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(!(ar.IsAlpha(a)||ar.IsNumeric(a)||ar.DollarSign(a)||ar.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})(ri||(ri={}));var Yi;(function(e){function t(r){let n=[];for(let o=0;o<r.length;o++){let i=r.charCodeAt(o);if(ar.IsNumeric(i)||ar.IsAlpha(i))n.push(r.charAt(o));else n.push(`_${i}_`)}return n.join("").replace(/__/g,"_")}e.Encode=t})(Yi||(Yi={}));var Xi;(function(e){function t(r){return r.replace(/'/g,"\\'")}e.Escape=t})(Xi||(Xi={}));class Ka extends z{constructor(e){super("Unknown type");this.schema=e}}class Qi extends z{constructor(e){super("Preflight validation check failed to guard for the given schema");this.schema=e}}var zr;(function(e){function t(s,a,c){return ne.ExactOptionalPropertyTypes?`('${a}' in ${s} ? ${c} : true)`:`(${ri.Encode(s,a)} !== undefined ? ${c} : true)`}e.IsExactOptionalProperty=t;function r(s){return!ne.AllowArrayObject?`(typeof ${s} === 'object' && ${s} !== null && !Array.isArray(${s}))`:`(typeof ${s} === 'object' && ${s} !== null)`}e.IsObjectLike=r;function n(s){return!ne.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 ne.AllowNaN?`typeof ${s} === 'number'`:`Number.isFinite(${s})`}e.IsNumberLike=o;function i(s){return ne.AllowNullVoid?`(${s} === undefined || ${s} === null)`:`${s} === undefined`}e.IsVoidLike=i})(zr||(zr={}));var uo;(function(e){function t(f){return f[x]==="Any"||f[x]==="Unknown"}function*r(f,w,d){yield"true"}function*n(f,w,d){yield"true"}function*o(f,w,d){yield`Array.isArray(${d})`;let[S,F]=[Ro("value","any"),Ro("acc","number")];if(M(f.maxItems))yield`${d}.length <= ${f.maxItems}`;if(M(f.minItems))yield`${d}.length >= ${f.minItems}`;let A=bt(f.items,w,"value");if(yield`${d}.every((${S}) => ${A})`,pe(f.contains)||M(f.minContains)||M(f.maxContains)){let re=pe(f.contains)?f.contains:E(),Ve=bt(re,w,"value"),Yt=M(f.minContains)?[`(count >= ${f.minContains})`]:[],_t=M(f.maxContains)?[`(count <= ${f.maxContains})`]:[],Dt=`const count = value.reduce((${F}, ${S}) => ${Ve} ? acc + 1 : acc, 0)`,Fo=["(count > 0)",...Yt,..._t].join(" && ");yield`((${S}) => { ${Dt}; return ${Fo}})(${d})`}if(f.uniqueItems===!0)yield`((${S}) => { 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 } )(${d})`}function*i(f,w,d){yield`(typeof value === 'object' && Symbol.asyncIterator in ${d})`}function*s(f,w,d){if(yield`(typeof ${d} === 'bigint')`,nt(f.exclusiveMaximum))yield`${d} < BigInt(${f.exclusiveMaximum})`;if(nt(f.exclusiveMinimum))yield`${d} > BigInt(${f.exclusiveMinimum})`;if(nt(f.maximum))yield`${d} <= BigInt(${f.maximum})`;if(nt(f.minimum))yield`${d} >= BigInt(${f.minimum})`;if(nt(f.multipleOf))yield`(${d} % BigInt(${f.multipleOf})) === 0`}function*a(f,w,d){yield`(typeof ${d} === 'boolean')`}function*c(f,w,d){yield*rn(f.returns,w,`${d}.prototype`)}function*u(f,w,d){if(yield`(${d} instanceof Date) && Number.isFinite(${d}.getTime())`,M(f.exclusiveMaximumTimestamp))yield`${d}.getTime() < ${f.exclusiveMaximumTimestamp}`;if(M(f.exclusiveMinimumTimestamp))yield`${d}.getTime() > ${f.exclusiveMinimumTimestamp}`;if(M(f.maximumTimestamp))yield`${d}.getTime() <= ${f.maximumTimestamp}`;if(M(f.minimumTimestamp))yield`${d}.getTime() >= ${f.minimumTimestamp}`;if(M(f.multipleOfTimestamp))yield`(${d}.getTime() % ${f.multipleOfTimestamp}) === 0`}function*m(f,w,d){yield`(typeof ${d} === 'function')`}function*g(f,w,d){let S=globalThis.Object.getOwnPropertyNames(f.$defs).reduce((F,A)=>[...F,f.$defs[A]],[]);yield*rn(lt(f.$ref),[...w,...S],d)}function*I(f,w,d){if(yield`Number.isInteger(${d})`,M(f.exclusiveMaximum))yield`${d} < ${f.exclusiveMaximum}`;if(M(f.exclusiveMinimum))yield`${d} > ${f.exclusiveMinimum}`;if(M(f.maximum))yield`${d} <= ${f.maximum}`;if(M(f.minimum))yield`${d} >= ${f.minimum}`;if(M(f.multipleOf))yield`(${d} % ${f.multipleOf}) === 0`}function*O(f,w,d){let S=f.allOf.map((F)=>bt(F,w,d)).join(" && ");if(f.unevaluatedProperties===!1){let F=nn(`${new RegExp(rr(f))};`),A=`Object.getOwnPropertyNames(${d}).every(key => ${F}.test(key))`;yield`(${S} && ${A})`}else if(pe(f.unevaluatedProperties)){let F=nn(`${new RegExp(rr(f))};`),A=`Object.getOwnPropertyNames(${d}).every(key => ${F}.test(key) || ${bt(f.unevaluatedProperties,w,`${d}[key]`)})`;yield`(${S} && ${A})`}else yield`(${S})`}function*T(f,w,d){yield`(typeof value === 'object' && Symbol.iterator in ${d})`}function*C(f,w,d){if(typeof f.const==="number"||typeof f.const==="boolean")yield`(${d} === ${f.const})`;else yield`(${d} === '${Xi.Escape(f.const)}')`}function*Y(f,w,d){yield"false"}function*fe(f,w,d){yield`(!${bt(f.not,w,d)})`}function*Ee(f,w,d){yield`(${d} === null)`}function*j(f,w,d){if(yield zr.IsNumberLike(d),M(f.exclusiveMaximum))yield`${d} < ${f.exclusiveMaximum}`;if(M(f.exclusiveMinimum))yield`${d} > ${f.exclusiveMinimum}`;if(M(f.maximum))yield`${d} <= ${f.maximum}`;if(M(f.minimum))yield`${d} >= ${f.minimum}`;if(M(f.multipleOf))yield`(${d} % ${f.multipleOf}) === 0`}function*Ae(f,w,d){if(yield zr.IsObjectLike(d),M(f.minProperties))yield`Object.getOwnPropertyNames(${d}).length >= ${f.minProperties}`;if(M(f.maxProperties))yield`Object.getOwnPropertyNames(${d}).length <= ${f.maxProperties}`;let S=Object.getOwnPropertyNames(f.properties);for(let F of S){let A=ri.Encode(d,F),re=f.properties[F];if(f.required&&f.required.includes(F)){if(yield*rn(re,w,A),nr(re)||t(re))yield`('${F}' in ${d})`}else{let Ve=bt(re,w,A);yield zr.IsExactOptionalProperty(d,F,Ve)}}if(f.additionalProperties===!1)if(f.required&&f.required.length===S.length)yield`Object.getOwnPropertyNames(${d}).length === ${S.length}`;else{let F=`[${S.map((A)=>`'${A}'`).join(", ")}]`;yield`Object.getOwnPropertyNames(${d}).every(key => ${F}.includes(key))`}if(typeof f.additionalProperties==="object"){let F=bt(f.additionalProperties,w,`${d}[key]`),A=`[${S.map((re)=>`'${re}'`).join(", ")}]`;yield`(Object.getOwnPropertyNames(${d}).every(key => ${A}.includes(key) || ${F}))`}}function*ht(f,w,d){yield`${d} instanceof Promise`}function*Re(f,w,d){if(yield zr.IsRecordLike(d),M(f.minProperties))yield`Object.getOwnPropertyNames(${d}).length >= ${f.minProperties}`;if(M(f.maxProperties))yield`Object.getOwnPropertyNames(${d}).length <= ${f.maxProperties}`;let[S,F]=Object.entries(f.patternProperties)[0],A=nn(`${new RegExp(S)}`),re=bt(F,w,"value"),Ve=pe(f.additionalProperties)?bt(f.additionalProperties,w,d):f.additionalProperties===!1?"false":"true",Yt=`(${A}.test(key) ? ${re} : ${Ve})`;yield`(Object.entries(${d}).every(([key, value]) => ${Yt}))`}function*et(f,w,d){let S=Ce(f,w);if(Ne.functions.has(f.$ref))return yield`${wo(f.$ref)}(${d})`;yield*rn(S,w,d)}function*qe(f,w,d){let S=nn(`${new RegExp(f.source,f.flags)};`);if(yield`(typeof ${d} === 'string')`,M(f.maxLength))yield`${d}.length <= ${f.maxLength}`;if(M(f.minLength))yield`${d}.length >= ${f.minLength}`;yield`${S}.test(${d})`}function*tt(f,w,d){if(yield`(typeof ${d} === 'string')`,M(f.maxLength))yield`${d}.length <= ${f.maxLength}`;if(M(f.minLength))yield`${d}.length >= ${f.minLength}`;if(f.pattern!==void 0)yield`${nn(`${new RegExp(f.pattern)};`)}.test(${d})`;if(f.format!==void 0)yield`format('${f.format}', ${d})`}function*dr(f,w,d){yield`(typeof ${d} === 'symbol')`}function*tn(f,w,d){yield`(typeof ${d} === 'string')`,yield`${nn(`${new RegExp(f.pattern)};`)}.test(${d})`}function*Vn(f,w,d){yield`${wo(f.$ref)}(${d})`}function*ee(f,w,d){if(yield`Array.isArray(${d})`,f.items===void 0)return yield`${d}.length === 0`;yield`(${d}.length === ${f.maxItems})`;for(let S=0;S<f.items.length;S++)yield`${bt(f.items[S],w,`${d}[${S}]`)}`}function*rt(f,w,d){yield`${d} === undefined`}function*It(f,w,d){yield`(${f.anyOf.map((F)=>bt(F,w,d)).join(" || ")})`}function*Jt(f,w,d){if(yield`${d} instanceof Uint8Array`,M(f.maxByteLength))yield`(${d}.length <= ${f.maxByteLength})`;if(M(f.minByteLength))yield`(${d}.length >= ${f.minByteLength})`}function*zn(f,w,d){yield"true"}function*$o(f,w,d){yield zr.IsVoidLike(d)}function*tu(f,w,d){let S=Ne.instances.size;Ne.instances.set(S,f),yield`kind('${f[x]}', ${S}, ${d})`}function*rn(f,w,d,S=!0){let F=ke(f.$id)?[...w,f]:w,A=f;if(S&&ke(f.$id)){let re=wo(f.$id);if(Ne.functions.has(re))return yield`${re}(${d})`;else{Ne.functions.set(re,"<deferred>");let Ve=gs(re,f,w,"value",!1);return Ne.functions.set(re,Ve),yield`${re}(${d})`}}switch(A[x]){case"Any":return yield*r(A,F,d);case"Argument":return yield*n(A,F,d);case"Array":return yield*o(A,F,d);case"AsyncIterator":return yield*i(A,F,d);case"BigInt":return yield*s(A,F,d);case"Boolean":return yield*a(A,F,d);case"Constructor":return yield*c(A,F,d);case"Date":return yield*u(A,F,d);case"Function":return yield*m(A,F,d);case"Import":return yield*g(A,F,d);case"Integer":return yield*I(A,F,d);case"Intersect":return yield*O(A,F,d);case"Iterator":return yield*T(A,F,d);case"Literal":return yield*C(A,F,d);case"Never":return yield*Y(A,F,d);case"Not":return yield*fe(A,F,d);case"Null":return yield*Ee(A,F,d);case"Number":return yield*j(A,F,d);case"Object":return yield*Ae(A,F,d);case"Promise":return yield*ht(A,F,d);case"Record":return yield*Re(A,F,d);case"Ref":return yield*et(A,F,d);case"RegExp":return yield*qe(A,F,d);case"String":return yield*tt(A,F,d);case"Symbol":return yield*dr(A,F,d);case"TemplateLiteral":return yield*tn(A,F,d);case"This":return yield*Vn(A,F,d);case"Tuple":return yield*ee(A,F,d);case"Undefined":return yield*rt(A,F,d);case"Union":return yield*It(A,F,d);case"Uint8Array":return yield*Jt(A,F,d);case"Unknown":return yield*zn(A,F,d);case"Void":return yield*$o(A,F,d);default:if(!Wn(A[x]))throw new Ka(f);return yield*tu(A,F,d)}}let Ne={language:"javascript",functions:new Map,variables:new Map,instances:new Map};function bt(f,w,d,S=!0){return`(${[...rn(f,w,d,S)].join(" && ")})`}function wo(f){return`check_${Yi.Encode(f)}`}function nn(f){let w=`local_${Ne.variables.size}`;return Ne.variables.set(w,`const ${w} = ${f}`),w}function gs(f,w,d,S,F=!0){let[A,re]=[`
3
+ `,(Dt)=>"".padStart(Dt," ")],Ve=Ro("value","any"),Yt=xs("boolean"),_t=[...rn(w,d,S,F)].map((Dt)=>`${re(4)}${Dt}`).join(` &&${A}`);return`function ${f}(${Ve})${Yt} {${A}${re(2)}return (${A}${_t}${A}${re(2)})
4
+ }`}function Ro(f,w){let d=Ne.language==="typescript"?`: ${w}`:"";return`${f}${d}`}function xs(f){return Ne.language==="typescript"?`: ${f}`:""}function ru(f,w,d){let S=gs("check",f,w,"value"),F=Ro("value","any"),A=xs("boolean"),re=[...Ne.functions.values()],Ve=[...Ne.variables.values()],Yt=ke(f.$id)?`return function check(${F})${A} {
5
+ return ${wo(f.$id)}(value)
6
+ }`:`return ${S}`;return[...Ve,...re,Yt].join(`
7
+ `)}function hs(...f){let w={language:"javascript"},[d,S,F]=f.length===2&&_e(f[1])?[f[0],f[1],w]:f.length===2&&!_e(f[1])?[f[0],[],f[1]]:f.length===3?[f[0],f[1],f[2]]:f.length===1?[f[0],[],w]:[null,[],w];if(Ne.language=F.language,Ne.variables.clear(),Ne.functions.clear(),Ne.instances.clear(),!pe(d))throw new Qi(d);for(let A of S)if(!pe(A))throw new Qi(A);return ru(d,S,F)}e.Code=hs;function nu(f,w=[]){let d=hs(f,w,{language:"javascript"}),S=globalThis.Function("kind","format","hash",d),F=new Map(Ne.instances);function A(_t,Dt,Fo){if(!Wn(_t)||!F.has(Dt))return!1;let ou=Fi(_t),iu=F.get(Dt);return ou(iu,Fo)}function re(_t,Dt){if(!wi(_t))return!1;return Ri(_t)(Dt)}function Ve(_t){return In(_t)}let Yt=S(A,re,Ve);return new La(f,w,Yt,d)}e.Compile=nu})(uo||(uo={}));var D;(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}})(D||(D={}));var Zi;(function(e){e.mergeShapes=(t,r)=>({...t,...r})})(Zi||(Zi={}));var R=D.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),Vt=(e)=>{switch(typeof e){case"undefined":return R.undefined;case"string":return R.string;case"number":return Number.isNaN(e)?R.nan:R.number;case"boolean":return R.boolean;case"function":return R.function;case"bigint":return R.bigint;case"symbol":return R.symbol;case"object":if(Array.isArray(e))return R.array;if(e===null)return R.null;if(e.then&&typeof e.then==="function"&&e.catch&&typeof e.catch==="function")return R.promise;if(typeof Map<"u"&&e instanceof Map)return R.map;if(typeof Set<"u"&&e instanceof Set)return R.set;if(typeof Date<"u"&&e instanceof Date)return R.date;return R.object;default:return R.unknown}};var h=D.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"]),gl=(e)=>JSON.stringify(e,null,2).replace(/"([^"]+)":/g,"$1:");class Ze 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 Ze))throw Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,D.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()}}Ze.create=(e)=>new Ze(e);var xl=(e,t)=>{let r;switch(e.code){case h.invalid_type:if(e.received===R.undefined)r="Required";else r=`Expected ${e.expected}, received ${e.received}`;break;case h.invalid_literal:r=`Invalid literal value, expected ${JSON.stringify(e.expected,D.jsonStringifyReplacer)}`;break;case h.unrecognized_keys:r=`Unrecognized key(s) in object: ${D.joinValues(e.keys,", ")}`;break;case h.invalid_union:r="Invalid input";break;case h.invalid_union_discriminator:r=`Invalid discriminator value. Expected ${D.joinValues(e.options)}`;break;case h.invalid_enum_value:r=`Invalid enum value. Expected ${D.joinValues(e.options)}, received '${e.received}'`;break;case h.invalid_arguments:r="Invalid function arguments";break;case h.invalid_return_type:r="Invalid function return type";break;case h.invalid_date:r="Invalid date";break;case h.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 D.assertNever(e.validation);else if(e.validation!=="regex")r=`Invalid ${e.validation}`;else r="Invalid";break;case h.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 h.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 h.custom:r="Invalid input";break;case h.invalid_intersection_types:r="Intersection results could not be merged";break;case h.not_multiple_of:r=`Number must be a multiple of ${e.multipleOf}`;break;case h.not_finite:r="Number must be finite";break;default:r=t.defaultError,D.assertNever(e)}return{message:r}},cr=xl;var Ba=cr;function hl(e){Ba=e}function $n(){return Ba}var fo=(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((u)=>!!u).slice().reverse();for(let u of c)a=u(s,{data:t,defaultError:a}).message;return{...o,path:i,message:a}},Il=[];function b(e,t){let r=$n(),n=fo({issueData:t,data:e.data,path:e.path,errorMaps:[e.common.contextualErrorMap,e.schemaErrorMap,r,r===cr?void 0:cr].filter((o)=>!!o)});e.common.issues.push(n)}class Ue{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 P;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 Ue.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 P;if(i.status==="aborted")return P;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 P=Object.freeze({status:"aborted"}),Wr=(e)=>({status:"dirty",value:e}),Ge=(e)=>({status:"valid",value:e}),ni=(e)=>e.status==="aborted",oi=(e)=>e.status==="dirty",wr=(e)=>e.status==="valid",wn=(e)=>typeof Promise<"u"&&e instanceof Promise;var k;(function(e){e.errToObj=(t)=>typeof t==="string"?{message:t}:t||{},e.toString=(t)=>typeof t==="string"?t:t?.message})(k||(k={}));class Et{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 Da=(e,t)=>{if(wr(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 Ze(e.common.issues);return this._error=r,this._error}}}};function U(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 L{get description(){return this._def.description}_getType(e){return Vt(e.data)}_getOrReturnCtx(e,t){return t||{common:e.parent.common,data:e.data,parsedType:Vt(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new Ue,ctx:{common:e.parent.common,data:e.data,parsedType:Vt(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){let t=this._parse(e);if(wn(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:Vt(e)},n=this._parseSync({data:e,path:r.path,parent:r});return Da(r,n)}"~validate"(e){let t={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:Vt(e)};if(!this["~standard"].async)try{let r=this._parseSync({data:e,path:[],parent:t});return wr(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)=>wr(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:Vt(e)},n=this._parse({data:e,path:r.path,parent:r}),o=await(wn(n)?n:Promise.resolve(n));return Da(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:h.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 Lt({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 Ut.create(this,this._def)}nullable(){return fr.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return Mt.create(this)}promise(){return Qr.create(this,this._def)}or(e){return Tn.create([this,e],this._def)}and(e){return Pn.create(this,e,this._def)}transform(e){return new Lt({...U(this._def),schema:this,typeName:N.ZodEffects,effect:{type:"transform",transform:e}})}default(e){let t=typeof e==="function"?e:()=>e;return new Mn({...U(this._def),innerType:this,defaultValue:t,typeName:N.ZodDefault})}brand(){return new si({typeName:N.ZodBranded,type:this,...U(this._def)})}catch(e){let t=typeof e==="function"?e:()=>e;return new Un({...U(this._def),innerType:this,catchValue:t,typeName:N.ZodCatch})}describe(e){return new this.constructor({...this._def,description:e})}pipe(e){return xo.create(this,e)}readonly(){return En.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}var bl=/^c[^\s-]{8,}$/i,_l=/^[0-9a-z]+$/,Ol=/^[0-9A-HJKMNP-TV-Z]{26}$/i,$l=/^[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,wl=/^[a-z0-9_-]{21}$/i,Rl=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,Fl=/^[-+]?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)?)??$/,Al=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,kl="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$",es,Cl=/^(?:(?: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])$/,Tl=/^(?:(?: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])$/,Pl=/^(([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]))$/,Nl=/^(([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])$/,Sl=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,jl=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,qa="((\\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])))",Ml=new RegExp(`^${qa}$`);function va(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 Ul(e){return new RegExp(`^${va(e)}$`)}function Ha(e){let t=`${qa}T${va(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 El(e,t){if((t==="v4"||!t)&&Cl.test(e))return!0;if((t==="v6"||!t)&&Pl.test(e))return!0;return!1}function Ll(e,t){if(!Rl.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 Kl(e,t){if((t==="v4"||!t)&&Tl.test(e))return!0;if((t==="v6"||!t)&&Nl.test(e))return!0;return!1}class jt extends L{_parse(e){if(this._def.coerce)e.data=String(e.data);if(this._getType(e)!==R.string){let o=this._getOrReturnCtx(e);return b(o,{code:h.invalid_type,expected:R.string,received:o.parsedType}),P}let r=new Ue,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),b(n,{code:h.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),b(n,{code:h.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)b(n,{code:h.too_big,maximum:o.value,type:"string",inclusive:!0,exact:!0,message:o.message});else if(s)b(n,{code:h.too_small,minimum:o.value,type:"string",inclusive:!0,exact:!0,message:o.message});r.dirty()}}else if(o.kind==="email"){if(!Al.test(e.data))n=this._getOrReturnCtx(e,n),b(n,{validation:"email",code:h.invalid_string,message:o.message}),r.dirty()}else if(o.kind==="emoji"){if(!es)es=new RegExp(kl,"u");if(!es.test(e.data))n=this._getOrReturnCtx(e,n),b(n,{validation:"emoji",code:h.invalid_string,message:o.message}),r.dirty()}else if(o.kind==="uuid"){if(!$l.test(e.data))n=this._getOrReturnCtx(e,n),b(n,{validation:"uuid",code:h.invalid_string,message:o.message}),r.dirty()}else if(o.kind==="nanoid"){if(!wl.test(e.data))n=this._getOrReturnCtx(e,n),b(n,{validation:"nanoid",code:h.invalid_string,message:o.message}),r.dirty()}else if(o.kind==="cuid"){if(!bl.test(e.data))n=this._getOrReturnCtx(e,n),b(n,{validation:"cuid",code:h.invalid_string,message:o.message}),r.dirty()}else if(o.kind==="cuid2"){if(!_l.test(e.data))n=this._getOrReturnCtx(e,n),b(n,{validation:"cuid2",code:h.invalid_string,message:o.message}),r.dirty()}else if(o.kind==="ulid"){if(!Ol.test(e.data))n=this._getOrReturnCtx(e,n),b(n,{validation:"ulid",code:h.invalid_string,message:o.message}),r.dirty()}else if(o.kind==="url")try{new URL(e.data)}catch{n=this._getOrReturnCtx(e,n),b(n,{validation:"url",code:h.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),b(n,{validation:"regex",code:h.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),b(n,{code:h.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),b(n,{code:h.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),b(n,{code:h.invalid_string,validation:{endsWith:o.value},message:o.message}),r.dirty()}else if(o.kind==="datetime"){if(!Ha(o).test(e.data))n=this._getOrReturnCtx(e,n),b(n,{code:h.invalid_string,validation:"datetime",message:o.message}),r.dirty()}else if(o.kind==="date"){if(!Ml.test(e.data))n=this._getOrReturnCtx(e,n),b(n,{code:h.invalid_string,validation:"date",message:o.message}),r.dirty()}else if(o.kind==="time"){if(!Ul(o).test(e.data))n=this._getOrReturnCtx(e,n),b(n,{code:h.invalid_string,validation:"time",message:o.message}),r.dirty()}else if(o.kind==="duration"){if(!Fl.test(e.data))n=this._getOrReturnCtx(e,n),b(n,{validation:"duration",code:h.invalid_string,message:o.message}),r.dirty()}else if(o.kind==="ip"){if(!El(e.data,o.version))n=this._getOrReturnCtx(e,n),b(n,{validation:"ip",code:h.invalid_string,message:o.message}),r.dirty()}else if(o.kind==="jwt"){if(!Ll(e.data,o.alg))n=this._getOrReturnCtx(e,n),b(n,{validation:"jwt",code:h.invalid_string,message:o.message}),r.dirty()}else if(o.kind==="cidr"){if(!Kl(e.data,o.version))n=this._getOrReturnCtx(e,n),b(n,{validation:"cidr",code:h.invalid_string,message:o.message}),r.dirty()}else if(o.kind==="base64"){if(!Sl.test(e.data))n=this._getOrReturnCtx(e,n),b(n,{validation:"base64",code:h.invalid_string,message:o.message}),r.dirty()}else if(o.kind==="base64url"){if(!jl.test(e.data))n=this._getOrReturnCtx(e,n),b(n,{validation:"base64url",code:h.invalid_string,message:o.message}),r.dirty()}else D.assertNever(o);return{status:r.value,value:e.data}}_regex(e,t,r){return this.refinement((n)=>e.test(n),{validation:t,code:h.invalid_string,...k.errToObj(r)})}_addCheck(e){return new jt({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...k.errToObj(e)})}url(e){return this._addCheck({kind:"url",...k.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...k.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...k.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",...k.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...k.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...k.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...k.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",...k.errToObj(e)})}base64url(e){return this._addCheck({kind:"base64url",...k.errToObj(e)})}jwt(e){return this._addCheck({kind:"jwt",...k.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...k.errToObj(e)})}cidr(e){return this._addCheck({kind:"cidr",...k.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,...k.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,...k.errToObj(e?.message)})}duration(e){return this._addCheck({kind:"duration",...k.errToObj(e)})}regex(e,t){return this._addCheck({kind:"regex",regex:e,...k.errToObj(t)})}includes(e,t){return this._addCheck({kind:"includes",value:e,position:t?.position,...k.errToObj(t?.message)})}startsWith(e,t){return this._addCheck({kind:"startsWith",value:e,...k.errToObj(t)})}endsWith(e,t){return this._addCheck({kind:"endsWith",value:e,...k.errToObj(t)})}min(e,t){return this._addCheck({kind:"min",value:e,...k.errToObj(t)})}max(e,t){return this._addCheck({kind:"max",value:e,...k.errToObj(t)})}length(e,t){return this._addCheck({kind:"length",value:e,...k.errToObj(t)})}nonempty(e){return this.min(1,k.errToObj(e))}trim(){return new jt({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new jt({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new jt({...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}}jt.create=(e)=>new jt({checks:[],typeName:N.ZodString,coerce:e?.coerce??!1,...U(e)});function Bl(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 Fr extends L{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)!==R.number){let o=this._getOrReturnCtx(e);return b(o,{code:h.invalid_type,expected:R.number,received:o.parsedType}),P}let r=void 0,n=new Ue;for(let o of this._def.checks)if(o.kind==="int"){if(!D.isInteger(e.data))r=this._getOrReturnCtx(e,r),b(r,{code:h.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),b(r,{code:h.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),b(r,{code:h.too_big,maximum:o.value,type:"number",inclusive:o.inclusive,exact:!1,message:o.message}),n.dirty()}else if(o.kind==="multipleOf"){if(Bl(e.data,o.value)!==0)r=this._getOrReturnCtx(e,r),b(r,{code:h.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),b(r,{code:h.not_finite,message:o.message}),n.dirty()}else D.assertNever(o);return{status:n.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,k.toString(t))}gt(e,t){return this.setLimit("min",e,!1,k.toString(t))}lte(e,t){return this.setLimit("max",e,!0,k.toString(t))}lt(e,t){return this.setLimit("max",e,!1,k.toString(t))}setLimit(e,t,r,n){return new Fr({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:r,message:k.toString(n)}]})}_addCheck(e){return new Fr({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:k.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:k.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:k.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:k.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:k.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:k.toString(t)})}finite(e){return this._addCheck({kind:"finite",message:k.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:k.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:k.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"&&D.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)}}Fr.create=(e)=>new Fr({checks:[],typeName:N.ZodNumber,coerce:e?.coerce||!1,...U(e)});class Ar extends L{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)!==R.bigint)return this._getInvalidInput(e);let r=void 0,n=new Ue;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),b(r,{code:h.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),b(r,{code:h.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),b(r,{code:h.not_multiple_of,multipleOf:o.value,message:o.message}),n.dirty()}else D.assertNever(o);return{status:n.value,value:e.data}}_getInvalidInput(e){let t=this._getOrReturnCtx(e);return b(t,{code:h.invalid_type,expected:R.bigint,received:t.parsedType}),P}gte(e,t){return this.setLimit("min",e,!0,k.toString(t))}gt(e,t){return this.setLimit("min",e,!1,k.toString(t))}lte(e,t){return this.setLimit("max",e,!0,k.toString(t))}lt(e,t){return this.setLimit("max",e,!1,k.toString(t))}setLimit(e,t,r,n){return new Ar({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:r,message:k.toString(n)}]})}_addCheck(e){return new Ar({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:k.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:k.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:k.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:k.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:k.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}}Ar.create=(e)=>new Ar({checks:[],typeName:N.ZodBigInt,coerce:e?.coerce??!1,...U(e)});class An extends L{_parse(e){if(this._def.coerce)e.data=Boolean(e.data);if(this._getType(e)!==R.boolean){let r=this._getOrReturnCtx(e);return b(r,{code:h.invalid_type,expected:R.boolean,received:r.parsedType}),P}return Ge(e.data)}}An.create=(e)=>new An({typeName:N.ZodBoolean,coerce:e?.coerce||!1,...U(e)});class Jr extends L{_parse(e){if(this._def.coerce)e.data=new Date(e.data);if(this._getType(e)!==R.date){let o=this._getOrReturnCtx(e);return b(o,{code:h.invalid_type,expected:R.date,received:o.parsedType}),P}if(Number.isNaN(e.data.getTime())){let o=this._getOrReturnCtx(e);return b(o,{code:h.invalid_date}),P}let r=new Ue,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),b(n,{code:h.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),b(n,{code:h.too_big,message:o.message,inclusive:!0,exact:!1,maximum:o.value,type:"date"}),r.dirty()}else D.assertNever(o);return{status:r.value,value:new Date(e.data.getTime())}}_addCheck(e){return new Jr({...this._def,checks:[...this._def.checks,e]})}min(e,t){return this._addCheck({kind:"min",value:e.getTime(),message:k.toString(t)})}max(e,t){return this._addCheck({kind:"max",value:e.getTime(),message:k.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}}Jr.create=(e)=>new Jr({checks:[],coerce:e?.coerce||!1,typeName:N.ZodDate,...U(e)});class mo extends L{_parse(e){if(this._getType(e)!==R.symbol){let r=this._getOrReturnCtx(e);return b(r,{code:h.invalid_type,expected:R.symbol,received:r.parsedType}),P}return Ge(e.data)}}mo.create=(e)=>new mo({typeName:N.ZodSymbol,...U(e)});class kn extends L{_parse(e){if(this._getType(e)!==R.undefined){let r=this._getOrReturnCtx(e);return b(r,{code:h.invalid_type,expected:R.undefined,received:r.parsedType}),P}return Ge(e.data)}}kn.create=(e)=>new kn({typeName:N.ZodUndefined,...U(e)});class Cn extends L{_parse(e){if(this._getType(e)!==R.null){let r=this._getOrReturnCtx(e);return b(r,{code:h.invalid_type,expected:R.null,received:r.parsedType}),P}return Ge(e.data)}}Cn.create=(e)=>new Cn({typeName:N.ZodNull,...U(e)});class Yr extends L{constructor(){super(...arguments);this._any=!0}_parse(e){return Ge(e.data)}}Yr.create=(e)=>new Yr({typeName:N.ZodAny,...U(e)});class Rr extends L{constructor(){super(...arguments);this._unknown=!0}_parse(e){return Ge(e.data)}}Rr.create=(e)=>new Rr({typeName:N.ZodUnknown,...U(e)});class zt extends L{_parse(e){let t=this._getOrReturnCtx(e);return b(t,{code:h.invalid_type,expected:R.never,received:t.parsedType}),P}}zt.create=(e)=>new zt({typeName:N.ZodNever,...U(e)});class po extends L{_parse(e){if(this._getType(e)!==R.undefined){let r=this._getOrReturnCtx(e);return b(r,{code:h.invalid_type,expected:R.void,received:r.parsedType}),P}return Ge(e.data)}}po.create=(e)=>new po({typeName:N.ZodVoid,...U(e)});class Mt extends L{_parse(e){let{ctx:t,status:r}=this._processInputParams(e),n=this._def;if(t.parsedType!==R.array)return b(t,{code:h.invalid_type,expected:R.array,received:t.parsedType}),P;if(n.exactLength!==null){let i=t.data.length>n.exactLength.value,s=t.data.length<n.exactLength.value;if(i||s)b(t,{code:i?h.too_big:h.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)b(t,{code:h.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)b(t,{code:h.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 Et(t,i,t.path,s)))).then((i)=>Ue.mergeArray(r,i));let o=[...t.data].map((i,s)=>n.type._parseSync(new Et(t,i,t.path,s)));return Ue.mergeArray(r,o)}get element(){return this._def.type}min(e,t){return new Mt({...this._def,minLength:{value:e,message:k.toString(t)}})}max(e,t){return new Mt({...this._def,maxLength:{value:e,message:k.toString(t)}})}length(e,t){return new Mt({...this._def,exactLength:{value:e,message:k.toString(t)}})}nonempty(e){return this.min(1,e)}}Mt.create=(e,t)=>new Mt({type:e,minLength:null,maxLength:null,exactLength:null,typeName:N.ZodArray,...U(t)});function Rn(e){if(e instanceof he){let t={};for(let r in e.shape){let n=e.shape[r];t[r]=Ut.create(Rn(n))}return new he({...e._def,shape:()=>t})}else if(e instanceof Mt)return new Mt({...e._def,type:Rn(e.element)});else if(e instanceof Ut)return Ut.create(Rn(e.unwrap()));else if(e instanceof fr)return fr.create(Rn(e.unwrap()));else if(e instanceof Wt)return Wt.create(e.items.map((t)=>Rn(t)));else return e}class he extends L{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=D.objectKeys(e);return this._cached={shape:e,keys:t},this._cached}_parse(e){if(this._getType(e)!==R.object){let c=this._getOrReturnCtx(e);return b(c,{code:h.invalid_type,expected:R.object,received:c.parsedType}),P}let{status:r,ctx:n}=this._processInputParams(e),{shape:o,keys:i}=this._getCached(),s=[];if(!(this._def.catchall instanceof zt&&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 u=o[c],m=n.data[c];a.push({key:{status:"valid",value:c},value:u._parse(new Et(n,m,n.path,c)),alwaysSet:c in n.data})}if(this._def.catchall instanceof zt){let c=this._def.unknownKeys;if(c==="passthrough")for(let u of s)a.push({key:{status:"valid",value:u},value:{status:"valid",value:n.data[u]}});else if(c==="strict"){if(s.length>0)b(n,{code:h.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 u of s){let m=n.data[u];a.push({key:{status:"valid",value:u},value:c._parse(new Et(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,g=await u.value;c.push({key:m,value:g,alwaysSet:u.alwaysSet})}return c}).then((c)=>Ue.mergeObjectSync(r,c));else return Ue.mergeObjectSync(r,a)}get shape(){return this._def.shape()}strict(e){return k.errToObj,new he({...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:k.errToObj(e).message??n};return{message:n}}}:{}})}strip(){return new he({...this._def,unknownKeys:"strip"})}passthrough(){return new he({...this._def,unknownKeys:"passthrough"})}extend(e){return new he({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new he({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 he({...this._def,catchall:e})}pick(e){let t={};for(let r of D.objectKeys(e))if(e[r]&&this.shape[r])t[r]=this.shape[r];return new he({...this._def,shape:()=>t})}omit(e){let t={};for(let r of D.objectKeys(this.shape))if(!e[r])t[r]=this.shape[r];return new he({...this._def,shape:()=>t})}deepPartial(){return Rn(this)}partial(e){let t={};for(let r of D.objectKeys(this.shape)){let n=this.shape[r];if(e&&!e[r])t[r]=n;else t[r]=n.optional()}return new he({...this._def,shape:()=>t})}required(e){let t={};for(let r of D.objectKeys(this.shape))if(e&&!e[r])t[r]=this.shape[r];else{let o=this.shape[r];while(o instanceof Ut)o=o._def.innerType;t[r]=o}return new he({...this._def,shape:()=>t})}keyof(){return Va(D.objectKeys(this.shape))}}he.create=(e,t)=>new he({shape:()=>e,unknownKeys:"strip",catchall:zt.create(),typeName:N.ZodObject,...U(t)});he.strictCreate=(e,t)=>new he({shape:()=>e,unknownKeys:"strict",catchall:zt.create(),typeName:N.ZodObject,...U(t)});he.lazycreate=(e,t)=>new he({shape:e,unknownKeys:"strip",catchall:zt.create(),typeName:N.ZodObject,...U(t)});class Tn extends L{_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 Ze(s.ctx.common.issues));return b(t,{code:h.invalid_union,unionErrors:i}),P}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},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)i.push(c.common.issues)}if(o)return t.common.issues.push(...o.ctx.common.issues),o.result;let s=i.map((a)=>new Ze(a));return b(t,{code:h.invalid_union,unionErrors:s}),P}}get options(){return this._def.options}}Tn.create=(e,t)=>new Tn({options:e,typeName:N.ZodUnion,...U(t)});var ur=(e)=>{if(e instanceof Nn)return ur(e.schema);else if(e instanceof Lt)return ur(e.innerType());else if(e instanceof Sn)return[e.value];else if(e instanceof kr)return e.options;else if(e instanceof jn)return D.objectValues(e.enum);else if(e instanceof Mn)return ur(e._def.innerType);else if(e instanceof kn)return[void 0];else if(e instanceof Cn)return[null];else if(e instanceof Ut)return[void 0,...ur(e.unwrap())];else if(e instanceof fr)return[null,...ur(e.unwrap())];else if(e instanceof si)return ur(e.unwrap());else if(e instanceof En)return ur(e.unwrap());else if(e instanceof Un)return ur(e._def.innerType);else return[]};class ii extends L{_parse(e){let{ctx:t}=this._processInputParams(e);if(t.parsedType!==R.object)return b(t,{code:h.invalid_type,expected:R.object,received:t.parsedType}),P;let r=this.discriminator,n=t.data[r],o=this.optionsMap.get(n);if(!o)return b(t,{code:h.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[r]}),P;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=ur(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 ii({typeName:N.ZodDiscriminatedUnion,discriminator:e,options:t,optionsMap:n,...U(r)})}}function ts(e,t){let r=Vt(e),n=Vt(t);if(e===t)return{valid:!0,data:e};else if(r===R.object&&n===R.object){let o=D.objectKeys(t),i=D.objectKeys(e).filter((a)=>o.indexOf(a)!==-1),s={...e,...t};for(let a of i){let c=ts(e[a],t[a]);if(!c.valid)return{valid:!1};s[a]=c.data}return{valid:!0,data:s}}else if(r===R.array&&n===R.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=ts(s,a);if(!c.valid)return{valid:!1};o.push(c.data)}return{valid:!0,data:o}}else if(r===R.date&&n===R.date&&+e===+t)return{valid:!0,data:e};else return{valid:!1}}class Pn extends L{_parse(e){let{status:t,ctx:r}=this._processInputParams(e),n=(o,i)=>{if(ni(o)||ni(i))return P;let s=ts(o.value,i.value);if(!s.valid)return b(r,{code:h.invalid_intersection_types}),P;if(oi(o)||oi(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}))}}Pn.create=(e,t,r)=>new Pn({left:e,right:t,typeName:N.ZodIntersection,...U(r)});class Wt extends L{_parse(e){let{status:t,ctx:r}=this._processInputParams(e);if(r.parsedType!==R.array)return b(r,{code:h.invalid_type,expected:R.array,received:r.parsedType}),P;if(r.data.length<this._def.items.length)return b(r,{code:h.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),P;if(!this._def.rest&&r.data.length>this._def.items.length)b(r,{code:h.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 Et(r,i,r.path,s))}).filter((i)=>!!i);if(r.common.async)return Promise.all(o).then((i)=>Ue.mergeArray(t,i));else return Ue.mergeArray(t,o)}get items(){return this._def.items}rest(e){return new Wt({...this._def,rest:e})}}Wt.create=(e,t)=>{if(!Array.isArray(e))throw Error("You must pass an array of schemas to z.tuple([ ... ])");return new Wt({items:e,typeName:N.ZodTuple,rest:null,...U(t)})};class lo extends L{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!==R.object)return b(r,{code:h.invalid_type,expected:R.object,received:r.parsedType}),P;let n=[],o=this._def.keyType,i=this._def.valueType;for(let s in r.data)n.push({key:o._parse(new Et(r,s,r.path,s)),value:i._parse(new Et(r,r.data[s],r.path,s)),alwaysSet:s in r.data});if(r.common.async)return Ue.mergeObjectAsync(t,n);else return Ue.mergeObjectSync(t,n)}get element(){return this._def.valueType}static create(e,t,r){if(t instanceof L)return new lo({keyType:e,valueType:t,typeName:N.ZodRecord,...U(r)});return new lo({keyType:jt.create(),valueType:e,typeName:N.ZodRecord,...U(t)})}}class yo extends L{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!==R.map)return b(r,{code:h.invalid_type,expected:R.map,received:r.parsedType}),P;let n=this._def.keyType,o=this._def.valueType,i=[...r.data.entries()].map(([s,a],c)=>({key:n._parse(new Et(r,s,r.path,[c,"key"])),value:o._parse(new Et(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,u=await a.value;if(c.status==="aborted"||u.status==="aborted")return P;if(c.status==="dirty"||u.status==="dirty")t.dirty();s.set(c.value,u.value)}return{status:t.value,value:s}})}else{let s=new Map;for(let a of i){let{key:c,value:u}=a;if(c.status==="aborted"||u.status==="aborted")return P;if(c.status==="dirty"||u.status==="dirty")t.dirty();s.set(c.value,u.value)}return{status:t.value,value:s}}}}yo.create=(e,t,r)=>new yo({valueType:t,keyType:e,typeName:N.ZodMap,...U(r)});class Xr extends L{_parse(e){let{status:t,ctx:r}=this._processInputParams(e);if(r.parsedType!==R.set)return b(r,{code:h.invalid_type,expected:R.set,received:r.parsedType}),P;let n=this._def;if(n.minSize!==null){if(r.data.size<n.minSize.value)b(r,{code:h.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)b(r,{code:h.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 u of a){if(u.status==="aborted")return P;if(u.status==="dirty")t.dirty();c.add(u.value)}return{status:t.value,value:c}}let s=[...r.data.values()].map((a,c)=>o._parse(new Et(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 Xr({...this._def,minSize:{value:e,message:k.toString(t)}})}max(e,t){return new Xr({...this._def,maxSize:{value:e,message:k.toString(t)}})}size(e,t){return this.min(e,t).max(e,t)}nonempty(e){return this.min(1,e)}}Xr.create=(e,t)=>new Xr({valueType:e,minSize:null,maxSize:null,typeName:N.ZodSet,...U(t)});class Fn extends L{constructor(){super(...arguments);this.validate=this.implement}_parse(e){let{ctx:t}=this._processInputParams(e);if(t.parsedType!==R.function)return b(t,{code:h.invalid_type,expected:R.function,received:t.parsedType}),P;function r(s,a){return fo({data:s,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,$n(),cr].filter((c)=>!!c),issueData:{code:h.invalid_arguments,argumentsError:a}})}function n(s,a){return fo({data:s,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,$n(),cr].filter((c)=>!!c),issueData:{code:h.invalid_return_type,returnTypeError:a}})}let o={errorMap:t.common.contextualErrorMap},i=t.data;if(this._def.returns instanceof Qr){let s=this;return Ge(async function(...a){let c=new Ze([]),u=await s._def.args.parseAsync(a,o).catch((I)=>{throw c.addIssue(r(a,I)),c}),m=await Reflect.apply(i,this,u);return await s._def.returns._def.type.parseAsync(m,o).catch((I)=>{throw c.addIssue(n(m,I)),c})})}else{let s=this;return Ge(function(...a){let c=s._def.args.safeParse(a,o);if(!c.success)throw new Ze([r(a,c.error)]);let u=Reflect.apply(i,this,c.data),m=s._def.returns.safeParse(u,o);if(!m.success)throw new Ze([n(u,m.error)]);return m.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new Fn({...this._def,args:Wt.create(e).rest(Rr.create())})}returns(e){return new Fn({...this._def,returns:e})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,t,r){return new Fn({args:e?e:Wt.create([]).rest(Rr.create()),returns:t||Rr.create(),typeName:N.ZodFunction,...U(r)})}}class Nn extends L{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})}}Nn.create=(e,t)=>new Nn({getter:e,typeName:N.ZodLazy,...U(t)});class Sn extends L{_parse(e){if(e.data!==this._def.value){let t=this._getOrReturnCtx(e);return b(t,{received:t.data,code:h.invalid_literal,expected:this._def.value}),P}return{status:"valid",value:e.data}}get value(){return this._def.value}}Sn.create=(e,t)=>new Sn({value:e,typeName:N.ZodLiteral,...U(t)});function Va(e,t){return new kr({values:e,typeName:N.ZodEnum,...U(t)})}class kr extends L{_parse(e){if(typeof e.data!=="string"){let t=this._getOrReturnCtx(e),r=this._def.values;return b(t,{expected:D.joinValues(r),received:t.parsedType,code:h.invalid_type}),P}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 b(t,{received:t.data,code:h.invalid_enum_value,options:r}),P}return Ge(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 kr.create(e,{...this._def,...t})}exclude(e,t=this._def){return kr.create(this.options.filter((r)=>!e.includes(r)),{...this._def,...t})}}kr.create=Va;class jn extends L{_parse(e){let t=D.getValidEnumValues(this._def.values),r=this._getOrReturnCtx(e);if(r.parsedType!==R.string&&r.parsedType!==R.number){let n=D.objectValues(t);return b(r,{expected:D.joinValues(n),received:r.parsedType,code:h.invalid_type}),P}if(!this._cache)this._cache=new Set(D.getValidEnumValues(this._def.values));if(!this._cache.has(e.data)){let n=D.objectValues(t);return b(r,{received:r.data,code:h.invalid_enum_value,options:n}),P}return Ge(e.data)}get enum(){return this._def.values}}jn.create=(e,t)=>new jn({values:e,typeName:N.ZodNativeEnum,...U(t)});class Qr extends L{unwrap(){return this._def.type}_parse(e){let{ctx:t}=this._processInputParams(e);if(t.parsedType!==R.promise&&t.common.async===!1)return b(t,{code:h.invalid_type,expected:R.promise,received:t.parsedType}),P;let r=t.parsedType===R.promise?t.data:Promise.resolve(t.data);return Ge(r.then((n)=>this._def.type.parseAsync(n,{path:t.path,errorMap:t.common.contextualErrorMap})))}}Qr.create=(e,t)=>new Qr({type:e,typeName:N.ZodPromise,...U(t)});class Lt extends L{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:(i)=>{if(b(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 P;let a=await this._def.schema._parseAsync({data:s,path:r.path,parent:r});if(a.status==="aborted")return P;if(a.status==="dirty")return Wr(a.value);if(t.value==="dirty")return Wr(a.value);return a});else{if(t.value==="aborted")return P;let s=this._def.schema._parseSync({data:i,path:r.path,parent:r});if(s.status==="aborted")return P;if(s.status==="dirty")return Wr(s.value);if(t.value==="dirty")return Wr(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 P;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 P;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(!wr(i))return P;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(!wr(i))return P;return Promise.resolve(n.transform(i.value,o)).then((s)=>({status:t.value,value:s}))});D.assertNever(n)}}Lt.create=(e,t,r)=>new Lt({schema:e,typeName:N.ZodEffects,effect:t,...U(r)});Lt.createWithPreprocess=(e,t,r)=>new Lt({schema:t,effect:{type:"preprocess",transform:e},typeName:N.ZodEffects,...U(r)});class Ut extends L{_parse(e){if(this._getType(e)===R.undefined)return Ge(void 0);return this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}Ut.create=(e,t)=>new Ut({innerType:e,typeName:N.ZodOptional,...U(t)});class fr extends L{_parse(e){if(this._getType(e)===R.null)return Ge(null);return this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}fr.create=(e,t)=>new fr({innerType:e,typeName:N.ZodNullable,...U(t)});class Mn extends L{_parse(e){let{ctx:t}=this._processInputParams(e),r=t.data;if(t.parsedType===R.undefined)r=this._def.defaultValue();return this._def.innerType._parse({data:r,path:t.path,parent:t})}removeDefault(){return this._def.innerType}}Mn.create=(e,t)=>new Mn({innerType:e,typeName:N.ZodDefault,defaultValue:typeof t.default==="function"?t.default:()=>t.default,...U(t)});class Un extends L{_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(wn(n))return n.then((o)=>({status:"valid",value:o.status==="valid"?o.value:this._def.catchValue({get error(){return new Ze(r.common.issues)},input:r.data})}));else return{status:"valid",value:n.status==="valid"?n.value:this._def.catchValue({get error(){return new Ze(r.common.issues)},input:r.data})}}removeCatch(){return this._def.innerType}}Un.create=(e,t)=>new Un({innerType:e,typeName:N.ZodCatch,catchValue:typeof t.catch==="function"?t.catch:()=>t.catch,...U(t)});class go extends L{_parse(e){if(this._getType(e)!==R.nan){let r=this._getOrReturnCtx(e);return b(r,{code:h.invalid_type,expected:R.nan,received:r.parsedType}),P}return{status:"valid",value:e.data}}}go.create=(e)=>new go({typeName:N.ZodNaN,...U(e)});var Dl=Symbol("zod_brand");class si extends L{_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 xo extends L{_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 P;if(o.status==="dirty")return t.dirty(),Wr(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 P;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 xo({in:e,out:t,typeName:N.ZodPipeline})}}class En extends L{_parse(e){let t=this._def.innerType._parse(e),r=(n)=>{if(wr(n))n.value=Object.freeze(n.value);return n};return wn(t)?t.then((n)=>r(n)):r(t)}unwrap(){return this._def.innerType}}En.create=(e,t)=>new En({innerType:e,typeName:N.ZodReadonly,...U(t)});function Ga(e,t){let r=typeof e==="function"?e(t):typeof e==="string"?{message:e}:e;return typeof r==="string"?{message:r}:r}function za(e,t={},r){if(e)return Yr.create().superRefine((n,o)=>{let i=e(n);if(i instanceof Promise)return i.then((s)=>{if(!s){let a=Ga(t,n),c=a.fatal??r??!0;o.addIssue({code:"custom",...a,fatal:c})}});if(!i){let s=Ga(t,n),a=s.fatal??r??!0;o.addIssue({code:"custom",...s,fatal:a})}return});return Yr.create()}var Gl={object:he.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 ql=(e,t={message:`Input not instance of ${e.name}`})=>za((r)=>r instanceof e,t),Wa=jt.create,Ja=Fr.create,vl=go.create,Hl=Ar.create,Ya=An.create,Vl=Jr.create,zl=mo.create,Wl=kn.create,Jl=Cn.create,Yl=Yr.create,Xl=Rr.create,Ql=zt.create,Zl=po.create,ey=Mt.create,{create:ty,strictCreate:ry}=he,ny=Tn.create,oy=ii.create,iy=Pn.create,sy=Wt.create,ay=lo.create,cy=yo.create,uy=Xr.create,fy=Fn.create,dy=Nn.create,my=Sn.create,py=kr.create,ly=jn.create,yy=Qr.create,gy=Lt.create,xy=Ut.create,hy=fr.create,Iy=Lt.createWithPreprocess,by=xo.create,_y=()=>Wa().optional(),Oy=()=>Ja().optional(),$y=()=>Ya().optional(),wy={string:(e)=>jt.create({...e,coerce:!0}),number:(e)=>Fr.create({...e,coerce:!0}),boolean:(e)=>An.create({...e,coerce:!0}),bigint:(e)=>Ar.create({...e,coerce:!0}),date:(e)=>Jr.create({...e,coerce:!0})};var Ry=P;var Fy=ai,He=(e,t=400)=>Response.json(e,{status:t,headers:{"Content-Type":"application/json"}}),Qa=(e)=>{let t=uo.Compile(e),r=async(n,o)=>{try{let i=n instanceof Object&&"req"in n,s=i?await n.jsonBody():await n.json();if(!t.Check(s)){let a=t.Errors(s).First();return He({status:"error",code:"VALIDATION_FAILED",message:a?.message||"Invalid input",path:a?.path||"body"})}if(i)n.body=s;return o?o():void 0}catch{return He({status:"error",message:"Malformed JSON payload"})}};return r.__schema=e,r},Za=(e)=>{let t=e.properties||{},r=Object.keys(t),n=r.length,o=Array.isArray(e.required)?new Set(e.required):null,i=async(s,a)=>{try{let c=s instanceof Object&&"req"in s,u=c?await s.jsonBody():await s.json();if(!u||typeof u!=="object"||Array.isArray(u))return He({status:"error",message:"Invalid JSON object payload"});for(let m=0;m<n;m++){let g=r[m];if(!(Object.hasOwn(u,g)&&u[g]!==void 0)){if(!o||o.has(g))return He({status:"error",code:"TYPE_MISMATCH",message:`Field '${g}' must be of type ${t[g]?.type}`,field:g});continue}if(typeof u[g]!==t[g]?.type)return He({status:"error",code:"TYPE_MISMATCH",message:`Field '${g}' must be of type ${t[g]?.type}`,field:g})}if(c)s.body=u;return a?a():void 0}catch{return He({status:"error",message:"Invalid JSON payload"})}};return i.__schema=e,i},ec=(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 He({status:"error",code:"ZOD_ERROR",errors:s.error.flatten()});if(o)r.body=s.data;return n?n():void 0}catch{return He({status:"error",message:"Invalid JSON payload"})}};return t.__schema=e,t},Ay=(e)=>{if(e&&"_def"in e)return ec(e);if(e&&(e.kind||e.type||e[Symbol.for("TypeBox.Kind")]))return Qa(e);return Za(e)};var ho=(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=uo.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}}}},rs=(e,t)=>{let r=e?.properties;if(!r||typeof r!=="object")return null;let n=[];for(let[o,i]of Object.entries(r)){let s=JSON.stringify(o),a=`${t}[${s}]`,c=rs(i,a);if(c)n.push(`${s}: (${a} && typeof ${a} === 'object' && !Array.isArray(${a})) ? ${c} : ${a}`);else n.push(`${s}: ${a}`)}return`{ ${n.join(", ")} }`},ky=(e)=>{if(!e||"_def"in e)return null;if(e.type==="array"&&e.items){let r=rs(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=rs(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
+ }`)()},tc=(e)=>{let t=ho(e),r=ky(e);return(n)=>{if(n instanceof Response)return n;let o=r?r(n):n,i=t(o);if(!i.ok)return He({status:"error",code:"RESPONSE_VALIDATION_FAILED",error:i.error},500);return i.data}},Xa=(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,i]of Object.entries(r)){if(!Object.hasOwn(n,o))continue;let s=n[o];if(typeof s!=="string")continue;let a=i?.type||i?._def?.typeName;if(a==="number"||a==="integer"||a==="ZodNumber"){if(s.trim()!==""){let c=Number(s);if(!Number.isNaN(c))n[o]=c}}else if(a==="boolean"||a==="ZodBoolean"){if(s==="true")n[o]=!0;else if(s==="false")n[o]=!1}}return n},ns=(e)=>{let t=e.body?ho(e.body):null,r=e.query?ho(e.query):null,n=e.params?ho(e.params):null,o=e.headers?ho(e.headers):null,i=e.response?tc(e.response):null,s=e.maxBodySize??1048576,a=(u)=>{if(n){let m=Xa(u.params,e.params),g=n(m);if(!g.ok)return He({status:"error",code:"PARAMS_INVALID",error:g.error});u.params=g.data}if(r){let m=Xa(u.query,e.query),g=r(m);if(!g.ok)return He({status:"error",code:"QUERY_INVALID",error:g.error});u._query=g.data}if(o){let m={};u.req.headers.forEach((I,O)=>{m[O.toLowerCase()]=I});let g=o(m);if(!g.ok)return He({status:"error",code:"HEADERS_INVALID",error:g.error})}return};if(!t){let u=(m,g)=>{let I=a(m);if(I)return I;return g?g():void 0};if(u.__routeSchemas=e,i)u.__responseFilter=i;return u}let c=async(u,m)=>{let g=a(u);if(g)return g;let I;try{I=await u.jsonBody(s)}catch(T){if(T?.status===413)return He({status:"error",code:"PAYLOAD_TOO_LARGE",message:"Payload Too Large"},413);return He({status:"error",message:"Malformed JSON payload"})}let O=t(I);if(!O.ok)return He({status:"error",code:"VALIDATION_FAILED",error:O.error});return u.body=O.data,m?m():void 0};if(c.__schema=e.body,c.__routeSchemas=e,i)c.__responseFilter=i;return c};class Ln{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 i=0;i<r.length;i++){let s=r[i];if(typeof s==="function")o.push(s);else if(s&&typeof s==="object")o.push(ns(s))}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);group=(e,...t)=>{let r=t.pop(),n=t,o=(this.prefix+"/"+e).replace(/\/+/g,"/"),i=new Ln(o,[...this.groupMiddleware,...n]);return r(i),this.routes.push(...i.routes),this};use(e){if(e instanceof Ln||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 Zr{children={};staticKeys=[];paramNode=null;paramName=null;wildcardNode=null;handlers={};insert(e,t,r){let n=this,o=e.split("/").filter(Boolean);for(let i of o)if(i==="*"){if(!n.wildcardNode)n.wildcardNode=new Zr;n=n.wildcardNode;break}else if(i.startsWith(":")){if(!n.paramNode)n.paramNode=new Zr;n.paramName=i.slice(1),n=n.paramNode}else{if(!n.children[i])n.children[i]=new Zr,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,u=!1,m=o.staticKeys,g=m.length;if(g===1){let I=m[0];if(I.length===c){let O=!0;for(let T=0;T<c;T++)if(I[T]!==t[i+T]){O=!1;break}if(O)o=o.children[I],u=!0}}else for(let I=0;I<g;I++){let O=m[I];if(O.length===c){let T=!0;for(let C=0;C<c;C++)if(O[C]!==t[i+C]){T=!1;break}if(T){o=o.children[O],u=!0;break}}}if(!u)if(o.paramNode)n.params[o.paramName]=t.slice(i,a),o=o.paramNode;else if(o.wildcardNode)return n.params["*"]=t.slice(i),o.wildcardNode.handlers[e]||null;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) {
20
+ `,o.length>0){let a=o.map((c)=>`${JSON.stringify(c.name)}: ${c.varName}`).join(", ");i+=`${s} ctx.params = { ${a} };
4
21
  `}i+=`${s} switch(method) {
5
- `;for(let[a,f]of Object.entries(this.handlers)){let l=e(f);i+=`${s} case ${JSON.stringify(a)}: return ${l}(ctx);
22
+ `;for(let[a,c]of Object.entries(this.handlers)){let u=e(c);i+=`${s} case ${JSON.stringify(a)}: return ${u}(ctx);
6
23
  `}i+=`${s} }
7
24
  `,i+=`${s}}
8
- `}if(this.staticKeys.length>0)if(this.staticKeys.length===1){let a=this.staticKeys[0],f=a.length,l=`nextIdxL${t}`;i+=`${s}if (${r}.startsWith(${JSON.stringify(a)}, ${n})) {
9
- `,i+=`${s} const ${l} = ${n} + ${f};
10
- `,i+=`${s} if (${l} === urlLen || ${r}.charCodeAt(${l}) === 47) {
11
- `;let g=this.children[a],R=`newIdxL${t}`;i+=`${s} const ${R} = ${l} === urlLen ? urlLen : (${l} + 1);
12
- `,i+=g.jitCompile(e,t+1,r,R,o),i+=`${s} }
25
+ `}if(this.staticKeys.length>0)if(this.staticKeys.length===1){let a=this.staticKeys[0],c=a.length,u=`nextIdxL${t}`;i+=`${s}if (${r}.startsWith(${JSON.stringify(a)}, ${n})) {
26
+ `,i+=`${s} const ${u} = ${n} + ${c};
27
+ `,i+=`${s} if (${u} === urlLen || ${r}.charCodeAt(${u}) === 47) {
28
+ `;let m=this.children[a],g=`newIdxL${t}`;i+=`${s} const ${g} = ${u} === urlLen ? urlLen : (${u} + 1);
29
+ `,i+=m.jitCompile(e,t+1,r,g,o),i+=`${s} }
13
30
  `,i+=`${s}}
31
+ `}else if(this.staticKeys.length>4){i+=`${s}let slash${t} = ${r}.indexOf('/', ${n});
32
+ `,i+=`${s}if (slash${t} === -1 || slash${t} > urlLen) slash${t} = urlLen;
33
+ `,i+=`${s}switch (${r}.slice(${n}, slash${t})) {
34
+ `;for(let a of this.staticKeys){i+=`${s} case ${JSON.stringify(a)}: {
35
+ `;let c=this.children[a];i+=c.jitCompile(e,t+1,r,`slash${t} + 1`,o),i+=`${s} break;
36
+ `,i+=`${s} }
37
+ `}i+=`${s}}
14
38
  `}else{i+=`${s}let slash${t} = ${r}.indexOf('/', ${n});
15
39
  `,i+=`${s}if (slash${t} === -1 || slash${t} > urlLen) slash${t} = urlLen;
16
40
  `,i+=`${s}const len${t} = slash${t} - (${n});
17
41
 
18
- `;let a=new Map;for(let f of this.staticKeys){let l=a.get(f.length);if(!l)l=[],a.set(f.length,l);l.push(f)}i+=`${s}switch(len${t}) {
19
- `;for(let[f,l]of a){i+=`${s} case ${f}:
20
- `;for(let g of l){if(f===1)i+=`${s} if (${r}.charCodeAt(${n}) === ${g.charCodeAt(0)}) {
21
- `;else i+=`${s} if (${r}.startsWith(${JSON.stringify(g)}, ${n})) {
22
- `;let R=this.children[g];i+=R.jitCompile(e,t+1,r,`slash${t} + 1`,o),i+=`${s} }
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)}i+=`${s}switch(len${t}) {
43
+ `;for(let[c,u]of a){i+=`${s} case ${c}:
44
+ `;for(let m of u){if(c===1)i+=`${s} if (${r}.charCodeAt(${n}) === ${m.charCodeAt(0)}) {
45
+ `;else i+=`${s} if (${r}.startsWith(${JSON.stringify(m)}, ${n})) {
46
+ `;let g=this.children[m];i+=g.jitCompile(e,t+1,r,`slash${t} + 1`,o),i+=`${s} }
23
47
  `}i+=`${s} break;
24
48
  `}i+=`${s}}
25
- `}if(this.paramNode){let a=this.paramNode;if(this.staticKeys.length===0)i+=`${s}let slash${t} = ${r}.indexOf('/', ${n});
49
+ `}if(this.paramNode){let a=this.paramNode;if(this.staticKeys.length<=1)i+=`${s}let slash${t} = ${r}.indexOf('/', ${n});
26
50
  `,i+=`${s}if (slash${t} === -1 || slash${t} > urlLen) slash${t} = urlLen;
27
- `;let f=`pL${t}`;i+=`${s}const ${f} = ${r}.slice(${n}, slash${t});
28
- `;let l=[...o,{name:this.paramName,varName:f}];i+=a.jitCompile(e,t+1,r,`slash${t} + 1`,l)}return i}id=Math.random().toString(36).slice(2)}class ao{req;params={};_status=200;_headers=void 0;store=new Map;body=void 0;query={};constructor(){}async jsonBody(){if(this.body!==void 0)return this.body;let e=this.req.headers.get("content-type");if(e&&e.includes("application/json"))try{return this.body=await this.req.json()}catch{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={},this.body=void 0,this}status(e){return this._status=e,this}json(e){let t=this._status||200;if(!this._headers)return Response.json(e,{status:t});if(this._headers["content-type"]===void 0)this._headers["content-type"]="application/json";return Response.json(e,{status:t,headers:this._headers})}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={};return this._headers[e.toLowerCase()]=t,this}send(e,t={}){let r=this._status>=400;return this.json({status:r?"error":"success",msg:e,...t})}}function Yi(e){return re(e)&&!ye(e)&&!Xt(e)&&Symbol.asyncIterator in e}function ye(e){return Array.isArray(e)}function co(e){return typeof e==="bigint"}function Qt(e){return typeof e==="boolean"}function qr(e){return e instanceof globalThis.Date}function Qi(e){return typeof e==="function"}function Xi(e){return re(e)&&!ye(e)&&!Xt(e)&&Symbol.iterator in e}function Zi(e){return e===null}function Ve(e){return typeof e==="number"}function re(e){return typeof e==="object"&&e!==null}function uo(e){return e instanceof globalThis.RegExp}function X(e){return typeof e==="string"}function es(e){return typeof e==="symbol"}function Xt(e){return e instanceof globalThis.Uint8Array}function Z(e){return e===void 0}function ru(e){return e.map((t)=>fo(t))}function nu(e){return new Date(e.getTime())}function ou(e){return new Uint8Array(e)}function iu(e){return new RegExp(e.source,e.flags)}function su(e){let t={};for(let r of Object.getOwnPropertyNames(e))t[r]=fo(e[r]);for(let r of Object.getOwnPropertySymbols(e))t[r]=fo(e[r]);return t}function fo(e){return ye(e)?ru(e):qr(e)?nu(e):Xt(e)?ou(e):uo(e)?iu(e):re(e)?su(e):e}function ne(e){return fo(e)}function Vr(e,t){return t===void 0?ne(e):ne({...t,...e})}function mo(e){return Ke(e)&&globalThis.Symbol.asyncIterator in e}function po(e){return Ke(e)&&globalThis.Symbol.iterator in e}function lo(e){return e instanceof globalThis.Promise}function Hr(e){return e instanceof Date&&globalThis.Number.isFinite(e.getTime())}function zr(e){return e instanceof globalThis.Uint8Array}function yo(e,t){return t in e}function Ke(e){return e!==null&&typeof e==="object"}function xe(e){return globalThis.Array.isArray(e)&&!globalThis.ArrayBuffer.isView(e)}function Se(e){return e===void 0}function gr(e){return e===null}function Ir(e){return typeof e==="boolean"}function N(e){return typeof e==="number"}function xo(e){return globalThis.Number.isInteger(e)}function He(e){return typeof e==="bigint"}function _e(e){return typeof e==="string"}function go(e){return typeof e==="function"}function hr(e){return typeof e==="symbol"}function Io(e){return He(e)||Ir(e)||gr(e)||N(e)||_e(e)||hr(e)||Se(e)}var ee;(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&&!xe(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=Se(s);return e.AllowNullVoid?a||s===null:a}e.IsVoidLike=i})(ee||(ee={}));function au(e){return globalThis.Object.freeze(e).map((t)=>jn(t))}function cu(e){return e}function uu(e){return e}function fu(e){return e}function mu(e){let t={};for(let r of Object.getOwnPropertyNames(e))t[r]=jn(e[r]);for(let r of Object.getOwnPropertySymbols(e))t[r]=jn(e[r]);return globalThis.Object.freeze(t)}function jn(e){return ye(e)?au(e):qr(e)?cu(e):Xt(e)?uu(e):uo(e)?fu(e):re(e)?mu(e):e}function d(e,t){let r=t!==void 0?{...t,...e}:e;switch(ee.InstanceMode){case"freeze":return jn(r);case"clone":return ne(r);default:return r}}class v extends Error{constructor(e){super(e)}}var ie=Symbol.for("TypeBox.Transform"),kt=Symbol.for("TypeBox.Readonly"),Re=Symbol.for("TypeBox.Optional"),Nt=Symbol.for("TypeBox.Hint"),y=Symbol.for("TypeBox.Kind");function Wr(e){return re(e)&&e[kt]==="Readonly"}function Ee(e){return re(e)&&e[Re]==="Optional"}function ii(e){return E(e,"Any")}function si(e){return E(e,"Argument")}function ut(e){return E(e,"Array")}function br(e){return E(e,"AsyncIterator")}function _r(e){return E(e,"BigInt")}function Kt(e){return E(e,"Boolean")}function ft(e){return E(e,"Computed")}function mt(e){return E(e,"Constructor")}function du(e){return E(e,"Date")}function dt(e){return E(e,"Function")}function pt(e){return E(e,"Integer")}function ue(e){return E(e,"Intersect")}function Or(e){return E(e,"Iterator")}function E(e,t){return re(e)&&y in e&&e[y]===t}function ho(e){return Qt(e)||Ve(e)||X(e)}function ze(e){return E(e,"Literal")}function We(e){return E(e,"MappedKey")}function oe(e){return E(e,"MappedResult")}function Zt(e){return E(e,"Never")}function pu(e){return E(e,"Not")}function Mn(e){return E(e,"Null")}function lt(e){return E(e,"Number")}function le(e){return E(e,"Object")}function $r(e){return E(e,"Promise")}function Fr(e){return E(e,"Record")}function pe(e){return E(e,"Ref")}function ai(e){return E(e,"RegExp")}function Et(e){return E(e,"String")}function Sn(e){return E(e,"Symbol")}function Je(e){return E(e,"TemplateLiteral")}function lu(e){return E(e,"This")}function D(e){return re(e)&&ie in e}function Ye(e){return E(e,"Tuple")}function Lt(e){return E(e,"Undefined")}function B(e){return E(e,"Union")}function yu(e){return E(e,"Uint8Array")}function xu(e){return E(e,"Unknown")}function gu(e){return E(e,"Unsafe")}function Iu(e){return E(e,"Void")}function hu(e){return re(e)&&y in e&&X(e[y])}function se(e){return ii(e)||si(e)||ut(e)||Kt(e)||_r(e)||br(e)||ft(e)||mt(e)||du(e)||dt(e)||pt(e)||ue(e)||Or(e)||ze(e)||We(e)||oe(e)||Zt(e)||pu(e)||Mn(e)||lt(e)||le(e)||$r(e)||Fr(e)||pe(e)||ai(e)||Et(e)||Sn(e)||Je(e)||lu(e)||Ye(e)||Lt(e)||B(e)||yu(e)||xu(e)||gu(e)||Iu(e)||hu(e)}var bu=["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 ts(e){try{return new RegExp(e),!0}catch{return!1}}function ci(e){if(!X(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 rs(e){return ui(e)||ae(e)}function Un(e){return Z(e)||co(e)}function Y(e){return Z(e)||Ve(e)}function ui(e){return Z(e)||Qt(e)}function H(e){return Z(e)||X(e)}function _u(e){return Z(e)||X(e)&&ci(e)&&ts(e)}function Ou(e){return Z(e)||X(e)&&ci(e)}function ns(e){return Z(e)||ae(e)}function bo(e){return re(e)&&e[Re]==="Optional"}function yt(e){return L(e,"Any")&&H(e.$id)}function $u(e){return L(e,"Argument")&&Ve(e.index)}function wr(e){return L(e,"Array")&&e.type==="array"&&H(e.$id)&&ae(e.items)&&Y(e.minItems)&&Y(e.maxItems)&&ui(e.uniqueItems)&&ns(e.contains)&&Y(e.minContains)&&Y(e.maxContains)}function fi(e){return L(e,"AsyncIterator")&&e.type==="AsyncIterator"&&H(e.$id)&&ae(e.items)}function _o(e){return L(e,"BigInt")&&e.type==="bigint"&&H(e.$id)&&Un(e.exclusiveMaximum)&&Un(e.exclusiveMinimum)&&Un(e.maximum)&&Un(e.minimum)&&Un(e.multipleOf)}function Rr(e){return L(e,"Boolean")&&e.type==="boolean"&&H(e.$id)}function Fu(e){return L(e,"Computed")&&X(e.target)&&ye(e.parameters)&&e.parameters.every((t)=>ae(t))}function Oo(e){return L(e,"Constructor")&&e.type==="Constructor"&&H(e.$id)&&ye(e.parameters)&&e.parameters.every((t)=>ae(t))&&ae(e.returns)}function $o(e){return L(e,"Date")&&e.type==="Date"&&H(e.$id)&&Y(e.exclusiveMaximumTimestamp)&&Y(e.exclusiveMinimumTimestamp)&&Y(e.maximumTimestamp)&&Y(e.minimumTimestamp)&&Y(e.multipleOfTimestamp)}function Fo(e){return L(e,"Function")&&e.type==="Function"&&H(e.$id)&&ye(e.parameters)&&e.parameters.every((t)=>ae(t))&&ae(e.returns)}function Gt(e){return L(e,"Integer")&&e.type==="integer"&&H(e.$id)&&Y(e.exclusiveMaximum)&&Y(e.exclusiveMinimum)&&Y(e.maximum)&&Y(e.minimum)&&Y(e.multipleOf)}function os(e){return re(e)&&Object.entries(e).every(([t,r])=>ci(t)&&ae(r))}function Tr(e){return L(e,"Intersect")&&(X(e.type)&&e.type!=="object"?!1:!0)&&ye(e.allOf)&&e.allOf.every((t)=>ae(t)&&!Nu(t))&&H(e.type)&&(ui(e.unevaluatedProperties)||ns(e.unevaluatedProperties))&&H(e.$id)}function mi(e){return L(e,"Iterator")&&e.type==="Iterator"&&H(e.$id)&&ae(e.items)}function L(e,t){return re(e)&&y in e&&e[y]===t}function is(e){return er(e)&&X(e.const)}function ss(e){return er(e)&&Ve(e.const)}function as(e){return er(e)&&Qt(e.const)}function er(e){return L(e,"Literal")&&H(e.$id)&&wu(e.const)}function wu(e){return Qt(e)||Ve(e)||X(e)}function Ru(e){return L(e,"MappedKey")&&ye(e.keys)&&e.keys.every((t)=>Ve(t)||X(t))}function Tu(e){return L(e,"MappedResult")&&os(e.properties)}function tr(e){return L(e,"Never")&&re(e.not)&&Object.getOwnPropertyNames(e.not).length===0}function Jr(e){return L(e,"Not")&&ae(e.not)}function di(e){return L(e,"Null")&&e.type==="null"&&H(e.$id)}function Le(e){return L(e,"Number")&&e.type==="number"&&H(e.$id)&&Y(e.exclusiveMaximum)&&Y(e.exclusiveMinimum)&&Y(e.maximum)&&Y(e.minimum)&&Y(e.multipleOf)}function fe(e){return L(e,"Object")&&e.type==="object"&&H(e.$id)&&os(e.properties)&&rs(e.additionalProperties)&&Y(e.minProperties)&&Y(e.maxProperties)}function pi(e){return L(e,"Promise")&&e.type==="Promise"&&H(e.$id)&&ae(e.item)}function Te(e){return L(e,"Record")&&e.type==="object"&&H(e.$id)&&rs(e.additionalProperties)&&re(e.patternProperties)&&((t)=>{let r=Object.getOwnPropertyNames(t.patternProperties);return r.length===1&&ts(r[0])&&re(t.patternProperties)&&ae(t.patternProperties[r[0]])})(e)}function Au(e){return L(e,"Ref")&&H(e.$id)&&X(e.$ref)}function Kn(e){return L(e,"RegExp")&&H(e.$id)&&X(e.source)&&X(e.flags)&&Y(e.maxLength)&&Y(e.minLength)}function xt(e){return L(e,"String")&&e.type==="string"&&H(e.$id)&&Y(e.minLength)&&Y(e.maxLength)&&_u(e.pattern)&&Ou(e.format)}function En(e){return L(e,"Symbol")&&e.type==="symbol"&&H(e.$id)}function Ln(e){return L(e,"TemplateLiteral")&&e.type==="string"&&X(e.pattern)&&e.pattern[0]==="^"&&e.pattern[e.pattern.length-1]==="$"}function ku(e){return L(e,"This")&&H(e.$id)&&X(e.$ref)}function Nu(e){return re(e)&&ie in e}function wo(e){return L(e,"Tuple")&&e.type==="array"&&H(e.$id)&&Ve(e.minItems)&&Ve(e.maxItems)&&e.minItems===e.maxItems&&(Z(e.items)&&Z(e.additionalItems)&&e.minItems===0||ye(e.items)&&e.items.every((t)=>ae(t)))}function Ar(e){return L(e,"Undefined")&&e.type==="undefined"&&H(e.$id)}function Dt(e){return L(e,"Union")&&H(e.$id)&&re(e)&&ye(e.anyOf)&&e.anyOf.every((t)=>ae(t))}function Bn(e){return L(e,"Uint8Array")&&e.type==="Uint8Array"&&H(e.$id)&&Y(e.minByteLength)&&Y(e.maxByteLength)}function gt(e){return L(e,"Unknown")&&H(e.$id)}function Pu(e){return L(e,"Unsafe")}function Ro(e){return L(e,"Void")&&e.type==="void"&&H(e.$id)}function Cu(e){return re(e)&&y in e&&X(e[y])&&!bu.includes(e[y])}function ae(e){return re(e)&&(yt(e)||$u(e)||wr(e)||Rr(e)||_o(e)||fi(e)||Fu(e)||Oo(e)||$o(e)||Fo(e)||Gt(e)||Tr(e)||mi(e)||er(e)||Ru(e)||Tu(e)||tr(e)||Jr(e)||di(e)||Le(e)||fe(e)||pi(e)||Te(e)||Au(e)||Kn(e)||xt(e)||En(e)||Ln(e)||ku(e)||wo(e)||Ar(e)||Dt(e)||Bn(e)||gt(e)||Pu(e)||Ro(e)||Cu(e))}var us="(true|false)",To="(0|[1-9][0-9]*)",fs="(.*)";var rr="^(0|[1-9][0-9]*)$",nr="^(.*)$",ms="^(?!.*)$";var ds=new Map;function li(e){return ds.has(e)}function yi(e){return ds.get(e)}var ps=new Map;function Gn(e){return ps.has(e)}function xi(e){return ps.get(e)}function ls(e,t){return e.includes(t)}function ys(e){return[...new Set(e)]}function ju(e,t){return e.filter((r)=>t.includes(r))}function Mu(e,t){return e.reduce((r,n)=>ju(r,n),t)}function xs(e){return e.length===1?e[0]:e.length>1?Mu(e.slice(1),e[0]):[]}function gs(e){let t=[];for(let r of e)t.push(...r);return t}function or(e){return d({[y]:"Any"},e)}function Yr(e,t){return d({[y]:"Array",type:"array",items:e},t)}function Is(e){return d({[y]:"Argument",index:e})}function Qr(e,t){return d({[y]:"AsyncIterator",type:"AsyncIterator",items:e},t)}function te(e,t,r){return d({[y]:"Computed",target:e,parameters:t},r)}function Su(e,t){let{[t]:r,...n}=e;return n}function me(e,t){return t.reduce((r,n)=>Su(r,n),e)}function j(e){return d({[y]:"Never",not:{}},e)}function G(e){return d({[y]:"MappedResult",properties:e})}function Xr(e,t,r){return d({[y]:"Constructor",type:"Constructor",parameters:e,returns:t},r)}function Pt(e,t,r){return d({[y]:"Function",type:"Function",parameters:e,returns:t},r)}function Dn(e,t){return d({[y]:"Union",anyOf:e},t)}function Uu(e){return e.some((t)=>Ee(t))}function hs(e){return e.map((t)=>Ee(t)?Ku(t):t)}function Ku(e){return me(e,[Re])}function Eu(e,t){return Uu(e)?Ne(Dn(hs(e),t)):Dn(hs(e),t)}function Ct(e,t){return e.length===1?d(e[0],t):e.length===0?j(t):Eu(e,t)}function V(e,t){return e.length===0?j(t):e.length===1?d(e[0],t):Dn(e,t)}class gi extends v{}function Lu(e){return e.replace(/\\\$/g,"$").replace(/\\\*/g,"*").replace(/\\\^/g,"^").replace(/\\\|/g,"|").replace(/\\\(/g,"(").replace(/\\\)/g,")")}function Ii(e,t,r){return e[t]===r&&e.charCodeAt(t-1)!==92}function vt(e,t){return Ii(e,t,"(")}function vn(e,t){return Ii(e,t,")")}function bs(e,t){return Ii(e,t,"|")}function Bu(e){if(!(vt(e,0)&&vn(e,e.length-1)))return!1;let t=0;for(let r=0;r<e.length;r++){if(vt(e,r))t+=1;if(vn(e,r))t-=1;if(t===0&&r!==e.length-1)return!1}return!0}function Gu(e){return e.slice(1,e.length-1)}function Du(e){let t=0;for(let r=0;r<e.length;r++){if(vt(e,r))t+=1;if(vn(e,r))t-=1;if(bs(e,r)&&t===0)return!0}return!1}function vu(e){for(let t=0;t<e.length;t++)if(vt(e,t))return!0;return!1}function qu(e){let[t,r]=[0,0],n=[];for(let i=0;i<e.length;i++){if(vt(e,i))t+=1;if(vn(e,i))t-=1;if(bs(e,i)&&t===0){let s=e.slice(r,i);if(s.length>0)n.push(Zr(s));r=i+1}}let o=e.slice(r);if(o.length>0)n.push(Zr(o));if(n.length===0)return{type:"const",const:""};if(n.length===1)return n[0];return{type:"or",expr:n}}function Vu(e){function t(o,i){if(!vt(o,i))throw new gi("TemplateLiteralParser: Index must point to open parens");let s=0;for(let a=i;a<o.length;a++){if(vt(o,a))s+=1;if(vn(o,a))s-=1;if(s===0)return[i,a]}throw new gi("TemplateLiteralParser: Unclosed group parens in expression")}function r(o,i){for(let s=i;s<o.length;s++)if(vt(o,s))return[i,s];return[i,o.length]}let n=[];for(let o=0;o<e.length;o++)if(vt(e,o)){let[i,s]=t(e,o),a=e.slice(i,s+1);n.push(Zr(a)),o=s}else{let[i,s]=r(e,o),a=e.slice(i,s);if(a.length>0)n.push(Zr(a));o=s-1}return n.length===0?{type:"const",const:""}:n.length===1?n[0]:{type:"and",expr:n}}function Zr(e){return Bu(e)?Zr(Gu(e)):Du(e)?qu(e):vu(e)?Vu(e):{type:"const",const:Lu(e)}}function en(e){return Zr(e.slice(1,e.length-1))}class _s extends v{}function Hu(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 zu(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 Wu(e){return e.type==="const"&&e.const===".*"}function kr(e){return Hu(e)||Wu(e)?!1:zu(e)?!0:e.type==="and"?e.expr.every((t)=>kr(t)):e.type==="or"?e.expr.every((t)=>kr(t)):e.type==="const"?!0:(()=>{throw new _s("Unknown expression type")})()}function Os(e){let t=en(e.pattern);return kr(t)}class $s extends v{}function*Fs(e){if(e.length===1)return yield*e[0];for(let t of e[0])for(let r of Fs(e.slice(1)))yield`${t}${r}`}function*Ju(e){return yield*Fs(e.expr.map((t)=>[...qn(t)]))}function*Yu(e){for(let t of e.expr)yield*qn(t)}function*Qu(e){return yield e.const}function*qn(e){return e.type==="and"?yield*Ju(e):e.type==="or"?yield*Yu(e):e.type==="const"?yield*Qu(e):(()=>{throw new $s("Unknown expression")})()}function No(e){let t=en(e.pattern);return kr(t)?[...qn(t)]:[]}function q(e,t){return d({[y]:"Literal",const:e,type:typeof e},t)}function Po(e){return d({[y]:"Boolean",type:"boolean"},e)}function tn(e){return d({[y]:"BigInt",type:"bigint"},e)}function Ze(e){return d({[y]:"Number",type:"number"},e)}function It(e){return d({[y]:"String",type:"string"},e)}function*Xu(e){let t=e.trim().replace(/"|'/g,"");return t==="boolean"?yield Po():t==="number"?yield Ze():t==="bigint"?yield tn():t==="string"?yield It():yield(()=>{let r=t.split("|").map((n)=>q(n.trim()));return r.length===0?j():r.length===1?r[0]:Ct(r)})()}function*Zu(e){if(e[1]!=="{"){let t=q("$"),r=hi(e.slice(1));return yield*[t,...r]}for(let t=2;t<e.length;t++)if(e[t]==="}"){let r=Xu(e.slice(2,t)),n=hi(e.slice(t+1));return yield*[...r,...n]}yield q(e)}function*hi(e){for(let t=0;t<e.length;t++)if(e[t]==="$"){let r=q(e.slice(0,t)),n=Zu(e.slice(t));return yield*[r,...n]}yield q(e)}function ws(e){return[...hi(e)]}class Rs extends v{}function ef(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Ts(e,t){return Je(e)?e.pattern.slice(1,e.pattern.length-1):B(e)?`(${e.anyOf.map((r)=>Ts(r,t)).join("|")})`:lt(e)?`${t}${To}`:pt(e)?`${t}${To}`:_r(e)?`${t}${To}`:Et(e)?`${t}${fs}`:ze(e)?`${t}${ef(e.const.toString())}`:Kt(e)?`${t}${us}`:(()=>{throw new Rs(`Unexpected Kind '${e[y]}'`)})()}function bi(e){return`^${e.map((t)=>Ts(t,"")).join("")}$`}function Nr(e){let r=No(e).map((n)=>q(n));return Ct(r)}function Co(e,t){let r=X(e)?bi(ws(e)):bi(e);return d({[y]:"TemplateLiteral",type:"string",pattern:r},t)}function tf(e){return No(e).map((r)=>r.toString())}function rf(e){let t=[];for(let r of e)t.push(...Be(r));return t}function nf(e){return[e.toString()]}function Be(e){return[...new Set(Je(e)?tf(e):B(e)?rf(e.anyOf):ze(e)?nf(e.const):lt(e)?["[number]"]:pt(e)?["[number]"]:[])]}function of(e,t,r){let n={};for(let o of Object.getOwnPropertyNames(t))n[o]=ir(e,Be(t[o]),r);return n}function sf(e,t,r){return of(e,t.properties,r)}function As(e,t,r){let n=sf(e,t,r);return G(n)}function Ns(e,t){return e.map((r)=>Ps(r,t))}function af(e){return e.filter((t)=>!Zt(t))}function cf(e,t){return jo(af(Ns(e,t)))}function uf(e){return e.some((t)=>Zt(t))?[]:e}function ff(e,t){return Ct(uf(Ns(e,t)))}function mf(e,t){return t in e?e[t]:t==="[number]"?Ct(e):j()}function df(e,t){return t==="[number]"?e:j()}function pf(e,t){return t in e?e[t]:j()}function Ps(e,t){return ue(e)?cf(e.allOf,t):B(e)?ff(e.anyOf,t):Ye(e)?mf(e.items??[],t):ut(e)?df(e.items,t):le(e)?pf(e.properties,t):j()}function Vn(e,t){return t.map((r)=>Ps(e,r))}function ks(e,t){return Ct(Vn(e,t))}function ir(e,t,r){if(pe(e)||pe(t)){if(!se(e)||!se(t))throw new v("Index types using Ref parameters require both Type and Key to be of TSchema");return te("Index",[e,t])}if(oe(t))return As(e,t,r);if(We(t))return Cs(e,t,r);return d(se(t)?ks(e,Be(t)):ks(e,t),r)}function lf(e,t,r){return{[t]:ir(e,[t],ne(r))}}function yf(e,t,r){return t.reduce((n,o)=>({...n,...lf(e,o,r)}),{})}function xf(e,t,r){return yf(e,t.keys,r)}function Cs(e,t,r){let n=xf(e,t,r);return G(n)}function rn(e,t){return d({[y]:"Iterator",type:"Iterator",items:e},t)}function gf(e){return globalThis.Object.keys(e).filter((t)=>!Ee(e[t]))}function If(e,t){let r=gf(e),n=r.length>0?{[y]:"Object",type:"object",required:r,properties:e}:{[y]:"Object",type:"object",properties:e};return d(n,t)}var z=If;function Mo(e,t){return d({[y]:"Promise",type:"Promise",item:e},t)}function hf(e){return d(me(e,[kt]))}function bf(e){return d({...e,[kt]:"Readonly"})}function _f(e,t){return t===!1?hf(e):bf(e)}function Ge(e,t){let r=t??!0;return oe(e)?js(e,r):_f(e,r)}function Of(e,t){let r={};for(let n of globalThis.Object.getOwnPropertyNames(e))r[n]=Ge(e[n],t);return r}function $f(e,t){return Of(e.properties,t)}function js(e,t){let r=$f(e,t);return G(r)}function et(e,t){return d(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 Ms(e,t){return e in t?tt(e,t[e]):G(t)}function Ff(e){return{[e]:q(e)}}function wf(e){let t={};for(let r of e)t[r]=q(r);return t}function Rf(e,t){return ls(t,e)?Ff(e):wf(t)}function Tf(e,t){let r=Rf(e,t);return Ms(e,r)}function Hn(e,t){return t.map((r)=>tt(e,r))}function Af(e,t){let r={};for(let n of globalThis.Object.getOwnPropertyNames(t))r[n]=tt(e,t[n]);return r}function tt(e,t){let r={...t};return Ee(t)?Ne(tt(e,me(t,[Re]))):Wr(t)?Ge(tt(e,me(t,[kt]))):oe(t)?Ms(e,t.properties):We(t)?Tf(e,t.keys):mt(t)?Xr(Hn(e,t.parameters),tt(e,t.returns),r):dt(t)?Pt(Hn(e,t.parameters),tt(e,t.returns),r):br(t)?Qr(tt(e,t.items),r):Or(t)?rn(tt(e,t.items),r):ue(t)?Pe(Hn(e,t.allOf),r):B(t)?V(Hn(e,t.anyOf),r):Ye(t)?et(Hn(e,t.items??[]),r):le(t)?z(Af(e,t.properties),r):ut(t)?Yr(tt(e,t.items),r):$r(t)?Mo(tt(e,t.item),r):t}function kf(e,t){let r={};for(let n of e)r[n]=tt(n,t);return r}function Ss(e,t,r){let n=se(e)?Be(e):e,o=t({[y]:"MappedKey",keys:n}),i=kf(n,o);return z(i,r)}function Nf(e){return d(me(e,[Re]))}function Pf(e){return d({...e,[Re]:"Optional"})}function Cf(e,t){return t===!1?Nf(e):Pf(e)}function Ne(e,t){let r=t??!0;return oe(e)?Us(e,r):Cf(e,r)}function jf(e,t){let r={};for(let n of globalThis.Object.getOwnPropertyNames(e))r[n]=Ne(e[n],t);return r}function Mf(e,t){return jf(e.properties,t)}function Us(e,t){let r=Mf(e,t);return G(r)}function zn(e,t={}){let r=e.every((o)=>le(o)),n=se(t.unevaluatedProperties)?{unevaluatedProperties:t.unevaluatedProperties}:{};return d(t.unevaluatedProperties===!1||se(t.unevaluatedProperties)||r?{...n,[y]:"Intersect",type:"object",allOf:e}:{...n,[y]:"Intersect",allOf:e},t)}function Sf(e){return e.every((t)=>Ee(t))}function Uf(e){return me(e,[Re])}function Ks(e){return e.map((t)=>Ee(t)?Uf(t):t)}function Kf(e,t){return Sf(e)?Ne(zn(Ks(e),t)):zn(Ks(e),t)}function jo(e,t={}){if(e.length===1)return d(e[0],t);if(e.length===0)return j(t);if(e.some((r)=>D(r)))throw Error("Cannot intersect transform types");return Kf(e,t)}function Pe(e,t){if(e.length===1)return d(e[0],t);if(e.length===0)return j(t);if(e.some((r)=>D(r)))throw Error("Cannot intersect transform types");return zn(e,t)}function rt(...e){let[t,r]=typeof e[0]==="string"?[e[0],e[1]]:[e[0].$id,e[1]];if(typeof t!=="string")throw new v("Ref: $ref must be a string");return d({[y]:"Ref",$ref:t},r)}function Ef(e,t){return te("Awaited",[te(e,t)])}function Lf(e){return te("Awaited",[rt(e)])}function Bf(e){return Pe(Es(e))}function Gf(e){return V(Es(e))}function Df(e){return nn(e)}function Es(e){return e.map((t)=>nn(t))}function nn(e,t){return d(ft(e)?Ef(e.target,e.parameters):ue(e)?Bf(e.allOf):B(e)?Gf(e.anyOf):$r(e)?Df(e.item):pe(e)?Lf(e.$ref):e,t)}function Ls(e){let t=[];for(let r of e)t.push(nt(r));return t}function vf(e){let t=Ls(e);return gs(t)}function qf(e){let t=Ls(e);return xs(t)}function Vf(e){return e.map((t,r)=>r.toString())}function Hf(e){return["[number]"]}function zf(e){return globalThis.Object.getOwnPropertyNames(e)}function Wf(e){if(!_i)return[];return globalThis.Object.getOwnPropertyNames(e).map((r)=>r[0]==="^"&&r[r.length-1]==="$"?r.slice(1,r.length-1):r)}function nt(e){return ue(e)?vf(e.allOf):B(e)?qf(e.anyOf):Ye(e)?Vf(e.items??[]):ut(e)?Hf(e.items):le(e)?zf(e.properties):Fr(e)?Wf(e.patternProperties):[]}var _i=!1;function qt(e){_i=!0;let t=nt(e);return _i=!1,`^(${t.map((n)=>`(${n})`).join("|")})$`}function Jf(e,t){return te("KeyOf",[te(e,t)])}function Yf(e){return te("KeyOf",[rt(e)])}function Qf(e,t){let r=nt(e),n=Xf(r),o=Ct(n);return d(o,t)}function Xf(e){return e.map((t)=>t==="[number]"?Ze():q(t))}function on(e,t){return ft(e)?Jf(e.target,e.parameters):pe(e)?Yf(e.$ref):oe(e)?Bs(e,t):Qf(e,t)}function Zf(e,t){let r={};for(let n of globalThis.Object.getOwnPropertyNames(e))r[n]=on(e[n],ne(t));return r}function em(e,t){return Zf(e.properties,t)}function Bs(e,t){let r=em(e,t);return G(r)}function So(e){let t=nt(e),r=Vn(e,t);return t.map((n,o)=>[t[o],r[o]])}function tm(e){let t=[];for(let r of e)t.push(...nt(r));return ys(t)}function rm(e){return e.filter((t)=>!Zt(t))}function nm(e,t){let r=[];for(let n of e)r.push(...Vn(n,[t]));return rm(r)}function om(e,t){let r={};for(let n of t)r[n]=jo(nm(e,n));return r}function Gs(e,t){let r=tm(e),n=om(e,r);return z(n,t)}function Uo(e){return d({[y]:"Date",type:"Date"},e)}function Ko(e){return d({[y]:"Null",type:"null"},e)}function Eo(e){return d({[y]:"Symbol",type:"symbol"},e)}function Lo(e){return d({[y]:"Undefined",type:"undefined"},e)}function Bo(e){return d({[y]:"Uint8Array",type:"Uint8Array"},e)}function sr(e){return d({[y]:"Unknown"},e)}function im(e){return e.map((t)=>Oi(t,!1))}function sm(e){let t={};for(let r of globalThis.Object.getOwnPropertyNames(e))t[r]=Ge(Oi(e[r],!1));return t}function Go(e,t){return t===!0?e:Ge(e)}function Oi(e,t){return Yi(e)?Go(or(),t):Xi(e)?Go(or(),t):ye(e)?Ge(et(im(e))):Xt(e)?Bo():qr(e)?Uo():re(e)?Go(z(sm(e)),t):Qi(e)?Go(Pt([],sr()),t):Z(e)?Lo():Zi(e)?Ko():es(e)?Eo():co(e)?tn():Ve(e)?q(e):Qt(e)?q(e):X(e)?q(e):z({})}function Ds(e,t){return d(Oi(e,!0),t)}function vs(e,t){return mt(e)?et(e.parameters,t):j(t)}function qs(e,t){if(Z(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)=>q(i));return V(o,{...t,[Nt]:"Enum"})}class Js extends v{}var p;(function(e){e[e.Union=0]="Union",e[e.True=1]="True",e[e.False=2]="False"})(p||(p={}));function ot(e){return e===p.False?e:p.True}function sn(e){throw new Js(e)}function ge(e){return tr(e)||Tr(e)||Dt(e)||gt(e)||yt(e)}function Ie(e,t){return tr(t)?Xs(e,t):Tr(t)?Do(e,t):Dt(t)?Ti(e,t):gt(t)?ra(e,t):yt(t)?Ri(e,t):sn("StructuralRight")}function Ri(e,t){return p.True}function am(e,t){return Tr(t)?Do(e,t):Dt(t)&&t.anyOf.some((r)=>yt(r)||gt(r))?p.True:Dt(t)?p.Union:gt(t)?p.True:yt(t)?p.True:p.Union}function cm(e,t){return gt(e)?p.False:yt(e)?p.Union:tr(e)?p.True:p.False}function um(e,t){return fe(t)&&vo(t)?p.True:ge(t)?Ie(e,t):!wr(t)?p.False:ot(W(e.items,t.items))}function fm(e,t){return ge(t)?Ie(e,t):!fi(t)?p.False:ot(W(e.items,t.items))}function mm(e,t){return ge(t)?Ie(e,t):fe(t)?Ce(e,t):Te(t)?it(e,t):_o(t)?p.True:p.False}function Ys(e,t){return as(e)?p.True:Rr(e)?p.True:p.False}function dm(e,t){return ge(t)?Ie(e,t):fe(t)?Ce(e,t):Te(t)?it(e,t):Rr(t)?p.True:p.False}function pm(e,t){return ge(t)?Ie(e,t):fe(t)?Ce(e,t):!Oo(t)?p.False:e.parameters.length>t.parameters.length?p.False:!e.parameters.every((r,n)=>ot(W(t.parameters[n],r))===p.True)?p.False:ot(W(e.returns,t.returns))}function lm(e,t){return ge(t)?Ie(e,t):fe(t)?Ce(e,t):Te(t)?it(e,t):$o(t)?p.True:p.False}function ym(e,t){return ge(t)?Ie(e,t):fe(t)?Ce(e,t):!Fo(t)?p.False:e.parameters.length>t.parameters.length?p.False:!e.parameters.every((r,n)=>ot(W(t.parameters[n],r))===p.True)?p.False:ot(W(e.returns,t.returns))}function Qs(e,t){return er(e)&&Ve(e.const)?p.True:Le(e)||Gt(e)?p.True:p.False}function xm(e,t){return Gt(t)||Le(t)?p.True:ge(t)?Ie(e,t):fe(t)?Ce(e,t):Te(t)?it(e,t):p.False}function Do(e,t){return t.allOf.every((r)=>W(e,r)===p.True)?p.True:p.False}function gm(e,t){return e.allOf.some((r)=>W(r,t)===p.True)?p.True:p.False}function Im(e,t){return ge(t)?Ie(e,t):!mi(t)?p.False:ot(W(e.items,t.items))}function hm(e,t){return er(t)&&t.const===e.const?p.True:ge(t)?Ie(e,t):fe(t)?Ce(e,t):Te(t)?it(e,t):xt(t)?ta(e,t):Le(t)?Zs(e,t):Gt(t)?Qs(e,t):Rr(t)?Ys(e,t):p.False}function Xs(e,t){return p.False}function bm(e,t){return p.True}function Vs(e){let[t,r]=[e,0];while(!0){if(!Jr(t))break;t=t.not,r+=1}return r%2===0?t:sr()}function _m(e,t){return Jr(e)?W(Vs(e),t):Jr(t)?W(e,Vs(t)):sn("Invalid fallthrough for Not")}function Om(e,t){return ge(t)?Ie(e,t):fe(t)?Ce(e,t):Te(t)?it(e,t):di(t)?p.True:p.False}function Zs(e,t){return ss(e)?p.True:Le(e)||Gt(e)?p.True:p.False}function $m(e,t){return ge(t)?Ie(e,t):fe(t)?Ce(e,t):Te(t)?it(e,t):Gt(t)||Le(t)?p.True:p.False}function De(e,t){return Object.getOwnPropertyNames(e.properties).length===t}function Hs(e){return vo(e)}function zs(e){return De(e,0)||De(e,1)&&"description"in e.properties&&Dt(e.properties.description)&&e.properties.description.anyOf.length===2&&(xt(e.properties.description.anyOf[0])&&Ar(e.properties.description.anyOf[1])||xt(e.properties.description.anyOf[1])&&Ar(e.properties.description.anyOf[0]))}function $i(e){return De(e,0)}function Ws(e){return De(e,0)}function Fm(e){return De(e,0)}function wm(e){return De(e,0)}function Rm(e){return vo(e)}function Tm(e){let t=Ze();return De(e,0)||De(e,1)&&"length"in e.properties&&ot(W(e.properties.length,t))===p.True}function Am(e){return De(e,0)}function vo(e){let t=Ze();return De(e,0)||De(e,1)&&"length"in e.properties&&ot(W(e.properties.length,t))===p.True}function km(e){let t=Pt([or()],or());return De(e,0)||De(e,1)&&"then"in e.properties&&ot(W(e.properties.then,t))===p.True}function ea(e,t){return W(e,t)===p.False?p.False:bo(e)&&!bo(t)?p.False:p.True}function Ce(e,t){return gt(e)?p.False:yt(e)?p.Union:tr(e)||is(e)&&Hs(t)||ss(e)&&$i(t)||as(e)&&Ws(t)||En(e)&&zs(t)||_o(e)&&Fm(t)||xt(e)&&Hs(t)||En(e)&&zs(t)||Le(e)&&$i(t)||Gt(e)&&$i(t)||Rr(e)&&Ws(t)||Bn(e)&&Rm(t)||$o(e)&&wm(t)||Oo(e)&&Am(t)||Fo(e)&&Tm(t)?p.True:Te(e)&&xt(Fi(e))?(()=>t[Nt]==="Record"?p.True:p.False)():Te(e)&&Le(Fi(e))?(()=>De(t,0)?p.True:p.False)():p.False}function Nm(e,t){return ge(t)?Ie(e,t):Te(t)?it(e,t):!fe(t)?p.False:(()=>{for(let r of Object.getOwnPropertyNames(t.properties)){if(!(r in e.properties)&&!bo(t.properties[r]))return p.False;if(bo(t.properties[r]))return p.True;if(ea(e.properties[r],t.properties[r])===p.False)return p.False}return p.True})()}function Pm(e,t){return ge(t)?Ie(e,t):fe(t)&&km(t)?p.True:!pi(t)?p.False:ot(W(e.item,t.item))}function Fi(e){return rr in e.patternProperties?Ze():(nr in e.patternProperties)?It():sn("Unknown record key pattern")}function wi(e){return rr in e.patternProperties?e.patternProperties[rr]:(nr in e.patternProperties)?e.patternProperties[nr]:sn("Unable to get record value schema")}function it(e,t){let[r,n]=[Fi(t),wi(t)];return is(e)&&Le(r)&&ot(W(e,n))===p.True?p.True:Bn(e)&&Le(r)?W(e,n):xt(e)&&Le(r)?W(e,n):wr(e)&&Le(r)?W(e,n):fe(e)?(()=>{for(let o of Object.getOwnPropertyNames(e.properties))if(ea(n,e.properties[o])===p.False)return p.False;return p.True})():p.False}function Cm(e,t){return ge(t)?Ie(e,t):fe(t)?Ce(e,t):!Te(t)?p.False:W(wi(e),wi(t))}function jm(e,t){let r=Kn(e)?It():e,n=Kn(t)?It():t;return W(r,n)}function ta(e,t){return er(e)&&X(e.const)?p.True:xt(e)?p.True:p.False}function Mm(e,t){return ge(t)?Ie(e,t):fe(t)?Ce(e,t):Te(t)?it(e,t):xt(t)?p.True:p.False}function Sm(e,t){return ge(t)?Ie(e,t):fe(t)?Ce(e,t):Te(t)?it(e,t):En(t)?p.True:p.False}function Um(e,t){return Ln(e)?W(Nr(e),t):Ln(t)?W(e,Nr(t)):sn("Invalid fallthrough for TemplateLiteral")}function Km(e,t){return wr(t)&&e.items!==void 0&&e.items.every((r)=>W(r,t.items)===p.True)}function Em(e,t){return tr(e)?p.True:gt(e)?p.False:yt(e)?p.Union:p.False}function Lm(e,t){return ge(t)?Ie(e,t):fe(t)&&vo(t)?p.True:wr(t)&&Km(e,t)?p.True:!wo(t)?p.False:Z(e.items)&&!Z(t.items)||!Z(e.items)&&Z(t.items)?p.False:Z(e.items)&&!Z(t.items)?p.True:e.items.every((r,n)=>W(r,t.items[n])===p.True)?p.True:p.False}function Bm(e,t){return ge(t)?Ie(e,t):fe(t)?Ce(e,t):Te(t)?it(e,t):Bn(t)?p.True:p.False}function Gm(e,t){return ge(t)?Ie(e,t):fe(t)?Ce(e,t):Te(t)?it(e,t):Ro(t)?qm(e,t):Ar(t)?p.True:p.False}function Ti(e,t){return t.anyOf.some((r)=>W(e,r)===p.True)?p.True:p.False}function Dm(e,t){return e.anyOf.every((r)=>W(r,t)===p.True)?p.True:p.False}function ra(e,t){return p.True}function vm(e,t){return tr(t)?Xs(e,t):Tr(t)?Do(e,t):Dt(t)?Ti(e,t):yt(t)?Ri(e,t):xt(t)?ta(e,t):Le(t)?Zs(e,t):Gt(t)?Qs(e,t):Rr(t)?Ys(e,t):wr(t)?cm(e,t):wo(t)?Em(e,t):fe(t)?Ce(e,t):gt(t)?p.True:p.False}function qm(e,t){return Ar(e)?p.True:Ar(e)?p.True:p.False}function Vm(e,t){return Tr(t)?Do(e,t):Dt(t)?Ti(e,t):gt(t)?ra(e,t):yt(t)?Ri(e,t):fe(t)?Ce(e,t):Ro(t)?p.True:p.False}function W(e,t){return Ln(e)||Ln(t)?Um(e,t):Kn(e)||Kn(t)?jm(e,t):Jr(e)||Jr(t)?_m(e,t):yt(e)?am(e,t):wr(e)?um(e,t):_o(e)?mm(e,t):Rr(e)?dm(e,t):fi(e)?fm(e,t):Oo(e)?pm(e,t):$o(e)?lm(e,t):Fo(e)?ym(e,t):Gt(e)?xm(e,t):Tr(e)?gm(e,t):mi(e)?Im(e,t):er(e)?hm(e,t):tr(e)?bm(e,t):di(e)?Om(e,t):Le(e)?$m(e,t):fe(e)?Nm(e,t):Te(e)?Cm(e,t):xt(e)?Mm(e,t):En(e)?Sm(e,t):wo(e)?Lm(e,t):pi(e)?Pm(e,t):Bn(e)?Bm(e,t):Ar(e)?Gm(e,t):Dt(e)?Dm(e,t):gt(e)?vm(e,t):Ro(e)?Vm(e,t):sn(`Unknown left type operand '${e[y]}'`)}function ar(e,t){return W(e,t)}function Hm(e,t,r,n,o){let i={};for(let s of globalThis.Object.getOwnPropertyNames(e))i[s]=an(e[s],t,r,n,ne(o));return i}function zm(e,t,r,n,o){return Hm(e.properties,t,r,n,o)}function na(e,t,r,n,o){let i=zm(e,t,r,n,o);return G(i)}function Wm(e,t,r,n){let o=ar(e,t);return o===p.Union?V([r,n]):o===p.True?r:n}function an(e,t,r,n,o){return oe(e)?na(e,t,r,n,o):We(e)?d(oa(e,t,r,n,o)):d(Wm(e,t,r,n),o)}function Jm(e,t,r,n,o){return{[e]:an(q(e),t,r,n,ne(o))}}function Ym(e,t,r,n,o){return e.reduce((i,s)=>({...i,...Jm(s,t,r,n,o)}),{})}function Qm(e,t,r,n,o){return Ym(e.keys,t,r,n,o)}function oa(e,t,r,n,o){let i=Qm(e,t,r,n,o);return G(i)}function Xm(e){return e.allOf.every((t)=>Vt(t))}function Zm(e){return e.anyOf.some((t)=>Vt(t))}function ed(e){return!Vt(e.not)}function Vt(e){return e[y]==="Intersect"?Xm(e):e[y]==="Union"?Zm(e):e[y]==="Not"?ed(e):e[y]==="Undefined"?!0:!1}function ia(e,t){return cn(Nr(e),t)}function td(e,t){let r=e.filter((n)=>ar(n,t)===p.False);return r.length===1?r[0]:V(r)}function cn(e,t,r={}){if(Je(e))return d(ia(e,t),r);if(oe(e))return d(sa(e,t),r);return d(B(e)?td(e.anyOf,t):ar(e,t)!==p.False?j():e,r)}function rd(e,t){let r={};for(let n of globalThis.Object.getOwnPropertyNames(e))r[n]=cn(e[n],t);return r}function nd(e,t){return rd(e.properties,t)}function sa(e,t){let r=nd(e,t);return G(r)}function aa(e,t){return un(Nr(e),t)}function od(e,t){let r=e.filter((n)=>ar(n,t)!==p.False);return r.length===1?r[0]:V(r)}function un(e,t,r){if(Je(e))return d(aa(e,t),r);if(oe(e))return d(ca(e,t),r);return d(B(e)?od(e.anyOf,t):ar(e,t)!==p.False?e:j(),r)}function id(e,t){let r={};for(let n of globalThis.Object.getOwnPropertyNames(e))r[n]=un(e[n],t);return r}function sd(e,t){return id(e.properties,t)}function ca(e,t){let r=sd(e,t);return G(r)}function ua(e,t){return mt(e)?d(e.returns,t):j(t)}function qo(e){return Ge(Ne(e))}function Pr(e,t,r){return d({[y]:"Record",type:"object",patternProperties:{[e]:t}},r)}function Ai(e,t,r){let n={};for(let o of e)n[o]=t;return z(n,{...r,[Nt]:"Record"})}function ad(e,t,r){return Os(e)?Ai(Be(e),t,r):Pr(e.pattern,t,r)}function cd(e,t,r){return Ai(Be(V(e)),t,r)}function ud(e,t,r){return Ai([e.toString()],t,r)}function fd(e,t,r){return Pr(e.source,t,r)}function md(e,t,r){let n=Z(e.pattern)?nr:e.pattern;return Pr(n,t,r)}function dd(e,t,r){return Pr(nr,t,r)}function pd(e,t,r){return Pr(ms,t,r)}function ld(e,t,r){return z({true:t,false:t},r)}function yd(e,t,r){return Pr(rr,t,r)}function xd(e,t,r){return Pr(rr,t,r)}function Vo(e,t,r={}){return B(e)?cd(e.anyOf,t,r):Je(e)?ad(e,t,r):ze(e)?ud(e.const,t,r):Kt(e)?ld(e,t,r):pt(e)?yd(e,t,r):lt(e)?xd(e,t,r):ai(e)?fd(e,t,r):Et(e)?md(e,t,r):ii(e)?dd(e,t,r):Zt(e)?pd(e,t,r):j(r)}function Ho(e){return globalThis.Object.getOwnPropertyNames(e.patternProperties)[0]}function fa(e){let t=Ho(e);return t===nr?It():t===rr?Ze():It({pattern:t})}function zo(e){return e.patternProperties[Ho(e)]}function gd(e,t){return t.parameters=Wn(e,t.parameters),t.returns=ht(e,t.returns),t}function Id(e,t){return t.parameters=Wn(e,t.parameters),t.returns=ht(e,t.returns),t}function hd(e,t){return t.allOf=Wn(e,t.allOf),t}function bd(e,t){return t.anyOf=Wn(e,t.anyOf),t}function _d(e,t){if(Z(t.items))return t;return t.items=Wn(e,t.items),t}function Od(e,t){return t.items=ht(e,t.items),t}function $d(e,t){return t.items=ht(e,t.items),t}function Fd(e,t){return t.items=ht(e,t.items),t}function wd(e,t){return t.item=ht(e,t.item),t}function Rd(e,t){let r=Nd(e,t.properties);return{...t,...z(r)}}function Td(e,t){let r=ht(e,fa(t)),n=ht(e,zo(t)),o=Vo(r,n);return{...t,...o}}function Ad(e,t){return t.index in e?e[t.index]:sr()}function kd(e,t){let r=Wr(t),n=Ee(t),o=ht(e,t);return r&&n?qo(o):r&&!n?Ge(o):!r&&n?Ne(o):o}function Nd(e,t){return globalThis.Object.getOwnPropertyNames(t).reduce((r,n)=>({...r,[n]:kd(e,t[n])}),{})}function Wn(e,t){return t.map((r)=>ht(e,r))}function ht(e,t){return mt(t)?gd(e,t):dt(t)?Id(e,t):ue(t)?hd(e,t):B(t)?bd(e,t):Ye(t)?_d(e,t):ut(t)?Od(e,t):br(t)?$d(e,t):Or(t)?Fd(e,t):$r(t)?wd(e,t):le(t)?Rd(e,t):Fr(t)?Td(e,t):si(t)?Ad(e,t):t}function ma(e,t){return ht(t,Vr(e))}function da(e){return d({[y]:"Integer",type:"integer"},e)}function Pd(e,t,r){return{[e]:bt(q(e),t,ne(r))}}function Cd(e,t,r){return e.reduce((o,i)=>({...o,...Pd(i,t,r)}),{})}function jd(e,t,r){return Cd(e.keys,t,r)}function pa(e,t,r){let n=jd(e,t,r);return G(n)}function Md(e){let[t,r]=[e.slice(0,1),e.slice(1)];return[t.toLowerCase(),r].join("")}function Sd(e){let[t,r]=[e.slice(0,1),e.slice(1)];return[t.toUpperCase(),r].join("")}function Ud(e){return e.toUpperCase()}function Kd(e){return e.toLowerCase()}function Ed(e,t,r){let n=en(e.pattern);if(!kr(n))return{...e,pattern:la(e.pattern,t)};let s=[...qn(n)].map((l)=>q(l)),a=ya(s,t),f=V(a);return Co([f],r)}function la(e,t){return typeof e==="string"?t==="Uncapitalize"?Md(e):t==="Capitalize"?Sd(e):t==="Uppercase"?Ud(e):t==="Lowercase"?Kd(e):e:e.toString()}function ya(e,t){return e.map((r)=>bt(r,t))}function bt(e,t,r={}){return We(e)?pa(e,t,r):Je(e)?Ed(e,t,r):B(e)?V(ya(e.anyOf,t),r):ze(e)?q(la(e.const,t),r):d(e,r)}function xa(e,t={}){return bt(e,"Capitalize",t)}function ga(e,t={}){return bt(e,"Lowercase",t)}function Ia(e,t={}){return bt(e,"Uncapitalize",t)}function ha(e,t={}){return bt(e,"Uppercase",t)}function Ld(e,t,r){let n={};for(let o of globalThis.Object.getOwnPropertyNames(e))n[o]=cr(e[o],t,ne(r));return n}function Bd(e,t,r){return Ld(e.properties,t,r)}function ba(e,t,r){let n=Bd(e,t,r);return G(n)}function Gd(e,t){return e.map((r)=>ki(r,t))}function Dd(e,t){return e.map((r)=>ki(r,t))}function vd(e,t){let{[t]:r,...n}=e;return n}function qd(e,t){return t.reduce((r,n)=>vd(r,n),e)}function Vd(e,t,r){let n=me(e,[ie,"$id","required","properties"]),o=qd(r,t);return z(o,n)}function Hd(e){let t=e.reduce((r,n)=>ho(n)?[...r,q(n)]:r,[]);return V(t)}function ki(e,t){return ue(e)?Pe(Gd(e.allOf,t)):B(e)?V(Dd(e.anyOf,t)):le(e)?Vd(e,t,e.properties):z({})}function cr(e,t,r){let n=ye(t)?Hd(t):t,o=se(t)?Be(t):t,i=pe(e),s=pe(t);return oe(e)?ba(e,o,r):We(t)?_a(e,t,r):i&&s?te("Omit",[e,n],r):!i&&s?te("Omit",[e,n],r):i&&!s?te("Omit",[e,n],r):d({...ki(e,o),...r})}function zd(e,t,r){return{[t]:cr(e,[t],ne(r))}}function Wd(e,t,r){return t.reduce((n,o)=>({...n,...zd(e,o,r)}),{})}function Jd(e,t,r){return Wd(e,t.keys,r)}function _a(e,t,r){let n=Jd(e,t,r);return G(n)}function Yd(e,t,r){let n={};for(let o of globalThis.Object.getOwnPropertyNames(e))n[o]=ur(e[o],t,ne(r));return n}function Qd(e,t,r){return Yd(e.properties,t,r)}function Oa(e,t,r){let n=Qd(e,t,r);return G(n)}function Xd(e,t){return e.map((r)=>Ni(r,t))}function Zd(e,t){return e.map((r)=>Ni(r,t))}function ep(e,t){let r={};for(let n of t)if(n in e)r[n]=e[n];return r}function tp(e,t,r){let n=me(e,[ie,"$id","required","properties"]),o=ep(r,t);return z(o,n)}function rp(e){let t=e.reduce((r,n)=>ho(n)?[...r,q(n)]:r,[]);return V(t)}function Ni(e,t){return ue(e)?Pe(Xd(e.allOf,t)):B(e)?V(Zd(e.anyOf,t)):le(e)?tp(e,t,e.properties):z({})}function ur(e,t,r){let n=ye(t)?rp(t):t,o=se(t)?Be(t):t,i=pe(e),s=pe(t);return oe(e)?Oa(e,o,r):We(t)?$a(e,t,r):i&&s?te("Pick",[e,n],r):!i&&s?te("Pick",[e,n],r):i&&!s?te("Pick",[e,n],r):d({...Ni(e,o),...r})}function np(e,t,r){return{[t]:ur(e,[t],ne(r))}}function op(e,t,r){return t.reduce((n,o)=>({...n,...np(e,o,r)}),{})}function ip(e,t,r){return op(e,t.keys,r)}function $a(e,t,r){let n=ip(e,t,r);return G(n)}function sp(e,t){return te("Partial",[te(e,t)])}function ap(e){return te("Partial",[rt(e)])}function cp(e){let t={};for(let r of globalThis.Object.getOwnPropertyNames(e))t[r]=Ne(e[r]);return t}function up(e,t){let r=me(e,[ie,"$id","required","properties"]),n=cp(t);return z(n,r)}function Fa(e){return e.map((t)=>wa(t))}function wa(e){return ft(e)?sp(e.target,e.parameters):pe(e)?ap(e.$ref):ue(e)?Pe(Fa(e.allOf)):B(e)?V(Fa(e.anyOf)):le(e)?up(e,e.properties):_r(e)?e:Kt(e)?e:pt(e)?e:ze(e)?e:Mn(e)?e:lt(e)?e:Et(e)?e:Sn(e)?e:Lt(e)?e:z({})}function fn(e,t){if(oe(e))return Ra(e,t);else return d({...wa(e),...t})}function fp(e,t){let r={};for(let n of globalThis.Object.getOwnPropertyNames(e))r[n]=fn(e[n],ne(t));return r}function mp(e,t){return fp(e.properties,t)}function Ra(e,t){let r=mp(e,t);return G(r)}function dp(e,t){return te("Required",[te(e,t)])}function pp(e){return te("Required",[rt(e)])}function lp(e){let t={};for(let r of globalThis.Object.getOwnPropertyNames(e))t[r]=me(e[r],[Re]);return t}function yp(e,t){let r=me(e,[ie,"$id","required","properties"]),n=lp(t);return z(n,r)}function Ta(e){return e.map((t)=>Aa(t))}function Aa(e){return ft(e)?dp(e.target,e.parameters):pe(e)?pp(e.$ref):ue(e)?Pe(Ta(e.allOf)):B(e)?V(Ta(e.anyOf)):le(e)?yp(e,e.properties):_r(e)?e:Kt(e)?e:pt(e)?e:ze(e)?e:Mn(e)?e:lt(e)?e:Et(e)?e:Sn(e)?e:Lt(e)?e:z({})}function mn(e,t){if(oe(e))return ka(e,t);else return d({...Aa(e),...t})}function xp(e,t){let r={};for(let n of globalThis.Object.getOwnPropertyNames(e))r[n]=mn(e[n],t);return r}function gp(e,t){return xp(e.properties,t)}function ka(e,t){let r=gp(e,t);return G(r)}function Ip(e,t){return t.map((r)=>pe(r)?Pi(e,r.$ref):Qe(e,r))}function Pi(e,t){return t in e?pe(e[t])?Pi(e,e[t].$ref):Qe(e,e[t]):j()}function hp(e){return nn(e[0])}function bp(e){return ir(e[0],e[1])}function _p(e){return on(e[0])}function Op(e){return fn(e[0])}function $p(e){return cr(e[0],e[1])}function Fp(e){return ur(e[0],e[1])}function wp(e){return mn(e[0])}function Rp(e,t,r){let n=Ip(e,r);return t==="Awaited"?hp(n):t==="Index"?bp(n):t==="KeyOf"?_p(n):t==="Partial"?Op(n):t==="Omit"?$p(n):t==="Pick"?Fp(n):t==="Required"?wp(n):j()}function Tp(e,t){return Yr(Qe(e,t))}function Ap(e,t){return Qr(Qe(e,t))}function kp(e,t,r){return Xr(Jn(e,t),Qe(e,r))}function Np(e,t,r){return Pt(Jn(e,t),Qe(e,r))}function Pp(e,t){return Pe(Jn(e,t))}function Cp(e,t){return rn(Qe(e,t))}function jp(e,t){return z(globalThis.Object.keys(t).reduce((r,n)=>({...r,[n]:Qe(e,t[n])}),{}))}function Mp(e,t){let[r,n]=[Qe(e,zo(t)),Ho(t)],o=Vr(t);return o.patternProperties[n]=r,o}function Sp(e,t){return pe(t)?{...Pi(e,t.$ref),[ie]:t[ie]}:t}function Up(e,t){return et(Jn(e,t))}function Kp(e,t){return V(Jn(e,t))}function Jn(e,t){return t.map((r)=>Qe(e,r))}function Qe(e,t){return Ee(t)?d(Qe(e,me(t,[Re])),t):Wr(t)?d(Qe(e,me(t,[kt])),t):D(t)?d(Sp(e,t),t):ut(t)?d(Tp(e,t.items),t):br(t)?d(Ap(e,t.items),t):ft(t)?d(Rp(e,t.target,t.parameters)):mt(t)?d(kp(e,t.parameters,t.returns),t):dt(t)?d(Np(e,t.parameters,t.returns),t):ue(t)?d(Pp(e,t.allOf),t):Or(t)?d(Cp(e,t.items),t):le(t)?d(jp(e,t.properties),t):Fr(t)?d(Mp(e,t)):Ye(t)?d(Up(e,t.items||[]),t):B(t)?d(Kp(e,t.anyOf),t):t}function Ep(e,t){return t in e?Qe(e,e[t]):j()}function Na(e){return globalThis.Object.getOwnPropertyNames(e).reduce((t,r)=>({...t,[r]:Ep(e,r)}),{})}class Pa{constructor(e){let t=Na(e),r=this.WithIdentifiers(t);this.$defs=r}Import(e,t){let r={...this.$defs,[e]:d(this.$defs[e],t)};return d({[y]:"Import",$defs:r,$ref:e})}WithIdentifiers(e){return globalThis.Object.getOwnPropertyNames(e).reduce((t,r)=>({...t,[r]:{...e[r],$id:r}}),{})}}function Ca(e){return new Pa(e)}function ja(e,t){return d({[y]:"Not",not:e},t)}function Ma(e,t){return dt(e)?et(e.parameters,t):j()}var Lp=0;function Sa(e,t={}){if(Z(t.$id))t.$id=`T${Lp++}`;let r=Vr(e({[y]:"This",$ref:`${t.$id}`}));return r.$id=t.$id,d({[Nt]:"Recursive",...r},t)}function Ua(e,t){let r=X(e)?new globalThis.RegExp(e):e;return d({[y]:"RegExp",type:"RegExp",source:r.source,flags:r.flags},t)}function Bp(e){return ue(e)?e.allOf:B(e)?e.anyOf:Ye(e)?e.items??[]:[]}function Ka(e){return Bp(e)}function Ea(e,t){return dt(e)?d(e.returns,t):j(t)}class La{constructor(e){this.schema=e}Decode(e){return new Ba(this.schema,e)}}class Ba{constructor(e,t){this.schema=e,this.decode=t}EncodeTransform(e,t){let o={Encode:(i)=>t[ie].Encode(e(i)),Decode:(i)=>this.decode(t[ie].Decode(i))};return{...t,[ie]:o}}EncodeSchema(e,t){let r={Decode:this.decode,Encode:e};return{...t,[ie]:r}}Encode(e){return D(this.schema)?this.EncodeTransform(e,this.schema):this.EncodeSchema(e,this.schema)}}function Ga(e){return new La(e)}function Da(e={}){return d({[y]:e[y]??"Unsafe"},e)}function va(e){return d({[y]:"Void",type:"void"},e)}var Gp=Ci;import{join as vp}from"path";import{readFileSync as qp}from"fs";Jo();import{join as Dp}from"path";async function Va(){let e=Dp(process.cwd(),"bare.config.ts");try{let t=await import(e);return Wo(t.default)}catch{return Wo()}}class Ha extends Dr{tree=new vr;pool=[];hotFetch;compiled=!1;poolMask;_useLog=!1;useLog(e=!0){return this._useLog=e,this}constructor(e=1024){super();Va();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 ao);try{let r=vp(process.cwd(),"package.json"),n=JSON.parse(qp(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}compileHandler(e,t){let r=e.length,n={status:200,headers:{"content-type":"application/json"}},o={status:200,headers:{"content-type":"text/plain"}},a=`
51
+ `;let c=`pL${t}`;i+=`${s}const ${c} = ${r}.slice(${n}, slash${t});
52
+ `;let u=[...o,{name:this.paramName,varName:c}];i+=a.jitCompile(e,t+1,r,`slash${t} + 1`,u)}if(this.wildcardNode&&Object.keys(this.wildcardNode.handlers).length>0){let a=`wL${t}`;i+=`${s}const ${a} = ${r}.slice(${n}, urlLen);
53
+ `;let u=[...o,{name:"*",varName:a}].map((m)=>`${JSON.stringify(m.name)}: ${m.varName}`).join(", ");i+=`${s}ctx.params = { ${u} };
54
+ `,i+=`${s}switch(method) {
55
+ `;for(let[m,g]of Object.entries(this.wildcardNode.handlers)){let I=e(g);i+=`${s} case ${JSON.stringify(m)}: return ${I}(ctx);
56
+ `}i+=`${s}}
57
+ `}return i}id=Math.random().toString(36).slice(2)}import{createHmac as rc,timingSafeEqual as Cy}from"crypto";class Io{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;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 i=t.indexOf("&",n);if(i===-1)i=o;if(i>n){let s=t.indexOf("=",n),a,c;if(s!==-1&&s<i)a=t.slice(n,s),c=t.slice(s+1,i);else a=t.slice(n,i),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=i+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 i=t.indexOf("=",r);if(i!==-1&&i<o){let s=t.slice(r,i).trim(),a=t.slice(i+1,o).trim();try{a=decodeURIComponent(a)}catch{}if(s&&s!=="__proto__"&&s!=="constructor"&&s!=="prototype")e[s]=a}r=o+1}}return this._cookies=e,e}setCookie(e,t,r={}){let n=t;if(r.secret){let i=rc("sha256",r.secret).update(t).digest("base64url");n=`${t}.${i}`}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),i=r.slice(n+1),s=rc("sha256",t).update(o).digest(),a=Buffer.from(i,"base64url");if(a.length!==s.length||!Cy(a,s))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}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=(i)=>{if(typeof i==="string")return t.encode(`data: ${i}
58
+
59
+ `);let s="";if(i.id!==void 0)s+=`id: ${i.id}
60
+ `;if(i.event!==void 0)s+=`event: ${i.event}
61
+ `;if(i.retry!==void 0)s+=`retry: ${i.retry}
62
+ `;let a=typeof i.data==="string"?i.data:JSON.stringify(i.data);return s+=`data: ${a}
63
+
64
+ `,t.encode(s)},n=new ReadableStream({async start(i){try{if(typeof e==="function"){let s=!1,a=(u,m,g)=>{if(!s)i.enqueue(r({data:u,event:m,id:g}))},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})}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(){let e=this.req?.headers?.get("x-forwarded-for");if(e)return e.split(",")[0].trim();return this.req?.headers?.get("x-real-ip")||this.req?.headers?.get("cf-connecting-ip")||"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 s=await this.req.formData(),a={},c=[];for(let[u,m]of s.entries()){if(typeof m==="string"){if(u!=="__proto__"&&u!=="constructor"&&u!=="prototype")a[u]=m;continue}let g=m;if(c.length>=r)throw Object.assign(Error(`Too many files (max ${r})`),{status:413});if(g.size>t)throw Object.assign(Error(`File exceeds max size of ${t} bytes`),{status:413});let I=(g.type||"").split(";")[0].trim().toLowerCase();if(n&&!n.has(I))throw Object.assign(Error(`Unsupported file type: ${g.type||"unknown"}`),{status:415});let O=g.name||"file",C=(O.split(/[\\/]/).pop()||"file").replace(/[^a-zA-Z0-9._-]/g,"_").replace(/^\.+/,"")||"file";c.push({fieldName:u,filename:O,safeName:C,type:g.type,size:g.size,file:g})}return{fields:a,files:c}}}function Kn(e,t){return t===void 0?ce(e):ce({...t,...e})}function nc(e){return l({[x]:"Argument",index:e})}function Ty(e,t){return se("Awaited",[se(e,t)])}function Py(e){return se("Awaited",[lt(e)])}function Ny(e){return Ke(oc(e))}function Sy(e){return J(oc(e))}function jy(e){return Bn(e)}function oc(e){return e.map((t)=>Bn(t))}function Bn(e,t){return l($t(e)?Ty(e.target,e.parameters):ge(e)?Ny(e.allOf):v(e)?Sy(e.anyOf):Lr(e)?jy(e.item):Ie(e)?Py(e.$ref):e,t)}function My(e){let t=[];for(let r of e)t.push(...yt(r));return Js(t)}function Uy(e){return e.filter((t)=>!lr(t))}function Ey(e,t){let r=[];for(let n of e)r.push(...ro(n,[t]));return Uy(r)}function Ly(e,t){let r={};for(let n of t)r[n]=Bo(Ey(e,n));return r}function ic(e,t){let r=My(e),n=Ly(e,r);return X(n,t)}function ci(e){return l({[x]:"Date",type:"Date"},e)}function ui(e){return l({[x]:"Null",type:"null"},e)}function fi(e){return l({[x]:"Symbol",type:"symbol"},e)}function di(e){return l({[x]:"Undefined",type:"undefined"},e)}function mi(e){return l({[x]:"Uint8Array",type:"Uint8Array"},e)}function Ky(e){return e.map((t)=>os(t,!1))}function By(e){let t={};for(let r of globalThis.Object.getOwnPropertyNames(e))t[r]=Ye(os(e[r],!1));return t}function pi(e,t){return t===!0?e:Ye(e)}function os(e,t){return Os(e)?pi(Ir(),t):ws(e)?pi(Ir(),t):Oe(e)?Ye(mt(Ky(e))):pr(e)?mi():an(e)?ci():ae(e)?pi(X(By(e)),t):$s(e)?pi(vt([],br()),t):ie(e)?di():Rs(e)?ui():Fs(e)?fi():Uo(e)?ln():ot(e)?W(e):mr(e)?W(e):oe(e)?W(e):X({})}function sc(e,t){return l(os(e,!0),t)}function ac(e,t){return wt(e)?mt(e.parameters,t):E(t)}function cc(e,t){if(ie(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)=>W(i));return J(o,{...t,[qt]:"Enum"})}function uc(e,t){return Dn(Dr(e),t)}function Dy(e,t){let r=e.filter((n)=>$r(n,t)===y.False);return r.length===1?r[0]:J(r)}function Dn(e,t,r={}){if(at(e))return l(uc(e,t),r);if(ue(e))return l(fc(e,t),r);return l(v(e)?Dy(e.anyOf,t):$r(e,t)!==y.False?E():e,r)}function Gy(e,t){let r={};for(let n of globalThis.Object.getOwnPropertyNames(e))r[n]=Dn(e[n],t);return r}function qy(e,t){return Gy(e.properties,t)}function fc(e,t){let r=qy(e,t);return H(r)}function dc(e,t){return Gn(Dr(e),t)}function vy(e,t){let r=e.filter((n)=>$r(n,t)!==y.False);return r.length===1?r[0]:J(r)}function Gn(e,t,r){if(at(e))return l(dc(e,t),r);if(ue(e))return l(mc(e,t),r);return l(v(e)?vy(e.anyOf,t):$r(e,t)!==y.False?e:E(),r)}function Hy(e,t){let r={};for(let n of globalThis.Object.getOwnPropertyNames(e))r[n]=Gn(e[n],t);return r}function Vy(e,t){return Hy(e.properties,t)}function mc(e,t){let r=Vy(e,t);return H(r)}function pc(e,t){return wt(e)?l(e.returns,t):E(t)}function li(e){return Ye(Le(e))}function en(e,t,r){return l({[x]:"Record",type:"object",patternProperties:{[e]:t}},r)}function is(e,t,r){let n={};for(let o of e)n[o]=t;return X(n,{...r,[qt]:"Record"})}function zy(e,t,r){return Ss(e)?is(Je(e),t,r):en(e.pattern,t,r)}function Wy(e,t,r){return is(Je(J(e)),t,r)}function Jy(e,t,r){return is([e.toString()],t,r)}function Yy(e,t,r){return en(e.source,t,r)}function Xy(e,t,r){let n=ie(e.pattern)?gr:e.pattern;return en(n,t,r)}function Qy(e,t,r){return en(gr,t,r)}function Zy(e,t,r){return en(Ks,t,r)}function eg(e,t,r){return X({true:t,false:t},r)}function tg(e,t,r){return en(yr,t,r)}function rg(e,t,r){return en(yr,t,r)}function yi(e,t,r={}){return v(e)?Wy(e.anyOf,t,r):at(e)?zy(e,t,r):it(e)?Jy(e.const,t,r):Xt(e)?eg(e,t,r):Ft(e)?tg(e,t,r):At(e)?rg(e,t,r):Ci(e)?Yy(e,t,r):Qt(e)?Xy(e,t,r):Ai(e)?Qy(e,t,r):lr(e)?Zy(e,t,r):E(r)}function gi(e){return globalThis.Object.getOwnPropertyNames(e.patternProperties)[0]}function lc(e){let t=gi(e);return t===gr?kt():t===yr?dt():kt({pattern:t})}function xi(e){return e.patternProperties[gi(e)]}function ng(e,t){return t.parameters=bo(e,t.parameters),t.returns=Kt(e,t.returns),t}function og(e,t){return t.parameters=bo(e,t.parameters),t.returns=Kt(e,t.returns),t}function ig(e,t){return t.allOf=bo(e,t.allOf),t}function sg(e,t){return t.anyOf=bo(e,t.anyOf),t}function ag(e,t){if(ie(t.items))return t;return t.items=bo(e,t.items),t}function cg(e,t){return t.items=Kt(e,t.items),t}function ug(e,t){return t.items=Kt(e,t.items),t}function fg(e,t){return t.items=Kt(e,t.items),t}function dg(e,t){return t.item=Kt(e,t.item),t}function mg(e,t){let r=gg(e,t.properties);return{...t,...X(r)}}function pg(e,t){let r=Kt(e,lc(t)),n=Kt(e,xi(t)),o=yi(r,n);return{...t,...o}}function lg(e,t){return t.index in e?e[t.index]:br()}function yg(e,t){let r=dn(t),n=We(t),o=Kt(e,t);return r&&n?li(o):r&&!n?Ye(o):!r&&n?Le(o):o}function gg(e,t){return globalThis.Object.getOwnPropertyNames(t).reduce((r,n)=>({...r,[n]:yg(e,t[n])}),{})}function bo(e,t){return t.map((r)=>Kt(e,r))}function Kt(e,t){return wt(t)?ng(e,t):Rt(t)?og(e,t):ge(t)?ig(e,t):v(t)?sg(e,t):ct(t)?ag(e,t):Ot(t)?cg(e,t):Mr(t)?ug(e,t):Er(t)?fg(e,t):Lr(t)?dg(e,t):be(t)?mg(e,t):Kr(t)?pg(e,t):ki(t)?lg(e,t):t}function yc(e,t){return Kt(t,Kn(e))}function gc(e){return l({[x]:"Integer",type:"integer"},e)}function xg(e,t,r){return{[e]:Bt(W(e),t,ce(r))}}function hg(e,t,r){return e.reduce((o,i)=>({...o,...xg(i,t,r)}),{})}function Ig(e,t,r){return hg(e.keys,t,r)}function xc(e,t,r){let n=Ig(e,t,r);return H(n)}function bg(e){let[t,r]=[e.slice(0,1),e.slice(1)];return[t.toLowerCase(),r].join("")}function _g(e){let[t,r]=[e.slice(0,1),e.slice(1)];return[t.toUpperCase(),r].join("")}function Og(e){return e.toUpperCase()}function $g(e){return e.toLowerCase()}function wg(e,t,r){let n=pn(e.pattern);if(!Br(n))return{...e,pattern:hc(e.pattern,t)};let s=[...to(n)].map((u)=>W(u)),a=Ic(s,t),c=J(a);return vo([c],r)}function hc(e,t){return typeof e==="string"?t==="Uncapitalize"?bg(e):t==="Capitalize"?_g(e):t==="Uppercase"?Og(e):t==="Lowercase"?$g(e):e:e.toString()}function Ic(e,t){return e.map((r)=>Bt(r,t))}function Bt(e,t,r={}){return st(e)?xc(e,t,r):at(e)?wg(e,t,r):v(e)?J(Ic(e.anyOf,t),r):it(e)?W(hc(e.const,t),r):l(e,r)}function bc(e,t={}){return Bt(e,"Capitalize",t)}function _c(e,t={}){return Bt(e,"Lowercase",t)}function Oc(e,t={}){return Bt(e,"Uncapitalize",t)}function $c(e,t={}){return Bt(e,"Uppercase",t)}function Rg(e,t,r){let n={};for(let o of globalThis.Object.getOwnPropertyNames(e))n[o]=Cr(e[o],t,ce(r));return n}function Fg(e,t,r){return Rg(e.properties,t,r)}function wc(e,t,r){let n=Fg(e,t,r);return H(n)}function Ag(e,t){return e.map((r)=>ss(r,t))}function kg(e,t){return e.map((r)=>ss(r,t))}function Cg(e,t){let{[t]:r,...n}=e;return n}function Tg(e,t){return t.reduce((r,n)=>Cg(r,n),e)}function Pg(e,t,r){let n=ye(e,[de,"$id","required","properties"]),o=Tg(r,t);return X(o,n)}function Ng(e){let t=e.reduce((r,n)=>Ko(n)?[...r,W(n)]:r,[]);return J(t)}function ss(e,t){return ge(e)?Ke(Ag(e.allOf,t)):v(e)?J(kg(e.anyOf,t)):be(e)?Pg(e,t,e.properties):X({})}function Cr(e,t,r){let n=Oe(t)?Ng(t):t,o=me(t)?Je(t):t,i=Ie(e),s=Ie(t);return ue(e)?wc(e,o,r):st(t)?Rc(e,t,r):i&&s?se("Omit",[e,n],r):!i&&s?se("Omit",[e,n],r):i&&!s?se("Omit",[e,n],r):l({...ss(e,o),...r})}function Sg(e,t,r){return{[t]:Cr(e,[t],ce(r))}}function jg(e,t,r){return t.reduce((n,o)=>({...n,...Sg(e,o,r)}),{})}function Mg(e,t,r){return jg(e,t.keys,r)}function Rc(e,t,r){let n=Mg(e,t,r);return H(n)}function Ug(e,t,r){let n={};for(let o of globalThis.Object.getOwnPropertyNames(e))n[o]=Tr(e[o],t,ce(r));return n}function Eg(e,t,r){return Ug(e.properties,t,r)}function Fc(e,t,r){let n=Eg(e,t,r);return H(n)}function Lg(e,t){return e.map((r)=>as(r,t))}function Kg(e,t){return e.map((r)=>as(r,t))}function Bg(e,t){let r={};for(let n of t)if(n in e)r[n]=e[n];return r}function Dg(e,t,r){let n=ye(e,[de,"$id","required","properties"]),o=Bg(r,t);return X(o,n)}function Gg(e){let t=e.reduce((r,n)=>Ko(n)?[...r,W(n)]:r,[]);return J(t)}function as(e,t){return ge(e)?Ke(Lg(e.allOf,t)):v(e)?J(Kg(e.anyOf,t)):be(e)?Dg(e,t,e.properties):X({})}function Tr(e,t,r){let n=Oe(t)?Gg(t):t,o=me(t)?Je(t):t,i=Ie(e),s=Ie(t);return ue(e)?Fc(e,o,r):st(t)?Ac(e,t,r):i&&s?se("Pick",[e,n],r):!i&&s?se("Pick",[e,n],r):i&&!s?se("Pick",[e,n],r):l({...as(e,o),...r})}function qg(e,t,r){return{[t]:Tr(e,[t],ce(r))}}function vg(e,t,r){return t.reduce((n,o)=>({...n,...qg(e,o,r)}),{})}function Hg(e,t,r){return vg(e,t.keys,r)}function Ac(e,t,r){let n=Hg(e,t,r);return H(n)}function Vg(e,t){return se("Partial",[se(e,t)])}function zg(e){return se("Partial",[lt(e)])}function Wg(e){let t={};for(let r of globalThis.Object.getOwnPropertyNames(e))t[r]=Le(e[r]);return t}function Jg(e,t){let r=ye(e,[de,"$id","required","properties"]),n=Wg(t);return X(n,r)}function kc(e){return e.map((t)=>Cc(t))}function Cc(e){return $t(e)?Vg(e.target,e.parameters):Ie(e)?zg(e.$ref):ge(e)?Ke(kc(e.allOf)):v(e)?J(kc(e.anyOf)):be(e)?Jg(e,e.properties):Ur(e)?e:Xt(e)?e:Ft(e)?e:it(e)?e:Yn(e)?e:At(e)?e:Qt(e)?e:Xn(e)?e:Zt(e)?e:X({})}function qn(e,t){if(ue(e))return Tc(e,t);else return l({...Cc(e),...t})}function Yg(e,t){let r={};for(let n of globalThis.Object.getOwnPropertyNames(e))r[n]=qn(e[n],ce(t));return r}function Xg(e,t){return Yg(e.properties,t)}function Tc(e,t){let r=Xg(e,t);return H(r)}function Qg(e,t){return se("Required",[se(e,t)])}function Zg(e){return se("Required",[lt(e)])}function ex(e){let t={};for(let r of globalThis.Object.getOwnPropertyNames(e))t[r]=ye(e[r],[Se]);return t}function tx(e,t){let r=ye(e,[de,"$id","required","properties"]),n=ex(t);return X(n,r)}function Pc(e){return e.map((t)=>Nc(t))}function Nc(e){return $t(e)?Qg(e.target,e.parameters):Ie(e)?Zg(e.$ref):ge(e)?Ke(Pc(e.allOf)):v(e)?J(Pc(e.anyOf)):be(e)?tx(e,e.properties):Ur(e)?e:Xt(e)?e:Ft(e)?e:it(e)?e:Yn(e)?e:At(e)?e:Qt(e)?e:Xn(e)?e:Zt(e)?e:X({})}function vn(e,t){if(ue(e))return Sc(e,t);else return l({...Nc(e),...t})}function rx(e,t){let r={};for(let n of globalThis.Object.getOwnPropertyNames(e))r[n]=vn(e[n],t);return r}function nx(e,t){return rx(e.properties,t)}function Sc(e,t){let r=nx(e,t);return H(r)}function ox(e,t){return t.map((r)=>Ie(r)?cs(e,r.$ref):ft(e,r))}function cs(e,t){return t in e?Ie(e[t])?cs(e,e[t].$ref):ft(e,e[t]):E()}function ix(e){return Bn(e[0])}function sx(e){return xr(e[0],e[1])}function ax(e){return gn(e[0])}function cx(e){return qn(e[0])}function ux(e){return Cr(e[0],e[1])}function fx(e){return Tr(e[0],e[1])}function dx(e){return vn(e[0])}function mx(e,t,r){let n=ox(e,r);return t==="Awaited"?ix(n):t==="Index"?sx(n):t==="KeyOf"?ax(n):t==="Partial"?cx(n):t==="Omit"?ux(n):t==="Pick"?fx(n):t==="Required"?dx(n):E()}function px(e,t){return cn(ft(e,t))}function lx(e,t){return un(ft(e,t))}function yx(e,t,r){return fn(_o(e,t),ft(e,r))}function gx(e,t,r){return vt(_o(e,t),ft(e,r))}function xx(e,t){return Ke(_o(e,t))}function hx(e,t){return yn(ft(e,t))}function Ix(e,t){return X(globalThis.Object.keys(t).reduce((r,n)=>({...r,[n]:ft(e,t[n])}),{}))}function bx(e,t){let[r,n]=[ft(e,xi(t)),gi(t)],o=Kn(t);return o.patternProperties[n]=r,o}function _x(e,t){return Ie(t)?{...cs(e,t.$ref),[de]:t[de]}:t}function Ox(e,t){return mt(_o(e,t))}function $x(e,t){return J(_o(e,t))}function _o(e,t){return t.map((r)=>ft(e,r))}function ft(e,t){return We(t)?l(ft(e,ye(t,[Se])),t):dn(t)?l(ft(e,ye(t,[Gt])),t):V(t)?l(_x(e,t),t):Ot(t)?l(px(e,t.items),t):Mr(t)?l(lx(e,t.items),t):$t(t)?l(mx(e,t.target,t.parameters)):wt(t)?l(yx(e,t.parameters,t.returns),t):Rt(t)?l(gx(e,t.parameters,t.returns),t):ge(t)?l(xx(e,t.allOf),t):Er(t)?l(hx(e,t.items),t):be(t)?l(Ix(e,t.properties),t):Kr(t)?l(bx(e,t)):ct(t)?l(Ox(e,t.items||[]),t):v(t)?l($x(e,t.anyOf),t):t}function wx(e,t){return t in e?ft(e,e[t]):E()}function jc(e){return globalThis.Object.getOwnPropertyNames(e).reduce((t,r)=>({...t,[r]:wx(e,r)}),{})}class Mc{constructor(e){let t=jc(e),r=this.WithIdentifiers(t);this.$defs=r}Import(e,t){let r={...this.$defs,[e]:l(this.$defs[e],t)};return l({[x]:"Import",$defs:r,$ref:e})}WithIdentifiers(e){return globalThis.Object.getOwnPropertyNames(e).reduce((t,r)=>({...t,[r]:{...e[r],$id:r}}),{})}}function Uc(e){return new Mc(e)}function Ec(e,t){return l({[x]:"Not",not:e},t)}function Lc(e,t){return Rt(e)?mt(e.parameters,t):E()}var Rx=0;function Kc(e,t={}){if(ie(t.$id))t.$id=`T${Rx++}`;let r=Kn(e({[x]:"This",$ref:`${t.$id}`}));return r.$id=t.$id,l({[qt]:"Recursive",...r},t)}function Bc(e,t){let r=oe(e)?new globalThis.RegExp(e):e;return l({[x]:"RegExp",type:"RegExp",source:r.source,flags:r.flags},t)}function Fx(e){return ge(e)?e.allOf:v(e)?e.anyOf:ct(e)?e.items??[]:[]}function Dc(e){return Fx(e)}function Gc(e,t){return Rt(e)?l(e.returns,t):E(t)}class qc{constructor(e){this.schema=e}Decode(e){return new vc(this.schema,e)}}class vc{constructor(e,t){this.schema=e,this.decode=t}EncodeTransform(e,t){let o={Encode:(i)=>t[de].Encode(e(i)),Decode:(i)=>this.decode(t[de].Decode(i))};return{...t,[de]:o}}EncodeSchema(e,t){let r={Decode:this.decode,Encode:e};return{...t,[de]:r}}Encode(e){return V(this.schema)?this.EncodeTransform(e,this.schema):this.EncodeSchema(e,this.schema)}}function Hc(e){return new qc(e)}function Vc(e){return l({[x]:"Void",type:"void"},e)}var Ax=us;import{join as Cx}from"path";import{readFileSync as Tx}from"fs";Ii();import{join as kx}from"path";async function Wc(){let e=kx(process.cwd(),"bare.config.ts");try{let t=await import(e);return hi(t.default)}catch{return hi()}}var bi=(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]=bi(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:bi(t.type)};if(r==="ZodOptional"||r==="ZodDefault")return bi(t.innerType);if(r==="ZodEnum")return{type:"string",enum:t.values};return{type:"object"}},Oo=(e)=>{if(!e)return{type:"object"};if("_def"in e)return bi(e);return JSON.parse(JSON.stringify(e))},ds=(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=void 0,c=void 0,u=void 0,m=null;for(let I of n.handlers){if(!I)continue;let O=I.__routeSchemas;if(O){if(O.detail)u=O.detail;if(O.params)m=Oo(O.params);if(O.query){let T=Oo(O.query),C=new Set(T.required||[]);for(let[Y,fe]of Object.entries(T.properties||{}))s.push({name:Y,in:"query",required:C.has(Y),schema:fe})}if(O.headers){let T=Oo(O.headers),C=new Set(T.required||[]);for(let[Y,fe]of Object.entries(T.properties||{}))s.push({name:Y,in:"header",required:C.has(Y),schema:fe})}if(O.response)c=Oo(O.response)}if(I.__schema&&!a)a={required:!0,content:{"application/json":{schema:Oo(I.__schema)}}}}let g=n.path.matchAll(/:([a-zA-Z0-9_]+)/g);for(let I of g){let O=I[1],T=m?.properties?.[O]||{type:"string"};s.unshift({name:O,in:"path",required:!0,schema:T})}r[o][i]={summary:u?.summary||`${n.method} ${o}`,...u?.description?{description:u.description}:{},...u?.tags?{tags:u.tags}:{},...s.length?{parameters:s}:{},...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}:{}},paths:r}},ms=(e,t="BareJS API Docs")=>{let r=t.replace(/[<>&"]/g,""),n=JSON.stringify(e);return`<!doctype html>
65
+ <html>
66
+ <head>
67
+ <title>${r}</title>
68
+ <meta charset="utf-8" />
69
+ <meta name="viewport" content="width=device-width, initial-scale=1" />
70
+ </head>
71
+ <body>
72
+ <script id="api-reference" data-url=${n}></script>
73
+ <script src="https://cdn.jsdelivr.net/npm/@scalar/api-reference"></script>
74
+ </body>
75
+ </html>`};class Jc extends Ln{tree=new Zr;pool=[];hotFetch;compiled=!1;poolMask;_useLog=!1;errorHandler;wsRoutes=new Map;startHooks=[];stopHooks=[];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}async stop(e=!1){if(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();Wc();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 Io);try{let r=Cx(process.cwd(),"package.json"),n=JSON.parse(Tx(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,i=ms(n,t.title||`${this.name} API Docs`);return this.get(n,()=>{if(!o)o=JSON.stringify(ds(this.routes,{title:this.name,...t}));return new Response(o,{status:200,headers:{"content-type":"application/json"}})}),this.get(r,()=>new Response(i,{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 i=Object.hasOwn(t,n.method)?t[n.method]:void 0;if(!i)return{jsonrpc:"2.0",error:{code:-32601,message:"Method not found"},id:n.id??null};try{let s=await i(n.params,o);if(n.id===void 0)return null;return{jsonrpc:"2.0",result:s,id:n.id}}catch(s){return{jsonrpc:"2.0",error:{code:-32603,message:s?.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 s=(await Promise.all(o.map((a)=>r(a,n)))).filter(Boolean);return s.length>0?s:new Response(null,{status:204})}let i=await r(o,n);return i===null?new Response(null,{status:204}):i}),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 i=0;i<o.length;i++){let s=o[i];if(s!=="__proto__"&&s!=="constructor"&&s!=="prototype")t[s]=n[s],t._derivedKeys.push(s)}}return r()}),this}compileHandler(e,t){let r=e.find((j)=>j?.__timeout);if(r){let{ms:j,status:Ae,message:ht}=r.__timeout,Re=e.filter((qe)=>!qe?.__timeout),et=this.compileHandler(Re,t);return async(qe,tt)=>{let dr=et(qe,tt);if(!dr||!dr.then)return dr;let tn;try{let Vn=new Promise((ee)=>{tn=setTimeout(()=>{ee(Response.json({status:"error",code:"REQUEST_TIMEOUT",message:ht},{status:Ae}))},j)});return await Promise.race([dr,Vn])}finally{if(tn!==void 0)clearTimeout(tn)}}}let n=e.length,i=e.find((j)=>j?.__responseFilter)?.__responseFilter,a=e.find((j)=>j?.__idempotencyCommit)?.__idempotencyCommit,c={status:200,headers:{"content-type":"application/json"}},u={status:200,headers:{"content-type":"text/plain"}},I=`
76
+ ${i?"res = rFilter(res);":""}
29
77
  if (res instanceof Response) {
78
+ if (ctx._headers) {
79
+ for (const k in ctx._headers) {
80
+ if (!res.headers.has(k)) res.headers.set(k, ctx._headers[k]);
81
+ }
82
+ }
83
+ if (ctx._setCookies) {
84
+ for (let i = 0; i < ctx._setCookies.length; i++) res.headers.append('Set-Cookie', ctx._setCookies[i]);
85
+ }
30
86
  ${t?"doLog(res.status);":""}
31
87
  return res;
32
88
  }
33
89
 
34
90
  const finalStatus = ctx._status || 200;
91
+ ${a?"idemCommit(ctx, res, finalStatus);":""}
35
92
  ${t?"doLog(finalStatus);":""}
36
93
 
94
+ let outRes;
37
95
  if (typeof res === 'string') {
38
- if (finalStatus === 200 && !ctx._headers) return new Response(res, text200);
39
- return new Response(res, {
96
+ if (finalStatus === 200 && !ctx._headers) {
97
+ outRes = new Response(res, text200);
98
+ } else {
99
+ outRes = new Response(res, {
100
+ status: finalStatus,
101
+ headers: ctx._headers || text200.headers
102
+ });
103
+ }
104
+ } else if (finalStatus === 200 && !ctx._headers) {
105
+ outRes = Response.json(res ?? null, json200);
106
+ } else {
107
+ outRes = Response.json(res ?? null, {
40
108
  status: finalStatus,
41
- headers: ctx._headers || text200.headers
109
+ headers: ctx._headers || json200.headers
42
110
  });
43
111
  }
44
-
45
- if (finalStatus === 200 && !ctx._headers) return Response.json(res ?? null, json200);
46
- return Response.json(res ?? null, {
47
- status: finalStatus,
48
- headers: ctx._headers && ctx._headers["content-type"] ? ctx._headers : json200.headers
49
- });
50
- `,f=t?"ctx, doLog":"ctx";if(r===1){let P=e[0];return Function("fn0","json200","text200",`return function(${f}) {
112
+
113
+ if (ctx._setCookies) {
114
+ for (let i = 0; i < ctx._setCookies.length; i++) outRes.headers.append('Set-Cookie', ctx._setCookies[i]);
115
+ }
116
+ return outRes;
117
+ `,O=t?"ctx, doLog":"ctx";if(n===1){let j=e[0];if(j.constructor.name==="AsyncFunction")return Function("fn0","json200","text200",`return async function(${O}) {
118
+ const res = await fn0(ctx);
119
+ ${I}
120
+ }`)(j,c,u);return Function("fn0","json200","text200",`return function(${O}) {
51
121
  const res = fn0(ctx);
52
- if (res && res.then) return res.then(v => { const res = v; ${a} });
53
- ${a}
54
- }`)(P,n,o)}let l=e.some((P)=>P.constructor.name==="AsyncFunction"),g="",R=e.map((P,qe)=>`fn${qe}`);if(l){for(let P=0;P<r-1;P++)g+=`let r${P} = fn${P}(ctx, noop);
55
- `,g+=`if (r${P}) {
56
- `,g+=` if (r${P}.then) r${P} = await r${P};
57
- `,g+=` if (r${P} instanceof Response) { ${t?"doLog(r"+P+".status);":""} return r${P}; }
58
- `,g+=`}
59
- `;g+=`
60
- let res = fn${r-1}(ctx);
122
+ if (res && res.then) return res.then(v => { const res = v; ${I} });
123
+ ${I}
124
+ }`)(j,c,u)}let T=e.some((j)=>j.constructor.name==="AsyncFunction"),C="",Y=e.map((j,Ae)=>`fn${Ae}`);if(T){for(let j=0;j<n-1;j++)C+=`let r${j} = fn${j}(ctx, noop);
125
+ `,C+=`if (r${j}) {
126
+ `,C+=` if (r${j}.then) r${j} = await r${j};
127
+ `,C+=` if (r${j} instanceof Response) { ${t?"doLog(r"+j+".status);":""} return r${j}; }
128
+ `,C+=`}
129
+ `;C+=`
130
+ let res = fn${n-1}(ctx);
61
131
  if (res && res.then) res = await res;
62
- ${a}
63
- `}else{for(let P=0;P<r-1;P++)g+=`const r${P} = fn${P}(ctx, noop);
64
- `,g+=`if (r${P} && r${P} instanceof Response) { ${t?"doLog(r"+P+".status);":""} return r${P}; }
65
- `;g+=`
66
- const res = fn${r-1}(ctx);
67
- if (res && res.then) return res.then(v => { const res = v; ${a} });
68
- ${a}
69
- `}let J=()=>{},be=l?`return async function(${f})`:`return function(${f})`;return Function(...R,"noop","json200","text200",`${be} { ${g} }`)(...e,J,n,o)}compile(){let e=this._useLog;this.tree=new vr;for(let st of this.routes)this.tree.insert(st.path,st.method,this.compileHandler(st.handlers,e));let t=this.tree,r=this.pool,n=r.length,o=this.notFoundHandler,i=(st)=>({status:500,message:st?.message||"Internal Server Error",stack:st?.stack}),s=[],a=(st)=>{let Cn=`h${s.length}`;return s.push(st),Cn},f=t.jitCompile(a),l=Object.freeze({}),g=s.map((st,Cn)=>`h${Cn}`),R=`
132
+ ${I}
133
+ `}else{for(let j=0;j<n-1;j++)C+=`const r${j} = fn${j}(ctx, noop);
134
+ `,C+=`if (r${j} && r${j} instanceof Response) { ${t?"doLog(r"+j+".status);":""} return r${j}; }
135
+ `;C+=`
136
+ let res = fn${n-1}(ctx);
137
+ if (res && res.then) return res.then(v => { let res = v; ${I} });
138
+ ${I}
139
+ `}let fe=()=>{},Ee=T?`return async function(${O})`:`return function(${O})`;return Function(...Y,"noop","json200","text200",...i?["rFilter"]:[],...a?["idemCommit"]:[],`${Ee} { ${C} }`)(...e,fe,c,u,...i?[i]:[],...a?[a]:[])}compile(){let e=this._useLog;this.tree=new Zr;for(let ee of this.routes)this.tree.insert(ee.path,ee.method,this.compileHandler(ee.handlers,e));let t=this.tree,r=this.pool,n=r.length,o=this.notFoundHandler,i=this.errorHandler,s=(ee,rt)=>{if(i){let It=i(ee,rt);if(It instanceof Response)return It;let Jt=rt._status>=400?rt._status:500;if(typeof It==="string")return new Response(It,{status:Jt});return Response.json(It??null,{status:Jt})}if(ee?.status>=400&&ee?.status<500)return Response.json({status:ee.status,message:ee.message||"Bad Request"},{status:ee.status});return Response.json({status:500,message:ee?.message||"Internal Server Error",stack:ee?.stack},{status:500})},a=[],c=(ee)=>{let rt=`h${a.length}`;return a.push(ee),rt},u=t.jitCompile(c),m=Object.freeze({}),g=a.map((ee,rt)=>`h${rt}`),I=this.routes.some((ee)=>ee.handlers.some((rt)=>rt?.__idempotencyCommit)),C=`
70
140
  if (ctx.store.size > 0) ctx.store.clear();
141
+ ${this._hasDerive?"if (ctx._derivedKeys) { for (let i = 0; i < ctx._derivedKeys.length; i++) delete ctx[ctx._derivedKeys[i]]; ctx._derivedKeys = undefined; }":""}
142
+ ${I?"if (ctx._idempotencyKey) { ctx._idemInFlight.delete(ctx._idempotencyKey); ctx._idempotencyKey = undefined; ctx._idemInFlight = undefined; }":""}
71
143
  ctx.req = undefined;
144
+ ctx._status = 200;
72
145
  ctx.body = undefined;
146
+ ctx._query = undefined;
147
+ ctx._cookies = undefined;
148
+ ctx._setCookies = undefined;
73
149
  ctx._headers = undefined;
150
+ ctx._requestId = undefined;
74
151
  ctx.params = EMPTY_PARAMS;
75
152
  if (poolTop < maxPool) pool[poolTop++] = ctx;
76
- `,J=e?"(ctx, doLog)":"(ctx)",be=f.replace(/return (h\d+)\(ctx\);/g,`const out = $1${J};
77
- if (out && out.then) return out.then((v) => { ${R} return v; }, (e) => { ${R} ${e?"doLog(500);":""} return Response.json(hError(e), { status: 500 }); });
78
- ${R}
79
- return out;`),P=["pool","maxPool","Context","hNotFound","hError","EMPTY_PARAMS",...g],qe=[r,n,ao,o,i,l,...s],Pn=`
153
+ `,Y=e?"(ctx, doLog)":"(ctx)",fe=u.replace(/return (h\d+)\(ctx\);/g,`out = $1${Y};
154
+ 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; });
155
+ ${C}
156
+ return out;`),Ee=this.groupMiddleware.length>0,j=Ee?this.compileHandler(this.groupMiddleware,e):void 0,Ae=Ee?`if (method === 'OPTIONS') {
157
+ out = hOptions${Y};
158
+ 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; });
159
+ ${C}
160
+ return out;
161
+ }`:"",ht=this.groupMiddleware.filter((ee)=>ee.__isStatic),Re=ht.length>0,et=Re?async(ee)=>{let rt=()=>{};for(let It=0;It<ht.length;It++){let Jt=await ht[It](ee,rt);if(Jt instanceof Response){if(ee._headers)for(let zn in ee._headers){let $o=ee._headers[zn];if($o!==void 0&&!Jt.headers.has(zn))Jt.headers.set(zn,$o)}return Jt}}return}:void 0,qe=Re?`if (method === 'GET' || method === 'HEAD') {
162
+ out = runStatic(ctx);
163
+ if (out && out.then) {
164
+ return out.then((v) => {
165
+ if (v instanceof Response) { ${e?"doLog(v.status);":""} ${C} return v; }
166
+ const errorBody = hNotFound();
167
+ const status = errorBody.status || 404;
168
+ ${e?"doLog(status);":""}
169
+ ${C}
170
+ return Response.json(errorBody, { status });
171
+ }, (e) => {
172
+ const errRes = hError(e, ctx);
173
+ ${C}
174
+ ${e?"doLog(errRes.status || 500);":""}
175
+ return errRes;
176
+ });
177
+ }
178
+ }`:"",tt=["pool","maxPool","Context","hNotFound","hError","EMPTY_PARAMS",...Ee?["hOptions"]:[],...Re?["runStatic"]:[],...g],dr=[r,n,Io,o,s,m,...Ee?[j]:[],...Re?[et]:[],...a],Vn=`
80
179
  let poolTop = maxPool;
81
180
  return function(req) {
82
181
  const url = req.url;
@@ -88,31 +187,32 @@ var{defineProperty:ni,getOwnPropertyNames:Wc,getOwnPropertyDescriptor:Jc}=Object
88
187
 
89
188
  const method = req.method;
90
189
  const ctx = poolTop > 0 ? pool[--poolTop] : new Context();
190
+ let out;
91
191
  ${e?"\n const start = performance.now();\n const doLog = (status) => {\n const duration = (performance.now() - start).toFixed(3);\n console.log(\n ` \\x1b[90m${new Date().toLocaleTimeString()}\\x1b[0m ` +\n `\\x1b[1m\\x1b[38;5;117m${method.padEnd(7)}\\x1b[0m ` +\n `\\x1b[38;5;250m${url.substring(url.indexOf('/', 8))}\\x1b[0m ` +\n `${status >= 400 ? '\\x1b[33m' : '\\x1b[32m'}${status}\\x1b[0m ` +\n `\\x1b[90m(${duration}ms)\\x1b[0m`\n );\n };":""}
92
192
 
93
193
  try {
94
194
  ctx.req = req;
95
- ctx._status = 200;
96
- ctx._headers = undefined;
97
- if (ctx.store.size > 0) ctx.store.clear();
98
- ctx.params = EMPTY_PARAMS;
99
- ctx.body = undefined;
100
195
 
101
- ${be}
196
+ ${fe}
197
+
198
+ ${Ae}
199
+
200
+ ${qe}
102
201
 
103
202
  const errorBody = hNotFound();
104
203
  const status = errorBody.status || 404;
105
204
  ${e?"doLog(status);":""}
106
- ${R}
205
+ ${C}
107
206
  return Response.json(errorBody, { status });
108
207
 
109
208
  } catch (e) {
110
- ${e?"doLog(500);":""}
111
- ${R}
112
- return Response.json(hError(e), { status: 500 });
209
+ const errRes = hError(e, ctx);
210
+ ${e?"doLog(errRes.status || 500);":""}
211
+ ${C}
212
+ return errRes;
113
213
  }
114
214
  }
115
- `;this.hotFetch=Function(...P,Pn)(...qe),this.compiled=!0,this.fetch=this.hotFetch}fetch=(e)=>{if(!this.compiled)return this.compile(),this.hotFetch(e);return this.hotFetch(e)};name="App";listen(e,t="0.0.0.0",r=!0){if(!this.compiled)this.compile();let{BARE_CONFIG:n}=(Jo(),Xc(qa)),o=e||n.port||3000;if(!0)console.log(`
215
+ `;this.hotFetch=Function(...tt,Vn)(...dr),this.compiled=!0,this.fetch=this.hotFetch}fetch=(e)=>{if(!this.compiled)return this.compile(),this.hotFetch(e);return this.hotFetch(e)};name="App";listen(e,t="0.0.0.0",r=!0){if(!this.compiled)this.compile();let{BARE_CONFIG:n}=(Ii(),fu(zc)),o=e||n.port||3000;if(!0)console.log(`
116
216
  \x1B[33m ____ _ _____ \x1B[0m
117
217
  \x1B[33m | __ ) __ _ _ __ ___ | | ____|\x1B[0m
118
218
  \x1B[33m | _ \\ / _\` | '__/ _ \\ _ | | _| \x1B[0m
@@ -122,12 +222,7 @@ var{defineProperty:ni,getOwnPropertyNames:Wc,getOwnPropertyDescriptor:Jc}=Object
122
222
  \x1B[32m\uD83D\uDE80 ${this.name} is running in development mode\x1B[0m
123
223
  \x1B[90m\u2699\uFE0F Pool Size: ${this.pool.length} | JIT: Enabled | Port: ${o}\x1B[0m
124
224
  \x1B[36m\uD83D\uDEE1\uFE0F Hash: ${n.hash.algorithm} (${n.hash.memoryCost/1024}MB) | Iterations: ${n.hash.timeCost}\x1B[0m
125
- `);let s=Bun.serve({port:o,hostname:t,fetch:this.fetch,reusePort:r}),a=()=>{let l=this.name,g=process.stdout.isTTY;{let R=g?"\uD83D\uDED1":"!",J=g?"\u2705":"v";process.stdout.write(`
126
- \x1B[31m${R} Stopping ${l}...\x1B[0m
127
- `),s.stop(),process.stdout.write(`\x1B[32m${J} ${l} has been stopped.\x1B[0m
128
- `)}process.exit(0)};process.on("SIGINT",a),process.on("SIGTERM",a)}}function Vp(e){switch(e.errorType){case m.ArrayContains:return"Expected array to contain at least one matching value";case m.ArrayMaxContains:return`Expected array to contain no more than ${e.schema.maxContains} matching values`;case m.ArrayMinContains:return`Expected array to contain at least ${e.schema.minContains} matching values`;case m.ArrayMaxItems:return`Expected array length to be less or equal to ${e.schema.maxItems}`;case m.ArrayMinItems:return`Expected array length to be greater or equal to ${e.schema.minItems}`;case m.ArrayUniqueItems:return"Expected array elements to be unique";case m.Array:return"Expected array";case m.AsyncIterator:return"Expected AsyncIterator";case m.BigIntExclusiveMaximum:return`Expected bigint to be less than ${e.schema.exclusiveMaximum}`;case m.BigIntExclusiveMinimum:return`Expected bigint to be greater than ${e.schema.exclusiveMinimum}`;case m.BigIntMaximum:return`Expected bigint to be less or equal to ${e.schema.maximum}`;case m.BigIntMinimum:return`Expected bigint to be greater or equal to ${e.schema.minimum}`;case m.BigIntMultipleOf:return`Expected bigint to be a multiple of ${e.schema.multipleOf}`;case m.BigInt:return"Expected bigint";case m.Boolean:return"Expected boolean";case m.DateExclusiveMinimumTimestamp:return`Expected Date timestamp to be greater than ${e.schema.exclusiveMinimumTimestamp}`;case m.DateExclusiveMaximumTimestamp:return`Expected Date timestamp to be less than ${e.schema.exclusiveMaximumTimestamp}`;case m.DateMinimumTimestamp:return`Expected Date timestamp to be greater or equal to ${e.schema.minimumTimestamp}`;case m.DateMaximumTimestamp:return`Expected Date timestamp to be less or equal to ${e.schema.maximumTimestamp}`;case m.DateMultipleOfTimestamp:return`Expected Date timestamp to be a multiple of ${e.schema.multipleOfTimestamp}`;case m.Date:return"Expected Date";case m.Function:return"Expected function";case m.IntegerExclusiveMaximum:return`Expected integer to be less than ${e.schema.exclusiveMaximum}`;case m.IntegerExclusiveMinimum:return`Expected integer to be greater than ${e.schema.exclusiveMinimum}`;case m.IntegerMaximum:return`Expected integer to be less or equal to ${e.schema.maximum}`;case m.IntegerMinimum:return`Expected integer to be greater or equal to ${e.schema.minimum}`;case m.IntegerMultipleOf:return`Expected integer to be a multiple of ${e.schema.multipleOf}`;case m.Integer:return"Expected integer";case m.IntersectUnevaluatedProperties:return"Unexpected property";case m.Intersect:return"Expected all values to match";case m.Iterator:return"Expected Iterator";case m.Literal:return`Expected ${typeof e.schema.const==="string"?`'${e.schema.const}'`:e.schema.const}`;case m.Never:return"Never";case m.Not:return"Value should not match";case m.Null:return"Expected null";case m.NumberExclusiveMaximum:return`Expected number to be less than ${e.schema.exclusiveMaximum}`;case m.NumberExclusiveMinimum:return`Expected number to be greater than ${e.schema.exclusiveMinimum}`;case m.NumberMaximum:return`Expected number to be less or equal to ${e.schema.maximum}`;case m.NumberMinimum:return`Expected number to be greater or equal to ${e.schema.minimum}`;case m.NumberMultipleOf:return`Expected number to be a multiple of ${e.schema.multipleOf}`;case m.Number:return"Expected number";case m.Object:return"Expected object";case m.ObjectAdditionalProperties:return"Unexpected property";case m.ObjectMaxProperties:return`Expected object to have no more than ${e.schema.maxProperties} properties`;case m.ObjectMinProperties:return`Expected object to have at least ${e.schema.minProperties} properties`;case m.ObjectRequiredProperty:return"Expected required property";case m.Promise:return"Expected Promise";case m.RegExp:return"Expected string to match regular expression";case m.StringFormatUnknown:return`Unknown format '${e.schema.format}'`;case m.StringFormat:return`Expected string to match '${e.schema.format}' format`;case m.StringMaxLength:return`Expected string length less or equal to ${e.schema.maxLength}`;case m.StringMinLength:return`Expected string length greater or equal to ${e.schema.minLength}`;case m.StringPattern:return`Expected string to match '${e.schema.pattern}'`;case m.String:return"Expected string";case m.Symbol:return"Expected symbol";case m.TupleLength:return`Expected tuple to have ${e.schema.maxItems||0} elements`;case m.Tuple:return"Expected tuple";case m.Uint8ArrayMaxByteLength:return`Expected byte length less or equal to ${e.schema.maxByteLength}`;case m.Uint8ArrayMinByteLength:return`Expected byte length greater or equal to ${e.schema.minByteLength}`;case m.Uint8Array:return"Expected Uint8Array";case m.Undefined:return"Expected undefined";case m.Union:return"Expected union value";case m.Void:return"Expected void";case m.Kind:return`Expected kind '${e.schema[y]}'`;default:return"Unknown error type"}}var Hp=Vp;function za(){return Hp}class Wa extends v{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 Wa(e);return Oe(r,t)}function fr(e,t){if(!_e(e.$id)||t.some((r)=>r.$id===e.$id))return t;return t.push(e),t}function Oe(e,t){return e[y]==="This"||e[y]==="Ref"?zp(e,t):e}class Ja extends v{constructor(e){super("Unable to hash value");this.value=e}}var Xe;(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"})(Xe||(Xe={}));var pn=BigInt("14695981039346656037"),[Wp,Jp]=[BigInt("1099511628211"),BigInt("18446744073709551616")],Yp=Array.from({length:256}).map((e,t)=>BigInt(t)),Ya=new Float64Array(1),Qa=new DataView(Ya.buffer),Xa=new Uint8Array(Ya.buffer);function*Qp(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 Xp(e){je(Xe.Array);for(let t of e)ln(t)}function Zp(e){je(Xe.Boolean),je(e?1:0)}function el(e){je(Xe.BigInt),Qa.setBigInt64(0,e);for(let t of Xa)je(t)}function tl(e){je(Xe.Date),ln(e.getTime())}function rl(e){je(Xe.Null)}function nl(e){je(Xe.Number),Qa.setFloat64(0,e);for(let t of Xa)je(t)}function ol(e){je(Xe.Object);for(let t of globalThis.Object.getOwnPropertyNames(e).sort())ln(t),ln(e[t])}function il(e){je(Xe.String);for(let t=0;t<e.length;t++)for(let r of Qp(e.charCodeAt(t)))je(r)}function sl(e){je(Xe.Symbol),ln(e.description)}function al(e){je(Xe.Uint8Array);for(let t=0;t<e.length;t++)je(e[t])}function cl(e){return je(Xe.Undefined)}function ln(e){if(xe(e))return Xp(e);if(Ir(e))return Zp(e);if(He(e))return el(e);if(Hr(e))return tl(e);if(gr(e))return rl(e);if(N(e))return nl(e);if(Ke(e))return ol(e);if(_e(e))return il(e);if(hr(e))return sl(e);if(zr(e))return al(e);if(Se(e))return cl(e);throw new Ja(e)}function je(e){pn=pn^Yp[e],pn=pn*Wp%Jp}function yn(e){return pn=BigInt("14695981039346656037"),ln(e),pn}class Za extends v{constructor(e){super("Unknown type");this.schema=e}}function ul(e){return e[y]==="Any"||e[y]==="Unknown"}function S(e){return e!==void 0}function fl(e,t,r){return!0}function ml(e,t,r){return!0}function dl(e,t,r){if(!xe(r))return!1;if(S(e.minItems)&&!(r.length>=e.minItems))return!1;if(S(e.maxItems)&&!(r.length<=e.maxItems))return!1;if(!r.every((i)=>$e(e.items,t,i)))return!1;if(e.uniqueItems===!0&&!function(){let i=new Set;for(let s of r){let a=yn(s);if(i.has(a))return!1;else i.add(a)}return!0}())return!1;if(!(S(e.contains)||N(e.minContains)||N(e.maxContains)))return!0;let n=S(e.contains)?e.contains:j(),o=r.reduce((i,s)=>$e(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 pl(e,t,r){return mo(r)}function ll(e,t,r){if(!He(r))return!1;if(S(e.exclusiveMaximum)&&!(r<e.exclusiveMaximum))return!1;if(S(e.exclusiveMinimum)&&!(r>e.exclusiveMinimum))return!1;if(S(e.maximum)&&!(r<=e.maximum))return!1;if(S(e.minimum)&&!(r>=e.minimum))return!1;if(S(e.multipleOf)&&r%e.multipleOf!==BigInt(0))return!1;return!0}function yl(e,t,r){return Ir(r)}function xl(e,t,r){return $e(e.returns,t,r.prototype)}function gl(e,t,r){if(!Hr(r))return!1;if(S(e.exclusiveMaximumTimestamp)&&!(r.getTime()<e.exclusiveMaximumTimestamp))return!1;if(S(e.exclusiveMinimumTimestamp)&&!(r.getTime()>e.exclusiveMinimumTimestamp))return!1;if(S(e.maximumTimestamp)&&!(r.getTime()<=e.maximumTimestamp))return!1;if(S(e.minimumTimestamp)&&!(r.getTime()>=e.minimumTimestamp))return!1;if(S(e.multipleOfTimestamp)&&r.getTime()%e.multipleOfTimestamp!==0)return!1;return!0}function Il(e,t,r){return go(r)}function hl(e,t,r){let n=globalThis.Object.values(e.$defs),o=e.$defs[e.$ref];return $e(o,[...t,...n],r)}function bl(e,t,r){if(!xo(r))return!1;if(S(e.exclusiveMaximum)&&!(r<e.exclusiveMaximum))return!1;if(S(e.exclusiveMinimum)&&!(r>e.exclusiveMinimum))return!1;if(S(e.maximum)&&!(r<=e.maximum))return!1;if(S(e.minimum)&&!(r>=e.minimum))return!1;if(S(e.multipleOf)&&r%e.multipleOf!==0)return!1;return!0}function _l(e,t,r){let n=e.allOf.every((o)=>$e(o,t,r));if(e.unevaluatedProperties===!1){let o=new RegExp(qt(e)),i=Object.getOwnPropertyNames(r).every((s)=>o.test(s));return n&&i}else if(se(e.unevaluatedProperties)){let o=new RegExp(qt(e)),i=Object.getOwnPropertyNames(r).every((s)=>o.test(s)||$e(e.unevaluatedProperties,t,r[s]));return n&&i}else return n}function Ol(e,t,r){return po(r)}function $l(e,t,r){return r===e.const}function Fl(e,t,r){return!1}function wl(e,t,r){return!$e(e.not,t,r)}function Rl(e,t,r){return gr(r)}function Tl(e,t,r){if(!ee.IsNumberLike(r))return!1;if(S(e.exclusiveMaximum)&&!(r<e.exclusiveMaximum))return!1;if(S(e.exclusiveMinimum)&&!(r>e.exclusiveMinimum))return!1;if(S(e.minimum)&&!(r>=e.minimum))return!1;if(S(e.maximum)&&!(r<=e.maximum))return!1;if(S(e.multipleOf)&&r%e.multipleOf!==0)return!1;return!0}function Al(e,t,r){if(!ee.IsObjectLike(r))return!1;if(S(e.minProperties)&&!(Object.getOwnPropertyNames(r).length>=e.minProperties))return!1;if(S(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(!$e(i,t,r[o]))return!1;if((Vt(i)||ul(i))&&!(o in r))return!1}else if(ee.IsExactOptionalProperty(r,o)&&!$e(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)||$e(e.additionalProperties,t,r[i]));else return!0}function kl(e,t,r){return lo(r)}function Nl(e,t,r){if(!ee.IsRecordLike(r))return!1;if(S(e.minProperties)&&!(Object.getOwnPropertyNames(r).length>=e.minProperties))return!1;if(S(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(([l,g])=>i.test(l)?$e(o,t,g):!0),a=typeof e.additionalProperties==="object"?Object.entries(r).every(([l,g])=>!i.test(l)?$e(e.additionalProperties,t,g):!0):!0,f=e.additionalProperties===!1?Object.getOwnPropertyNames(r).every((l)=>i.test(l)):!0;return s&&a&&f}function Pl(e,t,r){return $e(Oe(e,t),t,r)}function Cl(e,t,r){let n=new RegExp(e.source,e.flags);if(S(e.minLength)){if(!(r.length>=e.minLength))return!1}if(S(e.maxLength)){if(!(r.length<=e.maxLength))return!1}return n.test(r)}function jl(e,t,r){if(!_e(r))return!1;if(S(e.minLength)){if(!(r.length>=e.minLength))return!1}if(S(e.maxLength)){if(!(r.length<=e.maxLength))return!1}if(S(e.pattern)){if(!new RegExp(e.pattern).test(r))return!1}if(S(e.format)){if(!li(e.format))return!1;return yi(e.format)(r)}return!0}function Ml(e,t,r){return hr(r)}function Sl(e,t,r){return _e(r)&&new RegExp(e.pattern).test(r)}function Ul(e,t,r){return $e(Oe(e,t),t,r)}function Kl(e,t,r){if(!xe(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(!$e(e.items[n],t,r[n]))return!1;return!0}function El(e,t,r){return Se(r)}function Ll(e,t,r){return e.anyOf.some((n)=>$e(n,t,r))}function Bl(e,t,r){if(!zr(r))return!1;if(S(e.maxByteLength)&&!(r.length<=e.maxByteLength))return!1;if(S(e.minByteLength)&&!(r.length>=e.minByteLength))return!1;return!0}function Gl(e,t,r){return!0}function Dl(e,t,r){return ee.IsVoidLike(r)}function vl(e,t,r){if(!Gn(e[y]))return!1;return xi(e[y])(e,r)}function $e(e,t,r){let n=S(e.$id)?fr(e,t):t,o=e;switch(o[y]){case"Any":return fl(o,n,r);case"Argument":return ml(o,n,r);case"Array":return dl(o,n,r);case"AsyncIterator":return pl(o,n,r);case"BigInt":return ll(o,n,r);case"Boolean":return yl(o,n,r);case"Constructor":return xl(o,n,r);case"Date":return gl(o,n,r);case"Function":return Il(o,n,r);case"Import":return hl(o,n,r);case"Integer":return bl(o,n,r);case"Intersect":return _l(o,n,r);case"Iterator":return Ol(o,n,r);case"Literal":return $l(o,n,r);case"Never":return Fl(o,n,r);case"Not":return wl(o,n,r);case"Null":return Rl(o,n,r);case"Number":return Tl(o,n,r);case"Object":return Al(o,n,r);case"Promise":return kl(o,n,r);case"Record":return Nl(o,n,r);case"Ref":return Pl(o,n,r);case"RegExp":return Cl(o,n,r);case"String":return jl(o,n,r);case"Symbol":return Ml(o,n,r);case"TemplateLiteral":return Sl(o,n,r);case"This":return Ul(o,n,r);case"Tuple":return Kl(o,n,r);case"Undefined":return El(o,n,r);case"Union":return Ll(o,n,r);case"Uint8Array":return Bl(o,n,r);case"Unknown":return Gl(o,n,r);case"Void":return Dl(o,n,r);default:if(!Gn(o[y]))throw new Za(o);return vl(o,n,r)}}function Cr(...e){return e.length===3?$e(e[0],e[1],e[2]):$e(e[0],[],e[1])}var m;(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"})(m||(m={}));class ec extends v{constructor(e){super("Unknown type");this.schema=e}}function Ht(e){return e.replace(/~/g,"~0").replace(/\//g,"~1")}function U(e){return e!==void 0}class Mi{constructor(e){this.iterator=e}[Symbol.iterator](){return this.iterator}First(){let e=this.iterator.next();return e.done?void 0:e.value}}function h(e,t,r,n,o=[]){return{type:e,schema:t,path:r,value:n,message:za()({errorType:e,path:r,schema:t,value:n,errors:o}),errors:o}}function*ql(e,t,r,n){}function*Vl(e,t,r,n){}function*Hl(e,t,r,n){if(!xe(n))return yield h(m.Array,e,r,n);if(U(e.minItems)&&!(n.length>=e.minItems))yield h(m.ArrayMinItems,e,r,n);if(U(e.maxItems)&&!(n.length<=e.maxItems))yield h(m.ArrayMaxItems,e,r,n);for(let s=0;s<n.length;s++)yield*Fe(e.items,t,`${r}/${s}`,n[s]);if(e.uniqueItems===!0&&!function(){let s=new Set;for(let a of n){let f=yn(a);if(s.has(f))return!1;else s.add(f)}return!0}())yield h(m.ArrayUniqueItems,e,r,n);if(!(U(e.contains)||U(e.minContains)||U(e.maxContains)))return;let o=U(e.contains)?e.contains:j(),i=n.reduce((s,a,f)=>Fe(o,t,`${r}${f}`,a).next().done===!0?s+1:s,0);if(i===0)yield h(m.ArrayContains,e,r,n);if(N(e.minContains)&&i<e.minContains)yield h(m.ArrayMinContains,e,r,n);if(N(e.maxContains)&&i>e.maxContains)yield h(m.ArrayMaxContains,e,r,n)}function*zl(e,t,r,n){if(!mo(n))yield h(m.AsyncIterator,e,r,n)}function*Wl(e,t,r,n){if(!He(n))return yield h(m.BigInt,e,r,n);if(U(e.exclusiveMaximum)&&!(n<e.exclusiveMaximum))yield h(m.BigIntExclusiveMaximum,e,r,n);if(U(e.exclusiveMinimum)&&!(n>e.exclusiveMinimum))yield h(m.BigIntExclusiveMinimum,e,r,n);if(U(e.maximum)&&!(n<=e.maximum))yield h(m.BigIntMaximum,e,r,n);if(U(e.minimum)&&!(n>=e.minimum))yield h(m.BigIntMinimum,e,r,n);if(U(e.multipleOf)&&n%e.multipleOf!==BigInt(0))yield h(m.BigIntMultipleOf,e,r,n)}function*Jl(e,t,r,n){if(!Ir(n))yield h(m.Boolean,e,r,n)}function*Yl(e,t,r,n){yield*Fe(e.returns,t,r,n.prototype)}function*Ql(e,t,r,n){if(!Hr(n))return yield h(m.Date,e,r,n);if(U(e.exclusiveMaximumTimestamp)&&!(n.getTime()<e.exclusiveMaximumTimestamp))yield h(m.DateExclusiveMaximumTimestamp,e,r,n);if(U(e.exclusiveMinimumTimestamp)&&!(n.getTime()>e.exclusiveMinimumTimestamp))yield h(m.DateExclusiveMinimumTimestamp,e,r,n);if(U(e.maximumTimestamp)&&!(n.getTime()<=e.maximumTimestamp))yield h(m.DateMaximumTimestamp,e,r,n);if(U(e.minimumTimestamp)&&!(n.getTime()>=e.minimumTimestamp))yield h(m.DateMinimumTimestamp,e,r,n);if(U(e.multipleOfTimestamp)&&n.getTime()%e.multipleOfTimestamp!==0)yield h(m.DateMultipleOfTimestamp,e,r,n)}function*Xl(e,t,r,n){if(!go(n))yield h(m.Function,e,r,n)}function*Zl(e,t,r,n){let o=globalThis.Object.values(e.$defs),i=e.$defs[e.$ref];yield*Fe(i,[...t,...o],r,n)}function*ey(e,t,r,n){if(!xo(n))return yield h(m.Integer,e,r,n);if(U(e.exclusiveMaximum)&&!(n<e.exclusiveMaximum))yield h(m.IntegerExclusiveMaximum,e,r,n);if(U(e.exclusiveMinimum)&&!(n>e.exclusiveMinimum))yield h(m.IntegerExclusiveMinimum,e,r,n);if(U(e.maximum)&&!(n<=e.maximum))yield h(m.IntegerMaximum,e,r,n);if(U(e.minimum)&&!(n>=e.minimum))yield h(m.IntegerMinimum,e,r,n);if(U(e.multipleOf)&&n%e.multipleOf!==0)yield h(m.IntegerMultipleOf,e,r,n)}function*ty(e,t,r,n){let o=!1;for(let i of e.allOf)for(let s of Fe(i,t,r,n))o=!0,yield s;if(o)return yield h(m.Intersect,e,r,n);if(e.unevaluatedProperties===!1){let i=new RegExp(qt(e));for(let s of Object.getOwnPropertyNames(n))if(!i.test(s))yield h(m.IntersectUnevaluatedProperties,e,`${r}/${s}`,n)}if(typeof e.unevaluatedProperties==="object"){let i=new RegExp(qt(e));for(let s of Object.getOwnPropertyNames(n))if(!i.test(s)){let a=Fe(e.unevaluatedProperties,t,`${r}/${s}`,n[s]).next();if(!a.done)yield a.value}}}function*ry(e,t,r,n){if(!po(n))yield h(m.Iterator,e,r,n)}function*ny(e,t,r,n){if(n!==e.const)yield h(m.Literal,e,r,n)}function*oy(e,t,r,n){yield h(m.Never,e,r,n)}function*iy(e,t,r,n){if(Fe(e.not,t,r,n).next().done===!0)yield h(m.Not,e,r,n)}function*sy(e,t,r,n){if(!gr(n))yield h(m.Null,e,r,n)}function*ay(e,t,r,n){if(!ee.IsNumberLike(n))return yield h(m.Number,e,r,n);if(U(e.exclusiveMaximum)&&!(n<e.exclusiveMaximum))yield h(m.NumberExclusiveMaximum,e,r,n);if(U(e.exclusiveMinimum)&&!(n>e.exclusiveMinimum))yield h(m.NumberExclusiveMinimum,e,r,n);if(U(e.maximum)&&!(n<=e.maximum))yield h(m.NumberMaximum,e,r,n);if(U(e.minimum)&&!(n>=e.minimum))yield h(m.NumberMinimum,e,r,n);if(U(e.multipleOf)&&n%e.multipleOf!==0)yield h(m.NumberMultipleOf,e,r,n)}function*cy(e,t,r,n){if(!ee.IsObjectLike(n))return yield h(m.Object,e,r,n);if(U(e.minProperties)&&!(Object.getOwnPropertyNames(n).length>=e.minProperties))yield h(m.ObjectMinProperties,e,r,n);if(U(e.maxProperties)&&!(Object.getOwnPropertyNames(n).length<=e.maxProperties))yield h(m.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 h(m.ObjectRequiredProperty,e.properties[a],`${r}/${Ht(a)}`,void 0)}if(e.additionalProperties===!1){for(let a of s)if(!i.includes(a))yield h(m.ObjectAdditionalProperties,e,`${r}/${Ht(a)}`,n[a])}if(typeof e.additionalProperties==="object")for(let a of s){if(i.includes(a))continue;yield*Fe(e.additionalProperties,t,`${r}/${Ht(a)}`,n[a])}for(let a of i){let f=e.properties[a];if(e.required&&e.required.includes(a)){if(yield*Fe(f,t,`${r}/${Ht(a)}`,n[a]),Vt(e)&&!(a in n))yield h(m.ObjectRequiredProperty,f,`${r}/${Ht(a)}`,void 0)}else if(ee.IsExactOptionalProperty(n,a))yield*Fe(f,t,`${r}/${Ht(a)}`,n[a])}}function*uy(e,t,r,n){if(!lo(n))yield h(m.Promise,e,r,n)}function*fy(e,t,r,n){if(!ee.IsRecordLike(n))return yield h(m.Object,e,r,n);if(U(e.minProperties)&&!(Object.getOwnPropertyNames(n).length>=e.minProperties))yield h(m.ObjectMinProperties,e,r,n);if(U(e.maxProperties)&&!(Object.getOwnPropertyNames(n).length<=e.maxProperties))yield h(m.ObjectMaxProperties,e,r,n);let[o,i]=Object.entries(e.patternProperties)[0],s=new RegExp(o);for(let[a,f]of Object.entries(n))if(s.test(a))yield*Fe(i,t,`${r}/${Ht(a)}`,f);if(typeof e.additionalProperties==="object"){for(let[a,f]of Object.entries(n))if(!s.test(a))yield*Fe(e.additionalProperties,t,`${r}/${Ht(a)}`,f)}if(e.additionalProperties===!1)for(let[a,f]of Object.entries(n)){if(s.test(a))continue;return yield h(m.ObjectAdditionalProperties,e,`${r}/${Ht(a)}`,f)}}function*my(e,t,r,n){yield*Fe(Oe(e,t),t,r,n)}function*dy(e,t,r,n){if(!_e(n))return yield h(m.String,e,r,n);if(U(e.minLength)&&!(n.length>=e.minLength))yield h(m.StringMinLength,e,r,n);if(U(e.maxLength)&&!(n.length<=e.maxLength))yield h(m.StringMaxLength,e,r,n);if(!new RegExp(e.source,e.flags).test(n))return yield h(m.RegExp,e,r,n)}function*py(e,t,r,n){if(!_e(n))return yield h(m.String,e,r,n);if(U(e.minLength)&&!(n.length>=e.minLength))yield h(m.StringMinLength,e,r,n);if(U(e.maxLength)&&!(n.length<=e.maxLength))yield h(m.StringMaxLength,e,r,n);if(_e(e.pattern)){if(!new RegExp(e.pattern).test(n))yield h(m.StringPattern,e,r,n)}if(_e(e.format)){if(!li(e.format))yield h(m.StringFormatUnknown,e,r,n);else if(!yi(e.format)(n))yield h(m.StringFormat,e,r,n)}}function*ly(e,t,r,n){if(!hr(n))yield h(m.Symbol,e,r,n)}function*yy(e,t,r,n){if(!_e(n))return yield h(m.String,e,r,n);if(!new RegExp(e.pattern).test(n))yield h(m.StringPattern,e,r,n)}function*xy(e,t,r,n){yield*Fe(Oe(e,t),t,r,n)}function*gy(e,t,r,n){if(!xe(n))return yield h(m.Tuple,e,r,n);if(e.items===void 0&&n.length!==0)return yield h(m.TupleLength,e,r,n);if(n.length!==e.maxItems)return yield h(m.TupleLength,e,r,n);if(!e.items)return;for(let o=0;o<e.items.length;o++)yield*Fe(e.items[o],t,`${r}/${o}`,n[o])}function*Iy(e,t,r,n){if(!Se(n))yield h(m.Undefined,e,r,n)}function*hy(e,t,r,n){if(Cr(e,t,n))return;let o=e.anyOf.map((i)=>new Mi(Fe(i,t,r,n)));yield h(m.Union,e,r,n,o)}function*by(e,t,r,n){if(!zr(n))return yield h(m.Uint8Array,e,r,n);if(U(e.maxByteLength)&&!(n.length<=e.maxByteLength))yield h(m.Uint8ArrayMaxByteLength,e,r,n);if(U(e.minByteLength)&&!(n.length>=e.minByteLength))yield h(m.Uint8ArrayMinByteLength,e,r,n)}function*_y(e,t,r,n){}function*Oy(e,t,r,n){if(!ee.IsVoidLike(n))yield h(m.Void,e,r,n)}function*$y(e,t,r,n){if(!xi(e[y])(e,n))yield h(m.Kind,e,r,n)}function*Fe(e,t,r,n){let o=U(e.$id)?[...t,e]:t,i=e;switch(i[y]){case"Any":return yield*ql(i,o,r,n);case"Argument":return yield*Vl(i,o,r,n);case"Array":return yield*Hl(i,o,r,n);case"AsyncIterator":return yield*zl(i,o,r,n);case"BigInt":return yield*Wl(i,o,r,n);case"Boolean":return yield*Jl(i,o,r,n);case"Constructor":return yield*Yl(i,o,r,n);case"Date":return yield*Ql(i,o,r,n);case"Function":return yield*Xl(i,o,r,n);case"Import":return yield*Zl(i,o,r,n);case"Integer":return yield*ey(i,o,r,n);case"Intersect":return yield*ty(i,o,r,n);case"Iterator":return yield*ry(i,o,r,n);case"Literal":return yield*ny(i,o,r,n);case"Never":return yield*oy(i,o,r,n);case"Not":return yield*iy(i,o,r,n);case"Null":return yield*sy(i,o,r,n);case"Number":return yield*ay(i,o,r,n);case"Object":return yield*cy(i,o,r,n);case"Promise":return yield*uy(i,o,r,n);case"Record":return yield*fy(i,o,r,n);case"Ref":return yield*my(i,o,r,n);case"RegExp":return yield*dy(i,o,r,n);case"String":return yield*py(i,o,r,n);case"Symbol":return yield*ly(i,o,r,n);case"TemplateLiteral":return yield*yy(i,o,r,n);case"This":return yield*xy(i,o,r,n);case"Tuple":return yield*gy(i,o,r,n);case"Undefined":return yield*Iy(i,o,r,n);case"Union":return yield*hy(i,o,r,n);case"Uint8Array":return yield*by(i,o,r,n);case"Unknown":return yield*_y(i,o,r,n);case"Void":return yield*Oy(i,o,r,n);default:if(!Gn(i[y]))throw new ec(e);return yield*$y(i,o,r,n)}}function tc(...e){let t=e.length===3?Fe(e[0],e[1],"",e[2]):Fe(e[0],[],"",e[1]);return new Mi(t)}class Si extends v{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 rc extends v{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 ce(e,t,r){try{return D(e)?e[ie].Decode(r):r}catch(n){throw new rc(e,t,r,n)}}function Fy(e,t,r,n){return xe(n)?ce(e,r,n.map((o,i)=>_t(e.items,t,`${r}/${i}`,o))):ce(e,r,n)}function wy(e,t,r,n){if(!Ke(n)||Io(n))return ce(e,r,n);let o=So(e),i=o.map((g)=>g[0]),s={...n};for(let[g,R]of o)if(g in s)s[g]=_t(R,t,`${r}/${g}`,s[g]);if(!D(e.unevaluatedProperties))return ce(e,r,s);let a=Object.getOwnPropertyNames(s),f=e.unevaluatedProperties,l={...s};for(let g of a)if(!i.includes(g))l[g]=ce(f,`${r}/${g}`,l[g]);return ce(e,r,l)}function Ry(e,t,r,n){let o=globalThis.Object.values(e.$defs),i=e.$defs[e.$ref],s=_t(i,[...t,...o],r,n);return ce(e,r,s)}function Ty(e,t,r,n){return ce(e,r,_t(e.not,t,r,n))}function Ay(e,t,r,n){if(!Ke(n))return ce(e,r,n);let o=nt(e),i={...n};for(let l of o){if(!yo(i,l))continue;if(Se(i[l])&&(!Lt(e.properties[l])||ee.IsExactOptionalProperty(i,l)))continue;i[l]=_t(e.properties[l],t,`${r}/${l}`,i[l])}if(!se(e.additionalProperties))return ce(e,r,i);let s=Object.getOwnPropertyNames(i),a=e.additionalProperties,f={...i};for(let l of s)if(!o.includes(l))f[l]=ce(a,`${r}/${l}`,f[l]);return ce(e,r,f)}function ky(e,t,r,n){if(!Ke(n))return ce(e,r,n);let o=Object.getOwnPropertyNames(e.patternProperties)[0],i=new RegExp(o),s={...n};for(let g of Object.getOwnPropertyNames(n))if(i.test(g))s[g]=_t(e.patternProperties[o],t,`${r}/${g}`,s[g]);if(!se(e.additionalProperties))return ce(e,r,s);let a=Object.getOwnPropertyNames(s),f=e.additionalProperties,l={...s};for(let g of a)if(!i.test(g))l[g]=ce(f,`${r}/${g}`,l[g]);return ce(e,r,l)}function Ny(e,t,r,n){let o=Oe(e,t);return ce(e,r,_t(o,t,r,n))}function Py(e,t,r,n){let o=Oe(e,t);return ce(e,r,_t(o,t,r,n))}function Cy(e,t,r,n){return xe(n)&&xe(e.items)?ce(e,r,e.items.map((o,i)=>_t(o,t,`${r}/${i}`,n[i]))):ce(e,r,n)}function jy(e,t,r,n){for(let o of e.anyOf){if(!Cr(o,t,n))continue;let i=_t(o,t,r,n);return ce(e,r,i)}return ce(e,r,n)}function _t(e,t,r,n){let o=fr(e,t),i=e;switch(e[y]){case"Array":return Fy(i,o,r,n);case"Import":return Ry(i,o,r,n);case"Intersect":return wy(i,o,r,n);case"Not":return Ty(i,o,r,n);case"Object":return Ay(i,o,r,n);case"Record":return ky(i,o,r,n);case"Ref":return Ny(i,o,r,n);case"Symbol":return ce(i,r,n);case"This":return Py(i,o,r,n);case"Tuple":return Cy(i,o,r,n);case"Union":return jy(i,o,r,n);default:return ce(i,r,n)}}function nc(e,t,r){return _t(e,t,"",r)}class Ui extends v{constructor(e,t,r){super("The encoded value does not match the expected schema");this.schema=e,this.value=t,this.error=r}}class oc extends v{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 D(e)?e[ie].Encode(r):r}catch(n){throw new oc(e,t,r,n)}}function My(e,t,r,n){let o=Ae(e,r,n);return xe(o)?o.map((i,s)=>Ot(e.items,t,`${r}/${s}`,i)):o}function Sy(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 Uy(e,t,r,n){let o=Ae(e,r,n);if(!Ke(n)||Io(n))return o;let i=So(e),s=i.map((R)=>R[0]),a={...o};for(let[R,J]of i)if(R in a)a[R]=Ot(J,t,`${r}/${R}`,a[R]);if(!D(e.unevaluatedProperties))return a;let f=Object.getOwnPropertyNames(a),l=e.unevaluatedProperties,g={...a};for(let R of f)if(!s.includes(R))g[R]=Ae(l,`${r}/${R}`,g[R]);return g}function Ky(e,t,r,n){return Ae(e.not,r,Ae(e,r,n))}function Ey(e,t,r,n){let o=Ae(e,r,n);if(!Ke(o))return o;let i=nt(e),s={...o};for(let g of i){if(!yo(s,g))continue;if(Se(s[g])&&(!Lt(e.properties[g])||ee.IsExactOptionalProperty(s,g)))continue;s[g]=Ot(e.properties[g],t,`${r}/${g}`,s[g])}if(!se(e.additionalProperties))return s;let a=Object.getOwnPropertyNames(s),f=e.additionalProperties,l={...s};for(let g of a)if(!i.includes(g))l[g]=Ae(f,`${r}/${g}`,l[g]);return l}function Ly(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 R of Object.getOwnPropertyNames(n))if(s.test(R))a[R]=Ot(e.patternProperties[i],t,`${r}/${R}`,a[R]);if(!se(e.additionalProperties))return a;let f=Object.getOwnPropertyNames(a),l=e.additionalProperties,g={...a};for(let R of f)if(!s.test(R))g[R]=Ae(l,`${r}/${R}`,g[R]);return g}function By(e,t,r,n){let o=Oe(e,t),i=Ot(o,t,r,n);return Ae(e,r,i)}function Gy(e,t,r,n){let o=Oe(e,t),i=Ot(o,t,r,n);return Ae(e,r,i)}function Dy(e,t,r,n){let o=Ae(e,r,n);return xe(e.items)?e.items.map((i,s)=>Ot(i,t,`${r}/${s}`,o[s])):[]}function vy(e,t,r,n){for(let o of e.anyOf){if(!Cr(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(!Cr(e,t,i))continue;return Ae(e,r,i)}return Ae(e,r,n)}function Ot(e,t,r,n){let o=fr(e,t),i=e;switch(e[y]){case"Array":return My(i,o,r,n);case"Import":return Sy(i,o,r,n);case"Intersect":return Uy(i,o,r,n);case"Not":return Ky(i,o,r,n);case"Object":return Ey(i,o,r,n);case"Record":return Ly(i,o,r,n);case"Ref":return By(i,o,r,n);case"This":return Gy(i,o,r,n);case"Tuple":return Dy(i,o,r,n);case"Union":return vy(i,o,r,n);default:return Ae(i,r,n)}}function ic(e,t,r){return Ot(e,t,"",r)}function qy(e,t){return D(e)||he(e.items,t)}function Vy(e,t){return D(e)||he(e.items,t)}function Hy(e,t){return D(e)||he(e.returns,t)||e.parameters.some((r)=>he(r,t))}function zy(e,t){return D(e)||he(e.returns,t)||e.parameters.some((r)=>he(r,t))}function Wy(e,t){return D(e)||D(e.unevaluatedProperties)||e.allOf.some((r)=>he(r,t))}function Jy(e,t){let r=globalThis.Object.getOwnPropertyNames(e.$defs).reduce((o,i)=>[...o,e.$defs[i]],[]),n=e.$defs[e.$ref];return D(e)||he(n,[...r,...t])}function Yy(e,t){return D(e)||he(e.items,t)}function Qy(e,t){return D(e)||he(e.not,t)}function Xy(e,t){return D(e)||Object.values(e.properties).some((r)=>he(r,t))||se(e.additionalProperties)&&he(e.additionalProperties,t)}function Zy(e,t){return D(e)||he(e.item,t)}function ex(e,t){let r=Object.getOwnPropertyNames(e.patternProperties)[0],n=e.patternProperties[r];return D(e)||he(n,t)||se(e.additionalProperties)&&D(e.additionalProperties)}function tx(e,t){if(D(e))return!0;return he(Oe(e,t),t)}function rx(e,t){if(D(e))return!0;return he(Oe(e,t),t)}function nx(e,t){return D(e)||!Se(e.items)&&e.items.some((r)=>he(r,t))}function ox(e,t){return D(e)||e.anyOf.some((r)=>he(r,t))}function he(e,t){let r=fr(e,t),n=e;if(e.$id&&Ki.has(e.$id))return!1;if(e.$id)Ki.add(e.$id);switch(e[y]){case"Array":return qy(n,r);case"AsyncIterator":return Vy(n,r);case"Constructor":return Hy(n,r);case"Function":return zy(n,r);case"Import":return Jy(n,r);case"Intersect":return Wy(n,r);case"Iterator":return Yy(n,r);case"Not":return Qy(n,r);case"Object":return Xy(n,r);case"Promise":return Zy(n,r);case"Record":return ex(n,r);case"Ref":return tx(n,r);case"This":return rx(n,r);case"Tuple":return nx(n,r);case"Union":return ox(n,r);default:return D(e)}}var Ki=new Set;function sc(e,t){return Ki.clear(),he(e,t)}class ac{constructor(e,t,r,n){this.schema=e,this.references=t,this.checkFunc=r,this.code=n,this.hasTransform=sc(e,t)}Code(){return this.code}Schema(){return this.schema}References(){return this.references}Errors(e){return tc(this.schema,this.references,e)}Check(e){return this.checkFunc(e)}Decode(e){if(!this.checkFunc(e))throw new Si(this.schema,e,this.Errors(e).First());return this.hasTransform?nc(this.schema,this.references,e):e}Encode(e){let t=this.hasTransform?ic(this.schema,this.references,e):e;if(!this.checkFunc(t))throw new Ui(this.schema,e,this.Errors(e).First());return t}}var zt;(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})(zt||(zt={}));var Yo;(function(e){function t(i){if(i.length===0)return!1;return zt.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(!(zt.IsAlpha(a)||zt.IsNumeric(a)||zt.DollarSign(a)||zt.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})(Yo||(Yo={}));var Ei;(function(e){function t(r){let n=[];for(let o=0;o<r.length;o++){let i=r.charCodeAt(o);if(zt.IsNumeric(i)||zt.IsAlpha(i))n.push(r.charAt(o));else n.push(`_${i}_`)}return n.join("").replace(/__/g,"_")}e.Encode=t})(Ei||(Ei={}));var Li;(function(e){function t(r){return r.replace(/'/g,"\\'")}e.Escape=t})(Li||(Li={}));class cc extends v{constructor(e){super("Unknown type");this.schema=e}}class Bi extends v{constructor(e){super("Preflight validation check failed to guard for the given schema");this.schema=e}}var jr;(function(e){function t(s,a,f){return ee.ExactOptionalPropertyTypes?`('${a}' in ${s} ? ${f} : true)`:`(${Yo.Encode(s,a)} !== undefined ? ${f} : true)`}e.IsExactOptionalProperty=t;function r(s){return!ee.AllowArrayObject?`(typeof ${s} === 'object' && ${s} !== null && !Array.isArray(${s}))`:`(typeof ${s} === 'object' && ${s} !== null)`}e.IsObjectLike=r;function n(s){return!ee.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 ee.AllowNaN?`typeof ${s} === 'number'`:`Number.isFinite(${s})`}e.IsNumberLike=o;function i(s){return ee.AllowNullVoid?`(${s} === undefined || ${s} === null)`:`${s} === undefined`}e.IsVoidLike=i})(jr||(jr={}));var Qo;(function(e){function t(c){return c[y]==="Any"||c[y]==="Unknown"}function*r(c,b,u){yield"true"}function*n(c,b,u){yield"true"}function*o(c,b,u){yield`Array.isArray(${u})`;let[k,O]=[io("value","any"),io("acc","number")];if(N(c.maxItems))yield`${u}.length <= ${c.maxItems}`;if(N(c.minItems))yield`${u}.length >= ${c.minItems}`;let F=at(c.items,b,"value");if(yield`${u}.every((${k}) => ${F})`,ae(c.contains)||N(c.minContains)||N(c.maxContains)){let Q=ae(c.contains)?c.contains:j(),Ue=at(Q,b,"value"),Ut=N(c.minContains)?[`(count >= ${c.minContains})`]:[],ct=N(c.maxContains)?[`(count <= ${c.maxContains})`]:[],At=`const count = value.reduce((${O}, ${k}) => ${Ue} ? acc + 1 : acc, 0)`,so=["(count > 0)",...Ut,...ct].join(" && ");yield`((${k}) => { ${At}; return ${so}})(${u})`}if(c.uniqueItems===!0)yield`((${k}) => { 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 } )(${u})`}function*i(c,b,u){yield`(typeof value === 'object' && Symbol.asyncIterator in ${u})`}function*s(c,b,u){if(yield`(typeof ${u} === 'bigint')`,He(c.exclusiveMaximum))yield`${u} < BigInt(${c.exclusiveMaximum})`;if(He(c.exclusiveMinimum))yield`${u} > BigInt(${c.exclusiveMinimum})`;if(He(c.maximum))yield`${u} <= BigInt(${c.maximum})`;if(He(c.minimum))yield`${u} >= BigInt(${c.minimum})`;if(He(c.multipleOf))yield`(${u} % BigInt(${c.multipleOf})) === 0`}function*a(c,b,u){yield`(typeof ${u} === 'boolean')`}function*f(c,b,u){yield*Br(c.returns,b,`${u}.prototype`)}function*l(c,b,u){if(yield`(${u} instanceof Date) && Number.isFinite(${u}.getTime())`,N(c.exclusiveMaximumTimestamp))yield`${u}.getTime() < ${c.exclusiveMaximumTimestamp}`;if(N(c.exclusiveMinimumTimestamp))yield`${u}.getTime() > ${c.exclusiveMinimumTimestamp}`;if(N(c.maximumTimestamp))yield`${u}.getTime() <= ${c.maximumTimestamp}`;if(N(c.minimumTimestamp))yield`${u}.getTime() >= ${c.minimumTimestamp}`;if(N(c.multipleOfTimestamp))yield`(${u}.getTime() % ${c.multipleOfTimestamp}) === 0`}function*g(c,b,u){yield`(typeof ${u} === 'function')`}function*R(c,b,u){let k=globalThis.Object.getOwnPropertyNames(c.$defs).reduce((O,F)=>[...O,c.$defs[F]],[]);yield*Br(rt(c.$ref),[...b,...k],u)}function*J(c,b,u){if(yield`Number.isInteger(${u})`,N(c.exclusiveMaximum))yield`${u} < ${c.exclusiveMaximum}`;if(N(c.exclusiveMinimum))yield`${u} > ${c.exclusiveMinimum}`;if(N(c.maximum))yield`${u} <= ${c.maximum}`;if(N(c.minimum))yield`${u} >= ${c.minimum}`;if(N(c.multipleOf))yield`(${u} % ${c.multipleOf}) === 0`}function*be(c,b,u){let k=c.allOf.map((O)=>at(O,b,u)).join(" && ");if(c.unevaluatedProperties===!1){let O=Gr(`${new RegExp(qt(c))};`),F=`Object.getOwnPropertyNames(${u}).every(key => ${O}.test(key))`;yield`(${k} && ${F})`}else if(ae(c.unevaluatedProperties)){let O=Gr(`${new RegExp(qt(c))};`),F=`Object.getOwnPropertyNames(${u}).every(key => ${O}.test(key) || ${at(c.unevaluatedProperties,b,`${u}[key]`)})`;yield`(${k} && ${F})`}else yield`(${k})`}function*P(c,b,u){yield`(typeof value === 'object' && Symbol.iterator in ${u})`}function*qe(c,b,u){if(typeof c.const==="number"||typeof c.const==="boolean")yield`(${u} === ${c.const})`;else yield`(${u} === '${Li.Escape(c.const)}')`}function*no(c,b,u){yield"false"}function*Pn(c,b,u){yield`(!${at(c.not,b,u)})`}function*st(c,b,u){yield`(${u} === null)`}function*Cn(c,b,u){if(yield jr.IsNumberLike(u),N(c.exclusiveMaximum))yield`${u} < ${c.exclusiveMaximum}`;if(N(c.exclusiveMinimum))yield`${u} > ${c.exclusiveMinimum}`;if(N(c.maximum))yield`${u} <= ${c.maximum}`;if(N(c.minimum))yield`${u} >= ${c.minimum}`;if(N(c.multipleOf))yield`(${u} % ${c.multipleOf}) === 0`}function*Ac(c,b,u){if(yield jr.IsObjectLike(u),N(c.minProperties))yield`Object.getOwnPropertyNames(${u}).length >= ${c.minProperties}`;if(N(c.maxProperties))yield`Object.getOwnPropertyNames(${u}).length <= ${c.maxProperties}`;let k=Object.getOwnPropertyNames(c.properties);for(let O of k){let F=Yo.Encode(u,O),Q=c.properties[O];if(c.required&&c.required.includes(O)){if(yield*Br(Q,b,F),Vt(Q)||t(Q))yield`('${O}' in ${u})`}else{let Ue=at(Q,b,F);yield jr.IsExactOptionalProperty(u,O,Ue)}}if(c.additionalProperties===!1)if(c.required&&c.required.length===k.length)yield`Object.getOwnPropertyNames(${u}).length === ${k.length}`;else{let O=`[${k.map((F)=>`'${F}'`).join(", ")}]`;yield`Object.getOwnPropertyNames(${u}).every(key => ${O}.includes(key))`}if(typeof c.additionalProperties==="object"){let O=at(c.additionalProperties,b,`${u}[key]`),F=`[${k.map((Q)=>`'${Q}'`).join(", ")}]`;yield`(Object.getOwnPropertyNames(${u}).every(key => ${F}.includes(key) || ${O}))`}}function*kc(c,b,u){yield`${u} instanceof Promise`}function*Nc(c,b,u){if(yield jr.IsRecordLike(u),N(c.minProperties))yield`Object.getOwnPropertyNames(${u}).length >= ${c.minProperties}`;if(N(c.maxProperties))yield`Object.getOwnPropertyNames(${u}).length <= ${c.maxProperties}`;let[k,O]=Object.entries(c.patternProperties)[0],F=Gr(`${new RegExp(k)}`),Q=at(O,b,"value"),Ue=ae(c.additionalProperties)?at(c.additionalProperties,b,u):c.additionalProperties===!1?"false":"true",Ut=`(${F}.test(key) ? ${Q} : ${Ue})`;yield`(Object.entries(${u}).every(([key, value]) => ${Ut}))`}function*Pc(c,b,u){let k=Oe(c,b);if(we.functions.has(c.$ref))return yield`${oo(c.$ref)}(${u})`;yield*Br(k,b,u)}function*Cc(c,b,u){let k=Gr(`${new RegExp(c.source,c.flags)};`);if(yield`(typeof ${u} === 'string')`,N(c.maxLength))yield`${u}.length <= ${c.maxLength}`;if(N(c.minLength))yield`${u}.length >= ${c.minLength}`;yield`${k}.test(${u})`}function*jc(c,b,u){if(yield`(typeof ${u} === 'string')`,N(c.maxLength))yield`${u}.length <= ${c.maxLength}`;if(N(c.minLength))yield`${u}.length >= ${c.minLength}`;if(c.pattern!==void 0)yield`${Gr(`${new RegExp(c.pattern)};`)}.test(${u})`;if(c.format!==void 0)yield`format('${c.format}', ${u})`}function*Mc(c,b,u){yield`(typeof ${u} === 'symbol')`}function*Sc(c,b,u){yield`(typeof ${u} === 'string')`,yield`${Gr(`${new RegExp(c.pattern)};`)}.test(${u})`}function*Uc(c,b,u){yield`${oo(c.$ref)}(${u})`}function*Kc(c,b,u){if(yield`Array.isArray(${u})`,c.items===void 0)return yield`${u}.length === 0`;yield`(${u}.length === ${c.maxItems})`;for(let k=0;k<c.items.length;k++)yield`${at(c.items[k],b,`${u}[${k}]`)}`}function*Ec(c,b,u){yield`${u} === undefined`}function*Lc(c,b,u){yield`(${c.anyOf.map((O)=>at(O,b,u)).join(" || ")})`}function*Bc(c,b,u){if(yield`${u} instanceof Uint8Array`,N(c.maxByteLength))yield`(${u}.length <= ${c.maxByteLength})`;if(N(c.minByteLength))yield`(${u}.length >= ${c.minByteLength})`}function*Gc(c,b,u){yield"true"}function*Dc(c,b,u){yield jr.IsVoidLike(u)}function*vc(c,b,u){let k=we.instances.size;we.instances.set(k,c),yield`kind('${c[y]}', ${k}, ${u})`}function*Br(c,b,u,k=!0){let O=_e(c.$id)?[...b,c]:b,F=c;if(k&&_e(c.$id)){let Q=oo(c.$id);if(we.functions.has(Q))return yield`${Q}(${u})`;else{we.functions.set(Q,"<deferred>");let Ue=Hi(Q,c,b,"value",!1);return we.functions.set(Q,Ue),yield`${Q}(${u})`}}switch(F[y]){case"Any":return yield*r(F,O,u);case"Argument":return yield*n(F,O,u);case"Array":return yield*o(F,O,u);case"AsyncIterator":return yield*i(F,O,u);case"BigInt":return yield*s(F,O,u);case"Boolean":return yield*a(F,O,u);case"Constructor":return yield*f(F,O,u);case"Date":return yield*l(F,O,u);case"Function":return yield*g(F,O,u);case"Import":return yield*R(F,O,u);case"Integer":return yield*J(F,O,u);case"Intersect":return yield*be(F,O,u);case"Iterator":return yield*P(F,O,u);case"Literal":return yield*qe(F,O,u);case"Never":return yield*no(F,O,u);case"Not":return yield*Pn(F,O,u);case"Null":return yield*st(F,O,u);case"Number":return yield*Cn(F,O,u);case"Object":return yield*Ac(F,O,u);case"Promise":return yield*kc(F,O,u);case"Record":return yield*Nc(F,O,u);case"Ref":return yield*Pc(F,O,u);case"RegExp":return yield*Cc(F,O,u);case"String":return yield*jc(F,O,u);case"Symbol":return yield*Mc(F,O,u);case"TemplateLiteral":return yield*Sc(F,O,u);case"This":return yield*Uc(F,O,u);case"Tuple":return yield*Kc(F,O,u);case"Undefined":return yield*Ec(F,O,u);case"Union":return yield*Lc(F,O,u);case"Uint8Array":return yield*Bc(F,O,u);case"Unknown":return yield*Gc(F,O,u);case"Void":return yield*Dc(F,O,u);default:if(!Gn(F[y]))throw new cc(c);return yield*vc(F,O,u)}}let we={language:"javascript",functions:new Map,variables:new Map,instances:new Map};function at(c,b,u,k=!0){return`(${[...Br(c,b,u,k)].join(" && ")})`}function oo(c){return`check_${Ei.Encode(c)}`}function Gr(c){let b=`local_${we.variables.size}`;return we.variables.set(b,`const ${b} = ${c}`),b}function Hi(c,b,u,k,O=!0){let[F,Q]=[`
129
- `,(At)=>"".padStart(At," ")],Ue=io("value","any"),Ut=zi("boolean"),ct=[...Br(b,u,k,O)].map((At)=>`${Q(4)}${At}`).join(` &&${F}`);return`function ${c}(${Ue})${Ut} {${F}${Q(2)}return (${F}${ct}${F}${Q(2)})
130
- }`}function io(c,b){let u=we.language==="typescript"?`: ${b}`:"";return`${c}${u}`}function zi(c){return we.language==="typescript"?`: ${c}`:""}function qc(c,b,u){let k=Hi("check",c,b,"value"),O=io("value","any"),F=zi("boolean"),Q=[...we.functions.values()],Ue=[...we.variables.values()],Ut=_e(c.$id)?`return function check(${O})${F} {
131
- return ${oo(c.$id)}(value)
132
- }`:`return ${k}`;return[...Ue,...Q,Ut].join(`
133
- `)}function Wi(...c){let b={language:"javascript"},[u,k,O]=c.length===2&&xe(c[1])?[c[0],c[1],b]:c.length===2&&!xe(c[1])?[c[0],[],c[1]]:c.length===3?[c[0],c[1],c[2]]:c.length===1?[c[0],[],b]:[null,[],b];if(we.language=O.language,we.variables.clear(),we.functions.clear(),we.instances.clear(),!ae(u))throw new Bi(u);for(let F of k)if(!ae(F))throw new Bi(F);return qc(u,k,O)}e.Code=Wi;function Vc(c,b=[]){let u=Wi(c,b,{language:"javascript"}),k=globalThis.Function("kind","format","hash",u),O=new Map(we.instances);function F(ct,At,so){if(!Gn(ct)||!O.has(At))return!1;let Hc=xi(ct),zc=O.get(At);return Hc(zc,so)}function Q(ct,At){if(!li(ct))return!1;return yi(ct)(At)}function Ue(ct){return yn(ct)}let Ut=k(F,Q,Ue);return new ac(c,b,Ut,u)}e.Compile=Vc})(Qo||(Qo={}));var K;(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}})(K||(K={}));var Gi;(function(e){e.mergeShapes=(t,r)=>({...t,...r})})(Gi||(Gi={}));var _=K.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),jt=(e)=>{switch(typeof e){case"undefined":return _.undefined;case"string":return _.string;case"number":return Number.isNaN(e)?_.nan:_.number;case"boolean":return _.boolean;case"function":return _.function;case"bigint":return _.bigint;case"symbol":return _.symbol;case"object":if(Array.isArray(e))return _.array;if(e===null)return _.null;if(e.then&&typeof e.then==="function"&&e.catch&&typeof e.catch==="function")return _.promise;if(typeof Map<"u"&&e instanceof Map)return _.map;if(typeof Set<"u"&&e instanceof Set)return _.set;if(typeof Date<"u"&&e instanceof Date)return _.date;return _.object;default:return _.unknown}};var x=K.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"]),ix=(e)=>JSON.stringify(e,null,2).replace(/"([^"]+)":/g,"$1:");class ve 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 f=i.path[a];if(a!==i.path.length-1)s[f]=s[f]||{_errors:[]};else s[f]=s[f]||{_errors:[]},s[f]._errors.push(t(i));s=s[f],a++}}};return n(this),r}static assert(e){if(!(e instanceof ve))throw Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,K.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()}}ve.create=(e)=>new ve(e);var sx=(e,t)=>{let r;switch(e.code){case x.invalid_type:if(e.received===_.undefined)r="Required";else r=`Expected ${e.expected}, received ${e.received}`;break;case x.invalid_literal:r=`Invalid literal value, expected ${JSON.stringify(e.expected,K.jsonStringifyReplacer)}`;break;case x.unrecognized_keys:r=`Unrecognized key(s) in object: ${K.joinValues(e.keys,", ")}`;break;case x.invalid_union:r="Invalid input";break;case x.invalid_union_discriminator:r=`Invalid discriminator value. Expected ${K.joinValues(e.options)}`;break;case x.invalid_enum_value:r=`Invalid enum value. Expected ${K.joinValues(e.options)}, received '${e.received}'`;break;case x.invalid_arguments:r="Invalid function arguments";break;case x.invalid_return_type:r="Invalid function return type";break;case x.invalid_date:r="Invalid date";break;case x.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 K.assertNever(e.validation);else if(e.validation!=="regex")r=`Invalid ${e.validation}`;else r="Invalid";break;case x.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 x.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 x.custom:r="Invalid input";break;case x.invalid_intersection_types:r="Intersection results could not be merged";break;case x.not_multiple_of:r=`Number must be a multiple of ${e.multipleOf}`;break;case x.not_finite:r="Number must be finite";break;default:r=t.defaultError,K.assertNever(e)}return{message:r}},Wt=sx;var uc=Wt;function ax(e){uc=e}function xn(){return uc}var Yn=(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="",f=n.filter((l)=>!!l).slice().reverse();for(let l of f)a=l(s,{data:t,defaultError:a}).message;return{...o,path:i,message:a}},cx=[];function I(e,t){let r=xn(),n=Yn({issueData:t,data:e.data,path:e.path,errorMaps:[e.common.contextualErrorMap,e.schemaErrorMap,r,r===Wt?void 0:Wt].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"}),Mr=(e)=>({status:"dirty",value:e}),Me=(e)=>({status:"valid",value:e}),Xo=(e)=>e.status==="aborted",Zo=(e)=>e.status==="dirty",mr=(e)=>e.status==="valid",gn=(e)=>typeof Promise<"u"&&e instanceof Promise;var w;(function(e){e.errToObj=(t)=>typeof t==="string"?{message:t}:t||{},e.toString=(t)=>typeof t==="string"?t:t?.message})(w||(w={}));class Rt{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 fc=(e,t)=>{if(mr(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 ve(e.common.issues);return this._error=r,this._error}}}};function C(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:f}=e;if(s.code==="invalid_enum_value")return{message:f??a.defaultError};if(typeof a.data>"u")return{message:f??n??a.defaultError};if(s.code!=="invalid_type")return{message:a.defaultError};return{message:f??r??a.defaultError}},description:o}}class M{get description(){return this._def.description}_getType(e){return jt(e.data)}_getOrReturnCtx(e,t){return t||{common:e.parent.common,data:e.data,parsedType:jt(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:jt(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){let t=this._parse(e);if(gn(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:jt(e)},n=this._parseSync({data:e,path:r.path,parent:r});return fc(r,n)}"~validate"(e){let t={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:jt(e)};if(!this["~standard"].async)try{let r=this._parseSync({data:e,path:[],parent:t});return mr(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)=>mr(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:jt(e)},n=this._parse({data:e,path:r.path,parent:r}),o=await(gn(n)?n:Promise.resolve(n));return fc(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:x.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 Tt({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 Yt.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return Ft.create(this)}promise(){return Er.create(this,this._def)}or(e){return $n.create([this,e],this._def)}and(e){return Fn.create(this,e,this._def)}transform(e){return new Tt({...C(this._def),schema:this,typeName:A.ZodEffects,effect:{type:"transform",transform:e}})}default(e){let t=typeof e==="function"?e:()=>e;return new An({...C(this._def),innerType:this,defaultValue:t,typeName:A.ZodDefault})}brand(){return new ti({typeName:A.ZodBranded,type:this,...C(this._def)})}catch(e){let t=typeof e==="function"?e:()=>e;return new kn({...C(this._def),innerType:this,catchValue:t,typeName:A.ZodCatch})}describe(e){return new this.constructor({...this._def,description:e})}pipe(e){return ro.create(this,e)}readonly(){return Nn.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}var ux=/^c[^\s-]{8,}$/i,fx=/^[0-9a-z]+$/,mx=/^[0-9A-HJKMNP-TV-Z]{26}$/i,dx=/^[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,px=/^[a-z0-9_-]{21}$/i,lx=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,yx=/^[-+]?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)?)??$/,xx=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,gx="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$",Di,Ix=/^(?:(?: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])$/,hx=/^(?:(?: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])$/,bx=/^(([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]))$/,_x=/^(([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])$/,Ox=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,$x=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,dc="((\\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])))",Fx=new RegExp(`^${dc}$`);function pc(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 wx(e){return new RegExp(`^${pc(e)}$`)}function lc(e){let t=`${dc}T${pc(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 Rx(e,t){if((t==="v4"||!t)&&Ix.test(e))return!0;if((t==="v6"||!t)&&bx.test(e))return!0;return!1}function Tx(e,t){if(!lx.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 Ax(e,t){if((t==="v4"||!t)&&hx.test(e))return!0;if((t==="v6"||!t)&&_x.test(e))return!0;return!1}class $t extends M{_parse(e){if(this._def.coerce)e.data=String(e.data);if(this._getType(e)!==_.string){let o=this._getOrReturnCtx(e);return I(o,{code:x.invalid_type,expected:_.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),I(n,{code:x.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),I(n,{code:x.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)I(n,{code:x.too_big,maximum:o.value,type:"string",inclusive:!0,exact:!0,message:o.message});else if(s)I(n,{code:x.too_small,minimum:o.value,type:"string",inclusive:!0,exact:!0,message:o.message});r.dirty()}}else if(o.kind==="email"){if(!xx.test(e.data))n=this._getOrReturnCtx(e,n),I(n,{validation:"email",code:x.invalid_string,message:o.message}),r.dirty()}else if(o.kind==="emoji"){if(!Di)Di=new RegExp(gx,"u");if(!Di.test(e.data))n=this._getOrReturnCtx(e,n),I(n,{validation:"emoji",code:x.invalid_string,message:o.message}),r.dirty()}else if(o.kind==="uuid"){if(!dx.test(e.data))n=this._getOrReturnCtx(e,n),I(n,{validation:"uuid",code:x.invalid_string,message:o.message}),r.dirty()}else if(o.kind==="nanoid"){if(!px.test(e.data))n=this._getOrReturnCtx(e,n),I(n,{validation:"nanoid",code:x.invalid_string,message:o.message}),r.dirty()}else if(o.kind==="cuid"){if(!ux.test(e.data))n=this._getOrReturnCtx(e,n),I(n,{validation:"cuid",code:x.invalid_string,message:o.message}),r.dirty()}else if(o.kind==="cuid2"){if(!fx.test(e.data))n=this._getOrReturnCtx(e,n),I(n,{validation:"cuid2",code:x.invalid_string,message:o.message}),r.dirty()}else if(o.kind==="ulid"){if(!mx.test(e.data))n=this._getOrReturnCtx(e,n),I(n,{validation:"ulid",code:x.invalid_string,message:o.message}),r.dirty()}else if(o.kind==="url")try{new URL(e.data)}catch{n=this._getOrReturnCtx(e,n),I(n,{validation:"url",code:x.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),I(n,{validation:"regex",code:x.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),I(n,{code:x.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),I(n,{code:x.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),I(n,{code:x.invalid_string,validation:{endsWith:o.value},message:o.message}),r.dirty()}else if(o.kind==="datetime"){if(!lc(o).test(e.data))n=this._getOrReturnCtx(e,n),I(n,{code:x.invalid_string,validation:"datetime",message:o.message}),r.dirty()}else if(o.kind==="date"){if(!Fx.test(e.data))n=this._getOrReturnCtx(e,n),I(n,{code:x.invalid_string,validation:"date",message:o.message}),r.dirty()}else if(o.kind==="time"){if(!wx(o).test(e.data))n=this._getOrReturnCtx(e,n),I(n,{code:x.invalid_string,validation:"time",message:o.message}),r.dirty()}else if(o.kind==="duration"){if(!yx.test(e.data))n=this._getOrReturnCtx(e,n),I(n,{validation:"duration",code:x.invalid_string,message:o.message}),r.dirty()}else if(o.kind==="ip"){if(!Rx(e.data,o.version))n=this._getOrReturnCtx(e,n),I(n,{validation:"ip",code:x.invalid_string,message:o.message}),r.dirty()}else if(o.kind==="jwt"){if(!Tx(e.data,o.alg))n=this._getOrReturnCtx(e,n),I(n,{validation:"jwt",code:x.invalid_string,message:o.message}),r.dirty()}else if(o.kind==="cidr"){if(!Ax(e.data,o.version))n=this._getOrReturnCtx(e,n),I(n,{validation:"cidr",code:x.invalid_string,message:o.message}),r.dirty()}else if(o.kind==="base64"){if(!Ox.test(e.data))n=this._getOrReturnCtx(e,n),I(n,{validation:"base64",code:x.invalid_string,message:o.message}),r.dirty()}else if(o.kind==="base64url"){if(!$x.test(e.data))n=this._getOrReturnCtx(e,n),I(n,{validation:"base64url",code:x.invalid_string,message:o.message}),r.dirty()}else K.assertNever(o);return{status:r.value,value:e.data}}_regex(e,t,r){return this.refinement((n)=>e.test(n),{validation:t,code:x.invalid_string,...w.errToObj(r)})}_addCheck(e){return new $t({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...w.errToObj(e)})}url(e){return this._addCheck({kind:"url",...w.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...w.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...w.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",...w.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...w.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...w.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...w.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",...w.errToObj(e)})}base64url(e){return this._addCheck({kind:"base64url",...w.errToObj(e)})}jwt(e){return this._addCheck({kind:"jwt",...w.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...w.errToObj(e)})}cidr(e){return this._addCheck({kind:"cidr",...w.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,...w.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,...w.errToObj(e?.message)})}duration(e){return this._addCheck({kind:"duration",...w.errToObj(e)})}regex(e,t){return this._addCheck({kind:"regex",regex:e,...w.errToObj(t)})}includes(e,t){return this._addCheck({kind:"includes",value:e,position:t?.position,...w.errToObj(t?.message)})}startsWith(e,t){return this._addCheck({kind:"startsWith",value:e,...w.errToObj(t)})}endsWith(e,t){return this._addCheck({kind:"endsWith",value:e,...w.errToObj(t)})}min(e,t){return this._addCheck({kind:"min",value:e,...w.errToObj(t)})}max(e,t){return this._addCheck({kind:"max",value:e,...w.errToObj(t)})}length(e,t){return this._addCheck({kind:"length",value:e,...w.errToObj(t)})}nonempty(e){return this.min(1,w.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,...C(e)});function kx(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 pr extends M{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)!==_.number){let o=this._getOrReturnCtx(e);return I(o,{code:x.invalid_type,expected:_.number,received:o.parsedType}),T}let r=void 0,n=new ke;for(let o of this._def.checks)if(o.kind==="int"){if(!K.isInteger(e.data))r=this._getOrReturnCtx(e,r),I(r,{code:x.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),I(r,{code:x.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),I(r,{code:x.too_big,maximum:o.value,type:"number",inclusive:o.inclusive,exact:!1,message:o.message}),n.dirty()}else if(o.kind==="multipleOf"){if(kx(e.data,o.value)!==0)r=this._getOrReturnCtx(e,r),I(r,{code:x.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),I(r,{code:x.not_finite,message:o.message}),n.dirty()}else K.assertNever(o);return{status:n.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,w.toString(t))}gt(e,t){return this.setLimit("min",e,!1,w.toString(t))}lte(e,t){return this.setLimit("max",e,!0,w.toString(t))}lt(e,t){return this.setLimit("max",e,!1,w.toString(t))}setLimit(e,t,r,n){return new pr({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:r,message:w.toString(n)}]})}_addCheck(e){return new pr({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:w.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:w.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:w.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:w.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:w.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:w.toString(t)})}finite(e){return this._addCheck({kind:"finite",message:w.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:w.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:w.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"&&K.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)}}pr.create=(e)=>new pr({checks:[],typeName:A.ZodNumber,coerce:e?.coerce||!1,...C(e)});class lr extends M{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)!==_.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),I(r,{code:x.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),I(r,{code:x.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),I(r,{code:x.not_multiple_of,multipleOf:o.value,message:o.message}),n.dirty()}else K.assertNever(o);return{status:n.value,value:e.data}}_getInvalidInput(e){let t=this._getOrReturnCtx(e);return I(t,{code:x.invalid_type,expected:_.bigint,received:t.parsedType}),T}gte(e,t){return this.setLimit("min",e,!0,w.toString(t))}gt(e,t){return this.setLimit("min",e,!1,w.toString(t))}lte(e,t){return this.setLimit("max",e,!0,w.toString(t))}lt(e,t){return this.setLimit("max",e,!1,w.toString(t))}setLimit(e,t,r,n){return new lr({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:r,message:w.toString(n)}]})}_addCheck(e){return new lr({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:w.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:w.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:w.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:w.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:w.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}}lr.create=(e)=>new lr({checks:[],typeName:A.ZodBigInt,coerce:e?.coerce??!1,...C(e)});class bn extends M{_parse(e){if(this._def.coerce)e.data=Boolean(e.data);if(this._getType(e)!==_.boolean){let r=this._getOrReturnCtx(e);return I(r,{code:x.invalid_type,expected:_.boolean,received:r.parsedType}),T}return Me(e.data)}}bn.create=(e)=>new bn({typeName:A.ZodBoolean,coerce:e?.coerce||!1,...C(e)});class Sr extends M{_parse(e){if(this._def.coerce)e.data=new Date(e.data);if(this._getType(e)!==_.date){let o=this._getOrReturnCtx(e);return I(o,{code:x.invalid_type,expected:_.date,received:o.parsedType}),T}if(Number.isNaN(e.data.getTime())){let o=this._getOrReturnCtx(e);return I(o,{code:x.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),I(n,{code:x.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),I(n,{code:x.too_big,message:o.message,inclusive:!0,exact:!1,maximum:o.value,type:"date"}),r.dirty()}else K.assertNever(o);return{status:r.value,value:new Date(e.data.getTime())}}_addCheck(e){return new Sr({...this._def,checks:[...this._def.checks,e]})}min(e,t){return this._addCheck({kind:"min",value:e.getTime(),message:w.toString(t)})}max(e,t){return this._addCheck({kind:"max",value:e.getTime(),message:w.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}}Sr.create=(e)=>new Sr({checks:[],coerce:e?.coerce||!1,typeName:A.ZodDate,...C(e)});class Qn extends M{_parse(e){if(this._getType(e)!==_.symbol){let r=this._getOrReturnCtx(e);return I(r,{code:x.invalid_type,expected:_.symbol,received:r.parsedType}),T}return Me(e.data)}}Qn.create=(e)=>new Qn({typeName:A.ZodSymbol,...C(e)});class _n extends M{_parse(e){if(this._getType(e)!==_.undefined){let r=this._getOrReturnCtx(e);return I(r,{code:x.invalid_type,expected:_.undefined,received:r.parsedType}),T}return Me(e.data)}}_n.create=(e)=>new _n({typeName:A.ZodUndefined,...C(e)});class On extends M{_parse(e){if(this._getType(e)!==_.null){let r=this._getOrReturnCtx(e);return I(r,{code:x.invalid_type,expected:_.null,received:r.parsedType}),T}return Me(e.data)}}On.create=(e)=>new On({typeName:A.ZodNull,...C(e)});class Ur extends M{constructor(){super(...arguments);this._any=!0}_parse(e){return Me(e.data)}}Ur.create=(e)=>new Ur({typeName:A.ZodAny,...C(e)});class dr extends M{constructor(){super(...arguments);this._unknown=!0}_parse(e){return Me(e.data)}}dr.create=(e)=>new dr({typeName:A.ZodUnknown,...C(e)});class Mt extends M{_parse(e){let t=this._getOrReturnCtx(e);return I(t,{code:x.invalid_type,expected:_.never,received:t.parsedType}),T}}Mt.create=(e)=>new Mt({typeName:A.ZodNever,...C(e)});class Xn extends M{_parse(e){if(this._getType(e)!==_.undefined){let r=this._getOrReturnCtx(e);return I(r,{code:x.invalid_type,expected:_.void,received:r.parsedType}),T}return Me(e.data)}}Xn.create=(e)=>new Xn({typeName:A.ZodVoid,...C(e)});class Ft extends M{_parse(e){let{ctx:t,status:r}=this._processInputParams(e),n=this._def;if(t.parsedType!==_.array)return I(t,{code:x.invalid_type,expected:_.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)I(t,{code:i?x.too_big:x.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)I(t,{code:x.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)I(t,{code:x.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 Rt(t,i,t.path,s)))).then((i)=>ke.mergeArray(r,i));let o=[...t.data].map((i,s)=>n.type._parseSync(new Rt(t,i,t.path,s)));return ke.mergeArray(r,o)}get element(){return this._def.type}min(e,t){return new Ft({...this._def,minLength:{value:e,message:w.toString(t)}})}max(e,t){return new Ft({...this._def,maxLength:{value:e,message:w.toString(t)}})}length(e,t){return new Ft({...this._def,exactLength:{value:e,message:w.toString(t)}})}nonempty(e){return this.min(1,e)}}Ft.create=(e,t)=>new Ft({type:e,minLength:null,maxLength:null,exactLength:null,typeName:A.ZodArray,...C(t)});function In(e){if(e instanceof de){let t={};for(let r in e.shape){let n=e.shape[r];t[r]=wt.create(In(n))}return new de({...e._def,shape:()=>t})}else if(e instanceof Ft)return new Ft({...e._def,type:In(e.element)});else if(e instanceof wt)return wt.create(In(e.unwrap()));else if(e instanceof Yt)return Yt.create(In(e.unwrap()));else if(e instanceof St)return St.create(e.items.map((t)=>In(t)));else return e}class de extends M{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=K.objectKeys(e);return this._cached={shape:e,keys:t},this._cached}_parse(e){if(this._getType(e)!==_.object){let f=this._getOrReturnCtx(e);return I(f,{code:x.invalid_type,expected:_.object,received:f.parsedType}),T}let{status:r,ctx:n}=this._processInputParams(e),{shape:o,keys:i}=this._getCached(),s=[];if(!(this._def.catchall instanceof Mt&&this._def.unknownKeys==="strip")){for(let f in n.data)if(!i.includes(f))s.push(f)}let a=[];for(let f of i){let l=o[f],g=n.data[f];a.push({key:{status:"valid",value:f},value:l._parse(new Rt(n,g,n.path,f)),alwaysSet:f in n.data})}if(this._def.catchall instanceof Mt){let f=this._def.unknownKeys;if(f==="passthrough")for(let l of s)a.push({key:{status:"valid",value:l},value:{status:"valid",value:n.data[l]}});else if(f==="strict"){if(s.length>0)I(n,{code:x.unrecognized_keys,keys:s}),r.dirty()}else if(f==="strip");else throw Error("Internal ZodObject error: invalid unknownKeys value.")}else{let f=this._def.catchall;for(let l of s){let g=n.data[l];a.push({key:{status:"valid",value:l},value:f._parse(new Rt(n,g,n.path,l)),alwaysSet:l in n.data})}}if(n.common.async)return Promise.resolve().then(async()=>{let f=[];for(let l of a){let g=await l.key,R=await l.value;f.push({key:g,value:R,alwaysSet:l.alwaysSet})}return f}).then((f)=>ke.mergeObjectSync(r,f));else return ke.mergeObjectSync(r,a)}get shape(){return this._def.shape()}strict(e){return w.errToObj,new de({...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:w.errToObj(e).message??n};return{message:n}}}:{}})}strip(){return new de({...this._def,unknownKeys:"strip"})}passthrough(){return new de({...this._def,unknownKeys:"passthrough"})}extend(e){return new de({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new de({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 de({...this._def,catchall:e})}pick(e){let t={};for(let r of K.objectKeys(e))if(e[r]&&this.shape[r])t[r]=this.shape[r];return new de({...this._def,shape:()=>t})}omit(e){let t={};for(let r of K.objectKeys(this.shape))if(!e[r])t[r]=this.shape[r];return new de({...this._def,shape:()=>t})}deepPartial(){return In(this)}partial(e){let t={};for(let r of K.objectKeys(this.shape)){let n=this.shape[r];if(e&&!e[r])t[r]=n;else t[r]=n.optional()}return new de({...this._def,shape:()=>t})}required(e){let t={};for(let r of K.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 de({...this._def,shape:()=>t})}keyof(){return yc(K.objectKeys(this.shape))}}de.create=(e,t)=>new de({shape:()=>e,unknownKeys:"strip",catchall:Mt.create(),typeName:A.ZodObject,...C(t)});de.strictCreate=(e,t)=>new de({shape:()=>e,unknownKeys:"strict",catchall:Mt.create(),typeName:A.ZodObject,...C(t)});de.lazycreate=(e,t)=>new de({shape:e,unknownKeys:"strip",catchall:Mt.create(),typeName:A.ZodObject,...C(t)});class $n extends M{_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 ve(s.ctx.common.issues));return I(t,{code:x.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 f={...t,common:{...t.common,issues:[]},parent:null},l=a._parseSync({data:t.data,path:t.path,parent:f});if(l.status==="valid")return l;else if(l.status==="dirty"&&!o)o={result:l,ctx:f};if(f.common.issues.length)i.push(f.common.issues)}if(o)return t.common.issues.push(...o.ctx.common.issues),o.result;let s=i.map((a)=>new ve(a));return I(t,{code:x.invalid_union,unionErrors:s}),T}}get options(){return this._def.options}}$n.create=(e,t)=>new $n({options:e,typeName:A.ZodUnion,...C(t)});var Jt=(e)=>{if(e instanceof wn)return Jt(e.schema);else if(e instanceof Tt)return Jt(e.innerType());else if(e instanceof Rn)return[e.value];else if(e instanceof yr)return e.options;else if(e instanceof Tn)return K.objectValues(e.enum);else if(e instanceof An)return Jt(e._def.innerType);else if(e instanceof _n)return[void 0];else if(e instanceof On)return[null];else if(e instanceof wt)return[void 0,...Jt(e.unwrap())];else if(e instanceof Yt)return[null,...Jt(e.unwrap())];else if(e instanceof ti)return Jt(e.unwrap());else if(e instanceof Nn)return Jt(e.unwrap());else if(e instanceof kn)return Jt(e._def.innerType);else return[]};class ei extends M{_parse(e){let{ctx:t}=this._processInputParams(e);if(t.parsedType!==_.object)return I(t,{code:x.invalid_type,expected:_.object,received:t.parsedType}),T;let r=this.discriminator,n=t.data[r],o=this.optionsMap.get(n);if(!o)return I(t,{code:x.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=Jt(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 ei({typeName:A.ZodDiscriminatedUnion,discriminator:e,options:t,optionsMap:n,...C(r)})}}function vi(e,t){let r=jt(e),n=jt(t);if(e===t)return{valid:!0,data:e};else if(r===_.object&&n===_.object){let o=K.objectKeys(t),i=K.objectKeys(e).filter((a)=>o.indexOf(a)!==-1),s={...e,...t};for(let a of i){let f=vi(e[a],t[a]);if(!f.valid)return{valid:!1};s[a]=f.data}return{valid:!0,data:s}}else if(r===_.array&&n===_.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],f=vi(s,a);if(!f.valid)return{valid:!1};o.push(f.data)}return{valid:!0,data:o}}else if(r===_.date&&n===_.date&&+e===+t)return{valid:!0,data:e};else return{valid:!1}}class Fn extends M{_parse(e){let{status:t,ctx:r}=this._processInputParams(e),n=(o,i)=>{if(Xo(o)||Xo(i))return T;let s=vi(o.value,i.value);if(!s.valid)return I(r,{code:x.invalid_intersection_types}),T;if(Zo(o)||Zo(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}))}}Fn.create=(e,t,r)=>new Fn({left:e,right:t,typeName:A.ZodIntersection,...C(r)});class St extends M{_parse(e){let{status:t,ctx:r}=this._processInputParams(e);if(r.parsedType!==_.array)return I(r,{code:x.invalid_type,expected:_.array,received:r.parsedType}),T;if(r.data.length<this._def.items.length)return I(r,{code:x.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)I(r,{code:x.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 Rt(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 St({...this._def,rest:e})}}St.create=(e,t)=>{if(!Array.isArray(e))throw Error("You must pass an array of schemas to z.tuple([ ... ])");return new St({items:e,typeName:A.ZodTuple,rest:null,...C(t)})};class Zn extends M{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!==_.object)return I(r,{code:x.invalid_type,expected:_.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 Rt(r,s,r.path,s)),value:i._parse(new Rt(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 M)return new Zn({keyType:e,valueType:t,typeName:A.ZodRecord,...C(r)});return new Zn({keyType:$t.create(),valueType:e,typeName:A.ZodRecord,...C(t)})}}class eo extends M{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!==_.map)return I(r,{code:x.invalid_type,expected:_.map,received:r.parsedType}),T;let n=this._def.keyType,o=this._def.valueType,i=[...r.data.entries()].map(([s,a],f)=>({key:n._parse(new Rt(r,s,r.path,[f,"key"])),value:o._parse(new Rt(r,a,r.path,[f,"value"]))}));if(r.common.async){let s=new Map;return Promise.resolve().then(async()=>{for(let a of i){let f=await a.key,l=await a.value;if(f.status==="aborted"||l.status==="aborted")return T;if(f.status==="dirty"||l.status==="dirty")t.dirty();s.set(f.value,l.value)}return{status:t.value,value:s}})}else{let s=new Map;for(let a of i){let{key:f,value:l}=a;if(f.status==="aborted"||l.status==="aborted")return T;if(f.status==="dirty"||l.status==="dirty")t.dirty();s.set(f.value,l.value)}return{status:t.value,value:s}}}}eo.create=(e,t,r)=>new eo({valueType:t,keyType:e,typeName:A.ZodMap,...C(r)});class Kr extends M{_parse(e){let{status:t,ctx:r}=this._processInputParams(e);if(r.parsedType!==_.set)return I(r,{code:x.invalid_type,expected:_.set,received:r.parsedType}),T;let n=this._def;if(n.minSize!==null){if(r.data.size<n.minSize.value)I(r,{code:x.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)I(r,{code:x.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 f=new Set;for(let l of a){if(l.status==="aborted")return T;if(l.status==="dirty")t.dirty();f.add(l.value)}return{status:t.value,value:f}}let s=[...r.data.values()].map((a,f)=>o._parse(new Rt(r,a,r.path,f)));if(r.common.async)return Promise.all(s).then((a)=>i(a));else return i(s)}min(e,t){return new Kr({...this._def,minSize:{value:e,message:w.toString(t)}})}max(e,t){return new Kr({...this._def,maxSize:{value:e,message:w.toString(t)}})}size(e,t){return this.min(e,t).max(e,t)}nonempty(e){return this.min(1,e)}}Kr.create=(e,t)=>new Kr({valueType:e,minSize:null,maxSize:null,typeName:A.ZodSet,...C(t)});class hn extends M{constructor(){super(...arguments);this.validate=this.implement}_parse(e){let{ctx:t}=this._processInputParams(e);if(t.parsedType!==_.function)return I(t,{code:x.invalid_type,expected:_.function,received:t.parsedType}),T;function r(s,a){return Yn({data:s,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,xn(),Wt].filter((f)=>!!f),issueData:{code:x.invalid_arguments,argumentsError:a}})}function n(s,a){return Yn({data:s,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,xn(),Wt].filter((f)=>!!f),issueData:{code:x.invalid_return_type,returnTypeError:a}})}let o={errorMap:t.common.contextualErrorMap},i=t.data;if(this._def.returns instanceof Er){let s=this;return Me(async function(...a){let f=new ve([]),l=await s._def.args.parseAsync(a,o).catch((J)=>{throw f.addIssue(r(a,J)),f}),g=await Reflect.apply(i,this,l);return await s._def.returns._def.type.parseAsync(g,o).catch((J)=>{throw f.addIssue(n(g,J)),f})})}else{let s=this;return Me(function(...a){let f=s._def.args.safeParse(a,o);if(!f.success)throw new ve([r(a,f.error)]);let l=Reflect.apply(i,this,f.data),g=s._def.returns.safeParse(l,o);if(!g.success)throw new ve([n(l,g.error)]);return g.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new hn({...this._def,args:St.create(e).rest(dr.create())})}returns(e){return new hn({...this._def,returns:e})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,t,r){return new hn({args:e?e:St.create([]).rest(dr.create()),returns:t||dr.create(),typeName:A.ZodFunction,...C(r)})}}class wn extends M{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})}}wn.create=(e,t)=>new wn({getter:e,typeName:A.ZodLazy,...C(t)});class Rn extends M{_parse(e){if(e.data!==this._def.value){let t=this._getOrReturnCtx(e);return I(t,{received:t.data,code:x.invalid_literal,expected:this._def.value}),T}return{status:"valid",value:e.data}}get value(){return this._def.value}}Rn.create=(e,t)=>new Rn({value:e,typeName:A.ZodLiteral,...C(t)});function yc(e,t){return new yr({values:e,typeName:A.ZodEnum,...C(t)})}class yr extends M{_parse(e){if(typeof e.data!=="string"){let t=this._getOrReturnCtx(e),r=this._def.values;return I(t,{expected:K.joinValues(r),received:t.parsedType,code:x.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 I(t,{received:t.data,code:x.invalid_enum_value,options:r}),T}return Me(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 yr.create(e,{...this._def,...t})}exclude(e,t=this._def){return yr.create(this.options.filter((r)=>!e.includes(r)),{...this._def,...t})}}yr.create=yc;class Tn extends M{_parse(e){let t=K.getValidEnumValues(this._def.values),r=this._getOrReturnCtx(e);if(r.parsedType!==_.string&&r.parsedType!==_.number){let n=K.objectValues(t);return I(r,{expected:K.joinValues(n),received:r.parsedType,code:x.invalid_type}),T}if(!this._cache)this._cache=new Set(K.getValidEnumValues(this._def.values));if(!this._cache.has(e.data)){let n=K.objectValues(t);return I(r,{received:r.data,code:x.invalid_enum_value,options:n}),T}return Me(e.data)}get enum(){return this._def.values}}Tn.create=(e,t)=>new Tn({values:e,typeName:A.ZodNativeEnum,...C(t)});class Er extends M{unwrap(){return this._def.type}_parse(e){let{ctx:t}=this._processInputParams(e);if(t.parsedType!==_.promise&&t.common.async===!1)return I(t,{code:x.invalid_type,expected:_.promise,received:t.parsedType}),T;let r=t.parsedType===_.promise?t.data:Promise.resolve(t.data);return Me(r.then((n)=>this._def.type.parseAsync(n,{path:t.path,errorMap:t.common.contextualErrorMap})))}}Er.create=(e,t)=>new Er({type:e,typeName:A.ZodPromise,...C(t)});class Tt extends M{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(I(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 Mr(a.value);if(t.value==="dirty")return Mr(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 Mr(s.value);if(t.value==="dirty")return Mr(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(!mr(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(!mr(i))return T;return Promise.resolve(n.transform(i.value,o)).then((s)=>({status:t.value,value:s}))});K.assertNever(n)}}Tt.create=(e,t,r)=>new Tt({schema:e,typeName:A.ZodEffects,effect:t,...C(r)});Tt.createWithPreprocess=(e,t,r)=>new Tt({schema:t,effect:{type:"preprocess",transform:e},typeName:A.ZodEffects,...C(r)});class wt extends M{_parse(e){if(this._getType(e)===_.undefined)return Me(void 0);return this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}wt.create=(e,t)=>new wt({innerType:e,typeName:A.ZodOptional,...C(t)});class Yt extends M{_parse(e){if(this._getType(e)===_.null)return Me(null);return this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}Yt.create=(e,t)=>new Yt({innerType:e,typeName:A.ZodNullable,...C(t)});class An extends M{_parse(e){let{ctx:t}=this._processInputParams(e),r=t.data;if(t.parsedType===_.undefined)r=this._def.defaultValue();return this._def.innerType._parse({data:r,path:t.path,parent:t})}removeDefault(){return this._def.innerType}}An.create=(e,t)=>new An({innerType:e,typeName:A.ZodDefault,defaultValue:typeof t.default==="function"?t.default:()=>t.default,...C(t)});class kn extends M{_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(gn(n))return n.then((o)=>({status:"valid",value:o.status==="valid"?o.value:this._def.catchValue({get error(){return new ve(r.common.issues)},input:r.data})}));else return{status:"valid",value:n.status==="valid"?n.value:this._def.catchValue({get error(){return new ve(r.common.issues)},input:r.data})}}removeCatch(){return this._def.innerType}}kn.create=(e,t)=>new kn({innerType:e,typeName:A.ZodCatch,catchValue:typeof t.catch==="function"?t.catch:()=>t.catch,...C(t)});class to extends M{_parse(e){if(this._getType(e)!==_.nan){let r=this._getOrReturnCtx(e);return I(r,{code:x.invalid_type,expected:_.nan,received:r.parsedType}),T}return{status:"valid",value:e.data}}}to.create=(e)=>new to({typeName:A.ZodNaN,...C(e)});var Nx=Symbol("zod_brand");class ti extends M{_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 ro extends M{_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(),Mr(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 ro({in:e,out:t,typeName:A.ZodPipeline})}}class Nn extends M{_parse(e){let t=this._def.innerType._parse(e),r=(n)=>{if(mr(n))n.value=Object.freeze(n.value);return n};return gn(t)?t.then((n)=>r(n)):r(t)}unwrap(){return this._def.innerType}}Nn.create=(e,t)=>new Nn({innerType:e,typeName:A.ZodReadonly,...C(t)});function mc(e,t){let r=typeof e==="function"?e(t):typeof e==="string"?{message:e}:e;return typeof r==="string"?{message:r}:r}function xc(e,t={},r){if(e)return Ur.create().superRefine((n,o)=>{let i=e(n);if(i instanceof Promise)return i.then((s)=>{if(!s){let a=mc(t,n),f=a.fatal??r??!0;o.addIssue({code:"custom",...a,fatal:f})}});if(!i){let s=mc(t,n),a=s.fatal??r??!0;o.addIssue({code:"custom",...s,fatal:a})}return});return Ur.create()}var Px={object:de.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 Cx=(e,t={message:`Input not instance of ${e.name}`})=>xc((r)=>r instanceof e,t),gc=$t.create,Ic=pr.create,jx=to.create,Mx=lr.create,hc=bn.create,Sx=Sr.create,Ux=Qn.create,Kx=_n.create,Ex=On.create,Lx=Ur.create,Bx=dr.create,Gx=Mt.create,Dx=Xn.create,vx=Ft.create,{create:qx,strictCreate:Vx}=de,Hx=$n.create,zx=ei.create,Wx=Fn.create,Jx=St.create,Yx=Zn.create,Qx=eo.create,Xx=Kr.create,Zx=hn.create,eg=wn.create,tg=Rn.create,rg=yr.create,ng=Tn.create,og=Er.create,ig=Tt.create,sg=wt.create,ag=Yt.create,cg=Tt.createWithPreprocess,ug=ro.create,fg=()=>gc().optional(),mg=()=>Ic().optional(),dg=()=>hc().optional(),pg={string:(e)=>$t.create({...e,coerce:!0}),number:(e)=>pr.create({...e,coerce:!0}),boolean:(e)=>bn.create({...e,coerce:!0}),bigint:(e)=>lr.create({...e,coerce:!0}),date:(e)=>Sr.create({...e,coerce:!0})};var lg=T;var yg=ri,Lr=(e,t=400)=>Response.json(e,{status:t,headers:{"Content-Type":"application/json"}}),bc=(e)=>{let t=Qo.Compile(e);return async(r,n)=>{try{let o=await r.jsonBody();if(!t.Check(o)){let i=t.Errors(o).First();return Lr({status:"error",code:"VALIDATION_FAILED",message:i?.message||"Invalid input",path:i?.path||"body"})}return r.body=o,n?n():void 0}catch{return Lr({status:"error",message:"Malformed JSON payload"})}}},_c=(e)=>{let t=e.properties||{},r=Object.keys(t),n=r.length;return async(o,i)=>{try{let s=o instanceof Object&&"req"in o,a=s?await o.jsonBody():await o.json();if(!a||typeof a!=="object"||Array.isArray(a))return Lr({status:"error",message:"Invalid JSON object payload"});for(let f=0;f<n;f++){let l=r[f];if(!Object.hasOwn(a,l)||typeof a[l]!==t[l]?.type)return Lr({status:"error",code:"TYPE_MISMATCH",message:`Field '${l}' must be of type ${t[l]?.type}`,field:l})}if(s)o.body=a;return i?i():void 0}catch{return Lr({status:"error",message:"Invalid JSON payload"})}}},Oc=(e)=>async(t,r)=>{try{let n=t instanceof Object&&"req"in t,o=n?await t.jsonBody():await t.json(),i=await e.safeParseAsync(o);if(!i.success)return Lr({status:"error",code:"ZOD_ERROR",errors:i.error.flatten()});if(n)t.body=i.data;return r?r():void 0}catch{return Lr({status:"error",message:"Invalid JSON payload"})}},xg=(e)=>{if(e&&"_def"in e)return Oc(e);if(e&&(e.kind||e.type||e[Symbol.for("TypeBox.Kind")]))return bc(e);return _c(e)};var gg=(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 f=a?.();if(f&&typeof f.then==="function")return f.then((l)=>{if(l instanceof Response){if(l.headers.set("Access-Control-Allow-Origin",t),l.headers.set("Access-Control-Allow-Methods",r),t!=="*")l.headers.set("Vary","Origin")}return l});if(f instanceof Response){if(f.headers.set("Access-Control-Allow-Origin",t),f.headers.set("Access-Control-Allow-Methods",r),t!=="*")f.headers.set("Vary","Origin")}return f}};import{resolve as $c,sep as Fc}from"path";var Ig=(e="public")=>{let t=$c(process.cwd(),e),r=t.endsWith(Fc)?t:t+Fc;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),f=a===-1?-1:s.indexOf("?",a),l=a===-1?"":f===-1?s.slice(a):s.slice(a,f),g;try{g=decodeURIComponent(l)}catch{return n.status(400).send("Bad Request")}if(g.includes("\x00"))return n.status(400).send("Bad Request");let R=g.replace(/^\/+/,""),J=$c(t,R);if(J!==t&&!J.startsWith(r))return n.status(403).send("Forbidden");let be=Bun.file(J);if(await be.exists())return new Response(be);return o()}};import{createHash as g0,createHmac as hg,timingSafeEqual as bg}from"crypto";var Rc=new TextEncoder,qi=(e)=>typeof e==="string"?Buffer.from(e).toString("base64url"):Buffer.from(e).toString("base64url"),wc=(e)=>Buffer.from(e,"base64url").toString("utf-8"),Vi=new Map,_g=async(e)=>{if(Vi.has(e))return Vi.get(e);let t=await crypto.subtle.importKey("raw",Rc.encode(e),{name:"HMAC",hash:"SHA-256"},!1,["sign","verify"]);return Vi.set(e,t),t},Og=async(e,t)=>{let r=JSON.stringify({alg:"HS256",typ:"JWT"}),n=JSON.stringify(e),o=qi(r),i=qi(n),s=`${o}.${i}`,a=await _g(t),f=await crypto.subtle.sign("HMAC",a,Rc.encode(s)),l=qi(new Uint8Array(f));return`${s}.${l}`},$g=(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),f=o.slice(i+1,s),l=o.slice(s+1),g=o.slice(0,s);try{let R=hg("sha256",e).update(g).digest(),J=Buffer.from(l,"base64url");if(J.length!==R.length||!bg(J,R))return t.status(401).send("Invalid signature");let be=JSON.parse(wc(a));if(!be||be.alg!=="HS256")return t.status(401).send("Unsupported token algorithm");let P=JSON.parse(wc(f)),qe=Date.now()*0.001;if(typeof P.exp==="number"&&qe>=P.exp)return t.status(401).send("Token expired");if(typeof P.nbf==="number"&&qe<P.nbf)return t.status(401).send("Token not active");if(t.set("user",P),Array.isArray(r)){if(r.length===0)return;let[no,...Pn]=r;return no(t,Pn)}if(typeof r==="function")return r();return}catch{return t.status(401).send("Token verification failed")}};Jo();var Tc={make:(e)=>Bun.password.hash(e,dn.hash),verify:(e,t)=>Bun.password.verify(e,t),needsRehash:(e)=>{let{algorithm:t,memoryCost:r,timeCost:n}=dn.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}};export{Ha as BareJS,Dr as BareRouter,Tc as Hash,Tc as Password,Gp as T,Gp as Type,Gp as TypeBox,yg as Z,yg as Zod,$g as bareAuth,gg as cors,Og as createToken,_c as n,_c as native,Ig as staticFile,bc as t,bc as typebox,xg as v,xg as validate,Oc as z,Oc as zod};
225
+ `);let s=this.wsRoutes,a=this.fetch,u=s.size>0?Bun.serve({port:o,hostname:t,reusePort:r,fetch(g,I){if(g.headers.get("upgrade")==="websocket"){let O=g.url,T=O.indexOf("/",8),C=T===-1?-1:O.indexOf("?",T),Y=T===-1?"/":C===-1?O.slice(T):O.slice(T,C),fe=Y.length>1&&Y.endsWith("/")?Y.slice(0,-1):Y,Ee=s.get(fe);if(Ee&&I.upgrade(g,{data:Ee}))return}return a(g)},websocket:this.wsAdapter}):Bun.serve({port:o,hostname:t,reusePort:r,fetch:a});this.server=u;for(let g of this.startHooks)Promise.resolve(g()).catch((I)=>console.error(`[${this.name}] onStart error:`,I));let m=async()=>{let I=this.name,O=process.stdout.isTTY;{let T=O?"\uD83D\uDED1":"!",C=O?"\u2705":"v";process.stdout.write(`
226
+ \x1B[31m${T} Stopping ${I}...\x1B[0m
227
+ `),await this.stop(!1),process.stdout.write(`\x1B[32m${C} ${I} has been stopped.\x1B[0m
228
+ `)}process.exit(0)};return this.shutdownHandler=m,process.on("SIGINT",m),process.on("SIGTERM",m),u}}var Px=(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,i=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(i)u["Access-Control-Allow-Credentials"]="true";let m={status:204,headers:u};return(I,O)=>{if(I.req.method==="OPTIONS")return new Response(null,m);if(I.setHeader("Access-Control-Allow-Origin",t),I.setHeader("Access-Control-Allow-Methods",r),t!=="*")I.setHeader("Vary","Origin");if(i)I.setHeader("Access-Control-Allow-Credentials","true");if(o)I.setHeader("Access-Control-Expose-Headers",o);let T=O?.();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(i)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(i)T.headers.set("Access-Control-Allow-Credentials","true");if(o)T.headers.set("Access-Control-Expose-Headers",o)}return T}}let s=Array.isArray(t)?new Set(t):null,a=(u)=>{if(!u)return null;if(s)return s.has(u)?u:null;return t(u)?u:null};return(u,m)=>{let g=a(u.req.headers.get("origin"));if(u.req.method==="OPTIONS"){let I={"Access-Control-Allow-Methods":r,"Access-Control-Allow-Headers":n,Vary:"Origin"};if(g)I["Access-Control-Allow-Origin"]=g;if(i&&g)I["Access-Control-Allow-Credentials"]="true";return new Response(null,{status:204,headers:I})}if(u.setHeader("Vary","Origin"),u.setHeader("Access-Control-Allow-Methods",r),g){if(u.setHeader("Access-Control-Allow-Origin",g),i)u.setHeader("Access-Control-Allow-Credentials","true")}if(o)u.setHeader("Access-Control-Expose-Headers",o);return m?.()}};var Nx=new Set(["GET","HEAD","OPTIONS"]),Sx=(e={})=>{let t=e.ignoreMethods?new Set(e.ignoreMethods.map((s)=>s.toUpperCase())):Nx,r=e.allowedOrigins?new Set(e.allowedOrigins):null,n=e.cookieName||"csrf_token",o=(e.headerName||"x-csrf-token").toLowerCase(),i=e.requireToken===!0;return(s,a)=>{let c=s.req.method.toUpperCase();if(t.has(c))return a();let u=s.req.headers.get("sec-fetch-site"),m=s.req.headers.get("origin"),g=s.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 I=m;if(!I&&g)try{I=new URL(g).origin}catch{return Response.json({status:"error",code:"CSRF_FORBIDDEN",message:"Invalid Referer header"},{status:403})}if(I){let O;try{O=new URL(s.req.url).origin}catch{O=""}if(!(I===O||r!==null&&r.has(I)))return Response.json({status:"error",code:"CSRF_FORBIDDEN",message:"Origin mismatch"},{status:403})}if(i){let O=s.cookies[n],T=s.req.headers.get(o);if(!O||!T||O!==T)return Response.json({status:"error",code:"CSRF_TOKEN_INVALID",message:"Invalid or missing CSRF token"},{status:403})}return a()}};var jx=(e=1e4,t={})=>{let r=t.status??408,n=t.message??"Request Timeout",o=async(i,s)=>{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(s()),c])}finally{if(a!==void 0)clearTimeout(a)}};return o.__timeout={ms:e,status:r,message:n},o};var Mx=(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 u=Date.now(),m=i(a),g=s.get(m);if(!g||u>=g.resetAt){if(s.size>=o){for(let[O,T]of s){if(u>=T.resetAt)s.delete(O);if(s.size<o)break}if(s.size>=o){let O=s.keys().next().value;if(O!==void 0)s.delete(O)}}g={count:1,resetAt:u+t},s.set(m,g)}else g.count++;let I=Math.max(0,r-g.count);if(a.setHeader("X-RateLimit-Limit",String(r)),a.setHeader("X-RateLimit-Remaining",String(I)),a.setHeader("X-RateLimit-Reset",String(Math.ceil(g.resetAt/1000))),g.count>r){let O=Math.max(1,Math.ceil((g.resetAt-u)/1000));return Response.json({status:"error",code:"RATE_LIMITED",message:n},{status:429,headers:{"Retry-After":String(O),"X-RateLimit-Limit":String(r),"X-RateLimit-Remaining":"0","X-RateLimit-Reset":String(Math.ceil(g.resetAt/1000))}})}return c?.()}};var Ux=(e={})=>{let t=(e.headerName||"idempotency-key").toLowerCase(),r=e.ttlMs??300000,n=e.maxKeys??1e4,o=new Map,i=new Set,s=(a)=>{let c=a.req.headers.get(t);if(!c)return;let u=Date.now(),m=o.get(c);if(m){if(u<m.expiresAt)return Response.json(m.body,{status:m.status,headers:{"X-Idempotent-Replayed":"true"}});o.delete(c)}if(i.has(c))return Response.json({status:"error",code:"IDEMPOTENT_IN_FLIGHT",message:"Duplicate request is currently in flight"},{status:409});i.add(c),a._idempotencyKey=c,a._idemInFlight=i;return};return s.__idempotencyCommit=(a,c,u)=>{let m=a._idempotencyKey;if(!m)return;if(i.delete(m),u>=200&&u<300&&!(c instanceof Response)){if(o.size>=n){let g=o.keys().next().value;if(g!==void 0)o.delete(g)}o.set(m,{status:u,body:c,expiresAt:Date.now()+r})}},s},Ex=()=>{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 Lx=(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 i=0;i<r;i++){let s=t[i];o[s[0].toLowerCase()]=s[1]}return o})());return(o,i)=>{if(!o._headers)o._headers=n;else o._headers={...o._headers,...n};let s=i?.();if(s&&typeof s.then==="function")return s.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(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}};import{resolve as Yc,sep as Xc}from"path";import{stat as Kx}from"fs/promises";var Bx=(e="public",t={})=>{let r=Yc(process.cwd(),e),n=r.endsWith(Xc)?r:r+Xc,o=t.maxAge??3600,i=t.etag!==!1,s=async(a,c)=>{let u=a.req.method;if(u!=="GET"&&u!=="HEAD")return c();let m=a.req.url,g=m.indexOf("/",8),I=g===-1?-1:m.indexOf("?",g),O=g===-1?"":I===-1?m.slice(g):m.slice(g,I),T;try{T=decodeURIComponent(O)}catch{return a.status(400).send("Bad Request")}if(T.includes("\x00"))return a.status(400).send("Bad Request");let C=T.replace(/^\/+/,""),Y=Yc(r,C);if(Y!==r&&!Y.startsWith(n))return a.status(403).send("Forbidden");let fe=0,Ee=0;try{let Re=await Kx(Y);if(Re.isDirectory())return c();fe=Re.size,Ee=Math.floor(Re.mtimeMs)}catch{return c()}let j=Bun.file(Y),Ae={"Cache-Control":`public, max-age=${o}`,"Accept-Ranges":"bytes"};if(i){let Re=`W/"${fe.toString(16)}-${Ee.toString(16)}"`;Ae.ETag=Re;let et=a.req.headers?.get?.("if-none-match");if(et&&et===Re)return new Response(null,{status:304,headers:Ae})}let ht=a.req.headers?.get?.("range");if(ht&&ht.startsWith("bytes=")&&fe>0){let[Re,et]=ht.slice(6).split("-"),qe=Re?Number(Re):0,tt=et?Number(et):fe-1;if(!Re&&et)qe=Math.max(0,fe-Number(et)),tt=fe-1;if(!Number.isInteger(qe)||!Number.isInteger(tt)||qe<0||tt>=fe||qe>tt)return new Response(null,{status:416,headers:{...Ae,"Content-Range":`bytes */${fe}`}});if(Ae["Content-Range"]=`bytes ${qe}-${tt}/${fe}`,Ae["Content-Length"]=String(tt-qe+1),j.type)Ae["Content-Type"]=j.type;return new Response(u==="HEAD"?null:j.slice(qe,tt+1),{status:206,headers:Ae})}if(j.type)Ae["Content-Type"]=j.type;return Ae["Content-Length"]=String(fe),new Response(u==="HEAD"?null:j,{status:200,headers:Ae})};return s.__isStatic=!0,s};import{createHash as Dx,createHmac as Gx,timingSafeEqual as ys}from"crypto";var Zc=new TextEncoder,ps=(e)=>typeof e==="string"?Buffer.from(e).toString("base64url"):Buffer.from(e).toString("base64url"),Qc=(e)=>Buffer.from(e,"base64url").toString("utf-8"),ls=new Map,qx=async(e)=>{if(ls.has(e))return ls.get(e);let t=await crypto.subtle.importKey("raw",Zc.encode(e),{name:"HMAC",hash:"SHA-256"},!1,["sign","verify"]);return ls.set(e,t),t},vx=async(e,t)=>{let r=JSON.stringify({alg:"HS256",typ:"JWT"}),n=JSON.stringify(e),o=ps(r),i=ps(n),s=`${o}.${i}`,a=await qx(t),c=await crypto.subtle.sign("HMAC",a,Zc.encode(s)),u=ps(new Uint8Array(c));return`${s}.${u}`},Hx=(e)=>{let t=typeof e==="string"?e:e.secret;return(r,n)=>{let o=r.req.headers.get("Authorization");if(!o?.startsWith("Bearer "))return r.status(401).send("Bearer token required");let i=o.slice(7),s=i.indexOf("."),a=s===-1?-1:i.indexOf(".",s+1);if(s===-1||a===-1||i.indexOf(".",a+1)!==-1)return r.status(401).send("Malformed JWT token");let c=i.slice(0,s),u=i.slice(s+1,a),m=i.slice(a+1),g=i.slice(0,a);try{let I=Gx("sha256",t).update(g).digest(),O=Buffer.from(m,"base64url");if(O.length!==I.length||!ys(O,I))return r.status(401).send("Invalid signature");let T=JSON.parse(Qc(c));if(!T||T.alg!=="HS256")return r.status(401).send("Unsupported token algorithm");let C=JSON.parse(Qc(u)),Y=Date.now()*0.001;if(typeof C.exp==="number"&&Y>=C.exp)return r.status(401).send("Token expired");if(typeof C.nbf==="number"&&Y<C.nbf)return r.status(401).send("Token not active");if(r.set("user",C),Array.isArray(n)){if(n.length===0)return;let[fe,...Ee]=n;return fe(r,Ee)}if(typeof n==="function")return n();return}catch{return r.status(401).send("Token verification failed")}}},_i=(e)=>Dx("sha256").update(e).digest(),Vx=(e)=>{let t=_i(e.user),r=_i(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 u=a.slice(0,c),m=a.slice(c+1),g=ys(_i(u),t),I=ys(_i(m),r);if(g&&I)return o();return n.status(401).json({status:"error",message:"Invalid credentials"})}},zx=(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()};Ii();var eu={make:(e)=>Bun.password.hash(e,Hn.hash),verify:(e,t)=>Bun.password.verify(e,t),needsRehash:(e)=>{let{algorithm:t,memoryCost:r,timeCost:n}=Hn.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 Wx=(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[u,m]of Object.entries(r.query))if(m!==void 0)a.set(u,String(m));let c=a.toString();if(c)s+=`?${c}`}return s},Jx=(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),i=t.headers??{},s=async(a,c,u)=>{let m=Wx(n,c,u),g={...i,...u?.headers??{}},I={method:a,headers:g};if(u?.body!==void 0&&a!=="GET"&&a!=="HEAD"){if(!g["Content-Type"]&&!g["content-type"])g["Content-Type"]="application/json";I.body=typeof u.body==="string"?u.body:JSON.stringify(u.body)}let O=await o(m,I),C=(O.headers.get("content-type")||"").includes("application/json")?await O.json():await O.text();if(!O.ok){let Y=Error(`HTTP ${O.status}`);throw Y.status=O.status,Y.data=C,Y}return C};return{get:(a,c)=>s("GET",a,c),post:(a,c)=>s("POST",a,c),put:(a,c)=>s("PUT",a,c),patch:(a,c)=>s("PATCH",a,c),delete:(a,c)=>s("DELETE",a,c)}};export{Jc as BareJS,Ln as BareRouter,Io as Context,eu as Hash,eu as Password,Ax as T,Ax as Type,Ax as TypeBox,Fy as Z,Fy as Zod,Hx as bareAuth,Jx as bareClient,Vx as basicAuth,Px as cors,tc as createResponseFilter,Ex as createSingleflight,vx as createToken,Sx as csrf,ds as generateOpenAPISpec,zx as hasRole,Ux as idempotency,Za as n,Za as native,Mx as rateLimit,ms as renderDocsHTML,ns as schemaValidator,Lx as securityHeaders,Bx as staticFile,Qa as t,jx as timeout,Qa as typebox,Ay as v,Ay as validate,ec as z,ec as zod};