@absolutejs/auth 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +24 -0
- package/README.md +62 -0
- package/dist/authorize.d.ts +57 -0
- package/dist/callback.d.ts +49 -0
- package/dist/index.d.ts +138 -0
- package/dist/index.js +322 -0
- package/dist/logout.d.ts +43 -0
- package/dist/protectRoute.d.ts +27 -0
- package/dist/providers.d.ts +56 -0
- package/dist/refresh.d.ts +44 -0
- package/dist/revoke.d.ts +46 -0
- package/dist/sessionStore.d.ts +26 -0
- package/dist/status.d.ts +44 -0
- package/dist/typeGuards.d.ts +13 -0
- package/dist/types.d.ts +50 -0
- package/package.json +53 -0
package/dist/index.js
ADDED
|
@@ -0,0 +1,322 @@
|
|
|
1
|
+
var PW=Object.create;var{getPrototypeOf:OW,defineProperty:A5,getOwnPropertyNames:CW}=Object;var RW=Object.prototype.hasOwnProperty;var Ww=(w,z,A)=>{A=w!=null?PW(OW(w)):{};let U=z||!w||!w.__esModule?A5(A,"default",{value:w,enumerable:!0}):A;for(let W of CW(w))if(!RW.call(U,W))A5(U,W,{get:()=>w[W],enumerable:!0});return U};var Cz=(w,z)=>()=>(z||w((z={exports:{}}).exports,z),z.exports);var B6=(w,z)=>{for(var A in z)A5(w,A,{get:z[A],enumerable:!0,configurable:!0,set:(U)=>z[A]=()=>U})};var rA=Cz((sA)=>{Object.defineProperty(sA,"__esModule",{value:!0});sA.parse=EH;sA.serialize=IH;var CH=/^[\u0021-\u003A\u003C\u003E-\u007E]+$/,RH=/^[\u0021-\u003A\u003C-\u007E]*$/,KH=/^([.]?[a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?)([.][a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?)*$/i,jH=/^[\u0020-\u003A\u003D-\u007E]*$/,FH=Object.prototype.toString,xH=(()=>{let w=function(){};return w.prototype=Object.create(null),w})();function EH(w,z){let A=new xH,U=w.length;if(U<2)return A;let W=z?.decode||fH,$=0;do{let X=w.indexOf("=",$);if(X===-1)break;let Q=w.indexOf(";",$),Z=Q===-1?U:Q;if(X>Z){$=w.lastIndexOf(";",X-1)+1;continue}let J=pA(w,$,X),Y=lA(w,X,J),L=w.slice(J,Y);if(A[L]===void 0){let _=pA(w,X+1,Z),G=lA(w,Z,_),O=W(w.slice(_,G));A[L]=O}$=Z+1}while($<U);return A}function pA(w,z,A){do{let U=w.charCodeAt(z);if(U!==32&&U!==9)return z}while(++z<A);return A}function lA(w,z,A){while(z>A){let U=w.charCodeAt(--z);if(U!==32&&U!==9)return z+1}return A}function IH(w,z,A){let U=A?.encode||encodeURIComponent;if(!CH.test(w))throw new TypeError(`argument name is invalid: ${w}`);let W=U(z);if(!RH.test(W))throw new TypeError(`argument val is invalid: ${z}`);let $=w+"="+W;if(!A)return $;if(A.maxAge!==void 0){if(!Number.isInteger(A.maxAge))throw new TypeError(`option maxAge is invalid: ${A.maxAge}`);$+="; Max-Age="+A.maxAge}if(A.domain){if(!KH.test(A.domain))throw new TypeError(`option domain is invalid: ${A.domain}`);$+="; Domain="+A.domain}if(A.path){if(!jH.test(A.path))throw new TypeError(`option path is invalid: ${A.path}`);$+="; Path="+A.path}if(A.expires){if(!kH(A.expires)||!Number.isFinite(A.expires.valueOf()))throw new TypeError(`option expires is invalid: ${A.expires}`);$+="; Expires="+A.expires.toUTCString()}if(A.httpOnly)$+="; HttpOnly";if(A.secure)$+="; Secure";if(A.partitioned)$+="; Partitioned";if(A.priority)switch(typeof A.priority==="string"?A.priority.toLowerCase():void 0){case"low":$+="; Priority=Low";break;case"medium":$+="; Priority=Medium";break;case"high":$+="; Priority=High";break;default:throw new TypeError(`option priority is invalid: ${A.priority}`)}if(A.sameSite)switch(typeof A.sameSite==="string"?A.sameSite.toLowerCase():A.sameSite){case!0:case"strict":$+="; SameSite=Strict";break;case"lax":$+="; SameSite=Lax";break;case"none":$+="; SameSite=None";break;default:throw new TypeError(`option sameSite is invalid: ${A.sameSite}`)}return $}function fH(w){if(w.indexOf("%")===-1)return w;try{return decodeURIComponent(w)}catch(z){return w}}function kH(w){return FH.call(w)==="[object Date]"}});var ew=Cz((Ex,wU)=>{var aA=12,TH=0,Xz=[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 iH(w){var z=w.indexOf("%");if(z===-1)return w;var A=w.length,U="",W=0,$=0,X=z,Q=aA;while(z>-1&&z<A){var Z=eA(w[z+1],4),J=eA(w[z+2],0),Y=Z|J,L=Xz[Y];if(Q=Xz[256+Q+L],$=$<<6|Y&Xz[364+L],Q===aA)U+=w.slice(W,X),U+=$<=65535?String.fromCharCode($):String.fromCharCode(55232+($>>10),56320+($&1023)),$=0,W=z+3,z=X=w.indexOf("%",W);else if(Q===TH)return null;else{if(z+=3,z<A&&w.charCodeAt(z)===37)continue;return null}}return U+w.slice(W)}var dH={"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 eA(w,z){var A=dH[w];return A===void 0?255:A<<z}wU.exports=iH});var f6=(w,z)=>{let A=z?.length?{}:null;if(A)for(let U of z)A[U.part.charCodeAt(0)]=U;return{part:w,store:null,inert:A,params:null,wildcardStore:null}},Rz=(w,z)=>({...w,part:z}),Kz=(w)=>({name:w,store:null,inert:null}),$w=class w{root={};history=[];static regex={static:/:.+?(?=\/|$)/,params:/:.+?(?=\/|$)/g,optionalParams:/:.+?\?(?=\/|$)/g};add(z,A,U,{ignoreError:W=!1,ignoreHistory:$=!1}={}){if(typeof A!=="string")throw new TypeError("Route path must be a string");if(A==="")A="/";else if(A[0]!=="/")A=`/${A}`;let X=A[A.length-1]==="*",Q=A.match(w.regex.optionalParams);if(Q){let _=A.replaceAll("?","");this.add(z,_,U,{ignoreError:W});for(let G=0;G<Q.length;G++){let O=A.replace("/"+Q[G],"");this.add(z,O,U,{ignoreError:!0})}return U}if(Q)A=A.replaceAll("?","");if(this.history.find(([_,G,O])=>_===z&&G===A))return U;if(X||Q&&A.charCodeAt(A.length-1)===63)A=A.slice(0,-1);if(!$)this.history.push([z,A,U]);let Z=A.split(w.regex.static),J=A.match(w.regex.params)||[];if(Z[Z.length-1]==="")Z.pop();let Y;if(!this.root[z])Y=this.root[z]=f6("/");else Y=this.root[z];let L=0;for(let _=0;_<Z.length;++_){let G=Z[_];if(_>0){let O=J[L++].slice(1);if(Y.params===null)Y.params=Kz(O);else if(Y.params.name!==O)if(W)return U;else throw new Error(`Cannot create route "${A}" with parameter "${O}" because a route already exists with a different parameter name ("${Y.params.name}") in the same location`);let C=Y.params;if(C.inert===null){Y=C.inert=f6(G);continue}Y=C.inert}for(let O=0;;){if(O===G.length){if(O<Y.part.length){let C=Rz(Y,Y.part.slice(O));Object.assign(Y,f6(G,[C]))}break}if(O===Y.part.length){if(Y.inert===null)Y.inert={};let C=Y.inert[G.charCodeAt(O)];if(C){Y=C,G=G.slice(O),O=0;continue}let q=f6(G.slice(O));Y.inert[G.charCodeAt(O)]=q,Y=q;break}if(G[O]!==Y.part[O]){let C=Rz(Y,Y.part.slice(O)),q=f6(G.slice(O));Object.assign(Y,f6(Y.part.slice(0,O),[C,q])),Y=q;break}++O}}if(L<J.length){let G=J[L].slice(1);if(Y.params===null)Y.params=Kz(G);else if(Y.params.name!==G)if(W)return U;else throw new Error(`Cannot create route "${A}" 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(z,A){let U=this.root[z];if(!U)return null;return U5(A,A.length,U,0)}},U5=(w,z,A,U)=>{let W=A.part,$=W.length,X=U+$;if($>1){if(X>z)return null;if($<15){for(let Q=1,Z=U+1;Q<$;++Q,++Z)if(W.charCodeAt(Q)!==w.charCodeAt(Z))return null}else if(w.slice(U,X)!==W)return null}if(X===z){if(A.store!==null)return{store:A.store,params:{}};if(A.wildcardStore!==null)return{store:A.wildcardStore,params:{"*":""}};return null}if(A.inert!==null){let Q=A.inert[w.charCodeAt(X)];if(Q!==void 0){let Z=U5(w,z,Q,X);if(Z!==null)return Z}}if(A.params!==null){let{store:Q,name:Z,inert:J}=A.params,Y=w.indexOf("/",X);if(Y!==X){if(Y===-1||Y>=z){if(Q!==null){let L={};return L[Z]=w.substring(X,z),{store:Q,params:L}}}else if(J!==null){let L=U5(w,z,J,Y);if(L!==null)return L.params[Z]=w.substring(X,Y),L}}}if(A.wildcardStore!==null)return{store:A.wildcardStore,params:{"*":w.substring(X,z)}};return null};var N2={};B6(N2,{IsUndefined:()=>l0,IsUint8Array:()=>R1,IsSymbol:()=>Z5,IsString:()=>x0,IsRegExp:()=>N4,IsObject:()=>_0,IsNumber:()=>d2,IsNull:()=>Q5,IsIterator:()=>X5,IsFunction:()=>$5,IsDate:()=>M6,IsBoolean:()=>C1,IsBigInt:()=>b4,IsAsyncIterator:()=>W5,IsArray:()=>y0,HasPropertyKey:()=>Xw});function Xw(w,z){return z in w}function W5(w){return _0(w)&&!y0(w)&&!R1(w)&&Symbol.asyncIterator in w}function y0(w){return Array.isArray(w)}function b4(w){return typeof w==="bigint"}function C1(w){return typeof w==="boolean"}function M6(w){return w instanceof globalThis.Date}function $5(w){return typeof w==="function"}function X5(w){return _0(w)&&!y0(w)&&!R1(w)&&Symbol.iterator in w}function Q5(w){return w===null}function d2(w){return typeof w==="number"}function _0(w){return typeof w==="object"&&w!==null}function N4(w){return w instanceof globalThis.RegExp}function x0(w){return typeof w==="string"}function Z5(w){return typeof w==="symbol"}function R1(w){return w instanceof globalThis.Uint8Array}function l0(w){return w===void 0}function KW(w){return w.map((z)=>Qw(z))}function jW(w){return new Date(w.getTime())}function FW(w){return new Uint8Array(w)}function xW(w){return new RegExp(w.source,w.flags)}function EW(w){let z={};for(let A of Object.getOwnPropertyNames(w))z[A]=Qw(w[A]);for(let A of Object.getOwnPropertySymbols(w))z[A]=Qw(w[A]);return z}function Qw(w){return y0(w)?KW(w):M6(w)?jW(w):R1(w)?FW(w):N4(w)?xW(w):_0(w)?EW(w):w}function f0(w){return Qw(w)}function jz(w,z){return z===void 0?f0(w):f0({...z,...w})}function Zw(w){return r(w)&&Symbol.asyncIterator in w}function Jw(w){return r(w)&&Symbol.iterator in w}function J5(w){return r(w)&&(Object.getPrototypeOf(w)===Object.prototype||Object.getPrototypeOf(w)===null)}function Yw(w){return w instanceof Promise}function S2(w){return w instanceof Date&&Number.isFinite(w.getTime())}function Fz(w){return w instanceof globalThis.Map}function xz(w){return w instanceof globalThis.Set}function c2(w){return ArrayBuffer.isView(w)}function k6(w){return w instanceof globalThis.Uint8Array}function y(w,z){return z in w}function r(w){return w!==null&&typeof w==="object"}function v(w){return Array.isArray(w)&&!ArrayBuffer.isView(w)}function k0(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 qw(w){return Number.isInteger(w)}function U2(w){return typeof w==="bigint"}function Q0(w){return typeof w==="string"}function o1(w){return typeof w==="function"}function j1(w){return typeof w==="symbol"}function k2(w){return U2(w)||G1(w)||K1(w)||d(w)||Q0(w)||j1(w)||k0(w)}var I0;(function(w){w.InstanceMode="default",w.ExactOptionalPropertyTypes=!1,w.AllowArrayObject=!1,w.AllowNaN=!1,w.AllowNullVoid=!1;function z(X,Q){return w.ExactOptionalPropertyTypes?Q in X:X[Q]!==void 0}w.IsExactOptionalProperty=z;function A(X){let Q=r(X);return w.AllowArrayObject?Q:Q&&!v(X)}w.IsObjectLike=A;function U(X){return A(X)&&!(X instanceof Date)&&!(X instanceof Uint8Array)}w.IsRecordLike=U;function W(X){return w.AllowNaN?d(X):Number.isFinite(X)}w.IsNumberLike=W;function $(X){let Q=k0(X);return w.AllowNullVoid?Q||X===null:Q}w.IsVoidLike=$})(I0||(I0={}));function IW(w){return globalThis.Object.freeze(w).map((z)=>S4(z))}function fW(w){return w}function kW(w){return w}function VW(w){return w}function gW(w){let z={};for(let A of Object.getOwnPropertyNames(w))z[A]=S4(w[A]);for(let A of Object.getOwnPropertySymbols(w))z[A]=S4(w[A]);return globalThis.Object.freeze(z)}function S4(w){return y0(w)?IW(w):M6(w)?fW(w):R1(w)?kW(w):N4(w)?VW(w):_0(w)?gW(w):w}function D(w,z){let A=z!==void 0?{...z,...w}:w;switch(I0.InstanceMode){case"freeze":return S4(A);case"clone":return f0(A);default:return A}}class n extends Error{constructor(w){super(w)}}var j0=Symbol.for("TypeBox.Transform"),A1=Symbol.for("TypeBox.Readonly"),W2=Symbol.for("TypeBox.Optional"),n2=Symbol.for("TypeBox.Hint"),b=Symbol.for("TypeBox.Kind");function Bw(w){return _0(w)&&w[A1]==="Readonly"}function h2(w){return _0(w)&&w[W2]==="Optional"}function Y5(w){return Z0(w,"Any")}function F1(w){return Z0(w,"Array")}function D4(w){return Z0(w,"AsyncIterator")}function q5(w){return Z0(w,"BigInt")}function B5(w){return Z0(w,"Boolean")}function O2(w){return Z0(w,"Computed")}function _4(w){return Z0(w,"Constructor")}function TW(w){return Z0(w,"Date")}function P4(w){return Z0(w,"Function")}function H6(w){return Z0(w,"Integer")}function v0(w){return Z0(w,"Intersect")}function O4(w){return Z0(w,"Iterator")}function Z0(w,z){return _0(w)&&b in w&&w[b]===z}function Mw(w){return C1(w)||d2(w)||x0(w)}function x1(w){return Z0(w,"Literal")}function V2(w){return Z0(w,"MappedKey")}function V0(w){return Z0(w,"MappedResult")}function u1(w){return Z0(w,"Never")}function iW(w){return Z0(w,"Not")}function dW(w){return Z0(w,"Null")}function G6(w){return Z0(w,"Number")}function s0(w){return Z0(w,"Object")}function C4(w){return Z0(w,"Promise")}function M5(w){return Z0(w,"Record")}function d0(w){return Z0(w,"Ref")}function H5(w){return Z0(w,"RegExp")}function R4(w){return Z0(w,"String")}function cW(w){return Z0(w,"Symbol")}function g2(w){return Z0(w,"TemplateLiteral")}function nW(w){return Z0(w,"This")}function N0(w){return _0(w)&&j0 in w}function U1(w){return Z0(w,"Tuple")}function K4(w){return Z0(w,"Undefined")}function M0(w){return Z0(w,"Union")}function hW(w){return Z0(w,"Uint8Array")}function tW(w){return Z0(w,"Unknown")}function yW(w){return Z0(w,"Unsafe")}function vW(w){return Z0(w,"Void")}function m1(w){return _0(w)&&b in w&&x0(w[b])}function T0(w){return Y5(w)||F1(w)||B5(w)||q5(w)||D4(w)||O2(w)||_4(w)||TW(w)||P4(w)||H6(w)||v0(w)||O4(w)||x1(w)||V2(w)||V0(w)||u1(w)||iW(w)||dW(w)||G6(w)||s0(w)||C4(w)||M5(w)||d0(w)||H5(w)||R4(w)||cW(w)||g2(w)||nW(w)||U1(w)||K4(w)||M0(w)||hW(w)||tW(w)||yW(w)||vW(w)||m1(w)}var M={};B6(M,{TypeGuardUnknownTypeError:()=>Iz,IsVoid:()=>b9,IsUnsafe:()=>L9,IsUnknown:()=>G9,IsUnionLiteral:()=>eW,IsUnion:()=>b5,IsUndefined:()=>M9,IsUint8Array:()=>H9,IsTuple:()=>B9,IsTransform:()=>q9,IsThis:()=>Y9,IsTemplateLiteral:()=>J9,IsSymbol:()=>Z9,IsString:()=>Q9,IsSchema:()=>g0,IsRegExp:()=>X9,IsRef:()=>$9,IsRecursive:()=>aW,IsRecord:()=>W9,IsReadonly:()=>pW,IsProperties:()=>Hw,IsPromise:()=>U9,IsOptional:()=>lW,IsObject:()=>A9,IsNumber:()=>z9,IsNull:()=>w9,IsNot:()=>ez,IsNever:()=>az,IsMappedResult:()=>rz,IsMappedKey:()=>sz,IsLiteralValue:()=>lz,IsLiteralString:()=>mz,IsLiteralNumber:()=>pz,IsLiteralBoolean:()=>rW,IsLiteral:()=>F4,IsKindOf:()=>w0,IsKind:()=>N9,IsIterator:()=>uz,IsIntersect:()=>oz,IsInteger:()=>vz,IsImport:()=>sW,IsFunction:()=>yz,IsDate:()=>tz,IsConstructor:()=>hz,IsComputed:()=>nz,IsBoolean:()=>cz,IsBigInt:()=>dz,IsAsyncIterator:()=>iz,IsArray:()=>Tz,IsAny:()=>gz});class Iz extends n{}var oW=["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 fz(w){try{return new RegExp(w),!0}catch{return!1}}function G5(w){if(!x0(w))return!1;for(let z=0;z<w.length;z++){let A=w.charCodeAt(z);if(A>=7&&A<=13||A===27||A===127)return!1}return!0}function kz(w){return L5(w)||g0(w)}function j4(w){return l0(w)||b4(w)}function E0(w){return l0(w)||d2(w)}function L5(w){return l0(w)||C1(w)}function P0(w){return l0(w)||x0(w)}function uW(w){return l0(w)||x0(w)&&G5(w)&&fz(w)}function mW(w){return l0(w)||x0(w)&&G5(w)}function Vz(w){return l0(w)||g0(w)}function pW(w){return _0(w)&&w[A1]==="Readonly"}function lW(w){return _0(w)&&w[W2]==="Optional"}function gz(w){return w0(w,"Any")&&P0(w.$id)}function Tz(w){return w0(w,"Array")&&w.type==="array"&&P0(w.$id)&&g0(w.items)&&E0(w.minItems)&&E0(w.maxItems)&&L5(w.uniqueItems)&&Vz(w.contains)&&E0(w.minContains)&&E0(w.maxContains)}function iz(w){return w0(w,"AsyncIterator")&&w.type==="AsyncIterator"&&P0(w.$id)&&g0(w.items)}function dz(w){return w0(w,"BigInt")&&w.type==="bigint"&&P0(w.$id)&&j4(w.exclusiveMaximum)&&j4(w.exclusiveMinimum)&&j4(w.maximum)&&j4(w.minimum)&&j4(w.multipleOf)}function cz(w){return w0(w,"Boolean")&&w.type==="boolean"&&P0(w.$id)}function nz(w){return w0(w,"Computed")&&x0(w.target)&&y0(w.parameters)&&w.parameters.every((z)=>g0(z))}function hz(w){return w0(w,"Constructor")&&w.type==="Constructor"&&P0(w.$id)&&y0(w.parameters)&&w.parameters.every((z)=>g0(z))&&g0(w.returns)}function tz(w){return w0(w,"Date")&&w.type==="Date"&&P0(w.$id)&&E0(w.exclusiveMaximumTimestamp)&&E0(w.exclusiveMinimumTimestamp)&&E0(w.maximumTimestamp)&&E0(w.minimumTimestamp)&&E0(w.multipleOfTimestamp)}function yz(w){return w0(w,"Function")&&w.type==="Function"&&P0(w.$id)&&y0(w.parameters)&&w.parameters.every((z)=>g0(z))&&g0(w.returns)}function sW(w){return w0(w,"Import")&&Xw(w,"$defs")&&_0(w.$defs)&&Hw(w.$defs)&&Xw(w,"$ref")&&x0(w.$ref)&&w.$ref in w.$defs}function vz(w){return w0(w,"Integer")&&w.type==="integer"&&P0(w.$id)&&E0(w.exclusiveMaximum)&&E0(w.exclusiveMinimum)&&E0(w.maximum)&&E0(w.minimum)&&E0(w.multipleOf)}function Hw(w){return _0(w)&&Object.entries(w).every(([z,A])=>G5(z)&&g0(A))}function oz(w){return w0(w,"Intersect")&&(x0(w.type)&&w.type!=="object"?!1:!0)&&y0(w.allOf)&&w.allOf.every((z)=>g0(z)&&!q9(z))&&P0(w.type)&&(L5(w.unevaluatedProperties)||Vz(w.unevaluatedProperties))&&P0(w.$id)}function uz(w){return w0(w,"Iterator")&&w.type==="Iterator"&&P0(w.$id)&&g0(w.items)}function w0(w,z){return _0(w)&&b in w&&w[b]===z}function mz(w){return F4(w)&&x0(w.const)}function pz(w){return F4(w)&&d2(w.const)}function rW(w){return F4(w)&&C1(w.const)}function F4(w){return w0(w,"Literal")&&P0(w.$id)&&lz(w.const)}function lz(w){return C1(w)||d2(w)||x0(w)}function sz(w){return w0(w,"MappedKey")&&y0(w.keys)&&w.keys.every((z)=>d2(z)||x0(z))}function rz(w){return w0(w,"MappedResult")&&Hw(w.properties)}function az(w){return w0(w,"Never")&&_0(w.not)&&Object.getOwnPropertyNames(w.not).length===0}function ez(w){return w0(w,"Not")&&g0(w.not)}function w9(w){return w0(w,"Null")&&w.type==="null"&&P0(w.$id)}function z9(w){return w0(w,"Number")&&w.type==="number"&&P0(w.$id)&&E0(w.exclusiveMaximum)&&E0(w.exclusiveMinimum)&&E0(w.maximum)&&E0(w.minimum)&&E0(w.multipleOf)}function A9(w){return w0(w,"Object")&&w.type==="object"&&P0(w.$id)&&Hw(w.properties)&&kz(w.additionalProperties)&&E0(w.minProperties)&&E0(w.maxProperties)}function U9(w){return w0(w,"Promise")&&w.type==="Promise"&&P0(w.$id)&&g0(w.item)}function W9(w){return w0(w,"Record")&&w.type==="object"&&P0(w.$id)&&kz(w.additionalProperties)&&_0(w.patternProperties)&&((z)=>{let A=Object.getOwnPropertyNames(z.patternProperties);return A.length===1&&fz(A[0])&&_0(z.patternProperties)&&g0(z.patternProperties[A[0]])})(w)}function aW(w){return _0(w)&&n2 in w&&w[n2]==="Recursive"}function $9(w){return w0(w,"Ref")&&P0(w.$id)&&x0(w.$ref)}function X9(w){return w0(w,"RegExp")&&P0(w.$id)&&x0(w.source)&&x0(w.flags)&&E0(w.maxLength)&&E0(w.minLength)}function Q9(w){return w0(w,"String")&&w.type==="string"&&P0(w.$id)&&E0(w.minLength)&&E0(w.maxLength)&&uW(w.pattern)&&mW(w.format)}function Z9(w){return w0(w,"Symbol")&&w.type==="symbol"&&P0(w.$id)}function J9(w){return w0(w,"TemplateLiteral")&&w.type==="string"&&x0(w.pattern)&&w.pattern[0]==="^"&&w.pattern[w.pattern.length-1]==="$"}function Y9(w){return w0(w,"This")&&P0(w.$id)&&x0(w.$ref)}function q9(w){return _0(w)&&j0 in w}function B9(w){return w0(w,"Tuple")&&w.type==="array"&&P0(w.$id)&&d2(w.minItems)&&d2(w.maxItems)&&w.minItems===w.maxItems&&(l0(w.items)&&l0(w.additionalItems)&&w.minItems===0||y0(w.items)&&w.items.every((z)=>g0(z)))}function M9(w){return w0(w,"Undefined")&&w.type==="undefined"&&P0(w.$id)}function eW(w){return b5(w)&&w.anyOf.every((z)=>mz(z)||pz(z))}function b5(w){return w0(w,"Union")&&P0(w.$id)&&_0(w)&&y0(w.anyOf)&&w.anyOf.every((z)=>g0(z))}function H9(w){return w0(w,"Uint8Array")&&w.type==="Uint8Array"&&P0(w.$id)&&E0(w.minByteLength)&&E0(w.maxByteLength)}function G9(w){return w0(w,"Unknown")&&P0(w.$id)}function L9(w){return w0(w,"Unsafe")}function b9(w){return w0(w,"Void")&&w.type==="void"&&P0(w.$id)}function N9(w){return _0(w)&&b in w&&x0(w[b])&&!oW.includes(w[b])}function g0(w){return _0(w)&&(gz(w)||Tz(w)||cz(w)||dz(w)||iz(w)||nz(w)||hz(w)||tz(w)||yz(w)||vz(w)||oz(w)||uz(w)||F4(w)||sz(w)||rz(w)||az(w)||ez(w)||w9(w)||z9(w)||A9(w)||U9(w)||W9(w)||$9(w)||X9(w)||Q9(w)||Z9(w)||J9(w)||Y9(w)||B9(w)||M9(w)||b5(w)||H9(w)||G9(w)||L9(w)||b9(w)||N9(w))}var S9="(true|false)",Gw="(0|[1-9][0-9]*)",D9="(.*)";var E1="^(0|[1-9][0-9]*)$",I1="^(.*)$",_9="^(?!.*)$";var O0={};B6(O0,{Set:()=>W$,Has:()=>U$,Get:()=>$$,Entries:()=>w$,Delete:()=>A$,Clear:()=>z$});var V6=new Map;function w$(){return new Map(V6)}function z$(){return V6.clear()}function A$(w){return V6.delete(w)}function U$(w){return V6.has(w)}function W$(w,z){V6.set(w,z)}function $$(w){return V6.get(w)}var c0={};B6(c0,{Set:()=>Y$,Has:()=>J$,Get:()=>q$,Entries:()=>X$,Delete:()=>Z$,Clear:()=>Q$});var g6=new Map;function X$(){return new Map(g6)}function Q$(){return g6.clear()}function Z$(w){return g6.delete(w)}function J$(w){return g6.has(w)}function Y$(w,z){g6.set(w,z)}function q$(w){return g6.get(w)}function P9(w,z){return w.includes(z)}function O9(w){return[...new Set(w)]}function B$(w,z){return w.filter((A)=>z.includes(A))}function M$(w,z){return w.reduce((A,U)=>{return B$(A,U)},z)}function C9(w){return w.length===1?w[0]:w.length>1?M$(w.slice(1),w[0]):[]}function R9(w){let z=[];for(let A of w)z.push(...A);return z}function p1(w){return D({[b]:"Any"},w)}function T6(w,z){return D({[b]:"Array",type:"array",items:w},z)}function i6(w,z){return D({[b]:"AsyncIterator",type:"AsyncIterator",items:w},z)}function b0(w,z,A){return D({[b]:"Computed",target:w,parameters:z},A)}function H$(w,z){let{[z]:A,...U}=w;return U}function n0(w,z){return z.reduce((A,U)=>H$(A,U),w)}function H0(w){return D({[b]:"Never",not:{}},w)}function J0(w){return D({[b]:"MappedResult",properties:w})}function d6(w,z,A){return D({[b]:"Constructor",type:"Constructor",parameters:w,returns:z},A)}function L1(w,z,A){return D({[b]:"Function",type:"Function",parameters:w,returns:z},A)}function x4(w,z){return D({[b]:"Union",anyOf:w},z)}function G$(w){return w.some((z)=>h2(z))}function K9(w){return w.map((z)=>h2(z)?L$(z):z)}function L$(w){return n0(w,[W2])}function b$(w,z){return G$(w)?C2(x4(K9(w),z)):x4(K9(w),z)}function b1(w,z){return w.length===1?D(w[0],z):w.length===0?H0(z):b$(w,z)}function G0(w,z){return w.length===0?H0(z):w.length===1?D(w[0],z):x4(w,z)}class N5 extends n{}function N$(w){return w.replace(/\\\$/g,"$").replace(/\\\*/g,"*").replace(/\\\^/g,"^").replace(/\\\|/g,"|").replace(/\\\(/g,"(").replace(/\\\)/g,")")}function S5(w,z,A){return w[z]===A&&w.charCodeAt(z-1)!==92}function f1(w,z){return S5(w,z,"(")}function E4(w,z){return S5(w,z,")")}function j9(w,z){return S5(w,z,"|")}function S$(w){if(!(f1(w,0)&&E4(w,w.length-1)))return!1;let z=0;for(let A=0;A<w.length;A++){if(f1(w,A))z+=1;if(E4(w,A))z-=1;if(z===0&&A!==w.length-1)return!1}return!0}function D$(w){return w.slice(1,w.length-1)}function _$(w){let z=0;for(let A=0;A<w.length;A++){if(f1(w,A))z+=1;if(E4(w,A))z-=1;if(j9(w,A)&&z===0)return!0}return!1}function P$(w){for(let z=0;z<w.length;z++)if(f1(w,z))return!0;return!1}function O$(w){let[z,A]=[0,0],U=[];for(let $=0;$<w.length;$++){if(f1(w,$))z+=1;if(E4(w,$))z-=1;if(j9(w,$)&&z===0){let X=w.slice(A,$);if(X.length>0)U.push(c6(X));A=$+1}}let W=w.slice(A);if(W.length>0)U.push(c6(W));if(U.length===0)return{type:"const",const:""};if(U.length===1)return U[0];return{type:"or",expr:U}}function C$(w){function z(W,$){if(!f1(W,$))throw new N5("TemplateLiteralParser: Index must point to open parens");let X=0;for(let Q=$;Q<W.length;Q++){if(f1(W,Q))X+=1;if(E4(W,Q))X-=1;if(X===0)return[$,Q]}throw new N5("TemplateLiteralParser: Unclosed group parens in expression")}function A(W,$){for(let X=$;X<W.length;X++)if(f1(W,X))return[$,X];return[$,W.length]}let U=[];for(let W=0;W<w.length;W++)if(f1(w,W)){let[$,X]=z(w,W),Q=w.slice($,X+1);U.push(c6(Q)),W=X}else{let[$,X]=A(w,W),Q=w.slice($,X);if(Q.length>0)U.push(c6(Q));W=X-1}return U.length===0?{type:"const",const:""}:U.length===1?U[0]:{type:"and",expr:U}}function c6(w){return S$(w)?c6(D$(w)):_$(w)?O$(w):P$(w)?C$(w):{type:"const",const:N$(w)}}function n6(w){return c6(w.slice(1,w.length-1))}class F9 extends n{}function R$(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 K$(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 j$(w){return w.type==="const"&&w.const===".*"}function L6(w){return R$(w)||j$(w)?!1:K$(w)?!0:w.type==="and"?w.expr.every((z)=>L6(z)):w.type==="or"?w.expr.every((z)=>L6(z)):w.type==="const"?!0:(()=>{throw new F9("Unknown expression type")})()}function Lw(w){let z=n6(w.pattern);return L6(z)}class x9 extends n{}function*E9(w){if(w.length===1)return yield*w[0];for(let z of w[0])for(let A of E9(w.slice(1)))yield`${z}${A}`}function*F$(w){return yield*E9(w.expr.map((z)=>[...I4(z)]))}function*x$(w){for(let z of w.expr)yield*I4(z)}function*E$(w){return yield w.const}function*I4(w){return w.type==="and"?yield*F$(w):w.type==="or"?yield*x$(w):w.type==="const"?yield*E$(w):(()=>{throw new x9("Unknown expression")})()}function h6(w){let z=n6(w.pattern);return L6(z)?[...I4(z)]:[]}function X0(w,z){return D({[b]:"Literal",const:w,type:typeof w},z)}function bw(w){return D({[b]:"Boolean",type:"boolean"},w)}function t6(w){return D({[b]:"BigInt",type:"bigint"},w)}function N1(w){return D({[b]:"Number",type:"number"},w)}function t2(w){return D({[b]:"String",type:"string"},w)}function*I$(w){let z=w.trim().replace(/"|'/g,"");return z==="boolean"?yield bw():z==="number"?yield N1():z==="bigint"?yield t6():z==="string"?yield t2():yield(()=>{let A=z.split("|").map((U)=>X0(U.trim()));return A.length===0?H0():A.length===1?A[0]:b1(A)})()}function*f$(w){if(w[1]!=="{"){let z=X0("$"),A=D5(w.slice(1));return yield*[z,...A]}for(let z=2;z<w.length;z++)if(w[z]==="}"){let A=I$(w.slice(2,z)),U=D5(w.slice(z+1));return yield*[...A,...U]}yield X0(w)}function*D5(w){for(let z=0;z<w.length;z++)if(w[z]==="$"){let A=X0(w.slice(0,z)),U=f$(w.slice(z));return yield*[A,...U]}yield X0(w)}function I9(w){return[...D5(w)]}class f9 extends n{}function k$(w){return w.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function k9(w,z){return g2(w)?w.pattern.slice(1,w.pattern.length-1):M0(w)?`(${w.anyOf.map((A)=>k9(A,z)).join("|")})`:G6(w)?`${z}${Gw}`:H6(w)?`${z}${Gw}`:q5(w)?`${z}${Gw}`:R4(w)?`${z}${D9}`:x1(w)?`${z}${k$(w.const.toString())}`:B5(w)?`${z}${S9}`:(()=>{throw new f9(`Unexpected Kind '${w[b]}'`)})()}function _5(w){return`^${w.map((z)=>k9(z,"")).join("")}$`}function b6(w){let A=h6(w).map((U)=>X0(U));return b1(A)}function Nw(w,z){let A=x0(w)?_5(I9(w)):_5(w);return D({[b]:"TemplateLiteral",type:"string",pattern:A},z)}function V$(w){return h6(w).map((A)=>A.toString())}function g$(w){let z=[];for(let A of w)z.push(...R2(A));return z}function T$(w){return[w.toString()]}function R2(w){return[...new Set(g2(w)?V$(w):M0(w)?g$(w.anyOf):x1(w)?T$(w.const):G6(w)?["[number]"]:H6(w)?["[number]"]:[])]}function i$(w,z,A){let U={};for(let W of Object.getOwnPropertyNames(z))U[W]=l1(w,R2(z[W]),A);return U}function d$(w,z,A){return i$(w,z.properties,A)}function V9(w,z,A){let U=d$(w,z,A);return J0(U)}function T9(w,z){return w.map((A)=>i9(A,z))}function c$(w){return w.filter((z)=>!u1(z))}function n$(w,z){return Sw(c$(T9(w,z)))}function h$(w){return w.some((z)=>u1(z))?[]:w}function t$(w,z){return b1(h$(T9(w,z)))}function y$(w,z){return z in w?w[z]:z==="[number]"?b1(w):H0()}function v$(w,z){return z==="[number]"?w:H0()}function o$(w,z){return z in w?w[z]:H0()}function i9(w,z){return v0(w)?n$(w.allOf,z):M0(w)?t$(w.anyOf,z):U1(w)?y$(w.items??[],z):F1(w)?v$(w.items,z):s0(w)?o$(w.properties,z):H0()}function f4(w,z){return z.map((A)=>i9(w,A))}function g9(w,z){return b1(f4(w,z))}function l1(w,z,A){if(d0(w)||d0(z)){if(!T0(w)||!T0(z))throw new n("Index types using Ref parameters require both Type and Key to be of TSchema");return b0("Index",[w,z])}if(V0(z))return V9(w,z,A);if(V2(z))return d9(w,z,A);return D(T0(z)?g9(w,R2(z)):g9(w,z),A)}function u$(w,z,A){return{[z]:l1(w,[z],f0(A))}}function m$(w,z,A){return z.reduce((U,W)=>{return{...U,...u$(w,W,A)}},{})}function p$(w,z,A){return m$(w,z.keys,A)}function d9(w,z,A){let U=p$(w,z,A);return J0(U)}function y6(w,z){return D({[b]:"Iterator",type:"Iterator",items:w},z)}function l$(w){let z=[];for(let A in w)if(!h2(w[A]))z.push(A);return z}function s$(w,z){let A=l$(w),U=A.length>0?{[b]:"Object",type:"object",properties:w,required:A}:{[b]:"Object",type:"object",properties:w};return D(U,z)}var S0=s$;function Dw(w,z){return D({[b]:"Promise",type:"Promise",item:w},z)}function r$(w){return D(n0(w,[A1]))}function a$(w){return D({...w,[A1]:"Readonly"})}function e$(w,z){return z===!1?r$(w):a$(w)}function y2(w,z){let A=z??!0;return V0(w)?c9(w,A):e$(w,A)}function wX(w,z){let A={};for(let U of globalThis.Object.getOwnPropertyNames(w))A[U]=y2(w[U],z);return A}function zX(w,z){return wX(w.properties,z)}function c9(w,z){let A=zX(w,z);return J0(A)}function v2(w,z){return D(w.length>0?{[b]:"Tuple",type:"array",items:w,additionalItems:!1,minItems:w.length,maxItems:w.length}:{[b]:"Tuple",type:"array",minItems:w.length,maxItems:w.length},z)}function n9(w,z){return w in z?o2(w,z[w]):J0(z)}function AX(w){return{[w]:X0(w)}}function UX(w){let z={};for(let A of w)z[A]=X0(A);return z}function WX(w,z){return P9(z,w)?AX(w):UX(z)}function $X(w,z){let A=WX(w,z);return n9(w,A)}function k4(w,z){return z.map((A)=>o2(w,A))}function XX(w,z){let A={};for(let U of globalThis.Object.getOwnPropertyNames(z))A[U]=o2(w,z[U]);return A}function o2(w,z){let A={...z};return h2(z)?C2(o2(w,n0(z,[W2]))):Bw(z)?y2(o2(w,n0(z,[A1]))):V0(z)?n9(w,z.properties):V2(z)?$X(w,z.keys):_4(z)?d6(k4(w,z.parameters),o2(w,z.returns),A):P4(z)?L1(k4(w,z.parameters),o2(w,z.returns),A):D4(z)?i6(o2(w,z.items),A):O4(z)?y6(o2(w,z.items),A):v0(z)?Z2(k4(w,z.allOf),A):M0(z)?G0(k4(w,z.anyOf),A):U1(z)?v2(k4(w,z.items??[]),A):s0(z)?S0(XX(w,z.properties),A):F1(z)?T6(o2(w,z.items),A):C4(z)?Dw(o2(w,z.item),A):z}function QX(w,z){let A={};for(let U of w)A[U]=o2(U,z);return A}function h9(w,z,A){let U=T0(w)?R2(w):w,W=z({[b]:"MappedKey",keys:U}),$=QX(U,W);return S0($,A)}function ZX(w){return D(n0(w,[W2]))}function JX(w){return D({...w,[W2]:"Optional"})}function YX(w,z){return z===!1?ZX(w):JX(w)}function C2(w,z){let A=z??!0;return V0(w)?t9(w,A):YX(w,A)}function qX(w,z){let A={};for(let U of globalThis.Object.getOwnPropertyNames(w))A[U]=C2(w[U],z);return A}function BX(w,z){return qX(w.properties,z)}function t9(w,z){let A=BX(w,z);return J0(A)}function V4(w,z={}){let A=w.every((W)=>s0(W)),U=T0(z.unevaluatedProperties)?{unevaluatedProperties:z.unevaluatedProperties}:{};return D(z.unevaluatedProperties===!1||T0(z.unevaluatedProperties)||A?{...U,[b]:"Intersect",type:"object",allOf:w}:{...U,[b]:"Intersect",allOf:w},z)}function MX(w){return w.every((z)=>h2(z))}function HX(w){return n0(w,[W2])}function y9(w){return w.map((z)=>h2(z)?HX(z):z)}function GX(w,z){return MX(w)?C2(V4(y9(w),z)):V4(y9(w),z)}function Sw(w,z={}){if(w.length===1)return D(w[0],z);if(w.length===0)return H0(z);if(w.some((A)=>N0(A)))throw new Error("Cannot intersect transform types");return GX(w,z)}function Z2(w,z){if(w.length===1)return D(w[0],z);if(w.length===0)return H0(z);if(w.some((A)=>N0(A)))throw new Error("Cannot intersect transform types");return V4(w,z)}function K2(...w){let[z,A]=typeof w[0]==="string"?[w[0],w[1]]:[w[0].$id,w[1]];if(typeof z!=="string")throw new n("Ref: $ref must be a string");return D({[b]:"Ref",$ref:z},A)}function LX(w,z){return b0("Awaited",[b0(w,z)])}function bX(w){return b0("Awaited",[K2(w)])}function NX(w){return Z2(v9(w))}function SX(w){return G0(v9(w))}function DX(w){return v6(w)}function v9(w){return w.map((z)=>v6(z))}function v6(w,z){return D(O2(w)?LX(w.target,w.parameters):v0(w)?NX(w.allOf):M0(w)?SX(w.anyOf):C4(w)?DX(w.item):d0(w)?bX(w.$ref):w,z)}function o9(w){let z=[];for(let A of w)z.push(j2(A));return z}function _X(w){let z=o9(w);return R9(z)}function PX(w){let z=o9(w);return C9(z)}function OX(w){return w.map((z,A)=>A.toString())}function CX(w){return["[number]"]}function RX(w){return globalThis.Object.getOwnPropertyNames(w)}function KX(w){if(!P5)return[];return globalThis.Object.getOwnPropertyNames(w).map((A)=>{return A[0]==="^"&&A[A.length-1]==="$"?A.slice(1,A.length-1):A})}function j2(w){return v0(w)?_X(w.allOf):M0(w)?PX(w.anyOf):U1(w)?OX(w.items??[]):F1(w)?CX(w.items):s0(w)?RX(w.properties):M5(w)?KX(w.patternProperties):[]}var P5=!1;function k1(w){P5=!0;let z=j2(w);return P5=!1,`^(${z.map((U)=>`(${U})`).join("|")})$`}function jX(w,z){return b0("KeyOf",[b0(w,z)])}function FX(w){return b0("KeyOf",[K2(w)])}function xX(w,z){let A=j2(w),U=EX(A),W=b1(U);return D(W,z)}function EX(w){return w.map((z)=>z==="[number]"?N1():X0(z))}function o6(w,z){return O2(w)?jX(w.target,w.parameters):d0(w)?FX(w.$ref):V0(w)?u9(w,z):xX(w,z)}function IX(w,z){let A={};for(let U of globalThis.Object.getOwnPropertyNames(w))A[U]=o6(w[U],f0(z));return A}function fX(w,z){return IX(w.properties,z)}function u9(w,z){let A=fX(w,z);return J0(A)}function _w(w){let z=j2(w),A=f4(w,z);return z.map((U,W)=>[z[W],A[W]])}function kX(w){let z=[];for(let A of w)z.push(...j2(A));return O9(z)}function VX(w){return w.filter((z)=>!u1(z))}function gX(w,z){let A=[];for(let U of w)A.push(...f4(U,[z]));return VX(A)}function TX(w,z){let A={};for(let U of z)A[U]=Sw(gX(w,U));return A}function m9(w,z){let A=kX(w),U=TX(w,A);return S0(U,z)}function Pw(w){return D({[b]:"Date",type:"Date"},w)}function Ow(w){return D({[b]:"Null",type:"null"},w)}function Cw(w){return D({[b]:"Symbol",type:"symbol"},w)}function Rw(w){return D({[b]:"Undefined",type:"undefined"},w)}function Kw(w){return D({[b]:"Uint8Array",type:"Uint8Array"},w)}function V1(w){return D({[b]:"Unknown"},w)}function iX(w){return w.map((z)=>O5(z,!1))}function dX(w){let z={};for(let A of globalThis.Object.getOwnPropertyNames(w))z[A]=y2(O5(w[A],!1));return z}function jw(w,z){return z===!0?w:y2(w)}function O5(w,z){return W5(w)?jw(p1(),z):X5(w)?jw(p1(),z):y0(w)?y2(v2(iX(w))):R1(w)?Kw():M6(w)?Pw():_0(w)?jw(S0(dX(w)),z):$5(w)?jw(L1([],V1()),z):l0(w)?Rw():Q5(w)?Ow():Z5(w)?Cw():b4(w)?t6():d2(w)?X0(w):C1(w)?X0(w):x0(w)?X0(w):S0({})}function p9(w,z){return D(O5(w,!0),z)}function l9(w,z){return v2(w.parameters,z)}function s9(w,z){if(l0(w))throw new Error("Enum undefined or empty");let A=globalThis.Object.getOwnPropertyNames(w).filter(($)=>isNaN($)).map(($)=>w[$]),W=[...new Set(A)].map(($)=>X0($));return G0(W,{...z,[n2]:"Enum"})}class z7 extends n{}var S;(function(w){w[w.Union=0]="Union",w[w.True=1]="True",w[w.False=2]="False"})(S||(S={}));function u2(w){return w===S.False?w:S.True}function u6(w){throw new z7(w)}function o0(w){return M.IsNever(w)||M.IsIntersect(w)||M.IsUnion(w)||M.IsUnknown(w)||M.IsAny(w)}function u0(w,z){return M.IsNever(z)?W7(w,z):M.IsIntersect(z)?Fw(w,z):M.IsUnion(z)?F5(w,z):M.IsUnknown(z)?Z7(w,z):M.IsAny(z)?j5(w,z):u6("StructuralRight")}function j5(w,z){return S.True}function cX(w,z){return M.IsIntersect(z)?Fw(w,z):M.IsUnion(z)&&z.anyOf.some((A)=>M.IsAny(A)||M.IsUnknown(A))?S.True:M.IsUnion(z)?S.Union:M.IsUnknown(z)?S.True:M.IsAny(z)?S.True:S.Union}function nX(w,z){return M.IsUnknown(w)?S.False:M.IsAny(w)?S.Union:M.IsNever(w)?S.True:S.False}function hX(w,z){return M.IsObject(z)&&xw(z)?S.True:o0(z)?u0(w,z):!M.IsArray(z)?S.False:u2(C0(w.items,z.items))}function tX(w,z){return o0(z)?u0(w,z):!M.IsAsyncIterator(z)?S.False:u2(C0(w.items,z.items))}function yX(w,z){return o0(z)?u0(w,z):M.IsObject(z)?J2(w,z):M.IsRecord(z)?m2(w,z):M.IsBigInt(z)?S.True:S.False}function A7(w,z){return M.IsLiteralBoolean(w)?S.True:M.IsBoolean(w)?S.True:S.False}function vX(w,z){return o0(z)?u0(w,z):M.IsObject(z)?J2(w,z):M.IsRecord(z)?m2(w,z):M.IsBoolean(z)?S.True:S.False}function oX(w,z){return o0(z)?u0(w,z):M.IsObject(z)?J2(w,z):!M.IsConstructor(z)?S.False:w.parameters.length>z.parameters.length?S.False:!w.parameters.every((A,U)=>u2(C0(z.parameters[U],A))===S.True)?S.False:u2(C0(w.returns,z.returns))}function uX(w,z){return o0(z)?u0(w,z):M.IsObject(z)?J2(w,z):M.IsRecord(z)?m2(w,z):M.IsDate(z)?S.True:S.False}function mX(w,z){return o0(z)?u0(w,z):M.IsObject(z)?J2(w,z):!M.IsFunction(z)?S.False:w.parameters.length>z.parameters.length?S.False:!w.parameters.every((A,U)=>u2(C0(z.parameters[U],A))===S.True)?S.False:u2(C0(w.returns,z.returns))}function U7(w,z){return M.IsLiteral(w)&&N2.IsNumber(w.const)?S.True:M.IsNumber(w)||M.IsInteger(w)?S.True:S.False}function pX(w,z){return M.IsInteger(z)||M.IsNumber(z)?S.True:o0(z)?u0(w,z):M.IsObject(z)?J2(w,z):M.IsRecord(z)?m2(w,z):S.False}function Fw(w,z){return z.allOf.every((A)=>C0(w,A)===S.True)?S.True:S.False}function lX(w,z){return w.allOf.some((A)=>C0(A,z)===S.True)?S.True:S.False}function sX(w,z){return o0(z)?u0(w,z):!M.IsIterator(z)?S.False:u2(C0(w.items,z.items))}function rX(w,z){return M.IsLiteral(z)&&z.const===w.const?S.True:o0(z)?u0(w,z):M.IsObject(z)?J2(w,z):M.IsRecord(z)?m2(w,z):M.IsString(z)?Q7(w,z):M.IsNumber(z)?$7(w,z):M.IsInteger(z)?U7(w,z):M.IsBoolean(z)?A7(w,z):S.False}function W7(w,z){return S.False}function aX(w,z){return S.True}function r9(w){let[z,A]=[w,0];while(!0){if(!M.IsNot(z))break;z=z.not,A+=1}return A%2===0?z:V1()}function eX(w,z){return M.IsNot(w)?C0(r9(w),z):M.IsNot(z)?C0(w,r9(z)):u6("Invalid fallthrough for Not")}function wQ(w,z){return o0(z)?u0(w,z):M.IsObject(z)?J2(w,z):M.IsRecord(z)?m2(w,z):M.IsNull(z)?S.True:S.False}function $7(w,z){return M.IsLiteralNumber(w)?S.True:M.IsNumber(w)||M.IsInteger(w)?S.True:S.False}function zQ(w,z){return o0(z)?u0(w,z):M.IsObject(z)?J2(w,z):M.IsRecord(z)?m2(w,z):M.IsInteger(z)||M.IsNumber(z)?S.True:S.False}function F2(w,z){return Object.getOwnPropertyNames(w.properties).length===z}function a9(w){return xw(w)}function e9(w){return F2(w,0)||F2(w,1)&&"description"in w.properties&&M.IsUnion(w.properties.description)&&w.properties.description.anyOf.length===2&&(M.IsString(w.properties.description.anyOf[0])&&M.IsUndefined(w.properties.description.anyOf[1])||M.IsString(w.properties.description.anyOf[1])&&M.IsUndefined(w.properties.description.anyOf[0]))}function C5(w){return F2(w,0)}function w7(w){return F2(w,0)}function AQ(w){return F2(w,0)}function UQ(w){return F2(w,0)}function WQ(w){return xw(w)}function $Q(w){let z=N1();return F2(w,0)||F2(w,1)&&"length"in w.properties&&u2(C0(w.properties.length,z))===S.True}function XQ(w){return F2(w,0)}function xw(w){let z=N1();return F2(w,0)||F2(w,1)&&"length"in w.properties&&u2(C0(w.properties.length,z))===S.True}function QQ(w){let z=L1([p1()],p1());return F2(w,0)||F2(w,1)&&"then"in w.properties&&u2(C0(w.properties.then,z))===S.True}function X7(w,z){return C0(w,z)===S.False?S.False:M.IsOptional(w)&&!M.IsOptional(z)?S.False:S.True}function J2(w,z){return M.IsUnknown(w)?S.False:M.IsAny(w)?S.Union:M.IsNever(w)||M.IsLiteralString(w)&&a9(z)||M.IsLiteralNumber(w)&&C5(z)||M.IsLiteralBoolean(w)&&w7(z)||M.IsSymbol(w)&&e9(z)||M.IsBigInt(w)&&AQ(z)||M.IsString(w)&&a9(z)||M.IsSymbol(w)&&e9(z)||M.IsNumber(w)&&C5(z)||M.IsInteger(w)&&C5(z)||M.IsBoolean(w)&&w7(z)||M.IsUint8Array(w)&&WQ(z)||M.IsDate(w)&&UQ(z)||M.IsConstructor(w)&&XQ(z)||M.IsFunction(w)&&$Q(z)?S.True:M.IsRecord(w)&&M.IsString(R5(w))?(()=>{return z[n2]==="Record"?S.True:S.False})():M.IsRecord(w)&&M.IsNumber(R5(w))?(()=>{return F2(z,0)?S.True:S.False})():S.False}function ZQ(w,z){return o0(z)?u0(w,z):M.IsRecord(z)?m2(w,z):!M.IsObject(z)?S.False:(()=>{for(let A of Object.getOwnPropertyNames(z.properties)){if(!(A in w.properties)&&!M.IsOptional(z.properties[A]))return S.False;if(M.IsOptional(z.properties[A]))return S.True;if(X7(w.properties[A],z.properties[A])===S.False)return S.False}return S.True})()}function JQ(w,z){return o0(z)?u0(w,z):M.IsObject(z)&&QQ(z)?S.True:!M.IsPromise(z)?S.False:u2(C0(w.item,z.item))}function R5(w){return E1 in w.patternProperties?N1():(I1 in w.patternProperties)?t2():u6("Unknown record key pattern")}function K5(w){return E1 in w.patternProperties?w.patternProperties[E1]:(I1 in w.patternProperties)?w.patternProperties[I1]:u6("Unable to get record value schema")}function m2(w,z){let[A,U]=[R5(z),K5(z)];return M.IsLiteralString(w)&&M.IsNumber(A)&&u2(C0(w,U))===S.True?S.True:M.IsUint8Array(w)&&M.IsNumber(A)?C0(w,U):M.IsString(w)&&M.IsNumber(A)?C0(w,U):M.IsArray(w)&&M.IsNumber(A)?C0(w,U):M.IsObject(w)?(()=>{for(let W of Object.getOwnPropertyNames(w.properties))if(X7(U,w.properties[W])===S.False)return S.False;return S.True})():S.False}function YQ(w,z){return o0(z)?u0(w,z):M.IsObject(z)?J2(w,z):!M.IsRecord(z)?S.False:C0(K5(w),K5(z))}function qQ(w,z){let A=M.IsRegExp(w)?t2():w,U=M.IsRegExp(z)?t2():z;return C0(A,U)}function Q7(w,z){return M.IsLiteral(w)&&N2.IsString(w.const)?S.True:M.IsString(w)?S.True:S.False}function BQ(w,z){return o0(z)?u0(w,z):M.IsObject(z)?J2(w,z):M.IsRecord(z)?m2(w,z):M.IsString(z)?S.True:S.False}function MQ(w,z){return o0(z)?u0(w,z):M.IsObject(z)?J2(w,z):M.IsRecord(z)?m2(w,z):M.IsSymbol(z)?S.True:S.False}function HQ(w,z){return M.IsTemplateLiteral(w)?C0(b6(w),z):M.IsTemplateLiteral(z)?C0(w,b6(z)):u6("Invalid fallthrough for TemplateLiteral")}function GQ(w,z){return M.IsArray(z)&&w.items!==void 0&&w.items.every((A)=>C0(A,z.items)===S.True)}function LQ(w,z){return M.IsNever(w)?S.True:M.IsUnknown(w)?S.False:M.IsAny(w)?S.Union:S.False}function bQ(w,z){return o0(z)?u0(w,z):M.IsObject(z)&&xw(z)?S.True:M.IsArray(z)&&GQ(w,z)?S.True:!M.IsTuple(z)?S.False:N2.IsUndefined(w.items)&&!N2.IsUndefined(z.items)||!N2.IsUndefined(w.items)&&N2.IsUndefined(z.items)?S.False:N2.IsUndefined(w.items)&&!N2.IsUndefined(z.items)?S.True:w.items.every((A,U)=>C0(A,z.items[U])===S.True)?S.True:S.False}function NQ(w,z){return o0(z)?u0(w,z):M.IsObject(z)?J2(w,z):M.IsRecord(z)?m2(w,z):M.IsUint8Array(z)?S.True:S.False}function SQ(w,z){return o0(z)?u0(w,z):M.IsObject(z)?J2(w,z):M.IsRecord(z)?m2(w,z):M.IsVoid(z)?PQ(w,z):M.IsUndefined(z)?S.True:S.False}function F5(w,z){return z.anyOf.some((A)=>C0(w,A)===S.True)?S.True:S.False}function DQ(w,z){return w.anyOf.every((A)=>C0(A,z)===S.True)?S.True:S.False}function Z7(w,z){return S.True}function _Q(w,z){return M.IsNever(z)?W7(w,z):M.IsIntersect(z)?Fw(w,z):M.IsUnion(z)?F5(w,z):M.IsAny(z)?j5(w,z):M.IsString(z)?Q7(w,z):M.IsNumber(z)?$7(w,z):M.IsInteger(z)?U7(w,z):M.IsBoolean(z)?A7(w,z):M.IsArray(z)?nX(w,z):M.IsTuple(z)?LQ(w,z):M.IsObject(z)?J2(w,z):M.IsUnknown(z)?S.True:S.False}function PQ(w,z){return M.IsUndefined(w)?S.True:M.IsUndefined(w)?S.True:S.False}function OQ(w,z){return M.IsIntersect(z)?Fw(w,z):M.IsUnion(z)?F5(w,z):M.IsUnknown(z)?Z7(w,z):M.IsAny(z)?j5(w,z):M.IsObject(z)?J2(w,z):M.IsVoid(z)?S.True:S.False}function C0(w,z){return M.IsTemplateLiteral(w)||M.IsTemplateLiteral(z)?HQ(w,z):M.IsRegExp(w)||M.IsRegExp(z)?qQ(w,z):M.IsNot(w)||M.IsNot(z)?eX(w,z):M.IsAny(w)?cX(w,z):M.IsArray(w)?hX(w,z):M.IsBigInt(w)?yX(w,z):M.IsBoolean(w)?vX(w,z):M.IsAsyncIterator(w)?tX(w,z):M.IsConstructor(w)?oX(w,z):M.IsDate(w)?uX(w,z):M.IsFunction(w)?mX(w,z):M.IsInteger(w)?pX(w,z):M.IsIntersect(w)?lX(w,z):M.IsIterator(w)?sX(w,z):M.IsLiteral(w)?rX(w,z):M.IsNever(w)?aX(w,z):M.IsNull(w)?wQ(w,z):M.IsNumber(w)?zQ(w,z):M.IsObject(w)?ZQ(w,z):M.IsRecord(w)?YQ(w,z):M.IsString(w)?BQ(w,z):M.IsSymbol(w)?MQ(w,z):M.IsTuple(w)?bQ(w,z):M.IsPromise(w)?JQ(w,z):M.IsUint8Array(w)?NQ(w,z):M.IsUndefined(w)?SQ(w,z):M.IsUnion(w)?DQ(w,z):M.IsUnknown(w)?_Q(w,z):M.IsVoid(w)?OQ(w,z):u6(`Unknown left type operand '${w[b]}'`)}function s1(w,z){return C0(w,z)}function CQ(w,z,A,U,W){let $={};for(let X of globalThis.Object.getOwnPropertyNames(w))$[X]=m6(w[X],z,A,U,f0(W));return $}function RQ(w,z,A,U,W){return CQ(w.properties,z,A,U,W)}function J7(w,z,A,U,W){let $=RQ(w,z,A,U,W);return J0($)}function KQ(w,z,A,U){let W=s1(w,z);return W===S.Union?G0([A,U]):W===S.True?A:U}function m6(w,z,A,U,W){return V0(w)?J7(w,z,A,U,W):V2(w)?D(Y7(w,z,A,U,W)):D(KQ(w,z,A,U),W)}function jQ(w,z,A,U,W){return{[w]:m6(X0(w),z,A,U,f0(W))}}function FQ(w,z,A,U,W){return w.reduce(($,X)=>{return{...$,...jQ(X,z,A,U,W)}},{})}function xQ(w,z,A,U,W){return FQ(w.keys,z,A,U,W)}function Y7(w,z,A,U,W){let $=xQ(w,z,A,U,W);return J0($)}function EQ(w){return w.allOf.every((z)=>g1(z))}function IQ(w){return w.anyOf.some((z)=>g1(z))}function fQ(w){return!g1(w.not)}function g1(w){return w[b]==="Intersect"?EQ(w):w[b]==="Union"?IQ(w):w[b]==="Not"?fQ(w):w[b]==="Undefined"?!0:!1}function q7(w,z){return p6(b6(w),z)}function kQ(w,z){let A=w.filter((U)=>s1(U,z)===S.False);return A.length===1?A[0]:G0(A)}function p6(w,z,A={}){if(g2(w))return D(q7(w,z),A);if(V0(w))return D(B7(w,z),A);return D(M0(w)?kQ(w.anyOf,z):s1(w,z)!==S.False?H0():w,A)}function VQ(w,z){let A={};for(let U of globalThis.Object.getOwnPropertyNames(w))A[U]=p6(w[U],z);return A}function gQ(w,z){return VQ(w.properties,z)}function B7(w,z){let A=gQ(w,z);return J0(A)}function M7(w,z){return l6(b6(w),z)}function TQ(w,z){let A=w.filter((U)=>s1(U,z)!==S.False);return A.length===1?A[0]:G0(A)}function l6(w,z,A){if(g2(w))return D(M7(w,z),A);if(V0(w))return D(H7(w,z),A);return D(M0(w)?TQ(w.anyOf,z):s1(w,z)!==S.False?w:H0(),A)}function iQ(w,z){let A={};for(let U of globalThis.Object.getOwnPropertyNames(w))A[U]=l6(w[U],z);return A}function dQ(w,z){return iQ(w.properties,z)}function H7(w,z){let A=dQ(w,z);return J0(A)}function G7(w,z){return D(w.returns,z)}function L7(w){return D({[b]:"Integer",type:"integer"},w)}function cQ(w,z,A){return{[w]:W1(X0(w),z,f0(A))}}function nQ(w,z,A){return w.reduce((W,$)=>{return{...W,...cQ($,z,A)}},{})}function hQ(w,z,A){return nQ(w.keys,z,A)}function b7(w,z,A){let U=hQ(w,z,A);return J0(U)}function tQ(w){let[z,A]=[w.slice(0,1),w.slice(1)];return[z.toLowerCase(),A].join("")}function yQ(w){let[z,A]=[w.slice(0,1),w.slice(1)];return[z.toUpperCase(),A].join("")}function vQ(w){return w.toUpperCase()}function oQ(w){return w.toLowerCase()}function uQ(w,z,A){let U=n6(w.pattern);if(!L6(U))return{...w,pattern:N7(w.pattern,z)};let X=[...I4(U)].map((J)=>X0(J)),Q=S7(X,z),Z=G0(Q);return Nw([Z],A)}function N7(w,z){return typeof w==="string"?z==="Uncapitalize"?tQ(w):z==="Capitalize"?yQ(w):z==="Uppercase"?vQ(w):z==="Lowercase"?oQ(w):w:w.toString()}function S7(w,z){return w.map((A)=>W1(A,z))}function W1(w,z,A={}){return V2(w)?b7(w,z,A):g2(w)?uQ(w,z,A):M0(w)?G0(S7(w.anyOf,z),A):x1(w)?X0(N7(w.const,z),A):D(w,A)}function D7(w,z={}){return W1(w,"Capitalize",z)}function _7(w,z={}){return W1(w,"Lowercase",z)}function P7(w,z={}){return W1(w,"Uncapitalize",z)}function O7(w,z={}){return W1(w,"Uppercase",z)}function mQ(w,z,A){let U={};for(let W of globalThis.Object.getOwnPropertyNames(w))U[W]=r1(w[W],z,f0(A));return U}function pQ(w,z,A){return mQ(w.properties,z,A)}function C7(w,z,A){let U=pQ(w,z,A);return J0(U)}function lQ(w,z){return w.map((A)=>x5(A,z))}function sQ(w,z){return w.map((A)=>x5(A,z))}function rQ(w,z){let{[z]:A,...U}=w;return U}function aQ(w,z){return z.reduce((A,U)=>rQ(A,U),w)}function eQ(w,z){let A=n0(w,[j0,"$id","required","properties"]),U=aQ(w.properties,z);return S0(U,A)}function wZ(w){let z=w.reduce((A,U)=>Mw(U)?[...A,X0(U)]:A,[]);return G0(z)}function x5(w,z){return v0(w)?Z2(lQ(w.allOf,z)):M0(w)?G0(sQ(w.anyOf,z)):s0(w)?eQ(w,z):S0({})}function r1(w,z,A){let U=y0(z)?wZ(z):z,W=T0(z)?R2(z):z,$=d0(w),X=d0(z);return V0(w)?C7(w,W,A):V2(z)?R7(w,z,A):$&&X?b0("Omit",[w,U],A):!$&&X?b0("Omit",[w,U],A):$&&!X?b0("Omit",[w,U],A):D({...x5(w,W),...A})}function zZ(w,z,A){return{[z]:r1(w,[z],f0(A))}}function AZ(w,z,A){return z.reduce((U,W)=>{return{...U,...zZ(w,W,A)}},{})}function UZ(w,z,A){return AZ(w,z.keys,A)}function R7(w,z,A){let U=UZ(w,z,A);return J0(U)}function WZ(w,z,A){let U={};for(let W of globalThis.Object.getOwnPropertyNames(w))U[W]=a1(w[W],z,f0(A));return U}function $Z(w,z,A){return WZ(w.properties,z,A)}function K7(w,z,A){let U=$Z(w,z,A);return J0(U)}function XZ(w,z){return w.map((A)=>E5(A,z))}function QZ(w,z){return w.map((A)=>E5(A,z))}function ZZ(w,z){let A={};for(let U of z)if(U in w)A[U]=w[U];return A}function JZ(w,z){let A=n0(w,[j0,"$id","required","properties"]),U=ZZ(w.properties,z);return S0(U,A)}function YZ(w){let z=w.reduce((A,U)=>Mw(U)?[...A,X0(U)]:A,[]);return G0(z)}function E5(w,z){return v0(w)?Z2(XZ(w.allOf,z)):M0(w)?G0(QZ(w.anyOf,z)):s0(w)?JZ(w,z):S0({})}function a1(w,z,A){let U=y0(z)?YZ(z):z,W=T0(z)?R2(z):z,$=d0(w),X=d0(z);return V0(w)?K7(w,W,A):V2(z)?j7(w,z,A):$&&X?b0("Pick",[w,U],A):!$&&X?b0("Pick",[w,U],A):$&&!X?b0("Pick",[w,U],A):D({...E5(w,W),...A})}function qZ(w,z,A){return{[z]:a1(w,[z],f0(A))}}function BZ(w,z,A){return z.reduce((U,W)=>{return{...U,...qZ(w,W,A)}},{})}function MZ(w,z,A){return BZ(w,z.keys,A)}function j7(w,z,A){let U=MZ(w,z,A);return J0(U)}function HZ(w,z){return b0("Partial",[b0(w,z)])}function GZ(w){return b0("Partial",[K2(w)])}function LZ(w){let z={};for(let A of globalThis.Object.getOwnPropertyNames(w))z[A]=C2(w[A]);return z}function bZ(w){let z=n0(w,[j0,"$id","required","properties"]),A=LZ(w.properties);return S0(A,z)}function F7(w){return w.map((z)=>x7(z))}function x7(w){return O2(w)?HZ(w.target,w.parameters):d0(w)?GZ(w.$ref):v0(w)?Z2(F7(w.allOf)):M0(w)?G0(F7(w.anyOf)):s0(w)?bZ(w):S0({})}function s6(w,z){if(V0(w))return E7(w,z);else return D({...x7(w),...z})}function NZ(w,z){let A={};for(let U of globalThis.Object.getOwnPropertyNames(w))A[U]=s6(w[U],f0(z));return A}function SZ(w,z){return NZ(w.properties,z)}function E7(w,z){let A=SZ(w,z);return J0(A)}function N6(w,z,A){return D({[b]:"Record",type:"object",patternProperties:{[w]:z}},A)}function I5(w,z,A){let U={};for(let W of w)U[W]=z;return S0(U,{...A,[n2]:"Record"})}function DZ(w,z,A){return Lw(w)?I5(R2(w),z,A):N6(w.pattern,z,A)}function _Z(w,z,A){return I5(R2(G0(w)),z,A)}function PZ(w,z,A){return I5([w.toString()],z,A)}function OZ(w,z,A){return N6(w.source,z,A)}function CZ(w,z,A){let U=l0(w.pattern)?I1:w.pattern;return N6(U,z,A)}function RZ(w,z,A){return N6(I1,z,A)}function KZ(w,z,A){return N6(_9,z,A)}function jZ(w,z,A){return N6(E1,z,A)}function FZ(w,z,A){return N6(E1,z,A)}function Ew(w,z,A={}){return O2(z)?b0("Record",[w,b0(z.target,z.parameters)],A):O2(w)?b0("Record",[b0(z.target,z.parameters),z],A):d0(w)?b0("Record",[K2(w.$ref),z]):M0(w)?_Z(w.anyOf,z,A):g2(w)?DZ(w,z,A):x1(w)?PZ(w.const,z,A):H6(w)?jZ(w,z,A):G6(w)?FZ(w,z,A):H5(w)?OZ(w,z,A):R4(w)?CZ(w,z,A):Y5(w)?RZ(w,z,A):u1(w)?KZ(w,z,A):H0(A)}function xZ(w,z){return b0("Required",[b0(w,z)])}function EZ(w){return b0("Required",[K2(w)])}function IZ(w){let z={};for(let A of globalThis.Object.getOwnPropertyNames(w))z[A]=n0(w[A],[W2]);return z}function fZ(w){let z=n0(w,[j0,"$id","required","properties"]),A=IZ(w.properties);return S0(A,z)}function I7(w){return w.map((z)=>f7(z))}function f7(w){return O2(w)?xZ(w.target,w.parameters):d0(w)?EZ(w.$ref):v0(w)?Z2(I7(w.allOf)):M0(w)?G0(I7(w.anyOf)):s0(w)?fZ(w):S0({})}function r6(w,z){if(V0(w))return k7(w,z);else return D({...f7(w),...z})}function kZ(w,z){let A={};for(let U of globalThis.Object.getOwnPropertyNames(w))A[U]=r6(w[U],z);return A}function VZ(w,z){return kZ(w.properties,z)}function k7(w,z){let A=VZ(w,z);return J0(A)}function gZ(w,z){return z.map((A)=>{return d0(A)?V7(w,A.$ref):p2(w,A)})}function V7(w,z){return z in w?d0(w[z])?V7(w,w[z].$ref):p2(w,w[z]):H0()}function TZ(w){return v6(w[0])}function iZ(w){return l1(w[0],w[1])}function dZ(w){return o6(w[0])}function cZ(w){return s6(w[0])}function nZ(w){return r1(w[0],w[1])}function hZ(w){return a1(w[0],w[1])}function tZ(w){return Ew(w[0],w[1])}function yZ(w){return r6(w[0])}function vZ(w,z,A){let U=gZ(w,A);return z==="Awaited"?TZ(U):z==="Index"?iZ(U):z==="KeyOf"?dZ(U):z==="Partial"?cZ(U):z==="Omit"?nZ(U):z==="Pick"?hZ(U):z==="Record"?tZ(U):z==="Required"?yZ(U):H0()}function oZ(w,z){return S0(globalThis.Object.keys(z).reduce((A,U)=>{return{...A,[U]:p2(w,z[U])}},{}))}function uZ(w,z,A){return d6(g4(w,z),p2(w,A))}function mZ(w,z,A){return L1(g4(w,z),p2(w,A))}function pZ(w,z){return v2(g4(w,z))}function lZ(w,z){return Z2(g4(w,z))}function sZ(w,z){return G0(g4(w,z))}function rZ(w,z){return T6(p2(w,z))}function aZ(w,z){return i6(p2(w,z))}function eZ(w,z){return y6(p2(w,z))}function g4(w,z){return z.map((A)=>p2(w,A))}function p2(w,z){return h2(z)?D(p2(w,n0(z,[W2])),z):Bw(z)?D(p2(w,n0(z,[A1])),z):F1(z)?D(rZ(w,z.items),z):D4(z)?D(aZ(w,z.items),z):O2(z)?D(vZ(w,z.target,z.parameters)):_4(z)?D(uZ(w,z.parameters,z.returns),z):P4(z)?D(mZ(w,z.parameters,z.returns),z):v0(z)?D(lZ(w,z.allOf),z):O4(z)?D(eZ(w,z.items),z):s0(z)?D(oZ(w,z.properties),z):U1(z)?D(pZ(w,z.items||[]),z):M0(z)?D(sZ(w,z.anyOf),z):z}function wJ(w,z){return z in w?p2(w,w[z]):H0()}function g7(w){return globalThis.Object.getOwnPropertyNames(w).reduce((z,A)=>{return{...z,[A]:wJ(w,A)}},{})}class T7{constructor(w){let z=g7(w),A=this.WithIdentifiers(z);this.$defs=A}Import(w,z){let A={...this.$defs,[w]:D(this.$defs[w],z)};return D({[b]:"Import",$defs:A,$ref:w})}WithIdentifiers(w){return globalThis.Object.getOwnPropertyNames(w).reduce((z,A)=>{return{...z,[A]:{...w[A],$id:A}}},{})}}function i7(w){return new T7(w)}function d7(w,z){return D({[b]:"Not",not:w},z)}function c7(w,z){return v2(w.parameters,z)}function n7(w){return y2(C2(w))}var zJ=0;function h7(w,z={}){if(l0(z.$id))z.$id=`T${zJ++}`;let A=jz(w({[b]:"This",$ref:`${z.$id}`}));return A.$id=z.$id,D({[n2]:"Recursive",...A},z)}function t7(w,z){let A=x0(w)?new globalThis.RegExp(w):w;return D({[b]:"RegExp",type:"RegExp",source:A.source,flags:A.flags},z)}function AJ(w){return v0(w)?w.allOf:M0(w)?w.anyOf:U1(w)?w.items??[]:[]}function y7(w){return AJ(w)}function v7(w,z){return D(w.returns,z)}class o7{constructor(w){this.schema=w}Decode(w){return new u7(this.schema,w)}}class u7{constructor(w,z){this.schema=w,this.decode=z}EncodeTransform(w,z){let W={Encode:($)=>z[j0].Encode(w($)),Decode:($)=>this.decode(z[j0].Decode($))};return{...z,[j0]:W}}EncodeSchema(w,z){let A={Decode:this.decode,Encode:w};return{...z,[j0]:A}}Encode(w){return N0(this.schema)?this.EncodeTransform(w,this.schema):this.EncodeSchema(w,this.schema)}}function m7(w){return new o7(w)}function Iw(w={}){return D({[b]:w[b]??"Unsafe"},w)}function p7(w){return D({[b]:"Void",type:"void"},w)}var f5={};B6(f5,{Void:()=>p7,Uppercase:()=>O7,Unsafe:()=>Iw,Unknown:()=>V1,Union:()=>G0,Undefined:()=>Rw,Uncapitalize:()=>P7,Uint8Array:()=>Kw,Tuple:()=>v2,Transform:()=>m7,TemplateLiteral:()=>Nw,Symbol:()=>Cw,String:()=>t2,ReturnType:()=>v7,Rest:()=>y7,Required:()=>r6,RegExp:()=>t7,Ref:()=>K2,Recursive:()=>h7,Record:()=>Ew,ReadonlyOptional:()=>n7,Readonly:()=>y2,Promise:()=>Dw,Pick:()=>a1,Partial:()=>s6,Parameters:()=>c7,Optional:()=>C2,Omit:()=>r1,Object:()=>S0,Number:()=>N1,Null:()=>Ow,Not:()=>d7,Never:()=>H0,Module:()=>i7,Mapped:()=>h9,Lowercase:()=>_7,Literal:()=>X0,KeyOf:()=>o6,Iterator:()=>y6,Intersect:()=>Z2,Integer:()=>L7,InstanceType:()=>G7,Index:()=>l1,Function:()=>L1,Extract:()=>l6,Extends:()=>m6,Exclude:()=>p6,Enum:()=>s9,Date:()=>Pw,ConstructorParameters:()=>l9,Constructor:()=>d6,Const:()=>p9,Composite:()=>m9,Capitalize:()=>D7,Boolean:()=>bw,BigInt:()=>t6,Awaited:()=>v6,AsyncIterator:()=>i6,Array:()=>T6,Any:()=>p1});var S6=f5;class l7 extends n{constructor(w){super(`Duplicate type kind '${w}' detected`)}}class s7 extends n{constructor(w){super(`Duplicate string format '${w}' detected`)}}var T1;(function(w){function z(U,W){if(c0.Has(U))throw new l7(U);return c0.Set(U,W),($={})=>Iw({...$,[b]:U})}w.Type=z;function A(U,W){if(O0.Has(U))throw new s7(U);return O0.Set(U,W),U}w.Format=A})(T1||(T1={}));function UJ(w){switch(w.errorType){case N.ArrayContains:return"Expected array to contain at least one matching value";case N.ArrayMaxContains:return`Expected array to contain no more than ${w.schema.maxContains} matching values`;case N.ArrayMinContains:return`Expected array to contain at least ${w.schema.minContains} matching values`;case N.ArrayMaxItems:return`Expected array length to be less or equal to ${w.schema.maxItems}`;case N.ArrayMinItems:return`Expected array length to be greater or equal to ${w.schema.minItems}`;case N.ArrayUniqueItems:return"Expected array elements to be unique";case N.Array:return"Expected array";case N.AsyncIterator:return"Expected AsyncIterator";case N.BigIntExclusiveMaximum:return`Expected bigint to be less than ${w.schema.exclusiveMaximum}`;case N.BigIntExclusiveMinimum:return`Expected bigint to be greater than ${w.schema.exclusiveMinimum}`;case N.BigIntMaximum:return`Expected bigint to be less or equal to ${w.schema.maximum}`;case N.BigIntMinimum:return`Expected bigint to be greater or equal to ${w.schema.minimum}`;case N.BigIntMultipleOf:return`Expected bigint to be a multiple of ${w.schema.multipleOf}`;case N.BigInt:return"Expected bigint";case N.Boolean:return"Expected boolean";case N.DateExclusiveMinimumTimestamp:return`Expected Date timestamp to be greater than ${w.schema.exclusiveMinimumTimestamp}`;case N.DateExclusiveMaximumTimestamp:return`Expected Date timestamp to be less than ${w.schema.exclusiveMaximumTimestamp}`;case N.DateMinimumTimestamp:return`Expected Date timestamp to be greater or equal to ${w.schema.minimumTimestamp}`;case N.DateMaximumTimestamp:return`Expected Date timestamp to be less or equal to ${w.schema.maximumTimestamp}`;case N.DateMultipleOfTimestamp:return`Expected Date timestamp to be a multiple of ${w.schema.multipleOfTimestamp}`;case N.Date:return"Expected Date";case N.Function:return"Expected function";case N.IntegerExclusiveMaximum:return`Expected integer to be less than ${w.schema.exclusiveMaximum}`;case N.IntegerExclusiveMinimum:return`Expected integer to be greater than ${w.schema.exclusiveMinimum}`;case N.IntegerMaximum:return`Expected integer to be less or equal to ${w.schema.maximum}`;case N.IntegerMinimum:return`Expected integer to be greater or equal to ${w.schema.minimum}`;case N.IntegerMultipleOf:return`Expected integer to be a multiple of ${w.schema.multipleOf}`;case N.Integer:return"Expected integer";case N.IntersectUnevaluatedProperties:return"Unexpected property";case N.Intersect:return"Expected all values to match";case N.Iterator:return"Expected Iterator";case N.Literal:return`Expected ${typeof w.schema.const==="string"?`'${w.schema.const}'`:w.schema.const}`;case N.Never:return"Never";case N.Not:return"Value should not match";case N.Null:return"Expected null";case N.NumberExclusiveMaximum:return`Expected number to be less than ${w.schema.exclusiveMaximum}`;case N.NumberExclusiveMinimum:return`Expected number to be greater than ${w.schema.exclusiveMinimum}`;case N.NumberMaximum:return`Expected number to be less or equal to ${w.schema.maximum}`;case N.NumberMinimum:return`Expected number to be greater or equal to ${w.schema.minimum}`;case N.NumberMultipleOf:return`Expected number to be a multiple of ${w.schema.multipleOf}`;case N.Number:return"Expected number";case N.Object:return"Expected object";case N.ObjectAdditionalProperties:return"Unexpected property";case N.ObjectMaxProperties:return`Expected object to have no more than ${w.schema.maxProperties} properties`;case N.ObjectMinProperties:return`Expected object to have at least ${w.schema.minProperties} properties`;case N.ObjectRequiredProperty:return"Expected required property";case N.Promise:return"Expected Promise";case N.RegExp:return"Expected string to match regular expression";case N.StringFormatUnknown:return`Unknown format '${w.schema.format}'`;case N.StringFormat:return`Expected string to match '${w.schema.format}' format`;case N.StringMaxLength:return`Expected string length less or equal to ${w.schema.maxLength}`;case N.StringMinLength:return`Expected string length greater or equal to ${w.schema.minLength}`;case N.StringPattern:return`Expected string to match '${w.schema.pattern}'`;case N.String:return"Expected string";case N.Symbol:return"Expected symbol";case N.TupleLength:return`Expected tuple to have ${w.schema.maxItems||0} elements`;case N.Tuple:return"Expected tuple";case N.Uint8ArrayMaxByteLength:return`Expected byte length less or equal to ${w.schema.maxByteLength}`;case N.Uint8ArrayMinByteLength:return`Expected byte length greater or equal to ${w.schema.minByteLength}`;case N.Uint8Array:return"Expected Uint8Array";case N.Undefined:return"Expected undefined";case N.Union:return"Expected union value";case N.Void:return"Expected void";case N.Kind:return`Expected kind '${w.schema[b]}'`;default:return"Unknown error type"}}var WJ=UJ;function r7(){return WJ}class a7 extends n{constructor(w){super(`Unable to dereference schema with $id '${w.$ref}'`);this.schema=w}}function $J(w,z){let A=z.find((U)=>U.$id===w.$ref);if(A===void 0)throw new a7(w);return Y0(A,z)}function e0(w,z){if(!Q0(w.$id)||z.some((A)=>A.$id===w.$id))return z;return z.push(w),z}function Y0(w,z){return w[b]==="This"||w[b]==="Ref"?$J(w,z):w}class e7 extends n{constructor(w){super("Unable to hash value");this.value=w}}var T2;(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"})(T2||(T2={}));var a6=BigInt("14695981039346656037"),[XJ,QJ]=[BigInt("1099511628211"),BigInt("18446744073709551616")],ZJ=Array.from({length:256}).map((w,z)=>BigInt(z)),wA=new Float64Array(1),zA=new DataView(wA.buffer),AA=new Uint8Array(wA.buffer);function*JJ(w){let z=w===0?1:Math.ceil(Math.floor(Math.log2(w)+1)/8);for(let A=0;A<z;A++)yield w>>8*(z-1-A)&255}function YJ(w){Y2(T2.Array);for(let z of w)e6(z)}function qJ(w){Y2(T2.Boolean),Y2(w?1:0)}function BJ(w){Y2(T2.BigInt),zA.setBigInt64(0,w);for(let z of AA)Y2(z)}function MJ(w){Y2(T2.Date),e6(w.getTime())}function HJ(w){Y2(T2.Null)}function GJ(w){Y2(T2.Number),zA.setFloat64(0,w);for(let z of AA)Y2(z)}function LJ(w){Y2(T2.Object);for(let z of globalThis.Object.getOwnPropertyNames(w).sort())e6(z),e6(w[z])}function bJ(w){Y2(T2.String);for(let z=0;z<w.length;z++)for(let A of JJ(w.charCodeAt(z)))Y2(A)}function NJ(w){Y2(T2.Symbol),e6(w.description)}function SJ(w){Y2(T2.Uint8Array);for(let z=0;z<w.length;z++)Y2(w[z])}function DJ(w){return Y2(T2.Undefined)}function e6(w){if(v(w))return YJ(w);if(G1(w))return qJ(w);if(U2(w))return BJ(w);if(S2(w))return MJ(w);if(K1(w))return HJ(w);if(d(w))return GJ(w);if(r(w))return LJ(w);if(Q0(w))return bJ(w);if(j1(w))return NJ(w);if(k6(w))return SJ(w);if(k0(w))return DJ(w);throw new e7(w)}function Y2(w){a6=a6^ZJ[w],a6=a6*XJ%QJ}function e1(w){return a6=BigInt("14695981039346656037"),e6(w),a6}class UA extends n{constructor(w){super("Unknown type");this.schema=w}}function _J(w){return w[b]==="Any"||w[b]==="Unknown"}function z0(w){return w!==void 0}function PJ(w,z,A){return!0}function OJ(w,z,A){if(!v(A))return!1;if(z0(w.minItems)&&!(A.length>=w.minItems))return!1;if(z0(w.maxItems)&&!(A.length<=w.maxItems))return!1;if(!A.every(($)=>w2(w.items,z,$)))return!1;if(w.uniqueItems===!0&&!function(){let $=new Set;for(let X of A){let Q=e1(X);if($.has(Q))return!1;else $.add(Q)}return!0}())return!1;if(!(z0(w.contains)||d(w.minContains)||d(w.maxContains)))return!0;let U=z0(w.contains)?w.contains:H0(),W=A.reduce(($,X)=>w2(U,z,X)?$+1:$,0);if(W===0)return!1;if(d(w.minContains)&&W<w.minContains)return!1;if(d(w.maxContains)&&W>w.maxContains)return!1;return!0}function CJ(w,z,A){return Zw(A)}function RJ(w,z,A){if(!U2(A))return!1;if(z0(w.exclusiveMaximum)&&!(A<w.exclusiveMaximum))return!1;if(z0(w.exclusiveMinimum)&&!(A>w.exclusiveMinimum))return!1;if(z0(w.maximum)&&!(A<=w.maximum))return!1;if(z0(w.minimum)&&!(A>=w.minimum))return!1;if(z0(w.multipleOf)&&A%w.multipleOf!==BigInt(0))return!1;return!0}function KJ(w,z,A){return G1(A)}function jJ(w,z,A){return w2(w.returns,z,A.prototype)}function FJ(w,z,A){if(!S2(A))return!1;if(z0(w.exclusiveMaximumTimestamp)&&!(A.getTime()<w.exclusiveMaximumTimestamp))return!1;if(z0(w.exclusiveMinimumTimestamp)&&!(A.getTime()>w.exclusiveMinimumTimestamp))return!1;if(z0(w.maximumTimestamp)&&!(A.getTime()<=w.maximumTimestamp))return!1;if(z0(w.minimumTimestamp)&&!(A.getTime()>=w.minimumTimestamp))return!1;if(z0(w.multipleOfTimestamp)&&A.getTime()%w.multipleOfTimestamp!==0)return!1;return!0}function xJ(w,z,A){return o1(A)}function EJ(w,z,A){let U=globalThis.Object.values(w.$defs),W=w.$defs[w.$ref];return w2(W,[...z,...U],A)}function IJ(w,z,A){if(!qw(A))return!1;if(z0(w.exclusiveMaximum)&&!(A<w.exclusiveMaximum))return!1;if(z0(w.exclusiveMinimum)&&!(A>w.exclusiveMinimum))return!1;if(z0(w.maximum)&&!(A<=w.maximum))return!1;if(z0(w.minimum)&&!(A>=w.minimum))return!1;if(z0(w.multipleOf)&&A%w.multipleOf!==0)return!1;return!0}function fJ(w,z,A){let U=w.allOf.every((W)=>w2(W,z,A));if(w.unevaluatedProperties===!1){let W=new RegExp(k1(w)),$=Object.getOwnPropertyNames(A).every((X)=>W.test(X));return U&&$}else if(T0(w.unevaluatedProperties)){let W=new RegExp(k1(w)),$=Object.getOwnPropertyNames(A).every((X)=>W.test(X)||w2(w.unevaluatedProperties,z,A[X]));return U&&$}else return U}function kJ(w,z,A){return Jw(A)}function VJ(w,z,A){return A===w.const}function gJ(w,z,A){return!1}function TJ(w,z,A){return!w2(w.not,z,A)}function iJ(w,z,A){return K1(A)}function dJ(w,z,A){if(!I0.IsNumberLike(A))return!1;if(z0(w.exclusiveMaximum)&&!(A<w.exclusiveMaximum))return!1;if(z0(w.exclusiveMinimum)&&!(A>w.exclusiveMinimum))return!1;if(z0(w.minimum)&&!(A>=w.minimum))return!1;if(z0(w.maximum)&&!(A<=w.maximum))return!1;if(z0(w.multipleOf)&&A%w.multipleOf!==0)return!1;return!0}function cJ(w,z,A){if(!I0.IsObjectLike(A))return!1;if(z0(w.minProperties)&&!(Object.getOwnPropertyNames(A).length>=w.minProperties))return!1;if(z0(w.maxProperties)&&!(Object.getOwnPropertyNames(A).length<=w.maxProperties))return!1;let U=Object.getOwnPropertyNames(w.properties);for(let W of U){let $=w.properties[W];if(w.required&&w.required.includes(W)){if(!w2($,z,A[W]))return!1;if((g1($)||_J($))&&!(W in A))return!1}else if(I0.IsExactOptionalProperty(A,W)&&!w2($,z,A[W]))return!1}if(w.additionalProperties===!1){let W=Object.getOwnPropertyNames(A);if(w.required&&w.required.length===U.length&&W.length===U.length)return!0;else return W.every(($)=>U.includes($))}else if(typeof w.additionalProperties==="object")return Object.getOwnPropertyNames(A).every(($)=>U.includes($)||w2(w.additionalProperties,z,A[$]));else return!0}function nJ(w,z,A){return Yw(A)}function hJ(w,z,A){if(!I0.IsRecordLike(A))return!1;if(z0(w.minProperties)&&!(Object.getOwnPropertyNames(A).length>=w.minProperties))return!1;if(z0(w.maxProperties)&&!(Object.getOwnPropertyNames(A).length<=w.maxProperties))return!1;let[U,W]=Object.entries(w.patternProperties)[0],$=new RegExp(U),X=Object.entries(A).every(([J,Y])=>{return $.test(J)?w2(W,z,Y):!0}),Q=typeof w.additionalProperties==="object"?Object.entries(A).every(([J,Y])=>{return!$.test(J)?w2(w.additionalProperties,z,Y):!0}):!0,Z=w.additionalProperties===!1?Object.getOwnPropertyNames(A).every((J)=>{return $.test(J)}):!0;return X&&Q&&Z}function tJ(w,z,A){return w2(Y0(w,z),z,A)}function yJ(w,z,A){let U=new RegExp(w.source,w.flags);if(z0(w.minLength)){if(!(A.length>=w.minLength))return!1}if(z0(w.maxLength)){if(!(A.length<=w.maxLength))return!1}return U.test(A)}function vJ(w,z,A){if(!Q0(A))return!1;if(z0(w.minLength)){if(!(A.length>=w.minLength))return!1}if(z0(w.maxLength)){if(!(A.length<=w.maxLength))return!1}if(z0(w.pattern)){if(!new RegExp(w.pattern).test(A))return!1}if(z0(w.format)){if(!O0.Has(w.format))return!1;return O0.Get(w.format)(A)}return!0}function oJ(w,z,A){return j1(A)}function uJ(w,z,A){return Q0(A)&&new RegExp(w.pattern).test(A)}function mJ(w,z,A){return w2(Y0(w,z),z,A)}function pJ(w,z,A){if(!v(A))return!1;if(w.items===void 0&&A.length!==0)return!1;if(A.length!==w.maxItems)return!1;if(!w.items)return!0;for(let U=0;U<w.items.length;U++)if(!w2(w.items[U],z,A[U]))return!1;return!0}function lJ(w,z,A){return k0(A)}function sJ(w,z,A){return w.anyOf.some((U)=>w2(U,z,A))}function rJ(w,z,A){if(!k6(A))return!1;if(z0(w.maxByteLength)&&!(A.length<=w.maxByteLength))return!1;if(z0(w.minByteLength)&&!(A.length>=w.minByteLength))return!1;return!0}function aJ(w,z,A){return!0}function eJ(w,z,A){return I0.IsVoidLike(A)}function wY(w,z,A){if(!c0.Has(w[b]))return!1;return c0.Get(w[b])(w,A)}function w2(w,z,A){let U=z0(w.$id)?e0(w,z):z,W=w;switch(W[b]){case"Any":return PJ(W,U,A);case"Array":return OJ(W,U,A);case"AsyncIterator":return CJ(W,U,A);case"BigInt":return RJ(W,U,A);case"Boolean":return KJ(W,U,A);case"Constructor":return jJ(W,U,A);case"Date":return FJ(W,U,A);case"Function":return xJ(W,U,A);case"Import":return EJ(W,U,A);case"Integer":return IJ(W,U,A);case"Intersect":return fJ(W,U,A);case"Iterator":return kJ(W,U,A);case"Literal":return VJ(W,U,A);case"Never":return gJ(W,U,A);case"Not":return TJ(W,U,A);case"Null":return iJ(W,U,A);case"Number":return dJ(W,U,A);case"Object":return cJ(W,U,A);case"Promise":return nJ(W,U,A);case"Record":return hJ(W,U,A);case"Ref":return tJ(W,U,A);case"RegExp":return yJ(W,U,A);case"String":return vJ(W,U,A);case"Symbol":return oJ(W,U,A);case"TemplateLiteral":return uJ(W,U,A);case"This":return mJ(W,U,A);case"Tuple":return pJ(W,U,A);case"Undefined":return lJ(W,U,A);case"Union":return sJ(W,U,A);case"Uint8Array":return rJ(W,U,A);case"Unknown":return aJ(W,U,A);case"Void":return eJ(W,U,A);default:if(!c0.Has(W[b]))throw new UA(W);return wY(W,U,A)}}function a(...w){return w.length===3?w2(w[0],w[1],w[2]):w2(w[0],[],w[1])}var N;(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"})(N||(N={}));class WA extends n{constructor(w){super("Unknown type");this.schema=w}}function i1(w){return w.replace(/~/g,"~0").replace(/\//g,"~1")}function A0(w){return w!==void 0}class D6{constructor(w){this.iterator=w}[Symbol.iterator](){return this.iterator}First(){let w=this.iterator.next();return w.done?void 0:w.value}}function I(w,z,A,U,W=[]){return{type:w,schema:z,path:A,value:U,message:r7()({errorType:w,path:A,schema:z,value:U,errors:W}),errors:W}}function*zY(w,z,A,U){}function*AY(w,z,A,U){if(!v(U))return yield I(N.Array,w,A,U);if(A0(w.minItems)&&!(U.length>=w.minItems))yield I(N.ArrayMinItems,w,A,U);if(A0(w.maxItems)&&!(U.length<=w.maxItems))yield I(N.ArrayMaxItems,w,A,U);for(let X=0;X<U.length;X++)yield*z2(w.items,z,`${A}/${X}`,U[X]);if(w.uniqueItems===!0&&!function(){let X=new Set;for(let Q of U){let Z=e1(Q);if(X.has(Z))return!1;else X.add(Z)}return!0}())yield I(N.ArrayUniqueItems,w,A,U);if(!(A0(w.contains)||A0(w.minContains)||A0(w.maxContains)))return;let W=A0(w.contains)?w.contains:H0(),$=U.reduce((X,Q,Z)=>z2(W,z,`${A}${Z}`,Q).next().done===!0?X+1:X,0);if($===0)yield I(N.ArrayContains,w,A,U);if(d(w.minContains)&&$<w.minContains)yield I(N.ArrayMinContains,w,A,U);if(d(w.maxContains)&&$>w.maxContains)yield I(N.ArrayMaxContains,w,A,U)}function*UY(w,z,A,U){if(!Zw(U))yield I(N.AsyncIterator,w,A,U)}function*WY(w,z,A,U){if(!U2(U))return yield I(N.BigInt,w,A,U);if(A0(w.exclusiveMaximum)&&!(U<w.exclusiveMaximum))yield I(N.BigIntExclusiveMaximum,w,A,U);if(A0(w.exclusiveMinimum)&&!(U>w.exclusiveMinimum))yield I(N.BigIntExclusiveMinimum,w,A,U);if(A0(w.maximum)&&!(U<=w.maximum))yield I(N.BigIntMaximum,w,A,U);if(A0(w.minimum)&&!(U>=w.minimum))yield I(N.BigIntMinimum,w,A,U);if(A0(w.multipleOf)&&U%w.multipleOf!==BigInt(0))yield I(N.BigIntMultipleOf,w,A,U)}function*$Y(w,z,A,U){if(!G1(U))yield I(N.Boolean,w,A,U)}function*XY(w,z,A,U){yield*z2(w.returns,z,A,U.prototype)}function*QY(w,z,A,U){if(!S2(U))return yield I(N.Date,w,A,U);if(A0(w.exclusiveMaximumTimestamp)&&!(U.getTime()<w.exclusiveMaximumTimestamp))yield I(N.DateExclusiveMaximumTimestamp,w,A,U);if(A0(w.exclusiveMinimumTimestamp)&&!(U.getTime()>w.exclusiveMinimumTimestamp))yield I(N.DateExclusiveMinimumTimestamp,w,A,U);if(A0(w.maximumTimestamp)&&!(U.getTime()<=w.maximumTimestamp))yield I(N.DateMaximumTimestamp,w,A,U);if(A0(w.minimumTimestamp)&&!(U.getTime()>=w.minimumTimestamp))yield I(N.DateMinimumTimestamp,w,A,U);if(A0(w.multipleOfTimestamp)&&U.getTime()%w.multipleOfTimestamp!==0)yield I(N.DateMultipleOfTimestamp,w,A,U)}function*ZY(w,z,A,U){if(!o1(U))yield I(N.Function,w,A,U)}function*JY(w,z,A,U){let W=globalThis.Object.values(w.$defs),$=w.$defs[w.$ref];yield*z2($,[...z,...W],A,U)}function*YY(w,z,A,U){if(!qw(U))return yield I(N.Integer,w,A,U);if(A0(w.exclusiveMaximum)&&!(U<w.exclusiveMaximum))yield I(N.IntegerExclusiveMaximum,w,A,U);if(A0(w.exclusiveMinimum)&&!(U>w.exclusiveMinimum))yield I(N.IntegerExclusiveMinimum,w,A,U);if(A0(w.maximum)&&!(U<=w.maximum))yield I(N.IntegerMaximum,w,A,U);if(A0(w.minimum)&&!(U>=w.minimum))yield I(N.IntegerMinimum,w,A,U);if(A0(w.multipleOf)&&U%w.multipleOf!==0)yield I(N.IntegerMultipleOf,w,A,U)}function*qY(w,z,A,U){let W=!1;for(let $ of w.allOf)for(let X of z2($,z,A,U))W=!0,yield X;if(W)return yield I(N.Intersect,w,A,U);if(w.unevaluatedProperties===!1){let $=new RegExp(k1(w));for(let X of Object.getOwnPropertyNames(U))if(!$.test(X))yield I(N.IntersectUnevaluatedProperties,w,`${A}/${X}`,U)}if(typeof w.unevaluatedProperties==="object"){let $=new RegExp(k1(w));for(let X of Object.getOwnPropertyNames(U))if(!$.test(X)){let Q=z2(w.unevaluatedProperties,z,`${A}/${X}`,U[X]).next();if(!Q.done)yield Q.value}}}function*BY(w,z,A,U){if(!Jw(U))yield I(N.Iterator,w,A,U)}function*MY(w,z,A,U){if(U!==w.const)yield I(N.Literal,w,A,U)}function*HY(w,z,A,U){yield I(N.Never,w,A,U)}function*GY(w,z,A,U){if(z2(w.not,z,A,U).next().done===!0)yield I(N.Not,w,A,U)}function*LY(w,z,A,U){if(!K1(U))yield I(N.Null,w,A,U)}function*bY(w,z,A,U){if(!I0.IsNumberLike(U))return yield I(N.Number,w,A,U);if(A0(w.exclusiveMaximum)&&!(U<w.exclusiveMaximum))yield I(N.NumberExclusiveMaximum,w,A,U);if(A0(w.exclusiveMinimum)&&!(U>w.exclusiveMinimum))yield I(N.NumberExclusiveMinimum,w,A,U);if(A0(w.maximum)&&!(U<=w.maximum))yield I(N.NumberMaximum,w,A,U);if(A0(w.minimum)&&!(U>=w.minimum))yield I(N.NumberMinimum,w,A,U);if(A0(w.multipleOf)&&U%w.multipleOf!==0)yield I(N.NumberMultipleOf,w,A,U)}function*NY(w,z,A,U){if(!I0.IsObjectLike(U))return yield I(N.Object,w,A,U);if(A0(w.minProperties)&&!(Object.getOwnPropertyNames(U).length>=w.minProperties))yield I(N.ObjectMinProperties,w,A,U);if(A0(w.maxProperties)&&!(Object.getOwnPropertyNames(U).length<=w.maxProperties))yield I(N.ObjectMaxProperties,w,A,U);let W=Array.isArray(w.required)?w.required:[],$=Object.getOwnPropertyNames(w.properties),X=Object.getOwnPropertyNames(U);for(let Q of W){if(X.includes(Q))continue;yield I(N.ObjectRequiredProperty,w.properties[Q],`${A}/${i1(Q)}`,void 0)}if(w.additionalProperties===!1){for(let Q of X)if(!$.includes(Q))yield I(N.ObjectAdditionalProperties,w,`${A}/${i1(Q)}`,U[Q])}if(typeof w.additionalProperties==="object")for(let Q of X){if($.includes(Q))continue;yield*z2(w.additionalProperties,z,`${A}/${i1(Q)}`,U[Q])}for(let Q of $){let Z=w.properties[Q];if(w.required&&w.required.includes(Q)){if(yield*z2(Z,z,`${A}/${i1(Q)}`,U[Q]),g1(w)&&!(Q in U))yield I(N.ObjectRequiredProperty,Z,`${A}/${i1(Q)}`,void 0)}else if(I0.IsExactOptionalProperty(U,Q))yield*z2(Z,z,`${A}/${i1(Q)}`,U[Q])}}function*SY(w,z,A,U){if(!Yw(U))yield I(N.Promise,w,A,U)}function*DY(w,z,A,U){if(!I0.IsRecordLike(U))return yield I(N.Object,w,A,U);if(A0(w.minProperties)&&!(Object.getOwnPropertyNames(U).length>=w.minProperties))yield I(N.ObjectMinProperties,w,A,U);if(A0(w.maxProperties)&&!(Object.getOwnPropertyNames(U).length<=w.maxProperties))yield I(N.ObjectMaxProperties,w,A,U);let[W,$]=Object.entries(w.patternProperties)[0],X=new RegExp(W);for(let[Q,Z]of Object.entries(U))if(X.test(Q))yield*z2($,z,`${A}/${i1(Q)}`,Z);if(typeof w.additionalProperties==="object"){for(let[Q,Z]of Object.entries(U))if(!X.test(Q))yield*z2(w.additionalProperties,z,`${A}/${i1(Q)}`,Z)}if(w.additionalProperties===!1)for(let[Q,Z]of Object.entries(U)){if(X.test(Q))continue;return yield I(N.ObjectAdditionalProperties,w,`${A}/${i1(Q)}`,Z)}}function*_Y(w,z,A,U){yield*z2(Y0(w,z),z,A,U)}function*PY(w,z,A,U){if(!Q0(U))return yield I(N.String,w,A,U);if(A0(w.minLength)&&!(U.length>=w.minLength))yield I(N.StringMinLength,w,A,U);if(A0(w.maxLength)&&!(U.length<=w.maxLength))yield I(N.StringMaxLength,w,A,U);if(!new RegExp(w.source,w.flags).test(U))return yield I(N.RegExp,w,A,U)}function*OY(w,z,A,U){if(!Q0(U))return yield I(N.String,w,A,U);if(A0(w.minLength)&&!(U.length>=w.minLength))yield I(N.StringMinLength,w,A,U);if(A0(w.maxLength)&&!(U.length<=w.maxLength))yield I(N.StringMaxLength,w,A,U);if(Q0(w.pattern)){if(!new RegExp(w.pattern).test(U))yield I(N.StringPattern,w,A,U)}if(Q0(w.format)){if(!O0.Has(w.format))yield I(N.StringFormatUnknown,w,A,U);else if(!O0.Get(w.format)(U))yield I(N.StringFormat,w,A,U)}}function*CY(w,z,A,U){if(!j1(U))yield I(N.Symbol,w,A,U)}function*RY(w,z,A,U){if(!Q0(U))return yield I(N.String,w,A,U);if(!new RegExp(w.pattern).test(U))yield I(N.StringPattern,w,A,U)}function*KY(w,z,A,U){yield*z2(Y0(w,z),z,A,U)}function*jY(w,z,A,U){if(!v(U))return yield I(N.Tuple,w,A,U);if(w.items===void 0&&U.length!==0)return yield I(N.TupleLength,w,A,U);if(U.length!==w.maxItems)return yield I(N.TupleLength,w,A,U);if(!w.items)return;for(let W=0;W<w.items.length;W++)yield*z2(w.items[W],z,`${A}/${W}`,U[W])}function*FY(w,z,A,U){if(!k0(U))yield I(N.Undefined,w,A,U)}function*xY(w,z,A,U){if(a(w,z,U))return;let W=w.anyOf.map(($)=>new D6(z2($,z,A,U)));yield I(N.Union,w,A,U,W)}function*EY(w,z,A,U){if(!k6(U))return yield I(N.Uint8Array,w,A,U);if(A0(w.maxByteLength)&&!(U.length<=w.maxByteLength))yield I(N.Uint8ArrayMaxByteLength,w,A,U);if(A0(w.minByteLength)&&!(U.length>=w.minByteLength))yield I(N.Uint8ArrayMinByteLength,w,A,U)}function*IY(w,z,A,U){}function*fY(w,z,A,U){if(!I0.IsVoidLike(U))yield I(N.Void,w,A,U)}function*kY(w,z,A,U){if(!c0.Get(w[b])(w,U))yield I(N.Kind,w,A,U)}function*z2(w,z,A,U){let W=A0(w.$id)?[...z,w]:z,$=w;switch($[b]){case"Any":return yield*zY($,W,A,U);case"Array":return yield*AY($,W,A,U);case"AsyncIterator":return yield*UY($,W,A,U);case"BigInt":return yield*WY($,W,A,U);case"Boolean":return yield*$Y($,W,A,U);case"Constructor":return yield*XY($,W,A,U);case"Date":return yield*QY($,W,A,U);case"Function":return yield*ZY($,W,A,U);case"Import":return yield*JY($,W,A,U);case"Integer":return yield*YY($,W,A,U);case"Intersect":return yield*qY($,W,A,U);case"Iterator":return yield*BY($,W,A,U);case"Literal":return yield*MY($,W,A,U);case"Never":return yield*HY($,W,A,U);case"Not":return yield*GY($,W,A,U);case"Null":return yield*LY($,W,A,U);case"Number":return yield*bY($,W,A,U);case"Object":return yield*NY($,W,A,U);case"Promise":return yield*SY($,W,A,U);case"Record":return yield*DY($,W,A,U);case"Ref":return yield*_Y($,W,A,U);case"RegExp":return yield*PY($,W,A,U);case"String":return yield*OY($,W,A,U);case"Symbol":return yield*CY($,W,A,U);case"TemplateLiteral":return yield*RY($,W,A,U);case"This":return yield*KY($,W,A,U);case"Tuple":return yield*jY($,W,A,U);case"Undefined":return yield*FY($,W,A,U);case"Union":return yield*xY($,W,A,U);case"Uint8Array":return yield*EY($,W,A,U);case"Unknown":return yield*IY($,W,A,U);case"Void":return yield*fY($,W,A,U);default:if(!c0.Has($[b]))throw new WA(w);return yield*kY($,W,A,U)}}function S1(...w){let z=w.length===3?z2(w[0],w[1],"",w[2]):z2(w[0],[],"",w[1]);return new D6(z)}class T4 extends n{constructor(w,z,A){super("Unable to decode value as it does not match the expected schema");this.schema=w,this.value=z,this.error=A}}class fw extends n{constructor(w,z,A,U){super(U instanceof Error?U.message:"Unknown error");this.schema=w,this.path=z,this.value=A,this.error=U}}function h0(w,z,A){try{return N0(w)?w[j0].Decode(A):A}catch(U){throw new fw(w,z,A,U)}}function VY(w,z,A,U){return v(U)?h0(w,A,U.map((W,$)=>$1(w.items,z,`${A}/${$}`,W))):h0(w,A,U)}function gY(w,z,A,U){if(!r(U)||k2(U))return h0(w,A,U);let W=_w(w),$=W.map((Y)=>Y[0]),X={...U};for(let[Y,L]of W)if(Y in X)X[Y]=$1(L,z,`${A}/${Y}`,X[Y]);if(!N0(w.unevaluatedProperties))return h0(w,A,X);let Q=Object.getOwnPropertyNames(X),Z=w.unevaluatedProperties,J={...X};for(let Y of Q)if(!$.includes(Y))J[Y]=h0(Z,`${A}/${Y}`,J[Y]);return h0(w,A,J)}function TY(w,z,A,U){let W=globalThis.Object.values(w.$defs),$=w.$defs[w.$ref],X=w[j0],Q={[j0]:X,...$};return $1(Q,[...z,...W],A,U)}function iY(w,z,A,U){return h0(w,A,$1(w.not,z,A,U))}function dY(w,z,A,U){if(!r(U))return h0(w,A,U);let W=j2(w),$={...U};for(let J of W){if(!y($,J))continue;if(k0($[J])&&(!K4(w.properties[J])||I0.IsExactOptionalProperty($,J)))continue;$[J]=$1(w.properties[J],z,`${A}/${J}`,$[J])}if(!T0(w.additionalProperties))return h0(w,A,$);let X=Object.getOwnPropertyNames($),Q=w.additionalProperties,Z={...$};for(let J of X)if(!W.includes(J))Z[J]=h0(Q,`${A}/${J}`,Z[J]);return h0(w,A,Z)}function cY(w,z,A,U){if(!r(U))return h0(w,A,U);let W=Object.getOwnPropertyNames(w.patternProperties)[0],$=new RegExp(W),X={...U};for(let Y of Object.getOwnPropertyNames(U))if($.test(Y))X[Y]=$1(w.patternProperties[W],z,`${A}/${Y}`,X[Y]);if(!T0(w.additionalProperties))return h0(w,A,X);let Q=Object.getOwnPropertyNames(X),Z=w.additionalProperties,J={...X};for(let Y of Q)if(!$.test(Y))J[Y]=h0(Z,`${A}/${Y}`,J[Y]);return h0(w,A,J)}function nY(w,z,A,U){let W=Y0(w,z);return h0(w,A,$1(W,z,A,U))}function hY(w,z,A,U){let W=Y0(w,z);return h0(w,A,$1(W,z,A,U))}function tY(w,z,A,U){return v(U)&&v(w.items)?h0(w,A,w.items.map((W,$)=>$1(W,z,`${A}/${$}`,U[$]))):h0(w,A,U)}function yY(w,z,A,U){for(let W of w.anyOf){if(!a(W,z,U))continue;let $=$1(W,z,A,U);return h0(w,A,$)}return h0(w,A,U)}function $1(w,z,A,U){let W=e0(w,z),$=w;switch(w[b]){case"Array":return VY($,W,A,U);case"Import":return TY($,W,A,U);case"Intersect":return gY($,W,A,U);case"Not":return iY($,W,A,U);case"Object":return dY($,W,A,U);case"Record":return cY($,W,A,U);case"Ref":return nY($,W,A,U);case"Symbol":return h0($,A,U);case"This":return hY($,W,A,U);case"Tuple":return tY($,W,A,U);case"Union":return yY($,W,A,U);default:return h0($,A,U)}}function w4(w,z,A){return $1(w,z,"",A)}class i4 extends n{constructor(w,z,A){super("The encoded value does not match the expected schema");this.schema=w,this.value=z,this.error=A}}class $A extends n{constructor(w,z,A,U){super(`${U instanceof Error?U.message:"Unknown error"}`);this.schema=w,this.path=z,this.value=A,this.error=U}}function q2(w,z,A){try{return N0(w)?w[j0].Encode(A):A}catch(U){throw new $A(w,z,A,U)}}function vY(w,z,A,U){let W=q2(w,A,U);return v(W)?W.map(($,X)=>X1(w.items,z,`${A}/${X}`,$)):W}function oY(w,z,A,U){let W=globalThis.Object.values(w.$defs),$=w.$defs[w.$ref],X=w[j0],Q={[j0]:X,...$};return X1(Q,[...z,...W],A,U)}function uY(w,z,A,U){let W=q2(w,A,U);if(!r(U)||k2(U))return W;let $=_w(w),X=$.map((L)=>L[0]),Q={...W};for(let[L,_]of $)if(L in Q)Q[L]=X1(_,z,`${A}/${L}`,Q[L]);if(!N0(w.unevaluatedProperties))return Q;let Z=Object.getOwnPropertyNames(Q),J=w.unevaluatedProperties,Y={...Q};for(let L of Z)if(!X.includes(L))Y[L]=q2(J,`${A}/${L}`,Y[L]);return Y}function mY(w,z,A,U){return q2(w.not,A,q2(w,A,U))}function pY(w,z,A,U){let W=q2(w,A,U);if(!r(W))return W;let $=j2(w),X={...W};for(let Y of $){if(!y(X,Y))continue;if(k0(X[Y])&&(!K4(w.properties[Y])||I0.IsExactOptionalProperty(X,Y)))continue;X[Y]=X1(w.properties[Y],z,`${A}/${Y}`,X[Y])}if(!T0(w.additionalProperties))return X;let Q=Object.getOwnPropertyNames(X),Z=w.additionalProperties,J={...X};for(let Y of Q)if(!$.includes(Y))J[Y]=q2(Z,`${A}/${Y}`,J[Y]);return J}function lY(w,z,A,U){let W=q2(w,A,U);if(!r(U))return W;let $=Object.getOwnPropertyNames(w.patternProperties)[0],X=new RegExp($),Q={...W};for(let L of Object.getOwnPropertyNames(U))if(X.test(L))Q[L]=X1(w.patternProperties[$],z,`${A}/${L}`,Q[L]);if(!T0(w.additionalProperties))return Q;let Z=Object.getOwnPropertyNames(Q),J=w.additionalProperties,Y={...Q};for(let L of Z)if(!X.test(L))Y[L]=q2(J,`${A}/${L}`,Y[L]);return Y}function sY(w,z,A,U){let W=Y0(w,z),$=X1(W,z,A,U);return q2(w,A,$)}function rY(w,z,A,U){let W=Y0(w,z),$=X1(W,z,A,U);return q2(w,A,$)}function aY(w,z,A,U){let W=q2(w,A,U);return v(w.items)?w.items.map(($,X)=>X1($,z,`${A}/${X}`,W[X])):[]}function eY(w,z,A,U){for(let W of w.anyOf){if(!a(W,z,U))continue;let $=X1(W,z,A,U);return q2(w,A,$)}for(let W of w.anyOf){let $=X1(W,z,A,U);if(!a(w,z,$))continue;return q2(w,A,$)}return q2(w,A,U)}function X1(w,z,A,U){let W=e0(w,z),$=w;switch(w[b]){case"Array":return vY($,W,A,U);case"Import":return oY($,W,A,U);case"Intersect":return uY($,W,A,U);case"Not":return mY($,W,A,U);case"Object":return pY($,W,A,U);case"Record":return lY($,W,A,U);case"Ref":return sY($,W,A,U);case"This":return rY($,W,A,U);case"Tuple":return aY($,W,A,U);case"Union":return eY($,W,A,U);default:return q2($,A,U)}}function z4(w,z,A){return X1(w,z,"",A)}function wq(w,z){return N0(w)||A2(w.items,z)}function zq(w,z){return N0(w)||A2(w.items,z)}function Aq(w,z){return N0(w)||A2(w.returns,z)||w.parameters.some((A)=>A2(A,z))}function Uq(w,z){return N0(w)||A2(w.returns,z)||w.parameters.some((A)=>A2(A,z))}function Wq(w,z){return N0(w)||N0(w.unevaluatedProperties)||w.allOf.some((A)=>A2(A,z))}function $q(w,z){return N0(w)||A2(w.items,z)}function Xq(w,z){return N0(w)||A2(w.not,z)}function Qq(w,z){return N0(w)||Object.values(w.properties).some((A)=>A2(A,z))||T0(w.additionalProperties)&&A2(w.additionalProperties,z)}function Zq(w,z){return N0(w)||A2(w.item,z)}function Jq(w,z){let A=Object.getOwnPropertyNames(w.patternProperties)[0],U=w.patternProperties[A];return N0(w)||A2(U,z)||T0(w.additionalProperties)&&N0(w.additionalProperties)}function Yq(w,z){if(N0(w))return!0;return A2(Y0(w,z),z)}function qq(w,z){if(N0(w))return!0;return A2(Y0(w,z),z)}function Bq(w,z){return N0(w)||!k0(w.items)&&w.items.some((A)=>A2(A,z))}function Mq(w,z){return N0(w)||w.anyOf.some((A)=>A2(A,z))}function A2(w,z){let A=e0(w,z),U=w;if(w.$id&&k5.has(w.$id))return!1;if(w.$id)k5.add(w.$id);switch(w[b]){case"Array":return wq(U,A);case"AsyncIterator":return zq(U,A);case"Constructor":return Aq(U,A);case"Function":return Uq(U,A);case"Intersect":return Wq(U,A);case"Iterator":return $q(U,A);case"Not":return Xq(U,A);case"Object":return Qq(U,A);case"Promise":return Zq(U,A);case"Record":return Jq(U,A);case"Ref":return Yq(U,A);case"This":return qq(U,A);case"Tuple":return Bq(U,A);case"Union":return Mq(U,A);default:return N0(w)}}var k5=new Set;function d1(w,z){return k5.clear(),A2(w,z)}class XA{constructor(w,z,A,U){this.schema=w,this.references=z,this.checkFunc=A,this.code=U,this.hasTransform=d1(w,z)}Code(){return this.code}Schema(){return this.schema}References(){return this.references}Errors(w){return S1(this.schema,this.references,w)}Check(w){return this.checkFunc(w)}Decode(w){if(!this.checkFunc(w))throw new T4(this.schema,w,this.Errors(w).First());return this.hasTransform?w4(this.schema,this.references,w):w}Encode(w){let z=this.hasTransform?z4(this.schema,this.references,w):w;if(!this.checkFunc(z))throw new i4(this.schema,w,this.Errors(w).First());return z}}var c1;(function(w){function z($){return $===36}w.DollarSign=z;function A($){return $===95}w.IsUnderscore=A;function U($){return $>=65&&$<=90||$>=97&&$<=122}w.IsAlpha=U;function W($){return $>=48&&$<=57}w.IsNumeric=W})(c1||(c1={}));var kw;(function(w){function z($){if($.length===0)return!1;return c1.IsNumeric($.charCodeAt(0))}function A($){if(z($))return!1;for(let X=0;X<$.length;X++){let Q=$.charCodeAt(X);if(!(c1.IsAlpha(Q)||c1.IsNumeric(Q)||c1.DollarSign(Q)||c1.IsUnderscore(Q)))return!1}return!0}function U($){return $.replace(/'/g,"\\'")}function W($,X){return A(X)?`${$}.${X}`:`${$}['${U(X)}']`}w.Encode=W})(kw||(kw={}));var V5;(function(w){function z(A){let U=[];for(let W=0;W<A.length;W++){let $=A.charCodeAt(W);if(c1.IsNumeric($)||c1.IsAlpha($))U.push(A.charAt(W));else U.push(`_${$}_`)}return U.join("").replace(/__/g,"_")}w.Encode=z})(V5||(V5={}));var g5;(function(w){function z(A){return A.replace(/'/g,"\\'")}w.Escape=z})(g5||(g5={}));class QA extends n{constructor(w){super("Unknown type");this.schema=w}}class T5 extends n{constructor(w){super("Preflight validation check failed to guard for the given schema");this.schema=w}}var _6;(function(w){function z(X,Q,Z){return I0.ExactOptionalPropertyTypes?`('${Q}' in ${X} ? ${Z} : true)`:`(${kw.Encode(X,Q)} !== undefined ? ${Z} : true)`}w.IsExactOptionalProperty=z;function A(X){return!I0.AllowArrayObject?`(typeof ${X} === 'object' && ${X} !== null && !Array.isArray(${X}))`:`(typeof ${X} === 'object' && ${X} !== null)`}w.IsObjectLike=A;function U(X){return!I0.AllowArrayObject?`(typeof ${X} === 'object' && ${X} !== null && !Array.isArray(${X}) && !(${X} instanceof Date) && !(${X} instanceof Uint8Array))`:`(typeof ${X} === 'object' && ${X} !== null && !(${X} instanceof Date) && !(${X} instanceof Uint8Array))`}w.IsRecordLike=U;function W(X){return I0.AllowNaN?`typeof ${X} === 'number'`:`Number.isFinite(${X})`}w.IsNumberLike=W;function $(X){return I0.AllowNullVoid?`(${X} === undefined || ${X} === null)`:`${X} === undefined`}w.IsVoidLike=$})(_6||(_6={}));var w6;(function(w){function z(B){return B[b]==="Any"||B[b]==="Unknown"}function*A(B,j,H){yield"true"}function*U(B,j,H){yield`Array.isArray(${H})`;let[i,E]=[P("value","any"),P("acc","number")];if(d(B.maxItems))yield`${H}.length <= ${B.maxItems}`;if(d(B.minItems))yield`${H}.length >= ${B.minItems}`;let k=L2(B.items,j,"value");if(yield`${H}.every((${i}) => ${k})`,g0(B.contains)||d(B.minContains)||d(B.maxContains)){let K0=g0(B.contains)?B.contains:H0(),P2=L2(K0,j,"value"),O1=d(B.minContains)?[`(count >= ${B.minContains})`]:[],z1=d(B.maxContains)?[`(count <= ${B.maxContains})`]:[],H1=`const count = value.reduce((${E}, ${i}) => ${P2} ? acc + 1 : acc, 0)`,Uw=["(count > 0)",...O1,...z1].join(" && ");yield`((${i}) => { ${H1}; return ${Uw}})(${H})`}if(B.uniqueItems===!0)yield`((${i}) => { 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 } )(${H})`}function*W(B,j,H){yield`(typeof value === 'object' && Symbol.asyncIterator in ${H})`}function*$(B,j,H){if(yield`(typeof ${H} === 'bigint')`,U2(B.exclusiveMaximum))yield`${H} < BigInt(${B.exclusiveMaximum})`;if(U2(B.exclusiveMinimum))yield`${H} > BigInt(${B.exclusiveMinimum})`;if(U2(B.maximum))yield`${H} <= BigInt(${B.maximum})`;if(U2(B.minimum))yield`${H} >= BigInt(${B.minimum})`;if(U2(B.multipleOf))yield`(${H} % BigInt(${B.multipleOf})) === 0`}function*X(B,j,H){yield`(typeof ${H} === 'boolean')`}function*Q(B,j,H){yield*m0(B.returns,j,`${H}.prototype`)}function*Z(B,j,H){if(yield`(${H} instanceof Date) && Number.isFinite(${H}.getTime())`,d(B.exclusiveMaximumTimestamp))yield`${H}.getTime() < ${B.exclusiveMaximumTimestamp}`;if(d(B.exclusiveMinimumTimestamp))yield`${H}.getTime() > ${B.exclusiveMinimumTimestamp}`;if(d(B.maximumTimestamp))yield`${H}.getTime() <= ${B.maximumTimestamp}`;if(d(B.minimumTimestamp))yield`${H}.getTime() >= ${B.minimumTimestamp}`;if(d(B.multipleOfTimestamp))yield`(${H}.getTime() % ${B.multipleOfTimestamp}) === 0`}function*J(B,j,H){yield`(typeof ${H} === 'function')`}function*Y(B,j,H){let i=globalThis.Object.getOwnPropertyNames(B.$defs).reduce((E,k)=>{return[...E,B.$defs[k]]},[]);yield*m0(K2(B.$ref),[...j,...i],H)}function*L(B,j,H){if(yield`Number.isInteger(${H})`,d(B.exclusiveMaximum))yield`${H} < ${B.exclusiveMaximum}`;if(d(B.exclusiveMinimum))yield`${H} > ${B.exclusiveMinimum}`;if(d(B.maximum))yield`${H} <= ${B.maximum}`;if(d(B.minimum))yield`${H} >= ${B.minimum}`;if(d(B.multipleOf))yield`(${H} % ${B.multipleOf}) === 0`}function*_(B,j,H){let i=B.allOf.map((E)=>L2(E,j,H)).join(" && ");if(B.unevaluatedProperties===!1){let E=b2(`${new RegExp(k1(B))};`),k=`Object.getOwnPropertyNames(${H}).every(key => ${E}.test(key))`;yield`(${i} && ${k})`}else if(g0(B.unevaluatedProperties)){let E=b2(`${new RegExp(k1(B))};`),k=`Object.getOwnPropertyNames(${H}).every(key => ${E}.test(key) || ${L2(B.unevaluatedProperties,j,`${H}[key]`)})`;yield`(${i} && ${k})`}else yield`(${i})`}function*G(B,j,H){yield`(typeof value === 'object' && Symbol.iterator in ${H})`}function*O(B,j,H){if(typeof B.const==="number"||typeof B.const==="boolean")yield`(${H} === ${B.const})`;else yield`(${H} === '${g5.Escape(B.const)}')`}function*C(B,j,H){yield"false"}function*q(B,j,H){yield`(!${L2(B.not,j,H)})`}function*o(B,j,H){yield`(${H} === null)`}function*W0(B,j,H){if(yield _6.IsNumberLike(H),d(B.exclusiveMaximum))yield`${H} < ${B.exclusiveMaximum}`;if(d(B.exclusiveMinimum))yield`${H} > ${B.exclusiveMinimum}`;if(d(B.maximum))yield`${H} <= ${B.maximum}`;if(d(B.minimum))yield`${H} >= ${B.minimum}`;if(d(B.multipleOf))yield`(${H} % ${B.multipleOf}) === 0`}function*L0(B,j,H){if(yield _6.IsObjectLike(H),d(B.minProperties))yield`Object.getOwnPropertyNames(${H}).length >= ${B.minProperties}`;if(d(B.maxProperties))yield`Object.getOwnPropertyNames(${H}).length <= ${B.maxProperties}`;let i=Object.getOwnPropertyNames(B.properties);for(let E of i){let k=kw.Encode(H,E),K0=B.properties[E];if(B.required&&B.required.includes(E)){if(yield*m0(K0,j,k),g1(K0)||z(K0))yield`('${E}' in ${H})`}else{let P2=L2(K0,j,k);yield _6.IsExactOptionalProperty(H,E,P2)}}if(B.additionalProperties===!1)if(B.required&&B.required.length===i.length)yield`Object.getOwnPropertyNames(${H}).length === ${i.length}`;else{let E=`[${i.map((k)=>`'${k}'`).join(", ")}]`;yield`Object.getOwnPropertyNames(${H}).every(key => ${E}.includes(key))`}if(typeof B.additionalProperties==="object"){let E=L2(B.additionalProperties,j,`${H}[key]`),k=`[${i.map((K0)=>`'${K0}'`).join(", ")}]`;yield`(Object.getOwnPropertyNames(${H}).every(key => ${k}.includes(key) || ${E}))`}}function*c(B,j,H){yield`(typeof value === 'object' && typeof ${H}.then === 'function')`}function*e(B,j,H){if(yield _6.IsRecordLike(H),d(B.minProperties))yield`Object.getOwnPropertyNames(${H}).length >= ${B.minProperties}`;if(d(B.maxProperties))yield`Object.getOwnPropertyNames(${H}).length <= ${B.maxProperties}`;let[i,E]=Object.entries(B.patternProperties)[0],k=b2(`${new RegExp(i)}`),K0=L2(E,j,"value"),P2=g0(B.additionalProperties)?L2(B.additionalProperties,j,H):B.additionalProperties===!1?"false":"true",O1=`(${k}.test(key) ? ${K0} : ${P2})`;yield`(Object.entries(${H}).every(([key, value]) => ${O1}))`}function*f(B,j,H){let i=Y0(B,j);if(p0.functions.has(B.$ref))return yield`${L4(B.$ref)}(${H})`;yield*m0(i,j,H)}function*t(B,j,H){let i=b2(`${new RegExp(B.source,B.flags)};`);if(yield`(typeof ${H} === 'string')`,d(B.maxLength))yield`${H}.length <= ${B.maxLength}`;if(d(B.minLength))yield`${H}.length >= ${B.minLength}`;yield`${i}.test(${H})`}function*K(B,j,H){if(yield`(typeof ${H} === 'string')`,d(B.maxLength))yield`${H}.length <= ${B.maxLength}`;if(d(B.minLength))yield`${H}.length >= ${B.minLength}`;if(B.pattern!==void 0)yield`${b2(`${new RegExp(B.pattern)};`)}.test(${H})`;if(B.format!==void 0)yield`format('${B.format}', ${H})`}function*l(B,j,H){yield`(typeof ${H} === 'symbol')`}function*D0(B,j,H){yield`(typeof ${H} === 'string')`,yield`${b2(`${new RegExp(B.pattern)};`)}.test(${H})`}function*s(B,j,H){yield`${L4(B.$ref)}(${H})`}function*P1(B,j,H){if(yield`Array.isArray(${H})`,B.items===void 0)return yield`${H}.length === 0`;yield`(${H}.length === ${B.maxItems})`;for(let i=0;i<B.items.length;i++)yield`${L2(B.items[i],j,`${H}[${i}]`)}`}function*R0(B,j,H){yield`${H} === undefined`}function*v1(B,j,H){yield`(${B.anyOf.map((E)=>L2(E,j,H)).join(" || ")})`}function*f2(B,j,H){if(yield`${H} instanceof Uint8Array`,d(B.maxByteLength))yield`(${H}.length <= ${B.maxByteLength})`;if(d(B.minByteLength))yield`(${H}.length >= ${B.minByteLength})`}function*q6(B,j,H){yield"true"}function*z5(B,j,H){yield _6.IsVoidLike(H)}function*I6(B,j,H){let i=p0.instances.size;p0.instances.set(i,B),yield`kind('${B[b]}', ${i}, ${H})`}function*m0(B,j,H,i=!0){let E=Q0(B.$id)?[...j,B]:j,k=B;if(i&&Q0(B.$id)){let K0=L4(B.$id);if(p0.functions.has(K0))return yield`${K0}(${H})`;else{p0.functions.set(K0,"<deferred>");let P2=F(K0,B,j,"value",!1);return p0.functions.set(K0,P2),yield`${K0}(${H})`}}switch(k[b]){case"Any":return yield*A(k,E,H);case"Array":return yield*U(k,E,H);case"AsyncIterator":return yield*W(k,E,H);case"BigInt":return yield*$(k,E,H);case"Boolean":return yield*X(k,E,H);case"Constructor":return yield*Q(k,E,H);case"Date":return yield*Z(k,E,H);case"Function":return yield*J(k,E,H);case"Import":return yield*Y(k,E,H);case"Integer":return yield*L(k,E,H);case"Intersect":return yield*_(k,E,H);case"Iterator":return yield*G(k,E,H);case"Literal":return yield*O(k,E,H);case"Never":return yield*C(k,E,H);case"Not":return yield*q(k,E,H);case"Null":return yield*o(k,E,H);case"Number":return yield*W0(k,E,H);case"Object":return yield*L0(k,E,H);case"Promise":return yield*c(k,E,H);case"Record":return yield*e(k,E,H);case"Ref":return yield*f(k,E,H);case"RegExp":return yield*t(k,E,H);case"String":return yield*K(k,E,H);case"Symbol":return yield*l(k,E,H);case"TemplateLiteral":return yield*D0(k,E,H);case"This":return yield*s(k,E,H);case"Tuple":return yield*P1(k,E,H);case"Undefined":return yield*R0(k,E,H);case"Union":return yield*v1(k,E,H);case"Uint8Array":return yield*f2(k,E,H);case"Unknown":return yield*q6(k,E,H);case"Void":return yield*z5(k,E,H);default:if(!c0.Has(k[b]))throw new QA(B);return yield*I6(k,E,H)}}let p0={language:"javascript",functions:new Map,variables:new Map,instances:new Map};function L2(B,j,H,i=!0){return`(${[...m0(B,j,H,i)].join(" && ")})`}function L4(B){return`check_${V5.Encode(B)}`}function b2(B){let j=`local_${p0.variables.size}`;return p0.variables.set(j,`const ${j} = ${B}`),j}function F(B,j,H,i,E=!0){let[k,K0]=[`
|
|
2
|
+
`,(H1)=>"".padStart(H1," ")],P2=P("value","any"),O1=R("boolean"),z1=[...m0(j,H,i,E)].map((H1)=>`${K0(4)}${H1}`).join(` &&${k}`);return`function ${B}(${P2})${O1} {${k}${K0(2)}return (${k}${z1}${k}${K0(2)})
|
|
3
|
+
}`}function P(B,j){let H=p0.language==="typescript"?`: ${j}`:"";return`${B}${H}`}function R(B){return p0.language==="typescript"?`: ${B}`:""}function V(B,j,H){let i=F("check",B,j,"value"),E=P("value","any"),k=R("boolean"),K0=[...p0.functions.values()],P2=[...p0.variables.values()],O1=Q0(B.$id)?`return function check(${E})${k} {
|
|
4
|
+
return ${L4(B.$id)}(value)
|
|
5
|
+
}`:`return ${i}`;return[...P2,...K0,O1].join(`
|
|
6
|
+
`)}function u(...B){let j={language:"javascript"},[H,i,E]=B.length===2&&v(B[1])?[B[0],B[1],j]:B.length===2&&!v(B[1])?[B[0],[],B[1]]:B.length===3?[B[0],B[1],B[2]]:B.length===1?[B[0],[],j]:[null,[],j];if(p0.language=E.language,p0.variables.clear(),p0.functions.clear(),p0.instances.clear(),!g0(H))throw new T5(H);for(let k of i)if(!g0(k))throw new T5(k);return V(H,i,E)}w.Code=u;function $0(B,j=[]){let H=u(B,j,{language:"javascript"}),i=globalThis.Function("kind","format","hash",H),E=new Map(p0.instances);function k(z1,H1,Uw){if(!c0.Has(z1)||!E.has(H1))return!1;let DW=c0.Get(z1),_W=E.get(H1);return DW(_W,Uw)}function K0(z1,H1){if(!O0.Has(z1))return!1;return O0.Get(z1)(H1)}function P2(z1){return e1(z1)}let O1=i(k,K0,P2);return new XA(B,j,O1,H)}w.Compile=$0})(w6||(w6={}));var Hq=function(w,z,A,U,W){if(U==="m")throw new TypeError("Private method is not writable");if(U==="a"&&!W)throw new TypeError("Private accessor was defined without a setter");if(typeof z==="function"?w!==z||!W:!z.has(w))throw new TypeError("Cannot write private member to an object whose class did not declare it");return U==="a"?W.call(w,A):W?W.value=A:z.set(w,A),A},JA=function(w,z,A,U){if(A==="a"&&!U)throw new TypeError("Private accessor was defined without a getter");if(typeof z==="function"?w!==z||!U:!z.has(w))throw new TypeError("Cannot read private member from an object whose class did not declare it");return A==="m"?U:A==="a"?U.call(w):U?U.value:z.get(w)},i5,Vw,YA;class qA extends n{constructor(w){let z=w.First();super(z===void 0?"Invalid Value":z.message);i5.add(this),Vw.set(this,void 0),Hq(this,Vw,w,"f"),this.error=z}Errors(){return new D6(JA(this,i5,"m",YA).call(this))}}Vw=new WeakMap,i5=new WeakSet,YA=function*w(){if(this.error)yield this.error;yield*JA(this,Vw,"f")};function ZA(w,z,A){if(a(w,z,A))return;throw new qA(S1(w,z,A))}function gw(...w){return w.length===3?ZA(w[0],w[1],w[2]):ZA(w[0],[],w[1])}function Gq(w){let z={};for(let A of Object.getOwnPropertyNames(w))z[A]=q0(w[A]);for(let A of Object.getOwnPropertySymbols(w))z[A]=q0(w[A]);return z}function Lq(w){return w.map((z)=>q0(z))}function bq(w){return w.slice()}function Nq(w){return new Map(q0([...w.entries()]))}function Sq(w){return new Set(q0([...w.entries()]))}function Dq(w){return new Date(w.toISOString())}function _q(w){return w}function q0(w){if(v(w))return Lq(w);if(S2(w))return Dq(w);if(c2(w))return bq(w);if(Fz(w))return Nq(w);if(xz(w))return Sq(w);if(r(w))return Gq(w);if(k2(w))return _q(w);throw new Error("ValueClone: Unable to clone value")}class l2 extends n{constructor(w,z){super(z);this.schema=w}}function B0(w){return o1(w)?w():q0(w)}function Pq(w,z){if(y(w,"default"))return B0(w.default);else return{}}function Oq(w,z){if(w.uniqueItems===!0&&!y(w,"default"))throw new l2(w,"Array with the uniqueItems constraint requires a default value");else if("contains"in w&&!y(w,"default"))throw new l2(w,"Array with the contains constraint requires a default value");else if("default"in w)return B0(w.default);else if(w.minItems!==void 0)return Array.from({length:w.minItems}).map((A)=>{return x2(w.items,z)});else return[]}function Cq(w,z){if(y(w,"default"))return B0(w.default);else return async function*(){}()}function Rq(w,z){if(y(w,"default"))return B0(w.default);else return BigInt(0)}function Kq(w,z){if(y(w,"default"))return B0(w.default);else return!1}function jq(w,z){if(y(w,"default"))return B0(w.default);else{let A=x2(w.returns,z);if(typeof A==="object"&&!Array.isArray(A))return class{constructor(){for(let[U,W]of Object.entries(A)){let $=this;$[U]=W}}};else return class{}}}function Fq(w,z){if(y(w,"default"))return B0(w.default);else if(w.minimumTimestamp!==void 0)return new Date(w.minimumTimestamp);else return new Date}function xq(w,z){if(y(w,"default"))return B0(w.default);else return()=>x2(w.returns,z)}function Eq(w,z){let A=globalThis.Object.values(w.$defs),U=w.$defs[w.$ref];return x2(U,[...z,...A])}function Iq(w,z){if(y(w,"default"))return B0(w.default);else if(w.minimum!==void 0)return w.minimum;else return 0}function fq(w,z){if(y(w,"default"))return B0(w.default);else{let A=w.allOf.reduce((U,W)=>{let $=x2(W,z);return typeof $==="object"?{...U,...$}:$},{});if(!a(w,z,A))throw new l2(w,"Intersect produced invalid value. Consider using a default value.");return A}}function kq(w,z){if(y(w,"default"))return B0(w.default);else return function*(){}()}function Vq(w,z){if(y(w,"default"))return B0(w.default);else return w.const}function gq(w,z){if(y(w,"default"))return B0(w.default);else throw new l2(w,"Never types cannot be created. Consider using a default value.")}function Tq(w,z){if(y(w,"default"))return B0(w.default);else throw new l2(w,"Not types must have a default value")}function iq(w,z){if(y(w,"default"))return B0(w.default);else return null}function dq(w,z){if(y(w,"default"))return B0(w.default);else if(w.minimum!==void 0)return w.minimum;else return 0}function cq(w,z){if(y(w,"default"))return B0(w.default);else{let A=new Set(w.required),U={};for(let[W,$]of Object.entries(w.properties)){if(!A.has(W))continue;U[W]=x2($,z)}return U}}function nq(w,z){if(y(w,"default"))return B0(w.default);else return Promise.resolve(x2(w.item,z))}function hq(w,z){let[A,U]=Object.entries(w.patternProperties)[0];if(y(w,"default"))return B0(w.default);else if(!(A===I1||A===E1)){let W=A.slice(1,A.length-1).split("|"),$={};for(let X of W)$[X]=x2(U,z);return $}else return{}}function tq(w,z){if(y(w,"default"))return B0(w.default);else return x2(Y0(w,z),z)}function yq(w,z){if(y(w,"default"))return B0(w.default);else throw new l2(w,"RegExp types cannot be created. Consider using a default value.")}function vq(w,z){if(w.pattern!==void 0)if(!y(w,"default"))throw new l2(w,"String types with patterns must specify a default value");else return B0(w.default);else if(w.format!==void 0)if(!y(w,"default"))throw new l2(w,"String types with formats must specify a default value");else return B0(w.default);else if(y(w,"default"))return B0(w.default);else if(w.minLength!==void 0)return Array.from({length:w.minLength}).map(()=>" ").join("");else return""}function oq(w,z){if(y(w,"default"))return B0(w.default);else if("value"in w)return Symbol.for(w.value);else return Symbol()}function uq(w,z){if(y(w,"default"))return B0(w.default);if(!Lw(w))throw new l2(w,"Can only create template literals that produce a finite variants. Consider using a default value.");return h6(w)[0]}function mq(w,z){if(BA++>zB)throw new l2(w,"Cannot create recursive type as it appears possibly infinite. Consider using a default.");if(y(w,"default"))return B0(w.default);else return x2(Y0(w,z),z)}function pq(w,z){if(y(w,"default"))return B0(w.default);if(w.items===void 0)return[];else return Array.from({length:w.minItems}).map((A,U)=>x2(w.items[U],z))}function lq(w,z){if(y(w,"default"))return B0(w.default);else return}function sq(w,z){if(y(w,"default"))return B0(w.default);else if(w.anyOf.length===0)throw new Error("ValueCreate.Union: Cannot create Union with zero variants");else return x2(w.anyOf[0],z)}function rq(w,z){if(y(w,"default"))return B0(w.default);else if(w.minByteLength!==void 0)return new Uint8Array(w.minByteLength);else return new Uint8Array(0)}function aq(w,z){if(y(w,"default"))return B0(w.default);else return{}}function eq(w,z){if(y(w,"default"))return B0(w.default);else return}function wB(w,z){if(y(w,"default"))return B0(w.default);else throw new Error("User defined types must specify a default value")}function x2(w,z){let A=e0(w,z),U=w;switch(U[b]){case"Any":return Pq(U,A);case"Array":return Oq(U,A);case"AsyncIterator":return Cq(U,A);case"BigInt":return Rq(U,A);case"Boolean":return Kq(U,A);case"Constructor":return jq(U,A);case"Date":return Fq(U,A);case"Function":return xq(U,A);case"Import":return Eq(U,A);case"Integer":return Iq(U,A);case"Intersect":return fq(U,A);case"Iterator":return kq(U,A);case"Literal":return Vq(U,A);case"Never":return gq(U,A);case"Not":return Tq(U,A);case"Null":return iq(U,A);case"Number":return dq(U,A);case"Object":return cq(U,A);case"Promise":return nq(U,A);case"Record":return hq(U,A);case"Ref":return tq(U,A);case"RegExp":return yq(U,A);case"String":return vq(U,A);case"Symbol":return oq(U,A);case"TemplateLiteral":return uq(U,A);case"This":return mq(U,A);case"Tuple":return pq(U,A);case"Undefined":return lq(U,A);case"Union":return sq(U,A);case"Uint8Array":return rq(U,A);case"Unknown":return aq(U,A);case"Void":return eq(U,A);default:if(!c0.Has(U[b]))throw new l2(U,"Unknown type");return wB(U,A)}}var zB=512,BA=0;function s2(...w){return BA=0,w.length===2?x2(w[0],w[1]):x2(w[0],[])}class d5 extends n{constructor(w,z){super(z);this.schema=w}}function AB(w,z,A){if(w[b]==="Object"&&typeof A==="object"&&!K1(A)){let U=w,W=Object.getOwnPropertyNames(A),$=Object.entries(U.properties),[X,Q]=[1/$.length,$.length];return $.reduce((Z,[J,Y])=>{let L=Y[b]==="Literal"&&Y.const===A[J]?Q:0,_=a(Y,z,A[J])?X:0,G=W.includes(J)?X:0;return Z+(L+_+G)},0)}else return a(w,z,A)?1:0}function UB(w,z,A){let U=w.anyOf.map((X)=>Y0(X,z)),[W,$]=[U[0],0];for(let X of U){let Q=AB(X,z,A);if(Q>$)W=X,$=Q}return W}function WB(w,z,A){if("default"in w)return typeof A==="function"?w.default:q0(w.default);else{let U=UB(w,z,A);return c5(U,z,A)}}function $B(w,z,A){return a(w,z,A)?q0(A):s2(w,z)}function XB(w,z,A){return a(w,z,A)?A:s2(w,z)}function QB(w,z,A){if(a(w,z,A))return q0(A);let U=v(A)?q0(A):s2(w,z),W=d(w.minItems)&&U.length<w.minItems?[...U,...Array.from({length:w.minItems-U.length},()=>null)]:U,X=(d(w.maxItems)&&W.length>w.maxItems?W.slice(0,w.maxItems):W).map((Z)=>Q1(w.items,z,Z));if(w.uniqueItems!==!0)return X;let Q=[...new Set(X)];if(!a(w,z,Q))throw new d5(w,"Array cast produced invalid data due to uniqueItems constraint");return Q}function ZB(w,z,A){if(a(w,z,A))return s2(w,z);let U=new Set(w.returns.required||[]),W=function(){};for(let[$,X]of Object.entries(w.returns.properties)){if(!U.has($)&&A.prototype[$]===void 0)continue;W.prototype[$]=Q1(X,z,A.prototype[$])}return W}function JB(w,z,A){let U=globalThis.Object.values(w.$defs),W=w.$defs[w.$ref];return Q1(W,[...z,...U],A)}function YB(w,z,A){let U=s2(w,z),W=r(U)&&r(A)?{...U,...A}:A;return a(w,z,W)?W:s2(w,z)}function qB(w,z,A){throw new d5(w,"Never types cannot be cast")}function BB(w,z,A){if(a(w,z,A))return A;if(A===null||typeof A!=="object")return s2(w,z);let U=new Set(w.required||[]),W={};for(let[$,X]of Object.entries(w.properties)){if(!U.has($)&&A[$]===void 0)continue;W[$]=Q1(X,z,A[$])}if(typeof w.additionalProperties==="object"){let $=Object.getOwnPropertyNames(w.properties);for(let X of Object.getOwnPropertyNames(A)){if($.includes(X))continue;W[X]=Q1(w.additionalProperties,z,A[X])}}return W}function MB(w,z,A){if(a(w,z,A))return q0(A);if(A===null||typeof A!=="object"||Array.isArray(A)||A instanceof Date)return s2(w,z);let U=Object.getOwnPropertyNames(w.patternProperties)[0],W=w.patternProperties[U],$={};for(let[X,Q]of Object.entries(A))$[X]=Q1(W,z,Q);return $}function HB(w,z,A){return Q1(Y0(w,z),z,A)}function GB(w,z,A){return Q1(Y0(w,z),z,A)}function LB(w,z,A){if(a(w,z,A))return q0(A);if(!v(A))return s2(w,z);if(w.items===void 0)return[];return w.items.map((U,W)=>Q1(U,z,A[W]))}function bB(w,z,A){return a(w,z,A)?q0(A):WB(w,z,A)}function Q1(w,z,A){let U=Q0(w.$id)?e0(w,z):z,W=w;switch(w[b]){case"Array":return QB(W,U,A);case"Constructor":return ZB(W,U,A);case"Import":return JB(W,U,A);case"Intersect":return YB(W,U,A);case"Never":return qB(W,U,A);case"Object":return BB(W,U,A);case"Record":return MB(W,U,A);case"Ref":return HB(W,U,A);case"This":return GB(W,U,A);case"Tuple":return LB(W,U,A);case"Union":return bB(W,U,A);case"Date":case"Symbol":case"Uint8Array":return $B(w,z,A);default:return XB(W,U,A)}}function c5(...w){return w.length===3?Q1(w[0],w[1],w[2]):Q1(w[0],[],w[1])}function NB(w){return m1(w)&&w[b]!=="Unsafe"}function SB(w,z,A){if(!v(A))return A;return A.map((U)=>E2(w.items,z,U))}function DB(w,z,A){let U=globalThis.Object.values(w.$defs),W=w.$defs[w.$ref];return E2(W,[...z,...U],A)}function _B(w,z,A){let U=w.unevaluatedProperties,$=w.allOf.map((Q)=>E2(Q,z,q0(A))).reduce((Q,Z)=>r(Z)?{...Q,...Z}:Z,{});if(!r(A)||!r($)||!m1(U))return $;let X=j2(w);for(let Q of Object.getOwnPropertyNames(A)){if(X.includes(Q))continue;if(a(U,z,A[Q]))$[Q]=E2(U,z,A[Q])}return $}function PB(w,z,A){if(!r(A)||v(A))return A;let U=w.additionalProperties;for(let W of Object.getOwnPropertyNames(A)){if(y(w.properties,W)){A[W]=E2(w.properties[W],z,A[W]);continue}if(m1(U)&&a(U,z,A[W])){A[W]=E2(U,z,A[W]);continue}delete A[W]}return A}function OB(w,z,A){if(!r(A))return A;let U=w.additionalProperties,W=Object.getOwnPropertyNames(A),[$,X]=Object.entries(w.patternProperties)[0],Q=new RegExp($);for(let Z of W){if(Q.test(Z)){A[Z]=E2(X,z,A[Z]);continue}if(m1(U)&&a(U,z,A[Z])){A[Z]=E2(U,z,A[Z]);continue}delete A[Z]}return A}function CB(w,z,A){return E2(Y0(w,z),z,A)}function RB(w,z,A){return E2(Y0(w,z),z,A)}function KB(w,z,A){if(!v(A))return A;if(k0(w.items))return[];let U=Math.min(A.length,w.items.length);for(let W=0;W<U;W++)A[W]=E2(w.items[W],z,A[W]);return A.length>U?A.slice(0,U):A}function jB(w,z,A){for(let U of w.anyOf)if(NB(U)&&a(U,z,A))return E2(U,z,A);return A}function E2(w,z,A){let U=Q0(w.$id)?e0(w,z):z,W=w;switch(W[b]){case"Array":return SB(W,U,A);case"Import":return DB(W,U,A);case"Intersect":return _B(W,U,A);case"Object":return PB(W,U,A);case"Record":return OB(W,U,A);case"Ref":return CB(W,U,A);case"This":return RB(W,U,A);case"Tuple":return KB(W,U,A);case"Union":return jB(W,U,A);default:return A}}function Tw(...w){return w.length===3?E2(w[0],w[1],w[2]):E2(w[0],[],w[1])}function iw(w){return Q0(w)&&!isNaN(w)&&!isNaN(parseFloat(w))}function FB(w){return U2(w)||G1(w)||d(w)}function d4(w){return w===!0||d(w)&&w===1||U2(w)&&w===BigInt("1")||Q0(w)&&(w.toLowerCase()==="true"||w==="1")}function c4(w){return w===!1||d(w)&&(w===0||Object.is(w,-0))||U2(w)&&w===BigInt("0")||Q0(w)&&(w.toLowerCase()==="false"||w==="0"||w==="-0")}function xB(w){return Q0(w)&&/^(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)$/i.test(w)}function EB(w){return Q0(w)&&/^(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)?$/i.test(w)}function IB(w){return Q0(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 fB(w){return Q0(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 kB(w){return Q0(w)&&/^\d\d\d\d-[0-1]\d-[0-3]\d$/i.test(w)}function VB(w,z){let A=HA(w);return A===z?A:w}function gB(w,z){let A=GA(w);return A===z?A:w}function TB(w,z){let A=MA(w);return A===z?A:w}function iB(w,z){return Q0(w.const)?VB(z,w.const):d(w.const)?gB(z,w.const):G1(w.const)?TB(z,w.const):z}function MA(w){return d4(w)?!0:c4(w)?!1:w}function dB(w){let z=(A)=>A.split(".")[0];return iw(w)?BigInt(z(w)):d(w)?BigInt(Math.trunc(w)):c4(w)?BigInt(0):d4(w)?BigInt(1):w}function HA(w){return j1(w)&&w.description!==void 0?w.description.toString():FB(w)?w.toString():w}function GA(w){return iw(w)?parseFloat(w):d4(w)?1:c4(w)?0:w}function cB(w){return iw(w)?parseInt(w):d(w)?w|0:d4(w)?1:c4(w)?0:w}function nB(w){return Q0(w)&&w.toLowerCase()==="null"?null:w}function hB(w){return Q0(w)&&w==="undefined"?void 0:w}function tB(w){return S2(w)?w:d(w)?new Date(w):d4(w)?new Date(1):c4(w)?new Date(0):iw(w)?new Date(parseInt(w)):EB(w)?new Date(`1970-01-01T${w}.000Z`):xB(w)?new Date(`1970-01-01T${w}`):fB(w)?new Date(`${w}.000Z`):IB(w)?new Date(w):kB(w)?new Date(`${w}T00:00:00.000Z`):w}function yB(w){return w}function vB(w,z,A){return(v(A)?A:[A]).map((W)=>Z1(w.items,z,W))}function oB(w,z,A){return dB(A)}function uB(w,z,A){return MA(A)}function mB(w,z,A){return tB(A)}function pB(w,z,A){let U=globalThis.Object.values(w.$defs),W=w.$defs[w.$ref];return Z1(W,[...z,...U],A)}function lB(w,z,A){return cB(A)}function sB(w,z,A){return w.allOf.reduce((U,W)=>Z1(W,z,U),A)}function rB(w,z,A){return iB(w,A)}function aB(w,z,A){return nB(A)}function eB(w,z,A){return GA(A)}function wM(w,z,A){if(!r(A))return A;for(let U of Object.getOwnPropertyNames(w.properties)){if(!y(A,U))continue;A[U]=Z1(w.properties[U],z,A[U])}return A}function zM(w,z,A){if(!r(A))return A;let W=Object.getOwnPropertyNames(w.patternProperties)[0],$=w.patternProperties[W];for(let[X,Q]of Object.entries(A))A[X]=Z1($,z,Q);return A}function AM(w,z,A){return Z1(Y0(w,z),z,A)}function UM(w,z,A){return HA(A)}function WM(w,z,A){return Q0(A)||d(A)?Symbol(A):A}function $M(w,z,A){return Z1(Y0(w,z),z,A)}function XM(w,z,A){if(!(v(A)&&!k0(w.items)))return A;return A.map((W,$)=>{return $<w.items.length?Z1(w.items[$],z,W):W})}function QM(w,z,A){return hB(A)}function ZM(w,z,A){for(let U of w.anyOf){let W=Z1(U,z,q0(A));if(!a(U,z,W))continue;return W}return A}function Z1(w,z,A){let U=e0(w,z),W=w;switch(w[b]){case"Array":return vB(W,U,A);case"BigInt":return oB(W,U,A);case"Boolean":return uB(W,U,A);case"Date":return mB(W,U,A);case"Import":return pB(W,U,A);case"Integer":return lB(W,U,A);case"Intersect":return sB(W,U,A);case"Literal":return rB(W,U,A);case"Null":return aB(W,U,A);case"Number":return eB(W,U,A);case"Object":return wM(W,U,A);case"Record":return zM(W,U,A);case"Ref":return AM(W,U,A);case"String":return UM(W,U,A);case"Symbol":return WM(W,U,A);case"This":return $M(W,U,A);case"Tuple":return XM(W,U,A);case"Undefined":return QM(W,U,A);case"Union":return ZM(W,U,A);default:return yB(A)}}function dw(...w){return w.length===3?Z1(w[0],w[1],w[2]):Z1(w[0],[],w[1])}function LA(...w){let[z,A,U]=w.length===3?[w[0],w[1],w[2]]:[w[0],[],w[1]];if(!a(z,A,U))throw new T4(z,U,S1(z,A,U).First());return d1(z,A)?w4(z,A,U):U}function n1(w,z){let A=y(w,"default")?w.default:void 0,U=o1(A)?A():q0(A);return k0(z)?U:r(z)&&r(U)?Object.assign(U,z):z}function n5(w){return m1(w)&&"default"in w}function JM(w,z,A){if(v(A)){for(let W=0;W<A.length;W++)A[W]=D2(w.items,z,A[W]);return A}let U=n1(w,A);if(!v(U))return U;for(let W=0;W<U.length;W++)U[W]=D2(w.items,z,U[W]);return U}function YM(w,z,A){return S2(A)?A:n1(w,A)}function qM(w,z,A){let U=globalThis.Object.values(w.$defs),W=w.$defs[w.$ref];return D2(W,[...z,...U],A)}function BM(w,z,A){let U=n1(w,A);return w.allOf.reduce((W,$)=>{let X=D2($,z,U);return r(X)?{...W,...X}:X},{})}function MM(w,z,A){let U=n1(w,A);if(!r(U))return U;let W=Object.getOwnPropertyNames(w.properties);for(let $ of W){let X=D2(w.properties[$],z,U[$]);if(k0(X))continue;U[$]=D2(w.properties[$],z,U[$])}if(!n5(w.additionalProperties))return U;for(let $ of Object.getOwnPropertyNames(U)){if(W.includes($))continue;U[$]=D2(w.additionalProperties,z,U[$])}return U}function HM(w,z,A){let U=n1(w,A);if(!r(U))return U;let W=w.additionalProperties,[$,X]=Object.entries(w.patternProperties)[0],Q=new RegExp($);for(let Z of Object.getOwnPropertyNames(U)){if(!(Q.test(Z)&&n5(X)))continue;U[Z]=D2(X,z,U[Z])}if(!n5(W))return U;for(let Z of Object.getOwnPropertyNames(U)){if(Q.test(Z))continue;U[Z]=D2(W,z,U[Z])}return U}function GM(w,z,A){return D2(Y0(w,z),z,n1(w,A))}function LM(w,z,A){return D2(Y0(w,z),z,A)}function bM(w,z,A){let U=n1(w,A);if(!v(U)||k0(w.items))return U;let[W,$]=[w.items,Math.max(w.items.length,U.length)];for(let X=0;X<$;X++)if(X<W.length)U[X]=D2(W[X],z,U[X]);return U}function NM(w,z,A){let U=n1(w,A);for(let W of w.anyOf){let $=D2(W,z,q0(U));if(a(W,z,$))return $}return U}function D2(w,z,A){let U=e0(w,z),W=w;switch(W[b]){case"Array":return JM(W,U,A);case"Date":return YM(W,U,A);case"Import":return qM(W,U,A);case"Intersect":return BM(W,U,A);case"Object":return MM(W,U,A);case"Record":return HM(W,U,A);case"Ref":return GM(W,U,A);case"This":return LM(W,U,A);case"Tuple":return bM(W,U,A);case"Union":return NM(W,U,A);default:return n1(W,A)}}function cw(...w){return w.length===3?D2(w[0],w[1],w[2]):D2(w[0],[],w[1])}var J1={};B6(J1,{ValuePointerRootSetError:()=>h5,ValuePointerRootDeleteError:()=>t5,Set:()=>SM,Has:()=>_M,Get:()=>PM,Format:()=>n4,Delete:()=>DM});class h5 extends n{constructor(w,z,A){super("Cannot set root value");this.value=w,this.path=z,this.update=A}}class t5 extends n{constructor(w,z){super("Cannot delete root value");this.value=w,this.path=z}}function bA(w){return w.indexOf("~")===-1?w:w.replace(/~1/g,"/").replace(/~0/g,"~")}function*n4(w){if(w==="")return;let[z,A]=[0,0];for(let U=0;U<w.length;U++)if(w.charAt(U)==="/")if(U===0)z=U+1;else A=U,yield bA(w.slice(z,A)),z=U+1;else A=U;yield bA(w.slice(z))}function SM(w,z,A){if(z==="")throw new h5(w,z,A);let[U,W,$]=[null,w,""];for(let X of n4(z)){if(W[X]===void 0)W[X]={};U=W,W=W[X],$=X}U[$]=A}function DM(w,z){if(z==="")throw new t5(w,z);let[A,U,W]=[null,w,""];for(let $ of n4(z)){if(U[$]===void 0||U[$]===null)return;A=U,U=U[$],W=$}if(Array.isArray(A)){let $=parseInt(W);A.splice($,1)}else delete A[W]}function _M(w,z){if(z==="")return!0;let[A,U,W]=[null,w,""];for(let $ of n4(z)){if(U[$]===void 0)return!1;A=U,U=U[$],W=$}return Object.getOwnPropertyNames(A).includes(W)}function PM(w,z){if(z==="")return w;let A=w;for(let U of n4(z)){if(A[U]===void 0)return;A=A[U]}return A}function OM(w,z){if(!r(z))return!1;let A=[...Object.keys(w),...Object.getOwnPropertySymbols(w)],U=[...Object.keys(z),...Object.getOwnPropertySymbols(z)];if(A.length!==U.length)return!1;return A.every((W)=>P6(w[W],z[W]))}function CM(w,z){return S2(z)&&w.getTime()===z.getTime()}function RM(w,z){if(!v(z)||w.length!==z.length)return!1;return w.every((A,U)=>P6(A,z[U]))}function KM(w,z){if(!c2(z)||w.length!==z.length||Object.getPrototypeOf(w).constructor.name!==Object.getPrototypeOf(z).constructor.name)return!1;return w.every((A,U)=>P6(A,z[U]))}function jM(w,z){return w===z}function P6(w,z){if(S2(w))return CM(w,z);if(c2(w))return KM(w,z);if(v(w))return RM(w,z);if(r(w))return OM(w,z);if(k2(w))return jM(w,z);throw new Error("ValueEquals: Unable to compare value")}var FM=S0({type:X0("insert"),path:t2(),value:V1()}),xM=S0({type:X0("update"),path:t2(),value:V1()}),EM=S0({type:X0("delete"),path:t2()}),SA=G0([FM,xM,EM]);class y5 extends n{constructor(w,z){super(z);this.value=w}}function nw(w,z){return{type:"update",path:w,value:z}}function DA(w,z){return{type:"insert",path:w,value:z}}function _A(w){return{type:"delete",path:w}}function NA(w){if(globalThis.Object.getOwnPropertySymbols(w).length>0)throw new y5(w,"Cannot diff objects with symbols")}function*IM(w,z,A){if(NA(z),NA(A),!J5(A))return yield nw(w,A);let U=globalThis.Object.getOwnPropertyNames(z),W=globalThis.Object.getOwnPropertyNames(A);for(let $ of W){if(y(z,$))continue;yield DA(`${w}/${$}`,A[$])}for(let $ of U){if(!y(A,$))continue;if(P6(z,A))continue;yield*hw(`${w}/${$}`,z[$],A[$])}for(let $ of U){if(y(A,$))continue;yield _A(`${w}/${$}`)}}function*fM(w,z,A){if(!v(A))return yield nw(w,A);for(let U=0;U<Math.min(z.length,A.length);U++)yield*hw(`${w}/${U}`,z[U],A[U]);for(let U=0;U<A.length;U++){if(U<z.length)continue;yield DA(`${w}/${U}`,A[U])}for(let U=z.length-1;U>=0;U--){if(U<A.length)continue;yield _A(`${w}/${U}`)}}function*kM(w,z,A){if(!c2(A)||z.length!==A.length||globalThis.Object.getPrototypeOf(z).constructor.name!==globalThis.Object.getPrototypeOf(A).constructor.name)return yield nw(w,A);for(let U=0;U<Math.min(z.length,A.length);U++)yield*hw(`${w}/${U}`,z[U],A[U])}function*VM(w,z,A){if(z===A)return;yield nw(w,A)}function*hw(w,z,A){if(J5(z))return yield*IM(w,z,A);if(v(z))return yield*fM(w,z,A);if(c2(z))return yield*kM(w,z,A);if(k2(z))return yield*VM(w,z,A);throw new y5(z,"Unable to diff value")}function PA(w,z){return[...hw("",w,z)]}function gM(w){return w.length>0&&w[0].path===""&&w[0].type==="update"}function TM(w){return w.length===0}function OA(w,z){if(gM(z))return q0(z[0].value);if(TM(z))return q0(w);let A=q0(w);for(let U of z)switch(U.type){case"insert":{J1.Set(A,U.path,U.value);break}case"update":{J1.Set(A,U.path,U.value);break}case"delete":{J1.Delete(A,U.path);break}}return A}function CA(...w){let[z,A,U]=w.length===3?[w[0],w[1],w[2]]:[w[0],[],w[1]],W=d1(z,A)?z4(z,A,U):U;if(!a(z,A,W))throw new i4(z,W,S1(z,A,W).First());return W}function tw(w){return r(w)&&!v(w)}class v5 extends n{constructor(w){super(w)}}function iM(w,z,A,U){if(!tw(A))J1.Set(w,z,q0(U));else{let W=Object.getOwnPropertyNames(A),$=Object.getOwnPropertyNames(U);for(let X of W)if(!$.includes(X))delete A[X];for(let X of $)if(!W.includes(X))A[X]=null;for(let X of $)o5(w,`${z}/${X}`,A[X],U[X])}}function dM(w,z,A,U){if(!v(A))J1.Set(w,z,q0(U));else{for(let W=0;W<U.length;W++)o5(w,`${z}/${W}`,A[W],U[W]);A.splice(U.length)}}function cM(w,z,A,U){if(c2(A)&&A.length===U.length)for(let W=0;W<A.length;W++)A[W]=U[W];else J1.Set(w,z,q0(U))}function nM(w,z,A,U){if(A===U)return;J1.Set(w,z,U)}function o5(w,z,A,U){if(v(U))return dM(w,z,A,U);if(c2(U))return cM(w,z,A,U);if(tw(U))return iM(w,z,A,U);if(k2(U))return nM(w,z,A,U)}function RA(w){return c2(w)||k2(w)}function hM(w,z){return tw(w)&&v(z)||v(w)&&tw(z)}function KA(w,z){if(RA(w)||RA(z))throw new v5("Only object and array types can be mutated at the root level");if(hM(w,z))throw new v5("Cannot assign due type mismatch of assignable values");o5(w,"",w,z)}class m5 extends n{constructor(w){super(w)}}var u5;(function(w){let z=new Map([["Clone",($,X,Q)=>q0(Q)],["Clean",($,X,Q)=>Tw($,X,Q)],["Default",($,X,Q)=>cw($,X,Q)],["Convert",($,X,Q)=>dw($,X,Q)],["Assert",($,X,Q)=>{return gw($,X,Q),Q}],["Decode",($,X,Q)=>d1($,X)?w4($,X,Q):Q],["Encode",($,X,Q)=>d1($,X)?z4($,X,Q):Q]]);function A($){z.delete($)}w.Delete=A;function U($,X){z.set($,X)}w.Set=U;function W($){return z.get($)}w.Get=W})(u5||(u5={}));var jA=["Clone","Clean","Default","Convert","Assert","Decode"];function tM(w,z,A,U){return w.reduce((W,$)=>{let X=u5.Get($);if(k0(X))throw new m5(`Unable to find Parse operation '${$}'`);return X(z,A,W)},U)}function FA(...w){let[z,A,U,W]=w.length===4?[w[0],w[1],w[2],w[3]]:w.length===3?v(w[0])?[w[0],w[1],[],w[2]]:[jA,w[0],w[1],w[2]]:w.length===2?[jA,w[0],[],w[1]]:(()=>{throw new m5("Invalid Arguments")})();return tM(z,A,U,W)}var p={};B6(p,{ValueErrorIterator:()=>D6,Patch:()=>OA,Parse:()=>FA,Mutate:()=>KA,Hash:()=>e1,Errors:()=>S1,Equal:()=>P6,Encode:()=>CA,Edit:()=>SA,Diff:()=>PA,Default:()=>cw,Decode:()=>LA,Create:()=>s2,Convert:()=>dw,Clone:()=>q0,Clean:()=>Tw,Check:()=>a,Cast:()=>c5,Assert:()=>gw});var yw={date:fA,time:p5(!0),"date-time":xA(!0),"iso-time":p5(!1),"iso-date-time":xA(!1),duration:/^P(?!$)((\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+S)?)?|(\d+W)?)$/,uri:sM,"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:UH,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:rM,int32:{type:"number",validate:wH},int64:{type:"number",validate:zH},float:{type:"number",validate:IA},double:{type:"number",validate:IA},password:!0,binary:!0};function yM(w){return w%4===0&&(w%100!==0||w%400===0)}var vM=/^(\d\d\d\d)-(\d\d)-(\d\d)$/,oM=[0,31,28,31,30,31,30,31,31,30,31,30,31];function fA(w){let z=vM.exec(w);if(!z)return!1;let A=+z[1],U=+z[2],W=+z[3];return U>=1&&U<=12&&W>=1&&W<=(U===2&&yM(A)?29:oM[U])}var uM=/^(\d\d):(\d\d):(\d\d(?:\.\d+)?)(z|([+-])(\d\d)(?::?(\d\d))?)?$/i;function p5(w){return function z(A){let U=uM.exec(A);if(!U)return!1;let W=+U[1],$=+U[2],X=+U[3],Q=U[4],Z=U[5]==="-"?-1:1,J=+(U[6]||0),Y=+(U[7]||0);if(J>23||Y>59||w&&!Q)return!1;if(W<=23&&$<=59&&X<60)return!0;let L=$-Y*Z,_=W-J*Z-(L<0?1:0);return(_===23||_===-1)&&(L===59||L===-1)&&X<61}}var mM=/t|\s/i;function xA(w){let z=p5(w);return function A(U){let W=U.split(mM);return W.length===2&&fA(W[0])&&z(W[1])}}var pM=/\/|:/,lM=/^(?:[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 sM(w){return pM.test(w)&&lM.test(w)}var EA=/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/gm;function rM(w){return EA.lastIndex=0,EA.test(w)}var aM=-2147483648,eM=2147483647;function wH(w){return Number.isInteger(w)&&w<=eM&&w>=aM}function zH(w){return Number.isInteger(w)}function IA(){return!0}var AH=/[^\\]\\Z/;function UH(w){if(AH.test(w))return!1;try{return new RegExp(w),!0}catch(z){return!1}}var vw="toJSON"in new Headers,A4=(w,z)=>{let A=new URL(w);return A.pathname=z,A.toString()},WH=(w)=>typeof w==="function"&&/^\s*class\s+/.test(w.toString())||w.toString().startsWith("[object ")&&w.toString()!=="[object Object]"||Q2(Object.getPrototypeOf(w)),l5=(w)=>w&&typeof w==="object"&&!Array.isArray(w),_2=(w,z,{skipKeys:A,override:U=!0}={})=>{if(!l5(w)||!l5(z))return w;for(let[W,$]of Object.entries(z)){if(A?.includes(W))continue;if(!l5($)||!(W in w)||WH($)){if(U||!(W in w))w[W]=$;continue}w[W]=_2(w[W],$,{skipKeys:A,override:U})}return w},$H=(w,z)=>{let{properties:A,...U}=w??{},{properties:W,...$}=z??{};return _2(U,$)},i0=(w=[],z=[])=>{if(!w)return[];if(!z)return w;let A=[],U=[];if(!Array.isArray(w))w=[w];if(!Array.isArray(z))z=[z];for(let W of w)if(A.push(W),W.checksum)U.push(W.checksum);for(let W of z)if(!U.includes(W.checksum))A.push(W);return A},XH=["start","request","parse","transform","resolve","beforeHandle","afterHandle","mapResponse","afterResponse","trace","error","stop","body","headers","params","query","response","type","detail"],QH=XH.reduce((w,z)=>(w[z]=!0,w),{}),VA=(w,z)=>{let A=(U)=>typeof U==="object"&&Object.keys(U).every(y4);if(A(w)&&A(z))return{...w,...z};else if(w&&!A(w)&&A(z))return{200:w,...z};return z??w},U4=(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:VA(w?.response,z?.response)}},r2=(w,z)=>{let{resolve:A,...U}=w??{},{resolve:W,...$}=z??{};return{...U,...$,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:VA(w?.response,z?.response),type:w?.type||z?.type,detail:_2(z?.detail??{},w?.detail??{}),parse:i0(w?.parse,z?.parse),transform:i0(w?.transform,z?.transform),beforeHandle:i0(i0(r0(A,"resolve"),w?.beforeHandle),i0(r0(W,"resolve"),z?.beforeHandle)),afterHandle:i0(w?.afterHandle,z?.afterHandle),mapResponse:i0(w?.mapResponse,z?.mapResponse),afterResponse:i0(w?.afterResponse,z?.afterResponse),trace:i0(w?.trace,z?.trace),error:i0(w?.error,z?.error)}},t4=(w,z,A=!0)=>{if(!Array.isArray(z))return B2(w,z,A);for(let U of z)w=B2(w,U,A);return w},B2=(w,z,A=!0)=>{if(!w)return w;if(z.untilObjectFound&&!A&&w.type==="object")return w;let U=z.from[b];if(w.oneOf){for(let X=0;X<w.oneOf.length;X++)w.oneOf[X]=B2(w.oneOf[X],z,A);return w}if(w.anyOf){for(let X=0;X<w.anyOf.length;X++)w.anyOf[X]=B2(w.anyOf[X],z,A);return w}if(w.allOf){for(let X=0;X<w.allOf.length;X++)w.allOf[X]=B2(w.allOf[X],z,A);return w}if(w.not){for(let X=0;X<w.not.length;X++)w.not[X]=B2(w.not[X],z,A);return w}let W=A&&!!z.excludeRoot;if(w[b]===U){let{anyOf:X,oneOf:Q,allOf:Z,not:J,properties:Y,items:L,..._}=w,G=z.to(_),O,C=(q)=>{if(Y&&q.type==="object"){let W0={};for(let[L0,c]of Object.entries(Y))W0[L0]=B2(c,z,!1);return{..._,...q,properties:W0}}if(L&&q.type==="array")return{..._,...q,items:B2(L,z,!1)};let o={..._,...q};if(delete o.required,Y&&q.type==="string"&&q.format==="ObjectString"&&q.default==="{}")O=x.ObjectString(Y,_),o.default=JSON.stringify(p.Create(x.Object(Y))),o.properties=Y;if(L&&q.type==="string"&&q.format==="ArrayString"&&q.default==="[]")O=x.ArrayString(L,_),o.default=JSON.stringify(p.Create(x.Array(L))),o.items=L;return o};if(W){if(Y){let q={};for(let[o,W0]of Object.entries(Y))q[o]=B2(W0,z,!1);return{..._,properties:q}}else if(L?.map)return{..._,items:L.map((q)=>B2(q,z,!1))};return _}if(G.anyOf)for(let q=0;q<G.anyOf.length;q++)G.anyOf[q]=C(G.anyOf[q]);else if(G.oneOf)for(let q=0;q<G.oneOf.length;q++)G.oneOf[q]=C(G.oneOf[q]);else if(G.allOf)for(let q=0;q<G.allOf.length;q++)G.allOf[q]=C(G.allOf[q]);else if(G.not)for(let q=0;q<G.not.length;q++)G.not[q]=C(G.not[q]);if(O)G[j0]=O[j0];if(G.anyOf||G.oneOf||G.allOf||G.not)return G;if(Y){let q={};for(let[o,W0]of Object.entries(Y))q[o]=B2(W0,z,!1);return{..._,...G,properties:q}}else if(L?.map)return{..._,...G,items:L.map((q)=>B2(q,z,!1))};return{..._,...G}}let $=w?.properties;if($&&A&&z.rootOnly!==!0)for(let[X,Q]of Object.entries($))switch(Q[b]){case U:let{anyOf:Z,oneOf:J,allOf:Y,not:L,type:_,...G}=Q,O=z.to(G);if(O.anyOf)for(let C=0;C<O.anyOf.length;C++)O.anyOf[C]={...G,...O.anyOf[C]};else if(O.oneOf)for(let C=0;C<O.oneOf.length;C++)O.oneOf[C]={...G,...O.oneOf[C]};else if(O.allOf)for(let C=0;C<O.allOf.length;C++)O.allOf[C]={...G,...O.allOf[C]};else if(O.not)for(let C=0;C<O.not.length;C++)O.not[C]={...G,...O.not[C]};$[X]={...G,...B2(G,z,!1)};break;case"Object":case"Union":$[X]=B2(Q,z,!1);break;default:if(Q.items)for(let C=0;C<Q.items.length;C++)Q.items[C]=B2(Q.items[C],z,!1);else if(Q.anyOf||Q.oneOf||Q.allOf||Q.not)$[X]=B2(Q,z,!1);break}return w},h4=(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},$2=(w,{models:z={},dynamic:A=!1,modules:U,normalize:W=!1,additionalProperties:$=!1,coerce:X=!1,additionalCoerce:Q=[]}={modules:x.Module({})})=>{if(!w)return;if(typeof w==="string"&&!(w in z))return;let Z=typeof w==="string"?U.Import(w)??z[w]:w;if(X||Q)if(X)Z=t4(Z,[{from:x.Ref(""),to:(Y)=>U.Import(Y.$ref)},{from:x.Number(),to:(Y)=>x.Numeric(Y),untilObjectFound:!0},{from:x.Boolean(),to:(Y)=>x.BooleanString(Y),untilObjectFound:!0},...Array.isArray(Q)?Q:[Q]]);else Z=t4(Z,[{from:x.Ref(""),to:(Y)=>U.Import(Y.$ref)},...Array.isArray(Q)?Q:[Q]]);if(Z.type==="object"&&"additionalProperties"in Z===!1)Z.additionalProperties=$;if(A){let Y={schema:Z,references:"",checkFunc:()=>{},code:"",Check:(L)=>p.Check(Z,L),Errors:(L)=>p.Errors(Z,L),Code:()=>"",Clean:h4(Z),Decode:(L)=>p.Decode(Z,L),Encode:(L)=>p.Encode(Z,L)};if(W&&Z.additionalProperties===!1)Y.Clean=h4(Z);if(Z.config){if(Y.config=Z.config,Y?.schema?.config)delete Y.schema.config}return Y.parse=(L)=>{try{return Y.Decode(L)}catch(_){throw[...Y.Errors(L)].map(i2)}},Y.safeParse=(L)=>{try{return{success:!0,data:Y.Decode(L),error:null}}catch(_){let G=[...J.Errors(L)].map(i2);return{success:!1,data:null,error:G[0]?.summary,errors:G}}},Y}let J=w6.Compile(Z,Object.values(z));if(J.Clean=h4(Z),Z.config){if(J.config=Z.config,J?.schema?.config)delete J.schema.config}return J.parse=(Y)=>{try{return J.Decode(Y)}catch(L){throw[...J.Errors(Y)].map(i2)}},J.safeParse=(Y)=>{try{return{success:!0,data:J.Decode(Y),error:null}}catch(L){let _=[...J.Errors(Y)].map(i2);return{success:!1,data:null,error:_[0]?.summary,errors:_}}},J},ow=(w,{models:z={},modules:A,dynamic:U=!1,normalize:W=!1,additionalProperties:$=!1})=>{if(!w)return;if(typeof w==="string"&&!(w in z))return;let X=typeof w==="string"?A.Import(w)??z[w]:w,Q=(J,Y)=>{if(U)return{schema:J,references:"",checkFunc:()=>{},code:"",Check:(_)=>p.Check(J,_),Errors:(_)=>p.Errors(J,_),Code:()=>"",Clean:h4(J),Decode:(_)=>p.Decode(J,_),Encode:(_)=>p.Encode(J,_)};let L=w6.Compile(J,Y);if(W&&J.additionalProperties===!1)L.Clean=h4(J);return L};if(b in X){if("additionalProperties"in X===!1)X.additionalProperties=$;return{200:Q(X,Object.values(z))}}let Z={};return Object.keys(X).forEach((J)=>{let Y=X[+J];if(typeof Y==="string"){if(Y in z){let L=z[Y];L.type==="object"&&"additionalProperties"in L,Z[+J]=b in L?Q(L,Object.values(z)):L}return}if(Y.type==="object"&&"additionalProperties"in Y===!1)Y.additionalProperties=$;Z[+J]=b in Y?Q(Y,Object.values(z)):Y}),Z},ZH=typeof Bun!=="undefined",JH=ZH&&typeof Bun.hash==="function",O6=(w)=>{if(JH)return Bun.hash(w);let z=9;for(let A=0;A<w.length;)z=Math.imul(z^w.charCodeAt(A++),387420489);return z=z^z>>>9},s5,A6=()=>{if(!s5)s5=[{from:x.Object({}),to:()=>x.ObjectString({}),excludeRoot:!0},{from:x.Array(x.Any()),to:()=>x.ArrayString(x.Any())}];return s5},r5,a5=()=>{if(!r5)r5=[{from:x.Number(),to:(w)=>x.Numeric(w),rootOnly:!0},{from:x.Boolean(),to:(w)=>x.BooleanString(w),rootOnly:!0}];return r5},uw=({validator:w,modules:z,defaultConfig:A={},config:U,dynamic:W,models:$})=>{let X=$2(w,{modules:z,dynamic:W,models:$,additionalProperties:!0,coerce:!0,additionalCoerce:A6()});if(Q2(A))if(X)X.config=$H(X.config,U);else X=$2(x.Cookie({}),{modules:z,dynamic:W,models:$,additionalProperties:!0}),X.config=A;return X},Y1=(w,z)=>{if(!z)return;if(!Array.isArray(z)){let U=z;if(w&&!U.checksum)U.checksum=w;if(U.scope==="scoped")U.scope="local";return U}let A=[...z];for(let U of A){if(w&&!U.checksum)U.checksum=w;if(U.scope==="scoped")U.scope="local"}return A},e5=(w,z,A)=>{return{start:i0(w.start,Y1(A,z?.start)),request:i0(w.request,Y1(A,z?.request)),parse:i0(w.parse,Y1(A,z?.parse)),transform:i0(w.transform,Y1(A,z?.transform)),beforeHandle:i0(i0(r0(w.resolve,"resolve"),w.beforeHandle),Y1(A,i0(r0(z?.resolve,"resolve"),z?.beforeHandle))),afterHandle:i0(w.afterHandle,Y1(A,z?.afterHandle)),mapResponse:i0(w.mapResponse,Y1(A,z?.mapResponse)),afterResponse:i0(w.afterResponse,Y1(A,z?.afterResponse)),trace:i0(w.trace,Y1(A,z?.trace)),error:i0(w.error,Y1(A,z?.error)),stop:i0(w.stop,Y1(A,z?.stop))}},gA=(w,z,{skipIfHasType:A=!1}={})=>{if(!w)return w;if(!Array.isArray(w)){if(A)w.scope??=z;else w.scope=z;return w}for(let U of w)if(A)U.scope??=z;else U.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 A of w)switch(A.scope){case"global":case"scoped":z.push({...A});break}return z},wz=(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)}},U6={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},mw=Object.fromEntries(Object.entries(U6).map(([w,z])=>[z,w]));function YH(w){let z=w;while(z.endsWith("="))z=z.slice(0,-1);return z}var kA=new TextEncoder,W4=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 A=await crypto.subtle.importKey("raw",kA.encode(z),{name:"HMAC",hash:"SHA-256"},!1,["sign"]),U=await crypto.subtle.sign("HMAC",A,kA.encode(w));return w+"."+YH(Buffer.from(U).toString("base64"))},zz=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 A=w.slice(0,w.lastIndexOf("."));return await W4(A,z)===w?A:!1},TA=(w,z,A)=>{if(!w||typeof w!=="object"||!z)return;for(let[U,W]of Object.entries(z)){if(U in QH||!(U in w))continue;let $=w[U];if(typeof $==="function"){let X=$(W);if(typeof X==="object")for(let[Q,Z]of Object.entries(X))A(Q)({fn:Z});delete z[U]}}},iA=({globalHook:w,localHook:z})=>(A)=>(U,W)=>{if(typeof U==="function")U={fn:U};if(A==="resolve")U={...U,subType:"resolve"};if("fn"in U||Array.isArray(U)){if(!z[A])z[A]=[];if(typeof z[A]==="function")z[A]=[z[A]];if(Array.isArray(U))z[A]=z[A].concat(U);else z[A].push(U);return}let{insert:$="after",stack:X="local"}=U;if(typeof W==="function")W={fn:W};if(X==="global")if(!Array.isArray(W))if($==="before")w[A].unshift(W);else w[A].push(W);else if($==="before")w[A]=W.concat(w[A]);else w[A]=w[A].concat(W);else{if(!z[A])z[A]=[];if(typeof z[A]==="function")z[A]=[z[A]];if(!Array.isArray(W))if($==="before")z[A].unshift(W);else z[A].push(W);else if($==="before")z[A]=W.concat(z[A]);else z[A]=z[A].concat(W)}},qH=(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},y4=(w)=>qH(w)!==null;class Az{constructor(w=console.error){this.onError=w,this.root=null,this.promises=[]}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 r0=(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 A=[];for(let U of w)if(typeof U==="function"||typeof U==="string")A.push(z?{fn:U,subType:z}:{fn:U});else if("fn"in U)A.push(U);return A},dA=(w)=>{return{...w,start:r0(w?.start),request:r0(w?.request),parse:r0(w?.parse),transform:r0(w?.transform),beforeHandle:r0(w?.beforeHandle),afterHandle:r0(w?.afterHandle),mapResponse:r0(w?.mapResponse),afterResponse:r0(w?.afterResponse),trace:r0(w?.trace),error:r0(w?.error),stop:r0(w?.stop)}},Uz=(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)}},v4=(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}),o4=(w,z=302)=>Response.redirect(w,z),BH=Symbol("ElysiaFormData"),C6=Symbol("ElysiaRequestId");var pw=()=>{let w=crypto.randomUUID();return w.slice(0,8)+w.slice(24,32)},lw=(w)=>{let z=[];for(let A=0;A<w.length;A++){let U=w[A];if(U.checksum){if(z.includes(U.checksum))w.splice(A,1),A--;z.push(U.checksum)}}return w},X2=(w,z="scoped")=>{if(z==="scoped"){for(let A of w)if("scope"in A&&A.scope==="local")A.scope="scoped";return}for(let A of w)if("scope"in A)A.scope="global"},h1=(w)=>{if(w.charCodeAt(w.length-1)===47)return w.slice(0,w.length-1);return w+"/"},Q2=(w)=>{if(!w)return!1;for(let z in w)return!0;return!1};var cA=typeof Bun!=="undefined"?Bun.env:typeof process!=="undefined"?process?.env:void 0,R6=Symbol("ElysiaErrorCode"),u4=(cA?.NODE_ENV??cA?.ENV)==="production";class I2{constructor(w,z){let A=z??(w in mw?mw[w]:w);this.code=U6[w]??w,this.response=A}}var Wz=(w,z)=>new I2(w,z);class sw extends Error{constructor(w){super(w??"INTERNAL_SERVER_ERROR");this.code="INTERNAL_SERVER_ERROR",this.status=500}}class K6 extends Error{constructor(w){super(w??"NOT_FOUND");this.code="NOT_FOUND",this.status=404}}class rw extends Error{constructor(){super("Bad Request");this.code="PARSE",this.status=400}}class m4 extends Error{constructor(w,z){super(z??`"${w}" has invalid cookie signature`);this.key=w,this.code="INVALID_COOKIE_SIGNATURE",this.status=400}}var i2=(w)=>{if(!w)return{summary:void 0};let{message:z,path:A,value:U,type:W}=w,$=A.slice(1).replaceAll("/","."),X=A==="";switch(W){case 42:return{...w,summary:X?"Value should not be provided":`Property '${$}' should not be provided`};case 45:return{...w,summary:X?"Value is missing":`Property '${$}' is missing`};case 50:let Q=z.indexOf("'"),Z=z.slice(Q+1,z.indexOf("'",Q+1));return{...w,summary:X?"Value should be an email":`Property '${$}' should be ${Z}`};case 54:return{...w,summary:`${z.slice(0,9)} property '${$}' to be ${z.slice(8)} but found: ${U}`};case 62:let J=w.schema.anyOf.map((Y)=>`'${Y?.format??Y.type}'`).join(", ");return{...w,summary:X?`Value should be one of ${J}`:`Property '${$}' should be one of: ${J}`};default:return{summary:z,...w}}};class m extends Error{constructor(w,z,A){if(A&&typeof A==="object"&&A instanceof I2)A=A.response;let U=u4?void 0:("Errors"in z)?z.Errors(A).First():p.Errors(z,A).First(),W=U.schema.message||U?.schema.error!==void 0?typeof U.schema.error==="function"?U.schema.error({type:w,validator:z,value:A,get errors(){return[...z.Errors(A)].map(i2)}}):U.schema.error:void 0,$=U?.path||"root",X="";if(W!==void 0)X=typeof W==="object"?JSON.stringify(W):W+"";else if(u4)X=JSON.stringify({type:"validation",on:w,summary:i2(U).summary,message:U?.message,found:A});else{let Q=z?.schema??z,Z="Errors"in z?[...z.Errors(A)].map(i2):[...p.Errors(z,A)].map(i2),J;try{J=p.Create(Q)}catch(Y){J={type:"Could not create expected value",message:Y?.message,error:Y}}X=JSON.stringify({type:"validation",on:w,summary:i2(U).summary,property:$,message:U?.message,expected:J,found:A,errors:Z},null,2)}super(X);this.type=w,this.validator=z,this.value=A,this.code="VALIDATION",this.status=422,Object.setPrototypeOf(this,m.prototype)}get all(){return"Errors"in this.validator?[...this.validator.Errors(this.value)].map(i2):[...p.Errors(this.validator,this.value)].map(i2)}static simplifyModel(w){let z="schema"in w?w.schema:w;try{return p.Create(z)}catch{return z}}get model(){return m.simplifyModel(this.validator)}toResponse(w){return new Response(this.message,{status:400,headers:{...w,"content-type":"application/json"}})}}var hA=/(\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))/,tA=/(?: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\([^)]+\)/,yA=/^(?:(?:(?:(?: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)?)?$/,MH=yw.date,HH=yw["date-time"];if(!O0.Has("date"))T1.Format("date",(w)=>{let z=w.replace(/"/g,"");if(hA.test(z)||tA.test(z)||yA.test(z)||MH(z)){let A=new Date(z);if(!Number.isNaN(A.getTime()))return!0}return!1});if(!O0.Has("date-time"))T1.Format("date-time",(w)=>{let z=w.replace(/"/g,"");if(hA.test(z)||tA.test(z)||yA.test(z)||HH(z)){let A=new Date(z);if(!Number.isNaN(A.getTime()))return!0}return!1});Object.entries(yw).forEach((w)=>{let[z,A]=w;if(!O0.Has(z)){if(A instanceof RegExp)T1.Format(z,(U)=>A.test(U));else if(typeof A==="function")T1.Format(z,A)}});var x=Object.assign({},S6),nA=(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},$z=(w,z)=>{if(!(z instanceof Blob))return!1;if(w.minSize&&z.size<nA(w.minSize))return!1;if(w.maxSize&&z.size>nA(w.maxSize))return!1;if(w.extension)if(typeof w.extension==="string"){if(!z.type.startsWith(w.extension))return!1}else{for(let A=0;A<w.extension.length;A++)if(z.type.startsWith(w.extension[A]))return!0;return!1}return!0},GH=c0.Get("Files")??T1.Type("File",$z),LH=c0.Get("Files")??T1.Type("Files",(w,z)=>{if(!Array.isArray(z))return $z(w,z);if(w.minItems&&z.length<w.minItems)return!1;if(w.maxItems&&z.length>w.maxItems)return!1;for(let A=0;A<z.length;A++)if(!$z(w,z[A]))return!1;return!0});if(!O0.Has("numeric"))O0.Set("numeric",(w)=>!!w&&!isNaN(+w));if(!O0.Has("integer"))O0.Set("integer",(w)=>!!w&&Number.isInteger(+w));if(!O0.Has("boolean"))O0.Set("boolean",(w)=>w==="true"||w==="false");if(!O0.Has("ObjectString"))O0.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(!O0.Has("ArrayString"))O0.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}});c0.Set("UnionEnum",(w,z)=>{return(typeof z==="number"||typeof z==="string"||z===null)&&w.enum.includes(z)});var a2={Numeric:(w)=>{let z=S6.Number(w);return x.Transform(x.Union([x.String({format:"numeric",default:0}),x.Number(w)],w)).Decode((A)=>{let U=+A;if(isNaN(U))return A;if(w&&!p.Check(z,U))throw new m("property",z,U);return U}).Encode((A)=>A)},Integer:(w)=>{let z=S6.Integer(w);return x.Transform(x.Union([x.String({format:"integer",default:0}),x.Number(w)],w)).Decode((A)=>{let U=+A;if(!p.Check(z,U))throw new m("property",z,U);return U}).Encode((A)=>A)},Date:(w)=>{let z=S6.Date(w);return x.Transform(x.Union([S6.Date(w),x.String({format:"date",default:new Date().toISOString()}),x.String({format:"date-time",default:new Date().toISOString()}),x.Number()],w)).Decode((A)=>{if(typeof A==="number"){let W=new Date(A);if(!p.Check(z,W))throw new m("property",z,W);return W}if(A instanceof Date)return A;let U=new Date(A);if(!p.Check(z,U))throw new m("property",z,U);return U}).Encode((A)=>{if(typeof A==="string")return new Date(A);return A})},BooleanString:(w)=>{let z=S6.Boolean(w);return x.Transform(x.Union([x.Boolean(w),x.String({format:"boolean",default:!1})],w)).Decode((A)=>{if(typeof A==="string")return A==="true";if(A!==void 0&&!p.Check(z,A))throw new m("property",z,A);return A}).Encode((A)=>A)},ObjectString:(w,z)=>{let A=x.Object(w,z),U=JSON.stringify(p.Create(A)),W;try{W=w6.Compile(A)}catch{}return x.Transform(x.Union([x.String({format:"ObjectString",default:U}),A])).Decode(($)=>{if(typeof $==="string"){if($.charCodeAt(0)!==123)throw new m("property",A,$);try{$=JSON.parse($)}catch{throw new m("property",A,$)}if(W){if(!W.Check($))throw new m("property",A,$);return W.Decode($)}if(!p.Check(A,$))throw new m("property",A,$);return p.Decode(A,$)}return $}).Encode(($)=>{if(typeof $==="string")try{$=JSON.parse($)}catch{throw new m("property",A,$)}if(!p.Check(A,$))throw new m("property",A,$);return JSON.stringify($)})},ArrayString:(w={},z)=>{let A=x.Array(w,z),U=JSON.stringify(p.Create(A)),W;try{W=w6.Compile(A)}catch{}return x.Transform(x.Union([x.String({format:"ArrayString",default:U}),A])).Decode(($)=>{if(typeof $==="string"){if($.charCodeAt(0)!==91)throw new m("property",A,$);try{$=JSON.parse($)}catch{throw new m("property",A,$)}if(W){if(!W.Check($))throw new m("property",A,$);return W.Decode($)}if(!p.Check(A,$))throw new m("property",A,$);return p.Decode(A,$)}return $}).Encode(($)=>{if(typeof $==="string")try{$=JSON.parse($)}catch{throw new m("property",A,$)}if(!p.Check(A,$))throw new m("property",A,$);return JSON.stringify($)})},File:GH,Files:(w={})=>x.Transform(LH(w)).Decode((z)=>{if(Array.isArray(z))return z;return[z]}).Encode((z)=>z),Nullable:(w)=>x.Union([w,x.Null()]),MaybeEmpty:(w)=>x.Union([w,x.Null(),x.Undefined()]),Cookie:(w,{domain:z,expires:A,httpOnly:U,maxAge:W,path:$,priority:X,sameSite:Q,secure:Z,secrets:J,sign:Y,...L}={})=>{let _=x.Object(w,L);return _.config={domain:z,expires:A,httpOnly:U,maxAge:W,path:$,priority:X,sameSite:Q,secure:Z,secrets:J,sign:Y},_},UnionEnum:(w,z={})=>{let A=w.every((U)=>typeof U==="string")?{type:"string"}:w.every((U)=>typeof U==="number")?{type:"number"}:w.every((U)=>U===null)?{type:"null"}:{};if(w.some((U)=>typeof U==="object"&&U!==null))throw new Error("This type does not support objects or arrays");return{default:w[0],...z,[b]:"UnionEnum",...A,enum:w}}};x.BooleanString=a2.BooleanString;x.ObjectString=a2.ObjectString;x.ArrayString=a2.ArrayString;x.Numeric=a2.Numeric;x.Integer=a2.Integer;x.File=(w={})=>a2.File({default:"File",...w,extension:w?.type,type:"string",format:"binary"});x.Files=(w={})=>a2.Files({...w,elysiaMeta:"Files",default:"Files",extension:w?.type,type:"array",items:{...w,default:"Files",type:"string",format:"binary"}});x.Nullable=(w)=>a2.Nullable(w);x.MaybeEmpty=a2.MaybeEmpty;x.Cookie=a2.Cookie;x.Date=a2.Date;x.UnionEnum=a2.UnionEnum;var $4=(w)=>{let z=typeof w==="object"?w.fn.toString():typeof w==="string"?w.toString():w,A=z.indexOf(")");if(z.charCodeAt(A+2)===61&&z.charCodeAt(A+5)!==123)return!0;return z.includes("return")},bH=(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 W=z;while(W>0)if(w.charCodeAt(--W)===41)break;let $=w.slice(z+2);if($.charCodeAt(0)===32)$=$.trimStart();return[w.slice(1,W),$,{isArrowReturn:$.charCodeAt(0)!==123}]}}if(/^(\w+)=>/g.test(w)){if(z=w.indexOf("=>"),z!==-1){let W=w.slice(z+2);if(W.charCodeAt(0)===32)W=W.trimStart();return[w.slice(0,z),W,{isArrowReturn:W.charCodeAt(0)!==123}]}}if(w.startsWith("function")){z=w.indexOf("(");let W=w.indexOf(")");return[w.slice(z+1,W),w.slice(W+2),{isArrowReturn:!1}]}let A=w.indexOf("(");if(A!==-1){let W=w.indexOf(`
|
|
7
|
+
`,2),$=w.slice(0,W),X=$.lastIndexOf(")")+1,Q=w.slice(W+1);return[$.slice(A,X),"{"+Q,{isArrowReturn:!1}]}let U=w.split(`
|
|
8
|
+
`,2);return[U[0],U[1],{isArrowReturn:!1}]},NH=(w)=>{let z=w.indexOf("{");if(z===-1)return[-1,0];let A=z+1,U=1;for(;A<w.length;A++){let W=w.charCodeAt(A);if(W===123)U++;else if(W===125)U--;if(U===0)break}if(U!==0)return[0,w.length];return[z,A+1]},SH=(w)=>{let z=w.lastIndexOf("}");if(z===-1)return[-1,0];let A=z-1,U=1;for(;A>=0;A--){let W=w.charCodeAt(A);if(W===125)U++;else if(W===123)U--;if(U===0)break}if(U!==0)return[-1,0];return[A,z+1]},oA=(w)=>{while(!0){let z=w.indexOf(":");if(z===-1)break;let A=w.indexOf(",",z);if(A===-1)A=w.indexOf("}",z)-1;if(A===-2)A=w.length;w=w.slice(0,z)+w.slice(A)}return w},uA=(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 A=[];while(!0){let[W,$]=NH(w);if(W===-1)break;if(A.push(w.slice(0,W-1)),w.charCodeAt($)===44)$++;w=w.slice($)}if(w=oA(w),w)A=A.concat(w.split(","));let U=[];for(let W of A){if(W.indexOf(",")===-1){U.push(W);continue}for(let $ of W.split(","))U.push($.trim())}return A=U,{hasParenthesis:z,parameters:A}},DH=(w,z)=>{let{parameters:A,hasParenthesis:U}=uA(w);if(!z.query&&A.includes("query"))z.query=!0;if(!z.headers&&A.includes("headers"))z.headers=!0;if(!z.body&&A.includes("body"))z.body=!0;if(!z.cookie&&A.includes("cookie"))z.cookie=!0;if(!z.set&&A.includes("set"))z.set=!0;if(!z.server&&A.includes("server"))z.server=!0;if(!z.request&&A.includes("request"))z.request=!0;if(!z.route&&A.includes("route"))z.route=!0;if(U)return`{ ${A.join(", ")} }`;return A.join(", ")},vA=(w,z,A)=>{let U=z.indexOf(w+`
|
|
9
|
+
`,A),W=z.indexOf(w+"\t",A),$=z.indexOf(w+",",A),X=z.indexOf(w+";",A),Q=z.indexOf(w+" ",A);return[U,W,$,X,Q].filter((Z)=>Z>0).sort((Z,J)=>Z-J)[0]||-1};var mA=(w,z,A=0)=>{if(A>5)return[];let U=[],W=z;while(!0){let $=vA(" = "+w,W);if($===-1)$=vA("="+w,W);if($===-1){let J=W.indexOf(" = "+w);if(J===-1)J=W.indexOf("="+w);if(J+3+w.length!==W.length)break;$=J}let X=W.slice(0,$),Q=X.lastIndexOf(" "),Z=X.slice(Q!==-1?Q+1:-1);if(Z==="}"){let[J,Y]=SH(X);U.push(oA(W.slice(J,Y))),W=W.slice($+3+w.length);continue}while(Z.charCodeAt(0)===44)Z=Z.slice(1);while(Z.charCodeAt(0)===9)Z=Z.slice(1);if(!Z.includes("("))U.push(Z);W=W.slice($+3+w.length)}for(let $ of U){if($.charCodeAt(0)===123)continue;let X=mA($,z);if(X.length>0)U.push(...X)}return U},_H=(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 A=w.indexOf("...");if(A===-1)return;return w.slice(A+3).trimEnd()},PH=(w,z,A)=>{let U=(W,$)=>w.includes($+"."+W)||w.includes($+'["'+W+'"]')||w.includes($+"['"+W+"']");for(let W of z){if(!W)continue;if(W.charCodeAt(0)===123){let $=uA(W).parameters;if(!A.query&&$.includes("query"))A.query=!0;if(!A.headers&&$.includes("headers"))A.headers=!0;if(!A.body&&$.includes("body"))A.body=!0;if(!A.cookie&&$.includes("cookie"))A.cookie=!0;if(!A.set&&$.includes("set"))A.set=!0;if(!A.query&&$.includes("server"))A.server=!0;if(!A.request&&$.includes("request"))A.request=!0;if(!A.route&&$.includes("route"))A.route=!0;continue}if(!A.query&&U("query",W))A.query=!0;if(w.includes("return "+W)||w.includes("return "+W+".query"))A.query=!0;if(!A.headers&&U("headers",W))A.headers=!0;if(!A.body&&U("body",W))A.body=!0;if(!A.cookie&&U("cookie",W))A.cookie=!0;if(!A.set&&U("set",W))A.set=!0;if(!A.server&&U("server",W))A.server=!0;if(A.query&&A.headers&&A.body&&A.cookie&&A.set&&A.server&&A.server&&A.route)break}return z};var OH=(w,z,A)=>{try{let U=new RegExp(`(?:\\w)\\((?:.*)?${w}`,"gs");U.test(z);let W=z.charCodeAt(U.lastIndex);if(W===41||W===44)return A.query=!0,A.headers=!0,A.body=!0,A.cookie=!0,A.set=!0,A.server=!0,A.route=!0,A.request=!0,!0;return!1}catch(U){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}},aw=(w,z={query:!1,headers:!1,body:!1,cookie:!1,set:!1,server:!1,request:!1,route:!1})=>{let A=[];if(w.handler&&typeof w.handler==="function")A.push(w.handler);if(w.request?.length)A.push(...w.request);if(w.beforeHandle?.length)A.push(...w.beforeHandle);if(w.parse?.length)A.push(...w.parse);if(w.error?.length)A.push(...w.error);if(w.transform?.length)A.push(...w.transform);if(w.afterHandle?.length)A.push(...w.afterHandle);if(w.mapResponse?.length)A.push(...w.mapResponse);if(w.afterResponse?.length)A.push(...w.afterResponse);for(let U of A){if(!U)continue;let W="fn"in U?U.fn:U;if(typeof W!=="function")continue;let[$,X,{isArrowReturn:Q}]=bH(W.toString()),Z=DH($,z),J=_H(Z);if(J){let Y=mA(J,X);if(Y.splice(0,-1,J),!OH(J,X,z))PH(X,Y,z);if(!z.query&&X.includes("return "+J+".query"))z.query=!0}if(z.query&&z.headers&&z.body&&z.cookie&&z.set&&z.server&&z.request&&z.route)break}return z};var w8=Ww(rA(),1),AU=Ww(ew(),1);class W6{constructor(w,z,A={}){this.name=w,this.jar=z,this.initial=A}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 zU=(w,z,A)=>{if(!w.cookie)w.cookie={};return new Proxy(z,{get(U,W){if(W in z)return new W6(W,w.cookie,Object.assign({},A??{},z[W]));return new W6(W,w.cookie,Object.assign({},A))}})},z8=async(w,z,{secrets:A,sign:U,...W}={})=>{if(!z)return zU(w,{},W);let $=typeof A==="string";if(U&&U!==!0&&!Array.isArray(U))U=[U];let X={},Q=w8.parse(z);for(let[Z,J]of Object.entries(Q)){let Y=AU.default(J);if(U===!0||U?.includes(Z)){if(!A)throw new Error("No secret is provided to cookie plugin");if($){let L=await zz(Y,A);if(L===!1)throw new m4(Z);Y=L}else{let L=!0;for(let _=0;_<A.length;_++){let G=await zz(Y,A[_]);if(G!==!1){L=!0,Y=G;break}}if(!L)throw new m4(Z)}}X[Z]={value:Y}}return zU(w,X,W)},p4=(w)=>{if(!w||!Q2(w))return;let z=[];for(let[A,U]of Object.entries(w)){if(!A||!U)continue;let W=U.value;if(W===void 0||W===null)continue;z.push(w8.serialize(A,typeof W==="object"?JSON.stringify(W):W+"",U))}if(z.length===0)return;if(z.length===1)return z[0];return z};var $6=(w,z)=>{let A=w.size;if(!z&&A||A&&z&&z.status!==206&&z.status!==304&&z.status!==412&&z.status!==416){if(z){if(z.headers instanceof Headers){let U={"accept-ranges":"bytes","content-range":`bytes 0-${A-1}/${A}`,"transfer-encoding":"chunked"};if(vw)U=z.headers.toJSON();else{U={};for(let[W,$]of z.headers.entries())if(W in z.headers)U[W]=$}return new Response(w,{status:z.status,headers:U})}if(Q2(z.headers))return new Response(w,{status:z.status,headers:Object.assign({"accept-ranges":"bytes","content-range":`bytes 0-${A-1}/${A}`,"transfer-encoding":"chunked"},z.headers)})}return new Response(w,{headers:{"accept-ranges":"bytes","content-range":`bytes 0-${A-1}/${A}`,"transfer-encoding":"chunked"}})}return new Response(w)},Qz=(w,z)=>{if(!w)return w;w.delete("set-cookie");for(let A=0;A<z.length;A++){let U=z[A].indexOf("=");w.append("set-cookie",`${z[A].slice(0,U)}=${z[A].slice(U+1)||""}`)}return w},q1=async(w,z,A)=>{let U=w.next();if(U instanceof Promise)U=await U;if(U.done){if(z)return H2(U.value,z,A);return D1(U.value,A)}return new Response(new ReadableStream({async start(W){let $=!1;if(A?.signal?.addEventListener("abort",()=>{$=!0;try{W.close()}catch{}}),U.value!==void 0&&U.value!==null)if(typeof U.value==="object")try{W.enqueue(Buffer.from(JSON.stringify(U.value)))}catch{W.enqueue(Buffer.from(U.value.toString()))}else W.enqueue(Buffer.from(U.value.toString()));for await(let X of w){if($)break;if(X===void 0||X===null)continue;if(typeof X==="object")try{W.enqueue(Buffer.from(JSON.stringify(X)))}catch{W.enqueue(Buffer.from(X.toString()))}else W.enqueue(Buffer.from(X.toString()));await new Promise((Q)=>setTimeout(()=>Q(),0))}try{W.close()}catch{}}}),{...z,headers:{"transfer-encoding":"chunked","content-type":"text/event-stream; charset=utf-8",...z?.headers}})};async function*X4(w){let z=w.body;if(!z)return;let A=z.getReader(),U=new TextDecoder;try{while(!0){let{done:W,value:$}=await A.read();if(W)break;yield U.decode($)}}finally{A.releaseLock()}}var UU=(w)=>{if(typeof w.status==="string")w.status=U6[w.status];if(w.cookie&&Q2(w.cookie)){let z=p4(w.cookie);if(z)w.headers["set-cookie"]=z}if(w.headers["set-cookie"]&&Array.isArray(w.headers["set-cookie"]))w.headers=Qz(new Headers(w.headers),w.headers["set-cookie"])},A8=(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 A=!1;if(z.headers instanceof Headers)for(let U of z.headers.keys())if(U==="set-cookie"){if(A)continue;A=!0;for(let W of z.headers.getSetCookie())w.headers.append("set-cookie",W)}else w.headers.append(U,z.headers?.get(U)??"");else for(let U in z.headers)w.headers.append(U,z.headers[U]);return w},H2=(w,z,A)=>{if(Q2(z.headers)||z.status!==200||z.cookie)switch(UU(z),w?.constructor?.name){case"String":return new Response(w,z);case"Array":case"Object":return Response.json(w,z);case"ElysiaFile":return $6(w.value);case"Blob":return $6(w,z);case"ElysiaCustomStatusResponse":return z.status=w.code,H2(w.response,z,A);case"ReadableStream":if(!z.headers["content-type"]?.startsWith("text/event-stream"))z.headers["content-type"]="text/event-stream; charset=utf-8";return A?.signal?.addEventListener("abort",{handleEvent(){if(A?.signal&&!A?.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=A8(w,z),w.headers.get("transfer-encoding")==="chunked")return q1(X4(w),z,A);return w;case"Error":return X6(w,z);case"Promise":return w.then((U)=>H2(U,z,A));case"Function":return H2(w(),z,A);case"Number":case"Boolean":return new Response(w.toString(),z);case"Cookie":if(w instanceof W6)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=A8(w,z),w.headers.get("transfer-encoding")==="chunked")return q1(X4(w),z,A);return w}if(w instanceof Promise)return w.then((U)=>H2(U,z));if(w instanceof Error)return X6(w,z);if(w instanceof I2)return z.status=w.code,H2(w.response,z,A);if(typeof w?.next==="function")return q1(w,z,A);if(typeof w?.then==="function")return w.then((U)=>H2(U,z));if(typeof w?.toResponse==="function")return H2(w.toResponse(),z);if("charCodeAt"in w){let U=w.charCodeAt(0);if(U===123||U===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 q1(w,z,A);return D1(w,A)},M2=(w,z,A)=>{if(w===void 0||w===null)return;if(Q2(z.headers)||z.status!==200||z.cookie)switch(UU(z),w?.constructor?.name){case"String":return new Response(w,z);case"Array":case"Object":return Response.json(w,z);case"ElysiaFile":return $6(w.value);case"Blob":return $6(w,z);case"ElysiaCustomStatusResponse":return z.status=w.code,M2(w.response,z,A);case"ReadableStream":if(!z.headers["content-type"]?.startsWith("text/event-stream"))z.headers["content-type"]="text/event-stream; charset=utf-8";return A?.signal?.addEventListener("abort",{handleEvent(){if(A?.signal&&!A?.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=A8(w,z),w.headers.get("transfer-encoding")==="chunked")return q1(X4(w),z,A);return w;case"Promise":return w.then((U)=>M2(U,z));case"Error":return X6(w,z);case"Function":return M2(w(),z);case"Number":case"Boolean":return new Response(w.toString(),z);case"FormData":return new Response(w);case"Cookie":if(w instanceof W6)return new Response(w.value,z);return new Response(w?.toString(),z);default:if(w instanceof Response){if(w=A8(w,z),w.headers.get("transfer-encoding")==="chunked")return q1(X4(w),z,A);return w}if(w instanceof Promise)return w.then((U)=>M2(U,z));if(w instanceof Error)return X6(w,z);if(w instanceof I2)return z.status=w.code,M2(w.response,z,A);if(typeof w?.next==="function")return q1(w,z,A);if(typeof w?.then==="function")return w.then((U)=>M2(U,z));if(typeof w?.toResponse==="function")return M2(w.toResponse(),z);if("charCodeAt"in w){let U=w.charCodeAt(0);if(U===123||U===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 $6(w.value);case"Blob":return $6(w,z);case"ElysiaCustomStatusResponse":return z.status=w.code,M2(w.response,z,A);case"ReadableStream":return A?.signal?.addEventListener("abort",{handleEvent(){if(A?.signal&&!A?.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 q1(X4(w));return w;case"Promise":return w.then((U)=>{let W=M2(U,z);if(W!==void 0)return W});case"Error":return X6(w,z);case"Function":return D1(w(),A);case"Number":case"Boolean":return new Response(w.toString());case"Cookie":if(w instanceof W6)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((U)=>M2(U,z));if(w instanceof Error)return X6(w,z);if(w instanceof I2)return z.status=w.code,M2(w.response,z,A);if(typeof w?.next==="function")return q1(w,z,A);if(typeof w?.then==="function")return w.then((U)=>M2(U,z));if(typeof w?.toResponse==="function")return M2(w.toResponse(),z);if("charCodeAt"in w){let U=w.charCodeAt(0);if(U===123||U===91){if(!z.headers["Content-Type"])z.headers["Content-Type"]="application/json";return new Response(JSON.stringify(w),z)}}return new Response(w)}},D1=(w,z)=>{switch(w?.constructor?.name){case"String":return new Response(w);case"Object":case"Array":return Response.json(w);case"ElysiaFile":return $6(w.value);case"Blob":return $6(w);case"ElysiaCustomStatusResponse":return H2(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 q1(X4(w));return w;case"Error":return X6(w);case"Promise":return w.then((A)=>D1(A,z));case"Function":return D1(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((A)=>D1(A,z));if(w instanceof Error)return X6(w);if(w instanceof I2)return H2(w.response,{status:w.code,headers:{}});if(typeof w?.next==="function")return q1(w,void 0,z);if(typeof w?.then==="function")return w.then((A)=>H2(A,set));if(typeof w?.toResponse==="function")return D1(w.toResponse());if("charCodeAt"in w){let A=w.charCodeAt(0);if(A===123||A===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}),Zz=(w,z,A={})=>{if(typeof w==="function")return;let U=H2(w,{headers:A});if(z.parse.length===0&&z.transform.length===0&&z.beforeHandle.length===0&&z.afterHandle.length===0)return U.clone.bind(U)};var Q4={name:"web-standard",isWebStandard:!0,handler:{mapResponse:H2,mapEarlyResponse:M2,mapCompactResponse:D1,createStaticHandler:Zz},composeHandler:{mapResponseContext:"c.request",preferWebstandardHeaders:!0,headers:`c.headers = {}
|
|
10
|
+
for (const [key, value] of c.request.headers.entries())c.headers[key] = value
|
|
11
|
+
`,parser:{json(w){if(w)return`try{c.body=await c.request.json()}catch{}
|
|
12
|
+
`;return`c.body=await c.request.json()
|
|
13
|
+
`},text(){return`c.body=await c.request.text()
|
|
14
|
+
`},urlencoded(){return`c.body=parseQuery(await c.request.text())
|
|
15
|
+
`},arrayBuffer(){return`c.body=await c.request.arrayBuffer()
|
|
16
|
+
`},formData(w){let z=`
|
|
17
|
+
c.body={}
|
|
18
|
+
`;if(w)z+="let form;try{form=await c.request.formData()}catch{}";else z+=`const form=await c.request.formData()
|
|
19
|
+
`;return z+`for(const key of form.keys()){if(c.body[key]) continue
|
|
20
|
+
const value=form.getAll(key)
|
|
21
|
+
if(value.length===1)c.body[key]=value[0]
|
|
22
|
+
else c.body[key]=value}`}}},composeGeneralHandler:{parameters:"r",createContext(w){let z="",A="",U=w.setHeaders;for(let X of Object.keys(w.singleton.decorator))z+=`,${X}: decorator['${X}']`;let W=w.config.handler?.standardHostname??!0,$=w.event.trace.length>0;if(A+=`const u=r.url,s=u.indexOf('/',${W?11:7}),qi=u.indexOf('?', s + 1)
|
|
23
|
+
let p
|
|
24
|
+
if(qi===-1)p=u.substring(s)
|
|
25
|
+
else p=u.substring(s, qi)
|
|
26
|
+
`,$)A+=`const id=randomId()
|
|
27
|
+
`;if(A+="const c={request:r,store,qi,path:p,url:u,redirect,error,set:{headers:",A+=Object.keys(U??{}).length?"Object.assign({}, app.setHeaders)":"{}",A+=",status:200}",w.inference.server)A+=",get server(){return getServer()}";if($)A+=",[ELYSIA_REQUEST_ID]:id";return A+=z,A+=`}
|
|
28
|
+
`,A},websocket(w){let z="",A=w.router.static.ws,U=w.router.ws;if(Object.keys(A).length||U.history.length){z+="if(r.method==='GET'){switch(p){";for(let[W,$]of Object.entries(A))z+=`case'${W}':`+(w.config.strictPath!==!0?`case'${h1(W)}':`:"")+`if(r.headers.get('upgrade')==='websocket')return ht[${$}].composed(c)
|
|
29
|
+
`;z+=`default:if(r.headers.get('upgrade')==='websocket'){const route=wsRouter.find('ws',p)
|
|
30
|
+
if(route){c.params=route.params
|
|
31
|
+
if(route.store.handler)return route.store.handler(c)
|
|
32
|
+
return (route.store.handler=route.store.compile())(c)}}break}}`}return z},error404(w,z){let A="if(route===null)return ";if(z)A+=`app.handleError(c,notFound,false,${this.parameters})`;else A+=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
|
+
const error404=new Response(error404Message,{status:404})
|
|
34
|
+
`,code:A}}},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")}}};var WU=(w,z,A={})=>{if(typeof w==="function"||w instanceof Blob)return;let U=H2(w,{headers:A});if(z.parse.length===0&&z.transform.length===0&&z.beforeHandle.length===0&&z.afterHandle.length===0){if(!U.headers.has("content-type"))U.headers.append("content-type","text/plain;charset=utf-8");return U.clone.bind(U)}};var Jz={open(w){w.data.open?.(w)},message(w,z){w.data.message?.(w,z)},drain(w){w.data.drain?.(w)},close(w,z,A){w.data.close?.(w,z,A)}};class Z4{constructor(w,z,A=void 0){this.raw=w,this.data=z,this.body=A,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)}get id(){return this.data.id}send(w,z){if(Buffer.isBuffer(w))return this.raw.send(w,z);if(this.validator?.Check(w)===!1)return this.raw.send(new m("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 m("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 m("message",this.validator,w).message);if(typeof w==="object")w=JSON.stringify(w);return this.raw.pong(w)}publish(w,z,A){if(Buffer.isBuffer(z))return this.raw.publish(w,z,A);if(this.validator?.Check(z)===!1)return this.raw.send(new m("message",this.validator,z).message);if(typeof z==="object")z=JSON.stringify(z);return this.raw.publish(w,z,A)}get readyState(){return this.raw.readyState}}var $U=(w)=>{let z=typeof w==="function"?[w]:w;return async function A(U,W){if(typeof W==="string"){let $=W?.charCodeAt(0);if($===47||$===123)try{W=JSON.parse(W)}catch{}else if(y4(W))W=+W}if(z)for(let $=0;$<z.length;$++){let X=z[$](U,W);if(X instanceof Promise)X=await X;if(X!==void 0)return X}return W}},XU=(w)=>{let z=(A,U)=>{if(U instanceof Promise)return U.then((X)=>z(A,X));if(Buffer.isBuffer(U))return A.send(U.toString());if(U===void 0)return;let W=(X)=>{if(w?.Check(X)===!1)return A.send(new m("message",w,X).message);if(typeof X==="object")return A.send(JSON.stringify(X));A.send(X)};if(typeof U?.next!=="function")return void W(U);let $=U.next();if($ instanceof Promise)return(async()=>{let X=await $;if(w?.Check(X)===!1)return A.send(new m("message",w,X).message);if(W(X.value),!X.done)for await(let Q of U)W(Q)})();if(W($.value),!$.done)for(let X of U)W(X)};return z};var QU={...Q4,name:"bun",handler:{...Q4.handler,createNativeStaticHandler:WU},composeHandler:{...Q4.composeHandler,headers:vw?`c.headers = c.request.headers.toJSON()
|
|
35
|
+
`:`c.headers = {}
|
|
36
|
+
for (const [key, value] of c.request.headers.entries())c.headers[key] = value
|
|
37
|
+
`},listen(w){return(z,A)=>{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(!y4(z))throw new Error("Port must be a numeric value");z=parseInt(z)}let U=w.fetch,W=typeof z==="object"?{development:!u4,reusePort:!0,...w.config.serve||{},...z||{},static:w.router.static.http.static,websocket:{...w.config.websocket||{},...Jz||{}},fetch:U,error:w.outerErrorHandler}:{development:!u4,reusePort:!0,...w.config.serve||{},static:w.router.static.http.static,websocket:{...w.config.websocket||{},...Jz||{}},port:z,fetch:U,error:w.outerErrorHandler};w.server=Bun?.serve(W);for(let $=0;$<w.event.start.length;$++)w.event.start[$].fn(w);if(A)A(w.server);process.on("beforeExit",()=>{if(w.server){w.server.stop(),w.server=null;for(let $=0;$<w.event.stop.length;$++)w.event.stop[$].fn(w)}}),w.promisedModules.then(()=>{Bun?.gc(!1)})}},ws(w,z,A){let{parse:U,body:W,response:$,...X}=A,Q=$2(W,{modules:w.definitions.typebox,models:w.definitions.type,normalize:w.config.normalize}),Z=$2($,{modules:w.definitions.typebox,models:w.definitions.type,normalize:w.config.normalize});w.route("$INTERNALWS",z,async(J)=>{let Y=w.getServer(),{set:L,path:_,qi:G,headers:O,query:C,params:q}=J;if(J.validator=Z,A.upgrade){if(typeof A.upgrade==="function"){let c=A.upgrade(J);if(c instanceof Promise)await c}else if(A.upgrade)Object.assign(L.headers,A.upgrade)}if(L.cookie&&Q2(L.cookie)){let c=p4(L.cookie);if(c)L.headers["set-cookie"]=c}if(L.headers["set-cookie"]&&Array.isArray(L.headers["set-cookie"]))L.headers=Qz(new Headers(L.headers),L.headers["set-cookie"]);let o=XU(Z),W0=$U(U),L0;if(Y?.upgrade(J.request,{headers:Q2(L.headers)?L.headers:void 0,data:{...J,get id(){if(L0)return L0;return L0=pw()},validator:Z,ping(c){A.ping?.(c)},pong(c){A.pong?.(c)},open(c){o(c,A.open?.(new Z4(c,J)))},message:async(c,e)=>{let f=await W0(c,e);if(Q?.Check(f)===!1)return void c.send(new m("message",Q,f).message);o(c,A.message?.(new Z4(c,J,f),f))},drain(c){o(c,A.drain?.(new Z4(c,J)))},close(c,e,f){o(c,A.close?.(new Z4(c,J),e,f))}}}))return;return L.status=400,"Expected a websocket connection"},{...X,websocket:A})}};var Yz=typeof Bun!=="undefined";var U8=Yz?Bun.env:typeof process!=="undefined"&&process?.env?process.env:{};var j6=Ww(ew(),1),J4=/\+/g;function ZU(w){let z={};if(typeof w!=="string")return z;let A="",U="",W=-1,$=-1,X=0,Q=w.length;for(let Z=0;Z<Q;Z++)switch(w.charCodeAt(Z)){case 38:let J=$>W;if(!J)$=Z;if(A=w.slice(W+1,$),J||A.length>0){if(X&1)A=A.replace(J4," ");if(X&2)A=j6.default(A)||A;if(!z[A]){if(J){if(U=w.slice($+1,Z),X&4)U=U.replace(J4," ");if(X&8)U=j6.default(U)||U}z[A]=U}}A="",U="",W=Z,$=Z,X=0;break;case 61:if($<=W)$=Z;else X|=8;break;case 43:if($>W)X|=4;else X|=1;break;case 37:if($>W)X|=8;else X|=2;break}if(W<Q){let Z=$>W;if(A=w.slice(W+1,Z?$:Q),Z||A.length>0){if(X&1)A=A.replace(J4," ");if(X&2)A=j6.default(A)||A;if(!z[A]){if(Z){if(U=w.slice($+1,Q),X&4)U=U.replace(J4," ");if(X&8)U=j6.default(U)||U}z[A]=U}}}return z}var Y4=(w)=>{let z={};if(typeof w!=="string")return z;let A=w.length,U="",W="",$=-1,X=-1,Q=!1,Z=!1,J=!1,Y=!1,L=!1,_=0;for(let G=0;G<A+1;G++){if(G!==A)_=w.charCodeAt(G);else _=38;switch(_){case 38:{if(L=X>$,!L)X=G;if(U=w.slice($+1,X),L||U.length>0){if(J)U=U.replace(J4," ");if(Q)U=j6.default(U)||U;if(L){if(W=w.slice(X+1,G),Y)W=W.replace(J4," ");if(Z)W=j6.default(W)||W}let O=z[U];if(O===void 0)z[U]=W;else if(O.pop)O.push(W);else z[U]=[O,W]}W="",$=G,X=G,Q=!1,Z=!1,J=!1,Y=!1;break}case 61:if(X<=$)X=G;else Z=!0;break;case 43:if(X>$)Y=!0;else J=!0;break;case 37:if(X>$)Z=!0;else Q=!0;break}}return z};var YU=Ww(ew(),1);var l4=Symbol("ElysiaTrace"),t1=()=>{let{promise:w,resolve:z}=Promise.withResolvers(),{promise:A,resolve:U}=Promise.withResolvers(),{promise:W,resolve:$}=Promise.withResolvers(),X=[],Q=[];return[(Z)=>{if(Z)X.push(Z);return w},(Z)=>{let J=[],Y=[],L=null;for(let G=0;G<(Z.total??0);G++){let{promise:O,resolve:C}=Promise.withResolvers(),{promise:q,resolve:o}=Promise.withResolvers(),{promise:W0,resolve:L0}=Promise.withResolvers(),c=[],e=[];J.push((f)=>{if(f)c.push(f);return O}),Y.push((f)=>{let t={...f,end:q,error:W0,index:G,onStop(K){if(K)e.push(K);return q}};C(t);for(let K=0;K<c.length;K++)c[K](t);return(K=null)=>{let l=performance.now();if(K)L=K;let D0={end:l,error:K,get elapsed(){return l-f.begin}};for(let s=0;s<e.length;s++)e[s](D0);o(l),L0(K)}})}let _={...Z,end:A,error:W,onEvent(G){for(let O=0;O<J.length;O++)J[O](G)},onStop(G){if(G)Q.push(G);return A}};z(_);for(let G=0;G<X.length;G++)X[G](_);return{resolveChild:Y,resolve(G=null){let O=performance.now();if(!G&&L)G=L;let C={end:O,error:G,get elapsed(){return O-Z.begin}};for(let q=0;q<Q.length;q++)Q[q](C);U(O),$(G)}}}]},JU=(w)=>{return(z)=>{let[A,U]=t1(),[W,$]=t1(),[X,Q]=t1(),[Z,J]=t1(),[Y,L]=t1(),[_,G]=t1(),[O,C]=t1(),[q,o]=t1(),[W0,L0]=t1();return w({id:z[C6],context:z,set:z.set,onRequest:A,onParse:W,onTransform:X,onBeforeHandle:Z,onHandle:Y,onAfterHandle:_,onMapResponse:q,onAfterResponse:W0,onError:O}),{request:U,parse:$,transform:Q,beforeHandle:J,handle:L,afterHandle:G,error:C,mapResponse:o,afterResponse:L0}}};var s4={optional:Symbol.for("TypeBox.Optional"),kind:Symbol.for("TypeBox.Kind")},B1=(w)=>{if(!w)return!1;let z=w?.schema;if(z?.[s4.kind]==="Import")return w.References().some(B1);return!!z&&s4.optional in z},cH=["json","text","urlencoded","arrayBuffer","formdata","application/json","text/plain","application/x-www-form-urlencoded","application/octet-stream","multipart/form-data"],e2=(w)=>{if(!w)return!1;let z=w?.schema??w;if(z[s4.kind]==="Import"&&w.References())return w.References().some(e2);if(z.anyOf)return z.anyOf.some(e2);if(z.someOf)return z.someOf.some(e2);if(z.allOf)return z.allOf.some(e2);if(z.not)return z.not.some(e2);if(z.type==="object"){let A=z.properties;if("additionalProperties"in z)return z.additionalProperties;if("patternProperties"in z)return!1;for(let U of Object.keys(A)){let W=A[U];if(W.type==="object"){if(e2(W))return!0}else if(W.anyOf){for(let $=0;$<W.anyOf.length;$++)if(e2(W.anyOf[$]))return!0}return W.additionalProperties}return!1}return!1},Bz=({context:w="c",trace:z,addFn:A})=>{if(!z.length)return()=>{return{resolveChild(){return()=>{}},resolve(){}}};for(let U=0;U<z.length;U++)A(`let report${U}, reportChild${U}, reportErr${U}, reportErrChild${U};let trace${U} = ${w}[ELYSIA_TRACE]?.[${U}] ?? trace[${U}](${w});
|
|
38
|
+
`);return(U,{name:W,total:$=0}={})=>{if(!W)W="anonymous";let X=U==="error"?"reportErr":"report";for(let Q=0;Q<z.length;Q++)A(`${X}${Q} = trace${Q}.${U}({id,event:'${U}',name:'${W}',begin:performance.now(),total:${$}})
|
|
39
|
+
`);return{resolve(){for(let Q=0;Q<z.length;Q++)A(`${X}${Q}.resolve()
|
|
40
|
+
`)},resolveChild(Q){for(let Z=0;Z<z.length;Z++)A(`${X}Child${Z}=${X}${Z}.resolveChild?.shift()?.({id,event:'${U}',name:'${Q}',begin:performance.now()})
|
|
41
|
+
`);return(Z)=>{for(let J=0;J<z.length;J++)if(Z)A(`if(${Z} instanceof Error){${X}Child${J}?.(${Z}) }else{${X}Child${J}?.()}`);else A(`${X}Child${J}?.()
|
|
42
|
+
`)}}}}},nH=({injectResponse:w="",normalize:z=!1,validator:A})=>({composeValidation:(U,W=`c.${U}`)=>`c.set.status=422;throw new ValidationError('${U}',validator.${U},${W})`,composeResponseValidation:(U="r")=>{let W=w+`
|
|
43
|
+
`;W+=`if(${U} instanceof ElysiaCustomStatusResponse){c.set.status=${U}.code
|
|
44
|
+
${U}=${U}.response}const isResponse=${U} instanceof Response
|
|
45
|
+
switch(c.set.status){`;for(let[$,X]of Object.entries(A.response)){if(W+=`
|
|
46
|
+
case ${$}:if(!isResponse){`,z&&"Clean"in X&&!e2(X))W+=`${U}=validator.response['${$}'].Clean(${U})
|
|
47
|
+
`;W+=`if(validator.response['${$}'].Check(${U})===false){c.set.status=422
|
|
48
|
+
throw new ValidationError('response',validator.response['${$}'],${U})}c.set.status = ${$}}break
|
|
49
|
+
`}return W+"}"}}),GE=Symbol.for("TypeBox.Kind");var Q6=(w,z)=>{if(!z)return;let A=z.schema??z;if(A[s4.kind]==="Import")return z.References().some((U)=>Q6(w,U));if(A.type==="object"){let U=A.properties;if(!U)return!1;for(let W of Object.keys(U)){let $=U[W];if(w in $)return!0;if($.type==="object"){if(Q6(w,$))return!0}else if($.anyOf){for(let X=0;X<$.anyOf.length;X++)if(Q6(w,$.anyOf[X]))return!0}}return!1}return w in A},qz=Symbol.for("TypeBox.Transform"),F6=(w)=>{if(!w)return;if(w.type==="object"&&w.properties){let z=w.properties;for(let A of Object.keys(z)){let U=z[A];if(U.type==="object"){if(F6(U))return!0}else if(U.anyOf){for(let $=0;$<U.anyOf.length;$++)if(F6(U.anyOf[$]))return!0}if(qz in U)return!0}return!1}return qz in w||w.properties&&qz in w.properties},hH=/(?:return|=>) \S+\(/g,q4=(w)=>{return(w?.fn??w).constructor.name==="AsyncFunction"},a0=(w)=>{let z=w?.fn??w;if(z.constructor.name==="AsyncFunction")return!0;let A=z.toString();if(A.includes("=> response.clone("))return!1;if(A.includes("await"))return!0;if(A.includes("async"))return!0;if(A.includes("=>response.clone("))return!1;return!!A.match(hH)},W8=(w)=>{let z=w?.fn??w;return z.constructor.name==="AsyncGeneratorFunction"||z.constructor.name==="GeneratorFunction"},qU=({app:w,path:z,method:A,localHook:U,hooks:W,validator:$,handler:X,allowMeta:Q=!1,inference:Z,asManifest:J=!1})=>{let Y=w["~adapter"].composeHandler,L=w["~adapter"].handler,_=typeof X==="function";if(!_){if(X=L.mapResponse(X,{headers:w.setHeaders??{}}),W.parse.length===0&&W.transform.length===0&&W.beforeHandle.length===0&&W.afterHandle.length===0){if(X instanceof Response)return Function("a","return function(){return a.clone()}")(X);return Function("a","return function(){return a}")(X)}}let G=_?"handler(c)":"handler",O=W.afterResponse.length>0,C=W.trace.length>0,q="";if(Z=aw(Object.assign(U,{handler:X}),Z),Y.declare){let F=Y.declare(Z);if(F)q+=F}if(Z.server)q+=`Object.defineProperty(c,'server',{get:function(){return getServer()}})
|
|
50
|
+
`;$.createBody?.(),$.createQuery?.(),$.createHeaders?.(),$.createParams?.(),$.createCookie?.(),$.createResponse?.();let o=Z.query||!!$.query,W0=A!=="$INTERNALWS"&&A!=="GET"&&A!=="HEAD"&&(Z.body||!!$.body||W.parse.length);if(W0)q+=`let isParsing=false
|
|
51
|
+
`;let L0=w.setHeaders,c=L0&&!!Object.keys(L0).length,e=Z.headers||$.headers||Y.preferWebstandardHeaders!==!0&&Z.body,f=Z.cookie||!!$.cookie,t=f?uw({modules:w.definitions.typebox,validator:$.cookie,defaultConfig:w.config.cookie,dynamic:!!w.config.aot,config:$.cookie?.config??{},models:w.definitions.type}):void 0,K=t?.config,l="";if(K?.sign){if(!K.secrets)throw new Error(`t.Cookie required secret which is not set in (${A}) ${z}.`);let F=!K.secrets?void 0:typeof K.secrets==="string"?K.secrets:K.secrets[0];if(l+=`const _setCookie = c.set.cookie
|
|
52
|
+
if(_setCookie){`,K.sign===!0)l+=`for(const [key, cookie] of Object.entries(_setCookie)){c.set.cookie[key].value=await signCookie(cookie.value,'${F}')}`;else for(let P of K.sign)l+=`if(_setCookie['${P}']?.value){c.set.cookie['${P}'].value=await signCookie(_setCookie['${P}'].value,'${F}')}`;l+=`}
|
|
53
|
+
`}let D0=w.config.normalize,{composeValidation:s,composeResponseValidation:P1}=nH({normalize:D0,validator:$});if(e)q+=Y.headers;if(C)q+=`const id=c[ELYSIA_REQUEST_ID]
|
|
54
|
+
`;let R0=Bz({trace:W.trace,addFn:(F)=>{q+=F}});if(q+="try{",f){let F=(R,V)=>{let u=K?.[R]??V;if(!u)return typeof V==="string"?`${R}:"${V}",`:`${R}:${V},`;if(typeof u==="string")return`${R}:'${u}',`;if(u instanceof Date)return`${R}: new Date(${u.getTime()}),`;return`${R}:${u},`},P=K?`{secrets:${K.secrets!==void 0?typeof K.secrets==="string"?`'${K.secrets}'`:"["+K.secrets.reduce((R,V)=>R+`'${V}',`,"")+"]":"undefined"},sign:${K.sign===!0?!0:K.sign!==void 0?"["+K.sign.reduce((R,V)=>R+`'${V}',`,"")+"]":"undefined"},`+F("domain")+F("expires")+F("httpOnly")+F("maxAge")+F("path","/")+F("priority")+F("sameSite")+F("secure")+"}":"undefined";if(e)q+=`
|
|
55
|
+
c.cookie=await parseCookie(c.set,c.headers.cookie,${P})
|
|
56
|
+
`;else q+=`
|
|
57
|
+
c.cookie=await parseCookie(c.set,c.request.headers.get('cookie'),${P})
|
|
58
|
+
`}if(o){let F=[];if($.query&&$.query.schema.type==="object"){let P=$.query.schema.properties;if(!e2($.query))for(let[R,V]of Object.entries(P)){let u=V;if(u&&s4.optional in u&&u.type==="array"&&u.items)u=u.items;let{type:$0,anyOf:B}=u,j=$0==="array"||B?.some((H)=>H.type==="string"&&H.format==="ArrayString");F.push({key:R,isArray:j,isNestedObjectArray:j&&u.items?.type==="object"||!!u.items?.anyOf?.some((H)=>H.type==="object"||H.type==="array"),isObject:$0==="object"||B?.some((H)=>H.type==="string"&&H.format==="ArrayString"),anyOf:!!B})}}if(!F.length)q+="if(c.qi===-1){c.query={}}else{c.query=parseQueryFromURL(c.url.slice(c.qi + 1))}";else{q+=`if(c.qi!==-1){let url = '&' + decodeURIComponent(c.url.slice(c.qi + 1))
|
|
59
|
+
`;let P=0;for(let{key:R,isArray:V,isObject:u,isNestedObjectArray:$0,anyOf:B}of F){let j=(P===0?"let ":"")+`memory=url.indexOf('&${R}=')
|
|
60
|
+
let a${P}
|
|
61
|
+
`;if(V)if(q+=j,$0)q+=`while(memory!==-1){const start=memory+${R.length+2}
|
|
62
|
+
memory=url.indexOf('&',start)
|
|
63
|
+
if(a${P}===undefined)
|
|
64
|
+
a${P}=''
|
|
65
|
+
else
|
|
66
|
+
a${P}+=','
|
|
67
|
+
let temp
|
|
68
|
+
if(memory===-1)temp=decodeURIComponent(url.slice(start).replace(/\\+|%20/g,' '))
|
|
69
|
+
else temp=decodeURIComponent(url.slice(start, memory).replace(/\\+|%20/g,' '))
|
|
70
|
+
const charCode = temp.charCodeAt(0)
|
|
71
|
+
if(charCode !== 91 && charCode !== 123)
|
|
72
|
+
temp='"'+temp+'"'
|
|
73
|
+
a${P} += temp
|
|
74
|
+
if(memory === -1)break
|
|
75
|
+
memory=url.indexOf('&${R}=',memory)
|
|
76
|
+
if(memory === -1)break}try{if(a${P}.charCodeAt(0) === 91)a${P} = JSON.parse(a${P})
|
|
77
|
+
else
|
|
78
|
+
a${P}=JSON.parse('['+a${P}+']')}catch{}
|
|
79
|
+
`;else q+=`while(memory!==-1){const start=memory+${R.length+2}
|
|
80
|
+
memory=url.indexOf('&',start)
|
|
81
|
+
if(a${P}===undefined)a${P}=[]
|
|
82
|
+
if(memory===-1){a${P}.push(decodeURIComponent(url.slice(start)).replace(/\\+|%20/g,' '))
|
|
83
|
+
break}else a${P}.push(decodeURIComponent(url.slice(start, memory)).replace(/\\+|%20/g,' '))
|
|
84
|
+
memory=url.indexOf('&${R}=',memory)
|
|
85
|
+
if(memory===-1) break
|
|
86
|
+
}`;else if(u)q+=j+`if(memory!==-1){const start=memory+${R.length+2}
|
|
87
|
+
memory=url.indexOf('&',start)
|
|
88
|
+
if(memory===-1)a${P}=decodeURIComponent(url.slice(start).replace(/\\+|%20/g,' '))else a${P}=decodeURIComponent(url.slice(start,memory).replace(/\\+|%20/g,' '))if(a${P}!==undefined)try{a${P}=JSON.parse(a${P})}catch{}}`;else{if(q+=j+`if(memory!==-1){const start=memory+${R.length+2}
|
|
89
|
+
memory=url.indexOf('&',start)
|
|
90
|
+
if(memory===-1)a${P}=decodeURIComponent(url.slice(start).replace(/\\+|%20/g,' '))
|
|
91
|
+
else{a${P}=decodeURIComponent(url.slice(start,memory).replace(/\\+|%20/g,' '))`,B)q+=`
|
|
92
|
+
let deepMemory=url.indexOf('&${R}=',memory)
|
|
93
|
+
if(deepMemory!==-1){a${P}=[a${P}]
|
|
94
|
+
let first=true
|
|
95
|
+
while(true){const start=deepMemory+${R.length+2}
|
|
96
|
+
if(first)first=false
|
|
97
|
+
else deepMemory = url.indexOf('&', start)
|
|
98
|
+
let value
|
|
99
|
+
if(deepMemory===-1)value=decodeURIComponent(url.slice(start).replace(/\\+|%20/g,' '))
|
|
100
|
+
else value=decodeURIComponent(url.slice(start, deepMemory).replace(/\\+|%20/g,' '))
|
|
101
|
+
const vStart=value.charCodeAt(0)
|
|
102
|
+
const vEnd=value.charCodeAt(value.length - 1)
|
|
103
|
+
if((vStart===91&&vEnd===93)||(vStart===123&&vEnd===125))
|
|
104
|
+
try{a${P}.push(JSON.parse(value))}catch{a${P}.push(value)}if(deepMemory===-1)break}}`;q+="}}"}P++,q+=`
|
|
105
|
+
`}q+="c.query={"+F.map(({key:R},V)=>`'${R}':a${V}`).join(",")+"}",q+=`} else c.query = {}
|
|
106
|
+
`}}let v1=typeof X==="function"&&a0(X),f2=C||W.afterResponse.length>0?"c.response= ":"",q6=f||W0||v1||W.parse.length>0||W.afterHandle.some(a0)||W.beforeHandle.some(a0)||W.transform.some(a0)||W.mapResponse.some(a0),z5=(typeof X==="function"?W8(X):!1)||W.beforeHandle.some(W8)||W.afterHandle.some(W8)||W.transform.some(W8),I6=Z.cookie||Z.set||e||C||$.response||_&&c||z5,m0=Y.mapResponseContext?`,${Y.mapResponseContext}`:"";if(Z.route)q+=`c.route=\`${z}\`
|
|
107
|
+
`;let p0=R0("parse",{total:W.parse.length});if(W0){let F=B1($.body),P=W.parse.length||Z.body||$.body;if(Y.parser.declare)q+=Y.parser.declare;q+=`
|
|
108
|
+
isParsing=true`;let R=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(R&&R in cH){let V=R0("parse",{total:W.parse.length});switch(R){case"json":case"application/json":q+=Y.parser.json(F);break;case"text":case"text/plain":q+=Y.parser.text(F);break;case"urlencoded":case"application/x-www-form-urlencoded":q+=Y.parser.urlencoded(F);break;case"arrayBuffer":case"application/octet-stream":q+=Y.parser.arrayBuffer(F);break;case"formdata":case"multipart/form-data":q+=Y.parser.formData(F);break;default:if(R[0]in w["~parser"])q+=e?"let contentType = c.headers['content-type']":"let contentType = c.request.headers.get('content-type')",q+=`
|
|
109
|
+
if(contentType){const index=contentType.indexOf(';')
|
|
110
|
+
if(index!==-1)contentType=contentType.substring(0, index)}
|
|
111
|
+
else{contentType=''}c.contentType=contentType
|
|
112
|
+
`,q+=`let result=parser['${R}'](c, contentType)
|
|
113
|
+
if(result instanceof Promise)result=await result
|
|
114
|
+
if(result instanceof ElysiaCustomStatusResponse)throw result
|
|
115
|
+
if(result!==undefined)c.body=result
|
|
116
|
+
delete c.contentType
|
|
117
|
+
`;break}V.resolve()}else if(P){if(q+=`
|
|
118
|
+
`,q+=e?"let contentType = c.headers['content-type']":"let contentType = c.request.headers.get('content-type')",q+=`
|
|
119
|
+
if(contentType){const index=contentType.indexOf(';')
|
|
120
|
+
if(index!==-1)contentType=contentType.substring(0, index)}
|
|
121
|
+
else{contentType=''}c.contentType=contentType
|
|
122
|
+
`,W.parse.length)q+=`let used=false
|
|
123
|
+
`;let V=R0("parse",{total:W.parse.length}),u=!1;for(let $0=0;$0<W.parse.length;$0++){let B=`bo${$0}`;if($0!==0)q+=`
|
|
124
|
+
if(!used){`;if(typeof W.parse[$0].fn==="string"){let j=V.resolveChild(W.parse[$0].fn);switch(W.parse[$0].fn){case"json":case"application/json":u=!0,q+=Y.parser.json(F);break;case"text":case"text/plain":u=!0,q+=Y.parser.text(F);break;case"urlencoded":case"application/x-www-form-urlencoded":u=!0,q+=Y.parser.urlencoded(F);break;case"arrayBuffer":case"application/octet-stream":u=!0,q+=Y.parser.arrayBuffer(F);break;case"formdata":case"multipart/form-data":u=!0,q+=Y.parser.formData(F);break;default:q+=`${B}=parser['${W.parse[$0].fn}'](c,contentType)
|
|
125
|
+
if(${B} instanceof Promise)${B}=await ${B}
|
|
126
|
+
if(${B}!==undefined){c.body=${B};used=true}
|
|
127
|
+
`}j()}else{let j=V.resolveChild(W.parse[$0].fn.name);q+=`let ${B}=parse[${$0}]
|
|
128
|
+
${B}=${B}(c,contentType)
|
|
129
|
+
if(${B} instanceof Promise)${B}=await ${B}
|
|
130
|
+
if(${B}!==undefined){c.body=${B};used=true}`,j()}if($0!==0)q+="}";if(u)break}if(V.resolve(),!u){if(W.parse.length)q+=`
|
|
131
|
+
if(!used){
|
|
132
|
+
if(!contentType) throw new ParseError()
|
|
133
|
+
`;q+="switch(contentType){",q+=`case 'application/json':
|
|
134
|
+
`+Y.parser.json(F)+`break
|
|
135
|
+
case 'text/plain':`+Y.parser.text(F)+`break
|
|
136
|
+
case 'application/x-www-form-urlencoded':`+Y.parser.urlencoded(F)+`break
|
|
137
|
+
case 'application/octet-stream':`+Y.parser.arrayBuffer(F)+`break
|
|
138
|
+
case 'multipart/form-data':`+Y.parser.formData(F)+`break
|
|
139
|
+
`;for(let $0 of Object.keys(w["~parser"]))q+=`case '${$0}':let bo${$0}=parser['${$0}'](c,contentType)
|
|
140
|
+
if(bo${$0} instanceof Promise)bo${$0}=await bo${$0}
|
|
141
|
+
if(bo${$0} instanceof ElysiaCustomStatusResponse)throw result
|
|
142
|
+
if(bo${$0}!==undefined)c.body=bo${$0}
|
|
143
|
+
break
|
|
144
|
+
`;if(W.parse.length)q+="}";q+="}"}}q+=`
|
|
145
|
+
delete c.contentType`,q+=`
|
|
146
|
+
isParsing=false
|
|
147
|
+
`}if(p0.resolve(),W?.transform){let F=R0("transform",{total:W.transform.length});if(W.transform.length)q+=`let transformed
|
|
148
|
+
`;for(let P=0;P<W.transform.length;P++){let R=W.transform[P],V=F.resolveChild(R.fn.name);if(q+=a0(R)?`transformed=await transform[${P}](c)
|
|
149
|
+
`:`transformed=transform[${P}](c)
|
|
150
|
+
`,R.subType==="mapDerive")q+=`if(transformed instanceof ElysiaCustomStatusResponse)throw transformed
|
|
151
|
+
else{transformed.request=c.request
|
|
152
|
+
transformed.store=c.store
|
|
153
|
+
transformed.qi=c.qi
|
|
154
|
+
transformed.path=c.path
|
|
155
|
+
transformed.url=c.url
|
|
156
|
+
transformed.redirect=c.redirect
|
|
157
|
+
transformed.set=c.set
|
|
158
|
+
transformed.error=c.error
|
|
159
|
+
c=transformed}`;else q+=`if(transformed instanceof ElysiaCustomStatusResponse)throw transformed
|
|
160
|
+
else Object.assign(c,transformed)
|
|
161
|
+
`;V()}F.resolve()}if($){if($.headers){if(D0&&"Clean"in $.headers&&!e2($.headers))q+=`c.headers=validator.headers.Clean(c.headers);
|
|
162
|
+
`;if(Q6("default",$.headers))for(let[F,P]of Object.entries(p.Default($.headers.schema,{}))){let R=typeof P==="object"?JSON.stringify(P):typeof P==="string"?`'${P}'`:P;if(R!==void 0)q+=`c.headers['${F}']??=${R}
|
|
163
|
+
`}if(B1($.headers))q+="if(isNotEmpty(c.headers)){";if(q+="if(validator.headers.Check(c.headers) === false){"+s("headers")+"}",F6($.headers.schema))q+=`c.headers=validator.headers.Decode(c.headers)
|
|
164
|
+
`;if(B1($.headers))q+="}"}if($.params){if(Q6("default",$.params))for(let[F,P]of Object.entries(p.Default($.params.schema,{}))){let R=typeof P==="object"?JSON.stringify(P):typeof P==="string"?`'${P}'`:P;if(R!==void 0)q+=`c.params['${F}']??=${R}
|
|
165
|
+
`}if(q+="if(validator.params.Check(c.params)===false){"+s("params")+"}",F6($.params.schema))q+=`c.params=validator.params.Decode(c.params)
|
|
166
|
+
`}if($.query){if(D0&&"Clean"in $.query&&!e2($.query))q+=`c.query=validator.query.Clean(c.query)
|
|
167
|
+
`;if(Q6("default",$.query))for(let[F,P]of Object.entries(p.Default($.query.schema,{}))){let R=typeof P==="object"?JSON.stringify(P):typeof P==="string"?`'${P}'`:P;if(R!==void 0)q+=`if(c.query['${F}']===undefined)c.query['${F}']=${R}
|
|
168
|
+
`}if(B1($.query))q+="if(isNotEmpty(c.query)){";if(q+="if(validator.query.Check(c.query)===false){"+s("query")+"}",F6($.query.schema))q+=`c.query=validator.query.Decode(Object.assign({},c.query))
|
|
169
|
+
`;if(B1($.query))q+="}"}if($.body){if(D0&&"Clean"in $.body&&!e2($.body))q+=`c.body=validator.body.Clean(c.body)
|
|
170
|
+
`;let F=F6($.body.schema);if(F||B1($.body))q+=`const isNotEmptyObject=c.body&&(typeof c.body==="object"&&isNotEmpty(c.body))
|
|
171
|
+
`;if(Q6("default",$.body)){let P=p.Default($.body.schema,$.body.schema.type==="object"?{}:void 0),R=typeof P==="object"?JSON.stringify(P):typeof P==="string"?`'${P}'`:P;if(q+=`if(validator.body.Check(c.body)===false){if(typeof c.body==='object')c.body=Object.assign(${R},c.body)
|
|
172
|
+
else c.body=${R}
|
|
173
|
+
`,B1($.body))q+="if(isNotEmptyObject&&validator.body.Check(c.body)===false){"+s("body")+"}";else q+="if(validator.body.Check(c.body)===false){"+s("body")+"}";q+="}"}else if(B1($.body))q+="if(isNotEmptyObject&&validator.body.Check(c.body)===false){"+s("body")+"}";else q+="if(validator.body.Check(c.body)===false){"+s("body")+"}";if(F)q+=`if(isNotEmptyObject)c.body=validator.body.Decode(c.body)
|
|
174
|
+
`}if(t&&Q2(t?.schema?.properties??t?.schema?.schema??{})){if(q+=`const cookieValue={}
|
|
175
|
+
for(const [key,value] of Object.entries(c.cookie))cookieValue[key]=value.value
|
|
176
|
+
`,Q6("default",t))for(let[F,P]of Object.entries(p.Default(t.schema,{})))q+=`cookieValue['${F}'] = ${typeof P==="object"?JSON.stringify(P):P}
|
|
177
|
+
`;if(B1($.cookie))q+="if(isNotEmpty(c.cookie)){";if(q+="if(validator.cookie.Check(cookieValue)===false){"+s("cookie","cookieValue")+"}",F6($.cookie.schema))q+=`for(const [key,value] of Object.entries(validator.cookie.Decode(cookieValue)))c.cookie[key].value=value
|
|
178
|
+
`;if(B1($.cookie))q+="}"}}if(W?.beforeHandle){let F=R0("beforeHandle",{total:W.beforeHandle.length}),P=!1;for(let R=0;R<W.beforeHandle.length;R++){let V=W.beforeHandle[R],u=F.resolveChild(V.fn.name),$0=$4(V);if(V.subType==="resolve"||V.subType==="mapResolve"){if(!P)P=!0,q+=`
|
|
179
|
+
let resolved
|
|
180
|
+
`;if(q+=a0(V)?`resolved=await beforeHandle[${R}](c);
|
|
181
|
+
`:`resolved=beforeHandle[${R}](c);
|
|
182
|
+
`,V.subType==="mapResolve")q+=`if(resolved instanceof ElysiaCustomStatusResponse)throw resolved
|
|
183
|
+
else{resolved.request = c.request
|
|
184
|
+
resolved.store = c.store
|
|
185
|
+
resolved.qi = c.qi
|
|
186
|
+
resolved.path = c.path
|
|
187
|
+
resolved.url = c.url
|
|
188
|
+
resolved.redirect = c.redirect
|
|
189
|
+
resolved.set = c.set
|
|
190
|
+
resolved.error = c.error
|
|
191
|
+
c = resolved}`;else q+=`if(resolved instanceof ElysiaCustomStatusResponse)throw resolved
|
|
192
|
+
else Object.assign(c, resolved)
|
|
193
|
+
`}else if(!$0)q+=a0(V)?`await beforeHandle[${R}](c)
|
|
194
|
+
`:`beforeHandle[${R}](c)
|
|
195
|
+
`,u();else{if(q+=a0(V)?`be=await beforeHandle[${R}](c)
|
|
196
|
+
`:`be=beforeHandle[${R}](c)
|
|
197
|
+
`,u("be"),q+="if(be!==undefined){",F.resolve(),W.afterHandle?.length){R0("handle",{name:_?X.name:void 0}).resolve();let H=R0("afterHandle",{total:W.afterHandle.length});for(let i=0;i<W.afterHandle.length;i++){let E=W.afterHandle[i],k=$4(E),K0=H.resolveChild(E.fn.name);if(q+=`c.response = be
|
|
198
|
+
`,!k)q+=a0(E.fn)?`await afterHandle[${i}](c, be)
|
|
199
|
+
`:`afterHandle[${i}](c, be)
|
|
200
|
+
`;else q+=a0(E.fn)?`af = await afterHandle[${i}](c)
|
|
201
|
+
`:`af = afterHandle[${i}](c)
|
|
202
|
+
`,q+=`if(af!==undefined) c.response=be=af
|
|
203
|
+
`;K0("af")}H.resolve()}if($.response)q+=P1("be");let j=R0("mapResponse",{total:W.mapResponse.length});if(W.mapResponse.length){q+=`c.response=be
|
|
204
|
+
`;for(let H=0;H<W.mapResponse.length;H++){let i=W.mapResponse[H],E=j.resolveChild(i.fn.name);q+=`if(mr===undefined){mr=${q4(i)?"await":""} onMapResponse[${H}](c)
|
|
205
|
+
if(mr!==undefined)be=c.response=mr}`,E()}}j.resolve(),q+=l,q+=`return mapEarlyResponse(${f2}be,c.set${m0})}
|
|
206
|
+
`}}F.resolve()}if(W?.afterHandle.length){let F=R0("handle",{name:_?X.name:void 0});if(W.afterHandle.length)q+=v1?`let r=c.response=await ${G}
|
|
207
|
+
`:`let r=c.response=${G}
|
|
208
|
+
`;else q+=v1?`let r=await ${G}
|
|
209
|
+
`:`let r=${G}
|
|
210
|
+
`;F.resolve();let P=R0("afterHandle",{total:W.afterHandle.length});for(let V=0;V<W.afterHandle.length;V++){let u=W.afterHandle[V],$0=$4(u),B=P.resolveChild(u.fn.name);if(!$0)q+=a0(u.fn)?`await afterHandle[${V}](c)
|
|
211
|
+
`:`afterHandle[${V}](c)
|
|
212
|
+
`,B();else if(q+=a0(u.fn)?`af=await afterHandle[${V}](c)
|
|
213
|
+
`:`af=afterHandle[${V}](c)
|
|
214
|
+
`,B("af"),$.response)q+="if(af!==undefined){",P.resolve(),q+=P1("af"),q+="c.response=af}";else q+="if(af!==undefined){",P.resolve(),q+="c.response=af}"}if(P.resolve(),q+=`r=c.response
|
|
215
|
+
`,$.response)q+=P1();q+=l;let R=R0("mapResponse",{total:W.mapResponse.length});if(W.mapResponse.length)for(let V=0;V<W.mapResponse.length;V++){let u=W.mapResponse[V],$0=R.resolveChild(u.fn.name);q+=`mr=${q4(u)?"await":""} onMapResponse[${V}](c)
|
|
216
|
+
if(mr!==undefined)r=c.response=mr
|
|
217
|
+
`,$0()}if(R.resolve(),I6)q+=`return mapResponse(${f2}r,c.set${m0})
|
|
218
|
+
`;else q+=`return mapCompactResponse(${f2}r${m0})
|
|
219
|
+
`}else{let F=R0("handle",{name:_?X.name:void 0});if($.response||W.mapResponse.length){if(q+=v1?`let r=await ${G}
|
|
220
|
+
`:`let r=${G}
|
|
221
|
+
`,F.resolve(),$.response)q+=P1();R0("afterHandle").resolve();let P=R0("mapResponse",{total:W.mapResponse.length});if(W.mapResponse.length){q+=`
|
|
222
|
+
c.response=r
|
|
223
|
+
`;for(let R=0;R<W.mapResponse.length;R++){let V=W.mapResponse[R],u=P.resolveChild(V.fn.name);q+=`
|
|
224
|
+
if(mr===undefined){mr=${q4(V)?"await ":""}onMapResponse[${R}](c)
|
|
225
|
+
if(mr!==undefined)r=c.response=mr}
|
|
226
|
+
`,u()}}if(P.resolve(),q+=l,X instanceof Response)q+=Z.set?`if(isNotEmpty(c.set.headers)||c.set.status!==200||c.set.redirect||c.set.cookie)return mapResponse(${f2}${G}.clone(),c.set${m0})else return ${G}.clone()`:`return ${G}.clone()`,q+=`
|
|
227
|
+
`;else if(I6)q+=`return mapResponse(${f2}r,c.set${m0})
|
|
228
|
+
`;else q+=`return mapCompactResponse(${f2}r${m0})
|
|
229
|
+
`}else if(f||C){q+=v1?`let r=await ${G}
|
|
230
|
+
`:`let r=${G}
|
|
231
|
+
`,F.resolve(),R0("afterHandle").resolve();let P=R0("mapResponse",{total:W.mapResponse.length});if(W.mapResponse.length){q+=`c.response= r
|
|
232
|
+
`;for(let R=0;R<W.mapResponse.length;R++){let V=W.mapResponse[R],u=P.resolveChild(V.fn.name);q+=`if(mr===undefined){mr=${q4(V)?"await ":""}onMapResponse[${R}](c)
|
|
233
|
+
if(mr!==undefined)r=c.response=mr}`,u()}}if(P.resolve(),q+=l,I6)q+=`return mapResponse(${f2}r,c.set${m0})
|
|
234
|
+
`;else q+=`return mapCompactResponse(${f2}r${m0})
|
|
235
|
+
`}else{F.resolve();let P=v1?`await ${G}`:G;if(R0("afterHandle").resolve(),X instanceof Response)q+=Z.set?`if(isNotEmpty(c.set.headers)||c.set.status!==200||c.set.redirect||c.set.cookie)return mapResponse(${f2}${G}.clone(),c.set${m0})
|
|
236
|
+
else return ${G}.clone()
|
|
237
|
+
`:`return ${G}.clone()
|
|
238
|
+
`;else if(I6)q+=`return mapResponse(${f2}${P},c.set${m0})
|
|
239
|
+
`;else q+=`return mapCompactResponse(${f2}${P}${m0})
|
|
240
|
+
`}}if(q+=`
|
|
241
|
+
}catch(error){`,W0)q+=`if(isParsing)error=new ParseError()
|
|
242
|
+
`;if(!q6)q+="return(async()=>{";if(q+=`const set=c.set
|
|
243
|
+
if(!set.status||set.status<300)set.status=error?.status||500
|
|
244
|
+
`,C)for(let F=0;F<W.trace.length;F++)q+=`report${F}?.resolve(error);reportChild${F}?.(error)
|
|
245
|
+
`;let L2=R0("error",{total:W.error.length});if(W.error.length){q+=`c.error=error
|
|
246
|
+
if(error instanceof TypeBoxError){c.code="VALIDATION"
|
|
247
|
+
c.set.status=422}else{c.code=error.code??error[ERROR_CODE]??"UNKNOWN"}let er
|
|
248
|
+
`;for(let F=0;F<W.error.length;F++){let P=L2.resolveChild(W.error[F].fn.name);if(a0(W.error[F]))q+=`er=await handleErrors[${F}](c)
|
|
249
|
+
`;else q+=`er=handleErrors[${F}](c)
|
|
250
|
+
if(er instanceof Promise)er=await er
|
|
251
|
+
`;P();let R=R0("mapResponse",{total:W.mapResponse.length});if(W.mapResponse.length)for(let V=0;V<W.mapResponse.length;V++){let u=W.mapResponse[V],$0=R.resolveChild(u.fn.name);q+=`c.response=er
|
|
252
|
+
er=onMapResponse[${V}](c)
|
|
253
|
+
if(er instanceof Promise)er=await er
|
|
254
|
+
`,$0()}if(R.resolve(),q+=`er=mapEarlyResponse(er,set${m0})
|
|
255
|
+
`,q+="if(er){",C){for(let V=0;V<W.trace.length;V++)q+=`report${V}.resolve()
|
|
256
|
+
`;L2.resolve()}q+="return er}"}}if(L2.resolve(),q+="return handleError(c,error,true)",!q6)q+="})()";if(q+="}",O||C){if(q+="finally{ ",!q6)q+=";(async()=>{";let F=R0("afterResponse",{total:W.afterResponse.length});if(O)for(let P=0;P<W.afterResponse.length;P++){let R=F.resolveChild(W.afterResponse[P].fn.name);q+=`
|
|
257
|
+
await afterResponse[${P}](c)
|
|
258
|
+
`,R()}if(F.resolve(),!q6)q+="})()";q+="}"}let b2="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,"+(Y.inject?Object.keys(Y.inject).join(",")+",":"")+`TypeBoxError}=hooks
|
|
259
|
+
const trace=_trace.map(x=>typeof x==='function'?x:x.fn)
|
|
260
|
+
return ${q6?"async ":""}function handle(c){`;if(W.beforeHandle.length)b2+=`let be
|
|
261
|
+
`;if(W.afterHandle.length)b2+=`let af
|
|
262
|
+
`;if(W.mapResponse.length)b2+=`let mr
|
|
263
|
+
`;if(Q)b2+=`c.schema = schema
|
|
264
|
+
c.defs = definitions
|
|
265
|
+
`;b2+=q+"}";try{if(J)return Function("hooks",b2);return Function("hooks",b2)({handler:X,hooks:Uz(W),validator:$,handleError:w.handleError,utils:{mapResponse:L.mapResponse,mapCompactResponse:L.mapCompactResponse,mapEarlyResponse:L.mapEarlyResponse,parseQuery:Y4,parseQueryFromURL:ZU,isNotEmpty:Q2},error:{NotFoundError:K6,ValidationError:m,InternalServerError:sw,ParseError:rw},schema:w.router.history,definitions:w.definitions.type,ERROR_CODE:R6,parseCookie:z8,signCookie:W4,decodeURIComponent:YU.default,ElysiaCustomStatusResponse:I2,ELYSIA_TRACE:l4,ELYSIA_REQUEST_ID:C6,getServer:()=>w.getServer(),TypeBoxError:n,parser:w["~parser"],...Y.inject})}catch(F){let P=Uz(W);console.log("[Composer] failed to generate optimized handler"),console.log("---"),console.log({handler:typeof X==="function"?X.toString():X,instruction:b2,hooks:{...P,transform:P?.transform?.map?.((R)=>R.toString()),resolve:P?.resolve?.map?.((R)=>R.toString()),beforeHandle:P?.beforeHandle?.map?.((R)=>R.toString()),afterHandle:P?.afterHandle?.map?.((R)=>R.toString()),mapResponse:P?.mapResponse?.map?.((R)=>R.toString()),parse:P?.parse?.map?.((R)=>R.toString()),error:P?.error?.map?.((R)=>R.toString()),afterResponse:P?.afterResponse?.map?.((R)=>R.toString()),stop:P?.stop?.map?.((R)=>R.toString())},validator:$,definitions:w.definitions.type,error:F,fnLiteral:q}),console.log("---"),process.exit(1)}},$8=(w,{asManifest:z=!1}={})=>{let A=w["~adapter"].composeGeneralHandler,U=A.error404(!!w.event.request.length,!!w.event.error.length),W="",$=w.router,X="const route=router.find(r.method,p)";X+=$.http.root.ALL?`??router.find("ALL",p)
|
|
266
|
+
`:`
|
|
267
|
+
`,X+=U.code,X+=`
|
|
268
|
+
c.params=route.params
|
|
269
|
+
if(route.store.handler)return route.store.handler(c)
|
|
270
|
+
return (route.store.handler=route.store.compile())(c)
|
|
271
|
+
`;let Q="";for(let[G,{code:O,all:C}]of Object.entries($.static.http.map)){if(Q+=`case'${G}':`,w.config.strictPath!==!0)Q+=`case'${h1(G)}':`;Q+=`switch(r.method){${O}
|
|
272
|
+
`+(C??"default: break map")+"}"}let Z=w.event.request.some(a0),J=A.inject?Object.keys(A.inject).join(",")+",":"";if(W+=`
|
|
273
|
+
const {app,mapEarlyResponse,NotFoundError,randomId,handleError,error,redirect,ELYSIA_TRACE,ELYSIA_REQUEST_ID,`+J+`getServer}=data
|
|
274
|
+
const store=app.singleton.store
|
|
275
|
+
const decorator=app.singleton.decorator
|
|
276
|
+
const staticRouter=app.router.static.http
|
|
277
|
+
const ht=app.router.history
|
|
278
|
+
const wsRouter=app.router.ws
|
|
279
|
+
const router=app.router.http
|
|
280
|
+
const trace=app.event.trace.map(x=>typeof x==='function'?x:x.fn)
|
|
281
|
+
const notFound=new NotFoundError()
|
|
282
|
+
const hoc=app.extender.higherOrderFunctions.map(x=>x.fn)
|
|
283
|
+
`,w.event.request.length)W+=`const onRequest=app.event.request.map(x=>x.fn)
|
|
284
|
+
`;if(W+=U.declare,w.event.trace.length)W+="const "+w.event.trace.map((G,O)=>`tr${O}=app.event.trace[${O}].fn`).join(",")+`
|
|
285
|
+
`;if(W+=`${Z?"async ":""}function map(${A.parameters}){`,w.event.request.length)W+=`let re
|
|
286
|
+
`;if(W+=A.createContext(w),w.event.trace.length)W+="c[ELYSIA_TRACE]=["+w.event.trace.map((G,O)=>`tr${O}(c)`).join(",")+`]
|
|
287
|
+
`;let L=Bz({trace:w.event.trace,addFn(G){W+=G}})("request",{total:w.event.request.length});if(w.event.request.length){W+="try{";for(let G=0;G<w.event.request.length;G++){let O=w.event.request[G],C=$4(O),q=a0(O),o=L.resolveChild(w.event.request[G].fn.name);if(C)W+=`re=mapEarlyResponse(${q?"await ":""}onRequest[${G}](c),c.set)
|
|
288
|
+
`,o("re"),W+=`if(re!==undefined)return re
|
|
289
|
+
`;else W+=`${q?"await ":""}onRequest[${G}](c)
|
|
290
|
+
`,o()}W+="}catch(error){return app.handleError(c,error,false)}"}if(L.resolve(),W+=A.websocket(w),W+=`
|
|
291
|
+
map:switch(p){
|
|
292
|
+
`+Q+"default:break}"+X+`}
|
|
293
|
+
`,w.extender.higherOrderFunctions.length){let G="map";for(let O=0;O<w.extender.higherOrderFunctions.length;O++)G=`hoc[${O}](${G},${A.parameters})`;W+=`return function hocMap(${A.parameters}){return ${G}(${A.parameters})}`}else W+="return map";let _=Mz(w);return w.handleError=_,Function("data",W)({app:w,mapEarlyResponse:w["~adapter"].handler.mapEarlyResponse,NotFoundError:K6,randomId:pw,handleError:_,error:Wz,redirect:o4,ELYSIA_TRACE:l4,ELYSIA_REQUEST_ID:C6,getServer:()=>w.getServer(),...A.inject})},Mz=(w)=>{let z=w.event,A="",U=w["~adapter"].composeError,W=U.inject?Object.keys(U.inject).join(",")+",":"";A+="const {app:{event:{error:onErrorContainer,afterResponse:resContainer,mapResponse:_onMapResponse,trace:_trace}},mapResponse,ERROR_CODE,ElysiaCustomStatusResponse,ELYSIA_TRACE,"+W+`ELYSIA_REQUEST_ID}=inject
|
|
294
|
+
`,A+=`const trace=_trace.map(x=>typeof x==='function'?x:x.fn)
|
|
295
|
+
const onMapResponse=[]
|
|
296
|
+
for(let i=0;i<_onMapResponse.length;i++)onMapResponse.push(_onMapResponse[i].fn??_onMapResponse[i])
|
|
297
|
+
delete _onMapResponse
|
|
298
|
+
const onError=onErrorContainer.map(x=>x.fn)
|
|
299
|
+
const res=resContainer.map(x=>x.fn)
|
|
300
|
+
return ${w.event.error.find(a0)||w.event.mapResponse.find(a0)?"async ":""}function(context,error,skipGlobal){`;let $=w.event.trace.length>0;if(A+="",$)A+=`const id=context[ELYSIA_REQUEST_ID]
|
|
301
|
+
`;let X=Bz({context:"context",trace:z.trace,addFn:(J)=>{A+=J}});if(A+=`const set=context.set
|
|
302
|
+
let _r
|
|
303
|
+
if(!context.code)context.code=error.code??error[ERROR_CODE]
|
|
304
|
+
if(!(context.error instanceof Error))context.error=error
|
|
305
|
+
if(error instanceof ElysiaCustomStatusResponse){set.status=error.status=error.code
|
|
306
|
+
error.message=error.response}`,U.declare)A+=U.declare;let Q=$||z.afterResponse.length>0||z.afterResponse.length>0?"context.response = ":"";for(let J=0;J<w.event.error.length;J++){let Y=w.event.error[J],L=`${a0(Y)?"await ":""}onError[${J}](context)
|
|
307
|
+
`;if(A+="if(skipGlobal!==true){",$4(Y)){A+=`_r=${L}
|
|
308
|
+
if(_r!==undefined){if(_r instanceof Response)return mapResponse(_r,set${U.mapResponseContext})
|
|
309
|
+
if(_r instanceof ElysiaCustomStatusResponse){error.status=error.code
|
|
310
|
+
error.message = error.response}if(set.status===200||!set.status)set.status=error.status
|
|
311
|
+
`;let _=X("mapResponse",{total:z.mapResponse.length,name:"context"});if(z.mapResponse.length)for(let G=0;G<z.mapResponse.length;G++){let O=z.mapResponse[G],C=_.resolveChild(O.fn.name);A+=`context.response=_r_r=${q4(O)?"await ":""}onMapResponse[${G}](context)
|
|
312
|
+
`,C()}_.resolve(),A+=`return mapResponse(${Q}_r,set${U.mapResponseContext})}`}else A+=L;A+="}"}A+=`if(error.constructor.name==="ValidationError"||error.constructor.name==="TransformDecodeError"){if(error.error)error=error.error
|
|
313
|
+
set.status=error.status??422
|
|
314
|
+
`+U.validationError+"}",A+="if(error instanceof Error){"+U.unknownError+"}";let Z=X("mapResponse",{total:z.mapResponse.length,name:"context"});if(A+=`
|
|
315
|
+
if(!context.response)context.response=error.message??error
|
|
316
|
+
`,z.mapResponse.length){A+=`let mr
|
|
317
|
+
`;for(let J=0;J<z.mapResponse.length;J++){let Y=z.mapResponse[J],L=Z.resolveChild(Y.fn.name);A+=`if(mr===undefined){mr=${q4(Y)?"await ":""}onMapResponse[${J}](context)
|
|
318
|
+
if(mr!==undefined)error=context.response=mr}`,L()}}return Z.resolve(),A+=`
|
|
319
|
+
return mapResponse(${Q}error,set${U.mapResponseContext})}`,Function("inject",A)({app:w,mapResponse:w["~adapter"].handler.mapResponse,ERROR_CODE:R6,ElysiaCustomStatusResponse:I2,ELYSIA_TRACE:l4,ELYSIA_REQUEST_ID:C6,...U.inject})};var Hz=(w,z)=>{for(let[A,U]of Object.entries(w.schema.properties))z[A]??=U.default},Gz=(w)=>{let{mapResponse:z,mapEarlyResponse:A}=w["~adapter"].handler;return async(U)=>{let W=U.url,$=W.indexOf("/",11),X=W.indexOf("?",$+1),Q=X===-1?W.substring($):W.substring($,X),Z={cookie:{},status:200,headers:{}},J=Object.assign({},w.singleton.decorator,{set:Z,store:w.singleton.store,request:U,path:Q,qi:X,redirect:o4});try{for(let f=0;f<w.event.request.length;f++){let t=w.event.request[f].fn,K=t(J);if(K instanceof Promise)K=await K;if(K=A(K,Z),K)return J.response=K}let Y=w.router.dynamic.find(U.method,Q)??w.router.dynamic.find("ALL",Q);if(!Y)throw new K6;let{handle:L,hooks:_,validator:G,content:O}=Y.store,C;if(U.method!=="GET"&&U.method!=="HEAD")if(O)switch(O){case"application/json":C=await U.json();break;case"text/plain":C=await U.text();break;case"application/x-www-form-urlencoded":C=Y4(await U.text());break;case"application/octet-stream":C=await U.arrayBuffer();break;case"multipart/form-data":C={};let f=await U.formData();for(let t of f.keys()){if(C[t])continue;let K=f.getAll(t);if(K.length===1)C[t]=K[0];else C[t]=K}break}else{let f=U.headers.get("content-type");if(f){let t=f.indexOf(";");if(t!==-1)f=f.slice(0,t);J.contentType=f;for(let K=0;K<_.parse.length;K++){let l=_.parse[K].fn,D0=l(J,f);if(D0 instanceof Promise)D0=await D0;if(D0){C=D0;break}}if(delete J.contentType,C===void 0)switch(f){case"application/json":C=await U.json();break;case"text/plain":C=await U.text();break;case"application/x-www-form-urlencoded":C=Y4(await U.text());break;case"application/octet-stream":C=await U.arrayBuffer();break;case"multipart/form-data":C={};let K=await U.formData();for(let l of K.keys()){if(C[l])continue;let D0=K.getAll(l);if(D0.length===1)C[l]=D0[0];else C[l]=D0}break}}}J.body=C,J.params=Y?.params||void 0,J.query=X===-1?{}:Y4(W.substring(X+1)),J.headers={};for(let[f,t]of U.headers.entries())J.headers[f]=t;let q=Object.assign({},w.config?.cookie,G?.cookie?.config),o=U.headers.get("cookie");J.cookie=await z8(J.set,o,q?{secrets:q.secrets!==void 0?typeof q.secrets==="string"?q.secrets:q.secrets.join(","):void 0,sign:q.sign===!0?!0:q.sign!==void 0?typeof q.sign==="string"?q.sign:q.sign.join(","):void 0}:void 0);let W0=G?.createHeaders?.();if(W0)Hz(W0,J.headers);let L0=G?.createParams?.();if(L0)Hz(L0,J.params);let c=G?.createQuery?.();if(c)Hz(c,J.query);for(let f=0;f<_.transform.length;f++){let t=_.transform[f],K=t.fn(J);if(t.subType==="derive")if(K instanceof Promise)Object.assign(J,await K);else Object.assign(J,K);else if(K instanceof Promise)await K}if(G){if(W0){let f=structuredClone(J.headers);for(let[t,K]of U.headers)f[t]=K;if(G.headers.Check(f)===!1)throw new m("header",G.headers,f)}else if(G.headers?.Decode)J.headers=G.headers.Decode(J.headers);if(L0?.Check(J.params)===!1)throw new m("params",G.params,J.params);else if(G.params?.Decode)J.params=G.params.Decode(J.params);if(c?.Check(J.query)===!1)throw new m("query",G.query,J.query);else if(G.query?.Decode)J.query=G.query.Decode(J.query);if(G.createCookie?.()){let f={};for(let[t,K]of Object.entries(J.cookie))f[t]=K.value;if(G.cookie.Check(f)===!1)throw new m("cookie",G.cookie,f);else if(G.cookie?.Decode)f=G.cookie.Decode(f)}if(G.createBody?.()?.Check(C)===!1)throw new m("body",G.body,C);else if(G.body?.Decode)J.body=G.body.Decode(C)}for(let f=0;f<_.beforeHandle.length;f++){let t=_.beforeHandle[f],K=t.fn(J);if(t.subType==="resolve"){if(K instanceof I2){let l=A(K,J.set);if(l)return J.response=l}if(K instanceof Promise)Object.assign(J,await K);else Object.assign(J,K);continue}else if(K instanceof Promise)K=await K;if(K!==void 0){J.response=K;for(let D0=0;D0<_.afterHandle.length;D0++){let s=_.afterHandle[D0].fn(J);if(s instanceof Promise)s=await s;if(s)K=s}let l=A(K,J.set);if(l)return J.response=l}}let e=typeof L==="function"?L(J):L;if(e instanceof Promise)e=await e;if(!_.afterHandle.length){let f=e instanceof I2?e.code:Z.status?typeof Z.status==="string"?U6[Z.status]:Z.status:200,t=G?.createResponse?.()?.[f];if(t?.Check(e)===!1)throw new m("response",t,e);else if(t?.Decode)e=t.Decode(e)}else{J.response=e;for(let f=0;f<_.afterHandle.length;f++){let t=_.afterHandle[f].fn(J);if(t instanceof Promise)t=await t;let K=A(t,J.set);if(K!==void 0){let l=G?.response?.[K.status];if(l?.Check(K)===!1)throw new m("response",l,K);else if(l?.Decode)e=l.Decode(e);return J.response=K}}}if(J.set.cookie&&q?.sign){let f=!q.secrets?void 0:typeof q.secrets==="string"?q.secrets:q.secrets[0];if(q.sign===!0)for(let[t,K]of Object.entries(J.set.cookie))J.set.cookie[t].value=await W4(K.value,"${secret}");else{let t=G?.cookie?.schema?.properties;for(let K of q.sign){if(!(K in t))continue;if(J.set.cookie[K]?.value)J.set.cookie[K].value=await W4(J.set.cookie[K].value,f)}}}return z(J.response=e,J.set)}catch(Y){let L=Y instanceof fw&&Y.error?Y.error:Y;return w.handleError(J,L)}finally{for(let Y of w.event.afterResponse)await Y.fn(J)}}},BU=(w)=>{let{mapResponse:z}=w["~adapter"].handler;return async(A,U)=>{let W=Object.assign(A,{error:U,code:U.code});W.set=A.set;for(let $=0;$<w.event.error.length;$++){let Q=w.event.error[$].fn(W);if(Q instanceof Promise)Q=await Q;if(Q!==void 0&&Q!==null)return A.response=z(Q,A.set)}return new Response(typeof U.cause==="string"?U.cause:U.message,{headers:A.set.headers,status:U.status??500})}};class F0{constructor(w={}){if(this.server=null,this.dependencies={},this._routes={},this._types={Prefix:"",Singleton:{},Definitions:{},Metadata:{}},this._ephemeral={},this._volatile={},this.singleton={decorator:{},store:{},derive:{},resolve:{}},this.definitions={typebox:x.Module({}),type:{},error:{}},this.extender={macros:[],higherOrderFunctions:[]},this.validator={global:null,scoped:null,local:null,getCandidate(){return U4(U4(this.global,this.scoped),this.local)}},this.event={start:[],request:[],parse:[],transform:[],beforeHandle:[],afterHandle:[],mapResponse:[],afterResponse:[],trace:[],error:[],stop:[]},this.telemetry={stack:void 0},this.router={http:new $w,ws:new $w,dynamic:new $w,static:{http:{static:{},map:{},all:""},ws:{}},history:[]},this.routeTree=new Map,this.inference={body:!1,cookie:!1,headers:!1,query:!1,set:!1,server:!1,request:!1,route:!1},this["~parser"]={},this.handle=async(z)=>this.fetch(z),this.fetch=(z)=>{return(this.fetch=this.config.aot?$8(this):Gz(this))(z)},this.handleError=async(z,A)=>{return(this.handleError=this.config.aot?Mz(this):BU(this))(z,A)},this.outerErrorHandler=(z)=>new Response(z.message||z.name||"Error",{status:z?.status??500}),this.listen=(z,A)=>{return this["~adapter"].listen(this)(z,A),this},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 A=0;A<this.event.stop.length;A++)this.event.stop[A].fn(this)}},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"?QU:Q4),w?.analytic&&(w?.name||w?.seed!==void 0))this.telemetry.stack=new Error().stack}get store(){return this.singleton.store}get decorator(){return this.singleton.decorator}get routes(){return this.router.history}getGlobalRoutes(){return this.router.history}getServer(){return this.server}get promisedModules(){if(!this._promisedModules)this._promisedModules=new Az;return this._promisedModules}env(w,z=U8){if($2(w,{modules:this.definitions.typebox,dynamic:!0,additionalProperties:!0,coerce:!0}).Check(z)===!1){let U=new m("env",w,z);throw new Error(U.all.map((W)=>W.summary).join(`
|
|
320
|
+
`))}return this}wrap(w){return this.extender.higherOrderFunctions.push({checksum:O6(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=iA({globalHook:this.event,localHook:w}),A={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 U of this.extender.macros)TA(U.fn(A),w,z)}}applyConfig(w){return this.config={prefix:"",aot:U8.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]=$2(this.definitions.typebox.Import(z));return w.modules=this.definitions.typebox,w}add(w,z,A,U,{allowMeta:W=!1,skipPrefix:$=!1}={allowMeta:!1,skipPrefix:!1}){if(U=dA(U),z!==""&&z.charCodeAt(0)!==47)z="/"+z;if(this.config.prefix&&!$)z=this.config.prefix+z;if(U?.type)switch(U.type){case"text":U.type="text/plain";break;case"json":U.type="application/json";break;case"formdata":U.type="multipart/form-data";break;case"urlencoded":U.type="application/x-www-form-urlencoded";break;case"arrayBuffer":U.type="application/octet-stream";break;default:break}let X=this.definitions.type,Q=!this.config.aot,Z={...this.validator.getCandidate()},J={body:U?.body??Z?.body,headers:U?.headers??Z?.headers,params:U?.params??Z?.params,query:U?.query??Z?.query,cookie:U?.cookie??Z?.cookie,response:U?.response??Z?.response},Y=()=>J.cookie?uw({modules:_,validator:J.cookie,defaultConfig:this.config.cookie,config:J.cookie?.config??{},dynamic:Q,models:X}):void 0,L=this.config.normalize,_=this.definitions.typebox,G=this.config.precompile===!0||typeof this.config.precompile==="object"&&this.config.precompile.schema===!0?{body:$2(J.body,{modules:_,dynamic:Q,models:X,normalize:L,additionalCoerce:a5()}),headers:$2(J.headers,{modules:_,dynamic:Q,models:X,additionalProperties:!this.config.normalize,coerce:!0,additionalCoerce:A6()}),params:$2(J.params,{modules:_,dynamic:Q,models:X,coerce:!0,additionalCoerce:A6()}),query:$2(J.query,{modules:_,dynamic:Q,models:X,normalize:L,coerce:!0,additionalCoerce:A6()}),cookie:Y(),response:ow(J.response,{modules:_,dynamic:Q,models:X,normalize:L})}:{createBody(){if(this.body)return this.body;return this.body=$2(J.body,{modules:_,dynamic:Q,models:X,normalize:L,additionalCoerce:a5()})},createHeaders(){if(this.headers)return this.headers;return this.headers=$2(J.headers,{modules:_,dynamic:Q,models:X,additionalProperties:!L,coerce:!0,additionalCoerce:A6()})},createParams(){if(this.params)return this.params;return this.params=$2(J.params,{modules:_,dynamic:Q,models:X,coerce:!0,additionalCoerce:A6()})},createQuery(){if(this.query)return this.query;return this.query=$2(J.query,{modules:_,dynamic:Q,models:X,coerce:!0,additionalCoerce:A6()})},createCookie(){if(this.cookie)return this.cookie;return this.cookie=Y()},createResponse(){if(this.response)return this.response;return this.response=ow(J.response,{modules:_,dynamic:Q,models:X,normalize:L})}};if(U=r2(U,Z),U.tags)if(!U.detail)U.detail={tags:U.tags};else U.detail.tags=U.tags;if(Q2(this.config.detail))U.detail=_2(Object.assign({},this.config.detail),U.detail);this.applyMacro(U);let O=r2(this.event,U);if(this.config.aot===!1){if(this.router.dynamic.add(w,z,{validator:G,hooks:O,content:U?.type,handle:A}),this.config.strictPath===!1)this.router.dynamic.add(w,h1(z),{validator:G,hooks:O,content:U?.type,handle:A});this.router.history.push({method:w,path:z,composed:null,handler:A,hooks:O,compile:A});return}let C=this.config.precompile===!0||typeof this.config.precompile==="object"&&this.config.precompile.compose===!0,q=v4(this.inference),o=this["~adapter"].handler,W0=typeof A!=="function"&&typeof o.createStaticHandler==="function"?o.createStaticHandler(A,O,this.setHeaders):void 0,L0=typeof A!=="function"?o.createNativeStaticHandler?.(A,O,this.setHeaders):void 0;if(this.config.nativeStaticResponse===!0&&L0&&(w==="GET"||w==="ALL"))this.router.static.http.static[z]=L0();let c=(s=!1)=>qU({app:this,path:z,method:w,localHook:r2(U),hooks:O,validator:G,handler:typeof A!=="function"&&typeof o.createStaticHandler!=="function"?()=>A:A,allowMeta:W,inference:q,asManifest:s});if(this.routeTree.has(w+z))for(let s=0;s<this.router.history.length;s++){let P1=this.router.history[s];if(P1.path===z&&P1.method===w){let R0=this.router.history.splice(s,1)[0];if(R0&&this.routeTree.has(R0?.method+R0?.path))this.routeTree.delete(R0.method+R0.path)}}else this.routeTree.set(w+z,this.router.history.length);let e=this.router.history,f=this.router.history.length,t=C?c():(s)=>(e[f].composed=c())(s),K=w==="$INTERNALWS";this.router.history.push({method:w,path:z,composed:t,handler:A,hooks:O,compile:()=>c(),websocket:U.websocket});let l=this.router.static.http,D0={handler:C?t:void 0,compile:c};if(K){let s=h1(z);if(z.indexOf(":")===-1&&z.indexOf("*")===-1)this.router.static.ws[z]=f;else if(this.router.ws.add("ws",z,D0),s)this.router.ws.add("ws",s,D0);return}if(z.indexOf(":")===-1&&z.indexOf("*")===-1){if(!l.map[z])l.map[z]={code:""};let s=W0?"":"c";if(w==="ALL")l.map[z].all=`default:return ht[${f}].composed(${s})
|
|
321
|
+
`;else l.map[z].code=`case '${w}':return ht[${f}].composed(${s})
|
|
322
|
+
${l.map[z].code}`;if(!this.config.strictPath&&this.config.nativeStaticResponse===!0&&L0&&(w==="GET"||w==="ALL"))this.router.static.http.static[h1(z)]=L0()}else if(this.router.http.add(w,z,D0),!this.config.strictPath){let s=h1(z);if(this.config.nativeStaticResponse===!0&&W0&&(w==="GET"||w==="ALL"))this.router.static.http.static[s]=W0();this.router.http.add(w,s,D0)}}headers(w){if(!w)return this;if(!this.setHeaders)this.setHeaders={};return this.setHeaders=_2(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 A={subType:"resolve",fn:z};return this.onBeforeHandle(w,A)}mapResolve(w,z){if(!z)z=w,w={as:"local"};let A={subType:"mapResolve",fn:z};return this.onBeforeHandle(w,A)}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 A of z)this.on(w,"trace",JU(A));return this}error(w,z){switch(typeof w){case"string":return z.prototype[R6]=w,this.definitions.error[w]=z,this;case"function":return this.definitions.error=w(this.definitions.error),this}for(let[A,U]of Object.entries(w))U.prototype[R6]=A,this.definitions.error[A]=U;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,A){let U;switch(typeof w){case"string":U=w,A=z;break;case"object":if(U=z,!Array.isArray(z)&&typeof z==="object")A=z;break}if(Array.isArray(A))A=r0(A);else if(typeof A==="function")A=[{fn:A}];else A=[A];let W=A;for(let $ of W)if($.scope=typeof w==="string"?"local":w?.as??"local",U==="resolve"||U==="derive")$.subType=U;if(U!=="trace")aw({[U]:W.map(($)=>$.fn)},this.inference);for(let $ of W){let X=gA($,"global",{skipIfHasType:!0});switch(U){case"start":this.event.start.push(X);break;case"request":this.event.request.push(X);break;case"parse":this.event.parse.push(X);break;case"transform":this.event.transform.push(X);break;case"derive":this.event.transform.push(r0(X,"derive"));break;case"beforeHandle":this.event.beforeHandle.push(X);break;case"resolve":this.event.beforeHandle.push(r0(X,"resolve"));break;case"afterHandle":this.event.afterHandle.push(X);break;case"mapResponse":this.event.mapResponse.push(X);break;case"afterResponse":this.event.afterResponse.push(X);break;case"trace":this.event.trace.push(X);break;case"error":this.event.error.push(X);break;case"stop":this.event.stop.push(X);break}}return this}propagate(){return X2(this.event.parse),X2(this.event.transform),X2(this.event.beforeHandle),X2(this.event.afterHandle),X2(this.event.mapResponse),X2(this.event.afterResponse),X2(this.event.trace),X2(this.event.error),this}as(w){let z={plugin:"scoped",scoped:"scoped",global:"global"}[w];if(X2(this.event.parse,z),X2(this.event.transform,z),X2(this.event.beforeHandle,z),X2(this.event.afterHandle,z),X2(this.event.mapResponse,z),X2(this.event.afterResponse,z),X2(this.event.trace,z),X2(this.event.error,z),w==="plugin")this.validator.scoped=U4(this.validator.scoped,this.validator.local),this.validator.local=null;else if(w==="global")this.validator.global=U4(this.validator.global,U4(this.validator.scoped,this.validator.local)),this.validator.scoped=null,this.validator.local=null;return this}group(w,z,A){let U=new F0({...this.config,prefix:""});U.singleton={...this.singleton},U.definitions={...this.definitions},U.getServer=()=>this.getServer(),U.inference=v4(this.inference),U.extender={...this.extender};let W=typeof z==="object",$=(W?A:z)(U);if(this.singleton=_2(this.singleton,U.singleton),this.definitions=_2(this.definitions,U.definitions),$.event.request.length)this.event.request=[...this.event.request||[],...$.event.request||[]];if($.event.mapResponse.length)this.event.mapResponse=[...this.event.mapResponse||[],...$.event.mapResponse||[]];return this.model($.definitions.type),Object.values(U.router.history).forEach(({method:X,path:Q,handler:Z,hooks:J})=>{if(Q=(W?"":this.config.prefix)+w+Q,W){let Y=z,L=J;this.add(X,Q,Z,r2(Y,{...L||{},error:!L.error?$.event.error:Array.isArray(L.error)?[...L.error||{},...$.event.error||{}]:[L.error,...$.event.error||{}]}))}else this.add(X,Q,Z,r2(J,{error:$.event.error}),{skipPrefix:!0})}),this}guard(w,z){if(!z){if(typeof w==="object"){this.applyMacro(w);let W=w.as??"local";if(this.validator[W]={body:w.body??this.validator[W]?.body,headers:w.headers??this.validator[W]?.headers,params:w.params??this.validator[W]?.params,query:w.query??this.validator[W]?.query,response:w.response??this.validator[W]?.response,cookie:w.cookie??this.validator[W]?.cookie},w.parse)this.on({as:W},"parse",w.parse);if(w.transform)this.on({as:W},"transform",w.transform);if(w.derive)this.on({as:W},"derive",w.derive);if(w.beforeHandle)this.on({as:W},"beforeHandle",w.beforeHandle);if(w.resolve)this.on({as:W},"resolve",w.resolve);if(w.afterHandle)this.on({as:W},"afterHandle",w.afterHandle);if(w.mapResponse)this.on({as:W},"mapResponse",w.mapResponse);if(w.afterResponse)this.on({as:W},"afterResponse",w.afterResponse);if(w.error)this.on({as:W},"error",w.error);if(w.detail)if(this.config.detail)this.config.detail=_2(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 A=new F0({...this.config,prefix:""});A.singleton={...this.singleton},A.definitions={...this.definitions},A.inference=v4(this.inference),A.extender={...this.extender};let U=z(A);if(this.singleton=_2(this.singleton,A.singleton),this.definitions=_2(this.definitions,A.definitions),U.getServer=()=>this.server,U.event.request.length)this.event.request=[...this.event.request||[],...U.event.request||[]];if(U.event.mapResponse.length)this.event.mapResponse=[...this.event.mapResponse||[],...U.event.mapResponse||[]];return this.model(U.definitions.type),Object.values(A.router.history).forEach(({method:W,path:$,handler:X,hooks:Q})=>{this.add(W,$,X,r2(w,{...Q||{},error:!Q.error?U.event.error:Array.isArray(Q.error)?[...Q.error||{},...U.event.error||[]]:[Q.error,...U.event.error||[]]}))}),this}use(w,z){if(Array.isArray(w)){let A=this;for(let U of w)A=A.use(U);return A}if(z?.scoped)return this.guard({},(A)=>A.use(w));if(Array.isArray(w)){let A=this;for(let U of w)A=this.use(U);return A}if(w instanceof Promise)return this.promisedModules.add(w.then((A)=>{if(typeof A==="function")return A(this);if(A instanceof F0)return this._use(A).compile();if(A.constructor.name==="Elysia")return this._use(A).compile();if(typeof A.default==="function")return A.default(this);if(A.default instanceof F0)return this._use(A.default);if(A.constructor.name==="Elysia")return this._use(A.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((A)=>A.compile())),this;return this._use(w)}_use(w){if(typeof w==="function"){let W=w(this);if(W instanceof Promise)return this.promisedModules.add(W.then(($)=>{if($ instanceof F0){$.getServer=()=>this.getServer(),$.getGlobalRoutes=()=>this.getGlobalRoutes(),$.model(this.definitions.type),$.error(this.definitions.error);for(let{method:X,path:Q,handler:Z,hooks:J}of Object.values($.router.history))this.add(X,Q,Z,r2(J,{error:$.event.error}));return $.compile(),$}if(typeof $==="function")return $(this);if(typeof $.default==="function")return $.default(this);return this._use($)}).then(($)=>$.compile())),this;return W}let{name:z,seed:A}=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 W=A!==void 0?O6(z+JSON.stringify(A)):0;if(!this.dependencies[z].some(({checksum:$})=>W===$))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);lw(this.extender.macros),lw(this.extender.higherOrderFunctions);let U=[];for(let W=0;W<this.extender.higherOrderFunctions.length;W++){let $=this.extender.higherOrderFunctions[W];if($.checksum){if(U.includes($.checksum))this.extender.higherOrderFunctions.splice(W,1),W--;U.push($.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:W,path:$,handler:X,hooks:Q}of Object.values(w.router.history))this.add(W,$,X,r2(Q,{error:w.event.error}));if(z){if(!(z in this.dependencies))this.dependencies[z]=[];let W=A!==void 0?O6(z+JSON.stringify(A)):0;if(this.dependencies[z].some(({checksum:$})=>W===$))return this;this.dependencies[z].push(this.config?.analytic?{name:w.config.name,seed:w.config.seed,checksum:W,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(($)=>$?.subType==="derive").map(($)=>({fn:$.toString(),stack:new Error().stack??""})),resolve:w.event.transform.filter(($)=>$?.subType==="resolve").map(($)=>({fn:$.toString(),stack:new Error().stack??""}))}:{name:w.config.name,seed:w.config.seed,checksum:W,dependencies:w.dependencies}),this.event=e5(this.event,wz(w.event),W)}else this.event=e5(this.event,wz(w.event));return this.validator.global=r2(this.validator.global,{...w.validator.global}),this.validator.local=r2(this.validator.local,{...w.validator.scoped}),this}macro(w){if(typeof w==="function"){let z={checksum:O6(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:O6(JSON.stringify({name:this.config.name,seed:this.config.seed,content:Object.entries(w).map(([A,U])=>`${A}+${U}`).join(",")})),fn:()=>w};this.extender.macros.push(z)}return this}mount(w,z){if(w instanceof F0||typeof w==="function"||w.length===0||w==="/"){let W=typeof w==="function"?w:w instanceof F0?w.compile().fetch:z instanceof F0?z.compile().fetch:z,$=async({request:X,path:Q})=>{if(X.method==="GET"||X.method==="HEAD"||!X.headers.get("content-type"))return W(new Request(A4(X.url,Q||"/"),X));return W(new Request(A4(X.url,Q||"/"),{...X,body:await X.arrayBuffer()}))};return this.all("/*",$,{type:"none"}),this}let A=w.length;if(z instanceof F0)z=z.compile().fetch;let U=async({request:W,path:$})=>{if(W.method==="GET"||W.method==="HEAD"||!W.headers.get("content-type"))return z(new Request(A4(W.url,$.slice(A)||"/"),W));return z(new Request(A4(W.url,$.slice(A)||"/"),{...W,body:await W.arrayBuffer()}))};return this.all(w,U,{type:"none"}),this.all(w+(w.endsWith("/")?"*":"/*"),U,{type:"none"}),this}get(w,z,A){return this.add("GET",w,z,A),this}post(w,z,A){return this.add("POST",w,z,A),this}put(w,z,A){return this.add("PUT",w,z,A),this}patch(w,z,A){return this.add("PATCH",w,z,A),this}delete(w,z,A){return this.add("DELETE",w,z,A),this}options(w,z,A){return this.add("OPTIONS",w,z,A),this}all(w,z,A){return this.add("ALL",w,z,A),this}head(w,z,A){return this.add("HEAD",w,z,A),this}connect(w,z,A){return this.add("CONNECT",w,z,A),this}route(w,z,A,U){return this.add(w.toUpperCase(),z,A,U,U?.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,A){if(z===void 0)A=w,w={as:"append"},z="";else if(A===void 0){if(typeof w==="string")A=z,z=w,w={as:"append"};else if(typeof w==="object")A=z,z=""}let{as:U}=w;if(typeof z!=="string")return this;switch(typeof A){case"object":if(z){if(z in this.singleton.store)this.singleton.store[z]=_2(this.singleton.store[z],A,{override:U==="override"});else this.singleton.store[z]=A;return this}if(A===null)return this;return this.singleton.store=_2(this.singleton.store,A,{override:U==="override"}),this;case"function":if(z){if(U==="override"||!(z in this.singleton.store))this.singleton.store[z]=A}else this.singleton.store=A(this.singleton.store);return this;default:if(U==="override"||!(z in this.singleton.store))this.singleton.store[z]=A;return this}}decorate(w,z,A){if(z===void 0)A=w,w={as:"append"},z="";else if(A===void 0){if(typeof w==="string")A=z,z=w,w={as:"append"};else if(typeof w==="object")A=z,z=""}let{as:U}=w;if(typeof z!=="string")return this;switch(typeof A){case"object":if(z){if(z in this.singleton.decorator)this.singleton.decorator[z]=_2(this.singleton.decorator[z],A,{override:U==="override"});else this.singleton.decorator[z]=A;return this}if(A===null)return this;return this.singleton.decorator=_2(this.singleton.decorator,A,{override:U==="override"}),this;case"function":if(z){if(U==="override"||!(z in this.singleton.decorator))this.singleton.decorator[z]=A}else this.singleton.decorator=A(this.singleton.decorator);return this;default:if(U==="override"||!(z in this.singleton.decorator))this.singleton.decorator[z]=A;return this}}derive(w,z){if(!z)z=w,w={as:"local"};let A={subType:"derive",fn:z};return this.onTransform(w,A)}model(w,z){let A=(U)=>t4(U,[{from:x.Number(),to:(W)=>x.Numeric(W),untilObjectFound:!0},{from:x.Boolean(),to:(W)=>x.BooleanString(W),untilObjectFound:!0}]);switch(typeof w){case"object":let U={};return Object.entries(w).forEach(([$,X])=>{if(!($ in this.definitions.type))U[$]=this.definitions.type[$]=A(X)}),this.definitions.typebox=x.Module({...this.definitions.typebox.$defs,...U}),this;case"function":let W=A(w(this.definitions.type));return this.definitions.type=W,this.definitions.typebox=x.Module(W),this}return this.definitions.type[w]=z,this.definitions.typebox=x.Module({...this.definitions.typebox.$defs,[w]:z}),this}mapDerive(w,z){if(!z)z=w,w={as:"local"};let A={subType:"mapDerive",fn:z};return this.onTransform(w,A)}affix(w,z,A){if(A==="")return this;let U=["_","-"," "],W=(Z)=>Z[0].toUpperCase()+Z.slice(1),$=w==="prefix"?(Z,J)=>U.includes(Z.at(-1)??"")?Z+J:Z+W(J):U.includes(A.at(-1)??"")?(Z,J)=>J+Z:(Z,J)=>J+W(Z),X=(Z)=>{let J={};switch(Z){case"decorator":for(let Y in this.singleton.decorator)J[$(A,Y)]=this.singleton.decorator[Y];this.singleton.decorator=J;break;case"state":for(let Y in this.singleton.store)J[$(A,Y)]=this.singleton.store[Y];this.singleton.store=J;break;case"model":for(let Y in this.definitions.type)J[$(A,Y)]=this.definitions.type[Y];this.definitions.type=J;break;case"error":for(let Y in this.definitions.error)J[$(A,Y)]=this.definitions.error[Y];this.definitions.error=J;break}},Q=Array.isArray(z)?z:[z];for(let Z of Q.some((J)=>J==="all")?["decorator","state","model","error"]:Q)X(Z);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?$8(this):Gz(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=$8(this),this}get modules(){return Promise.all(this.promisedModules.promises)}}var MU;(function(w){w[w.Include=0]="Include",w[w.None=1]="None"})(MU||(MU={}));var HU;(function(w){w[w.Required=0]="Required",w[w.Ignore=1]="Ignore"})(HU||(HU={}));function Lz(w){return LU(w,tH,r4.Include)}function a4(w){return LU(w,yH,r4.None)}function LU(w,z,A){let U="";for(let W=0;W<w.byteLength;W+=3){let $=0,X=0;for(let Q=0;Q<3&&W+Q<w.byteLength;Q++)$=$<<8|w[W+Q],X+=8;for(let Q=0;Q<4;Q++)if(X>=6)U+=z[$>>X-6&63],X-=6;else if(X>0)U+=z[$<<6-X&63],X=0;else if(A===r4.Include)U+="="}return U}var tH="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",yH="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_";var r4;(function(w){w[w.Include=0]="Include",w[w.None=1]="None"})(r4||(r4={}));var GU;(function(w){w[w.Required=0]="Required",w[w.Ignore=1]="Ignore"})(GU||(GU={}));class NU{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 A=0;for(let U=0;U<4;U++)A|=w[z+U]<<24-U*8;return A}uint64(w,z){if(w.byteLength<z+8)throw new TypeError("Insufficient bytes");let A=0n;for(let U=0;U<8;U++)A|=BigInt(w[z+U])<<BigInt(56-U*8);return A}putUint8(w,z,A){if(w.length<A+1)throw new TypeError("Not enough space");if(z<0||z>255)throw new TypeError("Invalid uint8 value");w[A]=z}putUint16(w,z,A){if(w.length<A+2)throw new TypeError("Not enough space");if(z<0||z>65535)throw new TypeError("Invalid uint16 value");w[A]=z>>8,w[A+1]=z&255}putUint32(w,z,A){if(w.length<A+4)throw new TypeError("Not enough space");if(z<0||z>4294967295)throw new TypeError("Invalid uint32 value");for(let U=0;U<4;U++)w[A+U]=z>>(3-U)*8&255}putUint64(w,z,A){if(w.length<A+8)throw new TypeError("Not enough space");if(z<0||z>18446744073709551615n)throw new TypeError("Invalid uint64 value");for(let U=0;U<8;U++)w[A+U]=Number(z>>BigInt((7-U)*8)&0xffn)}}class SU{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 A=0;for(let U=0;U<4;U++)A|=w[z+U]<<U*8;return A}uint64(w,z){if(w.byteLength<z+8)throw new TypeError("Insufficient bytes");let A=0n;for(let U=0;U<8;U++)A|=BigInt(w[z+U])<<BigInt(U*8);return A}putUint8(w,z,A){if(w.length<1+A)throw new TypeError("Insufficient space");if(z<0||z>255)throw new TypeError("Invalid uint8 value");w[A]=z}putUint16(w,z,A){if(w.length<2+A)throw new TypeError("Insufficient space");if(z<0||z>65535)throw new TypeError("Invalid uint16 value");w[A+1]=z>>8,w[A]=z&255}putUint32(w,z,A){if(w.length<4+A)throw new TypeError("Insufficient space");if(z<0||z>4294967295)throw new TypeError("Invalid uint32 value");for(let U=0;U<4;U++)w[A+U]=z>>U*8&255}putUint64(w,z,A){if(w.length<8+A)throw new TypeError("Insufficient space");if(z<0||z>18446744073709551615n)throw new TypeError("Invalid uint64 value");for(let U=0;U<8;U++)w[A+U]=Number(z>>BigInt(U*8)&0xffn)}}var _1=new NU,vH=new SU;function t0(w,z){return(w<<32-z|w>>>z)>>>0}function w1(w,z){return(w<<BigInt(64-z)|w>>BigInt(z))&0xffffffffffffffffn}class DU{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 A=w.slice(0,64-this.currentBlockSize);this.blocks.set(A,this.currentBlockSize),this.process(),z+=A.byteLength,this.currentBlockSize=0}while(z+64<=w.byteLength){let A=w.slice(z,z+64);this.blocks.set(A),this.process(),z+=64}if(w.byteLength-z>0){let A=w.slice(z);this.blocks.set(A),this.currentBlockSize=A.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),_1.putUint64(this.blocks,this.l,this.blockSize-8),this.process();let w=new Uint8Array(28);for(let z=0;z<7;z++)_1.putUint32(w,this.H[z],z*4);return w}process(){for(let Z=0;Z<16;Z++)this.w[Z]=(this.blocks[Z*4]<<24|this.blocks[Z*4+1]<<16|this.blocks[Z*4+2]<<8|this.blocks[Z*4+3])>>>0;for(let Z=16;Z<64;Z++){let J=(t0(this.w[Z-2],17)^t0(this.w[Z-2],19)^this.w[Z-2]>>>10)>>>0,Y=(t0(this.w[Z-15],7)^t0(this.w[Z-15],18)^this.w[Z-15]>>>3)>>>0;this.w[Z]=J+this.w[Z-7]+Y+this.w[Z-16]|0}let w=this.H[0],z=this.H[1],A=this.H[2],U=this.H[3],W=this.H[4],$=this.H[5],X=this.H[6],Q=this.H[7];for(let Z=0;Z<64;Z++){let J=(t0(W,6)^t0(W,11)^t0(W,25))>>>0,Y=(W&$^~W&X)>>>0,L=Q+J+Y+oH[Z]+this.w[Z]|0,_=(t0(w,2)^t0(w,13)^t0(w,22))>>>0,G=(w&z^w&A^z&A)>>>0,O=_+G|0;Q=X,X=$,$=W,W=U+L|0,U=A,A=z,z=w,w=L+O|0}this.H[0]=w+this.H[0]|0,this.H[1]=z+this.H[1]|0,this.H[2]=A+this.H[2]|0,this.H[3]=U+this.H[3]|0,this.H[4]=W+this.H[4]|0,this.H[5]=$+this.H[5]|0,this.H[6]=X+this.H[6]|0,this.H[7]=Q+this.H[7]|0}}var oH=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 bz(w){let z=new Nz;return z.update(w),z.digest()}class Nz{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 A=w.slice(0,64-this.currentBlockSize);this.blocks.set(A,this.currentBlockSize),this.process(),z+=A.byteLength,this.currentBlockSize=0}while(z+64<=w.byteLength){let A=w.slice(z,z+64);this.blocks.set(A),this.process(),z+=64}if(w.byteLength-z>0){let A=w.slice(z);this.blocks.set(A),this.currentBlockSize=A.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),_1.putUint64(this.blocks,this.l,this.blockSize-8),this.process();let w=new Uint8Array(32);for(let z=0;z<8;z++)_1.putUint32(w,this.H[z],z*4);return w}process(){for(let Z=0;Z<16;Z++)this.w[Z]=(this.blocks[Z*4]<<24|this.blocks[Z*4+1]<<16|this.blocks[Z*4+2]<<8|this.blocks[Z*4+3])>>>0;for(let Z=16;Z<64;Z++){let J=(t0(this.w[Z-2],17)^t0(this.w[Z-2],19)^this.w[Z-2]>>>10)>>>0,Y=(t0(this.w[Z-15],7)^t0(this.w[Z-15],18)^this.w[Z-15]>>>3)>>>0;this.w[Z]=J+this.w[Z-7]+Y+this.w[Z-16]|0}let w=this.H[0],z=this.H[1],A=this.H[2],U=this.H[3],W=this.H[4],$=this.H[5],X=this.H[6],Q=this.H[7];for(let Z=0;Z<64;Z++){let J=(t0(W,6)^t0(W,11)^t0(W,25))>>>0,Y=(W&$^~W&X)>>>0,L=Q+J+Y+uH[Z]+this.w[Z]|0,_=(t0(w,2)^t0(w,13)^t0(w,22))>>>0,G=(w&z^w&A^z&A)>>>0,O=_+G|0;Q=X,X=$,$=W,W=U+L|0,U=A,A=z,z=w,w=L+O|0}this.H[0]=w+this.H[0]|0,this.H[1]=z+this.H[1]|0,this.H[2]=A+this.H[2]|0,this.H[3]=U+this.H[3]|0,this.H[4]=W+this.H[4]|0,this.H[5]=$+this.H[5]|0,this.H[6]=X+this.H[6]|0,this.H[7]=Q+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]);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 A=w.slice(0,128-this.currentBlockSize);this.blocks.set(A,this.currentBlockSize),this.process(),z+=A.byteLength,this.currentBlockSize=0}while(z+128<=w.byteLength){let A=w.slice(z,z+128);this.blocks.set(A),this.process(),z+=128,this.currentBlockSize=0}if(w.byteLength-z>0){let A=w.slice(z);this.blocks.set(A),this.currentBlockSize=A.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),_1.putUint64(this.blocks,this.l,this.blockSize-8),this.process();for(let z=0;z<w.byteLength/8;z++)_1.putUint64(w,this.H[z],z*8)}process(){for(let Z=0;Z<16;Z++)this.w[Z]=BigInt(this.blocks[Z*8])<<56n|BigInt(this.blocks[Z*8+1])<<48n|BigInt(this.blocks[Z*8+2])<<40n|BigInt(this.blocks[Z*8+3])<<32n|BigInt(this.blocks[Z*8+4])<<24n|BigInt(this.blocks[Z*8+5])<<16n|BigInt(this.blocks[Z*8+6])<<8n|BigInt(this.blocks[Z*8+7]);for(let Z=16;Z<80;Z++){let J=(w1(this.w[Z-2],19)^w1(this.w[Z-2],61)^this.w[Z-2]>>6n)&0xffffffffffffffffn,Y=(w1(this.w[Z-15],1)^w1(this.w[Z-15],8)^this.w[Z-15]>>7n)&0xffffffffffffffffn;this.w[Z]=J+this.w[Z-7]+Y+this.w[Z-16]&0xffffffffffffffffn}let w=this.H[0],z=this.H[1],A=this.H[2],U=this.H[3],W=this.H[4],$=this.H[5],X=this.H[6],Q=this.H[7];for(let Z=0;Z<80;Z++){let J=(w1(W,14)^w1(W,18)^w1(W,41))&0xffffffffffffffffn,Y=(W&$^~W&X)&0xffffffffffffffffn,L=Q+J+Y+mH[Z]+this.w[Z]&0xffffffffffffffffn,_=(w1(w,28)^w1(w,34)^w1(w,39))&0xffffffffffffffffn,G=(w&z^w&A^z&A)&0xffffffffffffffffn,O=_+G&0xffffffffffffffffn;Q=X,X=$,$=W,W=U+L&0xffffffffffffffffn,U=A,A=z,z=w,w=L+O&0xffffffffffffffffn}this.H[0]=w+this.H[0]&0xffffffffffffffffn,this.H[1]=z+this.H[1]&0xffffffffffffffffn,this.H[2]=A+this.H[2]&0xffffffffffffffffn,this.H[3]=U+this.H[3]&0xffffffffffffffffn,this.H[4]=W+this.H[4]&0xffffffffffffffffn,this.H[5]=$+this.H[5]&0xffffffffffffffffn,this.H[6]=X+this.H[6]&0xffffffffffffffffn,this.H[7]=Q+this.H[7]&0xffffffffffffffffn}}class _U{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 mH=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 PU{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 OU{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 CU{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 B4{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 M4(w){let z=bz(new TextEncoder().encode(w));return a4(z)}function Sz(){let w=new Uint8Array(32);return crypto.getRandomValues(w),a4(w)}function Dz(){let w=new Uint8Array(32);return crypto.getRandomValues(w),a4(w)}function RU(w,z){if(z.length!==1)throw new TypeError("Invalid character string");let A=0;while(A<w.length&&w[A]===z)A++;return w.slice(A)}function _z(w,z){if(z.length!==1)throw new TypeError("Invalid character string");let A=w.length;while(A>0&&w[A-1]===z)A--;return w.slice(0,A)}function G2(w,...z){let A=_z(w,"/");for(let U of z)A+="/",A+=_z(RU(U,"/"),"/");return A}function g(w,z){let A=new TextEncoder().encode(z.toString()),U=new Request(w,{method:"POST",body:A});return U.headers.set("Content-Type","application/x-www-form-urlencoded"),U.headers.set("Accept","application/json"),U.headers.set("User-Agent","arctic"),U.headers.set("Content-Length",A.byteLength.toString()),U}function x6(w,z){let A=new TextEncoder().encode(`${w}:${z}`);return Lz(A)}async function h(w){let z;try{z=await fetch(w)}catch(A){throw new J6(A)}if(z.status===400||z.status===401){let A;try{A=await z.json()}catch{throw new y1(z.status)}if(typeof A!=="object"||A===null)throw new M1(z.status,A);let U;try{U=X8(A)}catch{throw new M1(z.status,A)}throw U}if(z.status===200){let A;try{A=await z.json()}catch{throw new y1(z.status)}if(typeof A!=="object"||A===null)throw new M1(z.status,A);return new B4(A)}if(z.body!==null)await z.body.cancel();throw new y1(z.status)}async function H4(w){let z;try{z=await fetch(w)}catch(A){throw new J6(A)}if(z.status===400||z.status===401){let A;try{A=await z.json()}catch{throw new M1(z.status,null)}if(typeof A!=="object"||A===null)throw new M1(z.status,A);let U;try{U=X8(A)}catch{throw new M1(z.status,A)}throw U}if(z.status===200){if(z.body!==null)await z.body.cancel();return}if(z.body!==null)await z.body.cancel();throw new y1(z.status)}function X8(w){let z;if("error"in w&&typeof w.error==="string")z=w.error;else throw new Error("Invalid error response");let A=null,U=null,W=null;if("error_description"in w){if(typeof w.error_description!=="string")throw new Error("Invalid data");A=w.error_description}if("error_uri"in w){if(typeof w.error_uri!=="string")throw new Error("Invalid data");U=w.error_uri}if("state"in w){if(typeof w.state!=="string")throw new Error("Invalid data");W=w.state}return new e4(z,A,U,W)}class J6 extends Error{constructor(w){super("Failed to send request",{cause:w})}}class e4 extends Error{code;description;uri;state;constructor(w,z,A,U){super(`OAuth request error: ${w}`);this.code=w,this.description=z,this.uri=A,this.state=U}}class y1 extends Error{status;constructor(w){super("Unexpected error response");this.status=w}}class M1 extends Error{status;data;constructor(w,z){super("Unexpected error response body");this.status=w,this.data=z}}class T{clientId;clientPassword;redirectURI;constructor(w,z,A){this.clientId=w,this.clientPassword=z,this.redirectURI=A}createAuthorizationURL(w,z,A){let U=new URL(w);if(U.searchParams.set("response_type","code"),U.searchParams.set("client_id",this.clientId),this.redirectURI!==null)U.searchParams.set("redirect_uri",this.redirectURI);if(U.searchParams.set("state",z),A.length>0)U.searchParams.set("scope",A.join(" "));return U}createAuthorizationURLWithPKCE(w,z,A,U,W){let $=new URL(w);if($.searchParams.set("response_type","code"),$.searchParams.set("client_id",this.clientId),this.redirectURI!==null)$.searchParams.set("redirect_uri",this.redirectURI);if($.searchParams.set("state",z),A===U0.S256){let X=M4(U);$.searchParams.set("code_challenge_method","S256"),$.searchParams.set("code_challenge",X)}else if(A===U0.Plain)$.searchParams.set("code_challenge_method","plain"),$.searchParams.set("code_challenge",U);if(W.length>0)$.searchParams.set("scope",W.join(" "));return $}async validateAuthorizationCode(w,z,A){let U=new URLSearchParams;if(U.set("grant_type","authorization_code"),U.set("code",z),this.redirectURI!==null)U.set("redirect_uri",this.redirectURI);if(A!==null)U.set("code_verifier",A);if(this.clientPassword===null)U.set("client_id",this.clientId);let W=g(w,U);if(this.clientPassword!==null){let X=x6(this.clientId,this.clientPassword);W.headers.set("Authorization",`Basic ${X}`)}return await h(W)}async refreshAccessToken(w,z,A){let U=new URLSearchParams;if(U.set("grant_type","refresh_token"),U.set("refresh_token",z),this.clientPassword===null)U.set("client_id",this.clientId);if(A.length>0)U.set("scope",A.join(" "));let W=g(w,U);if(this.clientPassword!==null){let X=x6(this.clientId,this.clientPassword);W.headers.set("Authorization",`Basic ${X}`)}return await h(W)}async revokeToken(w,z){let A=new URLSearchParams;if(A.set("token",z),this.clientPassword===null)A.set("client_id",this.clientId);let U=g(w,A);if(this.clientPassword!==null){let W=x6(this.clientId,this.clientPassword);U.headers.set("Authorization",`Basic ${W}`)}await H4(U)}}var U0;(function(w){w[w.S256=0]="S256",w[w.Plain=1]="Plain"})(U0||(U0={}));class Q8{authorizationEndpoint;tokenEndpoint;tokenRevocationEndpoint;client;constructor(w,z,A,U){this.authorizationEndpoint=`https://${w}/oauth2/authorize`,this.tokenEndpoint=`https://${w}/oauth2/token`,this.tokenRevocationEndpoint=`https://${w}/oauth2/revoke`,this.client=new T(z,A,U)}createAuthorizationURL(w,z,A){return this.client.createAuthorizationURLWithPKCE(this.authorizationEndpoint,w,U0.S256,z,A)}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 lH="https://anilist.co/api/v2/oauth/authorize",sH="https://anilist.co/api/v2/oauth/token";class Z8{client;constructor(w,z,A){this.client=new T(w,z,A)}createAuthorizationURL(w){return this.client.createAuthorizationURL(lH,w,[])}async validateAuthorizationCode(w){return await this.client.validateAuthorizationCode(sH,w,null)}}var KU;(function(w){w[w.Include=0]="Include",w[w.None=1]="None"})(KU||(KU={}));var jU;(function(w){w[w.Required=0]="Required",w[w.Ignore=1]="Ignore"})(jU||(jU={}));function E6(w){return rH(w,aH,J8.None)}function rH(w,z,A){let U="";for(let W=0;W<w.byteLength;W+=3){let $=0,X=0;for(let Q=0;Q<3&&W+Q<w.byteLength;Q++)$=$<<8|w[W+Q],X+=8;for(let Q=0;Q<4;Q++)if(X>=6)U+=z[$>>X-6&63],X-=6;else if(X>0)U+=z[$<<6-X&63],X=0;else if(A===J8.Include)U+="="}return U}var aH="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_";function Pz(w){return eH(w,wG,ww.Ignore)}function eH(w,z,A){let U=new Uint8Array(Math.ceil(w.length/4)*3),W=0;for(let $=0;$<w.length;$+=4){let X=0,Q=0;for(let J=0;J<4;J++){if(A===ww.Required&&w[$+J]==="=")continue;if(A===ww.Ignore&&($+J>=w.length||w[$+J]==="="))continue;if(J>0&&w[$+J-1]==="=")throw new Error("Invalid padding");if(!(w[$+J]in z))throw new Error("Invalid character");X|=z[w[$+J]]<<(3-J)*6,Q+=6}if(Q<24){let J;if(Q===12)J=X&65535;else if(Q===18)J=X&255;else throw new Error("Invalid padding");if(J!==0)throw new Error("Invalid padding")}let Z=Math.floor(Q/8);for(let J=0;J<Z;J++)U[W]=X>>16-J*8&255,W++}return U.slice(0,W)}var J8;(function(w){w[w.Include=0]="Include",w[w.None=1]="None"})(J8||(J8={}));var ww;(function(w){w[w.Required=0]="Required",w[w.Ignore=1]="Ignore"})(ww||(ww={}));var wG={"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 FU(w){let z=w.split(".");if(z.length!==3)throw new Error("Invalid JWT");let A;try{A=new TextDecoder().decode(Pz(z[1]))}catch{throw new Error("Invalid JWT: Invalid base64url encoding")}let U;try{U=JSON.parse(A)}catch{throw new Error("Invalid JWT: Invalid JSON encoding")}if(typeof U!=="object"||U===null)throw new Error("Invalid JWT: Invalid payload");return U}function xU(w,z,A){let U=E6(new TextEncoder().encode(w)),W=E6(new TextEncoder().encode(z)),$=E6(A);return U+"."+W+"."+$}function EU(w,z){let A=E6(new TextEncoder().encode(w)),U=E6(new TextEncoder().encode(z)),W=A+"."+U;return new TextEncoder().encode(W)}var AG="https://appleid.apple.com/auth/authorize",UG="https://appleid.apple.com/auth/token";class Y8{clientId;teamId;keyId;pkcs8PrivateKey;redirectURI;constructor(w,z,A,U,W){this.clientId=w,this.teamId=z,this.keyId=A,this.pkcs8PrivateKey=U,this.redirectURI=W}createAuthorizationURL(w,z){let A=new URL(AG);if(A.searchParams.set("response_type","code"),A.searchParams.set("client_id",this.clientId),A.searchParams.set("state",w),z.length>0)A.searchParams.set("scope",z.join(" "));return A.searchParams.set("redirect_uri",this.redirectURI),A}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 A=await this.createClientSecret();z.set("client_secret",A);let U=g(UG,z);return await h(U)}async createClientSecret(){let w=await crypto.subtle.importKey("pkcs8",this.pkcs8PrivateKey,{name:"ECDSA",namedCurve:"P-256"},!1,["sign"]),z=Math.floor(Date.now()/1000),A=JSON.stringify({typ:"JWT",alg:"ES256",kid:this.keyId}),U=JSON.stringify({iss:this.teamId,exp:z+300,aud:["https://appleid.apple.com"],sub:this.clientId,iat:z}),W=new Uint8Array(await crypto.subtle.sign({name:"ECDSA",hash:"SHA-256"},w,EU(A,U)));return xU(A,U,W)}}var WG="https://auth.atlassian.com/authorize",fU="https://auth.atlassian.com/oauth/token";class q8{clientId;clientSecret;redirectURI;constructor(w,z,A){this.clientId=w,this.clientSecret=z,this.redirectURI=A}createAuthorizationURL(w,z){let A=new URL(WG);if(A.searchParams.set("response_type","code"),A.searchParams.set("client_id",this.clientId),A.searchParams.set("state",w),z.length>0)A.searchParams.set("scope",z.join(" "));return A.searchParams.set("redirect_uri",this.redirectURI),A.searchParams.set("audience","api.atlassian.com"),A.searchParams.set("prompt","consent"),A}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 A=g(fU,z);return await h(A)}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 A=g(fU,z);return await h(A)}}class B8{authorizationEndpoint;tokenEndpoint;tokenRevocationEndpoint;client;constructor(w,z,A,U){this.authorizationEndpoint=`https://${w}/authorize`,this.tokenEndpoint=`https://${w}/oauth/token`,this.tokenRevocationEndpoint=`https://${w}/oauth/revoke`,this.client=new T(z,A,U)}createAuthorizationURL(w,z,A){let U;if(z!==null)U=this.client.createAuthorizationURLWithPKCE(this.authorizationEndpoint,w,U0.S256,z,A);else U=this.client.createAuthorizationURL(this.authorizationEndpoint,w,A);return 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)}}class M8{authorizationEndpoint;tokenEndpoint;tokenRevocationEndpoint;client;constructor(w,z,A,U){this.authorizationEndpoint=G2(w,"/application/o/authorize"),this.tokenEndpoint=G2(w,"/application/o/token"),this.tokenRevocationEndpoint=G2(w,"/application/o/revoke"),this.client=new T(z,A,U)}createAuthorizationURL(w,z,A){return this.client.createAuthorizationURLWithPKCE(this.authorizationEndpoint,w,U0.S256,z,A)}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 $G="https://bitbucket.org/site/oauth2/authorize",kU="https://bitbucket.org/site/oauth2/access_token";class H8{client;constructor(w,z,A){this.client=new T(w,z,A)}createAuthorizationURL(w){return this.client.createAuthorizationURL($G,w,[])}async validateAuthorizationCode(w){return await this.client.validateAuthorizationCode(kU,w,null)}async refreshAccessToken(w){return await this.client.refreshAccessToken(kU,w,[])}}var XG="https://account.box.com/api/oauth2/authorize",VU="https://api.box.com/oauth2/token",QG="https://api.box.com/oauth2/revoke";class G8{clientId;clientSecret;redirectURI;constructor(w,z,A){this.clientId=w,this.clientSecret=z,this.redirectURI=A}createAuthorizationURL(w,z){let A=new URL(XG);if(A.searchParams.set("response_type","code"),A.searchParams.set("client_id",this.clientId),A.searchParams.set("state",w),z.length>0)A.searchParams.set("scope",z.join(" "));return A.searchParams.set("redirect_uri",this.redirectURI),A}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 A=g(VU,z);return await h(A)}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 A=g(VU,z);return await h(A)}async revokeToken(w){let z=new URLSearchParams;z.set("token",w),z.set("client_id",this.clientId),z.set("client_secret",this.clientSecret);let A=g(QG,z);await H4(A)}}var ZG="https://www.coinbase.com/oauth/authorize",gU="https://www.coinbase.com/oauth/token",JG="https://api.coinbase.com/oauth/revoke";class L8{clientId;clientSecret;redirectURI;constructor(w,z,A){this.clientId=w,this.clientSecret=z,this.redirectURI=A}createAuthorizationURL(w,z){let A=new URL(ZG);if(A.searchParams.set("response_type","code"),A.searchParams.set("client_id",this.clientId),A.searchParams.set("state",w),z.length>0)A.searchParams.set("scope",z.join(" "));return A.searchParams.set("redirect_uri",this.redirectURI),A}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 A=g(gU,z);return await h(A)}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 A=g(gU,z);return await h(A)}async revokeToken(w){let z=new URLSearchParams;z.set("token",w),z.set("client_id",this.clientId),z.set("client_secret",this.clientSecret);let A=g(JG,z);await H4(A)}}var TU="https://discord.com/oauth2/authorize",iU="https://discord.com/api/oauth2/token",YG="https://discord.com/api/oauth2/token/revoke";class b8{client;constructor(w,z,A){this.client=new T(w,z,A)}createAuthorizationURL(w,z,A){let U;if(z!==null)U=this.client.createAuthorizationURLWithPKCE(TU,w,U0.S256,z,A);else U=this.client.createAuthorizationURL(TU,w,A);return U}async validateAuthorizationCode(w,z){return await this.client.validateAuthorizationCode(iU,w,z)}async refreshAccessToken(w){return await this.client.refreshAccessToken(iU,w,[])}async revokeToken(w){await this.client.revokeToken(YG,w)}}var qG="https://dribbble.com/oauth/authorize",BG="https://dribbble.com/oauth/token";class N8{clientId;clientSecret;redirectURI;constructor(w,z,A){this.clientId=w,this.clientSecret=z,this.redirectURI=A}createAuthorizationURL(w,z){let A=new URL(qG);if(A.searchParams.set("response_type","code"),A.searchParams.set("client_id",this.clientId),A.searchParams.set("state",w),z.length>0)A.searchParams.set("scope",z.join(" "));return A.searchParams.set("redirect_uri",this.redirectURI),A}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 A=g(BG,z);return await h(A)}}var MG="https://www.dropbox.com/oauth2/authorize",dU="https://api.dropboxapi.com/oauth2/token",HG="https://api.dropboxapi.com/2/auth/token/revoke";class S8{client;constructor(w,z,A){this.client=new T(w,z,A)}createAuthorizationURL(w,z){return this.client.createAuthorizationURL(MG,w,z)}async validateAuthorizationCode(w){return await this.client.validateAuthorizationCode(dU,w,null)}async refreshAccessToken(w){return await this.client.refreshAccessToken(dU,w,[])}async revokeToken(w){await this.client.revokeToken(HG,w)}}var GG="https://www.facebook.com/v16.0/dialog/oauth",LG="https://graph.facebook.com/v16.0/oauth/access_token";class D8{clientId;clientSecret;redirectURI;constructor(w,z,A){this.clientId=w,this.clientSecret=z,this.redirectURI=A}createAuthorizationURL(w,z){let A=new URL(GG);if(A.searchParams.set("response_type","code"),A.searchParams.set("client_id",this.clientId),A.searchParams.set("state",w),z.length>0)A.searchParams.set("scope",z.join(" "));return A.searchParams.set("redirect_uri",this.redirectURI),A}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 A=g(LG,z);return await h(A)}}var bG="https://www.figma.com/oauth",NG="https://www.figma.com/api/oauth/token";class _8{client;constructor(w,z,A){this.client=new T(w,z,A)}createAuthorizationURL(w,z){return this.client.createAuthorizationURL(bG,w,z)}async validateAuthorizationCode(w){return await this.client.validateAuthorizationCode(NG,w,null)}}var SG="https://appcenter.intuit.com/connect/oauth2",cU="https://oauth.platform.intuit.com/oauth2/v1/tokens/bearer",DG="https://developer.API.intuit.com/v2/oauth2/tokens/revoke";class P8{client;constructor(w,z,A){this.client=new T(w,z,A)}createAuthorizationURL(w,z){return this.client.createAuthorizationURL(SG,w,z)}async validateAuthorizationCode(w){return await this.client.validateAuthorizationCode(cU,w,null)}async refreshAccessToken(w){return await this.client.refreshAccessToken(cU,w,[])}async revokeToken(w){await this.client.revokeToken(DG,w)}}var _G="https://github.com/login/oauth/authorize",nU="https://github.com/login/oauth/access_token";class O8{clientId;clientSecret;redirectURI;constructor(w,z,A){this.clientId=w,this.clientSecret=z,this.redirectURI=A}createAuthorizationURL(w,z){let A=new URL(_G);if(A.searchParams.set("response_type","code"),A.searchParams.set("client_id",this.clientId),A.searchParams.set("state",w),z.length>0)A.searchParams.set("scope",z.join(" "));if(this.redirectURI!==null)A.searchParams.set("redirect_uri",this.redirectURI);return A}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 A=g(nU,z),U=x6(this.clientId,this.clientSecret);return A.headers.set("Authorization",`Basic ${U}`),await hU(A)}async refreshAccessToken(w){let z=new URLSearchParams;z.set("grant_type","refresh_token"),z.set("refresh_token",w);let A=g(nU,z),U=x6(this.clientId,this.clientSecret);return A.headers.set("Authorization",`Basic ${U}`),await hU(A)}}async function hU(w){let z;try{z=await fetch(w)}catch(W){throw new J6(W)}if(z.status!==200){if(z.body!==null)await z.body.cancel();throw new y1(z.status)}let A;try{A=await z.json()}catch{throw new y1(z.status)}if(typeof A!=="object"||A===null)throw new M1(z.status,A);if("error"in A&&typeof A.error==="string"){let W;try{W=X8(A)}catch{throw new M1(z.status,A)}throw W}return new B4(A)}class C8{authorizationEndpoint;tokenEndpoint;tokenRevocationEndpoint;client;constructor(w,z,A,U){this.authorizationEndpoint=G2(w,"/oauth/authorize"),this.tokenEndpoint=G2(w,"/oauth/token"),this.tokenRevocationEndpoint=G2(w,"/oauth/revoke"),this.client=new T(z,A,U)}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",tU="https://oauth2.googleapis.com/token",OG="https://oauth2.googleapis.com/revoke";class R8{client;constructor(w,z,A){this.client=new T(w,z,A)}createAuthorizationURL(w,z,A){return this.client.createAuthorizationURLWithPKCE(PG,w,U0.S256,z,A)}async validateAuthorizationCode(w,z){return await this.client.validateAuthorizationCode(tU,w,z)}async refreshAccessToken(w){return await this.client.refreshAccessToken(tU,w,[])}async revokeToken(w){await this.client.revokeToken(OG,w)}}var CG="https://kauth.kakao.com/oauth/authorize",yU="https://kauth.kakao.com/oauth/token";class K8{clientId;clientSecret;redirectURI;constructor(w,z,A){this.clientId=w,this.clientSecret=z,this.redirectURI=A}createAuthorizationURL(w,z){let A=new URL(CG);if(A.searchParams.set("response_type","code"),A.searchParams.set("client_id",this.clientId),A.searchParams.set("state",w),z.length>0)A.searchParams.set("scope",z.join(" "));return A.searchParams.set("redirect_uri",this.redirectURI),A}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 A=g(yU,z);return await h(A)}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 A=g(yU,z);return await h(A)}}class j8{authorizationEndpoint;tokenEndpoint;tokenRevocationEndpoint;client;constructor(w,z,A,U){this.authorizationEndpoint=w+"/protocol/openid-connect/auth",this.tokenEndpoint=w+"/protocol/openid-connect/token",this.tokenRevocationEndpoint=w+"/protocol/openid-connect/revoke",this.client=new T(z,A,U)}createAuthorizationURL(w,z,A){return this.client.createAuthorizationURLWithPKCE(this.authorizationEndpoint,w,U0.S256,z,A)}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",KG="https://lichess.org/api/token";class F8{client;constructor(w,z){this.client=new T(w,null,z)}createAuthorizationURL(w,z,A){return this.client.createAuthorizationURLWithPKCE(RG,w,U0.S256,z,A)}async validateAuthorizationCode(w,z){return await this.client.validateAuthorizationCode(KG,w,z)}}var jG="https://access.line.me/oauth2/v2.1/authorize",vU="https://api.line.me/oauth2/v2.1/token";class x8{clientId;clientSecret;redirectURI;constructor(w,z,A){this.clientId=w,this.clientSecret=z,this.redirectURI=A}createAuthorizationURL(w,z,A){let U=new URL(jG);if(U.searchParams.set("response_type","code"),U.searchParams.set("client_id",this.clientId),U.searchParams.set("state",w),A.length>0)U.searchParams.set("scope",A.join(" "));U.searchParams.set("redirect_uri",this.redirectURI);let W=M4(z);return U.searchParams.set("code_challenge_method","S256"),U.searchParams.set("code_challenge",W),U}async validateAuthorizationCode(w,z){let A=new URLSearchParams;A.set("grant_type","authorization_code"),A.set("code",w),A.set("code_verifier",z),A.set("redirect_uri",this.redirectURI),A.set("client_id",this.clientId),A.set("client_secret",this.clientSecret);let U=g(vU,A);return await h(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 A=g(vU,z);return await h(A)}}var FG="https://linear.app/oauth/authorize",xG="https://api.linear.app/oauth/token";class E8{clientId;clientSecret;redirectURI;constructor(w,z,A){this.clientId=w,this.clientSecret=z,this.redirectURI=A}createAuthorizationURL(w,z){let A=new URL(FG);if(A.searchParams.set("response_type","code"),A.searchParams.set("client_id",this.clientId),A.searchParams.set("state",w),z.length>0)A.searchParams.set("scope",z.join(" "));return A.searchParams.set("redirect_uri",this.redirectURI),A}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 A=g(xG,z);return await h(A)}}var EG="https://www.linkedin.com/oauth/v2/authorization",oU="https://www.linkedin.com/oauth/v2/accessToken";class I8{clientId;clientSecret;redirectURI;constructor(w,z,A){this.clientId=w,this.clientSecret=z,this.redirectURI=A}createAuthorizationURL(w,z){let A=new URL(EG);if(A.searchParams.set("response_type","code"),A.searchParams.set("client_id",this.clientId),A.searchParams.set("state",w),z.length>0)A.searchParams.set("scope",z.join(" "));return A.searchParams.set("redirect_uri",this.redirectURI),A}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 A=g(oU,z);return await h(A)}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 A=g(oU,z);return await h(A)}}class f8{authorizationEndpoint;tokenEndpoint;client;constructor(w,z,A,U){this.authorizationEndpoint=G2("https://login.microsoftonline.com",w,"/oauth2/v2.0/authorize"),this.tokenEndpoint=G2("https://login.microsoftonline.com",w,"/oauth2/v2.0/token"),this.client=new T(z,A,U)}createAuthorizationURL(w,z,A){return this.client.createAuthorizationURLWithPKCE(this.authorizationEndpoint,w,U0.S256,z,A)}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",uU="https://myanimelist.net/v1/oauth2/token";class k8{client;constructor(w,z,A){this.client=new T(w,z,A)}createAuthorizationURL(w,z){return this.client.createAuthorizationURLWithPKCE(IG,w,U0.Plain,z,[])}async validateAuthorizationCode(w,z){return await this.client.validateAuthorizationCode(uU,w,z)}async refreshAccessToken(w){return await this.client.refreshAccessToken(uU,w,[])}}var fG="https://api.notion.com/v1/oauth/authorize",kG="https://api.notion.com/v1/oauth/token";class V8{client;constructor(w,z,A){this.client=new T(w,z,A)}createAuthorizationURL(w){let z=this.client.createAuthorizationURL(fG,w,[]);return z.searchParams.set("owner","user"),z}async validateAuthorizationCode(w){return await this.client.validateAuthorizationCode(kG,w,null)}}class g8{authorizationEndpoint;tokenEndpoint;tokenRevocationEndpoint;client;constructor(w,z,A,U,W){let $=`https://${w}/oauth2`;if(z!==null)$=G2($,z);this.authorizationEndpoint=G2($,"/v1/authorize"),this.tokenEndpoint=G2($,"/v1/token"),this.tokenRevocationEndpoint=G2($,"/v1/revoke"),this.client=new T(A,U,W)}createAuthorizationURL(w,z,A){return this.client.createAuthorizationURLWithPKCE(this.authorizationEndpoint,w,U0.S256,z,A)}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 VG="https://osu.ppy.sh/oauth/authorize",mU="https://osu.ppy.sh/oauth/token";class T8{clientId;clientSecret;redirectURI;constructor(w,z,A){this.clientId=w,this.clientSecret=z,this.redirectURI=A}createAuthorizationURL(w,z){let A=new URL(VG);if(A.searchParams.set("response_type","code"),A.searchParams.set("client_id",this.clientId),A.searchParams.set("state",w),z.length>0)A.searchParams.set("scope",z.join(" "));if(this.redirectURI!==null)A.searchParams.set("redirect_uri",this.redirectURI);return A}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 A=g(mU,z);return await h(A)}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 A=g(mU,z);return await h(A)}}var gG="https://www.patreon.com/oauth2/authorize",pU="https://www.patreon.com/api/oauth2/token";class i8{clientId;clientSecret;redirectURI;constructor(w,z,A){this.clientId=w,this.clientSecret=z,this.redirectURI=A}createAuthorizationURL(w,z){let A=new URL(gG);if(A.searchParams.set("response_type","code"),A.searchParams.set("client_id",this.clientId),A.searchParams.set("state",w),z.length>0)A.searchParams.set("scope",z.join(" "));return A.searchParams.set("redirect_uri",this.redirectURI),A}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 A=g(pU,z);return await h(A)}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 A=g(pU,z);return await h(A)}}var TG="https://www.reddit.com/api/v1/authorize",lU="https://www.reddit.com/api/v1/access_token";class d8{client;constructor(w,z,A){this.client=new T(w,z,A)}createAuthorizationURL(w,z){return this.client.createAuthorizationURL(TG,w,z)}async validateAuthorizationCode(w){return await this.client.validateAuthorizationCode(lU,w,null)}async refreshAccessToken(w){return await this.client.refreshAccessToken(lU,w,[])}}var iG="https://apis.roblox.com/oauth/v1/authorize",sU="https://apis.roblox.com/oauth/v1/token",dG="https://apis.roblox.com/oauth/v1/token/revoke";class c8{client;constructor(w,z,A){this.client=new T(w,z,A)}createAuthorizationURL(w,z,A){return this.client.createAuthorizationURLWithPKCE(iG,w,U0.S256,z,A)}async validateAuthorizationCode(w,z){return await this.client.validateAuthorizationCode(sU,w,z)}async refreshAccessToken(w){return await this.client.refreshAccessToken(sU,w,[])}async revokeToken(w){await this.client.revokeToken(dG,w)}}class n8{authorizationEndpoint;tokenEndpoint;tokenRevocationEndpoint;client;constructor(w,z,A,U){this.authorizationEndpoint=`https://${w}/services/oauth2/authorize`,this.tokenEndpoint=`https://${w}/services/oauth2/token`,this.tokenRevocationEndpoint=`https://${w}/services/oauth2/revoke`,this.client=new T(z,A,U)}createAuthorizationURL(w,z,A){return this.client.createAuthorizationURLWithPKCE(this.authorizationEndpoint,w,U0.S256,z,A)}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 cG="https://shikimori.one/oauth/authorize",rU="https://shikimori.one/oauth/token";class h8{clientId;clientSecret;redirectURI;constructor(w,z,A){this.clientId=w,this.clientSecret=z,this.redirectURI=A}createAuthorizationURL(w){let z=new URL(cG);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 A=g(rU,z);return await h(A)}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 A=g(rU,z);return await h(A)}}var nG="https://slack.com/openid/connect/authorize",hG="https://slack.com/api/openid.connect.token";class t8{client;constructor(w,z,A){this.client=new T(w,z,A)}createAuthorizationURL(w,z){return this.client.createAuthorizationURL(nG,w,z)}async validateAuthorizationCode(w){return await this.client.validateAuthorizationCode(hG,w,null)}}var aU="https://accounts.spotify.com/authorize",eU="https://accounts.spotify.com/api/token";class y8{client;constructor(w,z,A){this.client=new T(w,z,A)}createAuthorizationURL(w,z,A){let U;if(z!==null)U=this.client.createAuthorizationURLWithPKCE(aU,w,U0.S256,z,A);else U=this.client.createAuthorizationURL(aU,w,A);return U}async validateAuthorizationCode(w,z){return await this.client.validateAuthorizationCode(eU,w,z)}async refreshAccessToken(w){return await this.client.refreshAccessToken(eU,w,[])}}var tG="https://www.strava.com/oauth/authorize",yG="https://www.strava.com/oauth/token";class v8{clientId;clientSecret;redirectURI;constructor(w,z,A){this.clientId=w,this.clientSecret=z,this.redirectURI=A}createAuthorizationURL(w,z){let A=new URL(tG);if(A.searchParams.set("response_type","code"),A.searchParams.set("client_id",this.clientId),A.searchParams.set("state",w),z.length>0)A.searchParams.set("scope",z.join(","));return A.searchParams.set("redirect_uri",this.redirectURI),A}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 A=g(yG,z);return await h(A)}}var vG="https://v5api.tiltify.com/oauth/authorizeze",wW="https://v5api.tiltify.com/oauth/token";class o8{clientId;clientSecret;redirectURI;constructor(w,z,A){this.clientId=w,this.clientSecret=z,this.redirectURI=A}createAuthorizationURL(w,z){let A=new URL(vG);if(A.searchParams.set("response_type","code"),A.searchParams.set("client_id",this.clientId),A.searchParams.set("state",w),z.length>0)A.searchParams.set("scope",z.join(" "));return A.searchParams.set("redirect_uri",this.redirectURI),A}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 A=g(wW,z);return await h(A)}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 A=g(wW,z);return await h(A)}}var oG="https://www.tumblr.com/oauth2/authorize",zW="https://api.tumblr.com/v2/oauth2/token";class u8{client;constructor(w,z,A){this.client=new T(w,z,A)}createAuthorizationURL(w,z){return this.client.createAuthorizationURL(oG,w,z)}async validateAuthorizationCode(w){return await this.client.validateAuthorizationCode(zW,w,null)}async refreshAccessToken(w){return await this.client.refreshAccessToken(zW,w,[])}}var uG="https://id.twitch.tv/oauth2/authorize",AW="https://id.twitch.tv/oauth2/token";class m8{clientId;clientSecret;redirectURI;constructor(w,z,A){this.clientId=w,this.clientSecret=z,this.redirectURI=A}createAuthorizationURL(w,z){let A=new URL(uG);if(A.searchParams.set("response_type","code"),A.searchParams.set("client_id",this.clientId),A.searchParams.set("state",w),z.length>0)A.searchParams.set("scope",z.join(" "));return A.searchParams.set("redirect_uri",this.redirectURI),A}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 A=g(AW,z);return await h(A)}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 A=g(AW,z);return await h(A)}}var mG="https://twitter.com/i/oauth2/authorize",UW="https://api.twitter.com/2/oauth2/token",pG="https://api.twitter.com/2/oauth2/revoke";class p8{client;constructor(w,z,A){this.client=new T(w,z,A)}createAuthorizationURL(w,z,A){return this.client.createAuthorizationURLWithPKCE(mG,w,U0.S256,z,A)}async validateAuthorizationCode(w,z){return await this.client.validateAuthorizationCode(UW,w,z)}async refreshAccessToken(w){return await this.client.refreshAccessToken(UW,w,[])}async revokeToken(w){await this.client.revokeToken(pG,w)}}var lG="https://oauth.vk.com/authorize",sG="https://oauth.vk.com/access_token";class l8{clientId;clientSecret;redirectURI;constructor(w,z,A){this.clientId=w,this.clientSecret=z,this.redirectURI=A}createAuthorizationURL(w,z){let A=new URL(lG);if(A.searchParams.set("response_type","code"),A.searchParams.set("client_id",this.clientId),A.searchParams.set("state",w),z.length>0)A.searchParams.set("scope",z.join(" "));return A.searchParams.set("redirect_uri",this.redirectURI),A}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 A=g(sG,z);return await h(A)}}var rG="https://api.workos.com/sso/authorize",aG="https://api.workos.com/sso/token";class s8{clientId;clientSecret;redirectURI;constructor(w,z,A){this.clientId=w,this.clientSecret=z,this.redirectURI=A}createAuthorizationURL(w,z){let A=new URL(rG);if(A.searchParams.set("response_type","code"),A.searchParams.set("client_id",this.clientId),A.searchParams.set("state",w),A.searchParams.set("redirect_uri",this.redirectURI),z!==null){let U=M4(z);A.searchParams.set("code_challenge_method","S256"),A.searchParams.set("code_challenge",U)}return A}async validateAuthorizationCode(w,z){let A=new URLSearchParams;if(A.set("grant_type","authorization_code"),A.set("code",w),A.set("redirect_uri",this.redirectURI),A.set("client_id",this.clientId),this.clientSecret!==null)A.set("client_secret",this.clientSecret);if(z!==null)A.set("code_verifier",z);let U=g(aG,A);return await h(U)}}var eG="https://api.login.yahoo.com/oauth2/request_auth",WW="https://api.login.yahoo.com/oauth2/get_token";class r8{client;constructor(w,z,A){this.client=new T(w,z,A)}createAuthorizationURL(w,z){return this.client.createAuthorizationURL(eG,w,z)}async validateAuthorizationCode(w){return await this.client.validateAuthorizationCode(WW,w,null)}async refreshAccessToken(w){return await this.client.refreshAccessToken(WW,w,[])}}var wL="https://oauth.yandex.com/authorize",$W="https://oauth.yandex.com/token";class a8{client;constructor(w,z,A){this.client=new T(w,z,A)}createAuthorizationURL(w,z){return this.client.createAuthorizationURL(wL,w,z)}async validateAuthorizationCode(w){return await this.client.validateAuthorizationCode($W,w,null)}async refreshAccessToken(w){return await this.client.refreshAccessToken($W,w,[])}}var zL="https://zoom.us/oauth/authorize",XW="https://zoom.us/oauth/token",AL="https://zoom.us/oauth/revoke";class e8{client;constructor(w,z,A){this.client=new T(w,z,A)}createAuthorizationURL(w,z,A){return this.client.createAuthorizationURLWithPKCE(zL,w,U0.S256,z,A)}async validateAuthorizationCode(w,z){return await this.client.validateAuthorizationCode(XW,w,z)}async refreshAccessToken(w){return await this.client.refreshAccessToken(XW,w,[])}async revokeToken(w){await this.client.revokeToken(AL,w)}}var UL="https://api.intra.42.fr/oauth/authorize",WL="https://api.intra.42.fr/oauth/token";class w5{clientId;clientSecret;redirectURI;constructor(w,z,A){this.clientId=w,this.clientSecret=z,this.redirectURI=A}createAuthorizationURL(w,z){let A=new URL(UL);if(A.searchParams.set("response_type","code"),A.searchParams.set("client_id",this.clientId),A.searchParams.set("state",w),z.length>0)A.searchParams.set("scope",z.join(" "));return A.searchParams.set("redirect_uri",this.redirectURI),A}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 A=g(WL,z);return await h(A)}}function Oz(w){try{return FU(w)}catch(z){throw new Error("Invalid ID token",{cause:z})}}var zw={AmazonCognito:Q8,AniList:Z8,Apple:Y8,Atlassian:q8,Auth0:B8,Authentik:M8,Bitbucket:H8,Box:G8,Coinbase:L8,Discord:b8,Dribbble:N8,Dropbox:S8,Facebook:D8,Figma:_8,Intuit:P8,GitHub:O8,GitLab:C8,Google:R8,Kakao:K8,KeyCloak:j8,Lichess:F8,Line:x8,Linear:E8,LinkedIn:I8,MicrosoftEntraId:f8,MyAnimeList:k8,Notion:V8,Okta:g8,Osu:T8,Patreon:i8,Reddit:d8,Roblox:c8,Salesforce:n8,Shikimori:h8,Slack:t8,Spotify:y8,Strava:v8,Tiltify:o8,Tumblr:u8,Twitch:m8,Twitter:p8,VK:l8,WorkOS:s8,Yahoo:r8,Yandex:a8,Zoom:e8,FortyTwo:w5},QW=Object.keys(zw).reduce((w,z)=>{return w[z.toLowerCase()]=z,w},{}),Aw={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"},ZW={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"},JW=Object.keys(Aw).reduce((w,z)=>{return w[z.toLowerCase()]=z,w},{}),ag=Object.keys(ZW).reduce((w,z)=>{return w[z.toLowerCase()]=z,w},{});var YW=({logoutRoute:w="logout",onLogout:z})=>{return new F0().post(`/${w}`,async({error:A,cookie:{user_session_id:U,auth_provider:W}})=>{if(W.value===void 0)return A(401,"No auth provider found");try{return z?.(),U.remove(),W.remove(),new Response("Succesfuly Logged Out",{status:204})}catch($){if($ instanceof Error)console.error("Failed to refresh token:",$.message);return A(500)}})};var qW=(w)=>{return"refreshAccessToken"in w&&typeof w.refreshAccessToken==="function"};var Y6=(w)=>{return Object.keys(zw).map((z)=>z.toLowerCase()).includes(w.toLowerCase())},BW=(w)=>{return Object.keys(Aw).includes(w)};var MW=(w)=>{return!0};var HW=({clientProviders:w,revokeRoute:z="revoke",onRevoke:A})=>{return new F0().post(`/${z}/access-token`,async({error:U,cookie:{user_refresh_token:W,auth_provider:$}})=>{if(W.value===void 0)return U(401,"No refresh token found");if($.value===void 0)return U(401,"No auth provider found");if(!Y6($.value))return U(400,"Invalid provider");let X=$.value.toLowerCase(),{providerInstance:Q}=w[X];A?.()})};var G4=()=>{return new F0({name:"sessionStore"}).state({session:{}})};var GW=({statusRoute:w="auth-status",onStatus:z})=>{return new F0().use(G4()).get(`/${w}`,async({error:A,cookie:{user_session_id:U,auth_provider:W},store:{session:$}})=>{try{if(U.value===void 0)return new Response(JSON.stringify({user:null}),{headers:{"Content-Type":"application/json"}});if(W.value===void 0)return new Response(JSON.stringify({user:null}),{headers:{"Content-Type":"application/json"}});let X=$[U.value];if(X===void 0)return new Response(JSON.stringify({user:null}),{headers:{"Content-Type":"application/json"}});let Q=X.user;return z?.(),new Response(JSON.stringify({user:Q}),{headers:{"Content-Type":"application/json"}})}catch(X){if(X instanceof Error)console.error("Failed to get auth status: ",X.message);return A(500)}})};var LW=({clientProviders:w,refreshRoute:z="refresh",onRefresh:A})=>{return new F0().post(`/${z}`,async({error:U,cookie:{user_refresh_token:W,auth_provider:$}})=>{if(W.value===void 0)return U(401,"No refresh token found");if($.value===void 0)return U(401,"No auth provider found");let X=$.value.toLowerCase(),{providerInstance:Q}=w[X];if(!qW(Q))return U(401,"Provider is not refreshable");try{let Z=await Q.refreshAccessToken(W.value);return A?.(),new Response("Token refreshed",{status:204})}catch(Z){if(Z instanceof Error)console.error("Failed to refresh token:",Z.message);return U(500)}})};var bW=({clientProviders:w,authorizeRoute:z="authorize",onAuthorize:A})=>{return new F0().get(`/${z}/:provider`,({error:U,redirect:W,cookie:{state:$,code_verifier:X,auth_provider:Q,redirect_url:Z},params:{provider:J},headers:Y})=>{if(J===void 0)return U(400,"Provider is required");if(!Y6(J))return U(400,"Invalid provider");try{let L=J.toLowerCase(),{providerInstance:_,scopes:G,searchParams:O}=w[L],C=Y.referer||"/";Z.set({value:C,secure:!0,sameSite:"lax",path:"/",httpOnly:!0,maxAge:600}),Q.set({value:J,secure:!0,sameSite:"lax",path:"/",httpOnly:!0,maxAge:600});let q=Dz();$.set({value:q,secure:!0,sameSite:"lax",path:"/",httpOnly:!0,maxAge:600});let o,W0;if(_.createAuthorizationURL.toString().includes("codeVerifier"))W0=Sz(),X.set({value:W0,secure:!0,sameSite:"lax",path:"/",httpOnly:!0,maxAge:600}),o=_.createAuthorizationURL(q,W0,G);else o=_.createAuthorizationURL(q,G);return O.forEach(([L0,c])=>{o.searchParams.set(L0,c)}),A?.(),W(o.toString())}catch(L){if(L instanceof Error)console.error("Failed to validate authorization code:",L.message);return U(500)}})};var NW=({clientProviders:w,callbackRoute:z="authorize/callback",onCallback:A,getUser:U,createUser:W})=>{return new F0().use(G4()).get(`/${z}`,async({error:$,redirect:X,store:{session:Q},cookie:{state:Z,code_verifier:J,redirect_url:Y,user_session_id:L,auth_provider:_},query:{code:G,state:O}})=>{if(!G||!Z.value)return $(400,"Invalid callback request");if(O!==Z.value)return $(400,"Invalid state mismatch");if(_.value===void 0)return $(401,"No auth provider found");if(!Y6(_.value))return $(400,"Invalid provider");let C=_.value.toLowerCase(),{providerInstance:q}=w[C];try{let o;if(Z.remove(),q.validateAuthorizationCode.toString().includes("codeVerifier")){if(!J.value)return $(400,"Code verifier not found and is required");o=await q.validateAuthorizationCode(G,J.value),J.remove()}else o=await q.validateAuthorizationCode(G);let W0=Oz(o.idToken()),L0=_.value,c=await U?.({decodedIdToken:W0,authProvider:L0});if(c===null||c===void 0)c=await W?.({decodedIdToken:W0,authProvider:L0});let e=crypto.randomUUID();if(!MW(c))return $(500,"Invalid user schema");Q[e]={user:c,expiresAt:Date.now()+86400000},L.set({value:e,secure:!0,httpOnly:!0,sameSite:"lax"}),A?.();let f=Y.value??"/";return X(f)}catch(o){if(o instanceof Error)console.error("Failed to validate authorization code:",o.message);return $(500)}})};var SW=()=>{return new F0().use(G4()).derive(({store:{session:w},cookie:{user_session_id:z},error:A})=>{return{protectRoute:async(U,W)=>{if(z.value===void 0)return W?.()??A(401,"No session ID found");if(w[z.value]===void 0)return W?.()??A(401,"No session found");return U()}}}).as("plugin")};var dT=({config:w,authorizeRoute:z,callbackRoute:A,logoutRoute:U,statusRoute:W,refreshRoute:$,revokeRoute:X,onAuthorize:Q,onCallback:Z,onStatus:J,onRefresh:Y,onLogout:L,onRevoke:_,createUser:G,getUser:O})=>{let C=Object.entries(w).reduce((q,[o,W0={}])=>{let L0=o.toLowerCase(),c=QW[L0],e=JW[L0];if(!c||!Y6(c))return console.error(`Provider ${o} is not supported`),q;let f=zw[c],t;if(BW(e))t=Aw[e];let{credentials:K=[],scopes:l=[],searchParams:D0=[]}=W0,s=new f(...K);return q[L0]={providerInstance:s,scopes:l,searchParams:D0,userInfoURL:t},q},{});return new F0().error("OAUTH2_REQUEST_ERROR",e4).error("ARCTIC_FETCH_ERROR",J6).use(YW({logoutRoute:U,onLogout:L})).use(HW({clientProviders:C,revokeRoute:X,onRevoke:_})).use(GW({statusRoute:W,onStatus:J})).use(LW({clientProviders:C,refreshRoute:$,onRefresh:Y})).use(bW({clientProviders:C,authorizeRoute:z,onAuthorize:Q})).use(NW({clientProviders:C,callbackRoute:A,onCallback:Z,getUser:O,createUser:G})).use(SW()).as("plugin")};export{dT as absoluteAuth};
|