barejs 0.1.55 → 0.1.57

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,20 +1,46 @@
1
1
  // @bun
2
- var fu=Object.defineProperty;var mu=(e)=>e;function pu(e,t){this[e]=mu.bind(null,t)}var _i=(e,t)=>{for(var r in t)fu(e,r,{get:t[r],enumerable:!0,configurable:!0,set:pu.bind(t,r)})};var us={};_i(us,{BRAND:()=>vl,DIRTY:()=>rn,EMPTY_PATH:()=>Il,INVALID:()=>v,NEVER:()=>$y,OK:()=>nt,ParseStatus:()=>Qe,Schema:()=>W,ZodAny:()=>on,ZodArray:()=>qt,ZodBigInt:()=>jr,ZodBoolean:()=>Mn,ZodBranded:()=>cs,ZodCatch:()=>qn,ZodDate:()=>nn,ZodDefault:()=>Dn,ZodDiscriminatedUnion:()=>as,ZodEffects:()=>zt,ZodEnum:()=>Er,ZodError:()=>mt,ZodFirstPartyTypeKind:()=>D,ZodFunction:()=>Nn,ZodIntersection:()=>Un,ZodIssueCode:()=>R,ZodLazy:()=>Kn,ZodLiteral:()=>Bn,ZodMap:()=>Io,ZodNaN:()=>bo,ZodNativeEnum:()=>vn,ZodNever:()=>tr,ZodNull:()=>En,ZodNullable:()=>xr,ZodNumber:()=>Mr,ZodObject:()=>ke,ZodOptional:()=>Gt,ZodParsedType:()=>k,ZodPipeline:()=>Ro,ZodPromise:()=>an,ZodReadonly:()=>Gn,ZodRecord:()=>xo,ZodSchema:()=>W,ZodSet:()=>sn,ZodString:()=>Dt,ZodSymbol:()=>go,ZodTransformer:()=>zt,ZodTuple:()=>rr,ZodType:()=>W,ZodUndefined:()=>jn,ZodUnion:()=>Ln,ZodUnknown:()=>Nr,ZodVoid:()=>ho,addIssueToContext:()=>O,any:()=>Xl,array:()=>ey,bigint:()=>Hl,boolean:()=>Za,coerce:()=>wy,custom:()=>Xa,date:()=>zl,datetimeRegex:()=>Ja,defaultErrorMap:()=>gr,discriminatedUnion:()=>oy,effect:()=>gy,enum:()=>py,function:()=>dy,getErrorMap:()=>kn,getParsedType:()=>er,instanceof:()=>ql,intersection:()=>sy,isAborted:()=>ss,isAsync:()=>Tn,isDirty:()=>is,isValid:()=>Fr,late:()=>Dl,lazy:()=>fy,literal:()=>my,makeIssue:()=>yo,map:()=>cy,nan:()=>Gl,nativeEnum:()=>ly,never:()=>Ql,null:()=>Wl,nullable:()=>xy,number:()=>Qa,object:()=>ty,objectUtil:()=>ei,oboolean:()=>Oy,onumber:()=>_y,optional:()=>hy,ostring:()=>Ry,pipeline:()=>by,preprocess:()=>Iy,promise:()=>yy,quotelessJson:()=>gl,record:()=>ay,set:()=>uy,setErrorMap:()=>xl,strictObject:()=>ry,string:()=>Ya,symbol:()=>Vl,transformer:()=>gy,tuple:()=>iy,undefined:()=>Jl,union:()=>ny,unknown:()=>Yl,util:()=>Q,void:()=>Zl});var di={};_i(di,{Any:()=>Cr,Argument:()=>ac,Array:()=>yn,AsyncIterator:()=>gn,Awaited:()=>zn,BigInt:()=>Rn,Boolean:()=>Go,Capitalize:()=>wc,Composite:()=>uc,Const:()=>dc,Constructor:()=>hn,ConstructorParameters:()=>fc,Date:()=>ds,Enum:()=>mc,Exclude:()=>Vn,Extends:()=>An,Extract:()=>Jn,Function:()=>Qt,Index:()=>$r,InstanceType:()=>hc,Instantiate:()=>Ic,Integer:()=>bc,Intersect:()=>et,Iterator:()=>_n,KeyOf:()=>On,Literal:()=>se,Lowercase:()=>$c,Mapped:()=>ra,Module:()=>Bc,Never:()=>J,Not:()=>vc,Null:()=>fs,Number:()=>_t,Object:()=>ue,Omit:()=>Lr,Optional:()=>Ze,Parameters:()=>Dc,Partial:()=>Wn,Pick:()=>Ur,Promise:()=>Vo,Readonly:()=>ut,ReadonlyOptional:()=>gs,Record:()=>hs,Recursive:()=>qc,Ref:()=>$t,RegExp:()=>Gc,Required:()=>Xn,Rest:()=>Hc,ReturnType:()=>zc,String:()=>Et,Symbol:()=>ms,TemplateLiteral:()=>zo,Transform:()=>Wc,Tuple:()=>Ot,Uint8Array:()=>ls,Uncapitalize:()=>Sc,Undefined:()=>ps,Union:()=>ie,Unknown:()=>Pr,Unsafe:()=>ki,Uppercase:()=>Cc,Void:()=>Xc});function Ao(e){return it(e)&&globalThis.Symbol.asyncIterator in e}function ko(e){return it(e)&&globalThis.Symbol.iterator in e}function To(e){return e instanceof globalThis.Promise}function mn(e){return e instanceof Date&&globalThis.Number.isFinite(e.getTime())}function pn(e){return e instanceof globalThis.Uint8Array}function Fo(e,t){return t in e}function it(e){return e!==null&&typeof e==="object"}function Ue(e){return globalThis.Array.isArray(e)&&!globalThis.ArrayBuffer.isView(e)}function ot(e){return e===void 0}function Kr(e){return e===null}function Br(e){return typeof e==="boolean"}function H(e){return typeof e==="number"}function No(e){return globalThis.Number.isInteger(e)}function lt(e){return typeof e==="bigint"}function Ge(e){return typeof e==="string"}function Mo(e){return typeof e==="function"}function vr(e){return typeof e==="symbol"}function jo(e){return lt(e)||Br(e)||Kr(e)||H(e)||Ge(e)||vr(e)||ot(e)}var ge;(function(e){e.InstanceMode="default",e.ExactOptionalPropertyTypes=!1,e.AllowArrayObject=!1,e.AllowNaN=!1,e.AllowNullVoid=!1;function t(i,a){return e.ExactOptionalPropertyTypes?a in i:i[a]!==void 0}e.IsExactOptionalProperty=t;function r(i){let a=it(i);return e.AllowArrayObject?a:a&&!Ue(i)}e.IsObjectLike=r;function n(i){return r(i)&&!(i instanceof Date)&&!(i instanceof Uint8Array)}e.IsRecordLike=n;function o(i){return e.AllowNaN?H(i):Number.isFinite(i)}e.IsNumberLike=o;function s(i){let a=ot(i);return e.AllowNullVoid?a||i===null:a}e.IsVoidLike=s})(ge||(ge={}));var Oi=new Map;function $s(e){return Oi.has(e)}function Ss(e){return Oi.get(e)}var wi=new Map;function Qn(e){return wi.has(e)}function Cs(e){return wi.get(e)}function $i(e){return be(e)&&!Ke(e)&&!Rr(e)&&Symbol.asyncIterator in e}function Ke(e){return Array.isArray(e)}function Uo(e){return typeof e==="bigint"}function br(e){return typeof e==="boolean"}function ln(e){return e instanceof globalThis.Date}function Si(e){return typeof e==="function"}function Ci(e){return be(e)&&!Ke(e)&&!Rr(e)&&Symbol.iterator in e}function Pi(e){return e===null}function yt(e){return typeof e==="number"}function be(e){return typeof e==="object"&&e!==null}function Ko(e){return e instanceof globalThis.RegExp}function he(e){return typeof e==="string"}function Ai(e){return typeof e==="symbol"}function Rr(e){return e instanceof globalThis.Uint8Array}function xe(e){return e===void 0}function lu(e){return globalThis.Object.freeze(e).map((t)=>Zn(t))}function yu(e){return e}function gu(e){return e}function hu(e){return e}function xu(e){let t={};for(let r of Object.getOwnPropertyNames(e))t[r]=Zn(e[r]);for(let r of Object.getOwnPropertySymbols(e))t[r]=Zn(e[r]);return globalThis.Object.freeze(t)}function Zn(e){return Ke(e)?lu(e):ln(e)?yu(e):Rr(e)?gu(e):Ko(e)?hu(e):be(e)?xu(e):e}function Iu(e){return e.map((t)=>Bo(t))}function bu(e){return new Date(e.getTime())}function Ru(e){return new Uint8Array(e)}function _u(e){return new RegExp(e.source,e.flags)}function Ou(e){let t={};for(let r of Object.getOwnPropertyNames(e))t[r]=Bo(e[r]);for(let r of Object.getOwnPropertySymbols(e))t[r]=Bo(e[r]);return t}function Bo(e){return Ke(e)?Iu(e):ln(e)?bu(e):Rr(e)?Ru(e):Ko(e)?_u(e):be(e)?Ou(e):e}function Re(e){return Bo(e)}function h(e,t){let r=t!==void 0?{...t,...e}:e;switch(ge.InstanceMode){case"freeze":return Zn(r);case"clone":return Re(r);default:return r}}var Oe=Symbol.for("TypeBox.Transform"),Xt=Symbol.for("TypeBox.Readonly"),We=Symbol.for("TypeBox.Optional"),Yt=Symbol.for("TypeBox.Hint"),I=Symbol.for("TypeBox.Kind");function ki(e={}){return h({[I]:e[I]??"Unsafe"},e)}class oe extends Error{constructor(e){super(e)}}function re(e){return h({[I]:"MappedResult",properties:e})}function wu(e,t){let{[t]:r,...n}=e;return n}function Ce(e,t){return t.reduce((r,n)=>wu(r,n),e)}function yn(e,t){return h({[I]:"Array",type:"array",items:e},t)}function gn(e,t){return h({[I]:"AsyncIterator",type:"AsyncIterator",items:e},t)}function hn(e,t,r){return h({[I]:"Constructor",type:"Constructor",parameters:e,returns:t},r)}function Qt(e,t,r){return h({[I]:"Function",type:"Function",parameters:e,returns:t},r)}function Ie(e,t,r){return h({[I]:"Computed",target:e,parameters:t},r)}function J(e){return h({[I]:"Never",not:{}},e)}function xn(e){return be(e)&&e[Xt]==="Readonly"}function at(e){return be(e)&&e[We]==="Optional"}function Ps(e){return Z(e,"Any")}function As(e){return Z(e,"Argument")}function kt(e){return Z(e,"Array")}function qr(e){return Z(e,"AsyncIterator")}function Gr(e){return Z(e,"BigInt")}function sr(e){return Z(e,"Boolean")}function Tt(e){return Z(e,"Computed")}function Ft(e){return Z(e,"Constructor")}function $u(e){return Z(e,"Date")}function Nt(e){return Z(e,"Function")}function Mt(e){return Z(e,"Integer")}function Pe(e){return Z(e,"Intersect")}function Hr(e){return Z(e,"Iterator")}function Z(e,t){return be(e)&&I in e&&e[I]===t}function vo(e){return br(e)||yt(e)||he(e)}function gt(e){return Z(e,"Literal")}function ht(e){return Z(e,"MappedKey")}function _e(e){return Z(e,"MappedResult")}function _r(e){return Z(e,"Never")}function Su(e){return Z(e,"Not")}function eo(e){return Z(e,"Null")}function jt(e){return Z(e,"Number")}function Ne(e){return Z(e,"Object")}function zr(e){return Z(e,"Promise")}function Vr(e){return Z(e,"Record")}function Fe(e){return Z(e,"Ref")}function ks(e){return Z(e,"RegExp")}function ir(e){return Z(e,"String")}function to(e){return Z(e,"Symbol")}function xt(e){return Z(e,"TemplateLiteral")}function Cu(e){return Z(e,"This")}function ne(e){return be(e)&&Oe in e}function It(e){return Z(e,"Tuple")}function ar(e){return Z(e,"Undefined")}function te(e){return Z(e,"Union")}function Pu(e){return Z(e,"Uint8Array")}function Au(e){return Z(e,"Unknown")}function ku(e){return Z(e,"Unsafe")}function Tu(e){return Z(e,"Void")}function Fu(e){return be(e)&&I in e&&he(e[I])}function we(e){return Ps(e)||As(e)||kt(e)||sr(e)||Gr(e)||qr(e)||Tt(e)||Ft(e)||$u(e)||Nt(e)||Mt(e)||Pe(e)||Hr(e)||gt(e)||ht(e)||_e(e)||_r(e)||Su(e)||eo(e)||jt(e)||Ne(e)||zr(e)||Vr(e)||Fe(e)||ks(e)||ir(e)||to(e)||xt(e)||Cu(e)||It(e)||ar(e)||te(e)||Pu(e)||Au(e)||ku(e)||Tu(e)||Fu(e)}function Nu(e){return h(Ce(e,[We]))}function Mu(e){return h({...e,[We]:"Optional"})}function ju(e,t){return t===!1?Nu(e):Mu(e)}function Ze(e,t){let r=t??!0;return _e(e)?Ti(e,r):ju(e,r)}function Eu(e,t){let r={};for(let n of globalThis.Object.getOwnPropertyNames(e))r[n]=Ze(e[n],t);return r}function Lu(e,t){return Eu(e.properties,t)}function Ti(e,t){let r=Lu(e,t);return re(r)}function ro(e,t={}){let r=e.every((o)=>Ne(o)),n=we(t.unevaluatedProperties)?{unevaluatedProperties:t.unevaluatedProperties}:{};return h(t.unevaluatedProperties===!1||we(t.unevaluatedProperties)||r?{...n,[I]:"Intersect",type:"object",allOf:e}:{...n,[I]:"Intersect",allOf:e},t)}function Uu(e){return e.every((t)=>at(t))}function Ku(e){return Ce(e,[We])}function Fi(e){return e.map((t)=>at(t)?Ku(t):t)}function Bu(e,t){return Uu(e)?Ze(ro(Fi(e),t)):ro(Fi(e),t)}function Do(e,t={}){if(e.length===1)return h(e[0],t);if(e.length===0)return J(t);if(e.some((r)=>ne(r)))throw Error("Cannot intersect transform types");return Bu(e,t)}function et(e,t){if(e.length===1)return h(e[0],t);if(e.length===0)return J(t);if(e.some((r)=>ne(r)))throw Error("Cannot intersect transform types");return ro(e,t)}function no(e,t){return h({[I]:"Union",anyOf:e},t)}function vu(e){return e.some((t)=>at(t))}function Ni(e){return e.map((t)=>at(t)?Du(t):t)}function Du(e){return Ce(e,[We])}function qu(e,t){return vu(e)?Ze(no(Ni(e),t)):no(Ni(e),t)}function Zt(e,t){return e.length===1?h(e[0],t):e.length===0?J(t):qu(e,t)}function ie(e,t){return e.length===0?J(t):e.length===1?h(e[0],t):no(e,t)}class Ts extends oe{}function Gu(e){return e.replace(/\\\$/g,"$").replace(/\\\*/g,"*").replace(/\\\^/g,"^").replace(/\\\|/g,"|").replace(/\\\(/g,"(").replace(/\\\)/g,")")}function Fs(e,t,r){return e[t]===r&&e.charCodeAt(t-1)!==92}function ur(e,t){return Fs(e,t,"(")}function oo(e,t){return Fs(e,t,")")}function Mi(e,t){return Fs(e,t,"|")}function Hu(e){if(!(ur(e,0)&&oo(e,e.length-1)))return!1;let t=0;for(let r=0;r<e.length;r++){if(ur(e,r))t+=1;if(oo(e,r))t-=1;if(t===0&&r!==e.length-1)return!1}return!0}function zu(e){return e.slice(1,e.length-1)}function Vu(e){let t=0;for(let r=0;r<e.length;r++){if(ur(e,r))t+=1;if(oo(e,r))t-=1;if(Mi(e,r)&&t===0)return!0}return!1}function Ju(e){for(let t=0;t<e.length;t++)if(ur(e,t))return!0;return!1}function Wu(e){let[t,r]=[0,0],n=[];for(let s=0;s<e.length;s++){if(ur(e,s))t+=1;if(oo(e,s))t-=1;if(Mi(e,s)&&t===0){let i=e.slice(r,s);if(i.length>0)n.push(In(i));r=s+1}}let o=e.slice(r);if(o.length>0)n.push(In(o));if(n.length===0)return{type:"const",const:""};if(n.length===1)return n[0];return{type:"or",expr:n}}function Xu(e){function t(o,s){if(!ur(o,s))throw new Ts("TemplateLiteralParser: Index must point to open parens");let i=0;for(let a=s;a<o.length;a++){if(ur(o,a))i+=1;if(oo(o,a))i-=1;if(i===0)return[s,a]}throw new Ts("TemplateLiteralParser: Unclosed group parens in expression")}function r(o,s){for(let i=s;i<o.length;i++)if(ur(o,i))return[s,i];return[s,o.length]}let n=[];for(let o=0;o<e.length;o++)if(ur(e,o)){let[s,i]=t(e,o),a=e.slice(s,i+1);n.push(In(a)),o=i}else{let[s,i]=r(e,o),a=e.slice(s,i);if(a.length>0)n.push(In(a));o=i-1}return n.length===0?{type:"const",const:""}:n.length===1?n[0]:{type:"and",expr:n}}function In(e){return Hu(e)?In(zu(e)):Vu(e)?Wu(e):Ju(e)?Xu(e):{type:"const",const:Gu(e)}}function bn(e){return In(e.slice(1,e.length-1))}class ji extends oe{}function Yu(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 Jr(e){return Yu(e)||Zu(e)?!1:Qu(e)?!0:e.type==="and"?e.expr.every((t)=>Jr(t)):e.type==="or"?e.expr.every((t)=>Jr(t)):e.type==="const"?!0:(()=>{throw new ji("Unknown expression type")})()}function Ei(e){let t=bn(e.pattern);return Jr(t)}class Li extends oe{}function*Ui(e){if(e.length===1)return yield*e[0];for(let t of e[0])for(let r of Ui(e.slice(1)))yield`${t}${r}`}function*ed(e){return yield*Ui(e.expr.map((t)=>[...so(t)]))}function*td(e){for(let t of e.expr)yield*so(t)}function*rd(e){return yield e.const}function*so(e){return e.type==="and"?yield*ed(e):e.type==="or"?yield*td(e):e.type==="const"?yield*rd(e):(()=>{throw new Li("Unknown expression")})()}function qo(e){let t=bn(e.pattern);return Jr(t)?[...so(t)]:[]}function se(e,t){return h({[I]:"Literal",const:e,type:typeof e},t)}function Go(e){return h({[I]:"Boolean",type:"boolean"},e)}function Rn(e){return h({[I]:"BigInt",type:"bigint"},e)}function _t(e){return h({[I]:"Number",type:"number"},e)}function Et(e){return h({[I]:"String",type:"string"},e)}function*nd(e){let t=e.trim().replace(/"|'/g,"");return t==="boolean"?yield Go():t==="number"?yield _t():t==="bigint"?yield Rn():t==="string"?yield Et():yield(()=>{let r=t.split("|").map((n)=>se(n.trim()));return r.length===0?J():r.length===1?r[0]:Zt(r)})()}function*od(e){if(e[1]!=="{"){let t=se("$"),r=Ns(e.slice(1));return yield*[t,...r]}for(let t=2;t<e.length;t++)if(e[t]==="}"){let r=nd(e.slice(2,t)),n=Ns(e.slice(t+1));return yield*[...r,...n]}yield se(e)}function*Ns(e){for(let t=0;t<e.length;t++)if(e[t]==="$"){let r=se(e.slice(0,t)),n=od(e.slice(t));return yield*[r,...n]}yield se(e)}function Ki(e){return[...Ns(e)]}var Bi="(true|false)",Ho="(0|[1-9][0-9]*)",vi="(.*)";var Or="^(0|[1-9][0-9]*)$",wr="^(.*)$",Di="^(?!.*)$";class qi extends oe{}function sd(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Gi(e,t){return xt(e)?e.pattern.slice(1,e.pattern.length-1):te(e)?`(${e.anyOf.map((r)=>Gi(r,t)).join("|")})`:jt(e)?`${t}${Ho}`:Mt(e)?`${t}${Ho}`:Gr(e)?`${t}${Ho}`:ir(e)?`${t}${vi}`:gt(e)?`${t}${sd(e.const.toString())}`:sr(e)?`${t}${Bi}`:(()=>{throw new qi(`Unexpected Kind '${e[I]}'`)})()}function Ms(e){return`^${e.map((t)=>Gi(t,"")).join("")}$`}function Wr(e){let r=qo(e).map((n)=>se(n));return Zt(r)}function zo(e,t){let r=he(e)?Ms(Ki(e)):Ms(e);return h({[I]:"TemplateLiteral",type:"string",pattern:r},t)}function id(e){return qo(e).map((r)=>r.toString())}function ad(e){let t=[];for(let r of e)t.push(...ct(r));return t}function cd(e){return[e.toString()]}function ct(e){return[...new Set(xt(e)?id(e):te(e)?ad(e.anyOf):gt(e)?cd(e.const):jt(e)?["[number]"]:Mt(e)?["[number]"]:[])]}function ud(e,t,r){let n={};for(let o of Object.getOwnPropertyNames(t))n[o]=$r(e,ct(t[o]),r);return n}function dd(e,t,r){return ud(e,t.properties,r)}function Hi(e,t,r){let n=dd(e,t,r);return re(n)}function Vi(e,t){return e.map((r)=>Ji(r,t))}function fd(e){return e.filter((t)=>!_r(t))}function md(e,t){return Do(fd(Vi(e,t)))}function pd(e){return e.some((t)=>_r(t))?[]:e}function ld(e,t){return Zt(pd(Vi(e,t)))}function yd(e,t){return t in e?e[t]:t==="[number]"?Zt(e):J()}function gd(e,t){return t==="[number]"?e:J()}function hd(e,t){return t in e?e[t]:J()}function Ji(e,t){return Pe(e)?md(e.allOf,t):te(e)?ld(e.anyOf,t):It(e)?yd(e.items??[],t):kt(e)?gd(e.items,t):Ne(e)?hd(e.properties,t):J()}function io(e,t){return t.map((r)=>Ji(e,r))}function zi(e,t){return Zt(io(e,t))}function $r(e,t,r){if(Fe(e)||Fe(t)){if(!we(e)||!we(t))throw new oe("Index types using Ref parameters require both Type and Key to be of TSchema");return Ie("Index",[e,t])}if(_e(t))return Hi(e,t,r);if(ht(t))return Wi(e,t,r);return h(we(t)?zi(e,ct(t)):zi(e,t),r)}function xd(e,t,r){return{[t]:$r(e,[t],Re(r))}}function Id(e,t,r){return t.reduce((n,o)=>({...n,...xd(e,o,r)}),{})}function bd(e,t,r){return Id(e,t.keys,r)}function Wi(e,t,r){let n=bd(e,t,r);return re(n)}function _n(e,t){return h({[I]:"Iterator",type:"Iterator",items:e},t)}function Rd(e){return globalThis.Object.keys(e).filter((t)=>!at(e[t]))}function _d(e,t){let r=Rd(e),n=r.length>0?{[I]:"Object",type:"object",required:r,properties:e}:{[I]:"Object",type:"object",properties:e};return h(n,t)}var ue=_d;function Vo(e,t){return h({[I]:"Promise",type:"Promise",item:e},t)}function Od(e){return h(Ce(e,[Xt]))}function wd(e){return h({...e,[Xt]:"Readonly"})}function $d(e,t){return t===!1?Od(e):wd(e)}function ut(e,t){let r=t??!0;return _e(e)?Xi(e,r):$d(e,r)}function Sd(e,t){let r={};for(let n of globalThis.Object.getOwnPropertyNames(e))r[n]=ut(e[n],t);return r}function Cd(e,t){return Sd(e.properties,t)}function Xi(e,t){let r=Cd(e,t);return re(r)}function Ot(e,t){return h(e.length>0?{[I]:"Tuple",type:"array",items:e,additionalItems:!1,minItems:e.length,maxItems:e.length}:{[I]:"Tuple",type:"array",minItems:e.length,maxItems:e.length},t)}function Yi(e,t){return e.includes(t)}function Qi(e){return[...new Set(e)]}function Pd(e,t){return e.filter((r)=>t.includes(r))}function Ad(e,t){return e.reduce((r,n)=>Pd(r,n),t)}function Zi(e){return e.length===1?e[0]:e.length>1?Ad(e.slice(1),e[0]):[]}function ea(e){let t=[];for(let r of e)t.push(...r);return t}function ta(e,t){return e in t?wt(e,t[e]):re(t)}function kd(e){return{[e]:se(e)}}function Td(e){let t={};for(let r of e)t[r]=se(r);return t}function Fd(e,t){return Yi(t,e)?kd(e):Td(t)}function Nd(e,t){let r=Fd(e,t);return ta(e,r)}function ao(e,t){return t.map((r)=>wt(e,r))}function Md(e,t){let r={};for(let n of globalThis.Object.getOwnPropertyNames(t))r[n]=wt(e,t[n]);return r}function wt(e,t){let r={...t};return at(t)?Ze(wt(e,Ce(t,[We]))):xn(t)?ut(wt(e,Ce(t,[Xt]))):_e(t)?ta(e,t.properties):ht(t)?Nd(e,t.keys):Ft(t)?hn(ao(e,t.parameters),wt(e,t.returns),r):Nt(t)?Qt(ao(e,t.parameters),wt(e,t.returns),r):qr(t)?gn(wt(e,t.items),r):Hr(t)?_n(wt(e,t.items),r):Pe(t)?et(ao(e,t.allOf),r):te(t)?ie(ao(e,t.anyOf),r):It(t)?Ot(ao(e,t.items??[]),r):Ne(t)?ue(Md(e,t.properties),r):kt(t)?yn(wt(e,t.items),r):zr(t)?Vo(wt(e,t.item),r):t}function jd(e,t){let r={};for(let n of e)r[n]=wt(n,t);return r}function ra(e,t,r){let n=we(e)?ct(e):e,o=t({[I]:"MappedKey",keys:n}),s=jd(n,o);return ue(s,r)}function $t(...e){let[t,r]=typeof e[0]==="string"?[e[0],e[1]]:[e[0].$id,e[1]];if(typeof t!=="string")throw new oe("Ref: $ref must be a string");return h({[I]:"Ref",$ref:t},r)}function na(e){let t=[];for(let r of e)t.push(St(r));return t}function Ed(e){let t=na(e);return ea(t)}function Ld(e){let t=na(e);return Zi(t)}function Ud(e){return e.map((t,r)=>r.toString())}function Kd(e){return["[number]"]}function Bd(e){return globalThis.Object.getOwnPropertyNames(e)}function vd(e){if(!js)return[];return globalThis.Object.getOwnPropertyNames(e).map((r)=>r[0]==="^"&&r[r.length-1]==="$"?r.slice(1,r.length-1):r)}function St(e){return Pe(e)?Ed(e.allOf):te(e)?Ld(e.anyOf):It(e)?Ud(e.items??[]):kt(e)?Kd(e.items):Ne(e)?Bd(e.properties):Vr(e)?vd(e.patternProperties):[]}var js=!1;function dr(e){js=!0;let t=St(e);return js=!1,`^(${t.map((n)=>`(${n})`).join("|")})$`}function Dd(e,t){return Ie("KeyOf",[Ie(e,t)])}function qd(e){return Ie("KeyOf",[$t(e)])}function Gd(e,t){let r=St(e),n=Hd(r),o=Zt(n);return h(o,t)}function Hd(e){return e.map((t)=>t==="[number]"?_t():se(t))}function On(e,t){return Tt(e)?Dd(e.target,e.parameters):Fe(e)?qd(e.$ref):_e(e)?oa(e,t):Gd(e,t)}function zd(e,t){let r={};for(let n of globalThis.Object.getOwnPropertyNames(e))r[n]=On(e[n],Re(t));return r}function Vd(e,t){return zd(e.properties,t)}function oa(e,t){let r=Vd(e,t);return re(r)}function Jo(e){let t=St(e),r=io(e,t);return t.map((n,o)=>[t[o],r[o]])}function Jd(e){return e.allOf.every((t)=>fr(t))}function Wd(e){return e.anyOf.some((t)=>fr(t))}function Xd(e){return!fr(e.not)}function fr(e){return e[I]==="Intersect"?Jd(e):e[I]==="Union"?Wd(e):e[I]==="Not"?Xd(e):e[I]==="Undefined"?!0:!1}function Yd(e){switch(e.errorType){case g.ArrayContains:return"Expected array to contain at least one matching value";case g.ArrayMaxContains:return`Expected array to contain no more than ${e.schema.maxContains} matching values`;case g.ArrayMinContains:return`Expected array to contain at least ${e.schema.minContains} matching values`;case g.ArrayMaxItems:return`Expected array length to be less or equal to ${e.schema.maxItems}`;case g.ArrayMinItems:return`Expected array length to be greater or equal to ${e.schema.minItems}`;case g.ArrayUniqueItems:return"Expected array elements to be unique";case g.Array:return"Expected array";case g.AsyncIterator:return"Expected AsyncIterator";case g.BigIntExclusiveMaximum:return`Expected bigint to be less than ${e.schema.exclusiveMaximum}`;case g.BigIntExclusiveMinimum:return`Expected bigint to be greater than ${e.schema.exclusiveMinimum}`;case g.BigIntMaximum:return`Expected bigint to be less or equal to ${e.schema.maximum}`;case g.BigIntMinimum:return`Expected bigint to be greater or equal to ${e.schema.minimum}`;case g.BigIntMultipleOf:return`Expected bigint to be a multiple of ${e.schema.multipleOf}`;case g.BigInt:return"Expected bigint";case g.Boolean:return"Expected boolean";case g.DateExclusiveMinimumTimestamp:return`Expected Date timestamp to be greater than ${e.schema.exclusiveMinimumTimestamp}`;case g.DateExclusiveMaximumTimestamp:return`Expected Date timestamp to be less than ${e.schema.exclusiveMaximumTimestamp}`;case g.DateMinimumTimestamp:return`Expected Date timestamp to be greater or equal to ${e.schema.minimumTimestamp}`;case g.DateMaximumTimestamp:return`Expected Date timestamp to be less or equal to ${e.schema.maximumTimestamp}`;case g.DateMultipleOfTimestamp:return`Expected Date timestamp to be a multiple of ${e.schema.multipleOfTimestamp}`;case g.Date:return"Expected Date";case g.Function:return"Expected function";case g.IntegerExclusiveMaximum:return`Expected integer to be less than ${e.schema.exclusiveMaximum}`;case g.IntegerExclusiveMinimum:return`Expected integer to be greater than ${e.schema.exclusiveMinimum}`;case g.IntegerMaximum:return`Expected integer to be less or equal to ${e.schema.maximum}`;case g.IntegerMinimum:return`Expected integer to be greater or equal to ${e.schema.minimum}`;case g.IntegerMultipleOf:return`Expected integer to be a multiple of ${e.schema.multipleOf}`;case g.Integer:return"Expected integer";case g.IntersectUnevaluatedProperties:return"Unexpected property";case g.Intersect:return"Expected all values to match";case g.Iterator:return"Expected Iterator";case g.Literal:return`Expected ${typeof e.schema.const==="string"?`'${e.schema.const}'`:e.schema.const}`;case g.Never:return"Never";case g.Not:return"Value should not match";case g.Null:return"Expected null";case g.NumberExclusiveMaximum:return`Expected number to be less than ${e.schema.exclusiveMaximum}`;case g.NumberExclusiveMinimum:return`Expected number to be greater than ${e.schema.exclusiveMinimum}`;case g.NumberMaximum:return`Expected number to be less or equal to ${e.schema.maximum}`;case g.NumberMinimum:return`Expected number to be greater or equal to ${e.schema.minimum}`;case g.NumberMultipleOf:return`Expected number to be a multiple of ${e.schema.multipleOf}`;case g.Number:return"Expected number";case g.Object:return"Expected object";case g.ObjectAdditionalProperties:return"Unexpected property";case g.ObjectMaxProperties:return`Expected object to have no more than ${e.schema.maxProperties} properties`;case g.ObjectMinProperties:return`Expected object to have at least ${e.schema.minProperties} properties`;case g.ObjectRequiredProperty:return"Expected required property";case g.Promise:return"Expected Promise";case g.RegExp:return"Expected string to match regular expression";case g.StringFormatUnknown:return`Unknown format '${e.schema.format}'`;case g.StringFormat:return`Expected string to match '${e.schema.format}' format`;case g.StringMaxLength:return`Expected string length less or equal to ${e.schema.maxLength}`;case g.StringMinLength:return`Expected string length greater or equal to ${e.schema.minLength}`;case g.StringPattern:return`Expected string to match '${e.schema.pattern}'`;case g.String:return"Expected string";case g.Symbol:return"Expected symbol";case g.TupleLength:return`Expected tuple to have ${e.schema.maxItems||0} elements`;case g.Tuple:return"Expected tuple";case g.Uint8ArrayMaxByteLength:return`Expected byte length less or equal to ${e.schema.maxByteLength}`;case g.Uint8ArrayMinByteLength:return`Expected byte length greater or equal to ${e.schema.minByteLength}`;case g.Uint8Array:return"Expected Uint8Array";case g.Undefined:return"Expected undefined";case g.Union:return"Expected union value";case g.Void:return"Expected void";case g.Kind:return`Expected kind '${e.schema[I]}'`;default:return"Unknown error type"}}var Qd=Yd;function sa(){return Qd}class ia extends oe{constructor(e){super(`Unable to dereference schema with $id '${e.$ref}'`);this.schema=e}}function Zd(e,t){let r=t.find((n)=>n.$id===e.$ref);if(r===void 0)throw new ia(e);return He(r,t)}function Sr(e,t){if(!Ge(e.$id)||t.some((r)=>r.$id===e.$id))return t;return t.push(e),t}function He(e,t){return e[I]==="This"||e[I]==="Ref"?Zd(e,t):e}class aa extends oe{constructor(e){super("Unable to hash value");this.value=e}}var bt;(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"})(bt||(bt={}));var wn=BigInt("14695981039346656037"),[ef,tf]=[BigInt("1099511628211"),BigInt("18446744073709551616")],rf=Array.from({length:256}).map((e,t)=>BigInt(t)),ca=new Float64Array(1),ua=new DataView(ca.buffer),da=new Uint8Array(ca.buffer);function*nf(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 of(e){tt(bt.Array);for(let t of e)$n(t)}function sf(e){tt(bt.Boolean),tt(e?1:0)}function af(e){tt(bt.BigInt),ua.setBigInt64(0,e);for(let t of da)tt(t)}function cf(e){tt(bt.Date),$n(e.getTime())}function uf(e){tt(bt.Null)}function df(e){tt(bt.Number),ua.setFloat64(0,e);for(let t of da)tt(t)}function ff(e){tt(bt.Object);for(let t of globalThis.Object.getOwnPropertyNames(e).sort())$n(t),$n(e[t])}function mf(e){tt(bt.String);for(let t=0;t<e.length;t++)for(let r of nf(e.charCodeAt(t)))tt(r)}function pf(e){tt(bt.Symbol),$n(e.description)}function lf(e){tt(bt.Uint8Array);for(let t=0;t<e.length;t++)tt(e[t])}function yf(e){return tt(bt.Undefined)}function $n(e){if(Ue(e))return of(e);if(Br(e))return sf(e);if(lt(e))return af(e);if(mn(e))return cf(e);if(Kr(e))return uf(e);if(H(e))return df(e);if(it(e))return ff(e);if(Ge(e))return mf(e);if(vr(e))return pf(e);if(pn(e))return lf(e);if(ot(e))return yf(e);throw new aa(e)}function tt(e){wn=wn^rf[e],wn=wn*ef%tf}function Sn(e){return wn=BigInt("14695981039346656037"),$n(e),wn}function Cr(e){return h({[I]:"Any"},e)}function Pr(e){return h({[I]:"Unknown"},e)}var gf=["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 fa(e){try{return new RegExp(e),!0}catch{return!1}}function Es(e){if(!he(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 ma(e){return Ls(e)||$e(e)}function co(e){return xe(e)||Uo(e)}function le(e){return xe(e)||yt(e)}function Ls(e){return xe(e)||br(e)}function de(e){return xe(e)||he(e)}function hf(e){return xe(e)||he(e)&&Es(e)&&fa(e)}function xf(e){return xe(e)||he(e)&&Es(e)}function pa(e){return xe(e)||$e(e)}function Wo(e){return be(e)&&e[We]==="Optional"}function Lt(e){return ee(e,"Any")&&de(e.$id)}function If(e){return ee(e,"Argument")&&yt(e.index)}function Xr(e){return ee(e,"Array")&&e.type==="array"&&de(e.$id)&&$e(e.items)&&le(e.minItems)&&le(e.maxItems)&&Ls(e.uniqueItems)&&pa(e.contains)&&le(e.minContains)&&le(e.maxContains)}function Us(e){return ee(e,"AsyncIterator")&&e.type==="AsyncIterator"&&de(e.$id)&&$e(e.items)}function Xo(e){return ee(e,"BigInt")&&e.type==="bigint"&&de(e.$id)&&co(e.exclusiveMaximum)&&co(e.exclusiveMinimum)&&co(e.maximum)&&co(e.minimum)&&co(e.multipleOf)}function Yr(e){return ee(e,"Boolean")&&e.type==="boolean"&&de(e.$id)}function bf(e){return ee(e,"Computed")&&he(e.target)&&Ke(e.parameters)&&e.parameters.every((t)=>$e(t))}function Yo(e){return ee(e,"Constructor")&&e.type==="Constructor"&&de(e.$id)&&Ke(e.parameters)&&e.parameters.every((t)=>$e(t))&&$e(e.returns)}function Qo(e){return ee(e,"Date")&&e.type==="Date"&&de(e.$id)&&le(e.exclusiveMaximumTimestamp)&&le(e.exclusiveMinimumTimestamp)&&le(e.maximumTimestamp)&&le(e.minimumTimestamp)&&le(e.multipleOfTimestamp)}function Zo(e){return ee(e,"Function")&&e.type==="Function"&&de(e.$id)&&Ke(e.parameters)&&e.parameters.every((t)=>$e(t))&&$e(e.returns)}function mr(e){return ee(e,"Integer")&&e.type==="integer"&&de(e.$id)&&le(e.exclusiveMaximum)&&le(e.exclusiveMinimum)&&le(e.maximum)&&le(e.minimum)&&le(e.multipleOf)}function la(e){return be(e)&&Object.entries(e).every(([t,r])=>Es(t)&&$e(r))}function Qr(e){return ee(e,"Intersect")&&(he(e.type)&&e.type!=="object"?!1:!0)&&Ke(e.allOf)&&e.allOf.every((t)=>$e(t)&&!Sf(t))&&de(e.type)&&(Ls(e.unevaluatedProperties)||pa(e.unevaluatedProperties))&&de(e.$id)}function Ks(e){return ee(e,"Iterator")&&e.type==="Iterator"&&de(e.$id)&&$e(e.items)}function ee(e,t){return be(e)&&I in e&&e[I]===t}function ya(e){return Ar(e)&&he(e.const)}function ga(e){return Ar(e)&&yt(e.const)}function ha(e){return Ar(e)&&br(e.const)}function Ar(e){return ee(e,"Literal")&&de(e.$id)&&Rf(e.const)}function Rf(e){return br(e)||yt(e)||he(e)}function _f(e){return ee(e,"MappedKey")&&Ke(e.keys)&&e.keys.every((t)=>yt(t)||he(t))}function Of(e){return ee(e,"MappedResult")&&la(e.properties)}function kr(e){return ee(e,"Never")&&be(e.not)&&Object.getOwnPropertyNames(e.not).length===0}function Cn(e){return ee(e,"Not")&&$e(e.not)}function Bs(e){return ee(e,"Null")&&e.type==="null"&&de(e.$id)}function dt(e){return ee(e,"Number")&&e.type==="number"&&de(e.$id)&&le(e.exclusiveMaximum)&&le(e.exclusiveMinimum)&&le(e.maximum)&&le(e.minimum)&&le(e.multipleOf)}function Ae(e){return ee(e,"Object")&&e.type==="object"&&de(e.$id)&&la(e.properties)&&ma(e.additionalProperties)&&le(e.minProperties)&&le(e.maxProperties)}function vs(e){return ee(e,"Promise")&&e.type==="Promise"&&de(e.$id)&&$e(e.item)}function Xe(e){return ee(e,"Record")&&e.type==="object"&&de(e.$id)&&ma(e.additionalProperties)&&be(e.patternProperties)&&((t)=>{let r=Object.getOwnPropertyNames(t.patternProperties);return r.length===1&&fa(r[0])&&be(t.patternProperties)&&$e(t.patternProperties[r[0]])})(e)}function wf(e){return ee(e,"Ref")&&de(e.$id)&&he(e.$ref)}function uo(e){return ee(e,"RegExp")&&de(e.$id)&&he(e.source)&&he(e.flags)&&le(e.maxLength)&&le(e.minLength)}function Ut(e){return ee(e,"String")&&e.type==="string"&&de(e.$id)&&le(e.minLength)&&le(e.maxLength)&&hf(e.pattern)&&xf(e.format)}function fo(e){return ee(e,"Symbol")&&e.type==="symbol"&&de(e.$id)}function mo(e){return ee(e,"TemplateLiteral")&&e.type==="string"&&he(e.pattern)&&e.pattern[0]==="^"&&e.pattern[e.pattern.length-1]==="$"}function $f(e){return ee(e,"This")&&de(e.$id)&&he(e.$ref)}function Sf(e){return be(e)&&Oe in e}function es(e){return ee(e,"Tuple")&&e.type==="array"&&de(e.$id)&&yt(e.minItems)&&yt(e.maxItems)&&e.minItems===e.maxItems&&(xe(e.items)&&xe(e.additionalItems)&&e.minItems===0||Ke(e.items)&&e.items.every((t)=>$e(t)))}function Zr(e){return ee(e,"Undefined")&&e.type==="undefined"&&de(e.$id)}function pr(e){return ee(e,"Union")&&de(e.$id)&&be(e)&&Ke(e.anyOf)&&e.anyOf.every((t)=>$e(t))}function po(e){return ee(e,"Uint8Array")&&e.type==="Uint8Array"&&de(e.$id)&&le(e.minByteLength)&&le(e.maxByteLength)}function Kt(e){return ee(e,"Unknown")&&de(e.$id)}function Cf(e){return ee(e,"Unsafe")}function ts(e){return ee(e,"Void")&&e.type==="void"&&de(e.$id)}function Pf(e){return be(e)&&I in e&&he(e[I])&&!gf.includes(e[I])}function $e(e){return be(e)&&(Lt(e)||If(e)||Xr(e)||Yr(e)||Xo(e)||Us(e)||bf(e)||Yo(e)||Qo(e)||Zo(e)||mr(e)||Qr(e)||Ks(e)||Ar(e)||_f(e)||Of(e)||kr(e)||Cn(e)||Bs(e)||dt(e)||Ae(e)||vs(e)||Xe(e)||wf(e)||uo(e)||Ut(e)||fo(e)||mo(e)||$f(e)||es(e)||Zr(e)||pr(e)||po(e)||Kt(e)||Cf(e)||ts(e)||Pf(e))}class Oa extends oe{}var x;(function(e){e[e.Union=0]="Union",e[e.True=1]="True",e[e.False=2]="False"})(x||(x={}));function Ct(e){return e===x.False?e:x.True}function Pn(e){throw new Oa(e)}function Be(e){return kr(e)||Qr(e)||pr(e)||Kt(e)||Lt(e)}function ve(e,t){return kr(t)?Sa(e,t):Qr(t)?rs(e,t):pr(t)?zs(e,t):Kt(t)?ka(e,t):Lt(t)?Hs(e,t):Pn("StructuralRight")}function Hs(e,t){return x.True}function Af(e,t){return Qr(t)?rs(e,t):pr(t)&&t.anyOf.some((r)=>Lt(r)||Kt(r))?x.True:pr(t)?x.Union:Kt(t)?x.True:Lt(t)?x.True:x.Union}function kf(e,t){return Kt(e)?x.False:Lt(e)?x.Union:kr(e)?x.True:x.False}function Tf(e,t){return Ae(t)&&ns(t)?x.True:Be(t)?ve(e,t):!Xr(t)?x.False:Ct(fe(e.items,t.items))}function Ff(e,t){return Be(t)?ve(e,t):!Us(t)?x.False:Ct(fe(e.items,t.items))}function Nf(e,t){return Be(t)?ve(e,t):Ae(t)?rt(e,t):Xe(t)?Pt(e,t):Xo(t)?x.True:x.False}function wa(e,t){return ha(e)?x.True:Yr(e)?x.True:x.False}function Mf(e,t){return Be(t)?ve(e,t):Ae(t)?rt(e,t):Xe(t)?Pt(e,t):Yr(t)?x.True:x.False}function jf(e,t){return Be(t)?ve(e,t):Ae(t)?rt(e,t):!Yo(t)?x.False:e.parameters.length>t.parameters.length?x.False:!e.parameters.every((r,n)=>Ct(fe(t.parameters[n],r))===x.True)?x.False:Ct(fe(e.returns,t.returns))}function Ef(e,t){return Be(t)?ve(e,t):Ae(t)?rt(e,t):Xe(t)?Pt(e,t):Qo(t)?x.True:x.False}function Lf(e,t){return Be(t)?ve(e,t):Ae(t)?rt(e,t):!Zo(t)?x.False:e.parameters.length>t.parameters.length?x.False:!e.parameters.every((r,n)=>Ct(fe(t.parameters[n],r))===x.True)?x.False:Ct(fe(e.returns,t.returns))}function $a(e,t){return Ar(e)&&yt(e.const)?x.True:dt(e)||mr(e)?x.True:x.False}function Uf(e,t){return mr(t)||dt(t)?x.True:Be(t)?ve(e,t):Ae(t)?rt(e,t):Xe(t)?Pt(e,t):x.False}function rs(e,t){return t.allOf.every((r)=>fe(e,r)===x.True)?x.True:x.False}function Kf(e,t){return e.allOf.some((r)=>fe(r,t)===x.True)?x.True:x.False}function Bf(e,t){return Be(t)?ve(e,t):!Ks(t)?x.False:Ct(fe(e.items,t.items))}function vf(e,t){return Ar(t)&&t.const===e.const?x.True:Be(t)?ve(e,t):Ae(t)?rt(e,t):Xe(t)?Pt(e,t):Ut(t)?Aa(e,t):dt(t)?Ca(e,t):mr(t)?$a(e,t):Yr(t)?wa(e,t):x.False}function Sa(e,t){return x.False}function Df(e,t){return x.True}function Ia(e){let[t,r]=[e,0];while(!0){if(!Cn(t))break;t=t.not,r+=1}return r%2===0?t:Pr()}function qf(e,t){return Cn(e)?fe(Ia(e),t):Cn(t)?fe(e,Ia(t)):Pn("Invalid fallthrough for Not")}function Gf(e,t){return Be(t)?ve(e,t):Ae(t)?rt(e,t):Xe(t)?Pt(e,t):Bs(t)?x.True:x.False}function Ca(e,t){return ga(e)?x.True:dt(e)||mr(e)?x.True:x.False}function Hf(e,t){return Be(t)?ve(e,t):Ae(t)?rt(e,t):Xe(t)?Pt(e,t):mr(t)||dt(t)?x.True:x.False}function ft(e,t){return Object.getOwnPropertyNames(e.properties).length===t}function ba(e){return ns(e)}function Ra(e){return ft(e,0)||ft(e,1)&&"description"in e.properties&&pr(e.properties.description)&&e.properties.description.anyOf.length===2&&(Ut(e.properties.description.anyOf[0])&&Zr(e.properties.description.anyOf[1])||Ut(e.properties.description.anyOf[1])&&Zr(e.properties.description.anyOf[0]))}function Ds(e){return ft(e,0)}function _a(e){return ft(e,0)}function zf(e){return ft(e,0)}function Vf(e){return ft(e,0)}function Jf(e){return ns(e)}function Wf(e){let t=_t();return ft(e,0)||ft(e,1)&&"length"in e.properties&&Ct(fe(e.properties.length,t))===x.True}function Xf(e){return ft(e,0)}function ns(e){let t=_t();return ft(e,0)||ft(e,1)&&"length"in e.properties&&Ct(fe(e.properties.length,t))===x.True}function Yf(e){let t=Qt([Cr()],Cr());return ft(e,0)||ft(e,1)&&"then"in e.properties&&Ct(fe(e.properties.then,t))===x.True}function Pa(e,t){return fe(e,t)===x.False?x.False:Wo(e)&&!Wo(t)?x.False:x.True}function rt(e,t){return Kt(e)?x.False:Lt(e)?x.Union:kr(e)||ya(e)&&ba(t)||ga(e)&&Ds(t)||ha(e)&&_a(t)||fo(e)&&Ra(t)||Xo(e)&&zf(t)||Ut(e)&&ba(t)||fo(e)&&Ra(t)||dt(e)&&Ds(t)||mr(e)&&Ds(t)||Yr(e)&&_a(t)||po(e)&&Jf(t)||Qo(e)&&Vf(t)||Yo(e)&&Xf(t)||Zo(e)&&Wf(t)?x.True:Xe(e)&&Ut(qs(e))?(()=>t[Yt]==="Record"?x.True:x.False)():Xe(e)&&dt(qs(e))?(()=>ft(t,0)?x.True:x.False)():x.False}function Qf(e,t){return Be(t)?ve(e,t):Xe(t)?Pt(e,t):!Ae(t)?x.False:(()=>{for(let r of Object.getOwnPropertyNames(t.properties)){if(!(r in e.properties)&&!Wo(t.properties[r]))return x.False;if(Wo(t.properties[r]))return x.True;if(Pa(e.properties[r],t.properties[r])===x.False)return x.False}return x.True})()}function Zf(e,t){return Be(t)?ve(e,t):Ae(t)&&Yf(t)?x.True:!vs(t)?x.False:Ct(fe(e.item,t.item))}function qs(e){return Or in e.patternProperties?_t():(wr in e.patternProperties)?Et():Pn("Unknown record key pattern")}function Gs(e){return Or in e.patternProperties?e.patternProperties[Or]:(wr in e.patternProperties)?e.patternProperties[wr]:Pn("Unable to get record value schema")}function Pt(e,t){let[r,n]=[qs(t),Gs(t)];return ya(e)&&dt(r)&&Ct(fe(e,n))===x.True?x.True:po(e)&&dt(r)?fe(e,n):Ut(e)&&dt(r)?fe(e,n):Xr(e)&&dt(r)?fe(e,n):Ae(e)?(()=>{for(let o of Object.getOwnPropertyNames(e.properties))if(Pa(n,e.properties[o])===x.False)return x.False;return x.True})():x.False}function em(e,t){return Be(t)?ve(e,t):Ae(t)?rt(e,t):!Xe(t)?x.False:fe(Gs(e),Gs(t))}function tm(e,t){let r=uo(e)?Et():e,n=uo(t)?Et():t;return fe(r,n)}function Aa(e,t){return Ar(e)&&he(e.const)?x.True:Ut(e)?x.True:x.False}function rm(e,t){return Be(t)?ve(e,t):Ae(t)?rt(e,t):Xe(t)?Pt(e,t):Ut(t)?x.True:x.False}function nm(e,t){return Be(t)?ve(e,t):Ae(t)?rt(e,t):Xe(t)?Pt(e,t):fo(t)?x.True:x.False}function om(e,t){return mo(e)?fe(Wr(e),t):mo(t)?fe(e,Wr(t)):Pn("Invalid fallthrough for TemplateLiteral")}function sm(e,t){return Xr(t)&&e.items!==void 0&&e.items.every((r)=>fe(r,t.items)===x.True)}function im(e,t){return kr(e)?x.True:Kt(e)?x.False:Lt(e)?x.Union:x.False}function am(e,t){return Be(t)?ve(e,t):Ae(t)&&ns(t)?x.True:Xr(t)&&sm(e,t)?x.True:!es(t)?x.False:xe(e.items)&&!xe(t.items)||!xe(e.items)&&xe(t.items)?x.False:xe(e.items)&&!xe(t.items)?x.True:e.items.every((r,n)=>fe(r,t.items[n])===x.True)?x.True:x.False}function cm(e,t){return Be(t)?ve(e,t):Ae(t)?rt(e,t):Xe(t)?Pt(e,t):po(t)?x.True:x.False}function um(e,t){return Be(t)?ve(e,t):Ae(t)?rt(e,t):Xe(t)?Pt(e,t):ts(t)?mm(e,t):Zr(t)?x.True:x.False}function zs(e,t){return t.anyOf.some((r)=>fe(e,r)===x.True)?x.True:x.False}function dm(e,t){return e.anyOf.every((r)=>fe(r,t)===x.True)?x.True:x.False}function ka(e,t){return x.True}function fm(e,t){return kr(t)?Sa(e,t):Qr(t)?rs(e,t):pr(t)?zs(e,t):Lt(t)?Hs(e,t):Ut(t)?Aa(e,t):dt(t)?Ca(e,t):mr(t)?$a(e,t):Yr(t)?wa(e,t):Xr(t)?kf(e,t):es(t)?im(e,t):Ae(t)?rt(e,t):Kt(t)?x.True:x.False}function mm(e,t){return Zr(e)?x.True:Zr(e)?x.True:x.False}function pm(e,t){return Qr(t)?rs(e,t):pr(t)?zs(e,t):Kt(t)?ka(e,t):Lt(t)?Hs(e,t):Ae(t)?rt(e,t):ts(t)?x.True:x.False}function fe(e,t){return mo(e)||mo(t)?om(e,t):uo(e)||uo(t)?tm(e,t):Cn(e)||Cn(t)?qf(e,t):Lt(e)?Af(e,t):Xr(e)?Tf(e,t):Xo(e)?Nf(e,t):Yr(e)?Mf(e,t):Us(e)?Ff(e,t):Yo(e)?jf(e,t):Qo(e)?Ef(e,t):Zo(e)?Lf(e,t):mr(e)?Uf(e,t):Qr(e)?Kf(e,t):Ks(e)?Bf(e,t):Ar(e)?vf(e,t):kr(e)?Df(e,t):Bs(e)?Gf(e,t):dt(e)?Hf(e,t):Ae(e)?Qf(e,t):Xe(e)?em(e,t):Ut(e)?rm(e,t):fo(e)?nm(e,t):es(e)?am(e,t):vs(e)?Zf(e,t):po(e)?cm(e,t):Zr(e)?um(e,t):pr(e)?dm(e,t):Kt(e)?fm(e,t):ts(e)?pm(e,t):Pn(`Unknown left type operand '${e[I]}'`)}function Tr(e,t){return fe(e,t)}function lm(e,t,r,n,o){let s={};for(let i of globalThis.Object.getOwnPropertyNames(e))s[i]=An(e[i],t,r,n,Re(o));return s}function ym(e,t,r,n,o){return lm(e.properties,t,r,n,o)}function Ta(e,t,r,n,o){let s=ym(e,t,r,n,o);return re(s)}function gm(e,t,r,n){let o=Tr(e,t);return o===x.Union?ie([r,n]):o===x.True?r:n}function An(e,t,r,n,o){return _e(e)?Ta(e,t,r,n,o):ht(e)?h(Fa(e,t,r,n,o)):h(gm(e,t,r,n),o)}function hm(e,t,r,n,o){return{[e]:An(se(e),t,r,n,Re(o))}}function xm(e,t,r,n,o){return e.reduce((s,i)=>({...s,...hm(i,t,r,n,o)}),{})}function Im(e,t,r,n,o){return xm(e.keys,t,r,n,o)}function Fa(e,t,r,n,o){let s=Im(e,t,r,n,o);return re(s)}class Na extends oe{constructor(e){super("Unknown type");this.schema=e}}function bm(e){return e[I]==="Any"||e[I]==="Unknown"}function X(e){return e!==void 0}function Rm(e,t,r){return!0}function _m(e,t,r){return!0}function Om(e,t,r){if(!Ue(r))return!1;if(X(e.minItems)&&!(r.length>=e.minItems))return!1;if(X(e.maxItems)&&!(r.length<=e.maxItems))return!1;if(!r.every((s)=>ze(e.items,t,s)))return!1;if(e.uniqueItems===!0&&!function(){let s=new Set;for(let i of r){let a=Sn(i);if(s.has(a))return!1;else s.add(a)}return!0}())return!1;if(!(X(e.contains)||H(e.minContains)||H(e.maxContains)))return!0;let n=X(e.contains)?e.contains:J(),o=r.reduce((s,i)=>ze(n,t,i)?s+1:s,0);if(o===0)return!1;if(H(e.minContains)&&o<e.minContains)return!1;if(H(e.maxContains)&&o>e.maxContains)return!1;return!0}function wm(e,t,r){return Ao(r)}function $m(e,t,r){if(!lt(r))return!1;if(X(e.exclusiveMaximum)&&!(r<e.exclusiveMaximum))return!1;if(X(e.exclusiveMinimum)&&!(r>e.exclusiveMinimum))return!1;if(X(e.maximum)&&!(r<=e.maximum))return!1;if(X(e.minimum)&&!(r>=e.minimum))return!1;if(X(e.multipleOf)&&r%e.multipleOf!==BigInt(0))return!1;return!0}function Sm(e,t,r){return Br(r)}function Cm(e,t,r){return ze(e.returns,t,r.prototype)}function Pm(e,t,r){if(!mn(r))return!1;if(X(e.exclusiveMaximumTimestamp)&&!(r.getTime()<e.exclusiveMaximumTimestamp))return!1;if(X(e.exclusiveMinimumTimestamp)&&!(r.getTime()>e.exclusiveMinimumTimestamp))return!1;if(X(e.maximumTimestamp)&&!(r.getTime()<=e.maximumTimestamp))return!1;if(X(e.minimumTimestamp)&&!(r.getTime()>=e.minimumTimestamp))return!1;if(X(e.multipleOfTimestamp)&&r.getTime()%e.multipleOfTimestamp!==0)return!1;return!0}function Am(e,t,r){return Mo(r)}function km(e,t,r){let n=globalThis.Object.values(e.$defs),o=e.$defs[e.$ref];return ze(o,[...t,...n],r)}function Tm(e,t,r){if(!No(r))return!1;if(X(e.exclusiveMaximum)&&!(r<e.exclusiveMaximum))return!1;if(X(e.exclusiveMinimum)&&!(r>e.exclusiveMinimum))return!1;if(X(e.maximum)&&!(r<=e.maximum))return!1;if(X(e.minimum)&&!(r>=e.minimum))return!1;if(X(e.multipleOf)&&r%e.multipleOf!==0)return!1;return!0}function Fm(e,t,r){let n=e.allOf.every((o)=>ze(o,t,r));if(e.unevaluatedProperties===!1){let o=new RegExp(dr(e)),s=Object.getOwnPropertyNames(r).every((i)=>o.test(i));return n&&s}else if(we(e.unevaluatedProperties)){let o=new RegExp(dr(e)),s=Object.getOwnPropertyNames(r).every((i)=>o.test(i)||ze(e.unevaluatedProperties,t,r[i]));return n&&s}else return n}function Nm(e,t,r){return ko(r)}function Mm(e,t,r){return r===e.const}function jm(e,t,r){return!1}function Em(e,t,r){return!ze(e.not,t,r)}function Lm(e,t,r){return Kr(r)}function Um(e,t,r){if(!ge.IsNumberLike(r))return!1;if(X(e.exclusiveMaximum)&&!(r<e.exclusiveMaximum))return!1;if(X(e.exclusiveMinimum)&&!(r>e.exclusiveMinimum))return!1;if(X(e.minimum)&&!(r>=e.minimum))return!1;if(X(e.maximum)&&!(r<=e.maximum))return!1;if(X(e.multipleOf)&&r%e.multipleOf!==0)return!1;return!0}function Km(e,t,r){if(!ge.IsObjectLike(r))return!1;if(X(e.minProperties)&&!(Object.getOwnPropertyNames(r).length>=e.minProperties))return!1;if(X(e.maxProperties)&&!(Object.getOwnPropertyNames(r).length<=e.maxProperties))return!1;let n=Object.getOwnPropertyNames(e.properties);for(let o of n){let s=e.properties[o];if(e.required&&e.required.includes(o)){if(!ze(s,t,r[o]))return!1;if((fr(s)||bm(s))&&!(o in r))return!1}else if(ge.IsExactOptionalProperty(r,o)&&!ze(s,t,r[o]))return!1}if(e.additionalProperties===!1){let o=Object.getOwnPropertyNames(r);if(e.required&&e.required.length===n.length&&o.length===n.length)return!0;else return o.every((s)=>n.includes(s))}else if(typeof e.additionalProperties==="object")return Object.getOwnPropertyNames(r).every((s)=>n.includes(s)||ze(e.additionalProperties,t,r[s]));else return!0}function Bm(e,t,r){return To(r)}function vm(e,t,r){if(!ge.IsRecordLike(r))return!1;if(X(e.minProperties)&&!(Object.getOwnPropertyNames(r).length>=e.minProperties))return!1;if(X(e.maxProperties)&&!(Object.getOwnPropertyNames(r).length<=e.maxProperties))return!1;let[n,o]=Object.entries(e.patternProperties)[0],s=new RegExp(n),i=Object.entries(r).every(([c,d])=>s.test(c)?ze(o,t,d):!0),a=typeof e.additionalProperties==="object"?Object.entries(r).every(([c,d])=>!s.test(c)?ze(e.additionalProperties,t,d):!0):!0,u=e.additionalProperties===!1?Object.getOwnPropertyNames(r).every((c)=>s.test(c)):!0;return i&&a&&u}function Dm(e,t,r){return ze(He(e,t),t,r)}function qm(e,t,r){let n=new RegExp(e.source,e.flags);if(X(e.minLength)){if(!(r.length>=e.minLength))return!1}if(X(e.maxLength)){if(!(r.length<=e.maxLength))return!1}return n.test(r)}function Gm(e,t,r){if(!Ge(r))return!1;if(X(e.minLength)){if(!(r.length>=e.minLength))return!1}if(X(e.maxLength)){if(!(r.length<=e.maxLength))return!1}if(X(e.pattern)){if(!new RegExp(e.pattern).test(r))return!1}if(X(e.format)){if(!$s(e.format))return!1;return Ss(e.format)(r)}return!0}function Hm(e,t,r){return vr(r)}function zm(e,t,r){return Ge(r)&&new RegExp(e.pattern).test(r)}function Vm(e,t,r){return ze(He(e,t),t,r)}function Jm(e,t,r){if(!Ue(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(!ze(e.items[n],t,r[n]))return!1;return!0}function Wm(e,t,r){return ot(r)}function Xm(e,t,r){return e.anyOf.some((n)=>ze(n,t,r))}function Ym(e,t,r){if(!pn(r))return!1;if(X(e.maxByteLength)&&!(r.length<=e.maxByteLength))return!1;if(X(e.minByteLength)&&!(r.length>=e.minByteLength))return!1;return!0}function Qm(e,t,r){return!0}function Zm(e,t,r){return ge.IsVoidLike(r)}function ep(e,t,r){if(!Qn(e[I]))return!1;return Cs(e[I])(e,r)}function ze(e,t,r){let n=X(e.$id)?Sr(e,t):t,o=e;switch(o[I]){case"Any":return Rm(o,n,r);case"Argument":return _m(o,n,r);case"Array":return Om(o,n,r);case"AsyncIterator":return wm(o,n,r);case"BigInt":return $m(o,n,r);case"Boolean":return Sm(o,n,r);case"Constructor":return Cm(o,n,r);case"Date":return Pm(o,n,r);case"Function":return Am(o,n,r);case"Import":return km(o,n,r);case"Integer":return Tm(o,n,r);case"Intersect":return Fm(o,n,r);case"Iterator":return Nm(o,n,r);case"Literal":return Mm(o,n,r);case"Never":return jm(o,n,r);case"Not":return Em(o,n,r);case"Null":return Lm(o,n,r);case"Number":return Um(o,n,r);case"Object":return Km(o,n,r);case"Promise":return Bm(o,n,r);case"Record":return vm(o,n,r);case"Ref":return Dm(o,n,r);case"RegExp":return qm(o,n,r);case"String":return Gm(o,n,r);case"Symbol":return Hm(o,n,r);case"TemplateLiteral":return zm(o,n,r);case"This":return Vm(o,n,r);case"Tuple":return Jm(o,n,r);case"Undefined":return Wm(o,n,r);case"Union":return Xm(o,n,r);case"Uint8Array":return Ym(o,n,r);case"Unknown":return Qm(o,n,r);case"Void":return Zm(o,n,r);default:if(!Qn(o[I]))throw new Na(o);return ep(o,n,r)}}function en(...e){return e.length===3?ze(e[0],e[1],e[2]):ze(e[0],[],e[1])}var g;(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"})(g||(g={}));class Ma extends oe{constructor(e){super("Unknown type");this.schema=e}}function lr(e){return e.replace(/~/g,"~0").replace(/\//g,"~1")}function Y(e){return e!==void 0}class Vs{constructor(e){this.iterator=e}[Symbol.iterator](){return this.iterator}First(){let e=this.iterator.next();return e.done?void 0:e.value}}function S(e,t,r,n,o=[]){return{type:e,schema:t,path:r,value:n,message:sa()({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(!Ue(n))return yield S(g.Array,e,r,n);if(Y(e.minItems)&&!(n.length>=e.minItems))yield S(g.ArrayMinItems,e,r,n);if(Y(e.maxItems)&&!(n.length<=e.maxItems))yield S(g.ArrayMaxItems,e,r,n);for(let i=0;i<n.length;i++)yield*Ve(e.items,t,`${r}/${i}`,n[i]);if(e.uniqueItems===!0&&!function(){let i=new Set;for(let a of n){let u=Sn(a);if(i.has(u))return!1;else i.add(u)}return!0}())yield S(g.ArrayUniqueItems,e,r,n);if(!(Y(e.contains)||Y(e.minContains)||Y(e.maxContains)))return;let o=Y(e.contains)?e.contains:J(),s=n.reduce((i,a,u)=>Ve(o,t,`${r}${u}`,a).next().done===!0?i+1:i,0);if(s===0)yield S(g.ArrayContains,e,r,n);if(H(e.minContains)&&s<e.minContains)yield S(g.ArrayMinContains,e,r,n);if(H(e.maxContains)&&s>e.maxContains)yield S(g.ArrayMaxContains,e,r,n)}function*op(e,t,r,n){if(!Ao(n))yield S(g.AsyncIterator,e,r,n)}function*sp(e,t,r,n){if(!lt(n))return yield S(g.BigInt,e,r,n);if(Y(e.exclusiveMaximum)&&!(n<e.exclusiveMaximum))yield S(g.BigIntExclusiveMaximum,e,r,n);if(Y(e.exclusiveMinimum)&&!(n>e.exclusiveMinimum))yield S(g.BigIntExclusiveMinimum,e,r,n);if(Y(e.maximum)&&!(n<=e.maximum))yield S(g.BigIntMaximum,e,r,n);if(Y(e.minimum)&&!(n>=e.minimum))yield S(g.BigIntMinimum,e,r,n);if(Y(e.multipleOf)&&n%e.multipleOf!==BigInt(0))yield S(g.BigIntMultipleOf,e,r,n)}function*ip(e,t,r,n){if(!Br(n))yield S(g.Boolean,e,r,n)}function*ap(e,t,r,n){yield*Ve(e.returns,t,r,n.prototype)}function*cp(e,t,r,n){if(!mn(n))return yield S(g.Date,e,r,n);if(Y(e.exclusiveMaximumTimestamp)&&!(n.getTime()<e.exclusiveMaximumTimestamp))yield S(g.DateExclusiveMaximumTimestamp,e,r,n);if(Y(e.exclusiveMinimumTimestamp)&&!(n.getTime()>e.exclusiveMinimumTimestamp))yield S(g.DateExclusiveMinimumTimestamp,e,r,n);if(Y(e.maximumTimestamp)&&!(n.getTime()<=e.maximumTimestamp))yield S(g.DateMaximumTimestamp,e,r,n);if(Y(e.minimumTimestamp)&&!(n.getTime()>=e.minimumTimestamp))yield S(g.DateMinimumTimestamp,e,r,n);if(Y(e.multipleOfTimestamp)&&n.getTime()%e.multipleOfTimestamp!==0)yield S(g.DateMultipleOfTimestamp,e,r,n)}function*up(e,t,r,n){if(!Mo(n))yield S(g.Function,e,r,n)}function*dp(e,t,r,n){let o=globalThis.Object.values(e.$defs),s=e.$defs[e.$ref];yield*Ve(s,[...t,...o],r,n)}function*fp(e,t,r,n){if(!No(n))return yield S(g.Integer,e,r,n);if(Y(e.exclusiveMaximum)&&!(n<e.exclusiveMaximum))yield S(g.IntegerExclusiveMaximum,e,r,n);if(Y(e.exclusiveMinimum)&&!(n>e.exclusiveMinimum))yield S(g.IntegerExclusiveMinimum,e,r,n);if(Y(e.maximum)&&!(n<=e.maximum))yield S(g.IntegerMaximum,e,r,n);if(Y(e.minimum)&&!(n>=e.minimum))yield S(g.IntegerMinimum,e,r,n);if(Y(e.multipleOf)&&n%e.multipleOf!==0)yield S(g.IntegerMultipleOf,e,r,n)}function*mp(e,t,r,n){let o=!1;for(let s of e.allOf)for(let i of Ve(s,t,r,n))o=!0,yield i;if(o)return yield S(g.Intersect,e,r,n);if(e.unevaluatedProperties===!1){let s=new RegExp(dr(e));for(let i of Object.getOwnPropertyNames(n))if(!s.test(i))yield S(g.IntersectUnevaluatedProperties,e,`${r}/${i}`,n)}if(typeof e.unevaluatedProperties==="object"){let s=new RegExp(dr(e));for(let i of Object.getOwnPropertyNames(n))if(!s.test(i)){let a=Ve(e.unevaluatedProperties,t,`${r}/${i}`,n[i]).next();if(!a.done)yield a.value}}}function*pp(e,t,r,n){if(!ko(n))yield S(g.Iterator,e,r,n)}function*lp(e,t,r,n){if(n!==e.const)yield S(g.Literal,e,r,n)}function*yp(e,t,r,n){yield S(g.Never,e,r,n)}function*gp(e,t,r,n){if(Ve(e.not,t,r,n).next().done===!0)yield S(g.Not,e,r,n)}function*hp(e,t,r,n){if(!Kr(n))yield S(g.Null,e,r,n)}function*xp(e,t,r,n){if(!ge.IsNumberLike(n))return yield S(g.Number,e,r,n);if(Y(e.exclusiveMaximum)&&!(n<e.exclusiveMaximum))yield S(g.NumberExclusiveMaximum,e,r,n);if(Y(e.exclusiveMinimum)&&!(n>e.exclusiveMinimum))yield S(g.NumberExclusiveMinimum,e,r,n);if(Y(e.maximum)&&!(n<=e.maximum))yield S(g.NumberMaximum,e,r,n);if(Y(e.minimum)&&!(n>=e.minimum))yield S(g.NumberMinimum,e,r,n);if(Y(e.multipleOf)&&n%e.multipleOf!==0)yield S(g.NumberMultipleOf,e,r,n)}function*Ip(e,t,r,n){if(!ge.IsObjectLike(n))return yield S(g.Object,e,r,n);if(Y(e.minProperties)&&!(Object.getOwnPropertyNames(n).length>=e.minProperties))yield S(g.ObjectMinProperties,e,r,n);if(Y(e.maxProperties)&&!(Object.getOwnPropertyNames(n).length<=e.maxProperties))yield S(g.ObjectMaxProperties,e,r,n);let o=Array.isArray(e.required)?e.required:[],s=Object.getOwnPropertyNames(e.properties),i=Object.getOwnPropertyNames(n);for(let a of o){if(i.includes(a))continue;yield S(g.ObjectRequiredProperty,e.properties[a],`${r}/${lr(a)}`,void 0)}if(e.additionalProperties===!1){for(let a of i)if(!s.includes(a))yield S(g.ObjectAdditionalProperties,e,`${r}/${lr(a)}`,n[a])}if(typeof e.additionalProperties==="object")for(let a of i){if(s.includes(a))continue;yield*Ve(e.additionalProperties,t,`${r}/${lr(a)}`,n[a])}for(let a of s){let u=e.properties[a];if(e.required&&e.required.includes(a)){if(yield*Ve(u,t,`${r}/${lr(a)}`,n[a]),fr(e)&&!(a in n))yield S(g.ObjectRequiredProperty,u,`${r}/${lr(a)}`,void 0)}else if(ge.IsExactOptionalProperty(n,a))yield*Ve(u,t,`${r}/${lr(a)}`,n[a])}}function*bp(e,t,r,n){if(!To(n))yield S(g.Promise,e,r,n)}function*Rp(e,t,r,n){if(!ge.IsRecordLike(n))return yield S(g.Object,e,r,n);if(Y(e.minProperties)&&!(Object.getOwnPropertyNames(n).length>=e.minProperties))yield S(g.ObjectMinProperties,e,r,n);if(Y(e.maxProperties)&&!(Object.getOwnPropertyNames(n).length<=e.maxProperties))yield S(g.ObjectMaxProperties,e,r,n);let[o,s]=Object.entries(e.patternProperties)[0],i=new RegExp(o);for(let[a,u]of Object.entries(n))if(i.test(a))yield*Ve(s,t,`${r}/${lr(a)}`,u);if(typeof e.additionalProperties==="object"){for(let[a,u]of Object.entries(n))if(!i.test(a))yield*Ve(e.additionalProperties,t,`${r}/${lr(a)}`,u)}if(e.additionalProperties===!1)for(let[a,u]of Object.entries(n)){if(i.test(a))continue;return yield S(g.ObjectAdditionalProperties,e,`${r}/${lr(a)}`,u)}}function*_p(e,t,r,n){yield*Ve(He(e,t),t,r,n)}function*Op(e,t,r,n){if(!Ge(n))return yield S(g.String,e,r,n);if(Y(e.minLength)&&!(n.length>=e.minLength))yield S(g.StringMinLength,e,r,n);if(Y(e.maxLength)&&!(n.length<=e.maxLength))yield S(g.StringMaxLength,e,r,n);if(!new RegExp(e.source,e.flags).test(n))return yield S(g.RegExp,e,r,n)}function*wp(e,t,r,n){if(!Ge(n))return yield S(g.String,e,r,n);if(Y(e.minLength)&&!(n.length>=e.minLength))yield S(g.StringMinLength,e,r,n);if(Y(e.maxLength)&&!(n.length<=e.maxLength))yield S(g.StringMaxLength,e,r,n);if(Ge(e.pattern)){if(!new RegExp(e.pattern).test(n))yield S(g.StringPattern,e,r,n)}if(Ge(e.format)){if(!$s(e.format))yield S(g.StringFormatUnknown,e,r,n);else if(!Ss(e.format)(n))yield S(g.StringFormat,e,r,n)}}function*$p(e,t,r,n){if(!vr(n))yield S(g.Symbol,e,r,n)}function*Sp(e,t,r,n){if(!Ge(n))return yield S(g.String,e,r,n);if(!new RegExp(e.pattern).test(n))yield S(g.StringPattern,e,r,n)}function*Cp(e,t,r,n){yield*Ve(He(e,t),t,r,n)}function*Pp(e,t,r,n){if(!Ue(n))return yield S(g.Tuple,e,r,n);if(e.items===void 0&&n.length!==0)return yield S(g.TupleLength,e,r,n);if(n.length!==e.maxItems)return yield S(g.TupleLength,e,r,n);if(!e.items)return;for(let o=0;o<e.items.length;o++)yield*Ve(e.items[o],t,`${r}/${o}`,n[o])}function*Ap(e,t,r,n){if(!ot(n))yield S(g.Undefined,e,r,n)}function*kp(e,t,r,n){if(en(e,t,n))return;let o=e.anyOf.map((s)=>new Vs(Ve(s,t,r,n)));yield S(g.Union,e,r,n,o)}function*Tp(e,t,r,n){if(!pn(n))return yield S(g.Uint8Array,e,r,n);if(Y(e.maxByteLength)&&!(n.length<=e.maxByteLength))yield S(g.Uint8ArrayMaxByteLength,e,r,n);if(Y(e.minByteLength)&&!(n.length>=e.minByteLength))yield S(g.Uint8ArrayMinByteLength,e,r,n)}function*Fp(e,t,r,n){}function*Np(e,t,r,n){if(!ge.IsVoidLike(n))yield S(g.Void,e,r,n)}function*Mp(e,t,r,n){if(!Cs(e[I])(e,n))yield S(g.Kind,e,r,n)}function*Ve(e,t,r,n){let o=Y(e.$id)?[...t,e]:t,s=e;switch(s[I]){case"Any":return yield*tp(s,o,r,n);case"Argument":return yield*rp(s,o,r,n);case"Array":return yield*np(s,o,r,n);case"AsyncIterator":return yield*op(s,o,r,n);case"BigInt":return yield*sp(s,o,r,n);case"Boolean":return yield*ip(s,o,r,n);case"Constructor":return yield*ap(s,o,r,n);case"Date":return yield*cp(s,o,r,n);case"Function":return yield*up(s,o,r,n);case"Import":return yield*dp(s,o,r,n);case"Integer":return yield*fp(s,o,r,n);case"Intersect":return yield*mp(s,o,r,n);case"Iterator":return yield*pp(s,o,r,n);case"Literal":return yield*lp(s,o,r,n);case"Never":return yield*yp(s,o,r,n);case"Not":return yield*gp(s,o,r,n);case"Null":return yield*hp(s,o,r,n);case"Number":return yield*xp(s,o,r,n);case"Object":return yield*Ip(s,o,r,n);case"Promise":return yield*bp(s,o,r,n);case"Record":return yield*Rp(s,o,r,n);case"Ref":return yield*_p(s,o,r,n);case"RegExp":return yield*Op(s,o,r,n);case"String":return yield*wp(s,o,r,n);case"Symbol":return yield*$p(s,o,r,n);case"TemplateLiteral":return yield*Sp(s,o,r,n);case"This":return yield*Cp(s,o,r,n);case"Tuple":return yield*Pp(s,o,r,n);case"Undefined":return yield*Ap(s,o,r,n);case"Union":return yield*kp(s,o,r,n);case"Uint8Array":return yield*Tp(s,o,r,n);case"Unknown":return yield*Fp(s,o,r,n);case"Void":return yield*Np(s,o,r,n);default:if(!Qn(s[I]))throw new Ma(e);return yield*Mp(s,o,r,n)}}function ja(...e){let t=e.length===3?Ve(e[0],e[1],"",e[2]):Ve(e[0],[],"",e[1]);return new Vs(t)}class Js extends oe{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 Ea extends oe{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 Se(e,t,r){try{return ne(e)?e[Oe].Decode(r):r}catch(n){throw new Ea(e,t,r,n)}}function jp(e,t,r,n){return Ue(n)?Se(e,r,n.map((o,s)=>Bt(e.items,t,`${r}/${s}`,o))):Se(e,r,n)}function Ep(e,t,r,n){if(!it(n)||jo(n))return Se(e,r,n);let o=Jo(e),s=o.map((d)=>d[0]),i={...n};for(let[d,f]of o)if(d in i)i[d]=Bt(f,t,`${r}/${d}`,i[d]);if(!ne(e.unevaluatedProperties))return Se(e,r,i);let a=Object.getOwnPropertyNames(i),u=e.unevaluatedProperties,c={...i};for(let d of a)if(!s.includes(d))c[d]=Se(u,`${r}/${d}`,c[d]);return Se(e,r,c)}function Lp(e,t,r,n){let o=globalThis.Object.values(e.$defs),s=e.$defs[e.$ref],i=Bt(s,[...t,...o],r,n);return Se(e,r,i)}function Up(e,t,r,n){return Se(e,r,Bt(e.not,t,r,n))}function Kp(e,t,r,n){if(!it(n))return Se(e,r,n);let o=St(e),s={...n};for(let c of o){if(!Fo(s,c))continue;if(ot(s[c])&&(!ar(e.properties[c])||ge.IsExactOptionalProperty(s,c)))continue;s[c]=Bt(e.properties[c],t,`${r}/${c}`,s[c])}if(!we(e.additionalProperties))return Se(e,r,s);let i=Object.getOwnPropertyNames(s),a=e.additionalProperties,u={...s};for(let c of i)if(!o.includes(c))u[c]=Se(a,`${r}/${c}`,u[c]);return Se(e,r,u)}function Bp(e,t,r,n){if(!it(n))return Se(e,r,n);let o=Object.getOwnPropertyNames(e.patternProperties)[0],s=new RegExp(o),i={...n};for(let d of Object.getOwnPropertyNames(n))if(s.test(d))i[d]=Bt(e.patternProperties[o],t,`${r}/${d}`,i[d]);if(!we(e.additionalProperties))return Se(e,r,i);let a=Object.getOwnPropertyNames(i),u=e.additionalProperties,c={...i};for(let d of a)if(!s.test(d))c[d]=Se(u,`${r}/${d}`,c[d]);return Se(e,r,c)}function vp(e,t,r,n){let o=He(e,t);return Se(e,r,Bt(o,t,r,n))}function Dp(e,t,r,n){let o=He(e,t);return Se(e,r,Bt(o,t,r,n))}function qp(e,t,r,n){return Ue(n)&&Ue(e.items)?Se(e,r,e.items.map((o,s)=>Bt(o,t,`${r}/${s}`,n[s]))):Se(e,r,n)}function Gp(e,t,r,n){for(let o of e.anyOf){if(!en(o,t,n))continue;let s=Bt(o,t,r,n);return Se(e,r,s)}return Se(e,r,n)}function Bt(e,t,r,n){let o=Sr(e,t),s=e;switch(e[I]){case"Array":return jp(s,o,r,n);case"Import":return Lp(s,o,r,n);case"Intersect":return Ep(s,o,r,n);case"Not":return Up(s,o,r,n);case"Object":return Kp(s,o,r,n);case"Record":return Bp(s,o,r,n);case"Ref":return vp(s,o,r,n);case"Symbol":return Se(s,r,n);case"This":return Dp(s,o,r,n);case"Tuple":return qp(s,o,r,n);case"Union":return Gp(s,o,r,n);default:return Se(s,r,n)}}function La(e,t,r){return Bt(e,t,"",r)}class Ws extends oe{constructor(e,t,r){super("The encoded value does not match the expected schema");this.schema=e,this.value=t,this.error=r}}class Ua extends oe{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 Ye(e,t,r){try{return ne(e)?e[Oe].Encode(r):r}catch(n){throw new Ua(e,t,r,n)}}function Hp(e,t,r,n){let o=Ye(e,r,n);return Ue(o)?o.map((s,i)=>vt(e.items,t,`${r}/${i}`,s)):o}function zp(e,t,r,n){let o=globalThis.Object.values(e.$defs),s=e.$defs[e.$ref],i=Ye(e,r,n);return vt(s,[...t,...o],r,i)}function Vp(e,t,r,n){let o=Ye(e,r,n);if(!it(n)||jo(n))return o;let s=Jo(e),i=s.map((f)=>f[0]),a={...o};for(let[f,p]of s)if(f in a)a[f]=vt(p,t,`${r}/${f}`,a[f]);if(!ne(e.unevaluatedProperties))return a;let u=Object.getOwnPropertyNames(a),c=e.unevaluatedProperties,d={...a};for(let f of u)if(!i.includes(f))d[f]=Ye(c,`${r}/${f}`,d[f]);return d}function Jp(e,t,r,n){return Ye(e.not,r,Ye(e,r,n))}function Wp(e,t,r,n){let o=Ye(e,r,n);if(!it(o))return o;let s=St(e),i={...o};for(let d of s){if(!Fo(i,d))continue;if(ot(i[d])&&(!ar(e.properties[d])||ge.IsExactOptionalProperty(i,d)))continue;i[d]=vt(e.properties[d],t,`${r}/${d}`,i[d])}if(!we(e.additionalProperties))return i;let a=Object.getOwnPropertyNames(i),u=e.additionalProperties,c={...i};for(let d of a)if(!s.includes(d))c[d]=Ye(u,`${r}/${d}`,c[d]);return c}function Xp(e,t,r,n){let o=Ye(e,r,n);if(!it(n))return o;let s=Object.getOwnPropertyNames(e.patternProperties)[0],i=new RegExp(s),a={...o};for(let f of Object.getOwnPropertyNames(n))if(i.test(f))a[f]=vt(e.patternProperties[s],t,`${r}/${f}`,a[f]);if(!we(e.additionalProperties))return a;let u=Object.getOwnPropertyNames(a),c=e.additionalProperties,d={...a};for(let f of u)if(!i.test(f))d[f]=Ye(c,`${r}/${f}`,d[f]);return d}function Yp(e,t,r,n){let o=He(e,t),s=vt(o,t,r,n);return Ye(e,r,s)}function Qp(e,t,r,n){let o=He(e,t),s=vt(o,t,r,n);return Ye(e,r,s)}function Zp(e,t,r,n){let o=Ye(e,r,n);return Ue(e.items)?e.items.map((s,i)=>vt(s,t,`${r}/${i}`,o[i])):[]}function el(e,t,r,n){for(let o of e.anyOf){if(!en(o,t,n))continue;let s=vt(o,t,r,n);return Ye(e,r,s)}for(let o of e.anyOf){let s=vt(o,t,r,n);if(!en(e,t,s))continue;return Ye(e,r,s)}return Ye(e,r,n)}function vt(e,t,r,n){let o=Sr(e,t),s=e;switch(e[I]){case"Array":return Hp(s,o,r,n);case"Import":return zp(s,o,r,n);case"Intersect":return Vp(s,o,r,n);case"Not":return Jp(s,o,r,n);case"Object":return Wp(s,o,r,n);case"Record":return Xp(s,o,r,n);case"Ref":return Yp(s,o,r,n);case"This":return Qp(s,o,r,n);case"Tuple":return Zp(s,o,r,n);case"Union":return el(s,o,r,n);default:return Ye(s,r,n)}}function Ka(e,t,r){return vt(e,t,"",r)}function tl(e,t){return ne(e)||De(e.items,t)}function rl(e,t){return ne(e)||De(e.items,t)}function nl(e,t){return ne(e)||De(e.returns,t)||e.parameters.some((r)=>De(r,t))}function ol(e,t){return ne(e)||De(e.returns,t)||e.parameters.some((r)=>De(r,t))}function sl(e,t){return ne(e)||ne(e.unevaluatedProperties)||e.allOf.some((r)=>De(r,t))}function il(e,t){let r=globalThis.Object.getOwnPropertyNames(e.$defs).reduce((o,s)=>[...o,e.$defs[s]],[]),n=e.$defs[e.$ref];return ne(e)||De(n,[...r,...t])}function al(e,t){return ne(e)||De(e.items,t)}function cl(e,t){return ne(e)||De(e.not,t)}function ul(e,t){return ne(e)||Object.values(e.properties).some((r)=>De(r,t))||we(e.additionalProperties)&&De(e.additionalProperties,t)}function dl(e,t){return ne(e)||De(e.item,t)}function fl(e,t){let r=Object.getOwnPropertyNames(e.patternProperties)[0],n=e.patternProperties[r];return ne(e)||De(n,t)||we(e.additionalProperties)&&ne(e.additionalProperties)}function ml(e,t){if(ne(e))return!0;return De(He(e,t),t)}function pl(e,t){if(ne(e))return!0;return De(He(e,t),t)}function ll(e,t){return ne(e)||!ot(e.items)&&e.items.some((r)=>De(r,t))}function yl(e,t){return ne(e)||e.anyOf.some((r)=>De(r,t))}function De(e,t){let r=Sr(e,t),n=e;if(e.$id&&Xs.has(e.$id))return!1;if(e.$id)Xs.add(e.$id);switch(e[I]){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 il(n,r);case"Intersect":return sl(n,r);case"Iterator":return al(n,r);case"Not":return cl(n,r);case"Object":return ul(n,r);case"Promise":return dl(n,r);case"Record":return fl(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 ne(e)}}var Xs=new Set;function Ba(e,t){return Xs.clear(),De(e,t)}class va{constructor(e,t,r,n){this.schema=e,this.references=t,this.checkFunc=r,this.code=n,this.hasTransform=Ba(e,t)}Code(){return this.code}Schema(){return this.schema}References(){return this.references}Errors(e){return ja(this.schema,this.references,e)}Check(e){return this.checkFunc(e)}Decode(e){if(!this.checkFunc(e))throw new Js(this.schema,e,this.Errors(e).First());return this.hasTransform?La(this.schema,this.references,e):e}Encode(e){let t=this.hasTransform?Ka(this.schema,this.references,e):e;if(!this.checkFunc(t))throw new Ws(this.schema,e,this.Errors(e).First());return t}}var yr;(function(e){function t(s){return s===36}e.DollarSign=t;function r(s){return s===95}e.IsUnderscore=r;function n(s){return s>=65&&s<=90||s>=97&&s<=122}e.IsAlpha=n;function o(s){return s>=48&&s<=57}e.IsNumeric=o})(yr||(yr={}));var os;(function(e){function t(s){if(s.length===0)return!1;return yr.IsNumeric(s.charCodeAt(0))}function r(s){if(t(s))return!1;for(let i=0;i<s.length;i++){let a=s.charCodeAt(i);if(!(yr.IsAlpha(a)||yr.IsNumeric(a)||yr.DollarSign(a)||yr.IsUnderscore(a)))return!1}return!0}function n(s){return s.replace(/'/g,"\\'")}function o(s,i){return r(i)?`${s}.${i}`:`${s}['${n(i)}']`}e.Encode=o})(os||(os={}));var Ys;(function(e){function t(r){let n=[];for(let o=0;o<r.length;o++){let s=r.charCodeAt(o);if(yr.IsNumeric(s)||yr.IsAlpha(s))n.push(r.charAt(o));else n.push(`_${s}_`)}return n.join("").replace(/__/g,"_")}e.Encode=t})(Ys||(Ys={}));var Qs;(function(e){function t(r){return r.replace(/'/g,"\\'")}e.Escape=t})(Qs||(Qs={}));class Da extends oe{constructor(e){super("Unknown type");this.schema=e}}class Zs extends oe{constructor(e){super("Preflight validation check failed to guard for the given schema");this.schema=e}}var tn;(function(e){function t(i,a,u){return ge.ExactOptionalPropertyTypes?`('${a}' in ${i} ? ${u} : true)`:`(${os.Encode(i,a)} !== undefined ? ${u} : true)`}e.IsExactOptionalProperty=t;function r(i){return!ge.AllowArrayObject?`(typeof ${i} === 'object' && ${i} !== null && !Array.isArray(${i}))`:`(typeof ${i} === 'object' && ${i} !== null)`}e.IsObjectLike=r;function n(i){return!ge.AllowArrayObject?`(typeof ${i} === 'object' && ${i} !== null && !Array.isArray(${i}) && !(${i} instanceof Date) && !(${i} instanceof Uint8Array))`:`(typeof ${i} === 'object' && ${i} !== null && !(${i} instanceof Date) && !(${i} instanceof Uint8Array))`}e.IsRecordLike=n;function o(i){return ge.AllowNaN?`typeof ${i} === 'number'`:`Number.isFinite(${i})`}e.IsNumberLike=o;function s(i){return ge.AllowNullVoid?`(${i} === undefined || ${i} === null)`:`${i} === undefined`}e.IsVoidLike=s})(tn||(tn={}));var lo;(function(e){function t(m){return m[I]==="Any"||m[I]==="Unknown"}function*r(m,A,l){yield"true"}function*n(m,A,l){yield"true"}function*o(m,A,l){yield`Array.isArray(${l})`;let[q,T]=[Co("value","any"),Co("acc","number")];if(H(m.maxItems))yield`${l}.length <= ${m.maxItems}`;if(H(m.minItems))yield`${l}.length >= ${m.minItems}`;let F=pt(m.items,A,"value");if(yield`${l}.every((${q}) => ${F})`,$e(m.contains)||H(m.minContains)||H(m.maxContains)){let ye=$e(m.contains)?m.contains:J(),st=pt(ye,A,"value"),or=H(m.minContains)?[`(count >= ${m.minContains})`]:[],At=H(m.maxContains)?[`(count <= ${m.maxContains})`]:[],Wt=`const count = value.reduce((${T}, ${q}) => ${st} ? acc + 1 : acc, 0)`,Po=["(count > 0)",...or,...At].join(" && ");yield`((${q}) => { ${Wt}; return ${Po}})(${l})`}if(m.uniqueItems===!0)yield`((${q}) => { 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 } )(${l})`}function*s(m,A,l){yield`(typeof value === 'object' && Symbol.asyncIterator in ${l})`}function*i(m,A,l){if(yield`(typeof ${l} === 'bigint')`,lt(m.exclusiveMaximum))yield`${l} < BigInt(${m.exclusiveMaximum})`;if(lt(m.exclusiveMinimum))yield`${l} > BigInt(${m.exclusiveMinimum})`;if(lt(m.maximum))yield`${l} <= BigInt(${m.maximum})`;if(lt(m.minimum))yield`${l} >= BigInt(${m.minimum})`;if(lt(m.multipleOf))yield`(${l} % BigInt(${m.multipleOf})) === 0`}function*a(m,A,l){yield`(typeof ${l} === 'boolean')`}function*u(m,A,l){yield*Te(m.returns,A,`${l}.prototype`)}function*c(m,A,l){if(yield`(${l} instanceof Date) && Number.isFinite(${l}.getTime())`,H(m.exclusiveMaximumTimestamp))yield`${l}.getTime() < ${m.exclusiveMaximumTimestamp}`;if(H(m.exclusiveMinimumTimestamp))yield`${l}.getTime() > ${m.exclusiveMinimumTimestamp}`;if(H(m.maximumTimestamp))yield`${l}.getTime() <= ${m.maximumTimestamp}`;if(H(m.minimumTimestamp))yield`${l}.getTime() >= ${m.minimumTimestamp}`;if(H(m.multipleOfTimestamp))yield`(${l}.getTime() % ${m.multipleOfTimestamp}) === 0`}function*d(m,A,l){yield`(typeof ${l} === 'function')`}function*f(m,A,l){let q=globalThis.Object.getOwnPropertyNames(m.$defs).reduce((T,F)=>[...T,m.$defs[F]],[]);yield*Te($t(m.$ref),[...A,...q],l)}function*p(m,A,l){if(yield`Number.isInteger(${l})`,H(m.exclusiveMaximum))yield`${l} < ${m.exclusiveMaximum}`;if(H(m.exclusiveMinimum))yield`${l} > ${m.exclusiveMinimum}`;if(H(m.maximum))yield`${l} <= ${m.maximum}`;if(H(m.minimum))yield`${l} >= ${m.minimum}`;if(H(m.multipleOf))yield`(${l} % ${m.multipleOf}) === 0`}function*y(m,A,l){let q=m.allOf.map((T)=>pt(T,A,l)).join(" && ");if(m.unevaluatedProperties===!1){let T=fn(`${new RegExp(dr(m))};`),F=`Object.getOwnPropertyNames(${l}).every(key => ${T}.test(key))`;yield`(${q} && ${F})`}else if($e(m.unevaluatedProperties)){let T=fn(`${new RegExp(dr(m))};`),F=`Object.getOwnPropertyNames(${l}).every(key => ${T}.test(key) || ${pt(m.unevaluatedProperties,A,`${l}[key]`)})`;yield`(${q} && ${F})`}else yield`(${q})`}function*b(m,A,l){yield`(typeof value === 'object' && Symbol.iterator in ${l})`}function*P(m,A,l){if(typeof m.const==="number"||typeof m.const==="boolean")yield`(${l} === ${m.const})`;else yield`(${l} === '${Qs.Escape(m.const)}')`}function*E(m,A,l){yield"false"}function*L(m,A,l){yield`(!${pt(m.not,A,l)})`}function*ae(m,A,l){yield`(${l} === null)`}function*Me(m,A,l){if(yield tn.IsNumberLike(l),H(m.exclusiveMaximum))yield`${l} < ${m.exclusiveMaximum}`;if(H(m.exclusiveMinimum))yield`${l} > ${m.exclusiveMinimum}`;if(H(m.maximum))yield`${l} <= ${m.maximum}`;if(H(m.minimum))yield`${l} >= ${m.minimum}`;if(H(m.multipleOf))yield`(${l} % ${m.multipleOf}) === 0`}function*qe(m,A,l){if(yield tn.IsObjectLike(l),H(m.minProperties))yield`Object.getOwnPropertyNames(${l}).length >= ${m.minProperties}`;if(H(m.maxProperties))yield`Object.getOwnPropertyNames(${l}).length <= ${m.maxProperties}`;let q=Object.getOwnPropertyNames(m.properties);for(let T of q){let F=os.Encode(l,T),ye=m.properties[T];if(m.required&&m.required.includes(T)){if(yield*Te(ye,A,F),fr(ye)||t(ye))yield`('${T}' in ${l})`}else{let st=pt(ye,A,F);yield tn.IsExactOptionalProperty(l,T,st)}}if(m.additionalProperties===!1)if(m.required&&m.required.length===q.length)yield`Object.getOwnPropertyNames(${l}).length === ${q.length}`;else{let T=`[${q.map((F)=>`'${F}'`).join(", ")}]`;yield`Object.getOwnPropertyNames(${l}).every(key => ${T}.includes(key))`}if(typeof m.additionalProperties==="object"){let T=pt(m.additionalProperties,A,`${l}[key]`),F=`[${q.map((ye)=>`'${ye}'`).join(", ")}]`;yield`(Object.getOwnPropertyNames(${l}).every(key => ${F}.includes(key) || ${T}))`}}function*je(m,A,l){yield`${l} instanceof Promise`}function*ce(m,A,l){if(yield tn.IsRecordLike(l),H(m.minProperties))yield`Object.getOwnPropertyNames(${l}).length >= ${m.minProperties}`;if(H(m.maxProperties))yield`Object.getOwnPropertyNames(${l}).length <= ${m.maxProperties}`;let[q,T]=Object.entries(m.patternProperties)[0],F=fn(`${new RegExp(q)}`),ye=pt(T,A,"value"),st=$e(m.additionalProperties)?pt(m.additionalProperties,A,l):m.additionalProperties===!1?"false":"true",or=`(${F}.test(key) ? ${ye} : ${st})`;yield`(Object.entries(${l}).every(([key, value]) => ${or}))`}function*M(m,A,l){let q=He(m,A);if(pe.functions.has(m.$ref))return yield`${Yn(m.$ref)}(${l})`;yield*Te(q,A,l)}function*w(m,A,l){let q=fn(`${new RegExp(m.source,m.flags)};`);if(yield`(typeof ${l} === 'string')`,H(m.maxLength))yield`${l}.length <= ${m.maxLength}`;if(H(m.minLength))yield`${l}.length >= ${m.minLength}`;yield`${q}.test(${l})`}function*V(m,A,l){if(yield`(typeof ${l} === 'string')`,H(m.maxLength))yield`${l}.length <= ${m.maxLength}`;if(H(m.minLength))yield`${l}.length >= ${m.minLength}`;if(m.pattern!==void 0)yield`${fn(`${new RegExp(m.pattern)};`)}.test(${l})`;if(m.format!==void 0)yield`format('${m.format}', ${l})`}function*_(m,A,l){yield`(typeof ${l} === 'symbol')`}function*C(m,A,l){yield`(typeof ${l} === 'string')`,yield`${fn(`${new RegExp(m.pattern)};`)}.test(${l})`}function*j(m,A,l){yield`${Yn(m.$ref)}(${l})`}function*U(m,A,l){if(yield`Array.isArray(${l})`,m.items===void 0)return yield`${l}.length === 0`;yield`(${l}.length === ${m.maxItems})`;for(let q=0;q<m.items.length;q++)yield`${pt(m.items[q],A,`${l}[${q}]`)}`}function*Ee(m,A,l){yield`${l} === undefined`}function*me(m,A,l){yield`(${m.anyOf.map((T)=>pt(T,A,l)).join(" || ")})`}function*K(m,A,l){if(yield`${l} instanceof Uint8Array`,H(m.maxByteLength))yield`(${l}.length <= ${m.maxByteLength})`;if(H(m.minByteLength))yield`(${l}.length >= ${m.minByteLength})`}function*B(m,A,l){yield"true"}function*G(m,A,l){yield tn.IsVoidLike(l)}function*Le(m,A,l){let q=pe.instances.size;pe.instances.set(q,m),yield`kind('${m[I]}', ${q}, ${l})`}function*Te(m,A,l,q=!0){let T=Ge(m.$id)?[...A,m]:A,F=m;if(q&&Ge(m.$id)){let ye=Yn(m.$id);if(pe.functions.has(ye))return yield`${ye}(${l})`;else{pe.functions.set(ye,"<deferred>");let st=Ii(ye,m,A,"value",!1);return pe.functions.set(ye,st),yield`${ye}(${l})`}}switch(F[I]){case"Any":return yield*r(F,T,l);case"Argument":return yield*n(F,T,l);case"Array":return yield*o(F,T,l);case"AsyncIterator":return yield*s(F,T,l);case"BigInt":return yield*i(F,T,l);case"Boolean":return yield*a(F,T,l);case"Constructor":return yield*u(F,T,l);case"Date":return yield*c(F,T,l);case"Function":return yield*d(F,T,l);case"Import":return yield*f(F,T,l);case"Integer":return yield*p(F,T,l);case"Intersect":return yield*y(F,T,l);case"Iterator":return yield*b(F,T,l);case"Literal":return yield*P(F,T,l);case"Never":return yield*E(F,T,l);case"Not":return yield*L(F,T,l);case"Null":return yield*ae(F,T,l);case"Number":return yield*Me(F,T,l);case"Object":return yield*qe(F,T,l);case"Promise":return yield*je(F,T,l);case"Record":return yield*ce(F,T,l);case"Ref":return yield*M(F,T,l);case"RegExp":return yield*w(F,T,l);case"String":return yield*V(F,T,l);case"Symbol":return yield*_(F,T,l);case"TemplateLiteral":return yield*C(F,T,l);case"This":return yield*j(F,T,l);case"Tuple":return yield*U(F,T,l);case"Undefined":return yield*Ee(F,T,l);case"Union":return yield*me(F,T,l);case"Uint8Array":return yield*K(F,T,l);case"Unknown":return yield*B(F,T,l);case"Void":return yield*G(F,T,l);default:if(!Qn(F[I]))throw new Da(m);return yield*Le(F,T,l)}}let pe={language:"javascript",functions:new Map,variables:new Map,instances:new Map};function pt(m,A,l,q=!0){return`(${[...Te(m,A,l,q)].join(" && ")})`}function Yn(m){return`check_${Ys.Encode(m)}`}function fn(m){let A=`local_${pe.variables.size}`;return pe.variables.set(A,`const ${A} = ${m}`),A}function Ii(m,A,l,q,T=!0){let[F,ye]=[`
3
- `,(Wt)=>"".padStart(Wt," ")],st=Co("value","any"),or=bi("boolean"),At=[...Te(A,l,q,T)].map((Wt)=>`${ye(4)}${Wt}`).join(` &&${F}`);return`function ${m}(${st})${or} {${F}${ye(2)}return (${F}${At}${F}${ye(2)})
4
- }`}function Co(m,A){let l=pe.language==="typescript"?`: ${A}`:"";return`${m}${l}`}function bi(m){return pe.language==="typescript"?`: ${m}`:""}function au(m,A,l){let q=Ii("check",m,A,"value"),T=Co("value","any"),F=bi("boolean"),ye=[...pe.functions.values()],st=[...pe.variables.values()],or=Ge(m.$id)?`return function check(${T})${F} {
5
- return ${Yn(m.$id)}(value)
6
- }`:`return ${q}`;return[...st,...ye,or].join(`
7
- `)}function Ri(...m){let A={language:"javascript"},[l,q,T]=m.length===2&&Ue(m[1])?[m[0],m[1],A]:m.length===2&&!Ue(m[1])?[m[0],[],m[1]]:m.length===3?[m[0],m[1],m[2]]:m.length===1?[m[0],[],A]:[null,[],A];if(pe.language=T.language,pe.variables.clear(),pe.functions.clear(),pe.instances.clear(),!$e(l))throw new Zs(l);for(let F of q)if(!$e(F))throw new Zs(F);return au(l,q,T)}e.Code=Ri;function cu(m,A=[]){let l=Ri(m,A,{language:"javascript"}),q=globalThis.Function("kind","format","hash",l),T=new Map(pe.instances);function F(At,Wt,Po){if(!Qn(At)||!T.has(Wt))return!1;let uu=Cs(At),du=T.get(Wt);return uu(du,Po)}function ye(At,Wt){if(!$s(At))return!1;return Ss(At)(Wt)}function st(At){return Sn(At)}let or=q(F,ye,st);return new va(m,A,or,l)}e.Compile=cu})(lo||(lo={}));var Q;(function(e){e.assertEqual=(o)=>{};function t(o){}e.assertIs=t;function r(o){throw Error()}e.assertNever=r,e.arrayToEnum=(o)=>{let s={};for(let i of o)s[i]=i;return s},e.getValidEnumValues=(o)=>{let s=e.objectKeys(o).filter((a)=>typeof o[o[a]]!=="number"),i={};for(let a of s)i[a]=o[a];return e.objectValues(i)},e.objectValues=(o)=>e.objectKeys(o).map(function(s){return o[s]}),e.objectKeys=typeof Object.keys==="function"?(o)=>Object.keys(o):(o)=>{let s=[];for(let i in o)if(Object.prototype.hasOwnProperty.call(o,i))s.push(i);return s},e.find=(o,s)=>{for(let i of o)if(s(i))return i;return},e.isInteger=typeof Number.isInteger==="function"?(o)=>Number.isInteger(o):(o)=>typeof o==="number"&&Number.isFinite(o)&&Math.floor(o)===o;function n(o,s=" | "){return o.map((i)=>typeof i==="string"?`'${i}'`:i).join(s)}e.joinValues=n,e.jsonStringifyReplacer=(o,s)=>{if(typeof s==="bigint")return s.toString();return s}})(Q||(Q={}));var ei;(function(e){e.mergeShapes=(t,r)=>({...t,...r})})(ei||(ei={}));var k=Q.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),er=(e)=>{switch(typeof e){case"undefined":return k.undefined;case"string":return k.string;case"number":return Number.isNaN(e)?k.nan:k.number;case"boolean":return k.boolean;case"function":return k.function;case"bigint":return k.bigint;case"symbol":return k.symbol;case"object":if(Array.isArray(e))return k.array;if(e===null)return k.null;if(e.then&&typeof e.then==="function"&&e.catch&&typeof e.catch==="function")return k.promise;if(typeof Map<"u"&&e instanceof Map)return k.map;if(typeof Set<"u"&&e instanceof Set)return k.set;if(typeof Date<"u"&&e instanceof Date)return k.date;return k.object;default:return k.unknown}};var R=Q.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 mt extends Error{get errors(){return this.issues}constructor(e){super();this.issues=[],this.addIssue=(r)=>{this.issues=[...this.issues,r]},this.addIssues=(r=[])=>{this.issues=[...this.issues,...r]};let t=new.target.prototype;if(Object.setPrototypeOf)Object.setPrototypeOf(this,t);else this.__proto__=t;this.name="ZodError",this.issues=e}format(e){let t=e||function(o){return o.message},r={_errors:[]},n=(o)=>{for(let s of o.issues)if(s.code==="invalid_union")s.unionErrors.map(n);else if(s.code==="invalid_return_type")n(s.returnTypeError);else if(s.code==="invalid_arguments")n(s.argumentsError);else if(s.path.length===0)r._errors.push(t(s));else{let i=r,a=0;while(a<s.path.length){let u=s.path[a];if(a!==s.path.length-1)i[u]=i[u]||{_errors:[]};else i[u]=i[u]||{_errors:[]},i[u]._errors.push(t(s));i=i[u],a++}}};return n(this),r}static assert(e){if(!(e instanceof mt))throw Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,Q.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()}}mt.create=(e)=>new mt(e);var hl=(e,t)=>{let r;switch(e.code){case R.invalid_type:if(e.received===k.undefined)r="Required";else r=`Expected ${e.expected}, received ${e.received}`;break;case R.invalid_literal:r=`Invalid literal value, expected ${JSON.stringify(e.expected,Q.jsonStringifyReplacer)}`;break;case R.unrecognized_keys:r=`Unrecognized key(s) in object: ${Q.joinValues(e.keys,", ")}`;break;case R.invalid_union:r="Invalid input";break;case R.invalid_union_discriminator:r=`Invalid discriminator value. Expected ${Q.joinValues(e.options)}`;break;case R.invalid_enum_value:r=`Invalid enum value. Expected ${Q.joinValues(e.options)}, received '${e.received}'`;break;case R.invalid_arguments:r="Invalid function arguments";break;case R.invalid_return_type:r="Invalid function return type";break;case R.invalid_date:r="Invalid date";break;case R.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 Q.assertNever(e.validation);else if(e.validation!=="regex")r=`Invalid ${e.validation}`;else r="Invalid";break;case R.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 R.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 R.custom:r="Invalid input";break;case R.invalid_intersection_types:r="Intersection results could not be merged";break;case R.not_multiple_of:r=`Number must be a multiple of ${e.multipleOf}`;break;case R.not_finite:r="Number must be finite";break;default:r=t.defaultError,Q.assertNever(e)}return{message:r}},gr=hl;var qa=gr;function xl(e){qa=e}function kn(){return qa}var yo=(e)=>{let{data:t,path:r,errorMaps:n,issueData:o}=e,s=[...r,...o.path||[]],i={...o,path:s};if(o.message!==void 0)return{...o,path:s,message:o.message};let a="",u=n.filter((c)=>!!c).slice().reverse();for(let c of u)a=c(i,{data:t,defaultError:a}).message;return{...o,path:s,message:a}},Il=[];function O(e,t){let r=kn(),n=yo({issueData:t,data:e.data,path:e.path,errorMaps:[e.common.contextualErrorMap,e.schemaErrorMap,r,r===gr?void 0:gr].filter((o)=>!!o)});e.common.issues.push(n)}class Qe{constructor(){this.value="valid"}dirty(){if(this.value==="valid")this.value="dirty"}abort(){if(this.value!=="aborted")this.value="aborted"}static mergeArray(e,t){let r=[];for(let n of t){if(n.status==="aborted")return v;if(n.status==="dirty")e.dirty();r.push(n.value)}return{status:e.value,value:r}}static async mergeObjectAsync(e,t){let r=[];for(let n of t){let o=await n.key,s=await n.value;r.push({key:o,value:s})}return Qe.mergeObjectSync(e,r)}static mergeObjectSync(e,t){let r={};for(let n of t){let{key:o,value:s}=n;if(o.status==="aborted")return v;if(s.status==="aborted")return v;if(o.status==="dirty")e.dirty();if(s.status==="dirty")e.dirty();if(o.value!=="__proto__"&&(typeof s.value<"u"||n.alwaysSet))r[o.value]=s.value}return{status:e.value,value:r}}}var v=Object.freeze({status:"aborted"}),rn=(e)=>({status:"dirty",value:e}),nt=(e)=>({status:"valid",value:e}),ss=(e)=>e.status==="aborted",is=(e)=>e.status==="dirty",Fr=(e)=>e.status==="valid",Tn=(e)=>typeof Promise<"u"&&e instanceof Promise;var N;(function(e){e.errToObj=(t)=>typeof t==="string"?{message:t}:t||{},e.toString=(t)=>typeof t==="string"?t:t?.message})(N||(N={}));class Ht{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 Ga=(e,t)=>{if(Fr(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 mt(e.common.issues);return this._error=r,this._error}}}};function z(e){if(!e)return{};let{errorMap:t,invalid_type_error:r,required_error:n,description:o}=e;if(t&&(r||n))throw Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);if(t)return{errorMap:t,description:o};return{errorMap:(i,a)=>{let{message:u}=e;if(i.code==="invalid_enum_value")return{message:u??a.defaultError};if(typeof a.data>"u")return{message:u??n??a.defaultError};if(i.code!=="invalid_type")return{message:a.defaultError};return{message:u??r??a.defaultError}},description:o}}class W{get description(){return this._def.description}_getType(e){return er(e.data)}_getOrReturnCtx(e,t){return t||{common:e.parent.common,data:e.data,parsedType:er(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new Qe,ctx:{common:e.parent.common,data:e.data,parsedType:er(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){let t=this._parse(e);if(Tn(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:er(e)},n=this._parseSync({data:e,path:r.path,parent:r});return Ga(r,n)}"~validate"(e){let t={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:er(e)};if(!this["~standard"].async)try{let r=this._parseSync({data:e,path:[],parent:t});return Fr(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)=>Fr(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:er(e)},n=this._parse({data:e,path:r.path,parent:r}),o=await(Tn(n)?n:Promise.resolve(n));return Ga(r,o)}refine(e,t){let r=(n)=>{if(typeof t==="string"||typeof t>"u")return{message:t};else if(typeof t==="function")return t(n);else return t};return this._refinement((n,o)=>{let s=e(n),i=()=>o.addIssue({code:R.custom,...r(n)});if(typeof Promise<"u"&&s instanceof Promise)return s.then((a)=>{if(!a)return i(),!1;else return!0});if(!s)return i(),!1;else return!0})}refinement(e,t){return this._refinement((r,n)=>{if(!e(r))return n.addIssue(typeof t==="function"?t(r,n):t),!1;else return!0})}_refinement(e){return new zt({schema:this,typeName:D.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 Gt.create(this,this._def)}nullable(){return xr.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return qt.create(this)}promise(){return an.create(this,this._def)}or(e){return Ln.create([this,e],this._def)}and(e){return Un.create(this,e,this._def)}transform(e){return new zt({...z(this._def),schema:this,typeName:D.ZodEffects,effect:{type:"transform",transform:e}})}default(e){let t=typeof e==="function"?e:()=>e;return new Dn({...z(this._def),innerType:this,defaultValue:t,typeName:D.ZodDefault})}brand(){return new cs({typeName:D.ZodBranded,type:this,...z(this._def)})}catch(e){let t=typeof e==="function"?e:()=>e;return new qn({...z(this._def),innerType:this,catchValue:t,typeName:D.ZodCatch})}describe(e){return new this.constructor({...this._def,description:e})}pipe(e){return Ro.create(this,e)}readonly(){return Gn.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}var bl=/^c[^\s-]{8,}$/i,Rl=/^[0-9a-z]+$/,_l=/^[0-9A-HJKMNP-TV-Z]{26}$/i,Ol=/^[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,$l=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,Sl=/^[-+]?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)?)??$/,Cl=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,Pl="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$",ti,Al=/^(?:(?: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])$/,kl=/^(?:(?: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])$/,Tl=/^(([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]))$/,Fl=/^(([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])$/,Nl=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,Ml=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,za="((\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-((0[13578]|1[02])-(0[1-9]|[12]\\d|3[01])|(0[469]|11)-(0[1-9]|[12]\\d|30)|(02)-(0[1-9]|1\\d|2[0-8])))",jl=new RegExp(`^${za}$`);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 El(e){return new RegExp(`^${Va(e)}$`)}function Ja(e){let t=`${za}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 Ll(e,t){if((t==="v4"||!t)&&Al.test(e))return!0;if((t==="v6"||!t)&&Tl.test(e))return!0;return!1}function Ul(e,t){if(!$l.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)&&kl.test(e))return!0;if((t==="v6"||!t)&&Fl.test(e))return!0;return!1}class Dt extends W{_parse(e){if(this._def.coerce)e.data=String(e.data);if(this._getType(e)!==k.string){let o=this._getOrReturnCtx(e);return O(o,{code:R.invalid_type,expected:k.string,received:o.parsedType}),v}let r=new Qe,n=void 0;for(let o of this._def.checks)if(o.kind==="min"){if(e.data.length<o.value)n=this._getOrReturnCtx(e,n),O(n,{code:R.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),O(n,{code:R.too_big,maximum:o.value,type:"string",inclusive:!0,exact:!1,message:o.message}),r.dirty()}else if(o.kind==="length"){let s=e.data.length>o.value,i=e.data.length<o.value;if(s||i){if(n=this._getOrReturnCtx(e,n),s)O(n,{code:R.too_big,maximum:o.value,type:"string",inclusive:!0,exact:!0,message:o.message});else if(i)O(n,{code:R.too_small,minimum:o.value,type:"string",inclusive:!0,exact:!0,message:o.message});r.dirty()}}else if(o.kind==="email"){if(!Cl.test(e.data))n=this._getOrReturnCtx(e,n),O(n,{validation:"email",code:R.invalid_string,message:o.message}),r.dirty()}else if(o.kind==="emoji"){if(!ti)ti=new RegExp(Pl,"u");if(!ti.test(e.data))n=this._getOrReturnCtx(e,n),O(n,{validation:"emoji",code:R.invalid_string,message:o.message}),r.dirty()}else if(o.kind==="uuid"){if(!Ol.test(e.data))n=this._getOrReturnCtx(e,n),O(n,{validation:"uuid",code:R.invalid_string,message:o.message}),r.dirty()}else if(o.kind==="nanoid"){if(!wl.test(e.data))n=this._getOrReturnCtx(e,n),O(n,{validation:"nanoid",code:R.invalid_string,message:o.message}),r.dirty()}else if(o.kind==="cuid"){if(!bl.test(e.data))n=this._getOrReturnCtx(e,n),O(n,{validation:"cuid",code:R.invalid_string,message:o.message}),r.dirty()}else if(o.kind==="cuid2"){if(!Rl.test(e.data))n=this._getOrReturnCtx(e,n),O(n,{validation:"cuid2",code:R.invalid_string,message:o.message}),r.dirty()}else if(o.kind==="ulid"){if(!_l.test(e.data))n=this._getOrReturnCtx(e,n),O(n,{validation:"ulid",code:R.invalid_string,message:o.message}),r.dirty()}else if(o.kind==="url")try{new URL(e.data)}catch{n=this._getOrReturnCtx(e,n),O(n,{validation:"url",code:R.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),O(n,{validation:"regex",code:R.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),O(n,{code:R.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),O(n,{code:R.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),O(n,{code:R.invalid_string,validation:{endsWith:o.value},message:o.message}),r.dirty()}else if(o.kind==="datetime"){if(!Ja(o).test(e.data))n=this._getOrReturnCtx(e,n),O(n,{code:R.invalid_string,validation:"datetime",message:o.message}),r.dirty()}else if(o.kind==="date"){if(!jl.test(e.data))n=this._getOrReturnCtx(e,n),O(n,{code:R.invalid_string,validation:"date",message:o.message}),r.dirty()}else if(o.kind==="time"){if(!El(o).test(e.data))n=this._getOrReturnCtx(e,n),O(n,{code:R.invalid_string,validation:"time",message:o.message}),r.dirty()}else if(o.kind==="duration"){if(!Sl.test(e.data))n=this._getOrReturnCtx(e,n),O(n,{validation:"duration",code:R.invalid_string,message:o.message}),r.dirty()}else if(o.kind==="ip"){if(!Ll(e.data,o.version))n=this._getOrReturnCtx(e,n),O(n,{validation:"ip",code:R.invalid_string,message:o.message}),r.dirty()}else if(o.kind==="jwt"){if(!Ul(e.data,o.alg))n=this._getOrReturnCtx(e,n),O(n,{validation:"jwt",code:R.invalid_string,message:o.message}),r.dirty()}else if(o.kind==="cidr"){if(!Kl(e.data,o.version))n=this._getOrReturnCtx(e,n),O(n,{validation:"cidr",code:R.invalid_string,message:o.message}),r.dirty()}else if(o.kind==="base64"){if(!Nl.test(e.data))n=this._getOrReturnCtx(e,n),O(n,{validation:"base64",code:R.invalid_string,message:o.message}),r.dirty()}else if(o.kind==="base64url"){if(!Ml.test(e.data))n=this._getOrReturnCtx(e,n),O(n,{validation:"base64url",code:R.invalid_string,message:o.message}),r.dirty()}else Q.assertNever(o);return{status:r.value,value:e.data}}_regex(e,t,r){return this.refinement((n)=>e.test(n),{validation:t,code:R.invalid_string,...N.errToObj(r)})}_addCheck(e){return new Dt({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...N.errToObj(e)})}url(e){return this._addCheck({kind:"url",...N.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...N.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...N.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",...N.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...N.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...N.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...N.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",...N.errToObj(e)})}base64url(e){return this._addCheck({kind:"base64url",...N.errToObj(e)})}jwt(e){return this._addCheck({kind:"jwt",...N.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...N.errToObj(e)})}cidr(e){return this._addCheck({kind:"cidr",...N.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,...N.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,...N.errToObj(e?.message)})}duration(e){return this._addCheck({kind:"duration",...N.errToObj(e)})}regex(e,t){return this._addCheck({kind:"regex",regex:e,...N.errToObj(t)})}includes(e,t){return this._addCheck({kind:"includes",value:e,position:t?.position,...N.errToObj(t?.message)})}startsWith(e,t){return this._addCheck({kind:"startsWith",value:e,...N.errToObj(t)})}endsWith(e,t){return this._addCheck({kind:"endsWith",value:e,...N.errToObj(t)})}min(e,t){return this._addCheck({kind:"min",value:e,...N.errToObj(t)})}max(e,t){return this._addCheck({kind:"max",value:e,...N.errToObj(t)})}length(e,t){return this._addCheck({kind:"length",value:e,...N.errToObj(t)})}nonempty(e){return this.min(1,N.errToObj(e))}trim(){return new Dt({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new Dt({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new Dt({...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}}Dt.create=(e)=>new Dt({checks:[],typeName:D.ZodString,coerce:e?.coerce??!1,...z(e)});function Bl(e,t){let r=(e.toString().split(".")[1]||"").length,n=(t.toString().split(".")[1]||"").length,o=r>n?r:n,s=Number.parseInt(e.toFixed(o).replace(".","")),i=Number.parseInt(t.toFixed(o).replace(".",""));return s%i/10**o}class Mr extends W{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)!==k.number){let o=this._getOrReturnCtx(e);return O(o,{code:R.invalid_type,expected:k.number,received:o.parsedType}),v}let r=void 0,n=new Qe;for(let o of this._def.checks)if(o.kind==="int"){if(!Q.isInteger(e.data))r=this._getOrReturnCtx(e,r),O(r,{code:R.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),O(r,{code:R.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),O(r,{code:R.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),O(r,{code:R.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),O(r,{code:R.not_finite,message:o.message}),n.dirty()}else Q.assertNever(o);return{status:n.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,N.toString(t))}gt(e,t){return this.setLimit("min",e,!1,N.toString(t))}lte(e,t){return this.setLimit("max",e,!0,N.toString(t))}lt(e,t){return this.setLimit("max",e,!1,N.toString(t))}setLimit(e,t,r,n){return new Mr({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:r,message:N.toString(n)}]})}_addCheck(e){return new Mr({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:N.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:N.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:N.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:N.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:N.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:N.toString(t)})}finite(e){return this._addCheck({kind:"finite",message:N.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:N.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:N.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"&&Q.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)}}Mr.create=(e)=>new Mr({checks:[],typeName:D.ZodNumber,coerce:e?.coerce||!1,...z(e)});class jr extends W{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)!==k.bigint)return this._getInvalidInput(e);let r=void 0,n=new Qe;for(let o of this._def.checks)if(o.kind==="min"){if(o.inclusive?e.data<o.value:e.data<=o.value)r=this._getOrReturnCtx(e,r),O(r,{code:R.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),O(r,{code:R.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),O(r,{code:R.not_multiple_of,multipleOf:o.value,message:o.message}),n.dirty()}else Q.assertNever(o);return{status:n.value,value:e.data}}_getInvalidInput(e){let t=this._getOrReturnCtx(e);return O(t,{code:R.invalid_type,expected:k.bigint,received:t.parsedType}),v}gte(e,t){return this.setLimit("min",e,!0,N.toString(t))}gt(e,t){return this.setLimit("min",e,!1,N.toString(t))}lte(e,t){return this.setLimit("max",e,!0,N.toString(t))}lt(e,t){return this.setLimit("max",e,!1,N.toString(t))}setLimit(e,t,r,n){return new jr({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:r,message:N.toString(n)}]})}_addCheck(e){return new jr({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:N.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:N.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:N.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:N.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:N.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}}jr.create=(e)=>new jr({checks:[],typeName:D.ZodBigInt,coerce:e?.coerce??!1,...z(e)});class Mn extends W{_parse(e){if(this._def.coerce)e.data=Boolean(e.data);if(this._getType(e)!==k.boolean){let r=this._getOrReturnCtx(e);return O(r,{code:R.invalid_type,expected:k.boolean,received:r.parsedType}),v}return nt(e.data)}}Mn.create=(e)=>new Mn({typeName:D.ZodBoolean,coerce:e?.coerce||!1,...z(e)});class nn extends W{_parse(e){if(this._def.coerce)e.data=new Date(e.data);if(this._getType(e)!==k.date){let o=this._getOrReturnCtx(e);return O(o,{code:R.invalid_type,expected:k.date,received:o.parsedType}),v}if(Number.isNaN(e.data.getTime())){let o=this._getOrReturnCtx(e);return O(o,{code:R.invalid_date}),v}let r=new Qe,n=void 0;for(let o of this._def.checks)if(o.kind==="min"){if(e.data.getTime()<o.value)n=this._getOrReturnCtx(e,n),O(n,{code:R.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),O(n,{code:R.too_big,message:o.message,inclusive:!0,exact:!1,maximum:o.value,type:"date"}),r.dirty()}else Q.assertNever(o);return{status:r.value,value:new Date(e.data.getTime())}}_addCheck(e){return new nn({...this._def,checks:[...this._def.checks,e]})}min(e,t){return this._addCheck({kind:"min",value:e.getTime(),message:N.toString(t)})}max(e,t){return this._addCheck({kind:"max",value:e.getTime(),message:N.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}}nn.create=(e)=>new nn({checks:[],coerce:e?.coerce||!1,typeName:D.ZodDate,...z(e)});class go extends W{_parse(e){if(this._getType(e)!==k.symbol){let r=this._getOrReturnCtx(e);return O(r,{code:R.invalid_type,expected:k.symbol,received:r.parsedType}),v}return nt(e.data)}}go.create=(e)=>new go({typeName:D.ZodSymbol,...z(e)});class jn extends W{_parse(e){if(this._getType(e)!==k.undefined){let r=this._getOrReturnCtx(e);return O(r,{code:R.invalid_type,expected:k.undefined,received:r.parsedType}),v}return nt(e.data)}}jn.create=(e)=>new jn({typeName:D.ZodUndefined,...z(e)});class En extends W{_parse(e){if(this._getType(e)!==k.null){let r=this._getOrReturnCtx(e);return O(r,{code:R.invalid_type,expected:k.null,received:r.parsedType}),v}return nt(e.data)}}En.create=(e)=>new En({typeName:D.ZodNull,...z(e)});class on extends W{constructor(){super(...arguments);this._any=!0}_parse(e){return nt(e.data)}}on.create=(e)=>new on({typeName:D.ZodAny,...z(e)});class Nr extends W{constructor(){super(...arguments);this._unknown=!0}_parse(e){return nt(e.data)}}Nr.create=(e)=>new Nr({typeName:D.ZodUnknown,...z(e)});class tr extends W{_parse(e){let t=this._getOrReturnCtx(e);return O(t,{code:R.invalid_type,expected:k.never,received:t.parsedType}),v}}tr.create=(e)=>new tr({typeName:D.ZodNever,...z(e)});class ho extends W{_parse(e){if(this._getType(e)!==k.undefined){let r=this._getOrReturnCtx(e);return O(r,{code:R.invalid_type,expected:k.void,received:r.parsedType}),v}return nt(e.data)}}ho.create=(e)=>new ho({typeName:D.ZodVoid,...z(e)});class qt extends W{_parse(e){let{ctx:t,status:r}=this._processInputParams(e),n=this._def;if(t.parsedType!==k.array)return O(t,{code:R.invalid_type,expected:k.array,received:t.parsedType}),v;if(n.exactLength!==null){let s=t.data.length>n.exactLength.value,i=t.data.length<n.exactLength.value;if(s||i)O(t,{code:s?R.too_big:R.too_small,minimum:i?n.exactLength.value:void 0,maximum:s?n.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:n.exactLength.message}),r.dirty()}if(n.minLength!==null){if(t.data.length<n.minLength.value)O(t,{code:R.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)O(t,{code:R.too_big,maximum:n.maxLength.value,type:"array",inclusive:!0,exact:!1,message:n.maxLength.message}),r.dirty()}if(t.common.async)return Promise.all([...t.data].map((s,i)=>n.type._parseAsync(new Ht(t,s,t.path,i)))).then((s)=>Qe.mergeArray(r,s));let o=[...t.data].map((s,i)=>n.type._parseSync(new Ht(t,s,t.path,i)));return Qe.mergeArray(r,o)}get element(){return this._def.type}min(e,t){return new qt({...this._def,minLength:{value:e,message:N.toString(t)}})}max(e,t){return new qt({...this._def,maxLength:{value:e,message:N.toString(t)}})}length(e,t){return new qt({...this._def,exactLength:{value:e,message:N.toString(t)}})}nonempty(e){return this.min(1,e)}}qt.create=(e,t)=>new qt({type:e,minLength:null,maxLength:null,exactLength:null,typeName:D.ZodArray,...z(t)});function Fn(e){if(e instanceof ke){let t={};for(let r in e.shape){let n=e.shape[r];t[r]=Gt.create(Fn(n))}return new ke({...e._def,shape:()=>t})}else if(e instanceof qt)return new qt({...e._def,type:Fn(e.element)});else if(e instanceof Gt)return Gt.create(Fn(e.unwrap()));else if(e instanceof xr)return xr.create(Fn(e.unwrap()));else if(e instanceof rr)return rr.create(e.items.map((t)=>Fn(t)));else return e}class ke extends W{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=Q.objectKeys(e);return this._cached={shape:e,keys:t},this._cached}_parse(e){if(this._getType(e)!==k.object){let u=this._getOrReturnCtx(e);return O(u,{code:R.invalid_type,expected:k.object,received:u.parsedType}),v}let{status:r,ctx:n}=this._processInputParams(e),{shape:o,keys:s}=this._getCached(),i=[];if(!(this._def.catchall instanceof tr&&this._def.unknownKeys==="strip")){for(let u in n.data)if(!s.includes(u))i.push(u)}let a=[];for(let u of s){let c=o[u],d=n.data[u];a.push({key:{status:"valid",value:u},value:c._parse(new Ht(n,d,n.path,u)),alwaysSet:u in n.data})}if(this._def.catchall instanceof tr){let u=this._def.unknownKeys;if(u==="passthrough")for(let c of i)a.push({key:{status:"valid",value:c},value:{status:"valid",value:n.data[c]}});else if(u==="strict"){if(i.length>0)O(n,{code:R.unrecognized_keys,keys:i}),r.dirty()}else if(u==="strip");else throw Error("Internal ZodObject error: invalid unknownKeys value.")}else{let u=this._def.catchall;for(let c of i){let d=n.data[c];a.push({key:{status:"valid",value:c},value:u._parse(new Ht(n,d,n.path,c)),alwaysSet:c in n.data})}}if(n.common.async)return Promise.resolve().then(async()=>{let u=[];for(let c of a){let d=await c.key,f=await c.value;u.push({key:d,value:f,alwaysSet:c.alwaysSet})}return u}).then((u)=>Qe.mergeObjectSync(r,u));else return Qe.mergeObjectSync(r,a)}get shape(){return this._def.shape()}strict(e){return N.errToObj,new ke({...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:N.errToObj(e).message??n};return{message:n}}}:{}})}strip(){return new ke({...this._def,unknownKeys:"strip"})}passthrough(){return new ke({...this._def,unknownKeys:"passthrough"})}extend(e){return new ke({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new ke({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:D.ZodObject})}setKey(e,t){return this.augment({[e]:t})}catchall(e){return new ke({...this._def,catchall:e})}pick(e){let t={};for(let r of Q.objectKeys(e))if(e[r]&&this.shape[r])t[r]=this.shape[r];return new ke({...this._def,shape:()=>t})}omit(e){let t={};for(let r of Q.objectKeys(this.shape))if(!e[r])t[r]=this.shape[r];return new ke({...this._def,shape:()=>t})}deepPartial(){return Fn(this)}partial(e){let t={};for(let r of Q.objectKeys(this.shape)){let n=this.shape[r];if(e&&!e[r])t[r]=n;else t[r]=n.optional()}return new ke({...this._def,shape:()=>t})}required(e){let t={};for(let r of Q.objectKeys(this.shape))if(e&&!e[r])t[r]=this.shape[r];else{let o=this.shape[r];while(o instanceof Gt)o=o._def.innerType;t[r]=o}return new ke({...this._def,shape:()=>t})}keyof(){return Wa(Q.objectKeys(this.shape))}}ke.create=(e,t)=>new ke({shape:()=>e,unknownKeys:"strip",catchall:tr.create(),typeName:D.ZodObject,...z(t)});ke.strictCreate=(e,t)=>new ke({shape:()=>e,unknownKeys:"strict",catchall:tr.create(),typeName:D.ZodObject,...z(t)});ke.lazycreate=(e,t)=>new ke({shape:e,unknownKeys:"strip",catchall:tr.create(),typeName:D.ZodObject,...z(t)});class Ln extends W{_parse(e){let{ctx:t}=this._processInputParams(e),r=this._def.options;function n(o){for(let i of o)if(i.result.status==="valid")return i.result;for(let i of o)if(i.result.status==="dirty")return t.common.issues.push(...i.ctx.common.issues),i.result;let s=o.map((i)=>new mt(i.ctx.common.issues));return O(t,{code:R.invalid_union,unionErrors:s}),v}if(t.common.async)return Promise.all(r.map(async(o)=>{let s={...t,common:{...t.common,issues:[]},parent:null};return{result:await o._parseAsync({data:t.data,path:t.path,parent:s}),ctx:s}})).then(n);else{let o=void 0,s=[];for(let a of r){let u={...t,common:{...t.common,issues:[]},parent:null},c=a._parseSync({data:t.data,path:t.path,parent:u});if(c.status==="valid")return c;else if(c.status==="dirty"&&!o)o={result:c,ctx:u};if(u.common.issues.length)s.push(u.common.issues)}if(o)return t.common.issues.push(...o.ctx.common.issues),o.result;let i=s.map((a)=>new mt(a));return O(t,{code:R.invalid_union,unionErrors:i}),v}}get options(){return this._def.options}}Ln.create=(e,t)=>new Ln({options:e,typeName:D.ZodUnion,...z(t)});var hr=(e)=>{if(e instanceof Kn)return hr(e.schema);else if(e instanceof zt)return hr(e.innerType());else if(e instanceof Bn)return[e.value];else if(e instanceof Er)return e.options;else if(e instanceof vn)return Q.objectValues(e.enum);else if(e instanceof Dn)return hr(e._def.innerType);else if(e instanceof jn)return[void 0];else if(e instanceof En)return[null];else if(e instanceof Gt)return[void 0,...hr(e.unwrap())];else if(e instanceof xr)return[null,...hr(e.unwrap())];else if(e instanceof cs)return hr(e.unwrap());else if(e instanceof Gn)return hr(e.unwrap());else if(e instanceof qn)return hr(e._def.innerType);else return[]};class as extends W{_parse(e){let{ctx:t}=this._processInputParams(e);if(t.parsedType!==k.object)return O(t,{code:R.invalid_type,expected:k.object,received:t.parsedType}),v;let r=this.discriminator,n=t.data[r],o=this.optionsMap.get(n);if(!o)return O(t,{code:R.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[r]}),v;if(t.common.async)return o._parseAsync({data:t.data,path:t.path,parent:t});else return o._parseSync({data:t.data,path:t.path,parent:t})}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,t,r){let n=new Map;for(let o of t){let s=hr(o.shape[e]);if(!s.length)throw Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);for(let i of s){if(n.has(i))throw Error(`Discriminator property ${String(e)} has duplicate value ${String(i)}`);n.set(i,o)}}return new as({typeName:D.ZodDiscriminatedUnion,discriminator:e,options:t,optionsMap:n,...z(r)})}}function ri(e,t){let r=er(e),n=er(t);if(e===t)return{valid:!0,data:e};else if(r===k.object&&n===k.object){let o=Q.objectKeys(t),s=Q.objectKeys(e).filter((a)=>o.indexOf(a)!==-1),i={...e,...t};for(let a of s){let u=ri(e[a],t[a]);if(!u.valid)return{valid:!1};i[a]=u.data}return{valid:!0,data:i}}else if(r===k.array&&n===k.array){if(e.length!==t.length)return{valid:!1};let o=[];for(let s=0;s<e.length;s++){let i=e[s],a=t[s],u=ri(i,a);if(!u.valid)return{valid:!1};o.push(u.data)}return{valid:!0,data:o}}else if(r===k.date&&n===k.date&&+e===+t)return{valid:!0,data:e};else return{valid:!1}}class Un extends W{_parse(e){let{status:t,ctx:r}=this._processInputParams(e),n=(o,s)=>{if(ss(o)||ss(s))return v;let i=ri(o.value,s.value);if(!i.valid)return O(r,{code:R.invalid_intersection_types}),v;if(is(o)||is(s))t.dirty();return{status:t.value,value:i.data}};if(r.common.async)return Promise.all([this._def.left._parseAsync({data:r.data,path:r.path,parent:r}),this._def.right._parseAsync({data:r.data,path:r.path,parent:r})]).then(([o,s])=>n(o,s));else return n(this._def.left._parseSync({data:r.data,path:r.path,parent:r}),this._def.right._parseSync({data:r.data,path:r.path,parent:r}))}}Un.create=(e,t,r)=>new Un({left:e,right:t,typeName:D.ZodIntersection,...z(r)});class rr extends W{_parse(e){let{status:t,ctx:r}=this._processInputParams(e);if(r.parsedType!==k.array)return O(r,{code:R.invalid_type,expected:k.array,received:r.parsedType}),v;if(r.data.length<this._def.items.length)return O(r,{code:R.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),v;if(!this._def.rest&&r.data.length>this._def.items.length)O(r,{code:R.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),t.dirty();let o=[...r.data].map((s,i)=>{let a=this._def.items[i]||this._def.rest;if(!a)return null;return a._parse(new Ht(r,s,r.path,i))}).filter((s)=>!!s);if(r.common.async)return Promise.all(o).then((s)=>Qe.mergeArray(t,s));else return Qe.mergeArray(t,o)}get items(){return this._def.items}rest(e){return new rr({...this._def,rest:e})}}rr.create=(e,t)=>{if(!Array.isArray(e))throw Error("You must pass an array of schemas to z.tuple([ ... ])");return new rr({items:e,typeName:D.ZodTuple,rest:null,...z(t)})};class xo extends W{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!==k.object)return O(r,{code:R.invalid_type,expected:k.object,received:r.parsedType}),v;let n=[],o=this._def.keyType,s=this._def.valueType;for(let i in r.data)n.push({key:o._parse(new Ht(r,i,r.path,i)),value:s._parse(new Ht(r,r.data[i],r.path,i)),alwaysSet:i in r.data});if(r.common.async)return Qe.mergeObjectAsync(t,n);else return Qe.mergeObjectSync(t,n)}get element(){return this._def.valueType}static create(e,t,r){if(t instanceof W)return new xo({keyType:e,valueType:t,typeName:D.ZodRecord,...z(r)});return new xo({keyType:Dt.create(),valueType:e,typeName:D.ZodRecord,...z(t)})}}class Io extends W{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!==k.map)return O(r,{code:R.invalid_type,expected:k.map,received:r.parsedType}),v;let n=this._def.keyType,o=this._def.valueType,s=[...r.data.entries()].map(([i,a],u)=>({key:n._parse(new Ht(r,i,r.path,[u,"key"])),value:o._parse(new Ht(r,a,r.path,[u,"value"]))}));if(r.common.async){let i=new Map;return Promise.resolve().then(async()=>{for(let a of s){let u=await a.key,c=await a.value;if(u.status==="aborted"||c.status==="aborted")return v;if(u.status==="dirty"||c.status==="dirty")t.dirty();i.set(u.value,c.value)}return{status:t.value,value:i}})}else{let i=new Map;for(let a of s){let{key:u,value:c}=a;if(u.status==="aborted"||c.status==="aborted")return v;if(u.status==="dirty"||c.status==="dirty")t.dirty();i.set(u.value,c.value)}return{status:t.value,value:i}}}}Io.create=(e,t,r)=>new Io({valueType:t,keyType:e,typeName:D.ZodMap,...z(r)});class sn extends W{_parse(e){let{status:t,ctx:r}=this._processInputParams(e);if(r.parsedType!==k.set)return O(r,{code:R.invalid_type,expected:k.set,received:r.parsedType}),v;let n=this._def;if(n.minSize!==null){if(r.data.size<n.minSize.value)O(r,{code:R.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)O(r,{code:R.too_big,maximum:n.maxSize.value,type:"set",inclusive:!0,exact:!1,message:n.maxSize.message}),t.dirty()}let o=this._def.valueType;function s(a){let u=new Set;for(let c of a){if(c.status==="aborted")return v;if(c.status==="dirty")t.dirty();u.add(c.value)}return{status:t.value,value:u}}let i=[...r.data.values()].map((a,u)=>o._parse(new Ht(r,a,r.path,u)));if(r.common.async)return Promise.all(i).then((a)=>s(a));else return s(i)}min(e,t){return new sn({...this._def,minSize:{value:e,message:N.toString(t)}})}max(e,t){return new sn({...this._def,maxSize:{value:e,message:N.toString(t)}})}size(e,t){return this.min(e,t).max(e,t)}nonempty(e){return this.min(1,e)}}sn.create=(e,t)=>new sn({valueType:e,minSize:null,maxSize:null,typeName:D.ZodSet,...z(t)});class Nn extends W{constructor(){super(...arguments);this.validate=this.implement}_parse(e){let{ctx:t}=this._processInputParams(e);if(t.parsedType!==k.function)return O(t,{code:R.invalid_type,expected:k.function,received:t.parsedType}),v;function r(i,a){return yo({data:i,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,kn(),gr].filter((u)=>!!u),issueData:{code:R.invalid_arguments,argumentsError:a}})}function n(i,a){return yo({data:i,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,kn(),gr].filter((u)=>!!u),issueData:{code:R.invalid_return_type,returnTypeError:a}})}let o={errorMap:t.common.contextualErrorMap},s=t.data;if(this._def.returns instanceof an){let i=this;return nt(async function(...a){let u=new mt([]),c=await i._def.args.parseAsync(a,o).catch((p)=>{throw u.addIssue(r(a,p)),u}),d=await Reflect.apply(s,this,c);return await i._def.returns._def.type.parseAsync(d,o).catch((p)=>{throw u.addIssue(n(d,p)),u})})}else{let i=this;return nt(function(...a){let u=i._def.args.safeParse(a,o);if(!u.success)throw new mt([r(a,u.error)]);let c=Reflect.apply(s,this,u.data),d=i._def.returns.safeParse(c,o);if(!d.success)throw new mt([n(c,d.error)]);return d.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new Nn({...this._def,args:rr.create(e).rest(Nr.create())})}returns(e){return new Nn({...this._def,returns:e})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,t,r){return new Nn({args:e?e:rr.create([]).rest(Nr.create()),returns:t||Nr.create(),typeName:D.ZodFunction,...z(r)})}}class Kn extends W{get schema(){return this._def.getter()}_parse(e){let{ctx:t}=this._processInputParams(e);return this._def.getter()._parse({data:t.data,path:t.path,parent:t})}}Kn.create=(e,t)=>new Kn({getter:e,typeName:D.ZodLazy,...z(t)});class Bn extends W{_parse(e){if(e.data!==this._def.value){let t=this._getOrReturnCtx(e);return O(t,{received:t.data,code:R.invalid_literal,expected:this._def.value}),v}return{status:"valid",value:e.data}}get value(){return this._def.value}}Bn.create=(e,t)=>new Bn({value:e,typeName:D.ZodLiteral,...z(t)});function Wa(e,t){return new Er({values:e,typeName:D.ZodEnum,...z(t)})}class Er extends W{_parse(e){if(typeof e.data!=="string"){let t=this._getOrReturnCtx(e),r=this._def.values;return O(t,{expected:Q.joinValues(r),received:t.parsedType,code:R.invalid_type}),v}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 O(t,{received:t.data,code:R.invalid_enum_value,options:r}),v}return nt(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 Er.create(e,{...this._def,...t})}exclude(e,t=this._def){return Er.create(this.options.filter((r)=>!e.includes(r)),{...this._def,...t})}}Er.create=Wa;class vn extends W{_parse(e){let t=Q.getValidEnumValues(this._def.values),r=this._getOrReturnCtx(e);if(r.parsedType!==k.string&&r.parsedType!==k.number){let n=Q.objectValues(t);return O(r,{expected:Q.joinValues(n),received:r.parsedType,code:R.invalid_type}),v}if(!this._cache)this._cache=new Set(Q.getValidEnumValues(this._def.values));if(!this._cache.has(e.data)){let n=Q.objectValues(t);return O(r,{received:r.data,code:R.invalid_enum_value,options:n}),v}return nt(e.data)}get enum(){return this._def.values}}vn.create=(e,t)=>new vn({values:e,typeName:D.ZodNativeEnum,...z(t)});class an extends W{unwrap(){return this._def.type}_parse(e){let{ctx:t}=this._processInputParams(e);if(t.parsedType!==k.promise&&t.common.async===!1)return O(t,{code:R.invalid_type,expected:k.promise,received:t.parsedType}),v;let r=t.parsedType===k.promise?t.data:Promise.resolve(t.data);return nt(r.then((n)=>this._def.type.parseAsync(n,{path:t.path,errorMap:t.common.contextualErrorMap})))}}an.create=(e,t)=>new an({type:e,typeName:D.ZodPromise,...z(t)});class zt extends W{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===D.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){let{status:t,ctx:r}=this._processInputParams(e),n=this._def.effect||null,o={addIssue:(s)=>{if(O(r,s),s.fatal)t.abort();else t.dirty()},get path(){return r.path}};if(o.addIssue=o.addIssue.bind(o),n.type==="preprocess"){let s=n.transform(r.data,o);if(r.common.async)return Promise.resolve(s).then(async(i)=>{if(t.value==="aborted")return v;let a=await this._def.schema._parseAsync({data:i,path:r.path,parent:r});if(a.status==="aborted")return v;if(a.status==="dirty")return rn(a.value);if(t.value==="dirty")return rn(a.value);return a});else{if(t.value==="aborted")return v;let i=this._def.schema._parseSync({data:s,path:r.path,parent:r});if(i.status==="aborted")return v;if(i.status==="dirty")return rn(i.value);if(t.value==="dirty")return rn(i.value);return i}}if(n.type==="refinement"){let s=(i)=>{let a=n.refinement(i,o);if(r.common.async)return Promise.resolve(a);if(a instanceof Promise)throw Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return i};if(r.common.async===!1){let i=this._def.schema._parseSync({data:r.data,path:r.path,parent:r});if(i.status==="aborted")return v;if(i.status==="dirty")t.dirty();return s(i.value),{status:t.value,value:i.value}}else return this._def.schema._parseAsync({data:r.data,path:r.path,parent:r}).then((i)=>{if(i.status==="aborted")return v;if(i.status==="dirty")t.dirty();return s(i.value).then(()=>({status:t.value,value:i.value}))})}if(n.type==="transform")if(r.common.async===!1){let s=this._def.schema._parseSync({data:r.data,path:r.path,parent:r});if(!Fr(s))return v;let i=n.transform(s.value,o);if(i instanceof Promise)throw Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:t.value,value:i}}else return this._def.schema._parseAsync({data:r.data,path:r.path,parent:r}).then((s)=>{if(!Fr(s))return v;return Promise.resolve(n.transform(s.value,o)).then((i)=>({status:t.value,value:i}))});Q.assertNever(n)}}zt.create=(e,t,r)=>new zt({schema:e,typeName:D.ZodEffects,effect:t,...z(r)});zt.createWithPreprocess=(e,t,r)=>new zt({schema:t,effect:{type:"preprocess",transform:e},typeName:D.ZodEffects,...z(r)});class Gt extends W{_parse(e){if(this._getType(e)===k.undefined)return nt(void 0);return this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}Gt.create=(e,t)=>new Gt({innerType:e,typeName:D.ZodOptional,...z(t)});class xr extends W{_parse(e){if(this._getType(e)===k.null)return nt(null);return this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}xr.create=(e,t)=>new xr({innerType:e,typeName:D.ZodNullable,...z(t)});class Dn extends W{_parse(e){let{ctx:t}=this._processInputParams(e),r=t.data;if(t.parsedType===k.undefined)r=this._def.defaultValue();return this._def.innerType._parse({data:r,path:t.path,parent:t})}removeDefault(){return this._def.innerType}}Dn.create=(e,t)=>new Dn({innerType:e,typeName:D.ZodDefault,defaultValue:typeof t.default==="function"?t.default:()=>t.default,...z(t)});class qn extends W{_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(Tn(n))return n.then((o)=>({status:"valid",value:o.status==="valid"?o.value:this._def.catchValue({get error(){return new mt(r.common.issues)},input:r.data})}));else return{status:"valid",value:n.status==="valid"?n.value:this._def.catchValue({get error(){return new mt(r.common.issues)},input:r.data})}}removeCatch(){return this._def.innerType}}qn.create=(e,t)=>new qn({innerType:e,typeName:D.ZodCatch,catchValue:typeof t.catch==="function"?t.catch:()=>t.catch,...z(t)});class bo extends W{_parse(e){if(this._getType(e)!==k.nan){let r=this._getOrReturnCtx(e);return O(r,{code:R.invalid_type,expected:k.nan,received:r.parsedType}),v}return{status:"valid",value:e.data}}}bo.create=(e)=>new bo({typeName:D.ZodNaN,...z(e)});var vl=Symbol("zod_brand");class cs extends W{_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 W{_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 v;if(o.status==="dirty")return t.dirty(),rn(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 v;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:D.ZodPipeline})}}class Gn extends W{_parse(e){let t=this._def.innerType._parse(e),r=(n)=>{if(Fr(n))n.value=Object.freeze(n.value);return n};return Tn(t)?t.then((n)=>r(n)):r(t)}unwrap(){return this._def.innerType}}Gn.create=(e,t)=>new Gn({innerType:e,typeName:D.ZodReadonly,...z(t)});function Ha(e,t){let r=typeof e==="function"?e(t):typeof e==="string"?{message:e}:e;return typeof r==="string"?{message:r}:r}function Xa(e,t={},r){if(e)return on.create().superRefine((n,o)=>{let s=e(n);if(s instanceof Promise)return s.then((i)=>{if(!i){let a=Ha(t,n),u=a.fatal??r??!0;o.addIssue({code:"custom",...a,fatal:u})}});if(!s){let i=Ha(t,n),a=i.fatal??r??!0;o.addIssue({code:"custom",...i,fatal:a})}return});return on.create()}var Dl={object:ke.lazycreate},D;(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"})(D||(D={}));var ql=(e,t={message:`Input not instance of ${e.name}`})=>Xa((r)=>r instanceof e,t),Ya=Dt.create,Qa=Mr.create,Gl=bo.create,Hl=jr.create,Za=Mn.create,zl=nn.create,Vl=go.create,Jl=jn.create,Wl=En.create,Xl=on.create,Yl=Nr.create,Ql=tr.create,Zl=ho.create,ey=qt.create,{create:ty,strictCreate:ry}=ke,ny=Ln.create,oy=as.create,sy=Un.create,iy=rr.create,ay=xo.create,cy=Io.create,uy=sn.create,dy=Nn.create,fy=Kn.create,my=Bn.create,py=Er.create,ly=vn.create,yy=an.create,gy=zt.create,hy=Gt.create,xy=xr.create,Iy=zt.createWithPreprocess,by=Ro.create,Ry=()=>Ya().optional(),_y=()=>Qa().optional(),Oy=()=>Za().optional(),wy={string:(e)=>Dt.create({...e,coerce:!0}),number:(e)=>Mr.create({...e,coerce:!0}),boolean:(e)=>Mn.create({...e,coerce:!0}),bigint:(e)=>jr.create({...e,coerce:!0}),date:(e)=>nn.create({...e,coerce:!0})};var $y=v;var Sy=us,Je=(e,t=400)=>Response.json(e,{status:t,headers:{"Content-Type":"application/json"}}),tc=(e)=>{let t=lo.Compile(e),r=async(n,o)=>{try{let s=n instanceof Object&&"req"in n,i=s?await n.jsonBody():await n.json();if(!t.Check(i)){let a=t.Errors(i).First();return Je({status:"error",code:"VALIDATION_FAILED",message:a?.message||"Invalid input",path:a?.path||"body"})}if(s)n.body=i;return o?o():void 0}catch(s){if(s?.status===413)return Je({status:"error",code:"PAYLOAD_TOO_LARGE",message:"Payload Too Large"},413);return Je({status:"error",message:"Malformed JSON payload"})}};return r.__schema=e,r},rc=(e)=>{let t=e.properties||{},r=Object.keys(t),n=r.length,o=Array.isArray(e.required)?new Set(e.required):null,s=(a,u)=>{if(u==="array")return Array.isArray(a);if(u==="integer")return typeof a==="number"&&Number.isInteger(a);if(u==="object")return a!==null&&typeof a==="object"&&!Array.isArray(a);if(u==="null")return a===null;return typeof a===u},i=async(a,u)=>{try{let c=a instanceof Object&&"req"in a,d=c?await a.jsonBody():await a.json();if(!d||typeof d!=="object"||Array.isArray(d))return Je({status:"error",message:"Invalid JSON object payload"});for(let f=0;f<n;f++){let p=r[f];if(!(Object.hasOwn(d,p)&&d[p]!==void 0)){if(!o||o.has(p))return Je({status:"error",code:"TYPE_MISMATCH",message:`Field '${p}' must be of type ${t[p]?.type}`,field:p});continue}if(!s(d[p],t[p]?.type))return Je({status:"error",code:"TYPE_MISMATCH",message:`Field '${p}' must be of type ${t[p]?.type}`,field:p})}if(c)a.body=d;return u?u():void 0}catch(c){if(c?.status===413)return Je({status:"error",code:"PAYLOAD_TOO_LARGE",message:"Payload Too Large"},413);return Je({status:"error",message:"Invalid JSON payload"})}};return i.__schema=e,i},nc=(e)=>{let t=async(r,n)=>{try{let o=r instanceof Object&&"req"in r,s=o?await r.jsonBody():await r.json(),i=await e.safeParseAsync(s);if(!i.success)return Je({status:"error",code:"ZOD_ERROR",errors:i.error.flatten()});if(o)r.body=i.data;return n?n():void 0}catch(o){if(o?.status===413)return Je({status:"error",code:"PAYLOAD_TOO_LARGE",message:"Payload Too Large"},413);return Je({status:"error",message:"Invalid JSON payload"})}};return t.__schema=e,t},Cy=(e)=>{if(e&&"_def"in e)return nc(e);if(e&&(e.kind||e.type||e[Symbol.for("TypeBox.Kind")]))return tc(e);return rc(e)};var _o=(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=lo.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}}}},ni=(e,t,r,n=0)=>{let o=e?.properties;if(!o||typeof o!=="object")return null;let s="",i=0;for(let[a,u]of Object.entries(o)){if(a==="__proto__"||a==="constructor"||a==="prototype")continue;let c=JSON.stringify(a),d=`v_${n}_${i++}`,f=`d_${n}_${i}`,p=ni(u,d,f,n+1);if(s+=`const ${d} = ${t}[${c}];
8
- `,p)s+=`if (${d} !== undefined) {
9
- `,s+=` if (${d} && typeof ${d} === 'object' && !Array.isArray(${d})) {
10
- `,s+=` const ${f} = {};
11
- ${p} ${r}[${c}] = ${f};
2
+ var Ac=Object.defineProperty;var Sc=(e)=>e;function Pc(e,t){this[e]=Sc.bind(null,t)}var Mi=(e,t)=>{for(var r in t)Ac(e,r,{get:t[r],enumerable:!0,configurable:!0,set:Pc.bind(t,r)})};var _s={};Mi(_s,{BRAND:()=>ny,DIRTY:()=>ln,EMPTY_PATH:()=>Mm,INVALID:()=>H,NEVER:()=>vy,OK:()=>ut,ParseStatus:()=>nt,Schema:()=>se,ZodAny:()=>yn,ZodArray:()=>Qt,ZodBigInt:()=>Gr,ZodBoolean:()=>qn,ZodBranded:()=>Is,ZodCatch:()=>Qn,ZodDate:()=>mn,ZodDefault:()=>Xn,ZodDiscriminatedUnion:()=>bs,ZodEffects:()=>tr,ZodEnum:()=>Hr,ZodError:()=>xt,ZodFirstPartyTypeKind:()=>V,ZodFunction:()=>Dn,ZodIntersection:()=>Vn,ZodIssueCode:()=>S,ZodLazy:()=>Jn,ZodLiteral:()=>Wn,ZodMap:()=>Co,ZodNaN:()=>To,ZodNativeEnum:()=>Yn,ZodNever:()=>fr,ZodNull:()=>Hn,ZodNullable:()=>Sr,ZodNumber:()=>qr,ZodObject:()=>ve,ZodOptional:()=>Zt,ZodParsedType:()=>M,ZodPipeline:()=>Fo,ZodPromise:()=>hn,ZodReadonly:()=>Zn,ZodRecord:()=>Po,ZodSchema:()=>se,ZodSet:()=>gn,ZodString:()=>Xt,ZodSymbol:()=>Ao,ZodTransformer:()=>tr,ZodTuple:()=>dr,ZodType:()=>se,ZodUndefined:()=>Gn,ZodUnion:()=>zn,ZodUnknown:()=>Dr,ZodVoid:()=>So,addIssueToContext:()=>F,any:()=>py,array:()=>gy,bigint:()=>ay,boolean:()=>pu,coerce:()=>By,custom:()=>cu,date:()=>uy,datetimeRegex:()=>au,defaultErrorMap:()=>kr,discriminatedUnion:()=>Iy,effect:()=>Fy,enum:()=>Py,function:()=>ky,getErrorMap:()=>Kn,getParsedType:()=>cr,instanceof:()=>sy,intersection:()=>_y,isAborted:()=>hs,isAsync:()=>Bn,isDirty:()=>xs,isValid:()=>vr,late:()=>oy,lazy:()=>Ay,literal:()=>Sy,makeIssue:()=>ko,map:()=>wy,nan:()=>iy,nativeEnum:()=>Cy,never:()=>my,null:()=>dy,nullable:()=>jy,number:()=>du,object:()=>hy,objectUtil:()=>mi,oboolean:()=>Ky,onumber:()=>Uy,optional:()=>Ny,ostring:()=>Ly,pipeline:()=>Ey,preprocess:()=>My,promise:()=>Ty,quotelessJson:()=>Fm,record:()=>Oy,set:()=>$y,setErrorMap:()=>jm,strictObject:()=>xy,string:()=>fu,symbol:()=>cy,transformer:()=>Fy,tuple:()=>Ry,undefined:()=>fy,union:()=>by,unknown:()=>ly,util:()=>fe,void:()=>yy});var ki={};Mi(ki,{Any:()=>Er,Argument:()=>Ou,Array:()=>wn,AsyncIterator:()=>$n,Awaited:()=>ro,BigInt:()=>Cn,Boolean:()=>rs,Capitalize:()=>Bu,Composite:()=>$u,Const:()=>ku,Constructor:()=>kn,ConstructorParameters:()=>Au,Date:()=>ws,Enum:()=>Su,Exclude:()=>no,Extends:()=>Un,Extract:()=>oo,Function:()=>ar,Index:()=>jr,InstanceType:()=>Nu,Instantiate:()=>Mu,Integer:()=>Eu,Intersect:()=>st,Iterator:()=>Tn,KeyOf:()=>Fn,Literal:()=>xe,Lowercase:()=>vu,Mapped:()=>ya,Module:()=>rc,Never:()=>ne,Not:()=>nc,Null:()=>$s,Number:()=>St,Object:()=>Ie,Omit:()=>zr,Optional:()=>ot,Parameters:()=>oc,Partial:()=>so,Pick:()=>Vr,Promise:()=>ss,Readonly:()=>yt,ReadonlyOptional:()=>Cs,Record:()=>Ts,Recursive:()=>sc,Ref:()=>Tt,RegExp:()=>ic,Required:()=>io,Rest:()=>ac,ReturnType:()=>uc,String:()=>Ht,Symbol:()=>ks,TemplateLiteral:()=>os,Transform:()=>dc,Tuple:()=>Pt,Uint8Array:()=>Ss,Uncapitalize:()=>Du,Undefined:()=>As,Union:()=>be,Unknown:()=>Lr,Unsafe:()=>qi,Uppercase:()=>qu,Void:()=>pc});function vo(e){return pt(e)&&globalThis.Symbol.asyncIterator in e}function Do(e){return pt(e)&&globalThis.Symbol.iterator in e}function qo(e){return e instanceof globalThis.Promise}function _n(e){return e instanceof Date&&globalThis.Number.isFinite(e.getTime())}function Rn(e){return e instanceof globalThis.Uint8Array}function Go(e,t){return t in e}function pt(e){return e!==null&&typeof e==="object"}function Ge(e){return globalThis.Array.isArray(e)&&!globalThis.ArrayBuffer.isView(e)}function ft(e){return e===void 0}function Wr(e){return e===null}function Yr(e){return typeof e==="boolean"}function X(e){return typeof e==="number"}function Ho(e){return globalThis.Number.isInteger(e)}function bt(e){return typeof e==="bigint"}function Ye(e){return typeof e==="string"}function zo(e){return typeof e==="function"}function Xr(e){return typeof e==="symbol"}function Vo(e){return bt(e)||Yr(e)||Wr(e)||X(e)||Ye(e)||Xr(e)||ft(e)}var ke;(function(e){e.InstanceMode="default",e.ExactOptionalPropertyTypes=!1,e.AllowArrayObject=!1,e.AllowNaN=!1,e.AllowNullVoid=!1;function t(i,a){return e.ExactOptionalPropertyTypes?a in i:i[a]!==void 0}e.IsExactOptionalProperty=t;function r(i){let a=pt(i);return e.AllowArrayObject?a:a&&!Ge(i)}e.IsObjectLike=r;function n(i){return r(i)&&!(i instanceof Date)&&!(i instanceof Uint8Array)}e.IsRecordLike=n;function o(i){return e.AllowNaN?X(i):Number.isFinite(i)}e.IsNumberLike=o;function s(i){let a=ft(i);return e.AllowNullVoid?a||i===null:a}e.IsVoidLike=s})(ke||(ke={}));var Ei=new Map;function Ks(e){return Ei.has(e)}function Bs(e){return Ei.get(e)}var Li=new Map;function co(e){return Li.has(e)}function vs(e){return Li.get(e)}function Ui(e){return Te(e)&&!He(e)&&!Cr(e)&&Symbol.asyncIterator in e}function He(e){return Array.isArray(e)}function Yo(e){return typeof e==="bigint"}function Pr(e){return typeof e==="boolean"}function On(e){return e instanceof globalThis.Date}function Ki(e){return typeof e==="function"}function Bi(e){return Te(e)&&!He(e)&&!Cr(e)&&Symbol.iterator in e}function vi(e){return e===null}function It(e){return typeof e==="number"}function Te(e){return typeof e==="object"&&e!==null}function Xo(e){return e instanceof globalThis.RegExp}function Ae(e){return typeof e==="string"}function Di(e){return typeof e==="symbol"}function Cr(e){return e instanceof globalThis.Uint8Array}function Se(e){return e===void 0}function Cc(e){return globalThis.Object.freeze(e).map((t)=>fo(t))}function Tc(e){return e}function Fc(e){return e}function Nc(e){return e}function jc(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 globalThis.Object.freeze(t)}function fo(e){return He(e)?Cc(e):On(e)?Tc(e):Cr(e)?Fc(e):Xo(e)?Nc(e):Te(e)?jc(e):e}function Mc(e){return e.map((t)=>Qo(t))}function Ec(e){return new Date(e.getTime())}function Lc(e){return new Uint8Array(e)}function Uc(e){return new RegExp(e.source,e.flags)}function Kc(e){let t={};for(let r of Object.getOwnPropertyNames(e))t[r]=Qo(e[r]);for(let r of Object.getOwnPropertySymbols(e))t[r]=Qo(e[r]);return t}function Qo(e){return He(e)?Mc(e):On(e)?Ec(e):Cr(e)?Lc(e):Xo(e)?Uc(e):Te(e)?Kc(e):e}function Fe(e){return Qo(e)}function I(e,t){let r=t!==void 0?{...t,...e}:e;switch(ke.InstanceMode){case"freeze":return fo(r);case"clone":return Fe(r);default:return r}}var je=Symbol.for("TypeBox.Transform"),sr=Symbol.for("TypeBox.Readonly"),et=Symbol.for("TypeBox.Optional"),ir=Symbol.for("TypeBox.Hint"),O=Symbol.for("TypeBox.Kind");function qi(e={}){return I({[O]:e[O]??"Unsafe"},e)}class he extends Error{constructor(e){super(e)}}function me(e){return I({[O]:"MappedResult",properties:e})}function Bc(e,t){let{[t]:r,...n}=e;return n}function Ue(e,t){return t.reduce((r,n)=>Bc(r,n),e)}function wn(e,t){return I({[O]:"Array",type:"array",items:e},t)}function $n(e,t){return I({[O]:"AsyncIterator",type:"AsyncIterator",items:e},t)}function kn(e,t,r){return I({[O]:"Constructor",type:"Constructor",parameters:e,returns:t},r)}function ar(e,t,r){return I({[O]:"Function",type:"Function",parameters:e,returns:t},r)}function Pe(e,t,r){return I({[O]:"Computed",target:e,parameters:t},r)}function ne(e){return I({[O]:"Never",not:{}},e)}function An(e){return Te(e)&&e[sr]==="Readonly"}function lt(e){return Te(e)&&e[et]==="Optional"}function Ds(e){return de(e,"Any")}function qs(e){return de(e,"Argument")}function Kt(e){return de(e,"Array")}function Zr(e){return de(e,"AsyncIterator")}function en(e){return de(e,"BigInt")}function yr(e){return de(e,"Boolean")}function Bt(e){return de(e,"Computed")}function vt(e){return de(e,"Constructor")}function vc(e){return de(e,"Date")}function Dt(e){return de(e,"Function")}function qt(e){return de(e,"Integer")}function Ke(e){return de(e,"Intersect")}function tn(e){return de(e,"Iterator")}function de(e,t){return Te(e)&&O in e&&e[O]===t}function Zo(e){return Pr(e)||It(e)||Ae(e)}function _t(e){return de(e,"Literal")}function Rt(e){return de(e,"MappedKey")}function Ne(e){return de(e,"MappedResult")}function Tr(e){return de(e,"Never")}function Dc(e){return de(e,"Not")}function po(e){return de(e,"Null")}function Gt(e){return de(e,"Number")}function qe(e){return de(e,"Object")}function rn(e){return de(e,"Promise")}function nn(e){return de(e,"Record")}function De(e){return de(e,"Ref")}function Gs(e){return de(e,"RegExp")}function gr(e){return de(e,"String")}function lo(e){return de(e,"Symbol")}function Ot(e){return de(e,"TemplateLiteral")}function qc(e){return de(e,"This")}function ye(e){return Te(e)&&je in e}function wt(e){return de(e,"Tuple")}function hr(e){return de(e,"Undefined")}function le(e){return de(e,"Union")}function Gc(e){return de(e,"Uint8Array")}function Hc(e){return de(e,"Unknown")}function zc(e){return de(e,"Unsafe")}function Vc(e){return de(e,"Void")}function Jc(e){return Te(e)&&O in e&&Ae(e[O])}function Me(e){return Ds(e)||qs(e)||Kt(e)||yr(e)||en(e)||Zr(e)||Bt(e)||vt(e)||vc(e)||Dt(e)||qt(e)||Ke(e)||tn(e)||_t(e)||Rt(e)||Ne(e)||Tr(e)||Dc(e)||po(e)||Gt(e)||qe(e)||rn(e)||nn(e)||De(e)||Gs(e)||gr(e)||lo(e)||Ot(e)||qc(e)||wt(e)||hr(e)||le(e)||Gc(e)||Hc(e)||zc(e)||Vc(e)||Jc(e)}function Wc(e){return I(Ue(e,[et]))}function Yc(e){return I({...e,[et]:"Optional"})}function Xc(e,t){return t===!1?Wc(e):Yc(e)}function ot(e,t){let r=t??!0;return Ne(e)?Gi(e,r):Xc(e,r)}function Qc(e,t){let r={};for(let n of globalThis.Object.getOwnPropertyNames(e))r[n]=ot(e[n],t);return r}function Zc(e,t){return Qc(e.properties,t)}function Gi(e,t){let r=Zc(e,t);return me(r)}function mo(e,t={}){let r=e.every((o)=>qe(o)),n=Me(t.unevaluatedProperties)?{unevaluatedProperties:t.unevaluatedProperties}:{};return I(t.unevaluatedProperties===!1||Me(t.unevaluatedProperties)||r?{...n,[O]:"Intersect",type:"object",allOf:e}:{...n,[O]:"Intersect",allOf:e},t)}function ef(e){return e.every((t)=>lt(t))}function tf(e){return Ue(e,[et])}function Hi(e){return e.map((t)=>lt(t)?tf(t):t)}function rf(e,t){return ef(e)?ot(mo(Hi(e),t)):mo(Hi(e),t)}function es(e,t={}){if(e.length===1)return I(e[0],t);if(e.length===0)return ne(t);if(e.some((r)=>ye(r)))throw Error("Cannot intersect transform types");return rf(e,t)}function st(e,t){if(e.length===1)return I(e[0],t);if(e.length===0)return ne(t);if(e.some((r)=>ye(r)))throw Error("Cannot intersect transform types");return mo(e,t)}function yo(e,t){return I({[O]:"Union",anyOf:e},t)}function nf(e){return e.some((t)=>lt(t))}function zi(e){return e.map((t)=>lt(t)?of(t):t)}function of(e){return Ue(e,[et])}function sf(e,t){return nf(e)?ot(yo(zi(e),t)):yo(zi(e),t)}function ur(e,t){return e.length===1?I(e[0],t):e.length===0?ne(t):sf(e,t)}function be(e,t){return e.length===0?ne(t):e.length===1?I(e[0],t):yo(e,t)}class Hs extends he{}function af(e){return e.replace(/\\\$/g,"$").replace(/\\\*/g,"*").replace(/\\\^/g,"^").replace(/\\\|/g,"|").replace(/\\\(/g,"(").replace(/\\\)/g,")")}function zs(e,t,r){return e[t]===r&&e.charCodeAt(t-1)!==92}function br(e,t){return zs(e,t,"(")}function go(e,t){return zs(e,t,")")}function Vi(e,t){return zs(e,t,"|")}function uf(e){if(!(br(e,0)&&go(e,e.length-1)))return!1;let t=0;for(let r=0;r<e.length;r++){if(br(e,r))t+=1;if(go(e,r))t-=1;if(t===0&&r!==e.length-1)return!1}return!0}function cf(e){return e.slice(1,e.length-1)}function ff(e){let t=0;for(let r=0;r<e.length;r++){if(br(e,r))t+=1;if(go(e,r))t-=1;if(Vi(e,r)&&t===0)return!0}return!1}function df(e){for(let t=0;t<e.length;t++)if(br(e,t))return!0;return!1}function pf(e){let[t,r]=[0,0],n=[];for(let s=0;s<e.length;s++){if(br(e,s))t+=1;if(go(e,s))t-=1;if(Vi(e,s)&&t===0){let i=e.slice(r,s);if(i.length>0)n.push(Sn(i));r=s+1}}let o=e.slice(r);if(o.length>0)n.push(Sn(o));if(n.length===0)return{type:"const",const:""};if(n.length===1)return n[0];return{type:"or",expr:n}}function lf(e){function t(o,s){if(!br(o,s))throw new Hs("TemplateLiteralParser: Index must point to open parens");let i=0;for(let a=s;a<o.length;a++){if(br(o,a))i+=1;if(go(o,a))i-=1;if(i===0)return[s,a]}throw new Hs("TemplateLiteralParser: Unclosed group parens in expression")}function r(o,s){for(let i=s;i<o.length;i++)if(br(o,i))return[s,i];return[s,o.length]}let n=[];for(let o=0;o<e.length;o++)if(br(e,o)){let[s,i]=t(e,o),a=e.slice(s,i+1);n.push(Sn(a)),o=i}else{let[s,i]=r(e,o),a=e.slice(s,i);if(a.length>0)n.push(Sn(a));o=i-1}return n.length===0?{type:"const",const:""}:n.length===1?n[0]:{type:"and",expr:n}}function Sn(e){return uf(e)?Sn(cf(e)):ff(e)?pf(e):df(e)?lf(e):{type:"const",const:af(e)}}function Pn(e){return Sn(e.slice(1,e.length-1))}class Ji extends he{}function mf(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 yf(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 gf(e){return e.type==="const"&&e.const===".*"}function on(e){return mf(e)||gf(e)?!1:yf(e)?!0:e.type==="and"?e.expr.every((t)=>on(t)):e.type==="or"?e.expr.every((t)=>on(t)):e.type==="const"?!0:(()=>{throw new Ji("Unknown expression type")})()}function Wi(e){let t=Pn(e.pattern);return on(t)}class Yi extends he{}function*Xi(e){if(e.length===1)return yield*e[0];for(let t of e[0])for(let r of Xi(e.slice(1)))yield`${t}${r}`}function*hf(e){return yield*Xi(e.expr.map((t)=>[...ho(t)]))}function*xf(e){for(let t of e.expr)yield*ho(t)}function*bf(e){return yield e.const}function*ho(e){return e.type==="and"?yield*hf(e):e.type==="or"?yield*xf(e):e.type==="const"?yield*bf(e):(()=>{throw new Yi("Unknown expression")})()}function ts(e){let t=Pn(e.pattern);return on(t)?[...ho(t)]:[]}function xe(e,t){return I({[O]:"Literal",const:e,type:typeof e},t)}function rs(e){return I({[O]:"Boolean",type:"boolean"},e)}function Cn(e){return I({[O]:"BigInt",type:"bigint"},e)}function St(e){return I({[O]:"Number",type:"number"},e)}function Ht(e){return I({[O]:"String",type:"string"},e)}function*If(e){let t=e.trim().replace(/"|'/g,"");return t==="boolean"?yield rs():t==="number"?yield St():t==="bigint"?yield Cn():t==="string"?yield Ht():yield(()=>{let r=t.split("|").map((n)=>xe(n.trim()));return r.length===0?ne():r.length===1?r[0]:ur(r)})()}function*_f(e){if(e[1]!=="{"){let t=xe("$"),r=Vs(e.slice(1));return yield*[t,...r]}for(let t=2;t<e.length;t++)if(e[t]==="}"){let r=If(e.slice(2,t)),n=Vs(e.slice(t+1));return yield*[...r,...n]}yield xe(e)}function*Vs(e){for(let t=0;t<e.length;t++)if(e[t]==="$"){let r=xe(e.slice(0,t)),n=_f(e.slice(t));return yield*[r,...n]}yield xe(e)}function Qi(e){return[...Vs(e)]}var Zi="(true|false)",ns="(0|[1-9][0-9]*)",ea="(.*)";var Fr="^(0|[1-9][0-9]*)$",Nr="^(.*)$",ta="^(?!.*)$";class ra extends he{}function Rf(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function na(e,t){return Ot(e)?e.pattern.slice(1,e.pattern.length-1):le(e)?`(${e.anyOf.map((r)=>na(r,t)).join("|")})`:Gt(e)?`${t}${ns}`:qt(e)?`${t}${ns}`:en(e)?`${t}${ns}`:gr(e)?`${t}${ea}`:_t(e)?`${t}${Rf(e.const.toString())}`:yr(e)?`${t}${Zi}`:(()=>{throw new ra(`Unexpected Kind '${e[O]}'`)})()}function Js(e){return`^${e.map((t)=>na(t,"")).join("")}$`}function sn(e){let r=ts(e).map((n)=>xe(n));return ur(r)}function os(e,t){let r=Ae(e)?Js(Qi(e)):Js(e);return I({[O]:"TemplateLiteral",type:"string",pattern:r},t)}function Of(e){return ts(e).map((r)=>r.toString())}function wf(e){let t=[];for(let r of e)t.push(...mt(r));return t}function $f(e){return[e.toString()]}function mt(e){return[...new Set(Ot(e)?Of(e):le(e)?wf(e.anyOf):_t(e)?$f(e.const):Gt(e)?["[number]"]:qt(e)?["[number]"]:[])]}function kf(e,t,r){let n={};for(let o of Object.getOwnPropertyNames(t))n[o]=jr(e,mt(t[o]),r);return n}function Af(e,t,r){return kf(e,t.properties,r)}function oa(e,t,r){let n=Af(e,t,r);return me(n)}function ia(e,t){return e.map((r)=>aa(r,t))}function Sf(e){return e.filter((t)=>!Tr(t))}function Pf(e,t){return es(Sf(ia(e,t)))}function Cf(e){return e.some((t)=>Tr(t))?[]:e}function Tf(e,t){return ur(Cf(ia(e,t)))}function Ff(e,t){return t in e?e[t]:t==="[number]"?ur(e):ne()}function Nf(e,t){return t==="[number]"?e:ne()}function jf(e,t){return t in e?e[t]:ne()}function aa(e,t){return Ke(e)?Pf(e.allOf,t):le(e)?Tf(e.anyOf,t):wt(e)?Ff(e.items??[],t):Kt(e)?Nf(e.items,t):qe(e)?jf(e.properties,t):ne()}function xo(e,t){return t.map((r)=>aa(e,r))}function sa(e,t){return ur(xo(e,t))}function jr(e,t,r){if(De(e)||De(t)){if(!Me(e)||!Me(t))throw new he("Index types using Ref parameters require both Type and Key to be of TSchema");return Pe("Index",[e,t])}if(Ne(t))return oa(e,t,r);if(Rt(t))return ua(e,t,r);return I(Me(t)?sa(e,mt(t)):sa(e,t),r)}function Mf(e,t,r){return{[t]:jr(e,[t],Fe(r))}}function Ef(e,t,r){return t.reduce((n,o)=>({...n,...Mf(e,o,r)}),{})}function Lf(e,t,r){return Ef(e,t.keys,r)}function ua(e,t,r){let n=Lf(e,t,r);return me(n)}function Tn(e,t){return I({[O]:"Iterator",type:"Iterator",items:e},t)}function Uf(e){return globalThis.Object.keys(e).filter((t)=>!lt(e[t]))}function Kf(e,t){let r=Uf(e),n=r.length>0?{[O]:"Object",type:"object",required:r,properties:e}:{[O]:"Object",type:"object",properties:e};return I(n,t)}var Ie=Kf;function ss(e,t){return I({[O]:"Promise",type:"Promise",item:e},t)}function Bf(e){return I(Ue(e,[sr]))}function vf(e){return I({...e,[sr]:"Readonly"})}function Df(e,t){return t===!1?Bf(e):vf(e)}function yt(e,t){let r=t??!0;return Ne(e)?ca(e,r):Df(e,r)}function qf(e,t){let r={};for(let n of globalThis.Object.getOwnPropertyNames(e))r[n]=yt(e[n],t);return r}function Gf(e,t){return qf(e.properties,t)}function ca(e,t){let r=Gf(e,t);return me(r)}function Pt(e,t){return I(e.length>0?{[O]:"Tuple",type:"array",items:e,additionalItems:!1,minItems:e.length,maxItems:e.length}:{[O]:"Tuple",type:"array",minItems:e.length,maxItems:e.length},t)}function fa(e,t){return e.includes(t)}function da(e){return[...new Set(e)]}function Hf(e,t){return e.filter((r)=>t.includes(r))}function zf(e,t){return e.reduce((r,n)=>Hf(r,n),t)}function pa(e){return e.length===1?e[0]:e.length>1?zf(e.slice(1),e[0]):[]}function la(e){let t=[];for(let r of e)t.push(...r);return t}function ma(e,t){return e in t?Ct(e,t[e]):me(t)}function Vf(e){return{[e]:xe(e)}}function Jf(e){let t={};for(let r of e)t[r]=xe(r);return t}function Wf(e,t){return fa(t,e)?Vf(e):Jf(t)}function Yf(e,t){let r=Wf(e,t);return ma(e,r)}function bo(e,t){return t.map((r)=>Ct(e,r))}function Xf(e,t){let r={};for(let n of globalThis.Object.getOwnPropertyNames(t))r[n]=Ct(e,t[n]);return r}function Ct(e,t){let r={...t};return lt(t)?ot(Ct(e,Ue(t,[et]))):An(t)?yt(Ct(e,Ue(t,[sr]))):Ne(t)?ma(e,t.properties):Rt(t)?Yf(e,t.keys):vt(t)?kn(bo(e,t.parameters),Ct(e,t.returns),r):Dt(t)?ar(bo(e,t.parameters),Ct(e,t.returns),r):Zr(t)?$n(Ct(e,t.items),r):tn(t)?Tn(Ct(e,t.items),r):Ke(t)?st(bo(e,t.allOf),r):le(t)?be(bo(e,t.anyOf),r):wt(t)?Pt(bo(e,t.items??[]),r):qe(t)?Ie(Xf(e,t.properties),r):Kt(t)?wn(Ct(e,t.items),r):rn(t)?ss(Ct(e,t.item),r):t}function Qf(e,t){let r={};for(let n of e)r[n]=Ct(n,t);return r}function ya(e,t,r){let n=Me(e)?mt(e):e,o=t({[O]:"MappedKey",keys:n}),s=Qf(n,o);return Ie(s,r)}function Tt(...e){let[t,r]=typeof e[0]==="string"?[e[0],e[1]]:[e[0].$id,e[1]];if(typeof t!=="string")throw new he("Ref: $ref must be a string");return I({[O]:"Ref",$ref:t},r)}function ga(e){let t=[];for(let r of e)t.push(Ft(r));return t}function Zf(e){let t=ga(e);return la(t)}function ed(e){let t=ga(e);return pa(t)}function td(e){return e.map((t,r)=>r.toString())}function rd(e){return["[number]"]}function nd(e){return globalThis.Object.getOwnPropertyNames(e)}function od(e){if(!Ws)return[];return globalThis.Object.getOwnPropertyNames(e).map((r)=>r[0]==="^"&&r[r.length-1]==="$"?r.slice(1,r.length-1):r)}function Ft(e){return Ke(e)?Zf(e.allOf):le(e)?ed(e.anyOf):wt(e)?td(e.items??[]):Kt(e)?rd(e.items):qe(e)?nd(e.properties):nn(e)?od(e.patternProperties):[]}var Ws=!1;function Ir(e){Ws=!0;let t=Ft(e);return Ws=!1,`^(${t.map((n)=>`(${n})`).join("|")})$`}function sd(e,t){return Pe("KeyOf",[Pe(e,t)])}function id(e){return Pe("KeyOf",[Tt(e)])}function ad(e,t){let r=Ft(e),n=ud(r),o=ur(n);return I(o,t)}function ud(e){return e.map((t)=>t==="[number]"?St():xe(t))}function Fn(e,t){return Bt(e)?sd(e.target,e.parameters):De(e)?id(e.$ref):Ne(e)?ha(e,t):ad(e,t)}function cd(e,t){let r={};for(let n of globalThis.Object.getOwnPropertyNames(e))r[n]=Fn(e[n],Fe(t));return r}function fd(e,t){return cd(e.properties,t)}function ha(e,t){let r=fd(e,t);return me(r)}function is(e){let t=Ft(e),r=xo(e,t);return t.map((n,o)=>[t[o],r[o]])}function dd(e){return e.allOf.every((t)=>_r(t))}function pd(e){return e.anyOf.some((t)=>_r(t))}function ld(e){return!_r(e.not)}function _r(e){return e[O]==="Intersect"?dd(e):e[O]==="Union"?pd(e):e[O]==="Not"?ld(e):e[O]==="Undefined"?!0:!1}function md(e){switch(e.errorType){case b.ArrayContains:return"Expected array to contain at least one matching value";case b.ArrayMaxContains:return`Expected array to contain no more than ${e.schema.maxContains} matching values`;case b.ArrayMinContains:return`Expected array to contain at least ${e.schema.minContains} matching values`;case b.ArrayMaxItems:return`Expected array length to be less or equal to ${e.schema.maxItems}`;case b.ArrayMinItems:return`Expected array length to be greater or equal to ${e.schema.minItems}`;case b.ArrayUniqueItems:return"Expected array elements to be unique";case b.Array:return"Expected array";case b.AsyncIterator:return"Expected AsyncIterator";case b.BigIntExclusiveMaximum:return`Expected bigint to be less than ${e.schema.exclusiveMaximum}`;case b.BigIntExclusiveMinimum:return`Expected bigint to be greater than ${e.schema.exclusiveMinimum}`;case b.BigIntMaximum:return`Expected bigint to be less or equal to ${e.schema.maximum}`;case b.BigIntMinimum:return`Expected bigint to be greater or equal to ${e.schema.minimum}`;case b.BigIntMultipleOf:return`Expected bigint to be a multiple of ${e.schema.multipleOf}`;case b.BigInt:return"Expected bigint";case b.Boolean:return"Expected boolean";case b.DateExclusiveMinimumTimestamp:return`Expected Date timestamp to be greater than ${e.schema.exclusiveMinimumTimestamp}`;case b.DateExclusiveMaximumTimestamp:return`Expected Date timestamp to be less than ${e.schema.exclusiveMaximumTimestamp}`;case b.DateMinimumTimestamp:return`Expected Date timestamp to be greater or equal to ${e.schema.minimumTimestamp}`;case b.DateMaximumTimestamp:return`Expected Date timestamp to be less or equal to ${e.schema.maximumTimestamp}`;case b.DateMultipleOfTimestamp:return`Expected Date timestamp to be a multiple of ${e.schema.multipleOfTimestamp}`;case b.Date:return"Expected Date";case b.Function:return"Expected function";case b.IntegerExclusiveMaximum:return`Expected integer to be less than ${e.schema.exclusiveMaximum}`;case b.IntegerExclusiveMinimum:return`Expected integer to be greater than ${e.schema.exclusiveMinimum}`;case b.IntegerMaximum:return`Expected integer to be less or equal to ${e.schema.maximum}`;case b.IntegerMinimum:return`Expected integer to be greater or equal to ${e.schema.minimum}`;case b.IntegerMultipleOf:return`Expected integer to be a multiple of ${e.schema.multipleOf}`;case b.Integer:return"Expected integer";case b.IntersectUnevaluatedProperties:return"Unexpected property";case b.Intersect:return"Expected all values to match";case b.Iterator:return"Expected Iterator";case b.Literal:return`Expected ${typeof e.schema.const==="string"?`'${e.schema.const}'`:e.schema.const}`;case b.Never:return"Never";case b.Not:return"Value should not match";case b.Null:return"Expected null";case b.NumberExclusiveMaximum:return`Expected number to be less than ${e.schema.exclusiveMaximum}`;case b.NumberExclusiveMinimum:return`Expected number to be greater than ${e.schema.exclusiveMinimum}`;case b.NumberMaximum:return`Expected number to be less or equal to ${e.schema.maximum}`;case b.NumberMinimum:return`Expected number to be greater or equal to ${e.schema.minimum}`;case b.NumberMultipleOf:return`Expected number to be a multiple of ${e.schema.multipleOf}`;case b.Number:return"Expected number";case b.Object:return"Expected object";case b.ObjectAdditionalProperties:return"Unexpected property";case b.ObjectMaxProperties:return`Expected object to have no more than ${e.schema.maxProperties} properties`;case b.ObjectMinProperties:return`Expected object to have at least ${e.schema.minProperties} properties`;case b.ObjectRequiredProperty:return"Expected required property";case b.Promise:return"Expected Promise";case b.RegExp:return"Expected string to match regular expression";case b.StringFormatUnknown:return`Unknown format '${e.schema.format}'`;case b.StringFormat:return`Expected string to match '${e.schema.format}' format`;case b.StringMaxLength:return`Expected string length less or equal to ${e.schema.maxLength}`;case b.StringMinLength:return`Expected string length greater or equal to ${e.schema.minLength}`;case b.StringPattern:return`Expected string to match '${e.schema.pattern}'`;case b.String:return"Expected string";case b.Symbol:return"Expected symbol";case b.TupleLength:return`Expected tuple to have ${e.schema.maxItems||0} elements`;case b.Tuple:return"Expected tuple";case b.Uint8ArrayMaxByteLength:return`Expected byte length less or equal to ${e.schema.maxByteLength}`;case b.Uint8ArrayMinByteLength:return`Expected byte length greater or equal to ${e.schema.minByteLength}`;case b.Uint8Array:return"Expected Uint8Array";case b.Undefined:return"Expected undefined";case b.Union:return"Expected union value";case b.Void:return"Expected void";case b.Kind:return`Expected kind '${e.schema[O]}'`;default:return"Unknown error type"}}var yd=md;function xa(){return yd}class ba extends he{constructor(e){super(`Unable to dereference schema with $id '${e.$ref}'`);this.schema=e}}function gd(e,t){let r=t.find((n)=>n.$id===e.$ref);if(r===void 0)throw new ba(e);return Xe(r,t)}function Mr(e,t){if(!Ye(e.$id)||t.some((r)=>r.$id===e.$id))return t;return t.push(e),t}function Xe(e,t){return e[O]==="This"||e[O]==="Ref"?gd(e,t):e}class Ia extends he{constructor(e){super("Unable to hash value");this.value=e}}var $t;(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"})($t||($t={}));var Nn=BigInt("14695981039346656037"),[hd,xd]=[BigInt("1099511628211"),BigInt("18446744073709551616")],bd=Array.from({length:256}).map((e,t)=>BigInt(t)),_a=new Float64Array(1),Ra=new DataView(_a.buffer),Oa=new Uint8Array(_a.buffer);function*Id(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 _d(e){it($t.Array);for(let t of e)jn(t)}function Rd(e){it($t.Boolean),it(e?1:0)}function Od(e){it($t.BigInt),Ra.setBigInt64(0,e);for(let t of Oa)it(t)}function wd(e){it($t.Date),jn(e.getTime())}function $d(e){it($t.Null)}function kd(e){it($t.Number),Ra.setFloat64(0,e);for(let t of Oa)it(t)}function Ad(e){it($t.Object);for(let t of globalThis.Object.getOwnPropertyNames(e).sort())jn(t),jn(e[t])}function Sd(e){it($t.String);for(let t=0;t<e.length;t++)for(let r of Id(e.charCodeAt(t)))it(r)}function Pd(e){it($t.Symbol),jn(e.description)}function Cd(e){it($t.Uint8Array);for(let t=0;t<e.length;t++)it(e[t])}function Td(e){return it($t.Undefined)}function jn(e){if(Ge(e))return _d(e);if(Yr(e))return Rd(e);if(bt(e))return Od(e);if(_n(e))return wd(e);if(Wr(e))return $d(e);if(X(e))return kd(e);if(pt(e))return Ad(e);if(Ye(e))return Sd(e);if(Xr(e))return Pd(e);if(Rn(e))return Cd(e);if(ft(e))return Td(e);throw new Ia(e)}function it(e){Nn=Nn^bd[e],Nn=Nn*hd%xd}function Mn(e){return Nn=BigInt("14695981039346656037"),jn(e),Nn}function Er(e){return I({[O]:"Any"},e)}function Lr(e){return I({[O]:"Unknown"},e)}var Fd=["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 wa(e){try{return new RegExp(e),!0}catch{return!1}}function Ys(e){if(!Ae(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 $a(e){return Xs(e)||Ee(e)}function Io(e){return Se(e)||Yo(e)}function Oe(e){return Se(e)||It(e)}function Xs(e){return Se(e)||Pr(e)}function _e(e){return Se(e)||Ae(e)}function Nd(e){return Se(e)||Ae(e)&&Ys(e)&&wa(e)}function jd(e){return Se(e)||Ae(e)&&Ys(e)}function ka(e){return Se(e)||Ee(e)}function as(e){return Te(e)&&e[et]==="Optional"}function zt(e){return pe(e,"Any")&&_e(e.$id)}function Md(e){return pe(e,"Argument")&&It(e.index)}function an(e){return pe(e,"Array")&&e.type==="array"&&_e(e.$id)&&Ee(e.items)&&Oe(e.minItems)&&Oe(e.maxItems)&&Xs(e.uniqueItems)&&ka(e.contains)&&Oe(e.minContains)&&Oe(e.maxContains)}function Qs(e){return pe(e,"AsyncIterator")&&e.type==="AsyncIterator"&&_e(e.$id)&&Ee(e.items)}function us(e){return pe(e,"BigInt")&&e.type==="bigint"&&_e(e.$id)&&Io(e.exclusiveMaximum)&&Io(e.exclusiveMinimum)&&Io(e.maximum)&&Io(e.minimum)&&Io(e.multipleOf)}function un(e){return pe(e,"Boolean")&&e.type==="boolean"&&_e(e.$id)}function Ed(e){return pe(e,"Computed")&&Ae(e.target)&&He(e.parameters)&&e.parameters.every((t)=>Ee(t))}function cs(e){return pe(e,"Constructor")&&e.type==="Constructor"&&_e(e.$id)&&He(e.parameters)&&e.parameters.every((t)=>Ee(t))&&Ee(e.returns)}function fs(e){return pe(e,"Date")&&e.type==="Date"&&_e(e.$id)&&Oe(e.exclusiveMaximumTimestamp)&&Oe(e.exclusiveMinimumTimestamp)&&Oe(e.maximumTimestamp)&&Oe(e.minimumTimestamp)&&Oe(e.multipleOfTimestamp)}function ds(e){return pe(e,"Function")&&e.type==="Function"&&_e(e.$id)&&He(e.parameters)&&e.parameters.every((t)=>Ee(t))&&Ee(e.returns)}function Rr(e){return pe(e,"Integer")&&e.type==="integer"&&_e(e.$id)&&Oe(e.exclusiveMaximum)&&Oe(e.exclusiveMinimum)&&Oe(e.maximum)&&Oe(e.minimum)&&Oe(e.multipleOf)}function Aa(e){return Te(e)&&Object.entries(e).every(([t,r])=>Ys(t)&&Ee(r))}function cn(e){return pe(e,"Intersect")&&(Ae(e.type)&&e.type!=="object"?!1:!0)&&He(e.allOf)&&e.allOf.every((t)=>Ee(t)&&!Dd(t))&&_e(e.type)&&(Xs(e.unevaluatedProperties)||ka(e.unevaluatedProperties))&&_e(e.$id)}function Zs(e){return pe(e,"Iterator")&&e.type==="Iterator"&&_e(e.$id)&&Ee(e.items)}function pe(e,t){return Te(e)&&O in e&&e[O]===t}function Sa(e){return Ur(e)&&Ae(e.const)}function Pa(e){return Ur(e)&&It(e.const)}function Ca(e){return Ur(e)&&Pr(e.const)}function Ur(e){return pe(e,"Literal")&&_e(e.$id)&&Ld(e.const)}function Ld(e){return Pr(e)||It(e)||Ae(e)}function Ud(e){return pe(e,"MappedKey")&&He(e.keys)&&e.keys.every((t)=>It(t)||Ae(t))}function Kd(e){return pe(e,"MappedResult")&&Aa(e.properties)}function Kr(e){return pe(e,"Never")&&Te(e.not)&&Object.getOwnPropertyNames(e.not).length===0}function En(e){return pe(e,"Not")&&Ee(e.not)}function ei(e){return pe(e,"Null")&&e.type==="null"&&_e(e.$id)}function gt(e){return pe(e,"Number")&&e.type==="number"&&_e(e.$id)&&Oe(e.exclusiveMaximum)&&Oe(e.exclusiveMinimum)&&Oe(e.maximum)&&Oe(e.minimum)&&Oe(e.multipleOf)}function Be(e){return pe(e,"Object")&&e.type==="object"&&_e(e.$id)&&Aa(e.properties)&&$a(e.additionalProperties)&&Oe(e.minProperties)&&Oe(e.maxProperties)}function ti(e){return pe(e,"Promise")&&e.type==="Promise"&&_e(e.$id)&&Ee(e.item)}function tt(e){return pe(e,"Record")&&e.type==="object"&&_e(e.$id)&&$a(e.additionalProperties)&&Te(e.patternProperties)&&((t)=>{let r=Object.getOwnPropertyNames(t.patternProperties);return r.length===1&&wa(r[0])&&Te(t.patternProperties)&&Ee(t.patternProperties[r[0]])})(e)}function Bd(e){return pe(e,"Ref")&&_e(e.$id)&&Ae(e.$ref)}function _o(e){return pe(e,"RegExp")&&_e(e.$id)&&Ae(e.source)&&Ae(e.flags)&&Oe(e.maxLength)&&Oe(e.minLength)}function Vt(e){return pe(e,"String")&&e.type==="string"&&_e(e.$id)&&Oe(e.minLength)&&Oe(e.maxLength)&&Nd(e.pattern)&&jd(e.format)}function Ro(e){return pe(e,"Symbol")&&e.type==="symbol"&&_e(e.$id)}function Oo(e){return pe(e,"TemplateLiteral")&&e.type==="string"&&Ae(e.pattern)&&e.pattern[0]==="^"&&e.pattern[e.pattern.length-1]==="$"}function vd(e){return pe(e,"This")&&_e(e.$id)&&Ae(e.$ref)}function Dd(e){return Te(e)&&je in e}function ps(e){return pe(e,"Tuple")&&e.type==="array"&&_e(e.$id)&&It(e.minItems)&&It(e.maxItems)&&e.minItems===e.maxItems&&(Se(e.items)&&Se(e.additionalItems)&&e.minItems===0||He(e.items)&&e.items.every((t)=>Ee(t)))}function fn(e){return pe(e,"Undefined")&&e.type==="undefined"&&_e(e.$id)}function Or(e){return pe(e,"Union")&&_e(e.$id)&&Te(e)&&He(e.anyOf)&&e.anyOf.every((t)=>Ee(t))}function wo(e){return pe(e,"Uint8Array")&&e.type==="Uint8Array"&&_e(e.$id)&&Oe(e.minByteLength)&&Oe(e.maxByteLength)}function Jt(e){return pe(e,"Unknown")&&_e(e.$id)}function qd(e){return pe(e,"Unsafe")}function ls(e){return pe(e,"Void")&&e.type==="void"&&_e(e.$id)}function Gd(e){return Te(e)&&O in e&&Ae(e[O])&&!Fd.includes(e[O])}function Ee(e){return Te(e)&&(zt(e)||Md(e)||an(e)||un(e)||us(e)||Qs(e)||Ed(e)||cs(e)||fs(e)||ds(e)||Rr(e)||cn(e)||Zs(e)||Ur(e)||Ud(e)||Kd(e)||Kr(e)||En(e)||ei(e)||gt(e)||Be(e)||ti(e)||tt(e)||Bd(e)||_o(e)||Vt(e)||Ro(e)||Oo(e)||vd(e)||ps(e)||fn(e)||Or(e)||wo(e)||Jt(e)||qd(e)||ls(e)||Gd(e))}class Ea extends he{}var _;(function(e){e[e.Union=0]="Union",e[e.True=1]="True",e[e.False=2]="False"})(_||(_={}));function Nt(e){return e===_.False?e:_.True}function Ln(e){throw new Ea(e)}function ze(e){return Kr(e)||cn(e)||Or(e)||Jt(e)||zt(e)}function Ve(e,t){return Kr(t)?Ka(e,t):cn(t)?ms(e,t):Or(t)?ii(e,t):Jt(t)?qa(e,t):zt(t)?si(e,t):Ln("StructuralRight")}function si(e,t){return _.True}function Hd(e,t){return cn(t)?ms(e,t):Or(t)&&t.anyOf.some((r)=>zt(r)||Jt(r))?_.True:Or(t)?_.Union:Jt(t)?_.True:zt(t)?_.True:_.Union}function zd(e,t){return Jt(e)?_.False:zt(e)?_.Union:Kr(e)?_.True:_.False}function Vd(e,t){return Be(t)&&ys(t)?_.True:ze(t)?Ve(e,t):!an(t)?_.False:Nt(Re(e.items,t.items))}function Jd(e,t){return ze(t)?Ve(e,t):!Qs(t)?_.False:Nt(Re(e.items,t.items))}function Wd(e,t){return ze(t)?Ve(e,t):Be(t)?at(e,t):tt(t)?jt(e,t):us(t)?_.True:_.False}function La(e,t){return Ca(e)?_.True:un(e)?_.True:_.False}function Yd(e,t){return ze(t)?Ve(e,t):Be(t)?at(e,t):tt(t)?jt(e,t):un(t)?_.True:_.False}function Xd(e,t){return ze(t)?Ve(e,t):Be(t)?at(e,t):!cs(t)?_.False:e.parameters.length>t.parameters.length?_.False:!e.parameters.every((r,n)=>Nt(Re(t.parameters[n],r))===_.True)?_.False:Nt(Re(e.returns,t.returns))}function Qd(e,t){return ze(t)?Ve(e,t):Be(t)?at(e,t):tt(t)?jt(e,t):fs(t)?_.True:_.False}function Zd(e,t){return ze(t)?Ve(e,t):Be(t)?at(e,t):!ds(t)?_.False:e.parameters.length>t.parameters.length?_.False:!e.parameters.every((r,n)=>Nt(Re(t.parameters[n],r))===_.True)?_.False:Nt(Re(e.returns,t.returns))}function Ua(e,t){return Ur(e)&&It(e.const)?_.True:gt(e)||Rr(e)?_.True:_.False}function ep(e,t){return Rr(t)||gt(t)?_.True:ze(t)?Ve(e,t):Be(t)?at(e,t):tt(t)?jt(e,t):_.False}function ms(e,t){return t.allOf.every((r)=>Re(e,r)===_.True)?_.True:_.False}function tp(e,t){return e.allOf.some((r)=>Re(r,t)===_.True)?_.True:_.False}function rp(e,t){return ze(t)?Ve(e,t):!Zs(t)?_.False:Nt(Re(e.items,t.items))}function np(e,t){return Ur(t)&&t.const===e.const?_.True:ze(t)?Ve(e,t):Be(t)?at(e,t):tt(t)?jt(e,t):Vt(t)?Da(e,t):gt(t)?Ba(e,t):Rr(t)?Ua(e,t):un(t)?La(e,t):_.False}function Ka(e,t){return _.False}function op(e,t){return _.True}function Fa(e){let[t,r]=[e,0];while(!0){if(!En(t))break;t=t.not,r+=1}return r%2===0?t:Lr()}function sp(e,t){return En(e)?Re(Fa(e),t):En(t)?Re(e,Fa(t)):Ln("Invalid fallthrough for Not")}function ip(e,t){return ze(t)?Ve(e,t):Be(t)?at(e,t):tt(t)?jt(e,t):ei(t)?_.True:_.False}function Ba(e,t){return Pa(e)?_.True:gt(e)||Rr(e)?_.True:_.False}function ap(e,t){return ze(t)?Ve(e,t):Be(t)?at(e,t):tt(t)?jt(e,t):Rr(t)||gt(t)?_.True:_.False}function ht(e,t){return Object.getOwnPropertyNames(e.properties).length===t}function Na(e){return ys(e)}function ja(e){return ht(e,0)||ht(e,1)&&"description"in e.properties&&Or(e.properties.description)&&e.properties.description.anyOf.length===2&&(Vt(e.properties.description.anyOf[0])&&fn(e.properties.description.anyOf[1])||Vt(e.properties.description.anyOf[1])&&fn(e.properties.description.anyOf[0]))}function ri(e){return ht(e,0)}function Ma(e){return ht(e,0)}function up(e){return ht(e,0)}function cp(e){return ht(e,0)}function fp(e){return ys(e)}function dp(e){let t=St();return ht(e,0)||ht(e,1)&&"length"in e.properties&&Nt(Re(e.properties.length,t))===_.True}function pp(e){return ht(e,0)}function ys(e){let t=St();return ht(e,0)||ht(e,1)&&"length"in e.properties&&Nt(Re(e.properties.length,t))===_.True}function lp(e){let t=ar([Er()],Er());return ht(e,0)||ht(e,1)&&"then"in e.properties&&Nt(Re(e.properties.then,t))===_.True}function va(e,t){return Re(e,t)===_.False?_.False:as(e)&&!as(t)?_.False:_.True}function at(e,t){return Jt(e)?_.False:zt(e)?_.Union:Kr(e)||Sa(e)&&Na(t)||Pa(e)&&ri(t)||Ca(e)&&Ma(t)||Ro(e)&&ja(t)||us(e)&&up(t)||Vt(e)&&Na(t)||Ro(e)&&ja(t)||gt(e)&&ri(t)||Rr(e)&&ri(t)||un(e)&&Ma(t)||wo(e)&&fp(t)||fs(e)&&cp(t)||cs(e)&&pp(t)||ds(e)&&dp(t)?_.True:tt(e)&&Vt(ni(e))?(()=>t[ir]==="Record"?_.True:_.False)():tt(e)&&gt(ni(e))?(()=>ht(t,0)?_.True:_.False)():_.False}function mp(e,t){return ze(t)?Ve(e,t):tt(t)?jt(e,t):!Be(t)?_.False:(()=>{for(let r of Object.getOwnPropertyNames(t.properties)){if(!(r in e.properties)&&!as(t.properties[r]))return _.False;if(as(t.properties[r]))return _.True;if(va(e.properties[r],t.properties[r])===_.False)return _.False}return _.True})()}function yp(e,t){return ze(t)?Ve(e,t):Be(t)&&lp(t)?_.True:!ti(t)?_.False:Nt(Re(e.item,t.item))}function ni(e){return Fr in e.patternProperties?St():(Nr in e.patternProperties)?Ht():Ln("Unknown record key pattern")}function oi(e){return Fr in e.patternProperties?e.patternProperties[Fr]:(Nr in e.patternProperties)?e.patternProperties[Nr]:Ln("Unable to get record value schema")}function jt(e,t){let[r,n]=[ni(t),oi(t)];return Sa(e)&&gt(r)&&Nt(Re(e,n))===_.True?_.True:wo(e)&&gt(r)?Re(e,n):Vt(e)&&gt(r)?Re(e,n):an(e)&&gt(r)?Re(e,n):Be(e)?(()=>{for(let o of Object.getOwnPropertyNames(e.properties))if(va(n,e.properties[o])===_.False)return _.False;return _.True})():_.False}function gp(e,t){return ze(t)?Ve(e,t):Be(t)?at(e,t):!tt(t)?_.False:Re(oi(e),oi(t))}function hp(e,t){let r=_o(e)?Ht():e,n=_o(t)?Ht():t;return Re(r,n)}function Da(e,t){return Ur(e)&&Ae(e.const)?_.True:Vt(e)?_.True:_.False}function xp(e,t){return ze(t)?Ve(e,t):Be(t)?at(e,t):tt(t)?jt(e,t):Vt(t)?_.True:_.False}function bp(e,t){return ze(t)?Ve(e,t):Be(t)?at(e,t):tt(t)?jt(e,t):Ro(t)?_.True:_.False}function Ip(e,t){return Oo(e)?Re(sn(e),t):Oo(t)?Re(e,sn(t)):Ln("Invalid fallthrough for TemplateLiteral")}function _p(e,t){return an(t)&&e.items!==void 0&&e.items.every((r)=>Re(r,t.items)===_.True)}function Rp(e,t){return Kr(e)?_.True:Jt(e)?_.False:zt(e)?_.Union:_.False}function Op(e,t){return ze(t)?Ve(e,t):Be(t)&&ys(t)?_.True:an(t)&&_p(e,t)?_.True:!ps(t)?_.False:Se(e.items)&&!Se(t.items)||!Se(e.items)&&Se(t.items)?_.False:Se(e.items)&&!Se(t.items)?_.True:e.items.every((r,n)=>Re(r,t.items[n])===_.True)?_.True:_.False}function wp(e,t){return ze(t)?Ve(e,t):Be(t)?at(e,t):tt(t)?jt(e,t):wo(t)?_.True:_.False}function $p(e,t){return ze(t)?Ve(e,t):Be(t)?at(e,t):tt(t)?jt(e,t):ls(t)?Sp(e,t):fn(t)?_.True:_.False}function ii(e,t){return t.anyOf.some((r)=>Re(e,r)===_.True)?_.True:_.False}function kp(e,t){return e.anyOf.every((r)=>Re(r,t)===_.True)?_.True:_.False}function qa(e,t){return _.True}function Ap(e,t){return Kr(t)?Ka(e,t):cn(t)?ms(e,t):Or(t)?ii(e,t):zt(t)?si(e,t):Vt(t)?Da(e,t):gt(t)?Ba(e,t):Rr(t)?Ua(e,t):un(t)?La(e,t):an(t)?zd(e,t):ps(t)?Rp(e,t):Be(t)?at(e,t):Jt(t)?_.True:_.False}function Sp(e,t){return fn(e)?_.True:fn(e)?_.True:_.False}function Pp(e,t){return cn(t)?ms(e,t):Or(t)?ii(e,t):Jt(t)?qa(e,t):zt(t)?si(e,t):Be(t)?at(e,t):ls(t)?_.True:_.False}function Re(e,t){return Oo(e)||Oo(t)?Ip(e,t):_o(e)||_o(t)?hp(e,t):En(e)||En(t)?sp(e,t):zt(e)?Hd(e,t):an(e)?Vd(e,t):us(e)?Wd(e,t):un(e)?Yd(e,t):Qs(e)?Jd(e,t):cs(e)?Xd(e,t):fs(e)?Qd(e,t):ds(e)?Zd(e,t):Rr(e)?ep(e,t):cn(e)?tp(e,t):Zs(e)?rp(e,t):Ur(e)?np(e,t):Kr(e)?op(e,t):ei(e)?ip(e,t):gt(e)?ap(e,t):Be(e)?mp(e,t):tt(e)?gp(e,t):Vt(e)?xp(e,t):Ro(e)?bp(e,t):ps(e)?Op(e,t):ti(e)?yp(e,t):wo(e)?wp(e,t):fn(e)?$p(e,t):Or(e)?kp(e,t):Jt(e)?Ap(e,t):ls(e)?Pp(e,t):Ln(`Unknown left type operand '${e[O]}'`)}function Br(e,t){return Re(e,t)}function Cp(e,t,r,n,o){let s={};for(let i of globalThis.Object.getOwnPropertyNames(e))s[i]=Un(e[i],t,r,n,Fe(o));return s}function Tp(e,t,r,n,o){return Cp(e.properties,t,r,n,o)}function Ga(e,t,r,n,o){let s=Tp(e,t,r,n,o);return me(s)}function Fp(e,t,r,n){let o=Br(e,t);return o===_.Union?be([r,n]):o===_.True?r:n}function Un(e,t,r,n,o){return Ne(e)?Ga(e,t,r,n,o):Rt(e)?I(Ha(e,t,r,n,o)):I(Fp(e,t,r,n),o)}function Np(e,t,r,n,o){return{[e]:Un(xe(e),t,r,n,Fe(o))}}function jp(e,t,r,n,o){return e.reduce((s,i)=>({...s,...Np(i,t,r,n,o)}),{})}function Mp(e,t,r,n,o){return jp(e.keys,t,r,n,o)}function Ha(e,t,r,n,o){let s=Mp(e,t,r,n,o);return me(s)}class za extends he{constructor(e){super("Unknown type");this.schema=e}}function Ep(e){return e[O]==="Any"||e[O]==="Unknown"}function ue(e){return e!==void 0}function Lp(e,t,r){return!0}function Up(e,t,r){return!0}function Kp(e,t,r){if(!Ge(r))return!1;if(ue(e.minItems)&&!(r.length>=e.minItems))return!1;if(ue(e.maxItems)&&!(r.length<=e.maxItems))return!1;if(!r.every((s)=>Qe(e.items,t,s)))return!1;if(e.uniqueItems===!0&&!function(){let s=new Set;for(let i of r){let a=Mn(i);if(s.has(a))return!1;else s.add(a)}return!0}())return!1;if(!(ue(e.contains)||X(e.minContains)||X(e.maxContains)))return!0;let n=ue(e.contains)?e.contains:ne(),o=r.reduce((s,i)=>Qe(n,t,i)?s+1:s,0);if(o===0)return!1;if(X(e.minContains)&&o<e.minContains)return!1;if(X(e.maxContains)&&o>e.maxContains)return!1;return!0}function Bp(e,t,r){return vo(r)}function vp(e,t,r){if(!bt(r))return!1;if(ue(e.exclusiveMaximum)&&!(r<e.exclusiveMaximum))return!1;if(ue(e.exclusiveMinimum)&&!(r>e.exclusiveMinimum))return!1;if(ue(e.maximum)&&!(r<=e.maximum))return!1;if(ue(e.minimum)&&!(r>=e.minimum))return!1;if(ue(e.multipleOf)&&r%e.multipleOf!==BigInt(0))return!1;return!0}function Dp(e,t,r){return Yr(r)}function qp(e,t,r){return Qe(e.returns,t,r.prototype)}function Gp(e,t,r){if(!_n(r))return!1;if(ue(e.exclusiveMaximumTimestamp)&&!(r.getTime()<e.exclusiveMaximumTimestamp))return!1;if(ue(e.exclusiveMinimumTimestamp)&&!(r.getTime()>e.exclusiveMinimumTimestamp))return!1;if(ue(e.maximumTimestamp)&&!(r.getTime()<=e.maximumTimestamp))return!1;if(ue(e.minimumTimestamp)&&!(r.getTime()>=e.minimumTimestamp))return!1;if(ue(e.multipleOfTimestamp)&&r.getTime()%e.multipleOfTimestamp!==0)return!1;return!0}function Hp(e,t,r){return zo(r)}function zp(e,t,r){let n=globalThis.Object.values(e.$defs),o=e.$defs[e.$ref];return Qe(o,[...t,...n],r)}function Vp(e,t,r){if(!Ho(r))return!1;if(ue(e.exclusiveMaximum)&&!(r<e.exclusiveMaximum))return!1;if(ue(e.exclusiveMinimum)&&!(r>e.exclusiveMinimum))return!1;if(ue(e.maximum)&&!(r<=e.maximum))return!1;if(ue(e.minimum)&&!(r>=e.minimum))return!1;if(ue(e.multipleOf)&&r%e.multipleOf!==0)return!1;return!0}function Jp(e,t,r){let n=e.allOf.every((o)=>Qe(o,t,r));if(e.unevaluatedProperties===!1){let o=new RegExp(Ir(e)),s=Object.getOwnPropertyNames(r).every((i)=>o.test(i));return n&&s}else if(Me(e.unevaluatedProperties)){let o=new RegExp(Ir(e)),s=Object.getOwnPropertyNames(r).every((i)=>o.test(i)||Qe(e.unevaluatedProperties,t,r[i]));return n&&s}else return n}function Wp(e,t,r){return Do(r)}function Yp(e,t,r){return r===e.const}function Xp(e,t,r){return!1}function Qp(e,t,r){return!Qe(e.not,t,r)}function Zp(e,t,r){return Wr(r)}function el(e,t,r){if(!ke.IsNumberLike(r))return!1;if(ue(e.exclusiveMaximum)&&!(r<e.exclusiveMaximum))return!1;if(ue(e.exclusiveMinimum)&&!(r>e.exclusiveMinimum))return!1;if(ue(e.minimum)&&!(r>=e.minimum))return!1;if(ue(e.maximum)&&!(r<=e.maximum))return!1;if(ue(e.multipleOf)&&r%e.multipleOf!==0)return!1;return!0}function tl(e,t,r){if(!ke.IsObjectLike(r))return!1;if(ue(e.minProperties)&&!(Object.getOwnPropertyNames(r).length>=e.minProperties))return!1;if(ue(e.maxProperties)&&!(Object.getOwnPropertyNames(r).length<=e.maxProperties))return!1;let n=Object.getOwnPropertyNames(e.properties);for(let o of n){let s=e.properties[o];if(e.required&&e.required.includes(o)){if(!Qe(s,t,r[o]))return!1;if((_r(s)||Ep(s))&&!(o in r))return!1}else if(ke.IsExactOptionalProperty(r,o)&&!Qe(s,t,r[o]))return!1}if(e.additionalProperties===!1){let o=Object.getOwnPropertyNames(r);if(e.required&&e.required.length===n.length&&o.length===n.length)return!0;else return o.every((s)=>n.includes(s))}else if(typeof e.additionalProperties==="object")return Object.getOwnPropertyNames(r).every((s)=>n.includes(s)||Qe(e.additionalProperties,t,r[s]));else return!0}function rl(e,t,r){return qo(r)}function nl(e,t,r){if(!ke.IsRecordLike(r))return!1;if(ue(e.minProperties)&&!(Object.getOwnPropertyNames(r).length>=e.minProperties))return!1;if(ue(e.maxProperties)&&!(Object.getOwnPropertyNames(r).length<=e.maxProperties))return!1;let[n,o]=Object.entries(e.patternProperties)[0],s=new RegExp(n),i=Object.entries(r).every(([c,f])=>s.test(c)?Qe(o,t,f):!0),a=typeof e.additionalProperties==="object"?Object.entries(r).every(([c,f])=>!s.test(c)?Qe(e.additionalProperties,t,f):!0):!0,u=e.additionalProperties===!1?Object.getOwnPropertyNames(r).every((c)=>s.test(c)):!0;return i&&a&&u}function ol(e,t,r){return Qe(Xe(e,t),t,r)}function sl(e,t,r){let n=new RegExp(e.source,e.flags);if(ue(e.minLength)){if(!(r.length>=e.minLength))return!1}if(ue(e.maxLength)){if(!(r.length<=e.maxLength))return!1}return n.test(r)}function il(e,t,r){if(!Ye(r))return!1;if(ue(e.minLength)){if(!(r.length>=e.minLength))return!1}if(ue(e.maxLength)){if(!(r.length<=e.maxLength))return!1}if(ue(e.pattern)){if(!new RegExp(e.pattern).test(r))return!1}if(ue(e.format)){if(!Ks(e.format))return!1;return Bs(e.format)(r)}return!0}function al(e,t,r){return Xr(r)}function ul(e,t,r){return Ye(r)&&new RegExp(e.pattern).test(r)}function cl(e,t,r){return Qe(Xe(e,t),t,r)}function fl(e,t,r){if(!Ge(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(!Qe(e.items[n],t,r[n]))return!1;return!0}function dl(e,t,r){return ft(r)}function pl(e,t,r){return e.anyOf.some((n)=>Qe(n,t,r))}function ll(e,t,r){if(!Rn(r))return!1;if(ue(e.maxByteLength)&&!(r.length<=e.maxByteLength))return!1;if(ue(e.minByteLength)&&!(r.length>=e.minByteLength))return!1;return!0}function ml(e,t,r){return!0}function yl(e,t,r){return ke.IsVoidLike(r)}function gl(e,t,r){if(!co(e[O]))return!1;return vs(e[O])(e,r)}function Qe(e,t,r){let n=ue(e.$id)?Mr(e,t):t,o=e;switch(o[O]){case"Any":return Lp(o,n,r);case"Argument":return Up(o,n,r);case"Array":return Kp(o,n,r);case"AsyncIterator":return Bp(o,n,r);case"BigInt":return vp(o,n,r);case"Boolean":return Dp(o,n,r);case"Constructor":return qp(o,n,r);case"Date":return Gp(o,n,r);case"Function":return Hp(o,n,r);case"Import":return zp(o,n,r);case"Integer":return Vp(o,n,r);case"Intersect":return Jp(o,n,r);case"Iterator":return Wp(o,n,r);case"Literal":return Yp(o,n,r);case"Never":return Xp(o,n,r);case"Not":return Qp(o,n,r);case"Null":return Zp(o,n,r);case"Number":return el(o,n,r);case"Object":return tl(o,n,r);case"Promise":return rl(o,n,r);case"Record":return nl(o,n,r);case"Ref":return ol(o,n,r);case"RegExp":return sl(o,n,r);case"String":return il(o,n,r);case"Symbol":return al(o,n,r);case"TemplateLiteral":return ul(o,n,r);case"This":return cl(o,n,r);case"Tuple":return fl(o,n,r);case"Undefined":return dl(o,n,r);case"Union":return pl(o,n,r);case"Uint8Array":return ll(o,n,r);case"Unknown":return ml(o,n,r);case"Void":return yl(o,n,r);default:if(!co(o[O]))throw new za(o);return gl(o,n,r)}}function dn(...e){return e.length===3?Qe(e[0],e[1],e[2]):Qe(e[0],[],e[1])}var b;(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"})(b||(b={}));class Va extends he{constructor(e){super("Unknown type");this.schema=e}}function wr(e){return e.replace(/~/g,"~0").replace(/\//g,"~1")}function ce(e){return e!==void 0}class ai{constructor(e){this.iterator=e}[Symbol.iterator](){return this.iterator}First(){let e=this.iterator.next();return e.done?void 0:e.value}}function N(e,t,r,n,o=[]){return{type:e,schema:t,path:r,value:n,message:xa()({errorType:e,path:r,schema:t,value:n,errors:o}),errors:o}}function*hl(e,t,r,n){}function*xl(e,t,r,n){}function*bl(e,t,r,n){if(!Ge(n))return yield N(b.Array,e,r,n);if(ce(e.minItems)&&!(n.length>=e.minItems))yield N(b.ArrayMinItems,e,r,n);if(ce(e.maxItems)&&!(n.length<=e.maxItems))yield N(b.ArrayMaxItems,e,r,n);for(let i=0;i<n.length;i++)yield*Ze(e.items,t,`${r}/${i}`,n[i]);if(e.uniqueItems===!0&&!function(){let i=new Set;for(let a of n){let u=Mn(a);if(i.has(u))return!1;else i.add(u)}return!0}())yield N(b.ArrayUniqueItems,e,r,n);if(!(ce(e.contains)||ce(e.minContains)||ce(e.maxContains)))return;let o=ce(e.contains)?e.contains:ne(),s=n.reduce((i,a,u)=>Ze(o,t,`${r}${u}`,a).next().done===!0?i+1:i,0);if(s===0)yield N(b.ArrayContains,e,r,n);if(X(e.minContains)&&s<e.minContains)yield N(b.ArrayMinContains,e,r,n);if(X(e.maxContains)&&s>e.maxContains)yield N(b.ArrayMaxContains,e,r,n)}function*Il(e,t,r,n){if(!vo(n))yield N(b.AsyncIterator,e,r,n)}function*_l(e,t,r,n){if(!bt(n))return yield N(b.BigInt,e,r,n);if(ce(e.exclusiveMaximum)&&!(n<e.exclusiveMaximum))yield N(b.BigIntExclusiveMaximum,e,r,n);if(ce(e.exclusiveMinimum)&&!(n>e.exclusiveMinimum))yield N(b.BigIntExclusiveMinimum,e,r,n);if(ce(e.maximum)&&!(n<=e.maximum))yield N(b.BigIntMaximum,e,r,n);if(ce(e.minimum)&&!(n>=e.minimum))yield N(b.BigIntMinimum,e,r,n);if(ce(e.multipleOf)&&n%e.multipleOf!==BigInt(0))yield N(b.BigIntMultipleOf,e,r,n)}function*Rl(e,t,r,n){if(!Yr(n))yield N(b.Boolean,e,r,n)}function*Ol(e,t,r,n){yield*Ze(e.returns,t,r,n.prototype)}function*wl(e,t,r,n){if(!_n(n))return yield N(b.Date,e,r,n);if(ce(e.exclusiveMaximumTimestamp)&&!(n.getTime()<e.exclusiveMaximumTimestamp))yield N(b.DateExclusiveMaximumTimestamp,e,r,n);if(ce(e.exclusiveMinimumTimestamp)&&!(n.getTime()>e.exclusiveMinimumTimestamp))yield N(b.DateExclusiveMinimumTimestamp,e,r,n);if(ce(e.maximumTimestamp)&&!(n.getTime()<=e.maximumTimestamp))yield N(b.DateMaximumTimestamp,e,r,n);if(ce(e.minimumTimestamp)&&!(n.getTime()>=e.minimumTimestamp))yield N(b.DateMinimumTimestamp,e,r,n);if(ce(e.multipleOfTimestamp)&&n.getTime()%e.multipleOfTimestamp!==0)yield N(b.DateMultipleOfTimestamp,e,r,n)}function*$l(e,t,r,n){if(!zo(n))yield N(b.Function,e,r,n)}function*kl(e,t,r,n){let o=globalThis.Object.values(e.$defs),s=e.$defs[e.$ref];yield*Ze(s,[...t,...o],r,n)}function*Al(e,t,r,n){if(!Ho(n))return yield N(b.Integer,e,r,n);if(ce(e.exclusiveMaximum)&&!(n<e.exclusiveMaximum))yield N(b.IntegerExclusiveMaximum,e,r,n);if(ce(e.exclusiveMinimum)&&!(n>e.exclusiveMinimum))yield N(b.IntegerExclusiveMinimum,e,r,n);if(ce(e.maximum)&&!(n<=e.maximum))yield N(b.IntegerMaximum,e,r,n);if(ce(e.minimum)&&!(n>=e.minimum))yield N(b.IntegerMinimum,e,r,n);if(ce(e.multipleOf)&&n%e.multipleOf!==0)yield N(b.IntegerMultipleOf,e,r,n)}function*Sl(e,t,r,n){let o=!1;for(let s of e.allOf)for(let i of Ze(s,t,r,n))o=!0,yield i;if(o)return yield N(b.Intersect,e,r,n);if(e.unevaluatedProperties===!1){let s=new RegExp(Ir(e));for(let i of Object.getOwnPropertyNames(n))if(!s.test(i))yield N(b.IntersectUnevaluatedProperties,e,`${r}/${i}`,n)}if(typeof e.unevaluatedProperties==="object"){let s=new RegExp(Ir(e));for(let i of Object.getOwnPropertyNames(n))if(!s.test(i)){let a=Ze(e.unevaluatedProperties,t,`${r}/${i}`,n[i]).next();if(!a.done)yield a.value}}}function*Pl(e,t,r,n){if(!Do(n))yield N(b.Iterator,e,r,n)}function*Cl(e,t,r,n){if(n!==e.const)yield N(b.Literal,e,r,n)}function*Tl(e,t,r,n){yield N(b.Never,e,r,n)}function*Fl(e,t,r,n){if(Ze(e.not,t,r,n).next().done===!0)yield N(b.Not,e,r,n)}function*Nl(e,t,r,n){if(!Wr(n))yield N(b.Null,e,r,n)}function*jl(e,t,r,n){if(!ke.IsNumberLike(n))return yield N(b.Number,e,r,n);if(ce(e.exclusiveMaximum)&&!(n<e.exclusiveMaximum))yield N(b.NumberExclusiveMaximum,e,r,n);if(ce(e.exclusiveMinimum)&&!(n>e.exclusiveMinimum))yield N(b.NumberExclusiveMinimum,e,r,n);if(ce(e.maximum)&&!(n<=e.maximum))yield N(b.NumberMaximum,e,r,n);if(ce(e.minimum)&&!(n>=e.minimum))yield N(b.NumberMinimum,e,r,n);if(ce(e.multipleOf)&&n%e.multipleOf!==0)yield N(b.NumberMultipleOf,e,r,n)}function*Ml(e,t,r,n){if(!ke.IsObjectLike(n))return yield N(b.Object,e,r,n);if(ce(e.minProperties)&&!(Object.getOwnPropertyNames(n).length>=e.minProperties))yield N(b.ObjectMinProperties,e,r,n);if(ce(e.maxProperties)&&!(Object.getOwnPropertyNames(n).length<=e.maxProperties))yield N(b.ObjectMaxProperties,e,r,n);let o=Array.isArray(e.required)?e.required:[],s=Object.getOwnPropertyNames(e.properties),i=Object.getOwnPropertyNames(n);for(let a of o){if(i.includes(a))continue;yield N(b.ObjectRequiredProperty,e.properties[a],`${r}/${wr(a)}`,void 0)}if(e.additionalProperties===!1){for(let a of i)if(!s.includes(a))yield N(b.ObjectAdditionalProperties,e,`${r}/${wr(a)}`,n[a])}if(typeof e.additionalProperties==="object")for(let a of i){if(s.includes(a))continue;yield*Ze(e.additionalProperties,t,`${r}/${wr(a)}`,n[a])}for(let a of s){let u=e.properties[a];if(e.required&&e.required.includes(a)){if(yield*Ze(u,t,`${r}/${wr(a)}`,n[a]),_r(e)&&!(a in n))yield N(b.ObjectRequiredProperty,u,`${r}/${wr(a)}`,void 0)}else if(ke.IsExactOptionalProperty(n,a))yield*Ze(u,t,`${r}/${wr(a)}`,n[a])}}function*El(e,t,r,n){if(!qo(n))yield N(b.Promise,e,r,n)}function*Ll(e,t,r,n){if(!ke.IsRecordLike(n))return yield N(b.Object,e,r,n);if(ce(e.minProperties)&&!(Object.getOwnPropertyNames(n).length>=e.minProperties))yield N(b.ObjectMinProperties,e,r,n);if(ce(e.maxProperties)&&!(Object.getOwnPropertyNames(n).length<=e.maxProperties))yield N(b.ObjectMaxProperties,e,r,n);let[o,s]=Object.entries(e.patternProperties)[0],i=new RegExp(o);for(let[a,u]of Object.entries(n))if(i.test(a))yield*Ze(s,t,`${r}/${wr(a)}`,u);if(typeof e.additionalProperties==="object"){for(let[a,u]of Object.entries(n))if(!i.test(a))yield*Ze(e.additionalProperties,t,`${r}/${wr(a)}`,u)}if(e.additionalProperties===!1)for(let[a,u]of Object.entries(n)){if(i.test(a))continue;return yield N(b.ObjectAdditionalProperties,e,`${r}/${wr(a)}`,u)}}function*Ul(e,t,r,n){yield*Ze(Xe(e,t),t,r,n)}function*Kl(e,t,r,n){if(!Ye(n))return yield N(b.String,e,r,n);if(ce(e.minLength)&&!(n.length>=e.minLength))yield N(b.StringMinLength,e,r,n);if(ce(e.maxLength)&&!(n.length<=e.maxLength))yield N(b.StringMaxLength,e,r,n);if(!new RegExp(e.source,e.flags).test(n))return yield N(b.RegExp,e,r,n)}function*Bl(e,t,r,n){if(!Ye(n))return yield N(b.String,e,r,n);if(ce(e.minLength)&&!(n.length>=e.minLength))yield N(b.StringMinLength,e,r,n);if(ce(e.maxLength)&&!(n.length<=e.maxLength))yield N(b.StringMaxLength,e,r,n);if(Ye(e.pattern)){if(!new RegExp(e.pattern).test(n))yield N(b.StringPattern,e,r,n)}if(Ye(e.format)){if(!Ks(e.format))yield N(b.StringFormatUnknown,e,r,n);else if(!Bs(e.format)(n))yield N(b.StringFormat,e,r,n)}}function*vl(e,t,r,n){if(!Xr(n))yield N(b.Symbol,e,r,n)}function*Dl(e,t,r,n){if(!Ye(n))return yield N(b.String,e,r,n);if(!new RegExp(e.pattern).test(n))yield N(b.StringPattern,e,r,n)}function*ql(e,t,r,n){yield*Ze(Xe(e,t),t,r,n)}function*Gl(e,t,r,n){if(!Ge(n))return yield N(b.Tuple,e,r,n);if(e.items===void 0&&n.length!==0)return yield N(b.TupleLength,e,r,n);if(n.length!==e.maxItems)return yield N(b.TupleLength,e,r,n);if(!e.items)return;for(let o=0;o<e.items.length;o++)yield*Ze(e.items[o],t,`${r}/${o}`,n[o])}function*Hl(e,t,r,n){if(!ft(n))yield N(b.Undefined,e,r,n)}function*zl(e,t,r,n){if(dn(e,t,n))return;let o=e.anyOf.map((s)=>new ai(Ze(s,t,r,n)));yield N(b.Union,e,r,n,o)}function*Vl(e,t,r,n){if(!Rn(n))return yield N(b.Uint8Array,e,r,n);if(ce(e.maxByteLength)&&!(n.length<=e.maxByteLength))yield N(b.Uint8ArrayMaxByteLength,e,r,n);if(ce(e.minByteLength)&&!(n.length>=e.minByteLength))yield N(b.Uint8ArrayMinByteLength,e,r,n)}function*Jl(e,t,r,n){}function*Wl(e,t,r,n){if(!ke.IsVoidLike(n))yield N(b.Void,e,r,n)}function*Yl(e,t,r,n){if(!vs(e[O])(e,n))yield N(b.Kind,e,r,n)}function*Ze(e,t,r,n){let o=ce(e.$id)?[...t,e]:t,s=e;switch(s[O]){case"Any":return yield*hl(s,o,r,n);case"Argument":return yield*xl(s,o,r,n);case"Array":return yield*bl(s,o,r,n);case"AsyncIterator":return yield*Il(s,o,r,n);case"BigInt":return yield*_l(s,o,r,n);case"Boolean":return yield*Rl(s,o,r,n);case"Constructor":return yield*Ol(s,o,r,n);case"Date":return yield*wl(s,o,r,n);case"Function":return yield*$l(s,o,r,n);case"Import":return yield*kl(s,o,r,n);case"Integer":return yield*Al(s,o,r,n);case"Intersect":return yield*Sl(s,o,r,n);case"Iterator":return yield*Pl(s,o,r,n);case"Literal":return yield*Cl(s,o,r,n);case"Never":return yield*Tl(s,o,r,n);case"Not":return yield*Fl(s,o,r,n);case"Null":return yield*Nl(s,o,r,n);case"Number":return yield*jl(s,o,r,n);case"Object":return yield*Ml(s,o,r,n);case"Promise":return yield*El(s,o,r,n);case"Record":return yield*Ll(s,o,r,n);case"Ref":return yield*Ul(s,o,r,n);case"RegExp":return yield*Kl(s,o,r,n);case"String":return yield*Bl(s,o,r,n);case"Symbol":return yield*vl(s,o,r,n);case"TemplateLiteral":return yield*Dl(s,o,r,n);case"This":return yield*ql(s,o,r,n);case"Tuple":return yield*Gl(s,o,r,n);case"Undefined":return yield*Hl(s,o,r,n);case"Union":return yield*zl(s,o,r,n);case"Uint8Array":return yield*Vl(s,o,r,n);case"Unknown":return yield*Jl(s,o,r,n);case"Void":return yield*Wl(s,o,r,n);default:if(!co(s[O]))throw new Va(e);return yield*Yl(s,o,r,n)}}function Ja(...e){let t=e.length===3?Ze(e[0],e[1],"",e[2]):Ze(e[0],[],"",e[1]);return new ai(t)}class ui extends he{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 Wa extends he{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 ye(e)?e[je].Decode(r):r}catch(n){throw new Wa(e,t,r,n)}}function Xl(e,t,r,n){return Ge(n)?Le(e,r,n.map((o,s)=>Wt(e.items,t,`${r}/${s}`,o))):Le(e,r,n)}function Ql(e,t,r,n){if(!pt(n)||Vo(n))return Le(e,r,n);let o=is(e),s=o.map((f)=>f[0]),i={...n};for(let[f,d]of o)if(f in i)i[f]=Wt(d,t,`${r}/${f}`,i[f]);if(!ye(e.unevaluatedProperties))return Le(e,r,i);let a=Object.getOwnPropertyNames(i),u=e.unevaluatedProperties,c={...i};for(let f of a)if(!s.includes(f))c[f]=Le(u,`${r}/${f}`,c[f]);return Le(e,r,c)}function Zl(e,t,r,n){let o=globalThis.Object.values(e.$defs),s=e.$defs[e.$ref],i=Wt(s,[...t,...o],r,n);return Le(e,r,i)}function em(e,t,r,n){return Le(e,r,Wt(e.not,t,r,n))}function tm(e,t,r,n){if(!pt(n))return Le(e,r,n);let o=Ft(e),s={...n};for(let c of o){if(!Go(s,c))continue;if(ft(s[c])&&(!hr(e.properties[c])||ke.IsExactOptionalProperty(s,c)))continue;s[c]=Wt(e.properties[c],t,`${r}/${c}`,s[c])}if(!Me(e.additionalProperties))return Le(e,r,s);let i=Object.getOwnPropertyNames(s),a=e.additionalProperties,u={...s};for(let c of i)if(!o.includes(c))u[c]=Le(a,`${r}/${c}`,u[c]);return Le(e,r,u)}function rm(e,t,r,n){if(!pt(n))return Le(e,r,n);let o=Object.getOwnPropertyNames(e.patternProperties)[0],s=new RegExp(o),i={...n};for(let f of Object.getOwnPropertyNames(n))if(s.test(f))i[f]=Wt(e.patternProperties[o],t,`${r}/${f}`,i[f]);if(!Me(e.additionalProperties))return Le(e,r,i);let a=Object.getOwnPropertyNames(i),u=e.additionalProperties,c={...i};for(let f of a)if(!s.test(f))c[f]=Le(u,`${r}/${f}`,c[f]);return Le(e,r,c)}function nm(e,t,r,n){let o=Xe(e,t);return Le(e,r,Wt(o,t,r,n))}function om(e,t,r,n){let o=Xe(e,t);return Le(e,r,Wt(o,t,r,n))}function sm(e,t,r,n){return Ge(n)&&Ge(e.items)?Le(e,r,e.items.map((o,s)=>Wt(o,t,`${r}/${s}`,n[s]))):Le(e,r,n)}function im(e,t,r,n){for(let o of e.anyOf){if(!dn(o,t,n))continue;let s=Wt(o,t,r,n);return Le(e,r,s)}return Le(e,r,n)}function Wt(e,t,r,n){let o=Mr(e,t),s=e;switch(e[O]){case"Array":return Xl(s,o,r,n);case"Import":return Zl(s,o,r,n);case"Intersect":return Ql(s,o,r,n);case"Not":return em(s,o,r,n);case"Object":return tm(s,o,r,n);case"Record":return rm(s,o,r,n);case"Ref":return nm(s,o,r,n);case"Symbol":return Le(s,r,n);case"This":return om(s,o,r,n);case"Tuple":return sm(s,o,r,n);case"Union":return im(s,o,r,n);default:return Le(s,r,n)}}function Ya(e,t,r){return Wt(e,t,"",r)}class ci extends he{constructor(e,t,r){super("The encoded value does not match the expected schema");this.schema=e,this.value=t,this.error=r}}class Xa extends he{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 rt(e,t,r){try{return ye(e)?e[je].Encode(r):r}catch(n){throw new Xa(e,t,r,n)}}function am(e,t,r,n){let o=rt(e,r,n);return Ge(o)?o.map((s,i)=>Yt(e.items,t,`${r}/${i}`,s)):o}function um(e,t,r,n){let o=globalThis.Object.values(e.$defs),s=e.$defs[e.$ref],i=rt(e,r,n);return Yt(s,[...t,...o],r,i)}function cm(e,t,r,n){let o=rt(e,r,n);if(!pt(n)||Vo(n))return o;let s=is(e),i=s.map((d)=>d[0]),a={...o};for(let[d,m]of s)if(d in a)a[d]=Yt(m,t,`${r}/${d}`,a[d]);if(!ye(e.unevaluatedProperties))return a;let u=Object.getOwnPropertyNames(a),c=e.unevaluatedProperties,f={...a};for(let d of u)if(!i.includes(d))f[d]=rt(c,`${r}/${d}`,f[d]);return f}function fm(e,t,r,n){return rt(e.not,r,rt(e,r,n))}function dm(e,t,r,n){let o=rt(e,r,n);if(!pt(o))return o;let s=Ft(e),i={...o};for(let f of s){if(!Go(i,f))continue;if(ft(i[f])&&(!hr(e.properties[f])||ke.IsExactOptionalProperty(i,f)))continue;i[f]=Yt(e.properties[f],t,`${r}/${f}`,i[f])}if(!Me(e.additionalProperties))return i;let a=Object.getOwnPropertyNames(i),u=e.additionalProperties,c={...i};for(let f of a)if(!s.includes(f))c[f]=rt(u,`${r}/${f}`,c[f]);return c}function pm(e,t,r,n){let o=rt(e,r,n);if(!pt(n))return o;let s=Object.getOwnPropertyNames(e.patternProperties)[0],i=new RegExp(s),a={...o};for(let d of Object.getOwnPropertyNames(n))if(i.test(d))a[d]=Yt(e.patternProperties[s],t,`${r}/${d}`,a[d]);if(!Me(e.additionalProperties))return a;let u=Object.getOwnPropertyNames(a),c=e.additionalProperties,f={...a};for(let d of u)if(!i.test(d))f[d]=rt(c,`${r}/${d}`,f[d]);return f}function lm(e,t,r,n){let o=Xe(e,t),s=Yt(o,t,r,n);return rt(e,r,s)}function mm(e,t,r,n){let o=Xe(e,t),s=Yt(o,t,r,n);return rt(e,r,s)}function ym(e,t,r,n){let o=rt(e,r,n);return Ge(e.items)?e.items.map((s,i)=>Yt(s,t,`${r}/${i}`,o[i])):[]}function gm(e,t,r,n){for(let o of e.anyOf){if(!dn(o,t,n))continue;let s=Yt(o,t,r,n);return rt(e,r,s)}for(let o of e.anyOf){let s=Yt(o,t,r,n);if(!dn(e,t,s))continue;return rt(e,r,s)}return rt(e,r,n)}function Yt(e,t,r,n){let o=Mr(e,t),s=e;switch(e[O]){case"Array":return am(s,o,r,n);case"Import":return um(s,o,r,n);case"Intersect":return cm(s,o,r,n);case"Not":return fm(s,o,r,n);case"Object":return dm(s,o,r,n);case"Record":return pm(s,o,r,n);case"Ref":return lm(s,o,r,n);case"This":return mm(s,o,r,n);case"Tuple":return ym(s,o,r,n);case"Union":return gm(s,o,r,n);default:return rt(s,r,n)}}function Qa(e,t,r){return Yt(e,t,"",r)}function hm(e,t){return ye(e)||Je(e.items,t)}function xm(e,t){return ye(e)||Je(e.items,t)}function bm(e,t){return ye(e)||Je(e.returns,t)||e.parameters.some((r)=>Je(r,t))}function Im(e,t){return ye(e)||Je(e.returns,t)||e.parameters.some((r)=>Je(r,t))}function _m(e,t){return ye(e)||ye(e.unevaluatedProperties)||e.allOf.some((r)=>Je(r,t))}function Rm(e,t){let r=globalThis.Object.getOwnPropertyNames(e.$defs).reduce((o,s)=>[...o,e.$defs[s]],[]),n=e.$defs[e.$ref];return ye(e)||Je(n,[...r,...t])}function Om(e,t){return ye(e)||Je(e.items,t)}function wm(e,t){return ye(e)||Je(e.not,t)}function $m(e,t){return ye(e)||Object.values(e.properties).some((r)=>Je(r,t))||Me(e.additionalProperties)&&Je(e.additionalProperties,t)}function km(e,t){return ye(e)||Je(e.item,t)}function Am(e,t){let r=Object.getOwnPropertyNames(e.patternProperties)[0],n=e.patternProperties[r];return ye(e)||Je(n,t)||Me(e.additionalProperties)&&ye(e.additionalProperties)}function Sm(e,t){if(ye(e))return!0;return Je(Xe(e,t),t)}function Pm(e,t){if(ye(e))return!0;return Je(Xe(e,t),t)}function Cm(e,t){return ye(e)||!ft(e.items)&&e.items.some((r)=>Je(r,t))}function Tm(e,t){return ye(e)||e.anyOf.some((r)=>Je(r,t))}function Je(e,t){let r=Mr(e,t),n=e;if(e.$id&&fi.has(e.$id))return!1;if(e.$id)fi.add(e.$id);switch(e[O]){case"Array":return hm(n,r);case"AsyncIterator":return xm(n,r);case"Constructor":return bm(n,r);case"Function":return Im(n,r);case"Import":return Rm(n,r);case"Intersect":return _m(n,r);case"Iterator":return Om(n,r);case"Not":return wm(n,r);case"Object":return $m(n,r);case"Promise":return km(n,r);case"Record":return Am(n,r);case"Ref":return Sm(n,r);case"This":return Pm(n,r);case"Tuple":return Cm(n,r);case"Union":return Tm(n,r);default:return ye(e)}}var fi=new Set;function Za(e,t){return fi.clear(),Je(e,t)}class eu{constructor(e,t,r,n){this.schema=e,this.references=t,this.checkFunc=r,this.code=n,this.hasTransform=Za(e,t)}Code(){return this.code}Schema(){return this.schema}References(){return this.references}Errors(e){return Ja(this.schema,this.references,e)}Check(e){return this.checkFunc(e)}Decode(e){if(!this.checkFunc(e))throw new ui(this.schema,e,this.Errors(e).First());return this.hasTransform?Ya(this.schema,this.references,e):e}Encode(e){let t=this.hasTransform?Qa(this.schema,this.references,e):e;if(!this.checkFunc(t))throw new ci(this.schema,e,this.Errors(e).First());return t}}var $r;(function(e){function t(s){return s===36}e.DollarSign=t;function r(s){return s===95}e.IsUnderscore=r;function n(s){return s>=65&&s<=90||s>=97&&s<=122}e.IsAlpha=n;function o(s){return s>=48&&s<=57}e.IsNumeric=o})($r||($r={}));var gs;(function(e){function t(s){if(s.length===0)return!1;return $r.IsNumeric(s.charCodeAt(0))}function r(s){if(t(s))return!1;for(let i=0;i<s.length;i++){let a=s.charCodeAt(i);if(!($r.IsAlpha(a)||$r.IsNumeric(a)||$r.DollarSign(a)||$r.IsUnderscore(a)))return!1}return!0}function n(s){return s.replace(/'/g,"\\'")}function o(s,i){return r(i)?`${s}.${i}`:`${s}['${n(i)}']`}e.Encode=o})(gs||(gs={}));var di;(function(e){function t(r){let n=[];for(let o=0;o<r.length;o++){let s=r.charCodeAt(o);if($r.IsNumeric(s)||$r.IsAlpha(s))n.push(r.charAt(o));else n.push(`_${s}_`)}return n.join("").replace(/__/g,"_")}e.Encode=t})(di||(di={}));var pi;(function(e){function t(r){return r.replace(/'/g,"\\'")}e.Escape=t})(pi||(pi={}));class tu extends he{constructor(e){super("Unknown type");this.schema=e}}class li extends he{constructor(e){super("Preflight validation check failed to guard for the given schema");this.schema=e}}var pn;(function(e){function t(i,a,u){return ke.ExactOptionalPropertyTypes?`('${a}' in ${i} ? ${u} : true)`:`(${gs.Encode(i,a)} !== undefined ? ${u} : true)`}e.IsExactOptionalProperty=t;function r(i){return!ke.AllowArrayObject?`(typeof ${i} === 'object' && ${i} !== null && !Array.isArray(${i}))`:`(typeof ${i} === 'object' && ${i} !== null)`}e.IsObjectLike=r;function n(i){return!ke.AllowArrayObject?`(typeof ${i} === 'object' && ${i} !== null && !Array.isArray(${i}) && !(${i} instanceof Date) && !(${i} instanceof Uint8Array))`:`(typeof ${i} === 'object' && ${i} !== null && !(${i} instanceof Date) && !(${i} instanceof Uint8Array))`}e.IsRecordLike=n;function o(i){return ke.AllowNaN?`typeof ${i} === 'number'`:`Number.isFinite(${i})`}e.IsNumberLike=o;function s(i){return ke.AllowNullVoid?`(${i} === undefined || ${i} === null)`:`${i} === undefined`}e.IsVoidLike=s})(pn||(pn={}));var $o;(function(e){function t(l){return l[O]==="Any"||l[O]==="Unknown"}function*r(l,j,g){yield"true"}function*n(l,j,g){yield"true"}function*o(l,j,g){yield`Array.isArray(${g})`;let[Y,E]=[Ce("value","any"),Ce("acc","number")];if(X(l.maxItems))yield`${g}.length <= ${l.maxItems}`;if(X(l.minItems))yield`${g}.length >= ${l.minItems}`;let U=k(l.items,j,"value");if(yield`${g}.every((${Y}) => ${U})`,Ee(l.contains)||X(l.minContains)||X(l.maxContains)){let $e=Ee(l.contains)?l.contains:ne(),dt=k($e,j,"value"),mr=X(l.minContains)?[`(count >= ${l.minContains})`]:[],Ut=X(l.maxContains)?[`(count <= ${l.maxContains})`]:[],or=`const count = value.reduce((${E}, ${Y}) => ${dt} ? acc + 1 : acc, 0)`,Bo=["(count > 0)",...mr,...Ut].join(" && ");yield`((${Y}) => { ${or}; return ${Bo}})(${g})`}if(l.uniqueItems===!0)yield`((${Y}) => { 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 } )(${g})`}function*s(l,j,g){yield`(typeof value === 'object' && Symbol.asyncIterator in ${g})`}function*i(l,j,g){if(yield`(typeof ${g} === 'bigint')`,bt(l.exclusiveMaximum))yield`${g} < BigInt(${l.exclusiveMaximum})`;if(bt(l.exclusiveMinimum))yield`${g} > BigInt(${l.exclusiveMinimum})`;if(bt(l.maximum))yield`${g} <= BigInt(${l.maximum})`;if(bt(l.minimum))yield`${g} >= BigInt(${l.minimum})`;if(bt(l.multipleOf))yield`(${g} % BigInt(${l.multipleOf})) === 0`}function*a(l,j,g){yield`(typeof ${g} === 'boolean')`}function*u(l,j,g){yield*ae(l.returns,j,`${g}.prototype`)}function*c(l,j,g){if(yield`(${g} instanceof Date) && Number.isFinite(${g}.getTime())`,X(l.exclusiveMaximumTimestamp))yield`${g}.getTime() < ${l.exclusiveMaximumTimestamp}`;if(X(l.exclusiveMinimumTimestamp))yield`${g}.getTime() > ${l.exclusiveMinimumTimestamp}`;if(X(l.maximumTimestamp))yield`${g}.getTime() <= ${l.maximumTimestamp}`;if(X(l.minimumTimestamp))yield`${g}.getTime() >= ${l.minimumTimestamp}`;if(X(l.multipleOfTimestamp))yield`(${g}.getTime() % ${l.multipleOfTimestamp}) === 0`}function*f(l,j,g){yield`(typeof ${g} === 'function')`}function*d(l,j,g){let Y=globalThis.Object.getOwnPropertyNames(l.$defs).reduce((E,U)=>[...E,l.$defs[U]],[]);yield*ae(Tt(l.$ref),[...j,...Y],g)}function*m(l,j,g){if(yield`Number.isInteger(${g})`,X(l.exclusiveMaximum))yield`${g} < ${l.exclusiveMaximum}`;if(X(l.exclusiveMinimum))yield`${g} > ${l.exclusiveMinimum}`;if(X(l.maximum))yield`${g} <= ${l.maximum}`;if(X(l.minimum))yield`${g} >= ${l.minimum}`;if(X(l.multipleOf))yield`(${g} % ${l.multipleOf}) === 0`}function*y(l,j,g){let Y=l.allOf.map((E)=>k(E,j,g)).join(" && ");if(l.unevaluatedProperties===!1){let E=G(`${new RegExp(Ir(l))};`),U=`Object.getOwnPropertyNames(${g}).every(key => ${E}.test(key))`;yield`(${Y} && ${U})`}else if(Ee(l.unevaluatedProperties)){let E=G(`${new RegExp(Ir(l))};`),U=`Object.getOwnPropertyNames(${g}).every(key => ${E}.test(key) || ${k(l.unevaluatedProperties,j,`${g}[key]`)})`;yield`(${Y} && ${U})`}else yield`(${Y})`}function*p(l,j,g){yield`(typeof value === 'object' && Symbol.iterator in ${g})`}function*h(l,j,g){if(typeof l.const==="number"||typeof l.const==="boolean")yield`(${g} === ${l.const})`;else yield`(${g} === '${pi.Escape(l.const)}')`}function*x(l,j,g){yield"false"}function*R(l,j,g){yield`(!${k(l.not,j,g)})`}function*w(l,j,g){yield`(${g} === null)`}function*P(l,j,g){if(yield pn.IsNumberLike(g),X(l.exclusiveMaximum))yield`${g} < ${l.exclusiveMaximum}`;if(X(l.exclusiveMinimum))yield`${g} > ${l.exclusiveMinimum}`;if(X(l.maximum))yield`${g} <= ${l.maximum}`;if(X(l.minimum))yield`${g} >= ${l.minimum}`;if(X(l.multipleOf))yield`(${g} % ${l.multipleOf}) === 0`}function*C(l,j,g){if(yield pn.IsObjectLike(g),X(l.minProperties))yield`Object.getOwnPropertyNames(${g}).length >= ${l.minProperties}`;if(X(l.maxProperties))yield`Object.getOwnPropertyNames(${g}).length <= ${l.maxProperties}`;let Y=Object.getOwnPropertyNames(l.properties);for(let E of Y){let U=gs.Encode(g,E),$e=l.properties[E];if(l.required&&l.required.includes(E)){if(yield*ae($e,j,U),_r($e)||t($e))yield`('${E}' in ${g})`}else{let dt=k($e,j,U);yield pn.IsExactOptionalProperty(g,E,dt)}}if(l.additionalProperties===!1)if(l.required&&l.required.length===Y.length)yield`Object.getOwnPropertyNames(${g}).length === ${Y.length}`;else{let E=`[${Y.map((U)=>`'${U}'`).join(", ")}]`;yield`Object.getOwnPropertyNames(${g}).every(key => ${E}.includes(key))`}if(typeof l.additionalProperties==="object"){let E=k(l.additionalProperties,j,`${g}[key]`),U=`[${Y.map(($e)=>`'${$e}'`).join(", ")}]`;yield`(Object.getOwnPropertyNames(${g}).every(key => ${U}.includes(key) || ${E}))`}}function*J(l,j,g){yield`${g} instanceof Promise`}function*z(l,j,g){if(yield pn.IsRecordLike(g),X(l.minProperties))yield`Object.getOwnPropertyNames(${g}).length >= ${l.minProperties}`;if(X(l.maxProperties))yield`Object.getOwnPropertyNames(${g}).length <= ${l.maxProperties}`;let[Y,E]=Object.entries(l.patternProperties)[0],U=G(`${new RegExp(Y)}`),$e=k(E,j,"value"),dt=Ee(l.additionalProperties)?k(l.additionalProperties,j,g):l.additionalProperties===!1?"false":"true",mr=`(${U}.test(key) ? ${$e} : ${dt})`;yield`(Object.entries(${g}).every(([key, value]) => ${mr}))`}function*L(l,j,g){let Y=Xe(l,j);if(D.functions.has(l.$ref))return yield`${v(l.$ref)}(${g})`;yield*ae(Y,j,g)}function*T(l,j,g){let Y=G(`${new RegExp(l.source,l.flags)};`);if(yield`(typeof ${g} === 'string')`,X(l.maxLength))yield`${g}.length <= ${l.maxLength}`;if(X(l.minLength))yield`${g}.length >= ${l.minLength}`;yield`${Y}.test(${g})`}function*B(l,j,g){if(yield`(typeof ${g} === 'string')`,X(l.maxLength))yield`${g}.length <= ${l.maxLength}`;if(X(l.minLength))yield`${g}.length >= ${l.minLength}`;if(l.pattern!==void 0)yield`${G(`${new RegExp(l.pattern)};`)}.test(${g})`;if(l.format!==void 0)yield`format('${l.format}', ${g})`}function*Z(l,j,g){yield`(typeof ${g} === 'symbol')`}function*W(l,j,g){yield`(typeof ${g} === 'string')`,yield`${G(`${new RegExp(l.pattern)};`)}.test(${g})`}function*q(l,j,g){yield`${v(l.$ref)}(${g})`}function*A(l,j,g){if(yield`Array.isArray(${g})`,l.items===void 0)return yield`${g}.length === 0`;yield`(${g}.length === ${l.maxItems})`;for(let Y=0;Y<l.items.length;Y++)yield`${k(l.items[Y],j,`${g}[${Y}]`)}`}function*oe(l,j,g){yield`${g} === undefined`}function*Q(l,j,g){yield`(${l.anyOf.map((E)=>k(E,j,g)).join(" || ")})`}function*re(l,j,g){if(yield`${g} instanceof Uint8Array`,X(l.maxByteLength))yield`(${g}.length <= ${l.maxByteLength})`;if(X(l.minByteLength))yield`(${g}.length >= ${l.minByteLength})`}function*ie(l,j,g){yield"true"}function*ge(l,j,g){yield pn.IsVoidLike(g)}function*ee(l,j,g){let Y=D.instances.size;D.instances.set(Y,l),yield`kind('${l[O]}', ${Y}, ${g})`}function*ae(l,j,g,Y=!0){let E=Ye(l.$id)?[...j,l]:j,U=l;if(Y&&Ye(l.$id)){let $e=v(l.$id);if(D.functions.has($e))return yield`${$e}(${g})`;else{D.functions.set($e,"<deferred>");let dt=we($e,l,j,"value",!1);return D.functions.set($e,dt),yield`${$e}(${g})`}}switch(U[O]){case"Any":return yield*r(U,E,g);case"Argument":return yield*n(U,E,g);case"Array":return yield*o(U,E,g);case"AsyncIterator":return yield*s(U,E,g);case"BigInt":return yield*i(U,E,g);case"Boolean":return yield*a(U,E,g);case"Constructor":return yield*u(U,E,g);case"Date":return yield*c(U,E,g);case"Function":return yield*f(U,E,g);case"Import":return yield*d(U,E,g);case"Integer":return yield*m(U,E,g);case"Intersect":return yield*y(U,E,g);case"Iterator":return yield*p(U,E,g);case"Literal":return yield*h(U,E,g);case"Never":return yield*x(U,E,g);case"Not":return yield*R(U,E,g);case"Null":return yield*w(U,E,g);case"Number":return yield*P(U,E,g);case"Object":return yield*C(U,E,g);case"Promise":return yield*J(U,E,g);case"Record":return yield*z(U,E,g);case"Ref":return yield*L(U,E,g);case"RegExp":return yield*T(U,E,g);case"String":return yield*B(U,E,g);case"Symbol":return yield*Z(U,E,g);case"TemplateLiteral":return yield*W(U,E,g);case"This":return yield*q(U,E,g);case"Tuple":return yield*A(U,E,g);case"Undefined":return yield*oe(U,E,g);case"Union":return yield*Q(U,E,g);case"Uint8Array":return yield*re(U,E,g);case"Unknown":return yield*ie(U,E,g);case"Void":return yield*ge(U,E,g);default:if(!co(U[O]))throw new tu(l);return yield*ee(U,E,g)}}let D={language:"javascript",functions:new Map,variables:new Map,instances:new Map};function k(l,j,g,Y=!0){return`(${[...ae(l,j,g,Y)].join(" && ")})`}function v(l){return`check_${di.Encode(l)}`}function G(l){let j=`local_${D.variables.size}`;return D.variables.set(j,`const ${j} = ${l}`),j}function we(l,j,g,Y,E=!0){let[U,$e]=[`
3
+ `,(or)=>"".padStart(or," ")],dt=Ce("value","any"),mr=At("boolean"),Ut=[...ae(j,g,Y,E)].map((or)=>`${$e(4)}${or}`).join(` &&${U}`);return`function ${l}(${dt})${mr} {${U}${$e(2)}return (${U}${Ut}${U}${$e(2)})
4
+ }`}function Ce(l,j){let g=D.language==="typescript"?`: ${j}`:"";return`${l}${g}`}function At(l){return D.language==="typescript"?`: ${l}`:""}function Lt(l,j,g){let Y=we("check",l,j,"value"),E=Ce("value","any"),U=At("boolean"),$e=[...D.functions.values()],dt=[...D.variables.values()],mr=Ye(l.$id)?`return function check(${E})${U} {
5
+ return ${v(l.$id)}(value)
6
+ }`:`return ${Y}`;return[...dt,...$e,mr].join(`
7
+ `)}function ct(...l){let j={language:"javascript"},[g,Y,E]=l.length===2&&Ge(l[1])?[l[0],l[1],j]:l.length===2&&!Ge(l[1])?[l[0],[],l[1]]:l.length===3?[l[0],l[1],l[2]]:l.length===1?[l[0],[],j]:[null,[],j];if(D.language=E.language,D.variables.clear(),D.functions.clear(),D.instances.clear(),!Ee(g))throw new li(g);for(let U of Y)if(!Ee(U))throw new li(U);return Lt(g,Y,E)}e.Code=ct;function wc(l,j=[]){let g=ct(l,j,{language:"javascript"}),Y=globalThis.Function("kind","format","hash",g),E=new Map(D.instances);function U(Ut,or,Bo){if(!co(Ut)||!E.has(or))return!1;let $c=vs(Ut),kc=E.get(or);return $c(kc,Bo)}function $e(Ut,or){if(!Ks(Ut))return!1;return Bs(Ut)(or)}function dt(Ut){return Mn(Ut)}let mr=Y(U,$e,dt);return new eu(l,j,mr,g)}e.Compile=wc})($o||($o={}));var fe;(function(e){e.assertEqual=(o)=>{};function t(o){}e.assertIs=t;function r(o){throw Error()}e.assertNever=r,e.arrayToEnum=(o)=>{let s={};for(let i of o)s[i]=i;return s},e.getValidEnumValues=(o)=>{let s=e.objectKeys(o).filter((a)=>typeof o[o[a]]!=="number"),i={};for(let a of s)i[a]=o[a];return e.objectValues(i)},e.objectValues=(o)=>e.objectKeys(o).map(function(s){return o[s]}),e.objectKeys=typeof Object.keys==="function"?(o)=>Object.keys(o):(o)=>{let s=[];for(let i in o)if(Object.prototype.hasOwnProperty.call(o,i))s.push(i);return s},e.find=(o,s)=>{for(let i of o)if(s(i))return i;return},e.isInteger=typeof Number.isInteger==="function"?(o)=>Number.isInteger(o):(o)=>typeof o==="number"&&Number.isFinite(o)&&Math.floor(o)===o;function n(o,s=" | "){return o.map((i)=>typeof i==="string"?`'${i}'`:i).join(s)}e.joinValues=n,e.jsonStringifyReplacer=(o,s)=>{if(typeof s==="bigint")return s.toString();return s}})(fe||(fe={}));var mi;(function(e){e.mergeShapes=(t,r)=>({...t,...r})})(mi||(mi={}));var M=fe.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),cr=(e)=>{switch(typeof e){case"undefined":return M.undefined;case"string":return M.string;case"number":return Number.isNaN(e)?M.nan:M.number;case"boolean":return M.boolean;case"function":return M.function;case"bigint":return M.bigint;case"symbol":return M.symbol;case"object":if(Array.isArray(e))return M.array;if(e===null)return M.null;if(e.then&&typeof e.then==="function"&&e.catch&&typeof e.catch==="function")return M.promise;if(typeof Map<"u"&&e instanceof Map)return M.map;if(typeof Set<"u"&&e instanceof Set)return M.set;if(typeof Date<"u"&&e instanceof Date)return M.date;return M.object;default:return M.unknown}};var S=fe.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"]),Fm=(e)=>JSON.stringify(e,null,2).replace(/"([^"]+)":/g,"$1:");class xt extends Error{get errors(){return this.issues}constructor(e){super();this.issues=[],this.addIssue=(r)=>{this.issues=[...this.issues,r]},this.addIssues=(r=[])=>{this.issues=[...this.issues,...r]};let t=new.target.prototype;if(Object.setPrototypeOf)Object.setPrototypeOf(this,t);else this.__proto__=t;this.name="ZodError",this.issues=e}format(e){let t=e||function(o){return o.message},r={_errors:[]},n=(o)=>{for(let s of o.issues)if(s.code==="invalid_union")s.unionErrors.map(n);else if(s.code==="invalid_return_type")n(s.returnTypeError);else if(s.code==="invalid_arguments")n(s.argumentsError);else if(s.path.length===0)r._errors.push(t(s));else{let i=r,a=0;while(a<s.path.length){let u=s.path[a];if(a!==s.path.length-1)i[u]=i[u]||{_errors:[]};else i[u]=i[u]||{_errors:[]},i[u]._errors.push(t(s));i=i[u],a++}}};return n(this),r}static assert(e){if(!(e instanceof xt))throw Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,fe.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()}}xt.create=(e)=>new xt(e);var Nm=(e,t)=>{let r;switch(e.code){case S.invalid_type:if(e.received===M.undefined)r="Required";else r=`Expected ${e.expected}, received ${e.received}`;break;case S.invalid_literal:r=`Invalid literal value, expected ${JSON.stringify(e.expected,fe.jsonStringifyReplacer)}`;break;case S.unrecognized_keys:r=`Unrecognized key(s) in object: ${fe.joinValues(e.keys,", ")}`;break;case S.invalid_union:r="Invalid input";break;case S.invalid_union_discriminator:r=`Invalid discriminator value. Expected ${fe.joinValues(e.options)}`;break;case S.invalid_enum_value:r=`Invalid enum value. Expected ${fe.joinValues(e.options)}, received '${e.received}'`;break;case S.invalid_arguments:r="Invalid function arguments";break;case S.invalid_return_type:r="Invalid function return type";break;case S.invalid_date:r="Invalid date";break;case S.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 fe.assertNever(e.validation);else if(e.validation!=="regex")r=`Invalid ${e.validation}`;else r="Invalid";break;case S.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 S.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 S.custom:r="Invalid input";break;case S.invalid_intersection_types:r="Intersection results could not be merged";break;case S.not_multiple_of:r=`Number must be a multiple of ${e.multipleOf}`;break;case S.not_finite:r="Number must be finite";break;default:r=t.defaultError,fe.assertNever(e)}return{message:r}},kr=Nm;var ru=kr;function jm(e){ru=e}function Kn(){return ru}var ko=(e)=>{let{data:t,path:r,errorMaps:n,issueData:o}=e,s=[...r,...o.path||[]],i={...o,path:s};if(o.message!==void 0)return{...o,path:s,message:o.message};let a="",u=n.filter((c)=>!!c).slice().reverse();for(let c of u)a=c(i,{data:t,defaultError:a}).message;return{...o,path:s,message:a}},Mm=[];function F(e,t){let r=Kn(),n=ko({issueData:t,data:e.data,path:e.path,errorMaps:[e.common.contextualErrorMap,e.schemaErrorMap,r,r===kr?void 0:kr].filter((o)=>!!o)});e.common.issues.push(n)}class nt{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 H;if(n.status==="dirty")e.dirty();r.push(n.value)}return{status:e.value,value:r}}static async mergeObjectAsync(e,t){let r=[];for(let n of t){let o=await n.key,s=await n.value;r.push({key:o,value:s})}return nt.mergeObjectSync(e,r)}static mergeObjectSync(e,t){let r={};for(let n of t){let{key:o,value:s}=n;if(o.status==="aborted")return H;if(s.status==="aborted")return H;if(o.status==="dirty")e.dirty();if(s.status==="dirty")e.dirty();if(o.value!=="__proto__"&&(typeof s.value<"u"||n.alwaysSet))r[o.value]=s.value}return{status:e.value,value:r}}}var H=Object.freeze({status:"aborted"}),ln=(e)=>({status:"dirty",value:e}),ut=(e)=>({status:"valid",value:e}),hs=(e)=>e.status==="aborted",xs=(e)=>e.status==="dirty",vr=(e)=>e.status==="valid",Bn=(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 er{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 nu=(e,t)=>{if(vr(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 xt(e.common.issues);return this._error=r,this._error}}}};function te(e){if(!e)return{};let{errorMap:t,invalid_type_error:r,required_error:n,description:o}=e;if(t&&(r||n))throw Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);if(t)return{errorMap:t,description:o};return{errorMap:(i,a)=>{let{message:u}=e;if(i.code==="invalid_enum_value")return{message:u??a.defaultError};if(typeof a.data>"u")return{message:u??n??a.defaultError};if(i.code!=="invalid_type")return{message:a.defaultError};return{message:u??r??a.defaultError}},description:o}}class se{get description(){return this._def.description}_getType(e){return cr(e.data)}_getOrReturnCtx(e,t){return t||{common:e.parent.common,data:e.data,parsedType:cr(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new nt,ctx:{common:e.parent.common,data:e.data,parsedType:cr(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){let t=this._parse(e);if(Bn(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:cr(e)},n=this._parseSync({data:e,path:r.path,parent:r});return nu(r,n)}"~validate"(e){let t={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:cr(e)};if(!this["~standard"].async)try{let r=this._parseSync({data:e,path:[],parent:t});return vr(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)=>vr(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:cr(e)},n=this._parse({data:e,path:r.path,parent:r}),o=await(Bn(n)?n:Promise.resolve(n));return nu(r,o)}refine(e,t){let r=(n)=>{if(typeof t==="string"||typeof t>"u")return{message:t};else if(typeof t==="function")return t(n);else return t};return this._refinement((n,o)=>{let s=e(n),i=()=>o.addIssue({code:S.custom,...r(n)});if(typeof Promise<"u"&&s instanceof Promise)return s.then((a)=>{if(!a)return i(),!1;else return!0});if(!s)return i(),!1;else return!0})}refinement(e,t){return this._refinement((r,n)=>{if(!e(r))return n.addIssue(typeof t==="function"?t(r,n):t),!1;else return!0})}_refinement(e){return new tr({schema:this,typeName:V.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 Zt.create(this,this._def)}nullable(){return Sr.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return Qt.create(this)}promise(){return hn.create(this,this._def)}or(e){return zn.create([this,e],this._def)}and(e){return Vn.create(this,e,this._def)}transform(e){return new tr({...te(this._def),schema:this,typeName:V.ZodEffects,effect:{type:"transform",transform:e}})}default(e){let t=typeof e==="function"?e:()=>e;return new Xn({...te(this._def),innerType:this,defaultValue:t,typeName:V.ZodDefault})}brand(){return new Is({typeName:V.ZodBranded,type:this,...te(this._def)})}catch(e){let t=typeof e==="function"?e:()=>e;return new Qn({...te(this._def),innerType:this,catchValue:t,typeName:V.ZodCatch})}describe(e){return new this.constructor({...this._def,description:e})}pipe(e){return Fo.create(this,e)}readonly(){return Zn.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}var Em=/^c[^\s-]{8,}$/i,Lm=/^[0-9a-z]+$/,Um=/^[0-9A-HJKMNP-TV-Z]{26}$/i,Km=/^[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,Bm=/^[a-z0-9_-]{21}$/i,vm=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,Dm=/^[-+]?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)?)??$/,qm=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,Gm="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$",yi,Hm=/^(?:(?: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])$/,zm=/^(?:(?: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])$/,Vm=/^(([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]))$/,Jm=/^(([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])$/,Wm=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,Ym=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,su="((\\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])))",Xm=new RegExp(`^${su}$`);function iu(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 Qm(e){return new RegExp(`^${iu(e)}$`)}function au(e){let t=`${su}T${iu(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 Zm(e,t){if((t==="v4"||!t)&&Hm.test(e))return!0;if((t==="v6"||!t)&&Vm.test(e))return!0;return!1}function ey(e,t){if(!vm.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 ty(e,t){if((t==="v4"||!t)&&zm.test(e))return!0;if((t==="v6"||!t)&&Jm.test(e))return!0;return!1}class Xt extends se{_parse(e){if(this._def.coerce)e.data=String(e.data);if(this._getType(e)!==M.string){let o=this._getOrReturnCtx(e);return F(o,{code:S.invalid_type,expected:M.string,received:o.parsedType}),H}let r=new nt,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),F(n,{code:S.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),F(n,{code:S.too_big,maximum:o.value,type:"string",inclusive:!0,exact:!1,message:o.message}),r.dirty()}else if(o.kind==="length"){let s=e.data.length>o.value,i=e.data.length<o.value;if(s||i){if(n=this._getOrReturnCtx(e,n),s)F(n,{code:S.too_big,maximum:o.value,type:"string",inclusive:!0,exact:!0,message:o.message});else if(i)F(n,{code:S.too_small,minimum:o.value,type:"string",inclusive:!0,exact:!0,message:o.message});r.dirty()}}else if(o.kind==="email"){if(!qm.test(e.data))n=this._getOrReturnCtx(e,n),F(n,{validation:"email",code:S.invalid_string,message:o.message}),r.dirty()}else if(o.kind==="emoji"){if(!yi)yi=new RegExp(Gm,"u");if(!yi.test(e.data))n=this._getOrReturnCtx(e,n),F(n,{validation:"emoji",code:S.invalid_string,message:o.message}),r.dirty()}else if(o.kind==="uuid"){if(!Km.test(e.data))n=this._getOrReturnCtx(e,n),F(n,{validation:"uuid",code:S.invalid_string,message:o.message}),r.dirty()}else if(o.kind==="nanoid"){if(!Bm.test(e.data))n=this._getOrReturnCtx(e,n),F(n,{validation:"nanoid",code:S.invalid_string,message:o.message}),r.dirty()}else if(o.kind==="cuid"){if(!Em.test(e.data))n=this._getOrReturnCtx(e,n),F(n,{validation:"cuid",code:S.invalid_string,message:o.message}),r.dirty()}else if(o.kind==="cuid2"){if(!Lm.test(e.data))n=this._getOrReturnCtx(e,n),F(n,{validation:"cuid2",code:S.invalid_string,message:o.message}),r.dirty()}else if(o.kind==="ulid"){if(!Um.test(e.data))n=this._getOrReturnCtx(e,n),F(n,{validation:"ulid",code:S.invalid_string,message:o.message}),r.dirty()}else if(o.kind==="url")try{new URL(e.data)}catch{n=this._getOrReturnCtx(e,n),F(n,{validation:"url",code:S.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),F(n,{validation:"regex",code:S.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),F(n,{code:S.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),F(n,{code:S.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),F(n,{code:S.invalid_string,validation:{endsWith:o.value},message:o.message}),r.dirty()}else if(o.kind==="datetime"){if(!au(o).test(e.data))n=this._getOrReturnCtx(e,n),F(n,{code:S.invalid_string,validation:"datetime",message:o.message}),r.dirty()}else if(o.kind==="date"){if(!Xm.test(e.data))n=this._getOrReturnCtx(e,n),F(n,{code:S.invalid_string,validation:"date",message:o.message}),r.dirty()}else if(o.kind==="time"){if(!Qm(o).test(e.data))n=this._getOrReturnCtx(e,n),F(n,{code:S.invalid_string,validation:"time",message:o.message}),r.dirty()}else if(o.kind==="duration"){if(!Dm.test(e.data))n=this._getOrReturnCtx(e,n),F(n,{validation:"duration",code:S.invalid_string,message:o.message}),r.dirty()}else if(o.kind==="ip"){if(!Zm(e.data,o.version))n=this._getOrReturnCtx(e,n),F(n,{validation:"ip",code:S.invalid_string,message:o.message}),r.dirty()}else if(o.kind==="jwt"){if(!ey(e.data,o.alg))n=this._getOrReturnCtx(e,n),F(n,{validation:"jwt",code:S.invalid_string,message:o.message}),r.dirty()}else if(o.kind==="cidr"){if(!ty(e.data,o.version))n=this._getOrReturnCtx(e,n),F(n,{validation:"cidr",code:S.invalid_string,message:o.message}),r.dirty()}else if(o.kind==="base64"){if(!Wm.test(e.data))n=this._getOrReturnCtx(e,n),F(n,{validation:"base64",code:S.invalid_string,message:o.message}),r.dirty()}else if(o.kind==="base64url"){if(!Ym.test(e.data))n=this._getOrReturnCtx(e,n),F(n,{validation:"base64url",code:S.invalid_string,message:o.message}),r.dirty()}else fe.assertNever(o);return{status:r.value,value:e.data}}_regex(e,t,r){return this.refinement((n)=>e.test(n),{validation:t,code:S.invalid_string,...K.errToObj(r)})}_addCheck(e){return new Xt({...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 Xt({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new Xt({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new Xt({...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}}Xt.create=(e)=>new Xt({checks:[],typeName:V.ZodString,coerce:e?.coerce??!1,...te(e)});function ry(e,t){let r=(e.toString().split(".")[1]||"").length,n=(t.toString().split(".")[1]||"").length,o=r>n?r:n,s=Number.parseInt(e.toFixed(o).replace(".","")),i=Number.parseInt(t.toFixed(o).replace(".",""));return s%i/10**o}class qr extends se{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)!==M.number){let o=this._getOrReturnCtx(e);return F(o,{code:S.invalid_type,expected:M.number,received:o.parsedType}),H}let r=void 0,n=new nt;for(let o of this._def.checks)if(o.kind==="int"){if(!fe.isInteger(e.data))r=this._getOrReturnCtx(e,r),F(r,{code:S.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),F(r,{code:S.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),F(r,{code:S.too_big,maximum:o.value,type:"number",inclusive:o.inclusive,exact:!1,message:o.message}),n.dirty()}else if(o.kind==="multipleOf"){if(ry(e.data,o.value)!==0)r=this._getOrReturnCtx(e,r),F(r,{code:S.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),F(r,{code:S.not_finite,message:o.message}),n.dirty()}else fe.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 qr({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:r,message:K.toString(n)}]})}_addCheck(e){return new qr({...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"&&fe.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)}}qr.create=(e)=>new qr({checks:[],typeName:V.ZodNumber,coerce:e?.coerce||!1,...te(e)});class Gr extends se{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)!==M.bigint)return this._getInvalidInput(e);let r=void 0,n=new nt;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),F(r,{code:S.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),F(r,{code:S.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),F(r,{code:S.not_multiple_of,multipleOf:o.value,message:o.message}),n.dirty()}else fe.assertNever(o);return{status:n.value,value:e.data}}_getInvalidInput(e){let t=this._getOrReturnCtx(e);return F(t,{code:S.invalid_type,expected:M.bigint,received:t.parsedType}),H}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 Gr({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:r,message:K.toString(n)}]})}_addCheck(e){return new Gr({...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}}Gr.create=(e)=>new Gr({checks:[],typeName:V.ZodBigInt,coerce:e?.coerce??!1,...te(e)});class qn extends se{_parse(e){if(this._def.coerce)e.data=Boolean(e.data);if(this._getType(e)!==M.boolean){let r=this._getOrReturnCtx(e);return F(r,{code:S.invalid_type,expected:M.boolean,received:r.parsedType}),H}return ut(e.data)}}qn.create=(e)=>new qn({typeName:V.ZodBoolean,coerce:e?.coerce||!1,...te(e)});class mn extends se{_parse(e){if(this._def.coerce)e.data=new Date(e.data);if(this._getType(e)!==M.date){let o=this._getOrReturnCtx(e);return F(o,{code:S.invalid_type,expected:M.date,received:o.parsedType}),H}if(Number.isNaN(e.data.getTime())){let o=this._getOrReturnCtx(e);return F(o,{code:S.invalid_date}),H}let r=new nt,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),F(n,{code:S.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),F(n,{code:S.too_big,message:o.message,inclusive:!0,exact:!1,maximum:o.value,type:"date"}),r.dirty()}else fe.assertNever(o);return{status:r.value,value:new Date(e.data.getTime())}}_addCheck(e){return new mn({...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}}mn.create=(e)=>new mn({checks:[],coerce:e?.coerce||!1,typeName:V.ZodDate,...te(e)});class Ao extends se{_parse(e){if(this._getType(e)!==M.symbol){let r=this._getOrReturnCtx(e);return F(r,{code:S.invalid_type,expected:M.symbol,received:r.parsedType}),H}return ut(e.data)}}Ao.create=(e)=>new Ao({typeName:V.ZodSymbol,...te(e)});class Gn extends se{_parse(e){if(this._getType(e)!==M.undefined){let r=this._getOrReturnCtx(e);return F(r,{code:S.invalid_type,expected:M.undefined,received:r.parsedType}),H}return ut(e.data)}}Gn.create=(e)=>new Gn({typeName:V.ZodUndefined,...te(e)});class Hn extends se{_parse(e){if(this._getType(e)!==M.null){let r=this._getOrReturnCtx(e);return F(r,{code:S.invalid_type,expected:M.null,received:r.parsedType}),H}return ut(e.data)}}Hn.create=(e)=>new Hn({typeName:V.ZodNull,...te(e)});class yn extends se{constructor(){super(...arguments);this._any=!0}_parse(e){return ut(e.data)}}yn.create=(e)=>new yn({typeName:V.ZodAny,...te(e)});class Dr extends se{constructor(){super(...arguments);this._unknown=!0}_parse(e){return ut(e.data)}}Dr.create=(e)=>new Dr({typeName:V.ZodUnknown,...te(e)});class fr extends se{_parse(e){let t=this._getOrReturnCtx(e);return F(t,{code:S.invalid_type,expected:M.never,received:t.parsedType}),H}}fr.create=(e)=>new fr({typeName:V.ZodNever,...te(e)});class So extends se{_parse(e){if(this._getType(e)!==M.undefined){let r=this._getOrReturnCtx(e);return F(r,{code:S.invalid_type,expected:M.void,received:r.parsedType}),H}return ut(e.data)}}So.create=(e)=>new So({typeName:V.ZodVoid,...te(e)});class Qt extends se{_parse(e){let{ctx:t,status:r}=this._processInputParams(e),n=this._def;if(t.parsedType!==M.array)return F(t,{code:S.invalid_type,expected:M.array,received:t.parsedType}),H;if(n.exactLength!==null){let s=t.data.length>n.exactLength.value,i=t.data.length<n.exactLength.value;if(s||i)F(t,{code:s?S.too_big:S.too_small,minimum:i?n.exactLength.value:void 0,maximum:s?n.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:n.exactLength.message}),r.dirty()}if(n.minLength!==null){if(t.data.length<n.minLength.value)F(t,{code:S.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)F(t,{code:S.too_big,maximum:n.maxLength.value,type:"array",inclusive:!0,exact:!1,message:n.maxLength.message}),r.dirty()}if(t.common.async)return Promise.all([...t.data].map((s,i)=>n.type._parseAsync(new er(t,s,t.path,i)))).then((s)=>nt.mergeArray(r,s));let o=[...t.data].map((s,i)=>n.type._parseSync(new er(t,s,t.path,i)));return nt.mergeArray(r,o)}get element(){return this._def.type}min(e,t){return new Qt({...this._def,minLength:{value:e,message:K.toString(t)}})}max(e,t){return new Qt({...this._def,maxLength:{value:e,message:K.toString(t)}})}length(e,t){return new Qt({...this._def,exactLength:{value:e,message:K.toString(t)}})}nonempty(e){return this.min(1,e)}}Qt.create=(e,t)=>new Qt({type:e,minLength:null,maxLength:null,exactLength:null,typeName:V.ZodArray,...te(t)});function vn(e){if(e instanceof ve){let t={};for(let r in e.shape){let n=e.shape[r];t[r]=Zt.create(vn(n))}return new ve({...e._def,shape:()=>t})}else if(e instanceof Qt)return new Qt({...e._def,type:vn(e.element)});else if(e instanceof Zt)return Zt.create(vn(e.unwrap()));else if(e instanceof Sr)return Sr.create(vn(e.unwrap()));else if(e instanceof dr)return dr.create(e.items.map((t)=>vn(t)));else return e}class ve extends se{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=fe.objectKeys(e);return this._cached={shape:e,keys:t},this._cached}_parse(e){if(this._getType(e)!==M.object){let u=this._getOrReturnCtx(e);return F(u,{code:S.invalid_type,expected:M.object,received:u.parsedType}),H}let{status:r,ctx:n}=this._processInputParams(e),{shape:o,keys:s}=this._getCached(),i=[];if(!(this._def.catchall instanceof fr&&this._def.unknownKeys==="strip")){for(let u in n.data)if(!s.includes(u))i.push(u)}let a=[];for(let u of s){let c=o[u],f=n.data[u];a.push({key:{status:"valid",value:u},value:c._parse(new er(n,f,n.path,u)),alwaysSet:u in n.data})}if(this._def.catchall instanceof fr){let u=this._def.unknownKeys;if(u==="passthrough")for(let c of i)a.push({key:{status:"valid",value:c},value:{status:"valid",value:n.data[c]}});else if(u==="strict"){if(i.length>0)F(n,{code:S.unrecognized_keys,keys:i}),r.dirty()}else if(u==="strip");else throw Error("Internal ZodObject error: invalid unknownKeys value.")}else{let u=this._def.catchall;for(let c of i){let f=n.data[c];a.push({key:{status:"valid",value:c},value:u._parse(new er(n,f,n.path,c)),alwaysSet:c in n.data})}}if(n.common.async)return Promise.resolve().then(async()=>{let u=[];for(let c of a){let f=await c.key,d=await c.value;u.push({key:f,value:d,alwaysSet:c.alwaysSet})}return u}).then((u)=>nt.mergeObjectSync(r,u));else return nt.mergeObjectSync(r,a)}get shape(){return this._def.shape()}strict(e){return K.errToObj,new ve({...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 ve({...this._def,unknownKeys:"strip"})}passthrough(){return new ve({...this._def,unknownKeys:"passthrough"})}extend(e){return new ve({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new ve({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:V.ZodObject})}setKey(e,t){return this.augment({[e]:t})}catchall(e){return new ve({...this._def,catchall:e})}pick(e){let t={};for(let r of fe.objectKeys(e))if(e[r]&&this.shape[r])t[r]=this.shape[r];return new ve({...this._def,shape:()=>t})}omit(e){let t={};for(let r of fe.objectKeys(this.shape))if(!e[r])t[r]=this.shape[r];return new ve({...this._def,shape:()=>t})}deepPartial(){return vn(this)}partial(e){let t={};for(let r of fe.objectKeys(this.shape)){let n=this.shape[r];if(e&&!e[r])t[r]=n;else t[r]=n.optional()}return new ve({...this._def,shape:()=>t})}required(e){let t={};for(let r of fe.objectKeys(this.shape))if(e&&!e[r])t[r]=this.shape[r];else{let o=this.shape[r];while(o instanceof Zt)o=o._def.innerType;t[r]=o}return new ve({...this._def,shape:()=>t})}keyof(){return uu(fe.objectKeys(this.shape))}}ve.create=(e,t)=>new ve({shape:()=>e,unknownKeys:"strip",catchall:fr.create(),typeName:V.ZodObject,...te(t)});ve.strictCreate=(e,t)=>new ve({shape:()=>e,unknownKeys:"strict",catchall:fr.create(),typeName:V.ZodObject,...te(t)});ve.lazycreate=(e,t)=>new ve({shape:e,unknownKeys:"strip",catchall:fr.create(),typeName:V.ZodObject,...te(t)});class zn extends se{_parse(e){let{ctx:t}=this._processInputParams(e),r=this._def.options;function n(o){for(let i of o)if(i.result.status==="valid")return i.result;for(let i of o)if(i.result.status==="dirty")return t.common.issues.push(...i.ctx.common.issues),i.result;let s=o.map((i)=>new xt(i.ctx.common.issues));return F(t,{code:S.invalid_union,unionErrors:s}),H}if(t.common.async)return Promise.all(r.map(async(o)=>{let s={...t,common:{...t.common,issues:[]},parent:null};return{result:await o._parseAsync({data:t.data,path:t.path,parent:s}),ctx:s}})).then(n);else{let o=void 0,s=[];for(let a of r){let u={...t,common:{...t.common,issues:[]},parent:null},c=a._parseSync({data:t.data,path:t.path,parent:u});if(c.status==="valid")return c;else if(c.status==="dirty"&&!o)o={result:c,ctx:u};if(u.common.issues.length)s.push(u.common.issues)}if(o)return t.common.issues.push(...o.ctx.common.issues),o.result;let i=s.map((a)=>new xt(a));return F(t,{code:S.invalid_union,unionErrors:i}),H}}get options(){return this._def.options}}zn.create=(e,t)=>new zn({options:e,typeName:V.ZodUnion,...te(t)});var Ar=(e)=>{if(e instanceof Jn)return Ar(e.schema);else if(e instanceof tr)return Ar(e.innerType());else if(e instanceof Wn)return[e.value];else if(e instanceof Hr)return e.options;else if(e instanceof Yn)return fe.objectValues(e.enum);else if(e instanceof Xn)return Ar(e._def.innerType);else if(e instanceof Gn)return[void 0];else if(e instanceof Hn)return[null];else if(e instanceof Zt)return[void 0,...Ar(e.unwrap())];else if(e instanceof Sr)return[null,...Ar(e.unwrap())];else if(e instanceof Is)return Ar(e.unwrap());else if(e instanceof Zn)return Ar(e.unwrap());else if(e instanceof Qn)return Ar(e._def.innerType);else return[]};class bs extends se{_parse(e){let{ctx:t}=this._processInputParams(e);if(t.parsedType!==M.object)return F(t,{code:S.invalid_type,expected:M.object,received:t.parsedType}),H;let r=this.discriminator,n=t.data[r],o=this.optionsMap.get(n);if(!o)return F(t,{code:S.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[r]}),H;if(t.common.async)return o._parseAsync({data:t.data,path:t.path,parent:t});else return o._parseSync({data:t.data,path:t.path,parent:t})}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,t,r){let n=new Map;for(let o of t){let s=Ar(o.shape[e]);if(!s.length)throw Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);for(let i of s){if(n.has(i))throw Error(`Discriminator property ${String(e)} has duplicate value ${String(i)}`);n.set(i,o)}}return new bs({typeName:V.ZodDiscriminatedUnion,discriminator:e,options:t,optionsMap:n,...te(r)})}}function gi(e,t){let r=cr(e),n=cr(t);if(e===t)return{valid:!0,data:e};else if(r===M.object&&n===M.object){let o=fe.objectKeys(t),s=fe.objectKeys(e).filter((a)=>o.indexOf(a)!==-1),i={...e,...t};for(let a of s){let u=gi(e[a],t[a]);if(!u.valid)return{valid:!1};i[a]=u.data}return{valid:!0,data:i}}else if(r===M.array&&n===M.array){if(e.length!==t.length)return{valid:!1};let o=[];for(let s=0;s<e.length;s++){let i=e[s],a=t[s],u=gi(i,a);if(!u.valid)return{valid:!1};o.push(u.data)}return{valid:!0,data:o}}else if(r===M.date&&n===M.date&&+e===+t)return{valid:!0,data:e};else return{valid:!1}}class Vn extends se{_parse(e){let{status:t,ctx:r}=this._processInputParams(e),n=(o,s)=>{if(hs(o)||hs(s))return H;let i=gi(o.value,s.value);if(!i.valid)return F(r,{code:S.invalid_intersection_types}),H;if(xs(o)||xs(s))t.dirty();return{status:t.value,value:i.data}};if(r.common.async)return Promise.all([this._def.left._parseAsync({data:r.data,path:r.path,parent:r}),this._def.right._parseAsync({data:r.data,path:r.path,parent:r})]).then(([o,s])=>n(o,s));else return n(this._def.left._parseSync({data:r.data,path:r.path,parent:r}),this._def.right._parseSync({data:r.data,path:r.path,parent:r}))}}Vn.create=(e,t,r)=>new Vn({left:e,right:t,typeName:V.ZodIntersection,...te(r)});class dr extends se{_parse(e){let{status:t,ctx:r}=this._processInputParams(e);if(r.parsedType!==M.array)return F(r,{code:S.invalid_type,expected:M.array,received:r.parsedType}),H;if(r.data.length<this._def.items.length)return F(r,{code:S.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),H;if(!this._def.rest&&r.data.length>this._def.items.length)F(r,{code:S.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),t.dirty();let o=[...r.data].map((s,i)=>{let a=this._def.items[i]||this._def.rest;if(!a)return null;return a._parse(new er(r,s,r.path,i))}).filter((s)=>!!s);if(r.common.async)return Promise.all(o).then((s)=>nt.mergeArray(t,s));else return nt.mergeArray(t,o)}get items(){return this._def.items}rest(e){return new dr({...this._def,rest:e})}}dr.create=(e,t)=>{if(!Array.isArray(e))throw Error("You must pass an array of schemas to z.tuple([ ... ])");return new dr({items:e,typeName:V.ZodTuple,rest:null,...te(t)})};class Po extends se{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!==M.object)return F(r,{code:S.invalid_type,expected:M.object,received:r.parsedType}),H;let n=[],o=this._def.keyType,s=this._def.valueType;for(let i in r.data)n.push({key:o._parse(new er(r,i,r.path,i)),value:s._parse(new er(r,r.data[i],r.path,i)),alwaysSet:i in r.data});if(r.common.async)return nt.mergeObjectAsync(t,n);else return nt.mergeObjectSync(t,n)}get element(){return this._def.valueType}static create(e,t,r){if(t instanceof se)return new Po({keyType:e,valueType:t,typeName:V.ZodRecord,...te(r)});return new Po({keyType:Xt.create(),valueType:e,typeName:V.ZodRecord,...te(t)})}}class Co extends se{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!==M.map)return F(r,{code:S.invalid_type,expected:M.map,received:r.parsedType}),H;let n=this._def.keyType,o=this._def.valueType,s=[...r.data.entries()].map(([i,a],u)=>({key:n._parse(new er(r,i,r.path,[u,"key"])),value:o._parse(new er(r,a,r.path,[u,"value"]))}));if(r.common.async){let i=new Map;return Promise.resolve().then(async()=>{for(let a of s){let u=await a.key,c=await a.value;if(u.status==="aborted"||c.status==="aborted")return H;if(u.status==="dirty"||c.status==="dirty")t.dirty();i.set(u.value,c.value)}return{status:t.value,value:i}})}else{let i=new Map;for(let a of s){let{key:u,value:c}=a;if(u.status==="aborted"||c.status==="aborted")return H;if(u.status==="dirty"||c.status==="dirty")t.dirty();i.set(u.value,c.value)}return{status:t.value,value:i}}}}Co.create=(e,t,r)=>new Co({valueType:t,keyType:e,typeName:V.ZodMap,...te(r)});class gn extends se{_parse(e){let{status:t,ctx:r}=this._processInputParams(e);if(r.parsedType!==M.set)return F(r,{code:S.invalid_type,expected:M.set,received:r.parsedType}),H;let n=this._def;if(n.minSize!==null){if(r.data.size<n.minSize.value)F(r,{code:S.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)F(r,{code:S.too_big,maximum:n.maxSize.value,type:"set",inclusive:!0,exact:!1,message:n.maxSize.message}),t.dirty()}let o=this._def.valueType;function s(a){let u=new Set;for(let c of a){if(c.status==="aborted")return H;if(c.status==="dirty")t.dirty();u.add(c.value)}return{status:t.value,value:u}}let i=[...r.data.values()].map((a,u)=>o._parse(new er(r,a,r.path,u)));if(r.common.async)return Promise.all(i).then((a)=>s(a));else return s(i)}min(e,t){return new gn({...this._def,minSize:{value:e,message:K.toString(t)}})}max(e,t){return new gn({...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)}}gn.create=(e,t)=>new gn({valueType:e,minSize:null,maxSize:null,typeName:V.ZodSet,...te(t)});class Dn extends se{constructor(){super(...arguments);this.validate=this.implement}_parse(e){let{ctx:t}=this._processInputParams(e);if(t.parsedType!==M.function)return F(t,{code:S.invalid_type,expected:M.function,received:t.parsedType}),H;function r(i,a){return ko({data:i,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,Kn(),kr].filter((u)=>!!u),issueData:{code:S.invalid_arguments,argumentsError:a}})}function n(i,a){return ko({data:i,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,Kn(),kr].filter((u)=>!!u),issueData:{code:S.invalid_return_type,returnTypeError:a}})}let o={errorMap:t.common.contextualErrorMap},s=t.data;if(this._def.returns instanceof hn){let i=this;return ut(async function(...a){let u=new xt([]),c=await i._def.args.parseAsync(a,o).catch((m)=>{throw u.addIssue(r(a,m)),u}),f=await Reflect.apply(s,this,c);return await i._def.returns._def.type.parseAsync(f,o).catch((m)=>{throw u.addIssue(n(f,m)),u})})}else{let i=this;return ut(function(...a){let u=i._def.args.safeParse(a,o);if(!u.success)throw new xt([r(a,u.error)]);let c=Reflect.apply(s,this,u.data),f=i._def.returns.safeParse(c,o);if(!f.success)throw new xt([n(c,f.error)]);return f.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new Dn({...this._def,args:dr.create(e).rest(Dr.create())})}returns(e){return new Dn({...this._def,returns:e})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,t,r){return new Dn({args:e?e:dr.create([]).rest(Dr.create()),returns:t||Dr.create(),typeName:V.ZodFunction,...te(r)})}}class Jn extends se{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})}}Jn.create=(e,t)=>new Jn({getter:e,typeName:V.ZodLazy,...te(t)});class Wn extends se{_parse(e){if(e.data!==this._def.value){let t=this._getOrReturnCtx(e);return F(t,{received:t.data,code:S.invalid_literal,expected:this._def.value}),H}return{status:"valid",value:e.data}}get value(){return this._def.value}}Wn.create=(e,t)=>new Wn({value:e,typeName:V.ZodLiteral,...te(t)});function uu(e,t){return new Hr({values:e,typeName:V.ZodEnum,...te(t)})}class Hr extends se{_parse(e){if(typeof e.data!=="string"){let t=this._getOrReturnCtx(e),r=this._def.values;return F(t,{expected:fe.joinValues(r),received:t.parsedType,code:S.invalid_type}),H}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 F(t,{received:t.data,code:S.invalid_enum_value,options:r}),H}return ut(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 Hr.create(e,{...this._def,...t})}exclude(e,t=this._def){return Hr.create(this.options.filter((r)=>!e.includes(r)),{...this._def,...t})}}Hr.create=uu;class Yn extends se{_parse(e){let t=fe.getValidEnumValues(this._def.values),r=this._getOrReturnCtx(e);if(r.parsedType!==M.string&&r.parsedType!==M.number){let n=fe.objectValues(t);return F(r,{expected:fe.joinValues(n),received:r.parsedType,code:S.invalid_type}),H}if(!this._cache)this._cache=new Set(fe.getValidEnumValues(this._def.values));if(!this._cache.has(e.data)){let n=fe.objectValues(t);return F(r,{received:r.data,code:S.invalid_enum_value,options:n}),H}return ut(e.data)}get enum(){return this._def.values}}Yn.create=(e,t)=>new Yn({values:e,typeName:V.ZodNativeEnum,...te(t)});class hn extends se{unwrap(){return this._def.type}_parse(e){let{ctx:t}=this._processInputParams(e);if(t.parsedType!==M.promise&&t.common.async===!1)return F(t,{code:S.invalid_type,expected:M.promise,received:t.parsedType}),H;let r=t.parsedType===M.promise?t.data:Promise.resolve(t.data);return ut(r.then((n)=>this._def.type.parseAsync(n,{path:t.path,errorMap:t.common.contextualErrorMap})))}}hn.create=(e,t)=>new hn({type:e,typeName:V.ZodPromise,...te(t)});class tr extends se{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===V.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){let{status:t,ctx:r}=this._processInputParams(e),n=this._def.effect||null,o={addIssue:(s)=>{if(F(r,s),s.fatal)t.abort();else t.dirty()},get path(){return r.path}};if(o.addIssue=o.addIssue.bind(o),n.type==="preprocess"){let s=n.transform(r.data,o);if(r.common.async)return Promise.resolve(s).then(async(i)=>{if(t.value==="aborted")return H;let a=await this._def.schema._parseAsync({data:i,path:r.path,parent:r});if(a.status==="aborted")return H;if(a.status==="dirty")return ln(a.value);if(t.value==="dirty")return ln(a.value);return a});else{if(t.value==="aborted")return H;let i=this._def.schema._parseSync({data:s,path:r.path,parent:r});if(i.status==="aborted")return H;if(i.status==="dirty")return ln(i.value);if(t.value==="dirty")return ln(i.value);return i}}if(n.type==="refinement"){let s=(i)=>{let a=n.refinement(i,o);if(r.common.async)return Promise.resolve(a);if(a instanceof Promise)throw Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return i};if(r.common.async===!1){let i=this._def.schema._parseSync({data:r.data,path:r.path,parent:r});if(i.status==="aborted")return H;if(i.status==="dirty")t.dirty();return s(i.value),{status:t.value,value:i.value}}else return this._def.schema._parseAsync({data:r.data,path:r.path,parent:r}).then((i)=>{if(i.status==="aborted")return H;if(i.status==="dirty")t.dirty();return s(i.value).then(()=>({status:t.value,value:i.value}))})}if(n.type==="transform")if(r.common.async===!1){let s=this._def.schema._parseSync({data:r.data,path:r.path,parent:r});if(!vr(s))return H;let i=n.transform(s.value,o);if(i instanceof Promise)throw Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:t.value,value:i}}else return this._def.schema._parseAsync({data:r.data,path:r.path,parent:r}).then((s)=>{if(!vr(s))return H;return Promise.resolve(n.transform(s.value,o)).then((i)=>({status:t.value,value:i}))});fe.assertNever(n)}}tr.create=(e,t,r)=>new tr({schema:e,typeName:V.ZodEffects,effect:t,...te(r)});tr.createWithPreprocess=(e,t,r)=>new tr({schema:t,effect:{type:"preprocess",transform:e},typeName:V.ZodEffects,...te(r)});class Zt extends se{_parse(e){if(this._getType(e)===M.undefined)return ut(void 0);return this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}Zt.create=(e,t)=>new Zt({innerType:e,typeName:V.ZodOptional,...te(t)});class Sr extends se{_parse(e){if(this._getType(e)===M.null)return ut(null);return this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}Sr.create=(e,t)=>new Sr({innerType:e,typeName:V.ZodNullable,...te(t)});class Xn extends se{_parse(e){let{ctx:t}=this._processInputParams(e),r=t.data;if(t.parsedType===M.undefined)r=this._def.defaultValue();return this._def.innerType._parse({data:r,path:t.path,parent:t})}removeDefault(){return this._def.innerType}}Xn.create=(e,t)=>new Xn({innerType:e,typeName:V.ZodDefault,defaultValue:typeof t.default==="function"?t.default:()=>t.default,...te(t)});class Qn extends se{_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(Bn(n))return n.then((o)=>({status:"valid",value:o.status==="valid"?o.value:this._def.catchValue({get error(){return new xt(r.common.issues)},input:r.data})}));else return{status:"valid",value:n.status==="valid"?n.value:this._def.catchValue({get error(){return new xt(r.common.issues)},input:r.data})}}removeCatch(){return this._def.innerType}}Qn.create=(e,t)=>new Qn({innerType:e,typeName:V.ZodCatch,catchValue:typeof t.catch==="function"?t.catch:()=>t.catch,...te(t)});class To extends se{_parse(e){if(this._getType(e)!==M.nan){let r=this._getOrReturnCtx(e);return F(r,{code:S.invalid_type,expected:M.nan,received:r.parsedType}),H}return{status:"valid",value:e.data}}}To.create=(e)=>new To({typeName:V.ZodNaN,...te(e)});var ny=Symbol("zod_brand");class Is extends se{_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 Fo extends se{_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 H;if(o.status==="dirty")return t.dirty(),ln(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 H;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 Fo({in:e,out:t,typeName:V.ZodPipeline})}}class Zn extends se{_parse(e){let t=this._def.innerType._parse(e),r=(n)=>{if(vr(n))n.value=Object.freeze(n.value);return n};return Bn(t)?t.then((n)=>r(n)):r(t)}unwrap(){return this._def.innerType}}Zn.create=(e,t)=>new Zn({innerType:e,typeName:V.ZodReadonly,...te(t)});function ou(e,t){let r=typeof e==="function"?e(t):typeof e==="string"?{message:e}:e;return typeof r==="string"?{message:r}:r}function cu(e,t={},r){if(e)return yn.create().superRefine((n,o)=>{let s=e(n);if(s instanceof Promise)return s.then((i)=>{if(!i){let a=ou(t,n),u=a.fatal??r??!0;o.addIssue({code:"custom",...a,fatal:u})}});if(!s){let i=ou(t,n),a=i.fatal??r??!0;o.addIssue({code:"custom",...i,fatal:a})}return});return yn.create()}var oy={object:ve.lazycreate},V;(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"})(V||(V={}));var sy=(e,t={message:`Input not instance of ${e.name}`})=>cu((r)=>r instanceof e,t),fu=Xt.create,du=qr.create,iy=To.create,ay=Gr.create,pu=qn.create,uy=mn.create,cy=Ao.create,fy=Gn.create,dy=Hn.create,py=yn.create,ly=Dr.create,my=fr.create,yy=So.create,gy=Qt.create,{create:hy,strictCreate:xy}=ve,by=zn.create,Iy=bs.create,_y=Vn.create,Ry=dr.create,Oy=Po.create,wy=Co.create,$y=gn.create,ky=Dn.create,Ay=Jn.create,Sy=Wn.create,Py=Hr.create,Cy=Yn.create,Ty=hn.create,Fy=tr.create,Ny=Zt.create,jy=Sr.create,My=tr.createWithPreprocess,Ey=Fo.create,Ly=()=>fu().optional(),Uy=()=>du().optional(),Ky=()=>pu().optional(),By={string:(e)=>Xt.create({...e,coerce:!0}),number:(e)=>qr.create({...e,coerce:!0}),boolean:(e)=>qn.create({...e,coerce:!0}),bigint:(e)=>Gr.create({...e,coerce:!0}),date:(e)=>mn.create({...e,coerce:!0})};var vy=H;var Dy=_s,We=(e,t=400)=>Response.json(e,{status:t,headers:{"Content-Type":"application/json"}}),hi=(e)=>{let t=$o.Compile(e),r=async(n,o)=>{try{let s=n instanceof Object&&"req"in n,i=s?await n.jsonBody():await n.json();if(!t.Check(i)){let a=t.Errors(i).First();return We({status:"error",code:"VALIDATION_FAILED",message:a?.message||"Invalid input",path:a?.path||"body"})}if(s)n.body=i;return o?o():void 0}catch(s){if(s?.status===413)return We({status:"error",code:"PAYLOAD_TOO_LARGE",message:"Payload Too Large"},413);return We({status:"error",message:"Malformed JSON payload"})}};return r.__schema=e,r},xi=(e)=>{let t=gu(e),r=async(n,o)=>{try{let s=n instanceof Object&&"req"in n,i=s?await n.jsonBody():await n.json(),a=t(i);if(!a.ok)return We({status:"error",code:a.error?.code||"TYPE_MISMATCH",message:a.error?.message||"Validation failed",...a.error?.path?{field:a.error.path}:{}});if(s)n.body=a.data;return o?o():void 0}catch(s){if(s?.status===413)return We({status:"error",code:"PAYLOAD_TOO_LARGE",message:"Payload Too Large"},413);return We({status:"error",message:"Invalid JSON payload"})}};return r.__schema=e,r},mu=(e)=>{let t=async(r,n)=>{try{let o=r instanceof Object&&"req"in r,s=o?await r.jsonBody():await r.json(),i=await e.safeParseAsync(s);if(!i.success)return We({status:"error",code:"ZOD_ERROR",errors:i.error.flatten()});if(o)r.body=i.data;return n?n():void 0}catch(o){if(o?.status===413)return We({status:"error",code:"PAYLOAD_TOO_LARGE",message:"Payload Too Large"},413);return We({status:"error",message:"Invalid JSON payload"})}};return t.__schema=e,t},qy=(e)=>{if(e&&"_def"in e)return mu(e);if(e&&(e.kind||e[Symbol.for("TypeBox.Kind")]))return hi(e);if(e&&e.type)try{return hi(e)}catch{return xi(e)}return xi(e)};var yu=(e,t)=>{if(t===void 0)return!0;if(Array.isArray(t))return t.some((r)=>yu(e,r));if(t==="array")return Array.isArray(e);if(t==="integer")return typeof e==="number"&&Number.isInteger(e);if(t==="number")return typeof e==="number"&&Number.isFinite(e);if(t==="object")return e!==null&&typeof e==="object"&&!Array.isArray(e);if(t==="null")return e===null;return typeof e===t},No=(e,t)=>{if(e===t)return!0;if(typeof e!=="object"||typeof t!=="object"||e===null||t===null)return!1;if(Array.isArray(e)!==Array.isArray(t))return!1;if(Array.isArray(e)){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(!No(e[n],t[n]))return!1;return!0}let r=Object.keys(e);if(r.length!==Object.keys(t).length)return!1;for(let n=0;n<r.length;n++){let o=r[n];if(!Object.hasOwn(t,o)||!No(e[o],t[o]))return!1}return!0},pr=(e,t,r,n)=>{if(!t||typeof t!=="object")return{ok:!0};if(Object.hasOwn(t,"const")&&!No(e,t.const))return{ok:!1,error:{message:`Value at '${r||"root"}' must equal ${JSON.stringify(t.const)}`,path:r}};if(Array.isArray(t.enum)&&!t.enum.some((o)=>No(o,e)))return{ok:!1,error:{message:`Value at '${r||"root"}' must be one of enum values`,path:r}};if(t.not&&typeof t.not==="object"&&pr(e,t.not,r,!1).ok)return{ok:!1,error:{message:`Value at '${r||"root"}' must not match the 'not' schema`,path:r}};if(Array.isArray(t.allOf))for(let o=0;o<t.allOf.length;o++){let s=pr(e,t.allOf[o],r,!1);if(!s.ok)return s}if(Array.isArray(t.anyOf)){let o=!1;for(let s=0;s<t.anyOf.length;s++)if(pr(e,t.anyOf[s],r,!1).ok){o=!0;break}if(!o)return{ok:!1,error:{message:`Value at '${r||"root"}' failed anyOf constraint`,path:r}}}if(Array.isArray(t.oneOf)){let o=0;for(let s=0;s<t.oneOf.length;s++)if(pr(e,t.oneOf[s],r,!1).ok)o++;if(o!==1)return{ok:!1,error:{message:`Value at '${r||"root"}' must match exactly one schema in oneOf`,path:r}}}if(!yu(e,t.type))return{ok:!1,error:{message:r?`Field '${r}' must be of type ${t.type}`:`Expected type ${t.type}`,path:r}};if(typeof e==="number"){if(typeof t.minimum==="number"&&e<t.minimum)return{ok:!1,error:{message:`Field '${r}' must be >= ${t.minimum}`,path:r}};if(typeof t.maximum==="number"&&e>t.maximum)return{ok:!1,error:{message:`Field '${r}' must be <= ${t.maximum}`,path:r}};if(typeof t.multipleOf==="number"&&t.multipleOf>0){let o=e/t.multipleOf;if(Math.abs(o-Math.round(o))>0.000000001*Math.max(1,Math.abs(o)))return{ok:!1,error:{message:`Field '${r}' must be a multiple of ${t.multipleOf}`,path:r}}}if(typeof t.exclusiveMinimum==="number"&&e<=t.exclusiveMinimum)return{ok:!1,error:{message:`Field '${r}' must be > ${t.exclusiveMinimum}`,path:r}};if(typeof t.exclusiveMaximum==="number"&&e>=t.exclusiveMaximum)return{ok:!1,error:{message:`Field '${r}' must be < ${t.exclusiveMaximum}`,path:r}}}if(typeof e==="string"){if(typeof t.minLength==="number"&&e.length<t.minLength)return{ok:!1,error:{message:`Field '${r}' length must be >= ${t.minLength}`,path:r}};if(typeof t.maxLength==="number"&&e.length>t.maxLength)return{ok:!1,error:{message:`Field '${r}' length must be <= ${t.maxLength}`,path:r}};if(typeof t.pattern==="string")try{if(!new RegExp(t.pattern).test(e))return{ok:!1,error:{message:`Field '${r}' does not match pattern`,path:r}}}catch{}}if(Array.isArray(e)){if(typeof t.minItems==="number"&&e.length<t.minItems)return{ok:!1,error:{message:`Field '${r}' must have at least ${t.minItems} items`,path:r}};if(typeof t.maxItems==="number"&&e.length>t.maxItems)return{ok:!1,error:{message:`Field '${r}' must have at most ${t.maxItems} items`,path:r}};if(t.uniqueItems===!0){for(let o=1;o<e.length;o++)for(let s=0;s<o;s++)if(No(e[o],e[s]))return{ok:!1,error:{message:`Field '${r}' must have unique items`,path:r}}}if(Array.isArray(t.items)){let o=Math.min(e.length,t.items.length);for(let s=0;s<o;s++){let i=pr(e[s],t.items[s],r?`${r}[${s}]`:`[${s}]`,!1);if(!i.ok)return i}}else if(t.items&&typeof t.items==="object")for(let o=0;o<e.length;o++){let s=pr(e[o],t.items,r?`${r}[${o}]`:`[${o}]`,!1);if(!s.ok)return s}}if(e!==null&&typeof e==="object"&&!Array.isArray(e)){let o=t.properties&&typeof t.properties==="object"?t.properties:null,s=Array.isArray(t.required)?t.required:null,i=s?new Set(s):null;if(typeof t.minProperties==="number"||typeof t.maxProperties==="number"){let u=Object.keys(e).length;if(typeof t.minProperties==="number"&&u<t.minProperties)return{ok:!1,error:{message:`Object at '${r||"root"}' must have at least ${t.minProperties} properties`,path:r}};if(typeof t.maxProperties==="number"&&u>t.maxProperties)return{ok:!1,error:{message:`Object at '${r||"root"}' must have at most ${t.maxProperties} properties`,path:r}}}if(s)for(let u=0;u<s.length;u++){let c=s[u];if(!Object.hasOwn(e,c)||e[c]===void 0){let f=o?.[c]?.type;return{ok:!1,error:{message:f?`Field '${c}' must be of type ${f}`:`Missing required field '${c}'`,path:r?`${r}.${c}`:c}}}}if(o){let u=Object.keys(o);for(let c=0;c<u.length;c++){let f=u[c];if(!(Object.hasOwn(e,f)&&e[f]!==void 0)){if(n&&!i)return{ok:!1,error:{message:`Field '${f}' must be of type ${o[f]?.type}`,path:r?`${r}.${f}`:f}};continue}let m=r?`${r}.${f}`:f,y=pr(e[f],o[f],m,!1);if(!y.ok)return y}}let a=new Set;if(t.patternProperties&&typeof t.patternProperties==="object"){let u=Object.keys(e);for(let[c,f]of Object.entries(t.patternProperties)){let d;try{d=new RegExp(c)}catch{continue}for(let m=0;m<u.length;m++){let y=u[m];if(!d.test(y))continue;a.add(y);let p=pr(e[y],f,r?`${r}.${y}`:y,!1);if(!p.ok)return p}}}if(t.dependentRequired&&typeof t.dependentRequired==="object")for(let[u,c]of Object.entries(t.dependentRequired)){if(!Object.hasOwn(e,u)||!Array.isArray(c))continue;for(let f of c)if(!Object.hasOwn(e,f))return{ok:!1,error:{message:`Field '${f}' is required when '${u}' is present`,path:r?`${r}.${f}`:f}}}if(t.additionalProperties===!1){let u=Object.keys(e);for(let c=0;c<u.length;c++){let f=u[c];if((!o||!Object.hasOwn(o,f))&&!a.has(f))return{ok:!1,error:{code:"ADDITIONAL_PROPERTIES",message:`Unknown field '${f}' is not allowed`,path:r?`${r}.${f}`:f}}}}else if(t.additionalProperties&&typeof t.additionalProperties==="object"){let u=Object.keys(e);for(let c=0;c<u.length;c++){let f=u[c];if((!o||!Object.hasOwn(o,f))&&!a.has(f)){let d=pr(e[f],t.additionalProperties,r?`${r}.${f}`:f,!1);if(!d.ok)return d}}}}return{ok:!0}},gu=(e)=>{let t=Boolean(e?.anyOf||e?.oneOf||e?.allOf),r=!t&&!Array.isArray(e?.required)&&Boolean(e?.properties),n=!e?.type||e.type==="object";return(o)=>{if(!e||typeof e!=="object")return!o||typeof o!=="object"||Array.isArray(o)?{ok:!1,error:{message:"Invalid JSON object payload"}}:{ok:!0,data:o};if(n&&(!o||typeof o!=="object"||Array.isArray(o))&&!t)return{ok:!1,error:{message:"Invalid JSON object payload"}};let s=pr(o,e,"",r);return s.ok?{ok:!0,data:o}:s}},eo=(e)=>{if(e&&"_def"in e)return(t)=>{let r=e.safeParse(t);return r.success?{ok:!0,data:r.data}:{ok:!1,error:r.error.flatten()}};try{let t=$o.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}}}}catch{return gu(e)}},hu=(e,t,r,n,o)=>{if(!e)return null;let s=`ar_${n}_${o}`,i=`j_${n}_${o}`,a=`ai_${n}_${o}`;if(e.type==="array"&&e.items){let f=hu(e.items,a,`${s}[${i}] = `,n+1,o+1);if(f===null)return null;return`if (Array.isArray(${t})) {
8
+ const ${s} = new Array(${t}.length);
9
+ for (let ${i} = 0; ${i} < ${t}.length; ${i}++) {
10
+ const ${a} = ${t}[${i}];
11
+ ${f}
12
+ }
13
+ ${r}${s};
14
+ } else {
15
+ ${r}${t};
16
+ }`}let u=`ao_${n}_${o}`,c=Os(e,a,u,n+1);if(c===null)return null;return`if (Array.isArray(${t})) {
17
+ const ${s} = new Array(${t}.length);
18
+ for (let ${i} = 0; ${i} < ${t}.length; ${i}++) {
19
+ const ${a} = ${t}[${i}];
20
+ if (${a} && typeof ${a} === 'object' && !Array.isArray(${a})) {
21
+ const ${u} = {};
22
+ ${c} ${s}[${i}] = ${u};
23
+ } else {
24
+ ${s}[${i}] = ${a};
25
+ }
26
+ }
27
+ ${r}${s};
28
+ } else {
29
+ ${r}${t};
30
+ }`},Os=(e,t,r,n=0)=>{let o=e?.properties;if(!o||typeof o!=="object")return null;let s="",i=0;for(let[a,u]of Object.entries(o)){if(a==="__proto__"||a==="constructor"||a==="prototype")continue;let c=JSON.stringify(a),f=`v_${n}_${i++}`,d=`d_${n}_${i}`;if(s+=`const ${f} = Object.hasOwn(${t}, ${c}) ? ${t}[${c}] : undefined;
31
+ `,u?.type==="array"&&u?.items){let y=hu(u.items,f,`${r}[${c}] = `,n,i);if(y!==null){s+=`if (${f} !== undefined) {
32
+ ${y}
33
+ }
34
+ `;continue}}let m=Os(u,f,d,n+1);if(m!==null)s+=`if (${f} !== undefined) {
35
+ `,s+=` if (${f} && typeof ${f} === 'object' && !Array.isArray(${f})) {
36
+ `,s+=` const ${d} = {};
37
+ ${m} ${r}[${c}] = ${d};
12
38
  `,s+=` } else {
13
- ${r}[${c}] = ${d};
39
+ ${r}[${c}] = ${f};
14
40
  }
15
41
  }
16
- `;else s+=`if (${d} !== undefined) ${r}[${c}] = ${d};
17
- `}return s},oc=(e)=>{if(!e||"_def"in e)return null;if(e.type==="array"&&e.items){let r=ni(e.items,"item","outItem");if(!r)return null;return Function(`return function(arr) {
42
+ `;else s+=`if (${f} !== undefined) ${r}[${c}] = ${f};
43
+ `}return s},bi=(e)=>{if(!e||typeof e!=="object")return!1;if(Array.isArray(e.anyOf)||Array.isArray(e.oneOf)||Array.isArray(e.allOf))return!0;if(e.additionalProperties&&typeof e.additionalProperties==="object")return!0;if(e.patternProperties&&typeof e.patternProperties==="object")return!0;if(Array.isArray(e.items))return!0;if(e.type==="array"&&e.items)return bi(e.items);if(e.properties&&typeof e.properties==="object"){for(let t of Object.values(e.properties))if(bi(t))return!0}return!1},xu=(e,t)=>{let r=!1;if(e?.properties&&typeof e.properties==="object")Object.assign(t,e.properties),r=!0;if(Array.isArray(e?.allOf)){for(let n of e.allOf)if(xu(n,t))r=!0}return r},Mt=(e,t)=>{if(!t||typeof t!=="object"||e===null||typeof e!=="object")return e;if(Array.isArray(e)){if(Array.isArray(t.items))return e.map((i,a)=>t.items[a]?Mt(i,t.items[a]):i);if(t.items&&typeof t.items==="object")return e.map((i)=>Mt(i,t.items));return e}let r=t.anyOf||t.oneOf;if(Array.isArray(r)&&r.length>0){let i=null;for(let a of r)if(a&&typeof a==="object"&&eo(a)(e).ok){i=a;break}if(i){if(t.properties&&typeof t.properties==="object"){let a={...t.properties,...i.properties||{}},u={};for(let[c,f]of Object.entries(a)){if(c==="__proto__"||c==="constructor"||c==="prototype")continue;if(Object.hasOwn(e,c)&&e[c]!==void 0)u[c]=Mt(e[c],f)}return u}return Mt(e,i)}if(!t.properties)return e}if(Array.isArray(t.allOf)){let i={};if(xu(t,i)){let a={};for(let[u,c]of Object.entries(i)){if(u==="__proto__"||u==="constructor"||u==="prototype")continue;if(Object.hasOwn(e,u)&&e[u]!==void 0)a[u]=Mt(e[u],c)}return a}}let n=Boolean(t.properties&&typeof t.properties==="object"),o=Boolean(t.patternProperties&&typeof t.patternProperties==="object"),s=Boolean(t.additionalProperties&&typeof t.additionalProperties==="object");if(n||o||s){let i={},a=n?t.properties:null;if(a)for(let[u,c]of Object.entries(a)){if(u==="__proto__"||u==="constructor"||u==="prototype")continue;if(Object.hasOwn(e,u)&&e[u]!==void 0)i[u]=Mt(e[u],c)}if(o||s){let u=o?Object.entries(t.patternProperties).map(([c,f])=>({re:new RegExp(c),sub:f})):[];for(let c of Object.keys(e)){if(c==="__proto__"||c==="constructor"||c==="prototype")continue;if(e[c]===void 0||a&&Object.hasOwn(a,c))continue;let f=!1;for(let d=0;d<u.length;d++)if(u[d].re.test(c)){i[c]=Mt(e[c],u[d].sub),f=!0;break}if(!f&&s)i[c]=Mt(e[c],t.additionalProperties)}}return i}return e},Rs=(e)=>{if(!e||"_def"in e)return null;if(bi(e))return(r)=>Mt(r,e);if(e.type==="array"&&e.items){if(e.items.type==="array")return(n)=>Mt(n,e);let r=Os(e.items,"item","outItem");if(r===null)return(n)=>Mt(n,e);return Function(`return function(arr) {
18
44
  if (!Array.isArray(arr)) return arr;
19
45
  const len = arr.length;
20
46
  const out = new Array(len);
@@ -29,58 +55,64 @@ ${p} ${r}[${c}] = ${f};
29
55
  }
30
56
  }
31
57
  return out;
32
- }`)()}let t=ni(e,"o","out");if(!t)return null;return Function(`return function(o) {
58
+ }`)()}let t=Os(e,"o","out");if(t===null)return(r)=>Mt(r,e);return Function(`return function(o) {
33
59
  if (!o || typeof o !== 'object' || Array.isArray(o)) return o;
34
60
  const out = {};
35
61
  ${t}
36
62
  return out;
37
- }`)()},sc=(e)=>{let t=_o(e),r=oc(e);return(n)=>{if(n instanceof Response)return n;let o=r?r(n):n,s=t(o);if(!s.ok)return Je({status:"error",code:"RESPONSE_VALIDATION_FAILED",error:s.error},500);return s.data}},Py=(e)=>{let t=e;while(t?._def&&(t._def.typeName==="ZodOptional"||t._def.typeName==="ZodDefault"||t._def.typeName==="ZodNullable"))t=t._def.innerType;return t?.type||t?._def?.typeName},ec=(e,t)=>{let r=t?.properties||(t?._def?.shape?typeof t._def.shape==="function"?t._def.shape():t._def.shape:null);if(!r)return e;let n={...e};for(let[o,s]of Object.entries(r)){if(!Object.hasOwn(n,o))continue;let i=n[o];if(typeof i!=="string")continue;let a=Py(s);if(a==="number"||a==="integer"||a==="ZodNumber"){if(i.trim()!==""){let u=Number(i);if(Number.isFinite(u))n[o]=u}}else if(a==="boolean"||a==="ZodBoolean"){if(i==="true")n[o]=!0;else if(i==="false")n[o]=!1}}return n},oi=(e)=>{let t=e.body?_o(e.body):null,r=e.query?_o(e.query):null,n=e.params?_o(e.params):null,o=e.headers?_o(e.headers):null,s=e.stripUnknown&&e.body?oc(e.body):null,i=e.response?sc(e.response):null,a=e.maxBodySize??1048576,u=Boolean(n||r||o),c=(f)=>{if(n){let p=ec(f.params,e.params),y=n(p);if(!y.ok)return Je({status:"error",code:"PARAMS_INVALID",error:y.error});f.params=y.data}if(r){let p=ec(f.query,e.query),y=r(p);if(!y.ok)return Je({status:"error",code:"QUERY_INVALID",error:y.error});f._query=y.data}if(o){let p={};f.req.headers.forEach((b,P)=>{p[P.toLowerCase()]=b});let y=o(p);if(!y.ok)return Je({status:"error",code:"HEADERS_INVALID",error:y.error})}return};if(!t){let f=(p,y)=>{if(u){let b=c(p);if(b)return b}return y?y():void 0};if(f.__routeSchemas=e,i)f.__responseFilter=i;return f}let d=async(f,p)=>{if(u){let P=c(f);if(P)return P}let y;try{y=await f.jsonBody(a)}catch(P){if(P?.status===413)return Je({status:"error",code:"PAYLOAD_TOO_LARGE",message:"Payload Too Large"},413);return Je({status:"error",message:"Malformed JSON payload"})}let b=t(y);if(!b.ok)return Je({status:"error",code:"VALIDATION_FAILED",error:b.error});return f.body=s?s(b.data):b.data,p?p():void 0};if(d.__schema=e.body,d.__routeSchemas=e,i)d.__responseFilter=i;return d};class cn{prefix;groupMiddleware;routes=[];constructor(e="",t=[]){this.prefix=e;this.groupMiddleware=t}_add(e,t,r){let n=(this.prefix+"/"+t).replace(/\/+/g,"/");if(n.endsWith("/"))n=n.slice(0,-1);let o=[];for(let s=0;s<r.length;s++){let i=r[s];if(typeof i==="function")o.push(i);else if(i&&typeof i==="object")o.push(oi(i))}return this.routes.push({method:e.toUpperCase(),path:n||"",handlers:[...this.groupMiddleware,...o]}),this}get=(e,...t)=>this._add("GET",e,t);post=(e,...t)=>this._add("POST",e,t);put=(e,...t)=>this._add("PUT",e,t);patch=(e,...t)=>this._add("PATCH",e,t);delete=(e,...t)=>this._add("DELETE",e,t);options=(e,...t)=>this._add("OPTIONS",e,t);head=(e,...t)=>this._add("HEAD",e,t);all=(e,...t)=>{for(let r of["GET","POST","PUT","PATCH","DELETE","OPTIONS","HEAD"])this._add(r,e,t);return this};group=(e,...t)=>{let r=t.pop(),n=t,o=(this.prefix+"/"+e).replace(/\/+/g,"/"),s=new cn(o,[...this.groupMiddleware,...n]);return r(s),this.routes.push(...s.routes),this};_mountRouter(e,t){let r=(this.prefix+"/"+e).replace(/\/+/g,"/").replace(/\/$/,"");for(let n of t.routes){let o=(r+"/"+n.path).replace(/\/+/g,"/");if(o.endsWith("/"))o=o.slice(0,-1);this.routes.push({method:n.method,path:o||"",handlers:[...this.groupMiddleware,...n.handlers]})}}route(e,t){return this._mountRouter(e,t),this}use(e,t){if(typeof e==="string"&&(t instanceof cn||t&&t.routes))this._mountRouter(e,t);else if(e instanceof cn||e&&e.routes)this._mountRouter("",e);else if(e&&typeof e.install==="function")e.install(this);else this.groupMiddleware.push(e);return this}}class un{children={};staticKeys=[];paramNode=null;paramName=null;wildcardNode=null;handlers={};insert(e,t,r){let n=this,o=e.split("/").filter(Boolean);for(let s of o)if(s==="*"){if(!n.wildcardNode)n.wildcardNode=new un;n=n.wildcardNode;break}else if(s.startsWith(":")){if(!n.paramNode)n.paramNode=new un;n.paramName=s.slice(1),n=n.paramNode}else{if(!n.children[s])n.children[s]=new un,n.staticKeys.push(s);n=n.children[s]}n.handlers[t]=r}lookup(e,t,r,n){let o=this,s=r===-1?0:r,i=t.length;if(t[s]==="/")s++;for(let a in n.params)delete n.params[a];while(s<i){let a=t.indexOf("/",s);if(a===-1)a=i;let u=a-s,c=!1,d=o.staticKeys,f=d.length;if(f===1){let p=d[0];if(p.length===u){let y=!0;for(let b=0;b<u;b++)if(p[b]!==t[s+b]){y=!1;break}if(y)o=o.children[p],c=!0}}else for(let p=0;p<f;p++){let y=d[p];if(y.length===u){let b=!0;for(let P=0;P<u;P++)if(y[P]!==t[s+P]){b=!1;break}if(b){o=o.children[y],c=!0;break}}}if(!c)if(o.paramNode)n.params[o.paramName]=t.slice(s,a),o=o.paramNode;else if(o.wildcardNode)return n.params["*"]=t.slice(s),o.wildcardNode.handlers[e]||null;else return null;s=a+1}return o.handlers[e]||null}jitCompile(e,t=0,r="url",n="s",o=[]){let s="",i=" ".repeat(t);if(Object.keys(this.handlers).length>0){if(s+=`${i}if (${n} >= urlLen) {
38
- `,o.length>0){let a=o.map((u)=>`${JSON.stringify(u.name)}: ${u.varName}`).join(", ");s+=`${i} ctx.params = { ${a} };
39
- `}s+=`${i} switch(method) {
40
- `;for(let[a,u]of Object.entries(this.handlers)){let c=e(u);s+=`${i} case ${JSON.stringify(a)}: return ${c}(ctx);
41
- `}s+=`${i} }
42
- `,s+=`${i}}
43
- `}if(this.staticKeys.length>0)if(this.staticKeys.length===1){let a=this.staticKeys[0],u=a.length,c=`nextIdxL${t}`;s+=`${i}if (${r}.startsWith(${JSON.stringify(a)}, ${n})) {
44
- `,s+=`${i} const ${c} = ${n} + ${u};
45
- `,s+=`${i} if (${c} === urlLen || ${r}.charCodeAt(${c}) === 47) {
46
- `;let d=this.children[a],f=`newIdxL${t}`;s+=`${i} const ${f} = ${c} === urlLen ? urlLen : (${c} + 1);
47
- `,s+=d.jitCompile(e,t+1,r,f,o),s+=`${i} }
48
- `,s+=`${i}}
49
- `}else if(this.staticKeys.length>4){s+=`${i}let slash${t} = ${r}.indexOf('/', ${n});
50
- `,s+=`${i}if (slash${t} === -1 || slash${t} > urlLen) slash${t} = urlLen;
51
- `,s+=`${i}switch (${r}.slice(${n}, slash${t})) {
52
- `;for(let a of this.staticKeys){s+=`${i} case ${JSON.stringify(a)}: {
53
- `;let u=this.children[a];s+=u.jitCompile(e,t+1,r,`slash${t} + 1`,o),s+=`${i} break;
54
- `,s+=`${i} }
55
- `}s+=`${i}}
56
- `}else{s+=`${i}let slash${t} = ${r}.indexOf('/', ${n});
57
- `,s+=`${i}if (slash${t} === -1 || slash${t} > urlLen) slash${t} = urlLen;
58
- `,s+=`${i}const len${t} = slash${t} - (${n});
59
-
60
- `;let a=new Map;for(let u of this.staticKeys){let c=a.get(u.length);if(!c)c=[],a.set(u.length,c);c.push(u)}s+=`${i}switch(len${t}) {
61
- `;for(let[u,c]of a){s+=`${i} case ${u}:
62
- `;for(let d of c){if(u===1)s+=`${i} if (${r}.charCodeAt(${n}) === ${d.charCodeAt(0)}) {
63
- `;else s+=`${i} if (${r}.startsWith(${JSON.stringify(d)}, ${n})) {
64
- `;let f=this.children[d];s+=f.jitCompile(e,t+1,r,`slash${t} + 1`,o),s+=`${i} }
65
- `}s+=`${i} break;
66
- `}s+=`${i}}
67
- `}if(this.paramNode){let a=this.paramNode;if(this.staticKeys.length<=1)s+=`${i}let slash${t} = ${r}.indexOf('/', ${n});
68
- `,s+=`${i}if (slash${t} === -1 || slash${t} > urlLen) slash${t} = urlLen;
69
- `;let u=`pL${t}`;s+=`${i}if (slash${t} > ${n}) {
70
- `,s+=`${i} const ${u} = ${r}.slice(${n}, slash${t});
71
- `;let c=[...o,{name:this.paramName,varName:u}];s+=a.jitCompile(e,t+1,r,`slash${t} + 1`,c),s+=`${i}}
72
- `}if(this.wildcardNode&&Object.keys(this.wildcardNode.handlers).length>0){let a=`wL${t}`;s+=`${i}const ${a} = ${r}.slice(${n}, urlLen);
73
- `;let c=[...o,{name:"*",varName:a}].map((d)=>`${JSON.stringify(d.name)}: ${d.varName}`).join(", ");s+=`${i}ctx.params = { ${c} };
74
- `,s+=`${i}switch(method) {
75
- `;for(let[d,f]of Object.entries(this.wildcardNode.handlers)){let p=e(f);s+=`${i} case ${JSON.stringify(d)}: return ${p}(ctx);
76
- `}s+=`${i}}
77
- `}return s}id=Math.random().toString(36).slice(2)}import{createHmac as ic,timingSafeEqual as Ay}from"crypto";class Oo{req;params={};_status=200;_headers=void 0;store=new Map;body=void 0;_query=void 0;_cookies=void 0;_setCookies=void 0;_requestId=void 0;_peerIp=void 0;_trustProxy=!1;_detached=!1;constructor(e=!1){this._trustProxy=e}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,s=t.indexOf("+",n)!==-1,i=t.indexOf("%",n)!==-1;while(n<o){let a=t.indexOf("&",n);if(a===-1)a=o;if(a>n){let u=t.indexOf("=",n),c,d;if(u!==-1&&u<a)c=t.slice(n,u),d=t.slice(u+1,a);else c=t.slice(n,a),d="";if(s){if(c.indexOf("+")!==-1)c=c.replaceAll("+"," ");if(d.indexOf("+")!==-1)d=d.replaceAll("+"," ")}if(i){if(c.indexOf("%")!==-1)try{c=decodeURIComponent(c)}catch{}if(d.indexOf("%")!==-1)try{d=decodeURIComponent(d)}catch{}}if(c!=="__proto__"&&c!=="constructor"&&c!=="prototype")e[c]=d}n=a+1}}}return this._query=e,e}getQuery(e){let t=this.query;return Object.hasOwn(t,e)?t[e]:void 0}get cookies(){if(this._cookies!==void 0)return this._cookies;let e={},t=this.req?.headers?.get("cookie");if(t){let r=0,n=t.length;while(r<n){let o=t.indexOf(";",r);if(o===-1)o=n;let s=t.indexOf("=",r);if(s!==-1&&s<o){let i=t.slice(r,s).trim(),a=t.slice(s+1,o).trim();try{a=decodeURIComponent(a)}catch{}if(i&&i!=="__proto__"&&i!=="constructor"&&i!=="prototype")e[i]=a}r=o+1}}return this._cookies=e,e}setCookie(e,t,r={}){if(!e||/[\r\n;= \t]/.test(e))throw Error("Invalid cookie name");let n=r.path??"/";if(/[\r\n;]/.test(n))throw Error("Invalid cookie path");if(r.domain&&/[\r\n;]/.test(r.domain))throw Error("Invalid cookie domain");let o=t;if(r.secret){let i=ic("sha256",r.secret).update(t).digest("base64url");o=`${t}.${i}`}let s=`${e}=${encodeURIComponent(o)}`;if(s+=`; Path=${n}`,r.domain)s+=`; Domain=${r.domain}`;if(r.maxAge!==void 0)s+=`; Max-Age=${Math.floor(r.maxAge)}`;if(r.expires)s+=`; Expires=${r.expires.toUTCString()}`;if(r.httpOnly!==!1)s+="; HttpOnly";if(r.secure)s+="; Secure";if(s+=`; SameSite=${r.sameSite??"Lax"}`,!this._setCookies)this._setCookies=[];return this._setCookies.push(s),this}getSignedCookie(e,t){let r=this.cookies[e];if(!r)return null;let n=r.lastIndexOf(".");if(n<=0)return null;let o=r.slice(0,n),s=r.slice(n+1),i=ic("sha256",t).update(o).digest(),a=Buffer.from(s,"base64url");if(a.length!==i.length||!Ay(a,i))return null;return o}deleteCookie(e,t={}){return this.setCookie(e,"",{...t,maxAge:0,expires:new Date(0)})}async jsonBody(e=1048576){if(this.body!==void 0)return this.body;let t=this.req.headers.get("content-type");if(t&&t.toLowerCase().includes("application/json")){let r=this.req.headers.get("content-length");if(r!==null){let n=r.trim(),o=n.length>0?Number(n):NaN;if(Number.isInteger(o)&&o>e){let s=Error("Payload Too Large");throw s.status=413,s}}try{let n=await this.req.text();if(Buffer.byteLength(n,"utf-8")>e){let o=Error("Payload Too Large");throw o.status=413,o}return this.body=JSON.parse(n)}catch(n){if(n?.status===413)throw n;return this.body=null}}return this.body=null}reset(e){if(this.req=e,this._status=200,this._headers=void 0,this.store.size>0)this.store.clear();return this.params={},this._query=void 0,this._cookies=void 0,this._setCookies=void 0,this.body=void 0,this._peerIp=void 0,this}status(e){return this._status=e,this}_applyCookies(e){if(this._setCookies){for(let t=0;t<this._setCookies.length;t++)e.headers.append("Set-Cookie",this._setCookies[t]);this._setCookies=void 0}return e}json(e){let t=this._status||200,r;if(!this._headers)r=t===200?Response.json(e):Response.json(e,{status:t});else{let n=this._headers;if(n["content-type"]===void 0){if(Object.isFrozen(n))n={...n},this._headers=n;n["content-type"]="application/json"}r=Response.json(e,{status:t,headers:n})}return this._applyCookies(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 this._applyCookies(new Response(e,{status:t??this._status,headers:r}))}text(e,t){let r={"content-type":"text/plain; charset=utf-8",...this._headers||{}};return this._applyCookies(new Response(e,{status:t??this._status,headers:r}))}redirect(e,t=302){let r={location:e,...this._headers||{}};return this._applyCookies(new Response(null,{status:t,headers:r}))}sse(e){let t=new TextEncoder,r=(i)=>i.split(/\r?\n/).map((a)=>`data: ${a}`).join(`
63
+ }`)()},bu=(e)=>{let t=eo(e),r=Rs(e);return(n)=>{if(n instanceof Response)return n;let o=r?r(n):n,s=t(o);if(!s.ok)return We({status:"error",code:"RESPONSE_VALIDATION_FAILED",error:s.error},500);return s.data}},Gy=(e)=>{let t=e;while(t?._def){let r=t._def.typeName;if(r==="ZodOptional"||r==="ZodDefault"||r==="ZodNullable")t=t._def.innerType;else if(r==="ZodEffects")t=t._def.schema;else break}return t?.type||t?._def?.typeName},Hy=/^\s*[-+]?(\d+\.?\d*|\.\d+)([eE][-+]?\d+)?\s*$/,lu=(e,t)=>{let r=t;while(r?._def?.typeName==="ZodEffects")r=r._def.schema;let n=r?.properties||(r?._def?.shape?typeof r._def.shape==="function"?r._def.shape():r._def.shape:null);if(!n)return e;let o={...e};for(let[s,i]of Object.entries(n)){if(!Object.hasOwn(o,s))continue;let a=o[s];if(typeof a!=="string")continue;let u=Gy(i);if(u==="number"||u==="integer"||u==="ZodNumber"){if(/^\s*[-+]?(\d+\.?\d*|\.\d+)([eE][-+]?\d+)?\s*$/.test(a)){let c=Number(a);if(Number.isFinite(c))o[s]=c}}else if(u==="boolean"||u==="ZodBoolean"){if(a==="true")o[s]=!0;else if(a==="false")o[s]=!1}}return o},Ii=(e)=>{let t=e.body?eo(e.body):null,r=e.query?eo(e.query):null,n=e.params?eo(e.params):null,o=e.headers?eo(e.headers):null,s=e.stripUnknown&&e.body?Rs(e.body):null,i=e.stripUnknown&&e.query?Rs(e.query):null,a=e.stripUnknown&&e.params?Rs(e.params):null,u=e.response?bu(e.response):null,c=e.maxBodySize??1048576,f=[],d=new Set;{let R=e.query;while(R?._def?.schema)R=R._def.schema;let w=R?.properties||(R?._def?.shape?typeof R._def.shape==="function"?R._def.shape():R._def.shape:null),P=(C)=>{let J=C;while(J?._def){let z=J._def.typeName;if(z==="ZodOptional"||z==="ZodDefault"||z==="ZodNullable")J=J._def.innerType;else if(z==="ZodEffects")J=J._def.schema;else break}return J};if(w)for(let[C,J]of Object.entries(w)){let z=P(J);if(!(z?.type==="array"||z?._def?.typeName==="ZodArray"))continue;f.push(C);let T=P(z.items??z._def?.type),B=T?.type??T?._def?.typeName;if(B==="number"||B==="integer"||B==="ZodNumber")d.add(C)}}let m=Boolean(n||r||o),y=(R)=>{if(n){let w=lu(R.params,e.params),P=n(w);if(!P.ok)return We({status:"error",code:"PARAMS_INVALID",error:P.error});R.params=a?a(P.data):P.data}if(r){let w=lu(R.query,e.query);for(let C of f){let J=R.queryAll(C);if(J.length>0)w[C]=J.map((z)=>d.has(C)&&Hy.test(z)?Number(z):z)}let P=r(w);if(!P.ok)return We({status:"error",code:"QUERY_INVALID",error:P.error});R._query=i?i(P.data):P.data}if(o){let w={};R.req.headers.forEach((C,J)=>{let z=J.toLowerCase();if(z!=="__proto__"&&z!=="constructor"&&z!=="prototype")w[z]=C});let P=o(w);if(!P.ok)return We({status:"error",code:"HEADERS_INVALID",error:P.error})}return};if(!t){let R=(w,P)=>{if(m){let C=y(w);if(C)return C}return P?P():void 0};if(R.__routeSchemas=e,u)R.__responseFilter=u;return R}let p=Boolean(e.body&&"_def"in e.body),h=(R,w,P)=>{let C;try{C=t(w)}catch{if(p)return e.body.safeParseAsync(w).then((J)=>{if(!J.success)return We({status:"error",code:"VALIDATION_FAILED",error:J.error.flatten()});return R.body=s?s(J.data):J.data,P?P():void 0});C={ok:!1,error:{message:"Validation failed"}}}if(!C.ok)return We({status:"error",code:"VALIDATION_FAILED",error:C.error});return R.body=s?s(C.data):C.data,P?P():void 0},x=(R,w)=>{if(m){let C=y(R);if(C)return C}let P;try{P=R.jsonBodySyncOrAsync(c)}catch(C){if(C?.status===413)return We({status:"error",code:"PAYLOAD_TOO_LARGE",message:"Payload Too Large"},413);return We({status:"error",message:"Malformed JSON payload"})}if(P&&typeof P.then==="function")return P.then((C)=>h(R,C,w),(C)=>{if(C?.status===413)return We({status:"error",code:"PAYLOAD_TOO_LARGE",message:"Payload Too Large"},413);return We({status:"error",message:"Malformed JSON payload"})});return h(R,P,w)};if(x.__schema=e.body,x.__routeSchemas=e,u)x.__responseFilter=u;return x};class xn{prefix;groupMiddleware;routes=[];constructor(e="",t=[]){this.prefix=e;this.groupMiddleware=t}_add(e,t,r){let n=(this.prefix+"/"+t).replace(/\/+/g,"/");if(n.endsWith("/"))n=n.slice(0,-1);let o=[];for(let s=0;s<r.length;s++){let i=r[s];if(typeof i==="function")o.push(i);else if(i&&typeof i==="object")o.push(Ii(i))}return this.routes.push({method:e.toUpperCase(),path:n||"",handlers:[...this.groupMiddleware,...o]}),this}get=(e,...t)=>this._add("GET",e,t);post=(e,...t)=>this._add("POST",e,t);put=(e,...t)=>this._add("PUT",e,t);patch=(e,...t)=>this._add("PATCH",e,t);delete=(e,...t)=>this._add("DELETE",e,t);options=(e,...t)=>this._add("OPTIONS",e,t);head=(e,...t)=>this._add("HEAD",e,t);all=(e,...t)=>{for(let r of["GET","POST","PUT","PATCH","DELETE","OPTIONS","HEAD"])this._add(r,e,t);return this};group=(e,...t)=>{let r=t.pop(),n=t,o=(this.prefix+"/"+e).replace(/\/+/g,"/"),s=new xn(o,[...this.groupMiddleware,...n]);return r(s),this.routes.push(...s.routes),this};_mountRouter(e,t){let r=(this.prefix+"/"+e).replace(/\/+/g,"/").replace(/\/$/,"");for(let n of t.routes){let o=(r+"/"+n.path).replace(/\/+/g,"/");if(o.endsWith("/"))o=o.slice(0,-1);this.routes.push({method:n.method,path:o||"",handlers:[...this.groupMiddleware,...n.handlers]})}}route(e,t){return this._mountRouter(e,t),this}use(e,...t){if(typeof e==="string"){let n=[],o=[];for(let s=0;s<t.length;s++){let i=t[s];if(i instanceof xn||i&&i.routes)o.push(i);else if(typeof i==="function")n.push(i)}if(o.length===0)throw TypeError(`BareRouter.use("${e}", ...) requires a BareRouter instance`);for(let s=0;s<o.length;s++){let i=this.routes.length;if(this._mountRouter(e,o[s]),n.length>0)for(let a=i;a<this.routes.length;a++)this.routes[a].handlers=[...this.groupMiddleware,...n,...this.routes[a].handlers.slice(this.groupMiddleware.length)]}return this}let r=[e,...t];for(let n=0;n<r.length;n++){let o=r[n];if(o instanceof xn||o&&o.routes)this._mountRouter("",o);else if(o&&typeof o.install==="function")o.install(this);else if(typeof o==="function")this.groupMiddleware.push(o)}return this}}class bn{children=Object.create(null);staticKeys=[];paramNode=null;paramName=null;wildcardNode=null;handlers=Object.create(null);handlerParams=Object.create(null);insert(e,t,r){let n=this,o=e.split("/").filter(Boolean),s=[];for(let i of o)if(i==="*"){if(!n.wildcardNode)n.wildcardNode=new bn;n=n.wildcardNode;break}else if(i.startsWith(":")){if(!n.paramNode)n.paramNode=new bn;let a=i.slice(1);if(!n.paramName)n.paramName=a;s.push(a),n=n.paramNode}else{if(!n.children[i])n.children[i]=new bn,n.staticKeys.push(i);n=n.children[i]}n.handlers[t]=r,n.handlerParams[t]=s}lookup(e,t,r,n){let o=r===-1?0:r,s=t.indexOf("?",o),i=s===-1?t.length:s;if(t[o]==="/")o++;let a=(c,f,d)=>{let y=c.includes("__proto__")?Object.create(null):{};for(let p=0;p<c.length;p++)y[c[p]]=f[p];if(d!==void 0)y["*"]=d;n.params=y},u=(c,f,d)=>{if(f>=i){let R=c.handlers[e];if(R)return a(c.handlerParams[e]||[],d),R;if(c.wildcardNode&&c.wildcardNode.handlers[e])return a(c.wildcardNode.handlerParams[e]||[],d,""),c.wildcardNode.handlers[e];return null}let m=t.indexOf("/",f);if(m===-1||m>i)m=i;let y=m-f,p=c.staticKeys,h=p.length,x=null;if(h===1){let R=p[0];if(R.length===y){let w=!0;for(let P=0;P<y;P++)if(R[P]!==t[f+P]){w=!1;break}if(w)x=c.children[R]}}else for(let R=0;R<h;R++){let w=p[R];if(w.length===y){let P=!0;for(let C=0;C<y;C++)if(w[C]!==t[f+C]){P=!1;break}if(P){x=c.children[w];break}}}if(x){let R=u(x,m+1,d);if(R)return R}if(c.paramNode&&y>0){d.push(t.slice(f,m));let R=u(c.paramNode,m+1,d);if(R)return R;d.pop()}if(c.wildcardNode&&c.wildcardNode.handlers[e])return a(c.wildcardNode.handlerParams[e]||[],d,t.slice(f,i)),c.wildcardNode.handlers[e];return null};return n.params={},u(this,o,[])}emitParamsAssign(e,t,r){if(t.length===0)return"";if(t.includes("__proto__")){let o=`${e}{ const _p = Object.create(null);
64
+ `;for(let s=0;s<t.length;s++)o+=`${e}_p[${JSON.stringify(t[s])}] = ${r[s]};
65
+ `;return o+`${e}ctx.params = _p; }
66
+ `}let n=t.map((o,s)=>`${JSON.stringify(o)}: ${r[s]}`).join(", ");return`${e}ctx.params = { ${n} };
67
+ `}jitCompile(e,t=0,r="url",n="s",o=[],s=(i)=>`return ${i}(ctx);`){let i="",a=" ".repeat(t);if(Object.keys(this.handlers).length>0){i+=`${a}if (${n} >= urlLen) {
68
+ `,i+=`${a} switch(method) {
69
+ `;for(let[c,f]of Object.entries(this.handlers)){let d=e(f),m=this.handlerParams[c]||[],y=m.length>0?this.emitParamsAssign("",m,o).trim()+" ":"";i+=`${a} case ${JSON.stringify(c)}: ${y}${s(d)}
70
+ `}i+=`${a} }
71
+ `,i+=`${a}}
72
+ `}if(this.staticKeys.length>0||this.paramNode!==null){let c=a+" ";if(i+=`${a}if (${n} < urlLen) {
73
+ `,this.staticKeys.length>0)if(this.staticKeys.length===1){let f=this.staticKeys[0],d=this.children[f],m=f.length,y=`${n} + ${m} === urlLen || ${r}.charCodeAt(${n} + ${m}) === 47`;if(m===1)i+=`${c}if (${r}.charCodeAt(${n}) === ${f.charCodeAt(0)} && (${y})) {
74
+ `;else i+=`${c}if (${r}.startsWith(${JSON.stringify(f)}, ${n}) && (${y})) {
75
+ `;i+=d.jitCompile(e,t+1,r,`${n} + ${m+1}`,o,s),i+=`${c}}
76
+ `}else{i+=`${c}let slash${t} = ${r}.indexOf('/', ${n});
77
+ `,i+=`${c}if (slash${t} === -1 || slash${t} > urlLen) slash${t} = urlLen;
78
+ `,i+=`${c}const len${t} = slash${t} - (${n});
79
+ `;let f=new Map;for(let d of this.staticKeys){let m=f.get(d.length);if(!m)m=[],f.set(d.length,m);m.push(d)}if(this.staticKeys.length>8){let d=new Map;for(let m of this.staticKeys){let y=this.children[m],p=0,h=y.jitCompile(()=>`__H${p++}__`,t+1,r,`slash${t} + 1`,o,s),x=d.get(h);if(!x)x=[],d.set(h,x);x.push(m)}i+=`${c}const seg${t} = ${r}.slice(${n}, slash${t});
80
+ `,i+=`${c}switch(seg${t}) {
81
+ `;for(let[m,y]of d)if(y.length===1){let p=y[0],h=this.children[p];i+=`${c} case ${JSON.stringify(p)}:
82
+ `,i+=h.jitCompile(e,t+1,r,`slash${t} + 1`,o,s),i+=`${c} break;
83
+ `}else{let p=[];for(let w of y){let P=this.children[w],C=[];P.jitCompile((J)=>{let z=e(J);return C.push(z),z},t+1,r,`slash${t} + 1`,o,s),p.push(C)}let h=p[0].length,x=Array.from({length:h},(w,P)=>`_rh${t}_${P}`);for(let w=0;w<y.length;w++)i+=`${c} case ${JSON.stringify(y[w])}:
84
+ `;if(i+=`${c} {
85
+ `,h>0){i+=`${c} let ${x.join(", ")};
86
+ `,i+=`${c} switch(seg${t}) {
87
+ `;for(let w=0;w<y.length;w++){let P=x.map((C,J)=>`${C} = ${p[w][J]}`).join("; ");i+=`${c} case ${JSON.stringify(y[w])}: ${P}; break;
88
+ `}i+=`${c} }
89
+ `}let R=m;for(let w=0;w<h;w++)R=R.replaceAll(`__H${w}__`,x[w]);i+=R,i+=`${c} break;
90
+ `,i+=`${c} }
91
+ `}i+=`${c}}
92
+ `}else{i+=`${c}switch(len${t}) {
93
+ `;for(let[d,m]of f){i+=`${c} case ${d}:
94
+ `;for(let y of m){if(d===1)i+=`${c} if (${r}.charCodeAt(${n}) === ${y.charCodeAt(0)}) {
95
+ `;else i+=`${c} if (${r}.startsWith(${JSON.stringify(y)}, ${n})) {
96
+ `;let p=this.children[y];i+=p.jitCompile(e,t+1,r,`slash${t} + 1`,o,s),i+=`${c} }
97
+ `}i+=`${c} break;
98
+ `}i+=`${c}}
99
+ `}}if(this.paramNode){let f=this.paramNode;if(this.staticKeys.length<=1)i+=`${c}let slash${t} = ${r}.indexOf('/', ${n});
100
+ `,i+=`${c}if (slash${t} === -1 || slash${t} > urlLen) slash${t} = urlLen;
101
+ `;let d=`pL${t}`;i+=`${c}if (slash${t} > ${n}) {
102
+ `,i+=`${c} const ${d} = ${r}.slice(${n}, slash${t});
103
+ `;let m=[...o,d];i+=f.jitCompile(e,t+1,r,`slash${t} + 1`,m,s),i+=`${c}}
104
+ `}i+=`${a}}
105
+ `}if(this.wildcardNode&&Object.keys(this.wildcardNode.handlers).length>0){let c=`wL${t}`;i+=`${a}const ${c} = ${r}.slice(${n}, urlLen);
106
+ `,i+=`${a}switch(method) {
107
+ `;for(let[f,d]of Object.entries(this.wildcardNode.handlers)){let m=e(d),y=[...this.wildcardNode.handlerParams[f]||[],"*"],p=[...o,c],h=this.emitParamsAssign("",y,p).trim();i+=`${a} case ${JSON.stringify(f)}: ${h} ${s(m)}
108
+ `}i+=`${a}}
109
+ `}return i}}import{createHmac as Iu,timingSafeEqual as zy}from"crypto";var _u=0,Ru=new WeakSet;if(typeof globalThis.ReadableStream==="function"&&!globalThis.ReadableStream.__bareTracked){let e=globalThis.ReadableStream,t=new Proxy(e,{construct(r,n,o){let s=Reflect.construct(r,n,o);if(n[0]&&typeof n[0].pull==="function")_u++,Ru.add(s);return s}});t.__bareTracked=!0,globalThis.ReadableStream=t}var Vy=new TextDecoder;class jo{req;params={};_status=200;_headers=void 0;store=new Map;body=void 0;_query=void 0;_cookies=void 0;_setCookies=void 0;_requestId=void 0;_peerIp=void 0;_trustProxy=!1;_detached=!1;constructor(e=!1){this._trustProxy=e}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,s=t.indexOf("+",n)!==-1,i=t.indexOf("%",n)!==-1;while(n<o){let a=t.indexOf("&",n);if(a===-1)a=o;if(a>n){let u=t.indexOf("=",n),c,f;if(u!==-1&&u<a)c=t.slice(n,u),f=t.slice(u+1,a);else c=t.slice(n,a),f="";if(s){if(c.indexOf("+")!==-1)c=c.replaceAll("+"," ");if(f.indexOf("+")!==-1)f=f.replaceAll("+"," ")}if(i){if(c.indexOf("%")!==-1)try{c=decodeURIComponent(c)}catch{}if(f.indexOf("%")!==-1)try{f=decodeURIComponent(f)}catch{}}if(c!=="__proto__"&&c!=="constructor"&&c!=="prototype")e[c]=f}n=a+1}}}return this._query=e,e}queryAll(e){let t=this.req?.url,r=t?t.indexOf("?"):-1;if(r===-1)return[];let n=[],o=new URLSearchParams(t.slice(r+1));for(let[s,i]of o)if(s===e)n.push(i);return n}getQuery(e){let t=this.query;return Object.hasOwn(t,e)?t[e]:void 0}get cookies(){if(this._cookies!==void 0)return this._cookies;let e=Object.create(null),t=this.req?.headers?.get("cookie");if(t){let r=0,n=t.length;while(r<n){let o=t.indexOf(";",r);if(o===-1)o=n;let s=t.indexOf("=",r);if(s!==-1&&s<o){let i=t.slice(r,s).trim(),a=t.slice(s+1,o).trim();try{a=decodeURIComponent(a)}catch{}if(i&&i!=="__proto__"&&i!=="constructor"&&i!=="prototype")e[i]=a}r=o+1}}return this._cookies=e,e}setCookie(e,t,r={}){if(!e||/[\r\n;= \t]/.test(e))throw Error("Invalid cookie name");let n=r.path??"/";if(/[\r\n;]/.test(n))throw Error("Invalid cookie path");if(r.domain&&/[\r\n;]/.test(r.domain))throw Error("Invalid cookie domain");let o=r.sameSite??"Lax";if(o!=="Strict"&&o!=="Lax"&&o!=="None")throw Error("Invalid cookie sameSite");let s=t;if(r.secret){let a=Iu("sha256",r.secret).update(t).digest("base64url");s=`${t}.${a}`}let i=`${e}=${encodeURIComponent(s)}`;if(i+=`; Path=${n}`,r.domain)i+=`; Domain=${r.domain}`;if(r.maxAge!==void 0&&Number.isFinite(r.maxAge))i+=`; Max-Age=${Math.floor(r.maxAge)}`;if(r.expires&&!Number.isNaN(r.expires.getTime()))i+=`; Expires=${r.expires.toUTCString()}`;if(r.httpOnly!==!1)i+="; HttpOnly";if(r.secure)i+="; Secure";if(i+=`; SameSite=${o}`,!this._setCookies)this._setCookies=[];return this._setCookies.push(i),this}getSignedCookie(e,t){let r=this.cookies;if(!Object.hasOwn(r,e))return null;let n=r[e];if(typeof n!=="string"||!n)return null;let o=n.lastIndexOf(".");if(o<0)return null;let s=n.slice(0,o),i=n.slice(o+1);if(!/^[A-Za-z0-9_-]{43}$/.test(i))return null;let a=Iu("sha256",t).update(s).digest(),u=Buffer.from(i,"base64url");if(u.length!==a.length||!zy(u,a))return null;return s}deleteCookie(e,t={}){return this.setCookie(e,"",{...t,maxAge:0,expires:new Date(0)})}async readBodyWithLimit(e){let t=this.req.body.getReader(),r=[],n=0;while(!0){let{done:i,value:a}=await t.read();if(i)break;if(a){if(n+=a.byteLength,n>e){try{await t.cancel()}catch{}throw Object.assign(Error("Payload Too Large"),{status:413})}r.push(a)}}let o=new Uint8Array(n),s=0;for(let i=0;i<r.length;i++)o.set(r[i],s),s+=r[i].byteLength;return o}_parseAndSanitizeJson(e,t){if(e.length>t||e.length*3>t&&Buffer.byteLength(e,"utf-8")>t){let n=Error("Payload Too Large");throw n.status=413,n}let r=JSON.parse(e);if(e.indexOf("__proto__")!==-1||e.indexOf("constructor")!==-1||e.indexOf("prototype")!==-1||e.indexOf("\\u")!==-1){let n=[r];while(n.length>0){let o=n.pop();if(!o||typeof o!=="object")continue;if(Array.isArray(o))for(let s=0;s<o.length;s++)n.push(o[s]);else{if(Object.hasOwn(o,"__proto__"))delete o.__proto__;if(Object.hasOwn(o,"constructor"))delete o.constructor;if(Object.hasOwn(o,"prototype"))delete o.prototype;let s=Object.keys(o);for(let i=0;i<s.length;i++)n.push(o[s[i]])}}}return this.body=r}jsonBodySyncOrAsync(e=1048576){if(this.body!==void 0)return this.body;let t=this.req.headers,r=t.get("content-type");if(r&&(r==="application/json"||r.startsWith("application/json;")||r.toLowerCase().includes("application/json"))){let n=t.get("content-length");if(n!==null){let i=n.trim(),a=i.length>0?Number(i):NaN;if(Number.isInteger(a)&&a>e){let u=Error("Payload Too Large");throw u.status=413,u}}if(n===null&&t.get("transfer-encoding")!==null||_u>0&&this.req.body&&Ru.has(this.req.body))return this.readBodyWithLimit(e).then((i)=>{try{return this._parseAndSanitizeJson(Vy.decode(i),e)}catch(a){if(a?.status===413)throw a;return this.body=null}},(i)=>{if(i?.status===413)throw i;return this.body=null});let o=this.req.text(),s=Bun.peek(o);if(typeof s==="string")try{return this._parseAndSanitizeJson(s,e)}catch(i){if(i?.status===413)throw i;return this.body=null}return o.then((i)=>{try{return this._parseAndSanitizeJson(i,e)}catch(a){if(a?.status===413)throw a;return this.body=null}},(i)=>{if(i?.status===413)throw i;return this.body=null})}return this.body=null}async jsonBody(e=1048576){return this.jsonBodySyncOrAsync(e)}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._requestId=void 0,this._peerIp=void 0,this._detached=!1,this}status(e){return this._status=e,this}_applyCookies(e){if(this._setCookies){for(let t=0;t<this._setCookies.length;t++)e.headers.append("Set-Cookie",this._setCookies[t]);this._setCookies=void 0}return e}json(e){let t=this._status||200,r;if(!this._headers)r=t===200?Response.json(e):Response.json(e,{status:t});else{let n=this._headers["content-type"]===void 0?{...this._headers,"content-type":"application/json"}:this._headers;r=Response.json(e,{status:t,headers:n})}return this._applyCookies(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};let r=e.toLowerCase();if(r==="vary"&&this._headers.vary){let n=this._headers.vary,o=n.toLowerCase().split(",").map((i)=>i.trim()),s=t.split(",").map((i)=>i.trim()).filter((i)=>i&&!o.includes(i.toLowerCase()));this._headers.vary=s.length>0?`${n}, ${s.join(", ")}`:n}else this._headers[r]=t;return 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={...this._headers||{},"content-type":"text/html; charset=utf-8"};return this._applyCookies(new Response(e,{status:t??this._status,headers:r}))}text(e,t){let r={...this._headers||{},"content-type":"text/plain; charset=utf-8"};return this._applyCookies(new Response(e,{status:t??this._status,headers:r}))}redirect(e,t=302){if(/[\r\n]/.test(e))throw Error("Invalid redirect URL");let r={...this._headers||{},location:e};return this._applyCookies(new Response(null,{status:t,headers:r}))}sse(e){let t=new TextEncoder,r=(a)=>a.split(/\r\n|\r|\n/).map((u)=>`data: ${u}`).join(`
78
110
  `)+`
79
111
 
80
- `,n=(i)=>{if(typeof i==="string")return t.encode(r(i));let a="";if(i.id!==void 0)a+=`id: ${String(i.id).replace(/[\r\n]/g,"")}
81
- `;if(i.event!==void 0)a+=`event: ${String(i.event).replace(/[\r\n]/g,"")}
82
- `;if(i.retry!==void 0&&Number.isFinite(i.retry))a+=`retry: ${Math.max(0,Math.floor(i.retry))}
83
- `;let u=typeof i.data==="string"?i.data:JSON.stringify(i.data);return a+=r(u),t.encode(a)},o=new ReadableStream({async start(i){try{if(typeof e==="function"){let a=!1,u=(d,f,p)=>{if(!a)i.enqueue(n({data:d,event:f,id:p}))},c=()=>{if(!a)a=!0,i.close()};await e(u,c),c()}else{for await(let a of e)i.enqueue(n(a));i.close()}}catch(a){i.error(a)}}}),s={"content-type":"text/event-stream; charset=utf-8","cache-control":"no-cache, no-transform",connection:"keep-alive",...this._headers||{}};return this._applyCookies(new Response(o,{status:this._status||200,headers:s}))}get requestId(){if(this._requestId!==void 0)return this._requestId;let e=this.req?.headers?.get("x-request-id");return this._requestId=e&&e.length>0&&e.length<=128?e:crypto.randomUUID(),this._requestId}get ip(){if(this._trustProxy){let e=this.req?.headers?.get("x-forwarded-for");if(e){let r=e.split(",")[0]?.trim();if(r)return r}let t=this.req?.headers?.get("x-real-ip")?.trim()||this.req?.headers?.get("cf-connecting-ip")?.trim();if(t)return t}return this._peerIp||"127.0.0.1"}async upload(e={}){let t=e.maxFileSize??5242880,r=e.maxFiles??10,n=e.allowedTypes?new Set(e.allowedTypes.map((f)=>f.trim().toLowerCase())):null;if(!(this.req?.headers?.get("content-type")||"").toLowerCase().includes("multipart/form-data"))throw Object.assign(Error("Expected multipart/form-data"),{status:400});let s=t*r,i=Number(this.req?.headers?.get("content-length")||0);if(Number.isFinite(i)&&i>s+65536)throw Object.assign(Error("Payload Too Large"),{status:413});let a=await this.req.formData(),u={},c=[],d=0;for(let[f,p]of a.entries()){if(typeof p==="string"){if(f!=="__proto__"&&f!=="constructor"&&f!=="prototype")u[f]=p;continue}let y=p;if(c.length>=r)throw Object.assign(Error(`Too many files (max ${r})`),{status:413});if(y.size>t)throw Object.assign(Error(`File exceeds max size of ${t} bytes`),{status:413});if(d+=y.size,d>s)throw Object.assign(Error(`Total upload size exceeds ${s} bytes`),{status:413});let b=(y.type||"").split(";")[0].trim().toLowerCase();if(n&&!n.has(b))throw Object.assign(Error(`Unsupported file type: ${y.type||"unknown"}`),{status:415});let P=y.name||"file",L=(P.split(/[\\/]/).pop()||"file").replace(/[^a-zA-Z0-9._-]/g,"_").replace(/^\.+/,"")||"file";c.push({fieldName:f,filename:P,safeName:L,type:y.type,size:y.size,file:y})}return{fields:u,files:c}}}function Hn(e,t){return t===void 0?Re(e):Re({...t,...e})}function ac(e){return h({[I]:"Argument",index:e})}function ky(e,t){return Ie("Awaited",[Ie(e,t)])}function Ty(e){return Ie("Awaited",[$t(e)])}function Fy(e){return et(cc(e))}function Ny(e){return ie(cc(e))}function My(e){return zn(e)}function cc(e){return e.map((t)=>zn(t))}function zn(e,t){return h(Tt(e)?ky(e.target,e.parameters):Pe(e)?Fy(e.allOf):te(e)?Ny(e.anyOf):zr(e)?My(e.item):Fe(e)?Ty(e.$ref):e,t)}function jy(e){let t=[];for(let r of e)t.push(...St(r));return Qi(t)}function Ey(e){return e.filter((t)=>!_r(t))}function Ly(e,t){let r=[];for(let n of e)r.push(...io(n,[t]));return Ey(r)}function Uy(e,t){let r={};for(let n of t)r[n]=Do(Ly(e,n));return r}function uc(e,t){let r=jy(e),n=Uy(e,r);return ue(n,t)}function ds(e){return h({[I]:"Date",type:"Date"},e)}function fs(e){return h({[I]:"Null",type:"null"},e)}function ms(e){return h({[I]:"Symbol",type:"symbol"},e)}function ps(e){return h({[I]:"Undefined",type:"undefined"},e)}function ls(e){return h({[I]:"Uint8Array",type:"Uint8Array"},e)}function Ky(e){return e.map((t)=>si(t,!1))}function By(e){let t={};for(let r of globalThis.Object.getOwnPropertyNames(e))t[r]=ut(si(e[r],!1));return t}function ys(e,t){return t===!0?e:ut(e)}function si(e,t){return $i(e)?ys(Cr(),t):Ci(e)?ys(Cr(),t):Ke(e)?ut(Ot(Ky(e))):Rr(e)?ls():ln(e)?ds():be(e)?ys(ue(By(e)),t):Si(e)?ys(Qt([],Pr()),t):xe(e)?ps():Pi(e)?fs():Ai(e)?ms():Uo(e)?Rn():yt(e)?se(e):br(e)?se(e):he(e)?se(e):ue({})}function dc(e,t){return h(si(e,!0),t)}function fc(e,t){return Ft(e)?Ot(e.parameters,t):J(t)}function mc(e,t){if(xe(e))throw Error("Enum undefined or empty");let r=globalThis.Object.getOwnPropertyNames(e).filter((s)=>isNaN(s)).map((s)=>e[s]),o=[...new Set(r)].map((s)=>se(s));return ie(o,{...t,[Yt]:"Enum"})}function pc(e,t){return Vn(Wr(e),t)}function vy(e,t){let r=e.filter((n)=>Tr(n,t)===x.False);return r.length===1?r[0]:ie(r)}function Vn(e,t,r={}){if(xt(e))return h(pc(e,t),r);if(_e(e))return h(lc(e,t),r);return h(te(e)?vy(e.anyOf,t):Tr(e,t)!==x.False?J():e,r)}function Dy(e,t){let r={};for(let n of globalThis.Object.getOwnPropertyNames(e))r[n]=Vn(e[n],t);return r}function qy(e,t){return Dy(e.properties,t)}function lc(e,t){let r=qy(e,t);return re(r)}function yc(e,t){return Jn(Wr(e),t)}function Gy(e,t){let r=e.filter((n)=>Tr(n,t)!==x.False);return r.length===1?r[0]:ie(r)}function Jn(e,t,r){if(xt(e))return h(yc(e,t),r);if(_e(e))return h(gc(e,t),r);return h(te(e)?Gy(e.anyOf,t):Tr(e,t)!==x.False?e:J(),r)}function Hy(e,t){let r={};for(let n of globalThis.Object.getOwnPropertyNames(e))r[n]=Jn(e[n],t);return r}function zy(e,t){return Hy(e.properties,t)}function gc(e,t){let r=zy(e,t);return re(r)}function hc(e,t){return Ft(e)?h(e.returns,t):J(t)}function gs(e){return ut(Ze(e))}function dn(e,t,r){return h({[I]:"Record",type:"object",patternProperties:{[e]:t}},r)}function ii(e,t,r){let n={};for(let o of e)n[o]=t;return ue(n,{...r,[Yt]:"Record"})}function Vy(e,t,r){return Ei(e)?ii(ct(e),t,r):dn(e.pattern,t,r)}function Jy(e,t,r){return ii(ct(ie(e)),t,r)}function Wy(e,t,r){return ii([e.toString()],t,r)}function Xy(e,t,r){return dn(e.source,t,r)}function Yy(e,t,r){let n=xe(e.pattern)?wr:e.pattern;return dn(n,t,r)}function Qy(e,t,r){return dn(wr,t,r)}function Zy(e,t,r){return dn(Di,t,r)}function eg(e,t,r){return ue({true:t,false:t},r)}function tg(e,t,r){return dn(Or,t,r)}function rg(e,t,r){return dn(Or,t,r)}function hs(e,t,r={}){return te(e)?Jy(e.anyOf,t,r):xt(e)?Vy(e,t,r):gt(e)?Wy(e.const,t,r):sr(e)?eg(e,t,r):Mt(e)?tg(e,t,r):jt(e)?rg(e,t,r):ks(e)?Xy(e,t,r):ir(e)?Yy(e,t,r):Ps(e)?Qy(e,t,r):_r(e)?Zy(e,t,r):J(r)}function xs(e){return globalThis.Object.getOwnPropertyNames(e.patternProperties)[0]}function xc(e){let t=xs(e);return t===wr?Et():t===Or?_t():Et({pattern:t})}function Is(e){return e.patternProperties[xs(e)]}function ng(e,t){return t.parameters=wo(e,t.parameters),t.returns=Vt(e,t.returns),t}function og(e,t){return t.parameters=wo(e,t.parameters),t.returns=Vt(e,t.returns),t}function sg(e,t){return t.allOf=wo(e,t.allOf),t}function ig(e,t){return t.anyOf=wo(e,t.anyOf),t}function ag(e,t){if(xe(t.items))return t;return t.items=wo(e,t.items),t}function cg(e,t){return t.items=Vt(e,t.items),t}function ug(e,t){return t.items=Vt(e,t.items),t}function dg(e,t){return t.items=Vt(e,t.items),t}function fg(e,t){return t.item=Vt(e,t.item),t}function mg(e,t){let r=gg(e,t.properties);return{...t,...ue(r)}}function pg(e,t){let r=Vt(e,xc(t)),n=Vt(e,Is(t)),o=hs(r,n);return{...t,...o}}function lg(e,t){return t.index in e?e[t.index]:Pr()}function yg(e,t){let r=xn(t),n=at(t),o=Vt(e,t);return r&&n?gs(o):r&&!n?ut(o):!r&&n?Ze(o):o}function gg(e,t){return globalThis.Object.getOwnPropertyNames(t).reduce((r,n)=>({...r,[n]:yg(e,t[n])}),{})}function wo(e,t){return t.map((r)=>Vt(e,r))}function Vt(e,t){return Ft(t)?ng(e,t):Nt(t)?og(e,t):Pe(t)?sg(e,t):te(t)?ig(e,t):It(t)?ag(e,t):kt(t)?cg(e,t):qr(t)?ug(e,t):Hr(t)?dg(e,t):zr(t)?fg(e,t):Ne(t)?mg(e,t):Vr(t)?pg(e,t):As(t)?lg(e,t):t}function Ic(e,t){return Vt(t,Hn(e))}function bc(e){return h({[I]:"Integer",type:"integer"},e)}function hg(e,t,r){return{[e]:Jt(se(e),t,Re(r))}}function xg(e,t,r){return e.reduce((o,s)=>({...o,...hg(s,t,r)}),{})}function Ig(e,t,r){return xg(e.keys,t,r)}function Rc(e,t,r){let n=Ig(e,t,r);return re(n)}function bg(e){let[t,r]=[e.slice(0,1),e.slice(1)];return[t.toLowerCase(),r].join("")}function Rg(e){let[t,r]=[e.slice(0,1),e.slice(1)];return[t.toUpperCase(),r].join("")}function _g(e){return e.toUpperCase()}function Og(e){return e.toLowerCase()}function wg(e,t,r){let n=bn(e.pattern);if(!Jr(n))return{...e,pattern:_c(e.pattern,t)};let i=[...so(n)].map((c)=>se(c)),a=Oc(i,t),u=ie(a);return zo([u],r)}function _c(e,t){return typeof e==="string"?t==="Uncapitalize"?bg(e):t==="Capitalize"?Rg(e):t==="Uppercase"?_g(e):t==="Lowercase"?Og(e):e:e.toString()}function Oc(e,t){return e.map((r)=>Jt(r,t))}function Jt(e,t,r={}){return ht(e)?Rc(e,t,r):xt(e)?wg(e,t,r):te(e)?ie(Oc(e.anyOf,t),r):gt(e)?se(_c(e.const,t),r):h(e,r)}function wc(e,t={}){return Jt(e,"Capitalize",t)}function $c(e,t={}){return Jt(e,"Lowercase",t)}function Sc(e,t={}){return Jt(e,"Uncapitalize",t)}function Cc(e,t={}){return Jt(e,"Uppercase",t)}function $g(e,t,r){let n={};for(let o of globalThis.Object.getOwnPropertyNames(e))n[o]=Lr(e[o],t,Re(r));return n}function Sg(e,t,r){return $g(e.properties,t,r)}function Pc(e,t,r){let n=Sg(e,t,r);return re(n)}function Cg(e,t){return e.map((r)=>ai(r,t))}function Pg(e,t){return e.map((r)=>ai(r,t))}function Ag(e,t){let{[t]:r,...n}=e;return n}function kg(e,t){return t.reduce((r,n)=>Ag(r,n),e)}function Tg(e,t,r){let n=Ce(e,[Oe,"$id","required","properties"]),o=kg(r,t);return ue(o,n)}function Fg(e){let t=e.reduce((r,n)=>vo(n)?[...r,se(n)]:r,[]);return ie(t)}function ai(e,t){return Pe(e)?et(Cg(e.allOf,t)):te(e)?ie(Pg(e.anyOf,t)):Ne(e)?Tg(e,t,e.properties):ue({})}function Lr(e,t,r){let n=Ke(t)?Fg(t):t,o=we(t)?ct(t):t,s=Fe(e),i=Fe(t);return _e(e)?Pc(e,o,r):ht(t)?Ac(e,t,r):s&&i?Ie("Omit",[e,n],r):!s&&i?Ie("Omit",[e,n],r):s&&!i?Ie("Omit",[e,n],r):h({...ai(e,o),...r})}function Ng(e,t,r){return{[t]:Lr(e,[t],Re(r))}}function Mg(e,t,r){return t.reduce((n,o)=>({...n,...Ng(e,o,r)}),{})}function jg(e,t,r){return Mg(e,t.keys,r)}function Ac(e,t,r){let n=jg(e,t,r);return re(n)}function Eg(e,t,r){let n={};for(let o of globalThis.Object.getOwnPropertyNames(e))n[o]=Ur(e[o],t,Re(r));return n}function Lg(e,t,r){return Eg(e.properties,t,r)}function kc(e,t,r){let n=Lg(e,t,r);return re(n)}function Ug(e,t){return e.map((r)=>ci(r,t))}function Kg(e,t){return e.map((r)=>ci(r,t))}function Bg(e,t){let r={};for(let n of t)if(n in e)r[n]=e[n];return r}function vg(e,t,r){let n=Ce(e,[Oe,"$id","required","properties"]),o=Bg(r,t);return ue(o,n)}function Dg(e){let t=e.reduce((r,n)=>vo(n)?[...r,se(n)]:r,[]);return ie(t)}function ci(e,t){return Pe(e)?et(Ug(e.allOf,t)):te(e)?ie(Kg(e.anyOf,t)):Ne(e)?vg(e,t,e.properties):ue({})}function Ur(e,t,r){let n=Ke(t)?Dg(t):t,o=we(t)?ct(t):t,s=Fe(e),i=Fe(t);return _e(e)?kc(e,o,r):ht(t)?Tc(e,t,r):s&&i?Ie("Pick",[e,n],r):!s&&i?Ie("Pick",[e,n],r):s&&!i?Ie("Pick",[e,n],r):h({...ci(e,o),...r})}function qg(e,t,r){return{[t]:Ur(e,[t],Re(r))}}function Gg(e,t,r){return t.reduce((n,o)=>({...n,...qg(e,o,r)}),{})}function Hg(e,t,r){return Gg(e,t.keys,r)}function Tc(e,t,r){let n=Hg(e,t,r);return re(n)}function zg(e,t){return Ie("Partial",[Ie(e,t)])}function Vg(e){return Ie("Partial",[$t(e)])}function Jg(e){let t={};for(let r of globalThis.Object.getOwnPropertyNames(e))t[r]=Ze(e[r]);return t}function Wg(e,t){let r=Ce(e,[Oe,"$id","required","properties"]),n=Jg(t);return ue(n,r)}function Fc(e){return e.map((t)=>Nc(t))}function Nc(e){return Tt(e)?zg(e.target,e.parameters):Fe(e)?Vg(e.$ref):Pe(e)?et(Fc(e.allOf)):te(e)?ie(Fc(e.anyOf)):Ne(e)?Wg(e,e.properties):Gr(e)?e:sr(e)?e:Mt(e)?e:gt(e)?e:eo(e)?e:jt(e)?e:ir(e)?e:to(e)?e:ar(e)?e:ue({})}function Wn(e,t){if(_e(e))return Mc(e,t);else return h({...Nc(e),...t})}function Xg(e,t){let r={};for(let n of globalThis.Object.getOwnPropertyNames(e))r[n]=Wn(e[n],Re(t));return r}function Yg(e,t){return Xg(e.properties,t)}function Mc(e,t){let r=Yg(e,t);return re(r)}function Qg(e,t){return Ie("Required",[Ie(e,t)])}function Zg(e){return Ie("Required",[$t(e)])}function eh(e){let t={};for(let r of globalThis.Object.getOwnPropertyNames(e))t[r]=Ce(e[r],[We]);return t}function th(e,t){let r=Ce(e,[Oe,"$id","required","properties"]),n=eh(t);return ue(n,r)}function jc(e){return e.map((t)=>Ec(t))}function Ec(e){return Tt(e)?Qg(e.target,e.parameters):Fe(e)?Zg(e.$ref):Pe(e)?et(jc(e.allOf)):te(e)?ie(jc(e.anyOf)):Ne(e)?th(e,e.properties):Gr(e)?e:sr(e)?e:Mt(e)?e:gt(e)?e:eo(e)?e:jt(e)?e:ir(e)?e:to(e)?e:ar(e)?e:ue({})}function Xn(e,t){if(_e(e))return Lc(e,t);else return h({...Ec(e),...t})}function rh(e,t){let r={};for(let n of globalThis.Object.getOwnPropertyNames(e))r[n]=Xn(e[n],t);return r}function nh(e,t){return rh(e.properties,t)}function Lc(e,t){let r=nh(e,t);return re(r)}function oh(e,t){return t.map((r)=>Fe(r)?ui(e,r.$ref):Rt(e,r))}function ui(e,t){return t in e?Fe(e[t])?ui(e,e[t].$ref):Rt(e,e[t]):J()}function sh(e){return zn(e[0])}function ih(e){return $r(e[0],e[1])}function ah(e){return On(e[0])}function ch(e){return Wn(e[0])}function uh(e){return Lr(e[0],e[1])}function dh(e){return Ur(e[0],e[1])}function fh(e){return Xn(e[0])}function mh(e,t,r){let n=oh(e,r);return t==="Awaited"?sh(n):t==="Index"?ih(n):t==="KeyOf"?ah(n):t==="Partial"?ch(n):t==="Omit"?uh(n):t==="Pick"?dh(n):t==="Required"?fh(n):J()}function ph(e,t){return yn(Rt(e,t))}function lh(e,t){return gn(Rt(e,t))}function yh(e,t,r){return hn($o(e,t),Rt(e,r))}function gh(e,t,r){return Qt($o(e,t),Rt(e,r))}function hh(e,t){return et($o(e,t))}function xh(e,t){return _n(Rt(e,t))}function Ih(e,t){return ue(globalThis.Object.keys(t).reduce((r,n)=>({...r,[n]:Rt(e,t[n])}),{}))}function bh(e,t){let[r,n]=[Rt(e,Is(t)),xs(t)],o=Hn(t);return o.patternProperties[n]=r,o}function Rh(e,t){return Fe(t)?{...ui(e,t.$ref),[Oe]:t[Oe]}:t}function _h(e,t){return Ot($o(e,t))}function Oh(e,t){return ie($o(e,t))}function $o(e,t){return t.map((r)=>Rt(e,r))}function Rt(e,t){return at(t)?h(Rt(e,Ce(t,[We])),t):xn(t)?h(Rt(e,Ce(t,[Xt])),t):ne(t)?h(Rh(e,t),t):kt(t)?h(ph(e,t.items),t):qr(t)?h(lh(e,t.items),t):Tt(t)?h(mh(e,t.target,t.parameters)):Ft(t)?h(yh(e,t.parameters,t.returns),t):Nt(t)?h(gh(e,t.parameters,t.returns),t):Pe(t)?h(hh(e,t.allOf),t):Hr(t)?h(xh(e,t.items),t):Ne(t)?h(Ih(e,t.properties),t):Vr(t)?h(bh(e,t)):It(t)?h(_h(e,t.items||[]),t):te(t)?h(Oh(e,t.anyOf),t):t}function wh(e,t){return t in e?Rt(e,e[t]):J()}function Uc(e){return globalThis.Object.getOwnPropertyNames(e).reduce((t,r)=>({...t,[r]:wh(e,r)}),{})}class Kc{constructor(e){let t=Uc(e),r=this.WithIdentifiers(t);this.$defs=r}Import(e,t){let r={...this.$defs,[e]:h(this.$defs[e],t)};return h({[I]:"Import",$defs:r,$ref:e})}WithIdentifiers(e){return globalThis.Object.getOwnPropertyNames(e).reduce((t,r)=>({...t,[r]:{...e[r],$id:r}}),{})}}function Bc(e){return new Kc(e)}function vc(e,t){return h({[I]:"Not",not:e},t)}function Dc(e,t){return Nt(e)?Ot(e.parameters,t):J()}var $h=0;function qc(e,t={}){if(xe(t.$id))t.$id=`T${$h++}`;let r=Hn(e({[I]:"This",$ref:`${t.$id}`}));return r.$id=t.$id,h({[Yt]:"Recursive",...r},t)}function Gc(e,t){let r=he(e)?new globalThis.RegExp(e):e;return h({[I]:"RegExp",type:"RegExp",source:r.source,flags:r.flags},t)}function Sh(e){return Pe(e)?e.allOf:te(e)?e.anyOf:It(e)?e.items??[]:[]}function Hc(e){return Sh(e)}function zc(e,t){return Nt(e)?h(e.returns,t):J(t)}class Vc{constructor(e){this.schema=e}Decode(e){return new Jc(this.schema,e)}}class Jc{constructor(e,t){this.schema=e,this.decode=t}EncodeTransform(e,t){let o={Encode:(s)=>t[Oe].Encode(e(s)),Decode:(s)=>this.decode(t[Oe].Decode(s))};return{...t,[Oe]:o}}EncodeSchema(e,t){let r={Decode:this.decode,Encode:e};return{...t,[Oe]:r}}Encode(e){return ne(this.schema)?this.EncodeTransform(e,this.schema):this.EncodeSchema(e,this.schema)}}function Wc(e){return new Vc(e)}function Xc(e){return h({[I]:"Void",type:"void"},e)}var Ch=di;import{join as Ah}from"path";import{readFileSync as kh}from"fs";import{join as Ph}from"path";var fi={hash:{algorithm:"argon2id",memoryCost:65536,timeCost:2},port:3000},nr=fi,mi=(e={})=>(nr={...fi,...e,hash:{...fi.hash,...e.hash}},nr);async function Yc(){let e=Ph(process.cwd(),"bare.config.ts");try{let t=await import(e);return mi(t.default)}catch{return mi()}}var bs=(e)=>{if(!e||!e._def)return{type:"object"};let t=e._def,r=t.typeName;if(r==="ZodObject"){let n=typeof t.shape==="function"?t.shape():t.shape,o={},s=[];for(let[i,a]of Object.entries(n||{})){let u=a;if(o[i]=bs(u),u?._def?.typeName!=="ZodOptional"&&u?._def?.typeName!=="ZodDefault")s.push(i)}return{type:"object",properties:o,...s.length?{required:s}:{}}}if(r==="ZodString")return{type:"string"};if(r==="ZodNumber")return{type:"number"};if(r==="ZodBoolean")return{type:"boolean"};if(r==="ZodArray")return{type:"array",items:bs(t.type)};if(r==="ZodOptional"||r==="ZodDefault")return bs(t.innerType);if(r==="ZodEnum")return{type:"string",enum:t.values};return{type:"object"}},So=(e)=>{if(!e)return{type:"object"};if("_def"in e)return bs(e);return JSON.parse(JSON.stringify(e))},pi=(e,t={})=>{let r={};for(let n of e){if(n.path==="/docs"||n.path==="/docs/json")continue;let o=("/"+n.path).replace(/\/+/g,"/").replace(/:([a-zA-Z0-9_]+)/g,"{$1}");if(!r[o])r[o]={};let s=n.method.toLowerCase(),i=[],a=void 0,u=void 0,c=void 0,d=null;for(let p of n.handlers){if(!p)continue;let y=p.__routeSchemas;if(y){if(y.detail)c=y.detail;if(y.params)d=So(y.params);if(y.query){let b=So(y.query),P=new Set(b.required||[]);for(let[E,L]of Object.entries(b.properties||{}))i.push({name:E,in:"query",required:P.has(E),schema:L})}if(y.headers){let b=So(y.headers),P=new Set(b.required||[]);for(let[E,L]of Object.entries(b.properties||{}))i.push({name:E,in:"header",required:P.has(E),schema:L})}if(y.response)u=So(y.response)}if(p.__schema&&!a)a={required:!0,content:{"application/json":{schema:So(p.__schema)}}}}let f=n.path.matchAll(/:([a-zA-Z0-9_]+)/g);for(let p of f){let y=p[1],b=d?.properties?.[y]||{type:"string"};i.unshift({name:y,in:"path",required:!0,schema:b})}r[o][s]={summary:c?.summary||`${n.method} ${o}`,...c?.description?{description:c.description}:{},...c?.tags?{tags:c.tags}:{},...i.length?{parameters:i}:{},...a?{requestBody:a}:{},responses:{"200":{description:"Success",...u?{content:{"application/json":{schema:u}}}:{}}}}}return{openapi:"3.1.0",info:{title:t.title||"BareJS API",version:t.version||"1.0.0",...t.description?{description:t.description}:{}},...t.servers?.length?{servers:t.servers}:{},...t.tags?.length?{tags:t.tags}:{},...t.securitySchemes?{components:{securitySchemes:t.securitySchemes}}:{},...t.security?.length?{security:t.security}:{},paths:r}},li=(e,t="BareJS API Docs")=>{let r=t.replace(/[<>&"]/g,""),n=JSON.stringify(e);return`<!doctype html>
112
+ `,n=(a)=>{if(typeof a==="string")return t.encode(r(a));let u="";if(a.id!==void 0)u+=`id: ${String(a.id).replace(/[\r\n]/g,"")}
113
+ `;if(a.event!==void 0)u+=`event: ${String(a.event).replace(/[\r\n]/g,"")}
114
+ `;if(a.retry!==void 0&&Number.isFinite(a.retry))u+=`retry: ${Math.max(0,Math.floor(a.retry))}
115
+ `;let c=a.data===void 0?"":typeof a.data==="string"?a.data:JSON.stringify(a.data);return u+=r(c),t.encode(u)},o=!1,s=new ReadableStream({async start(a){let u=()=>{if(!o){o=!0;try{a.close()}catch{}}};try{if(typeof e==="function"){let f=e((d,m,y)=>{if(!o)try{a.enqueue(n({data:d,event:m,id:y}))}catch{o=!0}},u);if(f&&typeof f.then==="function")await f,u()}else{for await(let c of e){if(o)break;try{a.enqueue(n(c))}catch{o=!0;break}}u()}}catch(c){if(!o){o=!0;try{a.error(c)}catch{}}}},cancel(){o=!0}}),i={"content-type":"text/event-stream; charset=utf-8","cache-control":"no-cache, no-transform",connection:"keep-alive",...this._headers||{}};return this._applyCookies(new Response(s,{status:this._status||200,headers:i}))}get requestId(){if(this._requestId!==void 0)return this._requestId;let e=this.req?.headers?.get("x-request-id"),t=e?e.replace(/[\x00-\x1f\x7f]/g,""):"";return this._requestId=t.length>0&&t.length<=128?t:crypto.randomUUID(),this._requestId}get ip(){if(this._trustProxy){let e=this.req?.headers?.get("x-forwarded-for");if(e){let r=e.split(",")[0]?.trim();if(r)return r}let t=this.req?.headers?.get("x-real-ip")?.trim()||this.req?.headers?.get("cf-connecting-ip")?.trim();if(t)return t}return this._peerIp||"127.0.0.1"}async upload(e={}){let t=e.maxFileSize??5242880,r=e.maxFiles??10,n=e.allowedTypes?new Set(e.allowedTypes.map((m)=>m.trim().toLowerCase())):null;if(!(this.req?.headers?.get("content-type")||"").toLowerCase().includes("multipart/form-data"))throw Object.assign(Error("Expected multipart/form-data"),{status:400});let s=t*r,i=s+65536,a=Number(this.req?.headers?.get("content-length")||0);if(Number.isFinite(a)&&a>i)throw Object.assign(Error("Payload Too Large"),{status:413});let u;try{if(this.req.body){let m=await this.readBodyWithLimit(i);u=await new Response(m,{headers:this.req.headers}).formData()}else u=await this.req.formData()}catch(m){if(m?.status===413)throw m;throw Object.assign(Error("Malformed multipart/form-data payload"),{status:400})}let c={},f=[],d=0;for(let[m,y]of u.entries()){if(typeof y==="string"){if(d+=Buffer.byteLength(y,"utf-8"),d>s)throw Object.assign(Error(`Total upload size exceeds ${s} bytes`),{status:413});if(m!=="__proto__"&&m!=="constructor"&&m!=="prototype")c[m]=y;continue}let p=y;if(f.length>=r)throw Object.assign(Error(`Too many files (max ${r})`),{status:413});if(p.size>t)throw Object.assign(Error(`File exceeds max size of ${t} bytes`),{status:413});if(d+=p.size,d>s)throw Object.assign(Error(`Total upload size exceeds ${s} bytes`),{status:413});let h=(p.type||"").split(";")[0].trim().toLowerCase();if(n&&!n.has(h))throw Object.assign(Error(`Unsupported file type: ${p.type||"unknown"}`),{status:415});let x=p.name||"file",w=(x.split(/[\\/]/).pop()||"file").replace(/[^a-zA-Z0-9._-]/g,"_").replace(/^\.+/,"")||"file";f.push({fieldName:m,filename:x,safeName:w,type:p.type,size:p.size,file:p})}return{fields:c,files:f}}}function to(e,t){return t===void 0?Fe(e):Fe({...t,...e})}function Ou(e){return I({[O]:"Argument",index:e})}function Jy(e,t){return Pe("Awaited",[Pe(e,t)])}function Wy(e){return Pe("Awaited",[Tt(e)])}function Yy(e){return st(wu(e))}function Xy(e){return be(wu(e))}function Qy(e){return ro(e)}function wu(e){return e.map((t)=>ro(t))}function ro(e,t){return I(Bt(e)?Jy(e.target,e.parameters):Ke(e)?Yy(e.allOf):le(e)?Xy(e.anyOf):rn(e)?Qy(e.item):De(e)?Wy(e.$ref):e,t)}function Zy(e){let t=[];for(let r of e)t.push(...Ft(r));return da(t)}function eg(e){return e.filter((t)=>!Tr(t))}function tg(e,t){let r=[];for(let n of e)r.push(...xo(n,[t]));return eg(r)}function rg(e,t){let r={};for(let n of t)r[n]=es(tg(e,n));return r}function $u(e,t){let r=Zy(e),n=rg(e,r);return Ie(n,t)}function ws(e){return I({[O]:"Date",type:"Date"},e)}function $s(e){return I({[O]:"Null",type:"null"},e)}function ks(e){return I({[O]:"Symbol",type:"symbol"},e)}function As(e){return I({[O]:"Undefined",type:"undefined"},e)}function Ss(e){return I({[O]:"Uint8Array",type:"Uint8Array"},e)}function ng(e){return e.map((t)=>_i(t,!1))}function og(e){let t={};for(let r of globalThis.Object.getOwnPropertyNames(e))t[r]=yt(_i(e[r],!1));return t}function Ps(e,t){return t===!0?e:yt(e)}function _i(e,t){return Ui(e)?Ps(Er(),t):Bi(e)?Ps(Er(),t):He(e)?yt(Pt(ng(e))):Cr(e)?Ss():On(e)?ws():Te(e)?Ps(Ie(og(e)),t):Ki(e)?Ps(ar([],Lr()),t):Se(e)?As():vi(e)?$s():Di(e)?ks():Yo(e)?Cn():It(e)?xe(e):Pr(e)?xe(e):Ae(e)?xe(e):Ie({})}function ku(e,t){return I(_i(e,!0),t)}function Au(e,t){return vt(e)?Pt(e.parameters,t):ne(t)}function Su(e,t){if(Se(e))throw Error("Enum undefined or empty");let r=globalThis.Object.getOwnPropertyNames(e).filter((s)=>isNaN(s)).map((s)=>e[s]),o=[...new Set(r)].map((s)=>xe(s));return be(o,{...t,[ir]:"Enum"})}function Pu(e,t){return no(sn(e),t)}function sg(e,t){let r=e.filter((n)=>Br(n,t)===_.False);return r.length===1?r[0]:be(r)}function no(e,t,r={}){if(Ot(e))return I(Pu(e,t),r);if(Ne(e))return I(Cu(e,t),r);return I(le(e)?sg(e.anyOf,t):Br(e,t)!==_.False?ne():e,r)}function ig(e,t){let r={};for(let n of globalThis.Object.getOwnPropertyNames(e))r[n]=no(e[n],t);return r}function ag(e,t){return ig(e.properties,t)}function Cu(e,t){let r=ag(e,t);return me(r)}function Tu(e,t){return oo(sn(e),t)}function ug(e,t){let r=e.filter((n)=>Br(n,t)!==_.False);return r.length===1?r[0]:be(r)}function oo(e,t,r){if(Ot(e))return I(Tu(e,t),r);if(Ne(e))return I(Fu(e,t),r);return I(le(e)?ug(e.anyOf,t):Br(e,t)!==_.False?e:ne(),r)}function cg(e,t){let r={};for(let n of globalThis.Object.getOwnPropertyNames(e))r[n]=oo(e[n],t);return r}function fg(e,t){return cg(e.properties,t)}function Fu(e,t){let r=fg(e,t);return me(r)}function Nu(e,t){return vt(e)?I(e.returns,t):ne(t)}function Cs(e){return yt(ot(e))}function In(e,t,r){return I({[O]:"Record",type:"object",patternProperties:{[e]:t}},r)}function Ri(e,t,r){let n={};for(let o of e)n[o]=t;return Ie(n,{...r,[ir]:"Record"})}function dg(e,t,r){return Wi(e)?Ri(mt(e),t,r):In(e.pattern,t,r)}function pg(e,t,r){return Ri(mt(be(e)),t,r)}function lg(e,t,r){return Ri([e.toString()],t,r)}function mg(e,t,r){return In(e.source,t,r)}function yg(e,t,r){let n=Se(e.pattern)?Nr:e.pattern;return In(n,t,r)}function gg(e,t,r){return In(Nr,t,r)}function hg(e,t,r){return In(ta,t,r)}function xg(e,t,r){return Ie({true:t,false:t},r)}function bg(e,t,r){return In(Fr,t,r)}function Ig(e,t,r){return In(Fr,t,r)}function Ts(e,t,r={}){return le(e)?pg(e.anyOf,t,r):Ot(e)?dg(e,t,r):_t(e)?lg(e.const,t,r):yr(e)?xg(e,t,r):qt(e)?bg(e,t,r):Gt(e)?Ig(e,t,r):Gs(e)?mg(e,t,r):gr(e)?yg(e,t,r):Ds(e)?gg(e,t,r):Tr(e)?hg(e,t,r):ne(r)}function Fs(e){return globalThis.Object.getOwnPropertyNames(e.patternProperties)[0]}function ju(e){let t=Fs(e);return t===Nr?Ht():t===Fr?St():Ht({pattern:t})}function Ns(e){return e.patternProperties[Fs(e)]}function _g(e,t){return t.parameters=Mo(e,t.parameters),t.returns=rr(e,t.returns),t}function Rg(e,t){return t.parameters=Mo(e,t.parameters),t.returns=rr(e,t.returns),t}function Og(e,t){return t.allOf=Mo(e,t.allOf),t}function wg(e,t){return t.anyOf=Mo(e,t.anyOf),t}function $g(e,t){if(Se(t.items))return t;return t.items=Mo(e,t.items),t}function kg(e,t){return t.items=rr(e,t.items),t}function Ag(e,t){return t.items=rr(e,t.items),t}function Sg(e,t){return t.items=rr(e,t.items),t}function Pg(e,t){return t.item=rr(e,t.item),t}function Cg(e,t){let r=jg(e,t.properties);return{...t,...Ie(r)}}function Tg(e,t){let r=rr(e,ju(t)),n=rr(e,Ns(t)),o=Ts(r,n);return{...t,...o}}function Fg(e,t){return t.index in e?e[t.index]:Lr()}function Ng(e,t){let r=An(t),n=lt(t),o=rr(e,t);return r&&n?Cs(o):r&&!n?yt(o):!r&&n?ot(o):o}function jg(e,t){return globalThis.Object.getOwnPropertyNames(t).reduce((r,n)=>({...r,[n]:Ng(e,t[n])}),{})}function Mo(e,t){return t.map((r)=>rr(e,r))}function rr(e,t){return vt(t)?_g(e,t):Dt(t)?Rg(e,t):Ke(t)?Og(e,t):le(t)?wg(e,t):wt(t)?$g(e,t):Kt(t)?kg(e,t):Zr(t)?Ag(e,t):tn(t)?Sg(e,t):rn(t)?Pg(e,t):qe(t)?Cg(e,t):nn(t)?Tg(e,t):qs(t)?Fg(e,t):t}function Mu(e,t){return rr(t,to(e))}function Eu(e){return I({[O]:"Integer",type:"integer"},e)}function Mg(e,t,r){return{[e]:nr(xe(e),t,Fe(r))}}function Eg(e,t,r){return e.reduce((o,s)=>({...o,...Mg(s,t,r)}),{})}function Lg(e,t,r){return Eg(e.keys,t,r)}function Lu(e,t,r){let n=Lg(e,t,r);return me(n)}function Ug(e){let[t,r]=[e.slice(0,1),e.slice(1)];return[t.toLowerCase(),r].join("")}function Kg(e){let[t,r]=[e.slice(0,1),e.slice(1)];return[t.toUpperCase(),r].join("")}function Bg(e){return e.toUpperCase()}function vg(e){return e.toLowerCase()}function Dg(e,t,r){let n=Pn(e.pattern);if(!on(n))return{...e,pattern:Uu(e.pattern,t)};let i=[...ho(n)].map((c)=>xe(c)),a=Ku(i,t),u=be(a);return os([u],r)}function Uu(e,t){return typeof e==="string"?t==="Uncapitalize"?Ug(e):t==="Capitalize"?Kg(e):t==="Uppercase"?Bg(e):t==="Lowercase"?vg(e):e:e.toString()}function Ku(e,t){return e.map((r)=>nr(r,t))}function nr(e,t,r={}){return Rt(e)?Lu(e,t,r):Ot(e)?Dg(e,t,r):le(e)?be(Ku(e.anyOf,t),r):_t(e)?xe(Uu(e.const,t),r):I(e,r)}function Bu(e,t={}){return nr(e,"Capitalize",t)}function vu(e,t={}){return nr(e,"Lowercase",t)}function Du(e,t={}){return nr(e,"Uncapitalize",t)}function qu(e,t={}){return nr(e,"Uppercase",t)}function qg(e,t,r){let n={};for(let o of globalThis.Object.getOwnPropertyNames(e))n[o]=zr(e[o],t,Fe(r));return n}function Gg(e,t,r){return qg(e.properties,t,r)}function Gu(e,t,r){let n=Gg(e,t,r);return me(n)}function Hg(e,t){return e.map((r)=>Oi(r,t))}function zg(e,t){return e.map((r)=>Oi(r,t))}function Vg(e,t){let{[t]:r,...n}=e;return n}function Jg(e,t){return t.reduce((r,n)=>Vg(r,n),e)}function Wg(e,t,r){let n=Ue(e,[je,"$id","required","properties"]),o=Jg(r,t);return Ie(o,n)}function Yg(e){let t=e.reduce((r,n)=>Zo(n)?[...r,xe(n)]:r,[]);return be(t)}function Oi(e,t){return Ke(e)?st(Hg(e.allOf,t)):le(e)?be(zg(e.anyOf,t)):qe(e)?Wg(e,t,e.properties):Ie({})}function zr(e,t,r){let n=He(t)?Yg(t):t,o=Me(t)?mt(t):t,s=De(e),i=De(t);return Ne(e)?Gu(e,o,r):Rt(t)?Hu(e,t,r):s&&i?Pe("Omit",[e,n],r):!s&&i?Pe("Omit",[e,n],r):s&&!i?Pe("Omit",[e,n],r):I({...Oi(e,o),...r})}function Xg(e,t,r){return{[t]:zr(e,[t],Fe(r))}}function Qg(e,t,r){return t.reduce((n,o)=>({...n,...Xg(e,o,r)}),{})}function Zg(e,t,r){return Qg(e,t.keys,r)}function Hu(e,t,r){let n=Zg(e,t,r);return me(n)}function eh(e,t,r){let n={};for(let o of globalThis.Object.getOwnPropertyNames(e))n[o]=Vr(e[o],t,Fe(r));return n}function th(e,t,r){return eh(e.properties,t,r)}function zu(e,t,r){let n=th(e,t,r);return me(n)}function rh(e,t){return e.map((r)=>wi(r,t))}function nh(e,t){return e.map((r)=>wi(r,t))}function oh(e,t){let r={};for(let n of t)if(n in e)r[n]=e[n];return r}function sh(e,t,r){let n=Ue(e,[je,"$id","required","properties"]),o=oh(r,t);return Ie(o,n)}function ih(e){let t=e.reduce((r,n)=>Zo(n)?[...r,xe(n)]:r,[]);return be(t)}function wi(e,t){return Ke(e)?st(rh(e.allOf,t)):le(e)?be(nh(e.anyOf,t)):qe(e)?sh(e,t,e.properties):Ie({})}function Vr(e,t,r){let n=He(t)?ih(t):t,o=Me(t)?mt(t):t,s=De(e),i=De(t);return Ne(e)?zu(e,o,r):Rt(t)?Vu(e,t,r):s&&i?Pe("Pick",[e,n],r):!s&&i?Pe("Pick",[e,n],r):s&&!i?Pe("Pick",[e,n],r):I({...wi(e,o),...r})}function ah(e,t,r){return{[t]:Vr(e,[t],Fe(r))}}function uh(e,t,r){return t.reduce((n,o)=>({...n,...ah(e,o,r)}),{})}function ch(e,t,r){return uh(e,t.keys,r)}function Vu(e,t,r){let n=ch(e,t,r);return me(n)}function fh(e,t){return Pe("Partial",[Pe(e,t)])}function dh(e){return Pe("Partial",[Tt(e)])}function ph(e){let t={};for(let r of globalThis.Object.getOwnPropertyNames(e))t[r]=ot(e[r]);return t}function lh(e,t){let r=Ue(e,[je,"$id","required","properties"]),n=ph(t);return Ie(n,r)}function Ju(e){return e.map((t)=>Wu(t))}function Wu(e){return Bt(e)?fh(e.target,e.parameters):De(e)?dh(e.$ref):Ke(e)?st(Ju(e.allOf)):le(e)?be(Ju(e.anyOf)):qe(e)?lh(e,e.properties):en(e)?e:yr(e)?e:qt(e)?e:_t(e)?e:po(e)?e:Gt(e)?e:gr(e)?e:lo(e)?e:hr(e)?e:Ie({})}function so(e,t){if(Ne(e))return Yu(e,t);else return I({...Wu(e),...t})}function mh(e,t){let r={};for(let n of globalThis.Object.getOwnPropertyNames(e))r[n]=so(e[n],Fe(t));return r}function yh(e,t){return mh(e.properties,t)}function Yu(e,t){let r=yh(e,t);return me(r)}function gh(e,t){return Pe("Required",[Pe(e,t)])}function hh(e){return Pe("Required",[Tt(e)])}function xh(e){let t={};for(let r of globalThis.Object.getOwnPropertyNames(e))t[r]=Ue(e[r],[et]);return t}function bh(e,t){let r=Ue(e,[je,"$id","required","properties"]),n=xh(t);return Ie(n,r)}function Xu(e){return e.map((t)=>Qu(t))}function Qu(e){return Bt(e)?gh(e.target,e.parameters):De(e)?hh(e.$ref):Ke(e)?st(Xu(e.allOf)):le(e)?be(Xu(e.anyOf)):qe(e)?bh(e,e.properties):en(e)?e:yr(e)?e:qt(e)?e:_t(e)?e:po(e)?e:Gt(e)?e:gr(e)?e:lo(e)?e:hr(e)?e:Ie({})}function io(e,t){if(Ne(e))return Zu(e,t);else return I({...Qu(e),...t})}function Ih(e,t){let r={};for(let n of globalThis.Object.getOwnPropertyNames(e))r[n]=io(e[n],t);return r}function _h(e,t){return Ih(e.properties,t)}function Zu(e,t){let r=_h(e,t);return me(r)}function Rh(e,t){return t.map((r)=>De(r)?$i(e,r.$ref):kt(e,r))}function $i(e,t){return t in e?De(e[t])?$i(e,e[t].$ref):kt(e,e[t]):ne()}function Oh(e){return ro(e[0])}function wh(e){return jr(e[0],e[1])}function $h(e){return Fn(e[0])}function kh(e){return so(e[0])}function Ah(e){return zr(e[0],e[1])}function Sh(e){return Vr(e[0],e[1])}function Ph(e){return io(e[0])}function Ch(e,t,r){let n=Rh(e,r);return t==="Awaited"?Oh(n):t==="Index"?wh(n):t==="KeyOf"?$h(n):t==="Partial"?kh(n):t==="Omit"?Ah(n):t==="Pick"?Sh(n):t==="Required"?Ph(n):ne()}function Th(e,t){return wn(kt(e,t))}function Fh(e,t){return $n(kt(e,t))}function Nh(e,t,r){return kn(Eo(e,t),kt(e,r))}function jh(e,t,r){return ar(Eo(e,t),kt(e,r))}function Mh(e,t){return st(Eo(e,t))}function Eh(e,t){return Tn(kt(e,t))}function Lh(e,t){return Ie(globalThis.Object.keys(t).reduce((r,n)=>({...r,[n]:kt(e,t[n])}),{}))}function Uh(e,t){let[r,n]=[kt(e,Ns(t)),Fs(t)],o=to(t);return o.patternProperties[n]=r,o}function Kh(e,t){return De(t)?{...$i(e,t.$ref),[je]:t[je]}:t}function Bh(e,t){return Pt(Eo(e,t))}function vh(e,t){return be(Eo(e,t))}function Eo(e,t){return t.map((r)=>kt(e,r))}function kt(e,t){return lt(t)?I(kt(e,Ue(t,[et])),t):An(t)?I(kt(e,Ue(t,[sr])),t):ye(t)?I(Kh(e,t),t):Kt(t)?I(Th(e,t.items),t):Zr(t)?I(Fh(e,t.items),t):Bt(t)?I(Ch(e,t.target,t.parameters)):vt(t)?I(Nh(e,t.parameters,t.returns),t):Dt(t)?I(jh(e,t.parameters,t.returns),t):Ke(t)?I(Mh(e,t.allOf),t):tn(t)?I(Eh(e,t.items),t):qe(t)?I(Lh(e,t.properties),t):nn(t)?I(Uh(e,t)):wt(t)?I(Bh(e,t.items||[]),t):le(t)?I(vh(e,t.anyOf),t):t}function Dh(e,t){return t in e?kt(e,e[t]):ne()}function ec(e){return globalThis.Object.getOwnPropertyNames(e).reduce((t,r)=>({...t,[r]:Dh(e,r)}),{})}class tc{constructor(e){let t=ec(e),r=this.WithIdentifiers(t);this.$defs=r}Import(e,t){let r={...this.$defs,[e]:I(this.$defs[e],t)};return I({[O]:"Import",$defs:r,$ref:e})}WithIdentifiers(e){return globalThis.Object.getOwnPropertyNames(e).reduce((t,r)=>({...t,[r]:{...e[r],$id:r}}),{})}}function rc(e){return new tc(e)}function nc(e,t){return I({[O]:"Not",not:e},t)}function oc(e,t){return Dt(e)?Pt(e.parameters,t):ne()}var qh=0;function sc(e,t={}){if(Se(t.$id))t.$id=`T${qh++}`;let r=to(e({[O]:"This",$ref:`${t.$id}`}));return r.$id=t.$id,I({[ir]:"Recursive",...r},t)}function ic(e,t){let r=Ae(e)?new globalThis.RegExp(e):e;return I({[O]:"RegExp",type:"RegExp",source:r.source,flags:r.flags},t)}function Gh(e){return Ke(e)?e.allOf:le(e)?e.anyOf:wt(e)?e.items??[]:[]}function ac(e){return Gh(e)}function uc(e,t){return Dt(e)?I(e.returns,t):ne(t)}class cc{constructor(e){this.schema=e}Decode(e){return new fc(this.schema,e)}}class fc{constructor(e,t){this.schema=e,this.decode=t}EncodeTransform(e,t){let o={Encode:(s)=>t[je].Encode(e(s)),Decode:(s)=>this.decode(t[je].Decode(s))};return{...t,[je]:o}}EncodeSchema(e,t){let r={Decode:this.decode,Encode:e};return{...t,[je]:r}}Encode(e){return ye(this.schema)?this.EncodeTransform(e,this.schema):this.EncodeSchema(e,this.schema)}}function dc(e){return new cc(e)}function pc(e){return I({[O]:"Void",type:"void"},e)}var Hh=ki;import{join as Yh}from"path";import{readFileSync as Xh}from"fs";import{existsSync as zh}from"fs";import{createRequire as Vh}from"module";import{join as Jh}from"path";var Ai={hash:{algorithm:"argon2id",memoryCost:65536,timeCost:2},port:3000},Et=Ai,js=(e={})=>{let t=e&&typeof e==="object"&&!Array.isArray(e)?e:{};return Et={...Ai,...t,hash:{...Ai.hash,...t.hash&&typeof t.hash==="object"&&!Array.isArray(t.hash)?t.hash:{}}},Et};var Si=Vh(import.meta.url);async function lc(){let e=Jh(process.cwd(),"bare.config.ts");if(!zh(e))return js();try{let t=Si.resolve(e);delete Si.cache[t];let r=Si(t);return js(r?.default??r)}catch(t){return console.warn("[BareJS] Failed to load bare.config.ts:",t?.message||t),js()}}var Jr=(e)=>{if(!e||!e._def)return{type:"object"};let t=e._def,r=t.typeName;if(r==="ZodObject"){let n=typeof t.shape==="function"?t.shape():t.shape,o={},s=[];for(let[i,a]of Object.entries(n||{})){let u=a;if(o[i]=Jr(u),u?._def?.typeName!=="ZodOptional"&&u?._def?.typeName!=="ZodDefault")s.push(i)}return{type:"object",properties:o,...s.length?{required:s}:{}}}if(r==="ZodString"){let n={type:"string"};for(let o of t.checks||[])if(o.kind==="min")n.minLength=o.value;else if(o.kind==="max")n.maxLength=o.value;else if(o.kind==="email")n.format="email";else if(o.kind==="uuid")n.format="uuid";return n}if(r==="ZodNumber"){let n={type:"number"};for(let o of t.checks||[])if(o.kind==="int")n.type="integer";else if(o.kind==="min")n[o.inclusive===!1?"exclusiveMinimum":"minimum"]=o.value;else if(o.kind==="max")n[o.inclusive===!1?"exclusiveMaximum":"maximum"]=o.value;return n}if(r==="ZodNullable")return{anyOf:[Jr(t.innerType),{type:"null"}]};if(r==="ZodBoolean")return{type:"boolean"};if(r==="ZodArray")return{type:"array",items:Jr(t.type)};if(r==="ZodOptional"||r==="ZodDefault")return Jr(t.innerType);if(r==="ZodEffects")return Jr(t.schema);if(r==="ZodLiteral")return{const:t.value};if(r==="ZodDate")return{type:"string",format:"date-time"};if(r==="ZodRecord")return{type:"object",additionalProperties:Jr(t.valueType)};if(r==="ZodUnion"&&Array.isArray(t.options))return{anyOf:t.options.map(Jr)};if(r==="ZodEnum")return{type:"string",enum:t.values};return{type:"object"}},Lo=(e)=>{if(!e)return{type:"object"};if("_def"in e)return Jr(e);return JSON.parse(JSON.stringify(e))},Pi=(e,t={})=>{let r={},n=new Set(["/docs","/docs/json",...t.excludePaths||[]]);for(let o of e){if(n.has(o.path))continue;let s=("/"+o.path).replace(/\/+/g,"/").replace(/:([a-zA-Z0-9_]+)/g,"{$1}").replace(/\/\*$/,"/{wildcard}");if(!r[s])r[s]={};let i=o.method.toLowerCase(),a=[],u=void 0,c=void 0,f=void 0,d=null;for(let h of o.handlers){if(!h)continue;let x=h.__routeSchemas;if(x){if(x.detail)f=x.detail;if(x.params)d=Lo(x.params);if(x.query){let R=Lo(x.query),w=new Set(R.required||[]);for(let[P,C]of Object.entries(R.properties||{}))a.push({name:P,in:"query",required:w.has(P),schema:C})}if(x.headers){let R=Lo(x.headers),w=new Set(R.required||[]);for(let[P,C]of Object.entries(R.properties||{}))a.push({name:P,in:"header",required:w.has(P),schema:C})}if(x.response)c=Lo(x.response)}if(h.__schema&&!u)u={required:!0,content:{"application/json":{schema:Lo(h.__schema)}}}}let m=[],y=o.path.matchAll(/:([a-zA-Z0-9_]+)/g);for(let h of y){let x=h[1],R=d?.properties?.[x]||{type:"string"};m.push({name:x,in:"path",required:!0,schema:R})}if(/\/\*$/.test(o.path))m.push({name:"wildcard",in:"path",required:!0,schema:{type:"string"}});let p=[...m,...a];r[s][i]={summary:f?.summary||`${o.method} ${s}`,...f?.description?{description:f.description}:{},...f?.tags?{tags:f.tags}:{},...p.length?{parameters:p}:{},...u?{requestBody:u}:{},responses:{"200":{description:"Success",...c?{content:{"application/json":{schema:c}}}:{}}}}}return{openapi:"3.1.0",info:{title:t.title||"BareJS API",version:t.version||"1.0.0",...t.description?{description:t.description}:{}},...t.servers?.length?{servers:t.servers}:{},...t.tags?.length?{tags:t.tags}:{},...t.securitySchemes?{components:{securitySchemes:t.securitySchemes}}:{},...t.security?.length?{security:t.security}:{},paths:r}},Wh=(e)=>e.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/'/g,"&#39;").replace(/</g,"&lt;").replace(/>/g,"&gt;"),Ci=(e,t="BareJS API Docs")=>{let r=t.replace(/[<>&"]/g,""),n=Wh(e);return`<!doctype html>
84
116
  <html>
85
117
  <head>
86
118
  <title>${r}</title>
@@ -88,29 +120,35 @@ ${p} ${r}[${c}] = ${f};
88
120
  <meta name="viewport" content="width=device-width, initial-scale=1" />
89
121
  </head>
90
122
  <body>
91
- <script id="api-reference" data-url=${n}></script>
123
+ <script id="api-reference" data-url="${n}"></script>
92
124
  <script src="https://cdn.jsdelivr.net/npm/@scalar/api-reference"></script>
93
125
  </body>
94
- </html>`};class Qc extends cn{tree=new un;pool=[];hotFetch;compiled=!1;poolMask;_useLog=!1;_trustProxy=!1;errorHandler;wsRoutes=new Map;startHooks=[];stopHooks=[];crons=[];server;shutdownHandler;wsAdapter={open(e){e.data?.open?.(e)},message(e,t){e.data?.message?.(e,t)},close(e,t,r){e.data?.close?.(e,t,r)},drain(e){e.data?.drain?.(e)}};useLog(e=!0){return this._useLog=e,this}onStart(e){return this.startHooks.push(e),this}onStop(e){return this.stopHooks.push(e),this}cron(e,t,r,n={}){let o=!1,s=async()=>{if(o)return;o=!0;try{await r()}catch(a){n.onError?.(a)}finally{o=!1}},i=setInterval(s,t);if(this.crons.push({name:e,timer:i}),n.runOnStart)s();return this}async stop(e=!1){for(let t of this.crons)clearInterval(t.timer);if(this.crons.length=0,this.shutdownHandler)process.off("SIGINT",this.shutdownHandler),process.off("SIGTERM",this.shutdownHandler),this.shutdownHandler=void 0;if(this.server)this.server.stop(e),this.server=void 0;for(let t of this.stopHooks)await t()}constructor(e=1024){super();Yc();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 Oo);try{let r=Ah(process.cwd(),"package.json"),n=JSON.parse(kh(r,"utf-8"));if(n.name)this.name=n.name.split(/[-_]/).map((o)=>o.charAt(0).toUpperCase()+o.slice(1)).join(" ")}catch{this.name="App"}}notFoundHandler=()=>({status:404,message:"Route not found"});setNotFound(e){this.notFoundHandler=e}onError(e){return this.errorHandler=e,this}ws(e,t){let r=("/"+e).replace(/\/+/g,"/").replace(/\/$/,"")||"/";return this.wsRoutes.set(r,t),this}docs(e="/docs",t={}){let r=("/"+e).replace(/\/+/g,"/").replace(/\/$/,"")||"/docs",n=`${r}/json`,o=null,s=li(n,t.title||`${this.name} API Docs`);return this.get(n,()=>{if(!o)o=JSON.stringify(pi(this.routes,{title:this.name,...t}));return new Response(o,{status:200,headers:{"content-type":"application/json"}})}),this.get(r,()=>new Response(s,{status:200,headers:{"content-type":"text/html; charset=utf-8"}})),this}rpc(e,t,r={}){let n=r.maxBatchSize??100,o=!1,s=async(i,a)=>{if(!i||i.jsonrpc!=="2.0"||typeof i.method!=="string")return{jsonrpc:"2.0",error:{code:-32600,message:"Invalid Request"},id:i?.id??null};let u=Object.hasOwn(t,i.method)?t[i.method]:void 0;if(!u)return{jsonrpc:"2.0",error:{code:-32601,message:"Method not found"},id:i.id??null};try{let c=await u(i.params,a);if(i.id===void 0)return null;return{jsonrpc:"2.0",result:c,id:i.id}}catch(c){return{jsonrpc:"2.0",error:{code:-32603,message:c?.message||"Internal error"},id:i.id??null}}};return this.post(e,async(i)=>{let a=await i.jsonBody();if(!a)return i.status(400).json({jsonrpc:"2.0",error:{code:-32700,message:"Parse error"},id:null});if(Array.isArray(a)){if(a.length===0||a.length>n)return i.status(400).json({jsonrpc:"2.0",error:{code:-32600,message:"Invalid Request"},id:null});let c=(await Promise.all(a.map((d)=>s(d,i)))).filter(Boolean);return c.length>0?c:new Response(null,{status:204})}let u=await s(a,i);return u===null?new Response(null,{status:204}):u}),this}_hasDerive=!1;derive(e){return this._hasDerive=!0,this.use(async(t,r)=>{let n=await e(t);if(n&&typeof n==="object"){let o=Object.keys(n);if(!t._derivedKeys)t._derivedKeys=[];for(let s=0;s<o.length;s++){let i=o[s];if(i!=="__proto__"&&i!=="constructor"&&i!=="prototype")t[i]=n[i],t._derivedKeys.push(i)}}return r()}),this}compileHandler(e,t){if(e.length===0)return()=>{return};let r=(_,C)=>{if(C._headers)for(let j in C._headers){let U=C._headers[j];if(U!==void 0&&!_.headers.has(j))try{_.headers.set(j,U)}catch{}}if(C._setCookies){for(let j=0;j<C._setCookies.length;j++)try{_.headers.append("Set-Cookie",C._setCookies[j])}catch{}C._setCookies=void 0}return _},n=e.find((_)=>_?.__timeout);if(n){let{ms:_,status:C,message:j}=n.__timeout,U=e.filter((me)=>!me?.__timeout),Ee=this.compileHandler(U,t);return async(me,K)=>{let B=Ee(me,K);if(!B||!B.then)return B;let G;try{let Le=new Promise((Te)=>{G=setTimeout(()=>{if(me._detached=!0,typeof B.catch==="function")B.catch(()=>{});Te(r(Response.json({status:"error",code:"REQUEST_TIMEOUT",message:j},{status:C}),me))},_)});return await Promise.race([B,Le])}finally{if(G!==void 0)clearTimeout(G)}}}let o=e.find((_)=>_?.__circuitBreaker);if(o){let _=o.__circuitBreaker,C=e.filter((U)=>!U?.__circuitBreaker),j=this.compileHandler(C,t);return(U,Ee)=>_(()=>j(U,Ee))}let s=e.find((_)=>_?.__compress);if(s){let _=s.__compress,C=e.filter((U)=>!U?.__compress),j=this.compileHandler(C,t);return async(U,Ee)=>{let me=await j(U,Ee);return _(U,me)}}let i=e.length,u=e.find((_)=>_?.__responseFilter)?.__responseFilter,c=e.find((_)=>_?.__idempotencyCommit),d=c?.__idempotencyCommit,f=c?.__idempotencyRelease,p={status:200,headers:{"content-type":"application/json"}},y={status:200,headers:{"content-type":"text/plain"}},E=`
95
- ${u?"res = rFilter(res);":""}
96
- if (res instanceof Response) {
97
- ${d?"idemCommit(ctx, res, res.status);":""}
98
- if (ctx._headers) {
99
- for (const k in ctx._headers) {
100
- if (!res.headers.has(k)) res.headers.set(k, ctx._headers[k]);
126
+ </html>`};class Ti extends xn{tree=new bn;pool=[];hotFetch;compiled=!1;_useLog=!1;_trustProxyBox={val:!1};errorHandler;wsRoutes=new Map;startHooks=[];stopHooks=[];crons=[];server;shutdownHandler;wsAdapter={open(e){e.data?.open?.(e)},message(e,t){e.data?.message?.(e,t)},close(e,t,r){e.data?.close?.(e,t,r)},drain(e){e.data?.drain?.(e)}};useLog(e=!0){return this._useLog=e,this}onStart(e){return this.startHooks.push(e),this}onStop(e){return this.stopHooks.push(e),this}cron(e,t,r,n={}){if(!Number.isFinite(t)||t<=0)throw RangeError(`cron("${e}") intervalMs must be a positive finite number`);let o=!1,s=async()=>{if(o)return;o=!0;try{await r()}catch(a){n.onError?.(a)}finally{o=!1}},i=setInterval(s,t);if(this.crons.push({name:e,timer:i}),n.runOnStart)s();return this}async stop(e=!1){for(let t of this.crons)clearInterval(t.timer);if(this.crons.length=0,this.shutdownHandler)process.off("SIGINT",this.shutdownHandler),process.off("SIGTERM",this.shutdownHandler),this.shutdownHandler=void 0;if(this.server)this.server.stop(e),this.server=void 0;for(let t of this.stopHooks)try{await t()}catch(r){console.error(`[${this.name}] onStop error:`,r)}}constructor(e=1024){super();lc();let t=Math.pow(2,Math.ceil(Math.log2(e)));for(let r=0;r<t;r++)this.pool.push(new jo);try{let r=Yh(process.cwd(),"package.json"),n=JSON.parse(Xh(r,"utf-8"));if(n.name)this.name=n.name.split(/[-_]/).map((o)=>o.charAt(0).toUpperCase()+o.slice(1)).join(" ")}catch{this.name="App"}}notFoundHandler=()=>({status:404,message:"Route not found"});setNotFound(e){this.notFoundHandler=e}onError(e){return this.errorHandler=e,this}ws(e,t){let r=("/"+e).replace(/\/+/g,"/").replace(/\/$/,"")||"/";return this.wsRoutes.set(r,t),this}docs(e="/docs",t={}){let r=("/"+e).replace(/\/+/g,"/").replace(/\/$/,"")||"/docs",n=`${r}/json`,o=null,s=Ci(n,t.title||`${this.name} API Docs`);return this.get(n,()=>{if(!o)o=JSON.stringify(Pi(this.routes,{title:this.name,excludePaths:[r,n],...t}));return new Response(o,{status:200,headers:{"content-type":"application/json"}})}),this.get(r,()=>new Response(s,{status:200,headers:{"content-type":"text/html; charset=utf-8"}})),this}rpc(e,t,r={}){let n=r.maxBatchSize??100,o=!1,s=async(i,a)=>{if(!i||i.jsonrpc!=="2.0"||typeof i.method!=="string")return{jsonrpc:"2.0",error:{code:-32600,message:"Invalid Request"},id:i?.id??null};let u=Object.hasOwn(t,i.method)?t[i.method]:void 0;if(!u)return{jsonrpc:"2.0",error:{code:-32601,message:"Method not found"},id:i.id??null};try{let c=await u(i.params,a);if(i.id===void 0)return null;return{jsonrpc:"2.0",result:c,id:i.id}}catch(c){return{jsonrpc:"2.0",error:{code:-32603,message:c?.message||"Internal error"},id:i.id??null}}};return this.post(e,async(i)=>{let a=await i.jsonBody();if(!a)return i.status(400).json({jsonrpc:"2.0",error:{code:-32700,message:"Parse error"},id:null});if(Array.isArray(a)){if(a.length===0||a.length>n)return i.status(400).json({jsonrpc:"2.0",error:{code:-32600,message:"Invalid Request"},id:null});let c=(await Promise.all(a.map((f)=>s(f,i)))).filter(Boolean);return c.length>0?c:new Response(null,{status:204})}let u=await s(a,i);return u===null?new Response(null,{status:204}):u}),this}_hasDerive=!1;static DERIVE_RESERVED=new Set(["__proto__","constructor","prototype","req","params","store","body","user","query","cookies","requestId","ip","status","json","html","text","redirect","sse","upload","reset","set","get","setHeader","setCookie","getSignedCookie","deleteCookie","jsonBody","send","getQuery","_status","_headers","_query","_cookies","_setCookies","_requestId","_peerIp","_trustProxy","_detached","_derivedKeys","_idempotencyKey","_idemInFlight"]);derive(e){this._hasDerive=!0;let t=async(r,n)=>{let o=await e(r);if(o&&typeof o==="object"){let s=Object.keys(o);if(!r._derivedKeys)r._derivedKeys=[];for(let i=0;i<s.length;i++){let a=s[i];if(a==="user")r.set("user",o[a]);else if(!Ti.DERIVE_RESERVED.has(a))r[a]=o[a],r._derivedKeys.push(a)}}return n()};return t.__isDerive=!0,this.use(t),this}compileHandler(e,t){if(e.length===0)return()=>{return};let r=(A,oe)=>{if(oe._headers)for(let Q in oe._headers){let re=oe._headers[Q];if(re===void 0)continue;if(!A.headers.has(Q))try{A.headers.set(Q,re)}catch{}else if(Q.toLowerCase()==="vary"){let ie=A.headers.get("vary")||"",ge=ie.toLowerCase().split(",").map((ae)=>ae.trim()),ee=re.split(",").map((ae)=>ae.trim()).filter((ae)=>ae&&!ge.includes(ae.toLowerCase()));if(ee.length>0)try{A.headers.set("vary",ie?`${ie}, ${ee.join(", ")}`:ee.join(", "))}catch{}}}if(oe._setCookies){for(let Q=0;Q<oe._setCookies.length;Q++)try{A.headers.append("Set-Cookie",oe._setCookies[Q])}catch{}oe._setCookies=void 0}return A},n=e.find((A)=>A?.__compress);if(n){let A=n.__compress,oe=e.filter((re)=>!re?.__compress),Q=this.compileHandler(oe,t);return async(re,ie)=>{let ge=await Q(re,ie);return A(re,ge)}}let o=e.findIndex((A)=>A?.__circuitBreaker);if(o!==-1){let oe=e[o].__circuitBreaker,Q=e.slice(0,o),re=[],ie=[];for(let D=0;D<Q.length;D++){let k=Q[D];if(k?.__timeout||k?.__idempotencyCommit||k?.__responseFilter)ie.push(k);else re.push(k)}let ge=[...ie,...e.slice(o+1)],ee=this.compileHandler(ge,t),ae=()=>{};return async(D,k)=>{for(let we=0;we<re.length;we++){let Ce=re[we](D,ae);if(Ce&&typeof Ce.then==="function")Ce=await Ce;if(Ce instanceof Response){if(r(Ce,D),t&&k&&!D._detached)k(Ce.status);return Ce}}let v=!1,G=await oe(()=>(v=!0,ee(D,k)));if(!v&&G instanceof Response){if(r(G,D),t&&k&&!D._detached)k(G.status)}return G}}let s=e.filter((A)=>A?.__timeout);if(s.length>0){let A=s[0].__timeout;for(let ee=1;ee<s.length;ee++)if(s[ee].__timeout.ms<A.ms)A=s[ee].__timeout;let{ms:oe,status:Q,message:re}=A,ie=e.filter((ee)=>!ee?.__timeout),ge=this.compileHandler(ie,t);return async(ee,ae)=>{let D=ge(ee,ae);if(!D||!D.then)return D;let k;try{let v=new Promise((G)=>{k=setTimeout(()=>{if(ee._detached=!0,ee._idempotencyKey&&ee._idemInFlight)ee._idemInFlight.delete(ee._idempotencyKey),ee._idempotencyKey=void 0,ee._idemInFlight=void 0;if(typeof D.catch==="function")D.catch(()=>{});if(t&&ae)ae(Q);G(r(Response.json({status:"error",code:"REQUEST_TIMEOUT",message:re},{status:Q}),ee))},oe)});return await Promise.race([D,v])}finally{if(k!==void 0)clearTimeout(k)}}}let i=e.length,u=e.find((A)=>A?.__responseFilter)?.__responseFilter,c=e.find((A)=>A?.__idempotencyCommit),f=c?.__idempotencyCommit,d=c?.__idempotencyRelease,m={status:200,headers:{"content-type":"application/json"}},y={status:200,headers:{"content-type":"text/plain"}},p=t?"if (!ctx._detached) doLog(res.status);":"",h=t?"if (!ctx._detached) doLog(finalStatus);":"",x=`
127
+ if (ctx._headers) {
128
+ for (const k in ctx._headers) {
129
+ const val = ctx._headers[k];
130
+ if (val === undefined) continue;
131
+ if (!res.headers.has(k)) {
132
+ try { res.headers.set(k, val); } catch {}
133
+ } else if (k.toLowerCase() === 'vary') {
134
+ const existing = res.headers.get('vary') || '';
135
+ const parts = existing.toLowerCase().split(',').map((v) => v.trim());
136
+ const toAdd = val.split(',').map((v) => v.trim()).filter((v) => v && !parts.includes(v.toLowerCase()));
137
+ if (toAdd.length > 0) {
138
+ try { res.headers.set('vary', existing ? \`\${existing}, \${toAdd.join(', ')}\` : toAdd.join(', ')); } catch {}
139
+ }
101
140
  }
102
141
  }
103
- if (ctx._setCookies) {
104
- for (let i = 0; i < ctx._setCookies.length; i++) res.headers.append('Set-Cookie', ctx._setCookies[i]);
142
+ }
143
+ if (ctx._setCookies) {
144
+ for (let i = 0; i < ctx._setCookies.length; i++) {
145
+ try { res.headers.append('Set-Cookie', ctx._setCookies[i]); } catch {}
105
146
  }
106
- ${t?"doLog(res.status);":""}
107
- return res;
108
147
  }
109
-
110
- const finalStatus = ctx._status || 200;
111
- ${d?"idemCommit(ctx, res, finalStatus);":""}
112
- ${t?"doLog(finalStatus);":""}
113
-
148
+ ${p}
149
+ return res;
150
+ `,R=`
151
+ ${h}
114
152
  let outRes;
115
153
  if (typeof res === 'string') {
116
154
  if (finalStatus === 200 && !ctx._headers) {
@@ -136,36 +174,67 @@ ${p} ${r}[${c}] = ${f};
136
174
  }
137
175
 
138
176
  if (ctx._setCookies) {
139
- for (let i = 0; i < ctx._setCookies.length; i++) outRes.headers.append('Set-Cookie', ctx._setCookies[i]);
177
+ for (let i = 0; i < ctx._setCookies.length; i++) {
178
+ try { outRes.headers.append('Set-Cookie', ctx._setCookies[i]); } catch {}
179
+ }
140
180
  }
141
181
  return outRes;
142
- `,L=t?"ctx, doLog":"ctx",ae=["applyShortCircuit",...u?["rFilter"]:[],...d?["idemCommit"]:[],...f?["idemRelease"]:[]],Me=[r,...u?[u]:[],...d?[d]:[],...f?[f]:[]],qe=(_)=>{if(!f)return _;return(C,j)=>{try{let U=_(C,j);if(U&&typeof U.then==="function")return U.then((Ee)=>Ee,(Ee)=>{throw f(C),Ee});return U}catch(U){throw f(C),U}}};if(i===1){let _=e[0];if(_.constructor.name==="AsyncFunction")return qe(Function("fn0","json200","text200",...ae,`let lastHdrs = null, lastInit200 = null; return async function(${L}) {
143
- const res = await fn0(ctx);
144
- ${E}
145
- }`)(_,p,y,...Me));return qe(Function("fn0","json200","text200",...ae,`let lastHdrs = null, lastInit200 = null; return function(${L}) {
146
- const res = fn0(ctx);
147
- if (res && res.then) return res.then(v => { const res = v; ${E} });
148
- ${E}
149
- }`)(_,p,y,...Me))}let je=e.some((_)=>_.constructor.name==="AsyncFunction"),ce="",M=e.map((_,C)=>`fn${C}`);if(je){for(let _=0;_<i-1;_++)ce+=`let r${_} = fn${_}(ctx, noop);
150
- `,ce+=`if (r${_}) {
151
- `,ce+=` if (r${_}.then) r${_} = await r${_};
152
- `,ce+=` if (r${_} instanceof Response) { applyShortCircuit(r${_}, ctx); ${t?"doLog(r"+_+".status);":""} return r${_}; }
153
- `,ce+=`}
154
- `;ce+=`
155
- let res = fn${i-1}(ctx);
182
+ `,w=`
183
+ ${u?"res = rFilter(res);":""}
184
+ if (res instanceof Response) {
185
+ ${f?"const ic = idemCommit(ctx, res, res.status); if (ic && ic.then) return ic.then(() => { "+x+" });":""}
186
+ ${x}
187
+ }
188
+
189
+ const finalStatus = ctx._status || 200;
190
+ ${f?"const ic = idemCommit(ctx, res, finalStatus); if (ic && ic.then) return ic.then(() => { "+R+" });":""}
191
+ ${R}
192
+ `,P=t?"ctx, doLog":"ctx",C=()=>{},J=["applyShortCircuit","noop",...u?["rFilter"]:[],...f?["idemCommit"]:[],...d?["idemRelease"]:[]],z=[r,C,...u?[u]:[],...f?[f]:[],...d?[d]:[]],L=(A)=>{if(!d)return A;return(oe,Q)=>{try{let re=A(oe,Q);if(re&&typeof re.then==="function")return re.then((ie)=>ie,(ie)=>{throw d(oe),ie});return re}catch(re){throw d(oe),re}}};if(i===1){let A=e[0];if(A.constructor.name==="AsyncFunction")return L(Function("fn0","json200","text200",...J,`let lastHdrs = null, lastInit200 = null; return async function(${P}) {
193
+ const res = await fn0(ctx, noop);
194
+ ${w}
195
+ }`)(A,m,y,...z));return L(Function("fn0","json200","text200",...J,`let lastHdrs = null, lastInit200 = null; return function(${P}) {
196
+ const res = fn0(ctx, noop);
197
+ if (res && res.then) return res.then(v => { const res = v; ${w} });
198
+ ${w}
199
+ }`)(A,m,y,...z))}let T=e.some((A)=>A.constructor.name==="AsyncFunction"),B="",Z=e.map((A,oe)=>`fn${oe}`),W="";if(T){for(let A=0;A<i-1;A++)B+=`let r${A} = fn${A}(ctx, noop);
200
+ `,B+=`if (r${A}) {
201
+ `,B+=` if (r${A}.then) r${A} = await r${A};
202
+ `,B+=` if (r${A} instanceof Response) { applyShortCircuit(r${A}, ctx); ${t?"if (!ctx._detached) doLog(r"+A+".status);":""} return r${A}; }
203
+ `,B+=`}
204
+ `;B+=`
205
+ let res = fn${i-1}(ctx, noop);
156
206
  if (res && res.then) res = await res;
157
- ${E}
158
- `}else{for(let _=0;_<i-1;_++)ce+=`const r${_} = fn${_}(ctx, noop);
159
- `,ce+=`if (r${_} && r${_} instanceof Response) { applyShortCircuit(r${_}, ctx); ${t?"doLog(r"+_+".status);":""} return r${_}; }
160
- `;ce+=`
161
- let res = fn${i-1}(ctx);
162
- if (res && res.then) return res.then(v => { let res = v; ${E} });
163
- ${E}
164
- `}let w=()=>{},V=je?`let lastHdrs = null, lastInit200 = null; return async function(${L})`:`let lastHdrs = null, lastInit200 = null; return function(${L})`;return qe(Function(...M,"noop","json200","text200",...ae,`${V} { ${ce} }`)(...e,w,p,y,...Me))}compile(){let e=this._useLog;this.tree=new un;for(let K of this.routes)this.tree.insert(K.path,K.method,this.compileHandler(K.handlers,e));let t=this.tree,r=this.pool,n=r.length,o=this.notFoundHandler,s=this.errorHandler,i=(K,B)=>{if(B._headers)for(let G in B._headers){let Le=B._headers[G];if(Le!==void 0&&!K.headers.has(G))try{K.headers.set(G,Le)}catch{}}if(B._setCookies)for(let G=0;G<B._setCookies.length;G++)try{K.headers.append("Set-Cookie",B._setCookies[G])}catch{}return K},a=(K,B)=>{if(K instanceof Response)return i(K,B);let G=B._status>=400?B._status:500;if(typeof K==="string")return i(new Response(K,{status:G}),B);return i(Response.json(K??null,{status:G}),B)},u=(K,B)=>{if(s){let G=s(K,B);if(G&&typeof G.then==="function")return G.then((Le)=>a(Le,B));return a(G,B)}if(K?.status>=400&&K?.status<500)return i(Response.json({status:K.status,message:K.message||"Bad Request"},{status:K.status}),B);return i(Response.json({status:500,message:K?.message||"Internal Server Error",stack:K?.stack},{status:500}),B)},c=[],d=(K)=>{let B=`h${c.length}`;return c.push(K),B},f=t.jitCompile(d),p=Object.freeze({}),y=c.map((K,B)=>`h${B}`),b=this.routes.some((K)=>K.handlers.some((B)=>B?.__idempotencyCommit)),L=`
207
+ ${w}
208
+ `}else{W=`
209
+ const fns = [${Z.join(", ")}];
210
+ const continueAsync = async (${t?"idx, pending, ctx, doLog":"idx, pending, ctx"}) => {
211
+ let r = await pending;
212
+ if (r instanceof Response) { applyShortCircuit(r, ctx); ${t?"if (!ctx._detached) doLog(r.status);":""} return r; }
213
+ for (let i = idx + 1; i < fns.length - 1; i++) {
214
+ r = fns[i](ctx, noop);
215
+ if (r) {
216
+ if (typeof r.then === 'function') r = await r;
217
+ if (r instanceof Response) { applyShortCircuit(r, ctx); ${t?"if (!ctx._detached) doLog(r.status);":""} return r; }
218
+ }
219
+ }
220
+ let res = fns[fns.length - 1](ctx, noop);
221
+ if (res && typeof res.then === 'function') res = await res;
222
+ ${w}
223
+ };
224
+ `;for(let A=0;A<i-1;A++)B+=`const r${A} = fn${A}(ctx, noop);
225
+ `,B+=`if (r${A}) {
226
+ `,B+=` if (r${A} instanceof Response) { applyShortCircuit(r${A}, ctx); ${t?"if (!ctx._detached) doLog(r"+A+".status);":""} return r${A}; }
227
+ `,B+=` if (typeof r${A}.then === 'function') return continueAsync(${A}, r${A}, ${P});
228
+ `,B+=`}
229
+ `;B+=`
230
+ let res = fn${i-1}(ctx, noop);
231
+ if (res && res.then) return res.then(v => { let res = v; ${w} });
232
+ ${w}
233
+ `}let q=T?`let lastHdrs = null, lastInit200 = null; return async function(${P})`:`let lastHdrs = null, lastInit200 = null; ${W} return function(${P})`;return L(Function(...Z,"json200","text200",...J,`${q} { ${B} }`)(...e,m,y,...z))}compile(){let e=this._useLog;this.tree=new bn;let t=new Set;for(let k of this.routes){if(k.method==="OPTIONS")t.add(k.path);this.tree.insert(k.path,k.method,this.compileHandler(k.handlers,e))}for(let k of this.routes){if(k.method==="OPTIONS"||t.has(k.path))continue;let v=-1;for(let G=k.handlers.length-1;G>=0;G--)if(k.handlers[G]?.__isCors&&!this.groupMiddleware.includes(k.handlers[G])){v=G;break}if(v!==-1){t.add(k.path);let G=[...k.handlers.slice(0,v+1).filter((we,Ce)=>Ce===v||!we?.__isCors),()=>new Response(null,{status:204})];this.tree.insert(k.path,"OPTIONS",this.compileHandler(G,e))}}let r=this.tree,n=this.pool,o=n.length,s=this.notFoundHandler,i=this.errorHandler,a=(k,v)=>{if(v._headers)for(let G in v._headers){let we=v._headers[G];if(we===void 0)continue;if(!k.headers.has(G))try{k.headers.set(G,we)}catch{}else if(G.toLowerCase()==="vary"){let Ce=k.headers.get("vary")||"",At=Ce.toLowerCase().split(",").map((ct)=>ct.trim()),Lt=we.split(",").map((ct)=>ct.trim()).filter((ct)=>ct&&!At.includes(ct.toLowerCase()));if(Lt.length>0)try{k.headers.set("vary",Ce?`${Ce}, ${Lt.join(", ")}`:Lt.join(", "))}catch{}}}if(v._setCookies)for(let G=0;G<v._setCookies.length;G++)try{k.headers.append("Set-Cookie",v._setCookies[G])}catch{}return k},u=(k,v)=>{if(k instanceof Response)return a(k,v);let G=v._status>=400?v._status:500;if(typeof k==="string")return a(new Response(k,{status:G}),v);return a(Response.json(k??null,{status:G}),v)},c=(k,v)=>{if(k?.status>=400&&k?.status<500)return a(Response.json({status:k.status,message:k.message||"Bad Request"},{status:k.status}),v);return a(Response.json({status:500,message:k?.message||"Internal Server Error",stack:k?.stack},{status:500}),v)},f=(k,v)=>{if(i)try{let G=i(k,v);if(G&&typeof G.then==="function")return G.then((we)=>u(we,v),(we)=>c(we,v));return u(G,v)}catch(G){return c(G,v)}return c(k,v)},d=[],m=(k)=>{let v=`h${d.length}`;return d.push(k),v},y=Object.freeze({}),p=this.routes.some((k)=>k.handlers.some((v)=>v?.__idempotencyCommit))||this.groupMiddleware.some((k)=>k?.__idempotencyCommit),w=`
165
234
  if (!ctx._detached) {
166
235
  if (ctx.store.size > 0) ctx.store.clear();
167
- ${this._hasDerive?"if (ctx._derivedKeys) { for (let i = 0; i < ctx._derivedKeys.length; i++) delete ctx[ctx._derivedKeys[i]]; ctx._derivedKeys = undefined; }":""}
168
- ${b?"if (ctx._idempotencyKey) { ctx._idemInFlight.delete(ctx._idempotencyKey); ctx._idempotencyKey = undefined; ctx._idemInFlight = undefined; }":""}
236
+ ${this._hasDerive||this.routes.some((k)=>k.handlers.some((v)=>v?.__isDerive))?"if (ctx._derivedKeys) { for (let i = 0; i < ctx._derivedKeys.length; i++) delete ctx[ctx._derivedKeys[i]]; ctx._derivedKeys = undefined; }":""}
237
+ ${p?"if (ctx._idempotencyKey) { if (ctx._idemInFlight) ctx._idemInFlight.delete(ctx._idempotencyKey); ctx._idempotencyKey = undefined; ctx._idemInFlight = undefined; }":""}
169
238
  ctx.req = undefined;
170
239
  ctx._status = 200;
171
240
  ctx.body = undefined;
@@ -178,35 +247,50 @@ ${p} ${r}[${c}] = ${f};
178
247
  ctx.params = EMPTY_PARAMS;
179
248
  if (poolTop < maxPool) pool[poolTop++] = ctx;
180
249
  }
181
- `,ae=`const errRes = hError(e, ctx);
182
- if (errRes && errRes.then) return errRes.then((r) => { ${e?"doLog(r.status || 500);":""} ${L} return r; });
250
+ `,P=`const errRes = hError(e, ctx);
251
+ if (errRes && errRes.then) return errRes.then((r) => { ${e?"doLog(r.status || 500);":""} ${w} return r; });
183
252
  ${e?"doLog(errRes.status || 500);":""}
184
- ${L}
185
- return errRes;`,Me=e?"(ctx, doLog)":"(ctx)",qe=f.replace(/return (h\d+)\(ctx\);/g,`out = $1${Me};
186
- if (out && out.then) return out.then((v) => { ${L} return v; }, (e) => { ${ae} });
187
- ${L}
188
- return out;`),je=this.groupMiddleware.length>0,ce=je?this.compileHandler(this.groupMiddleware,e):void 0,M=je?`if (method === 'OPTIONS') {
189
- out = hOptions${Me};
190
- if (out && out.then) return out.then((v) => { ${L} return v; }, (e) => { ${ae} });
191
- ${L}
192
- return out;
193
- }`:"",w=this.groupMiddleware.some((K)=>K.__isStatic),V=w?async(K)=>{let B=this.groupMiddleware,G=async(Le)=>{if(Le>=B.length)return;let Te=await B[Le](K,()=>G(Le+1));if(Te instanceof Response)return i(Te,K);return};return G(0)}:void 0,_=w?`if (method === 'GET' || method === 'HEAD') {
253
+ ${w}
254
+ return errRes;`,C=e?"(ctx, doLog)":"(ctx)",J=this.routes.length>16,z=r.jitCompile(m,0,"url","s",[],(k)=>J?`out = ${k}${C};
255
+ if (out && out.then) return out.then((v) => { _rel(ctx); return v; }, (e) => _onErr(e, ctx${e?", doLog":""}));
256
+ _rel(ctx);
257
+ return out;`:`out = ${k}${C};
258
+ if (out && out.then) return out.then((v) => { ${w} return v; }, (e) => { ${P} });
259
+ ${w}
260
+ return out;`),L=d.map((k,v)=>`h${v}`),T=this.groupMiddleware.length>0,B=T?async(k)=>{let v=this.groupMiddleware,G=async(we)=>{if(we>=v.length)return;let Ce=!1,At,Lt=await v[we](k,()=>(Ce=!0,G(we+1).then((ct)=>(At=ct,ct))));if(Lt instanceof Response)return a(Lt,k);if(At instanceof Response)return At;if(!Ce)return G(we+1);return};return G(0)}:void 0,Z=T?`if (method === 'OPTIONS') {
261
+ out = runGlobalOptions(ctx);
262
+ if (out && out.then) {
263
+ return out.then((v) => {
264
+ if (v instanceof Response) { ${e?"doLog(v.status);":""} ${w} return v; }
265
+ const errorBody = hNotFound();
266
+ const status = errorBody.status || 404;
267
+ const nfRes = applyCtxHeaders(Response.json(errorBody, { status }), ctx);
268
+ ${e?"doLog(status);":""}
269
+ ${w}
270
+ return nfRes;
271
+ }, (e) => {
272
+ ${P}
273
+ });
274
+ }
275
+ }`:"",W=this.groupMiddleware.some((k)=>k.__isStatic),q=W?async(k)=>{let v=this.groupMiddleware,G=async(we)=>{if(we>=v.length)return;let Ce=!1,At,Lt=await v[we](k,()=>(Ce=!0,G(we+1).then((ct)=>(At=ct,ct))));if(Lt instanceof Response)return a(Lt,k);if(At instanceof Response)return At;if(!Ce)return G(we+1);return};return G(0)}:void 0,A=W?`if (method === 'GET' || method === 'HEAD') {
194
276
  out = runStatic(ctx);
195
277
  if (out && out.then) {
196
278
  return out.then((v) => {
197
- if (v instanceof Response) { ${e?"doLog(v.status);":""} ${L} return v; }
279
+ if (v instanceof Response) { ${e?"doLog(v.status);":""} ${w} return v; }
198
280
  const errorBody = hNotFound();
199
281
  const status = errorBody.status || 404;
200
282
  const nfRes = applyCtxHeaders(Response.json(errorBody, { status }), ctx);
201
283
  ${e?"doLog(status);":""}
202
- ${L}
284
+ ${w}
203
285
  return nfRes;
204
286
  }, (e) => {
205
- ${ae}
287
+ ${P}
206
288
  });
207
289
  }
208
- }`:"",C=this._trustProxy,j=["pool","maxPool","Context","hNotFound","hError","applyCtxHeaders","EMPTY_PARAMS","trustProxyVal",...je?["hOptions"]:[],...w?["runStatic"]:[],...y],U=[r,n,Oo,o,u,i,p,C,...je?[ce]:[],...w?[V]:[],...c],me=`
209
- let poolTop = maxPool;
290
+ }`:"",oe=this.groupMiddleware.filter((k)=>k?.__isCors),Q=oe.length>0?(k,v)=>{for(let G=0;G<oe.length;G++)try{oe[G](v,()=>k)}catch{}return a(k,v)}:void 0,re=this._trustProxyBox,ie=["pool","maxPool","Context","hNotFound","hError","applyCtxHeaders","EMPTY_PARAMS","trustProxyBox",...T?["runGlobalOptions"]:[],...W?["runStatic"]:[],...Q?["apply404Cors"]:[],...L],ge=[n,o,jo,s,f,a,y,re,...T?[B]:[],...W?[q]:[],...Q?[Q]:[],...d],ee=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 };":"",D=`
291
+ let poolTop = maxPool;${J?`
292
+ const _rel = (ctx) => { ${w} };
293
+ const _onErr = (e, ctx${e?", doLog":""}) => { ${P} };`:""}
210
294
  return function(req, peerIp) {
211
295
  const url = req.url;
212
296
  let s = url.indexOf('/', 8);
@@ -216,32 +300,32 @@ ${p} ${r}[${c}] = ${f};
216
300
  else s = urlLen;
217
301
 
218
302
  const method = req.method;
219
- const ctx = poolTop > 0 ? pool[--poolTop] : new Context(trustProxyVal);
303
+ const ctx = poolTop > 0 ? pool[--poolTop] : new Context(trustProxyBox.val);
220
304
  let out;
221
- ${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 };":""}
305
+ ${ee}
222
306
 
223
307
  try {
224
308
  ctx.req = req;
225
309
  ctx._peerIp = peerIp;
226
310
 
227
- ${qe}
311
+ ${z}
228
312
 
229
- ${M}
313
+ ${Z}
230
314
 
231
- ${_}
315
+ ${A}
232
316
 
233
317
  const errorBody = hNotFound();
234
318
  const status = errorBody.status || 404;
235
- const nfRes = applyCtxHeaders(Response.json(errorBody, { status }), ctx);
319
+ const nfRes = ${Q?"apply404Cors(Response.json(errorBody, { status }), ctx)":"applyCtxHeaders(Response.json(errorBody, { status }), ctx)"};
236
320
  ${e?"doLog(status);":""}
237
- ${L}
321
+ ${w}
238
322
  return nfRes;
239
323
 
240
324
  } catch (e) {
241
- ${ae}
325
+ ${P}
242
326
  }
243
327
  }
244
- `;this.hotFetch=Function(...j,me)(...U),this.compiled=!0,this.fetch=this.hotFetch}fetch=(e,t)=>{if(!this.compiled)return this.compile(),this.hotFetch(e,t);return this.hotFetch(e,t)};async request(e,t){let r;if(e.startsWith("http://")||e.startsWith("https://"))r=e;else r=`http://localhost${e.startsWith("/")?e:`/${e}`}`;return this.fetch(new Request(r,t))}name="App";trustProxy(e=!0){this._trustProxy=e;for(let t=0;t<this.pool.length;t++)this.pool[t]._trustProxy=e;return this}listen(e,t="0.0.0.0",r=!0,n={}){if(!this.compiled)this.compile();if(n.trustProxy!==void 0)this.trustProxy(n.trustProxy);let o=n.maxRequestBodySize??10485760,s=e||nr.port||3000;if(!0)console.log(`
328
+ `;this.hotFetch=Function(...ie,D)(...ge),this.compiled=!0,this.fetch=this.hotFetch}fetch=(e,t)=>{if(!this.compiled)return this.compile(),this.hotFetch(e,t);return this.hotFetch(e,t)};async request(e,t){let r;if(e.startsWith("http://")||e.startsWith("https://"))r=e;else r=`http://localhost${e.startsWith("/")?e:`/${e}`}`;return this.fetch(new Request(r,t))}name="App";trustProxy(e=!0){this._trustProxyBox.val=e;for(let t=0;t<this.pool.length;t++)this.pool[t]._trustProxy=e;return this}listen(e,t="0.0.0.0",r=!0,n={}){if(n.trustProxy!==void 0)this.trustProxy(n.trustProxy);if(!this.compiled)this.compile();let o=n.maxRequestBodySize??10485760,s=e??Et.port??3000;if(!0)console.log(`
245
329
  \x1B[33m ____ _ _____ \x1B[0m
246
330
  \x1B[33m | __ ) __ _ _ __ ___ | | ____|\x1B[0m
247
331
  \x1B[33m | _ \\ / _\` | '__/ _ \\ _ | | _| \x1B[0m
@@ -250,8 +334,8 @@ ${p} ${r}[${c}] = ${f};
250
334
 
251
335
  \x1B[32m\uD83D\uDE80 ${this.name} is running in development mode\x1B[0m
252
336
  \x1B[90m\u2699\uFE0F Pool Size: ${this.pool.length} | JIT: Enabled | Port: ${s}\x1B[0m
253
- \x1B[36m\uD83D\uDEE1\uFE0F Hash: ${nr.hash.algorithm} (${nr.hash.memoryCost/1024}MB) | Iterations: ${nr.hash.timeCost}\x1B[0m
254
- `);let a=this.wsRoutes,u=this.fetch,d=a.size>0?Bun.serve({port:s,hostname:t,reusePort:r,maxRequestBodySize:o,fetch(p,y){if(p.headers.get("upgrade")?.toLowerCase()==="websocket"){let b=p.url,P=b.indexOf("/",8),E=P===-1?-1:b.indexOf("?",P),L=P===-1?"/":E===-1?b.slice(P):b.slice(P,E),ae=L.length>1&&L.endsWith("/")?L.slice(0,-1):L,Me=a.get(ae),qe;if(!Me){let je=ae.split("/").filter(Boolean);for(let[ce,M]of a){if(!ce.includes(":")&&!ce.includes("*"))continue;let w=ce.split("/").filter(Boolean),V={},_=!0;for(let C=0;C<w.length;C++){let j=w[C];if(j==="*"){V["*"]=je.slice(C).join("/");break}if(C>=je.length){_=!1;break}if(j.startsWith(":"))V[j.slice(1)]=je[C];else if(j!==je[C]){_=!1;break}}if(_&&(w.includes("*")||w.length===je.length)){Me=M,qe=V;break}}}if(Me&&y.upgrade(p,{data:qe?{...Me,params:qe}:Me}))return}return u(p,y?.requestIP?.(p)?.address)},websocket:this.wsAdapter}):Bun.serve({port:s,hostname:t,reusePort:r,maxRequestBodySize:o,fetch(p,y){return u(p,y?.requestIP?.(p)?.address)}});this.server=d;for(let p of this.startHooks)Promise.resolve(p()).catch((y)=>console.error(`[${this.name}] onStart error:`,y));let f=async()=>{let y=this.name,b=process.stdout.isTTY;{let P=b?"\uD83D\uDED1":"!",E=b?"\u2705":"v";process.stdout.write(`
255
- \x1B[31m${P} Stopping ${y}...\x1B[0m
256
- `),await this.stop(!1),process.stdout.write(`\x1B[32m${E} ${y} has been stopped.\x1B[0m
257
- `)}process.exit(0)};return this.shutdownHandler=f,process.on("SIGINT",f),process.on("SIGTERM",f),d}}var Th=(e)=>{let t=e.indexOf("/",8);if(t===-1)return"/";let r=e.indexOf("?",t);return r===-1?e.slice(t):e.slice(t,r)},Fh=(e={})=>{let t=e.format??"pretty",r=e.requestId??!0,{skip:n,onLog:o}=e;return(s,i)=>{let a=Th(s.req.url);if(n?.(s,a))return i?.();let u=r?s.requestId:void 0;if(u)s.setHeader("x-request-id",u);let c={timestamp:new Date().toISOString(),method:s.req.method,path:a,...u?{requestId:u}:{},ip:s.ip};if(o)o(c);else if(t==="json")console.log(JSON.stringify(c));else{let d=u?` [${u.slice(0,8)}]`:"";console.log(`[${c.timestamp}] ${c.method} ${c.path}${d}`)}return i?.()}};var Nh=(e={})=>{let t=e.path??"/health",{readyPath:r,checks:n}=e,o=Date.now(),s=async()=>{let i={},a=!0;if(n){let c=Object.entries(n);await Promise.all(c.map(async([d,f])=>{try{let p=await f();if(i[d]=p?"ok":"fail",!p)a=!1}catch{i[d]="fail",a=!1}}))}let u={status:a?"ok":"degraded",uptimeMs:Date.now()-o,timestamp:new Date().toISOString()};if(e.version)u.version=e.version;if(n)u.checks=i;return Response.json(u,{status:a?200:503})};return{install(i){if(i.get(t,s),r&&r!==t)i.get(r,s)}}};var Mh=(e={})=>{let t=e.origin||"*",r=e.methods||"GET,POST,PUT,PATCH,DELETE,OPTIONS",n=Array.isArray(e.allowedHeaders)?e.allowedHeaders.join(", "):e.allowedHeaders||"Content-Type, Authorization",o=Array.isArray(e.exposedHeaders)?e.exposedHeaders.join(", "):e.exposedHeaders,s=e.credentials===!0;if(typeof t==="string"){let c={"Access-Control-Allow-Origin":t,"Access-Control-Allow-Methods":r,"Access-Control-Allow-Headers":n};if(t!=="*")c.Vary="Origin";if(s)c["Access-Control-Allow-Credentials"]="true";let d={status:204,headers:c};return(p,y)=>{if(p.req.method==="OPTIONS")return new Response(null,d);if(p.setHeader("Access-Control-Allow-Origin",t),p.setHeader("Access-Control-Allow-Methods",r),t!=="*")p.setHeader("Vary","Origin");if(s)p.setHeader("Access-Control-Allow-Credentials","true");if(o)p.setHeader("Access-Control-Expose-Headers",o);let b=y?.();if(b&&typeof b.then==="function")return b.then((P)=>{if(P instanceof Response){if(P.headers.set("Access-Control-Allow-Origin",t),P.headers.set("Access-Control-Allow-Methods",r),t!=="*")P.headers.set("Vary","Origin");if(s)P.headers.set("Access-Control-Allow-Credentials","true");if(o)P.headers.set("Access-Control-Expose-Headers",o)}return P});if(b instanceof Response){if(b.headers.set("Access-Control-Allow-Origin",t),b.headers.set("Access-Control-Allow-Methods",r),t!=="*")b.headers.set("Vary","Origin");if(s)b.headers.set("Access-Control-Allow-Credentials","true");if(o)b.headers.set("Access-Control-Expose-Headers",o)}return b}}let i=Array.isArray(t)?new Set(t):null,a=(c)=>{if(!c)return null;if(i)return i.has(c)?c:null;return t(c)?c:null};return(c,d)=>{let f=a(c.req.headers.get("origin"));if(c.req.method==="OPTIONS"){let y={"Access-Control-Allow-Methods":r,"Access-Control-Allow-Headers":n,Vary:"Origin"};if(f)y["Access-Control-Allow-Origin"]=f;if(s&&f)y["Access-Control-Allow-Credentials"]="true";return new Response(null,{status:204,headers:y})}if(c.setHeader("Vary","Origin"),c.setHeader("Access-Control-Allow-Methods",r),f){if(c.setHeader("Access-Control-Allow-Origin",f),s)c.setHeader("Access-Control-Allow-Credentials","true")}if(o)c.setHeader("Access-Control-Expose-Headers",o);let p=d?.();if(p&&typeof p.then==="function")return p.then((y)=>{if(y instanceof Response){if(y.headers.set("Vary","Origin"),y.headers.set("Access-Control-Allow-Methods",r),f){if(y.headers.set("Access-Control-Allow-Origin",f),s)y.headers.set("Access-Control-Allow-Credentials","true")}if(o)y.headers.set("Access-Control-Expose-Headers",o)}return y});if(p instanceof Response){if(p.headers.set("Vary","Origin"),p.headers.set("Access-Control-Allow-Methods",r),f){if(p.headers.set("Access-Control-Allow-Origin",f),s)p.headers.set("Access-Control-Allow-Credentials","true")}if(o)p.headers.set("Access-Control-Expose-Headers",o)}return p}};import{timingSafeEqual as jh}from"crypto";var Eh=new Set(["GET","HEAD","OPTIONS"]),Lh=(e)=>{try{let t=new URL(e.req.url);if(e._trustProxy){let n=e.req.headers.get("x-forwarded-host")?.split(",")[0]?.trim(),o=e.req.headers.get("x-forwarded-proto")?.split(",")[0]?.trim();if(n)return`${o?`${o}:`:t.protocol}//${n}`}let r=e.req.headers.get("host")?.trim();if(r)return`${t.protocol}//${r}`;return t.origin}catch{return""}},Uh=(e={})=>{let t=e.ignoreMethods?new Set(e.ignoreMethods.map((a)=>a.toUpperCase())):Eh,r=e.allowedOrigins?new Set(e.allowedOrigins):null,n=e.cookieName||"csrf_token",o=(e.headerName||"x-csrf-token").toLowerCase(),s=e.requireToken===!0,i=e.allowMissingOrigin===!0;return(a,u)=>{let c=a.req.method.toUpperCase();if(t.has(c))return u?.();let d=a.req.headers.get("sec-fetch-site"),f=a.req.headers.get("origin"),p=a.req.headers.get("referer");if(d==="cross-site"){if(!r||!f||!r.has(f))return Response.json({status:"error",code:"CSRF_FORBIDDEN",message:"Cross-site request blocked"},{status:403})}let y=f;if(!y&&p)try{y=new URL(p).origin}catch{return Response.json({status:"error",code:"CSRF_FORBIDDEN",message:"Invalid Referer header"},{status:403})}if(y){let b=Lh(a);if(!(b!==""&&y===b||r!==null&&r.has(y)))return Response.json({status:"error",code:"CSRF_FORBIDDEN",message:"Origin mismatch"},{status:403})}else if(!i&&d!=="same-origin")return Response.json({status:"error",code:"CSRF_FORBIDDEN",message:"Missing Origin or Referer header"},{status:403});if(s){let b=a.cookies[n],P=a.req.headers.get(o),E=!1;if(b&&P){let L=Buffer.from(b),ae=Buffer.from(P);E=L.length===ae.length&&jh(L,ae)}if(!E)return Response.json({status:"error",code:"CSRF_TOKEN_INVALID",message:"Invalid or missing CSRF token"},{status:403})}return u()}};var Kh=(e=1e4,t={})=>{let r=t.status??408,n=t.message??"Request Timeout",o=async(s,i)=>{let a;try{let u=Promise.resolve(i()),c=new Promise((d)=>{a=setTimeout(()=>{u.catch(()=>{}),d(Response.json({status:"error",code:"REQUEST_TIMEOUT",message:n},{status:r}))},e)});return await Promise.race([u,c])}finally{if(a!==void 0)clearTimeout(a)}};return o.__timeout={ms:e,status:r,message:n},o};var Bh=(e={})=>{let t=e.windowMs??60000,r=e.max??100,n=e.message??"Too many requests, please try again later.",o=e.maxEntries??1e4,s=e.keyGenerator??((c)=>c.ip),i=e.store,a=(c,d,f,p,y)=>{let b=Math.max(0,r-d),P=String(Math.ceil(f/1000));if(c.setHeader("X-RateLimit-Limit",String(r)),c.setHeader("X-RateLimit-Remaining",String(b)),c.setHeader("X-RateLimit-Reset",P),d>r){let E=Math.max(1,Math.ceil((f-p)/1000));return Response.json({status:"error",code:"RATE_LIMITED",message:n},{status:429,headers:{"Retry-After":String(E),"X-RateLimit-Limit":String(r),"X-RateLimit-Remaining":"0","X-RateLimit-Reset":P}})}return y?.()};if(i)return async(c,d)=>{let f=Date.now(),p=s(c),{count:y,resetAt:b}=await i.increment(p,t);return a(c,y,b,f,d)};let u=new Map;return(c,d)=>{let f=Date.now(),p=s(c),y=u.get(p);if(!y||f>=y.resetAt){if(u.size>=o){for(let[b,P]of u){if(f>=P.resetAt)u.delete(b);if(u.size<o)break}if(u.size>=o){let b=u.keys().next().value;if(b!==void 0)u.delete(b)}}y={count:1,resetAt:f+t},u.set(p,y)}else y.count++;return a(c,y.count,y.resetAt,f,d)}};var Zc=(e)=>{if(e.rawBody!==void 0)return new Response(e.rawBody,{status:e.status,headers:{"content-type":e.contentType||"application/json","X-Idempotent-Replayed":"true"}});return Response.json(e.body,{status:e.status,headers:{"X-Idempotent-Replayed":"true"}})},eu=(e,t)=>{let r=e.req.headers.get(t)?.trim();if(!r)return;let n=e.req.url,o=n.indexOf("/",8),s=o===-1?-1:n.indexOf("?",o),i=o===-1?"/":s===-1?n.slice(o):n.slice(o,s);return`${e.req.method}:${i}:${r}`},vh=(e={})=>{let t=(e.headerName||"idempotency-key").toLowerCase(),r=e.ttlMs??300000,n=e.maxKeys??1e4,o=e.store;if(o){let c={delete:(f)=>{o.release(f)}},d=async(f)=>{let p=eu(f,t);if(!p){f._idempotencyKey=void 0;return}let y=await o.get(p);if(y&&Date.now()<y.expiresAt)return f._idempotencyKey=void 0,Zc(y);if(!await o.acquire(p,r))return f._idempotencyKey=void 0,Response.json({status:"error",code:"IDEMPOTENT_IN_FLIGHT",message:"Duplicate request is currently in flight"},{status:409});f._idempotencyKey=p,f._idemInFlight=c;return};return d.__idempotencyCommit=(f,p,y)=>{let b=f._idempotencyKey;if(!b)return;f._idempotencyKey=void 0,f._idemInFlight=void 0;let P=p instanceof Response&&(p.headers.get("content-type")||"").includes("text/event-stream"),E=!P&&y>=200&&y<300&&p instanceof Response?p.clone():null,L=E?E.headers.get("content-type")||"application/json":void 0;(async()=>{try{if(!P&&y>=200&&y<300)if(E){let ae=await E.arrayBuffer();await o.set(b,{status:y,rawBody:ae,contentType:L,expiresAt:Date.now()+r},r)}else await o.set(b,{status:y,body:p,expiresAt:Date.now()+r},r)}catch{}finally{await o.release(b)}})()},d.__idempotencyRelease=(f)=>{let p=f._idempotencyKey;if(p)f._idempotencyKey=void 0,f._idemInFlight=void 0,o.release(p)},d}let s=new Map,i=new Set,a=()=>{if(s.size>=n){let c=s.keys().next().value;if(c!==void 0)s.delete(c)}},u=(c)=>{let d=eu(c,t);if(!d){c._idempotencyKey=void 0;return}let f=Date.now(),p=s.get(d);if(p){if(f<p.expiresAt)return c._idempotencyKey=void 0,Zc(p);s.delete(d)}if(i.has(d))return c._idempotencyKey=void 0,Response.json({status:"error",code:"IDEMPOTENT_IN_FLIGHT",message:"Duplicate request is currently in flight"},{status:409});i.add(d),c._idempotencyKey=d,c._idemInFlight=i;return};return u.__idempotencyCommit=(c,d,f)=>{let p=c._idempotencyKey;if(!p)return;if(c._idempotencyKey=void 0,c._idemInFlight=void 0,i.delete(p),f>=200&&f<300)if(d instanceof Response){let y=d.headers.get("content-type")||"application/json";d.clone().arrayBuffer().then((b)=>{a(),s.set(p,{status:f,rawBody:b,contentType:y,expiresAt:Date.now()+r})}).catch(()=>{})}else a(),s.set(p,{status:f,body:d,expiresAt:Date.now()+r})},u.__idempotencyRelease=(c)=>{let d=c._idempotencyKey;if(d)c._idempotencyKey=void 0,c._idemInFlight=void 0,i.delete(d)},u},Dh=()=>{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 qh=(e,t={})=>{let r=t.prefix??"barejs:",n=typeof e.send==="function",o=(c)=>n?e.send("GET",[c]):e.get(c),s=(c)=>n?e.send("DEL",[c]):e.del(c),i=(c)=>n?e.send("INCR",[c]):e.incr(c),a=async(c,d,f)=>{if(n){await e.send("SET",[c,d,"PX",String(f)]);return}try{await e.set(c,d,"PX",f)}catch{if(await e.set(c,d),typeof e.pexpire==="function")await e.pexpire(c,f);else if(typeof e.expire==="function")await e.expire(c,Math.max(1,Math.ceil(f/1000)))}},u=async(c,d)=>{if(n)await e.send("PEXPIRE",[c,String(d)]);else if(typeof e.pexpire==="function")await e.pexpire(c,d);else if(typeof e.expire==="function")await e.expire(c,Math.max(1,Math.ceil(d/1000)))};return{async increment(c,d){let f=`${r}rl:${c}`,p=Number(await i(f));if(p===1)await u(f,d);let y=d,b=null;if(n)b=Number(await e.send("PTTL",[f]));else if(typeof e.pttl==="function")b=Number(await e.pttl(f));else if(typeof e.ttl==="function"){let P=Number(await e.ttl(f));b=P<0?P:P*1000}if(b===-1)await u(f,d);else if(b!==null&&Number.isFinite(b)&&b>0)y=b;return{count:p,resetAt:Date.now()+y}},async get(c){let d=await o(`${r}idem:${c}`);if(!d)return;try{let f=JSON.parse(typeof d==="string"?d:String(d));if(typeof f.rawBodyBase64==="string"){let p=Buffer.from(f.rawBodyBase64,"base64");return{status:f.status,rawBody:p.buffer.slice(p.byteOffset,p.byteOffset+p.byteLength),contentType:f.contentType,expiresAt:f.expiresAt}}return f}catch{return}},async set(c,d,f){let p={status:d.status,expiresAt:d.expiresAt};if(d.rawBody!==void 0)p.rawBodyBase64=Buffer.from(d.rawBody).toString("base64"),p.contentType=d.contentType;else p.body=d.body;await a(`${r}idem:${c}`,JSON.stringify(p),f)},async acquire(c,d=30000){let f=`${r}idem:lock:${c}`;if(n){let y=await e.send("SET",[f,"1","PX",String(d),"NX"]);return y==="OK"||y===!0}let p=await e.set(f,"1","PX",d,"NX");return p==="OK"||p===!0||p===1},async release(c){await s(`${r}idem:lock:${c}`)},async revoke(c,d){await a(`${r}rev:${c}`,"1",d)},async isRevoked(c){let d=await o(`${r}rev:${c}`);return d!==null&&d!==void 0}}};var Gh=(e={})=>{let t=e.failureThreshold??5,r=e.resetTimeoutMs??30000,n=e.isFailure??((f,p)=>Boolean(p)||f instanceof Response&&f.status>=500),o="CLOSED",s=0,i=0,a=!1,u=(f)=>{if(o!==f){let p=o;o=f,e.onStateChange?.(p,f)}},c=async(f)=>{if(o==="OPEN"){let y=Date.now()-i;if(y<r){let b=Math.max(1,Math.ceil((r-y)/1000));return Response.json({status:"error",code:"CIRCUIT_OPEN",message:"Service temporarily unavailable"},{status:503,headers:{"Retry-After":String(b)}})}u("HALF_OPEN")}let p=!1;if(o==="HALF_OPEN"){if(a)return Response.json({status:"error",code:"CIRCUIT_OPEN",message:"Service temporarily unavailable"},{status:503,headers:{"Retry-After":"1"}});a=!0,p=!0}try{let y=await f();if(n(y)){if(s++,p||s>=t)i=Date.now(),u("OPEN")}else if(s=0,p)u("CLOSED");return y}catch(y){if(s++,p||s>=t)i=Date.now(),u("OPEN");throw y}finally{if(p)a=!1}},d=(f,p)=>c(()=>p?p():void 0);return d.__circuitBreaker=c,d};var Hh=(e={})=>{let t=[];if(e.noSniff!==!1)t.push(["X-Content-Type-Options","nosniff"]);if(e.frameOptions!==!1)t.push(["X-Frame-Options",e.frameOptions??"DENY"]);if(e.referrerPolicy!==!1)t.push(["Referrer-Policy",e.referrerPolicy??"strict-origin-when-cross-origin"]);if(e.hsts!==!1)t.push(["Strict-Transport-Security",e.hsts??"max-age=31536000; includeSubDomains"]);if(e.contentSecurityPolicy)t.push(["Content-Security-Policy",e.contentSecurityPolicy]);t.push(["X-XSS-Protection","0"]);let r=t.length,n=Object.freeze((()=>{let o={};for(let s=0;s<r;s++){let i=t[s];o[i[0].toLowerCase()]=i[1]}return o})());return(o,s)=>{if(!o._headers)o._headers=n;else o._headers={...o._headers,...n};let i=s?.();if(i&&typeof i.then==="function")return i.then((a)=>{if(a instanceof Response)for(let u=0;u<r;u++){let c=t[u];if(!a.headers.has(c[0]))a.headers.set(c[0],c[1])}return a});if(i instanceof Response)for(let a=0;a<r;a++){let u=t[a];if(!i.headers.has(u[0]))i.headers.set(u[0],u[1])}return i}};import{resolve as tu,sep as Rs}from"path";import{stat as zh,realpath as ru}from"fs/promises";var Vh=(e="public",t={})=>{let r=tu(process.cwd(),e),n=r.endsWith(Rs)?r:r+Rs,o=null,s=t.maxAge??3600,i=t.etag!==!1,a=t.cacheMetadata,u=Boolean(a),c=typeof a==="object"?a.maxEntries??1000:1000,d=typeof a==="object"?a.ttlMs??30000:30000,f=u?new Map:null,p=async(y,b)=>{let P=y.req.method;if(P!=="GET"&&P!=="HEAD")return b?.();let E=y.req.url,L=E.indexOf("/",8),ae=L===-1?-1:E.indexOf("?",L),Me=L===-1?"":ae===-1?E.slice(L):E.slice(L,ae),qe;try{qe=decodeURIComponent(Me)}catch{return y.status(400).send("Bad Request")}if(qe.includes("\x00"))return y.status(400).send("Bad Request");let je=qe.replace(/^\/+/,""),ce=tu(r,je);if(ce!==r&&!ce.startsWith(n))return y.status(403).send("Forbidden");let M=ce,w=0,V=0,_="",C=f?.get(ce);if(C&&Date.now()<C.expiresAt)f.delete(ce),f.set(ce,C),M=C.realFile,w=C.fileSize,V=C.mtimeMs,_=C.etag;else try{let[me,K]=await Promise.all([o??=ru(r),ru(ce)]),B=me.endsWith(Rs)?me:me+Rs;if(K!==me&&!K.startsWith(B))return y.status(403).send("Forbidden");let G=await zh(K);if(G.isDirectory())return b?.();if(M=K,w=G.size,V=Math.floor(G.mtimeMs),_=i?`W/"${w.toString(16)}-${V.toString(16)}"`:"",f){if(f.size>=c){let Le=f.keys().next().value;if(Le!==void 0)f.delete(Le)}f.set(ce,{realFile:M,fileSize:w,mtimeMs:V,etag:_,expiresAt:Date.now()+d})}}catch{return b?.()}let j=Bun.file(M),U={"Cache-Control":`public, max-age=${s}`,"Accept-Ranges":"bytes"};if(i){U.ETag=_;let me=y.req.headers?.get?.("if-none-match");if(me&&me===_)return new Response(null,{status:304,headers:U})}let Ee=y.req.headers?.get?.("range");if(Ee&&Ee.startsWith("bytes=")&&w>0){let[me,K]=Ee.slice(6).split("-"),B=me?Number(me):0,G=K?Number(K):w-1;if(!me&&K)B=Math.max(0,w-Number(K)),G=w-1;if(!Number.isInteger(B)||!Number.isInteger(G)||B<0||G>=w||B>G)return new Response(null,{status:416,headers:{...U,"Content-Range":`bytes */${w}`}});if(U["Content-Range"]=`bytes ${B}-${G}/${w}`,U["Content-Length"]=String(G-B+1),j.type)U["Content-Type"]=j.type;return new Response(P==="HEAD"?null:j.slice(B,G+1),{status:206,headers:U})}if(j.type)U["Content-Type"]=j.type;return U["Content-Length"]=String(w),new Response(P==="HEAD"?null:j,{status:200,headers:U})};return p.__isStatic=!0,p};import{brotliCompressSync as Jh,constants as Wh}from"zlib";var Xh=(e={})=>{let t=e.minSize??1024,r=e.level??6,n=e.encodings??["zstd","br","gzip"],o=typeof Bun.zstdCompressSync==="function",s=(c,d)=>{let f=c.split(",");for(let p=0;p<f.length;p++){let y=f[p].trim();if(!y)continue;let b=y.indexOf(";");if((b===-1?y:y.slice(0,b)).trim()!==d)continue;if(b!==-1){let E=y.slice(b+1).match(/q\s*=\s*([0-9.]+)/);if(E){let L=parseFloat(E[1]);if(Number.isFinite(L)&&L<=0)return!1}}return!0}return!1},i=(c)=>{let d=c.toLowerCase();for(let f=0;f<n.length;f++){let p=n[f];if(p==="zstd"&&!o)continue;if(s(d,p))return p}return null},a=async(c,d)=>{if(c.req.method==="HEAD")return d;let f=c.req.headers.get("accept-encoding");if(!f)return d;let p=i(f);if(!p)return d;if(!(d instanceof Response))return d;if(d.status===204||d.status===304)return d;if(d.headers.has("content-encoding"))return d;if((d.headers.get("content-type")||"").includes("text/event-stream"))return d;let b=await d.arrayBuffer();if(b.byteLength<t)return new Response(b,{status:d.status,headers:d.headers});let P=new Uint8Array(b),E;if(p==="zstd")E=Bun.zstdCompressSync(P);else if(p==="br")E=Jh(P,{params:{[Wh.BROTLI_PARAM_QUALITY]:Math.min(11,Math.max(1,r))}});else E=Bun.gzipSync(P,{level:r});let L=new Headers(d.headers);L.set("Content-Encoding",p);let ae=L.get("Vary");if(!ae)L.set("Vary","Accept-Encoding");else if(!ae.toLowerCase().split(",").some((Me)=>Me.trim()==="accept-encoding"))L.set("Vary",`${ae}, Accept-Encoding`);return L.delete("Content-Length"),new Response(E,{status:d.status,headers:L})},u=async(c,d)=>{let f=await(d?d():void 0);return a(c,f)};return u.__compress=a,u};import{createHash as Yh,createHmac as nu,timingSafeEqual as ws}from"crypto";var xi=new TextEncoder,yi=(e)=>Buffer.from(e).toString("base64url"),_s=(e)=>Buffer.from(e,"base64url").toString("utf-8"),gi=new Map,Qh=async(e)=>{if(gi.has(e))return gi.get(e);let t=await crypto.subtle.importKey("raw",xi.encode(e),{name:"HMAC",hash:"SHA-256"},!1,["sign","verify"]);return gi.set(e,t),t},Zh=async(e,t)=>{let r=JSON.stringify({alg:"HS256",typ:"JWT"}),n=JSON.stringify(e),o=yi(r),s=yi(n),i=`${o}.${s}`,a=await Qh(t),u=await crypto.subtle.sign("HMAC",a,xi.encode(i)),c=yi(new Uint8Array(u));return`${i}.${c}`},Ir=new Map;function ex(e,t=3600000,r){if(r)return r.revoke(e,t);if(Ir.size>=1e4){let n=Date.now();for(let[o,s]of Ir)if(n>=s)Ir.delete(o);if(Ir.size>=1e4){let o=Ir.keys().next().value;if(o!==void 0)Ir.delete(o)}}Ir.set(e,Date.now()+t)}function hi(e,t){if(t)return t.isRevoked(e);let r=Ir.get(e);if(r===void 0)return!1;if(Date.now()>=r)return Ir.delete(e),!1;return!0}var ou=new Map,su=(e)=>e==="RS256"?{name:"RSASSA-PKCS1-v1_5",hash:"SHA-256"}:{name:"ECDSA",namedCurve:"P-256"},tx=(e)=>e==="RS256"?{name:"RSASSA-PKCS1-v1_5"}:{name:"ECDSA",hash:"SHA-256"},rx=(e)=>{let t=e.replace(/-----BEGIN [A-Z0-9 ]+-----/g,"").replace(/-----END [A-Z0-9 ]+-----/g,"").replace(/\s+/g,""),r=Buffer.from(t,"base64");return r.buffer.slice(r.byteOffset,r.byteOffset+r.byteLength)},nx=async(e,t)=>{if(typeof e!=="string")return e;let r=`${t}:${e}`,n=ou.get(r);if(n)return n;let o=await crypto.subtle.importKey("spki",rx(e),su(t),!1,["verify"]);return ou.set(r,o),o},ox=(e)=>{let t=typeof e==="string"?{secret:e}:e,r=t.secret??"",{isRevoked:n,revocationStore:o,publicKey:s,jwksUri:i}=t,a=t.jwksCacheTtlMs??300000,u=t.algorithms??(s||i?["RS256","ES256"]:["HS256"]),c=t.issuer===void 0?null:Array.isArray(t.issuer)?t.issuer:[t.issuer],d=t.audience===void 0?null:Array.isArray(t.audience)?t.audience:[t.audience],f=(M,w,V)=>{if(M.set("user",w),Array.isArray(V)){if(V.length===0)return;let[_,...C]=V;return _(M,C)}if(typeof V==="function")return V();return},p=(M,w,V,_)=>{if(!w||typeof w!=="object"||Array.isArray(w))return M.status(401).send("Invalid token payload");let C=Date.now()*0.001;if(typeof w.exp==="number"&&C>=w.exp)return M.status(401).send("Token expired");if(typeof w.nbf==="number"&&C<w.nbf)return M.status(401).send("Token not active");if(c&&(typeof w.iss!=="string"||!c.includes(w.iss)))return M.status(401).send("Invalid token issuer");if(d){if(!(Array.isArray(w.aud)?w.aud:typeof w.aud==="string"?[w.aud]:[]).some((U)=>typeof U==="string"&&d.includes(U)))return M.status(401).send("Invalid token audience")}if(hi(V)||w?.jti&&hi(String(w.jti)))return M.status(401).send("Token revoked");if(o)return(async()=>{if(await o.isRevoked(V))return M.status(401).send("Token revoked");if(w?.jti&&await o.isRevoked(String(w.jti)))return M.status(401).send("Token revoked");if(n){if(await n(w,V))return M.status(401).send("Token revoked")}return f(M,w,_)})();if(n){let j=n(w,V);if(j&&typeof j.then==="function")return j.then((U)=>U?M.status(401).send("Token revoked"):f(M,w,_));if(j)return M.status(401).send("Token revoked")}return f(M,w,_)};if(!s&&!i&&u.length===1&&u[0]==="HS256"){let M=(w,V)=>{let _=w.req.headers.get("Authorization");if(!_?.startsWith("Bearer "))return w.status(401).send("Bearer token required");let C=_.slice(7),j=C.indexOf("."),U=j===-1?-1:C.indexOf(".",j+1);if(j===-1||U===-1||C.indexOf(".",U+1)!==-1)return w.status(401).send("Malformed JWT token");let Ee=C.slice(0,j),me=C.slice(j+1,U),K=C.slice(U+1),B=C.slice(0,U);try{let G=nu("sha256",r).update(B).digest(),Le=Buffer.from(K,"base64url");if(Le.length!==G.length||!ws(Le,G))return w.status(401).send("Invalid signature");let Te=JSON.parse(_s(Ee));if(!Te||Te.alg!=="HS256")return w.status(401).send("Unsupported token algorithm");let pe=JSON.parse(_s(me));return p(w,pe,C,V)}catch{return w.status(401).send("Token verification failed")}};if(n||o)return async(w,V)=>M(w,V);return M}let b=0,P=0,E=[],L=null,ae=new Map,Me=15000,qe=async(M=!1)=>{let w=Date.now();if(!M&&E.length>0&&w-b<a)return E;if(M&&w-P<Me&&E.length>0)return E;if(L)return L;if(M)P=w;return L=(async()=>{let V=await fetch(i,{signal:AbortSignal.timeout(5000)});if(!V.ok)throw Error(`JWKS fetch failed: ${V.status}`);let _=await V.json();if(E=Array.isArray(_?.keys)?_.keys:[],b=Date.now(),M)ae.clear();return E})().finally(()=>{L=null}),L},je=(M,w,V)=>{let _=(C)=>C&&C.use!=="enc"&&(!C.alg||C.alg===V);return w?M.find((C)=>C.kid===w&&_(C)):M.find((C)=>_(C))},ce=async(M,w)=>{let V=`${w}:${M??"__default__"}`,_=ae.get(V);if(_&&Date.now()-b<a)return _;let C=await qe(!1),j=je(C,M,w);if(!j&&M)C=await qe(!0),j=je(C,M,w);if(!j)return null;let U=await crypto.subtle.importKey("jwk",j,su(w),!1,["verify"]);return ae.set(V,U),U};return async(M,w)=>{let V=M.req.headers.get("Authorization");if(!V?.startsWith("Bearer "))return M.status(401).send("Bearer token required");let _=V.slice(7),C=_.indexOf("."),j=C===-1?-1:_.indexOf(".",C+1);if(C===-1||j===-1||_.indexOf(".",j+1)!==-1)return M.status(401).send("Malformed JWT token");let U=_.slice(0,C),Ee=_.slice(C+1,j),me=_.slice(j+1),K=_.slice(0,j);try{let B=JSON.parse(_s(U)),G=B?.alg;if(!G||!u.includes(G))return M.status(401).send("Unsupported token algorithm");if(G==="HS256"){if(!r)return M.status(401).send("Unsupported token algorithm");let Te=nu("sha256",r).update(K).digest(),pe=Buffer.from(me,"base64url");if(pe.length!==Te.length||!ws(pe,Te))return M.status(401).send("Invalid signature")}else{let Te=null;if(i)Te=await ce(B?.kid,G);else if(s)Te=await nx(s,G);if(!Te)return M.status(401).send("Invalid signature");let pe=Buffer.from(me,"base64url"),pt=pe.buffer.slice(pe.byteOffset,pe.byteOffset+pe.byteLength);if(!await crypto.subtle.verify(tx(G),Te,pt,xi.encode(K)))return M.status(401).send("Invalid signature")}let Le=JSON.parse(_s(Ee));return p(M,Le,_,w)}catch{return M.status(401).send("Token verification failed")}}},Os=(e)=>Yh("sha256").update(e).digest(),sx=(e)=>{let t=Os(e.user),r=Os(e.pass);return async(n,o)=>{let s=n.req.headers.get("Authorization");if(!s?.startsWith("Basic "))return n.status(401).json({status:"error",message:"Basic Auth required"});let i=s.slice(6).trim();if(!i)return n.status(401).json({status:"error",message:"Missing credentials"});let a=Buffer.from(i,"base64").toString("utf-8"),u=a.indexOf(":");if(u===-1)return n.status(401).json({status:"error",message:"Invalid credentials"});let c=a.slice(0,u),d=a.slice(u+1),f=ws(Os(c),t),p=ws(Os(d),r);if(f&&p)return o?.();return n.status(401).json({status:"error",message:"Invalid credentials"})}},ix=(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?.()};var iu={make:(e)=>Bun.password.hash(e,nr.hash),verify:async(e,t)=>{if(!t||typeof t!=="string")return!1;try{return await Bun.password.verify(e,t)}catch{return!1}},needsRehash:(e)=>{if(!e||typeof e!=="string")return!0;let{algorithm:t,memoryCost:r,timeCost:n}=nr.hash;if(t==="bcrypt"){if(!/^\$2[aby]\$/.test(e))return!0;let i=e.match(/^\$2[aby]\$(\d+)\$/);return!i||Number(i[1])!==n}if(!e.startsWith(`$${t}$`))return!0;let o=e.match(/(?:^|[,$])m=(\d+)(?:[,$]|$)/),s=e.match(/(?:^|[,$])t=(\d+)(?:[,$]|$)/);return!o||Number(o[1])!==r||!s||Number(s[1])!==n}};var ax=(e,t,r)=>{let n=t;if(r?.params){let a=r.params;n=n.replace(/:([a-zA-Z0-9_]+)(?=\/|$)/g,(u,c)=>Object.hasOwn(a,c)?encodeURIComponent(String(a[c])):u)}let o=e.endsWith("/")?e.slice(0,-1):e,s=n.startsWith("/")?n:`/${n}`,i=`${o}${s}`;if(r?.query){let a=new URLSearchParams;for(let[c,d]of Object.entries(r.query))if(d!==void 0)a.set(c,String(d));let u=a.toString();if(u)i+=`?${u}`}return i},cx=(e,t={})=>{let r=typeof e==="object"&&e!==null&&typeof e.fetch==="function",n=r?"http://localhost":e,o=t.fetch??(r?(a,u)=>e.fetch(new Request(String(a),u)):fetch),s=t.headers??{},i=async(a,u,c)=>{let d=ax(n,u,c),f={...s,...c?.headers??{}},p={method:a,headers:f};if(c?.body!==void 0&&a!=="GET"&&a!=="HEAD"){if(!f["Content-Type"]&&!f["content-type"])f["Content-Type"]="application/json";p.body=typeof c.body==="string"?c.body:JSON.stringify(c.body)}let y=await o(d,p),b=null;if(y.status!==204&&y.status!==205&&y.status!==304)if((y.headers.get("content-type")||"").includes("application/json")){let E=await y.text();b=E?JSON.parse(E):null}else b=await y.text();if(!y.ok){let P=Error(`HTTP ${y.status}`);throw P.status=y.status,P.data=b,P}return b};return{get:(a,u)=>i("GET",a,u),post:(a,u)=>i("POST",a,u),put:(a,u)=>i("PUT",a,u),patch:(a,u)=>i("PATCH",a,u),delete:(a,u)=>i("DELETE",a,u)}};export{Qc as BareJS,cn as BareRouter,Oo as Context,iu as Hash,iu as Password,Ch as T,Ch as Type,Ch as TypeBox,Sy as Z,Sy as Zod,ox as bareAuth,cx as bareClient,sx as basicAuth,Gh as circuitBreaker,Xh as compress,Mh as cors,sc as createResponseFilter,Dh as createSingleflight,Zh as createToken,Uh as csrf,pi as generateOpenAPISpec,ix as hasRole,Nh as healthcheck,vh as idempotency,hi as isTokenRevoked,Fh as logger,rc as n,rc as native,Bh as rateLimit,qh as redisStore,li as renderDocsHTML,ex as revokeToken,oi as schemaValidator,Hh as securityHeaders,Vh as staticFile,tc as t,Kh as timeout,tc as typebox,Cy as v,Cy as validate,nc as z,nc as zod};
337
+ \x1B[36m\uD83D\uDEE1\uFE0F Hash: ${Et.hash.algorithm} (${Et.hash.memoryCost/1024}MB) | Iterations: ${Et.hash.timeCost}\x1B[0m
338
+ `);let a=this.wsRoutes,u=this.fetch,f=a.size>0?Bun.serve({port:s,hostname:t,reusePort:r,maxRequestBodySize:o,fetch(m,y){if(m.headers.get("upgrade")?.toLowerCase()==="websocket"){let p=m.url,h=p.indexOf("/",8),x=h===-1?-1:p.indexOf("?",h),w=(h===-1?"/":x===-1?p.slice(h):p.slice(h,x)).replace(/\/+/g,"/"),P=w.length>1&&w.endsWith("/")?w.slice(0,-1):w,C=a.get(P),J;if(!C){let z=P.split("/").filter(Boolean);for(let[L,T]of a){if(!L.includes(":")&&!L.includes("*"))continue;let B=L.split("/").filter(Boolean),Z={},W=!0;for(let q=0;q<B.length;q++){let A=B[q];if(A==="*"){Z["*"]=z.slice(q).join("/");break}if(q>=z.length){W=!1;break}if(A.startsWith(":"))Z[A.slice(1)]=z[q];else if(A!==z[q]){W=!1;break}}if(W&&(B.includes("*")||B.length===z.length)){C=T,J=Z;break}}}if(C&&y.upgrade(m,{data:J?{...C,params:J}:C}))return}return u(m,y?.requestIP?.(m)?.address)},websocket:this.wsAdapter}):Bun.serve({port:s,hostname:t,reusePort:r,maxRequestBodySize:o,fetch(m,y){return u(m,y?.requestIP?.(m)?.address)}});this.server=f;for(let m of this.startHooks)Promise.resolve(m()).catch((y)=>console.error(`[${this.name}] onStart error:`,y));let d=async()=>{let y=this.name,p=process.stdout.isTTY;{let h=p?"\uD83D\uDED1":"!",x=p?"\u2705":"v";process.stdout.write(`
339
+ \x1B[31m${h} Stopping ${y}...\x1B[0m
340
+ `),await this.stop(!1),process.stdout.write(`\x1B[32m${x} ${y} has been stopped.\x1B[0m
341
+ `)}process.exit(0)};return this.shutdownHandler=d,process.on("SIGINT",d),process.on("SIGTERM",d),f}}var Qh=(e)=>{let t=e.indexOf("/",8);if(t===-1)return"/";let r=e.indexOf("?",t);return r===-1?e.slice(t):e.slice(t,r)},Zh=(e={})=>{let t=e.format??"pretty",r=e.requestId??!0,{skip:n,onLog:o}=e;return(s,i)=>{let a=Qh(s.req.url);if(n?.(s,a))return i?.();let u=r?s.requestId:void 0;if(u)s.setHeader("x-request-id",u);let c={timestamp:new Date().toISOString(),method:s.req.method,path:a,...u?{requestId:u}:{},ip:s.ip};if(o)o(c);else if(t==="json")console.log(JSON.stringify(c));else{let f=u?` [${u.slice(0,8)}]`:"";console.log(`[${c.timestamp}] ${c.method} ${c.path}${f}`)}return i?.()}};var ex=(e={})=>{let t=e.path??"/health",{readyPath:r,checks:n}=e,o=Date.now(),s=async()=>{let i={},a=!0;if(n){let c=Object.entries(n);await Promise.all(c.map(async([f,d])=>{try{let m=await d();if(i[f]=m?"ok":"fail",!m)a=!1}catch{i[f]="fail",a=!1}}))}let u={status:a?"ok":"degraded",uptimeMs:Date.now()-o,timestamp:new Date().toISOString()};if(e.version)u.version=e.version;if(n)u.checks=i;return Response.json(u,{status:a?200:503})};return{install(i){if(i.get(t,s),r&&r!==t)i.get(r,s)}}};var ao=(e)=>{let t=e.get("Vary");if(!t)e.set("Vary","Origin");else if(!t.toLowerCase().split(",").some((r)=>r.trim()==="origin"))e.set("Vary",`${t}, Origin`)},tx=(e={})=>{let t=e.origin??"*",r=e.methods||"GET,POST,PUT,PATCH,DELETE,OPTIONS",n=Array.isArray(e.allowedHeaders)?e.allowedHeaders.join(", "):e.allowedHeaders||"Content-Type, Authorization",o=Array.isArray(e.exposedHeaders)?e.exposedHeaders.join(", "):e.exposedHeaders,s=e.credentials===!0,i=(f)=>{let d=f._headers?.vary;if(!d)f.setHeader("Vary","Origin");else if(!d.toLowerCase().split(",").map((m)=>m.trim()).includes("origin"))f.setHeader("Vary",`${d}, Origin`)};if(typeof t==="string"){if(t===""){let p=(h,x)=>{if(h.req.method==="OPTIONS")return new Response(null,{status:204,headers:{Vary:"Origin"}});h.setHeader("Vary","Origin");let R=x?.();if(R&&typeof R.then==="function")return R.then((w)=>{if(w instanceof Response)ao(w.headers);else i(h);return w});if(R instanceof Response)ao(R.headers);else i(h);return R};return p.__isCors=!0,p}let f=s&&t!=="*",d={"Access-Control-Allow-Origin":t,"Access-Control-Allow-Methods":r,"Access-Control-Allow-Headers":n};if(t!=="*")d.Vary="Origin";if(f)d["Access-Control-Allow-Credentials"]="true";let m={status:204,headers:d},y=(p,h)=>{if(p.req.method==="OPTIONS")return new Response(null,m);if(p.setHeader("Access-Control-Allow-Origin",t),p.setHeader("Access-Control-Allow-Methods",r),t!=="*")p.setHeader("Vary","Origin");if(f)p.setHeader("Access-Control-Allow-Credentials","true");if(o)p.setHeader("Access-Control-Expose-Headers",o);let x=h?.();if(x&&typeof x.then==="function")return x.then((R)=>{if(R instanceof Response){if(R.headers.set("Access-Control-Allow-Origin",t),R.headers.set("Access-Control-Allow-Methods",r),t!=="*")ao(R.headers);if(f)R.headers.set("Access-Control-Allow-Credentials","true");if(o)R.headers.set("Access-Control-Expose-Headers",o)}else if(t!=="*")i(p);return R});if(x instanceof Response){if(x.headers.set("Access-Control-Allow-Origin",t),x.headers.set("Access-Control-Allow-Methods",r),t!=="*")ao(x.headers);if(f)x.headers.set("Access-Control-Allow-Credentials","true");if(o)x.headers.set("Access-Control-Expose-Headers",o)}else if(t!=="*")i(p);return x};return y.__isCors=!0,y}let a=Array.isArray(t)?new Set(t):null,u=(f)=>{if(!f)return null;if(a)return a.has(f)?f:null;return t(f)?f:null},c=(f,d)=>{let m=u(f.req.headers.get("origin"));if(f.req.method==="OPTIONS"){let p={"Access-Control-Allow-Methods":r,"Access-Control-Allow-Headers":n,Vary:"Origin"};if(m)p["Access-Control-Allow-Origin"]=m;if(s&&m)p["Access-Control-Allow-Credentials"]="true";return new Response(null,{status:204,headers:p})}if(f.setHeader("Vary","Origin"),f.setHeader("Access-Control-Allow-Methods",r),m){if(f.setHeader("Access-Control-Allow-Origin",m),s)f.setHeader("Access-Control-Allow-Credentials","true")}if(o)f.setHeader("Access-Control-Expose-Headers",o);let y=d?.();if(y&&typeof y.then==="function")return y.then((p)=>{if(p instanceof Response){if(ao(p.headers),p.headers.set("Access-Control-Allow-Methods",r),m){if(p.headers.set("Access-Control-Allow-Origin",m),s)p.headers.set("Access-Control-Allow-Credentials","true")}if(o)p.headers.set("Access-Control-Expose-Headers",o)}else i(f);return p});if(y instanceof Response){if(ao(y.headers),y.headers.set("Access-Control-Allow-Methods",r),m){if(y.headers.set("Access-Control-Allow-Origin",m),s)y.headers.set("Access-Control-Allow-Credentials","true")}if(o)y.headers.set("Access-Control-Expose-Headers",o)}else i(f);return y};return c.__isCors=!0,c};import{timingSafeEqual as rx}from"crypto";var nx=new Set(["GET","HEAD","OPTIONS"]),ox=(e)=>{try{let t=new URL(e.req.url),r=e.req.headers.get("host")?.trim();if(e._trustProxy){let n=e.req.headers.get("x-forwarded-host")?.split(",")[0]?.trim(),o=e.req.headers.get("x-forwarded-proto")?.split(",")[0]?.trim(),s=n||r;if(s){let i=o?`${o.replace(/:$/,"")}:`:t.protocol;return new URL(`${i}//${s}`).origin}}if(r)return new URL(`${t.protocol}//${r}`).origin;return t.origin}catch{return""}},sx=(e={})=>{let t=e.ignoreMethods?new Set(e.ignoreMethods.map((a)=>a.toUpperCase())):nx,r=e.allowedOrigins?new Set(e.allowedOrigins):null,n=e.cookieName||"csrf_token",o=(e.headerName||"x-csrf-token").toLowerCase(),s=e.requireToken===!0,i=e.allowMissingOrigin===!0;return(a,u)=>{let c=a.req.method.toUpperCase();if(t.has(c))return u?.();let f=a.req.headers.get("sec-fetch-site"),d=a.req.headers.get("origin"),m=a.req.headers.get("referer");if(f==="cross-site"){if(!r||!d||!r.has(d))return Response.json({status:"error",code:"CSRF_FORBIDDEN",message:"Cross-site request blocked"},{status:403})}let y=d;if(!y&&m)try{y=new URL(m).origin}catch{return Response.json({status:"error",code:"CSRF_FORBIDDEN",message:"Invalid Referer header"},{status:403})}if(y){let p=ox(a);if(!(p!==""&&y===p||r!==null&&r.has(y)))return Response.json({status:"error",code:"CSRF_FORBIDDEN",message:"Origin mismatch"},{status:403})}else if(!i&&f!=="same-origin")return Response.json({status:"error",code:"CSRF_FORBIDDEN",message:"Missing Origin or Referer header"},{status:403});if(s){let p=a.cookies[n],h=a.req.headers.get(o),x=!1;if(p&&h){let R=Buffer.from(p),w=Buffer.from(h);x=R.length===w.length&&rx(R,w)}if(!x)return Response.json({status:"error",code:"CSRF_TOKEN_INVALID",message:"Invalid or missing CSRF token"},{status:403})}return u()}};var ix=(e=1e4,t={})=>{let r=t.status??408,n=t.message??"Request Timeout",o=Number.isFinite(e)?Math.min(Math.max(e,0),2147483647):2147483647,s=async(i,a)=>{let u;try{let c=Promise.resolve(a()),f=new Promise((d)=>{u=setTimeout(()=>{i._detached=!0,c.catch(()=>{}),d(Response.json({status:"error",code:"REQUEST_TIMEOUT",message:n},{status:r}))},o)});return await Promise.race([c,f])}finally{if(u!==void 0)clearTimeout(u)}};return s.__timeout={ms:o,status:r,message:n},s};var ax=(e={})=>{let t=e.windowMs??60000,r=e.max??100,n=e.message??"Too many requests, please try again later.",o=Math.max(1,e.maxEntries??1e4),s=e.keyGenerator??((c)=>c.ip),i=e.store,a=(c,f,d,m,y)=>{let p=Math.max(0,r-f),h=String(Math.ceil(d/1000));if(c.setHeader("X-RateLimit-Limit",String(r)),c.setHeader("X-RateLimit-Remaining",String(p)),c.setHeader("X-RateLimit-Reset",h),f>r){let x=Math.max(1,Math.ceil((d-m)/1000));return Response.json({status:"error",code:"RATE_LIMITED",message:n},{status:429,headers:{"Retry-After":String(x),"X-RateLimit-Limit":String(r),"X-RateLimit-Remaining":"0","X-RateLimit-Reset":h}})}return y?.()};if(i)return async(c,f)=>{let d=Date.now(),m=s(c),{count:y,resetAt:p}=await i.increment(m,t);return a(c,y,p,d,f)};let u=new Map;return(c,f)=>{let d=Date.now(),m=s(c),y=u.get(m);if(!y||d>=y.resetAt){if(u.size>=o)for(let[h,x]of u){if(d>=x.resetAt)u.delete(h);if(u.size<o)break}let p=m;if(u.size>=o&&!u.has(m)){p="\x00__overflow__";let h=u.get(p);if(h&&d<h.resetAt)return h.count++,a(c,h.count,h.resetAt,d,f)}y={count:1,resetAt:d+t},u.delete(p),u.set(p,y)}else y.count++,u.delete(m),u.set(m,y);return a(c,y.count,y.resetAt,d,f)}};import{createHash as ux}from"crypto";var cx=["location","content-location","etag"],mc=(e)=>{let t;for(let r of cx){let n=e.headers.get(r);if(n!==null)(t??={})[r]=n}return t},fx=(e)=>{let t=e.req.headers.get("authorization")||"",r=e.req.headers.get("cookie")||"";if(!t&&!r)return"";return ux("sha256").update(t).update("\x00").update(r).digest("hex")},Fi=(e)=>{if(e.rawBody!==void 0)return new Response(e.rawBody,{status:e.status,headers:{...e.headers||{},"content-type":e.contentType||"application/json","X-Idempotent-Replayed":"true"}});return Response.json(e.body??null,{status:e.status,headers:{"X-Idempotent-Replayed":"true"}})},yc=(e,t,r)=>{let n=e.req.headers.get(t)?.trim();if(!n)return;let o=e.req.url,s=o.indexOf("/",8),i=s===-1?-1:o.indexOf("?",s),a=s===-1?"/":i===-1?o.slice(s):o.slice(s,i);return`${e.req.method}:${a}:${r(e)||""}:${n}`},dx=(e={})=>{let t=(e.headerName||"idempotency-key").toLowerCase(),r=e.ttlMs??300000,n=e.keyScope??fx,o=e.maxKeys??1e4,s=e.store;if(s){let d=typeof s.acquireToken==="function",m={delete:(p)=>{s.release(p)}},y=async(p)=>{let h=yc(p,t,n);if(!h){p._idempotencyKey=void 0;return}let x=await s.get(h);if(x&&Date.now()<x.expiresAt)return p._idempotencyKey=void 0,Fi(x);let R=!1,w;if(d){let C=await s.acquireToken(h,r);if(C)R=!0,w=C}else R=await s.acquire(h,r);if(!R)return p._idempotencyKey=void 0,Response.json({status:"error",code:"IDEMPOTENT_IN_FLIGHT",message:"Duplicate request is currently in flight"},{status:409});if(p._detached){p._idempotencyKey=void 0,await s.release(h,w);return}let P;try{P=await s.get(h)}catch(C){throw p._idempotencyKey=void 0,await s.release(h,w),C}if(p._detached){p._idempotencyKey=void 0,await s.release(h,w);return}if(P&&Date.now()<P.expiresAt)return p._idempotencyKey=void 0,await s.release(h,w),Fi(P);p._idempotencyKey=h,p._idemExtToken=w,p._idemInFlight=d?{delete:(C)=>{let J=p._idemExtToken;p._idemExtToken=void 0,s.release(C,J)}}:m;return};return y.__idempotencyCommit=(p,h,x)=>{let R=p._idempotencyKey;if(!R)return;let w=h instanceof Response,P=w&&(h.headers.get("content-type")||"").includes("text/event-stream"),C=null;if(!P&&x>=200&&x<300&&w)try{C=h.clone()}catch{C=null}let J=C?C.headers.get("content-type")||"application/json":void 0;return(async()=>{try{if(!p._detached&&!P&&x>=200&&x<300)if(w){if(C){let z=await C.arrayBuffer();if(!p._detached)await s.set(R,{status:x,rawBody:z,contentType:J,headers:mc(C),expiresAt:Date.now()+r},r)}}else await s.set(R,{status:x,body:h??null,expiresAt:Date.now()+r},r)}catch{}finally{let z=p._idemExtToken,L=Boolean(p._detached)||!p._idempotencyKey;if(p._idempotencyKey=void 0,p._idemExtToken=void 0,p._idemInFlight=void 0,!L)await s.release(R,z)}})()},y.__idempotencyRelease=(p)=>{let h=p._idempotencyKey;if(h){let x=p._idemExtToken;p._idempotencyKey=void 0,p._idemExtToken=void 0,p._idemInFlight=void 0,s.release(h,x)}},y}let i=new Map,a=new Map,u=()=>{if(i.size>=o){let d=i.keys().next().value;if(d!==void 0)i.delete(d)}},c=(d)=>{let m=yc(d,t,n);if(!m){d._idempotencyKey=void 0;return}let y=Date.now(),p=i.get(m);if(p){if(y<p.expiresAt)return d._idempotencyKey=void 0,Fi(p);i.delete(m)}let h=a.get(m);if(h!==void 0){if(y<h.expiresAt)return d._idempotencyKey=void 0,Response.json({status:"error",code:"IDEMPOTENT_IN_FLIGHT",message:"Duplicate request is currently in flight"},{status:409});a.delete(m)}let x=crypto.randomUUID();a.set(m,{token:x,expiresAt:y+r}),d._idempotencyKey=m,d._idemToken=x,d._idemInFlight={delete:(R)=>{let w=a.get(R);if(w&&w.token===x)a.delete(R)}};return},f=(d,m)=>{let y=d._idemToken;d._idempotencyKey=void 0,d._idemToken=void 0,d._idemInFlight=void 0;let p=a.get(m);if(p&&(!y||p.token===y))a.delete(m)};return c.__idempotencyCommit=(d,m,y)=>{let p=d._idempotencyKey;if(!p)return;let h=m instanceof Response,x=h&&(m.headers.get("content-type")||"").includes("text/event-stream");if(!d._detached&&!x&&y>=200&&y<300){if(h){let R=null;try{R=m.clone()}catch{R=null}if(R){let w=R.headers.get("content-type")||"application/json";return R.arrayBuffer().then((P)=>{if(d._detached)return;u(),i.set(p,{status:y,rawBody:P,contentType:w,headers:mc(R),expiresAt:Date.now()+r})}).catch(()=>{}).finally(()=>{f(d,p)})}f(d,p);return}u(),i.set(p,{status:y,body:m??null,expiresAt:Date.now()+r})}f(d,p)},c.__idempotencyRelease=(d)=>{let m=d._idempotencyKey;if(m)f(d,m)},c},px=()=>{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,t={})=>{let r=t.prefix??"barejs:",n=typeof e.send==="function",o=(d)=>n?e.send("GET",[d]):e.get(d),s=(d)=>n?e.send("DEL",[d]):e.del(d),i=(d)=>n?e.send("INCR",[d]):e.incr(d),a=async(d,m,y)=>{if(n){await e.send("SET",[d,m,"PX",String(y)]);return}try{await e.set(d,m,"PX",y)}catch{if(await e.set(d,m),typeof e.pexpire==="function")await e.pexpire(d,y);else if(typeof e.expire==="function")await e.expire(d,Math.max(1,Math.ceil(y/1000)))}},u=async(d,m)=>{if(n)await e.send("PEXPIRE",[d,String(m)]);else if(typeof e.pexpire==="function")await e.pexpire(d,m);else if(typeof e.expire==="function")await e.expire(d,Math.max(1,Math.ceil(m/1000)))},c=new Map,f='if redis.call("get", KEYS[1]) == ARGV[1] then return redis.call("del", KEYS[1]) else return 0 end';return{async increment(d,m){let y=`${r}rl:${d}`,p=Number(await i(y));if(p===1)await u(y,m);let h=m,x=null;if(n)x=Number(await e.send("PTTL",[y]));else if(typeof e.pttl==="function")x=Number(await e.pttl(y));else if(typeof e.ttl==="function"){let R=Number(await e.ttl(y));x=R<0?R:R*1000}if(x===-1)await u(y,m);else if(x!==null&&Number.isFinite(x)&&x>0)h=x;return{count:p,resetAt:Date.now()+h}},async get(d){let m=await o(`${r}idem:${d}`);if(!m)return;try{let y=JSON.parse(typeof m==="string"?m:String(m));if(typeof y.rawBodyBase64==="string"){let p=Buffer.from(y.rawBodyBase64,"base64");return{status:y.status,rawBody:p.buffer.slice(p.byteOffset,p.byteOffset+p.byteLength),contentType:y.contentType,headers:y.headers,expiresAt:y.expiresAt}}return y}catch{return}},async set(d,m,y){let p={status:m.status,expiresAt:m.expiresAt};if(m.rawBody!==void 0){if(p.rawBodyBase64=Buffer.from(m.rawBody).toString("base64"),p.contentType=m.contentType,m.headers)p.headers=m.headers}else p.body=m.body;await a(`${r}idem:${d}`,JSON.stringify(p),y)},async acquireToken(d,m=30000){let y=`${r}idem:lock:${d}`,p=crypto.randomUUID();if(n){let x=await e.send("SET",[y,p,"PX",String(m),"NX"]);return x==="OK"||x===!0?p:null}let h=await e.set(y,p,"PX",m,"NX");return h==="OK"||h===!0||h===1?p:null},async acquire(d,m=30000){let y=await this.acquireToken(d,m);if(!y)return!1;let p=c.get(d);if(!p)p=[],c.set(d,p);return p.push(y),!0},async release(d,m){let y=`${r}idem:lock:${d}`,p=m;if(p===void 0){let x=c.get(d);if(p=x?.pop(),x&&x.length===0)c.delete(d)}if(!p)return;if(n)try{await e.send("EVAL",['if redis.call("get", KEYS[1]) == ARGV[1] then return redis.call("del", KEYS[1]) else return 0 end',"1",y,p]);return}catch{}else if(typeof e.eval==="function")try{await e.eval('if redis.call("get", KEYS[1]) == ARGV[1] then return redis.call("del", KEYS[1]) else return 0 end',1,y,p);return}catch{}if(await o(y)===p)await s(y)},async revoke(d,m){await a(`${r}rev:${d}`,"1",m)},async isRevoked(d){let m=await o(`${r}rev:${d}`);return m!==null&&m!==void 0}}};var mx=(e={})=>{let t=e.failureThreshold??5,r=e.resetTimeoutMs??30000,n=e.isFailure??((p,h)=>Boolean(h)||p instanceof Response&&(p.status>=500||p.status===408)),o="CLOSED",s=0,i=0,a=!1,u=0,c=0,f=0,d=(p)=>{if(o!==p){let h=o;o=p,u++;try{e.onStateChange?.(h,p)}catch{}}},m=async(p)=>{if(o==="OPEN"){let P=Date.now()-i;if(P<r){let C=Math.max(1,Math.ceil((r-P)/1000));return Response.json({status:"error",code:"CIRCUIT_OPEN",message:"Service temporarily unavailable"},{status:503,headers:{"Retry-After":String(C)}})}d("HALF_OPEN")}let h=!1;if(o==="HALF_OPEN"){if(a)return Response.json({status:"error",code:"CIRCUIT_OPEN",message:"Service temporarily unavailable"},{status:503,headers:{"Retry-After":"1"}});a=!0,h=!0}let x=u,R,w=h?++c:0;if(h)f=w,R=setTimeout(()=>{if(f===w&&x===u)a=!1,f=0,i=Date.now(),d("OPEN")},Math.min(Math.max(r,1),2147483647));try{let P=await p();if(x!==u)return P;if(n(P)){if(s++,h||s>=t)i=Date.now(),d("OPEN")}else if(s=0,h)d("CLOSED");return P}catch(P){if(x===u&&n(void 0,P)){if(s++,h||s>=t)i=Date.now(),d("OPEN")}throw P}finally{if(R!==void 0)clearTimeout(R);if(h&&f===w)a=!1,f=0}},y=(p,h)=>m(()=>h?h():void 0);return y.__circuitBreaker=m,y};var yx=(e={})=>{let t=[];if(e.noSniff!==!1)t.push(["X-Content-Type-Options","nosniff"]);if(e.frameOptions!==!1)t.push(["X-Frame-Options",e.frameOptions??"DENY"]);if(e.referrerPolicy!==!1)t.push(["Referrer-Policy",e.referrerPolicy??"strict-origin-when-cross-origin"]);if(e.hsts!==!1)t.push(["Strict-Transport-Security",e.hsts??"max-age=31536000; includeSubDomains"]);if(e.contentSecurityPolicy)t.push(["Content-Security-Policy",e.contentSecurityPolicy]);t.push(["X-XSS-Protection","0"]);let r=t.length,n=Object.freeze((()=>{let o={};for(let s=0;s<r;s++){let i=t[s];o[i[0].toLowerCase()]=i[1]}return o})());return(o,s)=>{if(!o._headers)o._headers=n;else o._headers={...o._headers,...n};let i=s?.();if(i&&typeof i.then==="function")return i.then((a)=>{if(a instanceof Response)for(let u=0;u<r;u++){let c=t[u];if(!a.headers.has(c[0]))a.headers.set(c[0],c[1])}return a});if(i instanceof Response)for(let a=0;a<r;a++){let u=t[a];if(!i.headers.has(u[0]))i.headers.set(u[0],u[1])}return i}};import{resolve as gc,sep as Ms}from"path";import{stat as gx,realpath as hc}from"fs/promises";var hx=(e="public",t={})=>{let r=gc(process.cwd(),e),n=r.endsWith(Ms)?r:r+Ms,o=null,s=t.maxAge??3600,i=t.etag!==!1,a=t.cacheMetadata,u=Boolean(a),c=typeof a==="object"?a.maxEntries??1000:1000,f=typeof a==="object"?a.ttlMs??30000:30000,d=u?new Map:null,m=async(y,p)=>{let h=y.req.method;if(h!=="GET"&&h!=="HEAD")return p?.();let x=y.req.url,R=x.indexOf("/",8),w=R===-1?-1:x.indexOf("?",R),P=R===-1?"":w===-1?x.slice(R):x.slice(R,w),C;try{C=decodeURIComponent(P)}catch{return y.status(400).send("Bad Request")}if(C.includes("\x00"))return y.status(400).send("Bad Request");let J=C.replace(/^\/+/,""),z=gc(r,J);if(z!==r&&!z.startsWith(n))return y.status(403).send("Forbidden");let L=z,T=0,B=0,Z="",W=d?.get(z);if(W&&Date.now()<W.expiresAt)d.delete(z),d.set(z,W),L=W.realFile,T=W.fileSize,B=W.mtimeMs,Z=W.etag;else try{let[Q,re]=await Promise.all([o??=hc(r),hc(z)]),ie=Q.endsWith(Ms)?Q:Q+Ms;if(re!==Q&&!re.startsWith(ie))return y.status(403).send("Forbidden");let ge=await gx(re);if(ge.isDirectory())return p?.();if(L=re,T=ge.size,B=Math.floor(ge.mtimeMs),Z=i?`W/"${T.toString(16)}-${B.toString(16)}"`:"",d){if(d.size>=c){let ee=d.keys().next().value;if(ee!==void 0)d.delete(ee)}d.set(z,{realFile:L,fileSize:T,mtimeMs:B,etag:Z,expiresAt:Date.now()+f})}}catch{return o=null,p?.()}let q=Bun.file(L),A={"Cache-Control":`public, max-age=${s}`,"Accept-Ranges":"bytes"};if(i){A.ETag=Z;let Q=y.req.headers?.get?.("if-none-match")?.trim();if(Q){if(Q==="*"||Q.split(",").some((ie)=>ie.trim()===Z))return new Response(null,{status:304,headers:A})}}let oe=y.req.headers?.get?.("range");if(oe&&oe.startsWith("bytes=")&&T>0){let re=oe.slice(6).split("-");if(re.length!==2)return new Response(null,{status:416,headers:{...A,"Content-Range":`bytes */${T}`}});let[ie,ge]=re,ee=/^\d+$/;if(!ie&&!ge||ie&&!ee.test(ie)||ge&&!ee.test(ge))return new Response(null,{status:416,headers:{...A,"Content-Range":`bytes */${T}`}});let ae=ie?Number(ie):0,D=ge?Math.min(Number(ge),T-1):T-1;if(!ie&&ge){let k=Number(ge);if(k===0)return new Response(null,{status:416,headers:{...A,"Content-Range":`bytes */${T}`}});ae=Math.max(0,T-k),D=T-1}if(!Number.isInteger(ae)||!Number.isInteger(D)||ae<0||ae>=T||ae>D)return new Response(null,{status:416,headers:{...A,"Content-Range":`bytes */${T}`}});if(A["Content-Range"]=`bytes ${ae}-${D}/${T}`,A["Content-Length"]=String(D-ae+1),q.type)A["Content-Type"]=q.type;return new Response(h==="HEAD"?null:q.slice(ae,D+1),{status:206,headers:A})}if(q.type)A["Content-Type"]=q.type;return A["Content-Length"]=String(T),new Response(h==="HEAD"?null:q,{status:200,headers:A})};return m.__isStatic=!0,m};import{brotliCompressSync as xx,constants as bx}from"zlib";var Ix=(e={})=>{let t=e.minSize??1024,r=e.level??6,n=e.encodings??["zstd","br","gzip"],o=typeof Bun.zstdCompressSync==="function",s=(u)=>{let f=u.toLowerCase().split(","),d=new Map;for(let h=0;h<f.length;h++){let x=f[h].trim();if(!x)continue;let R=x.indexOf(";"),w=(R===-1?x:x.slice(0,R)).trim(),P=1;if(R!==-1){let C=x.slice(R+1).match(/q\s*=\s*([0-9.]+)/);if(C){let J=parseFloat(C[1]);if(Number.isFinite(J))P=J}}d.set(w,P)}let m=d.get("*"),y=null,p=0;for(let h=0;h<n.length;h++){let x=n[h];if(x==="zstd"&&!o)continue;let R=d.has(x)?d.get(x):m??0;if(R>p)p=R,y=x}return y},i=async(u,c)=>{if(u.req.method==="HEAD")return c;let f=u.req.headers.get("accept-encoding");if(!f)return c;let d=s(f);if(!d)return c;if(!(c instanceof Response))return c;if(c.status===204||c.status===206||c.status===304)return c;if(c.headers.has("content-encoding"))return c;if((c.headers.get("content-type")||"").toLowerCase().includes("text/event-stream"))return c;let y=await c.arrayBuffer();if(y.byteLength<t)return new Response(y,{status:c.status,headers:c.headers});let p=new Uint8Array(y),h;if(d==="zstd")h=Bun.zstdCompressSync(p);else if(d==="br")h=xx(p,{params:{[bx.BROTLI_PARAM_QUALITY]:Math.min(11,Math.max(1,r))}});else h=Bun.gzipSync(p,{level:r});let x=new Headers(c.headers);x.set("Content-Encoding",d);let R=x.get("Vary");if(!R)x.set("Vary","Accept-Encoding");else if(!R.toLowerCase().split(",").some((w)=>w.trim()==="accept-encoding"))x.set("Vary",`${R}, Accept-Encoding`);return x.delete("Content-Length"),new Response(h,{status:c.status,headers:x})},a=async(u,c)=>{let f=await(c?c():void 0);return i(u,f)};return a.__compress=i,a};import{createHash as _x,createHmac as xc,timingSafeEqual as Us}from"crypto";var ji=new TextEncoder,Ni=(e)=>Buffer.from(e).toString("base64url"),Ko=(e)=>Buffer.from(e,"base64url").toString("utf-8"),uo=new Map,Rx=async(e)=>{if(uo.has(e))return uo.get(e);let t=await crypto.subtle.importKey("raw",ji.encode(e),{name:"HMAC",hash:"SHA-256"},!1,["sign","verify"]);if(uo.size>=1000){let r=uo.keys().next().value;if(r!==void 0)uo.delete(r)}return uo.set(e,t),t},bc=(e)=>{if(!e||typeof e!=="object")return;let t=[e];while(t.length>0){let r=t.pop();if(!r||typeof r!=="object")continue;if(Array.isArray(r)){for(let n=0;n<r.length;n++)if(r[n]&&typeof r[n]==="object")t.push(r[n])}else{if(Object.hasOwn(r,"__proto__"))delete r.__proto__;let n=Object.values(r);for(let o=0;o<n.length;o++)if(n[o]&&typeof n[o]==="object")t.push(n[o])}}},Ox=async(e,t)=>{let r=JSON.stringify({alg:"HS256",typ:"JWT"}),n=JSON.stringify(e),o=Ni(r),s=Ni(n),i=`${o}.${s}`,a=await Rx(t),u=await crypto.subtle.sign("HMAC",a,ji.encode(i)),c=Ni(new Uint8Array(u));return`${i}.${c}`},Ic=0xffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc632551n,_c=(e)=>{let t=e.indexOf(".");if(t<=0)return null;let r=e.indexOf(".",t+1);if(r<=t+1)return null;let n=e.slice(r+1);if(!/^[A-Za-z0-9_-]+$/.test(n))return null;let o=Buffer.from(n,"base64url");if(o.length!==64)return null;try{if(JSON.parse(Ko(e.slice(0,t)))?.alg!=="ES256")return null}catch{return null}let s=BigInt("0x"+o.subarray(32,64).toString("hex"));if(s<=0n||s>=Ic)return null;let a=(Ic-s).toString(16).padStart(64,"0"),u=Buffer.allocUnsafe(64);return o.copy(u,0,0,32),Buffer.from(a,"hex").copy(u,32),e.slice(0,r+1)+u.toString("base64url")},lr=new Map;function wx(e,t=3600000,r){let n=_c(e);if(r){if(n)return Promise.all([r.revoke(e,t),r.revoke(n,t)]).then(()=>{});return r.revoke(e,t)}if(lr.size>=1e4){let s=Date.now();for(let[i,a]of lr)if(s>=a)lr.delete(i);if(lr.size>=1e4){let i=lr.keys().next().value;if(i!==void 0)lr.delete(i)}}let o=Date.now()+t;if(lr.set(e,o),n)lr.set(n,o)}function Ls(e,t){if(t)return t.isRevoked(e);let r=lr.get(e);if(r===void 0)return!1;if(Date.now()>=r)return lr.delete(e),!1;return!0}var Uo=new Map,Rc=(e)=>e==="RS256"?{name:"RSASSA-PKCS1-v1_5",hash:"SHA-256"}:{name:"ECDSA",namedCurve:"P-256"},$x=(e)=>e==="RS256"?{name:"RSASSA-PKCS1-v1_5"}:{name:"ECDSA",hash:"SHA-256"},kx=(e)=>{let t=e.replace(/-----BEGIN [A-Z0-9 ]+-----/g,"").replace(/-----END [A-Z0-9 ]+-----/g,"").replace(/\s+/g,""),r=Buffer.from(t,"base64");return r.buffer.slice(r.byteOffset,r.byteOffset+r.byteLength)},Ax=async(e,t)=>{if(typeof e!=="string")return e;let r=`${t}:${e}`,n=Uo.get(r);if(n)return n;let o=await crypto.subtle.importKey("spki",kx(e),Rc(t),!1,["verify"]);if(Uo.size>=1000){let s=Uo.keys().next().value;if(s!==void 0)Uo.delete(s)}return Uo.set(r,o),o},Sx=(e)=>{let t=typeof e==="string"?{secret:e}:e,r=t.secret??"",{isRevoked:n,revocationStore:o,publicKey:s,jwksUri:i}=t,a=t.jwksCacheTtlMs??300000,u=t.algorithms??(s||i?["RS256","ES256"]:["HS256"]),c=t.issuer===void 0?null:Array.isArray(t.issuer)?t.issuer:[t.issuer],f=t.audience===void 0?null:Array.isArray(t.audience)?t.audience:[t.audience],d=(L,T,B)=>{if(L.set("user",T),Array.isArray(B)){if(B.length===0)return;let[Z,...W]=B;return Z(L,W)}if(typeof B==="function")return B();return},m=(L,T,B,Z)=>{if(!T||typeof T!=="object"||Array.isArray(T))return L.status(401).send("Invalid token payload");let W=Date.now()*0.001;if(typeof T.exp==="number"&&W>=T.exp)return L.status(401).send("Token expired");if(typeof T.nbf==="number"&&W<T.nbf)return L.status(401).send("Token not active");if(c&&(typeof T.iss!=="string"||!c.includes(T.iss)))return L.status(401).send("Invalid token issuer");if(f){if(!(Array.isArray(T.aud)?T.aud:typeof T.aud==="string"?[T.aud]:[]).some((oe)=>typeof oe==="string"&&f.includes(oe)))return L.status(401).send("Invalid token audience")}let q=_c(B);if(Ls(B)||q&&Ls(q)||T?.jti&&Ls(String(T.jti)))return L.status(401).send("Token revoked");if(o)return(async()=>{if(await o.isRevoked(B))return L.status(401).send("Token revoked");if(q&&await o.isRevoked(q))return L.status(401).send("Token revoked");if(T?.jti&&await o.isRevoked(String(T.jti)))return L.status(401).send("Token revoked");if(n){if(await n(T,B))return L.status(401).send("Token revoked")}return d(L,T,Z)})();if(n){let A=n(T,B);if(A&&typeof A.then==="function")return A.then((oe)=>oe?L.status(401).send("Token revoked"):d(L,T,Z));if(A)return L.status(401).send("Token revoked")}return d(L,T,Z)};if(!s&&!i&&u.length===1&&u[0]==="HS256"){let L=(T,B)=>{if(!r)return T.status(401).send("Unsupported token algorithm");let Z=T.req.headers.get("Authorization");if(!Z?.startsWith("Bearer "))return T.status(401).send("Bearer token required");let W=Z.slice(7),q=W.indexOf("."),A=q===-1?-1:W.indexOf(".",q+1);if(q===-1||A===-1||W.indexOf(".",A+1)!==-1)return T.status(401).send("Malformed JWT token");let oe=W.slice(0,q),Q=W.slice(q+1,A),re=W.slice(A+1);if(!/^[A-Za-z0-9_-]+$/.test(re))return T.status(401).send("Invalid signature");let ie=W.slice(0,A),ge;try{let ee=xc("sha256",r).update(ie).digest(),ae=Buffer.from(re,"base64url");if(ae.length!==ee.length||ae.toString("base64url")!==re||!Us(ae,ee))return T.status(401).send("Invalid signature");let D=JSON.parse(Ko(oe));if(!D||D.alg!=="HS256")return T.status(401).send("Unsupported token algorithm");let k=Ko(Q);if(ge=JSON.parse(k),ge&&typeof ge==="object"&&(k.indexOf("__proto__")!==-1||k.indexOf("\\u")!==-1))bc(ge)}catch{return T.status(401).send("Token verification failed")}return m(T,ge,W,B)};if(n||o)return async(T,B)=>L(T,B);return L}let p=0,h=0,x=[],R=null,w=new Map,P=15000,C=async(L=!1)=>{let T=Date.now();if(!L&&x.length>0&&T-p<a)return x;if(L&&T-h<P&&x.length>0)return x;if(R)return R;if(L)h=T;return R=(async()=>{let B=await fetch(i,{signal:AbortSignal.timeout(5000)});if(!B.ok)throw Error(`JWKS fetch failed: ${B.status}`);let Z=await B.json();return x=Array.isArray(Z?.keys)?Z.keys:[],p=Date.now(),w.clear(),x})().finally(()=>{R=null}),R},J=(L,T,B)=>{let Z=B==="RS256"?"RSA":"EC",W=(q)=>q&&q.use!=="enc"&&(!q.kty||q.kty===Z)&&(!q.alg||q.alg===B);return T?L.find((q)=>q.kid===T&&W(q)):L.find((q)=>W(q))},z=async(L,T)=>{let B=`${T}:${L??"__default__"}`,Z=w.get(B);if(Z&&Date.now()-p<a)return Z;let W=await C(!1),q=J(W,L,T);if(!q&&L)W=await C(!0),q=J(W,L,T);if(!q)return null;let A=await crypto.subtle.importKey("jwk",q,Rc(T),!1,["verify"]);return w.set(B,A),A};return async(L,T)=>{let B=L.req.headers.get("Authorization");if(!B?.startsWith("Bearer "))return L.status(401).send("Bearer token required");let Z=B.slice(7),W=Z.indexOf("."),q=W===-1?-1:Z.indexOf(".",W+1);if(W===-1||q===-1||Z.indexOf(".",q+1)!==-1)return L.status(401).send("Malformed JWT token");let A=Z.slice(0,W),oe=Z.slice(W+1,q),Q=Z.slice(q+1);if(!/^[A-Za-z0-9_-]+$/.test(Q))return L.status(401).send("Invalid signature");let re=Z.slice(0,q),ie;try{let ge=JSON.parse(Ko(A)),ee=ge?.alg;if(!ee||!u.includes(ee))return L.status(401).send("Unsupported token algorithm");if(ee==="HS256"){if(!r)return L.status(401).send("Unsupported token algorithm");let D=xc("sha256",r).update(re).digest(),k=Buffer.from(Q,"base64url");if(k.length!==D.length||k.toString("base64url")!==Q||!Us(k,D))return L.status(401).send("Invalid signature")}else{let D=null;if(i)D=await z(ge?.kid,ee);else if(s)D=await Ax(s,ee);if(!D)return L.status(401).send("Invalid signature");let k=Buffer.from(Q,"base64url");if(k.toString("base64url")!==Q)return L.status(401).send("Invalid signature");let v=k.buffer.slice(k.byteOffset,k.byteOffset+k.byteLength);if(!await crypto.subtle.verify($x(ee),D,v,ji.encode(re)))return L.status(401).send("Invalid signature")}let ae=Ko(oe);if(ie=JSON.parse(ae),ie&&typeof ie==="object"&&(ae.indexOf("__proto__")!==-1||ae.indexOf("\\u")!==-1))bc(ie)}catch{return L.status(401).send("Token verification failed")}return m(L,ie,Z,T)}},Es=(e)=>_x("sha256").update(e).digest(),Px=(e)=>{let t=Es(e.user),r=Es(e.pass);return async(n,o)=>{let s=n.req.headers.get("Authorization");if(!s?.startsWith("Basic "))return n.status(401).json({status:"error",message:"Basic Auth required"});let i=s.slice(6).trim();if(!i)return n.status(401).json({status:"error",message:"Missing credentials"});let a=Buffer.from(i,"base64").toString("utf-8"),u=a.indexOf(":");if(u===-1)return n.status(401).json({status:"error",message:"Invalid credentials"});let c=a.slice(0,u),f=a.slice(u+1),d=Us(Es(c),t),m=Us(Es(f),r);if(d&&m)return o?.();return n.status(401).json({status:"error",message:"Invalid credentials"})}},Cx=(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?.()};var Oc={make:(e)=>{if(Et.hash.algorithm==="bcrypt"){let t=Math.max(4,Math.min(31,Et.hash.timeCost));return Bun.password.hash(e,{algorithm:"bcrypt",cost:t})}return Bun.password.hash(e,Et.hash)},verify:async(e,t)=>{if(!t||typeof t!=="string")return!1;try{return await Bun.password.verify(e,t)}catch{return!1}},needsRehash:(e)=>{if(!e||typeof e!=="string")return!0;let{algorithm:t,memoryCost:r,timeCost:n}=Et.hash;if(t==="bcrypt"){if(!/^\$2[aby]\$/.test(e))return!0;let i=e.match(/^\$2[aby]\$(\d+)\$/),a=Math.max(4,Math.min(31,n));return!i||Number(i[1])!==a}if(!e.startsWith(`$${t}$`))return!0;let o=e.match(/(?:^|[,$])m=(\d+)(?:[,$]|$)/),s=e.match(/(?:^|[,$])t=(\d+)(?:[,$]|$)/);return!o||Number(o[1])!==r||!s||Number(s[1])!==n}};var Tx=(e,t,r)=>{let n=t;if(r?.params){let a=r.params;n=n.replace(/:([a-zA-Z0-9_]+)(?=\/|\?|$)/g,(u,c)=>Object.hasOwn(a,c)&&a[c]!==void 0?encodeURIComponent(String(a[c])):u)}let o=e.endsWith("/")?e.slice(0,-1):e,s=n.startsWith("/")?n:`/${n}`,i=`${o}${s}`;if(r?.query){let a=new URLSearchParams;for(let[c,f]of Object.entries(r.query))if(f!==void 0)a.set(c,String(f));let u=a.toString();if(u)i+=(i.includes("?")?"&":"?")+u}return i},Fx=(e,t={})=>{let r=typeof e==="object"&&e!==null&&typeof e.fetch==="function",n=r?"http://localhost":e,o=t.fetch??(r?(a,u)=>e.fetch(new Request(String(a),u)):fetch),s=t.headers??{},i=async(a,u,c)=>{let f=Tx(n,u,c),d=new Headers;for(let[h,x]of Object.entries(s))d.set(h,x);if(c?.headers)for(let[h,x]of Object.entries(c.headers))d.set(h,x);let m={method:a,headers:d};if(c?.body!==void 0&&a!=="GET"&&a!=="HEAD"){let h=c.body;if(typeof h==="string"||h instanceof FormData||h instanceof URLSearchParams||h instanceof Blob||h instanceof ArrayBuffer||ArrayBuffer.isView(h)||typeof ReadableStream<"u"&&h instanceof ReadableStream){if(h instanceof FormData)d.delete("content-type");m.body=h}else{if(!d.has("content-type"))d.set("Content-Type","application/json");m.body=JSON.stringify(h)}}let y=await o(f,m),p=null;if(y.status!==204&&y.status!==205&&y.status!==304){let h=(y.headers.get("content-type")||"").toLowerCase();if(h.includes("application/json")||h.includes("+json")){let x=await y.text();if(x)try{p=JSON.parse(x)}catch{p=x}else p=null}else p=await y.text()}if(!y.ok){let h=Error(`HTTP ${y.status}`);throw h.status=y.status,h.data=p,h}return p};return{get:(a,u)=>i("GET",a,u),post:(a,u)=>i("POST",a,u),put:(a,u)=>i("PUT",a,u),patch:(a,u)=>i("PATCH",a,u),delete:(a,u)=>i("DELETE",a,u)}};export{Ti as BareJS,xn as BareRouter,jo as Context,Oc as Hash,Oc as Password,Hh as T,Hh as Type,Hh as TypeBox,Dy as Z,Dy as Zod,Sx as bareAuth,Fx as bareClient,Px as basicAuth,mx as circuitBreaker,Ix as compress,tx as cors,bu as createResponseFilter,px as createSingleflight,Ox as createToken,sx as csrf,Pi as generateOpenAPISpec,Cx as hasRole,ex as healthcheck,dx as idempotency,Ls as isTokenRevoked,Zh as logger,xi as n,xi as native,ax as rateLimit,lx as redisStore,Ci as renderDocsHTML,wx as revokeToken,Ii as schemaValidator,yx as securityHeaders,hx as staticFile,hi as t,ix as timeout,hi as typebox,qy as v,qy as validate,mu as z,mu as zod};