diff --git a/.gitignore b/.gitignore index 87e5610..6972de0 100644 --- a/.gitignore +++ b/.gitignore @@ -14,6 +14,7 @@ # production /build +/dist # misc .DS_Store diff --git a/dist/controllers/units.js b/dist/controllers/units.js deleted file mode 100644 index 0c1bbe8..0000000 --- a/dist/controllers/units.js +++ /dev/null @@ -1,336 +0,0 @@ -// @bun -var tz=Object.create;var{getPrototypeOf:sz,defineProperty:G$,getOwnPropertyNames:rz}=Object;var az=Object.prototype.hasOwnProperty;var ez=(X,Z,Y)=>{Y=X!=null?tz(sz(X)):{};let $=Z||!X||!X.__esModule?G$(Y,"default",{value:X,enumerable:!0}):Y;for(let W of rz(X))if(!az.call($,W))G$($,W,{get:()=>X[W],enumerable:!0});return $};var XQ=(X,Z)=>()=>(Z||X((Z={exports:{}}).exports,Z),Z.exports);var EX=(X,Z)=>{for(var Y in Z)G$(X,Y,{get:Z[Y],enumerable:!0,configurable:!0,set:($)=>Z[Y]=()=>$})};var aW=XQ((rW)=>{Object.defineProperty(rW,"__esModule",{value:!0});rW.parse=pO;rW.serialize=cO;var fO=/^[\u0021-\u003A\u003C\u003E-\u007E]+$/,vO=/^[\u0021-\u003A\u003C-\u007E]*$/,yO=/^([.]?[a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?)([.][a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?)*$/i,dO=/^[\u0020-\u003A\u003D-\u007E]*$/,hO=Object.prototype.toString,mO=(()=>{let X=function(){};return X.prototype=Object.create(null),X})();function pO(X,Z){let Y=new mO,$=X.length;if($<2)return Y;let W=Z?.decode||uO,J=0;do{let z=X.indexOf("=",J);if(z===-1)break;let Q=X.indexOf(";",J),M=Q===-1?$:Q;if(z>M){J=X.lastIndexOf(";",z-1)+1;continue}let G=tW(X,J,z),U=sW(X,z,G),w=X.slice(G,U);if(Y[w]===void 0){let B=tW(X,z+1,M),N=sW(X,M,B),S=W(X.slice(B,N));Y[w]=S}J=M+1}while(J<$);return Y}function tW(X,Z,Y){do{let $=X.charCodeAt(Z);if($!==32&&$!==9)return Z}while(++ZY){let $=X.charCodeAt(--Z);if($!==32&&$!==9)return Z+1}return Y}function cO(X,Z,Y){let $=Y?.encode||encodeURIComponent;if(!fO.test(X))throw new TypeError(`argument name is invalid: ${X}`);let W=$(Z);if(!vO.test(W))throw new TypeError(`argument val is invalid: ${Z}`);let J=X+"="+W;if(!Y)return J;if(Y.maxAge!==void 0){if(!Number.isInteger(Y.maxAge))throw new TypeError(`option maxAge is invalid: ${Y.maxAge}`);J+="; Max-Age="+Y.maxAge}if(Y.domain){if(!yO.test(Y.domain))throw new TypeError(`option domain is invalid: ${Y.domain}`);J+="; Domain="+Y.domain}if(Y.path){if(!dO.test(Y.path))throw new TypeError(`option path is invalid: ${Y.path}`);J+="; Path="+Y.path}if(Y.expires){if(!iO(Y.expires)||!Number.isFinite(Y.expires.valueOf()))throw new TypeError(`option expires is invalid: ${Y.expires}`);J+="; Expires="+Y.expires.toUTCString()}if(Y.httpOnly)J+="; HttpOnly";if(Y.secure)J+="; Secure";if(Y.partitioned)J+="; Partitioned";if(Y.priority)switch(typeof Y.priority==="string"?Y.priority.toLowerCase():void 0){case"low":J+="; Priority=Low";break;case"medium":J+="; Priority=Medium";break;case"high":J+="; Priority=High";break;default:throw new TypeError(`option priority is invalid: ${Y.priority}`)}if(Y.sameSite)switch(typeof Y.sameSite==="string"?Y.sameSite.toLowerCase():Y.sameSite){case!0:case"strict":J+="; SameSite=Strict";break;case"lax":J+="; SameSite=Lax";break;case"none":J+="; SameSite=None";break;default:throw new TypeError(`option sameSite is invalid: ${Y.sameSite}`)}return J}function uO(X){if(X.indexOf("%")===-1)return X;try{return decodeURIComponent(X)}catch(Z){return X}}function iO(X){return hO.call(X)==="[object Date]"}});var N1=(X,Z)=>{let Y=Z?.length?{}:null;if(Y)for(let $ of Z)Y[$.part.charCodeAt(0)]=$;return{part:X,store:null,inert:Y,params:null,wildcardStore:null}},n6=(X,Z)=>({...X,part:Z}),l6=(X)=>({name:X,store:null,inert:null});class sX{config;root={};history=[];deferred=[];constructor(X={}){if(this.config=X,X.lazy)this.find=this.lazyFind}static regex={static:/:.+?(?=\/|$)/,params:/:.+?(?=\/|$)/g,optionalParams:/:.+?\?(?=\/|$)/g};lazyFind=(X,Z)=>{if(!this.config.lazy)return this.find;return this.build(),this.find(X,Z)};build(){if(!this.config.lazy)return;for(let[X,Z,Y]of this.deferred)this.add(X,Z,Y,{lazy:!1,ignoreHistory:!0});this.deferred=[],this.find=(X,Z)=>{let Y=this.root[X];if(!Y)return null;return vZ(Z,Z.length,Y,0)}}add(X,Z,Y,{ignoreError:$=!1,ignoreHistory:W=!1,lazy:J=this.config.lazy}={}){if(J)return this.find=this.lazyFind,this.deferred.push([X,Z,Y]),Y;if(typeof Z!=="string")throw new TypeError("Route path must be a string");if(Z==="")Z="/";else if(Z[0]!=="/")Z=`/${Z}`;let z=Z[Z.length-1]==="*",Q=Z.match(sX.regex.optionalParams);if(Q){let B=Z.replaceAll("?","");this.add(X,B,Y,{ignoreError:$,ignoreHistory:W,lazy:J});for(let N=0;NB===X&&N===Z))return Y;if(z||Q&&Z.charCodeAt(Z.length-1)===63)Z=Z.slice(0,-1);if(!W)this.history.push([X,Z,Y]);let M=Z.split(sX.regex.static),G=Z.match(sX.regex.params)||[];if(M[M.length-1]==="")M.pop();let U;if(!this.root[X])U=this.root[X]=N1("/");else U=this.root[X];let w=0;for(let B=0;B0){let S=G[w++].slice(1);if(U.params===null)U.params=l6(S);else if(U.params.name!==S)if($)return Y;else throw new Error(`Cannot create route "${Z}" with parameter "${S}" because a route already exists with a different parameter name ("${U.params.name}") in the same location`);let H=U.params;if(H.inert===null){U=H.inert=N1(N);continue}U=H.inert}for(let S=0;;){if(S===N.length){if(S{let W=Y.part,J=W.length,z=$+J;if(J>1){if(z>Z)return null;if(J<15){for(let Q=1,M=$+1;Q=Z){if(Q!==null){let w={};return w[M]=X.substring(z,Z),{store:Q,params:w}}}else if(G!==null){let w=vZ(X,Z,G,U);if(w!==null)return w.params[M]=X.substring(z,U),w}}}if(Y.wildcardStore!==null)return{store:Y.wildcardStore,params:{"*":X.substring(z,Z)}};return null};var K0={};EX(K0,{IsUndefined:()=>Y0,IsUint8Array:()=>JX,IsSymbol:()=>A$,IsString:()=>b8,IsRegExp:()=>e1,IsObject:()=>P8,IsNumber:()=>s0,IsNull:()=>D$,IsIterator:()=>H$,IsFunction:()=>U$,IsDate:()=>rX,IsBoolean:()=>WX,IsBigInt:()=>a1,IsAsyncIterator:()=>M$,IsArray:()=>Z0,HasPropertyKey:()=>yZ});function yZ(X,Z){return Z in X}function M$(X){return P8(X)&&!Z0(X)&&!JX(X)&&Symbol.asyncIterator in X}function Z0(X){return Array.isArray(X)}function a1(X){return typeof X==="bigint"}function WX(X){return typeof X==="boolean"}function rX(X){return X instanceof globalThis.Date}function U$(X){return typeof X==="function"}function H$(X){return P8(X)&&!Z0(X)&&!JX(X)&&Symbol.iterator in X}function D$(X){return X===null}function s0(X){return typeof X==="number"}function P8(X){return typeof X==="object"&&X!==null}function e1(X){return X instanceof globalThis.RegExp}function b8(X){return typeof X==="string"}function A$(X){return typeof X==="symbol"}function JX(X){return X instanceof globalThis.Uint8Array}function Y0(X){return X===void 0}function ZQ(X){return X.map((Z)=>dZ(Z))}function YQ(X){return new Date(X.getTime())}function $Q(X){return new Uint8Array(X)}function WQ(X){return new RegExp(X.source,X.flags)}function JQ(X){let Z={};for(let Y of Object.getOwnPropertyNames(X))Z[Y]=dZ(X[Y]);for(let Y of Object.getOwnPropertySymbols(X))Z[Y]=dZ(X[Y]);return Z}function dZ(X){return Z0(X)?ZQ(X):rX(X)?YQ(X):JX(X)?$Q(X):e1(X)?WQ(X):P8(X)?JQ(X):X}function p8(X){return dZ(X)}function L1(X,Z){return Z===void 0?p8(X):p8({...Z,...X})}function hZ(X){return W8(X)&&globalThis.Symbol.asyncIterator in X}function mZ(X){return W8(X)&&globalThis.Symbol.iterator in X}function _$(X){return W8(X)&&(globalThis.Object.getPrototypeOf(X)===Object.prototype||globalThis.Object.getPrototypeOf(X)===null)}function pZ(X){return X instanceof globalThis.Promise}function P0(X){return X instanceof Date&&globalThis.Number.isFinite(X.getTime())}function t6(X){return X instanceof globalThis.Map}function s6(X){return X instanceof globalThis.Set}function z2(X){return globalThis.ArrayBuffer.isView(X)}function F1(X){return X instanceof globalThis.Uint8Array}function l(X,Z){return Z in X}function W8(X){return X!==null&&typeof X==="object"}function t(X){return globalThis.Array.isArray(X)&&!globalThis.ArrayBuffer.isView(X)}function c8(X){return X===void 0}function zX(X){return X===null}function s2(X){return typeof X==="boolean"}function o(X){return typeof X==="number"}function cZ(X){return globalThis.Number.isInteger(X)}function O0(X){return typeof X==="bigint"}function O8(X){return typeof X==="string"}function CX(X){return typeof X==="function"}function QX(X){return typeof X==="symbol"}function r0(X){return O0(X)||s2(X)||zX(X)||o(X)||O8(X)||QX(X)||c8(X)}var h8;(function(X){X.InstanceMode="default",X.ExactOptionalPropertyTypes=!1,X.AllowArrayObject=!1,X.AllowNaN=!1,X.AllowNullVoid=!1;function Z(z,Q){return X.ExactOptionalPropertyTypes?Q in z:z[Q]!==void 0}X.IsExactOptionalProperty=Z;function Y(z){let Q=W8(z);return X.AllowArrayObject?Q:Q&&!t(z)}X.IsObjectLike=Y;function $(z){return Y(z)&&!(z instanceof Date)&&!(z instanceof Uint8Array)}X.IsRecordLike=$;function W(z){return X.AllowNaN?o(z):Number.isFinite(z)}X.IsNumberLike=W;function J(z){let Q=c8(z);return X.AllowNullVoid?Q||z===null:Q}X.IsVoidLike=J})(h8||(h8={}));function zQ(X){return globalThis.Object.freeze(X).map((Z)=>XZ(Z))}function QQ(X){return X}function GQ(X){return X}function MQ(X){return X}function UQ(X){let Z={};for(let Y of Object.getOwnPropertyNames(X))Z[Y]=XZ(X[Y]);for(let Y of Object.getOwnPropertySymbols(X))Z[Y]=XZ(X[Y]);return globalThis.Object.freeze(Z)}function XZ(X){return Z0(X)?zQ(X):rX(X)?QQ(X):JX(X)?GQ(X):e1(X)?MQ(X):P8(X)?UQ(X):X}function R(X,Z){let Y=Z!==void 0?{...Z,...X}:X;switch(h8.InstanceMode){case"freeze":return XZ(Y);case"clone":return p8(Y);default:return Y}}class n extends Error{constructor(X){super(X)}}var k8=Symbol.for("TypeBox.Transform"),E2=Symbol.for("TypeBox.Readonly"),N0=Symbol.for("TypeBox.Optional"),Q2=Symbol.for("TypeBox.Hint"),q=Symbol.for("TypeBox.Kind");function B1(X){return P8(X)&&X[E2]==="Readonly"}function g0(X){return P8(X)&&X[N0]==="Optional"}function w$(X){return A8(X,"Any")}function O$(X){return A8(X,"Argument")}function C2(X){return A8(X,"Array")}function aX(X){return A8(X,"AsyncIterator")}function eX(X){return A8(X,"BigInt")}function GX(X){return A8(X,"Boolean")}function P2(X){return A8(X,"Computed")}function I2(X){return A8(X,"Constructor")}function HQ(X){return A8(X,"Date")}function x2(X){return A8(X,"Function")}function T2(X){return A8(X,"Integer")}function l8(X){return A8(X,"Intersect")}function X1(X){return A8(X,"Iterator")}function A8(X,Z){return P8(X)&&q in X&&X[q]===Z}function uZ(X){return WX(X)||s0(X)||b8(X)}function a0(X){return A8(X,"Literal")}function e0(X){return A8(X,"MappedKey")}function u8(X){return A8(X,"MappedResult")}function PX(X){return A8(X,"Never")}function DQ(X){return A8(X,"Not")}function ZZ(X){return A8(X,"Null")}function b2(X){return A8(X,"Number")}function $0(X){return A8(X,"Object")}function Z1(X){return A8(X,"Promise")}function Y1(X){return A8(X,"Record")}function e8(X){return A8(X,"Ref")}function N$(X){return A8(X,"RegExp")}function MX(X){return A8(X,"String")}function YZ(X){return A8(X,"Symbol")}function X2(X){return A8(X,"TemplateLiteral")}function AQ(X){return A8(X,"This")}function K8(X){return P8(X)&&k8 in X}function Z2(X){return A8(X,"Tuple")}function UX(X){return A8(X,"Undefined")}function N8(X){return A8(X,"Union")}function _Q(X){return A8(X,"Uint8Array")}function wQ(X){return A8(X,"Unknown")}function OQ(X){return A8(X,"Unsafe")}function NQ(X){return A8(X,"Void")}function IX(X){return P8(X)&&q in X&&b8(X[q])}function o8(X){return w$(X)||O$(X)||C2(X)||GX(X)||eX(X)||aX(X)||P2(X)||I2(X)||HQ(X)||x2(X)||T2(X)||l8(X)||X1(X)||a0(X)||e0(X)||u8(X)||PX(X)||DQ(X)||ZZ(X)||b2(X)||$0(X)||Z1(X)||Y1(X)||e8(X)||N$(X)||MX(X)||YZ(X)||X2(X)||AQ(X)||Z2(X)||UX(X)||N8(X)||_Q(X)||wQ(X)||OQ(X)||NQ(X)||IX(X)}var L={};EX(L,{TypeGuardUnknownTypeError:()=>r6,IsVoid:()=>y9,IsUnsafe:()=>v9,IsUnknown:()=>f9,IsUnionLiteral:()=>VQ,IsUnion:()=>B$,IsUndefined:()=>k9,IsUint8Array:()=>g9,IsTuple:()=>b9,IsTransform:()=>T9,IsThis:()=>x9,IsTemplateLiteral:()=>I9,IsSymbol:()=>P9,IsString:()=>C9,IsSchema:()=>i8,IsRegExp:()=>E9,IsRef:()=>V9,IsRecursive:()=>SQ,IsRecord:()=>S9,IsReadonly:()=>qQ,IsProperties:()=>iZ,IsPromise:()=>j9,IsOptional:()=>KQ,IsObject:()=>R9,IsNumber:()=>K9,IsNull:()=>q9,IsNot:()=>B9,IsNever:()=>F9,IsMappedResult:()=>L9,IsMappedKey:()=>N9,IsLiteralValue:()=>O9,IsLiteralString:()=>_9,IsLiteralNumber:()=>w9,IsLiteralBoolean:()=>jQ,IsLiteral:()=>WZ,IsKindOf:()=>M8,IsKind:()=>d9,IsIterator:()=>A9,IsIntersect:()=>D9,IsInteger:()=>H9,IsImport:()=>RQ,IsFunction:()=>U9,IsDate:()=>M9,IsConstructor:()=>G9,IsComputed:()=>Q9,IsBoolean:()=>z9,IsBigInt:()=>J9,IsAsyncIterator:()=>W9,IsArray:()=>$9,IsArgument:()=>Y9,IsAny:()=>Z9});class r6 extends n{}var LQ=["Argument","Any","Array","AsyncIterator","BigInt","Boolean","Computed","Constructor","Date","Enum","Function","Integer","Intersect","Iterator","Literal","MappedKey","MappedResult","Not","Null","Number","Object","Promise","Record","Ref","RegExp","String","Symbol","TemplateLiteral","This","Tuple","Undefined","Union","Uint8Array","Unknown","Void"];function a6(X){try{return new RegExp(X),!0}catch{return!1}}function L$(X){if(!b8(X))return!1;for(let Z=0;Z=7&&Y<=13||Y===27||Y===127)return!1}return!0}function e6(X){return F$(X)||i8(X)}function $Z(X){return Y0(X)||a1(X)}function g8(X){return Y0(X)||s0(X)}function F$(X){return Y0(X)||WX(X)}function I8(X){return Y0(X)||b8(X)}function FQ(X){return Y0(X)||b8(X)&&L$(X)&&a6(X)}function BQ(X){return Y0(X)||b8(X)&&L$(X)}function X9(X){return Y0(X)||i8(X)}function qQ(X){return P8(X)&&X[E2]==="Readonly"}function KQ(X){return P8(X)&&X[N0]==="Optional"}function Z9(X){return M8(X,"Any")&&I8(X.$id)}function Y9(X){return M8(X,"Argument")&&s0(X.index)}function $9(X){return M8(X,"Array")&&X.type==="array"&&I8(X.$id)&&i8(X.items)&&g8(X.minItems)&&g8(X.maxItems)&&F$(X.uniqueItems)&&X9(X.contains)&&g8(X.minContains)&&g8(X.maxContains)}function W9(X){return M8(X,"AsyncIterator")&&X.type==="AsyncIterator"&&I8(X.$id)&&i8(X.items)}function J9(X){return M8(X,"BigInt")&&X.type==="bigint"&&I8(X.$id)&&$Z(X.exclusiveMaximum)&&$Z(X.exclusiveMinimum)&&$Z(X.maximum)&&$Z(X.minimum)&&$Z(X.multipleOf)}function z9(X){return M8(X,"Boolean")&&X.type==="boolean"&&I8(X.$id)}function Q9(X){return M8(X,"Computed")&&b8(X.target)&&Z0(X.parameters)&&X.parameters.every((Z)=>i8(Z))}function G9(X){return M8(X,"Constructor")&&X.type==="Constructor"&&I8(X.$id)&&Z0(X.parameters)&&X.parameters.every((Z)=>i8(Z))&&i8(X.returns)}function M9(X){return M8(X,"Date")&&X.type==="Date"&&I8(X.$id)&&g8(X.exclusiveMaximumTimestamp)&&g8(X.exclusiveMinimumTimestamp)&&g8(X.maximumTimestamp)&&g8(X.minimumTimestamp)&&g8(X.multipleOfTimestamp)}function U9(X){return M8(X,"Function")&&X.type==="Function"&&I8(X.$id)&&Z0(X.parameters)&&X.parameters.every((Z)=>i8(Z))&&i8(X.returns)}function RQ(X){return M8(X,"Import")&&yZ(X,"$defs")&&P8(X.$defs)&&iZ(X.$defs)&&yZ(X,"$ref")&&b8(X.$ref)&&X.$ref in X.$defs}function H9(X){return M8(X,"Integer")&&X.type==="integer"&&I8(X.$id)&&g8(X.exclusiveMaximum)&&g8(X.exclusiveMinimum)&&g8(X.maximum)&&g8(X.minimum)&&g8(X.multipleOf)}function iZ(X){return P8(X)&&Object.entries(X).every(([Z,Y])=>L$(Z)&&i8(Y))}function D9(X){return M8(X,"Intersect")&&(b8(X.type)&&X.type!=="object"?!1:!0)&&Z0(X.allOf)&&X.allOf.every((Z)=>i8(Z)&&!T9(Z))&&I8(X.type)&&(F$(X.unevaluatedProperties)||X9(X.unevaluatedProperties))&&I8(X.$id)}function A9(X){return M8(X,"Iterator")&&X.type==="Iterator"&&I8(X.$id)&&i8(X.items)}function M8(X,Z){return P8(X)&&q in X&&X[q]===Z}function _9(X){return WZ(X)&&b8(X.const)}function w9(X){return WZ(X)&&s0(X.const)}function jQ(X){return WZ(X)&&WX(X.const)}function WZ(X){return M8(X,"Literal")&&I8(X.$id)&&O9(X.const)}function O9(X){return WX(X)||s0(X)||b8(X)}function N9(X){return M8(X,"MappedKey")&&Z0(X.keys)&&X.keys.every((Z)=>s0(Z)||b8(Z))}function L9(X){return M8(X,"MappedResult")&&iZ(X.properties)}function F9(X){return M8(X,"Never")&&P8(X.not)&&Object.getOwnPropertyNames(X.not).length===0}function B9(X){return M8(X,"Not")&&i8(X.not)}function q9(X){return M8(X,"Null")&&X.type==="null"&&I8(X.$id)}function K9(X){return M8(X,"Number")&&X.type==="number"&&I8(X.$id)&&g8(X.exclusiveMaximum)&&g8(X.exclusiveMinimum)&&g8(X.maximum)&&g8(X.minimum)&&g8(X.multipleOf)}function R9(X){return M8(X,"Object")&&X.type==="object"&&I8(X.$id)&&iZ(X.properties)&&e6(X.additionalProperties)&&g8(X.minProperties)&&g8(X.maxProperties)}function j9(X){return M8(X,"Promise")&&X.type==="Promise"&&I8(X.$id)&&i8(X.item)}function S9(X){return M8(X,"Record")&&X.type==="object"&&I8(X.$id)&&e6(X.additionalProperties)&&P8(X.patternProperties)&&((Z)=>{let Y=Object.getOwnPropertyNames(Z.patternProperties);return Y.length===1&&a6(Y[0])&&P8(Z.patternProperties)&&i8(Z.patternProperties[Y[0]])})(X)}function SQ(X){return P8(X)&&Q2 in X&&X[Q2]==="Recursive"}function V9(X){return M8(X,"Ref")&&I8(X.$id)&&b8(X.$ref)}function E9(X){return M8(X,"RegExp")&&I8(X.$id)&&b8(X.source)&&b8(X.flags)&&g8(X.maxLength)&&g8(X.minLength)}function C9(X){return M8(X,"String")&&X.type==="string"&&I8(X.$id)&&g8(X.minLength)&&g8(X.maxLength)&&FQ(X.pattern)&&BQ(X.format)}function P9(X){return M8(X,"Symbol")&&X.type==="symbol"&&I8(X.$id)}function I9(X){return M8(X,"TemplateLiteral")&&X.type==="string"&&b8(X.pattern)&&X.pattern[0]==="^"&&X.pattern[X.pattern.length-1]==="$"}function x9(X){return M8(X,"This")&&I8(X.$id)&&b8(X.$ref)}function T9(X){return P8(X)&&k8 in X}function b9(X){return M8(X,"Tuple")&&X.type==="array"&&I8(X.$id)&&s0(X.minItems)&&s0(X.maxItems)&&X.minItems===X.maxItems&&(Y0(X.items)&&Y0(X.additionalItems)&&X.minItems===0||Z0(X.items)&&X.items.every((Z)=>i8(Z)))}function k9(X){return M8(X,"Undefined")&&X.type==="undefined"&&I8(X.$id)}function VQ(X){return B$(X)&&X.anyOf.every((Z)=>_9(Z)||w9(Z))}function B$(X){return M8(X,"Union")&&I8(X.$id)&&P8(X)&&Z0(X.anyOf)&&X.anyOf.every((Z)=>i8(Z))}function g9(X){return M8(X,"Uint8Array")&&X.type==="Uint8Array"&&I8(X.$id)&&g8(X.minByteLength)&&g8(X.maxByteLength)}function f9(X){return M8(X,"Unknown")&&I8(X.$id)}function v9(X){return M8(X,"Unsafe")}function y9(X){return M8(X,"Void")&&X.type==="void"&&I8(X.$id)}function d9(X){return P8(X)&&q in X&&b8(X[q])&&!LQ.includes(X[q])}function i8(X){return P8(X)&&(Z9(X)||Y9(X)||$9(X)||z9(X)||J9(X)||W9(X)||Q9(X)||G9(X)||M9(X)||U9(X)||H9(X)||D9(X)||A9(X)||WZ(X)||N9(X)||L9(X)||F9(X)||B9(X)||q9(X)||K9(X)||R9(X)||j9(X)||S9(X)||V9(X)||E9(X)||C9(X)||P9(X)||I9(X)||x9(X)||b9(X)||k9(X)||B$(X)||g9(X)||f9(X)||v9(X)||y9(X)||d9(X))}var h9="(true|false)",oZ="(0|[1-9][0-9]*)",m9="(.*)";var r2="^(0|[1-9][0-9]*)$",a2="^(.*)$",p9="^(?!.*)$";var C8={};EX(C8,{Set:()=>xQ,Has:()=>IQ,Get:()=>TQ,Entries:()=>EQ,Delete:()=>PQ,Clear:()=>CQ});var q1=new Map;function EQ(){return new Map(q1)}function CQ(){return q1.clear()}function PQ(X){return q1.delete(X)}function IQ(X){return q1.has(X)}function xQ(X,Z){q1.set(X,Z)}function TQ(X){return q1.get(X)}var t8={};EX(t8,{Set:()=>vQ,Has:()=>fQ,Get:()=>yQ,Entries:()=>bQ,Delete:()=>gQ,Clear:()=>kQ});var K1=new Map;function bQ(){return new Map(K1)}function kQ(){return K1.clear()}function gQ(X){return K1.delete(X)}function fQ(X){return K1.has(X)}function vQ(X,Z){K1.set(X,Z)}function yQ(X){return K1.get(X)}function c9(X,Z){return X.includes(Z)}function u9(X){return[...new Set(X)]}function dQ(X,Z){return X.filter((Y)=>Z.includes(Y))}function hQ(X,Z){return X.reduce((Y,$)=>{return dQ(Y,$)},Z)}function i9(X){return X.length===1?X[0]:X.length>1?hQ(X.slice(1),X[0]):[]}function o9(X){let Z=[];for(let Y of X)Z.push(...Y);return Z}function xX(X){return R({[q]:"Any"},X)}function R1(X,Z){return R({[q]:"Array",type:"array",items:X},Z)}function n9(X){return R({[q]:"Argument",index:X})}function j1(X,Z){return R({[q]:"AsyncIterator",type:"AsyncIterator",items:X},Z)}function m8(X,Z,Y){return R({[q]:"Computed",target:X,parameters:Z},Y)}function mQ(X,Z){let{[Z]:Y,...$}=X;return $}function s8(X,Z){return Z.reduce((Y,$)=>mQ(Y,$),X)}function Z8(X){return R({[q]:"Never",not:{}},X)}function L8(X){return R({[q]:"MappedResult",properties:X})}function S1(X,Z,Y){return R({[q]:"Constructor",type:"Constructor",parameters:X,returns:Z},Y)}function e2(X,Z,Y){return R({[q]:"Function",type:"Function",parameters:X,returns:Z},Y)}function JZ(X,Z){return R({[q]:"Union",anyOf:X},Z)}function pQ(X){return X.some((Z)=>g0(Z))}function l9(X){return X.map((Z)=>g0(Z)?cQ(Z):Z)}function cQ(X){return s8(X,[N0])}function uQ(X,Z){return pQ(X)?R0(JZ(l9(X),Z)):JZ(l9(X),Z)}function XX(X,Z){return X.length===1?R(X[0],Z):X.length===0?Z8(Z):uQ(X,Z)}function R8(X,Z){return X.length===0?Z8(Z):X.length===1?R(X[0],Z):JZ(X,Z)}class q$ extends n{}function iQ(X){return X.replace(/\\\$/g,"$").replace(/\\\*/g,"*").replace(/\\\^/g,"^").replace(/\\\|/g,"|").replace(/\\\(/g,"(").replace(/\\\)/g,")")}function K$(X,Z,Y){return X[Z]===Y&&X.charCodeAt(Z-1)!==92}function DX(X,Z){return K$(X,Z,"(")}function zZ(X,Z){return K$(X,Z,")")}function t9(X,Z){return K$(X,Z,"|")}function oQ(X){if(!(DX(X,0)&&zZ(X,X.length-1)))return!1;let Z=0;for(let Y=0;Y0)$.push(V1(z));Y=J+1}}let W=X.slice(Y);if(W.length>0)$.push(V1(W));if($.length===0)return{type:"const",const:""};if($.length===1)return $[0];return{type:"or",expr:$}}function rQ(X){function Z(W,J){if(!DX(W,J))throw new q$("TemplateLiteralParser: Index must point to open parens");let z=0;for(let Q=J;Q0)$.push(V1(Q));W=z-1}return $.length===0?{type:"const",const:""}:$.length===1?$[0]:{type:"and",expr:$}}function V1(X){return oQ(X)?V1(nQ(X)):lQ(X)?sQ(X):tQ(X)?rQ(X):{type:"const",const:iQ(X)}}function E1(X){return V1(X.slice(1,X.length-1))}class s9 extends n{}function aQ(X){return X.type==="or"&&X.expr.length===2&&X.expr[0].type==="const"&&X.expr[0].const==="0"&&X.expr[1].type==="const"&&X.expr[1].const==="[1-9][0-9]*"}function eQ(X){return X.type==="or"&&X.expr.length===2&&X.expr[0].type==="const"&&X.expr[0].const==="true"&&X.expr[1].type==="const"&&X.expr[1].const==="false"}function XG(X){return X.type==="const"&&X.const===".*"}function $1(X){return aQ(X)||XG(X)?!1:eQ(X)?!0:X.type==="and"?X.expr.every((Z)=>$1(Z)):X.type==="or"?X.expr.every((Z)=>$1(Z)):X.type==="const"?!0:(()=>{throw new s9("Unknown expression type")})()}function nZ(X){let Z=E1(X.pattern);return $1(Z)}class r9 extends n{}function*a9(X){if(X.length===1)return yield*X[0];for(let Z of X[0])for(let Y of a9(X.slice(1)))yield`${Z}${Y}`}function*ZG(X){return yield*a9(X.expr.map((Z)=>[...QZ(Z)]))}function*YG(X){for(let Z of X.expr)yield*QZ(Z)}function*$G(X){return yield X.const}function*QZ(X){return X.type==="and"?yield*ZG(X):X.type==="or"?yield*YG(X):X.type==="const"?yield*$G(X):(()=>{throw new r9("Unknown expression")})()}function C1(X){let Z=E1(X.pattern);return $1(Z)?[...QZ(Z)]:[]}function _8(X,Z){return R({[q]:"Literal",const:X,type:typeof X},Z)}function lZ(X){return R({[q]:"Boolean",type:"boolean"},X)}function P1(X){return R({[q]:"BigInt",type:"bigint"},X)}function G2(X){return R({[q]:"Number",type:"number"},X)}function I0(X){return R({[q]:"String",type:"string"},X)}function*WG(X){let Z=X.trim().replace(/"|'/g,"");return Z==="boolean"?yield lZ():Z==="number"?yield G2():Z==="bigint"?yield P1():Z==="string"?yield I0():yield(()=>{let Y=Z.split("|").map(($)=>_8($.trim()));return Y.length===0?Z8():Y.length===1?Y[0]:XX(Y)})()}function*JG(X){if(X[1]!=="{"){let Z=_8("$"),Y=R$(X.slice(1));return yield*[Z,...Y]}for(let Z=2;ZZ7(Y,Z)).join("|")})`:b2(X)?`${Z}${oZ}`:T2(X)?`${Z}${oZ}`:eX(X)?`${Z}${oZ}`:MX(X)?`${Z}${m9}`:a0(X)?`${Z}${zG(X.const.toString())}`:GX(X)?`${Z}${h9}`:(()=>{throw new X7(`Unexpected Kind '${X[q]}'`)})()}function j$(X){return`^${X.map((Z)=>Z7(Z,"")).join("")}$`}function W1(X){let Y=C1(X).map(($)=>_8($));return XX(Y)}function tZ(X,Z){let Y=b8(X)?j$(e9(X)):j$(X);return R({[q]:"TemplateLiteral",type:"string",pattern:Y},Z)}function QG(X){return C1(X).map((Y)=>Y.toString())}function GG(X){let Z=[];for(let Y of X)Z.push(...f0(Y));return Z}function MG(X){return[X.toString()]}function f0(X){return[...new Set(X2(X)?QG(X):N8(X)?GG(X.anyOf):a0(X)?MG(X.const):b2(X)?["[number]"]:T2(X)?["[number]"]:[])]}function UG(X,Z,Y){let $={};for(let W of Object.getOwnPropertyNames(Z))$[W]=TX(X,f0(Z[W]),Y);return $}function HG(X,Z,Y){return UG(X,Z.properties,Y)}function Y7(X,Z,Y){let $=HG(X,Z,Y);return L8($)}function W7(X,Z){return X.map((Y)=>J7(Y,Z))}function DG(X){return X.filter((Z)=>!PX(Z))}function AG(X,Z){return sZ(DG(W7(X,Z)))}function _G(X){return X.some((Z)=>PX(Z))?[]:X}function wG(X,Z){return XX(_G(W7(X,Z)))}function OG(X,Z){return Z in X?X[Z]:Z==="[number]"?XX(X):Z8()}function NG(X,Z){return Z==="[number]"?X:Z8()}function LG(X,Z){return Z in X?X[Z]:Z8()}function J7(X,Z){return l8(X)?AG(X.allOf,Z):N8(X)?wG(X.anyOf,Z):Z2(X)?OG(X.items??[],Z):C2(X)?NG(X.items,Z):$0(X)?LG(X.properties,Z):Z8()}function GZ(X,Z){return Z.map((Y)=>J7(X,Y))}function $7(X,Z){return XX(GZ(X,Z))}function TX(X,Z,Y){if(e8(X)||e8(Z)){if(!o8(X)||!o8(Z))throw new n("Index types using Ref parameters require both Type and Key to be of TSchema");return m8("Index",[X,Z])}if(u8(Z))return Y7(X,Z,Y);if(e0(Z))return z7(X,Z,Y);return R(o8(Z)?$7(X,f0(Z)):$7(X,Z),Y)}function FG(X,Z,Y){return{[Z]:TX(X,[Z],p8(Y))}}function BG(X,Z,Y){return Z.reduce(($,W)=>{return{...$,...FG(X,W,Y)}},{})}function qG(X,Z,Y){return BG(X,Z.keys,Y)}function z7(X,Z,Y){let $=qG(X,Z,Y);return L8($)}function I1(X,Z){return R({[q]:"Iterator",type:"Iterator",items:X},Z)}function KG(X){let Z=[];for(let Y in X)if(!g0(X[Y]))Z.push(Y);return Z}function RG(X,Z){let Y=KG(X),$=Y.length>0?{[q]:"Object",type:"object",properties:X,required:Y}:{[q]:"Object",type:"object",properties:X};return R($,Z)}var j8=RG;function rZ(X,Z){return R({[q]:"Promise",type:"Promise",item:X},Z)}function jG(X){return R(s8(X,[E2]))}function SG(X){return R({...X,[E2]:"Readonly"})}function VG(X,Z){return Z===!1?jG(X):SG(X)}function v0(X,Z){let Y=Z??!0;return u8(X)?Q7(X,Y):VG(X,Y)}function EG(X,Z){let Y={};for(let $ of globalThis.Object.getOwnPropertyNames(X))Y[$]=v0(X[$],Z);return Y}function CG(X,Z){return EG(X.properties,Z)}function Q7(X,Z){let Y=CG(X,Z);return L8(Y)}function M2(X,Z){return R(X.length>0?{[q]:"Tuple",type:"array",items:X,additionalItems:!1,minItems:X.length,maxItems:X.length}:{[q]:"Tuple",type:"array",minItems:X.length,maxItems:X.length},Z)}function G7(X,Z){return X in Z?U2(X,Z[X]):L8(Z)}function PG(X){return{[X]:_8(X)}}function IG(X){let Z={};for(let Y of X)Z[Y]=_8(Y);return Z}function xG(X,Z){return c9(Z,X)?PG(X):IG(Z)}function TG(X,Z){let Y=xG(X,Z);return G7(X,Y)}function MZ(X,Z){return Z.map((Y)=>U2(X,Y))}function bG(X,Z){let Y={};for(let $ of globalThis.Object.getOwnPropertyNames(Z))Y[$]=U2(X,Z[$]);return Y}function U2(X,Z){let Y={...Z};return g0(Z)?R0(U2(X,s8(Z,[N0]))):B1(Z)?v0(U2(X,s8(Z,[E2]))):u8(Z)?G7(X,Z.properties):e0(Z)?TG(X,Z.keys):I2(Z)?S1(MZ(X,Z.parameters),U2(X,Z.returns),Y):x2(Z)?e2(MZ(X,Z.parameters),U2(X,Z.returns),Y):aX(Z)?j1(U2(X,Z.items),Y):X1(Z)?I1(U2(X,Z.items),Y):l8(Z)?j0(MZ(X,Z.allOf),Y):N8(Z)?R8(MZ(X,Z.anyOf),Y):Z2(Z)?M2(MZ(X,Z.items??[]),Y):$0(Z)?j8(bG(X,Z.properties),Y):C2(Z)?R1(U2(X,Z.items),Y):Z1(Z)?rZ(U2(X,Z.item),Y):Z}function kG(X,Z){let Y={};for(let $ of X)Y[$]=U2($,Z);return Y}function M7(X,Z,Y){let $=o8(X)?f0(X):X,W=Z({[q]:"MappedKey",keys:$}),J=kG($,W);return j8(J,Y)}function gG(X){return R(s8(X,[N0]))}function fG(X){return R({...X,[N0]:"Optional"})}function vG(X,Z){return Z===!1?gG(X):fG(X)}function R0(X,Z){let Y=Z??!0;return u8(X)?U7(X,Y):vG(X,Y)}function yG(X,Z){let Y={};for(let $ of globalThis.Object.getOwnPropertyNames(X))Y[$]=R0(X[$],Z);return Y}function dG(X,Z){return yG(X.properties,Z)}function U7(X,Z){let Y=dG(X,Z);return L8(Y)}function UZ(X,Z={}){let Y=X.every((W)=>$0(W)),$=o8(Z.unevaluatedProperties)?{unevaluatedProperties:Z.unevaluatedProperties}:{};return R(Z.unevaluatedProperties===!1||o8(Z.unevaluatedProperties)||Y?{...$,[q]:"Intersect",type:"object",allOf:X}:{...$,[q]:"Intersect",allOf:X},Z)}function hG(X){return X.every((Z)=>g0(Z))}function mG(X){return s8(X,[N0])}function H7(X){return X.map((Z)=>g0(Z)?mG(Z):Z)}function pG(X,Z){return hG(X)?R0(UZ(H7(X),Z)):UZ(H7(X),Z)}function sZ(X,Z={}){if(X.length===1)return R(X[0],Z);if(X.length===0)return Z8(Z);if(X.some((Y)=>K8(Y)))throw new Error("Cannot intersect transform types");return pG(X,Z)}function j0(X,Z){if(X.length===1)return R(X[0],Z);if(X.length===0)return Z8(Z);if(X.some((Y)=>K8(Y)))throw new Error("Cannot intersect transform types");return UZ(X,Z)}function H2(...X){let[Z,Y]=typeof X[0]==="string"?[X[0],X[1]]:[X[0].$id,X[1]];if(typeof Z!=="string")throw new n("Ref: $ref must be a string");return R({[q]:"Ref",$ref:Z},Y)}function cG(X,Z){return m8("Awaited",[m8(X,Z)])}function uG(X){return m8("Awaited",[H2(X)])}function iG(X){return j0(D7(X))}function oG(X){return R8(D7(X))}function nG(X){return x1(X)}function D7(X){return X.map((Z)=>x1(Z))}function x1(X,Z){return R(P2(X)?cG(X.target,X.parameters):l8(X)?iG(X.allOf):N8(X)?oG(X.anyOf):Z1(X)?nG(X.item):e8(X)?uG(X.$ref):X,Z)}function A7(X){let Z=[];for(let Y of X)Z.push(y0(Y));return Z}function lG(X){let Z=A7(X);return o9(Z)}function tG(X){let Z=A7(X);return i9(Z)}function sG(X){return X.map((Z,Y)=>Y.toString())}function rG(X){return["[number]"]}function aG(X){return globalThis.Object.getOwnPropertyNames(X)}function eG(X){if(!S$)return[];return globalThis.Object.getOwnPropertyNames(X).map((Y)=>{return Y[0]==="^"&&Y[Y.length-1]==="$"?Y.slice(1,Y.length-1):Y})}function y0(X){return l8(X)?lG(X.allOf):N8(X)?tG(X.anyOf):Z2(X)?sG(X.items??[]):C2(X)?rG(X.items):$0(X)?aG(X.properties):Y1(X)?eG(X.patternProperties):[]}var S$=!1;function AX(X){S$=!0;let Z=y0(X);return S$=!1,`^(${Z.map(($)=>`(${$})`).join("|")})$`}function XM(X,Z){return m8("KeyOf",[m8(X,Z)])}function ZM(X){return m8("KeyOf",[H2(X)])}function YM(X,Z){let Y=y0(X),$=$M(Y),W=XX($);return R(W,Z)}function $M(X){return X.map((Z)=>Z==="[number]"?G2():_8(Z))}function T1(X,Z){return P2(X)?XM(X.target,X.parameters):e8(X)?ZM(X.$ref):u8(X)?_7(X,Z):YM(X,Z)}function WM(X,Z){let Y={};for(let $ of globalThis.Object.getOwnPropertyNames(X))Y[$]=T1(X[$],p8(Z));return Y}function JM(X,Z){return WM(X.properties,Z)}function _7(X,Z){let Y=JM(X,Z);return L8(Y)}function aZ(X){let Z=y0(X),Y=GZ(X,Z);return Z.map(($,W)=>[Z[W],Y[W]])}function zM(X){let Z=[];for(let Y of X)Z.push(...y0(Y));return u9(Z)}function QM(X){return X.filter((Z)=>!PX(Z))}function GM(X,Z){let Y=[];for(let $ of X)Y.push(...GZ($,[Z]));return QM(Y)}function MM(X,Z){let Y={};for(let $ of Z)Y[$]=sZ(GM(X,$));return Y}function w7(X,Z){let Y=zM(X),$=MM(X,Y);return j8($,Z)}function eZ(X){return R({[q]:"Date",type:"Date"},X)}function XY(X){return R({[q]:"Null",type:"null"},X)}function ZY(X){return R({[q]:"Symbol",type:"symbol"},X)}function YY(X){return R({[q]:"Undefined",type:"undefined"},X)}function $Y(X){return R({[q]:"Uint8Array",type:"Uint8Array"},X)}function k2(X){return R({[q]:"Unknown"},X)}function UM(X){return X.map((Z)=>V$(Z,!1))}function HM(X){let Z={};for(let Y of globalThis.Object.getOwnPropertyNames(X))Z[Y]=v0(V$(X[Y],!1));return Z}function WY(X,Z){return Z===!0?X:v0(X)}function V$(X,Z){return M$(X)?WY(xX(),Z):H$(X)?WY(xX(),Z):Z0(X)?v0(M2(UM(X))):JX(X)?$Y():rX(X)?eZ():P8(X)?WY(j8(HM(X)),Z):U$(X)?WY(e2([],k2()),Z):Y0(X)?YY():D$(X)?XY():A$(X)?ZY():a1(X)?P1():s0(X)?_8(X):WX(X)?_8(X):b8(X)?_8(X):j8({})}function O7(X,Z){return R(V$(X,!0),Z)}function N7(X,Z){return I2(X)?M2(X.parameters,Z):Z8(Z)}function L7(X,Z){if(Y0(X))throw new Error("Enum undefined or empty");let Y=globalThis.Object.getOwnPropertyNames(X).filter((J)=>isNaN(J)).map((J)=>X[J]),W=[...new Set(Y)].map((J)=>_8(J));return R8(W,{...Z,[Q2]:"Enum"})}class R7 extends n{}var j;(function(X){X[X.Union=0]="Union",X[X.True=1]="True",X[X.False=2]="False"})(j||(j={}));function D2(X){return X===j.False?X:j.True}function b1(X){throw new R7(X)}function J0(X){return L.IsNever(X)||L.IsIntersect(X)||L.IsUnion(X)||L.IsUnknown(X)||L.IsAny(X)}function z0(X,Z){return L.IsNever(Z)?V7(X,Z):L.IsIntersect(Z)?JY(X,Z):L.IsUnion(Z)?x$(X,Z):L.IsUnknown(Z)?I7(X,Z):L.IsAny(Z)?I$(X,Z):b1("StructuralRight")}function I$(X,Z){return j.True}function DM(X,Z){return L.IsIntersect(Z)?JY(X,Z):L.IsUnion(Z)&&Z.anyOf.some((Y)=>L.IsAny(Y)||L.IsUnknown(Y))?j.True:L.IsUnion(Z)?j.Union:L.IsUnknown(Z)?j.True:L.IsAny(Z)?j.True:j.Union}function AM(X,Z){return L.IsUnknown(X)?j.False:L.IsAny(X)?j.Union:L.IsNever(X)?j.True:j.False}function _M(X,Z){return L.IsObject(Z)&&zY(Z)?j.True:J0(Z)?z0(X,Z):!L.IsArray(Z)?j.False:D2(x8(X.items,Z.items))}function wM(X,Z){return J0(Z)?z0(X,Z):!L.IsAsyncIterator(Z)?j.False:D2(x8(X.items,Z.items))}function OM(X,Z){return J0(Z)?z0(X,Z):L.IsObject(Z)?S0(X,Z):L.IsRecord(Z)?A2(X,Z):L.IsBigInt(Z)?j.True:j.False}function j7(X,Z){return L.IsLiteralBoolean(X)?j.True:L.IsBoolean(X)?j.True:j.False}function NM(X,Z){return J0(Z)?z0(X,Z):L.IsObject(Z)?S0(X,Z):L.IsRecord(Z)?A2(X,Z):L.IsBoolean(Z)?j.True:j.False}function LM(X,Z){return J0(Z)?z0(X,Z):L.IsObject(Z)?S0(X,Z):!L.IsConstructor(Z)?j.False:X.parameters.length>Z.parameters.length?j.False:!X.parameters.every((Y,$)=>D2(x8(Z.parameters[$],Y))===j.True)?j.False:D2(x8(X.returns,Z.returns))}function FM(X,Z){return J0(Z)?z0(X,Z):L.IsObject(Z)?S0(X,Z):L.IsRecord(Z)?A2(X,Z):L.IsDate(Z)?j.True:j.False}function BM(X,Z){return J0(Z)?z0(X,Z):L.IsObject(Z)?S0(X,Z):!L.IsFunction(Z)?j.False:X.parameters.length>Z.parameters.length?j.False:!X.parameters.every((Y,$)=>D2(x8(Z.parameters[$],Y))===j.True)?j.False:D2(x8(X.returns,Z.returns))}function S7(X,Z){return L.IsLiteral(X)&&K0.IsNumber(X.const)?j.True:L.IsNumber(X)||L.IsInteger(X)?j.True:j.False}function qM(X,Z){return L.IsInteger(Z)||L.IsNumber(Z)?j.True:J0(Z)?z0(X,Z):L.IsObject(Z)?S0(X,Z):L.IsRecord(Z)?A2(X,Z):j.False}function JY(X,Z){return Z.allOf.every((Y)=>x8(X,Y)===j.True)?j.True:j.False}function KM(X,Z){return X.allOf.some((Y)=>x8(Y,Z)===j.True)?j.True:j.False}function RM(X,Z){return J0(Z)?z0(X,Z):!L.IsIterator(Z)?j.False:D2(x8(X.items,Z.items))}function jM(X,Z){return L.IsLiteral(Z)&&Z.const===X.const?j.True:J0(Z)?z0(X,Z):L.IsObject(Z)?S0(X,Z):L.IsRecord(Z)?A2(X,Z):L.IsString(Z)?P7(X,Z):L.IsNumber(Z)?E7(X,Z):L.IsInteger(Z)?S7(X,Z):L.IsBoolean(Z)?j7(X,Z):j.False}function V7(X,Z){return j.False}function SM(X,Z){return j.True}function F7(X){let[Z,Y]=[X,0];while(!0){if(!L.IsNot(Z))break;Z=Z.not,Y+=1}return Y%2===0?Z:k2()}function VM(X,Z){return L.IsNot(X)?x8(F7(X),Z):L.IsNot(Z)?x8(X,F7(Z)):b1("Invalid fallthrough for Not")}function EM(X,Z){return J0(Z)?z0(X,Z):L.IsObject(Z)?S0(X,Z):L.IsRecord(Z)?A2(X,Z):L.IsNull(Z)?j.True:j.False}function E7(X,Z){return L.IsLiteralNumber(X)?j.True:L.IsNumber(X)||L.IsInteger(X)?j.True:j.False}function CM(X,Z){return J0(Z)?z0(X,Z):L.IsObject(Z)?S0(X,Z):L.IsRecord(Z)?A2(X,Z):L.IsInteger(Z)||L.IsNumber(Z)?j.True:j.False}function d0(X,Z){return Object.getOwnPropertyNames(X.properties).length===Z}function B7(X){return zY(X)}function q7(X){return d0(X,0)||d0(X,1)&&"description"in X.properties&&L.IsUnion(X.properties.description)&&X.properties.description.anyOf.length===2&&(L.IsString(X.properties.description.anyOf[0])&&L.IsUndefined(X.properties.description.anyOf[1])||L.IsString(X.properties.description.anyOf[1])&&L.IsUndefined(X.properties.description.anyOf[0]))}function E$(X){return d0(X,0)}function K7(X){return d0(X,0)}function PM(X){return d0(X,0)}function IM(X){return d0(X,0)}function xM(X){return zY(X)}function TM(X){let Z=G2();return d0(X,0)||d0(X,1)&&"length"in X.properties&&D2(x8(X.properties.length,Z))===j.True}function bM(X){return d0(X,0)}function zY(X){let Z=G2();return d0(X,0)||d0(X,1)&&"length"in X.properties&&D2(x8(X.properties.length,Z))===j.True}function kM(X){let Z=e2([xX()],xX());return d0(X,0)||d0(X,1)&&"then"in X.properties&&D2(x8(X.properties.then,Z))===j.True}function C7(X,Z){return x8(X,Z)===j.False?j.False:L.IsOptional(X)&&!L.IsOptional(Z)?j.False:j.True}function S0(X,Z){return L.IsUnknown(X)?j.False:L.IsAny(X)?j.Union:L.IsNever(X)||L.IsLiteralString(X)&&B7(Z)||L.IsLiteralNumber(X)&&E$(Z)||L.IsLiteralBoolean(X)&&K7(Z)||L.IsSymbol(X)&&q7(Z)||L.IsBigInt(X)&&PM(Z)||L.IsString(X)&&B7(Z)||L.IsSymbol(X)&&q7(Z)||L.IsNumber(X)&&E$(Z)||L.IsInteger(X)&&E$(Z)||L.IsBoolean(X)&&K7(Z)||L.IsUint8Array(X)&&xM(Z)||L.IsDate(X)&&IM(Z)||L.IsConstructor(X)&&bM(Z)||L.IsFunction(X)&&TM(Z)?j.True:L.IsRecord(X)&&L.IsString(C$(X))?(()=>{return Z[Q2]==="Record"?j.True:j.False})():L.IsRecord(X)&&L.IsNumber(C$(X))?(()=>{return d0(Z,0)?j.True:j.False})():j.False}function gM(X,Z){return J0(Z)?z0(X,Z):L.IsRecord(Z)?A2(X,Z):!L.IsObject(Z)?j.False:(()=>{for(let Y of Object.getOwnPropertyNames(Z.properties)){if(!(Y in X.properties)&&!L.IsOptional(Z.properties[Y]))return j.False;if(L.IsOptional(Z.properties[Y]))return j.True;if(C7(X.properties[Y],Z.properties[Y])===j.False)return j.False}return j.True})()}function fM(X,Z){return J0(Z)?z0(X,Z):L.IsObject(Z)&&kM(Z)?j.True:!L.IsPromise(Z)?j.False:D2(x8(X.item,Z.item))}function C$(X){return r2 in X.patternProperties?G2():(a2 in X.patternProperties)?I0():b1("Unknown record key pattern")}function P$(X){return r2 in X.patternProperties?X.patternProperties[r2]:(a2 in X.patternProperties)?X.patternProperties[a2]:b1("Unable to get record value schema")}function A2(X,Z){let[Y,$]=[C$(Z),P$(Z)];return L.IsLiteralString(X)&&L.IsNumber(Y)&&D2(x8(X,$))===j.True?j.True:L.IsUint8Array(X)&&L.IsNumber(Y)?x8(X,$):L.IsString(X)&&L.IsNumber(Y)?x8(X,$):L.IsArray(X)&&L.IsNumber(Y)?x8(X,$):L.IsObject(X)?(()=>{for(let W of Object.getOwnPropertyNames(X.properties))if(C7($,X.properties[W])===j.False)return j.False;return j.True})():j.False}function vM(X,Z){return J0(Z)?z0(X,Z):L.IsObject(Z)?S0(X,Z):!L.IsRecord(Z)?j.False:x8(P$(X),P$(Z))}function yM(X,Z){let Y=L.IsRegExp(X)?I0():X,$=L.IsRegExp(Z)?I0():Z;return x8(Y,$)}function P7(X,Z){return L.IsLiteral(X)&&K0.IsString(X.const)?j.True:L.IsString(X)?j.True:j.False}function dM(X,Z){return J0(Z)?z0(X,Z):L.IsObject(Z)?S0(X,Z):L.IsRecord(Z)?A2(X,Z):L.IsString(Z)?j.True:j.False}function hM(X,Z){return J0(Z)?z0(X,Z):L.IsObject(Z)?S0(X,Z):L.IsRecord(Z)?A2(X,Z):L.IsSymbol(Z)?j.True:j.False}function mM(X,Z){return L.IsTemplateLiteral(X)?x8(W1(X),Z):L.IsTemplateLiteral(Z)?x8(X,W1(Z)):b1("Invalid fallthrough for TemplateLiteral")}function pM(X,Z){return L.IsArray(Z)&&X.items!==void 0&&X.items.every((Y)=>x8(Y,Z.items)===j.True)}function cM(X,Z){return L.IsNever(X)?j.True:L.IsUnknown(X)?j.False:L.IsAny(X)?j.Union:j.False}function uM(X,Z){return J0(Z)?z0(X,Z):L.IsObject(Z)&&zY(Z)?j.True:L.IsArray(Z)&&pM(X,Z)?j.True:!L.IsTuple(Z)?j.False:K0.IsUndefined(X.items)&&!K0.IsUndefined(Z.items)||!K0.IsUndefined(X.items)&&K0.IsUndefined(Z.items)?j.False:K0.IsUndefined(X.items)&&!K0.IsUndefined(Z.items)?j.True:X.items.every((Y,$)=>x8(Y,Z.items[$])===j.True)?j.True:j.False}function iM(X,Z){return J0(Z)?z0(X,Z):L.IsObject(Z)?S0(X,Z):L.IsRecord(Z)?A2(X,Z):L.IsUint8Array(Z)?j.True:j.False}function oM(X,Z){return J0(Z)?z0(X,Z):L.IsObject(Z)?S0(X,Z):L.IsRecord(Z)?A2(X,Z):L.IsVoid(Z)?tM(X,Z):L.IsUndefined(Z)?j.True:j.False}function x$(X,Z){return Z.anyOf.some((Y)=>x8(X,Y)===j.True)?j.True:j.False}function nM(X,Z){return X.anyOf.every((Y)=>x8(Y,Z)===j.True)?j.True:j.False}function I7(X,Z){return j.True}function lM(X,Z){return L.IsNever(Z)?V7(X,Z):L.IsIntersect(Z)?JY(X,Z):L.IsUnion(Z)?x$(X,Z):L.IsAny(Z)?I$(X,Z):L.IsString(Z)?P7(X,Z):L.IsNumber(Z)?E7(X,Z):L.IsInteger(Z)?S7(X,Z):L.IsBoolean(Z)?j7(X,Z):L.IsArray(Z)?AM(X,Z):L.IsTuple(Z)?cM(X,Z):L.IsObject(Z)?S0(X,Z):L.IsUnknown(Z)?j.True:j.False}function tM(X,Z){return L.IsUndefined(X)?j.True:L.IsUndefined(X)?j.True:j.False}function sM(X,Z){return L.IsIntersect(Z)?JY(X,Z):L.IsUnion(Z)?x$(X,Z):L.IsUnknown(Z)?I7(X,Z):L.IsAny(Z)?I$(X,Z):L.IsObject(Z)?S0(X,Z):L.IsVoid(Z)?j.True:j.False}function x8(X,Z){return L.IsTemplateLiteral(X)||L.IsTemplateLiteral(Z)?mM(X,Z):L.IsRegExp(X)||L.IsRegExp(Z)?yM(X,Z):L.IsNot(X)||L.IsNot(Z)?VM(X,Z):L.IsAny(X)?DM(X,Z):L.IsArray(X)?_M(X,Z):L.IsBigInt(X)?OM(X,Z):L.IsBoolean(X)?NM(X,Z):L.IsAsyncIterator(X)?wM(X,Z):L.IsConstructor(X)?LM(X,Z):L.IsDate(X)?FM(X,Z):L.IsFunction(X)?BM(X,Z):L.IsInteger(X)?qM(X,Z):L.IsIntersect(X)?KM(X,Z):L.IsIterator(X)?RM(X,Z):L.IsLiteral(X)?jM(X,Z):L.IsNever(X)?SM(X,Z):L.IsNull(X)?EM(X,Z):L.IsNumber(X)?CM(X,Z):L.IsObject(X)?gM(X,Z):L.IsRecord(X)?vM(X,Z):L.IsString(X)?dM(X,Z):L.IsSymbol(X)?hM(X,Z):L.IsTuple(X)?uM(X,Z):L.IsPromise(X)?fM(X,Z):L.IsUint8Array(X)?iM(X,Z):L.IsUndefined(X)?oM(X,Z):L.IsUnion(X)?nM(X,Z):L.IsUnknown(X)?lM(X,Z):L.IsVoid(X)?sM(X,Z):b1(`Unknown left type operand '${X[q]}'`)}function bX(X,Z){return x8(X,Z)}function rM(X,Z,Y,$,W){let J={};for(let z of globalThis.Object.getOwnPropertyNames(X))J[z]=k1(X[z],Z,Y,$,p8(W));return J}function aM(X,Z,Y,$,W){return rM(X.properties,Z,Y,$,W)}function x7(X,Z,Y,$,W){let J=aM(X,Z,Y,$,W);return L8(J)}function eM(X,Z,Y,$){let W=bX(X,Z);return W===j.Union?R8([Y,$]):W===j.True?Y:$}function k1(X,Z,Y,$,W){return u8(X)?x7(X,Z,Y,$,W):e0(X)?R(T7(X,Z,Y,$,W)):R(eM(X,Z,Y,$),W)}function XU(X,Z,Y,$,W){return{[X]:k1(_8(X),Z,Y,$,p8(W))}}function ZU(X,Z,Y,$,W){return X.reduce((J,z)=>{return{...J,...XU(z,Z,Y,$,W)}},{})}function YU(X,Z,Y,$,W){return ZU(X.keys,Z,Y,$,W)}function T7(X,Z,Y,$,W){let J=YU(X,Z,Y,$,W);return L8(J)}function $U(X){return X.allOf.every((Z)=>_X(Z))}function WU(X){return X.anyOf.some((Z)=>_X(Z))}function JU(X){return!_X(X.not)}function _X(X){return X[q]==="Intersect"?$U(X):X[q]==="Union"?WU(X):X[q]==="Not"?JU(X):X[q]==="Undefined"?!0:!1}function b7(X,Z){return g1(W1(X),Z)}function zU(X,Z){let Y=X.filter(($)=>bX($,Z)===j.False);return Y.length===1?Y[0]:R8(Y)}function g1(X,Z,Y={}){if(X2(X))return R(b7(X,Z),Y);if(u8(X))return R(k7(X,Z),Y);return R(N8(X)?zU(X.anyOf,Z):bX(X,Z)!==j.False?Z8():X,Y)}function QU(X,Z){let Y={};for(let $ of globalThis.Object.getOwnPropertyNames(X))Y[$]=g1(X[$],Z);return Y}function GU(X,Z){return QU(X.properties,Z)}function k7(X,Z){let Y=GU(X,Z);return L8(Y)}function g7(X,Z){return f1(W1(X),Z)}function MU(X,Z){let Y=X.filter(($)=>bX($,Z)!==j.False);return Y.length===1?Y[0]:R8(Y)}function f1(X,Z,Y){if(X2(X))return R(g7(X,Z),Y);if(u8(X))return R(f7(X,Z),Y);return R(N8(X)?MU(X.anyOf,Z):bX(X,Z)!==j.False?X:Z8(),Y)}function UU(X,Z){let Y={};for(let $ of globalThis.Object.getOwnPropertyNames(X))Y[$]=f1(X[$],Z);return Y}function HU(X,Z){return UU(X.properties,Z)}function f7(X,Z){let Y=HU(X,Z);return L8(Y)}function v7(X,Z){return I2(X)?R(X.returns,Z):Z8(Z)}function QY(X){return v0(R0(X))}function J1(X,Z,Y){return R({[q]:"Record",type:"object",patternProperties:{[X]:Z}},Y)}function T$(X,Z,Y){let $={};for(let W of X)$[W]=Z;return j8($,{...Y,[Q2]:"Record"})}function DU(X,Z,Y){return nZ(X)?T$(f0(X),Z,Y):J1(X.pattern,Z,Y)}function AU(X,Z,Y){return T$(f0(R8(X)),Z,Y)}function _U(X,Z,Y){return T$([X.toString()],Z,Y)}function wU(X,Z,Y){return J1(X.source,Z,Y)}function OU(X,Z,Y){let $=Y0(X.pattern)?a2:X.pattern;return J1($,Z,Y)}function NU(X,Z,Y){return J1(a2,Z,Y)}function LU(X,Z,Y){return J1(p9,Z,Y)}function FU(X,Z,Y){return j8({true:Z,false:Z},Y)}function BU(X,Z,Y){return J1(r2,Z,Y)}function qU(X,Z,Y){return J1(r2,Z,Y)}function GY(X,Z,Y={}){return N8(X)?AU(X.anyOf,Z,Y):X2(X)?DU(X,Z,Y):a0(X)?_U(X.const,Z,Y):GX(X)?FU(X,Z,Y):T2(X)?BU(X,Z,Y):b2(X)?qU(X,Z,Y):N$(X)?wU(X,Z,Y):MX(X)?OU(X,Z,Y):w$(X)?NU(X,Z,Y):PX(X)?LU(X,Z,Y):Z8(Y)}function MY(X){return globalThis.Object.getOwnPropertyNames(X.patternProperties)[0]}function y7(X){let Z=MY(X);return Z===a2?I0():Z===r2?G2():I0({pattern:Z})}function UY(X){return X.patternProperties[MY(X)]}function KU(X,Z){return Z.parameters=HZ(X,Z.parameters),Z.returns=g2(X,Z.returns),Z}function RU(X,Z){return Z.parameters=HZ(X,Z.parameters),Z.returns=g2(X,Z.returns),Z}function jU(X,Z){return Z.allOf=HZ(X,Z.allOf),Z}function SU(X,Z){return Z.anyOf=HZ(X,Z.anyOf),Z}function VU(X,Z){if(Y0(Z.items))return Z;return Z.items=HZ(X,Z.items),Z}function EU(X,Z){return Z.items=g2(X,Z.items),Z}function CU(X,Z){return Z.items=g2(X,Z.items),Z}function PU(X,Z){return Z.items=g2(X,Z.items),Z}function IU(X,Z){return Z.item=g2(X,Z.item),Z}function xU(X,Z){let Y=gU(X,Z.properties);return{...Z,...j8(Y)}}function TU(X,Z){let Y=g2(X,y7(Z)),$=g2(X,UY(Z)),W=GY(Y,$);return{...Z,...W}}function bU(X,Z){return Z.index in X?X[Z.index]:k2()}function kU(X,Z){let Y=B1(Z),$=g0(Z),W=g2(X,Z);return Y&&$?QY(W):Y&&!$?v0(W):!Y&&$?R0(W):W}function gU(X,Z){return globalThis.Object.getOwnPropertyNames(Z).reduce((Y,$)=>{return{...Y,[$]:kU(X,Z[$])}},{})}function HZ(X,Z){return Z.map((Y)=>g2(X,Y))}function g2(X,Z){return I2(Z)?KU(X,Z):x2(Z)?RU(X,Z):l8(Z)?jU(X,Z):N8(Z)?SU(X,Z):Z2(Z)?VU(X,Z):C2(Z)?EU(X,Z):aX(Z)?CU(X,Z):X1(Z)?PU(X,Z):Z1(Z)?IU(X,Z):$0(Z)?xU(X,Z):Y1(Z)?TU(X,Z):O$(Z)?bU(X,Z):Z}function d7(X,Z){return g2(Z,L1(X))}function h7(X){return R({[q]:"Integer",type:"integer"},X)}function fU(X,Z,Y){return{[X]:f2(_8(X),Z,p8(Y))}}function vU(X,Z,Y){return X.reduce((W,J)=>{return{...W,...fU(J,Z,Y)}},{})}function yU(X,Z,Y){return vU(X.keys,Z,Y)}function m7(X,Z,Y){let $=yU(X,Z,Y);return L8($)}function dU(X){let[Z,Y]=[X.slice(0,1),X.slice(1)];return[Z.toLowerCase(),Y].join("")}function hU(X){let[Z,Y]=[X.slice(0,1),X.slice(1)];return[Z.toUpperCase(),Y].join("")}function mU(X){return X.toUpperCase()}function pU(X){return X.toLowerCase()}function cU(X,Z,Y){let $=E1(X.pattern);if(!$1($))return{...X,pattern:p7(X.pattern,Z)};let z=[...QZ($)].map((G)=>_8(G)),Q=c7(z,Z),M=R8(Q);return tZ([M],Y)}function p7(X,Z){return typeof X==="string"?Z==="Uncapitalize"?dU(X):Z==="Capitalize"?hU(X):Z==="Uppercase"?mU(X):Z==="Lowercase"?pU(X):X:X.toString()}function c7(X,Z){return X.map((Y)=>f2(Y,Z))}function f2(X,Z,Y={}){return e0(X)?m7(X,Z,Y):X2(X)?cU(X,Z,Y):N8(X)?R8(c7(X.anyOf,Z),Y):a0(X)?_8(p7(X.const,Z),Y):R(X,Y)}function u7(X,Z={}){return f2(X,"Capitalize",Z)}function i7(X,Z={}){return f2(X,"Lowercase",Z)}function o7(X,Z={}){return f2(X,"Uncapitalize",Z)}function n7(X,Z={}){return f2(X,"Uppercase",Z)}function uU(X,Z,Y){let $={};for(let W of globalThis.Object.getOwnPropertyNames(X))$[W]=kX(X[W],Z,p8(Y));return $}function iU(X,Z,Y){return uU(X.properties,Z,Y)}function l7(X,Z,Y){let $=iU(X,Z,Y);return L8($)}function oU(X,Z){return X.map((Y)=>b$(Y,Z))}function nU(X,Z){return X.map((Y)=>b$(Y,Z))}function lU(X,Z){let{[Z]:Y,...$}=X;return $}function tU(X,Z){return Z.reduce((Y,$)=>lU(Y,$),X)}function sU(X,Z){let Y=s8(X,[k8,"$id","required","properties"]),$=tU(X.properties,Z);return j8($,Y)}function rU(X){let Z=X.reduce((Y,$)=>uZ($)?[...Y,_8($)]:Y,[]);return R8(Z)}function b$(X,Z){return l8(X)?j0(oU(X.allOf,Z)):N8(X)?R8(nU(X.anyOf,Z)):$0(X)?sU(X,Z):j8({})}function kX(X,Z,Y){let $=Z0(Z)?rU(Z):Z,W=o8(Z)?f0(Z):Z,J=e8(X),z=e8(Z);return u8(X)?l7(X,W,Y):e0(Z)?t7(X,Z,Y):J&&z?m8("Omit",[X,$],Y):!J&&z?m8("Omit",[X,$],Y):J&&!z?m8("Omit",[X,$],Y):R({...b$(X,W),...Y})}function aU(X,Z,Y){return{[Z]:kX(X,[Z],p8(Y))}}function eU(X,Z,Y){return Z.reduce(($,W)=>{return{...$,...aU(X,W,Y)}},{})}function XH(X,Z,Y){return eU(X,Z.keys,Y)}function t7(X,Z,Y){let $=XH(X,Z,Y);return L8($)}function ZH(X,Z,Y){let $={};for(let W of globalThis.Object.getOwnPropertyNames(X))$[W]=gX(X[W],Z,p8(Y));return $}function YH(X,Z,Y){return ZH(X.properties,Z,Y)}function s7(X,Z,Y){let $=YH(X,Z,Y);return L8($)}function $H(X,Z){return X.map((Y)=>k$(Y,Z))}function WH(X,Z){return X.map((Y)=>k$(Y,Z))}function JH(X,Z){let Y={};for(let $ of Z)if($ in X)Y[$]=X[$];return Y}function zH(X,Z){let Y=s8(X,[k8,"$id","required","properties"]),$=JH(X.properties,Z);return j8($,Y)}function QH(X){let Z=X.reduce((Y,$)=>uZ($)?[...Y,_8($)]:Y,[]);return R8(Z)}function k$(X,Z){return l8(X)?j0($H(X.allOf,Z)):N8(X)?R8(WH(X.anyOf,Z)):$0(X)?zH(X,Z):j8({})}function gX(X,Z,Y){let $=Z0(Z)?QH(Z):Z,W=o8(Z)?f0(Z):Z,J=e8(X),z=e8(Z);return u8(X)?s7(X,W,Y):e0(Z)?r7(X,Z,Y):J&&z?m8("Pick",[X,$],Y):!J&&z?m8("Pick",[X,$],Y):J&&!z?m8("Pick",[X,$],Y):R({...k$(X,W),...Y})}function GH(X,Z,Y){return{[Z]:gX(X,[Z],p8(Y))}}function MH(X,Z,Y){return Z.reduce(($,W)=>{return{...$,...GH(X,W,Y)}},{})}function UH(X,Z,Y){return MH(X,Z.keys,Y)}function r7(X,Z,Y){let $=UH(X,Z,Y);return L8($)}function HH(X,Z){return m8("Partial",[m8(X,Z)])}function DH(X){return m8("Partial",[H2(X)])}function AH(X){let Z={};for(let Y of globalThis.Object.getOwnPropertyNames(X))Z[Y]=R0(X[Y]);return Z}function _H(X){let Z=s8(X,[k8,"$id","required","properties"]),Y=AH(X.properties);return j8(Y,Z)}function a7(X){return X.map((Z)=>e7(Z))}function e7(X){return P2(X)?HH(X.target,X.parameters):e8(X)?DH(X.$ref):l8(X)?j0(a7(X.allOf)):N8(X)?R8(a7(X.anyOf)):$0(X)?_H(X):eX(X)?X:GX(X)?X:T2(X)?X:a0(X)?X:ZZ(X)?X:b2(X)?X:MX(X)?X:YZ(X)?X:UX(X)?X:j8({})}function v1(X,Z){if(u8(X))return XW(X,Z);else return R({...e7(X),...Z})}function wH(X,Z){let Y={};for(let $ of globalThis.Object.getOwnPropertyNames(X))Y[$]=v1(X[$],p8(Z));return Y}function OH(X,Z){return wH(X.properties,Z)}function XW(X,Z){let Y=OH(X,Z);return L8(Y)}function NH(X,Z){return m8("Required",[m8(X,Z)])}function LH(X){return m8("Required",[H2(X)])}function FH(X){let Z={};for(let Y of globalThis.Object.getOwnPropertyNames(X))Z[Y]=s8(X[Y],[N0]);return Z}function BH(X){let Z=s8(X,[k8,"$id","required","properties"]),Y=FH(X.properties);return j8(Y,Z)}function ZW(X){return X.map((Z)=>YW(Z))}function YW(X){return P2(X)?NH(X.target,X.parameters):e8(X)?LH(X.$ref):l8(X)?j0(ZW(X.allOf)):N8(X)?R8(ZW(X.anyOf)):$0(X)?BH(X):eX(X)?X:GX(X)?X:T2(X)?X:a0(X)?X:ZZ(X)?X:b2(X)?X:MX(X)?X:YZ(X)?X:UX(X)?X:j8({})}function y1(X,Z){if(u8(X))return $W(X,Z);else return R({...YW(X),...Z})}function qH(X,Z){let Y={};for(let $ of globalThis.Object.getOwnPropertyNames(X))Y[$]=y1(X[$],Z);return Y}function KH(X,Z){return qH(X.properties,Z)}function $W(X,Z){let Y=KH(X,Z);return L8(Y)}function RH(X,Z){return Z.map((Y)=>{return e8(Y)?g$(X,Y.$ref):Y2(X,Y)})}function g$(X,Z){return Z in X?e8(X[Z])?g$(X,X[Z].$ref):Y2(X,X[Z]):Z8()}function jH(X){return x1(X[0])}function SH(X){return TX(X[0],X[1])}function VH(X){return T1(X[0])}function EH(X){return v1(X[0])}function CH(X){return kX(X[0],X[1])}function PH(X){return gX(X[0],X[1])}function IH(X){return y1(X[0])}function xH(X,Z,Y){let $=RH(X,Y);return Z==="Awaited"?jH($):Z==="Index"?SH($):Z==="KeyOf"?VH($):Z==="Partial"?EH($):Z==="Omit"?CH($):Z==="Pick"?PH($):Z==="Required"?IH($):Z8()}function TH(X,Z){return R1(Y2(X,Z))}function bH(X,Z){return j1(Y2(X,Z))}function kH(X,Z,Y){return S1(DZ(X,Z),Y2(X,Y))}function gH(X,Z,Y){return e2(DZ(X,Z),Y2(X,Y))}function fH(X,Z){return j0(DZ(X,Z))}function vH(X,Z){return I1(Y2(X,Z))}function yH(X,Z){return j8(globalThis.Object.keys(Z).reduce((Y,$)=>{return{...Y,[$]:Y2(X,Z[$])}},{}))}function dH(X,Z){let[Y,$]=[Y2(X,UY(Z)),MY(Z)],W=L1(Z);return W.patternProperties[$]=Y,W}function hH(X,Z){return e8(Z)?{...g$(X,Z.$ref),[k8]:Z[k8]}:Z}function mH(X,Z){return M2(DZ(X,Z))}function pH(X,Z){return R8(DZ(X,Z))}function DZ(X,Z){return Z.map((Y)=>Y2(X,Y))}function Y2(X,Z){return g0(Z)?R(Y2(X,s8(Z,[N0])),Z):B1(Z)?R(Y2(X,s8(Z,[E2])),Z):K8(Z)?R(hH(X,Z),Z):C2(Z)?R(TH(X,Z.items),Z):aX(Z)?R(bH(X,Z.items),Z):P2(Z)?R(xH(X,Z.target,Z.parameters)):I2(Z)?R(kH(X,Z.parameters,Z.returns),Z):x2(Z)?R(gH(X,Z.parameters,Z.returns),Z):l8(Z)?R(fH(X,Z.allOf),Z):X1(Z)?R(vH(X,Z.items),Z):$0(Z)?R(yH(X,Z.properties),Z):Y1(Z)?R(dH(X,Z)):Z2(Z)?R(mH(X,Z.items||[]),Z):N8(Z)?R(pH(X,Z.anyOf),Z):Z}function cH(X,Z){return Z in X?Y2(X,X[Z]):Z8()}function WW(X){return globalThis.Object.getOwnPropertyNames(X).reduce((Z,Y)=>{return{...Z,[Y]:cH(X,Y)}},{})}class JW{constructor(X){let Z=WW(X),Y=this.WithIdentifiers(Z);this.$defs=Y}Import(X,Z){let Y={...this.$defs,[X]:R(this.$defs[X],Z)};return R({[q]:"Import",$defs:Y,$ref:X})}WithIdentifiers(X){return globalThis.Object.getOwnPropertyNames(X).reduce((Z,Y)=>{return{...Z,[Y]:{...X[Y],$id:Y}}},{})}}function zW(X){return new JW(X)}function QW(X,Z){return R({[q]:"Not",not:X},Z)}function GW(X,Z){return x2(X)?M2(X.parameters,Z):Z8()}var uH=0;function MW(X,Z={}){if(Y0(Z.$id))Z.$id=`T${uH++}`;let Y=L1(X({[q]:"This",$ref:`${Z.$id}`}));return Y.$id=Z.$id,R({[Q2]:"Recursive",...Y},Z)}function UW(X,Z){let Y=b8(X)?new globalThis.RegExp(X):X;return R({[q]:"RegExp",type:"RegExp",source:Y.source,flags:Y.flags},Z)}function iH(X){return l8(X)?X.allOf:N8(X)?X.anyOf:Z2(X)?X.items??[]:[]}function HW(X){return iH(X)}function DW(X,Z){return x2(X)?R(X.returns,Z):Z8(Z)}class AW{constructor(X){this.schema=X}Decode(X){return new _W(this.schema,X)}}class _W{constructor(X,Z){this.schema=X,this.decode=Z}EncodeTransform(X,Z){let W={Encode:(J)=>Z[k8].Encode(X(J)),Decode:(J)=>this.decode(Z[k8].Decode(J))};return{...Z,[k8]:W}}EncodeSchema(X,Z){let Y={Decode:this.decode,Encode:X};return{...Z,[k8]:Y}}Encode(X){return K8(this.schema)?this.EncodeTransform(X,this.schema):this.EncodeSchema(X,this.schema)}}function wW(X){return new AW(X)}function HY(X={}){return R({[q]:X[q]??"Unsafe"},X)}function OW(X){return R({[q]:"Void",type:"void"},X)}var f$={};EX(f$,{Void:()=>OW,Uppercase:()=>n7,Unsafe:()=>HY,Unknown:()=>k2,Union:()=>R8,Undefined:()=>YY,Uncapitalize:()=>o7,Uint8Array:()=>$Y,Tuple:()=>M2,Transform:()=>wW,TemplateLiteral:()=>tZ,Symbol:()=>ZY,String:()=>I0,ReturnType:()=>DW,Rest:()=>HW,Required:()=>y1,RegExp:()=>UW,Ref:()=>H2,Recursive:()=>MW,Record:()=>GY,ReadonlyOptional:()=>QY,Readonly:()=>v0,Promise:()=>rZ,Pick:()=>gX,Partial:()=>v1,Parameters:()=>GW,Optional:()=>R0,Omit:()=>kX,Object:()=>j8,Number:()=>G2,Null:()=>XY,Not:()=>QW,Never:()=>Z8,Module:()=>zW,Mapped:()=>M7,Lowercase:()=>i7,Literal:()=>_8,KeyOf:()=>T1,Iterator:()=>I1,Intersect:()=>j0,Integer:()=>h7,Instantiate:()=>d7,InstanceType:()=>v7,Index:()=>TX,Function:()=>e2,Extract:()=>f1,Extends:()=>k1,Exclude:()=>g1,Enum:()=>L7,Date:()=>eZ,ConstructorParameters:()=>N7,Constructor:()=>S1,Const:()=>O7,Composite:()=>w7,Capitalize:()=>u7,Boolean:()=>lZ,BigInt:()=>P1,Awaited:()=>x1,AsyncIterator:()=>j1,Array:()=>R1,Argument:()=>n9,Any:()=>xX});var f8=f$;function oH(X){switch(X.errorType){case K.ArrayContains:return"Expected array to contain at least one matching value";case K.ArrayMaxContains:return`Expected array to contain no more than ${X.schema.maxContains} matching values`;case K.ArrayMinContains:return`Expected array to contain at least ${X.schema.minContains} matching values`;case K.ArrayMaxItems:return`Expected array length to be less or equal to ${X.schema.maxItems}`;case K.ArrayMinItems:return`Expected array length to be greater or equal to ${X.schema.minItems}`;case K.ArrayUniqueItems:return"Expected array elements to be unique";case K.Array:return"Expected array";case K.AsyncIterator:return"Expected AsyncIterator";case K.BigIntExclusiveMaximum:return`Expected bigint to be less than ${X.schema.exclusiveMaximum}`;case K.BigIntExclusiveMinimum:return`Expected bigint to be greater than ${X.schema.exclusiveMinimum}`;case K.BigIntMaximum:return`Expected bigint to be less or equal to ${X.schema.maximum}`;case K.BigIntMinimum:return`Expected bigint to be greater or equal to ${X.schema.minimum}`;case K.BigIntMultipleOf:return`Expected bigint to be a multiple of ${X.schema.multipleOf}`;case K.BigInt:return"Expected bigint";case K.Boolean:return"Expected boolean";case K.DateExclusiveMinimumTimestamp:return`Expected Date timestamp to be greater than ${X.schema.exclusiveMinimumTimestamp}`;case K.DateExclusiveMaximumTimestamp:return`Expected Date timestamp to be less than ${X.schema.exclusiveMaximumTimestamp}`;case K.DateMinimumTimestamp:return`Expected Date timestamp to be greater or equal to ${X.schema.minimumTimestamp}`;case K.DateMaximumTimestamp:return`Expected Date timestamp to be less or equal to ${X.schema.maximumTimestamp}`;case K.DateMultipleOfTimestamp:return`Expected Date timestamp to be a multiple of ${X.schema.multipleOfTimestamp}`;case K.Date:return"Expected Date";case K.Function:return"Expected function";case K.IntegerExclusiveMaximum:return`Expected integer to be less than ${X.schema.exclusiveMaximum}`;case K.IntegerExclusiveMinimum:return`Expected integer to be greater than ${X.schema.exclusiveMinimum}`;case K.IntegerMaximum:return`Expected integer to be less or equal to ${X.schema.maximum}`;case K.IntegerMinimum:return`Expected integer to be greater or equal to ${X.schema.minimum}`;case K.IntegerMultipleOf:return`Expected integer to be a multiple of ${X.schema.multipleOf}`;case K.Integer:return"Expected integer";case K.IntersectUnevaluatedProperties:return"Unexpected property";case K.Intersect:return"Expected all values to match";case K.Iterator:return"Expected Iterator";case K.Literal:return`Expected ${typeof X.schema.const==="string"?`'${X.schema.const}'`:X.schema.const}`;case K.Never:return"Never";case K.Not:return"Value should not match";case K.Null:return"Expected null";case K.NumberExclusiveMaximum:return`Expected number to be less than ${X.schema.exclusiveMaximum}`;case K.NumberExclusiveMinimum:return`Expected number to be greater than ${X.schema.exclusiveMinimum}`;case K.NumberMaximum:return`Expected number to be less or equal to ${X.schema.maximum}`;case K.NumberMinimum:return`Expected number to be greater or equal to ${X.schema.minimum}`;case K.NumberMultipleOf:return`Expected number to be a multiple of ${X.schema.multipleOf}`;case K.Number:return"Expected number";case K.Object:return"Expected object";case K.ObjectAdditionalProperties:return"Unexpected property";case K.ObjectMaxProperties:return`Expected object to have no more than ${X.schema.maxProperties} properties`;case K.ObjectMinProperties:return`Expected object to have at least ${X.schema.minProperties} properties`;case K.ObjectRequiredProperty:return"Expected required property";case K.Promise:return"Expected Promise";case K.RegExp:return"Expected string to match regular expression";case K.StringFormatUnknown:return`Unknown format '${X.schema.format}'`;case K.StringFormat:return`Expected string to match '${X.schema.format}' format`;case K.StringMaxLength:return`Expected string length less or equal to ${X.schema.maxLength}`;case K.StringMinLength:return`Expected string length greater or equal to ${X.schema.minLength}`;case K.StringPattern:return`Expected string to match '${X.schema.pattern}'`;case K.String:return"Expected string";case K.Symbol:return"Expected symbol";case K.TupleLength:return`Expected tuple to have ${X.schema.maxItems||0} elements`;case K.Tuple:return"Expected tuple";case K.Uint8ArrayMaxByteLength:return`Expected byte length less or equal to ${X.schema.maxByteLength}`;case K.Uint8ArrayMinByteLength:return`Expected byte length greater or equal to ${X.schema.minByteLength}`;case K.Uint8Array:return"Expected Uint8Array";case K.Undefined:return"Expected undefined";case K.Union:return"Expected union value";case K.Void:return"Expected void";case K.Kind:return`Expected kind '${X.schema[q]}'`;default:return"Unknown error type"}}var nH=oH;function NW(){return nH}class LW extends n{constructor(X){super(`Unable to dereference schema with $id '${X.$ref}'`);this.schema=X}}function lH(X,Z){let Y=Z.find(($)=>$.$id===X.$ref);if(Y===void 0)throw new LW(X);return F8(Y,Z)}function D0(X,Z){if(!O8(X.$id)||Z.some((Y)=>Y.$id===X.$id))return Z;return Z.push(X),Z}function F8(X,Z){return X[q]==="This"||X[q]==="Ref"?lH(X,Z):X}class FW extends n{constructor(X){super("Unable to hash value");this.value=X}}var $2;(function(X){X[X.Undefined=0]="Undefined",X[X.Null=1]="Null",X[X.Boolean=2]="Boolean",X[X.Number=3]="Number",X[X.String=4]="String",X[X.Object=5]="Object",X[X.Array=6]="Array",X[X.Date=7]="Date",X[X.Uint8Array=8]="Uint8Array",X[X.Symbol=9]="Symbol",X[X.BigInt=10]="BigInt"})($2||($2={}));var d1=BigInt("14695981039346656037"),[tH,sH]=[BigInt("1099511628211"),BigInt("18446744073709551616")],rH=Array.from({length:256}).map((X,Z)=>BigInt(Z)),BW=new Float64Array(1),qW=new DataView(BW.buffer),KW=new Uint8Array(BW.buffer);function*aH(X){let Z=X===0?1:Math.ceil(Math.floor(Math.log2(X)+1)/8);for(let Y=0;Y>8*(Z-1-Y)&255}function eH(X){V0($2.Array);for(let Z of X)h1(Z)}function XD(X){V0($2.Boolean),V0(X?1:0)}function ZD(X){V0($2.BigInt),qW.setBigInt64(0,X);for(let Z of KW)V0(Z)}function YD(X){V0($2.Date),h1(X.getTime())}function $D(X){V0($2.Null)}function WD(X){V0($2.Number),qW.setFloat64(0,X);for(let Z of KW)V0(Z)}function JD(X){V0($2.Object);for(let Z of globalThis.Object.getOwnPropertyNames(X).sort())h1(Z),h1(X[Z])}function zD(X){V0($2.String);for(let Z=0;Z=X.minItems))return!1;if(H8(X.maxItems)&&!(Y.length<=X.maxItems))return!1;if(!Y.every((J)=>A0(X.items,Z,J)))return!1;if(X.uniqueItems===!0&&!function(){let J=new Set;for(let z of Y){let Q=fX(z);if(J.has(Q))return!1;else J.add(Q)}return!0}())return!1;if(!(H8(X.contains)||o(X.minContains)||o(X.maxContains)))return!0;let $=H8(X.contains)?X.contains:Z8(),W=Y.reduce((J,z)=>A0($,Z,z)?J+1:J,0);if(W===0)return!1;if(o(X.minContains)&&WX.maxContains)return!1;return!0}function _D(X,Z,Y){return hZ(Y)}function wD(X,Z,Y){if(!O0(Y))return!1;if(H8(X.exclusiveMaximum)&&!(YX.exclusiveMinimum))return!1;if(H8(X.maximum)&&!(Y<=X.maximum))return!1;if(H8(X.minimum)&&!(Y>=X.minimum))return!1;if(H8(X.multipleOf)&&Y%X.multipleOf!==BigInt(0))return!1;return!0}function OD(X,Z,Y){return s2(Y)}function ND(X,Z,Y){return A0(X.returns,Z,Y.prototype)}function LD(X,Z,Y){if(!P0(Y))return!1;if(H8(X.exclusiveMaximumTimestamp)&&!(Y.getTime()X.exclusiveMinimumTimestamp))return!1;if(H8(X.maximumTimestamp)&&!(Y.getTime()<=X.maximumTimestamp))return!1;if(H8(X.minimumTimestamp)&&!(Y.getTime()>=X.minimumTimestamp))return!1;if(H8(X.multipleOfTimestamp)&&Y.getTime()%X.multipleOfTimestamp!==0)return!1;return!0}function FD(X,Z,Y){return CX(Y)}function BD(X,Z,Y){let $=globalThis.Object.values(X.$defs),W=X.$defs[X.$ref];return A0(W,[...Z,...$],Y)}function qD(X,Z,Y){if(!cZ(Y))return!1;if(H8(X.exclusiveMaximum)&&!(YX.exclusiveMinimum))return!1;if(H8(X.maximum)&&!(Y<=X.maximum))return!1;if(H8(X.minimum)&&!(Y>=X.minimum))return!1;if(H8(X.multipleOf)&&Y%X.multipleOf!==0)return!1;return!0}function KD(X,Z,Y){let $=X.allOf.every((W)=>A0(W,Z,Y));if(X.unevaluatedProperties===!1){let W=new RegExp(AX(X)),J=Object.getOwnPropertyNames(Y).every((z)=>W.test(z));return $&&J}else if(o8(X.unevaluatedProperties)){let W=new RegExp(AX(X)),J=Object.getOwnPropertyNames(Y).every((z)=>W.test(z)||A0(X.unevaluatedProperties,Z,Y[z]));return $&&J}else return $}function RD(X,Z,Y){return mZ(Y)}function jD(X,Z,Y){return Y===X.const}function SD(X,Z,Y){return!1}function VD(X,Z,Y){return!A0(X.not,Z,Y)}function ED(X,Z,Y){return zX(Y)}function CD(X,Z,Y){if(!h8.IsNumberLike(Y))return!1;if(H8(X.exclusiveMaximum)&&!(YX.exclusiveMinimum))return!1;if(H8(X.minimum)&&!(Y>=X.minimum))return!1;if(H8(X.maximum)&&!(Y<=X.maximum))return!1;if(H8(X.multipleOf)&&Y%X.multipleOf!==0)return!1;return!0}function PD(X,Z,Y){if(!h8.IsObjectLike(Y))return!1;if(H8(X.minProperties)&&!(Object.getOwnPropertyNames(Y).length>=X.minProperties))return!1;if(H8(X.maxProperties)&&!(Object.getOwnPropertyNames(Y).length<=X.maxProperties))return!1;let $=Object.getOwnPropertyNames(X.properties);for(let W of $){let J=X.properties[W];if(X.required&&X.required.includes(W)){if(!A0(J,Z,Y[W]))return!1;if((_X(J)||UD(J))&&!(W in Y))return!1}else if(h8.IsExactOptionalProperty(Y,W)&&!A0(J,Z,Y[W]))return!1}if(X.additionalProperties===!1){let W=Object.getOwnPropertyNames(Y);if(X.required&&X.required.length===$.length&&W.length===$.length)return!0;else return W.every((J)=>$.includes(J))}else if(typeof X.additionalProperties==="object")return Object.getOwnPropertyNames(Y).every((J)=>$.includes(J)||A0(X.additionalProperties,Z,Y[J]));else return!0}function ID(X,Z,Y){return pZ(Y)}function xD(X,Z,Y){if(!h8.IsRecordLike(Y))return!1;if(H8(X.minProperties)&&!(Object.getOwnPropertyNames(Y).length>=X.minProperties))return!1;if(H8(X.maxProperties)&&!(Object.getOwnPropertyNames(Y).length<=X.maxProperties))return!1;let[$,W]=Object.entries(X.patternProperties)[0],J=new RegExp($),z=Object.entries(Y).every(([G,U])=>{return J.test(G)?A0(W,Z,U):!0}),Q=typeof X.additionalProperties==="object"?Object.entries(Y).every(([G,U])=>{return!J.test(G)?A0(X.additionalProperties,Z,U):!0}):!0,M=X.additionalProperties===!1?Object.getOwnPropertyNames(Y).every((G)=>{return J.test(G)}):!0;return z&&Q&&M}function TD(X,Z,Y){return A0(F8(X,Z),Z,Y)}function bD(X,Z,Y){let $=new RegExp(X.source,X.flags);if(H8(X.minLength)){if(!(Y.length>=X.minLength))return!1}if(H8(X.maxLength)){if(!(Y.length<=X.maxLength))return!1}return $.test(Y)}function kD(X,Z,Y){if(!O8(Y))return!1;if(H8(X.minLength)){if(!(Y.length>=X.minLength))return!1}if(H8(X.maxLength)){if(!(Y.length<=X.maxLength))return!1}if(H8(X.pattern)){if(!new RegExp(X.pattern).test(Y))return!1}if(H8(X.format)){if(!C8.Has(X.format))return!1;return C8.Get(X.format)(Y)}return!0}function gD(X,Z,Y){return QX(Y)}function fD(X,Z,Y){return O8(Y)&&new RegExp(X.pattern).test(Y)}function vD(X,Z,Y){return A0(F8(X,Z),Z,Y)}function yD(X,Z,Y){if(!t(Y))return!1;if(X.items===void 0&&Y.length!==0)return!1;if(Y.length!==X.maxItems)return!1;if(!X.items)return!0;for(let $=0;$A0($,Z,Y))}function mD(X,Z,Y){if(!F1(Y))return!1;if(H8(X.maxByteLength)&&!(Y.length<=X.maxByteLength))return!1;if(H8(X.minByteLength)&&!(Y.length>=X.minByteLength))return!1;return!0}function pD(X,Z,Y){return!0}function cD(X,Z,Y){return h8.IsVoidLike(Y)}function uD(X,Z,Y){if(!t8.Has(X[q]))return!1;return t8.Get(X[q])(X,Y)}function A0(X,Z,Y){let $=H8(X.$id)?D0(X,Z):Z,W=X;switch(W[q]){case"Any":return HD(W,$,Y);case"Argument":return DD(W,$,Y);case"Array":return AD(W,$,Y);case"AsyncIterator":return _D(W,$,Y);case"BigInt":return wD(W,$,Y);case"Boolean":return OD(W,$,Y);case"Constructor":return ND(W,$,Y);case"Date":return LD(W,$,Y);case"Function":return FD(W,$,Y);case"Import":return BD(W,$,Y);case"Integer":return qD(W,$,Y);case"Intersect":return KD(W,$,Y);case"Iterator":return RD(W,$,Y);case"Literal":return jD(W,$,Y);case"Never":return SD(W,$,Y);case"Not":return VD(W,$,Y);case"Null":return ED(W,$,Y);case"Number":return CD(W,$,Y);case"Object":return PD(W,$,Y);case"Promise":return ID(W,$,Y);case"Record":return xD(W,$,Y);case"Ref":return TD(W,$,Y);case"RegExp":return bD(W,$,Y);case"String":return kD(W,$,Y);case"Symbol":return gD(W,$,Y);case"TemplateLiteral":return fD(W,$,Y);case"This":return vD(W,$,Y);case"Tuple":return yD(W,$,Y);case"Undefined":return dD(W,$,Y);case"Union":return hD(W,$,Y);case"Uint8Array":return mD(W,$,Y);case"Unknown":return pD(W,$,Y);case"Void":return cD(W,$,Y);default:if(!t8.Has(W[q]))throw new RW(W);return uD(W,$,Y)}}function z8(...X){return X.length===3?A0(X[0],X[1],X[2]):A0(X[0],[],X[1])}var K;(function(X){X[X.ArrayContains=0]="ArrayContains",X[X.ArrayMaxContains=1]="ArrayMaxContains",X[X.ArrayMaxItems=2]="ArrayMaxItems",X[X.ArrayMinContains=3]="ArrayMinContains",X[X.ArrayMinItems=4]="ArrayMinItems",X[X.ArrayUniqueItems=5]="ArrayUniqueItems",X[X.Array=6]="Array",X[X.AsyncIterator=7]="AsyncIterator",X[X.BigIntExclusiveMaximum=8]="BigIntExclusiveMaximum",X[X.BigIntExclusiveMinimum=9]="BigIntExclusiveMinimum",X[X.BigIntMaximum=10]="BigIntMaximum",X[X.BigIntMinimum=11]="BigIntMinimum",X[X.BigIntMultipleOf=12]="BigIntMultipleOf",X[X.BigInt=13]="BigInt",X[X.Boolean=14]="Boolean",X[X.DateExclusiveMaximumTimestamp=15]="DateExclusiveMaximumTimestamp",X[X.DateExclusiveMinimumTimestamp=16]="DateExclusiveMinimumTimestamp",X[X.DateMaximumTimestamp=17]="DateMaximumTimestamp",X[X.DateMinimumTimestamp=18]="DateMinimumTimestamp",X[X.DateMultipleOfTimestamp=19]="DateMultipleOfTimestamp",X[X.Date=20]="Date",X[X.Function=21]="Function",X[X.IntegerExclusiveMaximum=22]="IntegerExclusiveMaximum",X[X.IntegerExclusiveMinimum=23]="IntegerExclusiveMinimum",X[X.IntegerMaximum=24]="IntegerMaximum",X[X.IntegerMinimum=25]="IntegerMinimum",X[X.IntegerMultipleOf=26]="IntegerMultipleOf",X[X.Integer=27]="Integer",X[X.IntersectUnevaluatedProperties=28]="IntersectUnevaluatedProperties",X[X.Intersect=29]="Intersect",X[X.Iterator=30]="Iterator",X[X.Kind=31]="Kind",X[X.Literal=32]="Literal",X[X.Never=33]="Never",X[X.Not=34]="Not",X[X.Null=35]="Null",X[X.NumberExclusiveMaximum=36]="NumberExclusiveMaximum",X[X.NumberExclusiveMinimum=37]="NumberExclusiveMinimum",X[X.NumberMaximum=38]="NumberMaximum",X[X.NumberMinimum=39]="NumberMinimum",X[X.NumberMultipleOf=40]="NumberMultipleOf",X[X.Number=41]="Number",X[X.ObjectAdditionalProperties=42]="ObjectAdditionalProperties",X[X.ObjectMaxProperties=43]="ObjectMaxProperties",X[X.ObjectMinProperties=44]="ObjectMinProperties",X[X.ObjectRequiredProperty=45]="ObjectRequiredProperty",X[X.Object=46]="Object",X[X.Promise=47]="Promise",X[X.RegExp=48]="RegExp",X[X.StringFormatUnknown=49]="StringFormatUnknown",X[X.StringFormat=50]="StringFormat",X[X.StringMaxLength=51]="StringMaxLength",X[X.StringMinLength=52]="StringMinLength",X[X.StringPattern=53]="StringPattern",X[X.String=54]="String",X[X.Symbol=55]="Symbol",X[X.TupleLength=56]="TupleLength",X[X.Tuple=57]="Tuple",X[X.Uint8ArrayMaxByteLength=58]="Uint8ArrayMaxByteLength",X[X.Uint8ArrayMinByteLength=59]="Uint8ArrayMinByteLength",X[X.Uint8Array=60]="Uint8Array",X[X.Undefined=61]="Undefined",X[X.Union=62]="Union",X[X.Void=63]="Void"})(K||(K={}));class jW extends n{constructor(X){super("Unknown type");this.schema=X}}function wX(X){return X.replace(/~/g,"~0").replace(/\//g,"~1")}function D8(X){return X!==void 0}class z1{constructor(X){this.iterator=X}[Symbol.iterator](){return this.iterator}First(){let X=this.iterator.next();return X.done?void 0:X.value}}function y(X,Z,Y,$,W=[]){return{type:X,schema:Z,path:Y,value:$,message:NW()({errorType:X,path:Y,schema:Z,value:$,errors:W}),errors:W}}function*iD(X,Z,Y,$){}function*oD(X,Z,Y,$){}function*nD(X,Z,Y,$){if(!t($))return yield y(K.Array,X,Y,$);if(D8(X.minItems)&&!($.length>=X.minItems))yield y(K.ArrayMinItems,X,Y,$);if(D8(X.maxItems)&&!($.length<=X.maxItems))yield y(K.ArrayMaxItems,X,Y,$);for(let z=0;z<$.length;z++)yield*_0(X.items,Z,`${Y}/${z}`,$[z]);if(X.uniqueItems===!0&&!function(){let z=new Set;for(let Q of $){let M=fX(Q);if(z.has(M))return!1;else z.add(M)}return!0}())yield y(K.ArrayUniqueItems,X,Y,$);if(!(D8(X.contains)||D8(X.minContains)||D8(X.maxContains)))return;let W=D8(X.contains)?X.contains:Z8(),J=$.reduce((z,Q,M)=>_0(W,Z,`${Y}${M}`,Q).next().done===!0?z+1:z,0);if(J===0)yield y(K.ArrayContains,X,Y,$);if(o(X.minContains)&&JX.maxContains)yield y(K.ArrayMaxContains,X,Y,$)}function*lD(X,Z,Y,$){if(!hZ($))yield y(K.AsyncIterator,X,Y,$)}function*tD(X,Z,Y,$){if(!O0($))return yield y(K.BigInt,X,Y,$);if(D8(X.exclusiveMaximum)&&!($X.exclusiveMinimum))yield y(K.BigIntExclusiveMinimum,X,Y,$);if(D8(X.maximum)&&!($<=X.maximum))yield y(K.BigIntMaximum,X,Y,$);if(D8(X.minimum)&&!($>=X.minimum))yield y(K.BigIntMinimum,X,Y,$);if(D8(X.multipleOf)&&$%X.multipleOf!==BigInt(0))yield y(K.BigIntMultipleOf,X,Y,$)}function*sD(X,Z,Y,$){if(!s2($))yield y(K.Boolean,X,Y,$)}function*rD(X,Z,Y,$){yield*_0(X.returns,Z,Y,$.prototype)}function*aD(X,Z,Y,$){if(!P0($))return yield y(K.Date,X,Y,$);if(D8(X.exclusiveMaximumTimestamp)&&!($.getTime()X.exclusiveMinimumTimestamp))yield y(K.DateExclusiveMinimumTimestamp,X,Y,$);if(D8(X.maximumTimestamp)&&!($.getTime()<=X.maximumTimestamp))yield y(K.DateMaximumTimestamp,X,Y,$);if(D8(X.minimumTimestamp)&&!($.getTime()>=X.minimumTimestamp))yield y(K.DateMinimumTimestamp,X,Y,$);if(D8(X.multipleOfTimestamp)&&$.getTime()%X.multipleOfTimestamp!==0)yield y(K.DateMultipleOfTimestamp,X,Y,$)}function*eD(X,Z,Y,$){if(!CX($))yield y(K.Function,X,Y,$)}function*XA(X,Z,Y,$){let W=globalThis.Object.values(X.$defs),J=X.$defs[X.$ref];yield*_0(J,[...Z,...W],Y,$)}function*ZA(X,Z,Y,$){if(!cZ($))return yield y(K.Integer,X,Y,$);if(D8(X.exclusiveMaximum)&&!($X.exclusiveMinimum))yield y(K.IntegerExclusiveMinimum,X,Y,$);if(D8(X.maximum)&&!($<=X.maximum))yield y(K.IntegerMaximum,X,Y,$);if(D8(X.minimum)&&!($>=X.minimum))yield y(K.IntegerMinimum,X,Y,$);if(D8(X.multipleOf)&&$%X.multipleOf!==0)yield y(K.IntegerMultipleOf,X,Y,$)}function*YA(X,Z,Y,$){let W=!1;for(let J of X.allOf)for(let z of _0(J,Z,Y,$))W=!0,yield z;if(W)return yield y(K.Intersect,X,Y,$);if(X.unevaluatedProperties===!1){let J=new RegExp(AX(X));for(let z of Object.getOwnPropertyNames($))if(!J.test(z))yield y(K.IntersectUnevaluatedProperties,X,`${Y}/${z}`,$)}if(typeof X.unevaluatedProperties==="object"){let J=new RegExp(AX(X));for(let z of Object.getOwnPropertyNames($))if(!J.test(z)){let Q=_0(X.unevaluatedProperties,Z,`${Y}/${z}`,$[z]).next();if(!Q.done)yield Q.value}}}function*$A(X,Z,Y,$){if(!mZ($))yield y(K.Iterator,X,Y,$)}function*WA(X,Z,Y,$){if($!==X.const)yield y(K.Literal,X,Y,$)}function*JA(X,Z,Y,$){yield y(K.Never,X,Y,$)}function*zA(X,Z,Y,$){if(_0(X.not,Z,Y,$).next().done===!0)yield y(K.Not,X,Y,$)}function*QA(X,Z,Y,$){if(!zX($))yield y(K.Null,X,Y,$)}function*GA(X,Z,Y,$){if(!h8.IsNumberLike($))return yield y(K.Number,X,Y,$);if(D8(X.exclusiveMaximum)&&!($X.exclusiveMinimum))yield y(K.NumberExclusiveMinimum,X,Y,$);if(D8(X.maximum)&&!($<=X.maximum))yield y(K.NumberMaximum,X,Y,$);if(D8(X.minimum)&&!($>=X.minimum))yield y(K.NumberMinimum,X,Y,$);if(D8(X.multipleOf)&&$%X.multipleOf!==0)yield y(K.NumberMultipleOf,X,Y,$)}function*MA(X,Z,Y,$){if(!h8.IsObjectLike($))return yield y(K.Object,X,Y,$);if(D8(X.minProperties)&&!(Object.getOwnPropertyNames($).length>=X.minProperties))yield y(K.ObjectMinProperties,X,Y,$);if(D8(X.maxProperties)&&!(Object.getOwnPropertyNames($).length<=X.maxProperties))yield y(K.ObjectMaxProperties,X,Y,$);let W=Array.isArray(X.required)?X.required:[],J=Object.getOwnPropertyNames(X.properties),z=Object.getOwnPropertyNames($);for(let Q of W){if(z.includes(Q))continue;yield y(K.ObjectRequiredProperty,X.properties[Q],`${Y}/${wX(Q)}`,void 0)}if(X.additionalProperties===!1){for(let Q of z)if(!J.includes(Q))yield y(K.ObjectAdditionalProperties,X,`${Y}/${wX(Q)}`,$[Q])}if(typeof X.additionalProperties==="object")for(let Q of z){if(J.includes(Q))continue;yield*_0(X.additionalProperties,Z,`${Y}/${wX(Q)}`,$[Q])}for(let Q of J){let M=X.properties[Q];if(X.required&&X.required.includes(Q)){if(yield*_0(M,Z,`${Y}/${wX(Q)}`,$[Q]),_X(X)&&!(Q in $))yield y(K.ObjectRequiredProperty,M,`${Y}/${wX(Q)}`,void 0)}else if(h8.IsExactOptionalProperty($,Q))yield*_0(M,Z,`${Y}/${wX(Q)}`,$[Q])}}function*UA(X,Z,Y,$){if(!pZ($))yield y(K.Promise,X,Y,$)}function*HA(X,Z,Y,$){if(!h8.IsRecordLike($))return yield y(K.Object,X,Y,$);if(D8(X.minProperties)&&!(Object.getOwnPropertyNames($).length>=X.minProperties))yield y(K.ObjectMinProperties,X,Y,$);if(D8(X.maxProperties)&&!(Object.getOwnPropertyNames($).length<=X.maxProperties))yield y(K.ObjectMaxProperties,X,Y,$);let[W,J]=Object.entries(X.patternProperties)[0],z=new RegExp(W);for(let[Q,M]of Object.entries($))if(z.test(Q))yield*_0(J,Z,`${Y}/${wX(Q)}`,M);if(typeof X.additionalProperties==="object"){for(let[Q,M]of Object.entries($))if(!z.test(Q))yield*_0(X.additionalProperties,Z,`${Y}/${wX(Q)}`,M)}if(X.additionalProperties===!1)for(let[Q,M]of Object.entries($)){if(z.test(Q))continue;return yield y(K.ObjectAdditionalProperties,X,`${Y}/${wX(Q)}`,M)}}function*DA(X,Z,Y,$){yield*_0(F8(X,Z),Z,Y,$)}function*AA(X,Z,Y,$){if(!O8($))return yield y(K.String,X,Y,$);if(D8(X.minLength)&&!($.length>=X.minLength))yield y(K.StringMinLength,X,Y,$);if(D8(X.maxLength)&&!($.length<=X.maxLength))yield y(K.StringMaxLength,X,Y,$);if(!new RegExp(X.source,X.flags).test($))return yield y(K.RegExp,X,Y,$)}function*_A(X,Z,Y,$){if(!O8($))return yield y(K.String,X,Y,$);if(D8(X.minLength)&&!($.length>=X.minLength))yield y(K.StringMinLength,X,Y,$);if(D8(X.maxLength)&&!($.length<=X.maxLength))yield y(K.StringMaxLength,X,Y,$);if(O8(X.pattern)){if(!new RegExp(X.pattern).test($))yield y(K.StringPattern,X,Y,$)}if(O8(X.format)){if(!C8.Has(X.format))yield y(K.StringFormatUnknown,X,Y,$);else if(!C8.Get(X.format)($))yield y(K.StringFormat,X,Y,$)}}function*wA(X,Z,Y,$){if(!QX($))yield y(K.Symbol,X,Y,$)}function*OA(X,Z,Y,$){if(!O8($))return yield y(K.String,X,Y,$);if(!new RegExp(X.pattern).test($))yield y(K.StringPattern,X,Y,$)}function*NA(X,Z,Y,$){yield*_0(F8(X,Z),Z,Y,$)}function*LA(X,Z,Y,$){if(!t($))return yield y(K.Tuple,X,Y,$);if(X.items===void 0&&$.length!==0)return yield y(K.TupleLength,X,Y,$);if($.length!==X.maxItems)return yield y(K.TupleLength,X,Y,$);if(!X.items)return;for(let W=0;Wnew z1(_0(J,Z,Y,$)));yield y(K.Union,X,Y,$,W)}function*qA(X,Z,Y,$){if(!F1($))return yield y(K.Uint8Array,X,Y,$);if(D8(X.maxByteLength)&&!($.length<=X.maxByteLength))yield y(K.Uint8ArrayMaxByteLength,X,Y,$);if(D8(X.minByteLength)&&!($.length>=X.minByteLength))yield y(K.Uint8ArrayMinByteLength,X,Y,$)}function*KA(X,Z,Y,$){}function*RA(X,Z,Y,$){if(!h8.IsVoidLike($))yield y(K.Void,X,Y,$)}function*jA(X,Z,Y,$){if(!t8.Get(X[q])(X,$))yield y(K.Kind,X,Y,$)}function*_0(X,Z,Y,$){let W=D8(X.$id)?[...Z,X]:Z,J=X;switch(J[q]){case"Any":return yield*iD(J,W,Y,$);case"Argument":return yield*oD(J,W,Y,$);case"Array":return yield*nD(J,W,Y,$);case"AsyncIterator":return yield*lD(J,W,Y,$);case"BigInt":return yield*tD(J,W,Y,$);case"Boolean":return yield*sD(J,W,Y,$);case"Constructor":return yield*rD(J,W,Y,$);case"Date":return yield*aD(J,W,Y,$);case"Function":return yield*eD(J,W,Y,$);case"Import":return yield*XA(J,W,Y,$);case"Integer":return yield*ZA(J,W,Y,$);case"Intersect":return yield*YA(J,W,Y,$);case"Iterator":return yield*$A(J,W,Y,$);case"Literal":return yield*WA(J,W,Y,$);case"Never":return yield*JA(J,W,Y,$);case"Not":return yield*zA(J,W,Y,$);case"Null":return yield*QA(J,W,Y,$);case"Number":return yield*GA(J,W,Y,$);case"Object":return yield*MA(J,W,Y,$);case"Promise":return yield*UA(J,W,Y,$);case"Record":return yield*HA(J,W,Y,$);case"Ref":return yield*DA(J,W,Y,$);case"RegExp":return yield*AA(J,W,Y,$);case"String":return yield*_A(J,W,Y,$);case"Symbol":return yield*wA(J,W,Y,$);case"TemplateLiteral":return yield*OA(J,W,Y,$);case"This":return yield*NA(J,W,Y,$);case"Tuple":return yield*LA(J,W,Y,$);case"Undefined":return yield*FA(J,W,Y,$);case"Union":return yield*BA(J,W,Y,$);case"Uint8Array":return yield*qA(J,W,Y,$);case"Unknown":return yield*KA(J,W,Y,$);case"Void":return yield*RA(J,W,Y,$);default:if(!t8.Has(J[q]))throw new jW(X);return yield*jA(J,W,Y,$)}}function ZX(...X){let Z=X.length===3?_0(X[0],X[1],"",X[2]):_0(X[0],[],"",X[1]);return new z1(Z)}class AZ extends n{constructor(X,Z,Y){super("Unable to decode value as it does not match the expected schema");this.schema=X,this.value=Z,this.error=Y}}class DY extends n{constructor(X,Z,Y,$){super($ instanceof Error?$.message:"Unknown error");this.schema=X,this.path=Z,this.value=Y,this.error=$}}function n8(X,Z,Y){try{return K8(X)?X[k8].Decode(Y):Y}catch($){throw new DY(X,Z,Y,$)}}function SA(X,Z,Y,$){return t($)?n8(X,Y,$.map((W,J)=>v2(X.items,Z,`${Y}/${J}`,W))):n8(X,Y,$)}function VA(X,Z,Y,$){if(!W8($)||r0($))return n8(X,Y,$);let W=aZ(X),J=W.map((U)=>U[0]),z={...$};for(let[U,w]of W)if(U in z)z[U]=v2(w,Z,`${Y}/${U}`,z[U]);if(!K8(X.unevaluatedProperties))return n8(X,Y,z);let Q=Object.getOwnPropertyNames(z),M=X.unevaluatedProperties,G={...z};for(let U of Q)if(!J.includes(U))G[U]=n8(M,`${Y}/${U}`,G[U]);return n8(X,Y,G)}function EA(X,Z,Y,$){let W=globalThis.Object.values(X.$defs),J=X.$defs[X.$ref],z=v2(J,[...Z,...W],Y,$);return n8(X,Y,z)}function CA(X,Z,Y,$){return n8(X,Y,v2(X.not,Z,Y,$))}function PA(X,Z,Y,$){if(!W8($))return n8(X,Y,$);let W=y0(X),J={...$};for(let G of W){if(!l(J,G))continue;if(c8(J[G])&&(!UX(X.properties[G])||h8.IsExactOptionalProperty(J,G)))continue;J[G]=v2(X.properties[G],Z,`${Y}/${G}`,J[G])}if(!o8(X.additionalProperties))return n8(X,Y,J);let z=Object.getOwnPropertyNames(J),Q=X.additionalProperties,M={...J};for(let G of z)if(!W.includes(G))M[G]=n8(Q,`${Y}/${G}`,M[G]);return n8(X,Y,M)}function IA(X,Z,Y,$){if(!W8($))return n8(X,Y,$);let W=Object.getOwnPropertyNames(X.patternProperties)[0],J=new RegExp(W),z={...$};for(let U of Object.getOwnPropertyNames($))if(J.test(U))z[U]=v2(X.patternProperties[W],Z,`${Y}/${U}`,z[U]);if(!o8(X.additionalProperties))return n8(X,Y,z);let Q=Object.getOwnPropertyNames(z),M=X.additionalProperties,G={...z};for(let U of Q)if(!J.test(U))G[U]=n8(M,`${Y}/${U}`,G[U]);return n8(X,Y,G)}function xA(X,Z,Y,$){let W=F8(X,Z);return n8(X,Y,v2(W,Z,Y,$))}function TA(X,Z,Y,$){let W=F8(X,Z);return n8(X,Y,v2(W,Z,Y,$))}function bA(X,Z,Y,$){return t($)&&t(X.items)?n8(X,Y,X.items.map((W,J)=>v2(W,Z,`${Y}/${J}`,$[J]))):n8(X,Y,$)}function kA(X,Z,Y,$){for(let W of X.anyOf){if(!z8(W,Z,$))continue;let J=v2(W,Z,Y,$);return n8(X,Y,J)}return n8(X,Y,$)}function v2(X,Z,Y,$){let W=D0(X,Z),J=X;switch(X[q]){case"Array":return SA(J,W,Y,$);case"Import":return EA(J,W,Y,$);case"Intersect":return VA(J,W,Y,$);case"Not":return CA(J,W,Y,$);case"Object":return PA(J,W,Y,$);case"Record":return IA(J,W,Y,$);case"Ref":return xA(J,W,Y,$);case"Symbol":return n8(J,Y,$);case"This":return TA(J,W,Y,$);case"Tuple":return bA(J,W,Y,$);case"Union":return kA(J,W,Y,$);default:return n8(J,Y,$)}}function m1(X,Z,Y){return v2(X,Z,"",Y)}class _Z extends n{constructor(X,Z,Y){super("The encoded value does not match the expected schema");this.schema=X,this.value=Z,this.error=Y}}class SW extends n{constructor(X,Z,Y,$){super(`${$ instanceof Error?$.message:"Unknown error"}`);this.schema=X,this.path=Z,this.value=Y,this.error=$}}function L0(X,Z,Y){try{return K8(X)?X[k8].Encode(Y):Y}catch($){throw new SW(X,Z,Y,$)}}function gA(X,Z,Y,$){let W=L0(X,Y,$);return t(W)?W.map((J,z)=>y2(X.items,Z,`${Y}/${z}`,J)):W}function fA(X,Z,Y,$){let W=globalThis.Object.values(X.$defs),J=X.$defs[X.$ref],z=L0(X,Y,$);return y2(J,[...Z,...W],Y,z)}function vA(X,Z,Y,$){let W=L0(X,Y,$);if(!W8($)||r0($))return W;let J=aZ(X),z=J.map((w)=>w[0]),Q={...W};for(let[w,B]of J)if(w in Q)Q[w]=y2(B,Z,`${Y}/${w}`,Q[w]);if(!K8(X.unevaluatedProperties))return Q;let M=Object.getOwnPropertyNames(Q),G=X.unevaluatedProperties,U={...Q};for(let w of M)if(!z.includes(w))U[w]=L0(G,`${Y}/${w}`,U[w]);return U}function yA(X,Z,Y,$){return L0(X.not,Y,L0(X,Y,$))}function dA(X,Z,Y,$){let W=L0(X,Y,$);if(!W8(W))return W;let J=y0(X),z={...W};for(let U of J){if(!l(z,U))continue;if(c8(z[U])&&(!UX(X.properties[U])||h8.IsExactOptionalProperty(z,U)))continue;z[U]=y2(X.properties[U],Z,`${Y}/${U}`,z[U])}if(!o8(X.additionalProperties))return z;let Q=Object.getOwnPropertyNames(z),M=X.additionalProperties,G={...z};for(let U of Q)if(!J.includes(U))G[U]=L0(M,`${Y}/${U}`,G[U]);return G}function hA(X,Z,Y,$){let W=L0(X,Y,$);if(!W8($))return W;let J=Object.getOwnPropertyNames(X.patternProperties)[0],z=new RegExp(J),Q={...W};for(let w of Object.getOwnPropertyNames($))if(z.test(w))Q[w]=y2(X.patternProperties[J],Z,`${Y}/${w}`,Q[w]);if(!o8(X.additionalProperties))return Q;let M=Object.getOwnPropertyNames(Q),G=X.additionalProperties,U={...Q};for(let w of M)if(!z.test(w))U[w]=L0(G,`${Y}/${w}`,U[w]);return U}function mA(X,Z,Y,$){let W=F8(X,Z),J=y2(W,Z,Y,$);return L0(X,Y,J)}function pA(X,Z,Y,$){let W=F8(X,Z),J=y2(W,Z,Y,$);return L0(X,Y,J)}function cA(X,Z,Y,$){let W=L0(X,Y,$);return t(X.items)?X.items.map((J,z)=>y2(J,Z,`${Y}/${z}`,W[z])):[]}function uA(X,Z,Y,$){for(let W of X.anyOf){if(!z8(W,Z,$))continue;let J=y2(W,Z,Y,$);return L0(X,Y,J)}for(let W of X.anyOf){let J=y2(W,Z,Y,$);if(!z8(X,Z,J))continue;return L0(X,Y,J)}return L0(X,Y,$)}function y2(X,Z,Y,$){let W=D0(X,Z),J=X;switch(X[q]){case"Array":return gA(J,W,Y,$);case"Import":return fA(J,W,Y,$);case"Intersect":return vA(J,W,Y,$);case"Not":return yA(J,W,Y,$);case"Object":return dA(J,W,Y,$);case"Record":return hA(J,W,Y,$);case"Ref":return mA(J,W,Y,$);case"This":return pA(J,W,Y,$);case"Tuple":return cA(J,W,Y,$);case"Union":return uA(J,W,Y,$);default:return L0(J,Y,$)}}function p1(X,Z,Y){return y2(X,Z,"",Y)}function iA(X,Z){return K8(X)||Q0(X.items,Z)}function oA(X,Z){return K8(X)||Q0(X.items,Z)}function nA(X,Z){return K8(X)||Q0(X.returns,Z)||X.parameters.some((Y)=>Q0(Y,Z))}function lA(X,Z){return K8(X)||Q0(X.returns,Z)||X.parameters.some((Y)=>Q0(Y,Z))}function tA(X,Z){return K8(X)||K8(X.unevaluatedProperties)||X.allOf.some((Y)=>Q0(Y,Z))}function sA(X,Z){let Y=globalThis.Object.getOwnPropertyNames(X.$defs).reduce((W,J)=>[...W,X.$defs[J]],[]),$=X.$defs[X.$ref];return K8(X)||Q0($,[...Y,...Z])}function rA(X,Z){return K8(X)||Q0(X.items,Z)}function aA(X,Z){return K8(X)||Q0(X.not,Z)}function eA(X,Z){return K8(X)||Object.values(X.properties).some((Y)=>Q0(Y,Z))||o8(X.additionalProperties)&&Q0(X.additionalProperties,Z)}function X_(X,Z){return K8(X)||Q0(X.item,Z)}function Z_(X,Z){let Y=Object.getOwnPropertyNames(X.patternProperties)[0],$=X.patternProperties[Y];return K8(X)||Q0($,Z)||o8(X.additionalProperties)&&K8(X.additionalProperties)}function Y_(X,Z){if(K8(X))return!0;return Q0(F8(X,Z),Z)}function $_(X,Z){if(K8(X))return!0;return Q0(F8(X,Z),Z)}function W_(X,Z){return K8(X)||!c8(X.items)&&X.items.some((Y)=>Q0(Y,Z))}function J_(X,Z){return K8(X)||X.anyOf.some((Y)=>Q0(Y,Z))}function Q0(X,Z){let Y=D0(X,Z),$=X;if(X.$id&&v$.has(X.$id))return!1;if(X.$id)v$.add(X.$id);switch(X[q]){case"Array":return iA($,Y);case"AsyncIterator":return oA($,Y);case"Constructor":return nA($,Y);case"Function":return lA($,Y);case"Import":return sA($,Y);case"Intersect":return tA($,Y);case"Iterator":return rA($,Y);case"Not":return aA($,Y);case"Object":return eA($,Y);case"Promise":return X_($,Y);case"Record":return Z_($,Y);case"Ref":return Y_($,Y);case"This":return $_($,Y);case"Tuple":return W_($,Y);case"Union":return J_($,Y);default:return K8(X)}}var v$=new Set;function OX(X,Z){return v$.clear(),Q0(X,Z)}class VW{constructor(X,Z,Y,$){this.schema=X,this.references=Z,this.checkFunc=Y,this.code=$,this.hasTransform=OX(X,Z)}Code(){return this.code}Schema(){return this.schema}References(){return this.references}Errors(X){return ZX(this.schema,this.references,X)}Check(X){return this.checkFunc(X)}Decode(X){if(!this.checkFunc(X))throw new AZ(this.schema,X,this.Errors(X).First());return this.hasTransform?m1(this.schema,this.references,X):X}Encode(X){let Z=this.hasTransform?p1(this.schema,this.references,X):X;if(!this.checkFunc(Z))throw new _Z(this.schema,X,this.Errors(X).First());return Z}}var NX;(function(X){function Z(J){return J===36}X.DollarSign=Z;function Y(J){return J===95}X.IsUnderscore=Y;function $(J){return J>=65&&J<=90||J>=97&&J<=122}X.IsAlpha=$;function W(J){return J>=48&&J<=57}X.IsNumeric=W})(NX||(NX={}));var AY;(function(X){function Z(J){if(J.length===0)return!1;return NX.IsNumeric(J.charCodeAt(0))}function Y(J){if(Z(J))return!1;for(let z=0;z= ${D.minItems}`;let c=t0(D.items,T,"value");if(yield`${F}.every((${p}) => ${c})`,i8(D.contains)||o(D.minContains)||o(D.maxContains)){let T8=i8(D.contains)?D.contains:Z8(),k0=t0(T8,T,"value"),$X=o(D.minContains)?[`(count >= ${D.minContains})`]:[],V2=o(D.maxContains)?[`(count <= ${D.maxContains})`]:[],t2=`const count = value.reduce((${v}, ${p}) => ${k0} ? acc + 1 : acc, 0)`,fZ=["(count > 0)",...$X,...V2].join(" && ");yield`((${p}) => { ${t2}; return ${fZ}})(${F})`}if(D.uniqueItems===!0)yield`((${p}) => { 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 } )(${F})`}function*J(D,T,F){yield`(typeof value === 'object' && Symbol.asyncIterator in ${F})`}function*z(D,T,F){if(yield`(typeof ${F} === 'bigint')`,O0(D.exclusiveMaximum))yield`${F} < BigInt(${D.exclusiveMaximum})`;if(O0(D.exclusiveMinimum))yield`${F} > BigInt(${D.exclusiveMinimum})`;if(O0(D.maximum))yield`${F} <= BigInt(${D.maximum})`;if(O0(D.minimum))yield`${F} >= BigInt(${D.minimum})`;if(O0(D.multipleOf))yield`(${F} % BigInt(${D.multipleOf})) === 0`}function*Q(D,T,F){yield`(typeof ${F} === 'boolean')`}function*M(D,T,F){yield*j2(D.returns,T,`${F}.prototype`)}function*G(D,T,F){if(yield`(${F} instanceof Date) && Number.isFinite(${F}.getTime())`,o(D.exclusiveMaximumTimestamp))yield`${F}.getTime() < ${D.exclusiveMaximumTimestamp}`;if(o(D.exclusiveMinimumTimestamp))yield`${F}.getTime() > ${D.exclusiveMinimumTimestamp}`;if(o(D.maximumTimestamp))yield`${F}.getTime() <= ${D.maximumTimestamp}`;if(o(D.minimumTimestamp))yield`${F}.getTime() >= ${D.minimumTimestamp}`;if(o(D.multipleOfTimestamp))yield`(${F}.getTime() % ${D.multipleOfTimestamp}) === 0`}function*U(D,T,F){yield`(typeof ${F} === 'function')`}function*w(D,T,F){let p=globalThis.Object.getOwnPropertyNames(D.$defs).reduce((v,c)=>{return[...v,D.$defs[c]]},[]);yield*j2(H2(D.$ref),[...T,...p],F)}function*B(D,T,F){if(yield`Number.isInteger(${F})`,o(D.exclusiveMaximum))yield`${F} < ${D.exclusiveMaximum}`;if(o(D.exclusiveMinimum))yield`${F} > ${D.exclusiveMinimum}`;if(o(D.maximum))yield`${F} <= ${D.maximum}`;if(o(D.minimum))yield`${F} >= ${D.minimum}`;if(o(D.multipleOf))yield`(${F} % ${D.multipleOf}) === 0`}function*N(D,T,F){let p=D.allOf.map((v)=>t0(v,T,F)).join(" && ");if(D.unevaluatedProperties===!1){let v=VX(`${new RegExp(AX(D))};`),c=`Object.getOwnPropertyNames(${F}).every(key => ${v}.test(key))`;yield`(${p} && ${c})`}else if(i8(D.unevaluatedProperties)){let v=VX(`${new RegExp(AX(D))};`),c=`Object.getOwnPropertyNames(${F}).every(key => ${v}.test(key) || ${t0(D.unevaluatedProperties,T,`${F}[key]`)})`;yield`(${p} && ${c})`}else yield`(${p})`}function*S(D,T,F){yield`(typeof value === 'object' && Symbol.iterator in ${F})`}function*H(D,T,F){if(typeof D.const==="number"||typeof D.const==="boolean")yield`(${F} === ${D.const})`;else yield`(${F} === '${d$.Escape(D.const)}')`}function*E(D,T,F){yield"false"}function*h(D,T,F){yield`(!${t0(D.not,T,F)})`}function*Y8(D,T,F){yield`(${F} === null)`}function*s(D,T,F){if(yield Q1.IsNumberLike(F),o(D.exclusiveMaximum))yield`${F} < ${D.exclusiveMaximum}`;if(o(D.exclusiveMinimum))yield`${F} > ${D.exclusiveMinimum}`;if(o(D.maximum))yield`${F} <= ${D.maximum}`;if(o(D.minimum))yield`${F} >= ${D.minimum}`;if(o(D.multipleOf))yield`(${F} % ${D.multipleOf}) === 0`}function*V8(D,T,F){if(yield Q1.IsObjectLike(F),o(D.minProperties))yield`Object.getOwnPropertyNames(${F}).length >= ${D.minProperties}`;if(o(D.maxProperties))yield`Object.getOwnPropertyNames(${F}).length <= ${D.maxProperties}`;let p=Object.getOwnPropertyNames(D.properties);for(let v of p){let c=AY.Encode(F,v),T8=D.properties[v];if(D.required&&D.required.includes(v)){if(yield*j2(T8,T,c),_X(T8)||Z(T8))yield`('${v}' in ${F})`}else{let k0=t0(T8,T,c);yield Q1.IsExactOptionalProperty(F,v,k0)}}if(D.additionalProperties===!1)if(D.required&&D.required.length===p.length)yield`Object.getOwnPropertyNames(${F}).length === ${p.length}`;else{let v=`[${p.map((c)=>`'${c}'`).join(", ")}]`;yield`Object.getOwnPropertyNames(${F}).every(key => ${v}.includes(key))`}if(typeof D.additionalProperties==="object"){let v=t0(D.additionalProperties,T,`${F}[key]`),c=`[${p.map((T8)=>`'${T8}'`).join(", ")}]`;yield`(Object.getOwnPropertyNames(${F}).every(key => ${c}.includes(key) || ${v}))`}}function*G8(D,T,F){yield`${F} instanceof Promise`}function*I(D,T,F){if(yield Q1.IsRecordLike(F),o(D.minProperties))yield`Object.getOwnPropertyNames(${F}).length >= ${D.minProperties}`;if(o(D.maxProperties))yield`Object.getOwnPropertyNames(${F}).length <= ${D.maxProperties}`;let[p,v]=Object.entries(D.patternProperties)[0],c=VX(`${new RegExp(p)}`),T8=t0(v,T,"value"),k0=i8(D.additionalProperties)?t0(D.additionalProperties,T,F):D.additionalProperties===!1?"false":"true",$X=`(${c}.test(key) ? ${T8} : ${k0})`;yield`(Object.entries(${F}).every(([key, value]) => ${$X}))`}function*P(D,T,F){let p=F8(D,T);if(E8.functions.has(D.$ref))return yield`${SX(D.$ref)}(${F})`;yield*j2(p,T,F)}function*k(D,T,F){let p=VX(`${new RegExp(D.source,D.flags)};`);if(yield`(typeof ${F} === 'string')`,o(D.maxLength))yield`${F}.length <= ${D.maxLength}`;if(o(D.minLength))yield`${F}.length >= ${D.minLength}`;yield`${p}.test(${F})`}function*b(D,T,F){if(yield`(typeof ${F} === 'string')`,o(D.maxLength))yield`${F}.length <= ${D.maxLength}`;if(o(D.minLength))yield`${F}.length >= ${D.minLength}`;if(D.pattern!==void 0)yield`${VX(`${new RegExp(D.pattern)};`)}.test(${F})`;if(D.format!==void 0)yield`format('${D.format}', ${F})`}function*$8(D,T,F){yield`(typeof ${F} === 'symbol')`}function*J8(D,T,F){yield`(typeof ${F} === 'string')`,yield`${VX(`${new RegExp(D.pattern)};`)}.test(${F})`}function*X8(D,T,F){yield`${SX(D.$ref)}(${F})`}function*U8(D,T,F){if(yield`Array.isArray(${F})`,D.items===void 0)return yield`${F}.length === 0`;yield`(${F}.length === ${D.maxItems})`;for(let p=0;pt0(v,T,F)).join(" || ")})`}function*l2(D,T,F){if(yield`${F} instanceof Uint8Array`,o(D.maxByteLength))yield`(${F}.length <= ${D.maxByteLength})`;if(o(D.minByteLength))yield`(${F}.length >= ${D.minByteLength})`}function*C0(D,T,F){yield"true"}function*tX(D,T,F){yield Q1.IsVoidLike(F)}function*Q$(D,T,F){let p=E8.instances.size;E8.instances.set(p,D),yield`kind('${D[q]}', ${p}, ${F})`}function*j2(D,T,F,p=!0){let v=O8(D.$id)?[...T,D]:T,c=D;if(p&&O8(D.$id)){let T8=SX(D.$id);if(E8.functions.has(T8))return yield`${T8}(${F})`;else{E8.functions.set(T8,"");let k0=S2(T8,D,T,"value",!1);return E8.functions.set(T8,k0),yield`${T8}(${F})`}}switch(c[q]){case"Any":return yield*Y(c,v,F);case"Argument":return yield*$(c,v,F);case"Array":return yield*W(c,v,F);case"AsyncIterator":return yield*J(c,v,F);case"BigInt":return yield*z(c,v,F);case"Boolean":return yield*Q(c,v,F);case"Constructor":return yield*M(c,v,F);case"Date":return yield*G(c,v,F);case"Function":return yield*U(c,v,F);case"Import":return yield*w(c,v,F);case"Integer":return yield*B(c,v,F);case"Intersect":return yield*N(c,v,F);case"Iterator":return yield*S(c,v,F);case"Literal":return yield*H(c,v,F);case"Never":return yield*E(c,v,F);case"Not":return yield*h(c,v,F);case"Null":return yield*Y8(c,v,F);case"Number":return yield*s(c,v,F);case"Object":return yield*V8(c,v,F);case"Promise":return yield*G8(c,v,F);case"Record":return yield*I(c,v,F);case"Ref":return yield*P(c,v,F);case"RegExp":return yield*k(c,v,F);case"String":return yield*b(c,v,F);case"Symbol":return yield*$8(c,v,F);case"TemplateLiteral":return yield*J8(c,v,F);case"This":return yield*X8(c,v,F);case"Tuple":return yield*U8(c,v,F);case"Undefined":return yield*H0(c,v,F);case"Union":return yield*d8(c,v,F);case"Uint8Array":return yield*l2(c,v,F);case"Unknown":return yield*C0(c,v,F);case"Void":return yield*tX(c,v,F);default:if(!t8.Has(c[q]))throw new EW(D);return yield*Q$(c,v,F)}}let E8={language:"javascript",functions:new Map,variables:new Map,instances:new Map};function t0(D,T,F,p=!0){return`(${[...j2(D,T,F,p)].join(" && ")})`}function SX(D){return`check_${y$.Encode(D)}`}function VX(D){let T=`local_${E8.variables.size}`;return E8.variables.set(T,`const ${T} = ${D}`),T}function S2(D,T,F,p,v=!0){let[c,T8]=[` -`,(t2)=>"".padStart(t2," ")],k0=g("value","any"),$X=C("boolean"),V2=[...j2(T,F,p,v)].map((t2)=>`${T8(4)}${t2}`).join(` &&${c}`);return`function ${D}(${k0})${$X} {${c}${T8(2)}return (${c}${V2}${c}${T8(2)}) -}`}function g(D,T){let F=E8.language==="typescript"?`: ${T}`:"";return`${D}${F}`}function C(D){return E8.language==="typescript"?`: ${D}`:""}function x(D,T,F){let p=S2("check",D,T,"value"),v=g("value","any"),c=C("boolean"),T8=[...E8.functions.values()],k0=[...E8.variables.values()],$X=O8(D.$id)?`return function check(${v})${c} { - return ${SX(D.$id)}(value) -}`:`return ${p}`;return[...k0,...T8,$X].join(` -`)}function u(...D){let T={language:"javascript"},[F,p,v]=D.length===2&&t(D[1])?[D[0],D[1],T]:D.length===2&&!t(D[1])?[D[0],[],D[1]]:D.length===3?[D[0],D[1],D[2]]:D.length===1?[D[0],[],T]:[null,[],T];if(E8.language=v.language,E8.variables.clear(),E8.functions.clear(),E8.instances.clear(),!i8(F))throw new h$(F);for(let c of p)if(!i8(c))throw new h$(c);return x(F,p,v)}X.Code=u;function r(D,T=[]){let F=u(D,T,{language:"javascript"}),p=globalThis.Function("kind","format","hash",F),v=new Map(E8.instances);function c(V2,t2,fZ){if(!t8.Has(V2)||!v.has(t2))return!1;let nz=t8.Get(V2),lz=v.get(t2);return nz(lz,fZ)}function T8(V2,t2){if(!C8.Has(V2))return!1;return C8.Get(V2)(t2)}function k0(V2){return fX(V2)}let $X=p(c,T8,k0);return new VW(D,T,$X,F)}X.Compile=r})(vX||(vX={}));var z_=function(X,Z,Y,$,W){if($==="m")throw new TypeError("Private method is not writable");if($==="a"&&!W)throw new TypeError("Private accessor was defined without a setter");if(typeof Z==="function"?X!==Z||!W:!Z.has(X))throw new TypeError("Cannot write private member to an object whose class did not declare it");return $==="a"?W.call(X,Y):W?W.value=Y:Z.set(X,Y),Y},PW=function(X,Z,Y,$){if(Y==="a"&&!$)throw new TypeError("Private accessor was defined without a getter");if(typeof Z==="function"?X!==Z||!$:!Z.has(X))throw new TypeError("Cannot read private member from an object whose class did not declare it");return Y==="m"?$:Y==="a"?$.call(X):$?$.value:Z.get(X)},m$,_Y,IW;class xW extends n{constructor(X){let Z=X.First();super(Z===void 0?"Invalid Value":Z.message);m$.add(this),_Y.set(this,void 0),z_(this,_Y,X,"f"),this.error=Z}Errors(){return new z1(PW(this,m$,"m",IW).call(this))}}_Y=new WeakMap,m$=new WeakSet,IW=function*X(){if(this.error)yield this.error;yield*PW(this,_Y,"f")};function CW(X,Z,Y){if(z8(X,Z,Y))return;throw new xW(ZX(X,Z,Y))}function wY(...X){return X.length===3?CW(X[0],X[1],X[2]):CW(X[0],[],X[1])}function Q_(X){let Z={};for(let Y of Object.getOwnPropertyNames(X))Z[Y]=B8(X[Y]);for(let Y of Object.getOwnPropertySymbols(X))Z[Y]=B8(X[Y]);return Z}function G_(X){return X.map((Z)=>B8(Z))}function M_(X){return X.slice()}function U_(X){return new Map(B8([...X.entries()]))}function H_(X){return new Set(B8([...X.entries()]))}function D_(X){return new Date(X.toISOString())}function A_(X){return X}function B8(X){if(t(X))return G_(X);if(P0(X))return D_(X);if(z2(X))return M_(X);if(t6(X))return U_(X);if(s6(X))return H_(X);if(W8(X))return Q_(X);if(r0(X))return A_(X);throw new Error("ValueClone: Unable to clone value")}class _2 extends n{constructor(X,Z){super(Z);this.schema=X}}function q8(X){return CX(X)?X():B8(X)}function __(X,Z){if(l(X,"default"))return q8(X.default);else return{}}function w_(X,Z){return{}}function O_(X,Z){if(X.uniqueItems===!0&&!l(X,"default"))throw new _2(X,"Array with the uniqueItems constraint requires a default value");else if("contains"in X&&!l(X,"default"))throw new _2(X,"Array with the contains constraint requires a default value");else if("default"in X)return q8(X.default);else if(X.minItems!==void 0)return Array.from({length:X.minItems}).map((Y)=>{return h0(X.items,Z)});else return[]}function N_(X,Z){if(l(X,"default"))return q8(X.default);else return async function*(){}()}function L_(X,Z){if(l(X,"default"))return q8(X.default);else return BigInt(0)}function F_(X,Z){if(l(X,"default"))return q8(X.default);else return!1}function B_(X,Z){if(l(X,"default"))return q8(X.default);else{let Y=h0(X.returns,Z);if(typeof Y==="object"&&!Array.isArray(Y))return class{constructor(){for(let[$,W]of Object.entries(Y)){let J=this;J[$]=W}}};else return class{}}}function q_(X,Z){if(l(X,"default"))return q8(X.default);else if(X.minimumTimestamp!==void 0)return new Date(X.minimumTimestamp);else return new Date}function K_(X,Z){if(l(X,"default"))return q8(X.default);else return()=>h0(X.returns,Z)}function R_(X,Z){let Y=globalThis.Object.values(X.$defs),$=X.$defs[X.$ref];return h0($,[...Z,...Y])}function j_(X,Z){if(l(X,"default"))return q8(X.default);else if(X.minimum!==void 0)return X.minimum;else return 0}function S_(X,Z){if(l(X,"default"))return q8(X.default);else{let Y=X.allOf.reduce(($,W)=>{let J=h0(W,Z);return typeof J==="object"?{...$,...J}:J},{});if(!z8(X,Z,Y))throw new _2(X,"Intersect produced invalid value. Consider using a default value.");return Y}}function V_(X,Z){if(l(X,"default"))return q8(X.default);else return function*(){}()}function E_(X,Z){if(l(X,"default"))return q8(X.default);else return X.const}function C_(X,Z){if(l(X,"default"))return q8(X.default);else throw new _2(X,"Never types cannot be created. Consider using a default value.")}function P_(X,Z){if(l(X,"default"))return q8(X.default);else throw new _2(X,"Not types must have a default value")}function I_(X,Z){if(l(X,"default"))return q8(X.default);else return null}function x_(X,Z){if(l(X,"default"))return q8(X.default);else if(X.minimum!==void 0)return X.minimum;else return 0}function T_(X,Z){if(l(X,"default"))return q8(X.default);else{let Y=new Set(X.required),$={};for(let[W,J]of Object.entries(X.properties)){if(!Y.has(W))continue;$[W]=h0(J,Z)}return $}}function b_(X,Z){if(l(X,"default"))return q8(X.default);else return Promise.resolve(h0(X.item,Z))}function k_(X,Z){let[Y,$]=Object.entries(X.patternProperties)[0];if(l(X,"default"))return q8(X.default);else if(!(Y===a2||Y===r2)){let W=Y.slice(1,Y.length-1).split("|"),J={};for(let z of W)J[z]=h0($,Z);return J}else return{}}function g_(X,Z){if(l(X,"default"))return q8(X.default);else return h0(F8(X,Z),Z)}function f_(X,Z){if(l(X,"default"))return q8(X.default);else throw new _2(X,"RegExp types cannot be created. Consider using a default value.")}function v_(X,Z){if(X.pattern!==void 0)if(!l(X,"default"))throw new _2(X,"String types with patterns must specify a default value");else return q8(X.default);else if(X.format!==void 0)if(!l(X,"default"))throw new _2(X,"String types with formats must specify a default value");else return q8(X.default);else if(l(X,"default"))return q8(X.default);else if(X.minLength!==void 0)return Array.from({length:X.minLength}).map(()=>" ").join("");else return""}function y_(X,Z){if(l(X,"default"))return q8(X.default);else if("value"in X)return Symbol.for(X.value);else return Symbol()}function d_(X,Z){if(l(X,"default"))return q8(X.default);if(!nZ(X))throw new _2(X,"Can only create template literals that produce a finite variants. Consider using a default value.");return C1(X)[0]}function h_(X,Z){if(TW++>l_)throw new _2(X,"Cannot create recursive type as it appears possibly infinite. Consider using a default.");if(l(X,"default"))return q8(X.default);else return h0(F8(X,Z),Z)}function m_(X,Z){if(l(X,"default"))return q8(X.default);if(X.items===void 0)return[];else return Array.from({length:X.minItems}).map((Y,$)=>h0(X.items[$],Z))}function p_(X,Z){if(l(X,"default"))return q8(X.default);else return}function c_(X,Z){if(l(X,"default"))return q8(X.default);else if(X.anyOf.length===0)throw new Error("ValueCreate.Union: Cannot create Union with zero variants");else return h0(X.anyOf[0],Z)}function u_(X,Z){if(l(X,"default"))return q8(X.default);else if(X.minByteLength!==void 0)return new Uint8Array(X.minByteLength);else return new Uint8Array(0)}function i_(X,Z){if(l(X,"default"))return q8(X.default);else return{}}function o_(X,Z){if(l(X,"default"))return q8(X.default);else return}function n_(X,Z){if(l(X,"default"))return q8(X.default);else throw new Error("User defined types must specify a default value")}function h0(X,Z){let Y=D0(X,Z),$=X;switch($[q]){case"Any":return __($,Y);case"Argument":return w_($,Y);case"Array":return O_($,Y);case"AsyncIterator":return N_($,Y);case"BigInt":return L_($,Y);case"Boolean":return F_($,Y);case"Constructor":return B_($,Y);case"Date":return q_($,Y);case"Function":return K_($,Y);case"Import":return R_($,Y);case"Integer":return j_($,Y);case"Intersect":return S_($,Y);case"Iterator":return V_($,Y);case"Literal":return E_($,Y);case"Never":return C_($,Y);case"Not":return P_($,Y);case"Null":return I_($,Y);case"Number":return x_($,Y);case"Object":return T_($,Y);case"Promise":return b_($,Y);case"Record":return k_($,Y);case"Ref":return g_($,Y);case"RegExp":return f_($,Y);case"String":return v_($,Y);case"Symbol":return y_($,Y);case"TemplateLiteral":return d_($,Y);case"This":return h_($,Y);case"Tuple":return m_($,Y);case"Undefined":return p_($,Y);case"Union":return c_($,Y);case"Uint8Array":return u_($,Y);case"Unknown":return i_($,Y);case"Void":return o_($,Y);default:if(!t8.Has($[q]))throw new _2($,"Unknown type");return n_($,Y)}}var l_=512,TW=0;function w2(...X){return TW=0,X.length===2?h0(X[0],X[1]):h0(X[0],[])}class p$ extends n{constructor(X,Z){super(Z);this.schema=X}}function t_(X,Z,Y){if(X[q]==="Object"&&typeof Y==="object"&&!zX(Y)){let $=X,W=Object.getOwnPropertyNames(Y),J=Object.entries($.properties),[z,Q]=[1/J.length,J.length];return J.reduce((M,[G,U])=>{let w=U[q]==="Literal"&&U.const===Y[G]?Q:0,B=z8(U,Z,Y[G])?z:0,N=W.includes(G)?z:0;return M+(w+B+N)},0)}else return z8(X,Z,Y)?1:0}function s_(X,Z,Y){let $=X.anyOf.map((z)=>F8(z,Z)),[W,J]=[$[0],0];for(let z of $){let Q=t_(z,Z,Y);if(Q>J)W=z,J=Q}return W}function r_(X,Z,Y){if("default"in X)return typeof Y==="function"?X.default:B8(X.default);else{let $=s_(X,Z,Y);return wZ($,Z,Y)}}function a_(X,Z,Y){return z8(X,Z,Y)?B8(Y):w2(X,Z)}function e_(X,Z,Y){return z8(X,Z,Y)?Y:w2(X,Z)}function Xw(X,Z,Y){if(z8(X,Z,Y))return B8(Y);let $=t(Y)?B8(Y):w2(X,Z),W=o(X.minItems)&&$.lengthnull)]:$,z=(o(X.maxItems)&&W.length>X.maxItems?W.slice(0,X.maxItems):W).map((M)=>d2(X.items,Z,M));if(X.uniqueItems!==!0)return z;let Q=[...new Set(z)];if(!z8(X,Z,Q))throw new p$(X,"Array cast produced invalid data due to uniqueItems constraint");return Q}function Zw(X,Z,Y){if(z8(X,Z,Y))return w2(X,Z);let $=new Set(X.returns.required||[]),W=function(){};for(let[J,z]of Object.entries(X.returns.properties)){if(!$.has(J)&&Y.prototype[J]===void 0)continue;W.prototype[J]=d2(z,Z,Y.prototype[J])}return W}function Yw(X,Z,Y){let $=globalThis.Object.values(X.$defs),W=X.$defs[X.$ref];return d2(W,[...Z,...$],Y)}function $w(X,Z,Y){let $=w2(X,Z),W=W8($)&&W8(Y)?{...$,...Y}:Y;return z8(X,Z,W)?W:w2(X,Z)}function Ww(X,Z,Y){throw new p$(X,"Never types cannot be cast")}function Jw(X,Z,Y){if(z8(X,Z,Y))return Y;if(Y===null||typeof Y!=="object")return w2(X,Z);let $=new Set(X.required||[]),W={};for(let[J,z]of Object.entries(X.properties)){if(!$.has(J)&&Y[J]===void 0)continue;W[J]=d2(z,Z,Y[J])}if(typeof X.additionalProperties==="object"){let J=Object.getOwnPropertyNames(X.properties);for(let z of Object.getOwnPropertyNames(Y)){if(J.includes(z))continue;W[z]=d2(X.additionalProperties,Z,Y[z])}}return W}function zw(X,Z,Y){if(z8(X,Z,Y))return B8(Y);if(Y===null||typeof Y!=="object"||Array.isArray(Y)||Y instanceof Date)return w2(X,Z);let $=Object.getOwnPropertyNames(X.patternProperties)[0],W=X.patternProperties[$],J={};for(let[z,Q]of Object.entries(Y))J[z]=d2(W,Z,Q);return J}function Qw(X,Z,Y){return d2(F8(X,Z),Z,Y)}function Gw(X,Z,Y){return d2(F8(X,Z),Z,Y)}function Mw(X,Z,Y){if(z8(X,Z,Y))return B8(Y);if(!t(Y))return w2(X,Z);if(X.items===void 0)return[];return X.items.map(($,W)=>d2($,Z,Y[W]))}function Uw(X,Z,Y){return z8(X,Z,Y)?B8(Y):r_(X,Z,Y)}function d2(X,Z,Y){let $=O8(X.$id)?D0(X,Z):Z,W=X;switch(X[q]){case"Array":return Xw(W,$,Y);case"Constructor":return Zw(W,$,Y);case"Import":return Yw(W,$,Y);case"Intersect":return $w(W,$,Y);case"Never":return Ww(W,$,Y);case"Object":return Jw(W,$,Y);case"Record":return zw(W,$,Y);case"Ref":return Qw(W,$,Y);case"This":return Gw(W,$,Y);case"Tuple":return Mw(W,$,Y);case"Union":return Uw(W,$,Y);case"Date":case"Symbol":case"Uint8Array":return a_(X,Z,Y);default:return e_(W,$,Y)}}function wZ(...X){return X.length===3?d2(X[0],X[1],X[2]):d2(X[0],[],X[1])}function Hw(X){return IX(X)&&X[q]!=="Unsafe"}function Dw(X,Z,Y){if(!t(Y))return Y;return Y.map(($)=>m0(X.items,Z,$))}function Aw(X,Z,Y){let $=globalThis.Object.values(X.$defs),W=X.$defs[X.$ref];return m0(W,[...Z,...$],Y)}function _w(X,Z,Y){let $=X.unevaluatedProperties,J=X.allOf.map((Q)=>m0(Q,Z,B8(Y))).reduce((Q,M)=>W8(M)?{...Q,...M}:M,{});if(!W8(Y)||!W8(J)||!IX($))return J;let z=y0(X);for(let Q of Object.getOwnPropertyNames(Y)){if(z.includes(Q))continue;if(z8($,Z,Y[Q]))J[Q]=m0($,Z,Y[Q])}return J}function ww(X,Z,Y){if(!W8(Y)||t(Y))return Y;let $=X.additionalProperties;for(let W of Object.getOwnPropertyNames(Y)){if(l(X.properties,W)){Y[W]=m0(X.properties[W],Z,Y[W]);continue}if(IX($)&&z8($,Z,Y[W])){Y[W]=m0($,Z,Y[W]);continue}delete Y[W]}return Y}function Ow(X,Z,Y){if(!W8(Y))return Y;let $=X.additionalProperties,W=Object.getOwnPropertyNames(Y),[J,z]=Object.entries(X.patternProperties)[0],Q=new RegExp(J);for(let M of W){if(Q.test(M)){Y[M]=m0(z,Z,Y[M]);continue}if(IX($)&&z8($,Z,Y[M])){Y[M]=m0($,Z,Y[M]);continue}delete Y[M]}return Y}function Nw(X,Z,Y){return m0(F8(X,Z),Z,Y)}function Lw(X,Z,Y){return m0(F8(X,Z),Z,Y)}function Fw(X,Z,Y){if(!t(Y))return Y;if(c8(X.items))return[];let $=Math.min(Y.length,X.items.length);for(let W=0;W<$;W++)Y[W]=m0(X.items[W],Z,Y[W]);return Y.length>$?Y.slice(0,$):Y}function Bw(X,Z,Y){for(let $ of X.anyOf)if(Hw($)&&z8($,Z,Y))return m0($,Z,Y);return Y}function m0(X,Z,Y){let $=O8(X.$id)?D0(X,Z):Z,W=X;switch(W[q]){case"Array":return Dw(W,$,Y);case"Import":return Aw(W,$,Y);case"Intersect":return _w(W,$,Y);case"Object":return ww(W,$,Y);case"Record":return Ow(W,$,Y);case"Ref":return Nw(W,$,Y);case"This":return Lw(W,$,Y);case"Tuple":return Fw(W,$,Y);case"Union":return Bw(W,$,Y);default:return Y}}function OY(...X){return X.length===3?m0(X[0],X[1],X[2]):m0(X[0],[],X[1])}function NY(X){return O8(X)&&!isNaN(X)&&!isNaN(parseFloat(X))}function qw(X){return O0(X)||s2(X)||o(X)}function OZ(X){return X===!0||o(X)&&X===1||O0(X)&&X===BigInt("1")||O8(X)&&(X.toLowerCase()==="true"||X==="1")}function NZ(X){return X===!1||o(X)&&(X===0||Object.is(X,-0))||O0(X)&&X===BigInt("0")||O8(X)&&(X.toLowerCase()==="false"||X==="0"||X==="-0")}function Kw(X){return O8(X)&&/^(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)$/i.test(X)}function Rw(X){return O8(X)&&/^(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)?$/i.test(X)}function jw(X){return O8(X)&&/^\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(X)}function Sw(X){return O8(X)&&/^\d\d\d\d-[0-1]\d-[0-3]\dt(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)?$/i.test(X)}function Vw(X){return O8(X)&&/^\d\d\d\d-[0-1]\d-[0-3]\d$/i.test(X)}function Ew(X,Z){let Y=kW(X);return Y===Z?Y:X}function Cw(X,Z){let Y=gW(X);return Y===Z?Y:X}function Pw(X,Z){let Y=bW(X);return Y===Z?Y:X}function Iw(X,Z){return O8(X.const)?Ew(Z,X.const):o(X.const)?Cw(Z,X.const):s2(X.const)?Pw(Z,X.const):Z}function bW(X){return OZ(X)?!0:NZ(X)?!1:X}function xw(X){let Z=(Y)=>Y.split(".")[0];return NY(X)?BigInt(Z(X)):o(X)?BigInt(Math.trunc(X)):NZ(X)?BigInt(0):OZ(X)?BigInt(1):X}function kW(X){return QX(X)&&X.description!==void 0?X.description.toString():qw(X)?X.toString():X}function gW(X){return NY(X)?parseFloat(X):OZ(X)?1:NZ(X)?0:X}function Tw(X){return NY(X)?parseInt(X):o(X)?Math.trunc(X):OZ(X)?1:NZ(X)?0:X}function bw(X){return O8(X)&&X.toLowerCase()==="null"?null:X}function kw(X){return O8(X)&&X==="undefined"?void 0:X}function gw(X){return P0(X)?X:o(X)?new Date(X):OZ(X)?new Date(1):NZ(X)?new Date(0):NY(X)?new Date(parseInt(X)):Rw(X)?new Date(`1970-01-01T${X}.000Z`):Kw(X)?new Date(`1970-01-01T${X}`):Sw(X)?new Date(`${X}.000Z`):jw(X)?new Date(X):Vw(X)?new Date(`${X}T00:00:00.000Z`):X}function fw(X){return X}function vw(X,Z,Y){return(t(Y)?Y:[Y]).map((W)=>h2(X.items,Z,W))}function yw(X,Z,Y){return xw(Y)}function dw(X,Z,Y){return bW(Y)}function hw(X,Z,Y){return gw(Y)}function mw(X,Z,Y){let $=globalThis.Object.values(X.$defs),W=X.$defs[X.$ref];return h2(W,[...Z,...$],Y)}function pw(X,Z,Y){return Tw(Y)}function cw(X,Z,Y){return X.allOf.reduce(($,W)=>h2(W,Z,$),Y)}function uw(X,Z,Y){return Iw(X,Y)}function iw(X,Z,Y){return bw(Y)}function ow(X,Z,Y){return gW(Y)}function nw(X,Z,Y){if(!W8(Y))return Y;for(let $ of Object.getOwnPropertyNames(X.properties)){if(!l(Y,$))continue;Y[$]=h2(X.properties[$],Z,Y[$])}return Y}function lw(X,Z,Y){if(!W8(Y))return Y;let W=Object.getOwnPropertyNames(X.patternProperties)[0],J=X.patternProperties[W];for(let[z,Q]of Object.entries(Y))Y[z]=h2(J,Z,Q);return Y}function tw(X,Z,Y){return h2(F8(X,Z),Z,Y)}function sw(X,Z,Y){return kW(Y)}function rw(X,Z,Y){return O8(Y)||o(Y)?Symbol(Y):Y}function aw(X,Z,Y){return h2(F8(X,Z),Z,Y)}function ew(X,Z,Y){if(!(t(Y)&&!c8(X.items)))return Y;return Y.map((W,J)=>{return J{let z=x0(J,Z,$);return W8(z)?{...W,...z}:z},{})}function zO(X,Z,Y){let $=LX(X,Y);if(!W8($))return $;let W=Object.getOwnPropertyNames(X.properties);for(let J of W){let z=x0(X.properties[J],Z,$[J]);if(c8(z))continue;$[J]=x0(X.properties[J],Z,$[J])}if(!c$(X.additionalProperties))return $;for(let J of Object.getOwnPropertyNames($)){if(W.includes(J))continue;$[J]=x0(X.additionalProperties,Z,$[J])}return $}function QO(X,Z,Y){let $=LX(X,Y);if(!W8($))return $;let W=X.additionalProperties,[J,z]=Object.entries(X.patternProperties)[0],Q=new RegExp(J);for(let M of Object.getOwnPropertyNames($)){if(!(Q.test(M)&&c$(z)))continue;$[M]=x0(z,Z,$[M])}if(!c$(W))return $;for(let M of Object.getOwnPropertyNames($)){if(Q.test(M))continue;$[M]=x0(W,Z,$[M])}return $}function GO(X,Z,Y){return x0(F8(X,Z),Z,LX(X,Y))}function MO(X,Z,Y){return x0(F8(X,Z),Z,Y)}function UO(X,Z,Y){let $=LX(X,Y);if(!t($)||c8(X.items))return $;let[W,J]=[X.items,Math.max(X.items.length,$.length)];for(let z=0;zu$,ValuePointerRootDeleteError:()=>i$,Set:()=>DO,Has:()=>_O,Get:()=>wO,Format:()=>LZ,Delete:()=>AO});class u$ extends n{constructor(X,Z,Y){super("Cannot set root value");this.value=X,this.path=Z,this.update=Y}}class i$ extends n{constructor(X,Z){super("Cannot delete root value");this.value=X,this.path=Z}}function vW(X){return X.indexOf("~")===-1?X:X.replace(/~1/g,"/").replace(/~0/g,"~")}function*LZ(X){if(X==="")return;let[Z,Y]=[0,0];for(let $=0;$G1(X[W],Z[W]))}function NO(X,Z){return P0(Z)&&X.getTime()===Z.getTime()}function LO(X,Z){if(!t(Z)||X.length!==Z.length)return!1;return X.every((Y,$)=>G1(Y,Z[$]))}function FO(X,Z){if(!z2(Z)||X.length!==Z.length||Object.getPrototypeOf(X).constructor.name!==Object.getPrototypeOf(Z).constructor.name)return!1;return X.every((Y,$)=>G1(Y,Z[$]))}function BO(X,Z){return X===Z}function G1(X,Z){if(P0(X))return NO(X,Z);if(z2(X))return FO(X,Z);if(t(X))return LO(X,Z);if(W8(X))return OO(X,Z);if(r0(X))return BO(X,Z);throw new Error("ValueEquals: Unable to compare value")}var qO=j8({type:_8("insert"),path:I0(),value:k2()}),KO=j8({type:_8("update"),path:I0(),value:k2()}),RO=j8({type:_8("delete"),path:I0()}),dW=R8([qO,KO,RO]);class o$ extends n{constructor(X,Z){super(Z);this.value=X}}function BY(X,Z){return{type:"update",path:X,value:Z}}function hW(X,Z){return{type:"insert",path:X,value:Z}}function mW(X){return{type:"delete",path:X}}function yW(X){if(globalThis.Object.getOwnPropertySymbols(X).length>0)throw new o$(X,"Cannot diff objects with symbols")}function*jO(X,Z,Y){if(yW(Z),yW(Y),!_$(Y))return yield BY(X,Y);let $=globalThis.Object.getOwnPropertyNames(Z),W=globalThis.Object.getOwnPropertyNames(Y);for(let J of W){if(l(Z,J))continue;yield hW(`${X}/${J}`,Y[J])}for(let J of $){if(!l(Y,J))continue;if(G1(Z,Y))continue;yield*qY(`${X}/${J}`,Z[J],Y[J])}for(let J of $){if(l(Y,J))continue;yield mW(`${X}/${J}`)}}function*SO(X,Z,Y){if(!t(Y))return yield BY(X,Y);for(let $=0;$=0;$--){if($0&&X[0].path===""&&X[0].type==="update"}function PO(X){return X.length===0}function cW(X,Z){if(CO(Z))return B8(Z[0].value);if(PO(Z))return B8(X);let Y=B8(X);for(let $ of Z)switch($.type){case"insert":{m2.Set(Y,$.path,$.value);break}case"update":{m2.Set(Y,$.path,$.value);break}case"delete":{m2.Delete(Y,$.path);break}}return Y}function uW(...X){let[Z,Y,$]=X.length===3?[X[0],X[1],X[2]]:[X[0],[],X[1]],W=OX(Z,Y)?p1(Z,Y,$):$;if(!z8(Z,Y,W))throw new _Z(Z,W,ZX(Z,Y,W).First());return W}function KY(X){return W8(X)&&!t(X)}class n$ extends n{constructor(X){super(X)}}function IO(X,Z,Y,$){if(!KY(Y))m2.Set(X,Z,B8($));else{let W=Object.getOwnPropertyNames(Y),J=Object.getOwnPropertyNames($);for(let z of W)if(!J.includes(z))delete Y[z];for(let z of J)if(!W.includes(z))Y[z]=null;for(let z of J)l$(X,`${Z}/${z}`,Y[z],$[z])}}function xO(X,Z,Y,$){if(!t(Y))m2.Set(X,Z,B8($));else{for(let W=0;W<$.length;W++)l$(X,`${Z}/${W}`,Y[W],$[W]);Y.splice($.length)}}function TO(X,Z,Y,$){if(z2(Y)&&Y.length===$.length)for(let W=0;W{return wY(J,z,Q),Q}],["Cast",(J,z,Q)=>wZ(J,z,Q)],["Clean",(J,z,Q)=>OY(J,z,Q)],["Clone",(J,z,Q)=>B8(Q)],["Convert",(J,z,Q)=>LY(J,z,Q)],["Decode",(J,z,Q)=>OX(J,z)?m1(J,z,Q):Q],["Default",(J,z,Q)=>FY(J,z,Q)],["Encode",(J,z,Q)=>OX(J,z)?p1(J,z,Q):Q]]);function Y(J){Z.delete(J)}X.Delete=Y;function $(J,z){Z.set(J,z)}X.Set=$;function W(J){return Z.get(J)}X.Get=W})(t$||(t$={}));var nW=["Clone","Clean","Default","Convert","Assert","Decode"];function gO(X,Z,Y,$){return X.reduce((W,J)=>{let z=t$.Get(J);if(c8(z))throw new s$(`Unable to find Parse operation '${J}'`);return z(Z,Y,W)},$)}function lW(...X){let[Z,Y,$,W]=X.length===4?[X[0],X[1],X[2],X[3]]:X.length===3?t(X[0])?[X[0],X[1],[],X[2]]:[nW,X[0],X[1],X[2]]:X.length===2?[nW,X[0],[],X[1]]:(()=>{throw new s$("Invalid Arguments")})();return gO(Z,Y,$,W)}var e={};EX(e,{ValueErrorIterator:()=>z1,Patch:()=>cW,Parse:()=>lW,Mutate:()=>oW,Hash:()=>fX,Errors:()=>ZX,Equal:()=>G1,Encode:()=>uW,Edit:()=>dW,Diff:()=>pW,Default:()=>FY,Decode:()=>fW,Create:()=>w2,Convert:()=>LY,Clone:()=>B8,Clean:()=>OY,Check:()=>z8,Cast:()=>wZ,Assert:()=>wY});var bY=ez(aW(),1);var G6={date:q5,time:W6(!0),"date-time":eW(!0),"iso-time":W6(!1),"iso-date-time":eW(!1),duration:/^P(?!$)((\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+S)?)?|(\d+W)?)$/,uri:ZN,"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:GN,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:YN,int32:{type:"number",validate:JN},int64:{type:"number",validate:zN},float:{type:"number",validate:Z5},double:{type:"number",validate:Z5},password:!0,binary:!0};function lO(X){return X%4===0&&(X%100!==0||X%400===0)}var tO=/^(\d\d\d\d)-(\d\d)-(\d\d)$/,sO=[0,31,28,31,30,31,30,31,31,30,31,30,31];function q5(X){let Z=tO.exec(X);if(!Z)return!1;let Y=+Z[1],$=+Z[2],W=+Z[3];return $>=1&&$<=12&&W>=1&&W<=($===2&&lO(Y)?29:sO[$])}var rO=/^(\d\d):(\d\d):(\d\d(?:\.\d+)?)(z|([+-])(\d\d)(?::?(\d\d))?)?$/i;function W6(X){return function Z(Y){let $=rO.exec(Y);if(!$)return!1;let W=+$[1],J=+$[2],z=+$[3],Q=$[4],M=$[5]==="-"?-1:1,G=+($[6]||0),U=+($[7]||0);if(G>23||U>59||X&&!Q)return!1;if(W<=23&&J<=59&&z<60)return!0;let w=J-U*M,B=W-G*M-(w<0?1:0);return(B===23||B===-1)&&(w===59||w===-1)&&z<61}}var aO=/t|\s/i;function eW(X){let Z=W6(X);return function Y($){let W=$.split(aO);return W.length===2&&q5(W[0])&&Z(W[1])}}var eO=/\/|:/,XN=/^(?:[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 ZN(X){return eO.test(X)&&XN.test(X)}var X5=/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/gm;function YN(X){return X5.lastIndex=0,X5.test(X)}var $N=-2147483648,WN=2147483647;function JN(X){return Number.isInteger(X)&&X<=WN&&X>=$N}function zN(X){return Number.isInteger(X)}function Z5(){return!0}var QN=/[^\\]\\Z/;function GN(X){if(QN.test(X))return!1;try{return new RegExp(X),!0}catch(Z){return!1}}var VY="toJSON"in new Headers,Y5=(X,Z)=>{let Y=new URL(X);return Y.pathname=Z,Y.toString()},MN=(X)=>typeof X==="function"&&/^\s*class\s+/.test(X.toString())||X.toString&&X.toString().startsWith("[object ")&&X.toString()!=="[object Object]"||F2(Object.getPrototypeOf(X)),r$=(X)=>X&&typeof X==="object"&&!Array.isArray(X),c0=(X,Z,{skipKeys:Y,override:$=!0}={})=>{if(!r$(X)||!r$(Z))return X;for(let[W,J]of Object.entries(Z)){if(Y?.includes(W))continue;if(!r$(J)||!(W in X)||MN(J)){if($||!(W in X))X[W]=J;continue}X[W]=c0(X[W],J,{skipKeys:Y,override:$})}return X},UN=(X,Z)=>{let Y=c0(Object.assign({},X),Z,{skipKeys:["properties"]});if("properties"in Y)delete Y.properties;return Y},r8=(X=[],Z=[])=>{if(!X)return;if(!Z)return X;let Y=[],$=[];if(!Array.isArray(X))X=[X];if(!Array.isArray(Z))Z=[Z];for(let W of X)if(Y.push(W),W.checksum)$.push(W.checksum);for(let W of Z)if(!$.includes(W.checksum))Y.push(W);return Y},HN=["start","request","parse","transform","resolve","beforeHandle","afterHandle","mapResponse","afterResponse","trace","error","stop","body","headers","params","query","response","type","detail"],DN=HN.reduce((X,Z)=>(X[Z]=!0,X),{}),K5=(X,Z)=>{let Y=($)=>typeof $==="object"&&Object.keys($).every(M6);if(Y(X)&&Y(Z))return Object.assign(X,Z);else if(X&&!Y(X)&&Y(Z))return Object.assign({200:X},Z);return Z??X},FZ=(X,Z)=>{return{body:Z?.body??X?.body,headers:Z?.headers??X?.headers,params:Z?.params??X?.params,query:Z?.query??X?.query,cookie:Z?.cookie??X?.cookie,response:K5(X?.response,Z?.response)}},FX=(X,Z)=>{let{resolve:Y,...$}=X??{},{resolve:W,...J}=Z??{};return{...$,...J,body:Z?.body??X?.body,headers:Z?.headers??X?.headers,params:Z?.params??X?.params,query:Z?.query??X?.query,cookie:Z?.cookie??X?.cookie,response:K5(X?.response,Z?.response),type:X?.type||Z?.type,detail:c0(Z?.detail??{},X?.detail??{}),parse:r8(X?.parse,Z?.parse),transform:r8(X?.transform,Z?.transform),beforeHandle:r8(r8(w0(Y,"resolve"),X?.beforeHandle),r8(w0(W,"resolve"),Z?.beforeHandle)),afterHandle:r8(X?.afterHandle,Z?.afterHandle),mapResponse:r8(X?.mapResponse,Z?.mapResponse),afterResponse:r8(X?.afterResponse,Z?.afterResponse),trace:r8(X?.trace,Z?.trace),error:r8(X?.error,Z?.error)}},J6=(X,Z,Y=!0)=>{if(!Array.isArray(Z))return Z.original=X,F0(X,Z,Y);for(let $ of Z)$.original=X,X=F0(X,$,Y);return X},F0=(X,Z,Y=!0)=>{if(!X)return X;if(Z.untilObjectFound&&!Y&&X.type==="object")return X;let $=Z.from[q];if(X.oneOf){for(let z=0;z{if(U&&E.type==="object"){let Y8={};for(let[s,V8]of Object.entries(U))Y8[s]=F0(V8,Z,!1);return{...B,...E,properties:Y8}}if(w&&E.type==="array")return{...B,...E,items:F0(w,Z,!1)};let h={...B,...E};if(delete h.required,U&&E.type==="string"&&E.format==="ObjectString"&&E.default==="{}")S=_.ObjectString(U,B),h.default=JSON.stringify(e.Create(_.Object(U))),h.properties=U;if(w&&E.type==="string"&&E.format==="ArrayString"&&E.default==="[]")S=_.ArrayString(w,B),h.default=JSON.stringify(e.Create(_.Array(w))),h.items=w;return h};if(W){if(U){let E={};for(let[h,Y8]of Object.entries(U))E[h]=F0(Y8,Z,!1);return{...B,properties:E}}else if(w?.map)return{...B,items:w.map((E)=>F0(E,Z,!1))};return B}if(N.anyOf)for(let E=0;EF0(E,Z,!1))};return{...B,...N}}let J=X?.properties;if(J&&Y&&Z.rootOnly!==!0)for(let[z,Q]of Object.entries(J))switch(Q[q]){case $:let{anyOf:M,oneOf:G,allOf:U,not:w,type:B,...N}=Q,S=Z.to(N);if(!S)return X;if(S.anyOf)for(let H=0;H(Z)=>{if(typeof Z==="object")try{return e.Clean(X,structuredClone(Z))}catch{try{return e.Clean(X,Z)}catch{return Z}}return Z},u0=(X,{models:Z={},dynamic:Y=!1,modules:$,normalize:W=!1,additionalProperties:J=!1,coerce:z=!1,additionalCoerce:Q=[]}={modules:_.Module({})})=>{if(!X)return;let M;if(typeof X!=="string")M=X;else{let U=X.endsWith("[]"),w=U?X.substring(0,X.length-2):X;if(M=$.Import(w)??Z[w],U)M=_.Array(M)}if(!M)return;if(z||Q)if(z)M=J6(M,[{from:_.Ref(""),to:(U)=>$.Import(U.$ref)},{from:_.Number(),to:(U)=>_.Numeric(U),untilObjectFound:!0},{from:_.Boolean(),to:(U)=>_.BooleanString(U),untilObjectFound:!0},...Array.isArray(Q)?Q:[Q]]);else M=J6(M,[{from:_.Ref(""),to:(U)=>$.Import(U.$ref)},...Array.isArray(Q)?Q:[Q]]);if(M.type==="object"&&"additionalProperties"in M===!1)M.additionalProperties=J;if(Y){let U={schema:M,references:"",checkFunc:()=>{},code:"",Check:(w)=>e.Check(M,w),Errors:(w)=>e.Errors(M,w),Code:()=>"",Clean:RZ(M),Decode:(w)=>e.Decode(M,w),Encode:(w)=>e.Encode(M,w)};if(W&&M.additionalProperties===!1)U.Clean=RZ(M);if(M.config){if(U.config=M.config,U?.schema?.config)delete U.schema.config}return U.parse=(w)=>{try{return U.Decode(w)}catch(B){throw[...U.Errors(w)].map(i2)}},U.safeParse=(w)=>{try{return{success:!0,data:U.Decode(w),error:null}}catch(B){let N=[...G.Errors(w)].map(i2);return{success:!1,data:null,error:N[0]?.summary,errors:N}}},U}let G=vX.Compile(M,Object.values(Z));if(G.Clean=RZ(M),M.config){if(G.config=M.config,G?.schema?.config)delete G.schema.config}return G.parse=(U)=>{try{return G.Decode(U)}catch(w){throw[...G.Errors(U)].map(i2)}},G.safeParse=(U)=>{try{return{success:!0,data:G.Decode(U),error:null}}catch(w){let B=[...G.Errors(U)].map(i2);return{success:!1,data:null,error:B[0]?.summary,errors:B}}},G},$5=(X,{models:Z={},modules:Y,dynamic:$=!1,normalize:W=!1,additionalProperties:J=!1})=>{if(!X)return;let z;if(typeof X!=="string")z=X;else{let U=X.endsWith("[]"),w=U?X.substring(0,X.length-2):X;if(z=Y.Import(w)??Z[w],U)z=_.Array(z)}if(!z)return;let Q=(U,w)=>{if($)return{schema:U,references:"",checkFunc:()=>{},code:"",Check:(N)=>e.Check(U,N),Errors:(N)=>e.Errors(U,N),Code:()=>"",Clean:RZ(U),Decode:(N)=>e.Decode(U,N),Encode:(N)=>e.Encode(U,N)};let B=vX.Compile(U,w);if(W&&U.additionalProperties===!1)B.Clean=RZ(U);return B},M=Object.values(Z);if(q in z){if("additionalProperties"in z===!1)z.additionalProperties=J;return{200:Q(z,M)}}let G={};return Object.keys(z).forEach((U)=>{let w=z[+U];if(typeof w==="string"){if(w in Z){let B=Z[w];B.type==="object"&&"additionalProperties"in B,G[+U]=q in B?Q(B,M):B}return}if(w.type==="object"&&"additionalProperties"in w===!1)w.additionalProperties=J;G[+U]=q in w?Q(w,M):w}),G},AN=typeof Bun!=="undefined",_N=AN&&typeof Bun.hash==="function",BZ=(X)=>{if(_N)return Bun.hash(X);let Z=9;for(let Y=0;Y>>9},a$,M1=()=>{if(!a$)a$=[{from:_.Object({}),to:()=>_.ObjectString({}),excludeRoot:!0},{from:_.Array(_.Any()),to:()=>_.ArrayString(_.Any())}];return a$},e$,W5=()=>{if(!e$)e$=[{from:_.Number(),to:(X)=>_.Numeric(X),rootOnly:!0},{from:_.Boolean(),to:(X)=>_.BooleanString(X),rootOnly:!0}];return e$},R5=({validator:X,modules:Z,defaultConfig:Y={},config:$,dynamic:W,models:J})=>{let z=u0(X,{modules:Z,dynamic:W,models:J,additionalProperties:!0,coerce:!0,additionalCoerce:M1()});if(F2(Y))if(z)z.config=UN(z.config,$);else z=u0(_.Cookie({}),{modules:Z,dynamic:W,models:J,additionalProperties:!0}),z.config=Y;return z},p2=(X,Z)=>{if(!Z)return;if(!Array.isArray(Z)){let $=Z;if(X&&!$.checksum)$.checksum=X;if($.scope==="scoped")$.scope="local";return $}let Y=[...Z];for(let $ of Y){if(X&&!$.checksum)$.checksum=X;if($.scope==="scoped")$.scope="local"}return Y},J5=(X,Z,Y)=>{return{start:r8(X.start,p2(Y,Z?.start)),request:r8(X.request,p2(Y,Z?.request)),parse:r8(X.parse,p2(Y,Z?.parse)),transform:r8(X.transform,p2(Y,Z?.transform)),beforeHandle:r8(r8(w0(X.resolve,"resolve"),X.beforeHandle),p2(Y,r8(w0(Z?.resolve,"resolve"),Z?.beforeHandle))),afterHandle:r8(X.afterHandle,p2(Y,Z?.afterHandle)),mapResponse:r8(X.mapResponse,p2(Y,Z?.mapResponse)),afterResponse:r8(X.afterResponse,p2(Y,Z?.afterResponse)),trace:r8(X.trace,p2(Y,Z?.trace)),error:r8(X.error,p2(Y,Z?.error)),stop:r8(X.stop,p2(Y,Z?.stop))}},wN=(X,Z,{skipIfHasType:Y=!1}={})=>{if(!X)return X;if(!Array.isArray(X)){if(Y)X.scope??=Z;else X.scope=Z;return X}for(let $ of X)if(Y)$.scope??=Z;else $.scope=Z;return X},yX=(X)=>{if(!X)return X;if(!Array.isArray(X))switch(X.scope){case"global":case"scoped":return{...X};default:return{fn:X}}let Z=[];for(let Y of X)switch(Y.scope){case"global":case"scoped":Z.push({...Y});break}return Z},z5=(X)=>{return{...X,type:X?.type,detail:X?.detail,parse:yX(X?.parse),transform:yX(X?.transform),beforeHandle:yX(X?.beforeHandle),afterHandle:yX(X?.afterHandle),mapResponse:yX(X?.mapResponse),afterResponse:yX(X?.afterResponse),error:yX(X?.error),trace:yX(X?.trace)}},xY={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},Q5=Object.fromEntries(Object.entries(xY).map(([X,Z])=>[Z,X]));function ON(X){let Z=X;while(Z.endsWith("="))Z=Z.slice(0,-1);return Z}var G5=new TextEncoder,EY=async(X,Z)=>{if(typeof X!=="string")throw new TypeError("Cookie value must be provided as a string.");if(Z===null)throw new TypeError("Secret key must be provided.");let Y=await crypto.subtle.importKey("raw",G5.encode(Z),{name:"HMAC",hash:"SHA-256"},!1,["sign"]),$=await crypto.subtle.sign("HMAC",Y,G5.encode(X));return X+"."+ON(Buffer.from($).toString("base64"))},M5=async(X,Z)=>{if(typeof X!=="string")throw new TypeError("Signed cookie string must be provided.");if(Z===null)throw new TypeError("Secret key must be provided.");let Y=X.slice(0,X.lastIndexOf("."));return await EY(Y,Z)===X?Y:!1},NN=(X,Z,Y)=>{if(!X||typeof X!=="object"||!Z)return;for(let[$,W]of Object.entries(Z)){if($ in DN||!($ in X))continue;let J=X[$];if(typeof J==="function"){let z=J(W);if(typeof z==="object")for(let[Q,M]of Object.entries(z))Y(Q)({fn:M})}delete Z[$]}},LN=({globalHook:X,localHook:Z})=>(Y)=>($,W)=>{if(typeof $==="function")$={fn:$};if(Y==="resolve")$={...$,subType:"resolve"};if("fn"in $||Array.isArray($)){if(!Z[Y])Z[Y]=[];if(typeof Z[Y]==="function")Z[Y]=[Z[Y]];if(Array.isArray($))Z[Y]=Z[Y].concat($);else Z[Y].push($);return}let{insert:J="after",stack:z="local"}=$;if(typeof W==="function")W={fn:W};if(z==="global")if(!Array.isArray(W))if(J==="before")X[Y].unshift(W);else X[Y].push(W);else if(J==="before")X[Y]=W.concat(X[Y]);else X[Y]=X[Y].concat(W);else{if(!Z[Y])Z[Y]=[];if(typeof Z[Y]==="function")Z[Y]=[Z[Y]];if(!Array.isArray(W))if(J==="before")Z[Y].unshift(W);else Z[Y].push(W);else if(J==="before")Z[Y]=W.concat(Z[Y]);else Z[Y]=Z[Y].concat(W)}},FN=(X)=>{if(typeof X==="number")return X;if(X.length<16){if(X.trim().length===0)return null;let Z=Number(X);if(Number.isNaN(Z))return null;return Z}if(X.length===16){if(X.trim().length===0)return null;let Z=Number(X);if(Number.isNaN(Z)||Z.toString()!==X)return null;return Z}return null},M6=(X)=>FN(X)!==null;class j5{onError;root=null;promises=[];constructor(X=console.error){this.onError=X}get size(){return this.promises.length}add(X){return this.promises.push(X),this.root||=this.drain(),X}async drain(){while(this.promises.length>0){try{await this.promises[0]}catch(X){this.onError(X)}this.promises.shift()}this.root=null}then(X,Z){return(this.root??Promise.resolve()).then(X,Z)}}var w0=(X,Z)=>{if(!X)return X;if(!Array.isArray(X)){if(typeof X==="function"||typeof X==="string")return Z?{fn:X,subType:Z}:{fn:X};else if("fn"in X)return X}let Y=[];for(let $ of X)if(typeof $==="function"||typeof $==="string")Y.push(Z?{fn:$,subType:Z}:{fn:$});else if("fn"in $)Y.push($);return Y},BN=(X)=>{return{...X,start:w0(X?.start),request:w0(X?.request),parse:w0(X?.parse),transform:w0(X?.transform),beforeHandle:w0(X?.beforeHandle),afterHandle:w0(X?.afterHandle),mapResponse:w0(X?.mapResponse),afterResponse:w0(X?.afterResponse),trace:w0(X?.trace),error:w0(X?.error),stop:w0(X?.stop)}},U5=(X)=>{let Z={};if(X.start?.map)Z.start=X.start.map((Y)=>Y.fn);if(X.request?.map)Z.request=X.request.map((Y)=>Y.fn);if(X.parse?.map)Z.parse=X.parse.map((Y)=>Y.fn);if(X.transform?.map)Z.transform=X.transform.map((Y)=>Y.fn);if(X.beforeHandle?.map)Z.beforeHandle=X.beforeHandle.map((Y)=>Y.fn);if(X.afterHandle?.map)Z.afterHandle=X.afterHandle.map((Y)=>Y.fn);if(X.mapResponse?.map)Z.mapResponse=X.mapResponse.map((Y)=>Y.fn);if(X.afterResponse?.map)Z.afterResponse=X.afterResponse.map((Y)=>Y.fn);if(X.trace?.map)Z.trace=X.trace.map((Y)=>Y.fn);if(X.error?.map)Z.error=X.error.map((Y)=>Y.fn);if(X.stop?.map)Z.stop=X.stop.map((Y)=>Y.fn);return Z},X6=(X)=>({body:X.body,cookie:X.cookie,headers:X.headers,query:X.query,set:X.set,server:X.server,request:X.request,route:X.route}),S5=(X,Z=302)=>Response.redirect(X,Z),nx=Symbol("ElysiaFormData"),TY=Symbol("ElysiaRequestId");var V5=()=>{let X=crypto.randomUUID();return X.slice(0,8)+X.slice(24,32)},H5=(X)=>{let Z=[];for(let Y=0;Y{if(!X)return;if(Z==="scoped"){for(let Y of X)if("scope"in Y&&Y.scope==="local")Y.scope="scoped";return}for(let Y of X)if("scope"in Y)Y.scope="global"},c1=(X)=>{if(X.charCodeAt(X.length-1)===47)return X.slice(0,X.length-1);return X+"/"},F2=(X)=>{if(!X)return!1;for(let Z in X)return!0;return!1},c2=(X)=>{if(Array.isArray(X))return X.length===0;return!X},Z6=(X)=>{let Z={...X};if(c2(X.afterHandle))delete Z.afterHandle;if(c2(X.afterResponse))delete Z.afterResponse;if(c2(X.beforeHandle))delete Z.beforeHandle;if(c2(X.error))delete Z.error;if(c2(X.mapResponse))delete Z.mapResponse;if(c2(X.parse))delete Z.parse;if(c2(X.request))delete Z.request;if(c2(X.start))delete Z.start;if(c2(X.stop))delete Z.stop;if(c2(X.trace))delete Z.trace;if(c2(X.transform))delete Z.transform;if(!Z.type)delete Z.type;if(Z.detail&&!Object.keys(Z.detail).length)delete Z.detail;if(!Z.body)delete Z.body;if(!Z.cookie)delete Z.cookie;if(!Z.headers)delete Z.headers;if(!Z.query)delete Z.query;if(!Z.params)delete Z.params;if(!Z.response)delete Z.response;return Z},qZ=(X,{dynamic:Z=!1}={})=>{let Y=encodeURIComponent(X).replace(/%2F/g,"/");if(Z)Y=Y.replace(/%3A/g,":").replace(/%3F/g,"?");return Y},D5=typeof Bun!=="undefined"?Bun.env:typeof process!=="undefined"?process?.env:void 0,CY=Symbol("ElysiaErrorCode"),PY=(D5?.NODE_ENV??D5?.ENV)==="production";class o2{code;response;constructor(X,Z){let Y=Z??(X in Q5?Q5[X]:X);this.code=xY[X]??X,this.response=Y}}var _1=(X,Z)=>new o2(X,Z);class E5 extends Error{code="INTERNAL_SERVER_ERROR";status=500;constructor(X){super(X??"INTERNAL_SERVER_ERROR")}}class U6 extends Error{code="NOT_FOUND";status=404;constructor(X){super(X??"NOT_FOUND")}}class C5 extends Error{code="PARSE";status=400;constructor(){super("Bad Request")}}class z6 extends Error{key;code="INVALID_COOKIE_SIGNATURE";status=400;constructor(X,Z){super(Z??`"${X}" has invalid cookie signature`);this.key=X}}var i2=(X)=>{if(!X)return{summary:void 0};let{message:Z,path:Y,value:$,type:W}=X,J=Y.slice(1).replaceAll("/","."),z=Y==="";switch(W){case 42:return{...X,summary:z?"Value should not be provided":`Property '${J}' should not be provided`};case 45:return{...X,summary:z?"Value is missing":`Property '${J}' is missing`};case 50:let Q=Z.indexOf("'"),M=Z.slice(Q+1,Z.indexOf("'",Q+1));return{...X,summary:z?"Value should be an email":`Property '${J}' should be ${M}`};case 54:return{...X,summary:`${Z.slice(0,9)} property '${J}' to be ${Z.slice(8)} but found: ${$}`};case 62:let G=X.schema.anyOf.map((U)=>`'${U?.format??U.type}'`).join(", ");return{...X,summary:z?`Value should be one of ${G}`:`Property '${J}' should be one of: ${G}`};default:return{summary:Z,...X}}};class Q8 extends Error{type;validator;value;code="VALIDATION";status=422;constructor(X,Z,Y){if(Y&&typeof Y==="object"&&Y instanceof o2)Y=Y.response;let $=PY?void 0:("Errors"in Z)?Z.Errors(Y).First():e.Errors(Z,Y).First(),W=$?.schema?.message||$?.schema?.error!==void 0?typeof $.schema.error==="function"?$.schema.error({type:X,validator:Z,value:Y,get errors(){return[...Z.Errors(Y)].map(i2)}}):$.schema.error:void 0,J=$?.path||"root",z="";if(W!==void 0)z=typeof W==="object"?JSON.stringify(W):W+"";else if(PY)z=JSON.stringify({type:"validation",on:X,summary:i2($).summary,message:$?.message,found:Y});else{let Q=Z?.schema??Z,M="Errors"in Z?[...Z.Errors(Y)].map(i2):[...e.Errors(Z,Y)].map(i2),G;try{G=e.Create(Q)}catch(U){G={type:"Could not create expected value",message:U?.message,error:U}}z=JSON.stringify({type:"validation",on:X,summary:i2($).summary,property:J,message:$?.message,expected:G,found:Y,errors:M},null,2)}super(z);this.type=X,this.validator=Z,this.value=Y,Object.setPrototypeOf(this,Q8.prototype)}get all(){return"Errors"in this.validator?[...this.validator.Errors(this.value)].map(i2):[...e.Errors(this.validator,this.value)].map(i2)}static simplifyModel(X){let Z="schema"in X?X.schema:X;try{return e.Create(Z)}catch{return Z}}get model(){return Q8.simplifyModel(this.validator)}toResponse(X){return new Response(this.message,{status:400,headers:{...X,"content-type":"application/json"}})}}var P5=/(\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))/,I5=/(?: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\([^)]+\)/,x5=/^(?:(?:(?:(?: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)?)?$/,qN=G6.date,KN=G6["date-time"];if(!C8.Has("date"))C8.Set("date",(X)=>{let Z=X.replace(/"/g,"");if(P5.test(Z)||I5.test(Z)||x5.test(Z)||qN(Z)){let Y=new Date(Z);if(!Number.isNaN(Y.getTime()))return!0}return!1});if(!C8.Has("date-time"))C8.Set("date-time",(X)=>{let Z=X.replace(/"/g,"");if(P5.test(Z)||I5.test(Z)||x5.test(Z)||KN(Z)){let Y=new Date(Z);if(!Number.isNaN(Y.getTime()))return!0}return!1});Object.entries(G6).forEach((X)=>{let[Z,Y]=X;if(!C8.Has(Z)){if(Y instanceof RegExp)C8.Set(Z,($)=>Y.test($));else if(typeof Y==="function")C8.Set(Z,Y)}});var _=Object.assign({},f8),A5=(X)=>{if(typeof X==="string")switch(X.slice(-1)){case"k":return+X.slice(0,X.length-1)*1024;case"m":return+X.slice(0,X.length-1)*1048576;default:return+X}return X},_5=(X,Z)=>{if(X.startsWith(Z))return!0;return Z.charCodeAt(Z.length-1)===42&&Z.charCodeAt(Z.length-2)===47&&X.startsWith(Z.slice(0,-1))},Q6=(X,Z)=>{if(!(Z instanceof Blob))return!1;if(X.minSize&&Z.sizeA5(X.maxSize))return!1;if(X.extension){if(typeof X.extension==="string")return _5(Z.type,X.extension);for(let Y=0;Y{if(!Array.isArray(Z))return Q6(X,Z);if(X.minItems&&Z.lengthX.maxItems)return!1;for(let Y=0;Y!!X&&!isNaN(+X));if(!C8.Has("integer"))C8.Set("integer",(X)=>!!X&&Number.isInteger(+X));if(!C8.Has("boolean"))C8.Set("boolean",(X)=>X==="true"||X==="false");if(!C8.Has("ObjectString"))C8.Set("ObjectString",(X)=>{let Z=X.charCodeAt(0);if(Z===9||Z===10||Z===32)Z=X.trimStart().charCodeAt(0);if(Z!==123&&Z!==91)return!1;try{return JSON.parse(X),!0}catch{return!1}});if(!C8.Has("ArrayString"))C8.Set("ArrayString",(X)=>{let Z=X.charCodeAt(0);if(Z===9||Z===10||Z===32)Z=X.trimStart().charCodeAt(0);if(Z!==123&&Z!==91)return!1;try{return JSON.parse(X),!0}catch{return!1}});if(!t8.Has("UnionEnum"))t8.Set("UnionEnum",(X,Z)=>{return(typeof Z==="number"||typeof Z==="string"||Z===null)&&X.enum.includes(Z)});var B2={Numeric:(X)=>{let Z=f8.Number(X);return _.Transform(_.Union([_.String({format:"numeric",default:0}),_.Number(X)],X)).Decode((Y)=>{let $=+Y;if(isNaN($))return Y;if(X&&!e.Check(Z,$))throw new Q8("property",Z,$);return $}).Encode((Y)=>Y)},Integer:(X)=>{let Z=f8.Integer(X);return _.Transform(_.Union([_.String({format:"integer",default:0}),f8.Integer(X)],X)).Decode((Y)=>{let $=+Y;if(!e.Check(Z,$))throw new Q8("property",Z,$);return $}).Encode((Y)=>Y)},Date:(X)=>{let Z=f8.Date(X),Y=X?.default?new Date(X.default):void 0;return _.Transform(_.Union([f8.Date(X),_.String({format:"date",default:Y?.toISOString()}),_.String({format:"date-time",default:Y?.toISOString()}),_.Number({default:Y?.getTime()})],X)).Decode(($)=>{if(typeof $==="number"){let J=new Date($);if(!e.Check(Z,J))throw new Q8("property",Z,J);return J}if($ instanceof Date)return $;let W=new Date($);if(!W||isNaN(W.getTime()))throw new Q8("property",Z,W);if(!e.Check(Z,W))throw new Q8("property",Z,W);return W}).Encode(($)=>$.toISOString())},BooleanString:(X)=>{let Z=f8.Boolean(X);return _.Transform(_.Union([_.Boolean(X),_.String({format:"boolean",default:!1})],X)).Decode((Y)=>{if(typeof Y==="string")return Y==="true";if(Y!==void 0&&!e.Check(Z,Y))throw new Q8("property",Z,Y);return Y}).Encode((Y)=>Y)},ObjectString:(X,Z)=>{let Y=_.Object(X,Z),$=JSON.stringify(e.Create(Y)),W;try{W=vX.Compile(Y)}catch{}return _.Transform(_.Union([_.String({format:"ObjectString",default:$}),Y])).Decode((J)=>{if(typeof J==="string"){if(J.charCodeAt(0)!==123)throw new Q8("property",Y,J);try{J=JSON.parse(J)}catch{throw new Q8("property",Y,J)}if(W){if(!W.Check(J))throw new Q8("property",Y,J);return W.Decode(J)}if(!e.Check(Y,J))throw new Q8("property",Y,J);return e.Decode(Y,J)}return J}).Encode((J)=>{if(typeof J==="string")try{J=JSON.parse(J)}catch{throw new Q8("property",Y,J)}if(!e.Check(Y,J))throw new Q8("property",Y,J);return JSON.stringify(J)})},ArrayString:(X=_.String(),Z)=>{let Y=_.Array(X,Z),$;try{$=vX.Compile(Y)}catch{}let W=(J,z=!1)=>{if(J.charCodeAt(0)===91){try{J=JSON.parse(J)}catch{throw new Q8("property",Y,J)}if($){if(!$.Check(J))throw new Q8("property",Y,J);return $.Decode(J)}if(!e.Check(Y,J))throw new Q8("property",Y,J);return e.Decode(Y,J)}if(J.indexOf(",")!==-1){let Q=J.split(",").map((M)=>M.trim());if($){if(!$.Check(Q))throw new Q8("property",Y,J);return $.Decode(Q)}if(!e.Check(Y,Q))throw new Q8("property",Y,Q);return e.Decode(Y,Q)}if(z)return J;throw new Q8("property",Y,J)};return _.Transform(_.Union([_.String({format:"ArrayString",default:Z?.default}),Y])).Decode((J)=>{if(Array.isArray(J)){let z=[];for(let Q=0;Q{if(typeof J==="string")try{J=JSON.parse(J)}catch{throw new Q8("property",Y,J)}if(!e.Check(Y,J))throw new Q8("property",Y,J);return JSON.stringify(J)})},File:RN,Files:(X={})=>_.Transform(jN(X)).Decode((Z)=>{if(Array.isArray(Z))return Z;return[Z]}).Encode((Z)=>Z),Nullable:(X,Z)=>_.Union([X,_.Null()],Z),MaybeEmpty:(X,Z)=>_.Union([X,_.Null(),_.Undefined()],Z),Cookie:(X,{domain:Z,expires:Y,httpOnly:$,maxAge:W,path:J,priority:z,sameSite:Q,secure:M,secrets:G,sign:U,...w}={})=>{let B=_.Object(X,w);return B.config={domain:Z,expires:Y,httpOnly:$,maxAge:W,path:J,priority:z,sameSite:Q,secure:M,secrets:G,sign:U},B},UnionEnum:(X,Z={})=>{let Y=X.every(($)=>typeof $==="string")?{type:"string"}:X.every(($)=>typeof $==="number")?{type:"number"}:X.every(($)=>$===null)?{type:"null"}:{};if(X.some(($)=>typeof $==="object"&&$!==null))throw new Error("This type does not support objects or arrays");return{default:X[0],...Z,[q]:"UnionEnum",...Y,enum:X}}};_.BooleanString=B2.BooleanString;_.ObjectString=B2.ObjectString;_.ArrayString=B2.ArrayString;_.Numeric=B2.Numeric;_.Integer=B2.Integer;_.File=(X={})=>B2.File({default:"File",...X,extension:X?.type,type:"string",format:"binary"});_.Files=(X={})=>B2.Files({...X,elysiaMeta:"Files",default:"Files",extension:X?.type,type:"array",items:{...X,default:"Files",type:"string",format:"binary"}});_.Nullable=(X)=>B2.Nullable(X);_.MaybeEmpty=B2.MaybeEmpty;_.Cookie=B2.Cookie;_.Date=B2.Date;_.UnionEnum=B2.UnionEnum;function T5(X,Z){if(!t8.Has(X))t8.Set(X,Z);return(Y={})=>HY({...Y,[q]:X})}var jZ=(X)=>{let Z=typeof X==="object"?X.fn.toString():typeof X==="string"?X.toString():X,Y=Z.indexOf(")");if(Z.charCodeAt(Y+2)===61&&Z.charCodeAt(Y+5)!==123)return!0;return Z.includes("return")},SN=(X)=>{if(X.startsWith("async"))X=X.slice(5);X=X.trimStart();let Z=-1;if(X.charCodeAt(0)===40){if(Z=X.indexOf("=>",X.indexOf(")")),Z!==-1){let W=Z;while(W>0)if(X.charCodeAt(--W)===41)break;let J=X.slice(Z+2);if(J.charCodeAt(0)===32)J=J.trimStart();return[X.slice(1,W),J,{isArrowReturn:J.charCodeAt(0)!==123}]}}if(/^(\w+)=>/g.test(X)){if(Z=X.indexOf("=>"),Z!==-1){let W=X.slice(Z+2);if(W.charCodeAt(0)===32)W=W.trimStart();return[X.slice(0,Z),W,{isArrowReturn:W.charCodeAt(0)!==123}]}}if(X.startsWith("function")){Z=X.indexOf("(");let W=X.indexOf(")");return[X.slice(Z+1,W),X.slice(W+2),{isArrowReturn:!1}]}let Y=X.indexOf("(");if(Y!==-1){let W=X.indexOf(` -`,2),J=X.slice(0,W),z=J.lastIndexOf(")")+1,Q=X.slice(W+1);return[J.slice(Y,z),"{"+Q,{isArrowReturn:!1}]}let $=X.split(` -`,2);return[$[0],$[1],{isArrowReturn:!1}]},VN=(X)=>{let Z=X.indexOf("{");if(Z===-1)return[-1,0];let Y=Z+1,$=1;for(;Y{let Z=X.lastIndexOf("}");if(Z===-1)return[-1,0];let Y=Z-1,$=1;for(;Y>=0;Y--){let W=X.charCodeAt(Y);if(W===125)$++;else if(W===123)$--;if($===0)break}if($!==0)return[-1,0];return[Y,Z+1]},b5=(X)=>{while(!0){let Z=X.indexOf(":");if(Z===-1)break;let Y=X.indexOf(",",Z);if(Y===-1)Y=X.indexOf("}",Z)-1;if(Y===-2)Y=X.length;X=X.slice(0,Z)+X.slice(Y)}return X},k5=(X)=>{let Z=!1;if(X.charCodeAt(0)===40)X=X.slice(1,-1);if(X.charCodeAt(0)===123)Z=!0,X=X.slice(1,-1);X=X.replace(/( |\t|\n)/g,"").trim();let Y=[];while(!0){let[W,J]=VN(X);if(W===-1)break;if(Y.push(X.slice(0,W-1)),X.charCodeAt(J)===44)J++;X=X.slice(J)}if(X=b5(X),X)Y=Y.concat(X.split(","));let $=[];for(let W of Y){if(W.indexOf(",")===-1){$.push(W);continue}for(let J of W.split(","))$.push(J.trim())}return Y=$,{hasParenthesis:Z,parameters:Y}},CN=(X,Z)=>{let{parameters:Y,hasParenthesis:$}=k5(X);if(!Z.query&&Y.includes("query"))Z.query=!0;if(!Z.headers&&Y.includes("headers"))Z.headers=!0;if(!Z.body&&Y.includes("body"))Z.body=!0;if(!Z.cookie&&Y.includes("cookie"))Z.cookie=!0;if(!Z.set&&Y.includes("set"))Z.set=!0;if(!Z.server&&Y.includes("server"))Z.server=!0;if(!Z.request&&Y.includes("request"))Z.request=!0;if(!Z.route&&Y.includes("route"))Z.route=!0;if($)return`{ ${Y.join(", ")} }`;return Y.join(", ")},w5=(X,Z,Y)=>{let $=Z.indexOf(X+` -`,Y),W=Z.indexOf(X+"\t",Y),J=Z.indexOf(X+",",Y),z=Z.indexOf(X+";",Y),Q=Z.indexOf(X+" ",Y);return[$,W,J,z,Q].filter((M)=>M>0).sort((M,G)=>M-G)[0]||-1},g5=(X,Z,Y=0)=>{if(Y>5)return[];let $=[],W=Z;while(!0){let J=w5(" = "+X,W);if(J===-1)J=w5("="+X,W);if(J===-1){let G=W.indexOf(" = "+X);if(G===-1)G=W.indexOf("="+X);if(G+3+X.length!==W.length)break;J=G}let z=W.slice(0,J),Q=z.lastIndexOf(" "),M=z.slice(Q!==-1?Q+1:-1);if(M==="}"){let[G,U]=EN(z);$.push(b5(W.slice(G,U))),W=W.slice(J+3+X.length);continue}while(M.charCodeAt(0)===44)M=M.slice(1);while(M.charCodeAt(0)===9)M=M.slice(1);if(!M.includes("("))$.push(M);W=W.slice(J+3+X.length)}for(let J of $){if(J.charCodeAt(0)===123)continue;let z=g5(J,Z);if(z.length>0)$.push(...z)}return $},PN=(X)=>{if(!X)return;if(X.charCodeAt(0)!==123)return X;if(X=X.slice(2,-2),!X.includes(",")){if(X.includes("..."))return X.slice(X.indexOf("...")+3);return}let Z=X.indexOf("...");if(Z===-1)return;return X.slice(Z+3).trimEnd()},IN=(X,Z,Y)=>{let $=(W,J)=>X.includes(J+"."+W)||X.includes(J+'["'+W+'"]')||X.includes(J+"['"+W+"']");for(let W of Z){if(!W)continue;if(W.charCodeAt(0)===123){let J=k5(W).parameters;if(!Y.query&&J.includes("query"))Y.query=!0;if(!Y.headers&&J.includes("headers"))Y.headers=!0;if(!Y.body&&J.includes("body"))Y.body=!0;if(!Y.cookie&&J.includes("cookie"))Y.cookie=!0;if(!Y.set&&J.includes("set"))Y.set=!0;if(!Y.query&&J.includes("server"))Y.server=!0;if(!Y.request&&J.includes("request"))Y.request=!0;if(!Y.route&&J.includes("route"))Y.route=!0;continue}if(!Y.query&&$("query",W))Y.query=!0;if(X.includes("return "+W)||X.includes("return "+W+".query"))Y.query=!0;if(!Y.headers&&$("headers",W))Y.headers=!0;if(!Y.body&&$("body",W))Y.body=!0;if(!Y.cookie&&$("cookie",W))Y.cookie=!0;if(!Y.set&&$("set",W))Y.set=!0;if(!Y.server&&$("server",W))Y.server=!0;if(Y.query&&Y.headers&&Y.body&&Y.cookie&&Y.set&&Y.server&&Y.server&&Y.route)break}return Z},xN=(X,Z,Y)=>{try{let $=new RegExp(`(?:\\w)\\((?:.*)?${X}`,"gs");$.test(Z);let W=Z.charCodeAt($.lastIndex);if(W===41||W===44)return Y.query=!0,Y.headers=!0,Y.body=!0,Y.cookie=!0,Y.set=!0,Y.server=!0,Y.route=!0,Y.request=!0,!0;return!1}catch($){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(X),!0}},f5=(X,Z={query:!1,headers:!1,body:!1,cookie:!1,set:!1,server:!1,request:!1,route:!1})=>{let Y=[];if(X.handler&&typeof X.handler==="function")Y.push(X.handler);if(X.request?.length)Y.push(...X.request);if(X.beforeHandle?.length)Y.push(...X.beforeHandle);if(X.parse?.length)Y.push(...X.parse);if(X.error?.length)Y.push(...X.error);if(X.transform?.length)Y.push(...X.transform);if(X.afterHandle?.length)Y.push(...X.afterHandle);if(X.mapResponse?.length)Y.push(...X.mapResponse);if(X.afterResponse?.length)Y.push(...X.afterResponse);for(let $ of Y){if(!$)continue;let W="fn"in $?$.fn:$;if(typeof W!=="function")continue;let[J,z,{isArrowReturn:Q}]=SN(W.toString()),M=CN(J,Z),G=PN(M);if(G){let U=g5(G,z.slice(1,-1));U.splice(0,-1,G);let w=z;if(w.charCodeAt(0)===123&&w.charCodeAt(z.length-1)===125)w=w.slice(1,-1);if(!xN(G,w,Z))IN(w,U,Z);if(!Z.query&&w.includes("return "+G+".query"))Z.query=!0}if(Z.query&&Z.headers&&Z.body&&Z.cookie&&Z.set&&Z.server&&Z.request&&Z.route)break}return Z},U1=[];for(let X=48;X<58;X++)U1[X]=X-48;for(let X=0;X<6;X++)U1[X+65]=U1[X+97]=X+10;var TN=(X,Z)=>{if(X in U1&&Z in U1)return U1[X]<<4|U1[Z];return 255},v5=[...new Array(128).fill(0),...new Array(16).fill(1),...new Array(16).fill(2),...new Array(32).fill(3),4,4,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,6,7,7,7,7,7,7,7,7,7,7,7,7,8,7,7,10,9,9,9,11,4,4,4,4,4,4,4,4,4,4,4],bN=[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],O5=v5.map((X)=>[127,63,63,63,0,31,15,15,15,7,7,7][X]),hX=(X)=>{let Z=X.indexOf("%");if(Z===-1)return X;let Y=X.length-3;if(Z>Y)return null;let $="",W=0,J=0,z=Z,Q=12,M;for(;;){if(M=TN(X.charCodeAt(Z+1),X.charCodeAt(Z+2)),Q=bN[Q+v5[M]],Q===0)return null;if(Q===12){if($+=X.substring(W,z),J=J<<6|M&O5[M],J>65535)$+=String.fromCharCode(55232+(J>>10),56320+(J&1023));else $+=String.fromCharCode(J);if(W=Z+3,Z=X.indexOf("%",W),Z===-1)return $+X.substring(W);if(Z>Y)return null;z=Z,J=0}else{if(Z+=3,Z>Y||X.charCodeAt(Z)!==37)return null;J=J<<6|M&O5[M]}}};class o1{name;jar;initial;constructor(X,Z,Y={}){this.name=X,this.jar=Z,this.initial=Y}get cookie(){return this.jar[this.name]??this.initial}set cookie(X){if(!(this.name in this.jar))this.jar[this.name]=this.initial;this.jar[this.name]=X}get setCookie(){if(!(this.name in this.jar))this.jar[this.name]=this.initial;return this.jar[this.name]}set setCookie(X){this.cookie=X}get value(){return this.cookie.value}set value(X){this.setCookie.value=X}get expires(){return this.cookie.expires}set expires(X){this.setCookie.expires=X}get maxAge(){return this.cookie.maxAge}set maxAge(X){this.setCookie.maxAge=X}get domain(){return this.cookie.domain}set domain(X){this.setCookie.domain=X}get path(){return this.cookie.path}set path(X){this.setCookie.path=X}get secure(){return this.cookie.secure}set secure(X){this.setCookie.secure=X}get httpOnly(){return this.cookie.httpOnly}set httpOnly(X){this.setCookie.httpOnly=X}get sameSite(){return this.cookie.sameSite}set sameSite(X){this.setCookie.sameSite=X}get priority(){return this.cookie.priority}set priority(X){this.setCookie.priority=X}get partitioned(){return this.cookie.partitioned}set partitioned(X){this.setCookie.partitioned=X}get secrets(){return this.cookie.secrets}set secrets(X){this.setCookie.secrets=X}update(X){return this.setCookie=Object.assign(this.cookie,typeof X==="function"?X(this.cookie):X),this}set(X){return this.setCookie=Object.assign({...this.initial,value:this.value},typeof X==="function"?X(this.cookie):X),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 N5=(X,Z,Y)=>{if(!X.cookie)X.cookie={};return new Proxy(Z,{get($,W){if(W in Z)return new o1(W,X.cookie,Object.assign({},Y??{},Z[W]));return new o1(W,X.cookie,Object.assign({},Y))}})},y5=async(X,Z,{secrets:Y,sign:$,...W}={})=>{if(!Z)return N5(X,{},W);let J=typeof Y==="string";if($&&$!==!0&&!Array.isArray($))$=[$];let z={},Q=bY.parse(Z);for(let[M,G]of Object.entries(Q)){if(G===void 0)continue;let U=hX(G);if($===!0||$?.includes(M)){if(!Y)throw new Error("No secret is provided to cookie plugin");if(J){let w=await M5(U,Y);if(w===!1)throw new z6(M);U=w}else{let w=!0;for(let B=0;B{if(!X||!F2(X))return;let Z=[];for(let[Y,$]of Object.entries(X)){if(!Y||!$)continue;let W=$.value;if(W===void 0||W===null)continue;Z.push(bY.serialize(Y,typeof W==="object"?JSON.stringify(W):W+"",$))}if(Z.length===0)return;if(Z.length===1)return Z[0];return Z},mX=(X,Z)=>{let Y=X.size;if(!Z&&Y||Y&&Z&&Z.status!==206&&Z.status!==304&&Z.status!==412&&Z.status!==416){if(Z){if(Z.headers instanceof Headers){let $={"accept-ranges":"bytes","content-range":`bytes 0-${Y-1}/${Y}`,"transfer-encoding":"chunked"};if(VY)$=Z.headers.toJSON();else{$={};for(let[W,J]of Z.headers.entries())if(W in Z.headers)$[W]=J}return new Response(X,{status:Z.status,headers:$})}if(F2(Z.headers))return new Response(X,{status:Z.status,headers:Object.assign({"accept-ranges":"bytes","content-range":`bytes 0-${Y-1}/${Y}`,"transfer-encoding":"chunked"},Z.headers)})}return new Response(X,{headers:{"accept-ranges":"bytes","content-range":`bytes 0-${Y-1}/${Y}`,"transfer-encoding":"chunked"}})}return new Response(X)},h5=(X,Z)=>{if(!X)return X;X.delete("set-cookie");for(let Y=0;Y{if(Z?.headers){if(X){if(VY)Object.assign(Z.headers,X.headers.toJSON());else for(let[Y,$]of X.headers.entries())if(Y in Z.headers)Z.headers[Y]=$}if(Z.status===200)Z.status=X.status;if(Z.headers["content-encoding"])delete Z.headers["content-encoding"];return Z}if(!X)return{headers:{},status:Z?.status??200};if(VY){if(Z={headers:X.headers.toJSON(),status:Z?.status??200},Z.headers["content-encoding"])delete Z.headers["content-encoding"];return Z}Z={headers:{},status:Z?.status??200};for(let[Y,$]of X.headers.entries()){if(Y==="content-encoding")continue;if(Y in Z.headers)Z.headers[Y]=$}return Z},L2=async(X,Z,Y)=>{let $=X.next();if($ instanceof Promise)$=await $;if($.done){if(Z)return i0($.value,Z,Y);return pX($.value,Y)}if(Z?.headers){if(!Z.headers["transfer-encoding"])Z.headers["transfer-encoding"]="chunked";if(!Z.headers["content-type"])Z.headers["content-type"]="text/event-stream; charset=utf-8"}else Z={status:200,headers:{"content-type":"text/event-stream; charset=utf-8","transfer-encoding":"chunked"}};return new Response(new ReadableStream({async start(W){let J=!1;if(Y?.signal?.addEventListener("abort",()=>{J=!0;try{W.close()}catch{}}),$.value!==void 0&&$.value!==null)if(typeof $.value==="object")try{W.enqueue(Buffer.from(JSON.stringify($.value)))}catch{W.enqueue(Buffer.from($.value.toString()))}else W.enqueue(Buffer.from($.value.toString()));for await(let z of X){if(J)break;if(z===void 0||z===null)continue;if(typeof z==="object")try{W.enqueue(Buffer.from(JSON.stringify(z)))}catch{W.enqueue(Buffer.from(z.toString()))}else W.enqueue(Buffer.from(z.toString()));await new Promise((Q)=>setTimeout(()=>Q(),0))}try{W.close()}catch{}}}),Z)};async function*D1(X){let Z=X.body;if(!Z)return;let Y=Z.getReader(),$=new TextDecoder;try{while(!0){let{done:W,value:J}=await Y.read();if(W)break;yield $.decode(J)}}finally{Y.releaseLock()}}var m5=(X)=>{if(typeof X.status==="string")X.status=xY[X.status];if(X.cookie&&F2(X.cookie)){let Z=d5(X.cookie);if(Z)X.headers["set-cookie"]=Z}if(X.headers["set-cookie"]&&Array.isArray(X.headers["set-cookie"]))X.headers=h5(new Headers(X.headers),X.headers["set-cookie"])},IY=(X,Z)=>{if(X.status!==Z.status&&Z.status!==200&&(X.status<=300||X.status>400))X=new Response(X.body,{headers:X.headers,status:Z.status});let Y=!1;if(Z.headers instanceof Headers)for(let $ of Z.headers.keys())if($==="set-cookie"){if(Y)continue;Y=!0;for(let W of Z.headers.getSetCookie())X.headers.append("set-cookie",W)}else X.headers.append($,Z.headers?.get($)??"");else for(let $ in Z.headers)X.headers.append($,Z.headers[$]);return X},i0=(X,Z,Y)=>{if(F2(Z.headers)||Z.status!==200||Z.cookie)switch(m5(Z),X?.constructor?.name){case"String":return new Response(X,Z);case"Array":case"Object":return Response.json(X,Z);case"ElysiaFile":return mX(X.value);case"Blob":return mX(X,Z);case"ElysiaCustomStatusResponse":return Z.status=X.code,i0(X.response,Z,Y);case"ReadableStream":if(!Z.headers["content-type"]?.startsWith("text/event-stream"))Z.headers["content-type"]="text/event-stream; charset=utf-8";return Y?.signal?.addEventListener("abort",{handleEvent(){if(Y?.signal&&!Y?.signal?.aborted)X.cancel()}},{once:!0}),new Response(X,Z);case void 0:if(!X)return new Response("",Z);return Response.json(X,Z);case"Response":if(X=IY(X,Z),!X.headers.has("content-length")&&X.headers.get("transfer-encoding")==="chunked")return L2(D1(X),H1(X,Z),Y);return X;case"Error":return cX(X,Z);case"Promise":return X.then(($)=>i0($,Z,Y));case"Function":return i0(X(),Z,Y);case"Number":case"Boolean":return new Response(X.toString(),Z);case"Cookie":if(X instanceof o1)return new Response(X.value,Z);return new Response(X?.toString(),Z);case"FormData":return new Response(X,Z);default:if(X instanceof Response){if(X=IY(X,Z),X.headers.get("transfer-encoding")==="chunked")return L2(D1(X),H1(X,Z),Y);return X}if(X instanceof Promise)return X.then(($)=>i0($,Z));if(X instanceof Error)return cX(X,Z);if(X instanceof o2)return Z.status=X.code,i0(X.response,Z,Y);if(typeof X?.next==="function")return L2(X,Z,Y);if(typeof X?.then==="function")return X.then(($)=>i0($,Z));if(typeof X?.toResponse==="function")return i0(X.toResponse(),Z);if("charCodeAt"in X){let $=X.charCodeAt(0);if($===123||$===91){if(!Z.headers["Content-Type"])Z.headers["Content-Type"]="application/json";return new Response(JSON.stringify(X),Z)}}return new Response(X,Z)}if(X instanceof Response&&!X.headers.has("content-length")&&X.headers.get("transfer-encoding")==="chunked")return L2(D1(X),H1(X,Z),Y);if(typeof X?.next==="function"||X instanceof ReadableStream)return L2(X,Z,Y);return pX(X,Y)},p0=(X,Z,Y)=>{if(X===void 0||X===null)return;if(F2(Z.headers)||Z.status!==200||Z.cookie)switch(m5(Z),X?.constructor?.name){case"String":return new Response(X,Z);case"Array":case"Object":return Response.json(X,Z);case"ElysiaFile":return mX(X.value);case"Blob":return mX(X,Z);case"ElysiaCustomStatusResponse":return Z.status=X.code,p0(X.response,Z,Y);case"ReadableStream":if(!Z.headers["content-type"]?.startsWith("text/event-stream"))Z.headers["content-type"]="text/event-stream; charset=utf-8";return Y?.signal?.addEventListener("abort",{handleEvent(){if(Y?.signal&&!Y?.signal?.aborted)X.cancel()}},{once:!0}),new Response(X,Z);case void 0:if(!X)return;return Response.json(X,Z);case"Response":if(X=IY(X,Z),!X.headers.has("content-length")&&X.headers.get("transfer-encoding")==="chunked")return L2(D1(X),H1(X,Z),Y);return X;case"Promise":return X.then(($)=>p0($,Z));case"Error":return cX(X,Z);case"Function":return p0(X(),Z);case"Number":case"Boolean":return new Response(X.toString(),Z);case"FormData":return new Response(X);case"Cookie":if(X instanceof o1)return new Response(X.value,Z);return new Response(X?.toString(),Z);default:if(X instanceof Response){if(X=IY(X,Z),X.headers.get("transfer-encoding")==="chunked")return L2(D1(X),H1(X,Z),Y);return X}if(X instanceof Promise)return X.then(($)=>p0($,Z));if(X instanceof Error)return cX(X,Z);if(X instanceof o2)return Z.status=X.code,p0(X.response,Z,Y);if(typeof X?.next==="function")return L2(X,Z,Y);if(typeof X?.then==="function")return X.then(($)=>p0($,Z));if(typeof X?.toResponse==="function")return p0(X.toResponse(),Z);if("charCodeAt"in X){let $=X.charCodeAt(0);if($===123||$===91){if(!Z.headers["Content-Type"])Z.headers["Content-Type"]="application/json";return new Response(JSON.stringify(X),Z)}}return new Response(X,Z)}else switch(X?.constructor?.name){case"String":return new Response(X);case"Array":case"Object":return Response.json(X,Z);case"ElysiaFile":return mX(X.value);case"Blob":return mX(X,Z);case"ElysiaCustomStatusResponse":return Z.status=X.code,p0(X.response,Z,Y);case"ReadableStream":return Y?.signal?.addEventListener("abort",{handleEvent(){if(Y?.signal&&!Y?.signal?.aborted)X.cancel()}},{once:!0}),new Response(X,{headers:{"Content-Type":"text/event-stream; charset=utf-8"}});case void 0:if(!X)return new Response("");return new Response(JSON.stringify(X),{headers:{"content-type":"application/json"}});case"Response":if(!X.headers.has("content-length")&&X.headers.get("transfer-encoding")==="chunked")return L2(D1(X),H1(X),Y);return X;case"Promise":return X.then(($)=>{let W=p0($,Z);if(W!==void 0)return W});case"Error":return cX(X,Z);case"Function":return pX(X(),Y);case"Number":case"Boolean":return new Response(X.toString());case"Cookie":if(X instanceof o1)return new Response(X.value,Z);return new Response(X?.toString(),Z);case"FormData":return new Response(X);default:if(X instanceof Response)return X;if(X instanceof Promise)return X.then(($)=>p0($,Z));if(X instanceof Error)return cX(X,Z);if(X instanceof o2)return Z.status=X.code,p0(X.response,Z,Y);if(typeof X?.next==="function")return L2(X,Z,Y);if(typeof X?.then==="function")return X.then(($)=>p0($,Z));if(typeof X?.toResponse==="function")return p0(X.toResponse(),Z);if("charCodeAt"in X){let $=X.charCodeAt(0);if($===123||$===91){if(!Z.headers["Content-Type"])Z.headers["Content-Type"]="application/json";return new Response(JSON.stringify(X),Z)}}return new Response(X)}},pX=(X,Z)=>{switch(X?.constructor?.name){case"String":return new Response(X);case"Object":case"Array":return Response.json(X);case"ElysiaFile":return mX(X.value);case"Blob":return mX(X);case"ElysiaCustomStatusResponse":return i0(X.response,{status:X.code,headers:{}});case"ReadableStream":return Z?.signal?.addEventListener("abort",{handleEvent(){if(Z?.signal&&!Z?.signal?.aborted)X.cancel()}},{once:!0}),new Response(X,{headers:{"Content-Type":"text/event-stream; charset=utf-8"}});case void 0:if(!X)return new Response("");return new Response(JSON.stringify(X),{headers:{"content-type":"application/json"}});case"Response":if(X.headers.get("transfer-encoding")==="chunked")return L2(D1(X),H1(X),Z);return X;case"Error":return cX(X);case"Promise":return X.then((Y)=>pX(Y,Z));case"Function":return pX(X(),Z);case"Number":case"Boolean":return new Response(X.toString());case"FormData":return new Response(X);default:if(X instanceof Response)return X;if(X instanceof Promise)return X.then((Y)=>pX(Y,Z));if(X instanceof Error)return cX(X);if(X instanceof o2)return i0(X.response,{status:X.code,headers:{}});if(typeof X?.next==="function")return L2(X,void 0,Z);if(typeof X?.then==="function")return X.then((Y)=>i0(Y,set));if(typeof X?.toResponse==="function")return pX(X.toResponse());if("charCodeAt"in X){let Y=X.charCodeAt(0);if(Y===123||Y===91)return new Response(JSON.stringify(X),{headers:{"Content-Type":"application/json"}})}return new Response(X)}},cX=(X,Z)=>new Response(JSON.stringify({name:X?.name,message:X?.message,cause:X?.cause}),{status:Z?.status!==200?Z?.status??500:500,headers:Z?.headers}),kN=(X,Z,Y={})=>{if(typeof X==="function")return;let $=i0(X,{headers:Y});if(!Z.parse?.length&&!Z.transform?.length&&!Z.beforeHandle?.length&&!Z.afterHandle?.length)return $.clone.bind($)},jY={name:"web-standard",isWebStandard:!0,handler:{mapResponse:i0,mapEarlyResponse:p0,mapCompactResponse:pX,createStaticHandler:kN},composeHandler:{mapResponseContext:"c.request",preferWebstandardHeaders:!0,headers:`c.headers = {} -for (const [key, value] of c.request.headers.entries())c.headers[key] = value -`,parser:{json(X){if(X)return`try{c.body=await c.request.json()}catch{} -`;return`c.body=await c.request.json() -`},text(){return`c.body=await c.request.text() -`},urlencoded(){return`c.body=parseQuery(await c.request.text()) -`},arrayBuffer(){return`c.body=await c.request.arrayBuffer() -`},formData(X){let Z=` -c.body={} -`;if(X)Z+="let form;try{form=await c.request.formData()}catch{}";else Z+=`const form=await c.request.formData() -`;return Z+`for(const key of form.keys()){if(c.body[key]) continue -const value=form.getAll(key) -if(value.length===1)c.body[key]=value[0] -else c.body[key]=value}`}}},composeGeneralHandler:{parameters:"r",createContext(X){let Z="",Y="",$=X.setHeaders;for(let z of Object.keys(X.singleton.decorator))Z+=`,${z}: decorator['${z}']`;let W=X.config.handler?.standardHostname??!0,J=!!X.event.trace?.length;if(Y+=`const u=r.url,s=u.indexOf('/',${W?11:7}),qi=u.indexOf('?', s + 1) -let p -if(qi===-1)p=u.substring(s) -else p=u.substring(s, qi) -`,J)Y+=`const id=randomId() -`;if(Y+="const c={request:r,store,qi,path:p,url:u,redirect,error,set:{headers:",Y+=Object.keys($??{}).length?"Object.assign({}, app.setHeaders)":"{}",Y+=",status:200}",X.inference.server)Y+=",get server(){return app.getServer()}";if(J)Y+=",[ELYSIA_REQUEST_ID]:id";return Y+=Z,Y+=`} -`,Y},websocket(X){let Z="",Y=X.router.static.ws,$=X.router.http;if($.build(),Object.keys(Y).length||$.root.ws||$.history.find((W)=>W["0"]==="ws")){Z+="if(r.method==='GET'){switch(p){";for(let[W,J]of Object.entries(Y))Z+=`case'${W}':`+(X.config.strictPath!==!0?`case'${c1(W)}':`:"")+`if(r.headers.get('upgrade')==='websocket')return ht[${J}].composed(c) -`;Z+=`default:if(r.headers.get('upgrade')==='websocket'){const route=router.find('ws',p) -if(route){c.params=route.params -if(route.store.handler)return route.store.handler(c) -return (route.store.handler=route.store.compile())(c)}}break}}`}return Z},error404(X,Z){let Y="if(route===null)return ";if(Z)Y+=`app.handleError(c,notFound,false,${this.parameters})`;else Y+=X?"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() -const error404=new Response(error404Message,{status:404}) -`,code:Y}}},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")}}},gN=(X,Z,Y={})=>{if(typeof X==="function"||X instanceof Blob)return;if(typeof X==="object"&&X?.toString()==="[object HTMLBundle]")return()=>X;let $=i0(X,{headers:Y});if(!Z.parse?.length&&!Z.transform?.length&&!Z.beforeHandle?.length&&!Z.afterHandle?.length){if(!$.headers.has("content-type"))$.headers.append("content-type","text/plain;charset=utf-8");return $.clone.bind($)}},L5={open(X){X.data.open?.(X)},message(X,Z){X.data.message?.(X,Z)},drain(X){X.data.drain?.(X)},close(X,Z,Y){X.data.close?.(X,Z,Y)}};class KZ{raw;data;body;validator;["~types"];get id(){return this.data.id}constructor(X,Z,Y=void 0){this.raw=X,this.data=Z,this.body=Y,this.validator=X.data?.validator,this.sendText=X.sendText.bind(X),this.sendBinary=X.sendBinary.bind(X),this.close=X.close.bind(X),this.terminate=X.terminate.bind(X),this.publishText=X.publishText.bind(X),this.publishBinary=X.publishBinary.bind(X),this.subscribe=X.subscribe.bind(X),this.unsubscribe=X.unsubscribe.bind(X),this.isSubscribed=X.isSubscribed.bind(X),this.cork=X.cork.bind(X),this.remoteAddress=X.remoteAddress,this.binaryType=X.binaryType,this.data=X.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(X,Z){if(Buffer.isBuffer(X))return this.raw.send(X,Z);if(this.validator?.Check(X)===!1)return this.raw.send(new Q8("message",this.validator,X).message);if(typeof X==="object")X=JSON.stringify(X);return this.raw.send(X,Z)}ping(X){if(Buffer.isBuffer(X))return this.raw.ping(X);if(this.validator?.Check(X)===!1)return this.raw.send(new Q8("message",this.validator,X).message);if(typeof X==="object")X=JSON.stringify(X);return this.raw.ping(X)}pong(X){if(Buffer.isBuffer(X))return this.raw.pong(X);if(this.validator?.Check(X)===!1)return this.raw.send(new Q8("message",this.validator,X).message);if(typeof X==="object")X=JSON.stringify(X);return this.raw.pong(X)}publish(X,Z,Y){if(Buffer.isBuffer(Z))return this.raw.publish(X,Z,Y);if(this.validator?.Check(Z)===!1)return this.raw.send(new Q8("message",this.validator,Z).message);if(typeof Z==="object")Z=JSON.stringify(Z);return this.raw.publish(X,Z,Y)}sendText;sendBinary;close;terminate;publishText;publishBinary;subscribe;unsubscribe;isSubscribed;cork;remoteAddress;binaryType;get readyState(){return this.raw.readyState}}var fN=(X)=>{let Z=typeof X==="function"?[X]:X;return async function Y($,W){if(typeof W==="string"){let J=W?.charCodeAt(0);if(J===34||J===47||J===91||J===123)try{W=JSON.parse(W)}catch{}else if(M6(W))W=+W;else if(W==="true")W=!0;else if(W==="false")W=!1;else if(W==="null")W=null}if(Z)for(let J=0;J{let Z=(Y,$)=>{if($ instanceof Promise)return $.then((z)=>Z(Y,z));if(Buffer.isBuffer($))return Y.send($.toString());if($===void 0)return;let W=(z)=>{if(X?.Check(z)===!1)return Y.send(new Q8("message",X,z).message);if(typeof z==="object")return Y.send(JSON.stringify(z));Y.send(z)};if(typeof $?.next!=="function")return void W($);let J=$.next();if(J instanceof Promise)return(async()=>{let z=await J;if(X?.Check(z)===!1)return Y.send(new Q8("message",X,z).message);if(W(z.value),!z.done)for await(let Q of $)W(Q)})();if(W(J.value),!J.done)for(let z of $)W(z)};return Z},yN={...jY,name:"bun",handler:{...jY.handler,createNativeStaticHandler:gN},composeHandler:{...jY.composeHandler,headers:VY?`c.headers = c.request.headers.toJSON() -`:`c.headers = {} -for (const [key, value] of c.request.headers.entries())c.headers[key] = value -`},listen(X){return(Z,Y)=>{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(X.compile(),typeof Z==="string"){if(!M6(Z))throw new Error("Port must be a numeric value");Z=parseInt(Z)}let $=X.fetch,W=typeof Z==="object"?{development:!PY,reusePort:!0,...X.config.serve||{},...Z||{},static:{...X.router.static.http.static,...X.config.serve?.static},websocket:{...X.config.websocket||{},...L5||{}},fetch:$,error:X.outerErrorHandler}:{development:!PY,reusePort:!0,...X.config.serve||{},static:X.router.static.http.static,websocket:{...X.config.websocket||{},...L5||{}},port:Z,fetch:$,error:X.outerErrorHandler};if(X.server=Bun?.serve(W),X.event.start)for(let J=0;J{if(X.server){if(X.server.stop?.(),X.server=null,X.event.stop)for(let J=0;J{Bun?.gc(!1)})}},ws(X,Z,Y){let{parse:$,body:W,response:J,...z}=Y,Q=u0(W,{modules:X.definitions.typebox,models:X.definitions.type,normalize:X.config.normalize}),M=u0(J,{modules:X.definitions.typebox,models:X.definitions.type,normalize:X.config.normalize});X.route("$INTERNALWS",Z,async(G)=>{let U=X.getServer(),{set:w,path:B,qi:N,headers:S,query:H,params:E}=G;if(G.validator=M,Y.upgrade){if(typeof Y.upgrade==="function"){let I=Y.upgrade(G);if(I instanceof Promise)await I}else if(Y.upgrade)Object.assign(w.headers,Y.upgrade)}if(w.cookie&&F2(w.cookie)){let I=d5(w.cookie);if(I)w.headers["set-cookie"]=I}if(w.headers["set-cookie"]&&Array.isArray(w.headers["set-cookie"]))w.headers=h5(new Headers(w.headers),w.headers["set-cookie"]);let h=vN(M),Y8=fN($),s,V8=[...Array.isArray(Y.error)?Y.error:[Y.error],...(X.event.error??[]).map((I)=>typeof I==="function"?I:I.fn)],G8=!V8.length?()=>{}:async(I,P)=>{for(let k of V8){let b=k(Object.assign(G,{error:P}));if(b instanceof Promise)b=await b;if(await h(I,b),b)break}};if(U?.upgrade(G.request,{headers:F2(w.headers)?w.headers:void 0,data:{...G,get id(){if(s)return s;return s=V5()},validator:M,ping(I){Y.ping?.(I)},pong(I){Y.pong?.(I)},open(I){try{h(I,Y.open?.(new KZ(I,G)))}catch(P){G8(I,P)}},message:async(I,P)=>{let k=await Y8(I,P);if(Q?.Check(k)===!1)return void I.send(new Q8("message",Q,k).message);try{h(I,Y.message?.(new KZ(I,G,k),k))}catch(b){G8(I,b)}},drain(I){try{h(I,Y.drain?.(new KZ(I,G)))}catch(P){G8(I,P)}},close(I,P,k){try{h(I,Y.close?.(new KZ(I,G),P,k))}catch(b){G8(I,b)}}}}))return;return w.status=400,"Expected a websocket connection"},{...z,websocket:Y})}},dN=typeof Bun!=="undefined",F5=dN?Bun.env:typeof process!=="undefined"&&process?.env?process.env:{},u1=/\+/g;function hN(X){let Z={};if(typeof X!=="string")return Z;let Y="",$="",W=-1,J=-1,z=0,Q=X.length;for(let M=0;MW;if(!G)J=M;if(Y=X.slice(W+1,J),G||Y.length>0){if(z&1)Y=Y.replace(u1," ");if(z&2)Y=hX(Y)||Y;if(!Z[Y]){if(G){if($=X.slice(J+1,M),z&4)$=$.replace(u1," ");if(z&8)$=hX($)||$}Z[Y]=$}}Y="",$="",W=M,J=M,z=0;break;case 61:if(J<=W)J=M;else z|=8;break;case 43:if(J>W)z|=4;else z|=1;break;case 37:if(J>W)z|=8;else z|=2;break}if(WW;if(Y=X.slice(W+1,M?J:Q),M||Y.length>0){if(z&1)Y=Y.replace(u1," ");if(z&2)Y=hX(Y)||Y;if(!Z[Y]){if(M){if($=X.slice(J+1,Q),z&4)$=$.replace(u1," ");if(z&8)$=hX($)||$}Z[Y]=$}}}return Z}var SY=(X)=>{let Z={};if(typeof X!=="string")return Z;let Y=X.length,$="",W="",J=-1,z=-1,Q=!1,M=!1,G=!1,U=!1,w=!1,B=0;for(let N=0;NJ,!w)z=N;if($=X.slice(J+1,z),w||$.length>0){if(G)$=$.replace(u1," ");if(Q)$=hX($)||$;if(w){if(W=X.slice(z+1,N),U)W=W.replace(u1," ");if(M)W=hX(W)||W}let S=Z[$];if(S===void 0)Z[$]=W;else if(S.pop)S.push(W);else Z[$]=[S,W]}W="",J=N,z=N,Q=!1,M=!1,G=!1,U=!1;break}case 61:if(z<=J)z=N;else M=!0;break;case 43:if(z>J)U=!0;else G=!0;break;case 37:if(z>J)M=!0;else Q=!0;break}}return Z},H6=Symbol("ElysiaTrace"),BX=()=>{let{promise:X,resolve:Z}=Promise.withResolvers(),{promise:Y,resolve:$}=Promise.withResolvers(),{promise:W,resolve:J}=Promise.withResolvers(),z=[],Q=[];return[(M)=>{if(M)z.push(M);return X},(M)=>{let G=[],U=[],w=null;for(let N=0;N<(M.total??0);N++){let{promise:S,resolve:H}=Promise.withResolvers(),{promise:E,resolve:h}=Promise.withResolvers(),{promise:Y8,resolve:s}=Promise.withResolvers(),V8=[],G8=[];G.push((I)=>{if(I)V8.push(I);return S}),U.push((I)=>{let P={...I,end:E,error:Y8,index:N,onStop(k){if(k)G8.push(k);return E}};H(P);for(let k=0;k{let b=performance.now();if(k)w=k;let $8={end:b,error:k,get elapsed(){return b-I.begin}};for(let J8=0;J8{return(Z)=>{let[Y,$]=BX(),[W,J]=BX(),[z,Q]=BX(),[M,G]=BX(),[U,w]=BX(),[B,N]=BX(),[S,H]=BX(),[E,h]=BX(),[Y8,s]=BX();return X({id:Z[TY],context:Z,set:Z.set,onRequest:Y,onParse:W,onTransform:z,onBeforeHandle:M,onHandle:U,onAfterHandle:B,onMapResponse:E,onAfterResponse:Y8,onError:S}),{request:$,parse:J,transform:Q,beforeHandle:G,handle:w,afterHandle:N,error:H,mapResponse:h,afterResponse:s}}},A1={optional:Symbol.for("TypeBox.Optional"),kind:Symbol.for("TypeBox.Kind")},u2=(X)=>{if(!X)return!1;let Z=X?.schema;if(Z?.[A1.kind]==="Import")return X.References().some(u2);return!!Z&&A1.optional in Z},B0=(X,Z)=>Z?X:"",pN=["json","text","urlencoded","arrayBuffer","formdata","application/json","text/plain","application/x-www-form-urlencoded","application/octet-stream","multipart/form-data"],N2=(X)=>{if(!X)return!1;let Z=X?.schema??X;if(Z[A1.kind]==="Import"&&X.References())return X.References().some(N2);if(Z.anyOf)return Z.anyOf.some(N2);if(Z.someOf)return Z.someOf.some(N2);if(Z.allOf)return Z.allOf.some(N2);if(Z.not)return Z.not.some(N2);if(Z.type==="object"){let Y=Z.properties;if("additionalProperties"in Z)return Z.additionalProperties;if("patternProperties"in Z)return!1;for(let $ of Object.keys(Y)){let W=Y[$];if(W.type==="object"){if(N2(W))return!0}else if(W.anyOf){for(let J=0;J{if(!Z.length)return()=>{return{resolveChild(){return()=>{}},resolve(){}}};for(let $=0;${if(!W)W="anonymous";let z=$==="error"?"reportErr":"report";for(let Q=0;Q{for(let G=0;G({composeValidation:(W,J=`c.${W}`)=>`c.set.status=422;throw new ValidationError('${W}',validator.${W},${J})`,composeResponseValidation:(W="r")=>{let J=X+` -`;J+=`if(${W} instanceof ElysiaCustomStatusResponse){c.set.status=${W}.code -${W}=${W}.response}const isResponse=${W} instanceof Response -switch(c.set.status){`;for(let[z,Q]of Object.entries(Y.response)){if(J+=` -case ${z}:if(!isResponse){`,Z&&"Clean"in Q&&!N2(Q))J+=`${W}=validator.response['${z}'].Clean(${W}) -`;if($&&(Q.hasTransform||typeof Q.Decode==="function"))J+=`${W}=validator.response['${z}'].Encode(${W}) -`;J+=`if(validator.response['${z}'].Check(${W})===false){c.set.status=422 -throw new ValidationError('response',validator.response['${z}'],${W})}c.set.status = ${z}} -`,J+=`break -`}return J+"}"}}),sx=Symbol.for("TypeBox.Kind"),dX=(X,Z)=>{if(!Z)return;let Y=Z.schema??Z;if(Y[A1.kind]==="Import")return Z.References().some(($)=>dX(X,$));if(Y.type==="object"){let $=Y.properties;if(!$)return!1;for(let W of Object.keys($)){let J=$[W];if(X in J)return!0;if(J.type==="object"){if(dX(X,J))return!0}else if(J.anyOf){for(let z=0;z{if(!X)return!1;if(X.$ref&&X.$defs&&X.$ref in X.$defs&&W2(X.$defs[X.$ref]))return!0;if(X.oneOf){for(let Z=0;Z) \S+\(/g,i1=(X)=>{return(X?.fn??X).constructor.name==="AsyncFunction"},G0=(X)=>{let Z=X?.fn??X;if(Z.constructor.name==="AsyncFunction")return!0;let Y=Z.toString();if(Y.includes("=> response.clone("))return!1;if(Y.includes("await"))return!0;if(Y.includes("async"))return!0;if(Y.includes("=>response.clone("))return!1;return!!Y.match(iN)},RY=(X)=>{let Z=X?.fn??X;return Z.constructor.name==="AsyncGeneratorFunction"||Z.constructor.name==="GeneratorFunction"},oN=({app:X,path:Z,method:Y,hooks:$,validator:W,handler:J,allowMeta:z=!1,inference:Q,asManifest:M=!1})=>{let G=X["~adapter"].composeHandler,U=X["~adapter"].handler,w=typeof J==="function";if(!w){if(J=U.mapResponse(J,{headers:X.setHeaders??{}}),$.parse?.length&&$.transform?.length&&$.beforeHandle?.length&&$.afterHandle?.length){if(J instanceof Response)return Function("a","return function(){return a.clone()}")(J);return Function("a","return function(){return a}")(J)}}let B=w?"handler(c)":"handler",N=!!$.afterResponse?.length,S=!!$.trace?.length,H="";if(Q=f5(Object.assign({},$,{handler:J}),Q),G.declare){let g=G.declare(Q);if(g)H+=g}if(Q.server)H+=`Object.defineProperty(c,'server',{get:function(){return getServer()}}) -`;W.createBody?.(),W.createQuery?.(),W.createHeaders?.(),W.createParams?.(),W.createCookie?.(),W.createResponse?.();let E=W.body||W.headers||W.params||W.query||W.cookie||W.response,h=Q.query||!!W.query,Y8=$.parse?.length===1&&$.parse[0].fn==="none",s=Y!=="$INTERNALWS"&&Y!=="GET"&&Y!=="HEAD"&&(Q.body||!!W.body||!!$.parse?.length)&&!Y8;if(s)H+=`let isParsing=false -`;let V8=X.setHeaders,G8=V8&&!!Object.keys(V8).length,I=Q.headers||W.headers||G.preferWebstandardHeaders!==!0&&Q.body,P=Q.cookie||!!W.cookie,k=P?R5({modules:X.definitions.typebox,validator:W.cookie,defaultConfig:X.config.cookie,dynamic:!!X.config.aot,config:W.cookie?.config??{},models:X.definitions.type}):void 0,b=k?.config,$8="";if(b?.sign){if(!b.secrets)throw new Error(`t.Cookie required secret which is not set in (${Y}) ${Z}.`);let g=!b.secrets?void 0:typeof b.secrets==="string"?b.secrets:b.secrets[0];if($8+=`const _setCookie = c.set.cookie -if(_setCookie){`,b.sign===!0)$8+=`for(const [key, cookie] of Object.entries(_setCookie)){c.set.cookie[key].value=await signCookie(cookie.value,'${g}')}`;else for(let C of b.sign)$8+=`if(_setCookie['${C}']?.value){c.set.cookie['${C}'].value=await signCookie(_setCookie['${C}'].value,'${g}')}`;$8+=`} -`}let J8=X.config.normalize,X8=X.config.experimental?.encodeSchema,{composeValidation:U8,composeResponseValidation:H0}=cN({normalize:J8,validator:W,encodeSchema:X8});if(I)H+=G.headers;if(S)H+=`const id=c[ELYSIA_REQUEST_ID] -`;let d8=D6({trace:$.trace,addFn:(g)=>{H+=g}});if(H+="try{",P){let g=(x,u)=>{let r=b?.[x]??u;if(!r)return typeof u==="string"?`${x}:"${u}",`:`${x}:${u},`;if(typeof r==="string")return`${x}:'${r}',`;if(r instanceof Date)return`${x}: new Date(${r.getTime()}),`;return`${x}:${r},`},C=b?`{secrets:${b.secrets!==void 0?typeof b.secrets==="string"?`'${b.secrets}'`:"["+b.secrets.reduce((x,u)=>x+`'${u}',`,"")+"]":"undefined"},sign:${b.sign===!0?!0:b.sign!==void 0?"["+b.sign.reduce((x,u)=>x+`'${u}',`,"")+"]":"undefined"},`+g("domain")+g("expires")+g("httpOnly")+g("maxAge")+g("path","/")+g("priority")+g("sameSite")+g("secure")+"}":"undefined";if(I)H+=` -c.cookie=await parseCookie(c.set,c.headers.cookie,${C}) -`;else H+=` -c.cookie=await parseCookie(c.set,c.request.headers.get('cookie'),${C}) -`}if(h){let g=[];if(W.query&&W.query.schema.type==="object"){let C=W.query.schema.properties;if(!N2(W.query))for(let[x,u]of Object.entries(C)){let r=u,D=r.type==="array"||!!r.anyOf?.some((p)=>p.type==="string"&&p.format==="ArrayString");if(r&&A1.optional in r&&r.type==="array"&&r.items)r=r.items;let{type:T,anyOf:F}=r;g.push({key:x,isArray:D,isNestedObjectArray:D&&r.items?.type==="object"||!!r.items?.anyOf?.some((p)=>p.type==="object"||p.type==="array"),isObject:T==="object"||F?.some((p)=>p.type==="string"&&p.format==="ArrayString"),anyOf:!!F})}}if(!g.length)H+="if(c.qi===-1){c.query={}}else{c.query=parseQueryFromURL(c.url.slice(c.qi + 1))}";else{H+=`if(c.qi!==-1){let url='&'+c.url.slice(c.qi + 1) -`;let C=0;for(let{key:x,isArray:u,isObject:r,isNestedObjectArray:D,anyOf:T}of g){let F=(C===0?"let ":"")+`memory=url.indexOf('&${x}=') -let a${C} -`;if(u)if(H+=F,D)H+=`while(memory!==-1){const start=memory+${x.length+2} -memory=url.indexOf('&',start) -if(a${C}===undefined) -a${C}='' -else -a${C}+=',' -let temp -if(memory===-1)temp=decodeURIComponent(url.slice(start).replace(/\\+/g,' ')) -else temp=decodeURIComponent(url.slice(start, memory).replace(/\\+/g,' ')) -const charCode=temp.charCodeAt(0) -if(charCode!==91&&charCode !== 123) -temp='"'+temp+'"' -a${C}+=temp -if(memory===-1)break -memory=url.indexOf('&${x}=',memory) -if(memory===-1)break}try{if(a${C}.charCodeAt(0)===91)a${C} = JSON.parse(a${C}) -else -a${C}=JSON.parse('['+a${C}+']')}catch{} -`;else H+=`while(memory!==-1){const start=memory+${x.length+2} -memory=url.indexOf('&',start) -if(a${C}===undefined)a${C}=[] -if(memory===-1){const temp=decodeURIComponent(url.slice(start)).replace(/\\+/g,' ') -if(temp.includes(',')){a${C}=a${C}.concat(temp.split(','))}else{a${C}.push(decodeURIComponent(url.slice(start)).replace(/\\+/g,' '))} -break}else{const temp=decodeURIComponent(url.slice(start, memory)).replace(/\\+/g,' ') -if(temp.includes(',')){a${C}=a${C}.concat(temp.split(','))}else{a${C}.push(temp)} -}memory=url.indexOf('&${x}=',memory) -if(memory===-1) break -}`;else if(r)H+=F+`if(memory!==-1){const start=memory+${x.length+2} -memory=url.indexOf('&',start) -if(memory===-1)a${C}=decodeURIComponent(url.slice(start).replace(/\\+/g,' '))else a${C}=decodeURIComponent(url.slice(start,memory).replace(/\\+/g,' '))if(a${C}!==undefined)try{a${C}=JSON.parse(a${C})}catch{}}`;else{if(H+=F+`if(memory!==-1){const start=memory+${x.length+2} -memory=url.indexOf('&',start) -if(memory===-1)a${C}=decodeURIComponent(url.slice(start).replace(/\\+/g,' ')) -else{a${C}=decodeURIComponent(url.slice(start,memory).replace(/\\+/g,' '))`,T)H+=` -let deepMemory=url.indexOf('&${x}=',memory) -if(deepMemory!==-1){a${C}=[a${C}] -let first=true -while(true){const start=deepMemory+${x.length+2} -if(first)first=false -else deepMemory = url.indexOf('&', start) -let value -if(deepMemory===-1)value=url.slice(start).replace(/\\+/g,' ') -else value=url.slice(start, deepMemory).replace(/\\+/g,' ') -value=decodeURIComponent(value) -if(value===null){if(deepMemory===-1){break}else{continue}} -const vStart=value.charCodeAt(0) -const vEnd=value.charCodeAt(value.length - 1) -if((vStart===91&&vEnd===93)||(vStart===123&&vEnd===125)) -try{a${C}.push(JSON.parse(value))}catch{a${C}.push(value)}if(deepMemory===-1)break}}`;H+="}}"}C++,H+=` -`}H+="c.query={"+g.map(({key:x},u)=>`'${x}':a${u}`).join(",")+"}",H+=`} else c.query = {} -`}}let l2=typeof J==="function"&&G0(J),C0=S||$.afterResponse?.length?"c.response= ":"",tX=P||s||l2||!!$.parse?.length||!!$.afterHandle?.some(G0)||!!$.beforeHandle?.some(G0)||!!$.transform?.some(G0)||!!$.mapResponse?.some(G0),Q$=(typeof J==="function"?RY(J):!1)||!!$.beforeHandle?.some(RY)||!!$.afterHandle?.some(RY)||!!$.transform?.some(RY),j2=Q.cookie||Q.set||I||S||W.response||w&&G8||Q$,E8=G.mapResponseContext?`,${G.mapResponseContext}`:"";if(S||Q.route)H+=`c.route=\`${Z}\` -`;let t0=d8("parse",{total:$.parse?.length});if(s){let g=u2(W.body),C=!!$.parse?.length||Q.body||W.body;if(G.parser.declare)H+=G.parser.declare;H+=` -isParsing=true -`;let x=typeof $.parse==="string"?$.parse:Array.isArray($.parse)&&$.parse.length===1?typeof $.parse[0]==="string"?$.parse[0]:typeof $.parse[0].fn==="string"?$.parse[0].fn:void 0:void 0;if(x&&pN.includes(x)){let u=d8("parse",{total:$.parse?.length});switch(x){case"json":case"application/json":H+=G.parser.json(g);break;case"text":case"text/plain":H+=G.parser.text(g);break;case"urlencoded":case"application/x-www-form-urlencoded":H+=G.parser.urlencoded(g);break;case"arrayBuffer":case"application/octet-stream":H+=G.parser.arrayBuffer(g);break;case"formdata":case"multipart/form-data":H+=G.parser.formData(g);break;default:if(x[0]in X["~parser"])H+=I?"let contentType = c.headers['content-type']":"let contentType = c.request.headers.get('content-type')",H+=` -if(contentType){const index=contentType.indexOf(';') -if(index!==-1)contentType=contentType.substring(0, index)} -else{contentType=''}c.contentType=contentType -`,H+=`let result=parser['${x}'](c, contentType) -if(result instanceof Promise)result=await result -if(result instanceof ElysiaCustomStatusResponse)throw result -if(result!==undefined)c.body=result -delete c.contentType -`;break}u.resolve()}else if(C){if(H+=` -`,H+=I?"let contentType = c.headers['content-type']":"let contentType = c.request.headers.get('content-type')",H+=` -if(contentType){const index=contentType.indexOf(';') -if(index!==-1)contentType=contentType.substring(0, index)} -else{contentType=''}c.contentType=contentType -`,$.parse?.length)H+=`let used=false -`;let u=d8("parse",{total:$.parse?.length}),r=!1;if($.parse)for(let D=0;D<$.parse.length;D++){let T=`bo${D}`;if(D!==0)H+=` -if(!used){`;if(typeof $.parse[D].fn==="string"){let F=u.resolveChild($.parse[D].fn);switch($.parse[D].fn){case"json":case"application/json":r=!0,H+=G.parser.json(g);break;case"text":case"text/plain":r=!0,H+=G.parser.text(g);break;case"urlencoded":case"application/x-www-form-urlencoded":r=!0,H+=G.parser.urlencoded(g);break;case"arrayBuffer":case"application/octet-stream":r=!0,H+=G.parser.arrayBuffer(g);break;case"formdata":case"multipart/form-data":r=!0,H+=G.parser.formData(g);break;default:H+=`${T}=parser['${$.parse[D].fn}'](c,contentType) -if(${T} instanceof Promise)${T}=await ${T} -if(${T}!==undefined){c.body=${T};used=true} -`}F()}else{let F=u.resolveChild($.parse[D].fn.name);H+=`let ${T}=e.parse[${D}] -${T}=${T}(c,contentType) -if(${T} instanceof Promise)${T}=await ${T} -if(${T}!==undefined){c.body=${T};used=true}`,F()}if(D!==0)H+="}";if(r)break}if(u.resolve(),!r){if($.parse?.length)H+=` -if(!used){ -if(!contentType) throw new ParseError() -`;H+="switch(contentType){",H+=`case 'application/json': -`+G.parser.json(g)+`break -case 'text/plain':`+G.parser.text(g)+`break -case 'application/x-www-form-urlencoded':`+G.parser.urlencoded(g)+`break -case 'application/octet-stream':`+G.parser.arrayBuffer(g)+`break -case 'multipart/form-data':`+G.parser.formData(g)+`break -`;for(let D of Object.keys(X["~parser"]))H+=`case '${D}':let bo${D}=parser['${D}'](c,contentType) -if(bo${D} instanceof Promise)bo${D}=await bo${D} -if(bo${D} instanceof ElysiaCustomStatusResponse)throw result -if(bo${D}!==undefined)c.body=bo${D} -break -`;if($.parse?.length)H+="}";H+="}"}}H+=` -delete c.contentType`,H+=` -isParsing=false -`}if(t0.resolve(),$?.transform){let g=d8("transform",{total:$.transform.length});if($.transform.length)H+=`let transformed -`;for(let C=0;C<$.transform.length;C++){let x=$.transform[C],u=g.resolveChild(x.fn.name);if(H+=G0(x)?`transformed=await e.transform[${C}](c) -`:`transformed=e.transform[${C}](c) -`,x.subType==="mapDerive")H+=`if(transformed instanceof ElysiaCustomStatusResponse)throw transformed -else{transformed.request=c.request -transformed.store=c.store -transformed.qi=c.qi -transformed.path=c.path -transformed.url=c.url -transformed.redirect=c.redirect -transformed.set=c.set -transformed.error=c.error -c=transformed}`;else H+=`if(transformed instanceof ElysiaCustomStatusResponse)throw transformed -else Object.assign(c,transformed) -`;u()}g.resolve()}if(W){if(W.headers){if(J8&&"Clean"in W.headers&&!N2(W.headers))H+=`c.headers=validator.headers.Clean(c.headers); -`;if(dX("default",W.headers))for(let[g,C]of Object.entries(e.Default(W.headers.schema,{}))){let x=typeof C==="object"?JSON.stringify(C):typeof C==="string"?`'${C}'`:C;if(x!==void 0)H+=`c.headers['${g}']??=${x} -`}if(u2(W.headers))H+="if(isNotEmpty(c.headers)){";if(H+="if(validator.headers.Check(c.headers) === false){"+U8("headers")+"}",W2(W.headers.schema))H+=`c.headers=validator.headers.Decode(c.headers) -`;if(u2(W.headers))H+="}"}if(W.params){if(dX("default",W.params))for(let[g,C]of Object.entries(e.Default(W.params.schema,{}))){let x=typeof C==="object"?JSON.stringify(C):typeof C==="string"?`'${C}'`:C;if(x!==void 0)H+=`c.params['${g}']??=${x} -`}if(H+="if(validator.params.Check(c.params)===false){"+U8("params")+"}",W2(W.params.schema))H+=`c.params=validator.params.Decode(c.params) -`}if(W.query){if(J8&&"Clean"in W.query&&!N2(W.query))H+=`c.query=validator.query.Clean(c.query) -`;if(dX("default",W.query))for(let[g,C]of Object.entries(e.Default(W.query.schema,{}))){let x=typeof C==="object"?JSON.stringify(C):typeof C==="string"?`'${C}'`:C;if(x!==void 0)H+=`if(c.query['${g}']===undefined)c.query['${g}']=${x} -`}if(u2(W.query))H+="if(isNotEmpty(c.query)){";if(H+="if(validator.query.Check(c.query)===false){"+U8("query")+"}",W2(W.query.schema))H+=`c.query=validator.query.Decode(Object.assign({},c.query)) -`;if(u2(W.query))H+="}"}if(W.body){if(J8&&"Clean"in W.body&&!N2(W.body))H+=`c.body=validator.body.Clean(c.body) -`;let g=W2(W.body.schema);if(g||u2(W.body))H+=`const isNotEmptyObject=c.body&&(typeof c.body==="object"&&isNotEmpty(c.body)) -`;if(dX("default",W.body)){let C=W.body.schema,x=e.Default(C,C.type==="object"||C[A1.kind]==="Import"&&C.$defs[C.$ref][A1.kind]==="Object"?{}:void 0),u=typeof x==="object"?JSON.stringify(x):typeof x==="string"?`'${x}'`:x;if(H+="if(validator.body.Check(c.body)===false){",x!==void 0&&x!==null)H+=`if(typeof c.body==='object')c.body=Object.assign(${u},c.body) -else c.body=${u} -`;if(u2(W.body))H+="if(isNotEmptyObject&&validator.body.Check(c.body)===false){"+U8("body")+"}";else H+="if(validator.body.Check(c.body)===false){"+U8("body")+"}";H+="}"}else if(u2(W.body))H+="if(isNotEmptyObject&&validator.body.Check(c.body)===false){"+U8("body")+"}";else H+="if(validator.body.Check(c.body)===false){"+U8("body")+"}";if(g)H+=`if(isNotEmptyObject)c.body=validator.body.Decode(c.body) -`}if(k&&F2(k?.schema?.properties??k?.schema?.schema??{})){if(H+=`const cookieValue={} -for(const [key,value] of Object.entries(c.cookie))cookieValue[key]=value.value -`,dX("default",k))for(let[g,C]of Object.entries(e.Default(k.schema,{})))H+=`cookieValue['${g}'] = ${typeof C==="object"?JSON.stringify(C):C} -`;if(u2(W.cookie))H+="if(isNotEmpty(c.cookie)){";if(H+="if(validator.cookie.Check(cookieValue)===false){"+U8("cookie","cookieValue")+"}",W2(W.cookie.schema))H+=`for(const [key,value] of Object.entries(validator.cookie.Decode(cookieValue)))c.cookie[key].value=value -`;if(u2(W.cookie))H+="}"}}if($?.beforeHandle){let g=d8("beforeHandle",{total:$.beforeHandle.length}),C=!1;for(let x=0;x<$.beforeHandle.length;x++){let u=$.beforeHandle[x],r=g.resolveChild(u.fn.name),D=jZ(u);if(u.subType==="resolve"||u.subType==="mapResolve"){if(!C)C=!0,H+=` -let resolved -`;if(H+=G0(u)?`resolved=await e.beforeHandle[${x}](c); -`:`resolved=e.beforeHandle[${x}](c); -`,u.subType==="mapResolve")H+=`if(resolved instanceof ElysiaCustomStatusResponse)throw resolved -else{resolved.request = c.request -resolved.store = c.store -resolved.qi = c.qi -resolved.path = c.path -resolved.url = c.url -resolved.redirect = c.redirect -resolved.set = c.set -resolved.error = c.error -c = resolved}`;else H+=`if(resolved instanceof ElysiaCustomStatusResponse)throw resolved -else Object.assign(c, resolved) -`}else if(!D)H+=G0(u)?`await e.beforeHandle[${x}](c) -`:`e.beforeHandle[${x}](c) -`,r();else{if(H+=G0(u)?`be=await e.beforeHandle[${x}](c) -`:`be=e.beforeHandle[${x}](c) -`,r("be"),H+="if(be!==undefined){",g.resolve(),$.afterHandle?.length){d8("handle",{name:w?J.name:void 0}).resolve();let F=d8("afterHandle",{total:$.afterHandle.length});for(let p=0;p<$.afterHandle.length;p++){let v=$.afterHandle[p],c=jZ(v),T8=F.resolveChild(v.fn.name);if(H+=`c.response = be -`,!c)H+=G0(v.fn)?`await e.afterHandle[${p}](c, be) -`:`e.afterHandle[${p}](c, be) -`;else H+=G0(v.fn)?`af = await e.afterHandle[${p}](c) -`:`af = e.afterHandle[${p}](c) -`,H+=`if(af!==undefined) c.response=be=af -`;T8("af")}F.resolve()}if(W.response)H+=H0("be");let T=d8("mapResponse",{total:$.mapResponse?.length});if($.mapResponse?.length){H+=`c.response=be -`;for(let F=0;F<$.mapResponse.length;F++){let p=$.mapResponse[F],v=T.resolveChild(p.fn.name);H+=`if(mr===undefined){mr=${i1(p)?"await ":""}e.mapResponse[${F}](c) -if(mr!==undefined)be=c.response=mr}`,v()}}T.resolve(),H+=$8,H+=`return mapEarlyResponse(${C0}be,c.set${E8})} -`}}g.resolve()}if($.afterHandle?.length){let g=d8("handle",{name:w?J.name:void 0});if($.afterHandle.length)H+=l2?`let r=c.response=await ${B} -`:`let r=c.response=${B} -`;else H+=l2?`let r=await ${B} -`:`let r=${B} -`;g.resolve();let C=d8("afterHandle",{total:$.afterHandle.length});for(let u=0;u<$.afterHandle.length;u++){let r=$.afterHandle[u],D=jZ(r),T=C.resolveChild(r.fn.name);if(!D)H+=G0(r.fn)?`await e.afterHandle[${u}](c) -`:`e.afterHandle[${u}](c) -`,T();else if(H+=G0(r.fn)?`af=await e.afterHandle[${u}](c) -`:`af=e.afterHandle[${u}](c) -`,T("af"),W.response)H+="if(af!==undefined){",C.resolve(),H+=H0("af"),H+="c.response=af}";else H+="if(af!==undefined){",C.resolve(),H+="c.response=af}"}if(C.resolve(),H+=`r=c.response -`,W.response)H+=H0();H+=$8;let x=d8("mapResponse",{total:$.mapResponse?.length});if($.mapResponse?.length)for(let u=0;u<$.mapResponse.length;u++){let r=$.mapResponse[u],D=x.resolveChild(r.fn.name);H+=`mr=${i1(r)?"await ":""}e.mapResponse[${u}](c) -if(mr!==undefined)r=c.response=mr -`,D()}if(x.resolve(),j2)H+=`return mapResponse(${C0}r,c.set${E8}) -`;else H+=`return mapCompactResponse(${C0}r${E8}) -`}else{let g=d8("handle",{name:w?J.name:void 0});if(W.response||$.mapResponse?.length){if(H+=l2?`let r=await ${B} -`:`let r=${B} -`,g.resolve(),W.response)H+=H0();d8("afterHandle").resolve();let C=d8("mapResponse",{total:$.mapResponse?.length});if($.mapResponse?.length){H+=` -c.response=r -`;for(let x=0;x<$.mapResponse.length;x++){let u=$.mapResponse[x],r=C.resolveChild(u.fn.name);H+=` -if(mr===undefined){mr=${i1(u)?"await ":""}e.mapResponse[${x}](c) -if(mr!==undefined)r=c.response=mr} -`,r()}}if(C.resolve(),H+=$8,J instanceof Response)H+=Q.set?`if(isNotEmpty(c.set.headers)||c.set.status!==200||c.set.redirect||c.set.cookie)return mapResponse(${C0}${B}.clone(),c.set${E8})else return ${B}.clone()`:`return ${B}.clone()`,H+=` -`;else if(j2)H+=`return mapResponse(${C0}r,c.set${E8}) -`;else H+=`return mapCompactResponse(${C0}r${E8}) -`}else if(P||S){H+=l2?`let r=await ${B} -`:`let r=${B} -`,g.resolve(),d8("afterHandle").resolve();let C=d8("mapResponse",{total:$.mapResponse?.length});if($.mapResponse?.length){H+=`c.response= r -`;for(let x=0;x<$.mapResponse.length;x++){let u=$.mapResponse[x],r=C.resolveChild(u.fn.name);H+=`if(mr===undefined){mr=${i1(u)?"await ":""}e.mapResponse[${x}](c) -if(mr!==undefined)r=c.response=mr}`,r()}}if(C.resolve(),H+=$8,j2)H+=`return mapResponse(${C0}r,c.set${E8}) -`;else H+=`return mapCompactResponse(${C0}r${E8}) -`}else{g.resolve();let C=l2?`await ${B}`:B;if(d8("afterHandle").resolve(),J instanceof Response)H+=Q.set?`if(isNotEmpty(c.set.headers)||c.set.status!==200||c.set.redirect||c.set.cookie)return mapResponse(${C0}${B}.clone(),c.set${E8}) -else return ${B}.clone() -`:`return ${B}.clone() -`;else if(j2)H+=`return mapResponse(${C0}${C},c.set${E8}) -`;else H+=`return mapCompactResponse(${C0}${C}${E8}) -`}}if(H+=` -}catch(error){`,s)H+=`if(isParsing)error=new ParseError() -`;if(!tX)H+="return(async()=>{";if(H+=`const set=c.set -if(!set.status||set.status<300)set.status=error?.status||500 -`,S&&$.trace)for(let g=0;g<$.trace.length;g++)H+=`report${g}?.resolve(error);reportChild${g}?.(error) -`;let SX=d8("error",{total:$.error?.length});if($.error?.length){if(H+=`c.error=error -`,E)H+=`if(error instanceof TypeBoxError){c.code="VALIDATION" -c.set.status=422}else{c.code=error.code??error[ERROR_CODE]??"UNKNOWN"}`;else H+=`c.code=error.code??error[ERROR_CODE]??"UNKNOWN" -`;H+=`let er -`;for(let g=0;g<$.error.length;g++){let C=SX.resolveChild($.error[g].fn.name);if(G0($.error[g]))H+=`er=await e.error[${g}](c) -`;else H+=`er=e.error[${g}](c) -if(er instanceof Promise)er=await er -`;C();let x=d8("mapResponse",{total:$.mapResponse?.length});if($.mapResponse?.length)for(let u=0;u<$.mapResponse.length;u++){let r=$.mapResponse[u],D=x.resolveChild(r.fn.name);H+=`c.response=er -er=e.mapResponse[${u}](c) -if(er instanceof Promise)er=await er -`,D()}if(x.resolve(),H+=`er=mapEarlyResponse(er,set${E8}) -`,H+="if(er){",S&&$.trace){for(let u=0;u<$.trace.length;u++)H+=`report${u}.resolve() -`;SX.resolve()}H+="return er}"}}if(SX.resolve(),H+="return handleError(c,error,true)",!tX)H+="})()";if(H+="}",N||S){if(H+="finally{ ",!tX)H+=";(async()=>{";let g=d8("afterResponse",{total:$.afterResponse?.length});if(N&&$.afterResponse)for(let C=0;C<$.afterResponse.length;C++){let x=g.resolveChild($.afterResponse[C].fn.name);H+=` -await e.afterResponse[${C}](c) -`,x()}if(g.resolve(),!tX)H+="})()";H+="}"}let VX=G.inject?Object.keys(G.inject).join(",")+",":"",S2="const {handler,handleError,hooks:e, "+B0("validator,",E)+"mapResponse,mapCompactResponse,mapEarlyResponse,isNotEmpty,utils:{"+B0("parseQuery,",s)+B0("parseQueryFromURL,",h)+"},error:{"+B0("ValidationError,",E)+"InternalServerError,"+B0("ParseError",s)+"},schema,definitions,ERROR_CODE,"+B0("parseCookie,",P)+B0("signCookie,",P)+B0("decodeURIComponent,",h)+"ElysiaCustomStatusResponse,"+B0("ELYSIA_TRACE,",S)+B0("ELYSIA_REQUEST_ID,",S)+B0("parser,",$.parse?.length)+B0("getServer,",Q.server)+VX+B0("TypeBoxError",E)+`}=hooks -const trace=e.trace?.map(x=>typeof x==='function'?x:x.fn)??[] -return ${tX?"async ":""}function handle(c){`;if($.beforeHandle?.length)S2+=`let be -`;if($.afterHandle?.length)S2+=`let af -`;if($.mapResponse?.length)S2+=`let mr -`;if(z)S2+=`c.schema = schema -c.defs = definitions -`;S2+=H+"}";try{if(M)return Function("hooks",S2);return Function("hooks",S2)({handler:J,hooks:U5($),validator:E?W:void 0,handleError:X.handleError,mapResponse:U.mapResponse,mapCompactResponse:U.mapCompactResponse,mapEarlyResponse:U.mapEarlyResponse,isNotEmpty:F2,utils:{parseQuery:s?SY:void 0,parseQueryFromURL:h?hN:void 0},error:{ValidationError:E?Q8:void 0,InternalServerError:E5,ParseError:s?C5:void 0},schema:X.router.history,definitions:X.definitions.type,ERROR_CODE:CY,parseCookie:P?y5:void 0,signCookie:P?EY:void 0,decodeURIComponent:h?hX:void 0,ElysiaCustomStatusResponse:o2,ELYSIA_TRACE:S?H6:void 0,ELYSIA_REQUEST_ID:S?TY:void 0,getServer:()=>X.getServer(),TypeBoxError:E?n:void 0,parser:X["~parser"],...G.inject})}catch(g){let C=U5($);console.log("[Composer] failed to generate optimized handler"),console.log("---"),console.log({handler:typeof J==="function"?J.toString():J,instruction:S2,hooks:{...C,transform:C?.transform?.map?.((x)=>x.toString()),resolve:C?.resolve?.map?.((x)=>x.toString()),beforeHandle:C?.beforeHandle?.map?.((x)=>x.toString()),afterHandle:C?.afterHandle?.map?.((x)=>x.toString()),mapResponse:C?.mapResponse?.map?.((x)=>x.toString()),parse:C?.parse?.map?.((x)=>x.toString()),error:C?.error?.map?.((x)=>x.toString()),afterResponse:C?.afterResponse?.map?.((x)=>x.toString()),stop:C?.stop?.map?.((x)=>x.toString())},validator:W,definitions:X.definitions.type,error:g,fnLiteral:H}),console.log("---"),process.exit(1)}},Y6=(X,{asManifest:Z=!1}={})=>{let Y=X["~adapter"].composeGeneralHandler;X.router.http.build();let $=Y.error404(!!X.event.request?.length,!!X.event.error?.length),W=X.event.trace?.length,J="",z=X.router,Q="const route=router.find(r.method,p)";Q+=z.http.root.ALL?`??router.find("ALL",p) -`:` -`,Q+=$.code,Q+=` -c.params=route.params -if(route.store.handler)return route.store.handler(c) -return (route.store.handler=route.store.compile())(c) -`;let M="";for(let[N,S]of Object.entries(z.static.http.map)){if(M+=`case'${N}':`,X.config.strictPath!==!0)M+=`case'${c1(N)}':`;let H=qZ(N);if(N!==H)M+=`case'${H}':`;M+=`switch(r.method){${S.code} -`+(S.all??"default: break map")+"}"}let G=!!X.event.request?.some(G0),U=Y.inject?Object.keys(Y.inject).join(",")+",":"";if(J+=` -const {app,mapEarlyResponse,NotFoundError,randomId,handleError,error,redirect,`+B0("ELYSIA_TRACE,",W)+B0("ELYSIA_REQUEST_ID,",W)+U+`}=data -const store=app.singleton.store -const decorator=app.singleton.decorator -const staticRouter=app.router.static.http -const ht=app.router.history -const router=app.router.http -const trace=app.event.trace?.map(x=>typeof x==='function'?x:x.fn)??[] -const notFound=new NotFoundError() -const hoc=app.extender.higherOrderFunctions.map(x=>x.fn) -`,X.event.request?.length)J+=`const onRequest=app.event.request.map(x=>x.fn) -`;if(J+=$.declare,X.event.trace?.length)J+="const "+X.event.trace.map((N,S)=>`tr${S}=app.event.trace[${S}].fn`).join(",")+` -`;if(J+=`${G?"async ":""}function map(${Y.parameters}){`,X.event.request?.length)J+=`let re -`;if(J+=Y.createContext(X),X.event.trace?.length)J+="c[ELYSIA_TRACE]=["+X.event.trace.map((N,S)=>`tr${S}(c)`).join(",")+`] -`;let w=D6({trace:X.event.trace,addFn(N){J+=N}})("request",{total:X.event.request?.length});if(X.event.request?.length){J+="try{";for(let N=0;N{let Z=X.event,Y="",$=X["~adapter"].composeError,W=$.inject?Object.keys($.inject).join(",")+",":"",J=!!X.event.trace?.length;if(Y+="const {app:{event:{error:onErrorContainer,afterResponse:resContainer,mapResponse:_onMapResponse,trace:_trace}},mapResponse,ERROR_CODE,ElysiaCustomStatusResponse,"+B0("ELYSIA_TRACE,",J)+B0("ELYSIA_REQUEST_ID,",J)+W+`}=inject -`,Y+=`const trace=_trace?.map(x=>typeof x==='function'?x:x.fn)??[] -const onMapResponse=[] -if(_onMapResponse)for(let i=0;i<_onMapResponse.length;i++)onMapResponse.push(_onMapResponse[i].fn??_onMapResponse[i]) -delete _onMapResponse -const onError=onErrorContainer?.map(x=>x.fn)??[] -const res=resContainer?.map(x=>x.fn)??[] -return ${X.event.error?.find(G0)||X.event.mapResponse?.find(G0)?"async ":""}function(context,error,skipGlobal){`,Y+="",J)Y+=`const id=context[ELYSIA_REQUEST_ID] -`;let z=D6({context:"context",trace:Z.trace,addFn:(G)=>{Y+=G}});if(Y+=`const set=context.set -let _r -if(!context.code)context.code=error.code??error[ERROR_CODE] -if(!(context.error instanceof Error))context.error=error -if(error instanceof ElysiaCustomStatusResponse){set.status=error.status=error.code -error.message=error.response}`,$.declare)Y+=$.declare;let Q=J||!!Z.afterResponse?.length||!!Z.afterResponse?.length?"context.response = ":"";if(X.event.error)for(let G=0;G{for(let[Y,$]of Object.entries(X.schema.properties))Z[Y]??=$.default},B5=(X)=>{let{mapResponse:Z,mapEarlyResponse:Y}=X["~adapter"].handler;return async($)=>{let W=$.url,J=W.indexOf("/",11),z=W.indexOf("?",J+1),Q=z===-1?W.substring(J):W.substring(J,z),M={cookie:{},status:200,headers:{}},G=Object.assign({},X.singleton.decorator,{set:M,store:X.singleton.store,request:$,path:Q,qi:z,error:_1,redirect:S5});try{if(X.event.request)for(let P=0;P{let{mapResponse:Z}=X["~adapter"].handler;return async(Y,$)=>{let W=Object.assign(Y,{error:$,code:$.code});if(W.set=Y.set,X.event.error)for(let J=0;J$.summary).join(` -`))}return this}wrap(X){return this.extender.higherOrderFunctions.push({checksum:BZ(JSON.stringify({name:this.config.name,seed:this.config.seed,content:X.toString()})),fn:X}),this}applyMacro(X){if(this.extender.macros.length){let Z=LN({globalHook:this.event,localHook:X}),Y={events:{global:this.event,local:X},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 $ of this.extender.macros)NN($.fn(Y),X,Z)}}applyConfig(X){return this.config={prefix:"",aot:F5.ELYSIA_AOT!=="false",normalize:!0,...X,cookie:{path:"/",...X?.cookie},experimental:X?.experimental??{},seed:X?.seed===void 0?"":X?.seed},this}get models(){let X={};for(let Z of Object.keys(this.definitions.type))X[Z]=u0(this.definitions.typebox.Import(Z));return X.modules=this.definitions.typebox,X}add(X,Z,Y,$,{allowMeta:W=!1,skipPrefix:J=!1}={allowMeta:!1,skipPrefix:!1}){if($=Z6(BN($)),Z!==""&&Z.charCodeAt(0)!==47)Z="/"+Z;if(this.config.prefix&&!J)Z=this.config.prefix+Z;if($?.type)switch($.type){case"text":$.type="text/plain";break;case"json":$.type="application/json";break;case"formdata":$.type="multipart/form-data";break;case"urlencoded":$.type="application/x-www-form-urlencoded";break;case"arrayBuffer":$.type="application/octet-stream";break;default:break}let z=this.definitions.type,Q=!this.config.aot,M={...this.validator.getCandidate()},G={body:$?.body??M?.body,headers:$?.headers??M?.headers,params:$?.params??M?.params,query:$?.query??M?.query,cookie:$?.cookie??M?.cookie,response:$?.response??M?.response},U=()=>G.cookie?R5({modules:B,validator:G.cookie,defaultConfig:this.config.cookie,config:G.cookie?.config??{},dynamic:Q,models:z}):void 0,w=this.config.normalize,B=this.definitions.typebox,N=this.config.precompile===!0||typeof this.config.precompile==="object"&&this.config.precompile.schema===!0?{body:u0(G.body,{modules:B,dynamic:Q,models:z,normalize:w,additionalCoerce:W5()}),headers:u0(G.headers,{modules:B,dynamic:Q,models:z,additionalProperties:!this.config.normalize,coerce:!0,additionalCoerce:M1()}),params:u0(G.params,{modules:B,dynamic:Q,models:z,coerce:!0,additionalCoerce:M1()}),query:u0(G.query,{modules:B,dynamic:Q,models:z,normalize:w,coerce:!0,additionalCoerce:M1()}),cookie:U(),response:$5(G.response,{modules:B,dynamic:Q,models:z,normalize:w})}:{createBody(){if(this.body)return this.body;return this.body=u0(G.body,{modules:B,dynamic:Q,models:z,normalize:w,additionalCoerce:W5()})},createHeaders(){if(this.headers)return this.headers;return this.headers=u0(G.headers,{modules:B,dynamic:Q,models:z,additionalProperties:!w,coerce:!0,additionalCoerce:M1()})},createParams(){if(this.params)return this.params;return this.params=u0(G.params,{modules:B,dynamic:Q,models:z,coerce:!0,additionalCoerce:M1()})},createQuery(){if(this.query)return this.query;return this.query=u0(G.query,{modules:B,dynamic:Q,models:z,coerce:!0,additionalCoerce:M1()})},createCookie(){if(this.cookie)return this.cookie;return this.cookie=U()},createResponse(){if(this.response)return this.response;return this.response=$5(G.response,{modules:B,dynamic:Q,models:z,normalize:w})}};if($=FX($,Z6(M)),$.tags)if(!$.detail)$.detail={tags:$.tags};else $.detail.tags=$.tags;if(F2(this.config.detail))$.detail=c0(Object.assign({},this.config.detail),$.detail);this.applyMacro($);let S=Z6(FX(this.event,$));if(this.config.aot===!1){this.router.dynamic.add(X,Z,{validator:N,hooks:S,content:$?.type,handle:Y,route:Z});let X8=qZ(Z,{dynamic:!0});if(Z!==X8)this.router.dynamic.add(X,X8,{validator:N,hooks:S,content:$?.type,handle:Y,route:Z});if(this.config.strictPath===!1){let U8=c1(Z);this.router.dynamic.add(X,U8,{validator:N,hooks:S,content:$?.type,handle:Y,route:Z});let H0=qZ(U8);if(U8!==H0)this.router.dynamic.add(X,U8,{validator:N,hooks:S,content:$?.type,handle:Y,route:Z})}this.router.history.push({method:X,path:Z,composed:null,handler:Y,hooks:S});return}let H=this.config.precompile===!0||typeof this.config.precompile==="object"&&this.config.precompile.compose===!0,E=X6(this.inference),h=this["~adapter"].handler,Y8=typeof Y!=="function"&&typeof h.createStaticHandler==="function"?h.createStaticHandler(Y,S,this.setHeaders):void 0,s=typeof Y!=="function"?h.createNativeStaticHandler?.(Y,S,this.setHeaders):void 0;if(this.config.nativeStaticResponse===!0&&s&&(X==="GET"||X==="ALL"))this.router.static.http.static[Z]=s();let V8=(X8=!1)=>oN({app:this,path:Z,method:X,hooks:S,validator:N,handler:typeof Y!=="function"&&typeof h.createStaticHandler!=="function"?()=>Y:Y,allowMeta:W,inference:E,asManifest:X8}),G8;if(this.routeTree.has(X+Z))for(let X8=0;X8{let U8=(I[P].composed=V8())(X8);return V8=void 0,U8};if(H)V8=void 0;let b=X==="$INTERNALWS";if(G8!==void 0)this.router.history[G8]=Object.assign({method:X,path:Z,composed:k,handler:Y,hooks:S},$.webSocket?{websocket:$.websocket}:{});else this.router.history.push(Object.assign({method:X,path:Z,composed:k,handler:Y,hooks:S},$.webSocket?{websocket:$.websocket}:{}));let $8=this.router.static.http,J8={handler:H?k:void 0,compile(){return this.handler=V8()}};if(b){if(this.router.http.add("ws",Z,J8),!this.config.strictPath)this.router.http.add("ws",c1(Z),J8);let X8=qZ(Z,{dynamic:!0});if(X8!==Z)this.router.http.add("ws",X8,J8);return}if(Z.indexOf(":")===-1&&Z.indexOf("*")===-1){if(!$8.map[Z])$8.map[Z]={code:""};let X8=Y8?"":"c";if(X==="ALL")$8.map[Z].all=`default:return ht[${P}].composed(${X8}) -`;else $8.map[Z].code=`case '${X}':return ht[${P}].composed(${X8}) -${$8.map[Z].code}`;if(!this.config.strictPath&&this.config.nativeStaticResponse===!0&&s&&(X==="GET"||X==="ALL"))this.router.static.http.static[c1(Z)]=s()}else{if(this.router.http.add(X,Z,J8),!this.config.strictPath){let U8=c1(Z);if(this.config.nativeStaticResponse===!0&&Y8&&(X==="GET"||X==="ALL"))this.router.static.http.static[U8]=Y8();this.router.http.add(X,U8,J8)}let X8=qZ(Z,{dynamic:!0});if(Z!==X8){if(this.router.http.add(X,X8,J8),this.config.nativeStaticResponse===!0&&Y8&&(X==="GET"||X==="ALL"))this.router.static.http.static[X8]=Y8();this.router.http.add(X,X8,J8)}}}setHeaders;headers(X){if(!X)return this;if(!this.setHeaders)this.setHeaders={};return this.setHeaders=c0(this.setHeaders,X),this}onStart(X){return this.on("start",X),this}onRequest(X){return this.on("request",X),this}onParse(X,Z){if(!Z){if(typeof X==="string")return this.on("parse",this["~parser"][X]);return this.on("parse",X)}return this.on(X,"parse",Z)}parser(X,Z){return this["~parser"][X]=Z,this}onTransform(X,Z){if(!Z)return this.on("transform",X);return this.on(X,"transform",Z)}resolve(X,Z){if(!Z)Z=X,X={as:"local"};let Y={subType:"resolve",fn:Z};return this.onBeforeHandle(X,Y)}mapResolve(X,Z){if(!Z)Z=X,X={as:"local"};let Y={subType:"mapResolve",fn:Z};return this.onBeforeHandle(X,Y)}onBeforeHandle(X,Z){if(!Z)return this.on("beforeHandle",X);return this.on(X,"beforeHandle",Z)}onAfterHandle(X,Z){if(!Z)return this.on("afterHandle",X);return this.on(X,"afterHandle",Z)}mapResponse(X,Z){if(!Z)return this.on("mapResponse",X);return this.on(X,"mapResponse",Z)}onAfterResponse(X,Z){if(!Z)return this.on("afterResponse",X);return this.on(X,"afterResponse",Z)}trace(X,Z){if(!Z)Z=X,X={as:"local"};if(!Array.isArray(Z))Z=[Z];for(let Y of Z)this.on(X,"trace",mN(Y));return this}error(X,Z){switch(typeof X){case"string":return Z.prototype[CY]=X,this.definitions.error[X]=Z,this;case"function":return this.definitions.error=X(this.definitions.error),this}for(let[Y,$]of Object.entries(X))$.prototype[CY]=Y,this.definitions.error[Y]=$;return this}onError(X,Z){if(!Z)return this.on("error",X);return this.on(X,"error",Z)}onStop(X){return this.on("stop",X),this}on(X,Z,Y){let $;switch(typeof X){case"string":$=X,Y=Z;break;case"object":if($=Z,!Array.isArray(Z)&&typeof Z==="object")Y=Z;break}if(Array.isArray(Y))Y=w0(Y);else if(typeof Y==="function")Y=[{fn:Y}];else Y=[Y];let W=Y;for(let J of W)if(J.scope=typeof X==="string"?"local":X?.as??"local",$==="resolve"||$==="derive")J.subType=$;if($!=="trace")f5({[$]:W.map((J)=>J.fn)},this.inference);for(let J of W){let z=wN(J,"global",{skipIfHasType:!0});switch($){case"start":this.event.start??=[],this.event.start.push(z);break;case"request":this.event.request??=[],this.event.request.push(z);break;case"parse":this.event.parse??=[],this.event.parse.push(z);break;case"transform":this.event.transform??=[],this.event.transform.push(z);break;case"derive":this.event.transform??=[],this.event.transform.push(w0(z,"derive"));break;case"beforeHandle":this.event.beforeHandle??=[],this.event.beforeHandle.push(z);break;case"resolve":this.event.beforeHandle??=[],this.event.beforeHandle.push(w0(z,"resolve"));break;case"afterHandle":this.event.afterHandle??=[],this.event.afterHandle.push(z);break;case"mapResponse":this.event.mapResponse??=[],this.event.mapResponse.push(z);break;case"afterResponse":this.event.afterResponse??=[],this.event.afterResponse.push(z);break;case"trace":this.event.trace??=[],this.event.trace.push(z);break;case"error":this.event.error??=[],this.event.error.push(z);break;case"stop":this.event.stop??=[],this.event.stop.push(z);break}}return this}propagate(){return E0(this.event.parse),E0(this.event.transform),E0(this.event.beforeHandle),E0(this.event.afterHandle),E0(this.event.mapResponse),E0(this.event.afterResponse),E0(this.event.trace),E0(this.event.error),this}as(X){let Z={plugin:"scoped",scoped:"scoped",global:"global"}[X];if(E0(this.event.parse,Z),E0(this.event.transform,Z),E0(this.event.beforeHandle,Z),E0(this.event.afterHandle,Z),E0(this.event.mapResponse,Z),E0(this.event.afterResponse,Z),E0(this.event.trace,Z),E0(this.event.error,Z),X==="plugin")this.validator.scoped=FZ(this.validator.scoped,this.validator.local),this.validator.local=null;else if(X==="global")this.validator.global=FZ(this.validator.global,FZ(this.validator.scoped,this.validator.local)),this.validator.scoped=null,this.validator.local=null;return this}group(X,Z,Y){let $=new O2({...this.config,prefix:""});$.singleton={...this.singleton},$.definitions={...this.definitions},$.getServer=()=>this.getServer(),$.inference=X6(this.inference),$.extender={...this.extender};let W=typeof Z==="object",J=(W?Y:Z)($);if(this.singleton=c0(this.singleton,$.singleton),this.definitions=c0(this.definitions,$.definitions),J.event.request?.length)this.event.request=[...this.event.request||[],...J.event.request||[]];if(J.event.mapResponse?.length)this.event.mapResponse=[...this.event.mapResponse||[],...J.event.mapResponse||[]];return this.model(J.definitions.type),Object.values($.router.history).forEach(({method:z,path:Q,handler:M,hooks:G})=>{if(Q=(W?"":this.config.prefix)+X+Q,W){let U=Z,w=G;this.add(z,Q,M,FX(U,{...w||{},error:!w.error?J.event.error:Array.isArray(w.error)?[...w.error||{},...J.event.error||{}]:[w.error,...J.event.error||{}]}))}else this.add(z,Q,M,FX(G,{error:J.event.error}),{skipPrefix:!0})}),this}guard(X,Z){if(!Z){if(typeof X==="object"){this.applyMacro(X);let W=X.as??"local";if(this.validator[W]={body:X.body??this.validator[W]?.body,headers:X.headers??this.validator[W]?.headers,params:X.params??this.validator[W]?.params,query:X.query??this.validator[W]?.query,response:X.response??this.validator[W]?.response,cookie:X.cookie??this.validator[W]?.cookie},X.parse)this.on({as:W},"parse",X.parse);if(X.transform)this.on({as:W},"transform",X.transform);if(X.derive)this.on({as:W},"derive",X.derive);if(X.beforeHandle)this.on({as:W},"beforeHandle",X.beforeHandle);if(X.resolve)this.on({as:W},"resolve",X.resolve);if(X.afterHandle)this.on({as:W},"afterHandle",X.afterHandle);if(X.mapResponse)this.on({as:W},"mapResponse",X.mapResponse);if(X.afterResponse)this.on({as:W},"afterResponse",X.afterResponse);if(X.error)this.on({as:W},"error",X.error);if(X.detail)if(this.config.detail)this.config.detail=c0(Object.assign({},this.config.detail),X.detail);else this.config.detail=X.detail;if(X?.tags)if(!this.config.detail)this.config.detail={tags:X.tags};else this.config.detail.tags=X.tags;return this}return this.guard({},X)}let Y=new O2({...this.config,prefix:""});Y.singleton={...this.singleton},Y.definitions={...this.definitions},Y.inference=X6(this.inference),Y.extender={...this.extender};let $=Z(Y);if(this.singleton=c0(this.singleton,Y.singleton),this.definitions=c0(this.definitions,Y.definitions),$.getServer=()=>this.server,$.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(Y.router.history).forEach(({method:W,path:J,handler:z,hooks:Q})=>{this.add(W,J,z,FX(X,{...Q||{},error:!Q.error?$.event.error:Array.isArray(Q.error)?[...Q.error||{},...$.event.error||[]]:[Q.error,...$.event.error||[]]}))}),this}use(X,Z){if(Array.isArray(X)){let Y=this;for(let $ of X)Y=Y.use($);return Y}if(Z?.scoped)return this.guard({},(Y)=>Y.use(X));if(Array.isArray(X)){let Y=this;for(let $ of X)Y=this.use($);return Y}if(X instanceof Promise)return this.promisedModules.add(X.then((Y)=>{if(typeof Y==="function")return Y(this);if(Y instanceof O2)return this._use(Y).compile();if(Y.constructor.name==="Elysia")return this._use(Y).compile();if(typeof Y.default==="function")return Y.default(this);if(Y.default instanceof O2)return this._use(Y.default);if(Y.constructor.name==="Elysia")return this._use(Y.default);if(Y.constructor.name==="_Elysia")return this._use(Y.default);try{return this._use(Y.default)}catch($){throw console.error('Invalid plugin type. Expected Elysia instance, function, or module with "default" as Elysia instance or function that returns Elysia instance.'),$}}).then((Y)=>{if(Y&&typeof Y.compile==="function")Y.compile();return Y})),this;return this._use(X)}propagatePromiseModules(X){if(X.promisedModules.size<=0)return this;for(let Z of X.promisedModules.promises)this.promisedModules.add(Z.then((Y)=>{if(!Y)return;let $=this._use(Y);if($ instanceof Promise)return $.then((W)=>{if(W)W.compile();else Y.compile()});return Y.compile()}));return this}_use(X){if(typeof X==="function"){let W=X(this);if(W instanceof Promise)return this.promisedModules.add(W.then((J)=>{if(J instanceof O2){J.getServer=()=>this.getServer(),J.getGlobalRoutes=()=>this.getGlobalRoutes(),J.model(this.definitions.type),J.error(this.definitions.error);for(let{method:z,path:Q,handler:M,hooks:G}of Object.values(J.router.history))this.add(z,Q,M,FX(G,{error:J.event.error}));if(J.compile(),J===this)return;return this.propagatePromiseModules(J),J}if(typeof J==="function")return J(this);if(typeof J.default==="function")return J.default(this);return this._use(J)}).then((J)=>{if(J&&typeof J.compile==="function")J.compile();return J})),this;return W}this.propagatePromiseModules(X);let{name:Z,seed:Y}=X.config;if(X.getParent=()=>this,X.getServer=()=>this.getServer(),X.getGlobalRoutes=()=>this.getGlobalRoutes(),X.model(this.definitions.type),X.error(this.definitions.error),this["~parser"]={...X["~parser"],...this["~parser"]},this.headers(X.setHeaders),Z){if(!(Z in this.dependencies))this.dependencies[Z]=[];let W=Y!==void 0?BZ(Z+JSON.stringify(Y)):0;if(!this.dependencies[Z].some(({checksum:J})=>W===J))this.extender.macros=this.extender.macros.concat(X.extender.macros),this.extender.higherOrderFunctions=this.extender.higherOrderFunctions.concat(X.extender.higherOrderFunctions)}else this.extender.macros=this.extender.macros.concat(X.extender.macros),this.extender.higherOrderFunctions=this.extender.higherOrderFunctions.concat(X.extender.higherOrderFunctions);H5(this.extender.macros),H5(this.extender.higherOrderFunctions);let $=[];for(let W=0;WW===J))return this;this.dependencies[Z].push(this.config?.analytic?{name:X.config.name,seed:X.config.seed,checksum:W,dependencies:X.dependencies,stack:X.telemetry.stack,routes:X.router.history,decorators:X.singleton,store:X.singleton.store,error:X.definitions.error,derive:X.event.transform?.filter((J)=>J?.subType==="derive").map((J)=>({fn:J.toString(),stack:new Error().stack??""})),resolve:X.event.transform?.filter((J)=>J?.subType==="resolve").map((J)=>({fn:J.toString(),stack:new Error().stack??""}))}:{name:X.config.name,seed:X.config.seed,checksum:W,dependencies:X.dependencies}),this.event=J5(this.event,z5(X.event),W)}else this.event=J5(this.event,z5(X.event));return this.validator.global=FX(this.validator.global,{...X.validator.global}),this.validator.local=FX(this.validator.local,{...X.validator.scoped}),this}macro(X){if(typeof X==="function"){let Z={checksum:BZ(JSON.stringify({name:this.config.name,seed:this.config.seed,content:X.toString()})),fn:X};this.extender.macros.push(Z)}else if(typeof X==="object"){for(let Y of Object.keys(X))if(typeof X[Y]==="object"){let $={...X[Y]};X[Y]=(W)=>{if(W===!0)return $}}let Z={checksum:BZ(JSON.stringify({name:this.config.name,seed:this.config.seed,content:Object.entries(X).map(([Y,$])=>`${Y}+${$}`).join(",")})),fn:()=>X};this.extender.macros.push(Z)}return this}mount(X,Z){if(X instanceof O2||typeof X==="function"||X.length===0||X==="/"){let W=typeof X==="function"?X:X instanceof O2?X.compile().fetch:Z instanceof O2?Z.compile().fetch:Z,J=({request:z,path:Q})=>W(new Request(Y5(z.url,Q),{method:z.method,headers:z.headers,signal:z.signal,credentials:z.credentials,referrerPolicy:z.referrerPolicy,duplex:z.duplex,redirect:z.redirect,mode:z.mode,keepalive:z.keepalive,integrity:z.integrity,body:z.body}));return this.all("/*",J,{parse:"none"}),this}if(!Z)return this;let Y=X.length-(X.endsWith("*")?1:0);if(Z instanceof O2)Z=Z.compile().fetch;let $=({request:W,path:J})=>Z(new Request(Y5(W.url,J.slice(Y)||"/"),{method:W.method,headers:W.headers,signal:W.signal,credentials:W.credentials,referrerPolicy:W.referrerPolicy,duplex:W.duplex,redirect:W.redirect,mode:W.mode,keepalive:W.keepalive,integrity:W.integrity,body:W.body}));return this.all(X,$,{parse:"none"}),this.all(X+(X.endsWith("/")?"*":"/*"),$,{parse:"none"}),this}get(X,Z,Y){return this.add("GET",X,Z,Y),this}post(X,Z,Y){return this.add("POST",X,Z,Y),this}put(X,Z,Y){return this.add("PUT",X,Z,Y),this}patch(X,Z,Y){return this.add("PATCH",X,Z,Y),this}delete(X,Z,Y){return this.add("DELETE",X,Z,Y),this}options(X,Z,Y){return this.add("OPTIONS",X,Z,Y),this}all(X,Z,Y){return this.add("ALL",X,Z,Y),this}head(X,Z,Y){return this.add("HEAD",X,Z,Y),this}connect(X,Z,Y){return this.add("CONNECT",X,Z,Y),this}route(X,Z,Y,$){return this.add(X.toUpperCase(),Z,Y,$,$?.config),this}ws(X,Z){if(this["~adapter"].ws)this["~adapter"].ws(this,X,Z);else console.warn("Current adapter doesn't support WebSocket");return this}state(X,Z,Y){if(Z===void 0)Y=X,X={as:"append"},Z="";else if(Y===void 0){if(typeof X==="string")Y=Z,Z=X,X={as:"append"};else if(typeof X==="object")Y=Z,Z=""}let{as:$}=X;if(typeof Z!=="string")return this;switch(typeof Y){case"object":if(Z){if(Z in this.singleton.store)this.singleton.store[Z]=c0(this.singleton.store[Z],Y,{override:$==="override"});else this.singleton.store[Z]=Y;return this}if(Y===null)return this;return this.singleton.store=c0(this.singleton.store,Y,{override:$==="override"}),this;case"function":if(Z){if($==="override"||!(Z in this.singleton.store))this.singleton.store[Z]=Y}else this.singleton.store=Y(this.singleton.store);return this;default:if($==="override"||!(Z in this.singleton.store))this.singleton.store[Z]=Y;return this}}decorate(X,Z,Y){if(Z===void 0)Y=X,X={as:"append"},Z="";else if(Y===void 0){if(typeof X==="string")Y=Z,Z=X,X={as:"append"};else if(typeof X==="object")Y=Z,Z=""}let{as:$}=X;if(typeof Z!=="string")return this;switch(typeof Y){case"object":if(Z){if(Z in this.singleton.decorator)this.singleton.decorator[Z]=c0(this.singleton.decorator[Z],Y,{override:$==="override"});else this.singleton.decorator[Z]=Y;return this}if(Y===null)return this;return this.singleton.decorator=c0(this.singleton.decorator,Y,{override:$==="override"}),this;case"function":if(Z){if($==="override"||!(Z in this.singleton.decorator))this.singleton.decorator[Z]=Y}else this.singleton.decorator=Y(this.singleton.decorator);return this;default:if($==="override"||!(Z in this.singleton.decorator))this.singleton.decorator[Z]=Y;return this}}derive(X,Z){if(!Z)Z=X,X={as:"local"};let Y={subType:"derive",fn:Z};return this.onTransform(X,Y)}model(X,Z){let Y=($)=>J6($,[{from:_.Number(),to:(W)=>_.Numeric(W),untilObjectFound:!0},{from:_.Boolean(),to:(W)=>_.BooleanString(W),untilObjectFound:!0}]);switch(typeof X){case"object":let $={},W=Object.entries(X);for(let[Q,M]of W){if(Q in this.definitions.type)continue;$[Q]=this.definitions.type[Q]=Y(M),$[Q].$id??=`#/components/schemas/${Q}`}return this.definitions.typebox=_.Module({...this.definitions.typebox.$defs,...$}),this;case"function":let J=Y(X(this.definitions.type));return this.definitions.type=J,this.definitions.typebox=_.Module(J),this;case"string":if(!Z)break;let z={...Z,id:Z.$id??`#/components/schemas/${X}`};return this.definitions.type[X]=Z,this.definitions.typebox=_.Module({...this.definitions.typebox.$defs,...z}),this}return this.definitions.type[X]=Z,this.definitions.typebox=_.Module({...this.definitions.typebox.$defs,[X]:Z}),this}mapDerive(X,Z){if(!Z)Z=X,X={as:"local"};let Y={subType:"mapDerive",fn:Z};return this.onTransform(X,Y)}affix(X,Z,Y){if(Y==="")return this;let $=["_","-"," "],W=(M)=>M[0].toUpperCase()+M.slice(1),J=X==="prefix"?(M,G)=>$.includes(M.at(-1)??"")?M+G:M+W(G):$.includes(Y.at(-1)??"")?(M,G)=>G+M:(M,G)=>G+W(M),z=(M)=>{let G={};switch(M){case"decorator":for(let U in this.singleton.decorator)G[J(Y,U)]=this.singleton.decorator[U];this.singleton.decorator=G;break;case"state":for(let U in this.singleton.store)G[J(Y,U)]=this.singleton.store[U];this.singleton.store=G;break;case"model":for(let U in this.definitions.type)G[J(Y,U)]=this.definitions.type[U];this.definitions.type=G;break;case"error":for(let U in this.definitions.error)G[J(Y,U)]=this.definitions.error[U];this.definitions.error=G;break}},Q=Array.isArray(Z)?Z:[Z];for(let M of Q.some((G)=>G==="all")?["decorator","state","model","error"]:Q)z(M);return this}prefix(X,Z){return this.affix("prefix",X,Z)}suffix(X,Z){return this.affix("suffix",X,Z)}compile(){if(this["~adapter"].isWebStandard){if(this.fetch=this.config.aot?Y6(this):B5(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=Y6(this),this}handle=async(X)=>this.fetch(X);fetch=(X)=>{return(this.fetch=this.config.aot?Y6(this):B5(this))(X)};handleError=async(X,Z)=>{return(this.handleError=this.config.aot?p5(this):nN(this))(X,Z)};outerErrorHandler=(X)=>new Response(X.message||X.name||"Error",{status:X?.status??500});listen=(X,Z)=>{return this["~adapter"].listen(this)(X,Z),this};stop=async(X)=>{if(!this.server)throw new Error("Elysia isn't running. Call `app.listen` to start the server.");if(this.server){if(this.server.stop(X),this.server=null,this.event.stop?.length)for(let Z=0;Za});var A=Symbol.for("drizzle:entityKind"),ex=Symbol.for("drizzle:hasOwnEntityKind");function V(X,Z){if(!X||typeof X!=="object")return!1;if(X instanceof Z)return!0;if(!Object.prototype.hasOwnProperty.call(Z,A))throw new Error(`Class "${Z.name??""}" doesn't look like a Drizzle entity. If this is incorrect and the class is provided by Drizzle, please report this as a bug.`);let Y=Object.getPrototypeOf(X).constructor;if(Y)while(Y){if(A in Y&&Y[A]===Z[A])return!0;Y=Object.getPrototypeOf(Y)}return!1}class S8{constructor(X,Z){this.table=X,this.config=Z,this.name=Z.name,this.keyAsName=Z.keyAsName,this.notNull=Z.notNull,this.default=Z.default,this.defaultFn=Z.defaultFn,this.onUpdateFn=Z.onUpdateFn,this.hasDefault=Z.hasDefault,this.primary=Z.primaryKey,this.isUnique=Z.isUnique,this.uniqueName=Z.uniqueName,this.uniqueType=Z.uniqueType,this.dataType=Z.dataType,this.columnType=Z.columnType,this.generated=Z.generated,this.generatedIdentity=Z.generatedIdentity}static[A]="Column";name;keyAsName;primary;notNull;default;defaultFn;onUpdateFn;hasDefault;isUnique;uniqueName;uniqueType;dataType;columnType;enumValues=void 0;generated=void 0;generatedIdentity=void 0;config;mapFromDriverValue(X){return X}mapToDriverValue(X){return X}shouldDisableInsert(){return this.config.generated!==void 0&&this.config.generated.type!=="byDefault"}}class A6{static[A]="ColumnBuilder";config;constructor(X,Z,Y){this.config={name:X,keyAsName:X==="",notNull:!1,default:void 0,hasDefault:!1,primaryKey:!1,isUnique:!1,uniqueName:void 0,uniqueType:void 0,dataType:Z,columnType:Y,generated:void 0}}$type(){return this}notNull(){return this.config.notNull=!0,this}default(X){return this.config.default=X,this.config.hasDefault=!0,this}$defaultFn(X){return this.config.defaultFn=X,this.config.hasDefault=!0,this}$default=this.$defaultFn;$onUpdateFn(X){return this.config.onUpdateFn=X,this.config.hasDefault=!0,this}$onUpdate=this.$onUpdateFn;primaryKey(){return this.config.primaryKey=!0,this.config.notNull=!0,this}setName(X){if(this.config.name!=="")return;this.config.name=X}}var n2=Symbol.for("drizzle:Name");class _6{static[A]="PgForeignKeyBuilder";reference;_onUpdate="no action";_onDelete="no action";constructor(X,Z){if(this.reference=()=>{let{name:Y,columns:$,foreignColumns:W}=X();return{name:Y,columns:$,foreignTable:W[0].table,foreignColumns:W}},Z)this._onUpdate=Z.onUpdate,this._onDelete=Z.onDelete}onUpdate(X){return this._onUpdate=X===void 0?"no action":X,this}onDelete(X){return this._onDelete=X===void 0?"no action":X,this}build(X){return new c5(X,this)}}class c5{constructor(X,Z){this.table=X,this.reference=Z.reference,this.onUpdate=Z._onUpdate,this.onDelete=Z._onDelete}static[A]="PgForeignKey";reference;onUpdate;onDelete;getName(){let{name:X,columns:Z,foreignColumns:Y}=this.reference(),$=Z.map((z)=>z.name),W=Y.map((z)=>z.name),J=[this.table[n2],...$,Y[0].table[n2],...W];return X??`${J.join("_")}_fk`}}function kY(X,...Z){return X(...Z)}function u5(X){return new o5(X)}function w6(X,Z){return`${X[n2]}_${Z.join("_")}_unique`}class i5{constructor(X,Z){this.name=Z,this.columns=X}static[A]="PgUniqueConstraintBuilder";columns;nullsNotDistinctConfig=!1;nullsNotDistinct(){return this.nullsNotDistinctConfig=!0,this}build(X){return new n5(X,this.columns,this.nullsNotDistinctConfig,this.name)}}class o5{static[A]="PgUniqueOnConstraintBuilder";name;constructor(X){this.name=X}on(...X){return new i5(X,this.name)}}class n5{constructor(X,Z,Y,$){this.table=X,this.columns=Z,this.name=$??w6(this.table,this.columns.map((W)=>W.name)),this.nullsNotDistinct=Y}static[A]="PgUniqueConstraint";columns;name;nullsNotDistinct=!1;getName(){return this.name}}function l5(X,Z,Y){for(let $=Z;${if(Array.isArray(Z))return O6(Z);if(typeof Z==="string")return`"${Z.replace(/\\/g,"\\\\").replace(/"/g,"\\\"")}"`;return`${Z}`}).join(",")}}`}class i extends A6{foreignKeyConfigs=[];static[A]="PgColumnBuilder";array(X){return new a5(this.config.name,this,X)}references(X,Z={}){return this.foreignKeyConfigs.push({ref:X,actions:Z}),this}unique(X,Z){return this.config.isUnique=!0,this.config.uniqueName=X,this.config.uniqueType=Z?.nulls,this}generatedAlwaysAs(X){return this.config.generated={as:X,type:"always",mode:"stored"},this}buildForeignKeys(X,Z){return this.foreignKeyConfigs.map(({ref:Y,actions:$})=>{return kY((W,J)=>{let z=new _6(()=>{let Q=W();return{columns:[X],foreignColumns:[Q]}});if(J.onUpdate)z.onUpdate(J.onUpdate);if(J.onDelete)z.onDelete(J.onDelete);return z.build(Z)},Y,$)})}buildExtraConfigColumn(X){return new r5(X,this.config)}}class f extends S8{constructor(X,Z){if(!Z.uniqueName)Z.uniqueName=w6(X,[Z.name]);super(X,Z);this.table=X}static[A]="PgColumn"}class r5 extends f{static[A]="ExtraConfigColumn";getSQLType(){return this.getSQLType()}indexConfig={order:this.config.order??"asc",nulls:this.config.nulls??"last",opClass:this.config.opClass};defaultConfig={order:"asc",nulls:"last",opClass:void 0};asc(){return this.indexConfig.order="asc",this}desc(){return this.indexConfig.order="desc",this}nullsFirst(){return this.indexConfig.nulls="first",this}nullsLast(){return this.indexConfig.nulls="last",this}op(X){return this.indexConfig.opClass=X,this}}class a5 extends i{static[A]="PgArrayBuilder";constructor(X,Z,Y){super(X,"array","PgArray");this.config.baseBuilder=Z,this.config.size=Y}build(X){let Z=this.config.baseBuilder.build(X);return new N6(X,this.config,Z)}}class N6 extends f{constructor(X,Z,Y,$){super(X,Z);this.baseColumn=Y,this.range=$,this.size=Z.size}size;static[A]="PgArray";getSQLType(){return`${this.baseColumn.getSQLType()}[${typeof this.size==="number"?this.size:""}]`}mapFromDriverValue(X){if(typeof X==="string")X=s5(X);return X.map((Z)=>this.baseColumn.mapFromDriverValue(Z))}mapToDriverValue(X,Z=!1){let Y=X.map(($)=>$===null?null:V(this.baseColumn,N6)?this.baseColumn.mapToDriverValue($,!0):this.baseColumn.mapToDriverValue($));if(Z)return Y;return O6(Y)}}var e5=Symbol.for("drizzle:isPgEnum");function X4(X){return!!X&&typeof X==="function"&&e5 in X&&X[e5]===!0}class lN extends f{static[A]="PgEnumColumn";enum=this.config.enum;enumValues=this.config.enum.enumValues;constructor(X,Z){super(X,Z);this.enum=Z.enum}getSQLType(){return this.enum.enumName}}class M0{static[A]="Subquery";constructor(X,Z,Y,$=!1){this._={brand:"Subquery",sql:X,selectedFields:Z,alias:Y,isWith:$}}}class SZ extends M0{static[A]="WithSubquery"}var Z4="0.41.0";var L6,F6,v8={startActiveSpan(X,Z){if(!L6)return Z();if(!F6)F6=L6.trace.getTracer("drizzle-orm",Z4);return kY((Y,$)=>$.startActiveSpan(X,(W)=>{try{return Z(W)}catch(J){throw W.setStatus({code:Y.SpanStatusCode.ERROR,message:J instanceof Error?J.message:"Unknown error"}),J}finally{W.end()}}),L6,F6)}};var y8=Symbol.for("drizzle:ViewBaseConfig");var gY=Symbol.for("drizzle:Schema"),fY=Symbol.for("drizzle:Columns"),Y4=Symbol.for("drizzle:ExtraConfigColumns"),B6=Symbol.for("drizzle:OriginalName"),q6=Symbol.for("drizzle:BaseName"),VZ=Symbol.for("drizzle:IsAlias"),$4=Symbol.for("drizzle:ExtraConfigBuilder"),W4=Symbol.for("drizzle:IsDrizzleTable");class d{static[A]="Table";static Symbol={Name:n2,Schema:gY,OriginalName:B6,Columns:fY,ExtraConfigColumns:Y4,BaseName:q6,IsAlias:VZ,ExtraConfigBuilder:$4};[n2];[B6];[gY];[fY];[Y4];[q6];[VZ]=!1;[W4]=!0;[$4]=void 0;constructor(X,Z,Y){this[n2]=this[B6]=X,this[gY]=Z,this[q6]=Y}}function K6(X){return typeof X==="object"&&X!==null&&W4 in X}function o0(X){return X[n2]}function w1(X){return`${X[gY]??"public"}.${X[n2]}`}function R6(X){return X!==null&&X!==void 0&&typeof X.getSQL==="function"}function tN(X){let Z={sql:"",params:[]};for(let Y of X)if(Z.sql+=Y.sql,Z.params.push(...Y.params),Y.typings?.length){if(!Z.typings)Z.typings=[];Z.typings.push(...Y.typings)}return Z}class U0{static[A]="StringChunk";value;constructor(X){this.value=Array.isArray(X)?X:[X]}getSQL(){return new m([this])}}class m{constructor(X){this.queryChunks=X}static[A]="SQL";decoder=z4;shouldInlineParams=!1;append(X){return this.queryChunks.push(...X.queryChunks),this}toQuery(X){return v8.startActiveSpan("drizzle.buildSQL",(Z)=>{let Y=this.buildQueryFromSourceParams(this.queryChunks,X);return Z?.setAttributes({"drizzle.query.text":Y.sql,"drizzle.query.params":JSON.stringify(Y.params)}),Y})}buildQueryFromSourceParams(X,Z){let Y=Object.assign({},Z,{inlineParams:Z.inlineParams||this.shouldInlineParams,paramStartIndex:Z.paramStartIndex||{value:0}}),{casing:$,escapeName:W,escapeParam:J,prepareTyping:z,inlineParams:Q,paramStartIndex:M}=Y;return tN(X.map((G)=>{if(V(G,U0))return{sql:G.value.join(""),params:[]};if(V(G,vY))return{sql:W(G.value),params:[]};if(G===void 0)return{sql:"",params:[]};if(Array.isArray(G)){let U=[new U0("(")];for(let[w,B]of G.entries())if(U.push(B),wX},Q4={mapToDriverValue:(X)=>X},pT={...z4,...Q4};class J2{constructor(X,Z=Q4){this.value=X,this.encoder=Z}static[A]="Param";brand;getSQL(){return new m([this])}}function O(X,...Z){let Y=[];if(Z.length>0||X.length>0&&X[0]!=="")Y.push(new U0(X[0]));for(let[$,W]of Z.entries())Y.push(W,new U0(X[$+1]));return new m(Y)}((X)=>{function Z(){return new m([])}X.empty=Z;function Y(M){return new m(M)}X.fromList=Y;function $(M){return new m([new U0(M)])}X.raw=$;function W(M,G){let U=[];for(let[w,B]of M.entries()){if(w>0&&G!==void 0)U.push(G);U.push(B)}return new m(U)}X.join=W;function J(M){return new vY(M)}X.identifier=J;function z(M){return new uX(M)}X.placeholder=z;function Q(M,G){return new J2(M,G)}X.param=Q})(O||(O={}));((X)=>{class Z{constructor(Y,$){this.sql=Y,this.fieldAlias=$}static[A]="SQL.Aliased";isSelectionField=!1;getSQL(){return this.sql}clone(){return new Z(this.sql,this.fieldAlias)}}X.Aliased=Z})(m||(m={}));class uX{constructor(X){this.name=X}static[A]="Placeholder";getSQL(){return new m([this])}}function j6(X,Z){return X.map((Y)=>{if(V(Y,uX)){if(!(Y.name in Z))throw new Error(`No value for placeholder "${Y.name}" was provided`);return Z[Y.name]}if(V(Y,J2)&&V(Y.value,uX)){if(!(Y.value.name in Z))throw new Error(`No value for placeholder "${Y.value.name}" was provided`);return Y.encoder.mapToDriverValue(Z[Y.value.name])}return Y})}var G4=Symbol.for("drizzle:IsDrizzleView");class n0{static[A]="View";[y8];[G4]=!0;constructor({name:X,schema:Z,selectedFields:Y,query:$}){this[y8]={name:X,originalName:X,schema:Z,selectedFields:Y,query:$,isExisting:!$,isAlias:!1}}getSQL(){return new m([this])}}function M4(X){return typeof X==="object"&&X!==null&&G4 in X}S8.prototype.getSQL=function(){return new m([this])};d.prototype.getSQL=function(){return new m([this])};M0.prototype.getSQL=function(){return new m([this])};class n1{constructor(X){this.table=X}static[A]="ColumnAliasProxyHandler";get(X,Z){if(Z==="table")return this.table;return X[Z]}}class EZ{constructor(X,Z){this.alias=X,this.replaceOriginalName=Z}static[A]="TableAliasProxyHandler";get(X,Z){if(Z===d.Symbol.IsAlias)return!0;if(Z===d.Symbol.Name)return this.alias;if(this.replaceOriginalName&&Z===d.Symbol.OriginalName)return this.alias;if(Z===y8)return{...X[y8],name:this.alias,isAlias:!0};if(Z===d.Symbol.Columns){let $=X[d.Symbol.Columns];if(!$)return $;let W={};return Object.keys($).map((J)=>{W[J]=new Proxy($[J],new n1(new Proxy(X,this)))}),W}let Y=X[Z];if(V(Y,S8))return new Proxy(Y,new n1(new Proxy(X,this)));return Y}}function yY(X,Z){return new Proxy(X,new EZ(Z,!1))}function YX(X,Z){return new Proxy(X,new n1(new Proxy(X.table,new EZ(Z,!1))))}function S6(X,Z){return new m.Aliased(CZ(X.sql,Z),X.fieldAlias)}function CZ(X,Z){return O.join(X.queryChunks.map((Y)=>{if(V(Y,S8))return YX(Y,Z);if(V(Y,m))return CZ(Y,Z);if(V(Y,m.Aliased))return S6(Y,Z);return Y}))}function U4(X,Z,Y){let $={},W=X.reduce((J,{path:z,field:Q},M)=>{let G;if(V(Q,S8))G=Q;else if(V(Q,m))G=Q.decoder;else G=Q.sql.decoder;let U=J;for(let[w,B]of z.entries())if(w0){for(let[J,z]of Object.entries($))if(typeof z==="string"&&!Y[z])W[J]=null}return W}function q2(X,Z){return Object.entries(X).reduce((Y,[$,W])=>{if(typeof $!=="string")return Y;let J=Z?[...Z,$]:[$];if(V(W,S8)||V(W,m)||V(W,m.Aliased))Y.push({path:J,field:W});else if(V(W,d))Y.push(...q2(W[d.Symbol.Columns],J));else Y.push(...q2(W,J));return Y},[])}function PZ(X,Z){let Y=Object.keys(X),$=Object.keys(Z);if(Y.length!==$.length)return!1;for(let[W,J]of Y.entries())if(J!==$[W])return!1;return!0}function dY(X,Z){let Y=Object.entries(Z).filter(([,$])=>$!==void 0).map(([$,W])=>{if(V(W,m)||V(W,S8))return[$,W];else return[$,new J2(W,X[d.Symbol.Columns][$])]});if(Y.length===0)throw new Error("No values to set");return Object.fromEntries(Y)}function H4(X,Z){for(let Y of Z)for(let $ of Object.getOwnPropertyNames(Y.prototype)){if($==="constructor")continue;Object.defineProperty(X.prototype,$,Object.getOwnPropertyDescriptor(Y.prototype,$)||Object.create(null))}}function hY(X){return X[d.Symbol.Columns]}function D4(X){return X[y8].selectedFields}function qX(X){return V(X,M0)?X._.alias:V(X,n0)?X[y8].name:V(X,m)?void 0:X[d.Symbol.IsAlias]?X[d.Symbol.Name]:X[d.Symbol.BaseName]}function w8(X,Z){return{name:typeof X==="string"&&X.length>0?X:"",config:typeof X==="object"?X:Z}}function A4(X){if(typeof X!=="object"||X===null)return!1;if(X.constructor.name!=="Object")return!1;if("logger"in X){let Z=typeof X.logger;if(Z!=="boolean"&&(Z!=="object"||typeof X.logger.logQuery!=="function")&&Z!=="undefined")return!1;return!0}if("schema"in X){let Z=typeof X.schema;if(Z!=="object"&&Z!=="undefined")return!1;return!0}if("casing"in X){let Z=typeof X.casing;if(Z!=="string"&&Z!=="undefined")return!1;return!0}if("mode"in X){if(X.mode!=="default"||X.mode!=="planetscale"||X.mode!==void 0)return!1;return!0}if("connection"in X){let Z=typeof X.connection;if(Z!=="string"&&Z!=="object"&&Z!=="undefined")return!1;return!0}if("client"in X){let Z=typeof X.client;if(Z!=="object"&&Z!=="function"&&Z!=="undefined")return!1;return!0}if(Object.keys(X).length===0)return!0;return!1}class iX extends i{static[A]="PgIntColumnBaseBuilder";generatedAlwaysAsIdentity(X){if(X){let{name:Z,...Y}=X;this.config.generatedIdentity={type:"always",sequenceName:Z,sequenceOptions:Y}}else this.config.generatedIdentity={type:"always"};return this.config.hasDefault=!0,this.config.notNull=!0,this}generatedByDefaultAsIdentity(X){if(X){let{name:Z,...Y}=X;this.config.generatedIdentity={type:"byDefault",sequenceName:Z,sequenceOptions:Y}}else this.config.generatedIdentity={type:"byDefault"};return this.config.hasDefault=!0,this.config.notNull=!0,this}}class _4 extends iX{static[A]="PgBigInt53Builder";constructor(X){super(X,"number","PgBigInt53")}build(X){return new w4(X,this.config)}}class w4 extends f{static[A]="PgBigInt53";getSQLType(){return"bigint"}mapFromDriverValue(X){if(typeof X==="number")return X;return Number(X)}}class O4 extends iX{static[A]="PgBigInt64Builder";constructor(X){super(X,"bigint","PgBigInt64")}build(X){return new N4(X,this.config)}}class N4 extends f{static[A]="PgBigInt64";getSQLType(){return"bigint"}mapFromDriverValue(X){return BigInt(X)}}function L4(X,Z){let{name:Y,config:$}=w8(X,Z);if($.mode==="number")return new _4(Y);return new O4(Y)}class F4 extends i{static[A]="PgBigSerial53Builder";constructor(X){super(X,"number","PgBigSerial53");this.config.hasDefault=!0,this.config.notNull=!0}build(X){return new B4(X,this.config)}}class B4 extends f{static[A]="PgBigSerial53";getSQLType(){return"bigserial"}mapFromDriverValue(X){if(typeof X==="number")return X;return Number(X)}}class q4 extends i{static[A]="PgBigSerial64Builder";constructor(X){super(X,"bigint","PgBigSerial64");this.config.hasDefault=!0}build(X){return new K4(X,this.config)}}class K4 extends f{static[A]="PgBigSerial64";getSQLType(){return"bigserial"}mapFromDriverValue(X){return BigInt(X)}}function R4(X,Z){let{name:Y,config:$}=w8(X,Z);if($.mode==="number")return new F4(Y);return new q4(Y)}class j4 extends i{static[A]="PgBooleanBuilder";constructor(X){super(X,"boolean","PgBoolean")}build(X){return new S4(X,this.config)}}class S4 extends f{static[A]="PgBoolean";getSQLType(){return"boolean"}}function V4(X){return new j4(X??"")}class E4 extends i{static[A]="PgCharBuilder";constructor(X,Z){super(X,"string","PgChar");this.config.length=Z.length,this.config.enumValues=Z.enum}build(X){return new C4(X,this.config)}}class C4 extends f{static[A]="PgChar";length=this.config.length;enumValues=this.config.enumValues;getSQLType(){return this.length===void 0?"char":`char(${this.length})`}}function P4(X,Z={}){let{name:Y,config:$}=w8(X,Z);return new E4(Y,$)}class I4 extends i{static[A]="PgCidrBuilder";constructor(X){super(X,"string","PgCidr")}build(X){return new x4(X,this.config)}}class x4 extends f{static[A]="PgCidr";getSQLType(){return"cidr"}}function T4(X){return new I4(X??"")}class b4 extends i{static[A]="PgCustomColumnBuilder";constructor(X,Z,Y){super(X,"custom","PgCustomColumn");this.config.fieldConfig=Z,this.config.customTypeParams=Y}build(X){return new k4(X,this.config)}}class k4 extends f{static[A]="PgCustomColumn";sqlName;mapTo;mapFrom;constructor(X,Z){super(X,Z);this.sqlName=Z.customTypeParams.dataType(Z.fieldConfig),this.mapTo=Z.customTypeParams.toDriver,this.mapFrom=Z.customTypeParams.fromDriver}getSQLType(){return this.sqlName}mapFromDriverValue(X){return typeof this.mapFrom==="function"?this.mapFrom(X):X}mapToDriverValue(X){return typeof this.mapTo==="function"?this.mapTo(X):X}}function g4(X){return(Z,Y)=>{let{name:$,config:W}=w8(Z,Y);return new b4($,W,X)}}class KX extends i{static[A]="PgDateColumnBaseBuilder";defaultNow(){return this.default(O`now()`)}}class f4 extends KX{static[A]="PgDateBuilder";constructor(X){super(X,"date","PgDate")}build(X){return new mY(X,this.config)}}class mY extends f{static[A]="PgDate";getSQLType(){return"date"}mapFromDriverValue(X){return new Date(X)}mapToDriverValue(X){return X.toISOString()}}class v4 extends KX{static[A]="PgDateStringBuilder";constructor(X){super(X,"string","PgDateString")}build(X){return new pY(X,this.config)}}class pY extends f{static[A]="PgDateString";getSQLType(){return"date"}}function y4(X,Z){let{name:Y,config:$}=w8(X,Z);if($?.mode==="date")return new f4(Y);return new v4(Y)}class d4 extends i{static[A]="PgDoublePrecisionBuilder";constructor(X){super(X,"number","PgDoublePrecision")}build(X){return new h4(X,this.config)}}class h4 extends f{static[A]="PgDoublePrecision";getSQLType(){return"double precision"}mapFromDriverValue(X){if(typeof X==="string")return Number.parseFloat(X);return X}}function l1(X){return new d4(X??"")}class m4 extends i{static[A]="PgInetBuilder";constructor(X){super(X,"string","PgInet")}build(X){return new p4(X,this.config)}}class p4 extends f{static[A]="PgInet";getSQLType(){return"inet"}}function c4(X){return new m4(X??"")}class u4 extends iX{static[A]="PgIntegerBuilder";constructor(X){super(X,"number","PgInteger")}build(X){return new i4(X,this.config)}}class i4 extends f{static[A]="PgInteger";getSQLType(){return"integer"}mapFromDriverValue(X){if(typeof X==="string")return Number.parseInt(X);return X}}function oX(X){return new u4(X??"")}class o4 extends i{static[A]="PgIntervalBuilder";constructor(X,Z){super(X,"string","PgInterval");this.config.intervalConfig=Z}build(X){return new n4(X,this.config)}}class n4 extends f{static[A]="PgInterval";fields=this.config.intervalConfig.fields;precision=this.config.intervalConfig.precision;getSQLType(){let X=this.fields?` ${this.fields}`:"",Z=this.precision?`(${this.precision})`:"";return`interval${X}${Z}`}}function l4(X,Z={}){let{name:Y,config:$}=w8(X,Z);return new o4(Y,$)}class t4 extends i{static[A]="PgJsonBuilder";constructor(X){super(X,"json","PgJson")}build(X){return new cY(X,this.config)}}class cY extends f{static[A]="PgJson";constructor(X,Z){super(X,Z)}getSQLType(){return"json"}mapToDriverValue(X){return JSON.stringify(X)}mapFromDriverValue(X){if(typeof X==="string")try{return JSON.parse(X)}catch{return X}return X}}function s4(X){return new t4(X??"")}class r4 extends i{static[A]="PgJsonbBuilder";constructor(X){super(X,"json","PgJsonb")}build(X){return new uY(X,this.config)}}class uY extends f{static[A]="PgJsonb";constructor(X,Z){super(X,Z)}getSQLType(){return"jsonb"}mapToDriverValue(X){return JSON.stringify(X)}mapFromDriverValue(X){if(typeof X==="string")try{return JSON.parse(X)}catch{return X}return X}}function a4(X){return new r4(X??"")}class e4 extends i{static[A]="PgLineBuilder";constructor(X){super(X,"array","PgLine")}build(X){return new XJ(X,this.config)}}class XJ extends f{static[A]="PgLine";getSQLType(){return"line"}mapFromDriverValue(X){let[Z,Y,$]=X.slice(1,-1).split(",");return[Number.parseFloat(Z),Number.parseFloat(Y),Number.parseFloat($)]}mapToDriverValue(X){return`{${X[0]},${X[1]},${X[2]}}`}}class ZJ extends i{static[A]="PgLineABCBuilder";constructor(X){super(X,"json","PgLineABC")}build(X){return new YJ(X,this.config)}}class YJ extends f{static[A]="PgLineABC";getSQLType(){return"line"}mapFromDriverValue(X){let[Z,Y,$]=X.slice(1,-1).split(",");return{a:Number.parseFloat(Z),b:Number.parseFloat(Y),c:Number.parseFloat($)}}mapToDriverValue(X){return`{${X.a},${X.b},${X.c}}`}}function $J(X,Z){let{name:Y,config:$}=w8(X,Z);if(!$?.mode||$.mode==="tuple")return new e4(Y);return new ZJ(Y)}class WJ extends i{static[A]="PgMacaddrBuilder";constructor(X){super(X,"string","PgMacaddr")}build(X){return new JJ(X,this.config)}}class JJ extends f{static[A]="PgMacaddr";getSQLType(){return"macaddr"}}function zJ(X){return new WJ(X??"")}class QJ extends i{static[A]="PgMacaddr8Builder";constructor(X){super(X,"string","PgMacaddr8")}build(X){return new GJ(X,this.config)}}class GJ extends f{static[A]="PgMacaddr8";getSQLType(){return"macaddr8"}}function MJ(X){return new QJ(X??"")}class UJ extends i{static[A]="PgNumericBuilder";constructor(X,Z,Y){super(X,"string","PgNumeric");this.config.precision=Z,this.config.scale=Y}build(X){return new iY(X,this.config)}}class iY extends f{static[A]="PgNumeric";precision;scale;constructor(X,Z){super(X,Z);this.precision=Z.precision,this.scale=Z.scale}mapFromDriverValue(X){if(typeof X==="string")return X;return String(X)}getSQLType(){if(this.precision!==void 0&&this.scale!==void 0)return`numeric(${this.precision}, ${this.scale})`;else if(this.precision===void 0)return"numeric";else return`numeric(${this.precision})`}}class HJ extends i{static[A]="PgNumericNumberBuilder";constructor(X,Z,Y){super(X,"number","PgNumericNumber");this.config.precision=Z,this.config.scale=Y}build(X){return new DJ(X,this.config)}}class DJ extends f{static[A]="PgNumericNumber";precision;scale;constructor(X,Z){super(X,Z);this.precision=Z.precision,this.scale=Z.scale}mapFromDriverValue(X){if(typeof X==="number")return X;return Number(X)}mapToDriverValue=String;getSQLType(){if(this.precision!==void 0&&this.scale!==void 0)return`numeric(${this.precision}, ${this.scale})`;else if(this.precision===void 0)return"numeric";else return`numeric(${this.precision})`}}class AJ extends i{static[A]="PgNumericBigIntBuilder";constructor(X,Z,Y){super(X,"bigint","PgNumericBigInt");this.config.precision=Z,this.config.scale=Y}build(X){return new _J(X,this.config)}}class _J extends f{static[A]="PgNumericBigInt";precision;scale;constructor(X,Z){super(X,Z);this.precision=Z.precision,this.scale=Z.scale}mapFromDriverValue=BigInt;mapToDriverValue=String;getSQLType(){if(this.precision!==void 0&&this.scale!==void 0)return`numeric(${this.precision}, ${this.scale})`;else if(this.precision===void 0)return"numeric";else return`numeric(${this.precision})`}}function wJ(X,Z){let{name:Y,config:$}=w8(X,Z),W=$?.mode;return W==="number"?new HJ(Y,$?.precision,$?.scale):W==="bigint"?new AJ(Y,$?.precision,$?.scale):new UJ(Y,$?.precision,$?.scale)}class OJ extends i{static[A]="PgPointTupleBuilder";constructor(X){super(X,"array","PgPointTuple")}build(X){return new NJ(X,this.config)}}class NJ extends f{static[A]="PgPointTuple";getSQLType(){return"point"}mapFromDriverValue(X){if(typeof X==="string"){let[Z,Y]=X.slice(1,-1).split(",");return[Number.parseFloat(Z),Number.parseFloat(Y)]}return[X.x,X.y]}mapToDriverValue(X){return`(${X[0]},${X[1]})`}}class LJ extends i{static[A]="PgPointObjectBuilder";constructor(X){super(X,"json","PgPointObject")}build(X){return new FJ(X,this.config)}}class FJ extends f{static[A]="PgPointObject";getSQLType(){return"point"}mapFromDriverValue(X){if(typeof X==="string"){let[Z,Y]=X.slice(1,-1).split(",");return{x:Number.parseFloat(Z),y:Number.parseFloat(Y)}}return X}mapToDriverValue(X){return`(${X.x},${X.y})`}}function BJ(X,Z){let{name:Y,config:$}=w8(X,Z);if(!$?.mode||$.mode==="tuple")return new OJ(Y);return new LJ(Y)}function sN(X){let Z=[];for(let Y=0;Y{if(typeof X==="string")return Number.parseFloat(X);return X}}function PJ(X){return new EJ(X??"")}class IJ extends i{static[A]="PgSerialBuilder";constructor(X){super(X,"number","PgSerial");this.config.hasDefault=!0,this.config.notNull=!0}build(X){return new xJ(X,this.config)}}class xJ extends f{static[A]="PgSerial";getSQLType(){return"serial"}}function TJ(X){return new IJ(X??"")}class bJ extends iX{static[A]="PgSmallIntBuilder";constructor(X){super(X,"number","PgSmallInt")}build(X){return new kJ(X,this.config)}}class kJ extends f{static[A]="PgSmallInt";getSQLType(){return"smallint"}mapFromDriverValue=(X)=>{if(typeof X==="string")return Number(X);return X}}function gJ(X){return new bJ(X??"")}class fJ extends i{static[A]="PgSmallSerialBuilder";constructor(X){super(X,"number","PgSmallSerial");this.config.hasDefault=!0,this.config.notNull=!0}build(X){return new vJ(X,this.config)}}class vJ extends f{static[A]="PgSmallSerial";getSQLType(){return"smallserial"}}function yJ(X){return new fJ(X??"")}class dJ extends i{static[A]="PgTextBuilder";constructor(X,Z){super(X,"string","PgText");this.config.enumValues=Z.enum}build(X){return new hJ(X,this.config)}}class hJ extends f{static[A]="PgText";enumValues=this.config.enumValues;getSQLType(){return"text"}}function mJ(X,Z={}){let{name:Y,config:$}=w8(X,Z);return new dJ(Y,$)}class pJ extends KX{constructor(X,Z,Y){super(X,"string","PgTime");this.withTimezone=Z,this.precision=Y,this.config.withTimezone=Z,this.config.precision=Y}static[A]="PgTimeBuilder";build(X){return new oY(X,this.config)}}class oY extends f{static[A]="PgTime";withTimezone;precision;constructor(X,Z){super(X,Z);this.withTimezone=Z.withTimezone,this.precision=Z.precision}getSQLType(){return`time${this.precision===void 0?"":`(${this.precision})`}${this.withTimezone?" with time zone":""}`}}function cJ(X,Z={}){let{name:Y,config:$}=w8(X,Z);return new pJ(Y,$.withTimezone??!1,$.precision)}class uJ extends KX{static[A]="PgTimestampBuilder";constructor(X,Z,Y){super(X,"date","PgTimestamp");this.config.withTimezone=Z,this.config.precision=Y}build(X){return new nY(X,this.config)}}class nY extends f{static[A]="PgTimestamp";withTimezone;precision;constructor(X,Z){super(X,Z);this.withTimezone=Z.withTimezone,this.precision=Z.precision}getSQLType(){return`timestamp${this.precision===void 0?"":` (${this.precision})`}${this.withTimezone?" with time zone":""}`}mapFromDriverValue=(X)=>{return new Date(this.withTimezone?X:X+"+0000")};mapToDriverValue=(X)=>{return X.toISOString()}}class iJ extends KX{static[A]="PgTimestampStringBuilder";constructor(X,Z,Y){super(X,"string","PgTimestampString");this.config.withTimezone=Z,this.config.precision=Y}build(X){return new lY(X,this.config)}}class lY extends f{static[A]="PgTimestampString";withTimezone;precision;constructor(X,Z){super(X,Z);this.withTimezone=Z.withTimezone,this.precision=Z.precision}getSQLType(){return`timestamp${this.precision===void 0?"":`(${this.precision})`}${this.withTimezone?" with time zone":""}`}}function oJ(X,Z={}){let{name:Y,config:$}=w8(X,Z);if($?.mode==="string")return new iJ(Y,$.withTimezone??!1,$.precision);return new uJ(Y,$?.withTimezone??!1,$?.precision)}class nJ extends i{static[A]="PgUUIDBuilder";constructor(X){super(X,"string","PgUUID")}defaultRandom(){return this.default(O`gen_random_uuid()`)}build(X){return new tY(X,this.config)}}class tY extends f{static[A]="PgUUID";getSQLType(){return"uuid"}}function sY(X){return new nJ(X??"")}class lJ extends i{static[A]="PgVarcharBuilder";constructor(X,Z){super(X,"string","PgVarchar");this.config.length=Z.length,this.config.enumValues=Z.enum}build(X){return new tJ(X,this.config)}}class tJ extends f{static[A]="PgVarchar";length=this.config.length;enumValues=this.config.enumValues;getSQLType(){return this.length===void 0?"varchar":`varchar(${this.length})`}}function nX(X,Z={}){let{name:Y,config:$}=w8(X,Z);return new lJ(Y,$)}class sJ extends i{static[A]="PgBinaryVectorBuilder";constructor(X,Z){super(X,"string","PgBinaryVector");this.config.dimensions=Z.dimensions}build(X){return new rJ(X,this.config)}}class rJ extends f{static[A]="PgBinaryVector";dimensions=this.config.dimensions;getSQLType(){return`bit(${this.dimensions})`}}function aJ(X,Z){let{name:Y,config:$}=w8(X,Z);return new sJ(Y,$)}class eJ extends i{static[A]="PgHalfVectorBuilder";constructor(X,Z){super(X,"array","PgHalfVector");this.config.dimensions=Z.dimensions}build(X){return new Xz(X,this.config)}}class Xz extends f{static[A]="PgHalfVector";dimensions=this.config.dimensions;getSQLType(){return`halfvec(${this.dimensions})`}mapToDriverValue(X){return JSON.stringify(X)}mapFromDriverValue(X){return X.slice(1,-1).split(",").map((Z)=>Number.parseFloat(Z))}}function Zz(X,Z){let{name:Y,config:$}=w8(X,Z);return new eJ(Y,$)}class Yz extends i{static[A]="PgSparseVectorBuilder";constructor(X,Z){super(X,"string","PgSparseVector");this.config.dimensions=Z.dimensions}build(X){return new $z(X,this.config)}}class $z extends f{static[A]="PgSparseVector";dimensions=this.config.dimensions;getSQLType(){return`sparsevec(${this.dimensions})`}}function Wz(X,Z){let{name:Y,config:$}=w8(X,Z);return new Yz(Y,$)}class Jz extends i{static[A]="PgVectorBuilder";constructor(X,Z){super(X,"array","PgVector");this.config.dimensions=Z.dimensions}build(X){return new zz(X,this.config)}}class zz extends f{static[A]="PgVector";dimensions=this.config.dimensions;getSQLType(){return`vector(${this.dimensions})`}mapToDriverValue(X){return JSON.stringify(X)}mapFromDriverValue(X){return X.slice(1,-1).split(",").map((Z)=>Number.parseFloat(Z))}}function Qz(X,Z){let{name:Y,config:$}=w8(X,Z);return new Jz(Y,$)}class T0{static[A]="QueryPromise";[Symbol.toStringTag]="QueryPromise";catch(X){return this.then(void 0,X)}finally(X){return this.then((Z)=>{return X?.(),Z},(Z)=>{throw X?.(),Z})}then(X,Z){return this.execute().then(X,Z)}}class X0{static[A]="SelectionProxyHandler";config;constructor(X){this.config={...X}}get(X,Z){if(Z==="_")return{...X._,selectedFields:new Proxy(X._.selectedFields,this)};if(Z===y8)return{...X[y8],selectedFields:new Proxy(X[y8].selectedFields,this)};if(typeof Z==="symbol")return X[Z];let $=(V(X,M0)?X._.selectedFields:V(X,n0)?X[y8].selectedFields:X)[Z];if(V($,m.Aliased)){if(this.config.sqlAliasedBehavior==="sql"&&!$.isSelectionField)return $.sql;let W=$.clone();return W.isSelectionField=!0,W}if(V($,m)){if(this.config.sqlBehavior==="sql")return $;throw new Error(`You tried to reference "${Z}" field from a subquery, which is a raw SQL field, but it doesn't have an alias declared. Please add an alias to the field using ".as('alias')" method.`)}if(V($,S8)){if(this.config.alias)return new Proxy($,new n1(new Proxy($.table,new EZ(this.config.alias,this.config.replaceOriginalName??!1))));return $}if(typeof $!=="object"||$===null)return $;return new Proxy($,new X0(this.config))}}class rY extends T0{constructor(X,Z,Y,$){super();this.session=Z,this.dialect=Y,this.config={table:X,withList:$}}static[A]="PgDelete";config;where(X){return this.config.where=X,this}returning(X=this.config.table[d.Symbol.Columns]){return this.config.returningFields=X,this.config.returning=q2(X),this}getSQL(){return this.dialect.buildDeleteQuery(this.config)}toSQL(){let{typings:X,...Z}=this.dialect.sqlToQuery(this.getSQL());return Z}_prepare(X){return v8.startActiveSpan("drizzle.prepareQuery",()=>{return this.session.prepareQuery(this.dialect.sqlToQuery(this.getSQL()),this.config.returning,X,!0)})}prepare(X){return this._prepare(X)}authToken;setToken(X){return this.authToken=X,this}execute=(X)=>{return v8.startActiveSpan("drizzle.operation",()=>{return this._prepare().execute(X,this.authToken)})};getSelectedFields(){return this.config.returningFields?new Proxy(this.config.returningFields,new X0({alias:o0(this.config.table),sqlAliasedBehavior:"alias",sqlBehavior:"error"})):void 0}$dynamic(){return this}}function rN(X){return(X.replace(/['\u2019]/g,"").match(/[\da-z]+|[A-Z]+(?![a-z])|[A-Z][\da-z]+/g)??[]).map((Y)=>Y.toLowerCase()).join("_")}function aN(X){return(X.replace(/['\u2019]/g,"").match(/[\da-z]+|[A-Z]+(?![a-z])|[A-Z][\da-z]+/g)??[]).reduce((Y,$,W)=>{let J=W===0?$.toLowerCase():`${$[0].toUpperCase()}${$.slice(1)}`;return Y+J},"")}function eN(X){return X}class E6{static[A]="CasingCache";cache={};cachedTables={};convert;constructor(X){this.convert=X==="snake_case"?rN:X==="camelCase"?aN:eN}getColumnCasing(X){if(!X.keyAsName)return X.name;let Z=X.table[d.Symbol.Schema]??"public",Y=X.table[d.Symbol.OriginalName],$=`${Z}.${Y}.${X.name}`;if(!this.cache[$])this.cacheTable(X.table);return this.cache[$]}cacheTable(X){let Z=X[d.Symbol.Schema]??"public",Y=X[d.Symbol.OriginalName],$=`${Z}.${Y}`;if(!this.cachedTables[$]){for(let W of Object.values(X[d.Symbol.Columns])){let J=`${$}.${W.name}`;this.cache[J]=this.convert(W.name)}this.cachedTables[$]=!0}}clearCache(){this.cache={},this.cachedTables={}}}class aY extends Error{static[A]="DrizzleError";constructor({message:X,cause:Z}){super(X);this.name="DrizzleError",this.cause=Z}}class C6 extends aY{static[A]="TransactionRollbackError";constructor(){super({message:"Rollback"})}}function Gz(){return{bigint:L4,bigserial:R4,boolean:V4,char:P4,cidr:T4,customType:g4,date:y4,doublePrecision:l1,inet:c4,integer:oX,interval:l4,json:s4,jsonb:a4,line:$J,macaddr:zJ,macaddr8:MJ,numeric:wJ,point:BJ,geometry:VJ,real:PJ,serial:TJ,smallint:gJ,smallserial:yJ,text:mJ,time:cJ,timestamp:oJ,uuid:sY,varchar:nX,bit:aJ,halfvec:Zz,sparsevec:Wz,vector:Qz}}var P6=Symbol.for("drizzle:PgInlineForeignKeys"),Mz=Symbol.for("drizzle:EnableRLS");class q0 extends d{static[A]="PgTable";static Symbol=Object.assign({},d.Symbol,{InlineForeignKeys:P6,EnableRLS:Mz});[P6]=[];[Mz]=!1;[d.Symbol.ExtraConfigBuilder]=void 0;[d.Symbol.ExtraConfigColumns]={}}function XL(X,Z,Y,$,W=X){let J=new q0(X,$,W),z=typeof Z==="function"?Z(Gz()):Z,Q=Object.fromEntries(Object.entries(z).map(([U,w])=>{let B=w;B.setName(U);let N=B.build(J);return J[P6].push(...B.buildForeignKeys(N,J)),[U,N]})),M=Object.fromEntries(Object.entries(z).map(([U,w])=>{let B=w;B.setName(U);let N=B.buildExtraConfigColumn(J);return[U,N]})),G=Object.assign(J,Q);if(G[d.Symbol.Columns]=Q,G[d.Symbol.ExtraConfigColumns]=M,Y)G[q0.Symbol.ExtraConfigBuilder]=Y;return Object.assign(G,{enableRLS:()=>{return G[q0.Symbol.EnableRLS]=!0,G}})}var Uz=(X,Z,Y)=>{return XL(X,Z,Y,void 0)};class I6{static[A]="PgPrimaryKeyBuilder";columns;name;constructor(X,Z){this.columns=X,this.name=Z}build(X){return new Hz(X,this.columns,this.name)}}class Hz{constructor(X,Z,Y){this.table=X,this.columns=Z,this.name=Y}static[A]="PgPrimaryKey";columns;name;getName(){return this.name??`${this.table[q0.Symbol.Name]}_${this.columns.map((X)=>X.name).join("_")}_pk`}}function l0(X,Z){if(J4(Z)&&!R6(X)&&!V(X,J2)&&!V(X,uX)&&!V(X,S8)&&!V(X,d)&&!V(X,n0))return new J2(X,Z);return X}var K2=(X,Z)=>{return O`${X} = ${l0(Z,X)}`},Dz=(X,Z)=>{return O`${X} <> ${l0(Z,X)}`};function RX(...X){let Z=X.filter((Y)=>Y!==void 0);if(Z.length===0)return;if(Z.length===1)return new m(Z);return new m([new U0("("),O.join(Z,new U0(" and ")),new U0(")")])}function Az(...X){let Z=X.filter((Y)=>Y!==void 0);if(Z.length===0)return;if(Z.length===1)return new m(Z);return new m([new U0("("),O.join(Z,new U0(" or ")),new U0(")")])}function _z(X){return O`not ${X}`}var wz=(X,Z)=>{return O`${X} > ${l0(Z,X)}`},Oz=(X,Z)=>{return O`${X} >= ${l0(Z,X)}`},Nz=(X,Z)=>{return O`${X} < ${l0(Z,X)}`},Lz=(X,Z)=>{return O`${X} <= ${l0(Z,X)}`};function t1(X,Z){if(Array.isArray(Z)){if(Z.length===0)return O`false`;return O`${X} in ${Z.map((Y)=>l0(Y,X))}`}return O`${X} in ${l0(Z,X)}`}function Fz(X,Z){if(Array.isArray(Z)){if(Z.length===0)return O`true`;return O`${X} not in ${Z.map((Y)=>l0(Y,X))}`}return O`${X} not in ${l0(Z,X)}`}function Bz(X){return O`${X} is null`}function qz(X){return O`${X} is not null`}function Kz(X){return O`exists ${X}`}function Rz(X){return O`not exists ${X}`}function R2(X,Z,Y){return O`${X} between ${l0(Z,X)} and ${l0(Y,X)}`}function jz(X,Z,Y){return O`${X} not between ${l0(Z,X)} and ${l0(Y,X)}`}function Sz(X,Z){return O`${X} like ${Z}`}function Vz(X,Z){return O`${X} not like ${Z}`}function Ez(X,Z){return O`${X} ilike ${Z}`}function Cz(X,Z){return O`${X} not ilike ${Z}`}function eY(X){return O`${X} asc`}function X$(X){return O`${X} desc`}class x6{constructor(X,Z,Y){this.sourceTable=X,this.referencedTable=Z,this.relationName=Y,this.referencedTableName=Z[d.Symbol.Name]}static[A]="Relation";referencedTableName;fieldName}class Pz{constructor(X,Z){this.table=X,this.config=Z}static[A]="Relations"}class lX extends x6{constructor(X,Z,Y,$){super(X,Z,Y?.relationName);this.config=Y,this.isNullable=$}static[A]="One";withFieldName(X){let Z=new lX(this.sourceTable,this.referencedTable,this.config,this.isNullable);return Z.fieldName=X,Z}}class IZ extends x6{constructor(X,Z,Y){super(X,Z,Y?.relationName);this.config=Y}static[A]="Many";withFieldName(X){let Z=new IZ(this.sourceTable,this.referencedTable,this.config);return Z.fieldName=X,Z}}function Iz(){return{and:RX,between:R2,eq:K2,exists:Kz,gt:wz,gte:Oz,ilike:Ez,inArray:t1,isNull:Bz,isNotNull:qz,like:Sz,lt:Nz,lte:Lz,ne:Dz,not:_z,notBetween:jz,notExists:Rz,notLike:Vz,notIlike:Cz,notInArray:Fz,or:Az,sql:O}}function xz(){return{sql:O,asc:eY,desc:X$}}function Tz(X,Z){if(Object.keys(X).length===1&&"default"in X&&!V(X.default,d))X=X.default;let Y={},$={},W={};for(let[J,z]of Object.entries(X))if(V(z,d)){let Q=w1(z),M=$[Q];Y[Q]=J,W[J]={tsName:J,dbName:z[d.Symbol.Name],schema:z[d.Symbol.Schema],columns:z[d.Symbol.Columns],relations:M?.relations??{},primaryKey:M?.primaryKey??[]};for(let U of Object.values(z[d.Symbol.Columns]))if(U.primary)W[J].primaryKey.push(U);let G=z[d.Symbol.ExtraConfigBuilder]?.(z[d.Symbol.ExtraConfigColumns]);if(G){for(let U of Object.values(G))if(V(U,I6))W[J].primaryKey.push(...U.columns)}}else if(V(z,Pz)){let Q=w1(z.table),M=Y[Q],G=z.config(Z(z.table)),U;for(let[w,B]of Object.entries(G))if(M){let N=W[M];if(N.relations[w]=B,U)N.primaryKey.push(...U)}else{if(!(Q in $))$[Q]={relations:{},primaryKey:U};$[Q].relations[w]=B}}return{tables:W,tableNamesMap:Y}}function ZL(X){return function Z(Y,$){return new lX(X,Y,$,$?.fields.reduce((W,J)=>W&&J.notNull,!0)??!1)}}function YL(X){return function Z(Y,$){return new IZ(X,Y,$)}}function bz(X,Z,Y){if(V(Y,lX)&&Y.config)return{fields:Y.config.fields,references:Y.config.references};let $=Z[w1(Y.referencedTable)];if(!$)throw new Error(`Table "${Y.referencedTable[d.Symbol.Name]}" not found in schema`);let W=X[$];if(!W)throw new Error(`Table "${$}" not found in schema`);let J=Y.sourceTable,z=Z[w1(J)];if(!z)throw new Error(`Table "${J[d.Symbol.Name]}" not found in schema`);let Q=[];for(let M of Object.values(W.relations))if(Y.relationName&&Y!==M&&M.relationName===Y.relationName||!Y.relationName&&M.referencedTable===Y.sourceTable)Q.push(M);if(Q.length>1)throw Y.relationName?new Error(`There are multiple relations with name "${Y.relationName}" in table "${$}"`):new Error(`There are multiple relations between "${$}" and "${Y.sourceTable[d.Symbol.Name]}". Please specify relation name`);if(Q[0]&&V(Q[0],lX)&&Q[0].config)return{fields:Q[0].config.references,references:Q[0].config.fields};throw new Error(`There is not enough information to infer relation "${z}.${Y.fieldName}"`)}function kz(X){return{one:ZL(X),many:YL(X)}}function Z$(X,Z,Y,$,W=(J)=>J){let J={};for(let[z,Q]of $.entries())if(Q.isJson){let M=Z.relations[Q.tsKey],G=Y[z],U=typeof G==="string"?JSON.parse(G):G;J[Q.tsKey]=V(M,lX)?U&&Z$(X,X[Q.relationTableTsKey],U,Q.selection,W):U.map((w)=>Z$(X,X[Q.relationTableTsKey],w,Q.selection,W))}else{let M=W(Y[z]),G=Q.field,U;if(V(G,S8))U=G;else if(V(G,m))U=G.decoder;else U=G.sql.decoder;J[Q.tsKey]=M===null?null:U.mapFromDriverValue(M)}return J}function gz(X){return O`count(${X||O.raw("*")})`.mapWith(Number)}function Y$(X){return O`max(${X})`.mapWith(V(X,S8)?X:String)}function $$(X){return O`min(${X})`.mapWith(V(X,S8)?X:String)}class xZ extends n0{static[A]="PgViewBase"}class O1{static[A]="PgDialect";casing;constructor(X){this.casing=new E6(X?.casing)}async migrate(X,Z,Y){let $=typeof Y==="string"?"__drizzle_migrations":Y.migrationsTable??"__drizzle_migrations",W=typeof Y==="string"?"drizzle":Y.migrationsSchema??"drizzle",J=O` - CREATE TABLE IF NOT EXISTS ${O.identifier(W)}.${O.identifier($)} ( - id SERIAL PRIMARY KEY, - hash text NOT NULL, - created_at bigint - ) - `;await Z.execute(O`CREATE SCHEMA IF NOT EXISTS ${O.identifier(W)}`),await Z.execute(J);let Q=(await Z.all(O`select id, hash, created_at from ${O.identifier(W)}.${O.identifier($)} order by created_at desc limit 1`))[0];await Z.transaction(async(M)=>{for await(let G of X)if(!Q||Number(Q.created_at)Z[J]!==void 0||Y[J]?.onUpdateFn!==void 0),W=$.length;return O.join($.flatMap((J,z)=>{let Q=Y[J],M=Z[J]??O.param(Q.onUpdateFn(),Q),G=O`${O.identifier(this.casing.getColumnCasing(Q))} = ${M}`;if(z{let z=[];if(V(W,m.Aliased)&&W.isSelectionField)z.push(O.identifier(W.fieldAlias));else if(V(W,m.Aliased)||V(W,m)){let Q=V(W,m.Aliased)?W.sql:W;if(Z)z.push(new m(Q.queryChunks.map((M)=>{if(V(M,f))return O.identifier(this.casing.getColumnCasing(M));return M})));else z.push(Q);if(V(W,m.Aliased))z.push(O` as ${O.identifier(W.fieldAlias)}`)}else if(V(W,S8))if(Z)z.push(O.identifier(this.casing.getColumnCasing(W)));else z.push(W);if(Jz?.some(({alias:d8})=>d8===(H0[d.Symbol.IsAlias]?o0(H0):H0[d.Symbol.BaseName])))(U8.field.table)){let H0=o0(U8.field.table);throw new Error(`Your "${U8.path.join("->")}" field references a column "${H0}"."${U8.field.name}", but the table "${H0}" is not part of the query! Did you forget to join it?`)}let H=!z||z.length===0,E=this.buildWithCTE(X),h;if(B)h=B===!0?O` distinct`:O` distinct on (${O.join(B.on,O`, `)})`;let Y8=this.buildSelection(S,{isSingleTable:H}),s=this.buildFromTable(J),V8=this.buildJoins(z),G8=$?O` where ${$}`:void 0,I=W?O` having ${W}`:void 0,P;if(Q&&Q.length>0)P=O` order by ${O.join(Q,O`, `)}`;let k;if(M&&M.length>0)k=O` group by ${O.join(M,O`, `)}`;let b=typeof G==="object"||typeof G==="number"&&G>=0?O` limit ${G}`:void 0,$8=U?O` offset ${U}`:void 0,J8=O.empty();if(w){let U8=O` for ${O.raw(w.strength)}`;if(w.config.of)U8.append(O` of ${O.join(Array.isArray(w.config.of)?w.config.of:[w.config.of],O`, `)}`);if(w.config.noWait)U8.append(O` no wait`);else if(w.config.skipLocked)U8.append(O` skip locked`);J8.append(U8)}let X8=O`${E}select${h} ${Y8} from ${s}${V8}${G8}${k}${I}${P}${b}${$8}${J8}`;if(N.length>0)return this.buildSetOperations(X8,N);return X8}buildSetOperations(X,Z){let[Y,...$]=Z;if(!Y)throw new Error("Cannot pass undefined values to any set operator");if($.length===0)return this.buildSetOperationQuery({leftSelect:X,setOperator:Y});return this.buildSetOperations(this.buildSetOperationQuery({leftSelect:X,setOperator:Y}),$)}buildSetOperationQuery({leftSelect:X,setOperator:{type:Z,isAll:Y,rightSelect:$,limit:W,orderBy:J,offset:z}}){let Q=O`(${X.getSQL()}) `,M=O`(${$.getSQL()})`,G;if(J&&J.length>0){let N=[];for(let S of J)if(V(S,f))N.push(O.identifier(S.name));else if(V(S,m)){for(let H=0;H=0?O` limit ${W}`:void 0,w=O.raw(`${Z} ${Y?"all ":""}`),B=z?O` offset ${z}`:void 0;return O`${Q}${w}${M}${G}${U}${B}`}buildInsertQuery({table:X,values:Z,onConflict:Y,returning:$,withList:W,select:J,overridingSystemValue_:z}){let Q=[],M=X[d.Symbol.Columns],G=Object.entries(M).filter(([E,h])=>!h.shouldDisableInsert()),U=G.map(([,E])=>O.identifier(this.casing.getColumnCasing(E)));if(J){let E=Z;if(V(E,m))Q.push(E);else Q.push(E.getSQL())}else{let E=Z;Q.push(O.raw("values "));for(let[h,Y8]of E.entries()){let s=[];for(let[V8,G8]of G){let I=Y8[V8];if(I===void 0||V(I,J2)&&I.value===void 0)if(G8.defaultFn!==void 0){let P=G8.defaultFn(),k=V(P,m)?P:O.param(P,G8);s.push(k)}else if(!G8.default&&G8.onUpdateFn!==void 0){let P=G8.onUpdateFn(),k=V(P,m)?P:O.param(P,G8);s.push(k)}else s.push(O`default`);else s.push(I)}if(Q.push(s),h({dbKey:Y8.name,tsKey:h,field:YX(Y8,z),relationTableTsKey:void 0,isJson:!1,selection:[]}));else{let E=Object.fromEntries(Object.entries(W.columns).map(([I,P])=>[I,YX(P,z)]));if(J.where){let I=typeof J.where==="function"?J.where(E,Iz()):J.where;N=I&&CZ(I,z)}let h=[],Y8=[];if(J.columns){let I=!1;for(let[P,k]of Object.entries(J.columns)){if(k===void 0)continue;if(P in W.columns){if(!I&&k===!0)I=!0;Y8.push(P)}}if(Y8.length>0)Y8=I?Y8.filter((P)=>J.columns?.[P]===!0):Object.keys(W.columns).filter((P)=>!Y8.includes(P))}else Y8=Object.keys(W.columns);for(let I of Y8){let P=W.columns[I];h.push({tsKey:I,value:P})}let s=[];if(J.with)s=Object.entries(J.with).filter((I)=>!!I[1]).map(([I,P])=>({tsKey:I,queryConfig:P,relation:W.relations[I]}));let V8;if(J.extras){V8=typeof J.extras==="function"?J.extras(E,{sql:O}):J.extras;for(let[I,P]of Object.entries(V8))h.push({tsKey:I,value:S6(P,z)})}for(let{tsKey:I,value:P}of h)G.push({dbKey:V(P,m.Aliased)?P.fieldAlias:W.columns[I].name,tsKey:I,field:V(P,S8)?YX(P,z):P,relationTableTsKey:void 0,isJson:!1,selection:[]});let G8=typeof J.orderBy==="function"?J.orderBy(E,xz()):J.orderBy??[];if(!Array.isArray(G8))G8=[G8];B=G8.map((I)=>{if(V(I,S8))return YX(I,z);return CZ(I,z)}),U=J.limit,w=J.offset;for(let{tsKey:I,queryConfig:P,relation:k}of s){let b=bz(Z,Y,k),$8=w1(k.referencedTable),J8=Y[$8],X8=`${z}_${I}`,U8=RX(...b.fields.map((l2,C0)=>K2(YX(b.references[C0],X8),YX(l2,z)))),H0=this.buildRelationalQueryWithoutPK({fullSchema:X,schema:Z,tableNamesMap:Y,table:X[J8],tableConfig:Z[J8],queryConfig:V(k,lX)?P===!0?{limit:1}:{...P,limit:1}:P,tableAlias:X8,joinOn:U8,nestedQueryRelation:k}),d8=O`${O.identifier(X8)}.${O.identifier("data")}`.as(I);S.push({on:O`true`,table:new M0(H0.sql,{},X8),alias:X8,joinType:"left",lateral:!0}),G.push({dbKey:I,tsKey:I,field:d8,relationTableTsKey:J8,isJson:!0,selection:H0.selection})}}if(G.length===0)throw new aY({message:`No fields selected for table "${W.tsName}" ("${z}")`});let H;if(N=RX(M,N),Q){let E=O`json_build_array(${O.join(G.map(({field:s,tsKey:V8,isJson:G8})=>G8?O`${O.identifier(`${z}_${V8}`)}.${O.identifier("data")}`:V(s,m.Aliased)?s.sql:s),O`, `)})`;if(V(Q,IZ))E=O`coalesce(json_agg(${E}${B.length>0?O` order by ${O.join(B,O`, `)}`:void 0}), '[]'::json)`;let h=[{dbKey:"data",tsKey:"data",field:E.as("data"),isJson:!0,relationTableTsKey:W.tsName,selection:G}];if(U!==void 0||w!==void 0||B.length>0)H=this.buildSelectQuery({table:yY($,z),fields:{},fieldsFlat:[{path:[],field:O.raw("*")}],where:N,limit:U,offset:w,orderBy:B,setOperators:[]}),N=void 0,U=void 0,w=void 0,B=[];else H=yY($,z);H=this.buildSelectQuery({table:V(H,q0)?H:new M0(H,{},z),fields:{},fieldsFlat:h.map(({field:s})=>({path:[],field:V(s,S8)?YX(s,z):s})),joins:S,where:N,limit:U,offset:w,orderBy:B,setOperators:[]})}else H=this.buildSelectQuery({table:yY($,z),fields:{},fieldsFlat:G.map(({field:E})=>({path:[],field:V(E,S8)?YX(E,z):E})),joins:S,where:N,limit:U,offset:w,orderBy:B,setOperators:[]});return{tableTsKey:W.tsName,sql:H,selection:G}}}class T6{static[A]="TypedQueryBuilder";getSelectedFields(){return this._.selectedFields}}class b0{static[A]="PgSelectBuilder";fields;session;dialect;withList=[];distinct;constructor(X){if(this.fields=X.fields,this.session=X.session,this.dialect=X.dialect,X.withList)this.withList=X.withList;this.distinct=X.distinct}authToken;setToken(X){return this.authToken=X,this}from(X){let Z=!!this.fields,Y=X,$;if(this.fields)$=this.fields;else if(V(Y,M0))$=Object.fromEntries(Object.keys(Y._.selectedFields).map((W)=>[W,Y[W]]));else if(V(Y,xZ))$=Y[y8].selectedFields;else if(V(Y,m))$={};else $=hY(Y);return new b6({table:Y,fields:$,isPartialSelect:Z,session:this.session,dialect:this.dialect,withList:this.withList,distinct:this.distinct}).setToken(this.authToken)}}class fz extends T6{static[A]="PgSelectQueryBuilder";_;config;joinsNotNullableMap;tableName;isPartialSelect;session;dialect;constructor({table:X,fields:Z,isPartialSelect:Y,session:$,dialect:W,withList:J,distinct:z}){super();this.config={withList:J,table:X,fields:{...Z},distinct:z,setOperators:[]},this.isPartialSelect=Y,this.session=$,this.dialect=W,this._={selectedFields:Z},this.tableName=qX(X),this.joinsNotNullableMap=typeof this.tableName==="string"?{[this.tableName]:!0}:{}}createJoin(X){return(Z,Y)=>{let $=this.tableName,W=qX(Z);if(typeof W==="string"&&this.config.joins?.some((J)=>J.alias===W))throw new Error(`Alias "${W}" is already used in this query`);if(!this.isPartialSelect){if(Object.keys(this.joinsNotNullableMap).length===1&&typeof $==="string")this.config.fields={[$]:this.config.fields};if(typeof W==="string"&&!V(Z,m)){let J=V(Z,M0)?Z._.selectedFields:V(Z,n0)?Z[y8].selectedFields:Z[d.Symbol.Columns];this.config.fields[W]=J}}if(typeof Y==="function")Y=Y(new Proxy(this.config.fields,new X0({sqlAliasedBehavior:"sql",sqlBehavior:"sql"})));if(!this.config.joins)this.config.joins=[];if(this.config.joins.push({on:Y,table:Z,joinType:X,alias:W}),typeof W==="string")switch(X){case"left":{this.joinsNotNullableMap[W]=!1;break}case"right":{this.joinsNotNullableMap=Object.fromEntries(Object.entries(this.joinsNotNullableMap).map(([J])=>[J,!1])),this.joinsNotNullableMap[W]=!0;break}case"inner":{this.joinsNotNullableMap[W]=!0;break}case"full":{this.joinsNotNullableMap=Object.fromEntries(Object.entries(this.joinsNotNullableMap).map(([J])=>[J,!1])),this.joinsNotNullableMap[W]=!1;break}}return this}}leftJoin=this.createJoin("left");rightJoin=this.createJoin("right");innerJoin=this.createJoin("inner");fullJoin=this.createJoin("full");createSetOperator(X,Z){return(Y)=>{let $=typeof Y==="function"?Y($L()):Y;if(!PZ(this.getSelectedFields(),$.getSelectedFields()))throw new Error("Set operator error (union / intersect / except): selected fields are not the same or are in a different order");return this.config.setOperators.push({type:X,isAll:Z,rightSelect:$}),this}}union=this.createSetOperator("union",!1);unionAll=this.createSetOperator("union",!0);intersect=this.createSetOperator("intersect",!1);intersectAll=this.createSetOperator("intersect",!0);except=this.createSetOperator("except",!1);exceptAll=this.createSetOperator("except",!0);addSetOperators(X){return this.config.setOperators.push(...X),this}where(X){if(typeof X==="function")X=X(new Proxy(this.config.fields,new X0({sqlAliasedBehavior:"sql",sqlBehavior:"sql"})));return this.config.where=X,this}having(X){if(typeof X==="function")X=X(new Proxy(this.config.fields,new X0({sqlAliasedBehavior:"sql",sqlBehavior:"sql"})));return this.config.having=X,this}groupBy(...X){if(typeof X[0]==="function"){let Z=X[0](new Proxy(this.config.fields,new X0({sqlAliasedBehavior:"alias",sqlBehavior:"sql"})));this.config.groupBy=Array.isArray(Z)?Z:[Z]}else this.config.groupBy=X;return this}orderBy(...X){if(typeof X[0]==="function"){let Z=X[0](new Proxy(this.config.fields,new X0({sqlAliasedBehavior:"alias",sqlBehavior:"sql"}))),Y=Array.isArray(Z)?Z:[Z];if(this.config.setOperators.length>0)this.config.setOperators.at(-1).orderBy=Y;else this.config.orderBy=Y}else{let Z=X;if(this.config.setOperators.length>0)this.config.setOperators.at(-1).orderBy=Z;else this.config.orderBy=Z}return this}limit(X){if(this.config.setOperators.length>0)this.config.setOperators.at(-1).limit=X;else this.config.limit=X;return this}offset(X){if(this.config.setOperators.length>0)this.config.setOperators.at(-1).offset=X;else this.config.offset=X;return this}for(X,Z={}){return this.config.lockingClause={strength:X,config:Z},this}getSQL(){return this.dialect.buildSelectQuery(this.config)}toSQL(){let{typings:X,...Z}=this.dialect.sqlToQuery(this.getSQL());return Z}as(X){return new Proxy(new M0(this.getSQL(),this.config.fields,X),new X0({alias:X,sqlAliasedBehavior:"alias",sqlBehavior:"error"}))}getSelectedFields(){return new Proxy(this.config.fields,new X0({alias:this.tableName,sqlAliasedBehavior:"alias",sqlBehavior:"error"}))}$dynamic(){return this}}class b6 extends fz{static[A]="PgSelect";_prepare(X){let{session:Z,config:Y,dialect:$,joinsNotNullableMap:W,authToken:J}=this;if(!Z)throw new Error("Cannot execute a query on a query builder. Please use a database instance instead.");return v8.startActiveSpan("drizzle.prepareQuery",()=>{let z=q2(Y.fields),Q=Z.prepareQuery($.sqlToQuery(this.getSQL()),z,X,!0);return Q.joinsNotNullableMap=W,Q.setToken(J)})}prepare(X){return this._prepare(X)}authToken;setToken(X){return this.authToken=X,this}execute=(X)=>{return v8.startActiveSpan("drizzle.operation",()=>{return this._prepare().execute(X,this.authToken)})}}H4(b6,[T0]);function s1(X,Z){return(Y,$,...W)=>{let J=[$,...W].map((z)=>({type:X,isAll:Z,rightSelect:z}));for(let z of J)if(!PZ(Y.getSelectedFields(),z.rightSelect.getSelectedFields()))throw new Error("Set operator error (union / intersect / except): selected fields are not the same or are in a different order");return Y.addSetOperators(J)}}var $L=()=>({union:WL,unionAll:JL,intersect:zL,intersectAll:QL,except:GL,exceptAll:ML}),WL=s1("union",!1),JL=s1("union",!0),zL=s1("intersect",!1),QL=s1("intersect",!0),GL=s1("except",!1),ML=s1("except",!0);class TZ{static[A]="PgQueryBuilder";dialect;dialectConfig;constructor(X){this.dialect=V(X,O1)?X:void 0,this.dialectConfig=V(X,O1)?void 0:X}$with=(X,Z)=>{let Y=this;return{as:(W)=>{if(typeof W==="function")W=W(Y);return new Proxy(new SZ(W.getSQL(),Z??("getSelectedFields"in W?W.getSelectedFields()??{}:{}),X,!0),new X0({alias:X,sqlAliasedBehavior:"alias",sqlBehavior:"error"}))}}};with(...X){let Z=this;function Y(J){return new b0({fields:J??void 0,session:void 0,dialect:Z.getDialect(),withList:X})}function $(J){return new b0({fields:J??void 0,session:void 0,dialect:Z.getDialect(),distinct:!0})}function W(J,z){return new b0({fields:z??void 0,session:void 0,dialect:Z.getDialect(),distinct:{on:J}})}return{select:Y,selectDistinct:$,selectDistinctOn:W}}select(X){return new b0({fields:X??void 0,session:void 0,dialect:this.getDialect()})}selectDistinct(X){return new b0({fields:X??void 0,session:void 0,dialect:this.getDialect(),distinct:!0})}selectDistinctOn(X,Z){return new b0({fields:Z??void 0,session:void 0,dialect:this.getDialect(),distinct:{on:X}})}getDialect(){if(!this.dialect)this.dialect=new O1(this.dialectConfig);return this.dialect}}class W${constructor(X,Z,Y,$,W){this.table=X,this.session=Z,this.dialect=Y,this.withList=$,this.overridingSystemValue_=W}static[A]="PgInsertBuilder";authToken;setToken(X){return this.authToken=X,this}overridingSystemValue(){return this.overridingSystemValue_=!0,this}values(X){if(X=Array.isArray(X)?X:[X],X.length===0)throw new Error("values() must be called with at least one value");let Z=X.map((Y)=>{let $={},W=this.table[d.Symbol.Columns];for(let J of Object.keys(Y)){let z=Y[J];$[J]=V(z,m)?z:new J2(z,W[J])}return $});return new k6(this.table,Z,this.session,this.dialect,this.withList,!1,this.overridingSystemValue_).setToken(this.authToken)}select(X){let Z=typeof X==="function"?X(new TZ):X;if(!V(Z,m)&&!PZ(this.table[fY],Z._.selectedFields))throw new Error("Insert select error: selected fields are not the same or are in a different order compared to the table definition");return new k6(this.table,Z,this.session,this.dialect,this.withList,!0)}}class k6 extends T0{constructor(X,Z,Y,$,W,J,z){super();this.session=Y,this.dialect=$,this.config={table:X,values:Z,withList:W,select:J,overridingSystemValue_:z}}static[A]="PgInsert";config;returning(X=this.config.table[d.Symbol.Columns]){return this.config.returningFields=X,this.config.returning=q2(X),this}onConflictDoNothing(X={}){if(X.target===void 0)this.config.onConflict=O`do nothing`;else{let Z="";Z=Array.isArray(X.target)?X.target.map(($)=>this.dialect.escapeName(this.dialect.casing.getColumnCasing($))).join(","):this.dialect.escapeName(this.dialect.casing.getColumnCasing(X.target));let Y=X.where?O` where ${X.where}`:void 0;this.config.onConflict=O`(${O.raw(Z)})${Y} do nothing`}return this}onConflictDoUpdate(X){if(X.where&&(X.targetWhere||X.setWhere))throw new Error('You cannot use both "where" and "targetWhere"/"setWhere" at the same time - "where" is deprecated, use "targetWhere" or "setWhere" instead.');let Z=X.where?O` where ${X.where}`:void 0,Y=X.targetWhere?O` where ${X.targetWhere}`:void 0,$=X.setWhere?O` where ${X.setWhere}`:void 0,W=this.dialect.buildUpdateSet(this.config.table,dY(this.config.table,X.set)),J="";return J=Array.isArray(X.target)?X.target.map((z)=>this.dialect.escapeName(this.dialect.casing.getColumnCasing(z))).join(","):this.dialect.escapeName(this.dialect.casing.getColumnCasing(X.target)),this.config.onConflict=O`(${O.raw(J)})${Y} do update set ${W}${Z}${$}`,this}getSQL(){return this.dialect.buildInsertQuery(this.config)}toSQL(){let{typings:X,...Z}=this.dialect.sqlToQuery(this.getSQL());return Z}_prepare(X){return v8.startActiveSpan("drizzle.prepareQuery",()=>{return this.session.prepareQuery(this.dialect.sqlToQuery(this.getSQL()),this.config.returning,X,!0)})}prepare(X){return this._prepare(X)}authToken;setToken(X){return this.authToken=X,this}execute=(X)=>{return v8.startActiveSpan("drizzle.operation",()=>{return this._prepare().execute(X,this.authToken)})};getSelectedFields(){return this.config.returningFields?new Proxy(this.config.returningFields,new X0({alias:o0(this.config.table),sqlAliasedBehavior:"alias",sqlBehavior:"error"})):void 0}$dynamic(){return this}}class g6 extends T0{constructor(X,Z,Y){super();this.session=Z,this.dialect=Y,this.config={view:X}}static[A]="PgRefreshMaterializedView";config;concurrently(){if(this.config.withNoData!==void 0)throw new Error("Cannot use concurrently and withNoData together");return this.config.concurrently=!0,this}withNoData(){if(this.config.concurrently!==void 0)throw new Error("Cannot use concurrently and withNoData together");return this.config.withNoData=!0,this}getSQL(){return this.dialect.buildRefreshMaterializedViewQuery(this.config)}toSQL(){let{typings:X,...Z}=this.dialect.sqlToQuery(this.getSQL());return Z}_prepare(X){return v8.startActiveSpan("drizzle.prepareQuery",()=>{return this.session.prepareQuery(this.dialect.sqlToQuery(this.getSQL()),void 0,X,!0)})}prepare(X){return this._prepare(X)}authToken;setToken(X){return this.authToken=X,this}execute=(X)=>{return v8.startActiveSpan("drizzle.operation",()=>{return this._prepare().execute(X,this.authToken)})}}class J${constructor(X,Z,Y,$){this.table=X,this.session=Z,this.dialect=Y,this.withList=$}static[A]="PgUpdateBuilder";authToken;setToken(X){return this.authToken=X,this}set(X){return new vz(this.table,dY(this.table,X),this.session,this.dialect,this.withList).setToken(this.authToken)}}class vz extends T0{constructor(X,Z,Y,$,W){super();this.session=Y,this.dialect=$,this.config={set:Z,table:X,withList:W,joins:[]},this.tableName=qX(X),this.joinsNotNullableMap=typeof this.tableName==="string"?{[this.tableName]:!0}:{}}static[A]="PgUpdate";config;tableName;joinsNotNullableMap;from(X){let Z=X,Y=qX(Z);if(typeof Y==="string")this.joinsNotNullableMap[Y]=!0;return this.config.from=Z,this}getTableLikeFields(X){if(V(X,q0))return X[d.Symbol.Columns];else if(V(X,M0))return X._.selectedFields;return X[y8].selectedFields}createJoin(X){return(Z,Y)=>{let $=qX(Z);if(typeof $==="string"&&this.config.joins.some((W)=>W.alias===$))throw new Error(`Alias "${$}" is already used in this query`);if(typeof Y==="function"){let W=this.config.from&&!V(this.config.from,m)?this.getTableLikeFields(this.config.from):void 0;Y=Y(new Proxy(this.config.table[d.Symbol.Columns],new X0({sqlAliasedBehavior:"sql",sqlBehavior:"sql"})),W&&new Proxy(W,new X0({sqlAliasedBehavior:"sql",sqlBehavior:"sql"})))}if(this.config.joins.push({on:Y,table:Z,joinType:X,alias:$}),typeof $==="string")switch(X){case"left":{this.joinsNotNullableMap[$]=!1;break}case"right":{this.joinsNotNullableMap=Object.fromEntries(Object.entries(this.joinsNotNullableMap).map(([W])=>[W,!1])),this.joinsNotNullableMap[$]=!0;break}case"inner":{this.joinsNotNullableMap[$]=!0;break}case"full":{this.joinsNotNullableMap=Object.fromEntries(Object.entries(this.joinsNotNullableMap).map(([W])=>[W,!1])),this.joinsNotNullableMap[$]=!1;break}}return this}}leftJoin=this.createJoin("left");rightJoin=this.createJoin("right");innerJoin=this.createJoin("inner");fullJoin=this.createJoin("full");where(X){return this.config.where=X,this}returning(X){if(!X){if(X=Object.assign({},this.config.table[d.Symbol.Columns]),this.config.from){let Z=qX(this.config.from);if(typeof Z==="string"&&this.config.from&&!V(this.config.from,m)){let Y=this.getTableLikeFields(this.config.from);X[Z]=Y}for(let Y of this.config.joins){let $=qX(Y.table);if(typeof $==="string"&&!V(Y.table,m)){let W=this.getTableLikeFields(Y.table);X[$]=W}}}}return this.config.returningFields=X,this.config.returning=q2(X),this}getSQL(){return this.dialect.buildUpdateQuery(this.config)}toSQL(){let{typings:X,...Z}=this.dialect.sqlToQuery(this.getSQL());return Z}_prepare(X){let Z=this.session.prepareQuery(this.dialect.sqlToQuery(this.getSQL()),this.config.returning,X,!0);return Z.joinsNotNullableMap=this.joinsNotNullableMap,Z}prepare(X){return this._prepare(X)}authToken;setToken(X){return this.authToken=X,this}execute=(X)=>{return this._prepare().execute(X,this.authToken)};getSelectedFields(){return this.config.returningFields?new Proxy(this.config.returningFields,new X0({alias:o0(this.config.table),sqlAliasedBehavior:"alias",sqlBehavior:"error"})):void 0}$dynamic(){return this}}class bZ extends m{constructor(X){super(bZ.buildEmbeddedCount(X.source,X.filters).queryChunks);this.params=X,this.mapWith(Number),this.session=X.session,this.sql=bZ.buildCount(X.source,X.filters)}sql;token;static[A]="PgCountBuilder";[Symbol.toStringTag]="PgCountBuilder";session;static buildEmbeddedCount(X,Z){return O`(select count(*) from ${X}${O.raw(" where ").if(Z)}${Z})`}static buildCount(X,Z){return O`select count(*) as count from ${X}${O.raw(" where ").if(Z)}${Z};`}setToken(X){return this.token=X,this}then(X,Z){return Promise.resolve(this.session.count(this.sql,this.token)).then(X,Z)}catch(X){return this.then(void 0,X)}finally(X){return this.then((Z)=>{return X?.(),Z},(Z)=>{throw X?.(),Z})}}class v6{constructor(X,Z,Y,$,W,J,z){this.fullSchema=X,this.schema=Z,this.tableNamesMap=Y,this.table=$,this.tableConfig=W,this.dialect=J,this.session=z}static[A]="PgRelationalQueryBuilder";findMany(X){return new f6(this.fullSchema,this.schema,this.tableNamesMap,this.table,this.tableConfig,this.dialect,this.session,X?X:{},"many")}findFirst(X){return new f6(this.fullSchema,this.schema,this.tableNamesMap,this.table,this.tableConfig,this.dialect,this.session,X?{...X,limit:1}:{limit:1},"first")}}class f6 extends T0{constructor(X,Z,Y,$,W,J,z,Q,M){super();this.fullSchema=X,this.schema=Z,this.tableNamesMap=Y,this.table=$,this.tableConfig=W,this.dialect=J,this.session=z,this.config=Q,this.mode=M}static[A]="PgRelationalQuery";_prepare(X){return v8.startActiveSpan("drizzle.prepareQuery",()=>{let{query:Z,builtQuery:Y}=this._toSQL();return this.session.prepareQuery(Y,void 0,X,!0,($,W)=>{let J=$.map((z)=>Z$(this.schema,this.tableConfig,z,Z.selection,W));if(this.mode==="first")return J[0];return J})})}prepare(X){return this._prepare(X)}_getQuery(){return this.dialect.buildRelationalQueryWithoutPK({fullSchema:this.fullSchema,schema:this.schema,tableNamesMap:this.tableNamesMap,table:this.table,tableConfig:this.tableConfig,queryConfig:this.config,tableAlias:this.tableConfig.tsName})}getSQL(){return this._getQuery().sql}_toSQL(){let X=this._getQuery(),Z=this.dialect.sqlToQuery(X.sql);return{query:X,builtQuery:Z}}toSQL(){return this._toSQL().builtQuery}authToken;setToken(X){return this.authToken=X,this}execute(){return v8.startActiveSpan("drizzle.operation",()=>{return this._prepare().execute(void 0,this.authToken)})}}class y6 extends T0{constructor(X,Z,Y,$){super();this.execute=X,this.sql=Z,this.query=Y,this.mapBatchResult=$}static[A]="PgRaw";getSQL(){return this.sql}getQuery(){return this.query}mapResult(X,Z){return Z?this.mapBatchResult(X):X}_prepare(){return this}isResponseInArrayMode(){return!1}}class kZ{constructor(X,Z,Y){if(this.dialect=X,this.session=Z,this._=Y?{schema:Y.schema,fullSchema:Y.fullSchema,tableNamesMap:Y.tableNamesMap,session:Z}:{schema:void 0,fullSchema:{},tableNamesMap:{},session:Z},this.query={},this._.schema)for(let[$,W]of Object.entries(this._.schema))this.query[$]=new v6(Y.fullSchema,this._.schema,this._.tableNamesMap,Y.fullSchema[$],W,X,Z)}static[A]="PgDatabase";query;$with=(X,Z)=>{let Y=this;return{as:(W)=>{if(typeof W==="function")W=W(new TZ(Y.dialect));return new Proxy(new SZ(W.getSQL(),Z??("getSelectedFields"in W?W.getSelectedFields()??{}:{}),X,!0),new X0({alias:X,sqlAliasedBehavior:"alias",sqlBehavior:"error"}))}}};$count(X,Z){return new bZ({source:X,filters:Z,session:this.session})}with(...X){let Z=this;function Y(M){return new b0({fields:M??void 0,session:Z.session,dialect:Z.dialect,withList:X})}function $(M){return new b0({fields:M??void 0,session:Z.session,dialect:Z.dialect,withList:X,distinct:!0})}function W(M,G){return new b0({fields:G??void 0,session:Z.session,dialect:Z.dialect,withList:X,distinct:{on:M}})}function J(M){return new J$(M,Z.session,Z.dialect,X)}function z(M){return new W$(M,Z.session,Z.dialect,X)}function Q(M){return new rY(M,Z.session,Z.dialect,X)}return{select:Y,selectDistinct:$,selectDistinctOn:W,update:J,insert:z,delete:Q}}select(X){return new b0({fields:X??void 0,session:this.session,dialect:this.dialect})}selectDistinct(X){return new b0({fields:X??void 0,session:this.session,dialect:this.dialect,distinct:!0})}selectDistinctOn(X,Z){return new b0({fields:Z??void 0,session:this.session,dialect:this.dialect,distinct:{on:X}})}update(X){return new J$(X,this.session,this.dialect)}insert(X){return new W$(X,this.session,this.dialect)}delete(X){return new rY(X,this.session,this.dialect)}refreshMaterializedView(X){return new g6(X,this.session,this.dialect)}authToken;execute(X){let Z=typeof X==="string"?O.raw(X):X.getSQL(),Y=this.dialect.sqlToQuery(Z),$=this.session.prepareQuery(Y,void 0,void 0,!1);return new y6(()=>$.execute(void 0,this.authToken),Z,Y,(W)=>$.mapResult(W,!0))}transaction(X,Z){return this.session.transaction(X,Z)}}class d6{constructor(X){this.query=X}authToken;getQuery(){return this.query}mapResult(X,Z){return X}setToken(X){return this.authToken=X,this}static[A]="PgPreparedQuery";joinsNotNullableMap}class h6{constructor(X){this.dialect=X}static[A]="PgSession";execute(X,Z){return v8.startActiveSpan("drizzle.operation",()=>{return v8.startActiveSpan("drizzle.prepareQuery",()=>{return this.prepareQuery(this.dialect.sqlToQuery(X),void 0,void 0,!1)}).setToken(Z).execute(void 0,Z)})}all(X){return this.prepareQuery(this.dialect.sqlToQuery(X),void 0,void 0,!1).all()}async count(X,Z){let Y=await this.execute(X,Z);return Number(Y[0].count)}}class m6 extends kZ{constructor(X,Z,Y,$=0){super(X,Z,Y);this.schema=Y,this.nestedIndex=$}static[A]="PgTransaction";rollback(){throw new C6}getTransactionConfigSQL(X){let Z=[];if(X.isolationLevel)Z.push(`isolation level ${X.isolationLevel}`);if(X.accessMode)Z.push(X.accessMode);if(typeof X.deferrable==="boolean")Z.push(X.deferrable?"deferrable":"not deferrable");return O.raw(Z.join(" "))}setTransaction(X){return this.session.execute(O`set transaction ${this.getTransactionConfigSQL(X)}`)}}var a=Uz("units",{id:sY("id").defaultRandom().primaryKey(),unitNo:nX("unit_no",{length:10}).notNull(),number:oX("number"),project:nX("project",{length:256}).notNull(),floor:oX("floor").notNull(),unitType:nX("unit_type",{length:256,enum:["Studio Squared","1 BR Squared","Studio Flex","2 BR Squared","One Bedroom2","Studio2","One Bedroom Loft","Two Bedroom Loft"]}),noOfBathrooms:oX("no_of_bathrooms").notNull(),unitView:nX("unit_view",{length:256,enum:["Canal / Amenities","Corner-Canal / Amenities","Corner-Canal View","Business Bay","Park Facing","Corner-Park Facing","Partial Park","BK/DT / Amenities","Corner-BK/DT / Amenities","Corner-Canal / BK/DT View","Marina View","Partial Marina View","Partial Marina, Partial City View","City view","Marina View, Sea View","Partial Marina View, Partial Sea View"]}),suitsArea:l1("suits_area").notNull(),squareFt:l1("square_ft").notNull(),noOfParkingSpace:oX("no_of_parking_space").notNull(),salesPrice:oX("sales_price").notNull(),state:nX("state",{length:256,enum:["reserved","sold_spa","available","sold_registered"]}).notNull(),balconyArea:l1("balcony_area").notNull()},(X)=>[u5().on(X.project,X.unitNo)]);class yz{static[A]="ConsoleLogWriter";write(X){console.log(X)}}class c6{static[A]="DefaultLogger";writer;constructor(X){this.writer=X?.writer??new yz}logQuery(X,Z){let Y=Z.map((W)=>{try{return JSON.stringify(W)}catch{return String(W)}}),$=Y.length?` -- params: [${Y.join(", ")}]`:"";this.writer.write(`Query: ${X}${$}`)}}class u6{static[A]="NoopLogger";logQuery(){}}var a8={INT8_MIN:-128,INT8_MAX:127,INT8_UNSIGNED_MAX:255,INT16_MIN:-32768,INT16_MAX:32767,INT16_UNSIGNED_MAX:65535,INT24_MIN:-8388608,INT24_MAX:8388607,INT24_UNSIGNED_MAX:16777215,INT32_MIN:-2147483648,INT32_MAX:2147483647,INT32_UNSIGNED_MAX:4294967295,INT48_MIN:-140737488355328,INT48_MAX:140737488355327,INT48_UNSIGNED_MAX:281474976710655,INT64_MIN:-9223372036854775808n,INT64_MAX:9223372036854775807n,INT64_UNSIGNED_MAX:18446744073709551615n};function W0(X,Z){return Z.includes(X.columnType)}function dz(X){return"enumValues"in X&&Array.isArray(X.enumValues)&&X.enumValues.length>0}var UL=dz,HL=f8.Union([f8.String(),f8.Number(),f8.Boolean(),f8.Null()]),DL=f8.Union([HL,f8.Array(f8.Any()),f8.Record(f8.String(),f8.Any())]);t8.Set("Buffer",(X,Z)=>Z instanceof Buffer);var AL={[q]:"Buffer",type:"buffer"};function hz(X){return Object.fromEntries(X.map((Z)=>[Z,Z]))}function mz(X,Z){let Y;if(dz(X))Y=X.enumValues.length?Z.Enum(hz(X.enumValues)):Z.String();if(!Y){if(W0(X,["PgGeometry","PgPointTuple"]))Y=Z.Tuple([Z.Number(),Z.Number()]);else if(W0(X,["PgGeometryObject","PgPointObject"]))Y=Z.Object({x:Z.Number(),y:Z.Number()});else if(W0(X,["PgHalfVector","PgVector"]))Y=Z.Array(Z.Number(),X.dimensions?{minItems:X.dimensions,maxItems:X.dimensions}:void 0);else if(W0(X,["PgLine"]))Y=Z.Tuple([Z.Number(),Z.Number(),Z.Number()]);else if(W0(X,["PgLineABC"]))Y=Z.Object({a:Z.Number(),b:Z.Number(),c:Z.Number()});else if(W0(X,["PgArray"]))Y=Z.Array(mz(X.baseColumn,Z),X.size?{minItems:X.size,maxItems:X.size}:void 0);else if(X.dataType==="array")Y=Z.Array(Z.Any());else if(X.dataType==="number")Y=_L(X,Z);else if(X.dataType==="bigint")Y=wL(X,Z);else if(X.dataType==="boolean")Y=Z.Boolean();else if(X.dataType==="date")Y=Z.Date();else if(X.dataType==="string")Y=OL(X,Z);else if(X.dataType==="json")Y=DL;else if(X.dataType==="custom")Y=Z.Any();else if(X.dataType==="buffer")Y=AL}if(!Y)Y=Z.Any();return Y}function _L(X,Z){let Y=X.getSQLType().includes("unsigned"),$,W,J=!1;if(W0(X,["MySqlTinyInt","SingleStoreTinyInt"]))$=Y?0:a8.INT8_MIN,W=Y?a8.INT8_UNSIGNED_MAX:a8.INT8_MAX,J=!0;else if(W0(X,["PgSmallInt","PgSmallSerial","MySqlSmallInt","SingleStoreSmallInt"]))$=Y?0:a8.INT16_MIN,W=Y?a8.INT16_UNSIGNED_MAX:a8.INT16_MAX,J=!0;else if(W0(X,["PgReal","MySqlFloat","MySqlMediumInt","SingleStoreFloat","SingleStoreMediumInt"]))$=Y?0:a8.INT24_MIN,W=Y?a8.INT24_UNSIGNED_MAX:a8.INT24_MAX,J=W0(X,["MySqlMediumInt","SingleStoreMediumInt"]);else if(W0(X,["PgInteger","PgSerial","MySqlInt","SingleStoreInt"]))$=Y?0:a8.INT32_MIN,W=Y?a8.INT32_UNSIGNED_MAX:a8.INT32_MAX,J=!0;else if(W0(X,["PgDoublePrecision","MySqlReal","MySqlDouble","SingleStoreReal","SingleStoreDouble","SQLiteReal"]))$=Y?0:a8.INT48_MIN,W=Y?a8.INT48_UNSIGNED_MAX:a8.INT48_MAX;else if(W0(X,["PgBigInt53","PgBigSerial53","MySqlBigInt53","MySqlSerial","SingleStoreBigInt53","SingleStoreSerial","SQLiteInteger"]))Y=Y||W0(X,["MySqlSerial","SingleStoreSerial"]),$=Y?0:Number.MIN_SAFE_INTEGER,W=Number.MAX_SAFE_INTEGER,J=!0;else if(W0(X,["MySqlYear","SingleStoreYear"]))$=1901,W=2155,J=!0;else $=Number.MIN_SAFE_INTEGER,W=Number.MAX_SAFE_INTEGER;return Z[J?"Integer":"Number"]({minimum:$,maximum:W})}function wL(X,Z){let Y=X.getSQLType().includes("unsigned"),$=Y?0n:a8.INT64_MIN,W=Y?a8.INT64_UNSIGNED_MAX:a8.INT64_MAX;return Z.BigInt({minimum:$,maximum:W})}function OL(X,Z){if(W0(X,["PgUUID"]))return Z.String({format:"uuid"});else if(W0(X,["PgBinaryVector"]))return Z.RegExp(/^[01]+$/,X.dimensions?{maxLength:X.dimensions}:void 0);let Y,$=!1;if(W0(X,["PgVarchar","SQLiteText"]))Y=X.length;else if(W0(X,["MySqlVarChar","SingleStoreVarChar"]))Y=X.length??a8.INT16_UNSIGNED_MAX;else if(W0(X,["MySqlText","SingleStoreText"]))if(X.textType==="longtext")Y=a8.INT32_UNSIGNED_MAX;else if(X.textType==="mediumtext")Y=a8.INT24_UNSIGNED_MAX;else if(X.textType==="text")Y=a8.INT16_UNSIGNED_MAX;else Y=a8.INT8_UNSIGNED_MAX;if(W0(X,["PgChar","MySqlChar","SingleStoreChar"]))Y=X.length,$=!0;let W={};if(Y!==void 0&&$)W.minLength=Y,W.maxLength=Y;else if(Y!==void 0)W.maxLength=Y;return Z.String(Object.keys(W).length>0?W:void 0)}function pz(X){return K6(X)?hY(X):D4(X)}function cz(X,Z,Y,$){let W={};for(let[J,z]of Object.entries(X)){if(!V(z,S8)&&!V(z,m)&&!V(z,m.Aliased)&&typeof z==="object"){let w=K6(z)||M4(z)?pz(z):z;W[J]=cz(w,Z[J]??{},Y,$);continue}let Q=Z[J];if(Q!==void 0&&typeof Q!=="function"){W[J]=Q;continue}let M=V(z,S8)?z:void 0,G=M?mz(M,$?.typeboxInstance??f8):f8.Any(),U=typeof Q==="function"?Q(G):G;if(Y.never(M))continue;else W[J]=U;if(M){if(Y.nullable(M))W[J]=f8.Union([W[J],f8.Null()]);if(Y.optional(M))W[J]=f8.Optional(W[J])}}return f8.Object(W)}function NL(X,Z){return(Z?.typeboxInstance??f8).Enum(hz(X.enumValues))}var LL={never:()=>!1,optional:()=>!1,nullable:(X)=>!X.notNull};var uz=(X,Z)=>{if(UL(X))return NL(X);let Y=pz(X);return cz(Y,Z??{},LL)};var{SQL:o6}=globalThis.Bun;class iz extends d6{constructor(X,Z,Y,$,W,J,z){super({sql:Z,params:Y});this.client=X,this.queryString=Z,this.params=Y,this.logger=$,this.fields=W,this._isResponseInArrayMode=J,this.customResultMapper=z}static[A]="BunSQLPreparedQuery";async execute(X={}){return v8.startActiveSpan("drizzle.execute",async(Z)=>{let Y=j6(this.params,X);Z?.setAttributes({"drizzle.query.text":this.queryString,"drizzle.query.params":JSON.stringify(Y)}),this.logger.logQuery(this.queryString,Y);let{fields:$,queryString:W,client:J,joinsNotNullableMap:z,customResultMapper:Q}=this;if(!$&&!Q)return v8.startActiveSpan("drizzle.driver.execute",()=>{return J.unsafe(W,Y)});let M=await v8.startActiveSpan("drizzle.driver.execute",()=>{return Z?.setAttributes({"drizzle.query.text":W,"drizzle.query.params":JSON.stringify(Y)}),J.unsafe(W,Y).values()});return v8.startActiveSpan("drizzle.mapResponse",()=>{return Q?Q(M):M.map((G)=>U4($,G,z))})})}all(X={}){return v8.startActiveSpan("drizzle.execute",async(Z)=>{let Y=j6(this.params,X);return Z?.setAttributes({"drizzle.query.text":this.queryString,"drizzle.query.params":JSON.stringify(Y)}),this.logger.logQuery(this.queryString,Y),v8.startActiveSpan("drizzle.driver.execute",()=>{return Z?.setAttributes({"drizzle.query.text":this.queryString,"drizzle.query.params":JSON.stringify(Y)}),this.client.unsafe(this.queryString,Y)})})}isResponseInArrayMode(){return this._isResponseInArrayMode}}class gZ extends h6{constructor(X,Z,Y,$={}){super(Z);this.client=X,this.schema=Y,this.options=$,this.logger=$.logger??new u6}static[A]="BunSQLSession";logger;prepareQuery(X,Z,Y,$,W){return new iz(this.client,X.sql,X.params,this.logger,Z,$,W)}query(X,Z){return this.logger.logQuery(X,Z),this.client.unsafe(X,Z).values()}queryObjects(X,Z){return this.client.unsafe(X,Z)}transaction(X,Z){return this.client.begin(async(Y)=>{let $=new gZ(Y,this.dialect,this.schema,this.options),W=new i6(this.dialect,$,this.schema);if(Z)await W.setTransaction(Z);return X(W)})}}class i6 extends m6{constructor(X,Z,Y,$=0){super(X,Z,Y,$);this.session=Z}static[A]="BunSQLTransaction";transaction(X){return this.session.client.savepoint((Z)=>{let Y=new gZ(Z,this.dialect,this.schema,this.session.options),$=new i6(this.dialect,Y,this.schema);return X($)})}}class oz extends kZ{static[A]="BunSQLDatabase"}function r1(X,Z={}){let Y=new O1({casing:Z.casing}),$;if(Z.logger===!0)$=new c6;else if(Z.logger!==!1)$=Z.logger;let W;if(Z.schema){let Q=Tz(Z.schema,kz);W={fullSchema:Z.schema,schema:Q.tables,tableNamesMap:Q.tableNamesMap}}let J=new gZ(X,Y,W,{logger:$}),z=new oz(Y,J,W);return z.$client=X,z}function z$(...X){if(typeof X[0]==="string"){let Z=new o6(X[0]);return r1(Z,X[1])}if(A4(X[0])){let{connection:Z,client:Y,...$}=X[0];if(Y)return r1(Y,$);if(typeof Z==="object"&&Z.url!==void 0){let{url:J,...z}=Z,Q=new o6({url:J,...z});return r1(Q,$)}let W=new o6(Z);return r1(W,$)}return r1(X[0],X[1])}((X)=>{function Z(Y){return r1({options:{parsers:{},serializers:{}}},Y)}X.mock=Z})(z$||(z$={}));var{SQL:FL}=globalThis.Bun;var jX=z$({schema:p6,client:new FL("postgresql://postgres:v1sq3vD5faXL@194.26.138.94:5432/irth")});var wd=uz(a),Od=new O2({prefix:"/units"}).get("/",async({query:{project:X,unitTypes:Z,cost:Y,floor:$,area:W,view:J,order:z,offset:Q,limit:M}})=>{try{return await jX.query.unitsTable.findMany({where:RX(X?K2(a.project,X):void 0,Z?t1(a.unitType,Z):void 0,Y?R2(a.salesPrice,Y[0],Y[1]):void 0,$?R2(a.floor,$[0],$[1]):void 0,W?R2(a.squareFt,W[0],W[1]):void 0,J?K2(a.unitView,J):void 0),orderBy:z?[z[1]==="asc"?eY(a[z[0]==="cost"?"salesPrice":"squareFt"]):X$(a[z[0]==="cost"?"salesPrice":"squareFt"])]:void 0,offset:Q,limit:M})}catch(G){return console.log(G.message),_1(500,"Internal server error")}},{query:_.Partial(_.Object({project:_.String(),unitTypes:_.Array(_.Union([_.Literal("Studio Squared"),_.Literal("1 BR Squared"),_.Literal("Studio Flex"),_.Literal("2 BR Squared"),_.Literal("Studio2"),_.Literal("One Bedroom2"),_.Literal("One Bedroom Loft"),_.Literal("Two Bedroom Loft")])),cost:_.Tuple([_.Number(),_.Number()]),floor:_.Tuple([_.Number(),_.Number()]),area:_.Tuple([_.Number(),_.Number()]),view:_.Union([_.Literal("Canal / Amenities"),_.Literal("Corner-Canal / Amenities"),_.Literal("Corner-Canal View"),_.Literal("Business Bay"),_.Literal("Park Facing"),_.Literal("Corner-Park Facing"),_.Literal("Partial Park"),_.Literal("BK/DT / Amenities"),_.Literal("Corner-BK/DT / Amenities"),_.Literal("Corner-Canal / BK/DT View"),_.Literal("Marina View"),_.Literal("Partial Marina View"),_.Literal("Partial Marina, Partial City View"),_.Literal("City view"),_.Literal("Marina View, Sea View"),_.Literal("Partial Marina View, Partial Sea View")]),order:_.Tuple([_.Union([_.Literal("cost"),_.Literal("sqft")]),_.Union([_.Literal("asc"),_.Literal("desc")])]),offset:_.Number({default:0}),limit:_.Number({default:16})}))}).get("/count",async({query:{project:X,unitTypes:Z,cost:Y,floor:$,area:W,view:J}})=>{try{return(await jX.select({count:gz()}).from(a).where(RX(X?K2(a.project,X):void 0,Z?t1(a.unitType,Z):void 0,Y?R2(a.salesPrice,Y[0],Y[1]):void 0,$?R2(a.floor,$[0],$[1]):void 0,W?R2(a.squareFt,W[0],W[1]):void 0,J?K2(a.unitView,J):void 0)))[0].count}catch(z){return console.log(z.message),_1(500,"Internal server error")}},{query:_.Partial(_.Object({project:_.String(),unitTypes:_.Array(_.Union([_.Literal("Studio Squared"),_.Literal("1 BR Squared"),_.Literal("Studio Flex"),_.Literal("2 BR Squared"),_.Literal("Studio2"),_.Literal("One Bedroom2"),_.Literal("One Bedroom Loft"),_.Literal("Two Bedroom Loft")])),cost:_.Tuple([_.Number(),_.Number()]),floor:_.Tuple([_.Number(),_.Number()]),area:_.Tuple([_.Number(),_.Number()]),view:_.Union([_.Literal("Canal / Amenities"),_.Literal("Corner-Canal / Amenities"),_.Literal("Corner-Canal View"),_.Literal("Business Bay"),_.Literal("Park Facing"),_.Literal("Corner-Park Facing"),_.Literal("Partial Park"),_.Literal("BK/DT / Amenities"),_.Literal("Corner-BK/DT / Amenities"),_.Literal("Corner-Canal / BK/DT View"),_.Literal("Marina View"),_.Literal("Partial Marina View"),_.Literal("Partial Marina, Partial City View"),_.Literal("City view"),_.Literal("Marina View, Sea View"),_.Literal("Partial Marina View, Partial Sea View")])}))}).get("/filters/:filterName",async({query:{project:X,view:Z,unitTypes:Y,cost:$,floor:W,area:J},params:{filterName:z}})=>{try{let Q=RX(X?K2(a.project,X):void 0,Y&&z!=="unitTypes"?t1(a.unitType,Y):void 0,Z&&z!=="views"?K2(a.unitView,Z):void 0,$&&z!=="cost"?R2(a.salesPrice,$[0],$[1]):void 0,W&&z!=="floor"?R2(a.floor,W[0],W[1]):void 0,J&&z!=="area"?R2(a.squareFt,J[0],J[1]):void 0);if(z==="unitTypes")return(await jX.selectDistinctOn([a.unitType],{unitType:a.unitType}).from(a).where(Q)).map((M)=>M.unitType).filter(Boolean);else if(z==="views")return(await jX.selectDistinctOn([a.unitView],{unitView:a.unitView}).from(a).where(Q)).map((M)=>M.unitView).filter(Boolean);else if(z==="cost")return(await jX.select({min:$$(a.salesPrice),max:Y$(a.salesPrice)}).from(a).where(Q))[0];else if(z==="area")return(await jX.select({min:$$(a.squareFt),max:Y$(a.squareFt)}).from(a).where(Q))[0];return(await jX.select({min:$$(a.floor),max:Y$(a.floor)}).from(a).where(Q))[0]}catch(Q){return console.log(Q.message),_1(500,"Internal server error")}},{response:{200:_.Union([_.Array(_.String()),_.Object({min:_.Number(),max:_.Number()})]),500:_.ObjectString({})},params:_.Object({filterName:_.Union([_.Literal("unitTypes"),_.Literal("views"),_.Literal("cost"),_.Literal("area"),_.Literal("floor")])}),query:_.Partial(_.Object({project:_.String(),unitTypes:_.Array(_.Union([_.Literal("Studio Squared"),_.Literal("1 BR Squared"),_.Literal("Studio Flex"),_.Literal("2 BR Squared"),_.Literal("Studio2"),_.Literal("One Bedroom2"),_.Literal("One Bedroom Loft"),_.Literal("Two Bedroom Loft")])),cost:_.Tuple([_.Number(),_.Number()]),floor:_.Tuple([_.Number(),_.Number()]),area:_.Tuple([_.Number(),_.Number()]),view:_.Union([_.Literal("Canal / Amenities"),_.Literal("Corner-Canal / Amenities"),_.Literal("Corner-Canal View"),_.Literal("Business Bay"),_.Literal("Park Facing"),_.Literal("Corner-Park Facing"),_.Literal("Partial Park"),_.Literal("BK/DT / Amenities"),_.Literal("Corner-BK/DT / Amenities"),_.Literal("Corner-Canal / BK/DT View"),_.Literal("Marina View"),_.Literal("Partial Marina View"),_.Literal("Partial Marina, Partial City View"),_.Literal("City view"),_.Literal("Marina View, Sea View"),_.Literal("Partial Marina View, Partial Sea View")])}))}).get("/get-floors-data/:project",async({params:{project:X}})=>{try{let Z=await jX.select({unitNo:a.unitNo,floor:a.floor,unitType:a.unitType}).from(a).where(K2(a.project,decodeURIComponent(X))),Y=new Map;for(let{unitNo:$,floor:W,unitType:J}of Z){if(!$||!W||!J)continue;let z=$.toString().startsWith("W")?"west":"east";if(!Y.has(W))Y.set(W,{floor:W,east:{types:{},totalUnits:0},west:{types:{},totalUnits:0}});let Q=Y.get(W);if(z==="east")Q.east.types[J]=(Q.east.types[J]||0)+1,Q.east.totalUnits++;else Q.west.types[J]=(Q.west.types[J]||0)+1,Q.west.totalUnits++}return Array.from(Y.values()).map(($)=>({floor:$.floor,east:$.east,west:$.west}))}catch(Z){return console.log(Z.message),_1(500,"Internal server error")}},{params:_.Object({project:_.String()})});export{Od as unitsController,wd as getUnitSchema}; diff --git a/dist/db/index.js b/dist/db/index.js deleted file mode 100644 index 4c77992..0000000 --- a/dist/db/index.js +++ /dev/null @@ -1,8 +0,0 @@ -// @bun -var S$=Object.defineProperty;var v$=($,X)=>{for(var Y in X)S$($,Y,{get:X[Y],enumerable:!0,configurable:!0,set:(Z)=>X[Y]=()=>Z})};var{SQL:T0}=globalThis.Bun;var G=Symbol.for("drizzle:entityKind"),a$=Symbol.for("drizzle:hasOwnEntityKind");function z($,X){if(!$||typeof $!=="object")return!1;if($ instanceof X)return!0;if(!Object.prototype.hasOwnProperty.call(X,G))throw new Error(`Class "${X.name??""}" doesn't look like a Drizzle entity. If this is incorrect and the class is provided by Drizzle, please report this as a bug.`);let Y=Object.getPrototypeOf($).constructor;if(Y)while(Y){if(G in Y&&Y[G]===X[G])return!0;Y=Object.getPrototypeOf(Y)}return!1}class S0{static[G]="ConsoleLogWriter";write($){console.log($)}}class i2{static[G]="DefaultLogger";writer;constructor($){this.writer=$?.writer??new S0}logQuery($,X){let Y=X.map((_)=>{try{return JSON.stringify(_)}catch{return String(_)}}),Z=Y.length?` -- params: [${Y.join(", ")}]`:"";this.writer.write(`Query: ${$}${Z}`)}}class l2{static[G]="NoopLogger";logQuery(){}}class f{static[G]="QueryPromise";[Symbol.toStringTag]="QueryPromise";catch($){return this.then(void 0,$)}finally($){return this.then((X)=>{return $?.(),X},(X)=>{throw $?.(),X})}then($,X){return this.execute().then($,X)}}class N{constructor($,X){this.table=$,this.config=X,this.name=X.name,this.keyAsName=X.keyAsName,this.notNull=X.notNull,this.default=X.default,this.defaultFn=X.defaultFn,this.onUpdateFn=X.onUpdateFn,this.hasDefault=X.hasDefault,this.primary=X.primaryKey,this.isUnique=X.isUnique,this.uniqueName=X.uniqueName,this.uniqueType=X.uniqueType,this.dataType=X.dataType,this.columnType=X.columnType,this.generated=X.generated,this.generatedIdentity=X.generatedIdentity}static[G]="Column";name;keyAsName;primary;notNull;default;defaultFn;onUpdateFn;hasDefault;isUnique;uniqueName;uniqueType;dataType;columnType;enumValues=void 0;generated=void 0;generatedIdentity=void 0;config;mapFromDriverValue($){return $}mapToDriverValue($){return $}shouldDisableInsert(){return this.config.generated!==void 0&&this.config.generated.type!=="byDefault"}}class a2{static[G]="ColumnBuilder";config;constructor($,X,Y){this.config={name:$,keyAsName:$==="",notNull:!1,default:void 0,hasDefault:!1,primaryKey:!1,isUnique:!1,uniqueName:void 0,uniqueType:void 0,dataType:X,columnType:Y,generated:void 0}}$type(){return this}notNull(){return this.config.notNull=!0,this}default($){return this.config.default=$,this.config.hasDefault=!0,this}$defaultFn($){return this.config.defaultFn=$,this.config.hasDefault=!0,this}$default=this.$defaultFn;$onUpdateFn($){return this.config.onUpdateFn=$,this.config.hasDefault=!0,this}$onUpdate=this.$onUpdateFn;primaryKey(){return this.config.primaryKey=!0,this.config.notNull=!0,this}setName($){if(this.config.name!=="")return;this.config.name=$}}var t=Symbol.for("drizzle:Name");class e2{static[G]="PgForeignKeyBuilder";reference;_onUpdate="no action";_onDelete="no action";constructor($,X){if(this.reference=()=>{let{name:Y,columns:Z,foreignColumns:_}=$();return{name:Y,columns:Z,foreignTable:_[0].table,foreignColumns:_}},X)this._onUpdate=X.onUpdate,this._onDelete=X.onDelete}onUpdate($){return this._onUpdate=$===void 0?"no action":$,this}onDelete($){return this._onDelete=$===void 0?"no action":$,this}build($){return new v0($,this)}}class v0{constructor($,X){this.table=$,this.reference=X.reference,this.onUpdate=X._onUpdate,this.onDelete=X._onDelete}static[G]="PgForeignKey";reference;onUpdate;onDelete;getName(){let{name:$,columns:X,foreignColumns:Y}=this.reference(),Z=X.map((E)=>E.name),_=Y.map((E)=>E.name),W=[this.table[t],...Z,Y[0].table[t],..._];return $??`${W.join("_")}_fk`}}function N2($,...X){return $(...X)}function B0($){return new C0($)}function $0($,X){return`${$[t]}_${X.join("_")}_unique`}class h0{constructor($,X){this.name=X,this.columns=$}static[G]="PgUniqueConstraintBuilder";columns;nullsNotDistinctConfig=!1;nullsNotDistinct(){return this.nullsNotDistinctConfig=!0,this}build($){return new q0($,this.columns,this.nullsNotDistinctConfig,this.name)}}class C0{static[G]="PgUniqueOnConstraintBuilder";name;constructor($){this.name=$}on(...$){return new h0($,this.name)}}class q0{constructor($,X,Y,Z){this.table=$,this.columns=X,this.name=Z??$0(this.table,this.columns.map((_)=>_.name)),this.nullsNotDistinct=Y}static[G]="PgUniqueConstraint";columns;name;nullsNotDistinct=!1;getName(){return this.name}}function P0($,X,Y){for(let Z=X;Z<$.length;Z++){let _=$[Z];if(_==="\\"){Z++;continue}if(_==='"')return[$.slice(X,Z).replace(/\\/g,""),Z+1];if(Y)continue;if(_===","||_==="}")return[$.slice(X,Z).replace(/\\/g,""),Z]}return[$.slice(X).replace(/\\/g,""),$.length]}function p0($,X=0){let Y=[],Z=X,_=!1;while(Z<$.length){let W=$[Z];if(W===","){if(_||Z===X)Y.push("");_=!0,Z++;continue}if(_=!1,W==="\\"){Z+=2;continue}if(W==='"'){let[D,H]=P0($,Z+1,!0);Y.push(D),Z=H;continue}if(W==="}")return[Y,Z+1];if(W==="{"){let[D,H]=p0($,Z+1);Y.push(D),Z=H;continue}let[E,F]=P0($,Z,!1);Y.push(E),Z=F}return[Y,Z]}function y0($){let[X]=p0($,1);return X}function X0($){return`{${$.map((X)=>{if(Array.isArray(X))return X0(X);if(typeof X==="string")return`"${X.replace(/\\/g,"\\\\").replace(/"/g,"\\\"")}"`;return`${X}`}).join(",")}}`}class M extends a2{foreignKeyConfigs=[];static[G]="PgColumnBuilder";array($){return new b0(this.config.name,this,$)}references($,X={}){return this.foreignKeyConfigs.push({ref:$,actions:X}),this}unique($,X){return this.config.isUnique=!0,this.config.uniqueName=$,this.config.uniqueType=X?.nulls,this}generatedAlwaysAs($){return this.config.generated={as:$,type:"always",mode:"stored"},this}buildForeignKeys($,X){return this.foreignKeyConfigs.map(({ref:Y,actions:Z})=>{return N2((_,W)=>{let E=new e2(()=>{let F=_();return{columns:[$],foreignColumns:[F]}});if(W.onUpdate)E.onUpdate(W.onUpdate);if(W.onDelete)E.onDelete(W.onDelete);return E.build(X)},Y,Z)})}buildExtraConfigColumn($){return new f0($,this.config)}}class O extends N{constructor($,X){if(!X.uniqueName)X.uniqueName=$0($,[X.name]);super($,X);this.table=$}static[G]="PgColumn"}class f0 extends O{static[G]="ExtraConfigColumn";getSQLType(){return this.getSQLType()}indexConfig={order:this.config.order??"asc",nulls:this.config.nulls??"last",opClass:this.config.opClass};defaultConfig={order:"asc",nulls:"last",opClass:void 0};asc(){return this.indexConfig.order="asc",this}desc(){return this.indexConfig.order="desc",this}nullsFirst(){return this.indexConfig.nulls="first",this}nullsLast(){return this.indexConfig.nulls="last",this}op($){return this.indexConfig.opClass=$,this}}class b0 extends M{static[G]="PgArrayBuilder";constructor($,X,Y){super($,"array","PgArray");this.config.baseBuilder=X,this.config.size=Y}build($){let X=this.config.baseBuilder.build($);return new Y0($,this.config,X)}}class Y0 extends O{constructor($,X,Y,Z){super($,X);this.baseColumn=Y,this.range=Z,this.size=X.size}size;static[G]="PgArray";getSQLType(){return`${this.baseColumn.getSQLType()}[${typeof this.size==="number"?this.size:""}]`}mapFromDriverValue($){if(typeof $==="string")$=y0($);return $.map((X)=>this.baseColumn.mapFromDriverValue(X))}mapToDriverValue($,X=!1){let Y=$.map((Z)=>Z===null?null:z(this.baseColumn,Y0)?this.baseColumn.mapToDriverValue(Z,!0):this.baseColumn.mapToDriverValue(Z));if(X)return Y;return X0(Y)}}var d0=Symbol.for("drizzle:isPgEnum");function m0($){return!!$&&typeof $==="function"&&d0 in $&&$[d0]===!0}class B$ extends O{static[G]="PgEnumColumn";enum=this.config.enum;enumValues=this.config.enum.enumValues;constructor($,X){super($,X);this.enum=X.enum}getSQLType(){return this.enum.enumName}}class B{static[G]="Subquery";constructor($,X,Y,Z=!1){this._={brand:"Subquery",sql:$,selectedFields:X,alias:Y,isWith:Z}}}class D2 extends B{static[G]="WithSubquery"}var g0="0.41.0";var Z0,_0,k={startActiveSpan($,X){if(!Z0)return X();if(!_0)_0=Z0.trace.getTracer("drizzle-orm",g0);return N2((Y,Z)=>Z.startActiveSpan($,(_)=>{try{return X(_)}catch(W){throw _.setStatus({code:Y.SpanStatusCode.ERROR,message:W instanceof Error?W.message:"Unknown error"}),W}finally{_.end()}}),Z0,_0)}};var T=Symbol.for("drizzle:ViewBaseConfig");var k2=Symbol.for("drizzle:Schema"),T2=Symbol.for("drizzle:Columns"),c0=Symbol.for("drizzle:ExtraConfigColumns"),G0=Symbol.for("drizzle:OriginalName"),J0=Symbol.for("drizzle:BaseName"),O2=Symbol.for("drizzle:IsAlias"),u0=Symbol.for("drizzle:ExtraConfigBuilder"),h$=Symbol.for("drizzle:IsDrizzleTable");class V{static[G]="Table";static Symbol={Name:t,Schema:k2,OriginalName:G0,Columns:T2,ExtraConfigColumns:c0,BaseName:J0,IsAlias:O2,ExtraConfigBuilder:u0};[t];[G0];[k2];[T2];[c0];[J0];[O2]=!1;[h$]=!0;[u0]=void 0;constructor($,X,Y){this[t]=this[G0]=$,this[k2]=X,this[J0]=Y}}function m($){return $[t]}function G2($){return`${$[k2]??"public"}.${$[t]}`}function W0($){return $!==null&&$!==void 0&&typeof $.getSQL==="function"}function C$($){let X={sql:"",params:[]};for(let Y of $)if(X.sql+=Y.sql,X.params.push(...Y.params),Y.typings?.length){if(!X.typings)X.typings=[];X.typings.push(...Y.typings)}return X}class h{static[G]="StringChunk";value;constructor($){this.value=Array.isArray($)?$:[$]}getSQL(){return new x([this])}}class x{constructor($){this.queryChunks=$}static[G]="SQL";decoder=r0;shouldInlineParams=!1;append($){return this.queryChunks.push(...$.queryChunks),this}toQuery($){return k.startActiveSpan("drizzle.buildSQL",(X)=>{let Y=this.buildQueryFromSourceParams(this.queryChunks,$);return X?.setAttributes({"drizzle.query.text":Y.sql,"drizzle.query.params":JSON.stringify(Y.params)}),Y})}buildQueryFromSourceParams($,X){let Y=Object.assign({},X,{inlineParams:X.inlineParams||this.shouldInlineParams,paramStartIndex:X.paramStartIndex||{value:0}}),{casing:Z,escapeName:_,escapeParam:W,prepareTyping:E,inlineParams:F,paramStartIndex:D}=Y;return C$($.map((H)=>{if(z(H,h))return{sql:H.value.join(""),params:[]};if(z(H,j2))return{sql:_(H.value),params:[]};if(H===void 0)return{sql:"",params:[]};if(Array.isArray(H)){let U=[new h("(")];for(let[A,Q]of H.entries())if(U.push(Q),A$},t0={mapToDriverValue:($)=>$},oX={...r0,...t0};class o{constructor($,X=t0){this.value=$,this.encoder=X}static[G]="Param";brand;getSQL(){return new x([this])}}function J($,...X){let Y=[];if(X.length>0||$.length>0&&$[0]!=="")Y.push(new h($[0]));for(let[Z,_]of X.entries())Y.push(_,new h($[Z+1]));return new x(Y)}(($)=>{function X(){return new x([])}$.empty=X;function Y(D){return new x(D)}$.fromList=Y;function Z(D){return new x([new h(D)])}$.raw=Z;function _(D,H){let U=[];for(let[A,Q]of D.entries()){if(A>0&&H!==void 0)U.push(H);U.push(Q)}return new x(U)}$.join=_;function W(D){return new j2(D)}$.identifier=W;function E(D){return new $2(D)}$.placeholder=E;function F(D,H){return new o(D,H)}$.param=F})(J||(J={}));(($)=>{class X{constructor(Y,Z){this.sql=Y,this.fieldAlias=Z}static[G]="SQL.Aliased";isSelectionField=!1;getSQL(){return this.sql}clone(){return new X(this.sql,this.fieldAlias)}}$.Aliased=X})(x||(x={}));class $2{constructor($){this.name=$}static[G]="Placeholder";getSQL(){return new x([this])}}function H0($,X){return $.map((Y)=>{if(z(Y,$2)){if(!(Y.name in X))throw new Error(`No value for placeholder "${Y.name}" was provided`);return X[Y.name]}if(z(Y,o)&&z(Y.value,$2)){if(!(Y.value.name in X))throw new Error(`No value for placeholder "${Y.value.name}" was provided`);return Y.encoder.mapToDriverValue(X[Y.value.name])}return Y})}var q$=Symbol.for("drizzle:IsDrizzleView");class g{static[G]="View";[T];[q$]=!0;constructor({name:$,schema:X,selectedFields:Y,query:Z}){this[T]={name:$,originalName:$,schema:X,selectedFields:Y,query:Z,isExisting:!Z,isAlias:!1}}getSQL(){return new x([this])}}N.prototype.getSQL=function(){return new x([this])};V.prototype.getSQL=function(){return new x([this])};B.prototype.getSQL=function(){return new x([this])};class H2{constructor($){this.table=$}static[G]="ColumnAliasProxyHandler";get($,X){if(X==="table")return this.table;return $[X]}}class U2{constructor($,X){this.alias=$,this.replaceOriginalName=X}static[G]="TableAliasProxyHandler";get($,X){if(X===V.Symbol.IsAlias)return!0;if(X===V.Symbol.Name)return this.alias;if(this.replaceOriginalName&&X===V.Symbol.OriginalName)return this.alias;if(X===T)return{...$[T],name:this.alias,isAlias:!0};if(X===V.Symbol.Columns){let Z=$[V.Symbol.Columns];if(!Z)return Z;let _={};return Object.keys(Z).map((W)=>{_[W]=new Proxy(Z[W],new H2(new Proxy($,this)))}),_}let Y=$[X];if(z(Y,N))return new Proxy(Y,new H2(new Proxy($,this)));return Y}}function S2($,X){return new Proxy($,new U2(X,!1))}function s($,X){return new Proxy($,new H2(new Proxy($.table,new U2(X,!1))))}function E0($,X){return new x.Aliased(V2($.sql,X),$.fieldAlias)}function V2($,X){return J.join($.queryChunks.map((Y)=>{if(z(Y,N))return s(Y,X);if(z(Y,x))return V2(Y,X);if(z(Y,x.Aliased))return E0(Y,X);return Y}))}class S{static[G]="SelectionProxyHandler";config;constructor($){this.config={...$}}get($,X){if(X==="_")return{...$._,selectedFields:new Proxy($._.selectedFields,this)};if(X===T)return{...$[T],selectedFields:new Proxy($[T].selectedFields,this)};if(typeof X==="symbol")return $[X];let Z=(z($,B)?$._.selectedFields:z($,g)?$[T].selectedFields:$)[X];if(z(Z,x.Aliased)){if(this.config.sqlAliasedBehavior==="sql"&&!Z.isSelectionField)return Z.sql;let _=Z.clone();return _.isSelectionField=!0,_}if(z(Z,x)){if(this.config.sqlBehavior==="sql")return Z;throw new Error(`You tried to reference "${X}" field from a subquery, which is a raw SQL field, but it doesn't have an alias declared. Please add an alias to the field using ".as('alias')" method.`)}if(z(Z,N)){if(this.config.alias)return new Proxy(Z,new H2(new Proxy(Z.table,new U2(this.config.alias,this.config.replaceOriginalName??!1))));return Z}if(typeof Z!=="object"||Z===null)return Z;return new Proxy(Z,new S(this.config))}}function s0($,X,Y){let Z={},_=$.reduce((W,{path:E,field:F},D)=>{let H;if(z(F,N))H=F;else if(z(F,x))H=F.decoder;else H=F.sql.decoder;let U=W;for(let[A,Q]of E.entries())if(A0){for(let[W,E]of Object.entries(Z))if(typeof E==="string"&&!Y[E])_[W]=null}return _}function r($,X){return Object.entries($).reduce((Y,[Z,_])=>{if(typeof Z!=="string")return Y;let W=X?[...X,Z]:[Z];if(z(_,N)||z(_,x)||z(_,x.Aliased))Y.push({path:W,field:_});else if(z(_,V))Y.push(...r(_[V.Symbol.Columns],W));else Y.push(...r(_,W));return Y},[])}function x2($,X){let Y=Object.keys($),Z=Object.keys(X);if(Y.length!==Z.length)return!1;for(let[_,W]of Y.entries())if(W!==Z[_])return!1;return!0}function v2($,X){let Y=Object.entries(X).filter(([,Z])=>Z!==void 0).map(([Z,_])=>{if(z(_,x)||z(_,N))return[Z,_];else return[Z,new o(_,$[V.Symbol.Columns][Z])]});if(Y.length===0)throw new Error("No values to set");return Object.fromEntries(Y)}function n0($,X){for(let Y of X)for(let Z of Object.getOwnPropertyNames(Y.prototype)){if(Z==="constructor")continue;Object.defineProperty($.prototype,Z,Object.getOwnPropertyDescriptor(Y.prototype,Z)||Object.create(null))}}function i0($){return $[V.Symbol.Columns]}function i($){return z($,B)?$._.alias:z($,g)?$[T].name:z($,x)?void 0:$[V.Symbol.IsAlias]?$[V.Symbol.Name]:$[V.Symbol.BaseName]}function R($,X){return{name:typeof $==="string"&&$.length>0?$:"",config:typeof $==="object"?$:X}}function l0($){if(typeof $!=="object"||$===null)return!1;if($.constructor.name!=="Object")return!1;if("logger"in $){let X=typeof $.logger;if(X!=="boolean"&&(X!=="object"||typeof $.logger.logQuery!=="function")&&X!=="undefined")return!1;return!0}if("schema"in $){let X=typeof $.schema;if(X!=="object"&&X!=="undefined")return!1;return!0}if("casing"in $){let X=typeof $.casing;if(X!=="string"&&X!=="undefined")return!1;return!0}if("mode"in $){if($.mode!=="default"||$.mode!=="planetscale"||$.mode!==void 0)return!1;return!0}if("connection"in $){let X=typeof $.connection;if(X!=="string"&&X!=="object"&&X!=="undefined")return!1;return!0}if("client"in $){let X=typeof $.client;if(X!=="object"&&X!=="function"&&X!=="undefined")return!1;return!0}if(Object.keys($).length===0)return!0;return!1}class B2 extends f{constructor($,X,Y,Z){super();this.session=X,this.dialect=Y,this.config={table:$,withList:Z}}static[G]="PgDelete";config;where($){return this.config.where=$,this}returning($=this.config.table[V.Symbol.Columns]){return this.config.returningFields=$,this.config.returning=r($),this}getSQL(){return this.dialect.buildDeleteQuery(this.config)}toSQL(){let{typings:$,...X}=this.dialect.sqlToQuery(this.getSQL());return X}_prepare($){return k.startActiveSpan("drizzle.prepareQuery",()=>{return this.session.prepareQuery(this.dialect.sqlToQuery(this.getSQL()),this.config.returning,$,!0)})}prepare($){return this._prepare($)}authToken;setToken($){return this.authToken=$,this}execute=($)=>{return k.startActiveSpan("drizzle.operation",()=>{return this._prepare().execute($,this.authToken)})};getSelectedFields(){return this.config.returningFields?new Proxy(this.config.returningFields,new S({alias:m(this.config.table),sqlAliasedBehavior:"alias",sqlBehavior:"error"})):void 0}$dynamic(){return this}}function P$($){return($.replace(/['\u2019]/g,"").match(/[\da-z]+|[A-Z]+(?![a-z])|[A-Z][\da-z]+/g)??[]).map((Y)=>Y.toLowerCase()).join("_")}function p$($){return($.replace(/['\u2019]/g,"").match(/[\da-z]+|[A-Z]+(?![a-z])|[A-Z][\da-z]+/g)??[]).reduce((Y,Z,_)=>{let W=_===0?Z.toLowerCase():`${Z[0].toUpperCase()}${Z.slice(1)}`;return Y+W},"")}function y$($){return $}class z0{static[G]="CasingCache";cache={};cachedTables={};convert;constructor($){this.convert=$==="snake_case"?P$:$==="camelCase"?p$:y$}getColumnCasing($){if(!$.keyAsName)return $.name;let X=$.table[V.Symbol.Schema]??"public",Y=$.table[V.Symbol.OriginalName],Z=`${X}.${Y}.${$.name}`;if(!this.cache[Z])this.cacheTable($.table);return this.cache[Z]}cacheTable($){let X=$[V.Symbol.Schema]??"public",Y=$[V.Symbol.OriginalName],Z=`${X}.${Y}`;if(!this.cachedTables[Z]){for(let _ of Object.values($[V.Symbol.Columns])){let W=`${Z}.${_.name}`;this.cache[W]=this.convert(_.name)}this.cachedTables[Z]=!0}}clearCache(){this.cache={},this.cachedTables={}}}class h2 extends Error{static[G]="DrizzleError";constructor({message:$,cause:X}){super($);this.name="DrizzleError",this.cause=X}}class F0 extends h2{static[G]="TransactionRollbackError";constructor(){super({message:"Rollback"})}}class X2 extends M{static[G]="PgIntColumnBaseBuilder";generatedAlwaysAsIdentity($){if($){let{name:X,...Y}=$;this.config.generatedIdentity={type:"always",sequenceName:X,sequenceOptions:Y}}else this.config.generatedIdentity={type:"always"};return this.config.hasDefault=!0,this.config.notNull=!0,this}generatedByDefaultAsIdentity($){if($){let{name:X,...Y}=$;this.config.generatedIdentity={type:"byDefault",sequenceName:X,sequenceOptions:Y}}else this.config.generatedIdentity={type:"byDefault"};return this.config.hasDefault=!0,this.config.notNull=!0,this}}class a0 extends X2{static[G]="PgBigInt53Builder";constructor($){super($,"number","PgBigInt53")}build($){return new e0($,this.config)}}class e0 extends O{static[G]="PgBigInt53";getSQLType(){return"bigint"}mapFromDriverValue($){if(typeof $==="number")return $;return Number($)}}class $1 extends X2{static[G]="PgBigInt64Builder";constructor($){super($,"bigint","PgBigInt64")}build($){return new X1($,this.config)}}class X1 extends O{static[G]="PgBigInt64";getSQLType(){return"bigint"}mapFromDriverValue($){return BigInt($)}}function Y1($,X){let{name:Y,config:Z}=R($,X);if(Z.mode==="number")return new a0(Y);return new $1(Y)}class Z1 extends M{static[G]="PgBigSerial53Builder";constructor($){super($,"number","PgBigSerial53");this.config.hasDefault=!0,this.config.notNull=!0}build($){return new _1($,this.config)}}class _1 extends O{static[G]="PgBigSerial53";getSQLType(){return"bigserial"}mapFromDriverValue($){if(typeof $==="number")return $;return Number($)}}class G1 extends M{static[G]="PgBigSerial64Builder";constructor($){super($,"bigint","PgBigSerial64");this.config.hasDefault=!0}build($){return new J1($,this.config)}}class J1 extends O{static[G]="PgBigSerial64";getSQLType(){return"bigserial"}mapFromDriverValue($){return BigInt($)}}function W1($,X){let{name:Y,config:Z}=R($,X);if(Z.mode==="number")return new Z1(Y);return new G1(Y)}class H1 extends M{static[G]="PgBooleanBuilder";constructor($){super($,"boolean","PgBoolean")}build($){return new E1($,this.config)}}class E1 extends O{static[G]="PgBoolean";getSQLType(){return"boolean"}}function z1($){return new H1($??"")}class F1 extends M{static[G]="PgCharBuilder";constructor($,X){super($,"string","PgChar");this.config.length=X.length,this.config.enumValues=X.enum}build($){return new D1($,this.config)}}class D1 extends O{static[G]="PgChar";length=this.config.length;enumValues=this.config.enumValues;getSQLType(){return this.length===void 0?"char":`char(${this.length})`}}function O1($,X={}){let{name:Y,config:Z}=R($,X);return new F1(Y,Z)}class U1 extends M{static[G]="PgCidrBuilder";constructor($){super($,"string","PgCidr")}build($){return new V1($,this.config)}}class V1 extends O{static[G]="PgCidr";getSQLType(){return"cidr"}}function x1($){return new U1($??"")}class M1 extends M{static[G]="PgCustomColumnBuilder";constructor($,X,Y){super($,"custom","PgCustomColumn");this.config.fieldConfig=X,this.config.customTypeParams=Y}build($){return new A1($,this.config)}}class A1 extends O{static[G]="PgCustomColumn";sqlName;mapTo;mapFrom;constructor($,X){super($,X);this.sqlName=X.customTypeParams.dataType(X.fieldConfig),this.mapTo=X.customTypeParams.toDriver,this.mapFrom=X.customTypeParams.fromDriver}getSQLType(){return this.sqlName}mapFromDriverValue($){return typeof this.mapFrom==="function"?this.mapFrom($):$}mapToDriverValue($){return typeof this.mapTo==="function"?this.mapTo($):$}}function Q1($){return(X,Y)=>{let{name:Z,config:_}=R(X,Y);return new M1(Z,_,$)}}class l extends M{static[G]="PgDateColumnBaseBuilder";defaultNow(){return this.default(J`now()`)}}class I1 extends l{static[G]="PgDateBuilder";constructor($){super($,"date","PgDate")}build($){return new C2($,this.config)}}class C2 extends O{static[G]="PgDate";getSQLType(){return"date"}mapFromDriverValue($){return new Date($)}mapToDriverValue($){return $.toISOString()}}class R1 extends l{static[G]="PgDateStringBuilder";constructor($){super($,"string","PgDateString")}build($){return new q2($,this.config)}}class q2 extends O{static[G]="PgDateString";getSQLType(){return"date"}}function K1($,X){let{name:Y,config:Z}=R($,X);if(Z?.mode==="date")return new I1(Y);return new R1(Y)}class w1 extends M{static[G]="PgDoublePrecisionBuilder";constructor($){super($,"number","PgDoublePrecision")}build($){return new L1($,this.config)}}class L1 extends O{static[G]="PgDoublePrecision";getSQLType(){return"double precision"}mapFromDriverValue($){if(typeof $==="string")return Number.parseFloat($);return $}}function E2($){return new w1($??"")}class N1 extends M{static[G]="PgInetBuilder";constructor($){super($,"string","PgInet")}build($){return new k1($,this.config)}}class k1 extends O{static[G]="PgInet";getSQLType(){return"inet"}}function T1($){return new N1($??"")}class j1 extends X2{static[G]="PgIntegerBuilder";constructor($){super($,"number","PgInteger")}build($){return new S1($,this.config)}}class S1 extends O{static[G]="PgInteger";getSQLType(){return"integer"}mapFromDriverValue($){if(typeof $==="string")return Number.parseInt($);return $}}function Y2($){return new j1($??"")}class v1 extends M{static[G]="PgIntervalBuilder";constructor($,X){super($,"string","PgInterval");this.config.intervalConfig=X}build($){return new B1($,this.config)}}class B1 extends O{static[G]="PgInterval";fields=this.config.intervalConfig.fields;precision=this.config.intervalConfig.precision;getSQLType(){let $=this.fields?` ${this.fields}`:"",X=this.precision?`(${this.precision})`:"";return`interval${$}${X}`}}function h1($,X={}){let{name:Y,config:Z}=R($,X);return new v1(Y,Z)}class C1 extends M{static[G]="PgJsonBuilder";constructor($){super($,"json","PgJson")}build($){return new P2($,this.config)}}class P2 extends O{static[G]="PgJson";constructor($,X){super($,X)}getSQLType(){return"json"}mapToDriverValue($){return JSON.stringify($)}mapFromDriverValue($){if(typeof $==="string")try{return JSON.parse($)}catch{return $}return $}}function q1($){return new C1($??"")}class P1 extends M{static[G]="PgJsonbBuilder";constructor($){super($,"json","PgJsonb")}build($){return new p2($,this.config)}}class p2 extends O{static[G]="PgJsonb";constructor($,X){super($,X)}getSQLType(){return"jsonb"}mapToDriverValue($){return JSON.stringify($)}mapFromDriverValue($){if(typeof $==="string")try{return JSON.parse($)}catch{return $}return $}}function p1($){return new P1($??"")}class y1 extends M{static[G]="PgLineBuilder";constructor($){super($,"array","PgLine")}build($){return new f1($,this.config)}}class f1 extends O{static[G]="PgLine";getSQLType(){return"line"}mapFromDriverValue($){let[X,Y,Z]=$.slice(1,-1).split(",");return[Number.parseFloat(X),Number.parseFloat(Y),Number.parseFloat(Z)]}mapToDriverValue($){return`{${$[0]},${$[1]},${$[2]}}`}}class b1 extends M{static[G]="PgLineABCBuilder";constructor($){super($,"json","PgLineABC")}build($){return new d1($,this.config)}}class d1 extends O{static[G]="PgLineABC";getSQLType(){return"line"}mapFromDriverValue($){let[X,Y,Z]=$.slice(1,-1).split(",");return{a:Number.parseFloat(X),b:Number.parseFloat(Y),c:Number.parseFloat(Z)}}mapToDriverValue($){return`{${$.a},${$.b},${$.c}}`}}function m1($,X){let{name:Y,config:Z}=R($,X);if(!Z?.mode||Z.mode==="tuple")return new y1(Y);return new b1(Y)}class g1 extends M{static[G]="PgMacaddrBuilder";constructor($){super($,"string","PgMacaddr")}build($){return new c1($,this.config)}}class c1 extends O{static[G]="PgMacaddr";getSQLType(){return"macaddr"}}function u1($){return new g1($??"")}class o1 extends M{static[G]="PgMacaddr8Builder";constructor($){super($,"string","PgMacaddr8")}build($){return new r1($,this.config)}}class r1 extends O{static[G]="PgMacaddr8";getSQLType(){return"macaddr8"}}function t1($){return new o1($??"")}class s1 extends M{static[G]="PgNumericBuilder";constructor($,X,Y){super($,"string","PgNumeric");this.config.precision=X,this.config.scale=Y}build($){return new y2($,this.config)}}class y2 extends O{static[G]="PgNumeric";precision;scale;constructor($,X){super($,X);this.precision=X.precision,this.scale=X.scale}mapFromDriverValue($){if(typeof $==="string")return $;return String($)}getSQLType(){if(this.precision!==void 0&&this.scale!==void 0)return`numeric(${this.precision}, ${this.scale})`;else if(this.precision===void 0)return"numeric";else return`numeric(${this.precision})`}}class n1 extends M{static[G]="PgNumericNumberBuilder";constructor($,X,Y){super($,"number","PgNumericNumber");this.config.precision=X,this.config.scale=Y}build($){return new i1($,this.config)}}class i1 extends O{static[G]="PgNumericNumber";precision;scale;constructor($,X){super($,X);this.precision=X.precision,this.scale=X.scale}mapFromDriverValue($){if(typeof $==="number")return $;return Number($)}mapToDriverValue=String;getSQLType(){if(this.precision!==void 0&&this.scale!==void 0)return`numeric(${this.precision}, ${this.scale})`;else if(this.precision===void 0)return"numeric";else return`numeric(${this.precision})`}}class l1 extends M{static[G]="PgNumericBigIntBuilder";constructor($,X,Y){super($,"bigint","PgNumericBigInt");this.config.precision=X,this.config.scale=Y}build($){return new a1($,this.config)}}class a1 extends O{static[G]="PgNumericBigInt";precision;scale;constructor($,X){super($,X);this.precision=X.precision,this.scale=X.scale}mapFromDriverValue=BigInt;mapToDriverValue=String;getSQLType(){if(this.precision!==void 0&&this.scale!==void 0)return`numeric(${this.precision}, ${this.scale})`;else if(this.precision===void 0)return"numeric";else return`numeric(${this.precision})`}}function e1($,X){let{name:Y,config:Z}=R($,X),_=Z?.mode;return _==="number"?new n1(Y,Z?.precision,Z?.scale):_==="bigint"?new l1(Y,Z?.precision,Z?.scale):new s1(Y,Z?.precision,Z?.scale)}class $8 extends M{static[G]="PgPointTupleBuilder";constructor($){super($,"array","PgPointTuple")}build($){return new X8($,this.config)}}class X8 extends O{static[G]="PgPointTuple";getSQLType(){return"point"}mapFromDriverValue($){if(typeof $==="string"){let[X,Y]=$.slice(1,-1).split(",");return[Number.parseFloat(X),Number.parseFloat(Y)]}return[$.x,$.y]}mapToDriverValue($){return`(${$[0]},${$[1]})`}}class Y8 extends M{static[G]="PgPointObjectBuilder";constructor($){super($,"json","PgPointObject")}build($){return new Z8($,this.config)}}class Z8 extends O{static[G]="PgPointObject";getSQLType(){return"point"}mapFromDriverValue($){if(typeof $==="string"){let[X,Y]=$.slice(1,-1).split(",");return{x:Number.parseFloat(X),y:Number.parseFloat(Y)}}return $}mapToDriverValue($){return`(${$.x},${$.y})`}}function _8($,X){let{name:Y,config:Z}=R($,X);if(!Z?.mode||Z.mode==="tuple")return new $8(Y);return new Y8(Y)}function f$($){let X=[];for(let Y=0;Y<$.length;Y+=2)X.push(Number.parseInt($.slice(Y,Y+2),16));return new Uint8Array(X)}function G8($,X){let Y=new ArrayBuffer(8),Z=new DataView(Y);for(let _=0;_<8;_++)Z.setUint8(_,$[X+_]);return Z.getFloat64(0,!0)}function D0($){let X=f$($),Y=0,Z=X[Y];Y+=1;let _=new DataView(X.buffer),W=_.getUint32(Y,Z===1);Y+=4;let E;if(W&536870912)E=_.getUint32(Y,Z===1),Y+=4;if((W&65535)===1){let F=G8(X,Y);Y+=8;let D=G8(X,Y);return Y+=8,[F,D]}throw new Error("Unsupported geometry type")}class J8 extends M{static[G]="PgGeometryBuilder";constructor($){super($,"array","PgGeometry")}build($){return new W8($,this.config)}}class W8 extends O{static[G]="PgGeometry";getSQLType(){return"geometry(point)"}mapFromDriverValue($){return D0($)}mapToDriverValue($){return`point(${$[0]} ${$[1]})`}}class H8 extends M{static[G]="PgGeometryObjectBuilder";constructor($){super($,"json","PgGeometryObject")}build($){return new E8($,this.config)}}class E8 extends O{static[G]="PgGeometryObject";getSQLType(){return"geometry(point)"}mapFromDriverValue($){let X=D0($);return{x:X[0],y:X[1]}}mapToDriverValue($){return`point(${$.x} ${$.y})`}}function z8($,X){let{name:Y,config:Z}=R($,X);if(!Z?.mode||Z.mode==="tuple")return new J8(Y);return new H8(Y)}class F8 extends M{static[G]="PgRealBuilder";constructor($,X){super($,"number","PgReal");this.config.length=X}build($){return new D8($,this.config)}}class D8 extends O{static[G]="PgReal";constructor($,X){super($,X)}getSQLType(){return"real"}mapFromDriverValue=($)=>{if(typeof $==="string")return Number.parseFloat($);return $}}function O8($){return new F8($??"")}class U8 extends M{static[G]="PgSerialBuilder";constructor($){super($,"number","PgSerial");this.config.hasDefault=!0,this.config.notNull=!0}build($){return new V8($,this.config)}}class V8 extends O{static[G]="PgSerial";getSQLType(){return"serial"}}function x8($){return new U8($??"")}class M8 extends X2{static[G]="PgSmallIntBuilder";constructor($){super($,"number","PgSmallInt")}build($){return new A8($,this.config)}}class A8 extends O{static[G]="PgSmallInt";getSQLType(){return"smallint"}mapFromDriverValue=($)=>{if(typeof $==="string")return Number($);return $}}function Q8($){return new M8($??"")}class I8 extends M{static[G]="PgSmallSerialBuilder";constructor($){super($,"number","PgSmallSerial");this.config.hasDefault=!0,this.config.notNull=!0}build($){return new R8($,this.config)}}class R8 extends O{static[G]="PgSmallSerial";getSQLType(){return"smallserial"}}function K8($){return new I8($??"")}class w8 extends M{static[G]="PgTextBuilder";constructor($,X){super($,"string","PgText");this.config.enumValues=X.enum}build($){return new L8($,this.config)}}class L8 extends O{static[G]="PgText";enumValues=this.config.enumValues;getSQLType(){return"text"}}function N8($,X={}){let{name:Y,config:Z}=R($,X);return new w8(Y,Z)}class k8 extends l{constructor($,X,Y){super($,"string","PgTime");this.withTimezone=X,this.precision=Y,this.config.withTimezone=X,this.config.precision=Y}static[G]="PgTimeBuilder";build($){return new f2($,this.config)}}class f2 extends O{static[G]="PgTime";withTimezone;precision;constructor($,X){super($,X);this.withTimezone=X.withTimezone,this.precision=X.precision}getSQLType(){return`time${this.precision===void 0?"":`(${this.precision})`}${this.withTimezone?" with time zone":""}`}}function T8($,X={}){let{name:Y,config:Z}=R($,X);return new k8(Y,Z.withTimezone??!1,Z.precision)}class j8 extends l{static[G]="PgTimestampBuilder";constructor($,X,Y){super($,"date","PgTimestamp");this.config.withTimezone=X,this.config.precision=Y}build($){return new b2($,this.config)}}class b2 extends O{static[G]="PgTimestamp";withTimezone;precision;constructor($,X){super($,X);this.withTimezone=X.withTimezone,this.precision=X.precision}getSQLType(){return`timestamp${this.precision===void 0?"":` (${this.precision})`}${this.withTimezone?" with time zone":""}`}mapFromDriverValue=($)=>{return new Date(this.withTimezone?$:$+"+0000")};mapToDriverValue=($)=>{return $.toISOString()}}class S8 extends l{static[G]="PgTimestampStringBuilder";constructor($,X,Y){super($,"string","PgTimestampString");this.config.withTimezone=X,this.config.precision=Y}build($){return new d2($,this.config)}}class d2 extends O{static[G]="PgTimestampString";withTimezone;precision;constructor($,X){super($,X);this.withTimezone=X.withTimezone,this.precision=X.precision}getSQLType(){return`timestamp${this.precision===void 0?"":`(${this.precision})`}${this.withTimezone?" with time zone":""}`}}function v8($,X={}){let{name:Y,config:Z}=R($,X);if(Z?.mode==="string")return new S8(Y,Z.withTimezone??!1,Z.precision);return new j8(Y,Z?.withTimezone??!1,Z?.precision)}class B8 extends M{static[G]="PgUUIDBuilder";constructor($){super($,"string","PgUUID")}defaultRandom(){return this.default(J`gen_random_uuid()`)}build($){return new m2($,this.config)}}class m2 extends O{static[G]="PgUUID";getSQLType(){return"uuid"}}function g2($){return new B8($??"")}class h8 extends M{static[G]="PgVarcharBuilder";constructor($,X){super($,"string","PgVarchar");this.config.length=X.length,this.config.enumValues=X.enum}build($){return new C8($,this.config)}}class C8 extends O{static[G]="PgVarchar";length=this.config.length;enumValues=this.config.enumValues;getSQLType(){return this.length===void 0?"varchar":`varchar(${this.length})`}}function Z2($,X={}){let{name:Y,config:Z}=R($,X);return new h8(Y,Z)}class q8 extends M{static[G]="PgBinaryVectorBuilder";constructor($,X){super($,"string","PgBinaryVector");this.config.dimensions=X.dimensions}build($){return new P8($,this.config)}}class P8 extends O{static[G]="PgBinaryVector";dimensions=this.config.dimensions;getSQLType(){return`bit(${this.dimensions})`}}function p8($,X){let{name:Y,config:Z}=R($,X);return new q8(Y,Z)}class y8 extends M{static[G]="PgHalfVectorBuilder";constructor($,X){super($,"array","PgHalfVector");this.config.dimensions=X.dimensions}build($){return new f8($,this.config)}}class f8 extends O{static[G]="PgHalfVector";dimensions=this.config.dimensions;getSQLType(){return`halfvec(${this.dimensions})`}mapToDriverValue($){return JSON.stringify($)}mapFromDriverValue($){return $.slice(1,-1).split(",").map((X)=>Number.parseFloat(X))}}function b8($,X){let{name:Y,config:Z}=R($,X);return new y8(Y,Z)}class d8 extends M{static[G]="PgSparseVectorBuilder";constructor($,X){super($,"string","PgSparseVector");this.config.dimensions=X.dimensions}build($){return new m8($,this.config)}}class m8 extends O{static[G]="PgSparseVector";dimensions=this.config.dimensions;getSQLType(){return`sparsevec(${this.dimensions})`}}function g8($,X){let{name:Y,config:Z}=R($,X);return new d8(Y,Z)}class c8 extends M{static[G]="PgVectorBuilder";constructor($,X){super($,"array","PgVector");this.config.dimensions=X.dimensions}build($){return new u8($,this.config)}}class u8 extends O{static[G]="PgVector";dimensions=this.config.dimensions;getSQLType(){return`vector(${this.dimensions})`}mapToDriverValue($){return JSON.stringify($)}mapFromDriverValue($){return $.slice(1,-1).split(",").map((X)=>Number.parseFloat(X))}}function o8($,X){let{name:Y,config:Z}=R($,X);return new c8(Y,Z)}function r8(){return{bigint:Y1,bigserial:W1,boolean:z1,char:O1,cidr:x1,customType:Q1,date:K1,doublePrecision:E2,inet:T1,integer:Y2,interval:h1,json:q1,jsonb:p1,line:m1,macaddr:u1,macaddr8:t1,numeric:e1,point:_8,geometry:z8,real:O8,serial:x8,smallint:Q8,smallserial:K8,text:N8,time:T8,timestamp:v8,uuid:g2,varchar:Z2,bit:p8,halfvec:b8,sparsevec:g8,vector:o8}}var O0=Symbol.for("drizzle:PgInlineForeignKeys"),t8=Symbol.for("drizzle:EnableRLS");class q extends V{static[G]="PgTable";static Symbol=Object.assign({},V.Symbol,{InlineForeignKeys:O0,EnableRLS:t8});[O0]=[];[t8]=!1;[V.Symbol.ExtraConfigBuilder]=void 0;[V.Symbol.ExtraConfigColumns]={}}function b$($,X,Y,Z,_=$){let W=new q($,Z,_),E=typeof X==="function"?X(r8()):X,F=Object.fromEntries(Object.entries(E).map(([U,A])=>{let Q=A;Q.setName(U);let w=Q.build(W);return W[O0].push(...Q.buildForeignKeys(w,W)),[U,w]})),D=Object.fromEntries(Object.entries(E).map(([U,A])=>{let Q=A;Q.setName(U);let w=Q.buildExtraConfigColumn(W);return[U,w]})),H=Object.assign(W,F);if(H[V.Symbol.Columns]=F,H[V.Symbol.ExtraConfigColumns]=D,Y)H[q.Symbol.ExtraConfigBuilder]=Y;return Object.assign(H,{enableRLS:()=>{return H[q.Symbol.EnableRLS]=!0,H}})}var s8=($,X,Y)=>{return b$($,X,Y,void 0)};class U0{static[G]="PgPrimaryKeyBuilder";columns;name;constructor($,X){this.columns=$,this.name=X}build($){return new n8($,this.columns,this.name)}}class n8{constructor($,X,Y){this.table=$,this.columns=X,this.name=Y}static[G]="PgPrimaryKey";columns;name;getName(){return this.name??`${this.table[q.Symbol.Name]}_${this.columns.map(($)=>$.name).join("_")}_pk`}}function c($,X){if(o0(X)&&!W0($)&&!z($,o)&&!z($,$2)&&!z($,N)&&!z($,V)&&!z($,g))return new o($,X);return $}var c2=($,X)=>{return J`${$} = ${c(X,$)}`},i8=($,X)=>{return J`${$} <> ${c(X,$)}`};function M2(...$){let X=$.filter((Y)=>Y!==void 0);if(X.length===0)return;if(X.length===1)return new x(X);return new x([new h("("),J.join(X,new h(" and ")),new h(")")])}function l8(...$){let X=$.filter((Y)=>Y!==void 0);if(X.length===0)return;if(X.length===1)return new x(X);return new x([new h("("),J.join(X,new h(" or ")),new h(")")])}function a8($){return J`not ${$}`}var e8=($,X)=>{return J`${$} > ${c(X,$)}`},$$=($,X)=>{return J`${$} >= ${c(X,$)}`},X$=($,X)=>{return J`${$} < ${c(X,$)}`},Y$=($,X)=>{return J`${$} <= ${c(X,$)}`};function Z$($,X){if(Array.isArray(X)){if(X.length===0)return J`false`;return J`${$} in ${X.map((Y)=>c(Y,$))}`}return J`${$} in ${c(X,$)}`}function _$($,X){if(Array.isArray(X)){if(X.length===0)return J`true`;return J`${$} not in ${X.map((Y)=>c(Y,$))}`}return J`${$} not in ${c(X,$)}`}function G$($){return J`${$} is null`}function J$($){return J`${$} is not null`}function W$($){return J`exists ${$}`}function H$($){return J`not exists ${$}`}function E$($,X,Y){return J`${$} between ${c(X,$)} and ${c(Y,$)}`}function z$($,X,Y){return J`${$} not between ${c(X,$)} and ${c(Y,$)}`}function F$($,X){return J`${$} like ${X}`}function D$($,X){return J`${$} not like ${X}`}function O$($,X){return J`${$} ilike ${X}`}function U$($,X){return J`${$} not ilike ${X}`}function V$($){return J`${$} asc`}function x$($){return J`${$} desc`}class V0{constructor($,X,Y){this.sourceTable=$,this.referencedTable=X,this.relationName=Y,this.referencedTableName=X[V.Symbol.Name]}static[G]="Relation";referencedTableName;fieldName}class M${constructor($,X){this.table=$,this.config=X}static[G]="Relations"}class _2 extends V0{constructor($,X,Y,Z){super($,X,Y?.relationName);this.config=Y,this.isNullable=Z}static[G]="One";withFieldName($){let X=new _2(this.sourceTable,this.referencedTable,this.config,this.isNullable);return X.fieldName=$,X}}class A2 extends V0{constructor($,X,Y){super($,X,Y?.relationName);this.config=Y}static[G]="Many";withFieldName($){let X=new A2(this.sourceTable,this.referencedTable,this.config);return X.fieldName=$,X}}function A$(){return{and:M2,between:E$,eq:c2,exists:W$,gt:e8,gte:$$,ilike:O$,inArray:Z$,isNull:G$,isNotNull:J$,like:F$,lt:X$,lte:Y$,ne:i8,not:a8,notBetween:z$,notExists:H$,notLike:D$,notIlike:U$,notInArray:_$,or:l8,sql:J}}function Q$(){return{sql:J,asc:V$,desc:x$}}function I$($,X){if(Object.keys($).length===1&&"default"in $&&!z($.default,V))$=$.default;let Y={},Z={},_={};for(let[W,E]of Object.entries($))if(z(E,V)){let F=G2(E),D=Z[F];Y[F]=W,_[W]={tsName:W,dbName:E[V.Symbol.Name],schema:E[V.Symbol.Schema],columns:E[V.Symbol.Columns],relations:D?.relations??{},primaryKey:D?.primaryKey??[]};for(let U of Object.values(E[V.Symbol.Columns]))if(U.primary)_[W].primaryKey.push(U);let H=E[V.Symbol.ExtraConfigBuilder]?.(E[V.Symbol.ExtraConfigColumns]);if(H){for(let U of Object.values(H))if(z(U,U0))_[W].primaryKey.push(...U.columns)}}else if(z(E,M$)){let F=G2(E.table),D=Y[F],H=E.config(X(E.table)),U;for(let[A,Q]of Object.entries(H))if(D){let w=_[D];if(w.relations[A]=Q,U)w.primaryKey.push(...U)}else{if(!(F in Z))Z[F]={relations:{},primaryKey:U};Z[F].relations[A]=Q}}return{tables:_,tableNamesMap:Y}}function d$($){return function X(Y,Z){return new _2($,Y,Z,Z?.fields.reduce((_,W)=>_&&W.notNull,!0)??!1)}}function m$($){return function X(Y,Z){return new A2($,Y,Z)}}function R$($,X,Y){if(z(Y,_2)&&Y.config)return{fields:Y.config.fields,references:Y.config.references};let Z=X[G2(Y.referencedTable)];if(!Z)throw new Error(`Table "${Y.referencedTable[V.Symbol.Name]}" not found in schema`);let _=$[Z];if(!_)throw new Error(`Table "${Z}" not found in schema`);let W=Y.sourceTable,E=X[G2(W)];if(!E)throw new Error(`Table "${W[V.Symbol.Name]}" not found in schema`);let F=[];for(let D of Object.values(_.relations))if(Y.relationName&&Y!==D&&D.relationName===Y.relationName||!Y.relationName&&D.referencedTable===Y.sourceTable)F.push(D);if(F.length>1)throw Y.relationName?new Error(`There are multiple relations with name "${Y.relationName}" in table "${Z}"`):new Error(`There are multiple relations between "${Z}" and "${Y.sourceTable[V.Symbol.Name]}". Please specify relation name`);if(F[0]&&z(F[0],_2)&&F[0].config)return{fields:F[0].config.references,references:F[0].config.fields};throw new Error(`There is not enough information to infer relation "${E}.${Y.fieldName}"`)}function K$($){return{one:d$($),many:m$($)}}function u2($,X,Y,Z,_=(W)=>W){let W={};for(let[E,F]of Z.entries())if(F.isJson){let D=X.relations[F.tsKey],H=Y[E],U=typeof H==="string"?JSON.parse(H):H;W[F.tsKey]=z(D,_2)?U&&u2($,$[F.relationTableTsKey],U,F.selection,_):U.map((A)=>u2($,$[F.relationTableTsKey],A,F.selection,_))}else{let D=_(Y[E]),H=F.field,U;if(z(H,N))U=H;else if(z(H,x))U=H.decoder;else U=H.sql.decoder;W[F.tsKey]=D===null?null:U.mapFromDriverValue(D)}return W}class Q2 extends g{static[G]="PgViewBase"}class J2{static[G]="PgDialect";casing;constructor($){this.casing=new z0($?.casing)}async migrate($,X,Y){let Z=typeof Y==="string"?"__drizzle_migrations":Y.migrationsTable??"__drizzle_migrations",_=typeof Y==="string"?"drizzle":Y.migrationsSchema??"drizzle",W=J` - CREATE TABLE IF NOT EXISTS ${J.identifier(_)}.${J.identifier(Z)} ( - id SERIAL PRIMARY KEY, - hash text NOT NULL, - created_at bigint - ) - `;await X.execute(J`CREATE SCHEMA IF NOT EXISTS ${J.identifier(_)}`),await X.execute(W);let F=(await X.all(J`select id, hash, created_at from ${J.identifier(_)}.${J.identifier(Z)} order by created_at desc limit 1`))[0];await X.transaction(async(D)=>{for await(let H of $)if(!F||Number(F.created_at)X[W]!==void 0||Y[W]?.onUpdateFn!==void 0),_=Z.length;return J.join(Z.flatMap((W,E)=>{let F=Y[W],D=X[W]??J.param(F.onUpdateFn(),F),H=J`${J.identifier(this.casing.getColumnCasing(F))} = ${D}`;if(E<_-1)return[H,J.raw(", ")];return[H]}))}buildUpdateQuery({table:$,set:X,where:Y,returning:Z,withList:_,from:W,joins:E}){let F=this.buildWithCTE(_),D=$[q.Symbol.Name],H=$[q.Symbol.Schema],U=$[q.Symbol.OriginalName],A=D===U?void 0:D,Q=J`${H?J`${J.identifier(H)}.`:void 0}${J.identifier(U)}${A&&J` ${J.identifier(A)}`}`,w=this.buildUpdateSet($,X),v=W&&J.join([J.raw(" from "),this.buildFromTable(W)]),j=this.buildJoins(E),L=Z?J` returning ${this.buildSelection(Z,{isSingleTable:!W})}`:void 0,P=Y?J` where ${Y}`:void 0;return J`${F}update ${Q} set ${w}${v}${j}${P}${L}`}buildSelection($,{isSingleTable:X=!1}={}){let Y=$.length,Z=$.flatMap(({field:_},W)=>{let E=[];if(z(_,x.Aliased)&&_.isSelectionField)E.push(J.identifier(_.fieldAlias));else if(z(_,x.Aliased)||z(_,x)){let F=z(_,x.Aliased)?_.sql:_;if(X)E.push(new x(F.queryChunks.map((D)=>{if(z(D,O))return J.identifier(this.casing.getColumnCasing(D));return D})));else E.push(F);if(z(_,x.Aliased))E.push(J` as ${J.identifier(_.fieldAlias)}`)}else if(z(_,N))if(X)E.push(J.identifier(this.casing.getColumnCasing(_)));else E.push(_);if(WE?.some(({alias:n2})=>n2===(n[V.Symbol.IsAlias]?m(n):n[V.Symbol.BaseName])))(u.field.table)){let n=m(u.field.table);throw new Error(`Your "${u.path.join("->")}" field references a column "${n}"."${u.field.name}", but the table "${n}" is not part of the query! Did you forget to join it?`)}let j=!E||E.length===0,L=this.buildWithCTE($),P;if(Q)P=Q===!0?J` distinct`:J` distinct on (${J.join(Q.on,J`, `)})`;let y=this.buildSelection(v,{isSingleTable:j}),C=this.buildFromTable(W),a=this.buildJoins(E),p=Z?J` where ${Z}`:void 0,I=_?J` having ${_}`:void 0,K;if(F&&F.length>0)K=J` order by ${J.join(F,J`, `)}`;let d;if(D&&D.length>0)d=J` group by ${J.join(D,J`, `)}`;let L2=typeof H==="object"||typeof H==="number"&&H>=0?J` limit ${H}`:void 0,s2=U?J` offset ${U}`:void 0,W2=J.empty();if(A){let u=J` for ${J.raw(A.strength)}`;if(A.config.of)u.append(J` of ${J.join(Array.isArray(A.config.of)?A.config.of:[A.config.of],J`, `)}`);if(A.config.noWait)u.append(J` no wait`);else if(A.config.skipLocked)u.append(J` skip locked`);W2.append(u)}let e=J`${L}select${P} ${y} from ${C}${a}${p}${d}${I}${K}${L2}${s2}${W2}`;if(w.length>0)return this.buildSetOperations(e,w);return e}buildSetOperations($,X){let[Y,...Z]=X;if(!Y)throw new Error("Cannot pass undefined values to any set operator");if(Z.length===0)return this.buildSetOperationQuery({leftSelect:$,setOperator:Y});return this.buildSetOperations(this.buildSetOperationQuery({leftSelect:$,setOperator:Y}),Z)}buildSetOperationQuery({leftSelect:$,setOperator:{type:X,isAll:Y,rightSelect:Z,limit:_,orderBy:W,offset:E}}){let F=J`(${$.getSQL()}) `,D=J`(${Z.getSQL()})`,H;if(W&&W.length>0){let w=[];for(let v of W)if(z(v,O))w.push(J.identifier(v.name));else if(z(v,x)){for(let j=0;j=0?J` limit ${_}`:void 0,A=J.raw(`${X} ${Y?"all ":""}`),Q=E?J` offset ${E}`:void 0;return J`${F}${A}${D}${H}${U}${Q}`}buildInsertQuery({table:$,values:X,onConflict:Y,returning:Z,withList:_,select:W,overridingSystemValue_:E}){let F=[],D=$[V.Symbol.Columns],H=Object.entries(D).filter(([L,P])=>!P.shouldDisableInsert()),U=H.map(([,L])=>J.identifier(this.casing.getColumnCasing(L)));if(W){let L=X;if(z(L,x))F.push(L);else F.push(L.getSQL())}else{let L=X;F.push(J.raw("values "));for(let[P,y]of L.entries()){let C=[];for(let[a,p]of H){let I=y[a];if(I===void 0||z(I,o)&&I.value===void 0)if(p.defaultFn!==void 0){let K=p.defaultFn(),d=z(K,x)?K:J.param(K,p);C.push(d)}else if(!p.default&&p.onUpdateFn!==void 0){let K=p.onUpdateFn(),d=z(K,x)?K:J.param(K,p);C.push(d)}else C.push(J`default`);else C.push(I)}if(F.push(C),P({dbKey:y.name,tsKey:P,field:s(y,E),relationTableTsKey:void 0,isJson:!1,selection:[]}));else{let L=Object.fromEntries(Object.entries(_.columns).map(([I,K])=>[I,s(K,E)]));if(W.where){let I=typeof W.where==="function"?W.where(L,A$()):W.where;w=I&&V2(I,E)}let P=[],y=[];if(W.columns){let I=!1;for(let[K,d]of Object.entries(W.columns)){if(d===void 0)continue;if(K in _.columns){if(!I&&d===!0)I=!0;y.push(K)}}if(y.length>0)y=I?y.filter((K)=>W.columns?.[K]===!0):Object.keys(_.columns).filter((K)=>!y.includes(K))}else y=Object.keys(_.columns);for(let I of y){let K=_.columns[I];P.push({tsKey:I,value:K})}let C=[];if(W.with)C=Object.entries(W.with).filter((I)=>!!I[1]).map(([I,K])=>({tsKey:I,queryConfig:K,relation:_.relations[I]}));let a;if(W.extras){a=typeof W.extras==="function"?W.extras(L,{sql:J}):W.extras;for(let[I,K]of Object.entries(a))P.push({tsKey:I,value:E0(K,E)})}for(let{tsKey:I,value:K}of P)H.push({dbKey:z(K,x.Aliased)?K.fieldAlias:_.columns[I].name,tsKey:I,field:z(K,N)?s(K,E):K,relationTableTsKey:void 0,isJson:!1,selection:[]});let p=typeof W.orderBy==="function"?W.orderBy(L,Q$()):W.orderBy??[];if(!Array.isArray(p))p=[p];Q=p.map((I)=>{if(z(I,N))return s(I,E);return V2(I,E)}),U=W.limit,A=W.offset;for(let{tsKey:I,queryConfig:K,relation:d}of C){let L2=R$(X,Y,d),s2=G2(d.referencedTable),W2=Y[s2],e=`${E}_${I}`,u=M2(...L2.fields.map((T$,j$)=>c2(s(L2.references[j$],e),s(T$,E)))),n=this.buildRelationalQueryWithoutPK({fullSchema:$,schema:X,tableNamesMap:Y,table:$[W2],tableConfig:X[W2],queryConfig:z(d,_2)?K===!0?{limit:1}:{...K,limit:1}:K,tableAlias:e,joinOn:u,nestedQueryRelation:d}),n2=J`${J.identifier(e)}.${J.identifier("data")}`.as(I);v.push({on:J`true`,table:new B(n.sql,{},e),alias:e,joinType:"left",lateral:!0}),H.push({dbKey:I,tsKey:I,field:n2,relationTableTsKey:W2,isJson:!0,selection:n.selection})}}if(H.length===0)throw new h2({message:`No fields selected for table "${_.tsName}" ("${E}")`});let j;if(w=M2(D,w),F){let L=J`json_build_array(${J.join(H.map(({field:C,tsKey:a,isJson:p})=>p?J`${J.identifier(`${E}_${a}`)}.${J.identifier("data")}`:z(C,x.Aliased)?C.sql:C),J`, `)})`;if(z(F,A2))L=J`coalesce(json_agg(${L}${Q.length>0?J` order by ${J.join(Q,J`, `)}`:void 0}), '[]'::json)`;let P=[{dbKey:"data",tsKey:"data",field:L.as("data"),isJson:!0,relationTableTsKey:_.tsName,selection:H}];if(U!==void 0||A!==void 0||Q.length>0)j=this.buildSelectQuery({table:S2(Z,E),fields:{},fieldsFlat:[{path:[],field:J.raw("*")}],where:w,limit:U,offset:A,orderBy:Q,setOperators:[]}),w=void 0,U=void 0,A=void 0,Q=[];else j=S2(Z,E);j=this.buildSelectQuery({table:z(j,q)?j:new B(j,{},E),fields:{},fieldsFlat:P.map(({field:C})=>({path:[],field:z(C,N)?s(C,E):C})),joins:v,where:w,limit:U,offset:A,orderBy:Q,setOperators:[]})}else j=this.buildSelectQuery({table:S2(Z,E),fields:{},fieldsFlat:H.map(({field:L})=>({path:[],field:z(L,N)?s(L,E):L})),joins:v,where:w,limit:U,offset:A,orderBy:Q,setOperators:[]});return{tableTsKey:_.tsName,sql:j,selection:H}}}class x0{static[G]="TypedQueryBuilder";getSelectedFields(){return this._.selectedFields}}class b{static[G]="PgSelectBuilder";fields;session;dialect;withList=[];distinct;constructor($){if(this.fields=$.fields,this.session=$.session,this.dialect=$.dialect,$.withList)this.withList=$.withList;this.distinct=$.distinct}authToken;setToken($){return this.authToken=$,this}from($){let X=!!this.fields,Y=$,Z;if(this.fields)Z=this.fields;else if(z(Y,B))Z=Object.fromEntries(Object.keys(Y._.selectedFields).map((_)=>[_,Y[_]]));else if(z(Y,Q2))Z=Y[T].selectedFields;else if(z(Y,x))Z={};else Z=i0(Y);return new M0({table:Y,fields:Z,isPartialSelect:X,session:this.session,dialect:this.dialect,withList:this.withList,distinct:this.distinct}).setToken(this.authToken)}}class w$ extends x0{static[G]="PgSelectQueryBuilder";_;config;joinsNotNullableMap;tableName;isPartialSelect;session;dialect;constructor({table:$,fields:X,isPartialSelect:Y,session:Z,dialect:_,withList:W,distinct:E}){super();this.config={withList:W,table:$,fields:{...X},distinct:E,setOperators:[]},this.isPartialSelect=Y,this.session=Z,this.dialect=_,this._={selectedFields:X},this.tableName=i($),this.joinsNotNullableMap=typeof this.tableName==="string"?{[this.tableName]:!0}:{}}createJoin($){return(X,Y)=>{let Z=this.tableName,_=i(X);if(typeof _==="string"&&this.config.joins?.some((W)=>W.alias===_))throw new Error(`Alias "${_}" is already used in this query`);if(!this.isPartialSelect){if(Object.keys(this.joinsNotNullableMap).length===1&&typeof Z==="string")this.config.fields={[Z]:this.config.fields};if(typeof _==="string"&&!z(X,x)){let W=z(X,B)?X._.selectedFields:z(X,g)?X[T].selectedFields:X[V.Symbol.Columns];this.config.fields[_]=W}}if(typeof Y==="function")Y=Y(new Proxy(this.config.fields,new S({sqlAliasedBehavior:"sql",sqlBehavior:"sql"})));if(!this.config.joins)this.config.joins=[];if(this.config.joins.push({on:Y,table:X,joinType:$,alias:_}),typeof _==="string")switch($){case"left":{this.joinsNotNullableMap[_]=!1;break}case"right":{this.joinsNotNullableMap=Object.fromEntries(Object.entries(this.joinsNotNullableMap).map(([W])=>[W,!1])),this.joinsNotNullableMap[_]=!0;break}case"inner":{this.joinsNotNullableMap[_]=!0;break}case"full":{this.joinsNotNullableMap=Object.fromEntries(Object.entries(this.joinsNotNullableMap).map(([W])=>[W,!1])),this.joinsNotNullableMap[_]=!1;break}}return this}}leftJoin=this.createJoin("left");rightJoin=this.createJoin("right");innerJoin=this.createJoin("inner");fullJoin=this.createJoin("full");createSetOperator($,X){return(Y)=>{let Z=typeof Y==="function"?Y(g$()):Y;if(!x2(this.getSelectedFields(),Z.getSelectedFields()))throw new Error("Set operator error (union / intersect / except): selected fields are not the same or are in a different order");return this.config.setOperators.push({type:$,isAll:X,rightSelect:Z}),this}}union=this.createSetOperator("union",!1);unionAll=this.createSetOperator("union",!0);intersect=this.createSetOperator("intersect",!1);intersectAll=this.createSetOperator("intersect",!0);except=this.createSetOperator("except",!1);exceptAll=this.createSetOperator("except",!0);addSetOperators($){return this.config.setOperators.push(...$),this}where($){if(typeof $==="function")$=$(new Proxy(this.config.fields,new S({sqlAliasedBehavior:"sql",sqlBehavior:"sql"})));return this.config.where=$,this}having($){if(typeof $==="function")$=$(new Proxy(this.config.fields,new S({sqlAliasedBehavior:"sql",sqlBehavior:"sql"})));return this.config.having=$,this}groupBy(...$){if(typeof $[0]==="function"){let X=$[0](new Proxy(this.config.fields,new S({sqlAliasedBehavior:"alias",sqlBehavior:"sql"})));this.config.groupBy=Array.isArray(X)?X:[X]}else this.config.groupBy=$;return this}orderBy(...$){if(typeof $[0]==="function"){let X=$[0](new Proxy(this.config.fields,new S({sqlAliasedBehavior:"alias",sqlBehavior:"sql"}))),Y=Array.isArray(X)?X:[X];if(this.config.setOperators.length>0)this.config.setOperators.at(-1).orderBy=Y;else this.config.orderBy=Y}else{let X=$;if(this.config.setOperators.length>0)this.config.setOperators.at(-1).orderBy=X;else this.config.orderBy=X}return this}limit($){if(this.config.setOperators.length>0)this.config.setOperators.at(-1).limit=$;else this.config.limit=$;return this}offset($){if(this.config.setOperators.length>0)this.config.setOperators.at(-1).offset=$;else this.config.offset=$;return this}for($,X={}){return this.config.lockingClause={strength:$,config:X},this}getSQL(){return this.dialect.buildSelectQuery(this.config)}toSQL(){let{typings:$,...X}=this.dialect.sqlToQuery(this.getSQL());return X}as($){return new Proxy(new B(this.getSQL(),this.config.fields,$),new S({alias:$,sqlAliasedBehavior:"alias",sqlBehavior:"error"}))}getSelectedFields(){return new Proxy(this.config.fields,new S({alias:this.tableName,sqlAliasedBehavior:"alias",sqlBehavior:"error"}))}$dynamic(){return this}}class M0 extends w${static[G]="PgSelect";_prepare($){let{session:X,config:Y,dialect:Z,joinsNotNullableMap:_,authToken:W}=this;if(!X)throw new Error("Cannot execute a query on a query builder. Please use a database instance instead.");return k.startActiveSpan("drizzle.prepareQuery",()=>{let E=r(Y.fields),F=X.prepareQuery(Z.sqlToQuery(this.getSQL()),E,$,!0);return F.joinsNotNullableMap=_,F.setToken(W)})}prepare($){return this._prepare($)}authToken;setToken($){return this.authToken=$,this}execute=($)=>{return k.startActiveSpan("drizzle.operation",()=>{return this._prepare().execute($,this.authToken)})}}n0(M0,[f]);function z2($,X){return(Y,Z,..._)=>{let W=[Z,..._].map((E)=>({type:$,isAll:X,rightSelect:E}));for(let E of W)if(!x2(Y.getSelectedFields(),E.rightSelect.getSelectedFields()))throw new Error("Set operator error (union / intersect / except): selected fields are not the same or are in a different order");return Y.addSetOperators(W)}}var g$=()=>({union:c$,unionAll:u$,intersect:o$,intersectAll:r$,except:t$,exceptAll:s$}),c$=z2("union",!1),u$=z2("union",!0),o$=z2("intersect",!1),r$=z2("intersect",!0),t$=z2("except",!1),s$=z2("except",!0);class I2{static[G]="PgQueryBuilder";dialect;dialectConfig;constructor($){this.dialect=z($,J2)?$:void 0,this.dialectConfig=z($,J2)?void 0:$}$with=($,X)=>{let Y=this;return{as:(_)=>{if(typeof _==="function")_=_(Y);return new Proxy(new D2(_.getSQL(),X??("getSelectedFields"in _?_.getSelectedFields()??{}:{}),$,!0),new S({alias:$,sqlAliasedBehavior:"alias",sqlBehavior:"error"}))}}};with(...$){let X=this;function Y(W){return new b({fields:W??void 0,session:void 0,dialect:X.getDialect(),withList:$})}function Z(W){return new b({fields:W??void 0,session:void 0,dialect:X.getDialect(),distinct:!0})}function _(W,E){return new b({fields:E??void 0,session:void 0,dialect:X.getDialect(),distinct:{on:W}})}return{select:Y,selectDistinct:Z,selectDistinctOn:_}}select($){return new b({fields:$??void 0,session:void 0,dialect:this.getDialect()})}selectDistinct($){return new b({fields:$??void 0,session:void 0,dialect:this.getDialect(),distinct:!0})}selectDistinctOn($,X){return new b({fields:X??void 0,session:void 0,dialect:this.getDialect(),distinct:{on:$}})}getDialect(){if(!this.dialect)this.dialect=new J2(this.dialectConfig);return this.dialect}}class o2{constructor($,X,Y,Z,_){this.table=$,this.session=X,this.dialect=Y,this.withList=Z,this.overridingSystemValue_=_}static[G]="PgInsertBuilder";authToken;setToken($){return this.authToken=$,this}overridingSystemValue(){return this.overridingSystemValue_=!0,this}values($){if($=Array.isArray($)?$:[$],$.length===0)throw new Error("values() must be called with at least one value");let X=$.map((Y)=>{let Z={},_=this.table[V.Symbol.Columns];for(let W of Object.keys(Y)){let E=Y[W];Z[W]=z(E,x)?E:new o(E,_[W])}return Z});return new A0(this.table,X,this.session,this.dialect,this.withList,!1,this.overridingSystemValue_).setToken(this.authToken)}select($){let X=typeof $==="function"?$(new I2):$;if(!z(X,x)&&!x2(this.table[T2],X._.selectedFields))throw new Error("Insert select error: selected fields are not the same or are in a different order compared to the table definition");return new A0(this.table,X,this.session,this.dialect,this.withList,!0)}}class A0 extends f{constructor($,X,Y,Z,_,W,E){super();this.session=Y,this.dialect=Z,this.config={table:$,values:X,withList:_,select:W,overridingSystemValue_:E}}static[G]="PgInsert";config;returning($=this.config.table[V.Symbol.Columns]){return this.config.returningFields=$,this.config.returning=r($),this}onConflictDoNothing($={}){if($.target===void 0)this.config.onConflict=J`do nothing`;else{let X="";X=Array.isArray($.target)?$.target.map((Z)=>this.dialect.escapeName(this.dialect.casing.getColumnCasing(Z))).join(","):this.dialect.escapeName(this.dialect.casing.getColumnCasing($.target));let Y=$.where?J` where ${$.where}`:void 0;this.config.onConflict=J`(${J.raw(X)})${Y} do nothing`}return this}onConflictDoUpdate($){if($.where&&($.targetWhere||$.setWhere))throw new Error('You cannot use both "where" and "targetWhere"/"setWhere" at the same time - "where" is deprecated, use "targetWhere" or "setWhere" instead.');let X=$.where?J` where ${$.where}`:void 0,Y=$.targetWhere?J` where ${$.targetWhere}`:void 0,Z=$.setWhere?J` where ${$.setWhere}`:void 0,_=this.dialect.buildUpdateSet(this.config.table,v2(this.config.table,$.set)),W="";return W=Array.isArray($.target)?$.target.map((E)=>this.dialect.escapeName(this.dialect.casing.getColumnCasing(E))).join(","):this.dialect.escapeName(this.dialect.casing.getColumnCasing($.target)),this.config.onConflict=J`(${J.raw(W)})${Y} do update set ${_}${X}${Z}`,this}getSQL(){return this.dialect.buildInsertQuery(this.config)}toSQL(){let{typings:$,...X}=this.dialect.sqlToQuery(this.getSQL());return X}_prepare($){return k.startActiveSpan("drizzle.prepareQuery",()=>{return this.session.prepareQuery(this.dialect.sqlToQuery(this.getSQL()),this.config.returning,$,!0)})}prepare($){return this._prepare($)}authToken;setToken($){return this.authToken=$,this}execute=($)=>{return k.startActiveSpan("drizzle.operation",()=>{return this._prepare().execute($,this.authToken)})};getSelectedFields(){return this.config.returningFields?new Proxy(this.config.returningFields,new S({alias:m(this.config.table),sqlAliasedBehavior:"alias",sqlBehavior:"error"})):void 0}$dynamic(){return this}}class Q0 extends f{constructor($,X,Y){super();this.session=X,this.dialect=Y,this.config={view:$}}static[G]="PgRefreshMaterializedView";config;concurrently(){if(this.config.withNoData!==void 0)throw new Error("Cannot use concurrently and withNoData together");return this.config.concurrently=!0,this}withNoData(){if(this.config.concurrently!==void 0)throw new Error("Cannot use concurrently and withNoData together");return this.config.withNoData=!0,this}getSQL(){return this.dialect.buildRefreshMaterializedViewQuery(this.config)}toSQL(){let{typings:$,...X}=this.dialect.sqlToQuery(this.getSQL());return X}_prepare($){return k.startActiveSpan("drizzle.prepareQuery",()=>{return this.session.prepareQuery(this.dialect.sqlToQuery(this.getSQL()),void 0,$,!0)})}prepare($){return this._prepare($)}authToken;setToken($){return this.authToken=$,this}execute=($)=>{return k.startActiveSpan("drizzle.operation",()=>{return this._prepare().execute($,this.authToken)})}}class r2{constructor($,X,Y,Z){this.table=$,this.session=X,this.dialect=Y,this.withList=Z}static[G]="PgUpdateBuilder";authToken;setToken($){return this.authToken=$,this}set($){return new L$(this.table,v2(this.table,$),this.session,this.dialect,this.withList).setToken(this.authToken)}}class L$ extends f{constructor($,X,Y,Z,_){super();this.session=Y,this.dialect=Z,this.config={set:X,table:$,withList:_,joins:[]},this.tableName=i($),this.joinsNotNullableMap=typeof this.tableName==="string"?{[this.tableName]:!0}:{}}static[G]="PgUpdate";config;tableName;joinsNotNullableMap;from($){let X=$,Y=i(X);if(typeof Y==="string")this.joinsNotNullableMap[Y]=!0;return this.config.from=X,this}getTableLikeFields($){if(z($,q))return $[V.Symbol.Columns];else if(z($,B))return $._.selectedFields;return $[T].selectedFields}createJoin($){return(X,Y)=>{let Z=i(X);if(typeof Z==="string"&&this.config.joins.some((_)=>_.alias===Z))throw new Error(`Alias "${Z}" is already used in this query`);if(typeof Y==="function"){let _=this.config.from&&!z(this.config.from,x)?this.getTableLikeFields(this.config.from):void 0;Y=Y(new Proxy(this.config.table[V.Symbol.Columns],new S({sqlAliasedBehavior:"sql",sqlBehavior:"sql"})),_&&new Proxy(_,new S({sqlAliasedBehavior:"sql",sqlBehavior:"sql"})))}if(this.config.joins.push({on:Y,table:X,joinType:$,alias:Z}),typeof Z==="string")switch($){case"left":{this.joinsNotNullableMap[Z]=!1;break}case"right":{this.joinsNotNullableMap=Object.fromEntries(Object.entries(this.joinsNotNullableMap).map(([_])=>[_,!1])),this.joinsNotNullableMap[Z]=!0;break}case"inner":{this.joinsNotNullableMap[Z]=!0;break}case"full":{this.joinsNotNullableMap=Object.fromEntries(Object.entries(this.joinsNotNullableMap).map(([_])=>[_,!1])),this.joinsNotNullableMap[Z]=!1;break}}return this}}leftJoin=this.createJoin("left");rightJoin=this.createJoin("right");innerJoin=this.createJoin("inner");fullJoin=this.createJoin("full");where($){return this.config.where=$,this}returning($){if(!$){if($=Object.assign({},this.config.table[V.Symbol.Columns]),this.config.from){let X=i(this.config.from);if(typeof X==="string"&&this.config.from&&!z(this.config.from,x)){let Y=this.getTableLikeFields(this.config.from);$[X]=Y}for(let Y of this.config.joins){let Z=i(Y.table);if(typeof Z==="string"&&!z(Y.table,x)){let _=this.getTableLikeFields(Y.table);$[Z]=_}}}}return this.config.returningFields=$,this.config.returning=r($),this}getSQL(){return this.dialect.buildUpdateQuery(this.config)}toSQL(){let{typings:$,...X}=this.dialect.sqlToQuery(this.getSQL());return X}_prepare($){let X=this.session.prepareQuery(this.dialect.sqlToQuery(this.getSQL()),this.config.returning,$,!0);return X.joinsNotNullableMap=this.joinsNotNullableMap,X}prepare($){return this._prepare($)}authToken;setToken($){return this.authToken=$,this}execute=($)=>{return this._prepare().execute($,this.authToken)};getSelectedFields(){return this.config.returningFields?new Proxy(this.config.returningFields,new S({alias:m(this.config.table),sqlAliasedBehavior:"alias",sqlBehavior:"error"})):void 0}$dynamic(){return this}}class R2 extends x{constructor($){super(R2.buildEmbeddedCount($.source,$.filters).queryChunks);this.params=$,this.mapWith(Number),this.session=$.session,this.sql=R2.buildCount($.source,$.filters)}sql;token;static[G]="PgCountBuilder";[Symbol.toStringTag]="PgCountBuilder";session;static buildEmbeddedCount($,X){return J`(select count(*) from ${$}${J.raw(" where ").if(X)}${X})`}static buildCount($,X){return J`select count(*) as count from ${$}${J.raw(" where ").if(X)}${X};`}setToken($){return this.token=$,this}then($,X){return Promise.resolve(this.session.count(this.sql,this.token)).then($,X)}catch($){return this.then(void 0,$)}finally($){return this.then((X)=>{return $?.(),X},(X)=>{throw $?.(),X})}}class R0{constructor($,X,Y,Z,_,W,E){this.fullSchema=$,this.schema=X,this.tableNamesMap=Y,this.table=Z,this.tableConfig=_,this.dialect=W,this.session=E}static[G]="PgRelationalQueryBuilder";findMany($){return new I0(this.fullSchema,this.schema,this.tableNamesMap,this.table,this.tableConfig,this.dialect,this.session,$?$:{},"many")}findFirst($){return new I0(this.fullSchema,this.schema,this.tableNamesMap,this.table,this.tableConfig,this.dialect,this.session,$?{...$,limit:1}:{limit:1},"first")}}class I0 extends f{constructor($,X,Y,Z,_,W,E,F,D){super();this.fullSchema=$,this.schema=X,this.tableNamesMap=Y,this.table=Z,this.tableConfig=_,this.dialect=W,this.session=E,this.config=F,this.mode=D}static[G]="PgRelationalQuery";_prepare($){return k.startActiveSpan("drizzle.prepareQuery",()=>{let{query:X,builtQuery:Y}=this._toSQL();return this.session.prepareQuery(Y,void 0,$,!0,(Z,_)=>{let W=Z.map((E)=>u2(this.schema,this.tableConfig,E,X.selection,_));if(this.mode==="first")return W[0];return W})})}prepare($){return this._prepare($)}_getQuery(){return this.dialect.buildRelationalQueryWithoutPK({fullSchema:this.fullSchema,schema:this.schema,tableNamesMap:this.tableNamesMap,table:this.table,tableConfig:this.tableConfig,queryConfig:this.config,tableAlias:this.tableConfig.tsName})}getSQL(){return this._getQuery().sql}_toSQL(){let $=this._getQuery(),X=this.dialect.sqlToQuery($.sql);return{query:$,builtQuery:X}}toSQL(){return this._toSQL().builtQuery}authToken;setToken($){return this.authToken=$,this}execute(){return k.startActiveSpan("drizzle.operation",()=>{return this._prepare().execute(void 0,this.authToken)})}}class K0 extends f{constructor($,X,Y,Z){super();this.execute=$,this.sql=X,this.query=Y,this.mapBatchResult=Z}static[G]="PgRaw";getSQL(){return this.sql}getQuery(){return this.query}mapResult($,X){return X?this.mapBatchResult($):$}_prepare(){return this}isResponseInArrayMode(){return!1}}class K2{constructor($,X,Y){if(this.dialect=$,this.session=X,this._=Y?{schema:Y.schema,fullSchema:Y.fullSchema,tableNamesMap:Y.tableNamesMap,session:X}:{schema:void 0,fullSchema:{},tableNamesMap:{},session:X},this.query={},this._.schema)for(let[Z,_]of Object.entries(this._.schema))this.query[Z]=new R0(Y.fullSchema,this._.schema,this._.tableNamesMap,Y.fullSchema[Z],_,$,X)}static[G]="PgDatabase";query;$with=($,X)=>{let Y=this;return{as:(_)=>{if(typeof _==="function")_=_(new I2(Y.dialect));return new Proxy(new D2(_.getSQL(),X??("getSelectedFields"in _?_.getSelectedFields()??{}:{}),$,!0),new S({alias:$,sqlAliasedBehavior:"alias",sqlBehavior:"error"}))}}};$count($,X){return new R2({source:$,filters:X,session:this.session})}with(...$){let X=this;function Y(D){return new b({fields:D??void 0,session:X.session,dialect:X.dialect,withList:$})}function Z(D){return new b({fields:D??void 0,session:X.session,dialect:X.dialect,withList:$,distinct:!0})}function _(D,H){return new b({fields:H??void 0,session:X.session,dialect:X.dialect,withList:$,distinct:{on:D}})}function W(D){return new r2(D,X.session,X.dialect,$)}function E(D){return new o2(D,X.session,X.dialect,$)}function F(D){return new B2(D,X.session,X.dialect,$)}return{select:Y,selectDistinct:Z,selectDistinctOn:_,update:W,insert:E,delete:F}}select($){return new b({fields:$??void 0,session:this.session,dialect:this.dialect})}selectDistinct($){return new b({fields:$??void 0,session:this.session,dialect:this.dialect,distinct:!0})}selectDistinctOn($,X){return new b({fields:X??void 0,session:this.session,dialect:this.dialect,distinct:{on:$}})}update($){return new r2($,this.session,this.dialect)}insert($){return new o2($,this.session,this.dialect)}delete($){return new B2($,this.session,this.dialect)}refreshMaterializedView($){return new Q0($,this.session,this.dialect)}authToken;execute($){let X=typeof $==="string"?J.raw($):$.getSQL(),Y=this.dialect.sqlToQuery(X),Z=this.session.prepareQuery(Y,void 0,void 0,!1);return new K0(()=>Z.execute(void 0,this.authToken),X,Y,(_)=>Z.mapResult(_,!0))}transaction($,X){return this.session.transaction($,X)}}class w0{constructor($){this.query=$}authToken;getQuery(){return this.query}mapResult($,X){return $}setToken($){return this.authToken=$,this}static[G]="PgPreparedQuery";joinsNotNullableMap}class L0{constructor($){this.dialect=$}static[G]="PgSession";execute($,X){return k.startActiveSpan("drizzle.operation",()=>{return k.startActiveSpan("drizzle.prepareQuery",()=>{return this.prepareQuery(this.dialect.sqlToQuery($),void 0,void 0,!1)}).setToken(X).execute(void 0,X)})}all($){return this.prepareQuery(this.dialect.sqlToQuery($),void 0,void 0,!1).all()}async count($,X){let Y=await this.execute($,X);return Number(Y[0].count)}}class N0 extends K2{constructor($,X,Y,Z=0){super($,X,Y);this.schema=Y,this.nestedIndex=Z}static[G]="PgTransaction";rollback(){throw new F0}getTransactionConfigSQL($){let X=[];if($.isolationLevel)X.push(`isolation level ${$.isolationLevel}`);if($.accessMode)X.push($.accessMode);if(typeof $.deferrable==="boolean")X.push($.deferrable?"deferrable":"not deferrable");return J.raw(X.join(" "))}setTransaction($){return this.session.execute(J`set transaction ${this.getTransactionConfigSQL($)}`)}}class N$ extends w0{constructor($,X,Y,Z,_,W,E){super({sql:X,params:Y});this.client=$,this.queryString=X,this.params=Y,this.logger=Z,this.fields=_,this._isResponseInArrayMode=W,this.customResultMapper=E}static[G]="BunSQLPreparedQuery";async execute($={}){return k.startActiveSpan("drizzle.execute",async(X)=>{let Y=H0(this.params,$);X?.setAttributes({"drizzle.query.text":this.queryString,"drizzle.query.params":JSON.stringify(Y)}),this.logger.logQuery(this.queryString,Y);let{fields:Z,queryString:_,client:W,joinsNotNullableMap:E,customResultMapper:F}=this;if(!Z&&!F)return k.startActiveSpan("drizzle.driver.execute",()=>{return W.unsafe(_,Y)});let D=await k.startActiveSpan("drizzle.driver.execute",()=>{return X?.setAttributes({"drizzle.query.text":_,"drizzle.query.params":JSON.stringify(Y)}),W.unsafe(_,Y).values()});return k.startActiveSpan("drizzle.mapResponse",()=>{return F?F(D):D.map((H)=>s0(Z,H,E))})})}all($={}){return k.startActiveSpan("drizzle.execute",async(X)=>{let Y=H0(this.params,$);return X?.setAttributes({"drizzle.query.text":this.queryString,"drizzle.query.params":JSON.stringify(Y)}),this.logger.logQuery(this.queryString,Y),k.startActiveSpan("drizzle.driver.execute",()=>{return X?.setAttributes({"drizzle.query.text":this.queryString,"drizzle.query.params":JSON.stringify(Y)}),this.client.unsafe(this.queryString,Y)})})}isResponseInArrayMode(){return this._isResponseInArrayMode}}class w2 extends L0{constructor($,X,Y,Z={}){super(X);this.client=$,this.schema=Y,this.options=Z,this.logger=Z.logger??new l2}static[G]="BunSQLSession";logger;prepareQuery($,X,Y,Z,_){return new N$(this.client,$.sql,$.params,this.logger,X,Z,_)}query($,X){return this.logger.logQuery($,X),this.client.unsafe($,X).values()}queryObjects($,X){return this.client.unsafe($,X)}transaction($,X){return this.client.begin(async(Y)=>{let Z=new w2(Y,this.dialect,this.schema,this.options),_=new k0(this.dialect,Z,this.schema);if(X)await _.setTransaction(X);return $(_)})}}class k0 extends N0{constructor($,X,Y,Z=0){super($,X,Y,Z);this.session=X}static[G]="BunSQLTransaction";transaction($){return this.session.client.savepoint((X)=>{let Y=new w2(X,this.dialect,this.schema,this.session.options),Z=new k0(this.dialect,Y,this.schema);return $(Z)})}}class k$ extends K2{static[G]="BunSQLDatabase"}function F2($,X={}){let Y=new J2({casing:X.casing}),Z;if(X.logger===!0)Z=new i2;else if(X.logger!==!1)Z=X.logger;let _;if(X.schema){let F=I$(X.schema,K$);_={fullSchema:X.schema,schema:F.tables,tableNamesMap:F.tableNamesMap}}let W=new w2($,Y,_,{logger:Z}),E=new k$(Y,W,_);return E.$client=$,E}function t2(...$){if(typeof $[0]==="string"){let X=new T0($[0]);return F2(X,$[1])}if(l0($[0])){let{connection:X,client:Y,...Z}=$[0];if(Y)return F2(Y,Z);if(typeof X==="object"&&X.url!==void 0){let{url:W,...E}=X,F=new T0({url:W,...E});return F2(F,Z)}let _=new T0(X);return F2(_,Z)}return F2($[0],$[1])}(($)=>{function X(Y){return F2({options:{parsers:{},serializers:{}}},Y)}$.mock=X})(t2||(t2={}));var j0={};v$(j0,{unitsTable:()=>n$});var n$=s8("units",{id:g2("id").defaultRandom().primaryKey(),unitNo:Z2("unit_no",{length:10}).notNull(),number:Y2("number"),project:Z2("project",{length:256}).notNull(),floor:Y2("floor").notNull(),unitType:Z2("unit_type",{length:256,enum:["Studio Squared","1 BR Squared","Studio Flex","2 BR Squared","One Bedroom2","Studio2","One Bedroom Loft","Two Bedroom Loft"]}),noOfBathrooms:Y2("no_of_bathrooms").notNull(),unitView:Z2("unit_view",{length:256,enum:["Canal / Amenities","Corner-Canal / Amenities","Corner-Canal View","Business Bay","Park Facing","Corner-Park Facing","Partial Park","BK/DT / Amenities","Corner-BK/DT / Amenities","Corner-Canal / BK/DT View","Marina View","Partial Marina View","Partial Marina, Partial City View","City view","Marina View, Sea View","Partial Marina View, Partial Sea View"]}),suitsArea:E2("suits_area").notNull(),squareFt:E2("square_ft").notNull(),noOfParkingSpace:Y2("no_of_parking_space").notNull(),salesPrice:Y2("sales_price").notNull(),state:Z2("state",{length:256,enum:["reserved","sold_spa","available","sold_registered"]}).notNull(),balconyArea:E2("balcony_area").notNull()},($)=>[B0().on($.project,$.unitNo)]);var{SQL:i$}=globalThis.Bun;var e5=t2({schema:j0,client:new i$("postgresql://postgres:v1sq3vD5faXL@194.26.138.94:5432/irth")});export{e5 as db}; diff --git a/dist/db/schema/index.js b/dist/db/schema/index.js deleted file mode 100644 index 85404ac..0000000 --- a/dist/db/schema/index.js +++ /dev/null @@ -1,2 +0,0 @@ -// @bun -var Y=Symbol.for("drizzle:entityKind"),j0=Symbol.for("drizzle:hasOwnEntityKind");function x(_,$){if(!_||typeof _!=="object")return!1;if(_ instanceof $)return!0;if(!Object.prototype.hasOwnProperty.call($,Y))throw new Error(`Class "${$.name??""}" doesn't look like a Drizzle entity. If this is incorrect and the class is provided by Drizzle, please report this as a bug.`);let X=Object.getPrototypeOf(_).constructor;if(X)while(X){if(Y in X&&X[Y]===$[Y])return!0;X=Object.getPrototypeOf(X)}return!1}class K{constructor(_,$){this.table=_,this.config=$,this.name=$.name,this.keyAsName=$.keyAsName,this.notNull=$.notNull,this.default=$.default,this.defaultFn=$.defaultFn,this.onUpdateFn=$.onUpdateFn,this.hasDefault=$.hasDefault,this.primary=$.primaryKey,this.isUnique=$.isUnique,this.uniqueName=$.uniqueName,this.uniqueType=$.uniqueType,this.dataType=$.dataType,this.columnType=$.columnType,this.generated=$.generated,this.generatedIdentity=$.generatedIdentity}static[Y]="Column";name;keyAsName;primary;notNull;default;defaultFn;onUpdateFn;hasDefault;isUnique;uniqueName;uniqueType;dataType;columnType;enumValues=void 0;generated=void 0;generatedIdentity=void 0;config;mapFromDriverValue(_){return _}mapToDriverValue(_){return _}shouldDisableInsert(){return this.config.generated!==void 0&&this.config.generated.type!=="byDefault"}}class b{static[Y]="ColumnBuilder";config;constructor(_,$,X){this.config={name:_,keyAsName:_==="",notNull:!1,default:void 0,hasDefault:!1,primaryKey:!1,isUnique:!1,uniqueName:void 0,uniqueType:void 0,dataType:$,columnType:X,generated:void 0}}$type(){return this}notNull(){return this.config.notNull=!0,this}default(_){return this.config.default=_,this.config.hasDefault=!0,this}$defaultFn(_){return this.config.defaultFn=_,this.config.hasDefault=!0,this}$default=this.$defaultFn;$onUpdateFn(_){return this.config.onUpdateFn=_,this.config.hasDefault=!0,this}$onUpdate=this.$onUpdateFn;primaryKey(){return this.config.primaryKey=!0,this.config.notNull=!0,this}setName(_){if(this.config.name!=="")return;this.config.name=_}}var U=Symbol.for("drizzle:Name");class P{static[Y]="PgForeignKeyBuilder";reference;_onUpdate="no action";_onDelete="no action";constructor(_,$){if(this.reference=()=>{let{name:X,columns:Z,foreignColumns:J}=_();return{name:X,columns:Z,foreignTable:J[0].table,foreignColumns:J}},$)this._onUpdate=$.onUpdate,this._onDelete=$.onDelete}onUpdate(_){return this._onUpdate=_===void 0?"no action":_,this}onDelete(_){return this._onDelete=_===void 0?"no action":_,this}build(_){return new n(_,this)}}class n{constructor(_,$){this.table=_,this.reference=$.reference,this.onUpdate=$._onUpdate,this.onDelete=$._onDelete}static[Y]="PgForeignKey";reference;onUpdate;onDelete;getName(){let{name:_,columns:$,foreignColumns:X}=this.reference(),Z=$.map((Q)=>Q.name),J=X.map((Q)=>Q.name),O=[this.table[U],...Z,X[0].table[U],...J];return _??`${O.join("_")}_fk`}}function h(_,...$){return _(...$)}function a(_){return new _2(_)}function d(_,$){return`${_[U]}_${$.join("_")}_unique`}class e{constructor(_,$){this.name=$,this.columns=_}static[Y]="PgUniqueConstraintBuilder";columns;nullsNotDistinctConfig=!1;nullsNotDistinct(){return this.nullsNotDistinctConfig=!0,this}build(_){return new $2(_,this.columns,this.nullsNotDistinctConfig,this.name)}}class _2{static[Y]="PgUniqueOnConstraintBuilder";name;constructor(_){this.name=_}on(..._){return new e(_,this.name)}}class $2{constructor(_,$,X,Z){this.table=_,this.columns=$,this.name=Z??d(this.table,this.columns.map((J)=>J.name)),this.nullsNotDistinct=X}static[Y]="PgUniqueConstraint";columns;name;nullsNotDistinct=!1;getName(){return this.name}}function X2(_,$,X){for(let Z=$;Z<_.length;Z++){let J=_[Z];if(J==="\\"){Z++;continue}if(J==='"')return[_.slice($,Z).replace(/\\/g,""),Z+1];if(X)continue;if(J===","||J==="}")return[_.slice($,Z).replace(/\\/g,""),Z]}return[_.slice($).replace(/\\/g,""),_.length]}function Y2(_,$=0){let X=[],Z=$,J=!1;while(Z<_.length){let O=_[Z];if(O===","){if(J||Z===$)X.push("");J=!0,Z++;continue}if(J=!1,O==="\\"){Z+=2;continue}if(O==='"'){let[E,W]=X2(_,Z+1,!0);X.push(E),Z=W;continue}if(O==="}")return[X,Z+1];if(O==="{"){let[E,W]=Y2(_,Z+1);X.push(E),Z=W;continue}let[Q,A]=X2(_,Z,!1);X.push(Q),Z=A}return[X,Z]}function Z2(_){let[$]=Y2(_,1);return $}function c(_){return`{${_.map(($)=>{if(Array.isArray($))return c($);if(typeof $==="string")return`"${$.replace(/\\/g,"\\\\").replace(/"/g,"\\\"")}"`;return`${$}`}).join(",")}}`}class G extends b{foreignKeyConfigs=[];static[Y]="PgColumnBuilder";array(_){return new W2(this.config.name,this,_)}references(_,$={}){return this.foreignKeyConfigs.push({ref:_,actions:$}),this}unique(_,$){return this.config.isUnique=!0,this.config.uniqueName=_,this.config.uniqueType=$?.nulls,this}generatedAlwaysAs(_){return this.config.generated={as:_,type:"always",mode:"stored"},this}buildForeignKeys(_,$){return this.foreignKeyConfigs.map(({ref:X,actions:Z})=>{return h((J,O)=>{let Q=new P(()=>{let A=J();return{columns:[_],foreignColumns:[A]}});if(O.onUpdate)Q.onUpdate(O.onUpdate);if(O.onDelete)Q.onDelete(O.onDelete);return Q.build($)},X,Z)})}buildExtraConfigColumn(_){return new H2(_,this.config)}}class H extends K{constructor(_,$){if(!$.uniqueName)$.uniqueName=d(_,[$.name]);super(_,$);this.table=_}static[Y]="PgColumn"}class H2 extends H{static[Y]="ExtraConfigColumn";getSQLType(){return this.getSQLType()}indexConfig={order:this.config.order??"asc",nulls:this.config.nulls??"last",opClass:this.config.opClass};defaultConfig={order:"asc",nulls:"last",opClass:void 0};asc(){return this.indexConfig.order="asc",this}desc(){return this.indexConfig.order="desc",this}nullsFirst(){return this.indexConfig.nulls="first",this}nullsLast(){return this.indexConfig.nulls="last",this}op(_){return this.indexConfig.opClass=_,this}}class W2 extends G{static[Y]="PgArrayBuilder";constructor(_,$,X){super(_,"array","PgArray");this.config.baseBuilder=$,this.config.size=X}build(_){let $=this.config.baseBuilder.build(_);return new o(_,this.config,$)}}class o extends H{constructor(_,$,X,Z){super(_,$);this.baseColumn=X,this.range=Z,this.size=$.size}size;static[Y]="PgArray";getSQLType(){return`${this.baseColumn.getSQLType()}[${typeof this.size==="number"?this.size:""}]`}mapFromDriverValue(_){if(typeof _==="string")_=Z2(_);return _.map(($)=>this.baseColumn.mapFromDriverValue($))}mapToDriverValue(_,$=!1){let X=_.map((Z)=>Z===null?null:x(this.baseColumn,o)?this.baseColumn.mapToDriverValue(Z,!0):this.baseColumn.mapToDriverValue(Z));if($)return X;return c(X)}}var G2=Symbol.for("drizzle:isPgEnum");function J2(_){return!!_&&typeof _==="function"&&G2 in _&&_[G2]===!0}class I0 extends H{static[Y]="PgEnumColumn";enum=this.config.enum;enumValues=this.config.enum.enumValues;constructor(_,$){super(_,$);this.enum=$.enum}getSQLType(){return this.enum.enumName}}class f{static[Y]="Subquery";constructor(_,$,X,Z=!1){this._={brand:"Subquery",sql:_,selectedFields:$,alias:X,isWith:Z}}}var z2="0.41.0";var s,m,O2={startActiveSpan(_,$){if(!s)return $();if(!m)m=s.trace.getTracer("drizzle-orm",z2);return h((X,Z)=>Z.startActiveSpan(_,(J)=>{try{return $(J)}catch(O){throw J.setStatus({code:X.SpanStatusCode.ERROR,message:O instanceof Error?O.message:"Unknown error"}),O}finally{J.end()}}),s,m)}};var N=Symbol.for("drizzle:ViewBaseConfig");var g=Symbol.for("drizzle:Schema"),F2=Symbol.for("drizzle:Columns"),E2=Symbol.for("drizzle:ExtraConfigColumns"),r=Symbol.for("drizzle:OriginalName"),t=Symbol.for("drizzle:BaseName"),j=Symbol.for("drizzle:IsAlias"),D2=Symbol.for("drizzle:ExtraConfigBuilder"),L0=Symbol.for("drizzle:IsDrizzleTable");class w{static[Y]="Table";static Symbol={Name:U,Schema:g,OriginalName:r,Columns:F2,ExtraConfigColumns:E2,BaseName:t,IsAlias:j,ExtraConfigBuilder:D2};[U];[r];[g];[F2];[E2];[t];[j]=!1;[L0]=!0;[D2]=void 0;constructor(_,$,X){this[U]=this[r]=_,this[g]=$,this[t]=X}}function T0(_){return _!==null&&_!==void 0&&typeof _.getSQL==="function"}function K0(_){let $={sql:"",params:[]};for(let X of _)if($.sql+=X.sql,$.params.push(...X.params),X.typings?.length){if(!$.typings)$.typings=[];$.typings.push(...X.typings)}return $}class R{static[Y]="StringChunk";value;constructor(_){this.value=Array.isArray(_)?_:[_]}getSQL(){return new D([this])}}class D{constructor(_){this.queryChunks=_}static[Y]="SQL";decoder=Q2;shouldInlineParams=!1;append(_){return this.queryChunks.push(..._.queryChunks),this}toQuery(_){return O2.startActiveSpan("drizzle.buildSQL",($)=>{let X=this.buildQueryFromSourceParams(this.queryChunks,_);return $?.setAttributes({"drizzle.query.text":X.sql,"drizzle.query.params":JSON.stringify(X.params)}),X})}buildQueryFromSourceParams(_,$){let X=Object.assign({},$,{inlineParams:$.inlineParams||this.shouldInlineParams,paramStartIndex:$.paramStartIndex||{value:0}}),{casing:Z,escapeName:J,escapeParam:O,prepareTyping:Q,inlineParams:A,paramStartIndex:E}=X;return K0(_.map((W)=>{if(x(W,R))return{sql:W.value.join(""),params:[]};if(x(W,C))return{sql:J(W.value),params:[]};if(W===void 0)return{sql:"",params:[]};if(Array.isArray(W)){let F=[new R("(")];for(let[V,M]of W.entries())if(F.push(M),V_},V2={mapToDriverValue:(_)=>_},R1={...Q2,...V2};class u{constructor(_,$=V2){this.value=_,this.encoder=$}static[Y]="Param";brand;getSQL(){return new D([this])}}function k(_,...$){let X=[];if($.length>0||_.length>0&&_[0]!=="")X.push(new R(_[0]));for(let[Z,J]of $.entries())X.push(J,new R(_[Z+1]));return new D(X)}((_)=>{function $(){return new D([])}_.empty=$;function X(E){return new D(E)}_.fromList=X;function Z(E){return new D([new R(E)])}_.raw=Z;function J(E,W){let F=[];for(let[V,M]of E.entries()){if(V>0&&W!==void 0)F.push(W);F.push(M)}return new D(F)}_.join=J;function O(E){return new C(E)}_.identifier=O;function Q(E){return new B(E)}_.placeholder=Q;function A(E,W){return new u(E,W)}_.param=A})(k||(k={}));((_)=>{class ${constructor(X,Z){this.sql=X,this.fieldAlias=Z}static[Y]="SQL.Aliased";isSelectionField=!1;getSQL(){return this.sql}clone(){return new $(this.sql,this.fieldAlias)}}_.Aliased=$})(D||(D={}));class B{constructor(_){this.name=_}static[Y]="Placeholder";getSQL(){return new D([this])}}var N0=Symbol.for("drizzle:IsDrizzleView");class w2{static[Y]="View";[N];[N0]=!0;constructor({name:_,schema:$,selectedFields:X,query:Z}){this[N]={name:_,originalName:_,schema:$,selectedFields:X,query:Z,isExisting:!Z,isAlias:!1}}getSQL(){return new D([this])}}K.prototype.getSQL=function(){return new D([this])};w.prototype.getSQL=function(){return new D([this])};f.prototype.getSQL=function(){return new D([this])};function z(_,$){return{name:typeof _==="string"&&_.length>0?_:"",config:typeof _==="object"?_:$}}class I extends G{static[Y]="PgIntColumnBaseBuilder";generatedAlwaysAsIdentity(_){if(_){let{name:$,...X}=_;this.config.generatedIdentity={type:"always",sequenceName:$,sequenceOptions:X}}else this.config.generatedIdentity={type:"always"};return this.config.hasDefault=!0,this.config.notNull=!0,this}generatedByDefaultAsIdentity(_){if(_){let{name:$,...X}=_;this.config.generatedIdentity={type:"byDefault",sequenceName:$,sequenceOptions:X}}else this.config.generatedIdentity={type:"byDefault"};return this.config.hasDefault=!0,this.config.notNull=!0,this}}class x2 extends I{static[Y]="PgBigInt53Builder";constructor(_){super(_,"number","PgBigInt53")}build(_){return new A2(_,this.config)}}class A2 extends H{static[Y]="PgBigInt53";getSQLType(){return"bigint"}mapFromDriverValue(_){if(typeof _==="number")return _;return Number(_)}}class R2 extends I{static[Y]="PgBigInt64Builder";constructor(_){super(_,"bigint","PgBigInt64")}build(_){return new M2(_,this.config)}}class M2 extends H{static[Y]="PgBigInt64";getSQLType(){return"bigint"}mapFromDriverValue(_){return BigInt(_)}}function U2(_,$){let{name:X,config:Z}=z(_,$);if(Z.mode==="number")return new x2(X);return new R2(X)}class q2 extends G{static[Y]="PgBigSerial53Builder";constructor(_){super(_,"number","PgBigSerial53");this.config.hasDefault=!0,this.config.notNull=!0}build(_){return new I2(_,this.config)}}class I2 extends H{static[Y]="PgBigSerial53";getSQLType(){return"bigserial"}mapFromDriverValue(_){if(typeof _==="number")return _;return Number(_)}}class L2 extends G{static[Y]="PgBigSerial64Builder";constructor(_){super(_,"bigint","PgBigSerial64");this.config.hasDefault=!0}build(_){return new T2(_,this.config)}}class T2 extends H{static[Y]="PgBigSerial64";getSQLType(){return"bigserial"}mapFromDriverValue(_){return BigInt(_)}}function K2(_,$){let{name:X,config:Z}=z(_,$);if(Z.mode==="number")return new q2(X);return new L2(X)}class N2 extends G{static[Y]="PgBooleanBuilder";constructor(_){super(_,"boolean","PgBoolean")}build(_){return new k2(_,this.config)}}class k2 extends H{static[Y]="PgBoolean";getSQLType(){return"boolean"}}function S2(_){return new N2(_??"")}class j2 extends G{static[Y]="PgCharBuilder";constructor(_,$){super(_,"string","PgChar");this.config.length=$.length,this.config.enumValues=$.enum}build(_){return new v2(_,this.config)}}class v2 extends H{static[Y]="PgChar";length=this.config.length;enumValues=this.config.enumValues;getSQLType(){return this.length===void 0?"char":`char(${this.length})`}}function h2(_,$={}){let{name:X,config:Z}=z(_,$);return new j2(X,Z)}class f2 extends G{static[Y]="PgCidrBuilder";constructor(_){super(_,"string","PgCidr")}build(_){return new C2(_,this.config)}}class C2 extends H{static[Y]="PgCidr";getSQLType(){return"cidr"}}function B2(_){return new f2(_??"")}class y2 extends G{static[Y]="PgCustomColumnBuilder";constructor(_,$,X){super(_,"custom","PgCustomColumn");this.config.fieldConfig=$,this.config.customTypeParams=X}build(_){return new p2(_,this.config)}}class p2 extends H{static[Y]="PgCustomColumn";sqlName;mapTo;mapFrom;constructor(_,$){super(_,$);this.sqlName=$.customTypeParams.dataType($.fieldConfig),this.mapTo=$.customTypeParams.toDriver,this.mapFrom=$.customTypeParams.fromDriver}getSQLType(){return this.sqlName}mapFromDriverValue(_){return typeof this.mapFrom==="function"?this.mapFrom(_):_}mapToDriverValue(_){return typeof this.mapTo==="function"?this.mapTo(_):_}}function b2(_){return($,X)=>{let{name:Z,config:J}=z($,X);return new y2(Z,J,_)}}class q extends G{static[Y]="PgDateColumnBaseBuilder";defaultNow(){return this.default(k`now()`)}}class P2 extends q{static[Y]="PgDateBuilder";constructor(_){super(_,"date","PgDate")}build(_){return new d2(_,this.config)}}class d2 extends H{static[Y]="PgDate";getSQLType(){return"date"}mapFromDriverValue(_){return new Date(_)}mapToDriverValue(_){return _.toISOString()}}class c2 extends q{static[Y]="PgDateStringBuilder";constructor(_){super(_,"string","PgDateString")}build(_){return new o2(_,this.config)}}class o2 extends H{static[Y]="PgDateString";getSQLType(){return"date"}}function s2(_,$){let{name:X,config:Z}=z(_,$);if(Z?.mode==="date")return new P2(X);return new c2(X)}class m2 extends G{static[Y]="PgDoublePrecisionBuilder";constructor(_){super(_,"number","PgDoublePrecision")}build(_){return new g2(_,this.config)}}class g2 extends H{static[Y]="PgDoublePrecision";getSQLType(){return"double precision"}mapFromDriverValue(_){if(typeof _==="string")return Number.parseFloat(_);return _}}function S(_){return new m2(_??"")}class r2 extends G{static[Y]="PgInetBuilder";constructor(_){super(_,"string","PgInet")}build(_){return new t2(_,this.config)}}class t2 extends H{static[Y]="PgInet";getSQLType(){return"inet"}}function u2(_){return new r2(_??"")}class l2 extends I{static[Y]="PgIntegerBuilder";constructor(_){super(_,"number","PgInteger")}build(_){return new i2(_,this.config)}}class i2 extends H{static[Y]="PgInteger";getSQLType(){return"integer"}mapFromDriverValue(_){if(typeof _==="string")return Number.parseInt(_);return _}}function L(_){return new l2(_??"")}class n2 extends G{static[Y]="PgIntervalBuilder";constructor(_,$){super(_,"string","PgInterval");this.config.intervalConfig=$}build(_){return new a2(_,this.config)}}class a2 extends H{static[Y]="PgInterval";fields=this.config.intervalConfig.fields;precision=this.config.intervalConfig.precision;getSQLType(){let _=this.fields?` ${this.fields}`:"",$=this.precision?`(${this.precision})`:"";return`interval${_}${$}`}}function e2(_,$={}){let{name:X,config:Z}=z(_,$);return new n2(X,Z)}class __ extends G{static[Y]="PgJsonBuilder";constructor(_){super(_,"json","PgJson")}build(_){return new $_(_,this.config)}}class $_ extends H{static[Y]="PgJson";constructor(_,$){super(_,$)}getSQLType(){return"json"}mapToDriverValue(_){return JSON.stringify(_)}mapFromDriverValue(_){if(typeof _==="string")try{return JSON.parse(_)}catch{return _}return _}}function X_(_){return new __(_??"")}class Y_ extends G{static[Y]="PgJsonbBuilder";constructor(_){super(_,"json","PgJsonb")}build(_){return new Z_(_,this.config)}}class Z_ extends H{static[Y]="PgJsonb";constructor(_,$){super(_,$)}getSQLType(){return"jsonb"}mapToDriverValue(_){return JSON.stringify(_)}mapFromDriverValue(_){if(typeof _==="string")try{return JSON.parse(_)}catch{return _}return _}}function H_(_){return new Y_(_??"")}class W_ extends G{static[Y]="PgLineBuilder";constructor(_){super(_,"array","PgLine")}build(_){return new G_(_,this.config)}}class G_ extends H{static[Y]="PgLine";getSQLType(){return"line"}mapFromDriverValue(_){let[$,X,Z]=_.slice(1,-1).split(",");return[Number.parseFloat($),Number.parseFloat(X),Number.parseFloat(Z)]}mapToDriverValue(_){return`{${_[0]},${_[1]},${_[2]}}`}}class J_ extends G{static[Y]="PgLineABCBuilder";constructor(_){super(_,"json","PgLineABC")}build(_){return new z_(_,this.config)}}class z_ extends H{static[Y]="PgLineABC";getSQLType(){return"line"}mapFromDriverValue(_){let[$,X,Z]=_.slice(1,-1).split(",");return{a:Number.parseFloat($),b:Number.parseFloat(X),c:Number.parseFloat(Z)}}mapToDriverValue(_){return`{${_.a},${_.b},${_.c}}`}}function O_(_,$){let{name:X,config:Z}=z(_,$);if(!Z?.mode||Z.mode==="tuple")return new W_(X);return new J_(X)}class F_ extends G{static[Y]="PgMacaddrBuilder";constructor(_){super(_,"string","PgMacaddr")}build(_){return new E_(_,this.config)}}class E_ extends H{static[Y]="PgMacaddr";getSQLType(){return"macaddr"}}function D_(_){return new F_(_??"")}class Q_ extends G{static[Y]="PgMacaddr8Builder";constructor(_){super(_,"string","PgMacaddr8")}build(_){return new V_(_,this.config)}}class V_ extends H{static[Y]="PgMacaddr8";getSQLType(){return"macaddr8"}}function w_(_){return new Q_(_??"")}class x_ extends G{static[Y]="PgNumericBuilder";constructor(_,$,X){super(_,"string","PgNumeric");this.config.precision=$,this.config.scale=X}build(_){return new A_(_,this.config)}}class A_ extends H{static[Y]="PgNumeric";precision;scale;constructor(_,$){super(_,$);this.precision=$.precision,this.scale=$.scale}mapFromDriverValue(_){if(typeof _==="string")return _;return String(_)}getSQLType(){if(this.precision!==void 0&&this.scale!==void 0)return`numeric(${this.precision}, ${this.scale})`;else if(this.precision===void 0)return"numeric";else return`numeric(${this.precision})`}}class R_ extends G{static[Y]="PgNumericNumberBuilder";constructor(_,$,X){super(_,"number","PgNumericNumber");this.config.precision=$,this.config.scale=X}build(_){return new M_(_,this.config)}}class M_ extends H{static[Y]="PgNumericNumber";precision;scale;constructor(_,$){super(_,$);this.precision=$.precision,this.scale=$.scale}mapFromDriverValue(_){if(typeof _==="number")return _;return Number(_)}mapToDriverValue=String;getSQLType(){if(this.precision!==void 0&&this.scale!==void 0)return`numeric(${this.precision}, ${this.scale})`;else if(this.precision===void 0)return"numeric";else return`numeric(${this.precision})`}}class U_ extends G{static[Y]="PgNumericBigIntBuilder";constructor(_,$,X){super(_,"bigint","PgNumericBigInt");this.config.precision=$,this.config.scale=X}build(_){return new q_(_,this.config)}}class q_ extends H{static[Y]="PgNumericBigInt";precision;scale;constructor(_,$){super(_,$);this.precision=$.precision,this.scale=$.scale}mapFromDriverValue=BigInt;mapToDriverValue=String;getSQLType(){if(this.precision!==void 0&&this.scale!==void 0)return`numeric(${this.precision}, ${this.scale})`;else if(this.precision===void 0)return"numeric";else return`numeric(${this.precision})`}}function I_(_,$){let{name:X,config:Z}=z(_,$),J=Z?.mode;return J==="number"?new R_(X,Z?.precision,Z?.scale):J==="bigint"?new U_(X,Z?.precision,Z?.scale):new x_(X,Z?.precision,Z?.scale)}class L_ extends G{static[Y]="PgPointTupleBuilder";constructor(_){super(_,"array","PgPointTuple")}build(_){return new T_(_,this.config)}}class T_ extends H{static[Y]="PgPointTuple";getSQLType(){return"point"}mapFromDriverValue(_){if(typeof _==="string"){let[$,X]=_.slice(1,-1).split(",");return[Number.parseFloat($),Number.parseFloat(X)]}return[_.x,_.y]}mapToDriverValue(_){return`(${_[0]},${_[1]})`}}class K_ extends G{static[Y]="PgPointObjectBuilder";constructor(_){super(_,"json","PgPointObject")}build(_){return new N_(_,this.config)}}class N_ extends H{static[Y]="PgPointObject";getSQLType(){return"point"}mapFromDriverValue(_){if(typeof _==="string"){let[$,X]=_.slice(1,-1).split(",");return{x:Number.parseFloat($),y:Number.parseFloat(X)}}return _}mapToDriverValue(_){return`(${_.x},${_.y})`}}function k_(_,$){let{name:X,config:Z}=z(_,$);if(!Z?.mode||Z.mode==="tuple")return new L_(X);return new K_(X)}function k0(_){let $=[];for(let X=0;X<_.length;X+=2)$.push(Number.parseInt(_.slice(X,X+2),16));return new Uint8Array($)}function S_(_,$){let X=new ArrayBuffer(8),Z=new DataView(X);for(let J=0;J<8;J++)Z.setUint8(J,_[$+J]);return Z.getFloat64(0,!0)}function l(_){let $=k0(_),X=0,Z=$[X];X+=1;let J=new DataView($.buffer),O=J.getUint32(X,Z===1);X+=4;let Q;if(O&536870912)Q=J.getUint32(X,Z===1),X+=4;if((O&65535)===1){let A=S_($,X);X+=8;let E=S_($,X);return X+=8,[A,E]}throw new Error("Unsupported geometry type")}class j_ extends G{static[Y]="PgGeometryBuilder";constructor(_){super(_,"array","PgGeometry")}build(_){return new v_(_,this.config)}}class v_ extends H{static[Y]="PgGeometry";getSQLType(){return"geometry(point)"}mapFromDriverValue(_){return l(_)}mapToDriverValue(_){return`point(${_[0]} ${_[1]})`}}class h_ extends G{static[Y]="PgGeometryObjectBuilder";constructor(_){super(_,"json","PgGeometryObject")}build(_){return new f_(_,this.config)}}class f_ extends H{static[Y]="PgGeometryObject";getSQLType(){return"geometry(point)"}mapFromDriverValue(_){let $=l(_);return{x:$[0],y:$[1]}}mapToDriverValue(_){return`point(${_.x} ${_.y})`}}function C_(_,$){let{name:X,config:Z}=z(_,$);if(!Z?.mode||Z.mode==="tuple")return new j_(X);return new h_(X)}class B_ extends G{static[Y]="PgRealBuilder";constructor(_,$){super(_,"number","PgReal");this.config.length=$}build(_){return new y_(_,this.config)}}class y_ extends H{static[Y]="PgReal";constructor(_,$){super(_,$)}getSQLType(){return"real"}mapFromDriverValue=(_)=>{if(typeof _==="string")return Number.parseFloat(_);return _}}function p_(_){return new B_(_??"")}class b_ extends G{static[Y]="PgSerialBuilder";constructor(_){super(_,"number","PgSerial");this.config.hasDefault=!0,this.config.notNull=!0}build(_){return new P_(_,this.config)}}class P_ extends H{static[Y]="PgSerial";getSQLType(){return"serial"}}function d_(_){return new b_(_??"")}class c_ extends I{static[Y]="PgSmallIntBuilder";constructor(_){super(_,"number","PgSmallInt")}build(_){return new o_(_,this.config)}}class o_ extends H{static[Y]="PgSmallInt";getSQLType(){return"smallint"}mapFromDriverValue=(_)=>{if(typeof _==="string")return Number(_);return _}}function s_(_){return new c_(_??"")}class m_ extends G{static[Y]="PgSmallSerialBuilder";constructor(_){super(_,"number","PgSmallSerial");this.config.hasDefault=!0,this.config.notNull=!0}build(_){return new g_(_,this.config)}}class g_ extends H{static[Y]="PgSmallSerial";getSQLType(){return"smallserial"}}function r_(_){return new m_(_??"")}class t_ extends G{static[Y]="PgTextBuilder";constructor(_,$){super(_,"string","PgText");this.config.enumValues=$.enum}build(_){return new u_(_,this.config)}}class u_ extends H{static[Y]="PgText";enumValues=this.config.enumValues;getSQLType(){return"text"}}function l_(_,$={}){let{name:X,config:Z}=z(_,$);return new t_(X,Z)}class i_ extends q{constructor(_,$,X){super(_,"string","PgTime");this.withTimezone=$,this.precision=X,this.config.withTimezone=$,this.config.precision=X}static[Y]="PgTimeBuilder";build(_){return new n_(_,this.config)}}class n_ extends H{static[Y]="PgTime";withTimezone;precision;constructor(_,$){super(_,$);this.withTimezone=$.withTimezone,this.precision=$.precision}getSQLType(){return`time${this.precision===void 0?"":`(${this.precision})`}${this.withTimezone?" with time zone":""}`}}function a_(_,$={}){let{name:X,config:Z}=z(_,$);return new i_(X,Z.withTimezone??!1,Z.precision)}class e_ extends q{static[Y]="PgTimestampBuilder";constructor(_,$,X){super(_,"date","PgTimestamp");this.config.withTimezone=$,this.config.precision=X}build(_){return new _0(_,this.config)}}class _0 extends H{static[Y]="PgTimestamp";withTimezone;precision;constructor(_,$){super(_,$);this.withTimezone=$.withTimezone,this.precision=$.precision}getSQLType(){return`timestamp${this.precision===void 0?"":` (${this.precision})`}${this.withTimezone?" with time zone":""}`}mapFromDriverValue=(_)=>{return new Date(this.withTimezone?_:_+"+0000")};mapToDriverValue=(_)=>{return _.toISOString()}}class $0 extends q{static[Y]="PgTimestampStringBuilder";constructor(_,$,X){super(_,"string","PgTimestampString");this.config.withTimezone=$,this.config.precision=X}build(_){return new X0(_,this.config)}}class X0 extends H{static[Y]="PgTimestampString";withTimezone;precision;constructor(_,$){super(_,$);this.withTimezone=$.withTimezone,this.precision=$.precision}getSQLType(){return`timestamp${this.precision===void 0?"":`(${this.precision})`}${this.withTimezone?" with time zone":""}`}}function Y0(_,$={}){let{name:X,config:Z}=z(_,$);if(Z?.mode==="string")return new $0(X,Z.withTimezone??!1,Z.precision);return new e_(X,Z?.withTimezone??!1,Z?.precision)}class Z0 extends G{static[Y]="PgUUIDBuilder";constructor(_){super(_,"string","PgUUID")}defaultRandom(){return this.default(k`gen_random_uuid()`)}build(_){return new H0(_,this.config)}}class H0 extends H{static[Y]="PgUUID";getSQLType(){return"uuid"}}function y(_){return new Z0(_??"")}class W0 extends G{static[Y]="PgVarcharBuilder";constructor(_,$){super(_,"string","PgVarchar");this.config.length=$.length,this.config.enumValues=$.enum}build(_){return new G0(_,this.config)}}class G0 extends H{static[Y]="PgVarchar";length=this.config.length;enumValues=this.config.enumValues;getSQLType(){return this.length===void 0?"varchar":`varchar(${this.length})`}}function T(_,$={}){let{name:X,config:Z}=z(_,$);return new W0(X,Z)}class J0 extends G{static[Y]="PgBinaryVectorBuilder";constructor(_,$){super(_,"string","PgBinaryVector");this.config.dimensions=$.dimensions}build(_){return new z0(_,this.config)}}class z0 extends H{static[Y]="PgBinaryVector";dimensions=this.config.dimensions;getSQLType(){return`bit(${this.dimensions})`}}function O0(_,$){let{name:X,config:Z}=z(_,$);return new J0(X,Z)}class F0 extends G{static[Y]="PgHalfVectorBuilder";constructor(_,$){super(_,"array","PgHalfVector");this.config.dimensions=$.dimensions}build(_){return new E0(_,this.config)}}class E0 extends H{static[Y]="PgHalfVector";dimensions=this.config.dimensions;getSQLType(){return`halfvec(${this.dimensions})`}mapToDriverValue(_){return JSON.stringify(_)}mapFromDriverValue(_){return _.slice(1,-1).split(",").map(($)=>Number.parseFloat($))}}function D0(_,$){let{name:X,config:Z}=z(_,$);return new F0(X,Z)}class Q0 extends G{static[Y]="PgSparseVectorBuilder";constructor(_,$){super(_,"string","PgSparseVector");this.config.dimensions=$.dimensions}build(_){return new V0(_,this.config)}}class V0 extends H{static[Y]="PgSparseVector";dimensions=this.config.dimensions;getSQLType(){return`sparsevec(${this.dimensions})`}}function w0(_,$){let{name:X,config:Z}=z(_,$);return new Q0(X,Z)}class x0 extends G{static[Y]="PgVectorBuilder";constructor(_,$){super(_,"array","PgVector");this.config.dimensions=$.dimensions}build(_){return new A0(_,this.config)}}class A0 extends H{static[Y]="PgVector";dimensions=this.config.dimensions;getSQLType(){return`vector(${this.dimensions})`}mapToDriverValue(_){return JSON.stringify(_)}mapFromDriverValue(_){return _.slice(1,-1).split(",").map(($)=>Number.parseFloat($))}}function R0(_,$){let{name:X,config:Z}=z(_,$);return new x0(X,Z)}function M0(){return{bigint:U2,bigserial:K2,boolean:S2,char:h2,cidr:B2,customType:b2,date:s2,doublePrecision:S,inet:u2,integer:L,interval:e2,json:X_,jsonb:H_,line:O_,macaddr:D_,macaddr8:w_,numeric:I_,point:k_,geometry:C_,real:p_,serial:d_,smallint:s_,smallserial:r_,text:l_,time:a_,timestamp:Y0,uuid:y,varchar:T,bit:O0,halfvec:D0,sparsevec:w0,vector:R0}}var i=Symbol.for("drizzle:PgInlineForeignKeys"),U0=Symbol.for("drizzle:EnableRLS");class p extends w{static[Y]="PgTable";static Symbol=Object.assign({},w.Symbol,{InlineForeignKeys:i,EnableRLS:U0});[i]=[];[U0]=!1;[w.Symbol.ExtraConfigBuilder]=void 0;[w.Symbol.ExtraConfigColumns]={}}function S0(_,$,X,Z,J=_){let O=new p(_,Z,J),Q=typeof $==="function"?$(M0()):$,A=Object.fromEntries(Object.entries(Q).map(([F,V])=>{let M=V;M.setName(F);let v=M.build(O);return O[i].push(...M.buildForeignKeys(v,O)),[F,v]})),E=Object.fromEntries(Object.entries(Q).map(([F,V])=>{let M=V;M.setName(F);let v=M.buildExtraConfigColumn(O);return[F,v]})),W=Object.assign(O,A);if(W[w.Symbol.Columns]=A,W[w.Symbol.ExtraConfigColumns]=E,X)W[p.Symbol.ExtraConfigBuilder]=X;return Object.assign(W,{enableRLS:()=>{return W[p.Symbol.EnableRLS]=!0,W}})}var q0=(_,$,X)=>{return S0(_,$,X,void 0)};var jX=q0("units",{id:y("id").defaultRandom().primaryKey(),unitNo:T("unit_no",{length:10}).notNull(),number:L("number"),project:T("project",{length:256}).notNull(),floor:L("floor").notNull(),unitType:T("unit_type",{length:256,enum:["Studio Squared","1 BR Squared","Studio Flex","2 BR Squared","One Bedroom2","Studio2","One Bedroom Loft","Two Bedroom Loft"]}),noOfBathrooms:L("no_of_bathrooms").notNull(),unitView:T("unit_view",{length:256,enum:["Canal / Amenities","Corner-Canal / Amenities","Corner-Canal View","Business Bay","Park Facing","Corner-Park Facing","Partial Park","BK/DT / Amenities","Corner-BK/DT / Amenities","Corner-Canal / BK/DT View","Marina View","Partial Marina View","Partial Marina, Partial City View","City view","Marina View, Sea View","Partial Marina View, Partial Sea View"]}),suitsArea:S("suits_area").notNull(),squareFt:S("square_ft").notNull(),noOfParkingSpace:L("no_of_parking_space").notNull(),salesPrice:L("sales_price").notNull(),state:T("state",{length:256,enum:["reserved","sold_spa","available","sold_registered"]}).notNull(),balconyArea:S("balcony_area").notNull()},(_)=>[a().on(_.project,_.unitNo)]);export{jX as unitsTable}; diff --git a/dist/db/schema/units.js b/dist/db/schema/units.js deleted file mode 100644 index 85404ac..0000000 --- a/dist/db/schema/units.js +++ /dev/null @@ -1,2 +0,0 @@ -// @bun -var Y=Symbol.for("drizzle:entityKind"),j0=Symbol.for("drizzle:hasOwnEntityKind");function x(_,$){if(!_||typeof _!=="object")return!1;if(_ instanceof $)return!0;if(!Object.prototype.hasOwnProperty.call($,Y))throw new Error(`Class "${$.name??""}" doesn't look like a Drizzle entity. If this is incorrect and the class is provided by Drizzle, please report this as a bug.`);let X=Object.getPrototypeOf(_).constructor;if(X)while(X){if(Y in X&&X[Y]===$[Y])return!0;X=Object.getPrototypeOf(X)}return!1}class K{constructor(_,$){this.table=_,this.config=$,this.name=$.name,this.keyAsName=$.keyAsName,this.notNull=$.notNull,this.default=$.default,this.defaultFn=$.defaultFn,this.onUpdateFn=$.onUpdateFn,this.hasDefault=$.hasDefault,this.primary=$.primaryKey,this.isUnique=$.isUnique,this.uniqueName=$.uniqueName,this.uniqueType=$.uniqueType,this.dataType=$.dataType,this.columnType=$.columnType,this.generated=$.generated,this.generatedIdentity=$.generatedIdentity}static[Y]="Column";name;keyAsName;primary;notNull;default;defaultFn;onUpdateFn;hasDefault;isUnique;uniqueName;uniqueType;dataType;columnType;enumValues=void 0;generated=void 0;generatedIdentity=void 0;config;mapFromDriverValue(_){return _}mapToDriverValue(_){return _}shouldDisableInsert(){return this.config.generated!==void 0&&this.config.generated.type!=="byDefault"}}class b{static[Y]="ColumnBuilder";config;constructor(_,$,X){this.config={name:_,keyAsName:_==="",notNull:!1,default:void 0,hasDefault:!1,primaryKey:!1,isUnique:!1,uniqueName:void 0,uniqueType:void 0,dataType:$,columnType:X,generated:void 0}}$type(){return this}notNull(){return this.config.notNull=!0,this}default(_){return this.config.default=_,this.config.hasDefault=!0,this}$defaultFn(_){return this.config.defaultFn=_,this.config.hasDefault=!0,this}$default=this.$defaultFn;$onUpdateFn(_){return this.config.onUpdateFn=_,this.config.hasDefault=!0,this}$onUpdate=this.$onUpdateFn;primaryKey(){return this.config.primaryKey=!0,this.config.notNull=!0,this}setName(_){if(this.config.name!=="")return;this.config.name=_}}var U=Symbol.for("drizzle:Name");class P{static[Y]="PgForeignKeyBuilder";reference;_onUpdate="no action";_onDelete="no action";constructor(_,$){if(this.reference=()=>{let{name:X,columns:Z,foreignColumns:J}=_();return{name:X,columns:Z,foreignTable:J[0].table,foreignColumns:J}},$)this._onUpdate=$.onUpdate,this._onDelete=$.onDelete}onUpdate(_){return this._onUpdate=_===void 0?"no action":_,this}onDelete(_){return this._onDelete=_===void 0?"no action":_,this}build(_){return new n(_,this)}}class n{constructor(_,$){this.table=_,this.reference=$.reference,this.onUpdate=$._onUpdate,this.onDelete=$._onDelete}static[Y]="PgForeignKey";reference;onUpdate;onDelete;getName(){let{name:_,columns:$,foreignColumns:X}=this.reference(),Z=$.map((Q)=>Q.name),J=X.map((Q)=>Q.name),O=[this.table[U],...Z,X[0].table[U],...J];return _??`${O.join("_")}_fk`}}function h(_,...$){return _(...$)}function a(_){return new _2(_)}function d(_,$){return`${_[U]}_${$.join("_")}_unique`}class e{constructor(_,$){this.name=$,this.columns=_}static[Y]="PgUniqueConstraintBuilder";columns;nullsNotDistinctConfig=!1;nullsNotDistinct(){return this.nullsNotDistinctConfig=!0,this}build(_){return new $2(_,this.columns,this.nullsNotDistinctConfig,this.name)}}class _2{static[Y]="PgUniqueOnConstraintBuilder";name;constructor(_){this.name=_}on(..._){return new e(_,this.name)}}class $2{constructor(_,$,X,Z){this.table=_,this.columns=$,this.name=Z??d(this.table,this.columns.map((J)=>J.name)),this.nullsNotDistinct=X}static[Y]="PgUniqueConstraint";columns;name;nullsNotDistinct=!1;getName(){return this.name}}function X2(_,$,X){for(let Z=$;Z<_.length;Z++){let J=_[Z];if(J==="\\"){Z++;continue}if(J==='"')return[_.slice($,Z).replace(/\\/g,""),Z+1];if(X)continue;if(J===","||J==="}")return[_.slice($,Z).replace(/\\/g,""),Z]}return[_.slice($).replace(/\\/g,""),_.length]}function Y2(_,$=0){let X=[],Z=$,J=!1;while(Z<_.length){let O=_[Z];if(O===","){if(J||Z===$)X.push("");J=!0,Z++;continue}if(J=!1,O==="\\"){Z+=2;continue}if(O==='"'){let[E,W]=X2(_,Z+1,!0);X.push(E),Z=W;continue}if(O==="}")return[X,Z+1];if(O==="{"){let[E,W]=Y2(_,Z+1);X.push(E),Z=W;continue}let[Q,A]=X2(_,Z,!1);X.push(Q),Z=A}return[X,Z]}function Z2(_){let[$]=Y2(_,1);return $}function c(_){return`{${_.map(($)=>{if(Array.isArray($))return c($);if(typeof $==="string")return`"${$.replace(/\\/g,"\\\\").replace(/"/g,"\\\"")}"`;return`${$}`}).join(",")}}`}class G extends b{foreignKeyConfigs=[];static[Y]="PgColumnBuilder";array(_){return new W2(this.config.name,this,_)}references(_,$={}){return this.foreignKeyConfigs.push({ref:_,actions:$}),this}unique(_,$){return this.config.isUnique=!0,this.config.uniqueName=_,this.config.uniqueType=$?.nulls,this}generatedAlwaysAs(_){return this.config.generated={as:_,type:"always",mode:"stored"},this}buildForeignKeys(_,$){return this.foreignKeyConfigs.map(({ref:X,actions:Z})=>{return h((J,O)=>{let Q=new P(()=>{let A=J();return{columns:[_],foreignColumns:[A]}});if(O.onUpdate)Q.onUpdate(O.onUpdate);if(O.onDelete)Q.onDelete(O.onDelete);return Q.build($)},X,Z)})}buildExtraConfigColumn(_){return new H2(_,this.config)}}class H extends K{constructor(_,$){if(!$.uniqueName)$.uniqueName=d(_,[$.name]);super(_,$);this.table=_}static[Y]="PgColumn"}class H2 extends H{static[Y]="ExtraConfigColumn";getSQLType(){return this.getSQLType()}indexConfig={order:this.config.order??"asc",nulls:this.config.nulls??"last",opClass:this.config.opClass};defaultConfig={order:"asc",nulls:"last",opClass:void 0};asc(){return this.indexConfig.order="asc",this}desc(){return this.indexConfig.order="desc",this}nullsFirst(){return this.indexConfig.nulls="first",this}nullsLast(){return this.indexConfig.nulls="last",this}op(_){return this.indexConfig.opClass=_,this}}class W2 extends G{static[Y]="PgArrayBuilder";constructor(_,$,X){super(_,"array","PgArray");this.config.baseBuilder=$,this.config.size=X}build(_){let $=this.config.baseBuilder.build(_);return new o(_,this.config,$)}}class o extends H{constructor(_,$,X,Z){super(_,$);this.baseColumn=X,this.range=Z,this.size=$.size}size;static[Y]="PgArray";getSQLType(){return`${this.baseColumn.getSQLType()}[${typeof this.size==="number"?this.size:""}]`}mapFromDriverValue(_){if(typeof _==="string")_=Z2(_);return _.map(($)=>this.baseColumn.mapFromDriverValue($))}mapToDriverValue(_,$=!1){let X=_.map((Z)=>Z===null?null:x(this.baseColumn,o)?this.baseColumn.mapToDriverValue(Z,!0):this.baseColumn.mapToDriverValue(Z));if($)return X;return c(X)}}var G2=Symbol.for("drizzle:isPgEnum");function J2(_){return!!_&&typeof _==="function"&&G2 in _&&_[G2]===!0}class I0 extends H{static[Y]="PgEnumColumn";enum=this.config.enum;enumValues=this.config.enum.enumValues;constructor(_,$){super(_,$);this.enum=$.enum}getSQLType(){return this.enum.enumName}}class f{static[Y]="Subquery";constructor(_,$,X,Z=!1){this._={brand:"Subquery",sql:_,selectedFields:$,alias:X,isWith:Z}}}var z2="0.41.0";var s,m,O2={startActiveSpan(_,$){if(!s)return $();if(!m)m=s.trace.getTracer("drizzle-orm",z2);return h((X,Z)=>Z.startActiveSpan(_,(J)=>{try{return $(J)}catch(O){throw J.setStatus({code:X.SpanStatusCode.ERROR,message:O instanceof Error?O.message:"Unknown error"}),O}finally{J.end()}}),s,m)}};var N=Symbol.for("drizzle:ViewBaseConfig");var g=Symbol.for("drizzle:Schema"),F2=Symbol.for("drizzle:Columns"),E2=Symbol.for("drizzle:ExtraConfigColumns"),r=Symbol.for("drizzle:OriginalName"),t=Symbol.for("drizzle:BaseName"),j=Symbol.for("drizzle:IsAlias"),D2=Symbol.for("drizzle:ExtraConfigBuilder"),L0=Symbol.for("drizzle:IsDrizzleTable");class w{static[Y]="Table";static Symbol={Name:U,Schema:g,OriginalName:r,Columns:F2,ExtraConfigColumns:E2,BaseName:t,IsAlias:j,ExtraConfigBuilder:D2};[U];[r];[g];[F2];[E2];[t];[j]=!1;[L0]=!0;[D2]=void 0;constructor(_,$,X){this[U]=this[r]=_,this[g]=$,this[t]=X}}function T0(_){return _!==null&&_!==void 0&&typeof _.getSQL==="function"}function K0(_){let $={sql:"",params:[]};for(let X of _)if($.sql+=X.sql,$.params.push(...X.params),X.typings?.length){if(!$.typings)$.typings=[];$.typings.push(...X.typings)}return $}class R{static[Y]="StringChunk";value;constructor(_){this.value=Array.isArray(_)?_:[_]}getSQL(){return new D([this])}}class D{constructor(_){this.queryChunks=_}static[Y]="SQL";decoder=Q2;shouldInlineParams=!1;append(_){return this.queryChunks.push(..._.queryChunks),this}toQuery(_){return O2.startActiveSpan("drizzle.buildSQL",($)=>{let X=this.buildQueryFromSourceParams(this.queryChunks,_);return $?.setAttributes({"drizzle.query.text":X.sql,"drizzle.query.params":JSON.stringify(X.params)}),X})}buildQueryFromSourceParams(_,$){let X=Object.assign({},$,{inlineParams:$.inlineParams||this.shouldInlineParams,paramStartIndex:$.paramStartIndex||{value:0}}),{casing:Z,escapeName:J,escapeParam:O,prepareTyping:Q,inlineParams:A,paramStartIndex:E}=X;return K0(_.map((W)=>{if(x(W,R))return{sql:W.value.join(""),params:[]};if(x(W,C))return{sql:J(W.value),params:[]};if(W===void 0)return{sql:"",params:[]};if(Array.isArray(W)){let F=[new R("(")];for(let[V,M]of W.entries())if(F.push(M),V_},V2={mapToDriverValue:(_)=>_},R1={...Q2,...V2};class u{constructor(_,$=V2){this.value=_,this.encoder=$}static[Y]="Param";brand;getSQL(){return new D([this])}}function k(_,...$){let X=[];if($.length>0||_.length>0&&_[0]!=="")X.push(new R(_[0]));for(let[Z,J]of $.entries())X.push(J,new R(_[Z+1]));return new D(X)}((_)=>{function $(){return new D([])}_.empty=$;function X(E){return new D(E)}_.fromList=X;function Z(E){return new D([new R(E)])}_.raw=Z;function J(E,W){let F=[];for(let[V,M]of E.entries()){if(V>0&&W!==void 0)F.push(W);F.push(M)}return new D(F)}_.join=J;function O(E){return new C(E)}_.identifier=O;function Q(E){return new B(E)}_.placeholder=Q;function A(E,W){return new u(E,W)}_.param=A})(k||(k={}));((_)=>{class ${constructor(X,Z){this.sql=X,this.fieldAlias=Z}static[Y]="SQL.Aliased";isSelectionField=!1;getSQL(){return this.sql}clone(){return new $(this.sql,this.fieldAlias)}}_.Aliased=$})(D||(D={}));class B{constructor(_){this.name=_}static[Y]="Placeholder";getSQL(){return new D([this])}}var N0=Symbol.for("drizzle:IsDrizzleView");class w2{static[Y]="View";[N];[N0]=!0;constructor({name:_,schema:$,selectedFields:X,query:Z}){this[N]={name:_,originalName:_,schema:$,selectedFields:X,query:Z,isExisting:!Z,isAlias:!1}}getSQL(){return new D([this])}}K.prototype.getSQL=function(){return new D([this])};w.prototype.getSQL=function(){return new D([this])};f.prototype.getSQL=function(){return new D([this])};function z(_,$){return{name:typeof _==="string"&&_.length>0?_:"",config:typeof _==="object"?_:$}}class I extends G{static[Y]="PgIntColumnBaseBuilder";generatedAlwaysAsIdentity(_){if(_){let{name:$,...X}=_;this.config.generatedIdentity={type:"always",sequenceName:$,sequenceOptions:X}}else this.config.generatedIdentity={type:"always"};return this.config.hasDefault=!0,this.config.notNull=!0,this}generatedByDefaultAsIdentity(_){if(_){let{name:$,...X}=_;this.config.generatedIdentity={type:"byDefault",sequenceName:$,sequenceOptions:X}}else this.config.generatedIdentity={type:"byDefault"};return this.config.hasDefault=!0,this.config.notNull=!0,this}}class x2 extends I{static[Y]="PgBigInt53Builder";constructor(_){super(_,"number","PgBigInt53")}build(_){return new A2(_,this.config)}}class A2 extends H{static[Y]="PgBigInt53";getSQLType(){return"bigint"}mapFromDriverValue(_){if(typeof _==="number")return _;return Number(_)}}class R2 extends I{static[Y]="PgBigInt64Builder";constructor(_){super(_,"bigint","PgBigInt64")}build(_){return new M2(_,this.config)}}class M2 extends H{static[Y]="PgBigInt64";getSQLType(){return"bigint"}mapFromDriverValue(_){return BigInt(_)}}function U2(_,$){let{name:X,config:Z}=z(_,$);if(Z.mode==="number")return new x2(X);return new R2(X)}class q2 extends G{static[Y]="PgBigSerial53Builder";constructor(_){super(_,"number","PgBigSerial53");this.config.hasDefault=!0,this.config.notNull=!0}build(_){return new I2(_,this.config)}}class I2 extends H{static[Y]="PgBigSerial53";getSQLType(){return"bigserial"}mapFromDriverValue(_){if(typeof _==="number")return _;return Number(_)}}class L2 extends G{static[Y]="PgBigSerial64Builder";constructor(_){super(_,"bigint","PgBigSerial64");this.config.hasDefault=!0}build(_){return new T2(_,this.config)}}class T2 extends H{static[Y]="PgBigSerial64";getSQLType(){return"bigserial"}mapFromDriverValue(_){return BigInt(_)}}function K2(_,$){let{name:X,config:Z}=z(_,$);if(Z.mode==="number")return new q2(X);return new L2(X)}class N2 extends G{static[Y]="PgBooleanBuilder";constructor(_){super(_,"boolean","PgBoolean")}build(_){return new k2(_,this.config)}}class k2 extends H{static[Y]="PgBoolean";getSQLType(){return"boolean"}}function S2(_){return new N2(_??"")}class j2 extends G{static[Y]="PgCharBuilder";constructor(_,$){super(_,"string","PgChar");this.config.length=$.length,this.config.enumValues=$.enum}build(_){return new v2(_,this.config)}}class v2 extends H{static[Y]="PgChar";length=this.config.length;enumValues=this.config.enumValues;getSQLType(){return this.length===void 0?"char":`char(${this.length})`}}function h2(_,$={}){let{name:X,config:Z}=z(_,$);return new j2(X,Z)}class f2 extends G{static[Y]="PgCidrBuilder";constructor(_){super(_,"string","PgCidr")}build(_){return new C2(_,this.config)}}class C2 extends H{static[Y]="PgCidr";getSQLType(){return"cidr"}}function B2(_){return new f2(_??"")}class y2 extends G{static[Y]="PgCustomColumnBuilder";constructor(_,$,X){super(_,"custom","PgCustomColumn");this.config.fieldConfig=$,this.config.customTypeParams=X}build(_){return new p2(_,this.config)}}class p2 extends H{static[Y]="PgCustomColumn";sqlName;mapTo;mapFrom;constructor(_,$){super(_,$);this.sqlName=$.customTypeParams.dataType($.fieldConfig),this.mapTo=$.customTypeParams.toDriver,this.mapFrom=$.customTypeParams.fromDriver}getSQLType(){return this.sqlName}mapFromDriverValue(_){return typeof this.mapFrom==="function"?this.mapFrom(_):_}mapToDriverValue(_){return typeof this.mapTo==="function"?this.mapTo(_):_}}function b2(_){return($,X)=>{let{name:Z,config:J}=z($,X);return new y2(Z,J,_)}}class q extends G{static[Y]="PgDateColumnBaseBuilder";defaultNow(){return this.default(k`now()`)}}class P2 extends q{static[Y]="PgDateBuilder";constructor(_){super(_,"date","PgDate")}build(_){return new d2(_,this.config)}}class d2 extends H{static[Y]="PgDate";getSQLType(){return"date"}mapFromDriverValue(_){return new Date(_)}mapToDriverValue(_){return _.toISOString()}}class c2 extends q{static[Y]="PgDateStringBuilder";constructor(_){super(_,"string","PgDateString")}build(_){return new o2(_,this.config)}}class o2 extends H{static[Y]="PgDateString";getSQLType(){return"date"}}function s2(_,$){let{name:X,config:Z}=z(_,$);if(Z?.mode==="date")return new P2(X);return new c2(X)}class m2 extends G{static[Y]="PgDoublePrecisionBuilder";constructor(_){super(_,"number","PgDoublePrecision")}build(_){return new g2(_,this.config)}}class g2 extends H{static[Y]="PgDoublePrecision";getSQLType(){return"double precision"}mapFromDriverValue(_){if(typeof _==="string")return Number.parseFloat(_);return _}}function S(_){return new m2(_??"")}class r2 extends G{static[Y]="PgInetBuilder";constructor(_){super(_,"string","PgInet")}build(_){return new t2(_,this.config)}}class t2 extends H{static[Y]="PgInet";getSQLType(){return"inet"}}function u2(_){return new r2(_??"")}class l2 extends I{static[Y]="PgIntegerBuilder";constructor(_){super(_,"number","PgInteger")}build(_){return new i2(_,this.config)}}class i2 extends H{static[Y]="PgInteger";getSQLType(){return"integer"}mapFromDriverValue(_){if(typeof _==="string")return Number.parseInt(_);return _}}function L(_){return new l2(_??"")}class n2 extends G{static[Y]="PgIntervalBuilder";constructor(_,$){super(_,"string","PgInterval");this.config.intervalConfig=$}build(_){return new a2(_,this.config)}}class a2 extends H{static[Y]="PgInterval";fields=this.config.intervalConfig.fields;precision=this.config.intervalConfig.precision;getSQLType(){let _=this.fields?` ${this.fields}`:"",$=this.precision?`(${this.precision})`:"";return`interval${_}${$}`}}function e2(_,$={}){let{name:X,config:Z}=z(_,$);return new n2(X,Z)}class __ extends G{static[Y]="PgJsonBuilder";constructor(_){super(_,"json","PgJson")}build(_){return new $_(_,this.config)}}class $_ extends H{static[Y]="PgJson";constructor(_,$){super(_,$)}getSQLType(){return"json"}mapToDriverValue(_){return JSON.stringify(_)}mapFromDriverValue(_){if(typeof _==="string")try{return JSON.parse(_)}catch{return _}return _}}function X_(_){return new __(_??"")}class Y_ extends G{static[Y]="PgJsonbBuilder";constructor(_){super(_,"json","PgJsonb")}build(_){return new Z_(_,this.config)}}class Z_ extends H{static[Y]="PgJsonb";constructor(_,$){super(_,$)}getSQLType(){return"jsonb"}mapToDriverValue(_){return JSON.stringify(_)}mapFromDriverValue(_){if(typeof _==="string")try{return JSON.parse(_)}catch{return _}return _}}function H_(_){return new Y_(_??"")}class W_ extends G{static[Y]="PgLineBuilder";constructor(_){super(_,"array","PgLine")}build(_){return new G_(_,this.config)}}class G_ extends H{static[Y]="PgLine";getSQLType(){return"line"}mapFromDriverValue(_){let[$,X,Z]=_.slice(1,-1).split(",");return[Number.parseFloat($),Number.parseFloat(X),Number.parseFloat(Z)]}mapToDriverValue(_){return`{${_[0]},${_[1]},${_[2]}}`}}class J_ extends G{static[Y]="PgLineABCBuilder";constructor(_){super(_,"json","PgLineABC")}build(_){return new z_(_,this.config)}}class z_ extends H{static[Y]="PgLineABC";getSQLType(){return"line"}mapFromDriverValue(_){let[$,X,Z]=_.slice(1,-1).split(",");return{a:Number.parseFloat($),b:Number.parseFloat(X),c:Number.parseFloat(Z)}}mapToDriverValue(_){return`{${_.a},${_.b},${_.c}}`}}function O_(_,$){let{name:X,config:Z}=z(_,$);if(!Z?.mode||Z.mode==="tuple")return new W_(X);return new J_(X)}class F_ extends G{static[Y]="PgMacaddrBuilder";constructor(_){super(_,"string","PgMacaddr")}build(_){return new E_(_,this.config)}}class E_ extends H{static[Y]="PgMacaddr";getSQLType(){return"macaddr"}}function D_(_){return new F_(_??"")}class Q_ extends G{static[Y]="PgMacaddr8Builder";constructor(_){super(_,"string","PgMacaddr8")}build(_){return new V_(_,this.config)}}class V_ extends H{static[Y]="PgMacaddr8";getSQLType(){return"macaddr8"}}function w_(_){return new Q_(_??"")}class x_ extends G{static[Y]="PgNumericBuilder";constructor(_,$,X){super(_,"string","PgNumeric");this.config.precision=$,this.config.scale=X}build(_){return new A_(_,this.config)}}class A_ extends H{static[Y]="PgNumeric";precision;scale;constructor(_,$){super(_,$);this.precision=$.precision,this.scale=$.scale}mapFromDriverValue(_){if(typeof _==="string")return _;return String(_)}getSQLType(){if(this.precision!==void 0&&this.scale!==void 0)return`numeric(${this.precision}, ${this.scale})`;else if(this.precision===void 0)return"numeric";else return`numeric(${this.precision})`}}class R_ extends G{static[Y]="PgNumericNumberBuilder";constructor(_,$,X){super(_,"number","PgNumericNumber");this.config.precision=$,this.config.scale=X}build(_){return new M_(_,this.config)}}class M_ extends H{static[Y]="PgNumericNumber";precision;scale;constructor(_,$){super(_,$);this.precision=$.precision,this.scale=$.scale}mapFromDriverValue(_){if(typeof _==="number")return _;return Number(_)}mapToDriverValue=String;getSQLType(){if(this.precision!==void 0&&this.scale!==void 0)return`numeric(${this.precision}, ${this.scale})`;else if(this.precision===void 0)return"numeric";else return`numeric(${this.precision})`}}class U_ extends G{static[Y]="PgNumericBigIntBuilder";constructor(_,$,X){super(_,"bigint","PgNumericBigInt");this.config.precision=$,this.config.scale=X}build(_){return new q_(_,this.config)}}class q_ extends H{static[Y]="PgNumericBigInt";precision;scale;constructor(_,$){super(_,$);this.precision=$.precision,this.scale=$.scale}mapFromDriverValue=BigInt;mapToDriverValue=String;getSQLType(){if(this.precision!==void 0&&this.scale!==void 0)return`numeric(${this.precision}, ${this.scale})`;else if(this.precision===void 0)return"numeric";else return`numeric(${this.precision})`}}function I_(_,$){let{name:X,config:Z}=z(_,$),J=Z?.mode;return J==="number"?new R_(X,Z?.precision,Z?.scale):J==="bigint"?new U_(X,Z?.precision,Z?.scale):new x_(X,Z?.precision,Z?.scale)}class L_ extends G{static[Y]="PgPointTupleBuilder";constructor(_){super(_,"array","PgPointTuple")}build(_){return new T_(_,this.config)}}class T_ extends H{static[Y]="PgPointTuple";getSQLType(){return"point"}mapFromDriverValue(_){if(typeof _==="string"){let[$,X]=_.slice(1,-1).split(",");return[Number.parseFloat($),Number.parseFloat(X)]}return[_.x,_.y]}mapToDriverValue(_){return`(${_[0]},${_[1]})`}}class K_ extends G{static[Y]="PgPointObjectBuilder";constructor(_){super(_,"json","PgPointObject")}build(_){return new N_(_,this.config)}}class N_ extends H{static[Y]="PgPointObject";getSQLType(){return"point"}mapFromDriverValue(_){if(typeof _==="string"){let[$,X]=_.slice(1,-1).split(",");return{x:Number.parseFloat($),y:Number.parseFloat(X)}}return _}mapToDriverValue(_){return`(${_.x},${_.y})`}}function k_(_,$){let{name:X,config:Z}=z(_,$);if(!Z?.mode||Z.mode==="tuple")return new L_(X);return new K_(X)}function k0(_){let $=[];for(let X=0;X<_.length;X+=2)$.push(Number.parseInt(_.slice(X,X+2),16));return new Uint8Array($)}function S_(_,$){let X=new ArrayBuffer(8),Z=new DataView(X);for(let J=0;J<8;J++)Z.setUint8(J,_[$+J]);return Z.getFloat64(0,!0)}function l(_){let $=k0(_),X=0,Z=$[X];X+=1;let J=new DataView($.buffer),O=J.getUint32(X,Z===1);X+=4;let Q;if(O&536870912)Q=J.getUint32(X,Z===1),X+=4;if((O&65535)===1){let A=S_($,X);X+=8;let E=S_($,X);return X+=8,[A,E]}throw new Error("Unsupported geometry type")}class j_ extends G{static[Y]="PgGeometryBuilder";constructor(_){super(_,"array","PgGeometry")}build(_){return new v_(_,this.config)}}class v_ extends H{static[Y]="PgGeometry";getSQLType(){return"geometry(point)"}mapFromDriverValue(_){return l(_)}mapToDriverValue(_){return`point(${_[0]} ${_[1]})`}}class h_ extends G{static[Y]="PgGeometryObjectBuilder";constructor(_){super(_,"json","PgGeometryObject")}build(_){return new f_(_,this.config)}}class f_ extends H{static[Y]="PgGeometryObject";getSQLType(){return"geometry(point)"}mapFromDriverValue(_){let $=l(_);return{x:$[0],y:$[1]}}mapToDriverValue(_){return`point(${_.x} ${_.y})`}}function C_(_,$){let{name:X,config:Z}=z(_,$);if(!Z?.mode||Z.mode==="tuple")return new j_(X);return new h_(X)}class B_ extends G{static[Y]="PgRealBuilder";constructor(_,$){super(_,"number","PgReal");this.config.length=$}build(_){return new y_(_,this.config)}}class y_ extends H{static[Y]="PgReal";constructor(_,$){super(_,$)}getSQLType(){return"real"}mapFromDriverValue=(_)=>{if(typeof _==="string")return Number.parseFloat(_);return _}}function p_(_){return new B_(_??"")}class b_ extends G{static[Y]="PgSerialBuilder";constructor(_){super(_,"number","PgSerial");this.config.hasDefault=!0,this.config.notNull=!0}build(_){return new P_(_,this.config)}}class P_ extends H{static[Y]="PgSerial";getSQLType(){return"serial"}}function d_(_){return new b_(_??"")}class c_ extends I{static[Y]="PgSmallIntBuilder";constructor(_){super(_,"number","PgSmallInt")}build(_){return new o_(_,this.config)}}class o_ extends H{static[Y]="PgSmallInt";getSQLType(){return"smallint"}mapFromDriverValue=(_)=>{if(typeof _==="string")return Number(_);return _}}function s_(_){return new c_(_??"")}class m_ extends G{static[Y]="PgSmallSerialBuilder";constructor(_){super(_,"number","PgSmallSerial");this.config.hasDefault=!0,this.config.notNull=!0}build(_){return new g_(_,this.config)}}class g_ extends H{static[Y]="PgSmallSerial";getSQLType(){return"smallserial"}}function r_(_){return new m_(_??"")}class t_ extends G{static[Y]="PgTextBuilder";constructor(_,$){super(_,"string","PgText");this.config.enumValues=$.enum}build(_){return new u_(_,this.config)}}class u_ extends H{static[Y]="PgText";enumValues=this.config.enumValues;getSQLType(){return"text"}}function l_(_,$={}){let{name:X,config:Z}=z(_,$);return new t_(X,Z)}class i_ extends q{constructor(_,$,X){super(_,"string","PgTime");this.withTimezone=$,this.precision=X,this.config.withTimezone=$,this.config.precision=X}static[Y]="PgTimeBuilder";build(_){return new n_(_,this.config)}}class n_ extends H{static[Y]="PgTime";withTimezone;precision;constructor(_,$){super(_,$);this.withTimezone=$.withTimezone,this.precision=$.precision}getSQLType(){return`time${this.precision===void 0?"":`(${this.precision})`}${this.withTimezone?" with time zone":""}`}}function a_(_,$={}){let{name:X,config:Z}=z(_,$);return new i_(X,Z.withTimezone??!1,Z.precision)}class e_ extends q{static[Y]="PgTimestampBuilder";constructor(_,$,X){super(_,"date","PgTimestamp");this.config.withTimezone=$,this.config.precision=X}build(_){return new _0(_,this.config)}}class _0 extends H{static[Y]="PgTimestamp";withTimezone;precision;constructor(_,$){super(_,$);this.withTimezone=$.withTimezone,this.precision=$.precision}getSQLType(){return`timestamp${this.precision===void 0?"":` (${this.precision})`}${this.withTimezone?" with time zone":""}`}mapFromDriverValue=(_)=>{return new Date(this.withTimezone?_:_+"+0000")};mapToDriverValue=(_)=>{return _.toISOString()}}class $0 extends q{static[Y]="PgTimestampStringBuilder";constructor(_,$,X){super(_,"string","PgTimestampString");this.config.withTimezone=$,this.config.precision=X}build(_){return new X0(_,this.config)}}class X0 extends H{static[Y]="PgTimestampString";withTimezone;precision;constructor(_,$){super(_,$);this.withTimezone=$.withTimezone,this.precision=$.precision}getSQLType(){return`timestamp${this.precision===void 0?"":`(${this.precision})`}${this.withTimezone?" with time zone":""}`}}function Y0(_,$={}){let{name:X,config:Z}=z(_,$);if(Z?.mode==="string")return new $0(X,Z.withTimezone??!1,Z.precision);return new e_(X,Z?.withTimezone??!1,Z?.precision)}class Z0 extends G{static[Y]="PgUUIDBuilder";constructor(_){super(_,"string","PgUUID")}defaultRandom(){return this.default(k`gen_random_uuid()`)}build(_){return new H0(_,this.config)}}class H0 extends H{static[Y]="PgUUID";getSQLType(){return"uuid"}}function y(_){return new Z0(_??"")}class W0 extends G{static[Y]="PgVarcharBuilder";constructor(_,$){super(_,"string","PgVarchar");this.config.length=$.length,this.config.enumValues=$.enum}build(_){return new G0(_,this.config)}}class G0 extends H{static[Y]="PgVarchar";length=this.config.length;enumValues=this.config.enumValues;getSQLType(){return this.length===void 0?"varchar":`varchar(${this.length})`}}function T(_,$={}){let{name:X,config:Z}=z(_,$);return new W0(X,Z)}class J0 extends G{static[Y]="PgBinaryVectorBuilder";constructor(_,$){super(_,"string","PgBinaryVector");this.config.dimensions=$.dimensions}build(_){return new z0(_,this.config)}}class z0 extends H{static[Y]="PgBinaryVector";dimensions=this.config.dimensions;getSQLType(){return`bit(${this.dimensions})`}}function O0(_,$){let{name:X,config:Z}=z(_,$);return new J0(X,Z)}class F0 extends G{static[Y]="PgHalfVectorBuilder";constructor(_,$){super(_,"array","PgHalfVector");this.config.dimensions=$.dimensions}build(_){return new E0(_,this.config)}}class E0 extends H{static[Y]="PgHalfVector";dimensions=this.config.dimensions;getSQLType(){return`halfvec(${this.dimensions})`}mapToDriverValue(_){return JSON.stringify(_)}mapFromDriverValue(_){return _.slice(1,-1).split(",").map(($)=>Number.parseFloat($))}}function D0(_,$){let{name:X,config:Z}=z(_,$);return new F0(X,Z)}class Q0 extends G{static[Y]="PgSparseVectorBuilder";constructor(_,$){super(_,"string","PgSparseVector");this.config.dimensions=$.dimensions}build(_){return new V0(_,this.config)}}class V0 extends H{static[Y]="PgSparseVector";dimensions=this.config.dimensions;getSQLType(){return`sparsevec(${this.dimensions})`}}function w0(_,$){let{name:X,config:Z}=z(_,$);return new Q0(X,Z)}class x0 extends G{static[Y]="PgVectorBuilder";constructor(_,$){super(_,"array","PgVector");this.config.dimensions=$.dimensions}build(_){return new A0(_,this.config)}}class A0 extends H{static[Y]="PgVector";dimensions=this.config.dimensions;getSQLType(){return`vector(${this.dimensions})`}mapToDriverValue(_){return JSON.stringify(_)}mapFromDriverValue(_){return _.slice(1,-1).split(",").map(($)=>Number.parseFloat($))}}function R0(_,$){let{name:X,config:Z}=z(_,$);return new x0(X,Z)}function M0(){return{bigint:U2,bigserial:K2,boolean:S2,char:h2,cidr:B2,customType:b2,date:s2,doublePrecision:S,inet:u2,integer:L,interval:e2,json:X_,jsonb:H_,line:O_,macaddr:D_,macaddr8:w_,numeric:I_,point:k_,geometry:C_,real:p_,serial:d_,smallint:s_,smallserial:r_,text:l_,time:a_,timestamp:Y0,uuid:y,varchar:T,bit:O0,halfvec:D0,sparsevec:w0,vector:R0}}var i=Symbol.for("drizzle:PgInlineForeignKeys"),U0=Symbol.for("drizzle:EnableRLS");class p extends w{static[Y]="PgTable";static Symbol=Object.assign({},w.Symbol,{InlineForeignKeys:i,EnableRLS:U0});[i]=[];[U0]=!1;[w.Symbol.ExtraConfigBuilder]=void 0;[w.Symbol.ExtraConfigColumns]={}}function S0(_,$,X,Z,J=_){let O=new p(_,Z,J),Q=typeof $==="function"?$(M0()):$,A=Object.fromEntries(Object.entries(Q).map(([F,V])=>{let M=V;M.setName(F);let v=M.build(O);return O[i].push(...M.buildForeignKeys(v,O)),[F,v]})),E=Object.fromEntries(Object.entries(Q).map(([F,V])=>{let M=V;M.setName(F);let v=M.buildExtraConfigColumn(O);return[F,v]})),W=Object.assign(O,A);if(W[w.Symbol.Columns]=A,W[w.Symbol.ExtraConfigColumns]=E,X)W[p.Symbol.ExtraConfigBuilder]=X;return Object.assign(W,{enableRLS:()=>{return W[p.Symbol.EnableRLS]=!0,W}})}var q0=(_,$,X)=>{return S0(_,$,X,void 0)};var jX=q0("units",{id:y("id").defaultRandom().primaryKey(),unitNo:T("unit_no",{length:10}).notNull(),number:L("number"),project:T("project",{length:256}).notNull(),floor:L("floor").notNull(),unitType:T("unit_type",{length:256,enum:["Studio Squared","1 BR Squared","Studio Flex","2 BR Squared","One Bedroom2","Studio2","One Bedroom Loft","Two Bedroom Loft"]}),noOfBathrooms:L("no_of_bathrooms").notNull(),unitView:T("unit_view",{length:256,enum:["Canal / Amenities","Corner-Canal / Amenities","Corner-Canal View","Business Bay","Park Facing","Corner-Park Facing","Partial Park","BK/DT / Amenities","Corner-BK/DT / Amenities","Corner-Canal / BK/DT View","Marina View","Partial Marina View","Partial Marina, Partial City View","City view","Marina View, Sea View","Partial Marina View, Partial Sea View"]}),suitsArea:S("suits_area").notNull(),squareFt:S("square_ft").notNull(),noOfParkingSpace:L("no_of_parking_space").notNull(),salesPrice:L("sales_price").notNull(),state:T("state",{length:256,enum:["reserved","sold_spa","available","sold_registered"]}).notNull(),balconyArea:S("balcony_area").notNull()},(_)=>[a().on(_.project,_.unitNo)]);export{jX as unitsTable}; diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 89fff52..0000000 --- a/dist/index.js +++ /dev/null @@ -1,336 +0,0 @@ -// @bun -var ez=Object.create;var{getPrototypeOf:XQ,defineProperty:GY,getOwnPropertyNames:ZQ}=Object;var $Q=Object.prototype.hasOwnProperty;var YQ=(X,Z,$)=>{$=X!=null?ez(XQ(X)):{};let Y=Z||!X||!X.__esModule?GY($,"default",{value:X,enumerable:!0}):$;for(let W of ZQ(X))if(!$Q.call(Y,W))GY(Y,W,{get:()=>X[W],enumerable:!0});return Y};var WQ=(X,Z)=>()=>(Z||X((Z={exports:{}}).exports,Z),Z.exports);var EX=(X,Z)=>{for(var $ in Z)GY(X,$,{get:Z[$],enumerable:!0,configurable:!0,set:(Y)=>Z[$]=()=>Y})};var aW=WQ((rW)=>{Object.defineProperty(rW,"__esModule",{value:!0});rW.parse=oO;rW.serialize=nO;var hO=/^[\u0021-\u003A\u003C\u003E-\u007E]+$/,mO=/^[\u0021-\u003A\u003C-\u007E]*$/,pO=/^([.]?[a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?)([.][a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?)*$/i,cO=/^[\u0020-\u003A\u003D-\u007E]*$/,uO=Object.prototype.toString,iO=(()=>{let X=function(){};return X.prototype=Object.create(null),X})();function oO(X,Z){let $=new iO,Y=X.length;if(Y<2)return $;let W=Z?.decode||lO,J=0;do{let z=X.indexOf("=",J);if(z===-1)break;let Q=X.indexOf(";",J),M=Q===-1?Y:Q;if(z>M){J=X.lastIndexOf(";",z-1)+1;continue}let G=tW(X,J,z),U=sW(X,z,G),w=X.slice(G,U);if($[w]===void 0){let B=tW(X,z+1,M),N=sW(X,M,B),j=W(X.slice(B,N));$[w]=j}J=M+1}while(J$){let Y=X.charCodeAt(--Z);if(Y!==32&&Y!==9)return Z+1}return $}function nO(X,Z,$){let Y=$?.encode||encodeURIComponent;if(!hO.test(X))throw new TypeError(`argument name is invalid: ${X}`);let W=Y(Z);if(!mO.test(W))throw new TypeError(`argument val is invalid: ${Z}`);let J=X+"="+W;if(!$)return J;if($.maxAge!==void 0){if(!Number.isInteger($.maxAge))throw new TypeError(`option maxAge is invalid: ${$.maxAge}`);J+="; Max-Age="+$.maxAge}if($.domain){if(!pO.test($.domain))throw new TypeError(`option domain is invalid: ${$.domain}`);J+="; Domain="+$.domain}if($.path){if(!cO.test($.path))throw new TypeError(`option path is invalid: ${$.path}`);J+="; Path="+$.path}if($.expires){if(!tO($.expires)||!Number.isFinite($.expires.valueOf()))throw new TypeError(`option expires is invalid: ${$.expires}`);J+="; Expires="+$.expires.toUTCString()}if($.httpOnly)J+="; HttpOnly";if($.secure)J+="; Secure";if($.partitioned)J+="; Partitioned";if($.priority)switch(typeof $.priority==="string"?$.priority.toLowerCase():void 0){case"low":J+="; Priority=Low";break;case"medium":J+="; Priority=Medium";break;case"high":J+="; Priority=High";break;default:throw new TypeError(`option priority is invalid: ${$.priority}`)}if($.sameSite)switch(typeof $.sameSite==="string"?$.sameSite.toLowerCase():$.sameSite){case!0:case"strict":J+="; SameSite=Strict";break;case"lax":J+="; SameSite=Lax";break;case"none":J+="; SameSite=None";break;default:throw new TypeError(`option sameSite is invalid: ${$.sameSite}`)}return J}function lO(X){if(X.indexOf("%")===-1)return X;try{return decodeURIComponent(X)}catch(Z){return X}}function tO(X){return uO.call(X)==="[object Date]"}});var N1=(X,Z)=>{let $=Z?.length?{}:null;if($)for(let Y of Z)$[Y.part.charCodeAt(0)]=Y;return{part:X,store:null,inert:$,params:null,wildcardStore:null}},n6=(X,Z)=>({...X,part:Z}),l6=(X)=>({name:X,store:null,inert:null});class sX{config;root={};history=[];deferred=[];constructor(X={}){if(this.config=X,X.lazy)this.find=this.lazyFind}static regex={static:/:.+?(?=\/|$)/,params:/:.+?(?=\/|$)/g,optionalParams:/:.+?\?(?=\/|$)/g};lazyFind=(X,Z)=>{if(!this.config.lazy)return this.find;return this.build(),this.find(X,Z)};build(){if(!this.config.lazy)return;for(let[X,Z,$]of this.deferred)this.add(X,Z,$,{lazy:!1,ignoreHistory:!0});this.deferred=[],this.find=(X,Z)=>{let $=this.root[X];if(!$)return null;return vZ(Z,Z.length,$,0)}}add(X,Z,$,{ignoreError:Y=!1,ignoreHistory:W=!1,lazy:J=this.config.lazy}={}){if(J)return this.find=this.lazyFind,this.deferred.push([X,Z,$]),$;if(typeof Z!=="string")throw new TypeError("Route path must be a string");if(Z==="")Z="/";else if(Z[0]!=="/")Z=`/${Z}`;let z=Z[Z.length-1]==="*",Q=Z.match(sX.regex.optionalParams);if(Q){let B=Z.replaceAll("?","");this.add(X,B,$,{ignoreError:Y,ignoreHistory:W,lazy:J});for(let N=0;NB===X&&N===Z))return $;if(z||Q&&Z.charCodeAt(Z.length-1)===63)Z=Z.slice(0,-1);if(!W)this.history.push([X,Z,$]);let M=Z.split(sX.regex.static),G=Z.match(sX.regex.params)||[];if(M[M.length-1]==="")M.pop();let U;if(!this.root[X])U=this.root[X]=N1("/");else U=this.root[X];let w=0;for(let B=0;B0){let j=G[w++].slice(1);if(U.params===null)U.params=l6(j);else if(U.params.name!==j)if(Y)return $;else throw new Error(`Cannot create route "${Z}" with parameter "${j}" because a route already exists with a different parameter name ("${U.params.name}") in the same location`);let H=U.params;if(H.inert===null){U=H.inert=N1(N);continue}U=H.inert}for(let j=0;;){if(j===N.length){if(j{let W=$.part,J=W.length,z=Y+J;if(J>1){if(z>Z)return null;if(J<15){for(let Q=1,M=Y+1;Q=Z){if(Q!==null){let w={};return w[M]=X.substring(z,Z),{store:Q,params:w}}}else if(G!==null){let w=vZ(X,Z,G,U);if(w!==null)return w.params[M]=X.substring(z,U),w}}}if($.wildcardStore!==null)return{store:$.wildcardStore,params:{"*":X.substring(z,Z)}};return null};var K2={};EX(K2,{IsUndefined:()=>$2,IsUint8Array:()=>JX,IsSymbol:()=>AY,IsString:()=>b0,IsRegExp:()=>e1,IsObject:()=>P0,IsNumber:()=>r2,IsNull:()=>DY,IsIterator:()=>HY,IsFunction:()=>UY,IsDate:()=>rX,IsBoolean:()=>WX,IsBigInt:()=>a1,IsAsyncIterator:()=>MY,IsArray:()=>Z2,HasPropertyKey:()=>yZ});function yZ(X,Z){return Z in X}function MY(X){return P0(X)&&!Z2(X)&&!JX(X)&&Symbol.asyncIterator in X}function Z2(X){return Array.isArray(X)}function a1(X){return typeof X==="bigint"}function WX(X){return typeof X==="boolean"}function rX(X){return X instanceof globalThis.Date}function UY(X){return typeof X==="function"}function HY(X){return P0(X)&&!Z2(X)&&!JX(X)&&Symbol.iterator in X}function DY(X){return X===null}function r2(X){return typeof X==="number"}function P0(X){return typeof X==="object"&&X!==null}function e1(X){return X instanceof globalThis.RegExp}function b0(X){return typeof X==="string"}function AY(X){return typeof X==="symbol"}function JX(X){return X instanceof globalThis.Uint8Array}function $2(X){return X===void 0}function JQ(X){return X.map((Z)=>dZ(Z))}function zQ(X){return new Date(X.getTime())}function QQ(X){return new Uint8Array(X)}function GQ(X){return new RegExp(X.source,X.flags)}function MQ(X){let Z={};for(let $ of Object.getOwnPropertyNames(X))Z[$]=dZ(X[$]);for(let $ of Object.getOwnPropertySymbols(X))Z[$]=dZ(X[$]);return Z}function dZ(X){return Z2(X)?JQ(X):rX(X)?zQ(X):JX(X)?QQ(X):e1(X)?GQ(X):P0(X)?MQ(X):X}function p0(X){return dZ(X)}function L1(X,Z){return Z===void 0?p0(X):p0({...Z,...X})}function hZ(X){return J0(X)&&globalThis.Symbol.asyncIterator in X}function mZ(X){return J0(X)&&globalThis.Symbol.iterator in X}function wY(X){return J0(X)&&(globalThis.Object.getPrototypeOf(X)===Object.prototype||globalThis.Object.getPrototypeOf(X)===null)}function pZ(X){return X instanceof globalThis.Promise}function I2(X){return X instanceof Date&&globalThis.Number.isFinite(X.getTime())}function t6(X){return X instanceof globalThis.Map}function s6(X){return X instanceof globalThis.Set}function Q8(X){return globalThis.ArrayBuffer.isView(X)}function F1(X){return X instanceof globalThis.Uint8Array}function s(X,Z){return Z in X}function J0(X){return X!==null&&typeof X==="object"}function r(X){return globalThis.Array.isArray(X)&&!globalThis.ArrayBuffer.isView(X)}function c0(X){return X===void 0}function zX(X){return X===null}function s8(X){return typeof X==="boolean"}function o(X){return typeof X==="number"}function cZ(X){return globalThis.Number.isInteger(X)}function O2(X){return typeof X==="bigint"}function N0(X){return typeof X==="string"}function CX(X){return typeof X==="function"}function QX(X){return typeof X==="symbol"}function a2(X){return O2(X)||s8(X)||zX(X)||o(X)||N0(X)||QX(X)||c0(X)}var h0;(function(X){X.InstanceMode="default",X.ExactOptionalPropertyTypes=!1,X.AllowArrayObject=!1,X.AllowNaN=!1,X.AllowNullVoid=!1;function Z(z,Q){return X.ExactOptionalPropertyTypes?Q in z:z[Q]!==void 0}X.IsExactOptionalProperty=Z;function $(z){let Q=J0(z);return X.AllowArrayObject?Q:Q&&!r(z)}X.IsObjectLike=$;function Y(z){return $(z)&&!(z instanceof Date)&&!(z instanceof Uint8Array)}X.IsRecordLike=Y;function W(z){return X.AllowNaN?o(z):Number.isFinite(z)}X.IsNumberLike=W;function J(z){let Q=c0(z);return X.AllowNullVoid?Q||z===null:Q}X.IsVoidLike=J})(h0||(h0={}));function UQ(X){return globalThis.Object.freeze(X).map((Z)=>XZ(Z))}function HQ(X){return X}function DQ(X){return X}function AQ(X){return X}function wQ(X){let Z={};for(let $ of Object.getOwnPropertyNames(X))Z[$]=XZ(X[$]);for(let $ of Object.getOwnPropertySymbols(X))Z[$]=XZ(X[$]);return globalThis.Object.freeze(Z)}function XZ(X){return Z2(X)?UQ(X):rX(X)?HQ(X):JX(X)?DQ(X):e1(X)?AQ(X):P0(X)?wQ(X):X}function S(X,Z){let $=Z!==void 0?{...Z,...X}:X;switch(h0.InstanceMode){case"freeze":return XZ($);case"clone":return p0($);default:return $}}class t extends Error{constructor(X){super(X)}}var k0=Symbol.for("TypeBox.Transform"),E8=Symbol.for("TypeBox.Readonly"),N2=Symbol.for("TypeBox.Optional"),G8=Symbol.for("TypeBox.Hint"),q=Symbol.for("TypeBox.Kind");function B1(X){return P0(X)&&X[E8]==="Readonly"}function f2(X){return P0(X)&&X[N2]==="Optional"}function _Y(X){return w0(X,"Any")}function OY(X){return w0(X,"Argument")}function C8(X){return w0(X,"Array")}function aX(X){return w0(X,"AsyncIterator")}function eX(X){return w0(X,"BigInt")}function GX(X){return w0(X,"Boolean")}function P8(X){return w0(X,"Computed")}function I8(X){return w0(X,"Constructor")}function _Q(X){return w0(X,"Date")}function x8(X){return w0(X,"Function")}function T8(X){return w0(X,"Integer")}function l0(X){return w0(X,"Intersect")}function X1(X){return w0(X,"Iterator")}function w0(X,Z){return P0(X)&&q in X&&X[q]===Z}function uZ(X){return WX(X)||r2(X)||b0(X)}function e2(X){return w0(X,"Literal")}function X8(X){return w0(X,"MappedKey")}function u0(X){return w0(X,"MappedResult")}function PX(X){return w0(X,"Never")}function OQ(X){return w0(X,"Not")}function ZZ(X){return w0(X,"Null")}function b8(X){return w0(X,"Number")}function Y2(X){return w0(X,"Object")}function Z1(X){return w0(X,"Promise")}function $1(X){return w0(X,"Record")}function e0(X){return w0(X,"Ref")}function NY(X){return w0(X,"RegExp")}function MX(X){return w0(X,"String")}function $Z(X){return w0(X,"Symbol")}function Z8(X){return w0(X,"TemplateLiteral")}function NQ(X){return w0(X,"This")}function R0(X){return P0(X)&&k0 in X}function $8(X){return w0(X,"Tuple")}function UX(X){return w0(X,"Undefined")}function L0(X){return w0(X,"Union")}function LQ(X){return w0(X,"Uint8Array")}function FQ(X){return w0(X,"Unknown")}function BQ(X){return w0(X,"Unsafe")}function qQ(X){return w0(X,"Void")}function IX(X){return P0(X)&&q in X&&b0(X[q])}function o0(X){return _Y(X)||OY(X)||C8(X)||GX(X)||eX(X)||aX(X)||P8(X)||I8(X)||_Q(X)||x8(X)||T8(X)||l0(X)||X1(X)||e2(X)||X8(X)||u0(X)||PX(X)||OQ(X)||ZZ(X)||b8(X)||Y2(X)||Z1(X)||$1(X)||e0(X)||NY(X)||MX(X)||$Z(X)||Z8(X)||NQ(X)||$8(X)||UX(X)||L0(X)||LQ(X)||FQ(X)||BQ(X)||qQ(X)||IX(X)}var L={};EX(L,{TypeGuardUnknownTypeError:()=>r6,IsVoid:()=>y9,IsUnsafe:()=>v9,IsUnknown:()=>f9,IsUnionLiteral:()=>IQ,IsUnion:()=>BY,IsUndefined:()=>k9,IsUint8Array:()=>g9,IsTuple:()=>b9,IsTransform:()=>T9,IsThis:()=>x9,IsTemplateLiteral:()=>I9,IsSymbol:()=>P9,IsString:()=>C9,IsSchema:()=>i0,IsRegExp:()=>E9,IsRef:()=>V9,IsRecursive:()=>PQ,IsRecord:()=>S9,IsReadonly:()=>SQ,IsProperties:()=>iZ,IsPromise:()=>j9,IsOptional:()=>VQ,IsObject:()=>R9,IsNumber:()=>K9,IsNull:()=>q9,IsNot:()=>B9,IsNever:()=>F9,IsMappedResult:()=>L9,IsMappedKey:()=>N9,IsLiteralValue:()=>O9,IsLiteralString:()=>w9,IsLiteralNumber:()=>_9,IsLiteralBoolean:()=>CQ,IsLiteral:()=>WZ,IsKindOf:()=>M0,IsKind:()=>d9,IsIterator:()=>A9,IsIntersect:()=>D9,IsInteger:()=>H9,IsImport:()=>EQ,IsFunction:()=>U9,IsDate:()=>M9,IsConstructor:()=>G9,IsComputed:()=>Q9,IsBoolean:()=>z9,IsBigInt:()=>J9,IsAsyncIterator:()=>W9,IsArray:()=>Y9,IsArgument:()=>$9,IsAny:()=>Z9});class r6 extends t{}var KQ=["Argument","Any","Array","AsyncIterator","BigInt","Boolean","Computed","Constructor","Date","Enum","Function","Integer","Intersect","Iterator","Literal","MappedKey","MappedResult","Not","Null","Number","Object","Promise","Record","Ref","RegExp","String","Symbol","TemplateLiteral","This","Tuple","Undefined","Union","Uint8Array","Unknown","Void"];function a6(X){try{return new RegExp(X),!0}catch{return!1}}function LY(X){if(!b0(X))return!1;for(let Z=0;Z=7&&$<=13||$===27||$===127)return!1}return!0}function e6(X){return FY(X)||i0(X)}function YZ(X){return $2(X)||a1(X)}function g0(X){return $2(X)||r2(X)}function FY(X){return $2(X)||WX(X)}function I0(X){return $2(X)||b0(X)}function RQ(X){return $2(X)||b0(X)&&LY(X)&&a6(X)}function jQ(X){return $2(X)||b0(X)&&LY(X)}function X9(X){return $2(X)||i0(X)}function SQ(X){return P0(X)&&X[E8]==="Readonly"}function VQ(X){return P0(X)&&X[N2]==="Optional"}function Z9(X){return M0(X,"Any")&&I0(X.$id)}function $9(X){return M0(X,"Argument")&&r2(X.index)}function Y9(X){return M0(X,"Array")&&X.type==="array"&&I0(X.$id)&&i0(X.items)&&g0(X.minItems)&&g0(X.maxItems)&&FY(X.uniqueItems)&&X9(X.contains)&&g0(X.minContains)&&g0(X.maxContains)}function W9(X){return M0(X,"AsyncIterator")&&X.type==="AsyncIterator"&&I0(X.$id)&&i0(X.items)}function J9(X){return M0(X,"BigInt")&&X.type==="bigint"&&I0(X.$id)&&YZ(X.exclusiveMaximum)&&YZ(X.exclusiveMinimum)&&YZ(X.maximum)&&YZ(X.minimum)&&YZ(X.multipleOf)}function z9(X){return M0(X,"Boolean")&&X.type==="boolean"&&I0(X.$id)}function Q9(X){return M0(X,"Computed")&&b0(X.target)&&Z2(X.parameters)&&X.parameters.every((Z)=>i0(Z))}function G9(X){return M0(X,"Constructor")&&X.type==="Constructor"&&I0(X.$id)&&Z2(X.parameters)&&X.parameters.every((Z)=>i0(Z))&&i0(X.returns)}function M9(X){return M0(X,"Date")&&X.type==="Date"&&I0(X.$id)&&g0(X.exclusiveMaximumTimestamp)&&g0(X.exclusiveMinimumTimestamp)&&g0(X.maximumTimestamp)&&g0(X.minimumTimestamp)&&g0(X.multipleOfTimestamp)}function U9(X){return M0(X,"Function")&&X.type==="Function"&&I0(X.$id)&&Z2(X.parameters)&&X.parameters.every((Z)=>i0(Z))&&i0(X.returns)}function EQ(X){return M0(X,"Import")&&yZ(X,"$defs")&&P0(X.$defs)&&iZ(X.$defs)&&yZ(X,"$ref")&&b0(X.$ref)&&X.$ref in X.$defs}function H9(X){return M0(X,"Integer")&&X.type==="integer"&&I0(X.$id)&&g0(X.exclusiveMaximum)&&g0(X.exclusiveMinimum)&&g0(X.maximum)&&g0(X.minimum)&&g0(X.multipleOf)}function iZ(X){return P0(X)&&Object.entries(X).every(([Z,$])=>LY(Z)&&i0($))}function D9(X){return M0(X,"Intersect")&&(b0(X.type)&&X.type!=="object"?!1:!0)&&Z2(X.allOf)&&X.allOf.every((Z)=>i0(Z)&&!T9(Z))&&I0(X.type)&&(FY(X.unevaluatedProperties)||X9(X.unevaluatedProperties))&&I0(X.$id)}function A9(X){return M0(X,"Iterator")&&X.type==="Iterator"&&I0(X.$id)&&i0(X.items)}function M0(X,Z){return P0(X)&&q in X&&X[q]===Z}function w9(X){return WZ(X)&&b0(X.const)}function _9(X){return WZ(X)&&r2(X.const)}function CQ(X){return WZ(X)&&WX(X.const)}function WZ(X){return M0(X,"Literal")&&I0(X.$id)&&O9(X.const)}function O9(X){return WX(X)||r2(X)||b0(X)}function N9(X){return M0(X,"MappedKey")&&Z2(X.keys)&&X.keys.every((Z)=>r2(Z)||b0(Z))}function L9(X){return M0(X,"MappedResult")&&iZ(X.properties)}function F9(X){return M0(X,"Never")&&P0(X.not)&&Object.getOwnPropertyNames(X.not).length===0}function B9(X){return M0(X,"Not")&&i0(X.not)}function q9(X){return M0(X,"Null")&&X.type==="null"&&I0(X.$id)}function K9(X){return M0(X,"Number")&&X.type==="number"&&I0(X.$id)&&g0(X.exclusiveMaximum)&&g0(X.exclusiveMinimum)&&g0(X.maximum)&&g0(X.minimum)&&g0(X.multipleOf)}function R9(X){return M0(X,"Object")&&X.type==="object"&&I0(X.$id)&&iZ(X.properties)&&e6(X.additionalProperties)&&g0(X.minProperties)&&g0(X.maxProperties)}function j9(X){return M0(X,"Promise")&&X.type==="Promise"&&I0(X.$id)&&i0(X.item)}function S9(X){return M0(X,"Record")&&X.type==="object"&&I0(X.$id)&&e6(X.additionalProperties)&&P0(X.patternProperties)&&((Z)=>{let $=Object.getOwnPropertyNames(Z.patternProperties);return $.length===1&&a6($[0])&&P0(Z.patternProperties)&&i0(Z.patternProperties[$[0]])})(X)}function PQ(X){return P0(X)&&G8 in X&&X[G8]==="Recursive"}function V9(X){return M0(X,"Ref")&&I0(X.$id)&&b0(X.$ref)}function E9(X){return M0(X,"RegExp")&&I0(X.$id)&&b0(X.source)&&b0(X.flags)&&g0(X.maxLength)&&g0(X.minLength)}function C9(X){return M0(X,"String")&&X.type==="string"&&I0(X.$id)&&g0(X.minLength)&&g0(X.maxLength)&&RQ(X.pattern)&&jQ(X.format)}function P9(X){return M0(X,"Symbol")&&X.type==="symbol"&&I0(X.$id)}function I9(X){return M0(X,"TemplateLiteral")&&X.type==="string"&&b0(X.pattern)&&X.pattern[0]==="^"&&X.pattern[X.pattern.length-1]==="$"}function x9(X){return M0(X,"This")&&I0(X.$id)&&b0(X.$ref)}function T9(X){return P0(X)&&k0 in X}function b9(X){return M0(X,"Tuple")&&X.type==="array"&&I0(X.$id)&&r2(X.minItems)&&r2(X.maxItems)&&X.minItems===X.maxItems&&($2(X.items)&&$2(X.additionalItems)&&X.minItems===0||Z2(X.items)&&X.items.every((Z)=>i0(Z)))}function k9(X){return M0(X,"Undefined")&&X.type==="undefined"&&I0(X.$id)}function IQ(X){return BY(X)&&X.anyOf.every((Z)=>w9(Z)||_9(Z))}function BY(X){return M0(X,"Union")&&I0(X.$id)&&P0(X)&&Z2(X.anyOf)&&X.anyOf.every((Z)=>i0(Z))}function g9(X){return M0(X,"Uint8Array")&&X.type==="Uint8Array"&&I0(X.$id)&&g0(X.minByteLength)&&g0(X.maxByteLength)}function f9(X){return M0(X,"Unknown")&&I0(X.$id)}function v9(X){return M0(X,"Unsafe")}function y9(X){return M0(X,"Void")&&X.type==="void"&&I0(X.$id)}function d9(X){return P0(X)&&q in X&&b0(X[q])&&!KQ.includes(X[q])}function i0(X){return P0(X)&&(Z9(X)||$9(X)||Y9(X)||z9(X)||J9(X)||W9(X)||Q9(X)||G9(X)||M9(X)||U9(X)||H9(X)||D9(X)||A9(X)||WZ(X)||N9(X)||L9(X)||F9(X)||B9(X)||q9(X)||K9(X)||R9(X)||j9(X)||S9(X)||V9(X)||E9(X)||C9(X)||P9(X)||I9(X)||x9(X)||b9(X)||k9(X)||BY(X)||g9(X)||f9(X)||v9(X)||y9(X)||d9(X))}var h9="(true|false)",oZ="(0|[1-9][0-9]*)",m9="(.*)";var r8="^(0|[1-9][0-9]*)$",a8="^(.*)$",p9="^(?!.*)$";var C0={};EX(C0,{Set:()=>gQ,Has:()=>kQ,Get:()=>fQ,Entries:()=>xQ,Delete:()=>bQ,Clear:()=>TQ});var q1=new Map;function xQ(){return new Map(q1)}function TQ(){return q1.clear()}function bQ(X){return q1.delete(X)}function kQ(X){return q1.has(X)}function gQ(X,Z){q1.set(X,Z)}function fQ(X){return q1.get(X)}var t0={};EX(t0,{Set:()=>mQ,Has:()=>hQ,Get:()=>pQ,Entries:()=>vQ,Delete:()=>dQ,Clear:()=>yQ});var K1=new Map;function vQ(){return new Map(K1)}function yQ(){return K1.clear()}function dQ(X){return K1.delete(X)}function hQ(X){return K1.has(X)}function mQ(X,Z){K1.set(X,Z)}function pQ(X){return K1.get(X)}function c9(X,Z){return X.includes(Z)}function u9(X){return[...new Set(X)]}function cQ(X,Z){return X.filter(($)=>Z.includes($))}function uQ(X,Z){return X.reduce(($,Y)=>{return cQ($,Y)},Z)}function i9(X){return X.length===1?X[0]:X.length>1?uQ(X.slice(1),X[0]):[]}function o9(X){let Z=[];for(let $ of X)Z.push(...$);return Z}function xX(X){return S({[q]:"Any"},X)}function R1(X,Z){return S({[q]:"Array",type:"array",items:X},Z)}function n9(X){return S({[q]:"Argument",index:X})}function j1(X,Z){return S({[q]:"AsyncIterator",type:"AsyncIterator",items:X},Z)}function m0(X,Z,$){return S({[q]:"Computed",target:X,parameters:Z},$)}function iQ(X,Z){let{[Z]:$,...Y}=X;return Y}function s0(X,Z){return Z.reduce(($,Y)=>iQ($,Y),X)}function Y0(X){return S({[q]:"Never",not:{}},X)}function F0(X){return S({[q]:"MappedResult",properties:X})}function S1(X,Z,$){return S({[q]:"Constructor",type:"Constructor",parameters:X,returns:Z},$)}function e8(X,Z,$){return S({[q]:"Function",type:"Function",parameters:X,returns:Z},$)}function JZ(X,Z){return S({[q]:"Union",anyOf:X},Z)}function oQ(X){return X.some((Z)=>f2(Z))}function l9(X){return X.map((Z)=>f2(Z)?nQ(Z):Z)}function nQ(X){return s0(X,[N2])}function lQ(X,Z){return oQ(X)?R2(JZ(l9(X),Z)):JZ(l9(X),Z)}function XX(X,Z){return X.length===1?S(X[0],Z):X.length===0?Y0(Z):lQ(X,Z)}function j0(X,Z){return X.length===0?Y0(Z):X.length===1?S(X[0],Z):JZ(X,Z)}class qY extends t{}function tQ(X){return X.replace(/\\\$/g,"$").replace(/\\\*/g,"*").replace(/\\\^/g,"^").replace(/\\\|/g,"|").replace(/\\\(/g,"(").replace(/\\\)/g,")")}function KY(X,Z,$){return X[Z]===$&&X.charCodeAt(Z-1)!==92}function DX(X,Z){return KY(X,Z,"(")}function zZ(X,Z){return KY(X,Z,")")}function t9(X,Z){return KY(X,Z,"|")}function sQ(X){if(!(DX(X,0)&&zZ(X,X.length-1)))return!1;let Z=0;for(let $=0;$0)Y.push(V1(z));$=J+1}}let W=X.slice($);if(W.length>0)Y.push(V1(W));if(Y.length===0)return{type:"const",const:""};if(Y.length===1)return Y[0];return{type:"or",expr:Y}}function ZG(X){function Z(W,J){if(!DX(W,J))throw new qY("TemplateLiteralParser: Index must point to open parens");let z=0;for(let Q=J;Q0)Y.push(V1(Q));W=z-1}return Y.length===0?{type:"const",const:""}:Y.length===1?Y[0]:{type:"and",expr:Y}}function V1(X){return sQ(X)?V1(rQ(X)):aQ(X)?XG(X):eQ(X)?ZG(X):{type:"const",const:tQ(X)}}function E1(X){return V1(X.slice(1,X.length-1))}class s9 extends t{}function $G(X){return X.type==="or"&&X.expr.length===2&&X.expr[0].type==="const"&&X.expr[0].const==="0"&&X.expr[1].type==="const"&&X.expr[1].const==="[1-9][0-9]*"}function YG(X){return X.type==="or"&&X.expr.length===2&&X.expr[0].type==="const"&&X.expr[0].const==="true"&&X.expr[1].type==="const"&&X.expr[1].const==="false"}function WG(X){return X.type==="const"&&X.const===".*"}function Y1(X){return $G(X)||WG(X)?!1:YG(X)?!0:X.type==="and"?X.expr.every((Z)=>Y1(Z)):X.type==="or"?X.expr.every((Z)=>Y1(Z)):X.type==="const"?!0:(()=>{throw new s9("Unknown expression type")})()}function nZ(X){let Z=E1(X.pattern);return Y1(Z)}class r9 extends t{}function*a9(X){if(X.length===1)return yield*X[0];for(let Z of X[0])for(let $ of a9(X.slice(1)))yield`${Z}${$}`}function*JG(X){return yield*a9(X.expr.map((Z)=>[...QZ(Z)]))}function*zG(X){for(let Z of X.expr)yield*QZ(Z)}function*QG(X){return yield X.const}function*QZ(X){return X.type==="and"?yield*JG(X):X.type==="or"?yield*zG(X):X.type==="const"?yield*QG(X):(()=>{throw new r9("Unknown expression")})()}function C1(X){let Z=E1(X.pattern);return Y1(Z)?[...QZ(Z)]:[]}function _0(X,Z){return S({[q]:"Literal",const:X,type:typeof X},Z)}function lZ(X){return S({[q]:"Boolean",type:"boolean"},X)}function P1(X){return S({[q]:"BigInt",type:"bigint"},X)}function M8(X){return S({[q]:"Number",type:"number"},X)}function x2(X){return S({[q]:"String",type:"string"},X)}function*GG(X){let Z=X.trim().replace(/"|'/g,"");return Z==="boolean"?yield lZ():Z==="number"?yield M8():Z==="bigint"?yield P1():Z==="string"?yield x2():yield(()=>{let $=Z.split("|").map((Y)=>_0(Y.trim()));return $.length===0?Y0():$.length===1?$[0]:XX($)})()}function*MG(X){if(X[1]!=="{"){let Z=_0("$"),$=RY(X.slice(1));return yield*[Z,...$]}for(let Z=2;ZZ7($,Z)).join("|")})`:b8(X)?`${Z}${oZ}`:T8(X)?`${Z}${oZ}`:eX(X)?`${Z}${oZ}`:MX(X)?`${Z}${m9}`:e2(X)?`${Z}${UG(X.const.toString())}`:GX(X)?`${Z}${h9}`:(()=>{throw new X7(`Unexpected Kind '${X[q]}'`)})()}function jY(X){return`^${X.map((Z)=>Z7(Z,"")).join("")}$`}function W1(X){let $=C1(X).map((Y)=>_0(Y));return XX($)}function tZ(X,Z){let $=b0(X)?jY(e9(X)):jY(X);return S({[q]:"TemplateLiteral",type:"string",pattern:$},Z)}function HG(X){return C1(X).map(($)=>$.toString())}function DG(X){let Z=[];for(let $ of X)Z.push(...v2($));return Z}function AG(X){return[X.toString()]}function v2(X){return[...new Set(Z8(X)?HG(X):L0(X)?DG(X.anyOf):e2(X)?AG(X.const):b8(X)?["[number]"]:T8(X)?["[number]"]:[])]}function wG(X,Z,$){let Y={};for(let W of Object.getOwnPropertyNames(Z))Y[W]=TX(X,v2(Z[W]),$);return Y}function _G(X,Z,$){return wG(X,Z.properties,$)}function $7(X,Z,$){let Y=_G(X,Z,$);return F0(Y)}function W7(X,Z){return X.map(($)=>J7($,Z))}function OG(X){return X.filter((Z)=>!PX(Z))}function NG(X,Z){return sZ(OG(W7(X,Z)))}function LG(X){return X.some((Z)=>PX(Z))?[]:X}function FG(X,Z){return XX(LG(W7(X,Z)))}function BG(X,Z){return Z in X?X[Z]:Z==="[number]"?XX(X):Y0()}function qG(X,Z){return Z==="[number]"?X:Y0()}function KG(X,Z){return Z in X?X[Z]:Y0()}function J7(X,Z){return l0(X)?NG(X.allOf,Z):L0(X)?FG(X.anyOf,Z):$8(X)?BG(X.items??[],Z):C8(X)?qG(X.items,Z):Y2(X)?KG(X.properties,Z):Y0()}function GZ(X,Z){return Z.map(($)=>J7(X,$))}function Y7(X,Z){return XX(GZ(X,Z))}function TX(X,Z,$){if(e0(X)||e0(Z)){if(!o0(X)||!o0(Z))throw new t("Index types using Ref parameters require both Type and Key to be of TSchema");return m0("Index",[X,Z])}if(u0(Z))return $7(X,Z,$);if(X8(Z))return z7(X,Z,$);return S(o0(Z)?Y7(X,v2(Z)):Y7(X,Z),$)}function RG(X,Z,$){return{[Z]:TX(X,[Z],p0($))}}function jG(X,Z,$){return Z.reduce((Y,W)=>{return{...Y,...RG(X,W,$)}},{})}function SG(X,Z,$){return jG(X,Z.keys,$)}function z7(X,Z,$){let Y=SG(X,Z,$);return F0(Y)}function I1(X,Z){return S({[q]:"Iterator",type:"Iterator",items:X},Z)}function VG(X){let Z=[];for(let $ in X)if(!f2(X[$]))Z.push($);return Z}function EG(X,Z){let $=VG(X),Y=$.length>0?{[q]:"Object",type:"object",properties:X,required:$}:{[q]:"Object",type:"object",properties:X};return S(Y,Z)}var S0=EG;function rZ(X,Z){return S({[q]:"Promise",type:"Promise",item:X},Z)}function CG(X){return S(s0(X,[E8]))}function PG(X){return S({...X,[E8]:"Readonly"})}function IG(X,Z){return Z===!1?CG(X):PG(X)}function y2(X,Z){let $=Z??!0;return u0(X)?Q7(X,$):IG(X,$)}function xG(X,Z){let $={};for(let Y of globalThis.Object.getOwnPropertyNames(X))$[Y]=y2(X[Y],Z);return $}function TG(X,Z){return xG(X.properties,Z)}function Q7(X,Z){let $=TG(X,Z);return F0($)}function U8(X,Z){return S(X.length>0?{[q]:"Tuple",type:"array",items:X,additionalItems:!1,minItems:X.length,maxItems:X.length}:{[q]:"Tuple",type:"array",minItems:X.length,maxItems:X.length},Z)}function G7(X,Z){return X in Z?H8(X,Z[X]):F0(Z)}function bG(X){return{[X]:_0(X)}}function kG(X){let Z={};for(let $ of X)Z[$]=_0($);return Z}function gG(X,Z){return c9(Z,X)?bG(X):kG(Z)}function fG(X,Z){let $=gG(X,Z);return G7(X,$)}function MZ(X,Z){return Z.map(($)=>H8(X,$))}function vG(X,Z){let $={};for(let Y of globalThis.Object.getOwnPropertyNames(Z))$[Y]=H8(X,Z[Y]);return $}function H8(X,Z){let $={...Z};return f2(Z)?R2(H8(X,s0(Z,[N2]))):B1(Z)?y2(H8(X,s0(Z,[E8]))):u0(Z)?G7(X,Z.properties):X8(Z)?fG(X,Z.keys):I8(Z)?S1(MZ(X,Z.parameters),H8(X,Z.returns),$):x8(Z)?e8(MZ(X,Z.parameters),H8(X,Z.returns),$):aX(Z)?j1(H8(X,Z.items),$):X1(Z)?I1(H8(X,Z.items),$):l0(Z)?j2(MZ(X,Z.allOf),$):L0(Z)?j0(MZ(X,Z.anyOf),$):$8(Z)?U8(MZ(X,Z.items??[]),$):Y2(Z)?S0(vG(X,Z.properties),$):C8(Z)?R1(H8(X,Z.items),$):Z1(Z)?rZ(H8(X,Z.item),$):Z}function yG(X,Z){let $={};for(let Y of X)$[Y]=H8(Y,Z);return $}function M7(X,Z,$){let Y=o0(X)?v2(X):X,W=Z({[q]:"MappedKey",keys:Y}),J=yG(Y,W);return S0(J,$)}function dG(X){return S(s0(X,[N2]))}function hG(X){return S({...X,[N2]:"Optional"})}function mG(X,Z){return Z===!1?dG(X):hG(X)}function R2(X,Z){let $=Z??!0;return u0(X)?U7(X,$):mG(X,$)}function pG(X,Z){let $={};for(let Y of globalThis.Object.getOwnPropertyNames(X))$[Y]=R2(X[Y],Z);return $}function cG(X,Z){return pG(X.properties,Z)}function U7(X,Z){let $=cG(X,Z);return F0($)}function UZ(X,Z={}){let $=X.every((W)=>Y2(W)),Y=o0(Z.unevaluatedProperties)?{unevaluatedProperties:Z.unevaluatedProperties}:{};return S(Z.unevaluatedProperties===!1||o0(Z.unevaluatedProperties)||$?{...Y,[q]:"Intersect",type:"object",allOf:X}:{...Y,[q]:"Intersect",allOf:X},Z)}function uG(X){return X.every((Z)=>f2(Z))}function iG(X){return s0(X,[N2])}function H7(X){return X.map((Z)=>f2(Z)?iG(Z):Z)}function oG(X,Z){return uG(X)?R2(UZ(H7(X),Z)):UZ(H7(X),Z)}function sZ(X,Z={}){if(X.length===1)return S(X[0],Z);if(X.length===0)return Y0(Z);if(X.some(($)=>R0($)))throw new Error("Cannot intersect transform types");return oG(X,Z)}function j2(X,Z){if(X.length===1)return S(X[0],Z);if(X.length===0)return Y0(Z);if(X.some(($)=>R0($)))throw new Error("Cannot intersect transform types");return UZ(X,Z)}function D8(...X){let[Z,$]=typeof X[0]==="string"?[X[0],X[1]]:[X[0].$id,X[1]];if(typeof Z!=="string")throw new t("Ref: $ref must be a string");return S({[q]:"Ref",$ref:Z},$)}function nG(X,Z){return m0("Awaited",[m0(X,Z)])}function lG(X){return m0("Awaited",[D8(X)])}function tG(X){return j2(D7(X))}function sG(X){return j0(D7(X))}function rG(X){return x1(X)}function D7(X){return X.map((Z)=>x1(Z))}function x1(X,Z){return S(P8(X)?nG(X.target,X.parameters):l0(X)?tG(X.allOf):L0(X)?sG(X.anyOf):Z1(X)?rG(X.item):e0(X)?lG(X.$ref):X,Z)}function A7(X){let Z=[];for(let $ of X)Z.push(d2($));return Z}function aG(X){let Z=A7(X);return o9(Z)}function eG(X){let Z=A7(X);return i9(Z)}function XM(X){return X.map((Z,$)=>$.toString())}function ZM(X){return["[number]"]}function $M(X){return globalThis.Object.getOwnPropertyNames(X)}function YM(X){if(!SY)return[];return globalThis.Object.getOwnPropertyNames(X).map(($)=>{return $[0]==="^"&&$[$.length-1]==="$"?$.slice(1,$.length-1):$})}function d2(X){return l0(X)?aG(X.allOf):L0(X)?eG(X.anyOf):$8(X)?XM(X.items??[]):C8(X)?ZM(X.items):Y2(X)?$M(X.properties):$1(X)?YM(X.patternProperties):[]}var SY=!1;function AX(X){SY=!0;let Z=d2(X);return SY=!1,`^(${Z.map((Y)=>`(${Y})`).join("|")})$`}function WM(X,Z){return m0("KeyOf",[m0(X,Z)])}function JM(X){return m0("KeyOf",[D8(X)])}function zM(X,Z){let $=d2(X),Y=QM($),W=XX(Y);return S(W,Z)}function QM(X){return X.map((Z)=>Z==="[number]"?M8():_0(Z))}function T1(X,Z){return P8(X)?WM(X.target,X.parameters):e0(X)?JM(X.$ref):u0(X)?w7(X,Z):zM(X,Z)}function GM(X,Z){let $={};for(let Y of globalThis.Object.getOwnPropertyNames(X))$[Y]=T1(X[Y],p0(Z));return $}function MM(X,Z){return GM(X.properties,Z)}function w7(X,Z){let $=MM(X,Z);return F0($)}function aZ(X){let Z=d2(X),$=GZ(X,Z);return Z.map((Y,W)=>[Z[W],$[W]])}function UM(X){let Z=[];for(let $ of X)Z.push(...d2($));return u9(Z)}function HM(X){return X.filter((Z)=>!PX(Z))}function DM(X,Z){let $=[];for(let Y of X)$.push(...GZ(Y,[Z]));return HM($)}function AM(X,Z){let $={};for(let Y of Z)$[Y]=sZ(DM(X,Y));return $}function _7(X,Z){let $=UM(X),Y=AM(X,$);return S0(Y,Z)}function eZ(X){return S({[q]:"Date",type:"Date"},X)}function X$(X){return S({[q]:"Null",type:"null"},X)}function Z$(X){return S({[q]:"Symbol",type:"symbol"},X)}function $$(X){return S({[q]:"Undefined",type:"undefined"},X)}function Y$(X){return S({[q]:"Uint8Array",type:"Uint8Array"},X)}function k8(X){return S({[q]:"Unknown"},X)}function wM(X){return X.map((Z)=>VY(Z,!1))}function _M(X){let Z={};for(let $ of globalThis.Object.getOwnPropertyNames(X))Z[$]=y2(VY(X[$],!1));return Z}function W$(X,Z){return Z===!0?X:y2(X)}function VY(X,Z){return MY(X)?W$(xX(),Z):HY(X)?W$(xX(),Z):Z2(X)?y2(U8(wM(X))):JX(X)?Y$():rX(X)?eZ():P0(X)?W$(S0(_M(X)),Z):UY(X)?W$(e8([],k8()),Z):$2(X)?$$():DY(X)?X$():AY(X)?Z$():a1(X)?P1():r2(X)?_0(X):WX(X)?_0(X):b0(X)?_0(X):S0({})}function O7(X,Z){return S(VY(X,!0),Z)}function N7(X,Z){return I8(X)?U8(X.parameters,Z):Y0(Z)}function L7(X,Z){if($2(X))throw new Error("Enum undefined or empty");let $=globalThis.Object.getOwnPropertyNames(X).filter((J)=>isNaN(J)).map((J)=>X[J]),W=[...new Set($)].map((J)=>_0(J));return j0(W,{...Z,[G8]:"Enum"})}class R7 extends t{}var V;(function(X){X[X.Union=0]="Union",X[X.True=1]="True",X[X.False=2]="False"})(V||(V={}));function A8(X){return X===V.False?X:V.True}function b1(X){throw new R7(X)}function J2(X){return L.IsNever(X)||L.IsIntersect(X)||L.IsUnion(X)||L.IsUnknown(X)||L.IsAny(X)}function z2(X,Z){return L.IsNever(Z)?V7(X,Z):L.IsIntersect(Z)?J$(X,Z):L.IsUnion(Z)?xY(X,Z):L.IsUnknown(Z)?I7(X,Z):L.IsAny(Z)?IY(X,Z):b1("StructuralRight")}function IY(X,Z){return V.True}function OM(X,Z){return L.IsIntersect(Z)?J$(X,Z):L.IsUnion(Z)&&Z.anyOf.some(($)=>L.IsAny($)||L.IsUnknown($))?V.True:L.IsUnion(Z)?V.Union:L.IsUnknown(Z)?V.True:L.IsAny(Z)?V.True:V.Union}function NM(X,Z){return L.IsUnknown(X)?V.False:L.IsAny(X)?V.Union:L.IsNever(X)?V.True:V.False}function LM(X,Z){return L.IsObject(Z)&&z$(Z)?V.True:J2(Z)?z2(X,Z):!L.IsArray(Z)?V.False:A8(x0(X.items,Z.items))}function FM(X,Z){return J2(Z)?z2(X,Z):!L.IsAsyncIterator(Z)?V.False:A8(x0(X.items,Z.items))}function BM(X,Z){return J2(Z)?z2(X,Z):L.IsObject(Z)?S2(X,Z):L.IsRecord(Z)?w8(X,Z):L.IsBigInt(Z)?V.True:V.False}function j7(X,Z){return L.IsLiteralBoolean(X)?V.True:L.IsBoolean(X)?V.True:V.False}function qM(X,Z){return J2(Z)?z2(X,Z):L.IsObject(Z)?S2(X,Z):L.IsRecord(Z)?w8(X,Z):L.IsBoolean(Z)?V.True:V.False}function KM(X,Z){return J2(Z)?z2(X,Z):L.IsObject(Z)?S2(X,Z):!L.IsConstructor(Z)?V.False:X.parameters.length>Z.parameters.length?V.False:!X.parameters.every(($,Y)=>A8(x0(Z.parameters[Y],$))===V.True)?V.False:A8(x0(X.returns,Z.returns))}function RM(X,Z){return J2(Z)?z2(X,Z):L.IsObject(Z)?S2(X,Z):L.IsRecord(Z)?w8(X,Z):L.IsDate(Z)?V.True:V.False}function jM(X,Z){return J2(Z)?z2(X,Z):L.IsObject(Z)?S2(X,Z):!L.IsFunction(Z)?V.False:X.parameters.length>Z.parameters.length?V.False:!X.parameters.every(($,Y)=>A8(x0(Z.parameters[Y],$))===V.True)?V.False:A8(x0(X.returns,Z.returns))}function S7(X,Z){return L.IsLiteral(X)&&K2.IsNumber(X.const)?V.True:L.IsNumber(X)||L.IsInteger(X)?V.True:V.False}function SM(X,Z){return L.IsInteger(Z)||L.IsNumber(Z)?V.True:J2(Z)?z2(X,Z):L.IsObject(Z)?S2(X,Z):L.IsRecord(Z)?w8(X,Z):V.False}function J$(X,Z){return Z.allOf.every(($)=>x0(X,$)===V.True)?V.True:V.False}function VM(X,Z){return X.allOf.some(($)=>x0($,Z)===V.True)?V.True:V.False}function EM(X,Z){return J2(Z)?z2(X,Z):!L.IsIterator(Z)?V.False:A8(x0(X.items,Z.items))}function CM(X,Z){return L.IsLiteral(Z)&&Z.const===X.const?V.True:J2(Z)?z2(X,Z):L.IsObject(Z)?S2(X,Z):L.IsRecord(Z)?w8(X,Z):L.IsString(Z)?P7(X,Z):L.IsNumber(Z)?E7(X,Z):L.IsInteger(Z)?S7(X,Z):L.IsBoolean(Z)?j7(X,Z):V.False}function V7(X,Z){return V.False}function PM(X,Z){return V.True}function F7(X){let[Z,$]=[X,0];while(!0){if(!L.IsNot(Z))break;Z=Z.not,$+=1}return $%2===0?Z:k8()}function IM(X,Z){return L.IsNot(X)?x0(F7(X),Z):L.IsNot(Z)?x0(X,F7(Z)):b1("Invalid fallthrough for Not")}function xM(X,Z){return J2(Z)?z2(X,Z):L.IsObject(Z)?S2(X,Z):L.IsRecord(Z)?w8(X,Z):L.IsNull(Z)?V.True:V.False}function E7(X,Z){return L.IsLiteralNumber(X)?V.True:L.IsNumber(X)||L.IsInteger(X)?V.True:V.False}function TM(X,Z){return J2(Z)?z2(X,Z):L.IsObject(Z)?S2(X,Z):L.IsRecord(Z)?w8(X,Z):L.IsInteger(Z)||L.IsNumber(Z)?V.True:V.False}function h2(X,Z){return Object.getOwnPropertyNames(X.properties).length===Z}function B7(X){return z$(X)}function q7(X){return h2(X,0)||h2(X,1)&&"description"in X.properties&&L.IsUnion(X.properties.description)&&X.properties.description.anyOf.length===2&&(L.IsString(X.properties.description.anyOf[0])&&L.IsUndefined(X.properties.description.anyOf[1])||L.IsString(X.properties.description.anyOf[1])&&L.IsUndefined(X.properties.description.anyOf[0]))}function EY(X){return h2(X,0)}function K7(X){return h2(X,0)}function bM(X){return h2(X,0)}function kM(X){return h2(X,0)}function gM(X){return z$(X)}function fM(X){let Z=M8();return h2(X,0)||h2(X,1)&&"length"in X.properties&&A8(x0(X.properties.length,Z))===V.True}function vM(X){return h2(X,0)}function z$(X){let Z=M8();return h2(X,0)||h2(X,1)&&"length"in X.properties&&A8(x0(X.properties.length,Z))===V.True}function yM(X){let Z=e8([xX()],xX());return h2(X,0)||h2(X,1)&&"then"in X.properties&&A8(x0(X.properties.then,Z))===V.True}function C7(X,Z){return x0(X,Z)===V.False?V.False:L.IsOptional(X)&&!L.IsOptional(Z)?V.False:V.True}function S2(X,Z){return L.IsUnknown(X)?V.False:L.IsAny(X)?V.Union:L.IsNever(X)||L.IsLiteralString(X)&&B7(Z)||L.IsLiteralNumber(X)&&EY(Z)||L.IsLiteralBoolean(X)&&K7(Z)||L.IsSymbol(X)&&q7(Z)||L.IsBigInt(X)&&bM(Z)||L.IsString(X)&&B7(Z)||L.IsSymbol(X)&&q7(Z)||L.IsNumber(X)&&EY(Z)||L.IsInteger(X)&&EY(Z)||L.IsBoolean(X)&&K7(Z)||L.IsUint8Array(X)&&gM(Z)||L.IsDate(X)&&kM(Z)||L.IsConstructor(X)&&vM(Z)||L.IsFunction(X)&&fM(Z)?V.True:L.IsRecord(X)&&L.IsString(CY(X))?(()=>{return Z[G8]==="Record"?V.True:V.False})():L.IsRecord(X)&&L.IsNumber(CY(X))?(()=>{return h2(Z,0)?V.True:V.False})():V.False}function dM(X,Z){return J2(Z)?z2(X,Z):L.IsRecord(Z)?w8(X,Z):!L.IsObject(Z)?V.False:(()=>{for(let $ of Object.getOwnPropertyNames(Z.properties)){if(!($ in X.properties)&&!L.IsOptional(Z.properties[$]))return V.False;if(L.IsOptional(Z.properties[$]))return V.True;if(C7(X.properties[$],Z.properties[$])===V.False)return V.False}return V.True})()}function hM(X,Z){return J2(Z)?z2(X,Z):L.IsObject(Z)&&yM(Z)?V.True:!L.IsPromise(Z)?V.False:A8(x0(X.item,Z.item))}function CY(X){return r8 in X.patternProperties?M8():(a8 in X.patternProperties)?x2():b1("Unknown record key pattern")}function PY(X){return r8 in X.patternProperties?X.patternProperties[r8]:(a8 in X.patternProperties)?X.patternProperties[a8]:b1("Unable to get record value schema")}function w8(X,Z){let[$,Y]=[CY(Z),PY(Z)];return L.IsLiteralString(X)&&L.IsNumber($)&&A8(x0(X,Y))===V.True?V.True:L.IsUint8Array(X)&&L.IsNumber($)?x0(X,Y):L.IsString(X)&&L.IsNumber($)?x0(X,Y):L.IsArray(X)&&L.IsNumber($)?x0(X,Y):L.IsObject(X)?(()=>{for(let W of Object.getOwnPropertyNames(X.properties))if(C7(Y,X.properties[W])===V.False)return V.False;return V.True})():V.False}function mM(X,Z){return J2(Z)?z2(X,Z):L.IsObject(Z)?S2(X,Z):!L.IsRecord(Z)?V.False:x0(PY(X),PY(Z))}function pM(X,Z){let $=L.IsRegExp(X)?x2():X,Y=L.IsRegExp(Z)?x2():Z;return x0($,Y)}function P7(X,Z){return L.IsLiteral(X)&&K2.IsString(X.const)?V.True:L.IsString(X)?V.True:V.False}function cM(X,Z){return J2(Z)?z2(X,Z):L.IsObject(Z)?S2(X,Z):L.IsRecord(Z)?w8(X,Z):L.IsString(Z)?V.True:V.False}function uM(X,Z){return J2(Z)?z2(X,Z):L.IsObject(Z)?S2(X,Z):L.IsRecord(Z)?w8(X,Z):L.IsSymbol(Z)?V.True:V.False}function iM(X,Z){return L.IsTemplateLiteral(X)?x0(W1(X),Z):L.IsTemplateLiteral(Z)?x0(X,W1(Z)):b1("Invalid fallthrough for TemplateLiteral")}function oM(X,Z){return L.IsArray(Z)&&X.items!==void 0&&X.items.every(($)=>x0($,Z.items)===V.True)}function nM(X,Z){return L.IsNever(X)?V.True:L.IsUnknown(X)?V.False:L.IsAny(X)?V.Union:V.False}function lM(X,Z){return J2(Z)?z2(X,Z):L.IsObject(Z)&&z$(Z)?V.True:L.IsArray(Z)&&oM(X,Z)?V.True:!L.IsTuple(Z)?V.False:K2.IsUndefined(X.items)&&!K2.IsUndefined(Z.items)||!K2.IsUndefined(X.items)&&K2.IsUndefined(Z.items)?V.False:K2.IsUndefined(X.items)&&!K2.IsUndefined(Z.items)?V.True:X.items.every(($,Y)=>x0($,Z.items[Y])===V.True)?V.True:V.False}function tM(X,Z){return J2(Z)?z2(X,Z):L.IsObject(Z)?S2(X,Z):L.IsRecord(Z)?w8(X,Z):L.IsUint8Array(Z)?V.True:V.False}function sM(X,Z){return J2(Z)?z2(X,Z):L.IsObject(Z)?S2(X,Z):L.IsRecord(Z)?w8(X,Z):L.IsVoid(Z)?eM(X,Z):L.IsUndefined(Z)?V.True:V.False}function xY(X,Z){return Z.anyOf.some(($)=>x0(X,$)===V.True)?V.True:V.False}function rM(X,Z){return X.anyOf.every(($)=>x0($,Z)===V.True)?V.True:V.False}function I7(X,Z){return V.True}function aM(X,Z){return L.IsNever(Z)?V7(X,Z):L.IsIntersect(Z)?J$(X,Z):L.IsUnion(Z)?xY(X,Z):L.IsAny(Z)?IY(X,Z):L.IsString(Z)?P7(X,Z):L.IsNumber(Z)?E7(X,Z):L.IsInteger(Z)?S7(X,Z):L.IsBoolean(Z)?j7(X,Z):L.IsArray(Z)?NM(X,Z):L.IsTuple(Z)?nM(X,Z):L.IsObject(Z)?S2(X,Z):L.IsUnknown(Z)?V.True:V.False}function eM(X,Z){return L.IsUndefined(X)?V.True:L.IsUndefined(X)?V.True:V.False}function XU(X,Z){return L.IsIntersect(Z)?J$(X,Z):L.IsUnion(Z)?xY(X,Z):L.IsUnknown(Z)?I7(X,Z):L.IsAny(Z)?IY(X,Z):L.IsObject(Z)?S2(X,Z):L.IsVoid(Z)?V.True:V.False}function x0(X,Z){return L.IsTemplateLiteral(X)||L.IsTemplateLiteral(Z)?iM(X,Z):L.IsRegExp(X)||L.IsRegExp(Z)?pM(X,Z):L.IsNot(X)||L.IsNot(Z)?IM(X,Z):L.IsAny(X)?OM(X,Z):L.IsArray(X)?LM(X,Z):L.IsBigInt(X)?BM(X,Z):L.IsBoolean(X)?qM(X,Z):L.IsAsyncIterator(X)?FM(X,Z):L.IsConstructor(X)?KM(X,Z):L.IsDate(X)?RM(X,Z):L.IsFunction(X)?jM(X,Z):L.IsInteger(X)?SM(X,Z):L.IsIntersect(X)?VM(X,Z):L.IsIterator(X)?EM(X,Z):L.IsLiteral(X)?CM(X,Z):L.IsNever(X)?PM(X,Z):L.IsNull(X)?xM(X,Z):L.IsNumber(X)?TM(X,Z):L.IsObject(X)?dM(X,Z):L.IsRecord(X)?mM(X,Z):L.IsString(X)?cM(X,Z):L.IsSymbol(X)?uM(X,Z):L.IsTuple(X)?lM(X,Z):L.IsPromise(X)?hM(X,Z):L.IsUint8Array(X)?tM(X,Z):L.IsUndefined(X)?sM(X,Z):L.IsUnion(X)?rM(X,Z):L.IsUnknown(X)?aM(X,Z):L.IsVoid(X)?XU(X,Z):b1(`Unknown left type operand '${X[q]}'`)}function bX(X,Z){return x0(X,Z)}function ZU(X,Z,$,Y,W){let J={};for(let z of globalThis.Object.getOwnPropertyNames(X))J[z]=k1(X[z],Z,$,Y,p0(W));return J}function $U(X,Z,$,Y,W){return ZU(X.properties,Z,$,Y,W)}function x7(X,Z,$,Y,W){let J=$U(X,Z,$,Y,W);return F0(J)}function YU(X,Z,$,Y){let W=bX(X,Z);return W===V.Union?j0([$,Y]):W===V.True?$:Y}function k1(X,Z,$,Y,W){return u0(X)?x7(X,Z,$,Y,W):X8(X)?S(T7(X,Z,$,Y,W)):S(YU(X,Z,$,Y),W)}function WU(X,Z,$,Y,W){return{[X]:k1(_0(X),Z,$,Y,p0(W))}}function JU(X,Z,$,Y,W){return X.reduce((J,z)=>{return{...J,...WU(z,Z,$,Y,W)}},{})}function zU(X,Z,$,Y,W){return JU(X.keys,Z,$,Y,W)}function T7(X,Z,$,Y,W){let J=zU(X,Z,$,Y,W);return F0(J)}function QU(X){return X.allOf.every((Z)=>wX(Z))}function GU(X){return X.anyOf.some((Z)=>wX(Z))}function MU(X){return!wX(X.not)}function wX(X){return X[q]==="Intersect"?QU(X):X[q]==="Union"?GU(X):X[q]==="Not"?MU(X):X[q]==="Undefined"?!0:!1}function b7(X,Z){return g1(W1(X),Z)}function UU(X,Z){let $=X.filter((Y)=>bX(Y,Z)===V.False);return $.length===1?$[0]:j0($)}function g1(X,Z,$={}){if(Z8(X))return S(b7(X,Z),$);if(u0(X))return S(k7(X,Z),$);return S(L0(X)?UU(X.anyOf,Z):bX(X,Z)!==V.False?Y0():X,$)}function HU(X,Z){let $={};for(let Y of globalThis.Object.getOwnPropertyNames(X))$[Y]=g1(X[Y],Z);return $}function DU(X,Z){return HU(X.properties,Z)}function k7(X,Z){let $=DU(X,Z);return F0($)}function g7(X,Z){return f1(W1(X),Z)}function AU(X,Z){let $=X.filter((Y)=>bX(Y,Z)!==V.False);return $.length===1?$[0]:j0($)}function f1(X,Z,$){if(Z8(X))return S(g7(X,Z),$);if(u0(X))return S(f7(X,Z),$);return S(L0(X)?AU(X.anyOf,Z):bX(X,Z)!==V.False?X:Y0(),$)}function wU(X,Z){let $={};for(let Y of globalThis.Object.getOwnPropertyNames(X))$[Y]=f1(X[Y],Z);return $}function _U(X,Z){return wU(X.properties,Z)}function f7(X,Z){let $=_U(X,Z);return F0($)}function v7(X,Z){return I8(X)?S(X.returns,Z):Y0(Z)}function Q$(X){return y2(R2(X))}function J1(X,Z,$){return S({[q]:"Record",type:"object",patternProperties:{[X]:Z}},$)}function TY(X,Z,$){let Y={};for(let W of X)Y[W]=Z;return S0(Y,{...$,[G8]:"Record"})}function OU(X,Z,$){return nZ(X)?TY(v2(X),Z,$):J1(X.pattern,Z,$)}function NU(X,Z,$){return TY(v2(j0(X)),Z,$)}function LU(X,Z,$){return TY([X.toString()],Z,$)}function FU(X,Z,$){return J1(X.source,Z,$)}function BU(X,Z,$){let Y=$2(X.pattern)?a8:X.pattern;return J1(Y,Z,$)}function qU(X,Z,$){return J1(a8,Z,$)}function KU(X,Z,$){return J1(p9,Z,$)}function RU(X,Z,$){return S0({true:Z,false:Z},$)}function jU(X,Z,$){return J1(r8,Z,$)}function SU(X,Z,$){return J1(r8,Z,$)}function G$(X,Z,$={}){return L0(X)?NU(X.anyOf,Z,$):Z8(X)?OU(X,Z,$):e2(X)?LU(X.const,Z,$):GX(X)?RU(X,Z,$):T8(X)?jU(X,Z,$):b8(X)?SU(X,Z,$):NY(X)?FU(X,Z,$):MX(X)?BU(X,Z,$):_Y(X)?qU(X,Z,$):PX(X)?KU(X,Z,$):Y0($)}function M$(X){return globalThis.Object.getOwnPropertyNames(X.patternProperties)[0]}function y7(X){let Z=M$(X);return Z===a8?x2():Z===r8?M8():x2({pattern:Z})}function U$(X){return X.patternProperties[M$(X)]}function VU(X,Z){return Z.parameters=HZ(X,Z.parameters),Z.returns=g8(X,Z.returns),Z}function EU(X,Z){return Z.parameters=HZ(X,Z.parameters),Z.returns=g8(X,Z.returns),Z}function CU(X,Z){return Z.allOf=HZ(X,Z.allOf),Z}function PU(X,Z){return Z.anyOf=HZ(X,Z.anyOf),Z}function IU(X,Z){if($2(Z.items))return Z;return Z.items=HZ(X,Z.items),Z}function xU(X,Z){return Z.items=g8(X,Z.items),Z}function TU(X,Z){return Z.items=g8(X,Z.items),Z}function bU(X,Z){return Z.items=g8(X,Z.items),Z}function kU(X,Z){return Z.item=g8(X,Z.item),Z}function gU(X,Z){let $=dU(X,Z.properties);return{...Z,...S0($)}}function fU(X,Z){let $=g8(X,y7(Z)),Y=g8(X,U$(Z)),W=G$($,Y);return{...Z,...W}}function vU(X,Z){return Z.index in X?X[Z.index]:k8()}function yU(X,Z){let $=B1(Z),Y=f2(Z),W=g8(X,Z);return $&&Y?Q$(W):$&&!Y?y2(W):!$&&Y?R2(W):W}function dU(X,Z){return globalThis.Object.getOwnPropertyNames(Z).reduce(($,Y)=>{return{...$,[Y]:yU(X,Z[Y])}},{})}function HZ(X,Z){return Z.map(($)=>g8(X,$))}function g8(X,Z){return I8(Z)?VU(X,Z):x8(Z)?EU(X,Z):l0(Z)?CU(X,Z):L0(Z)?PU(X,Z):$8(Z)?IU(X,Z):C8(Z)?xU(X,Z):aX(Z)?TU(X,Z):X1(Z)?bU(X,Z):Z1(Z)?kU(X,Z):Y2(Z)?gU(X,Z):$1(Z)?fU(X,Z):OY(Z)?vU(X,Z):Z}function d7(X,Z){return g8(Z,L1(X))}function h7(X){return S({[q]:"Integer",type:"integer"},X)}function hU(X,Z,$){return{[X]:f8(_0(X),Z,p0($))}}function mU(X,Z,$){return X.reduce((W,J)=>{return{...W,...hU(J,Z,$)}},{})}function pU(X,Z,$){return mU(X.keys,Z,$)}function m7(X,Z,$){let Y=pU(X,Z,$);return F0(Y)}function cU(X){let[Z,$]=[X.slice(0,1),X.slice(1)];return[Z.toLowerCase(),$].join("")}function uU(X){let[Z,$]=[X.slice(0,1),X.slice(1)];return[Z.toUpperCase(),$].join("")}function iU(X){return X.toUpperCase()}function oU(X){return X.toLowerCase()}function nU(X,Z,$){let Y=E1(X.pattern);if(!Y1(Y))return{...X,pattern:p7(X.pattern,Z)};let z=[...QZ(Y)].map((G)=>_0(G)),Q=c7(z,Z),M=j0(Q);return tZ([M],$)}function p7(X,Z){return typeof X==="string"?Z==="Uncapitalize"?cU(X):Z==="Capitalize"?uU(X):Z==="Uppercase"?iU(X):Z==="Lowercase"?oU(X):X:X.toString()}function c7(X,Z){return X.map(($)=>f8($,Z))}function f8(X,Z,$={}){return X8(X)?m7(X,Z,$):Z8(X)?nU(X,Z,$):L0(X)?j0(c7(X.anyOf,Z),$):e2(X)?_0(p7(X.const,Z),$):S(X,$)}function u7(X,Z={}){return f8(X,"Capitalize",Z)}function i7(X,Z={}){return f8(X,"Lowercase",Z)}function o7(X,Z={}){return f8(X,"Uncapitalize",Z)}function n7(X,Z={}){return f8(X,"Uppercase",Z)}function lU(X,Z,$){let Y={};for(let W of globalThis.Object.getOwnPropertyNames(X))Y[W]=kX(X[W],Z,p0($));return Y}function tU(X,Z,$){return lU(X.properties,Z,$)}function l7(X,Z,$){let Y=tU(X,Z,$);return F0(Y)}function sU(X,Z){return X.map(($)=>bY($,Z))}function rU(X,Z){return X.map(($)=>bY($,Z))}function aU(X,Z){let{[Z]:$,...Y}=X;return Y}function eU(X,Z){return Z.reduce(($,Y)=>aU($,Y),X)}function XH(X,Z){let $=s0(X,[k0,"$id","required","properties"]),Y=eU(X.properties,Z);return S0(Y,$)}function ZH(X){let Z=X.reduce(($,Y)=>uZ(Y)?[...$,_0(Y)]:$,[]);return j0(Z)}function bY(X,Z){return l0(X)?j2(sU(X.allOf,Z)):L0(X)?j0(rU(X.anyOf,Z)):Y2(X)?XH(X,Z):S0({})}function kX(X,Z,$){let Y=Z2(Z)?ZH(Z):Z,W=o0(Z)?v2(Z):Z,J=e0(X),z=e0(Z);return u0(X)?l7(X,W,$):X8(Z)?t7(X,Z,$):J&&z?m0("Omit",[X,Y],$):!J&&z?m0("Omit",[X,Y],$):J&&!z?m0("Omit",[X,Y],$):S({...bY(X,W),...$})}function $H(X,Z,$){return{[Z]:kX(X,[Z],p0($))}}function YH(X,Z,$){return Z.reduce((Y,W)=>{return{...Y,...$H(X,W,$)}},{})}function WH(X,Z,$){return YH(X,Z.keys,$)}function t7(X,Z,$){let Y=WH(X,Z,$);return F0(Y)}function JH(X,Z,$){let Y={};for(let W of globalThis.Object.getOwnPropertyNames(X))Y[W]=gX(X[W],Z,p0($));return Y}function zH(X,Z,$){return JH(X.properties,Z,$)}function s7(X,Z,$){let Y=zH(X,Z,$);return F0(Y)}function QH(X,Z){return X.map(($)=>kY($,Z))}function GH(X,Z){return X.map(($)=>kY($,Z))}function MH(X,Z){let $={};for(let Y of Z)if(Y in X)$[Y]=X[Y];return $}function UH(X,Z){let $=s0(X,[k0,"$id","required","properties"]),Y=MH(X.properties,Z);return S0(Y,$)}function HH(X){let Z=X.reduce(($,Y)=>uZ(Y)?[...$,_0(Y)]:$,[]);return j0(Z)}function kY(X,Z){return l0(X)?j2(QH(X.allOf,Z)):L0(X)?j0(GH(X.anyOf,Z)):Y2(X)?UH(X,Z):S0({})}function gX(X,Z,$){let Y=Z2(Z)?HH(Z):Z,W=o0(Z)?v2(Z):Z,J=e0(X),z=e0(Z);return u0(X)?s7(X,W,$):X8(Z)?r7(X,Z,$):J&&z?m0("Pick",[X,Y],$):!J&&z?m0("Pick",[X,Y],$):J&&!z?m0("Pick",[X,Y],$):S({...kY(X,W),...$})}function DH(X,Z,$){return{[Z]:gX(X,[Z],p0($))}}function AH(X,Z,$){return Z.reduce((Y,W)=>{return{...Y,...DH(X,W,$)}},{})}function wH(X,Z,$){return AH(X,Z.keys,$)}function r7(X,Z,$){let Y=wH(X,Z,$);return F0(Y)}function _H(X,Z){return m0("Partial",[m0(X,Z)])}function OH(X){return m0("Partial",[D8(X)])}function NH(X){let Z={};for(let $ of globalThis.Object.getOwnPropertyNames(X))Z[$]=R2(X[$]);return Z}function LH(X){let Z=s0(X,[k0,"$id","required","properties"]),$=NH(X.properties);return S0($,Z)}function a7(X){return X.map((Z)=>e7(Z))}function e7(X){return P8(X)?_H(X.target,X.parameters):e0(X)?OH(X.$ref):l0(X)?j2(a7(X.allOf)):L0(X)?j0(a7(X.anyOf)):Y2(X)?LH(X):eX(X)?X:GX(X)?X:T8(X)?X:e2(X)?X:ZZ(X)?X:b8(X)?X:MX(X)?X:$Z(X)?X:UX(X)?X:S0({})}function v1(X,Z){if(u0(X))return XW(X,Z);else return S({...e7(X),...Z})}function FH(X,Z){let $={};for(let Y of globalThis.Object.getOwnPropertyNames(X))$[Y]=v1(X[Y],p0(Z));return $}function BH(X,Z){return FH(X.properties,Z)}function XW(X,Z){let $=BH(X,Z);return F0($)}function qH(X,Z){return m0("Required",[m0(X,Z)])}function KH(X){return m0("Required",[D8(X)])}function RH(X){let Z={};for(let $ of globalThis.Object.getOwnPropertyNames(X))Z[$]=s0(X[$],[N2]);return Z}function jH(X){let Z=s0(X,[k0,"$id","required","properties"]),$=RH(X.properties);return S0($,Z)}function ZW(X){return X.map((Z)=>$W(Z))}function $W(X){return P8(X)?qH(X.target,X.parameters):e0(X)?KH(X.$ref):l0(X)?j2(ZW(X.allOf)):L0(X)?j0(ZW(X.anyOf)):Y2(X)?jH(X):eX(X)?X:GX(X)?X:T8(X)?X:e2(X)?X:ZZ(X)?X:b8(X)?X:MX(X)?X:$Z(X)?X:UX(X)?X:S0({})}function y1(X,Z){if(u0(X))return YW(X,Z);else return S({...$W(X),...Z})}function SH(X,Z){let $={};for(let Y of globalThis.Object.getOwnPropertyNames(X))$[Y]=y1(X[Y],Z);return $}function VH(X,Z){return SH(X.properties,Z)}function YW(X,Z){let $=VH(X,Z);return F0($)}function EH(X,Z){return Z.map(($)=>{return e0($)?gY(X,$.$ref):Y8(X,$)})}function gY(X,Z){return Z in X?e0(X[Z])?gY(X,X[Z].$ref):Y8(X,X[Z]):Y0()}function CH(X){return x1(X[0])}function PH(X){return TX(X[0],X[1])}function IH(X){return T1(X[0])}function xH(X){return v1(X[0])}function TH(X){return kX(X[0],X[1])}function bH(X){return gX(X[0],X[1])}function kH(X){return y1(X[0])}function gH(X,Z,$){let Y=EH(X,$);return Z==="Awaited"?CH(Y):Z==="Index"?PH(Y):Z==="KeyOf"?IH(Y):Z==="Partial"?xH(Y):Z==="Omit"?TH(Y):Z==="Pick"?bH(Y):Z==="Required"?kH(Y):Y0()}function fH(X,Z){return R1(Y8(X,Z))}function vH(X,Z){return j1(Y8(X,Z))}function yH(X,Z,$){return S1(DZ(X,Z),Y8(X,$))}function dH(X,Z,$){return e8(DZ(X,Z),Y8(X,$))}function hH(X,Z){return j2(DZ(X,Z))}function mH(X,Z){return I1(Y8(X,Z))}function pH(X,Z){return S0(globalThis.Object.keys(Z).reduce(($,Y)=>{return{...$,[Y]:Y8(X,Z[Y])}},{}))}function cH(X,Z){let[$,Y]=[Y8(X,U$(Z)),M$(Z)],W=L1(Z);return W.patternProperties[Y]=$,W}function uH(X,Z){return e0(Z)?{...gY(X,Z.$ref),[k0]:Z[k0]}:Z}function iH(X,Z){return U8(DZ(X,Z))}function oH(X,Z){return j0(DZ(X,Z))}function DZ(X,Z){return Z.map(($)=>Y8(X,$))}function Y8(X,Z){return f2(Z)?S(Y8(X,s0(Z,[N2])),Z):B1(Z)?S(Y8(X,s0(Z,[E8])),Z):R0(Z)?S(uH(X,Z),Z):C8(Z)?S(fH(X,Z.items),Z):aX(Z)?S(vH(X,Z.items),Z):P8(Z)?S(gH(X,Z.target,Z.parameters)):I8(Z)?S(yH(X,Z.parameters,Z.returns),Z):x8(Z)?S(dH(X,Z.parameters,Z.returns),Z):l0(Z)?S(hH(X,Z.allOf),Z):X1(Z)?S(mH(X,Z.items),Z):Y2(Z)?S(pH(X,Z.properties),Z):$1(Z)?S(cH(X,Z)):$8(Z)?S(iH(X,Z.items||[]),Z):L0(Z)?S(oH(X,Z.anyOf),Z):Z}function nH(X,Z){return Z in X?Y8(X,X[Z]):Y0()}function WW(X){return globalThis.Object.getOwnPropertyNames(X).reduce((Z,$)=>{return{...Z,[$]:nH(X,$)}},{})}class JW{constructor(X){let Z=WW(X),$=this.WithIdentifiers(Z);this.$defs=$}Import(X,Z){let $={...this.$defs,[X]:S(this.$defs[X],Z)};return S({[q]:"Import",$defs:$,$ref:X})}WithIdentifiers(X){return globalThis.Object.getOwnPropertyNames(X).reduce((Z,$)=>{return{...Z,[$]:{...X[$],$id:$}}},{})}}function zW(X){return new JW(X)}function QW(X,Z){return S({[q]:"Not",not:X},Z)}function GW(X,Z){return x8(X)?U8(X.parameters,Z):Y0()}var lH=0;function MW(X,Z={}){if($2(Z.$id))Z.$id=`T${lH++}`;let $=L1(X({[q]:"This",$ref:`${Z.$id}`}));return $.$id=Z.$id,S({[G8]:"Recursive",...$},Z)}function UW(X,Z){let $=b0(X)?new globalThis.RegExp(X):X;return S({[q]:"RegExp",type:"RegExp",source:$.source,flags:$.flags},Z)}function tH(X){return l0(X)?X.allOf:L0(X)?X.anyOf:$8(X)?X.items??[]:[]}function HW(X){return tH(X)}function DW(X,Z){return x8(X)?S(X.returns,Z):Y0(Z)}class AW{constructor(X){this.schema=X}Decode(X){return new wW(this.schema,X)}}class wW{constructor(X,Z){this.schema=X,this.decode=Z}EncodeTransform(X,Z){let W={Encode:(J)=>Z[k0].Encode(X(J)),Decode:(J)=>this.decode(Z[k0].Decode(J))};return{...Z,[k0]:W}}EncodeSchema(X,Z){let $={Decode:this.decode,Encode:X};return{...Z,[k0]:$}}Encode(X){return R0(this.schema)?this.EncodeTransform(X,this.schema):this.EncodeSchema(X,this.schema)}}function _W(X){return new AW(X)}function H$(X={}){return S({[q]:X[q]??"Unsafe"},X)}function OW(X){return S({[q]:"Void",type:"void"},X)}var fY={};EX(fY,{Void:()=>OW,Uppercase:()=>n7,Unsafe:()=>H$,Unknown:()=>k8,Union:()=>j0,Undefined:()=>$$,Uncapitalize:()=>o7,Uint8Array:()=>Y$,Tuple:()=>U8,Transform:()=>_W,TemplateLiteral:()=>tZ,Symbol:()=>Z$,String:()=>x2,ReturnType:()=>DW,Rest:()=>HW,Required:()=>y1,RegExp:()=>UW,Ref:()=>D8,Recursive:()=>MW,Record:()=>G$,ReadonlyOptional:()=>Q$,Readonly:()=>y2,Promise:()=>rZ,Pick:()=>gX,Partial:()=>v1,Parameters:()=>GW,Optional:()=>R2,Omit:()=>kX,Object:()=>S0,Number:()=>M8,Null:()=>X$,Not:()=>QW,Never:()=>Y0,Module:()=>zW,Mapped:()=>M7,Lowercase:()=>i7,Literal:()=>_0,KeyOf:()=>T1,Iterator:()=>I1,Intersect:()=>j2,Integer:()=>h7,Instantiate:()=>d7,InstanceType:()=>v7,Index:()=>TX,Function:()=>e8,Extract:()=>f1,Extends:()=>k1,Exclude:()=>g1,Enum:()=>L7,Date:()=>eZ,ConstructorParameters:()=>N7,Constructor:()=>S1,Const:()=>O7,Composite:()=>_7,Capitalize:()=>u7,Boolean:()=>lZ,BigInt:()=>P1,Awaited:()=>x1,AsyncIterator:()=>j1,Array:()=>R1,Argument:()=>n9,Any:()=>xX});var f0=fY;function sH(X){switch(X.errorType){case R.ArrayContains:return"Expected array to contain at least one matching value";case R.ArrayMaxContains:return`Expected array to contain no more than ${X.schema.maxContains} matching values`;case R.ArrayMinContains:return`Expected array to contain at least ${X.schema.minContains} matching values`;case R.ArrayMaxItems:return`Expected array length to be less or equal to ${X.schema.maxItems}`;case R.ArrayMinItems:return`Expected array length to be greater or equal to ${X.schema.minItems}`;case R.ArrayUniqueItems:return"Expected array elements to be unique";case R.Array:return"Expected array";case R.AsyncIterator:return"Expected AsyncIterator";case R.BigIntExclusiveMaximum:return`Expected bigint to be less than ${X.schema.exclusiveMaximum}`;case R.BigIntExclusiveMinimum:return`Expected bigint to be greater than ${X.schema.exclusiveMinimum}`;case R.BigIntMaximum:return`Expected bigint to be less or equal to ${X.schema.maximum}`;case R.BigIntMinimum:return`Expected bigint to be greater or equal to ${X.schema.minimum}`;case R.BigIntMultipleOf:return`Expected bigint to be a multiple of ${X.schema.multipleOf}`;case R.BigInt:return"Expected bigint";case R.Boolean:return"Expected boolean";case R.DateExclusiveMinimumTimestamp:return`Expected Date timestamp to be greater than ${X.schema.exclusiveMinimumTimestamp}`;case R.DateExclusiveMaximumTimestamp:return`Expected Date timestamp to be less than ${X.schema.exclusiveMaximumTimestamp}`;case R.DateMinimumTimestamp:return`Expected Date timestamp to be greater or equal to ${X.schema.minimumTimestamp}`;case R.DateMaximumTimestamp:return`Expected Date timestamp to be less or equal to ${X.schema.maximumTimestamp}`;case R.DateMultipleOfTimestamp:return`Expected Date timestamp to be a multiple of ${X.schema.multipleOfTimestamp}`;case R.Date:return"Expected Date";case R.Function:return"Expected function";case R.IntegerExclusiveMaximum:return`Expected integer to be less than ${X.schema.exclusiveMaximum}`;case R.IntegerExclusiveMinimum:return`Expected integer to be greater than ${X.schema.exclusiveMinimum}`;case R.IntegerMaximum:return`Expected integer to be less or equal to ${X.schema.maximum}`;case R.IntegerMinimum:return`Expected integer to be greater or equal to ${X.schema.minimum}`;case R.IntegerMultipleOf:return`Expected integer to be a multiple of ${X.schema.multipleOf}`;case R.Integer:return"Expected integer";case R.IntersectUnevaluatedProperties:return"Unexpected property";case R.Intersect:return"Expected all values to match";case R.Iterator:return"Expected Iterator";case R.Literal:return`Expected ${typeof X.schema.const==="string"?`'${X.schema.const}'`:X.schema.const}`;case R.Never:return"Never";case R.Not:return"Value should not match";case R.Null:return"Expected null";case R.NumberExclusiveMaximum:return`Expected number to be less than ${X.schema.exclusiveMaximum}`;case R.NumberExclusiveMinimum:return`Expected number to be greater than ${X.schema.exclusiveMinimum}`;case R.NumberMaximum:return`Expected number to be less or equal to ${X.schema.maximum}`;case R.NumberMinimum:return`Expected number to be greater or equal to ${X.schema.minimum}`;case R.NumberMultipleOf:return`Expected number to be a multiple of ${X.schema.multipleOf}`;case R.Number:return"Expected number";case R.Object:return"Expected object";case R.ObjectAdditionalProperties:return"Unexpected property";case R.ObjectMaxProperties:return`Expected object to have no more than ${X.schema.maxProperties} properties`;case R.ObjectMinProperties:return`Expected object to have at least ${X.schema.minProperties} properties`;case R.ObjectRequiredProperty:return"Expected required property";case R.Promise:return"Expected Promise";case R.RegExp:return"Expected string to match regular expression";case R.StringFormatUnknown:return`Unknown format '${X.schema.format}'`;case R.StringFormat:return`Expected string to match '${X.schema.format}' format`;case R.StringMaxLength:return`Expected string length less or equal to ${X.schema.maxLength}`;case R.StringMinLength:return`Expected string length greater or equal to ${X.schema.minLength}`;case R.StringPattern:return`Expected string to match '${X.schema.pattern}'`;case R.String:return"Expected string";case R.Symbol:return"Expected symbol";case R.TupleLength:return`Expected tuple to have ${X.schema.maxItems||0} elements`;case R.Tuple:return"Expected tuple";case R.Uint8ArrayMaxByteLength:return`Expected byte length less or equal to ${X.schema.maxByteLength}`;case R.Uint8ArrayMinByteLength:return`Expected byte length greater or equal to ${X.schema.minByteLength}`;case R.Uint8Array:return"Expected Uint8Array";case R.Undefined:return"Expected undefined";case R.Union:return"Expected union value";case R.Void:return"Expected void";case R.Kind:return`Expected kind '${X.schema[q]}'`;default:return"Unknown error type"}}var rH=sH;function NW(){return rH}class LW extends t{constructor(X){super(`Unable to dereference schema with $id '${X.$ref}'`);this.schema=X}}function aH(X,Z){let $=Z.find((Y)=>Y.$id===X.$ref);if($===void 0)throw new LW(X);return B0($,Z)}function D2(X,Z){if(!N0(X.$id)||Z.some(($)=>$.$id===X.$id))return Z;return Z.push(X),Z}function B0(X,Z){return X[q]==="This"||X[q]==="Ref"?aH(X,Z):X}class FW extends t{constructor(X){super("Unable to hash value");this.value=X}}var W8;(function(X){X[X.Undefined=0]="Undefined",X[X.Null=1]="Null",X[X.Boolean=2]="Boolean",X[X.Number=3]="Number",X[X.String=4]="String",X[X.Object=5]="Object",X[X.Array=6]="Array",X[X.Date=7]="Date",X[X.Uint8Array=8]="Uint8Array",X[X.Symbol=9]="Symbol",X[X.BigInt=10]="BigInt"})(W8||(W8={}));var d1=BigInt("14695981039346656037"),[eH,XD]=[BigInt("1099511628211"),BigInt("18446744073709551616")],ZD=Array.from({length:256}).map((X,Z)=>BigInt(Z)),BW=new Float64Array(1),qW=new DataView(BW.buffer),KW=new Uint8Array(BW.buffer);function*$D(X){let Z=X===0?1:Math.ceil(Math.floor(Math.log2(X)+1)/8);for(let $=0;$>8*(Z-1-$)&255}function YD(X){V2(W8.Array);for(let Z of X)h1(Z)}function WD(X){V2(W8.Boolean),V2(X?1:0)}function JD(X){V2(W8.BigInt),qW.setBigInt64(0,X);for(let Z of KW)V2(Z)}function zD(X){V2(W8.Date),h1(X.getTime())}function QD(X){V2(W8.Null)}function GD(X){V2(W8.Number),qW.setFloat64(0,X);for(let Z of KW)V2(Z)}function MD(X){V2(W8.Object);for(let Z of globalThis.Object.getOwnPropertyNames(X).sort())h1(Z),h1(X[Z])}function UD(X){V2(W8.String);for(let Z=0;Z=X.minItems))return!1;if(H0(X.maxItems)&&!($.length<=X.maxItems))return!1;if(!$.every((J)=>A2(X.items,Z,J)))return!1;if(X.uniqueItems===!0&&!function(){let J=new Set;for(let z of $){let Q=fX(z);if(J.has(Q))return!1;else J.add(Q)}return!0}())return!1;if(!(H0(X.contains)||o(X.minContains)||o(X.maxContains)))return!0;let Y=H0(X.contains)?X.contains:Y0(),W=$.reduce((J,z)=>A2(Y,Z,z)?J+1:J,0);if(W===0)return!1;if(o(X.minContains)&&WX.maxContains)return!1;return!0}function LD(X,Z,$){return hZ($)}function FD(X,Z,$){if(!O2($))return!1;if(H0(X.exclusiveMaximum)&&!($X.exclusiveMinimum))return!1;if(H0(X.maximum)&&!($<=X.maximum))return!1;if(H0(X.minimum)&&!($>=X.minimum))return!1;if(H0(X.multipleOf)&&$%X.multipleOf!==BigInt(0))return!1;return!0}function BD(X,Z,$){return s8($)}function qD(X,Z,$){return A2(X.returns,Z,$.prototype)}function KD(X,Z,$){if(!I2($))return!1;if(H0(X.exclusiveMaximumTimestamp)&&!($.getTime()X.exclusiveMinimumTimestamp))return!1;if(H0(X.maximumTimestamp)&&!($.getTime()<=X.maximumTimestamp))return!1;if(H0(X.minimumTimestamp)&&!($.getTime()>=X.minimumTimestamp))return!1;if(H0(X.multipleOfTimestamp)&&$.getTime()%X.multipleOfTimestamp!==0)return!1;return!0}function RD(X,Z,$){return CX($)}function jD(X,Z,$){let Y=globalThis.Object.values(X.$defs),W=X.$defs[X.$ref];return A2(W,[...Z,...Y],$)}function SD(X,Z,$){if(!cZ($))return!1;if(H0(X.exclusiveMaximum)&&!($X.exclusiveMinimum))return!1;if(H0(X.maximum)&&!($<=X.maximum))return!1;if(H0(X.minimum)&&!($>=X.minimum))return!1;if(H0(X.multipleOf)&&$%X.multipleOf!==0)return!1;return!0}function VD(X,Z,$){let Y=X.allOf.every((W)=>A2(W,Z,$));if(X.unevaluatedProperties===!1){let W=new RegExp(AX(X)),J=Object.getOwnPropertyNames($).every((z)=>W.test(z));return Y&&J}else if(o0(X.unevaluatedProperties)){let W=new RegExp(AX(X)),J=Object.getOwnPropertyNames($).every((z)=>W.test(z)||A2(X.unevaluatedProperties,Z,$[z]));return Y&&J}else return Y}function ED(X,Z,$){return mZ($)}function CD(X,Z,$){return $===X.const}function PD(X,Z,$){return!1}function ID(X,Z,$){return!A2(X.not,Z,$)}function xD(X,Z,$){return zX($)}function TD(X,Z,$){if(!h0.IsNumberLike($))return!1;if(H0(X.exclusiveMaximum)&&!($X.exclusiveMinimum))return!1;if(H0(X.minimum)&&!($>=X.minimum))return!1;if(H0(X.maximum)&&!($<=X.maximum))return!1;if(H0(X.multipleOf)&&$%X.multipleOf!==0)return!1;return!0}function bD(X,Z,$){if(!h0.IsObjectLike($))return!1;if(H0(X.minProperties)&&!(Object.getOwnPropertyNames($).length>=X.minProperties))return!1;if(H0(X.maxProperties)&&!(Object.getOwnPropertyNames($).length<=X.maxProperties))return!1;let Y=Object.getOwnPropertyNames(X.properties);for(let W of Y){let J=X.properties[W];if(X.required&&X.required.includes(W)){if(!A2(J,Z,$[W]))return!1;if((wX(J)||wD(J))&&!(W in $))return!1}else if(h0.IsExactOptionalProperty($,W)&&!A2(J,Z,$[W]))return!1}if(X.additionalProperties===!1){let W=Object.getOwnPropertyNames($);if(X.required&&X.required.length===Y.length&&W.length===Y.length)return!0;else return W.every((J)=>Y.includes(J))}else if(typeof X.additionalProperties==="object")return Object.getOwnPropertyNames($).every((J)=>Y.includes(J)||A2(X.additionalProperties,Z,$[J]));else return!0}function kD(X,Z,$){return pZ($)}function gD(X,Z,$){if(!h0.IsRecordLike($))return!1;if(H0(X.minProperties)&&!(Object.getOwnPropertyNames($).length>=X.minProperties))return!1;if(H0(X.maxProperties)&&!(Object.getOwnPropertyNames($).length<=X.maxProperties))return!1;let[Y,W]=Object.entries(X.patternProperties)[0],J=new RegExp(Y),z=Object.entries($).every(([G,U])=>{return J.test(G)?A2(W,Z,U):!0}),Q=typeof X.additionalProperties==="object"?Object.entries($).every(([G,U])=>{return!J.test(G)?A2(X.additionalProperties,Z,U):!0}):!0,M=X.additionalProperties===!1?Object.getOwnPropertyNames($).every((G)=>{return J.test(G)}):!0;return z&&Q&&M}function fD(X,Z,$){return A2(B0(X,Z),Z,$)}function vD(X,Z,$){let Y=new RegExp(X.source,X.flags);if(H0(X.minLength)){if(!($.length>=X.minLength))return!1}if(H0(X.maxLength)){if(!($.length<=X.maxLength))return!1}return Y.test($)}function yD(X,Z,$){if(!N0($))return!1;if(H0(X.minLength)){if(!($.length>=X.minLength))return!1}if(H0(X.maxLength)){if(!($.length<=X.maxLength))return!1}if(H0(X.pattern)){if(!new RegExp(X.pattern).test($))return!1}if(H0(X.format)){if(!C0.Has(X.format))return!1;return C0.Get(X.format)($)}return!0}function dD(X,Z,$){return QX($)}function hD(X,Z,$){return N0($)&&new RegExp(X.pattern).test($)}function mD(X,Z,$){return A2(B0(X,Z),Z,$)}function pD(X,Z,$){if(!r($))return!1;if(X.items===void 0&&$.length!==0)return!1;if($.length!==X.maxItems)return!1;if(!X.items)return!0;for(let Y=0;YA2(Y,Z,$))}function iD(X,Z,$){if(!F1($))return!1;if(H0(X.maxByteLength)&&!($.length<=X.maxByteLength))return!1;if(H0(X.minByteLength)&&!($.length>=X.minByteLength))return!1;return!0}function oD(X,Z,$){return!0}function nD(X,Z,$){return h0.IsVoidLike($)}function lD(X,Z,$){if(!t0.Has(X[q]))return!1;return t0.Get(X[q])(X,$)}function A2(X,Z,$){let Y=H0(X.$id)?D2(X,Z):Z,W=X;switch(W[q]){case"Any":return _D(W,Y,$);case"Argument":return OD(W,Y,$);case"Array":return ND(W,Y,$);case"AsyncIterator":return LD(W,Y,$);case"BigInt":return FD(W,Y,$);case"Boolean":return BD(W,Y,$);case"Constructor":return qD(W,Y,$);case"Date":return KD(W,Y,$);case"Function":return RD(W,Y,$);case"Import":return jD(W,Y,$);case"Integer":return SD(W,Y,$);case"Intersect":return VD(W,Y,$);case"Iterator":return ED(W,Y,$);case"Literal":return CD(W,Y,$);case"Never":return PD(W,Y,$);case"Not":return ID(W,Y,$);case"Null":return xD(W,Y,$);case"Number":return TD(W,Y,$);case"Object":return bD(W,Y,$);case"Promise":return kD(W,Y,$);case"Record":return gD(W,Y,$);case"Ref":return fD(W,Y,$);case"RegExp":return vD(W,Y,$);case"String":return yD(W,Y,$);case"Symbol":return dD(W,Y,$);case"TemplateLiteral":return hD(W,Y,$);case"This":return mD(W,Y,$);case"Tuple":return pD(W,Y,$);case"Undefined":return cD(W,Y,$);case"Union":return uD(W,Y,$);case"Uint8Array":return iD(W,Y,$);case"Unknown":return oD(W,Y,$);case"Void":return nD(W,Y,$);default:if(!t0.Has(W[q]))throw new RW(W);return lD(W,Y,$)}}function Q0(...X){return X.length===3?A2(X[0],X[1],X[2]):A2(X[0],[],X[1])}var R;(function(X){X[X.ArrayContains=0]="ArrayContains",X[X.ArrayMaxContains=1]="ArrayMaxContains",X[X.ArrayMaxItems=2]="ArrayMaxItems",X[X.ArrayMinContains=3]="ArrayMinContains",X[X.ArrayMinItems=4]="ArrayMinItems",X[X.ArrayUniqueItems=5]="ArrayUniqueItems",X[X.Array=6]="Array",X[X.AsyncIterator=7]="AsyncIterator",X[X.BigIntExclusiveMaximum=8]="BigIntExclusiveMaximum",X[X.BigIntExclusiveMinimum=9]="BigIntExclusiveMinimum",X[X.BigIntMaximum=10]="BigIntMaximum",X[X.BigIntMinimum=11]="BigIntMinimum",X[X.BigIntMultipleOf=12]="BigIntMultipleOf",X[X.BigInt=13]="BigInt",X[X.Boolean=14]="Boolean",X[X.DateExclusiveMaximumTimestamp=15]="DateExclusiveMaximumTimestamp",X[X.DateExclusiveMinimumTimestamp=16]="DateExclusiveMinimumTimestamp",X[X.DateMaximumTimestamp=17]="DateMaximumTimestamp",X[X.DateMinimumTimestamp=18]="DateMinimumTimestamp",X[X.DateMultipleOfTimestamp=19]="DateMultipleOfTimestamp",X[X.Date=20]="Date",X[X.Function=21]="Function",X[X.IntegerExclusiveMaximum=22]="IntegerExclusiveMaximum",X[X.IntegerExclusiveMinimum=23]="IntegerExclusiveMinimum",X[X.IntegerMaximum=24]="IntegerMaximum",X[X.IntegerMinimum=25]="IntegerMinimum",X[X.IntegerMultipleOf=26]="IntegerMultipleOf",X[X.Integer=27]="Integer",X[X.IntersectUnevaluatedProperties=28]="IntersectUnevaluatedProperties",X[X.Intersect=29]="Intersect",X[X.Iterator=30]="Iterator",X[X.Kind=31]="Kind",X[X.Literal=32]="Literal",X[X.Never=33]="Never",X[X.Not=34]="Not",X[X.Null=35]="Null",X[X.NumberExclusiveMaximum=36]="NumberExclusiveMaximum",X[X.NumberExclusiveMinimum=37]="NumberExclusiveMinimum",X[X.NumberMaximum=38]="NumberMaximum",X[X.NumberMinimum=39]="NumberMinimum",X[X.NumberMultipleOf=40]="NumberMultipleOf",X[X.Number=41]="Number",X[X.ObjectAdditionalProperties=42]="ObjectAdditionalProperties",X[X.ObjectMaxProperties=43]="ObjectMaxProperties",X[X.ObjectMinProperties=44]="ObjectMinProperties",X[X.ObjectRequiredProperty=45]="ObjectRequiredProperty",X[X.Object=46]="Object",X[X.Promise=47]="Promise",X[X.RegExp=48]="RegExp",X[X.StringFormatUnknown=49]="StringFormatUnknown",X[X.StringFormat=50]="StringFormat",X[X.StringMaxLength=51]="StringMaxLength",X[X.StringMinLength=52]="StringMinLength",X[X.StringPattern=53]="StringPattern",X[X.String=54]="String",X[X.Symbol=55]="Symbol",X[X.TupleLength=56]="TupleLength",X[X.Tuple=57]="Tuple",X[X.Uint8ArrayMaxByteLength=58]="Uint8ArrayMaxByteLength",X[X.Uint8ArrayMinByteLength=59]="Uint8ArrayMinByteLength",X[X.Uint8Array=60]="Uint8Array",X[X.Undefined=61]="Undefined",X[X.Union=62]="Union",X[X.Void=63]="Void"})(R||(R={}));class jW extends t{constructor(X){super("Unknown type");this.schema=X}}function _X(X){return X.replace(/~/g,"~0").replace(/\//g,"~1")}function D0(X){return X!==void 0}class z1{constructor(X){this.iterator=X}[Symbol.iterator](){return this.iterator}First(){let X=this.iterator.next();return X.done?void 0:X.value}}function d(X,Z,$,Y,W=[]){return{type:X,schema:Z,path:$,value:Y,message:NW()({errorType:X,path:$,schema:Z,value:Y,errors:W}),errors:W}}function*tD(X,Z,$,Y){}function*sD(X,Z,$,Y){}function*rD(X,Z,$,Y){if(!r(Y))return yield d(R.Array,X,$,Y);if(D0(X.minItems)&&!(Y.length>=X.minItems))yield d(R.ArrayMinItems,X,$,Y);if(D0(X.maxItems)&&!(Y.length<=X.maxItems))yield d(R.ArrayMaxItems,X,$,Y);for(let z=0;zw2(W,Z,`${$}${M}`,Q).next().done===!0?z+1:z,0);if(J===0)yield d(R.ArrayContains,X,$,Y);if(o(X.minContains)&&JX.maxContains)yield d(R.ArrayMaxContains,X,$,Y)}function*aD(X,Z,$,Y){if(!hZ(Y))yield d(R.AsyncIterator,X,$,Y)}function*eD(X,Z,$,Y){if(!O2(Y))return yield d(R.BigInt,X,$,Y);if(D0(X.exclusiveMaximum)&&!(YX.exclusiveMinimum))yield d(R.BigIntExclusiveMinimum,X,$,Y);if(D0(X.maximum)&&!(Y<=X.maximum))yield d(R.BigIntMaximum,X,$,Y);if(D0(X.minimum)&&!(Y>=X.minimum))yield d(R.BigIntMinimum,X,$,Y);if(D0(X.multipleOf)&&Y%X.multipleOf!==BigInt(0))yield d(R.BigIntMultipleOf,X,$,Y)}function*XA(X,Z,$,Y){if(!s8(Y))yield d(R.Boolean,X,$,Y)}function*ZA(X,Z,$,Y){yield*w2(X.returns,Z,$,Y.prototype)}function*$A(X,Z,$,Y){if(!I2(Y))return yield d(R.Date,X,$,Y);if(D0(X.exclusiveMaximumTimestamp)&&!(Y.getTime()X.exclusiveMinimumTimestamp))yield d(R.DateExclusiveMinimumTimestamp,X,$,Y);if(D0(X.maximumTimestamp)&&!(Y.getTime()<=X.maximumTimestamp))yield d(R.DateMaximumTimestamp,X,$,Y);if(D0(X.minimumTimestamp)&&!(Y.getTime()>=X.minimumTimestamp))yield d(R.DateMinimumTimestamp,X,$,Y);if(D0(X.multipleOfTimestamp)&&Y.getTime()%X.multipleOfTimestamp!==0)yield d(R.DateMultipleOfTimestamp,X,$,Y)}function*YA(X,Z,$,Y){if(!CX(Y))yield d(R.Function,X,$,Y)}function*WA(X,Z,$,Y){let W=globalThis.Object.values(X.$defs),J=X.$defs[X.$ref];yield*w2(J,[...Z,...W],$,Y)}function*JA(X,Z,$,Y){if(!cZ(Y))return yield d(R.Integer,X,$,Y);if(D0(X.exclusiveMaximum)&&!(YX.exclusiveMinimum))yield d(R.IntegerExclusiveMinimum,X,$,Y);if(D0(X.maximum)&&!(Y<=X.maximum))yield d(R.IntegerMaximum,X,$,Y);if(D0(X.minimum)&&!(Y>=X.minimum))yield d(R.IntegerMinimum,X,$,Y);if(D0(X.multipleOf)&&Y%X.multipleOf!==0)yield d(R.IntegerMultipleOf,X,$,Y)}function*zA(X,Z,$,Y){let W=!1;for(let J of X.allOf)for(let z of w2(J,Z,$,Y))W=!0,yield z;if(W)return yield d(R.Intersect,X,$,Y);if(X.unevaluatedProperties===!1){let J=new RegExp(AX(X));for(let z of Object.getOwnPropertyNames(Y))if(!J.test(z))yield d(R.IntersectUnevaluatedProperties,X,`${$}/${z}`,Y)}if(typeof X.unevaluatedProperties==="object"){let J=new RegExp(AX(X));for(let z of Object.getOwnPropertyNames(Y))if(!J.test(z)){let Q=w2(X.unevaluatedProperties,Z,`${$}/${z}`,Y[z]).next();if(!Q.done)yield Q.value}}}function*QA(X,Z,$,Y){if(!mZ(Y))yield d(R.Iterator,X,$,Y)}function*GA(X,Z,$,Y){if(Y!==X.const)yield d(R.Literal,X,$,Y)}function*MA(X,Z,$,Y){yield d(R.Never,X,$,Y)}function*UA(X,Z,$,Y){if(w2(X.not,Z,$,Y).next().done===!0)yield d(R.Not,X,$,Y)}function*HA(X,Z,$,Y){if(!zX(Y))yield d(R.Null,X,$,Y)}function*DA(X,Z,$,Y){if(!h0.IsNumberLike(Y))return yield d(R.Number,X,$,Y);if(D0(X.exclusiveMaximum)&&!(YX.exclusiveMinimum))yield d(R.NumberExclusiveMinimum,X,$,Y);if(D0(X.maximum)&&!(Y<=X.maximum))yield d(R.NumberMaximum,X,$,Y);if(D0(X.minimum)&&!(Y>=X.minimum))yield d(R.NumberMinimum,X,$,Y);if(D0(X.multipleOf)&&Y%X.multipleOf!==0)yield d(R.NumberMultipleOf,X,$,Y)}function*AA(X,Z,$,Y){if(!h0.IsObjectLike(Y))return yield d(R.Object,X,$,Y);if(D0(X.minProperties)&&!(Object.getOwnPropertyNames(Y).length>=X.minProperties))yield d(R.ObjectMinProperties,X,$,Y);if(D0(X.maxProperties)&&!(Object.getOwnPropertyNames(Y).length<=X.maxProperties))yield d(R.ObjectMaxProperties,X,$,Y);let W=Array.isArray(X.required)?X.required:[],J=Object.getOwnPropertyNames(X.properties),z=Object.getOwnPropertyNames(Y);for(let Q of W){if(z.includes(Q))continue;yield d(R.ObjectRequiredProperty,X.properties[Q],`${$}/${_X(Q)}`,void 0)}if(X.additionalProperties===!1){for(let Q of z)if(!J.includes(Q))yield d(R.ObjectAdditionalProperties,X,`${$}/${_X(Q)}`,Y[Q])}if(typeof X.additionalProperties==="object")for(let Q of z){if(J.includes(Q))continue;yield*w2(X.additionalProperties,Z,`${$}/${_X(Q)}`,Y[Q])}for(let Q of J){let M=X.properties[Q];if(X.required&&X.required.includes(Q)){if(yield*w2(M,Z,`${$}/${_X(Q)}`,Y[Q]),wX(X)&&!(Q in Y))yield d(R.ObjectRequiredProperty,M,`${$}/${_X(Q)}`,void 0)}else if(h0.IsExactOptionalProperty(Y,Q))yield*w2(M,Z,`${$}/${_X(Q)}`,Y[Q])}}function*wA(X,Z,$,Y){if(!pZ(Y))yield d(R.Promise,X,$,Y)}function*_A(X,Z,$,Y){if(!h0.IsRecordLike(Y))return yield d(R.Object,X,$,Y);if(D0(X.minProperties)&&!(Object.getOwnPropertyNames(Y).length>=X.minProperties))yield d(R.ObjectMinProperties,X,$,Y);if(D0(X.maxProperties)&&!(Object.getOwnPropertyNames(Y).length<=X.maxProperties))yield d(R.ObjectMaxProperties,X,$,Y);let[W,J]=Object.entries(X.patternProperties)[0],z=new RegExp(W);for(let[Q,M]of Object.entries(Y))if(z.test(Q))yield*w2(J,Z,`${$}/${_X(Q)}`,M);if(typeof X.additionalProperties==="object"){for(let[Q,M]of Object.entries(Y))if(!z.test(Q))yield*w2(X.additionalProperties,Z,`${$}/${_X(Q)}`,M)}if(X.additionalProperties===!1)for(let[Q,M]of Object.entries(Y)){if(z.test(Q))continue;return yield d(R.ObjectAdditionalProperties,X,`${$}/${_X(Q)}`,M)}}function*OA(X,Z,$,Y){yield*w2(B0(X,Z),Z,$,Y)}function*NA(X,Z,$,Y){if(!N0(Y))return yield d(R.String,X,$,Y);if(D0(X.minLength)&&!(Y.length>=X.minLength))yield d(R.StringMinLength,X,$,Y);if(D0(X.maxLength)&&!(Y.length<=X.maxLength))yield d(R.StringMaxLength,X,$,Y);if(!new RegExp(X.source,X.flags).test(Y))return yield d(R.RegExp,X,$,Y)}function*LA(X,Z,$,Y){if(!N0(Y))return yield d(R.String,X,$,Y);if(D0(X.minLength)&&!(Y.length>=X.minLength))yield d(R.StringMinLength,X,$,Y);if(D0(X.maxLength)&&!(Y.length<=X.maxLength))yield d(R.StringMaxLength,X,$,Y);if(N0(X.pattern)){if(!new RegExp(X.pattern).test(Y))yield d(R.StringPattern,X,$,Y)}if(N0(X.format)){if(!C0.Has(X.format))yield d(R.StringFormatUnknown,X,$,Y);else if(!C0.Get(X.format)(Y))yield d(R.StringFormat,X,$,Y)}}function*FA(X,Z,$,Y){if(!QX(Y))yield d(R.Symbol,X,$,Y)}function*BA(X,Z,$,Y){if(!N0(Y))return yield d(R.String,X,$,Y);if(!new RegExp(X.pattern).test(Y))yield d(R.StringPattern,X,$,Y)}function*qA(X,Z,$,Y){yield*w2(B0(X,Z),Z,$,Y)}function*KA(X,Z,$,Y){if(!r(Y))return yield d(R.Tuple,X,$,Y);if(X.items===void 0&&Y.length!==0)return yield d(R.TupleLength,X,$,Y);if(Y.length!==X.maxItems)return yield d(R.TupleLength,X,$,Y);if(!X.items)return;for(let W=0;Wnew z1(w2(J,Z,$,Y)));yield d(R.Union,X,$,Y,W)}function*SA(X,Z,$,Y){if(!F1(Y))return yield d(R.Uint8Array,X,$,Y);if(D0(X.maxByteLength)&&!(Y.length<=X.maxByteLength))yield d(R.Uint8ArrayMaxByteLength,X,$,Y);if(D0(X.minByteLength)&&!(Y.length>=X.minByteLength))yield d(R.Uint8ArrayMinByteLength,X,$,Y)}function*VA(X,Z,$,Y){}function*EA(X,Z,$,Y){if(!h0.IsVoidLike(Y))yield d(R.Void,X,$,Y)}function*CA(X,Z,$,Y){if(!t0.Get(X[q])(X,Y))yield d(R.Kind,X,$,Y)}function*w2(X,Z,$,Y){let W=D0(X.$id)?[...Z,X]:Z,J=X;switch(J[q]){case"Any":return yield*tD(J,W,$,Y);case"Argument":return yield*sD(J,W,$,Y);case"Array":return yield*rD(J,W,$,Y);case"AsyncIterator":return yield*aD(J,W,$,Y);case"BigInt":return yield*eD(J,W,$,Y);case"Boolean":return yield*XA(J,W,$,Y);case"Constructor":return yield*ZA(J,W,$,Y);case"Date":return yield*$A(J,W,$,Y);case"Function":return yield*YA(J,W,$,Y);case"Import":return yield*WA(J,W,$,Y);case"Integer":return yield*JA(J,W,$,Y);case"Intersect":return yield*zA(J,W,$,Y);case"Iterator":return yield*QA(J,W,$,Y);case"Literal":return yield*GA(J,W,$,Y);case"Never":return yield*MA(J,W,$,Y);case"Not":return yield*UA(J,W,$,Y);case"Null":return yield*HA(J,W,$,Y);case"Number":return yield*DA(J,W,$,Y);case"Object":return yield*AA(J,W,$,Y);case"Promise":return yield*wA(J,W,$,Y);case"Record":return yield*_A(J,W,$,Y);case"Ref":return yield*OA(J,W,$,Y);case"RegExp":return yield*NA(J,W,$,Y);case"String":return yield*LA(J,W,$,Y);case"Symbol":return yield*FA(J,W,$,Y);case"TemplateLiteral":return yield*BA(J,W,$,Y);case"This":return yield*qA(J,W,$,Y);case"Tuple":return yield*KA(J,W,$,Y);case"Undefined":return yield*RA(J,W,$,Y);case"Union":return yield*jA(J,W,$,Y);case"Uint8Array":return yield*SA(J,W,$,Y);case"Unknown":return yield*VA(J,W,$,Y);case"Void":return yield*EA(J,W,$,Y);default:if(!t0.Has(J[q]))throw new jW(X);return yield*CA(J,W,$,Y)}}function ZX(...X){let Z=X.length===3?w2(X[0],X[1],"",X[2]):w2(X[0],[],"",X[1]);return new z1(Z)}class AZ extends t{constructor(X,Z,$){super("Unable to decode value as it does not match the expected schema");this.schema=X,this.value=Z,this.error=$}}class D$ extends t{constructor(X,Z,$,Y){super(Y instanceof Error?Y.message:"Unknown error");this.schema=X,this.path=Z,this.value=$,this.error=Y}}function n0(X,Z,$){try{return R0(X)?X[k0].Decode($):$}catch(Y){throw new D$(X,Z,$,Y)}}function PA(X,Z,$,Y){return r(Y)?n0(X,$,Y.map((W,J)=>v8(X.items,Z,`${$}/${J}`,W))):n0(X,$,Y)}function IA(X,Z,$,Y){if(!J0(Y)||a2(Y))return n0(X,$,Y);let W=aZ(X),J=W.map((U)=>U[0]),z={...Y};for(let[U,w]of W)if(U in z)z[U]=v8(w,Z,`${$}/${U}`,z[U]);if(!R0(X.unevaluatedProperties))return n0(X,$,z);let Q=Object.getOwnPropertyNames(z),M=X.unevaluatedProperties,G={...z};for(let U of Q)if(!J.includes(U))G[U]=n0(M,`${$}/${U}`,G[U]);return n0(X,$,G)}function xA(X,Z,$,Y){let W=globalThis.Object.values(X.$defs),J=X.$defs[X.$ref],z=v8(J,[...Z,...W],$,Y);return n0(X,$,z)}function TA(X,Z,$,Y){return n0(X,$,v8(X.not,Z,$,Y))}function bA(X,Z,$,Y){if(!J0(Y))return n0(X,$,Y);let W=d2(X),J={...Y};for(let G of W){if(!s(J,G))continue;if(c0(J[G])&&(!UX(X.properties[G])||h0.IsExactOptionalProperty(J,G)))continue;J[G]=v8(X.properties[G],Z,`${$}/${G}`,J[G])}if(!o0(X.additionalProperties))return n0(X,$,J);let z=Object.getOwnPropertyNames(J),Q=X.additionalProperties,M={...J};for(let G of z)if(!W.includes(G))M[G]=n0(Q,`${$}/${G}`,M[G]);return n0(X,$,M)}function kA(X,Z,$,Y){if(!J0(Y))return n0(X,$,Y);let W=Object.getOwnPropertyNames(X.patternProperties)[0],J=new RegExp(W),z={...Y};for(let U of Object.getOwnPropertyNames(Y))if(J.test(U))z[U]=v8(X.patternProperties[W],Z,`${$}/${U}`,z[U]);if(!o0(X.additionalProperties))return n0(X,$,z);let Q=Object.getOwnPropertyNames(z),M=X.additionalProperties,G={...z};for(let U of Q)if(!J.test(U))G[U]=n0(M,`${$}/${U}`,G[U]);return n0(X,$,G)}function gA(X,Z,$,Y){let W=B0(X,Z);return n0(X,$,v8(W,Z,$,Y))}function fA(X,Z,$,Y){let W=B0(X,Z);return n0(X,$,v8(W,Z,$,Y))}function vA(X,Z,$,Y){return r(Y)&&r(X.items)?n0(X,$,X.items.map((W,J)=>v8(W,Z,`${$}/${J}`,Y[J]))):n0(X,$,Y)}function yA(X,Z,$,Y){for(let W of X.anyOf){if(!Q0(W,Z,Y))continue;let J=v8(W,Z,$,Y);return n0(X,$,J)}return n0(X,$,Y)}function v8(X,Z,$,Y){let W=D2(X,Z),J=X;switch(X[q]){case"Array":return PA(J,W,$,Y);case"Import":return xA(J,W,$,Y);case"Intersect":return IA(J,W,$,Y);case"Not":return TA(J,W,$,Y);case"Object":return bA(J,W,$,Y);case"Record":return kA(J,W,$,Y);case"Ref":return gA(J,W,$,Y);case"Symbol":return n0(J,$,Y);case"This":return fA(J,W,$,Y);case"Tuple":return vA(J,W,$,Y);case"Union":return yA(J,W,$,Y);default:return n0(J,$,Y)}}function m1(X,Z,$){return v8(X,Z,"",$)}class wZ extends t{constructor(X,Z,$){super("The encoded value does not match the expected schema");this.schema=X,this.value=Z,this.error=$}}class SW extends t{constructor(X,Z,$,Y){super(`${Y instanceof Error?Y.message:"Unknown error"}`);this.schema=X,this.path=Z,this.value=$,this.error=Y}}function L2(X,Z,$){try{return R0(X)?X[k0].Encode($):$}catch(Y){throw new SW(X,Z,$,Y)}}function dA(X,Z,$,Y){let W=L2(X,$,Y);return r(W)?W.map((J,z)=>y8(X.items,Z,`${$}/${z}`,J)):W}function hA(X,Z,$,Y){let W=globalThis.Object.values(X.$defs),J=X.$defs[X.$ref],z=L2(X,$,Y);return y8(J,[...Z,...W],$,z)}function mA(X,Z,$,Y){let W=L2(X,$,Y);if(!J0(Y)||a2(Y))return W;let J=aZ(X),z=J.map((w)=>w[0]),Q={...W};for(let[w,B]of J)if(w in Q)Q[w]=y8(B,Z,`${$}/${w}`,Q[w]);if(!R0(X.unevaluatedProperties))return Q;let M=Object.getOwnPropertyNames(Q),G=X.unevaluatedProperties,U={...Q};for(let w of M)if(!z.includes(w))U[w]=L2(G,`${$}/${w}`,U[w]);return U}function pA(X,Z,$,Y){return L2(X.not,$,L2(X,$,Y))}function cA(X,Z,$,Y){let W=L2(X,$,Y);if(!J0(W))return W;let J=d2(X),z={...W};for(let U of J){if(!s(z,U))continue;if(c0(z[U])&&(!UX(X.properties[U])||h0.IsExactOptionalProperty(z,U)))continue;z[U]=y8(X.properties[U],Z,`${$}/${U}`,z[U])}if(!o0(X.additionalProperties))return z;let Q=Object.getOwnPropertyNames(z),M=X.additionalProperties,G={...z};for(let U of Q)if(!J.includes(U))G[U]=L2(M,`${$}/${U}`,G[U]);return G}function uA(X,Z,$,Y){let W=L2(X,$,Y);if(!J0(Y))return W;let J=Object.getOwnPropertyNames(X.patternProperties)[0],z=new RegExp(J),Q={...W};for(let w of Object.getOwnPropertyNames(Y))if(z.test(w))Q[w]=y8(X.patternProperties[J],Z,`${$}/${w}`,Q[w]);if(!o0(X.additionalProperties))return Q;let M=Object.getOwnPropertyNames(Q),G=X.additionalProperties,U={...Q};for(let w of M)if(!z.test(w))U[w]=L2(G,`${$}/${w}`,U[w]);return U}function iA(X,Z,$,Y){let W=B0(X,Z),J=y8(W,Z,$,Y);return L2(X,$,J)}function oA(X,Z,$,Y){let W=B0(X,Z),J=y8(W,Z,$,Y);return L2(X,$,J)}function nA(X,Z,$,Y){let W=L2(X,$,Y);return r(X.items)?X.items.map((J,z)=>y8(J,Z,`${$}/${z}`,W[z])):[]}function lA(X,Z,$,Y){for(let W of X.anyOf){if(!Q0(W,Z,Y))continue;let J=y8(W,Z,$,Y);return L2(X,$,J)}for(let W of X.anyOf){let J=y8(W,Z,$,Y);if(!Q0(X,Z,J))continue;return L2(X,$,J)}return L2(X,$,Y)}function y8(X,Z,$,Y){let W=D2(X,Z),J=X;switch(X[q]){case"Array":return dA(J,W,$,Y);case"Import":return hA(J,W,$,Y);case"Intersect":return mA(J,W,$,Y);case"Not":return pA(J,W,$,Y);case"Object":return cA(J,W,$,Y);case"Record":return uA(J,W,$,Y);case"Ref":return iA(J,W,$,Y);case"This":return oA(J,W,$,Y);case"Tuple":return nA(J,W,$,Y);case"Union":return lA(J,W,$,Y);default:return L2(J,$,Y)}}function p1(X,Z,$){return y8(X,Z,"",$)}function tA(X,Z){return R0(X)||Q2(X.items,Z)}function sA(X,Z){return R0(X)||Q2(X.items,Z)}function rA(X,Z){return R0(X)||Q2(X.returns,Z)||X.parameters.some(($)=>Q2($,Z))}function aA(X,Z){return R0(X)||Q2(X.returns,Z)||X.parameters.some(($)=>Q2($,Z))}function eA(X,Z){return R0(X)||R0(X.unevaluatedProperties)||X.allOf.some(($)=>Q2($,Z))}function Xw(X,Z){let $=globalThis.Object.getOwnPropertyNames(X.$defs).reduce((W,J)=>[...W,X.$defs[J]],[]),Y=X.$defs[X.$ref];return R0(X)||Q2(Y,[...$,...Z])}function Zw(X,Z){return R0(X)||Q2(X.items,Z)}function $w(X,Z){return R0(X)||Q2(X.not,Z)}function Yw(X,Z){return R0(X)||Object.values(X.properties).some(($)=>Q2($,Z))||o0(X.additionalProperties)&&Q2(X.additionalProperties,Z)}function Ww(X,Z){return R0(X)||Q2(X.item,Z)}function Jw(X,Z){let $=Object.getOwnPropertyNames(X.patternProperties)[0],Y=X.patternProperties[$];return R0(X)||Q2(Y,Z)||o0(X.additionalProperties)&&R0(X.additionalProperties)}function zw(X,Z){if(R0(X))return!0;return Q2(B0(X,Z),Z)}function Qw(X,Z){if(R0(X))return!0;return Q2(B0(X,Z),Z)}function Gw(X,Z){return R0(X)||!c0(X.items)&&X.items.some(($)=>Q2($,Z))}function Mw(X,Z){return R0(X)||X.anyOf.some(($)=>Q2($,Z))}function Q2(X,Z){let $=D2(X,Z),Y=X;if(X.$id&&vY.has(X.$id))return!1;if(X.$id)vY.add(X.$id);switch(X[q]){case"Array":return tA(Y,$);case"AsyncIterator":return sA(Y,$);case"Constructor":return rA(Y,$);case"Function":return aA(Y,$);case"Import":return Xw(Y,$);case"Intersect":return eA(Y,$);case"Iterator":return Zw(Y,$);case"Not":return $w(Y,$);case"Object":return Yw(Y,$);case"Promise":return Ww(Y,$);case"Record":return Jw(Y,$);case"Ref":return zw(Y,$);case"This":return Qw(Y,$);case"Tuple":return Gw(Y,$);case"Union":return Mw(Y,$);default:return R0(X)}}var vY=new Set;function OX(X,Z){return vY.clear(),Q2(X,Z)}class VW{constructor(X,Z,$,Y){this.schema=X,this.references=Z,this.checkFunc=$,this.code=Y,this.hasTransform=OX(X,Z)}Code(){return this.code}Schema(){return this.schema}References(){return this.references}Errors(X){return ZX(this.schema,this.references,X)}Check(X){return this.checkFunc(X)}Decode(X){if(!this.checkFunc(X))throw new AZ(this.schema,X,this.Errors(X).First());return this.hasTransform?m1(this.schema,this.references,X):X}Encode(X){let Z=this.hasTransform?p1(this.schema,this.references,X):X;if(!this.checkFunc(Z))throw new wZ(this.schema,X,this.Errors(X).First());return Z}}var NX;(function(X){function Z(J){return J===36}X.DollarSign=Z;function $(J){return J===95}X.IsUnderscore=$;function Y(J){return J>=65&&J<=90||J>=97&&J<=122}X.IsAlpha=Y;function W(J){return J>=48&&J<=57}X.IsNumeric=W})(NX||(NX={}));var A$;(function(X){function Z(J){if(J.length===0)return!1;return NX.IsNumeric(J.charCodeAt(0))}function $(J){if(Z(J))return!1;for(let z=0;z= ${D.minItems}`;let c=s2(D.items,T,"value");if(yield`${F}.every((${p}) => ${c})`,i0(D.contains)||o(D.minContains)||o(D.maxContains)){let T0=i0(D.contains)?D.contains:Y0(),g2=s2(T0,T,"value"),YX=o(D.minContains)?[`(count >= ${D.minContains})`]:[],V8=o(D.maxContains)?[`(count <= ${D.maxContains})`]:[],t8=`const count = value.reduce((${y}, ${p}) => ${g2} ? acc + 1 : acc, 0)`,fZ=["(count > 0)",...YX,...V8].join(" && ");yield`((${p}) => { ${t8}; return ${fZ}})(${F})`}if(D.uniqueItems===!0)yield`((${p}) => { 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 } )(${F})`}function*J(D,T,F){yield`(typeof value === 'object' && Symbol.asyncIterator in ${F})`}function*z(D,T,F){if(yield`(typeof ${F} === 'bigint')`,O2(D.exclusiveMaximum))yield`${F} < BigInt(${D.exclusiveMaximum})`;if(O2(D.exclusiveMinimum))yield`${F} > BigInt(${D.exclusiveMinimum})`;if(O2(D.maximum))yield`${F} <= BigInt(${D.maximum})`;if(O2(D.minimum))yield`${F} >= BigInt(${D.minimum})`;if(O2(D.multipleOf))yield`(${F} % BigInt(${D.multipleOf})) === 0`}function*Q(D,T,F){yield`(typeof ${F} === 'boolean')`}function*M(D,T,F){yield*j8(D.returns,T,`${F}.prototype`)}function*G(D,T,F){if(yield`(${F} instanceof Date) && Number.isFinite(${F}.getTime())`,o(D.exclusiveMaximumTimestamp))yield`${F}.getTime() < ${D.exclusiveMaximumTimestamp}`;if(o(D.exclusiveMinimumTimestamp))yield`${F}.getTime() > ${D.exclusiveMinimumTimestamp}`;if(o(D.maximumTimestamp))yield`${F}.getTime() <= ${D.maximumTimestamp}`;if(o(D.minimumTimestamp))yield`${F}.getTime() >= ${D.minimumTimestamp}`;if(o(D.multipleOfTimestamp))yield`(${F}.getTime() % ${D.multipleOfTimestamp}) === 0`}function*U(D,T,F){yield`(typeof ${F} === 'function')`}function*w(D,T,F){let p=globalThis.Object.getOwnPropertyNames(D.$defs).reduce((y,c)=>{return[...y,D.$defs[c]]},[]);yield*j8(D8(D.$ref),[...T,...p],F)}function*B(D,T,F){if(yield`Number.isInteger(${F})`,o(D.exclusiveMaximum))yield`${F} < ${D.exclusiveMaximum}`;if(o(D.exclusiveMinimum))yield`${F} > ${D.exclusiveMinimum}`;if(o(D.maximum))yield`${F} <= ${D.maximum}`;if(o(D.minimum))yield`${F} >= ${D.minimum}`;if(o(D.multipleOf))yield`(${F} % ${D.multipleOf}) === 0`}function*N(D,T,F){let p=D.allOf.map((y)=>s2(y,T,F)).join(" && ");if(D.unevaluatedProperties===!1){let y=VX(`${new RegExp(AX(D))};`),c=`Object.getOwnPropertyNames(${F}).every(key => ${y}.test(key))`;yield`(${p} && ${c})`}else if(i0(D.unevaluatedProperties)){let y=VX(`${new RegExp(AX(D))};`),c=`Object.getOwnPropertyNames(${F}).every(key => ${y}.test(key) || ${s2(D.unevaluatedProperties,T,`${F}[key]`)})`;yield`(${p} && ${c})`}else yield`(${p})`}function*j(D,T,F){yield`(typeof value === 'object' && Symbol.iterator in ${F})`}function*H(D,T,F){if(typeof D.const==="number"||typeof D.const==="boolean")yield`(${F} === ${D.const})`;else yield`(${F} === '${dY.Escape(D.const)}')`}function*K(D,T,F){yield"false"}function*k(D,T,F){yield`(!${s2(D.not,T,F)})`}function*l(D,T,F){yield`(${F} === null)`}function*n(D,T,F){if(yield Q1.IsNumberLike(F),o(D.exclusiveMaximum))yield`${F} < ${D.exclusiveMaximum}`;if(o(D.exclusiveMinimum))yield`${F} > ${D.exclusiveMinimum}`;if(o(D.maximum))yield`${F} <= ${D.maximum}`;if(o(D.minimum))yield`${F} >= ${D.minimum}`;if(o(D.multipleOf))yield`(${F} % ${D.multipleOf}) === 0`}function*A0(D,T,F){if(yield Q1.IsObjectLike(F),o(D.minProperties))yield`Object.getOwnPropertyNames(${F}).length >= ${D.minProperties}`;if(o(D.maxProperties))yield`Object.getOwnPropertyNames(${F}).length <= ${D.maxProperties}`;let p=Object.getOwnPropertyNames(D.properties);for(let y of p){let c=A$.Encode(F,y),T0=D.properties[y];if(D.required&&D.required.includes(y)){if(yield*j8(T0,T,c),wX(T0)||Z(T0))yield`('${y}' in ${F})`}else{let g2=s2(T0,T,c);yield Q1.IsExactOptionalProperty(F,y,g2)}}if(D.additionalProperties===!1)if(D.required&&D.required.length===p.length)yield`Object.getOwnPropertyNames(${F}).length === ${p.length}`;else{let y=`[${p.map((c)=>`'${c}'`).join(", ")}]`;yield`Object.getOwnPropertyNames(${F}).every(key => ${y}.includes(key))`}if(typeof D.additionalProperties==="object"){let y=s2(D.additionalProperties,T,`${F}[key]`),c=`[${p.map((T0)=>`'${T0}'`).join(", ")}]`;yield`(Object.getOwnPropertyNames(${F}).every(key => ${c}.includes(key) || ${y}))`}}function*Z0(D,T,F){yield`${F} instanceof Promise`}function*I(D,T,F){if(yield Q1.IsRecordLike(F),o(D.minProperties))yield`Object.getOwnPropertyNames(${F}).length >= ${D.minProperties}`;if(o(D.maxProperties))yield`Object.getOwnPropertyNames(${F}).length <= ${D.maxProperties}`;let[p,y]=Object.entries(D.patternProperties)[0],c=VX(`${new RegExp(p)}`),T0=s2(y,T,"value"),g2=i0(D.additionalProperties)?s2(D.additionalProperties,T,F):D.additionalProperties===!1?"false":"true",YX=`(${c}.test(key) ? ${T0} : ${g2})`;yield`(Object.entries(${F}).every(([key, value]) => ${YX}))`}function*P(D,T,F){let p=B0(D,T);if(E0.functions.has(D.$ref))return yield`${SX(D.$ref)}(${F})`;yield*j8(p,T,F)}function*g(D,T,F){let p=VX(`${new RegExp(D.source,D.flags)};`);if(yield`(typeof ${F} === 'string')`,o(D.maxLength))yield`${F}.length <= ${D.maxLength}`;if(o(D.minLength))yield`${F}.length >= ${D.minLength}`;yield`${p}.test(${F})`}function*b(D,T,F){if(yield`(typeof ${F} === 'string')`,o(D.maxLength))yield`${F}.length <= ${D.maxLength}`;if(o(D.minLength))yield`${F}.length >= ${D.minLength}`;if(D.pattern!==void 0)yield`${VX(`${new RegExp(D.pattern)};`)}.test(${F})`;if(D.format!==void 0)yield`format('${D.format}', ${F})`}function*W0(D,T,F){yield`(typeof ${F} === 'symbol')`}function*z0(D,T,F){yield`(typeof ${F} === 'string')`,yield`${VX(`${new RegExp(D.pattern)};`)}.test(${F})`}function*$0(D,T,F){yield`${SX(D.$ref)}(${F})`}function*U0(D,T,F){if(yield`Array.isArray(${F})`,D.items===void 0)return yield`${F}.length === 0`;yield`(${F}.length === ${D.maxItems})`;for(let p=0;ps2(y,T,F)).join(" || ")})`}function*l8(D,T,F){if(yield`${F} instanceof Uint8Array`,o(D.maxByteLength))yield`(${F}.length <= ${D.maxByteLength})`;if(o(D.minByteLength))yield`(${F}.length >= ${D.minByteLength})`}function*P2(D,T,F){yield"true"}function*tX(D,T,F){yield Q1.IsVoidLike(F)}function*QY(D,T,F){let p=E0.instances.size;E0.instances.set(p,D),yield`kind('${D[q]}', ${p}, ${F})`}function*j8(D,T,F,p=!0){let y=N0(D.$id)?[...T,D]:T,c=D;if(p&&N0(D.$id)){let T0=SX(D.$id);if(E0.functions.has(T0))return yield`${T0}(${F})`;else{E0.functions.set(T0,"");let g2=S8(T0,D,T,"value",!1);return E0.functions.set(T0,g2),yield`${T0}(${F})`}}switch(c[q]){case"Any":return yield*$(c,y,F);case"Argument":return yield*Y(c,y,F);case"Array":return yield*W(c,y,F);case"AsyncIterator":return yield*J(c,y,F);case"BigInt":return yield*z(c,y,F);case"Boolean":return yield*Q(c,y,F);case"Constructor":return yield*M(c,y,F);case"Date":return yield*G(c,y,F);case"Function":return yield*U(c,y,F);case"Import":return yield*w(c,y,F);case"Integer":return yield*B(c,y,F);case"Intersect":return yield*N(c,y,F);case"Iterator":return yield*j(c,y,F);case"Literal":return yield*H(c,y,F);case"Never":return yield*K(c,y,F);case"Not":return yield*k(c,y,F);case"Null":return yield*l(c,y,F);case"Number":return yield*n(c,y,F);case"Object":return yield*A0(c,y,F);case"Promise":return yield*Z0(c,y,F);case"Record":return yield*I(c,y,F);case"Ref":return yield*P(c,y,F);case"RegExp":return yield*g(c,y,F);case"String":return yield*b(c,y,F);case"Symbol":return yield*W0(c,y,F);case"TemplateLiteral":return yield*z0(c,y,F);case"This":return yield*$0(c,y,F);case"Tuple":return yield*U0(c,y,F);case"Undefined":return yield*H2(c,y,F);case"Union":return yield*d0(c,y,F);case"Uint8Array":return yield*l8(c,y,F);case"Unknown":return yield*P2(c,y,F);case"Void":return yield*tX(c,y,F);default:if(!t0.Has(c[q]))throw new EW(D);return yield*QY(c,y,F)}}let E0={language:"javascript",functions:new Map,variables:new Map,instances:new Map};function s2(D,T,F,p=!0){return`(${[...j8(D,T,F,p)].join(" && ")})`}function SX(D){return`check_${yY.Encode(D)}`}function VX(D){let T=`local_${E0.variables.size}`;return E0.variables.set(T,`const ${T} = ${D}`),T}function S8(D,T,F,p,y=!0){let[c,T0]=[` -`,(t8)=>"".padStart(t8," ")],g2=f("value","any"),YX=C("boolean"),V8=[...j8(T,F,p,y)].map((t8)=>`${T0(4)}${t8}`).join(` &&${c}`);return`function ${D}(${g2})${YX} {${c}${T0(2)}return (${c}${V8}${c}${T0(2)}) -}`}function f(D,T){let F=E0.language==="typescript"?`: ${T}`:"";return`${D}${F}`}function C(D){return E0.language==="typescript"?`: ${D}`:""}function x(D,T,F){let p=S8("check",D,T,"value"),y=f("value","any"),c=C("boolean"),T0=[...E0.functions.values()],g2=[...E0.variables.values()],YX=N0(D.$id)?`return function check(${y})${c} { - return ${SX(D.$id)}(value) -}`:`return ${p}`;return[...g2,...T0,YX].join(` -`)}function u(...D){let T={language:"javascript"},[F,p,y]=D.length===2&&r(D[1])?[D[0],D[1],T]:D.length===2&&!r(D[1])?[D[0],[],D[1]]:D.length===3?[D[0],D[1],D[2]]:D.length===1?[D[0],[],T]:[null,[],T];if(E0.language=y.language,E0.variables.clear(),E0.functions.clear(),E0.instances.clear(),!i0(F))throw new hY(F);for(let c of p)if(!i0(c))throw new hY(c);return x(F,p,y)}X.Code=u;function a(D,T=[]){let F=u(D,T,{language:"javascript"}),p=globalThis.Function("kind","format","hash",F),y=new Map(E0.instances);function c(V8,t8,fZ){if(!t0.Has(V8)||!y.has(t8))return!1;let rz=t0.Get(V8),az=y.get(t8);return rz(az,fZ)}function T0(V8,t8){if(!C0.Has(V8))return!1;return C0.Get(V8)(t8)}function g2(V8){return fX(V8)}let YX=p(c,T0,g2);return new VW(D,T,YX,F)}X.Compile=a})(vX||(vX={}));var Uw=function(X,Z,$,Y,W){if(Y==="m")throw new TypeError("Private method is not writable");if(Y==="a"&&!W)throw new TypeError("Private accessor was defined without a setter");if(typeof Z==="function"?X!==Z||!W:!Z.has(X))throw new TypeError("Cannot write private member to an object whose class did not declare it");return Y==="a"?W.call(X,$):W?W.value=$:Z.set(X,$),$},PW=function(X,Z,$,Y){if($==="a"&&!Y)throw new TypeError("Private accessor was defined without a getter");if(typeof Z==="function"?X!==Z||!Y:!Z.has(X))throw new TypeError("Cannot read private member from an object whose class did not declare it");return $==="m"?Y:$==="a"?Y.call(X):Y?Y.value:Z.get(X)},mY,w$,IW;class xW extends t{constructor(X){let Z=X.First();super(Z===void 0?"Invalid Value":Z.message);mY.add(this),w$.set(this,void 0),Uw(this,w$,X,"f"),this.error=Z}Errors(){return new z1(PW(this,mY,"m",IW).call(this))}}w$=new WeakMap,mY=new WeakSet,IW=function*X(){if(this.error)yield this.error;yield*PW(this,w$,"f")};function CW(X,Z,$){if(Q0(X,Z,$))return;throw new xW(ZX(X,Z,$))}function _$(...X){return X.length===3?CW(X[0],X[1],X[2]):CW(X[0],[],X[1])}function Hw(X){let Z={};for(let $ of Object.getOwnPropertyNames(X))Z[$]=q0(X[$]);for(let $ of Object.getOwnPropertySymbols(X))Z[$]=q0(X[$]);return Z}function Dw(X){return X.map((Z)=>q0(Z))}function Aw(X){return X.slice()}function ww(X){return new Map(q0([...X.entries()]))}function _w(X){return new Set(q0([...X.entries()]))}function Ow(X){return new Date(X.toISOString())}function Nw(X){return X}function q0(X){if(r(X))return Dw(X);if(I2(X))return Ow(X);if(Q8(X))return Aw(X);if(t6(X))return ww(X);if(s6(X))return _w(X);if(J0(X))return Hw(X);if(a2(X))return Nw(X);throw new Error("ValueClone: Unable to clone value")}class _8 extends t{constructor(X,Z){super(Z);this.schema=X}}function K0(X){return CX(X)?X():q0(X)}function Lw(X,Z){if(s(X,"default"))return K0(X.default);else return{}}function Fw(X,Z){return{}}function Bw(X,Z){if(X.uniqueItems===!0&&!s(X,"default"))throw new _8(X,"Array with the uniqueItems constraint requires a default value");else if("contains"in X&&!s(X,"default"))throw new _8(X,"Array with the contains constraint requires a default value");else if("default"in X)return K0(X.default);else if(X.minItems!==void 0)return Array.from({length:X.minItems}).map(($)=>{return m2(X.items,Z)});else return[]}function qw(X,Z){if(s(X,"default"))return K0(X.default);else return async function*(){}()}function Kw(X,Z){if(s(X,"default"))return K0(X.default);else return BigInt(0)}function Rw(X,Z){if(s(X,"default"))return K0(X.default);else return!1}function jw(X,Z){if(s(X,"default"))return K0(X.default);else{let $=m2(X.returns,Z);if(typeof $==="object"&&!Array.isArray($))return class{constructor(){for(let[Y,W]of Object.entries($)){let J=this;J[Y]=W}}};else return class{}}}function Sw(X,Z){if(s(X,"default"))return K0(X.default);else if(X.minimumTimestamp!==void 0)return new Date(X.minimumTimestamp);else return new Date}function Vw(X,Z){if(s(X,"default"))return K0(X.default);else return()=>m2(X.returns,Z)}function Ew(X,Z){let $=globalThis.Object.values(X.$defs),Y=X.$defs[X.$ref];return m2(Y,[...Z,...$])}function Cw(X,Z){if(s(X,"default"))return K0(X.default);else if(X.minimum!==void 0)return X.minimum;else return 0}function Pw(X,Z){if(s(X,"default"))return K0(X.default);else{let $=X.allOf.reduce((Y,W)=>{let J=m2(W,Z);return typeof J==="object"?{...Y,...J}:J},{});if(!Q0(X,Z,$))throw new _8(X,"Intersect produced invalid value. Consider using a default value.");return $}}function Iw(X,Z){if(s(X,"default"))return K0(X.default);else return function*(){}()}function xw(X,Z){if(s(X,"default"))return K0(X.default);else return X.const}function Tw(X,Z){if(s(X,"default"))return K0(X.default);else throw new _8(X,"Never types cannot be created. Consider using a default value.")}function bw(X,Z){if(s(X,"default"))return K0(X.default);else throw new _8(X,"Not types must have a default value")}function kw(X,Z){if(s(X,"default"))return K0(X.default);else return null}function gw(X,Z){if(s(X,"default"))return K0(X.default);else if(X.minimum!==void 0)return X.minimum;else return 0}function fw(X,Z){if(s(X,"default"))return K0(X.default);else{let $=new Set(X.required),Y={};for(let[W,J]of Object.entries(X.properties)){if(!$.has(W))continue;Y[W]=m2(J,Z)}return Y}}function vw(X,Z){if(s(X,"default"))return K0(X.default);else return Promise.resolve(m2(X.item,Z))}function yw(X,Z){let[$,Y]=Object.entries(X.patternProperties)[0];if(s(X,"default"))return K0(X.default);else if(!($===a8||$===r8)){let W=$.slice(1,$.length-1).split("|"),J={};for(let z of W)J[z]=m2(Y,Z);return J}else return{}}function dw(X,Z){if(s(X,"default"))return K0(X.default);else return m2(B0(X,Z),Z)}function hw(X,Z){if(s(X,"default"))return K0(X.default);else throw new _8(X,"RegExp types cannot be created. Consider using a default value.")}function mw(X,Z){if(X.pattern!==void 0)if(!s(X,"default"))throw new _8(X,"String types with patterns must specify a default value");else return K0(X.default);else if(X.format!==void 0)if(!s(X,"default"))throw new _8(X,"String types with formats must specify a default value");else return K0(X.default);else if(s(X,"default"))return K0(X.default);else if(X.minLength!==void 0)return Array.from({length:X.minLength}).map(()=>" ").join("");else return""}function pw(X,Z){if(s(X,"default"))return K0(X.default);else if("value"in X)return Symbol.for(X.value);else return Symbol()}function cw(X,Z){if(s(X,"default"))return K0(X.default);if(!nZ(X))throw new _8(X,"Can only create template literals that produce a finite variants. Consider using a default value.");return C1(X)[0]}function uw(X,Z){if(TW++>aw)throw new _8(X,"Cannot create recursive type as it appears possibly infinite. Consider using a default.");if(s(X,"default"))return K0(X.default);else return m2(B0(X,Z),Z)}function iw(X,Z){if(s(X,"default"))return K0(X.default);if(X.items===void 0)return[];else return Array.from({length:X.minItems}).map(($,Y)=>m2(X.items[Y],Z))}function ow(X,Z){if(s(X,"default"))return K0(X.default);else return}function nw(X,Z){if(s(X,"default"))return K0(X.default);else if(X.anyOf.length===0)throw new Error("ValueCreate.Union: Cannot create Union with zero variants");else return m2(X.anyOf[0],Z)}function lw(X,Z){if(s(X,"default"))return K0(X.default);else if(X.minByteLength!==void 0)return new Uint8Array(X.minByteLength);else return new Uint8Array(0)}function tw(X,Z){if(s(X,"default"))return K0(X.default);else return{}}function sw(X,Z){if(s(X,"default"))return K0(X.default);else return}function rw(X,Z){if(s(X,"default"))return K0(X.default);else throw new Error("User defined types must specify a default value")}function m2(X,Z){let $=D2(X,Z),Y=X;switch(Y[q]){case"Any":return Lw(Y,$);case"Argument":return Fw(Y,$);case"Array":return Bw(Y,$);case"AsyncIterator":return qw(Y,$);case"BigInt":return Kw(Y,$);case"Boolean":return Rw(Y,$);case"Constructor":return jw(Y,$);case"Date":return Sw(Y,$);case"Function":return Vw(Y,$);case"Import":return Ew(Y,$);case"Integer":return Cw(Y,$);case"Intersect":return Pw(Y,$);case"Iterator":return Iw(Y,$);case"Literal":return xw(Y,$);case"Never":return Tw(Y,$);case"Not":return bw(Y,$);case"Null":return kw(Y,$);case"Number":return gw(Y,$);case"Object":return fw(Y,$);case"Promise":return vw(Y,$);case"Record":return yw(Y,$);case"Ref":return dw(Y,$);case"RegExp":return hw(Y,$);case"String":return mw(Y,$);case"Symbol":return pw(Y,$);case"TemplateLiteral":return cw(Y,$);case"This":return uw(Y,$);case"Tuple":return iw(Y,$);case"Undefined":return ow(Y,$);case"Union":return nw(Y,$);case"Uint8Array":return lw(Y,$);case"Unknown":return tw(Y,$);case"Void":return sw(Y,$);default:if(!t0.Has(Y[q]))throw new _8(Y,"Unknown type");return rw(Y,$)}}var aw=512,TW=0;function O8(...X){return TW=0,X.length===2?m2(X[0],X[1]):m2(X[0],[])}class pY extends t{constructor(X,Z){super(Z);this.schema=X}}function ew(X,Z,$){if(X[q]==="Object"&&typeof $==="object"&&!zX($)){let Y=X,W=Object.getOwnPropertyNames($),J=Object.entries(Y.properties),[z,Q]=[1/J.length,J.length];return J.reduce((M,[G,U])=>{let w=U[q]==="Literal"&&U.const===$[G]?Q:0,B=Q0(U,Z,$[G])?z:0,N=W.includes(G)?z:0;return M+(w+B+N)},0)}else return Q0(X,Z,$)?1:0}function X_(X,Z,$){let Y=X.anyOf.map((z)=>B0(z,Z)),[W,J]=[Y[0],0];for(let z of Y){let Q=ew(z,Z,$);if(Q>J)W=z,J=Q}return W}function Z_(X,Z,$){if("default"in X)return typeof $==="function"?X.default:q0(X.default);else{let Y=X_(X,Z,$);return _Z(Y,Z,$)}}function $_(X,Z,$){return Q0(X,Z,$)?q0($):O8(X,Z)}function Y_(X,Z,$){return Q0(X,Z,$)?$:O8(X,Z)}function W_(X,Z,$){if(Q0(X,Z,$))return q0($);let Y=r($)?q0($):O8(X,Z),W=o(X.minItems)&&Y.lengthnull)]:Y,z=(o(X.maxItems)&&W.length>X.maxItems?W.slice(0,X.maxItems):W).map((M)=>d8(X.items,Z,M));if(X.uniqueItems!==!0)return z;let Q=[...new Set(z)];if(!Q0(X,Z,Q))throw new pY(X,"Array cast produced invalid data due to uniqueItems constraint");return Q}function J_(X,Z,$){if(Q0(X,Z,$))return O8(X,Z);let Y=new Set(X.returns.required||[]),W=function(){};for(let[J,z]of Object.entries(X.returns.properties)){if(!Y.has(J)&&$.prototype[J]===void 0)continue;W.prototype[J]=d8(z,Z,$.prototype[J])}return W}function z_(X,Z,$){let Y=globalThis.Object.values(X.$defs),W=X.$defs[X.$ref];return d8(W,[...Z,...Y],$)}function Q_(X,Z,$){let Y=O8(X,Z),W=J0(Y)&&J0($)?{...Y,...$}:$;return Q0(X,Z,W)?W:O8(X,Z)}function G_(X,Z,$){throw new pY(X,"Never types cannot be cast")}function M_(X,Z,$){if(Q0(X,Z,$))return $;if($===null||typeof $!=="object")return O8(X,Z);let Y=new Set(X.required||[]),W={};for(let[J,z]of Object.entries(X.properties)){if(!Y.has(J)&&$[J]===void 0)continue;W[J]=d8(z,Z,$[J])}if(typeof X.additionalProperties==="object"){let J=Object.getOwnPropertyNames(X.properties);for(let z of Object.getOwnPropertyNames($)){if(J.includes(z))continue;W[z]=d8(X.additionalProperties,Z,$[z])}}return W}function U_(X,Z,$){if(Q0(X,Z,$))return q0($);if($===null||typeof $!=="object"||Array.isArray($)||$ instanceof Date)return O8(X,Z);let Y=Object.getOwnPropertyNames(X.patternProperties)[0],W=X.patternProperties[Y],J={};for(let[z,Q]of Object.entries($))J[z]=d8(W,Z,Q);return J}function H_(X,Z,$){return d8(B0(X,Z),Z,$)}function D_(X,Z,$){return d8(B0(X,Z),Z,$)}function A_(X,Z,$){if(Q0(X,Z,$))return q0($);if(!r($))return O8(X,Z);if(X.items===void 0)return[];return X.items.map((Y,W)=>d8(Y,Z,$[W]))}function w_(X,Z,$){return Q0(X,Z,$)?q0($):Z_(X,Z,$)}function d8(X,Z,$){let Y=N0(X.$id)?D2(X,Z):Z,W=X;switch(X[q]){case"Array":return W_(W,Y,$);case"Constructor":return J_(W,Y,$);case"Import":return z_(W,Y,$);case"Intersect":return Q_(W,Y,$);case"Never":return G_(W,Y,$);case"Object":return M_(W,Y,$);case"Record":return U_(W,Y,$);case"Ref":return H_(W,Y,$);case"This":return D_(W,Y,$);case"Tuple":return A_(W,Y,$);case"Union":return w_(W,Y,$);case"Date":case"Symbol":case"Uint8Array":return $_(X,Z,$);default:return Y_(W,Y,$)}}function _Z(...X){return X.length===3?d8(X[0],X[1],X[2]):d8(X[0],[],X[1])}function __(X){return IX(X)&&X[q]!=="Unsafe"}function O_(X,Z,$){if(!r($))return $;return $.map((Y)=>p2(X.items,Z,Y))}function N_(X,Z,$){let Y=globalThis.Object.values(X.$defs),W=X.$defs[X.$ref];return p2(W,[...Z,...Y],$)}function L_(X,Z,$){let Y=X.unevaluatedProperties,J=X.allOf.map((Q)=>p2(Q,Z,q0($))).reduce((Q,M)=>J0(M)?{...Q,...M}:M,{});if(!J0($)||!J0(J)||!IX(Y))return J;let z=d2(X);for(let Q of Object.getOwnPropertyNames($)){if(z.includes(Q))continue;if(Q0(Y,Z,$[Q]))J[Q]=p2(Y,Z,$[Q])}return J}function F_(X,Z,$){if(!J0($)||r($))return $;let Y=X.additionalProperties;for(let W of Object.getOwnPropertyNames($)){if(s(X.properties,W)){$[W]=p2(X.properties[W],Z,$[W]);continue}if(IX(Y)&&Q0(Y,Z,$[W])){$[W]=p2(Y,Z,$[W]);continue}delete $[W]}return $}function B_(X,Z,$){if(!J0($))return $;let Y=X.additionalProperties,W=Object.getOwnPropertyNames($),[J,z]=Object.entries(X.patternProperties)[0],Q=new RegExp(J);for(let M of W){if(Q.test(M)){$[M]=p2(z,Z,$[M]);continue}if(IX(Y)&&Q0(Y,Z,$[M])){$[M]=p2(Y,Z,$[M]);continue}delete $[M]}return $}function q_(X,Z,$){return p2(B0(X,Z),Z,$)}function K_(X,Z,$){return p2(B0(X,Z),Z,$)}function R_(X,Z,$){if(!r($))return $;if(c0(X.items))return[];let Y=Math.min($.length,X.items.length);for(let W=0;WY?$.slice(0,Y):$}function j_(X,Z,$){for(let Y of X.anyOf)if(__(Y)&&Q0(Y,Z,$))return p2(Y,Z,$);return $}function p2(X,Z,$){let Y=N0(X.$id)?D2(X,Z):Z,W=X;switch(W[q]){case"Array":return O_(W,Y,$);case"Import":return N_(W,Y,$);case"Intersect":return L_(W,Y,$);case"Object":return F_(W,Y,$);case"Record":return B_(W,Y,$);case"Ref":return q_(W,Y,$);case"This":return K_(W,Y,$);case"Tuple":return R_(W,Y,$);case"Union":return j_(W,Y,$);default:return $}}function O$(...X){return X.length===3?p2(X[0],X[1],X[2]):p2(X[0],[],X[1])}function N$(X){return N0(X)&&!isNaN(X)&&!isNaN(parseFloat(X))}function S_(X){return O2(X)||s8(X)||o(X)}function OZ(X){return X===!0||o(X)&&X===1||O2(X)&&X===BigInt("1")||N0(X)&&(X.toLowerCase()==="true"||X==="1")}function NZ(X){return X===!1||o(X)&&(X===0||Object.is(X,-0))||O2(X)&&X===BigInt("0")||N0(X)&&(X.toLowerCase()==="false"||X==="0"||X==="-0")}function V_(X){return N0(X)&&/^(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)$/i.test(X)}function E_(X){return N0(X)&&/^(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)?$/i.test(X)}function C_(X){return N0(X)&&/^\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(X)}function P_(X){return N0(X)&&/^\d\d\d\d-[0-1]\d-[0-3]\dt(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)?$/i.test(X)}function I_(X){return N0(X)&&/^\d\d\d\d-[0-1]\d-[0-3]\d$/i.test(X)}function x_(X,Z){let $=kW(X);return $===Z?$:X}function T_(X,Z){let $=gW(X);return $===Z?$:X}function b_(X,Z){let $=bW(X);return $===Z?$:X}function k_(X,Z){return N0(X.const)?x_(Z,X.const):o(X.const)?T_(Z,X.const):s8(X.const)?b_(Z,X.const):Z}function bW(X){return OZ(X)?!0:NZ(X)?!1:X}function g_(X){let Z=($)=>$.split(".")[0];return N$(X)?BigInt(Z(X)):o(X)?BigInt(Math.trunc(X)):NZ(X)?BigInt(0):OZ(X)?BigInt(1):X}function kW(X){return QX(X)&&X.description!==void 0?X.description.toString():S_(X)?X.toString():X}function gW(X){return N$(X)?parseFloat(X):OZ(X)?1:NZ(X)?0:X}function f_(X){return N$(X)?parseInt(X):o(X)?Math.trunc(X):OZ(X)?1:NZ(X)?0:X}function v_(X){return N0(X)&&X.toLowerCase()==="null"?null:X}function y_(X){return N0(X)&&X==="undefined"?void 0:X}function d_(X){return I2(X)?X:o(X)?new Date(X):OZ(X)?new Date(1):NZ(X)?new Date(0):N$(X)?new Date(parseInt(X)):E_(X)?new Date(`1970-01-01T${X}.000Z`):V_(X)?new Date(`1970-01-01T${X}`):P_(X)?new Date(`${X}.000Z`):C_(X)?new Date(X):I_(X)?new Date(`${X}T00:00:00.000Z`):X}function h_(X){return X}function m_(X,Z,$){return(r($)?$:[$]).map((W)=>h8(X.items,Z,W))}function p_(X,Z,$){return g_($)}function c_(X,Z,$){return bW($)}function u_(X,Z,$){return d_($)}function i_(X,Z,$){let Y=globalThis.Object.values(X.$defs),W=X.$defs[X.$ref];return h8(W,[...Z,...Y],$)}function o_(X,Z,$){return f_($)}function n_(X,Z,$){return X.allOf.reduce((Y,W)=>h8(W,Z,Y),$)}function l_(X,Z,$){return k_(X,$)}function t_(X,Z,$){return v_($)}function s_(X,Z,$){return gW($)}function r_(X,Z,$){if(!J0($))return $;for(let Y of Object.getOwnPropertyNames(X.properties)){if(!s($,Y))continue;$[Y]=h8(X.properties[Y],Z,$[Y])}return $}function a_(X,Z,$){if(!J0($))return $;let W=Object.getOwnPropertyNames(X.patternProperties)[0],J=X.patternProperties[W];for(let[z,Q]of Object.entries($))$[z]=h8(J,Z,Q);return $}function e_(X,Z,$){return h8(B0(X,Z),Z,$)}function XO(X,Z,$){return kW($)}function ZO(X,Z,$){return N0($)||o($)?Symbol($):$}function $O(X,Z,$){return h8(B0(X,Z),Z,$)}function YO(X,Z,$){if(!(r($)&&!c0(X.items)))return $;return $.map((W,J)=>{return J{let z=T2(J,Z,Y);return J0(z)?{...W,...z}:z},{})}function UO(X,Z,$){let Y=LX(X,$);if(!J0(Y))return Y;let W=Object.getOwnPropertyNames(X.properties);for(let J of W){let z=T2(X.properties[J],Z,Y[J]);if(c0(z))continue;Y[J]=T2(X.properties[J],Z,Y[J])}if(!cY(X.additionalProperties))return Y;for(let J of Object.getOwnPropertyNames(Y)){if(W.includes(J))continue;Y[J]=T2(X.additionalProperties,Z,Y[J])}return Y}function HO(X,Z,$){let Y=LX(X,$);if(!J0(Y))return Y;let W=X.additionalProperties,[J,z]=Object.entries(X.patternProperties)[0],Q=new RegExp(J);for(let M of Object.getOwnPropertyNames(Y)){if(!(Q.test(M)&&cY(z)))continue;Y[M]=T2(z,Z,Y[M])}if(!cY(W))return Y;for(let M of Object.getOwnPropertyNames(Y)){if(Q.test(M))continue;Y[M]=T2(W,Z,Y[M])}return Y}function DO(X,Z,$){return T2(B0(X,Z),Z,LX(X,$))}function AO(X,Z,$){return T2(B0(X,Z),Z,$)}function wO(X,Z,$){let Y=LX(X,$);if(!r(Y)||c0(X.items))return Y;let[W,J]=[X.items,Math.max(X.items.length,Y.length)];for(let z=0;zuY,ValuePointerRootDeleteError:()=>iY,Set:()=>OO,Has:()=>LO,Get:()=>FO,Format:()=>LZ,Delete:()=>NO});class uY extends t{constructor(X,Z,$){super("Cannot set root value");this.value=X,this.path=Z,this.update=$}}class iY extends t{constructor(X,Z){super("Cannot delete root value");this.value=X,this.path=Z}}function vW(X){return X.indexOf("~")===-1?X:X.replace(/~1/g,"/").replace(/~0/g,"~")}function*LZ(X){if(X==="")return;let[Z,$]=[0,0];for(let Y=0;YG1(X[W],Z[W]))}function qO(X,Z){return I2(Z)&&X.getTime()===Z.getTime()}function KO(X,Z){if(!r(Z)||X.length!==Z.length)return!1;return X.every(($,Y)=>G1($,Z[Y]))}function RO(X,Z){if(!Q8(Z)||X.length!==Z.length||Object.getPrototypeOf(X).constructor.name!==Object.getPrototypeOf(Z).constructor.name)return!1;return X.every(($,Y)=>G1($,Z[Y]))}function jO(X,Z){return X===Z}function G1(X,Z){if(I2(X))return qO(X,Z);if(Q8(X))return RO(X,Z);if(r(X))return KO(X,Z);if(J0(X))return BO(X,Z);if(a2(X))return jO(X,Z);throw new Error("ValueEquals: Unable to compare value")}var SO=S0({type:_0("insert"),path:x2(),value:k8()}),VO=S0({type:_0("update"),path:x2(),value:k8()}),EO=S0({type:_0("delete"),path:x2()}),dW=j0([SO,VO,EO]);class oY extends t{constructor(X,Z){super(Z);this.value=X}}function B$(X,Z){return{type:"update",path:X,value:Z}}function hW(X,Z){return{type:"insert",path:X,value:Z}}function mW(X){return{type:"delete",path:X}}function yW(X){if(globalThis.Object.getOwnPropertySymbols(X).length>0)throw new oY(X,"Cannot diff objects with symbols")}function*CO(X,Z,$){if(yW(Z),yW($),!wY($))return yield B$(X,$);let Y=globalThis.Object.getOwnPropertyNames(Z),W=globalThis.Object.getOwnPropertyNames($);for(let J of W){if(s(Z,J))continue;yield hW(`${X}/${J}`,$[J])}for(let J of Y){if(!s($,J))continue;if(G1(Z,$))continue;yield*q$(`${X}/${J}`,Z[J],$[J])}for(let J of Y){if(s($,J))continue;yield mW(`${X}/${J}`)}}function*PO(X,Z,$){if(!r($))return yield B$(X,$);for(let Y=0;Y=0;Y--){if(Y<$.length)continue;yield mW(`${X}/${Y}`)}}function*IO(X,Z,$){if(!Q8($)||Z.length!==$.length||globalThis.Object.getPrototypeOf(Z).constructor.name!==globalThis.Object.getPrototypeOf($).constructor.name)return yield B$(X,$);for(let Y=0;Y0&&X[0].path===""&&X[0].type==="update"}function bO(X){return X.length===0}function cW(X,Z){if(TO(Z))return q0(Z[0].value);if(bO(Z))return q0(X);let $=q0(X);for(let Y of Z)switch(Y.type){case"insert":{m8.Set($,Y.path,Y.value);break}case"update":{m8.Set($,Y.path,Y.value);break}case"delete":{m8.Delete($,Y.path);break}}return $}function uW(...X){let[Z,$,Y]=X.length===3?[X[0],X[1],X[2]]:[X[0],[],X[1]],W=OX(Z,$)?p1(Z,$,Y):Y;if(!Q0(Z,$,W))throw new wZ(Z,W,ZX(Z,$,W).First());return W}function K$(X){return J0(X)&&!r(X)}class nY extends t{constructor(X){super(X)}}function kO(X,Z,$,Y){if(!K$($))m8.Set(X,Z,q0(Y));else{let W=Object.getOwnPropertyNames($),J=Object.getOwnPropertyNames(Y);for(let z of W)if(!J.includes(z))delete $[z];for(let z of J)if(!W.includes(z))$[z]=null;for(let z of J)lY(X,`${Z}/${z}`,$[z],Y[z])}}function gO(X,Z,$,Y){if(!r($))m8.Set(X,Z,q0(Y));else{for(let W=0;W{return _$(J,z,Q),Q}],["Cast",(J,z,Q)=>_Z(J,z,Q)],["Clean",(J,z,Q)=>O$(J,z,Q)],["Clone",(J,z,Q)=>q0(Q)],["Convert",(J,z,Q)=>L$(J,z,Q)],["Decode",(J,z,Q)=>OX(J,z)?m1(J,z,Q):Q],["Default",(J,z,Q)=>F$(J,z,Q)],["Encode",(J,z,Q)=>OX(J,z)?p1(J,z,Q):Q]]);function $(J){Z.delete(J)}X.Delete=$;function Y(J,z){Z.set(J,z)}X.Set=Y;function W(J){return Z.get(J)}X.Get=W})(tY||(tY={}));var nW=["Clone","Clean","Default","Convert","Assert","Decode"];function dO(X,Z,$,Y){return X.reduce((W,J)=>{let z=tY.Get(J);if(c0(z))throw new sY(`Unable to find Parse operation '${J}'`);return z(Z,$,W)},Y)}function lW(...X){let[Z,$,Y,W]=X.length===4?[X[0],X[1],X[2],X[3]]:X.length===3?r(X[0])?[X[0],X[1],[],X[2]]:[nW,X[0],X[1],X[2]]:X.length===2?[nW,X[0],[],X[1]]:(()=>{throw new sY("Invalid Arguments")})();return dO(Z,$,Y,W)}var X0={};EX(X0,{ValueErrorIterator:()=>z1,Patch:()=>cW,Parse:()=>lW,Mutate:()=>oW,Hash:()=>fX,Errors:()=>ZX,Equal:()=>G1,Encode:()=>uW,Edit:()=>dW,Diff:()=>pW,Default:()=>F$,Decode:()=>fW,Create:()=>O8,Convert:()=>L$,Clone:()=>q0,Clean:()=>O$,Check:()=>Q0,Cast:()=>_Z,Assert:()=>_$});var b$=YQ(aW(),1);var G6={date:q5,time:W6(!0),"date-time":eW(!0),"iso-time":W6(!1),"iso-date-time":eW(!1),duration:/^P(?!$)((\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+S)?)?|(\d+W)?)$/,uri:JN,"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:DN,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:zN,int32:{type:"number",validate:MN},int64:{type:"number",validate:UN},float:{type:"number",validate:Z5},double:{type:"number",validate:Z5},password:!0,binary:!0};function aO(X){return X%4===0&&(X%100!==0||X%400===0)}var eO=/^(\d\d\d\d)-(\d\d)-(\d\d)$/,XN=[0,31,28,31,30,31,30,31,31,30,31,30,31];function q5(X){let Z=eO.exec(X);if(!Z)return!1;let $=+Z[1],Y=+Z[2],W=+Z[3];return Y>=1&&Y<=12&&W>=1&&W<=(Y===2&&aO($)?29:XN[Y])}var ZN=/^(\d\d):(\d\d):(\d\d(?:\.\d+)?)(z|([+-])(\d\d)(?::?(\d\d))?)?$/i;function W6(X){return function Z($){let Y=ZN.exec($);if(!Y)return!1;let W=+Y[1],J=+Y[2],z=+Y[3],Q=Y[4],M=Y[5]==="-"?-1:1,G=+(Y[6]||0),U=+(Y[7]||0);if(G>23||U>59||X&&!Q)return!1;if(W<=23&&J<=59&&z<60)return!0;let w=J-U*M,B=W-G*M-(w<0?1:0);return(B===23||B===-1)&&(w===59||w===-1)&&z<61}}var $N=/t|\s/i;function eW(X){let Z=W6(X);return function $(Y){let W=Y.split($N);return W.length===2&&q5(W[0])&&Z(W[1])}}var YN=/\/|:/,WN=/^(?:[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 JN(X){return YN.test(X)&&WN.test(X)}var X5=/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/gm;function zN(X){return X5.lastIndex=0,X5.test(X)}var QN=-2147483648,GN=2147483647;function MN(X){return Number.isInteger(X)&&X<=GN&&X>=QN}function UN(X){return Number.isInteger(X)}function Z5(){return!0}var HN=/[^\\]\\Z/;function DN(X){if(HN.test(X))return!1;try{return new RegExp(X),!0}catch(Z){return!1}}var V$="toJSON"in new Headers,$5=(X,Z)=>{let $=new URL(X);return $.pathname=Z,$.toString()},AN=(X)=>typeof X==="function"&&/^\s*class\s+/.test(X.toString())||X.toString&&X.toString().startsWith("[object ")&&X.toString()!=="[object Object]"||F8(Object.getPrototypeOf(X)),rY=(X)=>X&&typeof X==="object"&&!Array.isArray(X),u2=(X,Z,{skipKeys:$,override:Y=!0}={})=>{if(!rY(X)||!rY(Z))return X;for(let[W,J]of Object.entries(Z)){if($?.includes(W))continue;if(!rY(J)||!(W in X)||AN(J)){if(Y||!(W in X))X[W]=J;continue}X[W]=u2(X[W],J,{skipKeys:$,override:Y})}return X},wN=(X,Z)=>{let $=u2(Object.assign({},X),Z,{skipKeys:["properties"]});if("properties"in $)delete $.properties;return $},r0=(X=[],Z=[])=>{if(!X)return;if(!Z)return X;let $=[],Y=[];if(!Array.isArray(X))X=[X];if(!Array.isArray(Z))Z=[Z];for(let W of X)if($.push(W),W.checksum)Y.push(W.checksum);for(let W of Z)if(!Y.includes(W.checksum))$.push(W);return $},_N=["start","request","parse","transform","resolve","beforeHandle","afterHandle","mapResponse","afterResponse","trace","error","stop","body","headers","params","query","response","type","detail"],ON=_N.reduce((X,Z)=>(X[Z]=!0,X),{}),K5=(X,Z)=>{let $=(Y)=>typeof Y==="object"&&Object.keys(Y).every(M6);if($(X)&&$(Z))return Object.assign(X,Z);else if(X&&!$(X)&&$(Z))return Object.assign({200:X},Z);return Z??X},FZ=(X,Z)=>{return{body:Z?.body??X?.body,headers:Z?.headers??X?.headers,params:Z?.params??X?.params,query:Z?.query??X?.query,cookie:Z?.cookie??X?.cookie,response:K5(X?.response,Z?.response)}},FX=(X,Z)=>{let{resolve:$,...Y}=X??{},{resolve:W,...J}=Z??{};return{...Y,...J,body:Z?.body??X?.body,headers:Z?.headers??X?.headers,params:Z?.params??X?.params,query:Z?.query??X?.query,cookie:Z?.cookie??X?.cookie,response:K5(X?.response,Z?.response),type:X?.type||Z?.type,detail:u2(Z?.detail??{},X?.detail??{}),parse:r0(X?.parse,Z?.parse),transform:r0(X?.transform,Z?.transform),beforeHandle:r0(r0(_2($,"resolve"),X?.beforeHandle),r0(_2(W,"resolve"),Z?.beforeHandle)),afterHandle:r0(X?.afterHandle,Z?.afterHandle),mapResponse:r0(X?.mapResponse,Z?.mapResponse),afterResponse:r0(X?.afterResponse,Z?.afterResponse),trace:r0(X?.trace,Z?.trace),error:r0(X?.error,Z?.error)}},J6=(X,Z,$=!0)=>{if(!Array.isArray(Z))return Z.original=X,F2(X,Z,$);for(let Y of Z)Y.original=X,X=F2(X,Y,$);return X},F2=(X,Z,$=!0)=>{if(!X)return X;if(Z.untilObjectFound&&!$&&X.type==="object")return X;let Y=Z.from[q];if(X.oneOf){for(let z=0;z{if(U&&K.type==="object"){let l={};for(let[n,A0]of Object.entries(U))l[n]=F2(A0,Z,!1);return{...B,...K,properties:l}}if(w&&K.type==="array")return{...B,...K,items:F2(w,Z,!1)};let k={...B,...K};if(delete k.required,U&&K.type==="string"&&K.format==="ObjectString"&&K.default==="{}")j=_.ObjectString(U,B),k.default=JSON.stringify(X0.Create(_.Object(U))),k.properties=U;if(w&&K.type==="string"&&K.format==="ArrayString"&&K.default==="[]")j=_.ArrayString(w,B),k.default=JSON.stringify(X0.Create(_.Array(w))),k.items=w;return k};if(W){if(U){let K={};for(let[k,l]of Object.entries(U))K[k]=F2(l,Z,!1);return{...B,properties:K}}else if(w?.map)return{...B,items:w.map((K)=>F2(K,Z,!1))};return B}if(N.anyOf)for(let K=0;KF2(K,Z,!1))};return{...B,...N}}let J=X?.properties;if(J&&$&&Z.rootOnly!==!0)for(let[z,Q]of Object.entries(J))switch(Q[q]){case Y:let{anyOf:M,oneOf:G,allOf:U,not:w,type:B,...N}=Q,j=Z.to(N);if(!j)return X;if(j.anyOf)for(let H=0;H(Z)=>{if(typeof Z==="object")try{return X0.Clean(X,structuredClone(Z))}catch{try{return X0.Clean(X,Z)}catch{return Z}}return Z},i2=(X,{models:Z={},dynamic:$=!1,modules:Y,normalize:W=!1,additionalProperties:J=!1,coerce:z=!1,additionalCoerce:Q=[]}={modules:_.Module({})})=>{if(!X)return;let M;if(typeof X!=="string")M=X;else{let U=X.endsWith("[]"),w=U?X.substring(0,X.length-2):X;if(M=Y.Import(w)??Z[w],U)M=_.Array(M)}if(!M)return;if(z||Q)if(z)M=J6(M,[{from:_.Ref(""),to:(U)=>Y.Import(U.$ref)},{from:_.Number(),to:(U)=>_.Numeric(U),untilObjectFound:!0},{from:_.Boolean(),to:(U)=>_.BooleanString(U),untilObjectFound:!0},...Array.isArray(Q)?Q:[Q]]);else M=J6(M,[{from:_.Ref(""),to:(U)=>Y.Import(U.$ref)},...Array.isArray(Q)?Q:[Q]]);if(M.type==="object"&&"additionalProperties"in M===!1)M.additionalProperties=J;if($){let U={schema:M,references:"",checkFunc:()=>{},code:"",Check:(w)=>X0.Check(M,w),Errors:(w)=>X0.Errors(M,w),Code:()=>"",Clean:RZ(M),Decode:(w)=>X0.Decode(M,w),Encode:(w)=>X0.Encode(M,w)};if(W&&M.additionalProperties===!1)U.Clean=RZ(M);if(M.config){if(U.config=M.config,U?.schema?.config)delete U.schema.config}return U.parse=(w)=>{try{return U.Decode(w)}catch(B){throw[...U.Errors(w)].map(i8)}},U.safeParse=(w)=>{try{return{success:!0,data:U.Decode(w),error:null}}catch(B){let N=[...G.Errors(w)].map(i8);return{success:!1,data:null,error:N[0]?.summary,errors:N}}},U}let G=vX.Compile(M,Object.values(Z));if(G.Clean=RZ(M),M.config){if(G.config=M.config,G?.schema?.config)delete G.schema.config}return G.parse=(U)=>{try{return G.Decode(U)}catch(w){throw[...G.Errors(U)].map(i8)}},G.safeParse=(U)=>{try{return{success:!0,data:G.Decode(U),error:null}}catch(w){let B=[...G.Errors(U)].map(i8);return{success:!1,data:null,error:B[0]?.summary,errors:B}}},G},Y5=(X,{models:Z={},modules:$,dynamic:Y=!1,normalize:W=!1,additionalProperties:J=!1})=>{if(!X)return;let z;if(typeof X!=="string")z=X;else{let U=X.endsWith("[]"),w=U?X.substring(0,X.length-2):X;if(z=$.Import(w)??Z[w],U)z=_.Array(z)}if(!z)return;let Q=(U,w)=>{if(Y)return{schema:U,references:"",checkFunc:()=>{},code:"",Check:(N)=>X0.Check(U,N),Errors:(N)=>X0.Errors(U,N),Code:()=>"",Clean:RZ(U),Decode:(N)=>X0.Decode(U,N),Encode:(N)=>X0.Encode(U,N)};let B=vX.Compile(U,w);if(W&&U.additionalProperties===!1)B.Clean=RZ(U);return B},M=Object.values(Z);if(q in z){if("additionalProperties"in z===!1)z.additionalProperties=J;return{200:Q(z,M)}}let G={};return Object.keys(z).forEach((U)=>{let w=z[+U];if(typeof w==="string"){if(w in Z){let B=Z[w];B.type==="object"&&"additionalProperties"in B,G[+U]=q in B?Q(B,M):B}return}if(w.type==="object"&&"additionalProperties"in w===!1)w.additionalProperties=J;G[+U]=q in w?Q(w,M):w}),G},NN=typeof Bun!=="undefined",LN=NN&&typeof Bun.hash==="function",BZ=(X)=>{if(LN)return Bun.hash(X);let Z=9;for(let $=0;$>>9},aY,M1=()=>{if(!aY)aY=[{from:_.Object({}),to:()=>_.ObjectString({}),excludeRoot:!0},{from:_.Array(_.Any()),to:()=>_.ArrayString(_.Any())}];return aY},eY,W5=()=>{if(!eY)eY=[{from:_.Number(),to:(X)=>_.Numeric(X),rootOnly:!0},{from:_.Boolean(),to:(X)=>_.BooleanString(X),rootOnly:!0}];return eY},R5=({validator:X,modules:Z,defaultConfig:$={},config:Y,dynamic:W,models:J})=>{let z=i2(X,{modules:Z,dynamic:W,models:J,additionalProperties:!0,coerce:!0,additionalCoerce:M1()});if(F8($))if(z)z.config=wN(z.config,Y);else z=i2(_.Cookie({}),{modules:Z,dynamic:W,models:J,additionalProperties:!0}),z.config=$;return z},p8=(X,Z)=>{if(!Z)return;if(!Array.isArray(Z)){let Y=Z;if(X&&!Y.checksum)Y.checksum=X;if(Y.scope==="scoped")Y.scope="local";return Y}let $=[...Z];for(let Y of $){if(X&&!Y.checksum)Y.checksum=X;if(Y.scope==="scoped")Y.scope="local"}return $},J5=(X,Z,$)=>{return{start:r0(X.start,p8($,Z?.start)),request:r0(X.request,p8($,Z?.request)),parse:r0(X.parse,p8($,Z?.parse)),transform:r0(X.transform,p8($,Z?.transform)),beforeHandle:r0(r0(_2(X.resolve,"resolve"),X.beforeHandle),p8($,r0(_2(Z?.resolve,"resolve"),Z?.beforeHandle))),afterHandle:r0(X.afterHandle,p8($,Z?.afterHandle)),mapResponse:r0(X.mapResponse,p8($,Z?.mapResponse)),afterResponse:r0(X.afterResponse,p8($,Z?.afterResponse)),trace:r0(X.trace,p8($,Z?.trace)),error:r0(X.error,p8($,Z?.error)),stop:r0(X.stop,p8($,Z?.stop))}},FN=(X,Z,{skipIfHasType:$=!1}={})=>{if(!X)return X;if(!Array.isArray(X)){if($)X.scope??=Z;else X.scope=Z;return X}for(let Y of X)if($)Y.scope??=Z;else Y.scope=Z;return X},yX=(X)=>{if(!X)return X;if(!Array.isArray(X))switch(X.scope){case"global":case"scoped":return{...X};default:return{fn:X}}let Z=[];for(let $ of X)switch($.scope){case"global":case"scoped":Z.push({...$});break}return Z},z5=(X)=>{return{...X,type:X?.type,detail:X?.detail,parse:yX(X?.parse),transform:yX(X?.transform),beforeHandle:yX(X?.beforeHandle),afterHandle:yX(X?.afterHandle),mapResponse:yX(X?.mapResponse),afterResponse:yX(X?.afterResponse),error:yX(X?.error),trace:yX(X?.trace)}},x$={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},Q5=Object.fromEntries(Object.entries(x$).map(([X,Z])=>[Z,X]));function BN(X){let Z=X;while(Z.endsWith("="))Z=Z.slice(0,-1);return Z}var G5=new TextEncoder,E$=async(X,Z)=>{if(typeof X!=="string")throw new TypeError("Cookie value must be provided as a string.");if(Z===null)throw new TypeError("Secret key must be provided.");let $=await crypto.subtle.importKey("raw",G5.encode(Z),{name:"HMAC",hash:"SHA-256"},!1,["sign"]),Y=await crypto.subtle.sign("HMAC",$,G5.encode(X));return X+"."+BN(Buffer.from(Y).toString("base64"))},M5=async(X,Z)=>{if(typeof X!=="string")throw new TypeError("Signed cookie string must be provided.");if(Z===null)throw new TypeError("Secret key must be provided.");let $=X.slice(0,X.lastIndexOf("."));return await E$($,Z)===X?$:!1},qN=(X,Z,$)=>{if(!X||typeof X!=="object"||!Z)return;for(let[Y,W]of Object.entries(Z)){if(Y in ON||!(Y in X))continue;let J=X[Y];if(typeof J==="function"){let z=J(W);if(typeof z==="object")for(let[Q,M]of Object.entries(z))$(Q)({fn:M})}delete Z[Y]}},KN=({globalHook:X,localHook:Z})=>($)=>(Y,W)=>{if(typeof Y==="function")Y={fn:Y};if($==="resolve")Y={...Y,subType:"resolve"};if("fn"in Y||Array.isArray(Y)){if(!Z[$])Z[$]=[];if(typeof Z[$]==="function")Z[$]=[Z[$]];if(Array.isArray(Y))Z[$]=Z[$].concat(Y);else Z[$].push(Y);return}let{insert:J="after",stack:z="local"}=Y;if(typeof W==="function")W={fn:W};if(z==="global")if(!Array.isArray(W))if(J==="before")X[$].unshift(W);else X[$].push(W);else if(J==="before")X[$]=W.concat(X[$]);else X[$]=X[$].concat(W);else{if(!Z[$])Z[$]=[];if(typeof Z[$]==="function")Z[$]=[Z[$]];if(!Array.isArray(W))if(J==="before")Z[$].unshift(W);else Z[$].push(W);else if(J==="before")Z[$]=W.concat(Z[$]);else Z[$]=Z[$].concat(W)}},RN=(X)=>{if(typeof X==="number")return X;if(X.length<16){if(X.trim().length===0)return null;let Z=Number(X);if(Number.isNaN(Z))return null;return Z}if(X.length===16){if(X.trim().length===0)return null;let Z=Number(X);if(Number.isNaN(Z)||Z.toString()!==X)return null;return Z}return null},M6=(X)=>RN(X)!==null;class j5{onError;root=null;promises=[];constructor(X=console.error){this.onError=X}get size(){return this.promises.length}add(X){return this.promises.push(X),this.root||=this.drain(),X}async drain(){while(this.promises.length>0){try{await this.promises[0]}catch(X){this.onError(X)}this.promises.shift()}this.root=null}then(X,Z){return(this.root??Promise.resolve()).then(X,Z)}}var _2=(X,Z)=>{if(!X)return X;if(!Array.isArray(X)){if(typeof X==="function"||typeof X==="string")return Z?{fn:X,subType:Z}:{fn:X};else if("fn"in X)return X}let $=[];for(let Y of X)if(typeof Y==="function"||typeof Y==="string")$.push(Z?{fn:Y,subType:Z}:{fn:Y});else if("fn"in Y)$.push(Y);return $},jN=(X)=>{return{...X,start:_2(X?.start),request:_2(X?.request),parse:_2(X?.parse),transform:_2(X?.transform),beforeHandle:_2(X?.beforeHandle),afterHandle:_2(X?.afterHandle),mapResponse:_2(X?.mapResponse),afterResponse:_2(X?.afterResponse),trace:_2(X?.trace),error:_2(X?.error),stop:_2(X?.stop)}},U5=(X)=>{let Z={};if(X.start?.map)Z.start=X.start.map(($)=>$.fn);if(X.request?.map)Z.request=X.request.map(($)=>$.fn);if(X.parse?.map)Z.parse=X.parse.map(($)=>$.fn);if(X.transform?.map)Z.transform=X.transform.map(($)=>$.fn);if(X.beforeHandle?.map)Z.beforeHandle=X.beforeHandle.map(($)=>$.fn);if(X.afterHandle?.map)Z.afterHandle=X.afterHandle.map(($)=>$.fn);if(X.mapResponse?.map)Z.mapResponse=X.mapResponse.map(($)=>$.fn);if(X.afterResponse?.map)Z.afterResponse=X.afterResponse.map(($)=>$.fn);if(X.trace?.map)Z.trace=X.trace.map(($)=>$.fn);if(X.error?.map)Z.error=X.error.map(($)=>$.fn);if(X.stop?.map)Z.stop=X.stop.map(($)=>$.fn);return Z},X6=(X)=>({body:X.body,cookie:X.cookie,headers:X.headers,query:X.query,set:X.set,server:X.server,request:X.request,route:X.route}),S5=(X,Z=302)=>Response.redirect(X,Z),ex=Symbol("ElysiaFormData"),T$=Symbol("ElysiaRequestId");var V5=()=>{let X=crypto.randomUUID();return X.slice(0,8)+X.slice(24,32)},H5=(X)=>{let Z=[];for(let $=0;${if(!X)return;if(Z==="scoped"){for(let $ of X)if("scope"in $&&$.scope==="local")$.scope="scoped";return}for(let $ of X)if("scope"in $)$.scope="global"},c1=(X)=>{if(X.charCodeAt(X.length-1)===47)return X.slice(0,X.length-1);return X+"/"},F8=(X)=>{if(!X)return!1;for(let Z in X)return!0;return!1},c8=(X)=>{if(Array.isArray(X))return X.length===0;return!X},Z6=(X)=>{let Z={...X};if(c8(X.afterHandle))delete Z.afterHandle;if(c8(X.afterResponse))delete Z.afterResponse;if(c8(X.beforeHandle))delete Z.beforeHandle;if(c8(X.error))delete Z.error;if(c8(X.mapResponse))delete Z.mapResponse;if(c8(X.parse))delete Z.parse;if(c8(X.request))delete Z.request;if(c8(X.start))delete Z.start;if(c8(X.stop))delete Z.stop;if(c8(X.trace))delete Z.trace;if(c8(X.transform))delete Z.transform;if(!Z.type)delete Z.type;if(Z.detail&&!Object.keys(Z.detail).length)delete Z.detail;if(!Z.body)delete Z.body;if(!Z.cookie)delete Z.cookie;if(!Z.headers)delete Z.headers;if(!Z.query)delete Z.query;if(!Z.params)delete Z.params;if(!Z.response)delete Z.response;return Z},qZ=(X,{dynamic:Z=!1}={})=>{let $=encodeURIComponent(X).replace(/%2F/g,"/");if(Z)$=$.replace(/%3A/g,":").replace(/%3F/g,"?");return $},D5=typeof Bun!=="undefined"?Bun.env:typeof process!=="undefined"?process?.env:void 0,C$=Symbol("ElysiaErrorCode"),P$=(D5?.NODE_ENV??D5?.ENV)==="production";class o8{code;response;constructor(X,Z){let $=Z??(X in Q5?Q5[X]:X);this.code=x$[X]??X,this.response=$}}var w1=(X,Z)=>new o8(X,Z);class E5 extends Error{code="INTERNAL_SERVER_ERROR";status=500;constructor(X){super(X??"INTERNAL_SERVER_ERROR")}}class U6 extends Error{code="NOT_FOUND";status=404;constructor(X){super(X??"NOT_FOUND")}}class C5 extends Error{code="PARSE";status=400;constructor(){super("Bad Request")}}class z6 extends Error{key;code="INVALID_COOKIE_SIGNATURE";status=400;constructor(X,Z){super(Z??`"${X}" has invalid cookie signature`);this.key=X}}var i8=(X)=>{if(!X)return{summary:void 0};let{message:Z,path:$,value:Y,type:W}=X,J=$.slice(1).replaceAll("/","."),z=$==="";switch(W){case 42:return{...X,summary:z?"Value should not be provided":`Property '${J}' should not be provided`};case 45:return{...X,summary:z?"Value is missing":`Property '${J}' is missing`};case 50:let Q=Z.indexOf("'"),M=Z.slice(Q+1,Z.indexOf("'",Q+1));return{...X,summary:z?"Value should be an email":`Property '${J}' should be ${M}`};case 54:return{...X,summary:`${Z.slice(0,9)} property '${J}' to be ${Z.slice(8)} but found: ${Y}`};case 62:let G=X.schema.anyOf.map((U)=>`'${U?.format??U.type}'`).join(", ");return{...X,summary:z?`Value should be one of ${G}`:`Property '${J}' should be one of: ${G}`};default:return{summary:Z,...X}}};class G0 extends Error{type;validator;value;code="VALIDATION";status=422;constructor(X,Z,$){if($&&typeof $==="object"&&$ instanceof o8)$=$.response;let Y=P$?void 0:("Errors"in Z)?Z.Errors($).First():X0.Errors(Z,$).First(),W=Y?.schema?.message||Y?.schema?.error!==void 0?typeof Y.schema.error==="function"?Y.schema.error({type:X,validator:Z,value:$,get errors(){return[...Z.Errors($)].map(i8)}}):Y.schema.error:void 0,J=Y?.path||"root",z="";if(W!==void 0)z=typeof W==="object"?JSON.stringify(W):W+"";else if(P$)z=JSON.stringify({type:"validation",on:X,summary:i8(Y).summary,message:Y?.message,found:$});else{let Q=Z?.schema??Z,M="Errors"in Z?[...Z.Errors($)].map(i8):[...X0.Errors(Z,$)].map(i8),G;try{G=X0.Create(Q)}catch(U){G={type:"Could not create expected value",message:U?.message,error:U}}z=JSON.stringify({type:"validation",on:X,summary:i8(Y).summary,property:J,message:Y?.message,expected:G,found:$,errors:M},null,2)}super(z);this.type=X,this.validator=Z,this.value=$,Object.setPrototypeOf(this,G0.prototype)}get all(){return"Errors"in this.validator?[...this.validator.Errors(this.value)].map(i8):[...X0.Errors(this.validator,this.value)].map(i8)}static simplifyModel(X){let Z="schema"in X?X.schema:X;try{return X0.Create(Z)}catch{return Z}}get model(){return G0.simplifyModel(this.validator)}toResponse(X){return new Response(this.message,{status:400,headers:{...X,"content-type":"application/json"}})}}var P5=/(\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))/,I5=/(?: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\([^)]+\)/,x5=/^(?:(?:(?:(?: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)?)?$/,SN=G6.date,VN=G6["date-time"];if(!C0.Has("date"))C0.Set("date",(X)=>{let Z=X.replace(/"/g,"");if(P5.test(Z)||I5.test(Z)||x5.test(Z)||SN(Z)){let $=new Date(Z);if(!Number.isNaN($.getTime()))return!0}return!1});if(!C0.Has("date-time"))C0.Set("date-time",(X)=>{let Z=X.replace(/"/g,"");if(P5.test(Z)||I5.test(Z)||x5.test(Z)||VN(Z)){let $=new Date(Z);if(!Number.isNaN($.getTime()))return!0}return!1});Object.entries(G6).forEach((X)=>{let[Z,$]=X;if(!C0.Has(Z)){if($ instanceof RegExp)C0.Set(Z,(Y)=>$.test(Y));else if(typeof $==="function")C0.Set(Z,$)}});var _=Object.assign({},f0),A5=(X)=>{if(typeof X==="string")switch(X.slice(-1)){case"k":return+X.slice(0,X.length-1)*1024;case"m":return+X.slice(0,X.length-1)*1048576;default:return+X}return X},w5=(X,Z)=>{if(X.startsWith(Z))return!0;return Z.charCodeAt(Z.length-1)===42&&Z.charCodeAt(Z.length-2)===47&&X.startsWith(Z.slice(0,-1))},Q6=(X,Z)=>{if(!(Z instanceof Blob))return!1;if(X.minSize&&Z.sizeA5(X.maxSize))return!1;if(X.extension){if(typeof X.extension==="string")return w5(Z.type,X.extension);for(let $=0;${if(!Array.isArray(Z))return Q6(X,Z);if(X.minItems&&Z.lengthX.maxItems)return!1;for(let $=0;$!!X&&!isNaN(+X));if(!C0.Has("integer"))C0.Set("integer",(X)=>!!X&&Number.isInteger(+X));if(!C0.Has("boolean"))C0.Set("boolean",(X)=>X==="true"||X==="false");if(!C0.Has("ObjectString"))C0.Set("ObjectString",(X)=>{let Z=X.charCodeAt(0);if(Z===9||Z===10||Z===32)Z=X.trimStart().charCodeAt(0);if(Z!==123&&Z!==91)return!1;try{return JSON.parse(X),!0}catch{return!1}});if(!C0.Has("ArrayString"))C0.Set("ArrayString",(X)=>{let Z=X.charCodeAt(0);if(Z===9||Z===10||Z===32)Z=X.trimStart().charCodeAt(0);if(Z!==123&&Z!==91)return!1;try{return JSON.parse(X),!0}catch{return!1}});if(!t0.Has("UnionEnum"))t0.Set("UnionEnum",(X,Z)=>{return(typeof Z==="number"||typeof Z==="string"||Z===null)&&X.enum.includes(Z)});var B8={Numeric:(X)=>{let Z=f0.Number(X);return _.Transform(_.Union([_.String({format:"numeric",default:0}),_.Number(X)],X)).Decode(($)=>{let Y=+$;if(isNaN(Y))return $;if(X&&!X0.Check(Z,Y))throw new G0("property",Z,Y);return Y}).Encode(($)=>$)},Integer:(X)=>{let Z=f0.Integer(X);return _.Transform(_.Union([_.String({format:"integer",default:0}),f0.Integer(X)],X)).Decode(($)=>{let Y=+$;if(!X0.Check(Z,Y))throw new G0("property",Z,Y);return Y}).Encode(($)=>$)},Date:(X)=>{let Z=f0.Date(X),$=X?.default?new Date(X.default):void 0;return _.Transform(_.Union([f0.Date(X),_.String({format:"date",default:$?.toISOString()}),_.String({format:"date-time",default:$?.toISOString()}),_.Number({default:$?.getTime()})],X)).Decode((Y)=>{if(typeof Y==="number"){let J=new Date(Y);if(!X0.Check(Z,J))throw new G0("property",Z,J);return J}if(Y instanceof Date)return Y;let W=new Date(Y);if(!W||isNaN(W.getTime()))throw new G0("property",Z,W);if(!X0.Check(Z,W))throw new G0("property",Z,W);return W}).Encode((Y)=>Y.toISOString())},BooleanString:(X)=>{let Z=f0.Boolean(X);return _.Transform(_.Union([_.Boolean(X),_.String({format:"boolean",default:!1})],X)).Decode(($)=>{if(typeof $==="string")return $==="true";if($!==void 0&&!X0.Check(Z,$))throw new G0("property",Z,$);return $}).Encode(($)=>$)},ObjectString:(X,Z)=>{let $=_.Object(X,Z),Y=JSON.stringify(X0.Create($)),W;try{W=vX.Compile($)}catch{}return _.Transform(_.Union([_.String({format:"ObjectString",default:Y}),$])).Decode((J)=>{if(typeof J==="string"){if(J.charCodeAt(0)!==123)throw new G0("property",$,J);try{J=JSON.parse(J)}catch{throw new G0("property",$,J)}if(W){if(!W.Check(J))throw new G0("property",$,J);return W.Decode(J)}if(!X0.Check($,J))throw new G0("property",$,J);return X0.Decode($,J)}return J}).Encode((J)=>{if(typeof J==="string")try{J=JSON.parse(J)}catch{throw new G0("property",$,J)}if(!X0.Check($,J))throw new G0("property",$,J);return JSON.stringify(J)})},ArrayString:(X=_.String(),Z)=>{let $=_.Array(X,Z),Y;try{Y=vX.Compile($)}catch{}let W=(J,z=!1)=>{if(J.charCodeAt(0)===91){try{J=JSON.parse(J)}catch{throw new G0("property",$,J)}if(Y){if(!Y.Check(J))throw new G0("property",$,J);return Y.Decode(J)}if(!X0.Check($,J))throw new G0("property",$,J);return X0.Decode($,J)}if(J.indexOf(",")!==-1){let Q=J.split(",").map((M)=>M.trim());if(Y){if(!Y.Check(Q))throw new G0("property",$,J);return Y.Decode(Q)}if(!X0.Check($,Q))throw new G0("property",$,Q);return X0.Decode($,Q)}if(z)return J;throw new G0("property",$,J)};return _.Transform(_.Union([_.String({format:"ArrayString",default:Z?.default}),$])).Decode((J)=>{if(Array.isArray(J)){let z=[];for(let Q=0;Q{if(typeof J==="string")try{J=JSON.parse(J)}catch{throw new G0("property",$,J)}if(!X0.Check($,J))throw new G0("property",$,J);return JSON.stringify(J)})},File:EN,Files:(X={})=>_.Transform(CN(X)).Decode((Z)=>{if(Array.isArray(Z))return Z;return[Z]}).Encode((Z)=>Z),Nullable:(X,Z)=>_.Union([X,_.Null()],Z),MaybeEmpty:(X,Z)=>_.Union([X,_.Null(),_.Undefined()],Z),Cookie:(X,{domain:Z,expires:$,httpOnly:Y,maxAge:W,path:J,priority:z,sameSite:Q,secure:M,secrets:G,sign:U,...w}={})=>{let B=_.Object(X,w);return B.config={domain:Z,expires:$,httpOnly:Y,maxAge:W,path:J,priority:z,sameSite:Q,secure:M,secrets:G,sign:U},B},UnionEnum:(X,Z={})=>{let $=X.every((Y)=>typeof Y==="string")?{type:"string"}:X.every((Y)=>typeof Y==="number")?{type:"number"}:X.every((Y)=>Y===null)?{type:"null"}:{};if(X.some((Y)=>typeof Y==="object"&&Y!==null))throw new Error("This type does not support objects or arrays");return{default:X[0],...Z,[q]:"UnionEnum",...$,enum:X}}};_.BooleanString=B8.BooleanString;_.ObjectString=B8.ObjectString;_.ArrayString=B8.ArrayString;_.Numeric=B8.Numeric;_.Integer=B8.Integer;_.File=(X={})=>B8.File({default:"File",...X,extension:X?.type,type:"string",format:"binary"});_.Files=(X={})=>B8.Files({...X,elysiaMeta:"Files",default:"Files",extension:X?.type,type:"array",items:{...X,default:"Files",type:"string",format:"binary"}});_.Nullable=(X)=>B8.Nullable(X);_.MaybeEmpty=B8.MaybeEmpty;_.Cookie=B8.Cookie;_.Date=B8.Date;_.UnionEnum=B8.UnionEnum;function T5(X,Z){if(!t0.Has(X))t0.Set(X,Z);return($={})=>H$({...$,[q]:X})}var jZ=(X)=>{let Z=typeof X==="object"?X.fn.toString():typeof X==="string"?X.toString():X,$=Z.indexOf(")");if(Z.charCodeAt($+2)===61&&Z.charCodeAt($+5)!==123)return!0;return Z.includes("return")},PN=(X)=>{if(X.startsWith("async"))X=X.slice(5);X=X.trimStart();let Z=-1;if(X.charCodeAt(0)===40){if(Z=X.indexOf("=>",X.indexOf(")")),Z!==-1){let W=Z;while(W>0)if(X.charCodeAt(--W)===41)break;let J=X.slice(Z+2);if(J.charCodeAt(0)===32)J=J.trimStart();return[X.slice(1,W),J,{isArrowReturn:J.charCodeAt(0)!==123}]}}if(/^(\w+)=>/g.test(X)){if(Z=X.indexOf("=>"),Z!==-1){let W=X.slice(Z+2);if(W.charCodeAt(0)===32)W=W.trimStart();return[X.slice(0,Z),W,{isArrowReturn:W.charCodeAt(0)!==123}]}}if(X.startsWith("function")){Z=X.indexOf("(");let W=X.indexOf(")");return[X.slice(Z+1,W),X.slice(W+2),{isArrowReturn:!1}]}let $=X.indexOf("(");if($!==-1){let W=X.indexOf(` -`,2),J=X.slice(0,W),z=J.lastIndexOf(")")+1,Q=X.slice(W+1);return[J.slice($,z),"{"+Q,{isArrowReturn:!1}]}let Y=X.split(` -`,2);return[Y[0],Y[1],{isArrowReturn:!1}]},IN=(X)=>{let Z=X.indexOf("{");if(Z===-1)return[-1,0];let $=Z+1,Y=1;for(;${let Z=X.lastIndexOf("}");if(Z===-1)return[-1,0];let $=Z-1,Y=1;for(;$>=0;$--){let W=X.charCodeAt($);if(W===125)Y++;else if(W===123)Y--;if(Y===0)break}if(Y!==0)return[-1,0];return[$,Z+1]},b5=(X)=>{while(!0){let Z=X.indexOf(":");if(Z===-1)break;let $=X.indexOf(",",Z);if($===-1)$=X.indexOf("}",Z)-1;if($===-2)$=X.length;X=X.slice(0,Z)+X.slice($)}return X},k5=(X)=>{let Z=!1;if(X.charCodeAt(0)===40)X=X.slice(1,-1);if(X.charCodeAt(0)===123)Z=!0,X=X.slice(1,-1);X=X.replace(/( |\t|\n)/g,"").trim();let $=[];while(!0){let[W,J]=IN(X);if(W===-1)break;if($.push(X.slice(0,W-1)),X.charCodeAt(J)===44)J++;X=X.slice(J)}if(X=b5(X),X)$=$.concat(X.split(","));let Y=[];for(let W of $){if(W.indexOf(",")===-1){Y.push(W);continue}for(let J of W.split(","))Y.push(J.trim())}return $=Y,{hasParenthesis:Z,parameters:$}},TN=(X,Z)=>{let{parameters:$,hasParenthesis:Y}=k5(X);if(!Z.query&&$.includes("query"))Z.query=!0;if(!Z.headers&&$.includes("headers"))Z.headers=!0;if(!Z.body&&$.includes("body"))Z.body=!0;if(!Z.cookie&&$.includes("cookie"))Z.cookie=!0;if(!Z.set&&$.includes("set"))Z.set=!0;if(!Z.server&&$.includes("server"))Z.server=!0;if(!Z.request&&$.includes("request"))Z.request=!0;if(!Z.route&&$.includes("route"))Z.route=!0;if(Y)return`{ ${$.join(", ")} }`;return $.join(", ")},_5=(X,Z,$)=>{let Y=Z.indexOf(X+` -`,$),W=Z.indexOf(X+"\t",$),J=Z.indexOf(X+",",$),z=Z.indexOf(X+";",$),Q=Z.indexOf(X+" ",$);return[Y,W,J,z,Q].filter((M)=>M>0).sort((M,G)=>M-G)[0]||-1},g5=(X,Z,$=0)=>{if($>5)return[];let Y=[],W=Z;while(!0){let J=_5(" = "+X,W);if(J===-1)J=_5("="+X,W);if(J===-1){let G=W.indexOf(" = "+X);if(G===-1)G=W.indexOf("="+X);if(G+3+X.length!==W.length)break;J=G}let z=W.slice(0,J),Q=z.lastIndexOf(" "),M=z.slice(Q!==-1?Q+1:-1);if(M==="}"){let[G,U]=xN(z);Y.push(b5(W.slice(G,U))),W=W.slice(J+3+X.length);continue}while(M.charCodeAt(0)===44)M=M.slice(1);while(M.charCodeAt(0)===9)M=M.slice(1);if(!M.includes("("))Y.push(M);W=W.slice(J+3+X.length)}for(let J of Y){if(J.charCodeAt(0)===123)continue;let z=g5(J,Z);if(z.length>0)Y.push(...z)}return Y},bN=(X)=>{if(!X)return;if(X.charCodeAt(0)!==123)return X;if(X=X.slice(2,-2),!X.includes(",")){if(X.includes("..."))return X.slice(X.indexOf("...")+3);return}let Z=X.indexOf("...");if(Z===-1)return;return X.slice(Z+3).trimEnd()},kN=(X,Z,$)=>{let Y=(W,J)=>X.includes(J+"."+W)||X.includes(J+'["'+W+'"]')||X.includes(J+"['"+W+"']");for(let W of Z){if(!W)continue;if(W.charCodeAt(0)===123){let J=k5(W).parameters;if(!$.query&&J.includes("query"))$.query=!0;if(!$.headers&&J.includes("headers"))$.headers=!0;if(!$.body&&J.includes("body"))$.body=!0;if(!$.cookie&&J.includes("cookie"))$.cookie=!0;if(!$.set&&J.includes("set"))$.set=!0;if(!$.query&&J.includes("server"))$.server=!0;if(!$.request&&J.includes("request"))$.request=!0;if(!$.route&&J.includes("route"))$.route=!0;continue}if(!$.query&&Y("query",W))$.query=!0;if(X.includes("return "+W)||X.includes("return "+W+".query"))$.query=!0;if(!$.headers&&Y("headers",W))$.headers=!0;if(!$.body&&Y("body",W))$.body=!0;if(!$.cookie&&Y("cookie",W))$.cookie=!0;if(!$.set&&Y("set",W))$.set=!0;if(!$.server&&Y("server",W))$.server=!0;if($.query&&$.headers&&$.body&&$.cookie&&$.set&&$.server&&$.server&&$.route)break}return Z},gN=(X,Z,$)=>{try{let Y=new RegExp(`(?:\\w)\\((?:.*)?${X}`,"gs");Y.test(Z);let W=Z.charCodeAt(Y.lastIndex);if(W===41||W===44)return $.query=!0,$.headers=!0,$.body=!0,$.cookie=!0,$.set=!0,$.server=!0,$.route=!0,$.request=!0,!0;return!1}catch(Y){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(X),!0}},f5=(X,Z={query:!1,headers:!1,body:!1,cookie:!1,set:!1,server:!1,request:!1,route:!1})=>{let $=[];if(X.handler&&typeof X.handler==="function")$.push(X.handler);if(X.request?.length)$.push(...X.request);if(X.beforeHandle?.length)$.push(...X.beforeHandle);if(X.parse?.length)$.push(...X.parse);if(X.error?.length)$.push(...X.error);if(X.transform?.length)$.push(...X.transform);if(X.afterHandle?.length)$.push(...X.afterHandle);if(X.mapResponse?.length)$.push(...X.mapResponse);if(X.afterResponse?.length)$.push(...X.afterResponse);for(let Y of $){if(!Y)continue;let W="fn"in Y?Y.fn:Y;if(typeof W!=="function")continue;let[J,z,{isArrowReturn:Q}]=PN(W.toString()),M=TN(J,Z),G=bN(M);if(G){let U=g5(G,z.slice(1,-1));U.splice(0,-1,G);let w=z;if(w.charCodeAt(0)===123&&w.charCodeAt(z.length-1)===125)w=w.slice(1,-1);if(!gN(G,w,Z))kN(w,U,Z);if(!Z.query&&w.includes("return "+G+".query"))Z.query=!0}if(Z.query&&Z.headers&&Z.body&&Z.cookie&&Z.set&&Z.server&&Z.request&&Z.route)break}return Z},U1=[];for(let X=48;X<58;X++)U1[X]=X-48;for(let X=0;X<6;X++)U1[X+65]=U1[X+97]=X+10;var fN=(X,Z)=>{if(X in U1&&Z in U1)return U1[X]<<4|U1[Z];return 255},v5=[...new Array(128).fill(0),...new Array(16).fill(1),...new Array(16).fill(2),...new Array(32).fill(3),4,4,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,6,7,7,7,7,7,7,7,7,7,7,7,7,8,7,7,10,9,9,9,11,4,4,4,4,4,4,4,4,4,4,4],vN=[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],O5=v5.map((X)=>[127,63,63,63,0,31,15,15,15,7,7,7][X]),hX=(X)=>{let Z=X.indexOf("%");if(Z===-1)return X;let $=X.length-3;if(Z>$)return null;let Y="",W=0,J=0,z=Z,Q=12,M;for(;;){if(M=fN(X.charCodeAt(Z+1),X.charCodeAt(Z+2)),Q=vN[Q+v5[M]],Q===0)return null;if(Q===12){if(Y+=X.substring(W,z),J=J<<6|M&O5[M],J>65535)Y+=String.fromCharCode(55232+(J>>10),56320+(J&1023));else Y+=String.fromCharCode(J);if(W=Z+3,Z=X.indexOf("%",W),Z===-1)return Y+X.substring(W);if(Z>$)return null;z=Z,J=0}else{if(Z+=3,Z>$||X.charCodeAt(Z)!==37)return null;J=J<<6|M&O5[M]}}};class o1{name;jar;initial;constructor(X,Z,$={}){this.name=X,this.jar=Z,this.initial=$}get cookie(){return this.jar[this.name]??this.initial}set cookie(X){if(!(this.name in this.jar))this.jar[this.name]=this.initial;this.jar[this.name]=X}get setCookie(){if(!(this.name in this.jar))this.jar[this.name]=this.initial;return this.jar[this.name]}set setCookie(X){this.cookie=X}get value(){return this.cookie.value}set value(X){this.setCookie.value=X}get expires(){return this.cookie.expires}set expires(X){this.setCookie.expires=X}get maxAge(){return this.cookie.maxAge}set maxAge(X){this.setCookie.maxAge=X}get domain(){return this.cookie.domain}set domain(X){this.setCookie.domain=X}get path(){return this.cookie.path}set path(X){this.setCookie.path=X}get secure(){return this.cookie.secure}set secure(X){this.setCookie.secure=X}get httpOnly(){return this.cookie.httpOnly}set httpOnly(X){this.setCookie.httpOnly=X}get sameSite(){return this.cookie.sameSite}set sameSite(X){this.setCookie.sameSite=X}get priority(){return this.cookie.priority}set priority(X){this.setCookie.priority=X}get partitioned(){return this.cookie.partitioned}set partitioned(X){this.setCookie.partitioned=X}get secrets(){return this.cookie.secrets}set secrets(X){this.setCookie.secrets=X}update(X){return this.setCookie=Object.assign(this.cookie,typeof X==="function"?X(this.cookie):X),this}set(X){return this.setCookie=Object.assign({...this.initial,value:this.value},typeof X==="function"?X(this.cookie):X),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 N5=(X,Z,$)=>{if(!X.cookie)X.cookie={};return new Proxy(Z,{get(Y,W){if(W in Z)return new o1(W,X.cookie,Object.assign({},$??{},Z[W]));return new o1(W,X.cookie,Object.assign({},$))}})},y5=async(X,Z,{secrets:$,sign:Y,...W}={})=>{if(!Z)return N5(X,{},W);let J=typeof $==="string";if(Y&&Y!==!0&&!Array.isArray(Y))Y=[Y];let z={},Q=b$.parse(Z);for(let[M,G]of Object.entries(Q)){if(G===void 0)continue;let U=hX(G);if(Y===!0||Y?.includes(M)){if(!$)throw new Error("No secret is provided to cookie plugin");if(J){let w=await M5(U,$);if(w===!1)throw new z6(M);U=w}else{let w=!0;for(let B=0;B<$.length;B++){let N=await M5(U,$[B]);if(N!==!1){w=!0,U=N;break}}if(!w)throw new z6(M)}}z[M]={value:U}}return N5(X,z,W)},d5=(X)=>{if(!X||!F8(X))return;let Z=[];for(let[$,Y]of Object.entries(X)){if(!$||!Y)continue;let W=Y.value;if(W===void 0||W===null)continue;Z.push(b$.serialize($,typeof W==="object"?JSON.stringify(W):W+"",Y))}if(Z.length===0)return;if(Z.length===1)return Z[0];return Z},mX=(X,Z)=>{let $=X.size;if(!Z&&$||$&&Z&&Z.status!==206&&Z.status!==304&&Z.status!==412&&Z.status!==416){if(Z){if(Z.headers instanceof Headers){let Y={"accept-ranges":"bytes","content-range":`bytes 0-${$-1}/${$}`,"transfer-encoding":"chunked"};if(V$)Y=Z.headers.toJSON();else{Y={};for(let[W,J]of Z.headers.entries())if(W in Z.headers)Y[W]=J}return new Response(X,{status:Z.status,headers:Y})}if(F8(Z.headers))return new Response(X,{status:Z.status,headers:Object.assign({"accept-ranges":"bytes","content-range":`bytes 0-${$-1}/${$}`,"transfer-encoding":"chunked"},Z.headers)})}return new Response(X,{headers:{"accept-ranges":"bytes","content-range":`bytes 0-${$-1}/${$}`,"transfer-encoding":"chunked"}})}return new Response(X)},h5=(X,Z)=>{if(!X)return X;X.delete("set-cookie");for(let $=0;${if(Z?.headers){if(X){if(V$)Object.assign(Z.headers,X.headers.toJSON());else for(let[$,Y]of X.headers.entries())if($ in Z.headers)Z.headers[$]=Y}if(Z.status===200)Z.status=X.status;if(Z.headers["content-encoding"])delete Z.headers["content-encoding"];return Z}if(!X)return{headers:{},status:Z?.status??200};if(V$){if(Z={headers:X.headers.toJSON(),status:Z?.status??200},Z.headers["content-encoding"])delete Z.headers["content-encoding"];return Z}Z={headers:{},status:Z?.status??200};for(let[$,Y]of X.headers.entries()){if($==="content-encoding")continue;if($ in Z.headers)Z.headers[$]=Y}return Z},L8=async(X,Z,$)=>{let Y=X.next();if(Y instanceof Promise)Y=await Y;if(Y.done){if(Z)return o2(Y.value,Z,$);return pX(Y.value,$)}if(Z?.headers){if(!Z.headers["transfer-encoding"])Z.headers["transfer-encoding"]="chunked";if(!Z.headers["content-type"])Z.headers["content-type"]="text/event-stream; charset=utf-8"}else Z={status:200,headers:{"content-type":"text/event-stream; charset=utf-8","transfer-encoding":"chunked"}};return new Response(new ReadableStream({async start(W){let J=!1;if($?.signal?.addEventListener("abort",()=>{J=!0;try{W.close()}catch{}}),Y.value!==void 0&&Y.value!==null)if(typeof Y.value==="object")try{W.enqueue(Buffer.from(JSON.stringify(Y.value)))}catch{W.enqueue(Buffer.from(Y.value.toString()))}else W.enqueue(Buffer.from(Y.value.toString()));for await(let z of X){if(J)break;if(z===void 0||z===null)continue;if(typeof z==="object")try{W.enqueue(Buffer.from(JSON.stringify(z)))}catch{W.enqueue(Buffer.from(z.toString()))}else W.enqueue(Buffer.from(z.toString()));await new Promise((Q)=>setTimeout(()=>Q(),0))}try{W.close()}catch{}}}),Z)};async function*D1(X){let Z=X.body;if(!Z)return;let $=Z.getReader(),Y=new TextDecoder;try{while(!0){let{done:W,value:J}=await $.read();if(W)break;yield Y.decode(J)}}finally{$.releaseLock()}}var m5=(X)=>{if(typeof X.status==="string")X.status=x$[X.status];if(X.cookie&&F8(X.cookie)){let Z=d5(X.cookie);if(Z)X.headers["set-cookie"]=Z}if(X.headers["set-cookie"]&&Array.isArray(X.headers["set-cookie"]))X.headers=h5(new Headers(X.headers),X.headers["set-cookie"])},I$=(X,Z)=>{if(X.status!==Z.status&&Z.status!==200&&(X.status<=300||X.status>400))X=new Response(X.body,{headers:X.headers,status:Z.status});let $=!1;if(Z.headers instanceof Headers)for(let Y of Z.headers.keys())if(Y==="set-cookie"){if($)continue;$=!0;for(let W of Z.headers.getSetCookie())X.headers.append("set-cookie",W)}else X.headers.append(Y,Z.headers?.get(Y)??"");else for(let Y in Z.headers)X.headers.append(Y,Z.headers[Y]);return X},o2=(X,Z,$)=>{if(F8(Z.headers)||Z.status!==200||Z.cookie)switch(m5(Z),X?.constructor?.name){case"String":return new Response(X,Z);case"Array":case"Object":return Response.json(X,Z);case"ElysiaFile":return mX(X.value);case"Blob":return mX(X,Z);case"ElysiaCustomStatusResponse":return Z.status=X.code,o2(X.response,Z,$);case"ReadableStream":if(!Z.headers["content-type"]?.startsWith("text/event-stream"))Z.headers["content-type"]="text/event-stream; charset=utf-8";return $?.signal?.addEventListener("abort",{handleEvent(){if($?.signal&&!$?.signal?.aborted)X.cancel()}},{once:!0}),new Response(X,Z);case void 0:if(!X)return new Response("",Z);return Response.json(X,Z);case"Response":if(X=I$(X,Z),!X.headers.has("content-length")&&X.headers.get("transfer-encoding")==="chunked")return L8(D1(X),H1(X,Z),$);return X;case"Error":return cX(X,Z);case"Promise":return X.then((Y)=>o2(Y,Z,$));case"Function":return o2(X(),Z,$);case"Number":case"Boolean":return new Response(X.toString(),Z);case"Cookie":if(X instanceof o1)return new Response(X.value,Z);return new Response(X?.toString(),Z);case"FormData":return new Response(X,Z);default:if(X instanceof Response){if(X=I$(X,Z),X.headers.get("transfer-encoding")==="chunked")return L8(D1(X),H1(X,Z),$);return X}if(X instanceof Promise)return X.then((Y)=>o2(Y,Z));if(X instanceof Error)return cX(X,Z);if(X instanceof o8)return Z.status=X.code,o2(X.response,Z,$);if(typeof X?.next==="function")return L8(X,Z,$);if(typeof X?.then==="function")return X.then((Y)=>o2(Y,Z));if(typeof X?.toResponse==="function")return o2(X.toResponse(),Z);if("charCodeAt"in X){let Y=X.charCodeAt(0);if(Y===123||Y===91){if(!Z.headers["Content-Type"])Z.headers["Content-Type"]="application/json";return new Response(JSON.stringify(X),Z)}}return new Response(X,Z)}if(X instanceof Response&&!X.headers.has("content-length")&&X.headers.get("transfer-encoding")==="chunked")return L8(D1(X),H1(X,Z),$);if(typeof X?.next==="function"||X instanceof ReadableStream)return L8(X,Z,$);return pX(X,$)},c2=(X,Z,$)=>{if(X===void 0||X===null)return;if(F8(Z.headers)||Z.status!==200||Z.cookie)switch(m5(Z),X?.constructor?.name){case"String":return new Response(X,Z);case"Array":case"Object":return Response.json(X,Z);case"ElysiaFile":return mX(X.value);case"Blob":return mX(X,Z);case"ElysiaCustomStatusResponse":return Z.status=X.code,c2(X.response,Z,$);case"ReadableStream":if(!Z.headers["content-type"]?.startsWith("text/event-stream"))Z.headers["content-type"]="text/event-stream; charset=utf-8";return $?.signal?.addEventListener("abort",{handleEvent(){if($?.signal&&!$?.signal?.aborted)X.cancel()}},{once:!0}),new Response(X,Z);case void 0:if(!X)return;return Response.json(X,Z);case"Response":if(X=I$(X,Z),!X.headers.has("content-length")&&X.headers.get("transfer-encoding")==="chunked")return L8(D1(X),H1(X,Z),$);return X;case"Promise":return X.then((Y)=>c2(Y,Z));case"Error":return cX(X,Z);case"Function":return c2(X(),Z);case"Number":case"Boolean":return new Response(X.toString(),Z);case"FormData":return new Response(X);case"Cookie":if(X instanceof o1)return new Response(X.value,Z);return new Response(X?.toString(),Z);default:if(X instanceof Response){if(X=I$(X,Z),X.headers.get("transfer-encoding")==="chunked")return L8(D1(X),H1(X,Z),$);return X}if(X instanceof Promise)return X.then((Y)=>c2(Y,Z));if(X instanceof Error)return cX(X,Z);if(X instanceof o8)return Z.status=X.code,c2(X.response,Z,$);if(typeof X?.next==="function")return L8(X,Z,$);if(typeof X?.then==="function")return X.then((Y)=>c2(Y,Z));if(typeof X?.toResponse==="function")return c2(X.toResponse(),Z);if("charCodeAt"in X){let Y=X.charCodeAt(0);if(Y===123||Y===91){if(!Z.headers["Content-Type"])Z.headers["Content-Type"]="application/json";return new Response(JSON.stringify(X),Z)}}return new Response(X,Z)}else switch(X?.constructor?.name){case"String":return new Response(X);case"Array":case"Object":return Response.json(X,Z);case"ElysiaFile":return mX(X.value);case"Blob":return mX(X,Z);case"ElysiaCustomStatusResponse":return Z.status=X.code,c2(X.response,Z,$);case"ReadableStream":return $?.signal?.addEventListener("abort",{handleEvent(){if($?.signal&&!$?.signal?.aborted)X.cancel()}},{once:!0}),new Response(X,{headers:{"Content-Type":"text/event-stream; charset=utf-8"}});case void 0:if(!X)return new Response("");return new Response(JSON.stringify(X),{headers:{"content-type":"application/json"}});case"Response":if(!X.headers.has("content-length")&&X.headers.get("transfer-encoding")==="chunked")return L8(D1(X),H1(X),$);return X;case"Promise":return X.then((Y)=>{let W=c2(Y,Z);if(W!==void 0)return W});case"Error":return cX(X,Z);case"Function":return pX(X(),$);case"Number":case"Boolean":return new Response(X.toString());case"Cookie":if(X instanceof o1)return new Response(X.value,Z);return new Response(X?.toString(),Z);case"FormData":return new Response(X);default:if(X instanceof Response)return X;if(X instanceof Promise)return X.then((Y)=>c2(Y,Z));if(X instanceof Error)return cX(X,Z);if(X instanceof o8)return Z.status=X.code,c2(X.response,Z,$);if(typeof X?.next==="function")return L8(X,Z,$);if(typeof X?.then==="function")return X.then((Y)=>c2(Y,Z));if(typeof X?.toResponse==="function")return c2(X.toResponse(),Z);if("charCodeAt"in X){let Y=X.charCodeAt(0);if(Y===123||Y===91){if(!Z.headers["Content-Type"])Z.headers["Content-Type"]="application/json";return new Response(JSON.stringify(X),Z)}}return new Response(X)}},pX=(X,Z)=>{switch(X?.constructor?.name){case"String":return new Response(X);case"Object":case"Array":return Response.json(X);case"ElysiaFile":return mX(X.value);case"Blob":return mX(X);case"ElysiaCustomStatusResponse":return o2(X.response,{status:X.code,headers:{}});case"ReadableStream":return Z?.signal?.addEventListener("abort",{handleEvent(){if(Z?.signal&&!Z?.signal?.aborted)X.cancel()}},{once:!0}),new Response(X,{headers:{"Content-Type":"text/event-stream; charset=utf-8"}});case void 0:if(!X)return new Response("");return new Response(JSON.stringify(X),{headers:{"content-type":"application/json"}});case"Response":if(X.headers.get("transfer-encoding")==="chunked")return L8(D1(X),H1(X),Z);return X;case"Error":return cX(X);case"Promise":return X.then(($)=>pX($,Z));case"Function":return pX(X(),Z);case"Number":case"Boolean":return new Response(X.toString());case"FormData":return new Response(X);default:if(X instanceof Response)return X;if(X instanceof Promise)return X.then(($)=>pX($,Z));if(X instanceof Error)return cX(X);if(X instanceof o8)return o2(X.response,{status:X.code,headers:{}});if(typeof X?.next==="function")return L8(X,void 0,Z);if(typeof X?.then==="function")return X.then(($)=>o2($,set));if(typeof X?.toResponse==="function")return pX(X.toResponse());if("charCodeAt"in X){let $=X.charCodeAt(0);if($===123||$===91)return new Response(JSON.stringify(X),{headers:{"Content-Type":"application/json"}})}return new Response(X)}},cX=(X,Z)=>new Response(JSON.stringify({name:X?.name,message:X?.message,cause:X?.cause}),{status:Z?.status!==200?Z?.status??500:500,headers:Z?.headers}),yN=(X,Z,$={})=>{if(typeof X==="function")return;let Y=o2(X,{headers:$});if(!Z.parse?.length&&!Z.transform?.length&&!Z.beforeHandle?.length&&!Z.afterHandle?.length)return Y.clone.bind(Y)},j$={name:"web-standard",isWebStandard:!0,handler:{mapResponse:o2,mapEarlyResponse:c2,mapCompactResponse:pX,createStaticHandler:yN},composeHandler:{mapResponseContext:"c.request",preferWebstandardHeaders:!0,headers:`c.headers = {} -for (const [key, value] of c.request.headers.entries())c.headers[key] = value -`,parser:{json(X){if(X)return`try{c.body=await c.request.json()}catch{} -`;return`c.body=await c.request.json() -`},text(){return`c.body=await c.request.text() -`},urlencoded(){return`c.body=parseQuery(await c.request.text()) -`},arrayBuffer(){return`c.body=await c.request.arrayBuffer() -`},formData(X){let Z=` -c.body={} -`;if(X)Z+="let form;try{form=await c.request.formData()}catch{}";else Z+=`const form=await c.request.formData() -`;return Z+`for(const key of form.keys()){if(c.body[key]) continue -const value=form.getAll(key) -if(value.length===1)c.body[key]=value[0] -else c.body[key]=value}`}}},composeGeneralHandler:{parameters:"r",createContext(X){let Z="",$="",Y=X.setHeaders;for(let z of Object.keys(X.singleton.decorator))Z+=`,${z}: decorator['${z}']`;let W=X.config.handler?.standardHostname??!0,J=!!X.event.trace?.length;if($+=`const u=r.url,s=u.indexOf('/',${W?11:7}),qi=u.indexOf('?', s + 1) -let p -if(qi===-1)p=u.substring(s) -else p=u.substring(s, qi) -`,J)$+=`const id=randomId() -`;if($+="const c={request:r,store,qi,path:p,url:u,redirect,error,set:{headers:",$+=Object.keys(Y??{}).length?"Object.assign({}, app.setHeaders)":"{}",$+=",status:200}",X.inference.server)$+=",get server(){return app.getServer()}";if(J)$+=",[ELYSIA_REQUEST_ID]:id";return $+=Z,$+=`} -`,$},websocket(X){let Z="",$=X.router.static.ws,Y=X.router.http;if(Y.build(),Object.keys($).length||Y.root.ws||Y.history.find((W)=>W["0"]==="ws")){Z+="if(r.method==='GET'){switch(p){";for(let[W,J]of Object.entries($))Z+=`case'${W}':`+(X.config.strictPath!==!0?`case'${c1(W)}':`:"")+`if(r.headers.get('upgrade')==='websocket')return ht[${J}].composed(c) -`;Z+=`default:if(r.headers.get('upgrade')==='websocket'){const route=router.find('ws',p) -if(route){c.params=route.params -if(route.store.handler)return route.store.handler(c) -return (route.store.handler=route.store.compile())(c)}}break}}`}return Z},error404(X,Z){let $="if(route===null)return ";if(Z)$+=`app.handleError(c,notFound,false,${this.parameters})`;else $+=X?"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() -const error404=new Response(error404Message,{status:404}) -`,code:$}}},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")}}},dN=(X,Z,$={})=>{if(typeof X==="function"||X instanceof Blob)return;if(typeof X==="object"&&X?.toString()==="[object HTMLBundle]")return()=>X;let Y=o2(X,{headers:$});if(!Z.parse?.length&&!Z.transform?.length&&!Z.beforeHandle?.length&&!Z.afterHandle?.length){if(!Y.headers.has("content-type"))Y.headers.append("content-type","text/plain;charset=utf-8");return Y.clone.bind(Y)}},L5={open(X){X.data.open?.(X)},message(X,Z){X.data.message?.(X,Z)},drain(X){X.data.drain?.(X)},close(X,Z,$){X.data.close?.(X,Z,$)}};class KZ{raw;data;body;validator;["~types"];get id(){return this.data.id}constructor(X,Z,$=void 0){this.raw=X,this.data=Z,this.body=$,this.validator=X.data?.validator,this.sendText=X.sendText.bind(X),this.sendBinary=X.sendBinary.bind(X),this.close=X.close.bind(X),this.terminate=X.terminate.bind(X),this.publishText=X.publishText.bind(X),this.publishBinary=X.publishBinary.bind(X),this.subscribe=X.subscribe.bind(X),this.unsubscribe=X.unsubscribe.bind(X),this.isSubscribed=X.isSubscribed.bind(X),this.cork=X.cork.bind(X),this.remoteAddress=X.remoteAddress,this.binaryType=X.binaryType,this.data=X.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(X,Z){if(Buffer.isBuffer(X))return this.raw.send(X,Z);if(this.validator?.Check(X)===!1)return this.raw.send(new G0("message",this.validator,X).message);if(typeof X==="object")X=JSON.stringify(X);return this.raw.send(X,Z)}ping(X){if(Buffer.isBuffer(X))return this.raw.ping(X);if(this.validator?.Check(X)===!1)return this.raw.send(new G0("message",this.validator,X).message);if(typeof X==="object")X=JSON.stringify(X);return this.raw.ping(X)}pong(X){if(Buffer.isBuffer(X))return this.raw.pong(X);if(this.validator?.Check(X)===!1)return this.raw.send(new G0("message",this.validator,X).message);if(typeof X==="object")X=JSON.stringify(X);return this.raw.pong(X)}publish(X,Z,$){if(Buffer.isBuffer(Z))return this.raw.publish(X,Z,$);if(this.validator?.Check(Z)===!1)return this.raw.send(new G0("message",this.validator,Z).message);if(typeof Z==="object")Z=JSON.stringify(Z);return this.raw.publish(X,Z,$)}sendText;sendBinary;close;terminate;publishText;publishBinary;subscribe;unsubscribe;isSubscribed;cork;remoteAddress;binaryType;get readyState(){return this.raw.readyState}}var hN=(X)=>{let Z=typeof X==="function"?[X]:X;return async function $(Y,W){if(typeof W==="string"){let J=W?.charCodeAt(0);if(J===34||J===47||J===91||J===123)try{W=JSON.parse(W)}catch{}else if(M6(W))W=+W;else if(W==="true")W=!0;else if(W==="false")W=!1;else if(W==="null")W=null}if(Z)for(let J=0;J{let Z=($,Y)=>{if(Y instanceof Promise)return Y.then((z)=>Z($,z));if(Buffer.isBuffer(Y))return $.send(Y.toString());if(Y===void 0)return;let W=(z)=>{if(X?.Check(z)===!1)return $.send(new G0("message",X,z).message);if(typeof z==="object")return $.send(JSON.stringify(z));$.send(z)};if(typeof Y?.next!=="function")return void W(Y);let J=Y.next();if(J instanceof Promise)return(async()=>{let z=await J;if(X?.Check(z)===!1)return $.send(new G0("message",X,z).message);if(W(z.value),!z.done)for await(let Q of Y)W(Q)})();if(W(J.value),!J.done)for(let z of Y)W(z)};return Z},pN={...j$,name:"bun",handler:{...j$.handler,createNativeStaticHandler:dN},composeHandler:{...j$.composeHandler,headers:V$?`c.headers = c.request.headers.toJSON() -`:`c.headers = {} -for (const [key, value] of c.request.headers.entries())c.headers[key] = value -`},listen(X){return(Z,$)=>{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(X.compile(),typeof Z==="string"){if(!M6(Z))throw new Error("Port must be a numeric value");Z=parseInt(Z)}let Y=X.fetch,W=typeof Z==="object"?{development:!P$,reusePort:!0,...X.config.serve||{},...Z||{},static:{...X.router.static.http.static,...X.config.serve?.static},websocket:{...X.config.websocket||{},...L5||{}},fetch:Y,error:X.outerErrorHandler}:{development:!P$,reusePort:!0,...X.config.serve||{},static:X.router.static.http.static,websocket:{...X.config.websocket||{},...L5||{}},port:Z,fetch:Y,error:X.outerErrorHandler};if(X.server=Bun?.serve(W),X.event.start)for(let J=0;J{if(X.server){if(X.server.stop?.(),X.server=null,X.event.stop)for(let J=0;J{Bun?.gc(!1)})}},ws(X,Z,$){let{parse:Y,body:W,response:J,...z}=$,Q=i2(W,{modules:X.definitions.typebox,models:X.definitions.type,normalize:X.config.normalize}),M=i2(J,{modules:X.definitions.typebox,models:X.definitions.type,normalize:X.config.normalize});X.route("$INTERNALWS",Z,async(G)=>{let U=X.getServer(),{set:w,path:B,qi:N,headers:j,query:H,params:K}=G;if(G.validator=M,$.upgrade){if(typeof $.upgrade==="function"){let I=$.upgrade(G);if(I instanceof Promise)await I}else if($.upgrade)Object.assign(w.headers,$.upgrade)}if(w.cookie&&F8(w.cookie)){let I=d5(w.cookie);if(I)w.headers["set-cookie"]=I}if(w.headers["set-cookie"]&&Array.isArray(w.headers["set-cookie"]))w.headers=h5(new Headers(w.headers),w.headers["set-cookie"]);let k=mN(M),l=hN(Y),n,A0=[...Array.isArray($.error)?$.error:[$.error],...(X.event.error??[]).map((I)=>typeof I==="function"?I:I.fn)],Z0=!A0.length?()=>{}:async(I,P)=>{for(let g of A0){let b=g(Object.assign(G,{error:P}));if(b instanceof Promise)b=await b;if(await k(I,b),b)break}};if(U?.upgrade(G.request,{headers:F8(w.headers)?w.headers:void 0,data:{...G,get id(){if(n)return n;return n=V5()},validator:M,ping(I){$.ping?.(I)},pong(I){$.pong?.(I)},open(I){try{k(I,$.open?.(new KZ(I,G)))}catch(P){Z0(I,P)}},message:async(I,P)=>{let g=await l(I,P);if(Q?.Check(g)===!1)return void I.send(new G0("message",Q,g).message);try{k(I,$.message?.(new KZ(I,G,g),g))}catch(b){Z0(I,b)}},drain(I){try{k(I,$.drain?.(new KZ(I,G)))}catch(P){Z0(I,P)}},close(I,P,g){try{k(I,$.close?.(new KZ(I,G),P,g))}catch(b){Z0(I,b)}}}}))return;return w.status=400,"Expected a websocket connection"},{...z,websocket:$})}},cN=typeof Bun!=="undefined",F5=cN?Bun.env:typeof process!=="undefined"&&process?.env?process.env:{},u1=/\+/g;function uN(X){let Z={};if(typeof X!=="string")return Z;let $="",Y="",W=-1,J=-1,z=0,Q=X.length;for(let M=0;MW;if(!G)J=M;if($=X.slice(W+1,J),G||$.length>0){if(z&1)$=$.replace(u1," ");if(z&2)$=hX($)||$;if(!Z[$]){if(G){if(Y=X.slice(J+1,M),z&4)Y=Y.replace(u1," ");if(z&8)Y=hX(Y)||Y}Z[$]=Y}}$="",Y="",W=M,J=M,z=0;break;case 61:if(J<=W)J=M;else z|=8;break;case 43:if(J>W)z|=4;else z|=1;break;case 37:if(J>W)z|=8;else z|=2;break}if(WW;if($=X.slice(W+1,M?J:Q),M||$.length>0){if(z&1)$=$.replace(u1," ");if(z&2)$=hX($)||$;if(!Z[$]){if(M){if(Y=X.slice(J+1,Q),z&4)Y=Y.replace(u1," ");if(z&8)Y=hX(Y)||Y}Z[$]=Y}}}return Z}var S$=(X)=>{let Z={};if(typeof X!=="string")return Z;let $=X.length,Y="",W="",J=-1,z=-1,Q=!1,M=!1,G=!1,U=!1,w=!1,B=0;for(let N=0;N<$+1;N++){if(N!==$)B=X.charCodeAt(N);else B=38;switch(B){case 38:{if(w=z>J,!w)z=N;if(Y=X.slice(J+1,z),w||Y.length>0){if(G)Y=Y.replace(u1," ");if(Q)Y=hX(Y)||Y;if(w){if(W=X.slice(z+1,N),U)W=W.replace(u1," ");if(M)W=hX(W)||W}let j=Z[Y];if(j===void 0)Z[Y]=W;else if(j.pop)j.push(W);else Z[Y]=[j,W]}W="",J=N,z=N,Q=!1,M=!1,G=!1,U=!1;break}case 61:if(z<=J)z=N;else M=!0;break;case 43:if(z>J)U=!0;else G=!0;break;case 37:if(z>J)M=!0;else Q=!0;break}}return Z},H6=Symbol("ElysiaTrace"),BX=()=>{let{promise:X,resolve:Z}=Promise.withResolvers(),{promise:$,resolve:Y}=Promise.withResolvers(),{promise:W,resolve:J}=Promise.withResolvers(),z=[],Q=[];return[(M)=>{if(M)z.push(M);return X},(M)=>{let G=[],U=[],w=null;for(let N=0;N<(M.total??0);N++){let{promise:j,resolve:H}=Promise.withResolvers(),{promise:K,resolve:k}=Promise.withResolvers(),{promise:l,resolve:n}=Promise.withResolvers(),A0=[],Z0=[];G.push((I)=>{if(I)A0.push(I);return j}),U.push((I)=>{let P={...I,end:K,error:l,index:N,onStop(g){if(g)Z0.push(g);return K}};H(P);for(let g=0;g{let b=performance.now();if(g)w=g;let W0={end:b,error:g,get elapsed(){return b-I.begin}};for(let z0=0;z0{return(Z)=>{let[$,Y]=BX(),[W,J]=BX(),[z,Q]=BX(),[M,G]=BX(),[U,w]=BX(),[B,N]=BX(),[j,H]=BX(),[K,k]=BX(),[l,n]=BX();return X({id:Z[T$],context:Z,set:Z.set,onRequest:$,onParse:W,onTransform:z,onBeforeHandle:M,onHandle:U,onAfterHandle:B,onMapResponse:K,onAfterResponse:l,onError:j}),{request:Y,parse:J,transform:Q,beforeHandle:G,handle:w,afterHandle:N,error:H,mapResponse:k,afterResponse:n}}},A1={optional:Symbol.for("TypeBox.Optional"),kind:Symbol.for("TypeBox.Kind")},u8=(X)=>{if(!X)return!1;let Z=X?.schema;if(Z?.[A1.kind]==="Import")return X.References().some(u8);return!!Z&&A1.optional in Z},B2=(X,Z)=>Z?X:"",oN=["json","text","urlencoded","arrayBuffer","formdata","application/json","text/plain","application/x-www-form-urlencoded","application/octet-stream","multipart/form-data"],N8=(X)=>{if(!X)return!1;let Z=X?.schema??X;if(Z[A1.kind]==="Import"&&X.References())return X.References().some(N8);if(Z.anyOf)return Z.anyOf.some(N8);if(Z.someOf)return Z.someOf.some(N8);if(Z.allOf)return Z.allOf.some(N8);if(Z.not)return Z.not.some(N8);if(Z.type==="object"){let $=Z.properties;if("additionalProperties"in Z)return Z.additionalProperties;if("patternProperties"in Z)return!1;for(let Y of Object.keys($)){let W=$[Y];if(W.type==="object"){if(N8(W))return!0}else if(W.anyOf){for(let J=0;J{if(!Z.length)return()=>{return{resolveChild(){return()=>{}},resolve(){}}};for(let Y=0;Y{if(!W)W="anonymous";let z=Y==="error"?"reportErr":"report";for(let Q=0;Q{for(let G=0;G({composeValidation:(W,J=`c.${W}`)=>`c.set.status=422;throw new ValidationError('${W}',validator.${W},${J})`,composeResponseValidation:(W="r")=>{let J=X+` -`;J+=`if(${W} instanceof ElysiaCustomStatusResponse){c.set.status=${W}.code -${W}=${W}.response}const isResponse=${W} instanceof Response -switch(c.set.status){`;for(let[z,Q]of Object.entries($.response)){if(J+=` -case ${z}:if(!isResponse){`,Z&&"Clean"in Q&&!N8(Q))J+=`${W}=validator.response['${z}'].Clean(${W}) -`;if(Y&&(Q.hasTransform||typeof Q.Decode==="function"))J+=`${W}=validator.response['${z}'].Encode(${W}) -`;J+=`if(validator.response['${z}'].Check(${W})===false){c.set.status=422 -throw new ValidationError('response',validator.response['${z}'],${W})}c.set.status = ${z}} -`,J+=`break -`}return J+"}"}}),$T=Symbol.for("TypeBox.Kind"),dX=(X,Z)=>{if(!Z)return;let $=Z.schema??Z;if($[A1.kind]==="Import")return Z.References().some((Y)=>dX(X,Y));if($.type==="object"){let Y=$.properties;if(!Y)return!1;for(let W of Object.keys(Y)){let J=Y[W];if(X in J)return!0;if(J.type==="object"){if(dX(X,J))return!0}else if(J.anyOf){for(let z=0;z{if(!X)return!1;if(X.$ref&&X.$defs&&X.$ref in X.$defs&&J8(X.$defs[X.$ref]))return!0;if(X.oneOf){for(let Z=0;Z) \S+\(/g,i1=(X)=>{return(X?.fn??X).constructor.name==="AsyncFunction"},G2=(X)=>{let Z=X?.fn??X;if(Z.constructor.name==="AsyncFunction")return!0;let $=Z.toString();if($.includes("=> response.clone("))return!1;if($.includes("await"))return!0;if($.includes("async"))return!0;if($.includes("=>response.clone("))return!1;return!!$.match(tN)},R$=(X)=>{let Z=X?.fn??X;return Z.constructor.name==="AsyncGeneratorFunction"||Z.constructor.name==="GeneratorFunction"},sN=({app:X,path:Z,method:$,hooks:Y,validator:W,handler:J,allowMeta:z=!1,inference:Q,asManifest:M=!1})=>{let G=X["~adapter"].composeHandler,U=X["~adapter"].handler,w=typeof J==="function";if(!w){if(J=U.mapResponse(J,{headers:X.setHeaders??{}}),Y.parse?.length&&Y.transform?.length&&Y.beforeHandle?.length&&Y.afterHandle?.length){if(J instanceof Response)return Function("a","return function(){return a.clone()}")(J);return Function("a","return function(){return a}")(J)}}let B=w?"handler(c)":"handler",N=!!Y.afterResponse?.length,j=!!Y.trace?.length,H="";if(Q=f5(Object.assign({},Y,{handler:J}),Q),G.declare){let f=G.declare(Q);if(f)H+=f}if(Q.server)H+=`Object.defineProperty(c,'server',{get:function(){return getServer()}}) -`;W.createBody?.(),W.createQuery?.(),W.createHeaders?.(),W.createParams?.(),W.createCookie?.(),W.createResponse?.();let K=W.body||W.headers||W.params||W.query||W.cookie||W.response,k=Q.query||!!W.query,l=Y.parse?.length===1&&Y.parse[0].fn==="none",n=$!=="$INTERNALWS"&&$!=="GET"&&$!=="HEAD"&&(Q.body||!!W.body||!!Y.parse?.length)&&!l;if(n)H+=`let isParsing=false -`;let A0=X.setHeaders,Z0=A0&&!!Object.keys(A0).length,I=Q.headers||W.headers||G.preferWebstandardHeaders!==!0&&Q.body,P=Q.cookie||!!W.cookie,g=P?R5({modules:X.definitions.typebox,validator:W.cookie,defaultConfig:X.config.cookie,dynamic:!!X.config.aot,config:W.cookie?.config??{},models:X.definitions.type}):void 0,b=g?.config,W0="";if(b?.sign){if(!b.secrets)throw new Error(`t.Cookie required secret which is not set in (${$}) ${Z}.`);let f=!b.secrets?void 0:typeof b.secrets==="string"?b.secrets:b.secrets[0];if(W0+=`const _setCookie = c.set.cookie -if(_setCookie){`,b.sign===!0)W0+=`for(const [key, cookie] of Object.entries(_setCookie)){c.set.cookie[key].value=await signCookie(cookie.value,'${f}')}`;else for(let C of b.sign)W0+=`if(_setCookie['${C}']?.value){c.set.cookie['${C}'].value=await signCookie(_setCookie['${C}'].value,'${f}')}`;W0+=`} -`}let z0=X.config.normalize,$0=X.config.experimental?.encodeSchema,{composeValidation:U0,composeResponseValidation:H2}=nN({normalize:z0,validator:W,encodeSchema:$0});if(I)H+=G.headers;if(j)H+=`const id=c[ELYSIA_REQUEST_ID] -`;let d0=D6({trace:Y.trace,addFn:(f)=>{H+=f}});if(H+="try{",P){let f=(x,u)=>{let a=b?.[x]??u;if(!a)return typeof u==="string"?`${x}:"${u}",`:`${x}:${u},`;if(typeof a==="string")return`${x}:'${a}',`;if(a instanceof Date)return`${x}: new Date(${a.getTime()}),`;return`${x}:${a},`},C=b?`{secrets:${b.secrets!==void 0?typeof b.secrets==="string"?`'${b.secrets}'`:"["+b.secrets.reduce((x,u)=>x+`'${u}',`,"")+"]":"undefined"},sign:${b.sign===!0?!0:b.sign!==void 0?"["+b.sign.reduce((x,u)=>x+`'${u}',`,"")+"]":"undefined"},`+f("domain")+f("expires")+f("httpOnly")+f("maxAge")+f("path","/")+f("priority")+f("sameSite")+f("secure")+"}":"undefined";if(I)H+=` -c.cookie=await parseCookie(c.set,c.headers.cookie,${C}) -`;else H+=` -c.cookie=await parseCookie(c.set,c.request.headers.get('cookie'),${C}) -`}if(k){let f=[];if(W.query&&W.query.schema.type==="object"){let C=W.query.schema.properties;if(!N8(W.query))for(let[x,u]of Object.entries(C)){let a=u,D=a.type==="array"||!!a.anyOf?.some((p)=>p.type==="string"&&p.format==="ArrayString");if(a&&A1.optional in a&&a.type==="array"&&a.items)a=a.items;let{type:T,anyOf:F}=a;f.push({key:x,isArray:D,isNestedObjectArray:D&&a.items?.type==="object"||!!a.items?.anyOf?.some((p)=>p.type==="object"||p.type==="array"),isObject:T==="object"||F?.some((p)=>p.type==="string"&&p.format==="ArrayString"),anyOf:!!F})}}if(!f.length)H+="if(c.qi===-1){c.query={}}else{c.query=parseQueryFromURL(c.url.slice(c.qi + 1))}";else{H+=`if(c.qi!==-1){let url='&'+c.url.slice(c.qi + 1) -`;let C=0;for(let{key:x,isArray:u,isObject:a,isNestedObjectArray:D,anyOf:T}of f){let F=(C===0?"let ":"")+`memory=url.indexOf('&${x}=') -let a${C} -`;if(u)if(H+=F,D)H+=`while(memory!==-1){const start=memory+${x.length+2} -memory=url.indexOf('&',start) -if(a${C}===undefined) -a${C}='' -else -a${C}+=',' -let temp -if(memory===-1)temp=decodeURIComponent(url.slice(start).replace(/\\+/g,' ')) -else temp=decodeURIComponent(url.slice(start, memory).replace(/\\+/g,' ')) -const charCode=temp.charCodeAt(0) -if(charCode!==91&&charCode !== 123) -temp='"'+temp+'"' -a${C}+=temp -if(memory===-1)break -memory=url.indexOf('&${x}=',memory) -if(memory===-1)break}try{if(a${C}.charCodeAt(0)===91)a${C} = JSON.parse(a${C}) -else -a${C}=JSON.parse('['+a${C}+']')}catch{} -`;else H+=`while(memory!==-1){const start=memory+${x.length+2} -memory=url.indexOf('&',start) -if(a${C}===undefined)a${C}=[] -if(memory===-1){const temp=decodeURIComponent(url.slice(start)).replace(/\\+/g,' ') -if(temp.includes(',')){a${C}=a${C}.concat(temp.split(','))}else{a${C}.push(decodeURIComponent(url.slice(start)).replace(/\\+/g,' '))} -break}else{const temp=decodeURIComponent(url.slice(start, memory)).replace(/\\+/g,' ') -if(temp.includes(',')){a${C}=a${C}.concat(temp.split(','))}else{a${C}.push(temp)} -}memory=url.indexOf('&${x}=',memory) -if(memory===-1) break -}`;else if(a)H+=F+`if(memory!==-1){const start=memory+${x.length+2} -memory=url.indexOf('&',start) -if(memory===-1)a${C}=decodeURIComponent(url.slice(start).replace(/\\+/g,' '))else a${C}=decodeURIComponent(url.slice(start,memory).replace(/\\+/g,' '))if(a${C}!==undefined)try{a${C}=JSON.parse(a${C})}catch{}}`;else{if(H+=F+`if(memory!==-1){const start=memory+${x.length+2} -memory=url.indexOf('&',start) -if(memory===-1)a${C}=decodeURIComponent(url.slice(start).replace(/\\+/g,' ')) -else{a${C}=decodeURIComponent(url.slice(start,memory).replace(/\\+/g,' '))`,T)H+=` -let deepMemory=url.indexOf('&${x}=',memory) -if(deepMemory!==-1){a${C}=[a${C}] -let first=true -while(true){const start=deepMemory+${x.length+2} -if(first)first=false -else deepMemory = url.indexOf('&', start) -let value -if(deepMemory===-1)value=url.slice(start).replace(/\\+/g,' ') -else value=url.slice(start, deepMemory).replace(/\\+/g,' ') -value=decodeURIComponent(value) -if(value===null){if(deepMemory===-1){break}else{continue}} -const vStart=value.charCodeAt(0) -const vEnd=value.charCodeAt(value.length - 1) -if((vStart===91&&vEnd===93)||(vStart===123&&vEnd===125)) -try{a${C}.push(JSON.parse(value))}catch{a${C}.push(value)}if(deepMemory===-1)break}}`;H+="}}"}C++,H+=` -`}H+="c.query={"+f.map(({key:x},u)=>`'${x}':a${u}`).join(",")+"}",H+=`} else c.query = {} -`}}let l8=typeof J==="function"&&G2(J),P2=j||Y.afterResponse?.length?"c.response= ":"",tX=P||n||l8||!!Y.parse?.length||!!Y.afterHandle?.some(G2)||!!Y.beforeHandle?.some(G2)||!!Y.transform?.some(G2)||!!Y.mapResponse?.some(G2),QY=(typeof J==="function"?R$(J):!1)||!!Y.beforeHandle?.some(R$)||!!Y.afterHandle?.some(R$)||!!Y.transform?.some(R$),j8=Q.cookie||Q.set||I||j||W.response||w&&Z0||QY,E0=G.mapResponseContext?`,${G.mapResponseContext}`:"";if(j||Q.route)H+=`c.route=\`${Z}\` -`;let s2=d0("parse",{total:Y.parse?.length});if(n){let f=u8(W.body),C=!!Y.parse?.length||Q.body||W.body;if(G.parser.declare)H+=G.parser.declare;H+=` -isParsing=true -`;let x=typeof Y.parse==="string"?Y.parse:Array.isArray(Y.parse)&&Y.parse.length===1?typeof Y.parse[0]==="string"?Y.parse[0]:typeof Y.parse[0].fn==="string"?Y.parse[0].fn:void 0:void 0;if(x&&oN.includes(x)){let u=d0("parse",{total:Y.parse?.length});switch(x){case"json":case"application/json":H+=G.parser.json(f);break;case"text":case"text/plain":H+=G.parser.text(f);break;case"urlencoded":case"application/x-www-form-urlencoded":H+=G.parser.urlencoded(f);break;case"arrayBuffer":case"application/octet-stream":H+=G.parser.arrayBuffer(f);break;case"formdata":case"multipart/form-data":H+=G.parser.formData(f);break;default:if(x[0]in X["~parser"])H+=I?"let contentType = c.headers['content-type']":"let contentType = c.request.headers.get('content-type')",H+=` -if(contentType){const index=contentType.indexOf(';') -if(index!==-1)contentType=contentType.substring(0, index)} -else{contentType=''}c.contentType=contentType -`,H+=`let result=parser['${x}'](c, contentType) -if(result instanceof Promise)result=await result -if(result instanceof ElysiaCustomStatusResponse)throw result -if(result!==undefined)c.body=result -delete c.contentType -`;break}u.resolve()}else if(C){if(H+=` -`,H+=I?"let contentType = c.headers['content-type']":"let contentType = c.request.headers.get('content-type')",H+=` -if(contentType){const index=contentType.indexOf(';') -if(index!==-1)contentType=contentType.substring(0, index)} -else{contentType=''}c.contentType=contentType -`,Y.parse?.length)H+=`let used=false -`;let u=d0("parse",{total:Y.parse?.length}),a=!1;if(Y.parse)for(let D=0;Dtypeof x==='function'?x:x.fn)??[] -return ${tX?"async ":""}function handle(c){`;if(Y.beforeHandle?.length)S8+=`let be -`;if(Y.afterHandle?.length)S8+=`let af -`;if(Y.mapResponse?.length)S8+=`let mr -`;if(z)S8+=`c.schema = schema -c.defs = definitions -`;S8+=H+"}";try{if(M)return Function("hooks",S8);return Function("hooks",S8)({handler:J,hooks:U5(Y),validator:K?W:void 0,handleError:X.handleError,mapResponse:U.mapResponse,mapCompactResponse:U.mapCompactResponse,mapEarlyResponse:U.mapEarlyResponse,isNotEmpty:F8,utils:{parseQuery:n?S$:void 0,parseQueryFromURL:k?uN:void 0},error:{ValidationError:K?G0:void 0,InternalServerError:E5,ParseError:n?C5:void 0},schema:X.router.history,definitions:X.definitions.type,ERROR_CODE:C$,parseCookie:P?y5:void 0,signCookie:P?E$:void 0,decodeURIComponent:k?hX:void 0,ElysiaCustomStatusResponse:o8,ELYSIA_TRACE:j?H6:void 0,ELYSIA_REQUEST_ID:j?T$:void 0,getServer:()=>X.getServer(),TypeBoxError:K?t:void 0,parser:X["~parser"],...G.inject})}catch(f){let C=U5(Y);console.log("[Composer] failed to generate optimized handler"),console.log("---"),console.log({handler:typeof J==="function"?J.toString():J,instruction:S8,hooks:{...C,transform:C?.transform?.map?.((x)=>x.toString()),resolve:C?.resolve?.map?.((x)=>x.toString()),beforeHandle:C?.beforeHandle?.map?.((x)=>x.toString()),afterHandle:C?.afterHandle?.map?.((x)=>x.toString()),mapResponse:C?.mapResponse?.map?.((x)=>x.toString()),parse:C?.parse?.map?.((x)=>x.toString()),error:C?.error?.map?.((x)=>x.toString()),afterResponse:C?.afterResponse?.map?.((x)=>x.toString()),stop:C?.stop?.map?.((x)=>x.toString())},validator:W,definitions:X.definitions.type,error:f,fnLiteral:H}),console.log("---"),process.exit(1)}},$6=(X,{asManifest:Z=!1}={})=>{let $=X["~adapter"].composeGeneralHandler;X.router.http.build();let Y=$.error404(!!X.event.request?.length,!!X.event.error?.length),W=X.event.trace?.length,J="",z=X.router,Q="const route=router.find(r.method,p)";Q+=z.http.root.ALL?`??router.find("ALL",p) -`:` -`,Q+=Y.code,Q+=` -c.params=route.params -if(route.store.handler)return route.store.handler(c) -return (route.store.handler=route.store.compile())(c) -`;let M="";for(let[N,j]of Object.entries(z.static.http.map)){if(M+=`case'${N}':`,X.config.strictPath!==!0)M+=`case'${c1(N)}':`;let H=qZ(N);if(N!==H)M+=`case'${H}':`;M+=`switch(r.method){${j.code} -`+(j.all??"default: break map")+"}"}let G=!!X.event.request?.some(G2),U=$.inject?Object.keys($.inject).join(",")+",":"";if(J+=` -const {app,mapEarlyResponse,NotFoundError,randomId,handleError,error,redirect,`+B2("ELYSIA_TRACE,",W)+B2("ELYSIA_REQUEST_ID,",W)+U+`}=data -const store=app.singleton.store -const decorator=app.singleton.decorator -const staticRouter=app.router.static.http -const ht=app.router.history -const router=app.router.http -const trace=app.event.trace?.map(x=>typeof x==='function'?x:x.fn)??[] -const notFound=new NotFoundError() -const hoc=app.extender.higherOrderFunctions.map(x=>x.fn) -`,X.event.request?.length)J+=`const onRequest=app.event.request.map(x=>x.fn) -`;if(J+=Y.declare,X.event.trace?.length)J+="const "+X.event.trace.map((N,j)=>`tr${j}=app.event.trace[${j}].fn`).join(",")+` -`;if(J+=`${G?"async ":""}function map(${$.parameters}){`,X.event.request?.length)J+=`let re -`;if(J+=$.createContext(X),X.event.trace?.length)J+="c[ELYSIA_TRACE]=["+X.event.trace.map((N,j)=>`tr${j}(c)`).join(",")+`] -`;let w=D6({trace:X.event.trace,addFn(N){J+=N}})("request",{total:X.event.request?.length});if(X.event.request?.length){J+="try{";for(let N=0;N{let Z=X.event,$="",Y=X["~adapter"].composeError,W=Y.inject?Object.keys(Y.inject).join(",")+",":"",J=!!X.event.trace?.length;if($+="const {app:{event:{error:onErrorContainer,afterResponse:resContainer,mapResponse:_onMapResponse,trace:_trace}},mapResponse,ERROR_CODE,ElysiaCustomStatusResponse,"+B2("ELYSIA_TRACE,",J)+B2("ELYSIA_REQUEST_ID,",J)+W+`}=inject -`,$+=`const trace=_trace?.map(x=>typeof x==='function'?x:x.fn)??[] -const onMapResponse=[] -if(_onMapResponse)for(let i=0;i<_onMapResponse.length;i++)onMapResponse.push(_onMapResponse[i].fn??_onMapResponse[i]) -delete _onMapResponse -const onError=onErrorContainer?.map(x=>x.fn)??[] -const res=resContainer?.map(x=>x.fn)??[] -return ${X.event.error?.find(G2)||X.event.mapResponse?.find(G2)?"async ":""}function(context,error,skipGlobal){`,$+="",J)$+=`const id=context[ELYSIA_REQUEST_ID] -`;let z=D6({context:"context",trace:Z.trace,addFn:(G)=>{$+=G}});if($+=`const set=context.set -let _r -if(!context.code)context.code=error.code??error[ERROR_CODE] -if(!(context.error instanceof Error))context.error=error -if(error instanceof ElysiaCustomStatusResponse){set.status=error.status=error.code -error.message=error.response}`,Y.declare)$+=Y.declare;let Q=J||!!Z.afterResponse?.length||!!Z.afterResponse?.length?"context.response = ":"";if(X.event.error)for(let G=0;G{for(let[$,Y]of Object.entries(X.schema.properties))Z[$]??=Y.default},B5=(X)=>{let{mapResponse:Z,mapEarlyResponse:$}=X["~adapter"].handler;return async(Y)=>{let W=Y.url,J=W.indexOf("/",11),z=W.indexOf("?",J+1),Q=z===-1?W.substring(J):W.substring(J,z),M={cookie:{},status:200,headers:{}},G=Object.assign({},X.singleton.decorator,{set:M,store:X.singleton.store,request:Y,path:Q,qi:z,error:w1,redirect:S5});try{if(X.event.request)for(let P=0;P{let{mapResponse:Z}=X["~adapter"].handler;return async($,Y)=>{let W=Object.assign($,{error:Y,code:Y.code});if(W.set=$.set,X.event.error)for(let J=0;JY.summary).join(` -`))}return this}wrap(X){return this.extender.higherOrderFunctions.push({checksum:BZ(JSON.stringify({name:this.config.name,seed:this.config.seed,content:X.toString()})),fn:X}),this}applyMacro(X){if(this.extender.macros.length){let Z=KN({globalHook:this.event,localHook:X}),$={events:{global:this.event,local:X},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 Y of this.extender.macros)qN(Y.fn($),X,Z)}}applyConfig(X){return this.config={prefix:"",aot:F5.ELYSIA_AOT!=="false",normalize:!0,...X,cookie:{path:"/",...X?.cookie},experimental:X?.experimental??{},seed:X?.seed===void 0?"":X?.seed},this}get models(){let X={};for(let Z of Object.keys(this.definitions.type))X[Z]=i2(this.definitions.typebox.Import(Z));return X.modules=this.definitions.typebox,X}add(X,Z,$,Y,{allowMeta:W=!1,skipPrefix:J=!1}={allowMeta:!1,skipPrefix:!1}){if(Y=Z6(jN(Y)),Z!==""&&Z.charCodeAt(0)!==47)Z="/"+Z;if(this.config.prefix&&!J)Z=this.config.prefix+Z;if(Y?.type)switch(Y.type){case"text":Y.type="text/plain";break;case"json":Y.type="application/json";break;case"formdata":Y.type="multipart/form-data";break;case"urlencoded":Y.type="application/x-www-form-urlencoded";break;case"arrayBuffer":Y.type="application/octet-stream";break;default:break}let z=this.definitions.type,Q=!this.config.aot,M={...this.validator.getCandidate()},G={body:Y?.body??M?.body,headers:Y?.headers??M?.headers,params:Y?.params??M?.params,query:Y?.query??M?.query,cookie:Y?.cookie??M?.cookie,response:Y?.response??M?.response},U=()=>G.cookie?R5({modules:B,validator:G.cookie,defaultConfig:this.config.cookie,config:G.cookie?.config??{},dynamic:Q,models:z}):void 0,w=this.config.normalize,B=this.definitions.typebox,N=this.config.precompile===!0||typeof this.config.precompile==="object"&&this.config.precompile.schema===!0?{body:i2(G.body,{modules:B,dynamic:Q,models:z,normalize:w,additionalCoerce:W5()}),headers:i2(G.headers,{modules:B,dynamic:Q,models:z,additionalProperties:!this.config.normalize,coerce:!0,additionalCoerce:M1()}),params:i2(G.params,{modules:B,dynamic:Q,models:z,coerce:!0,additionalCoerce:M1()}),query:i2(G.query,{modules:B,dynamic:Q,models:z,normalize:w,coerce:!0,additionalCoerce:M1()}),cookie:U(),response:Y5(G.response,{modules:B,dynamic:Q,models:z,normalize:w})}:{createBody(){if(this.body)return this.body;return this.body=i2(G.body,{modules:B,dynamic:Q,models:z,normalize:w,additionalCoerce:W5()})},createHeaders(){if(this.headers)return this.headers;return this.headers=i2(G.headers,{modules:B,dynamic:Q,models:z,additionalProperties:!w,coerce:!0,additionalCoerce:M1()})},createParams(){if(this.params)return this.params;return this.params=i2(G.params,{modules:B,dynamic:Q,models:z,coerce:!0,additionalCoerce:M1()})},createQuery(){if(this.query)return this.query;return this.query=i2(G.query,{modules:B,dynamic:Q,models:z,coerce:!0,additionalCoerce:M1()})},createCookie(){if(this.cookie)return this.cookie;return this.cookie=U()},createResponse(){if(this.response)return this.response;return this.response=Y5(G.response,{modules:B,dynamic:Q,models:z,normalize:w})}};if(Y=FX(Y,Z6(M)),Y.tags)if(!Y.detail)Y.detail={tags:Y.tags};else Y.detail.tags=Y.tags;if(F8(this.config.detail))Y.detail=u2(Object.assign({},this.config.detail),Y.detail);this.applyMacro(Y);let j=Z6(FX(this.event,Y));if(this.config.aot===!1){this.router.dynamic.add(X,Z,{validator:N,hooks:j,content:Y?.type,handle:$,route:Z});let $0=qZ(Z,{dynamic:!0});if(Z!==$0)this.router.dynamic.add(X,$0,{validator:N,hooks:j,content:Y?.type,handle:$,route:Z});if(this.config.strictPath===!1){let U0=c1(Z);this.router.dynamic.add(X,U0,{validator:N,hooks:j,content:Y?.type,handle:$,route:Z});let H2=qZ(U0);if(U0!==H2)this.router.dynamic.add(X,U0,{validator:N,hooks:j,content:Y?.type,handle:$,route:Z})}this.router.history.push({method:X,path:Z,composed:null,handler:$,hooks:j});return}let H=this.config.precompile===!0||typeof this.config.precompile==="object"&&this.config.precompile.compose===!0,K=X6(this.inference),k=this["~adapter"].handler,l=typeof $!=="function"&&typeof k.createStaticHandler==="function"?k.createStaticHandler($,j,this.setHeaders):void 0,n=typeof $!=="function"?k.createNativeStaticHandler?.($,j,this.setHeaders):void 0;if(this.config.nativeStaticResponse===!0&&n&&(X==="GET"||X==="ALL"))this.router.static.http.static[Z]=n();let A0=($0=!1)=>sN({app:this,path:Z,method:X,hooks:j,validator:N,handler:typeof $!=="function"&&typeof k.createStaticHandler!=="function"?()=>$:$,allowMeta:W,inference:K,asManifest:$0}),Z0;if(this.routeTree.has(X+Z))for(let $0=0;$0{let U0=(I[P].composed=A0())($0);return A0=void 0,U0};if(H)A0=void 0;let b=X==="$INTERNALWS";if(Z0!==void 0)this.router.history[Z0]=Object.assign({method:X,path:Z,composed:g,handler:$,hooks:j},Y.webSocket?{websocket:Y.websocket}:{});else this.router.history.push(Object.assign({method:X,path:Z,composed:g,handler:$,hooks:j},Y.webSocket?{websocket:Y.websocket}:{}));let W0=this.router.static.http,z0={handler:H?g:void 0,compile(){return this.handler=A0()}};if(b){if(this.router.http.add("ws",Z,z0),!this.config.strictPath)this.router.http.add("ws",c1(Z),z0);let $0=qZ(Z,{dynamic:!0});if($0!==Z)this.router.http.add("ws",$0,z0);return}if(Z.indexOf(":")===-1&&Z.indexOf("*")===-1){if(!W0.map[Z])W0.map[Z]={code:""};let $0=l?"":"c";if(X==="ALL")W0.map[Z].all=`default:return ht[${P}].composed(${$0}) -`;else W0.map[Z].code=`case '${X}':return ht[${P}].composed(${$0}) -${W0.map[Z].code}`;if(!this.config.strictPath&&this.config.nativeStaticResponse===!0&&n&&(X==="GET"||X==="ALL"))this.router.static.http.static[c1(Z)]=n()}else{if(this.router.http.add(X,Z,z0),!this.config.strictPath){let U0=c1(Z);if(this.config.nativeStaticResponse===!0&&l&&(X==="GET"||X==="ALL"))this.router.static.http.static[U0]=l();this.router.http.add(X,U0,z0)}let $0=qZ(Z,{dynamic:!0});if(Z!==$0){if(this.router.http.add(X,$0,z0),this.config.nativeStaticResponse===!0&&l&&(X==="GET"||X==="ALL"))this.router.static.http.static[$0]=l();this.router.http.add(X,$0,z0)}}}setHeaders;headers(X){if(!X)return this;if(!this.setHeaders)this.setHeaders={};return this.setHeaders=u2(this.setHeaders,X),this}onStart(X){return this.on("start",X),this}onRequest(X){return this.on("request",X),this}onParse(X,Z){if(!Z){if(typeof X==="string")return this.on("parse",this["~parser"][X]);return this.on("parse",X)}return this.on(X,"parse",Z)}parser(X,Z){return this["~parser"][X]=Z,this}onTransform(X,Z){if(!Z)return this.on("transform",X);return this.on(X,"transform",Z)}resolve(X,Z){if(!Z)Z=X,X={as:"local"};let $={subType:"resolve",fn:Z};return this.onBeforeHandle(X,$)}mapResolve(X,Z){if(!Z)Z=X,X={as:"local"};let $={subType:"mapResolve",fn:Z};return this.onBeforeHandle(X,$)}onBeforeHandle(X,Z){if(!Z)return this.on("beforeHandle",X);return this.on(X,"beforeHandle",Z)}onAfterHandle(X,Z){if(!Z)return this.on("afterHandle",X);return this.on(X,"afterHandle",Z)}mapResponse(X,Z){if(!Z)return this.on("mapResponse",X);return this.on(X,"mapResponse",Z)}onAfterResponse(X,Z){if(!Z)return this.on("afterResponse",X);return this.on(X,"afterResponse",Z)}trace(X,Z){if(!Z)Z=X,X={as:"local"};if(!Array.isArray(Z))Z=[Z];for(let $ of Z)this.on(X,"trace",iN($));return this}error(X,Z){switch(typeof X){case"string":return Z.prototype[C$]=X,this.definitions.error[X]=Z,this;case"function":return this.definitions.error=X(this.definitions.error),this}for(let[$,Y]of Object.entries(X))Y.prototype[C$]=$,this.definitions.error[$]=Y;return this}onError(X,Z){if(!Z)return this.on("error",X);return this.on(X,"error",Z)}onStop(X){return this.on("stop",X),this}on(X,Z,$){let Y;switch(typeof X){case"string":Y=X,$=Z;break;case"object":if(Y=Z,!Array.isArray(Z)&&typeof Z==="object")$=Z;break}if(Array.isArray($))$=_2($);else if(typeof $==="function")$=[{fn:$}];else $=[$];let W=$;for(let J of W)if(J.scope=typeof X==="string"?"local":X?.as??"local",Y==="resolve"||Y==="derive")J.subType=Y;if(Y!=="trace")f5({[Y]:W.map((J)=>J.fn)},this.inference);for(let J of W){let z=FN(J,"global",{skipIfHasType:!0});switch(Y){case"start":this.event.start??=[],this.event.start.push(z);break;case"request":this.event.request??=[],this.event.request.push(z);break;case"parse":this.event.parse??=[],this.event.parse.push(z);break;case"transform":this.event.transform??=[],this.event.transform.push(z);break;case"derive":this.event.transform??=[],this.event.transform.push(_2(z,"derive"));break;case"beforeHandle":this.event.beforeHandle??=[],this.event.beforeHandle.push(z);break;case"resolve":this.event.beforeHandle??=[],this.event.beforeHandle.push(_2(z,"resolve"));break;case"afterHandle":this.event.afterHandle??=[],this.event.afterHandle.push(z);break;case"mapResponse":this.event.mapResponse??=[],this.event.mapResponse.push(z);break;case"afterResponse":this.event.afterResponse??=[],this.event.afterResponse.push(z);break;case"trace":this.event.trace??=[],this.event.trace.push(z);break;case"error":this.event.error??=[],this.event.error.push(z);break;case"stop":this.event.stop??=[],this.event.stop.push(z);break}}return this}propagate(){return E2(this.event.parse),E2(this.event.transform),E2(this.event.beforeHandle),E2(this.event.afterHandle),E2(this.event.mapResponse),E2(this.event.afterResponse),E2(this.event.trace),E2(this.event.error),this}as(X){let Z={plugin:"scoped",scoped:"scoped",global:"global"}[X];if(E2(this.event.parse,Z),E2(this.event.transform,Z),E2(this.event.beforeHandle,Z),E2(this.event.afterHandle,Z),E2(this.event.mapResponse,Z),E2(this.event.afterResponse,Z),E2(this.event.trace,Z),E2(this.event.error,Z),X==="plugin")this.validator.scoped=FZ(this.validator.scoped,this.validator.local),this.validator.local=null;else if(X==="global")this.validator.global=FZ(this.validator.global,FZ(this.validator.scoped,this.validator.local)),this.validator.scoped=null,this.validator.local=null;return this}group(X,Z,$){let Y=new C2({...this.config,prefix:""});Y.singleton={...this.singleton},Y.definitions={...this.definitions},Y.getServer=()=>this.getServer(),Y.inference=X6(this.inference),Y.extender={...this.extender};let W=typeof Z==="object",J=(W?$:Z)(Y);if(this.singleton=u2(this.singleton,Y.singleton),this.definitions=u2(this.definitions,Y.definitions),J.event.request?.length)this.event.request=[...this.event.request||[],...J.event.request||[]];if(J.event.mapResponse?.length)this.event.mapResponse=[...this.event.mapResponse||[],...J.event.mapResponse||[]];return this.model(J.definitions.type),Object.values(Y.router.history).forEach(({method:z,path:Q,handler:M,hooks:G})=>{if(Q=(W?"":this.config.prefix)+X+Q,W){let U=Z,w=G;this.add(z,Q,M,FX(U,{...w||{},error:!w.error?J.event.error:Array.isArray(w.error)?[...w.error||{},...J.event.error||{}]:[w.error,...J.event.error||{}]}))}else this.add(z,Q,M,FX(G,{error:J.event.error}),{skipPrefix:!0})}),this}guard(X,Z){if(!Z){if(typeof X==="object"){this.applyMacro(X);let W=X.as??"local";if(this.validator[W]={body:X.body??this.validator[W]?.body,headers:X.headers??this.validator[W]?.headers,params:X.params??this.validator[W]?.params,query:X.query??this.validator[W]?.query,response:X.response??this.validator[W]?.response,cookie:X.cookie??this.validator[W]?.cookie},X.parse)this.on({as:W},"parse",X.parse);if(X.transform)this.on({as:W},"transform",X.transform);if(X.derive)this.on({as:W},"derive",X.derive);if(X.beforeHandle)this.on({as:W},"beforeHandle",X.beforeHandle);if(X.resolve)this.on({as:W},"resolve",X.resolve);if(X.afterHandle)this.on({as:W},"afterHandle",X.afterHandle);if(X.mapResponse)this.on({as:W},"mapResponse",X.mapResponse);if(X.afterResponse)this.on({as:W},"afterResponse",X.afterResponse);if(X.error)this.on({as:W},"error",X.error);if(X.detail)if(this.config.detail)this.config.detail=u2(Object.assign({},this.config.detail),X.detail);else this.config.detail=X.detail;if(X?.tags)if(!this.config.detail)this.config.detail={tags:X.tags};else this.config.detail.tags=X.tags;return this}return this.guard({},X)}let $=new C2({...this.config,prefix:""});$.singleton={...this.singleton},$.definitions={...this.definitions},$.inference=X6(this.inference),$.extender={...this.extender};let Y=Z($);if(this.singleton=u2(this.singleton,$.singleton),this.definitions=u2(this.definitions,$.definitions),Y.getServer=()=>this.server,Y.event.request?.length)this.event.request=[...this.event.request||[],...Y.event.request||[]];if(Y.event.mapResponse?.length)this.event.mapResponse=[...this.event.mapResponse||[],...Y.event.mapResponse||[]];return this.model(Y.definitions.type),Object.values($.router.history).forEach(({method:W,path:J,handler:z,hooks:Q})=>{this.add(W,J,z,FX(X,{...Q||{},error:!Q.error?Y.event.error:Array.isArray(Q.error)?[...Q.error||{},...Y.event.error||[]]:[Q.error,...Y.event.error||[]]}))}),this}use(X,Z){if(Array.isArray(X)){let $=this;for(let Y of X)$=$.use(Y);return $}if(Z?.scoped)return this.guard({},($)=>$.use(X));if(Array.isArray(X)){let $=this;for(let Y of X)$=this.use(Y);return $}if(X instanceof Promise)return this.promisedModules.add(X.then(($)=>{if(typeof $==="function")return $(this);if($ instanceof C2)return this._use($).compile();if($.constructor.name==="Elysia")return this._use($).compile();if(typeof $.default==="function")return $.default(this);if($.default instanceof C2)return this._use($.default);if($.constructor.name==="Elysia")return this._use($.default);if($.constructor.name==="_Elysia")return this._use($.default);try{return this._use($.default)}catch(Y){throw console.error('Invalid plugin type. Expected Elysia instance, function, or module with "default" as Elysia instance or function that returns Elysia instance.'),Y}}).then(($)=>{if($&&typeof $.compile==="function")$.compile();return $})),this;return this._use(X)}propagatePromiseModules(X){if(X.promisedModules.size<=0)return this;for(let Z of X.promisedModules.promises)this.promisedModules.add(Z.then(($)=>{if(!$)return;let Y=this._use($);if(Y instanceof Promise)return Y.then((W)=>{if(W)W.compile();else $.compile()});return $.compile()}));return this}_use(X){if(typeof X==="function"){let W=X(this);if(W instanceof Promise)return this.promisedModules.add(W.then((J)=>{if(J instanceof C2){J.getServer=()=>this.getServer(),J.getGlobalRoutes=()=>this.getGlobalRoutes(),J.model(this.definitions.type),J.error(this.definitions.error);for(let{method:z,path:Q,handler:M,hooks:G}of Object.values(J.router.history))this.add(z,Q,M,FX(G,{error:J.event.error}));if(J.compile(),J===this)return;return this.propagatePromiseModules(J),J}if(typeof J==="function")return J(this);if(typeof J.default==="function")return J.default(this);return this._use(J)}).then((J)=>{if(J&&typeof J.compile==="function")J.compile();return J})),this;return W}this.propagatePromiseModules(X);let{name:Z,seed:$}=X.config;if(X.getParent=()=>this,X.getServer=()=>this.getServer(),X.getGlobalRoutes=()=>this.getGlobalRoutes(),X.model(this.definitions.type),X.error(this.definitions.error),this["~parser"]={...X["~parser"],...this["~parser"]},this.headers(X.setHeaders),Z){if(!(Z in this.dependencies))this.dependencies[Z]=[];let W=$!==void 0?BZ(Z+JSON.stringify($)):0;if(!this.dependencies[Z].some(({checksum:J})=>W===J))this.extender.macros=this.extender.macros.concat(X.extender.macros),this.extender.higherOrderFunctions=this.extender.higherOrderFunctions.concat(X.extender.higherOrderFunctions)}else this.extender.macros=this.extender.macros.concat(X.extender.macros),this.extender.higherOrderFunctions=this.extender.higherOrderFunctions.concat(X.extender.higherOrderFunctions);H5(this.extender.macros),H5(this.extender.higherOrderFunctions);let Y=[];for(let W=0;WW===J))return this;this.dependencies[Z].push(this.config?.analytic?{name:X.config.name,seed:X.config.seed,checksum:W,dependencies:X.dependencies,stack:X.telemetry.stack,routes:X.router.history,decorators:X.singleton,store:X.singleton.store,error:X.definitions.error,derive:X.event.transform?.filter((J)=>J?.subType==="derive").map((J)=>({fn:J.toString(),stack:new Error().stack??""})),resolve:X.event.transform?.filter((J)=>J?.subType==="resolve").map((J)=>({fn:J.toString(),stack:new Error().stack??""}))}:{name:X.config.name,seed:X.config.seed,checksum:W,dependencies:X.dependencies}),this.event=J5(this.event,z5(X.event),W)}else this.event=J5(this.event,z5(X.event));return this.validator.global=FX(this.validator.global,{...X.validator.global}),this.validator.local=FX(this.validator.local,{...X.validator.scoped}),this}macro(X){if(typeof X==="function"){let Z={checksum:BZ(JSON.stringify({name:this.config.name,seed:this.config.seed,content:X.toString()})),fn:X};this.extender.macros.push(Z)}else if(typeof X==="object"){for(let $ of Object.keys(X))if(typeof X[$]==="object"){let Y={...X[$]};X[$]=(W)=>{if(W===!0)return Y}}let Z={checksum:BZ(JSON.stringify({name:this.config.name,seed:this.config.seed,content:Object.entries(X).map(([$,Y])=>`${$}+${Y}`).join(",")})),fn:()=>X};this.extender.macros.push(Z)}return this}mount(X,Z){if(X instanceof C2||typeof X==="function"||X.length===0||X==="/"){let W=typeof X==="function"?X:X instanceof C2?X.compile().fetch:Z instanceof C2?Z.compile().fetch:Z,J=({request:z,path:Q})=>W(new Request($5(z.url,Q),{method:z.method,headers:z.headers,signal:z.signal,credentials:z.credentials,referrerPolicy:z.referrerPolicy,duplex:z.duplex,redirect:z.redirect,mode:z.mode,keepalive:z.keepalive,integrity:z.integrity,body:z.body}));return this.all("/*",J,{parse:"none"}),this}if(!Z)return this;let $=X.length-(X.endsWith("*")?1:0);if(Z instanceof C2)Z=Z.compile().fetch;let Y=({request:W,path:J})=>Z(new Request($5(W.url,J.slice($)||"/"),{method:W.method,headers:W.headers,signal:W.signal,credentials:W.credentials,referrerPolicy:W.referrerPolicy,duplex:W.duplex,redirect:W.redirect,mode:W.mode,keepalive:W.keepalive,integrity:W.integrity,body:W.body}));return this.all(X,Y,{parse:"none"}),this.all(X+(X.endsWith("/")?"*":"/*"),Y,{parse:"none"}),this}get(X,Z,$){return this.add("GET",X,Z,$),this}post(X,Z,$){return this.add("POST",X,Z,$),this}put(X,Z,$){return this.add("PUT",X,Z,$),this}patch(X,Z,$){return this.add("PATCH",X,Z,$),this}delete(X,Z,$){return this.add("DELETE",X,Z,$),this}options(X,Z,$){return this.add("OPTIONS",X,Z,$),this}all(X,Z,$){return this.add("ALL",X,Z,$),this}head(X,Z,$){return this.add("HEAD",X,Z,$),this}connect(X,Z,$){return this.add("CONNECT",X,Z,$),this}route(X,Z,$,Y){return this.add(X.toUpperCase(),Z,$,Y,Y?.config),this}ws(X,Z){if(this["~adapter"].ws)this["~adapter"].ws(this,X,Z);else console.warn("Current adapter doesn't support WebSocket");return this}state(X,Z,$){if(Z===void 0)$=X,X={as:"append"},Z="";else if($===void 0){if(typeof X==="string")$=Z,Z=X,X={as:"append"};else if(typeof X==="object")$=Z,Z=""}let{as:Y}=X;if(typeof Z!=="string")return this;switch(typeof $){case"object":if(Z){if(Z in this.singleton.store)this.singleton.store[Z]=u2(this.singleton.store[Z],$,{override:Y==="override"});else this.singleton.store[Z]=$;return this}if($===null)return this;return this.singleton.store=u2(this.singleton.store,$,{override:Y==="override"}),this;case"function":if(Z){if(Y==="override"||!(Z in this.singleton.store))this.singleton.store[Z]=$}else this.singleton.store=$(this.singleton.store);return this;default:if(Y==="override"||!(Z in this.singleton.store))this.singleton.store[Z]=$;return this}}decorate(X,Z,$){if(Z===void 0)$=X,X={as:"append"},Z="";else if($===void 0){if(typeof X==="string")$=Z,Z=X,X={as:"append"};else if(typeof X==="object")$=Z,Z=""}let{as:Y}=X;if(typeof Z!=="string")return this;switch(typeof $){case"object":if(Z){if(Z in this.singleton.decorator)this.singleton.decorator[Z]=u2(this.singleton.decorator[Z],$,{override:Y==="override"});else this.singleton.decorator[Z]=$;return this}if($===null)return this;return this.singleton.decorator=u2(this.singleton.decorator,$,{override:Y==="override"}),this;case"function":if(Z){if(Y==="override"||!(Z in this.singleton.decorator))this.singleton.decorator[Z]=$}else this.singleton.decorator=$(this.singleton.decorator);return this;default:if(Y==="override"||!(Z in this.singleton.decorator))this.singleton.decorator[Z]=$;return this}}derive(X,Z){if(!Z)Z=X,X={as:"local"};let $={subType:"derive",fn:Z};return this.onTransform(X,$)}model(X,Z){let $=(Y)=>J6(Y,[{from:_.Number(),to:(W)=>_.Numeric(W),untilObjectFound:!0},{from:_.Boolean(),to:(W)=>_.BooleanString(W),untilObjectFound:!0}]);switch(typeof X){case"object":let Y={},W=Object.entries(X);for(let[Q,M]of W){if(Q in this.definitions.type)continue;Y[Q]=this.definitions.type[Q]=$(M),Y[Q].$id??=`#/components/schemas/${Q}`}return this.definitions.typebox=_.Module({...this.definitions.typebox.$defs,...Y}),this;case"function":let J=$(X(this.definitions.type));return this.definitions.type=J,this.definitions.typebox=_.Module(J),this;case"string":if(!Z)break;let z={...Z,id:Z.$id??`#/components/schemas/${X}`};return this.definitions.type[X]=Z,this.definitions.typebox=_.Module({...this.definitions.typebox.$defs,...z}),this}return this.definitions.type[X]=Z,this.definitions.typebox=_.Module({...this.definitions.typebox.$defs,[X]:Z}),this}mapDerive(X,Z){if(!Z)Z=X,X={as:"local"};let $={subType:"mapDerive",fn:Z};return this.onTransform(X,$)}affix(X,Z,$){if($==="")return this;let Y=["_","-"," "],W=(M)=>M[0].toUpperCase()+M.slice(1),J=X==="prefix"?(M,G)=>Y.includes(M.at(-1)??"")?M+G:M+W(G):Y.includes($.at(-1)??"")?(M,G)=>G+M:(M,G)=>G+W(M),z=(M)=>{let G={};switch(M){case"decorator":for(let U in this.singleton.decorator)G[J($,U)]=this.singleton.decorator[U];this.singleton.decorator=G;break;case"state":for(let U in this.singleton.store)G[J($,U)]=this.singleton.store[U];this.singleton.store=G;break;case"model":for(let U in this.definitions.type)G[J($,U)]=this.definitions.type[U];this.definitions.type=G;break;case"error":for(let U in this.definitions.error)G[J($,U)]=this.definitions.error[U];this.definitions.error=G;break}},Q=Array.isArray(Z)?Z:[Z];for(let M of Q.some((G)=>G==="all")?["decorator","state","model","error"]:Q)z(M);return this}prefix(X,Z){return this.affix("prefix",X,Z)}suffix(X,Z){return this.affix("suffix",X,Z)}compile(){if(this["~adapter"].isWebStandard){if(this.fetch=this.config.aot?$6(this):B5(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=$6(this),this}handle=async(X)=>this.fetch(X);fetch=(X)=>{return(this.fetch=this.config.aot?$6(this):B5(this))(X)};handleError=async(X,Z)=>{return(this.handleError=this.config.aot?p5(this):rN(this))(X,Z)};outerErrorHandler=(X)=>new Response(X.message||X.name||"Error",{status:X?.status??500});listen=(X,Z)=>{return this["~adapter"].listen(this)(X,Z),this};stop=async(X)=>{if(!this.server)throw new Error("Elysia isn't running. Call `app.listen` to start the server.");if(this.server){if(this.server.stop(X),this.server=null,this.event.stop?.length)for(let Z=0;Ze});var A=Symbol.for("drizzle:entityKind"),JT=Symbol.for("drizzle:hasOwnEntityKind");function E(X,Z){if(!X||typeof X!=="object")return!1;if(X instanceof Z)return!0;if(!Object.prototype.hasOwnProperty.call(Z,A))throw new Error(`Class "${Z.name??""}" doesn't look like a Drizzle entity. If this is incorrect and the class is provided by Drizzle, please report this as a bug.`);let $=Object.getPrototypeOf(X).constructor;if($)while($){if(A in $&&$[A]===Z[A])return!0;$=Object.getPrototypeOf($)}return!1}class V0{constructor(X,Z){this.table=X,this.config=Z,this.name=Z.name,this.keyAsName=Z.keyAsName,this.notNull=Z.notNull,this.default=Z.default,this.defaultFn=Z.defaultFn,this.onUpdateFn=Z.onUpdateFn,this.hasDefault=Z.hasDefault,this.primary=Z.primaryKey,this.isUnique=Z.isUnique,this.uniqueName=Z.uniqueName,this.uniqueType=Z.uniqueType,this.dataType=Z.dataType,this.columnType=Z.columnType,this.generated=Z.generated,this.generatedIdentity=Z.generatedIdentity}static[A]="Column";name;keyAsName;primary;notNull;default;defaultFn;onUpdateFn;hasDefault;isUnique;uniqueName;uniqueType;dataType;columnType;enumValues=void 0;generated=void 0;generatedIdentity=void 0;config;mapFromDriverValue(X){return X}mapToDriverValue(X){return X}shouldDisableInsert(){return this.config.generated!==void 0&&this.config.generated.type!=="byDefault"}}class A6{static[A]="ColumnBuilder";config;constructor(X,Z,$){this.config={name:X,keyAsName:X==="",notNull:!1,default:void 0,hasDefault:!1,primaryKey:!1,isUnique:!1,uniqueName:void 0,uniqueType:void 0,dataType:Z,columnType:$,generated:void 0}}$type(){return this}notNull(){return this.config.notNull=!0,this}default(X){return this.config.default=X,this.config.hasDefault=!0,this}$defaultFn(X){return this.config.defaultFn=X,this.config.hasDefault=!0,this}$default=this.$defaultFn;$onUpdateFn(X){return this.config.onUpdateFn=X,this.config.hasDefault=!0,this}$onUpdate=this.$onUpdateFn;primaryKey(){return this.config.primaryKey=!0,this.config.notNull=!0,this}setName(X){if(this.config.name!=="")return;this.config.name=X}}var n8=Symbol.for("drizzle:Name");class w6{static[A]="PgForeignKeyBuilder";reference;_onUpdate="no action";_onDelete="no action";constructor(X,Z){if(this.reference=()=>{let{name:$,columns:Y,foreignColumns:W}=X();return{name:$,columns:Y,foreignTable:W[0].table,foreignColumns:W}},Z)this._onUpdate=Z.onUpdate,this._onDelete=Z.onDelete}onUpdate(X){return this._onUpdate=X===void 0?"no action":X,this}onDelete(X){return this._onDelete=X===void 0?"no action":X,this}build(X){return new c5(X,this)}}class c5{constructor(X,Z){this.table=X,this.reference=Z.reference,this.onUpdate=Z._onUpdate,this.onDelete=Z._onDelete}static[A]="PgForeignKey";reference;onUpdate;onDelete;getName(){let{name:X,columns:Z,foreignColumns:$}=this.reference(),Y=Z.map((z)=>z.name),W=$.map((z)=>z.name),J=[this.table[n8],...Y,$[0].table[n8],...W];return X??`${J.join("_")}_fk`}}function k$(X,...Z){return X(...Z)}function u5(X){return new o5(X)}function _6(X,Z){return`${X[n8]}_${Z.join("_")}_unique`}class i5{constructor(X,Z){this.name=Z,this.columns=X}static[A]="PgUniqueConstraintBuilder";columns;nullsNotDistinctConfig=!1;nullsNotDistinct(){return this.nullsNotDistinctConfig=!0,this}build(X){return new n5(X,this.columns,this.nullsNotDistinctConfig,this.name)}}class o5{static[A]="PgUniqueOnConstraintBuilder";name;constructor(X){this.name=X}on(...X){return new i5(X,this.name)}}class n5{constructor(X,Z,$,Y){this.table=X,this.columns=Z,this.name=Y??_6(this.table,this.columns.map((W)=>W.name)),this.nullsNotDistinct=$}static[A]="PgUniqueConstraint";columns;name;nullsNotDistinct=!1;getName(){return this.name}}function l5(X,Z,$){for(let Y=Z;Y{if(Array.isArray(Z))return O6(Z);if(typeof Z==="string")return`"${Z.replace(/\\/g,"\\\\").replace(/"/g,"\\\"")}"`;return`${Z}`}).join(",")}}`}class i extends A6{foreignKeyConfigs=[];static[A]="PgColumnBuilder";array(X){return new a5(this.config.name,this,X)}references(X,Z={}){return this.foreignKeyConfigs.push({ref:X,actions:Z}),this}unique(X,Z){return this.config.isUnique=!0,this.config.uniqueName=X,this.config.uniqueType=Z?.nulls,this}generatedAlwaysAs(X){return this.config.generated={as:X,type:"always",mode:"stored"},this}buildForeignKeys(X,Z){return this.foreignKeyConfigs.map(({ref:$,actions:Y})=>{return k$((W,J)=>{let z=new w6(()=>{let Q=W();return{columns:[X],foreignColumns:[Q]}});if(J.onUpdate)z.onUpdate(J.onUpdate);if(J.onDelete)z.onDelete(J.onDelete);return z.build(Z)},$,Y)})}buildExtraConfigColumn(X){return new r5(X,this.config)}}class v extends V0{constructor(X,Z){if(!Z.uniqueName)Z.uniqueName=_6(X,[Z.name]);super(X,Z);this.table=X}static[A]="PgColumn"}class r5 extends v{static[A]="ExtraConfigColumn";getSQLType(){return this.getSQLType()}indexConfig={order:this.config.order??"asc",nulls:this.config.nulls??"last",opClass:this.config.opClass};defaultConfig={order:"asc",nulls:"last",opClass:void 0};asc(){return this.indexConfig.order="asc",this}desc(){return this.indexConfig.order="desc",this}nullsFirst(){return this.indexConfig.nulls="first",this}nullsLast(){return this.indexConfig.nulls="last",this}op(X){return this.indexConfig.opClass=X,this}}class a5 extends i{static[A]="PgArrayBuilder";constructor(X,Z,$){super(X,"array","PgArray");this.config.baseBuilder=Z,this.config.size=$}build(X){let Z=this.config.baseBuilder.build(X);return new N6(X,this.config,Z)}}class N6 extends v{constructor(X,Z,$,Y){super(X,Z);this.baseColumn=$,this.range=Y,this.size=Z.size}size;static[A]="PgArray";getSQLType(){return`${this.baseColumn.getSQLType()}[${typeof this.size==="number"?this.size:""}]`}mapFromDriverValue(X){if(typeof X==="string")X=s5(X);return X.map((Z)=>this.baseColumn.mapFromDriverValue(Z))}mapToDriverValue(X,Z=!1){let $=X.map((Y)=>Y===null?null:E(this.baseColumn,N6)?this.baseColumn.mapToDriverValue(Y,!0):this.baseColumn.mapToDriverValue(Y));if(Z)return $;return O6($)}}var e5=Symbol.for("drizzle:isPgEnum");function X4(X){return!!X&&typeof X==="function"&&e5 in X&&X[e5]===!0}class aN extends v{static[A]="PgEnumColumn";enum=this.config.enum;enumValues=this.config.enum.enumValues;constructor(X,Z){super(X,Z);this.enum=Z.enum}getSQLType(){return this.enum.enumName}}class M2{static[A]="Subquery";constructor(X,Z,$,Y=!1){this._={brand:"Subquery",sql:X,selectedFields:Z,alias:$,isWith:Y}}}class SZ extends M2{static[A]="WithSubquery"}var Z4="0.41.0";var L6,F6,v0={startActiveSpan(X,Z){if(!L6)return Z();if(!F6)F6=L6.trace.getTracer("drizzle-orm",Z4);return k$(($,Y)=>Y.startActiveSpan(X,(W)=>{try{return Z(W)}catch(J){throw W.setStatus({code:$.SpanStatusCode.ERROR,message:J instanceof Error?J.message:"Unknown error"}),J}finally{W.end()}}),L6,F6)}};var y0=Symbol.for("drizzle:ViewBaseConfig");var g$=Symbol.for("drizzle:Schema"),f$=Symbol.for("drizzle:Columns"),$4=Symbol.for("drizzle:ExtraConfigColumns"),B6=Symbol.for("drizzle:OriginalName"),q6=Symbol.for("drizzle:BaseName"),VZ=Symbol.for("drizzle:IsAlias"),Y4=Symbol.for("drizzle:ExtraConfigBuilder"),W4=Symbol.for("drizzle:IsDrizzleTable");class h{static[A]="Table";static Symbol={Name:n8,Schema:g$,OriginalName:B6,Columns:f$,ExtraConfigColumns:$4,BaseName:q6,IsAlias:VZ,ExtraConfigBuilder:Y4};[n8];[B6];[g$];[f$];[$4];[q6];[VZ]=!1;[W4]=!0;[Y4]=void 0;constructor(X,Z,$){this[n8]=this[B6]=X,this[g$]=Z,this[q6]=$}}function K6(X){return typeof X==="object"&&X!==null&&W4 in X}function n2(X){return X[n8]}function _1(X){return`${X[g$]??"public"}.${X[n8]}`}function R6(X){return X!==null&&X!==void 0&&typeof X.getSQL==="function"}function eN(X){let Z={sql:"",params:[]};for(let $ of X)if(Z.sql+=$.sql,Z.params.push(...$.params),$.typings?.length){if(!Z.typings)Z.typings=[];Z.typings.push(...$.typings)}return Z}class U2{static[A]="StringChunk";value;constructor(X){this.value=Array.isArray(X)?X:[X]}getSQL(){return new m([this])}}class m{constructor(X){this.queryChunks=X}static[A]="SQL";decoder=z4;shouldInlineParams=!1;append(X){return this.queryChunks.push(...X.queryChunks),this}toQuery(X){return v0.startActiveSpan("drizzle.buildSQL",(Z)=>{let $=this.buildQueryFromSourceParams(this.queryChunks,X);return Z?.setAttributes({"drizzle.query.text":$.sql,"drizzle.query.params":JSON.stringify($.params)}),$})}buildQueryFromSourceParams(X,Z){let $=Object.assign({},Z,{inlineParams:Z.inlineParams||this.shouldInlineParams,paramStartIndex:Z.paramStartIndex||{value:0}}),{casing:Y,escapeName:W,escapeParam:J,prepareTyping:z,inlineParams:Q,paramStartIndex:M}=$;return eN(X.map((G)=>{if(E(G,U2))return{sql:G.value.join(""),params:[]};if(E(G,v$))return{sql:W(G.value),params:[]};if(G===void 0)return{sql:"",params:[]};if(Array.isArray(G)){let U=[new U2("(")];for(let[w,B]of G.entries())if(U.push(B),wX},Q4={mapToDriverValue:(X)=>X},lT={...z4,...Q4};class z8{constructor(X,Z=Q4){this.value=X,this.encoder=Z}static[A]="Param";brand;getSQL(){return new m([this])}}function O(X,...Z){let $=[];if(Z.length>0||X.length>0&&X[0]!=="")$.push(new U2(X[0]));for(let[Y,W]of Z.entries())$.push(W,new U2(X[Y+1]));return new m($)}((X)=>{function Z(){return new m([])}X.empty=Z;function $(M){return new m(M)}X.fromList=$;function Y(M){return new m([new U2(M)])}X.raw=Y;function W(M,G){let U=[];for(let[w,B]of M.entries()){if(w>0&&G!==void 0)U.push(G);U.push(B)}return new m(U)}X.join=W;function J(M){return new v$(M)}X.identifier=J;function z(M){return new uX(M)}X.placeholder=z;function Q(M,G){return new z8(M,G)}X.param=Q})(O||(O={}));((X)=>{class Z{constructor($,Y){this.sql=$,this.fieldAlias=Y}static[A]="SQL.Aliased";isSelectionField=!1;getSQL(){return this.sql}clone(){return new Z(this.sql,this.fieldAlias)}}X.Aliased=Z})(m||(m={}));class uX{constructor(X){this.name=X}static[A]="Placeholder";getSQL(){return new m([this])}}function j6(X,Z){return X.map(($)=>{if(E($,uX)){if(!($.name in Z))throw new Error(`No value for placeholder "${$.name}" was provided`);return Z[$.name]}if(E($,z8)&&E($.value,uX)){if(!($.value.name in Z))throw new Error(`No value for placeholder "${$.value.name}" was provided`);return $.encoder.mapToDriverValue(Z[$.value.name])}return $})}var G4=Symbol.for("drizzle:IsDrizzleView");class l2{static[A]="View";[y0];[G4]=!0;constructor({name:X,schema:Z,selectedFields:$,query:Y}){this[y0]={name:X,originalName:X,schema:Z,selectedFields:$,query:Y,isExisting:!Y,isAlias:!1}}getSQL(){return new m([this])}}function M4(X){return typeof X==="object"&&X!==null&&G4 in X}V0.prototype.getSQL=function(){return new m([this])};h.prototype.getSQL=function(){return new m([this])};M2.prototype.getSQL=function(){return new m([this])};class n1{constructor(X){this.table=X}static[A]="ColumnAliasProxyHandler";get(X,Z){if(Z==="table")return this.table;return X[Z]}}class EZ{constructor(X,Z){this.alias=X,this.replaceOriginalName=Z}static[A]="TableAliasProxyHandler";get(X,Z){if(Z===h.Symbol.IsAlias)return!0;if(Z===h.Symbol.Name)return this.alias;if(this.replaceOriginalName&&Z===h.Symbol.OriginalName)return this.alias;if(Z===y0)return{...X[y0],name:this.alias,isAlias:!0};if(Z===h.Symbol.Columns){let Y=X[h.Symbol.Columns];if(!Y)return Y;let W={};return Object.keys(Y).map((J)=>{W[J]=new Proxy(Y[J],new n1(new Proxy(X,this)))}),W}let $=X[Z];if(E($,V0))return new Proxy($,new n1(new Proxy(X,this)));return $}}function y$(X,Z){return new Proxy(X,new EZ(Z,!1))}function $X(X,Z){return new Proxy(X,new n1(new Proxy(X.table,new EZ(Z,!1))))}function S6(X,Z){return new m.Aliased(CZ(X.sql,Z),X.fieldAlias)}function CZ(X,Z){return O.join(X.queryChunks.map(($)=>{if(E($,V0))return $X($,Z);if(E($,m))return CZ($,Z);if(E($,m.Aliased))return S6($,Z);return $}))}function U4(X,Z,$){let Y={},W=X.reduce((J,{path:z,field:Q},M)=>{let G;if(E(Q,V0))G=Q;else if(E(Q,m))G=Q.decoder;else G=Q.sql.decoder;let U=J;for(let[w,B]of z.entries())if(w0){for(let[J,z]of Object.entries(Y))if(typeof z==="string"&&!$[z])W[J]=null}return W}function q8(X,Z){return Object.entries(X).reduce(($,[Y,W])=>{if(typeof Y!=="string")return $;let J=Z?[...Z,Y]:[Y];if(E(W,V0)||E(W,m)||E(W,m.Aliased))$.push({path:J,field:W});else if(E(W,h))$.push(...q8(W[h.Symbol.Columns],J));else $.push(...q8(W,J));return $},[])}function PZ(X,Z){let $=Object.keys(X),Y=Object.keys(Z);if($.length!==Y.length)return!1;for(let[W,J]of $.entries())if(J!==Y[W])return!1;return!0}function d$(X,Z){let $=Object.entries(Z).filter(([,Y])=>Y!==void 0).map(([Y,W])=>{if(E(W,m)||E(W,V0))return[Y,W];else return[Y,new z8(W,X[h.Symbol.Columns][Y])]});if($.length===0)throw new Error("No values to set");return Object.fromEntries($)}function H4(X,Z){for(let $ of Z)for(let Y of Object.getOwnPropertyNames($.prototype)){if(Y==="constructor")continue;Object.defineProperty(X.prototype,Y,Object.getOwnPropertyDescriptor($.prototype,Y)||Object.create(null))}}function h$(X){return X[h.Symbol.Columns]}function D4(X){return X[y0].selectedFields}function qX(X){return E(X,M2)?X._.alias:E(X,l2)?X[y0].name:E(X,m)?void 0:X[h.Symbol.IsAlias]?X[h.Symbol.Name]:X[h.Symbol.BaseName]}function O0(X,Z){return{name:typeof X==="string"&&X.length>0?X:"",config:typeof X==="object"?X:Z}}function A4(X){if(typeof X!=="object"||X===null)return!1;if(X.constructor.name!=="Object")return!1;if("logger"in X){let Z=typeof X.logger;if(Z!=="boolean"&&(Z!=="object"||typeof X.logger.logQuery!=="function")&&Z!=="undefined")return!1;return!0}if("schema"in X){let Z=typeof X.schema;if(Z!=="object"&&Z!=="undefined")return!1;return!0}if("casing"in X){let Z=typeof X.casing;if(Z!=="string"&&Z!=="undefined")return!1;return!0}if("mode"in X){if(X.mode!=="default"||X.mode!=="planetscale"||X.mode!==void 0)return!1;return!0}if("connection"in X){let Z=typeof X.connection;if(Z!=="string"&&Z!=="object"&&Z!=="undefined")return!1;return!0}if("client"in X){let Z=typeof X.client;if(Z!=="object"&&Z!=="function"&&Z!=="undefined")return!1;return!0}if(Object.keys(X).length===0)return!0;return!1}class iX extends i{static[A]="PgIntColumnBaseBuilder";generatedAlwaysAsIdentity(X){if(X){let{name:Z,...$}=X;this.config.generatedIdentity={type:"always",sequenceName:Z,sequenceOptions:$}}else this.config.generatedIdentity={type:"always"};return this.config.hasDefault=!0,this.config.notNull=!0,this}generatedByDefaultAsIdentity(X){if(X){let{name:Z,...$}=X;this.config.generatedIdentity={type:"byDefault",sequenceName:Z,sequenceOptions:$}}else this.config.generatedIdentity={type:"byDefault"};return this.config.hasDefault=!0,this.config.notNull=!0,this}}class w4 extends iX{static[A]="PgBigInt53Builder";constructor(X){super(X,"number","PgBigInt53")}build(X){return new _4(X,this.config)}}class _4 extends v{static[A]="PgBigInt53";getSQLType(){return"bigint"}mapFromDriverValue(X){if(typeof X==="number")return X;return Number(X)}}class O4 extends iX{static[A]="PgBigInt64Builder";constructor(X){super(X,"bigint","PgBigInt64")}build(X){return new N4(X,this.config)}}class N4 extends v{static[A]="PgBigInt64";getSQLType(){return"bigint"}mapFromDriverValue(X){return BigInt(X)}}function L4(X,Z){let{name:$,config:Y}=O0(X,Z);if(Y.mode==="number")return new w4($);return new O4($)}class F4 extends i{static[A]="PgBigSerial53Builder";constructor(X){super(X,"number","PgBigSerial53");this.config.hasDefault=!0,this.config.notNull=!0}build(X){return new B4(X,this.config)}}class B4 extends v{static[A]="PgBigSerial53";getSQLType(){return"bigserial"}mapFromDriverValue(X){if(typeof X==="number")return X;return Number(X)}}class q4 extends i{static[A]="PgBigSerial64Builder";constructor(X){super(X,"bigint","PgBigSerial64");this.config.hasDefault=!0}build(X){return new K4(X,this.config)}}class K4 extends v{static[A]="PgBigSerial64";getSQLType(){return"bigserial"}mapFromDriverValue(X){return BigInt(X)}}function R4(X,Z){let{name:$,config:Y}=O0(X,Z);if(Y.mode==="number")return new F4($);return new q4($)}class j4 extends i{static[A]="PgBooleanBuilder";constructor(X){super(X,"boolean","PgBoolean")}build(X){return new S4(X,this.config)}}class S4 extends v{static[A]="PgBoolean";getSQLType(){return"boolean"}}function V4(X){return new j4(X??"")}class E4 extends i{static[A]="PgCharBuilder";constructor(X,Z){super(X,"string","PgChar");this.config.length=Z.length,this.config.enumValues=Z.enum}build(X){return new C4(X,this.config)}}class C4 extends v{static[A]="PgChar";length=this.config.length;enumValues=this.config.enumValues;getSQLType(){return this.length===void 0?"char":`char(${this.length})`}}function P4(X,Z={}){let{name:$,config:Y}=O0(X,Z);return new E4($,Y)}class I4 extends i{static[A]="PgCidrBuilder";constructor(X){super(X,"string","PgCidr")}build(X){return new x4(X,this.config)}}class x4 extends v{static[A]="PgCidr";getSQLType(){return"cidr"}}function T4(X){return new I4(X??"")}class b4 extends i{static[A]="PgCustomColumnBuilder";constructor(X,Z,$){super(X,"custom","PgCustomColumn");this.config.fieldConfig=Z,this.config.customTypeParams=$}build(X){return new k4(X,this.config)}}class k4 extends v{static[A]="PgCustomColumn";sqlName;mapTo;mapFrom;constructor(X,Z){super(X,Z);this.sqlName=Z.customTypeParams.dataType(Z.fieldConfig),this.mapTo=Z.customTypeParams.toDriver,this.mapFrom=Z.customTypeParams.fromDriver}getSQLType(){return this.sqlName}mapFromDriverValue(X){return typeof this.mapFrom==="function"?this.mapFrom(X):X}mapToDriverValue(X){return typeof this.mapTo==="function"?this.mapTo(X):X}}function g4(X){return(Z,$)=>{let{name:Y,config:W}=O0(Z,$);return new b4(Y,W,X)}}class KX extends i{static[A]="PgDateColumnBaseBuilder";defaultNow(){return this.default(O`now()`)}}class f4 extends KX{static[A]="PgDateBuilder";constructor(X){super(X,"date","PgDate")}build(X){return new m$(X,this.config)}}class m$ extends v{static[A]="PgDate";getSQLType(){return"date"}mapFromDriverValue(X){return new Date(X)}mapToDriverValue(X){return X.toISOString()}}class v4 extends KX{static[A]="PgDateStringBuilder";constructor(X){super(X,"string","PgDateString")}build(X){return new p$(X,this.config)}}class p$ extends v{static[A]="PgDateString";getSQLType(){return"date"}}function y4(X,Z){let{name:$,config:Y}=O0(X,Z);if(Y?.mode==="date")return new f4($);return new v4($)}class d4 extends i{static[A]="PgDoublePrecisionBuilder";constructor(X){super(X,"number","PgDoublePrecision")}build(X){return new h4(X,this.config)}}class h4 extends v{static[A]="PgDoublePrecision";getSQLType(){return"double precision"}mapFromDriverValue(X){if(typeof X==="string")return Number.parseFloat(X);return X}}function l1(X){return new d4(X??"")}class m4 extends i{static[A]="PgInetBuilder";constructor(X){super(X,"string","PgInet")}build(X){return new p4(X,this.config)}}class p4 extends v{static[A]="PgInet";getSQLType(){return"inet"}}function c4(X){return new m4(X??"")}class u4 extends iX{static[A]="PgIntegerBuilder";constructor(X){super(X,"number","PgInteger")}build(X){return new i4(X,this.config)}}class i4 extends v{static[A]="PgInteger";getSQLType(){return"integer"}mapFromDriverValue(X){if(typeof X==="string")return Number.parseInt(X);return X}}function oX(X){return new u4(X??"")}class o4 extends i{static[A]="PgIntervalBuilder";constructor(X,Z){super(X,"string","PgInterval");this.config.intervalConfig=Z}build(X){return new n4(X,this.config)}}class n4 extends v{static[A]="PgInterval";fields=this.config.intervalConfig.fields;precision=this.config.intervalConfig.precision;getSQLType(){let X=this.fields?` ${this.fields}`:"",Z=this.precision?`(${this.precision})`:"";return`interval${X}${Z}`}}function l4(X,Z={}){let{name:$,config:Y}=O0(X,Z);return new o4($,Y)}class t4 extends i{static[A]="PgJsonBuilder";constructor(X){super(X,"json","PgJson")}build(X){return new c$(X,this.config)}}class c$ extends v{static[A]="PgJson";constructor(X,Z){super(X,Z)}getSQLType(){return"json"}mapToDriverValue(X){return JSON.stringify(X)}mapFromDriverValue(X){if(typeof X==="string")try{return JSON.parse(X)}catch{return X}return X}}function s4(X){return new t4(X??"")}class r4 extends i{static[A]="PgJsonbBuilder";constructor(X){super(X,"json","PgJsonb")}build(X){return new u$(X,this.config)}}class u$ extends v{static[A]="PgJsonb";constructor(X,Z){super(X,Z)}getSQLType(){return"jsonb"}mapToDriverValue(X){return JSON.stringify(X)}mapFromDriverValue(X){if(typeof X==="string")try{return JSON.parse(X)}catch{return X}return X}}function a4(X){return new r4(X??"")}class e4 extends i{static[A]="PgLineBuilder";constructor(X){super(X,"array","PgLine")}build(X){return new XJ(X,this.config)}}class XJ extends v{static[A]="PgLine";getSQLType(){return"line"}mapFromDriverValue(X){let[Z,$,Y]=X.slice(1,-1).split(",");return[Number.parseFloat(Z),Number.parseFloat($),Number.parseFloat(Y)]}mapToDriverValue(X){return`{${X[0]},${X[1]},${X[2]}}`}}class ZJ extends i{static[A]="PgLineABCBuilder";constructor(X){super(X,"json","PgLineABC")}build(X){return new $J(X,this.config)}}class $J extends v{static[A]="PgLineABC";getSQLType(){return"line"}mapFromDriverValue(X){let[Z,$,Y]=X.slice(1,-1).split(",");return{a:Number.parseFloat(Z),b:Number.parseFloat($),c:Number.parseFloat(Y)}}mapToDriverValue(X){return`{${X.a},${X.b},${X.c}}`}}function YJ(X,Z){let{name:$,config:Y}=O0(X,Z);if(!Y?.mode||Y.mode==="tuple")return new e4($);return new ZJ($)}class WJ extends i{static[A]="PgMacaddrBuilder";constructor(X){super(X,"string","PgMacaddr")}build(X){return new JJ(X,this.config)}}class JJ extends v{static[A]="PgMacaddr";getSQLType(){return"macaddr"}}function zJ(X){return new WJ(X??"")}class QJ extends i{static[A]="PgMacaddr8Builder";constructor(X){super(X,"string","PgMacaddr8")}build(X){return new GJ(X,this.config)}}class GJ extends v{static[A]="PgMacaddr8";getSQLType(){return"macaddr8"}}function MJ(X){return new QJ(X??"")}class UJ extends i{static[A]="PgNumericBuilder";constructor(X,Z,$){super(X,"string","PgNumeric");this.config.precision=Z,this.config.scale=$}build(X){return new i$(X,this.config)}}class i$ extends v{static[A]="PgNumeric";precision;scale;constructor(X,Z){super(X,Z);this.precision=Z.precision,this.scale=Z.scale}mapFromDriverValue(X){if(typeof X==="string")return X;return String(X)}getSQLType(){if(this.precision!==void 0&&this.scale!==void 0)return`numeric(${this.precision}, ${this.scale})`;else if(this.precision===void 0)return"numeric";else return`numeric(${this.precision})`}}class HJ extends i{static[A]="PgNumericNumberBuilder";constructor(X,Z,$){super(X,"number","PgNumericNumber");this.config.precision=Z,this.config.scale=$}build(X){return new DJ(X,this.config)}}class DJ extends v{static[A]="PgNumericNumber";precision;scale;constructor(X,Z){super(X,Z);this.precision=Z.precision,this.scale=Z.scale}mapFromDriverValue(X){if(typeof X==="number")return X;return Number(X)}mapToDriverValue=String;getSQLType(){if(this.precision!==void 0&&this.scale!==void 0)return`numeric(${this.precision}, ${this.scale})`;else if(this.precision===void 0)return"numeric";else return`numeric(${this.precision})`}}class AJ extends i{static[A]="PgNumericBigIntBuilder";constructor(X,Z,$){super(X,"bigint","PgNumericBigInt");this.config.precision=Z,this.config.scale=$}build(X){return new wJ(X,this.config)}}class wJ extends v{static[A]="PgNumericBigInt";precision;scale;constructor(X,Z){super(X,Z);this.precision=Z.precision,this.scale=Z.scale}mapFromDriverValue=BigInt;mapToDriverValue=String;getSQLType(){if(this.precision!==void 0&&this.scale!==void 0)return`numeric(${this.precision}, ${this.scale})`;else if(this.precision===void 0)return"numeric";else return`numeric(${this.precision})`}}function _J(X,Z){let{name:$,config:Y}=O0(X,Z),W=Y?.mode;return W==="number"?new HJ($,Y?.precision,Y?.scale):W==="bigint"?new AJ($,Y?.precision,Y?.scale):new UJ($,Y?.precision,Y?.scale)}class OJ extends i{static[A]="PgPointTupleBuilder";constructor(X){super(X,"array","PgPointTuple")}build(X){return new NJ(X,this.config)}}class NJ extends v{static[A]="PgPointTuple";getSQLType(){return"point"}mapFromDriverValue(X){if(typeof X==="string"){let[Z,$]=X.slice(1,-1).split(",");return[Number.parseFloat(Z),Number.parseFloat($)]}return[X.x,X.y]}mapToDriverValue(X){return`(${X[0]},${X[1]})`}}class LJ extends i{static[A]="PgPointObjectBuilder";constructor(X){super(X,"json","PgPointObject")}build(X){return new FJ(X,this.config)}}class FJ extends v{static[A]="PgPointObject";getSQLType(){return"point"}mapFromDriverValue(X){if(typeof X==="string"){let[Z,$]=X.slice(1,-1).split(",");return{x:Number.parseFloat(Z),y:Number.parseFloat($)}}return X}mapToDriverValue(X){return`(${X.x},${X.y})`}}function BJ(X,Z){let{name:$,config:Y}=O0(X,Z);if(!Y?.mode||Y.mode==="tuple")return new OJ($);return new LJ($)}function XL(X){let Z=[];for(let $=0;${if(typeof X==="string")return Number.parseFloat(X);return X}}function PJ(X){return new EJ(X??"")}class IJ extends i{static[A]="PgSerialBuilder";constructor(X){super(X,"number","PgSerial");this.config.hasDefault=!0,this.config.notNull=!0}build(X){return new xJ(X,this.config)}}class xJ extends v{static[A]="PgSerial";getSQLType(){return"serial"}}function TJ(X){return new IJ(X??"")}class bJ extends iX{static[A]="PgSmallIntBuilder";constructor(X){super(X,"number","PgSmallInt")}build(X){return new kJ(X,this.config)}}class kJ extends v{static[A]="PgSmallInt";getSQLType(){return"smallint"}mapFromDriverValue=(X)=>{if(typeof X==="string")return Number(X);return X}}function gJ(X){return new bJ(X??"")}class fJ extends i{static[A]="PgSmallSerialBuilder";constructor(X){super(X,"number","PgSmallSerial");this.config.hasDefault=!0,this.config.notNull=!0}build(X){return new vJ(X,this.config)}}class vJ extends v{static[A]="PgSmallSerial";getSQLType(){return"smallserial"}}function yJ(X){return new fJ(X??"")}class dJ extends i{static[A]="PgTextBuilder";constructor(X,Z){super(X,"string","PgText");this.config.enumValues=Z.enum}build(X){return new hJ(X,this.config)}}class hJ extends v{static[A]="PgText";enumValues=this.config.enumValues;getSQLType(){return"text"}}function mJ(X,Z={}){let{name:$,config:Y}=O0(X,Z);return new dJ($,Y)}class pJ extends KX{constructor(X,Z,$){super(X,"string","PgTime");this.withTimezone=Z,this.precision=$,this.config.withTimezone=Z,this.config.precision=$}static[A]="PgTimeBuilder";build(X){return new o$(X,this.config)}}class o$ extends v{static[A]="PgTime";withTimezone;precision;constructor(X,Z){super(X,Z);this.withTimezone=Z.withTimezone,this.precision=Z.precision}getSQLType(){return`time${this.precision===void 0?"":`(${this.precision})`}${this.withTimezone?" with time zone":""}`}}function cJ(X,Z={}){let{name:$,config:Y}=O0(X,Z);return new pJ($,Y.withTimezone??!1,Y.precision)}class uJ extends KX{static[A]="PgTimestampBuilder";constructor(X,Z,$){super(X,"date","PgTimestamp");this.config.withTimezone=Z,this.config.precision=$}build(X){return new n$(X,this.config)}}class n$ extends v{static[A]="PgTimestamp";withTimezone;precision;constructor(X,Z){super(X,Z);this.withTimezone=Z.withTimezone,this.precision=Z.precision}getSQLType(){return`timestamp${this.precision===void 0?"":` (${this.precision})`}${this.withTimezone?" with time zone":""}`}mapFromDriverValue=(X)=>{return new Date(this.withTimezone?X:X+"+0000")};mapToDriverValue=(X)=>{return X.toISOString()}}class iJ extends KX{static[A]="PgTimestampStringBuilder";constructor(X,Z,$){super(X,"string","PgTimestampString");this.config.withTimezone=Z,this.config.precision=$}build(X){return new l$(X,this.config)}}class l$ extends v{static[A]="PgTimestampString";withTimezone;precision;constructor(X,Z){super(X,Z);this.withTimezone=Z.withTimezone,this.precision=Z.precision}getSQLType(){return`timestamp${this.precision===void 0?"":`(${this.precision})`}${this.withTimezone?" with time zone":""}`}}function oJ(X,Z={}){let{name:$,config:Y}=O0(X,Z);if(Y?.mode==="string")return new iJ($,Y.withTimezone??!1,Y.precision);return new uJ($,Y?.withTimezone??!1,Y?.precision)}class nJ extends i{static[A]="PgUUIDBuilder";constructor(X){super(X,"string","PgUUID")}defaultRandom(){return this.default(O`gen_random_uuid()`)}build(X){return new t$(X,this.config)}}class t$ extends v{static[A]="PgUUID";getSQLType(){return"uuid"}}function s$(X){return new nJ(X??"")}class lJ extends i{static[A]="PgVarcharBuilder";constructor(X,Z){super(X,"string","PgVarchar");this.config.length=Z.length,this.config.enumValues=Z.enum}build(X){return new tJ(X,this.config)}}class tJ extends v{static[A]="PgVarchar";length=this.config.length;enumValues=this.config.enumValues;getSQLType(){return this.length===void 0?"varchar":`varchar(${this.length})`}}function nX(X,Z={}){let{name:$,config:Y}=O0(X,Z);return new lJ($,Y)}class sJ extends i{static[A]="PgBinaryVectorBuilder";constructor(X,Z){super(X,"string","PgBinaryVector");this.config.dimensions=Z.dimensions}build(X){return new rJ(X,this.config)}}class rJ extends v{static[A]="PgBinaryVector";dimensions=this.config.dimensions;getSQLType(){return`bit(${this.dimensions})`}}function aJ(X,Z){let{name:$,config:Y}=O0(X,Z);return new sJ($,Y)}class eJ extends i{static[A]="PgHalfVectorBuilder";constructor(X,Z){super(X,"array","PgHalfVector");this.config.dimensions=Z.dimensions}build(X){return new Xz(X,this.config)}}class Xz extends v{static[A]="PgHalfVector";dimensions=this.config.dimensions;getSQLType(){return`halfvec(${this.dimensions})`}mapToDriverValue(X){return JSON.stringify(X)}mapFromDriverValue(X){return X.slice(1,-1).split(",").map((Z)=>Number.parseFloat(Z))}}function Zz(X,Z){let{name:$,config:Y}=O0(X,Z);return new eJ($,Y)}class $z extends i{static[A]="PgSparseVectorBuilder";constructor(X,Z){super(X,"string","PgSparseVector");this.config.dimensions=Z.dimensions}build(X){return new Yz(X,this.config)}}class Yz extends v{static[A]="PgSparseVector";dimensions=this.config.dimensions;getSQLType(){return`sparsevec(${this.dimensions})`}}function Wz(X,Z){let{name:$,config:Y}=O0(X,Z);return new $z($,Y)}class Jz extends i{static[A]="PgVectorBuilder";constructor(X,Z){super(X,"array","PgVector");this.config.dimensions=Z.dimensions}build(X){return new zz(X,this.config)}}class zz extends v{static[A]="PgVector";dimensions=this.config.dimensions;getSQLType(){return`vector(${this.dimensions})`}mapToDriverValue(X){return JSON.stringify(X)}mapFromDriverValue(X){return X.slice(1,-1).split(",").map((Z)=>Number.parseFloat(Z))}}function Qz(X,Z){let{name:$,config:Y}=O0(X,Z);return new Jz($,Y)}class b2{static[A]="QueryPromise";[Symbol.toStringTag]="QueryPromise";catch(X){return this.then(void 0,X)}finally(X){return this.then((Z)=>{return X?.(),Z},(Z)=>{throw X?.(),Z})}then(X,Z){return this.execute().then(X,Z)}}class X2{static[A]="SelectionProxyHandler";config;constructor(X){this.config={...X}}get(X,Z){if(Z==="_")return{...X._,selectedFields:new Proxy(X._.selectedFields,this)};if(Z===y0)return{...X[y0],selectedFields:new Proxy(X[y0].selectedFields,this)};if(typeof Z==="symbol")return X[Z];let Y=(E(X,M2)?X._.selectedFields:E(X,l2)?X[y0].selectedFields:X)[Z];if(E(Y,m.Aliased)){if(this.config.sqlAliasedBehavior==="sql"&&!Y.isSelectionField)return Y.sql;let W=Y.clone();return W.isSelectionField=!0,W}if(E(Y,m)){if(this.config.sqlBehavior==="sql")return Y;throw new Error(`You tried to reference "${Z}" field from a subquery, which is a raw SQL field, but it doesn't have an alias declared. Please add an alias to the field using ".as('alias')" method.`)}if(E(Y,V0)){if(this.config.alias)return new Proxy(Y,new n1(new Proxy(Y.table,new EZ(this.config.alias,this.config.replaceOriginalName??!1))));return Y}if(typeof Y!=="object"||Y===null)return Y;return new Proxy(Y,new X2(this.config))}}class r$ extends b2{constructor(X,Z,$,Y){super();this.session=Z,this.dialect=$,this.config={table:X,withList:Y}}static[A]="PgDelete";config;where(X){return this.config.where=X,this}returning(X=this.config.table[h.Symbol.Columns]){return this.config.returningFields=X,this.config.returning=q8(X),this}getSQL(){return this.dialect.buildDeleteQuery(this.config)}toSQL(){let{typings:X,...Z}=this.dialect.sqlToQuery(this.getSQL());return Z}_prepare(X){return v0.startActiveSpan("drizzle.prepareQuery",()=>{return this.session.prepareQuery(this.dialect.sqlToQuery(this.getSQL()),this.config.returning,X,!0)})}prepare(X){return this._prepare(X)}authToken;setToken(X){return this.authToken=X,this}execute=(X)=>{return v0.startActiveSpan("drizzle.operation",()=>{return this._prepare().execute(X,this.authToken)})};getSelectedFields(){return this.config.returningFields?new Proxy(this.config.returningFields,new X2({alias:n2(this.config.table),sqlAliasedBehavior:"alias",sqlBehavior:"error"})):void 0}$dynamic(){return this}}function ZL(X){return(X.replace(/['\u2019]/g,"").match(/[\da-z]+|[A-Z]+(?![a-z])|[A-Z][\da-z]+/g)??[]).map(($)=>$.toLowerCase()).join("_")}function $L(X){return(X.replace(/['\u2019]/g,"").match(/[\da-z]+|[A-Z]+(?![a-z])|[A-Z][\da-z]+/g)??[]).reduce(($,Y,W)=>{let J=W===0?Y.toLowerCase():`${Y[0].toUpperCase()}${Y.slice(1)}`;return $+J},"")}function YL(X){return X}class E6{static[A]="CasingCache";cache={};cachedTables={};convert;constructor(X){this.convert=X==="snake_case"?ZL:X==="camelCase"?$L:YL}getColumnCasing(X){if(!X.keyAsName)return X.name;let Z=X.table[h.Symbol.Schema]??"public",$=X.table[h.Symbol.OriginalName],Y=`${Z}.${$}.${X.name}`;if(!this.cache[Y])this.cacheTable(X.table);return this.cache[Y]}cacheTable(X){let Z=X[h.Symbol.Schema]??"public",$=X[h.Symbol.OriginalName],Y=`${Z}.${$}`;if(!this.cachedTables[Y]){for(let W of Object.values(X[h.Symbol.Columns])){let J=`${Y}.${W.name}`;this.cache[J]=this.convert(W.name)}this.cachedTables[Y]=!0}}clearCache(){this.cache={},this.cachedTables={}}}class a$ extends Error{static[A]="DrizzleError";constructor({message:X,cause:Z}){super(X);this.name="DrizzleError",this.cause=Z}}class C6 extends a${static[A]="TransactionRollbackError";constructor(){super({message:"Rollback"})}}function Gz(){return{bigint:L4,bigserial:R4,boolean:V4,char:P4,cidr:T4,customType:g4,date:y4,doublePrecision:l1,inet:c4,integer:oX,interval:l4,json:s4,jsonb:a4,line:YJ,macaddr:zJ,macaddr8:MJ,numeric:_J,point:BJ,geometry:VJ,real:PJ,serial:TJ,smallint:gJ,smallserial:yJ,text:mJ,time:cJ,timestamp:oJ,uuid:s$,varchar:nX,bit:aJ,halfvec:Zz,sparsevec:Wz,vector:Qz}}var P6=Symbol.for("drizzle:PgInlineForeignKeys"),Mz=Symbol.for("drizzle:EnableRLS");class q2 extends h{static[A]="PgTable";static Symbol=Object.assign({},h.Symbol,{InlineForeignKeys:P6,EnableRLS:Mz});[P6]=[];[Mz]=!1;[h.Symbol.ExtraConfigBuilder]=void 0;[h.Symbol.ExtraConfigColumns]={}}function WL(X,Z,$,Y,W=X){let J=new q2(X,Y,W),z=typeof Z==="function"?Z(Gz()):Z,Q=Object.fromEntries(Object.entries(z).map(([U,w])=>{let B=w;B.setName(U);let N=B.build(J);return J[P6].push(...B.buildForeignKeys(N,J)),[U,N]})),M=Object.fromEntries(Object.entries(z).map(([U,w])=>{let B=w;B.setName(U);let N=B.buildExtraConfigColumn(J);return[U,N]})),G=Object.assign(J,Q);if(G[h.Symbol.Columns]=Q,G[h.Symbol.ExtraConfigColumns]=M,$)G[q2.Symbol.ExtraConfigBuilder]=$;return Object.assign(G,{enableRLS:()=>{return G[q2.Symbol.EnableRLS]=!0,G}})}var Uz=(X,Z,$)=>{return WL(X,Z,$,void 0)};class I6{static[A]="PgPrimaryKeyBuilder";columns;name;constructor(X,Z){this.columns=X,this.name=Z}build(X){return new Hz(X,this.columns,this.name)}}class Hz{constructor(X,Z,$){this.table=X,this.columns=Z,this.name=$}static[A]="PgPrimaryKey";columns;name;getName(){return this.name??`${this.table[q2.Symbol.Name]}_${this.columns.map((X)=>X.name).join("_")}_pk`}}function t2(X,Z){if(J4(Z)&&!R6(X)&&!E(X,z8)&&!E(X,uX)&&!E(X,V0)&&!E(X,h)&&!E(X,l2))return new z8(X,Z);return X}var K8=(X,Z)=>{return O`${X} = ${t2(Z,X)}`},Dz=(X,Z)=>{return O`${X} <> ${t2(Z,X)}`};function RX(...X){let Z=X.filter(($)=>$!==void 0);if(Z.length===0)return;if(Z.length===1)return new m(Z);return new m([new U2("("),O.join(Z,new U2(" and ")),new U2(")")])}function Az(...X){let Z=X.filter(($)=>$!==void 0);if(Z.length===0)return;if(Z.length===1)return new m(Z);return new m([new U2("("),O.join(Z,new U2(" or ")),new U2(")")])}function wz(X){return O`not ${X}`}var _z=(X,Z)=>{return O`${X} > ${t2(Z,X)}`},Oz=(X,Z)=>{return O`${X} >= ${t2(Z,X)}`},Nz=(X,Z)=>{return O`${X} < ${t2(Z,X)}`},Lz=(X,Z)=>{return O`${X} <= ${t2(Z,X)}`};function t1(X,Z){if(Array.isArray(Z)){if(Z.length===0)return O`false`;return O`${X} in ${Z.map(($)=>t2($,X))}`}return O`${X} in ${t2(Z,X)}`}function Fz(X,Z){if(Array.isArray(Z)){if(Z.length===0)return O`true`;return O`${X} not in ${Z.map(($)=>t2($,X))}`}return O`${X} not in ${t2(Z,X)}`}function Bz(X){return O`${X} is null`}function qz(X){return O`${X} is not null`}function Kz(X){return O`exists ${X}`}function Rz(X){return O`not exists ${X}`}function R8(X,Z,$){return O`${X} between ${t2(Z,X)} and ${t2($,X)}`}function jz(X,Z,$){return O`${X} not between ${t2(Z,X)} and ${t2($,X)}`}function Sz(X,Z){return O`${X} like ${Z}`}function Vz(X,Z){return O`${X} not like ${Z}`}function Ez(X,Z){return O`${X} ilike ${Z}`}function Cz(X,Z){return O`${X} not ilike ${Z}`}function e$(X){return O`${X} asc`}function XY(X){return O`${X} desc`}class x6{constructor(X,Z,$){this.sourceTable=X,this.referencedTable=Z,this.relationName=$,this.referencedTableName=Z[h.Symbol.Name]}static[A]="Relation";referencedTableName;fieldName}class Pz{constructor(X,Z){this.table=X,this.config=Z}static[A]="Relations"}class lX extends x6{constructor(X,Z,$,Y){super(X,Z,$?.relationName);this.config=$,this.isNullable=Y}static[A]="One";withFieldName(X){let Z=new lX(this.sourceTable,this.referencedTable,this.config,this.isNullable);return Z.fieldName=X,Z}}class IZ extends x6{constructor(X,Z,$){super(X,Z,$?.relationName);this.config=$}static[A]="Many";withFieldName(X){let Z=new IZ(this.sourceTable,this.referencedTable,this.config);return Z.fieldName=X,Z}}function Iz(){return{and:RX,between:R8,eq:K8,exists:Kz,gt:_z,gte:Oz,ilike:Ez,inArray:t1,isNull:Bz,isNotNull:qz,like:Sz,lt:Nz,lte:Lz,ne:Dz,not:wz,notBetween:jz,notExists:Rz,notLike:Vz,notIlike:Cz,notInArray:Fz,or:Az,sql:O}}function xz(){return{sql:O,asc:e$,desc:XY}}function Tz(X,Z){if(Object.keys(X).length===1&&"default"in X&&!E(X.default,h))X=X.default;let $={},Y={},W={};for(let[J,z]of Object.entries(X))if(E(z,h)){let Q=_1(z),M=Y[Q];$[Q]=J,W[J]={tsName:J,dbName:z[h.Symbol.Name],schema:z[h.Symbol.Schema],columns:z[h.Symbol.Columns],relations:M?.relations??{},primaryKey:M?.primaryKey??[]};for(let U of Object.values(z[h.Symbol.Columns]))if(U.primary)W[J].primaryKey.push(U);let G=z[h.Symbol.ExtraConfigBuilder]?.(z[h.Symbol.ExtraConfigColumns]);if(G){for(let U of Object.values(G))if(E(U,I6))W[J].primaryKey.push(...U.columns)}}else if(E(z,Pz)){let Q=_1(z.table),M=$[Q],G=z.config(Z(z.table)),U;for(let[w,B]of Object.entries(G))if(M){let N=W[M];if(N.relations[w]=B,U)N.primaryKey.push(...U)}else{if(!(Q in Y))Y[Q]={relations:{},primaryKey:U};Y[Q].relations[w]=B}}return{tables:W,tableNamesMap:$}}function JL(X){return function Z($,Y){return new lX(X,$,Y,Y?.fields.reduce((W,J)=>W&&J.notNull,!0)??!1)}}function zL(X){return function Z($,Y){return new IZ(X,$,Y)}}function bz(X,Z,$){if(E($,lX)&&$.config)return{fields:$.config.fields,references:$.config.references};let Y=Z[_1($.referencedTable)];if(!Y)throw new Error(`Table "${$.referencedTable[h.Symbol.Name]}" not found in schema`);let W=X[Y];if(!W)throw new Error(`Table "${Y}" not found in schema`);let J=$.sourceTable,z=Z[_1(J)];if(!z)throw new Error(`Table "${J[h.Symbol.Name]}" not found in schema`);let Q=[];for(let M of Object.values(W.relations))if($.relationName&&$!==M&&M.relationName===$.relationName||!$.relationName&&M.referencedTable===$.sourceTable)Q.push(M);if(Q.length>1)throw $.relationName?new Error(`There are multiple relations with name "${$.relationName}" in table "${Y}"`):new Error(`There are multiple relations between "${Y}" and "${$.sourceTable[h.Symbol.Name]}". Please specify relation name`);if(Q[0]&&E(Q[0],lX)&&Q[0].config)return{fields:Q[0].config.references,references:Q[0].config.fields};throw new Error(`There is not enough information to infer relation "${z}.${$.fieldName}"`)}function kz(X){return{one:JL(X),many:zL(X)}}function ZY(X,Z,$,Y,W=(J)=>J){let J={};for(let[z,Q]of Y.entries())if(Q.isJson){let M=Z.relations[Q.tsKey],G=$[z],U=typeof G==="string"?JSON.parse(G):G;J[Q.tsKey]=E(M,lX)?U&&ZY(X,X[Q.relationTableTsKey],U,Q.selection,W):U.map((w)=>ZY(X,X[Q.relationTableTsKey],w,Q.selection,W))}else{let M=W($[z]),G=Q.field,U;if(E(G,V0))U=G;else if(E(G,m))U=G.decoder;else U=G.sql.decoder;J[Q.tsKey]=M===null?null:U.mapFromDriverValue(M)}return J}function gz(X){return O`count(${X||O.raw("*")})`.mapWith(Number)}function $Y(X){return O`max(${X})`.mapWith(E(X,V0)?X:String)}function YY(X){return O`min(${X})`.mapWith(E(X,V0)?X:String)}class xZ extends l2{static[A]="PgViewBase"}class O1{static[A]="PgDialect";casing;constructor(X){this.casing=new E6(X?.casing)}async migrate(X,Z,$){let Y=typeof $==="string"?"__drizzle_migrations":$.migrationsTable??"__drizzle_migrations",W=typeof $==="string"?"drizzle":$.migrationsSchema??"drizzle",J=O` - CREATE TABLE IF NOT EXISTS ${O.identifier(W)}.${O.identifier(Y)} ( - id SERIAL PRIMARY KEY, - hash text NOT NULL, - created_at bigint - ) - `;await Z.execute(O`CREATE SCHEMA IF NOT EXISTS ${O.identifier(W)}`),await Z.execute(J);let Q=(await Z.all(O`select id, hash, created_at from ${O.identifier(W)}.${O.identifier(Y)} order by created_at desc limit 1`))[0];await Z.transaction(async(M)=>{for await(let G of X)if(!Q||Number(Q.created_at)Z[J]!==void 0||$[J]?.onUpdateFn!==void 0),W=Y.length;return O.join(Y.flatMap((J,z)=>{let Q=$[J],M=Z[J]??O.param(Q.onUpdateFn(),Q),G=O`${O.identifier(this.casing.getColumnCasing(Q))} = ${M}`;if(z{let z=[];if(E(W,m.Aliased)&&W.isSelectionField)z.push(O.identifier(W.fieldAlias));else if(E(W,m.Aliased)||E(W,m)){let Q=E(W,m.Aliased)?W.sql:W;if(Z)z.push(new m(Q.queryChunks.map((M)=>{if(E(M,v))return O.identifier(this.casing.getColumnCasing(M));return M})));else z.push(Q);if(E(W,m.Aliased))z.push(O` as ${O.identifier(W.fieldAlias)}`)}else if(E(W,V0))if(Z)z.push(O.identifier(this.casing.getColumnCasing(W)));else z.push(W);if(J<$-1)z.push(O`, `);return z});return O.join(Y)}buildJoins(X){if(!X||X.length===0)return;let Z=[];for(let[$,Y]of X.entries()){if($===0)Z.push(O` `);let W=Y.table,J=Y.lateral?O` lateral`:void 0;if(E(W,q2)){let z=W[q2.Symbol.Name],Q=W[q2.Symbol.Schema],M=W[q2.Symbol.OriginalName],G=z===M?void 0:Y.alias;Z.push(O`${O.raw(Y.joinType)} join${J} ${Q?O`${O.identifier(Q)}.`:void 0}${O.identifier(M)}${G&&O` ${O.identifier(G)}`} on ${Y.on}`)}else if(E(W,l2)){let z=W[y0].name,Q=W[y0].schema,M=W[y0].originalName,G=z===M?void 0:Y.alias;Z.push(O`${O.raw(Y.joinType)} join${J} ${Q?O`${O.identifier(Q)}.`:void 0}${O.identifier(M)}${G&&O` ${O.identifier(G)}`} on ${Y.on}`)}else Z.push(O`${O.raw(Y.joinType)} join${J} ${W} on ${Y.on}`);if($z?.some(({alias:d0})=>d0===(H2[h.Symbol.IsAlias]?n2(H2):H2[h.Symbol.BaseName])))(U0.field.table)){let H2=n2(U0.field.table);throw new Error(`Your "${U0.path.join("->")}" field references a column "${H2}"."${U0.field.name}", but the table "${H2}" is not part of the query! Did you forget to join it?`)}let H=!z||z.length===0,K=this.buildWithCTE(X),k;if(B)k=B===!0?O` distinct`:O` distinct on (${O.join(B.on,O`, `)})`;let l=this.buildSelection(j,{isSingleTable:H}),n=this.buildFromTable(J),A0=this.buildJoins(z),Z0=Y?O` where ${Y}`:void 0,I=W?O` having ${W}`:void 0,P;if(Q&&Q.length>0)P=O` order by ${O.join(Q,O`, `)}`;let g;if(M&&M.length>0)g=O` group by ${O.join(M,O`, `)}`;let b=typeof G==="object"||typeof G==="number"&&G>=0?O` limit ${G}`:void 0,W0=U?O` offset ${U}`:void 0,z0=O.empty();if(w){let U0=O` for ${O.raw(w.strength)}`;if(w.config.of)U0.append(O` of ${O.join(Array.isArray(w.config.of)?w.config.of:[w.config.of],O`, `)}`);if(w.config.noWait)U0.append(O` no wait`);else if(w.config.skipLocked)U0.append(O` skip locked`);z0.append(U0)}let $0=O`${K}select${k} ${l} from ${n}${A0}${Z0}${g}${I}${P}${b}${W0}${z0}`;if(N.length>0)return this.buildSetOperations($0,N);return $0}buildSetOperations(X,Z){let[$,...Y]=Z;if(!$)throw new Error("Cannot pass undefined values to any set operator");if(Y.length===0)return this.buildSetOperationQuery({leftSelect:X,setOperator:$});return this.buildSetOperations(this.buildSetOperationQuery({leftSelect:X,setOperator:$}),Y)}buildSetOperationQuery({leftSelect:X,setOperator:{type:Z,isAll:$,rightSelect:Y,limit:W,orderBy:J,offset:z}}){let Q=O`(${X.getSQL()}) `,M=O`(${Y.getSQL()})`,G;if(J&&J.length>0){let N=[];for(let j of J)if(E(j,v))N.push(O.identifier(j.name));else if(E(j,m)){for(let H=0;H=0?O` limit ${W}`:void 0,w=O.raw(`${Z} ${$?"all ":""}`),B=z?O` offset ${z}`:void 0;return O`${Q}${w}${M}${G}${U}${B}`}buildInsertQuery({table:X,values:Z,onConflict:$,returning:Y,withList:W,select:J,overridingSystemValue_:z}){let Q=[],M=X[h.Symbol.Columns],G=Object.entries(M).filter(([K,k])=>!k.shouldDisableInsert()),U=G.map(([,K])=>O.identifier(this.casing.getColumnCasing(K)));if(J){let K=Z;if(E(K,m))Q.push(K);else Q.push(K.getSQL())}else{let K=Z;Q.push(O.raw("values "));for(let[k,l]of K.entries()){let n=[];for(let[A0,Z0]of G){let I=l[A0];if(I===void 0||E(I,z8)&&I.value===void 0)if(Z0.defaultFn!==void 0){let P=Z0.defaultFn(),g=E(P,m)?P:O.param(P,Z0);n.push(g)}else if(!Z0.default&&Z0.onUpdateFn!==void 0){let P=Z0.onUpdateFn(),g=E(P,m)?P:O.param(P,Z0);n.push(g)}else n.push(O`default`);else n.push(I)}if(Q.push(n),k({dbKey:l.name,tsKey:k,field:$X(l,z),relationTableTsKey:void 0,isJson:!1,selection:[]}));else{let K=Object.fromEntries(Object.entries(W.columns).map(([I,P])=>[I,$X(P,z)]));if(J.where){let I=typeof J.where==="function"?J.where(K,Iz()):J.where;N=I&&CZ(I,z)}let k=[],l=[];if(J.columns){let I=!1;for(let[P,g]of Object.entries(J.columns)){if(g===void 0)continue;if(P in W.columns){if(!I&&g===!0)I=!0;l.push(P)}}if(l.length>0)l=I?l.filter((P)=>J.columns?.[P]===!0):Object.keys(W.columns).filter((P)=>!l.includes(P))}else l=Object.keys(W.columns);for(let I of l){let P=W.columns[I];k.push({tsKey:I,value:P})}let n=[];if(J.with)n=Object.entries(J.with).filter((I)=>!!I[1]).map(([I,P])=>({tsKey:I,queryConfig:P,relation:W.relations[I]}));let A0;if(J.extras){A0=typeof J.extras==="function"?J.extras(K,{sql:O}):J.extras;for(let[I,P]of Object.entries(A0))k.push({tsKey:I,value:S6(P,z)})}for(let{tsKey:I,value:P}of k)G.push({dbKey:E(P,m.Aliased)?P.fieldAlias:W.columns[I].name,tsKey:I,field:E(P,V0)?$X(P,z):P,relationTableTsKey:void 0,isJson:!1,selection:[]});let Z0=typeof J.orderBy==="function"?J.orderBy(K,xz()):J.orderBy??[];if(!Array.isArray(Z0))Z0=[Z0];B=Z0.map((I)=>{if(E(I,V0))return $X(I,z);return CZ(I,z)}),U=J.limit,w=J.offset;for(let{tsKey:I,queryConfig:P,relation:g}of n){let b=bz(Z,$,g),W0=_1(g.referencedTable),z0=$[W0],$0=`${z}_${I}`,U0=RX(...b.fields.map((l8,P2)=>K8($X(b.references[P2],$0),$X(l8,z)))),H2=this.buildRelationalQueryWithoutPK({fullSchema:X,schema:Z,tableNamesMap:$,table:X[z0],tableConfig:Z[z0],queryConfig:E(g,lX)?P===!0?{limit:1}:{...P,limit:1}:P,tableAlias:$0,joinOn:U0,nestedQueryRelation:g}),d0=O`${O.identifier($0)}.${O.identifier("data")}`.as(I);j.push({on:O`true`,table:new M2(H2.sql,{},$0),alias:$0,joinType:"left",lateral:!0}),G.push({dbKey:I,tsKey:I,field:d0,relationTableTsKey:z0,isJson:!0,selection:H2.selection})}}if(G.length===0)throw new a$({message:`No fields selected for table "${W.tsName}" ("${z}")`});let H;if(N=RX(M,N),Q){let K=O`json_build_array(${O.join(G.map(({field:n,tsKey:A0,isJson:Z0})=>Z0?O`${O.identifier(`${z}_${A0}`)}.${O.identifier("data")}`:E(n,m.Aliased)?n.sql:n),O`, `)})`;if(E(Q,IZ))K=O`coalesce(json_agg(${K}${B.length>0?O` order by ${O.join(B,O`, `)}`:void 0}), '[]'::json)`;let k=[{dbKey:"data",tsKey:"data",field:K.as("data"),isJson:!0,relationTableTsKey:W.tsName,selection:G}];if(U!==void 0||w!==void 0||B.length>0)H=this.buildSelectQuery({table:y$(Y,z),fields:{},fieldsFlat:[{path:[],field:O.raw("*")}],where:N,limit:U,offset:w,orderBy:B,setOperators:[]}),N=void 0,U=void 0,w=void 0,B=[];else H=y$(Y,z);H=this.buildSelectQuery({table:E(H,q2)?H:new M2(H,{},z),fields:{},fieldsFlat:k.map(({field:n})=>({path:[],field:E(n,V0)?$X(n,z):n})),joins:j,where:N,limit:U,offset:w,orderBy:B,setOperators:[]})}else H=this.buildSelectQuery({table:y$(Y,z),fields:{},fieldsFlat:G.map(({field:K})=>({path:[],field:E(K,V0)?$X(K,z):K})),joins:j,where:N,limit:U,offset:w,orderBy:B,setOperators:[]});return{tableTsKey:W.tsName,sql:H,selection:G}}}class T6{static[A]="TypedQueryBuilder";getSelectedFields(){return this._.selectedFields}}class k2{static[A]="PgSelectBuilder";fields;session;dialect;withList=[];distinct;constructor(X){if(this.fields=X.fields,this.session=X.session,this.dialect=X.dialect,X.withList)this.withList=X.withList;this.distinct=X.distinct}authToken;setToken(X){return this.authToken=X,this}from(X){let Z=!!this.fields,$=X,Y;if(this.fields)Y=this.fields;else if(E($,M2))Y=Object.fromEntries(Object.keys($._.selectedFields).map((W)=>[W,$[W]]));else if(E($,xZ))Y=$[y0].selectedFields;else if(E($,m))Y={};else Y=h$($);return new b6({table:$,fields:Y,isPartialSelect:Z,session:this.session,dialect:this.dialect,withList:this.withList,distinct:this.distinct}).setToken(this.authToken)}}class fz extends T6{static[A]="PgSelectQueryBuilder";_;config;joinsNotNullableMap;tableName;isPartialSelect;session;dialect;constructor({table:X,fields:Z,isPartialSelect:$,session:Y,dialect:W,withList:J,distinct:z}){super();this.config={withList:J,table:X,fields:{...Z},distinct:z,setOperators:[]},this.isPartialSelect=$,this.session=Y,this.dialect=W,this._={selectedFields:Z},this.tableName=qX(X),this.joinsNotNullableMap=typeof this.tableName==="string"?{[this.tableName]:!0}:{}}createJoin(X){return(Z,$)=>{let Y=this.tableName,W=qX(Z);if(typeof W==="string"&&this.config.joins?.some((J)=>J.alias===W))throw new Error(`Alias "${W}" is already used in this query`);if(!this.isPartialSelect){if(Object.keys(this.joinsNotNullableMap).length===1&&typeof Y==="string")this.config.fields={[Y]:this.config.fields};if(typeof W==="string"&&!E(Z,m)){let J=E(Z,M2)?Z._.selectedFields:E(Z,l2)?Z[y0].selectedFields:Z[h.Symbol.Columns];this.config.fields[W]=J}}if(typeof $==="function")$=$(new Proxy(this.config.fields,new X2({sqlAliasedBehavior:"sql",sqlBehavior:"sql"})));if(!this.config.joins)this.config.joins=[];if(this.config.joins.push({on:$,table:Z,joinType:X,alias:W}),typeof W==="string")switch(X){case"left":{this.joinsNotNullableMap[W]=!1;break}case"right":{this.joinsNotNullableMap=Object.fromEntries(Object.entries(this.joinsNotNullableMap).map(([J])=>[J,!1])),this.joinsNotNullableMap[W]=!0;break}case"inner":{this.joinsNotNullableMap[W]=!0;break}case"full":{this.joinsNotNullableMap=Object.fromEntries(Object.entries(this.joinsNotNullableMap).map(([J])=>[J,!1])),this.joinsNotNullableMap[W]=!1;break}}return this}}leftJoin=this.createJoin("left");rightJoin=this.createJoin("right");innerJoin=this.createJoin("inner");fullJoin=this.createJoin("full");createSetOperator(X,Z){return($)=>{let Y=typeof $==="function"?$(QL()):$;if(!PZ(this.getSelectedFields(),Y.getSelectedFields()))throw new Error("Set operator error (union / intersect / except): selected fields are not the same or are in a different order");return this.config.setOperators.push({type:X,isAll:Z,rightSelect:Y}),this}}union=this.createSetOperator("union",!1);unionAll=this.createSetOperator("union",!0);intersect=this.createSetOperator("intersect",!1);intersectAll=this.createSetOperator("intersect",!0);except=this.createSetOperator("except",!1);exceptAll=this.createSetOperator("except",!0);addSetOperators(X){return this.config.setOperators.push(...X),this}where(X){if(typeof X==="function")X=X(new Proxy(this.config.fields,new X2({sqlAliasedBehavior:"sql",sqlBehavior:"sql"})));return this.config.where=X,this}having(X){if(typeof X==="function")X=X(new Proxy(this.config.fields,new X2({sqlAliasedBehavior:"sql",sqlBehavior:"sql"})));return this.config.having=X,this}groupBy(...X){if(typeof X[0]==="function"){let Z=X[0](new Proxy(this.config.fields,new X2({sqlAliasedBehavior:"alias",sqlBehavior:"sql"})));this.config.groupBy=Array.isArray(Z)?Z:[Z]}else this.config.groupBy=X;return this}orderBy(...X){if(typeof X[0]==="function"){let Z=X[0](new Proxy(this.config.fields,new X2({sqlAliasedBehavior:"alias",sqlBehavior:"sql"}))),$=Array.isArray(Z)?Z:[Z];if(this.config.setOperators.length>0)this.config.setOperators.at(-1).orderBy=$;else this.config.orderBy=$}else{let Z=X;if(this.config.setOperators.length>0)this.config.setOperators.at(-1).orderBy=Z;else this.config.orderBy=Z}return this}limit(X){if(this.config.setOperators.length>0)this.config.setOperators.at(-1).limit=X;else this.config.limit=X;return this}offset(X){if(this.config.setOperators.length>0)this.config.setOperators.at(-1).offset=X;else this.config.offset=X;return this}for(X,Z={}){return this.config.lockingClause={strength:X,config:Z},this}getSQL(){return this.dialect.buildSelectQuery(this.config)}toSQL(){let{typings:X,...Z}=this.dialect.sqlToQuery(this.getSQL());return Z}as(X){return new Proxy(new M2(this.getSQL(),this.config.fields,X),new X2({alias:X,sqlAliasedBehavior:"alias",sqlBehavior:"error"}))}getSelectedFields(){return new Proxy(this.config.fields,new X2({alias:this.tableName,sqlAliasedBehavior:"alias",sqlBehavior:"error"}))}$dynamic(){return this}}class b6 extends fz{static[A]="PgSelect";_prepare(X){let{session:Z,config:$,dialect:Y,joinsNotNullableMap:W,authToken:J}=this;if(!Z)throw new Error("Cannot execute a query on a query builder. Please use a database instance instead.");return v0.startActiveSpan("drizzle.prepareQuery",()=>{let z=q8($.fields),Q=Z.prepareQuery(Y.sqlToQuery(this.getSQL()),z,X,!0);return Q.joinsNotNullableMap=W,Q.setToken(J)})}prepare(X){return this._prepare(X)}authToken;setToken(X){return this.authToken=X,this}execute=(X)=>{return v0.startActiveSpan("drizzle.operation",()=>{return this._prepare().execute(X,this.authToken)})}}H4(b6,[b2]);function s1(X,Z){return($,Y,...W)=>{let J=[Y,...W].map((z)=>({type:X,isAll:Z,rightSelect:z}));for(let z of J)if(!PZ($.getSelectedFields(),z.rightSelect.getSelectedFields()))throw new Error("Set operator error (union / intersect / except): selected fields are not the same or are in a different order");return $.addSetOperators(J)}}var QL=()=>({union:GL,unionAll:ML,intersect:UL,intersectAll:HL,except:DL,exceptAll:AL}),GL=s1("union",!1),ML=s1("union",!0),UL=s1("intersect",!1),HL=s1("intersect",!0),DL=s1("except",!1),AL=s1("except",!0);class TZ{static[A]="PgQueryBuilder";dialect;dialectConfig;constructor(X){this.dialect=E(X,O1)?X:void 0,this.dialectConfig=E(X,O1)?void 0:X}$with=(X,Z)=>{let $=this;return{as:(W)=>{if(typeof W==="function")W=W($);return new Proxy(new SZ(W.getSQL(),Z??("getSelectedFields"in W?W.getSelectedFields()??{}:{}),X,!0),new X2({alias:X,sqlAliasedBehavior:"alias",sqlBehavior:"error"}))}}};with(...X){let Z=this;function $(J){return new k2({fields:J??void 0,session:void 0,dialect:Z.getDialect(),withList:X})}function Y(J){return new k2({fields:J??void 0,session:void 0,dialect:Z.getDialect(),distinct:!0})}function W(J,z){return new k2({fields:z??void 0,session:void 0,dialect:Z.getDialect(),distinct:{on:J}})}return{select:$,selectDistinct:Y,selectDistinctOn:W}}select(X){return new k2({fields:X??void 0,session:void 0,dialect:this.getDialect()})}selectDistinct(X){return new k2({fields:X??void 0,session:void 0,dialect:this.getDialect(),distinct:!0})}selectDistinctOn(X,Z){return new k2({fields:Z??void 0,session:void 0,dialect:this.getDialect(),distinct:{on:X}})}getDialect(){if(!this.dialect)this.dialect=new O1(this.dialectConfig);return this.dialect}}class WY{constructor(X,Z,$,Y,W){this.table=X,this.session=Z,this.dialect=$,this.withList=Y,this.overridingSystemValue_=W}static[A]="PgInsertBuilder";authToken;setToken(X){return this.authToken=X,this}overridingSystemValue(){return this.overridingSystemValue_=!0,this}values(X){if(X=Array.isArray(X)?X:[X],X.length===0)throw new Error("values() must be called with at least one value");let Z=X.map(($)=>{let Y={},W=this.table[h.Symbol.Columns];for(let J of Object.keys($)){let z=$[J];Y[J]=E(z,m)?z:new z8(z,W[J])}return Y});return new k6(this.table,Z,this.session,this.dialect,this.withList,!1,this.overridingSystemValue_).setToken(this.authToken)}select(X){let Z=typeof X==="function"?X(new TZ):X;if(!E(Z,m)&&!PZ(this.table[f$],Z._.selectedFields))throw new Error("Insert select error: selected fields are not the same or are in a different order compared to the table definition");return new k6(this.table,Z,this.session,this.dialect,this.withList,!0)}}class k6 extends b2{constructor(X,Z,$,Y,W,J,z){super();this.session=$,this.dialect=Y,this.config={table:X,values:Z,withList:W,select:J,overridingSystemValue_:z}}static[A]="PgInsert";config;returning(X=this.config.table[h.Symbol.Columns]){return this.config.returningFields=X,this.config.returning=q8(X),this}onConflictDoNothing(X={}){if(X.target===void 0)this.config.onConflict=O`do nothing`;else{let Z="";Z=Array.isArray(X.target)?X.target.map((Y)=>this.dialect.escapeName(this.dialect.casing.getColumnCasing(Y))).join(","):this.dialect.escapeName(this.dialect.casing.getColumnCasing(X.target));let $=X.where?O` where ${X.where}`:void 0;this.config.onConflict=O`(${O.raw(Z)})${$} do nothing`}return this}onConflictDoUpdate(X){if(X.where&&(X.targetWhere||X.setWhere))throw new Error('You cannot use both "where" and "targetWhere"/"setWhere" at the same time - "where" is deprecated, use "targetWhere" or "setWhere" instead.');let Z=X.where?O` where ${X.where}`:void 0,$=X.targetWhere?O` where ${X.targetWhere}`:void 0,Y=X.setWhere?O` where ${X.setWhere}`:void 0,W=this.dialect.buildUpdateSet(this.config.table,d$(this.config.table,X.set)),J="";return J=Array.isArray(X.target)?X.target.map((z)=>this.dialect.escapeName(this.dialect.casing.getColumnCasing(z))).join(","):this.dialect.escapeName(this.dialect.casing.getColumnCasing(X.target)),this.config.onConflict=O`(${O.raw(J)})${$} do update set ${W}${Z}${Y}`,this}getSQL(){return this.dialect.buildInsertQuery(this.config)}toSQL(){let{typings:X,...Z}=this.dialect.sqlToQuery(this.getSQL());return Z}_prepare(X){return v0.startActiveSpan("drizzle.prepareQuery",()=>{return this.session.prepareQuery(this.dialect.sqlToQuery(this.getSQL()),this.config.returning,X,!0)})}prepare(X){return this._prepare(X)}authToken;setToken(X){return this.authToken=X,this}execute=(X)=>{return v0.startActiveSpan("drizzle.operation",()=>{return this._prepare().execute(X,this.authToken)})};getSelectedFields(){return this.config.returningFields?new Proxy(this.config.returningFields,new X2({alias:n2(this.config.table),sqlAliasedBehavior:"alias",sqlBehavior:"error"})):void 0}$dynamic(){return this}}class g6 extends b2{constructor(X,Z,$){super();this.session=Z,this.dialect=$,this.config={view:X}}static[A]="PgRefreshMaterializedView";config;concurrently(){if(this.config.withNoData!==void 0)throw new Error("Cannot use concurrently and withNoData together");return this.config.concurrently=!0,this}withNoData(){if(this.config.concurrently!==void 0)throw new Error("Cannot use concurrently and withNoData together");return this.config.withNoData=!0,this}getSQL(){return this.dialect.buildRefreshMaterializedViewQuery(this.config)}toSQL(){let{typings:X,...Z}=this.dialect.sqlToQuery(this.getSQL());return Z}_prepare(X){return v0.startActiveSpan("drizzle.prepareQuery",()=>{return this.session.prepareQuery(this.dialect.sqlToQuery(this.getSQL()),void 0,X,!0)})}prepare(X){return this._prepare(X)}authToken;setToken(X){return this.authToken=X,this}execute=(X)=>{return v0.startActiveSpan("drizzle.operation",()=>{return this._prepare().execute(X,this.authToken)})}}class JY{constructor(X,Z,$,Y){this.table=X,this.session=Z,this.dialect=$,this.withList=Y}static[A]="PgUpdateBuilder";authToken;setToken(X){return this.authToken=X,this}set(X){return new vz(this.table,d$(this.table,X),this.session,this.dialect,this.withList).setToken(this.authToken)}}class vz extends b2{constructor(X,Z,$,Y,W){super();this.session=$,this.dialect=Y,this.config={set:Z,table:X,withList:W,joins:[]},this.tableName=qX(X),this.joinsNotNullableMap=typeof this.tableName==="string"?{[this.tableName]:!0}:{}}static[A]="PgUpdate";config;tableName;joinsNotNullableMap;from(X){let Z=X,$=qX(Z);if(typeof $==="string")this.joinsNotNullableMap[$]=!0;return this.config.from=Z,this}getTableLikeFields(X){if(E(X,q2))return X[h.Symbol.Columns];else if(E(X,M2))return X._.selectedFields;return X[y0].selectedFields}createJoin(X){return(Z,$)=>{let Y=qX(Z);if(typeof Y==="string"&&this.config.joins.some((W)=>W.alias===Y))throw new Error(`Alias "${Y}" is already used in this query`);if(typeof $==="function"){let W=this.config.from&&!E(this.config.from,m)?this.getTableLikeFields(this.config.from):void 0;$=$(new Proxy(this.config.table[h.Symbol.Columns],new X2({sqlAliasedBehavior:"sql",sqlBehavior:"sql"})),W&&new Proxy(W,new X2({sqlAliasedBehavior:"sql",sqlBehavior:"sql"})))}if(this.config.joins.push({on:$,table:Z,joinType:X,alias:Y}),typeof Y==="string")switch(X){case"left":{this.joinsNotNullableMap[Y]=!1;break}case"right":{this.joinsNotNullableMap=Object.fromEntries(Object.entries(this.joinsNotNullableMap).map(([W])=>[W,!1])),this.joinsNotNullableMap[Y]=!0;break}case"inner":{this.joinsNotNullableMap[Y]=!0;break}case"full":{this.joinsNotNullableMap=Object.fromEntries(Object.entries(this.joinsNotNullableMap).map(([W])=>[W,!1])),this.joinsNotNullableMap[Y]=!1;break}}return this}}leftJoin=this.createJoin("left");rightJoin=this.createJoin("right");innerJoin=this.createJoin("inner");fullJoin=this.createJoin("full");where(X){return this.config.where=X,this}returning(X){if(!X){if(X=Object.assign({},this.config.table[h.Symbol.Columns]),this.config.from){let Z=qX(this.config.from);if(typeof Z==="string"&&this.config.from&&!E(this.config.from,m)){let $=this.getTableLikeFields(this.config.from);X[Z]=$}for(let $ of this.config.joins){let Y=qX($.table);if(typeof Y==="string"&&!E($.table,m)){let W=this.getTableLikeFields($.table);X[Y]=W}}}}return this.config.returningFields=X,this.config.returning=q8(X),this}getSQL(){return this.dialect.buildUpdateQuery(this.config)}toSQL(){let{typings:X,...Z}=this.dialect.sqlToQuery(this.getSQL());return Z}_prepare(X){let Z=this.session.prepareQuery(this.dialect.sqlToQuery(this.getSQL()),this.config.returning,X,!0);return Z.joinsNotNullableMap=this.joinsNotNullableMap,Z}prepare(X){return this._prepare(X)}authToken;setToken(X){return this.authToken=X,this}execute=(X)=>{return this._prepare().execute(X,this.authToken)};getSelectedFields(){return this.config.returningFields?new Proxy(this.config.returningFields,new X2({alias:n2(this.config.table),sqlAliasedBehavior:"alias",sqlBehavior:"error"})):void 0}$dynamic(){return this}}class bZ extends m{constructor(X){super(bZ.buildEmbeddedCount(X.source,X.filters).queryChunks);this.params=X,this.mapWith(Number),this.session=X.session,this.sql=bZ.buildCount(X.source,X.filters)}sql;token;static[A]="PgCountBuilder";[Symbol.toStringTag]="PgCountBuilder";session;static buildEmbeddedCount(X,Z){return O`(select count(*) from ${X}${O.raw(" where ").if(Z)}${Z})`}static buildCount(X,Z){return O`select count(*) as count from ${X}${O.raw(" where ").if(Z)}${Z};`}setToken(X){return this.token=X,this}then(X,Z){return Promise.resolve(this.session.count(this.sql,this.token)).then(X,Z)}catch(X){return this.then(void 0,X)}finally(X){return this.then((Z)=>{return X?.(),Z},(Z)=>{throw X?.(),Z})}}class v6{constructor(X,Z,$,Y,W,J,z){this.fullSchema=X,this.schema=Z,this.tableNamesMap=$,this.table=Y,this.tableConfig=W,this.dialect=J,this.session=z}static[A]="PgRelationalQueryBuilder";findMany(X){return new f6(this.fullSchema,this.schema,this.tableNamesMap,this.table,this.tableConfig,this.dialect,this.session,X?X:{},"many")}findFirst(X){return new f6(this.fullSchema,this.schema,this.tableNamesMap,this.table,this.tableConfig,this.dialect,this.session,X?{...X,limit:1}:{limit:1},"first")}}class f6 extends b2{constructor(X,Z,$,Y,W,J,z,Q,M){super();this.fullSchema=X,this.schema=Z,this.tableNamesMap=$,this.table=Y,this.tableConfig=W,this.dialect=J,this.session=z,this.config=Q,this.mode=M}static[A]="PgRelationalQuery";_prepare(X){return v0.startActiveSpan("drizzle.prepareQuery",()=>{let{query:Z,builtQuery:$}=this._toSQL();return this.session.prepareQuery($,void 0,X,!0,(Y,W)=>{let J=Y.map((z)=>ZY(this.schema,this.tableConfig,z,Z.selection,W));if(this.mode==="first")return J[0];return J})})}prepare(X){return this._prepare(X)}_getQuery(){return this.dialect.buildRelationalQueryWithoutPK({fullSchema:this.fullSchema,schema:this.schema,tableNamesMap:this.tableNamesMap,table:this.table,tableConfig:this.tableConfig,queryConfig:this.config,tableAlias:this.tableConfig.tsName})}getSQL(){return this._getQuery().sql}_toSQL(){let X=this._getQuery(),Z=this.dialect.sqlToQuery(X.sql);return{query:X,builtQuery:Z}}toSQL(){return this._toSQL().builtQuery}authToken;setToken(X){return this.authToken=X,this}execute(){return v0.startActiveSpan("drizzle.operation",()=>{return this._prepare().execute(void 0,this.authToken)})}}class y6 extends b2{constructor(X,Z,$,Y){super();this.execute=X,this.sql=Z,this.query=$,this.mapBatchResult=Y}static[A]="PgRaw";getSQL(){return this.sql}getQuery(){return this.query}mapResult(X,Z){return Z?this.mapBatchResult(X):X}_prepare(){return this}isResponseInArrayMode(){return!1}}class kZ{constructor(X,Z,$){if(this.dialect=X,this.session=Z,this._=$?{schema:$.schema,fullSchema:$.fullSchema,tableNamesMap:$.tableNamesMap,session:Z}:{schema:void 0,fullSchema:{},tableNamesMap:{},session:Z},this.query={},this._.schema)for(let[Y,W]of Object.entries(this._.schema))this.query[Y]=new v6($.fullSchema,this._.schema,this._.tableNamesMap,$.fullSchema[Y],W,X,Z)}static[A]="PgDatabase";query;$with=(X,Z)=>{let $=this;return{as:(W)=>{if(typeof W==="function")W=W(new TZ($.dialect));return new Proxy(new SZ(W.getSQL(),Z??("getSelectedFields"in W?W.getSelectedFields()??{}:{}),X,!0),new X2({alias:X,sqlAliasedBehavior:"alias",sqlBehavior:"error"}))}}};$count(X,Z){return new bZ({source:X,filters:Z,session:this.session})}with(...X){let Z=this;function $(M){return new k2({fields:M??void 0,session:Z.session,dialect:Z.dialect,withList:X})}function Y(M){return new k2({fields:M??void 0,session:Z.session,dialect:Z.dialect,withList:X,distinct:!0})}function W(M,G){return new k2({fields:G??void 0,session:Z.session,dialect:Z.dialect,withList:X,distinct:{on:M}})}function J(M){return new JY(M,Z.session,Z.dialect,X)}function z(M){return new WY(M,Z.session,Z.dialect,X)}function Q(M){return new r$(M,Z.session,Z.dialect,X)}return{select:$,selectDistinct:Y,selectDistinctOn:W,update:J,insert:z,delete:Q}}select(X){return new k2({fields:X??void 0,session:this.session,dialect:this.dialect})}selectDistinct(X){return new k2({fields:X??void 0,session:this.session,dialect:this.dialect,distinct:!0})}selectDistinctOn(X,Z){return new k2({fields:Z??void 0,session:this.session,dialect:this.dialect,distinct:{on:X}})}update(X){return new JY(X,this.session,this.dialect)}insert(X){return new WY(X,this.session,this.dialect)}delete(X){return new r$(X,this.session,this.dialect)}refreshMaterializedView(X){return new g6(X,this.session,this.dialect)}authToken;execute(X){let Z=typeof X==="string"?O.raw(X):X.getSQL(),$=this.dialect.sqlToQuery(Z),Y=this.session.prepareQuery($,void 0,void 0,!1);return new y6(()=>Y.execute(void 0,this.authToken),Z,$,(W)=>Y.mapResult(W,!0))}transaction(X,Z){return this.session.transaction(X,Z)}}class d6{constructor(X){this.query=X}authToken;getQuery(){return this.query}mapResult(X,Z){return X}setToken(X){return this.authToken=X,this}static[A]="PgPreparedQuery";joinsNotNullableMap}class h6{constructor(X){this.dialect=X}static[A]="PgSession";execute(X,Z){return v0.startActiveSpan("drizzle.operation",()=>{return v0.startActiveSpan("drizzle.prepareQuery",()=>{return this.prepareQuery(this.dialect.sqlToQuery(X),void 0,void 0,!1)}).setToken(Z).execute(void 0,Z)})}all(X){return this.prepareQuery(this.dialect.sqlToQuery(X),void 0,void 0,!1).all()}async count(X,Z){let $=await this.execute(X,Z);return Number($[0].count)}}class m6 extends kZ{constructor(X,Z,$,Y=0){super(X,Z,$);this.schema=$,this.nestedIndex=Y}static[A]="PgTransaction";rollback(){throw new C6}getTransactionConfigSQL(X){let Z=[];if(X.isolationLevel)Z.push(`isolation level ${X.isolationLevel}`);if(X.accessMode)Z.push(X.accessMode);if(typeof X.deferrable==="boolean")Z.push(X.deferrable?"deferrable":"not deferrable");return O.raw(Z.join(" "))}setTransaction(X){return this.session.execute(O`set transaction ${this.getTransactionConfigSQL(X)}`)}}var e=Uz("units",{id:s$("id").defaultRandom().primaryKey(),unitNo:nX("unit_no",{length:10}).notNull(),number:oX("number"),project:nX("project",{length:256}).notNull(),floor:oX("floor").notNull(),unitType:nX("unit_type",{length:256,enum:["Studio Squared","1 BR Squared","Studio Flex","2 BR Squared","One Bedroom2","Studio2","One Bedroom Loft","Two Bedroom Loft"]}),noOfBathrooms:oX("no_of_bathrooms").notNull(),unitView:nX("unit_view",{length:256,enum:["Canal / Amenities","Corner-Canal / Amenities","Corner-Canal View","Business Bay","Park Facing","Corner-Park Facing","Partial Park","BK/DT / Amenities","Corner-BK/DT / Amenities","Corner-Canal / BK/DT View","Marina View","Partial Marina View","Partial Marina, Partial City View","City view","Marina View, Sea View","Partial Marina View, Partial Sea View"]}),suitsArea:l1("suits_area").notNull(),squareFt:l1("square_ft").notNull(),noOfParkingSpace:oX("no_of_parking_space").notNull(),salesPrice:oX("sales_price").notNull(),state:nX("state",{length:256,enum:["reserved","sold_spa","available","sold_registered"]}).notNull(),balconyArea:l1("balcony_area").notNull()},(X)=>[u5().on(X.project,X.unitNo)]);class yz{static[A]="ConsoleLogWriter";write(X){console.log(X)}}class c6{static[A]="DefaultLogger";writer;constructor(X){this.writer=X?.writer??new yz}logQuery(X,Z){let $=Z.map((W)=>{try{return JSON.stringify(W)}catch{return String(W)}}),Y=$.length?` -- params: [${$.join(", ")}]`:"";this.writer.write(`Query: ${X}${Y}`)}}class u6{static[A]="NoopLogger";logQuery(){}}var a0={INT8_MIN:-128,INT8_MAX:127,INT8_UNSIGNED_MAX:255,INT16_MIN:-32768,INT16_MAX:32767,INT16_UNSIGNED_MAX:65535,INT24_MIN:-8388608,INT24_MAX:8388607,INT24_UNSIGNED_MAX:16777215,INT32_MIN:-2147483648,INT32_MAX:2147483647,INT32_UNSIGNED_MAX:4294967295,INT48_MIN:-140737488355328,INT48_MAX:140737488355327,INT48_UNSIGNED_MAX:281474976710655,INT64_MIN:-9223372036854775808n,INT64_MAX:9223372036854775807n,INT64_UNSIGNED_MAX:18446744073709551615n};function W2(X,Z){return Z.includes(X.columnType)}function dz(X){return"enumValues"in X&&Array.isArray(X.enumValues)&&X.enumValues.length>0}var wL=dz,_L=f0.Union([f0.String(),f0.Number(),f0.Boolean(),f0.Null()]),OL=f0.Union([_L,f0.Array(f0.Any()),f0.Record(f0.String(),f0.Any())]);t0.Set("Buffer",(X,Z)=>Z instanceof Buffer);var NL={[q]:"Buffer",type:"buffer"};function hz(X){return Object.fromEntries(X.map((Z)=>[Z,Z]))}function mz(X,Z){let $;if(dz(X))$=X.enumValues.length?Z.Enum(hz(X.enumValues)):Z.String();if(!$){if(W2(X,["PgGeometry","PgPointTuple"]))$=Z.Tuple([Z.Number(),Z.Number()]);else if(W2(X,["PgGeometryObject","PgPointObject"]))$=Z.Object({x:Z.Number(),y:Z.Number()});else if(W2(X,["PgHalfVector","PgVector"]))$=Z.Array(Z.Number(),X.dimensions?{minItems:X.dimensions,maxItems:X.dimensions}:void 0);else if(W2(X,["PgLine"]))$=Z.Tuple([Z.Number(),Z.Number(),Z.Number()]);else if(W2(X,["PgLineABC"]))$=Z.Object({a:Z.Number(),b:Z.Number(),c:Z.Number()});else if(W2(X,["PgArray"]))$=Z.Array(mz(X.baseColumn,Z),X.size?{minItems:X.size,maxItems:X.size}:void 0);else if(X.dataType==="array")$=Z.Array(Z.Any());else if(X.dataType==="number")$=LL(X,Z);else if(X.dataType==="bigint")$=FL(X,Z);else if(X.dataType==="boolean")$=Z.Boolean();else if(X.dataType==="date")$=Z.Date();else if(X.dataType==="string")$=BL(X,Z);else if(X.dataType==="json")$=OL;else if(X.dataType==="custom")$=Z.Any();else if(X.dataType==="buffer")$=NL}if(!$)$=Z.Any();return $}function LL(X,Z){let $=X.getSQLType().includes("unsigned"),Y,W,J=!1;if(W2(X,["MySqlTinyInt","SingleStoreTinyInt"]))Y=$?0:a0.INT8_MIN,W=$?a0.INT8_UNSIGNED_MAX:a0.INT8_MAX,J=!0;else if(W2(X,["PgSmallInt","PgSmallSerial","MySqlSmallInt","SingleStoreSmallInt"]))Y=$?0:a0.INT16_MIN,W=$?a0.INT16_UNSIGNED_MAX:a0.INT16_MAX,J=!0;else if(W2(X,["PgReal","MySqlFloat","MySqlMediumInt","SingleStoreFloat","SingleStoreMediumInt"]))Y=$?0:a0.INT24_MIN,W=$?a0.INT24_UNSIGNED_MAX:a0.INT24_MAX,J=W2(X,["MySqlMediumInt","SingleStoreMediumInt"]);else if(W2(X,["PgInteger","PgSerial","MySqlInt","SingleStoreInt"]))Y=$?0:a0.INT32_MIN,W=$?a0.INT32_UNSIGNED_MAX:a0.INT32_MAX,J=!0;else if(W2(X,["PgDoublePrecision","MySqlReal","MySqlDouble","SingleStoreReal","SingleStoreDouble","SQLiteReal"]))Y=$?0:a0.INT48_MIN,W=$?a0.INT48_UNSIGNED_MAX:a0.INT48_MAX;else if(W2(X,["PgBigInt53","PgBigSerial53","MySqlBigInt53","MySqlSerial","SingleStoreBigInt53","SingleStoreSerial","SQLiteInteger"]))$=$||W2(X,["MySqlSerial","SingleStoreSerial"]),Y=$?0:Number.MIN_SAFE_INTEGER,W=Number.MAX_SAFE_INTEGER,J=!0;else if(W2(X,["MySqlYear","SingleStoreYear"]))Y=1901,W=2155,J=!0;else Y=Number.MIN_SAFE_INTEGER,W=Number.MAX_SAFE_INTEGER;return Z[J?"Integer":"Number"]({minimum:Y,maximum:W})}function FL(X,Z){let $=X.getSQLType().includes("unsigned"),Y=$?0n:a0.INT64_MIN,W=$?a0.INT64_UNSIGNED_MAX:a0.INT64_MAX;return Z.BigInt({minimum:Y,maximum:W})}function BL(X,Z){if(W2(X,["PgUUID"]))return Z.String({format:"uuid"});else if(W2(X,["PgBinaryVector"]))return Z.RegExp(/^[01]+$/,X.dimensions?{maxLength:X.dimensions}:void 0);let $,Y=!1;if(W2(X,["PgVarchar","SQLiteText"]))$=X.length;else if(W2(X,["MySqlVarChar","SingleStoreVarChar"]))$=X.length??a0.INT16_UNSIGNED_MAX;else if(W2(X,["MySqlText","SingleStoreText"]))if(X.textType==="longtext")$=a0.INT32_UNSIGNED_MAX;else if(X.textType==="mediumtext")$=a0.INT24_UNSIGNED_MAX;else if(X.textType==="text")$=a0.INT16_UNSIGNED_MAX;else $=a0.INT8_UNSIGNED_MAX;if(W2(X,["PgChar","MySqlChar","SingleStoreChar"]))$=X.length,Y=!0;let W={};if($!==void 0&&Y)W.minLength=$,W.maxLength=$;else if($!==void 0)W.maxLength=$;return Z.String(Object.keys(W).length>0?W:void 0)}function pz(X){return K6(X)?h$(X):D4(X)}function cz(X,Z,$,Y){let W={};for(let[J,z]of Object.entries(X)){if(!E(z,V0)&&!E(z,m)&&!E(z,m.Aliased)&&typeof z==="object"){let w=K6(z)||M4(z)?pz(z):z;W[J]=cz(w,Z[J]??{},$,Y);continue}let Q=Z[J];if(Q!==void 0&&typeof Q!=="function"){W[J]=Q;continue}let M=E(z,V0)?z:void 0,G=M?mz(M,Y?.typeboxInstance??f0):f0.Any(),U=typeof Q==="function"?Q(G):G;if($.never(M))continue;else W[J]=U;if(M){if($.nullable(M))W[J]=f0.Union([W[J],f0.Null()]);if($.optional(M))W[J]=f0.Optional(W[J])}}return f0.Object(W)}function qL(X,Z){return(Z?.typeboxInstance??f0).Enum(hz(X.enumValues))}var KL={never:()=>!1,optional:()=>!1,nullable:(X)=>!X.notNull};var uz=(X,Z)=>{if(wL(X))return qL(X);let $=pz(X);return cz($,Z??{},KL)};var{SQL:o6}=globalThis.Bun;class iz extends d6{constructor(X,Z,$,Y,W,J,z){super({sql:Z,params:$});this.client=X,this.queryString=Z,this.params=$,this.logger=Y,this.fields=W,this._isResponseInArrayMode=J,this.customResultMapper=z}static[A]="BunSQLPreparedQuery";async execute(X={}){return v0.startActiveSpan("drizzle.execute",async(Z)=>{let $=j6(this.params,X);Z?.setAttributes({"drizzle.query.text":this.queryString,"drizzle.query.params":JSON.stringify($)}),this.logger.logQuery(this.queryString,$);let{fields:Y,queryString:W,client:J,joinsNotNullableMap:z,customResultMapper:Q}=this;if(!Y&&!Q)return v0.startActiveSpan("drizzle.driver.execute",()=>{return J.unsafe(W,$)});let M=await v0.startActiveSpan("drizzle.driver.execute",()=>{return Z?.setAttributes({"drizzle.query.text":W,"drizzle.query.params":JSON.stringify($)}),J.unsafe(W,$).values()});return v0.startActiveSpan("drizzle.mapResponse",()=>{return Q?Q(M):M.map((G)=>U4(Y,G,z))})})}all(X={}){return v0.startActiveSpan("drizzle.execute",async(Z)=>{let $=j6(this.params,X);return Z?.setAttributes({"drizzle.query.text":this.queryString,"drizzle.query.params":JSON.stringify($)}),this.logger.logQuery(this.queryString,$),v0.startActiveSpan("drizzle.driver.execute",()=>{return Z?.setAttributes({"drizzle.query.text":this.queryString,"drizzle.query.params":JSON.stringify($)}),this.client.unsafe(this.queryString,$)})})}isResponseInArrayMode(){return this._isResponseInArrayMode}}class gZ extends h6{constructor(X,Z,$,Y={}){super(Z);this.client=X,this.schema=$,this.options=Y,this.logger=Y.logger??new u6}static[A]="BunSQLSession";logger;prepareQuery(X,Z,$,Y,W){return new iz(this.client,X.sql,X.params,this.logger,Z,Y,W)}query(X,Z){return this.logger.logQuery(X,Z),this.client.unsafe(X,Z).values()}queryObjects(X,Z){return this.client.unsafe(X,Z)}transaction(X,Z){return this.client.begin(async($)=>{let Y=new gZ($,this.dialect,this.schema,this.options),W=new i6(this.dialect,Y,this.schema);if(Z)await W.setTransaction(Z);return X(W)})}}class i6 extends m6{constructor(X,Z,$,Y=0){super(X,Z,$,Y);this.session=Z}static[A]="BunSQLTransaction";transaction(X){return this.session.client.savepoint((Z)=>{let $=new gZ(Z,this.dialect,this.schema,this.session.options),Y=new i6(this.dialect,$,this.schema);return X(Y)})}}class oz extends kZ{static[A]="BunSQLDatabase"}function r1(X,Z={}){let $=new O1({casing:Z.casing}),Y;if(Z.logger===!0)Y=new c6;else if(Z.logger!==!1)Y=Z.logger;let W;if(Z.schema){let Q=Tz(Z.schema,kz);W={fullSchema:Z.schema,schema:Q.tables,tableNamesMap:Q.tableNamesMap}}let J=new gZ(X,$,W,{logger:Y}),z=new oz($,J,W);return z.$client=X,z}function zY(...X){if(typeof X[0]==="string"){let Z=new o6(X[0]);return r1(Z,X[1])}if(A4(X[0])){let{connection:Z,client:$,...Y}=X[0];if($)return r1($,Y);if(typeof Z==="object"&&Z.url!==void 0){let{url:J,...z}=Z,Q=new o6({url:J,...z});return r1(Q,Y)}let W=new o6(Z);return r1(W,Y)}return r1(X[0],X[1])}((X)=>{function Z($){return r1({options:{parsers:{},serializers:{}}},$)}X.mock=Z})(zY||(zY={}));var{SQL:RL}=globalThis.Bun;var jX=zY({schema:p6,client:new RL("postgresql://postgres:v1sq3vD5faXL@194.26.138.94:5432/irth")});var qd=uz(e),nz=new C2({prefix:"/units"}).get("/",async({query:{project:X,unitTypes:Z,cost:$,floor:Y,area:W,view:J,order:z,offset:Q,limit:M}})=>{try{return await jX.query.unitsTable.findMany({where:RX(X?K8(e.project,X):void 0,Z?t1(e.unitType,Z):void 0,$?R8(e.salesPrice,$[0],$[1]):void 0,Y?R8(e.floor,Y[0],Y[1]):void 0,W?R8(e.squareFt,W[0],W[1]):void 0,J?K8(e.unitView,J):void 0),orderBy:z?[z[1]==="asc"?e$(e[z[0]==="cost"?"salesPrice":"squareFt"]):XY(e[z[0]==="cost"?"salesPrice":"squareFt"])]:void 0,offset:Q,limit:M})}catch(G){return console.log(G.message),w1(500,"Internal server error")}},{query:_.Partial(_.Object({project:_.String(),unitTypes:_.Array(_.Union([_.Literal("Studio Squared"),_.Literal("1 BR Squared"),_.Literal("Studio Flex"),_.Literal("2 BR Squared"),_.Literal("Studio2"),_.Literal("One Bedroom2"),_.Literal("One Bedroom Loft"),_.Literal("Two Bedroom Loft")])),cost:_.Tuple([_.Number(),_.Number()]),floor:_.Tuple([_.Number(),_.Number()]),area:_.Tuple([_.Number(),_.Number()]),view:_.Union([_.Literal("Canal / Amenities"),_.Literal("Corner-Canal / Amenities"),_.Literal("Corner-Canal View"),_.Literal("Business Bay"),_.Literal("Park Facing"),_.Literal("Corner-Park Facing"),_.Literal("Partial Park"),_.Literal("BK/DT / Amenities"),_.Literal("Corner-BK/DT / Amenities"),_.Literal("Corner-Canal / BK/DT View"),_.Literal("Marina View"),_.Literal("Partial Marina View"),_.Literal("Partial Marina, Partial City View"),_.Literal("City view"),_.Literal("Marina View, Sea View"),_.Literal("Partial Marina View, Partial Sea View")]),order:_.Tuple([_.Union([_.Literal("cost"),_.Literal("sqft")]),_.Union([_.Literal("asc"),_.Literal("desc")])]),offset:_.Number({default:0}),limit:_.Number({default:16})}))}).get("/count",async({query:{project:X,unitTypes:Z,cost:$,floor:Y,area:W,view:J}})=>{try{return(await jX.select({count:gz()}).from(e).where(RX(X?K8(e.project,X):void 0,Z?t1(e.unitType,Z):void 0,$?R8(e.salesPrice,$[0],$[1]):void 0,Y?R8(e.floor,Y[0],Y[1]):void 0,W?R8(e.squareFt,W[0],W[1]):void 0,J?K8(e.unitView,J):void 0)))[0].count}catch(z){return console.log(z.message),w1(500,"Internal server error")}},{query:_.Partial(_.Object({project:_.String(),unitTypes:_.Array(_.Union([_.Literal("Studio Squared"),_.Literal("1 BR Squared"),_.Literal("Studio Flex"),_.Literal("2 BR Squared"),_.Literal("Studio2"),_.Literal("One Bedroom2"),_.Literal("One Bedroom Loft"),_.Literal("Two Bedroom Loft")])),cost:_.Tuple([_.Number(),_.Number()]),floor:_.Tuple([_.Number(),_.Number()]),area:_.Tuple([_.Number(),_.Number()]),view:_.Union([_.Literal("Canal / Amenities"),_.Literal("Corner-Canal / Amenities"),_.Literal("Corner-Canal View"),_.Literal("Business Bay"),_.Literal("Park Facing"),_.Literal("Corner-Park Facing"),_.Literal("Partial Park"),_.Literal("BK/DT / Amenities"),_.Literal("Corner-BK/DT / Amenities"),_.Literal("Corner-Canal / BK/DT View"),_.Literal("Marina View"),_.Literal("Partial Marina View"),_.Literal("Partial Marina, Partial City View"),_.Literal("City view"),_.Literal("Marina View, Sea View"),_.Literal("Partial Marina View, Partial Sea View")])}))}).get("/filters/:filterName",async({query:{project:X,view:Z,unitTypes:$,cost:Y,floor:W,area:J},params:{filterName:z}})=>{try{let Q=RX(X?K8(e.project,X):void 0,$&&z!=="unitTypes"?t1(e.unitType,$):void 0,Z&&z!=="views"?K8(e.unitView,Z):void 0,Y&&z!=="cost"?R8(e.salesPrice,Y[0],Y[1]):void 0,W&&z!=="floor"?R8(e.floor,W[0],W[1]):void 0,J&&z!=="area"?R8(e.squareFt,J[0],J[1]):void 0);if(z==="unitTypes")return(await jX.selectDistinctOn([e.unitType],{unitType:e.unitType}).from(e).where(Q)).map((M)=>M.unitType).filter(Boolean);else if(z==="views")return(await jX.selectDistinctOn([e.unitView],{unitView:e.unitView}).from(e).where(Q)).map((M)=>M.unitView).filter(Boolean);else if(z==="cost")return(await jX.select({min:YY(e.salesPrice),max:$Y(e.salesPrice)}).from(e).where(Q))[0];else if(z==="area")return(await jX.select({min:YY(e.squareFt),max:$Y(e.squareFt)}).from(e).where(Q))[0];return(await jX.select({min:YY(e.floor),max:$Y(e.floor)}).from(e).where(Q))[0]}catch(Q){return console.log(Q.message),w1(500,"Internal server error")}},{response:{200:_.Union([_.Array(_.String()),_.Object({min:_.Number(),max:_.Number()})]),500:_.ObjectString({})},params:_.Object({filterName:_.Union([_.Literal("unitTypes"),_.Literal("views"),_.Literal("cost"),_.Literal("area"),_.Literal("floor")])}),query:_.Partial(_.Object({project:_.String(),unitTypes:_.Array(_.Union([_.Literal("Studio Squared"),_.Literal("1 BR Squared"),_.Literal("Studio Flex"),_.Literal("2 BR Squared"),_.Literal("Studio2"),_.Literal("One Bedroom2"),_.Literal("One Bedroom Loft"),_.Literal("Two Bedroom Loft")])),cost:_.Tuple([_.Number(),_.Number()]),floor:_.Tuple([_.Number(),_.Number()]),area:_.Tuple([_.Number(),_.Number()]),view:_.Union([_.Literal("Canal / Amenities"),_.Literal("Corner-Canal / Amenities"),_.Literal("Corner-Canal View"),_.Literal("Business Bay"),_.Literal("Park Facing"),_.Literal("Corner-Park Facing"),_.Literal("Partial Park"),_.Literal("BK/DT / Amenities"),_.Literal("Corner-BK/DT / Amenities"),_.Literal("Corner-Canal / BK/DT View"),_.Literal("Marina View"),_.Literal("Partial Marina View"),_.Literal("Partial Marina, Partial City View"),_.Literal("City view"),_.Literal("Marina View, Sea View"),_.Literal("Partial Marina View, Partial Sea View")])}))}).get("/get-floors-data/:project",async({params:{project:X}})=>{try{let Z=await jX.select({unitNo:e.unitNo,floor:e.floor,unitType:e.unitType}).from(e).where(K8(e.project,decodeURIComponent(X))),$=new Map;for(let{unitNo:Y,floor:W,unitType:J}of Z){if(!Y||!W||!J)continue;let z=Y.toString().startsWith("W")?"west":"east";if(!$.has(W))$.set(W,{floor:W,east:{types:{},totalUnits:0},west:{types:{},totalUnits:0}});let Q=$.get(W);if(z==="east")Q.east.types[J]=(Q.east.types[J]||0)+1,Q.east.totalUnits++;else Q.west.types[J]=(Q.west.types[J]||0)+1,Q.west.totalUnits++}return Array.from($.values()).map((Y)=>({floor:Y.floor,east:Y.east,west:Y.west}))}catch(Z){return console.log(Z.message),w1(500,"Internal server error")}},{params:_.Object({project:_.String()})});var jL=typeof new Headers()?.toJSON==="function",SL=(X)=>{if(jL)return Object.keys(X.toJSON()).join(", ");let Z="";if(X.forEach(($,Y)=>{Z+=Y+", "}),Z)Z=Z.slice(0,-1);return Z},lz=(X,Z,$)=>{if(Array.isArray(X))return X.some((Y)=>lz(Y,Z,$));switch(typeof X){case"string":if(X.indexOf("://")===-1)return $.includes(X);return X===$;case"function":return X(Z)===!0;case"object":if(X instanceof RegExp)return X.test($)}return!1},tz=(X)=>{let{aot:Z=!0,origin:$=!0,methods:Y=!0,allowedHeaders:W=!0,exposeHeaders:J=!0,credentials:z=!0,maxAge:Q=5,preflight:M=!0}=X??{};if(Array.isArray(W))W=W.join(", ");if(Array.isArray(J))J=J.join(", ");let G=typeof $==="boolean"?void 0:Array.isArray($)?$:[$],U=new C2({name:"@elysiajs/cors",seed:X,aot:Z}),w=G?.some((K)=>K==="*"),B=(K,k)=>{if($===!0){K.headers.vary="*",K.headers["access-control-allow-origin"]=k.headers.get("Origin")||"*";return}if(w){K.headers.vary="*",K.headers["access-control-allow-origin"]="*";return}if(!G?.length)return;let l=[];if(G.length){let n=k.headers.get("Origin")??"";for(let A0=0;A0{if(!k)return;if(Y===!0)return K.headers["access-control-allow-methods"]=k??"*";if(Y===!1||!Y?.length)return;if(Y==="*")return K.headers["access-control-allow-methods"]="*";if(!Array.isArray(Y))return K.headers["access-control-allow-methods"]=Y;K.headers["access-control-allow-methods"]=Y.join(", ")},j={};if(typeof J==="string")j["access-control-expose-headers"]=J;if(typeof W==="string")j["access-control-allow-headers"]=W;if(z===!0)j["access-control-allow-credentials"]="true";U.headers(j);function H({set:K,request:k,headers:l}){if(B(K,k),N(K,k.headers.get("access-control-request-method")),W===!0||J===!0){if(W===!0)K.headers["access-control-allow-headers"]=l["access-control-request-headers"];if(J===!0)K.headers["access-control-expose-headers"]=Object.keys(l).join(",")}if(Q)K.headers["access-control-max-age"]=Q.toString();return new Response(null,{status:204})}if(M)U.options("/",H).options("/*",H);return U.onRequest(function K({set:k,request:l}){if(B(k,l),N(k,l.method),W===!0||J===!0){let n=SL(l.headers);if(W===!0)k.headers["access-control-allow-headers"]=n;if(J===!0)k.headers["access-control-expose-headers"]=n}})};var sz=new C2().use(tz({origin:"*"})).use(nz).listen(4002);console.log(`\uD83E\uDD8A Elysia is running at ${sz.server?.hostname}:${sz.server?.port}`); diff --git a/dist/types/IUnit.js b/dist/types/IUnit.js deleted file mode 100644 index aaa250a..0000000 --- a/dist/types/IUnit.js +++ /dev/null @@ -1 +0,0 @@ -// @bun