@absolutejs/auth 0.0.1 → 0.0.2

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.
Files changed (32) hide show
  1. package/dist/example/components/AuthOptions.d.ts +1 -0
  2. package/dist/example/components/Example.d.ts +1 -0
  3. package/dist/example/components/Head.d.ts +6 -0
  4. package/dist/example/components/Modal.d.ts +8 -0
  5. package/dist/example/components/Navbar.d.ts +10 -0
  6. package/dist/example/components/NotAuthorized.d.ts +1 -0
  7. package/dist/example/components/Protected.d.ts +1 -0
  8. package/dist/example/db/migrate.d.ts +1 -0
  9. package/dist/example/db/schema.d.ts +216 -0
  10. package/dist/example/hooks/useAuthStatus.d.ts +18 -0
  11. package/dist/example/indexes/ExampleIndex.d.ts +1 -0
  12. package/dist/example/indexes/NotAuthorizedIndex.d.ts +1 -0
  13. package/dist/example/indexes/ProtectedIndex.d.ts +1 -0
  14. package/dist/example/server.d.ts +1 -0
  15. package/dist/example/utils/networking.d.ts +1 -0
  16. package/dist/example/utils/pageUtils.d.ts +2 -0
  17. package/dist/example/utils/styles.d.ts +15 -0
  18. package/dist/example/utils/userUtils.d.ts +19 -0
  19. package/dist/index.js +208 -207
  20. package/dist/{callback.d.ts → src/callback.d.ts} +1 -1
  21. package/dist/{index.d.ts → src/index.d.ts} +5 -5
  22. package/dist/{logout.d.ts → src/logout.d.ts} +1 -1
  23. package/dist/{protectRoute.d.ts → src/protectRoute.d.ts} +2 -2
  24. package/dist/{refresh.d.ts → src/refresh.d.ts} +1 -1
  25. package/dist/{status.d.ts → src/status.d.ts} +2 -2
  26. package/package.json +14 -15
  27. /package/dist/{authorize.d.ts → src/authorize.d.ts} +0 -0
  28. /package/dist/{providers.d.ts → src/providers.d.ts} +0 -0
  29. /package/dist/{revoke.d.ts → src/revoke.d.ts} +0 -0
  30. /package/dist/{sessionStore.d.ts → src/sessionStore.d.ts} +0 -0
  31. /package/dist/{typeGuards.d.ts → src/typeGuards.d.ts} +0 -0
  32. /package/dist/{types.d.ts → src/types.d.ts} +0 -0
package/dist/index.js CHANGED
@@ -1,12 +1,13 @@
1
- var PW=Object.create;var{getPrototypeOf:OW,defineProperty:A5,getOwnPropertyNames:CW}=Object;var RW=Object.prototype.hasOwnProperty;var Ww=(w,z,A)=>{A=w!=null?PW(OW(w)):{};let U=z||!w||!w.__esModule?A5(A,"default",{value:w,enumerable:!0}):A;for(let W of CW(w))if(!RW.call(U,W))A5(U,W,{get:()=>w[W],enumerable:!0});return U};var Cz=(w,z)=>()=>(z||w((z={exports:{}}).exports,z),z.exports);var B6=(w,z)=>{for(var A in z)A5(w,A,{get:z[A],enumerable:!0,configurable:!0,set:(U)=>z[A]=()=>U})};var rA=Cz((sA)=>{Object.defineProperty(sA,"__esModule",{value:!0});sA.parse=EH;sA.serialize=IH;var CH=/^[\u0021-\u003A\u003C\u003E-\u007E]+$/,RH=/^[\u0021-\u003A\u003C-\u007E]*$/,KH=/^([.]?[a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?)([.][a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?)*$/i,jH=/^[\u0020-\u003A\u003D-\u007E]*$/,FH=Object.prototype.toString,xH=(()=>{let w=function(){};return w.prototype=Object.create(null),w})();function EH(w,z){let A=new xH,U=w.length;if(U<2)return A;let W=z?.decode||fH,$=0;do{let X=w.indexOf("=",$);if(X===-1)break;let Q=w.indexOf(";",$),Z=Q===-1?U:Q;if(X>Z){$=w.lastIndexOf(";",X-1)+1;continue}let J=pA(w,$,X),Y=lA(w,X,J),L=w.slice(J,Y);if(A[L]===void 0){let _=pA(w,X+1,Z),G=lA(w,Z,_),O=W(w.slice(_,G));A[L]=O}$=Z+1}while($<U);return A}function pA(w,z,A){do{let U=w.charCodeAt(z);if(U!==32&&U!==9)return z}while(++z<A);return A}function lA(w,z,A){while(z>A){let U=w.charCodeAt(--z);if(U!==32&&U!==9)return z+1}return A}function IH(w,z,A){let U=A?.encode||encodeURIComponent;if(!CH.test(w))throw new TypeError(`argument name is invalid: ${w}`);let W=U(z);if(!RH.test(W))throw new TypeError(`argument val is invalid: ${z}`);let $=w+"="+W;if(!A)return $;if(A.maxAge!==void 0){if(!Number.isInteger(A.maxAge))throw new TypeError(`option maxAge is invalid: ${A.maxAge}`);$+="; Max-Age="+A.maxAge}if(A.domain){if(!KH.test(A.domain))throw new TypeError(`option domain is invalid: ${A.domain}`);$+="; Domain="+A.domain}if(A.path){if(!jH.test(A.path))throw new TypeError(`option path is invalid: ${A.path}`);$+="; Path="+A.path}if(A.expires){if(!kH(A.expires)||!Number.isFinite(A.expires.valueOf()))throw new TypeError(`option expires is invalid: ${A.expires}`);$+="; Expires="+A.expires.toUTCString()}if(A.httpOnly)$+="; HttpOnly";if(A.secure)$+="; Secure";if(A.partitioned)$+="; Partitioned";if(A.priority)switch(typeof A.priority==="string"?A.priority.toLowerCase():void 0){case"low":$+="; Priority=Low";break;case"medium":$+="; Priority=Medium";break;case"high":$+="; Priority=High";break;default:throw new TypeError(`option priority is invalid: ${A.priority}`)}if(A.sameSite)switch(typeof A.sameSite==="string"?A.sameSite.toLowerCase():A.sameSite){case!0:case"strict":$+="; SameSite=Strict";break;case"lax":$+="; SameSite=Lax";break;case"none":$+="; SameSite=None";break;default:throw new TypeError(`option sameSite is invalid: ${A.sameSite}`)}return $}function fH(w){if(w.indexOf("%")===-1)return w;try{return decodeURIComponent(w)}catch(z){return w}}function kH(w){return FH.call(w)==="[object Date]"}});var ew=Cz((Ex,wU)=>{var aA=12,TH=0,Xz=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,4,4,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,6,7,7,7,7,7,7,7,7,7,7,7,7,8,7,7,10,9,9,9,11,4,4,4,4,4,4,4,4,4,4,4,0,0,0,0,0,0,0,0,0,0,0,0,12,0,0,0,0,24,36,48,60,72,84,96,0,12,12,12,0,0,0,0,0,0,0,0,0,0,0,24,0,0,0,0,0,0,0,0,0,24,24,24,0,0,0,0,0,0,0,0,0,24,24,0,0,0,0,0,0,0,0,0,0,48,48,48,0,0,0,0,0,0,0,0,0,0,48,48,0,0,0,0,0,0,0,0,0,48,0,0,0,0,0,0,0,0,0,0,127,63,63,63,0,31,15,15,15,7,7,7];function iH(w){var z=w.indexOf("%");if(z===-1)return w;var A=w.length,U="",W=0,$=0,X=z,Q=aA;while(z>-1&&z<A){var Z=eA(w[z+1],4),J=eA(w[z+2],0),Y=Z|J,L=Xz[Y];if(Q=Xz[256+Q+L],$=$<<6|Y&Xz[364+L],Q===aA)U+=w.slice(W,X),U+=$<=65535?String.fromCharCode($):String.fromCharCode(55232+($>>10),56320+($&1023)),$=0,W=z+3,z=X=w.indexOf("%",W);else if(Q===TH)return null;else{if(z+=3,z<A&&w.charCodeAt(z)===37)continue;return null}}return U+w.slice(W)}var dH={"0":0,"1":1,"2":2,"3":3,"4":4,"5":5,"6":6,"7":7,"8":8,"9":9,a:10,A:10,b:11,B:11,c:12,C:12,d:13,D:13,e:14,E:14,f:15,F:15};function eA(w,z){var A=dH[w];return A===void 0?255:A<<z}wU.exports=iH});var f6=(w,z)=>{let A=z?.length?{}:null;if(A)for(let U of z)A[U.part.charCodeAt(0)]=U;return{part:w,store:null,inert:A,params:null,wildcardStore:null}},Rz=(w,z)=>({...w,part:z}),Kz=(w)=>({name:w,store:null,inert:null}),$w=class w{root={};history=[];static regex={static:/:.+?(?=\/|$)/,params:/:.+?(?=\/|$)/g,optionalParams:/:.+?\?(?=\/|$)/g};add(z,A,U,{ignoreError:W=!1,ignoreHistory:$=!1}={}){if(typeof A!=="string")throw new TypeError("Route path must be a string");if(A==="")A="/";else if(A[0]!=="/")A=`/${A}`;let X=A[A.length-1]==="*",Q=A.match(w.regex.optionalParams);if(Q){let _=A.replaceAll("?","");this.add(z,_,U,{ignoreError:W});for(let G=0;G<Q.length;G++){let O=A.replace("/"+Q[G],"");this.add(z,O,U,{ignoreError:!0})}return U}if(Q)A=A.replaceAll("?","");if(this.history.find(([_,G,O])=>_===z&&G===A))return U;if(X||Q&&A.charCodeAt(A.length-1)===63)A=A.slice(0,-1);if(!$)this.history.push([z,A,U]);let Z=A.split(w.regex.static),J=A.match(w.regex.params)||[];if(Z[Z.length-1]==="")Z.pop();let Y;if(!this.root[z])Y=this.root[z]=f6("/");else Y=this.root[z];let L=0;for(let _=0;_<Z.length;++_){let G=Z[_];if(_>0){let O=J[L++].slice(1);if(Y.params===null)Y.params=Kz(O);else if(Y.params.name!==O)if(W)return U;else throw new Error(`Cannot create route "${A}" with parameter "${O}" because a route already exists with a different parameter name ("${Y.params.name}") in the same location`);let C=Y.params;if(C.inert===null){Y=C.inert=f6(G);continue}Y=C.inert}for(let O=0;;){if(O===G.length){if(O<Y.part.length){let C=Rz(Y,Y.part.slice(O));Object.assign(Y,f6(G,[C]))}break}if(O===Y.part.length){if(Y.inert===null)Y.inert={};let C=Y.inert[G.charCodeAt(O)];if(C){Y=C,G=G.slice(O),O=0;continue}let q=f6(G.slice(O));Y.inert[G.charCodeAt(O)]=q,Y=q;break}if(G[O]!==Y.part[O]){let C=Rz(Y,Y.part.slice(O)),q=f6(G.slice(O));Object.assign(Y,f6(Y.part.slice(0,O),[C,q])),Y=q;break}++O}}if(L<J.length){let G=J[L].slice(1);if(Y.params===null)Y.params=Kz(G);else if(Y.params.name!==G)if(W)return U;else throw new Error(`Cannot create route "${A}" with parameter "${G}" because a route already exists with a different parameter name ("${Y.params.name}") in the same location`);if(Y.params.store===null)Y.params.store=U;return Y.params.store}if(X){if(Y.wildcardStore===null)Y.wildcardStore=U;return Y.wildcardStore}if(Y.store===null)Y.store=U;return Y.store}find(z,A){let U=this.root[z];if(!U)return null;return U5(A,A.length,U,0)}},U5=(w,z,A,U)=>{let W=A.part,$=W.length,X=U+$;if($>1){if(X>z)return null;if($<15){for(let Q=1,Z=U+1;Q<$;++Q,++Z)if(W.charCodeAt(Q)!==w.charCodeAt(Z))return null}else if(w.slice(U,X)!==W)return null}if(X===z){if(A.store!==null)return{store:A.store,params:{}};if(A.wildcardStore!==null)return{store:A.wildcardStore,params:{"*":""}};return null}if(A.inert!==null){let Q=A.inert[w.charCodeAt(X)];if(Q!==void 0){let Z=U5(w,z,Q,X);if(Z!==null)return Z}}if(A.params!==null){let{store:Q,name:Z,inert:J}=A.params,Y=w.indexOf("/",X);if(Y!==X){if(Y===-1||Y>=z){if(Q!==null){let L={};return L[Z]=w.substring(X,z),{store:Q,params:L}}}else if(J!==null){let L=U5(w,z,J,Y);if(L!==null)return L.params[Z]=w.substring(X,Y),L}}}if(A.wildcardStore!==null)return{store:A.wildcardStore,params:{"*":w.substring(X,z)}};return null};var N2={};B6(N2,{IsUndefined:()=>l0,IsUint8Array:()=>R1,IsSymbol:()=>Z5,IsString:()=>x0,IsRegExp:()=>N4,IsObject:()=>_0,IsNumber:()=>d2,IsNull:()=>Q5,IsIterator:()=>X5,IsFunction:()=>$5,IsDate:()=>M6,IsBoolean:()=>C1,IsBigInt:()=>b4,IsAsyncIterator:()=>W5,IsArray:()=>y0,HasPropertyKey:()=>Xw});function Xw(w,z){return z in w}function W5(w){return _0(w)&&!y0(w)&&!R1(w)&&Symbol.asyncIterator in w}function y0(w){return Array.isArray(w)}function b4(w){return typeof w==="bigint"}function C1(w){return typeof w==="boolean"}function M6(w){return w instanceof globalThis.Date}function $5(w){return typeof w==="function"}function X5(w){return _0(w)&&!y0(w)&&!R1(w)&&Symbol.iterator in w}function Q5(w){return w===null}function d2(w){return typeof w==="number"}function _0(w){return typeof w==="object"&&w!==null}function N4(w){return w instanceof globalThis.RegExp}function x0(w){return typeof w==="string"}function Z5(w){return typeof w==="symbol"}function R1(w){return w instanceof globalThis.Uint8Array}function l0(w){return w===void 0}function KW(w){return w.map((z)=>Qw(z))}function jW(w){return new Date(w.getTime())}function FW(w){return new Uint8Array(w)}function xW(w){return new RegExp(w.source,w.flags)}function EW(w){let z={};for(let A of Object.getOwnPropertyNames(w))z[A]=Qw(w[A]);for(let A of Object.getOwnPropertySymbols(w))z[A]=Qw(w[A]);return z}function Qw(w){return y0(w)?KW(w):M6(w)?jW(w):R1(w)?FW(w):N4(w)?xW(w):_0(w)?EW(w):w}function f0(w){return Qw(w)}function jz(w,z){return z===void 0?f0(w):f0({...z,...w})}function Zw(w){return r(w)&&Symbol.asyncIterator in w}function Jw(w){return r(w)&&Symbol.iterator in w}function J5(w){return r(w)&&(Object.getPrototypeOf(w)===Object.prototype||Object.getPrototypeOf(w)===null)}function Yw(w){return w instanceof Promise}function S2(w){return w instanceof Date&&Number.isFinite(w.getTime())}function Fz(w){return w instanceof globalThis.Map}function xz(w){return w instanceof globalThis.Set}function c2(w){return ArrayBuffer.isView(w)}function k6(w){return w instanceof globalThis.Uint8Array}function y(w,z){return z in w}function r(w){return w!==null&&typeof w==="object"}function v(w){return Array.isArray(w)&&!ArrayBuffer.isView(w)}function k0(w){return w===void 0}function K1(w){return w===null}function G1(w){return typeof w==="boolean"}function d(w){return typeof w==="number"}function qw(w){return Number.isInteger(w)}function U2(w){return typeof w==="bigint"}function Q0(w){return typeof w==="string"}function o1(w){return typeof w==="function"}function j1(w){return typeof w==="symbol"}function k2(w){return U2(w)||G1(w)||K1(w)||d(w)||Q0(w)||j1(w)||k0(w)}var I0;(function(w){w.InstanceMode="default",w.ExactOptionalPropertyTypes=!1,w.AllowArrayObject=!1,w.AllowNaN=!1,w.AllowNullVoid=!1;function z(X,Q){return w.ExactOptionalPropertyTypes?Q in X:X[Q]!==void 0}w.IsExactOptionalProperty=z;function A(X){let Q=r(X);return w.AllowArrayObject?Q:Q&&!v(X)}w.IsObjectLike=A;function U(X){return A(X)&&!(X instanceof Date)&&!(X instanceof Uint8Array)}w.IsRecordLike=U;function W(X){return w.AllowNaN?d(X):Number.isFinite(X)}w.IsNumberLike=W;function $(X){let Q=k0(X);return w.AllowNullVoid?Q||X===null:Q}w.IsVoidLike=$})(I0||(I0={}));function IW(w){return globalThis.Object.freeze(w).map((z)=>S4(z))}function fW(w){return w}function kW(w){return w}function VW(w){return w}function gW(w){let z={};for(let A of Object.getOwnPropertyNames(w))z[A]=S4(w[A]);for(let A of Object.getOwnPropertySymbols(w))z[A]=S4(w[A]);return globalThis.Object.freeze(z)}function S4(w){return y0(w)?IW(w):M6(w)?fW(w):R1(w)?kW(w):N4(w)?VW(w):_0(w)?gW(w):w}function D(w,z){let A=z!==void 0?{...z,...w}:w;switch(I0.InstanceMode){case"freeze":return S4(A);case"clone":return f0(A);default:return A}}class n extends Error{constructor(w){super(w)}}var j0=Symbol.for("TypeBox.Transform"),A1=Symbol.for("TypeBox.Readonly"),W2=Symbol.for("TypeBox.Optional"),n2=Symbol.for("TypeBox.Hint"),b=Symbol.for("TypeBox.Kind");function Bw(w){return _0(w)&&w[A1]==="Readonly"}function h2(w){return _0(w)&&w[W2]==="Optional"}function Y5(w){return Z0(w,"Any")}function F1(w){return Z0(w,"Array")}function D4(w){return Z0(w,"AsyncIterator")}function q5(w){return Z0(w,"BigInt")}function B5(w){return Z0(w,"Boolean")}function O2(w){return Z0(w,"Computed")}function _4(w){return Z0(w,"Constructor")}function TW(w){return Z0(w,"Date")}function P4(w){return Z0(w,"Function")}function H6(w){return Z0(w,"Integer")}function v0(w){return Z0(w,"Intersect")}function O4(w){return Z0(w,"Iterator")}function Z0(w,z){return _0(w)&&b in w&&w[b]===z}function Mw(w){return C1(w)||d2(w)||x0(w)}function x1(w){return Z0(w,"Literal")}function V2(w){return Z0(w,"MappedKey")}function V0(w){return Z0(w,"MappedResult")}function u1(w){return Z0(w,"Never")}function iW(w){return Z0(w,"Not")}function dW(w){return Z0(w,"Null")}function G6(w){return Z0(w,"Number")}function s0(w){return Z0(w,"Object")}function C4(w){return Z0(w,"Promise")}function M5(w){return Z0(w,"Record")}function d0(w){return Z0(w,"Ref")}function H5(w){return Z0(w,"RegExp")}function R4(w){return Z0(w,"String")}function cW(w){return Z0(w,"Symbol")}function g2(w){return Z0(w,"TemplateLiteral")}function nW(w){return Z0(w,"This")}function N0(w){return _0(w)&&j0 in w}function U1(w){return Z0(w,"Tuple")}function K4(w){return Z0(w,"Undefined")}function M0(w){return Z0(w,"Union")}function hW(w){return Z0(w,"Uint8Array")}function tW(w){return Z0(w,"Unknown")}function yW(w){return Z0(w,"Unsafe")}function vW(w){return Z0(w,"Void")}function m1(w){return _0(w)&&b in w&&x0(w[b])}function T0(w){return Y5(w)||F1(w)||B5(w)||q5(w)||D4(w)||O2(w)||_4(w)||TW(w)||P4(w)||H6(w)||v0(w)||O4(w)||x1(w)||V2(w)||V0(w)||u1(w)||iW(w)||dW(w)||G6(w)||s0(w)||C4(w)||M5(w)||d0(w)||H5(w)||R4(w)||cW(w)||g2(w)||nW(w)||U1(w)||K4(w)||M0(w)||hW(w)||tW(w)||yW(w)||vW(w)||m1(w)}var M={};B6(M,{TypeGuardUnknownTypeError:()=>Iz,IsVoid:()=>b9,IsUnsafe:()=>L9,IsUnknown:()=>G9,IsUnionLiteral:()=>eW,IsUnion:()=>b5,IsUndefined:()=>M9,IsUint8Array:()=>H9,IsTuple:()=>B9,IsTransform:()=>q9,IsThis:()=>Y9,IsTemplateLiteral:()=>J9,IsSymbol:()=>Z9,IsString:()=>Q9,IsSchema:()=>g0,IsRegExp:()=>X9,IsRef:()=>$9,IsRecursive:()=>aW,IsRecord:()=>W9,IsReadonly:()=>pW,IsProperties:()=>Hw,IsPromise:()=>U9,IsOptional:()=>lW,IsObject:()=>A9,IsNumber:()=>z9,IsNull:()=>w9,IsNot:()=>ez,IsNever:()=>az,IsMappedResult:()=>rz,IsMappedKey:()=>sz,IsLiteralValue:()=>lz,IsLiteralString:()=>mz,IsLiteralNumber:()=>pz,IsLiteralBoolean:()=>rW,IsLiteral:()=>F4,IsKindOf:()=>w0,IsKind:()=>N9,IsIterator:()=>uz,IsIntersect:()=>oz,IsInteger:()=>vz,IsImport:()=>sW,IsFunction:()=>yz,IsDate:()=>tz,IsConstructor:()=>hz,IsComputed:()=>nz,IsBoolean:()=>cz,IsBigInt:()=>dz,IsAsyncIterator:()=>iz,IsArray:()=>Tz,IsAny:()=>gz});class Iz extends n{}var oW=["Any","Array","AsyncIterator","BigInt","Boolean","Computed","Constructor","Date","Enum","Function","Integer","Intersect","Iterator","Literal","MappedKey","MappedResult","Not","Null","Number","Object","Promise","Record","Ref","RegExp","String","Symbol","TemplateLiteral","This","Tuple","Undefined","Union","Uint8Array","Unknown","Void"];function fz(w){try{return new RegExp(w),!0}catch{return!1}}function G5(w){if(!x0(w))return!1;for(let z=0;z<w.length;z++){let A=w.charCodeAt(z);if(A>=7&&A<=13||A===27||A===127)return!1}return!0}function kz(w){return L5(w)||g0(w)}function j4(w){return l0(w)||b4(w)}function E0(w){return l0(w)||d2(w)}function L5(w){return l0(w)||C1(w)}function P0(w){return l0(w)||x0(w)}function uW(w){return l0(w)||x0(w)&&G5(w)&&fz(w)}function mW(w){return l0(w)||x0(w)&&G5(w)}function Vz(w){return l0(w)||g0(w)}function pW(w){return _0(w)&&w[A1]==="Readonly"}function lW(w){return _0(w)&&w[W2]==="Optional"}function gz(w){return w0(w,"Any")&&P0(w.$id)}function Tz(w){return w0(w,"Array")&&w.type==="array"&&P0(w.$id)&&g0(w.items)&&E0(w.minItems)&&E0(w.maxItems)&&L5(w.uniqueItems)&&Vz(w.contains)&&E0(w.minContains)&&E0(w.maxContains)}function iz(w){return w0(w,"AsyncIterator")&&w.type==="AsyncIterator"&&P0(w.$id)&&g0(w.items)}function dz(w){return w0(w,"BigInt")&&w.type==="bigint"&&P0(w.$id)&&j4(w.exclusiveMaximum)&&j4(w.exclusiveMinimum)&&j4(w.maximum)&&j4(w.minimum)&&j4(w.multipleOf)}function cz(w){return w0(w,"Boolean")&&w.type==="boolean"&&P0(w.$id)}function nz(w){return w0(w,"Computed")&&x0(w.target)&&y0(w.parameters)&&w.parameters.every((z)=>g0(z))}function hz(w){return w0(w,"Constructor")&&w.type==="Constructor"&&P0(w.$id)&&y0(w.parameters)&&w.parameters.every((z)=>g0(z))&&g0(w.returns)}function tz(w){return w0(w,"Date")&&w.type==="Date"&&P0(w.$id)&&E0(w.exclusiveMaximumTimestamp)&&E0(w.exclusiveMinimumTimestamp)&&E0(w.maximumTimestamp)&&E0(w.minimumTimestamp)&&E0(w.multipleOfTimestamp)}function yz(w){return w0(w,"Function")&&w.type==="Function"&&P0(w.$id)&&y0(w.parameters)&&w.parameters.every((z)=>g0(z))&&g0(w.returns)}function sW(w){return w0(w,"Import")&&Xw(w,"$defs")&&_0(w.$defs)&&Hw(w.$defs)&&Xw(w,"$ref")&&x0(w.$ref)&&w.$ref in w.$defs}function vz(w){return w0(w,"Integer")&&w.type==="integer"&&P0(w.$id)&&E0(w.exclusiveMaximum)&&E0(w.exclusiveMinimum)&&E0(w.maximum)&&E0(w.minimum)&&E0(w.multipleOf)}function Hw(w){return _0(w)&&Object.entries(w).every(([z,A])=>G5(z)&&g0(A))}function oz(w){return w0(w,"Intersect")&&(x0(w.type)&&w.type!=="object"?!1:!0)&&y0(w.allOf)&&w.allOf.every((z)=>g0(z)&&!q9(z))&&P0(w.type)&&(L5(w.unevaluatedProperties)||Vz(w.unevaluatedProperties))&&P0(w.$id)}function uz(w){return w0(w,"Iterator")&&w.type==="Iterator"&&P0(w.$id)&&g0(w.items)}function w0(w,z){return _0(w)&&b in w&&w[b]===z}function mz(w){return F4(w)&&x0(w.const)}function pz(w){return F4(w)&&d2(w.const)}function rW(w){return F4(w)&&C1(w.const)}function F4(w){return w0(w,"Literal")&&P0(w.$id)&&lz(w.const)}function lz(w){return C1(w)||d2(w)||x0(w)}function sz(w){return w0(w,"MappedKey")&&y0(w.keys)&&w.keys.every((z)=>d2(z)||x0(z))}function rz(w){return w0(w,"MappedResult")&&Hw(w.properties)}function az(w){return w0(w,"Never")&&_0(w.not)&&Object.getOwnPropertyNames(w.not).length===0}function ez(w){return w0(w,"Not")&&g0(w.not)}function w9(w){return w0(w,"Null")&&w.type==="null"&&P0(w.$id)}function z9(w){return w0(w,"Number")&&w.type==="number"&&P0(w.$id)&&E0(w.exclusiveMaximum)&&E0(w.exclusiveMinimum)&&E0(w.maximum)&&E0(w.minimum)&&E0(w.multipleOf)}function A9(w){return w0(w,"Object")&&w.type==="object"&&P0(w.$id)&&Hw(w.properties)&&kz(w.additionalProperties)&&E0(w.minProperties)&&E0(w.maxProperties)}function U9(w){return w0(w,"Promise")&&w.type==="Promise"&&P0(w.$id)&&g0(w.item)}function W9(w){return w0(w,"Record")&&w.type==="object"&&P0(w.$id)&&kz(w.additionalProperties)&&_0(w.patternProperties)&&((z)=>{let A=Object.getOwnPropertyNames(z.patternProperties);return A.length===1&&fz(A[0])&&_0(z.patternProperties)&&g0(z.patternProperties[A[0]])})(w)}function aW(w){return _0(w)&&n2 in w&&w[n2]==="Recursive"}function $9(w){return w0(w,"Ref")&&P0(w.$id)&&x0(w.$ref)}function X9(w){return w0(w,"RegExp")&&P0(w.$id)&&x0(w.source)&&x0(w.flags)&&E0(w.maxLength)&&E0(w.minLength)}function Q9(w){return w0(w,"String")&&w.type==="string"&&P0(w.$id)&&E0(w.minLength)&&E0(w.maxLength)&&uW(w.pattern)&&mW(w.format)}function Z9(w){return w0(w,"Symbol")&&w.type==="symbol"&&P0(w.$id)}function J9(w){return w0(w,"TemplateLiteral")&&w.type==="string"&&x0(w.pattern)&&w.pattern[0]==="^"&&w.pattern[w.pattern.length-1]==="$"}function Y9(w){return w0(w,"This")&&P0(w.$id)&&x0(w.$ref)}function q9(w){return _0(w)&&j0 in w}function B9(w){return w0(w,"Tuple")&&w.type==="array"&&P0(w.$id)&&d2(w.minItems)&&d2(w.maxItems)&&w.minItems===w.maxItems&&(l0(w.items)&&l0(w.additionalItems)&&w.minItems===0||y0(w.items)&&w.items.every((z)=>g0(z)))}function M9(w){return w0(w,"Undefined")&&w.type==="undefined"&&P0(w.$id)}function eW(w){return b5(w)&&w.anyOf.every((z)=>mz(z)||pz(z))}function b5(w){return w0(w,"Union")&&P0(w.$id)&&_0(w)&&y0(w.anyOf)&&w.anyOf.every((z)=>g0(z))}function H9(w){return w0(w,"Uint8Array")&&w.type==="Uint8Array"&&P0(w.$id)&&E0(w.minByteLength)&&E0(w.maxByteLength)}function G9(w){return w0(w,"Unknown")&&P0(w.$id)}function L9(w){return w0(w,"Unsafe")}function b9(w){return w0(w,"Void")&&w.type==="void"&&P0(w.$id)}function N9(w){return _0(w)&&b in w&&x0(w[b])&&!oW.includes(w[b])}function g0(w){return _0(w)&&(gz(w)||Tz(w)||cz(w)||dz(w)||iz(w)||nz(w)||hz(w)||tz(w)||yz(w)||vz(w)||oz(w)||uz(w)||F4(w)||sz(w)||rz(w)||az(w)||ez(w)||w9(w)||z9(w)||A9(w)||U9(w)||W9(w)||$9(w)||X9(w)||Q9(w)||Z9(w)||J9(w)||Y9(w)||B9(w)||M9(w)||b5(w)||H9(w)||G9(w)||L9(w)||b9(w)||N9(w))}var S9="(true|false)",Gw="(0|[1-9][0-9]*)",D9="(.*)";var E1="^(0|[1-9][0-9]*)$",I1="^(.*)$",_9="^(?!.*)$";var O0={};B6(O0,{Set:()=>W$,Has:()=>U$,Get:()=>$$,Entries:()=>w$,Delete:()=>A$,Clear:()=>z$});var V6=new Map;function w$(){return new Map(V6)}function z$(){return V6.clear()}function A$(w){return V6.delete(w)}function U$(w){return V6.has(w)}function W$(w,z){V6.set(w,z)}function $$(w){return V6.get(w)}var c0={};B6(c0,{Set:()=>Y$,Has:()=>J$,Get:()=>q$,Entries:()=>X$,Delete:()=>Z$,Clear:()=>Q$});var g6=new Map;function X$(){return new Map(g6)}function Q$(){return g6.clear()}function Z$(w){return g6.delete(w)}function J$(w){return g6.has(w)}function Y$(w,z){g6.set(w,z)}function q$(w){return g6.get(w)}function P9(w,z){return w.includes(z)}function O9(w){return[...new Set(w)]}function B$(w,z){return w.filter((A)=>z.includes(A))}function M$(w,z){return w.reduce((A,U)=>{return B$(A,U)},z)}function C9(w){return w.length===1?w[0]:w.length>1?M$(w.slice(1),w[0]):[]}function R9(w){let z=[];for(let A of w)z.push(...A);return z}function p1(w){return D({[b]:"Any"},w)}function T6(w,z){return D({[b]:"Array",type:"array",items:w},z)}function i6(w,z){return D({[b]:"AsyncIterator",type:"AsyncIterator",items:w},z)}function b0(w,z,A){return D({[b]:"Computed",target:w,parameters:z},A)}function H$(w,z){let{[z]:A,...U}=w;return U}function n0(w,z){return z.reduce((A,U)=>H$(A,U),w)}function H0(w){return D({[b]:"Never",not:{}},w)}function J0(w){return D({[b]:"MappedResult",properties:w})}function d6(w,z,A){return D({[b]:"Constructor",type:"Constructor",parameters:w,returns:z},A)}function L1(w,z,A){return D({[b]:"Function",type:"Function",parameters:w,returns:z},A)}function x4(w,z){return D({[b]:"Union",anyOf:w},z)}function G$(w){return w.some((z)=>h2(z))}function K9(w){return w.map((z)=>h2(z)?L$(z):z)}function L$(w){return n0(w,[W2])}function b$(w,z){return G$(w)?C2(x4(K9(w),z)):x4(K9(w),z)}function b1(w,z){return w.length===1?D(w[0],z):w.length===0?H0(z):b$(w,z)}function G0(w,z){return w.length===0?H0(z):w.length===1?D(w[0],z):x4(w,z)}class N5 extends n{}function N$(w){return w.replace(/\\\$/g,"$").replace(/\\\*/g,"*").replace(/\\\^/g,"^").replace(/\\\|/g,"|").replace(/\\\(/g,"(").replace(/\\\)/g,")")}function S5(w,z,A){return w[z]===A&&w.charCodeAt(z-1)!==92}function f1(w,z){return S5(w,z,"(")}function E4(w,z){return S5(w,z,")")}function j9(w,z){return S5(w,z,"|")}function S$(w){if(!(f1(w,0)&&E4(w,w.length-1)))return!1;let z=0;for(let A=0;A<w.length;A++){if(f1(w,A))z+=1;if(E4(w,A))z-=1;if(z===0&&A!==w.length-1)return!1}return!0}function D$(w){return w.slice(1,w.length-1)}function _$(w){let z=0;for(let A=0;A<w.length;A++){if(f1(w,A))z+=1;if(E4(w,A))z-=1;if(j9(w,A)&&z===0)return!0}return!1}function P$(w){for(let z=0;z<w.length;z++)if(f1(w,z))return!0;return!1}function O$(w){let[z,A]=[0,0],U=[];for(let $=0;$<w.length;$++){if(f1(w,$))z+=1;if(E4(w,$))z-=1;if(j9(w,$)&&z===0){let X=w.slice(A,$);if(X.length>0)U.push(c6(X));A=$+1}}let W=w.slice(A);if(W.length>0)U.push(c6(W));if(U.length===0)return{type:"const",const:""};if(U.length===1)return U[0];return{type:"or",expr:U}}function C$(w){function z(W,$){if(!f1(W,$))throw new N5("TemplateLiteralParser: Index must point to open parens");let X=0;for(let Q=$;Q<W.length;Q++){if(f1(W,Q))X+=1;if(E4(W,Q))X-=1;if(X===0)return[$,Q]}throw new N5("TemplateLiteralParser: Unclosed group parens in expression")}function A(W,$){for(let X=$;X<W.length;X++)if(f1(W,X))return[$,X];return[$,W.length]}let U=[];for(let W=0;W<w.length;W++)if(f1(w,W)){let[$,X]=z(w,W),Q=w.slice($,X+1);U.push(c6(Q)),W=X}else{let[$,X]=A(w,W),Q=w.slice($,X);if(Q.length>0)U.push(c6(Q));W=X-1}return U.length===0?{type:"const",const:""}:U.length===1?U[0]:{type:"and",expr:U}}function c6(w){return S$(w)?c6(D$(w)):_$(w)?O$(w):P$(w)?C$(w):{type:"const",const:N$(w)}}function n6(w){return c6(w.slice(1,w.length-1))}class F9 extends n{}function R$(w){return w.type==="or"&&w.expr.length===2&&w.expr[0].type==="const"&&w.expr[0].const==="0"&&w.expr[1].type==="const"&&w.expr[1].const==="[1-9][0-9]*"}function K$(w){return w.type==="or"&&w.expr.length===2&&w.expr[0].type==="const"&&w.expr[0].const==="true"&&w.expr[1].type==="const"&&w.expr[1].const==="false"}function j$(w){return w.type==="const"&&w.const===".*"}function L6(w){return R$(w)||j$(w)?!1:K$(w)?!0:w.type==="and"?w.expr.every((z)=>L6(z)):w.type==="or"?w.expr.every((z)=>L6(z)):w.type==="const"?!0:(()=>{throw new F9("Unknown expression type")})()}function Lw(w){let z=n6(w.pattern);return L6(z)}class x9 extends n{}function*E9(w){if(w.length===1)return yield*w[0];for(let z of w[0])for(let A of E9(w.slice(1)))yield`${z}${A}`}function*F$(w){return yield*E9(w.expr.map((z)=>[...I4(z)]))}function*x$(w){for(let z of w.expr)yield*I4(z)}function*E$(w){return yield w.const}function*I4(w){return w.type==="and"?yield*F$(w):w.type==="or"?yield*x$(w):w.type==="const"?yield*E$(w):(()=>{throw new x9("Unknown expression")})()}function h6(w){let z=n6(w.pattern);return L6(z)?[...I4(z)]:[]}function X0(w,z){return D({[b]:"Literal",const:w,type:typeof w},z)}function bw(w){return D({[b]:"Boolean",type:"boolean"},w)}function t6(w){return D({[b]:"BigInt",type:"bigint"},w)}function N1(w){return D({[b]:"Number",type:"number"},w)}function t2(w){return D({[b]:"String",type:"string"},w)}function*I$(w){let z=w.trim().replace(/"|'/g,"");return z==="boolean"?yield bw():z==="number"?yield N1():z==="bigint"?yield t6():z==="string"?yield t2():yield(()=>{let A=z.split("|").map((U)=>X0(U.trim()));return A.length===0?H0():A.length===1?A[0]:b1(A)})()}function*f$(w){if(w[1]!=="{"){let z=X0("$"),A=D5(w.slice(1));return yield*[z,...A]}for(let z=2;z<w.length;z++)if(w[z]==="}"){let A=I$(w.slice(2,z)),U=D5(w.slice(z+1));return yield*[...A,...U]}yield X0(w)}function*D5(w){for(let z=0;z<w.length;z++)if(w[z]==="$"){let A=X0(w.slice(0,z)),U=f$(w.slice(z));return yield*[A,...U]}yield X0(w)}function I9(w){return[...D5(w)]}class f9 extends n{}function k$(w){return w.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function k9(w,z){return g2(w)?w.pattern.slice(1,w.pattern.length-1):M0(w)?`(${w.anyOf.map((A)=>k9(A,z)).join("|")})`:G6(w)?`${z}${Gw}`:H6(w)?`${z}${Gw}`:q5(w)?`${z}${Gw}`:R4(w)?`${z}${D9}`:x1(w)?`${z}${k$(w.const.toString())}`:B5(w)?`${z}${S9}`:(()=>{throw new f9(`Unexpected Kind '${w[b]}'`)})()}function _5(w){return`^${w.map((z)=>k9(z,"")).join("")}$`}function b6(w){let A=h6(w).map((U)=>X0(U));return b1(A)}function Nw(w,z){let A=x0(w)?_5(I9(w)):_5(w);return D({[b]:"TemplateLiteral",type:"string",pattern:A},z)}function V$(w){return h6(w).map((A)=>A.toString())}function g$(w){let z=[];for(let A of w)z.push(...R2(A));return z}function T$(w){return[w.toString()]}function R2(w){return[...new Set(g2(w)?V$(w):M0(w)?g$(w.anyOf):x1(w)?T$(w.const):G6(w)?["[number]"]:H6(w)?["[number]"]:[])]}function i$(w,z,A){let U={};for(let W of Object.getOwnPropertyNames(z))U[W]=l1(w,R2(z[W]),A);return U}function d$(w,z,A){return i$(w,z.properties,A)}function V9(w,z,A){let U=d$(w,z,A);return J0(U)}function T9(w,z){return w.map((A)=>i9(A,z))}function c$(w){return w.filter((z)=>!u1(z))}function n$(w,z){return Sw(c$(T9(w,z)))}function h$(w){return w.some((z)=>u1(z))?[]:w}function t$(w,z){return b1(h$(T9(w,z)))}function y$(w,z){return z in w?w[z]:z==="[number]"?b1(w):H0()}function v$(w,z){return z==="[number]"?w:H0()}function o$(w,z){return z in w?w[z]:H0()}function i9(w,z){return v0(w)?n$(w.allOf,z):M0(w)?t$(w.anyOf,z):U1(w)?y$(w.items??[],z):F1(w)?v$(w.items,z):s0(w)?o$(w.properties,z):H0()}function f4(w,z){return z.map((A)=>i9(w,A))}function g9(w,z){return b1(f4(w,z))}function l1(w,z,A){if(d0(w)||d0(z)){if(!T0(w)||!T0(z))throw new n("Index types using Ref parameters require both Type and Key to be of TSchema");return b0("Index",[w,z])}if(V0(z))return V9(w,z,A);if(V2(z))return d9(w,z,A);return D(T0(z)?g9(w,R2(z)):g9(w,z),A)}function u$(w,z,A){return{[z]:l1(w,[z],f0(A))}}function m$(w,z,A){return z.reduce((U,W)=>{return{...U,...u$(w,W,A)}},{})}function p$(w,z,A){return m$(w,z.keys,A)}function d9(w,z,A){let U=p$(w,z,A);return J0(U)}function y6(w,z){return D({[b]:"Iterator",type:"Iterator",items:w},z)}function l$(w){let z=[];for(let A in w)if(!h2(w[A]))z.push(A);return z}function s$(w,z){let A=l$(w),U=A.length>0?{[b]:"Object",type:"object",properties:w,required:A}:{[b]:"Object",type:"object",properties:w};return D(U,z)}var S0=s$;function Dw(w,z){return D({[b]:"Promise",type:"Promise",item:w},z)}function r$(w){return D(n0(w,[A1]))}function a$(w){return D({...w,[A1]:"Readonly"})}function e$(w,z){return z===!1?r$(w):a$(w)}function y2(w,z){let A=z??!0;return V0(w)?c9(w,A):e$(w,A)}function wX(w,z){let A={};for(let U of globalThis.Object.getOwnPropertyNames(w))A[U]=y2(w[U],z);return A}function zX(w,z){return wX(w.properties,z)}function c9(w,z){let A=zX(w,z);return J0(A)}function v2(w,z){return D(w.length>0?{[b]:"Tuple",type:"array",items:w,additionalItems:!1,minItems:w.length,maxItems:w.length}:{[b]:"Tuple",type:"array",minItems:w.length,maxItems:w.length},z)}function n9(w,z){return w in z?o2(w,z[w]):J0(z)}function AX(w){return{[w]:X0(w)}}function UX(w){let z={};for(let A of w)z[A]=X0(A);return z}function WX(w,z){return P9(z,w)?AX(w):UX(z)}function $X(w,z){let A=WX(w,z);return n9(w,A)}function k4(w,z){return z.map((A)=>o2(w,A))}function XX(w,z){let A={};for(let U of globalThis.Object.getOwnPropertyNames(z))A[U]=o2(w,z[U]);return A}function o2(w,z){let A={...z};return h2(z)?C2(o2(w,n0(z,[W2]))):Bw(z)?y2(o2(w,n0(z,[A1]))):V0(z)?n9(w,z.properties):V2(z)?$X(w,z.keys):_4(z)?d6(k4(w,z.parameters),o2(w,z.returns),A):P4(z)?L1(k4(w,z.parameters),o2(w,z.returns),A):D4(z)?i6(o2(w,z.items),A):O4(z)?y6(o2(w,z.items),A):v0(z)?Z2(k4(w,z.allOf),A):M0(z)?G0(k4(w,z.anyOf),A):U1(z)?v2(k4(w,z.items??[]),A):s0(z)?S0(XX(w,z.properties),A):F1(z)?T6(o2(w,z.items),A):C4(z)?Dw(o2(w,z.item),A):z}function QX(w,z){let A={};for(let U of w)A[U]=o2(U,z);return A}function h9(w,z,A){let U=T0(w)?R2(w):w,W=z({[b]:"MappedKey",keys:U}),$=QX(U,W);return S0($,A)}function ZX(w){return D(n0(w,[W2]))}function JX(w){return D({...w,[W2]:"Optional"})}function YX(w,z){return z===!1?ZX(w):JX(w)}function C2(w,z){let A=z??!0;return V0(w)?t9(w,A):YX(w,A)}function qX(w,z){let A={};for(let U of globalThis.Object.getOwnPropertyNames(w))A[U]=C2(w[U],z);return A}function BX(w,z){return qX(w.properties,z)}function t9(w,z){let A=BX(w,z);return J0(A)}function V4(w,z={}){let A=w.every((W)=>s0(W)),U=T0(z.unevaluatedProperties)?{unevaluatedProperties:z.unevaluatedProperties}:{};return D(z.unevaluatedProperties===!1||T0(z.unevaluatedProperties)||A?{...U,[b]:"Intersect",type:"object",allOf:w}:{...U,[b]:"Intersect",allOf:w},z)}function MX(w){return w.every((z)=>h2(z))}function HX(w){return n0(w,[W2])}function y9(w){return w.map((z)=>h2(z)?HX(z):z)}function GX(w,z){return MX(w)?C2(V4(y9(w),z)):V4(y9(w),z)}function Sw(w,z={}){if(w.length===1)return D(w[0],z);if(w.length===0)return H0(z);if(w.some((A)=>N0(A)))throw new Error("Cannot intersect transform types");return GX(w,z)}function Z2(w,z){if(w.length===1)return D(w[0],z);if(w.length===0)return H0(z);if(w.some((A)=>N0(A)))throw new Error("Cannot intersect transform types");return V4(w,z)}function K2(...w){let[z,A]=typeof w[0]==="string"?[w[0],w[1]]:[w[0].$id,w[1]];if(typeof z!=="string")throw new n("Ref: $ref must be a string");return D({[b]:"Ref",$ref:z},A)}function LX(w,z){return b0("Awaited",[b0(w,z)])}function bX(w){return b0("Awaited",[K2(w)])}function NX(w){return Z2(v9(w))}function SX(w){return G0(v9(w))}function DX(w){return v6(w)}function v9(w){return w.map((z)=>v6(z))}function v6(w,z){return D(O2(w)?LX(w.target,w.parameters):v0(w)?NX(w.allOf):M0(w)?SX(w.anyOf):C4(w)?DX(w.item):d0(w)?bX(w.$ref):w,z)}function o9(w){let z=[];for(let A of w)z.push(j2(A));return z}function _X(w){let z=o9(w);return R9(z)}function PX(w){let z=o9(w);return C9(z)}function OX(w){return w.map((z,A)=>A.toString())}function CX(w){return["[number]"]}function RX(w){return globalThis.Object.getOwnPropertyNames(w)}function KX(w){if(!P5)return[];return globalThis.Object.getOwnPropertyNames(w).map((A)=>{return A[0]==="^"&&A[A.length-1]==="$"?A.slice(1,A.length-1):A})}function j2(w){return v0(w)?_X(w.allOf):M0(w)?PX(w.anyOf):U1(w)?OX(w.items??[]):F1(w)?CX(w.items):s0(w)?RX(w.properties):M5(w)?KX(w.patternProperties):[]}var P5=!1;function k1(w){P5=!0;let z=j2(w);return P5=!1,`^(${z.map((U)=>`(${U})`).join("|")})$`}function jX(w,z){return b0("KeyOf",[b0(w,z)])}function FX(w){return b0("KeyOf",[K2(w)])}function xX(w,z){let A=j2(w),U=EX(A),W=b1(U);return D(W,z)}function EX(w){return w.map((z)=>z==="[number]"?N1():X0(z))}function o6(w,z){return O2(w)?jX(w.target,w.parameters):d0(w)?FX(w.$ref):V0(w)?u9(w,z):xX(w,z)}function IX(w,z){let A={};for(let U of globalThis.Object.getOwnPropertyNames(w))A[U]=o6(w[U],f0(z));return A}function fX(w,z){return IX(w.properties,z)}function u9(w,z){let A=fX(w,z);return J0(A)}function _w(w){let z=j2(w),A=f4(w,z);return z.map((U,W)=>[z[W],A[W]])}function kX(w){let z=[];for(let A of w)z.push(...j2(A));return O9(z)}function VX(w){return w.filter((z)=>!u1(z))}function gX(w,z){let A=[];for(let U of w)A.push(...f4(U,[z]));return VX(A)}function TX(w,z){let A={};for(let U of z)A[U]=Sw(gX(w,U));return A}function m9(w,z){let A=kX(w),U=TX(w,A);return S0(U,z)}function Pw(w){return D({[b]:"Date",type:"Date"},w)}function Ow(w){return D({[b]:"Null",type:"null"},w)}function Cw(w){return D({[b]:"Symbol",type:"symbol"},w)}function Rw(w){return D({[b]:"Undefined",type:"undefined"},w)}function Kw(w){return D({[b]:"Uint8Array",type:"Uint8Array"},w)}function V1(w){return D({[b]:"Unknown"},w)}function iX(w){return w.map((z)=>O5(z,!1))}function dX(w){let z={};for(let A of globalThis.Object.getOwnPropertyNames(w))z[A]=y2(O5(w[A],!1));return z}function jw(w,z){return z===!0?w:y2(w)}function O5(w,z){return W5(w)?jw(p1(),z):X5(w)?jw(p1(),z):y0(w)?y2(v2(iX(w))):R1(w)?Kw():M6(w)?Pw():_0(w)?jw(S0(dX(w)),z):$5(w)?jw(L1([],V1()),z):l0(w)?Rw():Q5(w)?Ow():Z5(w)?Cw():b4(w)?t6():d2(w)?X0(w):C1(w)?X0(w):x0(w)?X0(w):S0({})}function p9(w,z){return D(O5(w,!0),z)}function l9(w,z){return v2(w.parameters,z)}function s9(w,z){if(l0(w))throw new Error("Enum undefined or empty");let A=globalThis.Object.getOwnPropertyNames(w).filter(($)=>isNaN($)).map(($)=>w[$]),W=[...new Set(A)].map(($)=>X0($));return G0(W,{...z,[n2]:"Enum"})}class z7 extends n{}var S;(function(w){w[w.Union=0]="Union",w[w.True=1]="True",w[w.False=2]="False"})(S||(S={}));function u2(w){return w===S.False?w:S.True}function u6(w){throw new z7(w)}function o0(w){return M.IsNever(w)||M.IsIntersect(w)||M.IsUnion(w)||M.IsUnknown(w)||M.IsAny(w)}function u0(w,z){return M.IsNever(z)?W7(w,z):M.IsIntersect(z)?Fw(w,z):M.IsUnion(z)?F5(w,z):M.IsUnknown(z)?Z7(w,z):M.IsAny(z)?j5(w,z):u6("StructuralRight")}function j5(w,z){return S.True}function cX(w,z){return M.IsIntersect(z)?Fw(w,z):M.IsUnion(z)&&z.anyOf.some((A)=>M.IsAny(A)||M.IsUnknown(A))?S.True:M.IsUnion(z)?S.Union:M.IsUnknown(z)?S.True:M.IsAny(z)?S.True:S.Union}function nX(w,z){return M.IsUnknown(w)?S.False:M.IsAny(w)?S.Union:M.IsNever(w)?S.True:S.False}function hX(w,z){return M.IsObject(z)&&xw(z)?S.True:o0(z)?u0(w,z):!M.IsArray(z)?S.False:u2(C0(w.items,z.items))}function tX(w,z){return o0(z)?u0(w,z):!M.IsAsyncIterator(z)?S.False:u2(C0(w.items,z.items))}function yX(w,z){return o0(z)?u0(w,z):M.IsObject(z)?J2(w,z):M.IsRecord(z)?m2(w,z):M.IsBigInt(z)?S.True:S.False}function A7(w,z){return M.IsLiteralBoolean(w)?S.True:M.IsBoolean(w)?S.True:S.False}function vX(w,z){return o0(z)?u0(w,z):M.IsObject(z)?J2(w,z):M.IsRecord(z)?m2(w,z):M.IsBoolean(z)?S.True:S.False}function oX(w,z){return o0(z)?u0(w,z):M.IsObject(z)?J2(w,z):!M.IsConstructor(z)?S.False:w.parameters.length>z.parameters.length?S.False:!w.parameters.every((A,U)=>u2(C0(z.parameters[U],A))===S.True)?S.False:u2(C0(w.returns,z.returns))}function uX(w,z){return o0(z)?u0(w,z):M.IsObject(z)?J2(w,z):M.IsRecord(z)?m2(w,z):M.IsDate(z)?S.True:S.False}function mX(w,z){return o0(z)?u0(w,z):M.IsObject(z)?J2(w,z):!M.IsFunction(z)?S.False:w.parameters.length>z.parameters.length?S.False:!w.parameters.every((A,U)=>u2(C0(z.parameters[U],A))===S.True)?S.False:u2(C0(w.returns,z.returns))}function U7(w,z){return M.IsLiteral(w)&&N2.IsNumber(w.const)?S.True:M.IsNumber(w)||M.IsInteger(w)?S.True:S.False}function pX(w,z){return M.IsInteger(z)||M.IsNumber(z)?S.True:o0(z)?u0(w,z):M.IsObject(z)?J2(w,z):M.IsRecord(z)?m2(w,z):S.False}function Fw(w,z){return z.allOf.every((A)=>C0(w,A)===S.True)?S.True:S.False}function lX(w,z){return w.allOf.some((A)=>C0(A,z)===S.True)?S.True:S.False}function sX(w,z){return o0(z)?u0(w,z):!M.IsIterator(z)?S.False:u2(C0(w.items,z.items))}function rX(w,z){return M.IsLiteral(z)&&z.const===w.const?S.True:o0(z)?u0(w,z):M.IsObject(z)?J2(w,z):M.IsRecord(z)?m2(w,z):M.IsString(z)?Q7(w,z):M.IsNumber(z)?$7(w,z):M.IsInteger(z)?U7(w,z):M.IsBoolean(z)?A7(w,z):S.False}function W7(w,z){return S.False}function aX(w,z){return S.True}function r9(w){let[z,A]=[w,0];while(!0){if(!M.IsNot(z))break;z=z.not,A+=1}return A%2===0?z:V1()}function eX(w,z){return M.IsNot(w)?C0(r9(w),z):M.IsNot(z)?C0(w,r9(z)):u6("Invalid fallthrough for Not")}function wQ(w,z){return o0(z)?u0(w,z):M.IsObject(z)?J2(w,z):M.IsRecord(z)?m2(w,z):M.IsNull(z)?S.True:S.False}function $7(w,z){return M.IsLiteralNumber(w)?S.True:M.IsNumber(w)||M.IsInteger(w)?S.True:S.False}function zQ(w,z){return o0(z)?u0(w,z):M.IsObject(z)?J2(w,z):M.IsRecord(z)?m2(w,z):M.IsInteger(z)||M.IsNumber(z)?S.True:S.False}function F2(w,z){return Object.getOwnPropertyNames(w.properties).length===z}function a9(w){return xw(w)}function e9(w){return F2(w,0)||F2(w,1)&&"description"in w.properties&&M.IsUnion(w.properties.description)&&w.properties.description.anyOf.length===2&&(M.IsString(w.properties.description.anyOf[0])&&M.IsUndefined(w.properties.description.anyOf[1])||M.IsString(w.properties.description.anyOf[1])&&M.IsUndefined(w.properties.description.anyOf[0]))}function C5(w){return F2(w,0)}function w7(w){return F2(w,0)}function AQ(w){return F2(w,0)}function UQ(w){return F2(w,0)}function WQ(w){return xw(w)}function $Q(w){let z=N1();return F2(w,0)||F2(w,1)&&"length"in w.properties&&u2(C0(w.properties.length,z))===S.True}function XQ(w){return F2(w,0)}function xw(w){let z=N1();return F2(w,0)||F2(w,1)&&"length"in w.properties&&u2(C0(w.properties.length,z))===S.True}function QQ(w){let z=L1([p1()],p1());return F2(w,0)||F2(w,1)&&"then"in w.properties&&u2(C0(w.properties.then,z))===S.True}function X7(w,z){return C0(w,z)===S.False?S.False:M.IsOptional(w)&&!M.IsOptional(z)?S.False:S.True}function J2(w,z){return M.IsUnknown(w)?S.False:M.IsAny(w)?S.Union:M.IsNever(w)||M.IsLiteralString(w)&&a9(z)||M.IsLiteralNumber(w)&&C5(z)||M.IsLiteralBoolean(w)&&w7(z)||M.IsSymbol(w)&&e9(z)||M.IsBigInt(w)&&AQ(z)||M.IsString(w)&&a9(z)||M.IsSymbol(w)&&e9(z)||M.IsNumber(w)&&C5(z)||M.IsInteger(w)&&C5(z)||M.IsBoolean(w)&&w7(z)||M.IsUint8Array(w)&&WQ(z)||M.IsDate(w)&&UQ(z)||M.IsConstructor(w)&&XQ(z)||M.IsFunction(w)&&$Q(z)?S.True:M.IsRecord(w)&&M.IsString(R5(w))?(()=>{return z[n2]==="Record"?S.True:S.False})():M.IsRecord(w)&&M.IsNumber(R5(w))?(()=>{return F2(z,0)?S.True:S.False})():S.False}function ZQ(w,z){return o0(z)?u0(w,z):M.IsRecord(z)?m2(w,z):!M.IsObject(z)?S.False:(()=>{for(let A of Object.getOwnPropertyNames(z.properties)){if(!(A in w.properties)&&!M.IsOptional(z.properties[A]))return S.False;if(M.IsOptional(z.properties[A]))return S.True;if(X7(w.properties[A],z.properties[A])===S.False)return S.False}return S.True})()}function JQ(w,z){return o0(z)?u0(w,z):M.IsObject(z)&&QQ(z)?S.True:!M.IsPromise(z)?S.False:u2(C0(w.item,z.item))}function R5(w){return E1 in w.patternProperties?N1():(I1 in w.patternProperties)?t2():u6("Unknown record key pattern")}function K5(w){return E1 in w.patternProperties?w.patternProperties[E1]:(I1 in w.patternProperties)?w.patternProperties[I1]:u6("Unable to get record value schema")}function m2(w,z){let[A,U]=[R5(z),K5(z)];return M.IsLiteralString(w)&&M.IsNumber(A)&&u2(C0(w,U))===S.True?S.True:M.IsUint8Array(w)&&M.IsNumber(A)?C0(w,U):M.IsString(w)&&M.IsNumber(A)?C0(w,U):M.IsArray(w)&&M.IsNumber(A)?C0(w,U):M.IsObject(w)?(()=>{for(let W of Object.getOwnPropertyNames(w.properties))if(X7(U,w.properties[W])===S.False)return S.False;return S.True})():S.False}function YQ(w,z){return o0(z)?u0(w,z):M.IsObject(z)?J2(w,z):!M.IsRecord(z)?S.False:C0(K5(w),K5(z))}function qQ(w,z){let A=M.IsRegExp(w)?t2():w,U=M.IsRegExp(z)?t2():z;return C0(A,U)}function Q7(w,z){return M.IsLiteral(w)&&N2.IsString(w.const)?S.True:M.IsString(w)?S.True:S.False}function BQ(w,z){return o0(z)?u0(w,z):M.IsObject(z)?J2(w,z):M.IsRecord(z)?m2(w,z):M.IsString(z)?S.True:S.False}function MQ(w,z){return o0(z)?u0(w,z):M.IsObject(z)?J2(w,z):M.IsRecord(z)?m2(w,z):M.IsSymbol(z)?S.True:S.False}function HQ(w,z){return M.IsTemplateLiteral(w)?C0(b6(w),z):M.IsTemplateLiteral(z)?C0(w,b6(z)):u6("Invalid fallthrough for TemplateLiteral")}function GQ(w,z){return M.IsArray(z)&&w.items!==void 0&&w.items.every((A)=>C0(A,z.items)===S.True)}function LQ(w,z){return M.IsNever(w)?S.True:M.IsUnknown(w)?S.False:M.IsAny(w)?S.Union:S.False}function bQ(w,z){return o0(z)?u0(w,z):M.IsObject(z)&&xw(z)?S.True:M.IsArray(z)&&GQ(w,z)?S.True:!M.IsTuple(z)?S.False:N2.IsUndefined(w.items)&&!N2.IsUndefined(z.items)||!N2.IsUndefined(w.items)&&N2.IsUndefined(z.items)?S.False:N2.IsUndefined(w.items)&&!N2.IsUndefined(z.items)?S.True:w.items.every((A,U)=>C0(A,z.items[U])===S.True)?S.True:S.False}function NQ(w,z){return o0(z)?u0(w,z):M.IsObject(z)?J2(w,z):M.IsRecord(z)?m2(w,z):M.IsUint8Array(z)?S.True:S.False}function SQ(w,z){return o0(z)?u0(w,z):M.IsObject(z)?J2(w,z):M.IsRecord(z)?m2(w,z):M.IsVoid(z)?PQ(w,z):M.IsUndefined(z)?S.True:S.False}function F5(w,z){return z.anyOf.some((A)=>C0(w,A)===S.True)?S.True:S.False}function DQ(w,z){return w.anyOf.every((A)=>C0(A,z)===S.True)?S.True:S.False}function Z7(w,z){return S.True}function _Q(w,z){return M.IsNever(z)?W7(w,z):M.IsIntersect(z)?Fw(w,z):M.IsUnion(z)?F5(w,z):M.IsAny(z)?j5(w,z):M.IsString(z)?Q7(w,z):M.IsNumber(z)?$7(w,z):M.IsInteger(z)?U7(w,z):M.IsBoolean(z)?A7(w,z):M.IsArray(z)?nX(w,z):M.IsTuple(z)?LQ(w,z):M.IsObject(z)?J2(w,z):M.IsUnknown(z)?S.True:S.False}function PQ(w,z){return M.IsUndefined(w)?S.True:M.IsUndefined(w)?S.True:S.False}function OQ(w,z){return M.IsIntersect(z)?Fw(w,z):M.IsUnion(z)?F5(w,z):M.IsUnknown(z)?Z7(w,z):M.IsAny(z)?j5(w,z):M.IsObject(z)?J2(w,z):M.IsVoid(z)?S.True:S.False}function C0(w,z){return M.IsTemplateLiteral(w)||M.IsTemplateLiteral(z)?HQ(w,z):M.IsRegExp(w)||M.IsRegExp(z)?qQ(w,z):M.IsNot(w)||M.IsNot(z)?eX(w,z):M.IsAny(w)?cX(w,z):M.IsArray(w)?hX(w,z):M.IsBigInt(w)?yX(w,z):M.IsBoolean(w)?vX(w,z):M.IsAsyncIterator(w)?tX(w,z):M.IsConstructor(w)?oX(w,z):M.IsDate(w)?uX(w,z):M.IsFunction(w)?mX(w,z):M.IsInteger(w)?pX(w,z):M.IsIntersect(w)?lX(w,z):M.IsIterator(w)?sX(w,z):M.IsLiteral(w)?rX(w,z):M.IsNever(w)?aX(w,z):M.IsNull(w)?wQ(w,z):M.IsNumber(w)?zQ(w,z):M.IsObject(w)?ZQ(w,z):M.IsRecord(w)?YQ(w,z):M.IsString(w)?BQ(w,z):M.IsSymbol(w)?MQ(w,z):M.IsTuple(w)?bQ(w,z):M.IsPromise(w)?JQ(w,z):M.IsUint8Array(w)?NQ(w,z):M.IsUndefined(w)?SQ(w,z):M.IsUnion(w)?DQ(w,z):M.IsUnknown(w)?_Q(w,z):M.IsVoid(w)?OQ(w,z):u6(`Unknown left type operand '${w[b]}'`)}function s1(w,z){return C0(w,z)}function CQ(w,z,A,U,W){let $={};for(let X of globalThis.Object.getOwnPropertyNames(w))$[X]=m6(w[X],z,A,U,f0(W));return $}function RQ(w,z,A,U,W){return CQ(w.properties,z,A,U,W)}function J7(w,z,A,U,W){let $=RQ(w,z,A,U,W);return J0($)}function KQ(w,z,A,U){let W=s1(w,z);return W===S.Union?G0([A,U]):W===S.True?A:U}function m6(w,z,A,U,W){return V0(w)?J7(w,z,A,U,W):V2(w)?D(Y7(w,z,A,U,W)):D(KQ(w,z,A,U),W)}function jQ(w,z,A,U,W){return{[w]:m6(X0(w),z,A,U,f0(W))}}function FQ(w,z,A,U,W){return w.reduce(($,X)=>{return{...$,...jQ(X,z,A,U,W)}},{})}function xQ(w,z,A,U,W){return FQ(w.keys,z,A,U,W)}function Y7(w,z,A,U,W){let $=xQ(w,z,A,U,W);return J0($)}function EQ(w){return w.allOf.every((z)=>g1(z))}function IQ(w){return w.anyOf.some((z)=>g1(z))}function fQ(w){return!g1(w.not)}function g1(w){return w[b]==="Intersect"?EQ(w):w[b]==="Union"?IQ(w):w[b]==="Not"?fQ(w):w[b]==="Undefined"?!0:!1}function q7(w,z){return p6(b6(w),z)}function kQ(w,z){let A=w.filter((U)=>s1(U,z)===S.False);return A.length===1?A[0]:G0(A)}function p6(w,z,A={}){if(g2(w))return D(q7(w,z),A);if(V0(w))return D(B7(w,z),A);return D(M0(w)?kQ(w.anyOf,z):s1(w,z)!==S.False?H0():w,A)}function VQ(w,z){let A={};for(let U of globalThis.Object.getOwnPropertyNames(w))A[U]=p6(w[U],z);return A}function gQ(w,z){return VQ(w.properties,z)}function B7(w,z){let A=gQ(w,z);return J0(A)}function M7(w,z){return l6(b6(w),z)}function TQ(w,z){let A=w.filter((U)=>s1(U,z)!==S.False);return A.length===1?A[0]:G0(A)}function l6(w,z,A){if(g2(w))return D(M7(w,z),A);if(V0(w))return D(H7(w,z),A);return D(M0(w)?TQ(w.anyOf,z):s1(w,z)!==S.False?w:H0(),A)}function iQ(w,z){let A={};for(let U of globalThis.Object.getOwnPropertyNames(w))A[U]=l6(w[U],z);return A}function dQ(w,z){return iQ(w.properties,z)}function H7(w,z){let A=dQ(w,z);return J0(A)}function G7(w,z){return D(w.returns,z)}function L7(w){return D({[b]:"Integer",type:"integer"},w)}function cQ(w,z,A){return{[w]:W1(X0(w),z,f0(A))}}function nQ(w,z,A){return w.reduce((W,$)=>{return{...W,...cQ($,z,A)}},{})}function hQ(w,z,A){return nQ(w.keys,z,A)}function b7(w,z,A){let U=hQ(w,z,A);return J0(U)}function tQ(w){let[z,A]=[w.slice(0,1),w.slice(1)];return[z.toLowerCase(),A].join("")}function yQ(w){let[z,A]=[w.slice(0,1),w.slice(1)];return[z.toUpperCase(),A].join("")}function vQ(w){return w.toUpperCase()}function oQ(w){return w.toLowerCase()}function uQ(w,z,A){let U=n6(w.pattern);if(!L6(U))return{...w,pattern:N7(w.pattern,z)};let X=[...I4(U)].map((J)=>X0(J)),Q=S7(X,z),Z=G0(Q);return Nw([Z],A)}function N7(w,z){return typeof w==="string"?z==="Uncapitalize"?tQ(w):z==="Capitalize"?yQ(w):z==="Uppercase"?vQ(w):z==="Lowercase"?oQ(w):w:w.toString()}function S7(w,z){return w.map((A)=>W1(A,z))}function W1(w,z,A={}){return V2(w)?b7(w,z,A):g2(w)?uQ(w,z,A):M0(w)?G0(S7(w.anyOf,z),A):x1(w)?X0(N7(w.const,z),A):D(w,A)}function D7(w,z={}){return W1(w,"Capitalize",z)}function _7(w,z={}){return W1(w,"Lowercase",z)}function P7(w,z={}){return W1(w,"Uncapitalize",z)}function O7(w,z={}){return W1(w,"Uppercase",z)}function mQ(w,z,A){let U={};for(let W of globalThis.Object.getOwnPropertyNames(w))U[W]=r1(w[W],z,f0(A));return U}function pQ(w,z,A){return mQ(w.properties,z,A)}function C7(w,z,A){let U=pQ(w,z,A);return J0(U)}function lQ(w,z){return w.map((A)=>x5(A,z))}function sQ(w,z){return w.map((A)=>x5(A,z))}function rQ(w,z){let{[z]:A,...U}=w;return U}function aQ(w,z){return z.reduce((A,U)=>rQ(A,U),w)}function eQ(w,z){let A=n0(w,[j0,"$id","required","properties"]),U=aQ(w.properties,z);return S0(U,A)}function wZ(w){let z=w.reduce((A,U)=>Mw(U)?[...A,X0(U)]:A,[]);return G0(z)}function x5(w,z){return v0(w)?Z2(lQ(w.allOf,z)):M0(w)?G0(sQ(w.anyOf,z)):s0(w)?eQ(w,z):S0({})}function r1(w,z,A){let U=y0(z)?wZ(z):z,W=T0(z)?R2(z):z,$=d0(w),X=d0(z);return V0(w)?C7(w,W,A):V2(z)?R7(w,z,A):$&&X?b0("Omit",[w,U],A):!$&&X?b0("Omit",[w,U],A):$&&!X?b0("Omit",[w,U],A):D({...x5(w,W),...A})}function zZ(w,z,A){return{[z]:r1(w,[z],f0(A))}}function AZ(w,z,A){return z.reduce((U,W)=>{return{...U,...zZ(w,W,A)}},{})}function UZ(w,z,A){return AZ(w,z.keys,A)}function R7(w,z,A){let U=UZ(w,z,A);return J0(U)}function WZ(w,z,A){let U={};for(let W of globalThis.Object.getOwnPropertyNames(w))U[W]=a1(w[W],z,f0(A));return U}function $Z(w,z,A){return WZ(w.properties,z,A)}function K7(w,z,A){let U=$Z(w,z,A);return J0(U)}function XZ(w,z){return w.map((A)=>E5(A,z))}function QZ(w,z){return w.map((A)=>E5(A,z))}function ZZ(w,z){let A={};for(let U of z)if(U in w)A[U]=w[U];return A}function JZ(w,z){let A=n0(w,[j0,"$id","required","properties"]),U=ZZ(w.properties,z);return S0(U,A)}function YZ(w){let z=w.reduce((A,U)=>Mw(U)?[...A,X0(U)]:A,[]);return G0(z)}function E5(w,z){return v0(w)?Z2(XZ(w.allOf,z)):M0(w)?G0(QZ(w.anyOf,z)):s0(w)?JZ(w,z):S0({})}function a1(w,z,A){let U=y0(z)?YZ(z):z,W=T0(z)?R2(z):z,$=d0(w),X=d0(z);return V0(w)?K7(w,W,A):V2(z)?j7(w,z,A):$&&X?b0("Pick",[w,U],A):!$&&X?b0("Pick",[w,U],A):$&&!X?b0("Pick",[w,U],A):D({...E5(w,W),...A})}function qZ(w,z,A){return{[z]:a1(w,[z],f0(A))}}function BZ(w,z,A){return z.reduce((U,W)=>{return{...U,...qZ(w,W,A)}},{})}function MZ(w,z,A){return BZ(w,z.keys,A)}function j7(w,z,A){let U=MZ(w,z,A);return J0(U)}function HZ(w,z){return b0("Partial",[b0(w,z)])}function GZ(w){return b0("Partial",[K2(w)])}function LZ(w){let z={};for(let A of globalThis.Object.getOwnPropertyNames(w))z[A]=C2(w[A]);return z}function bZ(w){let z=n0(w,[j0,"$id","required","properties"]),A=LZ(w.properties);return S0(A,z)}function F7(w){return w.map((z)=>x7(z))}function x7(w){return O2(w)?HZ(w.target,w.parameters):d0(w)?GZ(w.$ref):v0(w)?Z2(F7(w.allOf)):M0(w)?G0(F7(w.anyOf)):s0(w)?bZ(w):S0({})}function s6(w,z){if(V0(w))return E7(w,z);else return D({...x7(w),...z})}function NZ(w,z){let A={};for(let U of globalThis.Object.getOwnPropertyNames(w))A[U]=s6(w[U],f0(z));return A}function SZ(w,z){return NZ(w.properties,z)}function E7(w,z){let A=SZ(w,z);return J0(A)}function N6(w,z,A){return D({[b]:"Record",type:"object",patternProperties:{[w]:z}},A)}function I5(w,z,A){let U={};for(let W of w)U[W]=z;return S0(U,{...A,[n2]:"Record"})}function DZ(w,z,A){return Lw(w)?I5(R2(w),z,A):N6(w.pattern,z,A)}function _Z(w,z,A){return I5(R2(G0(w)),z,A)}function PZ(w,z,A){return I5([w.toString()],z,A)}function OZ(w,z,A){return N6(w.source,z,A)}function CZ(w,z,A){let U=l0(w.pattern)?I1:w.pattern;return N6(U,z,A)}function RZ(w,z,A){return N6(I1,z,A)}function KZ(w,z,A){return N6(_9,z,A)}function jZ(w,z,A){return N6(E1,z,A)}function FZ(w,z,A){return N6(E1,z,A)}function Ew(w,z,A={}){return O2(z)?b0("Record",[w,b0(z.target,z.parameters)],A):O2(w)?b0("Record",[b0(z.target,z.parameters),z],A):d0(w)?b0("Record",[K2(w.$ref),z]):M0(w)?_Z(w.anyOf,z,A):g2(w)?DZ(w,z,A):x1(w)?PZ(w.const,z,A):H6(w)?jZ(w,z,A):G6(w)?FZ(w,z,A):H5(w)?OZ(w,z,A):R4(w)?CZ(w,z,A):Y5(w)?RZ(w,z,A):u1(w)?KZ(w,z,A):H0(A)}function xZ(w,z){return b0("Required",[b0(w,z)])}function EZ(w){return b0("Required",[K2(w)])}function IZ(w){let z={};for(let A of globalThis.Object.getOwnPropertyNames(w))z[A]=n0(w[A],[W2]);return z}function fZ(w){let z=n0(w,[j0,"$id","required","properties"]),A=IZ(w.properties);return S0(A,z)}function I7(w){return w.map((z)=>f7(z))}function f7(w){return O2(w)?xZ(w.target,w.parameters):d0(w)?EZ(w.$ref):v0(w)?Z2(I7(w.allOf)):M0(w)?G0(I7(w.anyOf)):s0(w)?fZ(w):S0({})}function r6(w,z){if(V0(w))return k7(w,z);else return D({...f7(w),...z})}function kZ(w,z){let A={};for(let U of globalThis.Object.getOwnPropertyNames(w))A[U]=r6(w[U],z);return A}function VZ(w,z){return kZ(w.properties,z)}function k7(w,z){let A=VZ(w,z);return J0(A)}function gZ(w,z){return z.map((A)=>{return d0(A)?V7(w,A.$ref):p2(w,A)})}function V7(w,z){return z in w?d0(w[z])?V7(w,w[z].$ref):p2(w,w[z]):H0()}function TZ(w){return v6(w[0])}function iZ(w){return l1(w[0],w[1])}function dZ(w){return o6(w[0])}function cZ(w){return s6(w[0])}function nZ(w){return r1(w[0],w[1])}function hZ(w){return a1(w[0],w[1])}function tZ(w){return Ew(w[0],w[1])}function yZ(w){return r6(w[0])}function vZ(w,z,A){let U=gZ(w,A);return z==="Awaited"?TZ(U):z==="Index"?iZ(U):z==="KeyOf"?dZ(U):z==="Partial"?cZ(U):z==="Omit"?nZ(U):z==="Pick"?hZ(U):z==="Record"?tZ(U):z==="Required"?yZ(U):H0()}function oZ(w,z){return S0(globalThis.Object.keys(z).reduce((A,U)=>{return{...A,[U]:p2(w,z[U])}},{}))}function uZ(w,z,A){return d6(g4(w,z),p2(w,A))}function mZ(w,z,A){return L1(g4(w,z),p2(w,A))}function pZ(w,z){return v2(g4(w,z))}function lZ(w,z){return Z2(g4(w,z))}function sZ(w,z){return G0(g4(w,z))}function rZ(w,z){return T6(p2(w,z))}function aZ(w,z){return i6(p2(w,z))}function eZ(w,z){return y6(p2(w,z))}function g4(w,z){return z.map((A)=>p2(w,A))}function p2(w,z){return h2(z)?D(p2(w,n0(z,[W2])),z):Bw(z)?D(p2(w,n0(z,[A1])),z):F1(z)?D(rZ(w,z.items),z):D4(z)?D(aZ(w,z.items),z):O2(z)?D(vZ(w,z.target,z.parameters)):_4(z)?D(uZ(w,z.parameters,z.returns),z):P4(z)?D(mZ(w,z.parameters,z.returns),z):v0(z)?D(lZ(w,z.allOf),z):O4(z)?D(eZ(w,z.items),z):s0(z)?D(oZ(w,z.properties),z):U1(z)?D(pZ(w,z.items||[]),z):M0(z)?D(sZ(w,z.anyOf),z):z}function wJ(w,z){return z in w?p2(w,w[z]):H0()}function g7(w){return globalThis.Object.getOwnPropertyNames(w).reduce((z,A)=>{return{...z,[A]:wJ(w,A)}},{})}class T7{constructor(w){let z=g7(w),A=this.WithIdentifiers(z);this.$defs=A}Import(w,z){let A={...this.$defs,[w]:D(this.$defs[w],z)};return D({[b]:"Import",$defs:A,$ref:w})}WithIdentifiers(w){return globalThis.Object.getOwnPropertyNames(w).reduce((z,A)=>{return{...z,[A]:{...w[A],$id:A}}},{})}}function i7(w){return new T7(w)}function d7(w,z){return D({[b]:"Not",not:w},z)}function c7(w,z){return v2(w.parameters,z)}function n7(w){return y2(C2(w))}var zJ=0;function h7(w,z={}){if(l0(z.$id))z.$id=`T${zJ++}`;let A=jz(w({[b]:"This",$ref:`${z.$id}`}));return A.$id=z.$id,D({[n2]:"Recursive",...A},z)}function t7(w,z){let A=x0(w)?new globalThis.RegExp(w):w;return D({[b]:"RegExp",type:"RegExp",source:A.source,flags:A.flags},z)}function AJ(w){return v0(w)?w.allOf:M0(w)?w.anyOf:U1(w)?w.items??[]:[]}function y7(w){return AJ(w)}function v7(w,z){return D(w.returns,z)}class o7{constructor(w){this.schema=w}Decode(w){return new u7(this.schema,w)}}class u7{constructor(w,z){this.schema=w,this.decode=z}EncodeTransform(w,z){let W={Encode:($)=>z[j0].Encode(w($)),Decode:($)=>this.decode(z[j0].Decode($))};return{...z,[j0]:W}}EncodeSchema(w,z){let A={Decode:this.decode,Encode:w};return{...z,[j0]:A}}Encode(w){return N0(this.schema)?this.EncodeTransform(w,this.schema):this.EncodeSchema(w,this.schema)}}function m7(w){return new o7(w)}function Iw(w={}){return D({[b]:w[b]??"Unsafe"},w)}function p7(w){return D({[b]:"Void",type:"void"},w)}var f5={};B6(f5,{Void:()=>p7,Uppercase:()=>O7,Unsafe:()=>Iw,Unknown:()=>V1,Union:()=>G0,Undefined:()=>Rw,Uncapitalize:()=>P7,Uint8Array:()=>Kw,Tuple:()=>v2,Transform:()=>m7,TemplateLiteral:()=>Nw,Symbol:()=>Cw,String:()=>t2,ReturnType:()=>v7,Rest:()=>y7,Required:()=>r6,RegExp:()=>t7,Ref:()=>K2,Recursive:()=>h7,Record:()=>Ew,ReadonlyOptional:()=>n7,Readonly:()=>y2,Promise:()=>Dw,Pick:()=>a1,Partial:()=>s6,Parameters:()=>c7,Optional:()=>C2,Omit:()=>r1,Object:()=>S0,Number:()=>N1,Null:()=>Ow,Not:()=>d7,Never:()=>H0,Module:()=>i7,Mapped:()=>h9,Lowercase:()=>_7,Literal:()=>X0,KeyOf:()=>o6,Iterator:()=>y6,Intersect:()=>Z2,Integer:()=>L7,InstanceType:()=>G7,Index:()=>l1,Function:()=>L1,Extract:()=>l6,Extends:()=>m6,Exclude:()=>p6,Enum:()=>s9,Date:()=>Pw,ConstructorParameters:()=>l9,Constructor:()=>d6,Const:()=>p9,Composite:()=>m9,Capitalize:()=>D7,Boolean:()=>bw,BigInt:()=>t6,Awaited:()=>v6,AsyncIterator:()=>i6,Array:()=>T6,Any:()=>p1});var S6=f5;class l7 extends n{constructor(w){super(`Duplicate type kind '${w}' detected`)}}class s7 extends n{constructor(w){super(`Duplicate string format '${w}' detected`)}}var T1;(function(w){function z(U,W){if(c0.Has(U))throw new l7(U);return c0.Set(U,W),($={})=>Iw({...$,[b]:U})}w.Type=z;function A(U,W){if(O0.Has(U))throw new s7(U);return O0.Set(U,W),U}w.Format=A})(T1||(T1={}));function UJ(w){switch(w.errorType){case N.ArrayContains:return"Expected array to contain at least one matching value";case N.ArrayMaxContains:return`Expected array to contain no more than ${w.schema.maxContains} matching values`;case N.ArrayMinContains:return`Expected array to contain at least ${w.schema.minContains} matching values`;case N.ArrayMaxItems:return`Expected array length to be less or equal to ${w.schema.maxItems}`;case N.ArrayMinItems:return`Expected array length to be greater or equal to ${w.schema.minItems}`;case N.ArrayUniqueItems:return"Expected array elements to be unique";case N.Array:return"Expected array";case N.AsyncIterator:return"Expected AsyncIterator";case N.BigIntExclusiveMaximum:return`Expected bigint to be less than ${w.schema.exclusiveMaximum}`;case N.BigIntExclusiveMinimum:return`Expected bigint to be greater than ${w.schema.exclusiveMinimum}`;case N.BigIntMaximum:return`Expected bigint to be less or equal to ${w.schema.maximum}`;case N.BigIntMinimum:return`Expected bigint to be greater or equal to ${w.schema.minimum}`;case N.BigIntMultipleOf:return`Expected bigint to be a multiple of ${w.schema.multipleOf}`;case N.BigInt:return"Expected bigint";case N.Boolean:return"Expected boolean";case N.DateExclusiveMinimumTimestamp:return`Expected Date timestamp to be greater than ${w.schema.exclusiveMinimumTimestamp}`;case N.DateExclusiveMaximumTimestamp:return`Expected Date timestamp to be less than ${w.schema.exclusiveMaximumTimestamp}`;case N.DateMinimumTimestamp:return`Expected Date timestamp to be greater or equal to ${w.schema.minimumTimestamp}`;case N.DateMaximumTimestamp:return`Expected Date timestamp to be less or equal to ${w.schema.maximumTimestamp}`;case N.DateMultipleOfTimestamp:return`Expected Date timestamp to be a multiple of ${w.schema.multipleOfTimestamp}`;case N.Date:return"Expected Date";case N.Function:return"Expected function";case N.IntegerExclusiveMaximum:return`Expected integer to be less than ${w.schema.exclusiveMaximum}`;case N.IntegerExclusiveMinimum:return`Expected integer to be greater than ${w.schema.exclusiveMinimum}`;case N.IntegerMaximum:return`Expected integer to be less or equal to ${w.schema.maximum}`;case N.IntegerMinimum:return`Expected integer to be greater or equal to ${w.schema.minimum}`;case N.IntegerMultipleOf:return`Expected integer to be a multiple of ${w.schema.multipleOf}`;case N.Integer:return"Expected integer";case N.IntersectUnevaluatedProperties:return"Unexpected property";case N.Intersect:return"Expected all values to match";case N.Iterator:return"Expected Iterator";case N.Literal:return`Expected ${typeof w.schema.const==="string"?`'${w.schema.const}'`:w.schema.const}`;case N.Never:return"Never";case N.Not:return"Value should not match";case N.Null:return"Expected null";case N.NumberExclusiveMaximum:return`Expected number to be less than ${w.schema.exclusiveMaximum}`;case N.NumberExclusiveMinimum:return`Expected number to be greater than ${w.schema.exclusiveMinimum}`;case N.NumberMaximum:return`Expected number to be less or equal to ${w.schema.maximum}`;case N.NumberMinimum:return`Expected number to be greater or equal to ${w.schema.minimum}`;case N.NumberMultipleOf:return`Expected number to be a multiple of ${w.schema.multipleOf}`;case N.Number:return"Expected number";case N.Object:return"Expected object";case N.ObjectAdditionalProperties:return"Unexpected property";case N.ObjectMaxProperties:return`Expected object to have no more than ${w.schema.maxProperties} properties`;case N.ObjectMinProperties:return`Expected object to have at least ${w.schema.minProperties} properties`;case N.ObjectRequiredProperty:return"Expected required property";case N.Promise:return"Expected Promise";case N.RegExp:return"Expected string to match regular expression";case N.StringFormatUnknown:return`Unknown format '${w.schema.format}'`;case N.StringFormat:return`Expected string to match '${w.schema.format}' format`;case N.StringMaxLength:return`Expected string length less or equal to ${w.schema.maxLength}`;case N.StringMinLength:return`Expected string length greater or equal to ${w.schema.minLength}`;case N.StringPattern:return`Expected string to match '${w.schema.pattern}'`;case N.String:return"Expected string";case N.Symbol:return"Expected symbol";case N.TupleLength:return`Expected tuple to have ${w.schema.maxItems||0} elements`;case N.Tuple:return"Expected tuple";case N.Uint8ArrayMaxByteLength:return`Expected byte length less or equal to ${w.schema.maxByteLength}`;case N.Uint8ArrayMinByteLength:return`Expected byte length greater or equal to ${w.schema.minByteLength}`;case N.Uint8Array:return"Expected Uint8Array";case N.Undefined:return"Expected undefined";case N.Union:return"Expected union value";case N.Void:return"Expected void";case N.Kind:return`Expected kind '${w.schema[b]}'`;default:return"Unknown error type"}}var WJ=UJ;function r7(){return WJ}class a7 extends n{constructor(w){super(`Unable to dereference schema with $id '${w.$ref}'`);this.schema=w}}function $J(w,z){let A=z.find((U)=>U.$id===w.$ref);if(A===void 0)throw new a7(w);return Y0(A,z)}function e0(w,z){if(!Q0(w.$id)||z.some((A)=>A.$id===w.$id))return z;return z.push(w),z}function Y0(w,z){return w[b]==="This"||w[b]==="Ref"?$J(w,z):w}class e7 extends n{constructor(w){super("Unable to hash value");this.value=w}}var T2;(function(w){w[w.Undefined=0]="Undefined",w[w.Null=1]="Null",w[w.Boolean=2]="Boolean",w[w.Number=3]="Number",w[w.String=4]="String",w[w.Object=5]="Object",w[w.Array=6]="Array",w[w.Date=7]="Date",w[w.Uint8Array=8]="Uint8Array",w[w.Symbol=9]="Symbol",w[w.BigInt=10]="BigInt"})(T2||(T2={}));var a6=BigInt("14695981039346656037"),[XJ,QJ]=[BigInt("1099511628211"),BigInt("18446744073709551616")],ZJ=Array.from({length:256}).map((w,z)=>BigInt(z)),wA=new Float64Array(1),zA=new DataView(wA.buffer),AA=new Uint8Array(wA.buffer);function*JJ(w){let z=w===0?1:Math.ceil(Math.floor(Math.log2(w)+1)/8);for(let A=0;A<z;A++)yield w>>8*(z-1-A)&255}function YJ(w){Y2(T2.Array);for(let z of w)e6(z)}function qJ(w){Y2(T2.Boolean),Y2(w?1:0)}function BJ(w){Y2(T2.BigInt),zA.setBigInt64(0,w);for(let z of AA)Y2(z)}function MJ(w){Y2(T2.Date),e6(w.getTime())}function HJ(w){Y2(T2.Null)}function GJ(w){Y2(T2.Number),zA.setFloat64(0,w);for(let z of AA)Y2(z)}function LJ(w){Y2(T2.Object);for(let z of globalThis.Object.getOwnPropertyNames(w).sort())e6(z),e6(w[z])}function bJ(w){Y2(T2.String);for(let z=0;z<w.length;z++)for(let A of JJ(w.charCodeAt(z)))Y2(A)}function NJ(w){Y2(T2.Symbol),e6(w.description)}function SJ(w){Y2(T2.Uint8Array);for(let z=0;z<w.length;z++)Y2(w[z])}function DJ(w){return Y2(T2.Undefined)}function e6(w){if(v(w))return YJ(w);if(G1(w))return qJ(w);if(U2(w))return BJ(w);if(S2(w))return MJ(w);if(K1(w))return HJ(w);if(d(w))return GJ(w);if(r(w))return LJ(w);if(Q0(w))return bJ(w);if(j1(w))return NJ(w);if(k6(w))return SJ(w);if(k0(w))return DJ(w);throw new e7(w)}function Y2(w){a6=a6^ZJ[w],a6=a6*XJ%QJ}function e1(w){return a6=BigInt("14695981039346656037"),e6(w),a6}class UA extends n{constructor(w){super("Unknown type");this.schema=w}}function _J(w){return w[b]==="Any"||w[b]==="Unknown"}function z0(w){return w!==void 0}function PJ(w,z,A){return!0}function OJ(w,z,A){if(!v(A))return!1;if(z0(w.minItems)&&!(A.length>=w.minItems))return!1;if(z0(w.maxItems)&&!(A.length<=w.maxItems))return!1;if(!A.every(($)=>w2(w.items,z,$)))return!1;if(w.uniqueItems===!0&&!function(){let $=new Set;for(let X of A){let Q=e1(X);if($.has(Q))return!1;else $.add(Q)}return!0}())return!1;if(!(z0(w.contains)||d(w.minContains)||d(w.maxContains)))return!0;let U=z0(w.contains)?w.contains:H0(),W=A.reduce(($,X)=>w2(U,z,X)?$+1:$,0);if(W===0)return!1;if(d(w.minContains)&&W<w.minContains)return!1;if(d(w.maxContains)&&W>w.maxContains)return!1;return!0}function CJ(w,z,A){return Zw(A)}function RJ(w,z,A){if(!U2(A))return!1;if(z0(w.exclusiveMaximum)&&!(A<w.exclusiveMaximum))return!1;if(z0(w.exclusiveMinimum)&&!(A>w.exclusiveMinimum))return!1;if(z0(w.maximum)&&!(A<=w.maximum))return!1;if(z0(w.minimum)&&!(A>=w.minimum))return!1;if(z0(w.multipleOf)&&A%w.multipleOf!==BigInt(0))return!1;return!0}function KJ(w,z,A){return G1(A)}function jJ(w,z,A){return w2(w.returns,z,A.prototype)}function FJ(w,z,A){if(!S2(A))return!1;if(z0(w.exclusiveMaximumTimestamp)&&!(A.getTime()<w.exclusiveMaximumTimestamp))return!1;if(z0(w.exclusiveMinimumTimestamp)&&!(A.getTime()>w.exclusiveMinimumTimestamp))return!1;if(z0(w.maximumTimestamp)&&!(A.getTime()<=w.maximumTimestamp))return!1;if(z0(w.minimumTimestamp)&&!(A.getTime()>=w.minimumTimestamp))return!1;if(z0(w.multipleOfTimestamp)&&A.getTime()%w.multipleOfTimestamp!==0)return!1;return!0}function xJ(w,z,A){return o1(A)}function EJ(w,z,A){let U=globalThis.Object.values(w.$defs),W=w.$defs[w.$ref];return w2(W,[...z,...U],A)}function IJ(w,z,A){if(!qw(A))return!1;if(z0(w.exclusiveMaximum)&&!(A<w.exclusiveMaximum))return!1;if(z0(w.exclusiveMinimum)&&!(A>w.exclusiveMinimum))return!1;if(z0(w.maximum)&&!(A<=w.maximum))return!1;if(z0(w.minimum)&&!(A>=w.minimum))return!1;if(z0(w.multipleOf)&&A%w.multipleOf!==0)return!1;return!0}function fJ(w,z,A){let U=w.allOf.every((W)=>w2(W,z,A));if(w.unevaluatedProperties===!1){let W=new RegExp(k1(w)),$=Object.getOwnPropertyNames(A).every((X)=>W.test(X));return U&&$}else if(T0(w.unevaluatedProperties)){let W=new RegExp(k1(w)),$=Object.getOwnPropertyNames(A).every((X)=>W.test(X)||w2(w.unevaluatedProperties,z,A[X]));return U&&$}else return U}function kJ(w,z,A){return Jw(A)}function VJ(w,z,A){return A===w.const}function gJ(w,z,A){return!1}function TJ(w,z,A){return!w2(w.not,z,A)}function iJ(w,z,A){return K1(A)}function dJ(w,z,A){if(!I0.IsNumberLike(A))return!1;if(z0(w.exclusiveMaximum)&&!(A<w.exclusiveMaximum))return!1;if(z0(w.exclusiveMinimum)&&!(A>w.exclusiveMinimum))return!1;if(z0(w.minimum)&&!(A>=w.minimum))return!1;if(z0(w.maximum)&&!(A<=w.maximum))return!1;if(z0(w.multipleOf)&&A%w.multipleOf!==0)return!1;return!0}function cJ(w,z,A){if(!I0.IsObjectLike(A))return!1;if(z0(w.minProperties)&&!(Object.getOwnPropertyNames(A).length>=w.minProperties))return!1;if(z0(w.maxProperties)&&!(Object.getOwnPropertyNames(A).length<=w.maxProperties))return!1;let U=Object.getOwnPropertyNames(w.properties);for(let W of U){let $=w.properties[W];if(w.required&&w.required.includes(W)){if(!w2($,z,A[W]))return!1;if((g1($)||_J($))&&!(W in A))return!1}else if(I0.IsExactOptionalProperty(A,W)&&!w2($,z,A[W]))return!1}if(w.additionalProperties===!1){let W=Object.getOwnPropertyNames(A);if(w.required&&w.required.length===U.length&&W.length===U.length)return!0;else return W.every(($)=>U.includes($))}else if(typeof w.additionalProperties==="object")return Object.getOwnPropertyNames(A).every(($)=>U.includes($)||w2(w.additionalProperties,z,A[$]));else return!0}function nJ(w,z,A){return Yw(A)}function hJ(w,z,A){if(!I0.IsRecordLike(A))return!1;if(z0(w.minProperties)&&!(Object.getOwnPropertyNames(A).length>=w.minProperties))return!1;if(z0(w.maxProperties)&&!(Object.getOwnPropertyNames(A).length<=w.maxProperties))return!1;let[U,W]=Object.entries(w.patternProperties)[0],$=new RegExp(U),X=Object.entries(A).every(([J,Y])=>{return $.test(J)?w2(W,z,Y):!0}),Q=typeof w.additionalProperties==="object"?Object.entries(A).every(([J,Y])=>{return!$.test(J)?w2(w.additionalProperties,z,Y):!0}):!0,Z=w.additionalProperties===!1?Object.getOwnPropertyNames(A).every((J)=>{return $.test(J)}):!0;return X&&Q&&Z}function tJ(w,z,A){return w2(Y0(w,z),z,A)}function yJ(w,z,A){let U=new RegExp(w.source,w.flags);if(z0(w.minLength)){if(!(A.length>=w.minLength))return!1}if(z0(w.maxLength)){if(!(A.length<=w.maxLength))return!1}return U.test(A)}function vJ(w,z,A){if(!Q0(A))return!1;if(z0(w.minLength)){if(!(A.length>=w.minLength))return!1}if(z0(w.maxLength)){if(!(A.length<=w.maxLength))return!1}if(z0(w.pattern)){if(!new RegExp(w.pattern).test(A))return!1}if(z0(w.format)){if(!O0.Has(w.format))return!1;return O0.Get(w.format)(A)}return!0}function oJ(w,z,A){return j1(A)}function uJ(w,z,A){return Q0(A)&&new RegExp(w.pattern).test(A)}function mJ(w,z,A){return w2(Y0(w,z),z,A)}function pJ(w,z,A){if(!v(A))return!1;if(w.items===void 0&&A.length!==0)return!1;if(A.length!==w.maxItems)return!1;if(!w.items)return!0;for(let U=0;U<w.items.length;U++)if(!w2(w.items[U],z,A[U]))return!1;return!0}function lJ(w,z,A){return k0(A)}function sJ(w,z,A){return w.anyOf.some((U)=>w2(U,z,A))}function rJ(w,z,A){if(!k6(A))return!1;if(z0(w.maxByteLength)&&!(A.length<=w.maxByteLength))return!1;if(z0(w.minByteLength)&&!(A.length>=w.minByteLength))return!1;return!0}function aJ(w,z,A){return!0}function eJ(w,z,A){return I0.IsVoidLike(A)}function wY(w,z,A){if(!c0.Has(w[b]))return!1;return c0.Get(w[b])(w,A)}function w2(w,z,A){let U=z0(w.$id)?e0(w,z):z,W=w;switch(W[b]){case"Any":return PJ(W,U,A);case"Array":return OJ(W,U,A);case"AsyncIterator":return CJ(W,U,A);case"BigInt":return RJ(W,U,A);case"Boolean":return KJ(W,U,A);case"Constructor":return jJ(W,U,A);case"Date":return FJ(W,U,A);case"Function":return xJ(W,U,A);case"Import":return EJ(W,U,A);case"Integer":return IJ(W,U,A);case"Intersect":return fJ(W,U,A);case"Iterator":return kJ(W,U,A);case"Literal":return VJ(W,U,A);case"Never":return gJ(W,U,A);case"Not":return TJ(W,U,A);case"Null":return iJ(W,U,A);case"Number":return dJ(W,U,A);case"Object":return cJ(W,U,A);case"Promise":return nJ(W,U,A);case"Record":return hJ(W,U,A);case"Ref":return tJ(W,U,A);case"RegExp":return yJ(W,U,A);case"String":return vJ(W,U,A);case"Symbol":return oJ(W,U,A);case"TemplateLiteral":return uJ(W,U,A);case"This":return mJ(W,U,A);case"Tuple":return pJ(W,U,A);case"Undefined":return lJ(W,U,A);case"Union":return sJ(W,U,A);case"Uint8Array":return rJ(W,U,A);case"Unknown":return aJ(W,U,A);case"Void":return eJ(W,U,A);default:if(!c0.Has(W[b]))throw new UA(W);return wY(W,U,A)}}function a(...w){return w.length===3?w2(w[0],w[1],w[2]):w2(w[0],[],w[1])}var N;(function(w){w[w.ArrayContains=0]="ArrayContains",w[w.ArrayMaxContains=1]="ArrayMaxContains",w[w.ArrayMaxItems=2]="ArrayMaxItems",w[w.ArrayMinContains=3]="ArrayMinContains",w[w.ArrayMinItems=4]="ArrayMinItems",w[w.ArrayUniqueItems=5]="ArrayUniqueItems",w[w.Array=6]="Array",w[w.AsyncIterator=7]="AsyncIterator",w[w.BigIntExclusiveMaximum=8]="BigIntExclusiveMaximum",w[w.BigIntExclusiveMinimum=9]="BigIntExclusiveMinimum",w[w.BigIntMaximum=10]="BigIntMaximum",w[w.BigIntMinimum=11]="BigIntMinimum",w[w.BigIntMultipleOf=12]="BigIntMultipleOf",w[w.BigInt=13]="BigInt",w[w.Boolean=14]="Boolean",w[w.DateExclusiveMaximumTimestamp=15]="DateExclusiveMaximumTimestamp",w[w.DateExclusiveMinimumTimestamp=16]="DateExclusiveMinimumTimestamp",w[w.DateMaximumTimestamp=17]="DateMaximumTimestamp",w[w.DateMinimumTimestamp=18]="DateMinimumTimestamp",w[w.DateMultipleOfTimestamp=19]="DateMultipleOfTimestamp",w[w.Date=20]="Date",w[w.Function=21]="Function",w[w.IntegerExclusiveMaximum=22]="IntegerExclusiveMaximum",w[w.IntegerExclusiveMinimum=23]="IntegerExclusiveMinimum",w[w.IntegerMaximum=24]="IntegerMaximum",w[w.IntegerMinimum=25]="IntegerMinimum",w[w.IntegerMultipleOf=26]="IntegerMultipleOf",w[w.Integer=27]="Integer",w[w.IntersectUnevaluatedProperties=28]="IntersectUnevaluatedProperties",w[w.Intersect=29]="Intersect",w[w.Iterator=30]="Iterator",w[w.Kind=31]="Kind",w[w.Literal=32]="Literal",w[w.Never=33]="Never",w[w.Not=34]="Not",w[w.Null=35]="Null",w[w.NumberExclusiveMaximum=36]="NumberExclusiveMaximum",w[w.NumberExclusiveMinimum=37]="NumberExclusiveMinimum",w[w.NumberMaximum=38]="NumberMaximum",w[w.NumberMinimum=39]="NumberMinimum",w[w.NumberMultipleOf=40]="NumberMultipleOf",w[w.Number=41]="Number",w[w.ObjectAdditionalProperties=42]="ObjectAdditionalProperties",w[w.ObjectMaxProperties=43]="ObjectMaxProperties",w[w.ObjectMinProperties=44]="ObjectMinProperties",w[w.ObjectRequiredProperty=45]="ObjectRequiredProperty",w[w.Object=46]="Object",w[w.Promise=47]="Promise",w[w.RegExp=48]="RegExp",w[w.StringFormatUnknown=49]="StringFormatUnknown",w[w.StringFormat=50]="StringFormat",w[w.StringMaxLength=51]="StringMaxLength",w[w.StringMinLength=52]="StringMinLength",w[w.StringPattern=53]="StringPattern",w[w.String=54]="String",w[w.Symbol=55]="Symbol",w[w.TupleLength=56]="TupleLength",w[w.Tuple=57]="Tuple",w[w.Uint8ArrayMaxByteLength=58]="Uint8ArrayMaxByteLength",w[w.Uint8ArrayMinByteLength=59]="Uint8ArrayMinByteLength",w[w.Uint8Array=60]="Uint8Array",w[w.Undefined=61]="Undefined",w[w.Union=62]="Union",w[w.Void=63]="Void"})(N||(N={}));class WA extends n{constructor(w){super("Unknown type");this.schema=w}}function i1(w){return w.replace(/~/g,"~0").replace(/\//g,"~1")}function A0(w){return w!==void 0}class D6{constructor(w){this.iterator=w}[Symbol.iterator](){return this.iterator}First(){let w=this.iterator.next();return w.done?void 0:w.value}}function I(w,z,A,U,W=[]){return{type:w,schema:z,path:A,value:U,message:r7()({errorType:w,path:A,schema:z,value:U,errors:W}),errors:W}}function*zY(w,z,A,U){}function*AY(w,z,A,U){if(!v(U))return yield I(N.Array,w,A,U);if(A0(w.minItems)&&!(U.length>=w.minItems))yield I(N.ArrayMinItems,w,A,U);if(A0(w.maxItems)&&!(U.length<=w.maxItems))yield I(N.ArrayMaxItems,w,A,U);for(let X=0;X<U.length;X++)yield*z2(w.items,z,`${A}/${X}`,U[X]);if(w.uniqueItems===!0&&!function(){let X=new Set;for(let Q of U){let Z=e1(Q);if(X.has(Z))return!1;else X.add(Z)}return!0}())yield I(N.ArrayUniqueItems,w,A,U);if(!(A0(w.contains)||A0(w.minContains)||A0(w.maxContains)))return;let W=A0(w.contains)?w.contains:H0(),$=U.reduce((X,Q,Z)=>z2(W,z,`${A}${Z}`,Q).next().done===!0?X+1:X,0);if($===0)yield I(N.ArrayContains,w,A,U);if(d(w.minContains)&&$<w.minContains)yield I(N.ArrayMinContains,w,A,U);if(d(w.maxContains)&&$>w.maxContains)yield I(N.ArrayMaxContains,w,A,U)}function*UY(w,z,A,U){if(!Zw(U))yield I(N.AsyncIterator,w,A,U)}function*WY(w,z,A,U){if(!U2(U))return yield I(N.BigInt,w,A,U);if(A0(w.exclusiveMaximum)&&!(U<w.exclusiveMaximum))yield I(N.BigIntExclusiveMaximum,w,A,U);if(A0(w.exclusiveMinimum)&&!(U>w.exclusiveMinimum))yield I(N.BigIntExclusiveMinimum,w,A,U);if(A0(w.maximum)&&!(U<=w.maximum))yield I(N.BigIntMaximum,w,A,U);if(A0(w.minimum)&&!(U>=w.minimum))yield I(N.BigIntMinimum,w,A,U);if(A0(w.multipleOf)&&U%w.multipleOf!==BigInt(0))yield I(N.BigIntMultipleOf,w,A,U)}function*$Y(w,z,A,U){if(!G1(U))yield I(N.Boolean,w,A,U)}function*XY(w,z,A,U){yield*z2(w.returns,z,A,U.prototype)}function*QY(w,z,A,U){if(!S2(U))return yield I(N.Date,w,A,U);if(A0(w.exclusiveMaximumTimestamp)&&!(U.getTime()<w.exclusiveMaximumTimestamp))yield I(N.DateExclusiveMaximumTimestamp,w,A,U);if(A0(w.exclusiveMinimumTimestamp)&&!(U.getTime()>w.exclusiveMinimumTimestamp))yield I(N.DateExclusiveMinimumTimestamp,w,A,U);if(A0(w.maximumTimestamp)&&!(U.getTime()<=w.maximumTimestamp))yield I(N.DateMaximumTimestamp,w,A,U);if(A0(w.minimumTimestamp)&&!(U.getTime()>=w.minimumTimestamp))yield I(N.DateMinimumTimestamp,w,A,U);if(A0(w.multipleOfTimestamp)&&U.getTime()%w.multipleOfTimestamp!==0)yield I(N.DateMultipleOfTimestamp,w,A,U)}function*ZY(w,z,A,U){if(!o1(U))yield I(N.Function,w,A,U)}function*JY(w,z,A,U){let W=globalThis.Object.values(w.$defs),$=w.$defs[w.$ref];yield*z2($,[...z,...W],A,U)}function*YY(w,z,A,U){if(!qw(U))return yield I(N.Integer,w,A,U);if(A0(w.exclusiveMaximum)&&!(U<w.exclusiveMaximum))yield I(N.IntegerExclusiveMaximum,w,A,U);if(A0(w.exclusiveMinimum)&&!(U>w.exclusiveMinimum))yield I(N.IntegerExclusiveMinimum,w,A,U);if(A0(w.maximum)&&!(U<=w.maximum))yield I(N.IntegerMaximum,w,A,U);if(A0(w.minimum)&&!(U>=w.minimum))yield I(N.IntegerMinimum,w,A,U);if(A0(w.multipleOf)&&U%w.multipleOf!==0)yield I(N.IntegerMultipleOf,w,A,U)}function*qY(w,z,A,U){let W=!1;for(let $ of w.allOf)for(let X of z2($,z,A,U))W=!0,yield X;if(W)return yield I(N.Intersect,w,A,U);if(w.unevaluatedProperties===!1){let $=new RegExp(k1(w));for(let X of Object.getOwnPropertyNames(U))if(!$.test(X))yield I(N.IntersectUnevaluatedProperties,w,`${A}/${X}`,U)}if(typeof w.unevaluatedProperties==="object"){let $=new RegExp(k1(w));for(let X of Object.getOwnPropertyNames(U))if(!$.test(X)){let Q=z2(w.unevaluatedProperties,z,`${A}/${X}`,U[X]).next();if(!Q.done)yield Q.value}}}function*BY(w,z,A,U){if(!Jw(U))yield I(N.Iterator,w,A,U)}function*MY(w,z,A,U){if(U!==w.const)yield I(N.Literal,w,A,U)}function*HY(w,z,A,U){yield I(N.Never,w,A,U)}function*GY(w,z,A,U){if(z2(w.not,z,A,U).next().done===!0)yield I(N.Not,w,A,U)}function*LY(w,z,A,U){if(!K1(U))yield I(N.Null,w,A,U)}function*bY(w,z,A,U){if(!I0.IsNumberLike(U))return yield I(N.Number,w,A,U);if(A0(w.exclusiveMaximum)&&!(U<w.exclusiveMaximum))yield I(N.NumberExclusiveMaximum,w,A,U);if(A0(w.exclusiveMinimum)&&!(U>w.exclusiveMinimum))yield I(N.NumberExclusiveMinimum,w,A,U);if(A0(w.maximum)&&!(U<=w.maximum))yield I(N.NumberMaximum,w,A,U);if(A0(w.minimum)&&!(U>=w.minimum))yield I(N.NumberMinimum,w,A,U);if(A0(w.multipleOf)&&U%w.multipleOf!==0)yield I(N.NumberMultipleOf,w,A,U)}function*NY(w,z,A,U){if(!I0.IsObjectLike(U))return yield I(N.Object,w,A,U);if(A0(w.minProperties)&&!(Object.getOwnPropertyNames(U).length>=w.minProperties))yield I(N.ObjectMinProperties,w,A,U);if(A0(w.maxProperties)&&!(Object.getOwnPropertyNames(U).length<=w.maxProperties))yield I(N.ObjectMaxProperties,w,A,U);let W=Array.isArray(w.required)?w.required:[],$=Object.getOwnPropertyNames(w.properties),X=Object.getOwnPropertyNames(U);for(let Q of W){if(X.includes(Q))continue;yield I(N.ObjectRequiredProperty,w.properties[Q],`${A}/${i1(Q)}`,void 0)}if(w.additionalProperties===!1){for(let Q of X)if(!$.includes(Q))yield I(N.ObjectAdditionalProperties,w,`${A}/${i1(Q)}`,U[Q])}if(typeof w.additionalProperties==="object")for(let Q of X){if($.includes(Q))continue;yield*z2(w.additionalProperties,z,`${A}/${i1(Q)}`,U[Q])}for(let Q of $){let Z=w.properties[Q];if(w.required&&w.required.includes(Q)){if(yield*z2(Z,z,`${A}/${i1(Q)}`,U[Q]),g1(w)&&!(Q in U))yield I(N.ObjectRequiredProperty,Z,`${A}/${i1(Q)}`,void 0)}else if(I0.IsExactOptionalProperty(U,Q))yield*z2(Z,z,`${A}/${i1(Q)}`,U[Q])}}function*SY(w,z,A,U){if(!Yw(U))yield I(N.Promise,w,A,U)}function*DY(w,z,A,U){if(!I0.IsRecordLike(U))return yield I(N.Object,w,A,U);if(A0(w.minProperties)&&!(Object.getOwnPropertyNames(U).length>=w.minProperties))yield I(N.ObjectMinProperties,w,A,U);if(A0(w.maxProperties)&&!(Object.getOwnPropertyNames(U).length<=w.maxProperties))yield I(N.ObjectMaxProperties,w,A,U);let[W,$]=Object.entries(w.patternProperties)[0],X=new RegExp(W);for(let[Q,Z]of Object.entries(U))if(X.test(Q))yield*z2($,z,`${A}/${i1(Q)}`,Z);if(typeof w.additionalProperties==="object"){for(let[Q,Z]of Object.entries(U))if(!X.test(Q))yield*z2(w.additionalProperties,z,`${A}/${i1(Q)}`,Z)}if(w.additionalProperties===!1)for(let[Q,Z]of Object.entries(U)){if(X.test(Q))continue;return yield I(N.ObjectAdditionalProperties,w,`${A}/${i1(Q)}`,Z)}}function*_Y(w,z,A,U){yield*z2(Y0(w,z),z,A,U)}function*PY(w,z,A,U){if(!Q0(U))return yield I(N.String,w,A,U);if(A0(w.minLength)&&!(U.length>=w.minLength))yield I(N.StringMinLength,w,A,U);if(A0(w.maxLength)&&!(U.length<=w.maxLength))yield I(N.StringMaxLength,w,A,U);if(!new RegExp(w.source,w.flags).test(U))return yield I(N.RegExp,w,A,U)}function*OY(w,z,A,U){if(!Q0(U))return yield I(N.String,w,A,U);if(A0(w.minLength)&&!(U.length>=w.minLength))yield I(N.StringMinLength,w,A,U);if(A0(w.maxLength)&&!(U.length<=w.maxLength))yield I(N.StringMaxLength,w,A,U);if(Q0(w.pattern)){if(!new RegExp(w.pattern).test(U))yield I(N.StringPattern,w,A,U)}if(Q0(w.format)){if(!O0.Has(w.format))yield I(N.StringFormatUnknown,w,A,U);else if(!O0.Get(w.format)(U))yield I(N.StringFormat,w,A,U)}}function*CY(w,z,A,U){if(!j1(U))yield I(N.Symbol,w,A,U)}function*RY(w,z,A,U){if(!Q0(U))return yield I(N.String,w,A,U);if(!new RegExp(w.pattern).test(U))yield I(N.StringPattern,w,A,U)}function*KY(w,z,A,U){yield*z2(Y0(w,z),z,A,U)}function*jY(w,z,A,U){if(!v(U))return yield I(N.Tuple,w,A,U);if(w.items===void 0&&U.length!==0)return yield I(N.TupleLength,w,A,U);if(U.length!==w.maxItems)return yield I(N.TupleLength,w,A,U);if(!w.items)return;for(let W=0;W<w.items.length;W++)yield*z2(w.items[W],z,`${A}/${W}`,U[W])}function*FY(w,z,A,U){if(!k0(U))yield I(N.Undefined,w,A,U)}function*xY(w,z,A,U){if(a(w,z,U))return;let W=w.anyOf.map(($)=>new D6(z2($,z,A,U)));yield I(N.Union,w,A,U,W)}function*EY(w,z,A,U){if(!k6(U))return yield I(N.Uint8Array,w,A,U);if(A0(w.maxByteLength)&&!(U.length<=w.maxByteLength))yield I(N.Uint8ArrayMaxByteLength,w,A,U);if(A0(w.minByteLength)&&!(U.length>=w.minByteLength))yield I(N.Uint8ArrayMinByteLength,w,A,U)}function*IY(w,z,A,U){}function*fY(w,z,A,U){if(!I0.IsVoidLike(U))yield I(N.Void,w,A,U)}function*kY(w,z,A,U){if(!c0.Get(w[b])(w,U))yield I(N.Kind,w,A,U)}function*z2(w,z,A,U){let W=A0(w.$id)?[...z,w]:z,$=w;switch($[b]){case"Any":return yield*zY($,W,A,U);case"Array":return yield*AY($,W,A,U);case"AsyncIterator":return yield*UY($,W,A,U);case"BigInt":return yield*WY($,W,A,U);case"Boolean":return yield*$Y($,W,A,U);case"Constructor":return yield*XY($,W,A,U);case"Date":return yield*QY($,W,A,U);case"Function":return yield*ZY($,W,A,U);case"Import":return yield*JY($,W,A,U);case"Integer":return yield*YY($,W,A,U);case"Intersect":return yield*qY($,W,A,U);case"Iterator":return yield*BY($,W,A,U);case"Literal":return yield*MY($,W,A,U);case"Never":return yield*HY($,W,A,U);case"Not":return yield*GY($,W,A,U);case"Null":return yield*LY($,W,A,U);case"Number":return yield*bY($,W,A,U);case"Object":return yield*NY($,W,A,U);case"Promise":return yield*SY($,W,A,U);case"Record":return yield*DY($,W,A,U);case"Ref":return yield*_Y($,W,A,U);case"RegExp":return yield*PY($,W,A,U);case"String":return yield*OY($,W,A,U);case"Symbol":return yield*CY($,W,A,U);case"TemplateLiteral":return yield*RY($,W,A,U);case"This":return yield*KY($,W,A,U);case"Tuple":return yield*jY($,W,A,U);case"Undefined":return yield*FY($,W,A,U);case"Union":return yield*xY($,W,A,U);case"Uint8Array":return yield*EY($,W,A,U);case"Unknown":return yield*IY($,W,A,U);case"Void":return yield*fY($,W,A,U);default:if(!c0.Has($[b]))throw new WA(w);return yield*kY($,W,A,U)}}function S1(...w){let z=w.length===3?z2(w[0],w[1],"",w[2]):z2(w[0],[],"",w[1]);return new D6(z)}class T4 extends n{constructor(w,z,A){super("Unable to decode value as it does not match the expected schema");this.schema=w,this.value=z,this.error=A}}class fw extends n{constructor(w,z,A,U){super(U instanceof Error?U.message:"Unknown error");this.schema=w,this.path=z,this.value=A,this.error=U}}function h0(w,z,A){try{return N0(w)?w[j0].Decode(A):A}catch(U){throw new fw(w,z,A,U)}}function VY(w,z,A,U){return v(U)?h0(w,A,U.map((W,$)=>$1(w.items,z,`${A}/${$}`,W))):h0(w,A,U)}function gY(w,z,A,U){if(!r(U)||k2(U))return h0(w,A,U);let W=_w(w),$=W.map((Y)=>Y[0]),X={...U};for(let[Y,L]of W)if(Y in X)X[Y]=$1(L,z,`${A}/${Y}`,X[Y]);if(!N0(w.unevaluatedProperties))return h0(w,A,X);let Q=Object.getOwnPropertyNames(X),Z=w.unevaluatedProperties,J={...X};for(let Y of Q)if(!$.includes(Y))J[Y]=h0(Z,`${A}/${Y}`,J[Y]);return h0(w,A,J)}function TY(w,z,A,U){let W=globalThis.Object.values(w.$defs),$=w.$defs[w.$ref],X=w[j0],Q={[j0]:X,...$};return $1(Q,[...z,...W],A,U)}function iY(w,z,A,U){return h0(w,A,$1(w.not,z,A,U))}function dY(w,z,A,U){if(!r(U))return h0(w,A,U);let W=j2(w),$={...U};for(let J of W){if(!y($,J))continue;if(k0($[J])&&(!K4(w.properties[J])||I0.IsExactOptionalProperty($,J)))continue;$[J]=$1(w.properties[J],z,`${A}/${J}`,$[J])}if(!T0(w.additionalProperties))return h0(w,A,$);let X=Object.getOwnPropertyNames($),Q=w.additionalProperties,Z={...$};for(let J of X)if(!W.includes(J))Z[J]=h0(Q,`${A}/${J}`,Z[J]);return h0(w,A,Z)}function cY(w,z,A,U){if(!r(U))return h0(w,A,U);let W=Object.getOwnPropertyNames(w.patternProperties)[0],$=new RegExp(W),X={...U};for(let Y of Object.getOwnPropertyNames(U))if($.test(Y))X[Y]=$1(w.patternProperties[W],z,`${A}/${Y}`,X[Y]);if(!T0(w.additionalProperties))return h0(w,A,X);let Q=Object.getOwnPropertyNames(X),Z=w.additionalProperties,J={...X};for(let Y of Q)if(!$.test(Y))J[Y]=h0(Z,`${A}/${Y}`,J[Y]);return h0(w,A,J)}function nY(w,z,A,U){let W=Y0(w,z);return h0(w,A,$1(W,z,A,U))}function hY(w,z,A,U){let W=Y0(w,z);return h0(w,A,$1(W,z,A,U))}function tY(w,z,A,U){return v(U)&&v(w.items)?h0(w,A,w.items.map((W,$)=>$1(W,z,`${A}/${$}`,U[$]))):h0(w,A,U)}function yY(w,z,A,U){for(let W of w.anyOf){if(!a(W,z,U))continue;let $=$1(W,z,A,U);return h0(w,A,$)}return h0(w,A,U)}function $1(w,z,A,U){let W=e0(w,z),$=w;switch(w[b]){case"Array":return VY($,W,A,U);case"Import":return TY($,W,A,U);case"Intersect":return gY($,W,A,U);case"Not":return iY($,W,A,U);case"Object":return dY($,W,A,U);case"Record":return cY($,W,A,U);case"Ref":return nY($,W,A,U);case"Symbol":return h0($,A,U);case"This":return hY($,W,A,U);case"Tuple":return tY($,W,A,U);case"Union":return yY($,W,A,U);default:return h0($,A,U)}}function w4(w,z,A){return $1(w,z,"",A)}class i4 extends n{constructor(w,z,A){super("The encoded value does not match the expected schema");this.schema=w,this.value=z,this.error=A}}class $A extends n{constructor(w,z,A,U){super(`${U instanceof Error?U.message:"Unknown error"}`);this.schema=w,this.path=z,this.value=A,this.error=U}}function q2(w,z,A){try{return N0(w)?w[j0].Encode(A):A}catch(U){throw new $A(w,z,A,U)}}function vY(w,z,A,U){let W=q2(w,A,U);return v(W)?W.map(($,X)=>X1(w.items,z,`${A}/${X}`,$)):W}function oY(w,z,A,U){let W=globalThis.Object.values(w.$defs),$=w.$defs[w.$ref],X=w[j0],Q={[j0]:X,...$};return X1(Q,[...z,...W],A,U)}function uY(w,z,A,U){let W=q2(w,A,U);if(!r(U)||k2(U))return W;let $=_w(w),X=$.map((L)=>L[0]),Q={...W};for(let[L,_]of $)if(L in Q)Q[L]=X1(_,z,`${A}/${L}`,Q[L]);if(!N0(w.unevaluatedProperties))return Q;let Z=Object.getOwnPropertyNames(Q),J=w.unevaluatedProperties,Y={...Q};for(let L of Z)if(!X.includes(L))Y[L]=q2(J,`${A}/${L}`,Y[L]);return Y}function mY(w,z,A,U){return q2(w.not,A,q2(w,A,U))}function pY(w,z,A,U){let W=q2(w,A,U);if(!r(W))return W;let $=j2(w),X={...W};for(let Y of $){if(!y(X,Y))continue;if(k0(X[Y])&&(!K4(w.properties[Y])||I0.IsExactOptionalProperty(X,Y)))continue;X[Y]=X1(w.properties[Y],z,`${A}/${Y}`,X[Y])}if(!T0(w.additionalProperties))return X;let Q=Object.getOwnPropertyNames(X),Z=w.additionalProperties,J={...X};for(let Y of Q)if(!$.includes(Y))J[Y]=q2(Z,`${A}/${Y}`,J[Y]);return J}function lY(w,z,A,U){let W=q2(w,A,U);if(!r(U))return W;let $=Object.getOwnPropertyNames(w.patternProperties)[0],X=new RegExp($),Q={...W};for(let L of Object.getOwnPropertyNames(U))if(X.test(L))Q[L]=X1(w.patternProperties[$],z,`${A}/${L}`,Q[L]);if(!T0(w.additionalProperties))return Q;let Z=Object.getOwnPropertyNames(Q),J=w.additionalProperties,Y={...Q};for(let L of Z)if(!X.test(L))Y[L]=q2(J,`${A}/${L}`,Y[L]);return Y}function sY(w,z,A,U){let W=Y0(w,z),$=X1(W,z,A,U);return q2(w,A,$)}function rY(w,z,A,U){let W=Y0(w,z),$=X1(W,z,A,U);return q2(w,A,$)}function aY(w,z,A,U){let W=q2(w,A,U);return v(w.items)?w.items.map(($,X)=>X1($,z,`${A}/${X}`,W[X])):[]}function eY(w,z,A,U){for(let W of w.anyOf){if(!a(W,z,U))continue;let $=X1(W,z,A,U);return q2(w,A,$)}for(let W of w.anyOf){let $=X1(W,z,A,U);if(!a(w,z,$))continue;return q2(w,A,$)}return q2(w,A,U)}function X1(w,z,A,U){let W=e0(w,z),$=w;switch(w[b]){case"Array":return vY($,W,A,U);case"Import":return oY($,W,A,U);case"Intersect":return uY($,W,A,U);case"Not":return mY($,W,A,U);case"Object":return pY($,W,A,U);case"Record":return lY($,W,A,U);case"Ref":return sY($,W,A,U);case"This":return rY($,W,A,U);case"Tuple":return aY($,W,A,U);case"Union":return eY($,W,A,U);default:return q2($,A,U)}}function z4(w,z,A){return X1(w,z,"",A)}function wq(w,z){return N0(w)||A2(w.items,z)}function zq(w,z){return N0(w)||A2(w.items,z)}function Aq(w,z){return N0(w)||A2(w.returns,z)||w.parameters.some((A)=>A2(A,z))}function Uq(w,z){return N0(w)||A2(w.returns,z)||w.parameters.some((A)=>A2(A,z))}function Wq(w,z){return N0(w)||N0(w.unevaluatedProperties)||w.allOf.some((A)=>A2(A,z))}function $q(w,z){return N0(w)||A2(w.items,z)}function Xq(w,z){return N0(w)||A2(w.not,z)}function Qq(w,z){return N0(w)||Object.values(w.properties).some((A)=>A2(A,z))||T0(w.additionalProperties)&&A2(w.additionalProperties,z)}function Zq(w,z){return N0(w)||A2(w.item,z)}function Jq(w,z){let A=Object.getOwnPropertyNames(w.patternProperties)[0],U=w.patternProperties[A];return N0(w)||A2(U,z)||T0(w.additionalProperties)&&N0(w.additionalProperties)}function Yq(w,z){if(N0(w))return!0;return A2(Y0(w,z),z)}function qq(w,z){if(N0(w))return!0;return A2(Y0(w,z),z)}function Bq(w,z){return N0(w)||!k0(w.items)&&w.items.some((A)=>A2(A,z))}function Mq(w,z){return N0(w)||w.anyOf.some((A)=>A2(A,z))}function A2(w,z){let A=e0(w,z),U=w;if(w.$id&&k5.has(w.$id))return!1;if(w.$id)k5.add(w.$id);switch(w[b]){case"Array":return wq(U,A);case"AsyncIterator":return zq(U,A);case"Constructor":return Aq(U,A);case"Function":return Uq(U,A);case"Intersect":return Wq(U,A);case"Iterator":return $q(U,A);case"Not":return Xq(U,A);case"Object":return Qq(U,A);case"Promise":return Zq(U,A);case"Record":return Jq(U,A);case"Ref":return Yq(U,A);case"This":return qq(U,A);case"Tuple":return Bq(U,A);case"Union":return Mq(U,A);default:return N0(w)}}var k5=new Set;function d1(w,z){return k5.clear(),A2(w,z)}class XA{constructor(w,z,A,U){this.schema=w,this.references=z,this.checkFunc=A,this.code=U,this.hasTransform=d1(w,z)}Code(){return this.code}Schema(){return this.schema}References(){return this.references}Errors(w){return S1(this.schema,this.references,w)}Check(w){return this.checkFunc(w)}Decode(w){if(!this.checkFunc(w))throw new T4(this.schema,w,this.Errors(w).First());return this.hasTransform?w4(this.schema,this.references,w):w}Encode(w){let z=this.hasTransform?z4(this.schema,this.references,w):w;if(!this.checkFunc(z))throw new i4(this.schema,w,this.Errors(w).First());return z}}var c1;(function(w){function z($){return $===36}w.DollarSign=z;function A($){return $===95}w.IsUnderscore=A;function U($){return $>=65&&$<=90||$>=97&&$<=122}w.IsAlpha=U;function W($){return $>=48&&$<=57}w.IsNumeric=W})(c1||(c1={}));var kw;(function(w){function z($){if($.length===0)return!1;return c1.IsNumeric($.charCodeAt(0))}function A($){if(z($))return!1;for(let X=0;X<$.length;X++){let Q=$.charCodeAt(X);if(!(c1.IsAlpha(Q)||c1.IsNumeric(Q)||c1.DollarSign(Q)||c1.IsUnderscore(Q)))return!1}return!0}function U($){return $.replace(/'/g,"\\'")}function W($,X){return A(X)?`${$}.${X}`:`${$}['${U(X)}']`}w.Encode=W})(kw||(kw={}));var V5;(function(w){function z(A){let U=[];for(let W=0;W<A.length;W++){let $=A.charCodeAt(W);if(c1.IsNumeric($)||c1.IsAlpha($))U.push(A.charAt(W));else U.push(`_${$}_`)}return U.join("").replace(/__/g,"_")}w.Encode=z})(V5||(V5={}));var g5;(function(w){function z(A){return A.replace(/'/g,"\\'")}w.Escape=z})(g5||(g5={}));class QA extends n{constructor(w){super("Unknown type");this.schema=w}}class T5 extends n{constructor(w){super("Preflight validation check failed to guard for the given schema");this.schema=w}}var _6;(function(w){function z(X,Q,Z){return I0.ExactOptionalPropertyTypes?`('${Q}' in ${X} ? ${Z} : true)`:`(${kw.Encode(X,Q)} !== undefined ? ${Z} : true)`}w.IsExactOptionalProperty=z;function A(X){return!I0.AllowArrayObject?`(typeof ${X} === 'object' && ${X} !== null && !Array.isArray(${X}))`:`(typeof ${X} === 'object' && ${X} !== null)`}w.IsObjectLike=A;function U(X){return!I0.AllowArrayObject?`(typeof ${X} === 'object' && ${X} !== null && !Array.isArray(${X}) && !(${X} instanceof Date) && !(${X} instanceof Uint8Array))`:`(typeof ${X} === 'object' && ${X} !== null && !(${X} instanceof Date) && !(${X} instanceof Uint8Array))`}w.IsRecordLike=U;function W(X){return I0.AllowNaN?`typeof ${X} === 'number'`:`Number.isFinite(${X})`}w.IsNumberLike=W;function $(X){return I0.AllowNullVoid?`(${X} === undefined || ${X} === null)`:`${X} === undefined`}w.IsVoidLike=$})(_6||(_6={}));var w6;(function(w){function z(B){return B[b]==="Any"||B[b]==="Unknown"}function*A(B,j,H){yield"true"}function*U(B,j,H){yield`Array.isArray(${H})`;let[i,E]=[P("value","any"),P("acc","number")];if(d(B.maxItems))yield`${H}.length <= ${B.maxItems}`;if(d(B.minItems))yield`${H}.length >= ${B.minItems}`;let k=L2(B.items,j,"value");if(yield`${H}.every((${i}) => ${k})`,g0(B.contains)||d(B.minContains)||d(B.maxContains)){let K0=g0(B.contains)?B.contains:H0(),P2=L2(K0,j,"value"),O1=d(B.minContains)?[`(count >= ${B.minContains})`]:[],z1=d(B.maxContains)?[`(count <= ${B.maxContains})`]:[],H1=`const count = value.reduce((${E}, ${i}) => ${P2} ? acc + 1 : acc, 0)`,Uw=["(count > 0)",...O1,...z1].join(" && ");yield`((${i}) => { ${H1}; return ${Uw}})(${H})`}if(B.uniqueItems===!0)yield`((${i}) => { const set = new Set(); for(const element of value) { const hashed = hash(element); if(set.has(hashed)) { return false } else { set.add(hashed) } } return true } )(${H})`}function*W(B,j,H){yield`(typeof value === 'object' && Symbol.asyncIterator in ${H})`}function*$(B,j,H){if(yield`(typeof ${H} === 'bigint')`,U2(B.exclusiveMaximum))yield`${H} < BigInt(${B.exclusiveMaximum})`;if(U2(B.exclusiveMinimum))yield`${H} > BigInt(${B.exclusiveMinimum})`;if(U2(B.maximum))yield`${H} <= BigInt(${B.maximum})`;if(U2(B.minimum))yield`${H} >= BigInt(${B.minimum})`;if(U2(B.multipleOf))yield`(${H} % BigInt(${B.multipleOf})) === 0`}function*X(B,j,H){yield`(typeof ${H} === 'boolean')`}function*Q(B,j,H){yield*m0(B.returns,j,`${H}.prototype`)}function*Z(B,j,H){if(yield`(${H} instanceof Date) && Number.isFinite(${H}.getTime())`,d(B.exclusiveMaximumTimestamp))yield`${H}.getTime() < ${B.exclusiveMaximumTimestamp}`;if(d(B.exclusiveMinimumTimestamp))yield`${H}.getTime() > ${B.exclusiveMinimumTimestamp}`;if(d(B.maximumTimestamp))yield`${H}.getTime() <= ${B.maximumTimestamp}`;if(d(B.minimumTimestamp))yield`${H}.getTime() >= ${B.minimumTimestamp}`;if(d(B.multipleOfTimestamp))yield`(${H}.getTime() % ${B.multipleOfTimestamp}) === 0`}function*J(B,j,H){yield`(typeof ${H} === 'function')`}function*Y(B,j,H){let i=globalThis.Object.getOwnPropertyNames(B.$defs).reduce((E,k)=>{return[...E,B.$defs[k]]},[]);yield*m0(K2(B.$ref),[...j,...i],H)}function*L(B,j,H){if(yield`Number.isInteger(${H})`,d(B.exclusiveMaximum))yield`${H} < ${B.exclusiveMaximum}`;if(d(B.exclusiveMinimum))yield`${H} > ${B.exclusiveMinimum}`;if(d(B.maximum))yield`${H} <= ${B.maximum}`;if(d(B.minimum))yield`${H} >= ${B.minimum}`;if(d(B.multipleOf))yield`(${H} % ${B.multipleOf}) === 0`}function*_(B,j,H){let i=B.allOf.map((E)=>L2(E,j,H)).join(" && ");if(B.unevaluatedProperties===!1){let E=b2(`${new RegExp(k1(B))};`),k=`Object.getOwnPropertyNames(${H}).every(key => ${E}.test(key))`;yield`(${i} && ${k})`}else if(g0(B.unevaluatedProperties)){let E=b2(`${new RegExp(k1(B))};`),k=`Object.getOwnPropertyNames(${H}).every(key => ${E}.test(key) || ${L2(B.unevaluatedProperties,j,`${H}[key]`)})`;yield`(${i} && ${k})`}else yield`(${i})`}function*G(B,j,H){yield`(typeof value === 'object' && Symbol.iterator in ${H})`}function*O(B,j,H){if(typeof B.const==="number"||typeof B.const==="boolean")yield`(${H} === ${B.const})`;else yield`(${H} === '${g5.Escape(B.const)}')`}function*C(B,j,H){yield"false"}function*q(B,j,H){yield`(!${L2(B.not,j,H)})`}function*o(B,j,H){yield`(${H} === null)`}function*W0(B,j,H){if(yield _6.IsNumberLike(H),d(B.exclusiveMaximum))yield`${H} < ${B.exclusiveMaximum}`;if(d(B.exclusiveMinimum))yield`${H} > ${B.exclusiveMinimum}`;if(d(B.maximum))yield`${H} <= ${B.maximum}`;if(d(B.minimum))yield`${H} >= ${B.minimum}`;if(d(B.multipleOf))yield`(${H} % ${B.multipleOf}) === 0`}function*L0(B,j,H){if(yield _6.IsObjectLike(H),d(B.minProperties))yield`Object.getOwnPropertyNames(${H}).length >= ${B.minProperties}`;if(d(B.maxProperties))yield`Object.getOwnPropertyNames(${H}).length <= ${B.maxProperties}`;let i=Object.getOwnPropertyNames(B.properties);for(let E of i){let k=kw.Encode(H,E),K0=B.properties[E];if(B.required&&B.required.includes(E)){if(yield*m0(K0,j,k),g1(K0)||z(K0))yield`('${E}' in ${H})`}else{let P2=L2(K0,j,k);yield _6.IsExactOptionalProperty(H,E,P2)}}if(B.additionalProperties===!1)if(B.required&&B.required.length===i.length)yield`Object.getOwnPropertyNames(${H}).length === ${i.length}`;else{let E=`[${i.map((k)=>`'${k}'`).join(", ")}]`;yield`Object.getOwnPropertyNames(${H}).every(key => ${E}.includes(key))`}if(typeof B.additionalProperties==="object"){let E=L2(B.additionalProperties,j,`${H}[key]`),k=`[${i.map((K0)=>`'${K0}'`).join(", ")}]`;yield`(Object.getOwnPropertyNames(${H}).every(key => ${k}.includes(key) || ${E}))`}}function*c(B,j,H){yield`(typeof value === 'object' && typeof ${H}.then === 'function')`}function*e(B,j,H){if(yield _6.IsRecordLike(H),d(B.minProperties))yield`Object.getOwnPropertyNames(${H}).length >= ${B.minProperties}`;if(d(B.maxProperties))yield`Object.getOwnPropertyNames(${H}).length <= ${B.maxProperties}`;let[i,E]=Object.entries(B.patternProperties)[0],k=b2(`${new RegExp(i)}`),K0=L2(E,j,"value"),P2=g0(B.additionalProperties)?L2(B.additionalProperties,j,H):B.additionalProperties===!1?"false":"true",O1=`(${k}.test(key) ? ${K0} : ${P2})`;yield`(Object.entries(${H}).every(([key, value]) => ${O1}))`}function*f(B,j,H){let i=Y0(B,j);if(p0.functions.has(B.$ref))return yield`${L4(B.$ref)}(${H})`;yield*m0(i,j,H)}function*t(B,j,H){let i=b2(`${new RegExp(B.source,B.flags)};`);if(yield`(typeof ${H} === 'string')`,d(B.maxLength))yield`${H}.length <= ${B.maxLength}`;if(d(B.minLength))yield`${H}.length >= ${B.minLength}`;yield`${i}.test(${H})`}function*K(B,j,H){if(yield`(typeof ${H} === 'string')`,d(B.maxLength))yield`${H}.length <= ${B.maxLength}`;if(d(B.minLength))yield`${H}.length >= ${B.minLength}`;if(B.pattern!==void 0)yield`${b2(`${new RegExp(B.pattern)};`)}.test(${H})`;if(B.format!==void 0)yield`format('${B.format}', ${H})`}function*l(B,j,H){yield`(typeof ${H} === 'symbol')`}function*D0(B,j,H){yield`(typeof ${H} === 'string')`,yield`${b2(`${new RegExp(B.pattern)};`)}.test(${H})`}function*s(B,j,H){yield`${L4(B.$ref)}(${H})`}function*P1(B,j,H){if(yield`Array.isArray(${H})`,B.items===void 0)return yield`${H}.length === 0`;yield`(${H}.length === ${B.maxItems})`;for(let i=0;i<B.items.length;i++)yield`${L2(B.items[i],j,`${H}[${i}]`)}`}function*R0(B,j,H){yield`${H} === undefined`}function*v1(B,j,H){yield`(${B.anyOf.map((E)=>L2(E,j,H)).join(" || ")})`}function*f2(B,j,H){if(yield`${H} instanceof Uint8Array`,d(B.maxByteLength))yield`(${H}.length <= ${B.maxByteLength})`;if(d(B.minByteLength))yield`(${H}.length >= ${B.minByteLength})`}function*q6(B,j,H){yield"true"}function*z5(B,j,H){yield _6.IsVoidLike(H)}function*I6(B,j,H){let i=p0.instances.size;p0.instances.set(i,B),yield`kind('${B[b]}', ${i}, ${H})`}function*m0(B,j,H,i=!0){let E=Q0(B.$id)?[...j,B]:j,k=B;if(i&&Q0(B.$id)){let K0=L4(B.$id);if(p0.functions.has(K0))return yield`${K0}(${H})`;else{p0.functions.set(K0,"<deferred>");let P2=F(K0,B,j,"value",!1);return p0.functions.set(K0,P2),yield`${K0}(${H})`}}switch(k[b]){case"Any":return yield*A(k,E,H);case"Array":return yield*U(k,E,H);case"AsyncIterator":return yield*W(k,E,H);case"BigInt":return yield*$(k,E,H);case"Boolean":return yield*X(k,E,H);case"Constructor":return yield*Q(k,E,H);case"Date":return yield*Z(k,E,H);case"Function":return yield*J(k,E,H);case"Import":return yield*Y(k,E,H);case"Integer":return yield*L(k,E,H);case"Intersect":return yield*_(k,E,H);case"Iterator":return yield*G(k,E,H);case"Literal":return yield*O(k,E,H);case"Never":return yield*C(k,E,H);case"Not":return yield*q(k,E,H);case"Null":return yield*o(k,E,H);case"Number":return yield*W0(k,E,H);case"Object":return yield*L0(k,E,H);case"Promise":return yield*c(k,E,H);case"Record":return yield*e(k,E,H);case"Ref":return yield*f(k,E,H);case"RegExp":return yield*t(k,E,H);case"String":return yield*K(k,E,H);case"Symbol":return yield*l(k,E,H);case"TemplateLiteral":return yield*D0(k,E,H);case"This":return yield*s(k,E,H);case"Tuple":return yield*P1(k,E,H);case"Undefined":return yield*R0(k,E,H);case"Union":return yield*v1(k,E,H);case"Uint8Array":return yield*f2(k,E,H);case"Unknown":return yield*q6(k,E,H);case"Void":return yield*z5(k,E,H);default:if(!c0.Has(k[b]))throw new QA(B);return yield*I6(k,E,H)}}let p0={language:"javascript",functions:new Map,variables:new Map,instances:new Map};function L2(B,j,H,i=!0){return`(${[...m0(B,j,H,i)].join(" && ")})`}function L4(B){return`check_${V5.Encode(B)}`}function b2(B){let j=`local_${p0.variables.size}`;return p0.variables.set(j,`const ${j} = ${B}`),j}function F(B,j,H,i,E=!0){let[k,K0]=[`
2
- `,(H1)=>"".padStart(H1," ")],P2=P("value","any"),O1=R("boolean"),z1=[...m0(j,H,i,E)].map((H1)=>`${K0(4)}${H1}`).join(` &&${k}`);return`function ${B}(${P2})${O1} {${k}${K0(2)}return (${k}${z1}${k}${K0(2)})
3
- }`}function P(B,j){let H=p0.language==="typescript"?`: ${j}`:"";return`${B}${H}`}function R(B){return p0.language==="typescript"?`: ${B}`:""}function V(B,j,H){let i=F("check",B,j,"value"),E=P("value","any"),k=R("boolean"),K0=[...p0.functions.values()],P2=[...p0.variables.values()],O1=Q0(B.$id)?`return function check(${E})${k} {
4
- return ${L4(B.$id)}(value)
5
- }`:`return ${i}`;return[...P2,...K0,O1].join(`
6
- `)}function u(...B){let j={language:"javascript"},[H,i,E]=B.length===2&&v(B[1])?[B[0],B[1],j]:B.length===2&&!v(B[1])?[B[0],[],B[1]]:B.length===3?[B[0],B[1],B[2]]:B.length===1?[B[0],[],j]:[null,[],j];if(p0.language=E.language,p0.variables.clear(),p0.functions.clear(),p0.instances.clear(),!g0(H))throw new T5(H);for(let k of i)if(!g0(k))throw new T5(k);return V(H,i,E)}w.Code=u;function $0(B,j=[]){let H=u(B,j,{language:"javascript"}),i=globalThis.Function("kind","format","hash",H),E=new Map(p0.instances);function k(z1,H1,Uw){if(!c0.Has(z1)||!E.has(H1))return!1;let DW=c0.Get(z1),_W=E.get(H1);return DW(_W,Uw)}function K0(z1,H1){if(!O0.Has(z1))return!1;return O0.Get(z1)(H1)}function P2(z1){return e1(z1)}let O1=i(k,K0,P2);return new XA(B,j,O1,H)}w.Compile=$0})(w6||(w6={}));var Hq=function(w,z,A,U,W){if(U==="m")throw new TypeError("Private method is not writable");if(U==="a"&&!W)throw new TypeError("Private accessor was defined without a setter");if(typeof z==="function"?w!==z||!W:!z.has(w))throw new TypeError("Cannot write private member to an object whose class did not declare it");return U==="a"?W.call(w,A):W?W.value=A:z.set(w,A),A},JA=function(w,z,A,U){if(A==="a"&&!U)throw new TypeError("Private accessor was defined without a getter");if(typeof z==="function"?w!==z||!U:!z.has(w))throw new TypeError("Cannot read private member from an object whose class did not declare it");return A==="m"?U:A==="a"?U.call(w):U?U.value:z.get(w)},i5,Vw,YA;class qA extends n{constructor(w){let z=w.First();super(z===void 0?"Invalid Value":z.message);i5.add(this),Vw.set(this,void 0),Hq(this,Vw,w,"f"),this.error=z}Errors(){return new D6(JA(this,i5,"m",YA).call(this))}}Vw=new WeakMap,i5=new WeakSet,YA=function*w(){if(this.error)yield this.error;yield*JA(this,Vw,"f")};function ZA(w,z,A){if(a(w,z,A))return;throw new qA(S1(w,z,A))}function gw(...w){return w.length===3?ZA(w[0],w[1],w[2]):ZA(w[0],[],w[1])}function Gq(w){let z={};for(let A of Object.getOwnPropertyNames(w))z[A]=q0(w[A]);for(let A of Object.getOwnPropertySymbols(w))z[A]=q0(w[A]);return z}function Lq(w){return w.map((z)=>q0(z))}function bq(w){return w.slice()}function Nq(w){return new Map(q0([...w.entries()]))}function Sq(w){return new Set(q0([...w.entries()]))}function Dq(w){return new Date(w.toISOString())}function _q(w){return w}function q0(w){if(v(w))return Lq(w);if(S2(w))return Dq(w);if(c2(w))return bq(w);if(Fz(w))return Nq(w);if(xz(w))return Sq(w);if(r(w))return Gq(w);if(k2(w))return _q(w);throw new Error("ValueClone: Unable to clone value")}class l2 extends n{constructor(w,z){super(z);this.schema=w}}function B0(w){return o1(w)?w():q0(w)}function Pq(w,z){if(y(w,"default"))return B0(w.default);else return{}}function Oq(w,z){if(w.uniqueItems===!0&&!y(w,"default"))throw new l2(w,"Array with the uniqueItems constraint requires a default value");else if("contains"in w&&!y(w,"default"))throw new l2(w,"Array with the contains constraint requires a default value");else if("default"in w)return B0(w.default);else if(w.minItems!==void 0)return Array.from({length:w.minItems}).map((A)=>{return x2(w.items,z)});else return[]}function Cq(w,z){if(y(w,"default"))return B0(w.default);else return async function*(){}()}function Rq(w,z){if(y(w,"default"))return B0(w.default);else return BigInt(0)}function Kq(w,z){if(y(w,"default"))return B0(w.default);else return!1}function jq(w,z){if(y(w,"default"))return B0(w.default);else{let A=x2(w.returns,z);if(typeof A==="object"&&!Array.isArray(A))return class{constructor(){for(let[U,W]of Object.entries(A)){let $=this;$[U]=W}}};else return class{}}}function Fq(w,z){if(y(w,"default"))return B0(w.default);else if(w.minimumTimestamp!==void 0)return new Date(w.minimumTimestamp);else return new Date}function xq(w,z){if(y(w,"default"))return B0(w.default);else return()=>x2(w.returns,z)}function Eq(w,z){let A=globalThis.Object.values(w.$defs),U=w.$defs[w.$ref];return x2(U,[...z,...A])}function Iq(w,z){if(y(w,"default"))return B0(w.default);else if(w.minimum!==void 0)return w.minimum;else return 0}function fq(w,z){if(y(w,"default"))return B0(w.default);else{let A=w.allOf.reduce((U,W)=>{let $=x2(W,z);return typeof $==="object"?{...U,...$}:$},{});if(!a(w,z,A))throw new l2(w,"Intersect produced invalid value. Consider using a default value.");return A}}function kq(w,z){if(y(w,"default"))return B0(w.default);else return function*(){}()}function Vq(w,z){if(y(w,"default"))return B0(w.default);else return w.const}function gq(w,z){if(y(w,"default"))return B0(w.default);else throw new l2(w,"Never types cannot be created. Consider using a default value.")}function Tq(w,z){if(y(w,"default"))return B0(w.default);else throw new l2(w,"Not types must have a default value")}function iq(w,z){if(y(w,"default"))return B0(w.default);else return null}function dq(w,z){if(y(w,"default"))return B0(w.default);else if(w.minimum!==void 0)return w.minimum;else return 0}function cq(w,z){if(y(w,"default"))return B0(w.default);else{let A=new Set(w.required),U={};for(let[W,$]of Object.entries(w.properties)){if(!A.has(W))continue;U[W]=x2($,z)}return U}}function nq(w,z){if(y(w,"default"))return B0(w.default);else return Promise.resolve(x2(w.item,z))}function hq(w,z){let[A,U]=Object.entries(w.patternProperties)[0];if(y(w,"default"))return B0(w.default);else if(!(A===I1||A===E1)){let W=A.slice(1,A.length-1).split("|"),$={};for(let X of W)$[X]=x2(U,z);return $}else return{}}function tq(w,z){if(y(w,"default"))return B0(w.default);else return x2(Y0(w,z),z)}function yq(w,z){if(y(w,"default"))return B0(w.default);else throw new l2(w,"RegExp types cannot be created. Consider using a default value.")}function vq(w,z){if(w.pattern!==void 0)if(!y(w,"default"))throw new l2(w,"String types with patterns must specify a default value");else return B0(w.default);else if(w.format!==void 0)if(!y(w,"default"))throw new l2(w,"String types with formats must specify a default value");else return B0(w.default);else if(y(w,"default"))return B0(w.default);else if(w.minLength!==void 0)return Array.from({length:w.minLength}).map(()=>" ").join("");else return""}function oq(w,z){if(y(w,"default"))return B0(w.default);else if("value"in w)return Symbol.for(w.value);else return Symbol()}function uq(w,z){if(y(w,"default"))return B0(w.default);if(!Lw(w))throw new l2(w,"Can only create template literals that produce a finite variants. Consider using a default value.");return h6(w)[0]}function mq(w,z){if(BA++>zB)throw new l2(w,"Cannot create recursive type as it appears possibly infinite. Consider using a default.");if(y(w,"default"))return B0(w.default);else return x2(Y0(w,z),z)}function pq(w,z){if(y(w,"default"))return B0(w.default);if(w.items===void 0)return[];else return Array.from({length:w.minItems}).map((A,U)=>x2(w.items[U],z))}function lq(w,z){if(y(w,"default"))return B0(w.default);else return}function sq(w,z){if(y(w,"default"))return B0(w.default);else if(w.anyOf.length===0)throw new Error("ValueCreate.Union: Cannot create Union with zero variants");else return x2(w.anyOf[0],z)}function rq(w,z){if(y(w,"default"))return B0(w.default);else if(w.minByteLength!==void 0)return new Uint8Array(w.minByteLength);else return new Uint8Array(0)}function aq(w,z){if(y(w,"default"))return B0(w.default);else return{}}function eq(w,z){if(y(w,"default"))return B0(w.default);else return}function wB(w,z){if(y(w,"default"))return B0(w.default);else throw new Error("User defined types must specify a default value")}function x2(w,z){let A=e0(w,z),U=w;switch(U[b]){case"Any":return Pq(U,A);case"Array":return Oq(U,A);case"AsyncIterator":return Cq(U,A);case"BigInt":return Rq(U,A);case"Boolean":return Kq(U,A);case"Constructor":return jq(U,A);case"Date":return Fq(U,A);case"Function":return xq(U,A);case"Import":return Eq(U,A);case"Integer":return Iq(U,A);case"Intersect":return fq(U,A);case"Iterator":return kq(U,A);case"Literal":return Vq(U,A);case"Never":return gq(U,A);case"Not":return Tq(U,A);case"Null":return iq(U,A);case"Number":return dq(U,A);case"Object":return cq(U,A);case"Promise":return nq(U,A);case"Record":return hq(U,A);case"Ref":return tq(U,A);case"RegExp":return yq(U,A);case"String":return vq(U,A);case"Symbol":return oq(U,A);case"TemplateLiteral":return uq(U,A);case"This":return mq(U,A);case"Tuple":return pq(U,A);case"Undefined":return lq(U,A);case"Union":return sq(U,A);case"Uint8Array":return rq(U,A);case"Unknown":return aq(U,A);case"Void":return eq(U,A);default:if(!c0.Has(U[b]))throw new l2(U,"Unknown type");return wB(U,A)}}var zB=512,BA=0;function s2(...w){return BA=0,w.length===2?x2(w[0],w[1]):x2(w[0],[])}class d5 extends n{constructor(w,z){super(z);this.schema=w}}function AB(w,z,A){if(w[b]==="Object"&&typeof A==="object"&&!K1(A)){let U=w,W=Object.getOwnPropertyNames(A),$=Object.entries(U.properties),[X,Q]=[1/$.length,$.length];return $.reduce((Z,[J,Y])=>{let L=Y[b]==="Literal"&&Y.const===A[J]?Q:0,_=a(Y,z,A[J])?X:0,G=W.includes(J)?X:0;return Z+(L+_+G)},0)}else return a(w,z,A)?1:0}function UB(w,z,A){let U=w.anyOf.map((X)=>Y0(X,z)),[W,$]=[U[0],0];for(let X of U){let Q=AB(X,z,A);if(Q>$)W=X,$=Q}return W}function WB(w,z,A){if("default"in w)return typeof A==="function"?w.default:q0(w.default);else{let U=UB(w,z,A);return c5(U,z,A)}}function $B(w,z,A){return a(w,z,A)?q0(A):s2(w,z)}function XB(w,z,A){return a(w,z,A)?A:s2(w,z)}function QB(w,z,A){if(a(w,z,A))return q0(A);let U=v(A)?q0(A):s2(w,z),W=d(w.minItems)&&U.length<w.minItems?[...U,...Array.from({length:w.minItems-U.length},()=>null)]:U,X=(d(w.maxItems)&&W.length>w.maxItems?W.slice(0,w.maxItems):W).map((Z)=>Q1(w.items,z,Z));if(w.uniqueItems!==!0)return X;let Q=[...new Set(X)];if(!a(w,z,Q))throw new d5(w,"Array cast produced invalid data due to uniqueItems constraint");return Q}function ZB(w,z,A){if(a(w,z,A))return s2(w,z);let U=new Set(w.returns.required||[]),W=function(){};for(let[$,X]of Object.entries(w.returns.properties)){if(!U.has($)&&A.prototype[$]===void 0)continue;W.prototype[$]=Q1(X,z,A.prototype[$])}return W}function JB(w,z,A){let U=globalThis.Object.values(w.$defs),W=w.$defs[w.$ref];return Q1(W,[...z,...U],A)}function YB(w,z,A){let U=s2(w,z),W=r(U)&&r(A)?{...U,...A}:A;return a(w,z,W)?W:s2(w,z)}function qB(w,z,A){throw new d5(w,"Never types cannot be cast")}function BB(w,z,A){if(a(w,z,A))return A;if(A===null||typeof A!=="object")return s2(w,z);let U=new Set(w.required||[]),W={};for(let[$,X]of Object.entries(w.properties)){if(!U.has($)&&A[$]===void 0)continue;W[$]=Q1(X,z,A[$])}if(typeof w.additionalProperties==="object"){let $=Object.getOwnPropertyNames(w.properties);for(let X of Object.getOwnPropertyNames(A)){if($.includes(X))continue;W[X]=Q1(w.additionalProperties,z,A[X])}}return W}function MB(w,z,A){if(a(w,z,A))return q0(A);if(A===null||typeof A!=="object"||Array.isArray(A)||A instanceof Date)return s2(w,z);let U=Object.getOwnPropertyNames(w.patternProperties)[0],W=w.patternProperties[U],$={};for(let[X,Q]of Object.entries(A))$[X]=Q1(W,z,Q);return $}function HB(w,z,A){return Q1(Y0(w,z),z,A)}function GB(w,z,A){return Q1(Y0(w,z),z,A)}function LB(w,z,A){if(a(w,z,A))return q0(A);if(!v(A))return s2(w,z);if(w.items===void 0)return[];return w.items.map((U,W)=>Q1(U,z,A[W]))}function bB(w,z,A){return a(w,z,A)?q0(A):WB(w,z,A)}function Q1(w,z,A){let U=Q0(w.$id)?e0(w,z):z,W=w;switch(w[b]){case"Array":return QB(W,U,A);case"Constructor":return ZB(W,U,A);case"Import":return JB(W,U,A);case"Intersect":return YB(W,U,A);case"Never":return qB(W,U,A);case"Object":return BB(W,U,A);case"Record":return MB(W,U,A);case"Ref":return HB(W,U,A);case"This":return GB(W,U,A);case"Tuple":return LB(W,U,A);case"Union":return bB(W,U,A);case"Date":case"Symbol":case"Uint8Array":return $B(w,z,A);default:return XB(W,U,A)}}function c5(...w){return w.length===3?Q1(w[0],w[1],w[2]):Q1(w[0],[],w[1])}function NB(w){return m1(w)&&w[b]!=="Unsafe"}function SB(w,z,A){if(!v(A))return A;return A.map((U)=>E2(w.items,z,U))}function DB(w,z,A){let U=globalThis.Object.values(w.$defs),W=w.$defs[w.$ref];return E2(W,[...z,...U],A)}function _B(w,z,A){let U=w.unevaluatedProperties,$=w.allOf.map((Q)=>E2(Q,z,q0(A))).reduce((Q,Z)=>r(Z)?{...Q,...Z}:Z,{});if(!r(A)||!r($)||!m1(U))return $;let X=j2(w);for(let Q of Object.getOwnPropertyNames(A)){if(X.includes(Q))continue;if(a(U,z,A[Q]))$[Q]=E2(U,z,A[Q])}return $}function PB(w,z,A){if(!r(A)||v(A))return A;let U=w.additionalProperties;for(let W of Object.getOwnPropertyNames(A)){if(y(w.properties,W)){A[W]=E2(w.properties[W],z,A[W]);continue}if(m1(U)&&a(U,z,A[W])){A[W]=E2(U,z,A[W]);continue}delete A[W]}return A}function OB(w,z,A){if(!r(A))return A;let U=w.additionalProperties,W=Object.getOwnPropertyNames(A),[$,X]=Object.entries(w.patternProperties)[0],Q=new RegExp($);for(let Z of W){if(Q.test(Z)){A[Z]=E2(X,z,A[Z]);continue}if(m1(U)&&a(U,z,A[Z])){A[Z]=E2(U,z,A[Z]);continue}delete A[Z]}return A}function CB(w,z,A){return E2(Y0(w,z),z,A)}function RB(w,z,A){return E2(Y0(w,z),z,A)}function KB(w,z,A){if(!v(A))return A;if(k0(w.items))return[];let U=Math.min(A.length,w.items.length);for(let W=0;W<U;W++)A[W]=E2(w.items[W],z,A[W]);return A.length>U?A.slice(0,U):A}function jB(w,z,A){for(let U of w.anyOf)if(NB(U)&&a(U,z,A))return E2(U,z,A);return A}function E2(w,z,A){let U=Q0(w.$id)?e0(w,z):z,W=w;switch(W[b]){case"Array":return SB(W,U,A);case"Import":return DB(W,U,A);case"Intersect":return _B(W,U,A);case"Object":return PB(W,U,A);case"Record":return OB(W,U,A);case"Ref":return CB(W,U,A);case"This":return RB(W,U,A);case"Tuple":return KB(W,U,A);case"Union":return jB(W,U,A);default:return A}}function Tw(...w){return w.length===3?E2(w[0],w[1],w[2]):E2(w[0],[],w[1])}function iw(w){return Q0(w)&&!isNaN(w)&&!isNaN(parseFloat(w))}function FB(w){return U2(w)||G1(w)||d(w)}function d4(w){return w===!0||d(w)&&w===1||U2(w)&&w===BigInt("1")||Q0(w)&&(w.toLowerCase()==="true"||w==="1")}function c4(w){return w===!1||d(w)&&(w===0||Object.is(w,-0))||U2(w)&&w===BigInt("0")||Q0(w)&&(w.toLowerCase()==="false"||w==="0"||w==="-0")}function xB(w){return Q0(w)&&/^(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)$/i.test(w)}function EB(w){return Q0(w)&&/^(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)?$/i.test(w)}function IB(w){return Q0(w)&&/^\d\d\d\d-[0-1]\d-[0-3]\dt(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)$/i.test(w)}function fB(w){return Q0(w)&&/^\d\d\d\d-[0-1]\d-[0-3]\dt(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)?$/i.test(w)}function kB(w){return Q0(w)&&/^\d\d\d\d-[0-1]\d-[0-3]\d$/i.test(w)}function VB(w,z){let A=HA(w);return A===z?A:w}function gB(w,z){let A=GA(w);return A===z?A:w}function TB(w,z){let A=MA(w);return A===z?A:w}function iB(w,z){return Q0(w.const)?VB(z,w.const):d(w.const)?gB(z,w.const):G1(w.const)?TB(z,w.const):z}function MA(w){return d4(w)?!0:c4(w)?!1:w}function dB(w){let z=(A)=>A.split(".")[0];return iw(w)?BigInt(z(w)):d(w)?BigInt(Math.trunc(w)):c4(w)?BigInt(0):d4(w)?BigInt(1):w}function HA(w){return j1(w)&&w.description!==void 0?w.description.toString():FB(w)?w.toString():w}function GA(w){return iw(w)?parseFloat(w):d4(w)?1:c4(w)?0:w}function cB(w){return iw(w)?parseInt(w):d(w)?w|0:d4(w)?1:c4(w)?0:w}function nB(w){return Q0(w)&&w.toLowerCase()==="null"?null:w}function hB(w){return Q0(w)&&w==="undefined"?void 0:w}function tB(w){return S2(w)?w:d(w)?new Date(w):d4(w)?new Date(1):c4(w)?new Date(0):iw(w)?new Date(parseInt(w)):EB(w)?new Date(`1970-01-01T${w}.000Z`):xB(w)?new Date(`1970-01-01T${w}`):fB(w)?new Date(`${w}.000Z`):IB(w)?new Date(w):kB(w)?new Date(`${w}T00:00:00.000Z`):w}function yB(w){return w}function vB(w,z,A){return(v(A)?A:[A]).map((W)=>Z1(w.items,z,W))}function oB(w,z,A){return dB(A)}function uB(w,z,A){return MA(A)}function mB(w,z,A){return tB(A)}function pB(w,z,A){let U=globalThis.Object.values(w.$defs),W=w.$defs[w.$ref];return Z1(W,[...z,...U],A)}function lB(w,z,A){return cB(A)}function sB(w,z,A){return w.allOf.reduce((U,W)=>Z1(W,z,U),A)}function rB(w,z,A){return iB(w,A)}function aB(w,z,A){return nB(A)}function eB(w,z,A){return GA(A)}function wM(w,z,A){if(!r(A))return A;for(let U of Object.getOwnPropertyNames(w.properties)){if(!y(A,U))continue;A[U]=Z1(w.properties[U],z,A[U])}return A}function zM(w,z,A){if(!r(A))return A;let W=Object.getOwnPropertyNames(w.patternProperties)[0],$=w.patternProperties[W];for(let[X,Q]of Object.entries(A))A[X]=Z1($,z,Q);return A}function AM(w,z,A){return Z1(Y0(w,z),z,A)}function UM(w,z,A){return HA(A)}function WM(w,z,A){return Q0(A)||d(A)?Symbol(A):A}function $M(w,z,A){return Z1(Y0(w,z),z,A)}function XM(w,z,A){if(!(v(A)&&!k0(w.items)))return A;return A.map((W,$)=>{return $<w.items.length?Z1(w.items[$],z,W):W})}function QM(w,z,A){return hB(A)}function ZM(w,z,A){for(let U of w.anyOf){let W=Z1(U,z,q0(A));if(!a(U,z,W))continue;return W}return A}function Z1(w,z,A){let U=e0(w,z),W=w;switch(w[b]){case"Array":return vB(W,U,A);case"BigInt":return oB(W,U,A);case"Boolean":return uB(W,U,A);case"Date":return mB(W,U,A);case"Import":return pB(W,U,A);case"Integer":return lB(W,U,A);case"Intersect":return sB(W,U,A);case"Literal":return rB(W,U,A);case"Null":return aB(W,U,A);case"Number":return eB(W,U,A);case"Object":return wM(W,U,A);case"Record":return zM(W,U,A);case"Ref":return AM(W,U,A);case"String":return UM(W,U,A);case"Symbol":return WM(W,U,A);case"This":return $M(W,U,A);case"Tuple":return XM(W,U,A);case"Undefined":return QM(W,U,A);case"Union":return ZM(W,U,A);default:return yB(A)}}function dw(...w){return w.length===3?Z1(w[0],w[1],w[2]):Z1(w[0],[],w[1])}function LA(...w){let[z,A,U]=w.length===3?[w[0],w[1],w[2]]:[w[0],[],w[1]];if(!a(z,A,U))throw new T4(z,U,S1(z,A,U).First());return d1(z,A)?w4(z,A,U):U}function n1(w,z){let A=y(w,"default")?w.default:void 0,U=o1(A)?A():q0(A);return k0(z)?U:r(z)&&r(U)?Object.assign(U,z):z}function n5(w){return m1(w)&&"default"in w}function JM(w,z,A){if(v(A)){for(let W=0;W<A.length;W++)A[W]=D2(w.items,z,A[W]);return A}let U=n1(w,A);if(!v(U))return U;for(let W=0;W<U.length;W++)U[W]=D2(w.items,z,U[W]);return U}function YM(w,z,A){return S2(A)?A:n1(w,A)}function qM(w,z,A){let U=globalThis.Object.values(w.$defs),W=w.$defs[w.$ref];return D2(W,[...z,...U],A)}function BM(w,z,A){let U=n1(w,A);return w.allOf.reduce((W,$)=>{let X=D2($,z,U);return r(X)?{...W,...X}:X},{})}function MM(w,z,A){let U=n1(w,A);if(!r(U))return U;let W=Object.getOwnPropertyNames(w.properties);for(let $ of W){let X=D2(w.properties[$],z,U[$]);if(k0(X))continue;U[$]=D2(w.properties[$],z,U[$])}if(!n5(w.additionalProperties))return U;for(let $ of Object.getOwnPropertyNames(U)){if(W.includes($))continue;U[$]=D2(w.additionalProperties,z,U[$])}return U}function HM(w,z,A){let U=n1(w,A);if(!r(U))return U;let W=w.additionalProperties,[$,X]=Object.entries(w.patternProperties)[0],Q=new RegExp($);for(let Z of Object.getOwnPropertyNames(U)){if(!(Q.test(Z)&&n5(X)))continue;U[Z]=D2(X,z,U[Z])}if(!n5(W))return U;for(let Z of Object.getOwnPropertyNames(U)){if(Q.test(Z))continue;U[Z]=D2(W,z,U[Z])}return U}function GM(w,z,A){return D2(Y0(w,z),z,n1(w,A))}function LM(w,z,A){return D2(Y0(w,z),z,A)}function bM(w,z,A){let U=n1(w,A);if(!v(U)||k0(w.items))return U;let[W,$]=[w.items,Math.max(w.items.length,U.length)];for(let X=0;X<$;X++)if(X<W.length)U[X]=D2(W[X],z,U[X]);return U}function NM(w,z,A){let U=n1(w,A);for(let W of w.anyOf){let $=D2(W,z,q0(U));if(a(W,z,$))return $}return U}function D2(w,z,A){let U=e0(w,z),W=w;switch(W[b]){case"Array":return JM(W,U,A);case"Date":return YM(W,U,A);case"Import":return qM(W,U,A);case"Intersect":return BM(W,U,A);case"Object":return MM(W,U,A);case"Record":return HM(W,U,A);case"Ref":return GM(W,U,A);case"This":return LM(W,U,A);case"Tuple":return bM(W,U,A);case"Union":return NM(W,U,A);default:return n1(W,A)}}function cw(...w){return w.length===3?D2(w[0],w[1],w[2]):D2(w[0],[],w[1])}var J1={};B6(J1,{ValuePointerRootSetError:()=>h5,ValuePointerRootDeleteError:()=>t5,Set:()=>SM,Has:()=>_M,Get:()=>PM,Format:()=>n4,Delete:()=>DM});class h5 extends n{constructor(w,z,A){super("Cannot set root value");this.value=w,this.path=z,this.update=A}}class t5 extends n{constructor(w,z){super("Cannot delete root value");this.value=w,this.path=z}}function bA(w){return w.indexOf("~")===-1?w:w.replace(/~1/g,"/").replace(/~0/g,"~")}function*n4(w){if(w==="")return;let[z,A]=[0,0];for(let U=0;U<w.length;U++)if(w.charAt(U)==="/")if(U===0)z=U+1;else A=U,yield bA(w.slice(z,A)),z=U+1;else A=U;yield bA(w.slice(z))}function SM(w,z,A){if(z==="")throw new h5(w,z,A);let[U,W,$]=[null,w,""];for(let X of n4(z)){if(W[X]===void 0)W[X]={};U=W,W=W[X],$=X}U[$]=A}function DM(w,z){if(z==="")throw new t5(w,z);let[A,U,W]=[null,w,""];for(let $ of n4(z)){if(U[$]===void 0||U[$]===null)return;A=U,U=U[$],W=$}if(Array.isArray(A)){let $=parseInt(W);A.splice($,1)}else delete A[W]}function _M(w,z){if(z==="")return!0;let[A,U,W]=[null,w,""];for(let $ of n4(z)){if(U[$]===void 0)return!1;A=U,U=U[$],W=$}return Object.getOwnPropertyNames(A).includes(W)}function PM(w,z){if(z==="")return w;let A=w;for(let U of n4(z)){if(A[U]===void 0)return;A=A[U]}return A}function OM(w,z){if(!r(z))return!1;let A=[...Object.keys(w),...Object.getOwnPropertySymbols(w)],U=[...Object.keys(z),...Object.getOwnPropertySymbols(z)];if(A.length!==U.length)return!1;return A.every((W)=>P6(w[W],z[W]))}function CM(w,z){return S2(z)&&w.getTime()===z.getTime()}function RM(w,z){if(!v(z)||w.length!==z.length)return!1;return w.every((A,U)=>P6(A,z[U]))}function KM(w,z){if(!c2(z)||w.length!==z.length||Object.getPrototypeOf(w).constructor.name!==Object.getPrototypeOf(z).constructor.name)return!1;return w.every((A,U)=>P6(A,z[U]))}function jM(w,z){return w===z}function P6(w,z){if(S2(w))return CM(w,z);if(c2(w))return KM(w,z);if(v(w))return RM(w,z);if(r(w))return OM(w,z);if(k2(w))return jM(w,z);throw new Error("ValueEquals: Unable to compare value")}var FM=S0({type:X0("insert"),path:t2(),value:V1()}),xM=S0({type:X0("update"),path:t2(),value:V1()}),EM=S0({type:X0("delete"),path:t2()}),SA=G0([FM,xM,EM]);class y5 extends n{constructor(w,z){super(z);this.value=w}}function nw(w,z){return{type:"update",path:w,value:z}}function DA(w,z){return{type:"insert",path:w,value:z}}function _A(w){return{type:"delete",path:w}}function NA(w){if(globalThis.Object.getOwnPropertySymbols(w).length>0)throw new y5(w,"Cannot diff objects with symbols")}function*IM(w,z,A){if(NA(z),NA(A),!J5(A))return yield nw(w,A);let U=globalThis.Object.getOwnPropertyNames(z),W=globalThis.Object.getOwnPropertyNames(A);for(let $ of W){if(y(z,$))continue;yield DA(`${w}/${$}`,A[$])}for(let $ of U){if(!y(A,$))continue;if(P6(z,A))continue;yield*hw(`${w}/${$}`,z[$],A[$])}for(let $ of U){if(y(A,$))continue;yield _A(`${w}/${$}`)}}function*fM(w,z,A){if(!v(A))return yield nw(w,A);for(let U=0;U<Math.min(z.length,A.length);U++)yield*hw(`${w}/${U}`,z[U],A[U]);for(let U=0;U<A.length;U++){if(U<z.length)continue;yield DA(`${w}/${U}`,A[U])}for(let U=z.length-1;U>=0;U--){if(U<A.length)continue;yield _A(`${w}/${U}`)}}function*kM(w,z,A){if(!c2(A)||z.length!==A.length||globalThis.Object.getPrototypeOf(z).constructor.name!==globalThis.Object.getPrototypeOf(A).constructor.name)return yield nw(w,A);for(let U=0;U<Math.min(z.length,A.length);U++)yield*hw(`${w}/${U}`,z[U],A[U])}function*VM(w,z,A){if(z===A)return;yield nw(w,A)}function*hw(w,z,A){if(J5(z))return yield*IM(w,z,A);if(v(z))return yield*fM(w,z,A);if(c2(z))return yield*kM(w,z,A);if(k2(z))return yield*VM(w,z,A);throw new y5(z,"Unable to diff value")}function PA(w,z){return[...hw("",w,z)]}function gM(w){return w.length>0&&w[0].path===""&&w[0].type==="update"}function TM(w){return w.length===0}function OA(w,z){if(gM(z))return q0(z[0].value);if(TM(z))return q0(w);let A=q0(w);for(let U of z)switch(U.type){case"insert":{J1.Set(A,U.path,U.value);break}case"update":{J1.Set(A,U.path,U.value);break}case"delete":{J1.Delete(A,U.path);break}}return A}function CA(...w){let[z,A,U]=w.length===3?[w[0],w[1],w[2]]:[w[0],[],w[1]],W=d1(z,A)?z4(z,A,U):U;if(!a(z,A,W))throw new i4(z,W,S1(z,A,W).First());return W}function tw(w){return r(w)&&!v(w)}class v5 extends n{constructor(w){super(w)}}function iM(w,z,A,U){if(!tw(A))J1.Set(w,z,q0(U));else{let W=Object.getOwnPropertyNames(A),$=Object.getOwnPropertyNames(U);for(let X of W)if(!$.includes(X))delete A[X];for(let X of $)if(!W.includes(X))A[X]=null;for(let X of $)o5(w,`${z}/${X}`,A[X],U[X])}}function dM(w,z,A,U){if(!v(A))J1.Set(w,z,q0(U));else{for(let W=0;W<U.length;W++)o5(w,`${z}/${W}`,A[W],U[W]);A.splice(U.length)}}function cM(w,z,A,U){if(c2(A)&&A.length===U.length)for(let W=0;W<A.length;W++)A[W]=U[W];else J1.Set(w,z,q0(U))}function nM(w,z,A,U){if(A===U)return;J1.Set(w,z,U)}function o5(w,z,A,U){if(v(U))return dM(w,z,A,U);if(c2(U))return cM(w,z,A,U);if(tw(U))return iM(w,z,A,U);if(k2(U))return nM(w,z,A,U)}function RA(w){return c2(w)||k2(w)}function hM(w,z){return tw(w)&&v(z)||v(w)&&tw(z)}function KA(w,z){if(RA(w)||RA(z))throw new v5("Only object and array types can be mutated at the root level");if(hM(w,z))throw new v5("Cannot assign due type mismatch of assignable values");o5(w,"",w,z)}class m5 extends n{constructor(w){super(w)}}var u5;(function(w){let z=new Map([["Clone",($,X,Q)=>q0(Q)],["Clean",($,X,Q)=>Tw($,X,Q)],["Default",($,X,Q)=>cw($,X,Q)],["Convert",($,X,Q)=>dw($,X,Q)],["Assert",($,X,Q)=>{return gw($,X,Q),Q}],["Decode",($,X,Q)=>d1($,X)?w4($,X,Q):Q],["Encode",($,X,Q)=>d1($,X)?z4($,X,Q):Q]]);function A($){z.delete($)}w.Delete=A;function U($,X){z.set($,X)}w.Set=U;function W($){return z.get($)}w.Get=W})(u5||(u5={}));var jA=["Clone","Clean","Default","Convert","Assert","Decode"];function tM(w,z,A,U){return w.reduce((W,$)=>{let X=u5.Get($);if(k0(X))throw new m5(`Unable to find Parse operation '${$}'`);return X(z,A,W)},U)}function FA(...w){let[z,A,U,W]=w.length===4?[w[0],w[1],w[2],w[3]]:w.length===3?v(w[0])?[w[0],w[1],[],w[2]]:[jA,w[0],w[1],w[2]]:w.length===2?[jA,w[0],[],w[1]]:(()=>{throw new m5("Invalid Arguments")})();return tM(z,A,U,W)}var p={};B6(p,{ValueErrorIterator:()=>D6,Patch:()=>OA,Parse:()=>FA,Mutate:()=>KA,Hash:()=>e1,Errors:()=>S1,Equal:()=>P6,Encode:()=>CA,Edit:()=>SA,Diff:()=>PA,Default:()=>cw,Decode:()=>LA,Create:()=>s2,Convert:()=>dw,Clone:()=>q0,Clean:()=>Tw,Check:()=>a,Cast:()=>c5,Assert:()=>gw});var yw={date:fA,time:p5(!0),"date-time":xA(!0),"iso-time":p5(!1),"iso-date-time":xA(!1),duration:/^P(?!$)((\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+S)?)?|(\d+W)?)$/,uri:sM,"uri-reference":/^(?:[a-z][a-z0-9+\-.]*:)?(?:\/?\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:]|%[0-9a-f]{2})*@)?(?:\[(?:(?:(?:(?:[0-9a-f]{1,4}:){6}|::(?:[0-9a-f]{1,4}:){5}|(?:[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){4}|(?:(?:[0-9a-f]{1,4}:){0,1}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){3}|(?:(?:[0-9a-f]{1,4}:){0,2}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){2}|(?:(?:[0-9a-f]{1,4}:){0,3}[0-9a-f]{1,4})?::[0-9a-f]{1,4}:|(?:(?:[0-9a-f]{1,4}:){0,4}[0-9a-f]{1,4})?::)(?:[0-9a-f]{1,4}:[0-9a-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?))|(?:(?:[0-9a-f]{1,4}:){0,5}[0-9a-f]{1,4})?::[0-9a-f]{1,4}|(?:(?:[0-9a-f]{1,4}:){0,6}[0-9a-f]{1,4})?::)|[Vv][0-9a-f]+\.[a-z0-9\-._~!$&'()*+,;=:]+)\]|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)|(?:[a-z0-9\-._~!$&'"()*+,;=]|%[0-9a-f]{2})*)(?::\d*)?(?:\/(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})*)*|\/(?:(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})*)*)?|(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})*)*)?(?:\?(?:[a-z0-9\-._~!$&'"()*+,;=:@/?]|%[0-9a-f]{2})*)?(?:#(?:[a-z0-9\-._~!$&'"()*+,;=:@/?]|%[0-9a-f]{2})*)?$/i,"uri-template":/^(?:(?:[^\x00-\x20"'<>%\\^`{|}]|%[0-9a-f]{2})|\{[+#./;?&=,!@|]?(?:[a-z0-9_]|%[0-9a-f]{2})+(?::[1-9][0-9]{0,3}|\*)?(?:,(?:[a-z0-9_]|%[0-9a-f]{2})+(?::[1-9][0-9]{0,3}|\*)?)*\})*$/i,url:/^(?:https?|ftp):\/\/(?:\S+(?::\S*)?@)?(?:(?!(?:10|127)(?:\.\d{1,3}){3})(?!(?:169\.254|192\.168)(?:\.\d{1,3}){2})(?!172\.(?:1[6-9]|2\d|3[0-1])(?:\.\d{1,3}){2})(?:[1-9]\d?|1\d\d|2[01]\d|22[0-3])(?:\.(?:1?\d{1,2}|2[0-4]\d|25[0-5])){2}(?:\.(?:[1-9]\d?|1\d\d|2[0-4]\d|25[0-4]))|(?:(?:[a-z0-9\u{00a1}-\u{ffff}]+-)*[a-z0-9\u{00a1}-\u{ffff}]+)(?:\.(?:[a-z0-9\u{00a1}-\u{ffff}]+-)*[a-z0-9\u{00a1}-\u{ffff}]+)*(?:\.(?:[a-z\u{00a1}-\u{ffff}]{2,})))(?::\d{2,5})?(?:\/[^\s]*)?$/iu,email:/^[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$/i,hostname:/^(?=.{1,253}\.?$)[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?(?:\.[a-z0-9](?:[-0-9a-z]{0,61}[0-9a-z])?)*\.?$/i,ipv4:/^(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)$/,ipv6:/^((([0-9a-f]{1,4}:){7}([0-9a-f]{1,4}|:))|(([0-9a-f]{1,4}:){6}(:[0-9a-f]{1,4}|((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9a-f]{1,4}:){5}(((:[0-9a-f]{1,4}){1,2})|:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9a-f]{1,4}:){4}(((:[0-9a-f]{1,4}){1,3})|((:[0-9a-f]{1,4})?:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){3}(((:[0-9a-f]{1,4}){1,4})|((:[0-9a-f]{1,4}){0,2}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){2}(((:[0-9a-f]{1,4}){1,5})|((:[0-9a-f]{1,4}){0,3}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){1}(((:[0-9a-f]{1,4}){1,6})|((:[0-9a-f]{1,4}){0,4}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(:(((:[0-9a-f]{1,4}){1,7})|((:[0-9a-f]{1,4}){0,5}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:)))$/i,regex:UH,uuid:/^(?:urn:uuid:)?[0-9a-f]{8}-(?:[0-9a-f]{4}-){3}[0-9a-f]{12}$/i,"json-pointer":/^(?:\/(?:[^~/]|~0|~1)*)*$/,"json-pointer-uri-fragment":/^#(?:\/(?:[a-z0-9_\-.!$&'()*+,;:=@]|%[0-9a-f]{2}|~0|~1)*)*$/i,"relative-json-pointer":/^(?:0|[1-9][0-9]*)(?:#|(?:\/(?:[^~/]|~0|~1)*)*)$/,byte:rM,int32:{type:"number",validate:wH},int64:{type:"number",validate:zH},float:{type:"number",validate:IA},double:{type:"number",validate:IA},password:!0,binary:!0};function yM(w){return w%4===0&&(w%100!==0||w%400===0)}var vM=/^(\d\d\d\d)-(\d\d)-(\d\d)$/,oM=[0,31,28,31,30,31,30,31,31,30,31,30,31];function fA(w){let z=vM.exec(w);if(!z)return!1;let A=+z[1],U=+z[2],W=+z[3];return U>=1&&U<=12&&W>=1&&W<=(U===2&&yM(A)?29:oM[U])}var uM=/^(\d\d):(\d\d):(\d\d(?:\.\d+)?)(z|([+-])(\d\d)(?::?(\d\d))?)?$/i;function p5(w){return function z(A){let U=uM.exec(A);if(!U)return!1;let W=+U[1],$=+U[2],X=+U[3],Q=U[4],Z=U[5]==="-"?-1:1,J=+(U[6]||0),Y=+(U[7]||0);if(J>23||Y>59||w&&!Q)return!1;if(W<=23&&$<=59&&X<60)return!0;let L=$-Y*Z,_=W-J*Z-(L<0?1:0);return(_===23||_===-1)&&(L===59||L===-1)&&X<61}}var mM=/t|\s/i;function xA(w){let z=p5(w);return function A(U){let W=U.split(mM);return W.length===2&&fA(W[0])&&z(W[1])}}var pM=/\/|:/,lM=/^(?:[a-z][a-z0-9+\-.]*:)(?:\/?\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:]|%[0-9a-f]{2})*@)?(?:\[(?:(?:(?:(?:[0-9a-f]{1,4}:){6}|::(?:[0-9a-f]{1,4}:){5}|(?:[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){4}|(?:(?:[0-9a-f]{1,4}:){0,1}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){3}|(?:(?:[0-9a-f]{1,4}:){0,2}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){2}|(?:(?:[0-9a-f]{1,4}:){0,3}[0-9a-f]{1,4})?::[0-9a-f]{1,4}:|(?:(?:[0-9a-f]{1,4}:){0,4}[0-9a-f]{1,4})?::)(?:[0-9a-f]{1,4}:[0-9a-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?))|(?:(?:[0-9a-f]{1,4}:){0,5}[0-9a-f]{1,4})?::[0-9a-f]{1,4}|(?:(?:[0-9a-f]{1,4}:){0,6}[0-9a-f]{1,4})?::)|[Vv][0-9a-f]+\.[a-z0-9\-._~!$&'()*+,;=:]+)\]|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)|(?:[a-z0-9\-._~!$&'()*+,;=]|%[0-9a-f]{2})*)(?::\d*)?(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*|\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*)?|(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*)(?:\?(?:[a-z0-9\-._~!$&'()*+,;=:@/?]|%[0-9a-f]{2})*)?(?:#(?:[a-z0-9\-._~!$&'()*+,;=:@/?]|%[0-9a-f]{2})*)?$/i;function sM(w){return pM.test(w)&&lM.test(w)}var EA=/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/gm;function rM(w){return EA.lastIndex=0,EA.test(w)}var aM=-2147483648,eM=2147483647;function wH(w){return Number.isInteger(w)&&w<=eM&&w>=aM}function zH(w){return Number.isInteger(w)}function IA(){return!0}var AH=/[^\\]\\Z/;function UH(w){if(AH.test(w))return!1;try{return new RegExp(w),!0}catch(z){return!1}}var vw="toJSON"in new Headers,A4=(w,z)=>{let A=new URL(w);return A.pathname=z,A.toString()},WH=(w)=>typeof w==="function"&&/^\s*class\s+/.test(w.toString())||w.toString().startsWith("[object ")&&w.toString()!=="[object Object]"||Q2(Object.getPrototypeOf(w)),l5=(w)=>w&&typeof w==="object"&&!Array.isArray(w),_2=(w,z,{skipKeys:A,override:U=!0}={})=>{if(!l5(w)||!l5(z))return w;for(let[W,$]of Object.entries(z)){if(A?.includes(W))continue;if(!l5($)||!(W in w)||WH($)){if(U||!(W in w))w[W]=$;continue}w[W]=_2(w[W],$,{skipKeys:A,override:U})}return w},$H=(w,z)=>{let{properties:A,...U}=w??{},{properties:W,...$}=z??{};return _2(U,$)},i0=(w=[],z=[])=>{if(!w)return[];if(!z)return w;let A=[],U=[];if(!Array.isArray(w))w=[w];if(!Array.isArray(z))z=[z];for(let W of w)if(A.push(W),W.checksum)U.push(W.checksum);for(let W of z)if(!U.includes(W.checksum))A.push(W);return A},XH=["start","request","parse","transform","resolve","beforeHandle","afterHandle","mapResponse","afterResponse","trace","error","stop","body","headers","params","query","response","type","detail"],QH=XH.reduce((w,z)=>(w[z]=!0,w),{}),VA=(w,z)=>{let A=(U)=>typeof U==="object"&&Object.keys(U).every(y4);if(A(w)&&A(z))return{...w,...z};else if(w&&!A(w)&&A(z))return{200:w,...z};return z??w},U4=(w,z)=>{return{body:z?.body??w?.body,headers:z?.headers??w?.headers,params:z?.params??w?.params,query:z?.query??w?.query,cookie:z?.cookie??w?.cookie,response:VA(w?.response,z?.response)}},r2=(w,z)=>{let{resolve:A,...U}=w??{},{resolve:W,...$}=z??{};return{...U,...$,body:z?.body??w?.body,headers:z?.headers??w?.headers,params:z?.params??w?.params,query:z?.query??w?.query,cookie:z?.cookie??w?.cookie,response:VA(w?.response,z?.response),type:w?.type||z?.type,detail:_2(z?.detail??{},w?.detail??{}),parse:i0(w?.parse,z?.parse),transform:i0(w?.transform,z?.transform),beforeHandle:i0(i0(r0(A,"resolve"),w?.beforeHandle),i0(r0(W,"resolve"),z?.beforeHandle)),afterHandle:i0(w?.afterHandle,z?.afterHandle),mapResponse:i0(w?.mapResponse,z?.mapResponse),afterResponse:i0(w?.afterResponse,z?.afterResponse),trace:i0(w?.trace,z?.trace),error:i0(w?.error,z?.error)}},t4=(w,z,A=!0)=>{if(!Array.isArray(z))return B2(w,z,A);for(let U of z)w=B2(w,U,A);return w},B2=(w,z,A=!0)=>{if(!w)return w;if(z.untilObjectFound&&!A&&w.type==="object")return w;let U=z.from[b];if(w.oneOf){for(let X=0;X<w.oneOf.length;X++)w.oneOf[X]=B2(w.oneOf[X],z,A);return w}if(w.anyOf){for(let X=0;X<w.anyOf.length;X++)w.anyOf[X]=B2(w.anyOf[X],z,A);return w}if(w.allOf){for(let X=0;X<w.allOf.length;X++)w.allOf[X]=B2(w.allOf[X],z,A);return w}if(w.not){for(let X=0;X<w.not.length;X++)w.not[X]=B2(w.not[X],z,A);return w}let W=A&&!!z.excludeRoot;if(w[b]===U){let{anyOf:X,oneOf:Q,allOf:Z,not:J,properties:Y,items:L,..._}=w,G=z.to(_),O,C=(q)=>{if(Y&&q.type==="object"){let W0={};for(let[L0,c]of Object.entries(Y))W0[L0]=B2(c,z,!1);return{..._,...q,properties:W0}}if(L&&q.type==="array")return{..._,...q,items:B2(L,z,!1)};let o={..._,...q};if(delete o.required,Y&&q.type==="string"&&q.format==="ObjectString"&&q.default==="{}")O=x.ObjectString(Y,_),o.default=JSON.stringify(p.Create(x.Object(Y))),o.properties=Y;if(L&&q.type==="string"&&q.format==="ArrayString"&&q.default==="[]")O=x.ArrayString(L,_),o.default=JSON.stringify(p.Create(x.Array(L))),o.items=L;return o};if(W){if(Y){let q={};for(let[o,W0]of Object.entries(Y))q[o]=B2(W0,z,!1);return{..._,properties:q}}else if(L?.map)return{..._,items:L.map((q)=>B2(q,z,!1))};return _}if(G.anyOf)for(let q=0;q<G.anyOf.length;q++)G.anyOf[q]=C(G.anyOf[q]);else if(G.oneOf)for(let q=0;q<G.oneOf.length;q++)G.oneOf[q]=C(G.oneOf[q]);else if(G.allOf)for(let q=0;q<G.allOf.length;q++)G.allOf[q]=C(G.allOf[q]);else if(G.not)for(let q=0;q<G.not.length;q++)G.not[q]=C(G.not[q]);if(O)G[j0]=O[j0];if(G.anyOf||G.oneOf||G.allOf||G.not)return G;if(Y){let q={};for(let[o,W0]of Object.entries(Y))q[o]=B2(W0,z,!1);return{..._,...G,properties:q}}else if(L?.map)return{..._,...G,items:L.map((q)=>B2(q,z,!1))};return{..._,...G}}let $=w?.properties;if($&&A&&z.rootOnly!==!0)for(let[X,Q]of Object.entries($))switch(Q[b]){case U:let{anyOf:Z,oneOf:J,allOf:Y,not:L,type:_,...G}=Q,O=z.to(G);if(O.anyOf)for(let C=0;C<O.anyOf.length;C++)O.anyOf[C]={...G,...O.anyOf[C]};else if(O.oneOf)for(let C=0;C<O.oneOf.length;C++)O.oneOf[C]={...G,...O.oneOf[C]};else if(O.allOf)for(let C=0;C<O.allOf.length;C++)O.allOf[C]={...G,...O.allOf[C]};else if(O.not)for(let C=0;C<O.not.length;C++)O.not[C]={...G,...O.not[C]};$[X]={...G,...B2(G,z,!1)};break;case"Object":case"Union":$[X]=B2(Q,z,!1);break;default:if(Q.items)for(let C=0;C<Q.items.length;C++)Q.items[C]=B2(Q.items[C],z,!1);else if(Q.anyOf||Q.oneOf||Q.allOf||Q.not)$[X]=B2(Q,z,!1);break}return w},h4=(w)=>(z)=>{if(typeof z==="object")try{return p.Clean(w,structuredClone(z))}catch{try{return p.Clean(w,z)}catch{return z}}return z},$2=(w,{models:z={},dynamic:A=!1,modules:U,normalize:W=!1,additionalProperties:$=!1,coerce:X=!1,additionalCoerce:Q=[]}={modules:x.Module({})})=>{if(!w)return;if(typeof w==="string"&&!(w in z))return;let Z=typeof w==="string"?U.Import(w)??z[w]:w;if(X||Q)if(X)Z=t4(Z,[{from:x.Ref(""),to:(Y)=>U.Import(Y.$ref)},{from:x.Number(),to:(Y)=>x.Numeric(Y),untilObjectFound:!0},{from:x.Boolean(),to:(Y)=>x.BooleanString(Y),untilObjectFound:!0},...Array.isArray(Q)?Q:[Q]]);else Z=t4(Z,[{from:x.Ref(""),to:(Y)=>U.Import(Y.$ref)},...Array.isArray(Q)?Q:[Q]]);if(Z.type==="object"&&"additionalProperties"in Z===!1)Z.additionalProperties=$;if(A){let Y={schema:Z,references:"",checkFunc:()=>{},code:"",Check:(L)=>p.Check(Z,L),Errors:(L)=>p.Errors(Z,L),Code:()=>"",Clean:h4(Z),Decode:(L)=>p.Decode(Z,L),Encode:(L)=>p.Encode(Z,L)};if(W&&Z.additionalProperties===!1)Y.Clean=h4(Z);if(Z.config){if(Y.config=Z.config,Y?.schema?.config)delete Y.schema.config}return Y.parse=(L)=>{try{return Y.Decode(L)}catch(_){throw[...Y.Errors(L)].map(i2)}},Y.safeParse=(L)=>{try{return{success:!0,data:Y.Decode(L),error:null}}catch(_){let G=[...J.Errors(L)].map(i2);return{success:!1,data:null,error:G[0]?.summary,errors:G}}},Y}let J=w6.Compile(Z,Object.values(z));if(J.Clean=h4(Z),Z.config){if(J.config=Z.config,J?.schema?.config)delete J.schema.config}return J.parse=(Y)=>{try{return J.Decode(Y)}catch(L){throw[...J.Errors(Y)].map(i2)}},J.safeParse=(Y)=>{try{return{success:!0,data:J.Decode(Y),error:null}}catch(L){let _=[...J.Errors(Y)].map(i2);return{success:!1,data:null,error:_[0]?.summary,errors:_}}},J},ow=(w,{models:z={},modules:A,dynamic:U=!1,normalize:W=!1,additionalProperties:$=!1})=>{if(!w)return;if(typeof w==="string"&&!(w in z))return;let X=typeof w==="string"?A.Import(w)??z[w]:w,Q=(J,Y)=>{if(U)return{schema:J,references:"",checkFunc:()=>{},code:"",Check:(_)=>p.Check(J,_),Errors:(_)=>p.Errors(J,_),Code:()=>"",Clean:h4(J),Decode:(_)=>p.Decode(J,_),Encode:(_)=>p.Encode(J,_)};let L=w6.Compile(J,Y);if(W&&J.additionalProperties===!1)L.Clean=h4(J);return L};if(b in X){if("additionalProperties"in X===!1)X.additionalProperties=$;return{200:Q(X,Object.values(z))}}let Z={};return Object.keys(X).forEach((J)=>{let Y=X[+J];if(typeof Y==="string"){if(Y in z){let L=z[Y];L.type==="object"&&"additionalProperties"in L,Z[+J]=b in L?Q(L,Object.values(z)):L}return}if(Y.type==="object"&&"additionalProperties"in Y===!1)Y.additionalProperties=$;Z[+J]=b in Y?Q(Y,Object.values(z)):Y}),Z},ZH=typeof Bun!=="undefined",JH=ZH&&typeof Bun.hash==="function",O6=(w)=>{if(JH)return Bun.hash(w);let z=9;for(let A=0;A<w.length;)z=Math.imul(z^w.charCodeAt(A++),387420489);return z=z^z>>>9},s5,A6=()=>{if(!s5)s5=[{from:x.Object({}),to:()=>x.ObjectString({}),excludeRoot:!0},{from:x.Array(x.Any()),to:()=>x.ArrayString(x.Any())}];return s5},r5,a5=()=>{if(!r5)r5=[{from:x.Number(),to:(w)=>x.Numeric(w),rootOnly:!0},{from:x.Boolean(),to:(w)=>x.BooleanString(w),rootOnly:!0}];return r5},uw=({validator:w,modules:z,defaultConfig:A={},config:U,dynamic:W,models:$})=>{let X=$2(w,{modules:z,dynamic:W,models:$,additionalProperties:!0,coerce:!0,additionalCoerce:A6()});if(Q2(A))if(X)X.config=$H(X.config,U);else X=$2(x.Cookie({}),{modules:z,dynamic:W,models:$,additionalProperties:!0}),X.config=A;return X},Y1=(w,z)=>{if(!z)return;if(!Array.isArray(z)){let U=z;if(w&&!U.checksum)U.checksum=w;if(U.scope==="scoped")U.scope="local";return U}let A=[...z];for(let U of A){if(w&&!U.checksum)U.checksum=w;if(U.scope==="scoped")U.scope="local"}return A},e5=(w,z,A)=>{return{start:i0(w.start,Y1(A,z?.start)),request:i0(w.request,Y1(A,z?.request)),parse:i0(w.parse,Y1(A,z?.parse)),transform:i0(w.transform,Y1(A,z?.transform)),beforeHandle:i0(i0(r0(w.resolve,"resolve"),w.beforeHandle),Y1(A,i0(r0(z?.resolve,"resolve"),z?.beforeHandle))),afterHandle:i0(w.afterHandle,Y1(A,z?.afterHandle)),mapResponse:i0(w.mapResponse,Y1(A,z?.mapResponse)),afterResponse:i0(w.afterResponse,Y1(A,z?.afterResponse)),trace:i0(w.trace,Y1(A,z?.trace)),error:i0(w.error,Y1(A,z?.error)),stop:i0(w.stop,Y1(A,z?.stop))}},gA=(w,z,{skipIfHasType:A=!1}={})=>{if(!w)return w;if(!Array.isArray(w)){if(A)w.scope??=z;else w.scope=z;return w}for(let U of w)if(A)U.scope??=z;else U.scope=z;return w},z6=(w)=>{if(!w)return w;if(!Array.isArray(w))switch(w.scope){case"global":case"scoped":return{...w};default:return{fn:w}}let z=[];for(let A of w)switch(A.scope){case"global":case"scoped":z.push({...A});break}return z},wz=(w)=>{return{...w,type:w?.type,detail:w?.detail,parse:z6(w?.parse),transform:z6(w?.transform),beforeHandle:z6(w?.beforeHandle),afterHandle:z6(w?.afterHandle),mapResponse:z6(w?.mapResponse),afterResponse:z6(w?.afterResponse),error:z6(w?.error),trace:z6(w?.trace)}},U6={Continue:100,"Switching Protocols":101,Processing:102,"Early Hints":103,OK:200,Created:201,Accepted:202,"Non-Authoritative Information":203,"No Content":204,"Reset Content":205,"Partial Content":206,"Multi-Status":207,"Already Reported":208,"Multiple Choices":300,"Moved Permanently":301,Found:302,"See Other":303,"Not Modified":304,"Temporary Redirect":307,"Permanent Redirect":308,"Bad Request":400,Unauthorized:401,"Payment Required":402,Forbidden:403,"Not Found":404,"Method Not Allowed":405,"Not Acceptable":406,"Proxy Authentication Required":407,"Request Timeout":408,Conflict:409,Gone:410,"Length Required":411,"Precondition Failed":412,"Payload Too Large":413,"URI Too Long":414,"Unsupported Media Type":415,"Range Not Satisfiable":416,"Expectation Failed":417,"I'm a teapot":418,"Misdirected Request":421,"Unprocessable Content":422,Locked:423,"Failed Dependency":424,"Too Early":425,"Upgrade Required":426,"Precondition Required":428,"Too Many Requests":429,"Request Header Fields Too Large":431,"Unavailable For Legal Reasons":451,"Internal Server Error":500,"Not Implemented":501,"Bad Gateway":502,"Service Unavailable":503,"Gateway Timeout":504,"HTTP Version Not Supported":505,"Variant Also Negotiates":506,"Insufficient Storage":507,"Loop Detected":508,"Not Extended":510,"Network Authentication Required":511},mw=Object.fromEntries(Object.entries(U6).map(([w,z])=>[z,w]));function YH(w){let z=w;while(z.endsWith("="))z=z.slice(0,-1);return z}var kA=new TextEncoder,W4=async(w,z)=>{if(typeof w!=="string")throw new TypeError("Cookie value must be provided as a string.");if(z===null)throw new TypeError("Secret key must be provided.");let A=await crypto.subtle.importKey("raw",kA.encode(z),{name:"HMAC",hash:"SHA-256"},!1,["sign"]),U=await crypto.subtle.sign("HMAC",A,kA.encode(w));return w+"."+YH(Buffer.from(U).toString("base64"))},zz=async(w,z)=>{if(typeof w!=="string")throw new TypeError("Signed cookie string must be provided.");if(z===null)throw new TypeError("Secret key must be provided.");let A=w.slice(0,w.lastIndexOf("."));return await W4(A,z)===w?A:!1},TA=(w,z,A)=>{if(!w||typeof w!=="object"||!z)return;for(let[U,W]of Object.entries(z)){if(U in QH||!(U in w))continue;let $=w[U];if(typeof $==="function"){let X=$(W);if(typeof X==="object")for(let[Q,Z]of Object.entries(X))A(Q)({fn:Z});delete z[U]}}},iA=({globalHook:w,localHook:z})=>(A)=>(U,W)=>{if(typeof U==="function")U={fn:U};if(A==="resolve")U={...U,subType:"resolve"};if("fn"in U||Array.isArray(U)){if(!z[A])z[A]=[];if(typeof z[A]==="function")z[A]=[z[A]];if(Array.isArray(U))z[A]=z[A].concat(U);else z[A].push(U);return}let{insert:$="after",stack:X="local"}=U;if(typeof W==="function")W={fn:W};if(X==="global")if(!Array.isArray(W))if($==="before")w[A].unshift(W);else w[A].push(W);else if($==="before")w[A]=W.concat(w[A]);else w[A]=w[A].concat(W);else{if(!z[A])z[A]=[];if(typeof z[A]==="function")z[A]=[z[A]];if(!Array.isArray(W))if($==="before")z[A].unshift(W);else z[A].push(W);else if($==="before")z[A]=W.concat(z[A]);else z[A]=z[A].concat(W)}},qH=(w)=>{if(typeof w==="number")return w;if(w.length<16){if(w.trim().length===0)return null;let z=Number(w);if(Number.isNaN(z))return null;return z}if(w.length===16){if(w.trim().length===0)return null;let z=Number(w);if(Number.isNaN(z)||z.toString()!==w)return null;return z}return null},y4=(w)=>qH(w)!==null;class Az{constructor(w=console.error){this.onError=w,this.root=null,this.promises=[]}get size(){return this.promises.length}add(w){return this.promises.push(w),this.root||=this.drain(),w}async drain(){while(this.promises.length>0){try{await this.promises[0]}catch(w){this.onError(w)}this.promises.shift()}this.root=null}then(w,z){return(this.root??Promise.resolve()).then(w,z)}}var r0=(w,z)=>{if(!w)return w;if(!Array.isArray(w)){if(typeof w==="function"||typeof w==="string")return z?{fn:w,subType:z}:{fn:w};else if("fn"in w)return w}let A=[];for(let U of w)if(typeof U==="function"||typeof U==="string")A.push(z?{fn:U,subType:z}:{fn:U});else if("fn"in U)A.push(U);return A},dA=(w)=>{return{...w,start:r0(w?.start),request:r0(w?.request),parse:r0(w?.parse),transform:r0(w?.transform),beforeHandle:r0(w?.beforeHandle),afterHandle:r0(w?.afterHandle),mapResponse:r0(w?.mapResponse),afterResponse:r0(w?.afterResponse),trace:r0(w?.trace),error:r0(w?.error),stop:r0(w?.stop)}},Uz=(w)=>{return{...w,start:w.start?.map((z)=>z.fn),request:w.request?.map((z)=>z.fn),parse:w.parse?.map((z)=>z.fn),transform:w.transform?.map((z)=>z.fn),beforeHandle:w.beforeHandle?.map((z)=>z.fn),afterHandle:w.afterHandle?.map((z)=>z.fn),afterResponse:w.afterResponse?.map((z)=>z.fn),mapResponse:w.mapResponse?.map((z)=>z.fn),trace:w.trace?.map((z)=>z.fn),error:w.error?.map((z)=>z.fn),stop:w.stop?.map((z)=>z.fn)}},v4=(w)=>({body:w.body,cookie:w.cookie,headers:w.headers,query:w.query,set:w.set,server:w.server,request:w.request,route:w.route}),o4=(w,z=302)=>Response.redirect(w,z),BH=Symbol("ElysiaFormData"),C6=Symbol("ElysiaRequestId");var pw=()=>{let w=crypto.randomUUID();return w.slice(0,8)+w.slice(24,32)},lw=(w)=>{let z=[];for(let A=0;A<w.length;A++){let U=w[A];if(U.checksum){if(z.includes(U.checksum))w.splice(A,1),A--;z.push(U.checksum)}}return w},X2=(w,z="scoped")=>{if(z==="scoped"){for(let A of w)if("scope"in A&&A.scope==="local")A.scope="scoped";return}for(let A of w)if("scope"in A)A.scope="global"},h1=(w)=>{if(w.charCodeAt(w.length-1)===47)return w.slice(0,w.length-1);return w+"/"},Q2=(w)=>{if(!w)return!1;for(let z in w)return!0;return!1};var cA=typeof Bun!=="undefined"?Bun.env:typeof process!=="undefined"?process?.env:void 0,R6=Symbol("ElysiaErrorCode"),u4=(cA?.NODE_ENV??cA?.ENV)==="production";class I2{constructor(w,z){let A=z??(w in mw?mw[w]:w);this.code=U6[w]??w,this.response=A}}var Wz=(w,z)=>new I2(w,z);class sw extends Error{constructor(w){super(w??"INTERNAL_SERVER_ERROR");this.code="INTERNAL_SERVER_ERROR",this.status=500}}class K6 extends Error{constructor(w){super(w??"NOT_FOUND");this.code="NOT_FOUND",this.status=404}}class rw extends Error{constructor(){super("Bad Request");this.code="PARSE",this.status=400}}class m4 extends Error{constructor(w,z){super(z??`"${w}" has invalid cookie signature`);this.key=w,this.code="INVALID_COOKIE_SIGNATURE",this.status=400}}var i2=(w)=>{if(!w)return{summary:void 0};let{message:z,path:A,value:U,type:W}=w,$=A.slice(1).replaceAll("/","."),X=A==="";switch(W){case 42:return{...w,summary:X?"Value should not be provided":`Property '${$}' should not be provided`};case 45:return{...w,summary:X?"Value is missing":`Property '${$}' is missing`};case 50:let Q=z.indexOf("'"),Z=z.slice(Q+1,z.indexOf("'",Q+1));return{...w,summary:X?"Value should be an email":`Property '${$}' should be ${Z}`};case 54:return{...w,summary:`${z.slice(0,9)} property '${$}' to be ${z.slice(8)} but found: ${U}`};case 62:let J=w.schema.anyOf.map((Y)=>`'${Y?.format??Y.type}'`).join(", ");return{...w,summary:X?`Value should be one of ${J}`:`Property '${$}' should be one of: ${J}`};default:return{summary:z,...w}}};class m extends Error{constructor(w,z,A){if(A&&typeof A==="object"&&A instanceof I2)A=A.response;let U=u4?void 0:("Errors"in z)?z.Errors(A).First():p.Errors(z,A).First(),W=U.schema.message||U?.schema.error!==void 0?typeof U.schema.error==="function"?U.schema.error({type:w,validator:z,value:A,get errors(){return[...z.Errors(A)].map(i2)}}):U.schema.error:void 0,$=U?.path||"root",X="";if(W!==void 0)X=typeof W==="object"?JSON.stringify(W):W+"";else if(u4)X=JSON.stringify({type:"validation",on:w,summary:i2(U).summary,message:U?.message,found:A});else{let Q=z?.schema??z,Z="Errors"in z?[...z.Errors(A)].map(i2):[...p.Errors(z,A)].map(i2),J;try{J=p.Create(Q)}catch(Y){J={type:"Could not create expected value",message:Y?.message,error:Y}}X=JSON.stringify({type:"validation",on:w,summary:i2(U).summary,property:$,message:U?.message,expected:J,found:A,errors:Z},null,2)}super(X);this.type=w,this.validator=z,this.value=A,this.code="VALIDATION",this.status=422,Object.setPrototypeOf(this,m.prototype)}get all(){return"Errors"in this.validator?[...this.validator.Errors(this.value)].map(i2):[...p.Errors(this.validator,this.value)].map(i2)}static simplifyModel(w){let z="schema"in w?w.schema:w;try{return p.Create(z)}catch{return z}}get model(){return m.simplifyModel(this.validator)}toResponse(w){return new Response(this.message,{status:400,headers:{...w,"content-type":"application/json"}})}}var hA=/(\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d:[0-5]\d\.\d+([+-][0-2]\d:[0-5]\d|Z))|(\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d:[0-5]\d([+-][0-2]\d:[0-5]\d|Z))|(\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d([+-][0-2]\d:[0-5]\d|Z))/,tA=/(?:Sun|Mon|Tue|Wed|Thu|Fri|Sat)\s(?:Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)\s\d{2}\s\d{4}\s\d{2}:\d{2}:\d{2}\sGMT(?:\+|-)\d{4}\s\([^)]+\)/,yA=/^(?:(?:(?:(?:0?[1-9]|[12][0-9]|3[01])[/\s-](?:0?[1-9]|1[0-2])[/\s-](?:19|20)\d{2})|(?:(?:19|20)\d{2}[/\s-](?:0?[1-9]|1[0-2])[/\s-](?:0?[1-9]|[12][0-9]|3[01]))))(?:\s(?:1[012]|0?[1-9]):[0-5][0-9](?::[0-5][0-9])?(?:\s[AP]M)?)?$/,MH=yw.date,HH=yw["date-time"];if(!O0.Has("date"))T1.Format("date",(w)=>{let z=w.replace(/"/g,"");if(hA.test(z)||tA.test(z)||yA.test(z)||MH(z)){let A=new Date(z);if(!Number.isNaN(A.getTime()))return!0}return!1});if(!O0.Has("date-time"))T1.Format("date-time",(w)=>{let z=w.replace(/"/g,"");if(hA.test(z)||tA.test(z)||yA.test(z)||HH(z)){let A=new Date(z);if(!Number.isNaN(A.getTime()))return!0}return!1});Object.entries(yw).forEach((w)=>{let[z,A]=w;if(!O0.Has(z)){if(A instanceof RegExp)T1.Format(z,(U)=>A.test(U));else if(typeof A==="function")T1.Format(z,A)}});var x=Object.assign({},S6),nA=(w)=>{if(typeof w==="string")switch(w.slice(-1)){case"k":return+w.slice(0,w.length-1)*1024;case"m":return+w.slice(0,w.length-1)*1048576;default:return+w}return w},$z=(w,z)=>{if(!(z instanceof Blob))return!1;if(w.minSize&&z.size<nA(w.minSize))return!1;if(w.maxSize&&z.size>nA(w.maxSize))return!1;if(w.extension)if(typeof w.extension==="string"){if(!z.type.startsWith(w.extension))return!1}else{for(let A=0;A<w.extension.length;A++)if(z.type.startsWith(w.extension[A]))return!0;return!1}return!0},GH=c0.Get("Files")??T1.Type("File",$z),LH=c0.Get("Files")??T1.Type("Files",(w,z)=>{if(!Array.isArray(z))return $z(w,z);if(w.minItems&&z.length<w.minItems)return!1;if(w.maxItems&&z.length>w.maxItems)return!1;for(let A=0;A<z.length;A++)if(!$z(w,z[A]))return!1;return!0});if(!O0.Has("numeric"))O0.Set("numeric",(w)=>!!w&&!isNaN(+w));if(!O0.Has("integer"))O0.Set("integer",(w)=>!!w&&Number.isInteger(+w));if(!O0.Has("boolean"))O0.Set("boolean",(w)=>w==="true"||w==="false");if(!O0.Has("ObjectString"))O0.Set("ObjectString",(w)=>{let z=w.charCodeAt(0);if(z===9||z===10||z===32)z=w.trimStart().charCodeAt(0);if(z!==123&&z!==91)return!1;try{return JSON.parse(w),!0}catch{return!1}});if(!O0.Has("ArrayString"))O0.Set("ArrayString",(w)=>{let z=w.charCodeAt(0);if(z===9||z===10||z===32)z=w.trimStart().charCodeAt(0);if(z!==123&&z!==91)return!1;try{return JSON.parse(w),!0}catch{return!1}});c0.Set("UnionEnum",(w,z)=>{return(typeof z==="number"||typeof z==="string"||z===null)&&w.enum.includes(z)});var a2={Numeric:(w)=>{let z=S6.Number(w);return x.Transform(x.Union([x.String({format:"numeric",default:0}),x.Number(w)],w)).Decode((A)=>{let U=+A;if(isNaN(U))return A;if(w&&!p.Check(z,U))throw new m("property",z,U);return U}).Encode((A)=>A)},Integer:(w)=>{let z=S6.Integer(w);return x.Transform(x.Union([x.String({format:"integer",default:0}),x.Number(w)],w)).Decode((A)=>{let U=+A;if(!p.Check(z,U))throw new m("property",z,U);return U}).Encode((A)=>A)},Date:(w)=>{let z=S6.Date(w);return x.Transform(x.Union([S6.Date(w),x.String({format:"date",default:new Date().toISOString()}),x.String({format:"date-time",default:new Date().toISOString()}),x.Number()],w)).Decode((A)=>{if(typeof A==="number"){let W=new Date(A);if(!p.Check(z,W))throw new m("property",z,W);return W}if(A instanceof Date)return A;let U=new Date(A);if(!p.Check(z,U))throw new m("property",z,U);return U}).Encode((A)=>{if(typeof A==="string")return new Date(A);return A})},BooleanString:(w)=>{let z=S6.Boolean(w);return x.Transform(x.Union([x.Boolean(w),x.String({format:"boolean",default:!1})],w)).Decode((A)=>{if(typeof A==="string")return A==="true";if(A!==void 0&&!p.Check(z,A))throw new m("property",z,A);return A}).Encode((A)=>A)},ObjectString:(w,z)=>{let A=x.Object(w,z),U=JSON.stringify(p.Create(A)),W;try{W=w6.Compile(A)}catch{}return x.Transform(x.Union([x.String({format:"ObjectString",default:U}),A])).Decode(($)=>{if(typeof $==="string"){if($.charCodeAt(0)!==123)throw new m("property",A,$);try{$=JSON.parse($)}catch{throw new m("property",A,$)}if(W){if(!W.Check($))throw new m("property",A,$);return W.Decode($)}if(!p.Check(A,$))throw new m("property",A,$);return p.Decode(A,$)}return $}).Encode(($)=>{if(typeof $==="string")try{$=JSON.parse($)}catch{throw new m("property",A,$)}if(!p.Check(A,$))throw new m("property",A,$);return JSON.stringify($)})},ArrayString:(w={},z)=>{let A=x.Array(w,z),U=JSON.stringify(p.Create(A)),W;try{W=w6.Compile(A)}catch{}return x.Transform(x.Union([x.String({format:"ArrayString",default:U}),A])).Decode(($)=>{if(typeof $==="string"){if($.charCodeAt(0)!==91)throw new m("property",A,$);try{$=JSON.parse($)}catch{throw new m("property",A,$)}if(W){if(!W.Check($))throw new m("property",A,$);return W.Decode($)}if(!p.Check(A,$))throw new m("property",A,$);return p.Decode(A,$)}return $}).Encode(($)=>{if(typeof $==="string")try{$=JSON.parse($)}catch{throw new m("property",A,$)}if(!p.Check(A,$))throw new m("property",A,$);return JSON.stringify($)})},File:GH,Files:(w={})=>x.Transform(LH(w)).Decode((z)=>{if(Array.isArray(z))return z;return[z]}).Encode((z)=>z),Nullable:(w)=>x.Union([w,x.Null()]),MaybeEmpty:(w)=>x.Union([w,x.Null(),x.Undefined()]),Cookie:(w,{domain:z,expires:A,httpOnly:U,maxAge:W,path:$,priority:X,sameSite:Q,secure:Z,secrets:J,sign:Y,...L}={})=>{let _=x.Object(w,L);return _.config={domain:z,expires:A,httpOnly:U,maxAge:W,path:$,priority:X,sameSite:Q,secure:Z,secrets:J,sign:Y},_},UnionEnum:(w,z={})=>{let A=w.every((U)=>typeof U==="string")?{type:"string"}:w.every((U)=>typeof U==="number")?{type:"number"}:w.every((U)=>U===null)?{type:"null"}:{};if(w.some((U)=>typeof U==="object"&&U!==null))throw new Error("This type does not support objects or arrays");return{default:w[0],...z,[b]:"UnionEnum",...A,enum:w}}};x.BooleanString=a2.BooleanString;x.ObjectString=a2.ObjectString;x.ArrayString=a2.ArrayString;x.Numeric=a2.Numeric;x.Integer=a2.Integer;x.File=(w={})=>a2.File({default:"File",...w,extension:w?.type,type:"string",format:"binary"});x.Files=(w={})=>a2.Files({...w,elysiaMeta:"Files",default:"Files",extension:w?.type,type:"array",items:{...w,default:"Files",type:"string",format:"binary"}});x.Nullable=(w)=>a2.Nullable(w);x.MaybeEmpty=a2.MaybeEmpty;x.Cookie=a2.Cookie;x.Date=a2.Date;x.UnionEnum=a2.UnionEnum;var $4=(w)=>{let z=typeof w==="object"?w.fn.toString():typeof w==="string"?w.toString():w,A=z.indexOf(")");if(z.charCodeAt(A+2)===61&&z.charCodeAt(A+5)!==123)return!0;return z.includes("return")},bH=(w)=>{if(w.startsWith("async"))w=w.slice(5);w=w.trimStart();let z=-1;if(w.charCodeAt(0)===40){if(z=w.indexOf("=>",w.indexOf(")")),z!==-1){let W=z;while(W>0)if(w.charCodeAt(--W)===41)break;let $=w.slice(z+2);if($.charCodeAt(0)===32)$=$.trimStart();return[w.slice(1,W),$,{isArrowReturn:$.charCodeAt(0)!==123}]}}if(/^(\w+)=>/g.test(w)){if(z=w.indexOf("=>"),z!==-1){let W=w.slice(z+2);if(W.charCodeAt(0)===32)W=W.trimStart();return[w.slice(0,z),W,{isArrowReturn:W.charCodeAt(0)!==123}]}}if(w.startsWith("function")){z=w.indexOf("(");let W=w.indexOf(")");return[w.slice(z+1,W),w.slice(W+2),{isArrowReturn:!1}]}let A=w.indexOf("(");if(A!==-1){let W=w.indexOf(`
7
- `,2),$=w.slice(0,W),X=$.lastIndexOf(")")+1,Q=w.slice(W+1);return[$.slice(A,X),"{"+Q,{isArrowReturn:!1}]}let U=w.split(`
8
- `,2);return[U[0],U[1],{isArrowReturn:!1}]},NH=(w)=>{let z=w.indexOf("{");if(z===-1)return[-1,0];let A=z+1,U=1;for(;A<w.length;A++){let W=w.charCodeAt(A);if(W===123)U++;else if(W===125)U--;if(U===0)break}if(U!==0)return[0,w.length];return[z,A+1]},SH=(w)=>{let z=w.lastIndexOf("}");if(z===-1)return[-1,0];let A=z-1,U=1;for(;A>=0;A--){let W=w.charCodeAt(A);if(W===125)U++;else if(W===123)U--;if(U===0)break}if(U!==0)return[-1,0];return[A,z+1]},oA=(w)=>{while(!0){let z=w.indexOf(":");if(z===-1)break;let A=w.indexOf(",",z);if(A===-1)A=w.indexOf("}",z)-1;if(A===-2)A=w.length;w=w.slice(0,z)+w.slice(A)}return w},uA=(w)=>{let z=!1;if(w.charCodeAt(0)===40)w=w.slice(1,-1);if(w.charCodeAt(0)===123)z=!0,w=w.slice(1,-1);w=w.replace(/( |\t|\n)/g,"").trim();let A=[];while(!0){let[W,$]=NH(w);if(W===-1)break;if(A.push(w.slice(0,W-1)),w.charCodeAt($)===44)$++;w=w.slice($)}if(w=oA(w),w)A=A.concat(w.split(","));let U=[];for(let W of A){if(W.indexOf(",")===-1){U.push(W);continue}for(let $ of W.split(","))U.push($.trim())}return A=U,{hasParenthesis:z,parameters:A}},DH=(w,z)=>{let{parameters:A,hasParenthesis:U}=uA(w);if(!z.query&&A.includes("query"))z.query=!0;if(!z.headers&&A.includes("headers"))z.headers=!0;if(!z.body&&A.includes("body"))z.body=!0;if(!z.cookie&&A.includes("cookie"))z.cookie=!0;if(!z.set&&A.includes("set"))z.set=!0;if(!z.server&&A.includes("server"))z.server=!0;if(!z.request&&A.includes("request"))z.request=!0;if(!z.route&&A.includes("route"))z.route=!0;if(U)return`{ ${A.join(", ")} }`;return A.join(", ")},vA=(w,z,A)=>{let U=z.indexOf(w+`
9
- `,A),W=z.indexOf(w+"\t",A),$=z.indexOf(w+",",A),X=z.indexOf(w+";",A),Q=z.indexOf(w+" ",A);return[U,W,$,X,Q].filter((Z)=>Z>0).sort((Z,J)=>Z-J)[0]||-1};var mA=(w,z,A=0)=>{if(A>5)return[];let U=[],W=z;while(!0){let $=vA(" = "+w,W);if($===-1)$=vA("="+w,W);if($===-1){let J=W.indexOf(" = "+w);if(J===-1)J=W.indexOf("="+w);if(J+3+w.length!==W.length)break;$=J}let X=W.slice(0,$),Q=X.lastIndexOf(" "),Z=X.slice(Q!==-1?Q+1:-1);if(Z==="}"){let[J,Y]=SH(X);U.push(oA(W.slice(J,Y))),W=W.slice($+3+w.length);continue}while(Z.charCodeAt(0)===44)Z=Z.slice(1);while(Z.charCodeAt(0)===9)Z=Z.slice(1);if(!Z.includes("("))U.push(Z);W=W.slice($+3+w.length)}for(let $ of U){if($.charCodeAt(0)===123)continue;let X=mA($,z);if(X.length>0)U.push(...X)}return U},_H=(w)=>{if(!w)return;if(w.charCodeAt(0)!==123)return w;if(w=w.slice(2,-2),!w.includes(",")){if(w.includes("..."))return w.slice(w.indexOf("...")+3);return}let A=w.indexOf("...");if(A===-1)return;return w.slice(A+3).trimEnd()},PH=(w,z,A)=>{let U=(W,$)=>w.includes($+"."+W)||w.includes($+'["'+W+'"]')||w.includes($+"['"+W+"']");for(let W of z){if(!W)continue;if(W.charCodeAt(0)===123){let $=uA(W).parameters;if(!A.query&&$.includes("query"))A.query=!0;if(!A.headers&&$.includes("headers"))A.headers=!0;if(!A.body&&$.includes("body"))A.body=!0;if(!A.cookie&&$.includes("cookie"))A.cookie=!0;if(!A.set&&$.includes("set"))A.set=!0;if(!A.query&&$.includes("server"))A.server=!0;if(!A.request&&$.includes("request"))A.request=!0;if(!A.route&&$.includes("route"))A.route=!0;continue}if(!A.query&&U("query",W))A.query=!0;if(w.includes("return "+W)||w.includes("return "+W+".query"))A.query=!0;if(!A.headers&&U("headers",W))A.headers=!0;if(!A.body&&U("body",W))A.body=!0;if(!A.cookie&&U("cookie",W))A.cookie=!0;if(!A.set&&U("set",W))A.set=!0;if(!A.server&&U("server",W))A.server=!0;if(A.query&&A.headers&&A.body&&A.cookie&&A.set&&A.server&&A.server&&A.route)break}return z};var OH=(w,z,A)=>{try{let U=new RegExp(`(?:\\w)\\((?:.*)?${w}`,"gs");U.test(z);let W=z.charCodeAt(U.lastIndex);if(W===41||W===44)return A.query=!0,A.headers=!0,A.body=!0,A.cookie=!0,A.set=!0,A.server=!0,A.route=!0,A.request=!0,!0;return!1}catch(U){return console.log("[Sucrose] warning: unexpected isContextPassToFunction error, you may continue development as usual but please report the following to maintainers:"),console.log("--- body ---"),console.log(z),console.log("--- context ---"),console.log(w),!0}},aw=(w,z={query:!1,headers:!1,body:!1,cookie:!1,set:!1,server:!1,request:!1,route:!1})=>{let A=[];if(w.handler&&typeof w.handler==="function")A.push(w.handler);if(w.request?.length)A.push(...w.request);if(w.beforeHandle?.length)A.push(...w.beforeHandle);if(w.parse?.length)A.push(...w.parse);if(w.error?.length)A.push(...w.error);if(w.transform?.length)A.push(...w.transform);if(w.afterHandle?.length)A.push(...w.afterHandle);if(w.mapResponse?.length)A.push(...w.mapResponse);if(w.afterResponse?.length)A.push(...w.afterResponse);for(let U of A){if(!U)continue;let W="fn"in U?U.fn:U;if(typeof W!=="function")continue;let[$,X,{isArrowReturn:Q}]=bH(W.toString()),Z=DH($,z),J=_H(Z);if(J){let Y=mA(J,X);if(Y.splice(0,-1,J),!OH(J,X,z))PH(X,Y,z);if(!z.query&&X.includes("return "+J+".query"))z.query=!0}if(z.query&&z.headers&&z.body&&z.cookie&&z.set&&z.server&&z.request&&z.route)break}return z};var w8=Ww(rA(),1),AU=Ww(ew(),1);class W6{constructor(w,z,A={}){this.name=w,this.jar=z,this.initial=A}get cookie(){return this.jar[this.name]??this.initial}set cookie(w){if(!(this.name in this.jar))this.jar[this.name]=this.initial;this.jar[this.name]=w}get setCookie(){if(!(this.name in this.jar))this.jar[this.name]=this.initial;return this.jar[this.name]}set setCookie(w){this.cookie=w}get value(){return this.cookie.value}set value(w){this.setCookie.value=w}get expires(){return this.cookie.expires}set expires(w){this.setCookie.expires=w}get maxAge(){return this.cookie.maxAge}set maxAge(w){this.setCookie.maxAge=w}get domain(){return this.cookie.domain}set domain(w){this.setCookie.domain=w}get path(){return this.cookie.path}set path(w){this.setCookie.path=w}get secure(){return this.cookie.secure}set secure(w){this.setCookie.secure=w}get httpOnly(){return this.cookie.httpOnly}set httpOnly(w){this.setCookie.httpOnly=w}get sameSite(){return this.cookie.sameSite}set sameSite(w){this.setCookie.sameSite=w}get priority(){return this.cookie.priority}set priority(w){this.setCookie.priority=w}get partitioned(){return this.cookie.partitioned}set partitioned(w){this.setCookie.partitioned=w}get secrets(){return this.cookie.secrets}set secrets(w){this.setCookie.secrets=w}update(w){return this.setCookie=Object.assign(this.cookie,typeof w==="function"?w(this.cookie):w),this}set(w){return this.setCookie=Object.assign({...this.initial,value:this.value},typeof w==="function"?w(this.cookie):w),this}remove(){if(this.value===void 0)return;return this.set({expires:new Date(0),maxAge:0,value:""}),this}toString(){return typeof this.value==="object"?JSON.stringify(this.value):this.value?.toString()??""}}var zU=(w,z,A)=>{if(!w.cookie)w.cookie={};return new Proxy(z,{get(U,W){if(W in z)return new W6(W,w.cookie,Object.assign({},A??{},z[W]));return new W6(W,w.cookie,Object.assign({},A))}})},z8=async(w,z,{secrets:A,sign:U,...W}={})=>{if(!z)return zU(w,{},W);let $=typeof A==="string";if(U&&U!==!0&&!Array.isArray(U))U=[U];let X={},Q=w8.parse(z);for(let[Z,J]of Object.entries(Q)){let Y=AU.default(J);if(U===!0||U?.includes(Z)){if(!A)throw new Error("No secret is provided to cookie plugin");if($){let L=await zz(Y,A);if(L===!1)throw new m4(Z);Y=L}else{let L=!0;for(let _=0;_<A.length;_++){let G=await zz(Y,A[_]);if(G!==!1){L=!0,Y=G;break}}if(!L)throw new m4(Z)}}X[Z]={value:Y}}return zU(w,X,W)},p4=(w)=>{if(!w||!Q2(w))return;let z=[];for(let[A,U]of Object.entries(w)){if(!A||!U)continue;let W=U.value;if(W===void 0||W===null)continue;z.push(w8.serialize(A,typeof W==="object"?JSON.stringify(W):W+"",U))}if(z.length===0)return;if(z.length===1)return z[0];return z};var $6=(w,z)=>{let A=w.size;if(!z&&A||A&&z&&z.status!==206&&z.status!==304&&z.status!==412&&z.status!==416){if(z){if(z.headers instanceof Headers){let U={"accept-ranges":"bytes","content-range":`bytes 0-${A-1}/${A}`,"transfer-encoding":"chunked"};if(vw)U=z.headers.toJSON();else{U={};for(let[W,$]of z.headers.entries())if(W in z.headers)U[W]=$}return new Response(w,{status:z.status,headers:U})}if(Q2(z.headers))return new Response(w,{status:z.status,headers:Object.assign({"accept-ranges":"bytes","content-range":`bytes 0-${A-1}/${A}`,"transfer-encoding":"chunked"},z.headers)})}return new Response(w,{headers:{"accept-ranges":"bytes","content-range":`bytes 0-${A-1}/${A}`,"transfer-encoding":"chunked"}})}return new Response(w)},Qz=(w,z)=>{if(!w)return w;w.delete("set-cookie");for(let A=0;A<z.length;A++){let U=z[A].indexOf("=");w.append("set-cookie",`${z[A].slice(0,U)}=${z[A].slice(U+1)||""}`)}return w},q1=async(w,z,A)=>{let U=w.next();if(U instanceof Promise)U=await U;if(U.done){if(z)return H2(U.value,z,A);return D1(U.value,A)}return new Response(new ReadableStream({async start(W){let $=!1;if(A?.signal?.addEventListener("abort",()=>{$=!0;try{W.close()}catch{}}),U.value!==void 0&&U.value!==null)if(typeof U.value==="object")try{W.enqueue(Buffer.from(JSON.stringify(U.value)))}catch{W.enqueue(Buffer.from(U.value.toString()))}else W.enqueue(Buffer.from(U.value.toString()));for await(let X of w){if($)break;if(X===void 0||X===null)continue;if(typeof X==="object")try{W.enqueue(Buffer.from(JSON.stringify(X)))}catch{W.enqueue(Buffer.from(X.toString()))}else W.enqueue(Buffer.from(X.toString()));await new Promise((Q)=>setTimeout(()=>Q(),0))}try{W.close()}catch{}}}),{...z,headers:{"transfer-encoding":"chunked","content-type":"text/event-stream; charset=utf-8",...z?.headers}})};async function*X4(w){let z=w.body;if(!z)return;let A=z.getReader(),U=new TextDecoder;try{while(!0){let{done:W,value:$}=await A.read();if(W)break;yield U.decode($)}}finally{A.releaseLock()}}var UU=(w)=>{if(typeof w.status==="string")w.status=U6[w.status];if(w.cookie&&Q2(w.cookie)){let z=p4(w.cookie);if(z)w.headers["set-cookie"]=z}if(w.headers["set-cookie"]&&Array.isArray(w.headers["set-cookie"]))w.headers=Qz(new Headers(w.headers),w.headers["set-cookie"])},A8=(w,z)=>{if(w.status!==z.status&&z.status!==200&&(w.status<=300||w.status>400))w=new Response(w.body,{headers:w.headers,status:z.status});let A=!1;if(z.headers instanceof Headers)for(let U of z.headers.keys())if(U==="set-cookie"){if(A)continue;A=!0;for(let W of z.headers.getSetCookie())w.headers.append("set-cookie",W)}else w.headers.append(U,z.headers?.get(U)??"");else for(let U in z.headers)w.headers.append(U,z.headers[U]);return w},H2=(w,z,A)=>{if(Q2(z.headers)||z.status!==200||z.cookie)switch(UU(z),w?.constructor?.name){case"String":return new Response(w,z);case"Array":case"Object":return Response.json(w,z);case"ElysiaFile":return $6(w.value);case"Blob":return $6(w,z);case"ElysiaCustomStatusResponse":return z.status=w.code,H2(w.response,z,A);case"ReadableStream":if(!z.headers["content-type"]?.startsWith("text/event-stream"))z.headers["content-type"]="text/event-stream; charset=utf-8";return A?.signal?.addEventListener("abort",{handleEvent(){if(A?.signal&&!A?.signal?.aborted)w.cancel()}},{once:!0}),new Response(w,z);case void 0:if(!w)return new Response("",z);return Response.json(w,z);case"Response":if(w=A8(w,z),w.headers.get("transfer-encoding")==="chunked")return q1(X4(w),z,A);return w;case"Error":return X6(w,z);case"Promise":return w.then((U)=>H2(U,z,A));case"Function":return H2(w(),z,A);case"Number":case"Boolean":return new Response(w.toString(),z);case"Cookie":if(w instanceof W6)return new Response(w.value,z);return new Response(w?.toString(),z);case"FormData":return new Response(w,z);default:if(w instanceof Response){if(w=A8(w,z),w.headers.get("transfer-encoding")==="chunked")return q1(X4(w),z,A);return w}if(w instanceof Promise)return w.then((U)=>H2(U,z));if(w instanceof Error)return X6(w,z);if(w instanceof I2)return z.status=w.code,H2(w.response,z,A);if(typeof w?.next==="function")return q1(w,z,A);if(typeof w?.then==="function")return w.then((U)=>H2(U,z));if(typeof w?.toResponse==="function")return H2(w.toResponse(),z);if("charCodeAt"in w){let U=w.charCodeAt(0);if(U===123||U===91){if(!z.headers["Content-Type"])z.headers["Content-Type"]="application/json";return new Response(JSON.stringify(w),z)}}return new Response(w,z)}if(typeof w?.next==="function"||w instanceof ReadableStream||w instanceof Response&&w.headers.get("transfer-encoding")==="chunked")return q1(w,z,A);return D1(w,A)},M2=(w,z,A)=>{if(w===void 0||w===null)return;if(Q2(z.headers)||z.status!==200||z.cookie)switch(UU(z),w?.constructor?.name){case"String":return new Response(w,z);case"Array":case"Object":return Response.json(w,z);case"ElysiaFile":return $6(w.value);case"Blob":return $6(w,z);case"ElysiaCustomStatusResponse":return z.status=w.code,M2(w.response,z,A);case"ReadableStream":if(!z.headers["content-type"]?.startsWith("text/event-stream"))z.headers["content-type"]="text/event-stream; charset=utf-8";return A?.signal?.addEventListener("abort",{handleEvent(){if(A?.signal&&!A?.signal?.aborted)w.cancel()}},{once:!0}),new Response(w,z);case void 0:if(!w)return;return Response.json(w,z);case"Response":if(w=A8(w,z),w.headers.get("transfer-encoding")==="chunked")return q1(X4(w),z,A);return w;case"Promise":return w.then((U)=>M2(U,z));case"Error":return X6(w,z);case"Function":return M2(w(),z);case"Number":case"Boolean":return new Response(w.toString(),z);case"FormData":return new Response(w);case"Cookie":if(w instanceof W6)return new Response(w.value,z);return new Response(w?.toString(),z);default:if(w instanceof Response){if(w=A8(w,z),w.headers.get("transfer-encoding")==="chunked")return q1(X4(w),z,A);return w}if(w instanceof Promise)return w.then((U)=>M2(U,z));if(w instanceof Error)return X6(w,z);if(w instanceof I2)return z.status=w.code,M2(w.response,z,A);if(typeof w?.next==="function")return q1(w,z,A);if(typeof w?.then==="function")return w.then((U)=>M2(U,z));if(typeof w?.toResponse==="function")return M2(w.toResponse(),z);if("charCodeAt"in w){let U=w.charCodeAt(0);if(U===123||U===91){if(!z.headers["Content-Type"])z.headers["Content-Type"]="application/json";return new Response(JSON.stringify(w),z)}}return new Response(w,z)}else switch(w?.constructor?.name){case"String":return new Response(w);case"Array":case"Object":return Response.json(w,z);case"ElysiaFile":return $6(w.value);case"Blob":return $6(w,z);case"ElysiaCustomStatusResponse":return z.status=w.code,M2(w.response,z,A);case"ReadableStream":return A?.signal?.addEventListener("abort",{handleEvent(){if(A?.signal&&!A?.signal?.aborted)w.cancel()}},{once:!0}),new Response(w,{headers:{"Content-Type":"text/event-stream; charset=utf-8"}});case void 0:if(!w)return new Response("");return new Response(JSON.stringify(w),{headers:{"content-type":"application/json"}});case"Response":if(w.headers.get("transfer-encoding")==="chunked")return q1(X4(w));return w;case"Promise":return w.then((U)=>{let W=M2(U,z);if(W!==void 0)return W});case"Error":return X6(w,z);case"Function":return D1(w(),A);case"Number":case"Boolean":return new Response(w.toString());case"Cookie":if(w instanceof W6)return new Response(w.value,z);return new Response(w?.toString(),z);case"FormData":return new Response(w);default:if(w instanceof Response)return w;if(w instanceof Promise)return w.then((U)=>M2(U,z));if(w instanceof Error)return X6(w,z);if(w instanceof I2)return z.status=w.code,M2(w.response,z,A);if(typeof w?.next==="function")return q1(w,z,A);if(typeof w?.then==="function")return w.then((U)=>M2(U,z));if(typeof w?.toResponse==="function")return M2(w.toResponse(),z);if("charCodeAt"in w){let U=w.charCodeAt(0);if(U===123||U===91){if(!z.headers["Content-Type"])z.headers["Content-Type"]="application/json";return new Response(JSON.stringify(w),z)}}return new Response(w)}},D1=(w,z)=>{switch(w?.constructor?.name){case"String":return new Response(w);case"Object":case"Array":return Response.json(w);case"ElysiaFile":return $6(w.value);case"Blob":return $6(w);case"ElysiaCustomStatusResponse":return H2(w.response,{status:w.code,headers:{}});case"ReadableStream":return z?.signal?.addEventListener("abort",{handleEvent(){if(z?.signal&&!z?.signal?.aborted)w.cancel()}},{once:!0}),new Response(w,{headers:{"Content-Type":"text/event-stream; charset=utf-8"}});case void 0:if(!w)return new Response("");return new Response(JSON.stringify(w),{headers:{"content-type":"application/json"}});case"Response":if(w.headers.get("transfer-encoding")==="chunked")return q1(X4(w));return w;case"Error":return X6(w);case"Promise":return w.then((A)=>D1(A,z));case"Function":return D1(w(),z);case"Number":case"Boolean":return new Response(w.toString());case"FormData":return new Response(w);default:if(w instanceof Response)return w;if(w instanceof Promise)return w.then((A)=>D1(A,z));if(w instanceof Error)return X6(w);if(w instanceof I2)return H2(w.response,{status:w.code,headers:{}});if(typeof w?.next==="function")return q1(w,void 0,z);if(typeof w?.then==="function")return w.then((A)=>H2(A,set));if(typeof w?.toResponse==="function")return D1(w.toResponse());if("charCodeAt"in w){let A=w.charCodeAt(0);if(A===123||A===91)return new Response(JSON.stringify(w),{headers:{"Content-Type":"application/json"}})}return new Response(w)}},X6=(w,z)=>new Response(JSON.stringify({name:w?.name,message:w?.message,cause:w?.cause}),{status:z?.status!==200?z?.status??500:500,headers:z?.headers}),Zz=(w,z,A={})=>{if(typeof w==="function")return;let U=H2(w,{headers:A});if(z.parse.length===0&&z.transform.length===0&&z.beforeHandle.length===0&&z.afterHandle.length===0)return U.clone.bind(U)};var Q4={name:"web-standard",isWebStandard:!0,handler:{mapResponse:H2,mapEarlyResponse:M2,mapCompactResponse:D1,createStaticHandler:Zz},composeHandler:{mapResponseContext:"c.request",preferWebstandardHeaders:!0,headers:`c.headers = {}
1
+ // @bun
2
+ var $A=Object.create;var{getPrototypeOf:QA,defineProperty:f5,getOwnPropertyNames:YA}=Object;var JA=Object.prototype.hasOwnProperty;var n4=(w,z,U)=>{U=w!=null?$A(QA(w)):{};let W=z||!w||!w.__esModule?f5(U,"default",{value:w,enumerable:!0}):U;for(let A of YA(w))if(!JA.call(W,A))f5(W,A,{get:()=>w[A],enumerable:!0});return W};var aw=(w,z)=>()=>(z||w((z={exports:{}}).exports,z),z.exports);var J6=(w,z)=>{for(var U in z)f5(w,U,{get:z[U],enumerable:!0,configurable:!0,set:(W)=>z[U]=()=>W})};var ZU=aw((XU)=>{Object.defineProperty(XU,"__esModule",{value:!0});XU.parse=Tq;XU.serialize=gq;var jq=/^[\u0021-\u003A\u003C\u003E-\u007E]+$/,Eq=/^[\u0021-\u003A\u003C-\u007E]*$/,Iq=/^([.]?[a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?)([.][a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?)*$/i,xq=/^[\u0020-\u003A\u003D-\u007E]*$/,Vq=Object.prototype.toString,kq=(()=>{let w=function(){};return w.prototype=Object.create(null),w})();function Tq(w,z){let U=new kq,W=w.length;if(W<2)return U;let A=z?.decode||fq,X=0;do{let Z=w.indexOf("=",X);if(Z===-1)break;let $=w.indexOf(";",X),Q=$===-1?W:$;if(Z>Q){X=w.lastIndexOf(";",Z-1)+1;continue}let Y=WU(w,X,Z),B=AU(w,Z,Y),G=w.slice(Y,B);if(U[G]===void 0){let _=WU(w,Z+1,Q),H=AU(w,Q,_),F=A(w.slice(_,H));U[G]=F}X=Q+1}while(X<W);return U}function WU(w,z,U){do{let W=w.charCodeAt(z);if(W!==32&&W!==9)return z}while(++z<U);return U}function AU(w,z,U){while(z>U){let W=w.charCodeAt(--z);if(W!==32&&W!==9)return z+1}return U}function gq(w,z,U){let W=U?.encode||encodeURIComponent;if(!jq.test(w))throw new TypeError(`argument name is invalid: ${w}`);let A=W(z);if(!Eq.test(A))throw new TypeError(`argument val is invalid: ${z}`);let X=w+"="+A;if(!U)return X;if(U.maxAge!==void 0){if(!Number.isInteger(U.maxAge))throw new TypeError(`option maxAge is invalid: ${U.maxAge}`);X+="; Max-Age="+U.maxAge}if(U.domain){if(!Iq.test(U.domain))throw new TypeError(`option domain is invalid: ${U.domain}`);X+="; Domain="+U.domain}if(U.path){if(!xq.test(U.path))throw new TypeError(`option path is invalid: ${U.path}`);X+="; Path="+U.path}if(U.expires){if(!dq(U.expires)||!Number.isFinite(U.expires.valueOf()))throw new TypeError(`option expires is invalid: ${U.expires}`);X+="; Expires="+U.expires.toUTCString()}if(U.httpOnly)X+="; HttpOnly";if(U.secure)X+="; Secure";if(U.partitioned)X+="; Partitioned";if(U.priority)switch(typeof U.priority==="string"?U.priority.toLowerCase():void 0){case"low":X+="; Priority=Low";break;case"medium":X+="; Priority=Medium";break;case"high":X+="; Priority=High";break;default:throw new TypeError(`option priority is invalid: ${U.priority}`)}if(U.sameSite)switch(typeof U.sameSite==="string"?U.sameSite.toLowerCase():U.sameSite){case!0:case"strict":X+="; SameSite=Strict";break;case"lax":X+="; SameSite=Lax";break;case"none":X+="; SameSite=None";break;default:throw new TypeError(`option sameSite is invalid: ${U.sameSite}`)}return X}function fq(w){if(w.indexOf("%")===-1)return w;try{return decodeURIComponent(w)}catch(z){return w}}function dq(w){return Vq.call(w)==="[object Date]"}});var F8=aw((JE,YU)=>{var $U=12,cq=0,jw=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,4,4,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,6,7,7,7,7,7,7,7,7,7,7,7,7,8,7,7,10,9,9,9,11,4,4,4,4,4,4,4,4,4,4,4,0,0,0,0,0,0,0,0,0,0,0,0,12,0,0,0,0,24,36,48,60,72,84,96,0,12,12,12,0,0,0,0,0,0,0,0,0,0,0,24,0,0,0,0,0,0,0,0,0,24,24,24,0,0,0,0,0,0,0,0,0,24,24,0,0,0,0,0,0,0,0,0,0,48,48,48,0,0,0,0,0,0,0,0,0,0,48,48,0,0,0,0,0,0,0,0,0,48,0,0,0,0,0,0,0,0,0,0,127,63,63,63,0,31,15,15,15,7,7,7];function iq(w){var z=w.indexOf("%");if(z===-1)return w;var U=w.length,W="",A=0,X=0,Z=z,$=$U;while(z>-1&&z<U){var Q=QU(w[z+1],4),Y=QU(w[z+2],0),B=Q|Y,G=jw[B];if($=jw[256+$+G],X=X<<6|B&jw[364+G],$===$U)W+=w.slice(A,Z),W+=X<=65535?String.fromCharCode(X):String.fromCharCode(55232+(X>>10),56320+(X&1023)),X=0,A=z+3,z=Z=w.indexOf("%",A);else if($===cq)return null;else{if(z+=3,z<U&&w.charCodeAt(z)===37)continue;return null}}return W+w.slice(A)}var vq={"0":0,"1":1,"2":2,"3":3,"4":4,"5":5,"6":6,"7":7,"8":8,"9":9,a:10,A:10,b:11,B:11,c:12,C:12,d:13,D:13,e:14,E:14,f:15,F:15};function QU(w,z){var U=vq[w];return U===void 0?255:U<<z}YU.exports=iq});var F6=(w,z)=>{let U=z?.length?{}:null;if(U)for(let W of z)U[W.part.charCodeAt(0)]=W;return{part:w,store:null,inert:U,params:null,wildcardStore:null}},ew=(w,z)=>({...w,part:z}),wz=(w)=>({name:w,store:null,inert:null});class u1{root={};history=[];static regex={static:/:.+?(?=\/|$)/,params:/:.+?(?=\/|$)/g,optionalParams:/:.+?\?(?=\/|$)/g};add(w,z,U,{ignoreError:W=!1,ignoreHistory:A=!1}={}){if(typeof z!=="string")throw new TypeError("Route path must be a string");if(z==="")z="/";else if(z[0]!=="/")z=`/${z}`;let X=z[z.length-1]==="*",Z=z.match(u1.regex.optionalParams);if(Z){let G=z.replaceAll("?","");this.add(w,G,U,{ignoreError:W});for(let _=0;_<Z.length;_++){let H=z.replace("/"+Z[_],"");this.add(w,H,U,{ignoreError:!0})}return U}if(Z)z=z.replaceAll("?","");if(this.history.find(([G,_,H])=>G===w&&_===z))return U;if(X||Z&&z.charCodeAt(z.length-1)===63)z=z.slice(0,-1);if(!A)this.history.push([w,z,U]);let $=z.split(u1.regex.static),Q=z.match(u1.regex.params)||[];if($[$.length-1]==="")$.pop();let Y;if(!this.root[w])Y=this.root[w]=F6("/");else Y=this.root[w];let B=0;for(let G=0;G<$.length;++G){let _=$[G];if(G>0){let H=Q[B++].slice(1);if(Y.params===null)Y.params=wz(H);else if(Y.params.name!==H)if(W)return U;else throw new Error(`Cannot create route "${z}" with parameter "${H}" because a route already exists with a different parameter name ("${Y.params.name}") in the same location`);let F=Y.params;if(F.inert===null){Y=F.inert=F6(_);continue}Y=F.inert}for(let H=0;;){if(H===_.length){if(H<Y.part.length){let F=ew(Y,Y.part.slice(H));Object.assign(Y,F6(_,[F]))}break}if(H===Y.part.length){if(Y.inert===null)Y.inert={};let F=Y.inert[_.charCodeAt(H)];if(F){Y=F,_=_.slice(H),H=0;continue}let R=F6(_.slice(H));Y.inert[_.charCodeAt(H)]=R,Y=R;break}if(_[H]!==Y.part[H]){let F=ew(Y,Y.part.slice(H)),R=F6(_.slice(H));Object.assign(Y,F6(Y.part.slice(0,H),[F,R])),Y=R;break}++H}}if(B<Q.length){let G=Q[B].slice(1);if(Y.params===null)Y.params=wz(G);else if(Y.params.name!==G)if(W)return U;else throw new Error(`Cannot create route "${z}" with parameter "${G}" because a route already exists with a different parameter name ("${Y.params.name}") in the same location`);if(Y.params.store===null)Y.params.store=U;return Y.params.store}if(X){if(Y.wildcardStore===null)Y.wildcardStore=U;return Y.wildcardStore}if(Y.store===null)Y.store=U;return Y.store}find(w,z){let U=this.root[w];if(!U)return null;return d5(z,z.length,U,0)}}var d5=(w,z,U,W)=>{let A=U.part,X=A.length,Z=W+X;if(X>1){if(Z>z)return null;if(X<15){for(let $=1,Q=W+1;$<X;++$,++Q)if(A.charCodeAt($)!==w.charCodeAt(Q))return null}else if(w.slice(W,Z)!==A)return null}if(Z===z){if(U.store!==null)return{store:U.store,params:{}};if(U.wildcardStore!==null)return{store:U.wildcardStore,params:{"*":""}};return null}if(U.inert!==null){let $=U.inert[w.charCodeAt(Z)];if($!==void 0){let Q=d5(w,z,$,Z);if(Q!==null)return Q}}if(U.params!==null){let{store:$,name:Q,inert:Y}=U.params,B=w.indexOf("/",Z);if(B!==Z){if(B===-1||B>=z){if($!==null){let G={};return G[Q]=w.substring(Z,z),{store:$,params:G}}}else if(Y!==null){let G=d5(w,z,Y,B);if(G!==null)return G.params[Q]=w.substring(Z,B),G}}}if(U.wildcardStore!==null)return{store:U.wildcardStore,params:{"*":w.substring(Z,z)}};return null};var H2={};J6(H2,{IsUndefined:()=>s0,IsUint8Array:()=>C1,IsSymbol:()=>v5,IsString:()=>E0,IsRegExp:()=>$4,IsObject:()=>P0,IsNumber:()=>f2,IsNull:()=>i5,IsIterator:()=>c5,IsFunction:()=>y5,IsDate:()=>B6,IsBoolean:()=>R1,IsBigInt:()=>Z4,IsAsyncIterator:()=>h5,IsArray:()=>u0,HasPropertyKey:()=>u4});function u4(w,z){return z in w}function h5(w){return P0(w)&&!u0(w)&&!C1(w)&&Symbol.asyncIterator in w}function u0(w){return Array.isArray(w)}function Z4(w){return typeof w==="bigint"}function R1(w){return typeof w==="boolean"}function B6(w){return w instanceof globalThis.Date}function y5(w){return typeof w==="function"}function c5(w){return P0(w)&&!u0(w)&&!C1(w)&&Symbol.iterator in w}function i5(w){return w===null}function f2(w){return typeof w==="number"}function P0(w){return typeof w==="object"&&w!==null}function $4(w){return w instanceof globalThis.RegExp}function E0(w){return typeof w==="string"}function v5(w){return typeof w==="symbol"}function C1(w){return w instanceof globalThis.Uint8Array}function s0(w){return w===void 0}function BA(w){return w.map((z)=>m4(z))}function MA(w){return new Date(w.getTime())}function qA(w){return new Uint8Array(w)}function HA(w){return new RegExp(w.source,w.flags)}function GA(w){let z={};for(let U of Object.getOwnPropertyNames(w))z[U]=m4(w[U]);for(let U of Object.getOwnPropertySymbols(w))z[U]=m4(w[U]);return z}function m4(w){return u0(w)?BA(w):B6(w)?MA(w):C1(w)?qA(w):$4(w)?HA(w):P0(w)?GA(w):w}function k0(w){return m4(w)}function zz(w,z){return z===void 0?k0(w):k0({...z,...w})}function t4(w){return s(w)&&Symbol.asyncIterator in w}function p4(w){return s(w)&&Symbol.iterator in w}function n5(w){return s(w)&&(Object.getPrototypeOf(w)===Object.prototype||Object.getPrototypeOf(w)===null)}function o4(w){return w instanceof Promise}function G2(w){return w instanceof Date&&Number.isFinite(w.getTime())}function Uz(w){return w instanceof globalThis.Map}function Wz(w){return w instanceof globalThis.Set}function d2(w){return ArrayBuffer.isView(w)}function j6(w){return w instanceof globalThis.Uint8Array}function v(w,z){return z in w}function s(w){return w!==null&&typeof w==="object"}function n(w){return Array.isArray(w)&&!ArrayBuffer.isView(w)}function T0(w){return w===void 0}function K1(w){return w===null}function G1(w){return typeof w==="boolean"}function d(w){return typeof w==="number"}function l4(w){return Number.isInteger(w)}function A2(w){return typeof w==="bigint"}function $0(w){return typeof w==="string"}function m1(w){return typeof w==="function"}function F1(w){return typeof w==="symbol"}function V2(w){return A2(w)||G1(w)||K1(w)||d(w)||$0(w)||F1(w)||T0(w)}var V0;(function(w){w.InstanceMode="default",w.ExactOptionalPropertyTypes=!1,w.AllowArrayObject=!1,w.AllowNaN=!1,w.AllowNullVoid=!1;function z(Z,$){return w.ExactOptionalPropertyTypes?$ in Z:Z[$]!==void 0}w.IsExactOptionalProperty=z;function U(Z){let $=s(Z);return w.AllowArrayObject?$:$&&!n(Z)}w.IsObjectLike=U;function W(Z){return U(Z)&&!(Z instanceof Date)&&!(Z instanceof Uint8Array)}w.IsRecordLike=W;function A(Z){return w.AllowNaN?d(Z):Number.isFinite(Z)}w.IsNumberLike=A;function X(Z){let $=T0(Z);return w.AllowNullVoid?$||Z===null:$}w.IsVoidLike=X})(V0||(V0={}));function LA(w){return globalThis.Object.freeze(w).map((z)=>Q4(z))}function NA(w){return w}function SA(w){return w}function _A(w){return w}function DA(w){let z={};for(let U of Object.getOwnPropertyNames(w))z[U]=Q4(w[U]);for(let U of Object.getOwnPropertySymbols(w))z[U]=Q4(w[U]);return globalThis.Object.freeze(z)}function Q4(w){return u0(w)?LA(w):B6(w)?NA(w):C1(w)?SA(w):$4(w)?_A(w):P0(w)?DA(w):w}function P(w,z){let U=z!==void 0?{...z,...w}:w;switch(V0.InstanceMode){case"freeze":return Q4(U);case"clone":return k0(U);default:return U}}class y extends Error{constructor(w){super(w)}}var F0=Symbol.for("TypeBox.Transform"),w1=Symbol.for("TypeBox.Readonly"),X2=Symbol.for("TypeBox.Optional"),h2=Symbol.for("TypeBox.Hint"),N=Symbol.for("TypeBox.Kind");function s4(w){return P0(w)&&w[w1]==="Readonly"}function y2(w){return P0(w)&&w[X2]==="Optional"}function u5(w){return Q0(w,"Any")}function j1(w){return Q0(w,"Array")}function Y4(w){return Q0(w,"AsyncIterator")}function m5(w){return Q0(w,"BigInt")}function t5(w){return Q0(w,"Boolean")}function S2(w){return Q0(w,"Computed")}function J4(w){return Q0(w,"Constructor")}function PA(w){return Q0(w,"Date")}function B4(w){return Q0(w,"Function")}function M6(w){return Q0(w,"Integer")}function m0(w){return Q0(w,"Intersect")}function M4(w){return Q0(w,"Iterator")}function Q0(w,z){return P0(w)&&N in w&&w[N]===z}function r4(w){return R1(w)||f2(w)||E0(w)}function E1(w){return Q0(w,"Literal")}function k2(w){return Q0(w,"MappedKey")}function g0(w){return Q0(w,"MappedResult")}function t1(w){return Q0(w,"Never")}function OA(w){return Q0(w,"Not")}function bA(w){return Q0(w,"Null")}function q6(w){return Q0(w,"Number")}function r0(w){return Q0(w,"Object")}function q4(w){return Q0(w,"Promise")}function p5(w){return Q0(w,"Record")}function h0(w){return Q0(w,"Ref")}function o5(w){return Q0(w,"RegExp")}function H4(w){return Q0(w,"String")}function RA(w){return Q0(w,"Symbol")}function T2(w){return Q0(w,"TemplateLiteral")}function CA(w){return Q0(w,"This")}function S0(w){return P0(w)&&F0 in w}function z1(w){return Q0(w,"Tuple")}function G4(w){return Q0(w,"Undefined")}function q0(w){return Q0(w,"Union")}function KA(w){return Q0(w,"Uint8Array")}function FA(w){return Q0(w,"Unknown")}function jA(w){return Q0(w,"Unsafe")}function EA(w){return Q0(w,"Void")}function p1(w){return P0(w)&&N in w&&E0(w[N])}function d0(w){return u5(w)||j1(w)||t5(w)||m5(w)||Y4(w)||S2(w)||J4(w)||PA(w)||B4(w)||M6(w)||m0(w)||M4(w)||E1(w)||k2(w)||g0(w)||t1(w)||OA(w)||bA(w)||q6(w)||r0(w)||q4(w)||p5(w)||h0(w)||o5(w)||H4(w)||RA(w)||T2(w)||CA(w)||z1(w)||G4(w)||q0(w)||KA(w)||FA(w)||jA(w)||EA(w)||p1(w)}var q={};J6(q,{TypeGuardUnknownTypeError:()=>Xz,IsVoid:()=>mz,IsUnsafe:()=>uz,IsUnknown:()=>nz,IsUnionLiteral:()=>hA,IsUnion:()=>r5,IsUndefined:()=>iz,IsUint8Array:()=>vz,IsTuple:()=>cz,IsTransform:()=>yz,IsThis:()=>hz,IsTemplateLiteral:()=>dz,IsSymbol:()=>fz,IsString:()=>gz,IsSchema:()=>f0,IsRegExp:()=>Tz,IsRef:()=>kz,IsRecursive:()=>dA,IsRecord:()=>Vz,IsReadonly:()=>kA,IsProperties:()=>a4,IsPromise:()=>xz,IsOptional:()=>TA,IsObject:()=>Iz,IsNumber:()=>Ez,IsNull:()=>jz,IsNot:()=>Fz,IsNever:()=>Kz,IsMappedResult:()=>Cz,IsMappedKey:()=>Rz,IsLiteralValue:()=>bz,IsLiteralString:()=>Pz,IsLiteralNumber:()=>Oz,IsLiteralBoolean:()=>fA,IsLiteral:()=>N4,IsKindOf:()=>w0,IsKind:()=>tz,IsIterator:()=>Dz,IsIntersect:()=>_z,IsInteger:()=>Sz,IsImport:()=>gA,IsFunction:()=>Nz,IsDate:()=>Lz,IsConstructor:()=>Gz,IsComputed:()=>Hz,IsBoolean:()=>qz,IsBigInt:()=>Mz,IsAsyncIterator:()=>Bz,IsArray:()=>Jz,IsAny:()=>Yz});class Xz extends y{}var IA=["Any","Array","AsyncIterator","BigInt","Boolean","Computed","Constructor","Date","Enum","Function","Integer","Intersect","Iterator","Literal","MappedKey","MappedResult","Not","Null","Number","Object","Promise","Record","Ref","RegExp","String","Symbol","TemplateLiteral","This","Tuple","Undefined","Union","Uint8Array","Unknown","Void"];function Zz(w){try{return new RegExp(w),!0}catch{return!1}}function l5(w){if(!E0(w))return!1;for(let z=0;z<w.length;z++){let U=w.charCodeAt(z);if(U>=7&&U<=13||U===27||U===127)return!1}return!0}function $z(w){return s5(w)||f0(w)}function L4(w){return s0(w)||Z4(w)}function I0(w){return s0(w)||f2(w)}function s5(w){return s0(w)||R1(w)}function O0(w){return s0(w)||E0(w)}function xA(w){return s0(w)||E0(w)&&l5(w)&&Zz(w)}function VA(w){return s0(w)||E0(w)&&l5(w)}function Qz(w){return s0(w)||f0(w)}function kA(w){return P0(w)&&w[w1]==="Readonly"}function TA(w){return P0(w)&&w[X2]==="Optional"}function Yz(w){return w0(w,"Any")&&O0(w.$id)}function Jz(w){return w0(w,"Array")&&w.type==="array"&&O0(w.$id)&&f0(w.items)&&I0(w.minItems)&&I0(w.maxItems)&&s5(w.uniqueItems)&&Qz(w.contains)&&I0(w.minContains)&&I0(w.maxContains)}function Bz(w){return w0(w,"AsyncIterator")&&w.type==="AsyncIterator"&&O0(w.$id)&&f0(w.items)}function Mz(w){return w0(w,"BigInt")&&w.type==="bigint"&&O0(w.$id)&&L4(w.exclusiveMaximum)&&L4(w.exclusiveMinimum)&&L4(w.maximum)&&L4(w.minimum)&&L4(w.multipleOf)}function qz(w){return w0(w,"Boolean")&&w.type==="boolean"&&O0(w.$id)}function Hz(w){return w0(w,"Computed")&&E0(w.target)&&u0(w.parameters)&&w.parameters.every((z)=>f0(z))}function Gz(w){return w0(w,"Constructor")&&w.type==="Constructor"&&O0(w.$id)&&u0(w.parameters)&&w.parameters.every((z)=>f0(z))&&f0(w.returns)}function Lz(w){return w0(w,"Date")&&w.type==="Date"&&O0(w.$id)&&I0(w.exclusiveMaximumTimestamp)&&I0(w.exclusiveMinimumTimestamp)&&I0(w.maximumTimestamp)&&I0(w.minimumTimestamp)&&I0(w.multipleOfTimestamp)}function Nz(w){return w0(w,"Function")&&w.type==="Function"&&O0(w.$id)&&u0(w.parameters)&&w.parameters.every((z)=>f0(z))&&f0(w.returns)}function gA(w){return w0(w,"Import")&&u4(w,"$defs")&&P0(w.$defs)&&a4(w.$defs)&&u4(w,"$ref")&&E0(w.$ref)&&w.$ref in w.$defs}function Sz(w){return w0(w,"Integer")&&w.type==="integer"&&O0(w.$id)&&I0(w.exclusiveMaximum)&&I0(w.exclusiveMinimum)&&I0(w.maximum)&&I0(w.minimum)&&I0(w.multipleOf)}function a4(w){return P0(w)&&Object.entries(w).every(([z,U])=>l5(z)&&f0(U))}function _z(w){return w0(w,"Intersect")&&(E0(w.type)&&w.type!=="object"?!1:!0)&&u0(w.allOf)&&w.allOf.every((z)=>f0(z)&&!yz(z))&&O0(w.type)&&(s5(w.unevaluatedProperties)||Qz(w.unevaluatedProperties))&&O0(w.$id)}function Dz(w){return w0(w,"Iterator")&&w.type==="Iterator"&&O0(w.$id)&&f0(w.items)}function w0(w,z){return P0(w)&&N in w&&w[N]===z}function Pz(w){return N4(w)&&E0(w.const)}function Oz(w){return N4(w)&&f2(w.const)}function fA(w){return N4(w)&&R1(w.const)}function N4(w){return w0(w,"Literal")&&O0(w.$id)&&bz(w.const)}function bz(w){return R1(w)||f2(w)||E0(w)}function Rz(w){return w0(w,"MappedKey")&&u0(w.keys)&&w.keys.every((z)=>f2(z)||E0(z))}function Cz(w){return w0(w,"MappedResult")&&a4(w.properties)}function Kz(w){return w0(w,"Never")&&P0(w.not)&&Object.getOwnPropertyNames(w.not).length===0}function Fz(w){return w0(w,"Not")&&f0(w.not)}function jz(w){return w0(w,"Null")&&w.type==="null"&&O0(w.$id)}function Ez(w){return w0(w,"Number")&&w.type==="number"&&O0(w.$id)&&I0(w.exclusiveMaximum)&&I0(w.exclusiveMinimum)&&I0(w.maximum)&&I0(w.minimum)&&I0(w.multipleOf)}function Iz(w){return w0(w,"Object")&&w.type==="object"&&O0(w.$id)&&a4(w.properties)&&$z(w.additionalProperties)&&I0(w.minProperties)&&I0(w.maxProperties)}function xz(w){return w0(w,"Promise")&&w.type==="Promise"&&O0(w.$id)&&f0(w.item)}function Vz(w){return w0(w,"Record")&&w.type==="object"&&O0(w.$id)&&$z(w.additionalProperties)&&P0(w.patternProperties)&&((z)=>{let U=Object.getOwnPropertyNames(z.patternProperties);return U.length===1&&Zz(U[0])&&P0(z.patternProperties)&&f0(z.patternProperties[U[0]])})(w)}function dA(w){return P0(w)&&h2 in w&&w[h2]==="Recursive"}function kz(w){return w0(w,"Ref")&&O0(w.$id)&&E0(w.$ref)}function Tz(w){return w0(w,"RegExp")&&O0(w.$id)&&E0(w.source)&&E0(w.flags)&&I0(w.maxLength)&&I0(w.minLength)}function gz(w){return w0(w,"String")&&w.type==="string"&&O0(w.$id)&&I0(w.minLength)&&I0(w.maxLength)&&xA(w.pattern)&&VA(w.format)}function fz(w){return w0(w,"Symbol")&&w.type==="symbol"&&O0(w.$id)}function dz(w){return w0(w,"TemplateLiteral")&&w.type==="string"&&E0(w.pattern)&&w.pattern[0]==="^"&&w.pattern[w.pattern.length-1]==="$"}function hz(w){return w0(w,"This")&&O0(w.$id)&&E0(w.$ref)}function yz(w){return P0(w)&&F0 in w}function cz(w){return w0(w,"Tuple")&&w.type==="array"&&O0(w.$id)&&f2(w.minItems)&&f2(w.maxItems)&&w.minItems===w.maxItems&&(s0(w.items)&&s0(w.additionalItems)&&w.minItems===0||u0(w.items)&&w.items.every((z)=>f0(z)))}function iz(w){return w0(w,"Undefined")&&w.type==="undefined"&&O0(w.$id)}function hA(w){return r5(w)&&w.anyOf.every((z)=>Pz(z)||Oz(z))}function r5(w){return w0(w,"Union")&&O0(w.$id)&&P0(w)&&u0(w.anyOf)&&w.anyOf.every((z)=>f0(z))}function vz(w){return w0(w,"Uint8Array")&&w.type==="Uint8Array"&&O0(w.$id)&&I0(w.minByteLength)&&I0(w.maxByteLength)}function nz(w){return w0(w,"Unknown")&&O0(w.$id)}function uz(w){return w0(w,"Unsafe")}function mz(w){return w0(w,"Void")&&w.type==="void"&&O0(w.$id)}function tz(w){return P0(w)&&N in w&&E0(w[N])&&!IA.includes(w[N])}function f0(w){return P0(w)&&(Yz(w)||Jz(w)||qz(w)||Mz(w)||Bz(w)||Hz(w)||Gz(w)||Lz(w)||Nz(w)||Sz(w)||_z(w)||Dz(w)||N4(w)||Rz(w)||Cz(w)||Kz(w)||Fz(w)||jz(w)||Ez(w)||Iz(w)||xz(w)||Vz(w)||kz(w)||Tz(w)||gz(w)||fz(w)||dz(w)||hz(w)||cz(w)||iz(w)||r5(w)||vz(w)||nz(w)||uz(w)||mz(w)||tz(w))}var pz="(true|false)",e4="(0|[1-9][0-9]*)",oz="(.*)";var I1="^(0|[1-9][0-9]*)$",x1="^(.*)$",lz="^(?!.*)$";var b0={};J6(b0,{Set:()=>nA,Has:()=>vA,Get:()=>uA,Entries:()=>yA,Delete:()=>iA,Clear:()=>cA});var E6=new Map;function yA(){return new Map(E6)}function cA(){return E6.clear()}function iA(w){return E6.delete(w)}function vA(w){return E6.has(w)}function nA(w,z){E6.set(w,z)}function uA(w){return E6.get(w)}var y0={};J6(y0,{Set:()=>lA,Has:()=>oA,Get:()=>sA,Entries:()=>mA,Delete:()=>pA,Clear:()=>tA});var I6=new Map;function mA(){return new Map(I6)}function tA(){return I6.clear()}function pA(w){return I6.delete(w)}function oA(w){return I6.has(w)}function lA(w,z){I6.set(w,z)}function sA(w){return I6.get(w)}function sz(w,z){return w.includes(z)}function rz(w){return[...new Set(w)]}function rA(w,z){return w.filter((U)=>z.includes(U))}function aA(w,z){return w.reduce((U,W)=>{return rA(U,W)},z)}function az(w){return w.length===1?w[0]:w.length>1?aA(w.slice(1),w[0]):[]}function ez(w){let z=[];for(let U of w)z.push(...U);return z}function o1(w){return P({[N]:"Any"},w)}function x6(w,z){return P({[N]:"Array",type:"array",items:w},z)}function V6(w,z){return P({[N]:"AsyncIterator",type:"AsyncIterator",items:w},z)}function N0(w,z,U){return P({[N]:"Computed",target:w,parameters:z},U)}function eA(w,z){let{[z]:U,...W}=w;return W}function c0(w,z){return z.reduce((U,W)=>eA(U,W),w)}function H0(w){return P({[N]:"Never",not:{}},w)}function Y0(w){return P({[N]:"MappedResult",properties:w})}function k6(w,z,U){return P({[N]:"Constructor",type:"Constructor",parameters:w,returns:z},U)}function L1(w,z,U){return P({[N]:"Function",type:"Function",parameters:w,returns:z},U)}function S4(w,z){return P({[N]:"Union",anyOf:w},z)}function wX(w){return w.some((z)=>y2(z))}function w9(w){return w.map((z)=>y2(z)?zX(z):z)}function zX(w){return c0(w,[X2])}function UX(w,z){return wX(w)?_2(S4(w9(w),z)):S4(w9(w),z)}function N1(w,z){return w.length===1?P(w[0],z):w.length===0?H0(z):UX(w,z)}function G0(w,z){return w.length===0?H0(z):w.length===1?P(w[0],z):S4(w,z)}class a5 extends y{}function WX(w){return w.replace(/\\\$/g,"$").replace(/\\\*/g,"*").replace(/\\\^/g,"^").replace(/\\\|/g,"|").replace(/\\\(/g,"(").replace(/\\\)/g,")")}function e5(w,z,U){return w[z]===U&&w.charCodeAt(z-1)!==92}function V1(w,z){return e5(w,z,"(")}function _4(w,z){return e5(w,z,")")}function z9(w,z){return e5(w,z,"|")}function AX(w){if(!(V1(w,0)&&_4(w,w.length-1)))return!1;let z=0;for(let U=0;U<w.length;U++){if(V1(w,U))z+=1;if(_4(w,U))z-=1;if(z===0&&U!==w.length-1)return!1}return!0}function XX(w){return w.slice(1,w.length-1)}function ZX(w){let z=0;for(let U=0;U<w.length;U++){if(V1(w,U))z+=1;if(_4(w,U))z-=1;if(z9(w,U)&&z===0)return!0}return!1}function $X(w){for(let z=0;z<w.length;z++)if(V1(w,z))return!0;return!1}function QX(w){let[z,U]=[0,0],W=[];for(let X=0;X<w.length;X++){if(V1(w,X))z+=1;if(_4(w,X))z-=1;if(z9(w,X)&&z===0){let Z=w.slice(U,X);if(Z.length>0)W.push(T6(Z));U=X+1}}let A=w.slice(U);if(A.length>0)W.push(T6(A));if(W.length===0)return{type:"const",const:""};if(W.length===1)return W[0];return{type:"or",expr:W}}function YX(w){function z(A,X){if(!V1(A,X))throw new a5("TemplateLiteralParser: Index must point to open parens");let Z=0;for(let $=X;$<A.length;$++){if(V1(A,$))Z+=1;if(_4(A,$))Z-=1;if(Z===0)return[X,$]}throw new a5("TemplateLiteralParser: Unclosed group parens in expression")}function U(A,X){for(let Z=X;Z<A.length;Z++)if(V1(A,Z))return[X,Z];return[X,A.length]}let W=[];for(let A=0;A<w.length;A++)if(V1(w,A)){let[X,Z]=z(w,A),$=w.slice(X,Z+1);W.push(T6($)),A=Z}else{let[X,Z]=U(w,A),$=w.slice(X,Z);if($.length>0)W.push(T6($));A=Z-1}return W.length===0?{type:"const",const:""}:W.length===1?W[0]:{type:"and",expr:W}}function T6(w){return AX(w)?T6(XX(w)):ZX(w)?QX(w):$X(w)?YX(w):{type:"const",const:WX(w)}}function g6(w){return T6(w.slice(1,w.length-1))}class U9 extends y{}function JX(w){return w.type==="or"&&w.expr.length===2&&w.expr[0].type==="const"&&w.expr[0].const==="0"&&w.expr[1].type==="const"&&w.expr[1].const==="[1-9][0-9]*"}function BX(w){return w.type==="or"&&w.expr.length===2&&w.expr[0].type==="const"&&w.expr[0].const==="true"&&w.expr[1].type==="const"&&w.expr[1].const==="false"}function MX(w){return w.type==="const"&&w.const===".*"}function H6(w){return JX(w)||MX(w)?!1:BX(w)?!0:w.type==="and"?w.expr.every((z)=>H6(z)):w.type==="or"?w.expr.every((z)=>H6(z)):w.type==="const"?!0:(()=>{throw new U9("Unknown expression type")})()}function w8(w){let z=g6(w.pattern);return H6(z)}class W9 extends y{}function*A9(w){if(w.length===1)return yield*w[0];for(let z of w[0])for(let U of A9(w.slice(1)))yield`${z}${U}`}function*qX(w){return yield*A9(w.expr.map((z)=>[...D4(z)]))}function*HX(w){for(let z of w.expr)yield*D4(z)}function*GX(w){return yield w.const}function*D4(w){return w.type==="and"?yield*qX(w):w.type==="or"?yield*HX(w):w.type==="const"?yield*GX(w):(()=>{throw new W9("Unknown expression")})()}function f6(w){let z=g6(w.pattern);return H6(z)?[...D4(z)]:[]}function X0(w,z){return P({[N]:"Literal",const:w,type:typeof w},z)}function z8(w){return P({[N]:"Boolean",type:"boolean"},w)}function d6(w){return P({[N]:"BigInt",type:"bigint"},w)}function S1(w){return P({[N]:"Number",type:"number"},w)}function c2(w){return P({[N]:"String",type:"string"},w)}function*LX(w){let z=w.trim().replace(/"|'/g,"");return z==="boolean"?yield z8():z==="number"?yield S1():z==="bigint"?yield d6():z==="string"?yield c2():yield(()=>{let U=z.split("|").map((W)=>X0(W.trim()));return U.length===0?H0():U.length===1?U[0]:N1(U)})()}function*NX(w){if(w[1]!=="{"){let z=X0("$"),U=ww(w.slice(1));return yield*[z,...U]}for(let z=2;z<w.length;z++)if(w[z]==="}"){let U=LX(w.slice(2,z)),W=ww(w.slice(z+1));return yield*[...U,...W]}yield X0(w)}function*ww(w){for(let z=0;z<w.length;z++)if(w[z]==="$"){let U=X0(w.slice(0,z)),W=NX(w.slice(z));return yield*[U,...W]}yield X0(w)}function X9(w){return[...ww(w)]}class Z9 extends y{}function SX(w){return w.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function $9(w,z){return T2(w)?w.pattern.slice(1,w.pattern.length-1):q0(w)?`(${w.anyOf.map((U)=>$9(U,z)).join("|")})`:q6(w)?`${z}${e4}`:M6(w)?`${z}${e4}`:m5(w)?`${z}${e4}`:H4(w)?`${z}${oz}`:E1(w)?`${z}${SX(w.const.toString())}`:t5(w)?`${z}${pz}`:(()=>{throw new Z9(`Unexpected Kind '${w[N]}'`)})()}function zw(w){return`^${w.map((z)=>$9(z,"")).join("")}$`}function G6(w){let U=f6(w).map((W)=>X0(W));return N1(U)}function U8(w,z){let U=E0(w)?zw(X9(w)):zw(w);return P({[N]:"TemplateLiteral",type:"string",pattern:U},z)}function _X(w){return f6(w).map((U)=>U.toString())}function DX(w){let z=[];for(let U of w)z.push(...D2(U));return z}function PX(w){return[w.toString()]}function D2(w){return[...new Set(T2(w)?_X(w):q0(w)?DX(w.anyOf):E1(w)?PX(w.const):q6(w)?["[number]"]:M6(w)?["[number]"]:[])]}function OX(w,z,U){let W={};for(let A of Object.getOwnPropertyNames(z))W[A]=l1(w,D2(z[A]),U);return W}function bX(w,z,U){return OX(w,z.properties,U)}function Q9(w,z,U){let W=bX(w,z,U);return Y0(W)}function J9(w,z){return w.map((U)=>B9(U,z))}function RX(w){return w.filter((z)=>!t1(z))}function CX(w,z){return W8(RX(J9(w,z)))}function KX(w){return w.some((z)=>t1(z))?[]:w}function FX(w,z){return N1(KX(J9(w,z)))}function jX(w,z){return z in w?w[z]:z==="[number]"?N1(w):H0()}function EX(w,z){return z==="[number]"?w:H0()}function IX(w,z){return z in w?w[z]:H0()}function B9(w,z){return m0(w)?CX(w.allOf,z):q0(w)?FX(w.anyOf,z):z1(w)?jX(w.items??[],z):j1(w)?EX(w.items,z):r0(w)?IX(w.properties,z):H0()}function P4(w,z){return z.map((U)=>B9(w,U))}function Y9(w,z){return N1(P4(w,z))}function l1(w,z,U){if(h0(w)||h0(z)){if(!d0(w)||!d0(z))throw new y("Index types using Ref parameters require both Type and Key to be of TSchema");return N0("Index",[w,z])}if(g0(z))return Q9(w,z,U);if(k2(z))return M9(w,z,U);return P(d0(z)?Y9(w,D2(z)):Y9(w,z),U)}function xX(w,z,U){return{[z]:l1(w,[z],k0(U))}}function VX(w,z,U){return z.reduce((W,A)=>{return{...W,...xX(w,A,U)}},{})}function kX(w,z,U){return VX(w,z.keys,U)}function M9(w,z,U){let W=kX(w,z,U);return Y0(W)}function h6(w,z){return P({[N]:"Iterator",type:"Iterator",items:w},z)}function TX(w){let z=[];for(let U in w)if(!y2(w[U]))z.push(U);return z}function gX(w,z){let U=TX(w),W=U.length>0?{[N]:"Object",type:"object",properties:w,required:U}:{[N]:"Object",type:"object",properties:w};return P(W,z)}var _0=gX;function A8(w,z){return P({[N]:"Promise",type:"Promise",item:w},z)}function fX(w){return P(c0(w,[w1]))}function dX(w){return P({...w,[w1]:"Readonly"})}function hX(w,z){return z===!1?fX(w):dX(w)}function i2(w,z){let U=z??!0;return g0(w)?q9(w,U):hX(w,U)}function yX(w,z){let U={};for(let W of globalThis.Object.getOwnPropertyNames(w))U[W]=i2(w[W],z);return U}function cX(w,z){return yX(w.properties,z)}function q9(w,z){let U=cX(w,z);return Y0(U)}function v2(w,z){return P(w.length>0?{[N]:"Tuple",type:"array",items:w,additionalItems:!1,minItems:w.length,maxItems:w.length}:{[N]:"Tuple",type:"array",minItems:w.length,maxItems:w.length},z)}function H9(w,z){return w in z?n2(w,z[w]):Y0(z)}function iX(w){return{[w]:X0(w)}}function vX(w){let z={};for(let U of w)z[U]=X0(U);return z}function nX(w,z){return sz(z,w)?iX(w):vX(z)}function uX(w,z){let U=nX(w,z);return H9(w,U)}function O4(w,z){return z.map((U)=>n2(w,U))}function mX(w,z){let U={};for(let W of globalThis.Object.getOwnPropertyNames(z))U[W]=n2(w,z[W]);return U}function n2(w,z){let U={...z};return y2(z)?_2(n2(w,c0(z,[X2]))):s4(z)?i2(n2(w,c0(z,[w1]))):g0(z)?H9(w,z.properties):k2(z)?uX(w,z.keys):J4(z)?k6(O4(w,z.parameters),n2(w,z.returns),U):B4(z)?L1(O4(w,z.parameters),n2(w,z.returns),U):Y4(z)?V6(n2(w,z.items),U):M4(z)?h6(n2(w,z.items),U):m0(z)?Z2(O4(w,z.allOf),U):q0(z)?G0(O4(w,z.anyOf),U):z1(z)?v2(O4(w,z.items??[]),U):r0(z)?_0(mX(w,z.properties),U):j1(z)?x6(n2(w,z.items),U):q4(z)?A8(n2(w,z.item),U):z}function tX(w,z){let U={};for(let W of w)U[W]=n2(W,z);return U}function G9(w,z,U){let W=d0(w)?D2(w):w,A=z({[N]:"MappedKey",keys:W}),X=tX(W,A);return _0(X,U)}function pX(w){return P(c0(w,[X2]))}function oX(w){return P({...w,[X2]:"Optional"})}function lX(w,z){return z===!1?pX(w):oX(w)}function _2(w,z){let U=z??!0;return g0(w)?L9(w,U):lX(w,U)}function sX(w,z){let U={};for(let W of globalThis.Object.getOwnPropertyNames(w))U[W]=_2(w[W],z);return U}function rX(w,z){return sX(w.properties,z)}function L9(w,z){let U=rX(w,z);return Y0(U)}function b4(w,z={}){let U=w.every((A)=>r0(A)),W=d0(z.unevaluatedProperties)?{unevaluatedProperties:z.unevaluatedProperties}:{};return P(z.unevaluatedProperties===!1||d0(z.unevaluatedProperties)||U?{...W,[N]:"Intersect",type:"object",allOf:w}:{...W,[N]:"Intersect",allOf:w},z)}function aX(w){return w.every((z)=>y2(z))}function eX(w){return c0(w,[X2])}function N9(w){return w.map((z)=>y2(z)?eX(z):z)}function wZ(w,z){return aX(w)?_2(b4(N9(w),z)):b4(N9(w),z)}function W8(w,z={}){if(w.length===1)return P(w[0],z);if(w.length===0)return H0(z);if(w.some((U)=>S0(U)))throw new Error("Cannot intersect transform types");return wZ(w,z)}function Z2(w,z){if(w.length===1)return P(w[0],z);if(w.length===0)return H0(z);if(w.some((U)=>S0(U)))throw new Error("Cannot intersect transform types");return b4(w,z)}function P2(...w){let[z,U]=typeof w[0]==="string"?[w[0],w[1]]:[w[0].$id,w[1]];if(typeof z!=="string")throw new y("Ref: $ref must be a string");return P({[N]:"Ref",$ref:z},U)}function zZ(w,z){return N0("Awaited",[N0(w,z)])}function UZ(w){return N0("Awaited",[P2(w)])}function WZ(w){return Z2(S9(w))}function AZ(w){return G0(S9(w))}function XZ(w){return y6(w)}function S9(w){return w.map((z)=>y6(z))}function y6(w,z){return P(S2(w)?zZ(w.target,w.parameters):m0(w)?WZ(w.allOf):q0(w)?AZ(w.anyOf):q4(w)?XZ(w.item):h0(w)?UZ(w.$ref):w,z)}function _9(w){let z=[];for(let U of w)z.push(O2(U));return z}function ZZ(w){let z=_9(w);return ez(z)}function $Z(w){let z=_9(w);return az(z)}function QZ(w){return w.map((z,U)=>U.toString())}function YZ(w){return["[number]"]}function JZ(w){return globalThis.Object.getOwnPropertyNames(w)}function BZ(w){if(!Uw)return[];return globalThis.Object.getOwnPropertyNames(w).map((U)=>{return U[0]==="^"&&U[U.length-1]==="$"?U.slice(1,U.length-1):U})}function O2(w){return m0(w)?ZZ(w.allOf):q0(w)?$Z(w.anyOf):z1(w)?QZ(w.items??[]):j1(w)?YZ(w.items):r0(w)?JZ(w.properties):p5(w)?BZ(w.patternProperties):[]}var Uw=!1;function k1(w){Uw=!0;let z=O2(w);return Uw=!1,`^(${z.map((W)=>`(${W})`).join("|")})$`}function MZ(w,z){return N0("KeyOf",[N0(w,z)])}function qZ(w){return N0("KeyOf",[P2(w)])}function HZ(w,z){let U=O2(w),W=GZ(U),A=N1(W);return P(A,z)}function GZ(w){return w.map((z)=>z==="[number]"?S1():X0(z))}function c6(w,z){return S2(w)?MZ(w.target,w.parameters):h0(w)?qZ(w.$ref):g0(w)?D9(w,z):HZ(w,z)}function LZ(w,z){let U={};for(let W of globalThis.Object.getOwnPropertyNames(w))U[W]=c6(w[W],k0(z));return U}function NZ(w,z){return LZ(w.properties,z)}function D9(w,z){let U=NZ(w,z);return Y0(U)}function X8(w){let z=O2(w),U=P4(w,z);return z.map((W,A)=>[z[A],U[A]])}function SZ(w){let z=[];for(let U of w)z.push(...O2(U));return rz(z)}function _Z(w){return w.filter((z)=>!t1(z))}function DZ(w,z){let U=[];for(let W of w)U.push(...P4(W,[z]));return _Z(U)}function PZ(w,z){let U={};for(let W of z)U[W]=W8(DZ(w,W));return U}function P9(w,z){let U=SZ(w),W=PZ(w,U);return _0(W,z)}function Z8(w){return P({[N]:"Date",type:"Date"},w)}function $8(w){return P({[N]:"Null",type:"null"},w)}function Q8(w){return P({[N]:"Symbol",type:"symbol"},w)}function Y8(w){return P({[N]:"Undefined",type:"undefined"},w)}function J8(w){return P({[N]:"Uint8Array",type:"Uint8Array"},w)}function T1(w){return P({[N]:"Unknown"},w)}function OZ(w){return w.map((z)=>Ww(z,!1))}function bZ(w){let z={};for(let U of globalThis.Object.getOwnPropertyNames(w))z[U]=i2(Ww(w[U],!1));return z}function B8(w,z){return z===!0?w:i2(w)}function Ww(w,z){return h5(w)?B8(o1(),z):c5(w)?B8(o1(),z):u0(w)?i2(v2(OZ(w))):C1(w)?J8():B6(w)?Z8():P0(w)?B8(_0(bZ(w)),z):y5(w)?B8(L1([],T1()),z):s0(w)?Y8():i5(w)?$8():v5(w)?Q8():Z4(w)?d6():f2(w)?X0(w):R1(w)?X0(w):E0(w)?X0(w):_0({})}function O9(w,z){return P(Ww(w,!0),z)}function b9(w,z){return v2(w.parameters,z)}function R9(w,z){if(s0(w))throw new Error("Enum undefined or empty");let U=globalThis.Object.getOwnPropertyNames(w).filter((X)=>isNaN(X)).map((X)=>w[X]),A=[...new Set(U)].map((X)=>X0(X));return G0(A,{...z,[h2]:"Enum"})}class E9 extends y{}var D;(function(w){w[w.Union=0]="Union",w[w.True=1]="True",w[w.False=2]="False"})(D||(D={}));function u2(w){return w===D.False?w:D.True}function i6(w){throw new E9(w)}function t0(w){return q.IsNever(w)||q.IsIntersect(w)||q.IsUnion(w)||q.IsUnknown(w)||q.IsAny(w)}function p0(w,z){return q.IsNever(z)?V9(w,z):q.IsIntersect(z)?M8(w,z):q.IsUnion(z)?Qw(w,z):q.IsUnknown(z)?f9(w,z):q.IsAny(z)?$w(w,z):i6("StructuralRight")}function $w(w,z){return D.True}function RZ(w,z){return q.IsIntersect(z)?M8(w,z):q.IsUnion(z)&&z.anyOf.some((U)=>q.IsAny(U)||q.IsUnknown(U))?D.True:q.IsUnion(z)?D.Union:q.IsUnknown(z)?D.True:q.IsAny(z)?D.True:D.Union}function CZ(w,z){return q.IsUnknown(w)?D.False:q.IsAny(w)?D.Union:q.IsNever(w)?D.True:D.False}function KZ(w,z){return q.IsObject(z)&&q8(z)?D.True:t0(z)?p0(w,z):!q.IsArray(z)?D.False:u2(R0(w.items,z.items))}function FZ(w,z){return t0(z)?p0(w,z):!q.IsAsyncIterator(z)?D.False:u2(R0(w.items,z.items))}function jZ(w,z){return t0(z)?p0(w,z):q.IsObject(z)?$2(w,z):q.IsRecord(z)?m2(w,z):q.IsBigInt(z)?D.True:D.False}function I9(w,z){return q.IsLiteralBoolean(w)?D.True:q.IsBoolean(w)?D.True:D.False}function EZ(w,z){return t0(z)?p0(w,z):q.IsObject(z)?$2(w,z):q.IsRecord(z)?m2(w,z):q.IsBoolean(z)?D.True:D.False}function IZ(w,z){return t0(z)?p0(w,z):q.IsObject(z)?$2(w,z):!q.IsConstructor(z)?D.False:w.parameters.length>z.parameters.length?D.False:!w.parameters.every((U,W)=>u2(R0(z.parameters[W],U))===D.True)?D.False:u2(R0(w.returns,z.returns))}function xZ(w,z){return t0(z)?p0(w,z):q.IsObject(z)?$2(w,z):q.IsRecord(z)?m2(w,z):q.IsDate(z)?D.True:D.False}function VZ(w,z){return t0(z)?p0(w,z):q.IsObject(z)?$2(w,z):!q.IsFunction(z)?D.False:w.parameters.length>z.parameters.length?D.False:!w.parameters.every((U,W)=>u2(R0(z.parameters[W],U))===D.True)?D.False:u2(R0(w.returns,z.returns))}function x9(w,z){return q.IsLiteral(w)&&H2.IsNumber(w.const)?D.True:q.IsNumber(w)||q.IsInteger(w)?D.True:D.False}function kZ(w,z){return q.IsInteger(z)||q.IsNumber(z)?D.True:t0(z)?p0(w,z):q.IsObject(z)?$2(w,z):q.IsRecord(z)?m2(w,z):D.False}function M8(w,z){return z.allOf.every((U)=>R0(w,U)===D.True)?D.True:D.False}function TZ(w,z){return w.allOf.some((U)=>R0(U,z)===D.True)?D.True:D.False}function gZ(w,z){return t0(z)?p0(w,z):!q.IsIterator(z)?D.False:u2(R0(w.items,z.items))}function fZ(w,z){return q.IsLiteral(z)&&z.const===w.const?D.True:t0(z)?p0(w,z):q.IsObject(z)?$2(w,z):q.IsRecord(z)?m2(w,z):q.IsString(z)?g9(w,z):q.IsNumber(z)?k9(w,z):q.IsInteger(z)?x9(w,z):q.IsBoolean(z)?I9(w,z):D.False}function V9(w,z){return D.False}function dZ(w,z){return D.True}function C9(w){let[z,U]=[w,0];while(!0){if(!q.IsNot(z))break;z=z.not,U+=1}return U%2===0?z:T1()}function hZ(w,z){return q.IsNot(w)?R0(C9(w),z):q.IsNot(z)?R0(w,C9(z)):i6("Invalid fallthrough for Not")}function yZ(w,z){return t0(z)?p0(w,z):q.IsObject(z)?$2(w,z):q.IsRecord(z)?m2(w,z):q.IsNull(z)?D.True:D.False}function k9(w,z){return q.IsLiteralNumber(w)?D.True:q.IsNumber(w)||q.IsInteger(w)?D.True:D.False}function cZ(w,z){return t0(z)?p0(w,z):q.IsObject(z)?$2(w,z):q.IsRecord(z)?m2(w,z):q.IsInteger(z)||q.IsNumber(z)?D.True:D.False}function b2(w,z){return Object.getOwnPropertyNames(w.properties).length===z}function K9(w){return q8(w)}function F9(w){return b2(w,0)||b2(w,1)&&"description"in w.properties&&q.IsUnion(w.properties.description)&&w.properties.description.anyOf.length===2&&(q.IsString(w.properties.description.anyOf[0])&&q.IsUndefined(w.properties.description.anyOf[1])||q.IsString(w.properties.description.anyOf[1])&&q.IsUndefined(w.properties.description.anyOf[0]))}function Aw(w){return b2(w,0)}function j9(w){return b2(w,0)}function iZ(w){return b2(w,0)}function vZ(w){return b2(w,0)}function nZ(w){return q8(w)}function uZ(w){let z=S1();return b2(w,0)||b2(w,1)&&"length"in w.properties&&u2(R0(w.properties.length,z))===D.True}function mZ(w){return b2(w,0)}function q8(w){let z=S1();return b2(w,0)||b2(w,1)&&"length"in w.properties&&u2(R0(w.properties.length,z))===D.True}function tZ(w){let z=L1([o1()],o1());return b2(w,0)||b2(w,1)&&"then"in w.properties&&u2(R0(w.properties.then,z))===D.True}function T9(w,z){return R0(w,z)===D.False?D.False:q.IsOptional(w)&&!q.IsOptional(z)?D.False:D.True}function $2(w,z){return q.IsUnknown(w)?D.False:q.IsAny(w)?D.Union:q.IsNever(w)||q.IsLiteralString(w)&&K9(z)||q.IsLiteralNumber(w)&&Aw(z)||q.IsLiteralBoolean(w)&&j9(z)||q.IsSymbol(w)&&F9(z)||q.IsBigInt(w)&&iZ(z)||q.IsString(w)&&K9(z)||q.IsSymbol(w)&&F9(z)||q.IsNumber(w)&&Aw(z)||q.IsInteger(w)&&Aw(z)||q.IsBoolean(w)&&j9(z)||q.IsUint8Array(w)&&nZ(z)||q.IsDate(w)&&vZ(z)||q.IsConstructor(w)&&mZ(z)||q.IsFunction(w)&&uZ(z)?D.True:q.IsRecord(w)&&q.IsString(Xw(w))?(()=>{return z[h2]==="Record"?D.True:D.False})():q.IsRecord(w)&&q.IsNumber(Xw(w))?(()=>{return b2(z,0)?D.True:D.False})():D.False}function pZ(w,z){return t0(z)?p0(w,z):q.IsRecord(z)?m2(w,z):!q.IsObject(z)?D.False:(()=>{for(let U of Object.getOwnPropertyNames(z.properties)){if(!(U in w.properties)&&!q.IsOptional(z.properties[U]))return D.False;if(q.IsOptional(z.properties[U]))return D.True;if(T9(w.properties[U],z.properties[U])===D.False)return D.False}return D.True})()}function oZ(w,z){return t0(z)?p0(w,z):q.IsObject(z)&&tZ(z)?D.True:!q.IsPromise(z)?D.False:u2(R0(w.item,z.item))}function Xw(w){return I1 in w.patternProperties?S1():(x1 in w.patternProperties)?c2():i6("Unknown record key pattern")}function Zw(w){return I1 in w.patternProperties?w.patternProperties[I1]:(x1 in w.patternProperties)?w.patternProperties[x1]:i6("Unable to get record value schema")}function m2(w,z){let[U,W]=[Xw(z),Zw(z)];return q.IsLiteralString(w)&&q.IsNumber(U)&&u2(R0(w,W))===D.True?D.True:q.IsUint8Array(w)&&q.IsNumber(U)?R0(w,W):q.IsString(w)&&q.IsNumber(U)?R0(w,W):q.IsArray(w)&&q.IsNumber(U)?R0(w,W):q.IsObject(w)?(()=>{for(let A of Object.getOwnPropertyNames(w.properties))if(T9(W,w.properties[A])===D.False)return D.False;return D.True})():D.False}function lZ(w,z){return t0(z)?p0(w,z):q.IsObject(z)?$2(w,z):!q.IsRecord(z)?D.False:R0(Zw(w),Zw(z))}function sZ(w,z){let U=q.IsRegExp(w)?c2():w,W=q.IsRegExp(z)?c2():z;return R0(U,W)}function g9(w,z){return q.IsLiteral(w)&&H2.IsString(w.const)?D.True:q.IsString(w)?D.True:D.False}function rZ(w,z){return t0(z)?p0(w,z):q.IsObject(z)?$2(w,z):q.IsRecord(z)?m2(w,z):q.IsString(z)?D.True:D.False}function aZ(w,z){return t0(z)?p0(w,z):q.IsObject(z)?$2(w,z):q.IsRecord(z)?m2(w,z):q.IsSymbol(z)?D.True:D.False}function eZ(w,z){return q.IsTemplateLiteral(w)?R0(G6(w),z):q.IsTemplateLiteral(z)?R0(w,G6(z)):i6("Invalid fallthrough for TemplateLiteral")}function w$(w,z){return q.IsArray(z)&&w.items!==void 0&&w.items.every((U)=>R0(U,z.items)===D.True)}function z$(w,z){return q.IsNever(w)?D.True:q.IsUnknown(w)?D.False:q.IsAny(w)?D.Union:D.False}function U$(w,z){return t0(z)?p0(w,z):q.IsObject(z)&&q8(z)?D.True:q.IsArray(z)&&w$(w,z)?D.True:!q.IsTuple(z)?D.False:H2.IsUndefined(w.items)&&!H2.IsUndefined(z.items)||!H2.IsUndefined(w.items)&&H2.IsUndefined(z.items)?D.False:H2.IsUndefined(w.items)&&!H2.IsUndefined(z.items)?D.True:w.items.every((U,W)=>R0(U,z.items[W])===D.True)?D.True:D.False}function W$(w,z){return t0(z)?p0(w,z):q.IsObject(z)?$2(w,z):q.IsRecord(z)?m2(w,z):q.IsUint8Array(z)?D.True:D.False}function A$(w,z){return t0(z)?p0(w,z):q.IsObject(z)?$2(w,z):q.IsRecord(z)?m2(w,z):q.IsVoid(z)?$$(w,z):q.IsUndefined(z)?D.True:D.False}function Qw(w,z){return z.anyOf.some((U)=>R0(w,U)===D.True)?D.True:D.False}function X$(w,z){return w.anyOf.every((U)=>R0(U,z)===D.True)?D.True:D.False}function f9(w,z){return D.True}function Z$(w,z){return q.IsNever(z)?V9(w,z):q.IsIntersect(z)?M8(w,z):q.IsUnion(z)?Qw(w,z):q.IsAny(z)?$w(w,z):q.IsString(z)?g9(w,z):q.IsNumber(z)?k9(w,z):q.IsInteger(z)?x9(w,z):q.IsBoolean(z)?I9(w,z):q.IsArray(z)?CZ(w,z):q.IsTuple(z)?z$(w,z):q.IsObject(z)?$2(w,z):q.IsUnknown(z)?D.True:D.False}function $$(w,z){return q.IsUndefined(w)?D.True:q.IsUndefined(w)?D.True:D.False}function Q$(w,z){return q.IsIntersect(z)?M8(w,z):q.IsUnion(z)?Qw(w,z):q.IsUnknown(z)?f9(w,z):q.IsAny(z)?$w(w,z):q.IsObject(z)?$2(w,z):q.IsVoid(z)?D.True:D.False}function R0(w,z){return q.IsTemplateLiteral(w)||q.IsTemplateLiteral(z)?eZ(w,z):q.IsRegExp(w)||q.IsRegExp(z)?sZ(w,z):q.IsNot(w)||q.IsNot(z)?hZ(w,z):q.IsAny(w)?RZ(w,z):q.IsArray(w)?KZ(w,z):q.IsBigInt(w)?jZ(w,z):q.IsBoolean(w)?EZ(w,z):q.IsAsyncIterator(w)?FZ(w,z):q.IsConstructor(w)?IZ(w,z):q.IsDate(w)?xZ(w,z):q.IsFunction(w)?VZ(w,z):q.IsInteger(w)?kZ(w,z):q.IsIntersect(w)?TZ(w,z):q.IsIterator(w)?gZ(w,z):q.IsLiteral(w)?fZ(w,z):q.IsNever(w)?dZ(w,z):q.IsNull(w)?yZ(w,z):q.IsNumber(w)?cZ(w,z):q.IsObject(w)?pZ(w,z):q.IsRecord(w)?lZ(w,z):q.IsString(w)?rZ(w,z):q.IsSymbol(w)?aZ(w,z):q.IsTuple(w)?U$(w,z):q.IsPromise(w)?oZ(w,z):q.IsUint8Array(w)?W$(w,z):q.IsUndefined(w)?A$(w,z):q.IsUnion(w)?X$(w,z):q.IsUnknown(w)?Z$(w,z):q.IsVoid(w)?Q$(w,z):i6(`Unknown left type operand '${w[N]}'`)}function s1(w,z){return R0(w,z)}function Y$(w,z,U,W,A){let X={};for(let Z of globalThis.Object.getOwnPropertyNames(w))X[Z]=v6(w[Z],z,U,W,k0(A));return X}function J$(w,z,U,W,A){return Y$(w.properties,z,U,W,A)}function d9(w,z,U,W,A){let X=J$(w,z,U,W,A);return Y0(X)}function B$(w,z,U,W){let A=s1(w,z);return A===D.Union?G0([U,W]):A===D.True?U:W}function v6(w,z,U,W,A){return g0(w)?d9(w,z,U,W,A):k2(w)?P(h9(w,z,U,W,A)):P(B$(w,z,U,W),A)}function M$(w,z,U,W,A){return{[w]:v6(X0(w),z,U,W,k0(A))}}function q$(w,z,U,W,A){return w.reduce((X,Z)=>{return{...X,...M$(Z,z,U,W,A)}},{})}function H$(w,z,U,W,A){return q$(w.keys,z,U,W,A)}function h9(w,z,U,W,A){let X=H$(w,z,U,W,A);return Y0(X)}function G$(w){return w.allOf.every((z)=>g1(z))}function L$(w){return w.anyOf.some((z)=>g1(z))}function N$(w){return!g1(w.not)}function g1(w){return w[N]==="Intersect"?G$(w):w[N]==="Union"?L$(w):w[N]==="Not"?N$(w):w[N]==="Undefined"?!0:!1}function y9(w,z){return n6(G6(w),z)}function S$(w,z){let U=w.filter((W)=>s1(W,z)===D.False);return U.length===1?U[0]:G0(U)}function n6(w,z,U={}){if(T2(w))return P(y9(w,z),U);if(g0(w))return P(c9(w,z),U);return P(q0(w)?S$(w.anyOf,z):s1(w,z)!==D.False?H0():w,U)}function _$(w,z){let U={};for(let W of globalThis.Object.getOwnPropertyNames(w))U[W]=n6(w[W],z);return U}function D$(w,z){return _$(w.properties,z)}function c9(w,z){let U=D$(w,z);return Y0(U)}function i9(w,z){return u6(G6(w),z)}function P$(w,z){let U=w.filter((W)=>s1(W,z)!==D.False);return U.length===1?U[0]:G0(U)}function u6(w,z,U){if(T2(w))return P(i9(w,z),U);if(g0(w))return P(v9(w,z),U);return P(q0(w)?P$(w.anyOf,z):s1(w,z)!==D.False?w:H0(),U)}function O$(w,z){let U={};for(let W of globalThis.Object.getOwnPropertyNames(w))U[W]=u6(w[W],z);return U}function b$(w,z){return O$(w.properties,z)}function v9(w,z){let U=b$(w,z);return Y0(U)}function n9(w,z){return P(w.returns,z)}function u9(w){return P({[N]:"Integer",type:"integer"},w)}function R$(w,z,U){return{[w]:U1(X0(w),z,k0(U))}}function C$(w,z,U){return w.reduce((A,X)=>{return{...A,...R$(X,z,U)}},{})}function K$(w,z,U){return C$(w.keys,z,U)}function m9(w,z,U){let W=K$(w,z,U);return Y0(W)}function F$(w){let[z,U]=[w.slice(0,1),w.slice(1)];return[z.toLowerCase(),U].join("")}function j$(w){let[z,U]=[w.slice(0,1),w.slice(1)];return[z.toUpperCase(),U].join("")}function E$(w){return w.toUpperCase()}function I$(w){return w.toLowerCase()}function x$(w,z,U){let W=g6(w.pattern);if(!H6(W))return{...w,pattern:t9(w.pattern,z)};let Z=[...D4(W)].map((Y)=>X0(Y)),$=p9(Z,z),Q=G0($);return U8([Q],U)}function t9(w,z){return typeof w==="string"?z==="Uncapitalize"?F$(w):z==="Capitalize"?j$(w):z==="Uppercase"?E$(w):z==="Lowercase"?I$(w):w:w.toString()}function p9(w,z){return w.map((U)=>U1(U,z))}function U1(w,z,U={}){return k2(w)?m9(w,z,U):T2(w)?x$(w,z,U):q0(w)?G0(p9(w.anyOf,z),U):E1(w)?X0(t9(w.const,z),U):P(w,U)}function o9(w,z={}){return U1(w,"Capitalize",z)}function l9(w,z={}){return U1(w,"Lowercase",z)}function s9(w,z={}){return U1(w,"Uncapitalize",z)}function r9(w,z={}){return U1(w,"Uppercase",z)}function V$(w,z,U){let W={};for(let A of globalThis.Object.getOwnPropertyNames(w))W[A]=r1(w[A],z,k0(U));return W}function k$(w,z,U){return V$(w.properties,z,U)}function a9(w,z,U){let W=k$(w,z,U);return Y0(W)}function T$(w,z){return w.map((U)=>Yw(U,z))}function g$(w,z){return w.map((U)=>Yw(U,z))}function f$(w,z){let{[z]:U,...W}=w;return W}function d$(w,z){return z.reduce((U,W)=>f$(U,W),w)}function h$(w,z){let U=c0(w,[F0,"$id","required","properties"]),W=d$(w.properties,z);return _0(W,U)}function y$(w){let z=w.reduce((U,W)=>r4(W)?[...U,X0(W)]:U,[]);return G0(z)}function Yw(w,z){return m0(w)?Z2(T$(w.allOf,z)):q0(w)?G0(g$(w.anyOf,z)):r0(w)?h$(w,z):_0({})}function r1(w,z,U){let W=u0(z)?y$(z):z,A=d0(z)?D2(z):z,X=h0(w),Z=h0(z);return g0(w)?a9(w,A,U):k2(z)?e9(w,z,U):X&&Z?N0("Omit",[w,W],U):!X&&Z?N0("Omit",[w,W],U):X&&!Z?N0("Omit",[w,W],U):P({...Yw(w,A),...U})}function c$(w,z,U){return{[z]:r1(w,[z],k0(U))}}function i$(w,z,U){return z.reduce((W,A)=>{return{...W,...c$(w,A,U)}},{})}function v$(w,z,U){return i$(w,z.keys,U)}function e9(w,z,U){let W=v$(w,z,U);return Y0(W)}function n$(w,z,U){let W={};for(let A of globalThis.Object.getOwnPropertyNames(w))W[A]=a1(w[A],z,k0(U));return W}function u$(w,z,U){return n$(w.properties,z,U)}function w7(w,z,U){let W=u$(w,z,U);return Y0(W)}function m$(w,z){return w.map((U)=>Jw(U,z))}function t$(w,z){return w.map((U)=>Jw(U,z))}function p$(w,z){let U={};for(let W of z)if(W in w)U[W]=w[W];return U}function o$(w,z){let U=c0(w,[F0,"$id","required","properties"]),W=p$(w.properties,z);return _0(W,U)}function l$(w){let z=w.reduce((U,W)=>r4(W)?[...U,X0(W)]:U,[]);return G0(z)}function Jw(w,z){return m0(w)?Z2(m$(w.allOf,z)):q0(w)?G0(t$(w.anyOf,z)):r0(w)?o$(w,z):_0({})}function a1(w,z,U){let W=u0(z)?l$(z):z,A=d0(z)?D2(z):z,X=h0(w),Z=h0(z);return g0(w)?w7(w,A,U):k2(z)?z7(w,z,U):X&&Z?N0("Pick",[w,W],U):!X&&Z?N0("Pick",[w,W],U):X&&!Z?N0("Pick",[w,W],U):P({...Jw(w,A),...U})}function s$(w,z,U){return{[z]:a1(w,[z],k0(U))}}function r$(w,z,U){return z.reduce((W,A)=>{return{...W,...s$(w,A,U)}},{})}function a$(w,z,U){return r$(w,z.keys,U)}function z7(w,z,U){let W=a$(w,z,U);return Y0(W)}function e$(w,z){return N0("Partial",[N0(w,z)])}function wQ(w){return N0("Partial",[P2(w)])}function zQ(w){let z={};for(let U of globalThis.Object.getOwnPropertyNames(w))z[U]=_2(w[U]);return z}function UQ(w){let z=c0(w,[F0,"$id","required","properties"]),U=zQ(w.properties);return _0(U,z)}function U7(w){return w.map((z)=>W7(z))}function W7(w){return S2(w)?e$(w.target,w.parameters):h0(w)?wQ(w.$ref):m0(w)?Z2(U7(w.allOf)):q0(w)?G0(U7(w.anyOf)):r0(w)?UQ(w):_0({})}function m6(w,z){if(g0(w))return A7(w,z);else return P({...W7(w),...z})}function WQ(w,z){let U={};for(let W of globalThis.Object.getOwnPropertyNames(w))U[W]=m6(w[W],k0(z));return U}function AQ(w,z){return WQ(w.properties,z)}function A7(w,z){let U=AQ(w,z);return Y0(U)}function L6(w,z,U){return P({[N]:"Record",type:"object",patternProperties:{[w]:z}},U)}function Bw(w,z,U){let W={};for(let A of w)W[A]=z;return _0(W,{...U,[h2]:"Record"})}function XQ(w,z,U){return w8(w)?Bw(D2(w),z,U):L6(w.pattern,z,U)}function ZQ(w,z,U){return Bw(D2(G0(w)),z,U)}function $Q(w,z,U){return Bw([w.toString()],z,U)}function QQ(w,z,U){return L6(w.source,z,U)}function YQ(w,z,U){let W=s0(w.pattern)?x1:w.pattern;return L6(W,z,U)}function JQ(w,z,U){return L6(x1,z,U)}function BQ(w,z,U){return L6(lz,z,U)}function MQ(w,z,U){return L6(I1,z,U)}function qQ(w,z,U){return L6(I1,z,U)}function H8(w,z,U={}){return S2(z)?N0("Record",[w,N0(z.target,z.parameters)],U):S2(w)?N0("Record",[N0(z.target,z.parameters),z],U):h0(w)?N0("Record",[P2(w.$ref),z]):q0(w)?ZQ(w.anyOf,z,U):T2(w)?XQ(w,z,U):E1(w)?$Q(w.const,z,U):M6(w)?MQ(w,z,U):q6(w)?qQ(w,z,U):o5(w)?QQ(w,z,U):H4(w)?YQ(w,z,U):u5(w)?JQ(w,z,U):t1(w)?BQ(w,z,U):H0(U)}function HQ(w,z){return N0("Required",[N0(w,z)])}function GQ(w){return N0("Required",[P2(w)])}function LQ(w){let z={};for(let U of globalThis.Object.getOwnPropertyNames(w))z[U]=c0(w[U],[X2]);return z}function NQ(w){let z=c0(w,[F0,"$id","required","properties"]),U=LQ(w.properties);return _0(U,z)}function X7(w){return w.map((z)=>Z7(z))}function Z7(w){return S2(w)?HQ(w.target,w.parameters):h0(w)?GQ(w.$ref):m0(w)?Z2(X7(w.allOf)):q0(w)?G0(X7(w.anyOf)):r0(w)?NQ(w):_0({})}function t6(w,z){if(g0(w))return $7(w,z);else return P({...Z7(w),...z})}function SQ(w,z){let U={};for(let W of globalThis.Object.getOwnPropertyNames(w))U[W]=t6(w[W],z);return U}function _Q(w,z){return SQ(w.properties,z)}function $7(w,z){let U=_Q(w,z);return Y0(U)}function DQ(w,z){return z.map((U)=>{return h0(U)?Q7(w,U.$ref):t2(w,U)})}function Q7(w,z){return z in w?h0(w[z])?Q7(w,w[z].$ref):t2(w,w[z]):H0()}function PQ(w){return y6(w[0])}function OQ(w){return l1(w[0],w[1])}function bQ(w){return c6(w[0])}function RQ(w){return m6(w[0])}function CQ(w){return r1(w[0],w[1])}function KQ(w){return a1(w[0],w[1])}function FQ(w){return H8(w[0],w[1])}function jQ(w){return t6(w[0])}function EQ(w,z,U){let W=DQ(w,U);return z==="Awaited"?PQ(W):z==="Index"?OQ(W):z==="KeyOf"?bQ(W):z==="Partial"?RQ(W):z==="Omit"?CQ(W):z==="Pick"?KQ(W):z==="Record"?FQ(W):z==="Required"?jQ(W):H0()}function IQ(w,z){return _0(globalThis.Object.keys(z).reduce((U,W)=>{return{...U,[W]:t2(w,z[W])}},{}))}function xQ(w,z,U){return k6(R4(w,z),t2(w,U))}function VQ(w,z,U){return L1(R4(w,z),t2(w,U))}function kQ(w,z){return v2(R4(w,z))}function TQ(w,z){return Z2(R4(w,z))}function gQ(w,z){return G0(R4(w,z))}function fQ(w,z){return x6(t2(w,z))}function dQ(w,z){return V6(t2(w,z))}function hQ(w,z){return h6(t2(w,z))}function R4(w,z){return z.map((U)=>t2(w,U))}function t2(w,z){return y2(z)?P(t2(w,c0(z,[X2])),z):s4(z)?P(t2(w,c0(z,[w1])),z):j1(z)?P(fQ(w,z.items),z):Y4(z)?P(dQ(w,z.items),z):S2(z)?P(EQ(w,z.target,z.parameters)):J4(z)?P(xQ(w,z.parameters,z.returns),z):B4(z)?P(VQ(w,z.parameters,z.returns),z):m0(z)?P(TQ(w,z.allOf),z):M4(z)?P(hQ(w,z.items),z):r0(z)?P(IQ(w,z.properties),z):z1(z)?P(kQ(w,z.items||[]),z):q0(z)?P(gQ(w,z.anyOf),z):z}function yQ(w,z){return z in w?t2(w,w[z]):H0()}function Y7(w){return globalThis.Object.getOwnPropertyNames(w).reduce((z,U)=>{return{...z,[U]:yQ(w,U)}},{})}class J7{constructor(w){let z=Y7(w),U=this.WithIdentifiers(z);this.$defs=U}Import(w,z){let U={...this.$defs,[w]:P(this.$defs[w],z)};return P({[N]:"Import",$defs:U,$ref:w})}WithIdentifiers(w){return globalThis.Object.getOwnPropertyNames(w).reduce((z,U)=>{return{...z,[U]:{...w[U],$id:U}}},{})}}function B7(w){return new J7(w)}function M7(w,z){return P({[N]:"Not",not:w},z)}function q7(w,z){return v2(w.parameters,z)}function H7(w){return i2(_2(w))}var cQ=0;function G7(w,z={}){if(s0(z.$id))z.$id=`T${cQ++}`;let U=zz(w({[N]:"This",$ref:`${z.$id}`}));return U.$id=z.$id,P({[h2]:"Recursive",...U},z)}function L7(w,z){let U=E0(w)?new globalThis.RegExp(w):w;return P({[N]:"RegExp",type:"RegExp",source:U.source,flags:U.flags},z)}function iQ(w){return m0(w)?w.allOf:q0(w)?w.anyOf:z1(w)?w.items??[]:[]}function N7(w){return iQ(w)}function S7(w,z){return P(w.returns,z)}class _7{constructor(w){this.schema=w}Decode(w){return new D7(this.schema,w)}}class D7{constructor(w,z){this.schema=w,this.decode=z}EncodeTransform(w,z){let A={Encode:(X)=>z[F0].Encode(w(X)),Decode:(X)=>this.decode(z[F0].Decode(X))};return{...z,[F0]:A}}EncodeSchema(w,z){let U={Decode:this.decode,Encode:w};return{...z,[F0]:U}}Encode(w){return S0(this.schema)?this.EncodeTransform(w,this.schema):this.EncodeSchema(w,this.schema)}}function P7(w){return new _7(w)}function G8(w={}){return P({[N]:w[N]??"Unsafe"},w)}function O7(w){return P({[N]:"Void",type:"void"},w)}var Mw={};J6(Mw,{Void:()=>O7,Uppercase:()=>r9,Unsafe:()=>G8,Unknown:()=>T1,Union:()=>G0,Undefined:()=>Y8,Uncapitalize:()=>s9,Uint8Array:()=>J8,Tuple:()=>v2,Transform:()=>P7,TemplateLiteral:()=>U8,Symbol:()=>Q8,String:()=>c2,ReturnType:()=>S7,Rest:()=>N7,Required:()=>t6,RegExp:()=>L7,Ref:()=>P2,Recursive:()=>G7,Record:()=>H8,ReadonlyOptional:()=>H7,Readonly:()=>i2,Promise:()=>A8,Pick:()=>a1,Partial:()=>m6,Parameters:()=>q7,Optional:()=>_2,Omit:()=>r1,Object:()=>_0,Number:()=>S1,Null:()=>$8,Not:()=>M7,Never:()=>H0,Module:()=>B7,Mapped:()=>G9,Lowercase:()=>l9,Literal:()=>X0,KeyOf:()=>c6,Iterator:()=>h6,Intersect:()=>Z2,Integer:()=>u9,InstanceType:()=>n9,Index:()=>l1,Function:()=>L1,Extract:()=>u6,Extends:()=>v6,Exclude:()=>n6,Enum:()=>R9,Date:()=>Z8,ConstructorParameters:()=>b9,Constructor:()=>k6,Const:()=>O9,Composite:()=>P9,Capitalize:()=>o9,Boolean:()=>z8,BigInt:()=>d6,Awaited:()=>y6,AsyncIterator:()=>V6,Array:()=>x6,Any:()=>o1});var N6=Mw;class b7 extends y{constructor(w){super(`Duplicate type kind '${w}' detected`)}}class R7 extends y{constructor(w){super(`Duplicate string format '${w}' detected`)}}var f1;(function(w){function z(W,A){if(y0.Has(W))throw new b7(W);return y0.Set(W,A),(X={})=>G8({...X,[N]:W})}w.Type=z;function U(W,A){if(b0.Has(W))throw new R7(W);return b0.Set(W,A),W}w.Format=U})(f1||(f1={}));function vQ(w){switch(w.errorType){case S.ArrayContains:return"Expected array to contain at least one matching value";case S.ArrayMaxContains:return`Expected array to contain no more than ${w.schema.maxContains} matching values`;case S.ArrayMinContains:return`Expected array to contain at least ${w.schema.minContains} matching values`;case S.ArrayMaxItems:return`Expected array length to be less or equal to ${w.schema.maxItems}`;case S.ArrayMinItems:return`Expected array length to be greater or equal to ${w.schema.minItems}`;case S.ArrayUniqueItems:return"Expected array elements to be unique";case S.Array:return"Expected array";case S.AsyncIterator:return"Expected AsyncIterator";case S.BigIntExclusiveMaximum:return`Expected bigint to be less than ${w.schema.exclusiveMaximum}`;case S.BigIntExclusiveMinimum:return`Expected bigint to be greater than ${w.schema.exclusiveMinimum}`;case S.BigIntMaximum:return`Expected bigint to be less or equal to ${w.schema.maximum}`;case S.BigIntMinimum:return`Expected bigint to be greater or equal to ${w.schema.minimum}`;case S.BigIntMultipleOf:return`Expected bigint to be a multiple of ${w.schema.multipleOf}`;case S.BigInt:return"Expected bigint";case S.Boolean:return"Expected boolean";case S.DateExclusiveMinimumTimestamp:return`Expected Date timestamp to be greater than ${w.schema.exclusiveMinimumTimestamp}`;case S.DateExclusiveMaximumTimestamp:return`Expected Date timestamp to be less than ${w.schema.exclusiveMaximumTimestamp}`;case S.DateMinimumTimestamp:return`Expected Date timestamp to be greater or equal to ${w.schema.minimumTimestamp}`;case S.DateMaximumTimestamp:return`Expected Date timestamp to be less or equal to ${w.schema.maximumTimestamp}`;case S.DateMultipleOfTimestamp:return`Expected Date timestamp to be a multiple of ${w.schema.multipleOfTimestamp}`;case S.Date:return"Expected Date";case S.Function:return"Expected function";case S.IntegerExclusiveMaximum:return`Expected integer to be less than ${w.schema.exclusiveMaximum}`;case S.IntegerExclusiveMinimum:return`Expected integer to be greater than ${w.schema.exclusiveMinimum}`;case S.IntegerMaximum:return`Expected integer to be less or equal to ${w.schema.maximum}`;case S.IntegerMinimum:return`Expected integer to be greater or equal to ${w.schema.minimum}`;case S.IntegerMultipleOf:return`Expected integer to be a multiple of ${w.schema.multipleOf}`;case S.Integer:return"Expected integer";case S.IntersectUnevaluatedProperties:return"Unexpected property";case S.Intersect:return"Expected all values to match";case S.Iterator:return"Expected Iterator";case S.Literal:return`Expected ${typeof w.schema.const==="string"?`'${w.schema.const}'`:w.schema.const}`;case S.Never:return"Never";case S.Not:return"Value should not match";case S.Null:return"Expected null";case S.NumberExclusiveMaximum:return`Expected number to be less than ${w.schema.exclusiveMaximum}`;case S.NumberExclusiveMinimum:return`Expected number to be greater than ${w.schema.exclusiveMinimum}`;case S.NumberMaximum:return`Expected number to be less or equal to ${w.schema.maximum}`;case S.NumberMinimum:return`Expected number to be greater or equal to ${w.schema.minimum}`;case S.NumberMultipleOf:return`Expected number to be a multiple of ${w.schema.multipleOf}`;case S.Number:return"Expected number";case S.Object:return"Expected object";case S.ObjectAdditionalProperties:return"Unexpected property";case S.ObjectMaxProperties:return`Expected object to have no more than ${w.schema.maxProperties} properties`;case S.ObjectMinProperties:return`Expected object to have at least ${w.schema.minProperties} properties`;case S.ObjectRequiredProperty:return"Expected required property";case S.Promise:return"Expected Promise";case S.RegExp:return"Expected string to match regular expression";case S.StringFormatUnknown:return`Unknown format '${w.schema.format}'`;case S.StringFormat:return`Expected string to match '${w.schema.format}' format`;case S.StringMaxLength:return`Expected string length less or equal to ${w.schema.maxLength}`;case S.StringMinLength:return`Expected string length greater or equal to ${w.schema.minLength}`;case S.StringPattern:return`Expected string to match '${w.schema.pattern}'`;case S.String:return"Expected string";case S.Symbol:return"Expected symbol";case S.TupleLength:return`Expected tuple to have ${w.schema.maxItems||0} elements`;case S.Tuple:return"Expected tuple";case S.Uint8ArrayMaxByteLength:return`Expected byte length less or equal to ${w.schema.maxByteLength}`;case S.Uint8ArrayMinByteLength:return`Expected byte length greater or equal to ${w.schema.minByteLength}`;case S.Uint8Array:return"Expected Uint8Array";case S.Undefined:return"Expected undefined";case S.Union:return"Expected union value";case S.Void:return"Expected void";case S.Kind:return`Expected kind '${w.schema[N]}'`;default:return"Unknown error type"}}var nQ=vQ;function C7(){return nQ}class K7 extends y{constructor(w){super(`Unable to dereference schema with $id '${w.$ref}'`);this.schema=w}}function uQ(w,z){let U=z.find((W)=>W.$id===w.$ref);if(U===void 0)throw new K7(w);return J0(U,z)}function e0(w,z){if(!$0(w.$id)||z.some((U)=>U.$id===w.$id))return z;return z.push(w),z}function J0(w,z){return w[N]==="This"||w[N]==="Ref"?uQ(w,z):w}class F7 extends y{constructor(w){super("Unable to hash value");this.value=w}}var g2;(function(w){w[w.Undefined=0]="Undefined",w[w.Null=1]="Null",w[w.Boolean=2]="Boolean",w[w.Number=3]="Number",w[w.String=4]="String",w[w.Object=5]="Object",w[w.Array=6]="Array",w[w.Date=7]="Date",w[w.Uint8Array=8]="Uint8Array",w[w.Symbol=9]="Symbol",w[w.BigInt=10]="BigInt"})(g2||(g2={}));var p6=BigInt("14695981039346656037"),[mQ,tQ]=[BigInt("1099511628211"),BigInt("18446744073709551616")],pQ=Array.from({length:256}).map((w,z)=>BigInt(z)),j7=new Float64Array(1),E7=new DataView(j7.buffer),I7=new Uint8Array(j7.buffer);function*oQ(w){let z=w===0?1:Math.ceil(Math.floor(Math.log2(w)+1)/8);for(let U=0;U<z;U++)yield w>>8*(z-1-U)&255}function lQ(w){Q2(g2.Array);for(let z of w)o6(z)}function sQ(w){Q2(g2.Boolean),Q2(w?1:0)}function rQ(w){Q2(g2.BigInt),E7.setBigInt64(0,w);for(let z of I7)Q2(z)}function aQ(w){Q2(g2.Date),o6(w.getTime())}function eQ(w){Q2(g2.Null)}function wY(w){Q2(g2.Number),E7.setFloat64(0,w);for(let z of I7)Q2(z)}function zY(w){Q2(g2.Object);for(let z of globalThis.Object.getOwnPropertyNames(w).sort())o6(z),o6(w[z])}function UY(w){Q2(g2.String);for(let z=0;z<w.length;z++)for(let U of oQ(w.charCodeAt(z)))Q2(U)}function WY(w){Q2(g2.Symbol),o6(w.description)}function AY(w){Q2(g2.Uint8Array);for(let z=0;z<w.length;z++)Q2(w[z])}function XY(w){return Q2(g2.Undefined)}function o6(w){if(n(w))return lQ(w);if(G1(w))return sQ(w);if(A2(w))return rQ(w);if(G2(w))return aQ(w);if(K1(w))return eQ(w);if(d(w))return wY(w);if(s(w))return zY(w);if($0(w))return UY(w);if(F1(w))return WY(w);if(j6(w))return AY(w);if(T0(w))return XY(w);throw new F7(w)}function Q2(w){p6=p6^pQ[w],p6=p6*mQ%tQ}function e1(w){return p6=BigInt("14695981039346656037"),o6(w),p6}class x7 extends y{constructor(w){super("Unknown type");this.schema=w}}function ZY(w){return w[N]==="Any"||w[N]==="Unknown"}function z0(w){return w!==void 0}function $Y(w,z,U){return!0}function QY(w,z,U){if(!n(U))return!1;if(z0(w.minItems)&&!(U.length>=w.minItems))return!1;if(z0(w.maxItems)&&!(U.length<=w.maxItems))return!1;if(!U.every((X)=>w2(w.items,z,X)))return!1;if(w.uniqueItems===!0&&!function(){let X=new Set;for(let Z of U){let $=e1(Z);if(X.has($))return!1;else X.add($)}return!0}())return!1;if(!(z0(w.contains)||d(w.minContains)||d(w.maxContains)))return!0;let W=z0(w.contains)?w.contains:H0(),A=U.reduce((X,Z)=>w2(W,z,Z)?X+1:X,0);if(A===0)return!1;if(d(w.minContains)&&A<w.minContains)return!1;if(d(w.maxContains)&&A>w.maxContains)return!1;return!0}function YY(w,z,U){return t4(U)}function JY(w,z,U){if(!A2(U))return!1;if(z0(w.exclusiveMaximum)&&!(U<w.exclusiveMaximum))return!1;if(z0(w.exclusiveMinimum)&&!(U>w.exclusiveMinimum))return!1;if(z0(w.maximum)&&!(U<=w.maximum))return!1;if(z0(w.minimum)&&!(U>=w.minimum))return!1;if(z0(w.multipleOf)&&U%w.multipleOf!==BigInt(0))return!1;return!0}function BY(w,z,U){return G1(U)}function MY(w,z,U){return w2(w.returns,z,U.prototype)}function qY(w,z,U){if(!G2(U))return!1;if(z0(w.exclusiveMaximumTimestamp)&&!(U.getTime()<w.exclusiveMaximumTimestamp))return!1;if(z0(w.exclusiveMinimumTimestamp)&&!(U.getTime()>w.exclusiveMinimumTimestamp))return!1;if(z0(w.maximumTimestamp)&&!(U.getTime()<=w.maximumTimestamp))return!1;if(z0(w.minimumTimestamp)&&!(U.getTime()>=w.minimumTimestamp))return!1;if(z0(w.multipleOfTimestamp)&&U.getTime()%w.multipleOfTimestamp!==0)return!1;return!0}function HY(w,z,U){return m1(U)}function GY(w,z,U){let W=globalThis.Object.values(w.$defs),A=w.$defs[w.$ref];return w2(A,[...z,...W],U)}function LY(w,z,U){if(!l4(U))return!1;if(z0(w.exclusiveMaximum)&&!(U<w.exclusiveMaximum))return!1;if(z0(w.exclusiveMinimum)&&!(U>w.exclusiveMinimum))return!1;if(z0(w.maximum)&&!(U<=w.maximum))return!1;if(z0(w.minimum)&&!(U>=w.minimum))return!1;if(z0(w.multipleOf)&&U%w.multipleOf!==0)return!1;return!0}function NY(w,z,U){let W=w.allOf.every((A)=>w2(A,z,U));if(w.unevaluatedProperties===!1){let A=new RegExp(k1(w)),X=Object.getOwnPropertyNames(U).every((Z)=>A.test(Z));return W&&X}else if(d0(w.unevaluatedProperties)){let A=new RegExp(k1(w)),X=Object.getOwnPropertyNames(U).every((Z)=>A.test(Z)||w2(w.unevaluatedProperties,z,U[Z]));return W&&X}else return W}function SY(w,z,U){return p4(U)}function _Y(w,z,U){return U===w.const}function DY(w,z,U){return!1}function PY(w,z,U){return!w2(w.not,z,U)}function OY(w,z,U){return K1(U)}function bY(w,z,U){if(!V0.IsNumberLike(U))return!1;if(z0(w.exclusiveMaximum)&&!(U<w.exclusiveMaximum))return!1;if(z0(w.exclusiveMinimum)&&!(U>w.exclusiveMinimum))return!1;if(z0(w.minimum)&&!(U>=w.minimum))return!1;if(z0(w.maximum)&&!(U<=w.maximum))return!1;if(z0(w.multipleOf)&&U%w.multipleOf!==0)return!1;return!0}function RY(w,z,U){if(!V0.IsObjectLike(U))return!1;if(z0(w.minProperties)&&!(Object.getOwnPropertyNames(U).length>=w.minProperties))return!1;if(z0(w.maxProperties)&&!(Object.getOwnPropertyNames(U).length<=w.maxProperties))return!1;let W=Object.getOwnPropertyNames(w.properties);for(let A of W){let X=w.properties[A];if(w.required&&w.required.includes(A)){if(!w2(X,z,U[A]))return!1;if((g1(X)||ZY(X))&&!(A in U))return!1}else if(V0.IsExactOptionalProperty(U,A)&&!w2(X,z,U[A]))return!1}if(w.additionalProperties===!1){let A=Object.getOwnPropertyNames(U);if(w.required&&w.required.length===W.length&&A.length===W.length)return!0;else return A.every((X)=>W.includes(X))}else if(typeof w.additionalProperties==="object")return Object.getOwnPropertyNames(U).every((X)=>W.includes(X)||w2(w.additionalProperties,z,U[X]));else return!0}function CY(w,z,U){return o4(U)}function KY(w,z,U){if(!V0.IsRecordLike(U))return!1;if(z0(w.minProperties)&&!(Object.getOwnPropertyNames(U).length>=w.minProperties))return!1;if(z0(w.maxProperties)&&!(Object.getOwnPropertyNames(U).length<=w.maxProperties))return!1;let[W,A]=Object.entries(w.patternProperties)[0],X=new RegExp(W),Z=Object.entries(U).every(([Y,B])=>{return X.test(Y)?w2(A,z,B):!0}),$=typeof w.additionalProperties==="object"?Object.entries(U).every(([Y,B])=>{return!X.test(Y)?w2(w.additionalProperties,z,B):!0}):!0,Q=w.additionalProperties===!1?Object.getOwnPropertyNames(U).every((Y)=>{return X.test(Y)}):!0;return Z&&$&&Q}function FY(w,z,U){return w2(J0(w,z),z,U)}function jY(w,z,U){let W=new RegExp(w.source,w.flags);if(z0(w.minLength)){if(!(U.length>=w.minLength))return!1}if(z0(w.maxLength)){if(!(U.length<=w.maxLength))return!1}return W.test(U)}function EY(w,z,U){if(!$0(U))return!1;if(z0(w.minLength)){if(!(U.length>=w.minLength))return!1}if(z0(w.maxLength)){if(!(U.length<=w.maxLength))return!1}if(z0(w.pattern)){if(!new RegExp(w.pattern).test(U))return!1}if(z0(w.format)){if(!b0.Has(w.format))return!1;return b0.Get(w.format)(U)}return!0}function IY(w,z,U){return F1(U)}function xY(w,z,U){return $0(U)&&new RegExp(w.pattern).test(U)}function VY(w,z,U){return w2(J0(w,z),z,U)}function kY(w,z,U){if(!n(U))return!1;if(w.items===void 0&&U.length!==0)return!1;if(U.length!==w.maxItems)return!1;if(!w.items)return!0;for(let W=0;W<w.items.length;W++)if(!w2(w.items[W],z,U[W]))return!1;return!0}function TY(w,z,U){return T0(U)}function gY(w,z,U){return w.anyOf.some((W)=>w2(W,z,U))}function fY(w,z,U){if(!j6(U))return!1;if(z0(w.maxByteLength)&&!(U.length<=w.maxByteLength))return!1;if(z0(w.minByteLength)&&!(U.length>=w.minByteLength))return!1;return!0}function dY(w,z,U){return!0}function hY(w,z,U){return V0.IsVoidLike(U)}function yY(w,z,U){if(!y0.Has(w[N]))return!1;return y0.Get(w[N])(w,U)}function w2(w,z,U){let W=z0(w.$id)?e0(w,z):z,A=w;switch(A[N]){case"Any":return $Y(A,W,U);case"Array":return QY(A,W,U);case"AsyncIterator":return YY(A,W,U);case"BigInt":return JY(A,W,U);case"Boolean":return BY(A,W,U);case"Constructor":return MY(A,W,U);case"Date":return qY(A,W,U);case"Function":return HY(A,W,U);case"Import":return GY(A,W,U);case"Integer":return LY(A,W,U);case"Intersect":return NY(A,W,U);case"Iterator":return SY(A,W,U);case"Literal":return _Y(A,W,U);case"Never":return DY(A,W,U);case"Not":return PY(A,W,U);case"Null":return OY(A,W,U);case"Number":return bY(A,W,U);case"Object":return RY(A,W,U);case"Promise":return CY(A,W,U);case"Record":return KY(A,W,U);case"Ref":return FY(A,W,U);case"RegExp":return jY(A,W,U);case"String":return EY(A,W,U);case"Symbol":return IY(A,W,U);case"TemplateLiteral":return xY(A,W,U);case"This":return VY(A,W,U);case"Tuple":return kY(A,W,U);case"Undefined":return TY(A,W,U);case"Union":return gY(A,W,U);case"Uint8Array":return fY(A,W,U);case"Unknown":return dY(A,W,U);case"Void":return hY(A,W,U);default:if(!y0.Has(A[N]))throw new x7(A);return yY(A,W,U)}}function r(...w){return w.length===3?w2(w[0],w[1],w[2]):w2(w[0],[],w[1])}var S;(function(w){w[w.ArrayContains=0]="ArrayContains",w[w.ArrayMaxContains=1]="ArrayMaxContains",w[w.ArrayMaxItems=2]="ArrayMaxItems",w[w.ArrayMinContains=3]="ArrayMinContains",w[w.ArrayMinItems=4]="ArrayMinItems",w[w.ArrayUniqueItems=5]="ArrayUniqueItems",w[w.Array=6]="Array",w[w.AsyncIterator=7]="AsyncIterator",w[w.BigIntExclusiveMaximum=8]="BigIntExclusiveMaximum",w[w.BigIntExclusiveMinimum=9]="BigIntExclusiveMinimum",w[w.BigIntMaximum=10]="BigIntMaximum",w[w.BigIntMinimum=11]="BigIntMinimum",w[w.BigIntMultipleOf=12]="BigIntMultipleOf",w[w.BigInt=13]="BigInt",w[w.Boolean=14]="Boolean",w[w.DateExclusiveMaximumTimestamp=15]="DateExclusiveMaximumTimestamp",w[w.DateExclusiveMinimumTimestamp=16]="DateExclusiveMinimumTimestamp",w[w.DateMaximumTimestamp=17]="DateMaximumTimestamp",w[w.DateMinimumTimestamp=18]="DateMinimumTimestamp",w[w.DateMultipleOfTimestamp=19]="DateMultipleOfTimestamp",w[w.Date=20]="Date",w[w.Function=21]="Function",w[w.IntegerExclusiveMaximum=22]="IntegerExclusiveMaximum",w[w.IntegerExclusiveMinimum=23]="IntegerExclusiveMinimum",w[w.IntegerMaximum=24]="IntegerMaximum",w[w.IntegerMinimum=25]="IntegerMinimum",w[w.IntegerMultipleOf=26]="IntegerMultipleOf",w[w.Integer=27]="Integer",w[w.IntersectUnevaluatedProperties=28]="IntersectUnevaluatedProperties",w[w.Intersect=29]="Intersect",w[w.Iterator=30]="Iterator",w[w.Kind=31]="Kind",w[w.Literal=32]="Literal",w[w.Never=33]="Never",w[w.Not=34]="Not",w[w.Null=35]="Null",w[w.NumberExclusiveMaximum=36]="NumberExclusiveMaximum",w[w.NumberExclusiveMinimum=37]="NumberExclusiveMinimum",w[w.NumberMaximum=38]="NumberMaximum",w[w.NumberMinimum=39]="NumberMinimum",w[w.NumberMultipleOf=40]="NumberMultipleOf",w[w.Number=41]="Number",w[w.ObjectAdditionalProperties=42]="ObjectAdditionalProperties",w[w.ObjectMaxProperties=43]="ObjectMaxProperties",w[w.ObjectMinProperties=44]="ObjectMinProperties",w[w.ObjectRequiredProperty=45]="ObjectRequiredProperty",w[w.Object=46]="Object",w[w.Promise=47]="Promise",w[w.RegExp=48]="RegExp",w[w.StringFormatUnknown=49]="StringFormatUnknown",w[w.StringFormat=50]="StringFormat",w[w.StringMaxLength=51]="StringMaxLength",w[w.StringMinLength=52]="StringMinLength",w[w.StringPattern=53]="StringPattern",w[w.String=54]="String",w[w.Symbol=55]="Symbol",w[w.TupleLength=56]="TupleLength",w[w.Tuple=57]="Tuple",w[w.Uint8ArrayMaxByteLength=58]="Uint8ArrayMaxByteLength",w[w.Uint8ArrayMinByteLength=59]="Uint8ArrayMinByteLength",w[w.Uint8Array=60]="Uint8Array",w[w.Undefined=61]="Undefined",w[w.Union=62]="Union",w[w.Void=63]="Void"})(S||(S={}));class V7 extends y{constructor(w){super("Unknown type");this.schema=w}}function d1(w){return w.replace(/~/g,"~0").replace(/\//g,"~1")}function U0(w){return w!==void 0}class S6{constructor(w){this.iterator=w}[Symbol.iterator](){return this.iterator}First(){let w=this.iterator.next();return w.done?void 0:w.value}}function E(w,z,U,W,A=[]){return{type:w,schema:z,path:U,value:W,message:C7()({errorType:w,path:U,schema:z,value:W,errors:A}),errors:A}}function*cY(w,z,U,W){}function*iY(w,z,U,W){if(!n(W))return yield E(S.Array,w,U,W);if(U0(w.minItems)&&!(W.length>=w.minItems))yield E(S.ArrayMinItems,w,U,W);if(U0(w.maxItems)&&!(W.length<=w.maxItems))yield E(S.ArrayMaxItems,w,U,W);for(let Z=0;Z<W.length;Z++)yield*z2(w.items,z,`${U}/${Z}`,W[Z]);if(w.uniqueItems===!0&&!function(){let Z=new Set;for(let $ of W){let Q=e1($);if(Z.has(Q))return!1;else Z.add(Q)}return!0}())yield E(S.ArrayUniqueItems,w,U,W);if(!(U0(w.contains)||U0(w.minContains)||U0(w.maxContains)))return;let A=U0(w.contains)?w.contains:H0(),X=W.reduce((Z,$,Q)=>z2(A,z,`${U}${Q}`,$).next().done===!0?Z+1:Z,0);if(X===0)yield E(S.ArrayContains,w,U,W);if(d(w.minContains)&&X<w.minContains)yield E(S.ArrayMinContains,w,U,W);if(d(w.maxContains)&&X>w.maxContains)yield E(S.ArrayMaxContains,w,U,W)}function*vY(w,z,U,W){if(!t4(W))yield E(S.AsyncIterator,w,U,W)}function*nY(w,z,U,W){if(!A2(W))return yield E(S.BigInt,w,U,W);if(U0(w.exclusiveMaximum)&&!(W<w.exclusiveMaximum))yield E(S.BigIntExclusiveMaximum,w,U,W);if(U0(w.exclusiveMinimum)&&!(W>w.exclusiveMinimum))yield E(S.BigIntExclusiveMinimum,w,U,W);if(U0(w.maximum)&&!(W<=w.maximum))yield E(S.BigIntMaximum,w,U,W);if(U0(w.minimum)&&!(W>=w.minimum))yield E(S.BigIntMinimum,w,U,W);if(U0(w.multipleOf)&&W%w.multipleOf!==BigInt(0))yield E(S.BigIntMultipleOf,w,U,W)}function*uY(w,z,U,W){if(!G1(W))yield E(S.Boolean,w,U,W)}function*mY(w,z,U,W){yield*z2(w.returns,z,U,W.prototype)}function*tY(w,z,U,W){if(!G2(W))return yield E(S.Date,w,U,W);if(U0(w.exclusiveMaximumTimestamp)&&!(W.getTime()<w.exclusiveMaximumTimestamp))yield E(S.DateExclusiveMaximumTimestamp,w,U,W);if(U0(w.exclusiveMinimumTimestamp)&&!(W.getTime()>w.exclusiveMinimumTimestamp))yield E(S.DateExclusiveMinimumTimestamp,w,U,W);if(U0(w.maximumTimestamp)&&!(W.getTime()<=w.maximumTimestamp))yield E(S.DateMaximumTimestamp,w,U,W);if(U0(w.minimumTimestamp)&&!(W.getTime()>=w.minimumTimestamp))yield E(S.DateMinimumTimestamp,w,U,W);if(U0(w.multipleOfTimestamp)&&W.getTime()%w.multipleOfTimestamp!==0)yield E(S.DateMultipleOfTimestamp,w,U,W)}function*pY(w,z,U,W){if(!m1(W))yield E(S.Function,w,U,W)}function*oY(w,z,U,W){let A=globalThis.Object.values(w.$defs),X=w.$defs[w.$ref];yield*z2(X,[...z,...A],U,W)}function*lY(w,z,U,W){if(!l4(W))return yield E(S.Integer,w,U,W);if(U0(w.exclusiveMaximum)&&!(W<w.exclusiveMaximum))yield E(S.IntegerExclusiveMaximum,w,U,W);if(U0(w.exclusiveMinimum)&&!(W>w.exclusiveMinimum))yield E(S.IntegerExclusiveMinimum,w,U,W);if(U0(w.maximum)&&!(W<=w.maximum))yield E(S.IntegerMaximum,w,U,W);if(U0(w.minimum)&&!(W>=w.minimum))yield E(S.IntegerMinimum,w,U,W);if(U0(w.multipleOf)&&W%w.multipleOf!==0)yield E(S.IntegerMultipleOf,w,U,W)}function*sY(w,z,U,W){let A=!1;for(let X of w.allOf)for(let Z of z2(X,z,U,W))A=!0,yield Z;if(A)return yield E(S.Intersect,w,U,W);if(w.unevaluatedProperties===!1){let X=new RegExp(k1(w));for(let Z of Object.getOwnPropertyNames(W))if(!X.test(Z))yield E(S.IntersectUnevaluatedProperties,w,`${U}/${Z}`,W)}if(typeof w.unevaluatedProperties==="object"){let X=new RegExp(k1(w));for(let Z of Object.getOwnPropertyNames(W))if(!X.test(Z)){let $=z2(w.unevaluatedProperties,z,`${U}/${Z}`,W[Z]).next();if(!$.done)yield $.value}}}function*rY(w,z,U,W){if(!p4(W))yield E(S.Iterator,w,U,W)}function*aY(w,z,U,W){if(W!==w.const)yield E(S.Literal,w,U,W)}function*eY(w,z,U,W){yield E(S.Never,w,U,W)}function*wJ(w,z,U,W){if(z2(w.not,z,U,W).next().done===!0)yield E(S.Not,w,U,W)}function*zJ(w,z,U,W){if(!K1(W))yield E(S.Null,w,U,W)}function*UJ(w,z,U,W){if(!V0.IsNumberLike(W))return yield E(S.Number,w,U,W);if(U0(w.exclusiveMaximum)&&!(W<w.exclusiveMaximum))yield E(S.NumberExclusiveMaximum,w,U,W);if(U0(w.exclusiveMinimum)&&!(W>w.exclusiveMinimum))yield E(S.NumberExclusiveMinimum,w,U,W);if(U0(w.maximum)&&!(W<=w.maximum))yield E(S.NumberMaximum,w,U,W);if(U0(w.minimum)&&!(W>=w.minimum))yield E(S.NumberMinimum,w,U,W);if(U0(w.multipleOf)&&W%w.multipleOf!==0)yield E(S.NumberMultipleOf,w,U,W)}function*WJ(w,z,U,W){if(!V0.IsObjectLike(W))return yield E(S.Object,w,U,W);if(U0(w.minProperties)&&!(Object.getOwnPropertyNames(W).length>=w.minProperties))yield E(S.ObjectMinProperties,w,U,W);if(U0(w.maxProperties)&&!(Object.getOwnPropertyNames(W).length<=w.maxProperties))yield E(S.ObjectMaxProperties,w,U,W);let A=Array.isArray(w.required)?w.required:[],X=Object.getOwnPropertyNames(w.properties),Z=Object.getOwnPropertyNames(W);for(let $ of A){if(Z.includes($))continue;yield E(S.ObjectRequiredProperty,w.properties[$],`${U}/${d1($)}`,void 0)}if(w.additionalProperties===!1){for(let $ of Z)if(!X.includes($))yield E(S.ObjectAdditionalProperties,w,`${U}/${d1($)}`,W[$])}if(typeof w.additionalProperties==="object")for(let $ of Z){if(X.includes($))continue;yield*z2(w.additionalProperties,z,`${U}/${d1($)}`,W[$])}for(let $ of X){let Q=w.properties[$];if(w.required&&w.required.includes($)){if(yield*z2(Q,z,`${U}/${d1($)}`,W[$]),g1(w)&&!($ in W))yield E(S.ObjectRequiredProperty,Q,`${U}/${d1($)}`,void 0)}else if(V0.IsExactOptionalProperty(W,$))yield*z2(Q,z,`${U}/${d1($)}`,W[$])}}function*AJ(w,z,U,W){if(!o4(W))yield E(S.Promise,w,U,W)}function*XJ(w,z,U,W){if(!V0.IsRecordLike(W))return yield E(S.Object,w,U,W);if(U0(w.minProperties)&&!(Object.getOwnPropertyNames(W).length>=w.minProperties))yield E(S.ObjectMinProperties,w,U,W);if(U0(w.maxProperties)&&!(Object.getOwnPropertyNames(W).length<=w.maxProperties))yield E(S.ObjectMaxProperties,w,U,W);let[A,X]=Object.entries(w.patternProperties)[0],Z=new RegExp(A);for(let[$,Q]of Object.entries(W))if(Z.test($))yield*z2(X,z,`${U}/${d1($)}`,Q);if(typeof w.additionalProperties==="object"){for(let[$,Q]of Object.entries(W))if(!Z.test($))yield*z2(w.additionalProperties,z,`${U}/${d1($)}`,Q)}if(w.additionalProperties===!1)for(let[$,Q]of Object.entries(W)){if(Z.test($))continue;return yield E(S.ObjectAdditionalProperties,w,`${U}/${d1($)}`,Q)}}function*ZJ(w,z,U,W){yield*z2(J0(w,z),z,U,W)}function*$J(w,z,U,W){if(!$0(W))return yield E(S.String,w,U,W);if(U0(w.minLength)&&!(W.length>=w.minLength))yield E(S.StringMinLength,w,U,W);if(U0(w.maxLength)&&!(W.length<=w.maxLength))yield E(S.StringMaxLength,w,U,W);if(!new RegExp(w.source,w.flags).test(W))return yield E(S.RegExp,w,U,W)}function*QJ(w,z,U,W){if(!$0(W))return yield E(S.String,w,U,W);if(U0(w.minLength)&&!(W.length>=w.minLength))yield E(S.StringMinLength,w,U,W);if(U0(w.maxLength)&&!(W.length<=w.maxLength))yield E(S.StringMaxLength,w,U,W);if($0(w.pattern)){if(!new RegExp(w.pattern).test(W))yield E(S.StringPattern,w,U,W)}if($0(w.format)){if(!b0.Has(w.format))yield E(S.StringFormatUnknown,w,U,W);else if(!b0.Get(w.format)(W))yield E(S.StringFormat,w,U,W)}}function*YJ(w,z,U,W){if(!F1(W))yield E(S.Symbol,w,U,W)}function*JJ(w,z,U,W){if(!$0(W))return yield E(S.String,w,U,W);if(!new RegExp(w.pattern).test(W))yield E(S.StringPattern,w,U,W)}function*BJ(w,z,U,W){yield*z2(J0(w,z),z,U,W)}function*MJ(w,z,U,W){if(!n(W))return yield E(S.Tuple,w,U,W);if(w.items===void 0&&W.length!==0)return yield E(S.TupleLength,w,U,W);if(W.length!==w.maxItems)return yield E(S.TupleLength,w,U,W);if(!w.items)return;for(let A=0;A<w.items.length;A++)yield*z2(w.items[A],z,`${U}/${A}`,W[A])}function*qJ(w,z,U,W){if(!T0(W))yield E(S.Undefined,w,U,W)}function*HJ(w,z,U,W){if(r(w,z,W))return;let A=w.anyOf.map((X)=>new S6(z2(X,z,U,W)));yield E(S.Union,w,U,W,A)}function*GJ(w,z,U,W){if(!j6(W))return yield E(S.Uint8Array,w,U,W);if(U0(w.maxByteLength)&&!(W.length<=w.maxByteLength))yield E(S.Uint8ArrayMaxByteLength,w,U,W);if(U0(w.minByteLength)&&!(W.length>=w.minByteLength))yield E(S.Uint8ArrayMinByteLength,w,U,W)}function*LJ(w,z,U,W){}function*NJ(w,z,U,W){if(!V0.IsVoidLike(W))yield E(S.Void,w,U,W)}function*SJ(w,z,U,W){if(!y0.Get(w[N])(w,W))yield E(S.Kind,w,U,W)}function*z2(w,z,U,W){let A=U0(w.$id)?[...z,w]:z,X=w;switch(X[N]){case"Any":return yield*cY(X,A,U,W);case"Array":return yield*iY(X,A,U,W);case"AsyncIterator":return yield*vY(X,A,U,W);case"BigInt":return yield*nY(X,A,U,W);case"Boolean":return yield*uY(X,A,U,W);case"Constructor":return yield*mY(X,A,U,W);case"Date":return yield*tY(X,A,U,W);case"Function":return yield*pY(X,A,U,W);case"Import":return yield*oY(X,A,U,W);case"Integer":return yield*lY(X,A,U,W);case"Intersect":return yield*sY(X,A,U,W);case"Iterator":return yield*rY(X,A,U,W);case"Literal":return yield*aY(X,A,U,W);case"Never":return yield*eY(X,A,U,W);case"Not":return yield*wJ(X,A,U,W);case"Null":return yield*zJ(X,A,U,W);case"Number":return yield*UJ(X,A,U,W);case"Object":return yield*WJ(X,A,U,W);case"Promise":return yield*AJ(X,A,U,W);case"Record":return yield*XJ(X,A,U,W);case"Ref":return yield*ZJ(X,A,U,W);case"RegExp":return yield*$J(X,A,U,W);case"String":return yield*QJ(X,A,U,W);case"Symbol":return yield*YJ(X,A,U,W);case"TemplateLiteral":return yield*JJ(X,A,U,W);case"This":return yield*BJ(X,A,U,W);case"Tuple":return yield*MJ(X,A,U,W);case"Undefined":return yield*qJ(X,A,U,W);case"Union":return yield*HJ(X,A,U,W);case"Uint8Array":return yield*GJ(X,A,U,W);case"Unknown":return yield*LJ(X,A,U,W);case"Void":return yield*NJ(X,A,U,W);default:if(!y0.Has(X[N]))throw new V7(w);return yield*SJ(X,A,U,W)}}function _1(...w){let z=w.length===3?z2(w[0],w[1],"",w[2]):z2(w[0],[],"",w[1]);return new S6(z)}class C4 extends y{constructor(w,z,U){super("Unable to decode value as it does not match the expected schema");this.schema=w,this.value=z,this.error=U}}class L8 extends y{constructor(w,z,U,W){super(W instanceof Error?W.message:"Unknown error");this.schema=w,this.path=z,this.value=U,this.error=W}}function i0(w,z,U){try{return S0(w)?w[F0].Decode(U):U}catch(W){throw new L8(w,z,U,W)}}function _J(w,z,U,W){return n(W)?i0(w,U,W.map((A,X)=>W1(w.items,z,`${U}/${X}`,A))):i0(w,U,W)}function DJ(w,z,U,W){if(!s(W)||V2(W))return i0(w,U,W);let A=X8(w),X=A.map((B)=>B[0]),Z={...W};for(let[B,G]of A)if(B in Z)Z[B]=W1(G,z,`${U}/${B}`,Z[B]);if(!S0(w.unevaluatedProperties))return i0(w,U,Z);let $=Object.getOwnPropertyNames(Z),Q=w.unevaluatedProperties,Y={...Z};for(let B of $)if(!X.includes(B))Y[B]=i0(Q,`${U}/${B}`,Y[B]);return i0(w,U,Y)}function PJ(w,z,U,W){let A=globalThis.Object.values(w.$defs),X=w.$defs[w.$ref],Z=w[F0],$={[F0]:Z,...X};return W1($,[...z,...A],U,W)}function OJ(w,z,U,W){return i0(w,U,W1(w.not,z,U,W))}function bJ(w,z,U,W){if(!s(W))return i0(w,U,W);let A=O2(w),X={...W};for(let Y of A){if(!v(X,Y))continue;if(T0(X[Y])&&(!G4(w.properties[Y])||V0.IsExactOptionalProperty(X,Y)))continue;X[Y]=W1(w.properties[Y],z,`${U}/${Y}`,X[Y])}if(!d0(w.additionalProperties))return i0(w,U,X);let Z=Object.getOwnPropertyNames(X),$=w.additionalProperties,Q={...X};for(let Y of Z)if(!A.includes(Y))Q[Y]=i0($,`${U}/${Y}`,Q[Y]);return i0(w,U,Q)}function RJ(w,z,U,W){if(!s(W))return i0(w,U,W);let A=Object.getOwnPropertyNames(w.patternProperties)[0],X=new RegExp(A),Z={...W};for(let B of Object.getOwnPropertyNames(W))if(X.test(B))Z[B]=W1(w.patternProperties[A],z,`${U}/${B}`,Z[B]);if(!d0(w.additionalProperties))return i0(w,U,Z);let $=Object.getOwnPropertyNames(Z),Q=w.additionalProperties,Y={...Z};for(let B of $)if(!X.test(B))Y[B]=i0(Q,`${U}/${B}`,Y[B]);return i0(w,U,Y)}function CJ(w,z,U,W){let A=J0(w,z);return i0(w,U,W1(A,z,U,W))}function KJ(w,z,U,W){let A=J0(w,z);return i0(w,U,W1(A,z,U,W))}function FJ(w,z,U,W){return n(W)&&n(w.items)?i0(w,U,w.items.map((A,X)=>W1(A,z,`${U}/${X}`,W[X]))):i0(w,U,W)}function jJ(w,z,U,W){for(let A of w.anyOf){if(!r(A,z,W))continue;let X=W1(A,z,U,W);return i0(w,U,X)}return i0(w,U,W)}function W1(w,z,U,W){let A=e0(w,z),X=w;switch(w[N]){case"Array":return _J(X,A,U,W);case"Import":return PJ(X,A,U,W);case"Intersect":return DJ(X,A,U,W);case"Not":return OJ(X,A,U,W);case"Object":return bJ(X,A,U,W);case"Record":return RJ(X,A,U,W);case"Ref":return CJ(X,A,U,W);case"Symbol":return i0(X,U,W);case"This":return KJ(X,A,U,W);case"Tuple":return FJ(X,A,U,W);case"Union":return jJ(X,A,U,W);default:return i0(X,U,W)}}function l6(w,z,U){return W1(w,z,"",U)}class K4 extends y{constructor(w,z,U){super("The encoded value does not match the expected schema");this.schema=w,this.value=z,this.error=U}}class k7 extends y{constructor(w,z,U,W){super(`${W instanceof Error?W.message:"Unknown error"}`);this.schema=w,this.path=z,this.value=U,this.error=W}}function Y2(w,z,U){try{return S0(w)?w[F0].Encode(U):U}catch(W){throw new k7(w,z,U,W)}}function EJ(w,z,U,W){let A=Y2(w,U,W);return n(A)?A.map((X,Z)=>A1(w.items,z,`${U}/${Z}`,X)):A}function IJ(w,z,U,W){let A=globalThis.Object.values(w.$defs),X=w.$defs[w.$ref],Z=w[F0],$={[F0]:Z,...X};return A1($,[...z,...A],U,W)}function xJ(w,z,U,W){let A=Y2(w,U,W);if(!s(W)||V2(W))return A;let X=X8(w),Z=X.map((G)=>G[0]),$={...A};for(let[G,_]of X)if(G in $)$[G]=A1(_,z,`${U}/${G}`,$[G]);if(!S0(w.unevaluatedProperties))return $;let Q=Object.getOwnPropertyNames($),Y=w.unevaluatedProperties,B={...$};for(let G of Q)if(!Z.includes(G))B[G]=Y2(Y,`${U}/${G}`,B[G]);return B}function VJ(w,z,U,W){return Y2(w.not,U,Y2(w,U,W))}function kJ(w,z,U,W){let A=Y2(w,U,W);if(!s(A))return A;let X=O2(w),Z={...A};for(let B of X){if(!v(Z,B))continue;if(T0(Z[B])&&(!G4(w.properties[B])||V0.IsExactOptionalProperty(Z,B)))continue;Z[B]=A1(w.properties[B],z,`${U}/${B}`,Z[B])}if(!d0(w.additionalProperties))return Z;let $=Object.getOwnPropertyNames(Z),Q=w.additionalProperties,Y={...Z};for(let B of $)if(!X.includes(B))Y[B]=Y2(Q,`${U}/${B}`,Y[B]);return Y}function TJ(w,z,U,W){let A=Y2(w,U,W);if(!s(W))return A;let X=Object.getOwnPropertyNames(w.patternProperties)[0],Z=new RegExp(X),$={...A};for(let G of Object.getOwnPropertyNames(W))if(Z.test(G))$[G]=A1(w.patternProperties[X],z,`${U}/${G}`,$[G]);if(!d0(w.additionalProperties))return $;let Q=Object.getOwnPropertyNames($),Y=w.additionalProperties,B={...$};for(let G of Q)if(!Z.test(G))B[G]=Y2(Y,`${U}/${G}`,B[G]);return B}function gJ(w,z,U,W){let A=J0(w,z),X=A1(A,z,U,W);return Y2(w,U,X)}function fJ(w,z,U,W){let A=J0(w,z),X=A1(A,z,U,W);return Y2(w,U,X)}function dJ(w,z,U,W){let A=Y2(w,U,W);return n(w.items)?w.items.map((X,Z)=>A1(X,z,`${U}/${Z}`,A[Z])):[]}function hJ(w,z,U,W){for(let A of w.anyOf){if(!r(A,z,W))continue;let X=A1(A,z,U,W);return Y2(w,U,X)}for(let A of w.anyOf){let X=A1(A,z,U,W);if(!r(w,z,X))continue;return Y2(w,U,X)}return Y2(w,U,W)}function A1(w,z,U,W){let A=e0(w,z),X=w;switch(w[N]){case"Array":return EJ(X,A,U,W);case"Import":return IJ(X,A,U,W);case"Intersect":return xJ(X,A,U,W);case"Not":return VJ(X,A,U,W);case"Object":return kJ(X,A,U,W);case"Record":return TJ(X,A,U,W);case"Ref":return gJ(X,A,U,W);case"This":return fJ(X,A,U,W);case"Tuple":return dJ(X,A,U,W);case"Union":return hJ(X,A,U,W);default:return Y2(X,U,W)}}function s6(w,z,U){return A1(w,z,"",U)}function yJ(w,z){return S0(w)||U2(w.items,z)}function cJ(w,z){return S0(w)||U2(w.items,z)}function iJ(w,z){return S0(w)||U2(w.returns,z)||w.parameters.some((U)=>U2(U,z))}function vJ(w,z){return S0(w)||U2(w.returns,z)||w.parameters.some((U)=>U2(U,z))}function nJ(w,z){return S0(w)||S0(w.unevaluatedProperties)||w.allOf.some((U)=>U2(U,z))}function uJ(w,z){return S0(w)||U2(w.items,z)}function mJ(w,z){return S0(w)||U2(w.not,z)}function tJ(w,z){return S0(w)||Object.values(w.properties).some((U)=>U2(U,z))||d0(w.additionalProperties)&&U2(w.additionalProperties,z)}function pJ(w,z){return S0(w)||U2(w.item,z)}function oJ(w,z){let U=Object.getOwnPropertyNames(w.patternProperties)[0],W=w.patternProperties[U];return S0(w)||U2(W,z)||d0(w.additionalProperties)&&S0(w.additionalProperties)}function lJ(w,z){if(S0(w))return!0;return U2(J0(w,z),z)}function sJ(w,z){if(S0(w))return!0;return U2(J0(w,z),z)}function rJ(w,z){return S0(w)||!T0(w.items)&&w.items.some((U)=>U2(U,z))}function aJ(w,z){return S0(w)||w.anyOf.some((U)=>U2(U,z))}function U2(w,z){let U=e0(w,z),W=w;if(w.$id&&qw.has(w.$id))return!1;if(w.$id)qw.add(w.$id);switch(w[N]){case"Array":return yJ(W,U);case"AsyncIterator":return cJ(W,U);case"Constructor":return iJ(W,U);case"Function":return vJ(W,U);case"Intersect":return nJ(W,U);case"Iterator":return uJ(W,U);case"Not":return mJ(W,U);case"Object":return tJ(W,U);case"Promise":return pJ(W,U);case"Record":return oJ(W,U);case"Ref":return lJ(W,U);case"This":return sJ(W,U);case"Tuple":return rJ(W,U);case"Union":return aJ(W,U);default:return S0(w)}}var qw=new Set;function h1(w,z){return qw.clear(),U2(w,z)}class T7{constructor(w,z,U,W){this.schema=w,this.references=z,this.checkFunc=U,this.code=W,this.hasTransform=h1(w,z)}Code(){return this.code}Schema(){return this.schema}References(){return this.references}Errors(w){return _1(this.schema,this.references,w)}Check(w){return this.checkFunc(w)}Decode(w){if(!this.checkFunc(w))throw new C4(this.schema,w,this.Errors(w).First());return this.hasTransform?l6(this.schema,this.references,w):w}Encode(w){let z=this.hasTransform?s6(this.schema,this.references,w):w;if(!this.checkFunc(z))throw new K4(this.schema,w,this.Errors(w).First());return z}}var y1;(function(w){function z(X){return X===36}w.DollarSign=z;function U(X){return X===95}w.IsUnderscore=U;function W(X){return X>=65&&X<=90||X>=97&&X<=122}w.IsAlpha=W;function A(X){return X>=48&&X<=57}w.IsNumeric=A})(y1||(y1={}));var N8;(function(w){function z(X){if(X.length===0)return!1;return y1.IsNumeric(X.charCodeAt(0))}function U(X){if(z(X))return!1;for(let Z=0;Z<X.length;Z++){let $=X.charCodeAt(Z);if(!(y1.IsAlpha($)||y1.IsNumeric($)||y1.DollarSign($)||y1.IsUnderscore($)))return!1}return!0}function W(X){return X.replace(/'/g,"\\'")}function A(X,Z){return U(Z)?`${X}.${Z}`:`${X}['${W(Z)}']`}w.Encode=A})(N8||(N8={}));var Hw;(function(w){function z(U){let W=[];for(let A=0;A<U.length;A++){let X=U.charCodeAt(A);if(y1.IsNumeric(X)||y1.IsAlpha(X))W.push(U.charAt(A));else W.push(`_${X}_`)}return W.join("").replace(/__/g,"_")}w.Encode=z})(Hw||(Hw={}));var Gw;(function(w){function z(U){return U.replace(/'/g,"\\'")}w.Escape=z})(Gw||(Gw={}));class g7 extends y{constructor(w){super("Unknown type");this.schema=w}}class Lw extends y{constructor(w){super("Preflight validation check failed to guard for the given schema");this.schema=w}}var _6;(function(w){function z(Z,$,Q){return V0.ExactOptionalPropertyTypes?`('${$}' in ${Z} ? ${Q} : true)`:`(${N8.Encode(Z,$)} !== undefined ? ${Q} : true)`}w.IsExactOptionalProperty=z;function U(Z){return!V0.AllowArrayObject?`(typeof ${Z} === 'object' && ${Z} !== null && !Array.isArray(${Z}))`:`(typeof ${Z} === 'object' && ${Z} !== null)`}w.IsObjectLike=U;function W(Z){return!V0.AllowArrayObject?`(typeof ${Z} === 'object' && ${Z} !== null && !Array.isArray(${Z}) && !(${Z} instanceof Date) && !(${Z} instanceof Uint8Array))`:`(typeof ${Z} === 'object' && ${Z} !== null && !(${Z} instanceof Date) && !(${Z} instanceof Uint8Array))`}w.IsRecordLike=W;function A(Z){return V0.AllowNaN?`typeof ${Z} === 'number'`:`Number.isFinite(${Z})`}w.IsNumberLike=A;function X(Z){return V0.AllowNullVoid?`(${Z} === undefined || ${Z} === null)`:`${Z} === undefined`}w.IsVoidLike=X})(_6||(_6={}));var w6;(function(w){function z(M){return M[N]==="Any"||M[N]==="Unknown"}function*U(M,C,L){yield"true"}function*W(M,C,L){yield`Array.isArray(${L})`;let[u,V]=[b("value","any"),b("acc","number")];if(d(M.maxItems))yield`${L}.length <= ${M.maxItems}`;if(d(M.minItems))yield`${L}.length >= ${M.minItems}`;let k=q2(M.items,C,"value");if(yield`${L}.every((${u}) => ${k})`,f0(M.contains)||d(M.minContains)||d(M.maxContains)){let x0=f0(M.contains)?M.contains:H0(),N2=q2(x0,C,"value"),b1=d(M.minContains)?[`(count >= ${M.minContains})`]:[],e2=d(M.maxContains)?[`(count <= ${M.maxContains})`]:[],H1=`const count = value.reduce((${V}, ${u}) => ${N2} ? acc + 1 : acc, 0)`,v4=["(count > 0)",...b1,...e2].join(" && ");yield`((${u}) => { ${H1}; return ${v4}})(${L})`}if(M.uniqueItems===!0)yield`((${u}) => { const set = new Set(); for(const element of value) { const hashed = hash(element); if(set.has(hashed)) { return false } else { set.add(hashed) } } return true } )(${L})`}function*A(M,C,L){yield`(typeof value === 'object' && Symbol.asyncIterator in ${L})`}function*X(M,C,L){if(yield`(typeof ${L} === 'bigint')`,A2(M.exclusiveMaximum))yield`${L} < BigInt(${M.exclusiveMaximum})`;if(A2(M.exclusiveMinimum))yield`${L} > BigInt(${M.exclusiveMinimum})`;if(A2(M.maximum))yield`${L} <= BigInt(${M.maximum})`;if(A2(M.minimum))yield`${L} >= BigInt(${M.minimum})`;if(A2(M.multipleOf))yield`(${L} % BigInt(${M.multipleOf})) === 0`}function*Z(M,C,L){yield`(typeof ${L} === 'boolean')`}function*$(M,C,L){yield*o0(M.returns,C,`${L}.prototype`)}function*Q(M,C,L){if(yield`(${L} instanceof Date) && Number.isFinite(${L}.getTime())`,d(M.exclusiveMaximumTimestamp))yield`${L}.getTime() < ${M.exclusiveMaximumTimestamp}`;if(d(M.exclusiveMinimumTimestamp))yield`${L}.getTime() > ${M.exclusiveMinimumTimestamp}`;if(d(M.maximumTimestamp))yield`${L}.getTime() <= ${M.maximumTimestamp}`;if(d(M.minimumTimestamp))yield`${L}.getTime() >= ${M.minimumTimestamp}`;if(d(M.multipleOfTimestamp))yield`(${L}.getTime() % ${M.multipleOfTimestamp}) === 0`}function*Y(M,C,L){yield`(typeof ${L} === 'function')`}function*B(M,C,L){let u=globalThis.Object.getOwnPropertyNames(M.$defs).reduce((V,k)=>{return[...V,M.$defs[k]]},[]);yield*o0(P2(M.$ref),[...C,...u],L)}function*G(M,C,L){if(yield`Number.isInteger(${L})`,d(M.exclusiveMaximum))yield`${L} < ${M.exclusiveMaximum}`;if(d(M.exclusiveMinimum))yield`${L} > ${M.exclusiveMinimum}`;if(d(M.maximum))yield`${L} <= ${M.maximum}`;if(d(M.minimum))yield`${L} >= ${M.minimum}`;if(d(M.multipleOf))yield`(${L} % ${M.multipleOf}) === 0`}function*_(M,C,L){let u=M.allOf.map((V)=>q2(V,C,L)).join(" && ");if(M.unevaluatedProperties===!1){let V=j(`${new RegExp(k1(M))};`),k=`Object.getOwnPropertyNames(${L}).every(key => ${V}.test(key))`;yield`(${u} && ${k})`}else if(f0(M.unevaluatedProperties)){let V=j(`${new RegExp(k1(M))};`),k=`Object.getOwnPropertyNames(${L}).every(key => ${V}.test(key) || ${q2(M.unevaluatedProperties,C,`${L}[key]`)})`;yield`(${u} && ${k})`}else yield`(${u})`}function*H(M,C,L){yield`(typeof value === 'object' && Symbol.iterator in ${L})`}function*F(M,C,L){if(typeof M.const==="number"||typeof M.const==="boolean")yield`(${L} === ${M.const})`;else yield`(${L} === '${Gw.Escape(M.const)}')`}function*R(M,C,L){yield"false"}function*J(M,C,L){yield`(!${q2(M.not,C,L)})`}function*m(M,C,L){yield`(${L} === null)`}function*A0(M,C,L){if(yield _6.IsNumberLike(L),d(M.exclusiveMaximum))yield`${L} < ${M.exclusiveMaximum}`;if(d(M.exclusiveMinimum))yield`${L} > ${M.exclusiveMinimum}`;if(d(M.maximum))yield`${L} <= ${M.maximum}`;if(d(M.minimum))yield`${L} >= ${M.minimum}`;if(d(M.multipleOf))yield`(${L} % ${M.multipleOf}) === 0`}function*L0(M,C,L){if(yield _6.IsObjectLike(L),d(M.minProperties))yield`Object.getOwnPropertyNames(${L}).length >= ${M.minProperties}`;if(d(M.maxProperties))yield`Object.getOwnPropertyNames(${L}).length <= ${M.maxProperties}`;let u=Object.getOwnPropertyNames(M.properties);for(let V of u){let k=N8.Encode(L,V),x0=M.properties[V];if(M.required&&M.required.includes(V)){if(yield*o0(x0,C,k),g1(x0)||z(x0))yield`('${V}' in ${L})`}else{let N2=q2(x0,C,k);yield _6.IsExactOptionalProperty(L,V,N2)}}if(M.additionalProperties===!1)if(M.required&&M.required.length===u.length)yield`Object.getOwnPropertyNames(${L}).length === ${u.length}`;else{let V=`[${u.map((k)=>`'${k}'`).join(", ")}]`;yield`Object.getOwnPropertyNames(${L}).every(key => ${V}.includes(key))`}if(typeof M.additionalProperties==="object"){let V=q2(M.additionalProperties,C,`${L}[key]`),k=`[${u.map((x0)=>`'${x0}'`).join(", ")}]`;yield`(Object.getOwnPropertyNames(${L}).every(key => ${k}.includes(key) || ${V}))`}}function*h(M,C,L){yield`(typeof value === 'object' && typeof ${L}.then === 'function')`}function*a(M,C,L){if(yield _6.IsRecordLike(L),d(M.minProperties))yield`Object.getOwnPropertyNames(${L}).length >= ${M.minProperties}`;if(d(M.maxProperties))yield`Object.getOwnPropertyNames(${L}).length <= ${M.maxProperties}`;let[u,V]=Object.entries(M.patternProperties)[0],k=j(`${new RegExp(u)}`),x0=q2(V,C,"value"),N2=f0(M.additionalProperties)?q2(M.additionalProperties,C,L):M.additionalProperties===!1?"false":"true",b1=`(${k}.test(key) ? ${x0} : ${N2})`;yield`(Object.entries(${L}).every(([key, value]) => ${b1}))`}function*x(M,C,L){let u=J0(M,C);if(l0.functions.has(M.$ref))return yield`${x2(M.$ref)}(${L})`;yield*o0(u,C,L)}function*i(M,C,L){let u=j(`${new RegExp(M.source,M.flags)};`);if(yield`(typeof ${L} === 'string')`,d(M.maxLength))yield`${L}.length <= ${M.maxLength}`;if(d(M.minLength))yield`${L}.length >= ${M.minLength}`;yield`${u}.test(${L})`}function*K(M,C,L){if(yield`(typeof ${L} === 'string')`,d(M.maxLength))yield`${L}.length <= ${M.maxLength}`;if(d(M.minLength))yield`${L}.length >= ${M.minLength}`;if(M.pattern!==void 0)yield`${j(`${new RegExp(M.pattern)};`)}.test(${L})`;if(M.format!==void 0)yield`format('${M.format}', ${L})`}function*o(M,C,L){yield`(typeof ${L} === 'symbol')`}function*D0(M,C,L){yield`(typeof ${L} === 'string')`,yield`${j(`${new RegExp(M.pattern)};`)}.test(${L})`}function*l(M,C,L){yield`${x2(M.$ref)}(${L})`}function*O1(M,C,L){if(yield`Array.isArray(${L})`,M.items===void 0)return yield`${L}.length === 0`;yield`(${L}.length === ${M.maxItems})`;for(let u=0;u<M.items.length;u++)yield`${q2(M.items[u],C,`${L}[${u}]`)}`}function*C0(M,C,L){yield`${L} === undefined`}function*n1(M,C,L){yield`(${M.anyOf.map((V)=>q2(V,C,L)).join(" || ")})`}function*I2(M,C,L){if(yield`${L} instanceof Uint8Array`,d(M.maxByteLength))yield`(${L}.length <= ${M.maxByteLength})`;if(d(M.minByteLength))yield`(${L}.length >= ${M.minByteLength})`}function*Y6(M,C,L){yield"true"}function*g5(M,C,L){yield _6.IsVoidLike(L)}function*K6(M,C,L){let u=l0.instances.size;l0.instances.set(u,M),yield`kind('${M[N]}', ${u}, ${L})`}function*o0(M,C,L,u=!0){let V=$0(M.$id)?[...C,M]:C,k=M;if(u&&$0(M.$id)){let x0=x2(M.$id);if(l0.functions.has(x0))return yield`${x0}(${L})`;else{l0.functions.set(x0,"<deferred>");let N2=O(x0,M,C,"value",!1);return l0.functions.set(x0,N2),yield`${x0}(${L})`}}switch(k[N]){case"Any":return yield*U(k,V,L);case"Array":return yield*W(k,V,L);case"AsyncIterator":return yield*A(k,V,L);case"BigInt":return yield*X(k,V,L);case"Boolean":return yield*Z(k,V,L);case"Constructor":return yield*$(k,V,L);case"Date":return yield*Q(k,V,L);case"Function":return yield*Y(k,V,L);case"Import":return yield*B(k,V,L);case"Integer":return yield*G(k,V,L);case"Intersect":return yield*_(k,V,L);case"Iterator":return yield*H(k,V,L);case"Literal":return yield*F(k,V,L);case"Never":return yield*R(k,V,L);case"Not":return yield*J(k,V,L);case"Null":return yield*m(k,V,L);case"Number":return yield*A0(k,V,L);case"Object":return yield*L0(k,V,L);case"Promise":return yield*h(k,V,L);case"Record":return yield*a(k,V,L);case"Ref":return yield*x(k,V,L);case"RegExp":return yield*i(k,V,L);case"String":return yield*K(k,V,L);case"Symbol":return yield*o(k,V,L);case"TemplateLiteral":return yield*D0(k,V,L);case"This":return yield*l(k,V,L);case"Tuple":return yield*O1(k,V,L);case"Undefined":return yield*C0(k,V,L);case"Union":return yield*n1(k,V,L);case"Uint8Array":return yield*I2(k,V,L);case"Unknown":return yield*Y6(k,V,L);case"Void":return yield*g5(k,V,L);default:if(!y0.Has(k[N]))throw new g7(M);return yield*K6(k,V,L)}}let l0={language:"javascript",functions:new Map,variables:new Map,instances:new Map};function q2(M,C,L,u=!0){return`(${[...o0(M,C,L,u)].join(" && ")})`}function x2(M){return`check_${Hw.Encode(M)}`}function j(M){let C=`local_${l0.variables.size}`;return l0.variables.set(C,`const ${C} = ${M}`),C}function O(M,C,L,u,V=!0){let[k,x0]=[`
3
+ `,(H1)=>"".padStart(H1," ")],N2=b("value","any"),b1=T("boolean"),e2=[...o0(C,L,u,V)].map((H1)=>`${x0(4)}${H1}`).join(` &&${k}`);return`function ${M}(${N2})${b1} {${k}${x0(2)}return (${k}${e2}${k}${x0(2)})
4
+ }`}function b(M,C){let L=l0.language==="typescript"?`: ${C}`:"";return`${M}${L}`}function T(M){return l0.language==="typescript"?`: ${M}`:""}function t(M,C,L){let u=O("check",M,C,"value"),V=b("value","any"),k=T("boolean"),x0=[...l0.functions.values()],N2=[...l0.variables.values()],b1=$0(M.$id)?`return function check(${V})${k} {
5
+ return ${x2(M.$id)}(value)
6
+ }`:`return ${u}`;return[...N2,...x0,b1].join(`
7
+ `)}function e(...M){let C={language:"javascript"},[L,u,V]=M.length===2&&n(M[1])?[M[0],M[1],C]:M.length===2&&!n(M[1])?[M[0],[],M[1]]:M.length===3?[M[0],M[1],M[2]]:M.length===1?[M[0],[],C]:[null,[],C];if(l0.language=V.language,l0.variables.clear(),l0.functions.clear(),l0.instances.clear(),!f0(L))throw new Lw(L);for(let k of u)if(!f0(k))throw new Lw(k);return t(L,u,V)}w.Code=e;function K0(M,C=[]){let L=e(M,C,{language:"javascript"}),u=globalThis.Function("kind","format","hash",L),V=new Map(l0.instances);function k(e2,H1,v4){if(!y0.Has(e2)||!V.has(H1))return!1;let XA=y0.Get(e2),ZA=V.get(H1);return XA(ZA,v4)}function x0(e2,H1){if(!b0.Has(e2))return!1;return b0.Get(e2)(H1)}function N2(e2){return e1(e2)}let b1=u(k,x0,N2);return new T7(M,C,b1,L)}w.Compile=K0})(w6||(w6={}));var eJ=function(w,z,U,W,A){if(W==="m")throw new TypeError("Private method is not writable");if(W==="a"&&!A)throw new TypeError("Private accessor was defined without a setter");if(typeof z==="function"?w!==z||!A:!z.has(w))throw new TypeError("Cannot write private member to an object whose class did not declare it");return W==="a"?A.call(w,U):A?A.value=U:z.set(w,U),U},d7=function(w,z,U,W){if(U==="a"&&!W)throw new TypeError("Private accessor was defined without a getter");if(typeof z==="function"?w!==z||!W:!z.has(w))throw new TypeError("Cannot read private member from an object whose class did not declare it");return U==="m"?W:U==="a"?W.call(w):W?W.value:z.get(w)},Nw,S8,h7;class y7 extends y{constructor(w){let z=w.First();super(z===void 0?"Invalid Value":z.message);Nw.add(this),S8.set(this,void 0),eJ(this,S8,w,"f"),this.error=z}Errors(){return new S6(d7(this,Nw,"m",h7).call(this))}}S8=new WeakMap,Nw=new WeakSet,h7=function*w(){if(this.error)yield this.error;yield*d7(this,S8,"f")};function f7(w,z,U){if(r(w,z,U))return;throw new y7(_1(w,z,U))}function _8(...w){return w.length===3?f7(w[0],w[1],w[2]):f7(w[0],[],w[1])}function wB(w){let z={};for(let U of Object.getOwnPropertyNames(w))z[U]=B0(w[U]);for(let U of Object.getOwnPropertySymbols(w))z[U]=B0(w[U]);return z}function zB(w){return w.map((z)=>B0(z))}function UB(w){return w.slice()}function WB(w){return new Map(B0([...w.entries()]))}function AB(w){return new Set(B0([...w.entries()]))}function XB(w){return new Date(w.toISOString())}function ZB(w){return w}function B0(w){if(n(w))return zB(w);if(G2(w))return XB(w);if(d2(w))return UB(w);if(Uz(w))return WB(w);if(Wz(w))return AB(w);if(s(w))return wB(w);if(V2(w))return ZB(w);throw new Error("ValueClone: Unable to clone value")}class p2 extends y{constructor(w,z){super(z);this.schema=w}}function M0(w){return m1(w)?w():B0(w)}function $B(w,z){if(v(w,"default"))return M0(w.default);else return{}}function QB(w,z){if(w.uniqueItems===!0&&!v(w,"default"))throw new p2(w,"Array with the uniqueItems constraint requires a default value");else if("contains"in w&&!v(w,"default"))throw new p2(w,"Array with the contains constraint requires a default value");else if("default"in w)return M0(w.default);else if(w.minItems!==void 0)return Array.from({length:w.minItems}).map((U)=>{return R2(w.items,z)});else return[]}function YB(w,z){if(v(w,"default"))return M0(w.default);else return async function*(){}()}function JB(w,z){if(v(w,"default"))return M0(w.default);else return BigInt(0)}function BB(w,z){if(v(w,"default"))return M0(w.default);else return!1}function MB(w,z){if(v(w,"default"))return M0(w.default);else{let U=R2(w.returns,z);if(typeof U==="object"&&!Array.isArray(U))return class{constructor(){for(let[W,A]of Object.entries(U)){let X=this;X[W]=A}}};else return class{}}}function qB(w,z){if(v(w,"default"))return M0(w.default);else if(w.minimumTimestamp!==void 0)return new Date(w.minimumTimestamp);else return new Date}function HB(w,z){if(v(w,"default"))return M0(w.default);else return()=>R2(w.returns,z)}function GB(w,z){let U=globalThis.Object.values(w.$defs),W=w.$defs[w.$ref];return R2(W,[...z,...U])}function LB(w,z){if(v(w,"default"))return M0(w.default);else if(w.minimum!==void 0)return w.minimum;else return 0}function NB(w,z){if(v(w,"default"))return M0(w.default);else{let U=w.allOf.reduce((W,A)=>{let X=R2(A,z);return typeof X==="object"?{...W,...X}:X},{});if(!r(w,z,U))throw new p2(w,"Intersect produced invalid value. Consider using a default value.");return U}}function SB(w,z){if(v(w,"default"))return M0(w.default);else return function*(){}()}function _B(w,z){if(v(w,"default"))return M0(w.default);else return w.const}function DB(w,z){if(v(w,"default"))return M0(w.default);else throw new p2(w,"Never types cannot be created. Consider using a default value.")}function PB(w,z){if(v(w,"default"))return M0(w.default);else throw new p2(w,"Not types must have a default value")}function OB(w,z){if(v(w,"default"))return M0(w.default);else return null}function bB(w,z){if(v(w,"default"))return M0(w.default);else if(w.minimum!==void 0)return w.minimum;else return 0}function RB(w,z){if(v(w,"default"))return M0(w.default);else{let U=new Set(w.required),W={};for(let[A,X]of Object.entries(w.properties)){if(!U.has(A))continue;W[A]=R2(X,z)}return W}}function CB(w,z){if(v(w,"default"))return M0(w.default);else return Promise.resolve(R2(w.item,z))}function KB(w,z){let[U,W]=Object.entries(w.patternProperties)[0];if(v(w,"default"))return M0(w.default);else if(!(U===x1||U===I1)){let A=U.slice(1,U.length-1).split("|"),X={};for(let Z of A)X[Z]=R2(W,z);return X}else return{}}function FB(w,z){if(v(w,"default"))return M0(w.default);else return R2(J0(w,z),z)}function jB(w,z){if(v(w,"default"))return M0(w.default);else throw new p2(w,"RegExp types cannot be created. Consider using a default value.")}function EB(w,z){if(w.pattern!==void 0)if(!v(w,"default"))throw new p2(w,"String types with patterns must specify a default value");else return M0(w.default);else if(w.format!==void 0)if(!v(w,"default"))throw new p2(w,"String types with formats must specify a default value");else return M0(w.default);else if(v(w,"default"))return M0(w.default);else if(w.minLength!==void 0)return Array.from({length:w.minLength}).map(()=>" ").join("");else return""}function IB(w,z){if(v(w,"default"))return M0(w.default);else if("value"in w)return Symbol.for(w.value);else return Symbol()}function xB(w,z){if(v(w,"default"))return M0(w.default);if(!w8(w))throw new p2(w,"Can only create template literals that produce a finite variants. Consider using a default value.");return f6(w)[0]}function VB(w,z){if(c7++>cB)throw new p2(w,"Cannot create recursive type as it appears possibly infinite. Consider using a default.");if(v(w,"default"))return M0(w.default);else return R2(J0(w,z),z)}function kB(w,z){if(v(w,"default"))return M0(w.default);if(w.items===void 0)return[];else return Array.from({length:w.minItems}).map((U,W)=>R2(w.items[W],z))}function TB(w,z){if(v(w,"default"))return M0(w.default);else return}function gB(w,z){if(v(w,"default"))return M0(w.default);else if(w.anyOf.length===0)throw new Error("ValueCreate.Union: Cannot create Union with zero variants");else return R2(w.anyOf[0],z)}function fB(w,z){if(v(w,"default"))return M0(w.default);else if(w.minByteLength!==void 0)return new Uint8Array(w.minByteLength);else return new Uint8Array(0)}function dB(w,z){if(v(w,"default"))return M0(w.default);else return{}}function hB(w,z){if(v(w,"default"))return M0(w.default);else return}function yB(w,z){if(v(w,"default"))return M0(w.default);else throw new Error("User defined types must specify a default value")}function R2(w,z){let U=e0(w,z),W=w;switch(W[N]){case"Any":return $B(W,U);case"Array":return QB(W,U);case"AsyncIterator":return YB(W,U);case"BigInt":return JB(W,U);case"Boolean":return BB(W,U);case"Constructor":return MB(W,U);case"Date":return qB(W,U);case"Function":return HB(W,U);case"Import":return GB(W,U);case"Integer":return LB(W,U);case"Intersect":return NB(W,U);case"Iterator":return SB(W,U);case"Literal":return _B(W,U);case"Never":return DB(W,U);case"Not":return PB(W,U);case"Null":return OB(W,U);case"Number":return bB(W,U);case"Object":return RB(W,U);case"Promise":return CB(W,U);case"Record":return KB(W,U);case"Ref":return FB(W,U);case"RegExp":return jB(W,U);case"String":return EB(W,U);case"Symbol":return IB(W,U);case"TemplateLiteral":return xB(W,U);case"This":return VB(W,U);case"Tuple":return kB(W,U);case"Undefined":return TB(W,U);case"Union":return gB(W,U);case"Uint8Array":return fB(W,U);case"Unknown":return dB(W,U);case"Void":return hB(W,U);default:if(!y0.Has(W[N]))throw new p2(W,"Unknown type");return yB(W,U)}}var cB=512,c7=0;function o2(...w){return c7=0,w.length===2?R2(w[0],w[1]):R2(w[0],[])}class Sw extends y{constructor(w,z){super(z);this.schema=w}}function iB(w,z,U){if(w[N]==="Object"&&typeof U==="object"&&!K1(U)){let W=w,A=Object.getOwnPropertyNames(U),X=Object.entries(W.properties),[Z,$]=[1/X.length,X.length];return X.reduce((Q,[Y,B])=>{let G=B[N]==="Literal"&&B.const===U[Y]?$:0,_=r(B,z,U[Y])?Z:0,H=A.includes(Y)?Z:0;return Q+(G+_+H)},0)}else return r(w,z,U)?1:0}function vB(w,z,U){let W=w.anyOf.map((Z)=>J0(Z,z)),[A,X]=[W[0],0];for(let Z of W){let $=iB(Z,z,U);if($>X)A=Z,X=$}return A}function nB(w,z,U){if("default"in w)return typeof U==="function"?w.default:B0(w.default);else{let W=vB(w,z,U);return _w(W,z,U)}}function uB(w,z,U){return r(w,z,U)?B0(U):o2(w,z)}function mB(w,z,U){return r(w,z,U)?U:o2(w,z)}function tB(w,z,U){if(r(w,z,U))return B0(U);let W=n(U)?B0(U):o2(w,z),A=d(w.minItems)&&W.length<w.minItems?[...W,...Array.from({length:w.minItems-W.length},()=>null)]:W,Z=(d(w.maxItems)&&A.length>w.maxItems?A.slice(0,w.maxItems):A).map((Q)=>X1(w.items,z,Q));if(w.uniqueItems!==!0)return Z;let $=[...new Set(Z)];if(!r(w,z,$))throw new Sw(w,"Array cast produced invalid data due to uniqueItems constraint");return $}function pB(w,z,U){if(r(w,z,U))return o2(w,z);let W=new Set(w.returns.required||[]),A=function(){};for(let[X,Z]of Object.entries(w.returns.properties)){if(!W.has(X)&&U.prototype[X]===void 0)continue;A.prototype[X]=X1(Z,z,U.prototype[X])}return A}function oB(w,z,U){let W=globalThis.Object.values(w.$defs),A=w.$defs[w.$ref];return X1(A,[...z,...W],U)}function lB(w,z,U){let W=o2(w,z),A=s(W)&&s(U)?{...W,...U}:U;return r(w,z,A)?A:o2(w,z)}function sB(w,z,U){throw new Sw(w,"Never types cannot be cast")}function rB(w,z,U){if(r(w,z,U))return U;if(U===null||typeof U!=="object")return o2(w,z);let W=new Set(w.required||[]),A={};for(let[X,Z]of Object.entries(w.properties)){if(!W.has(X)&&U[X]===void 0)continue;A[X]=X1(Z,z,U[X])}if(typeof w.additionalProperties==="object"){let X=Object.getOwnPropertyNames(w.properties);for(let Z of Object.getOwnPropertyNames(U)){if(X.includes(Z))continue;A[Z]=X1(w.additionalProperties,z,U[Z])}}return A}function aB(w,z,U){if(r(w,z,U))return B0(U);if(U===null||typeof U!=="object"||Array.isArray(U)||U instanceof Date)return o2(w,z);let W=Object.getOwnPropertyNames(w.patternProperties)[0],A=w.patternProperties[W],X={};for(let[Z,$]of Object.entries(U))X[Z]=X1(A,z,$);return X}function eB(w,z,U){return X1(J0(w,z),z,U)}function wM(w,z,U){return X1(J0(w,z),z,U)}function zM(w,z,U){if(r(w,z,U))return B0(U);if(!n(U))return o2(w,z);if(w.items===void 0)return[];return w.items.map((W,A)=>X1(W,z,U[A]))}function UM(w,z,U){return r(w,z,U)?B0(U):nB(w,z,U)}function X1(w,z,U){let W=$0(w.$id)?e0(w,z):z,A=w;switch(w[N]){case"Array":return tB(A,W,U);case"Constructor":return pB(A,W,U);case"Import":return oB(A,W,U);case"Intersect":return lB(A,W,U);case"Never":return sB(A,W,U);case"Object":return rB(A,W,U);case"Record":return aB(A,W,U);case"Ref":return eB(A,W,U);case"This":return wM(A,W,U);case"Tuple":return zM(A,W,U);case"Union":return UM(A,W,U);case"Date":case"Symbol":case"Uint8Array":return uB(w,z,U);default:return mB(A,W,U)}}function _w(...w){return w.length===3?X1(w[0],w[1],w[2]):X1(w[0],[],w[1])}function WM(w){return p1(w)&&w[N]!=="Unsafe"}function AM(w,z,U){if(!n(U))return U;return U.map((W)=>C2(w.items,z,W))}function XM(w,z,U){let W=globalThis.Object.values(w.$defs),A=w.$defs[w.$ref];return C2(A,[...z,...W],U)}function ZM(w,z,U){let W=w.unevaluatedProperties,X=w.allOf.map(($)=>C2($,z,B0(U))).reduce(($,Q)=>s(Q)?{...$,...Q}:Q,{});if(!s(U)||!s(X)||!p1(W))return X;let Z=O2(w);for(let $ of Object.getOwnPropertyNames(U)){if(Z.includes($))continue;if(r(W,z,U[$]))X[$]=C2(W,z,U[$])}return X}function $M(w,z,U){if(!s(U)||n(U))return U;let W=w.additionalProperties;for(let A of Object.getOwnPropertyNames(U)){if(v(w.properties,A)){U[A]=C2(w.properties[A],z,U[A]);continue}if(p1(W)&&r(W,z,U[A])){U[A]=C2(W,z,U[A]);continue}delete U[A]}return U}function QM(w,z,U){if(!s(U))return U;let W=w.additionalProperties,A=Object.getOwnPropertyNames(U),[X,Z]=Object.entries(w.patternProperties)[0],$=new RegExp(X);for(let Q of A){if($.test(Q)){U[Q]=C2(Z,z,U[Q]);continue}if(p1(W)&&r(W,z,U[Q])){U[Q]=C2(W,z,U[Q]);continue}delete U[Q]}return U}function YM(w,z,U){return C2(J0(w,z),z,U)}function JM(w,z,U){return C2(J0(w,z),z,U)}function BM(w,z,U){if(!n(U))return U;if(T0(w.items))return[];let W=Math.min(U.length,w.items.length);for(let A=0;A<W;A++)U[A]=C2(w.items[A],z,U[A]);return U.length>W?U.slice(0,W):U}function MM(w,z,U){for(let W of w.anyOf)if(WM(W)&&r(W,z,U))return C2(W,z,U);return U}function C2(w,z,U){let W=$0(w.$id)?e0(w,z):z,A=w;switch(A[N]){case"Array":return AM(A,W,U);case"Import":return XM(A,W,U);case"Intersect":return ZM(A,W,U);case"Object":return $M(A,W,U);case"Record":return QM(A,W,U);case"Ref":return YM(A,W,U);case"This":return JM(A,W,U);case"Tuple":return BM(A,W,U);case"Union":return MM(A,W,U);default:return U}}function D8(...w){return w.length===3?C2(w[0],w[1],w[2]):C2(w[0],[],w[1])}function P8(w){return $0(w)&&!isNaN(w)&&!isNaN(parseFloat(w))}function qM(w){return A2(w)||G1(w)||d(w)}function F4(w){return w===!0||d(w)&&w===1||A2(w)&&w===BigInt("1")||$0(w)&&(w.toLowerCase()==="true"||w==="1")}function j4(w){return w===!1||d(w)&&(w===0||Object.is(w,-0))||A2(w)&&w===BigInt("0")||$0(w)&&(w.toLowerCase()==="false"||w==="0"||w==="-0")}function HM(w){return $0(w)&&/^(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)$/i.test(w)}function GM(w){return $0(w)&&/^(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)?$/i.test(w)}function LM(w){return $0(w)&&/^\d\d\d\d-[0-1]\d-[0-3]\dt(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)$/i.test(w)}function NM(w){return $0(w)&&/^\d\d\d\d-[0-1]\d-[0-3]\dt(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)?$/i.test(w)}function SM(w){return $0(w)&&/^\d\d\d\d-[0-1]\d-[0-3]\d$/i.test(w)}function _M(w,z){let U=v7(w);return U===z?U:w}function DM(w,z){let U=n7(w);return U===z?U:w}function PM(w,z){let U=i7(w);return U===z?U:w}function OM(w,z){return $0(w.const)?_M(z,w.const):d(w.const)?DM(z,w.const):G1(w.const)?PM(z,w.const):z}function i7(w){return F4(w)?!0:j4(w)?!1:w}function bM(w){let z=(U)=>U.split(".")[0];return P8(w)?BigInt(z(w)):d(w)?BigInt(Math.trunc(w)):j4(w)?BigInt(0):F4(w)?BigInt(1):w}function v7(w){return F1(w)&&w.description!==void 0?w.description.toString():qM(w)?w.toString():w}function n7(w){return P8(w)?parseFloat(w):F4(w)?1:j4(w)?0:w}function RM(w){return P8(w)?parseInt(w):d(w)?w|0:F4(w)?1:j4(w)?0:w}function CM(w){return $0(w)&&w.toLowerCase()==="null"?null:w}function KM(w){return $0(w)&&w==="undefined"?void 0:w}function FM(w){return G2(w)?w:d(w)?new Date(w):F4(w)?new Date(1):j4(w)?new Date(0):P8(w)?new Date(parseInt(w)):GM(w)?new Date(`1970-01-01T${w}.000Z`):HM(w)?new Date(`1970-01-01T${w}`):NM(w)?new Date(`${w}.000Z`):LM(w)?new Date(w):SM(w)?new Date(`${w}T00:00:00.000Z`):w}function jM(w){return w}function EM(w,z,U){return(n(U)?U:[U]).map((A)=>Z1(w.items,z,A))}function IM(w,z,U){return bM(U)}function xM(w,z,U){return i7(U)}function VM(w,z,U){return FM(U)}function kM(w,z,U){let W=globalThis.Object.values(w.$defs),A=w.$defs[w.$ref];return Z1(A,[...z,...W],U)}function TM(w,z,U){return RM(U)}function gM(w,z,U){return w.allOf.reduce((W,A)=>Z1(A,z,W),U)}function fM(w,z,U){return OM(w,U)}function dM(w,z,U){return CM(U)}function hM(w,z,U){return n7(U)}function yM(w,z,U){if(!s(U))return U;for(let W of Object.getOwnPropertyNames(w.properties)){if(!v(U,W))continue;U[W]=Z1(w.properties[W],z,U[W])}return U}function cM(w,z,U){if(!s(U))return U;let A=Object.getOwnPropertyNames(w.patternProperties)[0],X=w.patternProperties[A];for(let[Z,$]of Object.entries(U))U[Z]=Z1(X,z,$);return U}function iM(w,z,U){return Z1(J0(w,z),z,U)}function vM(w,z,U){return v7(U)}function nM(w,z,U){return $0(U)||d(U)?Symbol(U):U}function uM(w,z,U){return Z1(J0(w,z),z,U)}function mM(w,z,U){if(!(n(U)&&!T0(w.items)))return U;return U.map((A,X)=>{return X<w.items.length?Z1(w.items[X],z,A):A})}function tM(w,z,U){return KM(U)}function pM(w,z,U){for(let W of w.anyOf){let A=Z1(W,z,B0(U));if(!r(W,z,A))continue;return A}return U}function Z1(w,z,U){let W=e0(w,z),A=w;switch(w[N]){case"Array":return EM(A,W,U);case"BigInt":return IM(A,W,U);case"Boolean":return xM(A,W,U);case"Date":return VM(A,W,U);case"Import":return kM(A,W,U);case"Integer":return TM(A,W,U);case"Intersect":return gM(A,W,U);case"Literal":return fM(A,W,U);case"Null":return dM(A,W,U);case"Number":return hM(A,W,U);case"Object":return yM(A,W,U);case"Record":return cM(A,W,U);case"Ref":return iM(A,W,U);case"String":return vM(A,W,U);case"Symbol":return nM(A,W,U);case"This":return uM(A,W,U);case"Tuple":return mM(A,W,U);case"Undefined":return tM(A,W,U);case"Union":return pM(A,W,U);default:return jM(U)}}function O8(...w){return w.length===3?Z1(w[0],w[1],w[2]):Z1(w[0],[],w[1])}function u7(...w){let[z,U,W]=w.length===3?[w[0],w[1],w[2]]:[w[0],[],w[1]];if(!r(z,U,W))throw new C4(z,W,_1(z,U,W).First());return h1(z,U)?l6(z,U,W):W}function c1(w,z){let U=v(w,"default")?w.default:void 0,W=m1(U)?U():B0(U);return T0(z)?W:s(z)&&s(W)?Object.assign(W,z):z}function Dw(w){return p1(w)&&"default"in w}function oM(w,z,U){if(n(U)){for(let A=0;A<U.length;A++)U[A]=L2(w.items,z,U[A]);return U}let W=c1(w,U);if(!n(W))return W;for(let A=0;A<W.length;A++)W[A]=L2(w.items,z,W[A]);return W}function lM(w,z,U){return G2(U)?U:c1(w,U)}function sM(w,z,U){let W=globalThis.Object.values(w.$defs),A=w.$defs[w.$ref];return L2(A,[...z,...W],U)}function rM(w,z,U){let W=c1(w,U);return w.allOf.reduce((A,X)=>{let Z=L2(X,z,W);return s(Z)?{...A,...Z}:Z},{})}function aM(w,z,U){let W=c1(w,U);if(!s(W))return W;let A=Object.getOwnPropertyNames(w.properties);for(let X of A){let Z=L2(w.properties[X],z,W[X]);if(T0(Z))continue;W[X]=L2(w.properties[X],z,W[X])}if(!Dw(w.additionalProperties))return W;for(let X of Object.getOwnPropertyNames(W)){if(A.includes(X))continue;W[X]=L2(w.additionalProperties,z,W[X])}return W}function eM(w,z,U){let W=c1(w,U);if(!s(W))return W;let A=w.additionalProperties,[X,Z]=Object.entries(w.patternProperties)[0],$=new RegExp(X);for(let Q of Object.getOwnPropertyNames(W)){if(!($.test(Q)&&Dw(Z)))continue;W[Q]=L2(Z,z,W[Q])}if(!Dw(A))return W;for(let Q of Object.getOwnPropertyNames(W)){if($.test(Q))continue;W[Q]=L2(A,z,W[Q])}return W}function wq(w,z,U){return L2(J0(w,z),z,c1(w,U))}function zq(w,z,U){return L2(J0(w,z),z,U)}function Uq(w,z,U){let W=c1(w,U);if(!n(W)||T0(w.items))return W;let[A,X]=[w.items,Math.max(w.items.length,W.length)];for(let Z=0;Z<X;Z++)if(Z<A.length)W[Z]=L2(A[Z],z,W[Z]);return W}function Wq(w,z,U){let W=c1(w,U);for(let A of w.anyOf){let X=L2(A,z,B0(W));if(r(A,z,X))return X}return W}function L2(w,z,U){let W=e0(w,z),A=w;switch(A[N]){case"Array":return oM(A,W,U);case"Date":return lM(A,W,U);case"Import":return sM(A,W,U);case"Intersect":return rM(A,W,U);case"Object":return aM(A,W,U);case"Record":return eM(A,W,U);case"Ref":return wq(A,W,U);case"This":return zq(A,W,U);case"Tuple":return Uq(A,W,U);case"Union":return Wq(A,W,U);default:return c1(A,U)}}function b8(...w){return w.length===3?L2(w[0],w[1],w[2]):L2(w[0],[],w[1])}var $1={};J6($1,{ValuePointerRootSetError:()=>Pw,ValuePointerRootDeleteError:()=>Ow,Set:()=>Aq,Has:()=>Zq,Get:()=>$q,Format:()=>E4,Delete:()=>Xq});class Pw extends y{constructor(w,z,U){super("Cannot set root value");this.value=w,this.path=z,this.update=U}}class Ow extends y{constructor(w,z){super("Cannot delete root value");this.value=w,this.path=z}}function m7(w){return w.indexOf("~")===-1?w:w.replace(/~1/g,"/").replace(/~0/g,"~")}function*E4(w){if(w==="")return;let[z,U]=[0,0];for(let W=0;W<w.length;W++)if(w.charAt(W)==="/")if(W===0)z=W+1;else U=W,yield m7(w.slice(z,U)),z=W+1;else U=W;yield m7(w.slice(z))}function Aq(w,z,U){if(z==="")throw new Pw(w,z,U);let[W,A,X]=[null,w,""];for(let Z of E4(z)){if(A[Z]===void 0)A[Z]={};W=A,A=A[Z],X=Z}W[X]=U}function Xq(w,z){if(z==="")throw new Ow(w,z);let[U,W,A]=[null,w,""];for(let X of E4(z)){if(W[X]===void 0||W[X]===null)return;U=W,W=W[X],A=X}if(Array.isArray(U)){let X=parseInt(A);U.splice(X,1)}else delete U[A]}function Zq(w,z){if(z==="")return!0;let[U,W,A]=[null,w,""];for(let X of E4(z)){if(W[X]===void 0)return!1;U=W,W=W[X],A=X}return Object.getOwnPropertyNames(U).includes(A)}function $q(w,z){if(z==="")return w;let U=w;for(let W of E4(z)){if(U[W]===void 0)return;U=U[W]}return U}function Qq(w,z){if(!s(z))return!1;let U=[...Object.keys(w),...Object.getOwnPropertySymbols(w)],W=[...Object.keys(z),...Object.getOwnPropertySymbols(z)];if(U.length!==W.length)return!1;return U.every((A)=>D6(w[A],z[A]))}function Yq(w,z){return G2(z)&&w.getTime()===z.getTime()}function Jq(w,z){if(!n(z)||w.length!==z.length)return!1;return w.every((U,W)=>D6(U,z[W]))}function Bq(w,z){if(!d2(z)||w.length!==z.length||Object.getPrototypeOf(w).constructor.name!==Object.getPrototypeOf(z).constructor.name)return!1;return w.every((U,W)=>D6(U,z[W]))}function Mq(w,z){return w===z}function D6(w,z){if(G2(w))return Yq(w,z);if(d2(w))return Bq(w,z);if(n(w))return Jq(w,z);if(s(w))return Qq(w,z);if(V2(w))return Mq(w,z);throw new Error("ValueEquals: Unable to compare value")}var qq=_0({type:X0("insert"),path:c2(),value:T1()}),Hq=_0({type:X0("update"),path:c2(),value:T1()}),Gq=_0({type:X0("delete"),path:c2()}),p7=G0([qq,Hq,Gq]);class bw extends y{constructor(w,z){super(z);this.value=w}}function R8(w,z){return{type:"update",path:w,value:z}}function o7(w,z){return{type:"insert",path:w,value:z}}function l7(w){return{type:"delete",path:w}}function t7(w){if(globalThis.Object.getOwnPropertySymbols(w).length>0)throw new bw(w,"Cannot diff objects with symbols")}function*Lq(w,z,U){if(t7(z),t7(U),!n5(U))return yield R8(w,U);let W=globalThis.Object.getOwnPropertyNames(z),A=globalThis.Object.getOwnPropertyNames(U);for(let X of A){if(v(z,X))continue;yield o7(`${w}/${X}`,U[X])}for(let X of W){if(!v(U,X))continue;if(D6(z,U))continue;yield*C8(`${w}/${X}`,z[X],U[X])}for(let X of W){if(v(U,X))continue;yield l7(`${w}/${X}`)}}function*Nq(w,z,U){if(!n(U))return yield R8(w,U);for(let W=0;W<Math.min(z.length,U.length);W++)yield*C8(`${w}/${W}`,z[W],U[W]);for(let W=0;W<U.length;W++){if(W<z.length)continue;yield o7(`${w}/${W}`,U[W])}for(let W=z.length-1;W>=0;W--){if(W<U.length)continue;yield l7(`${w}/${W}`)}}function*Sq(w,z,U){if(!d2(U)||z.length!==U.length||globalThis.Object.getPrototypeOf(z).constructor.name!==globalThis.Object.getPrototypeOf(U).constructor.name)return yield R8(w,U);for(let W=0;W<Math.min(z.length,U.length);W++)yield*C8(`${w}/${W}`,z[W],U[W])}function*_q(w,z,U){if(z===U)return;yield R8(w,U)}function*C8(w,z,U){if(n5(z))return yield*Lq(w,z,U);if(n(z))return yield*Nq(w,z,U);if(d2(z))return yield*Sq(w,z,U);if(V2(z))return yield*_q(w,z,U);throw new bw(z,"Unable to diff value")}function s7(w,z){return[...C8("",w,z)]}function Dq(w){return w.length>0&&w[0].path===""&&w[0].type==="update"}function Pq(w){return w.length===0}function r7(w,z){if(Dq(z))return B0(z[0].value);if(Pq(z))return B0(w);let U=B0(w);for(let W of z)switch(W.type){case"insert":{$1.Set(U,W.path,W.value);break}case"update":{$1.Set(U,W.path,W.value);break}case"delete":{$1.Delete(U,W.path);break}}return U}function a7(...w){let[z,U,W]=w.length===3?[w[0],w[1],w[2]]:[w[0],[],w[1]],A=h1(z,U)?s6(z,U,W):W;if(!r(z,U,A))throw new K4(z,A,_1(z,U,A).First());return A}function K8(w){return s(w)&&!n(w)}class Rw extends y{constructor(w){super(w)}}function Oq(w,z,U,W){if(!K8(U))$1.Set(w,z,B0(W));else{let A=Object.getOwnPropertyNames(U),X=Object.getOwnPropertyNames(W);for(let Z of A)if(!X.includes(Z))delete U[Z];for(let Z of X)if(!A.includes(Z))U[Z]=null;for(let Z of X)Cw(w,`${z}/${Z}`,U[Z],W[Z])}}function bq(w,z,U,W){if(!n(U))$1.Set(w,z,B0(W));else{for(let A=0;A<W.length;A++)Cw(w,`${z}/${A}`,U[A],W[A]);U.splice(W.length)}}function Rq(w,z,U,W){if(d2(U)&&U.length===W.length)for(let A=0;A<U.length;A++)U[A]=W[A];else $1.Set(w,z,B0(W))}function Cq(w,z,U,W){if(U===W)return;$1.Set(w,z,W)}function Cw(w,z,U,W){if(n(W))return bq(w,z,U,W);if(d2(W))return Rq(w,z,U,W);if(K8(W))return Oq(w,z,U,W);if(V2(W))return Cq(w,z,U,W)}function e7(w){return d2(w)||V2(w)}function Kq(w,z){return K8(w)&&n(z)||n(w)&&K8(z)}function wU(w,z){if(e7(w)||e7(z))throw new Rw("Only object and array types can be mutated at the root level");if(Kq(w,z))throw new Rw("Cannot assign due type mismatch of assignable values");Cw(w,"",w,z)}class Fw extends y{constructor(w){super(w)}}var Kw;(function(w){let z=new Map([["Clone",(X,Z,$)=>B0($)],["Clean",(X,Z,$)=>D8(X,Z,$)],["Default",(X,Z,$)=>b8(X,Z,$)],["Convert",(X,Z,$)=>O8(X,Z,$)],["Assert",(X,Z,$)=>{return _8(X,Z,$),$}],["Decode",(X,Z,$)=>h1(X,Z)?l6(X,Z,$):$],["Encode",(X,Z,$)=>h1(X,Z)?s6(X,Z,$):$]]);function U(X){z.delete(X)}w.Delete=U;function W(X,Z){z.set(X,Z)}w.Set=W;function A(X){return z.get(X)}w.Get=A})(Kw||(Kw={}));var zU=["Clone","Clean","Default","Convert","Assert","Decode"];function Fq(w,z,U,W){return w.reduce((A,X)=>{let Z=Kw.Get(X);if(T0(Z))throw new Fw(`Unable to find Parse operation '${X}'`);return Z(z,U,A)},W)}function UU(...w){let[z,U,W,A]=w.length===4?[w[0],w[1],w[2],w[3]]:w.length===3?n(w[0])?[w[0],w[1],[],w[2]]:[zU,w[0],w[1],w[2]]:w.length===2?[zU,w[0],[],w[1]]:(()=>{throw new Fw("Invalid Arguments")})();return Fq(z,U,W,A)}var p={};J6(p,{ValueErrorIterator:()=>S6,Patch:()=>r7,Parse:()=>UU,Mutate:()=>wU,Hash:()=>e1,Errors:()=>_1,Equal:()=>D6,Encode:()=>a7,Edit:()=>p7,Diff:()=>s7,Default:()=>b8,Decode:()=>u7,Create:()=>o2,Convert:()=>O8,Clone:()=>B0,Clean:()=>D8,Check:()=>r,Cast:()=>_w,Assert:()=>_8});var y8=n4(ZU(),1),mU=n4(F8(),1);var b6=n4(F8(),1),sU=n4(F8(),1);var cw={date:EU,time:fw(!0),"date-time":JU(!0),"iso-time":fw(!1),"iso-date-time":JU(!1),duration:/^P(?!$)((\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+S)?)?|(\d+W)?)$/,uri:sq,"uri-reference":/^(?:[a-z][a-z0-9+\-.]*:)?(?:\/?\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:]|%[0-9a-f]{2})*@)?(?:\[(?:(?:(?:(?:[0-9a-f]{1,4}:){6}|::(?:[0-9a-f]{1,4}:){5}|(?:[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){4}|(?:(?:[0-9a-f]{1,4}:){0,1}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){3}|(?:(?:[0-9a-f]{1,4}:){0,2}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){2}|(?:(?:[0-9a-f]{1,4}:){0,3}[0-9a-f]{1,4})?::[0-9a-f]{1,4}:|(?:(?:[0-9a-f]{1,4}:){0,4}[0-9a-f]{1,4})?::)(?:[0-9a-f]{1,4}:[0-9a-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?))|(?:(?:[0-9a-f]{1,4}:){0,5}[0-9a-f]{1,4})?::[0-9a-f]{1,4}|(?:(?:[0-9a-f]{1,4}:){0,6}[0-9a-f]{1,4})?::)|[Vv][0-9a-f]+\.[a-z0-9\-._~!$&'()*+,;=:]+)\]|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)|(?:[a-z0-9\-._~!$&'"()*+,;=]|%[0-9a-f]{2})*)(?::\d*)?(?:\/(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})*)*|\/(?:(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})*)*)?|(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})*)*)?(?:\?(?:[a-z0-9\-._~!$&'"()*+,;=:@/?]|%[0-9a-f]{2})*)?(?:#(?:[a-z0-9\-._~!$&'"()*+,;=:@/?]|%[0-9a-f]{2})*)?$/i,"uri-template":/^(?:(?:[^\x00-\x20"'<>%\\^`{|}]|%[0-9a-f]{2})|\{[+#./;?&=,!@|]?(?:[a-z0-9_]|%[0-9a-f]{2})+(?::[1-9][0-9]{0,3}|\*)?(?:,(?:[a-z0-9_]|%[0-9a-f]{2})+(?::[1-9][0-9]{0,3}|\*)?)*\})*$/i,url:/^(?:https?|ftp):\/\/(?:\S+(?::\S*)?@)?(?:(?!(?:10|127)(?:\.\d{1,3}){3})(?!(?:169\.254|192\.168)(?:\.\d{1,3}){2})(?!172\.(?:1[6-9]|2\d|3[0-1])(?:\.\d{1,3}){2})(?:[1-9]\d?|1\d\d|2[01]\d|22[0-3])(?:\.(?:1?\d{1,2}|2[0-4]\d|25[0-5])){2}(?:\.(?:[1-9]\d?|1\d\d|2[0-4]\d|25[0-4]))|(?:(?:[a-z0-9\u{00a1}-\u{ffff}]+-)*[a-z0-9\u{00a1}-\u{ffff}]+)(?:\.(?:[a-z0-9\u{00a1}-\u{ffff}]+-)*[a-z0-9\u{00a1}-\u{ffff}]+)*(?:\.(?:[a-z\u{00a1}-\u{ffff}]{2,})))(?::\d{2,5})?(?:\/[^\s]*)?$/iu,email:/^[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$/i,hostname:/^(?=.{1,253}\.?$)[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?(?:\.[a-z0-9](?:[-0-9a-z]{0,61}[0-9a-z])?)*\.?$/i,ipv4:/^(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)$/,ipv6:/^((([0-9a-f]{1,4}:){7}([0-9a-f]{1,4}|:))|(([0-9a-f]{1,4}:){6}(:[0-9a-f]{1,4}|((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9a-f]{1,4}:){5}(((:[0-9a-f]{1,4}){1,2})|:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9a-f]{1,4}:){4}(((:[0-9a-f]{1,4}){1,3})|((:[0-9a-f]{1,4})?:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){3}(((:[0-9a-f]{1,4}){1,4})|((:[0-9a-f]{1,4}){0,2}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){2}(((:[0-9a-f]{1,4}){1,5})|((:[0-9a-f]{1,4}){0,3}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){1}(((:[0-9a-f]{1,4}){1,6})|((:[0-9a-f]{1,4}){0,4}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(:(((:[0-9a-f]{1,4}){1,7})|((:[0-9a-f]{1,4}){0,5}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:)))$/i,regex:WH,uuid:/^(?:urn:uuid:)?[0-9a-f]{8}-(?:[0-9a-f]{4}-){3}[0-9a-f]{12}$/i,"json-pointer":/^(?:\/(?:[^~/]|~0|~1)*)*$/,"json-pointer-uri-fragment":/^#(?:\/(?:[a-z0-9_\-.!$&'()*+,;:=@]|%[0-9a-f]{2}|~0|~1)*)*$/i,"relative-json-pointer":/^(?:0|[1-9][0-9]*)(?:#|(?:\/(?:[^~/]|~0|~1)*)*)$/,byte:rq,int32:{type:"number",validate:wH},int64:{type:"number",validate:zH},float:{type:"number",validate:MU},double:{type:"number",validate:MU},password:!0,binary:!0};function nq(w){return w%4===0&&(w%100!==0||w%400===0)}var uq=/^(\d\d\d\d)-(\d\d)-(\d\d)$/,mq=[0,31,28,31,30,31,30,31,31,30,31,30,31];function EU(w){let z=uq.exec(w);if(!z)return!1;let U=+z[1],W=+z[2],A=+z[3];return W>=1&&W<=12&&A>=1&&A<=(W===2&&nq(U)?29:mq[W])}var tq=/^(\d\d):(\d\d):(\d\d(?:\.\d+)?)(z|([+-])(\d\d)(?::?(\d\d))?)?$/i;function fw(w){return function z(U){let W=tq.exec(U);if(!W)return!1;let A=+W[1],X=+W[2],Z=+W[3],$=W[4],Q=W[5]==="-"?-1:1,Y=+(W[6]||0),B=+(W[7]||0);if(Y>23||B>59||w&&!$)return!1;if(A<=23&&X<=59&&Z<60)return!0;let G=X-B*Q,_=A-Y*Q-(G<0?1:0);return(_===23||_===-1)&&(G===59||G===-1)&&Z<61}}var pq=/t|\s/i;function JU(w){let z=fw(w);return function U(W){let A=W.split(pq);return A.length===2&&EU(A[0])&&z(A[1])}}var oq=/\/|:/,lq=/^(?:[a-z][a-z0-9+\-.]*:)(?:\/?\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:]|%[0-9a-f]{2})*@)?(?:\[(?:(?:(?:(?:[0-9a-f]{1,4}:){6}|::(?:[0-9a-f]{1,4}:){5}|(?:[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){4}|(?:(?:[0-9a-f]{1,4}:){0,1}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){3}|(?:(?:[0-9a-f]{1,4}:){0,2}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){2}|(?:(?:[0-9a-f]{1,4}:){0,3}[0-9a-f]{1,4})?::[0-9a-f]{1,4}:|(?:(?:[0-9a-f]{1,4}:){0,4}[0-9a-f]{1,4})?::)(?:[0-9a-f]{1,4}:[0-9a-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?))|(?:(?:[0-9a-f]{1,4}:){0,5}[0-9a-f]{1,4})?::[0-9a-f]{1,4}|(?:(?:[0-9a-f]{1,4}:){0,6}[0-9a-f]{1,4})?::)|[Vv][0-9a-f]+\.[a-z0-9\-._~!$&'()*+,;=:]+)\]|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)|(?:[a-z0-9\-._~!$&'()*+,;=]|%[0-9a-f]{2})*)(?::\d*)?(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*|\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*)?|(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*)(?:\?(?:[a-z0-9\-._~!$&'()*+,;=:@/?]|%[0-9a-f]{2})*)?(?:#(?:[a-z0-9\-._~!$&'()*+,;=:@/?]|%[0-9a-f]{2})*)?$/i;function sq(w){return oq.test(w)&&lq.test(w)}var BU=/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/gm;function rq(w){return BU.lastIndex=0,BU.test(w)}var aq=-2147483648,eq=2147483647;function wH(w){return Number.isInteger(w)&&w<=eq&&w>=aq}function zH(w){return Number.isInteger(w)}function MU(){return!0}var UH=/[^\\]\\Z/;function WH(w){if(UH.test(w))return!1;try{return new RegExp(w),!0}catch(z){return!1}}var IU="toJSON"in new Headers,j8=(w,z)=>{let U=new URL(w);return U.pathname=z,U.toString()},AH=(w)=>typeof w==="function"&&/^\s*class\s+/.test(w.toString())||w.toString().startsWith("[object ")&&w.toString()!=="[object Object]"||s2(Object.getPrototypeOf(w)),Ew=(w)=>w&&typeof w==="object"&&!Array.isArray(w),F2=(w,z,{skipKeys:U,override:W=!0}={})=>{if(!Ew(w)||!Ew(z))return w;for(let[A,X]of Object.entries(z)){if(U?.includes(A))continue;if(!Ew(X)||!(A in w)||AH(X)){if(W||!(A in w))w[A]=X;continue}w[A]=F2(w[A],X,{skipKeys:U,override:W})}return w},XH=(w,z)=>{let{properties:U,...W}=w??{},{properties:A,...X}=z??{};return F2(W,X)},v0=(w=[],z=[])=>{if(!w)return[];if(!z)return w;let U=[],W=[];if(!Array.isArray(w))w=[w];if(!Array.isArray(z))z=[z];for(let A of w)if(U.push(A),A.checksum)W.push(A.checksum);for(let A of z)if(!W.includes(A.checksum))U.push(A);return U},ZH=["start","request","parse","transform","resolve","beforeHandle","afterHandle","mapResponse","afterResponse","trace","error","stop","body","headers","params","query","response","type","detail"],$H=ZH.reduce((w,z)=>(w[z]=!0,w),{}),xU=(w,z)=>{let U=(W)=>typeof W==="object"&&Object.keys(W).every(iw);if(U(w)&&U(z))return{...w,...z};else if(w&&!U(w)&&U(z))return{200:w,...z};return z??w},I4=(w,z)=>{return{body:z?.body??w?.body,headers:z?.headers??w?.headers,params:z?.params??w?.params,query:z?.query??w?.query,cookie:z?.cookie??w?.cookie,response:xU(w?.response,z?.response)}},D1=(w,z)=>{let{resolve:U,...W}=w??{},{resolve:A,...X}=z??{};return{...W,...X,body:z?.body??w?.body,headers:z?.headers??w?.headers,params:z?.params??w?.params,query:z?.query??w?.query,cookie:z?.cookie??w?.cookie,response:xU(w?.response,z?.response),type:w?.type||z?.type,detail:F2(z?.detail??{},w?.detail??{}),parse:v0(w?.parse,z?.parse),transform:v0(w?.transform,z?.transform),beforeHandle:v0(v0(W2(U,"resolve"),w?.beforeHandle),v0(W2(A,"resolve"),z?.beforeHandle)),afterHandle:v0(w?.afterHandle,z?.afterHandle),mapResponse:v0(w?.mapResponse,z?.mapResponse),afterResponse:v0(w?.afterResponse,z?.afterResponse),trace:v0(w?.trace,z?.trace),error:v0(w?.error,z?.error)}},dw=(w,z,U=!0)=>{if(!Array.isArray(z))return B2(w,z,U);for(let W of z)w=B2(w,W,U);return w},B2=(w,z,U=!0)=>{if(!w)return w;if(z.untilObjectFound&&!U&&w.type==="object")return w;let W=z.from[N];if(w.oneOf){for(let Z=0;Z<w.oneOf.length;Z++)w.oneOf[Z]=B2(w.oneOf[Z],z,U);return w}if(w.anyOf){for(let Z=0;Z<w.anyOf.length;Z++)w.anyOf[Z]=B2(w.anyOf[Z],z,U);return w}if(w.allOf){for(let Z=0;Z<w.allOf.length;Z++)w.allOf[Z]=B2(w.allOf[Z],z,U);return w}if(w.not){for(let Z=0;Z<w.not.length;Z++)w.not[Z]=B2(w.not[Z],z,U);return w}let A=U&&!!z.excludeRoot;if(w[N]===W){let{anyOf:Z,oneOf:$,allOf:Q,not:Y,properties:B,items:G,..._}=w,H=z.to(_),F,R=(J)=>{if(B&&J.type==="object"){let A0={};for(let[L0,h]of Object.entries(B))A0[L0]=B2(h,z,!1);return{..._,...J,properties:A0}}if(G&&J.type==="array")return{..._,...J,items:B2(G,z,!1)};let m={..._,...J};if(delete m.required,B&&J.type==="string"&&J.format==="ObjectString"&&J.default==="{}")F=I.ObjectString(B,_),m.default=JSON.stringify(p.Create(I.Object(B))),m.properties=B;if(G&&J.type==="string"&&J.format==="ArrayString"&&J.default==="[]")F=I.ArrayString(G,_),m.default=JSON.stringify(p.Create(I.Array(G))),m.items=G;return m};if(A){if(B){let J={};for(let[m,A0]of Object.entries(B))J[m]=B2(A0,z,!1);return{..._,properties:J}}else if(G?.map)return{..._,items:G.map((J)=>B2(J,z,!1))};return _}if(H.anyOf)for(let J=0;J<H.anyOf.length;J++)H.anyOf[J]=R(H.anyOf[J]);else if(H.oneOf)for(let J=0;J<H.oneOf.length;J++)H.oneOf[J]=R(H.oneOf[J]);else if(H.allOf)for(let J=0;J<H.allOf.length;J++)H.allOf[J]=R(H.allOf[J]);else if(H.not)for(let J=0;J<H.not.length;J++)H.not[J]=R(H.not[J]);if(F)H[F0]=F[F0];if(H.anyOf||H.oneOf||H.allOf||H.not)return H;if(B){let J={};for(let[m,A0]of Object.entries(B))J[m]=B2(A0,z,!1);return{..._,...H,properties:J}}else if(G?.map)return{..._,...H,items:G.map((J)=>B2(J,z,!1))};return{..._,...H}}let X=w?.properties;if(X&&U&&z.rootOnly!==!0)for(let[Z,$]of Object.entries(X))switch($[N]){case W:let{anyOf:Q,oneOf:Y,allOf:B,not:G,type:_,...H}=$,F=z.to(H);if(F.anyOf)for(let R=0;R<F.anyOf.length;R++)F.anyOf[R]={...H,...F.anyOf[R]};else if(F.oneOf)for(let R=0;R<F.oneOf.length;R++)F.oneOf[R]={...H,...F.oneOf[R]};else if(F.allOf)for(let R=0;R<F.allOf.length;R++)F.allOf[R]={...H,...F.allOf[R]};else if(F.not)for(let R=0;R<F.not.length;R++)F.not[R]={...H,...F.not[R]};X[Z]={...H,...B2(H,z,!1)};break;case"Object":case"Union":X[Z]=B2($,z,!1);break;default:if($.items)for(let R=0;R<$.items.length;R++)$.items[R]=B2($.items[R],z,!1);else if($.anyOf||$.oneOf||$.allOf||$.not)X[Z]=B2($,z,!1);break}return w},k4=(w)=>(z)=>{if(typeof z==="object")try{return p.Clean(w,structuredClone(z))}catch{try{return p.Clean(w,z)}catch{return z}}return z},j2=(w,{models:z={},dynamic:U=!1,modules:W,normalize:A=!1,additionalProperties:X=!1,coerce:Z=!1,additionalCoerce:$=[]}={modules:I.Module({})})=>{if(!w)return;if(typeof w==="string"&&!(w in z))return;let Q=typeof w==="string"?W.Import(w)??z[w]:w;if(Z||$)if(Z)Q=dw(Q,[{from:I.Ref(""),to:(B)=>W.Import(B.$ref)},{from:I.Number(),to:(B)=>I.Numeric(B),untilObjectFound:!0},{from:I.Boolean(),to:(B)=>I.BooleanString(B),untilObjectFound:!0},...Array.isArray($)?$:[$]]);else Q=dw(Q,[{from:I.Ref(""),to:(B)=>W.Import(B.$ref)},...Array.isArray($)?$:[$]]);if(Q.type==="object"&&"additionalProperties"in Q===!1)Q.additionalProperties=X;if(U){let B={schema:Q,references:"",checkFunc:()=>{},code:"",Check:(G)=>p.Check(Q,G),Errors:(G)=>p.Errors(Q,G),Code:()=>"",Clean:k4(Q),Decode:(G)=>p.Decode(Q,G),Encode:(G)=>p.Encode(Q,G)};if(A&&Q.additionalProperties===!1)B.Clean=k4(Q);if(Q.config){if(B.config=Q.config,B?.schema?.config)delete B.schema.config}return B.parse=(G)=>{try{return B.Decode(G)}catch(_){throw[...B.Errors(G)].map(J1)}},B.safeParse=(G)=>{try{return{success:!0,data:B.Decode(G),error:null}}catch(_){let H=[...Y.Errors(G)].map(J1);return{success:!1,data:null,error:H[0]?.summary,errors:H}}},B}let Y=w6.Compile(Q,Object.values(z));if(Y.Clean=k4(Q),Q.config){if(Y.config=Q.config,Y?.schema?.config)delete Y.schema.config}return Y.parse=(B)=>{try{return Y.Decode(B)}catch(G){throw[...Y.Errors(B)].map(J1)}},Y.safeParse=(B)=>{try{return{success:!0,data:Y.Decode(B),error:null}}catch(G){let _=[...Y.Errors(B)].map(J1);return{success:!1,data:null,error:_[0]?.summary,errors:_}}},Y},qU=(w,{models:z={},modules:U,dynamic:W=!1,normalize:A=!1,additionalProperties:X=!1})=>{if(!w)return;if(typeof w==="string"&&!(w in z))return;let Z=typeof w==="string"?U.Import(w)??z[w]:w,$=(Y,B)=>{if(W)return{schema:Y,references:"",checkFunc:()=>{},code:"",Check:(_)=>p.Check(Y,_),Errors:(_)=>p.Errors(Y,_),Code:()=>"",Clean:k4(Y),Decode:(_)=>p.Decode(Y,_),Encode:(_)=>p.Encode(Y,_)};let G=w6.Compile(Y,B);if(A&&Y.additionalProperties===!1)G.Clean=k4(Y);return G};if(N in Z){if("additionalProperties"in Z===!1)Z.additionalProperties=X;return{200:$(Z,Object.values(z))}}let Q={};return Object.keys(Z).forEach((Y)=>{let B=Z[+Y];if(typeof B==="string"){if(B in z){let G=z[B];G.type==="object"&&"additionalProperties"in G,Q[+Y]=N in G?$(G,Object.values(z)):G}return}if(B.type==="object"&&"additionalProperties"in B===!1)B.additionalProperties=X;Q[+Y]=N in B?$(B,Object.values(z)):B}),Q},QH=typeof Bun!=="undefined",YH=QH&&typeof Bun.hash==="function",x4=(w)=>{if(YH)return Bun.hash(w);let z=9;for(let U=0;U<w.length;)z=Math.imul(z^w.charCodeAt(U++),387420489);return z=z^z>>>9},Iw,P6=()=>{if(!Iw)Iw=[{from:I.Object({}),to:()=>I.ObjectString({}),excludeRoot:!0},{from:I.Array(I.Any()),to:()=>I.ArrayString(I.Any())}];return Iw},xw,HU=()=>{if(!xw)xw=[{from:I.Number(),to:(w)=>I.Numeric(w),rootOnly:!0},{from:I.Boolean(),to:(w)=>I.BooleanString(w),rootOnly:!0}];return xw},VU=({validator:w,modules:z,defaultConfig:U={},config:W,dynamic:A,models:X})=>{let Z=j2(w,{modules:z,dynamic:A,models:X,additionalProperties:!0,coerce:!0,additionalCoerce:P6()});if(s2(U))if(Z)Z.config=XH(Z.config,W);else Z=j2(I.Cookie({}),{modules:z,dynamic:A,models:X,additionalProperties:!0}),Z.config=U;return Z},Q1=(w,z)=>{if(!z)return;if(!Array.isArray(z)){let W=z;if(w&&!W.checksum)W.checksum=w;if(W.scope==="scoped")W.scope="local";return W}let U=[...z];for(let W of U){if(w&&!W.checksum)W.checksum=w;if(W.scope==="scoped")W.scope="local"}return U},GU=(w,z,U)=>{return{start:v0(w.start,Q1(U,z?.start)),request:v0(w.request,Q1(U,z?.request)),parse:v0(w.parse,Q1(U,z?.parse)),transform:v0(w.transform,Q1(U,z?.transform)),beforeHandle:v0(v0(W2(w.resolve,"resolve"),w.beforeHandle),Q1(U,v0(W2(z?.resolve,"resolve"),z?.beforeHandle))),afterHandle:v0(w.afterHandle,Q1(U,z?.afterHandle)),mapResponse:v0(w.mapResponse,Q1(U,z?.mapResponse)),afterResponse:v0(w.afterResponse,Q1(U,z?.afterResponse)),trace:v0(w.trace,Q1(U,z?.trace)),error:v0(w.error,Q1(U,z?.error)),stop:v0(w.stop,Q1(U,z?.stop))}},JH=(w,z,{skipIfHasType:U=!1}={})=>{if(!w)return w;if(!Array.isArray(w)){if(U)w.scope??=z;else w.scope=z;return w}for(let W of w)if(U)W.scope??=z;else W.scope=z;return w},z6=(w)=>{if(!w)return w;if(!Array.isArray(w))switch(w.scope){case"global":case"scoped":return{...w};default:return{fn:w}}let z=[];for(let U of w)switch(U.scope){case"global":case"scoped":z.push({...U});break}return z},LU=(w)=>{return{...w,type:w?.type,detail:w?.detail,parse:z6(w?.parse),transform:z6(w?.transform),beforeHandle:z6(w?.beforeHandle),afterHandle:z6(w?.afterHandle),mapResponse:z6(w?.mapResponse),afterResponse:z6(w?.afterResponse),error:z6(w?.error),trace:z6(w?.trace)}},f8={Continue:100,"Switching Protocols":101,Processing:102,"Early Hints":103,OK:200,Created:201,Accepted:202,"Non-Authoritative Information":203,"No Content":204,"Reset Content":205,"Partial Content":206,"Multi-Status":207,"Already Reported":208,"Multiple Choices":300,"Moved Permanently":301,Found:302,"See Other":303,"Not Modified":304,"Temporary Redirect":307,"Permanent Redirect":308,"Bad Request":400,Unauthorized:401,"Payment Required":402,Forbidden:403,"Not Found":404,"Method Not Allowed":405,"Not Acceptable":406,"Proxy Authentication Required":407,"Request Timeout":408,Conflict:409,Gone:410,"Length Required":411,"Precondition Failed":412,"Payload Too Large":413,"URI Too Long":414,"Unsupported Media Type":415,"Range Not Satisfiable":416,"Expectation Failed":417,"I'm a teapot":418,"Misdirected Request":421,"Unprocessable Content":422,Locked:423,"Failed Dependency":424,"Too Early":425,"Upgrade Required":426,"Precondition Required":428,"Too Many Requests":429,"Request Header Fields Too Large":431,"Unavailable For Legal Reasons":451,"Internal Server Error":500,"Not Implemented":501,"Bad Gateway":502,"Service Unavailable":503,"Gateway Timeout":504,"HTTP Version Not Supported":505,"Variant Also Negotiates":506,"Insufficient Storage":507,"Loop Detected":508,"Not Extended":510,"Network Authentication Required":511},NU=Object.fromEntries(Object.entries(f8).map(([w,z])=>[z,w]));function BH(w){let z=w;while(z.endsWith("="))z=z.slice(0,-1);return z}var SU=new TextEncoder,V8=async(w,z)=>{if(typeof w!=="string")throw new TypeError("Cookie value must be provided as a string.");if(z===null)throw new TypeError("Secret key must be provided.");let U=await crypto.subtle.importKey("raw",SU.encode(z),{name:"HMAC",hash:"SHA-256"},!1,["sign"]),W=await crypto.subtle.sign("HMAC",U,SU.encode(w));return w+"."+BH(Buffer.from(W).toString("base64"))},_U=async(w,z)=>{if(typeof w!=="string")throw new TypeError("Signed cookie string must be provided.");if(z===null)throw new TypeError("Secret key must be provided.");let U=w.slice(0,w.lastIndexOf("."));return await V8(U,z)===w?U:!1},MH=(w,z,U)=>{if(!w||typeof w!=="object"||!z)return;for(let[W,A]of Object.entries(z)){if(W in $H||!(W in w))continue;let X=w[W];if(typeof X==="function"){let Z=X(A);if(typeof Z==="object")for(let[$,Q]of Object.entries(Z))U($)({fn:Q});delete z[W]}}},qH=({globalHook:w,localHook:z})=>(U)=>(W,A)=>{if(typeof W==="function")W={fn:W};if(U==="resolve")W={...W,subType:"resolve"};if("fn"in W||Array.isArray(W)){if(!z[U])z[U]=[];if(typeof z[U]==="function")z[U]=[z[U]];if(Array.isArray(W))z[U]=z[U].concat(W);else z[U].push(W);return}let{insert:X="after",stack:Z="local"}=W;if(typeof A==="function")A={fn:A};if(Z==="global")if(!Array.isArray(A))if(X==="before")w[U].unshift(A);else w[U].push(A);else if(X==="before")w[U]=A.concat(w[U]);else w[U]=w[U].concat(A);else{if(!z[U])z[U]=[];if(typeof z[U]==="function")z[U]=[z[U]];if(!Array.isArray(A))if(X==="before")z[U].unshift(A);else z[U].push(A);else if(X==="before")z[U]=A.concat(z[U]);else z[U]=z[U].concat(A)}},HH=(w)=>{if(typeof w==="number")return w;if(w.length<16){if(w.trim().length===0)return null;let z=Number(w);if(Number.isNaN(z))return null;return z}if(w.length===16){if(w.trim().length===0)return null;let z=Number(w);if(Number.isNaN(z)||z.toString()!==w)return null;return z}return null},iw=(w)=>HH(w)!==null;class kU{onError;root=null;promises=[];constructor(w=console.error){this.onError=w}get size(){return this.promises.length}add(w){return this.promises.push(w),this.root||=this.drain(),w}async drain(){while(this.promises.length>0){try{await this.promises[0]}catch(w){this.onError(w)}this.promises.shift()}this.root=null}then(w,z){return(this.root??Promise.resolve()).then(w,z)}}var W2=(w,z)=>{if(!w)return w;if(!Array.isArray(w)){if(typeof w==="function"||typeof w==="string")return z?{fn:w,subType:z}:{fn:w};else if("fn"in w)return w}let U=[];for(let W of w)if(typeof W==="function"||typeof W==="string")U.push(z?{fn:W,subType:z}:{fn:W});else if("fn"in W)U.push(W);return U},GH=(w)=>{return{...w,start:W2(w?.start),request:W2(w?.request),parse:W2(w?.parse),transform:W2(w?.transform),beforeHandle:W2(w?.beforeHandle),afterHandle:W2(w?.afterHandle),mapResponse:W2(w?.mapResponse),afterResponse:W2(w?.afterResponse),trace:W2(w?.trace),error:W2(w?.error),stop:W2(w?.stop)}},DU=(w)=>{return{...w,start:w.start?.map((z)=>z.fn),request:w.request?.map((z)=>z.fn),parse:w.parse?.map((z)=>z.fn),transform:w.transform?.map((z)=>z.fn),beforeHandle:w.beforeHandle?.map((z)=>z.fn),afterHandle:w.afterHandle?.map((z)=>z.fn),afterResponse:w.afterResponse?.map((z)=>z.fn),mapResponse:w.mapResponse?.map((z)=>z.fn),trace:w.trace?.map((z)=>z.fn),error:w.error?.map((z)=>z.fn),stop:w.stop?.map((z)=>z.fn)}},Vw=(w)=>({body:w.body,cookie:w.cookie,headers:w.headers,query:w.query,set:w.set,server:w.server,request:w.request,route:w.route}),TU=(w,z=302)=>Response.redirect(w,z),PE=Symbol("ElysiaFormData"),d8=Symbol("ElysiaRequestId");var gU=()=>{let w=crypto.randomUUID();return w.slice(0,8)+w.slice(24,32)},PU=(w)=>{let z=[];for(let U=0;U<w.length;U++){let W=w[U];if(W.checksum){if(z.includes(W.checksum))w.splice(U,1),U--;z.push(W.checksum)}}return w},J2=(w,z="scoped")=>{if(z==="scoped"){for(let U of w)if("scope"in U&&U.scope==="local")U.scope="scoped";return}for(let U of w)if("scope"in U)U.scope="global"},r6=(w)=>{if(w.charCodeAt(w.length-1)===47)return w.slice(0,w.length-1);return w+"/"},s2=(w)=>{if(!w)return!1;for(let z in w)return!0;return!1},OU=typeof Bun!=="undefined"?Bun.env:typeof process!=="undefined"?process?.env:void 0,k8=Symbol("ElysiaErrorCode"),T8=(OU?.NODE_ENV??OU?.ENV)==="production";class M1{code;response;constructor(w,z){let U=z??(w in NU?NU[w]:w);this.code=f8[w]??w,this.response=U}}var LH=(w,z)=>new M1(w,z);class fU extends Error{code="INTERNAL_SERVER_ERROR";status=500;constructor(w){super(w??"INTERNAL_SERVER_ERROR")}}class h8 extends Error{code="NOT_FOUND";status=404;constructor(w){super(w??"NOT_FOUND")}}class dU extends Error{code="PARSE";status=400;constructor(){super("Bad Request")}}class hw extends Error{key;code="INVALID_COOKIE_SIGNATURE";status=400;constructor(w,z){super(z??`"${w}" has invalid cookie signature`);this.key=w}}var J1=(w)=>{if(!w)return{summary:void 0};let{message:z,path:U,value:W,type:A}=w,X=U.slice(1).replaceAll("/","."),Z=U==="";switch(A){case 42:return{...w,summary:Z?"Value should not be provided":`Property '${X}' should not be provided`};case 45:return{...w,summary:Z?"Value is missing":`Property '${X}' is missing`};case 50:let $=z.indexOf("'"),Q=z.slice($+1,z.indexOf("'",$+1));return{...w,summary:Z?"Value should be an email":`Property '${X}' should be ${Q}`};case 54:return{...w,summary:`${z.slice(0,9)} property '${X}' to be ${z.slice(8)} but found: ${W}`};case 62:let Y=w.schema.anyOf.map((B)=>`'${B?.format??B.type}'`).join(", ");return{...w,summary:Z?`Value should be one of ${Y}`:`Property '${X}' should be one of: ${Y}`};default:return{summary:z,...w}}};class Z0 extends Error{type;validator;value;code="VALIDATION";status=422;constructor(w,z,U){if(U&&typeof U==="object"&&U instanceof M1)U=U.response;let W=T8?void 0:("Errors"in z)?z.Errors(U).First():p.Errors(z,U).First(),A=W.schema.message||W?.schema.error!==void 0?typeof W.schema.error==="function"?W.schema.error({type:w,validator:z,value:U,get errors(){return[...z.Errors(U)].map(J1)}}):W.schema.error:void 0,X=W?.path||"root",Z="";if(A!==void 0)Z=typeof A==="object"?JSON.stringify(A):A+"";else if(T8)Z=JSON.stringify({type:"validation",on:w,summary:J1(W).summary,message:W?.message,found:U});else{let $=z?.schema??z,Q="Errors"in z?[...z.Errors(U)].map(J1):[...p.Errors(z,U)].map(J1),Y;try{Y=p.Create($)}catch(B){Y={type:"Could not create expected value",message:B?.message,error:B}}Z=JSON.stringify({type:"validation",on:w,summary:J1(W).summary,property:X,message:W?.message,expected:Y,found:U,errors:Q},null,2)}super(Z);this.type=w,this.validator=z,this.value=U,Object.setPrototypeOf(this,Z0.prototype)}get all(){return"Errors"in this.validator?[...this.validator.Errors(this.value)].map(J1):[...p.Errors(this.validator,this.value)].map(J1)}static simplifyModel(w){let z="schema"in w?w.schema:w;try{return p.Create(z)}catch{return z}}get model(){return Z0.simplifyModel(this.validator)}toResponse(w){return new Response(this.message,{status:400,headers:{...w,"content-type":"application/json"}})}}var hU=/(\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d:[0-5]\d\.\d+([+-][0-2]\d:[0-5]\d|Z))|(\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d:[0-5]\d([+-][0-2]\d:[0-5]\d|Z))|(\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d([+-][0-2]\d:[0-5]\d|Z))/,yU=/(?:Sun|Mon|Tue|Wed|Thu|Fri|Sat)\s(?:Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)\s\d{2}\s\d{4}\s\d{2}:\d{2}:\d{2}\sGMT(?:\+|-)\d{4}\s\([^)]+\)/,cU=/^(?:(?:(?:(?:0?[1-9]|[12][0-9]|3[01])[/\s-](?:0?[1-9]|1[0-2])[/\s-](?:19|20)\d{2})|(?:(?:19|20)\d{2}[/\s-](?:0?[1-9]|1[0-2])[/\s-](?:0?[1-9]|[12][0-9]|3[01]))))(?:\s(?:1[012]|0?[1-9]):[0-5][0-9](?::[0-5][0-9])?(?:\s[AP]M)?)?$/,NH=cw.date,SH=cw["date-time"];if(!b0.Has("date"))f1.Format("date",(w)=>{let z=w.replace(/"/g,"");if(hU.test(z)||yU.test(z)||cU.test(z)||NH(z)){let U=new Date(z);if(!Number.isNaN(U.getTime()))return!0}return!1});if(!b0.Has("date-time"))f1.Format("date-time",(w)=>{let z=w.replace(/"/g,"");if(hU.test(z)||yU.test(z)||cU.test(z)||SH(z)){let U=new Date(z);if(!Number.isNaN(U.getTime()))return!0}return!1});Object.entries(cw).forEach((w)=>{let[z,U]=w;if(!b0.Has(z)){if(U instanceof RegExp)f1.Format(z,(W)=>U.test(W));else if(typeof U==="function")f1.Format(z,U)}});var I=Object.assign({},N6),bU=(w)=>{if(typeof w==="string")switch(w.slice(-1)){case"k":return+w.slice(0,w.length-1)*1024;case"m":return+w.slice(0,w.length-1)*1048576;default:return+w}return w},yw=(w,z)=>{if(!(z instanceof Blob))return!1;if(w.minSize&&z.size<bU(w.minSize))return!1;if(w.maxSize&&z.size>bU(w.maxSize))return!1;if(w.extension)if(typeof w.extension==="string"){if(!z.type.startsWith(w.extension))return!1}else{for(let U=0;U<w.extension.length;U++)if(z.type.startsWith(w.extension[U]))return!0;return!1}return!0},_H=y0.Get("Files")??f1.Type("File",yw),DH=y0.Get("Files")??f1.Type("Files",(w,z)=>{if(!Array.isArray(z))return yw(w,z);if(w.minItems&&z.length<w.minItems)return!1;if(w.maxItems&&z.length>w.maxItems)return!1;for(let U=0;U<z.length;U++)if(!yw(w,z[U]))return!1;return!0});if(!b0.Has("numeric"))b0.Set("numeric",(w)=>!!w&&!isNaN(+w));if(!b0.Has("integer"))b0.Set("integer",(w)=>!!w&&Number.isInteger(+w));if(!b0.Has("boolean"))b0.Set("boolean",(w)=>w==="true"||w==="false");if(!b0.Has("ObjectString"))b0.Set("ObjectString",(w)=>{let z=w.charCodeAt(0);if(z===9||z===10||z===32)z=w.trimStart().charCodeAt(0);if(z!==123&&z!==91)return!1;try{return JSON.parse(w),!0}catch{return!1}});if(!b0.Has("ArrayString"))b0.Set("ArrayString",(w)=>{let z=w.charCodeAt(0);if(z===9||z===10||z===32)z=w.trimStart().charCodeAt(0);if(z!==123&&z!==91)return!1;try{return JSON.parse(w),!0}catch{return!1}});y0.Set("UnionEnum",(w,z)=>{return(typeof z==="number"||typeof z==="string"||z===null)&&w.enum.includes(z)});var r2={Numeric:(w)=>{let z=N6.Number(w);return I.Transform(I.Union([I.String({format:"numeric",default:0}),I.Number(w)],w)).Decode((U)=>{let W=+U;if(isNaN(W))return U;if(w&&!p.Check(z,W))throw new Z0("property",z,W);return W}).Encode((U)=>U)},Integer:(w)=>{let z=N6.Integer(w);return I.Transform(I.Union([I.String({format:"integer",default:0}),I.Number(w)],w)).Decode((U)=>{let W=+U;if(!p.Check(z,W))throw new Z0("property",z,W);return W}).Encode((U)=>U)},Date:(w)=>{let z=N6.Date(w);return I.Transform(I.Union([N6.Date(w),I.String({format:"date",default:new Date().toISOString()}),I.String({format:"date-time",default:new Date().toISOString()}),I.Number()],w)).Decode((U)=>{if(typeof U==="number"){let A=new Date(U);if(!p.Check(z,A))throw new Z0("property",z,A);return A}if(U instanceof Date)return U;let W=new Date(U);if(!p.Check(z,W))throw new Z0("property",z,W);return W}).Encode((U)=>{if(typeof U==="string")return new Date(U);return U})},BooleanString:(w)=>{let z=N6.Boolean(w);return I.Transform(I.Union([I.Boolean(w),I.String({format:"boolean",default:!1})],w)).Decode((U)=>{if(typeof U==="string")return U==="true";if(U!==void 0&&!p.Check(z,U))throw new Z0("property",z,U);return U}).Encode((U)=>U)},ObjectString:(w,z)=>{let U=I.Object(w,z),W=JSON.stringify(p.Create(U)),A;try{A=w6.Compile(U)}catch{}return I.Transform(I.Union([I.String({format:"ObjectString",default:W}),U])).Decode((X)=>{if(typeof X==="string"){if(X.charCodeAt(0)!==123)throw new Z0("property",U,X);try{X=JSON.parse(X)}catch{throw new Z0("property",U,X)}if(A){if(!A.Check(X))throw new Z0("property",U,X);return A.Decode(X)}if(!p.Check(U,X))throw new Z0("property",U,X);return p.Decode(U,X)}return X}).Encode((X)=>{if(typeof X==="string")try{X=JSON.parse(X)}catch{throw new Z0("property",U,X)}if(!p.Check(U,X))throw new Z0("property",U,X);return JSON.stringify(X)})},ArrayString:(w={},z)=>{let U=I.Array(w,z),W=JSON.stringify(p.Create(U)),A;try{A=w6.Compile(U)}catch{}return I.Transform(I.Union([I.String({format:"ArrayString",default:W}),U])).Decode((X)=>{if(typeof X==="string"){if(X.charCodeAt(0)!==91)throw new Z0("property",U,X);try{X=JSON.parse(X)}catch{throw new Z0("property",U,X)}if(A){if(!A.Check(X))throw new Z0("property",U,X);return A.Decode(X)}if(!p.Check(U,X))throw new Z0("property",U,X);return p.Decode(U,X)}return X}).Encode((X)=>{if(typeof X==="string")try{X=JSON.parse(X)}catch{throw new Z0("property",U,X)}if(!p.Check(U,X))throw new Z0("property",U,X);return JSON.stringify(X)})},File:_H,Files:(w={})=>I.Transform(DH(w)).Decode((z)=>{if(Array.isArray(z))return z;return[z]}).Encode((z)=>z),Nullable:(w)=>I.Union([w,I.Null()]),MaybeEmpty:(w)=>I.Union([w,I.Null(),I.Undefined()]),Cookie:(w,{domain:z,expires:U,httpOnly:W,maxAge:A,path:X,priority:Z,sameSite:$,secure:Q,secrets:Y,sign:B,...G}={})=>{let _=I.Object(w,G);return _.config={domain:z,expires:U,httpOnly:W,maxAge:A,path:X,priority:Z,sameSite:$,secure:Q,secrets:Y,sign:B},_},UnionEnum:(w,z={})=>{let U=w.every((W)=>typeof W==="string")?{type:"string"}:w.every((W)=>typeof W==="number")?{type:"number"}:w.every((W)=>W===null)?{type:"null"}:{};if(w.some((W)=>typeof W==="object"&&W!==null))throw new Error("This type does not support objects or arrays");return{default:w[0],...z,[N]:"UnionEnum",...U,enum:w}}};I.BooleanString=r2.BooleanString;I.ObjectString=r2.ObjectString;I.ArrayString=r2.ArrayString;I.Numeric=r2.Numeric;I.Integer=r2.Integer;I.File=(w={})=>r2.File({default:"File",...w,extension:w?.type,type:"string",format:"binary"});I.Files=(w={})=>r2.Files({...w,elysiaMeta:"Files",default:"Files",extension:w?.type,type:"array",items:{...w,default:"Files",type:"string",format:"binary"}});I.Nullable=(w)=>r2.Nullable(w);I.MaybeEmpty=r2.MaybeEmpty;I.Cookie=r2.Cookie;I.Date=r2.Date;I.UnionEnum=r2.UnionEnum;var T4=(w)=>{let z=typeof w==="object"?w.fn.toString():typeof w==="string"?w.toString():w,U=z.indexOf(")");if(z.charCodeAt(U+2)===61&&z.charCodeAt(U+5)!==123)return!0;return z.includes("return")},PH=(w)=>{if(w.startsWith("async"))w=w.slice(5);w=w.trimStart();let z=-1;if(w.charCodeAt(0)===40){if(z=w.indexOf("=>",w.indexOf(")")),z!==-1){let A=z;while(A>0)if(w.charCodeAt(--A)===41)break;let X=w.slice(z+2);if(X.charCodeAt(0)===32)X=X.trimStart();return[w.slice(1,A),X,{isArrowReturn:X.charCodeAt(0)!==123}]}}if(/^(\w+)=>/g.test(w)){if(z=w.indexOf("=>"),z!==-1){let A=w.slice(z+2);if(A.charCodeAt(0)===32)A=A.trimStart();return[w.slice(0,z),A,{isArrowReturn:A.charCodeAt(0)!==123}]}}if(w.startsWith("function")){z=w.indexOf("(");let A=w.indexOf(")");return[w.slice(z+1,A),w.slice(A+2),{isArrowReturn:!1}]}let U=w.indexOf("(");if(U!==-1){let A=w.indexOf(`
8
+ `,2),X=w.slice(0,A),Z=X.lastIndexOf(")")+1,$=w.slice(A+1);return[X.slice(U,Z),"{"+$,{isArrowReturn:!1}]}let W=w.split(`
9
+ `,2);return[W[0],W[1],{isArrowReturn:!1}]},OH=(w)=>{let z=w.indexOf("{");if(z===-1)return[-1,0];let U=z+1,W=1;for(;U<w.length;U++){let A=w.charCodeAt(U);if(A===123)W++;else if(A===125)W--;if(W===0)break}if(W!==0)return[0,w.length];return[z,U+1]},bH=(w)=>{let z=w.lastIndexOf("}");if(z===-1)return[-1,0];let U=z-1,W=1;for(;U>=0;U--){let A=w.charCodeAt(U);if(A===125)W++;else if(A===123)W--;if(W===0)break}if(W!==0)return[-1,0];return[U,z+1]},iU=(w)=>{while(!0){let z=w.indexOf(":");if(z===-1)break;let U=w.indexOf(",",z);if(U===-1)U=w.indexOf("}",z)-1;if(U===-2)U=w.length;w=w.slice(0,z)+w.slice(U)}return w},vU=(w)=>{let z=!1;if(w.charCodeAt(0)===40)w=w.slice(1,-1);if(w.charCodeAt(0)===123)z=!0,w=w.slice(1,-1);w=w.replace(/( |\t|\n)/g,"").trim();let U=[];while(!0){let[A,X]=OH(w);if(A===-1)break;if(U.push(w.slice(0,A-1)),w.charCodeAt(X)===44)X++;w=w.slice(X)}if(w=iU(w),w)U=U.concat(w.split(","));let W=[];for(let A of U){if(A.indexOf(",")===-1){W.push(A);continue}for(let X of A.split(","))W.push(X.trim())}return U=W,{hasParenthesis:z,parameters:U}},RH=(w,z)=>{let{parameters:U,hasParenthesis:W}=vU(w);if(!z.query&&U.includes("query"))z.query=!0;if(!z.headers&&U.includes("headers"))z.headers=!0;if(!z.body&&U.includes("body"))z.body=!0;if(!z.cookie&&U.includes("cookie"))z.cookie=!0;if(!z.set&&U.includes("set"))z.set=!0;if(!z.server&&U.includes("server"))z.server=!0;if(!z.request&&U.includes("request"))z.request=!0;if(!z.route&&U.includes("route"))z.route=!0;if(W)return`{ ${U.join(", ")} }`;return U.join(", ")},RU=(w,z,U)=>{let W=z.indexOf(w+`
10
+ `,U),A=z.indexOf(w+"\t",U),X=z.indexOf(w+",",U),Z=z.indexOf(w+";",U),$=z.indexOf(w+" ",U);return[W,A,X,Z,$].filter((Q)=>Q>0).sort((Q,Y)=>Q-Y)[0]||-1},nU=(w,z,U=0)=>{if(U>5)return[];let W=[],A=z;while(!0){let X=RU(" = "+w,A);if(X===-1)X=RU("="+w,A);if(X===-1){let Y=A.indexOf(" = "+w);if(Y===-1)Y=A.indexOf("="+w);if(Y+3+w.length!==A.length)break;X=Y}let Z=A.slice(0,X),$=Z.lastIndexOf(" "),Q=Z.slice($!==-1?$+1:-1);if(Q==="}"){let[Y,B]=bH(Z);W.push(iU(A.slice(Y,B))),A=A.slice(X+3+w.length);continue}while(Q.charCodeAt(0)===44)Q=Q.slice(1);while(Q.charCodeAt(0)===9)Q=Q.slice(1);if(!Q.includes("("))W.push(Q);A=A.slice(X+3+w.length)}for(let X of W){if(X.charCodeAt(0)===123)continue;let Z=nU(X,z);if(Z.length>0)W.push(...Z)}return W},CH=(w)=>{if(!w)return;if(w.charCodeAt(0)!==123)return w;if(w=w.slice(2,-2),!w.includes(",")){if(w.includes("..."))return w.slice(w.indexOf("...")+3);return}let z=w.indexOf("...");if(z===-1)return;return w.slice(z+3).trimEnd()},KH=(w,z,U)=>{let W=(A,X)=>w.includes(X+"."+A)||w.includes(X+'["'+A+'"]')||w.includes(X+"['"+A+"']");for(let A of z){if(!A)continue;if(A.charCodeAt(0)===123){let X=vU(A).parameters;if(!U.query&&X.includes("query"))U.query=!0;if(!U.headers&&X.includes("headers"))U.headers=!0;if(!U.body&&X.includes("body"))U.body=!0;if(!U.cookie&&X.includes("cookie"))U.cookie=!0;if(!U.set&&X.includes("set"))U.set=!0;if(!U.query&&X.includes("server"))U.server=!0;if(!U.request&&X.includes("request"))U.request=!0;if(!U.route&&X.includes("route"))U.route=!0;continue}if(!U.query&&W("query",A))U.query=!0;if(w.includes("return "+A)||w.includes("return "+A+".query"))U.query=!0;if(!U.headers&&W("headers",A))U.headers=!0;if(!U.body&&W("body",A))U.body=!0;if(!U.cookie&&W("cookie",A))U.cookie=!0;if(!U.set&&W("set",A))U.set=!0;if(!U.server&&W("server",A))U.server=!0;if(U.query&&U.headers&&U.body&&U.cookie&&U.set&&U.server&&U.server&&U.route)break}return z},FH=(w,z,U)=>{try{let W=new RegExp(`(?:\\w)\\((?:.*)?${w}`,"gs");W.test(z);let A=z.charCodeAt(W.lastIndex);if(A===41||A===44)return U.query=!0,U.headers=!0,U.body=!0,U.cookie=!0,U.set=!0,U.server=!0,U.route=!0,U.request=!0,!0;return!1}catch(W){return console.log("[Sucrose] warning: unexpected isContextPassToFunction error, you may continue development as usual but please report the following to maintainers:"),console.log("--- body ---"),console.log(z),console.log("--- context ---"),console.log(w),!0}},uU=(w,z={query:!1,headers:!1,body:!1,cookie:!1,set:!1,server:!1,request:!1,route:!1})=>{let U=[];if(w.handler&&typeof w.handler==="function")U.push(w.handler);if(w.request?.length)U.push(...w.request);if(w.beforeHandle?.length)U.push(...w.beforeHandle);if(w.parse?.length)U.push(...w.parse);if(w.error?.length)U.push(...w.error);if(w.transform?.length)U.push(...w.transform);if(w.afterHandle?.length)U.push(...w.afterHandle);if(w.mapResponse?.length)U.push(...w.mapResponse);if(w.afterResponse?.length)U.push(...w.afterResponse);for(let W of U){if(!W)continue;let A="fn"in W?W.fn:W;if(typeof A!=="function")continue;let[X,Z,{isArrowReturn:$}]=PH(A.toString()),Q=RH(X,z),Y=CH(Q);if(Y){let B=nU(Y,Z);if(B.splice(0,-1,Y),!FH(Y,Z,z))KH(Z,B,z);if(!z.query&&Z.includes("return "+Y+".query"))z.query=!0}if(z.query&&z.headers&&z.body&&z.cookie&&z.set&&z.server&&z.request&&z.route)break}return z};class z4{name;jar;initial;constructor(w,z,U={}){this.name=w,this.jar=z,this.initial=U}get cookie(){return this.jar[this.name]??this.initial}set cookie(w){if(!(this.name in this.jar))this.jar[this.name]=this.initial;this.jar[this.name]=w}get setCookie(){if(!(this.name in this.jar))this.jar[this.name]=this.initial;return this.jar[this.name]}set setCookie(w){this.cookie=w}get value(){return this.cookie.value}set value(w){this.setCookie.value=w}get expires(){return this.cookie.expires}set expires(w){this.setCookie.expires=w}get maxAge(){return this.cookie.maxAge}set maxAge(w){this.setCookie.maxAge=w}get domain(){return this.cookie.domain}set domain(w){this.setCookie.domain=w}get path(){return this.cookie.path}set path(w){this.setCookie.path=w}get secure(){return this.cookie.secure}set secure(w){this.setCookie.secure=w}get httpOnly(){return this.cookie.httpOnly}set httpOnly(w){this.setCookie.httpOnly=w}get sameSite(){return this.cookie.sameSite}set sameSite(w){this.setCookie.sameSite=w}get priority(){return this.cookie.priority}set priority(w){this.setCookie.priority=w}get partitioned(){return this.cookie.partitioned}set partitioned(w){this.setCookie.partitioned=w}get secrets(){return this.cookie.secrets}set secrets(w){this.setCookie.secrets=w}update(w){return this.setCookie=Object.assign(this.cookie,typeof w==="function"?w(this.cookie):w),this}set(w){return this.setCookie=Object.assign({...this.initial,value:this.value},typeof w==="function"?w(this.cookie):w),this}remove(){if(this.value===void 0)return;return this.set({expires:new Date(0),maxAge:0,value:""}),this}toString(){return typeof this.value==="object"?JSON.stringify(this.value):this.value?.toString()??""}}var CU=(w,z,U)=>{if(!w.cookie)w.cookie={};return new Proxy(z,{get(W,A){if(A in z)return new z4(A,w.cookie,Object.assign({},U??{},z[A]));return new z4(A,w.cookie,Object.assign({},U))}})},tU=async(w,z,{secrets:U,sign:W,...A}={})=>{if(!z)return CU(w,{},A);let X=typeof U==="string";if(W&&W!==!0&&!Array.isArray(W))W=[W];let Z={},$=y8.parse(z);for(let[Q,Y]of Object.entries($)){let B=mU.default(Y);if(W===!0||W?.includes(Q)){if(!U)throw new Error("No secret is provided to cookie plugin");if(X){let G=await _U(B,U);if(G===!1)throw new hw(Q);B=G}else{let G=!0;for(let _=0;_<U.length;_++){let H=await _U(B,U[_]);if(H!==!1){G=!0,B=H;break}}if(!G)throw new hw(Q)}}Z[Q]={value:B}}return CU(w,Z,A)},pU=(w)=>{if(!w||!s2(w))return;let z=[];for(let[U,W]of Object.entries(w)){if(!U||!W)continue;let A=W.value;if(A===void 0||A===null)continue;z.push(y8.serialize(U,typeof A==="object"?JSON.stringify(A):A+"",W))}if(z.length===0)return;if(z.length===1)return z[0];return z},W6=(w,z)=>{let U=w.size;if(!z&&U||U&&z&&z.status!==206&&z.status!==304&&z.status!==412&&z.status!==416){if(z){if(z.headers instanceof Headers){let W={"accept-ranges":"bytes","content-range":`bytes 0-${U-1}/${U}`,"transfer-encoding":"chunked"};if(IU)W=z.headers.toJSON();else{W={};for(let[A,X]of z.headers.entries())if(A in z.headers)W[A]=X}return new Response(w,{status:z.status,headers:W})}if(s2(z.headers))return new Response(w,{status:z.status,headers:Object.assign({"accept-ranges":"bytes","content-range":`bytes 0-${U-1}/${U}`,"transfer-encoding":"chunked"},z.headers)})}return new Response(w,{headers:{"accept-ranges":"bytes","content-range":`bytes 0-${U-1}/${U}`,"transfer-encoding":"chunked"}})}return new Response(w)},oU=(w,z)=>{if(!w)return w;w.delete("set-cookie");for(let U=0;U<z.length;U++){let W=z[U].indexOf("=");w.append("set-cookie",`${z[U].slice(0,W)}=${z[U].slice(W+1)||""}`)}return w},B1=async(w,z,U)=>{let W=w.next();if(W instanceof Promise)W=await W;if(W.done){if(z)return E2(W.value,z,U);return A6(W.value,U)}return new Response(new ReadableStream({async start(A){let X=!1;if(U?.signal?.addEventListener("abort",()=>{X=!0;try{A.close()}catch{}}),W.value!==void 0&&W.value!==null)if(typeof W.value==="object")try{A.enqueue(Buffer.from(JSON.stringify(W.value)))}catch{A.enqueue(Buffer.from(W.value.toString()))}else A.enqueue(Buffer.from(W.value.toString()));for await(let Z of w){if(X)break;if(Z===void 0||Z===null)continue;if(typeof Z==="object")try{A.enqueue(Buffer.from(JSON.stringify(Z)))}catch{A.enqueue(Buffer.from(Z.toString()))}else A.enqueue(Buffer.from(Z.toString()));await new Promise(($)=>setTimeout(()=>$(),0))}try{A.close()}catch{}}}),{...z,headers:{"transfer-encoding":"chunked","content-type":"text/event-stream; charset=utf-8",...z?.headers}})};async function*w4(w){let z=w.body;if(!z)return;let U=z.getReader(),W=new TextDecoder;try{while(!0){let{done:A,value:X}=await U.read();if(A)break;yield W.decode(X)}}finally{U.releaseLock()}}var lU=(w)=>{if(typeof w.status==="string")w.status=f8[w.status];if(w.cookie&&s2(w.cookie)){let z=pU(w.cookie);if(z)w.headers["set-cookie"]=z}if(w.headers["set-cookie"]&&Array.isArray(w.headers["set-cookie"]))w.headers=oU(new Headers(w.headers),w.headers["set-cookie"])},g8=(w,z)=>{if(w.status!==z.status&&z.status!==200&&(w.status<=300||w.status>400))w=new Response(w.body,{headers:w.headers,status:z.status});let U=!1;if(z.headers instanceof Headers)for(let W of z.headers.keys())if(W==="set-cookie"){if(U)continue;U=!0;for(let A of z.headers.getSetCookie())w.headers.append("set-cookie",A)}else w.headers.append(W,z.headers?.get(W)??"");else for(let W in z.headers)w.headers.append(W,z.headers[W]);return w},E2=(w,z,U)=>{if(s2(z.headers)||z.status!==200||z.cookie)switch(lU(z),w?.constructor?.name){case"String":return new Response(w,z);case"Array":case"Object":return Response.json(w,z);case"ElysiaFile":return W6(w.value);case"Blob":return W6(w,z);case"ElysiaCustomStatusResponse":return z.status=w.code,E2(w.response,z,U);case"ReadableStream":if(!z.headers["content-type"]?.startsWith("text/event-stream"))z.headers["content-type"]="text/event-stream; charset=utf-8";return U?.signal?.addEventListener("abort",{handleEvent(){if(U?.signal&&!U?.signal?.aborted)w.cancel()}},{once:!0}),new Response(w,z);case void 0:if(!w)return new Response("",z);return Response.json(w,z);case"Response":if(w=g8(w,z),w.headers.get("transfer-encoding")==="chunked")return B1(w4(w),z,U);return w;case"Error":return X6(w,z);case"Promise":return w.then((W)=>E2(W,z,U));case"Function":return E2(w(),z,U);case"Number":case"Boolean":return new Response(w.toString(),z);case"Cookie":if(w instanceof z4)return new Response(w.value,z);return new Response(w?.toString(),z);case"FormData":return new Response(w,z);default:if(w instanceof Response){if(w=g8(w,z),w.headers.get("transfer-encoding")==="chunked")return B1(w4(w),z,U);return w}if(w instanceof Promise)return w.then((W)=>E2(W,z));if(w instanceof Error)return X6(w,z);if(w instanceof M1)return z.status=w.code,E2(w.response,z,U);if(typeof w?.next==="function")return B1(w,z,U);if(typeof w?.then==="function")return w.then((W)=>E2(W,z));if(typeof w?.toResponse==="function")return E2(w.toResponse(),z);if("charCodeAt"in w){let W=w.charCodeAt(0);if(W===123||W===91){if(!z.headers["Content-Type"])z.headers["Content-Type"]="application/json";return new Response(JSON.stringify(w),z)}}return new Response(w,z)}if(typeof w?.next==="function"||w instanceof ReadableStream||w instanceof Response&&w.headers.get("transfer-encoding")==="chunked")return B1(w,z,U);return A6(w,U)},K2=(w,z,U)=>{if(w===void 0||w===null)return;if(s2(z.headers)||z.status!==200||z.cookie)switch(lU(z),w?.constructor?.name){case"String":return new Response(w,z);case"Array":case"Object":return Response.json(w,z);case"ElysiaFile":return W6(w.value);case"Blob":return W6(w,z);case"ElysiaCustomStatusResponse":return z.status=w.code,K2(w.response,z,U);case"ReadableStream":if(!z.headers["content-type"]?.startsWith("text/event-stream"))z.headers["content-type"]="text/event-stream; charset=utf-8";return U?.signal?.addEventListener("abort",{handleEvent(){if(U?.signal&&!U?.signal?.aborted)w.cancel()}},{once:!0}),new Response(w,z);case void 0:if(!w)return;return Response.json(w,z);case"Response":if(w=g8(w,z),w.headers.get("transfer-encoding")==="chunked")return B1(w4(w),z,U);return w;case"Promise":return w.then((W)=>K2(W,z));case"Error":return X6(w,z);case"Function":return K2(w(),z);case"Number":case"Boolean":return new Response(w.toString(),z);case"FormData":return new Response(w);case"Cookie":if(w instanceof z4)return new Response(w.value,z);return new Response(w?.toString(),z);default:if(w instanceof Response){if(w=g8(w,z),w.headers.get("transfer-encoding")==="chunked")return B1(w4(w),z,U);return w}if(w instanceof Promise)return w.then((W)=>K2(W,z));if(w instanceof Error)return X6(w,z);if(w instanceof M1)return z.status=w.code,K2(w.response,z,U);if(typeof w?.next==="function")return B1(w,z,U);if(typeof w?.then==="function")return w.then((W)=>K2(W,z));if(typeof w?.toResponse==="function")return K2(w.toResponse(),z);if("charCodeAt"in w){let W=w.charCodeAt(0);if(W===123||W===91){if(!z.headers["Content-Type"])z.headers["Content-Type"]="application/json";return new Response(JSON.stringify(w),z)}}return new Response(w,z)}else switch(w?.constructor?.name){case"String":return new Response(w);case"Array":case"Object":return Response.json(w,z);case"ElysiaFile":return W6(w.value);case"Blob":return W6(w,z);case"ElysiaCustomStatusResponse":return z.status=w.code,K2(w.response,z,U);case"ReadableStream":return U?.signal?.addEventListener("abort",{handleEvent(){if(U?.signal&&!U?.signal?.aborted)w.cancel()}},{once:!0}),new Response(w,{headers:{"Content-Type":"text/event-stream; charset=utf-8"}});case void 0:if(!w)return new Response("");return new Response(JSON.stringify(w),{headers:{"content-type":"application/json"}});case"Response":if(w.headers.get("transfer-encoding")==="chunked")return B1(w4(w));return w;case"Promise":return w.then((W)=>{let A=K2(W,z);if(A!==void 0)return A});case"Error":return X6(w,z);case"Function":return A6(w(),U);case"Number":case"Boolean":return new Response(w.toString());case"Cookie":if(w instanceof z4)return new Response(w.value,z);return new Response(w?.toString(),z);case"FormData":return new Response(w);default:if(w instanceof Response)return w;if(w instanceof Promise)return w.then((W)=>K2(W,z));if(w instanceof Error)return X6(w,z);if(w instanceof M1)return z.status=w.code,K2(w.response,z,U);if(typeof w?.next==="function")return B1(w,z,U);if(typeof w?.then==="function")return w.then((W)=>K2(W,z));if(typeof w?.toResponse==="function")return K2(w.toResponse(),z);if("charCodeAt"in w){let W=w.charCodeAt(0);if(W===123||W===91){if(!z.headers["Content-Type"])z.headers["Content-Type"]="application/json";return new Response(JSON.stringify(w),z)}}return new Response(w)}},A6=(w,z)=>{switch(w?.constructor?.name){case"String":return new Response(w);case"Object":case"Array":return Response.json(w);case"ElysiaFile":return W6(w.value);case"Blob":return W6(w);case"ElysiaCustomStatusResponse":return E2(w.response,{status:w.code,headers:{}});case"ReadableStream":return z?.signal?.addEventListener("abort",{handleEvent(){if(z?.signal&&!z?.signal?.aborted)w.cancel()}},{once:!0}),new Response(w,{headers:{"Content-Type":"text/event-stream; charset=utf-8"}});case void 0:if(!w)return new Response("");return new Response(JSON.stringify(w),{headers:{"content-type":"application/json"}});case"Response":if(w.headers.get("transfer-encoding")==="chunked")return B1(w4(w));return w;case"Error":return X6(w);case"Promise":return w.then((U)=>A6(U,z));case"Function":return A6(w(),z);case"Number":case"Boolean":return new Response(w.toString());case"FormData":return new Response(w);default:if(w instanceof Response)return w;if(w instanceof Promise)return w.then((U)=>A6(U,z));if(w instanceof Error)return X6(w);if(w instanceof M1)return E2(w.response,{status:w.code,headers:{}});if(typeof w?.next==="function")return B1(w,void 0,z);if(typeof w?.then==="function")return w.then((U)=>E2(U,set));if(typeof w?.toResponse==="function")return A6(w.toResponse());if("charCodeAt"in w){let U=w.charCodeAt(0);if(U===123||U===91)return new Response(JSON.stringify(w),{headers:{"Content-Type":"application/json"}})}return new Response(w)}},X6=(w,z)=>new Response(JSON.stringify({name:w?.name,message:w?.message,cause:w?.cause}),{status:z?.status!==200?z?.status??500:500,headers:z?.headers}),jH=(w,z,U={})=>{if(typeof w==="function")return;let W=E2(w,{headers:U});if(z.parse.length===0&&z.transform.length===0&&z.beforeHandle.length===0&&z.afterHandle.length===0)return W.clone.bind(W)},I8={name:"web-standard",isWebStandard:!0,handler:{mapResponse:E2,mapEarlyResponse:K2,mapCompactResponse:A6,createStaticHandler:jH},composeHandler:{mapResponseContext:"c.request",preferWebstandardHeaders:!0,headers:`c.headers = {}
10
11
  for (const [key, value] of c.request.headers.entries())c.headers[key] = value
11
12
  `,parser:{json(w){if(w)return`try{c.body=await c.request.json()}catch{}
12
13
  `;return`c.body=await c.request.json()
@@ -19,80 +20,80 @@ c.body={}
19
20
  `;return z+`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(w){let z="",A="",U=w.setHeaders;for(let X of Object.keys(w.singleton.decorator))z+=`,${X}: decorator['${X}']`;let W=w.config.handler?.standardHostname??!0,$=w.event.trace.length>0;if(A+=`const u=r.url,s=u.indexOf('/',${W?11:7}),qi=u.indexOf('?', s + 1)
23
+ else c.body[key]=value}`}}},composeGeneralHandler:{parameters:"r",createContext(w){let z="",U="",W=w.setHeaders;for(let Z of Object.keys(w.singleton.decorator))z+=`,${Z}: decorator['${Z}']`;let A=w.config.handler?.standardHostname??!0,X=w.event.trace.length>0;if(U+=`const u=r.url,s=u.indexOf('/',${A?11:7}),qi=u.indexOf('?', s + 1)
23
24
  let p
24
25
  if(qi===-1)p=u.substring(s)
25
26
  else p=u.substring(s, qi)
26
- `,$)A+=`const id=randomId()
27
- `;if(A+="const c={request:r,store,qi,path:p,url:u,redirect,error,set:{headers:",A+=Object.keys(U??{}).length?"Object.assign({}, app.setHeaders)":"{}",A+=",status:200}",w.inference.server)A+=",get server(){return getServer()}";if($)A+=",[ELYSIA_REQUEST_ID]:id";return A+=z,A+=`}
28
- `,A},websocket(w){let z="",A=w.router.static.ws,U=w.router.ws;if(Object.keys(A).length||U.history.length){z+="if(r.method==='GET'){switch(p){";for(let[W,$]of Object.entries(A))z+=`case'${W}':`+(w.config.strictPath!==!0?`case'${h1(W)}':`:"")+`if(r.headers.get('upgrade')==='websocket')return ht[${$}].composed(c)
27
+ `,X)U+=`const id=randomId()
28
+ `;if(U+="const c={request:r,store,qi,path:p,url:u,redirect,error,set:{headers:",U+=Object.keys(W??{}).length?"Object.assign({}, app.setHeaders)":"{}",U+=",status:200}",w.inference.server)U+=",get server(){return getServer()}";if(X)U+=",[ELYSIA_REQUEST_ID]:id";return U+=z,U+=`}
29
+ `,U},websocket(w){let z="",U=w.router.static.ws,W=w.router.ws;if(Object.keys(U).length||W.history.length){z+="if(r.method==='GET'){switch(p){";for(let[A,X]of Object.entries(U))z+=`case'${A}':`+(w.config.strictPath!==!0?`case'${r6(A)}':`:"")+`if(r.headers.get('upgrade')==='websocket')return ht[${X}].composed(c)
29
30
  `;z+=`default:if(r.headers.get('upgrade')==='websocket'){const route=wsRouter.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 z},error404(w,z){let A="if(route===null)return ";if(z)A+=`app.handleError(c,notFound,false,${this.parameters})`;else A+=w?"new Response(error404Message,{status:c.set.status===200?404:c.set.status,headers:c.set.headers})":"error404.clone()";return{declare:z?"":`const error404Message=notFound.message.toString()
33
+ return (route.store.handler=route.store.compile())(c)}}break}}`}return z},error404(w,z){let U="if(route===null)return ";if(z)U+=`app.handleError(c,notFound,false,${this.parameters})`;else U+=w?"new Response(error404Message,{status:c.set.status===200?404:c.set.status,headers:c.set.headers})":"error404.clone()";return{declare:z?"":`const error404Message=notFound.message.toString()
33
34
  const error404=new Response(error404Message,{status:404})
34
- `,code:A}}},composeError:{mapResponseContext:"",validationError:"return new Response(error.message,{headers:Object.assign({'content-type':'application/json'},set.headers),status:set.status})",unknownError:"return new Response(error.message,{headers:set.headers,status:error.status??set.status??500})"},listen(){return()=>{throw new Error("WebStandard does not support listen, you might want to export default Elysia.fetch instead")}}};var WU=(w,z,A={})=>{if(typeof w==="function"||w instanceof Blob)return;let U=H2(w,{headers:A});if(z.parse.length===0&&z.transform.length===0&&z.beforeHandle.length===0&&z.afterHandle.length===0){if(!U.headers.has("content-type"))U.headers.append("content-type","text/plain;charset=utf-8");return U.clone.bind(U)}};var Jz={open(w){w.data.open?.(w)},message(w,z){w.data.message?.(w,z)},drain(w){w.data.drain?.(w)},close(w,z,A){w.data.close?.(w,z,A)}};class Z4{constructor(w,z,A=void 0){this.raw=w,this.data=z,this.body=A,this.validator=w.data?.validator,this.sendText=w.sendText.bind(w),this.sendBinary=w.sendBinary.bind(w),this.close=w.close.bind(w),this.terminate=w.terminate.bind(w),this.publishText=w.publishText.bind(w),this.publishBinary=w.publishBinary.bind(w),this.subscribe=w.subscribe.bind(w),this.unsubscribe=w.unsubscribe.bind(w),this.isSubscribed=w.isSubscribed.bind(w),this.cork=w.cork.bind(w),this.remoteAddress=w.remoteAddress,this.binaryType=w.binaryType,this.data=w.data,this.send=this.send.bind(this),this.ping=this.ping.bind(this),this.pong=this.pong.bind(this),this.publish=this.publish.bind(this)}get id(){return this.data.id}send(w,z){if(Buffer.isBuffer(w))return this.raw.send(w,z);if(this.validator?.Check(w)===!1)return this.raw.send(new m("message",this.validator,w).message);if(typeof w==="object")w=JSON.stringify(w);return this.raw.send(w,z)}ping(w){if(Buffer.isBuffer(w))return this.raw.ping(w);if(this.validator?.Check(w)===!1)return this.raw.send(new m("message",this.validator,w).message);if(typeof w==="object")w=JSON.stringify(w);return this.raw.ping(w)}pong(w){if(Buffer.isBuffer(w))return this.raw.pong(w);if(this.validator?.Check(w)===!1)return this.raw.send(new m("message",this.validator,w).message);if(typeof w==="object")w=JSON.stringify(w);return this.raw.pong(w)}publish(w,z,A){if(Buffer.isBuffer(z))return this.raw.publish(w,z,A);if(this.validator?.Check(z)===!1)return this.raw.send(new m("message",this.validator,z).message);if(typeof z==="object")z=JSON.stringify(z);return this.raw.publish(w,z,A)}get readyState(){return this.raw.readyState}}var $U=(w)=>{let z=typeof w==="function"?[w]:w;return async function A(U,W){if(typeof W==="string"){let $=W?.charCodeAt(0);if($===47||$===123)try{W=JSON.parse(W)}catch{}else if(y4(W))W=+W}if(z)for(let $=0;$<z.length;$++){let X=z[$](U,W);if(X instanceof Promise)X=await X;if(X!==void 0)return X}return W}},XU=(w)=>{let z=(A,U)=>{if(U instanceof Promise)return U.then((X)=>z(A,X));if(Buffer.isBuffer(U))return A.send(U.toString());if(U===void 0)return;let W=(X)=>{if(w?.Check(X)===!1)return A.send(new m("message",w,X).message);if(typeof X==="object")return A.send(JSON.stringify(X));A.send(X)};if(typeof U?.next!=="function")return void W(U);let $=U.next();if($ instanceof Promise)return(async()=>{let X=await $;if(w?.Check(X)===!1)return A.send(new m("message",w,X).message);if(W(X.value),!X.done)for await(let Q of U)W(Q)})();if(W($.value),!$.done)for(let X of U)W(X)};return z};var QU={...Q4,name:"bun",handler:{...Q4.handler,createNativeStaticHandler:WU},composeHandler:{...Q4.composeHandler,headers:vw?`c.headers = c.request.headers.toJSON()
35
+ `,code:U}}},composeError:{mapResponseContext:"",validationError:"return new Response(error.message,{headers:Object.assign({'content-type':'application/json'},set.headers),status:set.status})",unknownError:"return new Response(error.message,{headers:set.headers,status:error.status??set.status??500})"},listen(){return()=>{throw new Error("WebStandard does not support listen, you might want to export default Elysia.fetch instead")}}},EH=(w,z,U={})=>{if(typeof w==="function"||w instanceof Blob)return;let W=E2(w,{headers:U});if(z.parse.length===0&&z.transform.length===0&&z.beforeHandle.length===0&&z.afterHandle.length===0){if(!W.headers.has("content-type"))W.headers.append("content-type","text/plain;charset=utf-8");return W.clone.bind(W)}},KU={open(w){w.data.open?.(w)},message(w,z){w.data.message?.(w,z)},drain(w){w.data.drain?.(w)},close(w,z,U){w.data.close?.(w,z,U)}};class V4{raw;data;body;validator;["~types"];get id(){return this.data.id}constructor(w,z,U=void 0){this.raw=w,this.data=z,this.body=U,this.validator=w.data?.validator,this.sendText=w.sendText.bind(w),this.sendBinary=w.sendBinary.bind(w),this.close=w.close.bind(w),this.terminate=w.terminate.bind(w),this.publishText=w.publishText.bind(w),this.publishBinary=w.publishBinary.bind(w),this.subscribe=w.subscribe.bind(w),this.unsubscribe=w.unsubscribe.bind(w),this.isSubscribed=w.isSubscribed.bind(w),this.cork=w.cork.bind(w),this.remoteAddress=w.remoteAddress,this.binaryType=w.binaryType,this.data=w.data,this.send=this.send.bind(this),this.ping=this.ping.bind(this),this.pong=this.pong.bind(this),this.publish=this.publish.bind(this)}send(w,z){if(Buffer.isBuffer(w))return this.raw.send(w,z);if(this.validator?.Check(w)===!1)return this.raw.send(new Z0("message",this.validator,w).message);if(typeof w==="object")w=JSON.stringify(w);return this.raw.send(w,z)}ping(w){if(Buffer.isBuffer(w))return this.raw.ping(w);if(this.validator?.Check(w)===!1)return this.raw.send(new Z0("message",this.validator,w).message);if(typeof w==="object")w=JSON.stringify(w);return this.raw.ping(w)}pong(w){if(Buffer.isBuffer(w))return this.raw.pong(w);if(this.validator?.Check(w)===!1)return this.raw.send(new Z0("message",this.validator,w).message);if(typeof w==="object")w=JSON.stringify(w);return this.raw.pong(w)}publish(w,z,U){if(Buffer.isBuffer(z))return this.raw.publish(w,z,U);if(this.validator?.Check(z)===!1)return this.raw.send(new Z0("message",this.validator,z).message);if(typeof z==="object")z=JSON.stringify(z);return this.raw.publish(w,z,U)}sendText;sendBinary;close;terminate;publishText;publishBinary;subscribe;unsubscribe;isSubscribed;cork;remoteAddress;binaryType;get readyState(){return this.raw.readyState}}var IH=(w)=>{let z=typeof w==="function"?[w]:w;return async function U(W,A){if(typeof A==="string"){let X=A?.charCodeAt(0);if(X===47||X===123)try{A=JSON.parse(A)}catch{}else if(iw(A))A=+A}if(z)for(let X=0;X<z.length;X++){let Z=z[X](W,A);if(Z instanceof Promise)Z=await Z;if(Z!==void 0)return Z}return A}},xH=(w)=>{let z=(U,W)=>{if(W instanceof Promise)return W.then((Z)=>z(U,Z));if(Buffer.isBuffer(W))return U.send(W.toString());if(W===void 0)return;let A=(Z)=>{if(w?.Check(Z)===!1)return U.send(new Z0("message",w,Z).message);if(typeof Z==="object")return U.send(JSON.stringify(Z));U.send(Z)};if(typeof W?.next!=="function")return void A(W);let X=W.next();if(X instanceof Promise)return(async()=>{let Z=await X;if(w?.Check(Z)===!1)return U.send(new Z0("message",w,Z).message);if(A(Z.value),!Z.done)for await(let $ of W)A($)})();if(A(X.value),!X.done)for(let Z of W)A(Z)};return z},VH={...I8,name:"bun",handler:{...I8.handler,createNativeStaticHandler:EH},composeHandler:{...I8.composeHandler,headers:IU?`c.headers = c.request.headers.toJSON()
35
36
  `:`c.headers = {}
36
37
  for (const [key, value] of c.request.headers.entries())c.headers[key] = value
37
- `},listen(w){return(z,A)=>{if(typeof Bun==="undefined")throw new Error(".listen() is designed to run on Bun only. If you are running Elysia in other environment please use a dedicated plugin or export the handler via Elysia.fetch");if(w.compile(),typeof z==="string"){if(!y4(z))throw new Error("Port must be a numeric value");z=parseInt(z)}let U=w.fetch,W=typeof z==="object"?{development:!u4,reusePort:!0,...w.config.serve||{},...z||{},static:w.router.static.http.static,websocket:{...w.config.websocket||{},...Jz||{}},fetch:U,error:w.outerErrorHandler}:{development:!u4,reusePort:!0,...w.config.serve||{},static:w.router.static.http.static,websocket:{...w.config.websocket||{},...Jz||{}},port:z,fetch:U,error:w.outerErrorHandler};w.server=Bun?.serve(W);for(let $=0;$<w.event.start.length;$++)w.event.start[$].fn(w);if(A)A(w.server);process.on("beforeExit",()=>{if(w.server){w.server.stop(),w.server=null;for(let $=0;$<w.event.stop.length;$++)w.event.stop[$].fn(w)}}),w.promisedModules.then(()=>{Bun?.gc(!1)})}},ws(w,z,A){let{parse:U,body:W,response:$,...X}=A,Q=$2(W,{modules:w.definitions.typebox,models:w.definitions.type,normalize:w.config.normalize}),Z=$2($,{modules:w.definitions.typebox,models:w.definitions.type,normalize:w.config.normalize});w.route("$INTERNALWS",z,async(J)=>{let Y=w.getServer(),{set:L,path:_,qi:G,headers:O,query:C,params:q}=J;if(J.validator=Z,A.upgrade){if(typeof A.upgrade==="function"){let c=A.upgrade(J);if(c instanceof Promise)await c}else if(A.upgrade)Object.assign(L.headers,A.upgrade)}if(L.cookie&&Q2(L.cookie)){let c=p4(L.cookie);if(c)L.headers["set-cookie"]=c}if(L.headers["set-cookie"]&&Array.isArray(L.headers["set-cookie"]))L.headers=Qz(new Headers(L.headers),L.headers["set-cookie"]);let o=XU(Z),W0=$U(U),L0;if(Y?.upgrade(J.request,{headers:Q2(L.headers)?L.headers:void 0,data:{...J,get id(){if(L0)return L0;return L0=pw()},validator:Z,ping(c){A.ping?.(c)},pong(c){A.pong?.(c)},open(c){o(c,A.open?.(new Z4(c,J)))},message:async(c,e)=>{let f=await W0(c,e);if(Q?.Check(f)===!1)return void c.send(new m("message",Q,f).message);o(c,A.message?.(new Z4(c,J,f),f))},drain(c){o(c,A.drain?.(new Z4(c,J)))},close(c,e,f){o(c,A.close?.(new Z4(c,J),e,f))}}}))return;return L.status=400,"Expected a websocket connection"},{...X,websocket:A})}};var Yz=typeof Bun!=="undefined";var U8=Yz?Bun.env:typeof process!=="undefined"&&process?.env?process.env:{};var j6=Ww(ew(),1),J4=/\+/g;function ZU(w){let z={};if(typeof w!=="string")return z;let A="",U="",W=-1,$=-1,X=0,Q=w.length;for(let Z=0;Z<Q;Z++)switch(w.charCodeAt(Z)){case 38:let J=$>W;if(!J)$=Z;if(A=w.slice(W+1,$),J||A.length>0){if(X&1)A=A.replace(J4," ");if(X&2)A=j6.default(A)||A;if(!z[A]){if(J){if(U=w.slice($+1,Z),X&4)U=U.replace(J4," ");if(X&8)U=j6.default(U)||U}z[A]=U}}A="",U="",W=Z,$=Z,X=0;break;case 61:if($<=W)$=Z;else X|=8;break;case 43:if($>W)X|=4;else X|=1;break;case 37:if($>W)X|=8;else X|=2;break}if(W<Q){let Z=$>W;if(A=w.slice(W+1,Z?$:Q),Z||A.length>0){if(X&1)A=A.replace(J4," ");if(X&2)A=j6.default(A)||A;if(!z[A]){if(Z){if(U=w.slice($+1,Q),X&4)U=U.replace(J4," ");if(X&8)U=j6.default(U)||U}z[A]=U}}}return z}var Y4=(w)=>{let z={};if(typeof w!=="string")return z;let A=w.length,U="",W="",$=-1,X=-1,Q=!1,Z=!1,J=!1,Y=!1,L=!1,_=0;for(let G=0;G<A+1;G++){if(G!==A)_=w.charCodeAt(G);else _=38;switch(_){case 38:{if(L=X>$,!L)X=G;if(U=w.slice($+1,X),L||U.length>0){if(J)U=U.replace(J4," ");if(Q)U=j6.default(U)||U;if(L){if(W=w.slice(X+1,G),Y)W=W.replace(J4," ");if(Z)W=j6.default(W)||W}let O=z[U];if(O===void 0)z[U]=W;else if(O.pop)O.push(W);else z[U]=[O,W]}W="",$=G,X=G,Q=!1,Z=!1,J=!1,Y=!1;break}case 61:if(X<=$)X=G;else Z=!0;break;case 43:if(X>$)Y=!0;else J=!0;break;case 37:if(X>$)Z=!0;else Q=!0;break}}return z};var YU=Ww(ew(),1);var l4=Symbol("ElysiaTrace"),t1=()=>{let{promise:w,resolve:z}=Promise.withResolvers(),{promise:A,resolve:U}=Promise.withResolvers(),{promise:W,resolve:$}=Promise.withResolvers(),X=[],Q=[];return[(Z)=>{if(Z)X.push(Z);return w},(Z)=>{let J=[],Y=[],L=null;for(let G=0;G<(Z.total??0);G++){let{promise:O,resolve:C}=Promise.withResolvers(),{promise:q,resolve:o}=Promise.withResolvers(),{promise:W0,resolve:L0}=Promise.withResolvers(),c=[],e=[];J.push((f)=>{if(f)c.push(f);return O}),Y.push((f)=>{let t={...f,end:q,error:W0,index:G,onStop(K){if(K)e.push(K);return q}};C(t);for(let K=0;K<c.length;K++)c[K](t);return(K=null)=>{let l=performance.now();if(K)L=K;let D0={end:l,error:K,get elapsed(){return l-f.begin}};for(let s=0;s<e.length;s++)e[s](D0);o(l),L0(K)}})}let _={...Z,end:A,error:W,onEvent(G){for(let O=0;O<J.length;O++)J[O](G)},onStop(G){if(G)Q.push(G);return A}};z(_);for(let G=0;G<X.length;G++)X[G](_);return{resolveChild:Y,resolve(G=null){let O=performance.now();if(!G&&L)G=L;let C={end:O,error:G,get elapsed(){return O-Z.begin}};for(let q=0;q<Q.length;q++)Q[q](C);U(O),$(G)}}}]},JU=(w)=>{return(z)=>{let[A,U]=t1(),[W,$]=t1(),[X,Q]=t1(),[Z,J]=t1(),[Y,L]=t1(),[_,G]=t1(),[O,C]=t1(),[q,o]=t1(),[W0,L0]=t1();return w({id:z[C6],context:z,set:z.set,onRequest:A,onParse:W,onTransform:X,onBeforeHandle:Z,onHandle:Y,onAfterHandle:_,onMapResponse:q,onAfterResponse:W0,onError:O}),{request:U,parse:$,transform:Q,beforeHandle:J,handle:L,afterHandle:G,error:C,mapResponse:o,afterResponse:L0}}};var s4={optional:Symbol.for("TypeBox.Optional"),kind:Symbol.for("TypeBox.Kind")},B1=(w)=>{if(!w)return!1;let z=w?.schema;if(z?.[s4.kind]==="Import")return w.References().some(B1);return!!z&&s4.optional in z},cH=["json","text","urlencoded","arrayBuffer","formdata","application/json","text/plain","application/x-www-form-urlencoded","application/octet-stream","multipart/form-data"],e2=(w)=>{if(!w)return!1;let z=w?.schema??w;if(z[s4.kind]==="Import"&&w.References())return w.References().some(e2);if(z.anyOf)return z.anyOf.some(e2);if(z.someOf)return z.someOf.some(e2);if(z.allOf)return z.allOf.some(e2);if(z.not)return z.not.some(e2);if(z.type==="object"){let A=z.properties;if("additionalProperties"in z)return z.additionalProperties;if("patternProperties"in z)return!1;for(let U of Object.keys(A)){let W=A[U];if(W.type==="object"){if(e2(W))return!0}else if(W.anyOf){for(let $=0;$<W.anyOf.length;$++)if(e2(W.anyOf[$]))return!0}return W.additionalProperties}return!1}return!1},Bz=({context:w="c",trace:z,addFn:A})=>{if(!z.length)return()=>{return{resolveChild(){return()=>{}},resolve(){}}};for(let U=0;U<z.length;U++)A(`let report${U}, reportChild${U}, reportErr${U}, reportErrChild${U};let trace${U} = ${w}[ELYSIA_TRACE]?.[${U}] ?? trace[${U}](${w});
38
- `);return(U,{name:W,total:$=0}={})=>{if(!W)W="anonymous";let X=U==="error"?"reportErr":"report";for(let Q=0;Q<z.length;Q++)A(`${X}${Q} = trace${Q}.${U}({id,event:'${U}',name:'${W}',begin:performance.now(),total:${$}})
39
- `);return{resolve(){for(let Q=0;Q<z.length;Q++)A(`${X}${Q}.resolve()
40
- `)},resolveChild(Q){for(let Z=0;Z<z.length;Z++)A(`${X}Child${Z}=${X}${Z}.resolveChild?.shift()?.({id,event:'${U}',name:'${Q}',begin:performance.now()})
41
- `);return(Z)=>{for(let J=0;J<z.length;J++)if(Z)A(`if(${Z} instanceof Error){${X}Child${J}?.(${Z}) }else{${X}Child${J}?.()}`);else A(`${X}Child${J}?.()
42
- `)}}}}},nH=({injectResponse:w="",normalize:z=!1,validator:A})=>({composeValidation:(U,W=`c.${U}`)=>`c.set.status=422;throw new ValidationError('${U}',validator.${U},${W})`,composeResponseValidation:(U="r")=>{let W=w+`
43
- `;W+=`if(${U} instanceof ElysiaCustomStatusResponse){c.set.status=${U}.code
44
- ${U}=${U}.response}const isResponse=${U} instanceof Response
45
- switch(c.set.status){`;for(let[$,X]of Object.entries(A.response)){if(W+=`
46
- case ${$}:if(!isResponse){`,z&&"Clean"in X&&!e2(X))W+=`${U}=validator.response['${$}'].Clean(${U})
47
- `;W+=`if(validator.response['${$}'].Check(${U})===false){c.set.status=422
48
- throw new ValidationError('response',validator.response['${$}'],${U})}c.set.status = ${$}}break
49
- `}return W+"}"}}),GE=Symbol.for("TypeBox.Kind");var Q6=(w,z)=>{if(!z)return;let A=z.schema??z;if(A[s4.kind]==="Import")return z.References().some((U)=>Q6(w,U));if(A.type==="object"){let U=A.properties;if(!U)return!1;for(let W of Object.keys(U)){let $=U[W];if(w in $)return!0;if($.type==="object"){if(Q6(w,$))return!0}else if($.anyOf){for(let X=0;X<$.anyOf.length;X++)if(Q6(w,$.anyOf[X]))return!0}}return!1}return w in A},qz=Symbol.for("TypeBox.Transform"),F6=(w)=>{if(!w)return;if(w.type==="object"&&w.properties){let z=w.properties;for(let A of Object.keys(z)){let U=z[A];if(U.type==="object"){if(F6(U))return!0}else if(U.anyOf){for(let $=0;$<U.anyOf.length;$++)if(F6(U.anyOf[$]))return!0}if(qz in U)return!0}return!1}return qz in w||w.properties&&qz in w.properties},hH=/(?:return|=>) \S+\(/g,q4=(w)=>{return(w?.fn??w).constructor.name==="AsyncFunction"},a0=(w)=>{let z=w?.fn??w;if(z.constructor.name==="AsyncFunction")return!0;let A=z.toString();if(A.includes("=> response.clone("))return!1;if(A.includes("await"))return!0;if(A.includes("async"))return!0;if(A.includes("=>response.clone("))return!1;return!!A.match(hH)},W8=(w)=>{let z=w?.fn??w;return z.constructor.name==="AsyncGeneratorFunction"||z.constructor.name==="GeneratorFunction"},qU=({app:w,path:z,method:A,localHook:U,hooks:W,validator:$,handler:X,allowMeta:Q=!1,inference:Z,asManifest:J=!1})=>{let Y=w["~adapter"].composeHandler,L=w["~adapter"].handler,_=typeof X==="function";if(!_){if(X=L.mapResponse(X,{headers:w.setHeaders??{}}),W.parse.length===0&&W.transform.length===0&&W.beforeHandle.length===0&&W.afterHandle.length===0){if(X instanceof Response)return Function("a","return function(){return a.clone()}")(X);return Function("a","return function(){return a}")(X)}}let G=_?"handler(c)":"handler",O=W.afterResponse.length>0,C=W.trace.length>0,q="";if(Z=aw(Object.assign(U,{handler:X}),Z),Y.declare){let F=Y.declare(Z);if(F)q+=F}if(Z.server)q+=`Object.defineProperty(c,'server',{get:function(){return getServer()}})
50
- `;$.createBody?.(),$.createQuery?.(),$.createHeaders?.(),$.createParams?.(),$.createCookie?.(),$.createResponse?.();let o=Z.query||!!$.query,W0=A!=="$INTERNALWS"&&A!=="GET"&&A!=="HEAD"&&(Z.body||!!$.body||W.parse.length);if(W0)q+=`let isParsing=false
51
- `;let L0=w.setHeaders,c=L0&&!!Object.keys(L0).length,e=Z.headers||$.headers||Y.preferWebstandardHeaders!==!0&&Z.body,f=Z.cookie||!!$.cookie,t=f?uw({modules:w.definitions.typebox,validator:$.cookie,defaultConfig:w.config.cookie,dynamic:!!w.config.aot,config:$.cookie?.config??{},models:w.definitions.type}):void 0,K=t?.config,l="";if(K?.sign){if(!K.secrets)throw new Error(`t.Cookie required secret which is not set in (${A}) ${z}.`);let F=!K.secrets?void 0:typeof K.secrets==="string"?K.secrets:K.secrets[0];if(l+=`const _setCookie = c.set.cookie
52
- if(_setCookie){`,K.sign===!0)l+=`for(const [key, cookie] of Object.entries(_setCookie)){c.set.cookie[key].value=await signCookie(cookie.value,'${F}')}`;else for(let P of K.sign)l+=`if(_setCookie['${P}']?.value){c.set.cookie['${P}'].value=await signCookie(_setCookie['${P}'].value,'${F}')}`;l+=`}
53
- `}let D0=w.config.normalize,{composeValidation:s,composeResponseValidation:P1}=nH({normalize:D0,validator:$});if(e)q+=Y.headers;if(C)q+=`const id=c[ELYSIA_REQUEST_ID]
54
- `;let R0=Bz({trace:W.trace,addFn:(F)=>{q+=F}});if(q+="try{",f){let F=(R,V)=>{let u=K?.[R]??V;if(!u)return typeof V==="string"?`${R}:"${V}",`:`${R}:${V},`;if(typeof u==="string")return`${R}:'${u}',`;if(u instanceof Date)return`${R}: new Date(${u.getTime()}),`;return`${R}:${u},`},P=K?`{secrets:${K.secrets!==void 0?typeof K.secrets==="string"?`'${K.secrets}'`:"["+K.secrets.reduce((R,V)=>R+`'${V}',`,"")+"]":"undefined"},sign:${K.sign===!0?!0:K.sign!==void 0?"["+K.sign.reduce((R,V)=>R+`'${V}',`,"")+"]":"undefined"},`+F("domain")+F("expires")+F("httpOnly")+F("maxAge")+F("path","/")+F("priority")+F("sameSite")+F("secure")+"}":"undefined";if(e)q+=`
55
- c.cookie=await parseCookie(c.set,c.headers.cookie,${P})
56
- `;else q+=`
57
- c.cookie=await parseCookie(c.set,c.request.headers.get('cookie'),${P})
58
- `}if(o){let F=[];if($.query&&$.query.schema.type==="object"){let P=$.query.schema.properties;if(!e2($.query))for(let[R,V]of Object.entries(P)){let u=V;if(u&&s4.optional in u&&u.type==="array"&&u.items)u=u.items;let{type:$0,anyOf:B}=u,j=$0==="array"||B?.some((H)=>H.type==="string"&&H.format==="ArrayString");F.push({key:R,isArray:j,isNestedObjectArray:j&&u.items?.type==="object"||!!u.items?.anyOf?.some((H)=>H.type==="object"||H.type==="array"),isObject:$0==="object"||B?.some((H)=>H.type==="string"&&H.format==="ArrayString"),anyOf:!!B})}}if(!F.length)q+="if(c.qi===-1){c.query={}}else{c.query=parseQueryFromURL(c.url.slice(c.qi + 1))}";else{q+=`if(c.qi!==-1){let url = '&' + decodeURIComponent(c.url.slice(c.qi + 1))
59
- `;let P=0;for(let{key:R,isArray:V,isObject:u,isNestedObjectArray:$0,anyOf:B}of F){let j=(P===0?"let ":"")+`memory=url.indexOf('&${R}=')
60
- let a${P}
61
- `;if(V)if(q+=j,$0)q+=`while(memory!==-1){const start=memory+${R.length+2}
38
+ `},listen(w){return(z,U)=>{if(typeof Bun==="undefined")throw new Error(".listen() is designed to run on Bun only. If you are running Elysia in other environment please use a dedicated plugin or export the handler via Elysia.fetch");if(w.compile(),typeof z==="string"){if(!iw(z))throw new Error("Port must be a numeric value");z=parseInt(z)}let W=w.fetch,A=typeof z==="object"?{development:!T8,reusePort:!0,...w.config.serve||{},...z||{},static:w.router.static.http.static,websocket:{...w.config.websocket||{},...KU||{}},fetch:W,error:w.outerErrorHandler}:{development:!T8,reusePort:!0,...w.config.serve||{},static:w.router.static.http.static,websocket:{...w.config.websocket||{},...KU||{}},port:z,fetch:W,error:w.outerErrorHandler};w.server=Bun?.serve(A);for(let X=0;X<w.event.start.length;X++)w.event.start[X].fn(w);if(U)U(w.server);process.on("beforeExit",()=>{if(w.server){w.server.stop(),w.server=null;for(let X=0;X<w.event.stop.length;X++)w.event.stop[X].fn(w)}}),w.promisedModules.then(()=>{Bun?.gc(!1)})}},ws(w,z,U){let{parse:W,body:A,response:X,...Z}=U,$=j2(A,{modules:w.definitions.typebox,models:w.definitions.type,normalize:w.config.normalize}),Q=j2(X,{modules:w.definitions.typebox,models:w.definitions.type,normalize:w.config.normalize});w.route("$INTERNALWS",z,async(Y)=>{let B=w.getServer(),{set:G,path:_,qi:H,headers:F,query:R,params:J}=Y;if(Y.validator=Q,U.upgrade){if(typeof U.upgrade==="function"){let h=U.upgrade(Y);if(h instanceof Promise)await h}else if(U.upgrade)Object.assign(G.headers,U.upgrade)}if(G.cookie&&s2(G.cookie)){let h=pU(G.cookie);if(h)G.headers["set-cookie"]=h}if(G.headers["set-cookie"]&&Array.isArray(G.headers["set-cookie"]))G.headers=oU(new Headers(G.headers),G.headers["set-cookie"]);let m=xH(Q),A0=IH(W),L0;if(B?.upgrade(Y.request,{headers:s2(G.headers)?G.headers:void 0,data:{...Y,get id(){if(L0)return L0;return L0=gU()},validator:Q,ping(h){U.ping?.(h)},pong(h){U.pong?.(h)},open(h){m(h,U.open?.(new V4(h,Y)))},message:async(h,a)=>{let x=await A0(h,a);if($?.Check(x)===!1)return void h.send(new Z0("message",$,x).message);m(h,U.message?.(new V4(h,Y,x),x))},drain(h){m(h,U.drain?.(new V4(h,Y)))},close(h,a,x){m(h,U.close?.(new V4(h,Y),a,x))}}}))return;return G.status=400,"Expected a websocket connection"},{...Z,websocket:U})}},kH=typeof Bun!=="undefined",FU=kH?Bun.env:typeof process!=="undefined"&&process?.env?process.env:{},a6=/\+/g;function TH(w){let z={};if(typeof w!=="string")return z;let U="",W="",A=-1,X=-1,Z=0,$=w.length;for(let Q=0;Q<$;Q++)switch(w.charCodeAt(Q)){case 38:let Y=X>A;if(!Y)X=Q;if(U=w.slice(A+1,X),Y||U.length>0){if(Z&1)U=U.replace(a6," ");if(Z&2)U=b6.default(U)||U;if(!z[U]){if(Y){if(W=w.slice(X+1,Q),Z&4)W=W.replace(a6," ");if(Z&8)W=b6.default(W)||W}z[U]=W}}U="",W="",A=Q,X=Q,Z=0;break;case 61:if(X<=A)X=Q;else Z|=8;break;case 43:if(X>A)Z|=4;else Z|=1;break;case 37:if(X>A)Z|=8;else Z|=2;break}if(A<$){let Q=X>A;if(U=w.slice(A+1,Q?X:$),Q||U.length>0){if(Z&1)U=U.replace(a6," ");if(Z&2)U=b6.default(U)||U;if(!z[U]){if(Q){if(W=w.slice(X+1,$),Z&4)W=W.replace(a6," ");if(Z&8)W=b6.default(W)||W}z[U]=W}}}return z}var x8=(w)=>{let z={};if(typeof w!=="string")return z;let U=w.length,W="",A="",X=-1,Z=-1,$=!1,Q=!1,Y=!1,B=!1,G=!1,_=0;for(let H=0;H<U+1;H++){if(H!==U)_=w.charCodeAt(H);else _=38;switch(_){case 38:{if(G=Z>X,!G)Z=H;if(W=w.slice(X+1,Z),G||W.length>0){if(Y)W=W.replace(a6," ");if($)W=b6.default(W)||W;if(G){if(A=w.slice(Z+1,H),B)A=A.replace(a6," ");if(Q)A=b6.default(A)||A}let F=z[W];if(F===void 0)z[W]=A;else if(F.pop)F.push(A);else z[W]=[F,A]}A="",X=H,Z=H,$=!1,Q=!1,Y=!1,B=!1;break}case 61:if(Z<=X)Z=H;else Q=!0;break;case 43:if(Z>X)B=!0;else Y=!0;break;case 37:if(Z>X)Q=!0;else $=!0;break}}return z},vw=Symbol("ElysiaTrace"),i1=()=>{let{promise:w,resolve:z}=Promise.withResolvers(),{promise:U,resolve:W}=Promise.withResolvers(),{promise:A,resolve:X}=Promise.withResolvers(),Z=[],$=[];return[(Q)=>{if(Q)Z.push(Q);return w},(Q)=>{let Y=[],B=[],G=null;for(let H=0;H<(Q.total??0);H++){let{promise:F,resolve:R}=Promise.withResolvers(),{promise:J,resolve:m}=Promise.withResolvers(),{promise:A0,resolve:L0}=Promise.withResolvers(),h=[],a=[];Y.push((x)=>{if(x)h.push(x);return F}),B.push((x)=>{let i={...x,end:J,error:A0,index:H,onStop(K){if(K)a.push(K);return J}};R(i);for(let K=0;K<h.length;K++)h[K](i);return(K=null)=>{let o=performance.now();if(K)G=K;let D0={end:o,error:K,get elapsed(){return o-x.begin}};for(let l=0;l<a.length;l++)a[l](D0);m(o),L0(K)}})}let _={...Q,end:U,error:A,onEvent(H){for(let F=0;F<Y.length;F++)Y[F](H)},onStop(H){if(H)$.push(H);return U}};z(_);for(let H=0;H<Z.length;H++)Z[H](_);return{resolveChild:B,resolve(H=null){let F=performance.now();if(!H&&G)H=G;let R={end:F,error:H,get elapsed(){return F-Q.begin}};for(let J=0;J<$.length;J++)$[J](R);W(F),X(H)}}}]},gH=(w)=>{return(z)=>{let[U,W]=i1(),[A,X]=i1(),[Z,$]=i1(),[Q,Y]=i1(),[B,G]=i1(),[_,H]=i1(),[F,R]=i1(),[J,m]=i1(),[A0,L0]=i1();return w({id:z[d8],context:z,set:z.set,onRequest:U,onParse:A,onTransform:Z,onBeforeHandle:Q,onHandle:B,onAfterHandle:_,onMapResponse:J,onAfterResponse:A0,onError:F}),{request:W,parse:X,transform:$,beforeHandle:Y,handle:G,afterHandle:H,error:R,mapResponse:m,afterResponse:L0}}},g4={optional:Symbol.for("TypeBox.Optional"),kind:Symbol.for("TypeBox.Kind")},Y1=(w)=>{if(!w)return!1;let z=w?.schema;if(z?.[g4.kind]==="Import")return w.References().some(Y1);return!!z&&g4.optional in z},fH=["json","text","urlencoded","arrayBuffer","formdata","application/json","text/plain","application/x-www-form-urlencoded","application/octet-stream","multipart/form-data"],l2=(w)=>{if(!w)return!1;let z=w?.schema??w;if(z[g4.kind]==="Import"&&w.References())return w.References().some(l2);if(z.anyOf)return z.anyOf.some(l2);if(z.someOf)return z.someOf.some(l2);if(z.allOf)return z.allOf.some(l2);if(z.not)return z.not.some(l2);if(z.type==="object"){let U=z.properties;if("additionalProperties"in z)return z.additionalProperties;if("patternProperties"in z)return!1;for(let W of Object.keys(U)){let A=U[W];if(A.type==="object"){if(l2(A))return!0}else if(A.anyOf){for(let X=0;X<A.anyOf.length;X++)if(l2(A.anyOf[X]))return!0}return A.additionalProperties}return!1}return!1},nw=({context:w="c",trace:z,addFn:U})=>{if(!z.length)return()=>{return{resolveChild(){return()=>{}},resolve(){}}};for(let W=0;W<z.length;W++)U(`let report${W}, reportChild${W}, reportErr${W}, reportErrChild${W};let trace${W} = ${w}[ELYSIA_TRACE]?.[${W}] ?? trace[${W}](${w});
39
+ `);return(W,{name:A,total:X=0}={})=>{if(!A)A="anonymous";let Z=W==="error"?"reportErr":"report";for(let $=0;$<z.length;$++)U(`${Z}${$} = trace${$}.${W}({id,event:'${W}',name:'${A}',begin:performance.now(),total:${X}})
40
+ `);return{resolve(){for(let $=0;$<z.length;$++)U(`${Z}${$}.resolve()
41
+ `)},resolveChild($){for(let Q=0;Q<z.length;Q++)U(`${Z}Child${Q}=${Z}${Q}.resolveChild?.shift()?.({id,event:'${W}',name:'${$}',begin:performance.now()})
42
+ `);return(Q)=>{for(let Y=0;Y<z.length;Y++)if(Q)U(`if(${Q} instanceof Error){${Z}Child${Y}?.(${Q}) }else{${Z}Child${Y}?.()}`);else U(`${Z}Child${Y}?.()
43
+ `)}}}}},dH=({injectResponse:w="",normalize:z=!1,validator:U})=>({composeValidation:(W,A=`c.${W}`)=>`c.set.status=422;throw new ValidationError('${W}',validator.${W},${A})`,composeResponseValidation:(W="r")=>{let A=w+`
44
+ `;A+=`if(${W} instanceof ElysiaCustomStatusResponse){c.set.status=${W}.code
45
+ ${W}=${W}.response}const isResponse=${W} instanceof Response
46
+ switch(c.set.status){`;for(let[X,Z]of Object.entries(U.response)){if(A+=`
47
+ case ${X}:if(!isResponse){`,z&&"Clean"in Z&&!l2(Z))A+=`${W}=validator.response['${X}'].Clean(${W})
48
+ `;A+=`if(validator.response['${X}'].Check(${W})===false){c.set.status=422
49
+ throw new ValidationError('response',validator.response['${X}'],${W})}c.set.status = ${X}}break
50
+ `}return A+"}"}}),RE=Symbol.for("TypeBox.Kind"),U6=(w,z)=>{if(!z)return;let U=z.schema??z;if(U[g4.kind]==="Import")return z.References().some((W)=>U6(w,W));if(U.type==="object"){let W=U.properties;if(!W)return!1;for(let A of Object.keys(W)){let X=W[A];if(w in X)return!0;if(X.type==="object"){if(U6(w,X))return!0}else if(X.anyOf){for(let Z=0;Z<X.anyOf.length;Z++)if(U6(w,X.anyOf[Z]))return!0}}return!1}return w in U},kw=Symbol.for("TypeBox.Transform"),O6=(w)=>{if(!w)return;if(w.type==="object"&&w.properties){let z=w.properties;for(let U of Object.keys(z)){let W=z[U];if(W.type==="object"){if(O6(W))return!0}else if(W.anyOf){for(let A=0;A<W.anyOf.length;A++)if(O6(W.anyOf[A]))return!0}if(kw in W)return!0}return!1}return kw in w||w.properties&&kw in w.properties},hH=/(?:return|=>) \S+\(/g,e6=(w)=>{return(w?.fn??w).constructor.name==="AsyncFunction"},a0=(w)=>{let z=w?.fn??w;if(z.constructor.name==="AsyncFunction")return!0;let U=z.toString();if(U.includes("=> response.clone("))return!1;if(U.includes("await"))return!0;if(U.includes("async"))return!0;if(U.includes("=>response.clone("))return!1;return!!U.match(hH)},E8=(w)=>{let z=w?.fn??w;return z.constructor.name==="AsyncGeneratorFunction"||z.constructor.name==="GeneratorFunction"},yH=({app:w,path:z,method:U,localHook:W,hooks:A,validator:X,handler:Z,allowMeta:$=!1,inference:Q,asManifest:Y=!1})=>{let B=w["~adapter"].composeHandler,G=w["~adapter"].handler,_=typeof Z==="function";if(!_){if(Z=G.mapResponse(Z,{headers:w.setHeaders??{}}),A.parse.length===0&&A.transform.length===0&&A.beforeHandle.length===0&&A.afterHandle.length===0){if(Z instanceof Response)return Function("a","return function(){return a.clone()}")(Z);return Function("a","return function(){return a}")(Z)}}let H=_?"handler(c)":"handler",F=A.afterResponse.length>0,R=A.trace.length>0,J="";if(Q=uU(Object.assign(W,{handler:Z}),Q),B.declare){let j=B.declare(Q);if(j)J+=j}if(Q.server)J+=`Object.defineProperty(c,'server',{get:function(){return getServer()}})
51
+ `;X.createBody?.(),X.createQuery?.(),X.createHeaders?.(),X.createParams?.(),X.createCookie?.(),X.createResponse?.();let m=Q.query||!!X.query,A0=U!=="$INTERNALWS"&&U!=="GET"&&U!=="HEAD"&&(Q.body||!!X.body||A.parse.length);if(A0)J+=`let isParsing=false
52
+ `;let L0=w.setHeaders,h=L0&&!!Object.keys(L0).length,a=Q.headers||X.headers||B.preferWebstandardHeaders!==!0&&Q.body,x=Q.cookie||!!X.cookie,i=x?VU({modules:w.definitions.typebox,validator:X.cookie,defaultConfig:w.config.cookie,dynamic:!!w.config.aot,config:X.cookie?.config??{},models:w.definitions.type}):void 0,K=i?.config,o="";if(K?.sign){if(!K.secrets)throw new Error(`t.Cookie required secret which is not set in (${U}) ${z}.`);let j=!K.secrets?void 0:typeof K.secrets==="string"?K.secrets:K.secrets[0];if(o+=`const _setCookie = c.set.cookie
53
+ if(_setCookie){`,K.sign===!0)o+=`for(const [key, cookie] of Object.entries(_setCookie)){c.set.cookie[key].value=await signCookie(cookie.value,'${j}')}`;else for(let O of K.sign)o+=`if(_setCookie['${O}']?.value){c.set.cookie['${O}'].value=await signCookie(_setCookie['${O}'].value,'${j}')}`;o+=`}
54
+ `}let D0=w.config.normalize,{composeValidation:l,composeResponseValidation:O1}=dH({normalize:D0,validator:X});if(a)J+=B.headers;if(R)J+=`const id=c[ELYSIA_REQUEST_ID]
55
+ `;let C0=nw({trace:A.trace,addFn:(j)=>{J+=j}});if(J+="try{",x){let j=(b,T)=>{let t=K?.[b]??T;if(!t)return typeof T==="string"?`${b}:"${T}",`:`${b}:${T},`;if(typeof t==="string")return`${b}:'${t}',`;if(t instanceof Date)return`${b}: new Date(${t.getTime()}),`;return`${b}:${t},`},O=K?`{secrets:${K.secrets!==void 0?typeof K.secrets==="string"?`'${K.secrets}'`:"["+K.secrets.reduce((b,T)=>b+`'${T}',`,"")+"]":"undefined"},sign:${K.sign===!0?!0:K.sign!==void 0?"["+K.sign.reduce((b,T)=>b+`'${T}',`,"")+"]":"undefined"},`+j("domain")+j("expires")+j("httpOnly")+j("maxAge")+j("path","/")+j("priority")+j("sameSite")+j("secure")+"}":"undefined";if(a)J+=`
56
+ c.cookie=await parseCookie(c.set,c.headers.cookie,${O})
57
+ `;else J+=`
58
+ c.cookie=await parseCookie(c.set,c.request.headers.get('cookie'),${O})
59
+ `}if(m){let j=[];if(X.query&&X.query.schema.type==="object"){let O=X.query.schema.properties;if(!l2(X.query))for(let[b,T]of Object.entries(O)){let t=T;if(t&&g4.optional in t&&t.type==="array"&&t.items)t=t.items;let{type:e,anyOf:K0}=t,M=e==="array"||K0?.some((C)=>C.type==="string"&&C.format==="ArrayString");j.push({key:b,isArray:M,isNestedObjectArray:M&&t.items?.type==="object"||!!t.items?.anyOf?.some((C)=>C.type==="object"||C.type==="array"),isObject:e==="object"||K0?.some((C)=>C.type==="string"&&C.format==="ArrayString"),anyOf:!!K0})}}if(!j.length)J+="if(c.qi===-1){c.query={}}else{c.query=parseQueryFromURL(c.url.slice(c.qi + 1))}";else{J+=`if(c.qi!==-1){let url = '&' + decodeURIComponent(c.url.slice(c.qi + 1))
60
+ `;let O=0;for(let{key:b,isArray:T,isObject:t,isNestedObjectArray:e,anyOf:K0}of j){let M=(O===0?"let ":"")+`memory=url.indexOf('&${b}=')
61
+ let a${O}
62
+ `;if(T)if(J+=M,e)J+=`while(memory!==-1){const start=memory+${b.length+2}
62
63
  memory=url.indexOf('&',start)
63
- if(a${P}===undefined)
64
- a${P}=''
64
+ if(a${O}===undefined)
65
+ a${O}=''
65
66
  else
66
- a${P}+=','
67
+ a${O}+=','
67
68
  let temp
68
69
  if(memory===-1)temp=decodeURIComponent(url.slice(start).replace(/\\+|%20/g,' '))
69
70
  else temp=decodeURIComponent(url.slice(start, memory).replace(/\\+|%20/g,' '))
70
71
  const charCode = temp.charCodeAt(0)
71
72
  if(charCode !== 91 && charCode !== 123)
72
73
  temp='"'+temp+'"'
73
- a${P} += temp
74
+ a${O} += temp
74
75
  if(memory === -1)break
75
- memory=url.indexOf('&${R}=',memory)
76
- if(memory === -1)break}try{if(a${P}.charCodeAt(0) === 91)a${P} = JSON.parse(a${P})
76
+ memory=url.indexOf('&${b}=',memory)
77
+ if(memory === -1)break}try{if(a${O}.charCodeAt(0) === 91)a${O} = JSON.parse(a${O})
77
78
  else
78
- a${P}=JSON.parse('['+a${P}+']')}catch{}
79
- `;else q+=`while(memory!==-1){const start=memory+${R.length+2}
79
+ a${O}=JSON.parse('['+a${O}+']')}catch{}
80
+ `;else J+=`while(memory!==-1){const start=memory+${b.length+2}
80
81
  memory=url.indexOf('&',start)
81
- if(a${P}===undefined)a${P}=[]
82
- if(memory===-1){a${P}.push(decodeURIComponent(url.slice(start)).replace(/\\+|%20/g,' '))
83
- break}else a${P}.push(decodeURIComponent(url.slice(start, memory)).replace(/\\+|%20/g,' '))
84
- memory=url.indexOf('&${R}=',memory)
82
+ if(a${O}===undefined)a${O}=[]
83
+ if(memory===-1){a${O}.push(decodeURIComponent(url.slice(start)).replace(/\\+|%20/g,' '))
84
+ break}else a${O}.push(decodeURIComponent(url.slice(start, memory)).replace(/\\+|%20/g,' '))
85
+ memory=url.indexOf('&${b}=',memory)
85
86
  if(memory===-1) break
86
- }`;else if(u)q+=j+`if(memory!==-1){const start=memory+${R.length+2}
87
+ }`;else if(t)J+=M+`if(memory!==-1){const start=memory+${b.length+2}
87
88
  memory=url.indexOf('&',start)
88
- if(memory===-1)a${P}=decodeURIComponent(url.slice(start).replace(/\\+|%20/g,' '))else a${P}=decodeURIComponent(url.slice(start,memory).replace(/\\+|%20/g,' '))if(a${P}!==undefined)try{a${P}=JSON.parse(a${P})}catch{}}`;else{if(q+=j+`if(memory!==-1){const start=memory+${R.length+2}
89
+ if(memory===-1)a${O}=decodeURIComponent(url.slice(start).replace(/\\+|%20/g,' '))else a${O}=decodeURIComponent(url.slice(start,memory).replace(/\\+|%20/g,' '))if(a${O}!==undefined)try{a${O}=JSON.parse(a${O})}catch{}}`;else{if(J+=M+`if(memory!==-1){const start=memory+${b.length+2}
89
90
  memory=url.indexOf('&',start)
90
- if(memory===-1)a${P}=decodeURIComponent(url.slice(start).replace(/\\+|%20/g,' '))
91
- else{a${P}=decodeURIComponent(url.slice(start,memory).replace(/\\+|%20/g,' '))`,B)q+=`
92
- let deepMemory=url.indexOf('&${R}=',memory)
93
- if(deepMemory!==-1){a${P}=[a${P}]
91
+ if(memory===-1)a${O}=decodeURIComponent(url.slice(start).replace(/\\+|%20/g,' '))
92
+ else{a${O}=decodeURIComponent(url.slice(start,memory).replace(/\\+|%20/g,' '))`,K0)J+=`
93
+ let deepMemory=url.indexOf('&${b}=',memory)
94
+ if(deepMemory!==-1){a${O}=[a${O}]
94
95
  let first=true
95
- while(true){const start=deepMemory+${R.length+2}
96
+ while(true){const start=deepMemory+${b.length+2}
96
97
  if(first)first=false
97
98
  else deepMemory = url.indexOf('&', start)
98
99
  let value
@@ -101,53 +102,53 @@ else value=decodeURIComponent(url.slice(start, deepMemory).replace(/\\+|%20/g,'
101
102
  const vStart=value.charCodeAt(0)
102
103
  const vEnd=value.charCodeAt(value.length - 1)
103
104
  if((vStart===91&&vEnd===93)||(vStart===123&&vEnd===125))
104
- try{a${P}.push(JSON.parse(value))}catch{a${P}.push(value)}if(deepMemory===-1)break}}`;q+="}}"}P++,q+=`
105
- `}q+="c.query={"+F.map(({key:R},V)=>`'${R}':a${V}`).join(",")+"}",q+=`} else c.query = {}
106
- `}}let v1=typeof X==="function"&&a0(X),f2=C||W.afterResponse.length>0?"c.response= ":"",q6=f||W0||v1||W.parse.length>0||W.afterHandle.some(a0)||W.beforeHandle.some(a0)||W.transform.some(a0)||W.mapResponse.some(a0),z5=(typeof X==="function"?W8(X):!1)||W.beforeHandle.some(W8)||W.afterHandle.some(W8)||W.transform.some(W8),I6=Z.cookie||Z.set||e||C||$.response||_&&c||z5,m0=Y.mapResponseContext?`,${Y.mapResponseContext}`:"";if(Z.route)q+=`c.route=\`${z}\`
107
- `;let p0=R0("parse",{total:W.parse.length});if(W0){let F=B1($.body),P=W.parse.length||Z.body||$.body;if(Y.parser.declare)q+=Y.parser.declare;q+=`
108
- isParsing=true`;let R=typeof W.parse==="string"?W.parse:Array.isArray(W.parse)&&W.parse.length===1?typeof W.parse[0]==="string"?W.parse[0]:typeof W.parse[0].fn==="string"?W.parse[0].fn:void 0:void 0;if(R&&R in cH){let V=R0("parse",{total:W.parse.length});switch(R){case"json":case"application/json":q+=Y.parser.json(F);break;case"text":case"text/plain":q+=Y.parser.text(F);break;case"urlencoded":case"application/x-www-form-urlencoded":q+=Y.parser.urlencoded(F);break;case"arrayBuffer":case"application/octet-stream":q+=Y.parser.arrayBuffer(F);break;case"formdata":case"multipart/form-data":q+=Y.parser.formData(F);break;default:if(R[0]in w["~parser"])q+=e?"let contentType = c.headers['content-type']":"let contentType = c.request.headers.get('content-type')",q+=`
105
+ try{a${O}.push(JSON.parse(value))}catch{a${O}.push(value)}if(deepMemory===-1)break}}`;J+="}}"}O++,J+=`
106
+ `}J+="c.query={"+j.map(({key:b},T)=>`'${b}':a${T}`).join(",")+"}",J+=`} else c.query = {}
107
+ `}}let n1=typeof Z==="function"&&a0(Z),I2=R||A.afterResponse.length>0?"c.response= ":"",Y6=x||A0||n1||A.parse.length>0||A.afterHandle.some(a0)||A.beforeHandle.some(a0)||A.transform.some(a0)||A.mapResponse.some(a0),g5=(typeof Z==="function"?E8(Z):!1)||A.beforeHandle.some(E8)||A.afterHandle.some(E8)||A.transform.some(E8),K6=Q.cookie||Q.set||a||R||X.response||_&&h||g5,o0=B.mapResponseContext?`,${B.mapResponseContext}`:"";if(Q.route)J+=`c.route=\`${z}\`
108
+ `;let l0=C0("parse",{total:A.parse.length});if(A0){let j=Y1(X.body),O=A.parse.length||Q.body||X.body;if(B.parser.declare)J+=B.parser.declare;J+=`
109
+ isParsing=true`;let b=typeof A.parse==="string"?A.parse:Array.isArray(A.parse)&&A.parse.length===1?typeof A.parse[0]==="string"?A.parse[0]:typeof A.parse[0].fn==="string"?A.parse[0].fn:void 0:void 0;if(b&&b in fH){let T=C0("parse",{total:A.parse.length});switch(b){case"json":case"application/json":J+=B.parser.json(j);break;case"text":case"text/plain":J+=B.parser.text(j);break;case"urlencoded":case"application/x-www-form-urlencoded":J+=B.parser.urlencoded(j);break;case"arrayBuffer":case"application/octet-stream":J+=B.parser.arrayBuffer(j);break;case"formdata":case"multipart/form-data":J+=B.parser.formData(j);break;default:if(b[0]in w["~parser"])J+=a?"let contentType = c.headers['content-type']":"let contentType = c.request.headers.get('content-type')",J+=`
109
110
  if(contentType){const index=contentType.indexOf(';')
110
111
  if(index!==-1)contentType=contentType.substring(0, index)}
111
112
  else{contentType=''}c.contentType=contentType
112
- `,q+=`let result=parser['${R}'](c, contentType)
113
+ `,J+=`let result=parser['${b}'](c, contentType)
113
114
  if(result instanceof Promise)result=await result
114
115
  if(result instanceof ElysiaCustomStatusResponse)throw result
115
116
  if(result!==undefined)c.body=result
116
117
  delete c.contentType
117
- `;break}V.resolve()}else if(P){if(q+=`
118
- `,q+=e?"let contentType = c.headers['content-type']":"let contentType = c.request.headers.get('content-type')",q+=`
118
+ `;break}T.resolve()}else if(O){if(J+=`
119
+ `,J+=a?"let contentType = c.headers['content-type']":"let contentType = c.request.headers.get('content-type')",J+=`
119
120
  if(contentType){const index=contentType.indexOf(';')
120
121
  if(index!==-1)contentType=contentType.substring(0, index)}
121
122
  else{contentType=''}c.contentType=contentType
122
- `,W.parse.length)q+=`let used=false
123
- `;let V=R0("parse",{total:W.parse.length}),u=!1;for(let $0=0;$0<W.parse.length;$0++){let B=`bo${$0}`;if($0!==0)q+=`
124
- if(!used){`;if(typeof W.parse[$0].fn==="string"){let j=V.resolveChild(W.parse[$0].fn);switch(W.parse[$0].fn){case"json":case"application/json":u=!0,q+=Y.parser.json(F);break;case"text":case"text/plain":u=!0,q+=Y.parser.text(F);break;case"urlencoded":case"application/x-www-form-urlencoded":u=!0,q+=Y.parser.urlencoded(F);break;case"arrayBuffer":case"application/octet-stream":u=!0,q+=Y.parser.arrayBuffer(F);break;case"formdata":case"multipart/form-data":u=!0,q+=Y.parser.formData(F);break;default:q+=`${B}=parser['${W.parse[$0].fn}'](c,contentType)
125
- if(${B} instanceof Promise)${B}=await ${B}
126
- if(${B}!==undefined){c.body=${B};used=true}
127
- `}j()}else{let j=V.resolveChild(W.parse[$0].fn.name);q+=`let ${B}=parse[${$0}]
128
- ${B}=${B}(c,contentType)
129
- if(${B} instanceof Promise)${B}=await ${B}
130
- if(${B}!==undefined){c.body=${B};used=true}`,j()}if($0!==0)q+="}";if(u)break}if(V.resolve(),!u){if(W.parse.length)q+=`
123
+ `,A.parse.length)J+=`let used=false
124
+ `;let T=C0("parse",{total:A.parse.length}),t=!1;for(let e=0;e<A.parse.length;e++){let K0=`bo${e}`;if(e!==0)J+=`
125
+ if(!used){`;if(typeof A.parse[e].fn==="string"){let M=T.resolveChild(A.parse[e].fn);switch(A.parse[e].fn){case"json":case"application/json":t=!0,J+=B.parser.json(j);break;case"text":case"text/plain":t=!0,J+=B.parser.text(j);break;case"urlencoded":case"application/x-www-form-urlencoded":t=!0,J+=B.parser.urlencoded(j);break;case"arrayBuffer":case"application/octet-stream":t=!0,J+=B.parser.arrayBuffer(j);break;case"formdata":case"multipart/form-data":t=!0,J+=B.parser.formData(j);break;default:J+=`${K0}=parser['${A.parse[e].fn}'](c,contentType)
126
+ if(${K0} instanceof Promise)${K0}=await ${K0}
127
+ if(${K0}!==undefined){c.body=${K0};used=true}
128
+ `}M()}else{let M=T.resolveChild(A.parse[e].fn.name);J+=`let ${K0}=parse[${e}]
129
+ ${K0}=${K0}(c,contentType)
130
+ if(${K0} instanceof Promise)${K0}=await ${K0}
131
+ if(${K0}!==undefined){c.body=${K0};used=true}`,M()}if(e!==0)J+="}";if(t)break}if(T.resolve(),!t){if(A.parse.length)J+=`
131
132
  if(!used){
132
133
  if(!contentType) throw new ParseError()
133
- `;q+="switch(contentType){",q+=`case 'application/json':
134
- `+Y.parser.json(F)+`break
135
- case 'text/plain':`+Y.parser.text(F)+`break
136
- case 'application/x-www-form-urlencoded':`+Y.parser.urlencoded(F)+`break
137
- case 'application/octet-stream':`+Y.parser.arrayBuffer(F)+`break
138
- case 'multipart/form-data':`+Y.parser.formData(F)+`break
139
- `;for(let $0 of Object.keys(w["~parser"]))q+=`case '${$0}':let bo${$0}=parser['${$0}'](c,contentType)
140
- if(bo${$0} instanceof Promise)bo${$0}=await bo${$0}
141
- if(bo${$0} instanceof ElysiaCustomStatusResponse)throw result
142
- if(bo${$0}!==undefined)c.body=bo${$0}
134
+ `;J+="switch(contentType){",J+=`case 'application/json':
135
+ `+B.parser.json(j)+`break
136
+ case 'text/plain':`+B.parser.text(j)+`break
137
+ case 'application/x-www-form-urlencoded':`+B.parser.urlencoded(j)+`break
138
+ case 'application/octet-stream':`+B.parser.arrayBuffer(j)+`break
139
+ case 'multipart/form-data':`+B.parser.formData(j)+`break
140
+ `;for(let e of Object.keys(w["~parser"]))J+=`case '${e}':let bo${e}=parser['${e}'](c,contentType)
141
+ if(bo${e} instanceof Promise)bo${e}=await bo${e}
142
+ if(bo${e} instanceof ElysiaCustomStatusResponse)throw result
143
+ if(bo${e}!==undefined)c.body=bo${e}
143
144
  break
144
- `;if(W.parse.length)q+="}";q+="}"}}q+=`
145
- delete c.contentType`,q+=`
145
+ `;if(A.parse.length)J+="}";J+="}"}}J+=`
146
+ delete c.contentType`,J+=`
146
147
  isParsing=false
147
- `}if(p0.resolve(),W?.transform){let F=R0("transform",{total:W.transform.length});if(W.transform.length)q+=`let transformed
148
- `;for(let P=0;P<W.transform.length;P++){let R=W.transform[P],V=F.resolveChild(R.fn.name);if(q+=a0(R)?`transformed=await transform[${P}](c)
149
- `:`transformed=transform[${P}](c)
150
- `,R.subType==="mapDerive")q+=`if(transformed instanceof ElysiaCustomStatusResponse)throw transformed
148
+ `}if(l0.resolve(),A?.transform){let j=C0("transform",{total:A.transform.length});if(A.transform.length)J+=`let transformed
149
+ `;for(let O=0;O<A.transform.length;O++){let b=A.transform[O],T=j.resolveChild(b.fn.name);if(J+=a0(b)?`transformed=await transform[${O}](c)
150
+ `:`transformed=transform[${O}](c)
151
+ `,b.subType==="mapDerive")J+=`if(transformed instanceof ElysiaCustomStatusResponse)throw transformed
151
152
  else{transformed.request=c.request
152
153
  transformed.store=c.store
153
154
  transformed.qi=c.qi
@@ -156,30 +157,30 @@ transformed.url=c.url
156
157
  transformed.redirect=c.redirect
157
158
  transformed.set=c.set
158
159
  transformed.error=c.error
159
- c=transformed}`;else q+=`if(transformed instanceof ElysiaCustomStatusResponse)throw transformed
160
+ c=transformed}`;else J+=`if(transformed instanceof ElysiaCustomStatusResponse)throw transformed
160
161
  else Object.assign(c,transformed)
161
- `;V()}F.resolve()}if($){if($.headers){if(D0&&"Clean"in $.headers&&!e2($.headers))q+=`c.headers=validator.headers.Clean(c.headers);
162
- `;if(Q6("default",$.headers))for(let[F,P]of Object.entries(p.Default($.headers.schema,{}))){let R=typeof P==="object"?JSON.stringify(P):typeof P==="string"?`'${P}'`:P;if(R!==void 0)q+=`c.headers['${F}']??=${R}
163
- `}if(B1($.headers))q+="if(isNotEmpty(c.headers)){";if(q+="if(validator.headers.Check(c.headers) === false){"+s("headers")+"}",F6($.headers.schema))q+=`c.headers=validator.headers.Decode(c.headers)
164
- `;if(B1($.headers))q+="}"}if($.params){if(Q6("default",$.params))for(let[F,P]of Object.entries(p.Default($.params.schema,{}))){let R=typeof P==="object"?JSON.stringify(P):typeof P==="string"?`'${P}'`:P;if(R!==void 0)q+=`c.params['${F}']??=${R}
165
- `}if(q+="if(validator.params.Check(c.params)===false){"+s("params")+"}",F6($.params.schema))q+=`c.params=validator.params.Decode(c.params)
166
- `}if($.query){if(D0&&"Clean"in $.query&&!e2($.query))q+=`c.query=validator.query.Clean(c.query)
167
- `;if(Q6("default",$.query))for(let[F,P]of Object.entries(p.Default($.query.schema,{}))){let R=typeof P==="object"?JSON.stringify(P):typeof P==="string"?`'${P}'`:P;if(R!==void 0)q+=`if(c.query['${F}']===undefined)c.query['${F}']=${R}
168
- `}if(B1($.query))q+="if(isNotEmpty(c.query)){";if(q+="if(validator.query.Check(c.query)===false){"+s("query")+"}",F6($.query.schema))q+=`c.query=validator.query.Decode(Object.assign({},c.query))
169
- `;if(B1($.query))q+="}"}if($.body){if(D0&&"Clean"in $.body&&!e2($.body))q+=`c.body=validator.body.Clean(c.body)
170
- `;let F=F6($.body.schema);if(F||B1($.body))q+=`const isNotEmptyObject=c.body&&(typeof c.body==="object"&&isNotEmpty(c.body))
171
- `;if(Q6("default",$.body)){let P=p.Default($.body.schema,$.body.schema.type==="object"?{}:void 0),R=typeof P==="object"?JSON.stringify(P):typeof P==="string"?`'${P}'`:P;if(q+=`if(validator.body.Check(c.body)===false){if(typeof c.body==='object')c.body=Object.assign(${R},c.body)
172
- else c.body=${R}
173
- `,B1($.body))q+="if(isNotEmptyObject&&validator.body.Check(c.body)===false){"+s("body")+"}";else q+="if(validator.body.Check(c.body)===false){"+s("body")+"}";q+="}"}else if(B1($.body))q+="if(isNotEmptyObject&&validator.body.Check(c.body)===false){"+s("body")+"}";else q+="if(validator.body.Check(c.body)===false){"+s("body")+"}";if(F)q+=`if(isNotEmptyObject)c.body=validator.body.Decode(c.body)
174
- `}if(t&&Q2(t?.schema?.properties??t?.schema?.schema??{})){if(q+=`const cookieValue={}
162
+ `;T()}j.resolve()}if(X){if(X.headers){if(D0&&"Clean"in X.headers&&!l2(X.headers))J+=`c.headers=validator.headers.Clean(c.headers);
163
+ `;if(U6("default",X.headers))for(let[j,O]of Object.entries(p.Default(X.headers.schema,{}))){let b=typeof O==="object"?JSON.stringify(O):typeof O==="string"?`'${O}'`:O;if(b!==void 0)J+=`c.headers['${j}']??=${b}
164
+ `}if(Y1(X.headers))J+="if(isNotEmpty(c.headers)){";if(J+="if(validator.headers.Check(c.headers) === false){"+l("headers")+"}",O6(X.headers.schema))J+=`c.headers=validator.headers.Decode(c.headers)
165
+ `;if(Y1(X.headers))J+="}"}if(X.params){if(U6("default",X.params))for(let[j,O]of Object.entries(p.Default(X.params.schema,{}))){let b=typeof O==="object"?JSON.stringify(O):typeof O==="string"?`'${O}'`:O;if(b!==void 0)J+=`c.params['${j}']??=${b}
166
+ `}if(J+="if(validator.params.Check(c.params)===false){"+l("params")+"}",O6(X.params.schema))J+=`c.params=validator.params.Decode(c.params)
167
+ `}if(X.query){if(D0&&"Clean"in X.query&&!l2(X.query))J+=`c.query=validator.query.Clean(c.query)
168
+ `;if(U6("default",X.query))for(let[j,O]of Object.entries(p.Default(X.query.schema,{}))){let b=typeof O==="object"?JSON.stringify(O):typeof O==="string"?`'${O}'`:O;if(b!==void 0)J+=`if(c.query['${j}']===undefined)c.query['${j}']=${b}
169
+ `}if(Y1(X.query))J+="if(isNotEmpty(c.query)){";if(J+="if(validator.query.Check(c.query)===false){"+l("query")+"}",O6(X.query.schema))J+=`c.query=validator.query.Decode(Object.assign({},c.query))
170
+ `;if(Y1(X.query))J+="}"}if(X.body){if(D0&&"Clean"in X.body&&!l2(X.body))J+=`c.body=validator.body.Clean(c.body)
171
+ `;let j=O6(X.body.schema);if(j||Y1(X.body))J+=`const isNotEmptyObject=c.body&&(typeof c.body==="object"&&isNotEmpty(c.body))
172
+ `;if(U6("default",X.body)){let O=p.Default(X.body.schema,X.body.schema.type==="object"?{}:void 0),b=typeof O==="object"?JSON.stringify(O):typeof O==="string"?`'${O}'`:O;if(J+=`if(validator.body.Check(c.body)===false){if(typeof c.body==='object')c.body=Object.assign(${b},c.body)
173
+ else c.body=${b}
174
+ `,Y1(X.body))J+="if(isNotEmptyObject&&validator.body.Check(c.body)===false){"+l("body")+"}";else J+="if(validator.body.Check(c.body)===false){"+l("body")+"}";J+="}"}else if(Y1(X.body))J+="if(isNotEmptyObject&&validator.body.Check(c.body)===false){"+l("body")+"}";else J+="if(validator.body.Check(c.body)===false){"+l("body")+"}";if(j)J+=`if(isNotEmptyObject)c.body=validator.body.Decode(c.body)
175
+ `}if(i&&s2(i?.schema?.properties??i?.schema?.schema??{})){if(J+=`const cookieValue={}
175
176
  for(const [key,value] of Object.entries(c.cookie))cookieValue[key]=value.value
176
- `,Q6("default",t))for(let[F,P]of Object.entries(p.Default(t.schema,{})))q+=`cookieValue['${F}'] = ${typeof P==="object"?JSON.stringify(P):P}
177
- `;if(B1($.cookie))q+="if(isNotEmpty(c.cookie)){";if(q+="if(validator.cookie.Check(cookieValue)===false){"+s("cookie","cookieValue")+"}",F6($.cookie.schema))q+=`for(const [key,value] of Object.entries(validator.cookie.Decode(cookieValue)))c.cookie[key].value=value
178
- `;if(B1($.cookie))q+="}"}}if(W?.beforeHandle){let F=R0("beforeHandle",{total:W.beforeHandle.length}),P=!1;for(let R=0;R<W.beforeHandle.length;R++){let V=W.beforeHandle[R],u=F.resolveChild(V.fn.name),$0=$4(V);if(V.subType==="resolve"||V.subType==="mapResolve"){if(!P)P=!0,q+=`
177
+ `,U6("default",i))for(let[j,O]of Object.entries(p.Default(i.schema,{})))J+=`cookieValue['${j}'] = ${typeof O==="object"?JSON.stringify(O):O}
178
+ `;if(Y1(X.cookie))J+="if(isNotEmpty(c.cookie)){";if(J+="if(validator.cookie.Check(cookieValue)===false){"+l("cookie","cookieValue")+"}",O6(X.cookie.schema))J+=`for(const [key,value] of Object.entries(validator.cookie.Decode(cookieValue)))c.cookie[key].value=value
179
+ `;if(Y1(X.cookie))J+="}"}}if(A?.beforeHandle){let j=C0("beforeHandle",{total:A.beforeHandle.length}),O=!1;for(let b=0;b<A.beforeHandle.length;b++){let T=A.beforeHandle[b],t=j.resolveChild(T.fn.name),e=T4(T);if(T.subType==="resolve"||T.subType==="mapResolve"){if(!O)O=!0,J+=`
179
180
  let resolved
180
- `;if(q+=a0(V)?`resolved=await beforeHandle[${R}](c);
181
- `:`resolved=beforeHandle[${R}](c);
182
- `,V.subType==="mapResolve")q+=`if(resolved instanceof ElysiaCustomStatusResponse)throw resolved
181
+ `;if(J+=a0(T)?`resolved=await beforeHandle[${b}](c);
182
+ `:`resolved=beforeHandle[${b}](c);
183
+ `,T.subType==="mapResolve")J+=`if(resolved instanceof ElysiaCustomStatusResponse)throw resolved
183
184
  else{resolved.request = c.request
184
185
  resolved.store = c.store
185
186
  resolved.qi = c.qi
@@ -188,89 +189,89 @@ resolved.url = c.url
188
189
  resolved.redirect = c.redirect
189
190
  resolved.set = c.set
190
191
  resolved.error = c.error
191
- c = resolved}`;else q+=`if(resolved instanceof ElysiaCustomStatusResponse)throw resolved
192
+ c = resolved}`;else J+=`if(resolved instanceof ElysiaCustomStatusResponse)throw resolved
192
193
  else Object.assign(c, resolved)
193
- `}else if(!$0)q+=a0(V)?`await beforeHandle[${R}](c)
194
- `:`beforeHandle[${R}](c)
195
- `,u();else{if(q+=a0(V)?`be=await beforeHandle[${R}](c)
196
- `:`be=beforeHandle[${R}](c)
197
- `,u("be"),q+="if(be!==undefined){",F.resolve(),W.afterHandle?.length){R0("handle",{name:_?X.name:void 0}).resolve();let H=R0("afterHandle",{total:W.afterHandle.length});for(let i=0;i<W.afterHandle.length;i++){let E=W.afterHandle[i],k=$4(E),K0=H.resolveChild(E.fn.name);if(q+=`c.response = be
198
- `,!k)q+=a0(E.fn)?`await afterHandle[${i}](c, be)
199
- `:`afterHandle[${i}](c, be)
200
- `;else q+=a0(E.fn)?`af = await afterHandle[${i}](c)
201
- `:`af = afterHandle[${i}](c)
202
- `,q+=`if(af!==undefined) c.response=be=af
203
- `;K0("af")}H.resolve()}if($.response)q+=P1("be");let j=R0("mapResponse",{total:W.mapResponse.length});if(W.mapResponse.length){q+=`c.response=be
204
- `;for(let H=0;H<W.mapResponse.length;H++){let i=W.mapResponse[H],E=j.resolveChild(i.fn.name);q+=`if(mr===undefined){mr=${q4(i)?"await":""} onMapResponse[${H}](c)
205
- if(mr!==undefined)be=c.response=mr}`,E()}}j.resolve(),q+=l,q+=`return mapEarlyResponse(${f2}be,c.set${m0})}
206
- `}}F.resolve()}if(W?.afterHandle.length){let F=R0("handle",{name:_?X.name:void 0});if(W.afterHandle.length)q+=v1?`let r=c.response=await ${G}
207
- `:`let r=c.response=${G}
208
- `;else q+=v1?`let r=await ${G}
209
- `:`let r=${G}
210
- `;F.resolve();let P=R0("afterHandle",{total:W.afterHandle.length});for(let V=0;V<W.afterHandle.length;V++){let u=W.afterHandle[V],$0=$4(u),B=P.resolveChild(u.fn.name);if(!$0)q+=a0(u.fn)?`await afterHandle[${V}](c)
211
- `:`afterHandle[${V}](c)
212
- `,B();else if(q+=a0(u.fn)?`af=await afterHandle[${V}](c)
213
- `:`af=afterHandle[${V}](c)
214
- `,B("af"),$.response)q+="if(af!==undefined){",P.resolve(),q+=P1("af"),q+="c.response=af}";else q+="if(af!==undefined){",P.resolve(),q+="c.response=af}"}if(P.resolve(),q+=`r=c.response
215
- `,$.response)q+=P1();q+=l;let R=R0("mapResponse",{total:W.mapResponse.length});if(W.mapResponse.length)for(let V=0;V<W.mapResponse.length;V++){let u=W.mapResponse[V],$0=R.resolveChild(u.fn.name);q+=`mr=${q4(u)?"await":""} onMapResponse[${V}](c)
194
+ `}else if(!e)J+=a0(T)?`await beforeHandle[${b}](c)
195
+ `:`beforeHandle[${b}](c)
196
+ `,t();else{if(J+=a0(T)?`be=await beforeHandle[${b}](c)
197
+ `:`be=beforeHandle[${b}](c)
198
+ `,t("be"),J+="if(be!==undefined){",j.resolve(),A.afterHandle?.length){C0("handle",{name:_?Z.name:void 0}).resolve();let M=C0("afterHandle",{total:A.afterHandle.length});for(let C=0;C<A.afterHandle.length;C++){let L=A.afterHandle[C],u=T4(L),V=M.resolveChild(L.fn.name);if(J+=`c.response = be
199
+ `,!u)J+=a0(L.fn)?`await afterHandle[${C}](c, be)
200
+ `:`afterHandle[${C}](c, be)
201
+ `;else J+=a0(L.fn)?`af = await afterHandle[${C}](c)
202
+ `:`af = afterHandle[${C}](c)
203
+ `,J+=`if(af!==undefined) c.response=be=af
204
+ `;V("af")}M.resolve()}if(X.response)J+=O1("be");let K0=C0("mapResponse",{total:A.mapResponse.length});if(A.mapResponse.length){J+=`c.response=be
205
+ `;for(let M=0;M<A.mapResponse.length;M++){let C=A.mapResponse[M],L=K0.resolveChild(C.fn.name);J+=`if(mr===undefined){mr=${e6(C)?"await":""} onMapResponse[${M}](c)
206
+ if(mr!==undefined)be=c.response=mr}`,L()}}K0.resolve(),J+=o,J+=`return mapEarlyResponse(${I2}be,c.set${o0})}
207
+ `}}j.resolve()}if(A?.afterHandle.length){let j=C0("handle",{name:_?Z.name:void 0});if(A.afterHandle.length)J+=n1?`let r=c.response=await ${H}
208
+ `:`let r=c.response=${H}
209
+ `;else J+=n1?`let r=await ${H}
210
+ `:`let r=${H}
211
+ `;j.resolve();let O=C0("afterHandle",{total:A.afterHandle.length});for(let T=0;T<A.afterHandle.length;T++){let t=A.afterHandle[T],e=T4(t),K0=O.resolveChild(t.fn.name);if(!e)J+=a0(t.fn)?`await afterHandle[${T}](c)
212
+ `:`afterHandle[${T}](c)
213
+ `,K0();else if(J+=a0(t.fn)?`af=await afterHandle[${T}](c)
214
+ `:`af=afterHandle[${T}](c)
215
+ `,K0("af"),X.response)J+="if(af!==undefined){",O.resolve(),J+=O1("af"),J+="c.response=af}";else J+="if(af!==undefined){",O.resolve(),J+="c.response=af}"}if(O.resolve(),J+=`r=c.response
216
+ `,X.response)J+=O1();J+=o;let b=C0("mapResponse",{total:A.mapResponse.length});if(A.mapResponse.length)for(let T=0;T<A.mapResponse.length;T++){let t=A.mapResponse[T],e=b.resolveChild(t.fn.name);J+=`mr=${e6(t)?"await":""} onMapResponse[${T}](c)
216
217
  if(mr!==undefined)r=c.response=mr
217
- `,$0()}if(R.resolve(),I6)q+=`return mapResponse(${f2}r,c.set${m0})
218
- `;else q+=`return mapCompactResponse(${f2}r${m0})
219
- `}else{let F=R0("handle",{name:_?X.name:void 0});if($.response||W.mapResponse.length){if(q+=v1?`let r=await ${G}
220
- `:`let r=${G}
221
- `,F.resolve(),$.response)q+=P1();R0("afterHandle").resolve();let P=R0("mapResponse",{total:W.mapResponse.length});if(W.mapResponse.length){q+=`
218
+ `,e()}if(b.resolve(),K6)J+=`return mapResponse(${I2}r,c.set${o0})
219
+ `;else J+=`return mapCompactResponse(${I2}r${o0})
220
+ `}else{let j=C0("handle",{name:_?Z.name:void 0});if(X.response||A.mapResponse.length){if(J+=n1?`let r=await ${H}
221
+ `:`let r=${H}
222
+ `,j.resolve(),X.response)J+=O1();C0("afterHandle").resolve();let O=C0("mapResponse",{total:A.mapResponse.length});if(A.mapResponse.length){J+=`
222
223
  c.response=r
223
- `;for(let R=0;R<W.mapResponse.length;R++){let V=W.mapResponse[R],u=P.resolveChild(V.fn.name);q+=`
224
- if(mr===undefined){mr=${q4(V)?"await ":""}onMapResponse[${R}](c)
224
+ `;for(let b=0;b<A.mapResponse.length;b++){let T=A.mapResponse[b],t=O.resolveChild(T.fn.name);J+=`
225
+ if(mr===undefined){mr=${e6(T)?"await ":""}onMapResponse[${b}](c)
225
226
  if(mr!==undefined)r=c.response=mr}
226
- `,u()}}if(P.resolve(),q+=l,X instanceof Response)q+=Z.set?`if(isNotEmpty(c.set.headers)||c.set.status!==200||c.set.redirect||c.set.cookie)return mapResponse(${f2}${G}.clone(),c.set${m0})else return ${G}.clone()`:`return ${G}.clone()`,q+=`
227
- `;else if(I6)q+=`return mapResponse(${f2}r,c.set${m0})
228
- `;else q+=`return mapCompactResponse(${f2}r${m0})
229
- `}else if(f||C){q+=v1?`let r=await ${G}
230
- `:`let r=${G}
231
- `,F.resolve(),R0("afterHandle").resolve();let P=R0("mapResponse",{total:W.mapResponse.length});if(W.mapResponse.length){q+=`c.response= r
232
- `;for(let R=0;R<W.mapResponse.length;R++){let V=W.mapResponse[R],u=P.resolveChild(V.fn.name);q+=`if(mr===undefined){mr=${q4(V)?"await ":""}onMapResponse[${R}](c)
233
- if(mr!==undefined)r=c.response=mr}`,u()}}if(P.resolve(),q+=l,I6)q+=`return mapResponse(${f2}r,c.set${m0})
234
- `;else q+=`return mapCompactResponse(${f2}r${m0})
235
- `}else{F.resolve();let P=v1?`await ${G}`:G;if(R0("afterHandle").resolve(),X instanceof Response)q+=Z.set?`if(isNotEmpty(c.set.headers)||c.set.status!==200||c.set.redirect||c.set.cookie)return mapResponse(${f2}${G}.clone(),c.set${m0})
236
- else return ${G}.clone()
237
- `:`return ${G}.clone()
238
- `;else if(I6)q+=`return mapResponse(${f2}${P},c.set${m0})
239
- `;else q+=`return mapCompactResponse(${f2}${P}${m0})
240
- `}}if(q+=`
241
- }catch(error){`,W0)q+=`if(isParsing)error=new ParseError()
242
- `;if(!q6)q+="return(async()=>{";if(q+=`const set=c.set
227
+ `,t()}}if(O.resolve(),J+=o,Z instanceof Response)J+=Q.set?`if(isNotEmpty(c.set.headers)||c.set.status!==200||c.set.redirect||c.set.cookie)return mapResponse(${I2}${H}.clone(),c.set${o0})else return ${H}.clone()`:`return ${H}.clone()`,J+=`
228
+ `;else if(K6)J+=`return mapResponse(${I2}r,c.set${o0})
229
+ `;else J+=`return mapCompactResponse(${I2}r${o0})
230
+ `}else if(x||R){J+=n1?`let r=await ${H}
231
+ `:`let r=${H}
232
+ `,j.resolve(),C0("afterHandle").resolve();let O=C0("mapResponse",{total:A.mapResponse.length});if(A.mapResponse.length){J+=`c.response= r
233
+ `;for(let b=0;b<A.mapResponse.length;b++){let T=A.mapResponse[b],t=O.resolveChild(T.fn.name);J+=`if(mr===undefined){mr=${e6(T)?"await ":""}onMapResponse[${b}](c)
234
+ if(mr!==undefined)r=c.response=mr}`,t()}}if(O.resolve(),J+=o,K6)J+=`return mapResponse(${I2}r,c.set${o0})
235
+ `;else J+=`return mapCompactResponse(${I2}r${o0})
236
+ `}else{j.resolve();let O=n1?`await ${H}`:H;if(C0("afterHandle").resolve(),Z instanceof Response)J+=Q.set?`if(isNotEmpty(c.set.headers)||c.set.status!==200||c.set.redirect||c.set.cookie)return mapResponse(${I2}${H}.clone(),c.set${o0})
237
+ else return ${H}.clone()
238
+ `:`return ${H}.clone()
239
+ `;else if(K6)J+=`return mapResponse(${I2}${O},c.set${o0})
240
+ `;else J+=`return mapCompactResponse(${I2}${O}${o0})
241
+ `}}if(J+=`
242
+ }catch(error){`,A0)J+=`if(isParsing)error=new ParseError()
243
+ `;if(!Y6)J+="return(async()=>{";if(J+=`const set=c.set
243
244
  if(!set.status||set.status<300)set.status=error?.status||500
244
- `,C)for(let F=0;F<W.trace.length;F++)q+=`report${F}?.resolve(error);reportChild${F}?.(error)
245
- `;let L2=R0("error",{total:W.error.length});if(W.error.length){q+=`c.error=error
245
+ `,R)for(let j=0;j<A.trace.length;j++)J+=`report${j}?.resolve(error);reportChild${j}?.(error)
246
+ `;let q2=C0("error",{total:A.error.length});if(A.error.length){J+=`c.error=error
246
247
  if(error instanceof TypeBoxError){c.code="VALIDATION"
247
248
  c.set.status=422}else{c.code=error.code??error[ERROR_CODE]??"UNKNOWN"}let er
248
- `;for(let F=0;F<W.error.length;F++){let P=L2.resolveChild(W.error[F].fn.name);if(a0(W.error[F]))q+=`er=await handleErrors[${F}](c)
249
- `;else q+=`er=handleErrors[${F}](c)
249
+ `;for(let j=0;j<A.error.length;j++){let O=q2.resolveChild(A.error[j].fn.name);if(a0(A.error[j]))J+=`er=await handleErrors[${j}](c)
250
+ `;else J+=`er=handleErrors[${j}](c)
250
251
  if(er instanceof Promise)er=await er
251
- `;P();let R=R0("mapResponse",{total:W.mapResponse.length});if(W.mapResponse.length)for(let V=0;V<W.mapResponse.length;V++){let u=W.mapResponse[V],$0=R.resolveChild(u.fn.name);q+=`c.response=er
252
- er=onMapResponse[${V}](c)
252
+ `;O();let b=C0("mapResponse",{total:A.mapResponse.length});if(A.mapResponse.length)for(let T=0;T<A.mapResponse.length;T++){let t=A.mapResponse[T],e=b.resolveChild(t.fn.name);J+=`c.response=er
253
+ er=onMapResponse[${T}](c)
253
254
  if(er instanceof Promise)er=await er
254
- `,$0()}if(R.resolve(),q+=`er=mapEarlyResponse(er,set${m0})
255
- `,q+="if(er){",C){for(let V=0;V<W.trace.length;V++)q+=`report${V}.resolve()
256
- `;L2.resolve()}q+="return er}"}}if(L2.resolve(),q+="return handleError(c,error,true)",!q6)q+="})()";if(q+="}",O||C){if(q+="finally{ ",!q6)q+=";(async()=>{";let F=R0("afterResponse",{total:W.afterResponse.length});if(O)for(let P=0;P<W.afterResponse.length;P++){let R=F.resolveChild(W.afterResponse[P].fn.name);q+=`
257
- await afterResponse[${P}](c)
258
- `,R()}if(F.resolve(),!q6)q+="})()";q+="}"}let b2="const {handler,handleError,hooks: {transform,resolve,beforeHandle,afterHandle,mapResponse: onMapResponse,parse,error: handleErrors,afterResponse,trace: _trace},validator,utils: {mapResponse,mapCompactResponse,mapEarlyResponse,parseQuery,parseQueryFromURL,isNotEmpty},error: {NotFoundError,ValidationError,InternalServerError,ParseError},schema,definitions,ERROR_CODE,parseCookie,signCookie,decodeURIComponent,ElysiaCustomStatusResponse,ELYSIA_TRACE,ELYSIA_REQUEST_ID,parser,getServer,"+(Y.inject?Object.keys(Y.inject).join(",")+",":"")+`TypeBoxError}=hooks
255
+ `,e()}if(b.resolve(),J+=`er=mapEarlyResponse(er,set${o0})
256
+ `,J+="if(er){",R){for(let T=0;T<A.trace.length;T++)J+=`report${T}.resolve()
257
+ `;q2.resolve()}J+="return er}"}}if(q2.resolve(),J+="return handleError(c,error,true)",!Y6)J+="})()";if(J+="}",F||R){if(J+="finally{ ",!Y6)J+=";(async()=>{";let j=C0("afterResponse",{total:A.afterResponse.length});if(F)for(let O=0;O<A.afterResponse.length;O++){let b=j.resolveChild(A.afterResponse[O].fn.name);J+=`
258
+ await afterResponse[${O}](c)
259
+ `,b()}if(j.resolve(),!Y6)J+="})()";J+="}"}let x2="const {handler,handleError,hooks: {transform,resolve,beforeHandle,afterHandle,mapResponse: onMapResponse,parse,error: handleErrors,afterResponse,trace: _trace},validator,utils: {mapResponse,mapCompactResponse,mapEarlyResponse,parseQuery,parseQueryFromURL,isNotEmpty},error: {NotFoundError,ValidationError,InternalServerError,ParseError},schema,definitions,ERROR_CODE,parseCookie,signCookie,decodeURIComponent,ElysiaCustomStatusResponse,ELYSIA_TRACE,ELYSIA_REQUEST_ID,parser,getServer,"+(B.inject?Object.keys(B.inject).join(",")+",":"")+`TypeBoxError}=hooks
259
260
  const trace=_trace.map(x=>typeof x==='function'?x:x.fn)
260
- return ${q6?"async ":""}function handle(c){`;if(W.beforeHandle.length)b2+=`let be
261
- `;if(W.afterHandle.length)b2+=`let af
262
- `;if(W.mapResponse.length)b2+=`let mr
263
- `;if(Q)b2+=`c.schema = schema
261
+ return ${Y6?"async ":""}function handle(c){`;if(A.beforeHandle.length)x2+=`let be
262
+ `;if(A.afterHandle.length)x2+=`let af
263
+ `;if(A.mapResponse.length)x2+=`let mr
264
+ `;if($)x2+=`c.schema = schema
264
265
  c.defs = definitions
265
- `;b2+=q+"}";try{if(J)return Function("hooks",b2);return Function("hooks",b2)({handler:X,hooks:Uz(W),validator:$,handleError:w.handleError,utils:{mapResponse:L.mapResponse,mapCompactResponse:L.mapCompactResponse,mapEarlyResponse:L.mapEarlyResponse,parseQuery:Y4,parseQueryFromURL:ZU,isNotEmpty:Q2},error:{NotFoundError:K6,ValidationError:m,InternalServerError:sw,ParseError:rw},schema:w.router.history,definitions:w.definitions.type,ERROR_CODE:R6,parseCookie:z8,signCookie:W4,decodeURIComponent:YU.default,ElysiaCustomStatusResponse:I2,ELYSIA_TRACE:l4,ELYSIA_REQUEST_ID:C6,getServer:()=>w.getServer(),TypeBoxError:n,parser:w["~parser"],...Y.inject})}catch(F){let P=Uz(W);console.log("[Composer] failed to generate optimized handler"),console.log("---"),console.log({handler:typeof X==="function"?X.toString():X,instruction:b2,hooks:{...P,transform:P?.transform?.map?.((R)=>R.toString()),resolve:P?.resolve?.map?.((R)=>R.toString()),beforeHandle:P?.beforeHandle?.map?.((R)=>R.toString()),afterHandle:P?.afterHandle?.map?.((R)=>R.toString()),mapResponse:P?.mapResponse?.map?.((R)=>R.toString()),parse:P?.parse?.map?.((R)=>R.toString()),error:P?.error?.map?.((R)=>R.toString()),afterResponse:P?.afterResponse?.map?.((R)=>R.toString()),stop:P?.stop?.map?.((R)=>R.toString())},validator:$,definitions:w.definitions.type,error:F,fnLiteral:q}),console.log("---"),process.exit(1)}},$8=(w,{asManifest:z=!1}={})=>{let A=w["~adapter"].composeGeneralHandler,U=A.error404(!!w.event.request.length,!!w.event.error.length),W="",$=w.router,X="const route=router.find(r.method,p)";X+=$.http.root.ALL?`??router.find("ALL",p)
266
+ `;x2+=J+"}";try{if(Y)return Function("hooks",x2);return Function("hooks",x2)({handler:Z,hooks:DU(A),validator:X,handleError:w.handleError,utils:{mapResponse:G.mapResponse,mapCompactResponse:G.mapCompactResponse,mapEarlyResponse:G.mapEarlyResponse,parseQuery:x8,parseQueryFromURL:TH,isNotEmpty:s2},error:{NotFoundError:h8,ValidationError:Z0,InternalServerError:fU,ParseError:dU},schema:w.router.history,definitions:w.definitions.type,ERROR_CODE:k8,parseCookie:tU,signCookie:V8,decodeURIComponent:sU.default,ElysiaCustomStatusResponse:M1,ELYSIA_TRACE:vw,ELYSIA_REQUEST_ID:d8,getServer:()=>w.getServer(),TypeBoxError:y,parser:w["~parser"],...B.inject})}catch(j){let O=DU(A);console.log("[Composer] failed to generate optimized handler"),console.log("---"),console.log({handler:typeof Z==="function"?Z.toString():Z,instruction:x2,hooks:{...O,transform:O?.transform?.map?.((b)=>b.toString()),resolve:O?.resolve?.map?.((b)=>b.toString()),beforeHandle:O?.beforeHandle?.map?.((b)=>b.toString()),afterHandle:O?.afterHandle?.map?.((b)=>b.toString()),mapResponse:O?.mapResponse?.map?.((b)=>b.toString()),parse:O?.parse?.map?.((b)=>b.toString()),error:O?.error?.map?.((b)=>b.toString()),afterResponse:O?.afterResponse?.map?.((b)=>b.toString()),stop:O?.stop?.map?.((b)=>b.toString())},validator:X,definitions:w.definitions.type,error:j,fnLiteral:J}),console.log("---"),process.exit(1)}},Tw=(w,{asManifest:z=!1}={})=>{let U=w["~adapter"].composeGeneralHandler,W=U.error404(!!w.event.request.length,!!w.event.error.length),A="",X=w.router,Z="const route=router.find(r.method,p)";Z+=X.http.root.ALL?`??router.find("ALL",p)
266
267
  `:`
267
- `,X+=U.code,X+=`
268
+ `,Z+=W.code,Z+=`
268
269
  c.params=route.params
269
270
  if(route.store.handler)return route.store.handler(c)
270
271
  return (route.store.handler=route.store.compile())(c)
271
- `;let Q="";for(let[G,{code:O,all:C}]of Object.entries($.static.http.map)){if(Q+=`case'${G}':`,w.config.strictPath!==!0)Q+=`case'${h1(G)}':`;Q+=`switch(r.method){${O}
272
- `+(C??"default: break map")+"}"}let Z=w.event.request.some(a0),J=A.inject?Object.keys(A.inject).join(",")+",":"";if(W+=`
273
- const {app,mapEarlyResponse,NotFoundError,randomId,handleError,error,redirect,ELYSIA_TRACE,ELYSIA_REQUEST_ID,`+J+`getServer}=data
272
+ `;let $="";for(let[_,{code:H,all:F}]of Object.entries(X.static.http.map)){if($+=`case'${_}':`,w.config.strictPath!==!0)$+=`case'${r6(_)}':`;$+=`switch(r.method){${H}
273
+ `+(F??"default: break map")+"}"}let Q=w.event.request.some(a0),Y=U.inject?Object.keys(U.inject).join(",")+",":"";if(A+=`
274
+ const {app,mapEarlyResponse,NotFoundError,randomId,handleError,error,redirect,ELYSIA_TRACE,ELYSIA_REQUEST_ID,`+Y+`getServer}=data
274
275
  const store=app.singleton.store
275
276
  const decorator=app.singleton.decorator
276
277
  const staticRouter=app.router.static.http
@@ -280,43 +281,43 @@ const router=app.router.http
280
281
  const trace=app.event.trace.map(x=>typeof x==='function'?x:x.fn)
281
282
  const notFound=new NotFoundError()
282
283
  const hoc=app.extender.higherOrderFunctions.map(x=>x.fn)
283
- `,w.event.request.length)W+=`const onRequest=app.event.request.map(x=>x.fn)
284
- `;if(W+=U.declare,w.event.trace.length)W+="const "+w.event.trace.map((G,O)=>`tr${O}=app.event.trace[${O}].fn`).join(",")+`
285
- `;if(W+=`${Z?"async ":""}function map(${A.parameters}){`,w.event.request.length)W+=`let re
286
- `;if(W+=A.createContext(w),w.event.trace.length)W+="c[ELYSIA_TRACE]=["+w.event.trace.map((G,O)=>`tr${O}(c)`).join(",")+`]
287
- `;let L=Bz({trace:w.event.trace,addFn(G){W+=G}})("request",{total:w.event.request.length});if(w.event.request.length){W+="try{";for(let G=0;G<w.event.request.length;G++){let O=w.event.request[G],C=$4(O),q=a0(O),o=L.resolveChild(w.event.request[G].fn.name);if(C)W+=`re=mapEarlyResponse(${q?"await ":""}onRequest[${G}](c),c.set)
288
- `,o("re"),W+=`if(re!==undefined)return re
289
- `;else W+=`${q?"await ":""}onRequest[${G}](c)
290
- `,o()}W+="}catch(error){return app.handleError(c,error,false)}"}if(L.resolve(),W+=A.websocket(w),W+=`
284
+ `,w.event.request.length)A+=`const onRequest=app.event.request.map(x=>x.fn)
285
+ `;if(A+=W.declare,w.event.trace.length)A+="const "+w.event.trace.map((_,H)=>`tr${H}=app.event.trace[${H}].fn`).join(",")+`
286
+ `;if(A+=`${Q?"async ":""}function map(${U.parameters}){`,w.event.request.length)A+=`let re
287
+ `;if(A+=U.createContext(w),w.event.trace.length)A+="c[ELYSIA_TRACE]=["+w.event.trace.map((_,H)=>`tr${H}(c)`).join(",")+`]
288
+ `;let B=nw({trace:w.event.trace,addFn(_){A+=_}})("request",{total:w.event.request.length});if(w.event.request.length){A+="try{";for(let _=0;_<w.event.request.length;_++){let H=w.event.request[_],F=T4(H),R=a0(H),J=B.resolveChild(w.event.request[_].fn.name);if(F)A+=`re=mapEarlyResponse(${R?"await ":""}onRequest[${_}](c),c.set)
289
+ `,J("re"),A+=`if(re!==undefined)return re
290
+ `;else A+=`${R?"await ":""}onRequest[${_}](c)
291
+ `,J()}A+="}catch(error){return app.handleError(c,error,false)}"}if(B.resolve(),A+=U.websocket(w),A+=`
291
292
  map:switch(p){
292
- `+Q+"default:break}"+X+`}
293
- `,w.extender.higherOrderFunctions.length){let G="map";for(let O=0;O<w.extender.higherOrderFunctions.length;O++)G=`hoc[${O}](${G},${A.parameters})`;W+=`return function hocMap(${A.parameters}){return ${G}(${A.parameters})}`}else W+="return map";let _=Mz(w);return w.handleError=_,Function("data",W)({app:w,mapEarlyResponse:w["~adapter"].handler.mapEarlyResponse,NotFoundError:K6,randomId:pw,handleError:_,error:Wz,redirect:o4,ELYSIA_TRACE:l4,ELYSIA_REQUEST_ID:C6,getServer:()=>w.getServer(),...A.inject})},Mz=(w)=>{let z=w.event,A="",U=w["~adapter"].composeError,W=U.inject?Object.keys(U.inject).join(",")+",":"";A+="const {app:{event:{error:onErrorContainer,afterResponse:resContainer,mapResponse:_onMapResponse,trace:_trace}},mapResponse,ERROR_CODE,ElysiaCustomStatusResponse,ELYSIA_TRACE,"+W+`ELYSIA_REQUEST_ID}=inject
294
- `,A+=`const trace=_trace.map(x=>typeof x==='function'?x:x.fn)
293
+ `+$+"default:break}"+Z+`}
294
+ `,w.extender.higherOrderFunctions.length){let _="map";for(let H=0;H<w.extender.higherOrderFunctions.length;H++)_=`hoc[${H}](${_},${U.parameters})`;A+=`return function hocMap(${U.parameters}){return ${_}(${U.parameters})}`}else A+="return map";let G=rU(w);return w.handleError=G,Function("data",A)({app:w,mapEarlyResponse:w["~adapter"].handler.mapEarlyResponse,NotFoundError:h8,randomId:gU,handleError:G,error:LH,redirect:TU,ELYSIA_TRACE:vw,ELYSIA_REQUEST_ID:d8,getServer:()=>w.getServer(),...U.inject})},rU=(w)=>{let z=w.event,U="",W=w["~adapter"].composeError,A=W.inject?Object.keys(W.inject).join(",")+",":"";U+="const {app:{event:{error:onErrorContainer,afterResponse:resContainer,mapResponse:_onMapResponse,trace:_trace}},mapResponse,ERROR_CODE,ElysiaCustomStatusResponse,ELYSIA_TRACE,"+A+`ELYSIA_REQUEST_ID}=inject
295
+ `,U+=`const trace=_trace.map(x=>typeof x==='function'?x:x.fn)
295
296
  const onMapResponse=[]
296
297
  for(let i=0;i<_onMapResponse.length;i++)onMapResponse.push(_onMapResponse[i].fn??_onMapResponse[i])
297
298
  delete _onMapResponse
298
299
  const onError=onErrorContainer.map(x=>x.fn)
299
300
  const res=resContainer.map(x=>x.fn)
300
- return ${w.event.error.find(a0)||w.event.mapResponse.find(a0)?"async ":""}function(context,error,skipGlobal){`;let $=w.event.trace.length>0;if(A+="",$)A+=`const id=context[ELYSIA_REQUEST_ID]
301
- `;let X=Bz({context:"context",trace:z.trace,addFn:(J)=>{A+=J}});if(A+=`const set=context.set
301
+ return ${w.event.error.find(a0)||w.event.mapResponse.find(a0)?"async ":""}function(context,error,skipGlobal){`;let X=w.event.trace.length>0;if(U+="",X)U+=`const id=context[ELYSIA_REQUEST_ID]
302
+ `;let Z=nw({context:"context",trace:z.trace,addFn:(Y)=>{U+=Y}});if(U+=`const set=context.set
302
303
  let _r
303
304
  if(!context.code)context.code=error.code??error[ERROR_CODE]
304
305
  if(!(context.error instanceof Error))context.error=error
305
306
  if(error instanceof ElysiaCustomStatusResponse){set.status=error.status=error.code
306
- error.message=error.response}`,U.declare)A+=U.declare;let Q=$||z.afterResponse.length>0||z.afterResponse.length>0?"context.response = ":"";for(let J=0;J<w.event.error.length;J++){let Y=w.event.error[J],L=`${a0(Y)?"await ":""}onError[${J}](context)
307
- `;if(A+="if(skipGlobal!==true){",$4(Y)){A+=`_r=${L}
308
- if(_r!==undefined){if(_r instanceof Response)return mapResponse(_r,set${U.mapResponseContext})
307
+ error.message=error.response}`,W.declare)U+=W.declare;let $=X||z.afterResponse.length>0||z.afterResponse.length>0?"context.response = ":"";for(let Y=0;Y<w.event.error.length;Y++){let B=w.event.error[Y],G=`${a0(B)?"await ":""}onError[${Y}](context)
308
+ `;if(U+="if(skipGlobal!==true){",T4(B)){U+=`_r=${G}
309
+ if(_r!==undefined){if(_r instanceof Response)return mapResponse(_r,set${W.mapResponseContext})
309
310
  if(_r instanceof ElysiaCustomStatusResponse){error.status=error.code
310
311
  error.message = error.response}if(set.status===200||!set.status)set.status=error.status
311
- `;let _=X("mapResponse",{total:z.mapResponse.length,name:"context"});if(z.mapResponse.length)for(let G=0;G<z.mapResponse.length;G++){let O=z.mapResponse[G],C=_.resolveChild(O.fn.name);A+=`context.response=_r_r=${q4(O)?"await ":""}onMapResponse[${G}](context)
312
- `,C()}_.resolve(),A+=`return mapResponse(${Q}_r,set${U.mapResponseContext})}`}else A+=L;A+="}"}A+=`if(error.constructor.name==="ValidationError"||error.constructor.name==="TransformDecodeError"){if(error.error)error=error.error
312
+ `;let _=Z("mapResponse",{total:z.mapResponse.length,name:"context"});if(z.mapResponse.length)for(let H=0;H<z.mapResponse.length;H++){let F=z.mapResponse[H],R=_.resolveChild(F.fn.name);U+=`context.response=_r_r=${e6(F)?"await ":""}onMapResponse[${H}](context)
313
+ `,R()}_.resolve(),U+=`return mapResponse(${$}_r,set${W.mapResponseContext})}`}else U+=G;U+="}"}U+=`if(error.constructor.name==="ValidationError"||error.constructor.name==="TransformDecodeError"){if(error.error)error=error.error
313
314
  set.status=error.status??422
314
- `+U.validationError+"}",A+="if(error instanceof Error){"+U.unknownError+"}";let Z=X("mapResponse",{total:z.mapResponse.length,name:"context"});if(A+=`
315
+ `+W.validationError+"}",U+="if(error instanceof Error){"+W.unknownError+"}";let Q=Z("mapResponse",{total:z.mapResponse.length,name:"context"});if(U+=`
315
316
  if(!context.response)context.response=error.message??error
316
- `,z.mapResponse.length){A+=`let mr
317
- `;for(let J=0;J<z.mapResponse.length;J++){let Y=z.mapResponse[J],L=Z.resolveChild(Y.fn.name);A+=`if(mr===undefined){mr=${q4(Y)?"await ":""}onMapResponse[${J}](context)
318
- if(mr!==undefined)error=context.response=mr}`,L()}}return Z.resolve(),A+=`
319
- return mapResponse(${Q}error,set${U.mapResponseContext})}`,Function("inject",A)({app:w,mapResponse:w["~adapter"].handler.mapResponse,ERROR_CODE:R6,ElysiaCustomStatusResponse:I2,ELYSIA_TRACE:l4,ELYSIA_REQUEST_ID:C6,...U.inject})};var Hz=(w,z)=>{for(let[A,U]of Object.entries(w.schema.properties))z[A]??=U.default},Gz=(w)=>{let{mapResponse:z,mapEarlyResponse:A}=w["~adapter"].handler;return async(U)=>{let W=U.url,$=W.indexOf("/",11),X=W.indexOf("?",$+1),Q=X===-1?W.substring($):W.substring($,X),Z={cookie:{},status:200,headers:{}},J=Object.assign({},w.singleton.decorator,{set:Z,store:w.singleton.store,request:U,path:Q,qi:X,redirect:o4});try{for(let f=0;f<w.event.request.length;f++){let t=w.event.request[f].fn,K=t(J);if(K instanceof Promise)K=await K;if(K=A(K,Z),K)return J.response=K}let Y=w.router.dynamic.find(U.method,Q)??w.router.dynamic.find("ALL",Q);if(!Y)throw new K6;let{handle:L,hooks:_,validator:G,content:O}=Y.store,C;if(U.method!=="GET"&&U.method!=="HEAD")if(O)switch(O){case"application/json":C=await U.json();break;case"text/plain":C=await U.text();break;case"application/x-www-form-urlencoded":C=Y4(await U.text());break;case"application/octet-stream":C=await U.arrayBuffer();break;case"multipart/form-data":C={};let f=await U.formData();for(let t of f.keys()){if(C[t])continue;let K=f.getAll(t);if(K.length===1)C[t]=K[0];else C[t]=K}break}else{let f=U.headers.get("content-type");if(f){let t=f.indexOf(";");if(t!==-1)f=f.slice(0,t);J.contentType=f;for(let K=0;K<_.parse.length;K++){let l=_.parse[K].fn,D0=l(J,f);if(D0 instanceof Promise)D0=await D0;if(D0){C=D0;break}}if(delete J.contentType,C===void 0)switch(f){case"application/json":C=await U.json();break;case"text/plain":C=await U.text();break;case"application/x-www-form-urlencoded":C=Y4(await U.text());break;case"application/octet-stream":C=await U.arrayBuffer();break;case"multipart/form-data":C={};let K=await U.formData();for(let l of K.keys()){if(C[l])continue;let D0=K.getAll(l);if(D0.length===1)C[l]=D0[0];else C[l]=D0}break}}}J.body=C,J.params=Y?.params||void 0,J.query=X===-1?{}:Y4(W.substring(X+1)),J.headers={};for(let[f,t]of U.headers.entries())J.headers[f]=t;let q=Object.assign({},w.config?.cookie,G?.cookie?.config),o=U.headers.get("cookie");J.cookie=await z8(J.set,o,q?{secrets:q.secrets!==void 0?typeof q.secrets==="string"?q.secrets:q.secrets.join(","):void 0,sign:q.sign===!0?!0:q.sign!==void 0?typeof q.sign==="string"?q.sign:q.sign.join(","):void 0}:void 0);let W0=G?.createHeaders?.();if(W0)Hz(W0,J.headers);let L0=G?.createParams?.();if(L0)Hz(L0,J.params);let c=G?.createQuery?.();if(c)Hz(c,J.query);for(let f=0;f<_.transform.length;f++){let t=_.transform[f],K=t.fn(J);if(t.subType==="derive")if(K instanceof Promise)Object.assign(J,await K);else Object.assign(J,K);else if(K instanceof Promise)await K}if(G){if(W0){let f=structuredClone(J.headers);for(let[t,K]of U.headers)f[t]=K;if(G.headers.Check(f)===!1)throw new m("header",G.headers,f)}else if(G.headers?.Decode)J.headers=G.headers.Decode(J.headers);if(L0?.Check(J.params)===!1)throw new m("params",G.params,J.params);else if(G.params?.Decode)J.params=G.params.Decode(J.params);if(c?.Check(J.query)===!1)throw new m("query",G.query,J.query);else if(G.query?.Decode)J.query=G.query.Decode(J.query);if(G.createCookie?.()){let f={};for(let[t,K]of Object.entries(J.cookie))f[t]=K.value;if(G.cookie.Check(f)===!1)throw new m("cookie",G.cookie,f);else if(G.cookie?.Decode)f=G.cookie.Decode(f)}if(G.createBody?.()?.Check(C)===!1)throw new m("body",G.body,C);else if(G.body?.Decode)J.body=G.body.Decode(C)}for(let f=0;f<_.beforeHandle.length;f++){let t=_.beforeHandle[f],K=t.fn(J);if(t.subType==="resolve"){if(K instanceof I2){let l=A(K,J.set);if(l)return J.response=l}if(K instanceof Promise)Object.assign(J,await K);else Object.assign(J,K);continue}else if(K instanceof Promise)K=await K;if(K!==void 0){J.response=K;for(let D0=0;D0<_.afterHandle.length;D0++){let s=_.afterHandle[D0].fn(J);if(s instanceof Promise)s=await s;if(s)K=s}let l=A(K,J.set);if(l)return J.response=l}}let e=typeof L==="function"?L(J):L;if(e instanceof Promise)e=await e;if(!_.afterHandle.length){let f=e instanceof I2?e.code:Z.status?typeof Z.status==="string"?U6[Z.status]:Z.status:200,t=G?.createResponse?.()?.[f];if(t?.Check(e)===!1)throw new m("response",t,e);else if(t?.Decode)e=t.Decode(e)}else{J.response=e;for(let f=0;f<_.afterHandle.length;f++){let t=_.afterHandle[f].fn(J);if(t instanceof Promise)t=await t;let K=A(t,J.set);if(K!==void 0){let l=G?.response?.[K.status];if(l?.Check(K)===!1)throw new m("response",l,K);else if(l?.Decode)e=l.Decode(e);return J.response=K}}}if(J.set.cookie&&q?.sign){let f=!q.secrets?void 0:typeof q.secrets==="string"?q.secrets:q.secrets[0];if(q.sign===!0)for(let[t,K]of Object.entries(J.set.cookie))J.set.cookie[t].value=await W4(K.value,"${secret}");else{let t=G?.cookie?.schema?.properties;for(let K of q.sign){if(!(K in t))continue;if(J.set.cookie[K]?.value)J.set.cookie[K].value=await W4(J.set.cookie[K].value,f)}}}return z(J.response=e,J.set)}catch(Y){let L=Y instanceof fw&&Y.error?Y.error:Y;return w.handleError(J,L)}finally{for(let Y of w.event.afterResponse)await Y.fn(J)}}},BU=(w)=>{let{mapResponse:z}=w["~adapter"].handler;return async(A,U)=>{let W=Object.assign(A,{error:U,code:U.code});W.set=A.set;for(let $=0;$<w.event.error.length;$++){let Q=w.event.error[$].fn(W);if(Q instanceof Promise)Q=await Q;if(Q!==void 0&&Q!==null)return A.response=z(Q,A.set)}return new Response(typeof U.cause==="string"?U.cause:U.message,{headers:A.set.headers,status:U.status??500})}};class F0{constructor(w={}){if(this.server=null,this.dependencies={},this._routes={},this._types={Prefix:"",Singleton:{},Definitions:{},Metadata:{}},this._ephemeral={},this._volatile={},this.singleton={decorator:{},store:{},derive:{},resolve:{}},this.definitions={typebox:x.Module({}),type:{},error:{}},this.extender={macros:[],higherOrderFunctions:[]},this.validator={global:null,scoped:null,local:null,getCandidate(){return U4(U4(this.global,this.scoped),this.local)}},this.event={start:[],request:[],parse:[],transform:[],beforeHandle:[],afterHandle:[],mapResponse:[],afterResponse:[],trace:[],error:[],stop:[]},this.telemetry={stack:void 0},this.router={http:new $w,ws:new $w,dynamic:new $w,static:{http:{static:{},map:{},all:""},ws:{}},history:[]},this.routeTree=new Map,this.inference={body:!1,cookie:!1,headers:!1,query:!1,set:!1,server:!1,request:!1,route:!1},this["~parser"]={},this.handle=async(z)=>this.fetch(z),this.fetch=(z)=>{return(this.fetch=this.config.aot?$8(this):Gz(this))(z)},this.handleError=async(z,A)=>{return(this.handleError=this.config.aot?Mz(this):BU(this))(z,A)},this.outerErrorHandler=(z)=>new Response(z.message||z.name||"Error",{status:z?.status??500}),this.listen=(z,A)=>{return this["~adapter"].listen(this)(z,A),this},this.stop=async(z)=>{if(!this.server)throw new Error("Elysia isn't running. Call `app.listen` to start the server.");if(this.server){if(this.server.stop(z),this.server=null,this.event.stop.length)for(let A=0;A<this.event.stop.length;A++)this.event.stop[A].fn(this)}},w.tags)if(!w.detail)w.detail={tags:w.tags};else w.detail.tags=w.tags;if(w.nativeStaticResponse===void 0)w.nativeStaticResponse=!0;if(this.config={},this.applyConfig(w??{}),this["~adapter"]=w.adapter??(typeof Bun!=="undefined"?QU:Q4),w?.analytic&&(w?.name||w?.seed!==void 0))this.telemetry.stack=new Error().stack}get store(){return this.singleton.store}get decorator(){return this.singleton.decorator}get routes(){return this.router.history}getGlobalRoutes(){return this.router.history}getServer(){return this.server}get promisedModules(){if(!this._promisedModules)this._promisedModules=new Az;return this._promisedModules}env(w,z=U8){if($2(w,{modules:this.definitions.typebox,dynamic:!0,additionalProperties:!0,coerce:!0}).Check(z)===!1){let U=new m("env",w,z);throw new Error(U.all.map((W)=>W.summary).join(`
320
- `))}return this}wrap(w){return this.extender.higherOrderFunctions.push({checksum:O6(JSON.stringify({name:this.config.name,seed:this.config.seed,content:w.toString()})),fn:w}),this}applyMacro(w){if(this.extender.macros.length){let z=iA({globalHook:this.event,localHook:w}),A={events:{global:this.event,local:w},get onParse(){return z("parse")},get onTransform(){return z("transform")},get onBeforeHandle(){return z("beforeHandle")},get onAfterHandle(){return z("afterHandle")},get mapResponse(){return z("mapResponse")},get onAfterResponse(){return z("afterResponse")},get onError(){return z("error")}};for(let U of this.extender.macros)TA(U.fn(A),w,z)}}applyConfig(w){return this.config={prefix:"",aot:U8.ELYSIA_AOT!=="false",normalize:!0,...w,cookie:{path:"/",...w?.cookie},experimental:w?.experimental??{},seed:w?.seed===void 0?"":w?.seed},this}get models(){let w={};for(let z of Object.keys(this.definitions.type))w[z]=$2(this.definitions.typebox.Import(z));return w.modules=this.definitions.typebox,w}add(w,z,A,U,{allowMeta:W=!1,skipPrefix:$=!1}={allowMeta:!1,skipPrefix:!1}){if(U=dA(U),z!==""&&z.charCodeAt(0)!==47)z="/"+z;if(this.config.prefix&&!$)z=this.config.prefix+z;if(U?.type)switch(U.type){case"text":U.type="text/plain";break;case"json":U.type="application/json";break;case"formdata":U.type="multipart/form-data";break;case"urlencoded":U.type="application/x-www-form-urlencoded";break;case"arrayBuffer":U.type="application/octet-stream";break;default:break}let X=this.definitions.type,Q=!this.config.aot,Z={...this.validator.getCandidate()},J={body:U?.body??Z?.body,headers:U?.headers??Z?.headers,params:U?.params??Z?.params,query:U?.query??Z?.query,cookie:U?.cookie??Z?.cookie,response:U?.response??Z?.response},Y=()=>J.cookie?uw({modules:_,validator:J.cookie,defaultConfig:this.config.cookie,config:J.cookie?.config??{},dynamic:Q,models:X}):void 0,L=this.config.normalize,_=this.definitions.typebox,G=this.config.precompile===!0||typeof this.config.precompile==="object"&&this.config.precompile.schema===!0?{body:$2(J.body,{modules:_,dynamic:Q,models:X,normalize:L,additionalCoerce:a5()}),headers:$2(J.headers,{modules:_,dynamic:Q,models:X,additionalProperties:!this.config.normalize,coerce:!0,additionalCoerce:A6()}),params:$2(J.params,{modules:_,dynamic:Q,models:X,coerce:!0,additionalCoerce:A6()}),query:$2(J.query,{modules:_,dynamic:Q,models:X,normalize:L,coerce:!0,additionalCoerce:A6()}),cookie:Y(),response:ow(J.response,{modules:_,dynamic:Q,models:X,normalize:L})}:{createBody(){if(this.body)return this.body;return this.body=$2(J.body,{modules:_,dynamic:Q,models:X,normalize:L,additionalCoerce:a5()})},createHeaders(){if(this.headers)return this.headers;return this.headers=$2(J.headers,{modules:_,dynamic:Q,models:X,additionalProperties:!L,coerce:!0,additionalCoerce:A6()})},createParams(){if(this.params)return this.params;return this.params=$2(J.params,{modules:_,dynamic:Q,models:X,coerce:!0,additionalCoerce:A6()})},createQuery(){if(this.query)return this.query;return this.query=$2(J.query,{modules:_,dynamic:Q,models:X,coerce:!0,additionalCoerce:A6()})},createCookie(){if(this.cookie)return this.cookie;return this.cookie=Y()},createResponse(){if(this.response)return this.response;return this.response=ow(J.response,{modules:_,dynamic:Q,models:X,normalize:L})}};if(U=r2(U,Z),U.tags)if(!U.detail)U.detail={tags:U.tags};else U.detail.tags=U.tags;if(Q2(this.config.detail))U.detail=_2(Object.assign({},this.config.detail),U.detail);this.applyMacro(U);let O=r2(this.event,U);if(this.config.aot===!1){if(this.router.dynamic.add(w,z,{validator:G,hooks:O,content:U?.type,handle:A}),this.config.strictPath===!1)this.router.dynamic.add(w,h1(z),{validator:G,hooks:O,content:U?.type,handle:A});this.router.history.push({method:w,path:z,composed:null,handler:A,hooks:O,compile:A});return}let C=this.config.precompile===!0||typeof this.config.precompile==="object"&&this.config.precompile.compose===!0,q=v4(this.inference),o=this["~adapter"].handler,W0=typeof A!=="function"&&typeof o.createStaticHandler==="function"?o.createStaticHandler(A,O,this.setHeaders):void 0,L0=typeof A!=="function"?o.createNativeStaticHandler?.(A,O,this.setHeaders):void 0;if(this.config.nativeStaticResponse===!0&&L0&&(w==="GET"||w==="ALL"))this.router.static.http.static[z]=L0();let c=(s=!1)=>qU({app:this,path:z,method:w,localHook:r2(U),hooks:O,validator:G,handler:typeof A!=="function"&&typeof o.createStaticHandler!=="function"?()=>A:A,allowMeta:W,inference:q,asManifest:s});if(this.routeTree.has(w+z))for(let s=0;s<this.router.history.length;s++){let P1=this.router.history[s];if(P1.path===z&&P1.method===w){let R0=this.router.history.splice(s,1)[0];if(R0&&this.routeTree.has(R0?.method+R0?.path))this.routeTree.delete(R0.method+R0.path)}}else this.routeTree.set(w+z,this.router.history.length);let e=this.router.history,f=this.router.history.length,t=C?c():(s)=>(e[f].composed=c())(s),K=w==="$INTERNALWS";this.router.history.push({method:w,path:z,composed:t,handler:A,hooks:O,compile:()=>c(),websocket:U.websocket});let l=this.router.static.http,D0={handler:C?t:void 0,compile:c};if(K){let s=h1(z);if(z.indexOf(":")===-1&&z.indexOf("*")===-1)this.router.static.ws[z]=f;else if(this.router.ws.add("ws",z,D0),s)this.router.ws.add("ws",s,D0);return}if(z.indexOf(":")===-1&&z.indexOf("*")===-1){if(!l.map[z])l.map[z]={code:""};let s=W0?"":"c";if(w==="ALL")l.map[z].all=`default:return ht[${f}].composed(${s})
321
- `;else l.map[z].code=`case '${w}':return ht[${f}].composed(${s})
322
- ${l.map[z].code}`;if(!this.config.strictPath&&this.config.nativeStaticResponse===!0&&L0&&(w==="GET"||w==="ALL"))this.router.static.http.static[h1(z)]=L0()}else if(this.router.http.add(w,z,D0),!this.config.strictPath){let s=h1(z);if(this.config.nativeStaticResponse===!0&&W0&&(w==="GET"||w==="ALL"))this.router.static.http.static[s]=W0();this.router.http.add(w,s,D0)}}headers(w){if(!w)return this;if(!this.setHeaders)this.setHeaders={};return this.setHeaders=_2(this.setHeaders,w),this}onStart(w){return this.on("start",w),this}onRequest(w){return this.on("request",w),this}onParse(w,z){if(!z){if(typeof w==="string")return this.on("parse",this["~parser"][w]);return this.on("parse",w)}return this.on(w,"parse",z)}parser(w,z){return this["~parser"][w]=z,this}onTransform(w,z){if(!z)return this.on("transform",w);return this.on(w,"transform",z)}resolve(w,z){if(!z)z=w,w={as:"local"};let A={subType:"resolve",fn:z};return this.onBeforeHandle(w,A)}mapResolve(w,z){if(!z)z=w,w={as:"local"};let A={subType:"mapResolve",fn:z};return this.onBeforeHandle(w,A)}onBeforeHandle(w,z){if(!z)return this.on("beforeHandle",w);return this.on(w,"beforeHandle",z)}onAfterHandle(w,z){if(!z)return this.on("afterHandle",w);return this.on(w,"afterHandle",z)}mapResponse(w,z){if(!z)return this.on("mapResponse",w);return this.on(w,"mapResponse",z)}onAfterResponse(w,z){if(!z)return this.on("afterResponse",w);return this.on(w,"afterResponse",z)}trace(w,z){if(!z)z=w,w={as:"local"};if(!Array.isArray(z))z=[z];for(let A of z)this.on(w,"trace",JU(A));return this}error(w,z){switch(typeof w){case"string":return z.prototype[R6]=w,this.definitions.error[w]=z,this;case"function":return this.definitions.error=w(this.definitions.error),this}for(let[A,U]of Object.entries(w))U.prototype[R6]=A,this.definitions.error[A]=U;return this}onError(w,z){if(!z)return this.on("error",w);return this.on(w,"error",z)}onStop(w){return this.on("stop",w),this}on(w,z,A){let U;switch(typeof w){case"string":U=w,A=z;break;case"object":if(U=z,!Array.isArray(z)&&typeof z==="object")A=z;break}if(Array.isArray(A))A=r0(A);else if(typeof A==="function")A=[{fn:A}];else A=[A];let W=A;for(let $ of W)if($.scope=typeof w==="string"?"local":w?.as??"local",U==="resolve"||U==="derive")$.subType=U;if(U!=="trace")aw({[U]:W.map(($)=>$.fn)},this.inference);for(let $ of W){let X=gA($,"global",{skipIfHasType:!0});switch(U){case"start":this.event.start.push(X);break;case"request":this.event.request.push(X);break;case"parse":this.event.parse.push(X);break;case"transform":this.event.transform.push(X);break;case"derive":this.event.transform.push(r0(X,"derive"));break;case"beforeHandle":this.event.beforeHandle.push(X);break;case"resolve":this.event.beforeHandle.push(r0(X,"resolve"));break;case"afterHandle":this.event.afterHandle.push(X);break;case"mapResponse":this.event.mapResponse.push(X);break;case"afterResponse":this.event.afterResponse.push(X);break;case"trace":this.event.trace.push(X);break;case"error":this.event.error.push(X);break;case"stop":this.event.stop.push(X);break}}return this}propagate(){return X2(this.event.parse),X2(this.event.transform),X2(this.event.beforeHandle),X2(this.event.afterHandle),X2(this.event.mapResponse),X2(this.event.afterResponse),X2(this.event.trace),X2(this.event.error),this}as(w){let z={plugin:"scoped",scoped:"scoped",global:"global"}[w];if(X2(this.event.parse,z),X2(this.event.transform,z),X2(this.event.beforeHandle,z),X2(this.event.afterHandle,z),X2(this.event.mapResponse,z),X2(this.event.afterResponse,z),X2(this.event.trace,z),X2(this.event.error,z),w==="plugin")this.validator.scoped=U4(this.validator.scoped,this.validator.local),this.validator.local=null;else if(w==="global")this.validator.global=U4(this.validator.global,U4(this.validator.scoped,this.validator.local)),this.validator.scoped=null,this.validator.local=null;return this}group(w,z,A){let U=new F0({...this.config,prefix:""});U.singleton={...this.singleton},U.definitions={...this.definitions},U.getServer=()=>this.getServer(),U.inference=v4(this.inference),U.extender={...this.extender};let W=typeof z==="object",$=(W?A:z)(U);if(this.singleton=_2(this.singleton,U.singleton),this.definitions=_2(this.definitions,U.definitions),$.event.request.length)this.event.request=[...this.event.request||[],...$.event.request||[]];if($.event.mapResponse.length)this.event.mapResponse=[...this.event.mapResponse||[],...$.event.mapResponse||[]];return this.model($.definitions.type),Object.values(U.router.history).forEach(({method:X,path:Q,handler:Z,hooks:J})=>{if(Q=(W?"":this.config.prefix)+w+Q,W){let Y=z,L=J;this.add(X,Q,Z,r2(Y,{...L||{},error:!L.error?$.event.error:Array.isArray(L.error)?[...L.error||{},...$.event.error||{}]:[L.error,...$.event.error||{}]}))}else this.add(X,Q,Z,r2(J,{error:$.event.error}),{skipPrefix:!0})}),this}guard(w,z){if(!z){if(typeof w==="object"){this.applyMacro(w);let W=w.as??"local";if(this.validator[W]={body:w.body??this.validator[W]?.body,headers:w.headers??this.validator[W]?.headers,params:w.params??this.validator[W]?.params,query:w.query??this.validator[W]?.query,response:w.response??this.validator[W]?.response,cookie:w.cookie??this.validator[W]?.cookie},w.parse)this.on({as:W},"parse",w.parse);if(w.transform)this.on({as:W},"transform",w.transform);if(w.derive)this.on({as:W},"derive",w.derive);if(w.beforeHandle)this.on({as:W},"beforeHandle",w.beforeHandle);if(w.resolve)this.on({as:W},"resolve",w.resolve);if(w.afterHandle)this.on({as:W},"afterHandle",w.afterHandle);if(w.mapResponse)this.on({as:W},"mapResponse",w.mapResponse);if(w.afterResponse)this.on({as:W},"afterResponse",w.afterResponse);if(w.error)this.on({as:W},"error",w.error);if(w.detail)if(this.config.detail)this.config.detail=_2(Object.assign({},this.config.detail),w.detail);else this.config.detail=w.detail;if(w?.tags)if(!this.config.detail)this.config.detail={tags:w.tags};else this.config.detail.tags=w.tags;return this}return this.guard({},w)}let A=new F0({...this.config,prefix:""});A.singleton={...this.singleton},A.definitions={...this.definitions},A.inference=v4(this.inference),A.extender={...this.extender};let U=z(A);if(this.singleton=_2(this.singleton,A.singleton),this.definitions=_2(this.definitions,A.definitions),U.getServer=()=>this.server,U.event.request.length)this.event.request=[...this.event.request||[],...U.event.request||[]];if(U.event.mapResponse.length)this.event.mapResponse=[...this.event.mapResponse||[],...U.event.mapResponse||[]];return this.model(U.definitions.type),Object.values(A.router.history).forEach(({method:W,path:$,handler:X,hooks:Q})=>{this.add(W,$,X,r2(w,{...Q||{},error:!Q.error?U.event.error:Array.isArray(Q.error)?[...Q.error||{},...U.event.error||[]]:[Q.error,...U.event.error||[]]}))}),this}use(w,z){if(Array.isArray(w)){let A=this;for(let U of w)A=A.use(U);return A}if(z?.scoped)return this.guard({},(A)=>A.use(w));if(Array.isArray(w)){let A=this;for(let U of w)A=this.use(U);return A}if(w instanceof Promise)return this.promisedModules.add(w.then((A)=>{if(typeof A==="function")return A(this);if(A instanceof F0)return this._use(A).compile();if(A.constructor.name==="Elysia")return this._use(A).compile();if(typeof A.default==="function")return A.default(this);if(A.default instanceof F0)return this._use(A.default);if(A.constructor.name==="Elysia")return this._use(A.default);throw new Error('Invalid plugin type. Expected Elysia instance, function, or module with "default" as Elysia instance or function that returns Elysia instance.')}).then((A)=>A.compile())),this;return this._use(w)}_use(w){if(typeof w==="function"){let W=w(this);if(W instanceof Promise)return this.promisedModules.add(W.then(($)=>{if($ instanceof F0){$.getServer=()=>this.getServer(),$.getGlobalRoutes=()=>this.getGlobalRoutes(),$.model(this.definitions.type),$.error(this.definitions.error);for(let{method:X,path:Q,handler:Z,hooks:J}of Object.values($.router.history))this.add(X,Q,Z,r2(J,{error:$.event.error}));return $.compile(),$}if(typeof $==="function")return $(this);if(typeof $.default==="function")return $.default(this);return this._use($)}).then(($)=>$.compile())),this;return W}let{name:z,seed:A}=w.config;if(w.getServer=()=>this.getServer(),w.getGlobalRoutes=()=>this.getGlobalRoutes(),w.model(this.definitions.type),w.error(this.definitions.error),this["~parser"]={...w["~parser"],...this["~parser"]},this.headers(w.setHeaders),z){if(!(z in this.dependencies))this.dependencies[z]=[];let W=A!==void 0?O6(z+JSON.stringify(A)):0;if(!this.dependencies[z].some(({checksum:$})=>W===$))this.extender.macros=this.extender.macros.concat(w.extender.macros),this.extender.higherOrderFunctions=this.extender.higherOrderFunctions.concat(w.extender.higherOrderFunctions)}else this.extender.macros=this.extender.macros.concat(w.extender.macros),this.extender.higherOrderFunctions=this.extender.higherOrderFunctions.concat(w.extender.higherOrderFunctions);lw(this.extender.macros),lw(this.extender.higherOrderFunctions);let U=[];for(let W=0;W<this.extender.higherOrderFunctions.length;W++){let $=this.extender.higherOrderFunctions[W];if($.checksum){if(U.includes($.checksum))this.extender.higherOrderFunctions.splice(W,1),W--;U.push($.checksum)}}this.inference={body:this.inference.body||w.inference.body,cookie:this.inference.cookie||w.inference.cookie,headers:this.inference.headers||w.inference.headers,query:this.inference.query||w.inference.query,set:this.inference.set||w.inference.set,server:this.inference.server||w.inference.server,request:this.inference.request||w.inference.request,route:this.inference.route||w.inference.route},this.decorate(w.singleton.decorator),this.state(w.singleton.store),this.model(w.definitions.type),this.error(w.definitions.error),w.extender.macros=this.extender.macros.concat(w.extender.macros);for(let{method:W,path:$,handler:X,hooks:Q}of Object.values(w.router.history))this.add(W,$,X,r2(Q,{error:w.event.error}));if(z){if(!(z in this.dependencies))this.dependencies[z]=[];let W=A!==void 0?O6(z+JSON.stringify(A)):0;if(this.dependencies[z].some(({checksum:$})=>W===$))return this;this.dependencies[z].push(this.config?.analytic?{name:w.config.name,seed:w.config.seed,checksum:W,dependencies:w.dependencies,stack:w.telemetry.stack,routes:w.router.history,decorators:w.singleton,store:w.singleton.store,error:w.definitions.error,derive:w.event.transform.filter(($)=>$?.subType==="derive").map(($)=>({fn:$.toString(),stack:new Error().stack??""})),resolve:w.event.transform.filter(($)=>$?.subType==="resolve").map(($)=>({fn:$.toString(),stack:new Error().stack??""}))}:{name:w.config.name,seed:w.config.seed,checksum:W,dependencies:w.dependencies}),this.event=e5(this.event,wz(w.event),W)}else this.event=e5(this.event,wz(w.event));return this.validator.global=r2(this.validator.global,{...w.validator.global}),this.validator.local=r2(this.validator.local,{...w.validator.scoped}),this}macro(w){if(typeof w==="function"){let z={checksum:O6(JSON.stringify({name:this.config.name,seed:this.config.seed,content:w.toString()})),fn:w};this.extender.macros.push(z)}else if(typeof w==="object"){let z={checksum:O6(JSON.stringify({name:this.config.name,seed:this.config.seed,content:Object.entries(w).map(([A,U])=>`${A}+${U}`).join(",")})),fn:()=>w};this.extender.macros.push(z)}return this}mount(w,z){if(w instanceof F0||typeof w==="function"||w.length===0||w==="/"){let W=typeof w==="function"?w:w instanceof F0?w.compile().fetch:z instanceof F0?z.compile().fetch:z,$=async({request:X,path:Q})=>{if(X.method==="GET"||X.method==="HEAD"||!X.headers.get("content-type"))return W(new Request(A4(X.url,Q||"/"),X));return W(new Request(A4(X.url,Q||"/"),{...X,body:await X.arrayBuffer()}))};return this.all("/*",$,{type:"none"}),this}let A=w.length;if(z instanceof F0)z=z.compile().fetch;let U=async({request:W,path:$})=>{if(W.method==="GET"||W.method==="HEAD"||!W.headers.get("content-type"))return z(new Request(A4(W.url,$.slice(A)||"/"),W));return z(new Request(A4(W.url,$.slice(A)||"/"),{...W,body:await W.arrayBuffer()}))};return this.all(w,U,{type:"none"}),this.all(w+(w.endsWith("/")?"*":"/*"),U,{type:"none"}),this}get(w,z,A){return this.add("GET",w,z,A),this}post(w,z,A){return this.add("POST",w,z,A),this}put(w,z,A){return this.add("PUT",w,z,A),this}patch(w,z,A){return this.add("PATCH",w,z,A),this}delete(w,z,A){return this.add("DELETE",w,z,A),this}options(w,z,A){return this.add("OPTIONS",w,z,A),this}all(w,z,A){return this.add("ALL",w,z,A),this}head(w,z,A){return this.add("HEAD",w,z,A),this}connect(w,z,A){return this.add("CONNECT",w,z,A),this}route(w,z,A,U){return this.add(w.toUpperCase(),z,A,U,U?.config),this}ws(w,z){if(this["~adapter"].ws)this["~adapter"].ws(this,w,z);else console.warn("Current adapter doesn't support WebSocket");return this}state(w,z,A){if(z===void 0)A=w,w={as:"append"},z="";else if(A===void 0){if(typeof w==="string")A=z,z=w,w={as:"append"};else if(typeof w==="object")A=z,z=""}let{as:U}=w;if(typeof z!=="string")return this;switch(typeof A){case"object":if(z){if(z in this.singleton.store)this.singleton.store[z]=_2(this.singleton.store[z],A,{override:U==="override"});else this.singleton.store[z]=A;return this}if(A===null)return this;return this.singleton.store=_2(this.singleton.store,A,{override:U==="override"}),this;case"function":if(z){if(U==="override"||!(z in this.singleton.store))this.singleton.store[z]=A}else this.singleton.store=A(this.singleton.store);return this;default:if(U==="override"||!(z in this.singleton.store))this.singleton.store[z]=A;return this}}decorate(w,z,A){if(z===void 0)A=w,w={as:"append"},z="";else if(A===void 0){if(typeof w==="string")A=z,z=w,w={as:"append"};else if(typeof w==="object")A=z,z=""}let{as:U}=w;if(typeof z!=="string")return this;switch(typeof A){case"object":if(z){if(z in this.singleton.decorator)this.singleton.decorator[z]=_2(this.singleton.decorator[z],A,{override:U==="override"});else this.singleton.decorator[z]=A;return this}if(A===null)return this;return this.singleton.decorator=_2(this.singleton.decorator,A,{override:U==="override"}),this;case"function":if(z){if(U==="override"||!(z in this.singleton.decorator))this.singleton.decorator[z]=A}else this.singleton.decorator=A(this.singleton.decorator);return this;default:if(U==="override"||!(z in this.singleton.decorator))this.singleton.decorator[z]=A;return this}}derive(w,z){if(!z)z=w,w={as:"local"};let A={subType:"derive",fn:z};return this.onTransform(w,A)}model(w,z){let A=(U)=>t4(U,[{from:x.Number(),to:(W)=>x.Numeric(W),untilObjectFound:!0},{from:x.Boolean(),to:(W)=>x.BooleanString(W),untilObjectFound:!0}]);switch(typeof w){case"object":let U={};return Object.entries(w).forEach(([$,X])=>{if(!($ in this.definitions.type))U[$]=this.definitions.type[$]=A(X)}),this.definitions.typebox=x.Module({...this.definitions.typebox.$defs,...U}),this;case"function":let W=A(w(this.definitions.type));return this.definitions.type=W,this.definitions.typebox=x.Module(W),this}return this.definitions.type[w]=z,this.definitions.typebox=x.Module({...this.definitions.typebox.$defs,[w]:z}),this}mapDerive(w,z){if(!z)z=w,w={as:"local"};let A={subType:"mapDerive",fn:z};return this.onTransform(w,A)}affix(w,z,A){if(A==="")return this;let U=["_","-"," "],W=(Z)=>Z[0].toUpperCase()+Z.slice(1),$=w==="prefix"?(Z,J)=>U.includes(Z.at(-1)??"")?Z+J:Z+W(J):U.includes(A.at(-1)??"")?(Z,J)=>J+Z:(Z,J)=>J+W(Z),X=(Z)=>{let J={};switch(Z){case"decorator":for(let Y in this.singleton.decorator)J[$(A,Y)]=this.singleton.decorator[Y];this.singleton.decorator=J;break;case"state":for(let Y in this.singleton.store)J[$(A,Y)]=this.singleton.store[Y];this.singleton.store=J;break;case"model":for(let Y in this.definitions.type)J[$(A,Y)]=this.definitions.type[Y];this.definitions.type=J;break;case"error":for(let Y in this.definitions.error)J[$(A,Y)]=this.definitions.error[Y];this.definitions.error=J;break}},Q=Array.isArray(z)?z:[z];for(let Z of Q.some((J)=>J==="all")?["decorator","state","model","error"]:Q)X(Z);return this}prefix(w,z){return this.affix("prefix",w,z)}suffix(w,z){return this.affix("suffix",w,z)}compile(){if(this["~adapter"].isWebStandard){if(this.fetch=this.config.aot?$8(this):Gz(this),typeof this.server?.reload==="function")this.server.reload({...this.server||{},fetch:this.fetch});return this}if(typeof this.server?.reload==="function")this.server.reload(this.server||{});return this._handle=$8(this),this}get modules(){return Promise.all(this.promisedModules.promises)}}var MU;(function(w){w[w.Include=0]="Include",w[w.None=1]="None"})(MU||(MU={}));var HU;(function(w){w[w.Required=0]="Required",w[w.Ignore=1]="Ignore"})(HU||(HU={}));function Lz(w){return LU(w,tH,r4.Include)}function a4(w){return LU(w,yH,r4.None)}function LU(w,z,A){let U="";for(let W=0;W<w.byteLength;W+=3){let $=0,X=0;for(let Q=0;Q<3&&W+Q<w.byteLength;Q++)$=$<<8|w[W+Q],X+=8;for(let Q=0;Q<4;Q++)if(X>=6)U+=z[$>>X-6&63],X-=6;else if(X>0)U+=z[$<<6-X&63],X=0;else if(A===r4.Include)U+="="}return U}var tH="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",yH="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_";var r4;(function(w){w[w.Include=0]="Include",w[w.None=1]="None"})(r4||(r4={}));var GU;(function(w){w[w.Required=0]="Required",w[w.Ignore=1]="Ignore"})(GU||(GU={}));class NU{uint8(w,z){if(w.byteLength<z+1)throw new TypeError("Insufficient bytes");return w[z]}uint16(w,z){if(w.byteLength<z+2)throw new TypeError("Insufficient bytes");return w[z]<<8|w[z+1]}uint32(w,z){if(w.byteLength<z+4)throw new TypeError("Insufficient bytes");let A=0;for(let U=0;U<4;U++)A|=w[z+U]<<24-U*8;return A}uint64(w,z){if(w.byteLength<z+8)throw new TypeError("Insufficient bytes");let A=0n;for(let U=0;U<8;U++)A|=BigInt(w[z+U])<<BigInt(56-U*8);return A}putUint8(w,z,A){if(w.length<A+1)throw new TypeError("Not enough space");if(z<0||z>255)throw new TypeError("Invalid uint8 value");w[A]=z}putUint16(w,z,A){if(w.length<A+2)throw new TypeError("Not enough space");if(z<0||z>65535)throw new TypeError("Invalid uint16 value");w[A]=z>>8,w[A+1]=z&255}putUint32(w,z,A){if(w.length<A+4)throw new TypeError("Not enough space");if(z<0||z>4294967295)throw new TypeError("Invalid uint32 value");for(let U=0;U<4;U++)w[A+U]=z>>(3-U)*8&255}putUint64(w,z,A){if(w.length<A+8)throw new TypeError("Not enough space");if(z<0||z>18446744073709551615n)throw new TypeError("Invalid uint64 value");for(let U=0;U<8;U++)w[A+U]=Number(z>>BigInt((7-U)*8)&0xffn)}}class SU{uint8(w,z){if(w.byteLength<z+1)throw new TypeError("Insufficient bytes");return w[z]}uint16(w,z){if(w.byteLength<z+2)throw new TypeError("Insufficient bytes");return w[z]|w[z+1]<<8}uint32(w,z){if(w.byteLength<z+4)throw new TypeError("Insufficient bytes");let A=0;for(let U=0;U<4;U++)A|=w[z+U]<<U*8;return A}uint64(w,z){if(w.byteLength<z+8)throw new TypeError("Insufficient bytes");let A=0n;for(let U=0;U<8;U++)A|=BigInt(w[z+U])<<BigInt(U*8);return A}putUint8(w,z,A){if(w.length<1+A)throw new TypeError("Insufficient space");if(z<0||z>255)throw new TypeError("Invalid uint8 value");w[A]=z}putUint16(w,z,A){if(w.length<2+A)throw new TypeError("Insufficient space");if(z<0||z>65535)throw new TypeError("Invalid uint16 value");w[A+1]=z>>8,w[A]=z&255}putUint32(w,z,A){if(w.length<4+A)throw new TypeError("Insufficient space");if(z<0||z>4294967295)throw new TypeError("Invalid uint32 value");for(let U=0;U<4;U++)w[A+U]=z>>U*8&255}putUint64(w,z,A){if(w.length<8+A)throw new TypeError("Insufficient space");if(z<0||z>18446744073709551615n)throw new TypeError("Invalid uint64 value");for(let U=0;U<8;U++)w[A+U]=Number(z>>BigInt(U*8)&0xffn)}}var _1=new NU,vH=new SU;function t0(w,z){return(w<<32-z|w>>>z)>>>0}function w1(w,z){return(w<<BigInt(64-z)|w>>BigInt(z))&0xffffffffffffffffn}class DU{blockSize=64;size=32;blocks=new Uint8Array(64);currentBlockSize=0;H=new Uint32Array([3238371032,914150663,812702999,4144912697,4290775857,1750603025,1694076839,3204075428]);l=0n;w=new Uint32Array(64);update(w){if(this.l+=BigInt(w.byteLength)*8n,this.currentBlockSize+w.byteLength<64){this.blocks.set(w,this.currentBlockSize),this.currentBlockSize+=w.byteLength;return}let z=0;if(this.currentBlockSize>0){let A=w.slice(0,64-this.currentBlockSize);this.blocks.set(A,this.currentBlockSize),this.process(),z+=A.byteLength,this.currentBlockSize=0}while(z+64<=w.byteLength){let A=w.slice(z,z+64);this.blocks.set(A),this.process(),z+=64}if(w.byteLength-z>0){let A=w.slice(z);this.blocks.set(A),this.currentBlockSize=A.byteLength}}digest(){if(this.blocks[this.currentBlockSize]=128,this.currentBlockSize+=1,64-this.currentBlockSize<8)this.blocks.fill(0,this.currentBlockSize),this.process(),this.currentBlockSize=0;this.blocks.fill(0,this.currentBlockSize),_1.putUint64(this.blocks,this.l,this.blockSize-8),this.process();let w=new Uint8Array(28);for(let z=0;z<7;z++)_1.putUint32(w,this.H[z],z*4);return w}process(){for(let Z=0;Z<16;Z++)this.w[Z]=(this.blocks[Z*4]<<24|this.blocks[Z*4+1]<<16|this.blocks[Z*4+2]<<8|this.blocks[Z*4+3])>>>0;for(let Z=16;Z<64;Z++){let J=(t0(this.w[Z-2],17)^t0(this.w[Z-2],19)^this.w[Z-2]>>>10)>>>0,Y=(t0(this.w[Z-15],7)^t0(this.w[Z-15],18)^this.w[Z-15]>>>3)>>>0;this.w[Z]=J+this.w[Z-7]+Y+this.w[Z-16]|0}let w=this.H[0],z=this.H[1],A=this.H[2],U=this.H[3],W=this.H[4],$=this.H[5],X=this.H[6],Q=this.H[7];for(let Z=0;Z<64;Z++){let J=(t0(W,6)^t0(W,11)^t0(W,25))>>>0,Y=(W&$^~W&X)>>>0,L=Q+J+Y+oH[Z]+this.w[Z]|0,_=(t0(w,2)^t0(w,13)^t0(w,22))>>>0,G=(w&z^w&A^z&A)>>>0,O=_+G|0;Q=X,X=$,$=W,W=U+L|0,U=A,A=z,z=w,w=L+O|0}this.H[0]=w+this.H[0]|0,this.H[1]=z+this.H[1]|0,this.H[2]=A+this.H[2]|0,this.H[3]=U+this.H[3]|0,this.H[4]=W+this.H[4]|0,this.H[5]=$+this.H[5]|0,this.H[6]=X+this.H[6]|0,this.H[7]=Q+this.H[7]|0}}var oH=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]);function bz(w){let z=new Nz;return z.update(w),z.digest()}class Nz{blockSize=64;size=32;blocks=new Uint8Array(64);currentBlockSize=0;H=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]);l=0n;w=new Uint32Array(64);update(w){if(this.l+=BigInt(w.byteLength)*8n,this.currentBlockSize+w.byteLength<64){this.blocks.set(w,this.currentBlockSize),this.currentBlockSize+=w.byteLength;return}let z=0;if(this.currentBlockSize>0){let A=w.slice(0,64-this.currentBlockSize);this.blocks.set(A,this.currentBlockSize),this.process(),z+=A.byteLength,this.currentBlockSize=0}while(z+64<=w.byteLength){let A=w.slice(z,z+64);this.blocks.set(A),this.process(),z+=64}if(w.byteLength-z>0){let A=w.slice(z);this.blocks.set(A),this.currentBlockSize=A.byteLength}}digest(){if(this.blocks[this.currentBlockSize]=128,this.currentBlockSize+=1,64-this.currentBlockSize<8)this.blocks.fill(0,this.currentBlockSize),this.process(),this.currentBlockSize=0;this.blocks.fill(0,this.currentBlockSize),_1.putUint64(this.blocks,this.l,this.blockSize-8),this.process();let w=new Uint8Array(32);for(let z=0;z<8;z++)_1.putUint32(w,this.H[z],z*4);return w}process(){for(let Z=0;Z<16;Z++)this.w[Z]=(this.blocks[Z*4]<<24|this.blocks[Z*4+1]<<16|this.blocks[Z*4+2]<<8|this.blocks[Z*4+3])>>>0;for(let Z=16;Z<64;Z++){let J=(t0(this.w[Z-2],17)^t0(this.w[Z-2],19)^this.w[Z-2]>>>10)>>>0,Y=(t0(this.w[Z-15],7)^t0(this.w[Z-15],18)^this.w[Z-15]>>>3)>>>0;this.w[Z]=J+this.w[Z-7]+Y+this.w[Z-16]|0}let w=this.H[0],z=this.H[1],A=this.H[2],U=this.H[3],W=this.H[4],$=this.H[5],X=this.H[6],Q=this.H[7];for(let Z=0;Z<64;Z++){let J=(t0(W,6)^t0(W,11)^t0(W,25))>>>0,Y=(W&$^~W&X)>>>0,L=Q+J+Y+uH[Z]+this.w[Z]|0,_=(t0(w,2)^t0(w,13)^t0(w,22))>>>0,G=(w&z^w&A^z&A)>>>0,O=_+G|0;Q=X,X=$,$=W,W=U+L|0,U=A,A=z,z=w,w=L+O|0}this.H[0]=w+this.H[0]|0,this.H[1]=z+this.H[1]|0,this.H[2]=A+this.H[2]|0,this.H[3]=U+this.H[3]|0,this.H[4]=W+this.H[4]|0,this.H[5]=$+this.H[5]|0,this.H[6]=X+this.H[6]|0,this.H[7]=Q+this.H[7]|0}}var uH=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]);class Z6{blockSize=128;size=64;blocks=new Uint8Array(128);currentBlockSize=0;l=0n;w=new BigUint64Array(80);H;constructor(w){if(w.byteLength!==64)throw new TypeError;this.H=w}update(w){if(this.l+=BigInt(w.byteLength)*8n,this.currentBlockSize+w.byteLength<128){this.blocks.set(w,this.currentBlockSize),this.currentBlockSize+=w.byteLength;return}let z=0;if(this.currentBlockSize>0){let A=w.slice(0,128-this.currentBlockSize);this.blocks.set(A,this.currentBlockSize),this.process(),z+=A.byteLength,this.currentBlockSize=0}while(z+128<=w.byteLength){let A=w.slice(z,z+128);this.blocks.set(A),this.process(),z+=128,this.currentBlockSize=0}if(w.byteLength-z>0){let A=w.slice(z);this.blocks.set(A),this.currentBlockSize=A.byteLength}}putDigest(w){if(w.byteLength>64||w.byteLength%8!==0)throw new TypeError;if(this.blocks[this.currentBlockSize]=128,this.currentBlockSize+=1,128-this.currentBlockSize<16)this.blocks.fill(0,this.currentBlockSize),this.process(),this.currentBlockSize=0;this.blocks.fill(0,this.currentBlockSize),_1.putUint64(this.blocks,this.l,this.blockSize-8),this.process();for(let z=0;z<w.byteLength/8;z++)_1.putUint64(w,this.H[z],z*8)}process(){for(let Z=0;Z<16;Z++)this.w[Z]=BigInt(this.blocks[Z*8])<<56n|BigInt(this.blocks[Z*8+1])<<48n|BigInt(this.blocks[Z*8+2])<<40n|BigInt(this.blocks[Z*8+3])<<32n|BigInt(this.blocks[Z*8+4])<<24n|BigInt(this.blocks[Z*8+5])<<16n|BigInt(this.blocks[Z*8+6])<<8n|BigInt(this.blocks[Z*8+7]);for(let Z=16;Z<80;Z++){let J=(w1(this.w[Z-2],19)^w1(this.w[Z-2],61)^this.w[Z-2]>>6n)&0xffffffffffffffffn,Y=(w1(this.w[Z-15],1)^w1(this.w[Z-15],8)^this.w[Z-15]>>7n)&0xffffffffffffffffn;this.w[Z]=J+this.w[Z-7]+Y+this.w[Z-16]&0xffffffffffffffffn}let w=this.H[0],z=this.H[1],A=this.H[2],U=this.H[3],W=this.H[4],$=this.H[5],X=this.H[6],Q=this.H[7];for(let Z=0;Z<80;Z++){let J=(w1(W,14)^w1(W,18)^w1(W,41))&0xffffffffffffffffn,Y=(W&$^~W&X)&0xffffffffffffffffn,L=Q+J+Y+mH[Z]+this.w[Z]&0xffffffffffffffffn,_=(w1(w,28)^w1(w,34)^w1(w,39))&0xffffffffffffffffn,G=(w&z^w&A^z&A)&0xffffffffffffffffn,O=_+G&0xffffffffffffffffn;Q=X,X=$,$=W,W=U+L&0xffffffffffffffffn,U=A,A=z,z=w,w=L+O&0xffffffffffffffffn}this.H[0]=w+this.H[0]&0xffffffffffffffffn,this.H[1]=z+this.H[1]&0xffffffffffffffffn,this.H[2]=A+this.H[2]&0xffffffffffffffffn,this.H[3]=U+this.H[3]&0xffffffffffffffffn,this.H[4]=W+this.H[4]&0xffffffffffffffffn,this.H[5]=$+this.H[5]&0xffffffffffffffffn,this.H[6]=X+this.H[6]&0xffffffffffffffffn,this.H[7]=Q+this.H[7]&0xffffffffffffffffn}}class _U{blockSize=128;size=64;sha512=new Z6(new BigUint64Array([0x6a09e667f3bcc908n,0xbb67ae8584caa73bn,0x3c6ef372fe94f82bn,0xa54ff53a5f1d36f1n,0x510e527fade682d1n,0x9b05688c2b3e6c1fn,0x1f83d9abfb41bd6bn,0x5be0cd19137e2179n]));update(w){this.sha512.update(w)}digest(){let w=new Uint8Array(64);return this.sha512.putDigest(w),w}}var mH=new BigUint64Array([0x428a2f98d728ae22n,0x7137449123ef65cdn,0xb5c0fbcfec4d3b2fn,0xe9b5dba58189dbbcn,0x3956c25bf348b538n,0x59f111f1b605d019n,0x923f82a4af194f9bn,0xab1c5ed5da6d8118n,0xd807aa98a3030242n,0x12835b0145706fben,0x243185be4ee4b28cn,0x550c7dc3d5ffb4e2n,0x72be5d74f27b896fn,0x80deb1fe3b1696b1n,0x9bdc06a725c71235n,0xc19bf174cf692694n,0xe49b69c19ef14ad2n,0xefbe4786384f25e3n,0x0fc19dc68b8cd5b5n,0x240ca1cc77ac9c65n,0x2de92c6f592b0275n,0x4a7484aa6ea6e483n,0x5cb0a9dcbd41fbd4n,0x76f988da831153b5n,0x983e5152ee66dfabn,0xa831c66d2db43210n,0xb00327c898fb213fn,0xbf597fc7beef0ee4n,0xc6e00bf33da88fc2n,0xd5a79147930aa725n,0x06ca6351e003826fn,0x142929670a0e6e70n,0x27b70a8546d22ffcn,0x2e1b21385c26c926n,0x4d2c6dfc5ac42aedn,0x53380d139d95b3dfn,0x650a73548baf63den,0x766a0abb3c77b2a8n,0x81c2c92e47edaee6n,0x92722c851482353bn,0xa2bfe8a14cf10364n,0xa81a664bbc423001n,0xc24b8b70d0f89791n,0xc76c51a30654be30n,0xd192e819d6ef5218n,0xd69906245565a910n,0xf40e35855771202an,0x106aa07032bbd1b8n,0x19a4c116b8d2d0c8n,0x1e376c085141ab53n,0x2748774cdf8eeb99n,0x34b0bcb5e19b48a8n,0x391c0cb3c5c95a63n,0x4ed8aa4ae3418acbn,0x5b9cca4f7763e373n,0x682e6ff3d6b2b8a3n,0x748f82ee5defb2fcn,0x78a5636f43172f60n,0x84c87814a1f0ab72n,0x8cc702081a6439ecn,0x90befffa23631e28n,0xa4506cebde82bde9n,0xbef9a3f7b2c67915n,0xc67178f2e372532bn,0xca273eceea26619cn,0xd186b8c721c0c207n,0xeada7dd6cde0eb1en,0xf57d4f7fee6ed178n,0x06f067aa72176fban,0x0a637dc5a2c898a6n,0x113f9804bef90daen,0x1b710b35131c471bn,0x28db77f523047d84n,0x32caab7b40c72493n,0x3c9ebe0a15c9bebcn,0x431d67c49c100d4cn,0x4cc5d4becb3e42b6n,0x597f299cfc657e2an,0x5fcb6fab3ad6faecn,0x6c44198c4a475817n]);class PU{blockSize=128;size=48;sha512=new Z6(new BigUint64Array([0xcbbb9d5dc1059ed8n,0x629a292a367cd507n,0x9159015a3070dd17n,0x152fecd8f70e5939n,0x67332667ffc00b31n,0x8eb44a8768581511n,0xdb0c2e0d64f98fa7n,0x47b5481dbefa4fa4n]));update(w){this.sha512.update(w)}digest(){let w=new Uint8Array(48);return this.sha512.putDigest(w),w}}class OU{blockSize=128;size=28;sha512=new Z6(new BigUint64Array([0x8c3d37c819544da2n,0x73e1996689dcd4d6n,0x1dfab7ae32ff9c82n,0x679dd514582f9fcfn,0x0f6d2b697bd44da8n,0x77e36f7304c48942n,0x3f9d85a86a1d36c8n,0x1112e6ad91d692a1n]));update(w){this.sha512.update(w)}digest(){let w=new Uint8Array(32);return this.sha512.putDigest(w),w.slice(0,28)}}class CU{blockSize=128;size=28;sha512=new Z6(new BigUint64Array([0x22312194fc2bf72cn,0x9f555fa3c84c64c2n,0x2393b86b6f53b151n,0x963877195940eabdn,0x96283ee2a88effe3n,0xbe5e1e2553863992n,0x2b0199fc2c85b8aan,0x0eb72ddc81c52ca2n]));update(w){this.sha512.update(w)}digest(){let w=new Uint8Array(32);return this.sha512.putDigest(w),w}}class B4{data;constructor(w){this.data=w}tokenType(){if("token_type"in this.data&&typeof this.data.token_type==="string")return this.data.token_type;throw new Error("Missing or invalid 'token_type' field")}accessToken(){if("access_token"in this.data&&typeof this.data.access_token==="string")return this.data.access_token;throw new Error("Missing or invalid 'access_token' field")}accessTokenExpiresInSeconds(){if("expires_in"in this.data&&typeof this.data.expires_in==="number")return this.data.expires_in;throw new Error("Missing or invalid 'expires_in' field")}accessTokenExpiresAt(){return new Date(Date.now()+this.accessTokenExpiresInSeconds()*1000)}hasRefreshToken(){return"refresh_token"in this.data&&typeof this.data.refresh_token==="string"}refreshToken(){if("refresh_token"in this.data&&typeof this.data.refresh_token==="string")return this.data.refresh_token;throw new Error("Missing or invalid 'refresh_token' field")}hasScopes(){return"scope"in this.data&&typeof this.data.scope==="string"}scopes(){if("scope"in this.data&&typeof this.data.scope==="string")return this.data.scope.split(" ");throw new Error("Missing or invalid 'scope' field")}idToken(){if("id_token"in this.data&&typeof this.data.id_token==="string")return this.data.id_token;throw new Error("Missing or invalid field 'id_token'")}}function M4(w){let z=bz(new TextEncoder().encode(w));return a4(z)}function Sz(){let w=new Uint8Array(32);return crypto.getRandomValues(w),a4(w)}function Dz(){let w=new Uint8Array(32);return crypto.getRandomValues(w),a4(w)}function RU(w,z){if(z.length!==1)throw new TypeError("Invalid character string");let A=0;while(A<w.length&&w[A]===z)A++;return w.slice(A)}function _z(w,z){if(z.length!==1)throw new TypeError("Invalid character string");let A=w.length;while(A>0&&w[A-1]===z)A--;return w.slice(0,A)}function G2(w,...z){let A=_z(w,"/");for(let U of z)A+="/",A+=_z(RU(U,"/"),"/");return A}function g(w,z){let A=new TextEncoder().encode(z.toString()),U=new Request(w,{method:"POST",body:A});return U.headers.set("Content-Type","application/x-www-form-urlencoded"),U.headers.set("Accept","application/json"),U.headers.set("User-Agent","arctic"),U.headers.set("Content-Length",A.byteLength.toString()),U}function x6(w,z){let A=new TextEncoder().encode(`${w}:${z}`);return Lz(A)}async function h(w){let z;try{z=await fetch(w)}catch(A){throw new J6(A)}if(z.status===400||z.status===401){let A;try{A=await z.json()}catch{throw new y1(z.status)}if(typeof A!=="object"||A===null)throw new M1(z.status,A);let U;try{U=X8(A)}catch{throw new M1(z.status,A)}throw U}if(z.status===200){let A;try{A=await z.json()}catch{throw new y1(z.status)}if(typeof A!=="object"||A===null)throw new M1(z.status,A);return new B4(A)}if(z.body!==null)await z.body.cancel();throw new y1(z.status)}async function H4(w){let z;try{z=await fetch(w)}catch(A){throw new J6(A)}if(z.status===400||z.status===401){let A;try{A=await z.json()}catch{throw new M1(z.status,null)}if(typeof A!=="object"||A===null)throw new M1(z.status,A);let U;try{U=X8(A)}catch{throw new M1(z.status,A)}throw U}if(z.status===200){if(z.body!==null)await z.body.cancel();return}if(z.body!==null)await z.body.cancel();throw new y1(z.status)}function X8(w){let z;if("error"in w&&typeof w.error==="string")z=w.error;else throw new Error("Invalid error response");let A=null,U=null,W=null;if("error_description"in w){if(typeof w.error_description!=="string")throw new Error("Invalid data");A=w.error_description}if("error_uri"in w){if(typeof w.error_uri!=="string")throw new Error("Invalid data");U=w.error_uri}if("state"in w){if(typeof w.state!=="string")throw new Error("Invalid data");W=w.state}return new e4(z,A,U,W)}class J6 extends Error{constructor(w){super("Failed to send request",{cause:w})}}class e4 extends Error{code;description;uri;state;constructor(w,z,A,U){super(`OAuth request error: ${w}`);this.code=w,this.description=z,this.uri=A,this.state=U}}class y1 extends Error{status;constructor(w){super("Unexpected error response");this.status=w}}class M1 extends Error{status;data;constructor(w,z){super("Unexpected error response body");this.status=w,this.data=z}}class T{clientId;clientPassword;redirectURI;constructor(w,z,A){this.clientId=w,this.clientPassword=z,this.redirectURI=A}createAuthorizationURL(w,z,A){let U=new URL(w);if(U.searchParams.set("response_type","code"),U.searchParams.set("client_id",this.clientId),this.redirectURI!==null)U.searchParams.set("redirect_uri",this.redirectURI);if(U.searchParams.set("state",z),A.length>0)U.searchParams.set("scope",A.join(" "));return U}createAuthorizationURLWithPKCE(w,z,A,U,W){let $=new URL(w);if($.searchParams.set("response_type","code"),$.searchParams.set("client_id",this.clientId),this.redirectURI!==null)$.searchParams.set("redirect_uri",this.redirectURI);if($.searchParams.set("state",z),A===U0.S256){let X=M4(U);$.searchParams.set("code_challenge_method","S256"),$.searchParams.set("code_challenge",X)}else if(A===U0.Plain)$.searchParams.set("code_challenge_method","plain"),$.searchParams.set("code_challenge",U);if(W.length>0)$.searchParams.set("scope",W.join(" "));return $}async validateAuthorizationCode(w,z,A){let U=new URLSearchParams;if(U.set("grant_type","authorization_code"),U.set("code",z),this.redirectURI!==null)U.set("redirect_uri",this.redirectURI);if(A!==null)U.set("code_verifier",A);if(this.clientPassword===null)U.set("client_id",this.clientId);let W=g(w,U);if(this.clientPassword!==null){let X=x6(this.clientId,this.clientPassword);W.headers.set("Authorization",`Basic ${X}`)}return await h(W)}async refreshAccessToken(w,z,A){let U=new URLSearchParams;if(U.set("grant_type","refresh_token"),U.set("refresh_token",z),this.clientPassword===null)U.set("client_id",this.clientId);if(A.length>0)U.set("scope",A.join(" "));let W=g(w,U);if(this.clientPassword!==null){let X=x6(this.clientId,this.clientPassword);W.headers.set("Authorization",`Basic ${X}`)}return await h(W)}async revokeToken(w,z){let A=new URLSearchParams;if(A.set("token",z),this.clientPassword===null)A.set("client_id",this.clientId);let U=g(w,A);if(this.clientPassword!==null){let W=x6(this.clientId,this.clientPassword);U.headers.set("Authorization",`Basic ${W}`)}await H4(U)}}var U0;(function(w){w[w.S256=0]="S256",w[w.Plain=1]="Plain"})(U0||(U0={}));class Q8{authorizationEndpoint;tokenEndpoint;tokenRevocationEndpoint;client;constructor(w,z,A,U){this.authorizationEndpoint=`https://${w}/oauth2/authorize`,this.tokenEndpoint=`https://${w}/oauth2/token`,this.tokenRevocationEndpoint=`https://${w}/oauth2/revoke`,this.client=new T(z,A,U)}createAuthorizationURL(w,z,A){return this.client.createAuthorizationURLWithPKCE(this.authorizationEndpoint,w,U0.S256,z,A)}async validateAuthorizationCode(w,z){return await this.client.validateAuthorizationCode(this.tokenEndpoint,w,z)}async refreshAccessToken(w,z){return await this.client.refreshAccessToken(this.tokenEndpoint,w,z)}async revokeToken(w){await this.client.revokeToken(this.tokenRevocationEndpoint,w)}}var lH="https://anilist.co/api/v2/oauth/authorize",sH="https://anilist.co/api/v2/oauth/token";class Z8{client;constructor(w,z,A){this.client=new T(w,z,A)}createAuthorizationURL(w){return this.client.createAuthorizationURL(lH,w,[])}async validateAuthorizationCode(w){return await this.client.validateAuthorizationCode(sH,w,null)}}var KU;(function(w){w[w.Include=0]="Include",w[w.None=1]="None"})(KU||(KU={}));var jU;(function(w){w[w.Required=0]="Required",w[w.Ignore=1]="Ignore"})(jU||(jU={}));function E6(w){return rH(w,aH,J8.None)}function rH(w,z,A){let U="";for(let W=0;W<w.byteLength;W+=3){let $=0,X=0;for(let Q=0;Q<3&&W+Q<w.byteLength;Q++)$=$<<8|w[W+Q],X+=8;for(let Q=0;Q<4;Q++)if(X>=6)U+=z[$>>X-6&63],X-=6;else if(X>0)U+=z[$<<6-X&63],X=0;else if(A===J8.Include)U+="="}return U}var aH="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_";function Pz(w){return eH(w,wG,ww.Ignore)}function eH(w,z,A){let U=new Uint8Array(Math.ceil(w.length/4)*3),W=0;for(let $=0;$<w.length;$+=4){let X=0,Q=0;for(let J=0;J<4;J++){if(A===ww.Required&&w[$+J]==="=")continue;if(A===ww.Ignore&&($+J>=w.length||w[$+J]==="="))continue;if(J>0&&w[$+J-1]==="=")throw new Error("Invalid padding");if(!(w[$+J]in z))throw new Error("Invalid character");X|=z[w[$+J]]<<(3-J)*6,Q+=6}if(Q<24){let J;if(Q===12)J=X&65535;else if(Q===18)J=X&255;else throw new Error("Invalid padding");if(J!==0)throw new Error("Invalid padding")}let Z=Math.floor(Q/8);for(let J=0;J<Z;J++)U[W]=X>>16-J*8&255,W++}return U.slice(0,W)}var J8;(function(w){w[w.Include=0]="Include",w[w.None=1]="None"})(J8||(J8={}));var ww;(function(w){w[w.Required=0]="Required",w[w.Ignore=1]="Ignore"})(ww||(ww={}));var wG={"0":52,"1":53,"2":54,"3":55,"4":56,"5":57,"6":58,"7":59,"8":60,"9":61,A:0,B:1,C:2,D:3,E:4,F:5,G:6,H:7,I:8,J:9,K:10,L:11,M:12,N:13,O:14,P:15,Q:16,R:17,S:18,T:19,U:20,V:21,W:22,X:23,Y:24,Z:25,a:26,b:27,c:28,d:29,e:30,f:31,g:32,h:33,i:34,j:35,k:36,l:37,m:38,n:39,o:40,p:41,q:42,r:43,s:44,t:45,u:46,v:47,w:48,x:49,y:50,z:51,"-":62,_:63};function FU(w){let z=w.split(".");if(z.length!==3)throw new Error("Invalid JWT");let A;try{A=new TextDecoder().decode(Pz(z[1]))}catch{throw new Error("Invalid JWT: Invalid base64url encoding")}let U;try{U=JSON.parse(A)}catch{throw new Error("Invalid JWT: Invalid JSON encoding")}if(typeof U!=="object"||U===null)throw new Error("Invalid JWT: Invalid payload");return U}function xU(w,z,A){let U=E6(new TextEncoder().encode(w)),W=E6(new TextEncoder().encode(z)),$=E6(A);return U+"."+W+"."+$}function EU(w,z){let A=E6(new TextEncoder().encode(w)),U=E6(new TextEncoder().encode(z)),W=A+"."+U;return new TextEncoder().encode(W)}var AG="https://appleid.apple.com/auth/authorize",UG="https://appleid.apple.com/auth/token";class Y8{clientId;teamId;keyId;pkcs8PrivateKey;redirectURI;constructor(w,z,A,U,W){this.clientId=w,this.teamId=z,this.keyId=A,this.pkcs8PrivateKey=U,this.redirectURI=W}createAuthorizationURL(w,z){let A=new URL(AG);if(A.searchParams.set("response_type","code"),A.searchParams.set("client_id",this.clientId),A.searchParams.set("state",w),z.length>0)A.searchParams.set("scope",z.join(" "));return A.searchParams.set("redirect_uri",this.redirectURI),A}async validateAuthorizationCode(w){let z=new URLSearchParams;z.set("grant_type","authorization_code"),z.set("code",w),z.set("redirect_uri",this.redirectURI),z.set("client_id",this.clientId);let A=await this.createClientSecret();z.set("client_secret",A);let U=g(UG,z);return await h(U)}async createClientSecret(){let w=await crypto.subtle.importKey("pkcs8",this.pkcs8PrivateKey,{name:"ECDSA",namedCurve:"P-256"},!1,["sign"]),z=Math.floor(Date.now()/1000),A=JSON.stringify({typ:"JWT",alg:"ES256",kid:this.keyId}),U=JSON.stringify({iss:this.teamId,exp:z+300,aud:["https://appleid.apple.com"],sub:this.clientId,iat:z}),W=new Uint8Array(await crypto.subtle.sign({name:"ECDSA",hash:"SHA-256"},w,EU(A,U)));return xU(A,U,W)}}var WG="https://auth.atlassian.com/authorize",fU="https://auth.atlassian.com/oauth/token";class q8{clientId;clientSecret;redirectURI;constructor(w,z,A){this.clientId=w,this.clientSecret=z,this.redirectURI=A}createAuthorizationURL(w,z){let A=new URL(WG);if(A.searchParams.set("response_type","code"),A.searchParams.set("client_id",this.clientId),A.searchParams.set("state",w),z.length>0)A.searchParams.set("scope",z.join(" "));return A.searchParams.set("redirect_uri",this.redirectURI),A.searchParams.set("audience","api.atlassian.com"),A.searchParams.set("prompt","consent"),A}async validateAuthorizationCode(w){let z=new URLSearchParams;z.set("grant_type","authorization_code"),z.set("code",w),z.set("redirect_uri",this.redirectURI),z.set("client_id",this.clientId),z.set("client_secret",this.clientSecret);let A=g(fU,z);return await h(A)}async refreshAccessToken(w){let z=new URLSearchParams;z.set("grant_type","refresh_token"),z.set("refresh_token",w),z.set("client_id",this.clientId),z.set("client_secret",this.clientSecret);let A=g(fU,z);return await h(A)}}class B8{authorizationEndpoint;tokenEndpoint;tokenRevocationEndpoint;client;constructor(w,z,A,U){this.authorizationEndpoint=`https://${w}/authorize`,this.tokenEndpoint=`https://${w}/oauth/token`,this.tokenRevocationEndpoint=`https://${w}/oauth/revoke`,this.client=new T(z,A,U)}createAuthorizationURL(w,z,A){let U;if(z!==null)U=this.client.createAuthorizationURLWithPKCE(this.authorizationEndpoint,w,U0.S256,z,A);else U=this.client.createAuthorizationURL(this.authorizationEndpoint,w,A);return U}async validateAuthorizationCode(w,z){return await this.client.validateAuthorizationCode(this.tokenEndpoint,w,z)}async refreshAccessToken(w){return await this.client.refreshAccessToken(this.tokenEndpoint,w,[])}async revokeToken(w){await this.client.revokeToken(this.tokenRevocationEndpoint,w)}}class M8{authorizationEndpoint;tokenEndpoint;tokenRevocationEndpoint;client;constructor(w,z,A,U){this.authorizationEndpoint=G2(w,"/application/o/authorize"),this.tokenEndpoint=G2(w,"/application/o/token"),this.tokenRevocationEndpoint=G2(w,"/application/o/revoke"),this.client=new T(z,A,U)}createAuthorizationURL(w,z,A){return this.client.createAuthorizationURLWithPKCE(this.authorizationEndpoint,w,U0.S256,z,A)}async validateAuthorizationCode(w,z){return await this.client.validateAuthorizationCode(this.tokenEndpoint,w,z)}async refreshAccessToken(w){return await this.client.refreshAccessToken(this.tokenEndpoint,w,[])}async revokeToken(w){await this.client.revokeToken(this.tokenRevocationEndpoint,w)}}var $G="https://bitbucket.org/site/oauth2/authorize",kU="https://bitbucket.org/site/oauth2/access_token";class H8{client;constructor(w,z,A){this.client=new T(w,z,A)}createAuthorizationURL(w){return this.client.createAuthorizationURL($G,w,[])}async validateAuthorizationCode(w){return await this.client.validateAuthorizationCode(kU,w,null)}async refreshAccessToken(w){return await this.client.refreshAccessToken(kU,w,[])}}var XG="https://account.box.com/api/oauth2/authorize",VU="https://api.box.com/oauth2/token",QG="https://api.box.com/oauth2/revoke";class G8{clientId;clientSecret;redirectURI;constructor(w,z,A){this.clientId=w,this.clientSecret=z,this.redirectURI=A}createAuthorizationURL(w,z){let A=new URL(XG);if(A.searchParams.set("response_type","code"),A.searchParams.set("client_id",this.clientId),A.searchParams.set("state",w),z.length>0)A.searchParams.set("scope",z.join(" "));return A.searchParams.set("redirect_uri",this.redirectURI),A}async validateAuthorizationCode(w){let z=new URLSearchParams;z.set("grant_type","authorization_code"),z.set("code",w),z.set("redirect_uri",this.redirectURI),z.set("client_id",this.clientId),z.set("client_secret",this.clientSecret);let A=g(VU,z);return await h(A)}async refreshAccessToken(w){let z=new URLSearchParams;z.set("grant_type","refresh_token"),z.set("refresh_token",w),z.set("client_id",this.clientId),z.set("client_secret",this.clientSecret);let A=g(VU,z);return await h(A)}async revokeToken(w){let z=new URLSearchParams;z.set("token",w),z.set("client_id",this.clientId),z.set("client_secret",this.clientSecret);let A=g(QG,z);await H4(A)}}var ZG="https://www.coinbase.com/oauth/authorize",gU="https://www.coinbase.com/oauth/token",JG="https://api.coinbase.com/oauth/revoke";class L8{clientId;clientSecret;redirectURI;constructor(w,z,A){this.clientId=w,this.clientSecret=z,this.redirectURI=A}createAuthorizationURL(w,z){let A=new URL(ZG);if(A.searchParams.set("response_type","code"),A.searchParams.set("client_id",this.clientId),A.searchParams.set("state",w),z.length>0)A.searchParams.set("scope",z.join(" "));return A.searchParams.set("redirect_uri",this.redirectURI),A}async validateAuthorizationCode(w){let z=new URLSearchParams;z.set("grant_type","authorization_code"),z.set("code",w),z.set("redirect_uri",this.redirectURI),z.set("client_id",this.clientId),z.set("client_secret",this.clientSecret);let A=g(gU,z);return await h(A)}async refreshAccessToken(w){let z=new URLSearchParams;z.set("grant_type","refresh_token"),z.set("refresh_token",w),z.set("client_id",this.clientId),z.set("client_secret",this.clientSecret);let A=g(gU,z);return await h(A)}async revokeToken(w){let z=new URLSearchParams;z.set("token",w),z.set("client_id",this.clientId),z.set("client_secret",this.clientSecret);let A=g(JG,z);await H4(A)}}var TU="https://discord.com/oauth2/authorize",iU="https://discord.com/api/oauth2/token",YG="https://discord.com/api/oauth2/token/revoke";class b8{client;constructor(w,z,A){this.client=new T(w,z,A)}createAuthorizationURL(w,z,A){let U;if(z!==null)U=this.client.createAuthorizationURLWithPKCE(TU,w,U0.S256,z,A);else U=this.client.createAuthorizationURL(TU,w,A);return U}async validateAuthorizationCode(w,z){return await this.client.validateAuthorizationCode(iU,w,z)}async refreshAccessToken(w){return await this.client.refreshAccessToken(iU,w,[])}async revokeToken(w){await this.client.revokeToken(YG,w)}}var qG="https://dribbble.com/oauth/authorize",BG="https://dribbble.com/oauth/token";class N8{clientId;clientSecret;redirectURI;constructor(w,z,A){this.clientId=w,this.clientSecret=z,this.redirectURI=A}createAuthorizationURL(w,z){let A=new URL(qG);if(A.searchParams.set("response_type","code"),A.searchParams.set("client_id",this.clientId),A.searchParams.set("state",w),z.length>0)A.searchParams.set("scope",z.join(" "));return A.searchParams.set("redirect_uri",this.redirectURI),A}async validateAuthorizationCode(w){let z=new URLSearchParams;z.set("grant_type","authorization_code"),z.set("code",w),z.set("redirect_uri",this.redirectURI),z.set("client_id",this.clientId),z.set("client_secret",this.clientSecret);let A=g(BG,z);return await h(A)}}var MG="https://www.dropbox.com/oauth2/authorize",dU="https://api.dropboxapi.com/oauth2/token",HG="https://api.dropboxapi.com/2/auth/token/revoke";class S8{client;constructor(w,z,A){this.client=new T(w,z,A)}createAuthorizationURL(w,z){return this.client.createAuthorizationURL(MG,w,z)}async validateAuthorizationCode(w){return await this.client.validateAuthorizationCode(dU,w,null)}async refreshAccessToken(w){return await this.client.refreshAccessToken(dU,w,[])}async revokeToken(w){await this.client.revokeToken(HG,w)}}var GG="https://www.facebook.com/v16.0/dialog/oauth",LG="https://graph.facebook.com/v16.0/oauth/access_token";class D8{clientId;clientSecret;redirectURI;constructor(w,z,A){this.clientId=w,this.clientSecret=z,this.redirectURI=A}createAuthorizationURL(w,z){let A=new URL(GG);if(A.searchParams.set("response_type","code"),A.searchParams.set("client_id",this.clientId),A.searchParams.set("state",w),z.length>0)A.searchParams.set("scope",z.join(" "));return A.searchParams.set("redirect_uri",this.redirectURI),A}async validateAuthorizationCode(w){let z=new URLSearchParams;z.set("grant_type","authorization_code"),z.set("code",w),z.set("redirect_uri",this.redirectURI),z.set("client_id",this.clientId),z.set("client_secret",this.clientSecret);let A=g(LG,z);return await h(A)}}var bG="https://www.figma.com/oauth",NG="https://www.figma.com/api/oauth/token";class _8{client;constructor(w,z,A){this.client=new T(w,z,A)}createAuthorizationURL(w,z){return this.client.createAuthorizationURL(bG,w,z)}async validateAuthorizationCode(w){return await this.client.validateAuthorizationCode(NG,w,null)}}var SG="https://appcenter.intuit.com/connect/oauth2",cU="https://oauth.platform.intuit.com/oauth2/v1/tokens/bearer",DG="https://developer.API.intuit.com/v2/oauth2/tokens/revoke";class P8{client;constructor(w,z,A){this.client=new T(w,z,A)}createAuthorizationURL(w,z){return this.client.createAuthorizationURL(SG,w,z)}async validateAuthorizationCode(w){return await this.client.validateAuthorizationCode(cU,w,null)}async refreshAccessToken(w){return await this.client.refreshAccessToken(cU,w,[])}async revokeToken(w){await this.client.revokeToken(DG,w)}}var _G="https://github.com/login/oauth/authorize",nU="https://github.com/login/oauth/access_token";class O8{clientId;clientSecret;redirectURI;constructor(w,z,A){this.clientId=w,this.clientSecret=z,this.redirectURI=A}createAuthorizationURL(w,z){let A=new URL(_G);if(A.searchParams.set("response_type","code"),A.searchParams.set("client_id",this.clientId),A.searchParams.set("state",w),z.length>0)A.searchParams.set("scope",z.join(" "));if(this.redirectURI!==null)A.searchParams.set("redirect_uri",this.redirectURI);return A}async validateAuthorizationCode(w){let z=new URLSearchParams;if(z.set("grant_type","authorization_code"),z.set("code",w),this.redirectURI!==null)z.set("redirect_uri",this.redirectURI);let A=g(nU,z),U=x6(this.clientId,this.clientSecret);return A.headers.set("Authorization",`Basic ${U}`),await hU(A)}async refreshAccessToken(w){let z=new URLSearchParams;z.set("grant_type","refresh_token"),z.set("refresh_token",w);let A=g(nU,z),U=x6(this.clientId,this.clientSecret);return A.headers.set("Authorization",`Basic ${U}`),await hU(A)}}async function hU(w){let z;try{z=await fetch(w)}catch(W){throw new J6(W)}if(z.status!==200){if(z.body!==null)await z.body.cancel();throw new y1(z.status)}let A;try{A=await z.json()}catch{throw new y1(z.status)}if(typeof A!=="object"||A===null)throw new M1(z.status,A);if("error"in A&&typeof A.error==="string"){let W;try{W=X8(A)}catch{throw new M1(z.status,A)}throw W}return new B4(A)}class C8{authorizationEndpoint;tokenEndpoint;tokenRevocationEndpoint;client;constructor(w,z,A,U){this.authorizationEndpoint=G2(w,"/oauth/authorize"),this.tokenEndpoint=G2(w,"/oauth/token"),this.tokenRevocationEndpoint=G2(w,"/oauth/revoke"),this.client=new T(z,A,U)}createAuthorizationURL(w,z){return this.client.createAuthorizationURL(this.authorizationEndpoint,w,z)}async validateAuthorizationCode(w){return await this.client.validateAuthorizationCode(this.tokenEndpoint,w,null)}async refreshAccessToken(w){return await this.client.refreshAccessToken(this.tokenEndpoint,w,[])}async revokeToken(w){await this.client.revokeToken(this.tokenRevocationEndpoint,w)}}var PG="https://accounts.google.com/o/oauth2/v2/auth",tU="https://oauth2.googleapis.com/token",OG="https://oauth2.googleapis.com/revoke";class R8{client;constructor(w,z,A){this.client=new T(w,z,A)}createAuthorizationURL(w,z,A){return this.client.createAuthorizationURLWithPKCE(PG,w,U0.S256,z,A)}async validateAuthorizationCode(w,z){return await this.client.validateAuthorizationCode(tU,w,z)}async refreshAccessToken(w){return await this.client.refreshAccessToken(tU,w,[])}async revokeToken(w){await this.client.revokeToken(OG,w)}}var CG="https://kauth.kakao.com/oauth/authorize",yU="https://kauth.kakao.com/oauth/token";class K8{clientId;clientSecret;redirectURI;constructor(w,z,A){this.clientId=w,this.clientSecret=z,this.redirectURI=A}createAuthorizationURL(w,z){let A=new URL(CG);if(A.searchParams.set("response_type","code"),A.searchParams.set("client_id",this.clientId),A.searchParams.set("state",w),z.length>0)A.searchParams.set("scope",z.join(" "));return A.searchParams.set("redirect_uri",this.redirectURI),A}async validateAuthorizationCode(w){let z=new URLSearchParams;z.set("grant_type","authorization_code"),z.set("code",w),z.set("redirect_uri",this.redirectURI),z.set("client_id",this.clientId),z.set("client_secret",this.clientSecret);let A=g(yU,z);return await h(A)}async refreshAccessToken(w){let z=new URLSearchParams;z.set("grant_type","refresh_token"),z.set("refresh_token",w),z.set("client_id",this.clientId),z.set("client_secret",this.clientSecret);let A=g(yU,z);return await h(A)}}class j8{authorizationEndpoint;tokenEndpoint;tokenRevocationEndpoint;client;constructor(w,z,A,U){this.authorizationEndpoint=w+"/protocol/openid-connect/auth",this.tokenEndpoint=w+"/protocol/openid-connect/token",this.tokenRevocationEndpoint=w+"/protocol/openid-connect/revoke",this.client=new T(z,A,U)}createAuthorizationURL(w,z,A){return this.client.createAuthorizationURLWithPKCE(this.authorizationEndpoint,w,U0.S256,z,A)}async validateAuthorizationCode(w,z){return await this.client.validateAuthorizationCode(this.tokenEndpoint,w,z)}async refreshAccessToken(w){return await this.client.refreshAccessToken(this.tokenEndpoint,w,[])}async revokeToken(w){await this.client.revokeToken(this.tokenRevocationEndpoint,w)}}var RG="https://lichess.org/oauth",KG="https://lichess.org/api/token";class F8{client;constructor(w,z){this.client=new T(w,null,z)}createAuthorizationURL(w,z,A){return this.client.createAuthorizationURLWithPKCE(RG,w,U0.S256,z,A)}async validateAuthorizationCode(w,z){return await this.client.validateAuthorizationCode(KG,w,z)}}var jG="https://access.line.me/oauth2/v2.1/authorize",vU="https://api.line.me/oauth2/v2.1/token";class x8{clientId;clientSecret;redirectURI;constructor(w,z,A){this.clientId=w,this.clientSecret=z,this.redirectURI=A}createAuthorizationURL(w,z,A){let U=new URL(jG);if(U.searchParams.set("response_type","code"),U.searchParams.set("client_id",this.clientId),U.searchParams.set("state",w),A.length>0)U.searchParams.set("scope",A.join(" "));U.searchParams.set("redirect_uri",this.redirectURI);let W=M4(z);return U.searchParams.set("code_challenge_method","S256"),U.searchParams.set("code_challenge",W),U}async validateAuthorizationCode(w,z){let A=new URLSearchParams;A.set("grant_type","authorization_code"),A.set("code",w),A.set("code_verifier",z),A.set("redirect_uri",this.redirectURI),A.set("client_id",this.clientId),A.set("client_secret",this.clientSecret);let U=g(vU,A);return await h(U)}async refreshAccessToken(w){let z=new URLSearchParams;z.set("grant_type","refresh_token"),z.set("refresh_token",w),z.set("client_id",this.clientId),z.set("client_secret",this.clientSecret);let A=g(vU,z);return await h(A)}}var FG="https://linear.app/oauth/authorize",xG="https://api.linear.app/oauth/token";class E8{clientId;clientSecret;redirectURI;constructor(w,z,A){this.clientId=w,this.clientSecret=z,this.redirectURI=A}createAuthorizationURL(w,z){let A=new URL(FG);if(A.searchParams.set("response_type","code"),A.searchParams.set("client_id",this.clientId),A.searchParams.set("state",w),z.length>0)A.searchParams.set("scope",z.join(" "));return A.searchParams.set("redirect_uri",this.redirectURI),A}async validateAuthorizationCode(w){let z=new URLSearchParams;z.set("grant_type","authorization_code"),z.set("code",w),z.set("redirect_uri",this.redirectURI),z.set("client_id",this.clientId),z.set("client_secret",this.clientSecret);let A=g(xG,z);return await h(A)}}var EG="https://www.linkedin.com/oauth/v2/authorization",oU="https://www.linkedin.com/oauth/v2/accessToken";class I8{clientId;clientSecret;redirectURI;constructor(w,z,A){this.clientId=w,this.clientSecret=z,this.redirectURI=A}createAuthorizationURL(w,z){let A=new URL(EG);if(A.searchParams.set("response_type","code"),A.searchParams.set("client_id",this.clientId),A.searchParams.set("state",w),z.length>0)A.searchParams.set("scope",z.join(" "));return A.searchParams.set("redirect_uri",this.redirectURI),A}async validateAuthorizationCode(w){let z=new URLSearchParams;z.set("grant_type","authorization_code"),z.set("code",w),z.set("redirect_uri",this.redirectURI),z.set("client_id",this.clientId),z.set("client_secret",this.clientSecret);let A=g(oU,z);return await h(A)}async refreshAccessToken(w){let z=new URLSearchParams;z.set("grant_type","refresh_token"),z.set("refresh_token",w),z.set("client_id",this.clientId),z.set("client_secret",this.clientSecret);let A=g(oU,z);return await h(A)}}class f8{authorizationEndpoint;tokenEndpoint;client;constructor(w,z,A,U){this.authorizationEndpoint=G2("https://login.microsoftonline.com",w,"/oauth2/v2.0/authorize"),this.tokenEndpoint=G2("https://login.microsoftonline.com",w,"/oauth2/v2.0/token"),this.client=new T(z,A,U)}createAuthorizationURL(w,z,A){return this.client.createAuthorizationURLWithPKCE(this.authorizationEndpoint,w,U0.S256,z,A)}async validateAuthorizationCode(w,z){return await this.client.validateAuthorizationCode(this.tokenEndpoint,w,z)}async refreshAccessToken(w,z){return await this.client.refreshAccessToken(this.tokenEndpoint,w,z)}}var IG="https://myanimelist.net/v1/oauth2/authorize",uU="https://myanimelist.net/v1/oauth2/token";class k8{client;constructor(w,z,A){this.client=new T(w,z,A)}createAuthorizationURL(w,z){return this.client.createAuthorizationURLWithPKCE(IG,w,U0.Plain,z,[])}async validateAuthorizationCode(w,z){return await this.client.validateAuthorizationCode(uU,w,z)}async refreshAccessToken(w){return await this.client.refreshAccessToken(uU,w,[])}}var fG="https://api.notion.com/v1/oauth/authorize",kG="https://api.notion.com/v1/oauth/token";class V8{client;constructor(w,z,A){this.client=new T(w,z,A)}createAuthorizationURL(w){let z=this.client.createAuthorizationURL(fG,w,[]);return z.searchParams.set("owner","user"),z}async validateAuthorizationCode(w){return await this.client.validateAuthorizationCode(kG,w,null)}}class g8{authorizationEndpoint;tokenEndpoint;tokenRevocationEndpoint;client;constructor(w,z,A,U,W){let $=`https://${w}/oauth2`;if(z!==null)$=G2($,z);this.authorizationEndpoint=G2($,"/v1/authorize"),this.tokenEndpoint=G2($,"/v1/token"),this.tokenRevocationEndpoint=G2($,"/v1/revoke"),this.client=new T(A,U,W)}createAuthorizationURL(w,z,A){return this.client.createAuthorizationURLWithPKCE(this.authorizationEndpoint,w,U0.S256,z,A)}async validateAuthorizationCode(w,z){return await this.client.validateAuthorizationCode(this.tokenEndpoint,w,z)}async refreshAccessToken(w,z){return await this.client.refreshAccessToken(this.tokenEndpoint,w,z)}async revokeToken(w){await this.client.revokeToken(this.tokenRevocationEndpoint,w)}}var VG="https://osu.ppy.sh/oauth/authorize",mU="https://osu.ppy.sh/oauth/token";class T8{clientId;clientSecret;redirectURI;constructor(w,z,A){this.clientId=w,this.clientSecret=z,this.redirectURI=A}createAuthorizationURL(w,z){let A=new URL(VG);if(A.searchParams.set("response_type","code"),A.searchParams.set("client_id",this.clientId),A.searchParams.set("state",w),z.length>0)A.searchParams.set("scope",z.join(" "));if(this.redirectURI!==null)A.searchParams.set("redirect_uri",this.redirectURI);return A}async validateAuthorizationCode(w){let z=new URLSearchParams;if(z.set("grant_type","authorization_code"),z.set("code",w),this.redirectURI!==null)z.set("redirect_uri",this.redirectURI);z.set("client_id",this.clientId),z.set("client_secret",this.clientSecret);let A=g(mU,z);return await h(A)}async refreshAccessToken(w){let z=new URLSearchParams;z.set("grant_type","refresh_token"),z.set("refresh_token",w),z.set("client_id",this.clientId),z.set("client_secret",this.clientSecret);let A=g(mU,z);return await h(A)}}var gG="https://www.patreon.com/oauth2/authorize",pU="https://www.patreon.com/api/oauth2/token";class i8{clientId;clientSecret;redirectURI;constructor(w,z,A){this.clientId=w,this.clientSecret=z,this.redirectURI=A}createAuthorizationURL(w,z){let A=new URL(gG);if(A.searchParams.set("response_type","code"),A.searchParams.set("client_id",this.clientId),A.searchParams.set("state",w),z.length>0)A.searchParams.set("scope",z.join(" "));return A.searchParams.set("redirect_uri",this.redirectURI),A}async validateAuthorizationCode(w){let z=new URLSearchParams;z.set("grant_type","authorization_code"),z.set("code",w),z.set("redirect_uri",this.redirectURI),z.set("client_id",this.clientId),z.set("client_secret",this.clientSecret);let A=g(pU,z);return await h(A)}async refreshAccessToken(w){let z=new URLSearchParams;z.set("grant_type","refresh_token"),z.set("refresh_token",w),z.set("client_id",this.clientId),z.set("client_secret",this.clientSecret);let A=g(pU,z);return await h(A)}}var TG="https://www.reddit.com/api/v1/authorize",lU="https://www.reddit.com/api/v1/access_token";class d8{client;constructor(w,z,A){this.client=new T(w,z,A)}createAuthorizationURL(w,z){return this.client.createAuthorizationURL(TG,w,z)}async validateAuthorizationCode(w){return await this.client.validateAuthorizationCode(lU,w,null)}async refreshAccessToken(w){return await this.client.refreshAccessToken(lU,w,[])}}var iG="https://apis.roblox.com/oauth/v1/authorize",sU="https://apis.roblox.com/oauth/v1/token",dG="https://apis.roblox.com/oauth/v1/token/revoke";class c8{client;constructor(w,z,A){this.client=new T(w,z,A)}createAuthorizationURL(w,z,A){return this.client.createAuthorizationURLWithPKCE(iG,w,U0.S256,z,A)}async validateAuthorizationCode(w,z){return await this.client.validateAuthorizationCode(sU,w,z)}async refreshAccessToken(w){return await this.client.refreshAccessToken(sU,w,[])}async revokeToken(w){await this.client.revokeToken(dG,w)}}class n8{authorizationEndpoint;tokenEndpoint;tokenRevocationEndpoint;client;constructor(w,z,A,U){this.authorizationEndpoint=`https://${w}/services/oauth2/authorize`,this.tokenEndpoint=`https://${w}/services/oauth2/token`,this.tokenRevocationEndpoint=`https://${w}/services/oauth2/revoke`,this.client=new T(z,A,U)}createAuthorizationURL(w,z,A){return this.client.createAuthorizationURLWithPKCE(this.authorizationEndpoint,w,U0.S256,z,A)}async validateAuthorizationCode(w,z){return await this.client.validateAuthorizationCode(this.tokenEndpoint,w,z)}async refreshAccessToken(w){return await this.client.refreshAccessToken(this.tokenEndpoint,w,[])}async revokeToken(w){await this.client.revokeToken(this.tokenRevocationEndpoint,w)}}var cG="https://shikimori.one/oauth/authorize",rU="https://shikimori.one/oauth/token";class h8{clientId;clientSecret;redirectURI;constructor(w,z,A){this.clientId=w,this.clientSecret=z,this.redirectURI=A}createAuthorizationURL(w){let z=new URL(cG);return z.searchParams.set("response_type","code"),z.searchParams.set("client_id",this.clientId),z.searchParams.set("state",w),z.searchParams.set("redirect_uri",this.redirectURI),z}async validateAuthorizationCode(w){let z=new URLSearchParams;z.set("grant_type","authorization_code"),z.set("code",w),z.set("redirect_uri",this.redirectURI),z.set("client_id",this.clientId),z.set("client_secret",this.clientSecret);let A=g(rU,z);return await h(A)}async refreshAccessToken(w){let z=new URLSearchParams;z.set("grant_type","refresh_token"),z.set("refresh_token",w),z.set("client_id",this.clientId),z.set("client_secret",this.clientSecret);let A=g(rU,z);return await h(A)}}var nG="https://slack.com/openid/connect/authorize",hG="https://slack.com/api/openid.connect.token";class t8{client;constructor(w,z,A){this.client=new T(w,z,A)}createAuthorizationURL(w,z){return this.client.createAuthorizationURL(nG,w,z)}async validateAuthorizationCode(w){return await this.client.validateAuthorizationCode(hG,w,null)}}var aU="https://accounts.spotify.com/authorize",eU="https://accounts.spotify.com/api/token";class y8{client;constructor(w,z,A){this.client=new T(w,z,A)}createAuthorizationURL(w,z,A){let U;if(z!==null)U=this.client.createAuthorizationURLWithPKCE(aU,w,U0.S256,z,A);else U=this.client.createAuthorizationURL(aU,w,A);return U}async validateAuthorizationCode(w,z){return await this.client.validateAuthorizationCode(eU,w,z)}async refreshAccessToken(w){return await this.client.refreshAccessToken(eU,w,[])}}var tG="https://www.strava.com/oauth/authorize",yG="https://www.strava.com/oauth/token";class v8{clientId;clientSecret;redirectURI;constructor(w,z,A){this.clientId=w,this.clientSecret=z,this.redirectURI=A}createAuthorizationURL(w,z){let A=new URL(tG);if(A.searchParams.set("response_type","code"),A.searchParams.set("client_id",this.clientId),A.searchParams.set("state",w),z.length>0)A.searchParams.set("scope",z.join(","));return A.searchParams.set("redirect_uri",this.redirectURI),A}async validateAuthorizationCode(w){let z=new URLSearchParams;z.set("grant_type","authorization_code"),z.set("code",w),z.set("redirect_uri",this.redirectURI),z.set("client_id",this.clientId),z.set("client_secret",this.clientSecret);let A=g(yG,z);return await h(A)}}var vG="https://v5api.tiltify.com/oauth/authorizeze",wW="https://v5api.tiltify.com/oauth/token";class o8{clientId;clientSecret;redirectURI;constructor(w,z,A){this.clientId=w,this.clientSecret=z,this.redirectURI=A}createAuthorizationURL(w,z){let A=new URL(vG);if(A.searchParams.set("response_type","code"),A.searchParams.set("client_id",this.clientId),A.searchParams.set("state",w),z.length>0)A.searchParams.set("scope",z.join(" "));return A.searchParams.set("redirect_uri",this.redirectURI),A}async validateAuthorizationCode(w){let z=new URLSearchParams;z.set("grant_type","authorization_code"),z.set("code",w),z.set("redirect_uri",this.redirectURI),z.set("client_id",this.clientId),z.set("client_secret",this.clientSecret);let A=g(wW,z);return await h(A)}async refreshAccessToken(w){let z=new URLSearchParams;z.set("grant_type","refresh_token"),z.set("refresh_token",w),z.set("client_id",this.clientId),z.set("client_secret",this.clientSecret);let A=g(wW,z);return await h(A)}}var oG="https://www.tumblr.com/oauth2/authorize",zW="https://api.tumblr.com/v2/oauth2/token";class u8{client;constructor(w,z,A){this.client=new T(w,z,A)}createAuthorizationURL(w,z){return this.client.createAuthorizationURL(oG,w,z)}async validateAuthorizationCode(w){return await this.client.validateAuthorizationCode(zW,w,null)}async refreshAccessToken(w){return await this.client.refreshAccessToken(zW,w,[])}}var uG="https://id.twitch.tv/oauth2/authorize",AW="https://id.twitch.tv/oauth2/token";class m8{clientId;clientSecret;redirectURI;constructor(w,z,A){this.clientId=w,this.clientSecret=z,this.redirectURI=A}createAuthorizationURL(w,z){let A=new URL(uG);if(A.searchParams.set("response_type","code"),A.searchParams.set("client_id",this.clientId),A.searchParams.set("state",w),z.length>0)A.searchParams.set("scope",z.join(" "));return A.searchParams.set("redirect_uri",this.redirectURI),A}async validateAuthorizationCode(w){let z=new URLSearchParams;z.set("grant_type","authorization_code"),z.set("code",w),z.set("redirect_uri",this.redirectURI),z.set("client_id",this.clientId),z.set("client_secret",this.clientSecret);let A=g(AW,z);return await h(A)}async refreshAccessToken(w){let z=new URLSearchParams;z.set("grant_type","refresh_token"),z.set("refresh_token",w),z.set("client_id",this.clientId),z.set("client_secret",this.clientSecret);let A=g(AW,z);return await h(A)}}var mG="https://twitter.com/i/oauth2/authorize",UW="https://api.twitter.com/2/oauth2/token",pG="https://api.twitter.com/2/oauth2/revoke";class p8{client;constructor(w,z,A){this.client=new T(w,z,A)}createAuthorizationURL(w,z,A){return this.client.createAuthorizationURLWithPKCE(mG,w,U0.S256,z,A)}async validateAuthorizationCode(w,z){return await this.client.validateAuthorizationCode(UW,w,z)}async refreshAccessToken(w){return await this.client.refreshAccessToken(UW,w,[])}async revokeToken(w){await this.client.revokeToken(pG,w)}}var lG="https://oauth.vk.com/authorize",sG="https://oauth.vk.com/access_token";class l8{clientId;clientSecret;redirectURI;constructor(w,z,A){this.clientId=w,this.clientSecret=z,this.redirectURI=A}createAuthorizationURL(w,z){let A=new URL(lG);if(A.searchParams.set("response_type","code"),A.searchParams.set("client_id",this.clientId),A.searchParams.set("state",w),z.length>0)A.searchParams.set("scope",z.join(" "));return A.searchParams.set("redirect_uri",this.redirectURI),A}async validateAuthorizationCode(w){let z=new URLSearchParams;z.set("grant_type","authorization_code"),z.set("code",w),z.set("redirect_uri",this.redirectURI),z.set("client_id",this.clientId),z.set("client_secret",this.clientSecret);let A=g(sG,z);return await h(A)}}var rG="https://api.workos.com/sso/authorize",aG="https://api.workos.com/sso/token";class s8{clientId;clientSecret;redirectURI;constructor(w,z,A){this.clientId=w,this.clientSecret=z,this.redirectURI=A}createAuthorizationURL(w,z){let A=new URL(rG);if(A.searchParams.set("response_type","code"),A.searchParams.set("client_id",this.clientId),A.searchParams.set("state",w),A.searchParams.set("redirect_uri",this.redirectURI),z!==null){let U=M4(z);A.searchParams.set("code_challenge_method","S256"),A.searchParams.set("code_challenge",U)}return A}async validateAuthorizationCode(w,z){let A=new URLSearchParams;if(A.set("grant_type","authorization_code"),A.set("code",w),A.set("redirect_uri",this.redirectURI),A.set("client_id",this.clientId),this.clientSecret!==null)A.set("client_secret",this.clientSecret);if(z!==null)A.set("code_verifier",z);let U=g(aG,A);return await h(U)}}var eG="https://api.login.yahoo.com/oauth2/request_auth",WW="https://api.login.yahoo.com/oauth2/get_token";class r8{client;constructor(w,z,A){this.client=new T(w,z,A)}createAuthorizationURL(w,z){return this.client.createAuthorizationURL(eG,w,z)}async validateAuthorizationCode(w){return await this.client.validateAuthorizationCode(WW,w,null)}async refreshAccessToken(w){return await this.client.refreshAccessToken(WW,w,[])}}var wL="https://oauth.yandex.com/authorize",$W="https://oauth.yandex.com/token";class a8{client;constructor(w,z,A){this.client=new T(w,z,A)}createAuthorizationURL(w,z){return this.client.createAuthorizationURL(wL,w,z)}async validateAuthorizationCode(w){return await this.client.validateAuthorizationCode($W,w,null)}async refreshAccessToken(w){return await this.client.refreshAccessToken($W,w,[])}}var zL="https://zoom.us/oauth/authorize",XW="https://zoom.us/oauth/token",AL="https://zoom.us/oauth/revoke";class e8{client;constructor(w,z,A){this.client=new T(w,z,A)}createAuthorizationURL(w,z,A){return this.client.createAuthorizationURLWithPKCE(zL,w,U0.S256,z,A)}async validateAuthorizationCode(w,z){return await this.client.validateAuthorizationCode(XW,w,z)}async refreshAccessToken(w){return await this.client.refreshAccessToken(XW,w,[])}async revokeToken(w){await this.client.revokeToken(AL,w)}}var UL="https://api.intra.42.fr/oauth/authorize",WL="https://api.intra.42.fr/oauth/token";class w5{clientId;clientSecret;redirectURI;constructor(w,z,A){this.clientId=w,this.clientSecret=z,this.redirectURI=A}createAuthorizationURL(w,z){let A=new URL(UL);if(A.searchParams.set("response_type","code"),A.searchParams.set("client_id",this.clientId),A.searchParams.set("state",w),z.length>0)A.searchParams.set("scope",z.join(" "));return A.searchParams.set("redirect_uri",this.redirectURI),A}async validateAuthorizationCode(w){let z=new URLSearchParams;z.set("grant_type","authorization_code"),z.set("code",w),z.set("redirect_uri",this.redirectURI),z.set("client_id",this.clientId),z.set("client_secret",this.clientSecret);let A=g(WL,z);return await h(A)}}function Oz(w){try{return FU(w)}catch(z){throw new Error("Invalid ID token",{cause:z})}}var zw={AmazonCognito:Q8,AniList:Z8,Apple:Y8,Atlassian:q8,Auth0:B8,Authentik:M8,Bitbucket:H8,Box:G8,Coinbase:L8,Discord:b8,Dribbble:N8,Dropbox:S8,Facebook:D8,Figma:_8,Intuit:P8,GitHub:O8,GitLab:C8,Google:R8,Kakao:K8,KeyCloak:j8,Lichess:F8,Line:x8,Linear:E8,LinkedIn:I8,MicrosoftEntraId:f8,MyAnimeList:k8,Notion:V8,Okta:g8,Osu:T8,Patreon:i8,Reddit:d8,Roblox:c8,Salesforce:n8,Shikimori:h8,Slack:t8,Spotify:y8,Strava:v8,Tiltify:o8,Tumblr:u8,Twitch:m8,Twitter:p8,VK:l8,WorkOS:s8,Yahoo:r8,Yandex:a8,Zoom:e8,FortyTwo:w5},QW=Object.keys(zw).reduce((w,z)=>{return w[z.toLowerCase()]=z,w},{}),Aw={AmazonCognito:"https://{region}.amazonaws.com/{userPoolId}/.well-known/openid-configuration",AniList:"https://graphql.anilist.co",Apple:"https://appleid.apple.com/auth/token",Atlassian:"https://api.atlassian.com/me",Auth0:"https://{your_domain}/userinfo",Authentik:"https://{your_domain}/api/v1/user/me",Bitbucket:"https://api.bitbucket.org/2.0/user",Box:"https://api.box.com/2.0/users/me",Coinbase:"https://api.coinbase.com/v2/user",Discord:"https://discord.com/api/users/@me",Dribbble:"https://api.dribbble.com/v2/user",Dropbox:"https://api.dropboxapi.com/2/users/get_current_account",Facebook:"https://graph.facebook.com/me",Figma:"https://api.figma.com/v1/me",Intuit:"https://accounts.platform.intuit.com/v1/openid_connect/userinfo",GitHub:"https://api.github.com/user",GitLab:"https://gitlab.com/api/v4/user",Google:"https://www.googleapis.com/userinfo/v2/me",Kakao:"https://kapi.kakao.com/v2/user/me",KeyCloak:"https://{your_domain}/auth/realms/{realm}/protocol/openid-connect/userinfo",Lichess:"https://lichess.org/api/account",Line:"https://api.line.me/v2/profile",Linear:"https://api.linear.app/v1/me",LinkedIn:"https://api.linkedin.com/v2/me",MicrosoftEntraId:"https://graph.microsoft.com/v1.0/me",MyAnimeList:"https://myanimelist.net/v1/users/@me",Notion:"https://api.notion.com/v1/users/me",Okta:"https://{yourOktaDomain}/oauth2/v1/userinfo",Osu:"https://osu.ppy.sh/api/v2/me",Patreon:"https://www.patreon.com/api/oauth2/v2/identity",Reddit:"https://oauth.reddit.com/api/v1/me",Roblox:"https://apis.roblox.com/users/v1/users/me",Salesforce:"https://login.salesforce.com/services/oauth2/userinfo",Shikimori:"https://shikimori.one/api/users/whoami",Slack:"https://slack.com/api/users.identity",Spotify:"https://api.spotify.com/v1/me",Strava:"https://www.strava.com/api/v3/athlete",Tiltify:"https://tiltify.com/api/v3/user",Tumblr:"https://api.tumblr.com/v2/user/info",Twitch:"https://api.twitch.tv/helix/users",Twitter:"https://api.twitter.com/2/users/me",VK:"https://api.vk.com/method/users.get",WorkOS:"https://api.workos.com/sso/profile",Yahoo:"https://api.login.yahoo.com/openid/v1/userinfo",Yandex:"https://login.yandex.ru/info",Zoom:"https://api.zoom.us/v2/users/me",FortyTwo:"https://api.intra.42.fr/v2/me"},ZW={AmazonCognito:"https://cognito-idp.{region}.amazonaws.com/{userPoolId}",AniList:"https://anilist.co/api/v2/oauth/authorize",Apple:"https://appleid.apple.com",Atlassian:"https://auth.atlassian.com",Auth0:"https://{your_domain}.auth0.com",Authentik:"https://{your_domain}",Bitbucket:"https://bitbucket.org/site/oauth2/authorize",Box:"https://account.box.com/api/oauth2/authorize",Coinbase:"https://www.coinbase.com/oauth/authorize",Discord:"https://discord.com/api/oauth2/authorize",Dribbble:"https://dribbble.com/oauth/authorize",Dropbox:"https://www.dropbox.com/oauth2/authorize",Facebook:"https://www.facebook.com/v12.0/dialog/oauth",Figma:"https://www.figma.com/oauth",Intuit:"https://appcenter.intuit.com/connect/oauth2",GitHub:"https://github.com/login/oauth/authorize",GitLab:"https://gitlab.com/oauth/authorize",Google:"https://accounts.google.com",Kakao:"https://kauth.kakao.com/oauth/authorize",KeyCloak:"https://{your_domain}/auth",Lichess:"https://lichess.org/oauth/authorize",Line:"https://access.line.me/oauth2/v2.1/authorize",Linear:"https://linear.app/oauth/authorize",LinkedIn:"https://www.linkedin.com/oauth/v2/authorization",MicrosoftEntraId:"https://login.microsoftonline.com/{tenant}/v2.0",MyAnimeList:"https://myanimelist.net/v1/oauth2/authorize",Notion:"https://api.notion.com/v1/oauth/authorize",Okta:"https://{yourOktaDomain}/oauth2/default/v1/authorize",Osu:"https://osu.ppy.sh/oauth/authorize",Patreon:"https://www.patreon.com/oauth2/authorize",Reddit:"https://www.reddit.com/api/v1/authorize",Roblox:"https://apis.roblox.com/oauth/v1/authorize",Salesforce:"https://login.salesforce.com/services/oauth2/authorize",Shikimori:"https://shikimori.one/oauth/authorize",Slack:"https://slack.com/oauth/v2/authorize",Spotify:"https://accounts.spotify.com/authorize",Strava:"https://www.strava.com/oauth/authorize",Tiltify:"https://tiltify.com/oauth/authorize",Tumblr:"https://www.tumblr.com/oauth/authorize",Twitch:"https://id.twitch.tv/oauth2/authorize",Twitter:"https://api.twitter.com/oauth/authorize",VK:"https://oauth.vk.com/authorize",WorkOS:"https://api.workos.com/sso/authorize",Yahoo:"https://api.login.yahoo.com/oauth2/request_auth",Yandex:"https://oauth.yandex.com/authorize",Zoom:"https://zoom.us/oauth/authorize",FortyTwo:"https://api.intra.42.fr/oauth/authorize"},JW=Object.keys(Aw).reduce((w,z)=>{return w[z.toLowerCase()]=z,w},{}),ag=Object.keys(ZW).reduce((w,z)=>{return w[z.toLowerCase()]=z,w},{});var YW=({logoutRoute:w="logout",onLogout:z})=>{return new F0().post(`/${w}`,async({error:A,cookie:{user_session_id:U,auth_provider:W}})=>{if(W.value===void 0)return A(401,"No auth provider found");try{return z?.(),U.remove(),W.remove(),new Response("Succesfuly Logged Out",{status:204})}catch($){if($ instanceof Error)console.error("Failed to refresh token:",$.message);return A(500)}})};var qW=(w)=>{return"refreshAccessToken"in w&&typeof w.refreshAccessToken==="function"};var Y6=(w)=>{return Object.keys(zw).map((z)=>z.toLowerCase()).includes(w.toLowerCase())},BW=(w)=>{return Object.keys(Aw).includes(w)};var MW=(w)=>{return!0};var HW=({clientProviders:w,revokeRoute:z="revoke",onRevoke:A})=>{return new F0().post(`/${z}/access-token`,async({error:U,cookie:{user_refresh_token:W,auth_provider:$}})=>{if(W.value===void 0)return U(401,"No refresh token found");if($.value===void 0)return U(401,"No auth provider found");if(!Y6($.value))return U(400,"Invalid provider");let X=$.value.toLowerCase(),{providerInstance:Q}=w[X];A?.()})};var G4=()=>{return new F0({name:"sessionStore"}).state({session:{}})};var GW=({statusRoute:w="auth-status",onStatus:z})=>{return new F0().use(G4()).get(`/${w}`,async({error:A,cookie:{user_session_id:U,auth_provider:W},store:{session:$}})=>{try{if(U.value===void 0)return new Response(JSON.stringify({user:null}),{headers:{"Content-Type":"application/json"}});if(W.value===void 0)return new Response(JSON.stringify({user:null}),{headers:{"Content-Type":"application/json"}});let X=$[U.value];if(X===void 0)return new Response(JSON.stringify({user:null}),{headers:{"Content-Type":"application/json"}});let Q=X.user;return z?.(),new Response(JSON.stringify({user:Q}),{headers:{"Content-Type":"application/json"}})}catch(X){if(X instanceof Error)console.error("Failed to get auth status: ",X.message);return A(500)}})};var LW=({clientProviders:w,refreshRoute:z="refresh",onRefresh:A})=>{return new F0().post(`/${z}`,async({error:U,cookie:{user_refresh_token:W,auth_provider:$}})=>{if(W.value===void 0)return U(401,"No refresh token found");if($.value===void 0)return U(401,"No auth provider found");let X=$.value.toLowerCase(),{providerInstance:Q}=w[X];if(!qW(Q))return U(401,"Provider is not refreshable");try{let Z=await Q.refreshAccessToken(W.value);return A?.(),new Response("Token refreshed",{status:204})}catch(Z){if(Z instanceof Error)console.error("Failed to refresh token:",Z.message);return U(500)}})};var bW=({clientProviders:w,authorizeRoute:z="authorize",onAuthorize:A})=>{return new F0().get(`/${z}/:provider`,({error:U,redirect:W,cookie:{state:$,code_verifier:X,auth_provider:Q,redirect_url:Z},params:{provider:J},headers:Y})=>{if(J===void 0)return U(400,"Provider is required");if(!Y6(J))return U(400,"Invalid provider");try{let L=J.toLowerCase(),{providerInstance:_,scopes:G,searchParams:O}=w[L],C=Y.referer||"/";Z.set({value:C,secure:!0,sameSite:"lax",path:"/",httpOnly:!0,maxAge:600}),Q.set({value:J,secure:!0,sameSite:"lax",path:"/",httpOnly:!0,maxAge:600});let q=Dz();$.set({value:q,secure:!0,sameSite:"lax",path:"/",httpOnly:!0,maxAge:600});let o,W0;if(_.createAuthorizationURL.toString().includes("codeVerifier"))W0=Sz(),X.set({value:W0,secure:!0,sameSite:"lax",path:"/",httpOnly:!0,maxAge:600}),o=_.createAuthorizationURL(q,W0,G);else o=_.createAuthorizationURL(q,G);return O.forEach(([L0,c])=>{o.searchParams.set(L0,c)}),A?.(),W(o.toString())}catch(L){if(L instanceof Error)console.error("Failed to validate authorization code:",L.message);return U(500)}})};var NW=({clientProviders:w,callbackRoute:z="authorize/callback",onCallback:A,getUser:U,createUser:W})=>{return new F0().use(G4()).get(`/${z}`,async({error:$,redirect:X,store:{session:Q},cookie:{state:Z,code_verifier:J,redirect_url:Y,user_session_id:L,auth_provider:_},query:{code:G,state:O}})=>{if(!G||!Z.value)return $(400,"Invalid callback request");if(O!==Z.value)return $(400,"Invalid state mismatch");if(_.value===void 0)return $(401,"No auth provider found");if(!Y6(_.value))return $(400,"Invalid provider");let C=_.value.toLowerCase(),{providerInstance:q}=w[C];try{let o;if(Z.remove(),q.validateAuthorizationCode.toString().includes("codeVerifier")){if(!J.value)return $(400,"Code verifier not found and is required");o=await q.validateAuthorizationCode(G,J.value),J.remove()}else o=await q.validateAuthorizationCode(G);let W0=Oz(o.idToken()),L0=_.value,c=await U?.({decodedIdToken:W0,authProvider:L0});if(c===null||c===void 0)c=await W?.({decodedIdToken:W0,authProvider:L0});let e=crypto.randomUUID();if(!MW(c))return $(500,"Invalid user schema");Q[e]={user:c,expiresAt:Date.now()+86400000},L.set({value:e,secure:!0,httpOnly:!0,sameSite:"lax"}),A?.();let f=Y.value??"/";return X(f)}catch(o){if(o instanceof Error)console.error("Failed to validate authorization code:",o.message);return $(500)}})};var SW=()=>{return new F0().use(G4()).derive(({store:{session:w},cookie:{user_session_id:z},error:A})=>{return{protectRoute:async(U,W)=>{if(z.value===void 0)return W?.()??A(401,"No session ID found");if(w[z.value]===void 0)return W?.()??A(401,"No session found");return U()}}}).as("plugin")};var dT=({config:w,authorizeRoute:z,callbackRoute:A,logoutRoute:U,statusRoute:W,refreshRoute:$,revokeRoute:X,onAuthorize:Q,onCallback:Z,onStatus:J,onRefresh:Y,onLogout:L,onRevoke:_,createUser:G,getUser:O})=>{let C=Object.entries(w).reduce((q,[o,W0={}])=>{let L0=o.toLowerCase(),c=QW[L0],e=JW[L0];if(!c||!Y6(c))return console.error(`Provider ${o} is not supported`),q;let f=zw[c],t;if(BW(e))t=Aw[e];let{credentials:K=[],scopes:l=[],searchParams:D0=[]}=W0,s=new f(...K);return q[L0]={providerInstance:s,scopes:l,searchParams:D0,userInfoURL:t},q},{});return new F0().error("OAUTH2_REQUEST_ERROR",e4).error("ARCTIC_FETCH_ERROR",J6).use(YW({logoutRoute:U,onLogout:L})).use(HW({clientProviders:C,revokeRoute:X,onRevoke:_})).use(GW({statusRoute:W,onStatus:J})).use(LW({clientProviders:C,refreshRoute:$,onRefresh:Y})).use(bW({clientProviders:C,authorizeRoute:z,onAuthorize:Q})).use(NW({clientProviders:C,callbackRoute:A,onCallback:Z,getUser:O,createUser:G})).use(SW()).as("plugin")};export{dT as absoluteAuth};
317
+ `,z.mapResponse.length){U+=`let mr
318
+ `;for(let Y=0;Y<z.mapResponse.length;Y++){let B=z.mapResponse[Y],G=Q.resolveChild(B.fn.name);U+=`if(mr===undefined){mr=${e6(B)?"await ":""}onMapResponse[${Y}](context)
319
+ if(mr!==undefined)error=context.response=mr}`,G()}}return Q.resolve(),U+=`
320
+ return mapResponse(${$}error,set${W.mapResponseContext})}`,Function("inject",U)({app:w,mapResponse:w["~adapter"].handler.mapResponse,ERROR_CODE:k8,ElysiaCustomStatusResponse:M1,ELYSIA_TRACE:vw,ELYSIA_REQUEST_ID:d8,...W.inject})},gw=(w,z)=>{for(let[U,W]of Object.entries(w.schema.properties))z[U]??=W.default},jU=(w)=>{let{mapResponse:z,mapEarlyResponse:U}=w["~adapter"].handler;return async(W)=>{let A=W.url,X=A.indexOf("/",11),Z=A.indexOf("?",X+1),$=Z===-1?A.substring(X):A.substring(X,Z),Q={cookie:{},status:200,headers:{}},Y=Object.assign({},w.singleton.decorator,{set:Q,store:w.singleton.store,request:W,path:$,qi:Z,redirect:TU});try{for(let x=0;x<w.event.request.length;x++){let i=w.event.request[x].fn,K=i(Y);if(K instanceof Promise)K=await K;if(K=U(K,Q),K)return Y.response=K}let B=w.router.dynamic.find(W.method,$)??w.router.dynamic.find("ALL",$);if(!B)throw new h8;let{handle:G,hooks:_,validator:H,content:F}=B.store,R;if(W.method!=="GET"&&W.method!=="HEAD")if(F)switch(F){case"application/json":R=await W.json();break;case"text/plain":R=await W.text();break;case"application/x-www-form-urlencoded":R=x8(await W.text());break;case"application/octet-stream":R=await W.arrayBuffer();break;case"multipart/form-data":R={};let x=await W.formData();for(let i of x.keys()){if(R[i])continue;let K=x.getAll(i);if(K.length===1)R[i]=K[0];else R[i]=K}break}else{let x=W.headers.get("content-type");if(x){let i=x.indexOf(";");if(i!==-1)x=x.slice(0,i);Y.contentType=x;for(let K=0;K<_.parse.length;K++){let o=_.parse[K].fn,D0=o(Y,x);if(D0 instanceof Promise)D0=await D0;if(D0){R=D0;break}}if(delete Y.contentType,R===void 0)switch(x){case"application/json":R=await W.json();break;case"text/plain":R=await W.text();break;case"application/x-www-form-urlencoded":R=x8(await W.text());break;case"application/octet-stream":R=await W.arrayBuffer();break;case"multipart/form-data":R={};let K=await W.formData();for(let o of K.keys()){if(R[o])continue;let D0=K.getAll(o);if(D0.length===1)R[o]=D0[0];else R[o]=D0}break}}}Y.body=R,Y.params=B?.params||void 0,Y.query=Z===-1?{}:x8(A.substring(Z+1)),Y.headers={};for(let[x,i]of W.headers.entries())Y.headers[x]=i;let J=Object.assign({},w.config?.cookie,H?.cookie?.config),m=W.headers.get("cookie");Y.cookie=await tU(Y.set,m,J?{secrets:J.secrets!==void 0?typeof J.secrets==="string"?J.secrets:J.secrets.join(","):void 0,sign:J.sign===!0?!0:J.sign!==void 0?typeof J.sign==="string"?J.sign:J.sign.join(","):void 0}:void 0);let A0=H?.createHeaders?.();if(A0)gw(A0,Y.headers);let L0=H?.createParams?.();if(L0)gw(L0,Y.params);let h=H?.createQuery?.();if(h)gw(h,Y.query);for(let x=0;x<_.transform.length;x++){let i=_.transform[x],K=i.fn(Y);if(i.subType==="derive")if(K instanceof Promise)Object.assign(Y,await K);else Object.assign(Y,K);else if(K instanceof Promise)await K}if(H){if(A0){let x=structuredClone(Y.headers);for(let[i,K]of W.headers)x[i]=K;if(H.headers.Check(x)===!1)throw new Z0("header",H.headers,x)}else if(H.headers?.Decode)Y.headers=H.headers.Decode(Y.headers);if(L0?.Check(Y.params)===!1)throw new Z0("params",H.params,Y.params);else if(H.params?.Decode)Y.params=H.params.Decode(Y.params);if(h?.Check(Y.query)===!1)throw new Z0("query",H.query,Y.query);else if(H.query?.Decode)Y.query=H.query.Decode(Y.query);if(H.createCookie?.()){let x={};for(let[i,K]of Object.entries(Y.cookie))x[i]=K.value;if(H.cookie.Check(x)===!1)throw new Z0("cookie",H.cookie,x);else if(H.cookie?.Decode)x=H.cookie.Decode(x)}if(H.createBody?.()?.Check(R)===!1)throw new Z0("body",H.body,R);else if(H.body?.Decode)Y.body=H.body.Decode(R)}for(let x=0;x<_.beforeHandle.length;x++){let i=_.beforeHandle[x],K=i.fn(Y);if(i.subType==="resolve"){if(K instanceof M1){let o=U(K,Y.set);if(o)return Y.response=o}if(K instanceof Promise)Object.assign(Y,await K);else Object.assign(Y,K);continue}else if(K instanceof Promise)K=await K;if(K!==void 0){Y.response=K;for(let D0=0;D0<_.afterHandle.length;D0++){let l=_.afterHandle[D0].fn(Y);if(l instanceof Promise)l=await l;if(l)K=l}let o=U(K,Y.set);if(o)return Y.response=o}}let a=typeof G==="function"?G(Y):G;if(a instanceof Promise)a=await a;if(!_.afterHandle.length){let x=a instanceof M1?a.code:Q.status?typeof Q.status==="string"?f8[Q.status]:Q.status:200,i=H?.createResponse?.()?.[x];if(i?.Check(a)===!1)throw new Z0("response",i,a);else if(i?.Decode)a=i.Decode(a)}else{Y.response=a;for(let x=0;x<_.afterHandle.length;x++){let i=_.afterHandle[x].fn(Y);if(i instanceof Promise)i=await i;let K=U(i,Y.set);if(K!==void 0){let o=H?.response?.[K.status];if(o?.Check(K)===!1)throw new Z0("response",o,K);else if(o?.Decode)a=o.Decode(a);return Y.response=K}}}if(Y.set.cookie&&J?.sign){let x=!J.secrets?void 0:typeof J.secrets==="string"?J.secrets:J.secrets[0];if(J.sign===!0)for(let[i,K]of Object.entries(Y.set.cookie))Y.set.cookie[i].value=await V8(K.value,"${secret}");else{let i=H?.cookie?.schema?.properties;for(let K of J.sign){if(!(K in i))continue;if(Y.set.cookie[K]?.value)Y.set.cookie[K].value=await V8(Y.set.cookie[K].value,x)}}}return z(Y.response=a,Y.set)}catch(B){let G=B instanceof L8&&B.error?B.error:B;return w.handleError(Y,G)}finally{for(let B of w.event.afterResponse)await B.fn(Y)}}},cH=(w)=>{let{mapResponse:z}=w["~adapter"].handler;return async(U,W)=>{let A=Object.assign(U,{error:W,code:W.code});A.set=U.set;for(let X=0;X<w.event.error.length;X++){let Z=w.event.error[X].fn(A);if(Z instanceof Promise)Z=await Z;if(Z!==void 0&&Z!==null)return U.response=z(Z,U.set)}return new Response(typeof W.cause==="string"?W.cause:W.message,{headers:U.set.headers,status:W.status??500})}};class j0{config;server=null;dependencies={};_routes={};_types={Prefix:"",Singleton:{},Definitions:{},Metadata:{}};_ephemeral={};_volatile={};singleton={decorator:{},store:{},derive:{},resolve:{}};get store(){return this.singleton.store}get decorator(){return this.singleton.decorator}definitions={typebox:I.Module({}),type:{},error:{}};extender={macros:[],higherOrderFunctions:[]};validator={global:null,scoped:null,local:null,getCandidate(){return I4(I4(this.global,this.scoped),this.local)}};event={start:[],request:[],parse:[],transform:[],beforeHandle:[],afterHandle:[],mapResponse:[],afterResponse:[],trace:[],error:[],stop:[]};telemetry={stack:void 0};router={http:new u1,ws:new u1,dynamic:new u1,static:{http:{static:{},map:{},all:""},ws:{}},history:[]};routeTree=new Map;get routes(){return this.router.history}getGlobalRoutes(){return this.router.history}inference={body:!1,cookie:!1,headers:!1,query:!1,set:!1,server:!1,request:!1,route:!1};getServer(){return this.server}"~parser"={};_promisedModules;get promisedModules(){if(!this._promisedModules)this._promisedModules=new kU;return this._promisedModules}constructor(w={}){if(w.tags)if(!w.detail)w.detail={tags:w.tags};else w.detail.tags=w.tags;if(w.nativeStaticResponse===void 0)w.nativeStaticResponse=!0;if(this.config={},this.applyConfig(w??{}),this["~adapter"]=w.adapter??(typeof Bun!=="undefined"?VH:I8),w?.analytic&&(w?.name||w?.seed!==void 0))this.telemetry.stack=new Error().stack}"~adapter";env(w,z=FU){if(j2(w,{modules:this.definitions.typebox,dynamic:!0,additionalProperties:!0,coerce:!0}).Check(z)===!1){let U=new Z0("env",w,z);throw new Error(U.all.map((W)=>W.summary).join(`
321
+ `))}return this}wrap(w){return this.extender.higherOrderFunctions.push({checksum:x4(JSON.stringify({name:this.config.name,seed:this.config.seed,content:w.toString()})),fn:w}),this}applyMacro(w){if(this.extender.macros.length){let z=qH({globalHook:this.event,localHook:w}),U={events:{global:this.event,local:w},get onParse(){return z("parse")},get onTransform(){return z("transform")},get onBeforeHandle(){return z("beforeHandle")},get onAfterHandle(){return z("afterHandle")},get mapResponse(){return z("mapResponse")},get onAfterResponse(){return z("afterResponse")},get onError(){return z("error")}};for(let W of this.extender.macros)MH(W.fn(U),w,z)}}applyConfig(w){return this.config={prefix:"",aot:FU.ELYSIA_AOT!=="false",normalize:!0,...w,cookie:{path:"/",...w?.cookie},experimental:w?.experimental??{},seed:w?.seed===void 0?"":w?.seed},this}get models(){let w={};for(let z of Object.keys(this.definitions.type))w[z]=j2(this.definitions.typebox.Import(z));return w.modules=this.definitions.typebox,w}add(w,z,U,W,{allowMeta:A=!1,skipPrefix:X=!1}={allowMeta:!1,skipPrefix:!1}){if(W=GH(W),z!==""&&z.charCodeAt(0)!==47)z="/"+z;if(this.config.prefix&&!X)z=this.config.prefix+z;if(W?.type)switch(W.type){case"text":W.type="text/plain";break;case"json":W.type="application/json";break;case"formdata":W.type="multipart/form-data";break;case"urlencoded":W.type="application/x-www-form-urlencoded";break;case"arrayBuffer":W.type="application/octet-stream";break;default:break}let Z=this.definitions.type,$=!this.config.aot,Q={...this.validator.getCandidate()},Y={body:W?.body??Q?.body,headers:W?.headers??Q?.headers,params:W?.params??Q?.params,query:W?.query??Q?.query,cookie:W?.cookie??Q?.cookie,response:W?.response??Q?.response},B=()=>Y.cookie?VU({modules:_,validator:Y.cookie,defaultConfig:this.config.cookie,config:Y.cookie?.config??{},dynamic:$,models:Z}):void 0,G=this.config.normalize,_=this.definitions.typebox,H=this.config.precompile===!0||typeof this.config.precompile==="object"&&this.config.precompile.schema===!0?{body:j2(Y.body,{modules:_,dynamic:$,models:Z,normalize:G,additionalCoerce:HU()}),headers:j2(Y.headers,{modules:_,dynamic:$,models:Z,additionalProperties:!this.config.normalize,coerce:!0,additionalCoerce:P6()}),params:j2(Y.params,{modules:_,dynamic:$,models:Z,coerce:!0,additionalCoerce:P6()}),query:j2(Y.query,{modules:_,dynamic:$,models:Z,normalize:G,coerce:!0,additionalCoerce:P6()}),cookie:B(),response:qU(Y.response,{modules:_,dynamic:$,models:Z,normalize:G})}:{createBody(){if(this.body)return this.body;return this.body=j2(Y.body,{modules:_,dynamic:$,models:Z,normalize:G,additionalCoerce:HU()})},createHeaders(){if(this.headers)return this.headers;return this.headers=j2(Y.headers,{modules:_,dynamic:$,models:Z,additionalProperties:!G,coerce:!0,additionalCoerce:P6()})},createParams(){if(this.params)return this.params;return this.params=j2(Y.params,{modules:_,dynamic:$,models:Z,coerce:!0,additionalCoerce:P6()})},createQuery(){if(this.query)return this.query;return this.query=j2(Y.query,{modules:_,dynamic:$,models:Z,coerce:!0,additionalCoerce:P6()})},createCookie(){if(this.cookie)return this.cookie;return this.cookie=B()},createResponse(){if(this.response)return this.response;return this.response=qU(Y.response,{modules:_,dynamic:$,models:Z,normalize:G})}};if(W=D1(W,Q),W.tags)if(!W.detail)W.detail={tags:W.tags};else W.detail.tags=W.tags;if(s2(this.config.detail))W.detail=F2(Object.assign({},this.config.detail),W.detail);this.applyMacro(W);let F=D1(this.event,W);if(this.config.aot===!1){if(this.router.dynamic.add(w,z,{validator:H,hooks:F,content:W?.type,handle:U}),this.config.strictPath===!1)this.router.dynamic.add(w,r6(z),{validator:H,hooks:F,content:W?.type,handle:U});this.router.history.push({method:w,path:z,composed:null,handler:U,hooks:F,compile:U});return}let R=this.config.precompile===!0||typeof this.config.precompile==="object"&&this.config.precompile.compose===!0,J=Vw(this.inference),m=this["~adapter"].handler,A0=typeof U!=="function"&&typeof m.createStaticHandler==="function"?m.createStaticHandler(U,F,this.setHeaders):void 0,L0=typeof U!=="function"?m.createNativeStaticHandler?.(U,F,this.setHeaders):void 0;if(this.config.nativeStaticResponse===!0&&L0&&(w==="GET"||w==="ALL"))this.router.static.http.static[z]=L0();let h=(l=!1)=>yH({app:this,path:z,method:w,localHook:D1(W),hooks:F,validator:H,handler:typeof U!=="function"&&typeof m.createStaticHandler!=="function"?()=>U:U,allowMeta:A,inference:J,asManifest:l});if(this.routeTree.has(w+z))for(let l=0;l<this.router.history.length;l++){let O1=this.router.history[l];if(O1.path===z&&O1.method===w){let C0=this.router.history.splice(l,1)[0];if(C0&&this.routeTree.has(C0?.method+C0?.path))this.routeTree.delete(C0.method+C0.path)}}else this.routeTree.set(w+z,this.router.history.length);let a=this.router.history,x=this.router.history.length,i=R?h():(l)=>(a[x].composed=h())(l),K=w==="$INTERNALWS";this.router.history.push({method:w,path:z,composed:i,handler:U,hooks:F,compile:()=>h(),websocket:W.websocket});let o=this.router.static.http,D0={handler:R?i:void 0,compile:h};if(K){let l=r6(z);if(z.indexOf(":")===-1&&z.indexOf("*")===-1)this.router.static.ws[z]=x;else if(this.router.ws.add("ws",z,D0),l)this.router.ws.add("ws",l,D0);return}if(z.indexOf(":")===-1&&z.indexOf("*")===-1){if(!o.map[z])o.map[z]={code:""};let l=A0?"":"c";if(w==="ALL")o.map[z].all=`default:return ht[${x}].composed(${l})
322
+ `;else o.map[z].code=`case '${w}':return ht[${x}].composed(${l})
323
+ ${o.map[z].code}`;if(!this.config.strictPath&&this.config.nativeStaticResponse===!0&&L0&&(w==="GET"||w==="ALL"))this.router.static.http.static[r6(z)]=L0()}else if(this.router.http.add(w,z,D0),!this.config.strictPath){let l=r6(z);if(this.config.nativeStaticResponse===!0&&A0&&(w==="GET"||w==="ALL"))this.router.static.http.static[l]=A0();this.router.http.add(w,l,D0)}}setHeaders;headers(w){if(!w)return this;if(!this.setHeaders)this.setHeaders={};return this.setHeaders=F2(this.setHeaders,w),this}onStart(w){return this.on("start",w),this}onRequest(w){return this.on("request",w),this}onParse(w,z){if(!z){if(typeof w==="string")return this.on("parse",this["~parser"][w]);return this.on("parse",w)}return this.on(w,"parse",z)}parser(w,z){return this["~parser"][w]=z,this}onTransform(w,z){if(!z)return this.on("transform",w);return this.on(w,"transform",z)}resolve(w,z){if(!z)z=w,w={as:"local"};let U={subType:"resolve",fn:z};return this.onBeforeHandle(w,U)}mapResolve(w,z){if(!z)z=w,w={as:"local"};let U={subType:"mapResolve",fn:z};return this.onBeforeHandle(w,U)}onBeforeHandle(w,z){if(!z)return this.on("beforeHandle",w);return this.on(w,"beforeHandle",z)}onAfterHandle(w,z){if(!z)return this.on("afterHandle",w);return this.on(w,"afterHandle",z)}mapResponse(w,z){if(!z)return this.on("mapResponse",w);return this.on(w,"mapResponse",z)}onAfterResponse(w,z){if(!z)return this.on("afterResponse",w);return this.on(w,"afterResponse",z)}trace(w,z){if(!z)z=w,w={as:"local"};if(!Array.isArray(z))z=[z];for(let U of z)this.on(w,"trace",gH(U));return this}error(w,z){switch(typeof w){case"string":return z.prototype[k8]=w,this.definitions.error[w]=z,this;case"function":return this.definitions.error=w(this.definitions.error),this}for(let[U,W]of Object.entries(w))W.prototype[k8]=U,this.definitions.error[U]=W;return this}onError(w,z){if(!z)return this.on("error",w);return this.on(w,"error",z)}onStop(w){return this.on("stop",w),this}on(w,z,U){let W;switch(typeof w){case"string":W=w,U=z;break;case"object":if(W=z,!Array.isArray(z)&&typeof z==="object")U=z;break}if(Array.isArray(U))U=W2(U);else if(typeof U==="function")U=[{fn:U}];else U=[U];let A=U;for(let X of A)if(X.scope=typeof w==="string"?"local":w?.as??"local",W==="resolve"||W==="derive")X.subType=W;if(W!=="trace")uU({[W]:A.map((X)=>X.fn)},this.inference);for(let X of A){let Z=JH(X,"global",{skipIfHasType:!0});switch(W){case"start":this.event.start.push(Z);break;case"request":this.event.request.push(Z);break;case"parse":this.event.parse.push(Z);break;case"transform":this.event.transform.push(Z);break;case"derive":this.event.transform.push(W2(Z,"derive"));break;case"beforeHandle":this.event.beforeHandle.push(Z);break;case"resolve":this.event.beforeHandle.push(W2(Z,"resolve"));break;case"afterHandle":this.event.afterHandle.push(Z);break;case"mapResponse":this.event.mapResponse.push(Z);break;case"afterResponse":this.event.afterResponse.push(Z);break;case"trace":this.event.trace.push(Z);break;case"error":this.event.error.push(Z);break;case"stop":this.event.stop.push(Z);break}}return this}propagate(){return J2(this.event.parse),J2(this.event.transform),J2(this.event.beforeHandle),J2(this.event.afterHandle),J2(this.event.mapResponse),J2(this.event.afterResponse),J2(this.event.trace),J2(this.event.error),this}as(w){let z={plugin:"scoped",scoped:"scoped",global:"global"}[w];if(J2(this.event.parse,z),J2(this.event.transform,z),J2(this.event.beforeHandle,z),J2(this.event.afterHandle,z),J2(this.event.mapResponse,z),J2(this.event.afterResponse,z),J2(this.event.trace,z),J2(this.event.error,z),w==="plugin")this.validator.scoped=I4(this.validator.scoped,this.validator.local),this.validator.local=null;else if(w==="global")this.validator.global=I4(this.validator.global,I4(this.validator.scoped,this.validator.local)),this.validator.scoped=null,this.validator.local=null;return this}group(w,z,U){let W=new j0({...this.config,prefix:""});W.singleton={...this.singleton},W.definitions={...this.definitions},W.getServer=()=>this.getServer(),W.inference=Vw(this.inference),W.extender={...this.extender};let A=typeof z==="object",X=(A?U:z)(W);if(this.singleton=F2(this.singleton,W.singleton),this.definitions=F2(this.definitions,W.definitions),X.event.request.length)this.event.request=[...this.event.request||[],...X.event.request||[]];if(X.event.mapResponse.length)this.event.mapResponse=[...this.event.mapResponse||[],...X.event.mapResponse||[]];return this.model(X.definitions.type),Object.values(W.router.history).forEach(({method:Z,path:$,handler:Q,hooks:Y})=>{if($=(A?"":this.config.prefix)+w+$,A){let B=z,G=Y;this.add(Z,$,Q,D1(B,{...G||{},error:!G.error?X.event.error:Array.isArray(G.error)?[...G.error||{},...X.event.error||{}]:[G.error,...X.event.error||{}]}))}else this.add(Z,$,Q,D1(Y,{error:X.event.error}),{skipPrefix:!0})}),this}guard(w,z){if(!z){if(typeof w==="object"){this.applyMacro(w);let A=w.as??"local";if(this.validator[A]={body:w.body??this.validator[A]?.body,headers:w.headers??this.validator[A]?.headers,params:w.params??this.validator[A]?.params,query:w.query??this.validator[A]?.query,response:w.response??this.validator[A]?.response,cookie:w.cookie??this.validator[A]?.cookie},w.parse)this.on({as:A},"parse",w.parse);if(w.transform)this.on({as:A},"transform",w.transform);if(w.derive)this.on({as:A},"derive",w.derive);if(w.beforeHandle)this.on({as:A},"beforeHandle",w.beforeHandle);if(w.resolve)this.on({as:A},"resolve",w.resolve);if(w.afterHandle)this.on({as:A},"afterHandle",w.afterHandle);if(w.mapResponse)this.on({as:A},"mapResponse",w.mapResponse);if(w.afterResponse)this.on({as:A},"afterResponse",w.afterResponse);if(w.error)this.on({as:A},"error",w.error);if(w.detail)if(this.config.detail)this.config.detail=F2(Object.assign({},this.config.detail),w.detail);else this.config.detail=w.detail;if(w?.tags)if(!this.config.detail)this.config.detail={tags:w.tags};else this.config.detail.tags=w.tags;return this}return this.guard({},w)}let U=new j0({...this.config,prefix:""});U.singleton={...this.singleton},U.definitions={...this.definitions},U.inference=Vw(this.inference),U.extender={...this.extender};let W=z(U);if(this.singleton=F2(this.singleton,U.singleton),this.definitions=F2(this.definitions,U.definitions),W.getServer=()=>this.server,W.event.request.length)this.event.request=[...this.event.request||[],...W.event.request||[]];if(W.event.mapResponse.length)this.event.mapResponse=[...this.event.mapResponse||[],...W.event.mapResponse||[]];return this.model(W.definitions.type),Object.values(U.router.history).forEach(({method:A,path:X,handler:Z,hooks:$})=>{this.add(A,X,Z,D1(w,{...$||{},error:!$.error?W.event.error:Array.isArray($.error)?[...$.error||{},...W.event.error||[]]:[$.error,...W.event.error||[]]}))}),this}use(w,z){if(Array.isArray(w)){let U=this;for(let W of w)U=U.use(W);return U}if(z?.scoped)return this.guard({},(U)=>U.use(w));if(Array.isArray(w)){let U=this;for(let W of w)U=this.use(W);return U}if(w instanceof Promise)return this.promisedModules.add(w.then((U)=>{if(typeof U==="function")return U(this);if(U instanceof j0)return this._use(U).compile();if(U.constructor.name==="Elysia")return this._use(U).compile();if(typeof U.default==="function")return U.default(this);if(U.default instanceof j0)return this._use(U.default);if(U.constructor.name==="Elysia")return this._use(U.default);throw new Error('Invalid plugin type. Expected Elysia instance, function, or module with "default" as Elysia instance or function that returns Elysia instance.')}).then((U)=>U.compile())),this;return this._use(w)}_use(w){if(typeof w==="function"){let A=w(this);if(A instanceof Promise)return this.promisedModules.add(A.then((X)=>{if(X instanceof j0){X.getServer=()=>this.getServer(),X.getGlobalRoutes=()=>this.getGlobalRoutes(),X.model(this.definitions.type),X.error(this.definitions.error);for(let{method:Z,path:$,handler:Q,hooks:Y}of Object.values(X.router.history))this.add(Z,$,Q,D1(Y,{error:X.event.error}));return X.compile(),X}if(typeof X==="function")return X(this);if(typeof X.default==="function")return X.default(this);return this._use(X)}).then((X)=>X.compile())),this;return A}let{name:z,seed:U}=w.config;if(w.getServer=()=>this.getServer(),w.getGlobalRoutes=()=>this.getGlobalRoutes(),w.model(this.definitions.type),w.error(this.definitions.error),this["~parser"]={...w["~parser"],...this["~parser"]},this.headers(w.setHeaders),z){if(!(z in this.dependencies))this.dependencies[z]=[];let A=U!==void 0?x4(z+JSON.stringify(U)):0;if(!this.dependencies[z].some(({checksum:X})=>A===X))this.extender.macros=this.extender.macros.concat(w.extender.macros),this.extender.higherOrderFunctions=this.extender.higherOrderFunctions.concat(w.extender.higherOrderFunctions)}else this.extender.macros=this.extender.macros.concat(w.extender.macros),this.extender.higherOrderFunctions=this.extender.higherOrderFunctions.concat(w.extender.higherOrderFunctions);PU(this.extender.macros),PU(this.extender.higherOrderFunctions);let W=[];for(let A=0;A<this.extender.higherOrderFunctions.length;A++){let X=this.extender.higherOrderFunctions[A];if(X.checksum){if(W.includes(X.checksum))this.extender.higherOrderFunctions.splice(A,1),A--;W.push(X.checksum)}}this.inference={body:this.inference.body||w.inference.body,cookie:this.inference.cookie||w.inference.cookie,headers:this.inference.headers||w.inference.headers,query:this.inference.query||w.inference.query,set:this.inference.set||w.inference.set,server:this.inference.server||w.inference.server,request:this.inference.request||w.inference.request,route:this.inference.route||w.inference.route},this.decorate(w.singleton.decorator),this.state(w.singleton.store),this.model(w.definitions.type),this.error(w.definitions.error),w.extender.macros=this.extender.macros.concat(w.extender.macros);for(let{method:A,path:X,handler:Z,hooks:$}of Object.values(w.router.history))this.add(A,X,Z,D1($,{error:w.event.error}));if(z){if(!(z in this.dependencies))this.dependencies[z]=[];let A=U!==void 0?x4(z+JSON.stringify(U)):0;if(this.dependencies[z].some(({checksum:X})=>A===X))return this;this.dependencies[z].push(this.config?.analytic?{name:w.config.name,seed:w.config.seed,checksum:A,dependencies:w.dependencies,stack:w.telemetry.stack,routes:w.router.history,decorators:w.singleton,store:w.singleton.store,error:w.definitions.error,derive:w.event.transform.filter((X)=>X?.subType==="derive").map((X)=>({fn:X.toString(),stack:new Error().stack??""})),resolve:w.event.transform.filter((X)=>X?.subType==="resolve").map((X)=>({fn:X.toString(),stack:new Error().stack??""}))}:{name:w.config.name,seed:w.config.seed,checksum:A,dependencies:w.dependencies}),this.event=GU(this.event,LU(w.event),A)}else this.event=GU(this.event,LU(w.event));return this.validator.global=D1(this.validator.global,{...w.validator.global}),this.validator.local=D1(this.validator.local,{...w.validator.scoped}),this}macro(w){if(typeof w==="function"){let z={checksum:x4(JSON.stringify({name:this.config.name,seed:this.config.seed,content:w.toString()})),fn:w};this.extender.macros.push(z)}else if(typeof w==="object"){let z={checksum:x4(JSON.stringify({name:this.config.name,seed:this.config.seed,content:Object.entries(w).map(([U,W])=>`${U}+${W}`).join(",")})),fn:()=>w};this.extender.macros.push(z)}return this}mount(w,z){if(w instanceof j0||typeof w==="function"||w.length===0||w==="/"){let A=typeof w==="function"?w:w instanceof j0?w.compile().fetch:z instanceof j0?z.compile().fetch:z,X=async({request:Z,path:$})=>{if(Z.method==="GET"||Z.method==="HEAD"||!Z.headers.get("content-type"))return A(new Request(j8(Z.url,$||"/"),Z));return A(new Request(j8(Z.url,$||"/"),{...Z,body:await Z.arrayBuffer()}))};return this.all("/*",X,{type:"none"}),this}let U=w.length;if(z instanceof j0)z=z.compile().fetch;let W=async({request:A,path:X})=>{if(A.method==="GET"||A.method==="HEAD"||!A.headers.get("content-type"))return z(new Request(j8(A.url,X.slice(U)||"/"),A));return z(new Request(j8(A.url,X.slice(U)||"/"),{...A,body:await A.arrayBuffer()}))};return this.all(w,W,{type:"none"}),this.all(w+(w.endsWith("/")?"*":"/*"),W,{type:"none"}),this}get(w,z,U){return this.add("GET",w,z,U),this}post(w,z,U){return this.add("POST",w,z,U),this}put(w,z,U){return this.add("PUT",w,z,U),this}patch(w,z,U){return this.add("PATCH",w,z,U),this}delete(w,z,U){return this.add("DELETE",w,z,U),this}options(w,z,U){return this.add("OPTIONS",w,z,U),this}all(w,z,U){return this.add("ALL",w,z,U),this}head(w,z,U){return this.add("HEAD",w,z,U),this}connect(w,z,U){return this.add("CONNECT",w,z,U),this}route(w,z,U,W){return this.add(w.toUpperCase(),z,U,W,W?.config),this}ws(w,z){if(this["~adapter"].ws)this["~adapter"].ws(this,w,z);else console.warn("Current adapter doesn't support WebSocket");return this}state(w,z,U){if(z===void 0)U=w,w={as:"append"},z="";else if(U===void 0){if(typeof w==="string")U=z,z=w,w={as:"append"};else if(typeof w==="object")U=z,z=""}let{as:W}=w;if(typeof z!=="string")return this;switch(typeof U){case"object":if(z){if(z in this.singleton.store)this.singleton.store[z]=F2(this.singleton.store[z],U,{override:W==="override"});else this.singleton.store[z]=U;return this}if(U===null)return this;return this.singleton.store=F2(this.singleton.store,U,{override:W==="override"}),this;case"function":if(z){if(W==="override"||!(z in this.singleton.store))this.singleton.store[z]=U}else this.singleton.store=U(this.singleton.store);return this;default:if(W==="override"||!(z in this.singleton.store))this.singleton.store[z]=U;return this}}decorate(w,z,U){if(z===void 0)U=w,w={as:"append"},z="";else if(U===void 0){if(typeof w==="string")U=z,z=w,w={as:"append"};else if(typeof w==="object")U=z,z=""}let{as:W}=w;if(typeof z!=="string")return this;switch(typeof U){case"object":if(z){if(z in this.singleton.decorator)this.singleton.decorator[z]=F2(this.singleton.decorator[z],U,{override:W==="override"});else this.singleton.decorator[z]=U;return this}if(U===null)return this;return this.singleton.decorator=F2(this.singleton.decorator,U,{override:W==="override"}),this;case"function":if(z){if(W==="override"||!(z in this.singleton.decorator))this.singleton.decorator[z]=U}else this.singleton.decorator=U(this.singleton.decorator);return this;default:if(W==="override"||!(z in this.singleton.decorator))this.singleton.decorator[z]=U;return this}}derive(w,z){if(!z)z=w,w={as:"local"};let U={subType:"derive",fn:z};return this.onTransform(w,U)}model(w,z){let U=(W)=>dw(W,[{from:I.Number(),to:(A)=>I.Numeric(A),untilObjectFound:!0},{from:I.Boolean(),to:(A)=>I.BooleanString(A),untilObjectFound:!0}]);switch(typeof w){case"object":let W={};return Object.entries(w).forEach(([X,Z])=>{if(!(X in this.definitions.type))W[X]=this.definitions.type[X]=U(Z)}),this.definitions.typebox=I.Module({...this.definitions.typebox.$defs,...W}),this;case"function":let A=U(w(this.definitions.type));return this.definitions.type=A,this.definitions.typebox=I.Module(A),this}return this.definitions.type[w]=z,this.definitions.typebox=I.Module({...this.definitions.typebox.$defs,[w]:z}),this}mapDerive(w,z){if(!z)z=w,w={as:"local"};let U={subType:"mapDerive",fn:z};return this.onTransform(w,U)}affix(w,z,U){if(U==="")return this;let W=["_","-"," "],A=(Q)=>Q[0].toUpperCase()+Q.slice(1),X=w==="prefix"?(Q,Y)=>W.includes(Q.at(-1)??"")?Q+Y:Q+A(Y):W.includes(U.at(-1)??"")?(Q,Y)=>Y+Q:(Q,Y)=>Y+A(Q),Z=(Q)=>{let Y={};switch(Q){case"decorator":for(let B in this.singleton.decorator)Y[X(U,B)]=this.singleton.decorator[B];this.singleton.decorator=Y;break;case"state":for(let B in this.singleton.store)Y[X(U,B)]=this.singleton.store[B];this.singleton.store=Y;break;case"model":for(let B in this.definitions.type)Y[X(U,B)]=this.definitions.type[B];this.definitions.type=Y;break;case"error":for(let B in this.definitions.error)Y[X(U,B)]=this.definitions.error[B];this.definitions.error=Y;break}},$=Array.isArray(z)?z:[z];for(let Q of $.some((Y)=>Y==="all")?["decorator","state","model","error"]:$)Z(Q);return this}prefix(w,z){return this.affix("prefix",w,z)}suffix(w,z){return this.affix("suffix",w,z)}compile(){if(this["~adapter"].isWebStandard){if(this.fetch=this.config.aot?Tw(this):jU(this),typeof this.server?.reload==="function")this.server.reload({...this.server||{},fetch:this.fetch});return this}if(typeof this.server?.reload==="function")this.server.reload(this.server||{});return this._handle=Tw(this),this}handle=async(w)=>this.fetch(w);fetch=(w)=>{return(this.fetch=this.config.aot?Tw(this):jU(this))(w)};handleError=async(w,z)=>{return(this.handleError=this.config.aot?rU(this):cH(this))(w,z)};outerErrorHandler=(w)=>new Response(w.message||w.name||"Error",{status:w?.status??500});listen=(w,z)=>{return this["~adapter"].listen(this)(w,z),this};stop=async(w)=>{if(!this.server)throw new Error("Elysia isn't running. Call `app.listen` to start the server.");if(this.server){if(this.server.stop(w),this.server=null,this.event.stop.length)for(let z=0;z<this.event.stop.length;z++)this.event.stop[z].fn(this)}};get modules(){return Promise.all(this.promisedModules.promises)}}var aU;(function(w){w[w.Include=0]="Include",w[w.None=1]="None"})(aU||(aU={}));var eU;(function(w){w[w.Required=0]="Required",w[w.Ignore=1]="Ignore"})(eU||(eU={}));function uw(w){return zW(w,iH,f4.Include)}function d4(w){return zW(w,vH,f4.None)}function zW(w,z,U){let W="";for(let A=0;A<w.byteLength;A+=3){let X=0,Z=0;for(let $=0;$<3&&A+$<w.byteLength;$++)X=X<<8|w[A+$],Z+=8;for(let $=0;$<4;$++)if(Z>=6)W+=z[X>>Z-6&63],Z-=6;else if(Z>0)W+=z[X<<6-Z&63],Z=0;else if(U===f4.Include)W+="="}return W}var iH="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",vH="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_";var f4;(function(w){w[w.Include=0]="Include",w[w.None=1]="None"})(f4||(f4={}));var wW;(function(w){w[w.Required=0]="Required",w[w.Ignore=1]="Ignore"})(wW||(wW={}));class WW{uint8(w,z){if(w.byteLength<z+1)throw new TypeError("Insufficient bytes");return w[z]}uint16(w,z){if(w.byteLength<z+2)throw new TypeError("Insufficient bytes");return w[z]<<8|w[z+1]}uint32(w,z){if(w.byteLength<z+4)throw new TypeError("Insufficient bytes");let U=0;for(let W=0;W<4;W++)U|=w[z+W]<<24-W*8;return U}uint64(w,z){if(w.byteLength<z+8)throw new TypeError("Insufficient bytes");let U=0n;for(let W=0;W<8;W++)U|=BigInt(w[z+W])<<BigInt(56-W*8);return U}putUint8(w,z,U){if(w.length<U+1)throw new TypeError("Not enough space");if(z<0||z>255)throw new TypeError("Invalid uint8 value");w[U]=z}putUint16(w,z,U){if(w.length<U+2)throw new TypeError("Not enough space");if(z<0||z>65535)throw new TypeError("Invalid uint16 value");w[U]=z>>8,w[U+1]=z&255}putUint32(w,z,U){if(w.length<U+4)throw new TypeError("Not enough space");if(z<0||z>4294967295)throw new TypeError("Invalid uint32 value");for(let W=0;W<4;W++)w[U+W]=z>>(3-W)*8&255}putUint64(w,z,U){if(w.length<U+8)throw new TypeError("Not enough space");if(z<0||z>18446744073709551615n)throw new TypeError("Invalid uint64 value");for(let W=0;W<8;W++)w[U+W]=Number(z>>BigInt((7-W)*8)&0xffn)}}class AW{uint8(w,z){if(w.byteLength<z+1)throw new TypeError("Insufficient bytes");return w[z]}uint16(w,z){if(w.byteLength<z+2)throw new TypeError("Insufficient bytes");return w[z]|w[z+1]<<8}uint32(w,z){if(w.byteLength<z+4)throw new TypeError("Insufficient bytes");let U=0;for(let W=0;W<4;W++)U|=w[z+W]<<W*8;return U}uint64(w,z){if(w.byteLength<z+8)throw new TypeError("Insufficient bytes");let U=0n;for(let W=0;W<8;W++)U|=BigInt(w[z+W])<<BigInt(W*8);return U}putUint8(w,z,U){if(w.length<1+U)throw new TypeError("Insufficient space");if(z<0||z>255)throw new TypeError("Invalid uint8 value");w[U]=z}putUint16(w,z,U){if(w.length<2+U)throw new TypeError("Insufficient space");if(z<0||z>65535)throw new TypeError("Invalid uint16 value");w[U+1]=z>>8,w[U]=z&255}putUint32(w,z,U){if(w.length<4+U)throw new TypeError("Insufficient space");if(z<0||z>4294967295)throw new TypeError("Invalid uint32 value");for(let W=0;W<4;W++)w[U+W]=z>>W*8&255}putUint64(w,z,U){if(w.length<8+U)throw new TypeError("Insufficient space");if(z<0||z>18446744073709551615n)throw new TypeError("Invalid uint64 value");for(let W=0;W<8;W++)w[U+W]=Number(z>>BigInt(W*8)&0xffn)}}var P1=new WW,nH=new AW;function n0(w,z){return(w<<32-z|w>>>z)>>>0}function a2(w,z){return(w<<BigInt(64-z)|w>>BigInt(z))&0xffffffffffffffffn}class XW{blockSize=64;size=32;blocks=new Uint8Array(64);currentBlockSize=0;H=new Uint32Array([3238371032,914150663,812702999,4144912697,4290775857,1750603025,1694076839,3204075428]);l=0n;w=new Uint32Array(64);update(w){if(this.l+=BigInt(w.byteLength)*8n,this.currentBlockSize+w.byteLength<64){this.blocks.set(w,this.currentBlockSize),this.currentBlockSize+=w.byteLength;return}let z=0;if(this.currentBlockSize>0){let U=w.slice(0,64-this.currentBlockSize);this.blocks.set(U,this.currentBlockSize),this.process(),z+=U.byteLength,this.currentBlockSize=0}while(z+64<=w.byteLength){let U=w.slice(z,z+64);this.blocks.set(U),this.process(),z+=64}if(w.byteLength-z>0){let U=w.slice(z);this.blocks.set(U),this.currentBlockSize=U.byteLength}}digest(){if(this.blocks[this.currentBlockSize]=128,this.currentBlockSize+=1,64-this.currentBlockSize<8)this.blocks.fill(0,this.currentBlockSize),this.process(),this.currentBlockSize=0;this.blocks.fill(0,this.currentBlockSize),P1.putUint64(this.blocks,this.l,this.blockSize-8),this.process();let w=new Uint8Array(28);for(let z=0;z<7;z++)P1.putUint32(w,this.H[z],z*4);return w}process(){for(let Q=0;Q<16;Q++)this.w[Q]=(this.blocks[Q*4]<<24|this.blocks[Q*4+1]<<16|this.blocks[Q*4+2]<<8|this.blocks[Q*4+3])>>>0;for(let Q=16;Q<64;Q++){let Y=(n0(this.w[Q-2],17)^n0(this.w[Q-2],19)^this.w[Q-2]>>>10)>>>0,B=(n0(this.w[Q-15],7)^n0(this.w[Q-15],18)^this.w[Q-15]>>>3)>>>0;this.w[Q]=Y+this.w[Q-7]+B+this.w[Q-16]|0}let w=this.H[0],z=this.H[1],U=this.H[2],W=this.H[3],A=this.H[4],X=this.H[5],Z=this.H[6],$=this.H[7];for(let Q=0;Q<64;Q++){let Y=(n0(A,6)^n0(A,11)^n0(A,25))>>>0,B=(A&X^~A&Z)>>>0,G=$+Y+B+uH[Q]+this.w[Q]|0,_=(n0(w,2)^n0(w,13)^n0(w,22))>>>0,H=(w&z^w&U^z&U)>>>0,F=_+H|0;$=Z,Z=X,X=A,A=W+G|0,W=U,U=z,z=w,w=G+F|0}this.H[0]=w+this.H[0]|0,this.H[1]=z+this.H[1]|0,this.H[2]=U+this.H[2]|0,this.H[3]=W+this.H[3]|0,this.H[4]=A+this.H[4]|0,this.H[5]=X+this.H[5]|0,this.H[6]=Z+this.H[6]|0,this.H[7]=$+this.H[7]|0}}var uH=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]);function mw(w){let z=new tw;return z.update(w),z.digest()}class tw{blockSize=64;size=32;blocks=new Uint8Array(64);currentBlockSize=0;H=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]);l=0n;w=new Uint32Array(64);update(w){if(this.l+=BigInt(w.byteLength)*8n,this.currentBlockSize+w.byteLength<64){this.blocks.set(w,this.currentBlockSize),this.currentBlockSize+=w.byteLength;return}let z=0;if(this.currentBlockSize>0){let U=w.slice(0,64-this.currentBlockSize);this.blocks.set(U,this.currentBlockSize),this.process(),z+=U.byteLength,this.currentBlockSize=0}while(z+64<=w.byteLength){let U=w.slice(z,z+64);this.blocks.set(U),this.process(),z+=64}if(w.byteLength-z>0){let U=w.slice(z);this.blocks.set(U),this.currentBlockSize=U.byteLength}}digest(){if(this.blocks[this.currentBlockSize]=128,this.currentBlockSize+=1,64-this.currentBlockSize<8)this.blocks.fill(0,this.currentBlockSize),this.process(),this.currentBlockSize=0;this.blocks.fill(0,this.currentBlockSize),P1.putUint64(this.blocks,this.l,this.blockSize-8),this.process();let w=new Uint8Array(32);for(let z=0;z<8;z++)P1.putUint32(w,this.H[z],z*4);return w}process(){for(let Q=0;Q<16;Q++)this.w[Q]=(this.blocks[Q*4]<<24|this.blocks[Q*4+1]<<16|this.blocks[Q*4+2]<<8|this.blocks[Q*4+3])>>>0;for(let Q=16;Q<64;Q++){let Y=(n0(this.w[Q-2],17)^n0(this.w[Q-2],19)^this.w[Q-2]>>>10)>>>0,B=(n0(this.w[Q-15],7)^n0(this.w[Q-15],18)^this.w[Q-15]>>>3)>>>0;this.w[Q]=Y+this.w[Q-7]+B+this.w[Q-16]|0}let w=this.H[0],z=this.H[1],U=this.H[2],W=this.H[3],A=this.H[4],X=this.H[5],Z=this.H[6],$=this.H[7];for(let Q=0;Q<64;Q++){let Y=(n0(A,6)^n0(A,11)^n0(A,25))>>>0,B=(A&X^~A&Z)>>>0,G=$+Y+B+mH[Q]+this.w[Q]|0,_=(n0(w,2)^n0(w,13)^n0(w,22))>>>0,H=(w&z^w&U^z&U)>>>0,F=_+H|0;$=Z,Z=X,X=A,A=W+G|0,W=U,U=z,z=w,w=G+F|0}this.H[0]=w+this.H[0]|0,this.H[1]=z+this.H[1]|0,this.H[2]=U+this.H[2]|0,this.H[3]=W+this.H[3]|0,this.H[4]=A+this.H[4]|0,this.H[5]=X+this.H[5]|0,this.H[6]=Z+this.H[6]|0,this.H[7]=$+this.H[7]|0}}var mH=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]);class Z6{blockSize=128;size=64;blocks=new Uint8Array(128);currentBlockSize=0;l=0n;w=new BigUint64Array(80);H;constructor(w){if(w.byteLength!==64)throw new TypeError;this.H=w}update(w){if(this.l+=BigInt(w.byteLength)*8n,this.currentBlockSize+w.byteLength<128){this.blocks.set(w,this.currentBlockSize),this.currentBlockSize+=w.byteLength;return}let z=0;if(this.currentBlockSize>0){let U=w.slice(0,128-this.currentBlockSize);this.blocks.set(U,this.currentBlockSize),this.process(),z+=U.byteLength,this.currentBlockSize=0}while(z+128<=w.byteLength){let U=w.slice(z,z+128);this.blocks.set(U),this.process(),z+=128,this.currentBlockSize=0}if(w.byteLength-z>0){let U=w.slice(z);this.blocks.set(U),this.currentBlockSize=U.byteLength}}putDigest(w){if(w.byteLength>64||w.byteLength%8!==0)throw new TypeError;if(this.blocks[this.currentBlockSize]=128,this.currentBlockSize+=1,128-this.currentBlockSize<16)this.blocks.fill(0,this.currentBlockSize),this.process(),this.currentBlockSize=0;this.blocks.fill(0,this.currentBlockSize),P1.putUint64(this.blocks,this.l,this.blockSize-8),this.process();for(let z=0;z<w.byteLength/8;z++)P1.putUint64(w,this.H[z],z*8)}process(){for(let Q=0;Q<16;Q++)this.w[Q]=BigInt(this.blocks[Q*8])<<56n|BigInt(this.blocks[Q*8+1])<<48n|BigInt(this.blocks[Q*8+2])<<40n|BigInt(this.blocks[Q*8+3])<<32n|BigInt(this.blocks[Q*8+4])<<24n|BigInt(this.blocks[Q*8+5])<<16n|BigInt(this.blocks[Q*8+6])<<8n|BigInt(this.blocks[Q*8+7]);for(let Q=16;Q<80;Q++){let Y=(a2(this.w[Q-2],19)^a2(this.w[Q-2],61)^this.w[Q-2]>>6n)&0xffffffffffffffffn,B=(a2(this.w[Q-15],1)^a2(this.w[Q-15],8)^this.w[Q-15]>>7n)&0xffffffffffffffffn;this.w[Q]=Y+this.w[Q-7]+B+this.w[Q-16]&0xffffffffffffffffn}let w=this.H[0],z=this.H[1],U=this.H[2],W=this.H[3],A=this.H[4],X=this.H[5],Z=this.H[6],$=this.H[7];for(let Q=0;Q<80;Q++){let Y=(a2(A,14)^a2(A,18)^a2(A,41))&0xffffffffffffffffn,B=(A&X^~A&Z)&0xffffffffffffffffn,G=$+Y+B+tH[Q]+this.w[Q]&0xffffffffffffffffn,_=(a2(w,28)^a2(w,34)^a2(w,39))&0xffffffffffffffffn,H=(w&z^w&U^z&U)&0xffffffffffffffffn,F=_+H&0xffffffffffffffffn;$=Z,Z=X,X=A,A=W+G&0xffffffffffffffffn,W=U,U=z,z=w,w=G+F&0xffffffffffffffffn}this.H[0]=w+this.H[0]&0xffffffffffffffffn,this.H[1]=z+this.H[1]&0xffffffffffffffffn,this.H[2]=U+this.H[2]&0xffffffffffffffffn,this.H[3]=W+this.H[3]&0xffffffffffffffffn,this.H[4]=A+this.H[4]&0xffffffffffffffffn,this.H[5]=X+this.H[5]&0xffffffffffffffffn,this.H[6]=Z+this.H[6]&0xffffffffffffffffn,this.H[7]=$+this.H[7]&0xffffffffffffffffn}}class ZW{blockSize=128;size=64;sha512=new Z6(new BigUint64Array([0x6a09e667f3bcc908n,0xbb67ae8584caa73bn,0x3c6ef372fe94f82bn,0xa54ff53a5f1d36f1n,0x510e527fade682d1n,0x9b05688c2b3e6c1fn,0x1f83d9abfb41bd6bn,0x5be0cd19137e2179n]));update(w){this.sha512.update(w)}digest(){let w=new Uint8Array(64);return this.sha512.putDigest(w),w}}var tH=new BigUint64Array([0x428a2f98d728ae22n,0x7137449123ef65cdn,0xb5c0fbcfec4d3b2fn,0xe9b5dba58189dbbcn,0x3956c25bf348b538n,0x59f111f1b605d019n,0x923f82a4af194f9bn,0xab1c5ed5da6d8118n,0xd807aa98a3030242n,0x12835b0145706fben,0x243185be4ee4b28cn,0x550c7dc3d5ffb4e2n,0x72be5d74f27b896fn,0x80deb1fe3b1696b1n,0x9bdc06a725c71235n,0xc19bf174cf692694n,0xe49b69c19ef14ad2n,0xefbe4786384f25e3n,0x0fc19dc68b8cd5b5n,0x240ca1cc77ac9c65n,0x2de92c6f592b0275n,0x4a7484aa6ea6e483n,0x5cb0a9dcbd41fbd4n,0x76f988da831153b5n,0x983e5152ee66dfabn,0xa831c66d2db43210n,0xb00327c898fb213fn,0xbf597fc7beef0ee4n,0xc6e00bf33da88fc2n,0xd5a79147930aa725n,0x06ca6351e003826fn,0x142929670a0e6e70n,0x27b70a8546d22ffcn,0x2e1b21385c26c926n,0x4d2c6dfc5ac42aedn,0x53380d139d95b3dfn,0x650a73548baf63den,0x766a0abb3c77b2a8n,0x81c2c92e47edaee6n,0x92722c851482353bn,0xa2bfe8a14cf10364n,0xa81a664bbc423001n,0xc24b8b70d0f89791n,0xc76c51a30654be30n,0xd192e819d6ef5218n,0xd69906245565a910n,0xf40e35855771202an,0x106aa07032bbd1b8n,0x19a4c116b8d2d0c8n,0x1e376c085141ab53n,0x2748774cdf8eeb99n,0x34b0bcb5e19b48a8n,0x391c0cb3c5c95a63n,0x4ed8aa4ae3418acbn,0x5b9cca4f7763e373n,0x682e6ff3d6b2b8a3n,0x748f82ee5defb2fcn,0x78a5636f43172f60n,0x84c87814a1f0ab72n,0x8cc702081a6439ecn,0x90befffa23631e28n,0xa4506cebde82bde9n,0xbef9a3f7b2c67915n,0xc67178f2e372532bn,0xca273eceea26619cn,0xd186b8c721c0c207n,0xeada7dd6cde0eb1en,0xf57d4f7fee6ed178n,0x06f067aa72176fban,0x0a637dc5a2c898a6n,0x113f9804bef90daen,0x1b710b35131c471bn,0x28db77f523047d84n,0x32caab7b40c72493n,0x3c9ebe0a15c9bebcn,0x431d67c49c100d4cn,0x4cc5d4becb3e42b6n,0x597f299cfc657e2an,0x5fcb6fab3ad6faecn,0x6c44198c4a475817n]);class $W{blockSize=128;size=48;sha512=new Z6(new BigUint64Array([0xcbbb9d5dc1059ed8n,0x629a292a367cd507n,0x9159015a3070dd17n,0x152fecd8f70e5939n,0x67332667ffc00b31n,0x8eb44a8768581511n,0xdb0c2e0d64f98fa7n,0x47b5481dbefa4fa4n]));update(w){this.sha512.update(w)}digest(){let w=new Uint8Array(48);return this.sha512.putDigest(w),w}}class QW{blockSize=128;size=28;sha512=new Z6(new BigUint64Array([0x8c3d37c819544da2n,0x73e1996689dcd4d6n,0x1dfab7ae32ff9c82n,0x679dd514582f9fcfn,0x0f6d2b697bd44da8n,0x77e36f7304c48942n,0x3f9d85a86a1d36c8n,0x1112e6ad91d692a1n]));update(w){this.sha512.update(w)}digest(){let w=new Uint8Array(32);return this.sha512.putDigest(w),w.slice(0,28)}}class YW{blockSize=128;size=28;sha512=new Z6(new BigUint64Array([0x22312194fc2bf72cn,0x9f555fa3c84c64c2n,0x2393b86b6f53b151n,0x963877195940eabdn,0x96283ee2a88effe3n,0xbe5e1e2553863992n,0x2b0199fc2c85b8aan,0x0eb72ddc81c52ca2n]));update(w){this.sha512.update(w)}digest(){let w=new Uint8Array(32);return this.sha512.putDigest(w),w}}class U4{data;constructor(w){this.data=w}tokenType(){if("token_type"in this.data&&typeof this.data.token_type==="string")return this.data.token_type;throw new Error("Missing or invalid 'token_type' field")}accessToken(){if("access_token"in this.data&&typeof this.data.access_token==="string")return this.data.access_token;throw new Error("Missing or invalid 'access_token' field")}accessTokenExpiresInSeconds(){if("expires_in"in this.data&&typeof this.data.expires_in==="number")return this.data.expires_in;throw new Error("Missing or invalid 'expires_in' field")}accessTokenExpiresAt(){return new Date(Date.now()+this.accessTokenExpiresInSeconds()*1000)}hasRefreshToken(){return"refresh_token"in this.data&&typeof this.data.refresh_token==="string"}refreshToken(){if("refresh_token"in this.data&&typeof this.data.refresh_token==="string")return this.data.refresh_token;throw new Error("Missing or invalid 'refresh_token' field")}hasScopes(){return"scope"in this.data&&typeof this.data.scope==="string"}scopes(){if("scope"in this.data&&typeof this.data.scope==="string")return this.data.scope.split(" ");throw new Error("Missing or invalid 'scope' field")}idToken(){if("id_token"in this.data&&typeof this.data.id_token==="string")return this.data.id_token;throw new Error("Missing or invalid field 'id_token'")}}function W4(w){let z=mw(new TextEncoder().encode(w));return d4(z)}function pw(){let w=new Uint8Array(32);return crypto.getRandomValues(w),d4(w)}function ow(){let w=new Uint8Array(32);return crypto.getRandomValues(w),d4(w)}function JW(w,z){if(z.length!==1)throw new TypeError("Invalid character string");let U=0;while(U<w.length&&w[U]===z)U++;return w.slice(U)}function lw(w,z){if(z.length!==1)throw new TypeError("Invalid character string");let U=w.length;while(U>0&&w[U-1]===z)U--;return w.slice(0,U)}function M2(w,...z){let U=lw(w,"/");for(let W of z)U+="/",U+=lw(JW(W,"/"),"/");return U}function g(w,z){let U=new TextEncoder().encode(z.toString()),W=new Request(w,{method:"POST",body:U});return W.headers.set("Content-Type","application/x-www-form-urlencoded"),W.headers.set("Accept","application/json"),W.headers.set("User-Agent","arctic"),W.headers.set("Content-Length",U.byteLength.toString()),W}function R6(w,z){let U=new TextEncoder().encode(`${w}:${z}`);return uw(U)}async function c(w){let z;try{z=await fetch(w)}catch(U){throw new $6(U)}if(z.status===400||z.status===401){let U;try{U=await z.json()}catch{throw new v1(z.status)}if(typeof U!=="object"||U===null)throw new q1(z.status,U);let W;try{W=c8(U)}catch{throw new q1(z.status,U)}throw W}if(z.status===200){let U;try{U=await z.json()}catch{throw new v1(z.status)}if(typeof U!=="object"||U===null)throw new q1(z.status,U);return new U4(U)}if(z.body!==null)await z.body.cancel();throw new v1(z.status)}async function A4(w){let z;try{z=await fetch(w)}catch(U){throw new $6(U)}if(z.status===400||z.status===401){let U;try{U=await z.json()}catch{throw new q1(z.status,null)}if(typeof U!=="object"||U===null)throw new q1(z.status,U);let W;try{W=c8(U)}catch{throw new q1(z.status,U)}throw W}if(z.status===200){if(z.body!==null)await z.body.cancel();return}if(z.body!==null)await z.body.cancel();throw new v1(z.status)}function c8(w){let z;if("error"in w&&typeof w.error==="string")z=w.error;else throw new Error("Invalid error response");let U=null,W=null,A=null;if("error_description"in w){if(typeof w.error_description!=="string")throw new Error("Invalid data");U=w.error_description}if("error_uri"in w){if(typeof w.error_uri!=="string")throw new Error("Invalid data");W=w.error_uri}if("state"in w){if(typeof w.state!=="string")throw new Error("Invalid data");A=w.state}return new h4(z,U,W,A)}class $6 extends Error{constructor(w){super("Failed to send request",{cause:w})}}class h4 extends Error{code;description;uri;state;constructor(w,z,U,W){super(`OAuth request error: ${w}`);this.code=w,this.description=z,this.uri=U,this.state=W}}class v1 extends Error{status;constructor(w){super("Unexpected error response");this.status=w}}class q1 extends Error{status;data;constructor(w,z){super("Unexpected error response body");this.status=w,this.data=z}}class f{clientId;clientPassword;redirectURI;constructor(w,z,U){this.clientId=w,this.clientPassword=z,this.redirectURI=U}createAuthorizationURL(w,z,U){let W=new URL(w);if(W.searchParams.set("response_type","code"),W.searchParams.set("client_id",this.clientId),this.redirectURI!==null)W.searchParams.set("redirect_uri",this.redirectURI);if(W.searchParams.set("state",z),U.length>0)W.searchParams.set("scope",U.join(" "));return W}createAuthorizationURLWithPKCE(w,z,U,W,A){let X=new URL(w);if(X.searchParams.set("response_type","code"),X.searchParams.set("client_id",this.clientId),this.redirectURI!==null)X.searchParams.set("redirect_uri",this.redirectURI);if(X.searchParams.set("state",z),U===W0.S256){let Z=W4(W);X.searchParams.set("code_challenge_method","S256"),X.searchParams.set("code_challenge",Z)}else if(U===W0.Plain)X.searchParams.set("code_challenge_method","plain"),X.searchParams.set("code_challenge",W);if(A.length>0)X.searchParams.set("scope",A.join(" "));return X}async validateAuthorizationCode(w,z,U){let W=new URLSearchParams;if(W.set("grant_type","authorization_code"),W.set("code",z),this.redirectURI!==null)W.set("redirect_uri",this.redirectURI);if(U!==null)W.set("code_verifier",U);if(this.clientPassword===null)W.set("client_id",this.clientId);let A=g(w,W);if(this.clientPassword!==null){let Z=R6(this.clientId,this.clientPassword);A.headers.set("Authorization",`Basic ${Z}`)}return await c(A)}async refreshAccessToken(w,z,U){let W=new URLSearchParams;if(W.set("grant_type","refresh_token"),W.set("refresh_token",z),this.clientPassword===null)W.set("client_id",this.clientId);if(U.length>0)W.set("scope",U.join(" "));let A=g(w,W);if(this.clientPassword!==null){let Z=R6(this.clientId,this.clientPassword);A.headers.set("Authorization",`Basic ${Z}`)}return await c(A)}async revokeToken(w,z){let U=new URLSearchParams;if(U.set("token",z),this.clientPassword===null)U.set("client_id",this.clientId);let W=g(w,U);if(this.clientPassword!==null){let A=R6(this.clientId,this.clientPassword);W.headers.set("Authorization",`Basic ${A}`)}await A4(W)}}var W0;(function(w){w[w.S256=0]="S256",w[w.Plain=1]="Plain"})(W0||(W0={}));class i8{authorizationEndpoint;tokenEndpoint;tokenRevocationEndpoint;client;constructor(w,z,U,W){this.authorizationEndpoint=`https://${w}/oauth2/authorize`,this.tokenEndpoint=`https://${w}/oauth2/token`,this.tokenRevocationEndpoint=`https://${w}/oauth2/revoke`,this.client=new f(z,U,W)}createAuthorizationURL(w,z,U){return this.client.createAuthorizationURLWithPKCE(this.authorizationEndpoint,w,W0.S256,z,U)}async validateAuthorizationCode(w,z){return await this.client.validateAuthorizationCode(this.tokenEndpoint,w,z)}async refreshAccessToken(w,z){return await this.client.refreshAccessToken(this.tokenEndpoint,w,z)}async revokeToken(w){await this.client.revokeToken(this.tokenRevocationEndpoint,w)}}var oH="https://anilist.co/api/v2/oauth/authorize",lH="https://anilist.co/api/v2/oauth/token";class v8{client;constructor(w,z,U){this.client=new f(w,z,U)}createAuthorizationURL(w){return this.client.createAuthorizationURL(oH,w,[])}async validateAuthorizationCode(w){return await this.client.validateAuthorizationCode(lH,w,null)}}var BW;(function(w){w[w.Include=0]="Include",w[w.None=1]="None"})(BW||(BW={}));var MW;(function(w){w[w.Required=0]="Required",w[w.Ignore=1]="Ignore"})(MW||(MW={}));function C6(w){return sH(w,rH,n8.None)}function sH(w,z,U){let W="";for(let A=0;A<w.byteLength;A+=3){let X=0,Z=0;for(let $=0;$<3&&A+$<w.byteLength;$++)X=X<<8|w[A+$],Z+=8;for(let $=0;$<4;$++)if(Z>=6)W+=z[X>>Z-6&63],Z-=6;else if(Z>0)W+=z[X<<6-Z&63],Z=0;else if(U===n8.Include)W+="="}return W}var rH="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_";function sw(w){return aH(w,eH,y4.Ignore)}function aH(w,z,U){let W=new Uint8Array(Math.ceil(w.length/4)*3),A=0;for(let X=0;X<w.length;X+=4){let Z=0,$=0;for(let Y=0;Y<4;Y++){if(U===y4.Required&&w[X+Y]==="=")continue;if(U===y4.Ignore&&(X+Y>=w.length||w[X+Y]==="="))continue;if(Y>0&&w[X+Y-1]==="=")throw new Error("Invalid padding");if(!(w[X+Y]in z))throw new Error("Invalid character");Z|=z[w[X+Y]]<<(3-Y)*6,$+=6}if($<24){let Y;if($===12)Y=Z&65535;else if($===18)Y=Z&255;else throw new Error("Invalid padding");if(Y!==0)throw new Error("Invalid padding")}let Q=Math.floor($/8);for(let Y=0;Y<Q;Y++)W[A]=Z>>16-Y*8&255,A++}return W.slice(0,A)}var n8;(function(w){w[w.Include=0]="Include",w[w.None=1]="None"})(n8||(n8={}));var y4;(function(w){w[w.Required=0]="Required",w[w.Ignore=1]="Ignore"})(y4||(y4={}));var eH={"0":52,"1":53,"2":54,"3":55,"4":56,"5":57,"6":58,"7":59,"8":60,"9":61,A:0,B:1,C:2,D:3,E:4,F:5,G:6,H:7,I:8,J:9,K:10,L:11,M:12,N:13,O:14,P:15,Q:16,R:17,S:18,T:19,U:20,V:21,W:22,X:23,Y:24,Z:25,a:26,b:27,c:28,d:29,e:30,f:31,g:32,h:33,i:34,j:35,k:36,l:37,m:38,n:39,o:40,p:41,q:42,r:43,s:44,t:45,u:46,v:47,w:48,x:49,y:50,z:51,"-":62,_:63};function qW(w){let z=w.split(".");if(z.length!==3)throw new Error("Invalid JWT");let U;try{U=new TextDecoder().decode(sw(z[1]))}catch{throw new Error("Invalid JWT: Invalid base64url encoding")}let W;try{W=JSON.parse(U)}catch{throw new Error("Invalid JWT: Invalid JSON encoding")}if(typeof W!=="object"||W===null)throw new Error("Invalid JWT: Invalid payload");return W}function HW(w,z,U){let W=C6(new TextEncoder().encode(w)),A=C6(new TextEncoder().encode(z)),X=C6(U);return W+"."+A+"."+X}function GW(w,z){let U=C6(new TextEncoder().encode(w)),W=C6(new TextEncoder().encode(z)),A=U+"."+W;return new TextEncoder().encode(A)}var zG="https://appleid.apple.com/auth/authorize",UG="https://appleid.apple.com/auth/token";class u8{clientId;teamId;keyId;pkcs8PrivateKey;redirectURI;constructor(w,z,U,W,A){this.clientId=w,this.teamId=z,this.keyId=U,this.pkcs8PrivateKey=W,this.redirectURI=A}createAuthorizationURL(w,z){let U=new URL(zG);if(U.searchParams.set("response_type","code"),U.searchParams.set("client_id",this.clientId),U.searchParams.set("state",w),z.length>0)U.searchParams.set("scope",z.join(" "));return U.searchParams.set("redirect_uri",this.redirectURI),U}async validateAuthorizationCode(w){let z=new URLSearchParams;z.set("grant_type","authorization_code"),z.set("code",w),z.set("redirect_uri",this.redirectURI),z.set("client_id",this.clientId);let U=await this.createClientSecret();z.set("client_secret",U);let W=g(UG,z);return await c(W)}async createClientSecret(){let w=await crypto.subtle.importKey("pkcs8",this.pkcs8PrivateKey,{name:"ECDSA",namedCurve:"P-256"},!1,["sign"]),z=Math.floor(Date.now()/1000),U=JSON.stringify({typ:"JWT",alg:"ES256",kid:this.keyId}),W=JSON.stringify({iss:this.teamId,exp:z+300,aud:["https://appleid.apple.com"],sub:this.clientId,iat:z}),A=new Uint8Array(await crypto.subtle.sign({name:"ECDSA",hash:"SHA-256"},w,GW(U,W)));return HW(U,W,A)}}var WG="https://auth.atlassian.com/authorize",NW="https://auth.atlassian.com/oauth/token";class m8{clientId;clientSecret;redirectURI;constructor(w,z,U){this.clientId=w,this.clientSecret=z,this.redirectURI=U}createAuthorizationURL(w,z){let U=new URL(WG);if(U.searchParams.set("response_type","code"),U.searchParams.set("client_id",this.clientId),U.searchParams.set("state",w),z.length>0)U.searchParams.set("scope",z.join(" "));return U.searchParams.set("redirect_uri",this.redirectURI),U.searchParams.set("audience","api.atlassian.com"),U.searchParams.set("prompt","consent"),U}async validateAuthorizationCode(w){let z=new URLSearchParams;z.set("grant_type","authorization_code"),z.set("code",w),z.set("redirect_uri",this.redirectURI),z.set("client_id",this.clientId),z.set("client_secret",this.clientSecret);let U=g(NW,z);return await c(U)}async refreshAccessToken(w){let z=new URLSearchParams;z.set("grant_type","refresh_token"),z.set("refresh_token",w),z.set("client_id",this.clientId),z.set("client_secret",this.clientSecret);let U=g(NW,z);return await c(U)}}class t8{authorizationEndpoint;tokenEndpoint;tokenRevocationEndpoint;client;constructor(w,z,U,W){this.authorizationEndpoint=`https://${w}/authorize`,this.tokenEndpoint=`https://${w}/oauth/token`,this.tokenRevocationEndpoint=`https://${w}/oauth/revoke`,this.client=new f(z,U,W)}createAuthorizationURL(w,z,U){let W;if(z!==null)W=this.client.createAuthorizationURLWithPKCE(this.authorizationEndpoint,w,W0.S256,z,U);else W=this.client.createAuthorizationURL(this.authorizationEndpoint,w,U);return W}async validateAuthorizationCode(w,z){return await this.client.validateAuthorizationCode(this.tokenEndpoint,w,z)}async refreshAccessToken(w){return await this.client.refreshAccessToken(this.tokenEndpoint,w,[])}async revokeToken(w){await this.client.revokeToken(this.tokenRevocationEndpoint,w)}}class p8{authorizationEndpoint;tokenEndpoint;tokenRevocationEndpoint;client;constructor(w,z,U,W){this.authorizationEndpoint=M2(w,"/application/o/authorize"),this.tokenEndpoint=M2(w,"/application/o/token"),this.tokenRevocationEndpoint=M2(w,"/application/o/revoke"),this.client=new f(z,U,W)}createAuthorizationURL(w,z,U){return this.client.createAuthorizationURLWithPKCE(this.authorizationEndpoint,w,W0.S256,z,U)}async validateAuthorizationCode(w,z){return await this.client.validateAuthorizationCode(this.tokenEndpoint,w,z)}async refreshAccessToken(w){return await this.client.refreshAccessToken(this.tokenEndpoint,w,[])}async revokeToken(w){await this.client.revokeToken(this.tokenRevocationEndpoint,w)}}var AG="https://bitbucket.org/site/oauth2/authorize",SW="https://bitbucket.org/site/oauth2/access_token";class o8{client;constructor(w,z,U){this.client=new f(w,z,U)}createAuthorizationURL(w){return this.client.createAuthorizationURL(AG,w,[])}async validateAuthorizationCode(w){return await this.client.validateAuthorizationCode(SW,w,null)}async refreshAccessToken(w){return await this.client.refreshAccessToken(SW,w,[])}}var XG="https://account.box.com/api/oauth2/authorize",_W="https://api.box.com/oauth2/token",ZG="https://api.box.com/oauth2/revoke";class l8{clientId;clientSecret;redirectURI;constructor(w,z,U){this.clientId=w,this.clientSecret=z,this.redirectURI=U}createAuthorizationURL(w,z){let U=new URL(XG);if(U.searchParams.set("response_type","code"),U.searchParams.set("client_id",this.clientId),U.searchParams.set("state",w),z.length>0)U.searchParams.set("scope",z.join(" "));return U.searchParams.set("redirect_uri",this.redirectURI),U}async validateAuthorizationCode(w){let z=new URLSearchParams;z.set("grant_type","authorization_code"),z.set("code",w),z.set("redirect_uri",this.redirectURI),z.set("client_id",this.clientId),z.set("client_secret",this.clientSecret);let U=g(_W,z);return await c(U)}async refreshAccessToken(w){let z=new URLSearchParams;z.set("grant_type","refresh_token"),z.set("refresh_token",w),z.set("client_id",this.clientId),z.set("client_secret",this.clientSecret);let U=g(_W,z);return await c(U)}async revokeToken(w){let z=new URLSearchParams;z.set("token",w),z.set("client_id",this.clientId),z.set("client_secret",this.clientSecret);let U=g(ZG,z);await A4(U)}}var $G="https://www.coinbase.com/oauth/authorize",DW="https://www.coinbase.com/oauth/token",QG="https://api.coinbase.com/oauth/revoke";class s8{clientId;clientSecret;redirectURI;constructor(w,z,U){this.clientId=w,this.clientSecret=z,this.redirectURI=U}createAuthorizationURL(w,z){let U=new URL($G);if(U.searchParams.set("response_type","code"),U.searchParams.set("client_id",this.clientId),U.searchParams.set("state",w),z.length>0)U.searchParams.set("scope",z.join(" "));return U.searchParams.set("redirect_uri",this.redirectURI),U}async validateAuthorizationCode(w){let z=new URLSearchParams;z.set("grant_type","authorization_code"),z.set("code",w),z.set("redirect_uri",this.redirectURI),z.set("client_id",this.clientId),z.set("client_secret",this.clientSecret);let U=g(DW,z);return await c(U)}async refreshAccessToken(w){let z=new URLSearchParams;z.set("grant_type","refresh_token"),z.set("refresh_token",w),z.set("client_id",this.clientId),z.set("client_secret",this.clientSecret);let U=g(DW,z);return await c(U)}async revokeToken(w){let z=new URLSearchParams;z.set("token",w),z.set("client_id",this.clientId),z.set("client_secret",this.clientSecret);let U=g(QG,z);await A4(U)}}var PW="https://discord.com/oauth2/authorize",OW="https://discord.com/api/oauth2/token",YG="https://discord.com/api/oauth2/token/revoke";class r8{client;constructor(w,z,U){this.client=new f(w,z,U)}createAuthorizationURL(w,z,U){let W;if(z!==null)W=this.client.createAuthorizationURLWithPKCE(PW,w,W0.S256,z,U);else W=this.client.createAuthorizationURL(PW,w,U);return W}async validateAuthorizationCode(w,z){return await this.client.validateAuthorizationCode(OW,w,z)}async refreshAccessToken(w){return await this.client.refreshAccessToken(OW,w,[])}async revokeToken(w){await this.client.revokeToken(YG,w)}}var JG="https://dribbble.com/oauth/authorize",BG="https://dribbble.com/oauth/token";class a8{clientId;clientSecret;redirectURI;constructor(w,z,U){this.clientId=w,this.clientSecret=z,this.redirectURI=U}createAuthorizationURL(w,z){let U=new URL(JG);if(U.searchParams.set("response_type","code"),U.searchParams.set("client_id",this.clientId),U.searchParams.set("state",w),z.length>0)U.searchParams.set("scope",z.join(" "));return U.searchParams.set("redirect_uri",this.redirectURI),U}async validateAuthorizationCode(w){let z=new URLSearchParams;z.set("grant_type","authorization_code"),z.set("code",w),z.set("redirect_uri",this.redirectURI),z.set("client_id",this.clientId),z.set("client_secret",this.clientSecret);let U=g(BG,z);return await c(U)}}var MG="https://www.dropbox.com/oauth2/authorize",bW="https://api.dropboxapi.com/oauth2/token",qG="https://api.dropboxapi.com/2/auth/token/revoke";class e8{client;constructor(w,z,U){this.client=new f(w,z,U)}createAuthorizationURL(w,z){return this.client.createAuthorizationURL(MG,w,z)}async validateAuthorizationCode(w){return await this.client.validateAuthorizationCode(bW,w,null)}async refreshAccessToken(w){return await this.client.refreshAccessToken(bW,w,[])}async revokeToken(w){await this.client.revokeToken(qG,w)}}var HG="https://www.facebook.com/v16.0/dialog/oauth",GG="https://graph.facebook.com/v16.0/oauth/access_token";class w5{clientId;clientSecret;redirectURI;constructor(w,z,U){this.clientId=w,this.clientSecret=z,this.redirectURI=U}createAuthorizationURL(w,z){let U=new URL(HG);if(U.searchParams.set("response_type","code"),U.searchParams.set("client_id",this.clientId),U.searchParams.set("state",w),z.length>0)U.searchParams.set("scope",z.join(" "));return U.searchParams.set("redirect_uri",this.redirectURI),U}async validateAuthorizationCode(w){let z=new URLSearchParams;z.set("grant_type","authorization_code"),z.set("code",w),z.set("redirect_uri",this.redirectURI),z.set("client_id",this.clientId),z.set("client_secret",this.clientSecret);let U=g(GG,z);return await c(U)}}var LG="https://www.figma.com/oauth",NG="https://www.figma.com/api/oauth/token";class z5{client;constructor(w,z,U){this.client=new f(w,z,U)}createAuthorizationURL(w,z){return this.client.createAuthorizationURL(LG,w,z)}async validateAuthorizationCode(w){return await this.client.validateAuthorizationCode(NG,w,null)}}var SG="https://appcenter.intuit.com/connect/oauth2",RW="https://oauth.platform.intuit.com/oauth2/v1/tokens/bearer",_G="https://developer.API.intuit.com/v2/oauth2/tokens/revoke";class U5{client;constructor(w,z,U){this.client=new f(w,z,U)}createAuthorizationURL(w,z){return this.client.createAuthorizationURL(SG,w,z)}async validateAuthorizationCode(w){return await this.client.validateAuthorizationCode(RW,w,null)}async refreshAccessToken(w){return await this.client.refreshAccessToken(RW,w,[])}async revokeToken(w){await this.client.revokeToken(_G,w)}}var DG="https://github.com/login/oauth/authorize",CW="https://github.com/login/oauth/access_token";class W5{clientId;clientSecret;redirectURI;constructor(w,z,U){this.clientId=w,this.clientSecret=z,this.redirectURI=U}createAuthorizationURL(w,z){let U=new URL(DG);if(U.searchParams.set("response_type","code"),U.searchParams.set("client_id",this.clientId),U.searchParams.set("state",w),z.length>0)U.searchParams.set("scope",z.join(" "));if(this.redirectURI!==null)U.searchParams.set("redirect_uri",this.redirectURI);return U}async validateAuthorizationCode(w){let z=new URLSearchParams;if(z.set("grant_type","authorization_code"),z.set("code",w),this.redirectURI!==null)z.set("redirect_uri",this.redirectURI);let U=g(CW,z),W=R6(this.clientId,this.clientSecret);return U.headers.set("Authorization",`Basic ${W}`),await KW(U)}async refreshAccessToken(w){let z=new URLSearchParams;z.set("grant_type","refresh_token"),z.set("refresh_token",w);let U=g(CW,z),W=R6(this.clientId,this.clientSecret);return U.headers.set("Authorization",`Basic ${W}`),await KW(U)}}async function KW(w){let z;try{z=await fetch(w)}catch(A){throw new $6(A)}if(z.status!==200){if(z.body!==null)await z.body.cancel();throw new v1(z.status)}let U;try{U=await z.json()}catch{throw new v1(z.status)}if(typeof U!=="object"||U===null)throw new q1(z.status,U);if("error"in U&&typeof U.error==="string"){let A;try{A=c8(U)}catch{throw new q1(z.status,U)}throw A}return new U4(U)}class A5{authorizationEndpoint;tokenEndpoint;tokenRevocationEndpoint;client;constructor(w,z,U,W){this.authorizationEndpoint=M2(w,"/oauth/authorize"),this.tokenEndpoint=M2(w,"/oauth/token"),this.tokenRevocationEndpoint=M2(w,"/oauth/revoke"),this.client=new f(z,U,W)}createAuthorizationURL(w,z){return this.client.createAuthorizationURL(this.authorizationEndpoint,w,z)}async validateAuthorizationCode(w){return await this.client.validateAuthorizationCode(this.tokenEndpoint,w,null)}async refreshAccessToken(w){return await this.client.refreshAccessToken(this.tokenEndpoint,w,[])}async revokeToken(w){await this.client.revokeToken(this.tokenRevocationEndpoint,w)}}var PG="https://accounts.google.com/o/oauth2/v2/auth",FW="https://oauth2.googleapis.com/token",OG="https://oauth2.googleapis.com/revoke";class X5{client;constructor(w,z,U){this.client=new f(w,z,U)}createAuthorizationURL(w,z,U){return this.client.createAuthorizationURLWithPKCE(PG,w,W0.S256,z,U)}async validateAuthorizationCode(w,z){return await this.client.validateAuthorizationCode(FW,w,z)}async refreshAccessToken(w){return await this.client.refreshAccessToken(FW,w,[])}async revokeToken(w){await this.client.revokeToken(OG,w)}}var bG="https://kauth.kakao.com/oauth/authorize",jW="https://kauth.kakao.com/oauth/token";class Z5{clientId;clientSecret;redirectURI;constructor(w,z,U){this.clientId=w,this.clientSecret=z,this.redirectURI=U}createAuthorizationURL(w,z){let U=new URL(bG);if(U.searchParams.set("response_type","code"),U.searchParams.set("client_id",this.clientId),U.searchParams.set("state",w),z.length>0)U.searchParams.set("scope",z.join(" "));return U.searchParams.set("redirect_uri",this.redirectURI),U}async validateAuthorizationCode(w){let z=new URLSearchParams;z.set("grant_type","authorization_code"),z.set("code",w),z.set("redirect_uri",this.redirectURI),z.set("client_id",this.clientId),z.set("client_secret",this.clientSecret);let U=g(jW,z);return await c(U)}async refreshAccessToken(w){let z=new URLSearchParams;z.set("grant_type","refresh_token"),z.set("refresh_token",w),z.set("client_id",this.clientId),z.set("client_secret",this.clientSecret);let U=g(jW,z);return await c(U)}}class $5{authorizationEndpoint;tokenEndpoint;tokenRevocationEndpoint;client;constructor(w,z,U,W){this.authorizationEndpoint=w+"/protocol/openid-connect/auth",this.tokenEndpoint=w+"/protocol/openid-connect/token",this.tokenRevocationEndpoint=w+"/protocol/openid-connect/revoke",this.client=new f(z,U,W)}createAuthorizationURL(w,z,U){return this.client.createAuthorizationURLWithPKCE(this.authorizationEndpoint,w,W0.S256,z,U)}async validateAuthorizationCode(w,z){return await this.client.validateAuthorizationCode(this.tokenEndpoint,w,z)}async refreshAccessToken(w){return await this.client.refreshAccessToken(this.tokenEndpoint,w,[])}async revokeToken(w){await this.client.revokeToken(this.tokenRevocationEndpoint,w)}}var RG="https://lichess.org/oauth",CG="https://lichess.org/api/token";class Q5{client;constructor(w,z){this.client=new f(w,null,z)}createAuthorizationURL(w,z,U){return this.client.createAuthorizationURLWithPKCE(RG,w,W0.S256,z,U)}async validateAuthorizationCode(w,z){return await this.client.validateAuthorizationCode(CG,w,z)}}var KG="https://access.line.me/oauth2/v2.1/authorize",EW="https://api.line.me/oauth2/v2.1/token";class Y5{clientId;clientSecret;redirectURI;constructor(w,z,U){this.clientId=w,this.clientSecret=z,this.redirectURI=U}createAuthorizationURL(w,z,U){let W=new URL(KG);if(W.searchParams.set("response_type","code"),W.searchParams.set("client_id",this.clientId),W.searchParams.set("state",w),U.length>0)W.searchParams.set("scope",U.join(" "));W.searchParams.set("redirect_uri",this.redirectURI);let A=W4(z);return W.searchParams.set("code_challenge_method","S256"),W.searchParams.set("code_challenge",A),W}async validateAuthorizationCode(w,z){let U=new URLSearchParams;U.set("grant_type","authorization_code"),U.set("code",w),U.set("code_verifier",z),U.set("redirect_uri",this.redirectURI),U.set("client_id",this.clientId),U.set("client_secret",this.clientSecret);let W=g(EW,U);return await c(W)}async refreshAccessToken(w){let z=new URLSearchParams;z.set("grant_type","refresh_token"),z.set("refresh_token",w),z.set("client_id",this.clientId),z.set("client_secret",this.clientSecret);let U=g(EW,z);return await c(U)}}var FG="https://linear.app/oauth/authorize",jG="https://api.linear.app/oauth/token";class J5{clientId;clientSecret;redirectURI;constructor(w,z,U){this.clientId=w,this.clientSecret=z,this.redirectURI=U}createAuthorizationURL(w,z){let U=new URL(FG);if(U.searchParams.set("response_type","code"),U.searchParams.set("client_id",this.clientId),U.searchParams.set("state",w),z.length>0)U.searchParams.set("scope",z.join(" "));return U.searchParams.set("redirect_uri",this.redirectURI),U}async validateAuthorizationCode(w){let z=new URLSearchParams;z.set("grant_type","authorization_code"),z.set("code",w),z.set("redirect_uri",this.redirectURI),z.set("client_id",this.clientId),z.set("client_secret",this.clientSecret);let U=g(jG,z);return await c(U)}}var EG="https://www.linkedin.com/oauth/v2/authorization",IW="https://www.linkedin.com/oauth/v2/accessToken";class B5{clientId;clientSecret;redirectURI;constructor(w,z,U){this.clientId=w,this.clientSecret=z,this.redirectURI=U}createAuthorizationURL(w,z){let U=new URL(EG);if(U.searchParams.set("response_type","code"),U.searchParams.set("client_id",this.clientId),U.searchParams.set("state",w),z.length>0)U.searchParams.set("scope",z.join(" "));return U.searchParams.set("redirect_uri",this.redirectURI),U}async validateAuthorizationCode(w){let z=new URLSearchParams;z.set("grant_type","authorization_code"),z.set("code",w),z.set("redirect_uri",this.redirectURI),z.set("client_id",this.clientId),z.set("client_secret",this.clientSecret);let U=g(IW,z);return await c(U)}async refreshAccessToken(w){let z=new URLSearchParams;z.set("grant_type","refresh_token"),z.set("refresh_token",w),z.set("client_id",this.clientId),z.set("client_secret",this.clientSecret);let U=g(IW,z);return await c(U)}}class M5{authorizationEndpoint;tokenEndpoint;client;constructor(w,z,U,W){this.authorizationEndpoint=M2("https://login.microsoftonline.com",w,"/oauth2/v2.0/authorize"),this.tokenEndpoint=M2("https://login.microsoftonline.com",w,"/oauth2/v2.0/token"),this.client=new f(z,U,W)}createAuthorizationURL(w,z,U){return this.client.createAuthorizationURLWithPKCE(this.authorizationEndpoint,w,W0.S256,z,U)}async validateAuthorizationCode(w,z){return await this.client.validateAuthorizationCode(this.tokenEndpoint,w,z)}async refreshAccessToken(w,z){return await this.client.refreshAccessToken(this.tokenEndpoint,w,z)}}var IG="https://myanimelist.net/v1/oauth2/authorize",xW="https://myanimelist.net/v1/oauth2/token";class q5{client;constructor(w,z,U){this.client=new f(w,z,U)}createAuthorizationURL(w,z){return this.client.createAuthorizationURLWithPKCE(IG,w,W0.Plain,z,[])}async validateAuthorizationCode(w,z){return await this.client.validateAuthorizationCode(xW,w,z)}async refreshAccessToken(w){return await this.client.refreshAccessToken(xW,w,[])}}var xG="https://api.notion.com/v1/oauth/authorize",VG="https://api.notion.com/v1/oauth/token";class H5{client;constructor(w,z,U){this.client=new f(w,z,U)}createAuthorizationURL(w){let z=this.client.createAuthorizationURL(xG,w,[]);return z.searchParams.set("owner","user"),z}async validateAuthorizationCode(w){return await this.client.validateAuthorizationCode(VG,w,null)}}class G5{authorizationEndpoint;tokenEndpoint;tokenRevocationEndpoint;client;constructor(w,z,U,W,A){let X=`https://${w}/oauth2`;if(z!==null)X=M2(X,z);this.authorizationEndpoint=M2(X,"/v1/authorize"),this.tokenEndpoint=M2(X,"/v1/token"),this.tokenRevocationEndpoint=M2(X,"/v1/revoke"),this.client=new f(U,W,A)}createAuthorizationURL(w,z,U){return this.client.createAuthorizationURLWithPKCE(this.authorizationEndpoint,w,W0.S256,z,U)}async validateAuthorizationCode(w,z){return await this.client.validateAuthorizationCode(this.tokenEndpoint,w,z)}async refreshAccessToken(w,z){return await this.client.refreshAccessToken(this.tokenEndpoint,w,z)}async revokeToken(w){await this.client.revokeToken(this.tokenRevocationEndpoint,w)}}var kG="https://osu.ppy.sh/oauth/authorize",VW="https://osu.ppy.sh/oauth/token";class L5{clientId;clientSecret;redirectURI;constructor(w,z,U){this.clientId=w,this.clientSecret=z,this.redirectURI=U}createAuthorizationURL(w,z){let U=new URL(kG);if(U.searchParams.set("response_type","code"),U.searchParams.set("client_id",this.clientId),U.searchParams.set("state",w),z.length>0)U.searchParams.set("scope",z.join(" "));if(this.redirectURI!==null)U.searchParams.set("redirect_uri",this.redirectURI);return U}async validateAuthorizationCode(w){let z=new URLSearchParams;if(z.set("grant_type","authorization_code"),z.set("code",w),this.redirectURI!==null)z.set("redirect_uri",this.redirectURI);z.set("client_id",this.clientId),z.set("client_secret",this.clientSecret);let U=g(VW,z);return await c(U)}async refreshAccessToken(w){let z=new URLSearchParams;z.set("grant_type","refresh_token"),z.set("refresh_token",w),z.set("client_id",this.clientId),z.set("client_secret",this.clientSecret);let U=g(VW,z);return await c(U)}}var TG="https://www.patreon.com/oauth2/authorize",kW="https://www.patreon.com/api/oauth2/token";class N5{clientId;clientSecret;redirectURI;constructor(w,z,U){this.clientId=w,this.clientSecret=z,this.redirectURI=U}createAuthorizationURL(w,z){let U=new URL(TG);if(U.searchParams.set("response_type","code"),U.searchParams.set("client_id",this.clientId),U.searchParams.set("state",w),z.length>0)U.searchParams.set("scope",z.join(" "));return U.searchParams.set("redirect_uri",this.redirectURI),U}async validateAuthorizationCode(w){let z=new URLSearchParams;z.set("grant_type","authorization_code"),z.set("code",w),z.set("redirect_uri",this.redirectURI),z.set("client_id",this.clientId),z.set("client_secret",this.clientSecret);let U=g(kW,z);return await c(U)}async refreshAccessToken(w){let z=new URLSearchParams;z.set("grant_type","refresh_token"),z.set("refresh_token",w),z.set("client_id",this.clientId),z.set("client_secret",this.clientSecret);let U=g(kW,z);return await c(U)}}var gG="https://www.reddit.com/api/v1/authorize",TW="https://www.reddit.com/api/v1/access_token";class S5{client;constructor(w,z,U){this.client=new f(w,z,U)}createAuthorizationURL(w,z){return this.client.createAuthorizationURL(gG,w,z)}async validateAuthorizationCode(w){return await this.client.validateAuthorizationCode(TW,w,null)}async refreshAccessToken(w){return await this.client.refreshAccessToken(TW,w,[])}}var fG="https://apis.roblox.com/oauth/v1/authorize",gW="https://apis.roblox.com/oauth/v1/token",dG="https://apis.roblox.com/oauth/v1/token/revoke";class _5{client;constructor(w,z,U){this.client=new f(w,z,U)}createAuthorizationURL(w,z,U){return this.client.createAuthorizationURLWithPKCE(fG,w,W0.S256,z,U)}async validateAuthorizationCode(w,z){return await this.client.validateAuthorizationCode(gW,w,z)}async refreshAccessToken(w){return await this.client.refreshAccessToken(gW,w,[])}async revokeToken(w){await this.client.revokeToken(dG,w)}}class D5{authorizationEndpoint;tokenEndpoint;tokenRevocationEndpoint;client;constructor(w,z,U,W){this.authorizationEndpoint=`https://${w}/services/oauth2/authorize`,this.tokenEndpoint=`https://${w}/services/oauth2/token`,this.tokenRevocationEndpoint=`https://${w}/services/oauth2/revoke`,this.client=new f(z,U,W)}createAuthorizationURL(w,z,U){return this.client.createAuthorizationURLWithPKCE(this.authorizationEndpoint,w,W0.S256,z,U)}async validateAuthorizationCode(w,z){return await this.client.validateAuthorizationCode(this.tokenEndpoint,w,z)}async refreshAccessToken(w){return await this.client.refreshAccessToken(this.tokenEndpoint,w,[])}async revokeToken(w){await this.client.revokeToken(this.tokenRevocationEndpoint,w)}}var hG="https://shikimori.one/oauth/authorize",fW="https://shikimori.one/oauth/token";class P5{clientId;clientSecret;redirectURI;constructor(w,z,U){this.clientId=w,this.clientSecret=z,this.redirectURI=U}createAuthorizationURL(w){let z=new URL(hG);return z.searchParams.set("response_type","code"),z.searchParams.set("client_id",this.clientId),z.searchParams.set("state",w),z.searchParams.set("redirect_uri",this.redirectURI),z}async validateAuthorizationCode(w){let z=new URLSearchParams;z.set("grant_type","authorization_code"),z.set("code",w),z.set("redirect_uri",this.redirectURI),z.set("client_id",this.clientId),z.set("client_secret",this.clientSecret);let U=g(fW,z);return await c(U)}async refreshAccessToken(w){let z=new URLSearchParams;z.set("grant_type","refresh_token"),z.set("refresh_token",w),z.set("client_id",this.clientId),z.set("client_secret",this.clientSecret);let U=g(fW,z);return await c(U)}}var yG="https://slack.com/openid/connect/authorize",cG="https://slack.com/api/openid.connect.token";class O5{client;constructor(w,z,U){this.client=new f(w,z,U)}createAuthorizationURL(w,z){return this.client.createAuthorizationURL(yG,w,z)}async validateAuthorizationCode(w){return await this.client.validateAuthorizationCode(cG,w,null)}}var dW="https://accounts.spotify.com/authorize",hW="https://accounts.spotify.com/api/token";class b5{client;constructor(w,z,U){this.client=new f(w,z,U)}createAuthorizationURL(w,z,U){let W;if(z!==null)W=this.client.createAuthorizationURLWithPKCE(dW,w,W0.S256,z,U);else W=this.client.createAuthorizationURL(dW,w,U);return W}async validateAuthorizationCode(w,z){return await this.client.validateAuthorizationCode(hW,w,z)}async refreshAccessToken(w){return await this.client.refreshAccessToken(hW,w,[])}}var iG="https://www.strava.com/oauth/authorize",vG="https://www.strava.com/oauth/token";class R5{clientId;clientSecret;redirectURI;constructor(w,z,U){this.clientId=w,this.clientSecret=z,this.redirectURI=U}createAuthorizationURL(w,z){let U=new URL(iG);if(U.searchParams.set("response_type","code"),U.searchParams.set("client_id",this.clientId),U.searchParams.set("state",w),z.length>0)U.searchParams.set("scope",z.join(","));return U.searchParams.set("redirect_uri",this.redirectURI),U}async validateAuthorizationCode(w){let z=new URLSearchParams;z.set("grant_type","authorization_code"),z.set("code",w),z.set("redirect_uri",this.redirectURI),z.set("client_id",this.clientId),z.set("client_secret",this.clientSecret);let U=g(vG,z);return await c(U)}}var nG="https://v5api.tiltify.com/oauth/authorizeze",yW="https://v5api.tiltify.com/oauth/token";class C5{clientId;clientSecret;redirectURI;constructor(w,z,U){this.clientId=w,this.clientSecret=z,this.redirectURI=U}createAuthorizationURL(w,z){let U=new URL(nG);if(U.searchParams.set("response_type","code"),U.searchParams.set("client_id",this.clientId),U.searchParams.set("state",w),z.length>0)U.searchParams.set("scope",z.join(" "));return U.searchParams.set("redirect_uri",this.redirectURI),U}async validateAuthorizationCode(w){let z=new URLSearchParams;z.set("grant_type","authorization_code"),z.set("code",w),z.set("redirect_uri",this.redirectURI),z.set("client_id",this.clientId),z.set("client_secret",this.clientSecret);let U=g(yW,z);return await c(U)}async refreshAccessToken(w){let z=new URLSearchParams;z.set("grant_type","refresh_token"),z.set("refresh_token",w),z.set("client_id",this.clientId),z.set("client_secret",this.clientSecret);let U=g(yW,z);return await c(U)}}var uG="https://www.tumblr.com/oauth2/authorize",cW="https://api.tumblr.com/v2/oauth2/token";class K5{client;constructor(w,z,U){this.client=new f(w,z,U)}createAuthorizationURL(w,z){return this.client.createAuthorizationURL(uG,w,z)}async validateAuthorizationCode(w){return await this.client.validateAuthorizationCode(cW,w,null)}async refreshAccessToken(w){return await this.client.refreshAccessToken(cW,w,[])}}var mG="https://id.twitch.tv/oauth2/authorize",iW="https://id.twitch.tv/oauth2/token";class F5{clientId;clientSecret;redirectURI;constructor(w,z,U){this.clientId=w,this.clientSecret=z,this.redirectURI=U}createAuthorizationURL(w,z){let U=new URL(mG);if(U.searchParams.set("response_type","code"),U.searchParams.set("client_id",this.clientId),U.searchParams.set("state",w),z.length>0)U.searchParams.set("scope",z.join(" "));return U.searchParams.set("redirect_uri",this.redirectURI),U}async validateAuthorizationCode(w){let z=new URLSearchParams;z.set("grant_type","authorization_code"),z.set("code",w),z.set("redirect_uri",this.redirectURI),z.set("client_id",this.clientId),z.set("client_secret",this.clientSecret);let U=g(iW,z);return await c(U)}async refreshAccessToken(w){let z=new URLSearchParams;z.set("grant_type","refresh_token"),z.set("refresh_token",w),z.set("client_id",this.clientId),z.set("client_secret",this.clientSecret);let U=g(iW,z);return await c(U)}}var tG="https://twitter.com/i/oauth2/authorize",vW="https://api.twitter.com/2/oauth2/token",pG="https://api.twitter.com/2/oauth2/revoke";class j5{client;constructor(w,z,U){this.client=new f(w,z,U)}createAuthorizationURL(w,z,U){return this.client.createAuthorizationURLWithPKCE(tG,w,W0.S256,z,U)}async validateAuthorizationCode(w,z){return await this.client.validateAuthorizationCode(vW,w,z)}async refreshAccessToken(w){return await this.client.refreshAccessToken(vW,w,[])}async revokeToken(w){await this.client.revokeToken(pG,w)}}var oG="https://oauth.vk.com/authorize",lG="https://oauth.vk.com/access_token";class E5{clientId;clientSecret;redirectURI;constructor(w,z,U){this.clientId=w,this.clientSecret=z,this.redirectURI=U}createAuthorizationURL(w,z){let U=new URL(oG);if(U.searchParams.set("response_type","code"),U.searchParams.set("client_id",this.clientId),U.searchParams.set("state",w),z.length>0)U.searchParams.set("scope",z.join(" "));return U.searchParams.set("redirect_uri",this.redirectURI),U}async validateAuthorizationCode(w){let z=new URLSearchParams;z.set("grant_type","authorization_code"),z.set("code",w),z.set("redirect_uri",this.redirectURI),z.set("client_id",this.clientId),z.set("client_secret",this.clientSecret);let U=g(lG,z);return await c(U)}}var sG="https://api.workos.com/sso/authorize",rG="https://api.workos.com/sso/token";class I5{clientId;clientSecret;redirectURI;constructor(w,z,U){this.clientId=w,this.clientSecret=z,this.redirectURI=U}createAuthorizationURL(w,z){let U=new URL(sG);if(U.searchParams.set("response_type","code"),U.searchParams.set("client_id",this.clientId),U.searchParams.set("state",w),U.searchParams.set("redirect_uri",this.redirectURI),z!==null){let W=W4(z);U.searchParams.set("code_challenge_method","S256"),U.searchParams.set("code_challenge",W)}return U}async validateAuthorizationCode(w,z){let U=new URLSearchParams;if(U.set("grant_type","authorization_code"),U.set("code",w),U.set("redirect_uri",this.redirectURI),U.set("client_id",this.clientId),this.clientSecret!==null)U.set("client_secret",this.clientSecret);if(z!==null)U.set("code_verifier",z);let W=g(rG,U);return await c(W)}}var aG="https://api.login.yahoo.com/oauth2/request_auth",nW="https://api.login.yahoo.com/oauth2/get_token";class x5{client;constructor(w,z,U){this.client=new f(w,z,U)}createAuthorizationURL(w,z){return this.client.createAuthorizationURL(aG,w,z)}async validateAuthorizationCode(w){return await this.client.validateAuthorizationCode(nW,w,null)}async refreshAccessToken(w){return await this.client.refreshAccessToken(nW,w,[])}}var eG="https://oauth.yandex.com/authorize",uW="https://oauth.yandex.com/token";class V5{client;constructor(w,z,U){this.client=new f(w,z,U)}createAuthorizationURL(w,z){return this.client.createAuthorizationURL(eG,w,z)}async validateAuthorizationCode(w){return await this.client.validateAuthorizationCode(uW,w,null)}async refreshAccessToken(w){return await this.client.refreshAccessToken(uW,w,[])}}var wL="https://zoom.us/oauth/authorize",mW="https://zoom.us/oauth/token",zL="https://zoom.us/oauth/revoke";class k5{client;constructor(w,z,U){this.client=new f(w,z,U)}createAuthorizationURL(w,z,U){return this.client.createAuthorizationURLWithPKCE(wL,w,W0.S256,z,U)}async validateAuthorizationCode(w,z){return await this.client.validateAuthorizationCode(mW,w,z)}async refreshAccessToken(w){return await this.client.refreshAccessToken(mW,w,[])}async revokeToken(w){await this.client.revokeToken(zL,w)}}var UL="https://api.intra.42.fr/oauth/authorize",WL="https://api.intra.42.fr/oauth/token";class T5{clientId;clientSecret;redirectURI;constructor(w,z,U){this.clientId=w,this.clientSecret=z,this.redirectURI=U}createAuthorizationURL(w,z){let U=new URL(UL);if(U.searchParams.set("response_type","code"),U.searchParams.set("client_id",this.clientId),U.searchParams.set("state",w),z.length>0)U.searchParams.set("scope",z.join(" "));return U.searchParams.set("redirect_uri",this.redirectURI),U}async validateAuthorizationCode(w){let z=new URLSearchParams;z.set("grant_type","authorization_code"),z.set("code",w),z.set("redirect_uri",this.redirectURI),z.set("client_id",this.clientId),z.set("client_secret",this.clientSecret);let U=g(WL,z);return await c(U)}}function rw(w){try{return qW(w)}catch(z){throw new Error("Invalid ID token",{cause:z})}}var c4={AmazonCognito:i8,AniList:v8,Apple:u8,Atlassian:m8,Auth0:t8,Authentik:p8,Bitbucket:o8,Box:l8,Coinbase:s8,Discord:r8,Dribbble:a8,Dropbox:e8,Facebook:w5,Figma:z5,Intuit:U5,GitHub:W5,GitLab:A5,Google:X5,Kakao:Z5,KeyCloak:$5,Lichess:Q5,Line:Y5,Linear:J5,LinkedIn:B5,MicrosoftEntraId:M5,MyAnimeList:q5,Notion:H5,Okta:G5,Osu:L5,Patreon:N5,Reddit:S5,Roblox:_5,Salesforce:D5,Shikimori:P5,Slack:O5,Spotify:b5,Strava:R5,Tiltify:C5,Tumblr:K5,Twitch:F5,Twitter:j5,VK:E5,WorkOS:I5,Yahoo:x5,Yandex:V5,Zoom:k5,FortyTwo:T5},tW=Object.keys(c4).reduce((w,z)=>{return w[z.toLowerCase()]=z,w},{}),i4={AmazonCognito:"https://{region}.amazonaws.com/{userPoolId}/.well-known/openid-configuration",AniList:"https://graphql.anilist.co",Apple:"https://appleid.apple.com/auth/token",Atlassian:"https://api.atlassian.com/me",Auth0:"https://{your_domain}/userinfo",Authentik:"https://{your_domain}/api/v1/user/me",Bitbucket:"https://api.bitbucket.org/2.0/user",Box:"https://api.box.com/2.0/users/me",Coinbase:"https://api.coinbase.com/v2/user",Discord:"https://discord.com/api/users/@me",Dribbble:"https://api.dribbble.com/v2/user",Dropbox:"https://api.dropboxapi.com/2/users/get_current_account",Facebook:"https://graph.facebook.com/me",Figma:"https://api.figma.com/v1/me",Intuit:"https://accounts.platform.intuit.com/v1/openid_connect/userinfo",GitHub:"https://api.github.com/user",GitLab:"https://gitlab.com/api/v4/user",Google:"https://www.googleapis.com/userinfo/v2/me",Kakao:"https://kapi.kakao.com/v2/user/me",KeyCloak:"https://{your_domain}/auth/realms/{realm}/protocol/openid-connect/userinfo",Lichess:"https://lichess.org/api/account",Line:"https://api.line.me/v2/profile",Linear:"https://api.linear.app/v1/me",LinkedIn:"https://api.linkedin.com/v2/me",MicrosoftEntraId:"https://graph.microsoft.com/v1.0/me",MyAnimeList:"https://myanimelist.net/v1/users/@me",Notion:"https://api.notion.com/v1/users/me",Okta:"https://{yourOktaDomain}/oauth2/v1/userinfo",Osu:"https://osu.ppy.sh/api/v2/me",Patreon:"https://www.patreon.com/api/oauth2/v2/identity",Reddit:"https://oauth.reddit.com/api/v1/me",Roblox:"https://apis.roblox.com/users/v1/users/me",Salesforce:"https://login.salesforce.com/services/oauth2/userinfo",Shikimori:"https://shikimori.one/api/users/whoami",Slack:"https://slack.com/api/users.identity",Spotify:"https://api.spotify.com/v1/me",Strava:"https://www.strava.com/api/v3/athlete",Tiltify:"https://tiltify.com/api/v3/user",Tumblr:"https://api.tumblr.com/v2/user/info",Twitch:"https://api.twitch.tv/helix/users",Twitter:"https://api.twitter.com/2/users/me",VK:"https://api.vk.com/method/users.get",WorkOS:"https://api.workos.com/sso/profile",Yahoo:"https://api.login.yahoo.com/openid/v1/userinfo",Yandex:"https://login.yandex.ru/info",Zoom:"https://api.zoom.us/v2/users/me",FortyTwo:"https://api.intra.42.fr/v2/me"},pW={AmazonCognito:"https://cognito-idp.{region}.amazonaws.com/{userPoolId}",AniList:"https://anilist.co/api/v2/oauth/authorize",Apple:"https://appleid.apple.com",Atlassian:"https://auth.atlassian.com",Auth0:"https://{your_domain}.auth0.com",Authentik:"https://{your_domain}",Bitbucket:"https://bitbucket.org/site/oauth2/authorize",Box:"https://account.box.com/api/oauth2/authorize",Coinbase:"https://www.coinbase.com/oauth/authorize",Discord:"https://discord.com/api/oauth2/authorize",Dribbble:"https://dribbble.com/oauth/authorize",Dropbox:"https://www.dropbox.com/oauth2/authorize",Facebook:"https://www.facebook.com/v12.0/dialog/oauth",Figma:"https://www.figma.com/oauth",Intuit:"https://appcenter.intuit.com/connect/oauth2",GitHub:"https://github.com/login/oauth/authorize",GitLab:"https://gitlab.com/oauth/authorize",Google:"https://accounts.google.com",Kakao:"https://kauth.kakao.com/oauth/authorize",KeyCloak:"https://{your_domain}/auth",Lichess:"https://lichess.org/oauth/authorize",Line:"https://access.line.me/oauth2/v2.1/authorize",Linear:"https://linear.app/oauth/authorize",LinkedIn:"https://www.linkedin.com/oauth/v2/authorization",MicrosoftEntraId:"https://login.microsoftonline.com/{tenant}/v2.0",MyAnimeList:"https://myanimelist.net/v1/oauth2/authorize",Notion:"https://api.notion.com/v1/oauth/authorize",Okta:"https://{yourOktaDomain}/oauth2/default/v1/authorize",Osu:"https://osu.ppy.sh/oauth/authorize",Patreon:"https://www.patreon.com/oauth2/authorize",Reddit:"https://www.reddit.com/api/v1/authorize",Roblox:"https://apis.roblox.com/oauth/v1/authorize",Salesforce:"https://login.salesforce.com/services/oauth2/authorize",Shikimori:"https://shikimori.one/oauth/authorize",Slack:"https://slack.com/oauth/v2/authorize",Spotify:"https://accounts.spotify.com/authorize",Strava:"https://www.strava.com/oauth/authorize",Tiltify:"https://tiltify.com/oauth/authorize",Tumblr:"https://www.tumblr.com/oauth/authorize",Twitch:"https://id.twitch.tv/oauth2/authorize",Twitter:"https://api.twitter.com/oauth/authorize",VK:"https://oauth.vk.com/authorize",WorkOS:"https://api.workos.com/sso/authorize",Yahoo:"https://api.login.yahoo.com/oauth2/request_auth",Yandex:"https://oauth.yandex.com/authorize",Zoom:"https://zoom.us/oauth/authorize",FortyTwo:"https://api.intra.42.fr/oauth/authorize"},oW=Object.keys(i4).reduce((w,z)=>{return w[z.toLowerCase()]=z,w},{}),IT=Object.keys(pW).reduce((w,z)=>{return w[z.toLowerCase()]=z,w},{});var lW=({logoutRoute:w="logout",onLogout:z})=>{return new j0().post(`/${w}`,async({error:U,cookie:{user_session_id:W,auth_provider:A}})=>{if(A.value===void 0)return U(401,"No auth provider found");try{return z?.(),W.remove(),A.remove(),new Response("Succesfuly Logged Out",{status:204})}catch(X){if(X instanceof Error)console.error("Failed to refresh token:",X.message);return U(500)}})};var sW=(w)=>{return"refreshAccessToken"in w&&typeof w.refreshAccessToken==="function"};var Q6=(w)=>{return Object.keys(c4).map((z)=>z.toLowerCase()).includes(w.toLowerCase())},rW=(w)=>{return Object.keys(i4).includes(w)};var aW=(w)=>{return!0};var eW=({clientProviders:w,revokeRoute:z="revoke",onRevoke:U})=>{return new j0().post(`/${z}/access-token`,async({error:W,cookie:{user_refresh_token:A,auth_provider:X}})=>{if(A.value===void 0)return W(401,"No refresh token found");if(X.value===void 0)return W(401,"No auth provider found");if(!Q6(X.value))return W(400,"Invalid provider");let Z=X.value.toLowerCase(),{providerInstance:$}=w[Z];U?.()})};var X4=()=>{return new j0({name:"sessionStore"}).state({session:{}})};var wA=({statusRoute:w="auth-status",onStatus:z})=>{return new j0().use(X4()).get(`/${w}`,async({error:U,cookie:{user_session_id:W,auth_provider:A},store:{session:X}})=>{try{if(W.value===void 0)return new Response(JSON.stringify({user:null}),{headers:{"Content-Type":"application/json"}});if(A.value===void 0)return new Response(JSON.stringify({user:null}),{headers:{"Content-Type":"application/json"}});let Z=X[W.value];if(Z===void 0)return new Response(JSON.stringify({user:null}),{headers:{"Content-Type":"application/json"}});let $=Z.user;return z?.(),new Response(JSON.stringify({user:$}),{headers:{"Content-Type":"application/json"}})}catch(Z){if(Z instanceof Error)console.error("Failed to get auth status: ",Z.message);return U(500)}})};var zA=({clientProviders:w,refreshRoute:z="refresh",onRefresh:U})=>{return new j0().post(`/${z}`,async({error:W,cookie:{user_refresh_token:A,auth_provider:X}})=>{if(A.value===void 0)return W(401,"No refresh token found");if(X.value===void 0)return W(401,"No auth provider found");let Z=X.value.toLowerCase(),{providerInstance:$}=w[Z];if(!sW($))return W(401,"Provider is not refreshable");try{let Q=await $.refreshAccessToken(A.value);return U?.(),new Response("Token refreshed",{status:204})}catch(Q){if(Q instanceof Error)console.error("Failed to refresh token:",Q.message);return W(500)}})};var UA=({clientProviders:w,authorizeRoute:z="authorize",onAuthorize:U})=>{return new j0().get(`/${z}/:provider`,({error:W,redirect:A,cookie:{state:X,code_verifier:Z,auth_provider:$,redirect_url:Q},params:{provider:Y},headers:B})=>{if(Y===void 0)return W(400,"Provider is required");if(!Q6(Y))return W(400,"Invalid provider");try{let G=Y.toLowerCase(),{providerInstance:_,scopes:H,searchParams:F}=w[G],R=B.referer||"/";Q.set({value:R,secure:!0,sameSite:"lax",path:"/",httpOnly:!0,maxAge:600}),$.set({value:Y,secure:!0,sameSite:"lax",path:"/",httpOnly:!0,maxAge:600});let J=ow();X.set({value:J,secure:!0,sameSite:"lax",path:"/",httpOnly:!0,maxAge:600});let m,A0;if(_.createAuthorizationURL.toString().includes("codeVerifier"))A0=pw(),Z.set({value:A0,secure:!0,sameSite:"lax",path:"/",httpOnly:!0,maxAge:600}),m=_.createAuthorizationURL(J,A0,H);else m=_.createAuthorizationURL(J,H);return F.forEach(([L0,h])=>{m.searchParams.set(L0,h)}),U?.(),A(m.toString())}catch(G){if(G instanceof Error)console.error("Failed to validate authorization code:",G.message);return W(500)}})};var WA=({clientProviders:w,callbackRoute:z="authorize/callback",onCallback:U,getUser:W,createUser:A})=>{return new j0().use(X4()).get(`/${z}`,async({error:X,redirect:Z,store:{session:$},cookie:{state:Q,code_verifier:Y,redirect_url:B,user_session_id:G,auth_provider:_},query:{code:H,state:F}})=>{if(!H||!Q.value)return X(400,"Invalid callback request");if(F!==Q.value)return X(400,"Invalid state mismatch");if(_.value===void 0)return X(401,"No auth provider found");if(!Q6(_.value))return X(400,"Invalid provider");let R=_.value.toLowerCase(),{providerInstance:J}=w[R];try{let m;if(Q.remove(),J.validateAuthorizationCode.toString().includes("codeVerifier")){if(!Y.value)return X(400,"Code verifier not found and is required");m=await J.validateAuthorizationCode(H,Y.value),Y.remove()}else m=await J.validateAuthorizationCode(H);let A0=rw(m.idToken()),L0=_.value,h=await W?.({decodedIdToken:A0,authProvider:L0});if(h===null||h===void 0)h=await A?.({decodedIdToken:A0,authProvider:L0});let a=crypto.randomUUID();if(!aW(h))return X(500,"Invalid user schema");$[a]={user:h,expiresAt:Date.now()+86400000},G.set({value:a,secure:!0,httpOnly:!0,sameSite:"lax"}),U?.();let x=B.value??"/";return Z(x)}catch(m){if(m instanceof Error)console.error("Failed to validate authorization code:",m.message);return X(500)}})};var AA=()=>{return new j0().use(X4()).derive(({store:{session:w},cookie:{user_session_id:z},error:U})=>{return{protectRoute:async(W,A)=>{if(z.value===void 0)return A?.()??U(401,"No session ID found");if(w[z.value]===void 0)return A?.()??U(401,"No session found");return W()}}}).as("plugin")};var Lg=({config:w,authorizeRoute:z,callbackRoute:U,logoutRoute:W,statusRoute:A,refreshRoute:X,revokeRoute:Z,onAuthorize:$,onCallback:Q,onStatus:Y,onRefresh:B,onLogout:G,onRevoke:_,createUser:H,getUser:F})=>{let R=Object.entries(w).reduce((J,[m,A0={}])=>{let L0=m.toLowerCase(),h=tW[L0],a=oW[L0];if(!h||!Q6(h))return console.error(`Provider ${m} is not supported`),J;let x=c4[h],i;if(rW(a))i=i4[a];let{credentials:K=[],scopes:o=[],searchParams:D0=[]}=A0,l=new x(...K);return J[L0]={providerInstance:l,scopes:o,searchParams:D0,userInfoURL:i},J},{});return new j0().error("OAUTH2_REQUEST_ERROR",h4).error("ARCTIC_FETCH_ERROR",$6).use(lW({logoutRoute:W,onLogout:G})).use(eW({clientProviders:R,revokeRoute:Z,onRevoke:_})).use(wA({statusRoute:A,onStatus:Y})).use(zA({clientProviders:R,refreshRoute:X,onRefresh:B})).use(UA({clientProviders:R,authorizeRoute:z,onAuthorize:$})).use(WA({clientProviders:R,callbackRoute:U,onCallback:Q,getUser:F,createUser:H})).use(AA()).as("plugin")};export{Lg as absoluteAuth};