@absolutejs/auth 0.0.1 → 0.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/example/components/AuthOptions.d.ts +1 -0
- package/dist/example/components/Example.d.ts +1 -0
- package/dist/example/components/Head.d.ts +6 -0
- package/dist/example/components/Modal.d.ts +8 -0
- package/dist/example/components/Navbar.d.ts +10 -0
- package/dist/example/components/NotAuthorized.d.ts +1 -0
- package/dist/example/components/Protected.d.ts +1 -0
- package/dist/example/db/migrate.d.ts +1 -0
- package/dist/example/db/schema.d.ts +248 -0
- package/dist/example/hooks/useAuthStatus.d.ts +18 -0
- package/dist/example/indexes/ExampleIndex.d.ts +1 -0
- package/dist/example/indexes/NotAuthorizedIndex.d.ts +1 -0
- package/dist/example/indexes/ProtectedIndex.d.ts +1 -0
- package/dist/example/server.d.ts +1 -0
- package/dist/example/utils/networking.d.ts +1 -0
- package/dist/example/utils/pageUtils.d.ts +2 -0
- package/dist/example/utils/styles.d.ts +15 -0
- package/dist/example/utils/userUtils.d.ts +19 -0
- package/dist/index.js +230 -222
- package/dist/{callback.d.ts → src/callback.d.ts} +2 -2
- package/dist/{index.d.ts → src/index.d.ts} +6 -6
- package/dist/{logout.d.ts → src/logout.d.ts} +1 -1
- package/dist/{protectRoute.d.ts → src/protectRoute.d.ts} +3 -3
- package/dist/{refresh.d.ts → src/refresh.d.ts} +1 -1
- package/dist/{status.d.ts → src/status.d.ts} +3 -3
- package/package.json +15 -16
- /package/dist/{authorize.d.ts → src/authorize.d.ts} +0 -0
- /package/dist/{providers.d.ts → src/providers.d.ts} +0 -0
- /package/dist/{revoke.d.ts → src/revoke.d.ts} +0 -0
- /package/dist/{sessionStore.d.ts → src/sessionStore.d.ts} +0 -0
- /package/dist/{typeGuards.d.ts → src/typeGuards.d.ts} +0 -0
- /package/dist/{types.d.ts → src/types.d.ts} +0 -0
package/dist/index.js
CHANGED
|
@@ -1,153 +1,161 @@
|
|
|
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
|
-
|
|
4
|
-
|
|
5
|
-
|
|
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)
|
|
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 = {}
|
|
1
|
+
// @bun
|
|
2
|
+
var _X=Object.create;var{getPrototypeOf:SX,defineProperty:a5,getOwnPropertyNames:DX}=Object;var PX=Object.prototype.hasOwnProperty;var OX=(z,w,U)=>{U=z!=null?_X(SX(z)):{};let W=w||!z||!z.__esModule?a5(U,"default",{value:z,enumerable:!0}):U;for(let X of DX(z))if(!PX.call(W,X))a5(W,X,{get:()=>z[X],enumerable:!0});return W};var RX=(z,w)=>()=>(w||z((w={exports:{}}).exports,w),w.exports);var j6=(z,w)=>{for(var U in w)a5(z,U,{get:w[U],enumerable:!0,configurable:!0,set:(W)=>w[U]=()=>W})};var NU=RX((GU)=>{Object.defineProperty(GU,"__esModule",{value:!0});GU.parse=BL;GU.serialize=ML;var ZL=/^[\u0021-\u003A\u003C\u003E-\u007E]+$/,$L=/^[\u0021-\u003A\u003C-\u007E]*$/,AL=/^([.]?[a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?)([.][a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?)*$/i,QL=/^[\u0020-\u003A\u003D-\u007E]*$/,YL=Object.prototype.toString,JL=(()=>{let z=function(){};return z.prototype=Object.create(null),z})();function BL(z,w){let U=new JL,W=z.length;if(W<2)return U;let X=w?.decode||qL,Z=0;do{let $=z.indexOf("=",Z);if($===-1)break;let A=z.indexOf(";",Z),Q=A===-1?W:A;if($>Q){Z=z.lastIndexOf(";",$-1)+1;continue}let Y=qU(z,Z,$),J=LU(z,$,Y),G=z.slice(Y,J);if(U[G]===void 0){let S=qU(z,$+1,Q),N=LU(z,Q,S),O=X(z.slice(S,N));U[G]=O}Z=Q+1}while(Z<W);return U}function qU(z,w,U){do{let W=z.charCodeAt(w);if(W!==32&&W!==9)return w}while(++w<U);return U}function LU(z,w,U){while(w>U){let W=z.charCodeAt(--w);if(W!==32&&W!==9)return w+1}return U}function ML(z,w,U){let W=U?.encode||encodeURIComponent;if(!ZL.test(z))throw new TypeError(`argument name is invalid: ${z}`);let X=W(w);if(!$L.test(X))throw new TypeError(`argument val is invalid: ${w}`);let Z=z+"="+X;if(!U)return Z;if(U.maxAge!==void 0){if(!Number.isInteger(U.maxAge))throw new TypeError(`option maxAge is invalid: ${U.maxAge}`);Z+="; Max-Age="+U.maxAge}if(U.domain){if(!AL.test(U.domain))throw new TypeError(`option domain is invalid: ${U.domain}`);Z+="; Domain="+U.domain}if(U.path){if(!QL.test(U.path))throw new TypeError(`option path is invalid: ${U.path}`);Z+="; Path="+U.path}if(U.expires){if(!LL(U.expires)||!Number.isFinite(U.expires.valueOf()))throw new TypeError(`option expires is invalid: ${U.expires}`);Z+="; Expires="+U.expires.toUTCString()}if(U.httpOnly)Z+="; HttpOnly";if(U.secure)Z+="; Secure";if(U.partitioned)Z+="; Partitioned";if(U.priority)switch(typeof U.priority==="string"?U.priority.toLowerCase():void 0){case"low":Z+="; Priority=Low";break;case"medium":Z+="; Priority=Medium";break;case"high":Z+="; Priority=High";break;default:throw new TypeError(`option priority is invalid: ${U.priority}`)}if(U.sameSite)switch(typeof U.sameSite==="string"?U.sameSite.toLowerCase():U.sameSite){case!0:case"strict":Z+="; SameSite=Strict";break;case"lax":Z+="; SameSite=Lax";break;case"none":Z+="; SameSite=None";break;default:throw new TypeError(`option sameSite is invalid: ${U.sameSite}`)}return Z}function qL(z){if(z.indexOf("%")===-1)return z;try{return decodeURIComponent(z)}catch(w){return z}}function LL(z){return YL.call(z)==="[object Date]"}});var o6=(z,w)=>{let U=w?.length?{}:null;if(U)for(let W of w)U[W.part.charCodeAt(0)]=W;return{part:z,store:null,inert:U,params:null,wildcardStore:null}},Bw=(z,w)=>({...z,part:w}),Mw=(z)=>({name:z,store:null,inert:null});class F6{config;root={};history=[];deferred=[];constructor(z={}){if(this.config=z,z.lazy)this.find=this.lazyFind}static regex={static:/:.+?(?=\/|$)/,params:/:.+?(?=\/|$)/g,optionalParams:/:.+?\?(?=\/|$)/g};lazyFind=(z,w)=>{if(!this.config.lazy)return this.find;return this.build(),this.find(z,w)};build(){if(!this.config.lazy)return;for(let[z,w,U]of this.deferred)this.add(z,w,U,{lazy:!1,ignoreHistory:!0});this.deferred=[],this.find=(z,w)=>{let U=this.root[z];if(!U)return null;return Z8(w,w.length,U,0)}}add(z,w,U,{ignoreError:W=!1,ignoreHistory:X=!1,lazy:Z=this.config.lazy}={}){if(Z)return this.find=this.lazyFind,this.deferred.push([z,w,U]),U;if(typeof w!=="string")throw new TypeError("Route path must be a string");if(w==="")w="/";else if(w[0]!=="/")w=`/${w}`;let $=w[w.length-1]==="*",A=w.match(F6.regex.optionalParams);if(A){let S=w.replaceAll("?","");this.add(z,S,U,{ignoreError:W,ignoreHistory:X,lazy:Z});for(let N=0;N<A.length;N++){let O=w.replace("/"+A[N],"");this.add(z,O,U,{ignoreError:!0,ignoreHistory:X,lazy:Z})}return U}if(A)w=w.replaceAll("?","");if(this.history.find(([S,N,O])=>S===z&&N===w))return U;if($||A&&w.charCodeAt(w.length-1)===63)w=w.slice(0,-1);if(!X)this.history.push([z,w,U]);let Q=w.split(F6.regex.static),Y=w.match(F6.regex.params)||[];if(Q[Q.length-1]==="")Q.pop();let J;if(!this.root[z])J=this.root[z]=o6("/");else J=this.root[z];let G=0;for(let S=0;S<Q.length;++S){let N=Q[S];if(S>0){let O=Y[G++].slice(1);if(J.params===null)J.params=Mw(O);else if(J.params.name!==O)if(W)return U;else throw new Error(`Cannot create route "${w}" with parameter "${O}" because a route already exists with a different parameter name ("${J.params.name}") in the same location`);let M=J.params;if(M.inert===null){J=M.inert=o6(N);continue}J=M.inert}for(let O=0;;){if(O===N.length){if(O<J.part.length){let M=Bw(J,J.part.slice(O));Object.assign(J,o6(N,[M]))}break}if(O===J.part.length){if(J.inert===null)J.inert={};let M=J.inert[N.charCodeAt(O)];if(M){J=M,N=N.slice(O),O=0;continue}let C=o6(N.slice(O));J.inert[N.charCodeAt(O)]=C,J=C;break}if(N[O]!==J.part[O]){let M=Bw(J,J.part.slice(O)),C=o6(N.slice(O));Object.assign(J,o6(J.part.slice(0,O),[M,C])),J=C;break}++O}}if(G<Y.length){let S=Y[G].slice(1);if(J.params===null)J.params=Mw(S);else if(J.params.name!==S)if(W)return U;else throw new Error(`Cannot create route "${w}" with parameter "${S}" because a route already exists with a different parameter name ("${J.params.name}") in the same location`);if(J.params.store===null)J.params.store=U;return J.params.store}if($){if(J.wildcardStore===null)J.wildcardStore=U;return J.wildcardStore}if(J.store===null)J.store=U;return J.store}find(z,w){let U=this.root[z];if(!U)return null;return Z8(w,w.length,U,0)}}var Z8=(z,w,U,W)=>{let X=U.part,Z=X.length,$=W+Z;if(Z>1){if($>w)return null;if(Z<15){for(let A=1,Q=W+1;A<Z;++A,++Q)if(X.charCodeAt(A)!==z.charCodeAt(Q))return null}else if(z.slice(W,$)!==X)return null}if($===w){if(U.store!==null)return{store:U.store,params:{}};if(U.wildcardStore!==null)return{store:U.wildcardStore,params:{"*":""}};return null}if(U.inert!==null){let A=U.inert[z.charCodeAt($)];if(A!==void 0){let Q=Z8(z,w,A,$);if(Q!==null)return Q}}if(U.params!==null){let{store:A,name:Q,inert:Y}=U.params,J=z.indexOf("/",$);if(J!==$){if(J===-1||J>=w){if(A!==null){let G={};return G[Q]=z.substring($,w),{store:A,params:G}}}else if(Y!==null){let G=Z8(z,w,Y,J);if(G!==null)return G.params[Q]=z.substring($,J),G}}}if(U.wildcardStore!==null)return{store:U.wildcardStore,params:{"*":z.substring($,w)}};return null};var Y2={};j6(Y2,{IsUndefined:()=>t0,IsUint8Array:()=>h1,IsSymbol:()=>Wz,IsString:()=>j0,IsRegExp:()=>K4,IsObject:()=>P0,IsNumber:()=>V2,IsNull:()=>Uz,IsIterator:()=>wz,IsFunction:()=>zz,IsDate:()=>E6,IsBoolean:()=>d1,IsBigInt:()=>b4,IsAsyncIterator:()=>e5,IsArray:()=>m0,HasPropertyKey:()=>$8});function $8(z,w){return w in z}function e5(z){return P0(z)&&!m0(z)&&!h1(z)&&Symbol.asyncIterator in z}function m0(z){return Array.isArray(z)}function b4(z){return typeof z==="bigint"}function d1(z){return typeof z==="boolean"}function E6(z){return z instanceof globalThis.Date}function zz(z){return typeof z==="function"}function wz(z){return P0(z)&&!m0(z)&&!h1(z)&&Symbol.iterator in z}function Uz(z){return z===null}function V2(z){return typeof z==="number"}function P0(z){return typeof z==="object"&&z!==null}function K4(z){return z instanceof globalThis.RegExp}function j0(z){return typeof z==="string"}function Wz(z){return typeof z==="symbol"}function h1(z){return z instanceof globalThis.Uint8Array}function t0(z){return z===void 0}function CX(z){return z.map((w)=>A8(w))}function bX(z){return new Date(z.getTime())}function KX(z){return new Uint8Array(z)}function jX(z){return new RegExp(z.source,z.flags)}function FX(z){let w={};for(let U of Object.getOwnPropertyNames(z))w[U]=A8(z[U]);for(let U of Object.getOwnPropertySymbols(z))w[U]=A8(z[U]);return w}function A8(z){return m0(z)?CX(z):E6(z)?bX(z):h1(z)?KX(z):K4(z)?jX(z):P0(z)?FX(z):z}function V0(z){return A8(z)}function p6(z,w){return w===void 0?V0(z):V0({...w,...z})}function Q8(z){return l(z)&&globalThis.Symbol.asyncIterator in z}function Y8(z){return l(z)&&globalThis.Symbol.iterator in z}function Xz(z){return l(z)&&(globalThis.Object.getPrototypeOf(z)===Object.prototype||globalThis.Object.getPrototypeOf(z)===null)}function J8(z){return z instanceof globalThis.Promise}function G2(z){return z instanceof Date&&globalThis.Number.isFinite(z.getTime())}function qw(z){return z instanceof globalThis.Map}function Lw(z){return z instanceof globalThis.Set}function v2(z){return globalThis.ArrayBuffer.isView(z)}function l6(z){return z instanceof globalThis.Uint8Array}function u(z,w){return w in z}function l(z){return z!==null&&typeof z==="object"}function m(z){return globalThis.Array.isArray(z)&&!globalThis.ArrayBuffer.isView(z)}function k0(z){return z===void 0}function c1(z){return z===null}function F1(z){return typeof z==="boolean"}function v(z){return typeof z==="number"}function B8(z){return globalThis.Number.isInteger(z)}function X2(z){return typeof z==="bigint"}function A0(z){return typeof z==="string"}function $6(z){return typeof z==="function"}function i1(z){return typeof z==="symbol"}function k2(z){return X2(z)||F1(z)||c1(z)||v(z)||A0(z)||i1(z)||k0(z)}var I0;(function(z){z.InstanceMode="default",z.ExactOptionalPropertyTypes=!1,z.AllowArrayObject=!1,z.AllowNaN=!1,z.AllowNullVoid=!1;function w($,A){return z.ExactOptionalPropertyTypes?A in $:$[A]!==void 0}z.IsExactOptionalProperty=w;function U($){let A=l($);return z.AllowArrayObject?A:A&&!m($)}z.IsObjectLike=U;function W($){return U($)&&!($ instanceof Date)&&!($ instanceof Uint8Array)}z.IsRecordLike=W;function X($){return z.AllowNaN?v($):Number.isFinite($)}z.IsNumberLike=X;function Z($){let A=k0($);return z.AllowNullVoid?A||$===null:A}z.IsVoidLike=Z})(I0||(I0={}));function EX(z){return globalThis.Object.freeze(z).map((w)=>j4(w))}function IX(z){return z}function xX(z){return z}function VX(z){return z}function kX(z){let w={};for(let U of Object.getOwnPropertyNames(z))w[U]=j4(z[U]);for(let U of Object.getOwnPropertySymbols(z))w[U]=j4(z[U]);return globalThis.Object.freeze(w)}function j4(z){return m0(z)?EX(z):E6(z)?IX(z):h1(z)?xX(z):K4(z)?VX(z):P0(z)?kX(z):z}function D(z,w){let U=w!==void 0?{...w,...z}:z;switch(I0.InstanceMode){case"freeze":return j4(U);case"clone":return V0(U);default:return U}}class n extends Error{constructor(z){super(z)}}var F0=Symbol.for("TypeBox.Transform"),$1=Symbol.for("TypeBox.Readonly"),Z2=Symbol.for("TypeBox.Optional"),n2=Symbol.for("TypeBox.Hint"),H=Symbol.for("TypeBox.Kind");function s6(z){return P0(z)&&z[$1]==="Readonly"}function S2(z){return P0(z)&&z[Z2]==="Optional"}function Zz(z){return X0(z,"Any")}function $z(z){return X0(z,"Argument")}function A1(z){return X0(z,"Array")}function I6(z){return X0(z,"AsyncIterator")}function x6(z){return X0(z,"BigInt")}function y1(z){return X0(z,"Boolean")}function Q1(z){return X0(z,"Computed")}function Y1(z){return X0(z,"Constructor")}function TX(z){return X0(z,"Date")}function J1(z){return X0(z,"Function")}function B1(z){return X0(z,"Integer")}function c0(z){return X0(z,"Intersect")}function V6(z){return X0(z,"Iterator")}function X0(z,w){return P0(z)&&H in z&&z[H]===w}function M8(z){return d1(z)||V2(z)||j0(z)}function T2(z){return X0(z,"Literal")}function g2(z){return X0(z,"MappedKey")}function T0(z){return X0(z,"MappedResult")}function A6(z){return X0(z,"Never")}function gX(z){return X0(z,"Not")}function F4(z){return X0(z,"Null")}function M1(z){return X0(z,"Number")}function o0(z){return X0(z,"Object")}function k6(z){return X0(z,"Promise")}function T6(z){return X0(z,"Record")}function u0(z){return X0(z,"Ref")}function Az(z){return X0(z,"RegExp")}function v1(z){return X0(z,"String")}function E4(z){return X0(z,"Symbol")}function f2(z){return X0(z,"TemplateLiteral")}function fX(z){return X0(z,"This")}function G0(z){return P0(z)&&F0 in z}function d2(z){return X0(z,"Tuple")}function n1(z){return X0(z,"Undefined")}function Q0(z){return X0(z,"Union")}function dX(z){return X0(z,"Uint8Array")}function hX(z){return X0(z,"Unknown")}function cX(z){return X0(z,"Unsafe")}function iX(z){return X0(z,"Void")}function Q6(z){return P0(z)&&H in z&&j0(z[H])}function f0(z){return Zz(z)||$z(z)||A1(z)||y1(z)||x6(z)||I6(z)||Q1(z)||Y1(z)||TX(z)||J1(z)||B1(z)||c0(z)||V6(z)||T2(z)||g2(z)||T0(z)||A6(z)||gX(z)||F4(z)||M1(z)||o0(z)||k6(z)||T6(z)||u0(z)||Az(z)||v1(z)||E4(z)||f2(z)||fX(z)||d2(z)||n1(z)||Q0(z)||dX(z)||hX(z)||cX(z)||iX(z)||Q6(z)}var q={};j6(q,{TypeGuardUnknownTypeError:()=>Gw,IsVoid:()=>U9,IsUnsafe:()=>w9,IsUnknown:()=>z9,IsUnionLiteral:()=>lX,IsUnion:()=>Jz,IsUndefined:()=>aw,IsUint8Array:()=>ew,IsTuple:()=>rw,IsTransform:()=>sw,IsThis:()=>lw,IsTemplateLiteral:()=>pw,IsSymbol:()=>ow,IsString:()=>tw,IsSchema:()=>g0,IsRegExp:()=>mw,IsRef:()=>uw,IsRecursive:()=>pX,IsRecord:()=>nw,IsReadonly:()=>uX,IsProperties:()=>q8,IsPromise:()=>vw,IsOptional:()=>mX,IsObject:()=>yw,IsNumber:()=>iw,IsNull:()=>cw,IsNot:()=>hw,IsNever:()=>dw,IsMappedResult:()=>fw,IsMappedKey:()=>gw,IsLiteralValue:()=>Tw,IsLiteralString:()=>Vw,IsLiteralNumber:()=>kw,IsLiteralBoolean:()=>oX,IsLiteral:()=>x4,IsKindOf:()=>z0,IsKind:()=>W9,IsIterator:()=>xw,IsIntersect:()=>Iw,IsInteger:()=>Ew,IsImport:()=>tX,IsFunction:()=>Fw,IsDate:()=>jw,IsConstructor:()=>Kw,IsComputed:()=>bw,IsBoolean:()=>Cw,IsBigInt:()=>Rw,IsAsyncIterator:()=>Ow,IsArray:()=>Pw,IsArgument:()=>Dw,IsAny:()=>Sw});class Gw extends n{}var yX=["Argument","Any","Array","AsyncIterator","BigInt","Boolean","Computed","Constructor","Date","Enum","Function","Integer","Intersect","Iterator","Literal","MappedKey","MappedResult","Not","Null","Number","Object","Promise","Record","Ref","RegExp","String","Symbol","TemplateLiteral","This","Tuple","Undefined","Union","Uint8Array","Unknown","Void"];function Nw(z){try{return new RegExp(z),!0}catch{return!1}}function Qz(z){if(!j0(z))return!1;for(let w=0;w<z.length;w++){let U=z.charCodeAt(w);if(U>=7&&U<=13||U===27||U===127)return!1}return!0}function Hw(z){return Yz(z)||g0(z)}function I4(z){return t0(z)||b4(z)}function E0(z){return t0(z)||V2(z)}function Yz(z){return t0(z)||d1(z)}function O0(z){return t0(z)||j0(z)}function vX(z){return t0(z)||j0(z)&&Qz(z)&&Nw(z)}function nX(z){return t0(z)||j0(z)&&Qz(z)}function _w(z){return t0(z)||g0(z)}function uX(z){return P0(z)&&z[$1]==="Readonly"}function mX(z){return P0(z)&&z[Z2]==="Optional"}function Sw(z){return z0(z,"Any")&&O0(z.$id)}function Dw(z){return z0(z,"Argument")&&V2(z.index)}function Pw(z){return z0(z,"Array")&&z.type==="array"&&O0(z.$id)&&g0(z.items)&&E0(z.minItems)&&E0(z.maxItems)&&Yz(z.uniqueItems)&&_w(z.contains)&&E0(z.minContains)&&E0(z.maxContains)}function Ow(z){return z0(z,"AsyncIterator")&&z.type==="AsyncIterator"&&O0(z.$id)&&g0(z.items)}function Rw(z){return z0(z,"BigInt")&&z.type==="bigint"&&O0(z.$id)&&I4(z.exclusiveMaximum)&&I4(z.exclusiveMinimum)&&I4(z.maximum)&&I4(z.minimum)&&I4(z.multipleOf)}function Cw(z){return z0(z,"Boolean")&&z.type==="boolean"&&O0(z.$id)}function bw(z){return z0(z,"Computed")&&j0(z.target)&&m0(z.parameters)&&z.parameters.every((w)=>g0(w))}function Kw(z){return z0(z,"Constructor")&&z.type==="Constructor"&&O0(z.$id)&&m0(z.parameters)&&z.parameters.every((w)=>g0(w))&&g0(z.returns)}function jw(z){return z0(z,"Date")&&z.type==="Date"&&O0(z.$id)&&E0(z.exclusiveMaximumTimestamp)&&E0(z.exclusiveMinimumTimestamp)&&E0(z.maximumTimestamp)&&E0(z.minimumTimestamp)&&E0(z.multipleOfTimestamp)}function Fw(z){return z0(z,"Function")&&z.type==="Function"&&O0(z.$id)&&m0(z.parameters)&&z.parameters.every((w)=>g0(w))&&g0(z.returns)}function tX(z){return z0(z,"Import")&&$8(z,"$defs")&&P0(z.$defs)&&q8(z.$defs)&&$8(z,"$ref")&&j0(z.$ref)&&z.$ref in z.$defs}function Ew(z){return z0(z,"Integer")&&z.type==="integer"&&O0(z.$id)&&E0(z.exclusiveMaximum)&&E0(z.exclusiveMinimum)&&E0(z.maximum)&&E0(z.minimum)&&E0(z.multipleOf)}function q8(z){return P0(z)&&Object.entries(z).every(([w,U])=>Qz(w)&&g0(U))}function Iw(z){return z0(z,"Intersect")&&(j0(z.type)&&z.type!=="object"?!1:!0)&&m0(z.allOf)&&z.allOf.every((w)=>g0(w)&&!sw(w))&&O0(z.type)&&(Yz(z.unevaluatedProperties)||_w(z.unevaluatedProperties))&&O0(z.$id)}function xw(z){return z0(z,"Iterator")&&z.type==="Iterator"&&O0(z.$id)&&g0(z.items)}function z0(z,w){return P0(z)&&H in z&&z[H]===w}function Vw(z){return x4(z)&&j0(z.const)}function kw(z){return x4(z)&&V2(z.const)}function oX(z){return x4(z)&&d1(z.const)}function x4(z){return z0(z,"Literal")&&O0(z.$id)&&Tw(z.const)}function Tw(z){return d1(z)||V2(z)||j0(z)}function gw(z){return z0(z,"MappedKey")&&m0(z.keys)&&z.keys.every((w)=>V2(w)||j0(w))}function fw(z){return z0(z,"MappedResult")&&q8(z.properties)}function dw(z){return z0(z,"Never")&&P0(z.not)&&Object.getOwnPropertyNames(z.not).length===0}function hw(z){return z0(z,"Not")&&g0(z.not)}function cw(z){return z0(z,"Null")&&z.type==="null"&&O0(z.$id)}function iw(z){return z0(z,"Number")&&z.type==="number"&&O0(z.$id)&&E0(z.exclusiveMaximum)&&E0(z.exclusiveMinimum)&&E0(z.maximum)&&E0(z.minimum)&&E0(z.multipleOf)}function yw(z){return z0(z,"Object")&&z.type==="object"&&O0(z.$id)&&q8(z.properties)&&Hw(z.additionalProperties)&&E0(z.minProperties)&&E0(z.maxProperties)}function vw(z){return z0(z,"Promise")&&z.type==="Promise"&&O0(z.$id)&&g0(z.item)}function nw(z){return z0(z,"Record")&&z.type==="object"&&O0(z.$id)&&Hw(z.additionalProperties)&&P0(z.patternProperties)&&((w)=>{let U=Object.getOwnPropertyNames(w.patternProperties);return U.length===1&&Nw(U[0])&&P0(w.patternProperties)&&g0(w.patternProperties[U[0]])})(z)}function pX(z){return P0(z)&&n2 in z&&z[n2]==="Recursive"}function uw(z){return z0(z,"Ref")&&O0(z.$id)&&j0(z.$ref)}function mw(z){return z0(z,"RegExp")&&O0(z.$id)&&j0(z.source)&&j0(z.flags)&&E0(z.maxLength)&&E0(z.minLength)}function tw(z){return z0(z,"String")&&z.type==="string"&&O0(z.$id)&&E0(z.minLength)&&E0(z.maxLength)&&vX(z.pattern)&&nX(z.format)}function ow(z){return z0(z,"Symbol")&&z.type==="symbol"&&O0(z.$id)}function pw(z){return z0(z,"TemplateLiteral")&&z.type==="string"&&j0(z.pattern)&&z.pattern[0]==="^"&&z.pattern[z.pattern.length-1]==="$"}function lw(z){return z0(z,"This")&&O0(z.$id)&&j0(z.$ref)}function sw(z){return P0(z)&&F0 in z}function rw(z){return z0(z,"Tuple")&&z.type==="array"&&O0(z.$id)&&V2(z.minItems)&&V2(z.maxItems)&&z.minItems===z.maxItems&&(t0(z.items)&&t0(z.additionalItems)&&z.minItems===0||m0(z.items)&&z.items.every((w)=>g0(w)))}function aw(z){return z0(z,"Undefined")&&z.type==="undefined"&&O0(z.$id)}function lX(z){return Jz(z)&&z.anyOf.every((w)=>Vw(w)||kw(w))}function Jz(z){return z0(z,"Union")&&O0(z.$id)&&P0(z)&&m0(z.anyOf)&&z.anyOf.every((w)=>g0(w))}function ew(z){return z0(z,"Uint8Array")&&z.type==="Uint8Array"&&O0(z.$id)&&E0(z.minByteLength)&&E0(z.maxByteLength)}function z9(z){return z0(z,"Unknown")&&O0(z.$id)}function w9(z){return z0(z,"Unsafe")}function U9(z){return z0(z,"Void")&&z.type==="void"&&O0(z.$id)}function W9(z){return P0(z)&&H in z&&j0(z[H])&&!yX.includes(z[H])}function g0(z){return P0(z)&&(Sw(z)||Dw(z)||Pw(z)||Cw(z)||Rw(z)||Ow(z)||bw(z)||Kw(z)||jw(z)||Fw(z)||Ew(z)||Iw(z)||xw(z)||x4(z)||gw(z)||fw(z)||dw(z)||hw(z)||cw(z)||iw(z)||yw(z)||vw(z)||nw(z)||uw(z)||mw(z)||tw(z)||ow(z)||pw(z)||lw(z)||rw(z)||aw(z)||Jz(z)||ew(z)||z9(z)||w9(z)||U9(z)||W9(z))}var X9="(true|false)",L8="(0|[1-9][0-9]*)",Z9="(.*)";var E1="^(0|[1-9][0-9]*)$",I1="^(.*)$",$9="^(?!.*)$";var D0={};j6(D0,{Set:()=>zZ,Has:()=>eX,Get:()=>wZ,Entries:()=>sX,Delete:()=>aX,Clear:()=>rX});var r6=new Map;function sX(){return new Map(r6)}function rX(){return r6.clear()}function aX(z){return r6.delete(z)}function eX(z){return r6.has(z)}function zZ(z,w){r6.set(z,w)}function wZ(z){return r6.get(z)}var p0={};j6(p0,{Set:()=>$Z,Has:()=>ZZ,Get:()=>AZ,Entries:()=>UZ,Delete:()=>XZ,Clear:()=>WZ});var a6=new Map;function UZ(){return new Map(a6)}function WZ(){return a6.clear()}function XZ(z){return a6.delete(z)}function ZZ(z){return a6.has(z)}function $Z(z,w){a6.set(z,w)}function AZ(z){return a6.get(z)}function A9(z,w){return z.includes(w)}function Q9(z){return[...new Set(z)]}function QZ(z,w){return z.filter((U)=>w.includes(U))}function YZ(z,w){return z.reduce((U,W)=>{return QZ(U,W)},w)}function Y9(z){return z.length===1?z[0]:z.length>1?YZ(z.slice(1),z[0]):[]}function J9(z){let w=[];for(let U of z)w.push(...U);return w}function Y6(z){return D({[H]:"Any"},z)}function e6(z,w){return D({[H]:"Array",type:"array",items:z},w)}function B9(z){return D({[H]:"Argument",index:z})}function z4(z,w){return D({[H]:"AsyncIterator",type:"AsyncIterator",items:z},w)}function x0(z,w,U){return D({[H]:"Computed",target:z,parameters:w},U)}function JZ(z,w){let{[w]:U,...W}=z;return W}function i0(z,w){return w.reduce((U,W)=>JZ(U,W),z)}function p(z){return D({[H]:"Never",not:{}},z)}function J0(z){return D({[H]:"MappedResult",properties:z})}function w4(z,w,U){return D({[H]:"Constructor",type:"Constructor",parameters:z,returns:w},U)}function x1(z,w,U){return D({[H]:"Function",type:"Function",parameters:z,returns:w},U)}function V4(z,w){return D({[H]:"Union",anyOf:z},w)}function BZ(z){return z.some((w)=>S2(w))}function M9(z){return z.map((w)=>S2(w)?MZ(w):w)}function MZ(z){return i0(z,[Z2])}function qZ(z,w){return BZ(z)?J2(V4(M9(z),w)):V4(M9(z),w)}function V1(z,w){return z.length===1?D(z[0],w):z.length===0?p(w):qZ(z,w)}function N0(z,w){return z.length===0?p(w):z.length===1?D(z[0],w):V4(z,w)}class Bz extends n{}function LZ(z){return z.replace(/\\\$/g,"$").replace(/\\\*/g,"*").replace(/\\\^/g,"^").replace(/\\\|/g,"|").replace(/\\\(/g,"(").replace(/\\\)/g,")")}function Mz(z,w,U){return z[w]===U&&z.charCodeAt(w-1)!==92}function m1(z,w){return Mz(z,w,"(")}function k4(z,w){return Mz(z,w,")")}function q9(z,w){return Mz(z,w,"|")}function GZ(z){if(!(m1(z,0)&&k4(z,z.length-1)))return!1;let w=0;for(let U=0;U<z.length;U++){if(m1(z,U))w+=1;if(k4(z,U))w-=1;if(w===0&&U!==z.length-1)return!1}return!0}function NZ(z){return z.slice(1,z.length-1)}function HZ(z){let w=0;for(let U=0;U<z.length;U++){if(m1(z,U))w+=1;if(k4(z,U))w-=1;if(q9(z,U)&&w===0)return!0}return!1}function _Z(z){for(let w=0;w<z.length;w++)if(m1(z,w))return!0;return!1}function SZ(z){let[w,U]=[0,0],W=[];for(let Z=0;Z<z.length;Z++){if(m1(z,Z))w+=1;if(k4(z,Z))w-=1;if(q9(z,Z)&&w===0){let $=z.slice(U,Z);if($.length>0)W.push(U4($));U=Z+1}}let X=z.slice(U);if(X.length>0)W.push(U4(X));if(W.length===0)return{type:"const",const:""};if(W.length===1)return W[0];return{type:"or",expr:W}}function DZ(z){function w(X,Z){if(!m1(X,Z))throw new Bz("TemplateLiteralParser: Index must point to open parens");let $=0;for(let A=Z;A<X.length;A++){if(m1(X,A))$+=1;if(k4(X,A))$-=1;if($===0)return[Z,A]}throw new Bz("TemplateLiteralParser: Unclosed group parens in expression")}function U(X,Z){for(let $=Z;$<X.length;$++)if(m1(X,$))return[Z,$];return[Z,X.length]}let W=[];for(let X=0;X<z.length;X++)if(m1(z,X)){let[Z,$]=w(z,X),A=z.slice(Z,$+1);W.push(U4(A)),X=$}else{let[Z,$]=U(z,X),A=z.slice(Z,$);if(A.length>0)W.push(U4(A));X=$-1}return W.length===0?{type:"const",const:""}:W.length===1?W[0]:{type:"and",expr:W}}function U4(z){return GZ(z)?U4(NZ(z)):HZ(z)?SZ(z):_Z(z)?DZ(z):{type:"const",const:LZ(z)}}function W4(z){return U4(z.slice(1,z.length-1))}class L9 extends n{}function PZ(z){return z.type==="or"&&z.expr.length===2&&z.expr[0].type==="const"&&z.expr[0].const==="0"&&z.expr[1].type==="const"&&z.expr[1].const==="[1-9][0-9]*"}function OZ(z){return z.type==="or"&&z.expr.length===2&&z.expr[0].type==="const"&&z.expr[0].const==="true"&&z.expr[1].type==="const"&&z.expr[1].const==="false"}function RZ(z){return z.type==="const"&&z.const===".*"}function g6(z){return PZ(z)||RZ(z)?!1:OZ(z)?!0:z.type==="and"?z.expr.every((w)=>g6(w)):z.type==="or"?z.expr.every((w)=>g6(w)):z.type==="const"?!0:(()=>{throw new L9("Unknown expression type")})()}function G8(z){let w=W4(z.pattern);return g6(w)}class G9 extends n{}function*N9(z){if(z.length===1)return yield*z[0];for(let w of z[0])for(let U of N9(z.slice(1)))yield`${w}${U}`}function*CZ(z){return yield*N9(z.expr.map((w)=>[...T4(w)]))}function*bZ(z){for(let w of z.expr)yield*T4(w)}function*KZ(z){return yield z.const}function*T4(z){return z.type==="and"?yield*CZ(z):z.type==="or"?yield*bZ(z):z.type==="const"?yield*KZ(z):(()=>{throw new G9("Unknown expression")})()}function X4(z){let w=W4(z.pattern);return g6(w)?[...T4(w)]:[]}function Z0(z,w){return D({[H]:"Literal",const:z,type:typeof z},w)}function N8(z){return D({[H]:"Boolean",type:"boolean"},z)}function Z4(z){return D({[H]:"BigInt",type:"bigint"},z)}function u2(z){return D({[H]:"Number",type:"number"},z)}function N2(z){return D({[H]:"String",type:"string"},z)}function*jZ(z){let w=z.trim().replace(/"|'/g,"");return w==="boolean"?yield N8():w==="number"?yield u2():w==="bigint"?yield Z4():w==="string"?yield N2():yield(()=>{let U=w.split("|").map((W)=>Z0(W.trim()));return U.length===0?p():U.length===1?U[0]:V1(U)})()}function*FZ(z){if(z[1]!=="{"){let w=Z0("$"),U=qz(z.slice(1));return yield*[w,...U]}for(let w=2;w<z.length;w++)if(z[w]==="}"){let U=jZ(z.slice(2,w)),W=qz(z.slice(w+1));return yield*[...U,...W]}yield Z0(z)}function*qz(z){for(let w=0;w<z.length;w++)if(z[w]==="$"){let U=Z0(z.slice(0,w)),W=FZ(z.slice(w));return yield*[U,...W]}yield Z0(z)}function H9(z){return[...qz(z)]}class _9 extends n{}function EZ(z){return z.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function S9(z,w){return f2(z)?z.pattern.slice(1,z.pattern.length-1):Q0(z)?`(${z.anyOf.map((U)=>S9(U,w)).join("|")})`:M1(z)?`${w}${L8}`:B1(z)?`${w}${L8}`:x6(z)?`${w}${L8}`:v1(z)?`${w}${Z9}`:T2(z)?`${w}${EZ(z.const.toString())}`:y1(z)?`${w}${X9}`:(()=>{throw new _9(`Unexpected Kind '${z[H]}'`)})()}function Lz(z){return`^${z.map((w)=>S9(w,"")).join("")}$`}function f6(z){let U=X4(z).map((W)=>Z0(W));return V1(U)}function H8(z,w){let U=j0(z)?Lz(H9(z)):Lz(z);return D({[H]:"TemplateLiteral",type:"string",pattern:U},w)}function IZ(z){return X4(z).map((U)=>U.toString())}function xZ(z){let w=[];for(let U of z)w.push(...D2(U));return w}function VZ(z){return[z.toString()]}function D2(z){return[...new Set(f2(z)?IZ(z):Q0(z)?xZ(z.anyOf):T2(z)?VZ(z.const):M1(z)?["[number]"]:B1(z)?["[number]"]:[])]}function kZ(z,w,U){let W={};for(let X of Object.getOwnPropertyNames(w))W[X]=J6(z,D2(w[X]),U);return W}function TZ(z,w,U){return kZ(z,w.properties,U)}function D9(z,w,U){let W=TZ(z,w,U);return J0(W)}function O9(z,w){return z.map((U)=>R9(U,w))}function gZ(z){return z.filter((w)=>!A6(w))}function fZ(z,w){return _8(gZ(O9(z,w)))}function dZ(z){return z.some((w)=>A6(w))?[]:z}function hZ(z,w){return V1(dZ(O9(z,w)))}function cZ(z,w){return w in z?z[w]:w==="[number]"?V1(z):p()}function iZ(z,w){return w==="[number]"?z:p()}function yZ(z,w){return w in z?z[w]:p()}function R9(z,w){return c0(z)?fZ(z.allOf,w):Q0(z)?hZ(z.anyOf,w):d2(z)?cZ(z.items??[],w):A1(z)?iZ(z.items,w):o0(z)?yZ(z.properties,w):p()}function g4(z,w){return w.map((U)=>R9(z,U))}function P9(z,w){return V1(g4(z,w))}function J6(z,w,U){if(u0(z)||u0(w)){if(!f0(z)||!f0(w))throw new n("Index types using Ref parameters require both Type and Key to be of TSchema");return x0("Index",[z,w])}if(T0(w))return D9(z,w,U);if(g2(w))return C9(z,w,U);return D(f0(w)?P9(z,D2(w)):P9(z,w),U)}function vZ(z,w,U){return{[w]:J6(z,[w],V0(U))}}function nZ(z,w,U){return w.reduce((W,X)=>{return{...W,...vZ(z,X,U)}},{})}function uZ(z,w,U){return nZ(z,w.keys,U)}function C9(z,w,U){let W=uZ(z,w,U);return J0(W)}function $4(z,w){return D({[H]:"Iterator",type:"Iterator",items:z},w)}function mZ(z){let w=[];for(let U in z)if(!S2(z[U]))w.push(U);return w}function tZ(z,w){let U=mZ(z),W=U.length>0?{[H]:"Object",type:"object",properties:z,required:U}:{[H]:"Object",type:"object",properties:z};return D(W,w)}var H0=tZ;function S8(z,w){return D({[H]:"Promise",type:"Promise",item:z},w)}function oZ(z){return D(i0(z,[$1]))}function pZ(z){return D({...z,[$1]:"Readonly"})}function lZ(z,w){return w===!1?oZ(z):pZ(z)}function P2(z,w){let U=w??!0;return T0(z)?b9(z,U):lZ(z,U)}function sZ(z,w){let U={};for(let W of globalThis.Object.getOwnPropertyNames(z))U[W]=P2(z[W],w);return U}function rZ(z,w){return sZ(z.properties,w)}function b9(z,w){let U=rZ(z,w);return J0(U)}function m2(z,w){return D(z.length>0?{[H]:"Tuple",type:"array",items:z,additionalItems:!1,minItems:z.length,maxItems:z.length}:{[H]:"Tuple",type:"array",minItems:z.length,maxItems:z.length},w)}function K9(z,w){return z in w?t2(z,w[z]):J0(w)}function aZ(z){return{[z]:Z0(z)}}function eZ(z){let w={};for(let U of z)w[U]=Z0(U);return w}function z$(z,w){return A9(w,z)?aZ(z):eZ(w)}function w$(z,w){let U=z$(z,w);return K9(z,U)}function f4(z,w){return w.map((U)=>t2(z,U))}function U$(z,w){let U={};for(let W of globalThis.Object.getOwnPropertyNames(w))U[W]=t2(z,w[W]);return U}function t2(z,w){let U={...w};return S2(w)?J2(t2(z,i0(w,[Z2]))):s6(w)?P2(t2(z,i0(w,[$1]))):T0(w)?K9(z,w.properties):g2(w)?w$(z,w.keys):Y1(w)?w4(f4(z,w.parameters),t2(z,w.returns),U):J1(w)?x1(f4(z,w.parameters),t2(z,w.returns),U):I6(w)?z4(t2(z,w.items),U):V6(w)?$4(t2(z,w.items),U):c0(w)?B2(f4(z,w.allOf),U):Q0(w)?N0(f4(z,w.anyOf),U):d2(w)?m2(f4(z,w.items??[]),U):o0(w)?H0(U$(z,w.properties),U):A1(w)?e6(t2(z,w.items),U):k6(w)?S8(t2(z,w.item),U):w}function W$(z,w){let U={};for(let W of z)U[W]=t2(W,w);return U}function j9(z,w,U){let W=f0(z)?D2(z):z,X=w({[H]:"MappedKey",keys:W}),Z=W$(W,X);return H0(Z,U)}function X$(z){return D(i0(z,[Z2]))}function Z$(z){return D({...z,[Z2]:"Optional"})}function $$(z,w){return w===!1?X$(z):Z$(z)}function J2(z,w){let U=w??!0;return T0(z)?F9(z,U):$$(z,U)}function A$(z,w){let U={};for(let W of globalThis.Object.getOwnPropertyNames(z))U[W]=J2(z[W],w);return U}function Q$(z,w){return A$(z.properties,w)}function F9(z,w){let U=Q$(z,w);return J0(U)}function d4(z,w={}){let U=z.every((X)=>o0(X)),W=f0(w.unevaluatedProperties)?{unevaluatedProperties:w.unevaluatedProperties}:{};return D(w.unevaluatedProperties===!1||f0(w.unevaluatedProperties)||U?{...W,[H]:"Intersect",type:"object",allOf:z}:{...W,[H]:"Intersect",allOf:z},w)}function Y$(z){return z.every((w)=>S2(w))}function J$(z){return i0(z,[Z2])}function E9(z){return z.map((w)=>S2(w)?J$(w):w)}function B$(z,w){return Y$(z)?J2(d4(E9(z),w)):d4(E9(z),w)}function _8(z,w={}){if(z.length===1)return D(z[0],w);if(z.length===0)return p(w);if(z.some((U)=>G0(U)))throw new Error("Cannot intersect transform types");return B$(z,w)}function B2(z,w){if(z.length===1)return D(z[0],w);if(z.length===0)return p(w);if(z.some((U)=>G0(U)))throw new Error("Cannot intersect transform types");return d4(z,w)}function o2(...z){let[w,U]=typeof z[0]==="string"?[z[0],z[1]]:[z[0].$id,z[1]];if(typeof w!=="string")throw new n("Ref: $ref must be a string");return D({[H]:"Ref",$ref:w},U)}function M$(z,w){return x0("Awaited",[x0(z,w)])}function q$(z){return x0("Awaited",[o2(z)])}function L$(z){return B2(I9(z))}function G$(z){return N0(I9(z))}function N$(z){return A4(z)}function I9(z){return z.map((w)=>A4(w))}function A4(z,w){return D(Q1(z)?M$(z.target,z.parameters):c0(z)?L$(z.allOf):Q0(z)?G$(z.anyOf):k6(z)?N$(z.item):u0(z)?q$(z.$ref):z,w)}function x9(z){let w=[];for(let U of z)w.push(O2(U));return w}function H$(z){let w=x9(z);return J9(w)}function _$(z){let w=x9(z);return Y9(w)}function S$(z){return z.map((w,U)=>U.toString())}function D$(z){return["[number]"]}function P$(z){return globalThis.Object.getOwnPropertyNames(z)}function O$(z){if(!Gz)return[];return globalThis.Object.getOwnPropertyNames(z).map((U)=>{return U[0]==="^"&&U[U.length-1]==="$"?U.slice(1,U.length-1):U})}function O2(z){return c0(z)?H$(z.allOf):Q0(z)?_$(z.anyOf):d2(z)?S$(z.items??[]):A1(z)?D$(z.items):o0(z)?P$(z.properties):T6(z)?O$(z.patternProperties):[]}var Gz=!1;function t1(z){Gz=!0;let w=O2(z);return Gz=!1,`^(${w.map((W)=>`(${W})`).join("|")})$`}function R$(z,w){return x0("KeyOf",[x0(z,w)])}function C$(z){return x0("KeyOf",[o2(z)])}function b$(z,w){let U=O2(z),W=K$(U),X=V1(W);return D(X,w)}function K$(z){return z.map((w)=>w==="[number]"?u2():Z0(w))}function Q4(z,w){return Q1(z)?R$(z.target,z.parameters):u0(z)?C$(z.$ref):T0(z)?V9(z,w):b$(z,w)}function j$(z,w){let U={};for(let W of globalThis.Object.getOwnPropertyNames(z))U[W]=Q4(z[W],V0(w));return U}function F$(z,w){return j$(z.properties,w)}function V9(z,w){let U=F$(z,w);return J0(U)}function D8(z){let w=O2(z),U=g4(z,w);return w.map((W,X)=>[w[X],U[X]])}function E$(z){let w=[];for(let U of z)w.push(...O2(U));return Q9(w)}function I$(z){return z.filter((w)=>!A6(w))}function x$(z,w){let U=[];for(let W of z)U.push(...g4(W,[w]));return I$(U)}function V$(z,w){let U={};for(let W of w)U[W]=_8(x$(z,W));return U}function k9(z,w){let U=E$(z),W=V$(z,U);return H0(W,w)}function P8(z){return D({[H]:"Date",type:"Date"},z)}function O8(z){return D({[H]:"Null",type:"null"},z)}function R8(z){return D({[H]:"Symbol",type:"symbol"},z)}function C8(z){return D({[H]:"Undefined",type:"undefined"},z)}function b8(z){return D({[H]:"Uint8Array",type:"Uint8Array"},z)}function q1(z){return D({[H]:"Unknown"},z)}function k$(z){return z.map((w)=>Nz(w,!1))}function T$(z){let w={};for(let U of globalThis.Object.getOwnPropertyNames(z))w[U]=P2(Nz(z[U],!1));return w}function K8(z,w){return w===!0?z:P2(z)}function Nz(z,w){return e5(z)?K8(Y6(),w):wz(z)?K8(Y6(),w):m0(z)?P2(m2(k$(z))):h1(z)?b8():E6(z)?P8():P0(z)?K8(H0(T$(z)),w):zz(z)?K8(x1([],q1()),w):t0(z)?C8():Uz(z)?O8():Wz(z)?R8():b4(z)?Z4():V2(z)?Z0(z):d1(z)?Z0(z):j0(z)?Z0(z):H0({})}function T9(z,w){return D(Nz(z,!0),w)}function g9(z,w){return Y1(z)?m2(z.parameters,w):p(w)}function f9(z,w){if(t0(z))throw new Error("Enum undefined or empty");let U=globalThis.Object.getOwnPropertyNames(z).filter((Z)=>isNaN(Z)).map((Z)=>z[Z]),X=[...new Set(U)].map((Z)=>Z0(Z));return N0(X,{...w,[n2]:"Enum"})}class y9 extends n{}var P;(function(z){z[z.Union=0]="Union",z[z.True=1]="True",z[z.False=2]="False"})(P||(P={}));function p2(z){return z===P.False?z:P.True}function Y4(z){throw new y9(z)}function l0(z){return q.IsNever(z)||q.IsIntersect(z)||q.IsUnion(z)||q.IsUnknown(z)||q.IsAny(z)}function s0(z,w){return q.IsNever(w)?u9(z,w):q.IsIntersect(w)?j8(z,w):q.IsUnion(w)?Pz(z,w):q.IsUnknown(w)?p9(z,w):q.IsAny(w)?Dz(z,w):Y4("StructuralRight")}function Dz(z,w){return P.True}function g$(z,w){return q.IsIntersect(w)?j8(z,w):q.IsUnion(w)&&w.anyOf.some((U)=>q.IsAny(U)||q.IsUnknown(U))?P.True:q.IsUnion(w)?P.Union:q.IsUnknown(w)?P.True:q.IsAny(w)?P.True:P.Union}function f$(z,w){return q.IsUnknown(z)?P.False:q.IsAny(z)?P.Union:q.IsNever(z)?P.True:P.False}function d$(z,w){return q.IsObject(w)&&F8(w)?P.True:l0(w)?s0(z,w):!q.IsArray(w)?P.False:p2(R0(z.items,w.items))}function h$(z,w){return l0(w)?s0(z,w):!q.IsAsyncIterator(w)?P.False:p2(R0(z.items,w.items))}function c$(z,w){return l0(w)?s0(z,w):q.IsObject(w)?M2(z,w):q.IsRecord(w)?l2(z,w):q.IsBigInt(w)?P.True:P.False}function v9(z,w){return q.IsLiteralBoolean(z)?P.True:q.IsBoolean(z)?P.True:P.False}function i$(z,w){return l0(w)?s0(z,w):q.IsObject(w)?M2(z,w):q.IsRecord(w)?l2(z,w):q.IsBoolean(w)?P.True:P.False}function y$(z,w){return l0(w)?s0(z,w):q.IsObject(w)?M2(z,w):!q.IsConstructor(w)?P.False:z.parameters.length>w.parameters.length?P.False:!z.parameters.every((U,W)=>p2(R0(w.parameters[W],U))===P.True)?P.False:p2(R0(z.returns,w.returns))}function v$(z,w){return l0(w)?s0(z,w):q.IsObject(w)?M2(z,w):q.IsRecord(w)?l2(z,w):q.IsDate(w)?P.True:P.False}function n$(z,w){return l0(w)?s0(z,w):q.IsObject(w)?M2(z,w):!q.IsFunction(w)?P.False:z.parameters.length>w.parameters.length?P.False:!z.parameters.every((U,W)=>p2(R0(w.parameters[W],U))===P.True)?P.False:p2(R0(z.returns,w.returns))}function n9(z,w){return q.IsLiteral(z)&&Y2.IsNumber(z.const)?P.True:q.IsNumber(z)||q.IsInteger(z)?P.True:P.False}function u$(z,w){return q.IsInteger(w)||q.IsNumber(w)?P.True:l0(w)?s0(z,w):q.IsObject(w)?M2(z,w):q.IsRecord(w)?l2(z,w):P.False}function j8(z,w){return w.allOf.every((U)=>R0(z,U)===P.True)?P.True:P.False}function m$(z,w){return z.allOf.some((U)=>R0(U,w)===P.True)?P.True:P.False}function t$(z,w){return l0(w)?s0(z,w):!q.IsIterator(w)?P.False:p2(R0(z.items,w.items))}function o$(z,w){return q.IsLiteral(w)&&w.const===z.const?P.True:l0(w)?s0(z,w):q.IsObject(w)?M2(z,w):q.IsRecord(w)?l2(z,w):q.IsString(w)?o9(z,w):q.IsNumber(w)?m9(z,w):q.IsInteger(w)?n9(z,w):q.IsBoolean(w)?v9(z,w):P.False}function u9(z,w){return P.False}function p$(z,w){return P.True}function d9(z){let[w,U]=[z,0];while(!0){if(!q.IsNot(w))break;w=w.not,U+=1}return U%2===0?w:q1()}function l$(z,w){return q.IsNot(z)?R0(d9(z),w):q.IsNot(w)?R0(z,d9(w)):Y4("Invalid fallthrough for Not")}function s$(z,w){return l0(w)?s0(z,w):q.IsObject(w)?M2(z,w):q.IsRecord(w)?l2(z,w):q.IsNull(w)?P.True:P.False}function m9(z,w){return q.IsLiteralNumber(z)?P.True:q.IsNumber(z)||q.IsInteger(z)?P.True:P.False}function r$(z,w){return l0(w)?s0(z,w):q.IsObject(w)?M2(z,w):q.IsRecord(w)?l2(z,w):q.IsInteger(w)||q.IsNumber(w)?P.True:P.False}function R2(z,w){return Object.getOwnPropertyNames(z.properties).length===w}function h9(z){return F8(z)}function c9(z){return R2(z,0)||R2(z,1)&&"description"in z.properties&&q.IsUnion(z.properties.description)&&z.properties.description.anyOf.length===2&&(q.IsString(z.properties.description.anyOf[0])&&q.IsUndefined(z.properties.description.anyOf[1])||q.IsString(z.properties.description.anyOf[1])&&q.IsUndefined(z.properties.description.anyOf[0]))}function Hz(z){return R2(z,0)}function i9(z){return R2(z,0)}function a$(z){return R2(z,0)}function e$(z){return R2(z,0)}function zA(z){return F8(z)}function wA(z){let w=u2();return R2(z,0)||R2(z,1)&&"length"in z.properties&&p2(R0(z.properties.length,w))===P.True}function UA(z){return R2(z,0)}function F8(z){let w=u2();return R2(z,0)||R2(z,1)&&"length"in z.properties&&p2(R0(z.properties.length,w))===P.True}function WA(z){let w=x1([Y6()],Y6());return R2(z,0)||R2(z,1)&&"then"in z.properties&&p2(R0(z.properties.then,w))===P.True}function t9(z,w){return R0(z,w)===P.False?P.False:q.IsOptional(z)&&!q.IsOptional(w)?P.False:P.True}function M2(z,w){return q.IsUnknown(z)?P.False:q.IsAny(z)?P.Union:q.IsNever(z)||q.IsLiteralString(z)&&h9(w)||q.IsLiteralNumber(z)&&Hz(w)||q.IsLiteralBoolean(z)&&i9(w)||q.IsSymbol(z)&&c9(w)||q.IsBigInt(z)&&a$(w)||q.IsString(z)&&h9(w)||q.IsSymbol(z)&&c9(w)||q.IsNumber(z)&&Hz(w)||q.IsInteger(z)&&Hz(w)||q.IsBoolean(z)&&i9(w)||q.IsUint8Array(z)&&zA(w)||q.IsDate(z)&&e$(w)||q.IsConstructor(z)&&UA(w)||q.IsFunction(z)&&wA(w)?P.True:q.IsRecord(z)&&q.IsString(_z(z))?(()=>{return w[n2]==="Record"?P.True:P.False})():q.IsRecord(z)&&q.IsNumber(_z(z))?(()=>{return R2(w,0)?P.True:P.False})():P.False}function XA(z,w){return l0(w)?s0(z,w):q.IsRecord(w)?l2(z,w):!q.IsObject(w)?P.False:(()=>{for(let U of Object.getOwnPropertyNames(w.properties)){if(!(U in z.properties)&&!q.IsOptional(w.properties[U]))return P.False;if(q.IsOptional(w.properties[U]))return P.True;if(t9(z.properties[U],w.properties[U])===P.False)return P.False}return P.True})()}function ZA(z,w){return l0(w)?s0(z,w):q.IsObject(w)&&WA(w)?P.True:!q.IsPromise(w)?P.False:p2(R0(z.item,w.item))}function _z(z){return E1 in z.patternProperties?u2():(I1 in z.patternProperties)?N2():Y4("Unknown record key pattern")}function Sz(z){return E1 in z.patternProperties?z.patternProperties[E1]:(I1 in z.patternProperties)?z.patternProperties[I1]:Y4("Unable to get record value schema")}function l2(z,w){let[U,W]=[_z(w),Sz(w)];return q.IsLiteralString(z)&&q.IsNumber(U)&&p2(R0(z,W))===P.True?P.True:q.IsUint8Array(z)&&q.IsNumber(U)?R0(z,W):q.IsString(z)&&q.IsNumber(U)?R0(z,W):q.IsArray(z)&&q.IsNumber(U)?R0(z,W):q.IsObject(z)?(()=>{for(let X of Object.getOwnPropertyNames(z.properties))if(t9(W,z.properties[X])===P.False)return P.False;return P.True})():P.False}function $A(z,w){return l0(w)?s0(z,w):q.IsObject(w)?M2(z,w):!q.IsRecord(w)?P.False:R0(Sz(z),Sz(w))}function AA(z,w){let U=q.IsRegExp(z)?N2():z,W=q.IsRegExp(w)?N2():w;return R0(U,W)}function o9(z,w){return q.IsLiteral(z)&&Y2.IsString(z.const)?P.True:q.IsString(z)?P.True:P.False}function QA(z,w){return l0(w)?s0(z,w):q.IsObject(w)?M2(z,w):q.IsRecord(w)?l2(z,w):q.IsString(w)?P.True:P.False}function YA(z,w){return l0(w)?s0(z,w):q.IsObject(w)?M2(z,w):q.IsRecord(w)?l2(z,w):q.IsSymbol(w)?P.True:P.False}function JA(z,w){return q.IsTemplateLiteral(z)?R0(f6(z),w):q.IsTemplateLiteral(w)?R0(z,f6(w)):Y4("Invalid fallthrough for TemplateLiteral")}function BA(z,w){return q.IsArray(w)&&z.items!==void 0&&z.items.every((U)=>R0(U,w.items)===P.True)}function MA(z,w){return q.IsNever(z)?P.True:q.IsUnknown(z)?P.False:q.IsAny(z)?P.Union:P.False}function qA(z,w){return l0(w)?s0(z,w):q.IsObject(w)&&F8(w)?P.True:q.IsArray(w)&&BA(z,w)?P.True:!q.IsTuple(w)?P.False:Y2.IsUndefined(z.items)&&!Y2.IsUndefined(w.items)||!Y2.IsUndefined(z.items)&&Y2.IsUndefined(w.items)?P.False:Y2.IsUndefined(z.items)&&!Y2.IsUndefined(w.items)?P.True:z.items.every((U,W)=>R0(U,w.items[W])===P.True)?P.True:P.False}function LA(z,w){return l0(w)?s0(z,w):q.IsObject(w)?M2(z,w):q.IsRecord(w)?l2(z,w):q.IsUint8Array(w)?P.True:P.False}function GA(z,w){return l0(w)?s0(z,w):q.IsObject(w)?M2(z,w):q.IsRecord(w)?l2(z,w):q.IsVoid(w)?_A(z,w):q.IsUndefined(w)?P.True:P.False}function Pz(z,w){return w.anyOf.some((U)=>R0(z,U)===P.True)?P.True:P.False}function NA(z,w){return z.anyOf.every((U)=>R0(U,w)===P.True)?P.True:P.False}function p9(z,w){return P.True}function HA(z,w){return q.IsNever(w)?u9(z,w):q.IsIntersect(w)?j8(z,w):q.IsUnion(w)?Pz(z,w):q.IsAny(w)?Dz(z,w):q.IsString(w)?o9(z,w):q.IsNumber(w)?m9(z,w):q.IsInteger(w)?n9(z,w):q.IsBoolean(w)?v9(z,w):q.IsArray(w)?f$(z,w):q.IsTuple(w)?MA(z,w):q.IsObject(w)?M2(z,w):q.IsUnknown(w)?P.True:P.False}function _A(z,w){return q.IsUndefined(z)?P.True:q.IsUndefined(z)?P.True:P.False}function SA(z,w){return q.IsIntersect(w)?j8(z,w):q.IsUnion(w)?Pz(z,w):q.IsUnknown(w)?p9(z,w):q.IsAny(w)?Dz(z,w):q.IsObject(w)?M2(z,w):q.IsVoid(w)?P.True:P.False}function R0(z,w){return q.IsTemplateLiteral(z)||q.IsTemplateLiteral(w)?JA(z,w):q.IsRegExp(z)||q.IsRegExp(w)?AA(z,w):q.IsNot(z)||q.IsNot(w)?l$(z,w):q.IsAny(z)?g$(z,w):q.IsArray(z)?d$(z,w):q.IsBigInt(z)?c$(z,w):q.IsBoolean(z)?i$(z,w):q.IsAsyncIterator(z)?h$(z,w):q.IsConstructor(z)?y$(z,w):q.IsDate(z)?v$(z,w):q.IsFunction(z)?n$(z,w):q.IsInteger(z)?u$(z,w):q.IsIntersect(z)?m$(z,w):q.IsIterator(z)?t$(z,w):q.IsLiteral(z)?o$(z,w):q.IsNever(z)?p$(z,w):q.IsNull(z)?s$(z,w):q.IsNumber(z)?r$(z,w):q.IsObject(z)?XA(z,w):q.IsRecord(z)?$A(z,w):q.IsString(z)?QA(z,w):q.IsSymbol(z)?YA(z,w):q.IsTuple(z)?qA(z,w):q.IsPromise(z)?ZA(z,w):q.IsUint8Array(z)?LA(z,w):q.IsUndefined(z)?GA(z,w):q.IsUnion(z)?NA(z,w):q.IsUnknown(z)?HA(z,w):q.IsVoid(z)?SA(z,w):Y4(`Unknown left type operand '${z[H]}'`)}function B6(z,w){return R0(z,w)}function DA(z,w,U,W,X){let Z={};for(let $ of globalThis.Object.getOwnPropertyNames(z))Z[$]=J4(z[$],w,U,W,V0(X));return Z}function PA(z,w,U,W,X){return DA(z.properties,w,U,W,X)}function l9(z,w,U,W,X){let Z=PA(z,w,U,W,X);return J0(Z)}function OA(z,w,U,W){let X=B6(z,w);return X===P.Union?N0([U,W]):X===P.True?U:W}function J4(z,w,U,W,X){return T0(z)?l9(z,w,U,W,X):g2(z)?D(s9(z,w,U,W,X)):D(OA(z,w,U,W),X)}function RA(z,w,U,W,X){return{[z]:J4(Z0(z),w,U,W,V0(X))}}function CA(z,w,U,W,X){return z.reduce((Z,$)=>{return{...Z,...RA($,w,U,W,X)}},{})}function bA(z,w,U,W,X){return CA(z.keys,w,U,W,X)}function s9(z,w,U,W,X){let Z=bA(z,w,U,W,X);return J0(Z)}function KA(z){return z.allOf.every((w)=>o1(w))}function jA(z){return z.anyOf.some((w)=>o1(w))}function FA(z){return!o1(z.not)}function o1(z){return z[H]==="Intersect"?KA(z):z[H]==="Union"?jA(z):z[H]==="Not"?FA(z):z[H]==="Undefined"?!0:!1}function r9(z,w){return B4(f6(z),w)}function EA(z,w){let U=z.filter((W)=>B6(W,w)===P.False);return U.length===1?U[0]:N0(U)}function B4(z,w,U={}){if(f2(z))return D(r9(z,w),U);if(T0(z))return D(a9(z,w),U);return D(Q0(z)?EA(z.anyOf,w):B6(z,w)!==P.False?p():z,U)}function IA(z,w){let U={};for(let W of globalThis.Object.getOwnPropertyNames(z))U[W]=B4(z[W],w);return U}function xA(z,w){return IA(z.properties,w)}function a9(z,w){let U=xA(z,w);return J0(U)}function e9(z,w){return M4(f6(z),w)}function VA(z,w){let U=z.filter((W)=>B6(W,w)!==P.False);return U.length===1?U[0]:N0(U)}function M4(z,w,U){if(f2(z))return D(e9(z,w),U);if(T0(z))return D(z7(z,w),U);return D(Q0(z)?VA(z.anyOf,w):B6(z,w)!==P.False?z:p(),U)}function kA(z,w){let U={};for(let W of globalThis.Object.getOwnPropertyNames(z))U[W]=M4(z[W],w);return U}function TA(z,w){return kA(z.properties,w)}function z7(z,w){let U=TA(z,w);return J0(U)}function w7(z,w){return Y1(z)?D(z.returns,w):p(w)}function E8(z){return P2(J2(z))}function d6(z,w,U){return D({[H]:"Record",type:"object",patternProperties:{[z]:w}},U)}function Oz(z,w,U){let W={};for(let X of z)W[X]=w;return H0(W,{...U,[n2]:"Record"})}function gA(z,w,U){return G8(z)?Oz(D2(z),w,U):d6(z.pattern,w,U)}function fA(z,w,U){return Oz(D2(N0(z)),w,U)}function dA(z,w,U){return Oz([z.toString()],w,U)}function hA(z,w,U){return d6(z.source,w,U)}function cA(z,w,U){let W=t0(z.pattern)?I1:z.pattern;return d6(W,w,U)}function iA(z,w,U){return d6(I1,w,U)}function yA(z,w,U){return d6($9,w,U)}function vA(z,w,U){return H0({true:w,false:w},U)}function nA(z,w,U){return d6(E1,w,U)}function uA(z,w,U){return d6(E1,w,U)}function I8(z,w,U={}){return Q0(z)?fA(z.anyOf,w,U):f2(z)?gA(z,w,U):T2(z)?dA(z.const,w,U):y1(z)?vA(z,w,U):B1(z)?nA(z,w,U):M1(z)?uA(z,w,U):Az(z)?hA(z,w,U):v1(z)?cA(z,w,U):Zz(z)?iA(z,w,U):A6(z)?yA(z,w,U):p(U)}function x8(z){return globalThis.Object.getOwnPropertyNames(z.patternProperties)[0]}function U7(z){let w=x8(z);return w===I1?N2():w===E1?u2():N2({pattern:w})}function V8(z){return z.patternProperties[x8(z)]}function mA(z,w){return w.parameters=h4(z,w.parameters),w.returns=L1(z,w.returns),w}function tA(z,w){return w.parameters=h4(z,w.parameters),w.returns=L1(z,w.returns),w}function oA(z,w){return w.allOf=h4(z,w.allOf),w}function pA(z,w){return w.anyOf=h4(z,w.anyOf),w}function lA(z,w){if(t0(w.items))return w;return w.items=h4(z,w.items),w}function sA(z,w){return w.items=L1(z,w.items),w}function rA(z,w){return w.items=L1(z,w.items),w}function aA(z,w){return w.items=L1(z,w.items),w}function eA(z,w){return w.item=L1(z,w.item),w}function zQ(z,w){let U=XQ(z,w.properties);return{...w,...H0(U)}}function wQ(z,w){let U=L1(z,U7(w)),W=L1(z,V8(w)),X=I8(U,W);return{...w,...X}}function UQ(z,w){return w.index in z?z[w.index]:q1()}function WQ(z,w){let U=s6(w),W=S2(w),X=L1(z,w);return U&&W?E8(X):U&&!W?P2(X):!U&&W?J2(X):X}function XQ(z,w){return globalThis.Object.getOwnPropertyNames(w).reduce((U,W)=>{return{...U,[W]:WQ(z,w[W])}},{})}function h4(z,w){return w.map((U)=>L1(z,U))}function L1(z,w){return Y1(w)?mA(z,w):J1(w)?tA(z,w):c0(w)?oA(z,w):Q0(w)?pA(z,w):d2(w)?lA(z,w):A1(w)?sA(z,w):I6(w)?rA(z,w):V6(w)?aA(z,w):k6(w)?eA(z,w):o0(w)?zQ(z,w):T6(w)?wQ(z,w):$z(w)?UQ(z,w):w}function W7(z,w){return L1(w,p6(z))}function X7(z){return D({[H]:"Integer",type:"integer"},z)}function ZQ(z,w,U){return{[z]:G1(Z0(z),w,V0(U))}}function $Q(z,w,U){return z.reduce((X,Z)=>{return{...X,...ZQ(Z,w,U)}},{})}function AQ(z,w,U){return $Q(z.keys,w,U)}function Z7(z,w,U){let W=AQ(z,w,U);return J0(W)}function QQ(z){let[w,U]=[z.slice(0,1),z.slice(1)];return[w.toLowerCase(),U].join("")}function YQ(z){let[w,U]=[z.slice(0,1),z.slice(1)];return[w.toUpperCase(),U].join("")}function JQ(z){return z.toUpperCase()}function BQ(z){return z.toLowerCase()}function MQ(z,w,U){let W=W4(z.pattern);if(!g6(W))return{...z,pattern:$7(z.pattern,w)};let $=[...T4(W)].map((Y)=>Z0(Y)),A=A7($,w),Q=N0(A);return H8([Q],U)}function $7(z,w){return typeof z==="string"?w==="Uncapitalize"?QQ(z):w==="Capitalize"?YQ(z):w==="Uppercase"?JQ(z):w==="Lowercase"?BQ(z):z:z.toString()}function A7(z,w){return z.map((U)=>G1(U,w))}function G1(z,w,U={}){return g2(z)?Z7(z,w,U):f2(z)?MQ(z,w,U):Q0(z)?N0(A7(z.anyOf,w),U):T2(z)?Z0($7(z.const,w),U):D(z,U)}function Q7(z,w={}){return G1(z,"Capitalize",w)}function Y7(z,w={}){return G1(z,"Lowercase",w)}function J7(z,w={}){return G1(z,"Uncapitalize",w)}function B7(z,w={}){return G1(z,"Uppercase",w)}function qQ(z,w,U){let W={};for(let X of globalThis.Object.getOwnPropertyNames(z))W[X]=M6(z[X],w,V0(U));return W}function LQ(z,w,U){return qQ(z.properties,w,U)}function M7(z,w,U){let W=LQ(z,w,U);return J0(W)}function GQ(z,w){return z.map((U)=>Rz(U,w))}function NQ(z,w){return z.map((U)=>Rz(U,w))}function HQ(z,w){let{[w]:U,...W}=z;return W}function _Q(z,w){return w.reduce((U,W)=>HQ(U,W),z)}function SQ(z,w){let U=i0(z,[F0,"$id","required","properties"]),W=_Q(z.properties,w);return H0(W,U)}function DQ(z){let w=z.reduce((U,W)=>M8(W)?[...U,Z0(W)]:U,[]);return N0(w)}function Rz(z,w){return c0(z)?B2(GQ(z.allOf,w)):Q0(z)?N0(NQ(z.anyOf,w)):o0(z)?SQ(z,w):H0({})}function M6(z,w,U){let W=m0(w)?DQ(w):w,X=f0(w)?D2(w):w,Z=u0(z),$=u0(w);return T0(z)?M7(z,X,U):g2(w)?q7(z,w,U):Z&&$?x0("Omit",[z,W],U):!Z&&$?x0("Omit",[z,W],U):Z&&!$?x0("Omit",[z,W],U):D({...Rz(z,X),...U})}function PQ(z,w,U){return{[w]:M6(z,[w],V0(U))}}function OQ(z,w,U){return w.reduce((W,X)=>{return{...W,...PQ(z,X,U)}},{})}function RQ(z,w,U){return OQ(z,w.keys,U)}function q7(z,w,U){let W=RQ(z,w,U);return J0(W)}function CQ(z,w,U){let W={};for(let X of globalThis.Object.getOwnPropertyNames(z))W[X]=q6(z[X],w,V0(U));return W}function bQ(z,w,U){return CQ(z.properties,w,U)}function L7(z,w,U){let W=bQ(z,w,U);return J0(W)}function KQ(z,w){return z.map((U)=>Cz(U,w))}function jQ(z,w){return z.map((U)=>Cz(U,w))}function FQ(z,w){let U={};for(let W of w)if(W in z)U[W]=z[W];return U}function EQ(z,w){let U=i0(z,[F0,"$id","required","properties"]),W=FQ(z.properties,w);return H0(W,U)}function IQ(z){let w=z.reduce((U,W)=>M8(W)?[...U,Z0(W)]:U,[]);return N0(w)}function Cz(z,w){return c0(z)?B2(KQ(z.allOf,w)):Q0(z)?N0(jQ(z.anyOf,w)):o0(z)?EQ(z,w):H0({})}function q6(z,w,U){let W=m0(w)?IQ(w):w,X=f0(w)?D2(w):w,Z=u0(z),$=u0(w);return T0(z)?L7(z,X,U):g2(w)?G7(z,w,U):Z&&$?x0("Pick",[z,W],U):!Z&&$?x0("Pick",[z,W],U):Z&&!$?x0("Pick",[z,W],U):D({...Cz(z,X),...U})}function xQ(z,w,U){return{[w]:q6(z,[w],V0(U))}}function VQ(z,w,U){return w.reduce((W,X)=>{return{...W,...xQ(z,X,U)}},{})}function kQ(z,w,U){return VQ(z,w.keys,U)}function G7(z,w,U){let W=kQ(z,w,U);return J0(W)}function TQ(z,w){return x0("Partial",[x0(z,w)])}function gQ(z){return x0("Partial",[o2(z)])}function fQ(z){let w={};for(let U of globalThis.Object.getOwnPropertyNames(z))w[U]=J2(z[U]);return w}function dQ(z){let w=i0(z,[F0,"$id","required","properties"]),U=fQ(z.properties);return H0(U,w)}function N7(z){return z.map((w)=>H7(w))}function H7(z){return Q1(z)?TQ(z.target,z.parameters):u0(z)?gQ(z.$ref):c0(z)?B2(N7(z.allOf)):Q0(z)?N0(N7(z.anyOf)):o0(z)?dQ(z):x6(z)?z:y1(z)?z:B1(z)?z:T2(z)?z:F4(z)?z:M1(z)?z:v1(z)?z:E4(z)?z:n1(z)?z:H0({})}function q4(z,w){if(T0(z))return _7(z,w);else return D({...H7(z),...w})}function hQ(z,w){let U={};for(let W of globalThis.Object.getOwnPropertyNames(z))U[W]=q4(z[W],V0(w));return U}function cQ(z,w){return hQ(z.properties,w)}function _7(z,w){let U=cQ(z,w);return J0(U)}function iQ(z,w){return x0("Required",[x0(z,w)])}function yQ(z){return x0("Required",[o2(z)])}function vQ(z){let w={};for(let U of globalThis.Object.getOwnPropertyNames(z))w[U]=i0(z[U],[Z2]);return w}function nQ(z){let w=i0(z,[F0,"$id","required","properties"]),U=vQ(z.properties);return H0(U,w)}function S7(z){return z.map((w)=>D7(w))}function D7(z){return Q1(z)?iQ(z.target,z.parameters):u0(z)?yQ(z.$ref):c0(z)?B2(S7(z.allOf)):Q0(z)?N0(S7(z.anyOf)):o0(z)?nQ(z):x6(z)?z:y1(z)?z:B1(z)?z:T2(z)?z:F4(z)?z:M1(z)?z:v1(z)?z:E4(z)?z:n1(z)?z:H0({})}function L4(z,w){if(T0(z))return P7(z,w);else return D({...D7(z),...w})}function uQ(z,w){let U={};for(let W of globalThis.Object.getOwnPropertyNames(z))U[W]=L4(z[W],w);return U}function mQ(z,w){return uQ(z.properties,w)}function P7(z,w){let U=mQ(z,w);return J0(U)}function tQ(z,w){return w.map((U)=>{return u0(U)?bz(z,U.$ref):h2(z,U)})}function bz(z,w){return w in z?u0(z[w])?bz(z,z[w].$ref):h2(z,z[w]):p()}function oQ(z){return A4(z[0])}function pQ(z){return J6(z[0],z[1])}function lQ(z){return Q4(z[0])}function sQ(z){return q4(z[0])}function rQ(z){return M6(z[0],z[1])}function aQ(z){return q6(z[0],z[1])}function eQ(z){return L4(z[0])}function zY(z,w,U){let W=tQ(z,U);return w==="Awaited"?oQ(W):w==="Index"?pQ(W):w==="KeyOf"?lQ(W):w==="Partial"?sQ(W):w==="Omit"?rQ(W):w==="Pick"?aQ(W):w==="Required"?eQ(W):p()}function wY(z,w){return e6(h2(z,w))}function UY(z,w){return z4(h2(z,w))}function WY(z,w,U){return w4(c4(z,w),h2(z,U))}function XY(z,w,U){return x1(c4(z,w),h2(z,U))}function ZY(z,w){return B2(c4(z,w))}function $Y(z,w){return $4(h2(z,w))}function AY(z,w){return H0(globalThis.Object.keys(w).reduce((U,W)=>{return{...U,[W]:h2(z,w[W])}},{}))}function QY(z,w){let[U,W]=[h2(z,V8(w)),x8(w)],X=p6(w);return X.patternProperties[W]=U,X}function YY(z,w){return u0(w)?{...bz(z,w.$ref),[F0]:w[F0]}:w}function JY(z,w){return m2(c4(z,w))}function BY(z,w){return N0(c4(z,w))}function c4(z,w){return w.map((U)=>h2(z,U))}function h2(z,w){return S2(w)?D(h2(z,i0(w,[Z2])),w):s6(w)?D(h2(z,i0(w,[$1])),w):G0(w)?D(YY(z,w),w):A1(w)?D(wY(z,w.items),w):I6(w)?D(UY(z,w.items),w):Q1(w)?D(zY(z,w.target,w.parameters)):Y1(w)?D(WY(z,w.parameters,w.returns),w):J1(w)?D(XY(z,w.parameters,w.returns),w):c0(w)?D(ZY(z,w.allOf),w):V6(w)?D($Y(z,w.items),w):o0(w)?D(AY(z,w.properties),w):T6(w)?D(QY(z,w)):d2(w)?D(JY(z,w.items||[]),w):Q0(w)?D(BY(z,w.anyOf),w):w}function MY(z,w){return w in z?h2(z,z[w]):p()}function O7(z){return globalThis.Object.getOwnPropertyNames(z).reduce((w,U)=>{return{...w,[U]:MY(z,U)}},{})}class R7{constructor(z){let w=O7(z),U=this.WithIdentifiers(w);this.$defs=U}Import(z,w){let U={...this.$defs,[z]:D(this.$defs[z],w)};return D({[H]:"Import",$defs:U,$ref:z})}WithIdentifiers(z){return globalThis.Object.getOwnPropertyNames(z).reduce((w,U)=>{return{...w,[U]:{...z[U],$id:U}}},{})}}function C7(z){return new R7(z)}function b7(z,w){return D({[H]:"Not",not:z},w)}function K7(z,w){return J1(z)?m2(z.parameters,w):p()}var qY=0;function j7(z,w={}){if(t0(w.$id))w.$id=`T${qY++}`;let U=p6(z({[H]:"This",$ref:`${w.$id}`}));return U.$id=w.$id,D({[n2]:"Recursive",...U},w)}function F7(z,w){let U=j0(z)?new globalThis.RegExp(z):z;return D({[H]:"RegExp",type:"RegExp",source:U.source,flags:U.flags},w)}function LY(z){return c0(z)?z.allOf:Q0(z)?z.anyOf:d2(z)?z.items??[]:[]}function E7(z){return LY(z)}function I7(z,w){return J1(z)?D(z.returns,w):p(w)}class x7{constructor(z){this.schema=z}Decode(z){return new V7(this.schema,z)}}class V7{constructor(z,w){this.schema=z,this.decode=w}EncodeTransform(z,w){let X={Encode:(Z)=>w[F0].Encode(z(Z)),Decode:(Z)=>this.decode(w[F0].Decode(Z))};return{...w,[F0]:X}}EncodeSchema(z,w){let U={Decode:this.decode,Encode:z};return{...w,[F0]:U}}Encode(z){return G0(this.schema)?this.EncodeTransform(z,this.schema):this.EncodeSchema(z,this.schema)}}function k7(z){return new x7(z)}function k8(z={}){return D({[H]:z[H]??"Unsafe"},z)}function T7(z){return D({[H]:"Void",type:"void"},z)}var Kz={};j6(Kz,{Void:()=>T7,Uppercase:()=>B7,Unsafe:()=>k8,Unknown:()=>q1,Union:()=>N0,Undefined:()=>C8,Uncapitalize:()=>J7,Uint8Array:()=>b8,Tuple:()=>m2,Transform:()=>k7,TemplateLiteral:()=>H8,Symbol:()=>R8,String:()=>N2,ReturnType:()=>I7,Rest:()=>E7,Required:()=>L4,RegExp:()=>F7,Ref:()=>o2,Recursive:()=>j7,Record:()=>I8,ReadonlyOptional:()=>E8,Readonly:()=>P2,Promise:()=>S8,Pick:()=>q6,Partial:()=>q4,Parameters:()=>K7,Optional:()=>J2,Omit:()=>M6,Object:()=>H0,Number:()=>u2,Null:()=>O8,Not:()=>b7,Never:()=>p,Module:()=>C7,Mapped:()=>j9,Lowercase:()=>Y7,Literal:()=>Z0,KeyOf:()=>Q4,Iterator:()=>$4,Intersect:()=>B2,Integer:()=>X7,Instantiate:()=>W7,InstanceType:()=>w7,Index:()=>J6,Function:()=>x1,Extract:()=>M4,Extends:()=>J4,Exclude:()=>B4,Enum:()=>f9,Date:()=>P8,ConstructorParameters:()=>g9,Constructor:()=>w4,Const:()=>T9,Composite:()=>k9,Capitalize:()=>Q7,Boolean:()=>N8,BigInt:()=>Z4,Awaited:()=>A4,AsyncIterator:()=>z4,Array:()=>e6,Argument:()=>B9,Any:()=>Y6});var L6=Kz;function GY(z){switch(z.errorType){case _.ArrayContains:return"Expected array to contain at least one matching value";case _.ArrayMaxContains:return`Expected array to contain no more than ${z.schema.maxContains} matching values`;case _.ArrayMinContains:return`Expected array to contain at least ${z.schema.minContains} matching values`;case _.ArrayMaxItems:return`Expected array length to be less or equal to ${z.schema.maxItems}`;case _.ArrayMinItems:return`Expected array length to be greater or equal to ${z.schema.minItems}`;case _.ArrayUniqueItems:return"Expected array elements to be unique";case _.Array:return"Expected array";case _.AsyncIterator:return"Expected AsyncIterator";case _.BigIntExclusiveMaximum:return`Expected bigint to be less than ${z.schema.exclusiveMaximum}`;case _.BigIntExclusiveMinimum:return`Expected bigint to be greater than ${z.schema.exclusiveMinimum}`;case _.BigIntMaximum:return`Expected bigint to be less or equal to ${z.schema.maximum}`;case _.BigIntMinimum:return`Expected bigint to be greater or equal to ${z.schema.minimum}`;case _.BigIntMultipleOf:return`Expected bigint to be a multiple of ${z.schema.multipleOf}`;case _.BigInt:return"Expected bigint";case _.Boolean:return"Expected boolean";case _.DateExclusiveMinimumTimestamp:return`Expected Date timestamp to be greater than ${z.schema.exclusiveMinimumTimestamp}`;case _.DateExclusiveMaximumTimestamp:return`Expected Date timestamp to be less than ${z.schema.exclusiveMaximumTimestamp}`;case _.DateMinimumTimestamp:return`Expected Date timestamp to be greater or equal to ${z.schema.minimumTimestamp}`;case _.DateMaximumTimestamp:return`Expected Date timestamp to be less or equal to ${z.schema.maximumTimestamp}`;case _.DateMultipleOfTimestamp:return`Expected Date timestamp to be a multiple of ${z.schema.multipleOfTimestamp}`;case _.Date:return"Expected Date";case _.Function:return"Expected function";case _.IntegerExclusiveMaximum:return`Expected integer to be less than ${z.schema.exclusiveMaximum}`;case _.IntegerExclusiveMinimum:return`Expected integer to be greater than ${z.schema.exclusiveMinimum}`;case _.IntegerMaximum:return`Expected integer to be less or equal to ${z.schema.maximum}`;case _.IntegerMinimum:return`Expected integer to be greater or equal to ${z.schema.minimum}`;case _.IntegerMultipleOf:return`Expected integer to be a multiple of ${z.schema.multipleOf}`;case _.Integer:return"Expected integer";case _.IntersectUnevaluatedProperties:return"Unexpected property";case _.Intersect:return"Expected all values to match";case _.Iterator:return"Expected Iterator";case _.Literal:return`Expected ${typeof z.schema.const==="string"?`'${z.schema.const}'`:z.schema.const}`;case _.Never:return"Never";case _.Not:return"Value should not match";case _.Null:return"Expected null";case _.NumberExclusiveMaximum:return`Expected number to be less than ${z.schema.exclusiveMaximum}`;case _.NumberExclusiveMinimum:return`Expected number to be greater than ${z.schema.exclusiveMinimum}`;case _.NumberMaximum:return`Expected number to be less or equal to ${z.schema.maximum}`;case _.NumberMinimum:return`Expected number to be greater or equal to ${z.schema.minimum}`;case _.NumberMultipleOf:return`Expected number to be a multiple of ${z.schema.multipleOf}`;case _.Number:return"Expected number";case _.Object:return"Expected object";case _.ObjectAdditionalProperties:return"Unexpected property";case _.ObjectMaxProperties:return`Expected object to have no more than ${z.schema.maxProperties} properties`;case _.ObjectMinProperties:return`Expected object to have at least ${z.schema.minProperties} properties`;case _.ObjectRequiredProperty:return"Expected required property";case _.Promise:return"Expected Promise";case _.RegExp:return"Expected string to match regular expression";case _.StringFormatUnknown:return`Unknown format '${z.schema.format}'`;case _.StringFormat:return`Expected string to match '${z.schema.format}' format`;case _.StringMaxLength:return`Expected string length less or equal to ${z.schema.maxLength}`;case _.StringMinLength:return`Expected string length greater or equal to ${z.schema.minLength}`;case _.StringPattern:return`Expected string to match '${z.schema.pattern}'`;case _.String:return"Expected string";case _.Symbol:return"Expected symbol";case _.TupleLength:return`Expected tuple to have ${z.schema.maxItems||0} elements`;case _.Tuple:return"Expected tuple";case _.Uint8ArrayMaxByteLength:return`Expected byte length less or equal to ${z.schema.maxByteLength}`;case _.Uint8ArrayMinByteLength:return`Expected byte length greater or equal to ${z.schema.minByteLength}`;case _.Uint8Array:return"Expected Uint8Array";case _.Undefined:return"Expected undefined";case _.Union:return"Expected union value";case _.Void:return"Expected void";case _.Kind:return`Expected kind '${z.schema[H]}'`;default:return"Unknown error type"}}var NY=GY;function g7(){return NY}class f7 extends n{constructor(z){super(`Unable to dereference schema with $id '${z.$ref}'`);this.schema=z}}function HY(z,w){let U=w.find((W)=>W.$id===z.$ref);if(U===void 0)throw new f7(z);return B0(U,w)}function z2(z,w){if(!A0(z.$id)||w.some((U)=>U.$id===z.$id))return w;return w.push(z),w}function B0(z,w){return z[H]==="This"||z[H]==="Ref"?HY(z,w):z}class d7 extends n{constructor(z){super("Unable to hash value");this.value=z}}var c2;(function(z){z[z.Undefined=0]="Undefined",z[z.Null=1]="Null",z[z.Boolean=2]="Boolean",z[z.Number=3]="Number",z[z.String=4]="String",z[z.Object=5]="Object",z[z.Array=6]="Array",z[z.Date=7]="Date",z[z.Uint8Array=8]="Uint8Array",z[z.Symbol=9]="Symbol",z[z.BigInt=10]="BigInt"})(c2||(c2={}));var G4=BigInt("14695981039346656037"),[_Y,SY]=[BigInt("1099511628211"),BigInt("18446744073709551616")],DY=Array.from({length:256}).map((z,w)=>BigInt(w)),h7=new Float64Array(1),c7=new DataView(h7.buffer),i7=new Uint8Array(h7.buffer);function*PY(z){let w=z===0?1:Math.ceil(Math.floor(Math.log2(z)+1)/8);for(let U=0;U<w;U++)yield z>>8*(w-1-U)&255}function OY(z){q2(c2.Array);for(let w of z)N4(w)}function RY(z){q2(c2.Boolean),q2(z?1:0)}function CY(z){q2(c2.BigInt),c7.setBigInt64(0,z);for(let w of i7)q2(w)}function bY(z){q2(c2.Date),N4(z.getTime())}function KY(z){q2(c2.Null)}function jY(z){q2(c2.Number),c7.setFloat64(0,z);for(let w of i7)q2(w)}function FY(z){q2(c2.Object);for(let w of globalThis.Object.getOwnPropertyNames(z).sort())N4(w),N4(z[w])}function EY(z){q2(c2.String);for(let w=0;w<z.length;w++)for(let U of PY(z.charCodeAt(w)))q2(U)}function IY(z){q2(c2.Symbol),N4(z.description)}function xY(z){q2(c2.Uint8Array);for(let w=0;w<z.length;w++)q2(z[w])}function VY(z){return q2(c2.Undefined)}function N4(z){if(m(z))return OY(z);if(F1(z))return RY(z);if(X2(z))return CY(z);if(G2(z))return bY(z);if(c1(z))return KY(z);if(v(z))return jY(z);if(l(z))return FY(z);if(A0(z))return EY(z);if(i1(z))return IY(z);if(l6(z))return xY(z);if(k0(z))return VY(z);throw new d7(z)}function q2(z){G4=G4^DY[z],G4=G4*_Y%SY}function G6(z){return G4=BigInt("14695981039346656037"),N4(z),G4}class y7 extends n{constructor(z){super("Unknown type");this.schema=z}}function kY(z){return z[H]==="Any"||z[H]==="Unknown"}function U0(z){return z!==void 0}function TY(z,w,U){return!0}function gY(z,w,U){return!0}function fY(z,w,U){if(!m(U))return!1;if(U0(z.minItems)&&!(U.length>=z.minItems))return!1;if(U0(z.maxItems)&&!(U.length<=z.maxItems))return!1;if(!U.every((Z)=>w2(z.items,w,Z)))return!1;if(z.uniqueItems===!0&&!function(){let Z=new Set;for(let $ of U){let A=G6($);if(Z.has(A))return!1;else Z.add(A)}return!0}())return!1;if(!(U0(z.contains)||v(z.minContains)||v(z.maxContains)))return!0;let W=U0(z.contains)?z.contains:p(),X=U.reduce((Z,$)=>w2(W,w,$)?Z+1:Z,0);if(X===0)return!1;if(v(z.minContains)&&X<z.minContains)return!1;if(v(z.maxContains)&&X>z.maxContains)return!1;return!0}function dY(z,w,U){return Q8(U)}function hY(z,w,U){if(!X2(U))return!1;if(U0(z.exclusiveMaximum)&&!(U<z.exclusiveMaximum))return!1;if(U0(z.exclusiveMinimum)&&!(U>z.exclusiveMinimum))return!1;if(U0(z.maximum)&&!(U<=z.maximum))return!1;if(U0(z.minimum)&&!(U>=z.minimum))return!1;if(U0(z.multipleOf)&&U%z.multipleOf!==BigInt(0))return!1;return!0}function cY(z,w,U){return F1(U)}function iY(z,w,U){return w2(z.returns,w,U.prototype)}function yY(z,w,U){if(!G2(U))return!1;if(U0(z.exclusiveMaximumTimestamp)&&!(U.getTime()<z.exclusiveMaximumTimestamp))return!1;if(U0(z.exclusiveMinimumTimestamp)&&!(U.getTime()>z.exclusiveMinimumTimestamp))return!1;if(U0(z.maximumTimestamp)&&!(U.getTime()<=z.maximumTimestamp))return!1;if(U0(z.minimumTimestamp)&&!(U.getTime()>=z.minimumTimestamp))return!1;if(U0(z.multipleOfTimestamp)&&U.getTime()%z.multipleOfTimestamp!==0)return!1;return!0}function vY(z,w,U){return $6(U)}function nY(z,w,U){let W=globalThis.Object.values(z.$defs),X=z.$defs[z.$ref];return w2(X,[...w,...W],U)}function uY(z,w,U){if(!B8(U))return!1;if(U0(z.exclusiveMaximum)&&!(U<z.exclusiveMaximum))return!1;if(U0(z.exclusiveMinimum)&&!(U>z.exclusiveMinimum))return!1;if(U0(z.maximum)&&!(U<=z.maximum))return!1;if(U0(z.minimum)&&!(U>=z.minimum))return!1;if(U0(z.multipleOf)&&U%z.multipleOf!==0)return!1;return!0}function mY(z,w,U){let W=z.allOf.every((X)=>w2(X,w,U));if(z.unevaluatedProperties===!1){let X=new RegExp(t1(z)),Z=Object.getOwnPropertyNames(U).every(($)=>X.test($));return W&&Z}else if(f0(z.unevaluatedProperties)){let X=new RegExp(t1(z)),Z=Object.getOwnPropertyNames(U).every(($)=>X.test($)||w2(z.unevaluatedProperties,w,U[$]));return W&&Z}else return W}function tY(z,w,U){return Y8(U)}function oY(z,w,U){return U===z.const}function pY(z,w,U){return!1}function lY(z,w,U){return!w2(z.not,w,U)}function sY(z,w,U){return c1(U)}function rY(z,w,U){if(!I0.IsNumberLike(U))return!1;if(U0(z.exclusiveMaximum)&&!(U<z.exclusiveMaximum))return!1;if(U0(z.exclusiveMinimum)&&!(U>z.exclusiveMinimum))return!1;if(U0(z.minimum)&&!(U>=z.minimum))return!1;if(U0(z.maximum)&&!(U<=z.maximum))return!1;if(U0(z.multipleOf)&&U%z.multipleOf!==0)return!1;return!0}function aY(z,w,U){if(!I0.IsObjectLike(U))return!1;if(U0(z.minProperties)&&!(Object.getOwnPropertyNames(U).length>=z.minProperties))return!1;if(U0(z.maxProperties)&&!(Object.getOwnPropertyNames(U).length<=z.maxProperties))return!1;let W=Object.getOwnPropertyNames(z.properties);for(let X of W){let Z=z.properties[X];if(z.required&&z.required.includes(X)){if(!w2(Z,w,U[X]))return!1;if((o1(Z)||kY(Z))&&!(X in U))return!1}else if(I0.IsExactOptionalProperty(U,X)&&!w2(Z,w,U[X]))return!1}if(z.additionalProperties===!1){let X=Object.getOwnPropertyNames(U);if(z.required&&z.required.length===W.length&&X.length===W.length)return!0;else return X.every((Z)=>W.includes(Z))}else if(typeof z.additionalProperties==="object")return Object.getOwnPropertyNames(U).every((Z)=>W.includes(Z)||w2(z.additionalProperties,w,U[Z]));else return!0}function eY(z,w,U){return J8(U)}function zJ(z,w,U){if(!I0.IsRecordLike(U))return!1;if(U0(z.minProperties)&&!(Object.getOwnPropertyNames(U).length>=z.minProperties))return!1;if(U0(z.maxProperties)&&!(Object.getOwnPropertyNames(U).length<=z.maxProperties))return!1;let[W,X]=Object.entries(z.patternProperties)[0],Z=new RegExp(W),$=Object.entries(U).every(([Y,J])=>{return Z.test(Y)?w2(X,w,J):!0}),A=typeof z.additionalProperties==="object"?Object.entries(U).every(([Y,J])=>{return!Z.test(Y)?w2(z.additionalProperties,w,J):!0}):!0,Q=z.additionalProperties===!1?Object.getOwnPropertyNames(U).every((Y)=>{return Z.test(Y)}):!0;return $&&A&&Q}function wJ(z,w,U){return w2(B0(z,w),w,U)}function UJ(z,w,U){let W=new RegExp(z.source,z.flags);if(U0(z.minLength)){if(!(U.length>=z.minLength))return!1}if(U0(z.maxLength)){if(!(U.length<=z.maxLength))return!1}return W.test(U)}function WJ(z,w,U){if(!A0(U))return!1;if(U0(z.minLength)){if(!(U.length>=z.minLength))return!1}if(U0(z.maxLength)){if(!(U.length<=z.maxLength))return!1}if(U0(z.pattern)){if(!new RegExp(z.pattern).test(U))return!1}if(U0(z.format)){if(!D0.Has(z.format))return!1;return D0.Get(z.format)(U)}return!0}function XJ(z,w,U){return i1(U)}function ZJ(z,w,U){return A0(U)&&new RegExp(z.pattern).test(U)}function $J(z,w,U){return w2(B0(z,w),w,U)}function AJ(z,w,U){if(!m(U))return!1;if(z.items===void 0&&U.length!==0)return!1;if(U.length!==z.maxItems)return!1;if(!z.items)return!0;for(let W=0;W<z.items.length;W++)if(!w2(z.items[W],w,U[W]))return!1;return!0}function QJ(z,w,U){return k0(U)}function YJ(z,w,U){return z.anyOf.some((W)=>w2(W,w,U))}function JJ(z,w,U){if(!l6(U))return!1;if(U0(z.maxByteLength)&&!(U.length<=z.maxByteLength))return!1;if(U0(z.minByteLength)&&!(U.length>=z.minByteLength))return!1;return!0}function BJ(z,w,U){return!0}function MJ(z,w,U){return I0.IsVoidLike(U)}function qJ(z,w,U){if(!p0.Has(z[H]))return!1;return p0.Get(z[H])(z,U)}function w2(z,w,U){let W=U0(z.$id)?z2(z,w):w,X=z;switch(X[H]){case"Any":return TY(X,W,U);case"Argument":return gY(X,W,U);case"Array":return fY(X,W,U);case"AsyncIterator":return dY(X,W,U);case"BigInt":return hY(X,W,U);case"Boolean":return cY(X,W,U);case"Constructor":return iY(X,W,U);case"Date":return yY(X,W,U);case"Function":return vY(X,W,U);case"Import":return nY(X,W,U);case"Integer":return uY(X,W,U);case"Intersect":return mY(X,W,U);case"Iterator":return tY(X,W,U);case"Literal":return oY(X,W,U);case"Never":return pY(X,W,U);case"Not":return lY(X,W,U);case"Null":return sY(X,W,U);case"Number":return rY(X,W,U);case"Object":return aY(X,W,U);case"Promise":return eY(X,W,U);case"Record":return zJ(X,W,U);case"Ref":return wJ(X,W,U);case"RegExp":return UJ(X,W,U);case"String":return WJ(X,W,U);case"Symbol":return XJ(X,W,U);case"TemplateLiteral":return ZJ(X,W,U);case"This":return $J(X,W,U);case"Tuple":return AJ(X,W,U);case"Undefined":return QJ(X,W,U);case"Union":return YJ(X,W,U);case"Uint8Array":return JJ(X,W,U);case"Unknown":return BJ(X,W,U);case"Void":return MJ(X,W,U);default:if(!p0.Has(X[H]))throw new y7(X);return qJ(X,W,U)}}function s(...z){return z.length===3?w2(z[0],z[1],z[2]):w2(z[0],[],z[1])}var _;(function(z){z[z.ArrayContains=0]="ArrayContains",z[z.ArrayMaxContains=1]="ArrayMaxContains",z[z.ArrayMaxItems=2]="ArrayMaxItems",z[z.ArrayMinContains=3]="ArrayMinContains",z[z.ArrayMinItems=4]="ArrayMinItems",z[z.ArrayUniqueItems=5]="ArrayUniqueItems",z[z.Array=6]="Array",z[z.AsyncIterator=7]="AsyncIterator",z[z.BigIntExclusiveMaximum=8]="BigIntExclusiveMaximum",z[z.BigIntExclusiveMinimum=9]="BigIntExclusiveMinimum",z[z.BigIntMaximum=10]="BigIntMaximum",z[z.BigIntMinimum=11]="BigIntMinimum",z[z.BigIntMultipleOf=12]="BigIntMultipleOf",z[z.BigInt=13]="BigInt",z[z.Boolean=14]="Boolean",z[z.DateExclusiveMaximumTimestamp=15]="DateExclusiveMaximumTimestamp",z[z.DateExclusiveMinimumTimestamp=16]="DateExclusiveMinimumTimestamp",z[z.DateMaximumTimestamp=17]="DateMaximumTimestamp",z[z.DateMinimumTimestamp=18]="DateMinimumTimestamp",z[z.DateMultipleOfTimestamp=19]="DateMultipleOfTimestamp",z[z.Date=20]="Date",z[z.Function=21]="Function",z[z.IntegerExclusiveMaximum=22]="IntegerExclusiveMaximum",z[z.IntegerExclusiveMinimum=23]="IntegerExclusiveMinimum",z[z.IntegerMaximum=24]="IntegerMaximum",z[z.IntegerMinimum=25]="IntegerMinimum",z[z.IntegerMultipleOf=26]="IntegerMultipleOf",z[z.Integer=27]="Integer",z[z.IntersectUnevaluatedProperties=28]="IntersectUnevaluatedProperties",z[z.Intersect=29]="Intersect",z[z.Iterator=30]="Iterator",z[z.Kind=31]="Kind",z[z.Literal=32]="Literal",z[z.Never=33]="Never",z[z.Not=34]="Not",z[z.Null=35]="Null",z[z.NumberExclusiveMaximum=36]="NumberExclusiveMaximum",z[z.NumberExclusiveMinimum=37]="NumberExclusiveMinimum",z[z.NumberMaximum=38]="NumberMaximum",z[z.NumberMinimum=39]="NumberMinimum",z[z.NumberMultipleOf=40]="NumberMultipleOf",z[z.Number=41]="Number",z[z.ObjectAdditionalProperties=42]="ObjectAdditionalProperties",z[z.ObjectMaxProperties=43]="ObjectMaxProperties",z[z.ObjectMinProperties=44]="ObjectMinProperties",z[z.ObjectRequiredProperty=45]="ObjectRequiredProperty",z[z.Object=46]="Object",z[z.Promise=47]="Promise",z[z.RegExp=48]="RegExp",z[z.StringFormatUnknown=49]="StringFormatUnknown",z[z.StringFormat=50]="StringFormat",z[z.StringMaxLength=51]="StringMaxLength",z[z.StringMinLength=52]="StringMinLength",z[z.StringPattern=53]="StringPattern",z[z.String=54]="String",z[z.Symbol=55]="Symbol",z[z.TupleLength=56]="TupleLength",z[z.Tuple=57]="Tuple",z[z.Uint8ArrayMaxByteLength=58]="Uint8ArrayMaxByteLength",z[z.Uint8ArrayMinByteLength=59]="Uint8ArrayMinByteLength",z[z.Uint8Array=60]="Uint8Array",z[z.Undefined=61]="Undefined",z[z.Union=62]="Union",z[z.Void=63]="Void"})(_||(_={}));class v7 extends n{constructor(z){super("Unknown type");this.schema=z}}function p1(z){return z.replace(/~/g,"~0").replace(/\//g,"~1")}function W0(z){return z!==void 0}class h6{constructor(z){this.iterator=z}[Symbol.iterator](){return this.iterator}First(){let z=this.iterator.next();return z.done?void 0:z.value}}function x(z,w,U,W,X=[]){return{type:z,schema:w,path:U,value:W,message:g7()({errorType:z,path:U,schema:w,value:W,errors:X}),errors:X}}function*LJ(z,w,U,W){}function*GJ(z,w,U,W){}function*NJ(z,w,U,W){if(!m(W))return yield x(_.Array,z,U,W);if(W0(z.minItems)&&!(W.length>=z.minItems))yield x(_.ArrayMinItems,z,U,W);if(W0(z.maxItems)&&!(W.length<=z.maxItems))yield x(_.ArrayMaxItems,z,U,W);for(let $=0;$<W.length;$++)yield*U2(z.items,w,`${U}/${$}`,W[$]);if(z.uniqueItems===!0&&!function(){let $=new Set;for(let A of W){let Q=G6(A);if($.has(Q))return!1;else $.add(Q)}return!0}())yield x(_.ArrayUniqueItems,z,U,W);if(!(W0(z.contains)||W0(z.minContains)||W0(z.maxContains)))return;let X=W0(z.contains)?z.contains:p(),Z=W.reduce(($,A,Q)=>U2(X,w,`${U}${Q}`,A).next().done===!0?$+1:$,0);if(Z===0)yield x(_.ArrayContains,z,U,W);if(v(z.minContains)&&Z<z.minContains)yield x(_.ArrayMinContains,z,U,W);if(v(z.maxContains)&&Z>z.maxContains)yield x(_.ArrayMaxContains,z,U,W)}function*HJ(z,w,U,W){if(!Q8(W))yield x(_.AsyncIterator,z,U,W)}function*_J(z,w,U,W){if(!X2(W))return yield x(_.BigInt,z,U,W);if(W0(z.exclusiveMaximum)&&!(W<z.exclusiveMaximum))yield x(_.BigIntExclusiveMaximum,z,U,W);if(W0(z.exclusiveMinimum)&&!(W>z.exclusiveMinimum))yield x(_.BigIntExclusiveMinimum,z,U,W);if(W0(z.maximum)&&!(W<=z.maximum))yield x(_.BigIntMaximum,z,U,W);if(W0(z.minimum)&&!(W>=z.minimum))yield x(_.BigIntMinimum,z,U,W);if(W0(z.multipleOf)&&W%z.multipleOf!==BigInt(0))yield x(_.BigIntMultipleOf,z,U,W)}function*SJ(z,w,U,W){if(!F1(W))yield x(_.Boolean,z,U,W)}function*DJ(z,w,U,W){yield*U2(z.returns,w,U,W.prototype)}function*PJ(z,w,U,W){if(!G2(W))return yield x(_.Date,z,U,W);if(W0(z.exclusiveMaximumTimestamp)&&!(W.getTime()<z.exclusiveMaximumTimestamp))yield x(_.DateExclusiveMaximumTimestamp,z,U,W);if(W0(z.exclusiveMinimumTimestamp)&&!(W.getTime()>z.exclusiveMinimumTimestamp))yield x(_.DateExclusiveMinimumTimestamp,z,U,W);if(W0(z.maximumTimestamp)&&!(W.getTime()<=z.maximumTimestamp))yield x(_.DateMaximumTimestamp,z,U,W);if(W0(z.minimumTimestamp)&&!(W.getTime()>=z.minimumTimestamp))yield x(_.DateMinimumTimestamp,z,U,W);if(W0(z.multipleOfTimestamp)&&W.getTime()%z.multipleOfTimestamp!==0)yield x(_.DateMultipleOfTimestamp,z,U,W)}function*OJ(z,w,U,W){if(!$6(W))yield x(_.Function,z,U,W)}function*RJ(z,w,U,W){let X=globalThis.Object.values(z.$defs),Z=z.$defs[z.$ref];yield*U2(Z,[...w,...X],U,W)}function*CJ(z,w,U,W){if(!B8(W))return yield x(_.Integer,z,U,W);if(W0(z.exclusiveMaximum)&&!(W<z.exclusiveMaximum))yield x(_.IntegerExclusiveMaximum,z,U,W);if(W0(z.exclusiveMinimum)&&!(W>z.exclusiveMinimum))yield x(_.IntegerExclusiveMinimum,z,U,W);if(W0(z.maximum)&&!(W<=z.maximum))yield x(_.IntegerMaximum,z,U,W);if(W0(z.minimum)&&!(W>=z.minimum))yield x(_.IntegerMinimum,z,U,W);if(W0(z.multipleOf)&&W%z.multipleOf!==0)yield x(_.IntegerMultipleOf,z,U,W)}function*bJ(z,w,U,W){let X=!1;for(let Z of z.allOf)for(let $ of U2(Z,w,U,W))X=!0,yield $;if(X)return yield x(_.Intersect,z,U,W);if(z.unevaluatedProperties===!1){let Z=new RegExp(t1(z));for(let $ of Object.getOwnPropertyNames(W))if(!Z.test($))yield x(_.IntersectUnevaluatedProperties,z,`${U}/${$}`,W)}if(typeof z.unevaluatedProperties==="object"){let Z=new RegExp(t1(z));for(let $ of Object.getOwnPropertyNames(W))if(!Z.test($)){let A=U2(z.unevaluatedProperties,w,`${U}/${$}`,W[$]).next();if(!A.done)yield A.value}}}function*KJ(z,w,U,W){if(!Y8(W))yield x(_.Iterator,z,U,W)}function*jJ(z,w,U,W){if(W!==z.const)yield x(_.Literal,z,U,W)}function*FJ(z,w,U,W){yield x(_.Never,z,U,W)}function*EJ(z,w,U,W){if(U2(z.not,w,U,W).next().done===!0)yield x(_.Not,z,U,W)}function*IJ(z,w,U,W){if(!c1(W))yield x(_.Null,z,U,W)}function*xJ(z,w,U,W){if(!I0.IsNumberLike(W))return yield x(_.Number,z,U,W);if(W0(z.exclusiveMaximum)&&!(W<z.exclusiveMaximum))yield x(_.NumberExclusiveMaximum,z,U,W);if(W0(z.exclusiveMinimum)&&!(W>z.exclusiveMinimum))yield x(_.NumberExclusiveMinimum,z,U,W);if(W0(z.maximum)&&!(W<=z.maximum))yield x(_.NumberMaximum,z,U,W);if(W0(z.minimum)&&!(W>=z.minimum))yield x(_.NumberMinimum,z,U,W);if(W0(z.multipleOf)&&W%z.multipleOf!==0)yield x(_.NumberMultipleOf,z,U,W)}function*VJ(z,w,U,W){if(!I0.IsObjectLike(W))return yield x(_.Object,z,U,W);if(W0(z.minProperties)&&!(Object.getOwnPropertyNames(W).length>=z.minProperties))yield x(_.ObjectMinProperties,z,U,W);if(W0(z.maxProperties)&&!(Object.getOwnPropertyNames(W).length<=z.maxProperties))yield x(_.ObjectMaxProperties,z,U,W);let X=Array.isArray(z.required)?z.required:[],Z=Object.getOwnPropertyNames(z.properties),$=Object.getOwnPropertyNames(W);for(let A of X){if($.includes(A))continue;yield x(_.ObjectRequiredProperty,z.properties[A],`${U}/${p1(A)}`,void 0)}if(z.additionalProperties===!1){for(let A of $)if(!Z.includes(A))yield x(_.ObjectAdditionalProperties,z,`${U}/${p1(A)}`,W[A])}if(typeof z.additionalProperties==="object")for(let A of $){if(Z.includes(A))continue;yield*U2(z.additionalProperties,w,`${U}/${p1(A)}`,W[A])}for(let A of Z){let Q=z.properties[A];if(z.required&&z.required.includes(A)){if(yield*U2(Q,w,`${U}/${p1(A)}`,W[A]),o1(z)&&!(A in W))yield x(_.ObjectRequiredProperty,Q,`${U}/${p1(A)}`,void 0)}else if(I0.IsExactOptionalProperty(W,A))yield*U2(Q,w,`${U}/${p1(A)}`,W[A])}}function*kJ(z,w,U,W){if(!J8(W))yield x(_.Promise,z,U,W)}function*TJ(z,w,U,W){if(!I0.IsRecordLike(W))return yield x(_.Object,z,U,W);if(W0(z.minProperties)&&!(Object.getOwnPropertyNames(W).length>=z.minProperties))yield x(_.ObjectMinProperties,z,U,W);if(W0(z.maxProperties)&&!(Object.getOwnPropertyNames(W).length<=z.maxProperties))yield x(_.ObjectMaxProperties,z,U,W);let[X,Z]=Object.entries(z.patternProperties)[0],$=new RegExp(X);for(let[A,Q]of Object.entries(W))if($.test(A))yield*U2(Z,w,`${U}/${p1(A)}`,Q);if(typeof z.additionalProperties==="object"){for(let[A,Q]of Object.entries(W))if(!$.test(A))yield*U2(z.additionalProperties,w,`${U}/${p1(A)}`,Q)}if(z.additionalProperties===!1)for(let[A,Q]of Object.entries(W)){if($.test(A))continue;return yield x(_.ObjectAdditionalProperties,z,`${U}/${p1(A)}`,Q)}}function*gJ(z,w,U,W){yield*U2(B0(z,w),w,U,W)}function*fJ(z,w,U,W){if(!A0(W))return yield x(_.String,z,U,W);if(W0(z.minLength)&&!(W.length>=z.minLength))yield x(_.StringMinLength,z,U,W);if(W0(z.maxLength)&&!(W.length<=z.maxLength))yield x(_.StringMaxLength,z,U,W);if(!new RegExp(z.source,z.flags).test(W))return yield x(_.RegExp,z,U,W)}function*dJ(z,w,U,W){if(!A0(W))return yield x(_.String,z,U,W);if(W0(z.minLength)&&!(W.length>=z.minLength))yield x(_.StringMinLength,z,U,W);if(W0(z.maxLength)&&!(W.length<=z.maxLength))yield x(_.StringMaxLength,z,U,W);if(A0(z.pattern)){if(!new RegExp(z.pattern).test(W))yield x(_.StringPattern,z,U,W)}if(A0(z.format)){if(!D0.Has(z.format))yield x(_.StringFormatUnknown,z,U,W);else if(!D0.Get(z.format)(W))yield x(_.StringFormat,z,U,W)}}function*hJ(z,w,U,W){if(!i1(W))yield x(_.Symbol,z,U,W)}function*cJ(z,w,U,W){if(!A0(W))return yield x(_.String,z,U,W);if(!new RegExp(z.pattern).test(W))yield x(_.StringPattern,z,U,W)}function*iJ(z,w,U,W){yield*U2(B0(z,w),w,U,W)}function*yJ(z,w,U,W){if(!m(W))return yield x(_.Tuple,z,U,W);if(z.items===void 0&&W.length!==0)return yield x(_.TupleLength,z,U,W);if(W.length!==z.maxItems)return yield x(_.TupleLength,z,U,W);if(!z.items)return;for(let X=0;X<z.items.length;X++)yield*U2(z.items[X],w,`${U}/${X}`,W[X])}function*vJ(z,w,U,W){if(!k0(W))yield x(_.Undefined,z,U,W)}function*nJ(z,w,U,W){if(s(z,w,W))return;let X=z.anyOf.map((Z)=>new h6(U2(Z,w,U,W)));yield x(_.Union,z,U,W,X)}function*uJ(z,w,U,W){if(!l6(W))return yield x(_.Uint8Array,z,U,W);if(W0(z.maxByteLength)&&!(W.length<=z.maxByteLength))yield x(_.Uint8ArrayMaxByteLength,z,U,W);if(W0(z.minByteLength)&&!(W.length>=z.minByteLength))yield x(_.Uint8ArrayMinByteLength,z,U,W)}function*mJ(z,w,U,W){}function*tJ(z,w,U,W){if(!I0.IsVoidLike(W))yield x(_.Void,z,U,W)}function*oJ(z,w,U,W){if(!p0.Get(z[H])(z,W))yield x(_.Kind,z,U,W)}function*U2(z,w,U,W){let X=W0(z.$id)?[...w,z]:w,Z=z;switch(Z[H]){case"Any":return yield*LJ(Z,X,U,W);case"Argument":return yield*GJ(Z,X,U,W);case"Array":return yield*NJ(Z,X,U,W);case"AsyncIterator":return yield*HJ(Z,X,U,W);case"BigInt":return yield*_J(Z,X,U,W);case"Boolean":return yield*SJ(Z,X,U,W);case"Constructor":return yield*DJ(Z,X,U,W);case"Date":return yield*PJ(Z,X,U,W);case"Function":return yield*OJ(Z,X,U,W);case"Import":return yield*RJ(Z,X,U,W);case"Integer":return yield*CJ(Z,X,U,W);case"Intersect":return yield*bJ(Z,X,U,W);case"Iterator":return yield*KJ(Z,X,U,W);case"Literal":return yield*jJ(Z,X,U,W);case"Never":return yield*FJ(Z,X,U,W);case"Not":return yield*EJ(Z,X,U,W);case"Null":return yield*IJ(Z,X,U,W);case"Number":return yield*xJ(Z,X,U,W);case"Object":return yield*VJ(Z,X,U,W);case"Promise":return yield*kJ(Z,X,U,W);case"Record":return yield*TJ(Z,X,U,W);case"Ref":return yield*gJ(Z,X,U,W);case"RegExp":return yield*fJ(Z,X,U,W);case"String":return yield*dJ(Z,X,U,W);case"Symbol":return yield*hJ(Z,X,U,W);case"TemplateLiteral":return yield*cJ(Z,X,U,W);case"This":return yield*iJ(Z,X,U,W);case"Tuple":return yield*yJ(Z,X,U,W);case"Undefined":return yield*vJ(Z,X,U,W);case"Union":return yield*nJ(Z,X,U,W);case"Uint8Array":return yield*uJ(Z,X,U,W);case"Unknown":return yield*mJ(Z,X,U,W);case"Void":return yield*tJ(Z,X,U,W);default:if(!p0.Has(Z[H]))throw new v7(z);return yield*oJ(Z,X,U,W)}}function k1(...z){let w=z.length===3?U2(z[0],z[1],"",z[2]):U2(z[0],[],"",z[1]);return new h6(w)}class i4 extends n{constructor(z,w,U){super("Unable to decode value as it does not match the expected schema");this.schema=z,this.value=w,this.error=U}}class T8 extends n{constructor(z,w,U,W){super(W instanceof Error?W.message:"Unknown error");this.schema=z,this.path=w,this.value=U,this.error=W}}function d0(z,w,U){try{return G0(z)?z[F0].Decode(U):U}catch(W){throw new T8(z,w,U,W)}}function pJ(z,w,U,W){return m(W)?d0(z,U,W.map((X,Z)=>N1(z.items,w,`${U}/${Z}`,X))):d0(z,U,W)}function lJ(z,w,U,W){if(!l(W)||k2(W))return d0(z,U,W);let X=D8(z),Z=X.map((J)=>J[0]),$={...W};for(let[J,G]of X)if(J in $)$[J]=N1(G,w,`${U}/${J}`,$[J]);if(!G0(z.unevaluatedProperties))return d0(z,U,$);let A=Object.getOwnPropertyNames($),Q=z.unevaluatedProperties,Y={...$};for(let J of A)if(!Z.includes(J))Y[J]=d0(Q,`${U}/${J}`,Y[J]);return d0(z,U,Y)}function sJ(z,w,U,W){let X=globalThis.Object.values(z.$defs),Z=z.$defs[z.$ref],$=N1(Z,[...w,...X],U,W);return d0(z,U,$)}function rJ(z,w,U,W){return d0(z,U,N1(z.not,w,U,W))}function aJ(z,w,U,W){if(!l(W))return d0(z,U,W);let X=O2(z),Z={...W};for(let Y of X){if(!u(Z,Y))continue;if(k0(Z[Y])&&(!n1(z.properties[Y])||I0.IsExactOptionalProperty(Z,Y)))continue;Z[Y]=N1(z.properties[Y],w,`${U}/${Y}`,Z[Y])}if(!f0(z.additionalProperties))return d0(z,U,Z);let $=Object.getOwnPropertyNames(Z),A=z.additionalProperties,Q={...Z};for(let Y of $)if(!X.includes(Y))Q[Y]=d0(A,`${U}/${Y}`,Q[Y]);return d0(z,U,Q)}function eJ(z,w,U,W){if(!l(W))return d0(z,U,W);let X=Object.getOwnPropertyNames(z.patternProperties)[0],Z=new RegExp(X),$={...W};for(let J of Object.getOwnPropertyNames(W))if(Z.test(J))$[J]=N1(z.patternProperties[X],w,`${U}/${J}`,$[J]);if(!f0(z.additionalProperties))return d0(z,U,$);let A=Object.getOwnPropertyNames($),Q=z.additionalProperties,Y={...$};for(let J of A)if(!Z.test(J))Y[J]=d0(Q,`${U}/${J}`,Y[J]);return d0(z,U,Y)}function zB(z,w,U,W){let X=B0(z,w);return d0(z,U,N1(X,w,U,W))}function wB(z,w,U,W){let X=B0(z,w);return d0(z,U,N1(X,w,U,W))}function UB(z,w,U,W){return m(W)&&m(z.items)?d0(z,U,z.items.map((X,Z)=>N1(X,w,`${U}/${Z}`,W[Z]))):d0(z,U,W)}function WB(z,w,U,W){for(let X of z.anyOf){if(!s(X,w,W))continue;let Z=N1(X,w,U,W);return d0(z,U,Z)}return d0(z,U,W)}function N1(z,w,U,W){let X=z2(z,w),Z=z;switch(z[H]){case"Array":return pJ(Z,X,U,W);case"Import":return sJ(Z,X,U,W);case"Intersect":return lJ(Z,X,U,W);case"Not":return rJ(Z,X,U,W);case"Object":return aJ(Z,X,U,W);case"Record":return eJ(Z,X,U,W);case"Ref":return zB(Z,X,U,W);case"Symbol":return d0(Z,U,W);case"This":return wB(Z,X,U,W);case"Tuple":return UB(Z,X,U,W);case"Union":return WB(Z,X,U,W);default:return d0(Z,U,W)}}function H4(z,w,U){return N1(z,w,"",U)}class y4 extends n{constructor(z,w,U){super("The encoded value does not match the expected schema");this.schema=z,this.value=w,this.error=U}}class n7 extends n{constructor(z,w,U,W){super(`${W instanceof Error?W.message:"Unknown error"}`);this.schema=z,this.path=w,this.value=U,this.error=W}}function $2(z,w,U){try{return G0(z)?z[F0].Encode(U):U}catch(W){throw new n7(z,w,U,W)}}function XB(z,w,U,W){let X=$2(z,U,W);return m(X)?X.map((Z,$)=>H1(z.items,w,`${U}/${$}`,Z)):X}function ZB(z,w,U,W){let X=globalThis.Object.values(z.$defs),Z=z.$defs[z.$ref],$=$2(z,U,W);return H1(Z,[...w,...X],U,$)}function $B(z,w,U,W){let X=$2(z,U,W);if(!l(W)||k2(W))return X;let Z=D8(z),$=Z.map((G)=>G[0]),A={...X};for(let[G,S]of Z)if(G in A)A[G]=H1(S,w,`${U}/${G}`,A[G]);if(!G0(z.unevaluatedProperties))return A;let Q=Object.getOwnPropertyNames(A),Y=z.unevaluatedProperties,J={...A};for(let G of Q)if(!$.includes(G))J[G]=$2(Y,`${U}/${G}`,J[G]);return J}function AB(z,w,U,W){return $2(z.not,U,$2(z,U,W))}function QB(z,w,U,W){let X=$2(z,U,W);if(!l(X))return X;let Z=O2(z),$={...X};for(let J of Z){if(!u($,J))continue;if(k0($[J])&&(!n1(z.properties[J])||I0.IsExactOptionalProperty($,J)))continue;$[J]=H1(z.properties[J],w,`${U}/${J}`,$[J])}if(!f0(z.additionalProperties))return $;let A=Object.getOwnPropertyNames($),Q=z.additionalProperties,Y={...$};for(let J of A)if(!Z.includes(J))Y[J]=$2(Q,`${U}/${J}`,Y[J]);return Y}function YB(z,w,U,W){let X=$2(z,U,W);if(!l(W))return X;let Z=Object.getOwnPropertyNames(z.patternProperties)[0],$=new RegExp(Z),A={...X};for(let G of Object.getOwnPropertyNames(W))if($.test(G))A[G]=H1(z.patternProperties[Z],w,`${U}/${G}`,A[G]);if(!f0(z.additionalProperties))return A;let Q=Object.getOwnPropertyNames(A),Y=z.additionalProperties,J={...A};for(let G of Q)if(!$.test(G))J[G]=$2(Y,`${U}/${G}`,J[G]);return J}function JB(z,w,U,W){let X=B0(z,w),Z=H1(X,w,U,W);return $2(z,U,Z)}function BB(z,w,U,W){let X=B0(z,w),Z=H1(X,w,U,W);return $2(z,U,Z)}function MB(z,w,U,W){let X=$2(z,U,W);return m(z.items)?z.items.map((Z,$)=>H1(Z,w,`${U}/${$}`,X[$])):[]}function qB(z,w,U,W){for(let X of z.anyOf){if(!s(X,w,W))continue;let Z=H1(X,w,U,W);return $2(z,U,Z)}for(let X of z.anyOf){let Z=H1(X,w,U,W);if(!s(z,w,Z))continue;return $2(z,U,Z)}return $2(z,U,W)}function H1(z,w,U,W){let X=z2(z,w),Z=z;switch(z[H]){case"Array":return XB(Z,X,U,W);case"Import":return ZB(Z,X,U,W);case"Intersect":return $B(Z,X,U,W);case"Not":return AB(Z,X,U,W);case"Object":return QB(Z,X,U,W);case"Record":return YB(Z,X,U,W);case"Ref":return JB(Z,X,U,W);case"This":return BB(Z,X,U,W);case"Tuple":return MB(Z,X,U,W);case"Union":return qB(Z,X,U,W);default:return $2(Z,U,W)}}function _4(z,w,U){return H1(z,w,"",U)}function LB(z,w){return G0(z)||r0(z.items,w)}function GB(z,w){return G0(z)||r0(z.items,w)}function NB(z,w){return G0(z)||r0(z.returns,w)||z.parameters.some((U)=>r0(U,w))}function HB(z,w){return G0(z)||r0(z.returns,w)||z.parameters.some((U)=>r0(U,w))}function _B(z,w){return G0(z)||G0(z.unevaluatedProperties)||z.allOf.some((U)=>r0(U,w))}function SB(z,w){let U=globalThis.Object.getOwnPropertyNames(z.$defs).reduce((X,Z)=>[...X,z.$defs[Z]],[]),W=z.$defs[z.$ref];return G0(z)||r0(W,[...U,...w])}function DB(z,w){return G0(z)||r0(z.items,w)}function PB(z,w){return G0(z)||r0(z.not,w)}function OB(z,w){return G0(z)||Object.values(z.properties).some((U)=>r0(U,w))||f0(z.additionalProperties)&&r0(z.additionalProperties,w)}function RB(z,w){return G0(z)||r0(z.item,w)}function CB(z,w){let U=Object.getOwnPropertyNames(z.patternProperties)[0],W=z.patternProperties[U];return G0(z)||r0(W,w)||f0(z.additionalProperties)&&G0(z.additionalProperties)}function bB(z,w){if(G0(z))return!0;return r0(B0(z,w),w)}function KB(z,w){if(G0(z))return!0;return r0(B0(z,w),w)}function jB(z,w){return G0(z)||!k0(z.items)&&z.items.some((U)=>r0(U,w))}function FB(z,w){return G0(z)||z.anyOf.some((U)=>r0(U,w))}function r0(z,w){let U=z2(z,w),W=z;if(z.$id&&jz.has(z.$id))return!1;if(z.$id)jz.add(z.$id);switch(z[H]){case"Array":return LB(W,U);case"AsyncIterator":return GB(W,U);case"Constructor":return NB(W,U);case"Function":return HB(W,U);case"Import":return SB(W,U);case"Intersect":return _B(W,U);case"Iterator":return DB(W,U);case"Not":return PB(W,U);case"Object":return OB(W,U);case"Promise":return RB(W,U);case"Record":return CB(W,U);case"Ref":return bB(W,U);case"This":return KB(W,U);case"Tuple":return jB(W,U);case"Union":return FB(W,U);default:return G0(z)}}var jz=new Set;function l1(z,w){return jz.clear(),r0(z,w)}class u7{constructor(z,w,U,W){this.schema=z,this.references=w,this.checkFunc=U,this.code=W,this.hasTransform=l1(z,w)}Code(){return this.code}Schema(){return this.schema}References(){return this.references}Errors(z){return k1(this.schema,this.references,z)}Check(z){return this.checkFunc(z)}Decode(z){if(!this.checkFunc(z))throw new i4(this.schema,z,this.Errors(z).First());return this.hasTransform?H4(this.schema,this.references,z):z}Encode(z){let w=this.hasTransform?_4(this.schema,this.references,z):z;if(!this.checkFunc(w))throw new y4(this.schema,z,this.Errors(z).First());return w}}var s1;(function(z){function w(Z){return Z===36}z.DollarSign=w;function U(Z){return Z===95}z.IsUnderscore=U;function W(Z){return Z>=65&&Z<=90||Z>=97&&Z<=122}z.IsAlpha=W;function X(Z){return Z>=48&&Z<=57}z.IsNumeric=X})(s1||(s1={}));var g8;(function(z){function w(Z){if(Z.length===0)return!1;return s1.IsNumeric(Z.charCodeAt(0))}function U(Z){if(w(Z))return!1;for(let $=0;$<Z.length;$++){let A=Z.charCodeAt($);if(!(s1.IsAlpha(A)||s1.IsNumeric(A)||s1.DollarSign(A)||s1.IsUnderscore(A)))return!1}return!0}function W(Z){return Z.replace(/'/g,"\\'")}function X(Z,$){return U($)?`${Z}.${$}`:`${Z}['${W($)}']`}z.Encode=X})(g8||(g8={}));var Fz;(function(z){function w(U){let W=[];for(let X=0;X<U.length;X++){let Z=U.charCodeAt(X);if(s1.IsNumeric(Z)||s1.IsAlpha(Z))W.push(U.charAt(X));else W.push(`_${Z}_`)}return W.join("").replace(/__/g,"_")}z.Encode=w})(Fz||(Fz={}));var Ez;(function(z){function w(U){return U.replace(/'/g,"\\'")}z.Escape=w})(Ez||(Ez={}));class m7 extends n{constructor(z){super("Unknown type");this.schema=z}}class Iz extends n{constructor(z){super("Preflight validation check failed to guard for the given schema");this.schema=z}}var c6;(function(z){function w($,A,Q){return I0.ExactOptionalPropertyTypes?`('${A}' in ${$} ? ${Q} : true)`:`(${g8.Encode($,A)} !== undefined ? ${Q} : true)`}z.IsExactOptionalProperty=w;function U($){return!I0.AllowArrayObject?`(typeof ${$} === 'object' && ${$} !== null && !Array.isArray(${$}))`:`(typeof ${$} === 'object' && ${$} !== null)`}z.IsObjectLike=U;function W($){return!I0.AllowArrayObject?`(typeof ${$} === 'object' && ${$} !== null && !Array.isArray(${$}) && !(${$} instanceof Date) && !(${$} instanceof Uint8Array))`:`(typeof ${$} === 'object' && ${$} !== null && !(${$} instanceof Date) && !(${$} instanceof Uint8Array))`}z.IsRecordLike=W;function X($){return I0.AllowNaN?`typeof ${$} === 'number'`:`Number.isFinite(${$})`}z.IsNumberLike=X;function Z($){return I0.AllowNullVoid?`(${$} === undefined || ${$} === null)`:`${$} === undefined`}z.IsVoidLike=Z})(c6||(c6={}));var N6;(function(z){function w(B){return B[H]==="Any"||B[H]==="Unknown"}function*U(B,K,L){yield"true"}function*W(B,K,L){yield"true"}function*X(B,K,L){yield`Array.isArray(${L})`;let[d,I]=[F("value","any"),F("acc","number")];if(v(B.maxItems))yield`${L}.length <= ${B.maxItems}`;if(v(B.minItems))yield`${L}.length >= ${B.minItems}`;let h=x2(B.items,K,"value");if(yield`${L}.every((${d}) => ${h})`,g0(B.contains)||v(B.minContains)||v(B.maxContains)){let C0=g0(B.contains)?B.contains:p(),_2=x2(C0,K,"value"),f1=v(B.minContains)?[`(count >= ${B.minContains})`]:[],Z1=v(B.maxContains)?[`(count <= ${B.maxContains})`]:[],j1=`const count = value.reduce((${I}, ${d}) => ${_2} ? acc + 1 : acc, 0)`,X8=["(count > 0)",...f1,...Z1].join(" && ");yield`((${d}) => { ${j1}; return ${X8}})(${L})`}if(B.uniqueItems===!0)yield`((${d}) => { const set = new Set(); for(const element of value) { const hashed = hash(element); if(set.has(hashed)) { return false } else { set.add(hashed) } } return true } )(${L})`}function*Z(B,K,L){yield`(typeof value === 'object' && Symbol.asyncIterator in ${L})`}function*$(B,K,L){if(yield`(typeof ${L} === 'bigint')`,X2(B.exclusiveMaximum))yield`${L} < BigInt(${B.exclusiveMaximum})`;if(X2(B.exclusiveMinimum))yield`${L} > BigInt(${B.exclusiveMinimum})`;if(X2(B.maximum))yield`${L} <= BigInt(${B.maximum})`;if(X2(B.minimum))yield`${L} >= BigInt(${B.minimum})`;if(X2(B.multipleOf))yield`(${L} % BigInt(${B.multipleOf})) === 0`}function*A(B,K,L){yield`(typeof ${L} === 'boolean')`}function*Q(B,K,L){yield*W1(B.returns,K,`${L}.prototype`)}function*Y(B,K,L){if(yield`(${L} instanceof Date) && Number.isFinite(${L}.getTime())`,v(B.exclusiveMaximumTimestamp))yield`${L}.getTime() < ${B.exclusiveMaximumTimestamp}`;if(v(B.exclusiveMinimumTimestamp))yield`${L}.getTime() > ${B.exclusiveMinimumTimestamp}`;if(v(B.maximumTimestamp))yield`${L}.getTime() <= ${B.maximumTimestamp}`;if(v(B.minimumTimestamp))yield`${L}.getTime() >= ${B.minimumTimestamp}`;if(v(B.multipleOfTimestamp))yield`(${L}.getTime() % ${B.multipleOfTimestamp}) === 0`}function*J(B,K,L){yield`(typeof ${L} === 'function')`}function*G(B,K,L){let d=globalThis.Object.getOwnPropertyNames(B.$defs).reduce((I,h)=>{return[...I,B.$defs[h]]},[]);yield*W1(o2(B.$ref),[...K,...d],L)}function*S(B,K,L){if(yield`Number.isInteger(${L})`,v(B.exclusiveMaximum))yield`${L} < ${B.exclusiveMaximum}`;if(v(B.exclusiveMinimum))yield`${L} > ${B.exclusiveMinimum}`;if(v(B.maximum))yield`${L} <= ${B.maximum}`;if(v(B.minimum))yield`${L} >= ${B.minimum}`;if(v(B.multipleOf))yield`(${L} % ${B.multipleOf}) === 0`}function*N(B,K,L){let d=B.allOf.map((I)=>x2(I,K,L)).join(" && ");if(B.unevaluatedProperties===!1){let I=Z6(`${new RegExp(t1(B))};`),h=`Object.getOwnPropertyNames(${L}).every(key => ${I}.test(key))`;yield`(${d} && ${h})`}else if(g0(B.unevaluatedProperties)){let I=Z6(`${new RegExp(t1(B))};`),h=`Object.getOwnPropertyNames(${L}).every(key => ${I}.test(key) || ${x2(B.unevaluatedProperties,K,`${L}[key]`)})`;yield`(${d} && ${h})`}else yield`(${d})`}function*O(B,K,L){yield`(typeof value === 'object' && Symbol.iterator in ${L})`}function*M(B,K,L){if(typeof B.const==="number"||typeof B.const==="boolean")yield`(${L} === ${B.const})`;else yield`(${L} === '${Ez.Escape(B.const)}')`}function*C(B,K,L){yield"false"}function*g(B,K,L){yield`(!${x2(B.not,K,L)})`}function*L0(B,K,L){yield`(${L} === null)`}function*a(B,K,L){if(yield c6.IsNumberLike(L),v(B.exclusiveMaximum))yield`${L} < ${B.exclusiveMaximum}`;if(v(B.exclusiveMinimum))yield`${L} > ${B.exclusiveMinimum}`;if(v(B.maximum))yield`${L} <= ${B.maximum}`;if(v(B.minimum))yield`${L} >= ${B.minimum}`;if(v(B.multipleOf))yield`(${L} % ${B.multipleOf}) === 0`}function*$0(B,K,L){if(yield c6.IsObjectLike(L),v(B.minProperties))yield`Object.getOwnPropertyNames(${L}).length >= ${B.minProperties}`;if(v(B.maxProperties))yield`Object.getOwnPropertyNames(${L}).length <= ${B.maxProperties}`;let d=Object.getOwnPropertyNames(B.properties);for(let I of d){let h=g8.Encode(L,I),C0=B.properties[I];if(B.required&&B.required.includes(I)){if(yield*W1(C0,K,h),o1(C0)||w(C0))yield`('${I}' in ${L})`}else{let _2=x2(C0,K,h);yield c6.IsExactOptionalProperty(L,I,_2)}}if(B.additionalProperties===!1)if(B.required&&B.required.length===d.length)yield`Object.getOwnPropertyNames(${L}).length === ${d.length}`;else{let I=`[${d.map((h)=>`'${h}'`).join(", ")}]`;yield`Object.getOwnPropertyNames(${L}).every(key => ${I}.includes(key))`}if(typeof B.additionalProperties==="object"){let I=x2(B.additionalProperties,K,`${L}[key]`),h=`[${d.map((C0)=>`'${C0}'`).join(", ")}]`;yield`(Object.getOwnPropertyNames(${L}).every(key => ${h}.includes(key) || ${I}))`}}function*K0(B,K,L){yield`${L} instanceof Promise`}function*f(B,K,L){if(yield c6.IsRecordLike(L),v(B.minProperties))yield`Object.getOwnPropertyNames(${L}).length >= ${B.minProperties}`;if(v(B.maxProperties))yield`Object.getOwnPropertyNames(${L}).length <= ${B.maxProperties}`;let[d,I]=Object.entries(B.patternProperties)[0],h=Z6(`${new RegExp(d)}`),C0=x2(I,K,"value"),_2=g0(B.additionalProperties)?x2(B.additionalProperties,K,L):B.additionalProperties===!1?"false":"true",f1=`(${h}.test(key) ? ${C0} : ${_2})`;yield`(Object.entries(${L}).every(([key, value]) => ${f1}))`}function*V(B,K,L){let d=B0(B,K);if(S0.functions.has(B.$ref))return yield`${X6(B.$ref)}(${L})`;yield*W1(d,K,L)}function*k(B,K,L){let d=Z6(`${new RegExp(B.source,B.flags)};`);if(yield`(typeof ${L} === 'string')`,v(B.maxLength))yield`${L}.length <= ${B.maxLength}`;if(v(B.minLength))yield`${L}.length >= ${B.minLength}`;yield`${d}.test(${L})`}function*j(B,K,L){if(yield`(typeof ${L} === 'string')`,v(B.maxLength))yield`${L}.length <= ${B.maxLength}`;if(v(B.minLength))yield`${L}.length >= ${B.minLength}`;if(B.pattern!==void 0)yield`${Z6(`${new RegExp(B.pattern)};`)}.test(${L})`;if(B.format!==void 0)yield`format('${B.format}', ${L})`}function*e(B,K,L){yield`(typeof ${L} === 'symbol')`}function*Y0(B,K,L){yield`(typeof ${L} === 'string')`,yield`${Z6(`${new RegExp(B.pattern)};`)}.test(${L})`}function*_0(B,K,L){yield`${X6(B.$ref)}(${L})`}function*h0(B,K,L){if(yield`Array.isArray(${L})`,B.items===void 0)return yield`${L}.length === 0`;yield`(${L}.length === ${B.maxItems})`;for(let d=0;d<B.items.length;d++)yield`${x2(B.items[d],K,`${L}[${d}]`)}`}function*U6(B,K,L){yield`${L} === undefined`}function*n0(B,K,L){yield`(${B.anyOf.map((I)=>x2(I,K,L)).join(" || ")})`}function*W6(B,K,L){if(yield`${L} instanceof Uint8Array`,v(B.maxByteLength))yield`(${L}.length <= ${B.maxByteLength})`;if(v(B.minByteLength))yield`(${L}.length >= ${B.minByteLength})`}function*I2(B,K,L){yield"true"}function*K6(B,K,L){yield c6.IsVoidLike(L)}function*r5(B,K,L){let d=S0.instances.size;S0.instances.set(d,B),yield`kind('${B[H]}', ${d}, ${L})`}function*W1(B,K,L,d=!0){let I=A0(B.$id)?[...K,B]:K,h=B;if(d&&A0(B.$id)){let C0=X6(B.$id);if(S0.functions.has(C0))return yield`${C0}(${L})`;else{S0.functions.set(C0,"<deferred>");let _2=X1(C0,B,K,"value",!1);return S0.functions.set(C0,_2),yield`${C0}(${L})`}}switch(h[H]){case"Any":return yield*U(h,I,L);case"Argument":return yield*W(h,I,L);case"Array":return yield*X(h,I,L);case"AsyncIterator":return yield*Z(h,I,L);case"BigInt":return yield*$(h,I,L);case"Boolean":return yield*A(h,I,L);case"Constructor":return yield*Q(h,I,L);case"Date":return yield*Y(h,I,L);case"Function":return yield*J(h,I,L);case"Import":return yield*G(h,I,L);case"Integer":return yield*S(h,I,L);case"Intersect":return yield*N(h,I,L);case"Iterator":return yield*O(h,I,L);case"Literal":return yield*M(h,I,L);case"Never":return yield*C(h,I,L);case"Not":return yield*g(h,I,L);case"Null":return yield*L0(h,I,L);case"Number":return yield*a(h,I,L);case"Object":return yield*$0(h,I,L);case"Promise":return yield*K0(h,I,L);case"Record":return yield*f(h,I,L);case"Ref":return yield*V(h,I,L);case"RegExp":return yield*k(h,I,L);case"String":return yield*j(h,I,L);case"Symbol":return yield*e(h,I,L);case"TemplateLiteral":return yield*Y0(h,I,L);case"This":return yield*_0(h,I,L);case"Tuple":return yield*h0(h,I,L);case"Undefined":return yield*U6(h,I,L);case"Union":return yield*n0(h,I,L);case"Uint8Array":return yield*W6(h,I,L);case"Unknown":return yield*I2(h,I,L);case"Void":return yield*K6(h,I,L);default:if(!p0.Has(h[H]))throw new m7(B);return yield*r5(h,I,L)}}let S0={language:"javascript",functions:new Map,variables:new Map,instances:new Map};function x2(B,K,L,d=!0){return`(${[...W1(B,K,L,d)].join(" && ")})`}function X6(B){return`check_${Fz.Encode(B)}`}function Z6(B){let K=`local_${S0.variables.size}`;return S0.variables.set(K,`const ${K} = ${B}`),K}function X1(B,K,L,d,I=!0){let[h,C0]=[`
|
|
3
|
+
`,(j1)=>"".padStart(j1," ")],_2=F("value","any"),f1=R("boolean"),Z1=[...W1(K,L,d,I)].map((j1)=>`${C0(4)}${j1}`).join(` &&${h}`);return`function ${B}(${_2})${f1} {${h}${C0(2)}return (${h}${Z1}${h}${C0(2)})
|
|
4
|
+
}`}function F(B,K){let L=S0.language==="typescript"?`: ${K}`:"";return`${B}${L}`}function R(B){return S0.language==="typescript"?`: ${B}`:""}function b(B,K,L){let d=X1("check",B,K,"value"),I=F("value","any"),h=R("boolean"),C0=[...S0.functions.values()],_2=[...S0.variables.values()],f1=A0(B.$id)?`return function check(${I})${h} {
|
|
5
|
+
return ${X6(B.$id)}(value)
|
|
6
|
+
}`:`return ${d}`;return[..._2,...C0,f1].join(`
|
|
7
|
+
`)}function c(...B){let K={language:"javascript"},[L,d,I]=B.length===2&&m(B[1])?[B[0],B[1],K]:B.length===2&&!m(B[1])?[B[0],[],B[1]]:B.length===3?[B[0],B[1],B[2]]:B.length===1?[B[0],[],K]:[null,[],K];if(S0.language=I.language,S0.variables.clear(),S0.functions.clear(),S0.instances.clear(),!g0(L))throw new Iz(L);for(let h of d)if(!g0(h))throw new Iz(h);return b(L,d,I)}z.Code=c;function t(B,K=[]){let L=c(B,K,{language:"javascript"}),d=globalThis.Function("kind","format","hash",L),I=new Map(S0.instances);function h(Z1,j1,X8){if(!p0.Has(Z1)||!I.has(j1))return!1;let NX=p0.Get(Z1),HX=I.get(j1);return NX(HX,X8)}function C0(Z1,j1){if(!D0.Has(Z1))return!1;return D0.Get(Z1)(j1)}function _2(Z1){return G6(Z1)}let f1=d(h,C0,_2);return new u7(B,K,f1,L)}z.Compile=t})(N6||(N6={}));var EB=function(z,w,U,W,X){if(W==="m")throw new TypeError("Private method is not writable");if(W==="a"&&!X)throw new TypeError("Private accessor was defined without a setter");if(typeof w==="function"?z!==w||!X:!w.has(z))throw new TypeError("Cannot write private member to an object whose class did not declare it");return W==="a"?X.call(z,U):X?X.value=U:w.set(z,U),U},o7=function(z,w,U,W){if(U==="a"&&!W)throw new TypeError("Private accessor was defined without a getter");if(typeof w==="function"?z!==w||!W:!w.has(z))throw new TypeError("Cannot read private member from an object whose class did not declare it");return U==="m"?W:U==="a"?W.call(z):W?W.value:w.get(z)},xz,f8,p7;class l7 extends n{constructor(z){let w=z.First();super(w===void 0?"Invalid Value":w.message);xz.add(this),f8.set(this,void 0),EB(this,f8,z,"f"),this.error=w}Errors(){return new h6(o7(this,xz,"m",p7).call(this))}}f8=new WeakMap,xz=new WeakSet,p7=function*z(){if(this.error)yield this.error;yield*o7(this,f8,"f")};function t7(z,w,U){if(s(z,w,U))return;throw new l7(k1(z,w,U))}function d8(...z){return z.length===3?t7(z[0],z[1],z[2]):t7(z[0],[],z[1])}function IB(z){let w={};for(let U of Object.getOwnPropertyNames(z))w[U]=M0(z[U]);for(let U of Object.getOwnPropertySymbols(z))w[U]=M0(z[U]);return w}function xB(z){return z.map((w)=>M0(w))}function VB(z){return z.slice()}function kB(z){return new Map(M0([...z.entries()]))}function TB(z){return new Set(M0([...z.entries()]))}function gB(z){return new Date(z.toISOString())}function fB(z){return z}function M0(z){if(m(z))return xB(z);if(G2(z))return gB(z);if(v2(z))return VB(z);if(qw(z))return kB(z);if(Lw(z))return TB(z);if(l(z))return IB(z);if(k2(z))return fB(z);throw new Error("ValueClone: Unable to clone value")}class s2 extends n{constructor(z,w){super(w);this.schema=z}}function q0(z){return $6(z)?z():M0(z)}function dB(z,w){if(u(z,"default"))return q0(z.default);else return{}}function hB(z,w){return{}}function cB(z,w){if(z.uniqueItems===!0&&!u(z,"default"))throw new s2(z,"Array with the uniqueItems constraint requires a default value");else if("contains"in z&&!u(z,"default"))throw new s2(z,"Array with the contains constraint requires a default value");else if("default"in z)return q0(z.default);else if(z.minItems!==void 0)return Array.from({length:z.minItems}).map((U)=>{return C2(z.items,w)});else return[]}function iB(z,w){if(u(z,"default"))return q0(z.default);else return async function*(){}()}function yB(z,w){if(u(z,"default"))return q0(z.default);else return BigInt(0)}function vB(z,w){if(u(z,"default"))return q0(z.default);else return!1}function nB(z,w){if(u(z,"default"))return q0(z.default);else{let U=C2(z.returns,w);if(typeof U==="object"&&!Array.isArray(U))return class{constructor(){for(let[W,X]of Object.entries(U)){let Z=this;Z[W]=X}}};else return class{}}}function uB(z,w){if(u(z,"default"))return q0(z.default);else if(z.minimumTimestamp!==void 0)return new Date(z.minimumTimestamp);else return new Date}function mB(z,w){if(u(z,"default"))return q0(z.default);else return()=>C2(z.returns,w)}function tB(z,w){let U=globalThis.Object.values(z.$defs),W=z.$defs[z.$ref];return C2(W,[...w,...U])}function oB(z,w){if(u(z,"default"))return q0(z.default);else if(z.minimum!==void 0)return z.minimum;else return 0}function pB(z,w){if(u(z,"default"))return q0(z.default);else{let U=z.allOf.reduce((W,X)=>{let Z=C2(X,w);return typeof Z==="object"?{...W,...Z}:Z},{});if(!s(z,w,U))throw new s2(z,"Intersect produced invalid value. Consider using a default value.");return U}}function lB(z,w){if(u(z,"default"))return q0(z.default);else return function*(){}()}function sB(z,w){if(u(z,"default"))return q0(z.default);else return z.const}function rB(z,w){if(u(z,"default"))return q0(z.default);else throw new s2(z,"Never types cannot be created. Consider using a default value.")}function aB(z,w){if(u(z,"default"))return q0(z.default);else throw new s2(z,"Not types must have a default value")}function eB(z,w){if(u(z,"default"))return q0(z.default);else return null}function zM(z,w){if(u(z,"default"))return q0(z.default);else if(z.minimum!==void 0)return z.minimum;else return 0}function wM(z,w){if(u(z,"default"))return q0(z.default);else{let U=new Set(z.required),W={};for(let[X,Z]of Object.entries(z.properties)){if(!U.has(X))continue;W[X]=C2(Z,w)}return W}}function UM(z,w){if(u(z,"default"))return q0(z.default);else return Promise.resolve(C2(z.item,w))}function WM(z,w){let[U,W]=Object.entries(z.patternProperties)[0];if(u(z,"default"))return q0(z.default);else if(!(U===I1||U===E1)){let X=U.slice(1,U.length-1).split("|"),Z={};for(let $ of X)Z[$]=C2(W,w);return Z}else return{}}function XM(z,w){if(u(z,"default"))return q0(z.default);else return C2(B0(z,w),w)}function ZM(z,w){if(u(z,"default"))return q0(z.default);else throw new s2(z,"RegExp types cannot be created. Consider using a default value.")}function $M(z,w){if(z.pattern!==void 0)if(!u(z,"default"))throw new s2(z,"String types with patterns must specify a default value");else return q0(z.default);else if(z.format!==void 0)if(!u(z,"default"))throw new s2(z,"String types with formats must specify a default value");else return q0(z.default);else if(u(z,"default"))return q0(z.default);else if(z.minLength!==void 0)return Array.from({length:z.minLength}).map(()=>" ").join("");else return""}function AM(z,w){if(u(z,"default"))return q0(z.default);else if("value"in z)return Symbol.for(z.value);else return Symbol()}function QM(z,w){if(u(z,"default"))return q0(z.default);if(!G8(z))throw new s2(z,"Can only create template literals that produce a finite variants. Consider using a default value.");return X4(z)[0]}function YM(z,w){if(s7++>HM)throw new s2(z,"Cannot create recursive type as it appears possibly infinite. Consider using a default.");if(u(z,"default"))return q0(z.default);else return C2(B0(z,w),w)}function JM(z,w){if(u(z,"default"))return q0(z.default);if(z.items===void 0)return[];else return Array.from({length:z.minItems}).map((U,W)=>C2(z.items[W],w))}function BM(z,w){if(u(z,"default"))return q0(z.default);else return}function MM(z,w){if(u(z,"default"))return q0(z.default);else if(z.anyOf.length===0)throw new Error("ValueCreate.Union: Cannot create Union with zero variants");else return C2(z.anyOf[0],w)}function qM(z,w){if(u(z,"default"))return q0(z.default);else if(z.minByteLength!==void 0)return new Uint8Array(z.minByteLength);else return new Uint8Array(0)}function LM(z,w){if(u(z,"default"))return q0(z.default);else return{}}function GM(z,w){if(u(z,"default"))return q0(z.default);else return}function NM(z,w){if(u(z,"default"))return q0(z.default);else throw new Error("User defined types must specify a default value")}function C2(z,w){let U=z2(z,w),W=z;switch(W[H]){case"Any":return dB(W,U);case"Argument":return hB(W,U);case"Array":return cB(W,U);case"AsyncIterator":return iB(W,U);case"BigInt":return yB(W,U);case"Boolean":return vB(W,U);case"Constructor":return nB(W,U);case"Date":return uB(W,U);case"Function":return mB(W,U);case"Import":return tB(W,U);case"Integer":return oB(W,U);case"Intersect":return pB(W,U);case"Iterator":return lB(W,U);case"Literal":return sB(W,U);case"Never":return rB(W,U);case"Not":return aB(W,U);case"Null":return eB(W,U);case"Number":return zM(W,U);case"Object":return wM(W,U);case"Promise":return UM(W,U);case"Record":return WM(W,U);case"Ref":return XM(W,U);case"RegExp":return ZM(W,U);case"String":return $M(W,U);case"Symbol":return AM(W,U);case"TemplateLiteral":return QM(W,U);case"This":return YM(W,U);case"Tuple":return JM(W,U);case"Undefined":return BM(W,U);case"Union":return MM(W,U);case"Uint8Array":return qM(W,U);case"Unknown":return LM(W,U);case"Void":return GM(W,U);default:if(!p0.Has(W[H]))throw new s2(W,"Unknown type");return NM(W,U)}}var HM=512,s7=0;function r2(...z){return s7=0,z.length===2?C2(z[0],z[1]):C2(z[0],[])}class Vz extends n{constructor(z,w){super(w);this.schema=z}}function _M(z,w,U){if(z[H]==="Object"&&typeof U==="object"&&!c1(U)){let W=z,X=Object.getOwnPropertyNames(U),Z=Object.entries(W.properties),[$,A]=[1/Z.length,Z.length];return Z.reduce((Q,[Y,J])=>{let G=J[H]==="Literal"&&J.const===U[Y]?A:0,S=s(J,w,U[Y])?$:0,N=X.includes(Y)?$:0;return Q+(G+S+N)},0)}else return s(z,w,U)?1:0}function SM(z,w,U){let W=z.anyOf.map(($)=>B0($,w)),[X,Z]=[W[0],0];for(let $ of W){let A=_M($,w,U);if(A>Z)X=$,Z=A}return X}function DM(z,w,U){if("default"in z)return typeof U==="function"?z.default:M0(z.default);else{let W=SM(z,w,U);return v4(W,w,U)}}function PM(z,w,U){return s(z,w,U)?M0(U):r2(z,w)}function OM(z,w,U){return s(z,w,U)?U:r2(z,w)}function RM(z,w,U){if(s(z,w,U))return M0(U);let W=m(U)?M0(U):r2(z,w),X=v(z.minItems)&&W.length<z.minItems?[...W,...Array.from({length:z.minItems-W.length},()=>null)]:W,$=(v(z.maxItems)&&X.length>z.maxItems?X.slice(0,z.maxItems):X).map((Q)=>_1(z.items,w,Q));if(z.uniqueItems!==!0)return $;let A=[...new Set($)];if(!s(z,w,A))throw new Vz(z,"Array cast produced invalid data due to uniqueItems constraint");return A}function CM(z,w,U){if(s(z,w,U))return r2(z,w);let W=new Set(z.returns.required||[]),X=function(){};for(let[Z,$]of Object.entries(z.returns.properties)){if(!W.has(Z)&&U.prototype[Z]===void 0)continue;X.prototype[Z]=_1($,w,U.prototype[Z])}return X}function bM(z,w,U){let W=globalThis.Object.values(z.$defs),X=z.$defs[z.$ref];return _1(X,[...w,...W],U)}function KM(z,w,U){let W=r2(z,w),X=l(W)&&l(U)?{...W,...U}:U;return s(z,w,X)?X:r2(z,w)}function jM(z,w,U){throw new Vz(z,"Never types cannot be cast")}function FM(z,w,U){if(s(z,w,U))return U;if(U===null||typeof U!=="object")return r2(z,w);let W=new Set(z.required||[]),X={};for(let[Z,$]of Object.entries(z.properties)){if(!W.has(Z)&&U[Z]===void 0)continue;X[Z]=_1($,w,U[Z])}if(typeof z.additionalProperties==="object"){let Z=Object.getOwnPropertyNames(z.properties);for(let $ of Object.getOwnPropertyNames(U)){if(Z.includes($))continue;X[$]=_1(z.additionalProperties,w,U[$])}}return X}function EM(z,w,U){if(s(z,w,U))return M0(U);if(U===null||typeof U!=="object"||Array.isArray(U)||U instanceof Date)return r2(z,w);let W=Object.getOwnPropertyNames(z.patternProperties)[0],X=z.patternProperties[W],Z={};for(let[$,A]of Object.entries(U))Z[$]=_1(X,w,A);return Z}function IM(z,w,U){return _1(B0(z,w),w,U)}function xM(z,w,U){return _1(B0(z,w),w,U)}function VM(z,w,U){if(s(z,w,U))return M0(U);if(!m(U))return r2(z,w);if(z.items===void 0)return[];return z.items.map((W,X)=>_1(W,w,U[X]))}function kM(z,w,U){return s(z,w,U)?M0(U):DM(z,w,U)}function _1(z,w,U){let W=A0(z.$id)?z2(z,w):w,X=z;switch(z[H]){case"Array":return RM(X,W,U);case"Constructor":return CM(X,W,U);case"Import":return bM(X,W,U);case"Intersect":return KM(X,W,U);case"Never":return jM(X,W,U);case"Object":return FM(X,W,U);case"Record":return EM(X,W,U);case"Ref":return IM(X,W,U);case"This":return xM(X,W,U);case"Tuple":return VM(X,W,U);case"Union":return kM(X,W,U);case"Date":case"Symbol":case"Uint8Array":return PM(z,w,U);default:return OM(X,W,U)}}function v4(...z){return z.length===3?_1(z[0],z[1],z[2]):_1(z[0],[],z[1])}function TM(z){return Q6(z)&&z[H]!=="Unsafe"}function gM(z,w,U){if(!m(U))return U;return U.map((W)=>b2(z.items,w,W))}function fM(z,w,U){let W=globalThis.Object.values(z.$defs),X=z.$defs[z.$ref];return b2(X,[...w,...W],U)}function dM(z,w,U){let W=z.unevaluatedProperties,Z=z.allOf.map((A)=>b2(A,w,M0(U))).reduce((A,Q)=>l(Q)?{...A,...Q}:Q,{});if(!l(U)||!l(Z)||!Q6(W))return Z;let $=O2(z);for(let A of Object.getOwnPropertyNames(U)){if($.includes(A))continue;if(s(W,w,U[A]))Z[A]=b2(W,w,U[A])}return Z}function hM(z,w,U){if(!l(U)||m(U))return U;let W=z.additionalProperties;for(let X of Object.getOwnPropertyNames(U)){if(u(z.properties,X)){U[X]=b2(z.properties[X],w,U[X]);continue}if(Q6(W)&&s(W,w,U[X])){U[X]=b2(W,w,U[X]);continue}delete U[X]}return U}function cM(z,w,U){if(!l(U))return U;let W=z.additionalProperties,X=Object.getOwnPropertyNames(U),[Z,$]=Object.entries(z.patternProperties)[0],A=new RegExp(Z);for(let Q of X){if(A.test(Q)){U[Q]=b2($,w,U[Q]);continue}if(Q6(W)&&s(W,w,U[Q])){U[Q]=b2(W,w,U[Q]);continue}delete U[Q]}return U}function iM(z,w,U){return b2(B0(z,w),w,U)}function yM(z,w,U){return b2(B0(z,w),w,U)}function vM(z,w,U){if(!m(U))return U;if(k0(z.items))return[];let W=Math.min(U.length,z.items.length);for(let X=0;X<W;X++)U[X]=b2(z.items[X],w,U[X]);return U.length>W?U.slice(0,W):U}function nM(z,w,U){for(let W of z.anyOf)if(TM(W)&&s(W,w,U))return b2(W,w,U);return U}function b2(z,w,U){let W=A0(z.$id)?z2(z,w):w,X=z;switch(X[H]){case"Array":return gM(X,W,U);case"Import":return fM(X,W,U);case"Intersect":return dM(X,W,U);case"Object":return hM(X,W,U);case"Record":return cM(X,W,U);case"Ref":return iM(X,W,U);case"This":return yM(X,W,U);case"Tuple":return vM(X,W,U);case"Union":return nM(X,W,U);default:return U}}function h8(...z){return z.length===3?b2(z[0],z[1],z[2]):b2(z[0],[],z[1])}function c8(z){return A0(z)&&!isNaN(z)&&!isNaN(parseFloat(z))}function uM(z){return X2(z)||F1(z)||v(z)}function n4(z){return z===!0||v(z)&&z===1||X2(z)&&z===BigInt("1")||A0(z)&&(z.toLowerCase()==="true"||z==="1")}function u4(z){return z===!1||v(z)&&(z===0||Object.is(z,-0))||X2(z)&&z===BigInt("0")||A0(z)&&(z.toLowerCase()==="false"||z==="0"||z==="-0")}function mM(z){return A0(z)&&/^(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)$/i.test(z)}function tM(z){return A0(z)&&/^(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)?$/i.test(z)}function oM(z){return A0(z)&&/^\d\d\d\d-[0-1]\d-[0-3]\dt(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)$/i.test(z)}function pM(z){return A0(z)&&/^\d\d\d\d-[0-1]\d-[0-3]\dt(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)?$/i.test(z)}function lM(z){return A0(z)&&/^\d\d\d\d-[0-1]\d-[0-3]\d$/i.test(z)}function sM(z,w){let U=a7(z);return U===w?U:z}function rM(z,w){let U=e7(z);return U===w?U:z}function aM(z,w){let U=r7(z);return U===w?U:z}function eM(z,w){return A0(z.const)?sM(w,z.const):v(z.const)?rM(w,z.const):F1(z.const)?aM(w,z.const):w}function r7(z){return n4(z)?!0:u4(z)?!1:z}function zq(z){let w=(U)=>U.split(".")[0];return c8(z)?BigInt(w(z)):v(z)?BigInt(Math.trunc(z)):u4(z)?BigInt(0):n4(z)?BigInt(1):z}function a7(z){return i1(z)&&z.description!==void 0?z.description.toString():uM(z)?z.toString():z}function e7(z){return c8(z)?parseFloat(z):n4(z)?1:u4(z)?0:z}function wq(z){return c8(z)?parseInt(z):v(z)?Math.trunc(z):n4(z)?1:u4(z)?0:z}function Uq(z){return A0(z)&&z.toLowerCase()==="null"?null:z}function Wq(z){return A0(z)&&z==="undefined"?void 0:z}function Xq(z){return G2(z)?z:v(z)?new Date(z):n4(z)?new Date(1):u4(z)?new Date(0):c8(z)?new Date(parseInt(z)):tM(z)?new Date(`1970-01-01T${z}.000Z`):mM(z)?new Date(`1970-01-01T${z}`):pM(z)?new Date(`${z}.000Z`):oM(z)?new Date(z):lM(z)?new Date(`${z}T00:00:00.000Z`):z}function Zq(z){return z}function $q(z,w,U){return(m(U)?U:[U]).map((X)=>S1(z.items,w,X))}function Aq(z,w,U){return zq(U)}function Qq(z,w,U){return r7(U)}function Yq(z,w,U){return Xq(U)}function Jq(z,w,U){let W=globalThis.Object.values(z.$defs),X=z.$defs[z.$ref];return S1(X,[...w,...W],U)}function Bq(z,w,U){return wq(U)}function Mq(z,w,U){return z.allOf.reduce((W,X)=>S1(X,w,W),U)}function qq(z,w,U){return eM(z,U)}function Lq(z,w,U){return Uq(U)}function Gq(z,w,U){return e7(U)}function Nq(z,w,U){if(!l(U))return U;for(let W of Object.getOwnPropertyNames(z.properties)){if(!u(U,W))continue;U[W]=S1(z.properties[W],w,U[W])}return U}function Hq(z,w,U){if(!l(U))return U;let X=Object.getOwnPropertyNames(z.patternProperties)[0],Z=z.patternProperties[X];for(let[$,A]of Object.entries(U))U[$]=S1(Z,w,A);return U}function _q(z,w,U){return S1(B0(z,w),w,U)}function Sq(z,w,U){return a7(U)}function Dq(z,w,U){return A0(U)||v(U)?Symbol(U):U}function Pq(z,w,U){return S1(B0(z,w),w,U)}function Oq(z,w,U){if(!(m(U)&&!k0(z.items)))return U;return U.map((X,Z)=>{return Z<z.items.length?S1(z.items[Z],w,X):X})}function Rq(z,w,U){return Wq(U)}function Cq(z,w,U){for(let W of z.anyOf){let X=S1(W,w,M0(U));if(!s(W,w,X))continue;return X}return U}function S1(z,w,U){let W=z2(z,w),X=z;switch(z[H]){case"Array":return $q(X,W,U);case"BigInt":return Aq(X,W,U);case"Boolean":return Qq(X,W,U);case"Date":return Yq(X,W,U);case"Import":return Jq(X,W,U);case"Integer":return Bq(X,W,U);case"Intersect":return Mq(X,W,U);case"Literal":return qq(X,W,U);case"Null":return Lq(X,W,U);case"Number":return Gq(X,W,U);case"Object":return Nq(X,W,U);case"Record":return Hq(X,W,U);case"Ref":return _q(X,W,U);case"String":return Sq(X,W,U);case"Symbol":return Dq(X,W,U);case"This":return Pq(X,W,U);case"Tuple":return Oq(X,W,U);case"Undefined":return Rq(X,W,U);case"Union":return Cq(X,W,U);default:return Zq(U)}}function i8(...z){return z.length===3?S1(z[0],z[1],z[2]):S1(z[0],[],z[1])}function zU(...z){let[w,U,W]=z.length===3?[z[0],z[1],z[2]]:[z[0],[],z[1]];if(!s(w,U,W))throw new i4(w,W,k1(w,U,W).First());return l1(w,U)?H4(w,U,W):W}function r1(z,w){let U=u(z,"default")?z.default:void 0,W=$6(U)?U():M0(U);return k0(w)?W:l(w)&&l(W)?Object.assign(W,w):w}function kz(z){return Q6(z)&&"default"in z}function bq(z,w,U){if(m(U)){for(let X=0;X<U.length;X++)U[X]=H2(z.items,w,U[X]);return U}let W=r1(z,U);if(!m(W))return W;for(let X=0;X<W.length;X++)W[X]=H2(z.items,w,W[X]);return W}function Kq(z,w,U){return G2(U)?U:r1(z,U)}function jq(z,w,U){let W=globalThis.Object.values(z.$defs),X=z.$defs[z.$ref];return H2(X,[...w,...W],U)}function Fq(z,w,U){let W=r1(z,U);return z.allOf.reduce((X,Z)=>{let $=H2(Z,w,W);return l($)?{...X,...$}:$},{})}function Eq(z,w,U){let W=r1(z,U);if(!l(W))return W;let X=Object.getOwnPropertyNames(z.properties);for(let Z of X){let $=H2(z.properties[Z],w,W[Z]);if(k0($))continue;W[Z]=H2(z.properties[Z],w,W[Z])}if(!kz(z.additionalProperties))return W;for(let Z of Object.getOwnPropertyNames(W)){if(X.includes(Z))continue;W[Z]=H2(z.additionalProperties,w,W[Z])}return W}function Iq(z,w,U){let W=r1(z,U);if(!l(W))return W;let X=z.additionalProperties,[Z,$]=Object.entries(z.patternProperties)[0],A=new RegExp(Z);for(let Q of Object.getOwnPropertyNames(W)){if(!(A.test(Q)&&kz($)))continue;W[Q]=H2($,w,W[Q])}if(!kz(X))return W;for(let Q of Object.getOwnPropertyNames(W)){if(A.test(Q))continue;W[Q]=H2(X,w,W[Q])}return W}function xq(z,w,U){return H2(B0(z,w),w,r1(z,U))}function Vq(z,w,U){return H2(B0(z,w),w,U)}function kq(z,w,U){let W=r1(z,U);if(!m(W)||k0(z.items))return W;let[X,Z]=[z.items,Math.max(z.items.length,W.length)];for(let $=0;$<Z;$++)if($<X.length)W[$]=H2(X[$],w,W[$]);return W}function Tq(z,w,U){let W=r1(z,U);for(let X of z.anyOf){let Z=H2(X,w,M0(W));if(s(X,w,Z))return Z}return W}function H2(z,w,U){let W=z2(z,w),X=z;switch(X[H]){case"Array":return bq(X,W,U);case"Date":return Kq(X,W,U);case"Import":return jq(X,W,U);case"Intersect":return Fq(X,W,U);case"Object":return Eq(X,W,U);case"Record":return Iq(X,W,U);case"Ref":return xq(X,W,U);case"This":return Vq(X,W,U);case"Tuple":return kq(X,W,U);case"Union":return Tq(X,W,U);default:return r1(X,U)}}function y8(...z){return z.length===3?H2(z[0],z[1],z[2]):H2(z[0],[],z[1])}var D1={};j6(D1,{ValuePointerRootSetError:()=>Tz,ValuePointerRootDeleteError:()=>gz,Set:()=>gq,Has:()=>dq,Get:()=>hq,Format:()=>m4,Delete:()=>fq});class Tz extends n{constructor(z,w,U){super("Cannot set root value");this.value=z,this.path=w,this.update=U}}class gz extends n{constructor(z,w){super("Cannot delete root value");this.value=z,this.path=w}}function wU(z){return z.indexOf("~")===-1?z:z.replace(/~1/g,"/").replace(/~0/g,"~")}function*m4(z){if(z==="")return;let[w,U]=[0,0];for(let W=0;W<z.length;W++)if(z.charAt(W)==="/")if(W===0)w=W+1;else U=W,yield wU(z.slice(w,U)),w=W+1;else U=W;yield wU(z.slice(w))}function gq(z,w,U){if(w==="")throw new Tz(z,w,U);let[W,X,Z]=[null,z,""];for(let $ of m4(w)){if(X[$]===void 0)X[$]={};W=X,X=X[$],Z=$}W[Z]=U}function fq(z,w){if(w==="")throw new gz(z,w);let[U,W,X]=[null,z,""];for(let Z of m4(w)){if(W[Z]===void 0||W[Z]===null)return;U=W,W=W[Z],X=Z}if(Array.isArray(U)){let Z=parseInt(X);U.splice(Z,1)}else delete U[X]}function dq(z,w){if(w==="")return!0;let[U,W,X]=[null,z,""];for(let Z of m4(w)){if(W[Z]===void 0)return!1;U=W,W=W[Z],X=Z}return Object.getOwnPropertyNames(U).includes(X)}function hq(z,w){if(w==="")return z;let U=z;for(let W of m4(w)){if(U[W]===void 0)return;U=U[W]}return U}function cq(z,w){if(!l(w))return!1;let U=[...Object.keys(z),...Object.getOwnPropertySymbols(z)],W=[...Object.keys(w),...Object.getOwnPropertySymbols(w)];if(U.length!==W.length)return!1;return U.every((X)=>i6(z[X],w[X]))}function iq(z,w){return G2(w)&&z.getTime()===w.getTime()}function yq(z,w){if(!m(w)||z.length!==w.length)return!1;return z.every((U,W)=>i6(U,w[W]))}function vq(z,w){if(!v2(w)||z.length!==w.length||Object.getPrototypeOf(z).constructor.name!==Object.getPrototypeOf(w).constructor.name)return!1;return z.every((U,W)=>i6(U,w[W]))}function nq(z,w){return z===w}function i6(z,w){if(G2(z))return iq(z,w);if(v2(z))return vq(z,w);if(m(z))return yq(z,w);if(l(z))return cq(z,w);if(k2(z))return nq(z,w);throw new Error("ValueEquals: Unable to compare value")}var uq=H0({type:Z0("insert"),path:N2(),value:q1()}),mq=H0({type:Z0("update"),path:N2(),value:q1()}),tq=H0({type:Z0("delete"),path:N2()}),WU=N0([uq,mq,tq]);class fz extends n{constructor(z,w){super(w);this.value=z}}function v8(z,w){return{type:"update",path:z,value:w}}function XU(z,w){return{type:"insert",path:z,value:w}}function ZU(z){return{type:"delete",path:z}}function UU(z){if(globalThis.Object.getOwnPropertySymbols(z).length>0)throw new fz(z,"Cannot diff objects with symbols")}function*oq(z,w,U){if(UU(w),UU(U),!Xz(U))return yield v8(z,U);let W=globalThis.Object.getOwnPropertyNames(w),X=globalThis.Object.getOwnPropertyNames(U);for(let Z of X){if(u(w,Z))continue;yield XU(`${z}/${Z}`,U[Z])}for(let Z of W){if(!u(U,Z))continue;if(i6(w,U))continue;yield*n8(`${z}/${Z}`,w[Z],U[Z])}for(let Z of W){if(u(U,Z))continue;yield ZU(`${z}/${Z}`)}}function*pq(z,w,U){if(!m(U))return yield v8(z,U);for(let W=0;W<Math.min(w.length,U.length);W++)yield*n8(`${z}/${W}`,w[W],U[W]);for(let W=0;W<U.length;W++){if(W<w.length)continue;yield XU(`${z}/${W}`,U[W])}for(let W=w.length-1;W>=0;W--){if(W<U.length)continue;yield ZU(`${z}/${W}`)}}function*lq(z,w,U){if(!v2(U)||w.length!==U.length||globalThis.Object.getPrototypeOf(w).constructor.name!==globalThis.Object.getPrototypeOf(U).constructor.name)return yield v8(z,U);for(let W=0;W<Math.min(w.length,U.length);W++)yield*n8(`${z}/${W}`,w[W],U[W])}function*sq(z,w,U){if(w===U)return;yield v8(z,U)}function*n8(z,w,U){if(Xz(w))return yield*oq(z,w,U);if(m(w))return yield*pq(z,w,U);if(v2(w))return yield*lq(z,w,U);if(k2(w))return yield*sq(z,w,U);throw new fz(w,"Unable to diff value")}function $U(z,w){return[...n8("",z,w)]}function rq(z){return z.length>0&&z[0].path===""&&z[0].type==="update"}function aq(z){return z.length===0}function AU(z,w){if(rq(w))return M0(w[0].value);if(aq(w))return M0(z);let U=M0(z);for(let W of w)switch(W.type){case"insert":{D1.Set(U,W.path,W.value);break}case"update":{D1.Set(U,W.path,W.value);break}case"delete":{D1.Delete(U,W.path);break}}return U}function QU(...z){let[w,U,W]=z.length===3?[z[0],z[1],z[2]]:[z[0],[],z[1]],X=l1(w,U)?_4(w,U,W):W;if(!s(w,U,X))throw new y4(w,X,k1(w,U,X).First());return X}function u8(z){return l(z)&&!m(z)}class dz extends n{constructor(z){super(z)}}function eq(z,w,U,W){if(!u8(U))D1.Set(z,w,M0(W));else{let X=Object.getOwnPropertyNames(U),Z=Object.getOwnPropertyNames(W);for(let $ of X)if(!Z.includes($))delete U[$];for(let $ of Z)if(!X.includes($))U[$]=null;for(let $ of Z)hz(z,`${w}/${$}`,U[$],W[$])}}function zL(z,w,U,W){if(!m(U))D1.Set(z,w,M0(W));else{for(let X=0;X<W.length;X++)hz(z,`${w}/${X}`,U[X],W[X]);U.splice(W.length)}}function wL(z,w,U,W){if(v2(U)&&U.length===W.length)for(let X=0;X<U.length;X++)U[X]=W[X];else D1.Set(z,w,M0(W))}function UL(z,w,U,W){if(U===W)return;D1.Set(z,w,W)}function hz(z,w,U,W){if(m(W))return zL(z,w,U,W);if(v2(W))return wL(z,w,U,W);if(u8(W))return eq(z,w,U,W);if(k2(W))return UL(z,w,U,W)}function YU(z){return v2(z)||k2(z)}function WL(z,w){return u8(z)&&m(w)||m(z)&&u8(w)}function JU(z,w){if(YU(z)||YU(w))throw new dz("Only object and array types can be mutated at the root level");if(WL(z,w))throw new dz("Cannot assign due type mismatch of assignable values");hz(z,"",z,w)}class iz extends n{constructor(z){super(z)}}var cz;(function(z){let w=new Map([["Assert",(Z,$,A)=>{return d8(Z,$,A),A}],["Cast",(Z,$,A)=>v4(Z,$,A)],["Clean",(Z,$,A)=>h8(Z,$,A)],["Clone",(Z,$,A)=>M0(A)],["Convert",(Z,$,A)=>i8(Z,$,A)],["Decode",(Z,$,A)=>l1(Z,$)?H4(Z,$,A):A],["Default",(Z,$,A)=>y8(Z,$,A)],["Encode",(Z,$,A)=>l1(Z,$)?_4(Z,$,A):A]]);function U(Z){w.delete(Z)}z.Delete=U;function W(Z,$){w.set(Z,$)}z.Set=W;function X(Z){return w.get(Z)}z.Get=X})(cz||(cz={}));var BU=["Clone","Clean","Default","Convert","Assert","Decode"];function XL(z,w,U,W){return z.reduce((X,Z)=>{let $=cz.Get(Z);if(k0($))throw new iz(`Unable to find Parse operation '${Z}'`);return $(w,U,X)},W)}function MU(...z){let[w,U,W,X]=z.length===4?[z[0],z[1],z[2],z[3]]:z.length===3?m(z[0])?[z[0],z[1],[],z[2]]:[BU,z[0],z[1],z[2]]:z.length===2?[BU,z[0],[],z[1]]:(()=>{throw new iz("Invalid Arguments")})();return XL(w,U,W,X)}var o={};j6(o,{ValueErrorIterator:()=>h6,Patch:()=>AU,Parse:()=>MU,Mutate:()=>JU,Hash:()=>G6,Errors:()=>k1,Equal:()=>i6,Encode:()=>QU,Edit:()=>WU,Diff:()=>$U,Default:()=>y8,Decode:()=>zU,Create:()=>r2,Convert:()=>i8,Clone:()=>M0,Clean:()=>h8,Check:()=>s,Cast:()=>v4,Assert:()=>d8});var w5=OX(NU(),1);var az={date:cU,time:pz(!0),"date-time":HU(!0),"iso-time":pz(!1),"iso-date-time":HU(!1),duration:/^P(?!$)((\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+S)?)?|(\d+W)?)$/,uri:CL,"uri-reference":/^(?:[a-z][a-z0-9+\-.]*:)?(?:\/?\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:]|%[0-9a-f]{2})*@)?(?:\[(?:(?:(?:(?:[0-9a-f]{1,4}:){6}|::(?:[0-9a-f]{1,4}:){5}|(?:[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){4}|(?:(?:[0-9a-f]{1,4}:){0,1}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){3}|(?:(?:[0-9a-f]{1,4}:){0,2}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){2}|(?:(?:[0-9a-f]{1,4}:){0,3}[0-9a-f]{1,4})?::[0-9a-f]{1,4}:|(?:(?:[0-9a-f]{1,4}:){0,4}[0-9a-f]{1,4})?::)(?:[0-9a-f]{1,4}:[0-9a-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?))|(?:(?:[0-9a-f]{1,4}:){0,5}[0-9a-f]{1,4})?::[0-9a-f]{1,4}|(?:(?:[0-9a-f]{1,4}:){0,6}[0-9a-f]{1,4})?::)|[Vv][0-9a-f]+\.[a-z0-9\-._~!$&'()*+,;=:]+)\]|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)|(?:[a-z0-9\-._~!$&'"()*+,;=]|%[0-9a-f]{2})*)(?::\d*)?(?:\/(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})*)*|\/(?:(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})*)*)?|(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})*)*)?(?:\?(?:[a-z0-9\-._~!$&'"()*+,;=:@/?]|%[0-9a-f]{2})*)?(?:#(?:[a-z0-9\-._~!$&'"()*+,;=:@/?]|%[0-9a-f]{2})*)?$/i,"uri-template":/^(?:(?:[^\x00-\x20"'<>%\\^`{|}]|%[0-9a-f]{2})|\{[+#./;?&=,!@|]?(?:[a-z0-9_]|%[0-9a-f]{2})+(?::[1-9][0-9]{0,3}|\*)?(?:,(?:[a-z0-9_]|%[0-9a-f]{2})+(?::[1-9][0-9]{0,3}|\*)?)*\})*$/i,url:/^(?:https?|ftp):\/\/(?:\S+(?::\S*)?@)?(?:(?!(?:10|127)(?:\.\d{1,3}){3})(?!(?:169\.254|192\.168)(?:\.\d{1,3}){2})(?!172\.(?:1[6-9]|2\d|3[0-1])(?:\.\d{1,3}){2})(?:[1-9]\d?|1\d\d|2[01]\d|22[0-3])(?:\.(?:1?\d{1,2}|2[0-4]\d|25[0-5])){2}(?:\.(?:[1-9]\d?|1\d\d|2[0-4]\d|25[0-4]))|(?:(?:[a-z0-9\u{00a1}-\u{ffff}]+-)*[a-z0-9\u{00a1}-\u{ffff}]+)(?:\.(?:[a-z0-9\u{00a1}-\u{ffff}]+-)*[a-z0-9\u{00a1}-\u{ffff}]+)*(?:\.(?:[a-z\u{00a1}-\u{ffff}]{2,})))(?::\d{2,5})?(?:\/[^\s]*)?$/iu,email:/^[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$/i,hostname:/^(?=.{1,253}\.?$)[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?(?:\.[a-z0-9](?:[-0-9a-z]{0,61}[0-9a-z])?)*\.?$/i,ipv4:/^(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)$/,ipv6:/^((([0-9a-f]{1,4}:){7}([0-9a-f]{1,4}|:))|(([0-9a-f]{1,4}:){6}(:[0-9a-f]{1,4}|((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9a-f]{1,4}:){5}(((:[0-9a-f]{1,4}){1,2})|:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9a-f]{1,4}:){4}(((:[0-9a-f]{1,4}){1,3})|((:[0-9a-f]{1,4})?:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){3}(((:[0-9a-f]{1,4}){1,4})|((:[0-9a-f]{1,4}){0,2}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){2}(((:[0-9a-f]{1,4}){1,5})|((:[0-9a-f]{1,4}){0,3}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){1}(((:[0-9a-f]{1,4}){1,6})|((:[0-9a-f]{1,4}){0,4}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(:(((:[0-9a-f]{1,4}){1,7})|((:[0-9a-f]{1,4}){0,5}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:)))$/i,regex:xL,uuid:/^(?:urn:uuid:)?[0-9a-f]{8}-(?:[0-9a-f]{4}-){3}[0-9a-f]{12}$/i,"json-pointer":/^(?:\/(?:[^~/]|~0|~1)*)*$/,"json-pointer-uri-fragment":/^#(?:\/(?:[a-z0-9_\-.!$&'()*+,;:=@]|%[0-9a-f]{2}|~0|~1)*)*$/i,"relative-json-pointer":/^(?:0|[1-9][0-9]*)(?:#|(?:\/(?:[^~/]|~0|~1)*)*)$/,byte:bL,int32:{type:"number",validate:FL},int64:{type:"number",validate:EL},float:{type:"number",validate:SU},double:{type:"number",validate:SU},password:!0,binary:!0};function HL(z){return z%4===0&&(z%100!==0||z%400===0)}var _L=/^(\d\d\d\d)-(\d\d)-(\d\d)$/,SL=[0,31,28,31,30,31,30,31,31,30,31,30,31];function cU(z){let w=_L.exec(z);if(!w)return!1;let U=+w[1],W=+w[2],X=+w[3];return W>=1&&W<=12&&X>=1&&X<=(W===2&&HL(U)?29:SL[W])}var DL=/^(\d\d):(\d\d):(\d\d(?:\.\d+)?)(z|([+-])(\d\d)(?::?(\d\d))?)?$/i;function pz(z){return function w(U){let W=DL.exec(U);if(!W)return!1;let X=+W[1],Z=+W[2],$=+W[3],A=W[4],Q=W[5]==="-"?-1:1,Y=+(W[6]||0),J=+(W[7]||0);if(Y>23||J>59||z&&!A)return!1;if(X<=23&&Z<=59&&$<60)return!0;let G=Z-J*Q,S=X-Y*Q-(G<0?1:0);return(S===23||S===-1)&&(G===59||G===-1)&&$<61}}var PL=/t|\s/i;function HU(z){let w=pz(z);return function U(W){let X=W.split(PL);return X.length===2&&cU(X[0])&&w(X[1])}}var OL=/\/|:/,RL=/^(?:[a-z][a-z0-9+\-.]*:)(?:\/?\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:]|%[0-9a-f]{2})*@)?(?:\[(?:(?:(?:(?:[0-9a-f]{1,4}:){6}|::(?:[0-9a-f]{1,4}:){5}|(?:[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){4}|(?:(?:[0-9a-f]{1,4}:){0,1}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){3}|(?:(?:[0-9a-f]{1,4}:){0,2}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){2}|(?:(?:[0-9a-f]{1,4}:){0,3}[0-9a-f]{1,4})?::[0-9a-f]{1,4}:|(?:(?:[0-9a-f]{1,4}:){0,4}[0-9a-f]{1,4})?::)(?:[0-9a-f]{1,4}:[0-9a-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?))|(?:(?:[0-9a-f]{1,4}:){0,5}[0-9a-f]{1,4})?::[0-9a-f]{1,4}|(?:(?:[0-9a-f]{1,4}:){0,6}[0-9a-f]{1,4})?::)|[Vv][0-9a-f]+\.[a-z0-9\-._~!$&'()*+,;=:]+)\]|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)|(?:[a-z0-9\-._~!$&'()*+,;=]|%[0-9a-f]{2})*)(?::\d*)?(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*|\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*)?|(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*)(?:\?(?:[a-z0-9\-._~!$&'()*+,;=:@/?]|%[0-9a-f]{2})*)?(?:#(?:[a-z0-9\-._~!$&'()*+,;=:@/?]|%[0-9a-f]{2})*)?$/i;function CL(z){return OL.test(z)&&RL.test(z)}var _U=/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/gm;function bL(z){return _U.lastIndex=0,_U.test(z)}var KL=-2147483648,jL=2147483647;function FL(z){return Number.isInteger(z)&&z<=jL&&z>=KL}function EL(z){return Number.isInteger(z)}function SU(){return!0}var IL=/[^\\]\\Z/;function xL(z){if(IL.test(z))return!1;try{return new RegExp(z),!0}catch(w){return!1}}var p8="toJSON"in new Headers,DU=(z,w)=>{let U=new URL(z);return U.pathname=w,U.toString()},VL=(z)=>typeof z==="function"&&/^\s*class\s+/.test(z.toString())||z.toString&&z.toString().startsWith("[object ")&&z.toString()!=="[object Object]"||z1(Object.getPrototypeOf(z)),yz=(z)=>z&&typeof z==="object"&&!Array.isArray(z),j2=(z,w,{skipKeys:U,override:W=!0}={})=>{if(!yz(z)||!yz(w))return z;for(let[X,Z]of Object.entries(w)){if(U?.includes(X))continue;if(!yz(Z)||!(X in z)||VL(Z)){if(W||!(X in z))z[X]=Z;continue}z[X]=j2(z[X],Z,{skipKeys:U,override:W})}return z},kL=(z,w)=>{let U=j2(Object.assign({},z),w,{skipKeys:["properties"]});if("properties"in U)delete U.properties;return U},y0=(z=[],w=[])=>{if(!z)return;if(!w)return z;let U=[],W=[];if(!Array.isArray(z))z=[z];if(!Array.isArray(w))w=[w];for(let X of z)if(U.push(X),X.checksum)W.push(X.checksum);for(let X of w)if(!W.includes(X.checksum))U.push(X);return U},TL=["start","request","parse","transform","resolve","beforeHandle","afterHandle","mapResponse","afterResponse","trace","error","stop","body","headers","params","query","response","type","detail"],gL=TL.reduce((z,w)=>(z[w]=!0,z),{}),iU=(z,w)=>{let U=(W)=>typeof W==="object"&&Object.keys(W).every(ez);if(U(z)&&U(w))return Object.assign(z,w);else if(z&&!U(z)&&U(w))return Object.assign({200:z},w);return w??z},t4=(z,w)=>{return{body:w?.body??z?.body,headers:w?.headers??z?.headers,params:w?.params??z?.params,query:w?.query??z?.query,cookie:w?.cookie??z?.cookie,response:iU(z?.response,w?.response)}},a1=(z,w)=>{let{resolve:U,...W}=z??{},{resolve:X,...Z}=w??{};return{...W,...Z,body:w?.body??z?.body,headers:w?.headers??z?.headers,params:w?.params??z?.params,query:w?.query??z?.query,cookie:w?.cookie??z?.cookie,response:iU(z?.response,w?.response),type:z?.type||w?.type,detail:j2(w?.detail??{},z?.detail??{}),parse:y0(z?.parse,w?.parse),transform:y0(z?.transform,w?.transform),beforeHandle:y0(y0(W2(U,"resolve"),z?.beforeHandle),y0(W2(X,"resolve"),w?.beforeHandle)),afterHandle:y0(z?.afterHandle,w?.afterHandle),mapResponse:y0(z?.mapResponse,w?.mapResponse),afterResponse:y0(z?.afterResponse,w?.afterResponse),trace:y0(z?.trace,w?.trace),error:y0(z?.error,w?.error)}},lz=(z,w,U=!0)=>{if(!Array.isArray(w))return w.original=z,A2(z,w,U);for(let W of w)W.original=z,z=A2(z,W,U);return z},A2=(z,w,U=!0)=>{if(!z)return z;if(w.untilObjectFound&&!U&&z.type==="object")return z;let W=w.from[H];if(z.oneOf){for(let $=0;$<z.oneOf.length;$++)z.oneOf[$]=A2(z.oneOf[$],w,U);return z}if(z.anyOf){for(let $=0;$<z.anyOf.length;$++)z.anyOf[$]=A2(z.anyOf[$],w,U);return z}if(z.allOf){for(let $=0;$<z.allOf.length;$++)z.allOf[$]=A2(z.allOf[$],w,U);return z}if(z.not)return A2(z.not,w,U);let X=U&&!!w.excludeRoot;if(z[H]===W){let{anyOf:$,oneOf:A,allOf:Q,not:Y,properties:J,items:G,...S}=z,N=w.to(S);if(!N)return z;let O,M=(C)=>{if(J&&C.type==="object"){let L0={};for(let[a,$0]of Object.entries(J))L0[a]=A2($0,w,!1);return{...S,...C,properties:L0}}if(G&&C.type==="array")return{...S,...C,items:A2(G,w,!1)};let g={...S,...C};if(delete g.required,J&&C.type==="string"&&C.format==="ObjectString"&&C.default==="{}")O=E.ObjectString(J,S),g.default=JSON.stringify(o.Create(E.Object(J))),g.properties=J;if(G&&C.type==="string"&&C.format==="ArrayString"&&C.default==="[]")O=E.ArrayString(G,S),g.default=JSON.stringify(o.Create(E.Array(G))),g.items=G;return g};if(X){if(J){let C={};for(let[g,L0]of Object.entries(J))C[g]=A2(L0,w,!1);return{...S,properties:C}}else if(G?.map)return{...S,items:G.map((C)=>A2(C,w,!1))};return S}if(N.anyOf)for(let C=0;C<N.anyOf.length;C++)N.anyOf[C]=M(N.anyOf[C]);else if(N.oneOf)for(let C=0;C<N.oneOf.length;C++)N.oneOf[C]=M(N.oneOf[C]);else if(N.allOf)for(let C=0;C<N.allOf.length;C++)N.allOf[C]=M(N.allOf[C]);else if(N.not)N.not=M(N.not);if(O)N[F0]=O[F0];if(N.anyOf||N.oneOf||N.allOf||N.not)return N;if(J){let C={};for(let[g,L0]of Object.entries(J))C[g]=A2(L0,w,!1);return{...S,...N,properties:C}}else if(G?.map)return{...S,...N,items:G.map((C)=>A2(C,w,!1))};return{...S,...N}}let Z=z?.properties;if(Z&&U&&w.rootOnly!==!0)for(let[$,A]of Object.entries(Z))switch(A[H]){case W:let{anyOf:Q,oneOf:Y,allOf:J,not:G,type:S,...N}=A,O=w.to(N);if(!O)return z;if(O.anyOf)for(let M=0;M<O.anyOf.length;M++)O.anyOf[M]={...N,...O.anyOf[M]};else if(O.oneOf)for(let M=0;M<O.oneOf.length;M++)O.oneOf[M]={...N,...O.oneOf[M]};else if(O.allOf)for(let M=0;M<O.allOf.length;M++)O.allOf[M]={...N,...O.allOf[M]};else if(O.not)O.not={...N,...O.not};Z[$]={...N,...A2(N,w,!1)};break;case"Object":case"Union":Z[$]=A2(A,w,!1);break;default:if(Array.isArray(A.items))for(let M=0;M<A.items.length;M++)A.items[M]=A2(A.items[M],w,!1);else if(A.anyOf||A.oneOf||A.allOf||A.not)Z[$]=A2(A,w,!1);else if(A.type==="array")A.items=A2(A.items,w,!1);break}return z},s4=(z)=>(w)=>{if(typeof w==="object")try{return o.Clean(z,structuredClone(w))}catch{try{return o.Clean(z,w)}catch{return w}}return w},F2=(z,{models:w={},dynamic:U=!1,modules:W,normalize:X=!1,additionalProperties:Z=!1,coerce:$=!1,additionalCoerce:A=[]}={modules:E.Module({})})=>{if(!z)return;let Q;if(typeof z!=="string")Q=z;else{let J=z.endsWith("[]"),G=J?z.substring(0,z.length-2):z;if(Q=W.Import(G)??w[G],J)Q=E.Array(Q)}if(!Q)return;if($||A)if($)Q=lz(Q,[{from:E.Ref(""),to:(J)=>W.Import(J.$ref)},{from:E.Number(),to:(J)=>E.Numeric(J),untilObjectFound:!0},{from:E.Boolean(),to:(J)=>E.BooleanString(J),untilObjectFound:!0},...Array.isArray(A)?A:[A]]);else Q=lz(Q,[{from:E.Ref(""),to:(J)=>W.Import(J.$ref)},...Array.isArray(A)?A:[A]]);if(Q.type==="object"&&"additionalProperties"in Q===!1)Q.additionalProperties=Z;if(U){let J={schema:Q,references:"",checkFunc:()=>{},code:"",Check:(G)=>o.Check(Q,G),Errors:(G)=>o.Errors(Q,G),Code:()=>"",Clean:s4(Q),Decode:(G)=>o.Decode(Q,G),Encode:(G)=>o.Encode(Q,G)};if(X&&Q.additionalProperties===!1)J.Clean=s4(Q);if(Q.config){if(J.config=Q.config,J?.schema?.config)delete J.schema.config}return J.parse=(G)=>{try{return J.Decode(G)}catch(S){throw[...J.Errors(G)].map(C1)}},J.safeParse=(G)=>{try{return{success:!0,data:J.Decode(G),error:null}}catch(S){let N=[...Y.Errors(G)].map(C1);return{success:!1,data:null,error:N[0]?.summary,errors:N}}},J}let Y=N6.Compile(Q,Object.values(w));if(Y.Clean=s4(Q),Q.config){if(Y.config=Q.config,Y?.schema?.config)delete Y.schema.config}return Y.parse=(J)=>{try{return Y.Decode(J)}catch(G){throw[...Y.Errors(J)].map(C1)}},Y.safeParse=(J)=>{try{return{success:!0,data:Y.Decode(J),error:null}}catch(G){let S=[...Y.Errors(J)].map(C1);return{success:!1,data:null,error:S[0]?.summary,errors:S}}},Y},PU=(z,{models:w={},modules:U,dynamic:W=!1,normalize:X=!1,additionalProperties:Z=!1})=>{if(!z)return;let $;if(typeof z!=="string")$=z;else{let J=z.endsWith("[]"),G=J?z.substring(0,z.length-2):z;if($=U.Import(G)??w[G],J)$=E.Array($)}if(!$)return;let A=(J,G)=>{if(W)return{schema:J,references:"",checkFunc:()=>{},code:"",Check:(N)=>o.Check(J,N),Errors:(N)=>o.Errors(J,N),Code:()=>"",Clean:s4(J),Decode:(N)=>o.Decode(J,N),Encode:(N)=>o.Encode(J,N)};let S=N6.Compile(J,G);if(X&&J.additionalProperties===!1)S.Clean=s4(J);return S},Q=Object.values(w);if(H in $){if("additionalProperties"in $===!1)$.additionalProperties=Z;return{200:A($,Q)}}let Y={};return Object.keys($).forEach((J)=>{let G=$[+J];if(typeof G==="string"){if(G in w){let S=w[G];S.type==="object"&&"additionalProperties"in S,Y[+J]=H in S?A(S,Q):S}return}if(G.type==="object"&&"additionalProperties"in G===!1)G.additionalProperties=Z;Y[+J]=H in G?A(G,Q):G}),Y},fL=typeof Bun!=="undefined",dL=fL&&typeof Bun.hash==="function",o4=(z)=>{if(dL)return Bun.hash(z);let w=9;for(let U=0;U<z.length;)w=Math.imul(w^z.charCodeAt(U++),387420489);return w=w^w>>>9},vz,y6=()=>{if(!vz)vz=[{from:E.Object({}),to:()=>E.ObjectString({}),excludeRoot:!0},{from:E.Array(E.Any()),to:()=>E.ArrayString(E.Any())}];return vz},nz,OU=()=>{if(!nz)nz=[{from:E.Number(),to:(z)=>E.Numeric(z),rootOnly:!0},{from:E.Boolean(),to:(z)=>E.BooleanString(z),rootOnly:!0}];return nz},yU=({validator:z,modules:w,defaultConfig:U={},config:W,dynamic:X,models:Z})=>{let $=F2(z,{modules:w,dynamic:X,models:Z,additionalProperties:!0,coerce:!0,additionalCoerce:y6()});if(z1(U))if($)$.config=kL($.config,W);else $=F2(E.Cookie({}),{modules:w,dynamic:X,models:Z,additionalProperties:!0}),$.config=U;return $},P1=(z,w)=>{if(!w)return;if(!Array.isArray(w)){let W=w;if(z&&!W.checksum)W.checksum=z;if(W.scope==="scoped")W.scope="local";return W}let U=[...w];for(let W of U){if(z&&!W.checksum)W.checksum=z;if(W.scope==="scoped")W.scope="local"}return U},RU=(z,w,U)=>{return{start:y0(z.start,P1(U,w?.start)),request:y0(z.request,P1(U,w?.request)),parse:y0(z.parse,P1(U,w?.parse)),transform:y0(z.transform,P1(U,w?.transform)),beforeHandle:y0(y0(W2(z.resolve,"resolve"),z.beforeHandle),P1(U,y0(W2(w?.resolve,"resolve"),w?.beforeHandle))),afterHandle:y0(z.afterHandle,P1(U,w?.afterHandle)),mapResponse:y0(z.mapResponse,P1(U,w?.mapResponse)),afterResponse:y0(z.afterResponse,P1(U,w?.afterResponse)),trace:y0(z.trace,P1(U,w?.trace)),error:y0(z.error,P1(U,w?.error)),stop:y0(z.stop,P1(U,w?.stop))}},hL=(z,w,{skipIfHasType:U=!1}={})=>{if(!z)return z;if(!Array.isArray(z)){if(U)z.scope??=w;else z.scope=w;return z}for(let W of z)if(U)W.scope??=w;else W.scope=w;return z},H6=(z)=>{if(!z)return z;if(!Array.isArray(z))switch(z.scope){case"global":case"scoped":return{...z};default:return{fn:z}}let w=[];for(let U of z)switch(U.scope){case"global":case"scoped":w.push({...U});break}return w},CU=(z)=>{return{...z,type:z?.type,detail:z?.detail,parse:H6(z?.parse),transform:H6(z?.transform),beforeHandle:H6(z?.beforeHandle),afterHandle:H6(z?.afterHandle),mapResponse:H6(z?.mapResponse),afterResponse:H6(z?.afterResponse),error:H6(z?.error),trace:H6(z?.trace)}},e8={Continue:100,"Switching Protocols":101,Processing:102,"Early Hints":103,OK:200,Created:201,Accepted:202,"Non-Authoritative Information":203,"No Content":204,"Reset Content":205,"Partial Content":206,"Multi-Status":207,"Already Reported":208,"Multiple Choices":300,"Moved Permanently":301,Found:302,"See Other":303,"Not Modified":304,"Temporary Redirect":307,"Permanent Redirect":308,"Bad Request":400,Unauthorized:401,"Payment Required":402,Forbidden:403,"Not Found":404,"Method Not Allowed":405,"Not Acceptable":406,"Proxy Authentication Required":407,"Request Timeout":408,Conflict:409,Gone:410,"Length Required":411,"Precondition Failed":412,"Payload Too Large":413,"URI Too Long":414,"Unsupported Media Type":415,"Range Not Satisfiable":416,"Expectation Failed":417,"I'm a teapot":418,"Misdirected Request":421,"Unprocessable Content":422,Locked:423,"Failed Dependency":424,"Too Early":425,"Upgrade Required":426,"Precondition Required":428,"Too Many Requests":429,"Request Header Fields Too Large":431,"Unavailable For Legal Reasons":451,"Internal Server Error":500,"Not Implemented":501,"Bad Gateway":502,"Service Unavailable":503,"Gateway Timeout":504,"HTTP Version Not Supported":505,"Variant Also Negotiates":506,"Insufficient Storage":507,"Loop Detected":508,"Not Extended":510,"Network Authentication Required":511},bU=Object.fromEntries(Object.entries(e8).map(([z,w])=>[w,z]));function cL(z){let w=z;while(w.endsWith("="))w=w.slice(0,-1);return w}var KU=new TextEncoder,l8=async(z,w)=>{if(typeof z!=="string")throw new TypeError("Cookie value must be provided as a string.");if(w===null)throw new TypeError("Secret key must be provided.");let U=await crypto.subtle.importKey("raw",KU.encode(w),{name:"HMAC",hash:"SHA-256"},!1,["sign"]),W=await crypto.subtle.sign("HMAC",U,KU.encode(z));return z+"."+cL(Buffer.from(W).toString("base64"))},jU=async(z,w)=>{if(typeof z!=="string")throw new TypeError("Signed cookie string must be provided.");if(w===null)throw new TypeError("Secret key must be provided.");let U=z.slice(0,z.lastIndexOf("."));return await l8(U,w)===z?U:!1},iL=(z,w,U)=>{if(!z||typeof z!=="object"||!w)return;for(let[W,X]of Object.entries(w)){if(W in gL||!(W in z))continue;let Z=z[W];if(typeof Z==="function"){let $=Z(X);if(typeof $==="object")for(let[A,Q]of Object.entries($))U(A)({fn:Q})}delete w[W]}},yL=({globalHook:z,localHook:w})=>(U)=>(W,X)=>{if(typeof W==="function")W={fn:W};if(U==="resolve")W={...W,subType:"resolve"};if("fn"in W||Array.isArray(W)){if(!w[U])w[U]=[];if(typeof w[U]==="function")w[U]=[w[U]];if(Array.isArray(W))w[U]=w[U].concat(W);else w[U].push(W);return}let{insert:Z="after",stack:$="local"}=W;if(typeof X==="function")X={fn:X};if($==="global")if(!Array.isArray(X))if(Z==="before")z[U].unshift(X);else z[U].push(X);else if(Z==="before")z[U]=X.concat(z[U]);else z[U]=z[U].concat(X);else{if(!w[U])w[U]=[];if(typeof w[U]==="function")w[U]=[w[U]];if(!Array.isArray(X))if(Z==="before")w[U].unshift(X);else w[U].push(X);else if(Z==="before")w[U]=X.concat(w[U]);else w[U]=w[U].concat(X)}},vL=(z)=>{if(typeof z==="number")return z;if(z.length<16){if(z.trim().length===0)return null;let w=Number(z);if(Number.isNaN(w))return null;return w}if(z.length===16){if(z.trim().length===0)return null;let w=Number(z);if(Number.isNaN(w)||w.toString()!==z)return null;return w}return null},ez=(z)=>vL(z)!==null;class vU{onError;root=null;promises=[];constructor(z=console.error){this.onError=z}get size(){return this.promises.length}add(z){return this.promises.push(z),this.root||=this.drain(),z}async drain(){while(this.promises.length>0){try{await this.promises[0]}catch(z){this.onError(z)}this.promises.shift()}this.root=null}then(z,w){return(this.root??Promise.resolve()).then(z,w)}}var W2=(z,w)=>{if(!z)return z;if(!Array.isArray(z)){if(typeof z==="function"||typeof z==="string")return w?{fn:z,subType:w}:{fn:z};else if("fn"in z)return z}let U=[];for(let W of z)if(typeof W==="function"||typeof W==="string")U.push(w?{fn:W,subType:w}:{fn:W});else if("fn"in W)U.push(W);return U},nL=(z)=>{return{...z,start:W2(z?.start),request:W2(z?.request),parse:W2(z?.parse),transform:W2(z?.transform),beforeHandle:W2(z?.beforeHandle),afterHandle:W2(z?.afterHandle),mapResponse:W2(z?.mapResponse),afterResponse:W2(z?.afterResponse),trace:W2(z?.trace),error:W2(z?.error),stop:W2(z?.stop)}},FU=(z)=>{let w={};if(z.start?.map)w.start=z.start.map((U)=>U.fn);if(z.request?.map)w.request=z.request.map((U)=>U.fn);if(z.parse?.map)w.parse=z.parse.map((U)=>U.fn);if(z.transform?.map)w.transform=z.transform.map((U)=>U.fn);if(z.beforeHandle?.map)w.beforeHandle=z.beforeHandle.map((U)=>U.fn);if(z.afterHandle?.map)w.afterHandle=z.afterHandle.map((U)=>U.fn);if(z.mapResponse?.map)w.mapResponse=z.mapResponse.map((U)=>U.fn);if(z.afterResponse?.map)w.afterResponse=z.afterResponse.map((U)=>U.fn);if(z.trace?.map)w.trace=z.trace.map((U)=>U.fn);if(z.error?.map)w.error=z.error.map((U)=>U.fn);if(z.stop?.map)w.stop=z.stop.map((U)=>U.fn);return w},uz=(z)=>({body:z.body,cookie:z.cookie,headers:z.headers,query:z.query,set:z.set,server:z.server,request:z.request,route:z.route}),nU=(z,w=302)=>Response.redirect(z,w),AI=Symbol("ElysiaFormData"),z5=Symbol("ElysiaRequestId");var uU=()=>{let z=crypto.randomUUID();return z.slice(0,8)+z.slice(24,32)},EU=(z)=>{let w=[];for(let U=0;U<z.length;U++){let W=z[U];if(W.checksum){if(w.includes(W.checksum))z.splice(U,1),U--;w.push(W.checksum)}}return z},L2=(z,w="scoped")=>{if(!z)return;if(w==="scoped"){for(let U of z)if("scope"in U&&U.scope==="local")U.scope="scoped";return}for(let U of z)if("scope"in U)U.scope="global"},S4=(z)=>{if(z.charCodeAt(z.length-1)===47)return z.slice(0,z.length-1);return z+"/"},z1=(z)=>{if(!z)return!1;for(let w in z)return!0;return!1},O1=(z)=>{if(Array.isArray(z))return z.length===0;return!z},mz=(z)=>{let w={...z};if(O1(z.afterHandle))delete w.afterHandle;if(O1(z.afterResponse))delete w.afterResponse;if(O1(z.beforeHandle))delete w.beforeHandle;if(O1(z.error))delete w.error;if(O1(z.mapResponse))delete w.mapResponse;if(O1(z.parse))delete w.parse;if(O1(z.request))delete w.request;if(O1(z.start))delete w.start;if(O1(z.stop))delete w.stop;if(O1(z.trace))delete w.trace;if(O1(z.transform))delete w.transform;if(!w.type)delete w.type;if(w.detail&&!Object.keys(w.detail).length)delete w.detail;if(!w.body)delete w.body;if(!w.cookie)delete w.cookie;if(!w.headers)delete w.headers;if(!w.query)delete w.query;if(!w.params)delete w.params;if(!w.response)delete w.response;return w},p4=(z,{dynamic:w=!1}={})=>{let U=encodeURIComponent(z).replace(/%2F/g,"/");if(w)U=U.replace(/%3A/g,":").replace(/%3F/g,"?");return U},IU=typeof Bun!=="undefined"?Bun.env:typeof process!=="undefined"?process?.env:void 0,s8=Symbol("ElysiaErrorCode"),r8=(IU?.NODE_ENV??IU?.ENV)==="production";class b1{code;response;constructor(z,w){let U=w??(z in bU?bU[z]:z);this.code=e8[z]??z,this.response=U}}var mU=(z,w)=>new b1(z,w);class tU extends Error{code="INTERNAL_SERVER_ERROR";status=500;constructor(z){super(z??"INTERNAL_SERVER_ERROR")}}class zw extends Error{code="NOT_FOUND";status=404;constructor(z){super(z??"NOT_FOUND")}}class oU extends Error{code="PARSE";status=400;constructor(){super("Bad Request")}}class sz extends Error{key;code="INVALID_COOKIE_SIGNATURE";status=400;constructor(z,w){super(w??`"${z}" has invalid cookie signature`);this.key=z}}var C1=(z)=>{if(!z)return{summary:void 0};let{message:w,path:U,value:W,type:X}=z,Z=U.slice(1).replaceAll("/","."),$=U==="";switch(X){case 42:return{...z,summary:$?"Value should not be provided":`Property '${Z}' should not be provided`};case 45:return{...z,summary:$?"Value is missing":`Property '${Z}' is missing`};case 50:let A=w.indexOf("'"),Q=w.slice(A+1,w.indexOf("'",A+1));return{...z,summary:$?"Value should be an email":`Property '${Z}' should be ${Q}`};case 54:return{...z,summary:`${w.slice(0,9)} property '${Z}' to be ${w.slice(8)} but found: ${W}`};case 62:let Y=z.schema.anyOf.map((J)=>`'${J?.format??J.type}'`).join(", ");return{...z,summary:$?`Value should be one of ${Y}`:`Property '${Z}' should be one of: ${Y}`};default:return{summary:w,...z}}};class r extends Error{type;validator;value;code="VALIDATION";status=422;constructor(z,w,U){if(U&&typeof U==="object"&&U instanceof b1)U=U.response;let W=r8?void 0:("Errors"in w)?w.Errors(U).First():o.Errors(w,U).First(),X=W?.schema?.message||W?.schema?.error!==void 0?typeof W.schema.error==="function"?W.schema.error({type:z,validator:w,value:U,get errors(){return[...w.Errors(U)].map(C1)}}):W.schema.error:void 0,Z=W?.path||"root",$="";if(X!==void 0)$=typeof X==="object"?JSON.stringify(X):X+"";else if(r8)$=JSON.stringify({type:"validation",on:z,summary:C1(W).summary,message:W?.message,found:U});else{let A=w?.schema??w,Q="Errors"in w?[...w.Errors(U)].map(C1):[...o.Errors(w,U)].map(C1),Y;try{Y=o.Create(A)}catch(J){Y={type:"Could not create expected value",message:J?.message,error:J}}$=JSON.stringify({type:"validation",on:z,summary:C1(W).summary,property:Z,message:W?.message,expected:Y,found:U,errors:Q},null,2)}super($);this.type=z,this.validator=w,this.value=U,Object.setPrototypeOf(this,r.prototype)}get all(){return"Errors"in this.validator?[...this.validator.Errors(this.value)].map(C1):[...o.Errors(this.validator,this.value)].map(C1)}static simplifyModel(z){let w="schema"in z?z.schema:z;try{return o.Create(w)}catch{return w}}get model(){return r.simplifyModel(this.validator)}toResponse(z){return new Response(this.message,{status:400,headers:{...z,"content-type":"application/json"}})}}var pU=/(\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d:[0-5]\d\.\d+([+-][0-2]\d:[0-5]\d|Z))|(\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d:[0-5]\d([+-][0-2]\d:[0-5]\d|Z))|(\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d([+-][0-2]\d:[0-5]\d|Z))/,lU=/(?:Sun|Mon|Tue|Wed|Thu|Fri|Sat)\s(?:Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)\s\d{2}\s\d{4}\s\d{2}:\d{2}:\d{2}\sGMT(?:\+|-)\d{4}\s\([^)]+\)/,sU=/^(?:(?:(?:(?:0?[1-9]|[12][0-9]|3[01])[/\s-](?:0?[1-9]|1[0-2])[/\s-](?:19|20)\d{2})|(?:(?:19|20)\d{2}[/\s-](?:0?[1-9]|1[0-2])[/\s-](?:0?[1-9]|[12][0-9]|3[01]))))(?:\s(?:1[012]|0?[1-9]):[0-5][0-9](?::[0-5][0-9])?(?:\s[AP]M)?)?$/,uL=az.date,mL=az["date-time"];if(!D0.Has("date"))D0.Set("date",(z)=>{let w=z.replace(/"/g,"");if(pU.test(w)||lU.test(w)||sU.test(w)||uL(w)){let U=new Date(w);if(!Number.isNaN(U.getTime()))return!0}return!1});if(!D0.Has("date-time"))D0.Set("date-time",(z)=>{let w=z.replace(/"/g,"");if(pU.test(w)||lU.test(w)||sU.test(w)||mL(w)){let U=new Date(w);if(!Number.isNaN(U.getTime()))return!0}return!1});Object.entries(az).forEach((z)=>{let[w,U]=z;if(!D0.Has(w)){if(U instanceof RegExp)D0.Set(w,(W)=>U.test(W));else if(typeof U==="function")D0.Set(w,U)}});var E=Object.assign({},L6),xU=(z)=>{if(typeof z==="string")switch(z.slice(-1)){case"k":return+z.slice(0,z.length-1)*1024;case"m":return+z.slice(0,z.length-1)*1048576;default:return+z}return z},VU=(z,w)=>{if(z.startsWith(w))return!0;return w.charCodeAt(w.length-1)===42&&w.charCodeAt(w.length-2)===47&&z.startsWith(w.slice(0,-1))},rz=(z,w)=>{if(!(w instanceof Blob))return!1;if(z.minSize&&w.size<xU(z.minSize))return!1;if(z.maxSize&&w.size>xU(z.maxSize))return!1;if(z.extension){if(typeof z.extension==="string")return VU(w.type,z.extension);for(let U=0;U<z.extension.length;U++)if(VU(w.type,z.extension[U]))return!0;return!1}return!0},tL=rU("File",rz),oL=rU("Files",(z,w)=>{if(!Array.isArray(w))return rz(z,w);if(z.minItems&&w.length<z.minItems)return!1;if(z.maxItems&&w.length>z.maxItems)return!1;for(let U=0;U<w.length;U++)if(!rz(z,w[U]))return!1;return!0});if(!D0.Has("numeric"))D0.Set("numeric",(z)=>!!z&&!isNaN(+z));if(!D0.Has("integer"))D0.Set("integer",(z)=>!!z&&Number.isInteger(+z));if(!D0.Has("boolean"))D0.Set("boolean",(z)=>z==="true"||z==="false");if(!D0.Has("ObjectString"))D0.Set("ObjectString",(z)=>{let w=z.charCodeAt(0);if(w===9||w===10||w===32)w=z.trimStart().charCodeAt(0);if(w!==123&&w!==91)return!1;try{return JSON.parse(z),!0}catch{return!1}});if(!D0.Has("ArrayString"))D0.Set("ArrayString",(z)=>{let w=z.charCodeAt(0);if(w===9||w===10||w===32)w=z.trimStart().charCodeAt(0);if(w!==123&&w!==91)return!1;try{return JSON.parse(z),!0}catch{return!1}});if(!p0.Has("UnionEnum"))p0.Set("UnionEnum",(z,w)=>{return(typeof w==="number"||typeof w==="string"||w===null)&&z.enum.includes(w)});var w1={Numeric:(z)=>{let w=L6.Number(z);return E.Transform(E.Union([E.String({format:"numeric",default:0}),E.Number(z)],z)).Decode((U)=>{let W=+U;if(isNaN(W))return U;if(z&&!o.Check(w,W))throw new r("property",w,W);return W}).Encode((U)=>U)},Integer:(z)=>{let w=L6.Integer(z);return E.Transform(E.Union([E.String({format:"integer",default:0}),L6.Integer(z)],z)).Decode((U)=>{let W=+U;if(!o.Check(w,W))throw new r("property",w,W);return W}).Encode((U)=>U)},Date:(z)=>{let w=L6.Date(z),U=z?.default?new Date(z.default):void 0;return E.Transform(E.Union([L6.Date(z),E.String({format:"date",default:U?.toISOString()}),E.String({format:"date-time",default:U?.toISOString()}),E.Number({default:U?.getTime()})],z)).Decode((W)=>{if(typeof W==="number"){let Z=new Date(W);if(!o.Check(w,Z))throw new r("property",w,Z);return Z}if(W instanceof Date)return W;let X=new Date(W);if(!X||isNaN(X.getTime()))throw new r("property",w,X);if(!o.Check(w,X))throw new r("property",w,X);return X}).Encode((W)=>W.toISOString())},BooleanString:(z)=>{let w=L6.Boolean(z);return E.Transform(E.Union([E.Boolean(z),E.String({format:"boolean",default:!1})],z)).Decode((U)=>{if(typeof U==="string")return U==="true";if(U!==void 0&&!o.Check(w,U))throw new r("property",w,U);return U}).Encode((U)=>U)},ObjectString:(z,w)=>{let U=E.Object(z,w),W=JSON.stringify(o.Create(U)),X;try{X=N6.Compile(U)}catch{}return E.Transform(E.Union([E.String({format:"ObjectString",default:W}),U])).Decode((Z)=>{if(typeof Z==="string"){if(Z.charCodeAt(0)!==123)throw new r("property",U,Z);try{Z=JSON.parse(Z)}catch{throw new r("property",U,Z)}if(X){if(!X.Check(Z))throw new r("property",U,Z);return X.Decode(Z)}if(!o.Check(U,Z))throw new r("property",U,Z);return o.Decode(U,Z)}return Z}).Encode((Z)=>{if(typeof Z==="string")try{Z=JSON.parse(Z)}catch{throw new r("property",U,Z)}if(!o.Check(U,Z))throw new r("property",U,Z);return JSON.stringify(Z)})},ArrayString:(z=E.String(),w)=>{let U=E.Array(z,w),W;try{W=N6.Compile(U)}catch{}let X=(Z,$=!1)=>{if(Z.charCodeAt(0)===91){try{Z=JSON.parse(Z)}catch{throw new r("property",U,Z)}if(W){if(!W.Check(Z))throw new r("property",U,Z);return W.Decode(Z)}if(!o.Check(U,Z))throw new r("property",U,Z);return o.Decode(U,Z)}if(Z.indexOf(",")!==-1){let A=Z.split(",").map((Q)=>Q.trim());if(W){if(!W.Check(A))throw new r("property",U,Z);return W.Decode(A)}if(!o.Check(U,A))throw new r("property",U,A);return o.Decode(U,A)}if($)return Z;throw new r("property",U,Z)};return E.Transform(E.Union([E.String({format:"ArrayString",default:w?.default}),U])).Decode((Z)=>{if(Array.isArray(Z)){let $=[];for(let A=0;A<Z.length;A++){let Q=Z[A];if(typeof Q==="string"){let Y=X(Q,!0);if(Array.isArray(Y))$=$.concat(Y);else $.push(Y);continue}$.push(Q)}return $}if(typeof Z==="string")return X(Z);return Z}).Encode((Z)=>{if(typeof Z==="string")try{Z=JSON.parse(Z)}catch{throw new r("property",U,Z)}if(!o.Check(U,Z))throw new r("property",U,Z);return JSON.stringify(Z)})},File:tL,Files:(z={})=>E.Transform(oL(z)).Decode((w)=>{if(Array.isArray(w))return w;return[w]}).Encode((w)=>w),Nullable:(z,w)=>E.Union([z,E.Null()],w),MaybeEmpty:(z,w)=>E.Union([z,E.Null(),E.Undefined()],w),Cookie:(z,{domain:w,expires:U,httpOnly:W,maxAge:X,path:Z,priority:$,sameSite:A,secure:Q,secrets:Y,sign:J,...G}={})=>{let S=E.Object(z,G);return S.config={domain:w,expires:U,httpOnly:W,maxAge:X,path:Z,priority:$,sameSite:A,secure:Q,secrets:Y,sign:J},S},UnionEnum:(z,w={})=>{let U=z.every((W)=>typeof W==="string")?{type:"string"}:z.every((W)=>typeof W==="number")?{type:"number"}:z.every((W)=>W===null)?{type:"null"}:{};if(z.some((W)=>typeof W==="object"&&W!==null))throw new Error("This type does not support objects or arrays");return{default:z[0],...w,[H]:"UnionEnum",...U,enum:z}}};E.BooleanString=w1.BooleanString;E.ObjectString=w1.ObjectString;E.ArrayString=w1.ArrayString;E.Numeric=w1.Numeric;E.Integer=w1.Integer;E.File=(z={})=>w1.File({default:"File",...z,extension:z?.type,type:"string",format:"binary"});E.Files=(z={})=>w1.Files({...z,elysiaMeta:"Files",default:"Files",extension:z?.type,type:"array",items:{...z,default:"Files",type:"string",format:"binary"}});E.Nullable=(z)=>w1.Nullable(z);E.MaybeEmpty=w1.MaybeEmpty;E.Cookie=w1.Cookie;E.Date=w1.Date;E.UnionEnum=w1.UnionEnum;function rU(z,w){if(!p0.Has(z))p0.Set(z,w);return(U={})=>k8({...U,[H]:z})}var r4=(z)=>{let w=typeof z==="object"?z.fn.toString():typeof z==="string"?z.toString():z,U=w.indexOf(")");if(w.charCodeAt(U+2)===61&&w.charCodeAt(U+5)!==123)return!0;return w.includes("return")},pL=(z)=>{if(z.startsWith("async"))z=z.slice(5);z=z.trimStart();let w=-1;if(z.charCodeAt(0)===40){if(w=z.indexOf("=>",z.indexOf(")")),w!==-1){let X=w;while(X>0)if(z.charCodeAt(--X)===41)break;let Z=z.slice(w+2);if(Z.charCodeAt(0)===32)Z=Z.trimStart();return[z.slice(1,X),Z,{isArrowReturn:Z.charCodeAt(0)!==123}]}}if(/^(\w+)=>/g.test(z)){if(w=z.indexOf("=>"),w!==-1){let X=z.slice(w+2);if(X.charCodeAt(0)===32)X=X.trimStart();return[z.slice(0,w),X,{isArrowReturn:X.charCodeAt(0)!==123}]}}if(z.startsWith("function")){w=z.indexOf("(");let X=z.indexOf(")");return[z.slice(w+1,X),z.slice(X+2),{isArrowReturn:!1}]}let U=z.indexOf("(");if(U!==-1){let X=z.indexOf(`
|
|
8
|
+
`,2),Z=z.slice(0,X),$=Z.lastIndexOf(")")+1,A=z.slice(X+1);return[Z.slice(U,$),"{"+A,{isArrowReturn:!1}]}let W=z.split(`
|
|
9
|
+
`,2);return[W[0],W[1],{isArrowReturn:!1}]},lL=(z)=>{let w=z.indexOf("{");if(w===-1)return[-1,0];let U=w+1,W=1;for(;U<z.length;U++){let X=z.charCodeAt(U);if(X===123)W++;else if(X===125)W--;if(W===0)break}if(W!==0)return[0,z.length];return[w,U+1]},sL=(z)=>{let w=z.lastIndexOf("}");if(w===-1)return[-1,0];let U=w-1,W=1;for(;U>=0;U--){let X=z.charCodeAt(U);if(X===125)W++;else if(X===123)W--;if(W===0)break}if(W!==0)return[-1,0];return[U,w+1]},aU=(z)=>{while(!0){let w=z.indexOf(":");if(w===-1)break;let U=z.indexOf(",",w);if(U===-1)U=z.indexOf("}",w)-1;if(U===-2)U=z.length;z=z.slice(0,w)+z.slice(U)}return z},eU=(z)=>{let w=!1;if(z.charCodeAt(0)===40)z=z.slice(1,-1);if(z.charCodeAt(0)===123)w=!0,z=z.slice(1,-1);z=z.replace(/( |\t|\n)/g,"").trim();let U=[];while(!0){let[X,Z]=lL(z);if(X===-1)break;if(U.push(z.slice(0,X-1)),z.charCodeAt(Z)===44)Z++;z=z.slice(Z)}if(z=aU(z),z)U=U.concat(z.split(","));let W=[];for(let X of U){if(X.indexOf(",")===-1){W.push(X);continue}for(let Z of X.split(","))W.push(Z.trim())}return U=W,{hasParenthesis:w,parameters:U}},rL=(z,w)=>{let{parameters:U,hasParenthesis:W}=eU(z);if(!w.query&&U.includes("query"))w.query=!0;if(!w.headers&&U.includes("headers"))w.headers=!0;if(!w.body&&U.includes("body"))w.body=!0;if(!w.cookie&&U.includes("cookie"))w.cookie=!0;if(!w.set&&U.includes("set"))w.set=!0;if(!w.server&&U.includes("server"))w.server=!0;if(!w.request&&U.includes("request"))w.request=!0;if(!w.route&&U.includes("route"))w.route=!0;if(W)return`{ ${U.join(", ")} }`;return U.join(", ")},kU=(z,w,U)=>{let W=w.indexOf(z+`
|
|
10
|
+
`,U),X=w.indexOf(z+"\t",U),Z=w.indexOf(z+",",U),$=w.indexOf(z+";",U),A=w.indexOf(z+" ",U);return[W,X,Z,$,A].filter((Q)=>Q>0).sort((Q,Y)=>Q-Y)[0]||-1},zW=(z,w,U=0)=>{if(U>5)return[];let W=[],X=w;while(!0){let Z=kU(" = "+z,X);if(Z===-1)Z=kU("="+z,X);if(Z===-1){let Y=X.indexOf(" = "+z);if(Y===-1)Y=X.indexOf("="+z);if(Y+3+z.length!==X.length)break;Z=Y}let $=X.slice(0,Z),A=$.lastIndexOf(" "),Q=$.slice(A!==-1?A+1:-1);if(Q==="}"){let[Y,J]=sL($);W.push(aU(X.slice(Y,J))),X=X.slice(Z+3+z.length);continue}while(Q.charCodeAt(0)===44)Q=Q.slice(1);while(Q.charCodeAt(0)===9)Q=Q.slice(1);if(!Q.includes("("))W.push(Q);X=X.slice(Z+3+z.length)}for(let Z of W){if(Z.charCodeAt(0)===123)continue;let $=zW(Z,w);if($.length>0)W.push(...$)}return W},aL=(z)=>{if(!z)return;if(z.charCodeAt(0)!==123)return z;if(z=z.slice(2,-2),!z.includes(",")){if(z.includes("..."))return z.slice(z.indexOf("...")+3);return}let w=z.indexOf("...");if(w===-1)return;return z.slice(w+3).trimEnd()},eL=(z,w,U)=>{let W=(X,Z)=>z.includes(Z+"."+X)||z.includes(Z+'["'+X+'"]')||z.includes(Z+"['"+X+"']");for(let X of w){if(!X)continue;if(X.charCodeAt(0)===123){let Z=eU(X).parameters;if(!U.query&&Z.includes("query"))U.query=!0;if(!U.headers&&Z.includes("headers"))U.headers=!0;if(!U.body&&Z.includes("body"))U.body=!0;if(!U.cookie&&Z.includes("cookie"))U.cookie=!0;if(!U.set&&Z.includes("set"))U.set=!0;if(!U.query&&Z.includes("server"))U.server=!0;if(!U.request&&Z.includes("request"))U.request=!0;if(!U.route&&Z.includes("route"))U.route=!0;continue}if(!U.query&&W("query",X))U.query=!0;if(z.includes("return "+X)||z.includes("return "+X+".query"))U.query=!0;if(!U.headers&&W("headers",X))U.headers=!0;if(!U.body&&W("body",X))U.body=!0;if(!U.cookie&&W("cookie",X))U.cookie=!0;if(!U.set&&W("set",X))U.set=!0;if(!U.server&&W("server",X))U.server=!0;if(U.query&&U.headers&&U.body&&U.cookie&&U.set&&U.server&&U.server&&U.route)break}return w},zG=(z,w,U)=>{try{let W=new RegExp(`(?:\\w)\\((?:.*)?${z}`,"gs");W.test(w);let X=w.charCodeAt(W.lastIndex);if(X===41||X===44)return U.query=!0,U.headers=!0,U.body=!0,U.cookie=!0,U.set=!0,U.server=!0,U.route=!0,U.request=!0,!0;return!1}catch(W){return console.log("[Sucrose] warning: unexpected isContextPassToFunction error, you may continue development as usual but please report the following to maintainers:"),console.log("--- body ---"),console.log(w),console.log("--- context ---"),console.log(z),!0}},wW=(z,w={query:!1,headers:!1,body:!1,cookie:!1,set:!1,server:!1,request:!1,route:!1})=>{let U=[];if(z.handler&&typeof z.handler==="function")U.push(z.handler);if(z.request?.length)U.push(...z.request);if(z.beforeHandle?.length)U.push(...z.beforeHandle);if(z.parse?.length)U.push(...z.parse);if(z.error?.length)U.push(...z.error);if(z.transform?.length)U.push(...z.transform);if(z.afterHandle?.length)U.push(...z.afterHandle);if(z.mapResponse?.length)U.push(...z.mapResponse);if(z.afterResponse?.length)U.push(...z.afterResponse);for(let W of U){if(!W)continue;let X="fn"in W?W.fn:W;if(typeof X!=="function")continue;let[Z,$,{isArrowReturn:A}]=pL(X.toString()),Q=rL(Z,w),Y=aL(Q);if(Y){let J=zW(Y,$.slice(1,-1));J.splice(0,-1,Y);let G=$;if(G.charCodeAt(0)===123&&G.charCodeAt($.length-1)===125)G=G.slice(1,-1);if(!zG(Y,G,w))eL(G,J,w);if(!w.query&&G.includes("return "+Y+".query"))w.query=!0}if(w.query&&w.headers&&w.body&&w.cookie&&w.set&&w.server&&w.request&&w.route)break}return w},v6=[];for(let z=48;z<58;z++)v6[z]=z-48;for(let z=0;z<6;z++)v6[z+65]=v6[z+97]=z+10;var wG=(z,w)=>{if(z in v6&&w in v6)return v6[z]<<4|v6[w];return 255},UW=[...new Array(128).fill(0),...new Array(16).fill(1),...new Array(16).fill(2),...new Array(32).fill(3),4,4,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,6,7,7,7,7,7,7,7,7,7,7,7,7,8,7,7,10,9,9,9,11,4,4,4,4,4,4,4,4,4,4,4],UG=[0,0,0,0,0,0,0,0,0,0,0,0,12,0,0,0,0,24,36,48,60,72,84,96,0,12,12,12,0,0,0,0,0,0,0,0,0,0,0,24,0,0,0,0,0,0,0,0,0,24,24,24,0,0,0,0,0,0,0,0,0,24,24,0,0,0,0,0,0,0,0,0,0,48,48,48,0,0,0,0,0,0,0,0,0,0,48,48,0,0,0,0,0,0,0,0,0,48,0,0,0,0,0,0,0,0,0,0],TU=UW.map((z)=>[127,63,63,63,0,31,15,15,15,7,7,7][z]),S6=(z)=>{let w=z.indexOf("%");if(w===-1)return z;let U=z.length-3;if(w>U)return null;let W="",X=0,Z=0,$=w,A=12,Q;for(;;){if(Q=wG(z.charCodeAt(w+1),z.charCodeAt(w+2)),A=UG[A+UW[Q]],A===0)return null;if(A===12){if(W+=z.substring(X,$),Z=Z<<6|Q&TU[Q],Z>65535)W+=String.fromCharCode(55232+(Z>>10),56320+(Z&1023));else W+=String.fromCharCode(Z);if(X=w+3,w=z.indexOf("%",X),w===-1)return W+z.substring(X);if(w>U)return null;$=w,Z=0}else{if(w+=3,w>U||z.charCodeAt(w)!==37)return null;Z=Z<<6|Q&TU[Q]}}};class O4{name;jar;initial;constructor(z,w,U={}){this.name=z,this.jar=w,this.initial=U}get cookie(){return this.jar[this.name]??this.initial}set cookie(z){if(!(this.name in this.jar))this.jar[this.name]=this.initial;this.jar[this.name]=z}get setCookie(){if(!(this.name in this.jar))this.jar[this.name]=this.initial;return this.jar[this.name]}set setCookie(z){this.cookie=z}get value(){return this.cookie.value}set value(z){this.setCookie.value=z}get expires(){return this.cookie.expires}set expires(z){this.setCookie.expires=z}get maxAge(){return this.cookie.maxAge}set maxAge(z){this.setCookie.maxAge=z}get domain(){return this.cookie.domain}set domain(z){this.setCookie.domain=z}get path(){return this.cookie.path}set path(z){this.setCookie.path=z}get secure(){return this.cookie.secure}set secure(z){this.setCookie.secure=z}get httpOnly(){return this.cookie.httpOnly}set httpOnly(z){this.setCookie.httpOnly=z}get sameSite(){return this.cookie.sameSite}set sameSite(z){this.setCookie.sameSite=z}get priority(){return this.cookie.priority}set priority(z){this.setCookie.priority=z}get partitioned(){return this.cookie.partitioned}set partitioned(z){this.setCookie.partitioned=z}get secrets(){return this.cookie.secrets}set secrets(z){this.setCookie.secrets=z}update(z){return this.setCookie=Object.assign(this.cookie,typeof z==="function"?z(this.cookie):z),this}set(z){return this.setCookie=Object.assign({...this.initial,value:this.value},typeof z==="function"?z(this.cookie):z),this}remove(){if(this.value===void 0)return;return this.set({expires:new Date(0),maxAge:0,value:""}),this}toString(){return typeof this.value==="object"?JSON.stringify(this.value):this.value?.toString()??""}}var gU=(z,w,U)=>{if(!z.cookie)z.cookie={};return new Proxy(w,{get(W,X){if(X in w)return new O4(X,z.cookie,Object.assign({},U??{},w[X]));return new O4(X,z.cookie,Object.assign({},U))}})},WW=async(z,w,{secrets:U,sign:W,...X}={})=>{if(!w)return gU(z,{},X);let Z=typeof U==="string";if(W&&W!==!0&&!Array.isArray(W))W=[W];let $={},A=w5.parse(w);for(let[Q,Y]of Object.entries(A)){if(Y===void 0)continue;let J=S6(Y);if(W===!0||W?.includes(Q)){if(!U)throw new Error("No secret is provided to cookie plugin");if(Z){let G=await jU(J,U);if(G===!1)throw new sz(Q);J=G}else{let G=!0;for(let S=0;S<U.length;S++){let N=await jU(J,U[S]);if(N!==!1){G=!0,J=N;break}}if(!G)throw new sz(Q)}}$[Q]={value:J}}return gU(z,$,X)},XW=(z)=>{if(!z||!z1(z))return;let w=[];for(let[U,W]of Object.entries(z)){if(!U||!W)continue;let X=W.value;if(X===void 0||X===null)continue;w.push(w5.serialize(U,typeof X==="object"?JSON.stringify(X):X+"",W))}if(w.length===0)return;if(w.length===1)return w[0];return w},D6=(z,w)=>{let U=z.size;if(!w&&U||U&&w&&w.status!==206&&w.status!==304&&w.status!==412&&w.status!==416){if(w){if(w.headers instanceof Headers){let W={"accept-ranges":"bytes","content-range":`bytes 0-${U-1}/${U}`,"transfer-encoding":"chunked"};if(p8)W=w.headers.toJSON();else{W={};for(let[X,Z]of w.headers.entries())if(X in w.headers)W[X]=Z}return new Response(z,{status:w.status,headers:W})}if(z1(w.headers))return new Response(z,{status:w.status,headers:Object.assign({"accept-ranges":"bytes","content-range":`bytes 0-${U-1}/${U}`,"transfer-encoding":"chunked"},w.headers)})}return new Response(z,{headers:{"accept-ranges":"bytes","content-range":`bytes 0-${U-1}/${U}`,"transfer-encoding":"chunked"}})}return new Response(z)},ZW=(z,w)=>{if(!z)return z;z.delete("set-cookie");for(let U=0;U<w.length;U++){let W=w[U].indexOf("=");z.append("set-cookie",`${w[U].slice(0,W)}=${w[U].slice(W+1)||""}`)}return z},n6=(z,w)=>{if(w?.headers){if(z){if(p8)Object.assign(w.headers,z.headers.toJSON());else for(let[U,W]of z.headers.entries())if(U in w.headers)w.headers[U]=W}if(w.status===200)w.status=z.status;if(w.headers["content-encoding"])delete w.headers["content-encoding"];return w}if(!z)return{headers:{},status:w?.status??200};if(p8){if(w={headers:z.headers.toJSON(),status:w?.status??200},w.headers["content-encoding"])delete w.headers["content-encoding"];return w}w={headers:{},status:w?.status??200};for(let[U,W]of z.headers.entries()){if(U==="content-encoding")continue;if(U in w.headers)w.headers[U]=W}return w},e2=async(z,w,U)=>{let W=z.next();if(W instanceof Promise)W=await W;if(W.done){if(w)return E2(W.value,w,U);return P6(W.value,U)}if(w?.headers){if(!w.headers["transfer-encoding"])w.headers["transfer-encoding"]="chunked";if(!w.headers["content-type"])w.headers["content-type"]="text/event-stream; charset=utf-8"}else w={status:200,headers:{"content-type":"text/event-stream; charset=utf-8","transfer-encoding":"chunked"}};return new Response(new ReadableStream({async start(X){let Z=!1;if(U?.signal?.addEventListener("abort",()=>{Z=!0;try{X.close()}catch{}}),W.value!==void 0&&W.value!==null)if(typeof W.value==="object")try{X.enqueue(Buffer.from(JSON.stringify(W.value)))}catch{X.enqueue(Buffer.from(W.value.toString()))}else X.enqueue(Buffer.from(W.value.toString()));for await(let $ of z){if(Z)break;if($===void 0||$===null)continue;if(typeof $==="object")try{X.enqueue(Buffer.from(JSON.stringify($)))}catch{X.enqueue(Buffer.from($.toString()))}else X.enqueue(Buffer.from($.toString()));await new Promise((A)=>setTimeout(()=>A(),0))}try{X.close()}catch{}}}),w)};async function*u6(z){let w=z.body;if(!w)return;let U=w.getReader(),W=new TextDecoder;try{while(!0){let{done:X,value:Z}=await U.read();if(X)break;yield W.decode(Z)}}finally{U.releaseLock()}}var $W=(z)=>{if(typeof z.status==="string")z.status=e8[z.status];if(z.cookie&&z1(z.cookie)){let w=XW(z.cookie);if(w)z.headers["set-cookie"]=w}if(z.headers["set-cookie"]&&Array.isArray(z.headers["set-cookie"]))z.headers=ZW(new Headers(z.headers),z.headers["set-cookie"])},a8=(z,w)=>{if(z.status!==w.status&&w.status!==200&&(z.status<=300||z.status>400))z=new Response(z.body,{headers:z.headers,status:w.status});let U=!1;if(w.headers instanceof Headers)for(let W of w.headers.keys())if(W==="set-cookie"){if(U)continue;U=!0;for(let X of w.headers.getSetCookie())z.headers.append("set-cookie",X)}else z.headers.append(W,w.headers?.get(W)??"");else for(let W in w.headers)z.headers.append(W,w.headers[W]);return z},E2=(z,w,U)=>{if(z1(w.headers)||w.status!==200||w.cookie)switch($W(w),z?.constructor?.name){case"String":return new Response(z,w);case"Array":case"Object":return Response.json(z,w);case"ElysiaFile":return D6(z.value);case"Blob":return D6(z,w);case"ElysiaCustomStatusResponse":return w.status=z.code,E2(z.response,w,U);case"ReadableStream":if(!w.headers["content-type"]?.startsWith("text/event-stream"))w.headers["content-type"]="text/event-stream; charset=utf-8";return U?.signal?.addEventListener("abort",{handleEvent(){if(U?.signal&&!U?.signal?.aborted)z.cancel()}},{once:!0}),new Response(z,w);case void 0:if(!z)return new Response("",w);return Response.json(z,w);case"Response":if(z=a8(z,w),!z.headers.has("content-length")&&z.headers.get("transfer-encoding")==="chunked")return e2(u6(z),n6(z,w),U);return z;case"Error":return O6(z,w);case"Promise":return z.then((W)=>E2(W,w,U));case"Function":return E2(z(),w,U);case"Number":case"Boolean":return new Response(z.toString(),w);case"Cookie":if(z instanceof O4)return new Response(z.value,w);return new Response(z?.toString(),w);case"FormData":return new Response(z,w);default:if(z instanceof Response){if(z=a8(z,w),z.headers.get("transfer-encoding")==="chunked")return e2(u6(z),n6(z,w),U);return z}if(z instanceof Promise)return z.then((W)=>E2(W,w));if(z instanceof Error)return O6(z,w);if(z instanceof b1)return w.status=z.code,E2(z.response,w,U);if(typeof z?.next==="function")return e2(z,w,U);if(typeof z?.then==="function")return z.then((W)=>E2(W,w));if(typeof z?.toResponse==="function")return E2(z.toResponse(),w);if("charCodeAt"in z){let W=z.charCodeAt(0);if(W===123||W===91){if(!w.headers["Content-Type"])w.headers["Content-Type"]="application/json";return new Response(JSON.stringify(z),w)}}return new Response(z,w)}if(z instanceof Response&&!z.headers.has("content-length")&&z.headers.get("transfer-encoding")==="chunked")return e2(u6(z),n6(z,w),U);if(typeof z?.next==="function"||z instanceof ReadableStream)return e2(z,w,U);return P6(z,U)},K2=(z,w,U)=>{if(z===void 0||z===null)return;if(z1(w.headers)||w.status!==200||w.cookie)switch($W(w),z?.constructor?.name){case"String":return new Response(z,w);case"Array":case"Object":return Response.json(z,w);case"ElysiaFile":return D6(z.value);case"Blob":return D6(z,w);case"ElysiaCustomStatusResponse":return w.status=z.code,K2(z.response,w,U);case"ReadableStream":if(!w.headers["content-type"]?.startsWith("text/event-stream"))w.headers["content-type"]="text/event-stream; charset=utf-8";return U?.signal?.addEventListener("abort",{handleEvent(){if(U?.signal&&!U?.signal?.aborted)z.cancel()}},{once:!0}),new Response(z,w);case void 0:if(!z)return;return Response.json(z,w);case"Response":if(z=a8(z,w),!z.headers.has("content-length")&&z.headers.get("transfer-encoding")==="chunked")return e2(u6(z),n6(z,w),U);return z;case"Promise":return z.then((W)=>K2(W,w));case"Error":return O6(z,w);case"Function":return K2(z(),w);case"Number":case"Boolean":return new Response(z.toString(),w);case"FormData":return new Response(z);case"Cookie":if(z instanceof O4)return new Response(z.value,w);return new Response(z?.toString(),w);default:if(z instanceof Response){if(z=a8(z,w),z.headers.get("transfer-encoding")==="chunked")return e2(u6(z),n6(z,w),U);return z}if(z instanceof Promise)return z.then((W)=>K2(W,w));if(z instanceof Error)return O6(z,w);if(z instanceof b1)return w.status=z.code,K2(z.response,w,U);if(typeof z?.next==="function")return e2(z,w,U);if(typeof z?.then==="function")return z.then((W)=>K2(W,w));if(typeof z?.toResponse==="function")return K2(z.toResponse(),w);if("charCodeAt"in z){let W=z.charCodeAt(0);if(W===123||W===91){if(!w.headers["Content-Type"])w.headers["Content-Type"]="application/json";return new Response(JSON.stringify(z),w)}}return new Response(z,w)}else switch(z?.constructor?.name){case"String":return new Response(z);case"Array":case"Object":return Response.json(z,w);case"ElysiaFile":return D6(z.value);case"Blob":return D6(z,w);case"ElysiaCustomStatusResponse":return w.status=z.code,K2(z.response,w,U);case"ReadableStream":return U?.signal?.addEventListener("abort",{handleEvent(){if(U?.signal&&!U?.signal?.aborted)z.cancel()}},{once:!0}),new Response(z,{headers:{"Content-Type":"text/event-stream; charset=utf-8"}});case void 0:if(!z)return new Response("");return new Response(JSON.stringify(z),{headers:{"content-type":"application/json"}});case"Response":if(!z.headers.has("content-length")&&z.headers.get("transfer-encoding")==="chunked")return e2(u6(z),n6(z),U);return z;case"Promise":return z.then((W)=>{let X=K2(W,w);if(X!==void 0)return X});case"Error":return O6(z,w);case"Function":return P6(z(),U);case"Number":case"Boolean":return new Response(z.toString());case"Cookie":if(z instanceof O4)return new Response(z.value,w);return new Response(z?.toString(),w);case"FormData":return new Response(z);default:if(z instanceof Response)return z;if(z instanceof Promise)return z.then((W)=>K2(W,w));if(z instanceof Error)return O6(z,w);if(z instanceof b1)return w.status=z.code,K2(z.response,w,U);if(typeof z?.next==="function")return e2(z,w,U);if(typeof z?.then==="function")return z.then((W)=>K2(W,w));if(typeof z?.toResponse==="function")return K2(z.toResponse(),w);if("charCodeAt"in z){let W=z.charCodeAt(0);if(W===123||W===91){if(!w.headers["Content-Type"])w.headers["Content-Type"]="application/json";return new Response(JSON.stringify(z),w)}}return new Response(z)}},P6=(z,w)=>{switch(z?.constructor?.name){case"String":return new Response(z);case"Object":case"Array":return Response.json(z);case"ElysiaFile":return D6(z.value);case"Blob":return D6(z);case"ElysiaCustomStatusResponse":return E2(z.response,{status:z.code,headers:{}});case"ReadableStream":return w?.signal?.addEventListener("abort",{handleEvent(){if(w?.signal&&!w?.signal?.aborted)z.cancel()}},{once:!0}),new Response(z,{headers:{"Content-Type":"text/event-stream; charset=utf-8"}});case void 0:if(!z)return new Response("");return new Response(JSON.stringify(z),{headers:{"content-type":"application/json"}});case"Response":if(z.headers.get("transfer-encoding")==="chunked")return e2(u6(z),n6(z),w);return z;case"Error":return O6(z);case"Promise":return z.then((U)=>P6(U,w));case"Function":return P6(z(),w);case"Number":case"Boolean":return new Response(z.toString());case"FormData":return new Response(z);default:if(z instanceof Response)return z;if(z instanceof Promise)return z.then((U)=>P6(U,w));if(z instanceof Error)return O6(z);if(z instanceof b1)return E2(z.response,{status:z.code,headers:{}});if(typeof z?.next==="function")return e2(z,void 0,w);if(typeof z?.then==="function")return z.then((U)=>E2(U,set));if(typeof z?.toResponse==="function")return P6(z.toResponse());if("charCodeAt"in z){let U=z.charCodeAt(0);if(U===123||U===91)return new Response(JSON.stringify(z),{headers:{"Content-Type":"application/json"}})}return new Response(z)}},O6=(z,w)=>new Response(JSON.stringify({name:z?.name,message:z?.message,cause:z?.cause}),{status:w?.status!==200?w?.status??500:500,headers:w?.headers}),WG=(z,w,U={})=>{if(typeof z==="function")return;let W=E2(z,{headers:U});if(!w.parse?.length&&!w.transform?.length&&!w.beforeHandle?.length&&!w.afterHandle?.length)return W.clone.bind(W)},t8={name:"web-standard",isWebStandard:!0,handler:{mapResponse:E2,mapEarlyResponse:K2,mapCompactResponse:P6,createStaticHandler:WG},composeHandler:{mapResponseContext:"c.request",preferWebstandardHeaders:!0,headers:`c.headers = {}
|
|
10
11
|
for (const [key, value] of c.request.headers.entries())c.headers[key] = value
|
|
11
|
-
`,parser:{json(
|
|
12
|
+
`,parser:{json(z){if(z)return`try{c.body=await c.request.json()}catch{}
|
|
12
13
|
`;return`c.body=await c.request.json()
|
|
13
14
|
`},text(){return`c.body=await c.request.text()
|
|
14
15
|
`},urlencoded(){return`c.body=parseQuery(await c.request.text())
|
|
15
16
|
`},arrayBuffer(){return`c.body=await c.request.arrayBuffer()
|
|
16
|
-
`},formData(
|
|
17
|
+
`},formData(z){let w=`
|
|
17
18
|
c.body={}
|
|
18
|
-
`;if(w
|
|
19
|
-
`;return
|
|
19
|
+
`;if(z)w+="let form;try{form=await c.request.formData()}catch{}";else w+=`const form=await c.request.formData()
|
|
20
|
+
`;return w+`for(const key of form.keys()){if(c.body[key]) continue
|
|
20
21
|
const value=form.getAll(key)
|
|
21
22
|
if(value.length===1)c.body[key]=value[0]
|
|
22
|
-
else c.body[key]=value}`}}},composeGeneralHandler:{parameters:"r",createContext(
|
|
23
|
+
else c.body[key]=value}`}}},composeGeneralHandler:{parameters:"r",createContext(z){let w="",U="",W=z.setHeaders;for(let $ of Object.keys(z.singleton.decorator))w+=`,${$}: decorator['${$}']`;let X=z.config.handler?.standardHostname??!0,Z=!!z.event.trace?.length;if(U+=`const u=r.url,s=u.indexOf('/',${X?11:7}),qi=u.indexOf('?', s + 1)
|
|
23
24
|
let p
|
|
24
25
|
if(qi===-1)p=u.substring(s)
|
|
25
26
|
else p=u.substring(s, qi)
|
|
26
|
-
|
|
27
|
-
`;if(
|
|
28
|
-
`,
|
|
29
|
-
`;
|
|
27
|
+
`,Z)U+=`const id=randomId()
|
|
28
|
+
`;if(U+="const c={request:r,store,qi,path:p,url:u,redirect,error,set:{headers:",U+=Object.keys(W??{}).length?"Object.assign({}, app.setHeaders)":"{}",U+=",status:200}",z.inference.server)U+=",get server(){return app.getServer()}";if(Z)U+=",[ELYSIA_REQUEST_ID]:id";return U+=w,U+=`}
|
|
29
|
+
`,U},websocket(z){let w="",U=z.router.static.ws,W=z.router.http;if(W.build(),Object.keys(U).length||W.root.ws||W.history.find((X)=>X["0"]==="ws")){w+="if(r.method==='GET'){switch(p){";for(let[X,Z]of Object.entries(U))w+=`case'${X}':`+(z.config.strictPath!==!0?`case'${S4(X)}':`:"")+`if(r.headers.get('upgrade')==='websocket')return ht[${Z}].composed(c)
|
|
30
|
+
`;w+=`default:if(r.headers.get('upgrade')==='websocket'){const route=router.find('ws',p)
|
|
30
31
|
if(route){c.params=route.params
|
|
31
32
|
if(route.store.handler)return route.store.handler(c)
|
|
32
|
-
return (route.store.handler=route.store.compile())(c)}}break}}`}return
|
|
33
|
+
return (route.store.handler=route.store.compile())(c)}}break}}`}return w},error404(z,w){let U="if(route===null)return ";if(w)U+=`app.handleError(c,notFound,false,${this.parameters})`;else U+=z?"new Response(error404Message,{status:c.set.status===200?404:c.set.status,headers:c.set.headers})":"error404.clone()";return{declare:w?"":`const error404Message=notFound.message.toString()
|
|
33
34
|
const error404=new Response(error404Message,{status:404})
|
|
34
|
-
`,code:
|
|
35
|
+
`,code:U}}},composeError:{mapResponseContext:"",validationError:"return new Response(error.message,{headers:Object.assign({'content-type':'application/json'},set.headers),status:set.status})",unknownError:"return new Response(error.message,{headers:set.headers,status:error.status??set.status??500})"},listen(){return()=>{throw new Error("WebStandard does not support listen, you might want to export default Elysia.fetch instead")}}},XG=(z,w,U={})=>{if(typeof z==="function"||z instanceof Blob)return;if(typeof z==="object"&&z?.toString()==="[object HTMLBundle]")return()=>z;let W=E2(z,{headers:U});if(!w.parse?.length&&!w.transform?.length&&!w.beforeHandle?.length&&!w.afterHandle?.length){if(!W.headers.has("content-type"))W.headers.append("content-type","text/plain;charset=utf-8");return W.clone.bind(W)}},fU={open(z){z.data.open?.(z)},message(z,w){z.data.message?.(z,w)},drain(z){z.data.drain?.(z)},close(z,w,U){z.data.close?.(z,w,U)}};class l4{raw;data;body;validator;["~types"];get id(){return this.data.id}constructor(z,w,U=void 0){this.raw=z,this.data=w,this.body=U,this.validator=z.data?.validator,this.sendText=z.sendText.bind(z),this.sendBinary=z.sendBinary.bind(z),this.close=z.close.bind(z),this.terminate=z.terminate.bind(z),this.publishText=z.publishText.bind(z),this.publishBinary=z.publishBinary.bind(z),this.subscribe=z.subscribe.bind(z),this.unsubscribe=z.unsubscribe.bind(z),this.isSubscribed=z.isSubscribed.bind(z),this.cork=z.cork.bind(z),this.remoteAddress=z.remoteAddress,this.binaryType=z.binaryType,this.data=z.data,this.send=this.send.bind(this),this.ping=this.ping.bind(this),this.pong=this.pong.bind(this),this.publish=this.publish.bind(this)}send(z,w){if(Buffer.isBuffer(z))return this.raw.send(z,w);if(this.validator?.Check(z)===!1)return this.raw.send(new r("message",this.validator,z).message);if(typeof z==="object")z=JSON.stringify(z);return this.raw.send(z,w)}ping(z){if(Buffer.isBuffer(z))return this.raw.ping(z);if(this.validator?.Check(z)===!1)return this.raw.send(new r("message",this.validator,z).message);if(typeof z==="object")z=JSON.stringify(z);return this.raw.ping(z)}pong(z){if(Buffer.isBuffer(z))return this.raw.pong(z);if(this.validator?.Check(z)===!1)return this.raw.send(new r("message",this.validator,z).message);if(typeof z==="object")z=JSON.stringify(z);return this.raw.pong(z)}publish(z,w,U){if(Buffer.isBuffer(w))return this.raw.publish(z,w,U);if(this.validator?.Check(w)===!1)return this.raw.send(new r("message",this.validator,w).message);if(typeof w==="object")w=JSON.stringify(w);return this.raw.publish(z,w,U)}sendText;sendBinary;close;terminate;publishText;publishBinary;subscribe;unsubscribe;isSubscribed;cork;remoteAddress;binaryType;get readyState(){return this.raw.readyState}}var ZG=(z)=>{let w=typeof z==="function"?[z]:z;return async function U(W,X){if(typeof X==="string"){let Z=X?.charCodeAt(0);if(Z===34||Z===47||Z===91||Z===123)try{X=JSON.parse(X)}catch{}else if(ez(X))X=+X;else if(X==="true")X=!0;else if(X==="false")X=!1;else if(X==="null")X=null}if(w)for(let Z=0;Z<w.length;Z++){let $=w[Z](W,X);if($ instanceof Promise)$=await $;if($!==void 0)return $}return X}},$G=(z)=>{let w=(U,W)=>{if(W instanceof Promise)return W.then(($)=>w(U,$));if(Buffer.isBuffer(W))return U.send(W.toString());if(W===void 0)return;let X=($)=>{if(z?.Check($)===!1)return U.send(new r("message",z,$).message);if(typeof $==="object")return U.send(JSON.stringify($));U.send($)};if(typeof W?.next!=="function")return void X(W);let Z=W.next();if(Z instanceof Promise)return(async()=>{let $=await Z;if(z?.Check($)===!1)return U.send(new r("message",z,$).message);if(X($.value),!$.done)for await(let A of W)X(A)})();if(X(Z.value),!Z.done)for(let $ of W)X($)};return w},AG={...t8,name:"bun",handler:{...t8.handler,createNativeStaticHandler:XG},composeHandler:{...t8.composeHandler,headers:p8?`c.headers = c.request.headers.toJSON()
|
|
35
36
|
`:`c.headers = {}
|
|
36
37
|
for (const [key, value] of c.request.headers.entries())c.headers[key] = value
|
|
37
|
-
`},listen(
|
|
38
|
-
`);return(
|
|
39
|
-
`);return{resolve(){for(let
|
|
40
|
-
`)},resolveChild(
|
|
41
|
-
`);return(
|
|
42
|
-
`)}}}}},
|
|
43
|
-
`;
|
|
44
|
-
${
|
|
45
|
-
switch(c.set.status){`;for(let[$,
|
|
46
|
-
case ${$}:if(!isResponse){`,
|
|
47
|
-
`;
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
`;
|
|
57
|
-
c.cookie=await parseCookie(c.set,c.
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
let
|
|
61
|
-
`;
|
|
38
|
+
`},listen(z){return(w,U)=>{if(typeof Bun==="undefined")throw new Error(".listen() is designed to run on Bun only. If you are running Elysia in other environment please use a dedicated plugin or export the handler via Elysia.fetch");if(z.compile(),typeof w==="string"){if(!ez(w))throw new Error("Port must be a numeric value");w=parseInt(w)}let W=z.fetch,X=typeof w==="object"?{development:!r8,reusePort:!0,...z.config.serve||{},...w||{},static:{...z.router.static.http.static,...z.config.serve?.static},websocket:{...z.config.websocket||{},...fU||{}},fetch:W,error:z.outerErrorHandler}:{development:!r8,reusePort:!0,...z.config.serve||{},static:z.router.static.http.static,websocket:{...z.config.websocket||{},...fU||{}},port:w,fetch:W,error:z.outerErrorHandler};if(z.server=Bun?.serve(X),z.event.start)for(let Z=0;Z<z.event.start.length;Z++)z.event.start[Z].fn(z);if(U)U(z.server);process.on("beforeExit",()=>{if(z.server){if(z.server.stop?.(),z.server=null,z.event.stop)for(let Z=0;Z<z.event.stop.length;Z++)z.event.stop[Z].fn(z)}}),z.promisedModules.then(()=>{Bun?.gc(!1)})}},ws(z,w,U){let{parse:W,body:X,response:Z,...$}=U,A=F2(X,{modules:z.definitions.typebox,models:z.definitions.type,normalize:z.config.normalize}),Q=F2(Z,{modules:z.definitions.typebox,models:z.definitions.type,normalize:z.config.normalize});z.route("$INTERNALWS",w,async(Y)=>{let J=z.getServer(),{set:G,path:S,qi:N,headers:O,query:M,params:C}=Y;if(Y.validator=Q,U.upgrade){if(typeof U.upgrade==="function"){let f=U.upgrade(Y);if(f instanceof Promise)await f}else if(U.upgrade)Object.assign(G.headers,U.upgrade)}if(G.cookie&&z1(G.cookie)){let f=XW(G.cookie);if(f)G.headers["set-cookie"]=f}if(G.headers["set-cookie"]&&Array.isArray(G.headers["set-cookie"]))G.headers=ZW(new Headers(G.headers),G.headers["set-cookie"]);let g=$G(Q),L0=ZG(W),a,$0=[...Array.isArray(U.error)?U.error:[U.error],...(z.event.error??[]).map((f)=>typeof f==="function"?f:f.fn)],K0=!$0.length?()=>{}:async(f,V)=>{for(let k of $0){let j=k(Object.assign(Y,{error:V}));if(j instanceof Promise)j=await j;if(await g(f,j),j)break}};if(J?.upgrade(Y.request,{headers:z1(G.headers)?G.headers:void 0,data:{...Y,get id(){if(a)return a;return a=uU()},validator:Q,ping(f){U.ping?.(f)},pong(f){U.pong?.(f)},open(f){try{g(f,U.open?.(new l4(f,Y)))}catch(V){K0(f,V)}},message:async(f,V)=>{let k=await L0(f,V);if(A?.Check(k)===!1)return void f.send(new r("message",A,k).message);try{g(f,U.message?.(new l4(f,Y,k),k))}catch(j){K0(f,j)}},drain(f){try{g(f,U.drain?.(new l4(f,Y)))}catch(V){K0(f,V)}},close(f,V,k){try{g(f,U.close?.(new l4(f,Y),V,k))}catch(j){K0(f,j)}}}}))return;return G.status=400,"Expected a websocket connection"},{...$,websocket:U})}},QG=typeof Bun!=="undefined",dU=QG?Bun.env:typeof process!=="undefined"&&process?.env?process.env:{},D4=/\+/g;function YG(z){let w={};if(typeof z!=="string")return w;let U="",W="",X=-1,Z=-1,$=0,A=z.length;for(let Q=0;Q<A;Q++)switch(z.charCodeAt(Q)){case 38:let Y=Z>X;if(!Y)Z=Q;if(U=z.slice(X+1,Z),Y||U.length>0){if($&1)U=U.replace(D4," ");if($&2)U=S6(U)||U;if(!w[U]){if(Y){if(W=z.slice(Z+1,Q),$&4)W=W.replace(D4," ");if($&8)W=S6(W)||W}w[U]=W}}U="",W="",X=Q,Z=Q,$=0;break;case 61:if(Z<=X)Z=Q;else $|=8;break;case 43:if(Z>X)$|=4;else $|=1;break;case 37:if(Z>X)$|=8;else $|=2;break}if(X<A){let Q=Z>X;if(U=z.slice(X+1,Q?Z:A),Q||U.length>0){if($&1)U=U.replace(D4," ");if($&2)U=S6(U)||U;if(!w[U]){if(Q){if(W=z.slice(Z+1,A),$&4)W=W.replace(D4," ");if($&8)W=S6(W)||W}w[U]=W}}}return w}var o8=(z)=>{let w={};if(typeof z!=="string")return w;let U=z.length,W="",X="",Z=-1,$=-1,A=!1,Q=!1,Y=!1,J=!1,G=!1,S=0;for(let N=0;N<U+1;N++){if(N!==U)S=z.charCodeAt(N);else S=38;switch(S){case 38:{if(G=$>Z,!G)$=N;if(W=z.slice(Z+1,$),G||W.length>0){if(Y)W=W.replace(D4," ");if(A)W=S6(W)||W;if(G){if(X=z.slice($+1,N),J)X=X.replace(D4," ");if(Q)X=S6(X)||X}let O=w[W];if(O===void 0)w[W]=X;else if(O.pop)O.push(X);else w[W]=[O,X]}X="",Z=N,$=N,A=!1,Q=!1,Y=!1,J=!1;break}case 61:if($<=Z)$=N;else Q=!0;break;case 43:if($>Z)J=!0;else Y=!0;break;case 37:if($>Z)Q=!0;else A=!0;break}}return w},ww=Symbol("ElysiaTrace"),e1=()=>{let{promise:z,resolve:w}=Promise.withResolvers(),{promise:U,resolve:W}=Promise.withResolvers(),{promise:X,resolve:Z}=Promise.withResolvers(),$=[],A=[];return[(Q)=>{if(Q)$.push(Q);return z},(Q)=>{let Y=[],J=[],G=null;for(let N=0;N<(Q.total??0);N++){let{promise:O,resolve:M}=Promise.withResolvers(),{promise:C,resolve:g}=Promise.withResolvers(),{promise:L0,resolve:a}=Promise.withResolvers(),$0=[],K0=[];Y.push((f)=>{if(f)$0.push(f);return O}),J.push((f)=>{let V={...f,end:C,error:L0,index:N,onStop(k){if(k)K0.push(k);return C}};M(V);for(let k=0;k<$0.length;k++)$0[k](V);return(k=null)=>{let j=performance.now();if(k)G=k;let e={end:j,error:k,get elapsed(){return j-f.begin}};for(let Y0=0;Y0<K0.length;Y0++)K0[Y0](e);g(j),a(k)}})}let S={...Q,end:U,error:X,onEvent(N){for(let O=0;O<Y.length;O++)Y[O](N)},onStop(N){if(N)A.push(N);return U}};w(S);for(let N=0;N<$.length;N++)$[N](S);return{resolveChild:J,resolve(N=null){let O=performance.now();if(!N&&G)N=G;let M={end:O,error:N,get elapsed(){return O-Q.begin}};for(let C=0;C<A.length;C++)A[C](M);W(O),Z(N)}}}]},JG=(z)=>{return(w)=>{let[U,W]=e1(),[X,Z]=e1(),[$,A]=e1(),[Q,Y]=e1(),[J,G]=e1(),[S,N]=e1(),[O,M]=e1(),[C,g]=e1(),[L0,a]=e1();return z({id:w[z5],context:w,set:w.set,onRequest:U,onParse:X,onTransform:$,onBeforeHandle:Q,onHandle:J,onAfterHandle:S,onMapResponse:C,onAfterResponse:L0,onError:O}),{request:W,parse:Z,transform:A,beforeHandle:Y,handle:G,afterHandle:N,error:M,mapResponse:g,afterResponse:a}}},m6={optional:Symbol.for("TypeBox.Optional"),kind:Symbol.for("TypeBox.Kind")},R1=(z)=>{if(!z)return!1;let w=z?.schema;if(w?.[m6.kind]==="Import")return z.References().some(R1);return!!w&&m6.optional in w},Q2=(z,w)=>w?z:"",BG=["json","text","urlencoded","arrayBuffer","formdata","application/json","text/plain","application/x-www-form-urlencoded","application/octet-stream","multipart/form-data"],a2=(z)=>{if(!z)return!1;let w=z?.schema??z;if(w[m6.kind]==="Import"&&z.References())return z.References().some(a2);if(w.anyOf)return w.anyOf.some(a2);if(w.someOf)return w.someOf.some(a2);if(w.allOf)return w.allOf.some(a2);if(w.not)return w.not.some(a2);if(w.type==="object"){let U=w.properties;if("additionalProperties"in w)return w.additionalProperties;if("patternProperties"in w)return!1;for(let W of Object.keys(U)){let X=U[W];if(X.type==="object"){if(a2(X))return!0}else if(X.anyOf){for(let Z=0;Z<X.anyOf.length;Z++)if(a2(X.anyOf[Z]))return!0}return X.additionalProperties}return!1}return!1},Uw=({context:z="c",trace:w=[],addFn:U})=>{if(!w.length)return()=>{return{resolveChild(){return()=>{}},resolve(){}}};for(let W=0;W<w.length;W++)U(`let report${W}, reportChild${W}, reportErr${W}, reportErrChild${W};let trace${W} = ${z}[ELYSIA_TRACE]?.[${W}] ?? trace[${W}](${z});
|
|
39
|
+
`);return(W,{name:X,total:Z=0}={})=>{if(!X)X="anonymous";let $=W==="error"?"reportErr":"report";for(let A=0;A<w.length;A++)U(`${$}${A} = trace${A}.${W}({id,event:'${W}',name:'${X}',begin:performance.now(),total:${Z}})
|
|
40
|
+
`);return{resolve(){for(let A=0;A<w.length;A++)U(`${$}${A}.resolve()
|
|
41
|
+
`)},resolveChild(A){for(let Q=0;Q<w.length;Q++)U(`${$}Child${Q}=${$}${Q}.resolveChild?.shift()?.({id,event:'${W}',name:'${A}',begin:performance.now()})
|
|
42
|
+
`);return(Q)=>{for(let Y=0;Y<w.length;Y++)if(Q)U(`if(${Q} instanceof Error){${$}Child${Y}?.(${Q}) }else{${$}Child${Y}?.()}`);else U(`${$}Child${Y}?.()
|
|
43
|
+
`)}}}}},MG=({injectResponse:z="",normalize:w=!1,validator:U,encodeSchema:W=!1})=>({composeValidation:(X,Z=`c.${X}`)=>`c.set.status=422;throw new ValidationError('${X}',validator.${X},${Z})`,composeResponseValidation:(X="r")=>{let Z=z+`
|
|
44
|
+
`;Z+=`if(${X} instanceof ElysiaCustomStatusResponse){c.set.status=${X}.code
|
|
45
|
+
${X}=${X}.response}const isResponse=${X} instanceof Response
|
|
46
|
+
switch(c.set.status){`;for(let[$,A]of Object.entries(U.response)){if(Z+=`
|
|
47
|
+
case ${$}:if(!isResponse){`,w&&"Clean"in A&&!a2(A))Z+=`${X}=validator.response['${$}'].Clean(${X})
|
|
48
|
+
`;if(W&&(A.hasTransform||typeof A.Decode==="function"))Z+=`${X}=validator.response['${$}'].Encode(${X})
|
|
49
|
+
`;Z+=`if(validator.response['${$}'].Check(${X})===false){c.set.status=422
|
|
50
|
+
throw new ValidationError('response',validator.response['${$}'],${X})}c.set.status = ${$}}
|
|
51
|
+
`,Z+=`break
|
|
52
|
+
`}return Z+"}"}}),JI=Symbol.for("TypeBox.Kind"),_6=(z,w)=>{if(!w)return;let U=w.schema??w;if(U[m6.kind]==="Import")return w.References().some((W)=>_6(z,W));if(U.type==="object"){let W=U.properties;if(!W)return!1;for(let X of Object.keys(W)){let Z=W[X];if(z in Z)return!0;if(Z.type==="object"){if(_6(z,Z))return!0}else if(Z.anyOf){for(let $=0;$<Z.anyOf.length;$++)if(_6(z,Z.anyOf[$]))return!0}}return!1}return z in U},qG=Symbol.for("TypeBox.Transform"),i2=(z)=>{if(!z)return!1;if(z.$ref&&z.$defs&&z.$ref in z.$defs&&i2(z.$defs[z.$ref]))return!0;if(z.oneOf){for(let w=0;w<z.oneOf.length;w++)if(i2(z.oneOf[w]))return!0}if(z.anyOf){for(let w=0;w<z.anyOf.length;w++)if(i2(z.anyOf[w]))return!0}if(z.allOf){for(let w=0;w<z.allOf.length;w++)if(i2(z.allOf[w]))return!0}if(z.not&&i2(z.not))return!0;if(z.type==="object"&&z.properties){let w=z.properties;for(let U of Object.keys(w)){let W=w[U];if(i2(W))return!0;if(W.type==="array"&&W.items&&i2(W.items))return!0}}if(z.type==="array"&&z.items&&i2(z.items))return!0;return qG in z},LG=/(?:return|=>) \S+\(/g,P4=(z)=>{return(z?.fn??z).constructor.name==="AsyncFunction"},a0=(z)=>{let w=z?.fn??z;if(w.constructor.name==="AsyncFunction")return!0;let U=w.toString();if(U.includes("=> response.clone("))return!1;if(U.includes("await"))return!0;if(U.includes("async"))return!0;if(U.includes("=>response.clone("))return!1;return!!U.match(LG)},m8=(z)=>{let w=z?.fn??z;return w.constructor.name==="AsyncGeneratorFunction"||w.constructor.name==="GeneratorFunction"},GG=({app:z,path:w,method:U,hooks:W,validator:X,handler:Z,allowMeta:$=!1,inference:A,asManifest:Q=!1})=>{let Y=z["~adapter"].composeHandler,J=z["~adapter"].handler,G=typeof Z==="function";if(!G){if(Z=J.mapResponse(Z,{headers:z.setHeaders??{}}),W.parse?.length&&W.transform?.length&&W.beforeHandle?.length&&W.afterHandle?.length){if(Z instanceof Response)return Function("a","return function(){return a.clone()}")(Z);return Function("a","return function(){return a}")(Z)}}let S=G?"handler(c)":"handler",N=!!W.afterResponse?.length,O=!!W.trace?.length,M="";if(A=wW(Object.assign({},W,{handler:Z}),A),Y.declare){let F=Y.declare(A);if(F)M+=F}if(A.server)M+=`Object.defineProperty(c,'server',{get:function(){return getServer()}})
|
|
53
|
+
`;X.createBody?.(),X.createQuery?.(),X.createHeaders?.(),X.createParams?.(),X.createCookie?.(),X.createResponse?.();let C=X.body||X.headers||X.params||X.query||X.cookie||X.response,g=A.query||!!X.query,L0=W.parse?.length===1&&W.parse[0].fn==="none",a=U!=="$INTERNALWS"&&U!=="GET"&&U!=="HEAD"&&(A.body||!!X.body||!!W.parse?.length)&&!L0;if(a)M+=`let isParsing=false
|
|
54
|
+
`;let $0=z.setHeaders,K0=$0&&!!Object.keys($0).length,f=A.headers||X.headers||Y.preferWebstandardHeaders!==!0&&A.body,V=A.cookie||!!X.cookie,k=V?yU({modules:z.definitions.typebox,validator:X.cookie,defaultConfig:z.config.cookie,dynamic:!!z.config.aot,config:X.cookie?.config??{},models:z.definitions.type}):void 0,j=k?.config,e="";if(j?.sign){if(!j.secrets)throw new Error(`t.Cookie required secret which is not set in (${U}) ${w}.`);let F=!j.secrets?void 0:typeof j.secrets==="string"?j.secrets:j.secrets[0];if(e+=`const _setCookie = c.set.cookie
|
|
55
|
+
if(_setCookie){`,j.sign===!0)e+=`for(const [key, cookie] of Object.entries(_setCookie)){c.set.cookie[key].value=await signCookie(cookie.value,'${F}')}`;else for(let R of j.sign)e+=`if(_setCookie['${R}']?.value){c.set.cookie['${R}'].value=await signCookie(_setCookie['${R}'].value,'${F}')}`;e+=`}
|
|
56
|
+
`}let Y0=z.config.normalize,_0=z.config.experimental?.encodeSchema,{composeValidation:h0,composeResponseValidation:U6}=MG({normalize:Y0,validator:X,encodeSchema:_0});if(f)M+=Y.headers;if(O)M+=`const id=c[ELYSIA_REQUEST_ID]
|
|
57
|
+
`;let n0=Uw({trace:W.trace,addFn:(F)=>{M+=F}});if(M+="try{",V){let F=(b,c)=>{let t=j?.[b]??c;if(!t)return typeof c==="string"?`${b}:"${c}",`:`${b}:${c},`;if(typeof t==="string")return`${b}:'${t}',`;if(t instanceof Date)return`${b}: new Date(${t.getTime()}),`;return`${b}:${t},`},R=j?`{secrets:${j.secrets!==void 0?typeof j.secrets==="string"?`'${j.secrets}'`:"["+j.secrets.reduce((b,c)=>b+`'${c}',`,"")+"]":"undefined"},sign:${j.sign===!0?!0:j.sign!==void 0?"["+j.sign.reduce((b,c)=>b+`'${c}',`,"")+"]":"undefined"},`+F("domain")+F("expires")+F("httpOnly")+F("maxAge")+F("path","/")+F("priority")+F("sameSite")+F("secure")+"}":"undefined";if(f)M+=`
|
|
58
|
+
c.cookie=await parseCookie(c.set,c.headers.cookie,${R})
|
|
59
|
+
`;else M+=`
|
|
60
|
+
c.cookie=await parseCookie(c.set,c.request.headers.get('cookie'),${R})
|
|
61
|
+
`}if(g){let F=[];if(X.query&&X.query.schema.type==="object"){let R=X.query.schema.properties;if(!a2(X.query))for(let[b,c]of Object.entries(R)){let t=c,B=t.type==="array"||!!t.anyOf?.some((d)=>d.type==="string"&&d.format==="ArrayString");if(t&&m6.optional in t&&t.type==="array"&&t.items)t=t.items;let{type:K,anyOf:L}=t;F.push({key:b,isArray:B,isNestedObjectArray:B&&t.items?.type==="object"||!!t.items?.anyOf?.some((d)=>d.type==="object"||d.type==="array"),isObject:K==="object"||L?.some((d)=>d.type==="string"&&d.format==="ArrayString"),anyOf:!!L})}}if(!F.length)M+="if(c.qi===-1){c.query={}}else{c.query=parseQueryFromURL(c.url.slice(c.qi + 1))}";else{M+=`if(c.qi!==-1){let url='&'+c.url.slice(c.qi + 1)
|
|
62
|
+
`;let R=0;for(let{key:b,isArray:c,isObject:t,isNestedObjectArray:B,anyOf:K}of F){let L=(R===0?"let ":"")+`memory=url.indexOf('&${b}=')
|
|
63
|
+
let a${R}
|
|
64
|
+
`;if(c)if(M+=L,B)M+=`while(memory!==-1){const start=memory+${b.length+2}
|
|
62
65
|
memory=url.indexOf('&',start)
|
|
63
|
-
if(a${
|
|
64
|
-
a${
|
|
66
|
+
if(a${R}===undefined)
|
|
67
|
+
a${R}=''
|
|
65
68
|
else
|
|
66
|
-
a${
|
|
69
|
+
a${R}+=','
|
|
67
70
|
let temp
|
|
68
|
-
if(memory===-1)temp=decodeURIComponent(url.slice(start).replace(
|
|
69
|
-
else temp=decodeURIComponent(url.slice(start, memory).replace(
|
|
70
|
-
const charCode
|
|
71
|
-
if(charCode
|
|
71
|
+
if(memory===-1)temp=decodeURIComponent(url.slice(start).replace(/\\+/g,' '))
|
|
72
|
+
else temp=decodeURIComponent(url.slice(start, memory).replace(/\\+/g,' '))
|
|
73
|
+
const charCode=temp.charCodeAt(0)
|
|
74
|
+
if(charCode!==91&&charCode !== 123)
|
|
72
75
|
temp='"'+temp+'"'
|
|
73
|
-
a${
|
|
74
|
-
if(memory
|
|
75
|
-
memory=url.indexOf('&${
|
|
76
|
-
if(memory
|
|
76
|
+
a${R}+=temp
|
|
77
|
+
if(memory===-1)break
|
|
78
|
+
memory=url.indexOf('&${b}=',memory)
|
|
79
|
+
if(memory===-1)break}try{if(a${R}.charCodeAt(0)===91)a${R} = JSON.parse(a${R})
|
|
77
80
|
else
|
|
78
|
-
a${
|
|
79
|
-
`;else
|
|
81
|
+
a${R}=JSON.parse('['+a${R}+']')}catch{}
|
|
82
|
+
`;else M+=`while(memory!==-1){const start=memory+${b.length+2}
|
|
80
83
|
memory=url.indexOf('&',start)
|
|
81
|
-
if(a${
|
|
82
|
-
if(memory===-1){
|
|
83
|
-
|
|
84
|
-
|
|
84
|
+
if(a${R}===undefined)a${R}=[]
|
|
85
|
+
if(memory===-1){const temp=decodeURIComponent(url.slice(start)).replace(/\\+/g,' ')
|
|
86
|
+
if(temp.includes(',')){a${R}=a${R}.concat(temp.split(','))}else{a${R}.push(decodeURIComponent(url.slice(start)).replace(/\\+/g,' '))}
|
|
87
|
+
break}else{const temp=decodeURIComponent(url.slice(start, memory)).replace(/\\+/g,' ')
|
|
88
|
+
if(temp.includes(',')){a${R}=a${R}.concat(temp.split(','))}else{a${R}.push(temp)}
|
|
89
|
+
}memory=url.indexOf('&${b}=',memory)
|
|
85
90
|
if(memory===-1) break
|
|
86
|
-
}`;else if(
|
|
91
|
+
}`;else if(t)M+=L+`if(memory!==-1){const start=memory+${b.length+2}
|
|
87
92
|
memory=url.indexOf('&',start)
|
|
88
|
-
if(memory===-1)a${
|
|
93
|
+
if(memory===-1)a${R}=decodeURIComponent(url.slice(start).replace(/\\+/g,' '))else a${R}=decodeURIComponent(url.slice(start,memory).replace(/\\+/g,' '))if(a${R}!==undefined)try{a${R}=JSON.parse(a${R})}catch{}}`;else{if(M+=L+`if(memory!==-1){const start=memory+${b.length+2}
|
|
89
94
|
memory=url.indexOf('&',start)
|
|
90
|
-
if(memory===-1)a${
|
|
91
|
-
else{a${
|
|
92
|
-
let deepMemory=url.indexOf('&${
|
|
93
|
-
if(deepMemory!==-1){a${
|
|
95
|
+
if(memory===-1)a${R}=decodeURIComponent(url.slice(start).replace(/\\+/g,' '))
|
|
96
|
+
else{a${R}=decodeURIComponent(url.slice(start,memory).replace(/\\+/g,' '))`,K)M+=`
|
|
97
|
+
let deepMemory=url.indexOf('&${b}=',memory)
|
|
98
|
+
if(deepMemory!==-1){a${R}=[a${R}]
|
|
94
99
|
let first=true
|
|
95
|
-
while(true){const start=deepMemory+${
|
|
100
|
+
while(true){const start=deepMemory+${b.length+2}
|
|
96
101
|
if(first)first=false
|
|
97
102
|
else deepMemory = url.indexOf('&', start)
|
|
98
103
|
let value
|
|
99
|
-
if(deepMemory===-1)value=
|
|
100
|
-
else value=
|
|
104
|
+
if(deepMemory===-1)value=url.slice(start).replace(/\\+/g,' ')
|
|
105
|
+
else value=url.slice(start, deepMemory).replace(/\\+/g,' ')
|
|
106
|
+
value=decodeURIComponent(value)
|
|
107
|
+
if(value===null){if(deepMemory===-1){break}else{continue}}
|
|
101
108
|
const vStart=value.charCodeAt(0)
|
|
102
109
|
const vEnd=value.charCodeAt(value.length - 1)
|
|
103
110
|
if((vStart===91&&vEnd===93)||(vStart===123&&vEnd===125))
|
|
104
|
-
try{a${
|
|
105
|
-
`}
|
|
106
|
-
`}}let
|
|
107
|
-
`;let
|
|
108
|
-
isParsing=true
|
|
111
|
+
try{a${R}.push(JSON.parse(value))}catch{a${R}.push(value)}if(deepMemory===-1)break}}`;M+="}}"}R++,M+=`
|
|
112
|
+
`}M+="c.query={"+F.map(({key:b},c)=>`'${b}':a${c}`).join(",")+"}",M+=`} else c.query = {}
|
|
113
|
+
`}}let W6=typeof Z==="function"&&a0(Z),I2=O||W.afterResponse?.length?"c.response= ":"",K6=V||a||W6||!!W.parse?.length||!!W.afterHandle?.some(a0)||!!W.beforeHandle?.some(a0)||!!W.transform?.some(a0)||!!W.mapResponse?.some(a0),r5=(typeof Z==="function"?m8(Z):!1)||!!W.beforeHandle?.some(m8)||!!W.afterHandle?.some(m8)||!!W.transform?.some(m8),W1=A.cookie||A.set||f||O||X.response||G&&K0||r5,S0=Y.mapResponseContext?`,${Y.mapResponseContext}`:"";if(O||A.route)M+=`c.route=\`${w}\`
|
|
114
|
+
`;let x2=n0("parse",{total:W.parse?.length});if(a){let F=R1(X.body),R=!!W.parse?.length||A.body||X.body;if(Y.parser.declare)M+=Y.parser.declare;M+=`
|
|
115
|
+
isParsing=true
|
|
116
|
+
`;let b=typeof W.parse==="string"?W.parse:Array.isArray(W.parse)&&W.parse.length===1?typeof W.parse[0]==="string"?W.parse[0]:typeof W.parse[0].fn==="string"?W.parse[0].fn:void 0:void 0;if(b&&BG.includes(b)){let c=n0("parse",{total:W.parse?.length});switch(b){case"json":case"application/json":M+=Y.parser.json(F);break;case"text":case"text/plain":M+=Y.parser.text(F);break;case"urlencoded":case"application/x-www-form-urlencoded":M+=Y.parser.urlencoded(F);break;case"arrayBuffer":case"application/octet-stream":M+=Y.parser.arrayBuffer(F);break;case"formdata":case"multipart/form-data":M+=Y.parser.formData(F);break;default:if(b[0]in z["~parser"])M+=f?"let contentType = c.headers['content-type']":"let contentType = c.request.headers.get('content-type')",M+=`
|
|
109
117
|
if(contentType){const index=contentType.indexOf(';')
|
|
110
118
|
if(index!==-1)contentType=contentType.substring(0, index)}
|
|
111
119
|
else{contentType=''}c.contentType=contentType
|
|
112
|
-
`,
|
|
120
|
+
`,M+=`let result=parser['${b}'](c, contentType)
|
|
113
121
|
if(result instanceof Promise)result=await result
|
|
114
122
|
if(result instanceof ElysiaCustomStatusResponse)throw result
|
|
115
123
|
if(result!==undefined)c.body=result
|
|
116
124
|
delete c.contentType
|
|
117
|
-
`;break}
|
|
118
|
-
`,
|
|
125
|
+
`;break}c.resolve()}else if(R){if(M+=`
|
|
126
|
+
`,M+=f?"let contentType = c.headers['content-type']":"let contentType = c.request.headers.get('content-type')",M+=`
|
|
119
127
|
if(contentType){const index=contentType.indexOf(';')
|
|
120
128
|
if(index!==-1)contentType=contentType.substring(0, index)}
|
|
121
129
|
else{contentType=''}c.contentType=contentType
|
|
122
|
-
`,W.parse
|
|
123
|
-
`;let
|
|
124
|
-
if(!used){`;if(typeof W.parse[
|
|
125
|
-
if(${
|
|
126
|
-
if(${
|
|
127
|
-
`}
|
|
128
|
-
${
|
|
129
|
-
if(${
|
|
130
|
-
if(${
|
|
130
|
+
`,W.parse?.length)M+=`let used=false
|
|
131
|
+
`;let c=n0("parse",{total:W.parse?.length}),t=!1;if(W.parse)for(let B=0;B<W.parse.length;B++){let K=`bo${B}`;if(B!==0)M+=`
|
|
132
|
+
if(!used){`;if(typeof W.parse[B].fn==="string"){let L=c.resolveChild(W.parse[B].fn);switch(W.parse[B].fn){case"json":case"application/json":t=!0,M+=Y.parser.json(F);break;case"text":case"text/plain":t=!0,M+=Y.parser.text(F);break;case"urlencoded":case"application/x-www-form-urlencoded":t=!0,M+=Y.parser.urlencoded(F);break;case"arrayBuffer":case"application/octet-stream":t=!0,M+=Y.parser.arrayBuffer(F);break;case"formdata":case"multipart/form-data":t=!0,M+=Y.parser.formData(F);break;default:M+=`${K}=parser['${W.parse[B].fn}'](c,contentType)
|
|
133
|
+
if(${K} instanceof Promise)${K}=await ${K}
|
|
134
|
+
if(${K}!==undefined){c.body=${K};used=true}
|
|
135
|
+
`}L()}else{let L=c.resolveChild(W.parse[B].fn.name);M+=`let ${K}=e.parse[${B}]
|
|
136
|
+
${K}=${K}(c,contentType)
|
|
137
|
+
if(${K} instanceof Promise)${K}=await ${K}
|
|
138
|
+
if(${K}!==undefined){c.body=${K};used=true}`,L()}if(B!==0)M+="}";if(t)break}if(c.resolve(),!t){if(W.parse?.length)M+=`
|
|
131
139
|
if(!used){
|
|
132
140
|
if(!contentType) throw new ParseError()
|
|
133
|
-
`;
|
|
141
|
+
`;M+="switch(contentType){",M+=`case 'application/json':
|
|
134
142
|
`+Y.parser.json(F)+`break
|
|
135
143
|
case 'text/plain':`+Y.parser.text(F)+`break
|
|
136
144
|
case 'application/x-www-form-urlencoded':`+Y.parser.urlencoded(F)+`break
|
|
137
145
|
case 'application/octet-stream':`+Y.parser.arrayBuffer(F)+`break
|
|
138
146
|
case 'multipart/form-data':`+Y.parser.formData(F)+`break
|
|
139
|
-
`;for(let
|
|
140
|
-
if(bo${
|
|
141
|
-
if(bo${
|
|
142
|
-
if(bo${
|
|
147
|
+
`;for(let B of Object.keys(z["~parser"]))M+=`case '${B}':let bo${B}=parser['${B}'](c,contentType)
|
|
148
|
+
if(bo${B} instanceof Promise)bo${B}=await bo${B}
|
|
149
|
+
if(bo${B} instanceof ElysiaCustomStatusResponse)throw result
|
|
150
|
+
if(bo${B}!==undefined)c.body=bo${B}
|
|
143
151
|
break
|
|
144
|
-
`;if(W.parse
|
|
145
|
-
delete c.contentType`,
|
|
152
|
+
`;if(W.parse?.length)M+="}";M+="}"}}M+=`
|
|
153
|
+
delete c.contentType`,M+=`
|
|
146
154
|
isParsing=false
|
|
147
|
-
`}if(
|
|
148
|
-
`;for(let
|
|
149
|
-
`:`transformed=transform[${
|
|
150
|
-
`,
|
|
155
|
+
`}if(x2.resolve(),W?.transform){let F=n0("transform",{total:W.transform.length});if(W.transform.length)M+=`let transformed
|
|
156
|
+
`;for(let R=0;R<W.transform.length;R++){let b=W.transform[R],c=F.resolveChild(b.fn.name);if(M+=a0(b)?`transformed=await e.transform[${R}](c)
|
|
157
|
+
`:`transformed=e.transform[${R}](c)
|
|
158
|
+
`,b.subType==="mapDerive")M+=`if(transformed instanceof ElysiaCustomStatusResponse)throw transformed
|
|
151
159
|
else{transformed.request=c.request
|
|
152
160
|
transformed.store=c.store
|
|
153
161
|
transformed.qi=c.qi
|
|
@@ -156,30 +164,30 @@ transformed.url=c.url
|
|
|
156
164
|
transformed.redirect=c.redirect
|
|
157
165
|
transformed.set=c.set
|
|
158
166
|
transformed.error=c.error
|
|
159
|
-
c=transformed}`;else
|
|
167
|
+
c=transformed}`;else M+=`if(transformed instanceof ElysiaCustomStatusResponse)throw transformed
|
|
160
168
|
else Object.assign(c,transformed)
|
|
161
|
-
`;
|
|
162
|
-
`;if(
|
|
163
|
-
`}if(
|
|
164
|
-
`;if(
|
|
165
|
-
`}if(
|
|
166
|
-
`}if(
|
|
167
|
-
`;if(
|
|
168
|
-
`}if(
|
|
169
|
-
`;if(
|
|
170
|
-
`;let F=
|
|
171
|
-
`;if(
|
|
172
|
-
else c.body=${
|
|
173
|
-
|
|
174
|
-
`}if(
|
|
169
|
+
`;c()}F.resolve()}if(X){if(X.headers){if(Y0&&"Clean"in X.headers&&!a2(X.headers))M+=`c.headers=validator.headers.Clean(c.headers);
|
|
170
|
+
`;if(_6("default",X.headers))for(let[F,R]of Object.entries(o.Default(X.headers.schema,{}))){let b=typeof R==="object"?JSON.stringify(R):typeof R==="string"?`'${R}'`:R;if(b!==void 0)M+=`c.headers['${F}']??=${b}
|
|
171
|
+
`}if(R1(X.headers))M+="if(isNotEmpty(c.headers)){";if(M+="if(validator.headers.Check(c.headers) === false){"+h0("headers")+"}",i2(X.headers.schema))M+=`c.headers=validator.headers.Decode(c.headers)
|
|
172
|
+
`;if(R1(X.headers))M+="}"}if(X.params){if(_6("default",X.params))for(let[F,R]of Object.entries(o.Default(X.params.schema,{}))){let b=typeof R==="object"?JSON.stringify(R):typeof R==="string"?`'${R}'`:R;if(b!==void 0)M+=`c.params['${F}']??=${b}
|
|
173
|
+
`}if(M+="if(validator.params.Check(c.params)===false){"+h0("params")+"}",i2(X.params.schema))M+=`c.params=validator.params.Decode(c.params)
|
|
174
|
+
`}if(X.query){if(Y0&&"Clean"in X.query&&!a2(X.query))M+=`c.query=validator.query.Clean(c.query)
|
|
175
|
+
`;if(_6("default",X.query))for(let[F,R]of Object.entries(o.Default(X.query.schema,{}))){let b=typeof R==="object"?JSON.stringify(R):typeof R==="string"?`'${R}'`:R;if(b!==void 0)M+=`if(c.query['${F}']===undefined)c.query['${F}']=${b}
|
|
176
|
+
`}if(R1(X.query))M+="if(isNotEmpty(c.query)){";if(M+="if(validator.query.Check(c.query)===false){"+h0("query")+"}",i2(X.query.schema))M+=`c.query=validator.query.Decode(Object.assign({},c.query))
|
|
177
|
+
`;if(R1(X.query))M+="}"}if(X.body){if(Y0&&"Clean"in X.body&&!a2(X.body))M+=`c.body=validator.body.Clean(c.body)
|
|
178
|
+
`;let F=i2(X.body.schema);if(F||R1(X.body))M+=`const isNotEmptyObject=c.body&&(typeof c.body==="object"&&isNotEmpty(c.body))
|
|
179
|
+
`;if(_6("default",X.body)){let R=X.body.schema,b=o.Default(R,R.type==="object"||R[m6.kind]==="Import"&&R.$defs[R.$ref][m6.kind]==="Object"?{}:void 0),c=typeof b==="object"?JSON.stringify(b):typeof b==="string"?`'${b}'`:b;if(M+="if(validator.body.Check(c.body)===false){",b!==void 0&&b!==null)M+=`if(typeof c.body==='object')c.body=Object.assign(${c},c.body)
|
|
180
|
+
else c.body=${c}
|
|
181
|
+
`;if(R1(X.body))M+="if(isNotEmptyObject&&validator.body.Check(c.body)===false){"+h0("body")+"}";else M+="if(validator.body.Check(c.body)===false){"+h0("body")+"}";M+="}"}else if(R1(X.body))M+="if(isNotEmptyObject&&validator.body.Check(c.body)===false){"+h0("body")+"}";else M+="if(validator.body.Check(c.body)===false){"+h0("body")+"}";if(F)M+=`if(isNotEmptyObject)c.body=validator.body.Decode(c.body)
|
|
182
|
+
`}if(k&&z1(k?.schema?.properties??k?.schema?.schema??{})){if(M+=`const cookieValue={}
|
|
175
183
|
for(const [key,value] of Object.entries(c.cookie))cookieValue[key]=value.value
|
|
176
|
-
`,
|
|
177
|
-
`;if(
|
|
178
|
-
`;if(
|
|
184
|
+
`,_6("default",k))for(let[F,R]of Object.entries(o.Default(k.schema,{})))M+=`cookieValue['${F}'] = ${typeof R==="object"?JSON.stringify(R):R}
|
|
185
|
+
`;if(R1(X.cookie))M+="if(isNotEmpty(c.cookie)){";if(M+="if(validator.cookie.Check(cookieValue)===false){"+h0("cookie","cookieValue")+"}",i2(X.cookie.schema))M+=`for(const [key,value] of Object.entries(validator.cookie.Decode(cookieValue)))c.cookie[key].value=value
|
|
186
|
+
`;if(R1(X.cookie))M+="}"}}if(W?.beforeHandle){let F=n0("beforeHandle",{total:W.beforeHandle.length}),R=!1;for(let b=0;b<W.beforeHandle.length;b++){let c=W.beforeHandle[b],t=F.resolveChild(c.fn.name),B=r4(c);if(c.subType==="resolve"||c.subType==="mapResolve"){if(!R)R=!0,M+=`
|
|
179
187
|
let resolved
|
|
180
|
-
`;if(
|
|
181
|
-
`:`resolved=beforeHandle[${
|
|
182
|
-
`,
|
|
188
|
+
`;if(M+=a0(c)?`resolved=await e.beforeHandle[${b}](c);
|
|
189
|
+
`:`resolved=e.beforeHandle[${b}](c);
|
|
190
|
+
`,c.subType==="mapResolve")M+=`if(resolved instanceof ElysiaCustomStatusResponse)throw resolved
|
|
183
191
|
else{resolved.request = c.request
|
|
184
192
|
resolved.store = c.store
|
|
185
193
|
resolved.qi = c.qi
|
|
@@ -188,135 +196,135 @@ resolved.url = c.url
|
|
|
188
196
|
resolved.redirect = c.redirect
|
|
189
197
|
resolved.set = c.set
|
|
190
198
|
resolved.error = c.error
|
|
191
|
-
c = resolved}`;else
|
|
199
|
+
c = resolved}`;else M+=`if(resolved instanceof ElysiaCustomStatusResponse)throw resolved
|
|
192
200
|
else Object.assign(c, resolved)
|
|
193
|
-
`}else if(
|
|
194
|
-
`:`beforeHandle[${
|
|
195
|
-
`,
|
|
196
|
-
`:`be=beforeHandle[${
|
|
197
|
-
`,
|
|
198
|
-
`,!
|
|
199
|
-
`:`afterHandle[${
|
|
200
|
-
`;else
|
|
201
|
-
`:`af = afterHandle[${
|
|
202
|
-
`,
|
|
203
|
-
`;
|
|
204
|
-
`;for(let
|
|
205
|
-
if(mr!==undefined)be=c.response=mr}`,
|
|
206
|
-
`}}F.resolve()}if(W?.
|
|
207
|
-
`:`let r=c.response=${
|
|
208
|
-
`;else
|
|
209
|
-
`:`let r=${
|
|
210
|
-
`;F.resolve();let
|
|
211
|
-
`:`afterHandle[${
|
|
212
|
-
`,
|
|
213
|
-
`:`af=afterHandle[${
|
|
214
|
-
`,
|
|
215
|
-
|
|
201
|
+
`}else if(!B)M+=a0(c)?`await e.beforeHandle[${b}](c)
|
|
202
|
+
`:`e.beforeHandle[${b}](c)
|
|
203
|
+
`,t();else{if(M+=a0(c)?`be=await e.beforeHandle[${b}](c)
|
|
204
|
+
`:`be=e.beforeHandle[${b}](c)
|
|
205
|
+
`,t("be"),M+="if(be!==undefined){",F.resolve(),W.afterHandle?.length){n0("handle",{name:G?Z.name:void 0}).resolve();let L=n0("afterHandle",{total:W.afterHandle.length});for(let d=0;d<W.afterHandle.length;d++){let I=W.afterHandle[d],h=r4(I),C0=L.resolveChild(I.fn.name);if(M+=`c.response = be
|
|
206
|
+
`,!h)M+=a0(I.fn)?`await e.afterHandle[${d}](c, be)
|
|
207
|
+
`:`e.afterHandle[${d}](c, be)
|
|
208
|
+
`;else M+=a0(I.fn)?`af = await e.afterHandle[${d}](c)
|
|
209
|
+
`:`af = e.afterHandle[${d}](c)
|
|
210
|
+
`,M+=`if(af!==undefined) c.response=be=af
|
|
211
|
+
`;C0("af")}L.resolve()}if(X.response)M+=U6("be");let K=n0("mapResponse",{total:W.mapResponse?.length});if(W.mapResponse?.length){M+=`c.response=be
|
|
212
|
+
`;for(let L=0;L<W.mapResponse.length;L++){let d=W.mapResponse[L],I=K.resolveChild(d.fn.name);M+=`if(mr===undefined){mr=${P4(d)?"await ":""}e.mapResponse[${L}](c)
|
|
213
|
+
if(mr!==undefined)be=c.response=mr}`,I()}}K.resolve(),M+=e,M+=`return mapEarlyResponse(${I2}be,c.set${S0})}
|
|
214
|
+
`}}F.resolve()}if(W.afterHandle?.length){let F=n0("handle",{name:G?Z.name:void 0});if(W.afterHandle.length)M+=W6?`let r=c.response=await ${S}
|
|
215
|
+
`:`let r=c.response=${S}
|
|
216
|
+
`;else M+=W6?`let r=await ${S}
|
|
217
|
+
`:`let r=${S}
|
|
218
|
+
`;F.resolve();let R=n0("afterHandle",{total:W.afterHandle.length});for(let c=0;c<W.afterHandle.length;c++){let t=W.afterHandle[c],B=r4(t),K=R.resolveChild(t.fn.name);if(!B)M+=a0(t.fn)?`await e.afterHandle[${c}](c)
|
|
219
|
+
`:`e.afterHandle[${c}](c)
|
|
220
|
+
`,K();else if(M+=a0(t.fn)?`af=await e.afterHandle[${c}](c)
|
|
221
|
+
`:`af=e.afterHandle[${c}](c)
|
|
222
|
+
`,K("af"),X.response)M+="if(af!==undefined){",R.resolve(),M+=U6("af"),M+="c.response=af}";else M+="if(af!==undefined){",R.resolve(),M+="c.response=af}"}if(R.resolve(),M+=`r=c.response
|
|
223
|
+
`,X.response)M+=U6();M+=e;let b=n0("mapResponse",{total:W.mapResponse?.length});if(W.mapResponse?.length)for(let c=0;c<W.mapResponse.length;c++){let t=W.mapResponse[c],B=b.resolveChild(t.fn.name);M+=`mr=${P4(t)?"await ":""}e.mapResponse[${c}](c)
|
|
216
224
|
if(mr!==undefined)r=c.response=mr
|
|
217
|
-
|
|
218
|
-
`;else
|
|
219
|
-
`}else{let F=
|
|
220
|
-
`:`let r=${
|
|
221
|
-
`,F.resolve()
|
|
225
|
+
`,B()}if(b.resolve(),W1)M+=`return mapResponse(${I2}r,c.set${S0})
|
|
226
|
+
`;else M+=`return mapCompactResponse(${I2}r${S0})
|
|
227
|
+
`}else{let F=n0("handle",{name:G?Z.name:void 0});if(X.response||W.mapResponse?.length){if(M+=W6?`let r=await ${S}
|
|
228
|
+
`:`let r=${S}
|
|
229
|
+
`,F.resolve(),X.response)M+=U6();n0("afterHandle").resolve();let R=n0("mapResponse",{total:W.mapResponse?.length});if(W.mapResponse?.length){M+=`
|
|
222
230
|
c.response=r
|
|
223
|
-
`;for(let
|
|
224
|
-
if(mr===undefined){mr=${
|
|
231
|
+
`;for(let b=0;b<W.mapResponse.length;b++){let c=W.mapResponse[b],t=R.resolveChild(c.fn.name);M+=`
|
|
232
|
+
if(mr===undefined){mr=${P4(c)?"await ":""}e.mapResponse[${b}](c)
|
|
225
233
|
if(mr!==undefined)r=c.response=mr}
|
|
226
|
-
`,
|
|
227
|
-
`;else if(
|
|
228
|
-
`;else
|
|
229
|
-
`}else if(
|
|
230
|
-
`:`let r=${
|
|
231
|
-
`,F.resolve(),
|
|
232
|
-
`;for(let
|
|
233
|
-
if(mr!==undefined)r=c.response=mr}`,
|
|
234
|
-
`;else
|
|
235
|
-
`}else{F.resolve();let
|
|
236
|
-
else return ${
|
|
237
|
-
`:`return ${
|
|
238
|
-
`;else if(
|
|
239
|
-
`;else
|
|
240
|
-
`}}if(
|
|
241
|
-
}catch(error){`,
|
|
242
|
-
`;if(!
|
|
234
|
+
`,t()}}if(R.resolve(),M+=e,Z instanceof Response)M+=A.set?`if(isNotEmpty(c.set.headers)||c.set.status!==200||c.set.redirect||c.set.cookie)return mapResponse(${I2}${S}.clone(),c.set${S0})else return ${S}.clone()`:`return ${S}.clone()`,M+=`
|
|
235
|
+
`;else if(W1)M+=`return mapResponse(${I2}r,c.set${S0})
|
|
236
|
+
`;else M+=`return mapCompactResponse(${I2}r${S0})
|
|
237
|
+
`}else if(V||O){M+=W6?`let r=await ${S}
|
|
238
|
+
`:`let r=${S}
|
|
239
|
+
`,F.resolve(),n0("afterHandle").resolve();let R=n0("mapResponse",{total:W.mapResponse?.length});if(W.mapResponse?.length){M+=`c.response= r
|
|
240
|
+
`;for(let b=0;b<W.mapResponse.length;b++){let c=W.mapResponse[b],t=R.resolveChild(c.fn.name);M+=`if(mr===undefined){mr=${P4(c)?"await ":""}e.mapResponse[${b}](c)
|
|
241
|
+
if(mr!==undefined)r=c.response=mr}`,t()}}if(R.resolve(),M+=e,W1)M+=`return mapResponse(${I2}r,c.set${S0})
|
|
242
|
+
`;else M+=`return mapCompactResponse(${I2}r${S0})
|
|
243
|
+
`}else{F.resolve();let R=W6?`await ${S}`:S;if(n0("afterHandle").resolve(),Z instanceof Response)M+=A.set?`if(isNotEmpty(c.set.headers)||c.set.status!==200||c.set.redirect||c.set.cookie)return mapResponse(${I2}${S}.clone(),c.set${S0})
|
|
244
|
+
else return ${S}.clone()
|
|
245
|
+
`:`return ${S}.clone()
|
|
246
|
+
`;else if(W1)M+=`return mapResponse(${I2}${R},c.set${S0})
|
|
247
|
+
`;else M+=`return mapCompactResponse(${I2}${R}${S0})
|
|
248
|
+
`}}if(M+=`
|
|
249
|
+
}catch(error){`,a)M+=`if(isParsing)error=new ParseError()
|
|
250
|
+
`;if(!K6)M+="return(async()=>{";if(M+=`const set=c.set
|
|
243
251
|
if(!set.status||set.status<300)set.status=error?.status||500
|
|
244
|
-
`,
|
|
245
|
-
`;let
|
|
246
|
-
if(error instanceof TypeBoxError){c.code="VALIDATION"
|
|
247
|
-
c.set.status=422}else{c.code=error.code??error[ERROR_CODE]??"UNKNOWN"}
|
|
248
|
-
`;
|
|
249
|
-
`;
|
|
252
|
+
`,O&&W.trace)for(let F=0;F<W.trace.length;F++)M+=`report${F}?.resolve(error);reportChild${F}?.(error)
|
|
253
|
+
`;let X6=n0("error",{total:W.error?.length});if(W.error?.length){if(M+=`c.error=error
|
|
254
|
+
`,C)M+=`if(error instanceof TypeBoxError){c.code="VALIDATION"
|
|
255
|
+
c.set.status=422}else{c.code=error.code??error[ERROR_CODE]??"UNKNOWN"}`;else M+=`c.code=error.code??error[ERROR_CODE]??"UNKNOWN"
|
|
256
|
+
`;M+=`let er
|
|
257
|
+
`;for(let F=0;F<W.error.length;F++){let R=X6.resolveChild(W.error[F].fn.name);if(a0(W.error[F]))M+=`er=await e.error[${F}](c)
|
|
258
|
+
`;else M+=`er=e.error[${F}](c)
|
|
250
259
|
if(er instanceof Promise)er=await er
|
|
251
|
-
`;
|
|
252
|
-
er=
|
|
260
|
+
`;R();let b=n0("mapResponse",{total:W.mapResponse?.length});if(W.mapResponse?.length)for(let c=0;c<W.mapResponse.length;c++){let t=W.mapResponse[c],B=b.resolveChild(t.fn.name);M+=`c.response=er
|
|
261
|
+
er=e.mapResponse[${c}](c)
|
|
253
262
|
if(er instanceof Promise)er=await er
|
|
254
|
-
|
|
255
|
-
`,
|
|
256
|
-
`;
|
|
257
|
-
await afterResponse[${
|
|
258
|
-
`,
|
|
259
|
-
const trace=
|
|
260
|
-
return ${
|
|
261
|
-
`;if(W.afterHandle
|
|
262
|
-
`;if(W.mapResponse
|
|
263
|
-
`;if(
|
|
263
|
+
`,B()}if(b.resolve(),M+=`er=mapEarlyResponse(er,set${S0})
|
|
264
|
+
`,M+="if(er){",O&&W.trace){for(let c=0;c<W.trace.length;c++)M+=`report${c}.resolve()
|
|
265
|
+
`;X6.resolve()}M+="return er}"}}if(X6.resolve(),M+="return handleError(c,error,true)",!K6)M+="})()";if(M+="}",N||O){if(M+="finally{ ",!K6)M+=";(async()=>{";let F=n0("afterResponse",{total:W.afterResponse?.length});if(N&&W.afterResponse)for(let R=0;R<W.afterResponse.length;R++){let b=F.resolveChild(W.afterResponse[R].fn.name);M+=`
|
|
266
|
+
await e.afterResponse[${R}](c)
|
|
267
|
+
`,b()}if(F.resolve(),!K6)M+="})()";M+="}"}let Z6=Y.inject?Object.keys(Y.inject).join(",")+",":"",X1="const {handler,handleError,hooks:e, "+Q2("validator,",C)+"mapResponse,mapCompactResponse,mapEarlyResponse,isNotEmpty,utils:{"+Q2("parseQuery,",a)+Q2("parseQueryFromURL,",g)+"},error:{"+Q2("ValidationError,",C)+"InternalServerError,"+Q2("ParseError",a)+"},schema,definitions,ERROR_CODE,"+Q2("parseCookie,",V)+Q2("signCookie,",V)+Q2("decodeURIComponent,",g)+"ElysiaCustomStatusResponse,"+Q2("ELYSIA_TRACE,",O)+Q2("ELYSIA_REQUEST_ID,",O)+Q2("parser,",W.parse?.length)+Q2("getServer,",A.server)+Z6+Q2("TypeBoxError",C)+`}=hooks
|
|
268
|
+
const trace=e.trace?.map(x=>typeof x==='function'?x:x.fn)??[]
|
|
269
|
+
return ${K6?"async ":""}function handle(c){`;if(W.beforeHandle?.length)X1+=`let be
|
|
270
|
+
`;if(W.afterHandle?.length)X1+=`let af
|
|
271
|
+
`;if(W.mapResponse?.length)X1+=`let mr
|
|
272
|
+
`;if($)X1+=`c.schema = schema
|
|
264
273
|
c.defs = definitions
|
|
265
|
-
`;
|
|
274
|
+
`;X1+=M+"}";try{if(Q)return Function("hooks",X1);return Function("hooks",X1)({handler:Z,hooks:FU(W),validator:C?X:void 0,handleError:z.handleError,mapResponse:J.mapResponse,mapCompactResponse:J.mapCompactResponse,mapEarlyResponse:J.mapEarlyResponse,isNotEmpty:z1,utils:{parseQuery:a?o8:void 0,parseQueryFromURL:g?YG:void 0},error:{ValidationError:C?r:void 0,InternalServerError:tU,ParseError:a?oU:void 0},schema:z.router.history,definitions:z.definitions.type,ERROR_CODE:s8,parseCookie:V?WW:void 0,signCookie:V?l8:void 0,decodeURIComponent:g?S6:void 0,ElysiaCustomStatusResponse:b1,ELYSIA_TRACE:O?ww:void 0,ELYSIA_REQUEST_ID:O?z5:void 0,getServer:()=>z.getServer(),TypeBoxError:C?n:void 0,parser:z["~parser"],...Y.inject})}catch(F){let R=FU(W);console.log("[Composer] failed to generate optimized handler"),console.log("---"),console.log({handler:typeof Z==="function"?Z.toString():Z,instruction:X1,hooks:{...R,transform:R?.transform?.map?.((b)=>b.toString()),resolve:R?.resolve?.map?.((b)=>b.toString()),beforeHandle:R?.beforeHandle?.map?.((b)=>b.toString()),afterHandle:R?.afterHandle?.map?.((b)=>b.toString()),mapResponse:R?.mapResponse?.map?.((b)=>b.toString()),parse:R?.parse?.map?.((b)=>b.toString()),error:R?.error?.map?.((b)=>b.toString()),afterResponse:R?.afterResponse?.map?.((b)=>b.toString()),stop:R?.stop?.map?.((b)=>b.toString())},validator:X,definitions:z.definitions.type,error:F,fnLiteral:M}),console.log("---"),process.exit(1)}},tz=(z,{asManifest:w=!1}={})=>{let U=z["~adapter"].composeGeneralHandler;z.router.http.build();let W=U.error404(!!z.event.request?.length,!!z.event.error?.length),X=z.event.trace?.length,Z="",$=z.router,A="const route=router.find(r.method,p)";A+=$.http.root.ALL?`??router.find("ALL",p)
|
|
266
275
|
`:`
|
|
267
|
-
`,
|
|
276
|
+
`,A+=W.code,A+=`
|
|
268
277
|
c.params=route.params
|
|
269
278
|
if(route.store.handler)return route.store.handler(c)
|
|
270
279
|
return (route.store.handler=route.store.compile())(c)
|
|
271
|
-
`;let Q="";for(let[
|
|
272
|
-
`+(
|
|
273
|
-
const {app,mapEarlyResponse,NotFoundError,randomId,handleError,error,redirect
|
|
280
|
+
`;let Q="";for(let[N,O]of Object.entries($.static.http.map)){if(Q+=`case'${N}':`,z.config.strictPath!==!0)Q+=`case'${S4(N)}':`;let M=p4(N);if(N!==M)Q+=`case'${M}':`;Q+=`switch(r.method){${O.code}
|
|
281
|
+
`+(O.all??"default: break map")+"}"}let Y=!!z.event.request?.some(a0),J=U.inject?Object.keys(U.inject).join(",")+",":"";if(Z+=`
|
|
282
|
+
const {app,mapEarlyResponse,NotFoundError,randomId,handleError,error,redirect,`+Q2("ELYSIA_TRACE,",X)+Q2("ELYSIA_REQUEST_ID,",X)+J+`}=data
|
|
274
283
|
const store=app.singleton.store
|
|
275
284
|
const decorator=app.singleton.decorator
|
|
276
285
|
const staticRouter=app.router.static.http
|
|
277
286
|
const ht=app.router.history
|
|
278
|
-
const wsRouter=app.router.ws
|
|
279
287
|
const router=app.router.http
|
|
280
|
-
const trace=app.event.trace
|
|
288
|
+
const trace=app.event.trace?.map(x=>typeof x==='function'?x:x.fn)??[]
|
|
281
289
|
const notFound=new NotFoundError()
|
|
282
290
|
const hoc=app.extender.higherOrderFunctions.map(x=>x.fn)
|
|
283
|
-
`,
|
|
284
|
-
`;if(W
|
|
285
|
-
`;if(
|
|
286
|
-
`;if(
|
|
287
|
-
`;let
|
|
288
|
-
`,
|
|
289
|
-
`;else
|
|
290
|
-
`,
|
|
291
|
+
`,z.event.request?.length)Z+=`const onRequest=app.event.request.map(x=>x.fn)
|
|
292
|
+
`;if(Z+=W.declare,z.event.trace?.length)Z+="const "+z.event.trace.map((N,O)=>`tr${O}=app.event.trace[${O}].fn`).join(",")+`
|
|
293
|
+
`;if(Z+=`${Y?"async ":""}function map(${U.parameters}){`,z.event.request?.length)Z+=`let re
|
|
294
|
+
`;if(Z+=U.createContext(z),z.event.trace?.length)Z+="c[ELYSIA_TRACE]=["+z.event.trace.map((N,O)=>`tr${O}(c)`).join(",")+`]
|
|
295
|
+
`;let G=Uw({trace:z.event.trace,addFn(N){Z+=N}})("request",{total:z.event.request?.length});if(z.event.request?.length){Z+="try{";for(let N=0;N<z.event.request.length;N++){let O=z.event.request[N],M=r4(O),C=a0(O),g=G.resolveChild(z.event.request[N].fn.name);if(M)Z+=`re=mapEarlyResponse(${C?"await ":""}onRequest[${N}](c),c.set)
|
|
296
|
+
`,g("re"),Z+=`if(re!==undefined)return re
|
|
297
|
+
`;else Z+=`${C?"await ":""}onRequest[${N}](c)
|
|
298
|
+
`,g()}Z+="}catch(error){return app.handleError(c,error,false)}"}if(G.resolve(),Z+=U.websocket(z),Z+=`
|
|
291
299
|
map:switch(p){
|
|
292
|
-
`+Q+"default:break}"+
|
|
293
|
-
`,
|
|
294
|
-
`,
|
|
300
|
+
`+Q+"default:break}"+A+`}
|
|
301
|
+
`,z.extender.higherOrderFunctions.length){let N="map";for(let O=0;O<z.extender.higherOrderFunctions.length;O++)N=`hoc[${O}](${N},${U.parameters})`;Z+=`return function hocMap(${U.parameters}){return ${N}(${U.parameters})}`}else Z+="return map";let S=AW(z);return z.handleError=S,Function("data",Z)({app:z,mapEarlyResponse:z["~adapter"].handler.mapEarlyResponse,NotFoundError:zw,randomId:uU,handleError:S,error:mU,redirect:nU,ELYSIA_TRACE:X?ww:void 0,ELYSIA_REQUEST_ID:X?z5:void 0,...U.inject})},AW=(z)=>{let w=z.event,U="",W=z["~adapter"].composeError,X=W.inject?Object.keys(W.inject).join(",")+",":"",Z=!!z.event.trace?.length;if(U+="const {app:{event:{error:onErrorContainer,afterResponse:resContainer,mapResponse:_onMapResponse,trace:_trace}},mapResponse,ERROR_CODE,ElysiaCustomStatusResponse,"+Q2("ELYSIA_TRACE,",Z)+Q2("ELYSIA_REQUEST_ID,",Z)+X+`}=inject
|
|
302
|
+
`,U+=`const trace=_trace?.map(x=>typeof x==='function'?x:x.fn)??[]
|
|
295
303
|
const onMapResponse=[]
|
|
296
|
-
for(let i=0;i<_onMapResponse.length;i++)onMapResponse.push(_onMapResponse[i].fn??_onMapResponse[i])
|
|
304
|
+
if(_onMapResponse)for(let i=0;i<_onMapResponse.length;i++)onMapResponse.push(_onMapResponse[i].fn??_onMapResponse[i])
|
|
297
305
|
delete _onMapResponse
|
|
298
|
-
const onError=onErrorContainer
|
|
299
|
-
const res=resContainer
|
|
300
|
-
return ${
|
|
301
|
-
`;let
|
|
306
|
+
const onError=onErrorContainer?.map(x=>x.fn)??[]
|
|
307
|
+
const res=resContainer?.map(x=>x.fn)??[]
|
|
308
|
+
return ${z.event.error?.find(a0)||z.event.mapResponse?.find(a0)?"async ":""}function(context,error,skipGlobal){`,U+="",Z)U+=`const id=context[ELYSIA_REQUEST_ID]
|
|
309
|
+
`;let $=Uw({context:"context",trace:w.trace,addFn:(Y)=>{U+=Y}});if(U+=`const set=context.set
|
|
302
310
|
let _r
|
|
303
311
|
if(!context.code)context.code=error.code??error[ERROR_CODE]
|
|
304
312
|
if(!(context.error instanceof Error))context.error=error
|
|
305
313
|
if(error instanceof ElysiaCustomStatusResponse){set.status=error.status=error.code
|
|
306
|
-
error.message=error.response}`,
|
|
307
|
-
`;if(
|
|
308
|
-
if(_r!==undefined){if(_r instanceof Response)return mapResponse(_r,set${
|
|
314
|
+
error.message=error.response}`,W.declare)U+=W.declare;let A=Z||!!w.afterResponse?.length||!!w.afterResponse?.length?"context.response = ":"";if(z.event.error)for(let Y=0;Y<z.event.error.length;Y++){let J=z.event.error[Y],G=`${a0(J)?"await ":""}onError[${Y}](context)
|
|
315
|
+
`;if(U+="if(skipGlobal!==true){",r4(J)){U+=`_r=${G}
|
|
316
|
+
if(_r!==undefined){if(_r instanceof Response)return mapResponse(_r,set${W.mapResponseContext})
|
|
309
317
|
if(_r instanceof ElysiaCustomStatusResponse){error.status=error.code
|
|
310
318
|
error.message = error.response}if(set.status===200||!set.status)set.status=error.status
|
|
311
|
-
`;let
|
|
312
|
-
`,
|
|
319
|
+
`;let S=$("mapResponse",{total:w.mapResponse?.length,name:"context"});if(w.mapResponse?.length)for(let N=0;N<w.mapResponse.length;N++){let O=w.mapResponse[N],M=S.resolveChild(O.fn.name);U+=`context.response=_r_r=${P4(O)?"await ":""}onMapResponse[${N}](context)
|
|
320
|
+
`,M()}S.resolve(),U+=`return mapResponse(${A}_r,set${W.mapResponseContext})}`}else U+=G;U+="}"}U+=`if(error.constructor.name==="ValidationError"||error.constructor.name==="TransformDecodeError"){if(error.error)error=error.error
|
|
313
321
|
set.status=error.status??422
|
|
314
|
-
`+
|
|
322
|
+
`+W.validationError+"}",U+="if(error instanceof Error){"+W.unknownError+"}";let Q=$("mapResponse",{total:w.mapResponse?.length,name:"context"});if(U+=`
|
|
315
323
|
if(!context.response)context.response=error.message??error
|
|
316
|
-
`,
|
|
317
|
-
`;for(let
|
|
318
|
-
if(mr!==undefined)error=context.response=mr}`,
|
|
319
|
-
return mapResponse(${
|
|
320
|
-
`))}return this}wrap(
|
|
321
|
-
`;else
|
|
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};
|
|
324
|
+
`,w.mapResponse?.length){U+=`let mr
|
|
325
|
+
`;for(let Y=0;Y<w.mapResponse.length;Y++){let J=w.mapResponse[Y],G=Q.resolveChild(J.fn.name);U+=`if(mr===undefined){mr=${P4(J)?"await ":""}onMapResponse[${Y}](context)
|
|
326
|
+
if(mr!==undefined)error=context.response=mr}`,G()}}return Q.resolve(),U+=`
|
|
327
|
+
return mapResponse(${A}error,set${W.mapResponseContext})}`,Function("inject",U)({app:z,mapResponse:z["~adapter"].handler.mapResponse,ERROR_CODE:s8,ElysiaCustomStatusResponse:b1,ELYSIA_TRACE:Z?ww:void 0,ELYSIA_REQUEST_ID:Z?z5:void 0,...W.inject})},oz=(z,w)=>{for(let[U,W]of Object.entries(z.schema.properties))w[U]??=W.default},hU=(z)=>{let{mapResponse:w,mapEarlyResponse:U}=z["~adapter"].handler;return async(W)=>{let X=W.url,Z=X.indexOf("/",11),$=X.indexOf("?",Z+1),A=$===-1?X.substring(Z):X.substring(Z,$),Q={cookie:{},status:200,headers:{}},Y=Object.assign({},z.singleton.decorator,{set:Q,store:z.singleton.store,request:W,path:A,qi:$,error:mU,redirect:nU});try{if(z.event.request)for(let V=0;V<z.event.request.length;V++){let k=z.event.request[V].fn,j=k(Y);if(j instanceof Promise)j=await j;if(j=U(j,Q),j)return Y.response=j}let J=z.router.dynamic.find(W.method,A)??z.router.dynamic.find("ALL",A);if(!J)throw new zw;let{handle:G,hooks:S,validator:N,content:O,route:M}=J.store,C;if(W.method!=="GET"&&W.method!=="HEAD")if(O)switch(O){case"application/json":C=await W.json();break;case"text/plain":C=await W.text();break;case"application/x-www-form-urlencoded":C=o8(await W.text());break;case"application/octet-stream":C=await W.arrayBuffer();break;case"multipart/form-data":C={};let V=await W.formData();for(let k of V.keys()){if(C[k])continue;let j=V.getAll(k);if(j.length===1)C[k]=j[0];else C[k]=j}break}else{let V=W.headers.get("content-type");if(V){let k=V.indexOf(";");if(k!==-1)V=V.slice(0,k);if(Y.contentType=V,S.parse)for(let j=0;j<S.parse.length;j++){let e=S.parse[j].fn,Y0=e(Y,V);if(Y0 instanceof Promise)Y0=await Y0;if(Y0){C=Y0;break}}if(delete Y.contentType,C===void 0)switch(V){case"application/json":C=await W.json();break;case"text/plain":C=await W.text();break;case"application/x-www-form-urlencoded":C=o8(await W.text());break;case"application/octet-stream":C=await W.arrayBuffer();break;case"multipart/form-data":C={};let j=await W.formData();for(let e of j.keys()){if(C[e])continue;let Y0=j.getAll(e);if(Y0.length===1)C[e]=Y0[0];else C[e]=Y0}break}}}Y.route=M,Y.body=C,Y.params=J?.params||void 0,Y.query=$===-1?{}:o8(X.substring($+1)),Y.headers={};for(let[V,k]of W.headers.entries())Y.headers[V]=k;let g=Object.assign({},z.config?.cookie,N?.cookie?.config),L0=W.headers.get("cookie");Y.cookie=await WW(Y.set,L0,g?{secrets:g.secrets!==void 0?typeof g.secrets==="string"?g.secrets:g.secrets.join(","):void 0,sign:g.sign===!0?!0:g.sign!==void 0?typeof g.sign==="string"?g.sign:g.sign.join(","):void 0}:void 0);let a=N?.createHeaders?.();if(a)oz(a,Y.headers);let $0=N?.createParams?.();if($0)oz($0,Y.params);let K0=N?.createQuery?.();if(K0)oz(K0,Y.query);if(S.transform)for(let V=0;V<S.transform.length;V++){let k=S.transform[V],j=k.fn(Y);if(k.subType==="derive")if(j instanceof Promise)Object.assign(Y,await j);else Object.assign(Y,j);else if(j instanceof Promise)await j}if(N){if(a){let V=structuredClone(Y.headers);for(let[k,j]of W.headers)V[k]=j;if(N.headers.Check(V)===!1)throw new r("header",N.headers,V)}else if(N.headers?.Decode)Y.headers=N.headers.Decode(Y.headers);if($0?.Check(Y.params)===!1)throw new r("params",N.params,Y.params);else if(N.params?.Decode)Y.params=N.params.Decode(Y.params);if(K0?.Check(Y.query)===!1)throw new r("query",N.query,Y.query);else if(N.query?.Decode)Y.query=N.query.Decode(Y.query);if(N.createCookie?.()){let V={};for(let[k,j]of Object.entries(Y.cookie))V[k]=j.value;if(N.cookie.Check(V)===!1)throw new r("cookie",N.cookie,V);else if(N.cookie?.Decode)V=N.cookie.Decode(V)}if(N.createBody?.()?.Check(C)===!1)throw new r("body",N.body,C);else if(N.body?.Decode)Y.body=N.body.Decode(C)}if(S.beforeHandle)for(let V=0;V<S.beforeHandle.length;V++){let k=S.beforeHandle[V],j=k.fn(Y);if(k.subType==="resolve"){if(j instanceof b1){let e=U(j,Y.set);if(e)return Y.response=e}if(j instanceof Promise)Object.assign(Y,await j);else Object.assign(Y,j);continue}else if(j instanceof Promise)j=await j;if(j!==void 0){if(Y.response=j,S.afterHandle)for(let Y0=0;Y0<S.afterHandle.length;Y0++){let _0=S.afterHandle[Y0].fn(Y);if(_0 instanceof Promise)_0=await _0;if(_0)j=_0}let e=U(j,Y.set);if(e)return Y.response=e}}let f=typeof G==="function"?G(Y):G;if(f instanceof Promise)f=await f;if(S.afterHandle)if(!S.afterHandle.length){let V=f instanceof b1?f.code:Q.status?typeof Q.status==="string"?e8[Q.status]:Q.status:200,k=N?.createResponse?.()?.[V];if(k?.Check(f)===!1)throw new r("response",k,f);else if(k?.Decode)f=k.Decode(f)}else{Y.response=f;for(let V=0;V<S.afterHandle.length;V++){let k=S.afterHandle[V].fn(Y);if(k instanceof Promise)k=await k;let j=U(k,Y.set);if(j!==void 0){let e=N?.response?.[j.status];if(e?.Check(j)===!1)throw new r("response",e,j);else if(e?.Decode)f=e.Decode(f);return Y.response=j}}}if(Y.set.cookie&&g?.sign){let V=!g.secrets?void 0:typeof g.secrets==="string"?g.secrets:g.secrets[0];if(g.sign===!0)for(let[k,j]of Object.entries(Y.set.cookie))Y.set.cookie[k].value=await l8(j.value,"${secret}");else{let k=N?.cookie?.schema?.properties;for(let j of g.sign){if(!(j in k))continue;if(Y.set.cookie[j]?.value)Y.set.cookie[j].value=await l8(Y.set.cookie[j].value,V)}}}return w(Y.response=f,Y.set)}catch(J){let G=J instanceof T8&&J.error?J.error:J;return z.handleError(Y,G)}finally{if(z.event.afterResponse)for(let J of z.event.afterResponse)await J.fn(Y)}}},NG=(z)=>{let{mapResponse:w}=z["~adapter"].handler;return async(U,W)=>{let X=Object.assign(U,{error:W,code:W.code});if(X.set=U.set,z.event.error)for(let Z=0;Z<z.event.error.length;Z++){let $=z.event.error[Z].fn(X);if($ instanceof Promise)$=await $;if($!==void 0&&$!==null)return U.response=w($,U.set)}return new Response(typeof W.cause==="string"?W.cause:W.message,{headers:U.set.headers,status:W.status??500})}};class b0{config;server=null;dependencies={};_routes={};_types={Prefix:"",Singleton:{},Definitions:{},Metadata:{}};_ephemeral={};_volatile={};singleton={decorator:{},store:{},derive:{},resolve:{}};get store(){return this.singleton.store}get decorator(){return this.singleton.decorator}definitions={typebox:E.Module({}),type:{},error:{}};extender={macros:[],higherOrderFunctions:[]};validator={global:null,scoped:null,local:null,getCandidate(){return t4(t4(this.global,this.scoped),this.local)}};event={};telemetry={stack:void 0};router={"~http":void 0,get http(){if(!this["~http"])this["~http"]=new F6({lazy:!0});return this["~http"]},"~dynamic":void 0,get dynamic(){if(!this["~dynamic"])this["~dynamic"]=new F6;return this["~dynamic"]},static:{http:{static:{},map:{},all:""},ws:{}},history:[]};routeTree=new Map;get routes(){return this.router.history}getGlobalRoutes(){return this.router.history}inference={body:!1,cookie:!1,headers:!1,query:!1,set:!1,server:!1,request:!1,route:!1};getServer(){return this.server}getParent(){return null}"~parser"={};_promisedModules;get promisedModules(){if(!this._promisedModules)this._promisedModules=new vU;return this._promisedModules}constructor(z={}){if(z.tags)if(!z.detail)z.detail={tags:z.tags};else z.detail.tags=z.tags;if(z.nativeStaticResponse===void 0)z.nativeStaticResponse=!0;if(this.config={},this.applyConfig(z??{}),this["~adapter"]=z.adapter??(typeof Bun!=="undefined"?AG:t8),z?.analytic&&(z?.name||z?.seed!==void 0))this.telemetry.stack=new Error().stack}"~adapter";env(z,w=dU){if(F2(z,{modules:this.definitions.typebox,dynamic:!0,additionalProperties:!0,coerce:!0}).Check(w)===!1){let U=new r("env",z,w);throw new Error(U.all.map((W)=>W.summary).join(`
|
|
328
|
+
`))}return this}wrap(z){return this.extender.higherOrderFunctions.push({checksum:o4(JSON.stringify({name:this.config.name,seed:this.config.seed,content:z.toString()})),fn:z}),this}applyMacro(z){if(this.extender.macros.length){let w=yL({globalHook:this.event,localHook:z}),U={events:{global:this.event,local:z},get onParse(){return w("parse")},get onTransform(){return w("transform")},get onBeforeHandle(){return w("beforeHandle")},get onAfterHandle(){return w("afterHandle")},get mapResponse(){return w("mapResponse")},get onAfterResponse(){return w("afterResponse")},get onError(){return w("error")}};for(let W of this.extender.macros)iL(W.fn(U),z,w)}}applyConfig(z){return this.config={prefix:"",aot:dU.ELYSIA_AOT!=="false",normalize:!0,...z,cookie:{path:"/",...z?.cookie},experimental:z?.experimental??{},seed:z?.seed===void 0?"":z?.seed},this}get models(){let z={};for(let w of Object.keys(this.definitions.type))z[w]=F2(this.definitions.typebox.Import(w));return z.modules=this.definitions.typebox,z}add(z,w,U,W,{allowMeta:X=!1,skipPrefix:Z=!1}={allowMeta:!1,skipPrefix:!1}){if(W=mz(nL(W)),w!==""&&w.charCodeAt(0)!==47)w="/"+w;if(this.config.prefix&&!Z)w=this.config.prefix+w;if(W?.type)switch(W.type){case"text":W.type="text/plain";break;case"json":W.type="application/json";break;case"formdata":W.type="multipart/form-data";break;case"urlencoded":W.type="application/x-www-form-urlencoded";break;case"arrayBuffer":W.type="application/octet-stream";break;default:break}let $=this.definitions.type,A=!this.config.aot,Q={...this.validator.getCandidate()},Y={body:W?.body??Q?.body,headers:W?.headers??Q?.headers,params:W?.params??Q?.params,query:W?.query??Q?.query,cookie:W?.cookie??Q?.cookie,response:W?.response??Q?.response},J=()=>Y.cookie?yU({modules:S,validator:Y.cookie,defaultConfig:this.config.cookie,config:Y.cookie?.config??{},dynamic:A,models:$}):void 0,G=this.config.normalize,S=this.definitions.typebox,N=this.config.precompile===!0||typeof this.config.precompile==="object"&&this.config.precompile.schema===!0?{body:F2(Y.body,{modules:S,dynamic:A,models:$,normalize:G,additionalCoerce:OU()}),headers:F2(Y.headers,{modules:S,dynamic:A,models:$,additionalProperties:!this.config.normalize,coerce:!0,additionalCoerce:y6()}),params:F2(Y.params,{modules:S,dynamic:A,models:$,coerce:!0,additionalCoerce:y6()}),query:F2(Y.query,{modules:S,dynamic:A,models:$,normalize:G,coerce:!0,additionalCoerce:y6()}),cookie:J(),response:PU(Y.response,{modules:S,dynamic:A,models:$,normalize:G})}:{createBody(){if(this.body)return this.body;return this.body=F2(Y.body,{modules:S,dynamic:A,models:$,normalize:G,additionalCoerce:OU()})},createHeaders(){if(this.headers)return this.headers;return this.headers=F2(Y.headers,{modules:S,dynamic:A,models:$,additionalProperties:!G,coerce:!0,additionalCoerce:y6()})},createParams(){if(this.params)return this.params;return this.params=F2(Y.params,{modules:S,dynamic:A,models:$,coerce:!0,additionalCoerce:y6()})},createQuery(){if(this.query)return this.query;return this.query=F2(Y.query,{modules:S,dynamic:A,models:$,coerce:!0,additionalCoerce:y6()})},createCookie(){if(this.cookie)return this.cookie;return this.cookie=J()},createResponse(){if(this.response)return this.response;return this.response=PU(Y.response,{modules:S,dynamic:A,models:$,normalize:G})}};if(W=a1(W,mz(Q)),W.tags)if(!W.detail)W.detail={tags:W.tags};else W.detail.tags=W.tags;if(z1(this.config.detail))W.detail=j2(Object.assign({},this.config.detail),W.detail);this.applyMacro(W);let O=mz(a1(this.event,W));if(this.config.aot===!1){this.router.dynamic.add(z,w,{validator:N,hooks:O,content:W?.type,handle:U,route:w});let _0=p4(w,{dynamic:!0});if(w!==_0)this.router.dynamic.add(z,_0,{validator:N,hooks:O,content:W?.type,handle:U,route:w});if(this.config.strictPath===!1){let h0=S4(w);this.router.dynamic.add(z,h0,{validator:N,hooks:O,content:W?.type,handle:U,route:w});let U6=p4(h0);if(h0!==U6)this.router.dynamic.add(z,h0,{validator:N,hooks:O,content:W?.type,handle:U,route:w})}this.router.history.push({method:z,path:w,composed:null,handler:U,hooks:O});return}let M=this.config.precompile===!0||typeof this.config.precompile==="object"&&this.config.precompile.compose===!0,C=uz(this.inference),g=this["~adapter"].handler,L0=typeof U!=="function"&&typeof g.createStaticHandler==="function"?g.createStaticHandler(U,O,this.setHeaders):void 0,a=typeof U!=="function"?g.createNativeStaticHandler?.(U,O,this.setHeaders):void 0;if(this.config.nativeStaticResponse===!0&&a&&(z==="GET"||z==="ALL"))this.router.static.http.static[w]=a();let $0=(_0=!1)=>GG({app:this,path:w,method:z,hooks:O,validator:N,handler:typeof U!=="function"&&typeof g.createStaticHandler!=="function"?()=>U:U,allowMeta:X,inference:C,asManifest:_0}),K0;if(this.routeTree.has(z+w))for(let _0=0;_0<this.router.history.length;_0++){let h0=this.router.history[_0];if(h0.path===w&&h0.method===z){K0=_0;break}}else this.routeTree.set(z+w,this.router.history.length);let f=this.router.history,V=K0??this.router.history.length,k=M?$0():(_0)=>{let h0=(f[V].composed=$0())(_0);return $0=void 0,h0};if(M)$0=void 0;let j=z==="$INTERNALWS";if(K0!==void 0)this.router.history[K0]=Object.assign({method:z,path:w,composed:k,handler:U,hooks:O},W.webSocket?{websocket:W.websocket}:{});else this.router.history.push(Object.assign({method:z,path:w,composed:k,handler:U,hooks:O},W.webSocket?{websocket:W.websocket}:{}));let e=this.router.static.http,Y0={handler:M?k:void 0,compile(){return this.handler=$0()}};if(j){if(this.router.http.add("ws",w,Y0),!this.config.strictPath)this.router.http.add("ws",S4(w),Y0);let _0=p4(w,{dynamic:!0});if(_0!==w)this.router.http.add("ws",_0,Y0);return}if(w.indexOf(":")===-1&&w.indexOf("*")===-1){if(!e.map[w])e.map[w]={code:""};let _0=L0?"":"c";if(z==="ALL")e.map[w].all=`default:return ht[${V}].composed(${_0})
|
|
329
|
+
`;else e.map[w].code=`case '${z}':return ht[${V}].composed(${_0})
|
|
330
|
+
${e.map[w].code}`;if(!this.config.strictPath&&this.config.nativeStaticResponse===!0&&a&&(z==="GET"||z==="ALL"))this.router.static.http.static[S4(w)]=a()}else{if(this.router.http.add(z,w,Y0),!this.config.strictPath){let h0=S4(w);if(this.config.nativeStaticResponse===!0&&L0&&(z==="GET"||z==="ALL"))this.router.static.http.static[h0]=L0();this.router.http.add(z,h0,Y0)}let _0=p4(w,{dynamic:!0});if(w!==_0){if(this.router.http.add(z,_0,Y0),this.config.nativeStaticResponse===!0&&L0&&(z==="GET"||z==="ALL"))this.router.static.http.static[_0]=L0();this.router.http.add(z,_0,Y0)}}}setHeaders;headers(z){if(!z)return this;if(!this.setHeaders)this.setHeaders={};return this.setHeaders=j2(this.setHeaders,z),this}onStart(z){return this.on("start",z),this}onRequest(z){return this.on("request",z),this}onParse(z,w){if(!w){if(typeof z==="string")return this.on("parse",this["~parser"][z]);return this.on("parse",z)}return this.on(z,"parse",w)}parser(z,w){return this["~parser"][z]=w,this}onTransform(z,w){if(!w)return this.on("transform",z);return this.on(z,"transform",w)}resolve(z,w){if(!w)w=z,z={as:"local"};let U={subType:"resolve",fn:w};return this.onBeforeHandle(z,U)}mapResolve(z,w){if(!w)w=z,z={as:"local"};let U={subType:"mapResolve",fn:w};return this.onBeforeHandle(z,U)}onBeforeHandle(z,w){if(!w)return this.on("beforeHandle",z);return this.on(z,"beforeHandle",w)}onAfterHandle(z,w){if(!w)return this.on("afterHandle",z);return this.on(z,"afterHandle",w)}mapResponse(z,w){if(!w)return this.on("mapResponse",z);return this.on(z,"mapResponse",w)}onAfterResponse(z,w){if(!w)return this.on("afterResponse",z);return this.on(z,"afterResponse",w)}trace(z,w){if(!w)w=z,z={as:"local"};if(!Array.isArray(w))w=[w];for(let U of w)this.on(z,"trace",JG(U));return this}error(z,w){switch(typeof z){case"string":return w.prototype[s8]=z,this.definitions.error[z]=w,this;case"function":return this.definitions.error=z(this.definitions.error),this}for(let[U,W]of Object.entries(z))W.prototype[s8]=U,this.definitions.error[U]=W;return this}onError(z,w){if(!w)return this.on("error",z);return this.on(z,"error",w)}onStop(z){return this.on("stop",z),this}on(z,w,U){let W;switch(typeof z){case"string":W=z,U=w;break;case"object":if(W=w,!Array.isArray(w)&&typeof w==="object")U=w;break}if(Array.isArray(U))U=W2(U);else if(typeof U==="function")U=[{fn:U}];else U=[U];let X=U;for(let Z of X)if(Z.scope=typeof z==="string"?"local":z?.as??"local",W==="resolve"||W==="derive")Z.subType=W;if(W!=="trace")wW({[W]:X.map((Z)=>Z.fn)},this.inference);for(let Z of X){let $=hL(Z,"global",{skipIfHasType:!0});switch(W){case"start":this.event.start??=[],this.event.start.push($);break;case"request":this.event.request??=[],this.event.request.push($);break;case"parse":this.event.parse??=[],this.event.parse.push($);break;case"transform":this.event.transform??=[],this.event.transform.push($);break;case"derive":this.event.transform??=[],this.event.transform.push(W2($,"derive"));break;case"beforeHandle":this.event.beforeHandle??=[],this.event.beforeHandle.push($);break;case"resolve":this.event.beforeHandle??=[],this.event.beforeHandle.push(W2($,"resolve"));break;case"afterHandle":this.event.afterHandle??=[],this.event.afterHandle.push($);break;case"mapResponse":this.event.mapResponse??=[],this.event.mapResponse.push($);break;case"afterResponse":this.event.afterResponse??=[],this.event.afterResponse.push($);break;case"trace":this.event.trace??=[],this.event.trace.push($);break;case"error":this.event.error??=[],this.event.error.push($);break;case"stop":this.event.stop??=[],this.event.stop.push($);break}}return this}propagate(){return L2(this.event.parse),L2(this.event.transform),L2(this.event.beforeHandle),L2(this.event.afterHandle),L2(this.event.mapResponse),L2(this.event.afterResponse),L2(this.event.trace),L2(this.event.error),this}as(z){let w={plugin:"scoped",scoped:"scoped",global:"global"}[z];if(L2(this.event.parse,w),L2(this.event.transform,w),L2(this.event.beforeHandle,w),L2(this.event.afterHandle,w),L2(this.event.mapResponse,w),L2(this.event.afterResponse,w),L2(this.event.trace,w),L2(this.event.error,w),z==="plugin")this.validator.scoped=t4(this.validator.scoped,this.validator.local),this.validator.local=null;else if(z==="global")this.validator.global=t4(this.validator.global,t4(this.validator.scoped,this.validator.local)),this.validator.scoped=null,this.validator.local=null;return this}group(z,w,U){let W=new b0({...this.config,prefix:""});W.singleton={...this.singleton},W.definitions={...this.definitions},W.getServer=()=>this.getServer(),W.inference=uz(this.inference),W.extender={...this.extender};let X=typeof w==="object",Z=(X?U:w)(W);if(this.singleton=j2(this.singleton,W.singleton),this.definitions=j2(this.definitions,W.definitions),Z.event.request?.length)this.event.request=[...this.event.request||[],...Z.event.request||[]];if(Z.event.mapResponse?.length)this.event.mapResponse=[...this.event.mapResponse||[],...Z.event.mapResponse||[]];return this.model(Z.definitions.type),Object.values(W.router.history).forEach(({method:$,path:A,handler:Q,hooks:Y})=>{if(A=(X?"":this.config.prefix)+z+A,X){let J=w,G=Y;this.add($,A,Q,a1(J,{...G||{},error:!G.error?Z.event.error:Array.isArray(G.error)?[...G.error||{},...Z.event.error||{}]:[G.error,...Z.event.error||{}]}))}else this.add($,A,Q,a1(Y,{error:Z.event.error}),{skipPrefix:!0})}),this}guard(z,w){if(!w){if(typeof z==="object"){this.applyMacro(z);let X=z.as??"local";if(this.validator[X]={body:z.body??this.validator[X]?.body,headers:z.headers??this.validator[X]?.headers,params:z.params??this.validator[X]?.params,query:z.query??this.validator[X]?.query,response:z.response??this.validator[X]?.response,cookie:z.cookie??this.validator[X]?.cookie},z.parse)this.on({as:X},"parse",z.parse);if(z.transform)this.on({as:X},"transform",z.transform);if(z.derive)this.on({as:X},"derive",z.derive);if(z.beforeHandle)this.on({as:X},"beforeHandle",z.beforeHandle);if(z.resolve)this.on({as:X},"resolve",z.resolve);if(z.afterHandle)this.on({as:X},"afterHandle",z.afterHandle);if(z.mapResponse)this.on({as:X},"mapResponse",z.mapResponse);if(z.afterResponse)this.on({as:X},"afterResponse",z.afterResponse);if(z.error)this.on({as:X},"error",z.error);if(z.detail)if(this.config.detail)this.config.detail=j2(Object.assign({},this.config.detail),z.detail);else this.config.detail=z.detail;if(z?.tags)if(!this.config.detail)this.config.detail={tags:z.tags};else this.config.detail.tags=z.tags;return this}return this.guard({},z)}let U=new b0({...this.config,prefix:""});U.singleton={...this.singleton},U.definitions={...this.definitions},U.inference=uz(this.inference),U.extender={...this.extender};let W=w(U);if(this.singleton=j2(this.singleton,U.singleton),this.definitions=j2(this.definitions,U.definitions),W.getServer=()=>this.server,W.event.request?.length)this.event.request=[...this.event.request||[],...W.event.request||[]];if(W.event.mapResponse?.length)this.event.mapResponse=[...this.event.mapResponse||[],...W.event.mapResponse||[]];return this.model(W.definitions.type),Object.values(U.router.history).forEach(({method:X,path:Z,handler:$,hooks:A})=>{this.add(X,Z,$,a1(z,{...A||{},error:!A.error?W.event.error:Array.isArray(A.error)?[...A.error||{},...W.event.error||[]]:[A.error,...W.event.error||[]]}))}),this}use(z,w){if(Array.isArray(z)){let U=this;for(let W of z)U=U.use(W);return U}if(w?.scoped)return this.guard({},(U)=>U.use(z));if(Array.isArray(z)){let U=this;for(let W of z)U=this.use(W);return U}if(z instanceof Promise)return this.promisedModules.add(z.then((U)=>{if(typeof U==="function")return U(this);if(U instanceof b0)return this._use(U).compile();if(U.constructor.name==="Elysia")return this._use(U).compile();if(typeof U.default==="function")return U.default(this);if(U.default instanceof b0)return this._use(U.default);if(U.constructor.name==="Elysia")return this._use(U.default);if(U.constructor.name==="_Elysia")return this._use(U.default);try{return this._use(U.default)}catch(W){throw console.error('Invalid plugin type. Expected Elysia instance, function, or module with "default" as Elysia instance or function that returns Elysia instance.'),W}}).then((U)=>{if(U&&typeof U.compile==="function")U.compile();return U})),this;return this._use(z)}propagatePromiseModules(z){if(z.promisedModules.size<=0)return this;for(let w of z.promisedModules.promises)this.promisedModules.add(w.then((U)=>{if(!U)return;let W=this._use(U);if(W instanceof Promise)return W.then((X)=>{if(X)X.compile();else U.compile()});return U.compile()}));return this}_use(z){if(typeof z==="function"){let X=z(this);if(X instanceof Promise)return this.promisedModules.add(X.then((Z)=>{if(Z instanceof b0){Z.getServer=()=>this.getServer(),Z.getGlobalRoutes=()=>this.getGlobalRoutes(),Z.model(this.definitions.type),Z.error(this.definitions.error);for(let{method:$,path:A,handler:Q,hooks:Y}of Object.values(Z.router.history))this.add($,A,Q,a1(Y,{error:Z.event.error}));if(Z.compile(),Z===this)return;return this.propagatePromiseModules(Z),Z}if(typeof Z==="function")return Z(this);if(typeof Z.default==="function")return Z.default(this);return this._use(Z)}).then((Z)=>{if(Z&&typeof Z.compile==="function")Z.compile();return Z})),this;return X}this.propagatePromiseModules(z);let{name:w,seed:U}=z.config;if(z.getParent=()=>this,z.getServer=()=>this.getServer(),z.getGlobalRoutes=()=>this.getGlobalRoutes(),z.model(this.definitions.type),z.error(this.definitions.error),this["~parser"]={...z["~parser"],...this["~parser"]},this.headers(z.setHeaders),w){if(!(w in this.dependencies))this.dependencies[w]=[];let X=U!==void 0?o4(w+JSON.stringify(U)):0;if(!this.dependencies[w].some(({checksum:Z})=>X===Z))this.extender.macros=this.extender.macros.concat(z.extender.macros),this.extender.higherOrderFunctions=this.extender.higherOrderFunctions.concat(z.extender.higherOrderFunctions)}else this.extender.macros=this.extender.macros.concat(z.extender.macros),this.extender.higherOrderFunctions=this.extender.higherOrderFunctions.concat(z.extender.higherOrderFunctions);EU(this.extender.macros),EU(this.extender.higherOrderFunctions);let W=[];for(let X=0;X<this.extender.higherOrderFunctions.length;X++){let Z=this.extender.higherOrderFunctions[X];if(Z.checksum){if(W.includes(Z.checksum))this.extender.higherOrderFunctions.splice(X,1),X--;W.push(Z.checksum)}}this.inference={body:this.inference.body||z.inference.body,cookie:this.inference.cookie||z.inference.cookie,headers:this.inference.headers||z.inference.headers,query:this.inference.query||z.inference.query,set:this.inference.set||z.inference.set,server:this.inference.server||z.inference.server,request:this.inference.request||z.inference.request,route:this.inference.route||z.inference.route},this.decorate(z.singleton.decorator),this.state(z.singleton.store),this.model(z.definitions.type),this.error(z.definitions.error),z.extender.macros=this.extender.macros.concat(z.extender.macros);for(let{method:X,path:Z,handler:$,hooks:A}of Object.values(z.router.history))this.add(X,Z,$,a1(A,{error:z.event.error}));if(w){if(!(w in this.dependencies))this.dependencies[w]=[];let X=U!==void 0?o4(w+JSON.stringify(U)):0;if(this.dependencies[w].some(({checksum:Z})=>X===Z))return this;this.dependencies[w].push(this.config?.analytic?{name:z.config.name,seed:z.config.seed,checksum:X,dependencies:z.dependencies,stack:z.telemetry.stack,routes:z.router.history,decorators:z.singleton,store:z.singleton.store,error:z.definitions.error,derive:z.event.transform?.filter((Z)=>Z?.subType==="derive").map((Z)=>({fn:Z.toString(),stack:new Error().stack??""})),resolve:z.event.transform?.filter((Z)=>Z?.subType==="resolve").map((Z)=>({fn:Z.toString(),stack:new Error().stack??""}))}:{name:z.config.name,seed:z.config.seed,checksum:X,dependencies:z.dependencies}),this.event=RU(this.event,CU(z.event),X)}else this.event=RU(this.event,CU(z.event));return this.validator.global=a1(this.validator.global,{...z.validator.global}),this.validator.local=a1(this.validator.local,{...z.validator.scoped}),this}macro(z){if(typeof z==="function"){let w={checksum:o4(JSON.stringify({name:this.config.name,seed:this.config.seed,content:z.toString()})),fn:z};this.extender.macros.push(w)}else if(typeof z==="object"){for(let U of Object.keys(z))if(typeof z[U]==="object"){let W={...z[U]};z[U]=(X)=>{if(X===!0)return W}}let w={checksum:o4(JSON.stringify({name:this.config.name,seed:this.config.seed,content:Object.entries(z).map(([U,W])=>`${U}+${W}`).join(",")})),fn:()=>z};this.extender.macros.push(w)}return this}mount(z,w){if(z instanceof b0||typeof z==="function"||z.length===0||z==="/"){let X=typeof z==="function"?z:z instanceof b0?z.compile().fetch:w instanceof b0?w.compile().fetch:w,Z=({request:$,path:A})=>X(new Request(DU($.url,A),{method:$.method,headers:$.headers,signal:$.signal,credentials:$.credentials,referrerPolicy:$.referrerPolicy,duplex:$.duplex,redirect:$.redirect,mode:$.mode,keepalive:$.keepalive,integrity:$.integrity,body:$.body}));return this.all("/*",Z,{parse:"none"}),this}if(!w)return this;let U=z.length-(z.endsWith("*")?1:0);if(w instanceof b0)w=w.compile().fetch;let W=({request:X,path:Z})=>w(new Request(DU(X.url,Z.slice(U)||"/"),{method:X.method,headers:X.headers,signal:X.signal,credentials:X.credentials,referrerPolicy:X.referrerPolicy,duplex:X.duplex,redirect:X.redirect,mode:X.mode,keepalive:X.keepalive,integrity:X.integrity,body:X.body}));return this.all(z,W,{parse:"none"}),this.all(z+(z.endsWith("/")?"*":"/*"),W,{parse:"none"}),this}get(z,w,U){return this.add("GET",z,w,U),this}post(z,w,U){return this.add("POST",z,w,U),this}put(z,w,U){return this.add("PUT",z,w,U),this}patch(z,w,U){return this.add("PATCH",z,w,U),this}delete(z,w,U){return this.add("DELETE",z,w,U),this}options(z,w,U){return this.add("OPTIONS",z,w,U),this}all(z,w,U){return this.add("ALL",z,w,U),this}head(z,w,U){return this.add("HEAD",z,w,U),this}connect(z,w,U){return this.add("CONNECT",z,w,U),this}route(z,w,U,W){return this.add(z.toUpperCase(),w,U,W,W?.config),this}ws(z,w){if(this["~adapter"].ws)this["~adapter"].ws(this,z,w);else console.warn("Current adapter doesn't support WebSocket");return this}state(z,w,U){if(w===void 0)U=z,z={as:"append"},w="";else if(U===void 0){if(typeof z==="string")U=w,w=z,z={as:"append"};else if(typeof z==="object")U=w,w=""}let{as:W}=z;if(typeof w!=="string")return this;switch(typeof U){case"object":if(w){if(w in this.singleton.store)this.singleton.store[w]=j2(this.singleton.store[w],U,{override:W==="override"});else this.singleton.store[w]=U;return this}if(U===null)return this;return this.singleton.store=j2(this.singleton.store,U,{override:W==="override"}),this;case"function":if(w){if(W==="override"||!(w in this.singleton.store))this.singleton.store[w]=U}else this.singleton.store=U(this.singleton.store);return this;default:if(W==="override"||!(w in this.singleton.store))this.singleton.store[w]=U;return this}}decorate(z,w,U){if(w===void 0)U=z,z={as:"append"},w="";else if(U===void 0){if(typeof z==="string")U=w,w=z,z={as:"append"};else if(typeof z==="object")U=w,w=""}let{as:W}=z;if(typeof w!=="string")return this;switch(typeof U){case"object":if(w){if(w in this.singleton.decorator)this.singleton.decorator[w]=j2(this.singleton.decorator[w],U,{override:W==="override"});else this.singleton.decorator[w]=U;return this}if(U===null)return this;return this.singleton.decorator=j2(this.singleton.decorator,U,{override:W==="override"}),this;case"function":if(w){if(W==="override"||!(w in this.singleton.decorator))this.singleton.decorator[w]=U}else this.singleton.decorator=U(this.singleton.decorator);return this;default:if(W==="override"||!(w in this.singleton.decorator))this.singleton.decorator[w]=U;return this}}derive(z,w){if(!w)w=z,z={as:"local"};let U={subType:"derive",fn:w};return this.onTransform(z,U)}model(z,w){let U=(W)=>lz(W,[{from:E.Number(),to:(X)=>E.Numeric(X),untilObjectFound:!0},{from:E.Boolean(),to:(X)=>E.BooleanString(X),untilObjectFound:!0}]);switch(typeof z){case"object":let W={},X=Object.entries(z);for(let[A,Q]of X){if(A in this.definitions.type)continue;W[A]=this.definitions.type[A]=U(Q),W[A].$id??=`#/components/schemas/${A}`}return this.definitions.typebox=E.Module({...this.definitions.typebox.$defs,...W}),this;case"function":let Z=U(z(this.definitions.type));return this.definitions.type=Z,this.definitions.typebox=E.Module(Z),this;case"string":if(!w)break;let $={...w,id:w.$id??`#/components/schemas/${z}`};return this.definitions.type[z]=w,this.definitions.typebox=E.Module({...this.definitions.typebox.$defs,...$}),this}return this.definitions.type[z]=w,this.definitions.typebox=E.Module({...this.definitions.typebox.$defs,[z]:w}),this}mapDerive(z,w){if(!w)w=z,z={as:"local"};let U={subType:"mapDerive",fn:w};return this.onTransform(z,U)}affix(z,w,U){if(U==="")return this;let W=["_","-"," "],X=(Q)=>Q[0].toUpperCase()+Q.slice(1),Z=z==="prefix"?(Q,Y)=>W.includes(Q.at(-1)??"")?Q+Y:Q+X(Y):W.includes(U.at(-1)??"")?(Q,Y)=>Y+Q:(Q,Y)=>Y+X(Q),$=(Q)=>{let Y={};switch(Q){case"decorator":for(let J in this.singleton.decorator)Y[Z(U,J)]=this.singleton.decorator[J];this.singleton.decorator=Y;break;case"state":for(let J in this.singleton.store)Y[Z(U,J)]=this.singleton.store[J];this.singleton.store=Y;break;case"model":for(let J in this.definitions.type)Y[Z(U,J)]=this.definitions.type[J];this.definitions.type=Y;break;case"error":for(let J in this.definitions.error)Y[Z(U,J)]=this.definitions.error[J];this.definitions.error=Y;break}},A=Array.isArray(w)?w:[w];for(let Q of A.some((Y)=>Y==="all")?["decorator","state","model","error"]:A)$(Q);return this}prefix(z,w){return this.affix("prefix",z,w)}suffix(z,w){return this.affix("suffix",z,w)}compile(){if(this["~adapter"].isWebStandard){if(this.fetch=this.config.aot?tz(this):hU(this),typeof this.server?.reload==="function")this.server.reload({...this.server||{},fetch:this.fetch});return this}if(typeof this.server?.reload==="function")this.server.reload(this.server||{});return this._handle=tz(this),this}handle=async(z)=>this.fetch(z);fetch=(z)=>{return(this.fetch=this.config.aot?tz(this):hU(this))(z)};handleError=async(z,w)=>{return(this.handleError=this.config.aot?AW(this):NG(this))(z,w)};outerErrorHandler=(z)=>new Response(z.message||z.name||"Error",{status:z?.status??500});listen=(z,w)=>{return this["~adapter"].listen(this)(z,w),this};stop=async(z)=>{if(!this.server)throw new Error("Elysia isn't running. Call `app.listen` to start the server.");if(this.server){if(this.server.stop(z),this.server=null,this.event.stop?.length)for(let w=0;w<this.event.stop.length;w++)this.event.stop[w].fn(this)}};get modules(){return this.promisedModules}}var QW;(function(z){z[z.Include=0]="Include",z[z.None=1]="None"})(QW||(QW={}));var YW;(function(z){z[z.Required=0]="Required",z[z.Ignore=1]="Ignore"})(YW||(YW={}));function Ww(z){return BW(z,HG,a4.Include)}function e4(z){return BW(z,_G,a4.None)}function BW(z,w,U){let W="";for(let X=0;X<z.byteLength;X+=3){let Z=0,$=0;for(let A=0;A<3&&X+A<z.byteLength;A++)Z=Z<<8|z[X+A],$+=8;for(let A=0;A<4;A++)if($>=6)W+=w[Z>>$-6&63],$-=6;else if($>0)W+=w[Z<<6-$&63],$=0;else if(U===a4.Include)W+="="}return W}var HG="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",_G="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_";var a4;(function(z){z[z.Include=0]="Include",z[z.None=1]="None"})(a4||(a4={}));var JW;(function(z){z[z.Required=0]="Required",z[z.Ignore=1]="Ignore"})(JW||(JW={}));class qW{uint8(z,w){if(z.byteLength<w+1)throw new TypeError("Insufficient bytes");return z[w]}uint16(z,w){if(z.byteLength<w+2)throw new TypeError("Insufficient bytes");return z[w]<<8|z[w+1]}uint32(z,w){if(z.byteLength<w+4)throw new TypeError("Insufficient bytes");let U=0;for(let W=0;W<4;W++)U|=z[w+W]<<24-W*8;return U}uint64(z,w){if(z.byteLength<w+8)throw new TypeError("Insufficient bytes");let U=0n;for(let W=0;W<8;W++)U|=BigInt(z[w+W])<<BigInt(56-W*8);return U}putUint8(z,w,U){if(z.length<U+1)throw new TypeError("Not enough space");if(w<0||w>255)throw new TypeError("Invalid uint8 value");z[U]=w}putUint16(z,w,U){if(z.length<U+2)throw new TypeError("Not enough space");if(w<0||w>65535)throw new TypeError("Invalid uint16 value");z[U]=w>>8,z[U+1]=w&255}putUint32(z,w,U){if(z.length<U+4)throw new TypeError("Not enough space");if(w<0||w>4294967295)throw new TypeError("Invalid uint32 value");for(let W=0;W<4;W++)z[U+W]=w>>(3-W)*8&255}putUint64(z,w,U){if(z.length<U+8)throw new TypeError("Not enough space");if(w<0||w>18446744073709551615n)throw new TypeError("Invalid uint64 value");for(let W=0;W<8;W++)z[U+W]=Number(w>>BigInt((7-W)*8)&0xffn)}}class LW{uint8(z,w){if(z.byteLength<w+1)throw new TypeError("Insufficient bytes");return z[w]}uint16(z,w){if(z.byteLength<w+2)throw new TypeError("Insufficient bytes");return z[w]|z[w+1]<<8}uint32(z,w){if(z.byteLength<w+4)throw new TypeError("Insufficient bytes");let U=0;for(let W=0;W<4;W++)U|=z[w+W]<<W*8;return U}uint64(z,w){if(z.byteLength<w+8)throw new TypeError("Insufficient bytes");let U=0n;for(let W=0;W<8;W++)U|=BigInt(z[w+W])<<BigInt(W*8);return U}putUint8(z,w,U){if(z.length<1+U)throw new TypeError("Insufficient space");if(w<0||w>255)throw new TypeError("Invalid uint8 value");z[U]=w}putUint16(z,w,U){if(z.length<2+U)throw new TypeError("Insufficient space");if(w<0||w>65535)throw new TypeError("Invalid uint16 value");z[U+1]=w>>8,z[U]=w&255}putUint32(z,w,U){if(z.length<4+U)throw new TypeError("Insufficient space");if(w<0||w>4294967295)throw new TypeError("Invalid uint32 value");for(let W=0;W<4;W++)z[U+W]=w>>W*8&255}putUint64(z,w,U){if(z.length<8+U)throw new TypeError("Insufficient space");if(w<0||w>18446744073709551615n)throw new TypeError("Invalid uint64 value");for(let W=0;W<8;W++)z[U+W]=Number(w>>BigInt(W*8)&0xffn)}}var T1=new qW,SG=new LW;function v0(z,w){return(z<<32-w|z>>>w)>>>0}function U1(z,w){return(z<<BigInt(64-w)|z>>BigInt(w))&0xffffffffffffffffn}class GW{blockSize=64;size=32;blocks=new Uint8Array(64);currentBlockSize=0;H=new Uint32Array([3238371032,914150663,812702999,4144912697,4290775857,1750603025,1694076839,3204075428]);l=0n;w=new Uint32Array(64);update(z){if(this.l+=BigInt(z.byteLength)*8n,this.currentBlockSize+z.byteLength<64){this.blocks.set(z,this.currentBlockSize),this.currentBlockSize+=z.byteLength;return}let w=0;if(this.currentBlockSize>0){let U=z.slice(0,64-this.currentBlockSize);this.blocks.set(U,this.currentBlockSize),this.process(),w+=U.byteLength,this.currentBlockSize=0}while(w+64<=z.byteLength){let U=z.slice(w,w+64);this.blocks.set(U),this.process(),w+=64}if(z.byteLength-w>0){let U=z.slice(w);this.blocks.set(U),this.currentBlockSize=U.byteLength}}digest(){if(this.blocks[this.currentBlockSize]=128,this.currentBlockSize+=1,64-this.currentBlockSize<8)this.blocks.fill(0,this.currentBlockSize),this.process(),this.currentBlockSize=0;this.blocks.fill(0,this.currentBlockSize),T1.putUint64(this.blocks,this.l,this.blockSize-8),this.process();let z=new Uint8Array(28);for(let w=0;w<7;w++)T1.putUint32(z,this.H[w],w*4);return z}process(){for(let Q=0;Q<16;Q++)this.w[Q]=(this.blocks[Q*4]<<24|this.blocks[Q*4+1]<<16|this.blocks[Q*4+2]<<8|this.blocks[Q*4+3])>>>0;for(let Q=16;Q<64;Q++){let Y=(v0(this.w[Q-2],17)^v0(this.w[Q-2],19)^this.w[Q-2]>>>10)>>>0,J=(v0(this.w[Q-15],7)^v0(this.w[Q-15],18)^this.w[Q-15]>>>3)>>>0;this.w[Q]=Y+this.w[Q-7]+J+this.w[Q-16]|0}let z=this.H[0],w=this.H[1],U=this.H[2],W=this.H[3],X=this.H[4],Z=this.H[5],$=this.H[6],A=this.H[7];for(let Q=0;Q<64;Q++){let Y=(v0(X,6)^v0(X,11)^v0(X,25))>>>0,J=(X&Z^~X&$)>>>0,G=A+Y+J+DG[Q]+this.w[Q]|0,S=(v0(z,2)^v0(z,13)^v0(z,22))>>>0,N=(z&w^z&U^w&U)>>>0,O=S+N|0;A=$,$=Z,Z=X,X=W+G|0,W=U,U=w,w=z,z=G+O|0}this.H[0]=z+this.H[0]|0,this.H[1]=w+this.H[1]|0,this.H[2]=U+this.H[2]|0,this.H[3]=W+this.H[3]|0,this.H[4]=X+this.H[4]|0,this.H[5]=Z+this.H[5]|0,this.H[6]=$+this.H[6]|0,this.H[7]=A+this.H[7]|0}}var DG=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]);function Xw(z){let w=new Zw;return w.update(z),w.digest()}class Zw{blockSize=64;size=32;blocks=new Uint8Array(64);currentBlockSize=0;H=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]);l=0n;w=new Uint32Array(64);update(z){if(this.l+=BigInt(z.byteLength)*8n,this.currentBlockSize+z.byteLength<64){this.blocks.set(z,this.currentBlockSize),this.currentBlockSize+=z.byteLength;return}let w=0;if(this.currentBlockSize>0){let U=z.slice(0,64-this.currentBlockSize);this.blocks.set(U,this.currentBlockSize),this.process(),w+=U.byteLength,this.currentBlockSize=0}while(w+64<=z.byteLength){let U=z.slice(w,w+64);this.blocks.set(U),this.process(),w+=64}if(z.byteLength-w>0){let U=z.slice(w);this.blocks.set(U),this.currentBlockSize=U.byteLength}}digest(){if(this.blocks[this.currentBlockSize]=128,this.currentBlockSize+=1,64-this.currentBlockSize<8)this.blocks.fill(0,this.currentBlockSize),this.process(),this.currentBlockSize=0;this.blocks.fill(0,this.currentBlockSize),T1.putUint64(this.blocks,this.l,this.blockSize-8),this.process();let z=new Uint8Array(32);for(let w=0;w<8;w++)T1.putUint32(z,this.H[w],w*4);return z}process(){for(let Q=0;Q<16;Q++)this.w[Q]=(this.blocks[Q*4]<<24|this.blocks[Q*4+1]<<16|this.blocks[Q*4+2]<<8|this.blocks[Q*4+3])>>>0;for(let Q=16;Q<64;Q++){let Y=(v0(this.w[Q-2],17)^v0(this.w[Q-2],19)^this.w[Q-2]>>>10)>>>0,J=(v0(this.w[Q-15],7)^v0(this.w[Q-15],18)^this.w[Q-15]>>>3)>>>0;this.w[Q]=Y+this.w[Q-7]+J+this.w[Q-16]|0}let z=this.H[0],w=this.H[1],U=this.H[2],W=this.H[3],X=this.H[4],Z=this.H[5],$=this.H[6],A=this.H[7];for(let Q=0;Q<64;Q++){let Y=(v0(X,6)^v0(X,11)^v0(X,25))>>>0,J=(X&Z^~X&$)>>>0,G=A+Y+J+PG[Q]+this.w[Q]|0,S=(v0(z,2)^v0(z,13)^v0(z,22))>>>0,N=(z&w^z&U^w&U)>>>0,O=S+N|0;A=$,$=Z,Z=X,X=W+G|0,W=U,U=w,w=z,z=G+O|0}this.H[0]=z+this.H[0]|0,this.H[1]=w+this.H[1]|0,this.H[2]=U+this.H[2]|0,this.H[3]=W+this.H[3]|0,this.H[4]=X+this.H[4]|0,this.H[5]=Z+this.H[5]|0,this.H[6]=$+this.H[6]|0,this.H[7]=A+this.H[7]|0}}var PG=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]);class R6{blockSize=128;size=64;blocks=new Uint8Array(128);currentBlockSize=0;l=0n;w=new BigUint64Array(80);H;constructor(z){if(z.byteLength!==64)throw new TypeError;this.H=z}update(z){if(this.l+=BigInt(z.byteLength)*8n,this.currentBlockSize+z.byteLength<128){this.blocks.set(z,this.currentBlockSize),this.currentBlockSize+=z.byteLength;return}let w=0;if(this.currentBlockSize>0){let U=z.slice(0,128-this.currentBlockSize);this.blocks.set(U,this.currentBlockSize),this.process(),w+=U.byteLength,this.currentBlockSize=0}while(w+128<=z.byteLength){let U=z.slice(w,w+128);this.blocks.set(U),this.process(),w+=128,this.currentBlockSize=0}if(z.byteLength-w>0){let U=z.slice(w);this.blocks.set(U),this.currentBlockSize=U.byteLength}}putDigest(z){if(z.byteLength>64||z.byteLength%8!==0)throw new TypeError;if(this.blocks[this.currentBlockSize]=128,this.currentBlockSize+=1,128-this.currentBlockSize<16)this.blocks.fill(0,this.currentBlockSize),this.process(),this.currentBlockSize=0;this.blocks.fill(0,this.currentBlockSize),T1.putUint64(this.blocks,this.l,this.blockSize-8),this.process();for(let w=0;w<z.byteLength/8;w++)T1.putUint64(z,this.H[w],w*8)}process(){for(let Q=0;Q<16;Q++)this.w[Q]=BigInt(this.blocks[Q*8])<<56n|BigInt(this.blocks[Q*8+1])<<48n|BigInt(this.blocks[Q*8+2])<<40n|BigInt(this.blocks[Q*8+3])<<32n|BigInt(this.blocks[Q*8+4])<<24n|BigInt(this.blocks[Q*8+5])<<16n|BigInt(this.blocks[Q*8+6])<<8n|BigInt(this.blocks[Q*8+7]);for(let Q=16;Q<80;Q++){let Y=(U1(this.w[Q-2],19)^U1(this.w[Q-2],61)^this.w[Q-2]>>6n)&0xffffffffffffffffn,J=(U1(this.w[Q-15],1)^U1(this.w[Q-15],8)^this.w[Q-15]>>7n)&0xffffffffffffffffn;this.w[Q]=Y+this.w[Q-7]+J+this.w[Q-16]&0xffffffffffffffffn}let z=this.H[0],w=this.H[1],U=this.H[2],W=this.H[3],X=this.H[4],Z=this.H[5],$=this.H[6],A=this.H[7];for(let Q=0;Q<80;Q++){let Y=(U1(X,14)^U1(X,18)^U1(X,41))&0xffffffffffffffffn,J=(X&Z^~X&$)&0xffffffffffffffffn,G=A+Y+J+OG[Q]+this.w[Q]&0xffffffffffffffffn,S=(U1(z,28)^U1(z,34)^U1(z,39))&0xffffffffffffffffn,N=(z&w^z&U^w&U)&0xffffffffffffffffn,O=S+N&0xffffffffffffffffn;A=$,$=Z,Z=X,X=W+G&0xffffffffffffffffn,W=U,U=w,w=z,z=G+O&0xffffffffffffffffn}this.H[0]=z+this.H[0]&0xffffffffffffffffn,this.H[1]=w+this.H[1]&0xffffffffffffffffn,this.H[2]=U+this.H[2]&0xffffffffffffffffn,this.H[3]=W+this.H[3]&0xffffffffffffffffn,this.H[4]=X+this.H[4]&0xffffffffffffffffn,this.H[5]=Z+this.H[5]&0xffffffffffffffffn,this.H[6]=$+this.H[6]&0xffffffffffffffffn,this.H[7]=A+this.H[7]&0xffffffffffffffffn}}class NW{blockSize=128;size=64;sha512=new R6(new BigUint64Array([0x6a09e667f3bcc908n,0xbb67ae8584caa73bn,0x3c6ef372fe94f82bn,0xa54ff53a5f1d36f1n,0x510e527fade682d1n,0x9b05688c2b3e6c1fn,0x1f83d9abfb41bd6bn,0x5be0cd19137e2179n]));update(z){this.sha512.update(z)}digest(){let z=new Uint8Array(64);return this.sha512.putDigest(z),z}}var OG=new BigUint64Array([0x428a2f98d728ae22n,0x7137449123ef65cdn,0xb5c0fbcfec4d3b2fn,0xe9b5dba58189dbbcn,0x3956c25bf348b538n,0x59f111f1b605d019n,0x923f82a4af194f9bn,0xab1c5ed5da6d8118n,0xd807aa98a3030242n,0x12835b0145706fben,0x243185be4ee4b28cn,0x550c7dc3d5ffb4e2n,0x72be5d74f27b896fn,0x80deb1fe3b1696b1n,0x9bdc06a725c71235n,0xc19bf174cf692694n,0xe49b69c19ef14ad2n,0xefbe4786384f25e3n,0x0fc19dc68b8cd5b5n,0x240ca1cc77ac9c65n,0x2de92c6f592b0275n,0x4a7484aa6ea6e483n,0x5cb0a9dcbd41fbd4n,0x76f988da831153b5n,0x983e5152ee66dfabn,0xa831c66d2db43210n,0xb00327c898fb213fn,0xbf597fc7beef0ee4n,0xc6e00bf33da88fc2n,0xd5a79147930aa725n,0x06ca6351e003826fn,0x142929670a0e6e70n,0x27b70a8546d22ffcn,0x2e1b21385c26c926n,0x4d2c6dfc5ac42aedn,0x53380d139d95b3dfn,0x650a73548baf63den,0x766a0abb3c77b2a8n,0x81c2c92e47edaee6n,0x92722c851482353bn,0xa2bfe8a14cf10364n,0xa81a664bbc423001n,0xc24b8b70d0f89791n,0xc76c51a30654be30n,0xd192e819d6ef5218n,0xd69906245565a910n,0xf40e35855771202an,0x106aa07032bbd1b8n,0x19a4c116b8d2d0c8n,0x1e376c085141ab53n,0x2748774cdf8eeb99n,0x34b0bcb5e19b48a8n,0x391c0cb3c5c95a63n,0x4ed8aa4ae3418acbn,0x5b9cca4f7763e373n,0x682e6ff3d6b2b8a3n,0x748f82ee5defb2fcn,0x78a5636f43172f60n,0x84c87814a1f0ab72n,0x8cc702081a6439ecn,0x90befffa23631e28n,0xa4506cebde82bde9n,0xbef9a3f7b2c67915n,0xc67178f2e372532bn,0xca273eceea26619cn,0xd186b8c721c0c207n,0xeada7dd6cde0eb1en,0xf57d4f7fee6ed178n,0x06f067aa72176fban,0x0a637dc5a2c898a6n,0x113f9804bef90daen,0x1b710b35131c471bn,0x28db77f523047d84n,0x32caab7b40c72493n,0x3c9ebe0a15c9bebcn,0x431d67c49c100d4cn,0x4cc5d4becb3e42b6n,0x597f299cfc657e2an,0x5fcb6fab3ad6faecn,0x6c44198c4a475817n]);class HW{blockSize=128;size=48;sha512=new R6(new BigUint64Array([0xcbbb9d5dc1059ed8n,0x629a292a367cd507n,0x9159015a3070dd17n,0x152fecd8f70e5939n,0x67332667ffc00b31n,0x8eb44a8768581511n,0xdb0c2e0d64f98fa7n,0x47b5481dbefa4fa4n]));update(z){this.sha512.update(z)}digest(){let z=new Uint8Array(48);return this.sha512.putDigest(z),z}}class _W{blockSize=128;size=28;sha512=new R6(new BigUint64Array([0x8c3d37c819544da2n,0x73e1996689dcd4d6n,0x1dfab7ae32ff9c82n,0x679dd514582f9fcfn,0x0f6d2b697bd44da8n,0x77e36f7304c48942n,0x3f9d85a86a1d36c8n,0x1112e6ad91d692a1n]));update(z){this.sha512.update(z)}digest(){let z=new Uint8Array(32);return this.sha512.putDigest(z),z.slice(0,28)}}class SW{blockSize=128;size=28;sha512=new R6(new BigUint64Array([0x22312194fc2bf72cn,0x9f555fa3c84c64c2n,0x2393b86b6f53b151n,0x963877195940eabdn,0x96283ee2a88effe3n,0xbe5e1e2553863992n,0x2b0199fc2c85b8aan,0x0eb72ddc81c52ca2n]));update(z){this.sha512.update(z)}digest(){let z=new Uint8Array(32);return this.sha512.putDigest(z),z}}class R4{data;constructor(z){this.data=z}tokenType(){if("token_type"in this.data&&typeof this.data.token_type==="string")return this.data.token_type;throw new Error("Missing or invalid 'token_type' field")}accessToken(){if("access_token"in this.data&&typeof this.data.access_token==="string")return this.data.access_token;throw new Error("Missing or invalid 'access_token' field")}accessTokenExpiresInSeconds(){if("expires_in"in this.data&&typeof this.data.expires_in==="number")return this.data.expires_in;throw new Error("Missing or invalid 'expires_in' field")}accessTokenExpiresAt(){return new Date(Date.now()+this.accessTokenExpiresInSeconds()*1000)}hasRefreshToken(){return"refresh_token"in this.data&&typeof this.data.refresh_token==="string"}refreshToken(){if("refresh_token"in this.data&&typeof this.data.refresh_token==="string")return this.data.refresh_token;throw new Error("Missing or invalid 'refresh_token' field")}hasScopes(){return"scope"in this.data&&typeof this.data.scope==="string"}scopes(){if("scope"in this.data&&typeof this.data.scope==="string")return this.data.scope.split(" ");throw new Error("Missing or invalid 'scope' field")}idToken(){if("id_token"in this.data&&typeof this.data.id_token==="string")return this.data.id_token;throw new Error("Missing or invalid field 'id_token'")}}function y2(z){let w=Xw(new TextEncoder().encode(z));return e4(w)}function $w(){let z=new Uint8Array(32);return crypto.getRandomValues(z),e4(z)}function Aw(){let z=new Uint8Array(32);return crypto.getRandomValues(z),e4(z)}function DW(z,w){if(w.length!==1)throw new TypeError("Invalid character string");let U=0;while(U<z.length&&z[U]===w)U++;return z.slice(U)}function Qw(z,w){if(w.length!==1)throw new TypeError("Invalid character string");let U=z.length;while(U>0&&z[U-1]===w)U--;return z.slice(0,U)}function e0(z,...w){let U=Qw(z,"/");for(let W of w)U=Qw(U,"/")+"/"+DW(W,"/");return U}function T(z,w){let U=new TextEncoder().encode(w.toString()),W=new Request(z,{method:"POST",body:U});return W.headers.set("Content-Type","application/x-www-form-urlencoded"),W.headers.set("Accept","application/json"),W.headers.set("User-Agent","arctic"),W.headers.set("Content-Length",U.byteLength.toString()),W}function g1(z,w){let U=new TextEncoder().encode(`${z}:${w}`);return Ww(U)}async function i(z){let w;try{w=await fetch(z)}catch(U){throw new C6(U)}if(w.status===400||w.status===401){let U;try{U=await w.json()}catch{throw new z6(w.status)}if(typeof U!=="object"||U===null)throw new K1(w.status,U);let W;try{W=U5(U)}catch{throw new K1(w.status,U)}throw W}if(w.status===200){let U;try{U=await w.json()}catch{throw new z6(w.status)}if(typeof U!=="object"||U===null)throw new K1(w.status,U);return new R4(U)}if(w.body!==null)await w.body.cancel();throw new z6(w.status)}async function w6(z){let w;try{w=await fetch(z)}catch(U){throw new C6(U)}if(w.status===400||w.status===401){let U;try{U=await w.json()}catch{throw new K1(w.status,null)}if(typeof U!=="object"||U===null)throw new K1(w.status,U);let W;try{W=U5(U)}catch{throw new K1(w.status,U)}throw W}if(w.status===200){if(w.body!==null)await w.body.cancel();return}if(w.body!==null)await w.body.cancel();throw new z6(w.status)}function U5(z){let w;if("error"in z&&typeof z.error==="string")w=z.error;else throw new Error("Invalid error response");let U=null,W=null,X=null;if("error_description"in z){if(typeof z.error_description!=="string")throw new Error("Invalid data");U=z.error_description}if("error_uri"in z){if(typeof z.error_uri!=="string")throw new Error("Invalid data");W=z.error_uri}if("state"in z){if(typeof z.state!=="string")throw new Error("Invalid data");X=z.state}return new z8(w,U,W,X)}class C6 extends Error{constructor(z){super("Failed to send request",{cause:z})}}class z8 extends Error{code;description;uri;state;constructor(z,w,U,W){super(`OAuth request error: ${z}`);this.code=z,this.description=w,this.uri=U,this.state=W}}class z6 extends Error{status;constructor(z){super("Unexpected error response");this.status=z}}class K1 extends Error{status;data;constructor(z,w){super("Unexpected error response body");this.status=z,this.data=w}}class y{clientId;clientPassword;redirectURI;constructor(z,w,U){this.clientId=z,this.clientPassword=w,this.redirectURI=U}createAuthorizationURL(z,w,U){let W=new URL(z);if(W.searchParams.set("response_type","code"),W.searchParams.set("client_id",this.clientId),this.redirectURI!==null)W.searchParams.set("redirect_uri",this.redirectURI);if(W.searchParams.set("state",w),U.length>0)W.searchParams.set("scope",U.join(" "));return W}createAuthorizationURLWithPKCE(z,w,U,W,X){let Z=new URL(z);if(Z.searchParams.set("response_type","code"),Z.searchParams.set("client_id",this.clientId),this.redirectURI!==null)Z.searchParams.set("redirect_uri",this.redirectURI);if(Z.searchParams.set("state",w),U===w0.S256){let $=y2(W);Z.searchParams.set("code_challenge_method","S256"),Z.searchParams.set("code_challenge",$)}else if(U===w0.Plain)Z.searchParams.set("code_challenge_method","plain"),Z.searchParams.set("code_challenge",W);if(X.length>0)Z.searchParams.set("scope",X.join(" "));return Z}async validateAuthorizationCode(z,w,U){let W=new URLSearchParams;if(W.set("grant_type","authorization_code"),W.set("code",w),this.redirectURI!==null)W.set("redirect_uri",this.redirectURI);if(U!==null)W.set("code_verifier",U);if(this.clientPassword===null)W.set("client_id",this.clientId);let X=T(z,W);if(this.clientPassword!==null){let $=g1(this.clientId,this.clientPassword);X.headers.set("Authorization",`Basic ${$}`)}return await i(X)}async refreshAccessToken(z,w,U){let W=new URLSearchParams;if(W.set("grant_type","refresh_token"),W.set("refresh_token",w),this.clientPassword===null)W.set("client_id",this.clientId);if(U.length>0)W.set("scope",U.join(" "));let X=T(z,W);if(this.clientPassword!==null){let $=g1(this.clientId,this.clientPassword);X.headers.set("Authorization",`Basic ${$}`)}return await i(X)}async revokeToken(z,w){let U=new URLSearchParams;if(U.set("token",w),this.clientPassword===null)U.set("client_id",this.clientId);let W=T(z,U);if(this.clientPassword!==null){let X=g1(this.clientId,this.clientPassword);W.headers.set("Authorization",`Basic ${X}`)}await w6(W)}}var w0;(function(z){z[z.S256=0]="S256",z[z.Plain=1]="Plain"})(w0||(w0={}));class W5{authorizationEndpoint;tokenEndpoint;tokenRevocationEndpoint;client;constructor(z,w,U,W){this.authorizationEndpoint=`https://${z}/oauth2/authorize`,this.tokenEndpoint=`https://${z}/oauth2/token`,this.tokenRevocationEndpoint=`https://${z}/oauth2/revoke`,this.client=new y(w,U,W)}createAuthorizationURL(z,w,U){return this.client.createAuthorizationURLWithPKCE(this.authorizationEndpoint,z,w0.S256,w,U)}async validateAuthorizationCode(z,w){return await this.client.validateAuthorizationCode(this.tokenEndpoint,z,w)}async refreshAccessToken(z,w){return await this.client.refreshAccessToken(this.tokenEndpoint,z,w)}async revokeToken(z){await this.client.revokeToken(this.tokenRevocationEndpoint,z)}}var CG="https://anilist.co/api/v2/oauth/authorize",bG="https://anilist.co/api/v2/oauth/token";class X5{client;constructor(z,w,U){this.client=new y(z,w,U)}createAuthorizationURL(z){return this.client.createAuthorizationURL(CG,z,[])}async validateAuthorizationCode(z){return await this.client.validateAuthorizationCode(bG,z,null)}}var PW;(function(z){z[z.Include=0]="Include",z[z.None=1]="None"})(PW||(PW={}));var OW;(function(z){z[z.Required=0]="Required",z[z.Ignore=1]="Ignore"})(OW||(OW={}));function t6(z){return KG(z,jG,Z5.None)}function KG(z,w,U){let W="";for(let X=0;X<z.byteLength;X+=3){let Z=0,$=0;for(let A=0;A<3&&X+A<z.byteLength;A++)Z=Z<<8|z[X+A],$+=8;for(let A=0;A<4;A++)if($>=6)W+=w[Z>>$-6&63],$-=6;else if($>0)W+=w[Z<<6-$&63],$=0;else if(U===Z5.Include)W+="="}return W}var jG="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_";function Yw(z){return FG(z,EG,w8.Ignore)}function FG(z,w,U){let W=new Uint8Array(Math.ceil(z.length/4)*3),X=0;for(let Z=0;Z<z.length;Z+=4){let $=0,A=0;for(let Y=0;Y<4;Y++){if(U===w8.Required&&z[Z+Y]==="=")continue;if(U===w8.Ignore&&(Z+Y>=z.length||z[Z+Y]==="="))continue;if(Y>0&&z[Z+Y-1]==="=")throw new Error("Invalid padding");if(!(z[Z+Y]in w))throw new Error("Invalid character");$|=w[z[Z+Y]]<<(3-Y)*6,A+=6}if(A<24){let Y;if(A===12)Y=$&65535;else if(A===18)Y=$&255;else throw new Error("Invalid padding");if(Y!==0)throw new Error("Invalid padding")}let Q=Math.floor(A/8);for(let Y=0;Y<Q;Y++)W[X]=$>>16-Y*8&255,X++}return W.slice(0,X)}var Z5;(function(z){z[z.Include=0]="Include",z[z.None=1]="None"})(Z5||(Z5={}));var w8;(function(z){z[z.Required=0]="Required",z[z.Ignore=1]="Ignore"})(w8||(w8={}));var EG={"0":52,"1":53,"2":54,"3":55,"4":56,"5":57,"6":58,"7":59,"8":60,"9":61,A:0,B:1,C:2,D:3,E:4,F:5,G:6,H:7,I:8,J:9,K:10,L:11,M:12,N:13,O:14,P:15,Q:16,R:17,S:18,T:19,U:20,V:21,W:22,X:23,Y:24,Z:25,a:26,b:27,c:28,d:29,e:30,f:31,g:32,h:33,i:34,j:35,k:36,l:37,m:38,n:39,o:40,p:41,q:42,r:43,s:44,t:45,u:46,v:47,w:48,x:49,y:50,z:51,"-":62,_:63};function RW(z){let w=z.split(".");if(w.length!==3)throw new Error("Invalid JWT");let U;try{U=new TextDecoder().decode(Yw(w[1]))}catch{throw new Error("Invalid JWT: Invalid base64url encoding")}let W;try{W=JSON.parse(U)}catch{throw new Error("Invalid JWT: Invalid JSON encoding")}if(typeof W!=="object"||W===null)throw new Error("Invalid JWT: Invalid payload");return W}function CW(z,w,U){let W=t6(new TextEncoder().encode(z)),X=t6(new TextEncoder().encode(w)),Z=t6(U);return W+"."+X+"."+Z}function bW(z,w){let U=t6(new TextEncoder().encode(z)),W=t6(new TextEncoder().encode(w)),X=U+"."+W;return new TextEncoder().encode(X)}var xG="https://appleid.apple.com/auth/authorize",VG="https://appleid.apple.com/auth/token";class $5{clientId;teamId;keyId;pkcs8PrivateKey;redirectURI;constructor(z,w,U,W,X){this.clientId=z,this.teamId=w,this.keyId=U,this.pkcs8PrivateKey=W,this.redirectURI=X}createAuthorizationURL(z,w){let U=new URL(xG);if(U.searchParams.set("response_type","code"),U.searchParams.set("client_id",this.clientId),U.searchParams.set("state",z),w.length>0)U.searchParams.set("scope",w.join(" "));return U.searchParams.set("redirect_uri",this.redirectURI),U}async validateAuthorizationCode(z){let w=new URLSearchParams;w.set("grant_type","authorization_code"),w.set("code",z),w.set("redirect_uri",this.redirectURI),w.set("client_id",this.clientId);let U=await this.createClientSecret();w.set("client_secret",U);let W=T(VG,w);return await i(W)}async createClientSecret(){let z=await crypto.subtle.importKey("pkcs8",this.pkcs8PrivateKey,{name:"ECDSA",namedCurve:"P-256"},!1,["sign"]),w=Math.floor(Date.now()/1000),U=JSON.stringify({typ:"JWT",alg:"ES256",kid:this.keyId}),W=JSON.stringify({iss:this.teamId,exp:w+300,aud:["https://appleid.apple.com"],sub:this.clientId,iat:w}),X=new Uint8Array(await crypto.subtle.sign({name:"ECDSA",hash:"SHA-256"},z,bW(U,W)));return CW(U,W,X)}}var kG="https://auth.atlassian.com/authorize",jW="https://auth.atlassian.com/oauth/token";class A5{clientId;clientSecret;redirectURI;constructor(z,w,U){this.clientId=z,this.clientSecret=w,this.redirectURI=U}createAuthorizationURL(z,w){let U=new URL(kG);if(U.searchParams.set("response_type","code"),U.searchParams.set("client_id",this.clientId),U.searchParams.set("state",z),w.length>0)U.searchParams.set("scope",w.join(" "));return U.searchParams.set("redirect_uri",this.redirectURI),U.searchParams.set("audience","api.atlassian.com"),U.searchParams.set("prompt","consent"),U}async validateAuthorizationCode(z){let w=new URLSearchParams;w.set("grant_type","authorization_code"),w.set("code",z),w.set("redirect_uri",this.redirectURI),w.set("client_id",this.clientId),w.set("client_secret",this.clientSecret);let U=T(jW,w);return await i(U)}async refreshAccessToken(z){let w=new URLSearchParams;w.set("grant_type","refresh_token"),w.set("refresh_token",z),w.set("client_id",this.clientId),w.set("client_secret",this.clientSecret);let U=T(jW,w);return await i(U)}}class Q5{authorizationEndpoint;tokenEndpoint;tokenRevocationEndpoint;client;constructor(z,w,U,W){this.authorizationEndpoint=`https://${z}/authorize`,this.tokenEndpoint=`https://${z}/oauth/token`,this.tokenRevocationEndpoint=`https://${z}/oauth/revoke`,this.client=new y(w,U,W)}createAuthorizationURL(z,w,U){let W;if(w!==null)W=this.client.createAuthorizationURLWithPKCE(this.authorizationEndpoint,z,w0.S256,w,U);else W=this.client.createAuthorizationURL(this.authorizationEndpoint,z,U);return W}async validateAuthorizationCode(z,w){return await this.client.validateAuthorizationCode(this.tokenEndpoint,z,w)}async refreshAccessToken(z){return await this.client.refreshAccessToken(this.tokenEndpoint,z,[])}async revokeToken(z){await this.client.revokeToken(this.tokenRevocationEndpoint,z)}}class Y5{authorizationEndpoint;tokenEndpoint;tokenRevocationEndpoint;client;constructor(z,w,U,W){this.authorizationEndpoint=e0(z,"/application/o/authorize/"),this.tokenEndpoint=e0(z,"/application/o/token/"),this.tokenRevocationEndpoint=e0(z,"/application/o/revoke/"),this.client=new y(w,U,W)}createAuthorizationURL(z,w,U){return this.client.createAuthorizationURLWithPKCE(this.authorizationEndpoint,z,w0.S256,w,U)}async validateAuthorizationCode(z,w){return await this.client.validateAuthorizationCode(this.tokenEndpoint,z,w)}async refreshAccessToken(z){return await this.client.refreshAccessToken(this.tokenEndpoint,z,[])}async revokeToken(z){await this.client.revokeToken(this.tokenRevocationEndpoint,z)}}var TG="https://bitbucket.org/site/oauth2/authorize",FW="https://bitbucket.org/site/oauth2/access_token";class J5{client;constructor(z,w,U){this.client=new y(z,w,U)}createAuthorizationURL(z){return this.client.createAuthorizationURL(TG,z,[])}async validateAuthorizationCode(z){return await this.client.validateAuthorizationCode(FW,z,null)}async refreshAccessToken(z){return await this.client.refreshAccessToken(FW,z,[])}}var gG="https://account.box.com/api/oauth2/authorize",EW="https://api.box.com/oauth2/token",fG="https://api.box.com/oauth2/revoke";class B5{clientId;clientSecret;redirectURI;constructor(z,w,U){this.clientId=z,this.clientSecret=w,this.redirectURI=U}createAuthorizationURL(z,w){let U=new URL(gG);if(U.searchParams.set("response_type","code"),U.searchParams.set("client_id",this.clientId),U.searchParams.set("state",z),w.length>0)U.searchParams.set("scope",w.join(" "));return U.searchParams.set("redirect_uri",this.redirectURI),U}async validateAuthorizationCode(z){let w=new URLSearchParams;w.set("grant_type","authorization_code"),w.set("code",z),w.set("redirect_uri",this.redirectURI),w.set("client_id",this.clientId),w.set("client_secret",this.clientSecret);let U=T(EW,w);return await i(U)}async refreshAccessToken(z){let w=new URLSearchParams;w.set("grant_type","refresh_token"),w.set("refresh_token",z),w.set("client_id",this.clientId),w.set("client_secret",this.clientSecret);let U=T(EW,w);return await i(U)}async revokeToken(z){let w=new URLSearchParams;w.set("token",z),w.set("client_id",this.clientId),w.set("client_secret",this.clientSecret);let U=T(fG,w);await w6(U)}}var dG="https://www.coinbase.com/oauth/authorize",IW="https://www.coinbase.com/oauth/token",hG="https://api.coinbase.com/oauth/revoke";class M5{clientId;clientSecret;redirectURI;constructor(z,w,U){this.clientId=z,this.clientSecret=w,this.redirectURI=U}createAuthorizationURL(z,w){let U=new URL(dG);if(U.searchParams.set("response_type","code"),U.searchParams.set("client_id",this.clientId),U.searchParams.set("state",z),w.length>0)U.searchParams.set("scope",w.join(" "));return U.searchParams.set("redirect_uri",this.redirectURI),U}async validateAuthorizationCode(z){let w=new URLSearchParams;w.set("grant_type","authorization_code"),w.set("code",z),w.set("redirect_uri",this.redirectURI),w.set("client_id",this.clientId),w.set("client_secret",this.clientSecret);let U=T(IW,w);return await i(U)}async refreshAccessToken(z){let w=new URLSearchParams;w.set("grant_type","refresh_token"),w.set("refresh_token",z),w.set("client_id",this.clientId),w.set("client_secret",this.clientSecret);let U=T(IW,w);return await i(U)}async revokeToken(z){let w=new URLSearchParams;w.set("token",z),w.set("client_id",this.clientId),w.set("client_secret",this.clientSecret);let U=T(hG,w);await w6(U)}}var xW="https://discord.com/oauth2/authorize",VW="https://discord.com/api/oauth2/token",cG="https://discord.com/api/oauth2/token/revoke";class q5{client;constructor(z,w,U){this.client=new y(z,w,U)}createAuthorizationURL(z,w,U){let W;if(w!==null)W=this.client.createAuthorizationURLWithPKCE(xW,z,w0.S256,w,U);else W=this.client.createAuthorizationURL(xW,z,U);return W}async validateAuthorizationCode(z,w){return await this.client.validateAuthorizationCode(VW,z,w)}async refreshAccessToken(z){return await this.client.refreshAccessToken(VW,z,[])}async revokeToken(z){await this.client.revokeToken(cG,z)}}var iG="https://dribbble.com/oauth/authorize",yG="https://dribbble.com/oauth/token";class L5{clientId;clientSecret;redirectURI;constructor(z,w,U){this.clientId=z,this.clientSecret=w,this.redirectURI=U}createAuthorizationURL(z,w){let U=new URL(iG);if(U.searchParams.set("response_type","code"),U.searchParams.set("client_id",this.clientId),U.searchParams.set("state",z),w.length>0)U.searchParams.set("scope",w.join(" "));return U.searchParams.set("redirect_uri",this.redirectURI),U}async validateAuthorizationCode(z){let w=new URLSearchParams;w.set("grant_type","authorization_code"),w.set("code",z),w.set("redirect_uri",this.redirectURI),w.set("client_id",this.clientId),w.set("client_secret",this.clientSecret);let U=T(yG,w);return await i(U)}}var vG="https://www.dropbox.com/oauth2/authorize",kW="https://api.dropboxapi.com/oauth2/token",nG="https://api.dropboxapi.com/2/auth/token/revoke";class G5{client;constructor(z,w,U){this.client=new y(z,w,U)}createAuthorizationURL(z,w){return this.client.createAuthorizationURL(vG,z,w)}async validateAuthorizationCode(z){return await this.client.validateAuthorizationCode(kW,z,null)}async refreshAccessToken(z){return await this.client.refreshAccessToken(kW,z,[])}async revokeToken(z){await this.client.revokeToken(nG,z)}}var uG="https://www.facebook.com/v16.0/dialog/oauth",mG="https://graph.facebook.com/v16.0/oauth/access_token";class N5{clientId;clientSecret;redirectURI;constructor(z,w,U){this.clientId=z,this.clientSecret=w,this.redirectURI=U}createAuthorizationURL(z,w){let U=new URL(uG);if(U.searchParams.set("response_type","code"),U.searchParams.set("client_id",this.clientId),U.searchParams.set("state",z),w.length>0)U.searchParams.set("scope",w.join(" "));return U.searchParams.set("redirect_uri",this.redirectURI),U}async validateAuthorizationCode(z){let w=new URLSearchParams;w.set("grant_type","authorization_code"),w.set("code",z),w.set("redirect_uri",this.redirectURI),w.set("client_id",this.clientId),w.set("client_secret",this.clientSecret);let U=T(mG,w);return await i(U)}}var tG="https://www.figma.com/oauth",oG="https://api.figma.com/v1/oauth/token",pG="https://api.figma.com/v1/oauth/refresh";class H5{client;constructor(z,w,U){this.client=new y(z,w,U)}createAuthorizationURL(z,w){return this.client.createAuthorizationURL(tG,z,w)}async validateAuthorizationCode(z){return await this.client.validateAuthorizationCode(oG,z,null)}async refreshAccessToken(z){return await this.client.refreshAccessToken(pG,z,[])}}var lG="https://github.com/login/oauth/authorize",TW="https://github.com/login/oauth/access_token";class _5{clientId;clientSecret;redirectURI;constructor(z,w,U){this.clientId=z,this.clientSecret=w,this.redirectURI=U}createAuthorizationURL(z,w){let U=new URL(lG);if(U.searchParams.set("response_type","code"),U.searchParams.set("client_id",this.clientId),U.searchParams.set("state",z),w.length>0)U.searchParams.set("scope",w.join(" "));if(this.redirectURI!==null)U.searchParams.set("redirect_uri",this.redirectURI);return U}async validateAuthorizationCode(z){let w=new URLSearchParams;if(w.set("grant_type","authorization_code"),w.set("code",z),this.redirectURI!==null)w.set("redirect_uri",this.redirectURI);let U=T(TW,w),W=g1(this.clientId,this.clientSecret);return U.headers.set("Authorization",`Basic ${W}`),await gW(U)}async refreshAccessToken(z){let w=new URLSearchParams;w.set("grant_type","refresh_token"),w.set("refresh_token",z);let U=T(TW,w),W=g1(this.clientId,this.clientSecret);return U.headers.set("Authorization",`Basic ${W}`),await gW(U)}}async function gW(z){let w;try{w=await fetch(z)}catch(X){throw new C6(X)}if(w.status!==200){if(w.body!==null)await w.body.cancel();throw new z6(w.status)}let U;try{U=await w.json()}catch{throw new z6(w.status)}if(typeof U!=="object"||U===null)throw new K1(w.status,U);if("error"in U&&typeof U.error==="string"){let X;try{X=U5(U)}catch{throw new K1(w.status,U)}throw X}return new R4(U)}class S5{authorizationEndpoint;tokenEndpoint;tokenRevocationEndpoint;client;constructor(z,w,U,W){this.authorizationEndpoint=e0(z,"/oauth/authorize"),this.tokenEndpoint=e0(z,"/oauth/token"),this.tokenRevocationEndpoint=e0(z,"/oauth/revoke"),this.client=new y(w,U,W)}createAuthorizationURL(z,w){return this.client.createAuthorizationURL(this.authorizationEndpoint,z,w)}async validateAuthorizationCode(z){return await this.client.validateAuthorizationCode(this.tokenEndpoint,z,null)}async refreshAccessToken(z){return await this.client.refreshAccessToken(this.tokenEndpoint,z,[])}async revokeToken(z){await this.client.revokeToken(this.tokenRevocationEndpoint,z)}}var sG="https://accounts.google.com/o/oauth2/v2/auth",fW="https://oauth2.googleapis.com/token",rG="https://oauth2.googleapis.com/revoke";class D5{client;constructor(z,w,U){this.client=new y(z,w,U)}createAuthorizationURL(z,w,U){return this.client.createAuthorizationURLWithPKCE(sG,z,w0.S256,w,U)}async validateAuthorizationCode(z,w){return await this.client.validateAuthorizationCode(fW,z,w)}async refreshAccessToken(z){return await this.client.refreshAccessToken(fW,z,[])}async revokeToken(z){await this.client.revokeToken(rG,z)}}var aG="https://appcenter.intuit.com/connect/oauth2",dW="https://oauth.platform.intuit.com/oauth2/v1/tokens/bearer",eG="https://developer.API.intuit.com/v2/oauth2/tokens/revoke";class P5{client;constructor(z,w,U){this.client=new y(z,w,U)}createAuthorizationURL(z,w){return this.client.createAuthorizationURL(aG,z,w)}async validateAuthorizationCode(z){return await this.client.validateAuthorizationCode(dW,z,null)}async refreshAccessToken(z){return await this.client.refreshAccessToken(dW,z,[])}async revokeToken(z){await this.client.revokeToken(eG,z)}}var zN="https://kauth.kakao.com/oauth/authorize",hW="https://kauth.kakao.com/oauth/token";class O5{clientId;clientSecret;redirectURI;constructor(z,w,U){this.clientId=z,this.clientSecret=w,this.redirectURI=U}createAuthorizationURL(z,w){let U=new URL(zN);if(U.searchParams.set("response_type","code"),U.searchParams.set("client_id",this.clientId),U.searchParams.set("state",z),w.length>0)U.searchParams.set("scope",w.join(" "));return U.searchParams.set("redirect_uri",this.redirectURI),U}async validateAuthorizationCode(z){let w=new URLSearchParams;w.set("grant_type","authorization_code"),w.set("code",z),w.set("redirect_uri",this.redirectURI),w.set("client_id",this.clientId),w.set("client_secret",this.clientSecret);let U=T(hW,w);return await i(U)}async refreshAccessToken(z){let w=new URLSearchParams;w.set("grant_type","refresh_token"),w.set("refresh_token",z),w.set("client_id",this.clientId),w.set("client_secret",this.clientSecret);let U=T(hW,w);return await i(U)}}class R5{authorizationEndpoint;tokenEndpoint;tokenRevocationEndpoint;client;constructor(z,w,U,W){this.authorizationEndpoint=z+"/protocol/openid-connect/auth",this.tokenEndpoint=z+"/protocol/openid-connect/token",this.tokenRevocationEndpoint=z+"/protocol/openid-connect/revoke",this.client=new y(w,U,W)}createAuthorizationURL(z,w,U){return this.client.createAuthorizationURLWithPKCE(this.authorizationEndpoint,z,w0.S256,w,U)}async validateAuthorizationCode(z,w){return await this.client.validateAuthorizationCode(this.tokenEndpoint,z,w)}async refreshAccessToken(z){return await this.client.refreshAccessToken(this.tokenEndpoint,z,[])}async revokeToken(z){await this.client.revokeToken(this.tokenRevocationEndpoint,z)}}var wN="https://lichess.org/oauth",UN="https://lichess.org/api/token";class C5{client;constructor(z,w){this.client=new y(z,null,w)}createAuthorizationURL(z,w,U){return this.client.createAuthorizationURLWithPKCE(wN,z,w0.S256,w,U)}async validateAuthorizationCode(z,w){return await this.client.validateAuthorizationCode(UN,z,w)}}var WN="https://access.line.me/oauth2/v2.1/authorize",cW="https://api.line.me/oauth2/v2.1/token";class b5{clientId;clientSecret;redirectURI;constructor(z,w,U){this.clientId=z,this.clientSecret=w,this.redirectURI=U}createAuthorizationURL(z,w,U){let W=new URL(WN);if(W.searchParams.set("response_type","code"),W.searchParams.set("client_id",this.clientId),W.searchParams.set("state",z),U.length>0)W.searchParams.set("scope",U.join(" "));W.searchParams.set("redirect_uri",this.redirectURI);let X=y2(w);return W.searchParams.set("code_challenge_method","S256"),W.searchParams.set("code_challenge",X),W}async validateAuthorizationCode(z,w){let U=new URLSearchParams;U.set("grant_type","authorization_code"),U.set("code",z),U.set("code_verifier",w),U.set("redirect_uri",this.redirectURI),U.set("client_id",this.clientId),U.set("client_secret",this.clientSecret);let W=T(cW,U);return await i(W)}async refreshAccessToken(z){let w=new URLSearchParams;w.set("grant_type","refresh_token"),w.set("refresh_token",z),w.set("client_id",this.clientId),w.set("client_secret",this.clientSecret);let U=T(cW,w);return await i(U)}}var XN="https://linear.app/oauth/authorize",ZN="https://api.linear.app/oauth/token";class K5{clientId;clientSecret;redirectURI;constructor(z,w,U){this.clientId=z,this.clientSecret=w,this.redirectURI=U}createAuthorizationURL(z,w){let U=new URL(XN);if(U.searchParams.set("response_type","code"),U.searchParams.set("client_id",this.clientId),U.searchParams.set("state",z),w.length>0)U.searchParams.set("scope",w.join(" "));return U.searchParams.set("redirect_uri",this.redirectURI),U}async validateAuthorizationCode(z){let w=new URLSearchParams;w.set("grant_type","authorization_code"),w.set("code",z),w.set("redirect_uri",this.redirectURI),w.set("client_id",this.clientId),w.set("client_secret",this.clientSecret);let U=T(ZN,w);return await i(U)}}var $N="https://www.linkedin.com/oauth/v2/authorization",iW="https://www.linkedin.com/oauth/v2/accessToken";class j5{clientId;clientSecret;redirectURI;constructor(z,w,U){this.clientId=z,this.clientSecret=w,this.redirectURI=U}createAuthorizationURL(z,w){let U=new URL($N);if(U.searchParams.set("response_type","code"),U.searchParams.set("client_id",this.clientId),U.searchParams.set("state",z),w.length>0)U.searchParams.set("scope",w.join(" "));return U.searchParams.set("redirect_uri",this.redirectURI),U}async validateAuthorizationCode(z){let w=new URLSearchParams;w.set("grant_type","authorization_code"),w.set("code",z),w.set("redirect_uri",this.redirectURI),w.set("client_id",this.clientId),w.set("client_secret",this.clientSecret);let U=T(iW,w);return await i(U)}async refreshAccessToken(z){let w=new URLSearchParams;w.set("grant_type","refresh_token"),w.set("refresh_token",z),w.set("client_id",this.clientId),w.set("client_secret",this.clientSecret);let U=T(iW,w);return await i(U)}}class F5{authorizationEndpoint;tokenEndpoint;clientId;clientSecret;redirectURI;constructor(z,w,U,W){this.authorizationEndpoint=e0("https://login.microsoftonline.com",z,"/oauth2/v2.0/authorize"),this.tokenEndpoint=e0("https://login.microsoftonline.com",z,"/oauth2/v2.0/token"),this.clientId=w,this.clientSecret=U,this.redirectURI=W}createAuthorizationURL(z,w,U){let W=new URL(this.authorizationEndpoint);W.searchParams.set("response_type","code"),W.searchParams.set("client_id",this.clientId),W.searchParams.set("redirect_uri",this.redirectURI),W.searchParams.set("state",z);let X=y2(w);if(W.searchParams.set("code_challenge_method","S256"),W.searchParams.set("code_challenge",X),U.length>0)W.searchParams.set("scope",U.join(" "));return W}async validateAuthorizationCode(z,w){let U=new URLSearchParams;if(U.set("grant_type","authorization_code"),U.set("code",z),U.set("redirect_uri",this.redirectURI),U.set("code_verifier",w),this.clientSecret===null)U.set("client_id",this.clientId);let W=T(this.tokenEndpoint,U);if(this.clientSecret!==null){let Z=g1(this.clientId,this.clientSecret);W.headers.set("Authorization",`Basic ${Z}`)}else W.headers.set("Origin","arctic");return await i(W)}async refreshAccessToken(z,w){let U=new URLSearchParams;if(U.set("grant_type","refresh_token"),U.set("refresh_token",z),this.clientSecret===null)U.set("client_id",this.clientId);if(w.length>0)U.set("scope",w.join(" "));let W=T(this.tokenEndpoint,U);if(this.clientSecret!==null){let Z=g1(this.clientId,this.clientSecret);W.headers.set("Authorization",`Basic ${Z}`)}else W.headers.set("Origin","arctic");return await i(W)}}var AN="https://myanimelist.net/v1/oauth2/authorize",yW="https://myanimelist.net/v1/oauth2/token";class E5{client;constructor(z,w,U){this.client=new y(z,w,U)}createAuthorizationURL(z,w){return this.client.createAuthorizationURLWithPKCE(AN,z,w0.Plain,w,[])}async validateAuthorizationCode(z,w){return await this.client.validateAuthorizationCode(yW,z,w)}async refreshAccessToken(z){return await this.client.refreshAccessToken(yW,z,[])}}var QN="https://api.notion.com/v1/oauth/authorize",YN="https://api.notion.com/v1/oauth/token";class I5{client;constructor(z,w,U){this.client=new y(z,w,U)}createAuthorizationURL(z){let w=this.client.createAuthorizationURL(QN,z,[]);return w.searchParams.set("owner","user"),w}async validateAuthorizationCode(z){return await this.client.validateAuthorizationCode(YN,z,null)}}class x5{authorizationEndpoint;tokenEndpoint;tokenRevocationEndpoint;client;constructor(z,w,U,W,X){let Z=`https://${z}/oauth2`;if(w!==null)Z=e0(Z,w);this.authorizationEndpoint=e0(Z,"/v1/authorize"),this.tokenEndpoint=e0(Z,"/v1/token"),this.tokenRevocationEndpoint=e0(Z,"/v1/revoke"),this.client=new y(U,W,X)}createAuthorizationURL(z,w,U){return this.client.createAuthorizationURLWithPKCE(this.authorizationEndpoint,z,w0.S256,w,U)}async validateAuthorizationCode(z,w){return await this.client.validateAuthorizationCode(this.tokenEndpoint,z,w)}async refreshAccessToken(z,w){return await this.client.refreshAccessToken(this.tokenEndpoint,z,w)}async revokeToken(z){await this.client.revokeToken(this.tokenRevocationEndpoint,z)}}var JN="https://osu.ppy.sh/oauth/authorize",vW="https://osu.ppy.sh/oauth/token";class V5{clientId;clientSecret;redirectURI;constructor(z,w,U){this.clientId=z,this.clientSecret=w,this.redirectURI=U}createAuthorizationURL(z,w){let U=new URL(JN);if(U.searchParams.set("response_type","code"),U.searchParams.set("client_id",this.clientId),U.searchParams.set("state",z),w.length>0)U.searchParams.set("scope",w.join(" "));if(this.redirectURI!==null)U.searchParams.set("redirect_uri",this.redirectURI);return U}async validateAuthorizationCode(z){let w=new URLSearchParams;if(w.set("grant_type","authorization_code"),w.set("code",z),this.redirectURI!==null)w.set("redirect_uri",this.redirectURI);w.set("client_id",this.clientId),w.set("client_secret",this.clientSecret);let U=T(vW,w);return await i(U)}async refreshAccessToken(z){let w=new URLSearchParams;w.set("grant_type","refresh_token"),w.set("refresh_token",z),w.set("client_id",this.clientId),w.set("client_secret",this.clientSecret);let U=T(vW,w);return await i(U)}}var BN="https://www.patreon.com/oauth2/authorize",nW="https://www.patreon.com/api/oauth2/token";class k5{clientId;clientSecret;redirectURI;constructor(z,w,U){this.clientId=z,this.clientSecret=w,this.redirectURI=U}createAuthorizationURL(z,w){let U=new URL(BN);if(U.searchParams.set("response_type","code"),U.searchParams.set("client_id",this.clientId),U.searchParams.set("state",z),w.length>0)U.searchParams.set("scope",w.join(" "));return U.searchParams.set("redirect_uri",this.redirectURI),U}async validateAuthorizationCode(z){let w=new URLSearchParams;w.set("grant_type","authorization_code"),w.set("code",z),w.set("redirect_uri",this.redirectURI),w.set("client_id",this.clientId),w.set("client_secret",this.clientSecret);let U=T(nW,w);return await i(U)}async refreshAccessToken(z){let w=new URLSearchParams;w.set("grant_type","refresh_token"),w.set("refresh_token",z),w.set("client_id",this.clientId),w.set("client_secret",this.clientSecret);let U=T(nW,w);return await i(U)}}var MN="https://www.reddit.com/api/v1/authorize",uW="https://www.reddit.com/api/v1/access_token";class T5{client;constructor(z,w,U){this.client=new y(z,w,U)}createAuthorizationURL(z,w){return this.client.createAuthorizationURL(MN,z,w)}async validateAuthorizationCode(z){return await this.client.validateAuthorizationCode(uW,z,null)}async refreshAccessToken(z){return await this.client.refreshAccessToken(uW,z,[])}}var qN="https://apis.roblox.com/oauth/v1/authorize",mW="https://apis.roblox.com/oauth/v1/token",LN="https://apis.roblox.com/oauth/v1/token/revoke";class g5{client;constructor(z,w,U){this.client=new y(z,w,U)}createAuthorizationURL(z,w,U){return this.client.createAuthorizationURLWithPKCE(qN,z,w0.S256,w,U)}async validateAuthorizationCode(z,w){return await this.client.validateAuthorizationCode(mW,z,w)}async refreshAccessToken(z){return await this.client.refreshAccessToken(mW,z,[])}async revokeToken(z){await this.client.revokeToken(LN,z)}}class f5{authorizationEndpoint;tokenEndpoint;tokenRevocationEndpoint;client;constructor(z,w,U,W){this.authorizationEndpoint=`https://${z}/services/oauth2/authorize`,this.tokenEndpoint=`https://${z}/services/oauth2/token`,this.tokenRevocationEndpoint=`https://${z}/services/oauth2/revoke`,this.client=new y(w,U,W)}createAuthorizationURL(z,w,U){return this.client.createAuthorizationURLWithPKCE(this.authorizationEndpoint,z,w0.S256,w,U)}async validateAuthorizationCode(z,w){return await this.client.validateAuthorizationCode(this.tokenEndpoint,z,w)}async refreshAccessToken(z){return await this.client.refreshAccessToken(this.tokenEndpoint,z,[])}async revokeToken(z){await this.client.revokeToken(this.tokenRevocationEndpoint,z)}}var GN="https://shikimori.one/oauth/authorize",tW="https://shikimori.one/oauth/token";class d5{clientId;clientSecret;redirectURI;constructor(z,w,U){this.clientId=z,this.clientSecret=w,this.redirectURI=U}createAuthorizationURL(z){let w=new URL(GN);return w.searchParams.set("response_type","code"),w.searchParams.set("client_id",this.clientId),w.searchParams.set("state",z),w.searchParams.set("redirect_uri",this.redirectURI),w}async validateAuthorizationCode(z){let w=new URLSearchParams;w.set("grant_type","authorization_code"),w.set("code",z),w.set("redirect_uri",this.redirectURI),w.set("client_id",this.clientId),w.set("client_secret",this.clientSecret);let U=T(tW,w);return await i(U)}async refreshAccessToken(z){let w=new URLSearchParams;w.set("grant_type","refresh_token"),w.set("refresh_token",z),w.set("client_id",this.clientId),w.set("client_secret",this.clientSecret);let U=T(tW,w);return await i(U)}}var NN="https://slack.com/openid/connect/authorize",HN="https://slack.com/api/openid.connect.token";class h5{client;constructor(z,w,U){this.client=new y(z,w,U)}createAuthorizationURL(z,w){return this.client.createAuthorizationURL(NN,z,w)}async validateAuthorizationCode(z){return await this.client.validateAuthorizationCode(HN,z,null)}}var oW="https://accounts.spotify.com/authorize",pW="https://accounts.spotify.com/api/token";class c5{client;constructor(z,w,U){this.client=new y(z,w,U)}createAuthorizationURL(z,w,U){let W;if(w!==null)W=this.client.createAuthorizationURLWithPKCE(oW,z,w0.S256,w,U);else W=this.client.createAuthorizationURL(oW,z,U);return W}async validateAuthorizationCode(z,w){return await this.client.validateAuthorizationCode(pW,z,w)}async refreshAccessToken(z){return await this.client.refreshAccessToken(pW,z,[])}}var _N="https://www.strava.com/oauth/authorize",lW="https://www.strava.com/api/v3/oauth/token";class i5{clientId;clientSecret;redirectURI;constructor(z,w,U){this.clientId=z,this.clientSecret=w,this.redirectURI=U}createAuthorizationURL(z,w){let U=new URL(_N);if(U.searchParams.set("response_type","code"),U.searchParams.set("client_id",this.clientId),U.searchParams.set("state",z),w.length>0)U.searchParams.set("scope",w.join(","));return U.searchParams.set("redirect_uri",this.redirectURI),U}async validateAuthorizationCode(z){let w=new URLSearchParams;w.set("grant_type","authorization_code"),w.set("code",z),w.set("redirect_uri",this.redirectURI),w.set("client_id",this.clientId),w.set("client_secret",this.clientSecret);let U=T(lW,w);return await i(U)}async refreshAccessToken(z){let w=new URLSearchParams;w.set("grant_type","refresh_token"),w.set("refresh_token",z),w.set("client_id",this.clientId),w.set("client_secret",this.clientSecret);let U=T(lW,w);return await i(U)}}var SN="https://v5api.tiltify.com/oauth/authorizeze",sW="https://v5api.tiltify.com/oauth/token";class y5{clientId;clientSecret;redirectURI;constructor(z,w,U){this.clientId=z,this.clientSecret=w,this.redirectURI=U}createAuthorizationURL(z,w){let U=new URL(SN);if(U.searchParams.set("response_type","code"),U.searchParams.set("client_id",this.clientId),U.searchParams.set("state",z),w.length>0)U.searchParams.set("scope",w.join(" "));return U.searchParams.set("redirect_uri",this.redirectURI),U}async validateAuthorizationCode(z){let w=new URLSearchParams;w.set("grant_type","authorization_code"),w.set("code",z),w.set("redirect_uri",this.redirectURI),w.set("client_id",this.clientId),w.set("client_secret",this.clientSecret);let U=T(sW,w);return await i(U)}async refreshAccessToken(z){let w=new URLSearchParams;w.set("grant_type","refresh_token"),w.set("refresh_token",z),w.set("client_id",this.clientId),w.set("client_secret",this.clientSecret);let U=T(sW,w);return await i(U)}}var DN="https://www.tumblr.com/oauth2/authorize",rW="https://api.tumblr.com/v2/oauth2/token";class v5{client;constructor(z,w,U){this.client=new y(z,w,U)}createAuthorizationURL(z,w){return this.client.createAuthorizationURL(DN,z,w)}async validateAuthorizationCode(z){return await this.client.validateAuthorizationCode(rW,z,null)}async refreshAccessToken(z){return await this.client.refreshAccessToken(rW,z,[])}}var PN="https://id.twitch.tv/oauth2/authorize",aW="https://id.twitch.tv/oauth2/token";class n5{clientId;clientSecret;redirectURI;constructor(z,w,U){this.clientId=z,this.clientSecret=w,this.redirectURI=U}createAuthorizationURL(z,w){let U=new URL(PN);if(U.searchParams.set("response_type","code"),U.searchParams.set("client_id",this.clientId),U.searchParams.set("state",z),w.length>0)U.searchParams.set("scope",w.join(" "));return U.searchParams.set("redirect_uri",this.redirectURI),U}async validateAuthorizationCode(z){let w=new URLSearchParams;w.set("grant_type","authorization_code"),w.set("code",z),w.set("redirect_uri",this.redirectURI),w.set("client_id",this.clientId),w.set("client_secret",this.clientSecret);let U=T(aW,w);return await i(U)}async refreshAccessToken(z){let w=new URLSearchParams;w.set("grant_type","refresh_token"),w.set("refresh_token",z),w.set("client_id",this.clientId),w.set("client_secret",this.clientSecret);let U=T(aW,w);return await i(U)}}var ON="https://twitter.com/i/oauth2/authorize",eW="https://api.twitter.com/2/oauth2/token",RN="https://api.twitter.com/2/oauth2/revoke";class u5{client;constructor(z,w,U){this.client=new y(z,w,U)}createAuthorizationURL(z,w,U){return this.client.createAuthorizationURLWithPKCE(ON,z,w0.S256,w,U)}async validateAuthorizationCode(z,w){return await this.client.validateAuthorizationCode(eW,z,w)}async refreshAccessToken(z){return await this.client.refreshAccessToken(eW,z,[])}async revokeToken(z){await this.client.revokeToken(RN,z)}}var CN="https://oauth.vk.com/authorize",bN="https://oauth.vk.com/access_token";class m5{clientId;clientSecret;redirectURI;constructor(z,w,U){this.clientId=z,this.clientSecret=w,this.redirectURI=U}createAuthorizationURL(z,w){let U=new URL(CN);if(U.searchParams.set("response_type","code"),U.searchParams.set("client_id",this.clientId),U.searchParams.set("state",z),w.length>0)U.searchParams.set("scope",w.join(" "));return U.searchParams.set("redirect_uri",this.redirectURI),U}async validateAuthorizationCode(z){let w=new URLSearchParams;w.set("grant_type","authorization_code"),w.set("code",z),w.set("redirect_uri",this.redirectURI),w.set("client_id",this.clientId),w.set("client_secret",this.clientSecret);let U=T(bN,w);return await i(U)}}var KN="https://api.workos.com/sso/authorize",jN="https://api.workos.com/sso/token";class t5{clientId;clientSecret;redirectURI;constructor(z,w,U){this.clientId=z,this.clientSecret=w,this.redirectURI=U}createAuthorizationURL(z,w){let U=new URL(KN);if(U.searchParams.set("response_type","code"),U.searchParams.set("client_id",this.clientId),U.searchParams.set("state",z),U.searchParams.set("redirect_uri",this.redirectURI),w!==null){let W=y2(w);U.searchParams.set("code_challenge_method","S256"),U.searchParams.set("code_challenge",W)}return U}async validateAuthorizationCode(z,w){let U=new URLSearchParams;if(U.set("grant_type","authorization_code"),U.set("code",z),U.set("redirect_uri",this.redirectURI),U.set("client_id",this.clientId),this.clientSecret!==null)U.set("client_secret",this.clientSecret);if(w!==null)U.set("code_verifier",w);let W=T(jN,U);return await i(W)}}var FN="https://api.login.yahoo.com/oauth2/request_auth",zX="https://api.login.yahoo.com/oauth2/get_token";class o5{client;constructor(z,w,U){this.client=new y(z,w,U)}createAuthorizationURL(z,w){return this.client.createAuthorizationURL(FN,z,w)}async validateAuthorizationCode(z){return await this.client.validateAuthorizationCode(zX,z,null)}async refreshAccessToken(z){return await this.client.refreshAccessToken(zX,z,[])}}var EN="https://oauth.yandex.com/authorize",wX="https://oauth.yandex.com/token";class p5{client;constructor(z,w,U){this.client=new y(z,w,U)}createAuthorizationURL(z,w){return this.client.createAuthorizationURL(EN,z,w)}async validateAuthorizationCode(z){return await this.client.validateAuthorizationCode(wX,z,null)}async refreshAccessToken(z){return await this.client.refreshAccessToken(wX,z,[])}}var IN="https://zoom.us/oauth/authorize",UX="https://zoom.us/oauth/token",xN="https://zoom.us/oauth/revoke";class l5{client;constructor(z,w,U){this.client=new y(z,w,U)}createAuthorizationURL(z,w,U){return this.client.createAuthorizationURLWithPKCE(IN,z,w0.S256,w,U)}async validateAuthorizationCode(z,w){return await this.client.validateAuthorizationCode(UX,z,w)}async refreshAccessToken(z){return await this.client.refreshAccessToken(UX,z,[])}async revokeToken(z){await this.client.revokeToken(xN,z)}}var VN="https://api.intra.42.fr/oauth/authorize",kN="https://api.intra.42.fr/oauth/token";class s5{clientId;clientSecret;redirectURI;constructor(z,w,U){this.clientId=z,this.clientSecret=w,this.redirectURI=U}createAuthorizationURL(z,w){let U=new URL(VN);if(U.searchParams.set("response_type","code"),U.searchParams.set("client_id",this.clientId),U.searchParams.set("state",z),w.length>0)U.searchParams.set("scope",w.join(" "));return U.searchParams.set("redirect_uri",this.redirectURI),U}async validateAuthorizationCode(z){let w=new URLSearchParams;w.set("grant_type","authorization_code"),w.set("code",z),w.set("redirect_uri",this.redirectURI),w.set("client_id",this.clientId),w.set("client_secret",this.clientSecret);let U=T(kN,w);return await i(U)}}function Jw(z){try{return RW(z)}catch(w){throw new Error("Invalid ID token",{cause:w})}}var U8={AmazonCognito:W5,AniList:X5,Apple:$5,Atlassian:A5,Auth0:Q5,Authentik:Y5,Bitbucket:J5,Box:B5,Coinbase:M5,Discord:q5,Dribbble:L5,Dropbox:G5,Facebook:N5,Figma:H5,Intuit:P5,GitHub:_5,GitLab:S5,Google:D5,Kakao:O5,KeyCloak:R5,Lichess:C5,Line:b5,Linear:K5,LinkedIn:j5,MicrosoftEntraId:F5,MyAnimeList:E5,Notion:I5,Okta:x5,Osu:V5,Patreon:k5,Reddit:T5,Roblox:g5,Salesforce:f5,Shikimori:d5,Slack:h5,Spotify:c5,Strava:i5,Tiltify:y5,Tumblr:v5,Twitch:n5,Twitter:u5,VK:m5,WorkOS:t5,Yahoo:o5,Yandex:p5,Zoom:l5,FortyTwo:s5},WX=Object.keys(U8).reduce((z,w)=>{return z[w.toLowerCase()]=w,z},{}),W8={AmazonCognito:"https://{region}.amazonaws.com/{userPoolId}/.well-known/openid-configuration",AniList:"https://graphql.anilist.co",Apple:"https://appleid.apple.com/auth/token",Atlassian:"https://api.atlassian.com/me",Auth0:"https://{your_domain}/userinfo",Authentik:"https://{your_domain}/api/v1/user/me",Bitbucket:"https://api.bitbucket.org/2.0/user",Box:"https://api.box.com/2.0/users/me",Coinbase:"https://api.coinbase.com/v2/user",Discord:"https://discord.com/api/users/@me",Dribbble:"https://api.dribbble.com/v2/user",Dropbox:"https://api.dropboxapi.com/2/users/get_current_account",Facebook:"https://graph.facebook.com/me",Figma:"https://api.figma.com/v1/me",Intuit:"https://accounts.platform.intuit.com/v1/openid_connect/userinfo",GitHub:"https://api.github.com/user",GitLab:"https://gitlab.com/api/v4/user",Google:"https://www.googleapis.com/userinfo/v2/me",Kakao:"https://kapi.kakao.com/v2/user/me",KeyCloak:"https://{your_domain}/auth/realms/{realm}/protocol/openid-connect/userinfo",Lichess:"https://lichess.org/api/account",Line:"https://api.line.me/v2/profile",Linear:"https://api.linear.app/v1/me",LinkedIn:"https://api.linkedin.com/v2/me",MicrosoftEntraId:"https://graph.microsoft.com/v1.0/me",MyAnimeList:"https://myanimelist.net/v1/users/@me",Notion:"https://api.notion.com/v1/users/me",Okta:"https://{yourOktaDomain}/oauth2/v1/userinfo",Osu:"https://osu.ppy.sh/api/v2/me",Patreon:"https://www.patreon.com/api/oauth2/v2/identity",Reddit:"https://oauth.reddit.com/api/v1/me",Roblox:"https://apis.roblox.com/users/v1/users/me",Salesforce:"https://login.salesforce.com/services/oauth2/userinfo",Shikimori:"https://shikimori.one/api/users/whoami",Slack:"https://slack.com/api/users.identity",Spotify:"https://api.spotify.com/v1/me",Strava:"https://www.strava.com/api/v3/athlete",Tiltify:"https://tiltify.com/api/v3/user",Tumblr:"https://api.tumblr.com/v2/user/info",Twitch:"https://api.twitch.tv/helix/users",Twitter:"https://api.twitter.com/2/users/me",VK:"https://api.vk.com/method/users.get",WorkOS:"https://api.workos.com/sso/profile",Yahoo:"https://api.login.yahoo.com/openid/v1/userinfo",Yandex:"https://login.yandex.ru/info",Zoom:"https://api.zoom.us/v2/users/me",FortyTwo:"https://api.intra.42.fr/v2/me"},XX={AmazonCognito:"https://cognito-idp.{region}.amazonaws.com/{userPoolId}",AniList:"https://anilist.co/api/v2/oauth/authorize",Apple:"https://appleid.apple.com",Atlassian:"https://auth.atlassian.com",Auth0:"https://{your_domain}.auth0.com",Authentik:"https://{your_domain}",Bitbucket:"https://bitbucket.org/site/oauth2/authorize",Box:"https://account.box.com/api/oauth2/authorize",Coinbase:"https://www.coinbase.com/oauth/authorize",Discord:"https://discord.com/api/oauth2/authorize",Dribbble:"https://dribbble.com/oauth/authorize",Dropbox:"https://www.dropbox.com/oauth2/authorize",Facebook:"https://www.facebook.com/v12.0/dialog/oauth",Figma:"https://www.figma.com/oauth",Intuit:"https://appcenter.intuit.com/connect/oauth2",GitHub:"https://github.com/login/oauth/authorize",GitLab:"https://gitlab.com/oauth/authorize",Google:"https://accounts.google.com",Kakao:"https://kauth.kakao.com/oauth/authorize",KeyCloak:"https://{your_domain}/auth",Lichess:"https://lichess.org/oauth/authorize",Line:"https://access.line.me/oauth2/v2.1/authorize",Linear:"https://linear.app/oauth/authorize",LinkedIn:"https://www.linkedin.com/oauth/v2/authorization",MicrosoftEntraId:"https://login.microsoftonline.com/{tenant}/v2.0",MyAnimeList:"https://myanimelist.net/v1/oauth2/authorize",Notion:"https://api.notion.com/v1/oauth/authorize",Okta:"https://{yourOktaDomain}/oauth2/default/v1/authorize",Osu:"https://osu.ppy.sh/oauth/authorize",Patreon:"https://www.patreon.com/oauth2/authorize",Reddit:"https://www.reddit.com/api/v1/authorize",Roblox:"https://apis.roblox.com/oauth/v1/authorize",Salesforce:"https://login.salesforce.com/services/oauth2/authorize",Shikimori:"https://shikimori.one/oauth/authorize",Slack:"https://slack.com/oauth/v2/authorize",Spotify:"https://accounts.spotify.com/authorize",Strava:"https://www.strava.com/oauth/authorize",Tiltify:"https://tiltify.com/oauth/authorize",Tumblr:"https://www.tumblr.com/oauth/authorize",Twitch:"https://id.twitch.tv/oauth2/authorize",Twitter:"https://api.twitter.com/oauth/authorize",VK:"https://oauth.vk.com/authorize",WorkOS:"https://api.workos.com/sso/authorize",Yahoo:"https://api.login.yahoo.com/oauth2/request_auth",Yandex:"https://oauth.yandex.com/authorize",Zoom:"https://zoom.us/oauth/authorize",FortyTwo:"https://api.intra.42.fr/oauth/authorize"},ZX=Object.keys(W8).reduce((z,w)=>{return z[w.toLowerCase()]=w,z},{}),Jf=Object.keys(XX).reduce((z,w)=>{return z[w.toLowerCase()]=w,z},{});var $X=({logoutRoute:z="logout",onLogout:w})=>{return new b0().post(`/${z}`,async({error:U,cookie:{user_session_id:W,auth_provider:X}})=>{if(X.value===void 0)return U(401,"No auth provider found");try{return w?.(),W.remove(),X.remove(),new Response("Succesfuly Logged Out",{status:204})}catch(Z){if(Z instanceof Error)console.error("Failed to refresh token:",Z.message);return U(500)}})};var AX=(z)=>{return"refreshAccessToken"in z&&typeof z.refreshAccessToken==="function"};var b6=(z)=>{return Object.keys(U8).map((w)=>w.toLowerCase()).includes(z.toLowerCase())},QX=(z)=>{return Object.keys(W8).includes(z)};var YX=(z)=>{return!0};var JX=({clientProviders:z,revokeRoute:w="revoke",onRevoke:U})=>{return new b0().post(`/${w}/access-token`,async({error:W,cookie:{user_refresh_token:X,auth_provider:Z}})=>{if(X.value===void 0)return W(401,"No refresh token found");if(Z.value===void 0)return W(401,"No auth provider found");if(!b6(Z.value))return W(400,"Invalid provider");let $=Z.value.toLowerCase(),{providerInstance:A}=z[$];U?.()})};var C4=()=>{return new b0({name:"sessionStore"}).state({session:{}})};var BX=({statusRoute:z="auth-status",onStatus:w})=>{return new b0().use(C4()).get(`/${z}`,async({error:U,cookie:{user_session_id:W,auth_provider:X},store:{session:Z}})=>{try{if(W.value===void 0)return new Response(JSON.stringify({user:null}),{headers:{"Content-Type":"application/json"}});if(X.value===void 0)return new Response(JSON.stringify({user:null}),{headers:{"Content-Type":"application/json"}});let $=Z[W.value];if($===void 0)return new Response(JSON.stringify({user:null}),{headers:{"Content-Type":"application/json"}});let A=$.user;return w?.(),new Response(JSON.stringify({user:A}),{headers:{"Content-Type":"application/json"}})}catch($){if($ instanceof Error)console.error("Failed to get auth status: ",$.message);return U(500)}})};var MX=({clientProviders:z,refreshRoute:w="refresh",onRefresh:U})=>{return new b0().post(`/${w}`,async({error:W,cookie:{user_refresh_token:X,auth_provider:Z}})=>{if(X.value===void 0)return W(401,"No refresh token found");if(Z.value===void 0)return W(401,"No auth provider found");let $=Z.value.toLowerCase(),{providerInstance:A}=z[$];if(!AX(A))return W(401,"Provider is not refreshable");try{let Q=await A.refreshAccessToken(X.value);return U?.(),new Response("Token refreshed",{status:204})}catch(Q){if(Q instanceof Error)console.error("Failed to refresh token:",Q.message);return W(500)}})};var qX=({clientProviders:z,authorizeRoute:w="authorize",onAuthorize:U})=>{return new b0().get(`/${w}/:provider`,({error:W,redirect:X,cookie:{state:Z,code_verifier:$,auth_provider:A,redirect_url:Q},params:{provider:Y},headers:J})=>{if(Y===void 0)return W(400,"Provider is required");if(!b6(Y))return W(400,"Invalid provider");try{let G=Y.toLowerCase(),{providerInstance:S,scopes:N,searchParams:O}=z[G],M=J.referer||"/";Q.set({value:M,secure:!0,sameSite:"lax",path:"/",httpOnly:!0,maxAge:600}),A.set({value:Y,secure:!0,sameSite:"lax",path:"/",httpOnly:!0,maxAge:600});let C=Aw();Z.set({value:C,secure:!0,sameSite:"lax",path:"/",httpOnly:!0,maxAge:600});let g,L0;if(S.createAuthorizationURL.toString().includes("codeVerifier"))L0=$w(),$.set({value:L0,secure:!0,sameSite:"lax",path:"/",httpOnly:!0,maxAge:600}),g=S.createAuthorizationURL(C,L0,N);else g=S.createAuthorizationURL(C,N);return O.forEach(([a,$0])=>{g.searchParams.set(a,$0)}),U?.(),X(g.toString())}catch(G){if(G instanceof Error)console.error("Failed to validate authorization code:",G.message);return W(500)}})};var LX=({clientProviders:z,callbackRoute:w="authorize/callback",onCallback:U,getUser:W,createUser:X})=>{return new b0().use(C4()).get(`/${w}`,async({error:Z,redirect:$,store:{session:A},cookie:{state:Q,code_verifier:Y,redirect_url:J,user_session_id:G,auth_provider:S},query:{code:N,state:O}})=>{if(!N||!Q.value)return Z(400,"Invalid callback request");if(O!==Q.value)return Z(400,"Invalid state mismatch");if(S.value===void 0)return Z(401,"No auth provider found");if(!b6(S.value))return Z(400,"Invalid provider");let M=S.value.toLowerCase(),{providerInstance:C}=z[M];try{let g;if(Q.remove(),C.validateAuthorizationCode.toString().includes("codeVerifier")){if(!Y.value)return Z(400,"Code verifier not found and is required");g=await C.validateAuthorizationCode(N,Y.value),Y.remove()}else g=await C.validateAuthorizationCode(N);let L0=Jw(g.idToken()),a=S.value,$0=await W?.({decodedIdToken:L0,authProvider:a});if($0===null||$0===void 0)$0=await X?.({decodedIdToken:L0,authProvider:a});let K0=crypto.randomUUID();if(!YX($0))return Z(500,"Invalid user schema");A[K0]={user:$0,expiresAt:Date.now()+86400000},G.set({value:K0,secure:!0,httpOnly:!0,sameSite:"lax"}),U?.();let f=J.value??"/";return $(f)}catch(g){if(g instanceof Error)console.error("Failed to validate authorization code:",g.message);return Z(500)}})};var GX=()=>{return new b0().use(C4()).derive(({store:{session:z},cookie:{user_session_id:w},error:U})=>{return{protectRoute:async(W,X)=>{if(w.value===void 0)return X?.()??U(401,"No session ID found");if(z[w.value]===void 0)return X?.()??U(401,"No session found");return W()}}}).as("plugin")};var rf=({config:z,authorizeRoute:w,callbackRoute:U,logoutRoute:W,statusRoute:X,refreshRoute:Z,revokeRoute:$,onAuthorize:A,onCallback:Q,onStatus:Y,onRefresh:J,onLogout:G,onRevoke:S,createUser:N,getUser:O})=>{let M=Object.entries(z).reduce((C,[g,L0={}])=>{let a=g.toLowerCase(),$0=WX[a],K0=ZX[a];if(!$0||!b6($0))return console.error(`Provider ${g} is not supported`),C;let f=U8[$0],V;if(QX(K0))V=W8[K0];let{credentials:k=[],scopes:j=[],searchParams:e=[]}=L0,Y0=new f(...k);return C[a]={providerInstance:Y0,scopes:j,searchParams:e,userInfoURL:V},C},{});return new b0().error("OAUTH2_REQUEST_ERROR",z8).error("ARCTIC_FETCH_ERROR",C6).use($X({logoutRoute:W,onLogout:G})).use(JX({clientProviders:M,revokeRoute:$,onRevoke:S})).use(BX({statusRoute:X,onStatus:Y})).use(MX({clientProviders:M,refreshRoute:Z,onRefresh:J})).use(qX({clientProviders:M,authorizeRoute:w,onAuthorize:A})).use(LX({clientProviders:M,callbackRoute:U,onCallback:Q,getUser:O,createUser:N})).use(GX()).as("plugin")};export{rf as absoluteAuth};
|