@absolutejs/auth 0.0.2 → 0.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1,154 +1,161 @@
1
1
  // @bun
2
- var $A=Object.create;var{getPrototypeOf:QA,defineProperty:f5,getOwnPropertyNames:YA}=Object;var JA=Object.prototype.hasOwnProperty;var n4=(w,z,U)=>{U=w!=null?$A(QA(w)):{};let W=z||!w||!w.__esModule?f5(U,"default",{value:w,enumerable:!0}):U;for(let A of YA(w))if(!JA.call(W,A))f5(W,A,{get:()=>w[A],enumerable:!0});return W};var aw=(w,z)=>()=>(z||w((z={exports:{}}).exports,z),z.exports);var J6=(w,z)=>{for(var U in z)f5(w,U,{get:z[U],enumerable:!0,configurable:!0,set:(W)=>z[U]=()=>W})};var ZU=aw((XU)=>{Object.defineProperty(XU,"__esModule",{value:!0});XU.parse=Tq;XU.serialize=gq;var jq=/^[\u0021-\u003A\u003C\u003E-\u007E]+$/,Eq=/^[\u0021-\u003A\u003C-\u007E]*$/,Iq=/^([.]?[a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?)([.][a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?)*$/i,xq=/^[\u0020-\u003A\u003D-\u007E]*$/,Vq=Object.prototype.toString,kq=(()=>{let w=function(){};return w.prototype=Object.create(null),w})();function Tq(w,z){let U=new kq,W=w.length;if(W<2)return U;let A=z?.decode||fq,X=0;do{let Z=w.indexOf("=",X);if(Z===-1)break;let $=w.indexOf(";",X),Q=$===-1?W:$;if(Z>Q){X=w.lastIndexOf(";",Z-1)+1;continue}let Y=WU(w,X,Z),B=AU(w,Z,Y),G=w.slice(Y,B);if(U[G]===void 0){let _=WU(w,Z+1,Q),H=AU(w,Q,_),F=A(w.slice(_,H));U[G]=F}X=Q+1}while(X<W);return U}function WU(w,z,U){do{let W=w.charCodeAt(z);if(W!==32&&W!==9)return z}while(++z<U);return U}function AU(w,z,U){while(z>U){let W=w.charCodeAt(--z);if(W!==32&&W!==9)return z+1}return U}function gq(w,z,U){let W=U?.encode||encodeURIComponent;if(!jq.test(w))throw new TypeError(`argument name is invalid: ${w}`);let A=W(z);if(!Eq.test(A))throw new TypeError(`argument val is invalid: ${z}`);let X=w+"="+A;if(!U)return X;if(U.maxAge!==void 0){if(!Number.isInteger(U.maxAge))throw new TypeError(`option maxAge is invalid: ${U.maxAge}`);X+="; Max-Age="+U.maxAge}if(U.domain){if(!Iq.test(U.domain))throw new TypeError(`option domain is invalid: ${U.domain}`);X+="; Domain="+U.domain}if(U.path){if(!xq.test(U.path))throw new TypeError(`option path is invalid: ${U.path}`);X+="; Path="+U.path}if(U.expires){if(!dq(U.expires)||!Number.isFinite(U.expires.valueOf()))throw new TypeError(`option expires is invalid: ${U.expires}`);X+="; Expires="+U.expires.toUTCString()}if(U.httpOnly)X+="; HttpOnly";if(U.secure)X+="; Secure";if(U.partitioned)X+="; Partitioned";if(U.priority)switch(typeof U.priority==="string"?U.priority.toLowerCase():void 0){case"low":X+="; Priority=Low";break;case"medium":X+="; Priority=Medium";break;case"high":X+="; Priority=High";break;default:throw new TypeError(`option priority is invalid: ${U.priority}`)}if(U.sameSite)switch(typeof U.sameSite==="string"?U.sameSite.toLowerCase():U.sameSite){case!0:case"strict":X+="; SameSite=Strict";break;case"lax":X+="; SameSite=Lax";break;case"none":X+="; SameSite=None";break;default:throw new TypeError(`option sameSite is invalid: ${U.sameSite}`)}return X}function fq(w){if(w.indexOf("%")===-1)return w;try{return decodeURIComponent(w)}catch(z){return w}}function dq(w){return Vq.call(w)==="[object Date]"}});var F8=aw((JE,YU)=>{var $U=12,cq=0,jw=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,4,4,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,6,7,7,7,7,7,7,7,7,7,7,7,7,8,7,7,10,9,9,9,11,4,4,4,4,4,4,4,4,4,4,4,0,0,0,0,0,0,0,0,0,0,0,0,12,0,0,0,0,24,36,48,60,72,84,96,0,12,12,12,0,0,0,0,0,0,0,0,0,0,0,24,0,0,0,0,0,0,0,0,0,24,24,24,0,0,0,0,0,0,0,0,0,24,24,0,0,0,0,0,0,0,0,0,0,48,48,48,0,0,0,0,0,0,0,0,0,0,48,48,0,0,0,0,0,0,0,0,0,48,0,0,0,0,0,0,0,0,0,0,127,63,63,63,0,31,15,15,15,7,7,7];function iq(w){var z=w.indexOf("%");if(z===-1)return w;var U=w.length,W="",A=0,X=0,Z=z,$=$U;while(z>-1&&z<U){var Q=QU(w[z+1],4),Y=QU(w[z+2],0),B=Q|Y,G=jw[B];if($=jw[256+$+G],X=X<<6|B&jw[364+G],$===$U)W+=w.slice(A,Z),W+=X<=65535?String.fromCharCode(X):String.fromCharCode(55232+(X>>10),56320+(X&1023)),X=0,A=z+3,z=Z=w.indexOf("%",A);else if($===cq)return null;else{if(z+=3,z<U&&w.charCodeAt(z)===37)continue;return null}}return W+w.slice(A)}var vq={"0":0,"1":1,"2":2,"3":3,"4":4,"5":5,"6":6,"7":7,"8":8,"9":9,a:10,A:10,b:11,B:11,c:12,C:12,d:13,D:13,e:14,E:14,f:15,F:15};function QU(w,z){var U=vq[w];return U===void 0?255:U<<z}YU.exports=iq});var F6=(w,z)=>{let U=z?.length?{}:null;if(U)for(let W of z)U[W.part.charCodeAt(0)]=W;return{part:w,store:null,inert:U,params:null,wildcardStore:null}},ew=(w,z)=>({...w,part:z}),wz=(w)=>({name:w,store:null,inert:null});class u1{root={};history=[];static regex={static:/:.+?(?=\/|$)/,params:/:.+?(?=\/|$)/g,optionalParams:/:.+?\?(?=\/|$)/g};add(w,z,U,{ignoreError:W=!1,ignoreHistory:A=!1}={}){if(typeof z!=="string")throw new TypeError("Route path must be a string");if(z==="")z="/";else if(z[0]!=="/")z=`/${z}`;let X=z[z.length-1]==="*",Z=z.match(u1.regex.optionalParams);if(Z){let G=z.replaceAll("?","");this.add(w,G,U,{ignoreError:W});for(let _=0;_<Z.length;_++){let H=z.replace("/"+Z[_],"");this.add(w,H,U,{ignoreError:!0})}return U}if(Z)z=z.replaceAll("?","");if(this.history.find(([G,_,H])=>G===w&&_===z))return U;if(X||Z&&z.charCodeAt(z.length-1)===63)z=z.slice(0,-1);if(!A)this.history.push([w,z,U]);let $=z.split(u1.regex.static),Q=z.match(u1.regex.params)||[];if($[$.length-1]==="")$.pop();let Y;if(!this.root[w])Y=this.root[w]=F6("/");else Y=this.root[w];let B=0;for(let G=0;G<$.length;++G){let _=$[G];if(G>0){let H=Q[B++].slice(1);if(Y.params===null)Y.params=wz(H);else if(Y.params.name!==H)if(W)return U;else throw new Error(`Cannot create route "${z}" with parameter "${H}" because a route already exists with a different parameter name ("${Y.params.name}") in the same location`);let F=Y.params;if(F.inert===null){Y=F.inert=F6(_);continue}Y=F.inert}for(let H=0;;){if(H===_.length){if(H<Y.part.length){let F=ew(Y,Y.part.slice(H));Object.assign(Y,F6(_,[F]))}break}if(H===Y.part.length){if(Y.inert===null)Y.inert={};let F=Y.inert[_.charCodeAt(H)];if(F){Y=F,_=_.slice(H),H=0;continue}let R=F6(_.slice(H));Y.inert[_.charCodeAt(H)]=R,Y=R;break}if(_[H]!==Y.part[H]){let F=ew(Y,Y.part.slice(H)),R=F6(_.slice(H));Object.assign(Y,F6(Y.part.slice(0,H),[F,R])),Y=R;break}++H}}if(B<Q.length){let G=Q[B].slice(1);if(Y.params===null)Y.params=wz(G);else if(Y.params.name!==G)if(W)return U;else throw new Error(`Cannot create route "${z}" with parameter "${G}" because a route already exists with a different parameter name ("${Y.params.name}") in the same location`);if(Y.params.store===null)Y.params.store=U;return Y.params.store}if(X){if(Y.wildcardStore===null)Y.wildcardStore=U;return Y.wildcardStore}if(Y.store===null)Y.store=U;return Y.store}find(w,z){let U=this.root[w];if(!U)return null;return d5(z,z.length,U,0)}}var d5=(w,z,U,W)=>{let A=U.part,X=A.length,Z=W+X;if(X>1){if(Z>z)return null;if(X<15){for(let $=1,Q=W+1;$<X;++$,++Q)if(A.charCodeAt($)!==w.charCodeAt(Q))return null}else if(w.slice(W,Z)!==A)return null}if(Z===z){if(U.store!==null)return{store:U.store,params:{}};if(U.wildcardStore!==null)return{store:U.wildcardStore,params:{"*":""}};return null}if(U.inert!==null){let $=U.inert[w.charCodeAt(Z)];if($!==void 0){let Q=d5(w,z,$,Z);if(Q!==null)return Q}}if(U.params!==null){let{store:$,name:Q,inert:Y}=U.params,B=w.indexOf("/",Z);if(B!==Z){if(B===-1||B>=z){if($!==null){let G={};return G[Q]=w.substring(Z,z),{store:$,params:G}}}else if(Y!==null){let G=d5(w,z,Y,B);if(G!==null)return G.params[Q]=w.substring(Z,B),G}}}if(U.wildcardStore!==null)return{store:U.wildcardStore,params:{"*":w.substring(Z,z)}};return null};var H2={};J6(H2,{IsUndefined:()=>s0,IsUint8Array:()=>C1,IsSymbol:()=>v5,IsString:()=>E0,IsRegExp:()=>$4,IsObject:()=>P0,IsNumber:()=>f2,IsNull:()=>i5,IsIterator:()=>c5,IsFunction:()=>y5,IsDate:()=>B6,IsBoolean:()=>R1,IsBigInt:()=>Z4,IsAsyncIterator:()=>h5,IsArray:()=>u0,HasPropertyKey:()=>u4});function u4(w,z){return z in w}function h5(w){return P0(w)&&!u0(w)&&!C1(w)&&Symbol.asyncIterator in w}function u0(w){return Array.isArray(w)}function Z4(w){return typeof w==="bigint"}function R1(w){return typeof w==="boolean"}function B6(w){return w instanceof globalThis.Date}function y5(w){return typeof w==="function"}function c5(w){return P0(w)&&!u0(w)&&!C1(w)&&Symbol.iterator in w}function i5(w){return w===null}function f2(w){return typeof w==="number"}function P0(w){return typeof w==="object"&&w!==null}function $4(w){return w instanceof globalThis.RegExp}function E0(w){return typeof w==="string"}function v5(w){return typeof w==="symbol"}function C1(w){return w instanceof globalThis.Uint8Array}function s0(w){return w===void 0}function BA(w){return w.map((z)=>m4(z))}function MA(w){return new Date(w.getTime())}function qA(w){return new Uint8Array(w)}function HA(w){return new RegExp(w.source,w.flags)}function GA(w){let z={};for(let U of Object.getOwnPropertyNames(w))z[U]=m4(w[U]);for(let U of Object.getOwnPropertySymbols(w))z[U]=m4(w[U]);return z}function m4(w){return u0(w)?BA(w):B6(w)?MA(w):C1(w)?qA(w):$4(w)?HA(w):P0(w)?GA(w):w}function k0(w){return m4(w)}function zz(w,z){return z===void 0?k0(w):k0({...z,...w})}function t4(w){return s(w)&&Symbol.asyncIterator in w}function p4(w){return s(w)&&Symbol.iterator in w}function n5(w){return s(w)&&(Object.getPrototypeOf(w)===Object.prototype||Object.getPrototypeOf(w)===null)}function o4(w){return w instanceof Promise}function G2(w){return w instanceof Date&&Number.isFinite(w.getTime())}function Uz(w){return w instanceof globalThis.Map}function Wz(w){return w instanceof globalThis.Set}function d2(w){return ArrayBuffer.isView(w)}function j6(w){return w instanceof globalThis.Uint8Array}function v(w,z){return z in w}function s(w){return w!==null&&typeof w==="object"}function n(w){return Array.isArray(w)&&!ArrayBuffer.isView(w)}function T0(w){return w===void 0}function K1(w){return w===null}function G1(w){return typeof w==="boolean"}function d(w){return typeof w==="number"}function l4(w){return Number.isInteger(w)}function A2(w){return typeof w==="bigint"}function $0(w){return typeof w==="string"}function m1(w){return typeof w==="function"}function F1(w){return typeof w==="symbol"}function V2(w){return A2(w)||G1(w)||K1(w)||d(w)||$0(w)||F1(w)||T0(w)}var V0;(function(w){w.InstanceMode="default",w.ExactOptionalPropertyTypes=!1,w.AllowArrayObject=!1,w.AllowNaN=!1,w.AllowNullVoid=!1;function z(Z,$){return w.ExactOptionalPropertyTypes?$ in Z:Z[$]!==void 0}w.IsExactOptionalProperty=z;function U(Z){let $=s(Z);return w.AllowArrayObject?$:$&&!n(Z)}w.IsObjectLike=U;function W(Z){return U(Z)&&!(Z instanceof Date)&&!(Z instanceof Uint8Array)}w.IsRecordLike=W;function A(Z){return w.AllowNaN?d(Z):Number.isFinite(Z)}w.IsNumberLike=A;function X(Z){let $=T0(Z);return w.AllowNullVoid?$||Z===null:$}w.IsVoidLike=X})(V0||(V0={}));function LA(w){return globalThis.Object.freeze(w).map((z)=>Q4(z))}function NA(w){return w}function SA(w){return w}function _A(w){return w}function DA(w){let z={};for(let U of Object.getOwnPropertyNames(w))z[U]=Q4(w[U]);for(let U of Object.getOwnPropertySymbols(w))z[U]=Q4(w[U]);return globalThis.Object.freeze(z)}function Q4(w){return u0(w)?LA(w):B6(w)?NA(w):C1(w)?SA(w):$4(w)?_A(w):P0(w)?DA(w):w}function P(w,z){let U=z!==void 0?{...z,...w}:w;switch(V0.InstanceMode){case"freeze":return Q4(U);case"clone":return k0(U);default:return U}}class y extends Error{constructor(w){super(w)}}var F0=Symbol.for("TypeBox.Transform"),w1=Symbol.for("TypeBox.Readonly"),X2=Symbol.for("TypeBox.Optional"),h2=Symbol.for("TypeBox.Hint"),N=Symbol.for("TypeBox.Kind");function s4(w){return P0(w)&&w[w1]==="Readonly"}function y2(w){return P0(w)&&w[X2]==="Optional"}function u5(w){return Q0(w,"Any")}function j1(w){return Q0(w,"Array")}function Y4(w){return Q0(w,"AsyncIterator")}function m5(w){return Q0(w,"BigInt")}function t5(w){return Q0(w,"Boolean")}function S2(w){return Q0(w,"Computed")}function J4(w){return Q0(w,"Constructor")}function PA(w){return Q0(w,"Date")}function B4(w){return Q0(w,"Function")}function M6(w){return Q0(w,"Integer")}function m0(w){return Q0(w,"Intersect")}function M4(w){return Q0(w,"Iterator")}function Q0(w,z){return P0(w)&&N in w&&w[N]===z}function r4(w){return R1(w)||f2(w)||E0(w)}function E1(w){return Q0(w,"Literal")}function k2(w){return Q0(w,"MappedKey")}function g0(w){return Q0(w,"MappedResult")}function t1(w){return Q0(w,"Never")}function OA(w){return Q0(w,"Not")}function bA(w){return Q0(w,"Null")}function q6(w){return Q0(w,"Number")}function r0(w){return Q0(w,"Object")}function q4(w){return Q0(w,"Promise")}function p5(w){return Q0(w,"Record")}function h0(w){return Q0(w,"Ref")}function o5(w){return Q0(w,"RegExp")}function H4(w){return Q0(w,"String")}function RA(w){return Q0(w,"Symbol")}function T2(w){return Q0(w,"TemplateLiteral")}function CA(w){return Q0(w,"This")}function S0(w){return P0(w)&&F0 in w}function z1(w){return Q0(w,"Tuple")}function G4(w){return Q0(w,"Undefined")}function q0(w){return Q0(w,"Union")}function KA(w){return Q0(w,"Uint8Array")}function FA(w){return Q0(w,"Unknown")}function jA(w){return Q0(w,"Unsafe")}function EA(w){return Q0(w,"Void")}function p1(w){return P0(w)&&N in w&&E0(w[N])}function d0(w){return u5(w)||j1(w)||t5(w)||m5(w)||Y4(w)||S2(w)||J4(w)||PA(w)||B4(w)||M6(w)||m0(w)||M4(w)||E1(w)||k2(w)||g0(w)||t1(w)||OA(w)||bA(w)||q6(w)||r0(w)||q4(w)||p5(w)||h0(w)||o5(w)||H4(w)||RA(w)||T2(w)||CA(w)||z1(w)||G4(w)||q0(w)||KA(w)||FA(w)||jA(w)||EA(w)||p1(w)}var q={};J6(q,{TypeGuardUnknownTypeError:()=>Xz,IsVoid:()=>mz,IsUnsafe:()=>uz,IsUnknown:()=>nz,IsUnionLiteral:()=>hA,IsUnion:()=>r5,IsUndefined:()=>iz,IsUint8Array:()=>vz,IsTuple:()=>cz,IsTransform:()=>yz,IsThis:()=>hz,IsTemplateLiteral:()=>dz,IsSymbol:()=>fz,IsString:()=>gz,IsSchema:()=>f0,IsRegExp:()=>Tz,IsRef:()=>kz,IsRecursive:()=>dA,IsRecord:()=>Vz,IsReadonly:()=>kA,IsProperties:()=>a4,IsPromise:()=>xz,IsOptional:()=>TA,IsObject:()=>Iz,IsNumber:()=>Ez,IsNull:()=>jz,IsNot:()=>Fz,IsNever:()=>Kz,IsMappedResult:()=>Cz,IsMappedKey:()=>Rz,IsLiteralValue:()=>bz,IsLiteralString:()=>Pz,IsLiteralNumber:()=>Oz,IsLiteralBoolean:()=>fA,IsLiteral:()=>N4,IsKindOf:()=>w0,IsKind:()=>tz,IsIterator:()=>Dz,IsIntersect:()=>_z,IsInteger:()=>Sz,IsImport:()=>gA,IsFunction:()=>Nz,IsDate:()=>Lz,IsConstructor:()=>Gz,IsComputed:()=>Hz,IsBoolean:()=>qz,IsBigInt:()=>Mz,IsAsyncIterator:()=>Bz,IsArray:()=>Jz,IsAny:()=>Yz});class Xz extends y{}var IA=["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 Zz(w){try{return new RegExp(w),!0}catch{return!1}}function l5(w){if(!E0(w))return!1;for(let z=0;z<w.length;z++){let U=w.charCodeAt(z);if(U>=7&&U<=13||U===27||U===127)return!1}return!0}function $z(w){return s5(w)||f0(w)}function L4(w){return s0(w)||Z4(w)}function I0(w){return s0(w)||f2(w)}function s5(w){return s0(w)||R1(w)}function O0(w){return s0(w)||E0(w)}function xA(w){return s0(w)||E0(w)&&l5(w)&&Zz(w)}function VA(w){return s0(w)||E0(w)&&l5(w)}function Qz(w){return s0(w)||f0(w)}function kA(w){return P0(w)&&w[w1]==="Readonly"}function TA(w){return P0(w)&&w[X2]==="Optional"}function Yz(w){return w0(w,"Any")&&O0(w.$id)}function Jz(w){return w0(w,"Array")&&w.type==="array"&&O0(w.$id)&&f0(w.items)&&I0(w.minItems)&&I0(w.maxItems)&&s5(w.uniqueItems)&&Qz(w.contains)&&I0(w.minContains)&&I0(w.maxContains)}function Bz(w){return w0(w,"AsyncIterator")&&w.type==="AsyncIterator"&&O0(w.$id)&&f0(w.items)}function Mz(w){return w0(w,"BigInt")&&w.type==="bigint"&&O0(w.$id)&&L4(w.exclusiveMaximum)&&L4(w.exclusiveMinimum)&&L4(w.maximum)&&L4(w.minimum)&&L4(w.multipleOf)}function qz(w){return w0(w,"Boolean")&&w.type==="boolean"&&O0(w.$id)}function Hz(w){return w0(w,"Computed")&&E0(w.target)&&u0(w.parameters)&&w.parameters.every((z)=>f0(z))}function Gz(w){return w0(w,"Constructor")&&w.type==="Constructor"&&O0(w.$id)&&u0(w.parameters)&&w.parameters.every((z)=>f0(z))&&f0(w.returns)}function Lz(w){return w0(w,"Date")&&w.type==="Date"&&O0(w.$id)&&I0(w.exclusiveMaximumTimestamp)&&I0(w.exclusiveMinimumTimestamp)&&I0(w.maximumTimestamp)&&I0(w.minimumTimestamp)&&I0(w.multipleOfTimestamp)}function Nz(w){return w0(w,"Function")&&w.type==="Function"&&O0(w.$id)&&u0(w.parameters)&&w.parameters.every((z)=>f0(z))&&f0(w.returns)}function gA(w){return w0(w,"Import")&&u4(w,"$defs")&&P0(w.$defs)&&a4(w.$defs)&&u4(w,"$ref")&&E0(w.$ref)&&w.$ref in w.$defs}function Sz(w){return w0(w,"Integer")&&w.type==="integer"&&O0(w.$id)&&I0(w.exclusiveMaximum)&&I0(w.exclusiveMinimum)&&I0(w.maximum)&&I0(w.minimum)&&I0(w.multipleOf)}function a4(w){return P0(w)&&Object.entries(w).every(([z,U])=>l5(z)&&f0(U))}function _z(w){return w0(w,"Intersect")&&(E0(w.type)&&w.type!=="object"?!1:!0)&&u0(w.allOf)&&w.allOf.every((z)=>f0(z)&&!yz(z))&&O0(w.type)&&(s5(w.unevaluatedProperties)||Qz(w.unevaluatedProperties))&&O0(w.$id)}function Dz(w){return w0(w,"Iterator")&&w.type==="Iterator"&&O0(w.$id)&&f0(w.items)}function w0(w,z){return P0(w)&&N in w&&w[N]===z}function Pz(w){return N4(w)&&E0(w.const)}function Oz(w){return N4(w)&&f2(w.const)}function fA(w){return N4(w)&&R1(w.const)}function N4(w){return w0(w,"Literal")&&O0(w.$id)&&bz(w.const)}function bz(w){return R1(w)||f2(w)||E0(w)}function Rz(w){return w0(w,"MappedKey")&&u0(w.keys)&&w.keys.every((z)=>f2(z)||E0(z))}function Cz(w){return w0(w,"MappedResult")&&a4(w.properties)}function Kz(w){return w0(w,"Never")&&P0(w.not)&&Object.getOwnPropertyNames(w.not).length===0}function Fz(w){return w0(w,"Not")&&f0(w.not)}function jz(w){return w0(w,"Null")&&w.type==="null"&&O0(w.$id)}function Ez(w){return w0(w,"Number")&&w.type==="number"&&O0(w.$id)&&I0(w.exclusiveMaximum)&&I0(w.exclusiveMinimum)&&I0(w.maximum)&&I0(w.minimum)&&I0(w.multipleOf)}function Iz(w){return w0(w,"Object")&&w.type==="object"&&O0(w.$id)&&a4(w.properties)&&$z(w.additionalProperties)&&I0(w.minProperties)&&I0(w.maxProperties)}function xz(w){return w0(w,"Promise")&&w.type==="Promise"&&O0(w.$id)&&f0(w.item)}function Vz(w){return w0(w,"Record")&&w.type==="object"&&O0(w.$id)&&$z(w.additionalProperties)&&P0(w.patternProperties)&&((z)=>{let U=Object.getOwnPropertyNames(z.patternProperties);return U.length===1&&Zz(U[0])&&P0(z.patternProperties)&&f0(z.patternProperties[U[0]])})(w)}function dA(w){return P0(w)&&h2 in w&&w[h2]==="Recursive"}function kz(w){return w0(w,"Ref")&&O0(w.$id)&&E0(w.$ref)}function Tz(w){return w0(w,"RegExp")&&O0(w.$id)&&E0(w.source)&&E0(w.flags)&&I0(w.maxLength)&&I0(w.minLength)}function gz(w){return w0(w,"String")&&w.type==="string"&&O0(w.$id)&&I0(w.minLength)&&I0(w.maxLength)&&xA(w.pattern)&&VA(w.format)}function fz(w){return w0(w,"Symbol")&&w.type==="symbol"&&O0(w.$id)}function dz(w){return w0(w,"TemplateLiteral")&&w.type==="string"&&E0(w.pattern)&&w.pattern[0]==="^"&&w.pattern[w.pattern.length-1]==="$"}function hz(w){return w0(w,"This")&&O0(w.$id)&&E0(w.$ref)}function yz(w){return P0(w)&&F0 in w}function cz(w){return w0(w,"Tuple")&&w.type==="array"&&O0(w.$id)&&f2(w.minItems)&&f2(w.maxItems)&&w.minItems===w.maxItems&&(s0(w.items)&&s0(w.additionalItems)&&w.minItems===0||u0(w.items)&&w.items.every((z)=>f0(z)))}function iz(w){return w0(w,"Undefined")&&w.type==="undefined"&&O0(w.$id)}function hA(w){return r5(w)&&w.anyOf.every((z)=>Pz(z)||Oz(z))}function r5(w){return w0(w,"Union")&&O0(w.$id)&&P0(w)&&u0(w.anyOf)&&w.anyOf.every((z)=>f0(z))}function vz(w){return w0(w,"Uint8Array")&&w.type==="Uint8Array"&&O0(w.$id)&&I0(w.minByteLength)&&I0(w.maxByteLength)}function nz(w){return w0(w,"Unknown")&&O0(w.$id)}function uz(w){return w0(w,"Unsafe")}function mz(w){return w0(w,"Void")&&w.type==="void"&&O0(w.$id)}function tz(w){return P0(w)&&N in w&&E0(w[N])&&!IA.includes(w[N])}function f0(w){return P0(w)&&(Yz(w)||Jz(w)||qz(w)||Mz(w)||Bz(w)||Hz(w)||Gz(w)||Lz(w)||Nz(w)||Sz(w)||_z(w)||Dz(w)||N4(w)||Rz(w)||Cz(w)||Kz(w)||Fz(w)||jz(w)||Ez(w)||Iz(w)||xz(w)||Vz(w)||kz(w)||Tz(w)||gz(w)||fz(w)||dz(w)||hz(w)||cz(w)||iz(w)||r5(w)||vz(w)||nz(w)||uz(w)||mz(w)||tz(w))}var pz="(true|false)",e4="(0|[1-9][0-9]*)",oz="(.*)";var I1="^(0|[1-9][0-9]*)$",x1="^(.*)$",lz="^(?!.*)$";var b0={};J6(b0,{Set:()=>nA,Has:()=>vA,Get:()=>uA,Entries:()=>yA,Delete:()=>iA,Clear:()=>cA});var E6=new Map;function yA(){return new Map(E6)}function cA(){return E6.clear()}function iA(w){return E6.delete(w)}function vA(w){return E6.has(w)}function nA(w,z){E6.set(w,z)}function uA(w){return E6.get(w)}var y0={};J6(y0,{Set:()=>lA,Has:()=>oA,Get:()=>sA,Entries:()=>mA,Delete:()=>pA,Clear:()=>tA});var I6=new Map;function mA(){return new Map(I6)}function tA(){return I6.clear()}function pA(w){return I6.delete(w)}function oA(w){return I6.has(w)}function lA(w,z){I6.set(w,z)}function sA(w){return I6.get(w)}function sz(w,z){return w.includes(z)}function rz(w){return[...new Set(w)]}function rA(w,z){return w.filter((U)=>z.includes(U))}function aA(w,z){return w.reduce((U,W)=>{return rA(U,W)},z)}function az(w){return w.length===1?w[0]:w.length>1?aA(w.slice(1),w[0]):[]}function ez(w){let z=[];for(let U of w)z.push(...U);return z}function o1(w){return P({[N]:"Any"},w)}function x6(w,z){return P({[N]:"Array",type:"array",items:w},z)}function V6(w,z){return P({[N]:"AsyncIterator",type:"AsyncIterator",items:w},z)}function N0(w,z,U){return P({[N]:"Computed",target:w,parameters:z},U)}function eA(w,z){let{[z]:U,...W}=w;return W}function c0(w,z){return z.reduce((U,W)=>eA(U,W),w)}function H0(w){return P({[N]:"Never",not:{}},w)}function Y0(w){return P({[N]:"MappedResult",properties:w})}function k6(w,z,U){return P({[N]:"Constructor",type:"Constructor",parameters:w,returns:z},U)}function L1(w,z,U){return P({[N]:"Function",type:"Function",parameters:w,returns:z},U)}function S4(w,z){return P({[N]:"Union",anyOf:w},z)}function wX(w){return w.some((z)=>y2(z))}function w9(w){return w.map((z)=>y2(z)?zX(z):z)}function zX(w){return c0(w,[X2])}function UX(w,z){return wX(w)?_2(S4(w9(w),z)):S4(w9(w),z)}function N1(w,z){return w.length===1?P(w[0],z):w.length===0?H0(z):UX(w,z)}function G0(w,z){return w.length===0?H0(z):w.length===1?P(w[0],z):S4(w,z)}class a5 extends y{}function WX(w){return w.replace(/\\\$/g,"$").replace(/\\\*/g,"*").replace(/\\\^/g,"^").replace(/\\\|/g,"|").replace(/\\\(/g,"(").replace(/\\\)/g,")")}function e5(w,z,U){return w[z]===U&&w.charCodeAt(z-1)!==92}function V1(w,z){return e5(w,z,"(")}function _4(w,z){return e5(w,z,")")}function z9(w,z){return e5(w,z,"|")}function AX(w){if(!(V1(w,0)&&_4(w,w.length-1)))return!1;let z=0;for(let U=0;U<w.length;U++){if(V1(w,U))z+=1;if(_4(w,U))z-=1;if(z===0&&U!==w.length-1)return!1}return!0}function XX(w){return w.slice(1,w.length-1)}function ZX(w){let z=0;for(let U=0;U<w.length;U++){if(V1(w,U))z+=1;if(_4(w,U))z-=1;if(z9(w,U)&&z===0)return!0}return!1}function $X(w){for(let z=0;z<w.length;z++)if(V1(w,z))return!0;return!1}function QX(w){let[z,U]=[0,0],W=[];for(let X=0;X<w.length;X++){if(V1(w,X))z+=1;if(_4(w,X))z-=1;if(z9(w,X)&&z===0){let Z=w.slice(U,X);if(Z.length>0)W.push(T6(Z));U=X+1}}let A=w.slice(U);if(A.length>0)W.push(T6(A));if(W.length===0)return{type:"const",const:""};if(W.length===1)return W[0];return{type:"or",expr:W}}function YX(w){function z(A,X){if(!V1(A,X))throw new a5("TemplateLiteralParser: Index must point to open parens");let Z=0;for(let $=X;$<A.length;$++){if(V1(A,$))Z+=1;if(_4(A,$))Z-=1;if(Z===0)return[X,$]}throw new a5("TemplateLiteralParser: Unclosed group parens in expression")}function U(A,X){for(let Z=X;Z<A.length;Z++)if(V1(A,Z))return[X,Z];return[X,A.length]}let W=[];for(let A=0;A<w.length;A++)if(V1(w,A)){let[X,Z]=z(w,A),$=w.slice(X,Z+1);W.push(T6($)),A=Z}else{let[X,Z]=U(w,A),$=w.slice(X,Z);if($.length>0)W.push(T6($));A=Z-1}return W.length===0?{type:"const",const:""}:W.length===1?W[0]:{type:"and",expr:W}}function T6(w){return AX(w)?T6(XX(w)):ZX(w)?QX(w):$X(w)?YX(w):{type:"const",const:WX(w)}}function g6(w){return T6(w.slice(1,w.length-1))}class U9 extends y{}function JX(w){return w.type==="or"&&w.expr.length===2&&w.expr[0].type==="const"&&w.expr[0].const==="0"&&w.expr[1].type==="const"&&w.expr[1].const==="[1-9][0-9]*"}function BX(w){return w.type==="or"&&w.expr.length===2&&w.expr[0].type==="const"&&w.expr[0].const==="true"&&w.expr[1].type==="const"&&w.expr[1].const==="false"}function MX(w){return w.type==="const"&&w.const===".*"}function H6(w){return JX(w)||MX(w)?!1:BX(w)?!0:w.type==="and"?w.expr.every((z)=>H6(z)):w.type==="or"?w.expr.every((z)=>H6(z)):w.type==="const"?!0:(()=>{throw new U9("Unknown expression type")})()}function w8(w){let z=g6(w.pattern);return H6(z)}class W9 extends y{}function*A9(w){if(w.length===1)return yield*w[0];for(let z of w[0])for(let U of A9(w.slice(1)))yield`${z}${U}`}function*qX(w){return yield*A9(w.expr.map((z)=>[...D4(z)]))}function*HX(w){for(let z of w.expr)yield*D4(z)}function*GX(w){return yield w.const}function*D4(w){return w.type==="and"?yield*qX(w):w.type==="or"?yield*HX(w):w.type==="const"?yield*GX(w):(()=>{throw new W9("Unknown expression")})()}function f6(w){let z=g6(w.pattern);return H6(z)?[...D4(z)]:[]}function X0(w,z){return P({[N]:"Literal",const:w,type:typeof w},z)}function z8(w){return P({[N]:"Boolean",type:"boolean"},w)}function d6(w){return P({[N]:"BigInt",type:"bigint"},w)}function S1(w){return P({[N]:"Number",type:"number"},w)}function c2(w){return P({[N]:"String",type:"string"},w)}function*LX(w){let z=w.trim().replace(/"|'/g,"");return z==="boolean"?yield z8():z==="number"?yield S1():z==="bigint"?yield d6():z==="string"?yield c2():yield(()=>{let U=z.split("|").map((W)=>X0(W.trim()));return U.length===0?H0():U.length===1?U[0]:N1(U)})()}function*NX(w){if(w[1]!=="{"){let z=X0("$"),U=ww(w.slice(1));return yield*[z,...U]}for(let z=2;z<w.length;z++)if(w[z]==="}"){let U=LX(w.slice(2,z)),W=ww(w.slice(z+1));return yield*[...U,...W]}yield X0(w)}function*ww(w){for(let z=0;z<w.length;z++)if(w[z]==="$"){let U=X0(w.slice(0,z)),W=NX(w.slice(z));return yield*[U,...W]}yield X0(w)}function X9(w){return[...ww(w)]}class Z9 extends y{}function SX(w){return w.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function $9(w,z){return T2(w)?w.pattern.slice(1,w.pattern.length-1):q0(w)?`(${w.anyOf.map((U)=>$9(U,z)).join("|")})`:q6(w)?`${z}${e4}`:M6(w)?`${z}${e4}`:m5(w)?`${z}${e4}`:H4(w)?`${z}${oz}`:E1(w)?`${z}${SX(w.const.toString())}`:t5(w)?`${z}${pz}`:(()=>{throw new Z9(`Unexpected Kind '${w[N]}'`)})()}function zw(w){return`^${w.map((z)=>$9(z,"")).join("")}$`}function G6(w){let U=f6(w).map((W)=>X0(W));return N1(U)}function U8(w,z){let U=E0(w)?zw(X9(w)):zw(w);return P({[N]:"TemplateLiteral",type:"string",pattern:U},z)}function _X(w){return f6(w).map((U)=>U.toString())}function DX(w){let z=[];for(let U of w)z.push(...D2(U));return z}function PX(w){return[w.toString()]}function D2(w){return[...new Set(T2(w)?_X(w):q0(w)?DX(w.anyOf):E1(w)?PX(w.const):q6(w)?["[number]"]:M6(w)?["[number]"]:[])]}function OX(w,z,U){let W={};for(let A of Object.getOwnPropertyNames(z))W[A]=l1(w,D2(z[A]),U);return W}function bX(w,z,U){return OX(w,z.properties,U)}function Q9(w,z,U){let W=bX(w,z,U);return Y0(W)}function J9(w,z){return w.map((U)=>B9(U,z))}function RX(w){return w.filter((z)=>!t1(z))}function CX(w,z){return W8(RX(J9(w,z)))}function KX(w){return w.some((z)=>t1(z))?[]:w}function FX(w,z){return N1(KX(J9(w,z)))}function jX(w,z){return z in w?w[z]:z==="[number]"?N1(w):H0()}function EX(w,z){return z==="[number]"?w:H0()}function IX(w,z){return z in w?w[z]:H0()}function B9(w,z){return m0(w)?CX(w.allOf,z):q0(w)?FX(w.anyOf,z):z1(w)?jX(w.items??[],z):j1(w)?EX(w.items,z):r0(w)?IX(w.properties,z):H0()}function P4(w,z){return z.map((U)=>B9(w,U))}function Y9(w,z){return N1(P4(w,z))}function l1(w,z,U){if(h0(w)||h0(z)){if(!d0(w)||!d0(z))throw new y("Index types using Ref parameters require both Type and Key to be of TSchema");return N0("Index",[w,z])}if(g0(z))return Q9(w,z,U);if(k2(z))return M9(w,z,U);return P(d0(z)?Y9(w,D2(z)):Y9(w,z),U)}function xX(w,z,U){return{[z]:l1(w,[z],k0(U))}}function VX(w,z,U){return z.reduce((W,A)=>{return{...W,...xX(w,A,U)}},{})}function kX(w,z,U){return VX(w,z.keys,U)}function M9(w,z,U){let W=kX(w,z,U);return Y0(W)}function h6(w,z){return P({[N]:"Iterator",type:"Iterator",items:w},z)}function TX(w){let z=[];for(let U in w)if(!y2(w[U]))z.push(U);return z}function gX(w,z){let U=TX(w),W=U.length>0?{[N]:"Object",type:"object",properties:w,required:U}:{[N]:"Object",type:"object",properties:w};return P(W,z)}var _0=gX;function A8(w,z){return P({[N]:"Promise",type:"Promise",item:w},z)}function fX(w){return P(c0(w,[w1]))}function dX(w){return P({...w,[w1]:"Readonly"})}function hX(w,z){return z===!1?fX(w):dX(w)}function i2(w,z){let U=z??!0;return g0(w)?q9(w,U):hX(w,U)}function yX(w,z){let U={};for(let W of globalThis.Object.getOwnPropertyNames(w))U[W]=i2(w[W],z);return U}function cX(w,z){return yX(w.properties,z)}function q9(w,z){let U=cX(w,z);return Y0(U)}function v2(w,z){return P(w.length>0?{[N]:"Tuple",type:"array",items:w,additionalItems:!1,minItems:w.length,maxItems:w.length}:{[N]:"Tuple",type:"array",minItems:w.length,maxItems:w.length},z)}function H9(w,z){return w in z?n2(w,z[w]):Y0(z)}function iX(w){return{[w]:X0(w)}}function vX(w){let z={};for(let U of w)z[U]=X0(U);return z}function nX(w,z){return sz(z,w)?iX(w):vX(z)}function uX(w,z){let U=nX(w,z);return H9(w,U)}function O4(w,z){return z.map((U)=>n2(w,U))}function mX(w,z){let U={};for(let W of globalThis.Object.getOwnPropertyNames(z))U[W]=n2(w,z[W]);return U}function n2(w,z){let U={...z};return y2(z)?_2(n2(w,c0(z,[X2]))):s4(z)?i2(n2(w,c0(z,[w1]))):g0(z)?H9(w,z.properties):k2(z)?uX(w,z.keys):J4(z)?k6(O4(w,z.parameters),n2(w,z.returns),U):B4(z)?L1(O4(w,z.parameters),n2(w,z.returns),U):Y4(z)?V6(n2(w,z.items),U):M4(z)?h6(n2(w,z.items),U):m0(z)?Z2(O4(w,z.allOf),U):q0(z)?G0(O4(w,z.anyOf),U):z1(z)?v2(O4(w,z.items??[]),U):r0(z)?_0(mX(w,z.properties),U):j1(z)?x6(n2(w,z.items),U):q4(z)?A8(n2(w,z.item),U):z}function tX(w,z){let U={};for(let W of w)U[W]=n2(W,z);return U}function G9(w,z,U){let W=d0(w)?D2(w):w,A=z({[N]:"MappedKey",keys:W}),X=tX(W,A);return _0(X,U)}function pX(w){return P(c0(w,[X2]))}function oX(w){return P({...w,[X2]:"Optional"})}function lX(w,z){return z===!1?pX(w):oX(w)}function _2(w,z){let U=z??!0;return g0(w)?L9(w,U):lX(w,U)}function sX(w,z){let U={};for(let W of globalThis.Object.getOwnPropertyNames(w))U[W]=_2(w[W],z);return U}function rX(w,z){return sX(w.properties,z)}function L9(w,z){let U=rX(w,z);return Y0(U)}function b4(w,z={}){let U=w.every((A)=>r0(A)),W=d0(z.unevaluatedProperties)?{unevaluatedProperties:z.unevaluatedProperties}:{};return P(z.unevaluatedProperties===!1||d0(z.unevaluatedProperties)||U?{...W,[N]:"Intersect",type:"object",allOf:w}:{...W,[N]:"Intersect",allOf:w},z)}function aX(w){return w.every((z)=>y2(z))}function eX(w){return c0(w,[X2])}function N9(w){return w.map((z)=>y2(z)?eX(z):z)}function wZ(w,z){return aX(w)?_2(b4(N9(w),z)):b4(N9(w),z)}function W8(w,z={}){if(w.length===1)return P(w[0],z);if(w.length===0)return H0(z);if(w.some((U)=>S0(U)))throw new Error("Cannot intersect transform types");return wZ(w,z)}function Z2(w,z){if(w.length===1)return P(w[0],z);if(w.length===0)return H0(z);if(w.some((U)=>S0(U)))throw new Error("Cannot intersect transform types");return b4(w,z)}function P2(...w){let[z,U]=typeof w[0]==="string"?[w[0],w[1]]:[w[0].$id,w[1]];if(typeof z!=="string")throw new y("Ref: $ref must be a string");return P({[N]:"Ref",$ref:z},U)}function zZ(w,z){return N0("Awaited",[N0(w,z)])}function UZ(w){return N0("Awaited",[P2(w)])}function WZ(w){return Z2(S9(w))}function AZ(w){return G0(S9(w))}function XZ(w){return y6(w)}function S9(w){return w.map((z)=>y6(z))}function y6(w,z){return P(S2(w)?zZ(w.target,w.parameters):m0(w)?WZ(w.allOf):q0(w)?AZ(w.anyOf):q4(w)?XZ(w.item):h0(w)?UZ(w.$ref):w,z)}function _9(w){let z=[];for(let U of w)z.push(O2(U));return z}function ZZ(w){let z=_9(w);return ez(z)}function $Z(w){let z=_9(w);return az(z)}function QZ(w){return w.map((z,U)=>U.toString())}function YZ(w){return["[number]"]}function JZ(w){return globalThis.Object.getOwnPropertyNames(w)}function BZ(w){if(!Uw)return[];return globalThis.Object.getOwnPropertyNames(w).map((U)=>{return U[0]==="^"&&U[U.length-1]==="$"?U.slice(1,U.length-1):U})}function O2(w){return m0(w)?ZZ(w.allOf):q0(w)?$Z(w.anyOf):z1(w)?QZ(w.items??[]):j1(w)?YZ(w.items):r0(w)?JZ(w.properties):p5(w)?BZ(w.patternProperties):[]}var Uw=!1;function k1(w){Uw=!0;let z=O2(w);return Uw=!1,`^(${z.map((W)=>`(${W})`).join("|")})$`}function MZ(w,z){return N0("KeyOf",[N0(w,z)])}function qZ(w){return N0("KeyOf",[P2(w)])}function HZ(w,z){let U=O2(w),W=GZ(U),A=N1(W);return P(A,z)}function GZ(w){return w.map((z)=>z==="[number]"?S1():X0(z))}function c6(w,z){return S2(w)?MZ(w.target,w.parameters):h0(w)?qZ(w.$ref):g0(w)?D9(w,z):HZ(w,z)}function LZ(w,z){let U={};for(let W of globalThis.Object.getOwnPropertyNames(w))U[W]=c6(w[W],k0(z));return U}function NZ(w,z){return LZ(w.properties,z)}function D9(w,z){let U=NZ(w,z);return Y0(U)}function X8(w){let z=O2(w),U=P4(w,z);return z.map((W,A)=>[z[A],U[A]])}function SZ(w){let z=[];for(let U of w)z.push(...O2(U));return rz(z)}function _Z(w){return w.filter((z)=>!t1(z))}function DZ(w,z){let U=[];for(let W of w)U.push(...P4(W,[z]));return _Z(U)}function PZ(w,z){let U={};for(let W of z)U[W]=W8(DZ(w,W));return U}function P9(w,z){let U=SZ(w),W=PZ(w,U);return _0(W,z)}function Z8(w){return P({[N]:"Date",type:"Date"},w)}function $8(w){return P({[N]:"Null",type:"null"},w)}function Q8(w){return P({[N]:"Symbol",type:"symbol"},w)}function Y8(w){return P({[N]:"Undefined",type:"undefined"},w)}function J8(w){return P({[N]:"Uint8Array",type:"Uint8Array"},w)}function T1(w){return P({[N]:"Unknown"},w)}function OZ(w){return w.map((z)=>Ww(z,!1))}function bZ(w){let z={};for(let U of globalThis.Object.getOwnPropertyNames(w))z[U]=i2(Ww(w[U],!1));return z}function B8(w,z){return z===!0?w:i2(w)}function Ww(w,z){return h5(w)?B8(o1(),z):c5(w)?B8(o1(),z):u0(w)?i2(v2(OZ(w))):C1(w)?J8():B6(w)?Z8():P0(w)?B8(_0(bZ(w)),z):y5(w)?B8(L1([],T1()),z):s0(w)?Y8():i5(w)?$8():v5(w)?Q8():Z4(w)?d6():f2(w)?X0(w):R1(w)?X0(w):E0(w)?X0(w):_0({})}function O9(w,z){return P(Ww(w,!0),z)}function b9(w,z){return v2(w.parameters,z)}function R9(w,z){if(s0(w))throw new Error("Enum undefined or empty");let U=globalThis.Object.getOwnPropertyNames(w).filter((X)=>isNaN(X)).map((X)=>w[X]),A=[...new Set(U)].map((X)=>X0(X));return G0(A,{...z,[h2]:"Enum"})}class E9 extends y{}var D;(function(w){w[w.Union=0]="Union",w[w.True=1]="True",w[w.False=2]="False"})(D||(D={}));function u2(w){return w===D.False?w:D.True}function i6(w){throw new E9(w)}function t0(w){return q.IsNever(w)||q.IsIntersect(w)||q.IsUnion(w)||q.IsUnknown(w)||q.IsAny(w)}function p0(w,z){return q.IsNever(z)?V9(w,z):q.IsIntersect(z)?M8(w,z):q.IsUnion(z)?Qw(w,z):q.IsUnknown(z)?f9(w,z):q.IsAny(z)?$w(w,z):i6("StructuralRight")}function $w(w,z){return D.True}function RZ(w,z){return q.IsIntersect(z)?M8(w,z):q.IsUnion(z)&&z.anyOf.some((U)=>q.IsAny(U)||q.IsUnknown(U))?D.True:q.IsUnion(z)?D.Union:q.IsUnknown(z)?D.True:q.IsAny(z)?D.True:D.Union}function CZ(w,z){return q.IsUnknown(w)?D.False:q.IsAny(w)?D.Union:q.IsNever(w)?D.True:D.False}function KZ(w,z){return q.IsObject(z)&&q8(z)?D.True:t0(z)?p0(w,z):!q.IsArray(z)?D.False:u2(R0(w.items,z.items))}function FZ(w,z){return t0(z)?p0(w,z):!q.IsAsyncIterator(z)?D.False:u2(R0(w.items,z.items))}function jZ(w,z){return t0(z)?p0(w,z):q.IsObject(z)?$2(w,z):q.IsRecord(z)?m2(w,z):q.IsBigInt(z)?D.True:D.False}function I9(w,z){return q.IsLiteralBoolean(w)?D.True:q.IsBoolean(w)?D.True:D.False}function EZ(w,z){return t0(z)?p0(w,z):q.IsObject(z)?$2(w,z):q.IsRecord(z)?m2(w,z):q.IsBoolean(z)?D.True:D.False}function IZ(w,z){return t0(z)?p0(w,z):q.IsObject(z)?$2(w,z):!q.IsConstructor(z)?D.False:w.parameters.length>z.parameters.length?D.False:!w.parameters.every((U,W)=>u2(R0(z.parameters[W],U))===D.True)?D.False:u2(R0(w.returns,z.returns))}function xZ(w,z){return t0(z)?p0(w,z):q.IsObject(z)?$2(w,z):q.IsRecord(z)?m2(w,z):q.IsDate(z)?D.True:D.False}function VZ(w,z){return t0(z)?p0(w,z):q.IsObject(z)?$2(w,z):!q.IsFunction(z)?D.False:w.parameters.length>z.parameters.length?D.False:!w.parameters.every((U,W)=>u2(R0(z.parameters[W],U))===D.True)?D.False:u2(R0(w.returns,z.returns))}function x9(w,z){return q.IsLiteral(w)&&H2.IsNumber(w.const)?D.True:q.IsNumber(w)||q.IsInteger(w)?D.True:D.False}function kZ(w,z){return q.IsInteger(z)||q.IsNumber(z)?D.True:t0(z)?p0(w,z):q.IsObject(z)?$2(w,z):q.IsRecord(z)?m2(w,z):D.False}function M8(w,z){return z.allOf.every((U)=>R0(w,U)===D.True)?D.True:D.False}function TZ(w,z){return w.allOf.some((U)=>R0(U,z)===D.True)?D.True:D.False}function gZ(w,z){return t0(z)?p0(w,z):!q.IsIterator(z)?D.False:u2(R0(w.items,z.items))}function fZ(w,z){return q.IsLiteral(z)&&z.const===w.const?D.True:t0(z)?p0(w,z):q.IsObject(z)?$2(w,z):q.IsRecord(z)?m2(w,z):q.IsString(z)?g9(w,z):q.IsNumber(z)?k9(w,z):q.IsInteger(z)?x9(w,z):q.IsBoolean(z)?I9(w,z):D.False}function V9(w,z){return D.False}function dZ(w,z){return D.True}function C9(w){let[z,U]=[w,0];while(!0){if(!q.IsNot(z))break;z=z.not,U+=1}return U%2===0?z:T1()}function hZ(w,z){return q.IsNot(w)?R0(C9(w),z):q.IsNot(z)?R0(w,C9(z)):i6("Invalid fallthrough for Not")}function yZ(w,z){return t0(z)?p0(w,z):q.IsObject(z)?$2(w,z):q.IsRecord(z)?m2(w,z):q.IsNull(z)?D.True:D.False}function k9(w,z){return q.IsLiteralNumber(w)?D.True:q.IsNumber(w)||q.IsInteger(w)?D.True:D.False}function cZ(w,z){return t0(z)?p0(w,z):q.IsObject(z)?$2(w,z):q.IsRecord(z)?m2(w,z):q.IsInteger(z)||q.IsNumber(z)?D.True:D.False}function b2(w,z){return Object.getOwnPropertyNames(w.properties).length===z}function K9(w){return q8(w)}function F9(w){return b2(w,0)||b2(w,1)&&"description"in w.properties&&q.IsUnion(w.properties.description)&&w.properties.description.anyOf.length===2&&(q.IsString(w.properties.description.anyOf[0])&&q.IsUndefined(w.properties.description.anyOf[1])||q.IsString(w.properties.description.anyOf[1])&&q.IsUndefined(w.properties.description.anyOf[0]))}function Aw(w){return b2(w,0)}function j9(w){return b2(w,0)}function iZ(w){return b2(w,0)}function vZ(w){return b2(w,0)}function nZ(w){return q8(w)}function uZ(w){let z=S1();return b2(w,0)||b2(w,1)&&"length"in w.properties&&u2(R0(w.properties.length,z))===D.True}function mZ(w){return b2(w,0)}function q8(w){let z=S1();return b2(w,0)||b2(w,1)&&"length"in w.properties&&u2(R0(w.properties.length,z))===D.True}function tZ(w){let z=L1([o1()],o1());return b2(w,0)||b2(w,1)&&"then"in w.properties&&u2(R0(w.properties.then,z))===D.True}function T9(w,z){return R0(w,z)===D.False?D.False:q.IsOptional(w)&&!q.IsOptional(z)?D.False:D.True}function $2(w,z){return q.IsUnknown(w)?D.False:q.IsAny(w)?D.Union:q.IsNever(w)||q.IsLiteralString(w)&&K9(z)||q.IsLiteralNumber(w)&&Aw(z)||q.IsLiteralBoolean(w)&&j9(z)||q.IsSymbol(w)&&F9(z)||q.IsBigInt(w)&&iZ(z)||q.IsString(w)&&K9(z)||q.IsSymbol(w)&&F9(z)||q.IsNumber(w)&&Aw(z)||q.IsInteger(w)&&Aw(z)||q.IsBoolean(w)&&j9(z)||q.IsUint8Array(w)&&nZ(z)||q.IsDate(w)&&vZ(z)||q.IsConstructor(w)&&mZ(z)||q.IsFunction(w)&&uZ(z)?D.True:q.IsRecord(w)&&q.IsString(Xw(w))?(()=>{return z[h2]==="Record"?D.True:D.False})():q.IsRecord(w)&&q.IsNumber(Xw(w))?(()=>{return b2(z,0)?D.True:D.False})():D.False}function pZ(w,z){return t0(z)?p0(w,z):q.IsRecord(z)?m2(w,z):!q.IsObject(z)?D.False:(()=>{for(let U of Object.getOwnPropertyNames(z.properties)){if(!(U in w.properties)&&!q.IsOptional(z.properties[U]))return D.False;if(q.IsOptional(z.properties[U]))return D.True;if(T9(w.properties[U],z.properties[U])===D.False)return D.False}return D.True})()}function oZ(w,z){return t0(z)?p0(w,z):q.IsObject(z)&&tZ(z)?D.True:!q.IsPromise(z)?D.False:u2(R0(w.item,z.item))}function Xw(w){return I1 in w.patternProperties?S1():(x1 in w.patternProperties)?c2():i6("Unknown record key pattern")}function Zw(w){return I1 in w.patternProperties?w.patternProperties[I1]:(x1 in w.patternProperties)?w.patternProperties[x1]:i6("Unable to get record value schema")}function m2(w,z){let[U,W]=[Xw(z),Zw(z)];return q.IsLiteralString(w)&&q.IsNumber(U)&&u2(R0(w,W))===D.True?D.True:q.IsUint8Array(w)&&q.IsNumber(U)?R0(w,W):q.IsString(w)&&q.IsNumber(U)?R0(w,W):q.IsArray(w)&&q.IsNumber(U)?R0(w,W):q.IsObject(w)?(()=>{for(let A of Object.getOwnPropertyNames(w.properties))if(T9(W,w.properties[A])===D.False)return D.False;return D.True})():D.False}function lZ(w,z){return t0(z)?p0(w,z):q.IsObject(z)?$2(w,z):!q.IsRecord(z)?D.False:R0(Zw(w),Zw(z))}function sZ(w,z){let U=q.IsRegExp(w)?c2():w,W=q.IsRegExp(z)?c2():z;return R0(U,W)}function g9(w,z){return q.IsLiteral(w)&&H2.IsString(w.const)?D.True:q.IsString(w)?D.True:D.False}function rZ(w,z){return t0(z)?p0(w,z):q.IsObject(z)?$2(w,z):q.IsRecord(z)?m2(w,z):q.IsString(z)?D.True:D.False}function aZ(w,z){return t0(z)?p0(w,z):q.IsObject(z)?$2(w,z):q.IsRecord(z)?m2(w,z):q.IsSymbol(z)?D.True:D.False}function eZ(w,z){return q.IsTemplateLiteral(w)?R0(G6(w),z):q.IsTemplateLiteral(z)?R0(w,G6(z)):i6("Invalid fallthrough for TemplateLiteral")}function w$(w,z){return q.IsArray(z)&&w.items!==void 0&&w.items.every((U)=>R0(U,z.items)===D.True)}function z$(w,z){return q.IsNever(w)?D.True:q.IsUnknown(w)?D.False:q.IsAny(w)?D.Union:D.False}function U$(w,z){return t0(z)?p0(w,z):q.IsObject(z)&&q8(z)?D.True:q.IsArray(z)&&w$(w,z)?D.True:!q.IsTuple(z)?D.False:H2.IsUndefined(w.items)&&!H2.IsUndefined(z.items)||!H2.IsUndefined(w.items)&&H2.IsUndefined(z.items)?D.False:H2.IsUndefined(w.items)&&!H2.IsUndefined(z.items)?D.True:w.items.every((U,W)=>R0(U,z.items[W])===D.True)?D.True:D.False}function W$(w,z){return t0(z)?p0(w,z):q.IsObject(z)?$2(w,z):q.IsRecord(z)?m2(w,z):q.IsUint8Array(z)?D.True:D.False}function A$(w,z){return t0(z)?p0(w,z):q.IsObject(z)?$2(w,z):q.IsRecord(z)?m2(w,z):q.IsVoid(z)?$$(w,z):q.IsUndefined(z)?D.True:D.False}function Qw(w,z){return z.anyOf.some((U)=>R0(w,U)===D.True)?D.True:D.False}function X$(w,z){return w.anyOf.every((U)=>R0(U,z)===D.True)?D.True:D.False}function f9(w,z){return D.True}function Z$(w,z){return q.IsNever(z)?V9(w,z):q.IsIntersect(z)?M8(w,z):q.IsUnion(z)?Qw(w,z):q.IsAny(z)?$w(w,z):q.IsString(z)?g9(w,z):q.IsNumber(z)?k9(w,z):q.IsInteger(z)?x9(w,z):q.IsBoolean(z)?I9(w,z):q.IsArray(z)?CZ(w,z):q.IsTuple(z)?z$(w,z):q.IsObject(z)?$2(w,z):q.IsUnknown(z)?D.True:D.False}function $$(w,z){return q.IsUndefined(w)?D.True:q.IsUndefined(w)?D.True:D.False}function Q$(w,z){return q.IsIntersect(z)?M8(w,z):q.IsUnion(z)?Qw(w,z):q.IsUnknown(z)?f9(w,z):q.IsAny(z)?$w(w,z):q.IsObject(z)?$2(w,z):q.IsVoid(z)?D.True:D.False}function R0(w,z){return q.IsTemplateLiteral(w)||q.IsTemplateLiteral(z)?eZ(w,z):q.IsRegExp(w)||q.IsRegExp(z)?sZ(w,z):q.IsNot(w)||q.IsNot(z)?hZ(w,z):q.IsAny(w)?RZ(w,z):q.IsArray(w)?KZ(w,z):q.IsBigInt(w)?jZ(w,z):q.IsBoolean(w)?EZ(w,z):q.IsAsyncIterator(w)?FZ(w,z):q.IsConstructor(w)?IZ(w,z):q.IsDate(w)?xZ(w,z):q.IsFunction(w)?VZ(w,z):q.IsInteger(w)?kZ(w,z):q.IsIntersect(w)?TZ(w,z):q.IsIterator(w)?gZ(w,z):q.IsLiteral(w)?fZ(w,z):q.IsNever(w)?dZ(w,z):q.IsNull(w)?yZ(w,z):q.IsNumber(w)?cZ(w,z):q.IsObject(w)?pZ(w,z):q.IsRecord(w)?lZ(w,z):q.IsString(w)?rZ(w,z):q.IsSymbol(w)?aZ(w,z):q.IsTuple(w)?U$(w,z):q.IsPromise(w)?oZ(w,z):q.IsUint8Array(w)?W$(w,z):q.IsUndefined(w)?A$(w,z):q.IsUnion(w)?X$(w,z):q.IsUnknown(w)?Z$(w,z):q.IsVoid(w)?Q$(w,z):i6(`Unknown left type operand '${w[N]}'`)}function s1(w,z){return R0(w,z)}function Y$(w,z,U,W,A){let X={};for(let Z of globalThis.Object.getOwnPropertyNames(w))X[Z]=v6(w[Z],z,U,W,k0(A));return X}function J$(w,z,U,W,A){return Y$(w.properties,z,U,W,A)}function d9(w,z,U,W,A){let X=J$(w,z,U,W,A);return Y0(X)}function B$(w,z,U,W){let A=s1(w,z);return A===D.Union?G0([U,W]):A===D.True?U:W}function v6(w,z,U,W,A){return g0(w)?d9(w,z,U,W,A):k2(w)?P(h9(w,z,U,W,A)):P(B$(w,z,U,W),A)}function M$(w,z,U,W,A){return{[w]:v6(X0(w),z,U,W,k0(A))}}function q$(w,z,U,W,A){return w.reduce((X,Z)=>{return{...X,...M$(Z,z,U,W,A)}},{})}function H$(w,z,U,W,A){return q$(w.keys,z,U,W,A)}function h9(w,z,U,W,A){let X=H$(w,z,U,W,A);return Y0(X)}function G$(w){return w.allOf.every((z)=>g1(z))}function L$(w){return w.anyOf.some((z)=>g1(z))}function N$(w){return!g1(w.not)}function g1(w){return w[N]==="Intersect"?G$(w):w[N]==="Union"?L$(w):w[N]==="Not"?N$(w):w[N]==="Undefined"?!0:!1}function y9(w,z){return n6(G6(w),z)}function S$(w,z){let U=w.filter((W)=>s1(W,z)===D.False);return U.length===1?U[0]:G0(U)}function n6(w,z,U={}){if(T2(w))return P(y9(w,z),U);if(g0(w))return P(c9(w,z),U);return P(q0(w)?S$(w.anyOf,z):s1(w,z)!==D.False?H0():w,U)}function _$(w,z){let U={};for(let W of globalThis.Object.getOwnPropertyNames(w))U[W]=n6(w[W],z);return U}function D$(w,z){return _$(w.properties,z)}function c9(w,z){let U=D$(w,z);return Y0(U)}function i9(w,z){return u6(G6(w),z)}function P$(w,z){let U=w.filter((W)=>s1(W,z)!==D.False);return U.length===1?U[0]:G0(U)}function u6(w,z,U){if(T2(w))return P(i9(w,z),U);if(g0(w))return P(v9(w,z),U);return P(q0(w)?P$(w.anyOf,z):s1(w,z)!==D.False?w:H0(),U)}function O$(w,z){let U={};for(let W of globalThis.Object.getOwnPropertyNames(w))U[W]=u6(w[W],z);return U}function b$(w,z){return O$(w.properties,z)}function v9(w,z){let U=b$(w,z);return Y0(U)}function n9(w,z){return P(w.returns,z)}function u9(w){return P({[N]:"Integer",type:"integer"},w)}function R$(w,z,U){return{[w]:U1(X0(w),z,k0(U))}}function C$(w,z,U){return w.reduce((A,X)=>{return{...A,...R$(X,z,U)}},{})}function K$(w,z,U){return C$(w.keys,z,U)}function m9(w,z,U){let W=K$(w,z,U);return Y0(W)}function F$(w){let[z,U]=[w.slice(0,1),w.slice(1)];return[z.toLowerCase(),U].join("")}function j$(w){let[z,U]=[w.slice(0,1),w.slice(1)];return[z.toUpperCase(),U].join("")}function E$(w){return w.toUpperCase()}function I$(w){return w.toLowerCase()}function x$(w,z,U){let W=g6(w.pattern);if(!H6(W))return{...w,pattern:t9(w.pattern,z)};let Z=[...D4(W)].map((Y)=>X0(Y)),$=p9(Z,z),Q=G0($);return U8([Q],U)}function t9(w,z){return typeof w==="string"?z==="Uncapitalize"?F$(w):z==="Capitalize"?j$(w):z==="Uppercase"?E$(w):z==="Lowercase"?I$(w):w:w.toString()}function p9(w,z){return w.map((U)=>U1(U,z))}function U1(w,z,U={}){return k2(w)?m9(w,z,U):T2(w)?x$(w,z,U):q0(w)?G0(p9(w.anyOf,z),U):E1(w)?X0(t9(w.const,z),U):P(w,U)}function o9(w,z={}){return U1(w,"Capitalize",z)}function l9(w,z={}){return U1(w,"Lowercase",z)}function s9(w,z={}){return U1(w,"Uncapitalize",z)}function r9(w,z={}){return U1(w,"Uppercase",z)}function V$(w,z,U){let W={};for(let A of globalThis.Object.getOwnPropertyNames(w))W[A]=r1(w[A],z,k0(U));return W}function k$(w,z,U){return V$(w.properties,z,U)}function a9(w,z,U){let W=k$(w,z,U);return Y0(W)}function T$(w,z){return w.map((U)=>Yw(U,z))}function g$(w,z){return w.map((U)=>Yw(U,z))}function f$(w,z){let{[z]:U,...W}=w;return W}function d$(w,z){return z.reduce((U,W)=>f$(U,W),w)}function h$(w,z){let U=c0(w,[F0,"$id","required","properties"]),W=d$(w.properties,z);return _0(W,U)}function y$(w){let z=w.reduce((U,W)=>r4(W)?[...U,X0(W)]:U,[]);return G0(z)}function Yw(w,z){return m0(w)?Z2(T$(w.allOf,z)):q0(w)?G0(g$(w.anyOf,z)):r0(w)?h$(w,z):_0({})}function r1(w,z,U){let W=u0(z)?y$(z):z,A=d0(z)?D2(z):z,X=h0(w),Z=h0(z);return g0(w)?a9(w,A,U):k2(z)?e9(w,z,U):X&&Z?N0("Omit",[w,W],U):!X&&Z?N0("Omit",[w,W],U):X&&!Z?N0("Omit",[w,W],U):P({...Yw(w,A),...U})}function c$(w,z,U){return{[z]:r1(w,[z],k0(U))}}function i$(w,z,U){return z.reduce((W,A)=>{return{...W,...c$(w,A,U)}},{})}function v$(w,z,U){return i$(w,z.keys,U)}function e9(w,z,U){let W=v$(w,z,U);return Y0(W)}function n$(w,z,U){let W={};for(let A of globalThis.Object.getOwnPropertyNames(w))W[A]=a1(w[A],z,k0(U));return W}function u$(w,z,U){return n$(w.properties,z,U)}function w7(w,z,U){let W=u$(w,z,U);return Y0(W)}function m$(w,z){return w.map((U)=>Jw(U,z))}function t$(w,z){return w.map((U)=>Jw(U,z))}function p$(w,z){let U={};for(let W of z)if(W in w)U[W]=w[W];return U}function o$(w,z){let U=c0(w,[F0,"$id","required","properties"]),W=p$(w.properties,z);return _0(W,U)}function l$(w){let z=w.reduce((U,W)=>r4(W)?[...U,X0(W)]:U,[]);return G0(z)}function Jw(w,z){return m0(w)?Z2(m$(w.allOf,z)):q0(w)?G0(t$(w.anyOf,z)):r0(w)?o$(w,z):_0({})}function a1(w,z,U){let W=u0(z)?l$(z):z,A=d0(z)?D2(z):z,X=h0(w),Z=h0(z);return g0(w)?w7(w,A,U):k2(z)?z7(w,z,U):X&&Z?N0("Pick",[w,W],U):!X&&Z?N0("Pick",[w,W],U):X&&!Z?N0("Pick",[w,W],U):P({...Jw(w,A),...U})}function s$(w,z,U){return{[z]:a1(w,[z],k0(U))}}function r$(w,z,U){return z.reduce((W,A)=>{return{...W,...s$(w,A,U)}},{})}function a$(w,z,U){return r$(w,z.keys,U)}function z7(w,z,U){let W=a$(w,z,U);return Y0(W)}function e$(w,z){return N0("Partial",[N0(w,z)])}function wQ(w){return N0("Partial",[P2(w)])}function zQ(w){let z={};for(let U of globalThis.Object.getOwnPropertyNames(w))z[U]=_2(w[U]);return z}function UQ(w){let z=c0(w,[F0,"$id","required","properties"]),U=zQ(w.properties);return _0(U,z)}function U7(w){return w.map((z)=>W7(z))}function W7(w){return S2(w)?e$(w.target,w.parameters):h0(w)?wQ(w.$ref):m0(w)?Z2(U7(w.allOf)):q0(w)?G0(U7(w.anyOf)):r0(w)?UQ(w):_0({})}function m6(w,z){if(g0(w))return A7(w,z);else return P({...W7(w),...z})}function WQ(w,z){let U={};for(let W of globalThis.Object.getOwnPropertyNames(w))U[W]=m6(w[W],k0(z));return U}function AQ(w,z){return WQ(w.properties,z)}function A7(w,z){let U=AQ(w,z);return Y0(U)}function L6(w,z,U){return P({[N]:"Record",type:"object",patternProperties:{[w]:z}},U)}function Bw(w,z,U){let W={};for(let A of w)W[A]=z;return _0(W,{...U,[h2]:"Record"})}function XQ(w,z,U){return w8(w)?Bw(D2(w),z,U):L6(w.pattern,z,U)}function ZQ(w,z,U){return Bw(D2(G0(w)),z,U)}function $Q(w,z,U){return Bw([w.toString()],z,U)}function QQ(w,z,U){return L6(w.source,z,U)}function YQ(w,z,U){let W=s0(w.pattern)?x1:w.pattern;return L6(W,z,U)}function JQ(w,z,U){return L6(x1,z,U)}function BQ(w,z,U){return L6(lz,z,U)}function MQ(w,z,U){return L6(I1,z,U)}function qQ(w,z,U){return L6(I1,z,U)}function H8(w,z,U={}){return S2(z)?N0("Record",[w,N0(z.target,z.parameters)],U):S2(w)?N0("Record",[N0(z.target,z.parameters),z],U):h0(w)?N0("Record",[P2(w.$ref),z]):q0(w)?ZQ(w.anyOf,z,U):T2(w)?XQ(w,z,U):E1(w)?$Q(w.const,z,U):M6(w)?MQ(w,z,U):q6(w)?qQ(w,z,U):o5(w)?QQ(w,z,U):H4(w)?YQ(w,z,U):u5(w)?JQ(w,z,U):t1(w)?BQ(w,z,U):H0(U)}function HQ(w,z){return N0("Required",[N0(w,z)])}function GQ(w){return N0("Required",[P2(w)])}function LQ(w){let z={};for(let U of globalThis.Object.getOwnPropertyNames(w))z[U]=c0(w[U],[X2]);return z}function NQ(w){let z=c0(w,[F0,"$id","required","properties"]),U=LQ(w.properties);return _0(U,z)}function X7(w){return w.map((z)=>Z7(z))}function Z7(w){return S2(w)?HQ(w.target,w.parameters):h0(w)?GQ(w.$ref):m0(w)?Z2(X7(w.allOf)):q0(w)?G0(X7(w.anyOf)):r0(w)?NQ(w):_0({})}function t6(w,z){if(g0(w))return $7(w,z);else return P({...Z7(w),...z})}function SQ(w,z){let U={};for(let W of globalThis.Object.getOwnPropertyNames(w))U[W]=t6(w[W],z);return U}function _Q(w,z){return SQ(w.properties,z)}function $7(w,z){let U=_Q(w,z);return Y0(U)}function DQ(w,z){return z.map((U)=>{return h0(U)?Q7(w,U.$ref):t2(w,U)})}function Q7(w,z){return z in w?h0(w[z])?Q7(w,w[z].$ref):t2(w,w[z]):H0()}function PQ(w){return y6(w[0])}function OQ(w){return l1(w[0],w[1])}function bQ(w){return c6(w[0])}function RQ(w){return m6(w[0])}function CQ(w){return r1(w[0],w[1])}function KQ(w){return a1(w[0],w[1])}function FQ(w){return H8(w[0],w[1])}function jQ(w){return t6(w[0])}function EQ(w,z,U){let W=DQ(w,U);return z==="Awaited"?PQ(W):z==="Index"?OQ(W):z==="KeyOf"?bQ(W):z==="Partial"?RQ(W):z==="Omit"?CQ(W):z==="Pick"?KQ(W):z==="Record"?FQ(W):z==="Required"?jQ(W):H0()}function IQ(w,z){return _0(globalThis.Object.keys(z).reduce((U,W)=>{return{...U,[W]:t2(w,z[W])}},{}))}function xQ(w,z,U){return k6(R4(w,z),t2(w,U))}function VQ(w,z,U){return L1(R4(w,z),t2(w,U))}function kQ(w,z){return v2(R4(w,z))}function TQ(w,z){return Z2(R4(w,z))}function gQ(w,z){return G0(R4(w,z))}function fQ(w,z){return x6(t2(w,z))}function dQ(w,z){return V6(t2(w,z))}function hQ(w,z){return h6(t2(w,z))}function R4(w,z){return z.map((U)=>t2(w,U))}function t2(w,z){return y2(z)?P(t2(w,c0(z,[X2])),z):s4(z)?P(t2(w,c0(z,[w1])),z):j1(z)?P(fQ(w,z.items),z):Y4(z)?P(dQ(w,z.items),z):S2(z)?P(EQ(w,z.target,z.parameters)):J4(z)?P(xQ(w,z.parameters,z.returns),z):B4(z)?P(VQ(w,z.parameters,z.returns),z):m0(z)?P(TQ(w,z.allOf),z):M4(z)?P(hQ(w,z.items),z):r0(z)?P(IQ(w,z.properties),z):z1(z)?P(kQ(w,z.items||[]),z):q0(z)?P(gQ(w,z.anyOf),z):z}function yQ(w,z){return z in w?t2(w,w[z]):H0()}function Y7(w){return globalThis.Object.getOwnPropertyNames(w).reduce((z,U)=>{return{...z,[U]:yQ(w,U)}},{})}class J7{constructor(w){let z=Y7(w),U=this.WithIdentifiers(z);this.$defs=U}Import(w,z){let U={...this.$defs,[w]:P(this.$defs[w],z)};return P({[N]:"Import",$defs:U,$ref:w})}WithIdentifiers(w){return globalThis.Object.getOwnPropertyNames(w).reduce((z,U)=>{return{...z,[U]:{...w[U],$id:U}}},{})}}function B7(w){return new J7(w)}function M7(w,z){return P({[N]:"Not",not:w},z)}function q7(w,z){return v2(w.parameters,z)}function H7(w){return i2(_2(w))}var cQ=0;function G7(w,z={}){if(s0(z.$id))z.$id=`T${cQ++}`;let U=zz(w({[N]:"This",$ref:`${z.$id}`}));return U.$id=z.$id,P({[h2]:"Recursive",...U},z)}function L7(w,z){let U=E0(w)?new globalThis.RegExp(w):w;return P({[N]:"RegExp",type:"RegExp",source:U.source,flags:U.flags},z)}function iQ(w){return m0(w)?w.allOf:q0(w)?w.anyOf:z1(w)?w.items??[]:[]}function N7(w){return iQ(w)}function S7(w,z){return P(w.returns,z)}class _7{constructor(w){this.schema=w}Decode(w){return new D7(this.schema,w)}}class D7{constructor(w,z){this.schema=w,this.decode=z}EncodeTransform(w,z){let A={Encode:(X)=>z[F0].Encode(w(X)),Decode:(X)=>this.decode(z[F0].Decode(X))};return{...z,[F0]:A}}EncodeSchema(w,z){let U={Decode:this.decode,Encode:w};return{...z,[F0]:U}}Encode(w){return S0(this.schema)?this.EncodeTransform(w,this.schema):this.EncodeSchema(w,this.schema)}}function P7(w){return new _7(w)}function G8(w={}){return P({[N]:w[N]??"Unsafe"},w)}function O7(w){return P({[N]:"Void",type:"void"},w)}var Mw={};J6(Mw,{Void:()=>O7,Uppercase:()=>r9,Unsafe:()=>G8,Unknown:()=>T1,Union:()=>G0,Undefined:()=>Y8,Uncapitalize:()=>s9,Uint8Array:()=>J8,Tuple:()=>v2,Transform:()=>P7,TemplateLiteral:()=>U8,Symbol:()=>Q8,String:()=>c2,ReturnType:()=>S7,Rest:()=>N7,Required:()=>t6,RegExp:()=>L7,Ref:()=>P2,Recursive:()=>G7,Record:()=>H8,ReadonlyOptional:()=>H7,Readonly:()=>i2,Promise:()=>A8,Pick:()=>a1,Partial:()=>m6,Parameters:()=>q7,Optional:()=>_2,Omit:()=>r1,Object:()=>_0,Number:()=>S1,Null:()=>$8,Not:()=>M7,Never:()=>H0,Module:()=>B7,Mapped:()=>G9,Lowercase:()=>l9,Literal:()=>X0,KeyOf:()=>c6,Iterator:()=>h6,Intersect:()=>Z2,Integer:()=>u9,InstanceType:()=>n9,Index:()=>l1,Function:()=>L1,Extract:()=>u6,Extends:()=>v6,Exclude:()=>n6,Enum:()=>R9,Date:()=>Z8,ConstructorParameters:()=>b9,Constructor:()=>k6,Const:()=>O9,Composite:()=>P9,Capitalize:()=>o9,Boolean:()=>z8,BigInt:()=>d6,Awaited:()=>y6,AsyncIterator:()=>V6,Array:()=>x6,Any:()=>o1});var N6=Mw;class b7 extends y{constructor(w){super(`Duplicate type kind '${w}' detected`)}}class R7 extends y{constructor(w){super(`Duplicate string format '${w}' detected`)}}var f1;(function(w){function z(W,A){if(y0.Has(W))throw new b7(W);return y0.Set(W,A),(X={})=>G8({...X,[N]:W})}w.Type=z;function U(W,A){if(b0.Has(W))throw new R7(W);return b0.Set(W,A),W}w.Format=U})(f1||(f1={}));function vQ(w){switch(w.errorType){case S.ArrayContains:return"Expected array to contain at least one matching value";case S.ArrayMaxContains:return`Expected array to contain no more than ${w.schema.maxContains} matching values`;case S.ArrayMinContains:return`Expected array to contain at least ${w.schema.minContains} matching values`;case S.ArrayMaxItems:return`Expected array length to be less or equal to ${w.schema.maxItems}`;case S.ArrayMinItems:return`Expected array length to be greater or equal to ${w.schema.minItems}`;case S.ArrayUniqueItems:return"Expected array elements to be unique";case S.Array:return"Expected array";case S.AsyncIterator:return"Expected AsyncIterator";case S.BigIntExclusiveMaximum:return`Expected bigint to be less than ${w.schema.exclusiveMaximum}`;case S.BigIntExclusiveMinimum:return`Expected bigint to be greater than ${w.schema.exclusiveMinimum}`;case S.BigIntMaximum:return`Expected bigint to be less or equal to ${w.schema.maximum}`;case S.BigIntMinimum:return`Expected bigint to be greater or equal to ${w.schema.minimum}`;case S.BigIntMultipleOf:return`Expected bigint to be a multiple of ${w.schema.multipleOf}`;case S.BigInt:return"Expected bigint";case S.Boolean:return"Expected boolean";case S.DateExclusiveMinimumTimestamp:return`Expected Date timestamp to be greater than ${w.schema.exclusiveMinimumTimestamp}`;case S.DateExclusiveMaximumTimestamp:return`Expected Date timestamp to be less than ${w.schema.exclusiveMaximumTimestamp}`;case S.DateMinimumTimestamp:return`Expected Date timestamp to be greater or equal to ${w.schema.minimumTimestamp}`;case S.DateMaximumTimestamp:return`Expected Date timestamp to be less or equal to ${w.schema.maximumTimestamp}`;case S.DateMultipleOfTimestamp:return`Expected Date timestamp to be a multiple of ${w.schema.multipleOfTimestamp}`;case S.Date:return"Expected Date";case S.Function:return"Expected function";case S.IntegerExclusiveMaximum:return`Expected integer to be less than ${w.schema.exclusiveMaximum}`;case S.IntegerExclusiveMinimum:return`Expected integer to be greater than ${w.schema.exclusiveMinimum}`;case S.IntegerMaximum:return`Expected integer to be less or equal to ${w.schema.maximum}`;case S.IntegerMinimum:return`Expected integer to be greater or equal to ${w.schema.minimum}`;case S.IntegerMultipleOf:return`Expected integer to be a multiple of ${w.schema.multipleOf}`;case S.Integer:return"Expected integer";case S.IntersectUnevaluatedProperties:return"Unexpected property";case S.Intersect:return"Expected all values to match";case S.Iterator:return"Expected Iterator";case S.Literal:return`Expected ${typeof w.schema.const==="string"?`'${w.schema.const}'`:w.schema.const}`;case S.Never:return"Never";case S.Not:return"Value should not match";case S.Null:return"Expected null";case S.NumberExclusiveMaximum:return`Expected number to be less than ${w.schema.exclusiveMaximum}`;case S.NumberExclusiveMinimum:return`Expected number to be greater than ${w.schema.exclusiveMinimum}`;case S.NumberMaximum:return`Expected number to be less or equal to ${w.schema.maximum}`;case S.NumberMinimum:return`Expected number to be greater or equal to ${w.schema.minimum}`;case S.NumberMultipleOf:return`Expected number to be a multiple of ${w.schema.multipleOf}`;case S.Number:return"Expected number";case S.Object:return"Expected object";case S.ObjectAdditionalProperties:return"Unexpected property";case S.ObjectMaxProperties:return`Expected object to have no more than ${w.schema.maxProperties} properties`;case S.ObjectMinProperties:return`Expected object to have at least ${w.schema.minProperties} properties`;case S.ObjectRequiredProperty:return"Expected required property";case S.Promise:return"Expected Promise";case S.RegExp:return"Expected string to match regular expression";case S.StringFormatUnknown:return`Unknown format '${w.schema.format}'`;case S.StringFormat:return`Expected string to match '${w.schema.format}' format`;case S.StringMaxLength:return`Expected string length less or equal to ${w.schema.maxLength}`;case S.StringMinLength:return`Expected string length greater or equal to ${w.schema.minLength}`;case S.StringPattern:return`Expected string to match '${w.schema.pattern}'`;case S.String:return"Expected string";case S.Symbol:return"Expected symbol";case S.TupleLength:return`Expected tuple to have ${w.schema.maxItems||0} elements`;case S.Tuple:return"Expected tuple";case S.Uint8ArrayMaxByteLength:return`Expected byte length less or equal to ${w.schema.maxByteLength}`;case S.Uint8ArrayMinByteLength:return`Expected byte length greater or equal to ${w.schema.minByteLength}`;case S.Uint8Array:return"Expected Uint8Array";case S.Undefined:return"Expected undefined";case S.Union:return"Expected union value";case S.Void:return"Expected void";case S.Kind:return`Expected kind '${w.schema[N]}'`;default:return"Unknown error type"}}var nQ=vQ;function C7(){return nQ}class K7 extends y{constructor(w){super(`Unable to dereference schema with $id '${w.$ref}'`);this.schema=w}}function uQ(w,z){let U=z.find((W)=>W.$id===w.$ref);if(U===void 0)throw new K7(w);return J0(U,z)}function e0(w,z){if(!$0(w.$id)||z.some((U)=>U.$id===w.$id))return z;return z.push(w),z}function J0(w,z){return w[N]==="This"||w[N]==="Ref"?uQ(w,z):w}class F7 extends y{constructor(w){super("Unable to hash value");this.value=w}}var g2;(function(w){w[w.Undefined=0]="Undefined",w[w.Null=1]="Null",w[w.Boolean=2]="Boolean",w[w.Number=3]="Number",w[w.String=4]="String",w[w.Object=5]="Object",w[w.Array=6]="Array",w[w.Date=7]="Date",w[w.Uint8Array=8]="Uint8Array",w[w.Symbol=9]="Symbol",w[w.BigInt=10]="BigInt"})(g2||(g2={}));var p6=BigInt("14695981039346656037"),[mQ,tQ]=[BigInt("1099511628211"),BigInt("18446744073709551616")],pQ=Array.from({length:256}).map((w,z)=>BigInt(z)),j7=new Float64Array(1),E7=new DataView(j7.buffer),I7=new Uint8Array(j7.buffer);function*oQ(w){let z=w===0?1:Math.ceil(Math.floor(Math.log2(w)+1)/8);for(let U=0;U<z;U++)yield w>>8*(z-1-U)&255}function lQ(w){Q2(g2.Array);for(let z of w)o6(z)}function sQ(w){Q2(g2.Boolean),Q2(w?1:0)}function rQ(w){Q2(g2.BigInt),E7.setBigInt64(0,w);for(let z of I7)Q2(z)}function aQ(w){Q2(g2.Date),o6(w.getTime())}function eQ(w){Q2(g2.Null)}function wY(w){Q2(g2.Number),E7.setFloat64(0,w);for(let z of I7)Q2(z)}function zY(w){Q2(g2.Object);for(let z of globalThis.Object.getOwnPropertyNames(w).sort())o6(z),o6(w[z])}function UY(w){Q2(g2.String);for(let z=0;z<w.length;z++)for(let U of oQ(w.charCodeAt(z)))Q2(U)}function WY(w){Q2(g2.Symbol),o6(w.description)}function AY(w){Q2(g2.Uint8Array);for(let z=0;z<w.length;z++)Q2(w[z])}function XY(w){return Q2(g2.Undefined)}function o6(w){if(n(w))return lQ(w);if(G1(w))return sQ(w);if(A2(w))return rQ(w);if(G2(w))return aQ(w);if(K1(w))return eQ(w);if(d(w))return wY(w);if(s(w))return zY(w);if($0(w))return UY(w);if(F1(w))return WY(w);if(j6(w))return AY(w);if(T0(w))return XY(w);throw new F7(w)}function Q2(w){p6=p6^pQ[w],p6=p6*mQ%tQ}function e1(w){return p6=BigInt("14695981039346656037"),o6(w),p6}class x7 extends y{constructor(w){super("Unknown type");this.schema=w}}function ZY(w){return w[N]==="Any"||w[N]==="Unknown"}function z0(w){return w!==void 0}function $Y(w,z,U){return!0}function QY(w,z,U){if(!n(U))return!1;if(z0(w.minItems)&&!(U.length>=w.minItems))return!1;if(z0(w.maxItems)&&!(U.length<=w.maxItems))return!1;if(!U.every((X)=>w2(w.items,z,X)))return!1;if(w.uniqueItems===!0&&!function(){let X=new Set;for(let Z of U){let $=e1(Z);if(X.has($))return!1;else X.add($)}return!0}())return!1;if(!(z0(w.contains)||d(w.minContains)||d(w.maxContains)))return!0;let W=z0(w.contains)?w.contains:H0(),A=U.reduce((X,Z)=>w2(W,z,Z)?X+1:X,0);if(A===0)return!1;if(d(w.minContains)&&A<w.minContains)return!1;if(d(w.maxContains)&&A>w.maxContains)return!1;return!0}function YY(w,z,U){return t4(U)}function JY(w,z,U){if(!A2(U))return!1;if(z0(w.exclusiveMaximum)&&!(U<w.exclusiveMaximum))return!1;if(z0(w.exclusiveMinimum)&&!(U>w.exclusiveMinimum))return!1;if(z0(w.maximum)&&!(U<=w.maximum))return!1;if(z0(w.minimum)&&!(U>=w.minimum))return!1;if(z0(w.multipleOf)&&U%w.multipleOf!==BigInt(0))return!1;return!0}function BY(w,z,U){return G1(U)}function MY(w,z,U){return w2(w.returns,z,U.prototype)}function qY(w,z,U){if(!G2(U))return!1;if(z0(w.exclusiveMaximumTimestamp)&&!(U.getTime()<w.exclusiveMaximumTimestamp))return!1;if(z0(w.exclusiveMinimumTimestamp)&&!(U.getTime()>w.exclusiveMinimumTimestamp))return!1;if(z0(w.maximumTimestamp)&&!(U.getTime()<=w.maximumTimestamp))return!1;if(z0(w.minimumTimestamp)&&!(U.getTime()>=w.minimumTimestamp))return!1;if(z0(w.multipleOfTimestamp)&&U.getTime()%w.multipleOfTimestamp!==0)return!1;return!0}function HY(w,z,U){return m1(U)}function GY(w,z,U){let W=globalThis.Object.values(w.$defs),A=w.$defs[w.$ref];return w2(A,[...z,...W],U)}function LY(w,z,U){if(!l4(U))return!1;if(z0(w.exclusiveMaximum)&&!(U<w.exclusiveMaximum))return!1;if(z0(w.exclusiveMinimum)&&!(U>w.exclusiveMinimum))return!1;if(z0(w.maximum)&&!(U<=w.maximum))return!1;if(z0(w.minimum)&&!(U>=w.minimum))return!1;if(z0(w.multipleOf)&&U%w.multipleOf!==0)return!1;return!0}function NY(w,z,U){let W=w.allOf.every((A)=>w2(A,z,U));if(w.unevaluatedProperties===!1){let A=new RegExp(k1(w)),X=Object.getOwnPropertyNames(U).every((Z)=>A.test(Z));return W&&X}else if(d0(w.unevaluatedProperties)){let A=new RegExp(k1(w)),X=Object.getOwnPropertyNames(U).every((Z)=>A.test(Z)||w2(w.unevaluatedProperties,z,U[Z]));return W&&X}else return W}function SY(w,z,U){return p4(U)}function _Y(w,z,U){return U===w.const}function DY(w,z,U){return!1}function PY(w,z,U){return!w2(w.not,z,U)}function OY(w,z,U){return K1(U)}function bY(w,z,U){if(!V0.IsNumberLike(U))return!1;if(z0(w.exclusiveMaximum)&&!(U<w.exclusiveMaximum))return!1;if(z0(w.exclusiveMinimum)&&!(U>w.exclusiveMinimum))return!1;if(z0(w.minimum)&&!(U>=w.minimum))return!1;if(z0(w.maximum)&&!(U<=w.maximum))return!1;if(z0(w.multipleOf)&&U%w.multipleOf!==0)return!1;return!0}function RY(w,z,U){if(!V0.IsObjectLike(U))return!1;if(z0(w.minProperties)&&!(Object.getOwnPropertyNames(U).length>=w.minProperties))return!1;if(z0(w.maxProperties)&&!(Object.getOwnPropertyNames(U).length<=w.maxProperties))return!1;let W=Object.getOwnPropertyNames(w.properties);for(let A of W){let X=w.properties[A];if(w.required&&w.required.includes(A)){if(!w2(X,z,U[A]))return!1;if((g1(X)||ZY(X))&&!(A in U))return!1}else if(V0.IsExactOptionalProperty(U,A)&&!w2(X,z,U[A]))return!1}if(w.additionalProperties===!1){let A=Object.getOwnPropertyNames(U);if(w.required&&w.required.length===W.length&&A.length===W.length)return!0;else return A.every((X)=>W.includes(X))}else if(typeof w.additionalProperties==="object")return Object.getOwnPropertyNames(U).every((X)=>W.includes(X)||w2(w.additionalProperties,z,U[X]));else return!0}function CY(w,z,U){return o4(U)}function KY(w,z,U){if(!V0.IsRecordLike(U))return!1;if(z0(w.minProperties)&&!(Object.getOwnPropertyNames(U).length>=w.minProperties))return!1;if(z0(w.maxProperties)&&!(Object.getOwnPropertyNames(U).length<=w.maxProperties))return!1;let[W,A]=Object.entries(w.patternProperties)[0],X=new RegExp(W),Z=Object.entries(U).every(([Y,B])=>{return X.test(Y)?w2(A,z,B):!0}),$=typeof w.additionalProperties==="object"?Object.entries(U).every(([Y,B])=>{return!X.test(Y)?w2(w.additionalProperties,z,B):!0}):!0,Q=w.additionalProperties===!1?Object.getOwnPropertyNames(U).every((Y)=>{return X.test(Y)}):!0;return Z&&$&&Q}function FY(w,z,U){return w2(J0(w,z),z,U)}function jY(w,z,U){let W=new RegExp(w.source,w.flags);if(z0(w.minLength)){if(!(U.length>=w.minLength))return!1}if(z0(w.maxLength)){if(!(U.length<=w.maxLength))return!1}return W.test(U)}function EY(w,z,U){if(!$0(U))return!1;if(z0(w.minLength)){if(!(U.length>=w.minLength))return!1}if(z0(w.maxLength)){if(!(U.length<=w.maxLength))return!1}if(z0(w.pattern)){if(!new RegExp(w.pattern).test(U))return!1}if(z0(w.format)){if(!b0.Has(w.format))return!1;return b0.Get(w.format)(U)}return!0}function IY(w,z,U){return F1(U)}function xY(w,z,U){return $0(U)&&new RegExp(w.pattern).test(U)}function VY(w,z,U){return w2(J0(w,z),z,U)}function kY(w,z,U){if(!n(U))return!1;if(w.items===void 0&&U.length!==0)return!1;if(U.length!==w.maxItems)return!1;if(!w.items)return!0;for(let W=0;W<w.items.length;W++)if(!w2(w.items[W],z,U[W]))return!1;return!0}function TY(w,z,U){return T0(U)}function gY(w,z,U){return w.anyOf.some((W)=>w2(W,z,U))}function fY(w,z,U){if(!j6(U))return!1;if(z0(w.maxByteLength)&&!(U.length<=w.maxByteLength))return!1;if(z0(w.minByteLength)&&!(U.length>=w.minByteLength))return!1;return!0}function dY(w,z,U){return!0}function hY(w,z,U){return V0.IsVoidLike(U)}function yY(w,z,U){if(!y0.Has(w[N]))return!1;return y0.Get(w[N])(w,U)}function w2(w,z,U){let W=z0(w.$id)?e0(w,z):z,A=w;switch(A[N]){case"Any":return $Y(A,W,U);case"Array":return QY(A,W,U);case"AsyncIterator":return YY(A,W,U);case"BigInt":return JY(A,W,U);case"Boolean":return BY(A,W,U);case"Constructor":return MY(A,W,U);case"Date":return qY(A,W,U);case"Function":return HY(A,W,U);case"Import":return GY(A,W,U);case"Integer":return LY(A,W,U);case"Intersect":return NY(A,W,U);case"Iterator":return SY(A,W,U);case"Literal":return _Y(A,W,U);case"Never":return DY(A,W,U);case"Not":return PY(A,W,U);case"Null":return OY(A,W,U);case"Number":return bY(A,W,U);case"Object":return RY(A,W,U);case"Promise":return CY(A,W,U);case"Record":return KY(A,W,U);case"Ref":return FY(A,W,U);case"RegExp":return jY(A,W,U);case"String":return EY(A,W,U);case"Symbol":return IY(A,W,U);case"TemplateLiteral":return xY(A,W,U);case"This":return VY(A,W,U);case"Tuple":return kY(A,W,U);case"Undefined":return TY(A,W,U);case"Union":return gY(A,W,U);case"Uint8Array":return fY(A,W,U);case"Unknown":return dY(A,W,U);case"Void":return hY(A,W,U);default:if(!y0.Has(A[N]))throw new x7(A);return yY(A,W,U)}}function r(...w){return w.length===3?w2(w[0],w[1],w[2]):w2(w[0],[],w[1])}var S;(function(w){w[w.ArrayContains=0]="ArrayContains",w[w.ArrayMaxContains=1]="ArrayMaxContains",w[w.ArrayMaxItems=2]="ArrayMaxItems",w[w.ArrayMinContains=3]="ArrayMinContains",w[w.ArrayMinItems=4]="ArrayMinItems",w[w.ArrayUniqueItems=5]="ArrayUniqueItems",w[w.Array=6]="Array",w[w.AsyncIterator=7]="AsyncIterator",w[w.BigIntExclusiveMaximum=8]="BigIntExclusiveMaximum",w[w.BigIntExclusiveMinimum=9]="BigIntExclusiveMinimum",w[w.BigIntMaximum=10]="BigIntMaximum",w[w.BigIntMinimum=11]="BigIntMinimum",w[w.BigIntMultipleOf=12]="BigIntMultipleOf",w[w.BigInt=13]="BigInt",w[w.Boolean=14]="Boolean",w[w.DateExclusiveMaximumTimestamp=15]="DateExclusiveMaximumTimestamp",w[w.DateExclusiveMinimumTimestamp=16]="DateExclusiveMinimumTimestamp",w[w.DateMaximumTimestamp=17]="DateMaximumTimestamp",w[w.DateMinimumTimestamp=18]="DateMinimumTimestamp",w[w.DateMultipleOfTimestamp=19]="DateMultipleOfTimestamp",w[w.Date=20]="Date",w[w.Function=21]="Function",w[w.IntegerExclusiveMaximum=22]="IntegerExclusiveMaximum",w[w.IntegerExclusiveMinimum=23]="IntegerExclusiveMinimum",w[w.IntegerMaximum=24]="IntegerMaximum",w[w.IntegerMinimum=25]="IntegerMinimum",w[w.IntegerMultipleOf=26]="IntegerMultipleOf",w[w.Integer=27]="Integer",w[w.IntersectUnevaluatedProperties=28]="IntersectUnevaluatedProperties",w[w.Intersect=29]="Intersect",w[w.Iterator=30]="Iterator",w[w.Kind=31]="Kind",w[w.Literal=32]="Literal",w[w.Never=33]="Never",w[w.Not=34]="Not",w[w.Null=35]="Null",w[w.NumberExclusiveMaximum=36]="NumberExclusiveMaximum",w[w.NumberExclusiveMinimum=37]="NumberExclusiveMinimum",w[w.NumberMaximum=38]="NumberMaximum",w[w.NumberMinimum=39]="NumberMinimum",w[w.NumberMultipleOf=40]="NumberMultipleOf",w[w.Number=41]="Number",w[w.ObjectAdditionalProperties=42]="ObjectAdditionalProperties",w[w.ObjectMaxProperties=43]="ObjectMaxProperties",w[w.ObjectMinProperties=44]="ObjectMinProperties",w[w.ObjectRequiredProperty=45]="ObjectRequiredProperty",w[w.Object=46]="Object",w[w.Promise=47]="Promise",w[w.RegExp=48]="RegExp",w[w.StringFormatUnknown=49]="StringFormatUnknown",w[w.StringFormat=50]="StringFormat",w[w.StringMaxLength=51]="StringMaxLength",w[w.StringMinLength=52]="StringMinLength",w[w.StringPattern=53]="StringPattern",w[w.String=54]="String",w[w.Symbol=55]="Symbol",w[w.TupleLength=56]="TupleLength",w[w.Tuple=57]="Tuple",w[w.Uint8ArrayMaxByteLength=58]="Uint8ArrayMaxByteLength",w[w.Uint8ArrayMinByteLength=59]="Uint8ArrayMinByteLength",w[w.Uint8Array=60]="Uint8Array",w[w.Undefined=61]="Undefined",w[w.Union=62]="Union",w[w.Void=63]="Void"})(S||(S={}));class V7 extends y{constructor(w){super("Unknown type");this.schema=w}}function d1(w){return w.replace(/~/g,"~0").replace(/\//g,"~1")}function U0(w){return w!==void 0}class S6{constructor(w){this.iterator=w}[Symbol.iterator](){return this.iterator}First(){let w=this.iterator.next();return w.done?void 0:w.value}}function E(w,z,U,W,A=[]){return{type:w,schema:z,path:U,value:W,message:C7()({errorType:w,path:U,schema:z,value:W,errors:A}),errors:A}}function*cY(w,z,U,W){}function*iY(w,z,U,W){if(!n(W))return yield E(S.Array,w,U,W);if(U0(w.minItems)&&!(W.length>=w.minItems))yield E(S.ArrayMinItems,w,U,W);if(U0(w.maxItems)&&!(W.length<=w.maxItems))yield E(S.ArrayMaxItems,w,U,W);for(let Z=0;Z<W.length;Z++)yield*z2(w.items,z,`${U}/${Z}`,W[Z]);if(w.uniqueItems===!0&&!function(){let Z=new Set;for(let $ of W){let Q=e1($);if(Z.has(Q))return!1;else Z.add(Q)}return!0}())yield E(S.ArrayUniqueItems,w,U,W);if(!(U0(w.contains)||U0(w.minContains)||U0(w.maxContains)))return;let A=U0(w.contains)?w.contains:H0(),X=W.reduce((Z,$,Q)=>z2(A,z,`${U}${Q}`,$).next().done===!0?Z+1:Z,0);if(X===0)yield E(S.ArrayContains,w,U,W);if(d(w.minContains)&&X<w.minContains)yield E(S.ArrayMinContains,w,U,W);if(d(w.maxContains)&&X>w.maxContains)yield E(S.ArrayMaxContains,w,U,W)}function*vY(w,z,U,W){if(!t4(W))yield E(S.AsyncIterator,w,U,W)}function*nY(w,z,U,W){if(!A2(W))return yield E(S.BigInt,w,U,W);if(U0(w.exclusiveMaximum)&&!(W<w.exclusiveMaximum))yield E(S.BigIntExclusiveMaximum,w,U,W);if(U0(w.exclusiveMinimum)&&!(W>w.exclusiveMinimum))yield E(S.BigIntExclusiveMinimum,w,U,W);if(U0(w.maximum)&&!(W<=w.maximum))yield E(S.BigIntMaximum,w,U,W);if(U0(w.minimum)&&!(W>=w.minimum))yield E(S.BigIntMinimum,w,U,W);if(U0(w.multipleOf)&&W%w.multipleOf!==BigInt(0))yield E(S.BigIntMultipleOf,w,U,W)}function*uY(w,z,U,W){if(!G1(W))yield E(S.Boolean,w,U,W)}function*mY(w,z,U,W){yield*z2(w.returns,z,U,W.prototype)}function*tY(w,z,U,W){if(!G2(W))return yield E(S.Date,w,U,W);if(U0(w.exclusiveMaximumTimestamp)&&!(W.getTime()<w.exclusiveMaximumTimestamp))yield E(S.DateExclusiveMaximumTimestamp,w,U,W);if(U0(w.exclusiveMinimumTimestamp)&&!(W.getTime()>w.exclusiveMinimumTimestamp))yield E(S.DateExclusiveMinimumTimestamp,w,U,W);if(U0(w.maximumTimestamp)&&!(W.getTime()<=w.maximumTimestamp))yield E(S.DateMaximumTimestamp,w,U,W);if(U0(w.minimumTimestamp)&&!(W.getTime()>=w.minimumTimestamp))yield E(S.DateMinimumTimestamp,w,U,W);if(U0(w.multipleOfTimestamp)&&W.getTime()%w.multipleOfTimestamp!==0)yield E(S.DateMultipleOfTimestamp,w,U,W)}function*pY(w,z,U,W){if(!m1(W))yield E(S.Function,w,U,W)}function*oY(w,z,U,W){let A=globalThis.Object.values(w.$defs),X=w.$defs[w.$ref];yield*z2(X,[...z,...A],U,W)}function*lY(w,z,U,W){if(!l4(W))return yield E(S.Integer,w,U,W);if(U0(w.exclusiveMaximum)&&!(W<w.exclusiveMaximum))yield E(S.IntegerExclusiveMaximum,w,U,W);if(U0(w.exclusiveMinimum)&&!(W>w.exclusiveMinimum))yield E(S.IntegerExclusiveMinimum,w,U,W);if(U0(w.maximum)&&!(W<=w.maximum))yield E(S.IntegerMaximum,w,U,W);if(U0(w.minimum)&&!(W>=w.minimum))yield E(S.IntegerMinimum,w,U,W);if(U0(w.multipleOf)&&W%w.multipleOf!==0)yield E(S.IntegerMultipleOf,w,U,W)}function*sY(w,z,U,W){let A=!1;for(let X of w.allOf)for(let Z of z2(X,z,U,W))A=!0,yield Z;if(A)return yield E(S.Intersect,w,U,W);if(w.unevaluatedProperties===!1){let X=new RegExp(k1(w));for(let Z of Object.getOwnPropertyNames(W))if(!X.test(Z))yield E(S.IntersectUnevaluatedProperties,w,`${U}/${Z}`,W)}if(typeof w.unevaluatedProperties==="object"){let X=new RegExp(k1(w));for(let Z of Object.getOwnPropertyNames(W))if(!X.test(Z)){let $=z2(w.unevaluatedProperties,z,`${U}/${Z}`,W[Z]).next();if(!$.done)yield $.value}}}function*rY(w,z,U,W){if(!p4(W))yield E(S.Iterator,w,U,W)}function*aY(w,z,U,W){if(W!==w.const)yield E(S.Literal,w,U,W)}function*eY(w,z,U,W){yield E(S.Never,w,U,W)}function*wJ(w,z,U,W){if(z2(w.not,z,U,W).next().done===!0)yield E(S.Not,w,U,W)}function*zJ(w,z,U,W){if(!K1(W))yield E(S.Null,w,U,W)}function*UJ(w,z,U,W){if(!V0.IsNumberLike(W))return yield E(S.Number,w,U,W);if(U0(w.exclusiveMaximum)&&!(W<w.exclusiveMaximum))yield E(S.NumberExclusiveMaximum,w,U,W);if(U0(w.exclusiveMinimum)&&!(W>w.exclusiveMinimum))yield E(S.NumberExclusiveMinimum,w,U,W);if(U0(w.maximum)&&!(W<=w.maximum))yield E(S.NumberMaximum,w,U,W);if(U0(w.minimum)&&!(W>=w.minimum))yield E(S.NumberMinimum,w,U,W);if(U0(w.multipleOf)&&W%w.multipleOf!==0)yield E(S.NumberMultipleOf,w,U,W)}function*WJ(w,z,U,W){if(!V0.IsObjectLike(W))return yield E(S.Object,w,U,W);if(U0(w.minProperties)&&!(Object.getOwnPropertyNames(W).length>=w.minProperties))yield E(S.ObjectMinProperties,w,U,W);if(U0(w.maxProperties)&&!(Object.getOwnPropertyNames(W).length<=w.maxProperties))yield E(S.ObjectMaxProperties,w,U,W);let A=Array.isArray(w.required)?w.required:[],X=Object.getOwnPropertyNames(w.properties),Z=Object.getOwnPropertyNames(W);for(let $ of A){if(Z.includes($))continue;yield E(S.ObjectRequiredProperty,w.properties[$],`${U}/${d1($)}`,void 0)}if(w.additionalProperties===!1){for(let $ of Z)if(!X.includes($))yield E(S.ObjectAdditionalProperties,w,`${U}/${d1($)}`,W[$])}if(typeof w.additionalProperties==="object")for(let $ of Z){if(X.includes($))continue;yield*z2(w.additionalProperties,z,`${U}/${d1($)}`,W[$])}for(let $ of X){let Q=w.properties[$];if(w.required&&w.required.includes($)){if(yield*z2(Q,z,`${U}/${d1($)}`,W[$]),g1(w)&&!($ in W))yield E(S.ObjectRequiredProperty,Q,`${U}/${d1($)}`,void 0)}else if(V0.IsExactOptionalProperty(W,$))yield*z2(Q,z,`${U}/${d1($)}`,W[$])}}function*AJ(w,z,U,W){if(!o4(W))yield E(S.Promise,w,U,W)}function*XJ(w,z,U,W){if(!V0.IsRecordLike(W))return yield E(S.Object,w,U,W);if(U0(w.minProperties)&&!(Object.getOwnPropertyNames(W).length>=w.minProperties))yield E(S.ObjectMinProperties,w,U,W);if(U0(w.maxProperties)&&!(Object.getOwnPropertyNames(W).length<=w.maxProperties))yield E(S.ObjectMaxProperties,w,U,W);let[A,X]=Object.entries(w.patternProperties)[0],Z=new RegExp(A);for(let[$,Q]of Object.entries(W))if(Z.test($))yield*z2(X,z,`${U}/${d1($)}`,Q);if(typeof w.additionalProperties==="object"){for(let[$,Q]of Object.entries(W))if(!Z.test($))yield*z2(w.additionalProperties,z,`${U}/${d1($)}`,Q)}if(w.additionalProperties===!1)for(let[$,Q]of Object.entries(W)){if(Z.test($))continue;return yield E(S.ObjectAdditionalProperties,w,`${U}/${d1($)}`,Q)}}function*ZJ(w,z,U,W){yield*z2(J0(w,z),z,U,W)}function*$J(w,z,U,W){if(!$0(W))return yield E(S.String,w,U,W);if(U0(w.minLength)&&!(W.length>=w.minLength))yield E(S.StringMinLength,w,U,W);if(U0(w.maxLength)&&!(W.length<=w.maxLength))yield E(S.StringMaxLength,w,U,W);if(!new RegExp(w.source,w.flags).test(W))return yield E(S.RegExp,w,U,W)}function*QJ(w,z,U,W){if(!$0(W))return yield E(S.String,w,U,W);if(U0(w.minLength)&&!(W.length>=w.minLength))yield E(S.StringMinLength,w,U,W);if(U0(w.maxLength)&&!(W.length<=w.maxLength))yield E(S.StringMaxLength,w,U,W);if($0(w.pattern)){if(!new RegExp(w.pattern).test(W))yield E(S.StringPattern,w,U,W)}if($0(w.format)){if(!b0.Has(w.format))yield E(S.StringFormatUnknown,w,U,W);else if(!b0.Get(w.format)(W))yield E(S.StringFormat,w,U,W)}}function*YJ(w,z,U,W){if(!F1(W))yield E(S.Symbol,w,U,W)}function*JJ(w,z,U,W){if(!$0(W))return yield E(S.String,w,U,W);if(!new RegExp(w.pattern).test(W))yield E(S.StringPattern,w,U,W)}function*BJ(w,z,U,W){yield*z2(J0(w,z),z,U,W)}function*MJ(w,z,U,W){if(!n(W))return yield E(S.Tuple,w,U,W);if(w.items===void 0&&W.length!==0)return yield E(S.TupleLength,w,U,W);if(W.length!==w.maxItems)return yield E(S.TupleLength,w,U,W);if(!w.items)return;for(let A=0;A<w.items.length;A++)yield*z2(w.items[A],z,`${U}/${A}`,W[A])}function*qJ(w,z,U,W){if(!T0(W))yield E(S.Undefined,w,U,W)}function*HJ(w,z,U,W){if(r(w,z,W))return;let A=w.anyOf.map((X)=>new S6(z2(X,z,U,W)));yield E(S.Union,w,U,W,A)}function*GJ(w,z,U,W){if(!j6(W))return yield E(S.Uint8Array,w,U,W);if(U0(w.maxByteLength)&&!(W.length<=w.maxByteLength))yield E(S.Uint8ArrayMaxByteLength,w,U,W);if(U0(w.minByteLength)&&!(W.length>=w.minByteLength))yield E(S.Uint8ArrayMinByteLength,w,U,W)}function*LJ(w,z,U,W){}function*NJ(w,z,U,W){if(!V0.IsVoidLike(W))yield E(S.Void,w,U,W)}function*SJ(w,z,U,W){if(!y0.Get(w[N])(w,W))yield E(S.Kind,w,U,W)}function*z2(w,z,U,W){let A=U0(w.$id)?[...z,w]:z,X=w;switch(X[N]){case"Any":return yield*cY(X,A,U,W);case"Array":return yield*iY(X,A,U,W);case"AsyncIterator":return yield*vY(X,A,U,W);case"BigInt":return yield*nY(X,A,U,W);case"Boolean":return yield*uY(X,A,U,W);case"Constructor":return yield*mY(X,A,U,W);case"Date":return yield*tY(X,A,U,W);case"Function":return yield*pY(X,A,U,W);case"Import":return yield*oY(X,A,U,W);case"Integer":return yield*lY(X,A,U,W);case"Intersect":return yield*sY(X,A,U,W);case"Iterator":return yield*rY(X,A,U,W);case"Literal":return yield*aY(X,A,U,W);case"Never":return yield*eY(X,A,U,W);case"Not":return yield*wJ(X,A,U,W);case"Null":return yield*zJ(X,A,U,W);case"Number":return yield*UJ(X,A,U,W);case"Object":return yield*WJ(X,A,U,W);case"Promise":return yield*AJ(X,A,U,W);case"Record":return yield*XJ(X,A,U,W);case"Ref":return yield*ZJ(X,A,U,W);case"RegExp":return yield*$J(X,A,U,W);case"String":return yield*QJ(X,A,U,W);case"Symbol":return yield*YJ(X,A,U,W);case"TemplateLiteral":return yield*JJ(X,A,U,W);case"This":return yield*BJ(X,A,U,W);case"Tuple":return yield*MJ(X,A,U,W);case"Undefined":return yield*qJ(X,A,U,W);case"Union":return yield*HJ(X,A,U,W);case"Uint8Array":return yield*GJ(X,A,U,W);case"Unknown":return yield*LJ(X,A,U,W);case"Void":return yield*NJ(X,A,U,W);default:if(!y0.Has(X[N]))throw new V7(w);return yield*SJ(X,A,U,W)}}function _1(...w){let z=w.length===3?z2(w[0],w[1],"",w[2]):z2(w[0],[],"",w[1]);return new S6(z)}class C4 extends y{constructor(w,z,U){super("Unable to decode value as it does not match the expected schema");this.schema=w,this.value=z,this.error=U}}class L8 extends y{constructor(w,z,U,W){super(W instanceof Error?W.message:"Unknown error");this.schema=w,this.path=z,this.value=U,this.error=W}}function i0(w,z,U){try{return S0(w)?w[F0].Decode(U):U}catch(W){throw new L8(w,z,U,W)}}function _J(w,z,U,W){return n(W)?i0(w,U,W.map((A,X)=>W1(w.items,z,`${U}/${X}`,A))):i0(w,U,W)}function DJ(w,z,U,W){if(!s(W)||V2(W))return i0(w,U,W);let A=X8(w),X=A.map((B)=>B[0]),Z={...W};for(let[B,G]of A)if(B in Z)Z[B]=W1(G,z,`${U}/${B}`,Z[B]);if(!S0(w.unevaluatedProperties))return i0(w,U,Z);let $=Object.getOwnPropertyNames(Z),Q=w.unevaluatedProperties,Y={...Z};for(let B of $)if(!X.includes(B))Y[B]=i0(Q,`${U}/${B}`,Y[B]);return i0(w,U,Y)}function PJ(w,z,U,W){let A=globalThis.Object.values(w.$defs),X=w.$defs[w.$ref],Z=w[F0],$={[F0]:Z,...X};return W1($,[...z,...A],U,W)}function OJ(w,z,U,W){return i0(w,U,W1(w.not,z,U,W))}function bJ(w,z,U,W){if(!s(W))return i0(w,U,W);let A=O2(w),X={...W};for(let Y of A){if(!v(X,Y))continue;if(T0(X[Y])&&(!G4(w.properties[Y])||V0.IsExactOptionalProperty(X,Y)))continue;X[Y]=W1(w.properties[Y],z,`${U}/${Y}`,X[Y])}if(!d0(w.additionalProperties))return i0(w,U,X);let Z=Object.getOwnPropertyNames(X),$=w.additionalProperties,Q={...X};for(let Y of Z)if(!A.includes(Y))Q[Y]=i0($,`${U}/${Y}`,Q[Y]);return i0(w,U,Q)}function RJ(w,z,U,W){if(!s(W))return i0(w,U,W);let A=Object.getOwnPropertyNames(w.patternProperties)[0],X=new RegExp(A),Z={...W};for(let B of Object.getOwnPropertyNames(W))if(X.test(B))Z[B]=W1(w.patternProperties[A],z,`${U}/${B}`,Z[B]);if(!d0(w.additionalProperties))return i0(w,U,Z);let $=Object.getOwnPropertyNames(Z),Q=w.additionalProperties,Y={...Z};for(let B of $)if(!X.test(B))Y[B]=i0(Q,`${U}/${B}`,Y[B]);return i0(w,U,Y)}function CJ(w,z,U,W){let A=J0(w,z);return i0(w,U,W1(A,z,U,W))}function KJ(w,z,U,W){let A=J0(w,z);return i0(w,U,W1(A,z,U,W))}function FJ(w,z,U,W){return n(W)&&n(w.items)?i0(w,U,w.items.map((A,X)=>W1(A,z,`${U}/${X}`,W[X]))):i0(w,U,W)}function jJ(w,z,U,W){for(let A of w.anyOf){if(!r(A,z,W))continue;let X=W1(A,z,U,W);return i0(w,U,X)}return i0(w,U,W)}function W1(w,z,U,W){let A=e0(w,z),X=w;switch(w[N]){case"Array":return _J(X,A,U,W);case"Import":return PJ(X,A,U,W);case"Intersect":return DJ(X,A,U,W);case"Not":return OJ(X,A,U,W);case"Object":return bJ(X,A,U,W);case"Record":return RJ(X,A,U,W);case"Ref":return CJ(X,A,U,W);case"Symbol":return i0(X,U,W);case"This":return KJ(X,A,U,W);case"Tuple":return FJ(X,A,U,W);case"Union":return jJ(X,A,U,W);default:return i0(X,U,W)}}function l6(w,z,U){return W1(w,z,"",U)}class K4 extends y{constructor(w,z,U){super("The encoded value does not match the expected schema");this.schema=w,this.value=z,this.error=U}}class k7 extends y{constructor(w,z,U,W){super(`${W instanceof Error?W.message:"Unknown error"}`);this.schema=w,this.path=z,this.value=U,this.error=W}}function Y2(w,z,U){try{return S0(w)?w[F0].Encode(U):U}catch(W){throw new k7(w,z,U,W)}}function EJ(w,z,U,W){let A=Y2(w,U,W);return n(A)?A.map((X,Z)=>A1(w.items,z,`${U}/${Z}`,X)):A}function IJ(w,z,U,W){let A=globalThis.Object.values(w.$defs),X=w.$defs[w.$ref],Z=w[F0],$={[F0]:Z,...X};return A1($,[...z,...A],U,W)}function xJ(w,z,U,W){let A=Y2(w,U,W);if(!s(W)||V2(W))return A;let X=X8(w),Z=X.map((G)=>G[0]),$={...A};for(let[G,_]of X)if(G in $)$[G]=A1(_,z,`${U}/${G}`,$[G]);if(!S0(w.unevaluatedProperties))return $;let Q=Object.getOwnPropertyNames($),Y=w.unevaluatedProperties,B={...$};for(let G of Q)if(!Z.includes(G))B[G]=Y2(Y,`${U}/${G}`,B[G]);return B}function VJ(w,z,U,W){return Y2(w.not,U,Y2(w,U,W))}function kJ(w,z,U,W){let A=Y2(w,U,W);if(!s(A))return A;let X=O2(w),Z={...A};for(let B of X){if(!v(Z,B))continue;if(T0(Z[B])&&(!G4(w.properties[B])||V0.IsExactOptionalProperty(Z,B)))continue;Z[B]=A1(w.properties[B],z,`${U}/${B}`,Z[B])}if(!d0(w.additionalProperties))return Z;let $=Object.getOwnPropertyNames(Z),Q=w.additionalProperties,Y={...Z};for(let B of $)if(!X.includes(B))Y[B]=Y2(Q,`${U}/${B}`,Y[B]);return Y}function TJ(w,z,U,W){let A=Y2(w,U,W);if(!s(W))return A;let X=Object.getOwnPropertyNames(w.patternProperties)[0],Z=new RegExp(X),$={...A};for(let G of Object.getOwnPropertyNames(W))if(Z.test(G))$[G]=A1(w.patternProperties[X],z,`${U}/${G}`,$[G]);if(!d0(w.additionalProperties))return $;let Q=Object.getOwnPropertyNames($),Y=w.additionalProperties,B={...$};for(let G of Q)if(!Z.test(G))B[G]=Y2(Y,`${U}/${G}`,B[G]);return B}function gJ(w,z,U,W){let A=J0(w,z),X=A1(A,z,U,W);return Y2(w,U,X)}function fJ(w,z,U,W){let A=J0(w,z),X=A1(A,z,U,W);return Y2(w,U,X)}function dJ(w,z,U,W){let A=Y2(w,U,W);return n(w.items)?w.items.map((X,Z)=>A1(X,z,`${U}/${Z}`,A[Z])):[]}function hJ(w,z,U,W){for(let A of w.anyOf){if(!r(A,z,W))continue;let X=A1(A,z,U,W);return Y2(w,U,X)}for(let A of w.anyOf){let X=A1(A,z,U,W);if(!r(w,z,X))continue;return Y2(w,U,X)}return Y2(w,U,W)}function A1(w,z,U,W){let A=e0(w,z),X=w;switch(w[N]){case"Array":return EJ(X,A,U,W);case"Import":return IJ(X,A,U,W);case"Intersect":return xJ(X,A,U,W);case"Not":return VJ(X,A,U,W);case"Object":return kJ(X,A,U,W);case"Record":return TJ(X,A,U,W);case"Ref":return gJ(X,A,U,W);case"This":return fJ(X,A,U,W);case"Tuple":return dJ(X,A,U,W);case"Union":return hJ(X,A,U,W);default:return Y2(X,U,W)}}function s6(w,z,U){return A1(w,z,"",U)}function yJ(w,z){return S0(w)||U2(w.items,z)}function cJ(w,z){return S0(w)||U2(w.items,z)}function iJ(w,z){return S0(w)||U2(w.returns,z)||w.parameters.some((U)=>U2(U,z))}function vJ(w,z){return S0(w)||U2(w.returns,z)||w.parameters.some((U)=>U2(U,z))}function nJ(w,z){return S0(w)||S0(w.unevaluatedProperties)||w.allOf.some((U)=>U2(U,z))}function uJ(w,z){return S0(w)||U2(w.items,z)}function mJ(w,z){return S0(w)||U2(w.not,z)}function tJ(w,z){return S0(w)||Object.values(w.properties).some((U)=>U2(U,z))||d0(w.additionalProperties)&&U2(w.additionalProperties,z)}function pJ(w,z){return S0(w)||U2(w.item,z)}function oJ(w,z){let U=Object.getOwnPropertyNames(w.patternProperties)[0],W=w.patternProperties[U];return S0(w)||U2(W,z)||d0(w.additionalProperties)&&S0(w.additionalProperties)}function lJ(w,z){if(S0(w))return!0;return U2(J0(w,z),z)}function sJ(w,z){if(S0(w))return!0;return U2(J0(w,z),z)}function rJ(w,z){return S0(w)||!T0(w.items)&&w.items.some((U)=>U2(U,z))}function aJ(w,z){return S0(w)||w.anyOf.some((U)=>U2(U,z))}function U2(w,z){let U=e0(w,z),W=w;if(w.$id&&qw.has(w.$id))return!1;if(w.$id)qw.add(w.$id);switch(w[N]){case"Array":return yJ(W,U);case"AsyncIterator":return cJ(W,U);case"Constructor":return iJ(W,U);case"Function":return vJ(W,U);case"Intersect":return nJ(W,U);case"Iterator":return uJ(W,U);case"Not":return mJ(W,U);case"Object":return tJ(W,U);case"Promise":return pJ(W,U);case"Record":return oJ(W,U);case"Ref":return lJ(W,U);case"This":return sJ(W,U);case"Tuple":return rJ(W,U);case"Union":return aJ(W,U);default:return S0(w)}}var qw=new Set;function h1(w,z){return qw.clear(),U2(w,z)}class T7{constructor(w,z,U,W){this.schema=w,this.references=z,this.checkFunc=U,this.code=W,this.hasTransform=h1(w,z)}Code(){return this.code}Schema(){return this.schema}References(){return this.references}Errors(w){return _1(this.schema,this.references,w)}Check(w){return this.checkFunc(w)}Decode(w){if(!this.checkFunc(w))throw new C4(this.schema,w,this.Errors(w).First());return this.hasTransform?l6(this.schema,this.references,w):w}Encode(w){let z=this.hasTransform?s6(this.schema,this.references,w):w;if(!this.checkFunc(z))throw new K4(this.schema,w,this.Errors(w).First());return z}}var y1;(function(w){function z(X){return X===36}w.DollarSign=z;function U(X){return X===95}w.IsUnderscore=U;function W(X){return X>=65&&X<=90||X>=97&&X<=122}w.IsAlpha=W;function A(X){return X>=48&&X<=57}w.IsNumeric=A})(y1||(y1={}));var N8;(function(w){function z(X){if(X.length===0)return!1;return y1.IsNumeric(X.charCodeAt(0))}function U(X){if(z(X))return!1;for(let Z=0;Z<X.length;Z++){let $=X.charCodeAt(Z);if(!(y1.IsAlpha($)||y1.IsNumeric($)||y1.DollarSign($)||y1.IsUnderscore($)))return!1}return!0}function W(X){return X.replace(/'/g,"\\'")}function A(X,Z){return U(Z)?`${X}.${Z}`:`${X}['${W(Z)}']`}w.Encode=A})(N8||(N8={}));var Hw;(function(w){function z(U){let W=[];for(let A=0;A<U.length;A++){let X=U.charCodeAt(A);if(y1.IsNumeric(X)||y1.IsAlpha(X))W.push(U.charAt(A));else W.push(`_${X}_`)}return W.join("").replace(/__/g,"_")}w.Encode=z})(Hw||(Hw={}));var Gw;(function(w){function z(U){return U.replace(/'/g,"\\'")}w.Escape=z})(Gw||(Gw={}));class g7 extends y{constructor(w){super("Unknown type");this.schema=w}}class Lw extends y{constructor(w){super("Preflight validation check failed to guard for the given schema");this.schema=w}}var _6;(function(w){function z(Z,$,Q){return V0.ExactOptionalPropertyTypes?`('${$}' in ${Z} ? ${Q} : true)`:`(${N8.Encode(Z,$)} !== undefined ? ${Q} : true)`}w.IsExactOptionalProperty=z;function U(Z){return!V0.AllowArrayObject?`(typeof ${Z} === 'object' && ${Z} !== null && !Array.isArray(${Z}))`:`(typeof ${Z} === 'object' && ${Z} !== null)`}w.IsObjectLike=U;function W(Z){return!V0.AllowArrayObject?`(typeof ${Z} === 'object' && ${Z} !== null && !Array.isArray(${Z}) && !(${Z} instanceof Date) && !(${Z} instanceof Uint8Array))`:`(typeof ${Z} === 'object' && ${Z} !== null && !(${Z} instanceof Date) && !(${Z} instanceof Uint8Array))`}w.IsRecordLike=W;function A(Z){return V0.AllowNaN?`typeof ${Z} === 'number'`:`Number.isFinite(${Z})`}w.IsNumberLike=A;function X(Z){return V0.AllowNullVoid?`(${Z} === undefined || ${Z} === null)`:`${Z} === undefined`}w.IsVoidLike=X})(_6||(_6={}));var w6;(function(w){function z(M){return M[N]==="Any"||M[N]==="Unknown"}function*U(M,C,L){yield"true"}function*W(M,C,L){yield`Array.isArray(${L})`;let[u,V]=[b("value","any"),b("acc","number")];if(d(M.maxItems))yield`${L}.length <= ${M.maxItems}`;if(d(M.minItems))yield`${L}.length >= ${M.minItems}`;let k=q2(M.items,C,"value");if(yield`${L}.every((${u}) => ${k})`,f0(M.contains)||d(M.minContains)||d(M.maxContains)){let x0=f0(M.contains)?M.contains:H0(),N2=q2(x0,C,"value"),b1=d(M.minContains)?[`(count >= ${M.minContains})`]:[],e2=d(M.maxContains)?[`(count <= ${M.maxContains})`]:[],H1=`const count = value.reduce((${V}, ${u}) => ${N2} ? acc + 1 : acc, 0)`,v4=["(count > 0)",...b1,...e2].join(" && ");yield`((${u}) => { ${H1}; return ${v4}})(${L})`}if(M.uniqueItems===!0)yield`((${u}) => { 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*A(M,C,L){yield`(typeof value === 'object' && Symbol.asyncIterator in ${L})`}function*X(M,C,L){if(yield`(typeof ${L} === 'bigint')`,A2(M.exclusiveMaximum))yield`${L} < BigInt(${M.exclusiveMaximum})`;if(A2(M.exclusiveMinimum))yield`${L} > BigInt(${M.exclusiveMinimum})`;if(A2(M.maximum))yield`${L} <= BigInt(${M.maximum})`;if(A2(M.minimum))yield`${L} >= BigInt(${M.minimum})`;if(A2(M.multipleOf))yield`(${L} % BigInt(${M.multipleOf})) === 0`}function*Z(M,C,L){yield`(typeof ${L} === 'boolean')`}function*$(M,C,L){yield*o0(M.returns,C,`${L}.prototype`)}function*Q(M,C,L){if(yield`(${L} instanceof Date) && Number.isFinite(${L}.getTime())`,d(M.exclusiveMaximumTimestamp))yield`${L}.getTime() < ${M.exclusiveMaximumTimestamp}`;if(d(M.exclusiveMinimumTimestamp))yield`${L}.getTime() > ${M.exclusiveMinimumTimestamp}`;if(d(M.maximumTimestamp))yield`${L}.getTime() <= ${M.maximumTimestamp}`;if(d(M.minimumTimestamp))yield`${L}.getTime() >= ${M.minimumTimestamp}`;if(d(M.multipleOfTimestamp))yield`(${L}.getTime() % ${M.multipleOfTimestamp}) === 0`}function*Y(M,C,L){yield`(typeof ${L} === 'function')`}function*B(M,C,L){let u=globalThis.Object.getOwnPropertyNames(M.$defs).reduce((V,k)=>{return[...V,M.$defs[k]]},[]);yield*o0(P2(M.$ref),[...C,...u],L)}function*G(M,C,L){if(yield`Number.isInteger(${L})`,d(M.exclusiveMaximum))yield`${L} < ${M.exclusiveMaximum}`;if(d(M.exclusiveMinimum))yield`${L} > ${M.exclusiveMinimum}`;if(d(M.maximum))yield`${L} <= ${M.maximum}`;if(d(M.minimum))yield`${L} >= ${M.minimum}`;if(d(M.multipleOf))yield`(${L} % ${M.multipleOf}) === 0`}function*_(M,C,L){let u=M.allOf.map((V)=>q2(V,C,L)).join(" && ");if(M.unevaluatedProperties===!1){let V=j(`${new RegExp(k1(M))};`),k=`Object.getOwnPropertyNames(${L}).every(key => ${V}.test(key))`;yield`(${u} && ${k})`}else if(f0(M.unevaluatedProperties)){let V=j(`${new RegExp(k1(M))};`),k=`Object.getOwnPropertyNames(${L}).every(key => ${V}.test(key) || ${q2(M.unevaluatedProperties,C,`${L}[key]`)})`;yield`(${u} && ${k})`}else yield`(${u})`}function*H(M,C,L){yield`(typeof value === 'object' && Symbol.iterator in ${L})`}function*F(M,C,L){if(typeof M.const==="number"||typeof M.const==="boolean")yield`(${L} === ${M.const})`;else yield`(${L} === '${Gw.Escape(M.const)}')`}function*R(M,C,L){yield"false"}function*J(M,C,L){yield`(!${q2(M.not,C,L)})`}function*m(M,C,L){yield`(${L} === null)`}function*A0(M,C,L){if(yield _6.IsNumberLike(L),d(M.exclusiveMaximum))yield`${L} < ${M.exclusiveMaximum}`;if(d(M.exclusiveMinimum))yield`${L} > ${M.exclusiveMinimum}`;if(d(M.maximum))yield`${L} <= ${M.maximum}`;if(d(M.minimum))yield`${L} >= ${M.minimum}`;if(d(M.multipleOf))yield`(${L} % ${M.multipleOf}) === 0`}function*L0(M,C,L){if(yield _6.IsObjectLike(L),d(M.minProperties))yield`Object.getOwnPropertyNames(${L}).length >= ${M.minProperties}`;if(d(M.maxProperties))yield`Object.getOwnPropertyNames(${L}).length <= ${M.maxProperties}`;let u=Object.getOwnPropertyNames(M.properties);for(let V of u){let k=N8.Encode(L,V),x0=M.properties[V];if(M.required&&M.required.includes(V)){if(yield*o0(x0,C,k),g1(x0)||z(x0))yield`('${V}' in ${L})`}else{let N2=q2(x0,C,k);yield _6.IsExactOptionalProperty(L,V,N2)}}if(M.additionalProperties===!1)if(M.required&&M.required.length===u.length)yield`Object.getOwnPropertyNames(${L}).length === ${u.length}`;else{let V=`[${u.map((k)=>`'${k}'`).join(", ")}]`;yield`Object.getOwnPropertyNames(${L}).every(key => ${V}.includes(key))`}if(typeof M.additionalProperties==="object"){let V=q2(M.additionalProperties,C,`${L}[key]`),k=`[${u.map((x0)=>`'${x0}'`).join(", ")}]`;yield`(Object.getOwnPropertyNames(${L}).every(key => ${k}.includes(key) || ${V}))`}}function*h(M,C,L){yield`(typeof value === 'object' && typeof ${L}.then === 'function')`}function*a(M,C,L){if(yield _6.IsRecordLike(L),d(M.minProperties))yield`Object.getOwnPropertyNames(${L}).length >= ${M.minProperties}`;if(d(M.maxProperties))yield`Object.getOwnPropertyNames(${L}).length <= ${M.maxProperties}`;let[u,V]=Object.entries(M.patternProperties)[0],k=j(`${new RegExp(u)}`),x0=q2(V,C,"value"),N2=f0(M.additionalProperties)?q2(M.additionalProperties,C,L):M.additionalProperties===!1?"false":"true",b1=`(${k}.test(key) ? ${x0} : ${N2})`;yield`(Object.entries(${L}).every(([key, value]) => ${b1}))`}function*x(M,C,L){let u=J0(M,C);if(l0.functions.has(M.$ref))return yield`${x2(M.$ref)}(${L})`;yield*o0(u,C,L)}function*i(M,C,L){let u=j(`${new RegExp(M.source,M.flags)};`);if(yield`(typeof ${L} === 'string')`,d(M.maxLength))yield`${L}.length <= ${M.maxLength}`;if(d(M.minLength))yield`${L}.length >= ${M.minLength}`;yield`${u}.test(${L})`}function*K(M,C,L){if(yield`(typeof ${L} === 'string')`,d(M.maxLength))yield`${L}.length <= ${M.maxLength}`;if(d(M.minLength))yield`${L}.length >= ${M.minLength}`;if(M.pattern!==void 0)yield`${j(`${new RegExp(M.pattern)};`)}.test(${L})`;if(M.format!==void 0)yield`format('${M.format}', ${L})`}function*o(M,C,L){yield`(typeof ${L} === 'symbol')`}function*D0(M,C,L){yield`(typeof ${L} === 'string')`,yield`${j(`${new RegExp(M.pattern)};`)}.test(${L})`}function*l(M,C,L){yield`${x2(M.$ref)}(${L})`}function*O1(M,C,L){if(yield`Array.isArray(${L})`,M.items===void 0)return yield`${L}.length === 0`;yield`(${L}.length === ${M.maxItems})`;for(let u=0;u<M.items.length;u++)yield`${q2(M.items[u],C,`${L}[${u}]`)}`}function*C0(M,C,L){yield`${L} === undefined`}function*n1(M,C,L){yield`(${M.anyOf.map((V)=>q2(V,C,L)).join(" || ")})`}function*I2(M,C,L){if(yield`${L} instanceof Uint8Array`,d(M.maxByteLength))yield`(${L}.length <= ${M.maxByteLength})`;if(d(M.minByteLength))yield`(${L}.length >= ${M.minByteLength})`}function*Y6(M,C,L){yield"true"}function*g5(M,C,L){yield _6.IsVoidLike(L)}function*K6(M,C,L){let u=l0.instances.size;l0.instances.set(u,M),yield`kind('${M[N]}', ${u}, ${L})`}function*o0(M,C,L,u=!0){let V=$0(M.$id)?[...C,M]:C,k=M;if(u&&$0(M.$id)){let x0=x2(M.$id);if(l0.functions.has(x0))return yield`${x0}(${L})`;else{l0.functions.set(x0,"<deferred>");let N2=O(x0,M,C,"value",!1);return l0.functions.set(x0,N2),yield`${x0}(${L})`}}switch(k[N]){case"Any":return yield*U(k,V,L);case"Array":return yield*W(k,V,L);case"AsyncIterator":return yield*A(k,V,L);case"BigInt":return yield*X(k,V,L);case"Boolean":return yield*Z(k,V,L);case"Constructor":return yield*$(k,V,L);case"Date":return yield*Q(k,V,L);case"Function":return yield*Y(k,V,L);case"Import":return yield*B(k,V,L);case"Integer":return yield*G(k,V,L);case"Intersect":return yield*_(k,V,L);case"Iterator":return yield*H(k,V,L);case"Literal":return yield*F(k,V,L);case"Never":return yield*R(k,V,L);case"Not":return yield*J(k,V,L);case"Null":return yield*m(k,V,L);case"Number":return yield*A0(k,V,L);case"Object":return yield*L0(k,V,L);case"Promise":return yield*h(k,V,L);case"Record":return yield*a(k,V,L);case"Ref":return yield*x(k,V,L);case"RegExp":return yield*i(k,V,L);case"String":return yield*K(k,V,L);case"Symbol":return yield*o(k,V,L);case"TemplateLiteral":return yield*D0(k,V,L);case"This":return yield*l(k,V,L);case"Tuple":return yield*O1(k,V,L);case"Undefined":return yield*C0(k,V,L);case"Union":return yield*n1(k,V,L);case"Uint8Array":return yield*I2(k,V,L);case"Unknown":return yield*Y6(k,V,L);case"Void":return yield*g5(k,V,L);default:if(!y0.Has(k[N]))throw new g7(M);return yield*K6(k,V,L)}}let l0={language:"javascript",functions:new Map,variables:new Map,instances:new Map};function q2(M,C,L,u=!0){return`(${[...o0(M,C,L,u)].join(" && ")})`}function x2(M){return`check_${Hw.Encode(M)}`}function j(M){let C=`local_${l0.variables.size}`;return l0.variables.set(C,`const ${C} = ${M}`),C}function O(M,C,L,u,V=!0){let[k,x0]=[`
3
- `,(H1)=>"".padStart(H1," ")],N2=b("value","any"),b1=T("boolean"),e2=[...o0(C,L,u,V)].map((H1)=>`${x0(4)}${H1}`).join(` &&${k}`);return`function ${M}(${N2})${b1} {${k}${x0(2)}return (${k}${e2}${k}${x0(2)})
4
- }`}function b(M,C){let L=l0.language==="typescript"?`: ${C}`:"";return`${M}${L}`}function T(M){return l0.language==="typescript"?`: ${M}`:""}function t(M,C,L){let u=O("check",M,C,"value"),V=b("value","any"),k=T("boolean"),x0=[...l0.functions.values()],N2=[...l0.variables.values()],b1=$0(M.$id)?`return function check(${V})${k} {
5
- return ${x2(M.$id)}(value)
6
- }`:`return ${u}`;return[...N2,...x0,b1].join(`
7
- `)}function e(...M){let C={language:"javascript"},[L,u,V]=M.length===2&&n(M[1])?[M[0],M[1],C]:M.length===2&&!n(M[1])?[M[0],[],M[1]]:M.length===3?[M[0],M[1],M[2]]:M.length===1?[M[0],[],C]:[null,[],C];if(l0.language=V.language,l0.variables.clear(),l0.functions.clear(),l0.instances.clear(),!f0(L))throw new Lw(L);for(let k of u)if(!f0(k))throw new Lw(k);return t(L,u,V)}w.Code=e;function K0(M,C=[]){let L=e(M,C,{language:"javascript"}),u=globalThis.Function("kind","format","hash",L),V=new Map(l0.instances);function k(e2,H1,v4){if(!y0.Has(e2)||!V.has(H1))return!1;let XA=y0.Get(e2),ZA=V.get(H1);return XA(ZA,v4)}function x0(e2,H1){if(!b0.Has(e2))return!1;return b0.Get(e2)(H1)}function N2(e2){return e1(e2)}let b1=u(k,x0,N2);return new T7(M,C,b1,L)}w.Compile=K0})(w6||(w6={}));var eJ=function(w,z,U,W,A){if(W==="m")throw new TypeError("Private method is not writable");if(W==="a"&&!A)throw new TypeError("Private accessor was defined without a setter");if(typeof z==="function"?w!==z||!A:!z.has(w))throw new TypeError("Cannot write private member to an object whose class did not declare it");return W==="a"?A.call(w,U):A?A.value=U:z.set(w,U),U},d7=function(w,z,U,W){if(U==="a"&&!W)throw new TypeError("Private accessor was defined without a getter");if(typeof z==="function"?w!==z||!W:!z.has(w))throw new TypeError("Cannot read private member from an object whose class did not declare it");return U==="m"?W:U==="a"?W.call(w):W?W.value:z.get(w)},Nw,S8,h7;class y7 extends y{constructor(w){let z=w.First();super(z===void 0?"Invalid Value":z.message);Nw.add(this),S8.set(this,void 0),eJ(this,S8,w,"f"),this.error=z}Errors(){return new S6(d7(this,Nw,"m",h7).call(this))}}S8=new WeakMap,Nw=new WeakSet,h7=function*w(){if(this.error)yield this.error;yield*d7(this,S8,"f")};function f7(w,z,U){if(r(w,z,U))return;throw new y7(_1(w,z,U))}function _8(...w){return w.length===3?f7(w[0],w[1],w[2]):f7(w[0],[],w[1])}function wB(w){let z={};for(let U of Object.getOwnPropertyNames(w))z[U]=B0(w[U]);for(let U of Object.getOwnPropertySymbols(w))z[U]=B0(w[U]);return z}function zB(w){return w.map((z)=>B0(z))}function UB(w){return w.slice()}function WB(w){return new Map(B0([...w.entries()]))}function AB(w){return new Set(B0([...w.entries()]))}function XB(w){return new Date(w.toISOString())}function ZB(w){return w}function B0(w){if(n(w))return zB(w);if(G2(w))return XB(w);if(d2(w))return UB(w);if(Uz(w))return WB(w);if(Wz(w))return AB(w);if(s(w))return wB(w);if(V2(w))return ZB(w);throw new Error("ValueClone: Unable to clone value")}class p2 extends y{constructor(w,z){super(z);this.schema=w}}function M0(w){return m1(w)?w():B0(w)}function $B(w,z){if(v(w,"default"))return M0(w.default);else return{}}function QB(w,z){if(w.uniqueItems===!0&&!v(w,"default"))throw new p2(w,"Array with the uniqueItems constraint requires a default value");else if("contains"in w&&!v(w,"default"))throw new p2(w,"Array with the contains constraint requires a default value");else if("default"in w)return M0(w.default);else if(w.minItems!==void 0)return Array.from({length:w.minItems}).map((U)=>{return R2(w.items,z)});else return[]}function YB(w,z){if(v(w,"default"))return M0(w.default);else return async function*(){}()}function JB(w,z){if(v(w,"default"))return M0(w.default);else return BigInt(0)}function BB(w,z){if(v(w,"default"))return M0(w.default);else return!1}function MB(w,z){if(v(w,"default"))return M0(w.default);else{let U=R2(w.returns,z);if(typeof U==="object"&&!Array.isArray(U))return class{constructor(){for(let[W,A]of Object.entries(U)){let X=this;X[W]=A}}};else return class{}}}function qB(w,z){if(v(w,"default"))return M0(w.default);else if(w.minimumTimestamp!==void 0)return new Date(w.minimumTimestamp);else return new Date}function HB(w,z){if(v(w,"default"))return M0(w.default);else return()=>R2(w.returns,z)}function GB(w,z){let U=globalThis.Object.values(w.$defs),W=w.$defs[w.$ref];return R2(W,[...z,...U])}function LB(w,z){if(v(w,"default"))return M0(w.default);else if(w.minimum!==void 0)return w.minimum;else return 0}function NB(w,z){if(v(w,"default"))return M0(w.default);else{let U=w.allOf.reduce((W,A)=>{let X=R2(A,z);return typeof X==="object"?{...W,...X}:X},{});if(!r(w,z,U))throw new p2(w,"Intersect produced invalid value. Consider using a default value.");return U}}function SB(w,z){if(v(w,"default"))return M0(w.default);else return function*(){}()}function _B(w,z){if(v(w,"default"))return M0(w.default);else return w.const}function DB(w,z){if(v(w,"default"))return M0(w.default);else throw new p2(w,"Never types cannot be created. Consider using a default value.")}function PB(w,z){if(v(w,"default"))return M0(w.default);else throw new p2(w,"Not types must have a default value")}function OB(w,z){if(v(w,"default"))return M0(w.default);else return null}function bB(w,z){if(v(w,"default"))return M0(w.default);else if(w.minimum!==void 0)return w.minimum;else return 0}function RB(w,z){if(v(w,"default"))return M0(w.default);else{let U=new Set(w.required),W={};for(let[A,X]of Object.entries(w.properties)){if(!U.has(A))continue;W[A]=R2(X,z)}return W}}function CB(w,z){if(v(w,"default"))return M0(w.default);else return Promise.resolve(R2(w.item,z))}function KB(w,z){let[U,W]=Object.entries(w.patternProperties)[0];if(v(w,"default"))return M0(w.default);else if(!(U===x1||U===I1)){let A=U.slice(1,U.length-1).split("|"),X={};for(let Z of A)X[Z]=R2(W,z);return X}else return{}}function FB(w,z){if(v(w,"default"))return M0(w.default);else return R2(J0(w,z),z)}function jB(w,z){if(v(w,"default"))return M0(w.default);else throw new p2(w,"RegExp types cannot be created. Consider using a default value.")}function EB(w,z){if(w.pattern!==void 0)if(!v(w,"default"))throw new p2(w,"String types with patterns must specify a default value");else return M0(w.default);else if(w.format!==void 0)if(!v(w,"default"))throw new p2(w,"String types with formats must specify a default value");else return M0(w.default);else if(v(w,"default"))return M0(w.default);else if(w.minLength!==void 0)return Array.from({length:w.minLength}).map(()=>" ").join("");else return""}function IB(w,z){if(v(w,"default"))return M0(w.default);else if("value"in w)return Symbol.for(w.value);else return Symbol()}function xB(w,z){if(v(w,"default"))return M0(w.default);if(!w8(w))throw new p2(w,"Can only create template literals that produce a finite variants. Consider using a default value.");return f6(w)[0]}function VB(w,z){if(c7++>cB)throw new p2(w,"Cannot create recursive type as it appears possibly infinite. Consider using a default.");if(v(w,"default"))return M0(w.default);else return R2(J0(w,z),z)}function kB(w,z){if(v(w,"default"))return M0(w.default);if(w.items===void 0)return[];else return Array.from({length:w.minItems}).map((U,W)=>R2(w.items[W],z))}function TB(w,z){if(v(w,"default"))return M0(w.default);else return}function gB(w,z){if(v(w,"default"))return M0(w.default);else if(w.anyOf.length===0)throw new Error("ValueCreate.Union: Cannot create Union with zero variants");else return R2(w.anyOf[0],z)}function fB(w,z){if(v(w,"default"))return M0(w.default);else if(w.minByteLength!==void 0)return new Uint8Array(w.minByteLength);else return new Uint8Array(0)}function dB(w,z){if(v(w,"default"))return M0(w.default);else return{}}function hB(w,z){if(v(w,"default"))return M0(w.default);else return}function yB(w,z){if(v(w,"default"))return M0(w.default);else throw new Error("User defined types must specify a default value")}function R2(w,z){let U=e0(w,z),W=w;switch(W[N]){case"Any":return $B(W,U);case"Array":return QB(W,U);case"AsyncIterator":return YB(W,U);case"BigInt":return JB(W,U);case"Boolean":return BB(W,U);case"Constructor":return MB(W,U);case"Date":return qB(W,U);case"Function":return HB(W,U);case"Import":return GB(W,U);case"Integer":return LB(W,U);case"Intersect":return NB(W,U);case"Iterator":return SB(W,U);case"Literal":return _B(W,U);case"Never":return DB(W,U);case"Not":return PB(W,U);case"Null":return OB(W,U);case"Number":return bB(W,U);case"Object":return RB(W,U);case"Promise":return CB(W,U);case"Record":return KB(W,U);case"Ref":return FB(W,U);case"RegExp":return jB(W,U);case"String":return EB(W,U);case"Symbol":return IB(W,U);case"TemplateLiteral":return xB(W,U);case"This":return VB(W,U);case"Tuple":return kB(W,U);case"Undefined":return TB(W,U);case"Union":return gB(W,U);case"Uint8Array":return fB(W,U);case"Unknown":return dB(W,U);case"Void":return hB(W,U);default:if(!y0.Has(W[N]))throw new p2(W,"Unknown type");return yB(W,U)}}var cB=512,c7=0;function o2(...w){return c7=0,w.length===2?R2(w[0],w[1]):R2(w[0],[])}class Sw extends y{constructor(w,z){super(z);this.schema=w}}function iB(w,z,U){if(w[N]==="Object"&&typeof U==="object"&&!K1(U)){let W=w,A=Object.getOwnPropertyNames(U),X=Object.entries(W.properties),[Z,$]=[1/X.length,X.length];return X.reduce((Q,[Y,B])=>{let G=B[N]==="Literal"&&B.const===U[Y]?$:0,_=r(B,z,U[Y])?Z:0,H=A.includes(Y)?Z:0;return Q+(G+_+H)},0)}else return r(w,z,U)?1:0}function vB(w,z,U){let W=w.anyOf.map((Z)=>J0(Z,z)),[A,X]=[W[0],0];for(let Z of W){let $=iB(Z,z,U);if($>X)A=Z,X=$}return A}function nB(w,z,U){if("default"in w)return typeof U==="function"?w.default:B0(w.default);else{let W=vB(w,z,U);return _w(W,z,U)}}function uB(w,z,U){return r(w,z,U)?B0(U):o2(w,z)}function mB(w,z,U){return r(w,z,U)?U:o2(w,z)}function tB(w,z,U){if(r(w,z,U))return B0(U);let W=n(U)?B0(U):o2(w,z),A=d(w.minItems)&&W.length<w.minItems?[...W,...Array.from({length:w.minItems-W.length},()=>null)]:W,Z=(d(w.maxItems)&&A.length>w.maxItems?A.slice(0,w.maxItems):A).map((Q)=>X1(w.items,z,Q));if(w.uniqueItems!==!0)return Z;let $=[...new Set(Z)];if(!r(w,z,$))throw new Sw(w,"Array cast produced invalid data due to uniqueItems constraint");return $}function pB(w,z,U){if(r(w,z,U))return o2(w,z);let W=new Set(w.returns.required||[]),A=function(){};for(let[X,Z]of Object.entries(w.returns.properties)){if(!W.has(X)&&U.prototype[X]===void 0)continue;A.prototype[X]=X1(Z,z,U.prototype[X])}return A}function oB(w,z,U){let W=globalThis.Object.values(w.$defs),A=w.$defs[w.$ref];return X1(A,[...z,...W],U)}function lB(w,z,U){let W=o2(w,z),A=s(W)&&s(U)?{...W,...U}:U;return r(w,z,A)?A:o2(w,z)}function sB(w,z,U){throw new Sw(w,"Never types cannot be cast")}function rB(w,z,U){if(r(w,z,U))return U;if(U===null||typeof U!=="object")return o2(w,z);let W=new Set(w.required||[]),A={};for(let[X,Z]of Object.entries(w.properties)){if(!W.has(X)&&U[X]===void 0)continue;A[X]=X1(Z,z,U[X])}if(typeof w.additionalProperties==="object"){let X=Object.getOwnPropertyNames(w.properties);for(let Z of Object.getOwnPropertyNames(U)){if(X.includes(Z))continue;A[Z]=X1(w.additionalProperties,z,U[Z])}}return A}function aB(w,z,U){if(r(w,z,U))return B0(U);if(U===null||typeof U!=="object"||Array.isArray(U)||U instanceof Date)return o2(w,z);let W=Object.getOwnPropertyNames(w.patternProperties)[0],A=w.patternProperties[W],X={};for(let[Z,$]of Object.entries(U))X[Z]=X1(A,z,$);return X}function eB(w,z,U){return X1(J0(w,z),z,U)}function wM(w,z,U){return X1(J0(w,z),z,U)}function zM(w,z,U){if(r(w,z,U))return B0(U);if(!n(U))return o2(w,z);if(w.items===void 0)return[];return w.items.map((W,A)=>X1(W,z,U[A]))}function UM(w,z,U){return r(w,z,U)?B0(U):nB(w,z,U)}function X1(w,z,U){let W=$0(w.$id)?e0(w,z):z,A=w;switch(w[N]){case"Array":return tB(A,W,U);case"Constructor":return pB(A,W,U);case"Import":return oB(A,W,U);case"Intersect":return lB(A,W,U);case"Never":return sB(A,W,U);case"Object":return rB(A,W,U);case"Record":return aB(A,W,U);case"Ref":return eB(A,W,U);case"This":return wM(A,W,U);case"Tuple":return zM(A,W,U);case"Union":return UM(A,W,U);case"Date":case"Symbol":case"Uint8Array":return uB(w,z,U);default:return mB(A,W,U)}}function _w(...w){return w.length===3?X1(w[0],w[1],w[2]):X1(w[0],[],w[1])}function WM(w){return p1(w)&&w[N]!=="Unsafe"}function AM(w,z,U){if(!n(U))return U;return U.map((W)=>C2(w.items,z,W))}function XM(w,z,U){let W=globalThis.Object.values(w.$defs),A=w.$defs[w.$ref];return C2(A,[...z,...W],U)}function ZM(w,z,U){let W=w.unevaluatedProperties,X=w.allOf.map(($)=>C2($,z,B0(U))).reduce(($,Q)=>s(Q)?{...$,...Q}:Q,{});if(!s(U)||!s(X)||!p1(W))return X;let Z=O2(w);for(let $ of Object.getOwnPropertyNames(U)){if(Z.includes($))continue;if(r(W,z,U[$]))X[$]=C2(W,z,U[$])}return X}function $M(w,z,U){if(!s(U)||n(U))return U;let W=w.additionalProperties;for(let A of Object.getOwnPropertyNames(U)){if(v(w.properties,A)){U[A]=C2(w.properties[A],z,U[A]);continue}if(p1(W)&&r(W,z,U[A])){U[A]=C2(W,z,U[A]);continue}delete U[A]}return U}function QM(w,z,U){if(!s(U))return U;let W=w.additionalProperties,A=Object.getOwnPropertyNames(U),[X,Z]=Object.entries(w.patternProperties)[0],$=new RegExp(X);for(let Q of A){if($.test(Q)){U[Q]=C2(Z,z,U[Q]);continue}if(p1(W)&&r(W,z,U[Q])){U[Q]=C2(W,z,U[Q]);continue}delete U[Q]}return U}function YM(w,z,U){return C2(J0(w,z),z,U)}function JM(w,z,U){return C2(J0(w,z),z,U)}function BM(w,z,U){if(!n(U))return U;if(T0(w.items))return[];let W=Math.min(U.length,w.items.length);for(let A=0;A<W;A++)U[A]=C2(w.items[A],z,U[A]);return U.length>W?U.slice(0,W):U}function MM(w,z,U){for(let W of w.anyOf)if(WM(W)&&r(W,z,U))return C2(W,z,U);return U}function C2(w,z,U){let W=$0(w.$id)?e0(w,z):z,A=w;switch(A[N]){case"Array":return AM(A,W,U);case"Import":return XM(A,W,U);case"Intersect":return ZM(A,W,U);case"Object":return $M(A,W,U);case"Record":return QM(A,W,U);case"Ref":return YM(A,W,U);case"This":return JM(A,W,U);case"Tuple":return BM(A,W,U);case"Union":return MM(A,W,U);default:return U}}function D8(...w){return w.length===3?C2(w[0],w[1],w[2]):C2(w[0],[],w[1])}function P8(w){return $0(w)&&!isNaN(w)&&!isNaN(parseFloat(w))}function qM(w){return A2(w)||G1(w)||d(w)}function F4(w){return w===!0||d(w)&&w===1||A2(w)&&w===BigInt("1")||$0(w)&&(w.toLowerCase()==="true"||w==="1")}function j4(w){return w===!1||d(w)&&(w===0||Object.is(w,-0))||A2(w)&&w===BigInt("0")||$0(w)&&(w.toLowerCase()==="false"||w==="0"||w==="-0")}function HM(w){return $0(w)&&/^(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)$/i.test(w)}function GM(w){return $0(w)&&/^(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)?$/i.test(w)}function LM(w){return $0(w)&&/^\d\d\d\d-[0-1]\d-[0-3]\dt(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)$/i.test(w)}function NM(w){return $0(w)&&/^\d\d\d\d-[0-1]\d-[0-3]\dt(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)?$/i.test(w)}function SM(w){return $0(w)&&/^\d\d\d\d-[0-1]\d-[0-3]\d$/i.test(w)}function _M(w,z){let U=v7(w);return U===z?U:w}function DM(w,z){let U=n7(w);return U===z?U:w}function PM(w,z){let U=i7(w);return U===z?U:w}function OM(w,z){return $0(w.const)?_M(z,w.const):d(w.const)?DM(z,w.const):G1(w.const)?PM(z,w.const):z}function i7(w){return F4(w)?!0:j4(w)?!1:w}function bM(w){let z=(U)=>U.split(".")[0];return P8(w)?BigInt(z(w)):d(w)?BigInt(Math.trunc(w)):j4(w)?BigInt(0):F4(w)?BigInt(1):w}function v7(w){return F1(w)&&w.description!==void 0?w.description.toString():qM(w)?w.toString():w}function n7(w){return P8(w)?parseFloat(w):F4(w)?1:j4(w)?0:w}function RM(w){return P8(w)?parseInt(w):d(w)?w|0:F4(w)?1:j4(w)?0:w}function CM(w){return $0(w)&&w.toLowerCase()==="null"?null:w}function KM(w){return $0(w)&&w==="undefined"?void 0:w}function FM(w){return G2(w)?w:d(w)?new Date(w):F4(w)?new Date(1):j4(w)?new Date(0):P8(w)?new Date(parseInt(w)):GM(w)?new Date(`1970-01-01T${w}.000Z`):HM(w)?new Date(`1970-01-01T${w}`):NM(w)?new Date(`${w}.000Z`):LM(w)?new Date(w):SM(w)?new Date(`${w}T00:00:00.000Z`):w}function jM(w){return w}function EM(w,z,U){return(n(U)?U:[U]).map((A)=>Z1(w.items,z,A))}function IM(w,z,U){return bM(U)}function xM(w,z,U){return i7(U)}function VM(w,z,U){return FM(U)}function kM(w,z,U){let W=globalThis.Object.values(w.$defs),A=w.$defs[w.$ref];return Z1(A,[...z,...W],U)}function TM(w,z,U){return RM(U)}function gM(w,z,U){return w.allOf.reduce((W,A)=>Z1(A,z,W),U)}function fM(w,z,U){return OM(w,U)}function dM(w,z,U){return CM(U)}function hM(w,z,U){return n7(U)}function yM(w,z,U){if(!s(U))return U;for(let W of Object.getOwnPropertyNames(w.properties)){if(!v(U,W))continue;U[W]=Z1(w.properties[W],z,U[W])}return U}function cM(w,z,U){if(!s(U))return U;let A=Object.getOwnPropertyNames(w.patternProperties)[0],X=w.patternProperties[A];for(let[Z,$]of Object.entries(U))U[Z]=Z1(X,z,$);return U}function iM(w,z,U){return Z1(J0(w,z),z,U)}function vM(w,z,U){return v7(U)}function nM(w,z,U){return $0(U)||d(U)?Symbol(U):U}function uM(w,z,U){return Z1(J0(w,z),z,U)}function mM(w,z,U){if(!(n(U)&&!T0(w.items)))return U;return U.map((A,X)=>{return X<w.items.length?Z1(w.items[X],z,A):A})}function tM(w,z,U){return KM(U)}function pM(w,z,U){for(let W of w.anyOf){let A=Z1(W,z,B0(U));if(!r(W,z,A))continue;return A}return U}function Z1(w,z,U){let W=e0(w,z),A=w;switch(w[N]){case"Array":return EM(A,W,U);case"BigInt":return IM(A,W,U);case"Boolean":return xM(A,W,U);case"Date":return VM(A,W,U);case"Import":return kM(A,W,U);case"Integer":return TM(A,W,U);case"Intersect":return gM(A,W,U);case"Literal":return fM(A,W,U);case"Null":return dM(A,W,U);case"Number":return hM(A,W,U);case"Object":return yM(A,W,U);case"Record":return cM(A,W,U);case"Ref":return iM(A,W,U);case"String":return vM(A,W,U);case"Symbol":return nM(A,W,U);case"This":return uM(A,W,U);case"Tuple":return mM(A,W,U);case"Undefined":return tM(A,W,U);case"Union":return pM(A,W,U);default:return jM(U)}}function O8(...w){return w.length===3?Z1(w[0],w[1],w[2]):Z1(w[0],[],w[1])}function u7(...w){let[z,U,W]=w.length===3?[w[0],w[1],w[2]]:[w[0],[],w[1]];if(!r(z,U,W))throw new C4(z,W,_1(z,U,W).First());return h1(z,U)?l6(z,U,W):W}function c1(w,z){let U=v(w,"default")?w.default:void 0,W=m1(U)?U():B0(U);return T0(z)?W:s(z)&&s(W)?Object.assign(W,z):z}function Dw(w){return p1(w)&&"default"in w}function oM(w,z,U){if(n(U)){for(let A=0;A<U.length;A++)U[A]=L2(w.items,z,U[A]);return U}let W=c1(w,U);if(!n(W))return W;for(let A=0;A<W.length;A++)W[A]=L2(w.items,z,W[A]);return W}function lM(w,z,U){return G2(U)?U:c1(w,U)}function sM(w,z,U){let W=globalThis.Object.values(w.$defs),A=w.$defs[w.$ref];return L2(A,[...z,...W],U)}function rM(w,z,U){let W=c1(w,U);return w.allOf.reduce((A,X)=>{let Z=L2(X,z,W);return s(Z)?{...A,...Z}:Z},{})}function aM(w,z,U){let W=c1(w,U);if(!s(W))return W;let A=Object.getOwnPropertyNames(w.properties);for(let X of A){let Z=L2(w.properties[X],z,W[X]);if(T0(Z))continue;W[X]=L2(w.properties[X],z,W[X])}if(!Dw(w.additionalProperties))return W;for(let X of Object.getOwnPropertyNames(W)){if(A.includes(X))continue;W[X]=L2(w.additionalProperties,z,W[X])}return W}function eM(w,z,U){let W=c1(w,U);if(!s(W))return W;let A=w.additionalProperties,[X,Z]=Object.entries(w.patternProperties)[0],$=new RegExp(X);for(let Q of Object.getOwnPropertyNames(W)){if(!($.test(Q)&&Dw(Z)))continue;W[Q]=L2(Z,z,W[Q])}if(!Dw(A))return W;for(let Q of Object.getOwnPropertyNames(W)){if($.test(Q))continue;W[Q]=L2(A,z,W[Q])}return W}function wq(w,z,U){return L2(J0(w,z),z,c1(w,U))}function zq(w,z,U){return L2(J0(w,z),z,U)}function Uq(w,z,U){let W=c1(w,U);if(!n(W)||T0(w.items))return W;let[A,X]=[w.items,Math.max(w.items.length,W.length)];for(let Z=0;Z<X;Z++)if(Z<A.length)W[Z]=L2(A[Z],z,W[Z]);return W}function Wq(w,z,U){let W=c1(w,U);for(let A of w.anyOf){let X=L2(A,z,B0(W));if(r(A,z,X))return X}return W}function L2(w,z,U){let W=e0(w,z),A=w;switch(A[N]){case"Array":return oM(A,W,U);case"Date":return lM(A,W,U);case"Import":return sM(A,W,U);case"Intersect":return rM(A,W,U);case"Object":return aM(A,W,U);case"Record":return eM(A,W,U);case"Ref":return wq(A,W,U);case"This":return zq(A,W,U);case"Tuple":return Uq(A,W,U);case"Union":return Wq(A,W,U);default:return c1(A,U)}}function b8(...w){return w.length===3?L2(w[0],w[1],w[2]):L2(w[0],[],w[1])}var $1={};J6($1,{ValuePointerRootSetError:()=>Pw,ValuePointerRootDeleteError:()=>Ow,Set:()=>Aq,Has:()=>Zq,Get:()=>$q,Format:()=>E4,Delete:()=>Xq});class Pw extends y{constructor(w,z,U){super("Cannot set root value");this.value=w,this.path=z,this.update=U}}class Ow extends y{constructor(w,z){super("Cannot delete root value");this.value=w,this.path=z}}function m7(w){return w.indexOf("~")===-1?w:w.replace(/~1/g,"/").replace(/~0/g,"~")}function*E4(w){if(w==="")return;let[z,U]=[0,0];for(let W=0;W<w.length;W++)if(w.charAt(W)==="/")if(W===0)z=W+1;else U=W,yield m7(w.slice(z,U)),z=W+1;else U=W;yield m7(w.slice(z))}function Aq(w,z,U){if(z==="")throw new Pw(w,z,U);let[W,A,X]=[null,w,""];for(let Z of E4(z)){if(A[Z]===void 0)A[Z]={};W=A,A=A[Z],X=Z}W[X]=U}function Xq(w,z){if(z==="")throw new Ow(w,z);let[U,W,A]=[null,w,""];for(let X of E4(z)){if(W[X]===void 0||W[X]===null)return;U=W,W=W[X],A=X}if(Array.isArray(U)){let X=parseInt(A);U.splice(X,1)}else delete U[A]}function Zq(w,z){if(z==="")return!0;let[U,W,A]=[null,w,""];for(let X of E4(z)){if(W[X]===void 0)return!1;U=W,W=W[X],A=X}return Object.getOwnPropertyNames(U).includes(A)}function $q(w,z){if(z==="")return w;let U=w;for(let W of E4(z)){if(U[W]===void 0)return;U=U[W]}return U}function Qq(w,z){if(!s(z))return!1;let U=[...Object.keys(w),...Object.getOwnPropertySymbols(w)],W=[...Object.keys(z),...Object.getOwnPropertySymbols(z)];if(U.length!==W.length)return!1;return U.every((A)=>D6(w[A],z[A]))}function Yq(w,z){return G2(z)&&w.getTime()===z.getTime()}function Jq(w,z){if(!n(z)||w.length!==z.length)return!1;return w.every((U,W)=>D6(U,z[W]))}function Bq(w,z){if(!d2(z)||w.length!==z.length||Object.getPrototypeOf(w).constructor.name!==Object.getPrototypeOf(z).constructor.name)return!1;return w.every((U,W)=>D6(U,z[W]))}function Mq(w,z){return w===z}function D6(w,z){if(G2(w))return Yq(w,z);if(d2(w))return Bq(w,z);if(n(w))return Jq(w,z);if(s(w))return Qq(w,z);if(V2(w))return Mq(w,z);throw new Error("ValueEquals: Unable to compare value")}var qq=_0({type:X0("insert"),path:c2(),value:T1()}),Hq=_0({type:X0("update"),path:c2(),value:T1()}),Gq=_0({type:X0("delete"),path:c2()}),p7=G0([qq,Hq,Gq]);class bw extends y{constructor(w,z){super(z);this.value=w}}function R8(w,z){return{type:"update",path:w,value:z}}function o7(w,z){return{type:"insert",path:w,value:z}}function l7(w){return{type:"delete",path:w}}function t7(w){if(globalThis.Object.getOwnPropertySymbols(w).length>0)throw new bw(w,"Cannot diff objects with symbols")}function*Lq(w,z,U){if(t7(z),t7(U),!n5(U))return yield R8(w,U);let W=globalThis.Object.getOwnPropertyNames(z),A=globalThis.Object.getOwnPropertyNames(U);for(let X of A){if(v(z,X))continue;yield o7(`${w}/${X}`,U[X])}for(let X of W){if(!v(U,X))continue;if(D6(z,U))continue;yield*C8(`${w}/${X}`,z[X],U[X])}for(let X of W){if(v(U,X))continue;yield l7(`${w}/${X}`)}}function*Nq(w,z,U){if(!n(U))return yield R8(w,U);for(let W=0;W<Math.min(z.length,U.length);W++)yield*C8(`${w}/${W}`,z[W],U[W]);for(let W=0;W<U.length;W++){if(W<z.length)continue;yield o7(`${w}/${W}`,U[W])}for(let W=z.length-1;W>=0;W--){if(W<U.length)continue;yield l7(`${w}/${W}`)}}function*Sq(w,z,U){if(!d2(U)||z.length!==U.length||globalThis.Object.getPrototypeOf(z).constructor.name!==globalThis.Object.getPrototypeOf(U).constructor.name)return yield R8(w,U);for(let W=0;W<Math.min(z.length,U.length);W++)yield*C8(`${w}/${W}`,z[W],U[W])}function*_q(w,z,U){if(z===U)return;yield R8(w,U)}function*C8(w,z,U){if(n5(z))return yield*Lq(w,z,U);if(n(z))return yield*Nq(w,z,U);if(d2(z))return yield*Sq(w,z,U);if(V2(z))return yield*_q(w,z,U);throw new bw(z,"Unable to diff value")}function s7(w,z){return[...C8("",w,z)]}function Dq(w){return w.length>0&&w[0].path===""&&w[0].type==="update"}function Pq(w){return w.length===0}function r7(w,z){if(Dq(z))return B0(z[0].value);if(Pq(z))return B0(w);let U=B0(w);for(let W of z)switch(W.type){case"insert":{$1.Set(U,W.path,W.value);break}case"update":{$1.Set(U,W.path,W.value);break}case"delete":{$1.Delete(U,W.path);break}}return U}function a7(...w){let[z,U,W]=w.length===3?[w[0],w[1],w[2]]:[w[0],[],w[1]],A=h1(z,U)?s6(z,U,W):W;if(!r(z,U,A))throw new K4(z,A,_1(z,U,A).First());return A}function K8(w){return s(w)&&!n(w)}class Rw extends y{constructor(w){super(w)}}function Oq(w,z,U,W){if(!K8(U))$1.Set(w,z,B0(W));else{let A=Object.getOwnPropertyNames(U),X=Object.getOwnPropertyNames(W);for(let Z of A)if(!X.includes(Z))delete U[Z];for(let Z of X)if(!A.includes(Z))U[Z]=null;for(let Z of X)Cw(w,`${z}/${Z}`,U[Z],W[Z])}}function bq(w,z,U,W){if(!n(U))$1.Set(w,z,B0(W));else{for(let A=0;A<W.length;A++)Cw(w,`${z}/${A}`,U[A],W[A]);U.splice(W.length)}}function Rq(w,z,U,W){if(d2(U)&&U.length===W.length)for(let A=0;A<U.length;A++)U[A]=W[A];else $1.Set(w,z,B0(W))}function Cq(w,z,U,W){if(U===W)return;$1.Set(w,z,W)}function Cw(w,z,U,W){if(n(W))return bq(w,z,U,W);if(d2(W))return Rq(w,z,U,W);if(K8(W))return Oq(w,z,U,W);if(V2(W))return Cq(w,z,U,W)}function e7(w){return d2(w)||V2(w)}function Kq(w,z){return K8(w)&&n(z)||n(w)&&K8(z)}function wU(w,z){if(e7(w)||e7(z))throw new Rw("Only object and array types can be mutated at the root level");if(Kq(w,z))throw new Rw("Cannot assign due type mismatch of assignable values");Cw(w,"",w,z)}class Fw extends y{constructor(w){super(w)}}var Kw;(function(w){let z=new Map([["Clone",(X,Z,$)=>B0($)],["Clean",(X,Z,$)=>D8(X,Z,$)],["Default",(X,Z,$)=>b8(X,Z,$)],["Convert",(X,Z,$)=>O8(X,Z,$)],["Assert",(X,Z,$)=>{return _8(X,Z,$),$}],["Decode",(X,Z,$)=>h1(X,Z)?l6(X,Z,$):$],["Encode",(X,Z,$)=>h1(X,Z)?s6(X,Z,$):$]]);function U(X){z.delete(X)}w.Delete=U;function W(X,Z){z.set(X,Z)}w.Set=W;function A(X){return z.get(X)}w.Get=A})(Kw||(Kw={}));var zU=["Clone","Clean","Default","Convert","Assert","Decode"];function Fq(w,z,U,W){return w.reduce((A,X)=>{let Z=Kw.Get(X);if(T0(Z))throw new Fw(`Unable to find Parse operation '${X}'`);return Z(z,U,A)},W)}function UU(...w){let[z,U,W,A]=w.length===4?[w[0],w[1],w[2],w[3]]:w.length===3?n(w[0])?[w[0],w[1],[],w[2]]:[zU,w[0],w[1],w[2]]:w.length===2?[zU,w[0],[],w[1]]:(()=>{throw new Fw("Invalid Arguments")})();return Fq(z,U,W,A)}var p={};J6(p,{ValueErrorIterator:()=>S6,Patch:()=>r7,Parse:()=>UU,Mutate:()=>wU,Hash:()=>e1,Errors:()=>_1,Equal:()=>D6,Encode:()=>a7,Edit:()=>p7,Diff:()=>s7,Default:()=>b8,Decode:()=>u7,Create:()=>o2,Convert:()=>O8,Clone:()=>B0,Clean:()=>D8,Check:()=>r,Cast:()=>_w,Assert:()=>_8});var y8=n4(ZU(),1),mU=n4(F8(),1);var b6=n4(F8(),1),sU=n4(F8(),1);var cw={date:EU,time:fw(!0),"date-time":JU(!0),"iso-time":fw(!1),"iso-date-time":JU(!1),duration:/^P(?!$)((\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+S)?)?|(\d+W)?)$/,uri:sq,"uri-reference":/^(?:[a-z][a-z0-9+\-.]*:)?(?:\/?\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:]|%[0-9a-f]{2})*@)?(?:\[(?:(?:(?:(?:[0-9a-f]{1,4}:){6}|::(?:[0-9a-f]{1,4}:){5}|(?:[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){4}|(?:(?:[0-9a-f]{1,4}:){0,1}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){3}|(?:(?:[0-9a-f]{1,4}:){0,2}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){2}|(?:(?:[0-9a-f]{1,4}:){0,3}[0-9a-f]{1,4})?::[0-9a-f]{1,4}:|(?:(?:[0-9a-f]{1,4}:){0,4}[0-9a-f]{1,4})?::)(?:[0-9a-f]{1,4}:[0-9a-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?))|(?:(?:[0-9a-f]{1,4}:){0,5}[0-9a-f]{1,4})?::[0-9a-f]{1,4}|(?:(?:[0-9a-f]{1,4}:){0,6}[0-9a-f]{1,4})?::)|[Vv][0-9a-f]+\.[a-z0-9\-._~!$&'()*+,;=:]+)\]|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)|(?:[a-z0-9\-._~!$&'"()*+,;=]|%[0-9a-f]{2})*)(?::\d*)?(?:\/(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})*)*|\/(?:(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})*)*)?|(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})*)*)?(?:\?(?:[a-z0-9\-._~!$&'"()*+,;=:@/?]|%[0-9a-f]{2})*)?(?:#(?:[a-z0-9\-._~!$&'"()*+,;=:@/?]|%[0-9a-f]{2})*)?$/i,"uri-template":/^(?:(?:[^\x00-\x20"'<>%\\^`{|}]|%[0-9a-f]{2})|\{[+#./;?&=,!@|]?(?:[a-z0-9_]|%[0-9a-f]{2})+(?::[1-9][0-9]{0,3}|\*)?(?:,(?:[a-z0-9_]|%[0-9a-f]{2})+(?::[1-9][0-9]{0,3}|\*)?)*\})*$/i,url:/^(?:https?|ftp):\/\/(?:\S+(?::\S*)?@)?(?:(?!(?:10|127)(?:\.\d{1,3}){3})(?!(?:169\.254|192\.168)(?:\.\d{1,3}){2})(?!172\.(?:1[6-9]|2\d|3[0-1])(?:\.\d{1,3}){2})(?:[1-9]\d?|1\d\d|2[01]\d|22[0-3])(?:\.(?:1?\d{1,2}|2[0-4]\d|25[0-5])){2}(?:\.(?:[1-9]\d?|1\d\d|2[0-4]\d|25[0-4]))|(?:(?:[a-z0-9\u{00a1}-\u{ffff}]+-)*[a-z0-9\u{00a1}-\u{ffff}]+)(?:\.(?:[a-z0-9\u{00a1}-\u{ffff}]+-)*[a-z0-9\u{00a1}-\u{ffff}]+)*(?:\.(?:[a-z\u{00a1}-\u{ffff}]{2,})))(?::\d{2,5})?(?:\/[^\s]*)?$/iu,email:/^[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$/i,hostname:/^(?=.{1,253}\.?$)[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?(?:\.[a-z0-9](?:[-0-9a-z]{0,61}[0-9a-z])?)*\.?$/i,ipv4:/^(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)$/,ipv6:/^((([0-9a-f]{1,4}:){7}([0-9a-f]{1,4}|:))|(([0-9a-f]{1,4}:){6}(:[0-9a-f]{1,4}|((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9a-f]{1,4}:){5}(((:[0-9a-f]{1,4}){1,2})|:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9a-f]{1,4}:){4}(((:[0-9a-f]{1,4}){1,3})|((:[0-9a-f]{1,4})?:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){3}(((:[0-9a-f]{1,4}){1,4})|((:[0-9a-f]{1,4}){0,2}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){2}(((:[0-9a-f]{1,4}){1,5})|((:[0-9a-f]{1,4}){0,3}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){1}(((:[0-9a-f]{1,4}){1,6})|((:[0-9a-f]{1,4}){0,4}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(:(((:[0-9a-f]{1,4}){1,7})|((:[0-9a-f]{1,4}){0,5}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:)))$/i,regex:WH,uuid:/^(?:urn:uuid:)?[0-9a-f]{8}-(?:[0-9a-f]{4}-){3}[0-9a-f]{12}$/i,"json-pointer":/^(?:\/(?:[^~/]|~0|~1)*)*$/,"json-pointer-uri-fragment":/^#(?:\/(?:[a-z0-9_\-.!$&'()*+,;:=@]|%[0-9a-f]{2}|~0|~1)*)*$/i,"relative-json-pointer":/^(?:0|[1-9][0-9]*)(?:#|(?:\/(?:[^~/]|~0|~1)*)*)$/,byte:rq,int32:{type:"number",validate:wH},int64:{type:"number",validate:zH},float:{type:"number",validate:MU},double:{type:"number",validate:MU},password:!0,binary:!0};function nq(w){return w%4===0&&(w%100!==0||w%400===0)}var uq=/^(\d\d\d\d)-(\d\d)-(\d\d)$/,mq=[0,31,28,31,30,31,30,31,31,30,31,30,31];function EU(w){let z=uq.exec(w);if(!z)return!1;let U=+z[1],W=+z[2],A=+z[3];return W>=1&&W<=12&&A>=1&&A<=(W===2&&nq(U)?29:mq[W])}var tq=/^(\d\d):(\d\d):(\d\d(?:\.\d+)?)(z|([+-])(\d\d)(?::?(\d\d))?)?$/i;function fw(w){return function z(U){let W=tq.exec(U);if(!W)return!1;let A=+W[1],X=+W[2],Z=+W[3],$=W[4],Q=W[5]==="-"?-1:1,Y=+(W[6]||0),B=+(W[7]||0);if(Y>23||B>59||w&&!$)return!1;if(A<=23&&X<=59&&Z<60)return!0;let G=X-B*Q,_=A-Y*Q-(G<0?1:0);return(_===23||_===-1)&&(G===59||G===-1)&&Z<61}}var pq=/t|\s/i;function JU(w){let z=fw(w);return function U(W){let A=W.split(pq);return A.length===2&&EU(A[0])&&z(A[1])}}var oq=/\/|:/,lq=/^(?:[a-z][a-z0-9+\-.]*:)(?:\/?\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:]|%[0-9a-f]{2})*@)?(?:\[(?:(?:(?:(?:[0-9a-f]{1,4}:){6}|::(?:[0-9a-f]{1,4}:){5}|(?:[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){4}|(?:(?:[0-9a-f]{1,4}:){0,1}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){3}|(?:(?:[0-9a-f]{1,4}:){0,2}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){2}|(?:(?:[0-9a-f]{1,4}:){0,3}[0-9a-f]{1,4})?::[0-9a-f]{1,4}:|(?:(?:[0-9a-f]{1,4}:){0,4}[0-9a-f]{1,4})?::)(?:[0-9a-f]{1,4}:[0-9a-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?))|(?:(?:[0-9a-f]{1,4}:){0,5}[0-9a-f]{1,4})?::[0-9a-f]{1,4}|(?:(?:[0-9a-f]{1,4}:){0,6}[0-9a-f]{1,4})?::)|[Vv][0-9a-f]+\.[a-z0-9\-._~!$&'()*+,;=:]+)\]|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)|(?:[a-z0-9\-._~!$&'()*+,;=]|%[0-9a-f]{2})*)(?::\d*)?(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*|\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*)?|(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*)(?:\?(?:[a-z0-9\-._~!$&'()*+,;=:@/?]|%[0-9a-f]{2})*)?(?:#(?:[a-z0-9\-._~!$&'()*+,;=:@/?]|%[0-9a-f]{2})*)?$/i;function sq(w){return oq.test(w)&&lq.test(w)}var BU=/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/gm;function rq(w){return BU.lastIndex=0,BU.test(w)}var aq=-2147483648,eq=2147483647;function wH(w){return Number.isInteger(w)&&w<=eq&&w>=aq}function zH(w){return Number.isInteger(w)}function MU(){return!0}var UH=/[^\\]\\Z/;function WH(w){if(UH.test(w))return!1;try{return new RegExp(w),!0}catch(z){return!1}}var IU="toJSON"in new Headers,j8=(w,z)=>{let U=new URL(w);return U.pathname=z,U.toString()},AH=(w)=>typeof w==="function"&&/^\s*class\s+/.test(w.toString())||w.toString().startsWith("[object ")&&w.toString()!=="[object Object]"||s2(Object.getPrototypeOf(w)),Ew=(w)=>w&&typeof w==="object"&&!Array.isArray(w),F2=(w,z,{skipKeys:U,override:W=!0}={})=>{if(!Ew(w)||!Ew(z))return w;for(let[A,X]of Object.entries(z)){if(U?.includes(A))continue;if(!Ew(X)||!(A in w)||AH(X)){if(W||!(A in w))w[A]=X;continue}w[A]=F2(w[A],X,{skipKeys:U,override:W})}return w},XH=(w,z)=>{let{properties:U,...W}=w??{},{properties:A,...X}=z??{};return F2(W,X)},v0=(w=[],z=[])=>{if(!w)return[];if(!z)return w;let U=[],W=[];if(!Array.isArray(w))w=[w];if(!Array.isArray(z))z=[z];for(let A of w)if(U.push(A),A.checksum)W.push(A.checksum);for(let A of z)if(!W.includes(A.checksum))U.push(A);return U},ZH=["start","request","parse","transform","resolve","beforeHandle","afterHandle","mapResponse","afterResponse","trace","error","stop","body","headers","params","query","response","type","detail"],$H=ZH.reduce((w,z)=>(w[z]=!0,w),{}),xU=(w,z)=>{let U=(W)=>typeof W==="object"&&Object.keys(W).every(iw);if(U(w)&&U(z))return{...w,...z};else if(w&&!U(w)&&U(z))return{200:w,...z};return z??w},I4=(w,z)=>{return{body:z?.body??w?.body,headers:z?.headers??w?.headers,params:z?.params??w?.params,query:z?.query??w?.query,cookie:z?.cookie??w?.cookie,response:xU(w?.response,z?.response)}},D1=(w,z)=>{let{resolve:U,...W}=w??{},{resolve:A,...X}=z??{};return{...W,...X,body:z?.body??w?.body,headers:z?.headers??w?.headers,params:z?.params??w?.params,query:z?.query??w?.query,cookie:z?.cookie??w?.cookie,response:xU(w?.response,z?.response),type:w?.type||z?.type,detail:F2(z?.detail??{},w?.detail??{}),parse:v0(w?.parse,z?.parse),transform:v0(w?.transform,z?.transform),beforeHandle:v0(v0(W2(U,"resolve"),w?.beforeHandle),v0(W2(A,"resolve"),z?.beforeHandle)),afterHandle:v0(w?.afterHandle,z?.afterHandle),mapResponse:v0(w?.mapResponse,z?.mapResponse),afterResponse:v0(w?.afterResponse,z?.afterResponse),trace:v0(w?.trace,z?.trace),error:v0(w?.error,z?.error)}},dw=(w,z,U=!0)=>{if(!Array.isArray(z))return B2(w,z,U);for(let W of z)w=B2(w,W,U);return w},B2=(w,z,U=!0)=>{if(!w)return w;if(z.untilObjectFound&&!U&&w.type==="object")return w;let W=z.from[N];if(w.oneOf){for(let Z=0;Z<w.oneOf.length;Z++)w.oneOf[Z]=B2(w.oneOf[Z],z,U);return w}if(w.anyOf){for(let Z=0;Z<w.anyOf.length;Z++)w.anyOf[Z]=B2(w.anyOf[Z],z,U);return w}if(w.allOf){for(let Z=0;Z<w.allOf.length;Z++)w.allOf[Z]=B2(w.allOf[Z],z,U);return w}if(w.not){for(let Z=0;Z<w.not.length;Z++)w.not[Z]=B2(w.not[Z],z,U);return w}let A=U&&!!z.excludeRoot;if(w[N]===W){let{anyOf:Z,oneOf:$,allOf:Q,not:Y,properties:B,items:G,..._}=w,H=z.to(_),F,R=(J)=>{if(B&&J.type==="object"){let A0={};for(let[L0,h]of Object.entries(B))A0[L0]=B2(h,z,!1);return{..._,...J,properties:A0}}if(G&&J.type==="array")return{..._,...J,items:B2(G,z,!1)};let m={..._,...J};if(delete m.required,B&&J.type==="string"&&J.format==="ObjectString"&&J.default==="{}")F=I.ObjectString(B,_),m.default=JSON.stringify(p.Create(I.Object(B))),m.properties=B;if(G&&J.type==="string"&&J.format==="ArrayString"&&J.default==="[]")F=I.ArrayString(G,_),m.default=JSON.stringify(p.Create(I.Array(G))),m.items=G;return m};if(A){if(B){let J={};for(let[m,A0]of Object.entries(B))J[m]=B2(A0,z,!1);return{..._,properties:J}}else if(G?.map)return{..._,items:G.map((J)=>B2(J,z,!1))};return _}if(H.anyOf)for(let J=0;J<H.anyOf.length;J++)H.anyOf[J]=R(H.anyOf[J]);else if(H.oneOf)for(let J=0;J<H.oneOf.length;J++)H.oneOf[J]=R(H.oneOf[J]);else if(H.allOf)for(let J=0;J<H.allOf.length;J++)H.allOf[J]=R(H.allOf[J]);else if(H.not)for(let J=0;J<H.not.length;J++)H.not[J]=R(H.not[J]);if(F)H[F0]=F[F0];if(H.anyOf||H.oneOf||H.allOf||H.not)return H;if(B){let J={};for(let[m,A0]of Object.entries(B))J[m]=B2(A0,z,!1);return{..._,...H,properties:J}}else if(G?.map)return{..._,...H,items:G.map((J)=>B2(J,z,!1))};return{..._,...H}}let X=w?.properties;if(X&&U&&z.rootOnly!==!0)for(let[Z,$]of Object.entries(X))switch($[N]){case W:let{anyOf:Q,oneOf:Y,allOf:B,not:G,type:_,...H}=$,F=z.to(H);if(F.anyOf)for(let R=0;R<F.anyOf.length;R++)F.anyOf[R]={...H,...F.anyOf[R]};else if(F.oneOf)for(let R=0;R<F.oneOf.length;R++)F.oneOf[R]={...H,...F.oneOf[R]};else if(F.allOf)for(let R=0;R<F.allOf.length;R++)F.allOf[R]={...H,...F.allOf[R]};else if(F.not)for(let R=0;R<F.not.length;R++)F.not[R]={...H,...F.not[R]};X[Z]={...H,...B2(H,z,!1)};break;case"Object":case"Union":X[Z]=B2($,z,!1);break;default:if($.items)for(let R=0;R<$.items.length;R++)$.items[R]=B2($.items[R],z,!1);else if($.anyOf||$.oneOf||$.allOf||$.not)X[Z]=B2($,z,!1);break}return w},k4=(w)=>(z)=>{if(typeof z==="object")try{return p.Clean(w,structuredClone(z))}catch{try{return p.Clean(w,z)}catch{return z}}return z},j2=(w,{models:z={},dynamic:U=!1,modules:W,normalize:A=!1,additionalProperties:X=!1,coerce:Z=!1,additionalCoerce:$=[]}={modules:I.Module({})})=>{if(!w)return;if(typeof w==="string"&&!(w in z))return;let Q=typeof w==="string"?W.Import(w)??z[w]:w;if(Z||$)if(Z)Q=dw(Q,[{from:I.Ref(""),to:(B)=>W.Import(B.$ref)},{from:I.Number(),to:(B)=>I.Numeric(B),untilObjectFound:!0},{from:I.Boolean(),to:(B)=>I.BooleanString(B),untilObjectFound:!0},...Array.isArray($)?$:[$]]);else Q=dw(Q,[{from:I.Ref(""),to:(B)=>W.Import(B.$ref)},...Array.isArray($)?$:[$]]);if(Q.type==="object"&&"additionalProperties"in Q===!1)Q.additionalProperties=X;if(U){let B={schema:Q,references:"",checkFunc:()=>{},code:"",Check:(G)=>p.Check(Q,G),Errors:(G)=>p.Errors(Q,G),Code:()=>"",Clean:k4(Q),Decode:(G)=>p.Decode(Q,G),Encode:(G)=>p.Encode(Q,G)};if(A&&Q.additionalProperties===!1)B.Clean=k4(Q);if(Q.config){if(B.config=Q.config,B?.schema?.config)delete B.schema.config}return B.parse=(G)=>{try{return B.Decode(G)}catch(_){throw[...B.Errors(G)].map(J1)}},B.safeParse=(G)=>{try{return{success:!0,data:B.Decode(G),error:null}}catch(_){let H=[...Y.Errors(G)].map(J1);return{success:!1,data:null,error:H[0]?.summary,errors:H}}},B}let Y=w6.Compile(Q,Object.values(z));if(Y.Clean=k4(Q),Q.config){if(Y.config=Q.config,Y?.schema?.config)delete Y.schema.config}return Y.parse=(B)=>{try{return Y.Decode(B)}catch(G){throw[...Y.Errors(B)].map(J1)}},Y.safeParse=(B)=>{try{return{success:!0,data:Y.Decode(B),error:null}}catch(G){let _=[...Y.Errors(B)].map(J1);return{success:!1,data:null,error:_[0]?.summary,errors:_}}},Y},qU=(w,{models:z={},modules:U,dynamic:W=!1,normalize:A=!1,additionalProperties:X=!1})=>{if(!w)return;if(typeof w==="string"&&!(w in z))return;let Z=typeof w==="string"?U.Import(w)??z[w]:w,$=(Y,B)=>{if(W)return{schema:Y,references:"",checkFunc:()=>{},code:"",Check:(_)=>p.Check(Y,_),Errors:(_)=>p.Errors(Y,_),Code:()=>"",Clean:k4(Y),Decode:(_)=>p.Decode(Y,_),Encode:(_)=>p.Encode(Y,_)};let G=w6.Compile(Y,B);if(A&&Y.additionalProperties===!1)G.Clean=k4(Y);return G};if(N in Z){if("additionalProperties"in Z===!1)Z.additionalProperties=X;return{200:$(Z,Object.values(z))}}let Q={};return Object.keys(Z).forEach((Y)=>{let B=Z[+Y];if(typeof B==="string"){if(B in z){let G=z[B];G.type==="object"&&"additionalProperties"in G,Q[+Y]=N in G?$(G,Object.values(z)):G}return}if(B.type==="object"&&"additionalProperties"in B===!1)B.additionalProperties=X;Q[+Y]=N in B?$(B,Object.values(z)):B}),Q},QH=typeof Bun!=="undefined",YH=QH&&typeof Bun.hash==="function",x4=(w)=>{if(YH)return Bun.hash(w);let z=9;for(let U=0;U<w.length;)z=Math.imul(z^w.charCodeAt(U++),387420489);return z=z^z>>>9},Iw,P6=()=>{if(!Iw)Iw=[{from:I.Object({}),to:()=>I.ObjectString({}),excludeRoot:!0},{from:I.Array(I.Any()),to:()=>I.ArrayString(I.Any())}];return Iw},xw,HU=()=>{if(!xw)xw=[{from:I.Number(),to:(w)=>I.Numeric(w),rootOnly:!0},{from:I.Boolean(),to:(w)=>I.BooleanString(w),rootOnly:!0}];return xw},VU=({validator:w,modules:z,defaultConfig:U={},config:W,dynamic:A,models:X})=>{let Z=j2(w,{modules:z,dynamic:A,models:X,additionalProperties:!0,coerce:!0,additionalCoerce:P6()});if(s2(U))if(Z)Z.config=XH(Z.config,W);else Z=j2(I.Cookie({}),{modules:z,dynamic:A,models:X,additionalProperties:!0}),Z.config=U;return Z},Q1=(w,z)=>{if(!z)return;if(!Array.isArray(z)){let W=z;if(w&&!W.checksum)W.checksum=w;if(W.scope==="scoped")W.scope="local";return W}let U=[...z];for(let W of U){if(w&&!W.checksum)W.checksum=w;if(W.scope==="scoped")W.scope="local"}return U},GU=(w,z,U)=>{return{start:v0(w.start,Q1(U,z?.start)),request:v0(w.request,Q1(U,z?.request)),parse:v0(w.parse,Q1(U,z?.parse)),transform:v0(w.transform,Q1(U,z?.transform)),beforeHandle:v0(v0(W2(w.resolve,"resolve"),w.beforeHandle),Q1(U,v0(W2(z?.resolve,"resolve"),z?.beforeHandle))),afterHandle:v0(w.afterHandle,Q1(U,z?.afterHandle)),mapResponse:v0(w.mapResponse,Q1(U,z?.mapResponse)),afterResponse:v0(w.afterResponse,Q1(U,z?.afterResponse)),trace:v0(w.trace,Q1(U,z?.trace)),error:v0(w.error,Q1(U,z?.error)),stop:v0(w.stop,Q1(U,z?.stop))}},JH=(w,z,{skipIfHasType:U=!1}={})=>{if(!w)return w;if(!Array.isArray(w)){if(U)w.scope??=z;else w.scope=z;return w}for(let W of w)if(U)W.scope??=z;else W.scope=z;return w},z6=(w)=>{if(!w)return w;if(!Array.isArray(w))switch(w.scope){case"global":case"scoped":return{...w};default:return{fn:w}}let z=[];for(let U of w)switch(U.scope){case"global":case"scoped":z.push({...U});break}return z},LU=(w)=>{return{...w,type:w?.type,detail:w?.detail,parse:z6(w?.parse),transform:z6(w?.transform),beforeHandle:z6(w?.beforeHandle),afterHandle:z6(w?.afterHandle),mapResponse:z6(w?.mapResponse),afterResponse:z6(w?.afterResponse),error:z6(w?.error),trace:z6(w?.trace)}},f8={Continue:100,"Switching Protocols":101,Processing:102,"Early Hints":103,OK:200,Created:201,Accepted:202,"Non-Authoritative Information":203,"No Content":204,"Reset Content":205,"Partial Content":206,"Multi-Status":207,"Already Reported":208,"Multiple Choices":300,"Moved Permanently":301,Found:302,"See Other":303,"Not Modified":304,"Temporary Redirect":307,"Permanent Redirect":308,"Bad Request":400,Unauthorized:401,"Payment Required":402,Forbidden:403,"Not Found":404,"Method Not Allowed":405,"Not Acceptable":406,"Proxy Authentication Required":407,"Request Timeout":408,Conflict:409,Gone:410,"Length Required":411,"Precondition Failed":412,"Payload Too Large":413,"URI Too Long":414,"Unsupported Media Type":415,"Range Not Satisfiable":416,"Expectation Failed":417,"I'm a teapot":418,"Misdirected Request":421,"Unprocessable Content":422,Locked:423,"Failed Dependency":424,"Too Early":425,"Upgrade Required":426,"Precondition Required":428,"Too Many Requests":429,"Request Header Fields Too Large":431,"Unavailable For Legal Reasons":451,"Internal Server Error":500,"Not Implemented":501,"Bad Gateway":502,"Service Unavailable":503,"Gateway Timeout":504,"HTTP Version Not Supported":505,"Variant Also Negotiates":506,"Insufficient Storage":507,"Loop Detected":508,"Not Extended":510,"Network Authentication Required":511},NU=Object.fromEntries(Object.entries(f8).map(([w,z])=>[z,w]));function BH(w){let z=w;while(z.endsWith("="))z=z.slice(0,-1);return z}var SU=new TextEncoder,V8=async(w,z)=>{if(typeof w!=="string")throw new TypeError("Cookie value must be provided as a string.");if(z===null)throw new TypeError("Secret key must be provided.");let U=await crypto.subtle.importKey("raw",SU.encode(z),{name:"HMAC",hash:"SHA-256"},!1,["sign"]),W=await crypto.subtle.sign("HMAC",U,SU.encode(w));return w+"."+BH(Buffer.from(W).toString("base64"))},_U=async(w,z)=>{if(typeof w!=="string")throw new TypeError("Signed cookie string must be provided.");if(z===null)throw new TypeError("Secret key must be provided.");let U=w.slice(0,w.lastIndexOf("."));return await V8(U,z)===w?U:!1},MH=(w,z,U)=>{if(!w||typeof w!=="object"||!z)return;for(let[W,A]of Object.entries(z)){if(W in $H||!(W in w))continue;let X=w[W];if(typeof X==="function"){let Z=X(A);if(typeof Z==="object")for(let[$,Q]of Object.entries(Z))U($)({fn:Q});delete z[W]}}},qH=({globalHook:w,localHook:z})=>(U)=>(W,A)=>{if(typeof W==="function")W={fn:W};if(U==="resolve")W={...W,subType:"resolve"};if("fn"in W||Array.isArray(W)){if(!z[U])z[U]=[];if(typeof z[U]==="function")z[U]=[z[U]];if(Array.isArray(W))z[U]=z[U].concat(W);else z[U].push(W);return}let{insert:X="after",stack:Z="local"}=W;if(typeof A==="function")A={fn:A};if(Z==="global")if(!Array.isArray(A))if(X==="before")w[U].unshift(A);else w[U].push(A);else if(X==="before")w[U]=A.concat(w[U]);else w[U]=w[U].concat(A);else{if(!z[U])z[U]=[];if(typeof z[U]==="function")z[U]=[z[U]];if(!Array.isArray(A))if(X==="before")z[U].unshift(A);else z[U].push(A);else if(X==="before")z[U]=A.concat(z[U]);else z[U]=z[U].concat(A)}},HH=(w)=>{if(typeof w==="number")return w;if(w.length<16){if(w.trim().length===0)return null;let z=Number(w);if(Number.isNaN(z))return null;return z}if(w.length===16){if(w.trim().length===0)return null;let z=Number(w);if(Number.isNaN(z)||z.toString()!==w)return null;return z}return null},iw=(w)=>HH(w)!==null;class kU{onError;root=null;promises=[];constructor(w=console.error){this.onError=w}get size(){return this.promises.length}add(w){return this.promises.push(w),this.root||=this.drain(),w}async drain(){while(this.promises.length>0){try{await this.promises[0]}catch(w){this.onError(w)}this.promises.shift()}this.root=null}then(w,z){return(this.root??Promise.resolve()).then(w,z)}}var W2=(w,z)=>{if(!w)return w;if(!Array.isArray(w)){if(typeof w==="function"||typeof w==="string")return z?{fn:w,subType:z}:{fn:w};else if("fn"in w)return w}let U=[];for(let W of w)if(typeof W==="function"||typeof W==="string")U.push(z?{fn:W,subType:z}:{fn:W});else if("fn"in W)U.push(W);return U},GH=(w)=>{return{...w,start:W2(w?.start),request:W2(w?.request),parse:W2(w?.parse),transform:W2(w?.transform),beforeHandle:W2(w?.beforeHandle),afterHandle:W2(w?.afterHandle),mapResponse:W2(w?.mapResponse),afterResponse:W2(w?.afterResponse),trace:W2(w?.trace),error:W2(w?.error),stop:W2(w?.stop)}},DU=(w)=>{return{...w,start:w.start?.map((z)=>z.fn),request:w.request?.map((z)=>z.fn),parse:w.parse?.map((z)=>z.fn),transform:w.transform?.map((z)=>z.fn),beforeHandle:w.beforeHandle?.map((z)=>z.fn),afterHandle:w.afterHandle?.map((z)=>z.fn),afterResponse:w.afterResponse?.map((z)=>z.fn),mapResponse:w.mapResponse?.map((z)=>z.fn),trace:w.trace?.map((z)=>z.fn),error:w.error?.map((z)=>z.fn),stop:w.stop?.map((z)=>z.fn)}},Vw=(w)=>({body:w.body,cookie:w.cookie,headers:w.headers,query:w.query,set:w.set,server:w.server,request:w.request,route:w.route}),TU=(w,z=302)=>Response.redirect(w,z),PE=Symbol("ElysiaFormData"),d8=Symbol("ElysiaRequestId");var gU=()=>{let w=crypto.randomUUID();return w.slice(0,8)+w.slice(24,32)},PU=(w)=>{let z=[];for(let U=0;U<w.length;U++){let W=w[U];if(W.checksum){if(z.includes(W.checksum))w.splice(U,1),U--;z.push(W.checksum)}}return w},J2=(w,z="scoped")=>{if(z==="scoped"){for(let U of w)if("scope"in U&&U.scope==="local")U.scope="scoped";return}for(let U of w)if("scope"in U)U.scope="global"},r6=(w)=>{if(w.charCodeAt(w.length-1)===47)return w.slice(0,w.length-1);return w+"/"},s2=(w)=>{if(!w)return!1;for(let z in w)return!0;return!1},OU=typeof Bun!=="undefined"?Bun.env:typeof process!=="undefined"?process?.env:void 0,k8=Symbol("ElysiaErrorCode"),T8=(OU?.NODE_ENV??OU?.ENV)==="production";class M1{code;response;constructor(w,z){let U=z??(w in NU?NU[w]:w);this.code=f8[w]??w,this.response=U}}var LH=(w,z)=>new M1(w,z);class fU extends Error{code="INTERNAL_SERVER_ERROR";status=500;constructor(w){super(w??"INTERNAL_SERVER_ERROR")}}class h8 extends Error{code="NOT_FOUND";status=404;constructor(w){super(w??"NOT_FOUND")}}class dU extends Error{code="PARSE";status=400;constructor(){super("Bad Request")}}class hw extends Error{key;code="INVALID_COOKIE_SIGNATURE";status=400;constructor(w,z){super(z??`"${w}" has invalid cookie signature`);this.key=w}}var J1=(w)=>{if(!w)return{summary:void 0};let{message:z,path:U,value:W,type:A}=w,X=U.slice(1).replaceAll("/","."),Z=U==="";switch(A){case 42:return{...w,summary:Z?"Value should not be provided":`Property '${X}' should not be provided`};case 45:return{...w,summary:Z?"Value is missing":`Property '${X}' is missing`};case 50:let $=z.indexOf("'"),Q=z.slice($+1,z.indexOf("'",$+1));return{...w,summary:Z?"Value should be an email":`Property '${X}' should be ${Q}`};case 54:return{...w,summary:`${z.slice(0,9)} property '${X}' to be ${z.slice(8)} but found: ${W}`};case 62:let Y=w.schema.anyOf.map((B)=>`'${B?.format??B.type}'`).join(", ");return{...w,summary:Z?`Value should be one of ${Y}`:`Property '${X}' should be one of: ${Y}`};default:return{summary:z,...w}}};class Z0 extends Error{type;validator;value;code="VALIDATION";status=422;constructor(w,z,U){if(U&&typeof U==="object"&&U instanceof M1)U=U.response;let W=T8?void 0:("Errors"in z)?z.Errors(U).First():p.Errors(z,U).First(),A=W.schema.message||W?.schema.error!==void 0?typeof W.schema.error==="function"?W.schema.error({type:w,validator:z,value:U,get errors(){return[...z.Errors(U)].map(J1)}}):W.schema.error:void 0,X=W?.path||"root",Z="";if(A!==void 0)Z=typeof A==="object"?JSON.stringify(A):A+"";else if(T8)Z=JSON.stringify({type:"validation",on:w,summary:J1(W).summary,message:W?.message,found:U});else{let $=z?.schema??z,Q="Errors"in z?[...z.Errors(U)].map(J1):[...p.Errors(z,U)].map(J1),Y;try{Y=p.Create($)}catch(B){Y={type:"Could not create expected value",message:B?.message,error:B}}Z=JSON.stringify({type:"validation",on:w,summary:J1(W).summary,property:X,message:W?.message,expected:Y,found:U,errors:Q},null,2)}super(Z);this.type=w,this.validator=z,this.value=U,Object.setPrototypeOf(this,Z0.prototype)}get all(){return"Errors"in this.validator?[...this.validator.Errors(this.value)].map(J1):[...p.Errors(this.validator,this.value)].map(J1)}static simplifyModel(w){let z="schema"in w?w.schema:w;try{return p.Create(z)}catch{return z}}get model(){return Z0.simplifyModel(this.validator)}toResponse(w){return new Response(this.message,{status:400,headers:{...w,"content-type":"application/json"}})}}var hU=/(\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d:[0-5]\d\.\d+([+-][0-2]\d:[0-5]\d|Z))|(\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d:[0-5]\d([+-][0-2]\d:[0-5]\d|Z))|(\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d([+-][0-2]\d:[0-5]\d|Z))/,yU=/(?:Sun|Mon|Tue|Wed|Thu|Fri|Sat)\s(?:Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)\s\d{2}\s\d{4}\s\d{2}:\d{2}:\d{2}\sGMT(?:\+|-)\d{4}\s\([^)]+\)/,cU=/^(?:(?:(?:(?:0?[1-9]|[12][0-9]|3[01])[/\s-](?:0?[1-9]|1[0-2])[/\s-](?:19|20)\d{2})|(?:(?:19|20)\d{2}[/\s-](?:0?[1-9]|1[0-2])[/\s-](?:0?[1-9]|[12][0-9]|3[01]))))(?:\s(?:1[012]|0?[1-9]):[0-5][0-9](?::[0-5][0-9])?(?:\s[AP]M)?)?$/,NH=cw.date,SH=cw["date-time"];if(!b0.Has("date"))f1.Format("date",(w)=>{let z=w.replace(/"/g,"");if(hU.test(z)||yU.test(z)||cU.test(z)||NH(z)){let U=new Date(z);if(!Number.isNaN(U.getTime()))return!0}return!1});if(!b0.Has("date-time"))f1.Format("date-time",(w)=>{let z=w.replace(/"/g,"");if(hU.test(z)||yU.test(z)||cU.test(z)||SH(z)){let U=new Date(z);if(!Number.isNaN(U.getTime()))return!0}return!1});Object.entries(cw).forEach((w)=>{let[z,U]=w;if(!b0.Has(z)){if(U instanceof RegExp)f1.Format(z,(W)=>U.test(W));else if(typeof U==="function")f1.Format(z,U)}});var I=Object.assign({},N6),bU=(w)=>{if(typeof w==="string")switch(w.slice(-1)){case"k":return+w.slice(0,w.length-1)*1024;case"m":return+w.slice(0,w.length-1)*1048576;default:return+w}return w},yw=(w,z)=>{if(!(z instanceof Blob))return!1;if(w.minSize&&z.size<bU(w.minSize))return!1;if(w.maxSize&&z.size>bU(w.maxSize))return!1;if(w.extension)if(typeof w.extension==="string"){if(!z.type.startsWith(w.extension))return!1}else{for(let U=0;U<w.extension.length;U++)if(z.type.startsWith(w.extension[U]))return!0;return!1}return!0},_H=y0.Get("Files")??f1.Type("File",yw),DH=y0.Get("Files")??f1.Type("Files",(w,z)=>{if(!Array.isArray(z))return yw(w,z);if(w.minItems&&z.length<w.minItems)return!1;if(w.maxItems&&z.length>w.maxItems)return!1;for(let U=0;U<z.length;U++)if(!yw(w,z[U]))return!1;return!0});if(!b0.Has("numeric"))b0.Set("numeric",(w)=>!!w&&!isNaN(+w));if(!b0.Has("integer"))b0.Set("integer",(w)=>!!w&&Number.isInteger(+w));if(!b0.Has("boolean"))b0.Set("boolean",(w)=>w==="true"||w==="false");if(!b0.Has("ObjectString"))b0.Set("ObjectString",(w)=>{let z=w.charCodeAt(0);if(z===9||z===10||z===32)z=w.trimStart().charCodeAt(0);if(z!==123&&z!==91)return!1;try{return JSON.parse(w),!0}catch{return!1}});if(!b0.Has("ArrayString"))b0.Set("ArrayString",(w)=>{let z=w.charCodeAt(0);if(z===9||z===10||z===32)z=w.trimStart().charCodeAt(0);if(z!==123&&z!==91)return!1;try{return JSON.parse(w),!0}catch{return!1}});y0.Set("UnionEnum",(w,z)=>{return(typeof z==="number"||typeof z==="string"||z===null)&&w.enum.includes(z)});var r2={Numeric:(w)=>{let z=N6.Number(w);return I.Transform(I.Union([I.String({format:"numeric",default:0}),I.Number(w)],w)).Decode((U)=>{let W=+U;if(isNaN(W))return U;if(w&&!p.Check(z,W))throw new Z0("property",z,W);return W}).Encode((U)=>U)},Integer:(w)=>{let z=N6.Integer(w);return I.Transform(I.Union([I.String({format:"integer",default:0}),I.Number(w)],w)).Decode((U)=>{let W=+U;if(!p.Check(z,W))throw new Z0("property",z,W);return W}).Encode((U)=>U)},Date:(w)=>{let z=N6.Date(w);return I.Transform(I.Union([N6.Date(w),I.String({format:"date",default:new Date().toISOString()}),I.String({format:"date-time",default:new Date().toISOString()}),I.Number()],w)).Decode((U)=>{if(typeof U==="number"){let A=new Date(U);if(!p.Check(z,A))throw new Z0("property",z,A);return A}if(U instanceof Date)return U;let W=new Date(U);if(!p.Check(z,W))throw new Z0("property",z,W);return W}).Encode((U)=>{if(typeof U==="string")return new Date(U);return U})},BooleanString:(w)=>{let z=N6.Boolean(w);return I.Transform(I.Union([I.Boolean(w),I.String({format:"boolean",default:!1})],w)).Decode((U)=>{if(typeof U==="string")return U==="true";if(U!==void 0&&!p.Check(z,U))throw new Z0("property",z,U);return U}).Encode((U)=>U)},ObjectString:(w,z)=>{let U=I.Object(w,z),W=JSON.stringify(p.Create(U)),A;try{A=w6.Compile(U)}catch{}return I.Transform(I.Union([I.String({format:"ObjectString",default:W}),U])).Decode((X)=>{if(typeof X==="string"){if(X.charCodeAt(0)!==123)throw new Z0("property",U,X);try{X=JSON.parse(X)}catch{throw new Z0("property",U,X)}if(A){if(!A.Check(X))throw new Z0("property",U,X);return A.Decode(X)}if(!p.Check(U,X))throw new Z0("property",U,X);return p.Decode(U,X)}return X}).Encode((X)=>{if(typeof X==="string")try{X=JSON.parse(X)}catch{throw new Z0("property",U,X)}if(!p.Check(U,X))throw new Z0("property",U,X);return JSON.stringify(X)})},ArrayString:(w={},z)=>{let U=I.Array(w,z),W=JSON.stringify(p.Create(U)),A;try{A=w6.Compile(U)}catch{}return I.Transform(I.Union([I.String({format:"ArrayString",default:W}),U])).Decode((X)=>{if(typeof X==="string"){if(X.charCodeAt(0)!==91)throw new Z0("property",U,X);try{X=JSON.parse(X)}catch{throw new Z0("property",U,X)}if(A){if(!A.Check(X))throw new Z0("property",U,X);return A.Decode(X)}if(!p.Check(U,X))throw new Z0("property",U,X);return p.Decode(U,X)}return X}).Encode((X)=>{if(typeof X==="string")try{X=JSON.parse(X)}catch{throw new Z0("property",U,X)}if(!p.Check(U,X))throw new Z0("property",U,X);return JSON.stringify(X)})},File:_H,Files:(w={})=>I.Transform(DH(w)).Decode((z)=>{if(Array.isArray(z))return z;return[z]}).Encode((z)=>z),Nullable:(w)=>I.Union([w,I.Null()]),MaybeEmpty:(w)=>I.Union([w,I.Null(),I.Undefined()]),Cookie:(w,{domain:z,expires:U,httpOnly:W,maxAge:A,path:X,priority:Z,sameSite:$,secure:Q,secrets:Y,sign:B,...G}={})=>{let _=I.Object(w,G);return _.config={domain:z,expires:U,httpOnly:W,maxAge:A,path:X,priority:Z,sameSite:$,secure:Q,secrets:Y,sign:B},_},UnionEnum:(w,z={})=>{let U=w.every((W)=>typeof W==="string")?{type:"string"}:w.every((W)=>typeof W==="number")?{type:"number"}:w.every((W)=>W===null)?{type:"null"}:{};if(w.some((W)=>typeof W==="object"&&W!==null))throw new Error("This type does not support objects or arrays");return{default:w[0],...z,[N]:"UnionEnum",...U,enum:w}}};I.BooleanString=r2.BooleanString;I.ObjectString=r2.ObjectString;I.ArrayString=r2.ArrayString;I.Numeric=r2.Numeric;I.Integer=r2.Integer;I.File=(w={})=>r2.File({default:"File",...w,extension:w?.type,type:"string",format:"binary"});I.Files=(w={})=>r2.Files({...w,elysiaMeta:"Files",default:"Files",extension:w?.type,type:"array",items:{...w,default:"Files",type:"string",format:"binary"}});I.Nullable=(w)=>r2.Nullable(w);I.MaybeEmpty=r2.MaybeEmpty;I.Cookie=r2.Cookie;I.Date=r2.Date;I.UnionEnum=r2.UnionEnum;var T4=(w)=>{let z=typeof w==="object"?w.fn.toString():typeof w==="string"?w.toString():w,U=z.indexOf(")");if(z.charCodeAt(U+2)===61&&z.charCodeAt(U+5)!==123)return!0;return z.includes("return")},PH=(w)=>{if(w.startsWith("async"))w=w.slice(5);w=w.trimStart();let z=-1;if(w.charCodeAt(0)===40){if(z=w.indexOf("=>",w.indexOf(")")),z!==-1){let A=z;while(A>0)if(w.charCodeAt(--A)===41)break;let X=w.slice(z+2);if(X.charCodeAt(0)===32)X=X.trimStart();return[w.slice(1,A),X,{isArrowReturn:X.charCodeAt(0)!==123}]}}if(/^(\w+)=>/g.test(w)){if(z=w.indexOf("=>"),z!==-1){let A=w.slice(z+2);if(A.charCodeAt(0)===32)A=A.trimStart();return[w.slice(0,z),A,{isArrowReturn:A.charCodeAt(0)!==123}]}}if(w.startsWith("function")){z=w.indexOf("(");let A=w.indexOf(")");return[w.slice(z+1,A),w.slice(A+2),{isArrowReturn:!1}]}let U=w.indexOf("(");if(U!==-1){let A=w.indexOf(`
8
- `,2),X=w.slice(0,A),Z=X.lastIndexOf(")")+1,$=w.slice(A+1);return[X.slice(U,Z),"{"+$,{isArrowReturn:!1}]}let W=w.split(`
9
- `,2);return[W[0],W[1],{isArrowReturn:!1}]},OH=(w)=>{let z=w.indexOf("{");if(z===-1)return[-1,0];let U=z+1,W=1;for(;U<w.length;U++){let A=w.charCodeAt(U);if(A===123)W++;else if(A===125)W--;if(W===0)break}if(W!==0)return[0,w.length];return[z,U+1]},bH=(w)=>{let z=w.lastIndexOf("}");if(z===-1)return[-1,0];let U=z-1,W=1;for(;U>=0;U--){let A=w.charCodeAt(U);if(A===125)W++;else if(A===123)W--;if(W===0)break}if(W!==0)return[-1,0];return[U,z+1]},iU=(w)=>{while(!0){let z=w.indexOf(":");if(z===-1)break;let U=w.indexOf(",",z);if(U===-1)U=w.indexOf("}",z)-1;if(U===-2)U=w.length;w=w.slice(0,z)+w.slice(U)}return w},vU=(w)=>{let z=!1;if(w.charCodeAt(0)===40)w=w.slice(1,-1);if(w.charCodeAt(0)===123)z=!0,w=w.slice(1,-1);w=w.replace(/( |\t|\n)/g,"").trim();let U=[];while(!0){let[A,X]=OH(w);if(A===-1)break;if(U.push(w.slice(0,A-1)),w.charCodeAt(X)===44)X++;w=w.slice(X)}if(w=iU(w),w)U=U.concat(w.split(","));let W=[];for(let A of U){if(A.indexOf(",")===-1){W.push(A);continue}for(let X of A.split(","))W.push(X.trim())}return U=W,{hasParenthesis:z,parameters:U}},RH=(w,z)=>{let{parameters:U,hasParenthesis:W}=vU(w);if(!z.query&&U.includes("query"))z.query=!0;if(!z.headers&&U.includes("headers"))z.headers=!0;if(!z.body&&U.includes("body"))z.body=!0;if(!z.cookie&&U.includes("cookie"))z.cookie=!0;if(!z.set&&U.includes("set"))z.set=!0;if(!z.server&&U.includes("server"))z.server=!0;if(!z.request&&U.includes("request"))z.request=!0;if(!z.route&&U.includes("route"))z.route=!0;if(W)return`{ ${U.join(", ")} }`;return U.join(", ")},RU=(w,z,U)=>{let W=z.indexOf(w+`
10
- `,U),A=z.indexOf(w+"\t",U),X=z.indexOf(w+",",U),Z=z.indexOf(w+";",U),$=z.indexOf(w+" ",U);return[W,A,X,Z,$].filter((Q)=>Q>0).sort((Q,Y)=>Q-Y)[0]||-1},nU=(w,z,U=0)=>{if(U>5)return[];let W=[],A=z;while(!0){let X=RU(" = "+w,A);if(X===-1)X=RU("="+w,A);if(X===-1){let Y=A.indexOf(" = "+w);if(Y===-1)Y=A.indexOf("="+w);if(Y+3+w.length!==A.length)break;X=Y}let Z=A.slice(0,X),$=Z.lastIndexOf(" "),Q=Z.slice($!==-1?$+1:-1);if(Q==="}"){let[Y,B]=bH(Z);W.push(iU(A.slice(Y,B))),A=A.slice(X+3+w.length);continue}while(Q.charCodeAt(0)===44)Q=Q.slice(1);while(Q.charCodeAt(0)===9)Q=Q.slice(1);if(!Q.includes("("))W.push(Q);A=A.slice(X+3+w.length)}for(let X of W){if(X.charCodeAt(0)===123)continue;let Z=nU(X,z);if(Z.length>0)W.push(...Z)}return W},CH=(w)=>{if(!w)return;if(w.charCodeAt(0)!==123)return w;if(w=w.slice(2,-2),!w.includes(",")){if(w.includes("..."))return w.slice(w.indexOf("...")+3);return}let z=w.indexOf("...");if(z===-1)return;return w.slice(z+3).trimEnd()},KH=(w,z,U)=>{let W=(A,X)=>w.includes(X+"."+A)||w.includes(X+'["'+A+'"]')||w.includes(X+"['"+A+"']");for(let A of z){if(!A)continue;if(A.charCodeAt(0)===123){let X=vU(A).parameters;if(!U.query&&X.includes("query"))U.query=!0;if(!U.headers&&X.includes("headers"))U.headers=!0;if(!U.body&&X.includes("body"))U.body=!0;if(!U.cookie&&X.includes("cookie"))U.cookie=!0;if(!U.set&&X.includes("set"))U.set=!0;if(!U.query&&X.includes("server"))U.server=!0;if(!U.request&&X.includes("request"))U.request=!0;if(!U.route&&X.includes("route"))U.route=!0;continue}if(!U.query&&W("query",A))U.query=!0;if(w.includes("return "+A)||w.includes("return "+A+".query"))U.query=!0;if(!U.headers&&W("headers",A))U.headers=!0;if(!U.body&&W("body",A))U.body=!0;if(!U.cookie&&W("cookie",A))U.cookie=!0;if(!U.set&&W("set",A))U.set=!0;if(!U.server&&W("server",A))U.server=!0;if(U.query&&U.headers&&U.body&&U.cookie&&U.set&&U.server&&U.server&&U.route)break}return z},FH=(w,z,U)=>{try{let W=new RegExp(`(?:\\w)\\((?:.*)?${w}`,"gs");W.test(z);let A=z.charCodeAt(W.lastIndex);if(A===41||A===44)return U.query=!0,U.headers=!0,U.body=!0,U.cookie=!0,U.set=!0,U.server=!0,U.route=!0,U.request=!0,!0;return!1}catch(W){return console.log("[Sucrose] warning: unexpected isContextPassToFunction error, you may continue development as usual but please report the following to maintainers:"),console.log("--- body ---"),console.log(z),console.log("--- context ---"),console.log(w),!0}},uU=(w,z={query:!1,headers:!1,body:!1,cookie:!1,set:!1,server:!1,request:!1,route:!1})=>{let U=[];if(w.handler&&typeof w.handler==="function")U.push(w.handler);if(w.request?.length)U.push(...w.request);if(w.beforeHandle?.length)U.push(...w.beforeHandle);if(w.parse?.length)U.push(...w.parse);if(w.error?.length)U.push(...w.error);if(w.transform?.length)U.push(...w.transform);if(w.afterHandle?.length)U.push(...w.afterHandle);if(w.mapResponse?.length)U.push(...w.mapResponse);if(w.afterResponse?.length)U.push(...w.afterResponse);for(let W of U){if(!W)continue;let A="fn"in W?W.fn:W;if(typeof A!=="function")continue;let[X,Z,{isArrowReturn:$}]=PH(A.toString()),Q=RH(X,z),Y=CH(Q);if(Y){let B=nU(Y,Z);if(B.splice(0,-1,Y),!FH(Y,Z,z))KH(Z,B,z);if(!z.query&&Z.includes("return "+Y+".query"))z.query=!0}if(z.query&&z.headers&&z.body&&z.cookie&&z.set&&z.server&&z.request&&z.route)break}return z};class z4{name;jar;initial;constructor(w,z,U={}){this.name=w,this.jar=z,this.initial=U}get cookie(){return this.jar[this.name]??this.initial}set cookie(w){if(!(this.name in this.jar))this.jar[this.name]=this.initial;this.jar[this.name]=w}get setCookie(){if(!(this.name in this.jar))this.jar[this.name]=this.initial;return this.jar[this.name]}set setCookie(w){this.cookie=w}get value(){return this.cookie.value}set value(w){this.setCookie.value=w}get expires(){return this.cookie.expires}set expires(w){this.setCookie.expires=w}get maxAge(){return this.cookie.maxAge}set maxAge(w){this.setCookie.maxAge=w}get domain(){return this.cookie.domain}set domain(w){this.setCookie.domain=w}get path(){return this.cookie.path}set path(w){this.setCookie.path=w}get secure(){return this.cookie.secure}set secure(w){this.setCookie.secure=w}get httpOnly(){return this.cookie.httpOnly}set httpOnly(w){this.setCookie.httpOnly=w}get sameSite(){return this.cookie.sameSite}set sameSite(w){this.setCookie.sameSite=w}get priority(){return this.cookie.priority}set priority(w){this.setCookie.priority=w}get partitioned(){return this.cookie.partitioned}set partitioned(w){this.setCookie.partitioned=w}get secrets(){return this.cookie.secrets}set secrets(w){this.setCookie.secrets=w}update(w){return this.setCookie=Object.assign(this.cookie,typeof w==="function"?w(this.cookie):w),this}set(w){return this.setCookie=Object.assign({...this.initial,value:this.value},typeof w==="function"?w(this.cookie):w),this}remove(){if(this.value===void 0)return;return this.set({expires:new Date(0),maxAge:0,value:""}),this}toString(){return typeof this.value==="object"?JSON.stringify(this.value):this.value?.toString()??""}}var CU=(w,z,U)=>{if(!w.cookie)w.cookie={};return new Proxy(z,{get(W,A){if(A in z)return new z4(A,w.cookie,Object.assign({},U??{},z[A]));return new z4(A,w.cookie,Object.assign({},U))}})},tU=async(w,z,{secrets:U,sign:W,...A}={})=>{if(!z)return CU(w,{},A);let X=typeof U==="string";if(W&&W!==!0&&!Array.isArray(W))W=[W];let Z={},$=y8.parse(z);for(let[Q,Y]of Object.entries($)){let B=mU.default(Y);if(W===!0||W?.includes(Q)){if(!U)throw new Error("No secret is provided to cookie plugin");if(X){let G=await _U(B,U);if(G===!1)throw new hw(Q);B=G}else{let G=!0;for(let _=0;_<U.length;_++){let H=await _U(B,U[_]);if(H!==!1){G=!0,B=H;break}}if(!G)throw new hw(Q)}}Z[Q]={value:B}}return CU(w,Z,A)},pU=(w)=>{if(!w||!s2(w))return;let z=[];for(let[U,W]of Object.entries(w)){if(!U||!W)continue;let A=W.value;if(A===void 0||A===null)continue;z.push(y8.serialize(U,typeof A==="object"?JSON.stringify(A):A+"",W))}if(z.length===0)return;if(z.length===1)return z[0];return z},W6=(w,z)=>{let U=w.size;if(!z&&U||U&&z&&z.status!==206&&z.status!==304&&z.status!==412&&z.status!==416){if(z){if(z.headers instanceof Headers){let W={"accept-ranges":"bytes","content-range":`bytes 0-${U-1}/${U}`,"transfer-encoding":"chunked"};if(IU)W=z.headers.toJSON();else{W={};for(let[A,X]of z.headers.entries())if(A in z.headers)W[A]=X}return new Response(w,{status:z.status,headers:W})}if(s2(z.headers))return new Response(w,{status:z.status,headers:Object.assign({"accept-ranges":"bytes","content-range":`bytes 0-${U-1}/${U}`,"transfer-encoding":"chunked"},z.headers)})}return new Response(w,{headers:{"accept-ranges":"bytes","content-range":`bytes 0-${U-1}/${U}`,"transfer-encoding":"chunked"}})}return new Response(w)},oU=(w,z)=>{if(!w)return w;w.delete("set-cookie");for(let U=0;U<z.length;U++){let W=z[U].indexOf("=");w.append("set-cookie",`${z[U].slice(0,W)}=${z[U].slice(W+1)||""}`)}return w},B1=async(w,z,U)=>{let W=w.next();if(W instanceof Promise)W=await W;if(W.done){if(z)return E2(W.value,z,U);return A6(W.value,U)}return new Response(new ReadableStream({async start(A){let X=!1;if(U?.signal?.addEventListener("abort",()=>{X=!0;try{A.close()}catch{}}),W.value!==void 0&&W.value!==null)if(typeof W.value==="object")try{A.enqueue(Buffer.from(JSON.stringify(W.value)))}catch{A.enqueue(Buffer.from(W.value.toString()))}else A.enqueue(Buffer.from(W.value.toString()));for await(let Z of w){if(X)break;if(Z===void 0||Z===null)continue;if(typeof Z==="object")try{A.enqueue(Buffer.from(JSON.stringify(Z)))}catch{A.enqueue(Buffer.from(Z.toString()))}else A.enqueue(Buffer.from(Z.toString()));await new Promise(($)=>setTimeout(()=>$(),0))}try{A.close()}catch{}}}),{...z,headers:{"transfer-encoding":"chunked","content-type":"text/event-stream; charset=utf-8",...z?.headers}})};async function*w4(w){let z=w.body;if(!z)return;let U=z.getReader(),W=new TextDecoder;try{while(!0){let{done:A,value:X}=await U.read();if(A)break;yield W.decode(X)}}finally{U.releaseLock()}}var lU=(w)=>{if(typeof w.status==="string")w.status=f8[w.status];if(w.cookie&&s2(w.cookie)){let z=pU(w.cookie);if(z)w.headers["set-cookie"]=z}if(w.headers["set-cookie"]&&Array.isArray(w.headers["set-cookie"]))w.headers=oU(new Headers(w.headers),w.headers["set-cookie"])},g8=(w,z)=>{if(w.status!==z.status&&z.status!==200&&(w.status<=300||w.status>400))w=new Response(w.body,{headers:w.headers,status:z.status});let U=!1;if(z.headers instanceof Headers)for(let W of z.headers.keys())if(W==="set-cookie"){if(U)continue;U=!0;for(let A of z.headers.getSetCookie())w.headers.append("set-cookie",A)}else w.headers.append(W,z.headers?.get(W)??"");else for(let W in z.headers)w.headers.append(W,z.headers[W]);return w},E2=(w,z,U)=>{if(s2(z.headers)||z.status!==200||z.cookie)switch(lU(z),w?.constructor?.name){case"String":return new Response(w,z);case"Array":case"Object":return Response.json(w,z);case"ElysiaFile":return W6(w.value);case"Blob":return W6(w,z);case"ElysiaCustomStatusResponse":return z.status=w.code,E2(w.response,z,U);case"ReadableStream":if(!z.headers["content-type"]?.startsWith("text/event-stream"))z.headers["content-type"]="text/event-stream; charset=utf-8";return U?.signal?.addEventListener("abort",{handleEvent(){if(U?.signal&&!U?.signal?.aborted)w.cancel()}},{once:!0}),new Response(w,z);case void 0:if(!w)return new Response("",z);return Response.json(w,z);case"Response":if(w=g8(w,z),w.headers.get("transfer-encoding")==="chunked")return B1(w4(w),z,U);return w;case"Error":return X6(w,z);case"Promise":return w.then((W)=>E2(W,z,U));case"Function":return E2(w(),z,U);case"Number":case"Boolean":return new Response(w.toString(),z);case"Cookie":if(w instanceof z4)return new Response(w.value,z);return new Response(w?.toString(),z);case"FormData":return new Response(w,z);default:if(w instanceof Response){if(w=g8(w,z),w.headers.get("transfer-encoding")==="chunked")return B1(w4(w),z,U);return w}if(w instanceof Promise)return w.then((W)=>E2(W,z));if(w instanceof Error)return X6(w,z);if(w instanceof M1)return z.status=w.code,E2(w.response,z,U);if(typeof w?.next==="function")return B1(w,z,U);if(typeof w?.then==="function")return w.then((W)=>E2(W,z));if(typeof w?.toResponse==="function")return E2(w.toResponse(),z);if("charCodeAt"in w){let W=w.charCodeAt(0);if(W===123||W===91){if(!z.headers["Content-Type"])z.headers["Content-Type"]="application/json";return new Response(JSON.stringify(w),z)}}return new Response(w,z)}if(typeof w?.next==="function"||w instanceof ReadableStream||w instanceof Response&&w.headers.get("transfer-encoding")==="chunked")return B1(w,z,U);return A6(w,U)},K2=(w,z,U)=>{if(w===void 0||w===null)return;if(s2(z.headers)||z.status!==200||z.cookie)switch(lU(z),w?.constructor?.name){case"String":return new Response(w,z);case"Array":case"Object":return Response.json(w,z);case"ElysiaFile":return W6(w.value);case"Blob":return W6(w,z);case"ElysiaCustomStatusResponse":return z.status=w.code,K2(w.response,z,U);case"ReadableStream":if(!z.headers["content-type"]?.startsWith("text/event-stream"))z.headers["content-type"]="text/event-stream; charset=utf-8";return U?.signal?.addEventListener("abort",{handleEvent(){if(U?.signal&&!U?.signal?.aborted)w.cancel()}},{once:!0}),new Response(w,z);case void 0:if(!w)return;return Response.json(w,z);case"Response":if(w=g8(w,z),w.headers.get("transfer-encoding")==="chunked")return B1(w4(w),z,U);return w;case"Promise":return w.then((W)=>K2(W,z));case"Error":return X6(w,z);case"Function":return K2(w(),z);case"Number":case"Boolean":return new Response(w.toString(),z);case"FormData":return new Response(w);case"Cookie":if(w instanceof z4)return new Response(w.value,z);return new Response(w?.toString(),z);default:if(w instanceof Response){if(w=g8(w,z),w.headers.get("transfer-encoding")==="chunked")return B1(w4(w),z,U);return w}if(w instanceof Promise)return w.then((W)=>K2(W,z));if(w instanceof Error)return X6(w,z);if(w instanceof M1)return z.status=w.code,K2(w.response,z,U);if(typeof w?.next==="function")return B1(w,z,U);if(typeof w?.then==="function")return w.then((W)=>K2(W,z));if(typeof w?.toResponse==="function")return K2(w.toResponse(),z);if("charCodeAt"in w){let W=w.charCodeAt(0);if(W===123||W===91){if(!z.headers["Content-Type"])z.headers["Content-Type"]="application/json";return new Response(JSON.stringify(w),z)}}return new Response(w,z)}else switch(w?.constructor?.name){case"String":return new Response(w);case"Array":case"Object":return Response.json(w,z);case"ElysiaFile":return W6(w.value);case"Blob":return W6(w,z);case"ElysiaCustomStatusResponse":return z.status=w.code,K2(w.response,z,U);case"ReadableStream":return U?.signal?.addEventListener("abort",{handleEvent(){if(U?.signal&&!U?.signal?.aborted)w.cancel()}},{once:!0}),new Response(w,{headers:{"Content-Type":"text/event-stream; charset=utf-8"}});case void 0:if(!w)return new Response("");return new Response(JSON.stringify(w),{headers:{"content-type":"application/json"}});case"Response":if(w.headers.get("transfer-encoding")==="chunked")return B1(w4(w));return w;case"Promise":return w.then((W)=>{let A=K2(W,z);if(A!==void 0)return A});case"Error":return X6(w,z);case"Function":return A6(w(),U);case"Number":case"Boolean":return new Response(w.toString());case"Cookie":if(w instanceof z4)return new Response(w.value,z);return new Response(w?.toString(),z);case"FormData":return new Response(w);default:if(w instanceof Response)return w;if(w instanceof Promise)return w.then((W)=>K2(W,z));if(w instanceof Error)return X6(w,z);if(w instanceof M1)return z.status=w.code,K2(w.response,z,U);if(typeof w?.next==="function")return B1(w,z,U);if(typeof w?.then==="function")return w.then((W)=>K2(W,z));if(typeof w?.toResponse==="function")return K2(w.toResponse(),z);if("charCodeAt"in w){let W=w.charCodeAt(0);if(W===123||W===91){if(!z.headers["Content-Type"])z.headers["Content-Type"]="application/json";return new Response(JSON.stringify(w),z)}}return new Response(w)}},A6=(w,z)=>{switch(w?.constructor?.name){case"String":return new Response(w);case"Object":case"Array":return Response.json(w);case"ElysiaFile":return W6(w.value);case"Blob":return W6(w);case"ElysiaCustomStatusResponse":return E2(w.response,{status:w.code,headers:{}});case"ReadableStream":return z?.signal?.addEventListener("abort",{handleEvent(){if(z?.signal&&!z?.signal?.aborted)w.cancel()}},{once:!0}),new Response(w,{headers:{"Content-Type":"text/event-stream; charset=utf-8"}});case void 0:if(!w)return new Response("");return new Response(JSON.stringify(w),{headers:{"content-type":"application/json"}});case"Response":if(w.headers.get("transfer-encoding")==="chunked")return B1(w4(w));return w;case"Error":return X6(w);case"Promise":return w.then((U)=>A6(U,z));case"Function":return A6(w(),z);case"Number":case"Boolean":return new Response(w.toString());case"FormData":return new Response(w);default:if(w instanceof Response)return w;if(w instanceof Promise)return w.then((U)=>A6(U,z));if(w instanceof Error)return X6(w);if(w instanceof M1)return E2(w.response,{status:w.code,headers:{}});if(typeof w?.next==="function")return B1(w,void 0,z);if(typeof w?.then==="function")return w.then((U)=>E2(U,set));if(typeof w?.toResponse==="function")return A6(w.toResponse());if("charCodeAt"in w){let U=w.charCodeAt(0);if(U===123||U===91)return new Response(JSON.stringify(w),{headers:{"Content-Type":"application/json"}})}return new Response(w)}},X6=(w,z)=>new Response(JSON.stringify({name:w?.name,message:w?.message,cause:w?.cause}),{status:z?.status!==200?z?.status??500:500,headers:z?.headers}),jH=(w,z,U={})=>{if(typeof w==="function")return;let W=E2(w,{headers:U});if(z.parse.length===0&&z.transform.length===0&&z.beforeHandle.length===0&&z.afterHandle.length===0)return W.clone.bind(W)},I8={name:"web-standard",isWebStandard:!0,handler:{mapResponse:E2,mapEarlyResponse:K2,mapCompactResponse:A6,createStaticHandler:jH},composeHandler:{mapResponseContext:"c.request",preferWebstandardHeaders:!0,headers:`c.headers = {}
2
+ var _X=Object.create;var{getPrototypeOf:SX,defineProperty:a5,getOwnPropertyNames:DX}=Object;var PX=Object.prototype.hasOwnProperty;var OX=(z,w,U)=>{U=z!=null?_X(SX(z)):{};let W=w||!z||!z.__esModule?a5(U,"default",{value:z,enumerable:!0}):U;for(let X of DX(z))if(!PX.call(W,X))a5(W,X,{get:()=>z[X],enumerable:!0});return W};var RX=(z,w)=>()=>(w||z((w={exports:{}}).exports,w),w.exports);var j6=(z,w)=>{for(var U in w)a5(z,U,{get:w[U],enumerable:!0,configurable:!0,set:(W)=>w[U]=()=>W})};var NU=RX((GU)=>{Object.defineProperty(GU,"__esModule",{value:!0});GU.parse=BL;GU.serialize=ML;var ZL=/^[\u0021-\u003A\u003C\u003E-\u007E]+$/,$L=/^[\u0021-\u003A\u003C-\u007E]*$/,AL=/^([.]?[a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?)([.][a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?)*$/i,QL=/^[\u0020-\u003A\u003D-\u007E]*$/,YL=Object.prototype.toString,JL=(()=>{let z=function(){};return z.prototype=Object.create(null),z})();function BL(z,w){let U=new JL,W=z.length;if(W<2)return U;let X=w?.decode||qL,Z=0;do{let $=z.indexOf("=",Z);if($===-1)break;let A=z.indexOf(";",Z),Q=A===-1?W:A;if($>Q){Z=z.lastIndexOf(";",$-1)+1;continue}let Y=qU(z,Z,$),J=LU(z,$,Y),G=z.slice(Y,J);if(U[G]===void 0){let S=qU(z,$+1,Q),N=LU(z,Q,S),O=X(z.slice(S,N));U[G]=O}Z=Q+1}while(Z<W);return U}function qU(z,w,U){do{let W=z.charCodeAt(w);if(W!==32&&W!==9)return w}while(++w<U);return U}function LU(z,w,U){while(w>U){let W=z.charCodeAt(--w);if(W!==32&&W!==9)return w+1}return U}function ML(z,w,U){let W=U?.encode||encodeURIComponent;if(!ZL.test(z))throw new TypeError(`argument name is invalid: ${z}`);let X=W(w);if(!$L.test(X))throw new TypeError(`argument val is invalid: ${w}`);let Z=z+"="+X;if(!U)return Z;if(U.maxAge!==void 0){if(!Number.isInteger(U.maxAge))throw new TypeError(`option maxAge is invalid: ${U.maxAge}`);Z+="; Max-Age="+U.maxAge}if(U.domain){if(!AL.test(U.domain))throw new TypeError(`option domain is invalid: ${U.domain}`);Z+="; Domain="+U.domain}if(U.path){if(!QL.test(U.path))throw new TypeError(`option path is invalid: ${U.path}`);Z+="; Path="+U.path}if(U.expires){if(!LL(U.expires)||!Number.isFinite(U.expires.valueOf()))throw new TypeError(`option expires is invalid: ${U.expires}`);Z+="; Expires="+U.expires.toUTCString()}if(U.httpOnly)Z+="; HttpOnly";if(U.secure)Z+="; Secure";if(U.partitioned)Z+="; Partitioned";if(U.priority)switch(typeof U.priority==="string"?U.priority.toLowerCase():void 0){case"low":Z+="; Priority=Low";break;case"medium":Z+="; Priority=Medium";break;case"high":Z+="; Priority=High";break;default:throw new TypeError(`option priority is invalid: ${U.priority}`)}if(U.sameSite)switch(typeof U.sameSite==="string"?U.sameSite.toLowerCase():U.sameSite){case!0:case"strict":Z+="; SameSite=Strict";break;case"lax":Z+="; SameSite=Lax";break;case"none":Z+="; SameSite=None";break;default:throw new TypeError(`option sameSite is invalid: ${U.sameSite}`)}return Z}function qL(z){if(z.indexOf("%")===-1)return z;try{return decodeURIComponent(z)}catch(w){return z}}function LL(z){return YL.call(z)==="[object Date]"}});var o6=(z,w)=>{let U=w?.length?{}:null;if(U)for(let W of w)U[W.part.charCodeAt(0)]=W;return{part:z,store:null,inert:U,params:null,wildcardStore:null}},Bw=(z,w)=>({...z,part:w}),Mw=(z)=>({name:z,store:null,inert:null});class F6{config;root={};history=[];deferred=[];constructor(z={}){if(this.config=z,z.lazy)this.find=this.lazyFind}static regex={static:/:.+?(?=\/|$)/,params:/:.+?(?=\/|$)/g,optionalParams:/:.+?\?(?=\/|$)/g};lazyFind=(z,w)=>{if(!this.config.lazy)return this.find;return this.build(),this.find(z,w)};build(){if(!this.config.lazy)return;for(let[z,w,U]of this.deferred)this.add(z,w,U,{lazy:!1,ignoreHistory:!0});this.deferred=[],this.find=(z,w)=>{let U=this.root[z];if(!U)return null;return Z8(w,w.length,U,0)}}add(z,w,U,{ignoreError:W=!1,ignoreHistory:X=!1,lazy:Z=this.config.lazy}={}){if(Z)return this.find=this.lazyFind,this.deferred.push([z,w,U]),U;if(typeof w!=="string")throw new TypeError("Route path must be a string");if(w==="")w="/";else if(w[0]!=="/")w=`/${w}`;let $=w[w.length-1]==="*",A=w.match(F6.regex.optionalParams);if(A){let S=w.replaceAll("?","");this.add(z,S,U,{ignoreError:W,ignoreHistory:X,lazy:Z});for(let N=0;N<A.length;N++){let O=w.replace("/"+A[N],"");this.add(z,O,U,{ignoreError:!0,ignoreHistory:X,lazy:Z})}return U}if(A)w=w.replaceAll("?","");if(this.history.find(([S,N,O])=>S===z&&N===w))return U;if($||A&&w.charCodeAt(w.length-1)===63)w=w.slice(0,-1);if(!X)this.history.push([z,w,U]);let Q=w.split(F6.regex.static),Y=w.match(F6.regex.params)||[];if(Q[Q.length-1]==="")Q.pop();let J;if(!this.root[z])J=this.root[z]=o6("/");else J=this.root[z];let G=0;for(let S=0;S<Q.length;++S){let N=Q[S];if(S>0){let O=Y[G++].slice(1);if(J.params===null)J.params=Mw(O);else if(J.params.name!==O)if(W)return U;else throw new Error(`Cannot create route "${w}" with parameter "${O}" because a route already exists with a different parameter name ("${J.params.name}") in the same location`);let M=J.params;if(M.inert===null){J=M.inert=o6(N);continue}J=M.inert}for(let O=0;;){if(O===N.length){if(O<J.part.length){let M=Bw(J,J.part.slice(O));Object.assign(J,o6(N,[M]))}break}if(O===J.part.length){if(J.inert===null)J.inert={};let M=J.inert[N.charCodeAt(O)];if(M){J=M,N=N.slice(O),O=0;continue}let C=o6(N.slice(O));J.inert[N.charCodeAt(O)]=C,J=C;break}if(N[O]!==J.part[O]){let M=Bw(J,J.part.slice(O)),C=o6(N.slice(O));Object.assign(J,o6(J.part.slice(0,O),[M,C])),J=C;break}++O}}if(G<Y.length){let S=Y[G].slice(1);if(J.params===null)J.params=Mw(S);else if(J.params.name!==S)if(W)return U;else throw new Error(`Cannot create route "${w}" with parameter "${S}" because a route already exists with a different parameter name ("${J.params.name}") in the same location`);if(J.params.store===null)J.params.store=U;return J.params.store}if($){if(J.wildcardStore===null)J.wildcardStore=U;return J.wildcardStore}if(J.store===null)J.store=U;return J.store}find(z,w){let U=this.root[z];if(!U)return null;return Z8(w,w.length,U,0)}}var Z8=(z,w,U,W)=>{let X=U.part,Z=X.length,$=W+Z;if(Z>1){if($>w)return null;if(Z<15){for(let A=1,Q=W+1;A<Z;++A,++Q)if(X.charCodeAt(A)!==z.charCodeAt(Q))return null}else if(z.slice(W,$)!==X)return null}if($===w){if(U.store!==null)return{store:U.store,params:{}};if(U.wildcardStore!==null)return{store:U.wildcardStore,params:{"*":""}};return null}if(U.inert!==null){let A=U.inert[z.charCodeAt($)];if(A!==void 0){let Q=Z8(z,w,A,$);if(Q!==null)return Q}}if(U.params!==null){let{store:A,name:Q,inert:Y}=U.params,J=z.indexOf("/",$);if(J!==$){if(J===-1||J>=w){if(A!==null){let G={};return G[Q]=z.substring($,w),{store:A,params:G}}}else if(Y!==null){let G=Z8(z,w,Y,J);if(G!==null)return G.params[Q]=z.substring($,J),G}}}if(U.wildcardStore!==null)return{store:U.wildcardStore,params:{"*":z.substring($,w)}};return null};var Y2={};j6(Y2,{IsUndefined:()=>t0,IsUint8Array:()=>h1,IsSymbol:()=>Wz,IsString:()=>j0,IsRegExp:()=>K4,IsObject:()=>P0,IsNumber:()=>V2,IsNull:()=>Uz,IsIterator:()=>wz,IsFunction:()=>zz,IsDate:()=>E6,IsBoolean:()=>d1,IsBigInt:()=>b4,IsAsyncIterator:()=>e5,IsArray:()=>m0,HasPropertyKey:()=>$8});function $8(z,w){return w in z}function e5(z){return P0(z)&&!m0(z)&&!h1(z)&&Symbol.asyncIterator in z}function m0(z){return Array.isArray(z)}function b4(z){return typeof z==="bigint"}function d1(z){return typeof z==="boolean"}function E6(z){return z instanceof globalThis.Date}function zz(z){return typeof z==="function"}function wz(z){return P0(z)&&!m0(z)&&!h1(z)&&Symbol.iterator in z}function Uz(z){return z===null}function V2(z){return typeof z==="number"}function P0(z){return typeof z==="object"&&z!==null}function K4(z){return z instanceof globalThis.RegExp}function j0(z){return typeof z==="string"}function Wz(z){return typeof z==="symbol"}function h1(z){return z instanceof globalThis.Uint8Array}function t0(z){return z===void 0}function CX(z){return z.map((w)=>A8(w))}function bX(z){return new Date(z.getTime())}function KX(z){return new Uint8Array(z)}function jX(z){return new RegExp(z.source,z.flags)}function FX(z){let w={};for(let U of Object.getOwnPropertyNames(z))w[U]=A8(z[U]);for(let U of Object.getOwnPropertySymbols(z))w[U]=A8(z[U]);return w}function A8(z){return m0(z)?CX(z):E6(z)?bX(z):h1(z)?KX(z):K4(z)?jX(z):P0(z)?FX(z):z}function V0(z){return A8(z)}function p6(z,w){return w===void 0?V0(z):V0({...w,...z})}function Q8(z){return l(z)&&globalThis.Symbol.asyncIterator in z}function Y8(z){return l(z)&&globalThis.Symbol.iterator in z}function Xz(z){return l(z)&&(globalThis.Object.getPrototypeOf(z)===Object.prototype||globalThis.Object.getPrototypeOf(z)===null)}function J8(z){return z instanceof globalThis.Promise}function G2(z){return z instanceof Date&&globalThis.Number.isFinite(z.getTime())}function qw(z){return z instanceof globalThis.Map}function Lw(z){return z instanceof globalThis.Set}function v2(z){return globalThis.ArrayBuffer.isView(z)}function l6(z){return z instanceof globalThis.Uint8Array}function u(z,w){return w in z}function l(z){return z!==null&&typeof z==="object"}function m(z){return globalThis.Array.isArray(z)&&!globalThis.ArrayBuffer.isView(z)}function k0(z){return z===void 0}function c1(z){return z===null}function F1(z){return typeof z==="boolean"}function v(z){return typeof z==="number"}function B8(z){return globalThis.Number.isInteger(z)}function X2(z){return typeof z==="bigint"}function A0(z){return typeof z==="string"}function $6(z){return typeof z==="function"}function i1(z){return typeof z==="symbol"}function k2(z){return X2(z)||F1(z)||c1(z)||v(z)||A0(z)||i1(z)||k0(z)}var I0;(function(z){z.InstanceMode="default",z.ExactOptionalPropertyTypes=!1,z.AllowArrayObject=!1,z.AllowNaN=!1,z.AllowNullVoid=!1;function w($,A){return z.ExactOptionalPropertyTypes?A in $:$[A]!==void 0}z.IsExactOptionalProperty=w;function U($){let A=l($);return z.AllowArrayObject?A:A&&!m($)}z.IsObjectLike=U;function W($){return U($)&&!($ instanceof Date)&&!($ instanceof Uint8Array)}z.IsRecordLike=W;function X($){return z.AllowNaN?v($):Number.isFinite($)}z.IsNumberLike=X;function Z($){let A=k0($);return z.AllowNullVoid?A||$===null:A}z.IsVoidLike=Z})(I0||(I0={}));function EX(z){return globalThis.Object.freeze(z).map((w)=>j4(w))}function IX(z){return z}function xX(z){return z}function VX(z){return z}function kX(z){let w={};for(let U of Object.getOwnPropertyNames(z))w[U]=j4(z[U]);for(let U of Object.getOwnPropertySymbols(z))w[U]=j4(z[U]);return globalThis.Object.freeze(w)}function j4(z){return m0(z)?EX(z):E6(z)?IX(z):h1(z)?xX(z):K4(z)?VX(z):P0(z)?kX(z):z}function D(z,w){let U=w!==void 0?{...w,...z}:z;switch(I0.InstanceMode){case"freeze":return j4(U);case"clone":return V0(U);default:return U}}class n extends Error{constructor(z){super(z)}}var F0=Symbol.for("TypeBox.Transform"),$1=Symbol.for("TypeBox.Readonly"),Z2=Symbol.for("TypeBox.Optional"),n2=Symbol.for("TypeBox.Hint"),H=Symbol.for("TypeBox.Kind");function s6(z){return P0(z)&&z[$1]==="Readonly"}function S2(z){return P0(z)&&z[Z2]==="Optional"}function Zz(z){return X0(z,"Any")}function $z(z){return X0(z,"Argument")}function A1(z){return X0(z,"Array")}function I6(z){return X0(z,"AsyncIterator")}function x6(z){return X0(z,"BigInt")}function y1(z){return X0(z,"Boolean")}function Q1(z){return X0(z,"Computed")}function Y1(z){return X0(z,"Constructor")}function TX(z){return X0(z,"Date")}function J1(z){return X0(z,"Function")}function B1(z){return X0(z,"Integer")}function c0(z){return X0(z,"Intersect")}function V6(z){return X0(z,"Iterator")}function X0(z,w){return P0(z)&&H in z&&z[H]===w}function M8(z){return d1(z)||V2(z)||j0(z)}function T2(z){return X0(z,"Literal")}function g2(z){return X0(z,"MappedKey")}function T0(z){return X0(z,"MappedResult")}function A6(z){return X0(z,"Never")}function gX(z){return X0(z,"Not")}function F4(z){return X0(z,"Null")}function M1(z){return X0(z,"Number")}function o0(z){return X0(z,"Object")}function k6(z){return X0(z,"Promise")}function T6(z){return X0(z,"Record")}function u0(z){return X0(z,"Ref")}function Az(z){return X0(z,"RegExp")}function v1(z){return X0(z,"String")}function E4(z){return X0(z,"Symbol")}function f2(z){return X0(z,"TemplateLiteral")}function fX(z){return X0(z,"This")}function G0(z){return P0(z)&&F0 in z}function d2(z){return X0(z,"Tuple")}function n1(z){return X0(z,"Undefined")}function Q0(z){return X0(z,"Union")}function dX(z){return X0(z,"Uint8Array")}function hX(z){return X0(z,"Unknown")}function cX(z){return X0(z,"Unsafe")}function iX(z){return X0(z,"Void")}function Q6(z){return P0(z)&&H in z&&j0(z[H])}function f0(z){return Zz(z)||$z(z)||A1(z)||y1(z)||x6(z)||I6(z)||Q1(z)||Y1(z)||TX(z)||J1(z)||B1(z)||c0(z)||V6(z)||T2(z)||g2(z)||T0(z)||A6(z)||gX(z)||F4(z)||M1(z)||o0(z)||k6(z)||T6(z)||u0(z)||Az(z)||v1(z)||E4(z)||f2(z)||fX(z)||d2(z)||n1(z)||Q0(z)||dX(z)||hX(z)||cX(z)||iX(z)||Q6(z)}var q={};j6(q,{TypeGuardUnknownTypeError:()=>Gw,IsVoid:()=>U9,IsUnsafe:()=>w9,IsUnknown:()=>z9,IsUnionLiteral:()=>lX,IsUnion:()=>Jz,IsUndefined:()=>aw,IsUint8Array:()=>ew,IsTuple:()=>rw,IsTransform:()=>sw,IsThis:()=>lw,IsTemplateLiteral:()=>pw,IsSymbol:()=>ow,IsString:()=>tw,IsSchema:()=>g0,IsRegExp:()=>mw,IsRef:()=>uw,IsRecursive:()=>pX,IsRecord:()=>nw,IsReadonly:()=>uX,IsProperties:()=>q8,IsPromise:()=>vw,IsOptional:()=>mX,IsObject:()=>yw,IsNumber:()=>iw,IsNull:()=>cw,IsNot:()=>hw,IsNever:()=>dw,IsMappedResult:()=>fw,IsMappedKey:()=>gw,IsLiteralValue:()=>Tw,IsLiteralString:()=>Vw,IsLiteralNumber:()=>kw,IsLiteralBoolean:()=>oX,IsLiteral:()=>x4,IsKindOf:()=>z0,IsKind:()=>W9,IsIterator:()=>xw,IsIntersect:()=>Iw,IsInteger:()=>Ew,IsImport:()=>tX,IsFunction:()=>Fw,IsDate:()=>jw,IsConstructor:()=>Kw,IsComputed:()=>bw,IsBoolean:()=>Cw,IsBigInt:()=>Rw,IsAsyncIterator:()=>Ow,IsArray:()=>Pw,IsArgument:()=>Dw,IsAny:()=>Sw});class Gw extends n{}var yX=["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 Nw(z){try{return new RegExp(z),!0}catch{return!1}}function Qz(z){if(!j0(z))return!1;for(let w=0;w<z.length;w++){let U=z.charCodeAt(w);if(U>=7&&U<=13||U===27||U===127)return!1}return!0}function Hw(z){return Yz(z)||g0(z)}function I4(z){return t0(z)||b4(z)}function E0(z){return t0(z)||V2(z)}function Yz(z){return t0(z)||d1(z)}function O0(z){return t0(z)||j0(z)}function vX(z){return t0(z)||j0(z)&&Qz(z)&&Nw(z)}function nX(z){return t0(z)||j0(z)&&Qz(z)}function _w(z){return t0(z)||g0(z)}function uX(z){return P0(z)&&z[$1]==="Readonly"}function mX(z){return P0(z)&&z[Z2]==="Optional"}function Sw(z){return z0(z,"Any")&&O0(z.$id)}function Dw(z){return z0(z,"Argument")&&V2(z.index)}function Pw(z){return z0(z,"Array")&&z.type==="array"&&O0(z.$id)&&g0(z.items)&&E0(z.minItems)&&E0(z.maxItems)&&Yz(z.uniqueItems)&&_w(z.contains)&&E0(z.minContains)&&E0(z.maxContains)}function Ow(z){return z0(z,"AsyncIterator")&&z.type==="AsyncIterator"&&O0(z.$id)&&g0(z.items)}function Rw(z){return z0(z,"BigInt")&&z.type==="bigint"&&O0(z.$id)&&I4(z.exclusiveMaximum)&&I4(z.exclusiveMinimum)&&I4(z.maximum)&&I4(z.minimum)&&I4(z.multipleOf)}function Cw(z){return z0(z,"Boolean")&&z.type==="boolean"&&O0(z.$id)}function bw(z){return z0(z,"Computed")&&j0(z.target)&&m0(z.parameters)&&z.parameters.every((w)=>g0(w))}function Kw(z){return z0(z,"Constructor")&&z.type==="Constructor"&&O0(z.$id)&&m0(z.parameters)&&z.parameters.every((w)=>g0(w))&&g0(z.returns)}function jw(z){return z0(z,"Date")&&z.type==="Date"&&O0(z.$id)&&E0(z.exclusiveMaximumTimestamp)&&E0(z.exclusiveMinimumTimestamp)&&E0(z.maximumTimestamp)&&E0(z.minimumTimestamp)&&E0(z.multipleOfTimestamp)}function Fw(z){return z0(z,"Function")&&z.type==="Function"&&O0(z.$id)&&m0(z.parameters)&&z.parameters.every((w)=>g0(w))&&g0(z.returns)}function tX(z){return z0(z,"Import")&&$8(z,"$defs")&&P0(z.$defs)&&q8(z.$defs)&&$8(z,"$ref")&&j0(z.$ref)&&z.$ref in z.$defs}function Ew(z){return z0(z,"Integer")&&z.type==="integer"&&O0(z.$id)&&E0(z.exclusiveMaximum)&&E0(z.exclusiveMinimum)&&E0(z.maximum)&&E0(z.minimum)&&E0(z.multipleOf)}function q8(z){return P0(z)&&Object.entries(z).every(([w,U])=>Qz(w)&&g0(U))}function Iw(z){return z0(z,"Intersect")&&(j0(z.type)&&z.type!=="object"?!1:!0)&&m0(z.allOf)&&z.allOf.every((w)=>g0(w)&&!sw(w))&&O0(z.type)&&(Yz(z.unevaluatedProperties)||_w(z.unevaluatedProperties))&&O0(z.$id)}function xw(z){return z0(z,"Iterator")&&z.type==="Iterator"&&O0(z.$id)&&g0(z.items)}function z0(z,w){return P0(z)&&H in z&&z[H]===w}function Vw(z){return x4(z)&&j0(z.const)}function kw(z){return x4(z)&&V2(z.const)}function oX(z){return x4(z)&&d1(z.const)}function x4(z){return z0(z,"Literal")&&O0(z.$id)&&Tw(z.const)}function Tw(z){return d1(z)||V2(z)||j0(z)}function gw(z){return z0(z,"MappedKey")&&m0(z.keys)&&z.keys.every((w)=>V2(w)||j0(w))}function fw(z){return z0(z,"MappedResult")&&q8(z.properties)}function dw(z){return z0(z,"Never")&&P0(z.not)&&Object.getOwnPropertyNames(z.not).length===0}function hw(z){return z0(z,"Not")&&g0(z.not)}function cw(z){return z0(z,"Null")&&z.type==="null"&&O0(z.$id)}function iw(z){return z0(z,"Number")&&z.type==="number"&&O0(z.$id)&&E0(z.exclusiveMaximum)&&E0(z.exclusiveMinimum)&&E0(z.maximum)&&E0(z.minimum)&&E0(z.multipleOf)}function yw(z){return z0(z,"Object")&&z.type==="object"&&O0(z.$id)&&q8(z.properties)&&Hw(z.additionalProperties)&&E0(z.minProperties)&&E0(z.maxProperties)}function vw(z){return z0(z,"Promise")&&z.type==="Promise"&&O0(z.$id)&&g0(z.item)}function nw(z){return z0(z,"Record")&&z.type==="object"&&O0(z.$id)&&Hw(z.additionalProperties)&&P0(z.patternProperties)&&((w)=>{let U=Object.getOwnPropertyNames(w.patternProperties);return U.length===1&&Nw(U[0])&&P0(w.patternProperties)&&g0(w.patternProperties[U[0]])})(z)}function pX(z){return P0(z)&&n2 in z&&z[n2]==="Recursive"}function uw(z){return z0(z,"Ref")&&O0(z.$id)&&j0(z.$ref)}function mw(z){return z0(z,"RegExp")&&O0(z.$id)&&j0(z.source)&&j0(z.flags)&&E0(z.maxLength)&&E0(z.minLength)}function tw(z){return z0(z,"String")&&z.type==="string"&&O0(z.$id)&&E0(z.minLength)&&E0(z.maxLength)&&vX(z.pattern)&&nX(z.format)}function ow(z){return z0(z,"Symbol")&&z.type==="symbol"&&O0(z.$id)}function pw(z){return z0(z,"TemplateLiteral")&&z.type==="string"&&j0(z.pattern)&&z.pattern[0]==="^"&&z.pattern[z.pattern.length-1]==="$"}function lw(z){return z0(z,"This")&&O0(z.$id)&&j0(z.$ref)}function sw(z){return P0(z)&&F0 in z}function rw(z){return z0(z,"Tuple")&&z.type==="array"&&O0(z.$id)&&V2(z.minItems)&&V2(z.maxItems)&&z.minItems===z.maxItems&&(t0(z.items)&&t0(z.additionalItems)&&z.minItems===0||m0(z.items)&&z.items.every((w)=>g0(w)))}function aw(z){return z0(z,"Undefined")&&z.type==="undefined"&&O0(z.$id)}function lX(z){return Jz(z)&&z.anyOf.every((w)=>Vw(w)||kw(w))}function Jz(z){return z0(z,"Union")&&O0(z.$id)&&P0(z)&&m0(z.anyOf)&&z.anyOf.every((w)=>g0(w))}function ew(z){return z0(z,"Uint8Array")&&z.type==="Uint8Array"&&O0(z.$id)&&E0(z.minByteLength)&&E0(z.maxByteLength)}function z9(z){return z0(z,"Unknown")&&O0(z.$id)}function w9(z){return z0(z,"Unsafe")}function U9(z){return z0(z,"Void")&&z.type==="void"&&O0(z.$id)}function W9(z){return P0(z)&&H in z&&j0(z[H])&&!yX.includes(z[H])}function g0(z){return P0(z)&&(Sw(z)||Dw(z)||Pw(z)||Cw(z)||Rw(z)||Ow(z)||bw(z)||Kw(z)||jw(z)||Fw(z)||Ew(z)||Iw(z)||xw(z)||x4(z)||gw(z)||fw(z)||dw(z)||hw(z)||cw(z)||iw(z)||yw(z)||vw(z)||nw(z)||uw(z)||mw(z)||tw(z)||ow(z)||pw(z)||lw(z)||rw(z)||aw(z)||Jz(z)||ew(z)||z9(z)||w9(z)||U9(z)||W9(z))}var X9="(true|false)",L8="(0|[1-9][0-9]*)",Z9="(.*)";var E1="^(0|[1-9][0-9]*)$",I1="^(.*)$",$9="^(?!.*)$";var D0={};j6(D0,{Set:()=>zZ,Has:()=>eX,Get:()=>wZ,Entries:()=>sX,Delete:()=>aX,Clear:()=>rX});var r6=new Map;function sX(){return new Map(r6)}function rX(){return r6.clear()}function aX(z){return r6.delete(z)}function eX(z){return r6.has(z)}function zZ(z,w){r6.set(z,w)}function wZ(z){return r6.get(z)}var p0={};j6(p0,{Set:()=>$Z,Has:()=>ZZ,Get:()=>AZ,Entries:()=>UZ,Delete:()=>XZ,Clear:()=>WZ});var a6=new Map;function UZ(){return new Map(a6)}function WZ(){return a6.clear()}function XZ(z){return a6.delete(z)}function ZZ(z){return a6.has(z)}function $Z(z,w){a6.set(z,w)}function AZ(z){return a6.get(z)}function A9(z,w){return z.includes(w)}function Q9(z){return[...new Set(z)]}function QZ(z,w){return z.filter((U)=>w.includes(U))}function YZ(z,w){return z.reduce((U,W)=>{return QZ(U,W)},w)}function Y9(z){return z.length===1?z[0]:z.length>1?YZ(z.slice(1),z[0]):[]}function J9(z){let w=[];for(let U of z)w.push(...U);return w}function Y6(z){return D({[H]:"Any"},z)}function e6(z,w){return D({[H]:"Array",type:"array",items:z},w)}function B9(z){return D({[H]:"Argument",index:z})}function z4(z,w){return D({[H]:"AsyncIterator",type:"AsyncIterator",items:z},w)}function x0(z,w,U){return D({[H]:"Computed",target:z,parameters:w},U)}function JZ(z,w){let{[w]:U,...W}=z;return W}function i0(z,w){return w.reduce((U,W)=>JZ(U,W),z)}function p(z){return D({[H]:"Never",not:{}},z)}function J0(z){return D({[H]:"MappedResult",properties:z})}function w4(z,w,U){return D({[H]:"Constructor",type:"Constructor",parameters:z,returns:w},U)}function x1(z,w,U){return D({[H]:"Function",type:"Function",parameters:z,returns:w},U)}function V4(z,w){return D({[H]:"Union",anyOf:z},w)}function BZ(z){return z.some((w)=>S2(w))}function M9(z){return z.map((w)=>S2(w)?MZ(w):w)}function MZ(z){return i0(z,[Z2])}function qZ(z,w){return BZ(z)?J2(V4(M9(z),w)):V4(M9(z),w)}function V1(z,w){return z.length===1?D(z[0],w):z.length===0?p(w):qZ(z,w)}function N0(z,w){return z.length===0?p(w):z.length===1?D(z[0],w):V4(z,w)}class Bz extends n{}function LZ(z){return z.replace(/\\\$/g,"$").replace(/\\\*/g,"*").replace(/\\\^/g,"^").replace(/\\\|/g,"|").replace(/\\\(/g,"(").replace(/\\\)/g,")")}function Mz(z,w,U){return z[w]===U&&z.charCodeAt(w-1)!==92}function m1(z,w){return Mz(z,w,"(")}function k4(z,w){return Mz(z,w,")")}function q9(z,w){return Mz(z,w,"|")}function GZ(z){if(!(m1(z,0)&&k4(z,z.length-1)))return!1;let w=0;for(let U=0;U<z.length;U++){if(m1(z,U))w+=1;if(k4(z,U))w-=1;if(w===0&&U!==z.length-1)return!1}return!0}function NZ(z){return z.slice(1,z.length-1)}function HZ(z){let w=0;for(let U=0;U<z.length;U++){if(m1(z,U))w+=1;if(k4(z,U))w-=1;if(q9(z,U)&&w===0)return!0}return!1}function _Z(z){for(let w=0;w<z.length;w++)if(m1(z,w))return!0;return!1}function SZ(z){let[w,U]=[0,0],W=[];for(let Z=0;Z<z.length;Z++){if(m1(z,Z))w+=1;if(k4(z,Z))w-=1;if(q9(z,Z)&&w===0){let $=z.slice(U,Z);if($.length>0)W.push(U4($));U=Z+1}}let X=z.slice(U);if(X.length>0)W.push(U4(X));if(W.length===0)return{type:"const",const:""};if(W.length===1)return W[0];return{type:"or",expr:W}}function DZ(z){function w(X,Z){if(!m1(X,Z))throw new Bz("TemplateLiteralParser: Index must point to open parens");let $=0;for(let A=Z;A<X.length;A++){if(m1(X,A))$+=1;if(k4(X,A))$-=1;if($===0)return[Z,A]}throw new Bz("TemplateLiteralParser: Unclosed group parens in expression")}function U(X,Z){for(let $=Z;$<X.length;$++)if(m1(X,$))return[Z,$];return[Z,X.length]}let W=[];for(let X=0;X<z.length;X++)if(m1(z,X)){let[Z,$]=w(z,X),A=z.slice(Z,$+1);W.push(U4(A)),X=$}else{let[Z,$]=U(z,X),A=z.slice(Z,$);if(A.length>0)W.push(U4(A));X=$-1}return W.length===0?{type:"const",const:""}:W.length===1?W[0]:{type:"and",expr:W}}function U4(z){return GZ(z)?U4(NZ(z)):HZ(z)?SZ(z):_Z(z)?DZ(z):{type:"const",const:LZ(z)}}function W4(z){return U4(z.slice(1,z.length-1))}class L9 extends n{}function PZ(z){return z.type==="or"&&z.expr.length===2&&z.expr[0].type==="const"&&z.expr[0].const==="0"&&z.expr[1].type==="const"&&z.expr[1].const==="[1-9][0-9]*"}function OZ(z){return z.type==="or"&&z.expr.length===2&&z.expr[0].type==="const"&&z.expr[0].const==="true"&&z.expr[1].type==="const"&&z.expr[1].const==="false"}function RZ(z){return z.type==="const"&&z.const===".*"}function g6(z){return PZ(z)||RZ(z)?!1:OZ(z)?!0:z.type==="and"?z.expr.every((w)=>g6(w)):z.type==="or"?z.expr.every((w)=>g6(w)):z.type==="const"?!0:(()=>{throw new L9("Unknown expression type")})()}function G8(z){let w=W4(z.pattern);return g6(w)}class G9 extends n{}function*N9(z){if(z.length===1)return yield*z[0];for(let w of z[0])for(let U of N9(z.slice(1)))yield`${w}${U}`}function*CZ(z){return yield*N9(z.expr.map((w)=>[...T4(w)]))}function*bZ(z){for(let w of z.expr)yield*T4(w)}function*KZ(z){return yield z.const}function*T4(z){return z.type==="and"?yield*CZ(z):z.type==="or"?yield*bZ(z):z.type==="const"?yield*KZ(z):(()=>{throw new G9("Unknown expression")})()}function X4(z){let w=W4(z.pattern);return g6(w)?[...T4(w)]:[]}function Z0(z,w){return D({[H]:"Literal",const:z,type:typeof z},w)}function N8(z){return D({[H]:"Boolean",type:"boolean"},z)}function Z4(z){return D({[H]:"BigInt",type:"bigint"},z)}function u2(z){return D({[H]:"Number",type:"number"},z)}function N2(z){return D({[H]:"String",type:"string"},z)}function*jZ(z){let w=z.trim().replace(/"|'/g,"");return w==="boolean"?yield N8():w==="number"?yield u2():w==="bigint"?yield Z4():w==="string"?yield N2():yield(()=>{let U=w.split("|").map((W)=>Z0(W.trim()));return U.length===0?p():U.length===1?U[0]:V1(U)})()}function*FZ(z){if(z[1]!=="{"){let w=Z0("$"),U=qz(z.slice(1));return yield*[w,...U]}for(let w=2;w<z.length;w++)if(z[w]==="}"){let U=jZ(z.slice(2,w)),W=qz(z.slice(w+1));return yield*[...U,...W]}yield Z0(z)}function*qz(z){for(let w=0;w<z.length;w++)if(z[w]==="$"){let U=Z0(z.slice(0,w)),W=FZ(z.slice(w));return yield*[U,...W]}yield Z0(z)}function H9(z){return[...qz(z)]}class _9 extends n{}function EZ(z){return z.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function S9(z,w){return f2(z)?z.pattern.slice(1,z.pattern.length-1):Q0(z)?`(${z.anyOf.map((U)=>S9(U,w)).join("|")})`:M1(z)?`${w}${L8}`:B1(z)?`${w}${L8}`:x6(z)?`${w}${L8}`:v1(z)?`${w}${Z9}`:T2(z)?`${w}${EZ(z.const.toString())}`:y1(z)?`${w}${X9}`:(()=>{throw new _9(`Unexpected Kind '${z[H]}'`)})()}function Lz(z){return`^${z.map((w)=>S9(w,"")).join("")}$`}function f6(z){let U=X4(z).map((W)=>Z0(W));return V1(U)}function H8(z,w){let U=j0(z)?Lz(H9(z)):Lz(z);return D({[H]:"TemplateLiteral",type:"string",pattern:U},w)}function IZ(z){return X4(z).map((U)=>U.toString())}function xZ(z){let w=[];for(let U of z)w.push(...D2(U));return w}function VZ(z){return[z.toString()]}function D2(z){return[...new Set(f2(z)?IZ(z):Q0(z)?xZ(z.anyOf):T2(z)?VZ(z.const):M1(z)?["[number]"]:B1(z)?["[number]"]:[])]}function kZ(z,w,U){let W={};for(let X of Object.getOwnPropertyNames(w))W[X]=J6(z,D2(w[X]),U);return W}function TZ(z,w,U){return kZ(z,w.properties,U)}function D9(z,w,U){let W=TZ(z,w,U);return J0(W)}function O9(z,w){return z.map((U)=>R9(U,w))}function gZ(z){return z.filter((w)=>!A6(w))}function fZ(z,w){return _8(gZ(O9(z,w)))}function dZ(z){return z.some((w)=>A6(w))?[]:z}function hZ(z,w){return V1(dZ(O9(z,w)))}function cZ(z,w){return w in z?z[w]:w==="[number]"?V1(z):p()}function iZ(z,w){return w==="[number]"?z:p()}function yZ(z,w){return w in z?z[w]:p()}function R9(z,w){return c0(z)?fZ(z.allOf,w):Q0(z)?hZ(z.anyOf,w):d2(z)?cZ(z.items??[],w):A1(z)?iZ(z.items,w):o0(z)?yZ(z.properties,w):p()}function g4(z,w){return w.map((U)=>R9(z,U))}function P9(z,w){return V1(g4(z,w))}function J6(z,w,U){if(u0(z)||u0(w)){if(!f0(z)||!f0(w))throw new n("Index types using Ref parameters require both Type and Key to be of TSchema");return x0("Index",[z,w])}if(T0(w))return D9(z,w,U);if(g2(w))return C9(z,w,U);return D(f0(w)?P9(z,D2(w)):P9(z,w),U)}function vZ(z,w,U){return{[w]:J6(z,[w],V0(U))}}function nZ(z,w,U){return w.reduce((W,X)=>{return{...W,...vZ(z,X,U)}},{})}function uZ(z,w,U){return nZ(z,w.keys,U)}function C9(z,w,U){let W=uZ(z,w,U);return J0(W)}function $4(z,w){return D({[H]:"Iterator",type:"Iterator",items:z},w)}function mZ(z){let w=[];for(let U in z)if(!S2(z[U]))w.push(U);return w}function tZ(z,w){let U=mZ(z),W=U.length>0?{[H]:"Object",type:"object",properties:z,required:U}:{[H]:"Object",type:"object",properties:z};return D(W,w)}var H0=tZ;function S8(z,w){return D({[H]:"Promise",type:"Promise",item:z},w)}function oZ(z){return D(i0(z,[$1]))}function pZ(z){return D({...z,[$1]:"Readonly"})}function lZ(z,w){return w===!1?oZ(z):pZ(z)}function P2(z,w){let U=w??!0;return T0(z)?b9(z,U):lZ(z,U)}function sZ(z,w){let U={};for(let W of globalThis.Object.getOwnPropertyNames(z))U[W]=P2(z[W],w);return U}function rZ(z,w){return sZ(z.properties,w)}function b9(z,w){let U=rZ(z,w);return J0(U)}function m2(z,w){return D(z.length>0?{[H]:"Tuple",type:"array",items:z,additionalItems:!1,minItems:z.length,maxItems:z.length}:{[H]:"Tuple",type:"array",minItems:z.length,maxItems:z.length},w)}function K9(z,w){return z in w?t2(z,w[z]):J0(w)}function aZ(z){return{[z]:Z0(z)}}function eZ(z){let w={};for(let U of z)w[U]=Z0(U);return w}function z$(z,w){return A9(w,z)?aZ(z):eZ(w)}function w$(z,w){let U=z$(z,w);return K9(z,U)}function f4(z,w){return w.map((U)=>t2(z,U))}function U$(z,w){let U={};for(let W of globalThis.Object.getOwnPropertyNames(w))U[W]=t2(z,w[W]);return U}function t2(z,w){let U={...w};return S2(w)?J2(t2(z,i0(w,[Z2]))):s6(w)?P2(t2(z,i0(w,[$1]))):T0(w)?K9(z,w.properties):g2(w)?w$(z,w.keys):Y1(w)?w4(f4(z,w.parameters),t2(z,w.returns),U):J1(w)?x1(f4(z,w.parameters),t2(z,w.returns),U):I6(w)?z4(t2(z,w.items),U):V6(w)?$4(t2(z,w.items),U):c0(w)?B2(f4(z,w.allOf),U):Q0(w)?N0(f4(z,w.anyOf),U):d2(w)?m2(f4(z,w.items??[]),U):o0(w)?H0(U$(z,w.properties),U):A1(w)?e6(t2(z,w.items),U):k6(w)?S8(t2(z,w.item),U):w}function W$(z,w){let U={};for(let W of z)U[W]=t2(W,w);return U}function j9(z,w,U){let W=f0(z)?D2(z):z,X=w({[H]:"MappedKey",keys:W}),Z=W$(W,X);return H0(Z,U)}function X$(z){return D(i0(z,[Z2]))}function Z$(z){return D({...z,[Z2]:"Optional"})}function $$(z,w){return w===!1?X$(z):Z$(z)}function J2(z,w){let U=w??!0;return T0(z)?F9(z,U):$$(z,U)}function A$(z,w){let U={};for(let W of globalThis.Object.getOwnPropertyNames(z))U[W]=J2(z[W],w);return U}function Q$(z,w){return A$(z.properties,w)}function F9(z,w){let U=Q$(z,w);return J0(U)}function d4(z,w={}){let U=z.every((X)=>o0(X)),W=f0(w.unevaluatedProperties)?{unevaluatedProperties:w.unevaluatedProperties}:{};return D(w.unevaluatedProperties===!1||f0(w.unevaluatedProperties)||U?{...W,[H]:"Intersect",type:"object",allOf:z}:{...W,[H]:"Intersect",allOf:z},w)}function Y$(z){return z.every((w)=>S2(w))}function J$(z){return i0(z,[Z2])}function E9(z){return z.map((w)=>S2(w)?J$(w):w)}function B$(z,w){return Y$(z)?J2(d4(E9(z),w)):d4(E9(z),w)}function _8(z,w={}){if(z.length===1)return D(z[0],w);if(z.length===0)return p(w);if(z.some((U)=>G0(U)))throw new Error("Cannot intersect transform types");return B$(z,w)}function B2(z,w){if(z.length===1)return D(z[0],w);if(z.length===0)return p(w);if(z.some((U)=>G0(U)))throw new Error("Cannot intersect transform types");return d4(z,w)}function o2(...z){let[w,U]=typeof z[0]==="string"?[z[0],z[1]]:[z[0].$id,z[1]];if(typeof w!=="string")throw new n("Ref: $ref must be a string");return D({[H]:"Ref",$ref:w},U)}function M$(z,w){return x0("Awaited",[x0(z,w)])}function q$(z){return x0("Awaited",[o2(z)])}function L$(z){return B2(I9(z))}function G$(z){return N0(I9(z))}function N$(z){return A4(z)}function I9(z){return z.map((w)=>A4(w))}function A4(z,w){return D(Q1(z)?M$(z.target,z.parameters):c0(z)?L$(z.allOf):Q0(z)?G$(z.anyOf):k6(z)?N$(z.item):u0(z)?q$(z.$ref):z,w)}function x9(z){let w=[];for(let U of z)w.push(O2(U));return w}function H$(z){let w=x9(z);return J9(w)}function _$(z){let w=x9(z);return Y9(w)}function S$(z){return z.map((w,U)=>U.toString())}function D$(z){return["[number]"]}function P$(z){return globalThis.Object.getOwnPropertyNames(z)}function O$(z){if(!Gz)return[];return globalThis.Object.getOwnPropertyNames(z).map((U)=>{return U[0]==="^"&&U[U.length-1]==="$"?U.slice(1,U.length-1):U})}function O2(z){return c0(z)?H$(z.allOf):Q0(z)?_$(z.anyOf):d2(z)?S$(z.items??[]):A1(z)?D$(z.items):o0(z)?P$(z.properties):T6(z)?O$(z.patternProperties):[]}var Gz=!1;function t1(z){Gz=!0;let w=O2(z);return Gz=!1,`^(${w.map((W)=>`(${W})`).join("|")})$`}function R$(z,w){return x0("KeyOf",[x0(z,w)])}function C$(z){return x0("KeyOf",[o2(z)])}function b$(z,w){let U=O2(z),W=K$(U),X=V1(W);return D(X,w)}function K$(z){return z.map((w)=>w==="[number]"?u2():Z0(w))}function Q4(z,w){return Q1(z)?R$(z.target,z.parameters):u0(z)?C$(z.$ref):T0(z)?V9(z,w):b$(z,w)}function j$(z,w){let U={};for(let W of globalThis.Object.getOwnPropertyNames(z))U[W]=Q4(z[W],V0(w));return U}function F$(z,w){return j$(z.properties,w)}function V9(z,w){let U=F$(z,w);return J0(U)}function D8(z){let w=O2(z),U=g4(z,w);return w.map((W,X)=>[w[X],U[X]])}function E$(z){let w=[];for(let U of z)w.push(...O2(U));return Q9(w)}function I$(z){return z.filter((w)=>!A6(w))}function x$(z,w){let U=[];for(let W of z)U.push(...g4(W,[w]));return I$(U)}function V$(z,w){let U={};for(let W of w)U[W]=_8(x$(z,W));return U}function k9(z,w){let U=E$(z),W=V$(z,U);return H0(W,w)}function P8(z){return D({[H]:"Date",type:"Date"},z)}function O8(z){return D({[H]:"Null",type:"null"},z)}function R8(z){return D({[H]:"Symbol",type:"symbol"},z)}function C8(z){return D({[H]:"Undefined",type:"undefined"},z)}function b8(z){return D({[H]:"Uint8Array",type:"Uint8Array"},z)}function q1(z){return D({[H]:"Unknown"},z)}function k$(z){return z.map((w)=>Nz(w,!1))}function T$(z){let w={};for(let U of globalThis.Object.getOwnPropertyNames(z))w[U]=P2(Nz(z[U],!1));return w}function K8(z,w){return w===!0?z:P2(z)}function Nz(z,w){return e5(z)?K8(Y6(),w):wz(z)?K8(Y6(),w):m0(z)?P2(m2(k$(z))):h1(z)?b8():E6(z)?P8():P0(z)?K8(H0(T$(z)),w):zz(z)?K8(x1([],q1()),w):t0(z)?C8():Uz(z)?O8():Wz(z)?R8():b4(z)?Z4():V2(z)?Z0(z):d1(z)?Z0(z):j0(z)?Z0(z):H0({})}function T9(z,w){return D(Nz(z,!0),w)}function g9(z,w){return Y1(z)?m2(z.parameters,w):p(w)}function f9(z,w){if(t0(z))throw new Error("Enum undefined or empty");let U=globalThis.Object.getOwnPropertyNames(z).filter((Z)=>isNaN(Z)).map((Z)=>z[Z]),X=[...new Set(U)].map((Z)=>Z0(Z));return N0(X,{...w,[n2]:"Enum"})}class y9 extends n{}var P;(function(z){z[z.Union=0]="Union",z[z.True=1]="True",z[z.False=2]="False"})(P||(P={}));function p2(z){return z===P.False?z:P.True}function Y4(z){throw new y9(z)}function l0(z){return q.IsNever(z)||q.IsIntersect(z)||q.IsUnion(z)||q.IsUnknown(z)||q.IsAny(z)}function s0(z,w){return q.IsNever(w)?u9(z,w):q.IsIntersect(w)?j8(z,w):q.IsUnion(w)?Pz(z,w):q.IsUnknown(w)?p9(z,w):q.IsAny(w)?Dz(z,w):Y4("StructuralRight")}function Dz(z,w){return P.True}function g$(z,w){return q.IsIntersect(w)?j8(z,w):q.IsUnion(w)&&w.anyOf.some((U)=>q.IsAny(U)||q.IsUnknown(U))?P.True:q.IsUnion(w)?P.Union:q.IsUnknown(w)?P.True:q.IsAny(w)?P.True:P.Union}function f$(z,w){return q.IsUnknown(z)?P.False:q.IsAny(z)?P.Union:q.IsNever(z)?P.True:P.False}function d$(z,w){return q.IsObject(w)&&F8(w)?P.True:l0(w)?s0(z,w):!q.IsArray(w)?P.False:p2(R0(z.items,w.items))}function h$(z,w){return l0(w)?s0(z,w):!q.IsAsyncIterator(w)?P.False:p2(R0(z.items,w.items))}function c$(z,w){return l0(w)?s0(z,w):q.IsObject(w)?M2(z,w):q.IsRecord(w)?l2(z,w):q.IsBigInt(w)?P.True:P.False}function v9(z,w){return q.IsLiteralBoolean(z)?P.True:q.IsBoolean(z)?P.True:P.False}function i$(z,w){return l0(w)?s0(z,w):q.IsObject(w)?M2(z,w):q.IsRecord(w)?l2(z,w):q.IsBoolean(w)?P.True:P.False}function y$(z,w){return l0(w)?s0(z,w):q.IsObject(w)?M2(z,w):!q.IsConstructor(w)?P.False:z.parameters.length>w.parameters.length?P.False:!z.parameters.every((U,W)=>p2(R0(w.parameters[W],U))===P.True)?P.False:p2(R0(z.returns,w.returns))}function v$(z,w){return l0(w)?s0(z,w):q.IsObject(w)?M2(z,w):q.IsRecord(w)?l2(z,w):q.IsDate(w)?P.True:P.False}function n$(z,w){return l0(w)?s0(z,w):q.IsObject(w)?M2(z,w):!q.IsFunction(w)?P.False:z.parameters.length>w.parameters.length?P.False:!z.parameters.every((U,W)=>p2(R0(w.parameters[W],U))===P.True)?P.False:p2(R0(z.returns,w.returns))}function n9(z,w){return q.IsLiteral(z)&&Y2.IsNumber(z.const)?P.True:q.IsNumber(z)||q.IsInteger(z)?P.True:P.False}function u$(z,w){return q.IsInteger(w)||q.IsNumber(w)?P.True:l0(w)?s0(z,w):q.IsObject(w)?M2(z,w):q.IsRecord(w)?l2(z,w):P.False}function j8(z,w){return w.allOf.every((U)=>R0(z,U)===P.True)?P.True:P.False}function m$(z,w){return z.allOf.some((U)=>R0(U,w)===P.True)?P.True:P.False}function t$(z,w){return l0(w)?s0(z,w):!q.IsIterator(w)?P.False:p2(R0(z.items,w.items))}function o$(z,w){return q.IsLiteral(w)&&w.const===z.const?P.True:l0(w)?s0(z,w):q.IsObject(w)?M2(z,w):q.IsRecord(w)?l2(z,w):q.IsString(w)?o9(z,w):q.IsNumber(w)?m9(z,w):q.IsInteger(w)?n9(z,w):q.IsBoolean(w)?v9(z,w):P.False}function u9(z,w){return P.False}function p$(z,w){return P.True}function d9(z){let[w,U]=[z,0];while(!0){if(!q.IsNot(w))break;w=w.not,U+=1}return U%2===0?w:q1()}function l$(z,w){return q.IsNot(z)?R0(d9(z),w):q.IsNot(w)?R0(z,d9(w)):Y4("Invalid fallthrough for Not")}function s$(z,w){return l0(w)?s0(z,w):q.IsObject(w)?M2(z,w):q.IsRecord(w)?l2(z,w):q.IsNull(w)?P.True:P.False}function m9(z,w){return q.IsLiteralNumber(z)?P.True:q.IsNumber(z)||q.IsInteger(z)?P.True:P.False}function r$(z,w){return l0(w)?s0(z,w):q.IsObject(w)?M2(z,w):q.IsRecord(w)?l2(z,w):q.IsInteger(w)||q.IsNumber(w)?P.True:P.False}function R2(z,w){return Object.getOwnPropertyNames(z.properties).length===w}function h9(z){return F8(z)}function c9(z){return R2(z,0)||R2(z,1)&&"description"in z.properties&&q.IsUnion(z.properties.description)&&z.properties.description.anyOf.length===2&&(q.IsString(z.properties.description.anyOf[0])&&q.IsUndefined(z.properties.description.anyOf[1])||q.IsString(z.properties.description.anyOf[1])&&q.IsUndefined(z.properties.description.anyOf[0]))}function Hz(z){return R2(z,0)}function i9(z){return R2(z,0)}function a$(z){return R2(z,0)}function e$(z){return R2(z,0)}function zA(z){return F8(z)}function wA(z){let w=u2();return R2(z,0)||R2(z,1)&&"length"in z.properties&&p2(R0(z.properties.length,w))===P.True}function UA(z){return R2(z,0)}function F8(z){let w=u2();return R2(z,0)||R2(z,1)&&"length"in z.properties&&p2(R0(z.properties.length,w))===P.True}function WA(z){let w=x1([Y6()],Y6());return R2(z,0)||R2(z,1)&&"then"in z.properties&&p2(R0(z.properties.then,w))===P.True}function t9(z,w){return R0(z,w)===P.False?P.False:q.IsOptional(z)&&!q.IsOptional(w)?P.False:P.True}function M2(z,w){return q.IsUnknown(z)?P.False:q.IsAny(z)?P.Union:q.IsNever(z)||q.IsLiteralString(z)&&h9(w)||q.IsLiteralNumber(z)&&Hz(w)||q.IsLiteralBoolean(z)&&i9(w)||q.IsSymbol(z)&&c9(w)||q.IsBigInt(z)&&a$(w)||q.IsString(z)&&h9(w)||q.IsSymbol(z)&&c9(w)||q.IsNumber(z)&&Hz(w)||q.IsInteger(z)&&Hz(w)||q.IsBoolean(z)&&i9(w)||q.IsUint8Array(z)&&zA(w)||q.IsDate(z)&&e$(w)||q.IsConstructor(z)&&UA(w)||q.IsFunction(z)&&wA(w)?P.True:q.IsRecord(z)&&q.IsString(_z(z))?(()=>{return w[n2]==="Record"?P.True:P.False})():q.IsRecord(z)&&q.IsNumber(_z(z))?(()=>{return R2(w,0)?P.True:P.False})():P.False}function XA(z,w){return l0(w)?s0(z,w):q.IsRecord(w)?l2(z,w):!q.IsObject(w)?P.False:(()=>{for(let U of Object.getOwnPropertyNames(w.properties)){if(!(U in z.properties)&&!q.IsOptional(w.properties[U]))return P.False;if(q.IsOptional(w.properties[U]))return P.True;if(t9(z.properties[U],w.properties[U])===P.False)return P.False}return P.True})()}function ZA(z,w){return l0(w)?s0(z,w):q.IsObject(w)&&WA(w)?P.True:!q.IsPromise(w)?P.False:p2(R0(z.item,w.item))}function _z(z){return E1 in z.patternProperties?u2():(I1 in z.patternProperties)?N2():Y4("Unknown record key pattern")}function Sz(z){return E1 in z.patternProperties?z.patternProperties[E1]:(I1 in z.patternProperties)?z.patternProperties[I1]:Y4("Unable to get record value schema")}function l2(z,w){let[U,W]=[_z(w),Sz(w)];return q.IsLiteralString(z)&&q.IsNumber(U)&&p2(R0(z,W))===P.True?P.True:q.IsUint8Array(z)&&q.IsNumber(U)?R0(z,W):q.IsString(z)&&q.IsNumber(U)?R0(z,W):q.IsArray(z)&&q.IsNumber(U)?R0(z,W):q.IsObject(z)?(()=>{for(let X of Object.getOwnPropertyNames(z.properties))if(t9(W,z.properties[X])===P.False)return P.False;return P.True})():P.False}function $A(z,w){return l0(w)?s0(z,w):q.IsObject(w)?M2(z,w):!q.IsRecord(w)?P.False:R0(Sz(z),Sz(w))}function AA(z,w){let U=q.IsRegExp(z)?N2():z,W=q.IsRegExp(w)?N2():w;return R0(U,W)}function o9(z,w){return q.IsLiteral(z)&&Y2.IsString(z.const)?P.True:q.IsString(z)?P.True:P.False}function QA(z,w){return l0(w)?s0(z,w):q.IsObject(w)?M2(z,w):q.IsRecord(w)?l2(z,w):q.IsString(w)?P.True:P.False}function YA(z,w){return l0(w)?s0(z,w):q.IsObject(w)?M2(z,w):q.IsRecord(w)?l2(z,w):q.IsSymbol(w)?P.True:P.False}function JA(z,w){return q.IsTemplateLiteral(z)?R0(f6(z),w):q.IsTemplateLiteral(w)?R0(z,f6(w)):Y4("Invalid fallthrough for TemplateLiteral")}function BA(z,w){return q.IsArray(w)&&z.items!==void 0&&z.items.every((U)=>R0(U,w.items)===P.True)}function MA(z,w){return q.IsNever(z)?P.True:q.IsUnknown(z)?P.False:q.IsAny(z)?P.Union:P.False}function qA(z,w){return l0(w)?s0(z,w):q.IsObject(w)&&F8(w)?P.True:q.IsArray(w)&&BA(z,w)?P.True:!q.IsTuple(w)?P.False:Y2.IsUndefined(z.items)&&!Y2.IsUndefined(w.items)||!Y2.IsUndefined(z.items)&&Y2.IsUndefined(w.items)?P.False:Y2.IsUndefined(z.items)&&!Y2.IsUndefined(w.items)?P.True:z.items.every((U,W)=>R0(U,w.items[W])===P.True)?P.True:P.False}function LA(z,w){return l0(w)?s0(z,w):q.IsObject(w)?M2(z,w):q.IsRecord(w)?l2(z,w):q.IsUint8Array(w)?P.True:P.False}function GA(z,w){return l0(w)?s0(z,w):q.IsObject(w)?M2(z,w):q.IsRecord(w)?l2(z,w):q.IsVoid(w)?_A(z,w):q.IsUndefined(w)?P.True:P.False}function Pz(z,w){return w.anyOf.some((U)=>R0(z,U)===P.True)?P.True:P.False}function NA(z,w){return z.anyOf.every((U)=>R0(U,w)===P.True)?P.True:P.False}function p9(z,w){return P.True}function HA(z,w){return q.IsNever(w)?u9(z,w):q.IsIntersect(w)?j8(z,w):q.IsUnion(w)?Pz(z,w):q.IsAny(w)?Dz(z,w):q.IsString(w)?o9(z,w):q.IsNumber(w)?m9(z,w):q.IsInteger(w)?n9(z,w):q.IsBoolean(w)?v9(z,w):q.IsArray(w)?f$(z,w):q.IsTuple(w)?MA(z,w):q.IsObject(w)?M2(z,w):q.IsUnknown(w)?P.True:P.False}function _A(z,w){return q.IsUndefined(z)?P.True:q.IsUndefined(z)?P.True:P.False}function SA(z,w){return q.IsIntersect(w)?j8(z,w):q.IsUnion(w)?Pz(z,w):q.IsUnknown(w)?p9(z,w):q.IsAny(w)?Dz(z,w):q.IsObject(w)?M2(z,w):q.IsVoid(w)?P.True:P.False}function R0(z,w){return q.IsTemplateLiteral(z)||q.IsTemplateLiteral(w)?JA(z,w):q.IsRegExp(z)||q.IsRegExp(w)?AA(z,w):q.IsNot(z)||q.IsNot(w)?l$(z,w):q.IsAny(z)?g$(z,w):q.IsArray(z)?d$(z,w):q.IsBigInt(z)?c$(z,w):q.IsBoolean(z)?i$(z,w):q.IsAsyncIterator(z)?h$(z,w):q.IsConstructor(z)?y$(z,w):q.IsDate(z)?v$(z,w):q.IsFunction(z)?n$(z,w):q.IsInteger(z)?u$(z,w):q.IsIntersect(z)?m$(z,w):q.IsIterator(z)?t$(z,w):q.IsLiteral(z)?o$(z,w):q.IsNever(z)?p$(z,w):q.IsNull(z)?s$(z,w):q.IsNumber(z)?r$(z,w):q.IsObject(z)?XA(z,w):q.IsRecord(z)?$A(z,w):q.IsString(z)?QA(z,w):q.IsSymbol(z)?YA(z,w):q.IsTuple(z)?qA(z,w):q.IsPromise(z)?ZA(z,w):q.IsUint8Array(z)?LA(z,w):q.IsUndefined(z)?GA(z,w):q.IsUnion(z)?NA(z,w):q.IsUnknown(z)?HA(z,w):q.IsVoid(z)?SA(z,w):Y4(`Unknown left type operand '${z[H]}'`)}function B6(z,w){return R0(z,w)}function DA(z,w,U,W,X){let Z={};for(let $ of globalThis.Object.getOwnPropertyNames(z))Z[$]=J4(z[$],w,U,W,V0(X));return Z}function PA(z,w,U,W,X){return DA(z.properties,w,U,W,X)}function l9(z,w,U,W,X){let Z=PA(z,w,U,W,X);return J0(Z)}function OA(z,w,U,W){let X=B6(z,w);return X===P.Union?N0([U,W]):X===P.True?U:W}function J4(z,w,U,W,X){return T0(z)?l9(z,w,U,W,X):g2(z)?D(s9(z,w,U,W,X)):D(OA(z,w,U,W),X)}function RA(z,w,U,W,X){return{[z]:J4(Z0(z),w,U,W,V0(X))}}function CA(z,w,U,W,X){return z.reduce((Z,$)=>{return{...Z,...RA($,w,U,W,X)}},{})}function bA(z,w,U,W,X){return CA(z.keys,w,U,W,X)}function s9(z,w,U,W,X){let Z=bA(z,w,U,W,X);return J0(Z)}function KA(z){return z.allOf.every((w)=>o1(w))}function jA(z){return z.anyOf.some((w)=>o1(w))}function FA(z){return!o1(z.not)}function o1(z){return z[H]==="Intersect"?KA(z):z[H]==="Union"?jA(z):z[H]==="Not"?FA(z):z[H]==="Undefined"?!0:!1}function r9(z,w){return B4(f6(z),w)}function EA(z,w){let U=z.filter((W)=>B6(W,w)===P.False);return U.length===1?U[0]:N0(U)}function B4(z,w,U={}){if(f2(z))return D(r9(z,w),U);if(T0(z))return D(a9(z,w),U);return D(Q0(z)?EA(z.anyOf,w):B6(z,w)!==P.False?p():z,U)}function IA(z,w){let U={};for(let W of globalThis.Object.getOwnPropertyNames(z))U[W]=B4(z[W],w);return U}function xA(z,w){return IA(z.properties,w)}function a9(z,w){let U=xA(z,w);return J0(U)}function e9(z,w){return M4(f6(z),w)}function VA(z,w){let U=z.filter((W)=>B6(W,w)!==P.False);return U.length===1?U[0]:N0(U)}function M4(z,w,U){if(f2(z))return D(e9(z,w),U);if(T0(z))return D(z7(z,w),U);return D(Q0(z)?VA(z.anyOf,w):B6(z,w)!==P.False?z:p(),U)}function kA(z,w){let U={};for(let W of globalThis.Object.getOwnPropertyNames(z))U[W]=M4(z[W],w);return U}function TA(z,w){return kA(z.properties,w)}function z7(z,w){let U=TA(z,w);return J0(U)}function w7(z,w){return Y1(z)?D(z.returns,w):p(w)}function E8(z){return P2(J2(z))}function d6(z,w,U){return D({[H]:"Record",type:"object",patternProperties:{[z]:w}},U)}function Oz(z,w,U){let W={};for(let X of z)W[X]=w;return H0(W,{...U,[n2]:"Record"})}function gA(z,w,U){return G8(z)?Oz(D2(z),w,U):d6(z.pattern,w,U)}function fA(z,w,U){return Oz(D2(N0(z)),w,U)}function dA(z,w,U){return Oz([z.toString()],w,U)}function hA(z,w,U){return d6(z.source,w,U)}function cA(z,w,U){let W=t0(z.pattern)?I1:z.pattern;return d6(W,w,U)}function iA(z,w,U){return d6(I1,w,U)}function yA(z,w,U){return d6($9,w,U)}function vA(z,w,U){return H0({true:w,false:w},U)}function nA(z,w,U){return d6(E1,w,U)}function uA(z,w,U){return d6(E1,w,U)}function I8(z,w,U={}){return Q0(z)?fA(z.anyOf,w,U):f2(z)?gA(z,w,U):T2(z)?dA(z.const,w,U):y1(z)?vA(z,w,U):B1(z)?nA(z,w,U):M1(z)?uA(z,w,U):Az(z)?hA(z,w,U):v1(z)?cA(z,w,U):Zz(z)?iA(z,w,U):A6(z)?yA(z,w,U):p(U)}function x8(z){return globalThis.Object.getOwnPropertyNames(z.patternProperties)[0]}function U7(z){let w=x8(z);return w===I1?N2():w===E1?u2():N2({pattern:w})}function V8(z){return z.patternProperties[x8(z)]}function mA(z,w){return w.parameters=h4(z,w.parameters),w.returns=L1(z,w.returns),w}function tA(z,w){return w.parameters=h4(z,w.parameters),w.returns=L1(z,w.returns),w}function oA(z,w){return w.allOf=h4(z,w.allOf),w}function pA(z,w){return w.anyOf=h4(z,w.anyOf),w}function lA(z,w){if(t0(w.items))return w;return w.items=h4(z,w.items),w}function sA(z,w){return w.items=L1(z,w.items),w}function rA(z,w){return w.items=L1(z,w.items),w}function aA(z,w){return w.items=L1(z,w.items),w}function eA(z,w){return w.item=L1(z,w.item),w}function zQ(z,w){let U=XQ(z,w.properties);return{...w,...H0(U)}}function wQ(z,w){let U=L1(z,U7(w)),W=L1(z,V8(w)),X=I8(U,W);return{...w,...X}}function UQ(z,w){return w.index in z?z[w.index]:q1()}function WQ(z,w){let U=s6(w),W=S2(w),X=L1(z,w);return U&&W?E8(X):U&&!W?P2(X):!U&&W?J2(X):X}function XQ(z,w){return globalThis.Object.getOwnPropertyNames(w).reduce((U,W)=>{return{...U,[W]:WQ(z,w[W])}},{})}function h4(z,w){return w.map((U)=>L1(z,U))}function L1(z,w){return Y1(w)?mA(z,w):J1(w)?tA(z,w):c0(w)?oA(z,w):Q0(w)?pA(z,w):d2(w)?lA(z,w):A1(w)?sA(z,w):I6(w)?rA(z,w):V6(w)?aA(z,w):k6(w)?eA(z,w):o0(w)?zQ(z,w):T6(w)?wQ(z,w):$z(w)?UQ(z,w):w}function W7(z,w){return L1(w,p6(z))}function X7(z){return D({[H]:"Integer",type:"integer"},z)}function ZQ(z,w,U){return{[z]:G1(Z0(z),w,V0(U))}}function $Q(z,w,U){return z.reduce((X,Z)=>{return{...X,...ZQ(Z,w,U)}},{})}function AQ(z,w,U){return $Q(z.keys,w,U)}function Z7(z,w,U){let W=AQ(z,w,U);return J0(W)}function QQ(z){let[w,U]=[z.slice(0,1),z.slice(1)];return[w.toLowerCase(),U].join("")}function YQ(z){let[w,U]=[z.slice(0,1),z.slice(1)];return[w.toUpperCase(),U].join("")}function JQ(z){return z.toUpperCase()}function BQ(z){return z.toLowerCase()}function MQ(z,w,U){let W=W4(z.pattern);if(!g6(W))return{...z,pattern:$7(z.pattern,w)};let $=[...T4(W)].map((Y)=>Z0(Y)),A=A7($,w),Q=N0(A);return H8([Q],U)}function $7(z,w){return typeof z==="string"?w==="Uncapitalize"?QQ(z):w==="Capitalize"?YQ(z):w==="Uppercase"?JQ(z):w==="Lowercase"?BQ(z):z:z.toString()}function A7(z,w){return z.map((U)=>G1(U,w))}function G1(z,w,U={}){return g2(z)?Z7(z,w,U):f2(z)?MQ(z,w,U):Q0(z)?N0(A7(z.anyOf,w),U):T2(z)?Z0($7(z.const,w),U):D(z,U)}function Q7(z,w={}){return G1(z,"Capitalize",w)}function Y7(z,w={}){return G1(z,"Lowercase",w)}function J7(z,w={}){return G1(z,"Uncapitalize",w)}function B7(z,w={}){return G1(z,"Uppercase",w)}function qQ(z,w,U){let W={};for(let X of globalThis.Object.getOwnPropertyNames(z))W[X]=M6(z[X],w,V0(U));return W}function LQ(z,w,U){return qQ(z.properties,w,U)}function M7(z,w,U){let W=LQ(z,w,U);return J0(W)}function GQ(z,w){return z.map((U)=>Rz(U,w))}function NQ(z,w){return z.map((U)=>Rz(U,w))}function HQ(z,w){let{[w]:U,...W}=z;return W}function _Q(z,w){return w.reduce((U,W)=>HQ(U,W),z)}function SQ(z,w){let U=i0(z,[F0,"$id","required","properties"]),W=_Q(z.properties,w);return H0(W,U)}function DQ(z){let w=z.reduce((U,W)=>M8(W)?[...U,Z0(W)]:U,[]);return N0(w)}function Rz(z,w){return c0(z)?B2(GQ(z.allOf,w)):Q0(z)?N0(NQ(z.anyOf,w)):o0(z)?SQ(z,w):H0({})}function M6(z,w,U){let W=m0(w)?DQ(w):w,X=f0(w)?D2(w):w,Z=u0(z),$=u0(w);return T0(z)?M7(z,X,U):g2(w)?q7(z,w,U):Z&&$?x0("Omit",[z,W],U):!Z&&$?x0("Omit",[z,W],U):Z&&!$?x0("Omit",[z,W],U):D({...Rz(z,X),...U})}function PQ(z,w,U){return{[w]:M6(z,[w],V0(U))}}function OQ(z,w,U){return w.reduce((W,X)=>{return{...W,...PQ(z,X,U)}},{})}function RQ(z,w,U){return OQ(z,w.keys,U)}function q7(z,w,U){let W=RQ(z,w,U);return J0(W)}function CQ(z,w,U){let W={};for(let X of globalThis.Object.getOwnPropertyNames(z))W[X]=q6(z[X],w,V0(U));return W}function bQ(z,w,U){return CQ(z.properties,w,U)}function L7(z,w,U){let W=bQ(z,w,U);return J0(W)}function KQ(z,w){return z.map((U)=>Cz(U,w))}function jQ(z,w){return z.map((U)=>Cz(U,w))}function FQ(z,w){let U={};for(let W of w)if(W in z)U[W]=z[W];return U}function EQ(z,w){let U=i0(z,[F0,"$id","required","properties"]),W=FQ(z.properties,w);return H0(W,U)}function IQ(z){let w=z.reduce((U,W)=>M8(W)?[...U,Z0(W)]:U,[]);return N0(w)}function Cz(z,w){return c0(z)?B2(KQ(z.allOf,w)):Q0(z)?N0(jQ(z.anyOf,w)):o0(z)?EQ(z,w):H0({})}function q6(z,w,U){let W=m0(w)?IQ(w):w,X=f0(w)?D2(w):w,Z=u0(z),$=u0(w);return T0(z)?L7(z,X,U):g2(w)?G7(z,w,U):Z&&$?x0("Pick",[z,W],U):!Z&&$?x0("Pick",[z,W],U):Z&&!$?x0("Pick",[z,W],U):D({...Cz(z,X),...U})}function xQ(z,w,U){return{[w]:q6(z,[w],V0(U))}}function VQ(z,w,U){return w.reduce((W,X)=>{return{...W,...xQ(z,X,U)}},{})}function kQ(z,w,U){return VQ(z,w.keys,U)}function G7(z,w,U){let W=kQ(z,w,U);return J0(W)}function TQ(z,w){return x0("Partial",[x0(z,w)])}function gQ(z){return x0("Partial",[o2(z)])}function fQ(z){let w={};for(let U of globalThis.Object.getOwnPropertyNames(z))w[U]=J2(z[U]);return w}function dQ(z){let w=i0(z,[F0,"$id","required","properties"]),U=fQ(z.properties);return H0(U,w)}function N7(z){return z.map((w)=>H7(w))}function H7(z){return Q1(z)?TQ(z.target,z.parameters):u0(z)?gQ(z.$ref):c0(z)?B2(N7(z.allOf)):Q0(z)?N0(N7(z.anyOf)):o0(z)?dQ(z):x6(z)?z:y1(z)?z:B1(z)?z:T2(z)?z:F4(z)?z:M1(z)?z:v1(z)?z:E4(z)?z:n1(z)?z:H0({})}function q4(z,w){if(T0(z))return _7(z,w);else return D({...H7(z),...w})}function hQ(z,w){let U={};for(let W of globalThis.Object.getOwnPropertyNames(z))U[W]=q4(z[W],V0(w));return U}function cQ(z,w){return hQ(z.properties,w)}function _7(z,w){let U=cQ(z,w);return J0(U)}function iQ(z,w){return x0("Required",[x0(z,w)])}function yQ(z){return x0("Required",[o2(z)])}function vQ(z){let w={};for(let U of globalThis.Object.getOwnPropertyNames(z))w[U]=i0(z[U],[Z2]);return w}function nQ(z){let w=i0(z,[F0,"$id","required","properties"]),U=vQ(z.properties);return H0(U,w)}function S7(z){return z.map((w)=>D7(w))}function D7(z){return Q1(z)?iQ(z.target,z.parameters):u0(z)?yQ(z.$ref):c0(z)?B2(S7(z.allOf)):Q0(z)?N0(S7(z.anyOf)):o0(z)?nQ(z):x6(z)?z:y1(z)?z:B1(z)?z:T2(z)?z:F4(z)?z:M1(z)?z:v1(z)?z:E4(z)?z:n1(z)?z:H0({})}function L4(z,w){if(T0(z))return P7(z,w);else return D({...D7(z),...w})}function uQ(z,w){let U={};for(let W of globalThis.Object.getOwnPropertyNames(z))U[W]=L4(z[W],w);return U}function mQ(z,w){return uQ(z.properties,w)}function P7(z,w){let U=mQ(z,w);return J0(U)}function tQ(z,w){return w.map((U)=>{return u0(U)?bz(z,U.$ref):h2(z,U)})}function bz(z,w){return w in z?u0(z[w])?bz(z,z[w].$ref):h2(z,z[w]):p()}function oQ(z){return A4(z[0])}function pQ(z){return J6(z[0],z[1])}function lQ(z){return Q4(z[0])}function sQ(z){return q4(z[0])}function rQ(z){return M6(z[0],z[1])}function aQ(z){return q6(z[0],z[1])}function eQ(z){return L4(z[0])}function zY(z,w,U){let W=tQ(z,U);return w==="Awaited"?oQ(W):w==="Index"?pQ(W):w==="KeyOf"?lQ(W):w==="Partial"?sQ(W):w==="Omit"?rQ(W):w==="Pick"?aQ(W):w==="Required"?eQ(W):p()}function wY(z,w){return e6(h2(z,w))}function UY(z,w){return z4(h2(z,w))}function WY(z,w,U){return w4(c4(z,w),h2(z,U))}function XY(z,w,U){return x1(c4(z,w),h2(z,U))}function ZY(z,w){return B2(c4(z,w))}function $Y(z,w){return $4(h2(z,w))}function AY(z,w){return H0(globalThis.Object.keys(w).reduce((U,W)=>{return{...U,[W]:h2(z,w[W])}},{}))}function QY(z,w){let[U,W]=[h2(z,V8(w)),x8(w)],X=p6(w);return X.patternProperties[W]=U,X}function YY(z,w){return u0(w)?{...bz(z,w.$ref),[F0]:w[F0]}:w}function JY(z,w){return m2(c4(z,w))}function BY(z,w){return N0(c4(z,w))}function c4(z,w){return w.map((U)=>h2(z,U))}function h2(z,w){return S2(w)?D(h2(z,i0(w,[Z2])),w):s6(w)?D(h2(z,i0(w,[$1])),w):G0(w)?D(YY(z,w),w):A1(w)?D(wY(z,w.items),w):I6(w)?D(UY(z,w.items),w):Q1(w)?D(zY(z,w.target,w.parameters)):Y1(w)?D(WY(z,w.parameters,w.returns),w):J1(w)?D(XY(z,w.parameters,w.returns),w):c0(w)?D(ZY(z,w.allOf),w):V6(w)?D($Y(z,w.items),w):o0(w)?D(AY(z,w.properties),w):T6(w)?D(QY(z,w)):d2(w)?D(JY(z,w.items||[]),w):Q0(w)?D(BY(z,w.anyOf),w):w}function MY(z,w){return w in z?h2(z,z[w]):p()}function O7(z){return globalThis.Object.getOwnPropertyNames(z).reduce((w,U)=>{return{...w,[U]:MY(z,U)}},{})}class R7{constructor(z){let w=O7(z),U=this.WithIdentifiers(w);this.$defs=U}Import(z,w){let U={...this.$defs,[z]:D(this.$defs[z],w)};return D({[H]:"Import",$defs:U,$ref:z})}WithIdentifiers(z){return globalThis.Object.getOwnPropertyNames(z).reduce((w,U)=>{return{...w,[U]:{...z[U],$id:U}}},{})}}function C7(z){return new R7(z)}function b7(z,w){return D({[H]:"Not",not:z},w)}function K7(z,w){return J1(z)?m2(z.parameters,w):p()}var qY=0;function j7(z,w={}){if(t0(w.$id))w.$id=`T${qY++}`;let U=p6(z({[H]:"This",$ref:`${w.$id}`}));return U.$id=w.$id,D({[n2]:"Recursive",...U},w)}function F7(z,w){let U=j0(z)?new globalThis.RegExp(z):z;return D({[H]:"RegExp",type:"RegExp",source:U.source,flags:U.flags},w)}function LY(z){return c0(z)?z.allOf:Q0(z)?z.anyOf:d2(z)?z.items??[]:[]}function E7(z){return LY(z)}function I7(z,w){return J1(z)?D(z.returns,w):p(w)}class x7{constructor(z){this.schema=z}Decode(z){return new V7(this.schema,z)}}class V7{constructor(z,w){this.schema=z,this.decode=w}EncodeTransform(z,w){let X={Encode:(Z)=>w[F0].Encode(z(Z)),Decode:(Z)=>this.decode(w[F0].Decode(Z))};return{...w,[F0]:X}}EncodeSchema(z,w){let U={Decode:this.decode,Encode:z};return{...w,[F0]:U}}Encode(z){return G0(this.schema)?this.EncodeTransform(z,this.schema):this.EncodeSchema(z,this.schema)}}function k7(z){return new x7(z)}function k8(z={}){return D({[H]:z[H]??"Unsafe"},z)}function T7(z){return D({[H]:"Void",type:"void"},z)}var Kz={};j6(Kz,{Void:()=>T7,Uppercase:()=>B7,Unsafe:()=>k8,Unknown:()=>q1,Union:()=>N0,Undefined:()=>C8,Uncapitalize:()=>J7,Uint8Array:()=>b8,Tuple:()=>m2,Transform:()=>k7,TemplateLiteral:()=>H8,Symbol:()=>R8,String:()=>N2,ReturnType:()=>I7,Rest:()=>E7,Required:()=>L4,RegExp:()=>F7,Ref:()=>o2,Recursive:()=>j7,Record:()=>I8,ReadonlyOptional:()=>E8,Readonly:()=>P2,Promise:()=>S8,Pick:()=>q6,Partial:()=>q4,Parameters:()=>K7,Optional:()=>J2,Omit:()=>M6,Object:()=>H0,Number:()=>u2,Null:()=>O8,Not:()=>b7,Never:()=>p,Module:()=>C7,Mapped:()=>j9,Lowercase:()=>Y7,Literal:()=>Z0,KeyOf:()=>Q4,Iterator:()=>$4,Intersect:()=>B2,Integer:()=>X7,Instantiate:()=>W7,InstanceType:()=>w7,Index:()=>J6,Function:()=>x1,Extract:()=>M4,Extends:()=>J4,Exclude:()=>B4,Enum:()=>f9,Date:()=>P8,ConstructorParameters:()=>g9,Constructor:()=>w4,Const:()=>T9,Composite:()=>k9,Capitalize:()=>Q7,Boolean:()=>N8,BigInt:()=>Z4,Awaited:()=>A4,AsyncIterator:()=>z4,Array:()=>e6,Argument:()=>B9,Any:()=>Y6});var L6=Kz;function GY(z){switch(z.errorType){case _.ArrayContains:return"Expected array to contain at least one matching value";case _.ArrayMaxContains:return`Expected array to contain no more than ${z.schema.maxContains} matching values`;case _.ArrayMinContains:return`Expected array to contain at least ${z.schema.minContains} matching values`;case _.ArrayMaxItems:return`Expected array length to be less or equal to ${z.schema.maxItems}`;case _.ArrayMinItems:return`Expected array length to be greater or equal to ${z.schema.minItems}`;case _.ArrayUniqueItems:return"Expected array elements to be unique";case _.Array:return"Expected array";case _.AsyncIterator:return"Expected AsyncIterator";case _.BigIntExclusiveMaximum:return`Expected bigint to be less than ${z.schema.exclusiveMaximum}`;case _.BigIntExclusiveMinimum:return`Expected bigint to be greater than ${z.schema.exclusiveMinimum}`;case _.BigIntMaximum:return`Expected bigint to be less or equal to ${z.schema.maximum}`;case _.BigIntMinimum:return`Expected bigint to be greater or equal to ${z.schema.minimum}`;case _.BigIntMultipleOf:return`Expected bigint to be a multiple of ${z.schema.multipleOf}`;case _.BigInt:return"Expected bigint";case _.Boolean:return"Expected boolean";case _.DateExclusiveMinimumTimestamp:return`Expected Date timestamp to be greater than ${z.schema.exclusiveMinimumTimestamp}`;case _.DateExclusiveMaximumTimestamp:return`Expected Date timestamp to be less than ${z.schema.exclusiveMaximumTimestamp}`;case _.DateMinimumTimestamp:return`Expected Date timestamp to be greater or equal to ${z.schema.minimumTimestamp}`;case _.DateMaximumTimestamp:return`Expected Date timestamp to be less or equal to ${z.schema.maximumTimestamp}`;case _.DateMultipleOfTimestamp:return`Expected Date timestamp to be a multiple of ${z.schema.multipleOfTimestamp}`;case _.Date:return"Expected Date";case _.Function:return"Expected function";case _.IntegerExclusiveMaximum:return`Expected integer to be less than ${z.schema.exclusiveMaximum}`;case _.IntegerExclusiveMinimum:return`Expected integer to be greater than ${z.schema.exclusiveMinimum}`;case _.IntegerMaximum:return`Expected integer to be less or equal to ${z.schema.maximum}`;case _.IntegerMinimum:return`Expected integer to be greater or equal to ${z.schema.minimum}`;case _.IntegerMultipleOf:return`Expected integer to be a multiple of ${z.schema.multipleOf}`;case _.Integer:return"Expected integer";case _.IntersectUnevaluatedProperties:return"Unexpected property";case _.Intersect:return"Expected all values to match";case _.Iterator:return"Expected Iterator";case _.Literal:return`Expected ${typeof z.schema.const==="string"?`'${z.schema.const}'`:z.schema.const}`;case _.Never:return"Never";case _.Not:return"Value should not match";case _.Null:return"Expected null";case _.NumberExclusiveMaximum:return`Expected number to be less than ${z.schema.exclusiveMaximum}`;case _.NumberExclusiveMinimum:return`Expected number to be greater than ${z.schema.exclusiveMinimum}`;case _.NumberMaximum:return`Expected number to be less or equal to ${z.schema.maximum}`;case _.NumberMinimum:return`Expected number to be greater or equal to ${z.schema.minimum}`;case _.NumberMultipleOf:return`Expected number to be a multiple of ${z.schema.multipleOf}`;case _.Number:return"Expected number";case _.Object:return"Expected object";case _.ObjectAdditionalProperties:return"Unexpected property";case _.ObjectMaxProperties:return`Expected object to have no more than ${z.schema.maxProperties} properties`;case _.ObjectMinProperties:return`Expected object to have at least ${z.schema.minProperties} properties`;case _.ObjectRequiredProperty:return"Expected required property";case _.Promise:return"Expected Promise";case _.RegExp:return"Expected string to match regular expression";case _.StringFormatUnknown:return`Unknown format '${z.schema.format}'`;case _.StringFormat:return`Expected string to match '${z.schema.format}' format`;case _.StringMaxLength:return`Expected string length less or equal to ${z.schema.maxLength}`;case _.StringMinLength:return`Expected string length greater or equal to ${z.schema.minLength}`;case _.StringPattern:return`Expected string to match '${z.schema.pattern}'`;case _.String:return"Expected string";case _.Symbol:return"Expected symbol";case _.TupleLength:return`Expected tuple to have ${z.schema.maxItems||0} elements`;case _.Tuple:return"Expected tuple";case _.Uint8ArrayMaxByteLength:return`Expected byte length less or equal to ${z.schema.maxByteLength}`;case _.Uint8ArrayMinByteLength:return`Expected byte length greater or equal to ${z.schema.minByteLength}`;case _.Uint8Array:return"Expected Uint8Array";case _.Undefined:return"Expected undefined";case _.Union:return"Expected union value";case _.Void:return"Expected void";case _.Kind:return`Expected kind '${z.schema[H]}'`;default:return"Unknown error type"}}var NY=GY;function g7(){return NY}class f7 extends n{constructor(z){super(`Unable to dereference schema with $id '${z.$ref}'`);this.schema=z}}function HY(z,w){let U=w.find((W)=>W.$id===z.$ref);if(U===void 0)throw new f7(z);return B0(U,w)}function z2(z,w){if(!A0(z.$id)||w.some((U)=>U.$id===z.$id))return w;return w.push(z),w}function B0(z,w){return z[H]==="This"||z[H]==="Ref"?HY(z,w):z}class d7 extends n{constructor(z){super("Unable to hash value");this.value=z}}var c2;(function(z){z[z.Undefined=0]="Undefined",z[z.Null=1]="Null",z[z.Boolean=2]="Boolean",z[z.Number=3]="Number",z[z.String=4]="String",z[z.Object=5]="Object",z[z.Array=6]="Array",z[z.Date=7]="Date",z[z.Uint8Array=8]="Uint8Array",z[z.Symbol=9]="Symbol",z[z.BigInt=10]="BigInt"})(c2||(c2={}));var G4=BigInt("14695981039346656037"),[_Y,SY]=[BigInt("1099511628211"),BigInt("18446744073709551616")],DY=Array.from({length:256}).map((z,w)=>BigInt(w)),h7=new Float64Array(1),c7=new DataView(h7.buffer),i7=new Uint8Array(h7.buffer);function*PY(z){let w=z===0?1:Math.ceil(Math.floor(Math.log2(z)+1)/8);for(let U=0;U<w;U++)yield z>>8*(w-1-U)&255}function OY(z){q2(c2.Array);for(let w of z)N4(w)}function RY(z){q2(c2.Boolean),q2(z?1:0)}function CY(z){q2(c2.BigInt),c7.setBigInt64(0,z);for(let w of i7)q2(w)}function bY(z){q2(c2.Date),N4(z.getTime())}function KY(z){q2(c2.Null)}function jY(z){q2(c2.Number),c7.setFloat64(0,z);for(let w of i7)q2(w)}function FY(z){q2(c2.Object);for(let w of globalThis.Object.getOwnPropertyNames(z).sort())N4(w),N4(z[w])}function EY(z){q2(c2.String);for(let w=0;w<z.length;w++)for(let U of PY(z.charCodeAt(w)))q2(U)}function IY(z){q2(c2.Symbol),N4(z.description)}function xY(z){q2(c2.Uint8Array);for(let w=0;w<z.length;w++)q2(z[w])}function VY(z){return q2(c2.Undefined)}function N4(z){if(m(z))return OY(z);if(F1(z))return RY(z);if(X2(z))return CY(z);if(G2(z))return bY(z);if(c1(z))return KY(z);if(v(z))return jY(z);if(l(z))return FY(z);if(A0(z))return EY(z);if(i1(z))return IY(z);if(l6(z))return xY(z);if(k0(z))return VY(z);throw new d7(z)}function q2(z){G4=G4^DY[z],G4=G4*_Y%SY}function G6(z){return G4=BigInt("14695981039346656037"),N4(z),G4}class y7 extends n{constructor(z){super("Unknown type");this.schema=z}}function kY(z){return z[H]==="Any"||z[H]==="Unknown"}function U0(z){return z!==void 0}function TY(z,w,U){return!0}function gY(z,w,U){return!0}function fY(z,w,U){if(!m(U))return!1;if(U0(z.minItems)&&!(U.length>=z.minItems))return!1;if(U0(z.maxItems)&&!(U.length<=z.maxItems))return!1;if(!U.every((Z)=>w2(z.items,w,Z)))return!1;if(z.uniqueItems===!0&&!function(){let Z=new Set;for(let $ of U){let A=G6($);if(Z.has(A))return!1;else Z.add(A)}return!0}())return!1;if(!(U0(z.contains)||v(z.minContains)||v(z.maxContains)))return!0;let W=U0(z.contains)?z.contains:p(),X=U.reduce((Z,$)=>w2(W,w,$)?Z+1:Z,0);if(X===0)return!1;if(v(z.minContains)&&X<z.minContains)return!1;if(v(z.maxContains)&&X>z.maxContains)return!1;return!0}function dY(z,w,U){return Q8(U)}function hY(z,w,U){if(!X2(U))return!1;if(U0(z.exclusiveMaximum)&&!(U<z.exclusiveMaximum))return!1;if(U0(z.exclusiveMinimum)&&!(U>z.exclusiveMinimum))return!1;if(U0(z.maximum)&&!(U<=z.maximum))return!1;if(U0(z.minimum)&&!(U>=z.minimum))return!1;if(U0(z.multipleOf)&&U%z.multipleOf!==BigInt(0))return!1;return!0}function cY(z,w,U){return F1(U)}function iY(z,w,U){return w2(z.returns,w,U.prototype)}function yY(z,w,U){if(!G2(U))return!1;if(U0(z.exclusiveMaximumTimestamp)&&!(U.getTime()<z.exclusiveMaximumTimestamp))return!1;if(U0(z.exclusiveMinimumTimestamp)&&!(U.getTime()>z.exclusiveMinimumTimestamp))return!1;if(U0(z.maximumTimestamp)&&!(U.getTime()<=z.maximumTimestamp))return!1;if(U0(z.minimumTimestamp)&&!(U.getTime()>=z.minimumTimestamp))return!1;if(U0(z.multipleOfTimestamp)&&U.getTime()%z.multipleOfTimestamp!==0)return!1;return!0}function vY(z,w,U){return $6(U)}function nY(z,w,U){let W=globalThis.Object.values(z.$defs),X=z.$defs[z.$ref];return w2(X,[...w,...W],U)}function uY(z,w,U){if(!B8(U))return!1;if(U0(z.exclusiveMaximum)&&!(U<z.exclusiveMaximum))return!1;if(U0(z.exclusiveMinimum)&&!(U>z.exclusiveMinimum))return!1;if(U0(z.maximum)&&!(U<=z.maximum))return!1;if(U0(z.minimum)&&!(U>=z.minimum))return!1;if(U0(z.multipleOf)&&U%z.multipleOf!==0)return!1;return!0}function mY(z,w,U){let W=z.allOf.every((X)=>w2(X,w,U));if(z.unevaluatedProperties===!1){let X=new RegExp(t1(z)),Z=Object.getOwnPropertyNames(U).every(($)=>X.test($));return W&&Z}else if(f0(z.unevaluatedProperties)){let X=new RegExp(t1(z)),Z=Object.getOwnPropertyNames(U).every(($)=>X.test($)||w2(z.unevaluatedProperties,w,U[$]));return W&&Z}else return W}function tY(z,w,U){return Y8(U)}function oY(z,w,U){return U===z.const}function pY(z,w,U){return!1}function lY(z,w,U){return!w2(z.not,w,U)}function sY(z,w,U){return c1(U)}function rY(z,w,U){if(!I0.IsNumberLike(U))return!1;if(U0(z.exclusiveMaximum)&&!(U<z.exclusiveMaximum))return!1;if(U0(z.exclusiveMinimum)&&!(U>z.exclusiveMinimum))return!1;if(U0(z.minimum)&&!(U>=z.minimum))return!1;if(U0(z.maximum)&&!(U<=z.maximum))return!1;if(U0(z.multipleOf)&&U%z.multipleOf!==0)return!1;return!0}function aY(z,w,U){if(!I0.IsObjectLike(U))return!1;if(U0(z.minProperties)&&!(Object.getOwnPropertyNames(U).length>=z.minProperties))return!1;if(U0(z.maxProperties)&&!(Object.getOwnPropertyNames(U).length<=z.maxProperties))return!1;let W=Object.getOwnPropertyNames(z.properties);for(let X of W){let Z=z.properties[X];if(z.required&&z.required.includes(X)){if(!w2(Z,w,U[X]))return!1;if((o1(Z)||kY(Z))&&!(X in U))return!1}else if(I0.IsExactOptionalProperty(U,X)&&!w2(Z,w,U[X]))return!1}if(z.additionalProperties===!1){let X=Object.getOwnPropertyNames(U);if(z.required&&z.required.length===W.length&&X.length===W.length)return!0;else return X.every((Z)=>W.includes(Z))}else if(typeof z.additionalProperties==="object")return Object.getOwnPropertyNames(U).every((Z)=>W.includes(Z)||w2(z.additionalProperties,w,U[Z]));else return!0}function eY(z,w,U){return J8(U)}function zJ(z,w,U){if(!I0.IsRecordLike(U))return!1;if(U0(z.minProperties)&&!(Object.getOwnPropertyNames(U).length>=z.minProperties))return!1;if(U0(z.maxProperties)&&!(Object.getOwnPropertyNames(U).length<=z.maxProperties))return!1;let[W,X]=Object.entries(z.patternProperties)[0],Z=new RegExp(W),$=Object.entries(U).every(([Y,J])=>{return Z.test(Y)?w2(X,w,J):!0}),A=typeof z.additionalProperties==="object"?Object.entries(U).every(([Y,J])=>{return!Z.test(Y)?w2(z.additionalProperties,w,J):!0}):!0,Q=z.additionalProperties===!1?Object.getOwnPropertyNames(U).every((Y)=>{return Z.test(Y)}):!0;return $&&A&&Q}function wJ(z,w,U){return w2(B0(z,w),w,U)}function UJ(z,w,U){let W=new RegExp(z.source,z.flags);if(U0(z.minLength)){if(!(U.length>=z.minLength))return!1}if(U0(z.maxLength)){if(!(U.length<=z.maxLength))return!1}return W.test(U)}function WJ(z,w,U){if(!A0(U))return!1;if(U0(z.minLength)){if(!(U.length>=z.minLength))return!1}if(U0(z.maxLength)){if(!(U.length<=z.maxLength))return!1}if(U0(z.pattern)){if(!new RegExp(z.pattern).test(U))return!1}if(U0(z.format)){if(!D0.Has(z.format))return!1;return D0.Get(z.format)(U)}return!0}function XJ(z,w,U){return i1(U)}function ZJ(z,w,U){return A0(U)&&new RegExp(z.pattern).test(U)}function $J(z,w,U){return w2(B0(z,w),w,U)}function AJ(z,w,U){if(!m(U))return!1;if(z.items===void 0&&U.length!==0)return!1;if(U.length!==z.maxItems)return!1;if(!z.items)return!0;for(let W=0;W<z.items.length;W++)if(!w2(z.items[W],w,U[W]))return!1;return!0}function QJ(z,w,U){return k0(U)}function YJ(z,w,U){return z.anyOf.some((W)=>w2(W,w,U))}function JJ(z,w,U){if(!l6(U))return!1;if(U0(z.maxByteLength)&&!(U.length<=z.maxByteLength))return!1;if(U0(z.minByteLength)&&!(U.length>=z.minByteLength))return!1;return!0}function BJ(z,w,U){return!0}function MJ(z,w,U){return I0.IsVoidLike(U)}function qJ(z,w,U){if(!p0.Has(z[H]))return!1;return p0.Get(z[H])(z,U)}function w2(z,w,U){let W=U0(z.$id)?z2(z,w):w,X=z;switch(X[H]){case"Any":return TY(X,W,U);case"Argument":return gY(X,W,U);case"Array":return fY(X,W,U);case"AsyncIterator":return dY(X,W,U);case"BigInt":return hY(X,W,U);case"Boolean":return cY(X,W,U);case"Constructor":return iY(X,W,U);case"Date":return yY(X,W,U);case"Function":return vY(X,W,U);case"Import":return nY(X,W,U);case"Integer":return uY(X,W,U);case"Intersect":return mY(X,W,U);case"Iterator":return tY(X,W,U);case"Literal":return oY(X,W,U);case"Never":return pY(X,W,U);case"Not":return lY(X,W,U);case"Null":return sY(X,W,U);case"Number":return rY(X,W,U);case"Object":return aY(X,W,U);case"Promise":return eY(X,W,U);case"Record":return zJ(X,W,U);case"Ref":return wJ(X,W,U);case"RegExp":return UJ(X,W,U);case"String":return WJ(X,W,U);case"Symbol":return XJ(X,W,U);case"TemplateLiteral":return ZJ(X,W,U);case"This":return $J(X,W,U);case"Tuple":return AJ(X,W,U);case"Undefined":return QJ(X,W,U);case"Union":return YJ(X,W,U);case"Uint8Array":return JJ(X,W,U);case"Unknown":return BJ(X,W,U);case"Void":return MJ(X,W,U);default:if(!p0.Has(X[H]))throw new y7(X);return qJ(X,W,U)}}function s(...z){return z.length===3?w2(z[0],z[1],z[2]):w2(z[0],[],z[1])}var _;(function(z){z[z.ArrayContains=0]="ArrayContains",z[z.ArrayMaxContains=1]="ArrayMaxContains",z[z.ArrayMaxItems=2]="ArrayMaxItems",z[z.ArrayMinContains=3]="ArrayMinContains",z[z.ArrayMinItems=4]="ArrayMinItems",z[z.ArrayUniqueItems=5]="ArrayUniqueItems",z[z.Array=6]="Array",z[z.AsyncIterator=7]="AsyncIterator",z[z.BigIntExclusiveMaximum=8]="BigIntExclusiveMaximum",z[z.BigIntExclusiveMinimum=9]="BigIntExclusiveMinimum",z[z.BigIntMaximum=10]="BigIntMaximum",z[z.BigIntMinimum=11]="BigIntMinimum",z[z.BigIntMultipleOf=12]="BigIntMultipleOf",z[z.BigInt=13]="BigInt",z[z.Boolean=14]="Boolean",z[z.DateExclusiveMaximumTimestamp=15]="DateExclusiveMaximumTimestamp",z[z.DateExclusiveMinimumTimestamp=16]="DateExclusiveMinimumTimestamp",z[z.DateMaximumTimestamp=17]="DateMaximumTimestamp",z[z.DateMinimumTimestamp=18]="DateMinimumTimestamp",z[z.DateMultipleOfTimestamp=19]="DateMultipleOfTimestamp",z[z.Date=20]="Date",z[z.Function=21]="Function",z[z.IntegerExclusiveMaximum=22]="IntegerExclusiveMaximum",z[z.IntegerExclusiveMinimum=23]="IntegerExclusiveMinimum",z[z.IntegerMaximum=24]="IntegerMaximum",z[z.IntegerMinimum=25]="IntegerMinimum",z[z.IntegerMultipleOf=26]="IntegerMultipleOf",z[z.Integer=27]="Integer",z[z.IntersectUnevaluatedProperties=28]="IntersectUnevaluatedProperties",z[z.Intersect=29]="Intersect",z[z.Iterator=30]="Iterator",z[z.Kind=31]="Kind",z[z.Literal=32]="Literal",z[z.Never=33]="Never",z[z.Not=34]="Not",z[z.Null=35]="Null",z[z.NumberExclusiveMaximum=36]="NumberExclusiveMaximum",z[z.NumberExclusiveMinimum=37]="NumberExclusiveMinimum",z[z.NumberMaximum=38]="NumberMaximum",z[z.NumberMinimum=39]="NumberMinimum",z[z.NumberMultipleOf=40]="NumberMultipleOf",z[z.Number=41]="Number",z[z.ObjectAdditionalProperties=42]="ObjectAdditionalProperties",z[z.ObjectMaxProperties=43]="ObjectMaxProperties",z[z.ObjectMinProperties=44]="ObjectMinProperties",z[z.ObjectRequiredProperty=45]="ObjectRequiredProperty",z[z.Object=46]="Object",z[z.Promise=47]="Promise",z[z.RegExp=48]="RegExp",z[z.StringFormatUnknown=49]="StringFormatUnknown",z[z.StringFormat=50]="StringFormat",z[z.StringMaxLength=51]="StringMaxLength",z[z.StringMinLength=52]="StringMinLength",z[z.StringPattern=53]="StringPattern",z[z.String=54]="String",z[z.Symbol=55]="Symbol",z[z.TupleLength=56]="TupleLength",z[z.Tuple=57]="Tuple",z[z.Uint8ArrayMaxByteLength=58]="Uint8ArrayMaxByteLength",z[z.Uint8ArrayMinByteLength=59]="Uint8ArrayMinByteLength",z[z.Uint8Array=60]="Uint8Array",z[z.Undefined=61]="Undefined",z[z.Union=62]="Union",z[z.Void=63]="Void"})(_||(_={}));class v7 extends n{constructor(z){super("Unknown type");this.schema=z}}function p1(z){return z.replace(/~/g,"~0").replace(/\//g,"~1")}function W0(z){return z!==void 0}class h6{constructor(z){this.iterator=z}[Symbol.iterator](){return this.iterator}First(){let z=this.iterator.next();return z.done?void 0:z.value}}function x(z,w,U,W,X=[]){return{type:z,schema:w,path:U,value:W,message:g7()({errorType:z,path:U,schema:w,value:W,errors:X}),errors:X}}function*LJ(z,w,U,W){}function*GJ(z,w,U,W){}function*NJ(z,w,U,W){if(!m(W))return yield x(_.Array,z,U,W);if(W0(z.minItems)&&!(W.length>=z.minItems))yield x(_.ArrayMinItems,z,U,W);if(W0(z.maxItems)&&!(W.length<=z.maxItems))yield x(_.ArrayMaxItems,z,U,W);for(let $=0;$<W.length;$++)yield*U2(z.items,w,`${U}/${$}`,W[$]);if(z.uniqueItems===!0&&!function(){let $=new Set;for(let A of W){let Q=G6(A);if($.has(Q))return!1;else $.add(Q)}return!0}())yield x(_.ArrayUniqueItems,z,U,W);if(!(W0(z.contains)||W0(z.minContains)||W0(z.maxContains)))return;let X=W0(z.contains)?z.contains:p(),Z=W.reduce(($,A,Q)=>U2(X,w,`${U}${Q}`,A).next().done===!0?$+1:$,0);if(Z===0)yield x(_.ArrayContains,z,U,W);if(v(z.minContains)&&Z<z.minContains)yield x(_.ArrayMinContains,z,U,W);if(v(z.maxContains)&&Z>z.maxContains)yield x(_.ArrayMaxContains,z,U,W)}function*HJ(z,w,U,W){if(!Q8(W))yield x(_.AsyncIterator,z,U,W)}function*_J(z,w,U,W){if(!X2(W))return yield x(_.BigInt,z,U,W);if(W0(z.exclusiveMaximum)&&!(W<z.exclusiveMaximum))yield x(_.BigIntExclusiveMaximum,z,U,W);if(W0(z.exclusiveMinimum)&&!(W>z.exclusiveMinimum))yield x(_.BigIntExclusiveMinimum,z,U,W);if(W0(z.maximum)&&!(W<=z.maximum))yield x(_.BigIntMaximum,z,U,W);if(W0(z.minimum)&&!(W>=z.minimum))yield x(_.BigIntMinimum,z,U,W);if(W0(z.multipleOf)&&W%z.multipleOf!==BigInt(0))yield x(_.BigIntMultipleOf,z,U,W)}function*SJ(z,w,U,W){if(!F1(W))yield x(_.Boolean,z,U,W)}function*DJ(z,w,U,W){yield*U2(z.returns,w,U,W.prototype)}function*PJ(z,w,U,W){if(!G2(W))return yield x(_.Date,z,U,W);if(W0(z.exclusiveMaximumTimestamp)&&!(W.getTime()<z.exclusiveMaximumTimestamp))yield x(_.DateExclusiveMaximumTimestamp,z,U,W);if(W0(z.exclusiveMinimumTimestamp)&&!(W.getTime()>z.exclusiveMinimumTimestamp))yield x(_.DateExclusiveMinimumTimestamp,z,U,W);if(W0(z.maximumTimestamp)&&!(W.getTime()<=z.maximumTimestamp))yield x(_.DateMaximumTimestamp,z,U,W);if(W0(z.minimumTimestamp)&&!(W.getTime()>=z.minimumTimestamp))yield x(_.DateMinimumTimestamp,z,U,W);if(W0(z.multipleOfTimestamp)&&W.getTime()%z.multipleOfTimestamp!==0)yield x(_.DateMultipleOfTimestamp,z,U,W)}function*OJ(z,w,U,W){if(!$6(W))yield x(_.Function,z,U,W)}function*RJ(z,w,U,W){let X=globalThis.Object.values(z.$defs),Z=z.$defs[z.$ref];yield*U2(Z,[...w,...X],U,W)}function*CJ(z,w,U,W){if(!B8(W))return yield x(_.Integer,z,U,W);if(W0(z.exclusiveMaximum)&&!(W<z.exclusiveMaximum))yield x(_.IntegerExclusiveMaximum,z,U,W);if(W0(z.exclusiveMinimum)&&!(W>z.exclusiveMinimum))yield x(_.IntegerExclusiveMinimum,z,U,W);if(W0(z.maximum)&&!(W<=z.maximum))yield x(_.IntegerMaximum,z,U,W);if(W0(z.minimum)&&!(W>=z.minimum))yield x(_.IntegerMinimum,z,U,W);if(W0(z.multipleOf)&&W%z.multipleOf!==0)yield x(_.IntegerMultipleOf,z,U,W)}function*bJ(z,w,U,W){let X=!1;for(let Z of z.allOf)for(let $ of U2(Z,w,U,W))X=!0,yield $;if(X)return yield x(_.Intersect,z,U,W);if(z.unevaluatedProperties===!1){let Z=new RegExp(t1(z));for(let $ of Object.getOwnPropertyNames(W))if(!Z.test($))yield x(_.IntersectUnevaluatedProperties,z,`${U}/${$}`,W)}if(typeof z.unevaluatedProperties==="object"){let Z=new RegExp(t1(z));for(let $ of Object.getOwnPropertyNames(W))if(!Z.test($)){let A=U2(z.unevaluatedProperties,w,`${U}/${$}`,W[$]).next();if(!A.done)yield A.value}}}function*KJ(z,w,U,W){if(!Y8(W))yield x(_.Iterator,z,U,W)}function*jJ(z,w,U,W){if(W!==z.const)yield x(_.Literal,z,U,W)}function*FJ(z,w,U,W){yield x(_.Never,z,U,W)}function*EJ(z,w,U,W){if(U2(z.not,w,U,W).next().done===!0)yield x(_.Not,z,U,W)}function*IJ(z,w,U,W){if(!c1(W))yield x(_.Null,z,U,W)}function*xJ(z,w,U,W){if(!I0.IsNumberLike(W))return yield x(_.Number,z,U,W);if(W0(z.exclusiveMaximum)&&!(W<z.exclusiveMaximum))yield x(_.NumberExclusiveMaximum,z,U,W);if(W0(z.exclusiveMinimum)&&!(W>z.exclusiveMinimum))yield x(_.NumberExclusiveMinimum,z,U,W);if(W0(z.maximum)&&!(W<=z.maximum))yield x(_.NumberMaximum,z,U,W);if(W0(z.minimum)&&!(W>=z.minimum))yield x(_.NumberMinimum,z,U,W);if(W0(z.multipleOf)&&W%z.multipleOf!==0)yield x(_.NumberMultipleOf,z,U,W)}function*VJ(z,w,U,W){if(!I0.IsObjectLike(W))return yield x(_.Object,z,U,W);if(W0(z.minProperties)&&!(Object.getOwnPropertyNames(W).length>=z.minProperties))yield x(_.ObjectMinProperties,z,U,W);if(W0(z.maxProperties)&&!(Object.getOwnPropertyNames(W).length<=z.maxProperties))yield x(_.ObjectMaxProperties,z,U,W);let X=Array.isArray(z.required)?z.required:[],Z=Object.getOwnPropertyNames(z.properties),$=Object.getOwnPropertyNames(W);for(let A of X){if($.includes(A))continue;yield x(_.ObjectRequiredProperty,z.properties[A],`${U}/${p1(A)}`,void 0)}if(z.additionalProperties===!1){for(let A of $)if(!Z.includes(A))yield x(_.ObjectAdditionalProperties,z,`${U}/${p1(A)}`,W[A])}if(typeof z.additionalProperties==="object")for(let A of $){if(Z.includes(A))continue;yield*U2(z.additionalProperties,w,`${U}/${p1(A)}`,W[A])}for(let A of Z){let Q=z.properties[A];if(z.required&&z.required.includes(A)){if(yield*U2(Q,w,`${U}/${p1(A)}`,W[A]),o1(z)&&!(A in W))yield x(_.ObjectRequiredProperty,Q,`${U}/${p1(A)}`,void 0)}else if(I0.IsExactOptionalProperty(W,A))yield*U2(Q,w,`${U}/${p1(A)}`,W[A])}}function*kJ(z,w,U,W){if(!J8(W))yield x(_.Promise,z,U,W)}function*TJ(z,w,U,W){if(!I0.IsRecordLike(W))return yield x(_.Object,z,U,W);if(W0(z.minProperties)&&!(Object.getOwnPropertyNames(W).length>=z.minProperties))yield x(_.ObjectMinProperties,z,U,W);if(W0(z.maxProperties)&&!(Object.getOwnPropertyNames(W).length<=z.maxProperties))yield x(_.ObjectMaxProperties,z,U,W);let[X,Z]=Object.entries(z.patternProperties)[0],$=new RegExp(X);for(let[A,Q]of Object.entries(W))if($.test(A))yield*U2(Z,w,`${U}/${p1(A)}`,Q);if(typeof z.additionalProperties==="object"){for(let[A,Q]of Object.entries(W))if(!$.test(A))yield*U2(z.additionalProperties,w,`${U}/${p1(A)}`,Q)}if(z.additionalProperties===!1)for(let[A,Q]of Object.entries(W)){if($.test(A))continue;return yield x(_.ObjectAdditionalProperties,z,`${U}/${p1(A)}`,Q)}}function*gJ(z,w,U,W){yield*U2(B0(z,w),w,U,W)}function*fJ(z,w,U,W){if(!A0(W))return yield x(_.String,z,U,W);if(W0(z.minLength)&&!(W.length>=z.minLength))yield x(_.StringMinLength,z,U,W);if(W0(z.maxLength)&&!(W.length<=z.maxLength))yield x(_.StringMaxLength,z,U,W);if(!new RegExp(z.source,z.flags).test(W))return yield x(_.RegExp,z,U,W)}function*dJ(z,w,U,W){if(!A0(W))return yield x(_.String,z,U,W);if(W0(z.minLength)&&!(W.length>=z.minLength))yield x(_.StringMinLength,z,U,W);if(W0(z.maxLength)&&!(W.length<=z.maxLength))yield x(_.StringMaxLength,z,U,W);if(A0(z.pattern)){if(!new RegExp(z.pattern).test(W))yield x(_.StringPattern,z,U,W)}if(A0(z.format)){if(!D0.Has(z.format))yield x(_.StringFormatUnknown,z,U,W);else if(!D0.Get(z.format)(W))yield x(_.StringFormat,z,U,W)}}function*hJ(z,w,U,W){if(!i1(W))yield x(_.Symbol,z,U,W)}function*cJ(z,w,U,W){if(!A0(W))return yield x(_.String,z,U,W);if(!new RegExp(z.pattern).test(W))yield x(_.StringPattern,z,U,W)}function*iJ(z,w,U,W){yield*U2(B0(z,w),w,U,W)}function*yJ(z,w,U,W){if(!m(W))return yield x(_.Tuple,z,U,W);if(z.items===void 0&&W.length!==0)return yield x(_.TupleLength,z,U,W);if(W.length!==z.maxItems)return yield x(_.TupleLength,z,U,W);if(!z.items)return;for(let X=0;X<z.items.length;X++)yield*U2(z.items[X],w,`${U}/${X}`,W[X])}function*vJ(z,w,U,W){if(!k0(W))yield x(_.Undefined,z,U,W)}function*nJ(z,w,U,W){if(s(z,w,W))return;let X=z.anyOf.map((Z)=>new h6(U2(Z,w,U,W)));yield x(_.Union,z,U,W,X)}function*uJ(z,w,U,W){if(!l6(W))return yield x(_.Uint8Array,z,U,W);if(W0(z.maxByteLength)&&!(W.length<=z.maxByteLength))yield x(_.Uint8ArrayMaxByteLength,z,U,W);if(W0(z.minByteLength)&&!(W.length>=z.minByteLength))yield x(_.Uint8ArrayMinByteLength,z,U,W)}function*mJ(z,w,U,W){}function*tJ(z,w,U,W){if(!I0.IsVoidLike(W))yield x(_.Void,z,U,W)}function*oJ(z,w,U,W){if(!p0.Get(z[H])(z,W))yield x(_.Kind,z,U,W)}function*U2(z,w,U,W){let X=W0(z.$id)?[...w,z]:w,Z=z;switch(Z[H]){case"Any":return yield*LJ(Z,X,U,W);case"Argument":return yield*GJ(Z,X,U,W);case"Array":return yield*NJ(Z,X,U,W);case"AsyncIterator":return yield*HJ(Z,X,U,W);case"BigInt":return yield*_J(Z,X,U,W);case"Boolean":return yield*SJ(Z,X,U,W);case"Constructor":return yield*DJ(Z,X,U,W);case"Date":return yield*PJ(Z,X,U,W);case"Function":return yield*OJ(Z,X,U,W);case"Import":return yield*RJ(Z,X,U,W);case"Integer":return yield*CJ(Z,X,U,W);case"Intersect":return yield*bJ(Z,X,U,W);case"Iterator":return yield*KJ(Z,X,U,W);case"Literal":return yield*jJ(Z,X,U,W);case"Never":return yield*FJ(Z,X,U,W);case"Not":return yield*EJ(Z,X,U,W);case"Null":return yield*IJ(Z,X,U,W);case"Number":return yield*xJ(Z,X,U,W);case"Object":return yield*VJ(Z,X,U,W);case"Promise":return yield*kJ(Z,X,U,W);case"Record":return yield*TJ(Z,X,U,W);case"Ref":return yield*gJ(Z,X,U,W);case"RegExp":return yield*fJ(Z,X,U,W);case"String":return yield*dJ(Z,X,U,W);case"Symbol":return yield*hJ(Z,X,U,W);case"TemplateLiteral":return yield*cJ(Z,X,U,W);case"This":return yield*iJ(Z,X,U,W);case"Tuple":return yield*yJ(Z,X,U,W);case"Undefined":return yield*vJ(Z,X,U,W);case"Union":return yield*nJ(Z,X,U,W);case"Uint8Array":return yield*uJ(Z,X,U,W);case"Unknown":return yield*mJ(Z,X,U,W);case"Void":return yield*tJ(Z,X,U,W);default:if(!p0.Has(Z[H]))throw new v7(z);return yield*oJ(Z,X,U,W)}}function k1(...z){let w=z.length===3?U2(z[0],z[1],"",z[2]):U2(z[0],[],"",z[1]);return new h6(w)}class i4 extends n{constructor(z,w,U){super("Unable to decode value as it does not match the expected schema");this.schema=z,this.value=w,this.error=U}}class T8 extends n{constructor(z,w,U,W){super(W instanceof Error?W.message:"Unknown error");this.schema=z,this.path=w,this.value=U,this.error=W}}function d0(z,w,U){try{return G0(z)?z[F0].Decode(U):U}catch(W){throw new T8(z,w,U,W)}}function pJ(z,w,U,W){return m(W)?d0(z,U,W.map((X,Z)=>N1(z.items,w,`${U}/${Z}`,X))):d0(z,U,W)}function lJ(z,w,U,W){if(!l(W)||k2(W))return d0(z,U,W);let X=D8(z),Z=X.map((J)=>J[0]),$={...W};for(let[J,G]of X)if(J in $)$[J]=N1(G,w,`${U}/${J}`,$[J]);if(!G0(z.unevaluatedProperties))return d0(z,U,$);let A=Object.getOwnPropertyNames($),Q=z.unevaluatedProperties,Y={...$};for(let J of A)if(!Z.includes(J))Y[J]=d0(Q,`${U}/${J}`,Y[J]);return d0(z,U,Y)}function sJ(z,w,U,W){let X=globalThis.Object.values(z.$defs),Z=z.$defs[z.$ref],$=N1(Z,[...w,...X],U,W);return d0(z,U,$)}function rJ(z,w,U,W){return d0(z,U,N1(z.not,w,U,W))}function aJ(z,w,U,W){if(!l(W))return d0(z,U,W);let X=O2(z),Z={...W};for(let Y of X){if(!u(Z,Y))continue;if(k0(Z[Y])&&(!n1(z.properties[Y])||I0.IsExactOptionalProperty(Z,Y)))continue;Z[Y]=N1(z.properties[Y],w,`${U}/${Y}`,Z[Y])}if(!f0(z.additionalProperties))return d0(z,U,Z);let $=Object.getOwnPropertyNames(Z),A=z.additionalProperties,Q={...Z};for(let Y of $)if(!X.includes(Y))Q[Y]=d0(A,`${U}/${Y}`,Q[Y]);return d0(z,U,Q)}function eJ(z,w,U,W){if(!l(W))return d0(z,U,W);let X=Object.getOwnPropertyNames(z.patternProperties)[0],Z=new RegExp(X),$={...W};for(let J of Object.getOwnPropertyNames(W))if(Z.test(J))$[J]=N1(z.patternProperties[X],w,`${U}/${J}`,$[J]);if(!f0(z.additionalProperties))return d0(z,U,$);let A=Object.getOwnPropertyNames($),Q=z.additionalProperties,Y={...$};for(let J of A)if(!Z.test(J))Y[J]=d0(Q,`${U}/${J}`,Y[J]);return d0(z,U,Y)}function zB(z,w,U,W){let X=B0(z,w);return d0(z,U,N1(X,w,U,W))}function wB(z,w,U,W){let X=B0(z,w);return d0(z,U,N1(X,w,U,W))}function UB(z,w,U,W){return m(W)&&m(z.items)?d0(z,U,z.items.map((X,Z)=>N1(X,w,`${U}/${Z}`,W[Z]))):d0(z,U,W)}function WB(z,w,U,W){for(let X of z.anyOf){if(!s(X,w,W))continue;let Z=N1(X,w,U,W);return d0(z,U,Z)}return d0(z,U,W)}function N1(z,w,U,W){let X=z2(z,w),Z=z;switch(z[H]){case"Array":return pJ(Z,X,U,W);case"Import":return sJ(Z,X,U,W);case"Intersect":return lJ(Z,X,U,W);case"Not":return rJ(Z,X,U,W);case"Object":return aJ(Z,X,U,W);case"Record":return eJ(Z,X,U,W);case"Ref":return zB(Z,X,U,W);case"Symbol":return d0(Z,U,W);case"This":return wB(Z,X,U,W);case"Tuple":return UB(Z,X,U,W);case"Union":return WB(Z,X,U,W);default:return d0(Z,U,W)}}function H4(z,w,U){return N1(z,w,"",U)}class y4 extends n{constructor(z,w,U){super("The encoded value does not match the expected schema");this.schema=z,this.value=w,this.error=U}}class n7 extends n{constructor(z,w,U,W){super(`${W instanceof Error?W.message:"Unknown error"}`);this.schema=z,this.path=w,this.value=U,this.error=W}}function $2(z,w,U){try{return G0(z)?z[F0].Encode(U):U}catch(W){throw new n7(z,w,U,W)}}function XB(z,w,U,W){let X=$2(z,U,W);return m(X)?X.map((Z,$)=>H1(z.items,w,`${U}/${$}`,Z)):X}function ZB(z,w,U,W){let X=globalThis.Object.values(z.$defs),Z=z.$defs[z.$ref],$=$2(z,U,W);return H1(Z,[...w,...X],U,$)}function $B(z,w,U,W){let X=$2(z,U,W);if(!l(W)||k2(W))return X;let Z=D8(z),$=Z.map((G)=>G[0]),A={...X};for(let[G,S]of Z)if(G in A)A[G]=H1(S,w,`${U}/${G}`,A[G]);if(!G0(z.unevaluatedProperties))return A;let Q=Object.getOwnPropertyNames(A),Y=z.unevaluatedProperties,J={...A};for(let G of Q)if(!$.includes(G))J[G]=$2(Y,`${U}/${G}`,J[G]);return J}function AB(z,w,U,W){return $2(z.not,U,$2(z,U,W))}function QB(z,w,U,W){let X=$2(z,U,W);if(!l(X))return X;let Z=O2(z),$={...X};for(let J of Z){if(!u($,J))continue;if(k0($[J])&&(!n1(z.properties[J])||I0.IsExactOptionalProperty($,J)))continue;$[J]=H1(z.properties[J],w,`${U}/${J}`,$[J])}if(!f0(z.additionalProperties))return $;let A=Object.getOwnPropertyNames($),Q=z.additionalProperties,Y={...$};for(let J of A)if(!Z.includes(J))Y[J]=$2(Q,`${U}/${J}`,Y[J]);return Y}function YB(z,w,U,W){let X=$2(z,U,W);if(!l(W))return X;let Z=Object.getOwnPropertyNames(z.patternProperties)[0],$=new RegExp(Z),A={...X};for(let G of Object.getOwnPropertyNames(W))if($.test(G))A[G]=H1(z.patternProperties[Z],w,`${U}/${G}`,A[G]);if(!f0(z.additionalProperties))return A;let Q=Object.getOwnPropertyNames(A),Y=z.additionalProperties,J={...A};for(let G of Q)if(!$.test(G))J[G]=$2(Y,`${U}/${G}`,J[G]);return J}function JB(z,w,U,W){let X=B0(z,w),Z=H1(X,w,U,W);return $2(z,U,Z)}function BB(z,w,U,W){let X=B0(z,w),Z=H1(X,w,U,W);return $2(z,U,Z)}function MB(z,w,U,W){let X=$2(z,U,W);return m(z.items)?z.items.map((Z,$)=>H1(Z,w,`${U}/${$}`,X[$])):[]}function qB(z,w,U,W){for(let X of z.anyOf){if(!s(X,w,W))continue;let Z=H1(X,w,U,W);return $2(z,U,Z)}for(let X of z.anyOf){let Z=H1(X,w,U,W);if(!s(z,w,Z))continue;return $2(z,U,Z)}return $2(z,U,W)}function H1(z,w,U,W){let X=z2(z,w),Z=z;switch(z[H]){case"Array":return XB(Z,X,U,W);case"Import":return ZB(Z,X,U,W);case"Intersect":return $B(Z,X,U,W);case"Not":return AB(Z,X,U,W);case"Object":return QB(Z,X,U,W);case"Record":return YB(Z,X,U,W);case"Ref":return JB(Z,X,U,W);case"This":return BB(Z,X,U,W);case"Tuple":return MB(Z,X,U,W);case"Union":return qB(Z,X,U,W);default:return $2(Z,U,W)}}function _4(z,w,U){return H1(z,w,"",U)}function LB(z,w){return G0(z)||r0(z.items,w)}function GB(z,w){return G0(z)||r0(z.items,w)}function NB(z,w){return G0(z)||r0(z.returns,w)||z.parameters.some((U)=>r0(U,w))}function HB(z,w){return G0(z)||r0(z.returns,w)||z.parameters.some((U)=>r0(U,w))}function _B(z,w){return G0(z)||G0(z.unevaluatedProperties)||z.allOf.some((U)=>r0(U,w))}function SB(z,w){let U=globalThis.Object.getOwnPropertyNames(z.$defs).reduce((X,Z)=>[...X,z.$defs[Z]],[]),W=z.$defs[z.$ref];return G0(z)||r0(W,[...U,...w])}function DB(z,w){return G0(z)||r0(z.items,w)}function PB(z,w){return G0(z)||r0(z.not,w)}function OB(z,w){return G0(z)||Object.values(z.properties).some((U)=>r0(U,w))||f0(z.additionalProperties)&&r0(z.additionalProperties,w)}function RB(z,w){return G0(z)||r0(z.item,w)}function CB(z,w){let U=Object.getOwnPropertyNames(z.patternProperties)[0],W=z.patternProperties[U];return G0(z)||r0(W,w)||f0(z.additionalProperties)&&G0(z.additionalProperties)}function bB(z,w){if(G0(z))return!0;return r0(B0(z,w),w)}function KB(z,w){if(G0(z))return!0;return r0(B0(z,w),w)}function jB(z,w){return G0(z)||!k0(z.items)&&z.items.some((U)=>r0(U,w))}function FB(z,w){return G0(z)||z.anyOf.some((U)=>r0(U,w))}function r0(z,w){let U=z2(z,w),W=z;if(z.$id&&jz.has(z.$id))return!1;if(z.$id)jz.add(z.$id);switch(z[H]){case"Array":return LB(W,U);case"AsyncIterator":return GB(W,U);case"Constructor":return NB(W,U);case"Function":return HB(W,U);case"Import":return SB(W,U);case"Intersect":return _B(W,U);case"Iterator":return DB(W,U);case"Not":return PB(W,U);case"Object":return OB(W,U);case"Promise":return RB(W,U);case"Record":return CB(W,U);case"Ref":return bB(W,U);case"This":return KB(W,U);case"Tuple":return jB(W,U);case"Union":return FB(W,U);default:return G0(z)}}var jz=new Set;function l1(z,w){return jz.clear(),r0(z,w)}class u7{constructor(z,w,U,W){this.schema=z,this.references=w,this.checkFunc=U,this.code=W,this.hasTransform=l1(z,w)}Code(){return this.code}Schema(){return this.schema}References(){return this.references}Errors(z){return k1(this.schema,this.references,z)}Check(z){return this.checkFunc(z)}Decode(z){if(!this.checkFunc(z))throw new i4(this.schema,z,this.Errors(z).First());return this.hasTransform?H4(this.schema,this.references,z):z}Encode(z){let w=this.hasTransform?_4(this.schema,this.references,z):z;if(!this.checkFunc(w))throw new y4(this.schema,z,this.Errors(z).First());return w}}var s1;(function(z){function w(Z){return Z===36}z.DollarSign=w;function U(Z){return Z===95}z.IsUnderscore=U;function W(Z){return Z>=65&&Z<=90||Z>=97&&Z<=122}z.IsAlpha=W;function X(Z){return Z>=48&&Z<=57}z.IsNumeric=X})(s1||(s1={}));var g8;(function(z){function w(Z){if(Z.length===0)return!1;return s1.IsNumeric(Z.charCodeAt(0))}function U(Z){if(w(Z))return!1;for(let $=0;$<Z.length;$++){let A=Z.charCodeAt($);if(!(s1.IsAlpha(A)||s1.IsNumeric(A)||s1.DollarSign(A)||s1.IsUnderscore(A)))return!1}return!0}function W(Z){return Z.replace(/'/g,"\\'")}function X(Z,$){return U($)?`${Z}.${$}`:`${Z}['${W($)}']`}z.Encode=X})(g8||(g8={}));var Fz;(function(z){function w(U){let W=[];for(let X=0;X<U.length;X++){let Z=U.charCodeAt(X);if(s1.IsNumeric(Z)||s1.IsAlpha(Z))W.push(U.charAt(X));else W.push(`_${Z}_`)}return W.join("").replace(/__/g,"_")}z.Encode=w})(Fz||(Fz={}));var Ez;(function(z){function w(U){return U.replace(/'/g,"\\'")}z.Escape=w})(Ez||(Ez={}));class m7 extends n{constructor(z){super("Unknown type");this.schema=z}}class Iz extends n{constructor(z){super("Preflight validation check failed to guard for the given schema");this.schema=z}}var c6;(function(z){function w($,A,Q){return I0.ExactOptionalPropertyTypes?`('${A}' in ${$} ? ${Q} : true)`:`(${g8.Encode($,A)} !== undefined ? ${Q} : true)`}z.IsExactOptionalProperty=w;function U($){return!I0.AllowArrayObject?`(typeof ${$} === 'object' && ${$} !== null && !Array.isArray(${$}))`:`(typeof ${$} === 'object' && ${$} !== null)`}z.IsObjectLike=U;function W($){return!I0.AllowArrayObject?`(typeof ${$} === 'object' && ${$} !== null && !Array.isArray(${$}) && !(${$} instanceof Date) && !(${$} instanceof Uint8Array))`:`(typeof ${$} === 'object' && ${$} !== null && !(${$} instanceof Date) && !(${$} instanceof Uint8Array))`}z.IsRecordLike=W;function X($){return I0.AllowNaN?`typeof ${$} === 'number'`:`Number.isFinite(${$})`}z.IsNumberLike=X;function Z($){return I0.AllowNullVoid?`(${$} === undefined || ${$} === null)`:`${$} === undefined`}z.IsVoidLike=Z})(c6||(c6={}));var N6;(function(z){function w(B){return B[H]==="Any"||B[H]==="Unknown"}function*U(B,K,L){yield"true"}function*W(B,K,L){yield"true"}function*X(B,K,L){yield`Array.isArray(${L})`;let[d,I]=[F("value","any"),F("acc","number")];if(v(B.maxItems))yield`${L}.length <= ${B.maxItems}`;if(v(B.minItems))yield`${L}.length >= ${B.minItems}`;let h=x2(B.items,K,"value");if(yield`${L}.every((${d}) => ${h})`,g0(B.contains)||v(B.minContains)||v(B.maxContains)){let C0=g0(B.contains)?B.contains:p(),_2=x2(C0,K,"value"),f1=v(B.minContains)?[`(count >= ${B.minContains})`]:[],Z1=v(B.maxContains)?[`(count <= ${B.maxContains})`]:[],j1=`const count = value.reduce((${I}, ${d}) => ${_2} ? acc + 1 : acc, 0)`,X8=["(count > 0)",...f1,...Z1].join(" && ");yield`((${d}) => { ${j1}; return ${X8}})(${L})`}if(B.uniqueItems===!0)yield`((${d}) => { 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*Z(B,K,L){yield`(typeof value === 'object' && Symbol.asyncIterator in ${L})`}function*$(B,K,L){if(yield`(typeof ${L} === 'bigint')`,X2(B.exclusiveMaximum))yield`${L} < BigInt(${B.exclusiveMaximum})`;if(X2(B.exclusiveMinimum))yield`${L} > BigInt(${B.exclusiveMinimum})`;if(X2(B.maximum))yield`${L} <= BigInt(${B.maximum})`;if(X2(B.minimum))yield`${L} >= BigInt(${B.minimum})`;if(X2(B.multipleOf))yield`(${L} % BigInt(${B.multipleOf})) === 0`}function*A(B,K,L){yield`(typeof ${L} === 'boolean')`}function*Q(B,K,L){yield*W1(B.returns,K,`${L}.prototype`)}function*Y(B,K,L){if(yield`(${L} instanceof Date) && Number.isFinite(${L}.getTime())`,v(B.exclusiveMaximumTimestamp))yield`${L}.getTime() < ${B.exclusiveMaximumTimestamp}`;if(v(B.exclusiveMinimumTimestamp))yield`${L}.getTime() > ${B.exclusiveMinimumTimestamp}`;if(v(B.maximumTimestamp))yield`${L}.getTime() <= ${B.maximumTimestamp}`;if(v(B.minimumTimestamp))yield`${L}.getTime() >= ${B.minimumTimestamp}`;if(v(B.multipleOfTimestamp))yield`(${L}.getTime() % ${B.multipleOfTimestamp}) === 0`}function*J(B,K,L){yield`(typeof ${L} === 'function')`}function*G(B,K,L){let d=globalThis.Object.getOwnPropertyNames(B.$defs).reduce((I,h)=>{return[...I,B.$defs[h]]},[]);yield*W1(o2(B.$ref),[...K,...d],L)}function*S(B,K,L){if(yield`Number.isInteger(${L})`,v(B.exclusiveMaximum))yield`${L} < ${B.exclusiveMaximum}`;if(v(B.exclusiveMinimum))yield`${L} > ${B.exclusiveMinimum}`;if(v(B.maximum))yield`${L} <= ${B.maximum}`;if(v(B.minimum))yield`${L} >= ${B.minimum}`;if(v(B.multipleOf))yield`(${L} % ${B.multipleOf}) === 0`}function*N(B,K,L){let d=B.allOf.map((I)=>x2(I,K,L)).join(" && ");if(B.unevaluatedProperties===!1){let I=Z6(`${new RegExp(t1(B))};`),h=`Object.getOwnPropertyNames(${L}).every(key => ${I}.test(key))`;yield`(${d} && ${h})`}else if(g0(B.unevaluatedProperties)){let I=Z6(`${new RegExp(t1(B))};`),h=`Object.getOwnPropertyNames(${L}).every(key => ${I}.test(key) || ${x2(B.unevaluatedProperties,K,`${L}[key]`)})`;yield`(${d} && ${h})`}else yield`(${d})`}function*O(B,K,L){yield`(typeof value === 'object' && Symbol.iterator in ${L})`}function*M(B,K,L){if(typeof B.const==="number"||typeof B.const==="boolean")yield`(${L} === ${B.const})`;else yield`(${L} === '${Ez.Escape(B.const)}')`}function*C(B,K,L){yield"false"}function*g(B,K,L){yield`(!${x2(B.not,K,L)})`}function*L0(B,K,L){yield`(${L} === null)`}function*a(B,K,L){if(yield c6.IsNumberLike(L),v(B.exclusiveMaximum))yield`${L} < ${B.exclusiveMaximum}`;if(v(B.exclusiveMinimum))yield`${L} > ${B.exclusiveMinimum}`;if(v(B.maximum))yield`${L} <= ${B.maximum}`;if(v(B.minimum))yield`${L} >= ${B.minimum}`;if(v(B.multipleOf))yield`(${L} % ${B.multipleOf}) === 0`}function*$0(B,K,L){if(yield c6.IsObjectLike(L),v(B.minProperties))yield`Object.getOwnPropertyNames(${L}).length >= ${B.minProperties}`;if(v(B.maxProperties))yield`Object.getOwnPropertyNames(${L}).length <= ${B.maxProperties}`;let d=Object.getOwnPropertyNames(B.properties);for(let I of d){let h=g8.Encode(L,I),C0=B.properties[I];if(B.required&&B.required.includes(I)){if(yield*W1(C0,K,h),o1(C0)||w(C0))yield`('${I}' in ${L})`}else{let _2=x2(C0,K,h);yield c6.IsExactOptionalProperty(L,I,_2)}}if(B.additionalProperties===!1)if(B.required&&B.required.length===d.length)yield`Object.getOwnPropertyNames(${L}).length === ${d.length}`;else{let I=`[${d.map((h)=>`'${h}'`).join(", ")}]`;yield`Object.getOwnPropertyNames(${L}).every(key => ${I}.includes(key))`}if(typeof B.additionalProperties==="object"){let I=x2(B.additionalProperties,K,`${L}[key]`),h=`[${d.map((C0)=>`'${C0}'`).join(", ")}]`;yield`(Object.getOwnPropertyNames(${L}).every(key => ${h}.includes(key) || ${I}))`}}function*K0(B,K,L){yield`${L} instanceof Promise`}function*f(B,K,L){if(yield c6.IsRecordLike(L),v(B.minProperties))yield`Object.getOwnPropertyNames(${L}).length >= ${B.minProperties}`;if(v(B.maxProperties))yield`Object.getOwnPropertyNames(${L}).length <= ${B.maxProperties}`;let[d,I]=Object.entries(B.patternProperties)[0],h=Z6(`${new RegExp(d)}`),C0=x2(I,K,"value"),_2=g0(B.additionalProperties)?x2(B.additionalProperties,K,L):B.additionalProperties===!1?"false":"true",f1=`(${h}.test(key) ? ${C0} : ${_2})`;yield`(Object.entries(${L}).every(([key, value]) => ${f1}))`}function*V(B,K,L){let d=B0(B,K);if(S0.functions.has(B.$ref))return yield`${X6(B.$ref)}(${L})`;yield*W1(d,K,L)}function*k(B,K,L){let d=Z6(`${new RegExp(B.source,B.flags)};`);if(yield`(typeof ${L} === 'string')`,v(B.maxLength))yield`${L}.length <= ${B.maxLength}`;if(v(B.minLength))yield`${L}.length >= ${B.minLength}`;yield`${d}.test(${L})`}function*j(B,K,L){if(yield`(typeof ${L} === 'string')`,v(B.maxLength))yield`${L}.length <= ${B.maxLength}`;if(v(B.minLength))yield`${L}.length >= ${B.minLength}`;if(B.pattern!==void 0)yield`${Z6(`${new RegExp(B.pattern)};`)}.test(${L})`;if(B.format!==void 0)yield`format('${B.format}', ${L})`}function*e(B,K,L){yield`(typeof ${L} === 'symbol')`}function*Y0(B,K,L){yield`(typeof ${L} === 'string')`,yield`${Z6(`${new RegExp(B.pattern)};`)}.test(${L})`}function*_0(B,K,L){yield`${X6(B.$ref)}(${L})`}function*h0(B,K,L){if(yield`Array.isArray(${L})`,B.items===void 0)return yield`${L}.length === 0`;yield`(${L}.length === ${B.maxItems})`;for(let d=0;d<B.items.length;d++)yield`${x2(B.items[d],K,`${L}[${d}]`)}`}function*U6(B,K,L){yield`${L} === undefined`}function*n0(B,K,L){yield`(${B.anyOf.map((I)=>x2(I,K,L)).join(" || ")})`}function*W6(B,K,L){if(yield`${L} instanceof Uint8Array`,v(B.maxByteLength))yield`(${L}.length <= ${B.maxByteLength})`;if(v(B.minByteLength))yield`(${L}.length >= ${B.minByteLength})`}function*I2(B,K,L){yield"true"}function*K6(B,K,L){yield c6.IsVoidLike(L)}function*r5(B,K,L){let d=S0.instances.size;S0.instances.set(d,B),yield`kind('${B[H]}', ${d}, ${L})`}function*W1(B,K,L,d=!0){let I=A0(B.$id)?[...K,B]:K,h=B;if(d&&A0(B.$id)){let C0=X6(B.$id);if(S0.functions.has(C0))return yield`${C0}(${L})`;else{S0.functions.set(C0,"<deferred>");let _2=X1(C0,B,K,"value",!1);return S0.functions.set(C0,_2),yield`${C0}(${L})`}}switch(h[H]){case"Any":return yield*U(h,I,L);case"Argument":return yield*W(h,I,L);case"Array":return yield*X(h,I,L);case"AsyncIterator":return yield*Z(h,I,L);case"BigInt":return yield*$(h,I,L);case"Boolean":return yield*A(h,I,L);case"Constructor":return yield*Q(h,I,L);case"Date":return yield*Y(h,I,L);case"Function":return yield*J(h,I,L);case"Import":return yield*G(h,I,L);case"Integer":return yield*S(h,I,L);case"Intersect":return yield*N(h,I,L);case"Iterator":return yield*O(h,I,L);case"Literal":return yield*M(h,I,L);case"Never":return yield*C(h,I,L);case"Not":return yield*g(h,I,L);case"Null":return yield*L0(h,I,L);case"Number":return yield*a(h,I,L);case"Object":return yield*$0(h,I,L);case"Promise":return yield*K0(h,I,L);case"Record":return yield*f(h,I,L);case"Ref":return yield*V(h,I,L);case"RegExp":return yield*k(h,I,L);case"String":return yield*j(h,I,L);case"Symbol":return yield*e(h,I,L);case"TemplateLiteral":return yield*Y0(h,I,L);case"This":return yield*_0(h,I,L);case"Tuple":return yield*h0(h,I,L);case"Undefined":return yield*U6(h,I,L);case"Union":return yield*n0(h,I,L);case"Uint8Array":return yield*W6(h,I,L);case"Unknown":return yield*I2(h,I,L);case"Void":return yield*K6(h,I,L);default:if(!p0.Has(h[H]))throw new m7(B);return yield*r5(h,I,L)}}let S0={language:"javascript",functions:new Map,variables:new Map,instances:new Map};function x2(B,K,L,d=!0){return`(${[...W1(B,K,L,d)].join(" && ")})`}function X6(B){return`check_${Fz.Encode(B)}`}function Z6(B){let K=`local_${S0.variables.size}`;return S0.variables.set(K,`const ${K} = ${B}`),K}function X1(B,K,L,d,I=!0){let[h,C0]=[`
3
+ `,(j1)=>"".padStart(j1," ")],_2=F("value","any"),f1=R("boolean"),Z1=[...W1(K,L,d,I)].map((j1)=>`${C0(4)}${j1}`).join(` &&${h}`);return`function ${B}(${_2})${f1} {${h}${C0(2)}return (${h}${Z1}${h}${C0(2)})
4
+ }`}function F(B,K){let L=S0.language==="typescript"?`: ${K}`:"";return`${B}${L}`}function R(B){return S0.language==="typescript"?`: ${B}`:""}function b(B,K,L){let d=X1("check",B,K,"value"),I=F("value","any"),h=R("boolean"),C0=[...S0.functions.values()],_2=[...S0.variables.values()],f1=A0(B.$id)?`return function check(${I})${h} {
5
+ return ${X6(B.$id)}(value)
6
+ }`:`return ${d}`;return[..._2,...C0,f1].join(`
7
+ `)}function c(...B){let K={language:"javascript"},[L,d,I]=B.length===2&&m(B[1])?[B[0],B[1],K]:B.length===2&&!m(B[1])?[B[0],[],B[1]]:B.length===3?[B[0],B[1],B[2]]:B.length===1?[B[0],[],K]:[null,[],K];if(S0.language=I.language,S0.variables.clear(),S0.functions.clear(),S0.instances.clear(),!g0(L))throw new Iz(L);for(let h of d)if(!g0(h))throw new Iz(h);return b(L,d,I)}z.Code=c;function t(B,K=[]){let L=c(B,K,{language:"javascript"}),d=globalThis.Function("kind","format","hash",L),I=new Map(S0.instances);function h(Z1,j1,X8){if(!p0.Has(Z1)||!I.has(j1))return!1;let NX=p0.Get(Z1),HX=I.get(j1);return NX(HX,X8)}function C0(Z1,j1){if(!D0.Has(Z1))return!1;return D0.Get(Z1)(j1)}function _2(Z1){return G6(Z1)}let f1=d(h,C0,_2);return new u7(B,K,f1,L)}z.Compile=t})(N6||(N6={}));var EB=function(z,w,U,W,X){if(W==="m")throw new TypeError("Private method is not writable");if(W==="a"&&!X)throw new TypeError("Private accessor was defined without a setter");if(typeof w==="function"?z!==w||!X:!w.has(z))throw new TypeError("Cannot write private member to an object whose class did not declare it");return W==="a"?X.call(z,U):X?X.value=U:w.set(z,U),U},o7=function(z,w,U,W){if(U==="a"&&!W)throw new TypeError("Private accessor was defined without a getter");if(typeof w==="function"?z!==w||!W:!w.has(z))throw new TypeError("Cannot read private member from an object whose class did not declare it");return U==="m"?W:U==="a"?W.call(z):W?W.value:w.get(z)},xz,f8,p7;class l7 extends n{constructor(z){let w=z.First();super(w===void 0?"Invalid Value":w.message);xz.add(this),f8.set(this,void 0),EB(this,f8,z,"f"),this.error=w}Errors(){return new h6(o7(this,xz,"m",p7).call(this))}}f8=new WeakMap,xz=new WeakSet,p7=function*z(){if(this.error)yield this.error;yield*o7(this,f8,"f")};function t7(z,w,U){if(s(z,w,U))return;throw new l7(k1(z,w,U))}function d8(...z){return z.length===3?t7(z[0],z[1],z[2]):t7(z[0],[],z[1])}function IB(z){let w={};for(let U of Object.getOwnPropertyNames(z))w[U]=M0(z[U]);for(let U of Object.getOwnPropertySymbols(z))w[U]=M0(z[U]);return w}function xB(z){return z.map((w)=>M0(w))}function VB(z){return z.slice()}function kB(z){return new Map(M0([...z.entries()]))}function TB(z){return new Set(M0([...z.entries()]))}function gB(z){return new Date(z.toISOString())}function fB(z){return z}function M0(z){if(m(z))return xB(z);if(G2(z))return gB(z);if(v2(z))return VB(z);if(qw(z))return kB(z);if(Lw(z))return TB(z);if(l(z))return IB(z);if(k2(z))return fB(z);throw new Error("ValueClone: Unable to clone value")}class s2 extends n{constructor(z,w){super(w);this.schema=z}}function q0(z){return $6(z)?z():M0(z)}function dB(z,w){if(u(z,"default"))return q0(z.default);else return{}}function hB(z,w){return{}}function cB(z,w){if(z.uniqueItems===!0&&!u(z,"default"))throw new s2(z,"Array with the uniqueItems constraint requires a default value");else if("contains"in z&&!u(z,"default"))throw new s2(z,"Array with the contains constraint requires a default value");else if("default"in z)return q0(z.default);else if(z.minItems!==void 0)return Array.from({length:z.minItems}).map((U)=>{return C2(z.items,w)});else return[]}function iB(z,w){if(u(z,"default"))return q0(z.default);else return async function*(){}()}function yB(z,w){if(u(z,"default"))return q0(z.default);else return BigInt(0)}function vB(z,w){if(u(z,"default"))return q0(z.default);else return!1}function nB(z,w){if(u(z,"default"))return q0(z.default);else{let U=C2(z.returns,w);if(typeof U==="object"&&!Array.isArray(U))return class{constructor(){for(let[W,X]of Object.entries(U)){let Z=this;Z[W]=X}}};else return class{}}}function uB(z,w){if(u(z,"default"))return q0(z.default);else if(z.minimumTimestamp!==void 0)return new Date(z.minimumTimestamp);else return new Date}function mB(z,w){if(u(z,"default"))return q0(z.default);else return()=>C2(z.returns,w)}function tB(z,w){let U=globalThis.Object.values(z.$defs),W=z.$defs[z.$ref];return C2(W,[...w,...U])}function oB(z,w){if(u(z,"default"))return q0(z.default);else if(z.minimum!==void 0)return z.minimum;else return 0}function pB(z,w){if(u(z,"default"))return q0(z.default);else{let U=z.allOf.reduce((W,X)=>{let Z=C2(X,w);return typeof Z==="object"?{...W,...Z}:Z},{});if(!s(z,w,U))throw new s2(z,"Intersect produced invalid value. Consider using a default value.");return U}}function lB(z,w){if(u(z,"default"))return q0(z.default);else return function*(){}()}function sB(z,w){if(u(z,"default"))return q0(z.default);else return z.const}function rB(z,w){if(u(z,"default"))return q0(z.default);else throw new s2(z,"Never types cannot be created. Consider using a default value.")}function aB(z,w){if(u(z,"default"))return q0(z.default);else throw new s2(z,"Not types must have a default value")}function eB(z,w){if(u(z,"default"))return q0(z.default);else return null}function zM(z,w){if(u(z,"default"))return q0(z.default);else if(z.minimum!==void 0)return z.minimum;else return 0}function wM(z,w){if(u(z,"default"))return q0(z.default);else{let U=new Set(z.required),W={};for(let[X,Z]of Object.entries(z.properties)){if(!U.has(X))continue;W[X]=C2(Z,w)}return W}}function UM(z,w){if(u(z,"default"))return q0(z.default);else return Promise.resolve(C2(z.item,w))}function WM(z,w){let[U,W]=Object.entries(z.patternProperties)[0];if(u(z,"default"))return q0(z.default);else if(!(U===I1||U===E1)){let X=U.slice(1,U.length-1).split("|"),Z={};for(let $ of X)Z[$]=C2(W,w);return Z}else return{}}function XM(z,w){if(u(z,"default"))return q0(z.default);else return C2(B0(z,w),w)}function ZM(z,w){if(u(z,"default"))return q0(z.default);else throw new s2(z,"RegExp types cannot be created. Consider using a default value.")}function $M(z,w){if(z.pattern!==void 0)if(!u(z,"default"))throw new s2(z,"String types with patterns must specify a default value");else return q0(z.default);else if(z.format!==void 0)if(!u(z,"default"))throw new s2(z,"String types with formats must specify a default value");else return q0(z.default);else if(u(z,"default"))return q0(z.default);else if(z.minLength!==void 0)return Array.from({length:z.minLength}).map(()=>" ").join("");else return""}function AM(z,w){if(u(z,"default"))return q0(z.default);else if("value"in z)return Symbol.for(z.value);else return Symbol()}function QM(z,w){if(u(z,"default"))return q0(z.default);if(!G8(z))throw new s2(z,"Can only create template literals that produce a finite variants. Consider using a default value.");return X4(z)[0]}function YM(z,w){if(s7++>HM)throw new s2(z,"Cannot create recursive type as it appears possibly infinite. Consider using a default.");if(u(z,"default"))return q0(z.default);else return C2(B0(z,w),w)}function JM(z,w){if(u(z,"default"))return q0(z.default);if(z.items===void 0)return[];else return Array.from({length:z.minItems}).map((U,W)=>C2(z.items[W],w))}function BM(z,w){if(u(z,"default"))return q0(z.default);else return}function MM(z,w){if(u(z,"default"))return q0(z.default);else if(z.anyOf.length===0)throw new Error("ValueCreate.Union: Cannot create Union with zero variants");else return C2(z.anyOf[0],w)}function qM(z,w){if(u(z,"default"))return q0(z.default);else if(z.minByteLength!==void 0)return new Uint8Array(z.minByteLength);else return new Uint8Array(0)}function LM(z,w){if(u(z,"default"))return q0(z.default);else return{}}function GM(z,w){if(u(z,"default"))return q0(z.default);else return}function NM(z,w){if(u(z,"default"))return q0(z.default);else throw new Error("User defined types must specify a default value")}function C2(z,w){let U=z2(z,w),W=z;switch(W[H]){case"Any":return dB(W,U);case"Argument":return hB(W,U);case"Array":return cB(W,U);case"AsyncIterator":return iB(W,U);case"BigInt":return yB(W,U);case"Boolean":return vB(W,U);case"Constructor":return nB(W,U);case"Date":return uB(W,U);case"Function":return mB(W,U);case"Import":return tB(W,U);case"Integer":return oB(W,U);case"Intersect":return pB(W,U);case"Iterator":return lB(W,U);case"Literal":return sB(W,U);case"Never":return rB(W,U);case"Not":return aB(W,U);case"Null":return eB(W,U);case"Number":return zM(W,U);case"Object":return wM(W,U);case"Promise":return UM(W,U);case"Record":return WM(W,U);case"Ref":return XM(W,U);case"RegExp":return ZM(W,U);case"String":return $M(W,U);case"Symbol":return AM(W,U);case"TemplateLiteral":return QM(W,U);case"This":return YM(W,U);case"Tuple":return JM(W,U);case"Undefined":return BM(W,U);case"Union":return MM(W,U);case"Uint8Array":return qM(W,U);case"Unknown":return LM(W,U);case"Void":return GM(W,U);default:if(!p0.Has(W[H]))throw new s2(W,"Unknown type");return NM(W,U)}}var HM=512,s7=0;function r2(...z){return s7=0,z.length===2?C2(z[0],z[1]):C2(z[0],[])}class Vz extends n{constructor(z,w){super(w);this.schema=z}}function _M(z,w,U){if(z[H]==="Object"&&typeof U==="object"&&!c1(U)){let W=z,X=Object.getOwnPropertyNames(U),Z=Object.entries(W.properties),[$,A]=[1/Z.length,Z.length];return Z.reduce((Q,[Y,J])=>{let G=J[H]==="Literal"&&J.const===U[Y]?A:0,S=s(J,w,U[Y])?$:0,N=X.includes(Y)?$:0;return Q+(G+S+N)},0)}else return s(z,w,U)?1:0}function SM(z,w,U){let W=z.anyOf.map(($)=>B0($,w)),[X,Z]=[W[0],0];for(let $ of W){let A=_M($,w,U);if(A>Z)X=$,Z=A}return X}function DM(z,w,U){if("default"in z)return typeof U==="function"?z.default:M0(z.default);else{let W=SM(z,w,U);return v4(W,w,U)}}function PM(z,w,U){return s(z,w,U)?M0(U):r2(z,w)}function OM(z,w,U){return s(z,w,U)?U:r2(z,w)}function RM(z,w,U){if(s(z,w,U))return M0(U);let W=m(U)?M0(U):r2(z,w),X=v(z.minItems)&&W.length<z.minItems?[...W,...Array.from({length:z.minItems-W.length},()=>null)]:W,$=(v(z.maxItems)&&X.length>z.maxItems?X.slice(0,z.maxItems):X).map((Q)=>_1(z.items,w,Q));if(z.uniqueItems!==!0)return $;let A=[...new Set($)];if(!s(z,w,A))throw new Vz(z,"Array cast produced invalid data due to uniqueItems constraint");return A}function CM(z,w,U){if(s(z,w,U))return r2(z,w);let W=new Set(z.returns.required||[]),X=function(){};for(let[Z,$]of Object.entries(z.returns.properties)){if(!W.has(Z)&&U.prototype[Z]===void 0)continue;X.prototype[Z]=_1($,w,U.prototype[Z])}return X}function bM(z,w,U){let W=globalThis.Object.values(z.$defs),X=z.$defs[z.$ref];return _1(X,[...w,...W],U)}function KM(z,w,U){let W=r2(z,w),X=l(W)&&l(U)?{...W,...U}:U;return s(z,w,X)?X:r2(z,w)}function jM(z,w,U){throw new Vz(z,"Never types cannot be cast")}function FM(z,w,U){if(s(z,w,U))return U;if(U===null||typeof U!=="object")return r2(z,w);let W=new Set(z.required||[]),X={};for(let[Z,$]of Object.entries(z.properties)){if(!W.has(Z)&&U[Z]===void 0)continue;X[Z]=_1($,w,U[Z])}if(typeof z.additionalProperties==="object"){let Z=Object.getOwnPropertyNames(z.properties);for(let $ of Object.getOwnPropertyNames(U)){if(Z.includes($))continue;X[$]=_1(z.additionalProperties,w,U[$])}}return X}function EM(z,w,U){if(s(z,w,U))return M0(U);if(U===null||typeof U!=="object"||Array.isArray(U)||U instanceof Date)return r2(z,w);let W=Object.getOwnPropertyNames(z.patternProperties)[0],X=z.patternProperties[W],Z={};for(let[$,A]of Object.entries(U))Z[$]=_1(X,w,A);return Z}function IM(z,w,U){return _1(B0(z,w),w,U)}function xM(z,w,U){return _1(B0(z,w),w,U)}function VM(z,w,U){if(s(z,w,U))return M0(U);if(!m(U))return r2(z,w);if(z.items===void 0)return[];return z.items.map((W,X)=>_1(W,w,U[X]))}function kM(z,w,U){return s(z,w,U)?M0(U):DM(z,w,U)}function _1(z,w,U){let W=A0(z.$id)?z2(z,w):w,X=z;switch(z[H]){case"Array":return RM(X,W,U);case"Constructor":return CM(X,W,U);case"Import":return bM(X,W,U);case"Intersect":return KM(X,W,U);case"Never":return jM(X,W,U);case"Object":return FM(X,W,U);case"Record":return EM(X,W,U);case"Ref":return IM(X,W,U);case"This":return xM(X,W,U);case"Tuple":return VM(X,W,U);case"Union":return kM(X,W,U);case"Date":case"Symbol":case"Uint8Array":return PM(z,w,U);default:return OM(X,W,U)}}function v4(...z){return z.length===3?_1(z[0],z[1],z[2]):_1(z[0],[],z[1])}function TM(z){return Q6(z)&&z[H]!=="Unsafe"}function gM(z,w,U){if(!m(U))return U;return U.map((W)=>b2(z.items,w,W))}function fM(z,w,U){let W=globalThis.Object.values(z.$defs),X=z.$defs[z.$ref];return b2(X,[...w,...W],U)}function dM(z,w,U){let W=z.unevaluatedProperties,Z=z.allOf.map((A)=>b2(A,w,M0(U))).reduce((A,Q)=>l(Q)?{...A,...Q}:Q,{});if(!l(U)||!l(Z)||!Q6(W))return Z;let $=O2(z);for(let A of Object.getOwnPropertyNames(U)){if($.includes(A))continue;if(s(W,w,U[A]))Z[A]=b2(W,w,U[A])}return Z}function hM(z,w,U){if(!l(U)||m(U))return U;let W=z.additionalProperties;for(let X of Object.getOwnPropertyNames(U)){if(u(z.properties,X)){U[X]=b2(z.properties[X],w,U[X]);continue}if(Q6(W)&&s(W,w,U[X])){U[X]=b2(W,w,U[X]);continue}delete U[X]}return U}function cM(z,w,U){if(!l(U))return U;let W=z.additionalProperties,X=Object.getOwnPropertyNames(U),[Z,$]=Object.entries(z.patternProperties)[0],A=new RegExp(Z);for(let Q of X){if(A.test(Q)){U[Q]=b2($,w,U[Q]);continue}if(Q6(W)&&s(W,w,U[Q])){U[Q]=b2(W,w,U[Q]);continue}delete U[Q]}return U}function iM(z,w,U){return b2(B0(z,w),w,U)}function yM(z,w,U){return b2(B0(z,w),w,U)}function vM(z,w,U){if(!m(U))return U;if(k0(z.items))return[];let W=Math.min(U.length,z.items.length);for(let X=0;X<W;X++)U[X]=b2(z.items[X],w,U[X]);return U.length>W?U.slice(0,W):U}function nM(z,w,U){for(let W of z.anyOf)if(TM(W)&&s(W,w,U))return b2(W,w,U);return U}function b2(z,w,U){let W=A0(z.$id)?z2(z,w):w,X=z;switch(X[H]){case"Array":return gM(X,W,U);case"Import":return fM(X,W,U);case"Intersect":return dM(X,W,U);case"Object":return hM(X,W,U);case"Record":return cM(X,W,U);case"Ref":return iM(X,W,U);case"This":return yM(X,W,U);case"Tuple":return vM(X,W,U);case"Union":return nM(X,W,U);default:return U}}function h8(...z){return z.length===3?b2(z[0],z[1],z[2]):b2(z[0],[],z[1])}function c8(z){return A0(z)&&!isNaN(z)&&!isNaN(parseFloat(z))}function uM(z){return X2(z)||F1(z)||v(z)}function n4(z){return z===!0||v(z)&&z===1||X2(z)&&z===BigInt("1")||A0(z)&&(z.toLowerCase()==="true"||z==="1")}function u4(z){return z===!1||v(z)&&(z===0||Object.is(z,-0))||X2(z)&&z===BigInt("0")||A0(z)&&(z.toLowerCase()==="false"||z==="0"||z==="-0")}function mM(z){return A0(z)&&/^(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)$/i.test(z)}function tM(z){return A0(z)&&/^(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)?$/i.test(z)}function oM(z){return A0(z)&&/^\d\d\d\d-[0-1]\d-[0-3]\dt(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)$/i.test(z)}function pM(z){return A0(z)&&/^\d\d\d\d-[0-1]\d-[0-3]\dt(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)?$/i.test(z)}function lM(z){return A0(z)&&/^\d\d\d\d-[0-1]\d-[0-3]\d$/i.test(z)}function sM(z,w){let U=a7(z);return U===w?U:z}function rM(z,w){let U=e7(z);return U===w?U:z}function aM(z,w){let U=r7(z);return U===w?U:z}function eM(z,w){return A0(z.const)?sM(w,z.const):v(z.const)?rM(w,z.const):F1(z.const)?aM(w,z.const):w}function r7(z){return n4(z)?!0:u4(z)?!1:z}function zq(z){let w=(U)=>U.split(".")[0];return c8(z)?BigInt(w(z)):v(z)?BigInt(Math.trunc(z)):u4(z)?BigInt(0):n4(z)?BigInt(1):z}function a7(z){return i1(z)&&z.description!==void 0?z.description.toString():uM(z)?z.toString():z}function e7(z){return c8(z)?parseFloat(z):n4(z)?1:u4(z)?0:z}function wq(z){return c8(z)?parseInt(z):v(z)?Math.trunc(z):n4(z)?1:u4(z)?0:z}function Uq(z){return A0(z)&&z.toLowerCase()==="null"?null:z}function Wq(z){return A0(z)&&z==="undefined"?void 0:z}function Xq(z){return G2(z)?z:v(z)?new Date(z):n4(z)?new Date(1):u4(z)?new Date(0):c8(z)?new Date(parseInt(z)):tM(z)?new Date(`1970-01-01T${z}.000Z`):mM(z)?new Date(`1970-01-01T${z}`):pM(z)?new Date(`${z}.000Z`):oM(z)?new Date(z):lM(z)?new Date(`${z}T00:00:00.000Z`):z}function Zq(z){return z}function $q(z,w,U){return(m(U)?U:[U]).map((X)=>S1(z.items,w,X))}function Aq(z,w,U){return zq(U)}function Qq(z,w,U){return r7(U)}function Yq(z,w,U){return Xq(U)}function Jq(z,w,U){let W=globalThis.Object.values(z.$defs),X=z.$defs[z.$ref];return S1(X,[...w,...W],U)}function Bq(z,w,U){return wq(U)}function Mq(z,w,U){return z.allOf.reduce((W,X)=>S1(X,w,W),U)}function qq(z,w,U){return eM(z,U)}function Lq(z,w,U){return Uq(U)}function Gq(z,w,U){return e7(U)}function Nq(z,w,U){if(!l(U))return U;for(let W of Object.getOwnPropertyNames(z.properties)){if(!u(U,W))continue;U[W]=S1(z.properties[W],w,U[W])}return U}function Hq(z,w,U){if(!l(U))return U;let X=Object.getOwnPropertyNames(z.patternProperties)[0],Z=z.patternProperties[X];for(let[$,A]of Object.entries(U))U[$]=S1(Z,w,A);return U}function _q(z,w,U){return S1(B0(z,w),w,U)}function Sq(z,w,U){return a7(U)}function Dq(z,w,U){return A0(U)||v(U)?Symbol(U):U}function Pq(z,w,U){return S1(B0(z,w),w,U)}function Oq(z,w,U){if(!(m(U)&&!k0(z.items)))return U;return U.map((X,Z)=>{return Z<z.items.length?S1(z.items[Z],w,X):X})}function Rq(z,w,U){return Wq(U)}function Cq(z,w,U){for(let W of z.anyOf){let X=S1(W,w,M0(U));if(!s(W,w,X))continue;return X}return U}function S1(z,w,U){let W=z2(z,w),X=z;switch(z[H]){case"Array":return $q(X,W,U);case"BigInt":return Aq(X,W,U);case"Boolean":return Qq(X,W,U);case"Date":return Yq(X,W,U);case"Import":return Jq(X,W,U);case"Integer":return Bq(X,W,U);case"Intersect":return Mq(X,W,U);case"Literal":return qq(X,W,U);case"Null":return Lq(X,W,U);case"Number":return Gq(X,W,U);case"Object":return Nq(X,W,U);case"Record":return Hq(X,W,U);case"Ref":return _q(X,W,U);case"String":return Sq(X,W,U);case"Symbol":return Dq(X,W,U);case"This":return Pq(X,W,U);case"Tuple":return Oq(X,W,U);case"Undefined":return Rq(X,W,U);case"Union":return Cq(X,W,U);default:return Zq(U)}}function i8(...z){return z.length===3?S1(z[0],z[1],z[2]):S1(z[0],[],z[1])}function zU(...z){let[w,U,W]=z.length===3?[z[0],z[1],z[2]]:[z[0],[],z[1]];if(!s(w,U,W))throw new i4(w,W,k1(w,U,W).First());return l1(w,U)?H4(w,U,W):W}function r1(z,w){let U=u(z,"default")?z.default:void 0,W=$6(U)?U():M0(U);return k0(w)?W:l(w)&&l(W)?Object.assign(W,w):w}function kz(z){return Q6(z)&&"default"in z}function bq(z,w,U){if(m(U)){for(let X=0;X<U.length;X++)U[X]=H2(z.items,w,U[X]);return U}let W=r1(z,U);if(!m(W))return W;for(let X=0;X<W.length;X++)W[X]=H2(z.items,w,W[X]);return W}function Kq(z,w,U){return G2(U)?U:r1(z,U)}function jq(z,w,U){let W=globalThis.Object.values(z.$defs),X=z.$defs[z.$ref];return H2(X,[...w,...W],U)}function Fq(z,w,U){let W=r1(z,U);return z.allOf.reduce((X,Z)=>{let $=H2(Z,w,W);return l($)?{...X,...$}:$},{})}function Eq(z,w,U){let W=r1(z,U);if(!l(W))return W;let X=Object.getOwnPropertyNames(z.properties);for(let Z of X){let $=H2(z.properties[Z],w,W[Z]);if(k0($))continue;W[Z]=H2(z.properties[Z],w,W[Z])}if(!kz(z.additionalProperties))return W;for(let Z of Object.getOwnPropertyNames(W)){if(X.includes(Z))continue;W[Z]=H2(z.additionalProperties,w,W[Z])}return W}function Iq(z,w,U){let W=r1(z,U);if(!l(W))return W;let X=z.additionalProperties,[Z,$]=Object.entries(z.patternProperties)[0],A=new RegExp(Z);for(let Q of Object.getOwnPropertyNames(W)){if(!(A.test(Q)&&kz($)))continue;W[Q]=H2($,w,W[Q])}if(!kz(X))return W;for(let Q of Object.getOwnPropertyNames(W)){if(A.test(Q))continue;W[Q]=H2(X,w,W[Q])}return W}function xq(z,w,U){return H2(B0(z,w),w,r1(z,U))}function Vq(z,w,U){return H2(B0(z,w),w,U)}function kq(z,w,U){let W=r1(z,U);if(!m(W)||k0(z.items))return W;let[X,Z]=[z.items,Math.max(z.items.length,W.length)];for(let $=0;$<Z;$++)if($<X.length)W[$]=H2(X[$],w,W[$]);return W}function Tq(z,w,U){let W=r1(z,U);for(let X of z.anyOf){let Z=H2(X,w,M0(W));if(s(X,w,Z))return Z}return W}function H2(z,w,U){let W=z2(z,w),X=z;switch(X[H]){case"Array":return bq(X,W,U);case"Date":return Kq(X,W,U);case"Import":return jq(X,W,U);case"Intersect":return Fq(X,W,U);case"Object":return Eq(X,W,U);case"Record":return Iq(X,W,U);case"Ref":return xq(X,W,U);case"This":return Vq(X,W,U);case"Tuple":return kq(X,W,U);case"Union":return Tq(X,W,U);default:return r1(X,U)}}function y8(...z){return z.length===3?H2(z[0],z[1],z[2]):H2(z[0],[],z[1])}var D1={};j6(D1,{ValuePointerRootSetError:()=>Tz,ValuePointerRootDeleteError:()=>gz,Set:()=>gq,Has:()=>dq,Get:()=>hq,Format:()=>m4,Delete:()=>fq});class Tz extends n{constructor(z,w,U){super("Cannot set root value");this.value=z,this.path=w,this.update=U}}class gz extends n{constructor(z,w){super("Cannot delete root value");this.value=z,this.path=w}}function wU(z){return z.indexOf("~")===-1?z:z.replace(/~1/g,"/").replace(/~0/g,"~")}function*m4(z){if(z==="")return;let[w,U]=[0,0];for(let W=0;W<z.length;W++)if(z.charAt(W)==="/")if(W===0)w=W+1;else U=W,yield wU(z.slice(w,U)),w=W+1;else U=W;yield wU(z.slice(w))}function gq(z,w,U){if(w==="")throw new Tz(z,w,U);let[W,X,Z]=[null,z,""];for(let $ of m4(w)){if(X[$]===void 0)X[$]={};W=X,X=X[$],Z=$}W[Z]=U}function fq(z,w){if(w==="")throw new gz(z,w);let[U,W,X]=[null,z,""];for(let Z of m4(w)){if(W[Z]===void 0||W[Z]===null)return;U=W,W=W[Z],X=Z}if(Array.isArray(U)){let Z=parseInt(X);U.splice(Z,1)}else delete U[X]}function dq(z,w){if(w==="")return!0;let[U,W,X]=[null,z,""];for(let Z of m4(w)){if(W[Z]===void 0)return!1;U=W,W=W[Z],X=Z}return Object.getOwnPropertyNames(U).includes(X)}function hq(z,w){if(w==="")return z;let U=z;for(let W of m4(w)){if(U[W]===void 0)return;U=U[W]}return U}function cq(z,w){if(!l(w))return!1;let U=[...Object.keys(z),...Object.getOwnPropertySymbols(z)],W=[...Object.keys(w),...Object.getOwnPropertySymbols(w)];if(U.length!==W.length)return!1;return U.every((X)=>i6(z[X],w[X]))}function iq(z,w){return G2(w)&&z.getTime()===w.getTime()}function yq(z,w){if(!m(w)||z.length!==w.length)return!1;return z.every((U,W)=>i6(U,w[W]))}function vq(z,w){if(!v2(w)||z.length!==w.length||Object.getPrototypeOf(z).constructor.name!==Object.getPrototypeOf(w).constructor.name)return!1;return z.every((U,W)=>i6(U,w[W]))}function nq(z,w){return z===w}function i6(z,w){if(G2(z))return iq(z,w);if(v2(z))return vq(z,w);if(m(z))return yq(z,w);if(l(z))return cq(z,w);if(k2(z))return nq(z,w);throw new Error("ValueEquals: Unable to compare value")}var uq=H0({type:Z0("insert"),path:N2(),value:q1()}),mq=H0({type:Z0("update"),path:N2(),value:q1()}),tq=H0({type:Z0("delete"),path:N2()}),WU=N0([uq,mq,tq]);class fz extends n{constructor(z,w){super(w);this.value=z}}function v8(z,w){return{type:"update",path:z,value:w}}function XU(z,w){return{type:"insert",path:z,value:w}}function ZU(z){return{type:"delete",path:z}}function UU(z){if(globalThis.Object.getOwnPropertySymbols(z).length>0)throw new fz(z,"Cannot diff objects with symbols")}function*oq(z,w,U){if(UU(w),UU(U),!Xz(U))return yield v8(z,U);let W=globalThis.Object.getOwnPropertyNames(w),X=globalThis.Object.getOwnPropertyNames(U);for(let Z of X){if(u(w,Z))continue;yield XU(`${z}/${Z}`,U[Z])}for(let Z of W){if(!u(U,Z))continue;if(i6(w,U))continue;yield*n8(`${z}/${Z}`,w[Z],U[Z])}for(let Z of W){if(u(U,Z))continue;yield ZU(`${z}/${Z}`)}}function*pq(z,w,U){if(!m(U))return yield v8(z,U);for(let W=0;W<Math.min(w.length,U.length);W++)yield*n8(`${z}/${W}`,w[W],U[W]);for(let W=0;W<U.length;W++){if(W<w.length)continue;yield XU(`${z}/${W}`,U[W])}for(let W=w.length-1;W>=0;W--){if(W<U.length)continue;yield ZU(`${z}/${W}`)}}function*lq(z,w,U){if(!v2(U)||w.length!==U.length||globalThis.Object.getPrototypeOf(w).constructor.name!==globalThis.Object.getPrototypeOf(U).constructor.name)return yield v8(z,U);for(let W=0;W<Math.min(w.length,U.length);W++)yield*n8(`${z}/${W}`,w[W],U[W])}function*sq(z,w,U){if(w===U)return;yield v8(z,U)}function*n8(z,w,U){if(Xz(w))return yield*oq(z,w,U);if(m(w))return yield*pq(z,w,U);if(v2(w))return yield*lq(z,w,U);if(k2(w))return yield*sq(z,w,U);throw new fz(w,"Unable to diff value")}function $U(z,w){return[...n8("",z,w)]}function rq(z){return z.length>0&&z[0].path===""&&z[0].type==="update"}function aq(z){return z.length===0}function AU(z,w){if(rq(w))return M0(w[0].value);if(aq(w))return M0(z);let U=M0(z);for(let W of w)switch(W.type){case"insert":{D1.Set(U,W.path,W.value);break}case"update":{D1.Set(U,W.path,W.value);break}case"delete":{D1.Delete(U,W.path);break}}return U}function QU(...z){let[w,U,W]=z.length===3?[z[0],z[1],z[2]]:[z[0],[],z[1]],X=l1(w,U)?_4(w,U,W):W;if(!s(w,U,X))throw new y4(w,X,k1(w,U,X).First());return X}function u8(z){return l(z)&&!m(z)}class dz extends n{constructor(z){super(z)}}function eq(z,w,U,W){if(!u8(U))D1.Set(z,w,M0(W));else{let X=Object.getOwnPropertyNames(U),Z=Object.getOwnPropertyNames(W);for(let $ of X)if(!Z.includes($))delete U[$];for(let $ of Z)if(!X.includes($))U[$]=null;for(let $ of Z)hz(z,`${w}/${$}`,U[$],W[$])}}function zL(z,w,U,W){if(!m(U))D1.Set(z,w,M0(W));else{for(let X=0;X<W.length;X++)hz(z,`${w}/${X}`,U[X],W[X]);U.splice(W.length)}}function wL(z,w,U,W){if(v2(U)&&U.length===W.length)for(let X=0;X<U.length;X++)U[X]=W[X];else D1.Set(z,w,M0(W))}function UL(z,w,U,W){if(U===W)return;D1.Set(z,w,W)}function hz(z,w,U,W){if(m(W))return zL(z,w,U,W);if(v2(W))return wL(z,w,U,W);if(u8(W))return eq(z,w,U,W);if(k2(W))return UL(z,w,U,W)}function YU(z){return v2(z)||k2(z)}function WL(z,w){return u8(z)&&m(w)||m(z)&&u8(w)}function JU(z,w){if(YU(z)||YU(w))throw new dz("Only object and array types can be mutated at the root level");if(WL(z,w))throw new dz("Cannot assign due type mismatch of assignable values");hz(z,"",z,w)}class iz extends n{constructor(z){super(z)}}var cz;(function(z){let w=new Map([["Assert",(Z,$,A)=>{return d8(Z,$,A),A}],["Cast",(Z,$,A)=>v4(Z,$,A)],["Clean",(Z,$,A)=>h8(Z,$,A)],["Clone",(Z,$,A)=>M0(A)],["Convert",(Z,$,A)=>i8(Z,$,A)],["Decode",(Z,$,A)=>l1(Z,$)?H4(Z,$,A):A],["Default",(Z,$,A)=>y8(Z,$,A)],["Encode",(Z,$,A)=>l1(Z,$)?_4(Z,$,A):A]]);function U(Z){w.delete(Z)}z.Delete=U;function W(Z,$){w.set(Z,$)}z.Set=W;function X(Z){return w.get(Z)}z.Get=X})(cz||(cz={}));var BU=["Clone","Clean","Default","Convert","Assert","Decode"];function XL(z,w,U,W){return z.reduce((X,Z)=>{let $=cz.Get(Z);if(k0($))throw new iz(`Unable to find Parse operation '${Z}'`);return $(w,U,X)},W)}function MU(...z){let[w,U,W,X]=z.length===4?[z[0],z[1],z[2],z[3]]:z.length===3?m(z[0])?[z[0],z[1],[],z[2]]:[BU,z[0],z[1],z[2]]:z.length===2?[BU,z[0],[],z[1]]:(()=>{throw new iz("Invalid Arguments")})();return XL(w,U,W,X)}var o={};j6(o,{ValueErrorIterator:()=>h6,Patch:()=>AU,Parse:()=>MU,Mutate:()=>JU,Hash:()=>G6,Errors:()=>k1,Equal:()=>i6,Encode:()=>QU,Edit:()=>WU,Diff:()=>$U,Default:()=>y8,Decode:()=>zU,Create:()=>r2,Convert:()=>i8,Clone:()=>M0,Clean:()=>h8,Check:()=>s,Cast:()=>v4,Assert:()=>d8});var w5=OX(NU(),1);var az={date:cU,time:pz(!0),"date-time":HU(!0),"iso-time":pz(!1),"iso-date-time":HU(!1),duration:/^P(?!$)((\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+S)?)?|(\d+W)?)$/,uri:CL,"uri-reference":/^(?:[a-z][a-z0-9+\-.]*:)?(?:\/?\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:]|%[0-9a-f]{2})*@)?(?:\[(?:(?:(?:(?:[0-9a-f]{1,4}:){6}|::(?:[0-9a-f]{1,4}:){5}|(?:[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){4}|(?:(?:[0-9a-f]{1,4}:){0,1}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){3}|(?:(?:[0-9a-f]{1,4}:){0,2}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){2}|(?:(?:[0-9a-f]{1,4}:){0,3}[0-9a-f]{1,4})?::[0-9a-f]{1,4}:|(?:(?:[0-9a-f]{1,4}:){0,4}[0-9a-f]{1,4})?::)(?:[0-9a-f]{1,4}:[0-9a-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?))|(?:(?:[0-9a-f]{1,4}:){0,5}[0-9a-f]{1,4})?::[0-9a-f]{1,4}|(?:(?:[0-9a-f]{1,4}:){0,6}[0-9a-f]{1,4})?::)|[Vv][0-9a-f]+\.[a-z0-9\-._~!$&'()*+,;=:]+)\]|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)|(?:[a-z0-9\-._~!$&'"()*+,;=]|%[0-9a-f]{2})*)(?::\d*)?(?:\/(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})*)*|\/(?:(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})*)*)?|(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})*)*)?(?:\?(?:[a-z0-9\-._~!$&'"()*+,;=:@/?]|%[0-9a-f]{2})*)?(?:#(?:[a-z0-9\-._~!$&'"()*+,;=:@/?]|%[0-9a-f]{2})*)?$/i,"uri-template":/^(?:(?:[^\x00-\x20"'<>%\\^`{|}]|%[0-9a-f]{2})|\{[+#./;?&=,!@|]?(?:[a-z0-9_]|%[0-9a-f]{2})+(?::[1-9][0-9]{0,3}|\*)?(?:,(?:[a-z0-9_]|%[0-9a-f]{2})+(?::[1-9][0-9]{0,3}|\*)?)*\})*$/i,url:/^(?:https?|ftp):\/\/(?:\S+(?::\S*)?@)?(?:(?!(?:10|127)(?:\.\d{1,3}){3})(?!(?:169\.254|192\.168)(?:\.\d{1,3}){2})(?!172\.(?:1[6-9]|2\d|3[0-1])(?:\.\d{1,3}){2})(?:[1-9]\d?|1\d\d|2[01]\d|22[0-3])(?:\.(?:1?\d{1,2}|2[0-4]\d|25[0-5])){2}(?:\.(?:[1-9]\d?|1\d\d|2[0-4]\d|25[0-4]))|(?:(?:[a-z0-9\u{00a1}-\u{ffff}]+-)*[a-z0-9\u{00a1}-\u{ffff}]+)(?:\.(?:[a-z0-9\u{00a1}-\u{ffff}]+-)*[a-z0-9\u{00a1}-\u{ffff}]+)*(?:\.(?:[a-z\u{00a1}-\u{ffff}]{2,})))(?::\d{2,5})?(?:\/[^\s]*)?$/iu,email:/^[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$/i,hostname:/^(?=.{1,253}\.?$)[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?(?:\.[a-z0-9](?:[-0-9a-z]{0,61}[0-9a-z])?)*\.?$/i,ipv4:/^(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)$/,ipv6:/^((([0-9a-f]{1,4}:){7}([0-9a-f]{1,4}|:))|(([0-9a-f]{1,4}:){6}(:[0-9a-f]{1,4}|((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9a-f]{1,4}:){5}(((:[0-9a-f]{1,4}){1,2})|:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9a-f]{1,4}:){4}(((:[0-9a-f]{1,4}){1,3})|((:[0-9a-f]{1,4})?:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){3}(((:[0-9a-f]{1,4}){1,4})|((:[0-9a-f]{1,4}){0,2}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){2}(((:[0-9a-f]{1,4}){1,5})|((:[0-9a-f]{1,4}){0,3}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){1}(((:[0-9a-f]{1,4}){1,6})|((:[0-9a-f]{1,4}){0,4}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(:(((:[0-9a-f]{1,4}){1,7})|((:[0-9a-f]{1,4}){0,5}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:)))$/i,regex:xL,uuid:/^(?:urn:uuid:)?[0-9a-f]{8}-(?:[0-9a-f]{4}-){3}[0-9a-f]{12}$/i,"json-pointer":/^(?:\/(?:[^~/]|~0|~1)*)*$/,"json-pointer-uri-fragment":/^#(?:\/(?:[a-z0-9_\-.!$&'()*+,;:=@]|%[0-9a-f]{2}|~0|~1)*)*$/i,"relative-json-pointer":/^(?:0|[1-9][0-9]*)(?:#|(?:\/(?:[^~/]|~0|~1)*)*)$/,byte:bL,int32:{type:"number",validate:FL},int64:{type:"number",validate:EL},float:{type:"number",validate:SU},double:{type:"number",validate:SU},password:!0,binary:!0};function HL(z){return z%4===0&&(z%100!==0||z%400===0)}var _L=/^(\d\d\d\d)-(\d\d)-(\d\d)$/,SL=[0,31,28,31,30,31,30,31,31,30,31,30,31];function cU(z){let w=_L.exec(z);if(!w)return!1;let U=+w[1],W=+w[2],X=+w[3];return W>=1&&W<=12&&X>=1&&X<=(W===2&&HL(U)?29:SL[W])}var DL=/^(\d\d):(\d\d):(\d\d(?:\.\d+)?)(z|([+-])(\d\d)(?::?(\d\d))?)?$/i;function pz(z){return function w(U){let W=DL.exec(U);if(!W)return!1;let X=+W[1],Z=+W[2],$=+W[3],A=W[4],Q=W[5]==="-"?-1:1,Y=+(W[6]||0),J=+(W[7]||0);if(Y>23||J>59||z&&!A)return!1;if(X<=23&&Z<=59&&$<60)return!0;let G=Z-J*Q,S=X-Y*Q-(G<0?1:0);return(S===23||S===-1)&&(G===59||G===-1)&&$<61}}var PL=/t|\s/i;function HU(z){let w=pz(z);return function U(W){let X=W.split(PL);return X.length===2&&cU(X[0])&&w(X[1])}}var OL=/\/|:/,RL=/^(?:[a-z][a-z0-9+\-.]*:)(?:\/?\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:]|%[0-9a-f]{2})*@)?(?:\[(?:(?:(?:(?:[0-9a-f]{1,4}:){6}|::(?:[0-9a-f]{1,4}:){5}|(?:[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){4}|(?:(?:[0-9a-f]{1,4}:){0,1}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){3}|(?:(?:[0-9a-f]{1,4}:){0,2}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){2}|(?:(?:[0-9a-f]{1,4}:){0,3}[0-9a-f]{1,4})?::[0-9a-f]{1,4}:|(?:(?:[0-9a-f]{1,4}:){0,4}[0-9a-f]{1,4})?::)(?:[0-9a-f]{1,4}:[0-9a-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?))|(?:(?:[0-9a-f]{1,4}:){0,5}[0-9a-f]{1,4})?::[0-9a-f]{1,4}|(?:(?:[0-9a-f]{1,4}:){0,6}[0-9a-f]{1,4})?::)|[Vv][0-9a-f]+\.[a-z0-9\-._~!$&'()*+,;=:]+)\]|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)|(?:[a-z0-9\-._~!$&'()*+,;=]|%[0-9a-f]{2})*)(?::\d*)?(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*|\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*)?|(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*)(?:\?(?:[a-z0-9\-._~!$&'()*+,;=:@/?]|%[0-9a-f]{2})*)?(?:#(?:[a-z0-9\-._~!$&'()*+,;=:@/?]|%[0-9a-f]{2})*)?$/i;function CL(z){return OL.test(z)&&RL.test(z)}var _U=/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/gm;function bL(z){return _U.lastIndex=0,_U.test(z)}var KL=-2147483648,jL=2147483647;function FL(z){return Number.isInteger(z)&&z<=jL&&z>=KL}function EL(z){return Number.isInteger(z)}function SU(){return!0}var IL=/[^\\]\\Z/;function xL(z){if(IL.test(z))return!1;try{return new RegExp(z),!0}catch(w){return!1}}var p8="toJSON"in new Headers,DU=(z,w)=>{let U=new URL(z);return U.pathname=w,U.toString()},VL=(z)=>typeof z==="function"&&/^\s*class\s+/.test(z.toString())||z.toString&&z.toString().startsWith("[object ")&&z.toString()!=="[object Object]"||z1(Object.getPrototypeOf(z)),yz=(z)=>z&&typeof z==="object"&&!Array.isArray(z),j2=(z,w,{skipKeys:U,override:W=!0}={})=>{if(!yz(z)||!yz(w))return z;for(let[X,Z]of Object.entries(w)){if(U?.includes(X))continue;if(!yz(Z)||!(X in z)||VL(Z)){if(W||!(X in z))z[X]=Z;continue}z[X]=j2(z[X],Z,{skipKeys:U,override:W})}return z},kL=(z,w)=>{let U=j2(Object.assign({},z),w,{skipKeys:["properties"]});if("properties"in U)delete U.properties;return U},y0=(z=[],w=[])=>{if(!z)return;if(!w)return z;let U=[],W=[];if(!Array.isArray(z))z=[z];if(!Array.isArray(w))w=[w];for(let X of z)if(U.push(X),X.checksum)W.push(X.checksum);for(let X of w)if(!W.includes(X.checksum))U.push(X);return U},TL=["start","request","parse","transform","resolve","beforeHandle","afterHandle","mapResponse","afterResponse","trace","error","stop","body","headers","params","query","response","type","detail"],gL=TL.reduce((z,w)=>(z[w]=!0,z),{}),iU=(z,w)=>{let U=(W)=>typeof W==="object"&&Object.keys(W).every(ez);if(U(z)&&U(w))return Object.assign(z,w);else if(z&&!U(z)&&U(w))return Object.assign({200:z},w);return w??z},t4=(z,w)=>{return{body:w?.body??z?.body,headers:w?.headers??z?.headers,params:w?.params??z?.params,query:w?.query??z?.query,cookie:w?.cookie??z?.cookie,response:iU(z?.response,w?.response)}},a1=(z,w)=>{let{resolve:U,...W}=z??{},{resolve:X,...Z}=w??{};return{...W,...Z,body:w?.body??z?.body,headers:w?.headers??z?.headers,params:w?.params??z?.params,query:w?.query??z?.query,cookie:w?.cookie??z?.cookie,response:iU(z?.response,w?.response),type:z?.type||w?.type,detail:j2(w?.detail??{},z?.detail??{}),parse:y0(z?.parse,w?.parse),transform:y0(z?.transform,w?.transform),beforeHandle:y0(y0(W2(U,"resolve"),z?.beforeHandle),y0(W2(X,"resolve"),w?.beforeHandle)),afterHandle:y0(z?.afterHandle,w?.afterHandle),mapResponse:y0(z?.mapResponse,w?.mapResponse),afterResponse:y0(z?.afterResponse,w?.afterResponse),trace:y0(z?.trace,w?.trace),error:y0(z?.error,w?.error)}},lz=(z,w,U=!0)=>{if(!Array.isArray(w))return w.original=z,A2(z,w,U);for(let W of w)W.original=z,z=A2(z,W,U);return z},A2=(z,w,U=!0)=>{if(!z)return z;if(w.untilObjectFound&&!U&&z.type==="object")return z;let W=w.from[H];if(z.oneOf){for(let $=0;$<z.oneOf.length;$++)z.oneOf[$]=A2(z.oneOf[$],w,U);return z}if(z.anyOf){for(let $=0;$<z.anyOf.length;$++)z.anyOf[$]=A2(z.anyOf[$],w,U);return z}if(z.allOf){for(let $=0;$<z.allOf.length;$++)z.allOf[$]=A2(z.allOf[$],w,U);return z}if(z.not)return A2(z.not,w,U);let X=U&&!!w.excludeRoot;if(z[H]===W){let{anyOf:$,oneOf:A,allOf:Q,not:Y,properties:J,items:G,...S}=z,N=w.to(S);if(!N)return z;let O,M=(C)=>{if(J&&C.type==="object"){let L0={};for(let[a,$0]of Object.entries(J))L0[a]=A2($0,w,!1);return{...S,...C,properties:L0}}if(G&&C.type==="array")return{...S,...C,items:A2(G,w,!1)};let g={...S,...C};if(delete g.required,J&&C.type==="string"&&C.format==="ObjectString"&&C.default==="{}")O=E.ObjectString(J,S),g.default=JSON.stringify(o.Create(E.Object(J))),g.properties=J;if(G&&C.type==="string"&&C.format==="ArrayString"&&C.default==="[]")O=E.ArrayString(G,S),g.default=JSON.stringify(o.Create(E.Array(G))),g.items=G;return g};if(X){if(J){let C={};for(let[g,L0]of Object.entries(J))C[g]=A2(L0,w,!1);return{...S,properties:C}}else if(G?.map)return{...S,items:G.map((C)=>A2(C,w,!1))};return S}if(N.anyOf)for(let C=0;C<N.anyOf.length;C++)N.anyOf[C]=M(N.anyOf[C]);else if(N.oneOf)for(let C=0;C<N.oneOf.length;C++)N.oneOf[C]=M(N.oneOf[C]);else if(N.allOf)for(let C=0;C<N.allOf.length;C++)N.allOf[C]=M(N.allOf[C]);else if(N.not)N.not=M(N.not);if(O)N[F0]=O[F0];if(N.anyOf||N.oneOf||N.allOf||N.not)return N;if(J){let C={};for(let[g,L0]of Object.entries(J))C[g]=A2(L0,w,!1);return{...S,...N,properties:C}}else if(G?.map)return{...S,...N,items:G.map((C)=>A2(C,w,!1))};return{...S,...N}}let Z=z?.properties;if(Z&&U&&w.rootOnly!==!0)for(let[$,A]of Object.entries(Z))switch(A[H]){case W:let{anyOf:Q,oneOf:Y,allOf:J,not:G,type:S,...N}=A,O=w.to(N);if(!O)return z;if(O.anyOf)for(let M=0;M<O.anyOf.length;M++)O.anyOf[M]={...N,...O.anyOf[M]};else if(O.oneOf)for(let M=0;M<O.oneOf.length;M++)O.oneOf[M]={...N,...O.oneOf[M]};else if(O.allOf)for(let M=0;M<O.allOf.length;M++)O.allOf[M]={...N,...O.allOf[M]};else if(O.not)O.not={...N,...O.not};Z[$]={...N,...A2(N,w,!1)};break;case"Object":case"Union":Z[$]=A2(A,w,!1);break;default:if(Array.isArray(A.items))for(let M=0;M<A.items.length;M++)A.items[M]=A2(A.items[M],w,!1);else if(A.anyOf||A.oneOf||A.allOf||A.not)Z[$]=A2(A,w,!1);else if(A.type==="array")A.items=A2(A.items,w,!1);break}return z},s4=(z)=>(w)=>{if(typeof w==="object")try{return o.Clean(z,structuredClone(w))}catch{try{return o.Clean(z,w)}catch{return w}}return w},F2=(z,{models:w={},dynamic:U=!1,modules:W,normalize:X=!1,additionalProperties:Z=!1,coerce:$=!1,additionalCoerce:A=[]}={modules:E.Module({})})=>{if(!z)return;let Q;if(typeof z!=="string")Q=z;else{let J=z.endsWith("[]"),G=J?z.substring(0,z.length-2):z;if(Q=W.Import(G)??w[G],J)Q=E.Array(Q)}if(!Q)return;if($||A)if($)Q=lz(Q,[{from:E.Ref(""),to:(J)=>W.Import(J.$ref)},{from:E.Number(),to:(J)=>E.Numeric(J),untilObjectFound:!0},{from:E.Boolean(),to:(J)=>E.BooleanString(J),untilObjectFound:!0},...Array.isArray(A)?A:[A]]);else Q=lz(Q,[{from:E.Ref(""),to:(J)=>W.Import(J.$ref)},...Array.isArray(A)?A:[A]]);if(Q.type==="object"&&"additionalProperties"in Q===!1)Q.additionalProperties=Z;if(U){let J={schema:Q,references:"",checkFunc:()=>{},code:"",Check:(G)=>o.Check(Q,G),Errors:(G)=>o.Errors(Q,G),Code:()=>"",Clean:s4(Q),Decode:(G)=>o.Decode(Q,G),Encode:(G)=>o.Encode(Q,G)};if(X&&Q.additionalProperties===!1)J.Clean=s4(Q);if(Q.config){if(J.config=Q.config,J?.schema?.config)delete J.schema.config}return J.parse=(G)=>{try{return J.Decode(G)}catch(S){throw[...J.Errors(G)].map(C1)}},J.safeParse=(G)=>{try{return{success:!0,data:J.Decode(G),error:null}}catch(S){let N=[...Y.Errors(G)].map(C1);return{success:!1,data:null,error:N[0]?.summary,errors:N}}},J}let Y=N6.Compile(Q,Object.values(w));if(Y.Clean=s4(Q),Q.config){if(Y.config=Q.config,Y?.schema?.config)delete Y.schema.config}return Y.parse=(J)=>{try{return Y.Decode(J)}catch(G){throw[...Y.Errors(J)].map(C1)}},Y.safeParse=(J)=>{try{return{success:!0,data:Y.Decode(J),error:null}}catch(G){let S=[...Y.Errors(J)].map(C1);return{success:!1,data:null,error:S[0]?.summary,errors:S}}},Y},PU=(z,{models:w={},modules:U,dynamic:W=!1,normalize:X=!1,additionalProperties:Z=!1})=>{if(!z)return;let $;if(typeof z!=="string")$=z;else{let J=z.endsWith("[]"),G=J?z.substring(0,z.length-2):z;if($=U.Import(G)??w[G],J)$=E.Array($)}if(!$)return;let A=(J,G)=>{if(W)return{schema:J,references:"",checkFunc:()=>{},code:"",Check:(N)=>o.Check(J,N),Errors:(N)=>o.Errors(J,N),Code:()=>"",Clean:s4(J),Decode:(N)=>o.Decode(J,N),Encode:(N)=>o.Encode(J,N)};let S=N6.Compile(J,G);if(X&&J.additionalProperties===!1)S.Clean=s4(J);return S},Q=Object.values(w);if(H in $){if("additionalProperties"in $===!1)$.additionalProperties=Z;return{200:A($,Q)}}let Y={};return Object.keys($).forEach((J)=>{let G=$[+J];if(typeof G==="string"){if(G in w){let S=w[G];S.type==="object"&&"additionalProperties"in S,Y[+J]=H in S?A(S,Q):S}return}if(G.type==="object"&&"additionalProperties"in G===!1)G.additionalProperties=Z;Y[+J]=H in G?A(G,Q):G}),Y},fL=typeof Bun!=="undefined",dL=fL&&typeof Bun.hash==="function",o4=(z)=>{if(dL)return Bun.hash(z);let w=9;for(let U=0;U<z.length;)w=Math.imul(w^z.charCodeAt(U++),387420489);return w=w^w>>>9},vz,y6=()=>{if(!vz)vz=[{from:E.Object({}),to:()=>E.ObjectString({}),excludeRoot:!0},{from:E.Array(E.Any()),to:()=>E.ArrayString(E.Any())}];return vz},nz,OU=()=>{if(!nz)nz=[{from:E.Number(),to:(z)=>E.Numeric(z),rootOnly:!0},{from:E.Boolean(),to:(z)=>E.BooleanString(z),rootOnly:!0}];return nz},yU=({validator:z,modules:w,defaultConfig:U={},config:W,dynamic:X,models:Z})=>{let $=F2(z,{modules:w,dynamic:X,models:Z,additionalProperties:!0,coerce:!0,additionalCoerce:y6()});if(z1(U))if($)$.config=kL($.config,W);else $=F2(E.Cookie({}),{modules:w,dynamic:X,models:Z,additionalProperties:!0}),$.config=U;return $},P1=(z,w)=>{if(!w)return;if(!Array.isArray(w)){let W=w;if(z&&!W.checksum)W.checksum=z;if(W.scope==="scoped")W.scope="local";return W}let U=[...w];for(let W of U){if(z&&!W.checksum)W.checksum=z;if(W.scope==="scoped")W.scope="local"}return U},RU=(z,w,U)=>{return{start:y0(z.start,P1(U,w?.start)),request:y0(z.request,P1(U,w?.request)),parse:y0(z.parse,P1(U,w?.parse)),transform:y0(z.transform,P1(U,w?.transform)),beforeHandle:y0(y0(W2(z.resolve,"resolve"),z.beforeHandle),P1(U,y0(W2(w?.resolve,"resolve"),w?.beforeHandle))),afterHandle:y0(z.afterHandle,P1(U,w?.afterHandle)),mapResponse:y0(z.mapResponse,P1(U,w?.mapResponse)),afterResponse:y0(z.afterResponse,P1(U,w?.afterResponse)),trace:y0(z.trace,P1(U,w?.trace)),error:y0(z.error,P1(U,w?.error)),stop:y0(z.stop,P1(U,w?.stop))}},hL=(z,w,{skipIfHasType:U=!1}={})=>{if(!z)return z;if(!Array.isArray(z)){if(U)z.scope??=w;else z.scope=w;return z}for(let W of z)if(U)W.scope??=w;else W.scope=w;return z},H6=(z)=>{if(!z)return z;if(!Array.isArray(z))switch(z.scope){case"global":case"scoped":return{...z};default:return{fn:z}}let w=[];for(let U of z)switch(U.scope){case"global":case"scoped":w.push({...U});break}return w},CU=(z)=>{return{...z,type:z?.type,detail:z?.detail,parse:H6(z?.parse),transform:H6(z?.transform),beforeHandle:H6(z?.beforeHandle),afterHandle:H6(z?.afterHandle),mapResponse:H6(z?.mapResponse),afterResponse:H6(z?.afterResponse),error:H6(z?.error),trace:H6(z?.trace)}},e8={Continue:100,"Switching Protocols":101,Processing:102,"Early Hints":103,OK:200,Created:201,Accepted:202,"Non-Authoritative Information":203,"No Content":204,"Reset Content":205,"Partial Content":206,"Multi-Status":207,"Already Reported":208,"Multiple Choices":300,"Moved Permanently":301,Found:302,"See Other":303,"Not Modified":304,"Temporary Redirect":307,"Permanent Redirect":308,"Bad Request":400,Unauthorized:401,"Payment Required":402,Forbidden:403,"Not Found":404,"Method Not Allowed":405,"Not Acceptable":406,"Proxy Authentication Required":407,"Request Timeout":408,Conflict:409,Gone:410,"Length Required":411,"Precondition Failed":412,"Payload Too Large":413,"URI Too Long":414,"Unsupported Media Type":415,"Range Not Satisfiable":416,"Expectation Failed":417,"I'm a teapot":418,"Misdirected Request":421,"Unprocessable Content":422,Locked:423,"Failed Dependency":424,"Too Early":425,"Upgrade Required":426,"Precondition Required":428,"Too Many Requests":429,"Request Header Fields Too Large":431,"Unavailable For Legal Reasons":451,"Internal Server Error":500,"Not Implemented":501,"Bad Gateway":502,"Service Unavailable":503,"Gateway Timeout":504,"HTTP Version Not Supported":505,"Variant Also Negotiates":506,"Insufficient Storage":507,"Loop Detected":508,"Not Extended":510,"Network Authentication Required":511},bU=Object.fromEntries(Object.entries(e8).map(([z,w])=>[w,z]));function cL(z){let w=z;while(w.endsWith("="))w=w.slice(0,-1);return w}var KU=new TextEncoder,l8=async(z,w)=>{if(typeof z!=="string")throw new TypeError("Cookie value must be provided as a string.");if(w===null)throw new TypeError("Secret key must be provided.");let U=await crypto.subtle.importKey("raw",KU.encode(w),{name:"HMAC",hash:"SHA-256"},!1,["sign"]),W=await crypto.subtle.sign("HMAC",U,KU.encode(z));return z+"."+cL(Buffer.from(W).toString("base64"))},jU=async(z,w)=>{if(typeof z!=="string")throw new TypeError("Signed cookie string must be provided.");if(w===null)throw new TypeError("Secret key must be provided.");let U=z.slice(0,z.lastIndexOf("."));return await l8(U,w)===z?U:!1},iL=(z,w,U)=>{if(!z||typeof z!=="object"||!w)return;for(let[W,X]of Object.entries(w)){if(W in gL||!(W in z))continue;let Z=z[W];if(typeof Z==="function"){let $=Z(X);if(typeof $==="object")for(let[A,Q]of Object.entries($))U(A)({fn:Q})}delete w[W]}},yL=({globalHook:z,localHook:w})=>(U)=>(W,X)=>{if(typeof W==="function")W={fn:W};if(U==="resolve")W={...W,subType:"resolve"};if("fn"in W||Array.isArray(W)){if(!w[U])w[U]=[];if(typeof w[U]==="function")w[U]=[w[U]];if(Array.isArray(W))w[U]=w[U].concat(W);else w[U].push(W);return}let{insert:Z="after",stack:$="local"}=W;if(typeof X==="function")X={fn:X};if($==="global")if(!Array.isArray(X))if(Z==="before")z[U].unshift(X);else z[U].push(X);else if(Z==="before")z[U]=X.concat(z[U]);else z[U]=z[U].concat(X);else{if(!w[U])w[U]=[];if(typeof w[U]==="function")w[U]=[w[U]];if(!Array.isArray(X))if(Z==="before")w[U].unshift(X);else w[U].push(X);else if(Z==="before")w[U]=X.concat(w[U]);else w[U]=w[U].concat(X)}},vL=(z)=>{if(typeof z==="number")return z;if(z.length<16){if(z.trim().length===0)return null;let w=Number(z);if(Number.isNaN(w))return null;return w}if(z.length===16){if(z.trim().length===0)return null;let w=Number(z);if(Number.isNaN(w)||w.toString()!==z)return null;return w}return null},ez=(z)=>vL(z)!==null;class vU{onError;root=null;promises=[];constructor(z=console.error){this.onError=z}get size(){return this.promises.length}add(z){return this.promises.push(z),this.root||=this.drain(),z}async drain(){while(this.promises.length>0){try{await this.promises[0]}catch(z){this.onError(z)}this.promises.shift()}this.root=null}then(z,w){return(this.root??Promise.resolve()).then(z,w)}}var W2=(z,w)=>{if(!z)return z;if(!Array.isArray(z)){if(typeof z==="function"||typeof z==="string")return w?{fn:z,subType:w}:{fn:z};else if("fn"in z)return z}let U=[];for(let W of z)if(typeof W==="function"||typeof W==="string")U.push(w?{fn:W,subType:w}:{fn:W});else if("fn"in W)U.push(W);return U},nL=(z)=>{return{...z,start:W2(z?.start),request:W2(z?.request),parse:W2(z?.parse),transform:W2(z?.transform),beforeHandle:W2(z?.beforeHandle),afterHandle:W2(z?.afterHandle),mapResponse:W2(z?.mapResponse),afterResponse:W2(z?.afterResponse),trace:W2(z?.trace),error:W2(z?.error),stop:W2(z?.stop)}},FU=(z)=>{let w={};if(z.start?.map)w.start=z.start.map((U)=>U.fn);if(z.request?.map)w.request=z.request.map((U)=>U.fn);if(z.parse?.map)w.parse=z.parse.map((U)=>U.fn);if(z.transform?.map)w.transform=z.transform.map((U)=>U.fn);if(z.beforeHandle?.map)w.beforeHandle=z.beforeHandle.map((U)=>U.fn);if(z.afterHandle?.map)w.afterHandle=z.afterHandle.map((U)=>U.fn);if(z.mapResponse?.map)w.mapResponse=z.mapResponse.map((U)=>U.fn);if(z.afterResponse?.map)w.afterResponse=z.afterResponse.map((U)=>U.fn);if(z.trace?.map)w.trace=z.trace.map((U)=>U.fn);if(z.error?.map)w.error=z.error.map((U)=>U.fn);if(z.stop?.map)w.stop=z.stop.map((U)=>U.fn);return w},uz=(z)=>({body:z.body,cookie:z.cookie,headers:z.headers,query:z.query,set:z.set,server:z.server,request:z.request,route:z.route}),nU=(z,w=302)=>Response.redirect(z,w),AI=Symbol("ElysiaFormData"),z5=Symbol("ElysiaRequestId");var uU=()=>{let z=crypto.randomUUID();return z.slice(0,8)+z.slice(24,32)},EU=(z)=>{let w=[];for(let U=0;U<z.length;U++){let W=z[U];if(W.checksum){if(w.includes(W.checksum))z.splice(U,1),U--;w.push(W.checksum)}}return z},L2=(z,w="scoped")=>{if(!z)return;if(w==="scoped"){for(let U of z)if("scope"in U&&U.scope==="local")U.scope="scoped";return}for(let U of z)if("scope"in U)U.scope="global"},S4=(z)=>{if(z.charCodeAt(z.length-1)===47)return z.slice(0,z.length-1);return z+"/"},z1=(z)=>{if(!z)return!1;for(let w in z)return!0;return!1},O1=(z)=>{if(Array.isArray(z))return z.length===0;return!z},mz=(z)=>{let w={...z};if(O1(z.afterHandle))delete w.afterHandle;if(O1(z.afterResponse))delete w.afterResponse;if(O1(z.beforeHandle))delete w.beforeHandle;if(O1(z.error))delete w.error;if(O1(z.mapResponse))delete w.mapResponse;if(O1(z.parse))delete w.parse;if(O1(z.request))delete w.request;if(O1(z.start))delete w.start;if(O1(z.stop))delete w.stop;if(O1(z.trace))delete w.trace;if(O1(z.transform))delete w.transform;if(!w.type)delete w.type;if(w.detail&&!Object.keys(w.detail).length)delete w.detail;if(!w.body)delete w.body;if(!w.cookie)delete w.cookie;if(!w.headers)delete w.headers;if(!w.query)delete w.query;if(!w.params)delete w.params;if(!w.response)delete w.response;return w},p4=(z,{dynamic:w=!1}={})=>{let U=encodeURIComponent(z).replace(/%2F/g,"/");if(w)U=U.replace(/%3A/g,":").replace(/%3F/g,"?");return U},IU=typeof Bun!=="undefined"?Bun.env:typeof process!=="undefined"?process?.env:void 0,s8=Symbol("ElysiaErrorCode"),r8=(IU?.NODE_ENV??IU?.ENV)==="production";class b1{code;response;constructor(z,w){let U=w??(z in bU?bU[z]:z);this.code=e8[z]??z,this.response=U}}var mU=(z,w)=>new b1(z,w);class tU extends Error{code="INTERNAL_SERVER_ERROR";status=500;constructor(z){super(z??"INTERNAL_SERVER_ERROR")}}class zw extends Error{code="NOT_FOUND";status=404;constructor(z){super(z??"NOT_FOUND")}}class oU extends Error{code="PARSE";status=400;constructor(){super("Bad Request")}}class sz extends Error{key;code="INVALID_COOKIE_SIGNATURE";status=400;constructor(z,w){super(w??`"${z}" has invalid cookie signature`);this.key=z}}var C1=(z)=>{if(!z)return{summary:void 0};let{message:w,path:U,value:W,type:X}=z,Z=U.slice(1).replaceAll("/","."),$=U==="";switch(X){case 42:return{...z,summary:$?"Value should not be provided":`Property '${Z}' should not be provided`};case 45:return{...z,summary:$?"Value is missing":`Property '${Z}' is missing`};case 50:let A=w.indexOf("'"),Q=w.slice(A+1,w.indexOf("'",A+1));return{...z,summary:$?"Value should be an email":`Property '${Z}' should be ${Q}`};case 54:return{...z,summary:`${w.slice(0,9)} property '${Z}' to be ${w.slice(8)} but found: ${W}`};case 62:let Y=z.schema.anyOf.map((J)=>`'${J?.format??J.type}'`).join(", ");return{...z,summary:$?`Value should be one of ${Y}`:`Property '${Z}' should be one of: ${Y}`};default:return{summary:w,...z}}};class r extends Error{type;validator;value;code="VALIDATION";status=422;constructor(z,w,U){if(U&&typeof U==="object"&&U instanceof b1)U=U.response;let W=r8?void 0:("Errors"in w)?w.Errors(U).First():o.Errors(w,U).First(),X=W?.schema?.message||W?.schema?.error!==void 0?typeof W.schema.error==="function"?W.schema.error({type:z,validator:w,value:U,get errors(){return[...w.Errors(U)].map(C1)}}):W.schema.error:void 0,Z=W?.path||"root",$="";if(X!==void 0)$=typeof X==="object"?JSON.stringify(X):X+"";else if(r8)$=JSON.stringify({type:"validation",on:z,summary:C1(W).summary,message:W?.message,found:U});else{let A=w?.schema??w,Q="Errors"in w?[...w.Errors(U)].map(C1):[...o.Errors(w,U)].map(C1),Y;try{Y=o.Create(A)}catch(J){Y={type:"Could not create expected value",message:J?.message,error:J}}$=JSON.stringify({type:"validation",on:z,summary:C1(W).summary,property:Z,message:W?.message,expected:Y,found:U,errors:Q},null,2)}super($);this.type=z,this.validator=w,this.value=U,Object.setPrototypeOf(this,r.prototype)}get all(){return"Errors"in this.validator?[...this.validator.Errors(this.value)].map(C1):[...o.Errors(this.validator,this.value)].map(C1)}static simplifyModel(z){let w="schema"in z?z.schema:z;try{return o.Create(w)}catch{return w}}get model(){return r.simplifyModel(this.validator)}toResponse(z){return new Response(this.message,{status:400,headers:{...z,"content-type":"application/json"}})}}var pU=/(\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d:[0-5]\d\.\d+([+-][0-2]\d:[0-5]\d|Z))|(\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d:[0-5]\d([+-][0-2]\d:[0-5]\d|Z))|(\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d([+-][0-2]\d:[0-5]\d|Z))/,lU=/(?:Sun|Mon|Tue|Wed|Thu|Fri|Sat)\s(?:Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)\s\d{2}\s\d{4}\s\d{2}:\d{2}:\d{2}\sGMT(?:\+|-)\d{4}\s\([^)]+\)/,sU=/^(?:(?:(?:(?:0?[1-9]|[12][0-9]|3[01])[/\s-](?:0?[1-9]|1[0-2])[/\s-](?:19|20)\d{2})|(?:(?:19|20)\d{2}[/\s-](?:0?[1-9]|1[0-2])[/\s-](?:0?[1-9]|[12][0-9]|3[01]))))(?:\s(?:1[012]|0?[1-9]):[0-5][0-9](?::[0-5][0-9])?(?:\s[AP]M)?)?$/,uL=az.date,mL=az["date-time"];if(!D0.Has("date"))D0.Set("date",(z)=>{let w=z.replace(/"/g,"");if(pU.test(w)||lU.test(w)||sU.test(w)||uL(w)){let U=new Date(w);if(!Number.isNaN(U.getTime()))return!0}return!1});if(!D0.Has("date-time"))D0.Set("date-time",(z)=>{let w=z.replace(/"/g,"");if(pU.test(w)||lU.test(w)||sU.test(w)||mL(w)){let U=new Date(w);if(!Number.isNaN(U.getTime()))return!0}return!1});Object.entries(az).forEach((z)=>{let[w,U]=z;if(!D0.Has(w)){if(U instanceof RegExp)D0.Set(w,(W)=>U.test(W));else if(typeof U==="function")D0.Set(w,U)}});var E=Object.assign({},L6),xU=(z)=>{if(typeof z==="string")switch(z.slice(-1)){case"k":return+z.slice(0,z.length-1)*1024;case"m":return+z.slice(0,z.length-1)*1048576;default:return+z}return z},VU=(z,w)=>{if(z.startsWith(w))return!0;return w.charCodeAt(w.length-1)===42&&w.charCodeAt(w.length-2)===47&&z.startsWith(w.slice(0,-1))},rz=(z,w)=>{if(!(w instanceof Blob))return!1;if(z.minSize&&w.size<xU(z.minSize))return!1;if(z.maxSize&&w.size>xU(z.maxSize))return!1;if(z.extension){if(typeof z.extension==="string")return VU(w.type,z.extension);for(let U=0;U<z.extension.length;U++)if(VU(w.type,z.extension[U]))return!0;return!1}return!0},tL=rU("File",rz),oL=rU("Files",(z,w)=>{if(!Array.isArray(w))return rz(z,w);if(z.minItems&&w.length<z.minItems)return!1;if(z.maxItems&&w.length>z.maxItems)return!1;for(let U=0;U<w.length;U++)if(!rz(z,w[U]))return!1;return!0});if(!D0.Has("numeric"))D0.Set("numeric",(z)=>!!z&&!isNaN(+z));if(!D0.Has("integer"))D0.Set("integer",(z)=>!!z&&Number.isInteger(+z));if(!D0.Has("boolean"))D0.Set("boolean",(z)=>z==="true"||z==="false");if(!D0.Has("ObjectString"))D0.Set("ObjectString",(z)=>{let w=z.charCodeAt(0);if(w===9||w===10||w===32)w=z.trimStart().charCodeAt(0);if(w!==123&&w!==91)return!1;try{return JSON.parse(z),!0}catch{return!1}});if(!D0.Has("ArrayString"))D0.Set("ArrayString",(z)=>{let w=z.charCodeAt(0);if(w===9||w===10||w===32)w=z.trimStart().charCodeAt(0);if(w!==123&&w!==91)return!1;try{return JSON.parse(z),!0}catch{return!1}});if(!p0.Has("UnionEnum"))p0.Set("UnionEnum",(z,w)=>{return(typeof w==="number"||typeof w==="string"||w===null)&&z.enum.includes(w)});var w1={Numeric:(z)=>{let w=L6.Number(z);return E.Transform(E.Union([E.String({format:"numeric",default:0}),E.Number(z)],z)).Decode((U)=>{let W=+U;if(isNaN(W))return U;if(z&&!o.Check(w,W))throw new r("property",w,W);return W}).Encode((U)=>U)},Integer:(z)=>{let w=L6.Integer(z);return E.Transform(E.Union([E.String({format:"integer",default:0}),L6.Integer(z)],z)).Decode((U)=>{let W=+U;if(!o.Check(w,W))throw new r("property",w,W);return W}).Encode((U)=>U)},Date:(z)=>{let w=L6.Date(z),U=z?.default?new Date(z.default):void 0;return E.Transform(E.Union([L6.Date(z),E.String({format:"date",default:U?.toISOString()}),E.String({format:"date-time",default:U?.toISOString()}),E.Number({default:U?.getTime()})],z)).Decode((W)=>{if(typeof W==="number"){let Z=new Date(W);if(!o.Check(w,Z))throw new r("property",w,Z);return Z}if(W instanceof Date)return W;let X=new Date(W);if(!X||isNaN(X.getTime()))throw new r("property",w,X);if(!o.Check(w,X))throw new r("property",w,X);return X}).Encode((W)=>W.toISOString())},BooleanString:(z)=>{let w=L6.Boolean(z);return E.Transform(E.Union([E.Boolean(z),E.String({format:"boolean",default:!1})],z)).Decode((U)=>{if(typeof U==="string")return U==="true";if(U!==void 0&&!o.Check(w,U))throw new r("property",w,U);return U}).Encode((U)=>U)},ObjectString:(z,w)=>{let U=E.Object(z,w),W=JSON.stringify(o.Create(U)),X;try{X=N6.Compile(U)}catch{}return E.Transform(E.Union([E.String({format:"ObjectString",default:W}),U])).Decode((Z)=>{if(typeof Z==="string"){if(Z.charCodeAt(0)!==123)throw new r("property",U,Z);try{Z=JSON.parse(Z)}catch{throw new r("property",U,Z)}if(X){if(!X.Check(Z))throw new r("property",U,Z);return X.Decode(Z)}if(!o.Check(U,Z))throw new r("property",U,Z);return o.Decode(U,Z)}return Z}).Encode((Z)=>{if(typeof Z==="string")try{Z=JSON.parse(Z)}catch{throw new r("property",U,Z)}if(!o.Check(U,Z))throw new r("property",U,Z);return JSON.stringify(Z)})},ArrayString:(z=E.String(),w)=>{let U=E.Array(z,w),W;try{W=N6.Compile(U)}catch{}let X=(Z,$=!1)=>{if(Z.charCodeAt(0)===91){try{Z=JSON.parse(Z)}catch{throw new r("property",U,Z)}if(W){if(!W.Check(Z))throw new r("property",U,Z);return W.Decode(Z)}if(!o.Check(U,Z))throw new r("property",U,Z);return o.Decode(U,Z)}if(Z.indexOf(",")!==-1){let A=Z.split(",").map((Q)=>Q.trim());if(W){if(!W.Check(A))throw new r("property",U,Z);return W.Decode(A)}if(!o.Check(U,A))throw new r("property",U,A);return o.Decode(U,A)}if($)return Z;throw new r("property",U,Z)};return E.Transform(E.Union([E.String({format:"ArrayString",default:w?.default}),U])).Decode((Z)=>{if(Array.isArray(Z)){let $=[];for(let A=0;A<Z.length;A++){let Q=Z[A];if(typeof Q==="string"){let Y=X(Q,!0);if(Array.isArray(Y))$=$.concat(Y);else $.push(Y);continue}$.push(Q)}return $}if(typeof Z==="string")return X(Z);return Z}).Encode((Z)=>{if(typeof Z==="string")try{Z=JSON.parse(Z)}catch{throw new r("property",U,Z)}if(!o.Check(U,Z))throw new r("property",U,Z);return JSON.stringify(Z)})},File:tL,Files:(z={})=>E.Transform(oL(z)).Decode((w)=>{if(Array.isArray(w))return w;return[w]}).Encode((w)=>w),Nullable:(z,w)=>E.Union([z,E.Null()],w),MaybeEmpty:(z,w)=>E.Union([z,E.Null(),E.Undefined()],w),Cookie:(z,{domain:w,expires:U,httpOnly:W,maxAge:X,path:Z,priority:$,sameSite:A,secure:Q,secrets:Y,sign:J,...G}={})=>{let S=E.Object(z,G);return S.config={domain:w,expires:U,httpOnly:W,maxAge:X,path:Z,priority:$,sameSite:A,secure:Q,secrets:Y,sign:J},S},UnionEnum:(z,w={})=>{let U=z.every((W)=>typeof W==="string")?{type:"string"}:z.every((W)=>typeof W==="number")?{type:"number"}:z.every((W)=>W===null)?{type:"null"}:{};if(z.some((W)=>typeof W==="object"&&W!==null))throw new Error("This type does not support objects or arrays");return{default:z[0],...w,[H]:"UnionEnum",...U,enum:z}}};E.BooleanString=w1.BooleanString;E.ObjectString=w1.ObjectString;E.ArrayString=w1.ArrayString;E.Numeric=w1.Numeric;E.Integer=w1.Integer;E.File=(z={})=>w1.File({default:"File",...z,extension:z?.type,type:"string",format:"binary"});E.Files=(z={})=>w1.Files({...z,elysiaMeta:"Files",default:"Files",extension:z?.type,type:"array",items:{...z,default:"Files",type:"string",format:"binary"}});E.Nullable=(z)=>w1.Nullable(z);E.MaybeEmpty=w1.MaybeEmpty;E.Cookie=w1.Cookie;E.Date=w1.Date;E.UnionEnum=w1.UnionEnum;function rU(z,w){if(!p0.Has(z))p0.Set(z,w);return(U={})=>k8({...U,[H]:z})}var r4=(z)=>{let w=typeof z==="object"?z.fn.toString():typeof z==="string"?z.toString():z,U=w.indexOf(")");if(w.charCodeAt(U+2)===61&&w.charCodeAt(U+5)!==123)return!0;return w.includes("return")},pL=(z)=>{if(z.startsWith("async"))z=z.slice(5);z=z.trimStart();let w=-1;if(z.charCodeAt(0)===40){if(w=z.indexOf("=>",z.indexOf(")")),w!==-1){let X=w;while(X>0)if(z.charCodeAt(--X)===41)break;let Z=z.slice(w+2);if(Z.charCodeAt(0)===32)Z=Z.trimStart();return[z.slice(1,X),Z,{isArrowReturn:Z.charCodeAt(0)!==123}]}}if(/^(\w+)=>/g.test(z)){if(w=z.indexOf("=>"),w!==-1){let X=z.slice(w+2);if(X.charCodeAt(0)===32)X=X.trimStart();return[z.slice(0,w),X,{isArrowReturn:X.charCodeAt(0)!==123}]}}if(z.startsWith("function")){w=z.indexOf("(");let X=z.indexOf(")");return[z.slice(w+1,X),z.slice(X+2),{isArrowReturn:!1}]}let U=z.indexOf("(");if(U!==-1){let X=z.indexOf(`
8
+ `,2),Z=z.slice(0,X),$=Z.lastIndexOf(")")+1,A=z.slice(X+1);return[Z.slice(U,$),"{"+A,{isArrowReturn:!1}]}let W=z.split(`
9
+ `,2);return[W[0],W[1],{isArrowReturn:!1}]},lL=(z)=>{let w=z.indexOf("{");if(w===-1)return[-1,0];let U=w+1,W=1;for(;U<z.length;U++){let X=z.charCodeAt(U);if(X===123)W++;else if(X===125)W--;if(W===0)break}if(W!==0)return[0,z.length];return[w,U+1]},sL=(z)=>{let w=z.lastIndexOf("}");if(w===-1)return[-1,0];let U=w-1,W=1;for(;U>=0;U--){let X=z.charCodeAt(U);if(X===125)W++;else if(X===123)W--;if(W===0)break}if(W!==0)return[-1,0];return[U,w+1]},aU=(z)=>{while(!0){let w=z.indexOf(":");if(w===-1)break;let U=z.indexOf(",",w);if(U===-1)U=z.indexOf("}",w)-1;if(U===-2)U=z.length;z=z.slice(0,w)+z.slice(U)}return z},eU=(z)=>{let w=!1;if(z.charCodeAt(0)===40)z=z.slice(1,-1);if(z.charCodeAt(0)===123)w=!0,z=z.slice(1,-1);z=z.replace(/( |\t|\n)/g,"").trim();let U=[];while(!0){let[X,Z]=lL(z);if(X===-1)break;if(U.push(z.slice(0,X-1)),z.charCodeAt(Z)===44)Z++;z=z.slice(Z)}if(z=aU(z),z)U=U.concat(z.split(","));let W=[];for(let X of U){if(X.indexOf(",")===-1){W.push(X);continue}for(let Z of X.split(","))W.push(Z.trim())}return U=W,{hasParenthesis:w,parameters:U}},rL=(z,w)=>{let{parameters:U,hasParenthesis:W}=eU(z);if(!w.query&&U.includes("query"))w.query=!0;if(!w.headers&&U.includes("headers"))w.headers=!0;if(!w.body&&U.includes("body"))w.body=!0;if(!w.cookie&&U.includes("cookie"))w.cookie=!0;if(!w.set&&U.includes("set"))w.set=!0;if(!w.server&&U.includes("server"))w.server=!0;if(!w.request&&U.includes("request"))w.request=!0;if(!w.route&&U.includes("route"))w.route=!0;if(W)return`{ ${U.join(", ")} }`;return U.join(", ")},kU=(z,w,U)=>{let W=w.indexOf(z+`
10
+ `,U),X=w.indexOf(z+"\t",U),Z=w.indexOf(z+",",U),$=w.indexOf(z+";",U),A=w.indexOf(z+" ",U);return[W,X,Z,$,A].filter((Q)=>Q>0).sort((Q,Y)=>Q-Y)[0]||-1},zW=(z,w,U=0)=>{if(U>5)return[];let W=[],X=w;while(!0){let Z=kU(" = "+z,X);if(Z===-1)Z=kU("="+z,X);if(Z===-1){let Y=X.indexOf(" = "+z);if(Y===-1)Y=X.indexOf("="+z);if(Y+3+z.length!==X.length)break;Z=Y}let $=X.slice(0,Z),A=$.lastIndexOf(" "),Q=$.slice(A!==-1?A+1:-1);if(Q==="}"){let[Y,J]=sL($);W.push(aU(X.slice(Y,J))),X=X.slice(Z+3+z.length);continue}while(Q.charCodeAt(0)===44)Q=Q.slice(1);while(Q.charCodeAt(0)===9)Q=Q.slice(1);if(!Q.includes("("))W.push(Q);X=X.slice(Z+3+z.length)}for(let Z of W){if(Z.charCodeAt(0)===123)continue;let $=zW(Z,w);if($.length>0)W.push(...$)}return W},aL=(z)=>{if(!z)return;if(z.charCodeAt(0)!==123)return z;if(z=z.slice(2,-2),!z.includes(",")){if(z.includes("..."))return z.slice(z.indexOf("...")+3);return}let w=z.indexOf("...");if(w===-1)return;return z.slice(w+3).trimEnd()},eL=(z,w,U)=>{let W=(X,Z)=>z.includes(Z+"."+X)||z.includes(Z+'["'+X+'"]')||z.includes(Z+"['"+X+"']");for(let X of w){if(!X)continue;if(X.charCodeAt(0)===123){let Z=eU(X).parameters;if(!U.query&&Z.includes("query"))U.query=!0;if(!U.headers&&Z.includes("headers"))U.headers=!0;if(!U.body&&Z.includes("body"))U.body=!0;if(!U.cookie&&Z.includes("cookie"))U.cookie=!0;if(!U.set&&Z.includes("set"))U.set=!0;if(!U.query&&Z.includes("server"))U.server=!0;if(!U.request&&Z.includes("request"))U.request=!0;if(!U.route&&Z.includes("route"))U.route=!0;continue}if(!U.query&&W("query",X))U.query=!0;if(z.includes("return "+X)||z.includes("return "+X+".query"))U.query=!0;if(!U.headers&&W("headers",X))U.headers=!0;if(!U.body&&W("body",X))U.body=!0;if(!U.cookie&&W("cookie",X))U.cookie=!0;if(!U.set&&W("set",X))U.set=!0;if(!U.server&&W("server",X))U.server=!0;if(U.query&&U.headers&&U.body&&U.cookie&&U.set&&U.server&&U.server&&U.route)break}return w},zG=(z,w,U)=>{try{let W=new RegExp(`(?:\\w)\\((?:.*)?${z}`,"gs");W.test(w);let X=w.charCodeAt(W.lastIndex);if(X===41||X===44)return U.query=!0,U.headers=!0,U.body=!0,U.cookie=!0,U.set=!0,U.server=!0,U.route=!0,U.request=!0,!0;return!1}catch(W){return console.log("[Sucrose] warning: unexpected isContextPassToFunction error, you may continue development as usual but please report the following to maintainers:"),console.log("--- body ---"),console.log(w),console.log("--- context ---"),console.log(z),!0}},wW=(z,w={query:!1,headers:!1,body:!1,cookie:!1,set:!1,server:!1,request:!1,route:!1})=>{let U=[];if(z.handler&&typeof z.handler==="function")U.push(z.handler);if(z.request?.length)U.push(...z.request);if(z.beforeHandle?.length)U.push(...z.beforeHandle);if(z.parse?.length)U.push(...z.parse);if(z.error?.length)U.push(...z.error);if(z.transform?.length)U.push(...z.transform);if(z.afterHandle?.length)U.push(...z.afterHandle);if(z.mapResponse?.length)U.push(...z.mapResponse);if(z.afterResponse?.length)U.push(...z.afterResponse);for(let W of U){if(!W)continue;let X="fn"in W?W.fn:W;if(typeof X!=="function")continue;let[Z,$,{isArrowReturn:A}]=pL(X.toString()),Q=rL(Z,w),Y=aL(Q);if(Y){let J=zW(Y,$.slice(1,-1));J.splice(0,-1,Y);let G=$;if(G.charCodeAt(0)===123&&G.charCodeAt($.length-1)===125)G=G.slice(1,-1);if(!zG(Y,G,w))eL(G,J,w);if(!w.query&&G.includes("return "+Y+".query"))w.query=!0}if(w.query&&w.headers&&w.body&&w.cookie&&w.set&&w.server&&w.request&&w.route)break}return w},v6=[];for(let z=48;z<58;z++)v6[z]=z-48;for(let z=0;z<6;z++)v6[z+65]=v6[z+97]=z+10;var wG=(z,w)=>{if(z in v6&&w in v6)return v6[z]<<4|v6[w];return 255},UW=[...new Array(128).fill(0),...new Array(16).fill(1),...new Array(16).fill(2),...new Array(32).fill(3),4,4,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,6,7,7,7,7,7,7,7,7,7,7,7,7,8,7,7,10,9,9,9,11,4,4,4,4,4,4,4,4,4,4,4],UG=[0,0,0,0,0,0,0,0,0,0,0,0,12,0,0,0,0,24,36,48,60,72,84,96,0,12,12,12,0,0,0,0,0,0,0,0,0,0,0,24,0,0,0,0,0,0,0,0,0,24,24,24,0,0,0,0,0,0,0,0,0,24,24,0,0,0,0,0,0,0,0,0,0,48,48,48,0,0,0,0,0,0,0,0,0,0,48,48,0,0,0,0,0,0,0,0,0,48,0,0,0,0,0,0,0,0,0,0],TU=UW.map((z)=>[127,63,63,63,0,31,15,15,15,7,7,7][z]),S6=(z)=>{let w=z.indexOf("%");if(w===-1)return z;let U=z.length-3;if(w>U)return null;let W="",X=0,Z=0,$=w,A=12,Q;for(;;){if(Q=wG(z.charCodeAt(w+1),z.charCodeAt(w+2)),A=UG[A+UW[Q]],A===0)return null;if(A===12){if(W+=z.substring(X,$),Z=Z<<6|Q&TU[Q],Z>65535)W+=String.fromCharCode(55232+(Z>>10),56320+(Z&1023));else W+=String.fromCharCode(Z);if(X=w+3,w=z.indexOf("%",X),w===-1)return W+z.substring(X);if(w>U)return null;$=w,Z=0}else{if(w+=3,w>U||z.charCodeAt(w)!==37)return null;Z=Z<<6|Q&TU[Q]}}};class O4{name;jar;initial;constructor(z,w,U={}){this.name=z,this.jar=w,this.initial=U}get cookie(){return this.jar[this.name]??this.initial}set cookie(z){if(!(this.name in this.jar))this.jar[this.name]=this.initial;this.jar[this.name]=z}get setCookie(){if(!(this.name in this.jar))this.jar[this.name]=this.initial;return this.jar[this.name]}set setCookie(z){this.cookie=z}get value(){return this.cookie.value}set value(z){this.setCookie.value=z}get expires(){return this.cookie.expires}set expires(z){this.setCookie.expires=z}get maxAge(){return this.cookie.maxAge}set maxAge(z){this.setCookie.maxAge=z}get domain(){return this.cookie.domain}set domain(z){this.setCookie.domain=z}get path(){return this.cookie.path}set path(z){this.setCookie.path=z}get secure(){return this.cookie.secure}set secure(z){this.setCookie.secure=z}get httpOnly(){return this.cookie.httpOnly}set httpOnly(z){this.setCookie.httpOnly=z}get sameSite(){return this.cookie.sameSite}set sameSite(z){this.setCookie.sameSite=z}get priority(){return this.cookie.priority}set priority(z){this.setCookie.priority=z}get partitioned(){return this.cookie.partitioned}set partitioned(z){this.setCookie.partitioned=z}get secrets(){return this.cookie.secrets}set secrets(z){this.setCookie.secrets=z}update(z){return this.setCookie=Object.assign(this.cookie,typeof z==="function"?z(this.cookie):z),this}set(z){return this.setCookie=Object.assign({...this.initial,value:this.value},typeof z==="function"?z(this.cookie):z),this}remove(){if(this.value===void 0)return;return this.set({expires:new Date(0),maxAge:0,value:""}),this}toString(){return typeof this.value==="object"?JSON.stringify(this.value):this.value?.toString()??""}}var gU=(z,w,U)=>{if(!z.cookie)z.cookie={};return new Proxy(w,{get(W,X){if(X in w)return new O4(X,z.cookie,Object.assign({},U??{},w[X]));return new O4(X,z.cookie,Object.assign({},U))}})},WW=async(z,w,{secrets:U,sign:W,...X}={})=>{if(!w)return gU(z,{},X);let Z=typeof U==="string";if(W&&W!==!0&&!Array.isArray(W))W=[W];let $={},A=w5.parse(w);for(let[Q,Y]of Object.entries(A)){if(Y===void 0)continue;let J=S6(Y);if(W===!0||W?.includes(Q)){if(!U)throw new Error("No secret is provided to cookie plugin");if(Z){let G=await jU(J,U);if(G===!1)throw new sz(Q);J=G}else{let G=!0;for(let S=0;S<U.length;S++){let N=await jU(J,U[S]);if(N!==!1){G=!0,J=N;break}}if(!G)throw new sz(Q)}}$[Q]={value:J}}return gU(z,$,X)},XW=(z)=>{if(!z||!z1(z))return;let w=[];for(let[U,W]of Object.entries(z)){if(!U||!W)continue;let X=W.value;if(X===void 0||X===null)continue;w.push(w5.serialize(U,typeof X==="object"?JSON.stringify(X):X+"",W))}if(w.length===0)return;if(w.length===1)return w[0];return w},D6=(z,w)=>{let U=z.size;if(!w&&U||U&&w&&w.status!==206&&w.status!==304&&w.status!==412&&w.status!==416){if(w){if(w.headers instanceof Headers){let W={"accept-ranges":"bytes","content-range":`bytes 0-${U-1}/${U}`,"transfer-encoding":"chunked"};if(p8)W=w.headers.toJSON();else{W={};for(let[X,Z]of w.headers.entries())if(X in w.headers)W[X]=Z}return new Response(z,{status:w.status,headers:W})}if(z1(w.headers))return new Response(z,{status:w.status,headers:Object.assign({"accept-ranges":"bytes","content-range":`bytes 0-${U-1}/${U}`,"transfer-encoding":"chunked"},w.headers)})}return new Response(z,{headers:{"accept-ranges":"bytes","content-range":`bytes 0-${U-1}/${U}`,"transfer-encoding":"chunked"}})}return new Response(z)},ZW=(z,w)=>{if(!z)return z;z.delete("set-cookie");for(let U=0;U<w.length;U++){let W=w[U].indexOf("=");z.append("set-cookie",`${w[U].slice(0,W)}=${w[U].slice(W+1)||""}`)}return z},n6=(z,w)=>{if(w?.headers){if(z){if(p8)Object.assign(w.headers,z.headers.toJSON());else for(let[U,W]of z.headers.entries())if(U in w.headers)w.headers[U]=W}if(w.status===200)w.status=z.status;if(w.headers["content-encoding"])delete w.headers["content-encoding"];return w}if(!z)return{headers:{},status:w?.status??200};if(p8){if(w={headers:z.headers.toJSON(),status:w?.status??200},w.headers["content-encoding"])delete w.headers["content-encoding"];return w}w={headers:{},status:w?.status??200};for(let[U,W]of z.headers.entries()){if(U==="content-encoding")continue;if(U in w.headers)w.headers[U]=W}return w},e2=async(z,w,U)=>{let W=z.next();if(W instanceof Promise)W=await W;if(W.done){if(w)return E2(W.value,w,U);return P6(W.value,U)}if(w?.headers){if(!w.headers["transfer-encoding"])w.headers["transfer-encoding"]="chunked";if(!w.headers["content-type"])w.headers["content-type"]="text/event-stream; charset=utf-8"}else w={status:200,headers:{"content-type":"text/event-stream; charset=utf-8","transfer-encoding":"chunked"}};return new Response(new ReadableStream({async start(X){let Z=!1;if(U?.signal?.addEventListener("abort",()=>{Z=!0;try{X.close()}catch{}}),W.value!==void 0&&W.value!==null)if(typeof W.value==="object")try{X.enqueue(Buffer.from(JSON.stringify(W.value)))}catch{X.enqueue(Buffer.from(W.value.toString()))}else X.enqueue(Buffer.from(W.value.toString()));for await(let $ of z){if(Z)break;if($===void 0||$===null)continue;if(typeof $==="object")try{X.enqueue(Buffer.from(JSON.stringify($)))}catch{X.enqueue(Buffer.from($.toString()))}else X.enqueue(Buffer.from($.toString()));await new Promise((A)=>setTimeout(()=>A(),0))}try{X.close()}catch{}}}),w)};async function*u6(z){let w=z.body;if(!w)return;let U=w.getReader(),W=new TextDecoder;try{while(!0){let{done:X,value:Z}=await U.read();if(X)break;yield W.decode(Z)}}finally{U.releaseLock()}}var $W=(z)=>{if(typeof z.status==="string")z.status=e8[z.status];if(z.cookie&&z1(z.cookie)){let w=XW(z.cookie);if(w)z.headers["set-cookie"]=w}if(z.headers["set-cookie"]&&Array.isArray(z.headers["set-cookie"]))z.headers=ZW(new Headers(z.headers),z.headers["set-cookie"])},a8=(z,w)=>{if(z.status!==w.status&&w.status!==200&&(z.status<=300||z.status>400))z=new Response(z.body,{headers:z.headers,status:w.status});let U=!1;if(w.headers instanceof Headers)for(let W of w.headers.keys())if(W==="set-cookie"){if(U)continue;U=!0;for(let X of w.headers.getSetCookie())z.headers.append("set-cookie",X)}else z.headers.append(W,w.headers?.get(W)??"");else for(let W in w.headers)z.headers.append(W,w.headers[W]);return z},E2=(z,w,U)=>{if(z1(w.headers)||w.status!==200||w.cookie)switch($W(w),z?.constructor?.name){case"String":return new Response(z,w);case"Array":case"Object":return Response.json(z,w);case"ElysiaFile":return D6(z.value);case"Blob":return D6(z,w);case"ElysiaCustomStatusResponse":return w.status=z.code,E2(z.response,w,U);case"ReadableStream":if(!w.headers["content-type"]?.startsWith("text/event-stream"))w.headers["content-type"]="text/event-stream; charset=utf-8";return U?.signal?.addEventListener("abort",{handleEvent(){if(U?.signal&&!U?.signal?.aborted)z.cancel()}},{once:!0}),new Response(z,w);case void 0:if(!z)return new Response("",w);return Response.json(z,w);case"Response":if(z=a8(z,w),!z.headers.has("content-length")&&z.headers.get("transfer-encoding")==="chunked")return e2(u6(z),n6(z,w),U);return z;case"Error":return O6(z,w);case"Promise":return z.then((W)=>E2(W,w,U));case"Function":return E2(z(),w,U);case"Number":case"Boolean":return new Response(z.toString(),w);case"Cookie":if(z instanceof O4)return new Response(z.value,w);return new Response(z?.toString(),w);case"FormData":return new Response(z,w);default:if(z instanceof Response){if(z=a8(z,w),z.headers.get("transfer-encoding")==="chunked")return e2(u6(z),n6(z,w),U);return z}if(z instanceof Promise)return z.then((W)=>E2(W,w));if(z instanceof Error)return O6(z,w);if(z instanceof b1)return w.status=z.code,E2(z.response,w,U);if(typeof z?.next==="function")return e2(z,w,U);if(typeof z?.then==="function")return z.then((W)=>E2(W,w));if(typeof z?.toResponse==="function")return E2(z.toResponse(),w);if("charCodeAt"in z){let W=z.charCodeAt(0);if(W===123||W===91){if(!w.headers["Content-Type"])w.headers["Content-Type"]="application/json";return new Response(JSON.stringify(z),w)}}return new Response(z,w)}if(z instanceof Response&&!z.headers.has("content-length")&&z.headers.get("transfer-encoding")==="chunked")return e2(u6(z),n6(z,w),U);if(typeof z?.next==="function"||z instanceof ReadableStream)return e2(z,w,U);return P6(z,U)},K2=(z,w,U)=>{if(z===void 0||z===null)return;if(z1(w.headers)||w.status!==200||w.cookie)switch($W(w),z?.constructor?.name){case"String":return new Response(z,w);case"Array":case"Object":return Response.json(z,w);case"ElysiaFile":return D6(z.value);case"Blob":return D6(z,w);case"ElysiaCustomStatusResponse":return w.status=z.code,K2(z.response,w,U);case"ReadableStream":if(!w.headers["content-type"]?.startsWith("text/event-stream"))w.headers["content-type"]="text/event-stream; charset=utf-8";return U?.signal?.addEventListener("abort",{handleEvent(){if(U?.signal&&!U?.signal?.aborted)z.cancel()}},{once:!0}),new Response(z,w);case void 0:if(!z)return;return Response.json(z,w);case"Response":if(z=a8(z,w),!z.headers.has("content-length")&&z.headers.get("transfer-encoding")==="chunked")return e2(u6(z),n6(z,w),U);return z;case"Promise":return z.then((W)=>K2(W,w));case"Error":return O6(z,w);case"Function":return K2(z(),w);case"Number":case"Boolean":return new Response(z.toString(),w);case"FormData":return new Response(z);case"Cookie":if(z instanceof O4)return new Response(z.value,w);return new Response(z?.toString(),w);default:if(z instanceof Response){if(z=a8(z,w),z.headers.get("transfer-encoding")==="chunked")return e2(u6(z),n6(z,w),U);return z}if(z instanceof Promise)return z.then((W)=>K2(W,w));if(z instanceof Error)return O6(z,w);if(z instanceof b1)return w.status=z.code,K2(z.response,w,U);if(typeof z?.next==="function")return e2(z,w,U);if(typeof z?.then==="function")return z.then((W)=>K2(W,w));if(typeof z?.toResponse==="function")return K2(z.toResponse(),w);if("charCodeAt"in z){let W=z.charCodeAt(0);if(W===123||W===91){if(!w.headers["Content-Type"])w.headers["Content-Type"]="application/json";return new Response(JSON.stringify(z),w)}}return new Response(z,w)}else switch(z?.constructor?.name){case"String":return new Response(z);case"Array":case"Object":return Response.json(z,w);case"ElysiaFile":return D6(z.value);case"Blob":return D6(z,w);case"ElysiaCustomStatusResponse":return w.status=z.code,K2(z.response,w,U);case"ReadableStream":return U?.signal?.addEventListener("abort",{handleEvent(){if(U?.signal&&!U?.signal?.aborted)z.cancel()}},{once:!0}),new Response(z,{headers:{"Content-Type":"text/event-stream; charset=utf-8"}});case void 0:if(!z)return new Response("");return new Response(JSON.stringify(z),{headers:{"content-type":"application/json"}});case"Response":if(!z.headers.has("content-length")&&z.headers.get("transfer-encoding")==="chunked")return e2(u6(z),n6(z),U);return z;case"Promise":return z.then((W)=>{let X=K2(W,w);if(X!==void 0)return X});case"Error":return O6(z,w);case"Function":return P6(z(),U);case"Number":case"Boolean":return new Response(z.toString());case"Cookie":if(z instanceof O4)return new Response(z.value,w);return new Response(z?.toString(),w);case"FormData":return new Response(z);default:if(z instanceof Response)return z;if(z instanceof Promise)return z.then((W)=>K2(W,w));if(z instanceof Error)return O6(z,w);if(z instanceof b1)return w.status=z.code,K2(z.response,w,U);if(typeof z?.next==="function")return e2(z,w,U);if(typeof z?.then==="function")return z.then((W)=>K2(W,w));if(typeof z?.toResponse==="function")return K2(z.toResponse(),w);if("charCodeAt"in z){let W=z.charCodeAt(0);if(W===123||W===91){if(!w.headers["Content-Type"])w.headers["Content-Type"]="application/json";return new Response(JSON.stringify(z),w)}}return new Response(z)}},P6=(z,w)=>{switch(z?.constructor?.name){case"String":return new Response(z);case"Object":case"Array":return Response.json(z);case"ElysiaFile":return D6(z.value);case"Blob":return D6(z);case"ElysiaCustomStatusResponse":return E2(z.response,{status:z.code,headers:{}});case"ReadableStream":return w?.signal?.addEventListener("abort",{handleEvent(){if(w?.signal&&!w?.signal?.aborted)z.cancel()}},{once:!0}),new Response(z,{headers:{"Content-Type":"text/event-stream; charset=utf-8"}});case void 0:if(!z)return new Response("");return new Response(JSON.stringify(z),{headers:{"content-type":"application/json"}});case"Response":if(z.headers.get("transfer-encoding")==="chunked")return e2(u6(z),n6(z),w);return z;case"Error":return O6(z);case"Promise":return z.then((U)=>P6(U,w));case"Function":return P6(z(),w);case"Number":case"Boolean":return new Response(z.toString());case"FormData":return new Response(z);default:if(z instanceof Response)return z;if(z instanceof Promise)return z.then((U)=>P6(U,w));if(z instanceof Error)return O6(z);if(z instanceof b1)return E2(z.response,{status:z.code,headers:{}});if(typeof z?.next==="function")return e2(z,void 0,w);if(typeof z?.then==="function")return z.then((U)=>E2(U,set));if(typeof z?.toResponse==="function")return P6(z.toResponse());if("charCodeAt"in z){let U=z.charCodeAt(0);if(U===123||U===91)return new Response(JSON.stringify(z),{headers:{"Content-Type":"application/json"}})}return new Response(z)}},O6=(z,w)=>new Response(JSON.stringify({name:z?.name,message:z?.message,cause:z?.cause}),{status:w?.status!==200?w?.status??500:500,headers:w?.headers}),WG=(z,w,U={})=>{if(typeof z==="function")return;let W=E2(z,{headers:U});if(!w.parse?.length&&!w.transform?.length&&!w.beforeHandle?.length&&!w.afterHandle?.length)return W.clone.bind(W)},t8={name:"web-standard",isWebStandard:!0,handler:{mapResponse:E2,mapEarlyResponse:K2,mapCompactResponse:P6,createStaticHandler:WG},composeHandler:{mapResponseContext:"c.request",preferWebstandardHeaders:!0,headers:`c.headers = {}
11
11
  for (const [key, value] of c.request.headers.entries())c.headers[key] = value
12
- `,parser:{json(w){if(w)return`try{c.body=await c.request.json()}catch{}
12
+ `,parser:{json(z){if(z)return`try{c.body=await c.request.json()}catch{}
13
13
  `;return`c.body=await c.request.json()
14
14
  `},text(){return`c.body=await c.request.text()
15
15
  `},urlencoded(){return`c.body=parseQuery(await c.request.text())
16
16
  `},arrayBuffer(){return`c.body=await c.request.arrayBuffer()
17
- `},formData(w){let z=`
17
+ `},formData(z){let w=`
18
18
  c.body={}
19
- `;if(w)z+="let form;try{form=await c.request.formData()}catch{}";else z+=`const form=await c.request.formData()
20
- `;return z+`for(const key of form.keys()){if(c.body[key]) continue
19
+ `;if(z)w+="let form;try{form=await c.request.formData()}catch{}";else w+=`const form=await c.request.formData()
20
+ `;return w+`for(const key of form.keys()){if(c.body[key]) continue
21
21
  const value=form.getAll(key)
22
22
  if(value.length===1)c.body[key]=value[0]
23
- else c.body[key]=value}`}}},composeGeneralHandler:{parameters:"r",createContext(w){let z="",U="",W=w.setHeaders;for(let Z of Object.keys(w.singleton.decorator))z+=`,${Z}: decorator['${Z}']`;let A=w.config.handler?.standardHostname??!0,X=w.event.trace.length>0;if(U+=`const u=r.url,s=u.indexOf('/',${A?11:7}),qi=u.indexOf('?', s + 1)
23
+ else c.body[key]=value}`}}},composeGeneralHandler:{parameters:"r",createContext(z){let w="",U="",W=z.setHeaders;for(let $ of Object.keys(z.singleton.decorator))w+=`,${$}: decorator['${$}']`;let X=z.config.handler?.standardHostname??!0,Z=!!z.event.trace?.length;if(U+=`const u=r.url,s=u.indexOf('/',${X?11:7}),qi=u.indexOf('?', s + 1)
24
24
  let p
25
25
  if(qi===-1)p=u.substring(s)
26
26
  else p=u.substring(s, qi)
27
- `,X)U+=`const id=randomId()
28
- `;if(U+="const c={request:r,store,qi,path:p,url:u,redirect,error,set:{headers:",U+=Object.keys(W??{}).length?"Object.assign({}, app.setHeaders)":"{}",U+=",status:200}",w.inference.server)U+=",get server(){return getServer()}";if(X)U+=",[ELYSIA_REQUEST_ID]:id";return U+=z,U+=`}
29
- `,U},websocket(w){let z="",U=w.router.static.ws,W=w.router.ws;if(Object.keys(U).length||W.history.length){z+="if(r.method==='GET'){switch(p){";for(let[A,X]of Object.entries(U))z+=`case'${A}':`+(w.config.strictPath!==!0?`case'${r6(A)}':`:"")+`if(r.headers.get('upgrade')==='websocket')return ht[${X}].composed(c)
30
- `;z+=`default:if(r.headers.get('upgrade')==='websocket'){const route=wsRouter.find('ws',p)
27
+ `,Z)U+=`const id=randomId()
28
+ `;if(U+="const c={request:r,store,qi,path:p,url:u,redirect,error,set:{headers:",U+=Object.keys(W??{}).length?"Object.assign({}, app.setHeaders)":"{}",U+=",status:200}",z.inference.server)U+=",get server(){return app.getServer()}";if(Z)U+=",[ELYSIA_REQUEST_ID]:id";return U+=w,U+=`}
29
+ `,U},websocket(z){let w="",U=z.router.static.ws,W=z.router.http;if(W.build(),Object.keys(U).length||W.root.ws||W.history.find((X)=>X["0"]==="ws")){w+="if(r.method==='GET'){switch(p){";for(let[X,Z]of Object.entries(U))w+=`case'${X}':`+(z.config.strictPath!==!0?`case'${S4(X)}':`:"")+`if(r.headers.get('upgrade')==='websocket')return ht[${Z}].composed(c)
30
+ `;w+=`default:if(r.headers.get('upgrade')==='websocket'){const route=router.find('ws',p)
31
31
  if(route){c.params=route.params
32
32
  if(route.store.handler)return route.store.handler(c)
33
- return (route.store.handler=route.store.compile())(c)}}break}}`}return z},error404(w,z){let U="if(route===null)return ";if(z)U+=`app.handleError(c,notFound,false,${this.parameters})`;else U+=w?"new Response(error404Message,{status:c.set.status===200?404:c.set.status,headers:c.set.headers})":"error404.clone()";return{declare:z?"":`const error404Message=notFound.message.toString()
33
+ return (route.store.handler=route.store.compile())(c)}}break}}`}return w},error404(z,w){let U="if(route===null)return ";if(w)U+=`app.handleError(c,notFound,false,${this.parameters})`;else U+=z?"new Response(error404Message,{status:c.set.status===200?404:c.set.status,headers:c.set.headers})":"error404.clone()";return{declare:w?"":`const error404Message=notFound.message.toString()
34
34
  const error404=new Response(error404Message,{status:404})
35
- `,code:U}}},composeError:{mapResponseContext:"",validationError:"return new Response(error.message,{headers:Object.assign({'content-type':'application/json'},set.headers),status:set.status})",unknownError:"return new Response(error.message,{headers:set.headers,status:error.status??set.status??500})"},listen(){return()=>{throw new Error("WebStandard does not support listen, you might want to export default Elysia.fetch instead")}}},EH=(w,z,U={})=>{if(typeof w==="function"||w instanceof Blob)return;let W=E2(w,{headers:U});if(z.parse.length===0&&z.transform.length===0&&z.beforeHandle.length===0&&z.afterHandle.length===0){if(!W.headers.has("content-type"))W.headers.append("content-type","text/plain;charset=utf-8");return W.clone.bind(W)}},KU={open(w){w.data.open?.(w)},message(w,z){w.data.message?.(w,z)},drain(w){w.data.drain?.(w)},close(w,z,U){w.data.close?.(w,z,U)}};class V4{raw;data;body;validator;["~types"];get id(){return this.data.id}constructor(w,z,U=void 0){this.raw=w,this.data=z,this.body=U,this.validator=w.data?.validator,this.sendText=w.sendText.bind(w),this.sendBinary=w.sendBinary.bind(w),this.close=w.close.bind(w),this.terminate=w.terminate.bind(w),this.publishText=w.publishText.bind(w),this.publishBinary=w.publishBinary.bind(w),this.subscribe=w.subscribe.bind(w),this.unsubscribe=w.unsubscribe.bind(w),this.isSubscribed=w.isSubscribed.bind(w),this.cork=w.cork.bind(w),this.remoteAddress=w.remoteAddress,this.binaryType=w.binaryType,this.data=w.data,this.send=this.send.bind(this),this.ping=this.ping.bind(this),this.pong=this.pong.bind(this),this.publish=this.publish.bind(this)}send(w,z){if(Buffer.isBuffer(w))return this.raw.send(w,z);if(this.validator?.Check(w)===!1)return this.raw.send(new Z0("message",this.validator,w).message);if(typeof w==="object")w=JSON.stringify(w);return this.raw.send(w,z)}ping(w){if(Buffer.isBuffer(w))return this.raw.ping(w);if(this.validator?.Check(w)===!1)return this.raw.send(new Z0("message",this.validator,w).message);if(typeof w==="object")w=JSON.stringify(w);return this.raw.ping(w)}pong(w){if(Buffer.isBuffer(w))return this.raw.pong(w);if(this.validator?.Check(w)===!1)return this.raw.send(new Z0("message",this.validator,w).message);if(typeof w==="object")w=JSON.stringify(w);return this.raw.pong(w)}publish(w,z,U){if(Buffer.isBuffer(z))return this.raw.publish(w,z,U);if(this.validator?.Check(z)===!1)return this.raw.send(new Z0("message",this.validator,z).message);if(typeof z==="object")z=JSON.stringify(z);return this.raw.publish(w,z,U)}sendText;sendBinary;close;terminate;publishText;publishBinary;subscribe;unsubscribe;isSubscribed;cork;remoteAddress;binaryType;get readyState(){return this.raw.readyState}}var IH=(w)=>{let z=typeof w==="function"?[w]:w;return async function U(W,A){if(typeof A==="string"){let X=A?.charCodeAt(0);if(X===47||X===123)try{A=JSON.parse(A)}catch{}else if(iw(A))A=+A}if(z)for(let X=0;X<z.length;X++){let Z=z[X](W,A);if(Z instanceof Promise)Z=await Z;if(Z!==void 0)return Z}return A}},xH=(w)=>{let z=(U,W)=>{if(W instanceof Promise)return W.then((Z)=>z(U,Z));if(Buffer.isBuffer(W))return U.send(W.toString());if(W===void 0)return;let A=(Z)=>{if(w?.Check(Z)===!1)return U.send(new Z0("message",w,Z).message);if(typeof Z==="object")return U.send(JSON.stringify(Z));U.send(Z)};if(typeof W?.next!=="function")return void A(W);let X=W.next();if(X instanceof Promise)return(async()=>{let Z=await X;if(w?.Check(Z)===!1)return U.send(new Z0("message",w,Z).message);if(A(Z.value),!Z.done)for await(let $ of W)A($)})();if(A(X.value),!X.done)for(let Z of W)A(Z)};return z},VH={...I8,name:"bun",handler:{...I8.handler,createNativeStaticHandler:EH},composeHandler:{...I8.composeHandler,headers:IU?`c.headers = c.request.headers.toJSON()
35
+ `,code:U}}},composeError:{mapResponseContext:"",validationError:"return new Response(error.message,{headers:Object.assign({'content-type':'application/json'},set.headers),status:set.status})",unknownError:"return new Response(error.message,{headers:set.headers,status:error.status??set.status??500})"},listen(){return()=>{throw new Error("WebStandard does not support listen, you might want to export default Elysia.fetch instead")}}},XG=(z,w,U={})=>{if(typeof z==="function"||z instanceof Blob)return;if(typeof z==="object"&&z?.toString()==="[object HTMLBundle]")return()=>z;let W=E2(z,{headers:U});if(!w.parse?.length&&!w.transform?.length&&!w.beforeHandle?.length&&!w.afterHandle?.length){if(!W.headers.has("content-type"))W.headers.append("content-type","text/plain;charset=utf-8");return W.clone.bind(W)}},fU={open(z){z.data.open?.(z)},message(z,w){z.data.message?.(z,w)},drain(z){z.data.drain?.(z)},close(z,w,U){z.data.close?.(z,w,U)}};class l4{raw;data;body;validator;["~types"];get id(){return this.data.id}constructor(z,w,U=void 0){this.raw=z,this.data=w,this.body=U,this.validator=z.data?.validator,this.sendText=z.sendText.bind(z),this.sendBinary=z.sendBinary.bind(z),this.close=z.close.bind(z),this.terminate=z.terminate.bind(z),this.publishText=z.publishText.bind(z),this.publishBinary=z.publishBinary.bind(z),this.subscribe=z.subscribe.bind(z),this.unsubscribe=z.unsubscribe.bind(z),this.isSubscribed=z.isSubscribed.bind(z),this.cork=z.cork.bind(z),this.remoteAddress=z.remoteAddress,this.binaryType=z.binaryType,this.data=z.data,this.send=this.send.bind(this),this.ping=this.ping.bind(this),this.pong=this.pong.bind(this),this.publish=this.publish.bind(this)}send(z,w){if(Buffer.isBuffer(z))return this.raw.send(z,w);if(this.validator?.Check(z)===!1)return this.raw.send(new r("message",this.validator,z).message);if(typeof z==="object")z=JSON.stringify(z);return this.raw.send(z,w)}ping(z){if(Buffer.isBuffer(z))return this.raw.ping(z);if(this.validator?.Check(z)===!1)return this.raw.send(new r("message",this.validator,z).message);if(typeof z==="object")z=JSON.stringify(z);return this.raw.ping(z)}pong(z){if(Buffer.isBuffer(z))return this.raw.pong(z);if(this.validator?.Check(z)===!1)return this.raw.send(new r("message",this.validator,z).message);if(typeof z==="object")z=JSON.stringify(z);return this.raw.pong(z)}publish(z,w,U){if(Buffer.isBuffer(w))return this.raw.publish(z,w,U);if(this.validator?.Check(w)===!1)return this.raw.send(new r("message",this.validator,w).message);if(typeof w==="object")w=JSON.stringify(w);return this.raw.publish(z,w,U)}sendText;sendBinary;close;terminate;publishText;publishBinary;subscribe;unsubscribe;isSubscribed;cork;remoteAddress;binaryType;get readyState(){return this.raw.readyState}}var ZG=(z)=>{let w=typeof z==="function"?[z]:z;return async function U(W,X){if(typeof X==="string"){let Z=X?.charCodeAt(0);if(Z===34||Z===47||Z===91||Z===123)try{X=JSON.parse(X)}catch{}else if(ez(X))X=+X;else if(X==="true")X=!0;else if(X==="false")X=!1;else if(X==="null")X=null}if(w)for(let Z=0;Z<w.length;Z++){let $=w[Z](W,X);if($ instanceof Promise)$=await $;if($!==void 0)return $}return X}},$G=(z)=>{let w=(U,W)=>{if(W instanceof Promise)return W.then(($)=>w(U,$));if(Buffer.isBuffer(W))return U.send(W.toString());if(W===void 0)return;let X=($)=>{if(z?.Check($)===!1)return U.send(new r("message",z,$).message);if(typeof $==="object")return U.send(JSON.stringify($));U.send($)};if(typeof W?.next!=="function")return void X(W);let Z=W.next();if(Z instanceof Promise)return(async()=>{let $=await Z;if(z?.Check($)===!1)return U.send(new r("message",z,$).message);if(X($.value),!$.done)for await(let A of W)X(A)})();if(X(Z.value),!Z.done)for(let $ of W)X($)};return w},AG={...t8,name:"bun",handler:{...t8.handler,createNativeStaticHandler:XG},composeHandler:{...t8.composeHandler,headers:p8?`c.headers = c.request.headers.toJSON()
36
36
  `:`c.headers = {}
37
37
  for (const [key, value] of c.request.headers.entries())c.headers[key] = value
38
- `},listen(w){return(z,U)=>{if(typeof Bun==="undefined")throw new Error(".listen() is designed to run on Bun only. If you are running Elysia in other environment please use a dedicated plugin or export the handler via Elysia.fetch");if(w.compile(),typeof z==="string"){if(!iw(z))throw new Error("Port must be a numeric value");z=parseInt(z)}let W=w.fetch,A=typeof z==="object"?{development:!T8,reusePort:!0,...w.config.serve||{},...z||{},static:w.router.static.http.static,websocket:{...w.config.websocket||{},...KU||{}},fetch:W,error:w.outerErrorHandler}:{development:!T8,reusePort:!0,...w.config.serve||{},static:w.router.static.http.static,websocket:{...w.config.websocket||{},...KU||{}},port:z,fetch:W,error:w.outerErrorHandler};w.server=Bun?.serve(A);for(let X=0;X<w.event.start.length;X++)w.event.start[X].fn(w);if(U)U(w.server);process.on("beforeExit",()=>{if(w.server){w.server.stop(),w.server=null;for(let X=0;X<w.event.stop.length;X++)w.event.stop[X].fn(w)}}),w.promisedModules.then(()=>{Bun?.gc(!1)})}},ws(w,z,U){let{parse:W,body:A,response:X,...Z}=U,$=j2(A,{modules:w.definitions.typebox,models:w.definitions.type,normalize:w.config.normalize}),Q=j2(X,{modules:w.definitions.typebox,models:w.definitions.type,normalize:w.config.normalize});w.route("$INTERNALWS",z,async(Y)=>{let B=w.getServer(),{set:G,path:_,qi:H,headers:F,query:R,params:J}=Y;if(Y.validator=Q,U.upgrade){if(typeof U.upgrade==="function"){let h=U.upgrade(Y);if(h instanceof Promise)await h}else if(U.upgrade)Object.assign(G.headers,U.upgrade)}if(G.cookie&&s2(G.cookie)){let h=pU(G.cookie);if(h)G.headers["set-cookie"]=h}if(G.headers["set-cookie"]&&Array.isArray(G.headers["set-cookie"]))G.headers=oU(new Headers(G.headers),G.headers["set-cookie"]);let m=xH(Q),A0=IH(W),L0;if(B?.upgrade(Y.request,{headers:s2(G.headers)?G.headers:void 0,data:{...Y,get id(){if(L0)return L0;return L0=gU()},validator:Q,ping(h){U.ping?.(h)},pong(h){U.pong?.(h)},open(h){m(h,U.open?.(new V4(h,Y)))},message:async(h,a)=>{let x=await A0(h,a);if($?.Check(x)===!1)return void h.send(new Z0("message",$,x).message);m(h,U.message?.(new V4(h,Y,x),x))},drain(h){m(h,U.drain?.(new V4(h,Y)))},close(h,a,x){m(h,U.close?.(new V4(h,Y),a,x))}}}))return;return G.status=400,"Expected a websocket connection"},{...Z,websocket:U})}},kH=typeof Bun!=="undefined",FU=kH?Bun.env:typeof process!=="undefined"&&process?.env?process.env:{},a6=/\+/g;function TH(w){let z={};if(typeof w!=="string")return z;let U="",W="",A=-1,X=-1,Z=0,$=w.length;for(let Q=0;Q<$;Q++)switch(w.charCodeAt(Q)){case 38:let Y=X>A;if(!Y)X=Q;if(U=w.slice(A+1,X),Y||U.length>0){if(Z&1)U=U.replace(a6," ");if(Z&2)U=b6.default(U)||U;if(!z[U]){if(Y){if(W=w.slice(X+1,Q),Z&4)W=W.replace(a6," ");if(Z&8)W=b6.default(W)||W}z[U]=W}}U="",W="",A=Q,X=Q,Z=0;break;case 61:if(X<=A)X=Q;else Z|=8;break;case 43:if(X>A)Z|=4;else Z|=1;break;case 37:if(X>A)Z|=8;else Z|=2;break}if(A<$){let Q=X>A;if(U=w.slice(A+1,Q?X:$),Q||U.length>0){if(Z&1)U=U.replace(a6," ");if(Z&2)U=b6.default(U)||U;if(!z[U]){if(Q){if(W=w.slice(X+1,$),Z&4)W=W.replace(a6," ");if(Z&8)W=b6.default(W)||W}z[U]=W}}}return z}var x8=(w)=>{let z={};if(typeof w!=="string")return z;let U=w.length,W="",A="",X=-1,Z=-1,$=!1,Q=!1,Y=!1,B=!1,G=!1,_=0;for(let H=0;H<U+1;H++){if(H!==U)_=w.charCodeAt(H);else _=38;switch(_){case 38:{if(G=Z>X,!G)Z=H;if(W=w.slice(X+1,Z),G||W.length>0){if(Y)W=W.replace(a6," ");if($)W=b6.default(W)||W;if(G){if(A=w.slice(Z+1,H),B)A=A.replace(a6," ");if(Q)A=b6.default(A)||A}let F=z[W];if(F===void 0)z[W]=A;else if(F.pop)F.push(A);else z[W]=[F,A]}A="",X=H,Z=H,$=!1,Q=!1,Y=!1,B=!1;break}case 61:if(Z<=X)Z=H;else Q=!0;break;case 43:if(Z>X)B=!0;else Y=!0;break;case 37:if(Z>X)Q=!0;else $=!0;break}}return z},vw=Symbol("ElysiaTrace"),i1=()=>{let{promise:w,resolve:z}=Promise.withResolvers(),{promise:U,resolve:W}=Promise.withResolvers(),{promise:A,resolve:X}=Promise.withResolvers(),Z=[],$=[];return[(Q)=>{if(Q)Z.push(Q);return w},(Q)=>{let Y=[],B=[],G=null;for(let H=0;H<(Q.total??0);H++){let{promise:F,resolve:R}=Promise.withResolvers(),{promise:J,resolve:m}=Promise.withResolvers(),{promise:A0,resolve:L0}=Promise.withResolvers(),h=[],a=[];Y.push((x)=>{if(x)h.push(x);return F}),B.push((x)=>{let i={...x,end:J,error:A0,index:H,onStop(K){if(K)a.push(K);return J}};R(i);for(let K=0;K<h.length;K++)h[K](i);return(K=null)=>{let o=performance.now();if(K)G=K;let D0={end:o,error:K,get elapsed(){return o-x.begin}};for(let l=0;l<a.length;l++)a[l](D0);m(o),L0(K)}})}let _={...Q,end:U,error:A,onEvent(H){for(let F=0;F<Y.length;F++)Y[F](H)},onStop(H){if(H)$.push(H);return U}};z(_);for(let H=0;H<Z.length;H++)Z[H](_);return{resolveChild:B,resolve(H=null){let F=performance.now();if(!H&&G)H=G;let R={end:F,error:H,get elapsed(){return F-Q.begin}};for(let J=0;J<$.length;J++)$[J](R);W(F),X(H)}}}]},gH=(w)=>{return(z)=>{let[U,W]=i1(),[A,X]=i1(),[Z,$]=i1(),[Q,Y]=i1(),[B,G]=i1(),[_,H]=i1(),[F,R]=i1(),[J,m]=i1(),[A0,L0]=i1();return w({id:z[d8],context:z,set:z.set,onRequest:U,onParse:A,onTransform:Z,onBeforeHandle:Q,onHandle:B,onAfterHandle:_,onMapResponse:J,onAfterResponse:A0,onError:F}),{request:W,parse:X,transform:$,beforeHandle:Y,handle:G,afterHandle:H,error:R,mapResponse:m,afterResponse:L0}}},g4={optional:Symbol.for("TypeBox.Optional"),kind:Symbol.for("TypeBox.Kind")},Y1=(w)=>{if(!w)return!1;let z=w?.schema;if(z?.[g4.kind]==="Import")return w.References().some(Y1);return!!z&&g4.optional in z},fH=["json","text","urlencoded","arrayBuffer","formdata","application/json","text/plain","application/x-www-form-urlencoded","application/octet-stream","multipart/form-data"],l2=(w)=>{if(!w)return!1;let z=w?.schema??w;if(z[g4.kind]==="Import"&&w.References())return w.References().some(l2);if(z.anyOf)return z.anyOf.some(l2);if(z.someOf)return z.someOf.some(l2);if(z.allOf)return z.allOf.some(l2);if(z.not)return z.not.some(l2);if(z.type==="object"){let U=z.properties;if("additionalProperties"in z)return z.additionalProperties;if("patternProperties"in z)return!1;for(let W of Object.keys(U)){let A=U[W];if(A.type==="object"){if(l2(A))return!0}else if(A.anyOf){for(let X=0;X<A.anyOf.length;X++)if(l2(A.anyOf[X]))return!0}return A.additionalProperties}return!1}return!1},nw=({context:w="c",trace:z,addFn:U})=>{if(!z.length)return()=>{return{resolveChild(){return()=>{}},resolve(){}}};for(let W=0;W<z.length;W++)U(`let report${W}, reportChild${W}, reportErr${W}, reportErrChild${W};let trace${W} = ${w}[ELYSIA_TRACE]?.[${W}] ?? trace[${W}](${w});
39
- `);return(W,{name:A,total:X=0}={})=>{if(!A)A="anonymous";let Z=W==="error"?"reportErr":"report";for(let $=0;$<z.length;$++)U(`${Z}${$} = trace${$}.${W}({id,event:'${W}',name:'${A}',begin:performance.now(),total:${X}})
40
- `);return{resolve(){for(let $=0;$<z.length;$++)U(`${Z}${$}.resolve()
41
- `)},resolveChild($){for(let Q=0;Q<z.length;Q++)U(`${Z}Child${Q}=${Z}${Q}.resolveChild?.shift()?.({id,event:'${W}',name:'${$}',begin:performance.now()})
42
- `);return(Q)=>{for(let Y=0;Y<z.length;Y++)if(Q)U(`if(${Q} instanceof Error){${Z}Child${Y}?.(${Q}) }else{${Z}Child${Y}?.()}`);else U(`${Z}Child${Y}?.()
43
- `)}}}}},dH=({injectResponse:w="",normalize:z=!1,validator:U})=>({composeValidation:(W,A=`c.${W}`)=>`c.set.status=422;throw new ValidationError('${W}',validator.${W},${A})`,composeResponseValidation:(W="r")=>{let A=w+`
44
- `;A+=`if(${W} instanceof ElysiaCustomStatusResponse){c.set.status=${W}.code
45
- ${W}=${W}.response}const isResponse=${W} instanceof Response
46
- switch(c.set.status){`;for(let[X,Z]of Object.entries(U.response)){if(A+=`
47
- case ${X}:if(!isResponse){`,z&&"Clean"in Z&&!l2(Z))A+=`${W}=validator.response['${X}'].Clean(${W})
48
- `;A+=`if(validator.response['${X}'].Check(${W})===false){c.set.status=422
49
- throw new ValidationError('response',validator.response['${X}'],${W})}c.set.status = ${X}}break
50
- `}return A+"}"}}),RE=Symbol.for("TypeBox.Kind"),U6=(w,z)=>{if(!z)return;let U=z.schema??z;if(U[g4.kind]==="Import")return z.References().some((W)=>U6(w,W));if(U.type==="object"){let W=U.properties;if(!W)return!1;for(let A of Object.keys(W)){let X=W[A];if(w in X)return!0;if(X.type==="object"){if(U6(w,X))return!0}else if(X.anyOf){for(let Z=0;Z<X.anyOf.length;Z++)if(U6(w,X.anyOf[Z]))return!0}}return!1}return w in U},kw=Symbol.for("TypeBox.Transform"),O6=(w)=>{if(!w)return;if(w.type==="object"&&w.properties){let z=w.properties;for(let U of Object.keys(z)){let W=z[U];if(W.type==="object"){if(O6(W))return!0}else if(W.anyOf){for(let A=0;A<W.anyOf.length;A++)if(O6(W.anyOf[A]))return!0}if(kw in W)return!0}return!1}return kw in w||w.properties&&kw in w.properties},hH=/(?:return|=>) \S+\(/g,e6=(w)=>{return(w?.fn??w).constructor.name==="AsyncFunction"},a0=(w)=>{let z=w?.fn??w;if(z.constructor.name==="AsyncFunction")return!0;let U=z.toString();if(U.includes("=> response.clone("))return!1;if(U.includes("await"))return!0;if(U.includes("async"))return!0;if(U.includes("=>response.clone("))return!1;return!!U.match(hH)},E8=(w)=>{let z=w?.fn??w;return z.constructor.name==="AsyncGeneratorFunction"||z.constructor.name==="GeneratorFunction"},yH=({app:w,path:z,method:U,localHook:W,hooks:A,validator:X,handler:Z,allowMeta:$=!1,inference:Q,asManifest:Y=!1})=>{let B=w["~adapter"].composeHandler,G=w["~adapter"].handler,_=typeof Z==="function";if(!_){if(Z=G.mapResponse(Z,{headers:w.setHeaders??{}}),A.parse.length===0&&A.transform.length===0&&A.beforeHandle.length===0&&A.afterHandle.length===0){if(Z instanceof Response)return Function("a","return function(){return a.clone()}")(Z);return Function("a","return function(){return a}")(Z)}}let H=_?"handler(c)":"handler",F=A.afterResponse.length>0,R=A.trace.length>0,J="";if(Q=uU(Object.assign(W,{handler:Z}),Q),B.declare){let j=B.declare(Q);if(j)J+=j}if(Q.server)J+=`Object.defineProperty(c,'server',{get:function(){return getServer()}})
51
- `;X.createBody?.(),X.createQuery?.(),X.createHeaders?.(),X.createParams?.(),X.createCookie?.(),X.createResponse?.();let m=Q.query||!!X.query,A0=U!=="$INTERNALWS"&&U!=="GET"&&U!=="HEAD"&&(Q.body||!!X.body||A.parse.length);if(A0)J+=`let isParsing=false
52
- `;let L0=w.setHeaders,h=L0&&!!Object.keys(L0).length,a=Q.headers||X.headers||B.preferWebstandardHeaders!==!0&&Q.body,x=Q.cookie||!!X.cookie,i=x?VU({modules:w.definitions.typebox,validator:X.cookie,defaultConfig:w.config.cookie,dynamic:!!w.config.aot,config:X.cookie?.config??{},models:w.definitions.type}):void 0,K=i?.config,o="";if(K?.sign){if(!K.secrets)throw new Error(`t.Cookie required secret which is not set in (${U}) ${z}.`);let j=!K.secrets?void 0:typeof K.secrets==="string"?K.secrets:K.secrets[0];if(o+=`const _setCookie = c.set.cookie
53
- if(_setCookie){`,K.sign===!0)o+=`for(const [key, cookie] of Object.entries(_setCookie)){c.set.cookie[key].value=await signCookie(cookie.value,'${j}')}`;else for(let O of K.sign)o+=`if(_setCookie['${O}']?.value){c.set.cookie['${O}'].value=await signCookie(_setCookie['${O}'].value,'${j}')}`;o+=`}
54
- `}let D0=w.config.normalize,{composeValidation:l,composeResponseValidation:O1}=dH({normalize:D0,validator:X});if(a)J+=B.headers;if(R)J+=`const id=c[ELYSIA_REQUEST_ID]
55
- `;let C0=nw({trace:A.trace,addFn:(j)=>{J+=j}});if(J+="try{",x){let j=(b,T)=>{let t=K?.[b]??T;if(!t)return typeof T==="string"?`${b}:"${T}",`:`${b}:${T},`;if(typeof t==="string")return`${b}:'${t}',`;if(t instanceof Date)return`${b}: new Date(${t.getTime()}),`;return`${b}:${t},`},O=K?`{secrets:${K.secrets!==void 0?typeof K.secrets==="string"?`'${K.secrets}'`:"["+K.secrets.reduce((b,T)=>b+`'${T}',`,"")+"]":"undefined"},sign:${K.sign===!0?!0:K.sign!==void 0?"["+K.sign.reduce((b,T)=>b+`'${T}',`,"")+"]":"undefined"},`+j("domain")+j("expires")+j("httpOnly")+j("maxAge")+j("path","/")+j("priority")+j("sameSite")+j("secure")+"}":"undefined";if(a)J+=`
56
- c.cookie=await parseCookie(c.set,c.headers.cookie,${O})
57
- `;else J+=`
58
- c.cookie=await parseCookie(c.set,c.request.headers.get('cookie'),${O})
59
- `}if(m){let j=[];if(X.query&&X.query.schema.type==="object"){let O=X.query.schema.properties;if(!l2(X.query))for(let[b,T]of Object.entries(O)){let t=T;if(t&&g4.optional in t&&t.type==="array"&&t.items)t=t.items;let{type:e,anyOf:K0}=t,M=e==="array"||K0?.some((C)=>C.type==="string"&&C.format==="ArrayString");j.push({key:b,isArray:M,isNestedObjectArray:M&&t.items?.type==="object"||!!t.items?.anyOf?.some((C)=>C.type==="object"||C.type==="array"),isObject:e==="object"||K0?.some((C)=>C.type==="string"&&C.format==="ArrayString"),anyOf:!!K0})}}if(!j.length)J+="if(c.qi===-1){c.query={}}else{c.query=parseQueryFromURL(c.url.slice(c.qi + 1))}";else{J+=`if(c.qi!==-1){let url = '&' + decodeURIComponent(c.url.slice(c.qi + 1))
60
- `;let O=0;for(let{key:b,isArray:T,isObject:t,isNestedObjectArray:e,anyOf:K0}of j){let M=(O===0?"let ":"")+`memory=url.indexOf('&${b}=')
61
- let a${O}
62
- `;if(T)if(J+=M,e)J+=`while(memory!==-1){const start=memory+${b.length+2}
38
+ `},listen(z){return(w,U)=>{if(typeof Bun==="undefined")throw new Error(".listen() is designed to run on Bun only. If you are running Elysia in other environment please use a dedicated plugin or export the handler via Elysia.fetch");if(z.compile(),typeof w==="string"){if(!ez(w))throw new Error("Port must be a numeric value");w=parseInt(w)}let W=z.fetch,X=typeof w==="object"?{development:!r8,reusePort:!0,...z.config.serve||{},...w||{},static:{...z.router.static.http.static,...z.config.serve?.static},websocket:{...z.config.websocket||{},...fU||{}},fetch:W,error:z.outerErrorHandler}:{development:!r8,reusePort:!0,...z.config.serve||{},static:z.router.static.http.static,websocket:{...z.config.websocket||{},...fU||{}},port:w,fetch:W,error:z.outerErrorHandler};if(z.server=Bun?.serve(X),z.event.start)for(let Z=0;Z<z.event.start.length;Z++)z.event.start[Z].fn(z);if(U)U(z.server);process.on("beforeExit",()=>{if(z.server){if(z.server.stop?.(),z.server=null,z.event.stop)for(let Z=0;Z<z.event.stop.length;Z++)z.event.stop[Z].fn(z)}}),z.promisedModules.then(()=>{Bun?.gc(!1)})}},ws(z,w,U){let{parse:W,body:X,response:Z,...$}=U,A=F2(X,{modules:z.definitions.typebox,models:z.definitions.type,normalize:z.config.normalize}),Q=F2(Z,{modules:z.definitions.typebox,models:z.definitions.type,normalize:z.config.normalize});z.route("$INTERNALWS",w,async(Y)=>{let J=z.getServer(),{set:G,path:S,qi:N,headers:O,query:M,params:C}=Y;if(Y.validator=Q,U.upgrade){if(typeof U.upgrade==="function"){let f=U.upgrade(Y);if(f instanceof Promise)await f}else if(U.upgrade)Object.assign(G.headers,U.upgrade)}if(G.cookie&&z1(G.cookie)){let f=XW(G.cookie);if(f)G.headers["set-cookie"]=f}if(G.headers["set-cookie"]&&Array.isArray(G.headers["set-cookie"]))G.headers=ZW(new Headers(G.headers),G.headers["set-cookie"]);let g=$G(Q),L0=ZG(W),a,$0=[...Array.isArray(U.error)?U.error:[U.error],...(z.event.error??[]).map((f)=>typeof f==="function"?f:f.fn)],K0=!$0.length?()=>{}:async(f,V)=>{for(let k of $0){let j=k(Object.assign(Y,{error:V}));if(j instanceof Promise)j=await j;if(await g(f,j),j)break}};if(J?.upgrade(Y.request,{headers:z1(G.headers)?G.headers:void 0,data:{...Y,get id(){if(a)return a;return a=uU()},validator:Q,ping(f){U.ping?.(f)},pong(f){U.pong?.(f)},open(f){try{g(f,U.open?.(new l4(f,Y)))}catch(V){K0(f,V)}},message:async(f,V)=>{let k=await L0(f,V);if(A?.Check(k)===!1)return void f.send(new r("message",A,k).message);try{g(f,U.message?.(new l4(f,Y,k),k))}catch(j){K0(f,j)}},drain(f){try{g(f,U.drain?.(new l4(f,Y)))}catch(V){K0(f,V)}},close(f,V,k){try{g(f,U.close?.(new l4(f,Y),V,k))}catch(j){K0(f,j)}}}}))return;return G.status=400,"Expected a websocket connection"},{...$,websocket:U})}},QG=typeof Bun!=="undefined",dU=QG?Bun.env:typeof process!=="undefined"&&process?.env?process.env:{},D4=/\+/g;function YG(z){let w={};if(typeof z!=="string")return w;let U="",W="",X=-1,Z=-1,$=0,A=z.length;for(let Q=0;Q<A;Q++)switch(z.charCodeAt(Q)){case 38:let Y=Z>X;if(!Y)Z=Q;if(U=z.slice(X+1,Z),Y||U.length>0){if($&1)U=U.replace(D4," ");if($&2)U=S6(U)||U;if(!w[U]){if(Y){if(W=z.slice(Z+1,Q),$&4)W=W.replace(D4," ");if($&8)W=S6(W)||W}w[U]=W}}U="",W="",X=Q,Z=Q,$=0;break;case 61:if(Z<=X)Z=Q;else $|=8;break;case 43:if(Z>X)$|=4;else $|=1;break;case 37:if(Z>X)$|=8;else $|=2;break}if(X<A){let Q=Z>X;if(U=z.slice(X+1,Q?Z:A),Q||U.length>0){if($&1)U=U.replace(D4," ");if($&2)U=S6(U)||U;if(!w[U]){if(Q){if(W=z.slice(Z+1,A),$&4)W=W.replace(D4," ");if($&8)W=S6(W)||W}w[U]=W}}}return w}var o8=(z)=>{let w={};if(typeof z!=="string")return w;let U=z.length,W="",X="",Z=-1,$=-1,A=!1,Q=!1,Y=!1,J=!1,G=!1,S=0;for(let N=0;N<U+1;N++){if(N!==U)S=z.charCodeAt(N);else S=38;switch(S){case 38:{if(G=$>Z,!G)$=N;if(W=z.slice(Z+1,$),G||W.length>0){if(Y)W=W.replace(D4," ");if(A)W=S6(W)||W;if(G){if(X=z.slice($+1,N),J)X=X.replace(D4," ");if(Q)X=S6(X)||X}let O=w[W];if(O===void 0)w[W]=X;else if(O.pop)O.push(X);else w[W]=[O,X]}X="",Z=N,$=N,A=!1,Q=!1,Y=!1,J=!1;break}case 61:if($<=Z)$=N;else Q=!0;break;case 43:if($>Z)J=!0;else Y=!0;break;case 37:if($>Z)Q=!0;else A=!0;break}}return w},ww=Symbol("ElysiaTrace"),e1=()=>{let{promise:z,resolve:w}=Promise.withResolvers(),{promise:U,resolve:W}=Promise.withResolvers(),{promise:X,resolve:Z}=Promise.withResolvers(),$=[],A=[];return[(Q)=>{if(Q)$.push(Q);return z},(Q)=>{let Y=[],J=[],G=null;for(let N=0;N<(Q.total??0);N++){let{promise:O,resolve:M}=Promise.withResolvers(),{promise:C,resolve:g}=Promise.withResolvers(),{promise:L0,resolve:a}=Promise.withResolvers(),$0=[],K0=[];Y.push((f)=>{if(f)$0.push(f);return O}),J.push((f)=>{let V={...f,end:C,error:L0,index:N,onStop(k){if(k)K0.push(k);return C}};M(V);for(let k=0;k<$0.length;k++)$0[k](V);return(k=null)=>{let j=performance.now();if(k)G=k;let e={end:j,error:k,get elapsed(){return j-f.begin}};for(let Y0=0;Y0<K0.length;Y0++)K0[Y0](e);g(j),a(k)}})}let S={...Q,end:U,error:X,onEvent(N){for(let O=0;O<Y.length;O++)Y[O](N)},onStop(N){if(N)A.push(N);return U}};w(S);for(let N=0;N<$.length;N++)$[N](S);return{resolveChild:J,resolve(N=null){let O=performance.now();if(!N&&G)N=G;let M={end:O,error:N,get elapsed(){return O-Q.begin}};for(let C=0;C<A.length;C++)A[C](M);W(O),Z(N)}}}]},JG=(z)=>{return(w)=>{let[U,W]=e1(),[X,Z]=e1(),[$,A]=e1(),[Q,Y]=e1(),[J,G]=e1(),[S,N]=e1(),[O,M]=e1(),[C,g]=e1(),[L0,a]=e1();return z({id:w[z5],context:w,set:w.set,onRequest:U,onParse:X,onTransform:$,onBeforeHandle:Q,onHandle:J,onAfterHandle:S,onMapResponse:C,onAfterResponse:L0,onError:O}),{request:W,parse:Z,transform:A,beforeHandle:Y,handle:G,afterHandle:N,error:M,mapResponse:g,afterResponse:a}}},m6={optional:Symbol.for("TypeBox.Optional"),kind:Symbol.for("TypeBox.Kind")},R1=(z)=>{if(!z)return!1;let w=z?.schema;if(w?.[m6.kind]==="Import")return z.References().some(R1);return!!w&&m6.optional in w},Q2=(z,w)=>w?z:"",BG=["json","text","urlencoded","arrayBuffer","formdata","application/json","text/plain","application/x-www-form-urlencoded","application/octet-stream","multipart/form-data"],a2=(z)=>{if(!z)return!1;let w=z?.schema??z;if(w[m6.kind]==="Import"&&z.References())return z.References().some(a2);if(w.anyOf)return w.anyOf.some(a2);if(w.someOf)return w.someOf.some(a2);if(w.allOf)return w.allOf.some(a2);if(w.not)return w.not.some(a2);if(w.type==="object"){let U=w.properties;if("additionalProperties"in w)return w.additionalProperties;if("patternProperties"in w)return!1;for(let W of Object.keys(U)){let X=U[W];if(X.type==="object"){if(a2(X))return!0}else if(X.anyOf){for(let Z=0;Z<X.anyOf.length;Z++)if(a2(X.anyOf[Z]))return!0}return X.additionalProperties}return!1}return!1},Uw=({context:z="c",trace:w=[],addFn:U})=>{if(!w.length)return()=>{return{resolveChild(){return()=>{}},resolve(){}}};for(let W=0;W<w.length;W++)U(`let report${W}, reportChild${W}, reportErr${W}, reportErrChild${W};let trace${W} = ${z}[ELYSIA_TRACE]?.[${W}] ?? trace[${W}](${z});
39
+ `);return(W,{name:X,total:Z=0}={})=>{if(!X)X="anonymous";let $=W==="error"?"reportErr":"report";for(let A=0;A<w.length;A++)U(`${$}${A} = trace${A}.${W}({id,event:'${W}',name:'${X}',begin:performance.now(),total:${Z}})
40
+ `);return{resolve(){for(let A=0;A<w.length;A++)U(`${$}${A}.resolve()
41
+ `)},resolveChild(A){for(let Q=0;Q<w.length;Q++)U(`${$}Child${Q}=${$}${Q}.resolveChild?.shift()?.({id,event:'${W}',name:'${A}',begin:performance.now()})
42
+ `);return(Q)=>{for(let Y=0;Y<w.length;Y++)if(Q)U(`if(${Q} instanceof Error){${$}Child${Y}?.(${Q}) }else{${$}Child${Y}?.()}`);else U(`${$}Child${Y}?.()
43
+ `)}}}}},MG=({injectResponse:z="",normalize:w=!1,validator:U,encodeSchema:W=!1})=>({composeValidation:(X,Z=`c.${X}`)=>`c.set.status=422;throw new ValidationError('${X}',validator.${X},${Z})`,composeResponseValidation:(X="r")=>{let Z=z+`
44
+ `;Z+=`if(${X} instanceof ElysiaCustomStatusResponse){c.set.status=${X}.code
45
+ ${X}=${X}.response}const isResponse=${X} instanceof Response
46
+ switch(c.set.status){`;for(let[$,A]of Object.entries(U.response)){if(Z+=`
47
+ case ${$}:if(!isResponse){`,w&&"Clean"in A&&!a2(A))Z+=`${X}=validator.response['${$}'].Clean(${X})
48
+ `;if(W&&(A.hasTransform||typeof A.Decode==="function"))Z+=`${X}=validator.response['${$}'].Encode(${X})
49
+ `;Z+=`if(validator.response['${$}'].Check(${X})===false){c.set.status=422
50
+ throw new ValidationError('response',validator.response['${$}'],${X})}c.set.status = ${$}}
51
+ `,Z+=`break
52
+ `}return Z+"}"}}),JI=Symbol.for("TypeBox.Kind"),_6=(z,w)=>{if(!w)return;let U=w.schema??w;if(U[m6.kind]==="Import")return w.References().some((W)=>_6(z,W));if(U.type==="object"){let W=U.properties;if(!W)return!1;for(let X of Object.keys(W)){let Z=W[X];if(z in Z)return!0;if(Z.type==="object"){if(_6(z,Z))return!0}else if(Z.anyOf){for(let $=0;$<Z.anyOf.length;$++)if(_6(z,Z.anyOf[$]))return!0}}return!1}return z in U},qG=Symbol.for("TypeBox.Transform"),i2=(z)=>{if(!z)return!1;if(z.$ref&&z.$defs&&z.$ref in z.$defs&&i2(z.$defs[z.$ref]))return!0;if(z.oneOf){for(let w=0;w<z.oneOf.length;w++)if(i2(z.oneOf[w]))return!0}if(z.anyOf){for(let w=0;w<z.anyOf.length;w++)if(i2(z.anyOf[w]))return!0}if(z.allOf){for(let w=0;w<z.allOf.length;w++)if(i2(z.allOf[w]))return!0}if(z.not&&i2(z.not))return!0;if(z.type==="object"&&z.properties){let w=z.properties;for(let U of Object.keys(w)){let W=w[U];if(i2(W))return!0;if(W.type==="array"&&W.items&&i2(W.items))return!0}}if(z.type==="array"&&z.items&&i2(z.items))return!0;return qG in z},LG=/(?:return|=>) \S+\(/g,P4=(z)=>{return(z?.fn??z).constructor.name==="AsyncFunction"},a0=(z)=>{let w=z?.fn??z;if(w.constructor.name==="AsyncFunction")return!0;let U=w.toString();if(U.includes("=> response.clone("))return!1;if(U.includes("await"))return!0;if(U.includes("async"))return!0;if(U.includes("=>response.clone("))return!1;return!!U.match(LG)},m8=(z)=>{let w=z?.fn??z;return w.constructor.name==="AsyncGeneratorFunction"||w.constructor.name==="GeneratorFunction"},GG=({app:z,path:w,method:U,hooks:W,validator:X,handler:Z,allowMeta:$=!1,inference:A,asManifest:Q=!1})=>{let Y=z["~adapter"].composeHandler,J=z["~adapter"].handler,G=typeof Z==="function";if(!G){if(Z=J.mapResponse(Z,{headers:z.setHeaders??{}}),W.parse?.length&&W.transform?.length&&W.beforeHandle?.length&&W.afterHandle?.length){if(Z instanceof Response)return Function("a","return function(){return a.clone()}")(Z);return Function("a","return function(){return a}")(Z)}}let S=G?"handler(c)":"handler",N=!!W.afterResponse?.length,O=!!W.trace?.length,M="";if(A=wW(Object.assign({},W,{handler:Z}),A),Y.declare){let F=Y.declare(A);if(F)M+=F}if(A.server)M+=`Object.defineProperty(c,'server',{get:function(){return getServer()}})
53
+ `;X.createBody?.(),X.createQuery?.(),X.createHeaders?.(),X.createParams?.(),X.createCookie?.(),X.createResponse?.();let C=X.body||X.headers||X.params||X.query||X.cookie||X.response,g=A.query||!!X.query,L0=W.parse?.length===1&&W.parse[0].fn==="none",a=U!=="$INTERNALWS"&&U!=="GET"&&U!=="HEAD"&&(A.body||!!X.body||!!W.parse?.length)&&!L0;if(a)M+=`let isParsing=false
54
+ `;let $0=z.setHeaders,K0=$0&&!!Object.keys($0).length,f=A.headers||X.headers||Y.preferWebstandardHeaders!==!0&&A.body,V=A.cookie||!!X.cookie,k=V?yU({modules:z.definitions.typebox,validator:X.cookie,defaultConfig:z.config.cookie,dynamic:!!z.config.aot,config:X.cookie?.config??{},models:z.definitions.type}):void 0,j=k?.config,e="";if(j?.sign){if(!j.secrets)throw new Error(`t.Cookie required secret which is not set in (${U}) ${w}.`);let F=!j.secrets?void 0:typeof j.secrets==="string"?j.secrets:j.secrets[0];if(e+=`const _setCookie = c.set.cookie
55
+ if(_setCookie){`,j.sign===!0)e+=`for(const [key, cookie] of Object.entries(_setCookie)){c.set.cookie[key].value=await signCookie(cookie.value,'${F}')}`;else for(let R of j.sign)e+=`if(_setCookie['${R}']?.value){c.set.cookie['${R}'].value=await signCookie(_setCookie['${R}'].value,'${F}')}`;e+=`}
56
+ `}let Y0=z.config.normalize,_0=z.config.experimental?.encodeSchema,{composeValidation:h0,composeResponseValidation:U6}=MG({normalize:Y0,validator:X,encodeSchema:_0});if(f)M+=Y.headers;if(O)M+=`const id=c[ELYSIA_REQUEST_ID]
57
+ `;let n0=Uw({trace:W.trace,addFn:(F)=>{M+=F}});if(M+="try{",V){let F=(b,c)=>{let t=j?.[b]??c;if(!t)return typeof c==="string"?`${b}:"${c}",`:`${b}:${c},`;if(typeof t==="string")return`${b}:'${t}',`;if(t instanceof Date)return`${b}: new Date(${t.getTime()}),`;return`${b}:${t},`},R=j?`{secrets:${j.secrets!==void 0?typeof j.secrets==="string"?`'${j.secrets}'`:"["+j.secrets.reduce((b,c)=>b+`'${c}',`,"")+"]":"undefined"},sign:${j.sign===!0?!0:j.sign!==void 0?"["+j.sign.reduce((b,c)=>b+`'${c}',`,"")+"]":"undefined"},`+F("domain")+F("expires")+F("httpOnly")+F("maxAge")+F("path","/")+F("priority")+F("sameSite")+F("secure")+"}":"undefined";if(f)M+=`
58
+ c.cookie=await parseCookie(c.set,c.headers.cookie,${R})
59
+ `;else M+=`
60
+ c.cookie=await parseCookie(c.set,c.request.headers.get('cookie'),${R})
61
+ `}if(g){let F=[];if(X.query&&X.query.schema.type==="object"){let R=X.query.schema.properties;if(!a2(X.query))for(let[b,c]of Object.entries(R)){let t=c,B=t.type==="array"||!!t.anyOf?.some((d)=>d.type==="string"&&d.format==="ArrayString");if(t&&m6.optional in t&&t.type==="array"&&t.items)t=t.items;let{type:K,anyOf:L}=t;F.push({key:b,isArray:B,isNestedObjectArray:B&&t.items?.type==="object"||!!t.items?.anyOf?.some((d)=>d.type==="object"||d.type==="array"),isObject:K==="object"||L?.some((d)=>d.type==="string"&&d.format==="ArrayString"),anyOf:!!L})}}if(!F.length)M+="if(c.qi===-1){c.query={}}else{c.query=parseQueryFromURL(c.url.slice(c.qi + 1))}";else{M+=`if(c.qi!==-1){let url='&'+c.url.slice(c.qi + 1)
62
+ `;let R=0;for(let{key:b,isArray:c,isObject:t,isNestedObjectArray:B,anyOf:K}of F){let L=(R===0?"let ":"")+`memory=url.indexOf('&${b}=')
63
+ let a${R}
64
+ `;if(c)if(M+=L,B)M+=`while(memory!==-1){const start=memory+${b.length+2}
63
65
  memory=url.indexOf('&',start)
64
- if(a${O}===undefined)
65
- a${O}=''
66
+ if(a${R}===undefined)
67
+ a${R}=''
66
68
  else
67
- a${O}+=','
69
+ a${R}+=','
68
70
  let temp
69
- if(memory===-1)temp=decodeURIComponent(url.slice(start).replace(/\\+|%20/g,' '))
70
- else temp=decodeURIComponent(url.slice(start, memory).replace(/\\+|%20/g,' '))
71
- const charCode = temp.charCodeAt(0)
72
- if(charCode !== 91 && charCode !== 123)
71
+ if(memory===-1)temp=decodeURIComponent(url.slice(start).replace(/\\+/g,' '))
72
+ else temp=decodeURIComponent(url.slice(start, memory).replace(/\\+/g,' '))
73
+ const charCode=temp.charCodeAt(0)
74
+ if(charCode!==91&&charCode !== 123)
73
75
  temp='"'+temp+'"'
74
- a${O} += temp
75
- if(memory === -1)break
76
+ a${R}+=temp
77
+ if(memory===-1)break
76
78
  memory=url.indexOf('&${b}=',memory)
77
- if(memory === -1)break}try{if(a${O}.charCodeAt(0) === 91)a${O} = JSON.parse(a${O})
79
+ if(memory===-1)break}try{if(a${R}.charCodeAt(0)===91)a${R} = JSON.parse(a${R})
78
80
  else
79
- a${O}=JSON.parse('['+a${O}+']')}catch{}
80
- `;else J+=`while(memory!==-1){const start=memory+${b.length+2}
81
+ a${R}=JSON.parse('['+a${R}+']')}catch{}
82
+ `;else M+=`while(memory!==-1){const start=memory+${b.length+2}
81
83
  memory=url.indexOf('&',start)
82
- if(a${O}===undefined)a${O}=[]
83
- if(memory===-1){a${O}.push(decodeURIComponent(url.slice(start)).replace(/\\+|%20/g,' '))
84
- break}else a${O}.push(decodeURIComponent(url.slice(start, memory)).replace(/\\+|%20/g,' '))
85
- memory=url.indexOf('&${b}=',memory)
84
+ if(a${R}===undefined)a${R}=[]
85
+ if(memory===-1){const temp=decodeURIComponent(url.slice(start)).replace(/\\+/g,' ')
86
+ if(temp.includes(',')){a${R}=a${R}.concat(temp.split(','))}else{a${R}.push(decodeURIComponent(url.slice(start)).replace(/\\+/g,' '))}
87
+ break}else{const temp=decodeURIComponent(url.slice(start, memory)).replace(/\\+/g,' ')
88
+ if(temp.includes(',')){a${R}=a${R}.concat(temp.split(','))}else{a${R}.push(temp)}
89
+ }memory=url.indexOf('&${b}=',memory)
86
90
  if(memory===-1) break
87
- }`;else if(t)J+=M+`if(memory!==-1){const start=memory+${b.length+2}
91
+ }`;else if(t)M+=L+`if(memory!==-1){const start=memory+${b.length+2}
88
92
  memory=url.indexOf('&',start)
89
- if(memory===-1)a${O}=decodeURIComponent(url.slice(start).replace(/\\+|%20/g,' '))else a${O}=decodeURIComponent(url.slice(start,memory).replace(/\\+|%20/g,' '))if(a${O}!==undefined)try{a${O}=JSON.parse(a${O})}catch{}}`;else{if(J+=M+`if(memory!==-1){const start=memory+${b.length+2}
93
+ if(memory===-1)a${R}=decodeURIComponent(url.slice(start).replace(/\\+/g,' '))else a${R}=decodeURIComponent(url.slice(start,memory).replace(/\\+/g,' '))if(a${R}!==undefined)try{a${R}=JSON.parse(a${R})}catch{}}`;else{if(M+=L+`if(memory!==-1){const start=memory+${b.length+2}
90
94
  memory=url.indexOf('&',start)
91
- if(memory===-1)a${O}=decodeURIComponent(url.slice(start).replace(/\\+|%20/g,' '))
92
- else{a${O}=decodeURIComponent(url.slice(start,memory).replace(/\\+|%20/g,' '))`,K0)J+=`
95
+ if(memory===-1)a${R}=decodeURIComponent(url.slice(start).replace(/\\+/g,' '))
96
+ else{a${R}=decodeURIComponent(url.slice(start,memory).replace(/\\+/g,' '))`,K)M+=`
93
97
  let deepMemory=url.indexOf('&${b}=',memory)
94
- if(deepMemory!==-1){a${O}=[a${O}]
98
+ if(deepMemory!==-1){a${R}=[a${R}]
95
99
  let first=true
96
100
  while(true){const start=deepMemory+${b.length+2}
97
101
  if(first)first=false
98
102
  else deepMemory = url.indexOf('&', start)
99
103
  let value
100
- if(deepMemory===-1)value=decodeURIComponent(url.slice(start).replace(/\\+|%20/g,' '))
101
- else value=decodeURIComponent(url.slice(start, deepMemory).replace(/\\+|%20/g,' '))
104
+ if(deepMemory===-1)value=url.slice(start).replace(/\\+/g,' ')
105
+ else value=url.slice(start, deepMemory).replace(/\\+/g,' ')
106
+ value=decodeURIComponent(value)
107
+ if(value===null){if(deepMemory===-1){break}else{continue}}
102
108
  const vStart=value.charCodeAt(0)
103
109
  const vEnd=value.charCodeAt(value.length - 1)
104
110
  if((vStart===91&&vEnd===93)||(vStart===123&&vEnd===125))
105
- try{a${O}.push(JSON.parse(value))}catch{a${O}.push(value)}if(deepMemory===-1)break}}`;J+="}}"}O++,J+=`
106
- `}J+="c.query={"+j.map(({key:b},T)=>`'${b}':a${T}`).join(",")+"}",J+=`} else c.query = {}
107
- `}}let n1=typeof Z==="function"&&a0(Z),I2=R||A.afterResponse.length>0?"c.response= ":"",Y6=x||A0||n1||A.parse.length>0||A.afterHandle.some(a0)||A.beforeHandle.some(a0)||A.transform.some(a0)||A.mapResponse.some(a0),g5=(typeof Z==="function"?E8(Z):!1)||A.beforeHandle.some(E8)||A.afterHandle.some(E8)||A.transform.some(E8),K6=Q.cookie||Q.set||a||R||X.response||_&&h||g5,o0=B.mapResponseContext?`,${B.mapResponseContext}`:"";if(Q.route)J+=`c.route=\`${z}\`
108
- `;let l0=C0("parse",{total:A.parse.length});if(A0){let j=Y1(X.body),O=A.parse.length||Q.body||X.body;if(B.parser.declare)J+=B.parser.declare;J+=`
109
- isParsing=true`;let b=typeof A.parse==="string"?A.parse:Array.isArray(A.parse)&&A.parse.length===1?typeof A.parse[0]==="string"?A.parse[0]:typeof A.parse[0].fn==="string"?A.parse[0].fn:void 0:void 0;if(b&&b in fH){let T=C0("parse",{total:A.parse.length});switch(b){case"json":case"application/json":J+=B.parser.json(j);break;case"text":case"text/plain":J+=B.parser.text(j);break;case"urlencoded":case"application/x-www-form-urlencoded":J+=B.parser.urlencoded(j);break;case"arrayBuffer":case"application/octet-stream":J+=B.parser.arrayBuffer(j);break;case"formdata":case"multipart/form-data":J+=B.parser.formData(j);break;default:if(b[0]in w["~parser"])J+=a?"let contentType = c.headers['content-type']":"let contentType = c.request.headers.get('content-type')",J+=`
111
+ try{a${R}.push(JSON.parse(value))}catch{a${R}.push(value)}if(deepMemory===-1)break}}`;M+="}}"}R++,M+=`
112
+ `}M+="c.query={"+F.map(({key:b},c)=>`'${b}':a${c}`).join(",")+"}",M+=`} else c.query = {}
113
+ `}}let W6=typeof Z==="function"&&a0(Z),I2=O||W.afterResponse?.length?"c.response= ":"",K6=V||a||W6||!!W.parse?.length||!!W.afterHandle?.some(a0)||!!W.beforeHandle?.some(a0)||!!W.transform?.some(a0)||!!W.mapResponse?.some(a0),r5=(typeof Z==="function"?m8(Z):!1)||!!W.beforeHandle?.some(m8)||!!W.afterHandle?.some(m8)||!!W.transform?.some(m8),W1=A.cookie||A.set||f||O||X.response||G&&K0||r5,S0=Y.mapResponseContext?`,${Y.mapResponseContext}`:"";if(O||A.route)M+=`c.route=\`${w}\`
114
+ `;let x2=n0("parse",{total:W.parse?.length});if(a){let F=R1(X.body),R=!!W.parse?.length||A.body||X.body;if(Y.parser.declare)M+=Y.parser.declare;M+=`
115
+ isParsing=true
116
+ `;let b=typeof W.parse==="string"?W.parse:Array.isArray(W.parse)&&W.parse.length===1?typeof W.parse[0]==="string"?W.parse[0]:typeof W.parse[0].fn==="string"?W.parse[0].fn:void 0:void 0;if(b&&BG.includes(b)){let c=n0("parse",{total:W.parse?.length});switch(b){case"json":case"application/json":M+=Y.parser.json(F);break;case"text":case"text/plain":M+=Y.parser.text(F);break;case"urlencoded":case"application/x-www-form-urlencoded":M+=Y.parser.urlencoded(F);break;case"arrayBuffer":case"application/octet-stream":M+=Y.parser.arrayBuffer(F);break;case"formdata":case"multipart/form-data":M+=Y.parser.formData(F);break;default:if(b[0]in z["~parser"])M+=f?"let contentType = c.headers['content-type']":"let contentType = c.request.headers.get('content-type')",M+=`
110
117
  if(contentType){const index=contentType.indexOf(';')
111
118
  if(index!==-1)contentType=contentType.substring(0, index)}
112
119
  else{contentType=''}c.contentType=contentType
113
- `,J+=`let result=parser['${b}'](c, contentType)
120
+ `,M+=`let result=parser['${b}'](c, contentType)
114
121
  if(result instanceof Promise)result=await result
115
122
  if(result instanceof ElysiaCustomStatusResponse)throw result
116
123
  if(result!==undefined)c.body=result
117
124
  delete c.contentType
118
- `;break}T.resolve()}else if(O){if(J+=`
119
- `,J+=a?"let contentType = c.headers['content-type']":"let contentType = c.request.headers.get('content-type')",J+=`
125
+ `;break}c.resolve()}else if(R){if(M+=`
126
+ `,M+=f?"let contentType = c.headers['content-type']":"let contentType = c.request.headers.get('content-type')",M+=`
120
127
  if(contentType){const index=contentType.indexOf(';')
121
128
  if(index!==-1)contentType=contentType.substring(0, index)}
122
129
  else{contentType=''}c.contentType=contentType
123
- `,A.parse.length)J+=`let used=false
124
- `;let T=C0("parse",{total:A.parse.length}),t=!1;for(let e=0;e<A.parse.length;e++){let K0=`bo${e}`;if(e!==0)J+=`
125
- if(!used){`;if(typeof A.parse[e].fn==="string"){let M=T.resolveChild(A.parse[e].fn);switch(A.parse[e].fn){case"json":case"application/json":t=!0,J+=B.parser.json(j);break;case"text":case"text/plain":t=!0,J+=B.parser.text(j);break;case"urlencoded":case"application/x-www-form-urlencoded":t=!0,J+=B.parser.urlencoded(j);break;case"arrayBuffer":case"application/octet-stream":t=!0,J+=B.parser.arrayBuffer(j);break;case"formdata":case"multipart/form-data":t=!0,J+=B.parser.formData(j);break;default:J+=`${K0}=parser['${A.parse[e].fn}'](c,contentType)
126
- if(${K0} instanceof Promise)${K0}=await ${K0}
127
- if(${K0}!==undefined){c.body=${K0};used=true}
128
- `}M()}else{let M=T.resolveChild(A.parse[e].fn.name);J+=`let ${K0}=parse[${e}]
129
- ${K0}=${K0}(c,contentType)
130
- if(${K0} instanceof Promise)${K0}=await ${K0}
131
- if(${K0}!==undefined){c.body=${K0};used=true}`,M()}if(e!==0)J+="}";if(t)break}if(T.resolve(),!t){if(A.parse.length)J+=`
130
+ `,W.parse?.length)M+=`let used=false
131
+ `;let c=n0("parse",{total:W.parse?.length}),t=!1;if(W.parse)for(let B=0;B<W.parse.length;B++){let K=`bo${B}`;if(B!==0)M+=`
132
+ if(!used){`;if(typeof W.parse[B].fn==="string"){let L=c.resolveChild(W.parse[B].fn);switch(W.parse[B].fn){case"json":case"application/json":t=!0,M+=Y.parser.json(F);break;case"text":case"text/plain":t=!0,M+=Y.parser.text(F);break;case"urlencoded":case"application/x-www-form-urlencoded":t=!0,M+=Y.parser.urlencoded(F);break;case"arrayBuffer":case"application/octet-stream":t=!0,M+=Y.parser.arrayBuffer(F);break;case"formdata":case"multipart/form-data":t=!0,M+=Y.parser.formData(F);break;default:M+=`${K}=parser['${W.parse[B].fn}'](c,contentType)
133
+ if(${K} instanceof Promise)${K}=await ${K}
134
+ if(${K}!==undefined){c.body=${K};used=true}
135
+ `}L()}else{let L=c.resolveChild(W.parse[B].fn.name);M+=`let ${K}=e.parse[${B}]
136
+ ${K}=${K}(c,contentType)
137
+ if(${K} instanceof Promise)${K}=await ${K}
138
+ if(${K}!==undefined){c.body=${K};used=true}`,L()}if(B!==0)M+="}";if(t)break}if(c.resolve(),!t){if(W.parse?.length)M+=`
132
139
  if(!used){
133
140
  if(!contentType) throw new ParseError()
134
- `;J+="switch(contentType){",J+=`case 'application/json':
135
- `+B.parser.json(j)+`break
136
- case 'text/plain':`+B.parser.text(j)+`break
137
- case 'application/x-www-form-urlencoded':`+B.parser.urlencoded(j)+`break
138
- case 'application/octet-stream':`+B.parser.arrayBuffer(j)+`break
139
- case 'multipart/form-data':`+B.parser.formData(j)+`break
140
- `;for(let e of Object.keys(w["~parser"]))J+=`case '${e}':let bo${e}=parser['${e}'](c,contentType)
141
- if(bo${e} instanceof Promise)bo${e}=await bo${e}
142
- if(bo${e} instanceof ElysiaCustomStatusResponse)throw result
143
- if(bo${e}!==undefined)c.body=bo${e}
141
+ `;M+="switch(contentType){",M+=`case 'application/json':
142
+ `+Y.parser.json(F)+`break
143
+ case 'text/plain':`+Y.parser.text(F)+`break
144
+ case 'application/x-www-form-urlencoded':`+Y.parser.urlencoded(F)+`break
145
+ case 'application/octet-stream':`+Y.parser.arrayBuffer(F)+`break
146
+ case 'multipart/form-data':`+Y.parser.formData(F)+`break
147
+ `;for(let B of Object.keys(z["~parser"]))M+=`case '${B}':let bo${B}=parser['${B}'](c,contentType)
148
+ if(bo${B} instanceof Promise)bo${B}=await bo${B}
149
+ if(bo${B} instanceof ElysiaCustomStatusResponse)throw result
150
+ if(bo${B}!==undefined)c.body=bo${B}
144
151
  break
145
- `;if(A.parse.length)J+="}";J+="}"}}J+=`
146
- delete c.contentType`,J+=`
152
+ `;if(W.parse?.length)M+="}";M+="}"}}M+=`
153
+ delete c.contentType`,M+=`
147
154
  isParsing=false
148
- `}if(l0.resolve(),A?.transform){let j=C0("transform",{total:A.transform.length});if(A.transform.length)J+=`let transformed
149
- `;for(let O=0;O<A.transform.length;O++){let b=A.transform[O],T=j.resolveChild(b.fn.name);if(J+=a0(b)?`transformed=await transform[${O}](c)
150
- `:`transformed=transform[${O}](c)
151
- `,b.subType==="mapDerive")J+=`if(transformed instanceof ElysiaCustomStatusResponse)throw transformed
155
+ `}if(x2.resolve(),W?.transform){let F=n0("transform",{total:W.transform.length});if(W.transform.length)M+=`let transformed
156
+ `;for(let R=0;R<W.transform.length;R++){let b=W.transform[R],c=F.resolveChild(b.fn.name);if(M+=a0(b)?`transformed=await e.transform[${R}](c)
157
+ `:`transformed=e.transform[${R}](c)
158
+ `,b.subType==="mapDerive")M+=`if(transformed instanceof ElysiaCustomStatusResponse)throw transformed
152
159
  else{transformed.request=c.request
153
160
  transformed.store=c.store
154
161
  transformed.qi=c.qi
@@ -157,30 +164,30 @@ transformed.url=c.url
157
164
  transformed.redirect=c.redirect
158
165
  transformed.set=c.set
159
166
  transformed.error=c.error
160
- c=transformed}`;else J+=`if(transformed instanceof ElysiaCustomStatusResponse)throw transformed
167
+ c=transformed}`;else M+=`if(transformed instanceof ElysiaCustomStatusResponse)throw transformed
161
168
  else Object.assign(c,transformed)
162
- `;T()}j.resolve()}if(X){if(X.headers){if(D0&&"Clean"in X.headers&&!l2(X.headers))J+=`c.headers=validator.headers.Clean(c.headers);
163
- `;if(U6("default",X.headers))for(let[j,O]of Object.entries(p.Default(X.headers.schema,{}))){let b=typeof O==="object"?JSON.stringify(O):typeof O==="string"?`'${O}'`:O;if(b!==void 0)J+=`c.headers['${j}']??=${b}
164
- `}if(Y1(X.headers))J+="if(isNotEmpty(c.headers)){";if(J+="if(validator.headers.Check(c.headers) === false){"+l("headers")+"}",O6(X.headers.schema))J+=`c.headers=validator.headers.Decode(c.headers)
165
- `;if(Y1(X.headers))J+="}"}if(X.params){if(U6("default",X.params))for(let[j,O]of Object.entries(p.Default(X.params.schema,{}))){let b=typeof O==="object"?JSON.stringify(O):typeof O==="string"?`'${O}'`:O;if(b!==void 0)J+=`c.params['${j}']??=${b}
166
- `}if(J+="if(validator.params.Check(c.params)===false){"+l("params")+"}",O6(X.params.schema))J+=`c.params=validator.params.Decode(c.params)
167
- `}if(X.query){if(D0&&"Clean"in X.query&&!l2(X.query))J+=`c.query=validator.query.Clean(c.query)
168
- `;if(U6("default",X.query))for(let[j,O]of Object.entries(p.Default(X.query.schema,{}))){let b=typeof O==="object"?JSON.stringify(O):typeof O==="string"?`'${O}'`:O;if(b!==void 0)J+=`if(c.query['${j}']===undefined)c.query['${j}']=${b}
169
- `}if(Y1(X.query))J+="if(isNotEmpty(c.query)){";if(J+="if(validator.query.Check(c.query)===false){"+l("query")+"}",O6(X.query.schema))J+=`c.query=validator.query.Decode(Object.assign({},c.query))
170
- `;if(Y1(X.query))J+="}"}if(X.body){if(D0&&"Clean"in X.body&&!l2(X.body))J+=`c.body=validator.body.Clean(c.body)
171
- `;let j=O6(X.body.schema);if(j||Y1(X.body))J+=`const isNotEmptyObject=c.body&&(typeof c.body==="object"&&isNotEmpty(c.body))
172
- `;if(U6("default",X.body)){let O=p.Default(X.body.schema,X.body.schema.type==="object"?{}:void 0),b=typeof O==="object"?JSON.stringify(O):typeof O==="string"?`'${O}'`:O;if(J+=`if(validator.body.Check(c.body)===false){if(typeof c.body==='object')c.body=Object.assign(${b},c.body)
173
- else c.body=${b}
174
- `,Y1(X.body))J+="if(isNotEmptyObject&&validator.body.Check(c.body)===false){"+l("body")+"}";else J+="if(validator.body.Check(c.body)===false){"+l("body")+"}";J+="}"}else if(Y1(X.body))J+="if(isNotEmptyObject&&validator.body.Check(c.body)===false){"+l("body")+"}";else J+="if(validator.body.Check(c.body)===false){"+l("body")+"}";if(j)J+=`if(isNotEmptyObject)c.body=validator.body.Decode(c.body)
175
- `}if(i&&s2(i?.schema?.properties??i?.schema?.schema??{})){if(J+=`const cookieValue={}
169
+ `;c()}F.resolve()}if(X){if(X.headers){if(Y0&&"Clean"in X.headers&&!a2(X.headers))M+=`c.headers=validator.headers.Clean(c.headers);
170
+ `;if(_6("default",X.headers))for(let[F,R]of Object.entries(o.Default(X.headers.schema,{}))){let b=typeof R==="object"?JSON.stringify(R):typeof R==="string"?`'${R}'`:R;if(b!==void 0)M+=`c.headers['${F}']??=${b}
171
+ `}if(R1(X.headers))M+="if(isNotEmpty(c.headers)){";if(M+="if(validator.headers.Check(c.headers) === false){"+h0("headers")+"}",i2(X.headers.schema))M+=`c.headers=validator.headers.Decode(c.headers)
172
+ `;if(R1(X.headers))M+="}"}if(X.params){if(_6("default",X.params))for(let[F,R]of Object.entries(o.Default(X.params.schema,{}))){let b=typeof R==="object"?JSON.stringify(R):typeof R==="string"?`'${R}'`:R;if(b!==void 0)M+=`c.params['${F}']??=${b}
173
+ `}if(M+="if(validator.params.Check(c.params)===false){"+h0("params")+"}",i2(X.params.schema))M+=`c.params=validator.params.Decode(c.params)
174
+ `}if(X.query){if(Y0&&"Clean"in X.query&&!a2(X.query))M+=`c.query=validator.query.Clean(c.query)
175
+ `;if(_6("default",X.query))for(let[F,R]of Object.entries(o.Default(X.query.schema,{}))){let b=typeof R==="object"?JSON.stringify(R):typeof R==="string"?`'${R}'`:R;if(b!==void 0)M+=`if(c.query['${F}']===undefined)c.query['${F}']=${b}
176
+ `}if(R1(X.query))M+="if(isNotEmpty(c.query)){";if(M+="if(validator.query.Check(c.query)===false){"+h0("query")+"}",i2(X.query.schema))M+=`c.query=validator.query.Decode(Object.assign({},c.query))
177
+ `;if(R1(X.query))M+="}"}if(X.body){if(Y0&&"Clean"in X.body&&!a2(X.body))M+=`c.body=validator.body.Clean(c.body)
178
+ `;let F=i2(X.body.schema);if(F||R1(X.body))M+=`const isNotEmptyObject=c.body&&(typeof c.body==="object"&&isNotEmpty(c.body))
179
+ `;if(_6("default",X.body)){let R=X.body.schema,b=o.Default(R,R.type==="object"||R[m6.kind]==="Import"&&R.$defs[R.$ref][m6.kind]==="Object"?{}:void 0),c=typeof b==="object"?JSON.stringify(b):typeof b==="string"?`'${b}'`:b;if(M+="if(validator.body.Check(c.body)===false){",b!==void 0&&b!==null)M+=`if(typeof c.body==='object')c.body=Object.assign(${c},c.body)
180
+ else c.body=${c}
181
+ `;if(R1(X.body))M+="if(isNotEmptyObject&&validator.body.Check(c.body)===false){"+h0("body")+"}";else M+="if(validator.body.Check(c.body)===false){"+h0("body")+"}";M+="}"}else if(R1(X.body))M+="if(isNotEmptyObject&&validator.body.Check(c.body)===false){"+h0("body")+"}";else M+="if(validator.body.Check(c.body)===false){"+h0("body")+"}";if(F)M+=`if(isNotEmptyObject)c.body=validator.body.Decode(c.body)
182
+ `}if(k&&z1(k?.schema?.properties??k?.schema?.schema??{})){if(M+=`const cookieValue={}
176
183
  for(const [key,value] of Object.entries(c.cookie))cookieValue[key]=value.value
177
- `,U6("default",i))for(let[j,O]of Object.entries(p.Default(i.schema,{})))J+=`cookieValue['${j}'] = ${typeof O==="object"?JSON.stringify(O):O}
178
- `;if(Y1(X.cookie))J+="if(isNotEmpty(c.cookie)){";if(J+="if(validator.cookie.Check(cookieValue)===false){"+l("cookie","cookieValue")+"}",O6(X.cookie.schema))J+=`for(const [key,value] of Object.entries(validator.cookie.Decode(cookieValue)))c.cookie[key].value=value
179
- `;if(Y1(X.cookie))J+="}"}}if(A?.beforeHandle){let j=C0("beforeHandle",{total:A.beforeHandle.length}),O=!1;for(let b=0;b<A.beforeHandle.length;b++){let T=A.beforeHandle[b],t=j.resolveChild(T.fn.name),e=T4(T);if(T.subType==="resolve"||T.subType==="mapResolve"){if(!O)O=!0,J+=`
184
+ `,_6("default",k))for(let[F,R]of Object.entries(o.Default(k.schema,{})))M+=`cookieValue['${F}'] = ${typeof R==="object"?JSON.stringify(R):R}
185
+ `;if(R1(X.cookie))M+="if(isNotEmpty(c.cookie)){";if(M+="if(validator.cookie.Check(cookieValue)===false){"+h0("cookie","cookieValue")+"}",i2(X.cookie.schema))M+=`for(const [key,value] of Object.entries(validator.cookie.Decode(cookieValue)))c.cookie[key].value=value
186
+ `;if(R1(X.cookie))M+="}"}}if(W?.beforeHandle){let F=n0("beforeHandle",{total:W.beforeHandle.length}),R=!1;for(let b=0;b<W.beforeHandle.length;b++){let c=W.beforeHandle[b],t=F.resolveChild(c.fn.name),B=r4(c);if(c.subType==="resolve"||c.subType==="mapResolve"){if(!R)R=!0,M+=`
180
187
  let resolved
181
- `;if(J+=a0(T)?`resolved=await beforeHandle[${b}](c);
182
- `:`resolved=beforeHandle[${b}](c);
183
- `,T.subType==="mapResolve")J+=`if(resolved instanceof ElysiaCustomStatusResponse)throw resolved
188
+ `;if(M+=a0(c)?`resolved=await e.beforeHandle[${b}](c);
189
+ `:`resolved=e.beforeHandle[${b}](c);
190
+ `,c.subType==="mapResolve")M+=`if(resolved instanceof ElysiaCustomStatusResponse)throw resolved
184
191
  else{resolved.request = c.request
185
192
  resolved.store = c.store
186
193
  resolved.qi = c.qi
@@ -189,135 +196,135 @@ resolved.url = c.url
189
196
  resolved.redirect = c.redirect
190
197
  resolved.set = c.set
191
198
  resolved.error = c.error
192
- c = resolved}`;else J+=`if(resolved instanceof ElysiaCustomStatusResponse)throw resolved
199
+ c = resolved}`;else M+=`if(resolved instanceof ElysiaCustomStatusResponse)throw resolved
193
200
  else Object.assign(c, resolved)
194
- `}else if(!e)J+=a0(T)?`await beforeHandle[${b}](c)
195
- `:`beforeHandle[${b}](c)
196
- `,t();else{if(J+=a0(T)?`be=await beforeHandle[${b}](c)
197
- `:`be=beforeHandle[${b}](c)
198
- `,t("be"),J+="if(be!==undefined){",j.resolve(),A.afterHandle?.length){C0("handle",{name:_?Z.name:void 0}).resolve();let M=C0("afterHandle",{total:A.afterHandle.length});for(let C=0;C<A.afterHandle.length;C++){let L=A.afterHandle[C],u=T4(L),V=M.resolveChild(L.fn.name);if(J+=`c.response = be
199
- `,!u)J+=a0(L.fn)?`await afterHandle[${C}](c, be)
200
- `:`afterHandle[${C}](c, be)
201
- `;else J+=a0(L.fn)?`af = await afterHandle[${C}](c)
202
- `:`af = afterHandle[${C}](c)
203
- `,J+=`if(af!==undefined) c.response=be=af
204
- `;V("af")}M.resolve()}if(X.response)J+=O1("be");let K0=C0("mapResponse",{total:A.mapResponse.length});if(A.mapResponse.length){J+=`c.response=be
205
- `;for(let M=0;M<A.mapResponse.length;M++){let C=A.mapResponse[M],L=K0.resolveChild(C.fn.name);J+=`if(mr===undefined){mr=${e6(C)?"await":""} onMapResponse[${M}](c)
206
- if(mr!==undefined)be=c.response=mr}`,L()}}K0.resolve(),J+=o,J+=`return mapEarlyResponse(${I2}be,c.set${o0})}
207
- `}}j.resolve()}if(A?.afterHandle.length){let j=C0("handle",{name:_?Z.name:void 0});if(A.afterHandle.length)J+=n1?`let r=c.response=await ${H}
208
- `:`let r=c.response=${H}
209
- `;else J+=n1?`let r=await ${H}
210
- `:`let r=${H}
211
- `;j.resolve();let O=C0("afterHandle",{total:A.afterHandle.length});for(let T=0;T<A.afterHandle.length;T++){let t=A.afterHandle[T],e=T4(t),K0=O.resolveChild(t.fn.name);if(!e)J+=a0(t.fn)?`await afterHandle[${T}](c)
212
- `:`afterHandle[${T}](c)
213
- `,K0();else if(J+=a0(t.fn)?`af=await afterHandle[${T}](c)
214
- `:`af=afterHandle[${T}](c)
215
- `,K0("af"),X.response)J+="if(af!==undefined){",O.resolve(),J+=O1("af"),J+="c.response=af}";else J+="if(af!==undefined){",O.resolve(),J+="c.response=af}"}if(O.resolve(),J+=`r=c.response
216
- `,X.response)J+=O1();J+=o;let b=C0("mapResponse",{total:A.mapResponse.length});if(A.mapResponse.length)for(let T=0;T<A.mapResponse.length;T++){let t=A.mapResponse[T],e=b.resolveChild(t.fn.name);J+=`mr=${e6(t)?"await":""} onMapResponse[${T}](c)
201
+ `}else if(!B)M+=a0(c)?`await e.beforeHandle[${b}](c)
202
+ `:`e.beforeHandle[${b}](c)
203
+ `,t();else{if(M+=a0(c)?`be=await e.beforeHandle[${b}](c)
204
+ `:`be=e.beforeHandle[${b}](c)
205
+ `,t("be"),M+="if(be!==undefined){",F.resolve(),W.afterHandle?.length){n0("handle",{name:G?Z.name:void 0}).resolve();let L=n0("afterHandle",{total:W.afterHandle.length});for(let d=0;d<W.afterHandle.length;d++){let I=W.afterHandle[d],h=r4(I),C0=L.resolveChild(I.fn.name);if(M+=`c.response = be
206
+ `,!h)M+=a0(I.fn)?`await e.afterHandle[${d}](c, be)
207
+ `:`e.afterHandle[${d}](c, be)
208
+ `;else M+=a0(I.fn)?`af = await e.afterHandle[${d}](c)
209
+ `:`af = e.afterHandle[${d}](c)
210
+ `,M+=`if(af!==undefined) c.response=be=af
211
+ `;C0("af")}L.resolve()}if(X.response)M+=U6("be");let K=n0("mapResponse",{total:W.mapResponse?.length});if(W.mapResponse?.length){M+=`c.response=be
212
+ `;for(let L=0;L<W.mapResponse.length;L++){let d=W.mapResponse[L],I=K.resolveChild(d.fn.name);M+=`if(mr===undefined){mr=${P4(d)?"await ":""}e.mapResponse[${L}](c)
213
+ if(mr!==undefined)be=c.response=mr}`,I()}}K.resolve(),M+=e,M+=`return mapEarlyResponse(${I2}be,c.set${S0})}
214
+ `}}F.resolve()}if(W.afterHandle?.length){let F=n0("handle",{name:G?Z.name:void 0});if(W.afterHandle.length)M+=W6?`let r=c.response=await ${S}
215
+ `:`let r=c.response=${S}
216
+ `;else M+=W6?`let r=await ${S}
217
+ `:`let r=${S}
218
+ `;F.resolve();let R=n0("afterHandle",{total:W.afterHandle.length});for(let c=0;c<W.afterHandle.length;c++){let t=W.afterHandle[c],B=r4(t),K=R.resolveChild(t.fn.name);if(!B)M+=a0(t.fn)?`await e.afterHandle[${c}](c)
219
+ `:`e.afterHandle[${c}](c)
220
+ `,K();else if(M+=a0(t.fn)?`af=await e.afterHandle[${c}](c)
221
+ `:`af=e.afterHandle[${c}](c)
222
+ `,K("af"),X.response)M+="if(af!==undefined){",R.resolve(),M+=U6("af"),M+="c.response=af}";else M+="if(af!==undefined){",R.resolve(),M+="c.response=af}"}if(R.resolve(),M+=`r=c.response
223
+ `,X.response)M+=U6();M+=e;let b=n0("mapResponse",{total:W.mapResponse?.length});if(W.mapResponse?.length)for(let c=0;c<W.mapResponse.length;c++){let t=W.mapResponse[c],B=b.resolveChild(t.fn.name);M+=`mr=${P4(t)?"await ":""}e.mapResponse[${c}](c)
217
224
  if(mr!==undefined)r=c.response=mr
218
- `,e()}if(b.resolve(),K6)J+=`return mapResponse(${I2}r,c.set${o0})
219
- `;else J+=`return mapCompactResponse(${I2}r${o0})
220
- `}else{let j=C0("handle",{name:_?Z.name:void 0});if(X.response||A.mapResponse.length){if(J+=n1?`let r=await ${H}
221
- `:`let r=${H}
222
- `,j.resolve(),X.response)J+=O1();C0("afterHandle").resolve();let O=C0("mapResponse",{total:A.mapResponse.length});if(A.mapResponse.length){J+=`
225
+ `,B()}if(b.resolve(),W1)M+=`return mapResponse(${I2}r,c.set${S0})
226
+ `;else M+=`return mapCompactResponse(${I2}r${S0})
227
+ `}else{let F=n0("handle",{name:G?Z.name:void 0});if(X.response||W.mapResponse?.length){if(M+=W6?`let r=await ${S}
228
+ `:`let r=${S}
229
+ `,F.resolve(),X.response)M+=U6();n0("afterHandle").resolve();let R=n0("mapResponse",{total:W.mapResponse?.length});if(W.mapResponse?.length){M+=`
223
230
  c.response=r
224
- `;for(let b=0;b<A.mapResponse.length;b++){let T=A.mapResponse[b],t=O.resolveChild(T.fn.name);J+=`
225
- if(mr===undefined){mr=${e6(T)?"await ":""}onMapResponse[${b}](c)
231
+ `;for(let b=0;b<W.mapResponse.length;b++){let c=W.mapResponse[b],t=R.resolveChild(c.fn.name);M+=`
232
+ if(mr===undefined){mr=${P4(c)?"await ":""}e.mapResponse[${b}](c)
226
233
  if(mr!==undefined)r=c.response=mr}
227
- `,t()}}if(O.resolve(),J+=o,Z instanceof Response)J+=Q.set?`if(isNotEmpty(c.set.headers)||c.set.status!==200||c.set.redirect||c.set.cookie)return mapResponse(${I2}${H}.clone(),c.set${o0})else return ${H}.clone()`:`return ${H}.clone()`,J+=`
228
- `;else if(K6)J+=`return mapResponse(${I2}r,c.set${o0})
229
- `;else J+=`return mapCompactResponse(${I2}r${o0})
230
- `}else if(x||R){J+=n1?`let r=await ${H}
231
- `:`let r=${H}
232
- `,j.resolve(),C0("afterHandle").resolve();let O=C0("mapResponse",{total:A.mapResponse.length});if(A.mapResponse.length){J+=`c.response= r
233
- `;for(let b=0;b<A.mapResponse.length;b++){let T=A.mapResponse[b],t=O.resolveChild(T.fn.name);J+=`if(mr===undefined){mr=${e6(T)?"await ":""}onMapResponse[${b}](c)
234
- if(mr!==undefined)r=c.response=mr}`,t()}}if(O.resolve(),J+=o,K6)J+=`return mapResponse(${I2}r,c.set${o0})
235
- `;else J+=`return mapCompactResponse(${I2}r${o0})
236
- `}else{j.resolve();let O=n1?`await ${H}`:H;if(C0("afterHandle").resolve(),Z instanceof Response)J+=Q.set?`if(isNotEmpty(c.set.headers)||c.set.status!==200||c.set.redirect||c.set.cookie)return mapResponse(${I2}${H}.clone(),c.set${o0})
237
- else return ${H}.clone()
238
- `:`return ${H}.clone()
239
- `;else if(K6)J+=`return mapResponse(${I2}${O},c.set${o0})
240
- `;else J+=`return mapCompactResponse(${I2}${O}${o0})
241
- `}}if(J+=`
242
- }catch(error){`,A0)J+=`if(isParsing)error=new ParseError()
243
- `;if(!Y6)J+="return(async()=>{";if(J+=`const set=c.set
234
+ `,t()}}if(R.resolve(),M+=e,Z instanceof Response)M+=A.set?`if(isNotEmpty(c.set.headers)||c.set.status!==200||c.set.redirect||c.set.cookie)return mapResponse(${I2}${S}.clone(),c.set${S0})else return ${S}.clone()`:`return ${S}.clone()`,M+=`
235
+ `;else if(W1)M+=`return mapResponse(${I2}r,c.set${S0})
236
+ `;else M+=`return mapCompactResponse(${I2}r${S0})
237
+ `}else if(V||O){M+=W6?`let r=await ${S}
238
+ `:`let r=${S}
239
+ `,F.resolve(),n0("afterHandle").resolve();let R=n0("mapResponse",{total:W.mapResponse?.length});if(W.mapResponse?.length){M+=`c.response= r
240
+ `;for(let b=0;b<W.mapResponse.length;b++){let c=W.mapResponse[b],t=R.resolveChild(c.fn.name);M+=`if(mr===undefined){mr=${P4(c)?"await ":""}e.mapResponse[${b}](c)
241
+ if(mr!==undefined)r=c.response=mr}`,t()}}if(R.resolve(),M+=e,W1)M+=`return mapResponse(${I2}r,c.set${S0})
242
+ `;else M+=`return mapCompactResponse(${I2}r${S0})
243
+ `}else{F.resolve();let R=W6?`await ${S}`:S;if(n0("afterHandle").resolve(),Z instanceof Response)M+=A.set?`if(isNotEmpty(c.set.headers)||c.set.status!==200||c.set.redirect||c.set.cookie)return mapResponse(${I2}${S}.clone(),c.set${S0})
244
+ else return ${S}.clone()
245
+ `:`return ${S}.clone()
246
+ `;else if(W1)M+=`return mapResponse(${I2}${R},c.set${S0})
247
+ `;else M+=`return mapCompactResponse(${I2}${R}${S0})
248
+ `}}if(M+=`
249
+ }catch(error){`,a)M+=`if(isParsing)error=new ParseError()
250
+ `;if(!K6)M+="return(async()=>{";if(M+=`const set=c.set
244
251
  if(!set.status||set.status<300)set.status=error?.status||500
245
- `,R)for(let j=0;j<A.trace.length;j++)J+=`report${j}?.resolve(error);reportChild${j}?.(error)
246
- `;let q2=C0("error",{total:A.error.length});if(A.error.length){J+=`c.error=error
247
- if(error instanceof TypeBoxError){c.code="VALIDATION"
248
- c.set.status=422}else{c.code=error.code??error[ERROR_CODE]??"UNKNOWN"}let er
249
- `;for(let j=0;j<A.error.length;j++){let O=q2.resolveChild(A.error[j].fn.name);if(a0(A.error[j]))J+=`er=await handleErrors[${j}](c)
250
- `;else J+=`er=handleErrors[${j}](c)
252
+ `,O&&W.trace)for(let F=0;F<W.trace.length;F++)M+=`report${F}?.resolve(error);reportChild${F}?.(error)
253
+ `;let X6=n0("error",{total:W.error?.length});if(W.error?.length){if(M+=`c.error=error
254
+ `,C)M+=`if(error instanceof TypeBoxError){c.code="VALIDATION"
255
+ c.set.status=422}else{c.code=error.code??error[ERROR_CODE]??"UNKNOWN"}`;else M+=`c.code=error.code??error[ERROR_CODE]??"UNKNOWN"
256
+ `;M+=`let er
257
+ `;for(let F=0;F<W.error.length;F++){let R=X6.resolveChild(W.error[F].fn.name);if(a0(W.error[F]))M+=`er=await e.error[${F}](c)
258
+ `;else M+=`er=e.error[${F}](c)
251
259
  if(er instanceof Promise)er=await er
252
- `;O();let b=C0("mapResponse",{total:A.mapResponse.length});if(A.mapResponse.length)for(let T=0;T<A.mapResponse.length;T++){let t=A.mapResponse[T],e=b.resolveChild(t.fn.name);J+=`c.response=er
253
- er=onMapResponse[${T}](c)
260
+ `;R();let b=n0("mapResponse",{total:W.mapResponse?.length});if(W.mapResponse?.length)for(let c=0;c<W.mapResponse.length;c++){let t=W.mapResponse[c],B=b.resolveChild(t.fn.name);M+=`c.response=er
261
+ er=e.mapResponse[${c}](c)
254
262
  if(er instanceof Promise)er=await er
255
- `,e()}if(b.resolve(),J+=`er=mapEarlyResponse(er,set${o0})
256
- `,J+="if(er){",R){for(let T=0;T<A.trace.length;T++)J+=`report${T}.resolve()
257
- `;q2.resolve()}J+="return er}"}}if(q2.resolve(),J+="return handleError(c,error,true)",!Y6)J+="})()";if(J+="}",F||R){if(J+="finally{ ",!Y6)J+=";(async()=>{";let j=C0("afterResponse",{total:A.afterResponse.length});if(F)for(let O=0;O<A.afterResponse.length;O++){let b=j.resolveChild(A.afterResponse[O].fn.name);J+=`
258
- await afterResponse[${O}](c)
259
- `,b()}if(j.resolve(),!Y6)J+="})()";J+="}"}let x2="const {handler,handleError,hooks: {transform,resolve,beforeHandle,afterHandle,mapResponse: onMapResponse,parse,error: handleErrors,afterResponse,trace: _trace},validator,utils: {mapResponse,mapCompactResponse,mapEarlyResponse,parseQuery,parseQueryFromURL,isNotEmpty},error: {NotFoundError,ValidationError,InternalServerError,ParseError},schema,definitions,ERROR_CODE,parseCookie,signCookie,decodeURIComponent,ElysiaCustomStatusResponse,ELYSIA_TRACE,ELYSIA_REQUEST_ID,parser,getServer,"+(B.inject?Object.keys(B.inject).join(",")+",":"")+`TypeBoxError}=hooks
260
- const trace=_trace.map(x=>typeof x==='function'?x:x.fn)
261
- return ${Y6?"async ":""}function handle(c){`;if(A.beforeHandle.length)x2+=`let be
262
- `;if(A.afterHandle.length)x2+=`let af
263
- `;if(A.mapResponse.length)x2+=`let mr
264
- `;if($)x2+=`c.schema = schema
263
+ `,B()}if(b.resolve(),M+=`er=mapEarlyResponse(er,set${S0})
264
+ `,M+="if(er){",O&&W.trace){for(let c=0;c<W.trace.length;c++)M+=`report${c}.resolve()
265
+ `;X6.resolve()}M+="return er}"}}if(X6.resolve(),M+="return handleError(c,error,true)",!K6)M+="})()";if(M+="}",N||O){if(M+="finally{ ",!K6)M+=";(async()=>{";let F=n0("afterResponse",{total:W.afterResponse?.length});if(N&&W.afterResponse)for(let R=0;R<W.afterResponse.length;R++){let b=F.resolveChild(W.afterResponse[R].fn.name);M+=`
266
+ await e.afterResponse[${R}](c)
267
+ `,b()}if(F.resolve(),!K6)M+="})()";M+="}"}let Z6=Y.inject?Object.keys(Y.inject).join(",")+",":"",X1="const {handler,handleError,hooks:e, "+Q2("validator,",C)+"mapResponse,mapCompactResponse,mapEarlyResponse,isNotEmpty,utils:{"+Q2("parseQuery,",a)+Q2("parseQueryFromURL,",g)+"},error:{"+Q2("ValidationError,",C)+"InternalServerError,"+Q2("ParseError",a)+"},schema,definitions,ERROR_CODE,"+Q2("parseCookie,",V)+Q2("signCookie,",V)+Q2("decodeURIComponent,",g)+"ElysiaCustomStatusResponse,"+Q2("ELYSIA_TRACE,",O)+Q2("ELYSIA_REQUEST_ID,",O)+Q2("parser,",W.parse?.length)+Q2("getServer,",A.server)+Z6+Q2("TypeBoxError",C)+`}=hooks
268
+ const trace=e.trace?.map(x=>typeof x==='function'?x:x.fn)??[]
269
+ return ${K6?"async ":""}function handle(c){`;if(W.beforeHandle?.length)X1+=`let be
270
+ `;if(W.afterHandle?.length)X1+=`let af
271
+ `;if(W.mapResponse?.length)X1+=`let mr
272
+ `;if($)X1+=`c.schema = schema
265
273
  c.defs = definitions
266
- `;x2+=J+"}";try{if(Y)return Function("hooks",x2);return Function("hooks",x2)({handler:Z,hooks:DU(A),validator:X,handleError:w.handleError,utils:{mapResponse:G.mapResponse,mapCompactResponse:G.mapCompactResponse,mapEarlyResponse:G.mapEarlyResponse,parseQuery:x8,parseQueryFromURL:TH,isNotEmpty:s2},error:{NotFoundError:h8,ValidationError:Z0,InternalServerError:fU,ParseError:dU},schema:w.router.history,definitions:w.definitions.type,ERROR_CODE:k8,parseCookie:tU,signCookie:V8,decodeURIComponent:sU.default,ElysiaCustomStatusResponse:M1,ELYSIA_TRACE:vw,ELYSIA_REQUEST_ID:d8,getServer:()=>w.getServer(),TypeBoxError:y,parser:w["~parser"],...B.inject})}catch(j){let O=DU(A);console.log("[Composer] failed to generate optimized handler"),console.log("---"),console.log({handler:typeof Z==="function"?Z.toString():Z,instruction:x2,hooks:{...O,transform:O?.transform?.map?.((b)=>b.toString()),resolve:O?.resolve?.map?.((b)=>b.toString()),beforeHandle:O?.beforeHandle?.map?.((b)=>b.toString()),afterHandle:O?.afterHandle?.map?.((b)=>b.toString()),mapResponse:O?.mapResponse?.map?.((b)=>b.toString()),parse:O?.parse?.map?.((b)=>b.toString()),error:O?.error?.map?.((b)=>b.toString()),afterResponse:O?.afterResponse?.map?.((b)=>b.toString()),stop:O?.stop?.map?.((b)=>b.toString())},validator:X,definitions:w.definitions.type,error:j,fnLiteral:J}),console.log("---"),process.exit(1)}},Tw=(w,{asManifest:z=!1}={})=>{let U=w["~adapter"].composeGeneralHandler,W=U.error404(!!w.event.request.length,!!w.event.error.length),A="",X=w.router,Z="const route=router.find(r.method,p)";Z+=X.http.root.ALL?`??router.find("ALL",p)
274
+ `;X1+=M+"}";try{if(Q)return Function("hooks",X1);return Function("hooks",X1)({handler:Z,hooks:FU(W),validator:C?X:void 0,handleError:z.handleError,mapResponse:J.mapResponse,mapCompactResponse:J.mapCompactResponse,mapEarlyResponse:J.mapEarlyResponse,isNotEmpty:z1,utils:{parseQuery:a?o8:void 0,parseQueryFromURL:g?YG:void 0},error:{ValidationError:C?r:void 0,InternalServerError:tU,ParseError:a?oU:void 0},schema:z.router.history,definitions:z.definitions.type,ERROR_CODE:s8,parseCookie:V?WW:void 0,signCookie:V?l8:void 0,decodeURIComponent:g?S6:void 0,ElysiaCustomStatusResponse:b1,ELYSIA_TRACE:O?ww:void 0,ELYSIA_REQUEST_ID:O?z5:void 0,getServer:()=>z.getServer(),TypeBoxError:C?n:void 0,parser:z["~parser"],...Y.inject})}catch(F){let R=FU(W);console.log("[Composer] failed to generate optimized handler"),console.log("---"),console.log({handler:typeof Z==="function"?Z.toString():Z,instruction:X1,hooks:{...R,transform:R?.transform?.map?.((b)=>b.toString()),resolve:R?.resolve?.map?.((b)=>b.toString()),beforeHandle:R?.beforeHandle?.map?.((b)=>b.toString()),afterHandle:R?.afterHandle?.map?.((b)=>b.toString()),mapResponse:R?.mapResponse?.map?.((b)=>b.toString()),parse:R?.parse?.map?.((b)=>b.toString()),error:R?.error?.map?.((b)=>b.toString()),afterResponse:R?.afterResponse?.map?.((b)=>b.toString()),stop:R?.stop?.map?.((b)=>b.toString())},validator:X,definitions:z.definitions.type,error:F,fnLiteral:M}),console.log("---"),process.exit(1)}},tz=(z,{asManifest:w=!1}={})=>{let U=z["~adapter"].composeGeneralHandler;z.router.http.build();let W=U.error404(!!z.event.request?.length,!!z.event.error?.length),X=z.event.trace?.length,Z="",$=z.router,A="const route=router.find(r.method,p)";A+=$.http.root.ALL?`??router.find("ALL",p)
267
275
  `:`
268
- `,Z+=W.code,Z+=`
276
+ `,A+=W.code,A+=`
269
277
  c.params=route.params
270
278
  if(route.store.handler)return route.store.handler(c)
271
279
  return (route.store.handler=route.store.compile())(c)
272
- `;let $="";for(let[_,{code:H,all:F}]of Object.entries(X.static.http.map)){if($+=`case'${_}':`,w.config.strictPath!==!0)$+=`case'${r6(_)}':`;$+=`switch(r.method){${H}
273
- `+(F??"default: break map")+"}"}let Q=w.event.request.some(a0),Y=U.inject?Object.keys(U.inject).join(",")+",":"";if(A+=`
274
- const {app,mapEarlyResponse,NotFoundError,randomId,handleError,error,redirect,ELYSIA_TRACE,ELYSIA_REQUEST_ID,`+Y+`getServer}=data
280
+ `;let Q="";for(let[N,O]of Object.entries($.static.http.map)){if(Q+=`case'${N}':`,z.config.strictPath!==!0)Q+=`case'${S4(N)}':`;let M=p4(N);if(N!==M)Q+=`case'${M}':`;Q+=`switch(r.method){${O.code}
281
+ `+(O.all??"default: break map")+"}"}let Y=!!z.event.request?.some(a0),J=U.inject?Object.keys(U.inject).join(",")+",":"";if(Z+=`
282
+ const {app,mapEarlyResponse,NotFoundError,randomId,handleError,error,redirect,`+Q2("ELYSIA_TRACE,",X)+Q2("ELYSIA_REQUEST_ID,",X)+J+`}=data
275
283
  const store=app.singleton.store
276
284
  const decorator=app.singleton.decorator
277
285
  const staticRouter=app.router.static.http
278
286
  const ht=app.router.history
279
- const wsRouter=app.router.ws
280
287
  const router=app.router.http
281
- const trace=app.event.trace.map(x=>typeof x==='function'?x:x.fn)
288
+ const trace=app.event.trace?.map(x=>typeof x==='function'?x:x.fn)??[]
282
289
  const notFound=new NotFoundError()
283
290
  const hoc=app.extender.higherOrderFunctions.map(x=>x.fn)
284
- `,w.event.request.length)A+=`const onRequest=app.event.request.map(x=>x.fn)
285
- `;if(A+=W.declare,w.event.trace.length)A+="const "+w.event.trace.map((_,H)=>`tr${H}=app.event.trace[${H}].fn`).join(",")+`
286
- `;if(A+=`${Q?"async ":""}function map(${U.parameters}){`,w.event.request.length)A+=`let re
287
- `;if(A+=U.createContext(w),w.event.trace.length)A+="c[ELYSIA_TRACE]=["+w.event.trace.map((_,H)=>`tr${H}(c)`).join(",")+`]
288
- `;let B=nw({trace:w.event.trace,addFn(_){A+=_}})("request",{total:w.event.request.length});if(w.event.request.length){A+="try{";for(let _=0;_<w.event.request.length;_++){let H=w.event.request[_],F=T4(H),R=a0(H),J=B.resolveChild(w.event.request[_].fn.name);if(F)A+=`re=mapEarlyResponse(${R?"await ":""}onRequest[${_}](c),c.set)
289
- `,J("re"),A+=`if(re!==undefined)return re
290
- `;else A+=`${R?"await ":""}onRequest[${_}](c)
291
- `,J()}A+="}catch(error){return app.handleError(c,error,false)}"}if(B.resolve(),A+=U.websocket(w),A+=`
291
+ `,z.event.request?.length)Z+=`const onRequest=app.event.request.map(x=>x.fn)
292
+ `;if(Z+=W.declare,z.event.trace?.length)Z+="const "+z.event.trace.map((N,O)=>`tr${O}=app.event.trace[${O}].fn`).join(",")+`
293
+ `;if(Z+=`${Y?"async ":""}function map(${U.parameters}){`,z.event.request?.length)Z+=`let re
294
+ `;if(Z+=U.createContext(z),z.event.trace?.length)Z+="c[ELYSIA_TRACE]=["+z.event.trace.map((N,O)=>`tr${O}(c)`).join(",")+`]
295
+ `;let G=Uw({trace:z.event.trace,addFn(N){Z+=N}})("request",{total:z.event.request?.length});if(z.event.request?.length){Z+="try{";for(let N=0;N<z.event.request.length;N++){let O=z.event.request[N],M=r4(O),C=a0(O),g=G.resolveChild(z.event.request[N].fn.name);if(M)Z+=`re=mapEarlyResponse(${C?"await ":""}onRequest[${N}](c),c.set)
296
+ `,g("re"),Z+=`if(re!==undefined)return re
297
+ `;else Z+=`${C?"await ":""}onRequest[${N}](c)
298
+ `,g()}Z+="}catch(error){return app.handleError(c,error,false)}"}if(G.resolve(),Z+=U.websocket(z),Z+=`
292
299
  map:switch(p){
293
- `+$+"default:break}"+Z+`}
294
- `,w.extender.higherOrderFunctions.length){let _="map";for(let H=0;H<w.extender.higherOrderFunctions.length;H++)_=`hoc[${H}](${_},${U.parameters})`;A+=`return function hocMap(${U.parameters}){return ${_}(${U.parameters})}`}else A+="return map";let G=rU(w);return w.handleError=G,Function("data",A)({app:w,mapEarlyResponse:w["~adapter"].handler.mapEarlyResponse,NotFoundError:h8,randomId:gU,handleError:G,error:LH,redirect:TU,ELYSIA_TRACE:vw,ELYSIA_REQUEST_ID:d8,getServer:()=>w.getServer(),...U.inject})},rU=(w)=>{let z=w.event,U="",W=w["~adapter"].composeError,A=W.inject?Object.keys(W.inject).join(",")+",":"";U+="const {app:{event:{error:onErrorContainer,afterResponse:resContainer,mapResponse:_onMapResponse,trace:_trace}},mapResponse,ERROR_CODE,ElysiaCustomStatusResponse,ELYSIA_TRACE,"+A+`ELYSIA_REQUEST_ID}=inject
295
- `,U+=`const trace=_trace.map(x=>typeof x==='function'?x:x.fn)
300
+ `+Q+"default:break}"+A+`}
301
+ `,z.extender.higherOrderFunctions.length){let N="map";for(let O=0;O<z.extender.higherOrderFunctions.length;O++)N=`hoc[${O}](${N},${U.parameters})`;Z+=`return function hocMap(${U.parameters}){return ${N}(${U.parameters})}`}else Z+="return map";let S=AW(z);return z.handleError=S,Function("data",Z)({app:z,mapEarlyResponse:z["~adapter"].handler.mapEarlyResponse,NotFoundError:zw,randomId:uU,handleError:S,error:mU,redirect:nU,ELYSIA_TRACE:X?ww:void 0,ELYSIA_REQUEST_ID:X?z5:void 0,...U.inject})},AW=(z)=>{let w=z.event,U="",W=z["~adapter"].composeError,X=W.inject?Object.keys(W.inject).join(",")+",":"",Z=!!z.event.trace?.length;if(U+="const {app:{event:{error:onErrorContainer,afterResponse:resContainer,mapResponse:_onMapResponse,trace:_trace}},mapResponse,ERROR_CODE,ElysiaCustomStatusResponse,"+Q2("ELYSIA_TRACE,",Z)+Q2("ELYSIA_REQUEST_ID,",Z)+X+`}=inject
302
+ `,U+=`const trace=_trace?.map(x=>typeof x==='function'?x:x.fn)??[]
296
303
  const onMapResponse=[]
297
- for(let i=0;i<_onMapResponse.length;i++)onMapResponse.push(_onMapResponse[i].fn??_onMapResponse[i])
304
+ if(_onMapResponse)for(let i=0;i<_onMapResponse.length;i++)onMapResponse.push(_onMapResponse[i].fn??_onMapResponse[i])
298
305
  delete _onMapResponse
299
- const onError=onErrorContainer.map(x=>x.fn)
300
- const res=resContainer.map(x=>x.fn)
301
- return ${w.event.error.find(a0)||w.event.mapResponse.find(a0)?"async ":""}function(context,error,skipGlobal){`;let X=w.event.trace.length>0;if(U+="",X)U+=`const id=context[ELYSIA_REQUEST_ID]
302
- `;let Z=nw({context:"context",trace:z.trace,addFn:(Y)=>{U+=Y}});if(U+=`const set=context.set
306
+ const onError=onErrorContainer?.map(x=>x.fn)??[]
307
+ const res=resContainer?.map(x=>x.fn)??[]
308
+ return ${z.event.error?.find(a0)||z.event.mapResponse?.find(a0)?"async ":""}function(context,error,skipGlobal){`,U+="",Z)U+=`const id=context[ELYSIA_REQUEST_ID]
309
+ `;let $=Uw({context:"context",trace:w.trace,addFn:(Y)=>{U+=Y}});if(U+=`const set=context.set
303
310
  let _r
304
311
  if(!context.code)context.code=error.code??error[ERROR_CODE]
305
312
  if(!(context.error instanceof Error))context.error=error
306
313
  if(error instanceof ElysiaCustomStatusResponse){set.status=error.status=error.code
307
- error.message=error.response}`,W.declare)U+=W.declare;let $=X||z.afterResponse.length>0||z.afterResponse.length>0?"context.response = ":"";for(let Y=0;Y<w.event.error.length;Y++){let B=w.event.error[Y],G=`${a0(B)?"await ":""}onError[${Y}](context)
308
- `;if(U+="if(skipGlobal!==true){",T4(B)){U+=`_r=${G}
314
+ error.message=error.response}`,W.declare)U+=W.declare;let A=Z||!!w.afterResponse?.length||!!w.afterResponse?.length?"context.response = ":"";if(z.event.error)for(let Y=0;Y<z.event.error.length;Y++){let J=z.event.error[Y],G=`${a0(J)?"await ":""}onError[${Y}](context)
315
+ `;if(U+="if(skipGlobal!==true){",r4(J)){U+=`_r=${G}
309
316
  if(_r!==undefined){if(_r instanceof Response)return mapResponse(_r,set${W.mapResponseContext})
310
317
  if(_r instanceof ElysiaCustomStatusResponse){error.status=error.code
311
318
  error.message = error.response}if(set.status===200||!set.status)set.status=error.status
312
- `;let _=Z("mapResponse",{total:z.mapResponse.length,name:"context"});if(z.mapResponse.length)for(let H=0;H<z.mapResponse.length;H++){let F=z.mapResponse[H],R=_.resolveChild(F.fn.name);U+=`context.response=_r_r=${e6(F)?"await ":""}onMapResponse[${H}](context)
313
- `,R()}_.resolve(),U+=`return mapResponse(${$}_r,set${W.mapResponseContext})}`}else U+=G;U+="}"}U+=`if(error.constructor.name==="ValidationError"||error.constructor.name==="TransformDecodeError"){if(error.error)error=error.error
319
+ `;let S=$("mapResponse",{total:w.mapResponse?.length,name:"context"});if(w.mapResponse?.length)for(let N=0;N<w.mapResponse.length;N++){let O=w.mapResponse[N],M=S.resolveChild(O.fn.name);U+=`context.response=_r_r=${P4(O)?"await ":""}onMapResponse[${N}](context)
320
+ `,M()}S.resolve(),U+=`return mapResponse(${A}_r,set${W.mapResponseContext})}`}else U+=G;U+="}"}U+=`if(error.constructor.name==="ValidationError"||error.constructor.name==="TransformDecodeError"){if(error.error)error=error.error
314
321
  set.status=error.status??422
315
- `+W.validationError+"}",U+="if(error instanceof Error){"+W.unknownError+"}";let Q=Z("mapResponse",{total:z.mapResponse.length,name:"context"});if(U+=`
322
+ `+W.validationError+"}",U+="if(error instanceof Error){"+W.unknownError+"}";let Q=$("mapResponse",{total:w.mapResponse?.length,name:"context"});if(U+=`
316
323
  if(!context.response)context.response=error.message??error
317
- `,z.mapResponse.length){U+=`let mr
318
- `;for(let Y=0;Y<z.mapResponse.length;Y++){let B=z.mapResponse[Y],G=Q.resolveChild(B.fn.name);U+=`if(mr===undefined){mr=${e6(B)?"await ":""}onMapResponse[${Y}](context)
324
+ `,w.mapResponse?.length){U+=`let mr
325
+ `;for(let Y=0;Y<w.mapResponse.length;Y++){let J=w.mapResponse[Y],G=Q.resolveChild(J.fn.name);U+=`if(mr===undefined){mr=${P4(J)?"await ":""}onMapResponse[${Y}](context)
319
326
  if(mr!==undefined)error=context.response=mr}`,G()}}return Q.resolve(),U+=`
320
- return mapResponse(${$}error,set${W.mapResponseContext})}`,Function("inject",U)({app:w,mapResponse:w["~adapter"].handler.mapResponse,ERROR_CODE:k8,ElysiaCustomStatusResponse:M1,ELYSIA_TRACE:vw,ELYSIA_REQUEST_ID:d8,...W.inject})},gw=(w,z)=>{for(let[U,W]of Object.entries(w.schema.properties))z[U]??=W.default},jU=(w)=>{let{mapResponse:z,mapEarlyResponse:U}=w["~adapter"].handler;return async(W)=>{let A=W.url,X=A.indexOf("/",11),Z=A.indexOf("?",X+1),$=Z===-1?A.substring(X):A.substring(X,Z),Q={cookie:{},status:200,headers:{}},Y=Object.assign({},w.singleton.decorator,{set:Q,store:w.singleton.store,request:W,path:$,qi:Z,redirect:TU});try{for(let x=0;x<w.event.request.length;x++){let i=w.event.request[x].fn,K=i(Y);if(K instanceof Promise)K=await K;if(K=U(K,Q),K)return Y.response=K}let B=w.router.dynamic.find(W.method,$)??w.router.dynamic.find("ALL",$);if(!B)throw new h8;let{handle:G,hooks:_,validator:H,content:F}=B.store,R;if(W.method!=="GET"&&W.method!=="HEAD")if(F)switch(F){case"application/json":R=await W.json();break;case"text/plain":R=await W.text();break;case"application/x-www-form-urlencoded":R=x8(await W.text());break;case"application/octet-stream":R=await W.arrayBuffer();break;case"multipart/form-data":R={};let x=await W.formData();for(let i of x.keys()){if(R[i])continue;let K=x.getAll(i);if(K.length===1)R[i]=K[0];else R[i]=K}break}else{let x=W.headers.get("content-type");if(x){let i=x.indexOf(";");if(i!==-1)x=x.slice(0,i);Y.contentType=x;for(let K=0;K<_.parse.length;K++){let o=_.parse[K].fn,D0=o(Y,x);if(D0 instanceof Promise)D0=await D0;if(D0){R=D0;break}}if(delete Y.contentType,R===void 0)switch(x){case"application/json":R=await W.json();break;case"text/plain":R=await W.text();break;case"application/x-www-form-urlencoded":R=x8(await W.text());break;case"application/octet-stream":R=await W.arrayBuffer();break;case"multipart/form-data":R={};let K=await W.formData();for(let o of K.keys()){if(R[o])continue;let D0=K.getAll(o);if(D0.length===1)R[o]=D0[0];else R[o]=D0}break}}}Y.body=R,Y.params=B?.params||void 0,Y.query=Z===-1?{}:x8(A.substring(Z+1)),Y.headers={};for(let[x,i]of W.headers.entries())Y.headers[x]=i;let J=Object.assign({},w.config?.cookie,H?.cookie?.config),m=W.headers.get("cookie");Y.cookie=await tU(Y.set,m,J?{secrets:J.secrets!==void 0?typeof J.secrets==="string"?J.secrets:J.secrets.join(","):void 0,sign:J.sign===!0?!0:J.sign!==void 0?typeof J.sign==="string"?J.sign:J.sign.join(","):void 0}:void 0);let A0=H?.createHeaders?.();if(A0)gw(A0,Y.headers);let L0=H?.createParams?.();if(L0)gw(L0,Y.params);let h=H?.createQuery?.();if(h)gw(h,Y.query);for(let x=0;x<_.transform.length;x++){let i=_.transform[x],K=i.fn(Y);if(i.subType==="derive")if(K instanceof Promise)Object.assign(Y,await K);else Object.assign(Y,K);else if(K instanceof Promise)await K}if(H){if(A0){let x=structuredClone(Y.headers);for(let[i,K]of W.headers)x[i]=K;if(H.headers.Check(x)===!1)throw new Z0("header",H.headers,x)}else if(H.headers?.Decode)Y.headers=H.headers.Decode(Y.headers);if(L0?.Check(Y.params)===!1)throw new Z0("params",H.params,Y.params);else if(H.params?.Decode)Y.params=H.params.Decode(Y.params);if(h?.Check(Y.query)===!1)throw new Z0("query",H.query,Y.query);else if(H.query?.Decode)Y.query=H.query.Decode(Y.query);if(H.createCookie?.()){let x={};for(let[i,K]of Object.entries(Y.cookie))x[i]=K.value;if(H.cookie.Check(x)===!1)throw new Z0("cookie",H.cookie,x);else if(H.cookie?.Decode)x=H.cookie.Decode(x)}if(H.createBody?.()?.Check(R)===!1)throw new Z0("body",H.body,R);else if(H.body?.Decode)Y.body=H.body.Decode(R)}for(let x=0;x<_.beforeHandle.length;x++){let i=_.beforeHandle[x],K=i.fn(Y);if(i.subType==="resolve"){if(K instanceof M1){let o=U(K,Y.set);if(o)return Y.response=o}if(K instanceof Promise)Object.assign(Y,await K);else Object.assign(Y,K);continue}else if(K instanceof Promise)K=await K;if(K!==void 0){Y.response=K;for(let D0=0;D0<_.afterHandle.length;D0++){let l=_.afterHandle[D0].fn(Y);if(l instanceof Promise)l=await l;if(l)K=l}let o=U(K,Y.set);if(o)return Y.response=o}}let a=typeof G==="function"?G(Y):G;if(a instanceof Promise)a=await a;if(!_.afterHandle.length){let x=a instanceof M1?a.code:Q.status?typeof Q.status==="string"?f8[Q.status]:Q.status:200,i=H?.createResponse?.()?.[x];if(i?.Check(a)===!1)throw new Z0("response",i,a);else if(i?.Decode)a=i.Decode(a)}else{Y.response=a;for(let x=0;x<_.afterHandle.length;x++){let i=_.afterHandle[x].fn(Y);if(i instanceof Promise)i=await i;let K=U(i,Y.set);if(K!==void 0){let o=H?.response?.[K.status];if(o?.Check(K)===!1)throw new Z0("response",o,K);else if(o?.Decode)a=o.Decode(a);return Y.response=K}}}if(Y.set.cookie&&J?.sign){let x=!J.secrets?void 0:typeof J.secrets==="string"?J.secrets:J.secrets[0];if(J.sign===!0)for(let[i,K]of Object.entries(Y.set.cookie))Y.set.cookie[i].value=await V8(K.value,"${secret}");else{let i=H?.cookie?.schema?.properties;for(let K of J.sign){if(!(K in i))continue;if(Y.set.cookie[K]?.value)Y.set.cookie[K].value=await V8(Y.set.cookie[K].value,x)}}}return z(Y.response=a,Y.set)}catch(B){let G=B instanceof L8&&B.error?B.error:B;return w.handleError(Y,G)}finally{for(let B of w.event.afterResponse)await B.fn(Y)}}},cH=(w)=>{let{mapResponse:z}=w["~adapter"].handler;return async(U,W)=>{let A=Object.assign(U,{error:W,code:W.code});A.set=U.set;for(let X=0;X<w.event.error.length;X++){let Z=w.event.error[X].fn(A);if(Z instanceof Promise)Z=await Z;if(Z!==void 0&&Z!==null)return U.response=z(Z,U.set)}return new Response(typeof W.cause==="string"?W.cause:W.message,{headers:U.set.headers,status:W.status??500})}};class j0{config;server=null;dependencies={};_routes={};_types={Prefix:"",Singleton:{},Definitions:{},Metadata:{}};_ephemeral={};_volatile={};singleton={decorator:{},store:{},derive:{},resolve:{}};get store(){return this.singleton.store}get decorator(){return this.singleton.decorator}definitions={typebox:I.Module({}),type:{},error:{}};extender={macros:[],higherOrderFunctions:[]};validator={global:null,scoped:null,local:null,getCandidate(){return I4(I4(this.global,this.scoped),this.local)}};event={start:[],request:[],parse:[],transform:[],beforeHandle:[],afterHandle:[],mapResponse:[],afterResponse:[],trace:[],error:[],stop:[]};telemetry={stack:void 0};router={http:new u1,ws:new u1,dynamic:new u1,static:{http:{static:{},map:{},all:""},ws:{}},history:[]};routeTree=new Map;get routes(){return this.router.history}getGlobalRoutes(){return this.router.history}inference={body:!1,cookie:!1,headers:!1,query:!1,set:!1,server:!1,request:!1,route:!1};getServer(){return this.server}"~parser"={};_promisedModules;get promisedModules(){if(!this._promisedModules)this._promisedModules=new kU;return this._promisedModules}constructor(w={}){if(w.tags)if(!w.detail)w.detail={tags:w.tags};else w.detail.tags=w.tags;if(w.nativeStaticResponse===void 0)w.nativeStaticResponse=!0;if(this.config={},this.applyConfig(w??{}),this["~adapter"]=w.adapter??(typeof Bun!=="undefined"?VH:I8),w?.analytic&&(w?.name||w?.seed!==void 0))this.telemetry.stack=new Error().stack}"~adapter";env(w,z=FU){if(j2(w,{modules:this.definitions.typebox,dynamic:!0,additionalProperties:!0,coerce:!0}).Check(z)===!1){let U=new Z0("env",w,z);throw new Error(U.all.map((W)=>W.summary).join(`
321
- `))}return this}wrap(w){return this.extender.higherOrderFunctions.push({checksum:x4(JSON.stringify({name:this.config.name,seed:this.config.seed,content:w.toString()})),fn:w}),this}applyMacro(w){if(this.extender.macros.length){let z=qH({globalHook:this.event,localHook:w}),U={events:{global:this.event,local:w},get onParse(){return z("parse")},get onTransform(){return z("transform")},get onBeforeHandle(){return z("beforeHandle")},get onAfterHandle(){return z("afterHandle")},get mapResponse(){return z("mapResponse")},get onAfterResponse(){return z("afterResponse")},get onError(){return z("error")}};for(let W of this.extender.macros)MH(W.fn(U),w,z)}}applyConfig(w){return this.config={prefix:"",aot:FU.ELYSIA_AOT!=="false",normalize:!0,...w,cookie:{path:"/",...w?.cookie},experimental:w?.experimental??{},seed:w?.seed===void 0?"":w?.seed},this}get models(){let w={};for(let z of Object.keys(this.definitions.type))w[z]=j2(this.definitions.typebox.Import(z));return w.modules=this.definitions.typebox,w}add(w,z,U,W,{allowMeta:A=!1,skipPrefix:X=!1}={allowMeta:!1,skipPrefix:!1}){if(W=GH(W),z!==""&&z.charCodeAt(0)!==47)z="/"+z;if(this.config.prefix&&!X)z=this.config.prefix+z;if(W?.type)switch(W.type){case"text":W.type="text/plain";break;case"json":W.type="application/json";break;case"formdata":W.type="multipart/form-data";break;case"urlencoded":W.type="application/x-www-form-urlencoded";break;case"arrayBuffer":W.type="application/octet-stream";break;default:break}let Z=this.definitions.type,$=!this.config.aot,Q={...this.validator.getCandidate()},Y={body:W?.body??Q?.body,headers:W?.headers??Q?.headers,params:W?.params??Q?.params,query:W?.query??Q?.query,cookie:W?.cookie??Q?.cookie,response:W?.response??Q?.response},B=()=>Y.cookie?VU({modules:_,validator:Y.cookie,defaultConfig:this.config.cookie,config:Y.cookie?.config??{},dynamic:$,models:Z}):void 0,G=this.config.normalize,_=this.definitions.typebox,H=this.config.precompile===!0||typeof this.config.precompile==="object"&&this.config.precompile.schema===!0?{body:j2(Y.body,{modules:_,dynamic:$,models:Z,normalize:G,additionalCoerce:HU()}),headers:j2(Y.headers,{modules:_,dynamic:$,models:Z,additionalProperties:!this.config.normalize,coerce:!0,additionalCoerce:P6()}),params:j2(Y.params,{modules:_,dynamic:$,models:Z,coerce:!0,additionalCoerce:P6()}),query:j2(Y.query,{modules:_,dynamic:$,models:Z,normalize:G,coerce:!0,additionalCoerce:P6()}),cookie:B(),response:qU(Y.response,{modules:_,dynamic:$,models:Z,normalize:G})}:{createBody(){if(this.body)return this.body;return this.body=j2(Y.body,{modules:_,dynamic:$,models:Z,normalize:G,additionalCoerce:HU()})},createHeaders(){if(this.headers)return this.headers;return this.headers=j2(Y.headers,{modules:_,dynamic:$,models:Z,additionalProperties:!G,coerce:!0,additionalCoerce:P6()})},createParams(){if(this.params)return this.params;return this.params=j2(Y.params,{modules:_,dynamic:$,models:Z,coerce:!0,additionalCoerce:P6()})},createQuery(){if(this.query)return this.query;return this.query=j2(Y.query,{modules:_,dynamic:$,models:Z,coerce:!0,additionalCoerce:P6()})},createCookie(){if(this.cookie)return this.cookie;return this.cookie=B()},createResponse(){if(this.response)return this.response;return this.response=qU(Y.response,{modules:_,dynamic:$,models:Z,normalize:G})}};if(W=D1(W,Q),W.tags)if(!W.detail)W.detail={tags:W.tags};else W.detail.tags=W.tags;if(s2(this.config.detail))W.detail=F2(Object.assign({},this.config.detail),W.detail);this.applyMacro(W);let F=D1(this.event,W);if(this.config.aot===!1){if(this.router.dynamic.add(w,z,{validator:H,hooks:F,content:W?.type,handle:U}),this.config.strictPath===!1)this.router.dynamic.add(w,r6(z),{validator:H,hooks:F,content:W?.type,handle:U});this.router.history.push({method:w,path:z,composed:null,handler:U,hooks:F,compile:U});return}let R=this.config.precompile===!0||typeof this.config.precompile==="object"&&this.config.precompile.compose===!0,J=Vw(this.inference),m=this["~adapter"].handler,A0=typeof U!=="function"&&typeof m.createStaticHandler==="function"?m.createStaticHandler(U,F,this.setHeaders):void 0,L0=typeof U!=="function"?m.createNativeStaticHandler?.(U,F,this.setHeaders):void 0;if(this.config.nativeStaticResponse===!0&&L0&&(w==="GET"||w==="ALL"))this.router.static.http.static[z]=L0();let h=(l=!1)=>yH({app:this,path:z,method:w,localHook:D1(W),hooks:F,validator:H,handler:typeof U!=="function"&&typeof m.createStaticHandler!=="function"?()=>U:U,allowMeta:A,inference:J,asManifest:l});if(this.routeTree.has(w+z))for(let l=0;l<this.router.history.length;l++){let O1=this.router.history[l];if(O1.path===z&&O1.method===w){let C0=this.router.history.splice(l,1)[0];if(C0&&this.routeTree.has(C0?.method+C0?.path))this.routeTree.delete(C0.method+C0.path)}}else this.routeTree.set(w+z,this.router.history.length);let a=this.router.history,x=this.router.history.length,i=R?h():(l)=>(a[x].composed=h())(l),K=w==="$INTERNALWS";this.router.history.push({method:w,path:z,composed:i,handler:U,hooks:F,compile:()=>h(),websocket:W.websocket});let o=this.router.static.http,D0={handler:R?i:void 0,compile:h};if(K){let l=r6(z);if(z.indexOf(":")===-1&&z.indexOf("*")===-1)this.router.static.ws[z]=x;else if(this.router.ws.add("ws",z,D0),l)this.router.ws.add("ws",l,D0);return}if(z.indexOf(":")===-1&&z.indexOf("*")===-1){if(!o.map[z])o.map[z]={code:""};let l=A0?"":"c";if(w==="ALL")o.map[z].all=`default:return ht[${x}].composed(${l})
322
- `;else o.map[z].code=`case '${w}':return ht[${x}].composed(${l})
323
- ${o.map[z].code}`;if(!this.config.strictPath&&this.config.nativeStaticResponse===!0&&L0&&(w==="GET"||w==="ALL"))this.router.static.http.static[r6(z)]=L0()}else if(this.router.http.add(w,z,D0),!this.config.strictPath){let l=r6(z);if(this.config.nativeStaticResponse===!0&&A0&&(w==="GET"||w==="ALL"))this.router.static.http.static[l]=A0();this.router.http.add(w,l,D0)}}setHeaders;headers(w){if(!w)return this;if(!this.setHeaders)this.setHeaders={};return this.setHeaders=F2(this.setHeaders,w),this}onStart(w){return this.on("start",w),this}onRequest(w){return this.on("request",w),this}onParse(w,z){if(!z){if(typeof w==="string")return this.on("parse",this["~parser"][w]);return this.on("parse",w)}return this.on(w,"parse",z)}parser(w,z){return this["~parser"][w]=z,this}onTransform(w,z){if(!z)return this.on("transform",w);return this.on(w,"transform",z)}resolve(w,z){if(!z)z=w,w={as:"local"};let U={subType:"resolve",fn:z};return this.onBeforeHandle(w,U)}mapResolve(w,z){if(!z)z=w,w={as:"local"};let U={subType:"mapResolve",fn:z};return this.onBeforeHandle(w,U)}onBeforeHandle(w,z){if(!z)return this.on("beforeHandle",w);return this.on(w,"beforeHandle",z)}onAfterHandle(w,z){if(!z)return this.on("afterHandle",w);return this.on(w,"afterHandle",z)}mapResponse(w,z){if(!z)return this.on("mapResponse",w);return this.on(w,"mapResponse",z)}onAfterResponse(w,z){if(!z)return this.on("afterResponse",w);return this.on(w,"afterResponse",z)}trace(w,z){if(!z)z=w,w={as:"local"};if(!Array.isArray(z))z=[z];for(let U of z)this.on(w,"trace",gH(U));return this}error(w,z){switch(typeof w){case"string":return z.prototype[k8]=w,this.definitions.error[w]=z,this;case"function":return this.definitions.error=w(this.definitions.error),this}for(let[U,W]of Object.entries(w))W.prototype[k8]=U,this.definitions.error[U]=W;return this}onError(w,z){if(!z)return this.on("error",w);return this.on(w,"error",z)}onStop(w){return this.on("stop",w),this}on(w,z,U){let W;switch(typeof w){case"string":W=w,U=z;break;case"object":if(W=z,!Array.isArray(z)&&typeof z==="object")U=z;break}if(Array.isArray(U))U=W2(U);else if(typeof U==="function")U=[{fn:U}];else U=[U];let A=U;for(let X of A)if(X.scope=typeof w==="string"?"local":w?.as??"local",W==="resolve"||W==="derive")X.subType=W;if(W!=="trace")uU({[W]:A.map((X)=>X.fn)},this.inference);for(let X of A){let Z=JH(X,"global",{skipIfHasType:!0});switch(W){case"start":this.event.start.push(Z);break;case"request":this.event.request.push(Z);break;case"parse":this.event.parse.push(Z);break;case"transform":this.event.transform.push(Z);break;case"derive":this.event.transform.push(W2(Z,"derive"));break;case"beforeHandle":this.event.beforeHandle.push(Z);break;case"resolve":this.event.beforeHandle.push(W2(Z,"resolve"));break;case"afterHandle":this.event.afterHandle.push(Z);break;case"mapResponse":this.event.mapResponse.push(Z);break;case"afterResponse":this.event.afterResponse.push(Z);break;case"trace":this.event.trace.push(Z);break;case"error":this.event.error.push(Z);break;case"stop":this.event.stop.push(Z);break}}return this}propagate(){return J2(this.event.parse),J2(this.event.transform),J2(this.event.beforeHandle),J2(this.event.afterHandle),J2(this.event.mapResponse),J2(this.event.afterResponse),J2(this.event.trace),J2(this.event.error),this}as(w){let z={plugin:"scoped",scoped:"scoped",global:"global"}[w];if(J2(this.event.parse,z),J2(this.event.transform,z),J2(this.event.beforeHandle,z),J2(this.event.afterHandle,z),J2(this.event.mapResponse,z),J2(this.event.afterResponse,z),J2(this.event.trace,z),J2(this.event.error,z),w==="plugin")this.validator.scoped=I4(this.validator.scoped,this.validator.local),this.validator.local=null;else if(w==="global")this.validator.global=I4(this.validator.global,I4(this.validator.scoped,this.validator.local)),this.validator.scoped=null,this.validator.local=null;return this}group(w,z,U){let W=new j0({...this.config,prefix:""});W.singleton={...this.singleton},W.definitions={...this.definitions},W.getServer=()=>this.getServer(),W.inference=Vw(this.inference),W.extender={...this.extender};let A=typeof z==="object",X=(A?U:z)(W);if(this.singleton=F2(this.singleton,W.singleton),this.definitions=F2(this.definitions,W.definitions),X.event.request.length)this.event.request=[...this.event.request||[],...X.event.request||[]];if(X.event.mapResponse.length)this.event.mapResponse=[...this.event.mapResponse||[],...X.event.mapResponse||[]];return this.model(X.definitions.type),Object.values(W.router.history).forEach(({method:Z,path:$,handler:Q,hooks:Y})=>{if($=(A?"":this.config.prefix)+w+$,A){let B=z,G=Y;this.add(Z,$,Q,D1(B,{...G||{},error:!G.error?X.event.error:Array.isArray(G.error)?[...G.error||{},...X.event.error||{}]:[G.error,...X.event.error||{}]}))}else this.add(Z,$,Q,D1(Y,{error:X.event.error}),{skipPrefix:!0})}),this}guard(w,z){if(!z){if(typeof w==="object"){this.applyMacro(w);let A=w.as??"local";if(this.validator[A]={body:w.body??this.validator[A]?.body,headers:w.headers??this.validator[A]?.headers,params:w.params??this.validator[A]?.params,query:w.query??this.validator[A]?.query,response:w.response??this.validator[A]?.response,cookie:w.cookie??this.validator[A]?.cookie},w.parse)this.on({as:A},"parse",w.parse);if(w.transform)this.on({as:A},"transform",w.transform);if(w.derive)this.on({as:A},"derive",w.derive);if(w.beforeHandle)this.on({as:A},"beforeHandle",w.beforeHandle);if(w.resolve)this.on({as:A},"resolve",w.resolve);if(w.afterHandle)this.on({as:A},"afterHandle",w.afterHandle);if(w.mapResponse)this.on({as:A},"mapResponse",w.mapResponse);if(w.afterResponse)this.on({as:A},"afterResponse",w.afterResponse);if(w.error)this.on({as:A},"error",w.error);if(w.detail)if(this.config.detail)this.config.detail=F2(Object.assign({},this.config.detail),w.detail);else this.config.detail=w.detail;if(w?.tags)if(!this.config.detail)this.config.detail={tags:w.tags};else this.config.detail.tags=w.tags;return this}return this.guard({},w)}let U=new j0({...this.config,prefix:""});U.singleton={...this.singleton},U.definitions={...this.definitions},U.inference=Vw(this.inference),U.extender={...this.extender};let W=z(U);if(this.singleton=F2(this.singleton,U.singleton),this.definitions=F2(this.definitions,U.definitions),W.getServer=()=>this.server,W.event.request.length)this.event.request=[...this.event.request||[],...W.event.request||[]];if(W.event.mapResponse.length)this.event.mapResponse=[...this.event.mapResponse||[],...W.event.mapResponse||[]];return this.model(W.definitions.type),Object.values(U.router.history).forEach(({method:A,path:X,handler:Z,hooks:$})=>{this.add(A,X,Z,D1(w,{...$||{},error:!$.error?W.event.error:Array.isArray($.error)?[...$.error||{},...W.event.error||[]]:[$.error,...W.event.error||[]]}))}),this}use(w,z){if(Array.isArray(w)){let U=this;for(let W of w)U=U.use(W);return U}if(z?.scoped)return this.guard({},(U)=>U.use(w));if(Array.isArray(w)){let U=this;for(let W of w)U=this.use(W);return U}if(w instanceof Promise)return this.promisedModules.add(w.then((U)=>{if(typeof U==="function")return U(this);if(U instanceof j0)return this._use(U).compile();if(U.constructor.name==="Elysia")return this._use(U).compile();if(typeof U.default==="function")return U.default(this);if(U.default instanceof j0)return this._use(U.default);if(U.constructor.name==="Elysia")return this._use(U.default);throw new Error('Invalid plugin type. Expected Elysia instance, function, or module with "default" as Elysia instance or function that returns Elysia instance.')}).then((U)=>U.compile())),this;return this._use(w)}_use(w){if(typeof w==="function"){let A=w(this);if(A instanceof Promise)return this.promisedModules.add(A.then((X)=>{if(X instanceof j0){X.getServer=()=>this.getServer(),X.getGlobalRoutes=()=>this.getGlobalRoutes(),X.model(this.definitions.type),X.error(this.definitions.error);for(let{method:Z,path:$,handler:Q,hooks:Y}of Object.values(X.router.history))this.add(Z,$,Q,D1(Y,{error:X.event.error}));return X.compile(),X}if(typeof X==="function")return X(this);if(typeof X.default==="function")return X.default(this);return this._use(X)}).then((X)=>X.compile())),this;return A}let{name:z,seed:U}=w.config;if(w.getServer=()=>this.getServer(),w.getGlobalRoutes=()=>this.getGlobalRoutes(),w.model(this.definitions.type),w.error(this.definitions.error),this["~parser"]={...w["~parser"],...this["~parser"]},this.headers(w.setHeaders),z){if(!(z in this.dependencies))this.dependencies[z]=[];let A=U!==void 0?x4(z+JSON.stringify(U)):0;if(!this.dependencies[z].some(({checksum:X})=>A===X))this.extender.macros=this.extender.macros.concat(w.extender.macros),this.extender.higherOrderFunctions=this.extender.higherOrderFunctions.concat(w.extender.higherOrderFunctions)}else this.extender.macros=this.extender.macros.concat(w.extender.macros),this.extender.higherOrderFunctions=this.extender.higherOrderFunctions.concat(w.extender.higherOrderFunctions);PU(this.extender.macros),PU(this.extender.higherOrderFunctions);let W=[];for(let A=0;A<this.extender.higherOrderFunctions.length;A++){let X=this.extender.higherOrderFunctions[A];if(X.checksum){if(W.includes(X.checksum))this.extender.higherOrderFunctions.splice(A,1),A--;W.push(X.checksum)}}this.inference={body:this.inference.body||w.inference.body,cookie:this.inference.cookie||w.inference.cookie,headers:this.inference.headers||w.inference.headers,query:this.inference.query||w.inference.query,set:this.inference.set||w.inference.set,server:this.inference.server||w.inference.server,request:this.inference.request||w.inference.request,route:this.inference.route||w.inference.route},this.decorate(w.singleton.decorator),this.state(w.singleton.store),this.model(w.definitions.type),this.error(w.definitions.error),w.extender.macros=this.extender.macros.concat(w.extender.macros);for(let{method:A,path:X,handler:Z,hooks:$}of Object.values(w.router.history))this.add(A,X,Z,D1($,{error:w.event.error}));if(z){if(!(z in this.dependencies))this.dependencies[z]=[];let A=U!==void 0?x4(z+JSON.stringify(U)):0;if(this.dependencies[z].some(({checksum:X})=>A===X))return this;this.dependencies[z].push(this.config?.analytic?{name:w.config.name,seed:w.config.seed,checksum:A,dependencies:w.dependencies,stack:w.telemetry.stack,routes:w.router.history,decorators:w.singleton,store:w.singleton.store,error:w.definitions.error,derive:w.event.transform.filter((X)=>X?.subType==="derive").map((X)=>({fn:X.toString(),stack:new Error().stack??""})),resolve:w.event.transform.filter((X)=>X?.subType==="resolve").map((X)=>({fn:X.toString(),stack:new Error().stack??""}))}:{name:w.config.name,seed:w.config.seed,checksum:A,dependencies:w.dependencies}),this.event=GU(this.event,LU(w.event),A)}else this.event=GU(this.event,LU(w.event));return this.validator.global=D1(this.validator.global,{...w.validator.global}),this.validator.local=D1(this.validator.local,{...w.validator.scoped}),this}macro(w){if(typeof w==="function"){let z={checksum:x4(JSON.stringify({name:this.config.name,seed:this.config.seed,content:w.toString()})),fn:w};this.extender.macros.push(z)}else if(typeof w==="object"){let z={checksum:x4(JSON.stringify({name:this.config.name,seed:this.config.seed,content:Object.entries(w).map(([U,W])=>`${U}+${W}`).join(",")})),fn:()=>w};this.extender.macros.push(z)}return this}mount(w,z){if(w instanceof j0||typeof w==="function"||w.length===0||w==="/"){let A=typeof w==="function"?w:w instanceof j0?w.compile().fetch:z instanceof j0?z.compile().fetch:z,X=async({request:Z,path:$})=>{if(Z.method==="GET"||Z.method==="HEAD"||!Z.headers.get("content-type"))return A(new Request(j8(Z.url,$||"/"),Z));return A(new Request(j8(Z.url,$||"/"),{...Z,body:await Z.arrayBuffer()}))};return this.all("/*",X,{type:"none"}),this}let U=w.length;if(z instanceof j0)z=z.compile().fetch;let W=async({request:A,path:X})=>{if(A.method==="GET"||A.method==="HEAD"||!A.headers.get("content-type"))return z(new Request(j8(A.url,X.slice(U)||"/"),A));return z(new Request(j8(A.url,X.slice(U)||"/"),{...A,body:await A.arrayBuffer()}))};return this.all(w,W,{type:"none"}),this.all(w+(w.endsWith("/")?"*":"/*"),W,{type:"none"}),this}get(w,z,U){return this.add("GET",w,z,U),this}post(w,z,U){return this.add("POST",w,z,U),this}put(w,z,U){return this.add("PUT",w,z,U),this}patch(w,z,U){return this.add("PATCH",w,z,U),this}delete(w,z,U){return this.add("DELETE",w,z,U),this}options(w,z,U){return this.add("OPTIONS",w,z,U),this}all(w,z,U){return this.add("ALL",w,z,U),this}head(w,z,U){return this.add("HEAD",w,z,U),this}connect(w,z,U){return this.add("CONNECT",w,z,U),this}route(w,z,U,W){return this.add(w.toUpperCase(),z,U,W,W?.config),this}ws(w,z){if(this["~adapter"].ws)this["~adapter"].ws(this,w,z);else console.warn("Current adapter doesn't support WebSocket");return this}state(w,z,U){if(z===void 0)U=w,w={as:"append"},z="";else if(U===void 0){if(typeof w==="string")U=z,z=w,w={as:"append"};else if(typeof w==="object")U=z,z=""}let{as:W}=w;if(typeof z!=="string")return this;switch(typeof U){case"object":if(z){if(z in this.singleton.store)this.singleton.store[z]=F2(this.singleton.store[z],U,{override:W==="override"});else this.singleton.store[z]=U;return this}if(U===null)return this;return this.singleton.store=F2(this.singleton.store,U,{override:W==="override"}),this;case"function":if(z){if(W==="override"||!(z in this.singleton.store))this.singleton.store[z]=U}else this.singleton.store=U(this.singleton.store);return this;default:if(W==="override"||!(z in this.singleton.store))this.singleton.store[z]=U;return this}}decorate(w,z,U){if(z===void 0)U=w,w={as:"append"},z="";else if(U===void 0){if(typeof w==="string")U=z,z=w,w={as:"append"};else if(typeof w==="object")U=z,z=""}let{as:W}=w;if(typeof z!=="string")return this;switch(typeof U){case"object":if(z){if(z in this.singleton.decorator)this.singleton.decorator[z]=F2(this.singleton.decorator[z],U,{override:W==="override"});else this.singleton.decorator[z]=U;return this}if(U===null)return this;return this.singleton.decorator=F2(this.singleton.decorator,U,{override:W==="override"}),this;case"function":if(z){if(W==="override"||!(z in this.singleton.decorator))this.singleton.decorator[z]=U}else this.singleton.decorator=U(this.singleton.decorator);return this;default:if(W==="override"||!(z in this.singleton.decorator))this.singleton.decorator[z]=U;return this}}derive(w,z){if(!z)z=w,w={as:"local"};let U={subType:"derive",fn:z};return this.onTransform(w,U)}model(w,z){let U=(W)=>dw(W,[{from:I.Number(),to:(A)=>I.Numeric(A),untilObjectFound:!0},{from:I.Boolean(),to:(A)=>I.BooleanString(A),untilObjectFound:!0}]);switch(typeof w){case"object":let W={};return Object.entries(w).forEach(([X,Z])=>{if(!(X in this.definitions.type))W[X]=this.definitions.type[X]=U(Z)}),this.definitions.typebox=I.Module({...this.definitions.typebox.$defs,...W}),this;case"function":let A=U(w(this.definitions.type));return this.definitions.type=A,this.definitions.typebox=I.Module(A),this}return this.definitions.type[w]=z,this.definitions.typebox=I.Module({...this.definitions.typebox.$defs,[w]:z}),this}mapDerive(w,z){if(!z)z=w,w={as:"local"};let U={subType:"mapDerive",fn:z};return this.onTransform(w,U)}affix(w,z,U){if(U==="")return this;let W=["_","-"," "],A=(Q)=>Q[0].toUpperCase()+Q.slice(1),X=w==="prefix"?(Q,Y)=>W.includes(Q.at(-1)??"")?Q+Y:Q+A(Y):W.includes(U.at(-1)??"")?(Q,Y)=>Y+Q:(Q,Y)=>Y+A(Q),Z=(Q)=>{let Y={};switch(Q){case"decorator":for(let B in this.singleton.decorator)Y[X(U,B)]=this.singleton.decorator[B];this.singleton.decorator=Y;break;case"state":for(let B in this.singleton.store)Y[X(U,B)]=this.singleton.store[B];this.singleton.store=Y;break;case"model":for(let B in this.definitions.type)Y[X(U,B)]=this.definitions.type[B];this.definitions.type=Y;break;case"error":for(let B in this.definitions.error)Y[X(U,B)]=this.definitions.error[B];this.definitions.error=Y;break}},$=Array.isArray(z)?z:[z];for(let Q of $.some((Y)=>Y==="all")?["decorator","state","model","error"]:$)Z(Q);return this}prefix(w,z){return this.affix("prefix",w,z)}suffix(w,z){return this.affix("suffix",w,z)}compile(){if(this["~adapter"].isWebStandard){if(this.fetch=this.config.aot?Tw(this):jU(this),typeof this.server?.reload==="function")this.server.reload({...this.server||{},fetch:this.fetch});return this}if(typeof this.server?.reload==="function")this.server.reload(this.server||{});return this._handle=Tw(this),this}handle=async(w)=>this.fetch(w);fetch=(w)=>{return(this.fetch=this.config.aot?Tw(this):jU(this))(w)};handleError=async(w,z)=>{return(this.handleError=this.config.aot?rU(this):cH(this))(w,z)};outerErrorHandler=(w)=>new Response(w.message||w.name||"Error",{status:w?.status??500});listen=(w,z)=>{return this["~adapter"].listen(this)(w,z),this};stop=async(w)=>{if(!this.server)throw new Error("Elysia isn't running. Call `app.listen` to start the server.");if(this.server){if(this.server.stop(w),this.server=null,this.event.stop.length)for(let z=0;z<this.event.stop.length;z++)this.event.stop[z].fn(this)}};get modules(){return Promise.all(this.promisedModules.promises)}}var aU;(function(w){w[w.Include=0]="Include",w[w.None=1]="None"})(aU||(aU={}));var eU;(function(w){w[w.Required=0]="Required",w[w.Ignore=1]="Ignore"})(eU||(eU={}));function uw(w){return zW(w,iH,f4.Include)}function d4(w){return zW(w,vH,f4.None)}function zW(w,z,U){let W="";for(let A=0;A<w.byteLength;A+=3){let X=0,Z=0;for(let $=0;$<3&&A+$<w.byteLength;$++)X=X<<8|w[A+$],Z+=8;for(let $=0;$<4;$++)if(Z>=6)W+=z[X>>Z-6&63],Z-=6;else if(Z>0)W+=z[X<<6-Z&63],Z=0;else if(U===f4.Include)W+="="}return W}var iH="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",vH="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_";var f4;(function(w){w[w.Include=0]="Include",w[w.None=1]="None"})(f4||(f4={}));var wW;(function(w){w[w.Required=0]="Required",w[w.Ignore=1]="Ignore"})(wW||(wW={}));class WW{uint8(w,z){if(w.byteLength<z+1)throw new TypeError("Insufficient bytes");return w[z]}uint16(w,z){if(w.byteLength<z+2)throw new TypeError("Insufficient bytes");return w[z]<<8|w[z+1]}uint32(w,z){if(w.byteLength<z+4)throw new TypeError("Insufficient bytes");let U=0;for(let W=0;W<4;W++)U|=w[z+W]<<24-W*8;return U}uint64(w,z){if(w.byteLength<z+8)throw new TypeError("Insufficient bytes");let U=0n;for(let W=0;W<8;W++)U|=BigInt(w[z+W])<<BigInt(56-W*8);return U}putUint8(w,z,U){if(w.length<U+1)throw new TypeError("Not enough space");if(z<0||z>255)throw new TypeError("Invalid uint8 value");w[U]=z}putUint16(w,z,U){if(w.length<U+2)throw new TypeError("Not enough space");if(z<0||z>65535)throw new TypeError("Invalid uint16 value");w[U]=z>>8,w[U+1]=z&255}putUint32(w,z,U){if(w.length<U+4)throw new TypeError("Not enough space");if(z<0||z>4294967295)throw new TypeError("Invalid uint32 value");for(let W=0;W<4;W++)w[U+W]=z>>(3-W)*8&255}putUint64(w,z,U){if(w.length<U+8)throw new TypeError("Not enough space");if(z<0||z>18446744073709551615n)throw new TypeError("Invalid uint64 value");for(let W=0;W<8;W++)w[U+W]=Number(z>>BigInt((7-W)*8)&0xffn)}}class AW{uint8(w,z){if(w.byteLength<z+1)throw new TypeError("Insufficient bytes");return w[z]}uint16(w,z){if(w.byteLength<z+2)throw new TypeError("Insufficient bytes");return w[z]|w[z+1]<<8}uint32(w,z){if(w.byteLength<z+4)throw new TypeError("Insufficient bytes");let U=0;for(let W=0;W<4;W++)U|=w[z+W]<<W*8;return U}uint64(w,z){if(w.byteLength<z+8)throw new TypeError("Insufficient bytes");let U=0n;for(let W=0;W<8;W++)U|=BigInt(w[z+W])<<BigInt(W*8);return U}putUint8(w,z,U){if(w.length<1+U)throw new TypeError("Insufficient space");if(z<0||z>255)throw new TypeError("Invalid uint8 value");w[U]=z}putUint16(w,z,U){if(w.length<2+U)throw new TypeError("Insufficient space");if(z<0||z>65535)throw new TypeError("Invalid uint16 value");w[U+1]=z>>8,w[U]=z&255}putUint32(w,z,U){if(w.length<4+U)throw new TypeError("Insufficient space");if(z<0||z>4294967295)throw new TypeError("Invalid uint32 value");for(let W=0;W<4;W++)w[U+W]=z>>W*8&255}putUint64(w,z,U){if(w.length<8+U)throw new TypeError("Insufficient space");if(z<0||z>18446744073709551615n)throw new TypeError("Invalid uint64 value");for(let W=0;W<8;W++)w[U+W]=Number(z>>BigInt(W*8)&0xffn)}}var P1=new WW,nH=new AW;function n0(w,z){return(w<<32-z|w>>>z)>>>0}function a2(w,z){return(w<<BigInt(64-z)|w>>BigInt(z))&0xffffffffffffffffn}class XW{blockSize=64;size=32;blocks=new Uint8Array(64);currentBlockSize=0;H=new Uint32Array([3238371032,914150663,812702999,4144912697,4290775857,1750603025,1694076839,3204075428]);l=0n;w=new Uint32Array(64);update(w){if(this.l+=BigInt(w.byteLength)*8n,this.currentBlockSize+w.byteLength<64){this.blocks.set(w,this.currentBlockSize),this.currentBlockSize+=w.byteLength;return}let z=0;if(this.currentBlockSize>0){let U=w.slice(0,64-this.currentBlockSize);this.blocks.set(U,this.currentBlockSize),this.process(),z+=U.byteLength,this.currentBlockSize=0}while(z+64<=w.byteLength){let U=w.slice(z,z+64);this.blocks.set(U),this.process(),z+=64}if(w.byteLength-z>0){let U=w.slice(z);this.blocks.set(U),this.currentBlockSize=U.byteLength}}digest(){if(this.blocks[this.currentBlockSize]=128,this.currentBlockSize+=1,64-this.currentBlockSize<8)this.blocks.fill(0,this.currentBlockSize),this.process(),this.currentBlockSize=0;this.blocks.fill(0,this.currentBlockSize),P1.putUint64(this.blocks,this.l,this.blockSize-8),this.process();let w=new Uint8Array(28);for(let z=0;z<7;z++)P1.putUint32(w,this.H[z],z*4);return w}process(){for(let Q=0;Q<16;Q++)this.w[Q]=(this.blocks[Q*4]<<24|this.blocks[Q*4+1]<<16|this.blocks[Q*4+2]<<8|this.blocks[Q*4+3])>>>0;for(let Q=16;Q<64;Q++){let Y=(n0(this.w[Q-2],17)^n0(this.w[Q-2],19)^this.w[Q-2]>>>10)>>>0,B=(n0(this.w[Q-15],7)^n0(this.w[Q-15],18)^this.w[Q-15]>>>3)>>>0;this.w[Q]=Y+this.w[Q-7]+B+this.w[Q-16]|0}let w=this.H[0],z=this.H[1],U=this.H[2],W=this.H[3],A=this.H[4],X=this.H[5],Z=this.H[6],$=this.H[7];for(let Q=0;Q<64;Q++){let Y=(n0(A,6)^n0(A,11)^n0(A,25))>>>0,B=(A&X^~A&Z)>>>0,G=$+Y+B+uH[Q]+this.w[Q]|0,_=(n0(w,2)^n0(w,13)^n0(w,22))>>>0,H=(w&z^w&U^z&U)>>>0,F=_+H|0;$=Z,Z=X,X=A,A=W+G|0,W=U,U=z,z=w,w=G+F|0}this.H[0]=w+this.H[0]|0,this.H[1]=z+this.H[1]|0,this.H[2]=U+this.H[2]|0,this.H[3]=W+this.H[3]|0,this.H[4]=A+this.H[4]|0,this.H[5]=X+this.H[5]|0,this.H[6]=Z+this.H[6]|0,this.H[7]=$+this.H[7]|0}}var uH=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]);function mw(w){let z=new tw;return z.update(w),z.digest()}class tw{blockSize=64;size=32;blocks=new Uint8Array(64);currentBlockSize=0;H=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]);l=0n;w=new Uint32Array(64);update(w){if(this.l+=BigInt(w.byteLength)*8n,this.currentBlockSize+w.byteLength<64){this.blocks.set(w,this.currentBlockSize),this.currentBlockSize+=w.byteLength;return}let z=0;if(this.currentBlockSize>0){let U=w.slice(0,64-this.currentBlockSize);this.blocks.set(U,this.currentBlockSize),this.process(),z+=U.byteLength,this.currentBlockSize=0}while(z+64<=w.byteLength){let U=w.slice(z,z+64);this.blocks.set(U),this.process(),z+=64}if(w.byteLength-z>0){let U=w.slice(z);this.blocks.set(U),this.currentBlockSize=U.byteLength}}digest(){if(this.blocks[this.currentBlockSize]=128,this.currentBlockSize+=1,64-this.currentBlockSize<8)this.blocks.fill(0,this.currentBlockSize),this.process(),this.currentBlockSize=0;this.blocks.fill(0,this.currentBlockSize),P1.putUint64(this.blocks,this.l,this.blockSize-8),this.process();let w=new Uint8Array(32);for(let z=0;z<8;z++)P1.putUint32(w,this.H[z],z*4);return w}process(){for(let Q=0;Q<16;Q++)this.w[Q]=(this.blocks[Q*4]<<24|this.blocks[Q*4+1]<<16|this.blocks[Q*4+2]<<8|this.blocks[Q*4+3])>>>0;for(let Q=16;Q<64;Q++){let Y=(n0(this.w[Q-2],17)^n0(this.w[Q-2],19)^this.w[Q-2]>>>10)>>>0,B=(n0(this.w[Q-15],7)^n0(this.w[Q-15],18)^this.w[Q-15]>>>3)>>>0;this.w[Q]=Y+this.w[Q-7]+B+this.w[Q-16]|0}let w=this.H[0],z=this.H[1],U=this.H[2],W=this.H[3],A=this.H[4],X=this.H[5],Z=this.H[6],$=this.H[7];for(let Q=0;Q<64;Q++){let Y=(n0(A,6)^n0(A,11)^n0(A,25))>>>0,B=(A&X^~A&Z)>>>0,G=$+Y+B+mH[Q]+this.w[Q]|0,_=(n0(w,2)^n0(w,13)^n0(w,22))>>>0,H=(w&z^w&U^z&U)>>>0,F=_+H|0;$=Z,Z=X,X=A,A=W+G|0,W=U,U=z,z=w,w=G+F|0}this.H[0]=w+this.H[0]|0,this.H[1]=z+this.H[1]|0,this.H[2]=U+this.H[2]|0,this.H[3]=W+this.H[3]|0,this.H[4]=A+this.H[4]|0,this.H[5]=X+this.H[5]|0,this.H[6]=Z+this.H[6]|0,this.H[7]=$+this.H[7]|0}}var mH=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]);class Z6{blockSize=128;size=64;blocks=new Uint8Array(128);currentBlockSize=0;l=0n;w=new BigUint64Array(80);H;constructor(w){if(w.byteLength!==64)throw new TypeError;this.H=w}update(w){if(this.l+=BigInt(w.byteLength)*8n,this.currentBlockSize+w.byteLength<128){this.blocks.set(w,this.currentBlockSize),this.currentBlockSize+=w.byteLength;return}let z=0;if(this.currentBlockSize>0){let U=w.slice(0,128-this.currentBlockSize);this.blocks.set(U,this.currentBlockSize),this.process(),z+=U.byteLength,this.currentBlockSize=0}while(z+128<=w.byteLength){let U=w.slice(z,z+128);this.blocks.set(U),this.process(),z+=128,this.currentBlockSize=0}if(w.byteLength-z>0){let U=w.slice(z);this.blocks.set(U),this.currentBlockSize=U.byteLength}}putDigest(w){if(w.byteLength>64||w.byteLength%8!==0)throw new TypeError;if(this.blocks[this.currentBlockSize]=128,this.currentBlockSize+=1,128-this.currentBlockSize<16)this.blocks.fill(0,this.currentBlockSize),this.process(),this.currentBlockSize=0;this.blocks.fill(0,this.currentBlockSize),P1.putUint64(this.blocks,this.l,this.blockSize-8),this.process();for(let z=0;z<w.byteLength/8;z++)P1.putUint64(w,this.H[z],z*8)}process(){for(let Q=0;Q<16;Q++)this.w[Q]=BigInt(this.blocks[Q*8])<<56n|BigInt(this.blocks[Q*8+1])<<48n|BigInt(this.blocks[Q*8+2])<<40n|BigInt(this.blocks[Q*8+3])<<32n|BigInt(this.blocks[Q*8+4])<<24n|BigInt(this.blocks[Q*8+5])<<16n|BigInt(this.blocks[Q*8+6])<<8n|BigInt(this.blocks[Q*8+7]);for(let Q=16;Q<80;Q++){let Y=(a2(this.w[Q-2],19)^a2(this.w[Q-2],61)^this.w[Q-2]>>6n)&0xffffffffffffffffn,B=(a2(this.w[Q-15],1)^a2(this.w[Q-15],8)^this.w[Q-15]>>7n)&0xffffffffffffffffn;this.w[Q]=Y+this.w[Q-7]+B+this.w[Q-16]&0xffffffffffffffffn}let w=this.H[0],z=this.H[1],U=this.H[2],W=this.H[3],A=this.H[4],X=this.H[5],Z=this.H[6],$=this.H[7];for(let Q=0;Q<80;Q++){let Y=(a2(A,14)^a2(A,18)^a2(A,41))&0xffffffffffffffffn,B=(A&X^~A&Z)&0xffffffffffffffffn,G=$+Y+B+tH[Q]+this.w[Q]&0xffffffffffffffffn,_=(a2(w,28)^a2(w,34)^a2(w,39))&0xffffffffffffffffn,H=(w&z^w&U^z&U)&0xffffffffffffffffn,F=_+H&0xffffffffffffffffn;$=Z,Z=X,X=A,A=W+G&0xffffffffffffffffn,W=U,U=z,z=w,w=G+F&0xffffffffffffffffn}this.H[0]=w+this.H[0]&0xffffffffffffffffn,this.H[1]=z+this.H[1]&0xffffffffffffffffn,this.H[2]=U+this.H[2]&0xffffffffffffffffn,this.H[3]=W+this.H[3]&0xffffffffffffffffn,this.H[4]=A+this.H[4]&0xffffffffffffffffn,this.H[5]=X+this.H[5]&0xffffffffffffffffn,this.H[6]=Z+this.H[6]&0xffffffffffffffffn,this.H[7]=$+this.H[7]&0xffffffffffffffffn}}class ZW{blockSize=128;size=64;sha512=new Z6(new BigUint64Array([0x6a09e667f3bcc908n,0xbb67ae8584caa73bn,0x3c6ef372fe94f82bn,0xa54ff53a5f1d36f1n,0x510e527fade682d1n,0x9b05688c2b3e6c1fn,0x1f83d9abfb41bd6bn,0x5be0cd19137e2179n]));update(w){this.sha512.update(w)}digest(){let w=new Uint8Array(64);return this.sha512.putDigest(w),w}}var tH=new BigUint64Array([0x428a2f98d728ae22n,0x7137449123ef65cdn,0xb5c0fbcfec4d3b2fn,0xe9b5dba58189dbbcn,0x3956c25bf348b538n,0x59f111f1b605d019n,0x923f82a4af194f9bn,0xab1c5ed5da6d8118n,0xd807aa98a3030242n,0x12835b0145706fben,0x243185be4ee4b28cn,0x550c7dc3d5ffb4e2n,0x72be5d74f27b896fn,0x80deb1fe3b1696b1n,0x9bdc06a725c71235n,0xc19bf174cf692694n,0xe49b69c19ef14ad2n,0xefbe4786384f25e3n,0x0fc19dc68b8cd5b5n,0x240ca1cc77ac9c65n,0x2de92c6f592b0275n,0x4a7484aa6ea6e483n,0x5cb0a9dcbd41fbd4n,0x76f988da831153b5n,0x983e5152ee66dfabn,0xa831c66d2db43210n,0xb00327c898fb213fn,0xbf597fc7beef0ee4n,0xc6e00bf33da88fc2n,0xd5a79147930aa725n,0x06ca6351e003826fn,0x142929670a0e6e70n,0x27b70a8546d22ffcn,0x2e1b21385c26c926n,0x4d2c6dfc5ac42aedn,0x53380d139d95b3dfn,0x650a73548baf63den,0x766a0abb3c77b2a8n,0x81c2c92e47edaee6n,0x92722c851482353bn,0xa2bfe8a14cf10364n,0xa81a664bbc423001n,0xc24b8b70d0f89791n,0xc76c51a30654be30n,0xd192e819d6ef5218n,0xd69906245565a910n,0xf40e35855771202an,0x106aa07032bbd1b8n,0x19a4c116b8d2d0c8n,0x1e376c085141ab53n,0x2748774cdf8eeb99n,0x34b0bcb5e19b48a8n,0x391c0cb3c5c95a63n,0x4ed8aa4ae3418acbn,0x5b9cca4f7763e373n,0x682e6ff3d6b2b8a3n,0x748f82ee5defb2fcn,0x78a5636f43172f60n,0x84c87814a1f0ab72n,0x8cc702081a6439ecn,0x90befffa23631e28n,0xa4506cebde82bde9n,0xbef9a3f7b2c67915n,0xc67178f2e372532bn,0xca273eceea26619cn,0xd186b8c721c0c207n,0xeada7dd6cde0eb1en,0xf57d4f7fee6ed178n,0x06f067aa72176fban,0x0a637dc5a2c898a6n,0x113f9804bef90daen,0x1b710b35131c471bn,0x28db77f523047d84n,0x32caab7b40c72493n,0x3c9ebe0a15c9bebcn,0x431d67c49c100d4cn,0x4cc5d4becb3e42b6n,0x597f299cfc657e2an,0x5fcb6fab3ad6faecn,0x6c44198c4a475817n]);class $W{blockSize=128;size=48;sha512=new Z6(new BigUint64Array([0xcbbb9d5dc1059ed8n,0x629a292a367cd507n,0x9159015a3070dd17n,0x152fecd8f70e5939n,0x67332667ffc00b31n,0x8eb44a8768581511n,0xdb0c2e0d64f98fa7n,0x47b5481dbefa4fa4n]));update(w){this.sha512.update(w)}digest(){let w=new Uint8Array(48);return this.sha512.putDigest(w),w}}class QW{blockSize=128;size=28;sha512=new Z6(new BigUint64Array([0x8c3d37c819544da2n,0x73e1996689dcd4d6n,0x1dfab7ae32ff9c82n,0x679dd514582f9fcfn,0x0f6d2b697bd44da8n,0x77e36f7304c48942n,0x3f9d85a86a1d36c8n,0x1112e6ad91d692a1n]));update(w){this.sha512.update(w)}digest(){let w=new Uint8Array(32);return this.sha512.putDigest(w),w.slice(0,28)}}class YW{blockSize=128;size=28;sha512=new Z6(new BigUint64Array([0x22312194fc2bf72cn,0x9f555fa3c84c64c2n,0x2393b86b6f53b151n,0x963877195940eabdn,0x96283ee2a88effe3n,0xbe5e1e2553863992n,0x2b0199fc2c85b8aan,0x0eb72ddc81c52ca2n]));update(w){this.sha512.update(w)}digest(){let w=new Uint8Array(32);return this.sha512.putDigest(w),w}}class U4{data;constructor(w){this.data=w}tokenType(){if("token_type"in this.data&&typeof this.data.token_type==="string")return this.data.token_type;throw new Error("Missing or invalid 'token_type' field")}accessToken(){if("access_token"in this.data&&typeof this.data.access_token==="string")return this.data.access_token;throw new Error("Missing or invalid 'access_token' field")}accessTokenExpiresInSeconds(){if("expires_in"in this.data&&typeof this.data.expires_in==="number")return this.data.expires_in;throw new Error("Missing or invalid 'expires_in' field")}accessTokenExpiresAt(){return new Date(Date.now()+this.accessTokenExpiresInSeconds()*1000)}hasRefreshToken(){return"refresh_token"in this.data&&typeof this.data.refresh_token==="string"}refreshToken(){if("refresh_token"in this.data&&typeof this.data.refresh_token==="string")return this.data.refresh_token;throw new Error("Missing or invalid 'refresh_token' field")}hasScopes(){return"scope"in this.data&&typeof this.data.scope==="string"}scopes(){if("scope"in this.data&&typeof this.data.scope==="string")return this.data.scope.split(" ");throw new Error("Missing or invalid 'scope' field")}idToken(){if("id_token"in this.data&&typeof this.data.id_token==="string")return this.data.id_token;throw new Error("Missing or invalid field 'id_token'")}}function W4(w){let z=mw(new TextEncoder().encode(w));return d4(z)}function pw(){let w=new Uint8Array(32);return crypto.getRandomValues(w),d4(w)}function ow(){let w=new Uint8Array(32);return crypto.getRandomValues(w),d4(w)}function JW(w,z){if(z.length!==1)throw new TypeError("Invalid character string");let U=0;while(U<w.length&&w[U]===z)U++;return w.slice(U)}function lw(w,z){if(z.length!==1)throw new TypeError("Invalid character string");let U=w.length;while(U>0&&w[U-1]===z)U--;return w.slice(0,U)}function M2(w,...z){let U=lw(w,"/");for(let W of z)U+="/",U+=lw(JW(W,"/"),"/");return U}function g(w,z){let U=new TextEncoder().encode(z.toString()),W=new Request(w,{method:"POST",body:U});return W.headers.set("Content-Type","application/x-www-form-urlencoded"),W.headers.set("Accept","application/json"),W.headers.set("User-Agent","arctic"),W.headers.set("Content-Length",U.byteLength.toString()),W}function R6(w,z){let U=new TextEncoder().encode(`${w}:${z}`);return uw(U)}async function c(w){let z;try{z=await fetch(w)}catch(U){throw new $6(U)}if(z.status===400||z.status===401){let U;try{U=await z.json()}catch{throw new v1(z.status)}if(typeof U!=="object"||U===null)throw new q1(z.status,U);let W;try{W=c8(U)}catch{throw new q1(z.status,U)}throw W}if(z.status===200){let U;try{U=await z.json()}catch{throw new v1(z.status)}if(typeof U!=="object"||U===null)throw new q1(z.status,U);return new U4(U)}if(z.body!==null)await z.body.cancel();throw new v1(z.status)}async function A4(w){let z;try{z=await fetch(w)}catch(U){throw new $6(U)}if(z.status===400||z.status===401){let U;try{U=await z.json()}catch{throw new q1(z.status,null)}if(typeof U!=="object"||U===null)throw new q1(z.status,U);let W;try{W=c8(U)}catch{throw new q1(z.status,U)}throw W}if(z.status===200){if(z.body!==null)await z.body.cancel();return}if(z.body!==null)await z.body.cancel();throw new v1(z.status)}function c8(w){let z;if("error"in w&&typeof w.error==="string")z=w.error;else throw new Error("Invalid error response");let U=null,W=null,A=null;if("error_description"in w){if(typeof w.error_description!=="string")throw new Error("Invalid data");U=w.error_description}if("error_uri"in w){if(typeof w.error_uri!=="string")throw new Error("Invalid data");W=w.error_uri}if("state"in w){if(typeof w.state!=="string")throw new Error("Invalid data");A=w.state}return new h4(z,U,W,A)}class $6 extends Error{constructor(w){super("Failed to send request",{cause:w})}}class h4 extends Error{code;description;uri;state;constructor(w,z,U,W){super(`OAuth request error: ${w}`);this.code=w,this.description=z,this.uri=U,this.state=W}}class v1 extends Error{status;constructor(w){super("Unexpected error response");this.status=w}}class q1 extends Error{status;data;constructor(w,z){super("Unexpected error response body");this.status=w,this.data=z}}class f{clientId;clientPassword;redirectURI;constructor(w,z,U){this.clientId=w,this.clientPassword=z,this.redirectURI=U}createAuthorizationURL(w,z,U){let W=new URL(w);if(W.searchParams.set("response_type","code"),W.searchParams.set("client_id",this.clientId),this.redirectURI!==null)W.searchParams.set("redirect_uri",this.redirectURI);if(W.searchParams.set("state",z),U.length>0)W.searchParams.set("scope",U.join(" "));return W}createAuthorizationURLWithPKCE(w,z,U,W,A){let X=new URL(w);if(X.searchParams.set("response_type","code"),X.searchParams.set("client_id",this.clientId),this.redirectURI!==null)X.searchParams.set("redirect_uri",this.redirectURI);if(X.searchParams.set("state",z),U===W0.S256){let Z=W4(W);X.searchParams.set("code_challenge_method","S256"),X.searchParams.set("code_challenge",Z)}else if(U===W0.Plain)X.searchParams.set("code_challenge_method","plain"),X.searchParams.set("code_challenge",W);if(A.length>0)X.searchParams.set("scope",A.join(" "));return X}async validateAuthorizationCode(w,z,U){let W=new URLSearchParams;if(W.set("grant_type","authorization_code"),W.set("code",z),this.redirectURI!==null)W.set("redirect_uri",this.redirectURI);if(U!==null)W.set("code_verifier",U);if(this.clientPassword===null)W.set("client_id",this.clientId);let A=g(w,W);if(this.clientPassword!==null){let Z=R6(this.clientId,this.clientPassword);A.headers.set("Authorization",`Basic ${Z}`)}return await c(A)}async refreshAccessToken(w,z,U){let W=new URLSearchParams;if(W.set("grant_type","refresh_token"),W.set("refresh_token",z),this.clientPassword===null)W.set("client_id",this.clientId);if(U.length>0)W.set("scope",U.join(" "));let A=g(w,W);if(this.clientPassword!==null){let Z=R6(this.clientId,this.clientPassword);A.headers.set("Authorization",`Basic ${Z}`)}return await c(A)}async revokeToken(w,z){let U=new URLSearchParams;if(U.set("token",z),this.clientPassword===null)U.set("client_id",this.clientId);let W=g(w,U);if(this.clientPassword!==null){let A=R6(this.clientId,this.clientPassword);W.headers.set("Authorization",`Basic ${A}`)}await A4(W)}}var W0;(function(w){w[w.S256=0]="S256",w[w.Plain=1]="Plain"})(W0||(W0={}));class i8{authorizationEndpoint;tokenEndpoint;tokenRevocationEndpoint;client;constructor(w,z,U,W){this.authorizationEndpoint=`https://${w}/oauth2/authorize`,this.tokenEndpoint=`https://${w}/oauth2/token`,this.tokenRevocationEndpoint=`https://${w}/oauth2/revoke`,this.client=new f(z,U,W)}createAuthorizationURL(w,z,U){return this.client.createAuthorizationURLWithPKCE(this.authorizationEndpoint,w,W0.S256,z,U)}async validateAuthorizationCode(w,z){return await this.client.validateAuthorizationCode(this.tokenEndpoint,w,z)}async refreshAccessToken(w,z){return await this.client.refreshAccessToken(this.tokenEndpoint,w,z)}async revokeToken(w){await this.client.revokeToken(this.tokenRevocationEndpoint,w)}}var oH="https://anilist.co/api/v2/oauth/authorize",lH="https://anilist.co/api/v2/oauth/token";class v8{client;constructor(w,z,U){this.client=new f(w,z,U)}createAuthorizationURL(w){return this.client.createAuthorizationURL(oH,w,[])}async validateAuthorizationCode(w){return await this.client.validateAuthorizationCode(lH,w,null)}}var BW;(function(w){w[w.Include=0]="Include",w[w.None=1]="None"})(BW||(BW={}));var MW;(function(w){w[w.Required=0]="Required",w[w.Ignore=1]="Ignore"})(MW||(MW={}));function C6(w){return sH(w,rH,n8.None)}function sH(w,z,U){let W="";for(let A=0;A<w.byteLength;A+=3){let X=0,Z=0;for(let $=0;$<3&&A+$<w.byteLength;$++)X=X<<8|w[A+$],Z+=8;for(let $=0;$<4;$++)if(Z>=6)W+=z[X>>Z-6&63],Z-=6;else if(Z>0)W+=z[X<<6-Z&63],Z=0;else if(U===n8.Include)W+="="}return W}var rH="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_";function sw(w){return aH(w,eH,y4.Ignore)}function aH(w,z,U){let W=new Uint8Array(Math.ceil(w.length/4)*3),A=0;for(let X=0;X<w.length;X+=4){let Z=0,$=0;for(let Y=0;Y<4;Y++){if(U===y4.Required&&w[X+Y]==="=")continue;if(U===y4.Ignore&&(X+Y>=w.length||w[X+Y]==="="))continue;if(Y>0&&w[X+Y-1]==="=")throw new Error("Invalid padding");if(!(w[X+Y]in z))throw new Error("Invalid character");Z|=z[w[X+Y]]<<(3-Y)*6,$+=6}if($<24){let Y;if($===12)Y=Z&65535;else if($===18)Y=Z&255;else throw new Error("Invalid padding");if(Y!==0)throw new Error("Invalid padding")}let Q=Math.floor($/8);for(let Y=0;Y<Q;Y++)W[A]=Z>>16-Y*8&255,A++}return W.slice(0,A)}var n8;(function(w){w[w.Include=0]="Include",w[w.None=1]="None"})(n8||(n8={}));var y4;(function(w){w[w.Required=0]="Required",w[w.Ignore=1]="Ignore"})(y4||(y4={}));var eH={"0":52,"1":53,"2":54,"3":55,"4":56,"5":57,"6":58,"7":59,"8":60,"9":61,A:0,B:1,C:2,D:3,E:4,F:5,G:6,H:7,I:8,J:9,K:10,L:11,M:12,N:13,O:14,P:15,Q:16,R:17,S:18,T:19,U:20,V:21,W:22,X:23,Y:24,Z:25,a:26,b:27,c:28,d:29,e:30,f:31,g:32,h:33,i:34,j:35,k:36,l:37,m:38,n:39,o:40,p:41,q:42,r:43,s:44,t:45,u:46,v:47,w:48,x:49,y:50,z:51,"-":62,_:63};function qW(w){let z=w.split(".");if(z.length!==3)throw new Error("Invalid JWT");let U;try{U=new TextDecoder().decode(sw(z[1]))}catch{throw new Error("Invalid JWT: Invalid base64url encoding")}let W;try{W=JSON.parse(U)}catch{throw new Error("Invalid JWT: Invalid JSON encoding")}if(typeof W!=="object"||W===null)throw new Error("Invalid JWT: Invalid payload");return W}function HW(w,z,U){let W=C6(new TextEncoder().encode(w)),A=C6(new TextEncoder().encode(z)),X=C6(U);return W+"."+A+"."+X}function GW(w,z){let U=C6(new TextEncoder().encode(w)),W=C6(new TextEncoder().encode(z)),A=U+"."+W;return new TextEncoder().encode(A)}var zG="https://appleid.apple.com/auth/authorize",UG="https://appleid.apple.com/auth/token";class u8{clientId;teamId;keyId;pkcs8PrivateKey;redirectURI;constructor(w,z,U,W,A){this.clientId=w,this.teamId=z,this.keyId=U,this.pkcs8PrivateKey=W,this.redirectURI=A}createAuthorizationURL(w,z){let U=new URL(zG);if(U.searchParams.set("response_type","code"),U.searchParams.set("client_id",this.clientId),U.searchParams.set("state",w),z.length>0)U.searchParams.set("scope",z.join(" "));return U.searchParams.set("redirect_uri",this.redirectURI),U}async validateAuthorizationCode(w){let z=new URLSearchParams;z.set("grant_type","authorization_code"),z.set("code",w),z.set("redirect_uri",this.redirectURI),z.set("client_id",this.clientId);let U=await this.createClientSecret();z.set("client_secret",U);let W=g(UG,z);return await c(W)}async createClientSecret(){let w=await crypto.subtle.importKey("pkcs8",this.pkcs8PrivateKey,{name:"ECDSA",namedCurve:"P-256"},!1,["sign"]),z=Math.floor(Date.now()/1000),U=JSON.stringify({typ:"JWT",alg:"ES256",kid:this.keyId}),W=JSON.stringify({iss:this.teamId,exp:z+300,aud:["https://appleid.apple.com"],sub:this.clientId,iat:z}),A=new Uint8Array(await crypto.subtle.sign({name:"ECDSA",hash:"SHA-256"},w,GW(U,W)));return HW(U,W,A)}}var WG="https://auth.atlassian.com/authorize",NW="https://auth.atlassian.com/oauth/token";class m8{clientId;clientSecret;redirectURI;constructor(w,z,U){this.clientId=w,this.clientSecret=z,this.redirectURI=U}createAuthorizationURL(w,z){let U=new URL(WG);if(U.searchParams.set("response_type","code"),U.searchParams.set("client_id",this.clientId),U.searchParams.set("state",w),z.length>0)U.searchParams.set("scope",z.join(" "));return U.searchParams.set("redirect_uri",this.redirectURI),U.searchParams.set("audience","api.atlassian.com"),U.searchParams.set("prompt","consent"),U}async validateAuthorizationCode(w){let z=new URLSearchParams;z.set("grant_type","authorization_code"),z.set("code",w),z.set("redirect_uri",this.redirectURI),z.set("client_id",this.clientId),z.set("client_secret",this.clientSecret);let U=g(NW,z);return await c(U)}async refreshAccessToken(w){let z=new URLSearchParams;z.set("grant_type","refresh_token"),z.set("refresh_token",w),z.set("client_id",this.clientId),z.set("client_secret",this.clientSecret);let U=g(NW,z);return await c(U)}}class t8{authorizationEndpoint;tokenEndpoint;tokenRevocationEndpoint;client;constructor(w,z,U,W){this.authorizationEndpoint=`https://${w}/authorize`,this.tokenEndpoint=`https://${w}/oauth/token`,this.tokenRevocationEndpoint=`https://${w}/oauth/revoke`,this.client=new f(z,U,W)}createAuthorizationURL(w,z,U){let W;if(z!==null)W=this.client.createAuthorizationURLWithPKCE(this.authorizationEndpoint,w,W0.S256,z,U);else W=this.client.createAuthorizationURL(this.authorizationEndpoint,w,U);return W}async validateAuthorizationCode(w,z){return await this.client.validateAuthorizationCode(this.tokenEndpoint,w,z)}async refreshAccessToken(w){return await this.client.refreshAccessToken(this.tokenEndpoint,w,[])}async revokeToken(w){await this.client.revokeToken(this.tokenRevocationEndpoint,w)}}class p8{authorizationEndpoint;tokenEndpoint;tokenRevocationEndpoint;client;constructor(w,z,U,W){this.authorizationEndpoint=M2(w,"/application/o/authorize"),this.tokenEndpoint=M2(w,"/application/o/token"),this.tokenRevocationEndpoint=M2(w,"/application/o/revoke"),this.client=new f(z,U,W)}createAuthorizationURL(w,z,U){return this.client.createAuthorizationURLWithPKCE(this.authorizationEndpoint,w,W0.S256,z,U)}async validateAuthorizationCode(w,z){return await this.client.validateAuthorizationCode(this.tokenEndpoint,w,z)}async refreshAccessToken(w){return await this.client.refreshAccessToken(this.tokenEndpoint,w,[])}async revokeToken(w){await this.client.revokeToken(this.tokenRevocationEndpoint,w)}}var AG="https://bitbucket.org/site/oauth2/authorize",SW="https://bitbucket.org/site/oauth2/access_token";class o8{client;constructor(w,z,U){this.client=new f(w,z,U)}createAuthorizationURL(w){return this.client.createAuthorizationURL(AG,w,[])}async validateAuthorizationCode(w){return await this.client.validateAuthorizationCode(SW,w,null)}async refreshAccessToken(w){return await this.client.refreshAccessToken(SW,w,[])}}var XG="https://account.box.com/api/oauth2/authorize",_W="https://api.box.com/oauth2/token",ZG="https://api.box.com/oauth2/revoke";class l8{clientId;clientSecret;redirectURI;constructor(w,z,U){this.clientId=w,this.clientSecret=z,this.redirectURI=U}createAuthorizationURL(w,z){let U=new URL(XG);if(U.searchParams.set("response_type","code"),U.searchParams.set("client_id",this.clientId),U.searchParams.set("state",w),z.length>0)U.searchParams.set("scope",z.join(" "));return U.searchParams.set("redirect_uri",this.redirectURI),U}async validateAuthorizationCode(w){let z=new URLSearchParams;z.set("grant_type","authorization_code"),z.set("code",w),z.set("redirect_uri",this.redirectURI),z.set("client_id",this.clientId),z.set("client_secret",this.clientSecret);let U=g(_W,z);return await c(U)}async refreshAccessToken(w){let z=new URLSearchParams;z.set("grant_type","refresh_token"),z.set("refresh_token",w),z.set("client_id",this.clientId),z.set("client_secret",this.clientSecret);let U=g(_W,z);return await c(U)}async revokeToken(w){let z=new URLSearchParams;z.set("token",w),z.set("client_id",this.clientId),z.set("client_secret",this.clientSecret);let U=g(ZG,z);await A4(U)}}var $G="https://www.coinbase.com/oauth/authorize",DW="https://www.coinbase.com/oauth/token",QG="https://api.coinbase.com/oauth/revoke";class s8{clientId;clientSecret;redirectURI;constructor(w,z,U){this.clientId=w,this.clientSecret=z,this.redirectURI=U}createAuthorizationURL(w,z){let U=new URL($G);if(U.searchParams.set("response_type","code"),U.searchParams.set("client_id",this.clientId),U.searchParams.set("state",w),z.length>0)U.searchParams.set("scope",z.join(" "));return U.searchParams.set("redirect_uri",this.redirectURI),U}async validateAuthorizationCode(w){let z=new URLSearchParams;z.set("grant_type","authorization_code"),z.set("code",w),z.set("redirect_uri",this.redirectURI),z.set("client_id",this.clientId),z.set("client_secret",this.clientSecret);let U=g(DW,z);return await c(U)}async refreshAccessToken(w){let z=new URLSearchParams;z.set("grant_type","refresh_token"),z.set("refresh_token",w),z.set("client_id",this.clientId),z.set("client_secret",this.clientSecret);let U=g(DW,z);return await c(U)}async revokeToken(w){let z=new URLSearchParams;z.set("token",w),z.set("client_id",this.clientId),z.set("client_secret",this.clientSecret);let U=g(QG,z);await A4(U)}}var PW="https://discord.com/oauth2/authorize",OW="https://discord.com/api/oauth2/token",YG="https://discord.com/api/oauth2/token/revoke";class r8{client;constructor(w,z,U){this.client=new f(w,z,U)}createAuthorizationURL(w,z,U){let W;if(z!==null)W=this.client.createAuthorizationURLWithPKCE(PW,w,W0.S256,z,U);else W=this.client.createAuthorizationURL(PW,w,U);return W}async validateAuthorizationCode(w,z){return await this.client.validateAuthorizationCode(OW,w,z)}async refreshAccessToken(w){return await this.client.refreshAccessToken(OW,w,[])}async revokeToken(w){await this.client.revokeToken(YG,w)}}var JG="https://dribbble.com/oauth/authorize",BG="https://dribbble.com/oauth/token";class a8{clientId;clientSecret;redirectURI;constructor(w,z,U){this.clientId=w,this.clientSecret=z,this.redirectURI=U}createAuthorizationURL(w,z){let U=new URL(JG);if(U.searchParams.set("response_type","code"),U.searchParams.set("client_id",this.clientId),U.searchParams.set("state",w),z.length>0)U.searchParams.set("scope",z.join(" "));return U.searchParams.set("redirect_uri",this.redirectURI),U}async validateAuthorizationCode(w){let z=new URLSearchParams;z.set("grant_type","authorization_code"),z.set("code",w),z.set("redirect_uri",this.redirectURI),z.set("client_id",this.clientId),z.set("client_secret",this.clientSecret);let U=g(BG,z);return await c(U)}}var MG="https://www.dropbox.com/oauth2/authorize",bW="https://api.dropboxapi.com/oauth2/token",qG="https://api.dropboxapi.com/2/auth/token/revoke";class e8{client;constructor(w,z,U){this.client=new f(w,z,U)}createAuthorizationURL(w,z){return this.client.createAuthorizationURL(MG,w,z)}async validateAuthorizationCode(w){return await this.client.validateAuthorizationCode(bW,w,null)}async refreshAccessToken(w){return await this.client.refreshAccessToken(bW,w,[])}async revokeToken(w){await this.client.revokeToken(qG,w)}}var HG="https://www.facebook.com/v16.0/dialog/oauth",GG="https://graph.facebook.com/v16.0/oauth/access_token";class w5{clientId;clientSecret;redirectURI;constructor(w,z,U){this.clientId=w,this.clientSecret=z,this.redirectURI=U}createAuthorizationURL(w,z){let U=new URL(HG);if(U.searchParams.set("response_type","code"),U.searchParams.set("client_id",this.clientId),U.searchParams.set("state",w),z.length>0)U.searchParams.set("scope",z.join(" "));return U.searchParams.set("redirect_uri",this.redirectURI),U}async validateAuthorizationCode(w){let z=new URLSearchParams;z.set("grant_type","authorization_code"),z.set("code",w),z.set("redirect_uri",this.redirectURI),z.set("client_id",this.clientId),z.set("client_secret",this.clientSecret);let U=g(GG,z);return await c(U)}}var LG="https://www.figma.com/oauth",NG="https://www.figma.com/api/oauth/token";class z5{client;constructor(w,z,U){this.client=new f(w,z,U)}createAuthorizationURL(w,z){return this.client.createAuthorizationURL(LG,w,z)}async validateAuthorizationCode(w){return await this.client.validateAuthorizationCode(NG,w,null)}}var SG="https://appcenter.intuit.com/connect/oauth2",RW="https://oauth.platform.intuit.com/oauth2/v1/tokens/bearer",_G="https://developer.API.intuit.com/v2/oauth2/tokens/revoke";class U5{client;constructor(w,z,U){this.client=new f(w,z,U)}createAuthorizationURL(w,z){return this.client.createAuthorizationURL(SG,w,z)}async validateAuthorizationCode(w){return await this.client.validateAuthorizationCode(RW,w,null)}async refreshAccessToken(w){return await this.client.refreshAccessToken(RW,w,[])}async revokeToken(w){await this.client.revokeToken(_G,w)}}var DG="https://github.com/login/oauth/authorize",CW="https://github.com/login/oauth/access_token";class W5{clientId;clientSecret;redirectURI;constructor(w,z,U){this.clientId=w,this.clientSecret=z,this.redirectURI=U}createAuthorizationURL(w,z){let U=new URL(DG);if(U.searchParams.set("response_type","code"),U.searchParams.set("client_id",this.clientId),U.searchParams.set("state",w),z.length>0)U.searchParams.set("scope",z.join(" "));if(this.redirectURI!==null)U.searchParams.set("redirect_uri",this.redirectURI);return U}async validateAuthorizationCode(w){let z=new URLSearchParams;if(z.set("grant_type","authorization_code"),z.set("code",w),this.redirectURI!==null)z.set("redirect_uri",this.redirectURI);let U=g(CW,z),W=R6(this.clientId,this.clientSecret);return U.headers.set("Authorization",`Basic ${W}`),await KW(U)}async refreshAccessToken(w){let z=new URLSearchParams;z.set("grant_type","refresh_token"),z.set("refresh_token",w);let U=g(CW,z),W=R6(this.clientId,this.clientSecret);return U.headers.set("Authorization",`Basic ${W}`),await KW(U)}}async function KW(w){let z;try{z=await fetch(w)}catch(A){throw new $6(A)}if(z.status!==200){if(z.body!==null)await z.body.cancel();throw new v1(z.status)}let U;try{U=await z.json()}catch{throw new v1(z.status)}if(typeof U!=="object"||U===null)throw new q1(z.status,U);if("error"in U&&typeof U.error==="string"){let A;try{A=c8(U)}catch{throw new q1(z.status,U)}throw A}return new U4(U)}class A5{authorizationEndpoint;tokenEndpoint;tokenRevocationEndpoint;client;constructor(w,z,U,W){this.authorizationEndpoint=M2(w,"/oauth/authorize"),this.tokenEndpoint=M2(w,"/oauth/token"),this.tokenRevocationEndpoint=M2(w,"/oauth/revoke"),this.client=new f(z,U,W)}createAuthorizationURL(w,z){return this.client.createAuthorizationURL(this.authorizationEndpoint,w,z)}async validateAuthorizationCode(w){return await this.client.validateAuthorizationCode(this.tokenEndpoint,w,null)}async refreshAccessToken(w){return await this.client.refreshAccessToken(this.tokenEndpoint,w,[])}async revokeToken(w){await this.client.revokeToken(this.tokenRevocationEndpoint,w)}}var PG="https://accounts.google.com/o/oauth2/v2/auth",FW="https://oauth2.googleapis.com/token",OG="https://oauth2.googleapis.com/revoke";class X5{client;constructor(w,z,U){this.client=new f(w,z,U)}createAuthorizationURL(w,z,U){return this.client.createAuthorizationURLWithPKCE(PG,w,W0.S256,z,U)}async validateAuthorizationCode(w,z){return await this.client.validateAuthorizationCode(FW,w,z)}async refreshAccessToken(w){return await this.client.refreshAccessToken(FW,w,[])}async revokeToken(w){await this.client.revokeToken(OG,w)}}var bG="https://kauth.kakao.com/oauth/authorize",jW="https://kauth.kakao.com/oauth/token";class Z5{clientId;clientSecret;redirectURI;constructor(w,z,U){this.clientId=w,this.clientSecret=z,this.redirectURI=U}createAuthorizationURL(w,z){let U=new URL(bG);if(U.searchParams.set("response_type","code"),U.searchParams.set("client_id",this.clientId),U.searchParams.set("state",w),z.length>0)U.searchParams.set("scope",z.join(" "));return U.searchParams.set("redirect_uri",this.redirectURI),U}async validateAuthorizationCode(w){let z=new URLSearchParams;z.set("grant_type","authorization_code"),z.set("code",w),z.set("redirect_uri",this.redirectURI),z.set("client_id",this.clientId),z.set("client_secret",this.clientSecret);let U=g(jW,z);return await c(U)}async refreshAccessToken(w){let z=new URLSearchParams;z.set("grant_type","refresh_token"),z.set("refresh_token",w),z.set("client_id",this.clientId),z.set("client_secret",this.clientSecret);let U=g(jW,z);return await c(U)}}class $5{authorizationEndpoint;tokenEndpoint;tokenRevocationEndpoint;client;constructor(w,z,U,W){this.authorizationEndpoint=w+"/protocol/openid-connect/auth",this.tokenEndpoint=w+"/protocol/openid-connect/token",this.tokenRevocationEndpoint=w+"/protocol/openid-connect/revoke",this.client=new f(z,U,W)}createAuthorizationURL(w,z,U){return this.client.createAuthorizationURLWithPKCE(this.authorizationEndpoint,w,W0.S256,z,U)}async validateAuthorizationCode(w,z){return await this.client.validateAuthorizationCode(this.tokenEndpoint,w,z)}async refreshAccessToken(w){return await this.client.refreshAccessToken(this.tokenEndpoint,w,[])}async revokeToken(w){await this.client.revokeToken(this.tokenRevocationEndpoint,w)}}var RG="https://lichess.org/oauth",CG="https://lichess.org/api/token";class Q5{client;constructor(w,z){this.client=new f(w,null,z)}createAuthorizationURL(w,z,U){return this.client.createAuthorizationURLWithPKCE(RG,w,W0.S256,z,U)}async validateAuthorizationCode(w,z){return await this.client.validateAuthorizationCode(CG,w,z)}}var KG="https://access.line.me/oauth2/v2.1/authorize",EW="https://api.line.me/oauth2/v2.1/token";class Y5{clientId;clientSecret;redirectURI;constructor(w,z,U){this.clientId=w,this.clientSecret=z,this.redirectURI=U}createAuthorizationURL(w,z,U){let W=new URL(KG);if(W.searchParams.set("response_type","code"),W.searchParams.set("client_id",this.clientId),W.searchParams.set("state",w),U.length>0)W.searchParams.set("scope",U.join(" "));W.searchParams.set("redirect_uri",this.redirectURI);let A=W4(z);return W.searchParams.set("code_challenge_method","S256"),W.searchParams.set("code_challenge",A),W}async validateAuthorizationCode(w,z){let U=new URLSearchParams;U.set("grant_type","authorization_code"),U.set("code",w),U.set("code_verifier",z),U.set("redirect_uri",this.redirectURI),U.set("client_id",this.clientId),U.set("client_secret",this.clientSecret);let W=g(EW,U);return await c(W)}async refreshAccessToken(w){let z=new URLSearchParams;z.set("grant_type","refresh_token"),z.set("refresh_token",w),z.set("client_id",this.clientId),z.set("client_secret",this.clientSecret);let U=g(EW,z);return await c(U)}}var FG="https://linear.app/oauth/authorize",jG="https://api.linear.app/oauth/token";class J5{clientId;clientSecret;redirectURI;constructor(w,z,U){this.clientId=w,this.clientSecret=z,this.redirectURI=U}createAuthorizationURL(w,z){let U=new URL(FG);if(U.searchParams.set("response_type","code"),U.searchParams.set("client_id",this.clientId),U.searchParams.set("state",w),z.length>0)U.searchParams.set("scope",z.join(" "));return U.searchParams.set("redirect_uri",this.redirectURI),U}async validateAuthorizationCode(w){let z=new URLSearchParams;z.set("grant_type","authorization_code"),z.set("code",w),z.set("redirect_uri",this.redirectURI),z.set("client_id",this.clientId),z.set("client_secret",this.clientSecret);let U=g(jG,z);return await c(U)}}var EG="https://www.linkedin.com/oauth/v2/authorization",IW="https://www.linkedin.com/oauth/v2/accessToken";class B5{clientId;clientSecret;redirectURI;constructor(w,z,U){this.clientId=w,this.clientSecret=z,this.redirectURI=U}createAuthorizationURL(w,z){let U=new URL(EG);if(U.searchParams.set("response_type","code"),U.searchParams.set("client_id",this.clientId),U.searchParams.set("state",w),z.length>0)U.searchParams.set("scope",z.join(" "));return U.searchParams.set("redirect_uri",this.redirectURI),U}async validateAuthorizationCode(w){let z=new URLSearchParams;z.set("grant_type","authorization_code"),z.set("code",w),z.set("redirect_uri",this.redirectURI),z.set("client_id",this.clientId),z.set("client_secret",this.clientSecret);let U=g(IW,z);return await c(U)}async refreshAccessToken(w){let z=new URLSearchParams;z.set("grant_type","refresh_token"),z.set("refresh_token",w),z.set("client_id",this.clientId),z.set("client_secret",this.clientSecret);let U=g(IW,z);return await c(U)}}class M5{authorizationEndpoint;tokenEndpoint;client;constructor(w,z,U,W){this.authorizationEndpoint=M2("https://login.microsoftonline.com",w,"/oauth2/v2.0/authorize"),this.tokenEndpoint=M2("https://login.microsoftonline.com",w,"/oauth2/v2.0/token"),this.client=new f(z,U,W)}createAuthorizationURL(w,z,U){return this.client.createAuthorizationURLWithPKCE(this.authorizationEndpoint,w,W0.S256,z,U)}async validateAuthorizationCode(w,z){return await this.client.validateAuthorizationCode(this.tokenEndpoint,w,z)}async refreshAccessToken(w,z){return await this.client.refreshAccessToken(this.tokenEndpoint,w,z)}}var IG="https://myanimelist.net/v1/oauth2/authorize",xW="https://myanimelist.net/v1/oauth2/token";class q5{client;constructor(w,z,U){this.client=new f(w,z,U)}createAuthorizationURL(w,z){return this.client.createAuthorizationURLWithPKCE(IG,w,W0.Plain,z,[])}async validateAuthorizationCode(w,z){return await this.client.validateAuthorizationCode(xW,w,z)}async refreshAccessToken(w){return await this.client.refreshAccessToken(xW,w,[])}}var xG="https://api.notion.com/v1/oauth/authorize",VG="https://api.notion.com/v1/oauth/token";class H5{client;constructor(w,z,U){this.client=new f(w,z,U)}createAuthorizationURL(w){let z=this.client.createAuthorizationURL(xG,w,[]);return z.searchParams.set("owner","user"),z}async validateAuthorizationCode(w){return await this.client.validateAuthorizationCode(VG,w,null)}}class G5{authorizationEndpoint;tokenEndpoint;tokenRevocationEndpoint;client;constructor(w,z,U,W,A){let X=`https://${w}/oauth2`;if(z!==null)X=M2(X,z);this.authorizationEndpoint=M2(X,"/v1/authorize"),this.tokenEndpoint=M2(X,"/v1/token"),this.tokenRevocationEndpoint=M2(X,"/v1/revoke"),this.client=new f(U,W,A)}createAuthorizationURL(w,z,U){return this.client.createAuthorizationURLWithPKCE(this.authorizationEndpoint,w,W0.S256,z,U)}async validateAuthorizationCode(w,z){return await this.client.validateAuthorizationCode(this.tokenEndpoint,w,z)}async refreshAccessToken(w,z){return await this.client.refreshAccessToken(this.tokenEndpoint,w,z)}async revokeToken(w){await this.client.revokeToken(this.tokenRevocationEndpoint,w)}}var kG="https://osu.ppy.sh/oauth/authorize",VW="https://osu.ppy.sh/oauth/token";class L5{clientId;clientSecret;redirectURI;constructor(w,z,U){this.clientId=w,this.clientSecret=z,this.redirectURI=U}createAuthorizationURL(w,z){let U=new URL(kG);if(U.searchParams.set("response_type","code"),U.searchParams.set("client_id",this.clientId),U.searchParams.set("state",w),z.length>0)U.searchParams.set("scope",z.join(" "));if(this.redirectURI!==null)U.searchParams.set("redirect_uri",this.redirectURI);return U}async validateAuthorizationCode(w){let z=new URLSearchParams;if(z.set("grant_type","authorization_code"),z.set("code",w),this.redirectURI!==null)z.set("redirect_uri",this.redirectURI);z.set("client_id",this.clientId),z.set("client_secret",this.clientSecret);let U=g(VW,z);return await c(U)}async refreshAccessToken(w){let z=new URLSearchParams;z.set("grant_type","refresh_token"),z.set("refresh_token",w),z.set("client_id",this.clientId),z.set("client_secret",this.clientSecret);let U=g(VW,z);return await c(U)}}var TG="https://www.patreon.com/oauth2/authorize",kW="https://www.patreon.com/api/oauth2/token";class N5{clientId;clientSecret;redirectURI;constructor(w,z,U){this.clientId=w,this.clientSecret=z,this.redirectURI=U}createAuthorizationURL(w,z){let U=new URL(TG);if(U.searchParams.set("response_type","code"),U.searchParams.set("client_id",this.clientId),U.searchParams.set("state",w),z.length>0)U.searchParams.set("scope",z.join(" "));return U.searchParams.set("redirect_uri",this.redirectURI),U}async validateAuthorizationCode(w){let z=new URLSearchParams;z.set("grant_type","authorization_code"),z.set("code",w),z.set("redirect_uri",this.redirectURI),z.set("client_id",this.clientId),z.set("client_secret",this.clientSecret);let U=g(kW,z);return await c(U)}async refreshAccessToken(w){let z=new URLSearchParams;z.set("grant_type","refresh_token"),z.set("refresh_token",w),z.set("client_id",this.clientId),z.set("client_secret",this.clientSecret);let U=g(kW,z);return await c(U)}}var gG="https://www.reddit.com/api/v1/authorize",TW="https://www.reddit.com/api/v1/access_token";class S5{client;constructor(w,z,U){this.client=new f(w,z,U)}createAuthorizationURL(w,z){return this.client.createAuthorizationURL(gG,w,z)}async validateAuthorizationCode(w){return await this.client.validateAuthorizationCode(TW,w,null)}async refreshAccessToken(w){return await this.client.refreshAccessToken(TW,w,[])}}var fG="https://apis.roblox.com/oauth/v1/authorize",gW="https://apis.roblox.com/oauth/v1/token",dG="https://apis.roblox.com/oauth/v1/token/revoke";class _5{client;constructor(w,z,U){this.client=new f(w,z,U)}createAuthorizationURL(w,z,U){return this.client.createAuthorizationURLWithPKCE(fG,w,W0.S256,z,U)}async validateAuthorizationCode(w,z){return await this.client.validateAuthorizationCode(gW,w,z)}async refreshAccessToken(w){return await this.client.refreshAccessToken(gW,w,[])}async revokeToken(w){await this.client.revokeToken(dG,w)}}class D5{authorizationEndpoint;tokenEndpoint;tokenRevocationEndpoint;client;constructor(w,z,U,W){this.authorizationEndpoint=`https://${w}/services/oauth2/authorize`,this.tokenEndpoint=`https://${w}/services/oauth2/token`,this.tokenRevocationEndpoint=`https://${w}/services/oauth2/revoke`,this.client=new f(z,U,W)}createAuthorizationURL(w,z,U){return this.client.createAuthorizationURLWithPKCE(this.authorizationEndpoint,w,W0.S256,z,U)}async validateAuthorizationCode(w,z){return await this.client.validateAuthorizationCode(this.tokenEndpoint,w,z)}async refreshAccessToken(w){return await this.client.refreshAccessToken(this.tokenEndpoint,w,[])}async revokeToken(w){await this.client.revokeToken(this.tokenRevocationEndpoint,w)}}var hG="https://shikimori.one/oauth/authorize",fW="https://shikimori.one/oauth/token";class P5{clientId;clientSecret;redirectURI;constructor(w,z,U){this.clientId=w,this.clientSecret=z,this.redirectURI=U}createAuthorizationURL(w){let z=new URL(hG);return z.searchParams.set("response_type","code"),z.searchParams.set("client_id",this.clientId),z.searchParams.set("state",w),z.searchParams.set("redirect_uri",this.redirectURI),z}async validateAuthorizationCode(w){let z=new URLSearchParams;z.set("grant_type","authorization_code"),z.set("code",w),z.set("redirect_uri",this.redirectURI),z.set("client_id",this.clientId),z.set("client_secret",this.clientSecret);let U=g(fW,z);return await c(U)}async refreshAccessToken(w){let z=new URLSearchParams;z.set("grant_type","refresh_token"),z.set("refresh_token",w),z.set("client_id",this.clientId),z.set("client_secret",this.clientSecret);let U=g(fW,z);return await c(U)}}var yG="https://slack.com/openid/connect/authorize",cG="https://slack.com/api/openid.connect.token";class O5{client;constructor(w,z,U){this.client=new f(w,z,U)}createAuthorizationURL(w,z){return this.client.createAuthorizationURL(yG,w,z)}async validateAuthorizationCode(w){return await this.client.validateAuthorizationCode(cG,w,null)}}var dW="https://accounts.spotify.com/authorize",hW="https://accounts.spotify.com/api/token";class b5{client;constructor(w,z,U){this.client=new f(w,z,U)}createAuthorizationURL(w,z,U){let W;if(z!==null)W=this.client.createAuthorizationURLWithPKCE(dW,w,W0.S256,z,U);else W=this.client.createAuthorizationURL(dW,w,U);return W}async validateAuthorizationCode(w,z){return await this.client.validateAuthorizationCode(hW,w,z)}async refreshAccessToken(w){return await this.client.refreshAccessToken(hW,w,[])}}var iG="https://www.strava.com/oauth/authorize",vG="https://www.strava.com/oauth/token";class R5{clientId;clientSecret;redirectURI;constructor(w,z,U){this.clientId=w,this.clientSecret=z,this.redirectURI=U}createAuthorizationURL(w,z){let U=new URL(iG);if(U.searchParams.set("response_type","code"),U.searchParams.set("client_id",this.clientId),U.searchParams.set("state",w),z.length>0)U.searchParams.set("scope",z.join(","));return U.searchParams.set("redirect_uri",this.redirectURI),U}async validateAuthorizationCode(w){let z=new URLSearchParams;z.set("grant_type","authorization_code"),z.set("code",w),z.set("redirect_uri",this.redirectURI),z.set("client_id",this.clientId),z.set("client_secret",this.clientSecret);let U=g(vG,z);return await c(U)}}var nG="https://v5api.tiltify.com/oauth/authorizeze",yW="https://v5api.tiltify.com/oauth/token";class C5{clientId;clientSecret;redirectURI;constructor(w,z,U){this.clientId=w,this.clientSecret=z,this.redirectURI=U}createAuthorizationURL(w,z){let U=new URL(nG);if(U.searchParams.set("response_type","code"),U.searchParams.set("client_id",this.clientId),U.searchParams.set("state",w),z.length>0)U.searchParams.set("scope",z.join(" "));return U.searchParams.set("redirect_uri",this.redirectURI),U}async validateAuthorizationCode(w){let z=new URLSearchParams;z.set("grant_type","authorization_code"),z.set("code",w),z.set("redirect_uri",this.redirectURI),z.set("client_id",this.clientId),z.set("client_secret",this.clientSecret);let U=g(yW,z);return await c(U)}async refreshAccessToken(w){let z=new URLSearchParams;z.set("grant_type","refresh_token"),z.set("refresh_token",w),z.set("client_id",this.clientId),z.set("client_secret",this.clientSecret);let U=g(yW,z);return await c(U)}}var uG="https://www.tumblr.com/oauth2/authorize",cW="https://api.tumblr.com/v2/oauth2/token";class K5{client;constructor(w,z,U){this.client=new f(w,z,U)}createAuthorizationURL(w,z){return this.client.createAuthorizationURL(uG,w,z)}async validateAuthorizationCode(w){return await this.client.validateAuthorizationCode(cW,w,null)}async refreshAccessToken(w){return await this.client.refreshAccessToken(cW,w,[])}}var mG="https://id.twitch.tv/oauth2/authorize",iW="https://id.twitch.tv/oauth2/token";class F5{clientId;clientSecret;redirectURI;constructor(w,z,U){this.clientId=w,this.clientSecret=z,this.redirectURI=U}createAuthorizationURL(w,z){let U=new URL(mG);if(U.searchParams.set("response_type","code"),U.searchParams.set("client_id",this.clientId),U.searchParams.set("state",w),z.length>0)U.searchParams.set("scope",z.join(" "));return U.searchParams.set("redirect_uri",this.redirectURI),U}async validateAuthorizationCode(w){let z=new URLSearchParams;z.set("grant_type","authorization_code"),z.set("code",w),z.set("redirect_uri",this.redirectURI),z.set("client_id",this.clientId),z.set("client_secret",this.clientSecret);let U=g(iW,z);return await c(U)}async refreshAccessToken(w){let z=new URLSearchParams;z.set("grant_type","refresh_token"),z.set("refresh_token",w),z.set("client_id",this.clientId),z.set("client_secret",this.clientSecret);let U=g(iW,z);return await c(U)}}var tG="https://twitter.com/i/oauth2/authorize",vW="https://api.twitter.com/2/oauth2/token",pG="https://api.twitter.com/2/oauth2/revoke";class j5{client;constructor(w,z,U){this.client=new f(w,z,U)}createAuthorizationURL(w,z,U){return this.client.createAuthorizationURLWithPKCE(tG,w,W0.S256,z,U)}async validateAuthorizationCode(w,z){return await this.client.validateAuthorizationCode(vW,w,z)}async refreshAccessToken(w){return await this.client.refreshAccessToken(vW,w,[])}async revokeToken(w){await this.client.revokeToken(pG,w)}}var oG="https://oauth.vk.com/authorize",lG="https://oauth.vk.com/access_token";class E5{clientId;clientSecret;redirectURI;constructor(w,z,U){this.clientId=w,this.clientSecret=z,this.redirectURI=U}createAuthorizationURL(w,z){let U=new URL(oG);if(U.searchParams.set("response_type","code"),U.searchParams.set("client_id",this.clientId),U.searchParams.set("state",w),z.length>0)U.searchParams.set("scope",z.join(" "));return U.searchParams.set("redirect_uri",this.redirectURI),U}async validateAuthorizationCode(w){let z=new URLSearchParams;z.set("grant_type","authorization_code"),z.set("code",w),z.set("redirect_uri",this.redirectURI),z.set("client_id",this.clientId),z.set("client_secret",this.clientSecret);let U=g(lG,z);return await c(U)}}var sG="https://api.workos.com/sso/authorize",rG="https://api.workos.com/sso/token";class I5{clientId;clientSecret;redirectURI;constructor(w,z,U){this.clientId=w,this.clientSecret=z,this.redirectURI=U}createAuthorizationURL(w,z){let U=new URL(sG);if(U.searchParams.set("response_type","code"),U.searchParams.set("client_id",this.clientId),U.searchParams.set("state",w),U.searchParams.set("redirect_uri",this.redirectURI),z!==null){let W=W4(z);U.searchParams.set("code_challenge_method","S256"),U.searchParams.set("code_challenge",W)}return U}async validateAuthorizationCode(w,z){let U=new URLSearchParams;if(U.set("grant_type","authorization_code"),U.set("code",w),U.set("redirect_uri",this.redirectURI),U.set("client_id",this.clientId),this.clientSecret!==null)U.set("client_secret",this.clientSecret);if(z!==null)U.set("code_verifier",z);let W=g(rG,U);return await c(W)}}var aG="https://api.login.yahoo.com/oauth2/request_auth",nW="https://api.login.yahoo.com/oauth2/get_token";class x5{client;constructor(w,z,U){this.client=new f(w,z,U)}createAuthorizationURL(w,z){return this.client.createAuthorizationURL(aG,w,z)}async validateAuthorizationCode(w){return await this.client.validateAuthorizationCode(nW,w,null)}async refreshAccessToken(w){return await this.client.refreshAccessToken(nW,w,[])}}var eG="https://oauth.yandex.com/authorize",uW="https://oauth.yandex.com/token";class V5{client;constructor(w,z,U){this.client=new f(w,z,U)}createAuthorizationURL(w,z){return this.client.createAuthorizationURL(eG,w,z)}async validateAuthorizationCode(w){return await this.client.validateAuthorizationCode(uW,w,null)}async refreshAccessToken(w){return await this.client.refreshAccessToken(uW,w,[])}}var wL="https://zoom.us/oauth/authorize",mW="https://zoom.us/oauth/token",zL="https://zoom.us/oauth/revoke";class k5{client;constructor(w,z,U){this.client=new f(w,z,U)}createAuthorizationURL(w,z,U){return this.client.createAuthorizationURLWithPKCE(wL,w,W0.S256,z,U)}async validateAuthorizationCode(w,z){return await this.client.validateAuthorizationCode(mW,w,z)}async refreshAccessToken(w){return await this.client.refreshAccessToken(mW,w,[])}async revokeToken(w){await this.client.revokeToken(zL,w)}}var UL="https://api.intra.42.fr/oauth/authorize",WL="https://api.intra.42.fr/oauth/token";class T5{clientId;clientSecret;redirectURI;constructor(w,z,U){this.clientId=w,this.clientSecret=z,this.redirectURI=U}createAuthorizationURL(w,z){let U=new URL(UL);if(U.searchParams.set("response_type","code"),U.searchParams.set("client_id",this.clientId),U.searchParams.set("state",w),z.length>0)U.searchParams.set("scope",z.join(" "));return U.searchParams.set("redirect_uri",this.redirectURI),U}async validateAuthorizationCode(w){let z=new URLSearchParams;z.set("grant_type","authorization_code"),z.set("code",w),z.set("redirect_uri",this.redirectURI),z.set("client_id",this.clientId),z.set("client_secret",this.clientSecret);let U=g(WL,z);return await c(U)}}function rw(w){try{return qW(w)}catch(z){throw new Error("Invalid ID token",{cause:z})}}var c4={AmazonCognito:i8,AniList:v8,Apple:u8,Atlassian:m8,Auth0:t8,Authentik:p8,Bitbucket:o8,Box:l8,Coinbase:s8,Discord:r8,Dribbble:a8,Dropbox:e8,Facebook:w5,Figma:z5,Intuit:U5,GitHub:W5,GitLab:A5,Google:X5,Kakao:Z5,KeyCloak:$5,Lichess:Q5,Line:Y5,Linear:J5,LinkedIn:B5,MicrosoftEntraId:M5,MyAnimeList:q5,Notion:H5,Okta:G5,Osu:L5,Patreon:N5,Reddit:S5,Roblox:_5,Salesforce:D5,Shikimori:P5,Slack:O5,Spotify:b5,Strava:R5,Tiltify:C5,Tumblr:K5,Twitch:F5,Twitter:j5,VK:E5,WorkOS:I5,Yahoo:x5,Yandex:V5,Zoom:k5,FortyTwo:T5},tW=Object.keys(c4).reduce((w,z)=>{return w[z.toLowerCase()]=z,w},{}),i4={AmazonCognito:"https://{region}.amazonaws.com/{userPoolId}/.well-known/openid-configuration",AniList:"https://graphql.anilist.co",Apple:"https://appleid.apple.com/auth/token",Atlassian:"https://api.atlassian.com/me",Auth0:"https://{your_domain}/userinfo",Authentik:"https://{your_domain}/api/v1/user/me",Bitbucket:"https://api.bitbucket.org/2.0/user",Box:"https://api.box.com/2.0/users/me",Coinbase:"https://api.coinbase.com/v2/user",Discord:"https://discord.com/api/users/@me",Dribbble:"https://api.dribbble.com/v2/user",Dropbox:"https://api.dropboxapi.com/2/users/get_current_account",Facebook:"https://graph.facebook.com/me",Figma:"https://api.figma.com/v1/me",Intuit:"https://accounts.platform.intuit.com/v1/openid_connect/userinfo",GitHub:"https://api.github.com/user",GitLab:"https://gitlab.com/api/v4/user",Google:"https://www.googleapis.com/userinfo/v2/me",Kakao:"https://kapi.kakao.com/v2/user/me",KeyCloak:"https://{your_domain}/auth/realms/{realm}/protocol/openid-connect/userinfo",Lichess:"https://lichess.org/api/account",Line:"https://api.line.me/v2/profile",Linear:"https://api.linear.app/v1/me",LinkedIn:"https://api.linkedin.com/v2/me",MicrosoftEntraId:"https://graph.microsoft.com/v1.0/me",MyAnimeList:"https://myanimelist.net/v1/users/@me",Notion:"https://api.notion.com/v1/users/me",Okta:"https://{yourOktaDomain}/oauth2/v1/userinfo",Osu:"https://osu.ppy.sh/api/v2/me",Patreon:"https://www.patreon.com/api/oauth2/v2/identity",Reddit:"https://oauth.reddit.com/api/v1/me",Roblox:"https://apis.roblox.com/users/v1/users/me",Salesforce:"https://login.salesforce.com/services/oauth2/userinfo",Shikimori:"https://shikimori.one/api/users/whoami",Slack:"https://slack.com/api/users.identity",Spotify:"https://api.spotify.com/v1/me",Strava:"https://www.strava.com/api/v3/athlete",Tiltify:"https://tiltify.com/api/v3/user",Tumblr:"https://api.tumblr.com/v2/user/info",Twitch:"https://api.twitch.tv/helix/users",Twitter:"https://api.twitter.com/2/users/me",VK:"https://api.vk.com/method/users.get",WorkOS:"https://api.workos.com/sso/profile",Yahoo:"https://api.login.yahoo.com/openid/v1/userinfo",Yandex:"https://login.yandex.ru/info",Zoom:"https://api.zoom.us/v2/users/me",FortyTwo:"https://api.intra.42.fr/v2/me"},pW={AmazonCognito:"https://cognito-idp.{region}.amazonaws.com/{userPoolId}",AniList:"https://anilist.co/api/v2/oauth/authorize",Apple:"https://appleid.apple.com",Atlassian:"https://auth.atlassian.com",Auth0:"https://{your_domain}.auth0.com",Authentik:"https://{your_domain}",Bitbucket:"https://bitbucket.org/site/oauth2/authorize",Box:"https://account.box.com/api/oauth2/authorize",Coinbase:"https://www.coinbase.com/oauth/authorize",Discord:"https://discord.com/api/oauth2/authorize",Dribbble:"https://dribbble.com/oauth/authorize",Dropbox:"https://www.dropbox.com/oauth2/authorize",Facebook:"https://www.facebook.com/v12.0/dialog/oauth",Figma:"https://www.figma.com/oauth",Intuit:"https://appcenter.intuit.com/connect/oauth2",GitHub:"https://github.com/login/oauth/authorize",GitLab:"https://gitlab.com/oauth/authorize",Google:"https://accounts.google.com",Kakao:"https://kauth.kakao.com/oauth/authorize",KeyCloak:"https://{your_domain}/auth",Lichess:"https://lichess.org/oauth/authorize",Line:"https://access.line.me/oauth2/v2.1/authorize",Linear:"https://linear.app/oauth/authorize",LinkedIn:"https://www.linkedin.com/oauth/v2/authorization",MicrosoftEntraId:"https://login.microsoftonline.com/{tenant}/v2.0",MyAnimeList:"https://myanimelist.net/v1/oauth2/authorize",Notion:"https://api.notion.com/v1/oauth/authorize",Okta:"https://{yourOktaDomain}/oauth2/default/v1/authorize",Osu:"https://osu.ppy.sh/oauth/authorize",Patreon:"https://www.patreon.com/oauth2/authorize",Reddit:"https://www.reddit.com/api/v1/authorize",Roblox:"https://apis.roblox.com/oauth/v1/authorize",Salesforce:"https://login.salesforce.com/services/oauth2/authorize",Shikimori:"https://shikimori.one/oauth/authorize",Slack:"https://slack.com/oauth/v2/authorize",Spotify:"https://accounts.spotify.com/authorize",Strava:"https://www.strava.com/oauth/authorize",Tiltify:"https://tiltify.com/oauth/authorize",Tumblr:"https://www.tumblr.com/oauth/authorize",Twitch:"https://id.twitch.tv/oauth2/authorize",Twitter:"https://api.twitter.com/oauth/authorize",VK:"https://oauth.vk.com/authorize",WorkOS:"https://api.workos.com/sso/authorize",Yahoo:"https://api.login.yahoo.com/oauth2/request_auth",Yandex:"https://oauth.yandex.com/authorize",Zoom:"https://zoom.us/oauth/authorize",FortyTwo:"https://api.intra.42.fr/oauth/authorize"},oW=Object.keys(i4).reduce((w,z)=>{return w[z.toLowerCase()]=z,w},{}),IT=Object.keys(pW).reduce((w,z)=>{return w[z.toLowerCase()]=z,w},{});var lW=({logoutRoute:w="logout",onLogout:z})=>{return new j0().post(`/${w}`,async({error:U,cookie:{user_session_id:W,auth_provider:A}})=>{if(A.value===void 0)return U(401,"No auth provider found");try{return z?.(),W.remove(),A.remove(),new Response("Succesfuly Logged Out",{status:204})}catch(X){if(X instanceof Error)console.error("Failed to refresh token:",X.message);return U(500)}})};var sW=(w)=>{return"refreshAccessToken"in w&&typeof w.refreshAccessToken==="function"};var Q6=(w)=>{return Object.keys(c4).map((z)=>z.toLowerCase()).includes(w.toLowerCase())},rW=(w)=>{return Object.keys(i4).includes(w)};var aW=(w)=>{return!0};var eW=({clientProviders:w,revokeRoute:z="revoke",onRevoke:U})=>{return new j0().post(`/${z}/access-token`,async({error:W,cookie:{user_refresh_token:A,auth_provider:X}})=>{if(A.value===void 0)return W(401,"No refresh token found");if(X.value===void 0)return W(401,"No auth provider found");if(!Q6(X.value))return W(400,"Invalid provider");let Z=X.value.toLowerCase(),{providerInstance:$}=w[Z];U?.()})};var X4=()=>{return new j0({name:"sessionStore"}).state({session:{}})};var wA=({statusRoute:w="auth-status",onStatus:z})=>{return new j0().use(X4()).get(`/${w}`,async({error:U,cookie:{user_session_id:W,auth_provider:A},store:{session:X}})=>{try{if(W.value===void 0)return new Response(JSON.stringify({user:null}),{headers:{"Content-Type":"application/json"}});if(A.value===void 0)return new Response(JSON.stringify({user:null}),{headers:{"Content-Type":"application/json"}});let Z=X[W.value];if(Z===void 0)return new Response(JSON.stringify({user:null}),{headers:{"Content-Type":"application/json"}});let $=Z.user;return z?.(),new Response(JSON.stringify({user:$}),{headers:{"Content-Type":"application/json"}})}catch(Z){if(Z instanceof Error)console.error("Failed to get auth status: ",Z.message);return U(500)}})};var zA=({clientProviders:w,refreshRoute:z="refresh",onRefresh:U})=>{return new j0().post(`/${z}`,async({error:W,cookie:{user_refresh_token:A,auth_provider:X}})=>{if(A.value===void 0)return W(401,"No refresh token found");if(X.value===void 0)return W(401,"No auth provider found");let Z=X.value.toLowerCase(),{providerInstance:$}=w[Z];if(!sW($))return W(401,"Provider is not refreshable");try{let Q=await $.refreshAccessToken(A.value);return U?.(),new Response("Token refreshed",{status:204})}catch(Q){if(Q instanceof Error)console.error("Failed to refresh token:",Q.message);return W(500)}})};var UA=({clientProviders:w,authorizeRoute:z="authorize",onAuthorize:U})=>{return new j0().get(`/${z}/:provider`,({error:W,redirect:A,cookie:{state:X,code_verifier:Z,auth_provider:$,redirect_url:Q},params:{provider:Y},headers:B})=>{if(Y===void 0)return W(400,"Provider is required");if(!Q6(Y))return W(400,"Invalid provider");try{let G=Y.toLowerCase(),{providerInstance:_,scopes:H,searchParams:F}=w[G],R=B.referer||"/";Q.set({value:R,secure:!0,sameSite:"lax",path:"/",httpOnly:!0,maxAge:600}),$.set({value:Y,secure:!0,sameSite:"lax",path:"/",httpOnly:!0,maxAge:600});let J=ow();X.set({value:J,secure:!0,sameSite:"lax",path:"/",httpOnly:!0,maxAge:600});let m,A0;if(_.createAuthorizationURL.toString().includes("codeVerifier"))A0=pw(),Z.set({value:A0,secure:!0,sameSite:"lax",path:"/",httpOnly:!0,maxAge:600}),m=_.createAuthorizationURL(J,A0,H);else m=_.createAuthorizationURL(J,H);return F.forEach(([L0,h])=>{m.searchParams.set(L0,h)}),U?.(),A(m.toString())}catch(G){if(G instanceof Error)console.error("Failed to validate authorization code:",G.message);return W(500)}})};var WA=({clientProviders:w,callbackRoute:z="authorize/callback",onCallback:U,getUser:W,createUser:A})=>{return new j0().use(X4()).get(`/${z}`,async({error:X,redirect:Z,store:{session:$},cookie:{state:Q,code_verifier:Y,redirect_url:B,user_session_id:G,auth_provider:_},query:{code:H,state:F}})=>{if(!H||!Q.value)return X(400,"Invalid callback request");if(F!==Q.value)return X(400,"Invalid state mismatch");if(_.value===void 0)return X(401,"No auth provider found");if(!Q6(_.value))return X(400,"Invalid provider");let R=_.value.toLowerCase(),{providerInstance:J}=w[R];try{let m;if(Q.remove(),J.validateAuthorizationCode.toString().includes("codeVerifier")){if(!Y.value)return X(400,"Code verifier not found and is required");m=await J.validateAuthorizationCode(H,Y.value),Y.remove()}else m=await J.validateAuthorizationCode(H);let A0=rw(m.idToken()),L0=_.value,h=await W?.({decodedIdToken:A0,authProvider:L0});if(h===null||h===void 0)h=await A?.({decodedIdToken:A0,authProvider:L0});let a=crypto.randomUUID();if(!aW(h))return X(500,"Invalid user schema");$[a]={user:h,expiresAt:Date.now()+86400000},G.set({value:a,secure:!0,httpOnly:!0,sameSite:"lax"}),U?.();let x=B.value??"/";return Z(x)}catch(m){if(m instanceof Error)console.error("Failed to validate authorization code:",m.message);return X(500)}})};var AA=()=>{return new j0().use(X4()).derive(({store:{session:w},cookie:{user_session_id:z},error:U})=>{return{protectRoute:async(W,A)=>{if(z.value===void 0)return A?.()??U(401,"No session ID found");if(w[z.value]===void 0)return A?.()??U(401,"No session found");return W()}}}).as("plugin")};var Lg=({config:w,authorizeRoute:z,callbackRoute:U,logoutRoute:W,statusRoute:A,refreshRoute:X,revokeRoute:Z,onAuthorize:$,onCallback:Q,onStatus:Y,onRefresh:B,onLogout:G,onRevoke:_,createUser:H,getUser:F})=>{let R=Object.entries(w).reduce((J,[m,A0={}])=>{let L0=m.toLowerCase(),h=tW[L0],a=oW[L0];if(!h||!Q6(h))return console.error(`Provider ${m} is not supported`),J;let x=c4[h],i;if(rW(a))i=i4[a];let{credentials:K=[],scopes:o=[],searchParams:D0=[]}=A0,l=new x(...K);return J[L0]={providerInstance:l,scopes:o,searchParams:D0,userInfoURL:i},J},{});return new j0().error("OAUTH2_REQUEST_ERROR",h4).error("ARCTIC_FETCH_ERROR",$6).use(lW({logoutRoute:W,onLogout:G})).use(eW({clientProviders:R,revokeRoute:Z,onRevoke:_})).use(wA({statusRoute:A,onStatus:Y})).use(zA({clientProviders:R,refreshRoute:X,onRefresh:B})).use(UA({clientProviders:R,authorizeRoute:z,onAuthorize:$})).use(WA({clientProviders:R,callbackRoute:U,onCallback:Q,getUser:F,createUser:H})).use(AA()).as("plugin")};export{Lg as absoluteAuth};
327
+ return mapResponse(${A}error,set${W.mapResponseContext})}`,Function("inject",U)({app:z,mapResponse:z["~adapter"].handler.mapResponse,ERROR_CODE:s8,ElysiaCustomStatusResponse:b1,ELYSIA_TRACE:Z?ww:void 0,ELYSIA_REQUEST_ID:Z?z5:void 0,...W.inject})},oz=(z,w)=>{for(let[U,W]of Object.entries(z.schema.properties))w[U]??=W.default},hU=(z)=>{let{mapResponse:w,mapEarlyResponse:U}=z["~adapter"].handler;return async(W)=>{let X=W.url,Z=X.indexOf("/",11),$=X.indexOf("?",Z+1),A=$===-1?X.substring(Z):X.substring(Z,$),Q={cookie:{},status:200,headers:{}},Y=Object.assign({},z.singleton.decorator,{set:Q,store:z.singleton.store,request:W,path:A,qi:$,error:mU,redirect:nU});try{if(z.event.request)for(let V=0;V<z.event.request.length;V++){let k=z.event.request[V].fn,j=k(Y);if(j instanceof Promise)j=await j;if(j=U(j,Q),j)return Y.response=j}let J=z.router.dynamic.find(W.method,A)??z.router.dynamic.find("ALL",A);if(!J)throw new zw;let{handle:G,hooks:S,validator:N,content:O,route:M}=J.store,C;if(W.method!=="GET"&&W.method!=="HEAD")if(O)switch(O){case"application/json":C=await W.json();break;case"text/plain":C=await W.text();break;case"application/x-www-form-urlencoded":C=o8(await W.text());break;case"application/octet-stream":C=await W.arrayBuffer();break;case"multipart/form-data":C={};let V=await W.formData();for(let k of V.keys()){if(C[k])continue;let j=V.getAll(k);if(j.length===1)C[k]=j[0];else C[k]=j}break}else{let V=W.headers.get("content-type");if(V){let k=V.indexOf(";");if(k!==-1)V=V.slice(0,k);if(Y.contentType=V,S.parse)for(let j=0;j<S.parse.length;j++){let e=S.parse[j].fn,Y0=e(Y,V);if(Y0 instanceof Promise)Y0=await Y0;if(Y0){C=Y0;break}}if(delete Y.contentType,C===void 0)switch(V){case"application/json":C=await W.json();break;case"text/plain":C=await W.text();break;case"application/x-www-form-urlencoded":C=o8(await W.text());break;case"application/octet-stream":C=await W.arrayBuffer();break;case"multipart/form-data":C={};let j=await W.formData();for(let e of j.keys()){if(C[e])continue;let Y0=j.getAll(e);if(Y0.length===1)C[e]=Y0[0];else C[e]=Y0}break}}}Y.route=M,Y.body=C,Y.params=J?.params||void 0,Y.query=$===-1?{}:o8(X.substring($+1)),Y.headers={};for(let[V,k]of W.headers.entries())Y.headers[V]=k;let g=Object.assign({},z.config?.cookie,N?.cookie?.config),L0=W.headers.get("cookie");Y.cookie=await WW(Y.set,L0,g?{secrets:g.secrets!==void 0?typeof g.secrets==="string"?g.secrets:g.secrets.join(","):void 0,sign:g.sign===!0?!0:g.sign!==void 0?typeof g.sign==="string"?g.sign:g.sign.join(","):void 0}:void 0);let a=N?.createHeaders?.();if(a)oz(a,Y.headers);let $0=N?.createParams?.();if($0)oz($0,Y.params);let K0=N?.createQuery?.();if(K0)oz(K0,Y.query);if(S.transform)for(let V=0;V<S.transform.length;V++){let k=S.transform[V],j=k.fn(Y);if(k.subType==="derive")if(j instanceof Promise)Object.assign(Y,await j);else Object.assign(Y,j);else if(j instanceof Promise)await j}if(N){if(a){let V=structuredClone(Y.headers);for(let[k,j]of W.headers)V[k]=j;if(N.headers.Check(V)===!1)throw new r("header",N.headers,V)}else if(N.headers?.Decode)Y.headers=N.headers.Decode(Y.headers);if($0?.Check(Y.params)===!1)throw new r("params",N.params,Y.params);else if(N.params?.Decode)Y.params=N.params.Decode(Y.params);if(K0?.Check(Y.query)===!1)throw new r("query",N.query,Y.query);else if(N.query?.Decode)Y.query=N.query.Decode(Y.query);if(N.createCookie?.()){let V={};for(let[k,j]of Object.entries(Y.cookie))V[k]=j.value;if(N.cookie.Check(V)===!1)throw new r("cookie",N.cookie,V);else if(N.cookie?.Decode)V=N.cookie.Decode(V)}if(N.createBody?.()?.Check(C)===!1)throw new r("body",N.body,C);else if(N.body?.Decode)Y.body=N.body.Decode(C)}if(S.beforeHandle)for(let V=0;V<S.beforeHandle.length;V++){let k=S.beforeHandle[V],j=k.fn(Y);if(k.subType==="resolve"){if(j instanceof b1){let e=U(j,Y.set);if(e)return Y.response=e}if(j instanceof Promise)Object.assign(Y,await j);else Object.assign(Y,j);continue}else if(j instanceof Promise)j=await j;if(j!==void 0){if(Y.response=j,S.afterHandle)for(let Y0=0;Y0<S.afterHandle.length;Y0++){let _0=S.afterHandle[Y0].fn(Y);if(_0 instanceof Promise)_0=await _0;if(_0)j=_0}let e=U(j,Y.set);if(e)return Y.response=e}}let f=typeof G==="function"?G(Y):G;if(f instanceof Promise)f=await f;if(S.afterHandle)if(!S.afterHandle.length){let V=f instanceof b1?f.code:Q.status?typeof Q.status==="string"?e8[Q.status]:Q.status:200,k=N?.createResponse?.()?.[V];if(k?.Check(f)===!1)throw new r("response",k,f);else if(k?.Decode)f=k.Decode(f)}else{Y.response=f;for(let V=0;V<S.afterHandle.length;V++){let k=S.afterHandle[V].fn(Y);if(k instanceof Promise)k=await k;let j=U(k,Y.set);if(j!==void 0){let e=N?.response?.[j.status];if(e?.Check(j)===!1)throw new r("response",e,j);else if(e?.Decode)f=e.Decode(f);return Y.response=j}}}if(Y.set.cookie&&g?.sign){let V=!g.secrets?void 0:typeof g.secrets==="string"?g.secrets:g.secrets[0];if(g.sign===!0)for(let[k,j]of Object.entries(Y.set.cookie))Y.set.cookie[k].value=await l8(j.value,"${secret}");else{let k=N?.cookie?.schema?.properties;for(let j of g.sign){if(!(j in k))continue;if(Y.set.cookie[j]?.value)Y.set.cookie[j].value=await l8(Y.set.cookie[j].value,V)}}}return w(Y.response=f,Y.set)}catch(J){let G=J instanceof T8&&J.error?J.error:J;return z.handleError(Y,G)}finally{if(z.event.afterResponse)for(let J of z.event.afterResponse)await J.fn(Y)}}},NG=(z)=>{let{mapResponse:w}=z["~adapter"].handler;return async(U,W)=>{let X=Object.assign(U,{error:W,code:W.code});if(X.set=U.set,z.event.error)for(let Z=0;Z<z.event.error.length;Z++){let $=z.event.error[Z].fn(X);if($ instanceof Promise)$=await $;if($!==void 0&&$!==null)return U.response=w($,U.set)}return new Response(typeof W.cause==="string"?W.cause:W.message,{headers:U.set.headers,status:W.status??500})}};class b0{config;server=null;dependencies={};_routes={};_types={Prefix:"",Singleton:{},Definitions:{},Metadata:{}};_ephemeral={};_volatile={};singleton={decorator:{},store:{},derive:{},resolve:{}};get store(){return this.singleton.store}get decorator(){return this.singleton.decorator}definitions={typebox:E.Module({}),type:{},error:{}};extender={macros:[],higherOrderFunctions:[]};validator={global:null,scoped:null,local:null,getCandidate(){return t4(t4(this.global,this.scoped),this.local)}};event={};telemetry={stack:void 0};router={"~http":void 0,get http(){if(!this["~http"])this["~http"]=new F6({lazy:!0});return this["~http"]},"~dynamic":void 0,get dynamic(){if(!this["~dynamic"])this["~dynamic"]=new F6;return this["~dynamic"]},static:{http:{static:{},map:{},all:""},ws:{}},history:[]};routeTree=new Map;get routes(){return this.router.history}getGlobalRoutes(){return this.router.history}inference={body:!1,cookie:!1,headers:!1,query:!1,set:!1,server:!1,request:!1,route:!1};getServer(){return this.server}getParent(){return null}"~parser"={};_promisedModules;get promisedModules(){if(!this._promisedModules)this._promisedModules=new vU;return this._promisedModules}constructor(z={}){if(z.tags)if(!z.detail)z.detail={tags:z.tags};else z.detail.tags=z.tags;if(z.nativeStaticResponse===void 0)z.nativeStaticResponse=!0;if(this.config={},this.applyConfig(z??{}),this["~adapter"]=z.adapter??(typeof Bun!=="undefined"?AG:t8),z?.analytic&&(z?.name||z?.seed!==void 0))this.telemetry.stack=new Error().stack}"~adapter";env(z,w=dU){if(F2(z,{modules:this.definitions.typebox,dynamic:!0,additionalProperties:!0,coerce:!0}).Check(w)===!1){let U=new r("env",z,w);throw new Error(U.all.map((W)=>W.summary).join(`
328
+ `))}return this}wrap(z){return this.extender.higherOrderFunctions.push({checksum:o4(JSON.stringify({name:this.config.name,seed:this.config.seed,content:z.toString()})),fn:z}),this}applyMacro(z){if(this.extender.macros.length){let w=yL({globalHook:this.event,localHook:z}),U={events:{global:this.event,local:z},get onParse(){return w("parse")},get onTransform(){return w("transform")},get onBeforeHandle(){return w("beforeHandle")},get onAfterHandle(){return w("afterHandle")},get mapResponse(){return w("mapResponse")},get onAfterResponse(){return w("afterResponse")},get onError(){return w("error")}};for(let W of this.extender.macros)iL(W.fn(U),z,w)}}applyConfig(z){return this.config={prefix:"",aot:dU.ELYSIA_AOT!=="false",normalize:!0,...z,cookie:{path:"/",...z?.cookie},experimental:z?.experimental??{},seed:z?.seed===void 0?"":z?.seed},this}get models(){let z={};for(let w of Object.keys(this.definitions.type))z[w]=F2(this.definitions.typebox.Import(w));return z.modules=this.definitions.typebox,z}add(z,w,U,W,{allowMeta:X=!1,skipPrefix:Z=!1}={allowMeta:!1,skipPrefix:!1}){if(W=mz(nL(W)),w!==""&&w.charCodeAt(0)!==47)w="/"+w;if(this.config.prefix&&!Z)w=this.config.prefix+w;if(W?.type)switch(W.type){case"text":W.type="text/plain";break;case"json":W.type="application/json";break;case"formdata":W.type="multipart/form-data";break;case"urlencoded":W.type="application/x-www-form-urlencoded";break;case"arrayBuffer":W.type="application/octet-stream";break;default:break}let $=this.definitions.type,A=!this.config.aot,Q={...this.validator.getCandidate()},Y={body:W?.body??Q?.body,headers:W?.headers??Q?.headers,params:W?.params??Q?.params,query:W?.query??Q?.query,cookie:W?.cookie??Q?.cookie,response:W?.response??Q?.response},J=()=>Y.cookie?yU({modules:S,validator:Y.cookie,defaultConfig:this.config.cookie,config:Y.cookie?.config??{},dynamic:A,models:$}):void 0,G=this.config.normalize,S=this.definitions.typebox,N=this.config.precompile===!0||typeof this.config.precompile==="object"&&this.config.precompile.schema===!0?{body:F2(Y.body,{modules:S,dynamic:A,models:$,normalize:G,additionalCoerce:OU()}),headers:F2(Y.headers,{modules:S,dynamic:A,models:$,additionalProperties:!this.config.normalize,coerce:!0,additionalCoerce:y6()}),params:F2(Y.params,{modules:S,dynamic:A,models:$,coerce:!0,additionalCoerce:y6()}),query:F2(Y.query,{modules:S,dynamic:A,models:$,normalize:G,coerce:!0,additionalCoerce:y6()}),cookie:J(),response:PU(Y.response,{modules:S,dynamic:A,models:$,normalize:G})}:{createBody(){if(this.body)return this.body;return this.body=F2(Y.body,{modules:S,dynamic:A,models:$,normalize:G,additionalCoerce:OU()})},createHeaders(){if(this.headers)return this.headers;return this.headers=F2(Y.headers,{modules:S,dynamic:A,models:$,additionalProperties:!G,coerce:!0,additionalCoerce:y6()})},createParams(){if(this.params)return this.params;return this.params=F2(Y.params,{modules:S,dynamic:A,models:$,coerce:!0,additionalCoerce:y6()})},createQuery(){if(this.query)return this.query;return this.query=F2(Y.query,{modules:S,dynamic:A,models:$,coerce:!0,additionalCoerce:y6()})},createCookie(){if(this.cookie)return this.cookie;return this.cookie=J()},createResponse(){if(this.response)return this.response;return this.response=PU(Y.response,{modules:S,dynamic:A,models:$,normalize:G})}};if(W=a1(W,mz(Q)),W.tags)if(!W.detail)W.detail={tags:W.tags};else W.detail.tags=W.tags;if(z1(this.config.detail))W.detail=j2(Object.assign({},this.config.detail),W.detail);this.applyMacro(W);let O=mz(a1(this.event,W));if(this.config.aot===!1){this.router.dynamic.add(z,w,{validator:N,hooks:O,content:W?.type,handle:U,route:w});let _0=p4(w,{dynamic:!0});if(w!==_0)this.router.dynamic.add(z,_0,{validator:N,hooks:O,content:W?.type,handle:U,route:w});if(this.config.strictPath===!1){let h0=S4(w);this.router.dynamic.add(z,h0,{validator:N,hooks:O,content:W?.type,handle:U,route:w});let U6=p4(h0);if(h0!==U6)this.router.dynamic.add(z,h0,{validator:N,hooks:O,content:W?.type,handle:U,route:w})}this.router.history.push({method:z,path:w,composed:null,handler:U,hooks:O});return}let M=this.config.precompile===!0||typeof this.config.precompile==="object"&&this.config.precompile.compose===!0,C=uz(this.inference),g=this["~adapter"].handler,L0=typeof U!=="function"&&typeof g.createStaticHandler==="function"?g.createStaticHandler(U,O,this.setHeaders):void 0,a=typeof U!=="function"?g.createNativeStaticHandler?.(U,O,this.setHeaders):void 0;if(this.config.nativeStaticResponse===!0&&a&&(z==="GET"||z==="ALL"))this.router.static.http.static[w]=a();let $0=(_0=!1)=>GG({app:this,path:w,method:z,hooks:O,validator:N,handler:typeof U!=="function"&&typeof g.createStaticHandler!=="function"?()=>U:U,allowMeta:X,inference:C,asManifest:_0}),K0;if(this.routeTree.has(z+w))for(let _0=0;_0<this.router.history.length;_0++){let h0=this.router.history[_0];if(h0.path===w&&h0.method===z){K0=_0;break}}else this.routeTree.set(z+w,this.router.history.length);let f=this.router.history,V=K0??this.router.history.length,k=M?$0():(_0)=>{let h0=(f[V].composed=$0())(_0);return $0=void 0,h0};if(M)$0=void 0;let j=z==="$INTERNALWS";if(K0!==void 0)this.router.history[K0]=Object.assign({method:z,path:w,composed:k,handler:U,hooks:O},W.webSocket?{websocket:W.websocket}:{});else this.router.history.push(Object.assign({method:z,path:w,composed:k,handler:U,hooks:O},W.webSocket?{websocket:W.websocket}:{}));let e=this.router.static.http,Y0={handler:M?k:void 0,compile(){return this.handler=$0()}};if(j){if(this.router.http.add("ws",w,Y0),!this.config.strictPath)this.router.http.add("ws",S4(w),Y0);let _0=p4(w,{dynamic:!0});if(_0!==w)this.router.http.add("ws",_0,Y0);return}if(w.indexOf(":")===-1&&w.indexOf("*")===-1){if(!e.map[w])e.map[w]={code:""};let _0=L0?"":"c";if(z==="ALL")e.map[w].all=`default:return ht[${V}].composed(${_0})
329
+ `;else e.map[w].code=`case '${z}':return ht[${V}].composed(${_0})
330
+ ${e.map[w].code}`;if(!this.config.strictPath&&this.config.nativeStaticResponse===!0&&a&&(z==="GET"||z==="ALL"))this.router.static.http.static[S4(w)]=a()}else{if(this.router.http.add(z,w,Y0),!this.config.strictPath){let h0=S4(w);if(this.config.nativeStaticResponse===!0&&L0&&(z==="GET"||z==="ALL"))this.router.static.http.static[h0]=L0();this.router.http.add(z,h0,Y0)}let _0=p4(w,{dynamic:!0});if(w!==_0){if(this.router.http.add(z,_0,Y0),this.config.nativeStaticResponse===!0&&L0&&(z==="GET"||z==="ALL"))this.router.static.http.static[_0]=L0();this.router.http.add(z,_0,Y0)}}}setHeaders;headers(z){if(!z)return this;if(!this.setHeaders)this.setHeaders={};return this.setHeaders=j2(this.setHeaders,z),this}onStart(z){return this.on("start",z),this}onRequest(z){return this.on("request",z),this}onParse(z,w){if(!w){if(typeof z==="string")return this.on("parse",this["~parser"][z]);return this.on("parse",z)}return this.on(z,"parse",w)}parser(z,w){return this["~parser"][z]=w,this}onTransform(z,w){if(!w)return this.on("transform",z);return this.on(z,"transform",w)}resolve(z,w){if(!w)w=z,z={as:"local"};let U={subType:"resolve",fn:w};return this.onBeforeHandle(z,U)}mapResolve(z,w){if(!w)w=z,z={as:"local"};let U={subType:"mapResolve",fn:w};return this.onBeforeHandle(z,U)}onBeforeHandle(z,w){if(!w)return this.on("beforeHandle",z);return this.on(z,"beforeHandle",w)}onAfterHandle(z,w){if(!w)return this.on("afterHandle",z);return this.on(z,"afterHandle",w)}mapResponse(z,w){if(!w)return this.on("mapResponse",z);return this.on(z,"mapResponse",w)}onAfterResponse(z,w){if(!w)return this.on("afterResponse",z);return this.on(z,"afterResponse",w)}trace(z,w){if(!w)w=z,z={as:"local"};if(!Array.isArray(w))w=[w];for(let U of w)this.on(z,"trace",JG(U));return this}error(z,w){switch(typeof z){case"string":return w.prototype[s8]=z,this.definitions.error[z]=w,this;case"function":return this.definitions.error=z(this.definitions.error),this}for(let[U,W]of Object.entries(z))W.prototype[s8]=U,this.definitions.error[U]=W;return this}onError(z,w){if(!w)return this.on("error",z);return this.on(z,"error",w)}onStop(z){return this.on("stop",z),this}on(z,w,U){let W;switch(typeof z){case"string":W=z,U=w;break;case"object":if(W=w,!Array.isArray(w)&&typeof w==="object")U=w;break}if(Array.isArray(U))U=W2(U);else if(typeof U==="function")U=[{fn:U}];else U=[U];let X=U;for(let Z of X)if(Z.scope=typeof z==="string"?"local":z?.as??"local",W==="resolve"||W==="derive")Z.subType=W;if(W!=="trace")wW({[W]:X.map((Z)=>Z.fn)},this.inference);for(let Z of X){let $=hL(Z,"global",{skipIfHasType:!0});switch(W){case"start":this.event.start??=[],this.event.start.push($);break;case"request":this.event.request??=[],this.event.request.push($);break;case"parse":this.event.parse??=[],this.event.parse.push($);break;case"transform":this.event.transform??=[],this.event.transform.push($);break;case"derive":this.event.transform??=[],this.event.transform.push(W2($,"derive"));break;case"beforeHandle":this.event.beforeHandle??=[],this.event.beforeHandle.push($);break;case"resolve":this.event.beforeHandle??=[],this.event.beforeHandle.push(W2($,"resolve"));break;case"afterHandle":this.event.afterHandle??=[],this.event.afterHandle.push($);break;case"mapResponse":this.event.mapResponse??=[],this.event.mapResponse.push($);break;case"afterResponse":this.event.afterResponse??=[],this.event.afterResponse.push($);break;case"trace":this.event.trace??=[],this.event.trace.push($);break;case"error":this.event.error??=[],this.event.error.push($);break;case"stop":this.event.stop??=[],this.event.stop.push($);break}}return this}propagate(){return L2(this.event.parse),L2(this.event.transform),L2(this.event.beforeHandle),L2(this.event.afterHandle),L2(this.event.mapResponse),L2(this.event.afterResponse),L2(this.event.trace),L2(this.event.error),this}as(z){let w={plugin:"scoped",scoped:"scoped",global:"global"}[z];if(L2(this.event.parse,w),L2(this.event.transform,w),L2(this.event.beforeHandle,w),L2(this.event.afterHandle,w),L2(this.event.mapResponse,w),L2(this.event.afterResponse,w),L2(this.event.trace,w),L2(this.event.error,w),z==="plugin")this.validator.scoped=t4(this.validator.scoped,this.validator.local),this.validator.local=null;else if(z==="global")this.validator.global=t4(this.validator.global,t4(this.validator.scoped,this.validator.local)),this.validator.scoped=null,this.validator.local=null;return this}group(z,w,U){let W=new b0({...this.config,prefix:""});W.singleton={...this.singleton},W.definitions={...this.definitions},W.getServer=()=>this.getServer(),W.inference=uz(this.inference),W.extender={...this.extender};let X=typeof w==="object",Z=(X?U:w)(W);if(this.singleton=j2(this.singleton,W.singleton),this.definitions=j2(this.definitions,W.definitions),Z.event.request?.length)this.event.request=[...this.event.request||[],...Z.event.request||[]];if(Z.event.mapResponse?.length)this.event.mapResponse=[...this.event.mapResponse||[],...Z.event.mapResponse||[]];return this.model(Z.definitions.type),Object.values(W.router.history).forEach(({method:$,path:A,handler:Q,hooks:Y})=>{if(A=(X?"":this.config.prefix)+z+A,X){let J=w,G=Y;this.add($,A,Q,a1(J,{...G||{},error:!G.error?Z.event.error:Array.isArray(G.error)?[...G.error||{},...Z.event.error||{}]:[G.error,...Z.event.error||{}]}))}else this.add($,A,Q,a1(Y,{error:Z.event.error}),{skipPrefix:!0})}),this}guard(z,w){if(!w){if(typeof z==="object"){this.applyMacro(z);let X=z.as??"local";if(this.validator[X]={body:z.body??this.validator[X]?.body,headers:z.headers??this.validator[X]?.headers,params:z.params??this.validator[X]?.params,query:z.query??this.validator[X]?.query,response:z.response??this.validator[X]?.response,cookie:z.cookie??this.validator[X]?.cookie},z.parse)this.on({as:X},"parse",z.parse);if(z.transform)this.on({as:X},"transform",z.transform);if(z.derive)this.on({as:X},"derive",z.derive);if(z.beforeHandle)this.on({as:X},"beforeHandle",z.beforeHandle);if(z.resolve)this.on({as:X},"resolve",z.resolve);if(z.afterHandle)this.on({as:X},"afterHandle",z.afterHandle);if(z.mapResponse)this.on({as:X},"mapResponse",z.mapResponse);if(z.afterResponse)this.on({as:X},"afterResponse",z.afterResponse);if(z.error)this.on({as:X},"error",z.error);if(z.detail)if(this.config.detail)this.config.detail=j2(Object.assign({},this.config.detail),z.detail);else this.config.detail=z.detail;if(z?.tags)if(!this.config.detail)this.config.detail={tags:z.tags};else this.config.detail.tags=z.tags;return this}return this.guard({},z)}let U=new b0({...this.config,prefix:""});U.singleton={...this.singleton},U.definitions={...this.definitions},U.inference=uz(this.inference),U.extender={...this.extender};let W=w(U);if(this.singleton=j2(this.singleton,U.singleton),this.definitions=j2(this.definitions,U.definitions),W.getServer=()=>this.server,W.event.request?.length)this.event.request=[...this.event.request||[],...W.event.request||[]];if(W.event.mapResponse?.length)this.event.mapResponse=[...this.event.mapResponse||[],...W.event.mapResponse||[]];return this.model(W.definitions.type),Object.values(U.router.history).forEach(({method:X,path:Z,handler:$,hooks:A})=>{this.add(X,Z,$,a1(z,{...A||{},error:!A.error?W.event.error:Array.isArray(A.error)?[...A.error||{},...W.event.error||[]]:[A.error,...W.event.error||[]]}))}),this}use(z,w){if(Array.isArray(z)){let U=this;for(let W of z)U=U.use(W);return U}if(w?.scoped)return this.guard({},(U)=>U.use(z));if(Array.isArray(z)){let U=this;for(let W of z)U=this.use(W);return U}if(z instanceof Promise)return this.promisedModules.add(z.then((U)=>{if(typeof U==="function")return U(this);if(U instanceof b0)return this._use(U).compile();if(U.constructor.name==="Elysia")return this._use(U).compile();if(typeof U.default==="function")return U.default(this);if(U.default instanceof b0)return this._use(U.default);if(U.constructor.name==="Elysia")return this._use(U.default);if(U.constructor.name==="_Elysia")return this._use(U.default);try{return this._use(U.default)}catch(W){throw console.error('Invalid plugin type. Expected Elysia instance, function, or module with "default" as Elysia instance or function that returns Elysia instance.'),W}}).then((U)=>{if(U&&typeof U.compile==="function")U.compile();return U})),this;return this._use(z)}propagatePromiseModules(z){if(z.promisedModules.size<=0)return this;for(let w of z.promisedModules.promises)this.promisedModules.add(w.then((U)=>{if(!U)return;let W=this._use(U);if(W instanceof Promise)return W.then((X)=>{if(X)X.compile();else U.compile()});return U.compile()}));return this}_use(z){if(typeof z==="function"){let X=z(this);if(X instanceof Promise)return this.promisedModules.add(X.then((Z)=>{if(Z instanceof b0){Z.getServer=()=>this.getServer(),Z.getGlobalRoutes=()=>this.getGlobalRoutes(),Z.model(this.definitions.type),Z.error(this.definitions.error);for(let{method:$,path:A,handler:Q,hooks:Y}of Object.values(Z.router.history))this.add($,A,Q,a1(Y,{error:Z.event.error}));if(Z.compile(),Z===this)return;return this.propagatePromiseModules(Z),Z}if(typeof Z==="function")return Z(this);if(typeof Z.default==="function")return Z.default(this);return this._use(Z)}).then((Z)=>{if(Z&&typeof Z.compile==="function")Z.compile();return Z})),this;return X}this.propagatePromiseModules(z);let{name:w,seed:U}=z.config;if(z.getParent=()=>this,z.getServer=()=>this.getServer(),z.getGlobalRoutes=()=>this.getGlobalRoutes(),z.model(this.definitions.type),z.error(this.definitions.error),this["~parser"]={...z["~parser"],...this["~parser"]},this.headers(z.setHeaders),w){if(!(w in this.dependencies))this.dependencies[w]=[];let X=U!==void 0?o4(w+JSON.stringify(U)):0;if(!this.dependencies[w].some(({checksum:Z})=>X===Z))this.extender.macros=this.extender.macros.concat(z.extender.macros),this.extender.higherOrderFunctions=this.extender.higherOrderFunctions.concat(z.extender.higherOrderFunctions)}else this.extender.macros=this.extender.macros.concat(z.extender.macros),this.extender.higherOrderFunctions=this.extender.higherOrderFunctions.concat(z.extender.higherOrderFunctions);EU(this.extender.macros),EU(this.extender.higherOrderFunctions);let W=[];for(let X=0;X<this.extender.higherOrderFunctions.length;X++){let Z=this.extender.higherOrderFunctions[X];if(Z.checksum){if(W.includes(Z.checksum))this.extender.higherOrderFunctions.splice(X,1),X--;W.push(Z.checksum)}}this.inference={body:this.inference.body||z.inference.body,cookie:this.inference.cookie||z.inference.cookie,headers:this.inference.headers||z.inference.headers,query:this.inference.query||z.inference.query,set:this.inference.set||z.inference.set,server:this.inference.server||z.inference.server,request:this.inference.request||z.inference.request,route:this.inference.route||z.inference.route},this.decorate(z.singleton.decorator),this.state(z.singleton.store),this.model(z.definitions.type),this.error(z.definitions.error),z.extender.macros=this.extender.macros.concat(z.extender.macros);for(let{method:X,path:Z,handler:$,hooks:A}of Object.values(z.router.history))this.add(X,Z,$,a1(A,{error:z.event.error}));if(w){if(!(w in this.dependencies))this.dependencies[w]=[];let X=U!==void 0?o4(w+JSON.stringify(U)):0;if(this.dependencies[w].some(({checksum:Z})=>X===Z))return this;this.dependencies[w].push(this.config?.analytic?{name:z.config.name,seed:z.config.seed,checksum:X,dependencies:z.dependencies,stack:z.telemetry.stack,routes:z.router.history,decorators:z.singleton,store:z.singleton.store,error:z.definitions.error,derive:z.event.transform?.filter((Z)=>Z?.subType==="derive").map((Z)=>({fn:Z.toString(),stack:new Error().stack??""})),resolve:z.event.transform?.filter((Z)=>Z?.subType==="resolve").map((Z)=>({fn:Z.toString(),stack:new Error().stack??""}))}:{name:z.config.name,seed:z.config.seed,checksum:X,dependencies:z.dependencies}),this.event=RU(this.event,CU(z.event),X)}else this.event=RU(this.event,CU(z.event));return this.validator.global=a1(this.validator.global,{...z.validator.global}),this.validator.local=a1(this.validator.local,{...z.validator.scoped}),this}macro(z){if(typeof z==="function"){let w={checksum:o4(JSON.stringify({name:this.config.name,seed:this.config.seed,content:z.toString()})),fn:z};this.extender.macros.push(w)}else if(typeof z==="object"){for(let U of Object.keys(z))if(typeof z[U]==="object"){let W={...z[U]};z[U]=(X)=>{if(X===!0)return W}}let w={checksum:o4(JSON.stringify({name:this.config.name,seed:this.config.seed,content:Object.entries(z).map(([U,W])=>`${U}+${W}`).join(",")})),fn:()=>z};this.extender.macros.push(w)}return this}mount(z,w){if(z instanceof b0||typeof z==="function"||z.length===0||z==="/"){let X=typeof z==="function"?z:z instanceof b0?z.compile().fetch:w instanceof b0?w.compile().fetch:w,Z=({request:$,path:A})=>X(new Request(DU($.url,A),{method:$.method,headers:$.headers,signal:$.signal,credentials:$.credentials,referrerPolicy:$.referrerPolicy,duplex:$.duplex,redirect:$.redirect,mode:$.mode,keepalive:$.keepalive,integrity:$.integrity,body:$.body}));return this.all("/*",Z,{parse:"none"}),this}if(!w)return this;let U=z.length-(z.endsWith("*")?1:0);if(w instanceof b0)w=w.compile().fetch;let W=({request:X,path:Z})=>w(new Request(DU(X.url,Z.slice(U)||"/"),{method:X.method,headers:X.headers,signal:X.signal,credentials:X.credentials,referrerPolicy:X.referrerPolicy,duplex:X.duplex,redirect:X.redirect,mode:X.mode,keepalive:X.keepalive,integrity:X.integrity,body:X.body}));return this.all(z,W,{parse:"none"}),this.all(z+(z.endsWith("/")?"*":"/*"),W,{parse:"none"}),this}get(z,w,U){return this.add("GET",z,w,U),this}post(z,w,U){return this.add("POST",z,w,U),this}put(z,w,U){return this.add("PUT",z,w,U),this}patch(z,w,U){return this.add("PATCH",z,w,U),this}delete(z,w,U){return this.add("DELETE",z,w,U),this}options(z,w,U){return this.add("OPTIONS",z,w,U),this}all(z,w,U){return this.add("ALL",z,w,U),this}head(z,w,U){return this.add("HEAD",z,w,U),this}connect(z,w,U){return this.add("CONNECT",z,w,U),this}route(z,w,U,W){return this.add(z.toUpperCase(),w,U,W,W?.config),this}ws(z,w){if(this["~adapter"].ws)this["~adapter"].ws(this,z,w);else console.warn("Current adapter doesn't support WebSocket");return this}state(z,w,U){if(w===void 0)U=z,z={as:"append"},w="";else if(U===void 0){if(typeof z==="string")U=w,w=z,z={as:"append"};else if(typeof z==="object")U=w,w=""}let{as:W}=z;if(typeof w!=="string")return this;switch(typeof U){case"object":if(w){if(w in this.singleton.store)this.singleton.store[w]=j2(this.singleton.store[w],U,{override:W==="override"});else this.singleton.store[w]=U;return this}if(U===null)return this;return this.singleton.store=j2(this.singleton.store,U,{override:W==="override"}),this;case"function":if(w){if(W==="override"||!(w in this.singleton.store))this.singleton.store[w]=U}else this.singleton.store=U(this.singleton.store);return this;default:if(W==="override"||!(w in this.singleton.store))this.singleton.store[w]=U;return this}}decorate(z,w,U){if(w===void 0)U=z,z={as:"append"},w="";else if(U===void 0){if(typeof z==="string")U=w,w=z,z={as:"append"};else if(typeof z==="object")U=w,w=""}let{as:W}=z;if(typeof w!=="string")return this;switch(typeof U){case"object":if(w){if(w in this.singleton.decorator)this.singleton.decorator[w]=j2(this.singleton.decorator[w],U,{override:W==="override"});else this.singleton.decorator[w]=U;return this}if(U===null)return this;return this.singleton.decorator=j2(this.singleton.decorator,U,{override:W==="override"}),this;case"function":if(w){if(W==="override"||!(w in this.singleton.decorator))this.singleton.decorator[w]=U}else this.singleton.decorator=U(this.singleton.decorator);return this;default:if(W==="override"||!(w in this.singleton.decorator))this.singleton.decorator[w]=U;return this}}derive(z,w){if(!w)w=z,z={as:"local"};let U={subType:"derive",fn:w};return this.onTransform(z,U)}model(z,w){let U=(W)=>lz(W,[{from:E.Number(),to:(X)=>E.Numeric(X),untilObjectFound:!0},{from:E.Boolean(),to:(X)=>E.BooleanString(X),untilObjectFound:!0}]);switch(typeof z){case"object":let W={},X=Object.entries(z);for(let[A,Q]of X){if(A in this.definitions.type)continue;W[A]=this.definitions.type[A]=U(Q),W[A].$id??=`#/components/schemas/${A}`}return this.definitions.typebox=E.Module({...this.definitions.typebox.$defs,...W}),this;case"function":let Z=U(z(this.definitions.type));return this.definitions.type=Z,this.definitions.typebox=E.Module(Z),this;case"string":if(!w)break;let $={...w,id:w.$id??`#/components/schemas/${z}`};return this.definitions.type[z]=w,this.definitions.typebox=E.Module({...this.definitions.typebox.$defs,...$}),this}return this.definitions.type[z]=w,this.definitions.typebox=E.Module({...this.definitions.typebox.$defs,[z]:w}),this}mapDerive(z,w){if(!w)w=z,z={as:"local"};let U={subType:"mapDerive",fn:w};return this.onTransform(z,U)}affix(z,w,U){if(U==="")return this;let W=["_","-"," "],X=(Q)=>Q[0].toUpperCase()+Q.slice(1),Z=z==="prefix"?(Q,Y)=>W.includes(Q.at(-1)??"")?Q+Y:Q+X(Y):W.includes(U.at(-1)??"")?(Q,Y)=>Y+Q:(Q,Y)=>Y+X(Q),$=(Q)=>{let Y={};switch(Q){case"decorator":for(let J in this.singleton.decorator)Y[Z(U,J)]=this.singleton.decorator[J];this.singleton.decorator=Y;break;case"state":for(let J in this.singleton.store)Y[Z(U,J)]=this.singleton.store[J];this.singleton.store=Y;break;case"model":for(let J in this.definitions.type)Y[Z(U,J)]=this.definitions.type[J];this.definitions.type=Y;break;case"error":for(let J in this.definitions.error)Y[Z(U,J)]=this.definitions.error[J];this.definitions.error=Y;break}},A=Array.isArray(w)?w:[w];for(let Q of A.some((Y)=>Y==="all")?["decorator","state","model","error"]:A)$(Q);return this}prefix(z,w){return this.affix("prefix",z,w)}suffix(z,w){return this.affix("suffix",z,w)}compile(){if(this["~adapter"].isWebStandard){if(this.fetch=this.config.aot?tz(this):hU(this),typeof this.server?.reload==="function")this.server.reload({...this.server||{},fetch:this.fetch});return this}if(typeof this.server?.reload==="function")this.server.reload(this.server||{});return this._handle=tz(this),this}handle=async(z)=>this.fetch(z);fetch=(z)=>{return(this.fetch=this.config.aot?tz(this):hU(this))(z)};handleError=async(z,w)=>{return(this.handleError=this.config.aot?AW(this):NG(this))(z,w)};outerErrorHandler=(z)=>new Response(z.message||z.name||"Error",{status:z?.status??500});listen=(z,w)=>{return this["~adapter"].listen(this)(z,w),this};stop=async(z)=>{if(!this.server)throw new Error("Elysia isn't running. Call `app.listen` to start the server.");if(this.server){if(this.server.stop(z),this.server=null,this.event.stop?.length)for(let w=0;w<this.event.stop.length;w++)this.event.stop[w].fn(this)}};get modules(){return this.promisedModules}}var QW;(function(z){z[z.Include=0]="Include",z[z.None=1]="None"})(QW||(QW={}));var YW;(function(z){z[z.Required=0]="Required",z[z.Ignore=1]="Ignore"})(YW||(YW={}));function Ww(z){return BW(z,HG,a4.Include)}function e4(z){return BW(z,_G,a4.None)}function BW(z,w,U){let W="";for(let X=0;X<z.byteLength;X+=3){let Z=0,$=0;for(let A=0;A<3&&X+A<z.byteLength;A++)Z=Z<<8|z[X+A],$+=8;for(let A=0;A<4;A++)if($>=6)W+=w[Z>>$-6&63],$-=6;else if($>0)W+=w[Z<<6-$&63],$=0;else if(U===a4.Include)W+="="}return W}var HG="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",_G="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_";var a4;(function(z){z[z.Include=0]="Include",z[z.None=1]="None"})(a4||(a4={}));var JW;(function(z){z[z.Required=0]="Required",z[z.Ignore=1]="Ignore"})(JW||(JW={}));class qW{uint8(z,w){if(z.byteLength<w+1)throw new TypeError("Insufficient bytes");return z[w]}uint16(z,w){if(z.byteLength<w+2)throw new TypeError("Insufficient bytes");return z[w]<<8|z[w+1]}uint32(z,w){if(z.byteLength<w+4)throw new TypeError("Insufficient bytes");let U=0;for(let W=0;W<4;W++)U|=z[w+W]<<24-W*8;return U}uint64(z,w){if(z.byteLength<w+8)throw new TypeError("Insufficient bytes");let U=0n;for(let W=0;W<8;W++)U|=BigInt(z[w+W])<<BigInt(56-W*8);return U}putUint8(z,w,U){if(z.length<U+1)throw new TypeError("Not enough space");if(w<0||w>255)throw new TypeError("Invalid uint8 value");z[U]=w}putUint16(z,w,U){if(z.length<U+2)throw new TypeError("Not enough space");if(w<0||w>65535)throw new TypeError("Invalid uint16 value");z[U]=w>>8,z[U+1]=w&255}putUint32(z,w,U){if(z.length<U+4)throw new TypeError("Not enough space");if(w<0||w>4294967295)throw new TypeError("Invalid uint32 value");for(let W=0;W<4;W++)z[U+W]=w>>(3-W)*8&255}putUint64(z,w,U){if(z.length<U+8)throw new TypeError("Not enough space");if(w<0||w>18446744073709551615n)throw new TypeError("Invalid uint64 value");for(let W=0;W<8;W++)z[U+W]=Number(w>>BigInt((7-W)*8)&0xffn)}}class LW{uint8(z,w){if(z.byteLength<w+1)throw new TypeError("Insufficient bytes");return z[w]}uint16(z,w){if(z.byteLength<w+2)throw new TypeError("Insufficient bytes");return z[w]|z[w+1]<<8}uint32(z,w){if(z.byteLength<w+4)throw new TypeError("Insufficient bytes");let U=0;for(let W=0;W<4;W++)U|=z[w+W]<<W*8;return U}uint64(z,w){if(z.byteLength<w+8)throw new TypeError("Insufficient bytes");let U=0n;for(let W=0;W<8;W++)U|=BigInt(z[w+W])<<BigInt(W*8);return U}putUint8(z,w,U){if(z.length<1+U)throw new TypeError("Insufficient space");if(w<0||w>255)throw new TypeError("Invalid uint8 value");z[U]=w}putUint16(z,w,U){if(z.length<2+U)throw new TypeError("Insufficient space");if(w<0||w>65535)throw new TypeError("Invalid uint16 value");z[U+1]=w>>8,z[U]=w&255}putUint32(z,w,U){if(z.length<4+U)throw new TypeError("Insufficient space");if(w<0||w>4294967295)throw new TypeError("Invalid uint32 value");for(let W=0;W<4;W++)z[U+W]=w>>W*8&255}putUint64(z,w,U){if(z.length<8+U)throw new TypeError("Insufficient space");if(w<0||w>18446744073709551615n)throw new TypeError("Invalid uint64 value");for(let W=0;W<8;W++)z[U+W]=Number(w>>BigInt(W*8)&0xffn)}}var T1=new qW,SG=new LW;function v0(z,w){return(z<<32-w|z>>>w)>>>0}function U1(z,w){return(z<<BigInt(64-w)|z>>BigInt(w))&0xffffffffffffffffn}class GW{blockSize=64;size=32;blocks=new Uint8Array(64);currentBlockSize=0;H=new Uint32Array([3238371032,914150663,812702999,4144912697,4290775857,1750603025,1694076839,3204075428]);l=0n;w=new Uint32Array(64);update(z){if(this.l+=BigInt(z.byteLength)*8n,this.currentBlockSize+z.byteLength<64){this.blocks.set(z,this.currentBlockSize),this.currentBlockSize+=z.byteLength;return}let w=0;if(this.currentBlockSize>0){let U=z.slice(0,64-this.currentBlockSize);this.blocks.set(U,this.currentBlockSize),this.process(),w+=U.byteLength,this.currentBlockSize=0}while(w+64<=z.byteLength){let U=z.slice(w,w+64);this.blocks.set(U),this.process(),w+=64}if(z.byteLength-w>0){let U=z.slice(w);this.blocks.set(U),this.currentBlockSize=U.byteLength}}digest(){if(this.blocks[this.currentBlockSize]=128,this.currentBlockSize+=1,64-this.currentBlockSize<8)this.blocks.fill(0,this.currentBlockSize),this.process(),this.currentBlockSize=0;this.blocks.fill(0,this.currentBlockSize),T1.putUint64(this.blocks,this.l,this.blockSize-8),this.process();let z=new Uint8Array(28);for(let w=0;w<7;w++)T1.putUint32(z,this.H[w],w*4);return z}process(){for(let Q=0;Q<16;Q++)this.w[Q]=(this.blocks[Q*4]<<24|this.blocks[Q*4+1]<<16|this.blocks[Q*4+2]<<8|this.blocks[Q*4+3])>>>0;for(let Q=16;Q<64;Q++){let Y=(v0(this.w[Q-2],17)^v0(this.w[Q-2],19)^this.w[Q-2]>>>10)>>>0,J=(v0(this.w[Q-15],7)^v0(this.w[Q-15],18)^this.w[Q-15]>>>3)>>>0;this.w[Q]=Y+this.w[Q-7]+J+this.w[Q-16]|0}let z=this.H[0],w=this.H[1],U=this.H[2],W=this.H[3],X=this.H[4],Z=this.H[5],$=this.H[6],A=this.H[7];for(let Q=0;Q<64;Q++){let Y=(v0(X,6)^v0(X,11)^v0(X,25))>>>0,J=(X&Z^~X&$)>>>0,G=A+Y+J+DG[Q]+this.w[Q]|0,S=(v0(z,2)^v0(z,13)^v0(z,22))>>>0,N=(z&w^z&U^w&U)>>>0,O=S+N|0;A=$,$=Z,Z=X,X=W+G|0,W=U,U=w,w=z,z=G+O|0}this.H[0]=z+this.H[0]|0,this.H[1]=w+this.H[1]|0,this.H[2]=U+this.H[2]|0,this.H[3]=W+this.H[3]|0,this.H[4]=X+this.H[4]|0,this.H[5]=Z+this.H[5]|0,this.H[6]=$+this.H[6]|0,this.H[7]=A+this.H[7]|0}}var DG=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]);function Xw(z){let w=new Zw;return w.update(z),w.digest()}class Zw{blockSize=64;size=32;blocks=new Uint8Array(64);currentBlockSize=0;H=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]);l=0n;w=new Uint32Array(64);update(z){if(this.l+=BigInt(z.byteLength)*8n,this.currentBlockSize+z.byteLength<64){this.blocks.set(z,this.currentBlockSize),this.currentBlockSize+=z.byteLength;return}let w=0;if(this.currentBlockSize>0){let U=z.slice(0,64-this.currentBlockSize);this.blocks.set(U,this.currentBlockSize),this.process(),w+=U.byteLength,this.currentBlockSize=0}while(w+64<=z.byteLength){let U=z.slice(w,w+64);this.blocks.set(U),this.process(),w+=64}if(z.byteLength-w>0){let U=z.slice(w);this.blocks.set(U),this.currentBlockSize=U.byteLength}}digest(){if(this.blocks[this.currentBlockSize]=128,this.currentBlockSize+=1,64-this.currentBlockSize<8)this.blocks.fill(0,this.currentBlockSize),this.process(),this.currentBlockSize=0;this.blocks.fill(0,this.currentBlockSize),T1.putUint64(this.blocks,this.l,this.blockSize-8),this.process();let z=new Uint8Array(32);for(let w=0;w<8;w++)T1.putUint32(z,this.H[w],w*4);return z}process(){for(let Q=0;Q<16;Q++)this.w[Q]=(this.blocks[Q*4]<<24|this.blocks[Q*4+1]<<16|this.blocks[Q*4+2]<<8|this.blocks[Q*4+3])>>>0;for(let Q=16;Q<64;Q++){let Y=(v0(this.w[Q-2],17)^v0(this.w[Q-2],19)^this.w[Q-2]>>>10)>>>0,J=(v0(this.w[Q-15],7)^v0(this.w[Q-15],18)^this.w[Q-15]>>>3)>>>0;this.w[Q]=Y+this.w[Q-7]+J+this.w[Q-16]|0}let z=this.H[0],w=this.H[1],U=this.H[2],W=this.H[3],X=this.H[4],Z=this.H[5],$=this.H[6],A=this.H[7];for(let Q=0;Q<64;Q++){let Y=(v0(X,6)^v0(X,11)^v0(X,25))>>>0,J=(X&Z^~X&$)>>>0,G=A+Y+J+PG[Q]+this.w[Q]|0,S=(v0(z,2)^v0(z,13)^v0(z,22))>>>0,N=(z&w^z&U^w&U)>>>0,O=S+N|0;A=$,$=Z,Z=X,X=W+G|0,W=U,U=w,w=z,z=G+O|0}this.H[0]=z+this.H[0]|0,this.H[1]=w+this.H[1]|0,this.H[2]=U+this.H[2]|0,this.H[3]=W+this.H[3]|0,this.H[4]=X+this.H[4]|0,this.H[5]=Z+this.H[5]|0,this.H[6]=$+this.H[6]|0,this.H[7]=A+this.H[7]|0}}var PG=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]);class R6{blockSize=128;size=64;blocks=new Uint8Array(128);currentBlockSize=0;l=0n;w=new BigUint64Array(80);H;constructor(z){if(z.byteLength!==64)throw new TypeError;this.H=z}update(z){if(this.l+=BigInt(z.byteLength)*8n,this.currentBlockSize+z.byteLength<128){this.blocks.set(z,this.currentBlockSize),this.currentBlockSize+=z.byteLength;return}let w=0;if(this.currentBlockSize>0){let U=z.slice(0,128-this.currentBlockSize);this.blocks.set(U,this.currentBlockSize),this.process(),w+=U.byteLength,this.currentBlockSize=0}while(w+128<=z.byteLength){let U=z.slice(w,w+128);this.blocks.set(U),this.process(),w+=128,this.currentBlockSize=0}if(z.byteLength-w>0){let U=z.slice(w);this.blocks.set(U),this.currentBlockSize=U.byteLength}}putDigest(z){if(z.byteLength>64||z.byteLength%8!==0)throw new TypeError;if(this.blocks[this.currentBlockSize]=128,this.currentBlockSize+=1,128-this.currentBlockSize<16)this.blocks.fill(0,this.currentBlockSize),this.process(),this.currentBlockSize=0;this.blocks.fill(0,this.currentBlockSize),T1.putUint64(this.blocks,this.l,this.blockSize-8),this.process();for(let w=0;w<z.byteLength/8;w++)T1.putUint64(z,this.H[w],w*8)}process(){for(let Q=0;Q<16;Q++)this.w[Q]=BigInt(this.blocks[Q*8])<<56n|BigInt(this.blocks[Q*8+1])<<48n|BigInt(this.blocks[Q*8+2])<<40n|BigInt(this.blocks[Q*8+3])<<32n|BigInt(this.blocks[Q*8+4])<<24n|BigInt(this.blocks[Q*8+5])<<16n|BigInt(this.blocks[Q*8+6])<<8n|BigInt(this.blocks[Q*8+7]);for(let Q=16;Q<80;Q++){let Y=(U1(this.w[Q-2],19)^U1(this.w[Q-2],61)^this.w[Q-2]>>6n)&0xffffffffffffffffn,J=(U1(this.w[Q-15],1)^U1(this.w[Q-15],8)^this.w[Q-15]>>7n)&0xffffffffffffffffn;this.w[Q]=Y+this.w[Q-7]+J+this.w[Q-16]&0xffffffffffffffffn}let z=this.H[0],w=this.H[1],U=this.H[2],W=this.H[3],X=this.H[4],Z=this.H[5],$=this.H[6],A=this.H[7];for(let Q=0;Q<80;Q++){let Y=(U1(X,14)^U1(X,18)^U1(X,41))&0xffffffffffffffffn,J=(X&Z^~X&$)&0xffffffffffffffffn,G=A+Y+J+OG[Q]+this.w[Q]&0xffffffffffffffffn,S=(U1(z,28)^U1(z,34)^U1(z,39))&0xffffffffffffffffn,N=(z&w^z&U^w&U)&0xffffffffffffffffn,O=S+N&0xffffffffffffffffn;A=$,$=Z,Z=X,X=W+G&0xffffffffffffffffn,W=U,U=w,w=z,z=G+O&0xffffffffffffffffn}this.H[0]=z+this.H[0]&0xffffffffffffffffn,this.H[1]=w+this.H[1]&0xffffffffffffffffn,this.H[2]=U+this.H[2]&0xffffffffffffffffn,this.H[3]=W+this.H[3]&0xffffffffffffffffn,this.H[4]=X+this.H[4]&0xffffffffffffffffn,this.H[5]=Z+this.H[5]&0xffffffffffffffffn,this.H[6]=$+this.H[6]&0xffffffffffffffffn,this.H[7]=A+this.H[7]&0xffffffffffffffffn}}class NW{blockSize=128;size=64;sha512=new R6(new BigUint64Array([0x6a09e667f3bcc908n,0xbb67ae8584caa73bn,0x3c6ef372fe94f82bn,0xa54ff53a5f1d36f1n,0x510e527fade682d1n,0x9b05688c2b3e6c1fn,0x1f83d9abfb41bd6bn,0x5be0cd19137e2179n]));update(z){this.sha512.update(z)}digest(){let z=new Uint8Array(64);return this.sha512.putDigest(z),z}}var OG=new BigUint64Array([0x428a2f98d728ae22n,0x7137449123ef65cdn,0xb5c0fbcfec4d3b2fn,0xe9b5dba58189dbbcn,0x3956c25bf348b538n,0x59f111f1b605d019n,0x923f82a4af194f9bn,0xab1c5ed5da6d8118n,0xd807aa98a3030242n,0x12835b0145706fben,0x243185be4ee4b28cn,0x550c7dc3d5ffb4e2n,0x72be5d74f27b896fn,0x80deb1fe3b1696b1n,0x9bdc06a725c71235n,0xc19bf174cf692694n,0xe49b69c19ef14ad2n,0xefbe4786384f25e3n,0x0fc19dc68b8cd5b5n,0x240ca1cc77ac9c65n,0x2de92c6f592b0275n,0x4a7484aa6ea6e483n,0x5cb0a9dcbd41fbd4n,0x76f988da831153b5n,0x983e5152ee66dfabn,0xa831c66d2db43210n,0xb00327c898fb213fn,0xbf597fc7beef0ee4n,0xc6e00bf33da88fc2n,0xd5a79147930aa725n,0x06ca6351e003826fn,0x142929670a0e6e70n,0x27b70a8546d22ffcn,0x2e1b21385c26c926n,0x4d2c6dfc5ac42aedn,0x53380d139d95b3dfn,0x650a73548baf63den,0x766a0abb3c77b2a8n,0x81c2c92e47edaee6n,0x92722c851482353bn,0xa2bfe8a14cf10364n,0xa81a664bbc423001n,0xc24b8b70d0f89791n,0xc76c51a30654be30n,0xd192e819d6ef5218n,0xd69906245565a910n,0xf40e35855771202an,0x106aa07032bbd1b8n,0x19a4c116b8d2d0c8n,0x1e376c085141ab53n,0x2748774cdf8eeb99n,0x34b0bcb5e19b48a8n,0x391c0cb3c5c95a63n,0x4ed8aa4ae3418acbn,0x5b9cca4f7763e373n,0x682e6ff3d6b2b8a3n,0x748f82ee5defb2fcn,0x78a5636f43172f60n,0x84c87814a1f0ab72n,0x8cc702081a6439ecn,0x90befffa23631e28n,0xa4506cebde82bde9n,0xbef9a3f7b2c67915n,0xc67178f2e372532bn,0xca273eceea26619cn,0xd186b8c721c0c207n,0xeada7dd6cde0eb1en,0xf57d4f7fee6ed178n,0x06f067aa72176fban,0x0a637dc5a2c898a6n,0x113f9804bef90daen,0x1b710b35131c471bn,0x28db77f523047d84n,0x32caab7b40c72493n,0x3c9ebe0a15c9bebcn,0x431d67c49c100d4cn,0x4cc5d4becb3e42b6n,0x597f299cfc657e2an,0x5fcb6fab3ad6faecn,0x6c44198c4a475817n]);class HW{blockSize=128;size=48;sha512=new R6(new BigUint64Array([0xcbbb9d5dc1059ed8n,0x629a292a367cd507n,0x9159015a3070dd17n,0x152fecd8f70e5939n,0x67332667ffc00b31n,0x8eb44a8768581511n,0xdb0c2e0d64f98fa7n,0x47b5481dbefa4fa4n]));update(z){this.sha512.update(z)}digest(){let z=new Uint8Array(48);return this.sha512.putDigest(z),z}}class _W{blockSize=128;size=28;sha512=new R6(new BigUint64Array([0x8c3d37c819544da2n,0x73e1996689dcd4d6n,0x1dfab7ae32ff9c82n,0x679dd514582f9fcfn,0x0f6d2b697bd44da8n,0x77e36f7304c48942n,0x3f9d85a86a1d36c8n,0x1112e6ad91d692a1n]));update(z){this.sha512.update(z)}digest(){let z=new Uint8Array(32);return this.sha512.putDigest(z),z.slice(0,28)}}class SW{blockSize=128;size=28;sha512=new R6(new BigUint64Array([0x22312194fc2bf72cn,0x9f555fa3c84c64c2n,0x2393b86b6f53b151n,0x963877195940eabdn,0x96283ee2a88effe3n,0xbe5e1e2553863992n,0x2b0199fc2c85b8aan,0x0eb72ddc81c52ca2n]));update(z){this.sha512.update(z)}digest(){let z=new Uint8Array(32);return this.sha512.putDigest(z),z}}class R4{data;constructor(z){this.data=z}tokenType(){if("token_type"in this.data&&typeof this.data.token_type==="string")return this.data.token_type;throw new Error("Missing or invalid 'token_type' field")}accessToken(){if("access_token"in this.data&&typeof this.data.access_token==="string")return this.data.access_token;throw new Error("Missing or invalid 'access_token' field")}accessTokenExpiresInSeconds(){if("expires_in"in this.data&&typeof this.data.expires_in==="number")return this.data.expires_in;throw new Error("Missing or invalid 'expires_in' field")}accessTokenExpiresAt(){return new Date(Date.now()+this.accessTokenExpiresInSeconds()*1000)}hasRefreshToken(){return"refresh_token"in this.data&&typeof this.data.refresh_token==="string"}refreshToken(){if("refresh_token"in this.data&&typeof this.data.refresh_token==="string")return this.data.refresh_token;throw new Error("Missing or invalid 'refresh_token' field")}hasScopes(){return"scope"in this.data&&typeof this.data.scope==="string"}scopes(){if("scope"in this.data&&typeof this.data.scope==="string")return this.data.scope.split(" ");throw new Error("Missing or invalid 'scope' field")}idToken(){if("id_token"in this.data&&typeof this.data.id_token==="string")return this.data.id_token;throw new Error("Missing or invalid field 'id_token'")}}function y2(z){let w=Xw(new TextEncoder().encode(z));return e4(w)}function $w(){let z=new Uint8Array(32);return crypto.getRandomValues(z),e4(z)}function Aw(){let z=new Uint8Array(32);return crypto.getRandomValues(z),e4(z)}function DW(z,w){if(w.length!==1)throw new TypeError("Invalid character string");let U=0;while(U<z.length&&z[U]===w)U++;return z.slice(U)}function Qw(z,w){if(w.length!==1)throw new TypeError("Invalid character string");let U=z.length;while(U>0&&z[U-1]===w)U--;return z.slice(0,U)}function e0(z,...w){let U=Qw(z,"/");for(let W of w)U=Qw(U,"/")+"/"+DW(W,"/");return U}function T(z,w){let U=new TextEncoder().encode(w.toString()),W=new Request(z,{method:"POST",body:U});return W.headers.set("Content-Type","application/x-www-form-urlencoded"),W.headers.set("Accept","application/json"),W.headers.set("User-Agent","arctic"),W.headers.set("Content-Length",U.byteLength.toString()),W}function g1(z,w){let U=new TextEncoder().encode(`${z}:${w}`);return Ww(U)}async function i(z){let w;try{w=await fetch(z)}catch(U){throw new C6(U)}if(w.status===400||w.status===401){let U;try{U=await w.json()}catch{throw new z6(w.status)}if(typeof U!=="object"||U===null)throw new K1(w.status,U);let W;try{W=U5(U)}catch{throw new K1(w.status,U)}throw W}if(w.status===200){let U;try{U=await w.json()}catch{throw new z6(w.status)}if(typeof U!=="object"||U===null)throw new K1(w.status,U);return new R4(U)}if(w.body!==null)await w.body.cancel();throw new z6(w.status)}async function w6(z){let w;try{w=await fetch(z)}catch(U){throw new C6(U)}if(w.status===400||w.status===401){let U;try{U=await w.json()}catch{throw new K1(w.status,null)}if(typeof U!=="object"||U===null)throw new K1(w.status,U);let W;try{W=U5(U)}catch{throw new K1(w.status,U)}throw W}if(w.status===200){if(w.body!==null)await w.body.cancel();return}if(w.body!==null)await w.body.cancel();throw new z6(w.status)}function U5(z){let w;if("error"in z&&typeof z.error==="string")w=z.error;else throw new Error("Invalid error response");let U=null,W=null,X=null;if("error_description"in z){if(typeof z.error_description!=="string")throw new Error("Invalid data");U=z.error_description}if("error_uri"in z){if(typeof z.error_uri!=="string")throw new Error("Invalid data");W=z.error_uri}if("state"in z){if(typeof z.state!=="string")throw new Error("Invalid data");X=z.state}return new z8(w,U,W,X)}class C6 extends Error{constructor(z){super("Failed to send request",{cause:z})}}class z8 extends Error{code;description;uri;state;constructor(z,w,U,W){super(`OAuth request error: ${z}`);this.code=z,this.description=w,this.uri=U,this.state=W}}class z6 extends Error{status;constructor(z){super("Unexpected error response");this.status=z}}class K1 extends Error{status;data;constructor(z,w){super("Unexpected error response body");this.status=z,this.data=w}}class y{clientId;clientPassword;redirectURI;constructor(z,w,U){this.clientId=z,this.clientPassword=w,this.redirectURI=U}createAuthorizationURL(z,w,U){let W=new URL(z);if(W.searchParams.set("response_type","code"),W.searchParams.set("client_id",this.clientId),this.redirectURI!==null)W.searchParams.set("redirect_uri",this.redirectURI);if(W.searchParams.set("state",w),U.length>0)W.searchParams.set("scope",U.join(" "));return W}createAuthorizationURLWithPKCE(z,w,U,W,X){let Z=new URL(z);if(Z.searchParams.set("response_type","code"),Z.searchParams.set("client_id",this.clientId),this.redirectURI!==null)Z.searchParams.set("redirect_uri",this.redirectURI);if(Z.searchParams.set("state",w),U===w0.S256){let $=y2(W);Z.searchParams.set("code_challenge_method","S256"),Z.searchParams.set("code_challenge",$)}else if(U===w0.Plain)Z.searchParams.set("code_challenge_method","plain"),Z.searchParams.set("code_challenge",W);if(X.length>0)Z.searchParams.set("scope",X.join(" "));return Z}async validateAuthorizationCode(z,w,U){let W=new URLSearchParams;if(W.set("grant_type","authorization_code"),W.set("code",w),this.redirectURI!==null)W.set("redirect_uri",this.redirectURI);if(U!==null)W.set("code_verifier",U);if(this.clientPassword===null)W.set("client_id",this.clientId);let X=T(z,W);if(this.clientPassword!==null){let $=g1(this.clientId,this.clientPassword);X.headers.set("Authorization",`Basic ${$}`)}return await i(X)}async refreshAccessToken(z,w,U){let W=new URLSearchParams;if(W.set("grant_type","refresh_token"),W.set("refresh_token",w),this.clientPassword===null)W.set("client_id",this.clientId);if(U.length>0)W.set("scope",U.join(" "));let X=T(z,W);if(this.clientPassword!==null){let $=g1(this.clientId,this.clientPassword);X.headers.set("Authorization",`Basic ${$}`)}return await i(X)}async revokeToken(z,w){let U=new URLSearchParams;if(U.set("token",w),this.clientPassword===null)U.set("client_id",this.clientId);let W=T(z,U);if(this.clientPassword!==null){let X=g1(this.clientId,this.clientPassword);W.headers.set("Authorization",`Basic ${X}`)}await w6(W)}}var w0;(function(z){z[z.S256=0]="S256",z[z.Plain=1]="Plain"})(w0||(w0={}));class W5{authorizationEndpoint;tokenEndpoint;tokenRevocationEndpoint;client;constructor(z,w,U,W){this.authorizationEndpoint=`https://${z}/oauth2/authorize`,this.tokenEndpoint=`https://${z}/oauth2/token`,this.tokenRevocationEndpoint=`https://${z}/oauth2/revoke`,this.client=new y(w,U,W)}createAuthorizationURL(z,w,U){return this.client.createAuthorizationURLWithPKCE(this.authorizationEndpoint,z,w0.S256,w,U)}async validateAuthorizationCode(z,w){return await this.client.validateAuthorizationCode(this.tokenEndpoint,z,w)}async refreshAccessToken(z,w){return await this.client.refreshAccessToken(this.tokenEndpoint,z,w)}async revokeToken(z){await this.client.revokeToken(this.tokenRevocationEndpoint,z)}}var CG="https://anilist.co/api/v2/oauth/authorize",bG="https://anilist.co/api/v2/oauth/token";class X5{client;constructor(z,w,U){this.client=new y(z,w,U)}createAuthorizationURL(z){return this.client.createAuthorizationURL(CG,z,[])}async validateAuthorizationCode(z){return await this.client.validateAuthorizationCode(bG,z,null)}}var PW;(function(z){z[z.Include=0]="Include",z[z.None=1]="None"})(PW||(PW={}));var OW;(function(z){z[z.Required=0]="Required",z[z.Ignore=1]="Ignore"})(OW||(OW={}));function t6(z){return KG(z,jG,Z5.None)}function KG(z,w,U){let W="";for(let X=0;X<z.byteLength;X+=3){let Z=0,$=0;for(let A=0;A<3&&X+A<z.byteLength;A++)Z=Z<<8|z[X+A],$+=8;for(let A=0;A<4;A++)if($>=6)W+=w[Z>>$-6&63],$-=6;else if($>0)W+=w[Z<<6-$&63],$=0;else if(U===Z5.Include)W+="="}return W}var jG="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_";function Yw(z){return FG(z,EG,w8.Ignore)}function FG(z,w,U){let W=new Uint8Array(Math.ceil(z.length/4)*3),X=0;for(let Z=0;Z<z.length;Z+=4){let $=0,A=0;for(let Y=0;Y<4;Y++){if(U===w8.Required&&z[Z+Y]==="=")continue;if(U===w8.Ignore&&(Z+Y>=z.length||z[Z+Y]==="="))continue;if(Y>0&&z[Z+Y-1]==="=")throw new Error("Invalid padding");if(!(z[Z+Y]in w))throw new Error("Invalid character");$|=w[z[Z+Y]]<<(3-Y)*6,A+=6}if(A<24){let Y;if(A===12)Y=$&65535;else if(A===18)Y=$&255;else throw new Error("Invalid padding");if(Y!==0)throw new Error("Invalid padding")}let Q=Math.floor(A/8);for(let Y=0;Y<Q;Y++)W[X]=$>>16-Y*8&255,X++}return W.slice(0,X)}var Z5;(function(z){z[z.Include=0]="Include",z[z.None=1]="None"})(Z5||(Z5={}));var w8;(function(z){z[z.Required=0]="Required",z[z.Ignore=1]="Ignore"})(w8||(w8={}));var EG={"0":52,"1":53,"2":54,"3":55,"4":56,"5":57,"6":58,"7":59,"8":60,"9":61,A:0,B:1,C:2,D:3,E:4,F:5,G:6,H:7,I:8,J:9,K:10,L:11,M:12,N:13,O:14,P:15,Q:16,R:17,S:18,T:19,U:20,V:21,W:22,X:23,Y:24,Z:25,a:26,b:27,c:28,d:29,e:30,f:31,g:32,h:33,i:34,j:35,k:36,l:37,m:38,n:39,o:40,p:41,q:42,r:43,s:44,t:45,u:46,v:47,w:48,x:49,y:50,z:51,"-":62,_:63};function RW(z){let w=z.split(".");if(w.length!==3)throw new Error("Invalid JWT");let U;try{U=new TextDecoder().decode(Yw(w[1]))}catch{throw new Error("Invalid JWT: Invalid base64url encoding")}let W;try{W=JSON.parse(U)}catch{throw new Error("Invalid JWT: Invalid JSON encoding")}if(typeof W!=="object"||W===null)throw new Error("Invalid JWT: Invalid payload");return W}function CW(z,w,U){let W=t6(new TextEncoder().encode(z)),X=t6(new TextEncoder().encode(w)),Z=t6(U);return W+"."+X+"."+Z}function bW(z,w){let U=t6(new TextEncoder().encode(z)),W=t6(new TextEncoder().encode(w)),X=U+"."+W;return new TextEncoder().encode(X)}var xG="https://appleid.apple.com/auth/authorize",VG="https://appleid.apple.com/auth/token";class $5{clientId;teamId;keyId;pkcs8PrivateKey;redirectURI;constructor(z,w,U,W,X){this.clientId=z,this.teamId=w,this.keyId=U,this.pkcs8PrivateKey=W,this.redirectURI=X}createAuthorizationURL(z,w){let U=new URL(xG);if(U.searchParams.set("response_type","code"),U.searchParams.set("client_id",this.clientId),U.searchParams.set("state",z),w.length>0)U.searchParams.set("scope",w.join(" "));return U.searchParams.set("redirect_uri",this.redirectURI),U}async validateAuthorizationCode(z){let w=new URLSearchParams;w.set("grant_type","authorization_code"),w.set("code",z),w.set("redirect_uri",this.redirectURI),w.set("client_id",this.clientId);let U=await this.createClientSecret();w.set("client_secret",U);let W=T(VG,w);return await i(W)}async createClientSecret(){let z=await crypto.subtle.importKey("pkcs8",this.pkcs8PrivateKey,{name:"ECDSA",namedCurve:"P-256"},!1,["sign"]),w=Math.floor(Date.now()/1000),U=JSON.stringify({typ:"JWT",alg:"ES256",kid:this.keyId}),W=JSON.stringify({iss:this.teamId,exp:w+300,aud:["https://appleid.apple.com"],sub:this.clientId,iat:w}),X=new Uint8Array(await crypto.subtle.sign({name:"ECDSA",hash:"SHA-256"},z,bW(U,W)));return CW(U,W,X)}}var kG="https://auth.atlassian.com/authorize",jW="https://auth.atlassian.com/oauth/token";class A5{clientId;clientSecret;redirectURI;constructor(z,w,U){this.clientId=z,this.clientSecret=w,this.redirectURI=U}createAuthorizationURL(z,w){let U=new URL(kG);if(U.searchParams.set("response_type","code"),U.searchParams.set("client_id",this.clientId),U.searchParams.set("state",z),w.length>0)U.searchParams.set("scope",w.join(" "));return U.searchParams.set("redirect_uri",this.redirectURI),U.searchParams.set("audience","api.atlassian.com"),U.searchParams.set("prompt","consent"),U}async validateAuthorizationCode(z){let w=new URLSearchParams;w.set("grant_type","authorization_code"),w.set("code",z),w.set("redirect_uri",this.redirectURI),w.set("client_id",this.clientId),w.set("client_secret",this.clientSecret);let U=T(jW,w);return await i(U)}async refreshAccessToken(z){let w=new URLSearchParams;w.set("grant_type","refresh_token"),w.set("refresh_token",z),w.set("client_id",this.clientId),w.set("client_secret",this.clientSecret);let U=T(jW,w);return await i(U)}}class Q5{authorizationEndpoint;tokenEndpoint;tokenRevocationEndpoint;client;constructor(z,w,U,W){this.authorizationEndpoint=`https://${z}/authorize`,this.tokenEndpoint=`https://${z}/oauth/token`,this.tokenRevocationEndpoint=`https://${z}/oauth/revoke`,this.client=new y(w,U,W)}createAuthorizationURL(z,w,U){let W;if(w!==null)W=this.client.createAuthorizationURLWithPKCE(this.authorizationEndpoint,z,w0.S256,w,U);else W=this.client.createAuthorizationURL(this.authorizationEndpoint,z,U);return W}async validateAuthorizationCode(z,w){return await this.client.validateAuthorizationCode(this.tokenEndpoint,z,w)}async refreshAccessToken(z){return await this.client.refreshAccessToken(this.tokenEndpoint,z,[])}async revokeToken(z){await this.client.revokeToken(this.tokenRevocationEndpoint,z)}}class Y5{authorizationEndpoint;tokenEndpoint;tokenRevocationEndpoint;client;constructor(z,w,U,W){this.authorizationEndpoint=e0(z,"/application/o/authorize/"),this.tokenEndpoint=e0(z,"/application/o/token/"),this.tokenRevocationEndpoint=e0(z,"/application/o/revoke/"),this.client=new y(w,U,W)}createAuthorizationURL(z,w,U){return this.client.createAuthorizationURLWithPKCE(this.authorizationEndpoint,z,w0.S256,w,U)}async validateAuthorizationCode(z,w){return await this.client.validateAuthorizationCode(this.tokenEndpoint,z,w)}async refreshAccessToken(z){return await this.client.refreshAccessToken(this.tokenEndpoint,z,[])}async revokeToken(z){await this.client.revokeToken(this.tokenRevocationEndpoint,z)}}var TG="https://bitbucket.org/site/oauth2/authorize",FW="https://bitbucket.org/site/oauth2/access_token";class J5{client;constructor(z,w,U){this.client=new y(z,w,U)}createAuthorizationURL(z){return this.client.createAuthorizationURL(TG,z,[])}async validateAuthorizationCode(z){return await this.client.validateAuthorizationCode(FW,z,null)}async refreshAccessToken(z){return await this.client.refreshAccessToken(FW,z,[])}}var gG="https://account.box.com/api/oauth2/authorize",EW="https://api.box.com/oauth2/token",fG="https://api.box.com/oauth2/revoke";class B5{clientId;clientSecret;redirectURI;constructor(z,w,U){this.clientId=z,this.clientSecret=w,this.redirectURI=U}createAuthorizationURL(z,w){let U=new URL(gG);if(U.searchParams.set("response_type","code"),U.searchParams.set("client_id",this.clientId),U.searchParams.set("state",z),w.length>0)U.searchParams.set("scope",w.join(" "));return U.searchParams.set("redirect_uri",this.redirectURI),U}async validateAuthorizationCode(z){let w=new URLSearchParams;w.set("grant_type","authorization_code"),w.set("code",z),w.set("redirect_uri",this.redirectURI),w.set("client_id",this.clientId),w.set("client_secret",this.clientSecret);let U=T(EW,w);return await i(U)}async refreshAccessToken(z){let w=new URLSearchParams;w.set("grant_type","refresh_token"),w.set("refresh_token",z),w.set("client_id",this.clientId),w.set("client_secret",this.clientSecret);let U=T(EW,w);return await i(U)}async revokeToken(z){let w=new URLSearchParams;w.set("token",z),w.set("client_id",this.clientId),w.set("client_secret",this.clientSecret);let U=T(fG,w);await w6(U)}}var dG="https://www.coinbase.com/oauth/authorize",IW="https://www.coinbase.com/oauth/token",hG="https://api.coinbase.com/oauth/revoke";class M5{clientId;clientSecret;redirectURI;constructor(z,w,U){this.clientId=z,this.clientSecret=w,this.redirectURI=U}createAuthorizationURL(z,w){let U=new URL(dG);if(U.searchParams.set("response_type","code"),U.searchParams.set("client_id",this.clientId),U.searchParams.set("state",z),w.length>0)U.searchParams.set("scope",w.join(" "));return U.searchParams.set("redirect_uri",this.redirectURI),U}async validateAuthorizationCode(z){let w=new URLSearchParams;w.set("grant_type","authorization_code"),w.set("code",z),w.set("redirect_uri",this.redirectURI),w.set("client_id",this.clientId),w.set("client_secret",this.clientSecret);let U=T(IW,w);return await i(U)}async refreshAccessToken(z){let w=new URLSearchParams;w.set("grant_type","refresh_token"),w.set("refresh_token",z),w.set("client_id",this.clientId),w.set("client_secret",this.clientSecret);let U=T(IW,w);return await i(U)}async revokeToken(z){let w=new URLSearchParams;w.set("token",z),w.set("client_id",this.clientId),w.set("client_secret",this.clientSecret);let U=T(hG,w);await w6(U)}}var xW="https://discord.com/oauth2/authorize",VW="https://discord.com/api/oauth2/token",cG="https://discord.com/api/oauth2/token/revoke";class q5{client;constructor(z,w,U){this.client=new y(z,w,U)}createAuthorizationURL(z,w,U){let W;if(w!==null)W=this.client.createAuthorizationURLWithPKCE(xW,z,w0.S256,w,U);else W=this.client.createAuthorizationURL(xW,z,U);return W}async validateAuthorizationCode(z,w){return await this.client.validateAuthorizationCode(VW,z,w)}async refreshAccessToken(z){return await this.client.refreshAccessToken(VW,z,[])}async revokeToken(z){await this.client.revokeToken(cG,z)}}var iG="https://dribbble.com/oauth/authorize",yG="https://dribbble.com/oauth/token";class L5{clientId;clientSecret;redirectURI;constructor(z,w,U){this.clientId=z,this.clientSecret=w,this.redirectURI=U}createAuthorizationURL(z,w){let U=new URL(iG);if(U.searchParams.set("response_type","code"),U.searchParams.set("client_id",this.clientId),U.searchParams.set("state",z),w.length>0)U.searchParams.set("scope",w.join(" "));return U.searchParams.set("redirect_uri",this.redirectURI),U}async validateAuthorizationCode(z){let w=new URLSearchParams;w.set("grant_type","authorization_code"),w.set("code",z),w.set("redirect_uri",this.redirectURI),w.set("client_id",this.clientId),w.set("client_secret",this.clientSecret);let U=T(yG,w);return await i(U)}}var vG="https://www.dropbox.com/oauth2/authorize",kW="https://api.dropboxapi.com/oauth2/token",nG="https://api.dropboxapi.com/2/auth/token/revoke";class G5{client;constructor(z,w,U){this.client=new y(z,w,U)}createAuthorizationURL(z,w){return this.client.createAuthorizationURL(vG,z,w)}async validateAuthorizationCode(z){return await this.client.validateAuthorizationCode(kW,z,null)}async refreshAccessToken(z){return await this.client.refreshAccessToken(kW,z,[])}async revokeToken(z){await this.client.revokeToken(nG,z)}}var uG="https://www.facebook.com/v16.0/dialog/oauth",mG="https://graph.facebook.com/v16.0/oauth/access_token";class N5{clientId;clientSecret;redirectURI;constructor(z,w,U){this.clientId=z,this.clientSecret=w,this.redirectURI=U}createAuthorizationURL(z,w){let U=new URL(uG);if(U.searchParams.set("response_type","code"),U.searchParams.set("client_id",this.clientId),U.searchParams.set("state",z),w.length>0)U.searchParams.set("scope",w.join(" "));return U.searchParams.set("redirect_uri",this.redirectURI),U}async validateAuthorizationCode(z){let w=new URLSearchParams;w.set("grant_type","authorization_code"),w.set("code",z),w.set("redirect_uri",this.redirectURI),w.set("client_id",this.clientId),w.set("client_secret",this.clientSecret);let U=T(mG,w);return await i(U)}}var tG="https://www.figma.com/oauth",oG="https://api.figma.com/v1/oauth/token",pG="https://api.figma.com/v1/oauth/refresh";class H5{client;constructor(z,w,U){this.client=new y(z,w,U)}createAuthorizationURL(z,w){return this.client.createAuthorizationURL(tG,z,w)}async validateAuthorizationCode(z){return await this.client.validateAuthorizationCode(oG,z,null)}async refreshAccessToken(z){return await this.client.refreshAccessToken(pG,z,[])}}var lG="https://github.com/login/oauth/authorize",TW="https://github.com/login/oauth/access_token";class _5{clientId;clientSecret;redirectURI;constructor(z,w,U){this.clientId=z,this.clientSecret=w,this.redirectURI=U}createAuthorizationURL(z,w){let U=new URL(lG);if(U.searchParams.set("response_type","code"),U.searchParams.set("client_id",this.clientId),U.searchParams.set("state",z),w.length>0)U.searchParams.set("scope",w.join(" "));if(this.redirectURI!==null)U.searchParams.set("redirect_uri",this.redirectURI);return U}async validateAuthorizationCode(z){let w=new URLSearchParams;if(w.set("grant_type","authorization_code"),w.set("code",z),this.redirectURI!==null)w.set("redirect_uri",this.redirectURI);let U=T(TW,w),W=g1(this.clientId,this.clientSecret);return U.headers.set("Authorization",`Basic ${W}`),await gW(U)}async refreshAccessToken(z){let w=new URLSearchParams;w.set("grant_type","refresh_token"),w.set("refresh_token",z);let U=T(TW,w),W=g1(this.clientId,this.clientSecret);return U.headers.set("Authorization",`Basic ${W}`),await gW(U)}}async function gW(z){let w;try{w=await fetch(z)}catch(X){throw new C6(X)}if(w.status!==200){if(w.body!==null)await w.body.cancel();throw new z6(w.status)}let U;try{U=await w.json()}catch{throw new z6(w.status)}if(typeof U!=="object"||U===null)throw new K1(w.status,U);if("error"in U&&typeof U.error==="string"){let X;try{X=U5(U)}catch{throw new K1(w.status,U)}throw X}return new R4(U)}class S5{authorizationEndpoint;tokenEndpoint;tokenRevocationEndpoint;client;constructor(z,w,U,W){this.authorizationEndpoint=e0(z,"/oauth/authorize"),this.tokenEndpoint=e0(z,"/oauth/token"),this.tokenRevocationEndpoint=e0(z,"/oauth/revoke"),this.client=new y(w,U,W)}createAuthorizationURL(z,w){return this.client.createAuthorizationURL(this.authorizationEndpoint,z,w)}async validateAuthorizationCode(z){return await this.client.validateAuthorizationCode(this.tokenEndpoint,z,null)}async refreshAccessToken(z){return await this.client.refreshAccessToken(this.tokenEndpoint,z,[])}async revokeToken(z){await this.client.revokeToken(this.tokenRevocationEndpoint,z)}}var sG="https://accounts.google.com/o/oauth2/v2/auth",fW="https://oauth2.googleapis.com/token",rG="https://oauth2.googleapis.com/revoke";class D5{client;constructor(z,w,U){this.client=new y(z,w,U)}createAuthorizationURL(z,w,U){return this.client.createAuthorizationURLWithPKCE(sG,z,w0.S256,w,U)}async validateAuthorizationCode(z,w){return await this.client.validateAuthorizationCode(fW,z,w)}async refreshAccessToken(z){return await this.client.refreshAccessToken(fW,z,[])}async revokeToken(z){await this.client.revokeToken(rG,z)}}var aG="https://appcenter.intuit.com/connect/oauth2",dW="https://oauth.platform.intuit.com/oauth2/v1/tokens/bearer",eG="https://developer.API.intuit.com/v2/oauth2/tokens/revoke";class P5{client;constructor(z,w,U){this.client=new y(z,w,U)}createAuthorizationURL(z,w){return this.client.createAuthorizationURL(aG,z,w)}async validateAuthorizationCode(z){return await this.client.validateAuthorizationCode(dW,z,null)}async refreshAccessToken(z){return await this.client.refreshAccessToken(dW,z,[])}async revokeToken(z){await this.client.revokeToken(eG,z)}}var zN="https://kauth.kakao.com/oauth/authorize",hW="https://kauth.kakao.com/oauth/token";class O5{clientId;clientSecret;redirectURI;constructor(z,w,U){this.clientId=z,this.clientSecret=w,this.redirectURI=U}createAuthorizationURL(z,w){let U=new URL(zN);if(U.searchParams.set("response_type","code"),U.searchParams.set("client_id",this.clientId),U.searchParams.set("state",z),w.length>0)U.searchParams.set("scope",w.join(" "));return U.searchParams.set("redirect_uri",this.redirectURI),U}async validateAuthorizationCode(z){let w=new URLSearchParams;w.set("grant_type","authorization_code"),w.set("code",z),w.set("redirect_uri",this.redirectURI),w.set("client_id",this.clientId),w.set("client_secret",this.clientSecret);let U=T(hW,w);return await i(U)}async refreshAccessToken(z){let w=new URLSearchParams;w.set("grant_type","refresh_token"),w.set("refresh_token",z),w.set("client_id",this.clientId),w.set("client_secret",this.clientSecret);let U=T(hW,w);return await i(U)}}class R5{authorizationEndpoint;tokenEndpoint;tokenRevocationEndpoint;client;constructor(z,w,U,W){this.authorizationEndpoint=z+"/protocol/openid-connect/auth",this.tokenEndpoint=z+"/protocol/openid-connect/token",this.tokenRevocationEndpoint=z+"/protocol/openid-connect/revoke",this.client=new y(w,U,W)}createAuthorizationURL(z,w,U){return this.client.createAuthorizationURLWithPKCE(this.authorizationEndpoint,z,w0.S256,w,U)}async validateAuthorizationCode(z,w){return await this.client.validateAuthorizationCode(this.tokenEndpoint,z,w)}async refreshAccessToken(z){return await this.client.refreshAccessToken(this.tokenEndpoint,z,[])}async revokeToken(z){await this.client.revokeToken(this.tokenRevocationEndpoint,z)}}var wN="https://lichess.org/oauth",UN="https://lichess.org/api/token";class C5{client;constructor(z,w){this.client=new y(z,null,w)}createAuthorizationURL(z,w,U){return this.client.createAuthorizationURLWithPKCE(wN,z,w0.S256,w,U)}async validateAuthorizationCode(z,w){return await this.client.validateAuthorizationCode(UN,z,w)}}var WN="https://access.line.me/oauth2/v2.1/authorize",cW="https://api.line.me/oauth2/v2.1/token";class b5{clientId;clientSecret;redirectURI;constructor(z,w,U){this.clientId=z,this.clientSecret=w,this.redirectURI=U}createAuthorizationURL(z,w,U){let W=new URL(WN);if(W.searchParams.set("response_type","code"),W.searchParams.set("client_id",this.clientId),W.searchParams.set("state",z),U.length>0)W.searchParams.set("scope",U.join(" "));W.searchParams.set("redirect_uri",this.redirectURI);let X=y2(w);return W.searchParams.set("code_challenge_method","S256"),W.searchParams.set("code_challenge",X),W}async validateAuthorizationCode(z,w){let U=new URLSearchParams;U.set("grant_type","authorization_code"),U.set("code",z),U.set("code_verifier",w),U.set("redirect_uri",this.redirectURI),U.set("client_id",this.clientId),U.set("client_secret",this.clientSecret);let W=T(cW,U);return await i(W)}async refreshAccessToken(z){let w=new URLSearchParams;w.set("grant_type","refresh_token"),w.set("refresh_token",z),w.set("client_id",this.clientId),w.set("client_secret",this.clientSecret);let U=T(cW,w);return await i(U)}}var XN="https://linear.app/oauth/authorize",ZN="https://api.linear.app/oauth/token";class K5{clientId;clientSecret;redirectURI;constructor(z,w,U){this.clientId=z,this.clientSecret=w,this.redirectURI=U}createAuthorizationURL(z,w){let U=new URL(XN);if(U.searchParams.set("response_type","code"),U.searchParams.set("client_id",this.clientId),U.searchParams.set("state",z),w.length>0)U.searchParams.set("scope",w.join(" "));return U.searchParams.set("redirect_uri",this.redirectURI),U}async validateAuthorizationCode(z){let w=new URLSearchParams;w.set("grant_type","authorization_code"),w.set("code",z),w.set("redirect_uri",this.redirectURI),w.set("client_id",this.clientId),w.set("client_secret",this.clientSecret);let U=T(ZN,w);return await i(U)}}var $N="https://www.linkedin.com/oauth/v2/authorization",iW="https://www.linkedin.com/oauth/v2/accessToken";class j5{clientId;clientSecret;redirectURI;constructor(z,w,U){this.clientId=z,this.clientSecret=w,this.redirectURI=U}createAuthorizationURL(z,w){let U=new URL($N);if(U.searchParams.set("response_type","code"),U.searchParams.set("client_id",this.clientId),U.searchParams.set("state",z),w.length>0)U.searchParams.set("scope",w.join(" "));return U.searchParams.set("redirect_uri",this.redirectURI),U}async validateAuthorizationCode(z){let w=new URLSearchParams;w.set("grant_type","authorization_code"),w.set("code",z),w.set("redirect_uri",this.redirectURI),w.set("client_id",this.clientId),w.set("client_secret",this.clientSecret);let U=T(iW,w);return await i(U)}async refreshAccessToken(z){let w=new URLSearchParams;w.set("grant_type","refresh_token"),w.set("refresh_token",z),w.set("client_id",this.clientId),w.set("client_secret",this.clientSecret);let U=T(iW,w);return await i(U)}}class F5{authorizationEndpoint;tokenEndpoint;clientId;clientSecret;redirectURI;constructor(z,w,U,W){this.authorizationEndpoint=e0("https://login.microsoftonline.com",z,"/oauth2/v2.0/authorize"),this.tokenEndpoint=e0("https://login.microsoftonline.com",z,"/oauth2/v2.0/token"),this.clientId=w,this.clientSecret=U,this.redirectURI=W}createAuthorizationURL(z,w,U){let W=new URL(this.authorizationEndpoint);W.searchParams.set("response_type","code"),W.searchParams.set("client_id",this.clientId),W.searchParams.set("redirect_uri",this.redirectURI),W.searchParams.set("state",z);let X=y2(w);if(W.searchParams.set("code_challenge_method","S256"),W.searchParams.set("code_challenge",X),U.length>0)W.searchParams.set("scope",U.join(" "));return W}async validateAuthorizationCode(z,w){let U=new URLSearchParams;if(U.set("grant_type","authorization_code"),U.set("code",z),U.set("redirect_uri",this.redirectURI),U.set("code_verifier",w),this.clientSecret===null)U.set("client_id",this.clientId);let W=T(this.tokenEndpoint,U);if(this.clientSecret!==null){let Z=g1(this.clientId,this.clientSecret);W.headers.set("Authorization",`Basic ${Z}`)}else W.headers.set("Origin","arctic");return await i(W)}async refreshAccessToken(z,w){let U=new URLSearchParams;if(U.set("grant_type","refresh_token"),U.set("refresh_token",z),this.clientSecret===null)U.set("client_id",this.clientId);if(w.length>0)U.set("scope",w.join(" "));let W=T(this.tokenEndpoint,U);if(this.clientSecret!==null){let Z=g1(this.clientId,this.clientSecret);W.headers.set("Authorization",`Basic ${Z}`)}else W.headers.set("Origin","arctic");return await i(W)}}var AN="https://myanimelist.net/v1/oauth2/authorize",yW="https://myanimelist.net/v1/oauth2/token";class E5{client;constructor(z,w,U){this.client=new y(z,w,U)}createAuthorizationURL(z,w){return this.client.createAuthorizationURLWithPKCE(AN,z,w0.Plain,w,[])}async validateAuthorizationCode(z,w){return await this.client.validateAuthorizationCode(yW,z,w)}async refreshAccessToken(z){return await this.client.refreshAccessToken(yW,z,[])}}var QN="https://api.notion.com/v1/oauth/authorize",YN="https://api.notion.com/v1/oauth/token";class I5{client;constructor(z,w,U){this.client=new y(z,w,U)}createAuthorizationURL(z){let w=this.client.createAuthorizationURL(QN,z,[]);return w.searchParams.set("owner","user"),w}async validateAuthorizationCode(z){return await this.client.validateAuthorizationCode(YN,z,null)}}class x5{authorizationEndpoint;tokenEndpoint;tokenRevocationEndpoint;client;constructor(z,w,U,W,X){let Z=`https://${z}/oauth2`;if(w!==null)Z=e0(Z,w);this.authorizationEndpoint=e0(Z,"/v1/authorize"),this.tokenEndpoint=e0(Z,"/v1/token"),this.tokenRevocationEndpoint=e0(Z,"/v1/revoke"),this.client=new y(U,W,X)}createAuthorizationURL(z,w,U){return this.client.createAuthorizationURLWithPKCE(this.authorizationEndpoint,z,w0.S256,w,U)}async validateAuthorizationCode(z,w){return await this.client.validateAuthorizationCode(this.tokenEndpoint,z,w)}async refreshAccessToken(z,w){return await this.client.refreshAccessToken(this.tokenEndpoint,z,w)}async revokeToken(z){await this.client.revokeToken(this.tokenRevocationEndpoint,z)}}var JN="https://osu.ppy.sh/oauth/authorize",vW="https://osu.ppy.sh/oauth/token";class V5{clientId;clientSecret;redirectURI;constructor(z,w,U){this.clientId=z,this.clientSecret=w,this.redirectURI=U}createAuthorizationURL(z,w){let U=new URL(JN);if(U.searchParams.set("response_type","code"),U.searchParams.set("client_id",this.clientId),U.searchParams.set("state",z),w.length>0)U.searchParams.set("scope",w.join(" "));if(this.redirectURI!==null)U.searchParams.set("redirect_uri",this.redirectURI);return U}async validateAuthorizationCode(z){let w=new URLSearchParams;if(w.set("grant_type","authorization_code"),w.set("code",z),this.redirectURI!==null)w.set("redirect_uri",this.redirectURI);w.set("client_id",this.clientId),w.set("client_secret",this.clientSecret);let U=T(vW,w);return await i(U)}async refreshAccessToken(z){let w=new URLSearchParams;w.set("grant_type","refresh_token"),w.set("refresh_token",z),w.set("client_id",this.clientId),w.set("client_secret",this.clientSecret);let U=T(vW,w);return await i(U)}}var BN="https://www.patreon.com/oauth2/authorize",nW="https://www.patreon.com/api/oauth2/token";class k5{clientId;clientSecret;redirectURI;constructor(z,w,U){this.clientId=z,this.clientSecret=w,this.redirectURI=U}createAuthorizationURL(z,w){let U=new URL(BN);if(U.searchParams.set("response_type","code"),U.searchParams.set("client_id",this.clientId),U.searchParams.set("state",z),w.length>0)U.searchParams.set("scope",w.join(" "));return U.searchParams.set("redirect_uri",this.redirectURI),U}async validateAuthorizationCode(z){let w=new URLSearchParams;w.set("grant_type","authorization_code"),w.set("code",z),w.set("redirect_uri",this.redirectURI),w.set("client_id",this.clientId),w.set("client_secret",this.clientSecret);let U=T(nW,w);return await i(U)}async refreshAccessToken(z){let w=new URLSearchParams;w.set("grant_type","refresh_token"),w.set("refresh_token",z),w.set("client_id",this.clientId),w.set("client_secret",this.clientSecret);let U=T(nW,w);return await i(U)}}var MN="https://www.reddit.com/api/v1/authorize",uW="https://www.reddit.com/api/v1/access_token";class T5{client;constructor(z,w,U){this.client=new y(z,w,U)}createAuthorizationURL(z,w){return this.client.createAuthorizationURL(MN,z,w)}async validateAuthorizationCode(z){return await this.client.validateAuthorizationCode(uW,z,null)}async refreshAccessToken(z){return await this.client.refreshAccessToken(uW,z,[])}}var qN="https://apis.roblox.com/oauth/v1/authorize",mW="https://apis.roblox.com/oauth/v1/token",LN="https://apis.roblox.com/oauth/v1/token/revoke";class g5{client;constructor(z,w,U){this.client=new y(z,w,U)}createAuthorizationURL(z,w,U){return this.client.createAuthorizationURLWithPKCE(qN,z,w0.S256,w,U)}async validateAuthorizationCode(z,w){return await this.client.validateAuthorizationCode(mW,z,w)}async refreshAccessToken(z){return await this.client.refreshAccessToken(mW,z,[])}async revokeToken(z){await this.client.revokeToken(LN,z)}}class f5{authorizationEndpoint;tokenEndpoint;tokenRevocationEndpoint;client;constructor(z,w,U,W){this.authorizationEndpoint=`https://${z}/services/oauth2/authorize`,this.tokenEndpoint=`https://${z}/services/oauth2/token`,this.tokenRevocationEndpoint=`https://${z}/services/oauth2/revoke`,this.client=new y(w,U,W)}createAuthorizationURL(z,w,U){return this.client.createAuthorizationURLWithPKCE(this.authorizationEndpoint,z,w0.S256,w,U)}async validateAuthorizationCode(z,w){return await this.client.validateAuthorizationCode(this.tokenEndpoint,z,w)}async refreshAccessToken(z){return await this.client.refreshAccessToken(this.tokenEndpoint,z,[])}async revokeToken(z){await this.client.revokeToken(this.tokenRevocationEndpoint,z)}}var GN="https://shikimori.one/oauth/authorize",tW="https://shikimori.one/oauth/token";class d5{clientId;clientSecret;redirectURI;constructor(z,w,U){this.clientId=z,this.clientSecret=w,this.redirectURI=U}createAuthorizationURL(z){let w=new URL(GN);return w.searchParams.set("response_type","code"),w.searchParams.set("client_id",this.clientId),w.searchParams.set("state",z),w.searchParams.set("redirect_uri",this.redirectURI),w}async validateAuthorizationCode(z){let w=new URLSearchParams;w.set("grant_type","authorization_code"),w.set("code",z),w.set("redirect_uri",this.redirectURI),w.set("client_id",this.clientId),w.set("client_secret",this.clientSecret);let U=T(tW,w);return await i(U)}async refreshAccessToken(z){let w=new URLSearchParams;w.set("grant_type","refresh_token"),w.set("refresh_token",z),w.set("client_id",this.clientId),w.set("client_secret",this.clientSecret);let U=T(tW,w);return await i(U)}}var NN="https://slack.com/openid/connect/authorize",HN="https://slack.com/api/openid.connect.token";class h5{client;constructor(z,w,U){this.client=new y(z,w,U)}createAuthorizationURL(z,w){return this.client.createAuthorizationURL(NN,z,w)}async validateAuthorizationCode(z){return await this.client.validateAuthorizationCode(HN,z,null)}}var oW="https://accounts.spotify.com/authorize",pW="https://accounts.spotify.com/api/token";class c5{client;constructor(z,w,U){this.client=new y(z,w,U)}createAuthorizationURL(z,w,U){let W;if(w!==null)W=this.client.createAuthorizationURLWithPKCE(oW,z,w0.S256,w,U);else W=this.client.createAuthorizationURL(oW,z,U);return W}async validateAuthorizationCode(z,w){return await this.client.validateAuthorizationCode(pW,z,w)}async refreshAccessToken(z){return await this.client.refreshAccessToken(pW,z,[])}}var _N="https://www.strava.com/oauth/authorize",lW="https://www.strava.com/api/v3/oauth/token";class i5{clientId;clientSecret;redirectURI;constructor(z,w,U){this.clientId=z,this.clientSecret=w,this.redirectURI=U}createAuthorizationURL(z,w){let U=new URL(_N);if(U.searchParams.set("response_type","code"),U.searchParams.set("client_id",this.clientId),U.searchParams.set("state",z),w.length>0)U.searchParams.set("scope",w.join(","));return U.searchParams.set("redirect_uri",this.redirectURI),U}async validateAuthorizationCode(z){let w=new URLSearchParams;w.set("grant_type","authorization_code"),w.set("code",z),w.set("redirect_uri",this.redirectURI),w.set("client_id",this.clientId),w.set("client_secret",this.clientSecret);let U=T(lW,w);return await i(U)}async refreshAccessToken(z){let w=new URLSearchParams;w.set("grant_type","refresh_token"),w.set("refresh_token",z),w.set("client_id",this.clientId),w.set("client_secret",this.clientSecret);let U=T(lW,w);return await i(U)}}var SN="https://v5api.tiltify.com/oauth/authorizeze",sW="https://v5api.tiltify.com/oauth/token";class y5{clientId;clientSecret;redirectURI;constructor(z,w,U){this.clientId=z,this.clientSecret=w,this.redirectURI=U}createAuthorizationURL(z,w){let U=new URL(SN);if(U.searchParams.set("response_type","code"),U.searchParams.set("client_id",this.clientId),U.searchParams.set("state",z),w.length>0)U.searchParams.set("scope",w.join(" "));return U.searchParams.set("redirect_uri",this.redirectURI),U}async validateAuthorizationCode(z){let w=new URLSearchParams;w.set("grant_type","authorization_code"),w.set("code",z),w.set("redirect_uri",this.redirectURI),w.set("client_id",this.clientId),w.set("client_secret",this.clientSecret);let U=T(sW,w);return await i(U)}async refreshAccessToken(z){let w=new URLSearchParams;w.set("grant_type","refresh_token"),w.set("refresh_token",z),w.set("client_id",this.clientId),w.set("client_secret",this.clientSecret);let U=T(sW,w);return await i(U)}}var DN="https://www.tumblr.com/oauth2/authorize",rW="https://api.tumblr.com/v2/oauth2/token";class v5{client;constructor(z,w,U){this.client=new y(z,w,U)}createAuthorizationURL(z,w){return this.client.createAuthorizationURL(DN,z,w)}async validateAuthorizationCode(z){return await this.client.validateAuthorizationCode(rW,z,null)}async refreshAccessToken(z){return await this.client.refreshAccessToken(rW,z,[])}}var PN="https://id.twitch.tv/oauth2/authorize",aW="https://id.twitch.tv/oauth2/token";class n5{clientId;clientSecret;redirectURI;constructor(z,w,U){this.clientId=z,this.clientSecret=w,this.redirectURI=U}createAuthorizationURL(z,w){let U=new URL(PN);if(U.searchParams.set("response_type","code"),U.searchParams.set("client_id",this.clientId),U.searchParams.set("state",z),w.length>0)U.searchParams.set("scope",w.join(" "));return U.searchParams.set("redirect_uri",this.redirectURI),U}async validateAuthorizationCode(z){let w=new URLSearchParams;w.set("grant_type","authorization_code"),w.set("code",z),w.set("redirect_uri",this.redirectURI),w.set("client_id",this.clientId),w.set("client_secret",this.clientSecret);let U=T(aW,w);return await i(U)}async refreshAccessToken(z){let w=new URLSearchParams;w.set("grant_type","refresh_token"),w.set("refresh_token",z),w.set("client_id",this.clientId),w.set("client_secret",this.clientSecret);let U=T(aW,w);return await i(U)}}var ON="https://twitter.com/i/oauth2/authorize",eW="https://api.twitter.com/2/oauth2/token",RN="https://api.twitter.com/2/oauth2/revoke";class u5{client;constructor(z,w,U){this.client=new y(z,w,U)}createAuthorizationURL(z,w,U){return this.client.createAuthorizationURLWithPKCE(ON,z,w0.S256,w,U)}async validateAuthorizationCode(z,w){return await this.client.validateAuthorizationCode(eW,z,w)}async refreshAccessToken(z){return await this.client.refreshAccessToken(eW,z,[])}async revokeToken(z){await this.client.revokeToken(RN,z)}}var CN="https://oauth.vk.com/authorize",bN="https://oauth.vk.com/access_token";class m5{clientId;clientSecret;redirectURI;constructor(z,w,U){this.clientId=z,this.clientSecret=w,this.redirectURI=U}createAuthorizationURL(z,w){let U=new URL(CN);if(U.searchParams.set("response_type","code"),U.searchParams.set("client_id",this.clientId),U.searchParams.set("state",z),w.length>0)U.searchParams.set("scope",w.join(" "));return U.searchParams.set("redirect_uri",this.redirectURI),U}async validateAuthorizationCode(z){let w=new URLSearchParams;w.set("grant_type","authorization_code"),w.set("code",z),w.set("redirect_uri",this.redirectURI),w.set("client_id",this.clientId),w.set("client_secret",this.clientSecret);let U=T(bN,w);return await i(U)}}var KN="https://api.workos.com/sso/authorize",jN="https://api.workos.com/sso/token";class t5{clientId;clientSecret;redirectURI;constructor(z,w,U){this.clientId=z,this.clientSecret=w,this.redirectURI=U}createAuthorizationURL(z,w){let U=new URL(KN);if(U.searchParams.set("response_type","code"),U.searchParams.set("client_id",this.clientId),U.searchParams.set("state",z),U.searchParams.set("redirect_uri",this.redirectURI),w!==null){let W=y2(w);U.searchParams.set("code_challenge_method","S256"),U.searchParams.set("code_challenge",W)}return U}async validateAuthorizationCode(z,w){let U=new URLSearchParams;if(U.set("grant_type","authorization_code"),U.set("code",z),U.set("redirect_uri",this.redirectURI),U.set("client_id",this.clientId),this.clientSecret!==null)U.set("client_secret",this.clientSecret);if(w!==null)U.set("code_verifier",w);let W=T(jN,U);return await i(W)}}var FN="https://api.login.yahoo.com/oauth2/request_auth",zX="https://api.login.yahoo.com/oauth2/get_token";class o5{client;constructor(z,w,U){this.client=new y(z,w,U)}createAuthorizationURL(z,w){return this.client.createAuthorizationURL(FN,z,w)}async validateAuthorizationCode(z){return await this.client.validateAuthorizationCode(zX,z,null)}async refreshAccessToken(z){return await this.client.refreshAccessToken(zX,z,[])}}var EN="https://oauth.yandex.com/authorize",wX="https://oauth.yandex.com/token";class p5{client;constructor(z,w,U){this.client=new y(z,w,U)}createAuthorizationURL(z,w){return this.client.createAuthorizationURL(EN,z,w)}async validateAuthorizationCode(z){return await this.client.validateAuthorizationCode(wX,z,null)}async refreshAccessToken(z){return await this.client.refreshAccessToken(wX,z,[])}}var IN="https://zoom.us/oauth/authorize",UX="https://zoom.us/oauth/token",xN="https://zoom.us/oauth/revoke";class l5{client;constructor(z,w,U){this.client=new y(z,w,U)}createAuthorizationURL(z,w,U){return this.client.createAuthorizationURLWithPKCE(IN,z,w0.S256,w,U)}async validateAuthorizationCode(z,w){return await this.client.validateAuthorizationCode(UX,z,w)}async refreshAccessToken(z){return await this.client.refreshAccessToken(UX,z,[])}async revokeToken(z){await this.client.revokeToken(xN,z)}}var VN="https://api.intra.42.fr/oauth/authorize",kN="https://api.intra.42.fr/oauth/token";class s5{clientId;clientSecret;redirectURI;constructor(z,w,U){this.clientId=z,this.clientSecret=w,this.redirectURI=U}createAuthorizationURL(z,w){let U=new URL(VN);if(U.searchParams.set("response_type","code"),U.searchParams.set("client_id",this.clientId),U.searchParams.set("state",z),w.length>0)U.searchParams.set("scope",w.join(" "));return U.searchParams.set("redirect_uri",this.redirectURI),U}async validateAuthorizationCode(z){let w=new URLSearchParams;w.set("grant_type","authorization_code"),w.set("code",z),w.set("redirect_uri",this.redirectURI),w.set("client_id",this.clientId),w.set("client_secret",this.clientSecret);let U=T(kN,w);return await i(U)}}function Jw(z){try{return RW(z)}catch(w){throw new Error("Invalid ID token",{cause:w})}}var U8={AmazonCognito:W5,AniList:X5,Apple:$5,Atlassian:A5,Auth0:Q5,Authentik:Y5,Bitbucket:J5,Box:B5,Coinbase:M5,Discord:q5,Dribbble:L5,Dropbox:G5,Facebook:N5,Figma:H5,Intuit:P5,GitHub:_5,GitLab:S5,Google:D5,Kakao:O5,KeyCloak:R5,Lichess:C5,Line:b5,Linear:K5,LinkedIn:j5,MicrosoftEntraId:F5,MyAnimeList:E5,Notion:I5,Okta:x5,Osu:V5,Patreon:k5,Reddit:T5,Roblox:g5,Salesforce:f5,Shikimori:d5,Slack:h5,Spotify:c5,Strava:i5,Tiltify:y5,Tumblr:v5,Twitch:n5,Twitter:u5,VK:m5,WorkOS:t5,Yahoo:o5,Yandex:p5,Zoom:l5,FortyTwo:s5},WX=Object.keys(U8).reduce((z,w)=>{return z[w.toLowerCase()]=w,z},{}),W8={AmazonCognito:"https://{region}.amazonaws.com/{userPoolId}/.well-known/openid-configuration",AniList:"https://graphql.anilist.co",Apple:"https://appleid.apple.com/auth/token",Atlassian:"https://api.atlassian.com/me",Auth0:"https://{your_domain}/userinfo",Authentik:"https://{your_domain}/api/v1/user/me",Bitbucket:"https://api.bitbucket.org/2.0/user",Box:"https://api.box.com/2.0/users/me",Coinbase:"https://api.coinbase.com/v2/user",Discord:"https://discord.com/api/users/@me",Dribbble:"https://api.dribbble.com/v2/user",Dropbox:"https://api.dropboxapi.com/2/users/get_current_account",Facebook:"https://graph.facebook.com/me",Figma:"https://api.figma.com/v1/me",Intuit:"https://accounts.platform.intuit.com/v1/openid_connect/userinfo",GitHub:"https://api.github.com/user",GitLab:"https://gitlab.com/api/v4/user",Google:"https://www.googleapis.com/userinfo/v2/me",Kakao:"https://kapi.kakao.com/v2/user/me",KeyCloak:"https://{your_domain}/auth/realms/{realm}/protocol/openid-connect/userinfo",Lichess:"https://lichess.org/api/account",Line:"https://api.line.me/v2/profile",Linear:"https://api.linear.app/v1/me",LinkedIn:"https://api.linkedin.com/v2/me",MicrosoftEntraId:"https://graph.microsoft.com/v1.0/me",MyAnimeList:"https://myanimelist.net/v1/users/@me",Notion:"https://api.notion.com/v1/users/me",Okta:"https://{yourOktaDomain}/oauth2/v1/userinfo",Osu:"https://osu.ppy.sh/api/v2/me",Patreon:"https://www.patreon.com/api/oauth2/v2/identity",Reddit:"https://oauth.reddit.com/api/v1/me",Roblox:"https://apis.roblox.com/users/v1/users/me",Salesforce:"https://login.salesforce.com/services/oauth2/userinfo",Shikimori:"https://shikimori.one/api/users/whoami",Slack:"https://slack.com/api/users.identity",Spotify:"https://api.spotify.com/v1/me",Strava:"https://www.strava.com/api/v3/athlete",Tiltify:"https://tiltify.com/api/v3/user",Tumblr:"https://api.tumblr.com/v2/user/info",Twitch:"https://api.twitch.tv/helix/users",Twitter:"https://api.twitter.com/2/users/me",VK:"https://api.vk.com/method/users.get",WorkOS:"https://api.workos.com/sso/profile",Yahoo:"https://api.login.yahoo.com/openid/v1/userinfo",Yandex:"https://login.yandex.ru/info",Zoom:"https://api.zoom.us/v2/users/me",FortyTwo:"https://api.intra.42.fr/v2/me"},XX={AmazonCognito:"https://cognito-idp.{region}.amazonaws.com/{userPoolId}",AniList:"https://anilist.co/api/v2/oauth/authorize",Apple:"https://appleid.apple.com",Atlassian:"https://auth.atlassian.com",Auth0:"https://{your_domain}.auth0.com",Authentik:"https://{your_domain}",Bitbucket:"https://bitbucket.org/site/oauth2/authorize",Box:"https://account.box.com/api/oauth2/authorize",Coinbase:"https://www.coinbase.com/oauth/authorize",Discord:"https://discord.com/api/oauth2/authorize",Dribbble:"https://dribbble.com/oauth/authorize",Dropbox:"https://www.dropbox.com/oauth2/authorize",Facebook:"https://www.facebook.com/v12.0/dialog/oauth",Figma:"https://www.figma.com/oauth",Intuit:"https://appcenter.intuit.com/connect/oauth2",GitHub:"https://github.com/login/oauth/authorize",GitLab:"https://gitlab.com/oauth/authorize",Google:"https://accounts.google.com",Kakao:"https://kauth.kakao.com/oauth/authorize",KeyCloak:"https://{your_domain}/auth",Lichess:"https://lichess.org/oauth/authorize",Line:"https://access.line.me/oauth2/v2.1/authorize",Linear:"https://linear.app/oauth/authorize",LinkedIn:"https://www.linkedin.com/oauth/v2/authorization",MicrosoftEntraId:"https://login.microsoftonline.com/{tenant}/v2.0",MyAnimeList:"https://myanimelist.net/v1/oauth2/authorize",Notion:"https://api.notion.com/v1/oauth/authorize",Okta:"https://{yourOktaDomain}/oauth2/default/v1/authorize",Osu:"https://osu.ppy.sh/oauth/authorize",Patreon:"https://www.patreon.com/oauth2/authorize",Reddit:"https://www.reddit.com/api/v1/authorize",Roblox:"https://apis.roblox.com/oauth/v1/authorize",Salesforce:"https://login.salesforce.com/services/oauth2/authorize",Shikimori:"https://shikimori.one/oauth/authorize",Slack:"https://slack.com/oauth/v2/authorize",Spotify:"https://accounts.spotify.com/authorize",Strava:"https://www.strava.com/oauth/authorize",Tiltify:"https://tiltify.com/oauth/authorize",Tumblr:"https://www.tumblr.com/oauth/authorize",Twitch:"https://id.twitch.tv/oauth2/authorize",Twitter:"https://api.twitter.com/oauth/authorize",VK:"https://oauth.vk.com/authorize",WorkOS:"https://api.workos.com/sso/authorize",Yahoo:"https://api.login.yahoo.com/oauth2/request_auth",Yandex:"https://oauth.yandex.com/authorize",Zoom:"https://zoom.us/oauth/authorize",FortyTwo:"https://api.intra.42.fr/oauth/authorize"},ZX=Object.keys(W8).reduce((z,w)=>{return z[w.toLowerCase()]=w,z},{}),Jf=Object.keys(XX).reduce((z,w)=>{return z[w.toLowerCase()]=w,z},{});var $X=({logoutRoute:z="logout",onLogout:w})=>{return new b0().post(`/${z}`,async({error:U,cookie:{user_session_id:W,auth_provider:X}})=>{if(X.value===void 0)return U(401,"No auth provider found");try{return w?.(),W.remove(),X.remove(),new Response("Succesfuly Logged Out",{status:204})}catch(Z){if(Z instanceof Error)console.error("Failed to refresh token:",Z.message);return U(500)}})};var AX=(z)=>{return"refreshAccessToken"in z&&typeof z.refreshAccessToken==="function"};var b6=(z)=>{return Object.keys(U8).map((w)=>w.toLowerCase()).includes(z.toLowerCase())},QX=(z)=>{return Object.keys(W8).includes(z)};var YX=(z)=>{return!0};var JX=({clientProviders:z,revokeRoute:w="revoke",onRevoke:U})=>{return new b0().post(`/${w}/access-token`,async({error:W,cookie:{user_refresh_token:X,auth_provider:Z}})=>{if(X.value===void 0)return W(401,"No refresh token found");if(Z.value===void 0)return W(401,"No auth provider found");if(!b6(Z.value))return W(400,"Invalid provider");let $=Z.value.toLowerCase(),{providerInstance:A}=z[$];U?.()})};var C4=()=>{return new b0({name:"sessionStore"}).state({session:{}})};var BX=({statusRoute:z="auth-status",onStatus:w})=>{return new b0().use(C4()).get(`/${z}`,async({error:U,cookie:{user_session_id:W,auth_provider:X},store:{session:Z}})=>{try{if(W.value===void 0)return new Response(JSON.stringify({user:null}),{headers:{"Content-Type":"application/json"}});if(X.value===void 0)return new Response(JSON.stringify({user:null}),{headers:{"Content-Type":"application/json"}});let $=Z[W.value];if($===void 0)return new Response(JSON.stringify({user:null}),{headers:{"Content-Type":"application/json"}});let A=$.user;return w?.(),new Response(JSON.stringify({user:A}),{headers:{"Content-Type":"application/json"}})}catch($){if($ instanceof Error)console.error("Failed to get auth status: ",$.message);return U(500)}})};var MX=({clientProviders:z,refreshRoute:w="refresh",onRefresh:U})=>{return new b0().post(`/${w}`,async({error:W,cookie:{user_refresh_token:X,auth_provider:Z}})=>{if(X.value===void 0)return W(401,"No refresh token found");if(Z.value===void 0)return W(401,"No auth provider found");let $=Z.value.toLowerCase(),{providerInstance:A}=z[$];if(!AX(A))return W(401,"Provider is not refreshable");try{let Q=await A.refreshAccessToken(X.value);return U?.(),new Response("Token refreshed",{status:204})}catch(Q){if(Q instanceof Error)console.error("Failed to refresh token:",Q.message);return W(500)}})};var qX=({clientProviders:z,authorizeRoute:w="authorize",onAuthorize:U})=>{return new b0().get(`/${w}/:provider`,({error:W,redirect:X,cookie:{state:Z,code_verifier:$,auth_provider:A,redirect_url:Q},params:{provider:Y},headers:J})=>{if(Y===void 0)return W(400,"Provider is required");if(!b6(Y))return W(400,"Invalid provider");try{let G=Y.toLowerCase(),{providerInstance:S,scopes:N,searchParams:O}=z[G],M=J.referer||"/";Q.set({value:M,secure:!0,sameSite:"lax",path:"/",httpOnly:!0,maxAge:600}),A.set({value:Y,secure:!0,sameSite:"lax",path:"/",httpOnly:!0,maxAge:600});let C=Aw();Z.set({value:C,secure:!0,sameSite:"lax",path:"/",httpOnly:!0,maxAge:600});let g,L0;if(S.createAuthorizationURL.toString().includes("codeVerifier"))L0=$w(),$.set({value:L0,secure:!0,sameSite:"lax",path:"/",httpOnly:!0,maxAge:600}),g=S.createAuthorizationURL(C,L0,N);else g=S.createAuthorizationURL(C,N);return O.forEach(([a,$0])=>{g.searchParams.set(a,$0)}),U?.(),X(g.toString())}catch(G){if(G instanceof Error)console.error("Failed to validate authorization code:",G.message);return W(500)}})};var LX=({clientProviders:z,callbackRoute:w="authorize/callback",onCallback:U,getUser:W,createUser:X})=>{return new b0().use(C4()).get(`/${w}`,async({error:Z,redirect:$,store:{session:A},cookie:{state:Q,code_verifier:Y,redirect_url:J,user_session_id:G,auth_provider:S},query:{code:N,state:O}})=>{if(!N||!Q.value)return Z(400,"Invalid callback request");if(O!==Q.value)return Z(400,"Invalid state mismatch");if(S.value===void 0)return Z(401,"No auth provider found");if(!b6(S.value))return Z(400,"Invalid provider");let M=S.value.toLowerCase(),{providerInstance:C}=z[M];try{let g;if(Q.remove(),C.validateAuthorizationCode.toString().includes("codeVerifier")){if(!Y.value)return Z(400,"Code verifier not found and is required");g=await C.validateAuthorizationCode(N,Y.value),Y.remove()}else g=await C.validateAuthorizationCode(N);let L0=Jw(g.idToken()),a=S.value,$0=await W?.({decodedIdToken:L0,authProvider:a});if($0===null||$0===void 0)$0=await X?.({decodedIdToken:L0,authProvider:a});let K0=crypto.randomUUID();if(!YX($0))return Z(500,"Invalid user schema");A[K0]={user:$0,expiresAt:Date.now()+86400000},G.set({value:K0,secure:!0,httpOnly:!0,sameSite:"lax"}),U?.();let f=J.value??"/";return $(f)}catch(g){if(g instanceof Error)console.error("Failed to validate authorization code:",g.message);return Z(500)}})};var GX=()=>{return new b0().use(C4()).derive(({store:{session:z},cookie:{user_session_id:w},error:U})=>{return{protectRoute:async(W,X)=>{if(w.value===void 0)return X?.()??U(401,"No session ID found");if(z[w.value]===void 0)return X?.()??U(401,"No session found");return W()}}}).as("plugin")};var rf=({config:z,authorizeRoute:w,callbackRoute:U,logoutRoute:W,statusRoute:X,refreshRoute:Z,revokeRoute:$,onAuthorize:A,onCallback:Q,onStatus:Y,onRefresh:J,onLogout:G,onRevoke:S,createUser:N,getUser:O})=>{let M=Object.entries(z).reduce((C,[g,L0={}])=>{let a=g.toLowerCase(),$0=WX[a],K0=ZX[a];if(!$0||!b6($0))return console.error(`Provider ${g} is not supported`),C;let f=U8[$0],V;if(QX(K0))V=W8[K0];let{credentials:k=[],scopes:j=[],searchParams:e=[]}=L0,Y0=new f(...k);return C[a]={providerInstance:Y0,scopes:j,searchParams:e,userInfoURL:V},C},{});return new b0().error("OAUTH2_REQUEST_ERROR",z8).error("ARCTIC_FETCH_ERROR",C6).use($X({logoutRoute:W,onLogout:G})).use(JX({clientProviders:M,revokeRoute:$,onRevoke:S})).use(BX({statusRoute:X,onStatus:Y})).use(MX({clientProviders:M,refreshRoute:Z,onRefresh:J})).use(qX({clientProviders:M,authorizeRoute:w,onAuthorize:A})).use(LX({clientProviders:M,callbackRoute:U,onCallback:Q,getUser:O,createUser:N})).use(GX()).as("plugin")};export{rf as absoluteAuth};