barejs 0.1.21 → 0.1.23

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  // @bun
2
- var m8=Object.defineProperty;var _0=(Q,Z)=>{for(var Y in Z)m8(Q,Y,{get:Z[Y],enumerable:!0,configurable:!0,set:(G)=>Z[Y]=()=>G})};class M0{req;params;_status=200;store=Object.create(null);body=null;_headers={};_searchParams=null;_cookies=null;reset(Q,Z){this.req=Q,this.params=Z,this._status=200,this.body=null,this._headers={},this._searchParams=null,this._cookies=null;for(let Y in this.store)delete this.store[Y];return this}header(Q){return this.req.headers.get(Q)}query(Q){if(!this._searchParams)this._searchParams=new URL(this.req.url).searchParams;return this._searchParams.get(Q)}cookie(Q){let Z=this._cookies;if(!Z){Z=new Map;let Y=this.req.headers.get("cookie");if(Y){let G=Y.matchAll(/([^=\s]+)=([^;]+)/g);for(let W of G){let X=W[1],J=W[2];if(X&&J)Z.set(X,J)}}this._cookies=Z}return Z.get(Q)}get ip(){return this.req.headers.get("x-forwarded-for")||null}status(Q){return this._status=Q,this}setHeader(Q,Z){return this._headers[Q.toLowerCase()]=Z,this}setCookie(Q,Z,Y=""){return this.setHeader("set-cookie",`${Q}=${Z}; ${Y}`),this}json(Q){return this.setHeader("content-type","application/json"),Q}text(Q){return this.setHeader("content-type","text/plain; charset=utf-8"),Q}html(Q){return this.setHeader("content-type","text/html; charset=utf-8"),Q}redirect(Q,Z=302){return this._status=Z,this.setHeader("location",Q),null}set(Q,Z){this.store[Q]=Z}get(Q){return this.store[Q]}}function u1(Q){return s(Q)&&globalThis.Symbol.asyncIterator in Q}function l1(Q){return s(Q)&&globalThis.Symbol.iterator in Q}function s1(Q){return Q instanceof globalThis.Promise}function x1(Q){return Q instanceof Date&&globalThis.Number.isFinite(Q.getTime())}function g1(Q){return Q instanceof globalThis.Uint8Array}function r1(Q,Z){return Z in Q}function s(Q){return Q!==null&&typeof Q==="object"}function V(Q){return globalThis.Array.isArray(Q)&&!globalThis.ArrayBuffer.isView(Q)}function v(Q){return Q===void 0}function D1(Q){return Q===null}function N1(Q){return typeof Q==="boolean"}function N(Q){return typeof Q==="number"}function a1(Q){return globalThis.Number.isInteger(Q)}function a(Q){return typeof Q==="bigint"}function f(Q){return typeof Q==="string"}function e1(Q){return typeof Q==="function"}function P1(Q){return typeof Q==="symbol"}function Q0(Q){return a(Q)||N1(Q)||D1(Q)||N(Q)||f(Q)||P1(Q)||v(Q)}var _;(function(Q){Q.InstanceMode="default",Q.ExactOptionalPropertyTypes=!1,Q.AllowArrayObject=!1,Q.AllowNaN=!1,Q.AllowNullVoid=!1;function Z(J,H){return Q.ExactOptionalPropertyTypes?H in J:J[H]!==void 0}Q.IsExactOptionalProperty=Z;function Y(J){let H=s(J);return Q.AllowArrayObject?H:H&&!V(J)}Q.IsObjectLike=Y;function G(J){return Y(J)&&!(J instanceof Date)&&!(J instanceof Uint8Array)}Q.IsRecordLike=G;function W(J){return Q.AllowNaN?N(J):Number.isFinite(J)}Q.IsNumberLike=W;function X(J){let H=v(J);return Q.AllowNullVoid?H||J===null:H}Q.IsVoidLike=X})(_||(_={}));var Q1={};_0(Q1,{Set:()=>u8,Has:()=>c8,Get:()=>l8,Entries:()=>h8,Delete:()=>v8,Clear:()=>t8});var K1=new Map;function h8(){return new Map(K1)}function t8(){return K1.clear()}function v8(Q){return K1.delete(Q)}function c8(Q){return K1.has(Q)}function u8(Q,Z){K1.set(Q,Z)}function l8(Q){return K1.get(Q)}var r={};_0(r,{Set:()=>QQ,Has:()=>e8,Get:()=>YQ,Entries:()=>s8,Delete:()=>a8,Clear:()=>r8});var _1=new Map;function s8(){return new Map(_1)}function r8(){return _1.clear()}function a8(Q){return _1.delete(Q)}function e8(Q){return _1.has(Q)}function QQ(Q,Z){_1.set(Q,Z)}function YQ(Q){return _1.get(Q)}function Y1(Q){return Array.isArray(Q)}function E0(Q){return typeof Q==="bigint"}function Y0(Q){return typeof Q==="boolean"}function Z0(Q){return Q instanceof globalThis.Date}function A1(Q){return typeof Q==="number"}function I(Q){return typeof Q==="object"&&Q!==null}function G0(Q){return Q instanceof globalThis.RegExp}function n(Q){return typeof Q==="string"}function W0(Q){return Q instanceof globalThis.Uint8Array}function z1(Q){return Q===void 0}function ZQ(Q){return globalThis.Object.freeze(Q).map((Z)=>i1(Z))}function GQ(Q){return Q}function WQ(Q){return Q}function XQ(Q){return Q}function $Q(Q){let Z={};for(let Y of Object.getOwnPropertyNames(Q))Z[Y]=i1(Q[Y]);for(let Y of Object.getOwnPropertySymbols(Q))Z[Y]=i1(Q[Y]);return globalThis.Object.freeze(Z)}function i1(Q){return Y1(Q)?ZQ(Q):Z0(Q)?GQ(Q):W0(Q)?WQ(Q):G0(Q)?XQ(Q):I(Q)?$Q(Q):Q}function zQ(Q){return Q.map((Z)=>$0(Z))}function JQ(Q){return new Date(Q.getTime())}function qQ(Q){return new Uint8Array(Q)}function HQ(Q){return new RegExp(Q.source,Q.flags)}function LQ(Q){let Z={};for(let Y of Object.getOwnPropertyNames(Q))Z[Y]=$0(Q[Y]);for(let Y of Object.getOwnPropertySymbols(Q))Z[Y]=$0(Q[Y]);return Z}function $0(Q){return Y1(Q)?zQ(Q):Z0(Q)?JQ(Q):W0(Q)?qQ(Q):G0(Q)?HQ(Q):I(Q)?LQ(Q):Q}function k0(Q){return $0(Q)}function m(Q,Z){let Y=Z!==void 0?{...Z,...Q}:Q;switch(_.InstanceMode){case"freeze":return i1(Y);case"clone":return k0(Y);default:return Y}}var B1=Symbol.for("TypeBox.Transform");var J1=Symbol.for("TypeBox.Optional");var B=Symbol.for("TypeBox.Kind");class T extends Error{constructor(Q){super(Q)}}function V0(Q){return m({[B]:"MappedResult",properties:Q})}function MQ(Q,Z){let{[Z]:Y,...G}=Q;return G}function E1(Q,Z){return Z.reduce((Y,G)=>MQ(Y,G),Q)}function c(Q){return m({[B]:"Never",not:{}},Q)}function k1(Q){return I(Q)&&Q[J1]==="Optional"}function AQ(Q){return S(Q,"Any")}function BQ(Q){return S(Q,"Argument")}function y1(Q){return S(Q,"Array")}function jQ(Q){return S(Q,"AsyncIterator")}function wQ(Q){return S(Q,"BigInt")}function DQ(Q){return S(Q,"Boolean")}function NQ(Q){return S(Q,"Computed")}function PQ(Q){return S(Q,"Constructor")}function bQ(Q){return S(Q,"Date")}function SQ(Q){return S(Q,"Function")}function CQ(Q){return S(Q,"Integer")}function p1(Q){return S(Q,"Intersect")}function OQ(Q){return S(Q,"Iterator")}function S(Q,Z){return I(Q)&&B in Q&&Q[B]===Z}function FQ(Q){return S(Q,"Literal")}function T0(Q){return S(Q,"MappedKey")}function z0(Q){return S(Q,"MappedResult")}function J0(Q){return S(Q,"Never")}function xQ(Q){return S(Q,"Not")}function gQ(Q){return S(Q,"Null")}function KQ(Q){return S(Q,"Number")}function b1(Q){return S(Q,"Object")}function _Q(Q){return S(Q,"Promise")}function U0(Q){return S(Q,"Record")}function I0(Q){return S(Q,"Ref")}function EQ(Q){return S(Q,"RegExp")}function kQ(Q){return S(Q,"String")}function VQ(Q){return S(Q,"Symbol")}function TQ(Q){return S(Q,"TemplateLiteral")}function IQ(Q){return S(Q,"This")}function x(Q){return I(Q)&&B1 in Q}function o1(Q){return S(Q,"Tuple")}function n1(Q){return S(Q,"Undefined")}function m1(Q){return S(Q,"Union")}function dQ(Q){return S(Q,"Uint8Array")}function fQ(Q){return S(Q,"Unknown")}function iQ(Q){return S(Q,"Unsafe")}function yQ(Q){return S(Q,"Void")}function pQ(Q){return I(Q)&&B in Q&&n(Q[B])}function u(Q){return AQ(Q)||BQ(Q)||y1(Q)||DQ(Q)||wQ(Q)||jQ(Q)||NQ(Q)||PQ(Q)||bQ(Q)||SQ(Q)||CQ(Q)||p1(Q)||OQ(Q)||FQ(Q)||T0(Q)||z0(Q)||J0(Q)||xQ(Q)||gQ(Q)||KQ(Q)||b1(Q)||_Q(Q)||U0(Q)||I0(Q)||EQ(Q)||kQ(Q)||VQ(Q)||TQ(Q)||IQ(Q)||o1(Q)||n1(Q)||m1(Q)||dQ(Q)||fQ(Q)||iQ(Q)||yQ(Q)||pQ(Q)}function oQ(Q){return m(E1(Q,[J1]))}function nQ(Q){return m({...Q,[J1]:"Optional"})}function mQ(Q,Z){return Z===!1?oQ(Q):nQ(Q)}function V1(Q,Z){let Y=Z??!0;return z0(Q)?d0(Q,Y):mQ(Q,Y)}function hQ(Q,Z){let Y={};for(let G of globalThis.Object.getOwnPropertyNames(Q))Y[G]=V1(Q[G],Z);return Y}function tQ(Q,Z){return hQ(Q.properties,Z)}function d0(Q,Z){let Y=tQ(Q,Z);return V0(Y)}function R0(Q,Z={}){let Y=Q.every((W)=>b1(W)),G=u(Z.unevaluatedProperties)?{unevaluatedProperties:Z.unevaluatedProperties}:{};return m(Z.unevaluatedProperties===!1||u(Z.unevaluatedProperties)||Y?{...G,[B]:"Intersect",type:"object",allOf:Q}:{...G,[B]:"Intersect",allOf:Q},Z)}function vQ(Q){return Q.every((Z)=>k1(Z))}function cQ(Q){return E1(Q,[J1])}function f0(Q){return Q.map((Z)=>k1(Z)?cQ(Z):Z)}function uQ(Q,Z){return vQ(Q)?V1(R0(f0(Q),Z)):R0(f0(Q),Z)}function i0(Q,Z={}){if(Q.length===1)return m(Q[0],Z);if(Q.length===0)return c(Z);if(Q.some((Y)=>x(Y)))throw Error("Cannot intersect transform types");return uQ(Q,Z)}function A0(Q,Z){return m({[B]:"Union",anyOf:Q},Z)}function lQ(Q){return Q.some((Z)=>k1(Z))}function y0(Q){return Q.map((Z)=>k1(Z)?sQ(Z):Z)}function sQ(Q){return E1(Q,[J1])}function rQ(Q,Z){return lQ(Q)?V1(A0(y0(Q),Z)):A0(y0(Q),Z)}function B0(Q,Z){return Q.length===1?m(Q[0],Z):Q.length===0?c(Z):rQ(Q,Z)}function p0(Q,Z){return Q.map((Y)=>o0(Y,Z))}function aQ(Q){return Q.filter((Z)=>!J0(Z))}function eQ(Q,Z){return i0(aQ(p0(Q,Z)))}function QY(Q){return Q.some((Z)=>J0(Z))?[]:Q}function YY(Q,Z){return B0(QY(p0(Q,Z)))}function ZY(Q,Z){return Z in Q?Q[Z]:Z==="[number]"?B0(Q):c()}function GY(Q,Z){return Z==="[number]"?Q:c()}function WY(Q,Z){return Z in Q?Q[Z]:c()}function o0(Q,Z){return p1(Q)?eQ(Q.allOf,Z):m1(Q)?YY(Q.anyOf,Z):o1(Q)?ZY(Q.items??[],Z):y1(Q)?GY(Q.items,Z):b1(Q)?WY(Q.properties,Z):c()}function n0(Q,Z){return Z.map((Y)=>o0(Q,Y))}function XY(Q,Z){return Q.filter((Y)=>Z.includes(Y))}function $Y(Q,Z){return Q.reduce((Y,G)=>{return XY(Y,G)},Z)}function m0(Q){return Q.length===1?Q[0]:Q.length>1?$Y(Q.slice(1),Q[0]):[]}function h0(Q){let Z=[];for(let Y of Q)Z.push(...Y);return Z}function t0(...Q){let[Z,Y]=typeof Q[0]==="string"?[Q[0],Q[1]]:[Q[0].$id,Q[1]];if(typeof Z!=="string")throw new T("Ref: $ref must be a string");return m({[B]:"Ref",$ref:Z},Y)}function v0(Q){let Z=[];for(let Y of Q)Z.push(j1(Y));return Z}function zY(Q){let Z=v0(Q);return h0(Z)}function JY(Q){let Z=v0(Q);return m0(Z)}function qY(Q){return Q.map((Z,Y)=>Y.toString())}function HY(Q){return["[number]"]}function LY(Q){return globalThis.Object.getOwnPropertyNames(Q)}function MY(Q){if(!j0)return[];return globalThis.Object.getOwnPropertyNames(Q).map((Y)=>{return Y[0]==="^"&&Y[Y.length-1]==="$"?Y.slice(1,Y.length-1):Y})}function j1(Q){return p1(Q)?zY(Q.allOf):m1(Q)?JY(Q.anyOf):o1(Q)?qY(Q.items??[]):y1(Q)?HY(Q.items):b1(Q)?LY(Q.properties):U0(Q)?MY(Q.patternProperties):[]}var j0=!1;function H1(Q){j0=!0;let Z=j1(Q);return j0=!1,`^(${Z.map((G)=>`(${G})`).join("|")})$`}function q0(Q){let Z=j1(Q),Y=n0(Q,Z);return Z.map((G,W)=>[Z[W],Y[W]])}function UY(Q){return Q.allOf.every((Z)=>L1(Z))}function RY(Q){return Q.anyOf.some((Z)=>L1(Z))}function AY(Q){return!L1(Q.not)}function L1(Q){return Q[B]==="Intersect"?UY(Q):Q[B]==="Union"?RY(Q):Q[B]==="Not"?AY(Q):Q[B]==="Undefined"?!0:!1}function BY(Q){switch(Q.errorType){case q.ArrayContains:return"Expected array to contain at least one matching value";case q.ArrayMaxContains:return`Expected array to contain no more than ${Q.schema.maxContains} matching values`;case q.ArrayMinContains:return`Expected array to contain at least ${Q.schema.minContains} matching values`;case q.ArrayMaxItems:return`Expected array length to be less or equal to ${Q.schema.maxItems}`;case q.ArrayMinItems:return`Expected array length to be greater or equal to ${Q.schema.minItems}`;case q.ArrayUniqueItems:return"Expected array elements to be unique";case q.Array:return"Expected array";case q.AsyncIterator:return"Expected AsyncIterator";case q.BigIntExclusiveMaximum:return`Expected bigint to be less than ${Q.schema.exclusiveMaximum}`;case q.BigIntExclusiveMinimum:return`Expected bigint to be greater than ${Q.schema.exclusiveMinimum}`;case q.BigIntMaximum:return`Expected bigint to be less or equal to ${Q.schema.maximum}`;case q.BigIntMinimum:return`Expected bigint to be greater or equal to ${Q.schema.minimum}`;case q.BigIntMultipleOf:return`Expected bigint to be a multiple of ${Q.schema.multipleOf}`;case q.BigInt:return"Expected bigint";case q.Boolean:return"Expected boolean";case q.DateExclusiveMinimumTimestamp:return`Expected Date timestamp to be greater than ${Q.schema.exclusiveMinimumTimestamp}`;case q.DateExclusiveMaximumTimestamp:return`Expected Date timestamp to be less than ${Q.schema.exclusiveMaximumTimestamp}`;case q.DateMinimumTimestamp:return`Expected Date timestamp to be greater or equal to ${Q.schema.minimumTimestamp}`;case q.DateMaximumTimestamp:return`Expected Date timestamp to be less or equal to ${Q.schema.maximumTimestamp}`;case q.DateMultipleOfTimestamp:return`Expected Date timestamp to be a multiple of ${Q.schema.multipleOfTimestamp}`;case q.Date:return"Expected Date";case q.Function:return"Expected function";case q.IntegerExclusiveMaximum:return`Expected integer to be less than ${Q.schema.exclusiveMaximum}`;case q.IntegerExclusiveMinimum:return`Expected integer to be greater than ${Q.schema.exclusiveMinimum}`;case q.IntegerMaximum:return`Expected integer to be less or equal to ${Q.schema.maximum}`;case q.IntegerMinimum:return`Expected integer to be greater or equal to ${Q.schema.minimum}`;case q.IntegerMultipleOf:return`Expected integer to be a multiple of ${Q.schema.multipleOf}`;case q.Integer:return"Expected integer";case q.IntersectUnevaluatedProperties:return"Unexpected property";case q.Intersect:return"Expected all values to match";case q.Iterator:return"Expected Iterator";case q.Literal:return`Expected ${typeof Q.schema.const==="string"?`'${Q.schema.const}'`:Q.schema.const}`;case q.Never:return"Never";case q.Not:return"Value should not match";case q.Null:return"Expected null";case q.NumberExclusiveMaximum:return`Expected number to be less than ${Q.schema.exclusiveMaximum}`;case q.NumberExclusiveMinimum:return`Expected number to be greater than ${Q.schema.exclusiveMinimum}`;case q.NumberMaximum:return`Expected number to be less or equal to ${Q.schema.maximum}`;case q.NumberMinimum:return`Expected number to be greater or equal to ${Q.schema.minimum}`;case q.NumberMultipleOf:return`Expected number to be a multiple of ${Q.schema.multipleOf}`;case q.Number:return"Expected number";case q.Object:return"Expected object";case q.ObjectAdditionalProperties:return"Unexpected property";case q.ObjectMaxProperties:return`Expected object to have no more than ${Q.schema.maxProperties} properties`;case q.ObjectMinProperties:return`Expected object to have at least ${Q.schema.minProperties} properties`;case q.ObjectRequiredProperty:return"Expected required property";case q.Promise:return"Expected Promise";case q.RegExp:return"Expected string to match regular expression";case q.StringFormatUnknown:return`Unknown format '${Q.schema.format}'`;case q.StringFormat:return`Expected string to match '${Q.schema.format}' format`;case q.StringMaxLength:return`Expected string length less or equal to ${Q.schema.maxLength}`;case q.StringMinLength:return`Expected string length greater or equal to ${Q.schema.minLength}`;case q.StringPattern:return`Expected string to match '${Q.schema.pattern}'`;case q.String:return"Expected string";case q.Symbol:return"Expected symbol";case q.TupleLength:return`Expected tuple to have ${Q.schema.maxItems||0} elements`;case q.Tuple:return"Expected tuple";case q.Uint8ArrayMaxByteLength:return`Expected byte length less or equal to ${Q.schema.maxByteLength}`;case q.Uint8ArrayMinByteLength:return`Expected byte length greater or equal to ${Q.schema.minByteLength}`;case q.Uint8Array:return"Expected Uint8Array";case q.Undefined:return"Expected undefined";case q.Union:return"Expected union value";case q.Void:return"Expected void";case q.Kind:return`Expected kind '${Q.schema[B]}'`;default:return"Unknown error type"}}var jY=BY;function c0(){return jY}class u0 extends T{constructor(Q){super(`Unable to dereference schema with $id '${Q.$ref}'`);this.schema=Q}}function wY(Q,Z){let Y=Z.find((G)=>G.$id===Q.$ref);if(Y===void 0)throw new u0(Q);return i(Y,Z)}function w1(Q,Z){if(!f(Q.$id)||Z.some((Y)=>Y.$id===Q.$id))return Z;return Z.push(Q),Z}function i(Q,Z){return Q[B]==="This"||Q[B]==="Ref"?wY(Q,Z):Q}class l0 extends T{constructor(Q){super("Unable to hash value");this.value=Q}}var e;(function(Q){Q[Q.Undefined=0]="Undefined",Q[Q.Null=1]="Null",Q[Q.Boolean=2]="Boolean",Q[Q.Number=3]="Number",Q[Q.String=4]="String",Q[Q.Object=5]="Object",Q[Q.Array=6]="Array",Q[Q.Date=7]="Date",Q[Q.Uint8Array=8]="Uint8Array",Q[Q.Symbol=9]="Symbol",Q[Q.BigInt=10]="BigInt"})(e||(e={}));var T1=BigInt("14695981039346656037"),[DY,NY]=[BigInt("1099511628211"),BigInt("18446744073709551616")],PY=Array.from({length:256}).map((Q,Z)=>BigInt(Z)),s0=new Float64Array(1),r0=new DataView(s0.buffer),a0=new Uint8Array(s0.buffer);function*bY(Q){let Z=Q===0?1:Math.ceil(Math.floor(Math.log2(Q)+1)/8);for(let Y=0;Y<Z;Y++)yield Q>>8*(Z-1-Y)&255}function SY(Q){t(e.Array);for(let Z of Q)I1(Z)}function CY(Q){t(e.Boolean),t(Q?1:0)}function OY(Q){t(e.BigInt),r0.setBigInt64(0,Q);for(let Z of a0)t(Z)}function FY(Q){t(e.Date),I1(Q.getTime())}function xY(Q){t(e.Null)}function gY(Q){t(e.Number),r0.setFloat64(0,Q);for(let Z of a0)t(Z)}function KY(Q){t(e.Object);for(let Z of globalThis.Object.getOwnPropertyNames(Q).sort())I1(Z),I1(Q[Z])}function _Y(Q){t(e.String);for(let Z=0;Z<Q.length;Z++)for(let Y of bY(Q.charCodeAt(Z)))t(Y)}function EY(Q){t(e.Symbol),I1(Q.description)}function kY(Q){t(e.Uint8Array);for(let Z=0;Z<Q.length;Z++)t(Q[Z])}function VY(Q){return t(e.Undefined)}function I1(Q){if(V(Q))return SY(Q);if(N1(Q))return CY(Q);if(a(Q))return OY(Q);if(x1(Q))return FY(Q);if(D1(Q))return xY(Q);if(N(Q))return gY(Q);if(s(Q))return KY(Q);if(f(Q))return _Y(Q);if(P1(Q))return EY(Q);if(g1(Q))return kY(Q);if(v(Q))return VY(Q);throw new l0(Q)}function t(Q){T1=T1^PY[Q],T1=T1*DY%NY}function d1(Q){return T1=BigInt("14695981039346656037"),I1(Q),T1}var TY=["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 e0(Q){try{return new RegExp(Q),!0}catch{return!1}}function w0(Q){if(!n(Q))return!1;for(let Z=0;Z<Q.length;Z++){let Y=Q.charCodeAt(Z);if(Y>=7&&Y<=13||Y===27||Y===127)return!1}return!0}function Q8(Q){return D0(Q)||E(Q)}function h1(Q){return z1(Q)||E0(Q)}function g(Q){return z1(Q)||A1(Q)}function D0(Q){return z1(Q)||Y0(Q)}function F(Q){return z1(Q)||n(Q)}function IY(Q){return z1(Q)||n(Q)&&w0(Q)&&e0(Q)}function dY(Q){return z1(Q)||n(Q)&&w0(Q)}function Y8(Q){return z1(Q)||E(Q)}function fY(Q){return C(Q,"Any")&&F(Q.$id)}function iY(Q){return C(Q,"Argument")&&A1(Q.index)}function yY(Q){return C(Q,"Array")&&Q.type==="array"&&F(Q.$id)&&E(Q.items)&&g(Q.minItems)&&g(Q.maxItems)&&D0(Q.uniqueItems)&&Y8(Q.contains)&&g(Q.minContains)&&g(Q.maxContains)}function pY(Q){return C(Q,"AsyncIterator")&&Q.type==="AsyncIterator"&&F(Q.$id)&&E(Q.items)}function oY(Q){return C(Q,"BigInt")&&Q.type==="bigint"&&F(Q.$id)&&h1(Q.exclusiveMaximum)&&h1(Q.exclusiveMinimum)&&h1(Q.maximum)&&h1(Q.minimum)&&h1(Q.multipleOf)}function nY(Q){return C(Q,"Boolean")&&Q.type==="boolean"&&F(Q.$id)}function mY(Q){return C(Q,"Computed")&&n(Q.target)&&Y1(Q.parameters)&&Q.parameters.every((Z)=>E(Z))}function hY(Q){return C(Q,"Constructor")&&Q.type==="Constructor"&&F(Q.$id)&&Y1(Q.parameters)&&Q.parameters.every((Z)=>E(Z))&&E(Q.returns)}function tY(Q){return C(Q,"Date")&&Q.type==="Date"&&F(Q.$id)&&g(Q.exclusiveMaximumTimestamp)&&g(Q.exclusiveMinimumTimestamp)&&g(Q.maximumTimestamp)&&g(Q.minimumTimestamp)&&g(Q.multipleOfTimestamp)}function vY(Q){return C(Q,"Function")&&Q.type==="Function"&&F(Q.$id)&&Y1(Q.parameters)&&Q.parameters.every((Z)=>E(Z))&&E(Q.returns)}function cY(Q){return C(Q,"Integer")&&Q.type==="integer"&&F(Q.$id)&&g(Q.exclusiveMaximum)&&g(Q.exclusiveMinimum)&&g(Q.maximum)&&g(Q.minimum)&&g(Q.multipleOf)}function Z8(Q){return I(Q)&&Object.entries(Q).every(([Z,Y])=>w0(Z)&&E(Y))}function uY(Q){return C(Q,"Intersect")&&(n(Q.type)&&Q.type!=="object"?!1:!0)&&Y1(Q.allOf)&&Q.allOf.every((Z)=>E(Z)&&!UZ(Z))&&F(Q.type)&&(D0(Q.unevaluatedProperties)||Y8(Q.unevaluatedProperties))&&F(Q.$id)}function lY(Q){return C(Q,"Iterator")&&Q.type==="Iterator"&&F(Q.$id)&&E(Q.items)}function C(Q,Z){return I(Q)&&B in Q&&Q[B]===Z}function sY(Q){return C(Q,"Literal")&&F(Q.$id)&&rY(Q.const)}function rY(Q){return Y0(Q)||A1(Q)||n(Q)}function aY(Q){return C(Q,"MappedKey")&&Y1(Q.keys)&&Q.keys.every((Z)=>A1(Z)||n(Z))}function eY(Q){return C(Q,"MappedResult")&&Z8(Q.properties)}function QZ(Q){return C(Q,"Never")&&I(Q.not)&&Object.getOwnPropertyNames(Q.not).length===0}function YZ(Q){return C(Q,"Not")&&E(Q.not)}function ZZ(Q){return C(Q,"Null")&&Q.type==="null"&&F(Q.$id)}function GZ(Q){return C(Q,"Number")&&Q.type==="number"&&F(Q.$id)&&g(Q.exclusiveMaximum)&&g(Q.exclusiveMinimum)&&g(Q.maximum)&&g(Q.minimum)&&g(Q.multipleOf)}function WZ(Q){return C(Q,"Object")&&Q.type==="object"&&F(Q.$id)&&Z8(Q.properties)&&Q8(Q.additionalProperties)&&g(Q.minProperties)&&g(Q.maxProperties)}function XZ(Q){return C(Q,"Promise")&&Q.type==="Promise"&&F(Q.$id)&&E(Q.item)}function $Z(Q){return C(Q,"Record")&&Q.type==="object"&&F(Q.$id)&&Q8(Q.additionalProperties)&&I(Q.patternProperties)&&((Z)=>{let Y=Object.getOwnPropertyNames(Z.patternProperties);return Y.length===1&&e0(Y[0])&&I(Z.patternProperties)&&E(Z.patternProperties[Y[0]])})(Q)}function zZ(Q){return C(Q,"Ref")&&F(Q.$id)&&n(Q.$ref)}function JZ(Q){return C(Q,"RegExp")&&F(Q.$id)&&n(Q.source)&&n(Q.flags)&&g(Q.maxLength)&&g(Q.minLength)}function qZ(Q){return C(Q,"String")&&Q.type==="string"&&F(Q.$id)&&g(Q.minLength)&&g(Q.maxLength)&&IY(Q.pattern)&&dY(Q.format)}function HZ(Q){return C(Q,"Symbol")&&Q.type==="symbol"&&F(Q.$id)}function LZ(Q){return C(Q,"TemplateLiteral")&&Q.type==="string"&&n(Q.pattern)&&Q.pattern[0]==="^"&&Q.pattern[Q.pattern.length-1]==="$"}function MZ(Q){return C(Q,"This")&&F(Q.$id)&&n(Q.$ref)}function UZ(Q){return I(Q)&&B1 in Q}function RZ(Q){return C(Q,"Tuple")&&Q.type==="array"&&F(Q.$id)&&A1(Q.minItems)&&A1(Q.maxItems)&&Q.minItems===Q.maxItems&&(z1(Q.items)&&z1(Q.additionalItems)&&Q.minItems===0||Y1(Q.items)&&Q.items.every((Z)=>E(Z)))}function AZ(Q){return C(Q,"Undefined")&&Q.type==="undefined"&&F(Q.$id)}function BZ(Q){return C(Q,"Union")&&F(Q.$id)&&I(Q)&&Y1(Q.anyOf)&&Q.anyOf.every((Z)=>E(Z))}function jZ(Q){return C(Q,"Uint8Array")&&Q.type==="Uint8Array"&&F(Q.$id)&&g(Q.minByteLength)&&g(Q.maxByteLength)}function wZ(Q){return C(Q,"Unknown")&&F(Q.$id)}function DZ(Q){return C(Q,"Unsafe")}function NZ(Q){return C(Q,"Void")&&Q.type==="void"&&F(Q.$id)}function PZ(Q){return I(Q)&&B in Q&&n(Q[B])&&!TY.includes(Q[B])}function E(Q){return I(Q)&&(fY(Q)||iY(Q)||yY(Q)||nY(Q)||oY(Q)||pY(Q)||mY(Q)||hY(Q)||tY(Q)||vY(Q)||cY(Q)||uY(Q)||lY(Q)||sY(Q)||aY(Q)||eY(Q)||QZ(Q)||YZ(Q)||ZZ(Q)||GZ(Q)||WZ(Q)||XZ(Q)||$Z(Q)||zZ(Q)||JZ(Q)||qZ(Q)||HZ(Q)||LZ(Q)||MZ(Q)||RZ(Q)||AZ(Q)||BZ(Q)||jZ(Q)||wZ(Q)||DZ(Q)||NZ(Q)||PZ(Q))}class G8 extends T{constructor(Q){super("Unknown type");this.schema=Q}}function bZ(Q){return Q[B]==="Any"||Q[B]==="Unknown"}function P(Q){return Q!==void 0}function SZ(Q,Z,Y){return!0}function CZ(Q,Z,Y){return!0}function OZ(Q,Z,Y){if(!V(Y))return!1;if(P(Q.minItems)&&!(Y.length>=Q.minItems))return!1;if(P(Q.maxItems)&&!(Y.length<=Q.maxItems))return!1;if(!Y.every((X)=>y(Q.items,Z,X)))return!1;if(Q.uniqueItems===!0&&!function(){let X=new Set;for(let J of Y){let H=d1(J);if(X.has(H))return!1;else X.add(H)}return!0}())return!1;if(!(P(Q.contains)||N(Q.minContains)||N(Q.maxContains)))return!0;let G=P(Q.contains)?Q.contains:c(),W=Y.reduce((X,J)=>y(G,Z,J)?X+1:X,0);if(W===0)return!1;if(N(Q.minContains)&&W<Q.minContains)return!1;if(N(Q.maxContains)&&W>Q.maxContains)return!1;return!0}function FZ(Q,Z,Y){return u1(Y)}function xZ(Q,Z,Y){if(!a(Y))return!1;if(P(Q.exclusiveMaximum)&&!(Y<Q.exclusiveMaximum))return!1;if(P(Q.exclusiveMinimum)&&!(Y>Q.exclusiveMinimum))return!1;if(P(Q.maximum)&&!(Y<=Q.maximum))return!1;if(P(Q.minimum)&&!(Y>=Q.minimum))return!1;if(P(Q.multipleOf)&&Y%Q.multipleOf!==BigInt(0))return!1;return!0}function gZ(Q,Z,Y){return N1(Y)}function KZ(Q,Z,Y){return y(Q.returns,Z,Y.prototype)}function _Z(Q,Z,Y){if(!x1(Y))return!1;if(P(Q.exclusiveMaximumTimestamp)&&!(Y.getTime()<Q.exclusiveMaximumTimestamp))return!1;if(P(Q.exclusiveMinimumTimestamp)&&!(Y.getTime()>Q.exclusiveMinimumTimestamp))return!1;if(P(Q.maximumTimestamp)&&!(Y.getTime()<=Q.maximumTimestamp))return!1;if(P(Q.minimumTimestamp)&&!(Y.getTime()>=Q.minimumTimestamp))return!1;if(P(Q.multipleOfTimestamp)&&Y.getTime()%Q.multipleOfTimestamp!==0)return!1;return!0}function EZ(Q,Z,Y){return e1(Y)}function kZ(Q,Z,Y){let G=globalThis.Object.values(Q.$defs),W=Q.$defs[Q.$ref];return y(W,[...Z,...G],Y)}function VZ(Q,Z,Y){if(!a1(Y))return!1;if(P(Q.exclusiveMaximum)&&!(Y<Q.exclusiveMaximum))return!1;if(P(Q.exclusiveMinimum)&&!(Y>Q.exclusiveMinimum))return!1;if(P(Q.maximum)&&!(Y<=Q.maximum))return!1;if(P(Q.minimum)&&!(Y>=Q.minimum))return!1;if(P(Q.multipleOf)&&Y%Q.multipleOf!==0)return!1;return!0}function TZ(Q,Z,Y){let G=Q.allOf.every((W)=>y(W,Z,Y));if(Q.unevaluatedProperties===!1){let W=new RegExp(H1(Q)),X=Object.getOwnPropertyNames(Y).every((J)=>W.test(J));return G&&X}else if(u(Q.unevaluatedProperties)){let W=new RegExp(H1(Q)),X=Object.getOwnPropertyNames(Y).every((J)=>W.test(J)||y(Q.unevaluatedProperties,Z,Y[J]));return G&&X}else return G}function IZ(Q,Z,Y){return l1(Y)}function dZ(Q,Z,Y){return Y===Q.const}function fZ(Q,Z,Y){return!1}function iZ(Q,Z,Y){return!y(Q.not,Z,Y)}function yZ(Q,Z,Y){return D1(Y)}function pZ(Q,Z,Y){if(!_.IsNumberLike(Y))return!1;if(P(Q.exclusiveMaximum)&&!(Y<Q.exclusiveMaximum))return!1;if(P(Q.exclusiveMinimum)&&!(Y>Q.exclusiveMinimum))return!1;if(P(Q.minimum)&&!(Y>=Q.minimum))return!1;if(P(Q.maximum)&&!(Y<=Q.maximum))return!1;if(P(Q.multipleOf)&&Y%Q.multipleOf!==0)return!1;return!0}function oZ(Q,Z,Y){if(!_.IsObjectLike(Y))return!1;if(P(Q.minProperties)&&!(Object.getOwnPropertyNames(Y).length>=Q.minProperties))return!1;if(P(Q.maxProperties)&&!(Object.getOwnPropertyNames(Y).length<=Q.maxProperties))return!1;let G=Object.getOwnPropertyNames(Q.properties);for(let W of G){let X=Q.properties[W];if(Q.required&&Q.required.includes(W)){if(!y(X,Z,Y[W]))return!1;if((L1(X)||bZ(X))&&!(W in Y))return!1}else if(_.IsExactOptionalProperty(Y,W)&&!y(X,Z,Y[W]))return!1}if(Q.additionalProperties===!1){let W=Object.getOwnPropertyNames(Y);if(Q.required&&Q.required.length===G.length&&W.length===G.length)return!0;else return W.every((X)=>G.includes(X))}else if(typeof Q.additionalProperties==="object")return Object.getOwnPropertyNames(Y).every((X)=>G.includes(X)||y(Q.additionalProperties,Z,Y[X]));else return!0}function nZ(Q,Z,Y){return s1(Y)}function mZ(Q,Z,Y){if(!_.IsRecordLike(Y))return!1;if(P(Q.minProperties)&&!(Object.getOwnPropertyNames(Y).length>=Q.minProperties))return!1;if(P(Q.maxProperties)&&!(Object.getOwnPropertyNames(Y).length<=Q.maxProperties))return!1;let[G,W]=Object.entries(Q.patternProperties)[0],X=new RegExp(G),J=Object.entries(Y).every(([w,A])=>{return X.test(w)?y(W,Z,A):!0}),H=typeof Q.additionalProperties==="object"?Object.entries(Y).every(([w,A])=>{return!X.test(w)?y(Q.additionalProperties,Z,A):!0}):!0,j=Q.additionalProperties===!1?Object.getOwnPropertyNames(Y).every((w)=>{return X.test(w)}):!0;return J&&H&&j}function hZ(Q,Z,Y){return y(i(Q,Z),Z,Y)}function tZ(Q,Z,Y){let G=new RegExp(Q.source,Q.flags);if(P(Q.minLength)){if(!(Y.length>=Q.minLength))return!1}if(P(Q.maxLength)){if(!(Y.length<=Q.maxLength))return!1}return G.test(Y)}function vZ(Q,Z,Y){if(!f(Y))return!1;if(P(Q.minLength)){if(!(Y.length>=Q.minLength))return!1}if(P(Q.maxLength)){if(!(Y.length<=Q.maxLength))return!1}if(P(Q.pattern)){if(!new RegExp(Q.pattern).test(Y))return!1}if(P(Q.format)){if(!Q1.Has(Q.format))return!1;return Q1.Get(Q.format)(Y)}return!0}function cZ(Q,Z,Y){return P1(Y)}function uZ(Q,Z,Y){return f(Y)&&new RegExp(Q.pattern).test(Y)}function lZ(Q,Z,Y){return y(i(Q,Z),Z,Y)}function sZ(Q,Z,Y){if(!V(Y))return!1;if(Q.items===void 0&&Y.length!==0)return!1;if(Y.length!==Q.maxItems)return!1;if(!Q.items)return!0;for(let G=0;G<Q.items.length;G++)if(!y(Q.items[G],Z,Y[G]))return!1;return!0}function rZ(Q,Z,Y){return v(Y)}function aZ(Q,Z,Y){return Q.anyOf.some((G)=>y(G,Z,Y))}function eZ(Q,Z,Y){if(!g1(Y))return!1;if(P(Q.maxByteLength)&&!(Y.length<=Q.maxByteLength))return!1;if(P(Q.minByteLength)&&!(Y.length>=Q.minByteLength))return!1;return!0}function Q6(Q,Z,Y){return!0}function Y6(Q,Z,Y){return _.IsVoidLike(Y)}function Z6(Q,Z,Y){if(!r.Has(Q[B]))return!1;return r.Get(Q[B])(Q,Y)}function y(Q,Z,Y){let G=P(Q.$id)?w1(Q,Z):Z,W=Q;switch(W[B]){case"Any":return SZ(W,G,Y);case"Argument":return CZ(W,G,Y);case"Array":return OZ(W,G,Y);case"AsyncIterator":return FZ(W,G,Y);case"BigInt":return xZ(W,G,Y);case"Boolean":return gZ(W,G,Y);case"Constructor":return KZ(W,G,Y);case"Date":return _Z(W,G,Y);case"Function":return EZ(W,G,Y);case"Import":return kZ(W,G,Y);case"Integer":return VZ(W,G,Y);case"Intersect":return TZ(W,G,Y);case"Iterator":return IZ(W,G,Y);case"Literal":return dZ(W,G,Y);case"Never":return fZ(W,G,Y);case"Not":return iZ(W,G,Y);case"Null":return yZ(W,G,Y);case"Number":return pZ(W,G,Y);case"Object":return oZ(W,G,Y);case"Promise":return nZ(W,G,Y);case"Record":return mZ(W,G,Y);case"Ref":return hZ(W,G,Y);case"RegExp":return tZ(W,G,Y);case"String":return vZ(W,G,Y);case"Symbol":return cZ(W,G,Y);case"TemplateLiteral":return uZ(W,G,Y);case"This":return lZ(W,G,Y);case"Tuple":return sZ(W,G,Y);case"Undefined":return rZ(W,G,Y);case"Union":return aZ(W,G,Y);case"Uint8Array":return eZ(W,G,Y);case"Unknown":return Q6(W,G,Y);case"Void":return Y6(W,G,Y);default:if(!r.Has(W[B]))throw new G8(W);return Z6(W,G,Y)}}function S1(...Q){return Q.length===3?y(Q[0],Q[1],Q[2]):y(Q[0],[],Q[1])}var q;(function(Q){Q[Q.ArrayContains=0]="ArrayContains",Q[Q.ArrayMaxContains=1]="ArrayMaxContains",Q[Q.ArrayMaxItems=2]="ArrayMaxItems",Q[Q.ArrayMinContains=3]="ArrayMinContains",Q[Q.ArrayMinItems=4]="ArrayMinItems",Q[Q.ArrayUniqueItems=5]="ArrayUniqueItems",Q[Q.Array=6]="Array",Q[Q.AsyncIterator=7]="AsyncIterator",Q[Q.BigIntExclusiveMaximum=8]="BigIntExclusiveMaximum",Q[Q.BigIntExclusiveMinimum=9]="BigIntExclusiveMinimum",Q[Q.BigIntMaximum=10]="BigIntMaximum",Q[Q.BigIntMinimum=11]="BigIntMinimum",Q[Q.BigIntMultipleOf=12]="BigIntMultipleOf",Q[Q.BigInt=13]="BigInt",Q[Q.Boolean=14]="Boolean",Q[Q.DateExclusiveMaximumTimestamp=15]="DateExclusiveMaximumTimestamp",Q[Q.DateExclusiveMinimumTimestamp=16]="DateExclusiveMinimumTimestamp",Q[Q.DateMaximumTimestamp=17]="DateMaximumTimestamp",Q[Q.DateMinimumTimestamp=18]="DateMinimumTimestamp",Q[Q.DateMultipleOfTimestamp=19]="DateMultipleOfTimestamp",Q[Q.Date=20]="Date",Q[Q.Function=21]="Function",Q[Q.IntegerExclusiveMaximum=22]="IntegerExclusiveMaximum",Q[Q.IntegerExclusiveMinimum=23]="IntegerExclusiveMinimum",Q[Q.IntegerMaximum=24]="IntegerMaximum",Q[Q.IntegerMinimum=25]="IntegerMinimum",Q[Q.IntegerMultipleOf=26]="IntegerMultipleOf",Q[Q.Integer=27]="Integer",Q[Q.IntersectUnevaluatedProperties=28]="IntersectUnevaluatedProperties",Q[Q.Intersect=29]="Intersect",Q[Q.Iterator=30]="Iterator",Q[Q.Kind=31]="Kind",Q[Q.Literal=32]="Literal",Q[Q.Never=33]="Never",Q[Q.Not=34]="Not",Q[Q.Null=35]="Null",Q[Q.NumberExclusiveMaximum=36]="NumberExclusiveMaximum",Q[Q.NumberExclusiveMinimum=37]="NumberExclusiveMinimum",Q[Q.NumberMaximum=38]="NumberMaximum",Q[Q.NumberMinimum=39]="NumberMinimum",Q[Q.NumberMultipleOf=40]="NumberMultipleOf",Q[Q.Number=41]="Number",Q[Q.ObjectAdditionalProperties=42]="ObjectAdditionalProperties",Q[Q.ObjectMaxProperties=43]="ObjectMaxProperties",Q[Q.ObjectMinProperties=44]="ObjectMinProperties",Q[Q.ObjectRequiredProperty=45]="ObjectRequiredProperty",Q[Q.Object=46]="Object",Q[Q.Promise=47]="Promise",Q[Q.RegExp=48]="RegExp",Q[Q.StringFormatUnknown=49]="StringFormatUnknown",Q[Q.StringFormat=50]="StringFormat",Q[Q.StringMaxLength=51]="StringMaxLength",Q[Q.StringMinLength=52]="StringMinLength",Q[Q.StringPattern=53]="StringPattern",Q[Q.String=54]="String",Q[Q.Symbol=55]="Symbol",Q[Q.TupleLength=56]="TupleLength",Q[Q.Tuple=57]="Tuple",Q[Q.Uint8ArrayMaxByteLength=58]="Uint8ArrayMaxByteLength",Q[Q.Uint8ArrayMinByteLength=59]="Uint8ArrayMinByteLength",Q[Q.Uint8Array=60]="Uint8Array",Q[Q.Undefined=61]="Undefined",Q[Q.Union=62]="Union",Q[Q.Void=63]="Void"})(q||(q={}));class W8 extends T{constructor(Q){super("Unknown type");this.schema=Q}}function M1(Q){return Q.replace(/~/g,"~0").replace(/\//g,"~1")}function b(Q){return Q!==void 0}class N0{constructor(Q){this.iterator=Q}[Symbol.iterator](){return this.iterator}First(){let Q=this.iterator.next();return Q.done?void 0:Q.value}}function L(Q,Z,Y,G,W=[]){return{type:Q,schema:Z,path:Y,value:G,message:c0()({errorType:Q,path:Y,schema:Z,value:G,errors:W}),errors:W}}function*G6(Q,Z,Y,G){}function*W6(Q,Z,Y,G){}function*X6(Q,Z,Y,G){if(!V(G))return yield L(q.Array,Q,Y,G);if(b(Q.minItems)&&!(G.length>=Q.minItems))yield L(q.ArrayMinItems,Q,Y,G);if(b(Q.maxItems)&&!(G.length<=Q.maxItems))yield L(q.ArrayMaxItems,Q,Y,G);for(let J=0;J<G.length;J++)yield*p(Q.items,Z,`${Y}/${J}`,G[J]);if(Q.uniqueItems===!0&&!function(){let J=new Set;for(let H of G){let j=d1(H);if(J.has(j))return!1;else J.add(j)}return!0}())yield L(q.ArrayUniqueItems,Q,Y,G);if(!(b(Q.contains)||b(Q.minContains)||b(Q.maxContains)))return;let W=b(Q.contains)?Q.contains:c(),X=G.reduce((J,H,j)=>p(W,Z,`${Y}${j}`,H).next().done===!0?J+1:J,0);if(X===0)yield L(q.ArrayContains,Q,Y,G);if(N(Q.minContains)&&X<Q.minContains)yield L(q.ArrayMinContains,Q,Y,G);if(N(Q.maxContains)&&X>Q.maxContains)yield L(q.ArrayMaxContains,Q,Y,G)}function*$6(Q,Z,Y,G){if(!u1(G))yield L(q.AsyncIterator,Q,Y,G)}function*z6(Q,Z,Y,G){if(!a(G))return yield L(q.BigInt,Q,Y,G);if(b(Q.exclusiveMaximum)&&!(G<Q.exclusiveMaximum))yield L(q.BigIntExclusiveMaximum,Q,Y,G);if(b(Q.exclusiveMinimum)&&!(G>Q.exclusiveMinimum))yield L(q.BigIntExclusiveMinimum,Q,Y,G);if(b(Q.maximum)&&!(G<=Q.maximum))yield L(q.BigIntMaximum,Q,Y,G);if(b(Q.minimum)&&!(G>=Q.minimum))yield L(q.BigIntMinimum,Q,Y,G);if(b(Q.multipleOf)&&G%Q.multipleOf!==BigInt(0))yield L(q.BigIntMultipleOf,Q,Y,G)}function*J6(Q,Z,Y,G){if(!N1(G))yield L(q.Boolean,Q,Y,G)}function*q6(Q,Z,Y,G){yield*p(Q.returns,Z,Y,G.prototype)}function*H6(Q,Z,Y,G){if(!x1(G))return yield L(q.Date,Q,Y,G);if(b(Q.exclusiveMaximumTimestamp)&&!(G.getTime()<Q.exclusiveMaximumTimestamp))yield L(q.DateExclusiveMaximumTimestamp,Q,Y,G);if(b(Q.exclusiveMinimumTimestamp)&&!(G.getTime()>Q.exclusiveMinimumTimestamp))yield L(q.DateExclusiveMinimumTimestamp,Q,Y,G);if(b(Q.maximumTimestamp)&&!(G.getTime()<=Q.maximumTimestamp))yield L(q.DateMaximumTimestamp,Q,Y,G);if(b(Q.minimumTimestamp)&&!(G.getTime()>=Q.minimumTimestamp))yield L(q.DateMinimumTimestamp,Q,Y,G);if(b(Q.multipleOfTimestamp)&&G.getTime()%Q.multipleOfTimestamp!==0)yield L(q.DateMultipleOfTimestamp,Q,Y,G)}function*L6(Q,Z,Y,G){if(!e1(G))yield L(q.Function,Q,Y,G)}function*M6(Q,Z,Y,G){let W=globalThis.Object.values(Q.$defs),X=Q.$defs[Q.$ref];yield*p(X,[...Z,...W],Y,G)}function*U6(Q,Z,Y,G){if(!a1(G))return yield L(q.Integer,Q,Y,G);if(b(Q.exclusiveMaximum)&&!(G<Q.exclusiveMaximum))yield L(q.IntegerExclusiveMaximum,Q,Y,G);if(b(Q.exclusiveMinimum)&&!(G>Q.exclusiveMinimum))yield L(q.IntegerExclusiveMinimum,Q,Y,G);if(b(Q.maximum)&&!(G<=Q.maximum))yield L(q.IntegerMaximum,Q,Y,G);if(b(Q.minimum)&&!(G>=Q.minimum))yield L(q.IntegerMinimum,Q,Y,G);if(b(Q.multipleOf)&&G%Q.multipleOf!==0)yield L(q.IntegerMultipleOf,Q,Y,G)}function*R6(Q,Z,Y,G){let W=!1;for(let X of Q.allOf)for(let J of p(X,Z,Y,G))W=!0,yield J;if(W)return yield L(q.Intersect,Q,Y,G);if(Q.unevaluatedProperties===!1){let X=new RegExp(H1(Q));for(let J of Object.getOwnPropertyNames(G))if(!X.test(J))yield L(q.IntersectUnevaluatedProperties,Q,`${Y}/${J}`,G)}if(typeof Q.unevaluatedProperties==="object"){let X=new RegExp(H1(Q));for(let J of Object.getOwnPropertyNames(G))if(!X.test(J)){let H=p(Q.unevaluatedProperties,Z,`${Y}/${J}`,G[J]).next();if(!H.done)yield H.value}}}function*A6(Q,Z,Y,G){if(!l1(G))yield L(q.Iterator,Q,Y,G)}function*B6(Q,Z,Y,G){if(G!==Q.const)yield L(q.Literal,Q,Y,G)}function*j6(Q,Z,Y,G){yield L(q.Never,Q,Y,G)}function*w6(Q,Z,Y,G){if(p(Q.not,Z,Y,G).next().done===!0)yield L(q.Not,Q,Y,G)}function*D6(Q,Z,Y,G){if(!D1(G))yield L(q.Null,Q,Y,G)}function*N6(Q,Z,Y,G){if(!_.IsNumberLike(G))return yield L(q.Number,Q,Y,G);if(b(Q.exclusiveMaximum)&&!(G<Q.exclusiveMaximum))yield L(q.NumberExclusiveMaximum,Q,Y,G);if(b(Q.exclusiveMinimum)&&!(G>Q.exclusiveMinimum))yield L(q.NumberExclusiveMinimum,Q,Y,G);if(b(Q.maximum)&&!(G<=Q.maximum))yield L(q.NumberMaximum,Q,Y,G);if(b(Q.minimum)&&!(G>=Q.minimum))yield L(q.NumberMinimum,Q,Y,G);if(b(Q.multipleOf)&&G%Q.multipleOf!==0)yield L(q.NumberMultipleOf,Q,Y,G)}function*P6(Q,Z,Y,G){if(!_.IsObjectLike(G))return yield L(q.Object,Q,Y,G);if(b(Q.minProperties)&&!(Object.getOwnPropertyNames(G).length>=Q.minProperties))yield L(q.ObjectMinProperties,Q,Y,G);if(b(Q.maxProperties)&&!(Object.getOwnPropertyNames(G).length<=Q.maxProperties))yield L(q.ObjectMaxProperties,Q,Y,G);let W=Array.isArray(Q.required)?Q.required:[],X=Object.getOwnPropertyNames(Q.properties),J=Object.getOwnPropertyNames(G);for(let H of W){if(J.includes(H))continue;yield L(q.ObjectRequiredProperty,Q.properties[H],`${Y}/${M1(H)}`,void 0)}if(Q.additionalProperties===!1){for(let H of J)if(!X.includes(H))yield L(q.ObjectAdditionalProperties,Q,`${Y}/${M1(H)}`,G[H])}if(typeof Q.additionalProperties==="object")for(let H of J){if(X.includes(H))continue;yield*p(Q.additionalProperties,Z,`${Y}/${M1(H)}`,G[H])}for(let H of X){let j=Q.properties[H];if(Q.required&&Q.required.includes(H)){if(yield*p(j,Z,`${Y}/${M1(H)}`,G[H]),L1(Q)&&!(H in G))yield L(q.ObjectRequiredProperty,j,`${Y}/${M1(H)}`,void 0)}else if(_.IsExactOptionalProperty(G,H))yield*p(j,Z,`${Y}/${M1(H)}`,G[H])}}function*b6(Q,Z,Y,G){if(!s1(G))yield L(q.Promise,Q,Y,G)}function*S6(Q,Z,Y,G){if(!_.IsRecordLike(G))return yield L(q.Object,Q,Y,G);if(b(Q.minProperties)&&!(Object.getOwnPropertyNames(G).length>=Q.minProperties))yield L(q.ObjectMinProperties,Q,Y,G);if(b(Q.maxProperties)&&!(Object.getOwnPropertyNames(G).length<=Q.maxProperties))yield L(q.ObjectMaxProperties,Q,Y,G);let[W,X]=Object.entries(Q.patternProperties)[0],J=new RegExp(W);for(let[H,j]of Object.entries(G))if(J.test(H))yield*p(X,Z,`${Y}/${M1(H)}`,j);if(typeof Q.additionalProperties==="object"){for(let[H,j]of Object.entries(G))if(!J.test(H))yield*p(Q.additionalProperties,Z,`${Y}/${M1(H)}`,j)}if(Q.additionalProperties===!1)for(let[H,j]of Object.entries(G)){if(J.test(H))continue;return yield L(q.ObjectAdditionalProperties,Q,`${Y}/${M1(H)}`,j)}}function*C6(Q,Z,Y,G){yield*p(i(Q,Z),Z,Y,G)}function*O6(Q,Z,Y,G){if(!f(G))return yield L(q.String,Q,Y,G);if(b(Q.minLength)&&!(G.length>=Q.minLength))yield L(q.StringMinLength,Q,Y,G);if(b(Q.maxLength)&&!(G.length<=Q.maxLength))yield L(q.StringMaxLength,Q,Y,G);if(!new RegExp(Q.source,Q.flags).test(G))return yield L(q.RegExp,Q,Y,G)}function*F6(Q,Z,Y,G){if(!f(G))return yield L(q.String,Q,Y,G);if(b(Q.minLength)&&!(G.length>=Q.minLength))yield L(q.StringMinLength,Q,Y,G);if(b(Q.maxLength)&&!(G.length<=Q.maxLength))yield L(q.StringMaxLength,Q,Y,G);if(f(Q.pattern)){if(!new RegExp(Q.pattern).test(G))yield L(q.StringPattern,Q,Y,G)}if(f(Q.format)){if(!Q1.Has(Q.format))yield L(q.StringFormatUnknown,Q,Y,G);else if(!Q1.Get(Q.format)(G))yield L(q.StringFormat,Q,Y,G)}}function*x6(Q,Z,Y,G){if(!P1(G))yield L(q.Symbol,Q,Y,G)}function*g6(Q,Z,Y,G){if(!f(G))return yield L(q.String,Q,Y,G);if(!new RegExp(Q.pattern).test(G))yield L(q.StringPattern,Q,Y,G)}function*K6(Q,Z,Y,G){yield*p(i(Q,Z),Z,Y,G)}function*_6(Q,Z,Y,G){if(!V(G))return yield L(q.Tuple,Q,Y,G);if(Q.items===void 0&&G.length!==0)return yield L(q.TupleLength,Q,Y,G);if(G.length!==Q.maxItems)return yield L(q.TupleLength,Q,Y,G);if(!Q.items)return;for(let W=0;W<Q.items.length;W++)yield*p(Q.items[W],Z,`${Y}/${W}`,G[W])}function*E6(Q,Z,Y,G){if(!v(G))yield L(q.Undefined,Q,Y,G)}function*k6(Q,Z,Y,G){if(S1(Q,Z,G))return;let W=Q.anyOf.map((X)=>new N0(p(X,Z,Y,G)));yield L(q.Union,Q,Y,G,W)}function*V6(Q,Z,Y,G){if(!g1(G))return yield L(q.Uint8Array,Q,Y,G);if(b(Q.maxByteLength)&&!(G.length<=Q.maxByteLength))yield L(q.Uint8ArrayMaxByteLength,Q,Y,G);if(b(Q.minByteLength)&&!(G.length>=Q.minByteLength))yield L(q.Uint8ArrayMinByteLength,Q,Y,G)}function*T6(Q,Z,Y,G){}function*I6(Q,Z,Y,G){if(!_.IsVoidLike(G))yield L(q.Void,Q,Y,G)}function*d6(Q,Z,Y,G){if(!r.Get(Q[B])(Q,G))yield L(q.Kind,Q,Y,G)}function*p(Q,Z,Y,G){let W=b(Q.$id)?[...Z,Q]:Z,X=Q;switch(X[B]){case"Any":return yield*G6(X,W,Y,G);case"Argument":return yield*W6(X,W,Y,G);case"Array":return yield*X6(X,W,Y,G);case"AsyncIterator":return yield*$6(X,W,Y,G);case"BigInt":return yield*z6(X,W,Y,G);case"Boolean":return yield*J6(X,W,Y,G);case"Constructor":return yield*q6(X,W,Y,G);case"Date":return yield*H6(X,W,Y,G);case"Function":return yield*L6(X,W,Y,G);case"Import":return yield*M6(X,W,Y,G);case"Integer":return yield*U6(X,W,Y,G);case"Intersect":return yield*R6(X,W,Y,G);case"Iterator":return yield*A6(X,W,Y,G);case"Literal":return yield*B6(X,W,Y,G);case"Never":return yield*j6(X,W,Y,G);case"Not":return yield*w6(X,W,Y,G);case"Null":return yield*D6(X,W,Y,G);case"Number":return yield*N6(X,W,Y,G);case"Object":return yield*P6(X,W,Y,G);case"Promise":return yield*b6(X,W,Y,G);case"Record":return yield*S6(X,W,Y,G);case"Ref":return yield*C6(X,W,Y,G);case"RegExp":return yield*O6(X,W,Y,G);case"String":return yield*F6(X,W,Y,G);case"Symbol":return yield*x6(X,W,Y,G);case"TemplateLiteral":return yield*g6(X,W,Y,G);case"This":return yield*K6(X,W,Y,G);case"Tuple":return yield*_6(X,W,Y,G);case"Undefined":return yield*E6(X,W,Y,G);case"Union":return yield*k6(X,W,Y,G);case"Uint8Array":return yield*V6(X,W,Y,G);case"Unknown":return yield*T6(X,W,Y,G);case"Void":return yield*I6(X,W,Y,G);default:if(!r.Has(X[B]))throw new W8(Q);return yield*d6(X,W,Y,G)}}function X8(...Q){let Z=Q.length===3?p(Q[0],Q[1],"",Q[2]):p(Q[0],[],"",Q[1]);return new N0(Z)}class P0 extends T{constructor(Q,Z,Y){super("Unable to decode value as it does not match the expected schema");this.schema=Q,this.value=Z,this.error=Y}}class $8 extends T{constructor(Q,Z,Y,G){super(G instanceof Error?G.message:"Unknown error");this.schema=Q,this.path=Z,this.value=Y,this.error=G}}function k(Q,Z,Y){try{return x(Q)?Q[B1].Decode(Y):Y}catch(G){throw new $8(Q,Z,Y,G)}}function f6(Q,Z,Y,G){return V(G)?k(Q,Y,G.map((W,X)=>W1(Q.items,Z,`${Y}/${X}`,W))):k(Q,Y,G)}function i6(Q,Z,Y,G){if(!s(G)||Q0(G))return k(Q,Y,G);let W=q0(Q),X=W.map((A)=>A[0]),J={...G};for(let[A,O]of W)if(A in J)J[A]=W1(O,Z,`${Y}/${A}`,J[A]);if(!x(Q.unevaluatedProperties))return k(Q,Y,J);let H=Object.getOwnPropertyNames(J),j=Q.unevaluatedProperties,w={...J};for(let A of H)if(!X.includes(A))w[A]=k(j,`${Y}/${A}`,w[A]);return k(Q,Y,w)}function y6(Q,Z,Y,G){let W=globalThis.Object.values(Q.$defs),X=Q.$defs[Q.$ref],J=W1(X,[...Z,...W],Y,G);return k(Q,Y,J)}function p6(Q,Z,Y,G){return k(Q,Y,W1(Q.not,Z,Y,G))}function o6(Q,Z,Y,G){if(!s(G))return k(Q,Y,G);let W=j1(Q),X={...G};for(let w of W){if(!r1(X,w))continue;if(v(X[w])&&(!n1(Q.properties[w])||_.IsExactOptionalProperty(X,w)))continue;X[w]=W1(Q.properties[w],Z,`${Y}/${w}`,X[w])}if(!u(Q.additionalProperties))return k(Q,Y,X);let J=Object.getOwnPropertyNames(X),H=Q.additionalProperties,j={...X};for(let w of J)if(!W.includes(w))j[w]=k(H,`${Y}/${w}`,j[w]);return k(Q,Y,j)}function n6(Q,Z,Y,G){if(!s(G))return k(Q,Y,G);let W=Object.getOwnPropertyNames(Q.patternProperties)[0],X=new RegExp(W),J={...G};for(let A of Object.getOwnPropertyNames(G))if(X.test(A))J[A]=W1(Q.patternProperties[W],Z,`${Y}/${A}`,J[A]);if(!u(Q.additionalProperties))return k(Q,Y,J);let H=Object.getOwnPropertyNames(J),j=Q.additionalProperties,w={...J};for(let A of H)if(!X.test(A))w[A]=k(j,`${Y}/${A}`,w[A]);return k(Q,Y,w)}function m6(Q,Z,Y,G){let W=i(Q,Z);return k(Q,Y,W1(W,Z,Y,G))}function h6(Q,Z,Y,G){let W=i(Q,Z);return k(Q,Y,W1(W,Z,Y,G))}function t6(Q,Z,Y,G){return V(G)&&V(Q.items)?k(Q,Y,Q.items.map((W,X)=>W1(W,Z,`${Y}/${X}`,G[X]))):k(Q,Y,G)}function v6(Q,Z,Y,G){for(let W of Q.anyOf){if(!S1(W,Z,G))continue;let X=W1(W,Z,Y,G);return k(Q,Y,X)}return k(Q,Y,G)}function W1(Q,Z,Y,G){let W=w1(Q,Z),X=Q;switch(Q[B]){case"Array":return f6(X,W,Y,G);case"Import":return y6(X,W,Y,G);case"Intersect":return i6(X,W,Y,G);case"Not":return p6(X,W,Y,G);case"Object":return o6(X,W,Y,G);case"Record":return n6(X,W,Y,G);case"Ref":return m6(X,W,Y,G);case"Symbol":return k(X,Y,G);case"This":return h6(X,W,Y,G);case"Tuple":return t6(X,W,Y,G);case"Union":return v6(X,W,Y,G);default:return k(X,Y,G)}}function z8(Q,Z,Y){return W1(Q,Z,"",Y)}class b0 extends T{constructor(Q,Z,Y){super("The encoded value does not match the expected schema");this.schema=Q,this.value=Z,this.error=Y}}class J8 extends T{constructor(Q,Z,Y,G){super(`${G instanceof Error?G.message:"Unknown error"}`);this.schema=Q,this.path=Z,this.value=Y,this.error=G}}function h(Q,Z,Y){try{return x(Q)?Q[B1].Encode(Y):Y}catch(G){throw new J8(Q,Z,Y,G)}}function c6(Q,Z,Y,G){let W=h(Q,Y,G);return V(W)?W.map((X,J)=>X1(Q.items,Z,`${Y}/${J}`,X)):W}function u6(Q,Z,Y,G){let W=globalThis.Object.values(Q.$defs),X=Q.$defs[Q.$ref],J=h(Q,Y,G);return X1(X,[...Z,...W],Y,J)}function l6(Q,Z,Y,G){let W=h(Q,Y,G);if(!s(G)||Q0(G))return W;let X=q0(Q),J=X.map((O)=>O[0]),H={...W};for(let[O,R1]of X)if(O in H)H[O]=X1(R1,Z,`${Y}/${O}`,H[O]);if(!x(Q.unevaluatedProperties))return H;let j=Object.getOwnPropertyNames(H),w=Q.unevaluatedProperties,A={...H};for(let O of j)if(!J.includes(O))A[O]=h(w,`${Y}/${O}`,A[O]);return A}function s6(Q,Z,Y,G){return h(Q.not,Y,h(Q,Y,G))}function r6(Q,Z,Y,G){let W=h(Q,Y,G);if(!s(W))return W;let X=j1(Q),J={...W};for(let A of X){if(!r1(J,A))continue;if(v(J[A])&&(!n1(Q.properties[A])||_.IsExactOptionalProperty(J,A)))continue;J[A]=X1(Q.properties[A],Z,`${Y}/${A}`,J[A])}if(!u(Q.additionalProperties))return J;let H=Object.getOwnPropertyNames(J),j=Q.additionalProperties,w={...J};for(let A of H)if(!X.includes(A))w[A]=h(j,`${Y}/${A}`,w[A]);return w}function a6(Q,Z,Y,G){let W=h(Q,Y,G);if(!s(G))return W;let X=Object.getOwnPropertyNames(Q.patternProperties)[0],J=new RegExp(X),H={...W};for(let O of Object.getOwnPropertyNames(G))if(J.test(O))H[O]=X1(Q.patternProperties[X],Z,`${Y}/${O}`,H[O]);if(!u(Q.additionalProperties))return H;let j=Object.getOwnPropertyNames(H),w=Q.additionalProperties,A={...H};for(let O of j)if(!J.test(O))A[O]=h(w,`${Y}/${O}`,A[O]);return A}function e6(Q,Z,Y,G){let W=i(Q,Z),X=X1(W,Z,Y,G);return h(Q,Y,X)}function QG(Q,Z,Y,G){let W=i(Q,Z),X=X1(W,Z,Y,G);return h(Q,Y,X)}function YG(Q,Z,Y,G){let W=h(Q,Y,G);return V(Q.items)?Q.items.map((X,J)=>X1(X,Z,`${Y}/${J}`,W[J])):[]}function ZG(Q,Z,Y,G){for(let W of Q.anyOf){if(!S1(W,Z,G))continue;let X=X1(W,Z,Y,G);return h(Q,Y,X)}for(let W of Q.anyOf){let X=X1(W,Z,Y,G);if(!S1(Q,Z,X))continue;return h(Q,Y,X)}return h(Q,Y,G)}function X1(Q,Z,Y,G){let W=w1(Q,Z),X=Q;switch(Q[B]){case"Array":return c6(X,W,Y,G);case"Import":return u6(X,W,Y,G);case"Intersect":return l6(X,W,Y,G);case"Not":return s6(X,W,Y,G);case"Object":return r6(X,W,Y,G);case"Record":return a6(X,W,Y,G);case"Ref":return e6(X,W,Y,G);case"This":return QG(X,W,Y,G);case"Tuple":return YG(X,W,Y,G);case"Union":return ZG(X,W,Y,G);default:return h(X,Y,G)}}function q8(Q,Z,Y){return X1(Q,Z,"",Y)}function GG(Q,Z){return x(Q)||d(Q.items,Z)}function WG(Q,Z){return x(Q)||d(Q.items,Z)}function XG(Q,Z){return x(Q)||d(Q.returns,Z)||Q.parameters.some((Y)=>d(Y,Z))}function $G(Q,Z){return x(Q)||d(Q.returns,Z)||Q.parameters.some((Y)=>d(Y,Z))}function zG(Q,Z){return x(Q)||x(Q.unevaluatedProperties)||Q.allOf.some((Y)=>d(Y,Z))}function JG(Q,Z){let Y=globalThis.Object.getOwnPropertyNames(Q.$defs).reduce((W,X)=>[...W,Q.$defs[X]],[]),G=Q.$defs[Q.$ref];return x(Q)||d(G,[...Y,...Z])}function qG(Q,Z){return x(Q)||d(Q.items,Z)}function HG(Q,Z){return x(Q)||d(Q.not,Z)}function LG(Q,Z){return x(Q)||Object.values(Q.properties).some((Y)=>d(Y,Z))||u(Q.additionalProperties)&&d(Q.additionalProperties,Z)}function MG(Q,Z){return x(Q)||d(Q.item,Z)}function UG(Q,Z){let Y=Object.getOwnPropertyNames(Q.patternProperties)[0],G=Q.patternProperties[Y];return x(Q)||d(G,Z)||u(Q.additionalProperties)&&x(Q.additionalProperties)}function RG(Q,Z){if(x(Q))return!0;return d(i(Q,Z),Z)}function AG(Q,Z){if(x(Q))return!0;return d(i(Q,Z),Z)}function BG(Q,Z){return x(Q)||!v(Q.items)&&Q.items.some((Y)=>d(Y,Z))}function jG(Q,Z){return x(Q)||Q.anyOf.some((Y)=>d(Y,Z))}function d(Q,Z){let Y=w1(Q,Z),G=Q;if(Q.$id&&S0.has(Q.$id))return!1;if(Q.$id)S0.add(Q.$id);switch(Q[B]){case"Array":return GG(G,Y);case"AsyncIterator":return WG(G,Y);case"Constructor":return XG(G,Y);case"Function":return $G(G,Y);case"Import":return JG(G,Y);case"Intersect":return zG(G,Y);case"Iterator":return qG(G,Y);case"Not":return HG(G,Y);case"Object":return LG(G,Y);case"Promise":return MG(G,Y);case"Record":return UG(G,Y);case"Ref":return RG(G,Y);case"This":return AG(G,Y);case"Tuple":return BG(G,Y);case"Union":return jG(G,Y);default:return x(Q)}}var S0=new Set;function H8(Q,Z){return S0.clear(),d(Q,Z)}class L8{constructor(Q,Z,Y,G){this.schema=Q,this.references=Z,this.checkFunc=Y,this.code=G,this.hasTransform=H8(Q,Z)}Code(){return this.code}Schema(){return this.schema}References(){return this.references}Errors(Q){return X8(this.schema,this.references,Q)}Check(Q){return this.checkFunc(Q)}Decode(Q){if(!this.checkFunc(Q))throw new P0(this.schema,Q,this.Errors(Q).First());return this.hasTransform?z8(this.schema,this.references,Q):Q}Encode(Q){let Z=this.hasTransform?q8(this.schema,this.references,Q):Q;if(!this.checkFunc(Z))throw new b0(this.schema,Q,this.Errors(Q).First());return Z}}var U1;(function(Q){function Z(X){return X===36}Q.DollarSign=Z;function Y(X){return X===95}Q.IsUnderscore=Y;function G(X){return X>=65&&X<=90||X>=97&&X<=122}Q.IsAlpha=G;function W(X){return X>=48&&X<=57}Q.IsNumeric=W})(U1||(U1={}));var H0;(function(Q){function Z(X){if(X.length===0)return!1;return U1.IsNumeric(X.charCodeAt(0))}function Y(X){if(Z(X))return!1;for(let J=0;J<X.length;J++){let H=X.charCodeAt(J);if(!(U1.IsAlpha(H)||U1.IsNumeric(H)||U1.DollarSign(H)||U1.IsUnderscore(H)))return!1}return!0}function G(X){return X.replace(/'/g,"\\'")}function W(X,J){return Y(J)?`${X}.${J}`:`${X}['${G(J)}']`}Q.Encode=W})(H0||(H0={}));var C0;(function(Q){function Z(Y){let G=[];for(let W=0;W<Y.length;W++){let X=Y.charCodeAt(W);if(U1.IsNumeric(X)||U1.IsAlpha(X))G.push(Y.charAt(W));else G.push(`_${X}_`)}return G.join("").replace(/__/g,"_")}Q.Encode=Z})(C0||(C0={}));var O0;(function(Q){function Z(Y){return Y.replace(/'/g,"\\'")}Q.Escape=Z})(O0||(O0={}));class M8 extends T{constructor(Q){super("Unknown type");this.schema=Q}}class F0 extends T{constructor(Q){super("Preflight validation check failed to guard for the given schema");this.schema=Q}}var C1;(function(Q){function Z(J,H,j){return _.ExactOptionalPropertyTypes?`('${H}' in ${J} ? ${j} : true)`:`(${H0.Encode(J,H)} !== undefined ? ${j} : true)`}Q.IsExactOptionalProperty=Z;function Y(J){return!_.AllowArrayObject?`(typeof ${J} === 'object' && ${J} !== null && !Array.isArray(${J}))`:`(typeof ${J} === 'object' && ${J} !== null)`}Q.IsObjectLike=Y;function G(J){return!_.AllowArrayObject?`(typeof ${J} === 'object' && ${J} !== null && !Array.isArray(${J}) && !(${J} instanceof Date) && !(${J} instanceof Uint8Array))`:`(typeof ${J} === 'object' && ${J} !== null && !(${J} instanceof Date) && !(${J} instanceof Uint8Array))`}Q.IsRecordLike=G;function W(J){return _.AllowNaN?`typeof ${J} === 'number'`:`Number.isFinite(${J})`}Q.IsNumberLike=W;function X(J){return _.AllowNullVoid?`(${J} === undefined || ${J} === null)`:`${J} === undefined`}Q.IsVoidLike=X})(C1||(C1={}));var L0;(function(Q){function Z($){return $[B]==="Any"||$[B]==="Unknown"}function*Y($,M,z){yield"true"}function*G($,M,z){yield"true"}function*W($,M,z){yield`Array.isArray(${z})`;let[D,U]=[v1("value","any"),v1("acc","number")];if(N($.maxItems))yield`${z}.length <= ${$.maxItems}`;if(N($.minItems))yield`${z}.length >= ${$.minItems}`;let R=Z1($.items,M,"value");if(yield`${z}.every((${D}) => ${R})`,E($.contains)||N($.minContains)||N($.maxContains)){let K=E($.contains)?$.contains:c(),l=Z1(K,M,"value"),q1=N($.minContains)?[`(count >= ${$.minContains})`]:[],G1=N($.maxContains)?[`(count <= ${$.maxContains})`]:[],$1=`const count = value.reduce((${U}, ${D}) => ${l} ? acc + 1 : acc, 0)`,c1=["(count > 0)",...q1,...G1].join(" && ");yield`((${D}) => { ${$1}; return ${c1}})(${z})`}if($.uniqueItems===!0)yield`((${D}) => { const set = new Set(); for(const element of value) { const hashed = hash(element); if(set.has(hashed)) { return false } else { set.add(hashed) } } return true } )(${z})`}function*X($,M,z){yield`(typeof value === 'object' && Symbol.asyncIterator in ${z})`}function*J($,M,z){if(yield`(typeof ${z} === 'bigint')`,a($.exclusiveMaximum))yield`${z} < BigInt(${$.exclusiveMaximum})`;if(a($.exclusiveMinimum))yield`${z} > BigInt(${$.exclusiveMinimum})`;if(a($.maximum))yield`${z} <= BigInt(${$.maximum})`;if(a($.minimum))yield`${z} >= BigInt(${$.minimum})`;if(a($.multipleOf))yield`(${z} % BigInt(${$.multipleOf})) === 0`}function*H($,M,z){yield`(typeof ${z} === 'boolean')`}function*j($,M,z){yield*O1($.returns,M,`${z}.prototype`)}function*w($,M,z){if(yield`(${z} instanceof Date) && Number.isFinite(${z}.getTime())`,N($.exclusiveMaximumTimestamp))yield`${z}.getTime() < ${$.exclusiveMaximumTimestamp}`;if(N($.exclusiveMinimumTimestamp))yield`${z}.getTime() > ${$.exclusiveMinimumTimestamp}`;if(N($.maximumTimestamp))yield`${z}.getTime() <= ${$.maximumTimestamp}`;if(N($.minimumTimestamp))yield`${z}.getTime() >= ${$.minimumTimestamp}`;if(N($.multipleOfTimestamp))yield`(${z}.getTime() % ${$.multipleOfTimestamp}) === 0`}function*A($,M,z){yield`(typeof ${z} === 'function')`}function*O($,M,z){let D=globalThis.Object.getOwnPropertyNames($.$defs).reduce((U,R)=>{return[...U,$.$defs[R]]},[]);yield*O1(t0($.$ref),[...M,...D],z)}function*R1($,M,z){if(yield`Number.isInteger(${z})`,N($.exclusiveMaximum))yield`${z} < ${$.exclusiveMaximum}`;if(N($.exclusiveMinimum))yield`${z} > ${$.exclusiveMinimum}`;if(N($.maximum))yield`${z} <= ${$.maximum}`;if(N($.minimum))yield`${z} >= ${$.minimum}`;if(N($.multipleOf))yield`(${z} % ${$.multipleOf}) === 0`}function*B8($,M,z){let D=$.allOf.map((U)=>Z1(U,M,z)).join(" && ");if($.unevaluatedProperties===!1){let U=F1(`${new RegExp(H1($))};`),R=`Object.getOwnPropertyNames(${z}).every(key => ${U}.test(key))`;yield`(${D} && ${R})`}else if(E($.unevaluatedProperties)){let U=F1(`${new RegExp(H1($))};`),R=`Object.getOwnPropertyNames(${z}).every(key => ${U}.test(key) || ${Z1($.unevaluatedProperties,M,`${z}[key]`)})`;yield`(${D} && ${R})`}else yield`(${D})`}function*j8($,M,z){yield`(typeof value === 'object' && Symbol.iterator in ${z})`}function*w8($,M,z){if(typeof $.const==="number"||typeof $.const==="boolean")yield`(${z} === ${$.const})`;else yield`(${z} === '${O0.Escape($.const)}')`}function*D8($,M,z){yield"false"}function*N8($,M,z){yield`(!${Z1($.not,M,z)})`}function*P8($,M,z){yield`(${z} === null)`}function*b8($,M,z){if(yield C1.IsNumberLike(z),N($.exclusiveMaximum))yield`${z} < ${$.exclusiveMaximum}`;if(N($.exclusiveMinimum))yield`${z} > ${$.exclusiveMinimum}`;if(N($.maximum))yield`${z} <= ${$.maximum}`;if(N($.minimum))yield`${z} >= ${$.minimum}`;if(N($.multipleOf))yield`(${z} % ${$.multipleOf}) === 0`}function*S8($,M,z){if(yield C1.IsObjectLike(z),N($.minProperties))yield`Object.getOwnPropertyNames(${z}).length >= ${$.minProperties}`;if(N($.maxProperties))yield`Object.getOwnPropertyNames(${z}).length <= ${$.maxProperties}`;let D=Object.getOwnPropertyNames($.properties);for(let U of D){let R=H0.Encode(z,U),K=$.properties[U];if($.required&&$.required.includes(U)){if(yield*O1(K,M,R),L1(K)||Z(K))yield`('${U}' in ${z})`}else{let l=Z1(K,M,R);yield C1.IsExactOptionalProperty(z,U,l)}}if($.additionalProperties===!1)if($.required&&$.required.length===D.length)yield`Object.getOwnPropertyNames(${z}).length === ${D.length}`;else{let U=`[${D.map((R)=>`'${R}'`).join(", ")}]`;yield`Object.getOwnPropertyNames(${z}).every(key => ${U}.includes(key))`}if(typeof $.additionalProperties==="object"){let U=Z1($.additionalProperties,M,`${z}[key]`),R=`[${D.map((K)=>`'${K}'`).join(", ")}]`;yield`(Object.getOwnPropertyNames(${z}).every(key => ${R}.includes(key) || ${U}))`}}function*C8($,M,z){yield`${z} instanceof Promise`}function*O8($,M,z){if(yield C1.IsRecordLike(z),N($.minProperties))yield`Object.getOwnPropertyNames(${z}).length >= ${$.minProperties}`;if(N($.maxProperties))yield`Object.getOwnPropertyNames(${z}).length <= ${$.maxProperties}`;let[D,U]=Object.entries($.patternProperties)[0],R=F1(`${new RegExp(D)}`),K=Z1(U,M,"value"),l=E($.additionalProperties)?Z1($.additionalProperties,M,z):$.additionalProperties===!1?"false":"true",q1=`(${R}.test(key) ? ${K} : ${l})`;yield`(Object.entries(${z}).every(([key, value]) => ${q1}))`}function*F8($,M,z){let D=i($,M);if(o.functions.has($.$ref))return yield`${t1($.$ref)}(${z})`;yield*O1(D,M,z)}function*x8($,M,z){let D=F1(`${new RegExp($.source,$.flags)};`);if(yield`(typeof ${z} === 'string')`,N($.maxLength))yield`${z}.length <= ${$.maxLength}`;if(N($.minLength))yield`${z}.length >= ${$.minLength}`;yield`${D}.test(${z})`}function*g8($,M,z){if(yield`(typeof ${z} === 'string')`,N($.maxLength))yield`${z}.length <= ${$.maxLength}`;if(N($.minLength))yield`${z}.length >= ${$.minLength}`;if($.pattern!==void 0)yield`${F1(`${new RegExp($.pattern)};`)}.test(${z})`;if($.format!==void 0)yield`format('${$.format}', ${z})`}function*K8($,M,z){yield`(typeof ${z} === 'symbol')`}function*_8($,M,z){yield`(typeof ${z} === 'string')`,yield`${F1(`${new RegExp($.pattern)};`)}.test(${z})`}function*E8($,M,z){yield`${t1($.$ref)}(${z})`}function*k8($,M,z){if(yield`Array.isArray(${z})`,$.items===void 0)return yield`${z}.length === 0`;yield`(${z}.length === ${$.maxItems})`;for(let D=0;D<$.items.length;D++)yield`${Z1($.items[D],M,`${z}[${D}]`)}`}function*V8($,M,z){yield`${z} === undefined`}function*T8($,M,z){yield`(${$.anyOf.map((U)=>Z1(U,M,z)).join(" || ")})`}function*I8($,M,z){if(yield`${z} instanceof Uint8Array`,N($.maxByteLength))yield`(${z}.length <= ${$.maxByteLength})`;if(N($.minByteLength))yield`(${z}.length >= ${$.minByteLength})`}function*d8($,M,z){yield"true"}function*f8($,M,z){yield C1.IsVoidLike(z)}function*i8($,M,z){let D=o.instances.size;o.instances.set(D,$),yield`kind('${$[B]}', ${D}, ${z})`}function*O1($,M,z,D=!0){let U=f($.$id)?[...M,$]:M,R=$;if(D&&f($.$id)){let K=t1($.$id);if(o.functions.has(K))return yield`${K}(${z})`;else{o.functions.set(K,"<deferred>");let l=x0(K,$,M,"value",!1);return o.functions.set(K,l),yield`${K}(${z})`}}switch(R[B]){case"Any":return yield*Y(R,U,z);case"Argument":return yield*G(R,U,z);case"Array":return yield*W(R,U,z);case"AsyncIterator":return yield*X(R,U,z);case"BigInt":return yield*J(R,U,z);case"Boolean":return yield*H(R,U,z);case"Constructor":return yield*j(R,U,z);case"Date":return yield*w(R,U,z);case"Function":return yield*A(R,U,z);case"Import":return yield*O(R,U,z);case"Integer":return yield*R1(R,U,z);case"Intersect":return yield*B8(R,U,z);case"Iterator":return yield*j8(R,U,z);case"Literal":return yield*w8(R,U,z);case"Never":return yield*D8(R,U,z);case"Not":return yield*N8(R,U,z);case"Null":return yield*P8(R,U,z);case"Number":return yield*b8(R,U,z);case"Object":return yield*S8(R,U,z);case"Promise":return yield*C8(R,U,z);case"Record":return yield*O8(R,U,z);case"Ref":return yield*F8(R,U,z);case"RegExp":return yield*x8(R,U,z);case"String":return yield*g8(R,U,z);case"Symbol":return yield*K8(R,U,z);case"TemplateLiteral":return yield*_8(R,U,z);case"This":return yield*E8(R,U,z);case"Tuple":return yield*k8(R,U,z);case"Undefined":return yield*V8(R,U,z);case"Union":return yield*T8(R,U,z);case"Uint8Array":return yield*I8(R,U,z);case"Unknown":return yield*d8(R,U,z);case"Void":return yield*f8(R,U,z);default:if(!r.Has(R[B]))throw new M8($);return yield*i8(R,U,z)}}let o={language:"javascript",functions:new Map,variables:new Map,instances:new Map};function Z1($,M,z,D=!0){return`(${[...O1($,M,z,D)].join(" && ")})`}function t1($){return`check_${C0.Encode($)}`}function F1($){let M=`local_${o.variables.size}`;return o.variables.set(M,`const ${M} = ${$}`),M}function x0($,M,z,D,U=!0){let[R,K]=[`
3
- `,($1)=>"".padStart($1," ")],l=v1("value","any"),q1=g0("boolean"),G1=[...O1(M,z,D,U)].map(($1)=>`${K(4)}${$1}`).join(` &&${R}`);return`function ${$}(${l})${q1} {${R}${K(2)}return (${R}${G1}${R}${K(2)})
4
- }`}function v1($,M){let z=o.language==="typescript"?`: ${M}`:"";return`${$}${z}`}function g0($){return o.language==="typescript"?`: ${$}`:""}function y8($,M,z){let D=x0("check",$,M,"value"),U=v1("value","any"),R=g0("boolean"),K=[...o.functions.values()],l=[...o.variables.values()],q1=f($.$id)?`return function check(${U})${R} {
5
- return ${t1($.$id)}(value)
6
- }`:`return ${D}`;return[...l,...K,q1].join(`
7
- `)}function K0(...$){let M={language:"javascript"},[z,D,U]=$.length===2&&V($[1])?[$[0],$[1],M]:$.length===2&&!V($[1])?[$[0],[],$[1]]:$.length===3?[$[0],$[1],$[2]]:$.length===1?[$[0],[],M]:[null,[],M];if(o.language=U.language,o.variables.clear(),o.functions.clear(),o.instances.clear(),!E(z))throw new F0(z);for(let R of D)if(!E(R))throw new F0(R);return y8(z,D,U)}Q.Code=K0;function p8($,M=[]){let z=K0($,M,{language:"javascript"}),D=globalThis.Function("kind","format","hash",z),U=new Map(o.instances);function R(G1,$1,c1){if(!r.Has(G1)||!U.has($1))return!1;let o8=r.Get(G1),n8=U.get($1);return o8(n8,c1)}function K(G1,$1){if(!Q1.Has(G1))return!1;return Q1.Get(G1)($1)}function l(G1){return d1(G1)}let q1=D(R,K,l);return new L8($,M,q1,z)}Q.Compile=p8})(L0||(L0={}));var f1=(Q,Z=400)=>new Response(JSON.stringify(Q),{status:Z,headers:{"Content-Type":"application/json"}}),wG=(Q)=>{let Z=L0.Compile(Q);return async(Y,G)=>{try{let W=await Y.req.json();if(!Z.Check(W)){let X=Z.Errors(W).First();return f1({status:"error",code:"VALIDATION_FAILED",message:X?.message||"Invalid input",path:X?.path||"body"})}return Y.body=W,G?G():void 0}catch{return f1({status:"error",message:"Invalid JSON payload"})}}},DG=(Q)=>{let Z=Q.properties||{},Y=Object.keys(Z),G=Y.length;return async(X,J)=>{try{let H=X instanceof Object&&"req"in X,w=await(H?X.req:X).json();for(let A=0;A<G;A++){let O=Y[A];if(typeof w[O]!==Z[O]?.type)return f1({status:"error",code:"TYPE_MISMATCH",message:`Field '${O}' must be of type ${Z[O]?.type}`,field:O})}if(H)X.body=w;return J?J():void 0}catch{return f1({status:"error",message:"Invalid JSON payload"})}}},NG=(Q)=>{return async(Y,G)=>{try{let W=Y instanceof Object&&"req"in Y,J=await(W?Y.req:Y).json(),H=Q.safeParse(J);if(!H.success)return f1({status:"error",code:"ZOD_ERROR",errors:H.error.format()});if(W)Y.body=H.data;return G?G():void 0}catch{return f1({status:"error",message:"Invalid JSON payload"})}}};class U8{routes=[];globalMiddlewares=[];_server=null;_reusePort=!0;wsHandler=null;router={GET:{},POST:{},PUT:{},PATCH:{},DELETE:{}};dynamicRoutes=[];poolIdx=0;pool;poolMask;defaultHandler=(Q)=>new Response("404 Not Found",{status:404});constructor(Q){let Z=Q?.poolSize||Number(process.env.BARE_POOL_SIZE)||1024;if((Z&Z-1)!==0)Z=Math.pow(2,Math.ceil(Math.log2(Z)));this.poolMask=Z-1,this.pool=Array.from({length:Z},()=>new M0)}get server(){return this._server}set server(Q){this._server=Q}use(Q){if(Q&&typeof Q==="object"&&"install"in Q)Q.install(this);else this.globalMiddlewares.push(Q);return this}compileHandler(Q,Z){let Y=[...Z,Q];return(G)=>{let W=-1,X=(H)=>{if(H<=W)throw Error("next() called multiple times");W=H;let j=Y[H];if(!j)return;return j.length>2?j(G.req,G.params,()=>X(H+1)):j(G,()=>X(H+1))},J=X(0);if(!(J instanceof Promise)){if(J&&J.constructor===Object)return Response.json(J,{status:G._status});return J}return J.then((H)=>{if(H&&H.constructor===Object)return Response.json(H,{status:G._status});return H})}}get=(Q,...Z)=>{return this.routes.push({method:"GET",path:Q,handlers:Z}),this};post=(Q,...Z)=>{return this.routes.push({method:"POST",path:Q,handlers:Z}),this};put=(Q,...Z)=>{return this.routes.push({method:"PUT",path:Q,handlers:Z}),this};patch=(Q,...Z)=>{return this.routes.push({method:"PATCH",path:Q,handlers:Z}),this};delete=(Q,...Z)=>{return this.routes.push({method:"DELETE",path:Q,handlers:Z}),this};ws=(Q,Z)=>{return this.wsHandler={path:Q,handlers:Z},this};fetch=(Q,Z)=>{let Y=Q.url,G=Y.indexOf("/",8),W=G===-1?"/":Y.slice(G),X=Q.method,J=this.router[X]?.[W];if(J)return J(this.pool[this.poolIdx++&this.poolMask].reset(Q,{}));for(let H=0,j=this.dynamicRoutes.length;H<j;H++){let w=this.dynamicRoutes[H];if(w.m===X&&w.r.test(W)){let A=w.r.exec(W),O=Object.create(null);for(let R1=0;R1<w.p.length;R1++)O[w.p[R1]]=A[R1+1];return w.c(this.pool[this.poolIdx++&this.poolMask].reset(Q,O))}}return this.defaultHandler(this.pool[this.poolIdx++&this.poolMask].reset(Q,{}))};compile(){for(let Q of this.routes){let Z=[...this.globalMiddlewares,...Q.handlers],Y=Z.pop(),G=Z,W=this.compileHandler(Y,G);if(Q.path.includes(":")){let X=[],J=Q.path.replace(/:([^/]+)/g,(H,j)=>{return X.push(j),"([^/]+)"});this.dynamicRoutes.push({m:Q.method,r:new RegExp(`^${J}$`),p:X,c:W})}else this.router[Q.method][Q.path]=W}this.defaultHandler=this.compileHandler((Q)=>new Response("404 Not Found",{status:404}),this.globalMiddlewares)}async listen(Q,Z){this.compile();let Y=Number(process.env.PORT)||3000,G=process.env.HOST||"0.0.0.0";if(typeof Q==="number")Y=Q;if(typeof Q==="string")G=Q;if(typeof Z==="number")Y=Z;let W={hostname:G,port:Y,reusePort:this._reusePort,fetch:(X,J)=>this.fetch(X,J)};if(this.wsHandler)W.websocket={open:(X)=>this.wsHandler?.handlers.open?.(X),message:(X,J)=>this.wsHandler?.handlers.message?.(X,J),close:(X,J,H)=>this.wsHandler?.handlers.close?.(X,J,H),drain:(X)=>this.wsHandler?.handlers.drain?.(X)};return this._server=Bun.serve(W),console.log(`[BAREJS] \uD83D\uDE80 Server running at http://${G}:${Y}`),this._server}}var PG=async(Q,Z,Y)=>{let G=performance.now(),W=new URL(Q.url).pathname,X=await Y?.(),J=(performance.now()-G).toFixed(2),H=X instanceof Response?X.status:200,j=H>=500?"\x1B[31m":H>=400?"\x1B[33m":"\x1B[32m";return console.log(` \x1B[90m${new Date().toLocaleTimeString()}\x1B[0m \x1B[1m\x1B[38;5;117m${Q.method.padEnd(7)}\x1B[0m \x1B[38;5;250m${W}\x1B[0m ${j}${H}\x1B[0m \x1B[90m(${J}ms)\x1B[0m`),X};var bG=(Q={})=>{let Z=Q.origin||"*",Y=Q.methods||"GET,POST,PUT,PATCH,DELETE,OPTIONS";return async(W,X,J)=>{if(W.method==="OPTIONS")return new Response(null,{status:204,headers:{"Access-Control-Allow-Origin":Z,"Access-Control-Allow-Methods":Y,"Access-Control-Allow-Headers":"Content-Type, Authorization"}});let H=await J?.();if(H instanceof Response)H.headers.set("Access-Control-Allow-Origin",Z),H.headers.set("Access-Control-Allow-Methods",Y);return H}};import{join as SG}from"path";var CG=(Q="public")=>{return async(Z,Y)=>{if(Z.req.method!=="GET"&&Z.req.method!=="HEAD")return Y();let G=new URL(Z.req.url),W=decodeURIComponent(G.pathname).replace(/^\//,""),X=SG(process.cwd(),Q,W),J=Bun.file(X);if(await J.exists())return new Response(J);return Y()}};var R8=new TextEncoder,A8=async(Q,Z)=>{let Y=Bun.crypto.hmac("sha256",Z,Q);return Buffer.from(Y).toString("hex")},OG=async(Q,Z,Y)=>{let G=await A8(Q,Y);return Bun.crypto.timingSafeEqual(R8.encode(Z),R8.encode(G))},FG=(Q)=>{return async(Z,Y)=>{let G=Z.req.headers.get("Authorization");if(!G?.startsWith("Bearer "))return Z.status(401).json({status:"error",message:"Bearer token required"});let W=G.split(" ")[1];if(!W)return Z.status(401).json({status:"error",message:"Invalid token format"});let X=W.split(".");if(X.length!==2)return Z.status(401).json({status:"error",message:"Malformed token"});let[J,H]=X;try{let j=Buffer.from(J,"base64").toString();if(!await OG(j,H,Q))return Z.status(401).json({status:"error",message:"Invalid signature"});return Z.set("user",JSON.parse(j)),Y()}catch(j){return Z.status(401).json({status:"error",message:"Token verification failed"})}}};var xG={hash:(Q)=>Bun.password.hash(Q,{algorithm:"argon2id"}),verify:(Q,Z)=>Bun.password.verify(Q,Z)},gG=async(Q,Z)=>{let Y=JSON.stringify(Q),G=Buffer.from(Y).toString("base64"),W=await A8(Y,Z);return`${G}.${W}`};export{NG as zod,wG as typebox,CG as staticFile,DG as native,PG as logger,gG as createToken,bG as cors,FG as bareAuth,xG as Password,U8 as BareJS};
2
+ var m8=Object.defineProperty;var i0=(Q,Z)=>{for(var Y in Z)m8(Q,Y,{get:Z[Y],enumerable:!0,configurable:!0,set:(G)=>Z[Y]=()=>G})};class N0{req;params;_status=200;store=Object.create(null);body=null;_headers={};_searchParams=null;_cookies=null;reset(Q,Z){this.req=Q,this.params=Z,this._status=200,this.body=null,this._headers={},this._searchParams=null,this._cookies=null;for(let Y in this.store)delete this.store[Y];return this}header(Q){return this.req.headers.get(Q)}query(Q){if(!this._searchParams)this._searchParams=new URL(this.req.url).searchParams;return this._searchParams.get(Q)}cookie(Q){if(!this._cookies){this._cookies=new Map;let Z=this.req.headers.get("cookie");if(Z){let Y=Z.matchAll(/([^=\s]+)=([^;]+)/g);for(let G of Y)if(G[1]&&G[2])this._cookies.set(G[1],G[2])}}return this._cookies.get(Q)}get ip(){return this.req.headers.get("x-forwarded-for")||null}status(Q){return this._status=Q,this}setHeader(Q,Z){return this._headers[Q.toLowerCase()]=Z,this}set(Q,Z){if(typeof Z==="string")return this._headers[Q.toLowerCase()]=Z,this;this.store[Q]=Z}get(Q){return this.store[Q]}setCookie(Q,Z,Y=""){return this.setHeader("set-cookie",`${Q}=${Z}; ${Y}`),this}json(Q){return this._headers["content-type"]="application/json",Q}text(Q){return this._headers["content-type"]="text/plain; charset=utf-8",Q}html(Q){return this._headers["content-type"]="text/html; charset=utf-8",Q}redirect(Q,Z=302){return this._status=Z,this.setHeader("location",Q),null}}function Y0(Q){return r(Q)&&globalThis.Symbol.asyncIterator in Q}function Z0(Q){return r(Q)&&globalThis.Symbol.iterator in Q}function G0(Q){return Q instanceof globalThis.Promise}function E1(Q){return Q instanceof Date&&globalThis.Number.isFinite(Q.getTime())}function V1(Q){return Q instanceof globalThis.Uint8Array}function W0(Q,Z){return Z in Q}function r(Q){return Q!==null&&typeof Q==="object"}function V(Q){return globalThis.Array.isArray(Q)&&!globalThis.ArrayBuffer.isView(Q)}function v(Q){return Q===void 0}function b1(Q){return Q===null}function S1(Q){return typeof Q==="boolean"}function D(Q){return typeof Q==="number"}function X0(Q){return globalThis.Number.isInteger(Q)}function e(Q){return typeof Q==="bigint"}function f(Q){return typeof Q==="string"}function $0(Q){return typeof Q==="function"}function C1(Q){return typeof Q==="symbol"}function z0(Q){return e(Q)||S1(Q)||b1(Q)||D(Q)||f(Q)||C1(Q)||v(Q)}var _;(function(Q){Q.InstanceMode="default",Q.ExactOptionalPropertyTypes=!1,Q.AllowArrayObject=!1,Q.AllowNaN=!1,Q.AllowNullVoid=!1;function Z(J,H){return Q.ExactOptionalPropertyTypes?H in J:J[H]!==void 0}Q.IsExactOptionalProperty=Z;function Y(J){let H=r(J);return Q.AllowArrayObject?H:H&&!V(J)}Q.IsObjectLike=Y;function G(J){return Y(J)&&!(J instanceof Date)&&!(J instanceof Uint8Array)}Q.IsRecordLike=G;function W(J){return Q.AllowNaN?D(J):Number.isFinite(J)}Q.IsNumberLike=W;function X(J){let H=v(J);return Q.AllowNullVoid?H||J===null:H}Q.IsVoidLike=X})(_||(_={}));var Y1={};i0(Y1,{Set:()=>u8,Has:()=>c8,Get:()=>l8,Entries:()=>h8,Delete:()=>v8,Clear:()=>t8});var T1=new Map;function h8(){return new Map(T1)}function t8(){return T1.clear()}function v8(Q){return T1.delete(Q)}function c8(Q){return T1.has(Q)}function u8(Q,Z){T1.set(Q,Z)}function l8(Q){return T1.get(Q)}var a={};i0(a,{Set:()=>QQ,Has:()=>e8,Get:()=>YQ,Entries:()=>s8,Delete:()=>a8,Clear:()=>r8});var I1=new Map;function s8(){return new Map(I1)}function r8(){return I1.clear()}function a8(Q){return I1.delete(Q)}function e8(Q){return I1.has(Q)}function QQ(Q,Z){I1.set(Q,Z)}function YQ(Q){return I1.get(Q)}function Z1(Q){return Array.isArray(Q)}function y0(Q){return typeof Q==="bigint"}function J0(Q){return typeof Q==="boolean"}function q0(Q){return Q instanceof globalThis.Date}function A1(Q){return typeof Q==="number"}function I(Q){return typeof Q==="object"&&Q!==null}function H0(Q){return Q instanceof globalThis.RegExp}function n(Q){return typeof Q==="string"}function L0(Q){return Q instanceof globalThis.Uint8Array}function J1(Q){return Q===void 0}function ZQ(Q){return globalThis.Object.freeze(Q).map((Z)=>m1(Z))}function GQ(Q){return Q}function WQ(Q){return Q}function XQ(Q){return Q}function $Q(Q){let Z={};for(let Y of Object.getOwnPropertyNames(Q))Z[Y]=m1(Q[Y]);for(let Y of Object.getOwnPropertySymbols(Q))Z[Y]=m1(Q[Y]);return globalThis.Object.freeze(Z)}function m1(Q){return Z1(Q)?ZQ(Q):q0(Q)?GQ(Q):L0(Q)?WQ(Q):H0(Q)?XQ(Q):I(Q)?$Q(Q):Q}function zQ(Q){return Q.map((Z)=>U0(Z))}function JQ(Q){return new Date(Q.getTime())}function qQ(Q){return new Uint8Array(Q)}function HQ(Q){return new RegExp(Q.source,Q.flags)}function LQ(Q){let Z={};for(let Y of Object.getOwnPropertyNames(Q))Z[Y]=U0(Q[Y]);for(let Y of Object.getOwnPropertySymbols(Q))Z[Y]=U0(Q[Y]);return Z}function U0(Q){return Z1(Q)?zQ(Q):q0(Q)?JQ(Q):L0(Q)?qQ(Q):H0(Q)?HQ(Q):I(Q)?LQ(Q):Q}function p0(Q){return U0(Q)}function m(Q,Z){let Y=Z!==void 0?{...Z,...Q}:Q;switch(_.InstanceMode){case"freeze":return m1(Y);case"clone":return p0(Y);default:return Y}}var B1=Symbol.for("TypeBox.Transform");var q1=Symbol.for("TypeBox.Optional");var B=Symbol.for("TypeBox.Kind");class T extends Error{constructor(Q){super(Q)}}function o0(Q){return m({[B]:"MappedResult",properties:Q})}function MQ(Q,Z){let{[Z]:Y,...G}=Q;return G}function d1(Q,Z){return Z.reduce((Y,G)=>MQ(Y,G),Q)}function c(Q){return m({[B]:"Never",not:{}},Q)}function f1(Q){return I(Q)&&Q[q1]==="Optional"}function AQ(Q){return S(Q,"Any")}function BQ(Q){return S(Q,"Argument")}function h1(Q){return S(Q,"Array")}function wQ(Q){return S(Q,"AsyncIterator")}function jQ(Q){return S(Q,"BigInt")}function DQ(Q){return S(Q,"Boolean")}function NQ(Q){return S(Q,"Computed")}function PQ(Q){return S(Q,"Constructor")}function bQ(Q){return S(Q,"Date")}function SQ(Q){return S(Q,"Function")}function CQ(Q){return S(Q,"Integer")}function t1(Q){return S(Q,"Intersect")}function OQ(Q){return S(Q,"Iterator")}function S(Q,Z){return I(Q)&&B in Q&&Q[B]===Z}function FQ(Q){return S(Q,"Literal")}function n0(Q){return S(Q,"MappedKey")}function R0(Q){return S(Q,"MappedResult")}function A0(Q){return S(Q,"Never")}function xQ(Q){return S(Q,"Not")}function gQ(Q){return S(Q,"Null")}function KQ(Q){return S(Q,"Number")}function O1(Q){return S(Q,"Object")}function _Q(Q){return S(Q,"Promise")}function P0(Q){return S(Q,"Record")}function m0(Q){return S(Q,"Ref")}function kQ(Q){return S(Q,"RegExp")}function EQ(Q){return S(Q,"String")}function VQ(Q){return S(Q,"Symbol")}function TQ(Q){return S(Q,"TemplateLiteral")}function IQ(Q){return S(Q,"This")}function x(Q){return I(Q)&&B1 in Q}function v1(Q){return S(Q,"Tuple")}function c1(Q){return S(Q,"Undefined")}function u1(Q){return S(Q,"Union")}function dQ(Q){return S(Q,"Uint8Array")}function fQ(Q){return S(Q,"Unknown")}function iQ(Q){return S(Q,"Unsafe")}function yQ(Q){return S(Q,"Void")}function pQ(Q){return I(Q)&&B in Q&&n(Q[B])}function u(Q){return AQ(Q)||BQ(Q)||h1(Q)||DQ(Q)||jQ(Q)||wQ(Q)||NQ(Q)||PQ(Q)||bQ(Q)||SQ(Q)||CQ(Q)||t1(Q)||OQ(Q)||FQ(Q)||n0(Q)||R0(Q)||A0(Q)||xQ(Q)||gQ(Q)||KQ(Q)||O1(Q)||_Q(Q)||P0(Q)||m0(Q)||kQ(Q)||EQ(Q)||VQ(Q)||TQ(Q)||IQ(Q)||v1(Q)||c1(Q)||u1(Q)||dQ(Q)||fQ(Q)||iQ(Q)||yQ(Q)||pQ(Q)}function oQ(Q){return m(d1(Q,[q1]))}function nQ(Q){return m({...Q,[q1]:"Optional"})}function mQ(Q,Z){return Z===!1?oQ(Q):nQ(Q)}function i1(Q,Z){let Y=Z??!0;return R0(Q)?h0(Q,Y):mQ(Q,Y)}function hQ(Q,Z){let Y={};for(let G of globalThis.Object.getOwnPropertyNames(Q))Y[G]=i1(Q[G],Z);return Y}function tQ(Q,Z){return hQ(Q.properties,Z)}function h0(Q,Z){let Y=tQ(Q,Z);return o0(Y)}function b0(Q,Z={}){let Y=Q.every((W)=>O1(W)),G=u(Z.unevaluatedProperties)?{unevaluatedProperties:Z.unevaluatedProperties}:{};return m(Z.unevaluatedProperties===!1||u(Z.unevaluatedProperties)||Y?{...G,[B]:"Intersect",type:"object",allOf:Q}:{...G,[B]:"Intersect",allOf:Q},Z)}function vQ(Q){return Q.every((Z)=>f1(Z))}function cQ(Q){return d1(Q,[q1])}function t0(Q){return Q.map((Z)=>f1(Z)?cQ(Z):Z)}function uQ(Q,Z){return vQ(Q)?i1(b0(t0(Q),Z)):b0(t0(Q),Z)}function v0(Q,Z={}){if(Q.length===1)return m(Q[0],Z);if(Q.length===0)return c(Z);if(Q.some((Y)=>x(Y)))throw Error("Cannot intersect transform types");return uQ(Q,Z)}function S0(Q,Z){return m({[B]:"Union",anyOf:Q},Z)}function lQ(Q){return Q.some((Z)=>f1(Z))}function c0(Q){return Q.map((Z)=>f1(Z)?sQ(Z):Z)}function sQ(Q){return d1(Q,[q1])}function rQ(Q,Z){return lQ(Q)?i1(S0(c0(Q),Z)):S0(c0(Q),Z)}function C0(Q,Z){return Q.length===1?m(Q[0],Z):Q.length===0?c(Z):rQ(Q,Z)}function u0(Q,Z){return Q.map((Y)=>l0(Y,Z))}function aQ(Q){return Q.filter((Z)=>!A0(Z))}function eQ(Q,Z){return v0(aQ(u0(Q,Z)))}function QY(Q){return Q.some((Z)=>A0(Z))?[]:Q}function YY(Q,Z){return C0(QY(u0(Q,Z)))}function ZY(Q,Z){return Z in Q?Q[Z]:Z==="[number]"?C0(Q):c()}function GY(Q,Z){return Z==="[number]"?Q:c()}function WY(Q,Z){return Z in Q?Q[Z]:c()}function l0(Q,Z){return t1(Q)?eQ(Q.allOf,Z):u1(Q)?YY(Q.anyOf,Z):v1(Q)?ZY(Q.items??[],Z):h1(Q)?GY(Q.items,Z):O1(Q)?WY(Q.properties,Z):c()}function s0(Q,Z){return Z.map((Y)=>l0(Q,Y))}function XY(Q,Z){return Q.filter((Y)=>Z.includes(Y))}function $Y(Q,Z){return Q.reduce((Y,G)=>{return XY(Y,G)},Z)}function r0(Q){return Q.length===1?Q[0]:Q.length>1?$Y(Q.slice(1),Q[0]):[]}function a0(Q){let Z=[];for(let Y of Q)Z.push(...Y);return Z}function e0(...Q){let[Z,Y]=typeof Q[0]==="string"?[Q[0],Q[1]]:[Q[0].$id,Q[1]];if(typeof Z!=="string")throw new T("Ref: $ref must be a string");return m({[B]:"Ref",$ref:Z},Y)}function Q8(Q){let Z=[];for(let Y of Q)Z.push(w1(Y));return Z}function zY(Q){let Z=Q8(Q);return a0(Z)}function JY(Q){let Z=Q8(Q);return r0(Z)}function qY(Q){return Q.map((Z,Y)=>Y.toString())}function HY(Q){return["[number]"]}function LY(Q){return globalThis.Object.getOwnPropertyNames(Q)}function MY(Q){if(!O0)return[];return globalThis.Object.getOwnPropertyNames(Q).map((Y)=>{return Y[0]==="^"&&Y[Y.length-1]==="$"?Y.slice(1,Y.length-1):Y})}function w1(Q){return t1(Q)?zY(Q.allOf):u1(Q)?JY(Q.anyOf):v1(Q)?qY(Q.items??[]):h1(Q)?HY(Q.items):O1(Q)?LY(Q.properties):P0(Q)?MY(Q.patternProperties):[]}var O0=!1;function L1(Q){O0=!0;let Z=w1(Q);return O0=!1,`^(${Z.map((G)=>`(${G})`).join("|")})$`}function B0(Q){let Z=w1(Q),Y=s0(Q,Z);return Z.map((G,W)=>[Z[W],Y[W]])}function UY(Q){return Q.allOf.every((Z)=>M1(Z))}function RY(Q){return Q.anyOf.some((Z)=>M1(Z))}function AY(Q){return!M1(Q.not)}function M1(Q){return Q[B]==="Intersect"?UY(Q):Q[B]==="Union"?RY(Q):Q[B]==="Not"?AY(Q):Q[B]==="Undefined"?!0:!1}function BY(Q){switch(Q.errorType){case q.ArrayContains:return"Expected array to contain at least one matching value";case q.ArrayMaxContains:return`Expected array to contain no more than ${Q.schema.maxContains} matching values`;case q.ArrayMinContains:return`Expected array to contain at least ${Q.schema.minContains} matching values`;case q.ArrayMaxItems:return`Expected array length to be less or equal to ${Q.schema.maxItems}`;case q.ArrayMinItems:return`Expected array length to be greater or equal to ${Q.schema.minItems}`;case q.ArrayUniqueItems:return"Expected array elements to be unique";case q.Array:return"Expected array";case q.AsyncIterator:return"Expected AsyncIterator";case q.BigIntExclusiveMaximum:return`Expected bigint to be less than ${Q.schema.exclusiveMaximum}`;case q.BigIntExclusiveMinimum:return`Expected bigint to be greater than ${Q.schema.exclusiveMinimum}`;case q.BigIntMaximum:return`Expected bigint to be less or equal to ${Q.schema.maximum}`;case q.BigIntMinimum:return`Expected bigint to be greater or equal to ${Q.schema.minimum}`;case q.BigIntMultipleOf:return`Expected bigint to be a multiple of ${Q.schema.multipleOf}`;case q.BigInt:return"Expected bigint";case q.Boolean:return"Expected boolean";case q.DateExclusiveMinimumTimestamp:return`Expected Date timestamp to be greater than ${Q.schema.exclusiveMinimumTimestamp}`;case q.DateExclusiveMaximumTimestamp:return`Expected Date timestamp to be less than ${Q.schema.exclusiveMaximumTimestamp}`;case q.DateMinimumTimestamp:return`Expected Date timestamp to be greater or equal to ${Q.schema.minimumTimestamp}`;case q.DateMaximumTimestamp:return`Expected Date timestamp to be less or equal to ${Q.schema.maximumTimestamp}`;case q.DateMultipleOfTimestamp:return`Expected Date timestamp to be a multiple of ${Q.schema.multipleOfTimestamp}`;case q.Date:return"Expected Date";case q.Function:return"Expected function";case q.IntegerExclusiveMaximum:return`Expected integer to be less than ${Q.schema.exclusiveMaximum}`;case q.IntegerExclusiveMinimum:return`Expected integer to be greater than ${Q.schema.exclusiveMinimum}`;case q.IntegerMaximum:return`Expected integer to be less or equal to ${Q.schema.maximum}`;case q.IntegerMinimum:return`Expected integer to be greater or equal to ${Q.schema.minimum}`;case q.IntegerMultipleOf:return`Expected integer to be a multiple of ${Q.schema.multipleOf}`;case q.Integer:return"Expected integer";case q.IntersectUnevaluatedProperties:return"Unexpected property";case q.Intersect:return"Expected all values to match";case q.Iterator:return"Expected Iterator";case q.Literal:return`Expected ${typeof Q.schema.const==="string"?`'${Q.schema.const}'`:Q.schema.const}`;case q.Never:return"Never";case q.Not:return"Value should not match";case q.Null:return"Expected null";case q.NumberExclusiveMaximum:return`Expected number to be less than ${Q.schema.exclusiveMaximum}`;case q.NumberExclusiveMinimum:return`Expected number to be greater than ${Q.schema.exclusiveMinimum}`;case q.NumberMaximum:return`Expected number to be less or equal to ${Q.schema.maximum}`;case q.NumberMinimum:return`Expected number to be greater or equal to ${Q.schema.minimum}`;case q.NumberMultipleOf:return`Expected number to be a multiple of ${Q.schema.multipleOf}`;case q.Number:return"Expected number";case q.Object:return"Expected object";case q.ObjectAdditionalProperties:return"Unexpected property";case q.ObjectMaxProperties:return`Expected object to have no more than ${Q.schema.maxProperties} properties`;case q.ObjectMinProperties:return`Expected object to have at least ${Q.schema.minProperties} properties`;case q.ObjectRequiredProperty:return"Expected required property";case q.Promise:return"Expected Promise";case q.RegExp:return"Expected string to match regular expression";case q.StringFormatUnknown:return`Unknown format '${Q.schema.format}'`;case q.StringFormat:return`Expected string to match '${Q.schema.format}' format`;case q.StringMaxLength:return`Expected string length less or equal to ${Q.schema.maxLength}`;case q.StringMinLength:return`Expected string length greater or equal to ${Q.schema.minLength}`;case q.StringPattern:return`Expected string to match '${Q.schema.pattern}'`;case q.String:return"Expected string";case q.Symbol:return"Expected symbol";case q.TupleLength:return`Expected tuple to have ${Q.schema.maxItems||0} elements`;case q.Tuple:return"Expected tuple";case q.Uint8ArrayMaxByteLength:return`Expected byte length less or equal to ${Q.schema.maxByteLength}`;case q.Uint8ArrayMinByteLength:return`Expected byte length greater or equal to ${Q.schema.minByteLength}`;case q.Uint8Array:return"Expected Uint8Array";case q.Undefined:return"Expected undefined";case q.Union:return"Expected union value";case q.Void:return"Expected void";case q.Kind:return`Expected kind '${Q.schema[B]}'`;default:return"Unknown error type"}}var wY=BY;function Y8(){return wY}class Z8 extends T{constructor(Q){super(`Unable to dereference schema with $id '${Q.$ref}'`);this.schema=Q}}function jY(Q,Z){let Y=Z.find((G)=>G.$id===Q.$ref);if(Y===void 0)throw new Z8(Q);return i(Y,Z)}function j1(Q,Z){if(!f(Q.$id)||Z.some((Y)=>Y.$id===Q.$id))return Z;return Z.push(Q),Z}function i(Q,Z){return Q[B]==="This"||Q[B]==="Ref"?jY(Q,Z):Q}class G8 extends T{constructor(Q){super("Unable to hash value");this.value=Q}}var Q1;(function(Q){Q[Q.Undefined=0]="Undefined",Q[Q.Null=1]="Null",Q[Q.Boolean=2]="Boolean",Q[Q.Number=3]="Number",Q[Q.String=4]="String",Q[Q.Object=5]="Object",Q[Q.Array=6]="Array",Q[Q.Date=7]="Date",Q[Q.Uint8Array=8]="Uint8Array",Q[Q.Symbol=9]="Symbol",Q[Q.BigInt=10]="BigInt"})(Q1||(Q1={}));var y1=BigInt("14695981039346656037"),[DY,NY]=[BigInt("1099511628211"),BigInt("18446744073709551616")],PY=Array.from({length:256}).map((Q,Z)=>BigInt(Z)),W8=new Float64Array(1),X8=new DataView(W8.buffer),$8=new Uint8Array(W8.buffer);function*bY(Q){let Z=Q===0?1:Math.ceil(Math.floor(Math.log2(Q)+1)/8);for(let Y=0;Y<Z;Y++)yield Q>>8*(Z-1-Y)&255}function SY(Q){t(Q1.Array);for(let Z of Q)p1(Z)}function CY(Q){t(Q1.Boolean),t(Q?1:0)}function OY(Q){t(Q1.BigInt),X8.setBigInt64(0,Q);for(let Z of $8)t(Z)}function FY(Q){t(Q1.Date),p1(Q.getTime())}function xY(Q){t(Q1.Null)}function gY(Q){t(Q1.Number),X8.setFloat64(0,Q);for(let Z of $8)t(Z)}function KY(Q){t(Q1.Object);for(let Z of globalThis.Object.getOwnPropertyNames(Q).sort())p1(Z),p1(Q[Z])}function _Y(Q){t(Q1.String);for(let Z=0;Z<Q.length;Z++)for(let Y of bY(Q.charCodeAt(Z)))t(Y)}function kY(Q){t(Q1.Symbol),p1(Q.description)}function EY(Q){t(Q1.Uint8Array);for(let Z=0;Z<Q.length;Z++)t(Q[Z])}function VY(Q){return t(Q1.Undefined)}function p1(Q){if(V(Q))return SY(Q);if(S1(Q))return CY(Q);if(e(Q))return OY(Q);if(E1(Q))return FY(Q);if(b1(Q))return xY(Q);if(D(Q))return gY(Q);if(r(Q))return KY(Q);if(f(Q))return _Y(Q);if(C1(Q))return kY(Q);if(V1(Q))return EY(Q);if(v(Q))return VY(Q);throw new G8(Q)}function t(Q){y1=y1^PY[Q],y1=y1*DY%NY}function o1(Q){return y1=BigInt("14695981039346656037"),p1(Q),y1}var TY=["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 z8(Q){try{return new RegExp(Q),!0}catch{return!1}}function F0(Q){if(!n(Q))return!1;for(let Z=0;Z<Q.length;Z++){let Y=Q.charCodeAt(Z);if(Y>=7&&Y<=13||Y===27||Y===127)return!1}return!0}function J8(Q){return x0(Q)||k(Q)}function l1(Q){return J1(Q)||y0(Q)}function g(Q){return J1(Q)||A1(Q)}function x0(Q){return J1(Q)||J0(Q)}function F(Q){return J1(Q)||n(Q)}function IY(Q){return J1(Q)||n(Q)&&F0(Q)&&z8(Q)}function dY(Q){return J1(Q)||n(Q)&&F0(Q)}function q8(Q){return J1(Q)||k(Q)}function fY(Q){return C(Q,"Any")&&F(Q.$id)}function iY(Q){return C(Q,"Argument")&&A1(Q.index)}function yY(Q){return C(Q,"Array")&&Q.type==="array"&&F(Q.$id)&&k(Q.items)&&g(Q.minItems)&&g(Q.maxItems)&&x0(Q.uniqueItems)&&q8(Q.contains)&&g(Q.minContains)&&g(Q.maxContains)}function pY(Q){return C(Q,"AsyncIterator")&&Q.type==="AsyncIterator"&&F(Q.$id)&&k(Q.items)}function oY(Q){return C(Q,"BigInt")&&Q.type==="bigint"&&F(Q.$id)&&l1(Q.exclusiveMaximum)&&l1(Q.exclusiveMinimum)&&l1(Q.maximum)&&l1(Q.minimum)&&l1(Q.multipleOf)}function nY(Q){return C(Q,"Boolean")&&Q.type==="boolean"&&F(Q.$id)}function mY(Q){return C(Q,"Computed")&&n(Q.target)&&Z1(Q.parameters)&&Q.parameters.every((Z)=>k(Z))}function hY(Q){return C(Q,"Constructor")&&Q.type==="Constructor"&&F(Q.$id)&&Z1(Q.parameters)&&Q.parameters.every((Z)=>k(Z))&&k(Q.returns)}function tY(Q){return C(Q,"Date")&&Q.type==="Date"&&F(Q.$id)&&g(Q.exclusiveMaximumTimestamp)&&g(Q.exclusiveMinimumTimestamp)&&g(Q.maximumTimestamp)&&g(Q.minimumTimestamp)&&g(Q.multipleOfTimestamp)}function vY(Q){return C(Q,"Function")&&Q.type==="Function"&&F(Q.$id)&&Z1(Q.parameters)&&Q.parameters.every((Z)=>k(Z))&&k(Q.returns)}function cY(Q){return C(Q,"Integer")&&Q.type==="integer"&&F(Q.$id)&&g(Q.exclusiveMaximum)&&g(Q.exclusiveMinimum)&&g(Q.maximum)&&g(Q.minimum)&&g(Q.multipleOf)}function H8(Q){return I(Q)&&Object.entries(Q).every(([Z,Y])=>F0(Z)&&k(Y))}function uY(Q){return C(Q,"Intersect")&&(n(Q.type)&&Q.type!=="object"?!1:!0)&&Z1(Q.allOf)&&Q.allOf.every((Z)=>k(Z)&&!U4(Z))&&F(Q.type)&&(x0(Q.unevaluatedProperties)||q8(Q.unevaluatedProperties))&&F(Q.$id)}function lY(Q){return C(Q,"Iterator")&&Q.type==="Iterator"&&F(Q.$id)&&k(Q.items)}function C(Q,Z){return I(Q)&&B in Q&&Q[B]===Z}function sY(Q){return C(Q,"Literal")&&F(Q.$id)&&rY(Q.const)}function rY(Q){return J0(Q)||A1(Q)||n(Q)}function aY(Q){return C(Q,"MappedKey")&&Z1(Q.keys)&&Q.keys.every((Z)=>A1(Z)||n(Z))}function eY(Q){return C(Q,"MappedResult")&&H8(Q.properties)}function Q4(Q){return C(Q,"Never")&&I(Q.not)&&Object.getOwnPropertyNames(Q.not).length===0}function Y4(Q){return C(Q,"Not")&&k(Q.not)}function Z4(Q){return C(Q,"Null")&&Q.type==="null"&&F(Q.$id)}function G4(Q){return C(Q,"Number")&&Q.type==="number"&&F(Q.$id)&&g(Q.exclusiveMaximum)&&g(Q.exclusiveMinimum)&&g(Q.maximum)&&g(Q.minimum)&&g(Q.multipleOf)}function W4(Q){return C(Q,"Object")&&Q.type==="object"&&F(Q.$id)&&H8(Q.properties)&&J8(Q.additionalProperties)&&g(Q.minProperties)&&g(Q.maxProperties)}function X4(Q){return C(Q,"Promise")&&Q.type==="Promise"&&F(Q.$id)&&k(Q.item)}function $4(Q){return C(Q,"Record")&&Q.type==="object"&&F(Q.$id)&&J8(Q.additionalProperties)&&I(Q.patternProperties)&&((Z)=>{let Y=Object.getOwnPropertyNames(Z.patternProperties);return Y.length===1&&z8(Y[0])&&I(Z.patternProperties)&&k(Z.patternProperties[Y[0]])})(Q)}function z4(Q){return C(Q,"Ref")&&F(Q.$id)&&n(Q.$ref)}function J4(Q){return C(Q,"RegExp")&&F(Q.$id)&&n(Q.source)&&n(Q.flags)&&g(Q.maxLength)&&g(Q.minLength)}function q4(Q){return C(Q,"String")&&Q.type==="string"&&F(Q.$id)&&g(Q.minLength)&&g(Q.maxLength)&&IY(Q.pattern)&&dY(Q.format)}function H4(Q){return C(Q,"Symbol")&&Q.type==="symbol"&&F(Q.$id)}function L4(Q){return C(Q,"TemplateLiteral")&&Q.type==="string"&&n(Q.pattern)&&Q.pattern[0]==="^"&&Q.pattern[Q.pattern.length-1]==="$"}function M4(Q){return C(Q,"This")&&F(Q.$id)&&n(Q.$ref)}function U4(Q){return I(Q)&&B1 in Q}function R4(Q){return C(Q,"Tuple")&&Q.type==="array"&&F(Q.$id)&&A1(Q.minItems)&&A1(Q.maxItems)&&Q.minItems===Q.maxItems&&(J1(Q.items)&&J1(Q.additionalItems)&&Q.minItems===0||Z1(Q.items)&&Q.items.every((Z)=>k(Z)))}function A4(Q){return C(Q,"Undefined")&&Q.type==="undefined"&&F(Q.$id)}function B4(Q){return C(Q,"Union")&&F(Q.$id)&&I(Q)&&Z1(Q.anyOf)&&Q.anyOf.every((Z)=>k(Z))}function w4(Q){return C(Q,"Uint8Array")&&Q.type==="Uint8Array"&&F(Q.$id)&&g(Q.minByteLength)&&g(Q.maxByteLength)}function j4(Q){return C(Q,"Unknown")&&F(Q.$id)}function D4(Q){return C(Q,"Unsafe")}function N4(Q){return C(Q,"Void")&&Q.type==="void"&&F(Q.$id)}function P4(Q){return I(Q)&&B in Q&&n(Q[B])&&!TY.includes(Q[B])}function k(Q){return I(Q)&&(fY(Q)||iY(Q)||yY(Q)||nY(Q)||oY(Q)||pY(Q)||mY(Q)||hY(Q)||tY(Q)||vY(Q)||cY(Q)||uY(Q)||lY(Q)||sY(Q)||aY(Q)||eY(Q)||Q4(Q)||Y4(Q)||Z4(Q)||G4(Q)||W4(Q)||X4(Q)||$4(Q)||z4(Q)||J4(Q)||q4(Q)||H4(Q)||L4(Q)||M4(Q)||R4(Q)||A4(Q)||B4(Q)||w4(Q)||j4(Q)||D4(Q)||N4(Q)||P4(Q))}class L8 extends T{constructor(Q){super("Unknown type");this.schema=Q}}function b4(Q){return Q[B]==="Any"||Q[B]==="Unknown"}function P(Q){return Q!==void 0}function S4(Q,Z,Y){return!0}function C4(Q,Z,Y){return!0}function O4(Q,Z,Y){if(!V(Y))return!1;if(P(Q.minItems)&&!(Y.length>=Q.minItems))return!1;if(P(Q.maxItems)&&!(Y.length<=Q.maxItems))return!1;if(!Y.every((X)=>y(Q.items,Z,X)))return!1;if(Q.uniqueItems===!0&&!function(){let X=new Set;for(let J of Y){let H=o1(J);if(X.has(H))return!1;else X.add(H)}return!0}())return!1;if(!(P(Q.contains)||D(Q.minContains)||D(Q.maxContains)))return!0;let G=P(Q.contains)?Q.contains:c(),W=Y.reduce((X,J)=>y(G,Z,J)?X+1:X,0);if(W===0)return!1;if(D(Q.minContains)&&W<Q.minContains)return!1;if(D(Q.maxContains)&&W>Q.maxContains)return!1;return!0}function F4(Q,Z,Y){return Y0(Y)}function x4(Q,Z,Y){if(!e(Y))return!1;if(P(Q.exclusiveMaximum)&&!(Y<Q.exclusiveMaximum))return!1;if(P(Q.exclusiveMinimum)&&!(Y>Q.exclusiveMinimum))return!1;if(P(Q.maximum)&&!(Y<=Q.maximum))return!1;if(P(Q.minimum)&&!(Y>=Q.minimum))return!1;if(P(Q.multipleOf)&&Y%Q.multipleOf!==BigInt(0))return!1;return!0}function g4(Q,Z,Y){return S1(Y)}function K4(Q,Z,Y){return y(Q.returns,Z,Y.prototype)}function _4(Q,Z,Y){if(!E1(Y))return!1;if(P(Q.exclusiveMaximumTimestamp)&&!(Y.getTime()<Q.exclusiveMaximumTimestamp))return!1;if(P(Q.exclusiveMinimumTimestamp)&&!(Y.getTime()>Q.exclusiveMinimumTimestamp))return!1;if(P(Q.maximumTimestamp)&&!(Y.getTime()<=Q.maximumTimestamp))return!1;if(P(Q.minimumTimestamp)&&!(Y.getTime()>=Q.minimumTimestamp))return!1;if(P(Q.multipleOfTimestamp)&&Y.getTime()%Q.multipleOfTimestamp!==0)return!1;return!0}function k4(Q,Z,Y){return $0(Y)}function E4(Q,Z,Y){let G=globalThis.Object.values(Q.$defs),W=Q.$defs[Q.$ref];return y(W,[...Z,...G],Y)}function V4(Q,Z,Y){if(!X0(Y))return!1;if(P(Q.exclusiveMaximum)&&!(Y<Q.exclusiveMaximum))return!1;if(P(Q.exclusiveMinimum)&&!(Y>Q.exclusiveMinimum))return!1;if(P(Q.maximum)&&!(Y<=Q.maximum))return!1;if(P(Q.minimum)&&!(Y>=Q.minimum))return!1;if(P(Q.multipleOf)&&Y%Q.multipleOf!==0)return!1;return!0}function T4(Q,Z,Y){let G=Q.allOf.every((W)=>y(W,Z,Y));if(Q.unevaluatedProperties===!1){let W=new RegExp(L1(Q)),X=Object.getOwnPropertyNames(Y).every((J)=>W.test(J));return G&&X}else if(u(Q.unevaluatedProperties)){let W=new RegExp(L1(Q)),X=Object.getOwnPropertyNames(Y).every((J)=>W.test(J)||y(Q.unevaluatedProperties,Z,Y[J]));return G&&X}else return G}function I4(Q,Z,Y){return Z0(Y)}function d4(Q,Z,Y){return Y===Q.const}function f4(Q,Z,Y){return!1}function i4(Q,Z,Y){return!y(Q.not,Z,Y)}function y4(Q,Z,Y){return b1(Y)}function p4(Q,Z,Y){if(!_.IsNumberLike(Y))return!1;if(P(Q.exclusiveMaximum)&&!(Y<Q.exclusiveMaximum))return!1;if(P(Q.exclusiveMinimum)&&!(Y>Q.exclusiveMinimum))return!1;if(P(Q.minimum)&&!(Y>=Q.minimum))return!1;if(P(Q.maximum)&&!(Y<=Q.maximum))return!1;if(P(Q.multipleOf)&&Y%Q.multipleOf!==0)return!1;return!0}function o4(Q,Z,Y){if(!_.IsObjectLike(Y))return!1;if(P(Q.minProperties)&&!(Object.getOwnPropertyNames(Y).length>=Q.minProperties))return!1;if(P(Q.maxProperties)&&!(Object.getOwnPropertyNames(Y).length<=Q.maxProperties))return!1;let G=Object.getOwnPropertyNames(Q.properties);for(let W of G){let X=Q.properties[W];if(Q.required&&Q.required.includes(W)){if(!y(X,Z,Y[W]))return!1;if((M1(X)||b4(X))&&!(W in Y))return!1}else if(_.IsExactOptionalProperty(Y,W)&&!y(X,Z,Y[W]))return!1}if(Q.additionalProperties===!1){let W=Object.getOwnPropertyNames(Y);if(Q.required&&Q.required.length===G.length&&W.length===G.length)return!0;else return W.every((X)=>G.includes(X))}else if(typeof Q.additionalProperties==="object")return Object.getOwnPropertyNames(Y).every((X)=>G.includes(X)||y(Q.additionalProperties,Z,Y[X]));else return!0}function n4(Q,Z,Y){return G0(Y)}function m4(Q,Z,Y){if(!_.IsRecordLike(Y))return!1;if(P(Q.minProperties)&&!(Object.getOwnPropertyNames(Y).length>=Q.minProperties))return!1;if(P(Q.maxProperties)&&!(Object.getOwnPropertyNames(Y).length<=Q.maxProperties))return!1;let[G,W]=Object.entries(Q.patternProperties)[0],X=new RegExp(G),J=Object.entries(Y).every(([N,A])=>{return X.test(N)?y(W,Z,A):!0}),H=typeof Q.additionalProperties==="object"?Object.entries(Y).every(([N,A])=>{return!X.test(N)?y(Q.additionalProperties,Z,A):!0}):!0,w=Q.additionalProperties===!1?Object.getOwnPropertyNames(Y).every((N)=>{return X.test(N)}):!0;return J&&H&&w}function h4(Q,Z,Y){return y(i(Q,Z),Z,Y)}function t4(Q,Z,Y){let G=new RegExp(Q.source,Q.flags);if(P(Q.minLength)){if(!(Y.length>=Q.minLength))return!1}if(P(Q.maxLength)){if(!(Y.length<=Q.maxLength))return!1}return G.test(Y)}function v4(Q,Z,Y){if(!f(Y))return!1;if(P(Q.minLength)){if(!(Y.length>=Q.minLength))return!1}if(P(Q.maxLength)){if(!(Y.length<=Q.maxLength))return!1}if(P(Q.pattern)){if(!new RegExp(Q.pattern).test(Y))return!1}if(P(Q.format)){if(!Y1.Has(Q.format))return!1;return Y1.Get(Q.format)(Y)}return!0}function c4(Q,Z,Y){return C1(Y)}function u4(Q,Z,Y){return f(Y)&&new RegExp(Q.pattern).test(Y)}function l4(Q,Z,Y){return y(i(Q,Z),Z,Y)}function s4(Q,Z,Y){if(!V(Y))return!1;if(Q.items===void 0&&Y.length!==0)return!1;if(Y.length!==Q.maxItems)return!1;if(!Q.items)return!0;for(let G=0;G<Q.items.length;G++)if(!y(Q.items[G],Z,Y[G]))return!1;return!0}function r4(Q,Z,Y){return v(Y)}function a4(Q,Z,Y){return Q.anyOf.some((G)=>y(G,Z,Y))}function e4(Q,Z,Y){if(!V1(Y))return!1;if(P(Q.maxByteLength)&&!(Y.length<=Q.maxByteLength))return!1;if(P(Q.minByteLength)&&!(Y.length>=Q.minByteLength))return!1;return!0}function QZ(Q,Z,Y){return!0}function YZ(Q,Z,Y){return _.IsVoidLike(Y)}function ZZ(Q,Z,Y){if(!a.Has(Q[B]))return!1;return a.Get(Q[B])(Q,Y)}function y(Q,Z,Y){let G=P(Q.$id)?j1(Q,Z):Z,W=Q;switch(W[B]){case"Any":return S4(W,G,Y);case"Argument":return C4(W,G,Y);case"Array":return O4(W,G,Y);case"AsyncIterator":return F4(W,G,Y);case"BigInt":return x4(W,G,Y);case"Boolean":return g4(W,G,Y);case"Constructor":return K4(W,G,Y);case"Date":return _4(W,G,Y);case"Function":return k4(W,G,Y);case"Import":return E4(W,G,Y);case"Integer":return V4(W,G,Y);case"Intersect":return T4(W,G,Y);case"Iterator":return I4(W,G,Y);case"Literal":return d4(W,G,Y);case"Never":return f4(W,G,Y);case"Not":return i4(W,G,Y);case"Null":return y4(W,G,Y);case"Number":return p4(W,G,Y);case"Object":return o4(W,G,Y);case"Promise":return n4(W,G,Y);case"Record":return m4(W,G,Y);case"Ref":return h4(W,G,Y);case"RegExp":return t4(W,G,Y);case"String":return v4(W,G,Y);case"Symbol":return c4(W,G,Y);case"TemplateLiteral":return u4(W,G,Y);case"This":return l4(W,G,Y);case"Tuple":return s4(W,G,Y);case"Undefined":return r4(W,G,Y);case"Union":return a4(W,G,Y);case"Uint8Array":return e4(W,G,Y);case"Unknown":return QZ(W,G,Y);case"Void":return YZ(W,G,Y);default:if(!a.Has(W[B]))throw new L8(W);return ZZ(W,G,Y)}}function F1(...Q){return Q.length===3?y(Q[0],Q[1],Q[2]):y(Q[0],[],Q[1])}var q;(function(Q){Q[Q.ArrayContains=0]="ArrayContains",Q[Q.ArrayMaxContains=1]="ArrayMaxContains",Q[Q.ArrayMaxItems=2]="ArrayMaxItems",Q[Q.ArrayMinContains=3]="ArrayMinContains",Q[Q.ArrayMinItems=4]="ArrayMinItems",Q[Q.ArrayUniqueItems=5]="ArrayUniqueItems",Q[Q.Array=6]="Array",Q[Q.AsyncIterator=7]="AsyncIterator",Q[Q.BigIntExclusiveMaximum=8]="BigIntExclusiveMaximum",Q[Q.BigIntExclusiveMinimum=9]="BigIntExclusiveMinimum",Q[Q.BigIntMaximum=10]="BigIntMaximum",Q[Q.BigIntMinimum=11]="BigIntMinimum",Q[Q.BigIntMultipleOf=12]="BigIntMultipleOf",Q[Q.BigInt=13]="BigInt",Q[Q.Boolean=14]="Boolean",Q[Q.DateExclusiveMaximumTimestamp=15]="DateExclusiveMaximumTimestamp",Q[Q.DateExclusiveMinimumTimestamp=16]="DateExclusiveMinimumTimestamp",Q[Q.DateMaximumTimestamp=17]="DateMaximumTimestamp",Q[Q.DateMinimumTimestamp=18]="DateMinimumTimestamp",Q[Q.DateMultipleOfTimestamp=19]="DateMultipleOfTimestamp",Q[Q.Date=20]="Date",Q[Q.Function=21]="Function",Q[Q.IntegerExclusiveMaximum=22]="IntegerExclusiveMaximum",Q[Q.IntegerExclusiveMinimum=23]="IntegerExclusiveMinimum",Q[Q.IntegerMaximum=24]="IntegerMaximum",Q[Q.IntegerMinimum=25]="IntegerMinimum",Q[Q.IntegerMultipleOf=26]="IntegerMultipleOf",Q[Q.Integer=27]="Integer",Q[Q.IntersectUnevaluatedProperties=28]="IntersectUnevaluatedProperties",Q[Q.Intersect=29]="Intersect",Q[Q.Iterator=30]="Iterator",Q[Q.Kind=31]="Kind",Q[Q.Literal=32]="Literal",Q[Q.Never=33]="Never",Q[Q.Not=34]="Not",Q[Q.Null=35]="Null",Q[Q.NumberExclusiveMaximum=36]="NumberExclusiveMaximum",Q[Q.NumberExclusiveMinimum=37]="NumberExclusiveMinimum",Q[Q.NumberMaximum=38]="NumberMaximum",Q[Q.NumberMinimum=39]="NumberMinimum",Q[Q.NumberMultipleOf=40]="NumberMultipleOf",Q[Q.Number=41]="Number",Q[Q.ObjectAdditionalProperties=42]="ObjectAdditionalProperties",Q[Q.ObjectMaxProperties=43]="ObjectMaxProperties",Q[Q.ObjectMinProperties=44]="ObjectMinProperties",Q[Q.ObjectRequiredProperty=45]="ObjectRequiredProperty",Q[Q.Object=46]="Object",Q[Q.Promise=47]="Promise",Q[Q.RegExp=48]="RegExp",Q[Q.StringFormatUnknown=49]="StringFormatUnknown",Q[Q.StringFormat=50]="StringFormat",Q[Q.StringMaxLength=51]="StringMaxLength",Q[Q.StringMinLength=52]="StringMinLength",Q[Q.StringPattern=53]="StringPattern",Q[Q.String=54]="String",Q[Q.Symbol=55]="Symbol",Q[Q.TupleLength=56]="TupleLength",Q[Q.Tuple=57]="Tuple",Q[Q.Uint8ArrayMaxByteLength=58]="Uint8ArrayMaxByteLength",Q[Q.Uint8ArrayMinByteLength=59]="Uint8ArrayMinByteLength",Q[Q.Uint8Array=60]="Uint8Array",Q[Q.Undefined=61]="Undefined",Q[Q.Union=62]="Union",Q[Q.Void=63]="Void"})(q||(q={}));class M8 extends T{constructor(Q){super("Unknown type");this.schema=Q}}function U1(Q){return Q.replace(/~/g,"~0").replace(/\//g,"~1")}function b(Q){return Q!==void 0}class g0{constructor(Q){this.iterator=Q}[Symbol.iterator](){return this.iterator}First(){let Q=this.iterator.next();return Q.done?void 0:Q.value}}function L(Q,Z,Y,G,W=[]){return{type:Q,schema:Z,path:Y,value:G,message:Y8()({errorType:Q,path:Y,schema:Z,value:G,errors:W}),errors:W}}function*GZ(Q,Z,Y,G){}function*WZ(Q,Z,Y,G){}function*XZ(Q,Z,Y,G){if(!V(G))return yield L(q.Array,Q,Y,G);if(b(Q.minItems)&&!(G.length>=Q.minItems))yield L(q.ArrayMinItems,Q,Y,G);if(b(Q.maxItems)&&!(G.length<=Q.maxItems))yield L(q.ArrayMaxItems,Q,Y,G);for(let J=0;J<G.length;J++)yield*p(Q.items,Z,`${Y}/${J}`,G[J]);if(Q.uniqueItems===!0&&!function(){let J=new Set;for(let H of G){let w=o1(H);if(J.has(w))return!1;else J.add(w)}return!0}())yield L(q.ArrayUniqueItems,Q,Y,G);if(!(b(Q.contains)||b(Q.minContains)||b(Q.maxContains)))return;let W=b(Q.contains)?Q.contains:c(),X=G.reduce((J,H,w)=>p(W,Z,`${Y}${w}`,H).next().done===!0?J+1:J,0);if(X===0)yield L(q.ArrayContains,Q,Y,G);if(D(Q.minContains)&&X<Q.minContains)yield L(q.ArrayMinContains,Q,Y,G);if(D(Q.maxContains)&&X>Q.maxContains)yield L(q.ArrayMaxContains,Q,Y,G)}function*$Z(Q,Z,Y,G){if(!Y0(G))yield L(q.AsyncIterator,Q,Y,G)}function*zZ(Q,Z,Y,G){if(!e(G))return yield L(q.BigInt,Q,Y,G);if(b(Q.exclusiveMaximum)&&!(G<Q.exclusiveMaximum))yield L(q.BigIntExclusiveMaximum,Q,Y,G);if(b(Q.exclusiveMinimum)&&!(G>Q.exclusiveMinimum))yield L(q.BigIntExclusiveMinimum,Q,Y,G);if(b(Q.maximum)&&!(G<=Q.maximum))yield L(q.BigIntMaximum,Q,Y,G);if(b(Q.minimum)&&!(G>=Q.minimum))yield L(q.BigIntMinimum,Q,Y,G);if(b(Q.multipleOf)&&G%Q.multipleOf!==BigInt(0))yield L(q.BigIntMultipleOf,Q,Y,G)}function*JZ(Q,Z,Y,G){if(!S1(G))yield L(q.Boolean,Q,Y,G)}function*qZ(Q,Z,Y,G){yield*p(Q.returns,Z,Y,G.prototype)}function*HZ(Q,Z,Y,G){if(!E1(G))return yield L(q.Date,Q,Y,G);if(b(Q.exclusiveMaximumTimestamp)&&!(G.getTime()<Q.exclusiveMaximumTimestamp))yield L(q.DateExclusiveMaximumTimestamp,Q,Y,G);if(b(Q.exclusiveMinimumTimestamp)&&!(G.getTime()>Q.exclusiveMinimumTimestamp))yield L(q.DateExclusiveMinimumTimestamp,Q,Y,G);if(b(Q.maximumTimestamp)&&!(G.getTime()<=Q.maximumTimestamp))yield L(q.DateMaximumTimestamp,Q,Y,G);if(b(Q.minimumTimestamp)&&!(G.getTime()>=Q.minimumTimestamp))yield L(q.DateMinimumTimestamp,Q,Y,G);if(b(Q.multipleOfTimestamp)&&G.getTime()%Q.multipleOfTimestamp!==0)yield L(q.DateMultipleOfTimestamp,Q,Y,G)}function*LZ(Q,Z,Y,G){if(!$0(G))yield L(q.Function,Q,Y,G)}function*MZ(Q,Z,Y,G){let W=globalThis.Object.values(Q.$defs),X=Q.$defs[Q.$ref];yield*p(X,[...Z,...W],Y,G)}function*UZ(Q,Z,Y,G){if(!X0(G))return yield L(q.Integer,Q,Y,G);if(b(Q.exclusiveMaximum)&&!(G<Q.exclusiveMaximum))yield L(q.IntegerExclusiveMaximum,Q,Y,G);if(b(Q.exclusiveMinimum)&&!(G>Q.exclusiveMinimum))yield L(q.IntegerExclusiveMinimum,Q,Y,G);if(b(Q.maximum)&&!(G<=Q.maximum))yield L(q.IntegerMaximum,Q,Y,G);if(b(Q.minimum)&&!(G>=Q.minimum))yield L(q.IntegerMinimum,Q,Y,G);if(b(Q.multipleOf)&&G%Q.multipleOf!==0)yield L(q.IntegerMultipleOf,Q,Y,G)}function*RZ(Q,Z,Y,G){let W=!1;for(let X of Q.allOf)for(let J of p(X,Z,Y,G))W=!0,yield J;if(W)return yield L(q.Intersect,Q,Y,G);if(Q.unevaluatedProperties===!1){let X=new RegExp(L1(Q));for(let J of Object.getOwnPropertyNames(G))if(!X.test(J))yield L(q.IntersectUnevaluatedProperties,Q,`${Y}/${J}`,G)}if(typeof Q.unevaluatedProperties==="object"){let X=new RegExp(L1(Q));for(let J of Object.getOwnPropertyNames(G))if(!X.test(J)){let H=p(Q.unevaluatedProperties,Z,`${Y}/${J}`,G[J]).next();if(!H.done)yield H.value}}}function*AZ(Q,Z,Y,G){if(!Z0(G))yield L(q.Iterator,Q,Y,G)}function*BZ(Q,Z,Y,G){if(G!==Q.const)yield L(q.Literal,Q,Y,G)}function*wZ(Q,Z,Y,G){yield L(q.Never,Q,Y,G)}function*jZ(Q,Z,Y,G){if(p(Q.not,Z,Y,G).next().done===!0)yield L(q.Not,Q,Y,G)}function*DZ(Q,Z,Y,G){if(!b1(G))yield L(q.Null,Q,Y,G)}function*NZ(Q,Z,Y,G){if(!_.IsNumberLike(G))return yield L(q.Number,Q,Y,G);if(b(Q.exclusiveMaximum)&&!(G<Q.exclusiveMaximum))yield L(q.NumberExclusiveMaximum,Q,Y,G);if(b(Q.exclusiveMinimum)&&!(G>Q.exclusiveMinimum))yield L(q.NumberExclusiveMinimum,Q,Y,G);if(b(Q.maximum)&&!(G<=Q.maximum))yield L(q.NumberMaximum,Q,Y,G);if(b(Q.minimum)&&!(G>=Q.minimum))yield L(q.NumberMinimum,Q,Y,G);if(b(Q.multipleOf)&&G%Q.multipleOf!==0)yield L(q.NumberMultipleOf,Q,Y,G)}function*PZ(Q,Z,Y,G){if(!_.IsObjectLike(G))return yield L(q.Object,Q,Y,G);if(b(Q.minProperties)&&!(Object.getOwnPropertyNames(G).length>=Q.minProperties))yield L(q.ObjectMinProperties,Q,Y,G);if(b(Q.maxProperties)&&!(Object.getOwnPropertyNames(G).length<=Q.maxProperties))yield L(q.ObjectMaxProperties,Q,Y,G);let W=Array.isArray(Q.required)?Q.required:[],X=Object.getOwnPropertyNames(Q.properties),J=Object.getOwnPropertyNames(G);for(let H of W){if(J.includes(H))continue;yield L(q.ObjectRequiredProperty,Q.properties[H],`${Y}/${U1(H)}`,void 0)}if(Q.additionalProperties===!1){for(let H of J)if(!X.includes(H))yield L(q.ObjectAdditionalProperties,Q,`${Y}/${U1(H)}`,G[H])}if(typeof Q.additionalProperties==="object")for(let H of J){if(X.includes(H))continue;yield*p(Q.additionalProperties,Z,`${Y}/${U1(H)}`,G[H])}for(let H of X){let w=Q.properties[H];if(Q.required&&Q.required.includes(H)){if(yield*p(w,Z,`${Y}/${U1(H)}`,G[H]),M1(Q)&&!(H in G))yield L(q.ObjectRequiredProperty,w,`${Y}/${U1(H)}`,void 0)}else if(_.IsExactOptionalProperty(G,H))yield*p(w,Z,`${Y}/${U1(H)}`,G[H])}}function*bZ(Q,Z,Y,G){if(!G0(G))yield L(q.Promise,Q,Y,G)}function*SZ(Q,Z,Y,G){if(!_.IsRecordLike(G))return yield L(q.Object,Q,Y,G);if(b(Q.minProperties)&&!(Object.getOwnPropertyNames(G).length>=Q.minProperties))yield L(q.ObjectMinProperties,Q,Y,G);if(b(Q.maxProperties)&&!(Object.getOwnPropertyNames(G).length<=Q.maxProperties))yield L(q.ObjectMaxProperties,Q,Y,G);let[W,X]=Object.entries(Q.patternProperties)[0],J=new RegExp(W);for(let[H,w]of Object.entries(G))if(J.test(H))yield*p(X,Z,`${Y}/${U1(H)}`,w);if(typeof Q.additionalProperties==="object"){for(let[H,w]of Object.entries(G))if(!J.test(H))yield*p(Q.additionalProperties,Z,`${Y}/${U1(H)}`,w)}if(Q.additionalProperties===!1)for(let[H,w]of Object.entries(G)){if(J.test(H))continue;return yield L(q.ObjectAdditionalProperties,Q,`${Y}/${U1(H)}`,w)}}function*CZ(Q,Z,Y,G){yield*p(i(Q,Z),Z,Y,G)}function*OZ(Q,Z,Y,G){if(!f(G))return yield L(q.String,Q,Y,G);if(b(Q.minLength)&&!(G.length>=Q.minLength))yield L(q.StringMinLength,Q,Y,G);if(b(Q.maxLength)&&!(G.length<=Q.maxLength))yield L(q.StringMaxLength,Q,Y,G);if(!new RegExp(Q.source,Q.flags).test(G))return yield L(q.RegExp,Q,Y,G)}function*FZ(Q,Z,Y,G){if(!f(G))return yield L(q.String,Q,Y,G);if(b(Q.minLength)&&!(G.length>=Q.minLength))yield L(q.StringMinLength,Q,Y,G);if(b(Q.maxLength)&&!(G.length<=Q.maxLength))yield L(q.StringMaxLength,Q,Y,G);if(f(Q.pattern)){if(!new RegExp(Q.pattern).test(G))yield L(q.StringPattern,Q,Y,G)}if(f(Q.format)){if(!Y1.Has(Q.format))yield L(q.StringFormatUnknown,Q,Y,G);else if(!Y1.Get(Q.format)(G))yield L(q.StringFormat,Q,Y,G)}}function*xZ(Q,Z,Y,G){if(!C1(G))yield L(q.Symbol,Q,Y,G)}function*gZ(Q,Z,Y,G){if(!f(G))return yield L(q.String,Q,Y,G);if(!new RegExp(Q.pattern).test(G))yield L(q.StringPattern,Q,Y,G)}function*KZ(Q,Z,Y,G){yield*p(i(Q,Z),Z,Y,G)}function*_Z(Q,Z,Y,G){if(!V(G))return yield L(q.Tuple,Q,Y,G);if(Q.items===void 0&&G.length!==0)return yield L(q.TupleLength,Q,Y,G);if(G.length!==Q.maxItems)return yield L(q.TupleLength,Q,Y,G);if(!Q.items)return;for(let W=0;W<Q.items.length;W++)yield*p(Q.items[W],Z,`${Y}/${W}`,G[W])}function*kZ(Q,Z,Y,G){if(!v(G))yield L(q.Undefined,Q,Y,G)}function*EZ(Q,Z,Y,G){if(F1(Q,Z,G))return;let W=Q.anyOf.map((X)=>new g0(p(X,Z,Y,G)));yield L(q.Union,Q,Y,G,W)}function*VZ(Q,Z,Y,G){if(!V1(G))return yield L(q.Uint8Array,Q,Y,G);if(b(Q.maxByteLength)&&!(G.length<=Q.maxByteLength))yield L(q.Uint8ArrayMaxByteLength,Q,Y,G);if(b(Q.minByteLength)&&!(G.length>=Q.minByteLength))yield L(q.Uint8ArrayMinByteLength,Q,Y,G)}function*TZ(Q,Z,Y,G){}function*IZ(Q,Z,Y,G){if(!_.IsVoidLike(G))yield L(q.Void,Q,Y,G)}function*dZ(Q,Z,Y,G){if(!a.Get(Q[B])(Q,G))yield L(q.Kind,Q,Y,G)}function*p(Q,Z,Y,G){let W=b(Q.$id)?[...Z,Q]:Z,X=Q;switch(X[B]){case"Any":return yield*GZ(X,W,Y,G);case"Argument":return yield*WZ(X,W,Y,G);case"Array":return yield*XZ(X,W,Y,G);case"AsyncIterator":return yield*$Z(X,W,Y,G);case"BigInt":return yield*zZ(X,W,Y,G);case"Boolean":return yield*JZ(X,W,Y,G);case"Constructor":return yield*qZ(X,W,Y,G);case"Date":return yield*HZ(X,W,Y,G);case"Function":return yield*LZ(X,W,Y,G);case"Import":return yield*MZ(X,W,Y,G);case"Integer":return yield*UZ(X,W,Y,G);case"Intersect":return yield*RZ(X,W,Y,G);case"Iterator":return yield*AZ(X,W,Y,G);case"Literal":return yield*BZ(X,W,Y,G);case"Never":return yield*wZ(X,W,Y,G);case"Not":return yield*jZ(X,W,Y,G);case"Null":return yield*DZ(X,W,Y,G);case"Number":return yield*NZ(X,W,Y,G);case"Object":return yield*PZ(X,W,Y,G);case"Promise":return yield*bZ(X,W,Y,G);case"Record":return yield*SZ(X,W,Y,G);case"Ref":return yield*CZ(X,W,Y,G);case"RegExp":return yield*OZ(X,W,Y,G);case"String":return yield*FZ(X,W,Y,G);case"Symbol":return yield*xZ(X,W,Y,G);case"TemplateLiteral":return yield*gZ(X,W,Y,G);case"This":return yield*KZ(X,W,Y,G);case"Tuple":return yield*_Z(X,W,Y,G);case"Undefined":return yield*kZ(X,W,Y,G);case"Union":return yield*EZ(X,W,Y,G);case"Uint8Array":return yield*VZ(X,W,Y,G);case"Unknown":return yield*TZ(X,W,Y,G);case"Void":return yield*IZ(X,W,Y,G);default:if(!a.Has(X[B]))throw new M8(Q);return yield*dZ(X,W,Y,G)}}function U8(...Q){let Z=Q.length===3?p(Q[0],Q[1],"",Q[2]):p(Q[0],[],"",Q[1]);return new g0(Z)}class K0 extends T{constructor(Q,Z,Y){super("Unable to decode value as it does not match the expected schema");this.schema=Q,this.value=Z,this.error=Y}}class R8 extends T{constructor(Q,Z,Y,G){super(G instanceof Error?G.message:"Unknown error");this.schema=Q,this.path=Z,this.value=Y,this.error=G}}function E(Q,Z,Y){try{return x(Q)?Q[B1].Decode(Y):Y}catch(G){throw new R8(Q,Z,Y,G)}}function fZ(Q,Z,Y,G){return V(G)?E(Q,Y,G.map((W,X)=>X1(Q.items,Z,`${Y}/${X}`,W))):E(Q,Y,G)}function iZ(Q,Z,Y,G){if(!r(G)||z0(G))return E(Q,Y,G);let W=B0(Q),X=W.map((A)=>A[0]),J={...G};for(let[A,O]of W)if(A in J)J[A]=X1(O,Z,`${Y}/${A}`,J[A]);if(!x(Q.unevaluatedProperties))return E(Q,Y,J);let H=Object.getOwnPropertyNames(J),w=Q.unevaluatedProperties,N={...J};for(let A of H)if(!X.includes(A))N[A]=E(w,`${Y}/${A}`,N[A]);return E(Q,Y,N)}function yZ(Q,Z,Y,G){let W=globalThis.Object.values(Q.$defs),X=Q.$defs[Q.$ref],J=X1(X,[...Z,...W],Y,G);return E(Q,Y,J)}function pZ(Q,Z,Y,G){return E(Q,Y,X1(Q.not,Z,Y,G))}function oZ(Q,Z,Y,G){if(!r(G))return E(Q,Y,G);let W=w1(Q),X={...G};for(let N of W){if(!W0(X,N))continue;if(v(X[N])&&(!c1(Q.properties[N])||_.IsExactOptionalProperty(X,N)))continue;X[N]=X1(Q.properties[N],Z,`${Y}/${N}`,X[N])}if(!u(Q.additionalProperties))return E(Q,Y,X);let J=Object.getOwnPropertyNames(X),H=Q.additionalProperties,w={...X};for(let N of J)if(!W.includes(N))w[N]=E(H,`${Y}/${N}`,w[N]);return E(Q,Y,w)}function nZ(Q,Z,Y,G){if(!r(G))return E(Q,Y,G);let W=Object.getOwnPropertyNames(Q.patternProperties)[0],X=new RegExp(W),J={...G};for(let A of Object.getOwnPropertyNames(G))if(X.test(A))J[A]=X1(Q.patternProperties[W],Z,`${Y}/${A}`,J[A]);if(!u(Q.additionalProperties))return E(Q,Y,J);let H=Object.getOwnPropertyNames(J),w=Q.additionalProperties,N={...J};for(let A of H)if(!X.test(A))N[A]=E(w,`${Y}/${A}`,N[A]);return E(Q,Y,N)}function mZ(Q,Z,Y,G){let W=i(Q,Z);return E(Q,Y,X1(W,Z,Y,G))}function hZ(Q,Z,Y,G){let W=i(Q,Z);return E(Q,Y,X1(W,Z,Y,G))}function tZ(Q,Z,Y,G){return V(G)&&V(Q.items)?E(Q,Y,Q.items.map((W,X)=>X1(W,Z,`${Y}/${X}`,G[X]))):E(Q,Y,G)}function vZ(Q,Z,Y,G){for(let W of Q.anyOf){if(!F1(W,Z,G))continue;let X=X1(W,Z,Y,G);return E(Q,Y,X)}return E(Q,Y,G)}function X1(Q,Z,Y,G){let W=j1(Q,Z),X=Q;switch(Q[B]){case"Array":return fZ(X,W,Y,G);case"Import":return yZ(X,W,Y,G);case"Intersect":return iZ(X,W,Y,G);case"Not":return pZ(X,W,Y,G);case"Object":return oZ(X,W,Y,G);case"Record":return nZ(X,W,Y,G);case"Ref":return mZ(X,W,Y,G);case"Symbol":return E(X,Y,G);case"This":return hZ(X,W,Y,G);case"Tuple":return tZ(X,W,Y,G);case"Union":return vZ(X,W,Y,G);default:return E(X,Y,G)}}function A8(Q,Z,Y){return X1(Q,Z,"",Y)}class _0 extends T{constructor(Q,Z,Y){super("The encoded value does not match the expected schema");this.schema=Q,this.value=Z,this.error=Y}}class B8 extends T{constructor(Q,Z,Y,G){super(`${G instanceof Error?G.message:"Unknown error"}`);this.schema=Q,this.path=Z,this.value=Y,this.error=G}}function h(Q,Z,Y){try{return x(Q)?Q[B1].Encode(Y):Y}catch(G){throw new B8(Q,Z,Y,G)}}function cZ(Q,Z,Y,G){let W=h(Q,Y,G);return V(W)?W.map((X,J)=>$1(Q.items,Z,`${Y}/${J}`,X)):W}function uZ(Q,Z,Y,G){let W=globalThis.Object.values(Q.$defs),X=Q.$defs[Q.$ref],J=h(Q,Y,G);return $1(X,[...Z,...W],Y,J)}function lZ(Q,Z,Y,G){let W=h(Q,Y,G);if(!r(G)||z0(G))return W;let X=B0(Q),J=X.map((O)=>O[0]),H={...W};for(let[O,g1]of X)if(O in H)H[O]=$1(g1,Z,`${Y}/${O}`,H[O]);if(!x(Q.unevaluatedProperties))return H;let w=Object.getOwnPropertyNames(H),N=Q.unevaluatedProperties,A={...H};for(let O of w)if(!J.includes(O))A[O]=h(N,`${Y}/${O}`,A[O]);return A}function sZ(Q,Z,Y,G){return h(Q.not,Y,h(Q,Y,G))}function rZ(Q,Z,Y,G){let W=h(Q,Y,G);if(!r(W))return W;let X=w1(Q),J={...W};for(let A of X){if(!W0(J,A))continue;if(v(J[A])&&(!c1(Q.properties[A])||_.IsExactOptionalProperty(J,A)))continue;J[A]=$1(Q.properties[A],Z,`${Y}/${A}`,J[A])}if(!u(Q.additionalProperties))return J;let H=Object.getOwnPropertyNames(J),w=Q.additionalProperties,N={...J};for(let A of H)if(!X.includes(A))N[A]=h(w,`${Y}/${A}`,N[A]);return N}function aZ(Q,Z,Y,G){let W=h(Q,Y,G);if(!r(G))return W;let X=Object.getOwnPropertyNames(Q.patternProperties)[0],J=new RegExp(X),H={...W};for(let O of Object.getOwnPropertyNames(G))if(J.test(O))H[O]=$1(Q.patternProperties[X],Z,`${Y}/${O}`,H[O]);if(!u(Q.additionalProperties))return H;let w=Object.getOwnPropertyNames(H),N=Q.additionalProperties,A={...H};for(let O of w)if(!J.test(O))A[O]=h(N,`${Y}/${O}`,A[O]);return A}function eZ(Q,Z,Y,G){let W=i(Q,Z),X=$1(W,Z,Y,G);return h(Q,Y,X)}function QG(Q,Z,Y,G){let W=i(Q,Z),X=$1(W,Z,Y,G);return h(Q,Y,X)}function YG(Q,Z,Y,G){let W=h(Q,Y,G);return V(Q.items)?Q.items.map((X,J)=>$1(X,Z,`${Y}/${J}`,W[J])):[]}function ZG(Q,Z,Y,G){for(let W of Q.anyOf){if(!F1(W,Z,G))continue;let X=$1(W,Z,Y,G);return h(Q,Y,X)}for(let W of Q.anyOf){let X=$1(W,Z,Y,G);if(!F1(Q,Z,X))continue;return h(Q,Y,X)}return h(Q,Y,G)}function $1(Q,Z,Y,G){let W=j1(Q,Z),X=Q;switch(Q[B]){case"Array":return cZ(X,W,Y,G);case"Import":return uZ(X,W,Y,G);case"Intersect":return lZ(X,W,Y,G);case"Not":return sZ(X,W,Y,G);case"Object":return rZ(X,W,Y,G);case"Record":return aZ(X,W,Y,G);case"Ref":return eZ(X,W,Y,G);case"This":return QG(X,W,Y,G);case"Tuple":return YG(X,W,Y,G);case"Union":return ZG(X,W,Y,G);default:return h(X,Y,G)}}function w8(Q,Z,Y){return $1(Q,Z,"",Y)}function GG(Q,Z){return x(Q)||d(Q.items,Z)}function WG(Q,Z){return x(Q)||d(Q.items,Z)}function XG(Q,Z){return x(Q)||d(Q.returns,Z)||Q.parameters.some((Y)=>d(Y,Z))}function $G(Q,Z){return x(Q)||d(Q.returns,Z)||Q.parameters.some((Y)=>d(Y,Z))}function zG(Q,Z){return x(Q)||x(Q.unevaluatedProperties)||Q.allOf.some((Y)=>d(Y,Z))}function JG(Q,Z){let Y=globalThis.Object.getOwnPropertyNames(Q.$defs).reduce((W,X)=>[...W,Q.$defs[X]],[]),G=Q.$defs[Q.$ref];return x(Q)||d(G,[...Y,...Z])}function qG(Q,Z){return x(Q)||d(Q.items,Z)}function HG(Q,Z){return x(Q)||d(Q.not,Z)}function LG(Q,Z){return x(Q)||Object.values(Q.properties).some((Y)=>d(Y,Z))||u(Q.additionalProperties)&&d(Q.additionalProperties,Z)}function MG(Q,Z){return x(Q)||d(Q.item,Z)}function UG(Q,Z){let Y=Object.getOwnPropertyNames(Q.patternProperties)[0],G=Q.patternProperties[Y];return x(Q)||d(G,Z)||u(Q.additionalProperties)&&x(Q.additionalProperties)}function RG(Q,Z){if(x(Q))return!0;return d(i(Q,Z),Z)}function AG(Q,Z){if(x(Q))return!0;return d(i(Q,Z),Z)}function BG(Q,Z){return x(Q)||!v(Q.items)&&Q.items.some((Y)=>d(Y,Z))}function wG(Q,Z){return x(Q)||Q.anyOf.some((Y)=>d(Y,Z))}function d(Q,Z){let Y=j1(Q,Z),G=Q;if(Q.$id&&k0.has(Q.$id))return!1;if(Q.$id)k0.add(Q.$id);switch(Q[B]){case"Array":return GG(G,Y);case"AsyncIterator":return WG(G,Y);case"Constructor":return XG(G,Y);case"Function":return $G(G,Y);case"Import":return JG(G,Y);case"Intersect":return zG(G,Y);case"Iterator":return qG(G,Y);case"Not":return HG(G,Y);case"Object":return LG(G,Y);case"Promise":return MG(G,Y);case"Record":return UG(G,Y);case"Ref":return RG(G,Y);case"This":return AG(G,Y);case"Tuple":return BG(G,Y);case"Union":return wG(G,Y);default:return x(Q)}}var k0=new Set;function j8(Q,Z){return k0.clear(),d(Q,Z)}class D8{constructor(Q,Z,Y,G){this.schema=Q,this.references=Z,this.checkFunc=Y,this.code=G,this.hasTransform=j8(Q,Z)}Code(){return this.code}Schema(){return this.schema}References(){return this.references}Errors(Q){return U8(this.schema,this.references,Q)}Check(Q){return this.checkFunc(Q)}Decode(Q){if(!this.checkFunc(Q))throw new K0(this.schema,Q,this.Errors(Q).First());return this.hasTransform?A8(this.schema,this.references,Q):Q}Encode(Q){let Z=this.hasTransform?w8(this.schema,this.references,Q):Q;if(!this.checkFunc(Z))throw new _0(this.schema,Q,this.Errors(Q).First());return Z}}var R1;(function(Q){function Z(X){return X===36}Q.DollarSign=Z;function Y(X){return X===95}Q.IsUnderscore=Y;function G(X){return X>=65&&X<=90||X>=97&&X<=122}Q.IsAlpha=G;function W(X){return X>=48&&X<=57}Q.IsNumeric=W})(R1||(R1={}));var w0;(function(Q){function Z(X){if(X.length===0)return!1;return R1.IsNumeric(X.charCodeAt(0))}function Y(X){if(Z(X))return!1;for(let J=0;J<X.length;J++){let H=X.charCodeAt(J);if(!(R1.IsAlpha(H)||R1.IsNumeric(H)||R1.DollarSign(H)||R1.IsUnderscore(H)))return!1}return!0}function G(X){return X.replace(/'/g,"\\'")}function W(X,J){return Y(J)?`${X}.${J}`:`${X}['${G(J)}']`}Q.Encode=W})(w0||(w0={}));var E0;(function(Q){function Z(Y){let G=[];for(let W=0;W<Y.length;W++){let X=Y.charCodeAt(W);if(R1.IsNumeric(X)||R1.IsAlpha(X))G.push(Y.charAt(W));else G.push(`_${X}_`)}return G.join("").replace(/__/g,"_")}Q.Encode=Z})(E0||(E0={}));var V0;(function(Q){function Z(Y){return Y.replace(/'/g,"\\'")}Q.Escape=Z})(V0||(V0={}));class N8 extends T{constructor(Q){super("Unknown type");this.schema=Q}}class T0 extends T{constructor(Q){super("Preflight validation check failed to guard for the given schema");this.schema=Q}}var x1;(function(Q){function Z(J,H,w){return _.ExactOptionalPropertyTypes?`('${H}' in ${J} ? ${w} : true)`:`(${w0.Encode(J,H)} !== undefined ? ${w} : true)`}Q.IsExactOptionalProperty=Z;function Y(J){return!_.AllowArrayObject?`(typeof ${J} === 'object' && ${J} !== null && !Array.isArray(${J}))`:`(typeof ${J} === 'object' && ${J} !== null)`}Q.IsObjectLike=Y;function G(J){return!_.AllowArrayObject?`(typeof ${J} === 'object' && ${J} !== null && !Array.isArray(${J}) && !(${J} instanceof Date) && !(${J} instanceof Uint8Array))`:`(typeof ${J} === 'object' && ${J} !== null && !(${J} instanceof Date) && !(${J} instanceof Uint8Array))`}Q.IsRecordLike=G;function W(J){return _.AllowNaN?`typeof ${J} === 'number'`:`Number.isFinite(${J})`}Q.IsNumberLike=W;function X(J){return _.AllowNullVoid?`(${J} === undefined || ${J} === null)`:`${J} === undefined`}Q.IsVoidLike=X})(x1||(x1={}));var j0;(function(Q){function Z($){return $[B]==="Any"||$[B]==="Unknown"}function*Y($,M,z){yield"true"}function*G($,M,z){yield"true"}function*W($,M,z){yield`Array.isArray(${z})`;let[j,U]=[e1("value","any"),e1("acc","number")];if(D($.maxItems))yield`${z}.length <= ${$.maxItems}`;if(D($.minItems))yield`${z}.length >= ${$.minItems}`;let R=G1($.items,M,"value");if(yield`${z}.every((${j}) => ${R})`,k($.contains)||D($.minContains)||D($.maxContains)){let K=k($.contains)?$.contains:c(),s=G1(K,M,"value"),H1=D($.minContains)?[`(count >= ${$.minContains})`]:[],W1=D($.maxContains)?[`(count <= ${$.maxContains})`]:[],z1=`const count = value.reduce((${U}, ${j}) => ${s} ? acc + 1 : acc, 0)`,Q0=["(count > 0)",...H1,...W1].join(" && ");yield`((${j}) => { ${z1}; return ${Q0}})(${z})`}if($.uniqueItems===!0)yield`((${j}) => { 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 } )(${z})`}function*X($,M,z){yield`(typeof value === 'object' && Symbol.asyncIterator in ${z})`}function*J($,M,z){if(yield`(typeof ${z} === 'bigint')`,e($.exclusiveMaximum))yield`${z} < BigInt(${$.exclusiveMaximum})`;if(e($.exclusiveMinimum))yield`${z} > BigInt(${$.exclusiveMinimum})`;if(e($.maximum))yield`${z} <= BigInt(${$.maximum})`;if(e($.minimum))yield`${z} >= BigInt(${$.minimum})`;if(e($.multipleOf))yield`(${z} % BigInt(${$.multipleOf})) === 0`}function*H($,M,z){yield`(typeof ${z} === 'boolean')`}function*w($,M,z){yield*_1($.returns,M,`${z}.prototype`)}function*N($,M,z){if(yield`(${z} instanceof Date) && Number.isFinite(${z}.getTime())`,D($.exclusiveMaximumTimestamp))yield`${z}.getTime() < ${$.exclusiveMaximumTimestamp}`;if(D($.exclusiveMinimumTimestamp))yield`${z}.getTime() > ${$.exclusiveMinimumTimestamp}`;if(D($.maximumTimestamp))yield`${z}.getTime() <= ${$.maximumTimestamp}`;if(D($.minimumTimestamp))yield`${z}.getTime() >= ${$.minimumTimestamp}`;if(D($.multipleOfTimestamp))yield`(${z}.getTime() % ${$.multipleOfTimestamp}) === 0`}function*A($,M,z){yield`(typeof ${z} === 'function')`}function*O($,M,z){let j=globalThis.Object.getOwnPropertyNames($.$defs).reduce((U,R)=>{return[...U,$.$defs[R]]},[]);yield*_1(e0($.$ref),[...M,...j],z)}function*g1($,M,z){if(yield`Number.isInteger(${z})`,D($.exclusiveMaximum))yield`${z} < ${$.exclusiveMaximum}`;if(D($.exclusiveMinimum))yield`${z} > ${$.exclusiveMinimum}`;if(D($.maximum))yield`${z} <= ${$.maximum}`;if(D($.minimum))yield`${z} >= ${$.minimum}`;if(D($.multipleOf))yield`(${z} % ${$.multipleOf}) === 0`}function*l($,M,z){let j=$.allOf.map((U)=>G1(U,M,z)).join(" && ");if($.unevaluatedProperties===!1){let U=k1(`${new RegExp(L1($))};`),R=`Object.getOwnPropertyNames(${z}).every(key => ${U}.test(key))`;yield`(${j} && ${R})`}else if(k($.unevaluatedProperties)){let U=k1(`${new RegExp(L1($))};`),R=`Object.getOwnPropertyNames(${z}).every(key => ${U}.test(key) || ${G1($.unevaluatedProperties,M,`${z}[key]`)})`;yield`(${j} && ${R})`}else yield`(${j})`}function*D1($,M,z){yield`(typeof value === 'object' && Symbol.iterator in ${z})`}function*N1($,M,z){if(typeof $.const==="number"||typeof $.const==="boolean")yield`(${z} === ${$.const})`;else yield`(${z} === '${V0.Escape($.const)}')`}function*D0($,M,z){yield"false"}function*P1($,M,z){yield`(!${G1($.not,M,z)})`}function*s1($,M,z){yield`(${z} === null)`}function*r1($,M,z){if(yield x1.IsNumberLike(z),D($.exclusiveMaximum))yield`${z} < ${$.exclusiveMaximum}`;if(D($.exclusiveMinimum))yield`${z} > ${$.exclusiveMinimum}`;if(D($.maximum))yield`${z} <= ${$.maximum}`;if(D($.minimum))yield`${z} >= ${$.minimum}`;if(D($.multipleOf))yield`(${z} % ${$.multipleOf}) === 0`}function*K1($,M,z){if(yield x1.IsObjectLike(z),D($.minProperties))yield`Object.getOwnPropertyNames(${z}).length >= ${$.minProperties}`;if(D($.maxProperties))yield`Object.getOwnPropertyNames(${z}).length <= ${$.maxProperties}`;let j=Object.getOwnPropertyNames($.properties);for(let U of j){let R=w0.Encode(z,U),K=$.properties[U];if($.required&&$.required.includes(U)){if(yield*_1(K,M,R),M1(K)||Z(K))yield`('${U}' in ${z})`}else{let s=G1(K,M,R);yield x1.IsExactOptionalProperty(z,U,s)}}if($.additionalProperties===!1)if($.required&&$.required.length===j.length)yield`Object.getOwnPropertyNames(${z}).length === ${j.length}`;else{let U=`[${j.map((R)=>`'${R}'`).join(", ")}]`;yield`Object.getOwnPropertyNames(${z}).every(key => ${U}.includes(key))`}if(typeof $.additionalProperties==="object"){let U=G1($.additionalProperties,M,`${z}[key]`),R=`[${j.map((K)=>`'${K}'`).join(", ")}]`;yield`(Object.getOwnPropertyNames(${z}).every(key => ${R}.includes(key) || ${U}))`}}function*C8($,M,z){yield`${z} instanceof Promise`}function*O8($,M,z){if(yield x1.IsRecordLike(z),D($.minProperties))yield`Object.getOwnPropertyNames(${z}).length >= ${$.minProperties}`;if(D($.maxProperties))yield`Object.getOwnPropertyNames(${z}).length <= ${$.maxProperties}`;let[j,U]=Object.entries($.patternProperties)[0],R=k1(`${new RegExp(j)}`),K=G1(U,M,"value"),s=k($.additionalProperties)?G1($.additionalProperties,M,z):$.additionalProperties===!1?"false":"true",H1=`(${R}.test(key) ? ${K} : ${s})`;yield`(Object.entries(${z}).every(([key, value]) => ${H1}))`}function*F8($,M,z){let j=i($,M);if(o.functions.has($.$ref))return yield`${a1($.$ref)}(${z})`;yield*_1(j,M,z)}function*x8($,M,z){let j=k1(`${new RegExp($.source,$.flags)};`);if(yield`(typeof ${z} === 'string')`,D($.maxLength))yield`${z}.length <= ${$.maxLength}`;if(D($.minLength))yield`${z}.length >= ${$.minLength}`;yield`${j}.test(${z})`}function*g8($,M,z){if(yield`(typeof ${z} === 'string')`,D($.maxLength))yield`${z}.length <= ${$.maxLength}`;if(D($.minLength))yield`${z}.length >= ${$.minLength}`;if($.pattern!==void 0)yield`${k1(`${new RegExp($.pattern)};`)}.test(${z})`;if($.format!==void 0)yield`format('${$.format}', ${z})`}function*K8($,M,z){yield`(typeof ${z} === 'symbol')`}function*_8($,M,z){yield`(typeof ${z} === 'string')`,yield`${k1(`${new RegExp($.pattern)};`)}.test(${z})`}function*k8($,M,z){yield`${a1($.$ref)}(${z})`}function*E8($,M,z){if(yield`Array.isArray(${z})`,$.items===void 0)return yield`${z}.length === 0`;yield`(${z}.length === ${$.maxItems})`;for(let j=0;j<$.items.length;j++)yield`${G1($.items[j],M,`${z}[${j}]`)}`}function*V8($,M,z){yield`${z} === undefined`}function*T8($,M,z){yield`(${$.anyOf.map((U)=>G1(U,M,z)).join(" || ")})`}function*I8($,M,z){if(yield`${z} instanceof Uint8Array`,D($.maxByteLength))yield`(${z}.length <= ${$.maxByteLength})`;if(D($.minByteLength))yield`(${z}.length >= ${$.minByteLength})`}function*d8($,M,z){yield"true"}function*f8($,M,z){yield x1.IsVoidLike(z)}function*i8($,M,z){let j=o.instances.size;o.instances.set(j,$),yield`kind('${$[B]}', ${j}, ${z})`}function*_1($,M,z,j=!0){let U=f($.$id)?[...M,$]:M,R=$;if(j&&f($.$id)){let K=a1($.$id);if(o.functions.has(K))return yield`${K}(${z})`;else{o.functions.set(K,"<deferred>");let s=I0(K,$,M,"value",!1);return o.functions.set(K,s),yield`${K}(${z})`}}switch(R[B]){case"Any":return yield*Y(R,U,z);case"Argument":return yield*G(R,U,z);case"Array":return yield*W(R,U,z);case"AsyncIterator":return yield*X(R,U,z);case"BigInt":return yield*J(R,U,z);case"Boolean":return yield*H(R,U,z);case"Constructor":return yield*w(R,U,z);case"Date":return yield*N(R,U,z);case"Function":return yield*A(R,U,z);case"Import":return yield*O(R,U,z);case"Integer":return yield*g1(R,U,z);case"Intersect":return yield*l(R,U,z);case"Iterator":return yield*D1(R,U,z);case"Literal":return yield*N1(R,U,z);case"Never":return yield*D0(R,U,z);case"Not":return yield*P1(R,U,z);case"Null":return yield*s1(R,U,z);case"Number":return yield*r1(R,U,z);case"Object":return yield*K1(R,U,z);case"Promise":return yield*C8(R,U,z);case"Record":return yield*O8(R,U,z);case"Ref":return yield*F8(R,U,z);case"RegExp":return yield*x8(R,U,z);case"String":return yield*g8(R,U,z);case"Symbol":return yield*K8(R,U,z);case"TemplateLiteral":return yield*_8(R,U,z);case"This":return yield*k8(R,U,z);case"Tuple":return yield*E8(R,U,z);case"Undefined":return yield*V8(R,U,z);case"Union":return yield*T8(R,U,z);case"Uint8Array":return yield*I8(R,U,z);case"Unknown":return yield*d8(R,U,z);case"Void":return yield*f8(R,U,z);default:if(!a.Has(R[B]))throw new N8($);return yield*i8(R,U,z)}}let o={language:"javascript",functions:new Map,variables:new Map,instances:new Map};function G1($,M,z,j=!0){return`(${[..._1($,M,z,j)].join(" && ")})`}function a1($){return`check_${E0.Encode($)}`}function k1($){let M=`local_${o.variables.size}`;return o.variables.set(M,`const ${M} = ${$}`),M}function I0($,M,z,j,U=!0){let[R,K]=[`
3
+ `,(z1)=>"".padStart(z1," ")],s=e1("value","any"),H1=d0("boolean"),W1=[..._1(M,z,j,U)].map((z1)=>`${K(4)}${z1}`).join(` &&${R}`);return`function ${$}(${s})${H1} {${R}${K(2)}return (${R}${W1}${R}${K(2)})
4
+ }`}function e1($,M){let z=o.language==="typescript"?`: ${M}`:"";return`${$}${z}`}function d0($){return o.language==="typescript"?`: ${$}`:""}function y8($,M,z){let j=I0("check",$,M,"value"),U=e1("value","any"),R=d0("boolean"),K=[...o.functions.values()],s=[...o.variables.values()],H1=f($.$id)?`return function check(${U})${R} {
5
+ return ${a1($.$id)}(value)
6
+ }`:`return ${j}`;return[...s,...K,H1].join(`
7
+ `)}function f0(...$){let M={language:"javascript"},[z,j,U]=$.length===2&&V($[1])?[$[0],$[1],M]:$.length===2&&!V($[1])?[$[0],[],$[1]]:$.length===3?[$[0],$[1],$[2]]:$.length===1?[$[0],[],M]:[null,[],M];if(o.language=U.language,o.variables.clear(),o.functions.clear(),o.instances.clear(),!k(z))throw new T0(z);for(let R of j)if(!k(R))throw new T0(R);return y8(z,j,U)}Q.Code=f0;function p8($,M=[]){let z=f0($,M,{language:"javascript"}),j=globalThis.Function("kind","format","hash",z),U=new Map(o.instances);function R(W1,z1,Q0){if(!a.Has(W1)||!U.has(z1))return!1;let o8=a.Get(W1),n8=U.get(z1);return o8(n8,Q0)}function K(W1,z1){if(!Y1.Has(W1))return!1;return Y1.Get(W1)(z1)}function s(W1){return o1(W1)}let H1=j(R,K,s);return new D8($,M,H1,z)}Q.Compile=p8})(j0||(j0={}));var n1=(Q,Z=400)=>new Response(JSON.stringify(Q),{status:Z,headers:{"Content-Type":"application/json"}}),jG=(Q)=>{let Z=j0.Compile(Q);return async(Y,G)=>{try{let W=await Y.req.json();if(!Z.Check(W)){let X=Z.Errors(W).First();return n1({status:"error",code:"VALIDATION_FAILED",message:X?.message||"Invalid input",path:X?.path||"body"})}return Y.body=W,G?G():void 0}catch{return n1({status:"error",message:"Invalid JSON payload"})}}},DG=(Q)=>{let Z=Q.properties||{},Y=Object.keys(Z),G=Y.length;return async(X,J)=>{try{let H=X instanceof Object&&"req"in X,N=await(H?X.req:X).json();for(let A=0;A<G;A++){let O=Y[A];if(typeof N[O]!==Z[O]?.type)return n1({status:"error",code:"TYPE_MISMATCH",message:`Field '${O}' must be of type ${Z[O]?.type}`,field:O})}if(H)X.body=N;return J?J():void 0}catch{return n1({status:"error",message:"Invalid JSON payload"})}}},NG=(Q)=>{return async(Y,G)=>{try{let W=Y instanceof Object&&"req"in Y,J=await(W?Y.req:Y).json(),H=Q.safeParse(J);if(!H.success)return n1({status:"error",code:"ZOD_ERROR",errors:H.error.format()});if(W)Y.body=H.data;return G?G():void 0}catch{return n1({status:"error",message:"Invalid JSON payload"})}}};class P8{routes=[];globalMiddlewares=[];_server=null;_reusePort=!0;wsHandler=null;router={GET:{},POST:{},PUT:{},PATCH:{},DELETE:{}};dynamicRoutes=[];poolIdx=0;pool;poolMask;defaultHandler=(Q)=>new Response("404 Not Found",{status:404});constructor(Q){let Z=Q?.poolSize||Number(process.env.BARE_POOL_SIZE)||1024;if((Z&Z-1)!==0)Z=Math.pow(2,Math.ceil(Math.log2(Z)));this.poolMask=Z-1,this.pool=Array.from({length:Z},()=>new N0)}get server(){return this._server}set server(Q){this._server=Q}use(Q){if(Q&&typeof Q==="object"&&"install"in Q)Q.install(this);else this.globalMiddlewares.push(Q);return this}compileHandler(Q,Z){let Y=[...Z,Q];return(G)=>{let W=-1,X=(J)=>{if(J<=W)throw Error("next() called multiple times");W=J;let H=Y[J];if(!H)return;if(H.length===1)return H(G);if(H.length>2)return H(G.req,G.params,()=>X(J+1));return H(G,()=>X(J+1))};return X(0)}}get=(Q,...Z)=>{return this.routes.push({method:"GET",path:Q,handlers:Z}),this};post=(Q,...Z)=>{return this.routes.push({method:"POST",path:Q,handlers:Z}),this};put=(Q,...Z)=>{return this.routes.push({method:"PUT",path:Q,handlers:Z}),this};patch=(Q,...Z)=>{return this.routes.push({method:"PATCH",path:Q,handlers:Z}),this};delete=(Q,...Z)=>{return this.routes.push({method:"DELETE",path:Q,handlers:Z}),this};ws=(Q,Z)=>{return this.wsHandler={path:Q,handlers:Z},this};fetch=(Q,Z)=>{let Y=Q.url,G=Y.indexOf("/",8),W=G===-1?"/":Y.slice(G),X=Q.method,J=this.pool[this.poolIdx++&this.poolMask],H,w=this.router[X]?.[W];if(w)H=w(J.reset(Q,{}));else{let l=!1,D1=this.dynamicRoutes;for(let N1=0,D0=D1.length;N1<D0;N1++){let P1=D1[N1];if(P1.m===X){let s1=P1.r.exec(W);if(s1){let r1=Object.create(null);for(let K1=0;K1<P1.p.length;K1++)r1[P1.p[K1]]=s1[K1+1];H=P1.c(J.reset(Q,r1)),l=!0;break}}}if(!l)H=this.defaultHandler(J.reset(Q,{}))}if(H instanceof Response)return H;let N=J._status,A=new Headers,O=J._headers;for(let l in O)A.set(l.toLowerCase(),O[l]);let g1=(l)=>{if(l instanceof Response)return l;let D1=l!==null&&typeof l==="object";if(D1&&!A.has("content-type"))A.set("content-type","application/json");let N1=D1?JSON.stringify(l):l??"";return new Response(N1,{status:N,headers:A})};return H instanceof Promise?H.then(g1):g1(H)};compile(){for(let Q of this.routes){let Z=[...this.globalMiddlewares,...Q.handlers],Y=Z.pop()||((X)=>new Response("Not Found",{status:404})),G=Z,W=this.compileHandler(Y,G);if(Q.path.includes(":")){let X=[],J=Q.path.replace(/:([^/]+)/g,(H,w)=>{return X.push(w),"([^/]+)"});this.dynamicRoutes.push({m:Q.method,r:new RegExp(`^${J}$`),p:X,c:W})}else this.router[Q.method][Q.path]=W}this.defaultHandler=this.compileHandler((Q)=>new Response("404 Not Found",{status:404}),this.globalMiddlewares)}async listen(Q,Z){this.compile();let Y=Number(process.env.PORT)||3000,G=process.env.HOST||"0.0.0.0";if(typeof Q==="number")Y=Q;if(typeof Q==="string")G=Q;if(typeof Z==="number")Y=Z;return this._server=Bun.serve({hostname:G,port:Y,reusePort:this._reusePort,fetch:(W)=>this.fetch(W)}),console.log(`[BAREJS] \uD83D\uDE80 Server running at http://${G}:${Y}`),this._server}}var PG=async(Q,Z,Y)=>{let G=performance.now(),W=new URL(Q.url).pathname,X=await Y?.(),J=(performance.now()-G).toFixed(2),H=X instanceof Response?X.status:200,w=H>=500?"\x1B[31m":H>=400?"\x1B[33m":"\x1B[32m";return console.log(` \x1B[90m${new Date().toLocaleTimeString()}\x1B[0m \x1B[1m\x1B[38;5;117m${Q.method.padEnd(7)}\x1B[0m \x1B[38;5;250m${W}\x1B[0m ${w}${H}\x1B[0m \x1B[90m(${J}ms)\x1B[0m`),X};var bG=(Q={})=>{let Z=Q.origin||"*",Y=Q.methods||"GET,POST,PUT,PATCH,DELETE,OPTIONS";return async(W,X,J)=>{if(W.method==="OPTIONS")return new Response(null,{status:204,headers:{"Access-Control-Allow-Origin":Z,"Access-Control-Allow-Methods":Y,"Access-Control-Allow-Headers":"Content-Type, Authorization"}});let H=await J?.();if(H instanceof Response)H.headers.set("Access-Control-Allow-Origin",Z),H.headers.set("Access-Control-Allow-Methods",Y);return H}};import{join as SG}from"path";var CG=(Q="public")=>{return async(Z,Y)=>{if(Z.req.method!=="GET"&&Z.req.method!=="HEAD")return Y();let G=new URL(Z.req.url),W=decodeURIComponent(G.pathname).replace(/^\//,""),X=SG(process.cwd(),Q,W),J=Bun.file(X);if(await J.exists())return new Response(J);return Y()}};var b8=new TextEncoder,S8=async(Q,Z)=>{let Y=Bun.crypto.hmac("sha256",Z,Q);return Buffer.from(Y).toString("hex")},OG=async(Q,Z,Y)=>{let G=await S8(Q,Y);return Bun.crypto.timingSafeEqual(b8.encode(Z),b8.encode(G))},FG=(Q)=>{return async(Z,Y)=>{let G=Z.req.headers.get("Authorization");if(!G?.startsWith("Bearer "))return Z.status(401).json({status:"error",message:"Bearer token required"});let W=G.split(" ")[1];if(!W)return Z.status(401).json({status:"error",message:"Invalid token format"});let X=W.split(".");if(X.length!==2)return Z.status(401).json({status:"error",message:"Malformed token"});let[J,H]=X;try{let w=Buffer.from(J,"base64").toString();if(!await OG(w,H,Q))return Z.status(401).json({status:"error",message:"Invalid signature"});return Z.set("user",JSON.parse(w)),Y()}catch(w){return Z.status(401).json({status:"error",message:"Token verification failed"})}}};var xG={hash:(Q)=>Bun.password.hash(Q,{algorithm:"argon2id"}),verify:(Q,Z)=>Bun.password.verify(Q,Z)},gG=async(Q,Z)=>{let Y=JSON.stringify(Q),G=Buffer.from(Y).toString("base64"),W=await S8(Y,Z);return`${G}.${W}`};export{NG as zod,jG as typebox,CG as staticFile,DG as native,PG as logger,gG as createToken,bG as cors,FG as bareAuth,xG as Password,P8 as BareJS};
@@ -27,11 +27,11 @@ export declare class BareJS {
27
27
  install: (app: BareJS) => void;
28
28
  }): this;
29
29
  private compileHandler;
30
- get: (path: string, ...h: any[]) => this;
31
- post: (path: string, ...h: any[]) => this;
32
- put: (path: string, ...h: any[]) => this;
33
- patch: (path: string, ...h: any[]) => this;
34
- delete: (path: string, ...h: any[]) => this;
30
+ get: (path: string, ...handlers: [...Middleware[], Handler]) => this;
31
+ post: (path: string, ...handlers: [...Middleware[], Handler]) => this;
32
+ put: (path: string, ...handlers: [...Middleware[], Handler]) => this;
33
+ patch: (path: string, ...handlers: [...Middleware[], Handler]) => this;
34
+ delete: (path: string, ...handlers: [...Middleware[], Handler]) => this;
35
35
  ws: (path: string, handlers: WSHandlers) => this;
36
36
  fetch: (req: Request, server?: Server<any>) => any;
37
37
  compile(): void;
@@ -1,5 +1,13 @@
1
1
  export type Params = Record<string, string>;
2
2
  export type Next = () => Promise<any> | any;
3
+ /**
4
+ * 🎯 Hybrid Middleware Signature
5
+ * Supports Context-only (379ns path), Standard Middleware, and Legacy Style.
6
+ */
7
+ export type Middleware = ((ctx: Context) => Promise<any> | any) | ((ctx: Context, next: Next) => Promise<any> | any) | ((req: Request, params: Params, next: Next) => Promise<any> | any);
8
+ export type ContextHandler = (ctx: Context) => Promise<any> | any;
9
+ export type NativeHandler = (req: Request, params: Params) => Promise<any> | any;
10
+ export type Handler = ContextHandler | NativeHandler;
3
11
  export declare class Context {
4
12
  req: Request;
5
13
  params: Params;
@@ -11,31 +19,24 @@ export declare class Context {
11
19
  private _cookies;
12
20
  /**
13
21
  * 🏎️ Object Pool Reset
14
- * Reuses the Context instance. Clears all previous request data.
22
+ * Memory-stable wipe to prevent GC spikes and keep nanosecond performance.
15
23
  */
16
24
  reset(req: Request, params: Params): this;
17
25
  header(key: string): string | null;
18
26
  query(key: string): string | null;
19
- /**
20
- * 🍪 Lazy Cookie Parser (Unbreakable & TS-Safe)
21
- */
22
27
  cookie(name: string): string | undefined;
23
28
  get ip(): string | null;
24
29
  status(code: number): this;
25
30
  setHeader(key: string, value: string): this;
31
+ set(key: string, value: string): this;
32
+ set(key: string, value: unknown): void;
33
+ get<T = any>(key: string): T;
26
34
  setCookie(name: string, value: string, options?: string): this;
27
35
  json(data: any): any;
28
36
  text(data: string): string;
29
37
  html(data: string): string;
30
38
  redirect(url: string, code?: number): null;
31
- set(k: string, v: any): void;
32
- get<T = any>(k: string): T;
33
39
  }
34
- /**
35
- * 🎯 Hybrid Middleware Signature
36
- */
37
- export type Middleware = ((ctx: Context, next: Next) => Promise<any> | any) | ((req: Request, params: Params, next: Next) => Promise<any> | any);
38
- export type Handler = (ctx: Context) => Promise<any> | any;
39
40
  export interface WSHandlers {
40
41
  open?: (ws: any) => void;
41
42
  message?: (ws: any, message: string | Buffer) => void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "barejs",
3
- "version": "0.1.21",
3
+ "version": "0.1.23",
4
4
  "author": "xarhang",
5
5
  "description": "High-performance JIT-specialized web framework for Bun",
6
6
  "main": "./dist/index.js",
package/src/bare.ts CHANGED
@@ -181,17 +181,12 @@
181
181
  // return this.server;
182
182
  // }
183
183
  // }
184
-
185
184
  // All comments in English
186
185
  import { Context, type Middleware, type Handler, type WSHandlers, type Next } from './context';
187
186
  import { typebox, zod, native } from './validators';
188
- import { join } from 'node:path';
189
187
 
190
- // Exporting Types and Context
191
188
  export * from './context';
192
189
  export * from './validators';
193
-
194
- // Re-exporting core types specifically for convenience
195
190
  export type { Middleware, Handler, WSHandlers, Next };
196
191
 
197
192
  import type { Server, ServerWebSocket } from "bun";
@@ -213,22 +208,17 @@ export class BareJS {
213
208
 
214
209
  private dynamicRoutes: Array<{ m: string, r: RegExp, p: string[], c: Function }> = [];
215
210
 
216
- // High-Performance Object Pooling State
217
211
  private poolIdx = 0;
218
212
  private pool: Context[];
219
213
  private poolMask: number;
220
214
 
221
- // Pre-compiled fallback for 404s and Global Middleware execution
222
215
  private defaultHandler: Function = (ctx: Context) => new Response('404 Not Found', { status: 404 });
223
216
 
224
217
  constructor(options?: { poolSize?: number }) {
225
218
  let size = options?.poolSize || Number(process.env.BARE_POOL_SIZE) || 1024;
226
-
227
- // Ensure size is a Power of 2 for Bitwise Optimization
228
219
  if ((size & (size - 1)) !== 0) {
229
220
  size = Math.pow(2, Math.ceil(Math.log2(size)));
230
221
  }
231
-
232
222
  this.poolMask = size - 1;
233
223
  this.pool = Array.from({ length: size }, () => new Context());
234
224
  }
@@ -247,48 +237,33 @@ export class BareJS {
247
237
 
248
238
  private compileHandler(handler: Handler, middlewares: Middleware[]) {
249
239
  const pipeline = [...middlewares, handler];
250
-
240
+
251
241
  return (ctx: Context) => {
252
242
  let index = -1;
253
-
254
243
  const runner = (idx: number): any => {
255
244
  if (idx <= index) throw new Error('next() called multiple times');
256
245
  index = idx;
257
-
258
246
  const fn = pipeline[idx];
259
247
  if (!fn) return;
260
248
 
261
- return (fn as any).length > 2
262
- ? (fn as any)(ctx.req, ctx.params, () => runner(idx + 1))
263
- : (fn as any)(ctx, () => runner(idx + 1));
249
+ if (fn.length === 1) return (fn as any)(ctx);
250
+ if (fn.length > 2) return (fn as any)(ctx.req, ctx.params, () => runner(idx + 1));
251
+ return (fn as any)(ctx, () => runner(idx + 1));
264
252
  };
265
253
 
266
- const result = runner(0);
267
-
268
- // Fast-path: Synchronous Result
269
- if (!(result instanceof Promise)) {
270
- if (result && result.constructor === Object) {
271
- return Response.json(result, { status: ctx._status });
272
- }
273
- return result;
274
- }
275
-
276
- // Slow-path: Asynchronous Result
277
- return result.then((res) => {
278
- if (res && res.constructor === Object) {
279
- return Response.json(res, { status: ctx._status });
280
- }
281
- return res;
282
- });
254
+ return runner(0);
283
255
  };
284
256
  }
285
257
 
286
- public get = (path: string, ...h: any[]) => { this.routes.push({ method: "GET", path, handlers: h }); return this; };
287
- public post = (path: string, ...h: any[]) => { this.routes.push({ method: "POST", path, handlers: h }); return this; };
288
- public put = (path: string, ...h: any[]) => { this.routes.push({ method: "PUT", path, handlers: h }); return this; };
289
- public patch = (path: string, ...h: any[]) => { this.routes.push({ method: "PATCH", path, handlers: h }); return this; };
290
- public delete = (path: string, ...h: any[]) => { this.routes.push({ method: "DELETE", path, handlers: h }); return this; };
291
-
258
+ public get = (path: string, ...handlers: [...Middleware[], Handler]) => {
259
+ this.routes.push({ method: "GET", path, handlers });
260
+ return this;
261
+ };
262
+ public post = (path: string, ...handlers: [...Middleware[], Handler]) => { this.routes.push({ method: "POST", path, handlers }); return this; };
263
+ public put = (path: string, ...handlers: [...Middleware[], Handler]) => { this.routes.push({ method: "PUT", path, handlers }); return this; };
264
+ public patch = (path: string, ...handlers: [...Middleware[], Handler]) => { this.routes.push({ method: "PATCH", path, handlers }); return this; };
265
+ public delete = (path: string, ...handlers: [...Middleware[], Handler]) => { this.routes.push({ method: "DELETE", path, handlers }); return this; };
266
+
292
267
  public ws = (path: string, handlers: WSHandlers) => {
293
268
  this.wsHandler = { path, handlers };
294
269
  return this;
@@ -300,34 +275,64 @@ export class BareJS {
300
275
  const path = pathStart === -1 ? '/' : url.slice(pathStart);
301
276
  const method = req.method;
302
277
 
278
+ const ctx = this.pool[this.poolIdx++ & this.poolMask]!;
279
+ let res: any;
280
+
303
281
  // 1. Static O(1) Lookup
304
282
  const handler = this.router[method]?.[path];
305
283
  if (handler) {
306
- return handler(this.pool[this.poolIdx++ & this.poolMask]!.reset(req, {}));
307
- }
308
-
309
- // 2. Dynamic RegExp Lookup
310
- for (let i = 0, l = this.dynamicRoutes.length; i < l; i++) {
311
- const d = this.dynamicRoutes[i]!;
312
- if (d.m === method && d.r.test(path)) {
313
- const match = d.r.exec(path)!;
314
- const params = Object.create(null);
315
- for (let k = 0; k < d.p.length; k++) {
316
- params[d.p[k]!] = match[k + 1];
284
+ res = handler(ctx.reset(req, {}));
285
+ } else {
286
+ // 2. Dynamic Lookup (Fixed with your null-check logic)
287
+ let matched = false;
288
+ const routes = this.dynamicRoutes;
289
+ for (let i = 0, l = routes.length; i < l; i++) {
290
+ const d = routes[i]!;
291
+ if (d.m === method) {
292
+ const match = d.r.exec(path);
293
+ if (match) {
294
+ const params = Object.create(null);
295
+ for (let k = 0; k < d.p.length; k++) {
296
+ params[d.p[k]!] = match[k + 1];
297
+ }
298
+ // Ensure ctx is reset with params before passing to dynamic handler
299
+ res = d.c(ctx.reset(req, params));
300
+ matched = true;
301
+ break;
302
+ }
317
303
  }
318
- return d.c(this.pool[this.poolIdx++ & this.poolMask]!.reset(req, params));
319
304
  }
305
+ if (!matched) res = this.defaultHandler(ctx.reset(req, {}));
320
306
  }
321
307
 
322
- // 3. Fallback: Executes Global Middlewares (Logger, StaticFile) + 404
323
- return this.defaultHandler(this.pool[this.poolIdx++ & this.poolMask]!.reset(req, {}));
308
+ // --- Response Processing ---
309
+ if (res instanceof Response) return res;
310
+
311
+ const status = ctx._status;
312
+ const h = new Headers();
313
+ const raw = ctx._headers!;
314
+
315
+ // Standardize headers (Fixes the 'null' error in tests)
316
+ for (const key in raw) {
317
+ h.set(key.toLowerCase(), raw[key]!);
318
+ }
319
+
320
+ const build = (resolved: any): Response => {
321
+ if (resolved instanceof Response) return resolved;
322
+ const isObj = resolved !== null && typeof resolved === 'object';
323
+ if (isObj && !h.has('content-type')) h.set('content-type', 'application/json');
324
+
325
+ const body = isObj ? JSON.stringify(resolved) : (resolved ?? "");
326
+ return new Response(body, { status, headers: h });
327
+ };
328
+
329
+ return res instanceof Promise ? res.then(build) : build(res);
324
330
  };
325
331
 
326
332
  public compile() {
327
- // Compile registered routes
328
333
  for (const route of this.routes) {
329
334
  const pipeline = [...this.globalMiddlewares, ...route.handlers];
330
- const handler = pipeline.pop();
335
+ const handler = pipeline.pop() || ((ctx: Context) => new Response('Not Found', { status: 404 }));
331
336
  const middlewares = pipeline as Middleware[];
332
337
  const compiled = this.compileHandler(handler, middlewares);
333
338
 
@@ -340,7 +345,9 @@ export class BareJS {
340
345
  }
341
346
  }
342
347
 
343
- // PRE-COMPILE the Fallback Handler (Critical for 404 Middleware execution)
348
+ /**
349
+ * ✅ [FIX 6] Default Handler: Compile after global middlewares are registered
350
+ */
344
351
  this.defaultHandler = this.compileHandler(
345
352
  (ctx: Context) => new Response('404 Not Found', { status: 404 }),
346
353
  this.globalMiddlewares
@@ -351,28 +358,16 @@ export class BareJS {
351
358
  this.compile();
352
359
  let port = Number(process.env.PORT) || 3000;
353
360
  let host = process.env.HOST || '0.0.0.0';
354
-
355
361
  if (typeof arg1 === 'number') port = arg1;
356
362
  if (typeof arg1 === 'string') host = arg1;
357
363
  if (typeof arg2 === 'number') port = arg2;
358
364
 
359
- const serveOptions: any = {
365
+ this._server = Bun.serve({
360
366
  hostname: host,
361
367
  port: port,
362
368
  reusePort: this._reusePort,
363
- fetch: (req: Request, server: Server<any>) => this.fetch(req, server),
364
- };
365
-
366
- if (this.wsHandler) {
367
- serveOptions.websocket = {
368
- open: (ws: any) => this.wsHandler?.handlers.open?.(ws),
369
- message: (ws: any, msg: any) => this.wsHandler?.handlers.message?.(ws, msg),
370
- close: (ws: any, code: number, res: string) => this.wsHandler?.handlers.close?.(ws, code, res),
371
- drain: (ws: any) => this.wsHandler?.handlers.drain?.(ws),
372
- };
373
- }
374
-
375
- this._server = Bun.serve(serveOptions);
369
+ fetch: (req: Request) => this.fetch(req),
370
+ });
376
371
  console.log(`[BAREJS] 🚀 Server running at http://${host}:${port}`);
377
372
  return this._server;
378
373
  }
package/src/context.ts CHANGED
@@ -1,27 +1,44 @@
1
+ // context.ts
2
+
1
3
  export type Params = Record<string, string>;
2
4
  export type Next = () => Promise<any> | any;
3
5
 
6
+ /**
7
+ * 🎯 Hybrid Middleware Signature
8
+ * Supports Context-only (379ns path), Standard Middleware, and Legacy Style.
9
+ */
10
+ export type Middleware =
11
+ | ((ctx: Context) => Promise<any> | any)
12
+ | ((ctx: Context, next: Next) => Promise<any> | any)
13
+ | ((req: Request, params: Params, next: Next) => Promise<any> | any);
14
+
15
+ // export type Handler = (ctx: Context) => Promise<any> | any;
16
+ export type ContextHandler = (ctx: Context) => Promise<any> | any;
17
+ export type NativeHandler = (req: Request, params: Params) => Promise<any> | any;
18
+
19
+ // 2. The Final Handler: This allows either (ctx) OR (req, params)
20
+ export type Handler = ContextHandler | NativeHandler;
4
21
  export class Context {
5
22
  public req!: Request;
6
23
  public params!: Params;
7
24
  public _status: number = 200;
8
-
25
+
9
26
  // Clean prototype-less store for middleware data
10
27
  public store: any = Object.create(null);
11
-
28
+
12
29
  // Holds parsed JSON or form data from Validators
13
30
  public body: any = null;
14
-
31
+
15
32
  // Internal tracking for response construction
16
33
  public _headers: Record<string, string> = {};
17
-
34
+
18
35
  // Lazy-loaded caches
19
36
  private _searchParams: URLSearchParams | null = null;
20
37
  private _cookies: Map<string, string> | null = null;
21
38
 
22
39
  /**
23
40
  * 🏎️ Object Pool Reset
24
- * Reuses the Context instance. Clears all previous request data.
41
+ * Memory-stable wipe to prevent GC spikes and keep nanosecond performance.
25
42
  */
26
43
  public reset(req: Request, params: Params): this {
27
44
  this.req = req;
@@ -29,20 +46,21 @@ export class Context {
29
46
  this._status = 200;
30
47
  this.body = null;
31
48
  this._headers = {};
32
- this._searchParams = null;
49
+ this._searchParams = null;
33
50
  this._cookies = null;
34
-
35
- // Memory-stable wipe
51
+
52
+ // Wipe store without re-allocating object
36
53
  for (const key in this.store) {
37
54
  delete this.store[key];
38
55
  }
39
-
56
+
40
57
  return this;
41
58
  }
42
59
 
43
60
  // --- REQUEST HELPERS ---
44
61
 
45
62
  public header(key: string): string | null {
63
+
46
64
  return this.req.headers.get(key);
47
65
  }
48
66
 
@@ -53,29 +71,18 @@ export class Context {
53
71
  return this._searchParams.get(key);
54
72
  }
55
73
 
56
- /**
57
- * 🍪 Lazy Cookie Parser (Unbreakable & TS-Safe)
58
- */
59
74
  public cookie(name: string): string | undefined {
60
- let cookies = this._cookies;
61
-
62
- if (!cookies) {
63
- cookies = new Map();
75
+ if (!this._cookies) {
76
+ this._cookies = new Map();
64
77
  const header = this.req.headers.get("cookie");
65
78
  if (header) {
66
79
  const matches = header.matchAll(/([^=\s]+)=([^;]+)/g);
67
80
  for (const match of matches) {
68
- const key = match[1];
69
- const value = match[2];
70
- if (key && value) {
71
- cookies.set(key, value);
72
- }
81
+ if (match[1] && match[2]) this._cookies.set(match[1], match[2]);
73
82
  }
74
83
  }
75
- this._cookies = cookies;
76
84
  }
77
-
78
- return cookies.get(name);
85
+ return this._cookies.get(name);
79
86
  }
80
87
 
81
88
  public get ip(): string | null {
@@ -84,9 +91,9 @@ export class Context {
84
91
 
85
92
  // --- RESPONSE HELPERS ---
86
93
 
87
- public status(code: number): this {
88
- this._status = code;
89
- return this;
94
+ public status(code: number): this {
95
+ this._status = code;
96
+ return this;
90
97
  }
91
98
 
92
99
  public setHeader(key: string, value: string): this {
@@ -94,23 +101,43 @@ export class Context {
94
101
  return this;
95
102
  }
96
103
 
104
+ // Header setter → chainable
105
+ public set(key: string, value: string): this;
106
+
107
+ // State setter → non-chainable
108
+ public set(key: string, value: unknown): void;
109
+
110
+ public set(key: string, value: unknown): this | void {
111
+ if (typeof value === "string") {
112
+ this._headers[key.toLowerCase()] = value;
113
+ return this;
114
+ }
115
+
116
+ this.store[key] = value;
117
+ }
118
+
119
+ public get<T = any>(key: string): T {
120
+ return this.store[key];
121
+ }
122
+
97
123
  public setCookie(name: string, value: string, options: string = ""): this {
98
124
  this.setHeader("set-cookie", `${name}=${value}; ${options}`);
99
125
  return this;
100
126
  }
101
127
 
128
+ // Finalizer hints
102
129
  public json(data: any) {
103
- this.setHeader('content-type', 'application/json');
130
+ this._headers['content-type'] = 'application/json';
104
131
  return data;
105
132
  }
106
133
 
107
134
  public text(data: string) {
108
- this.setHeader('content-type', 'text/plain; charset=utf-8');
135
+ this._headers['content-type'] = 'text/plain; charset=utf-8';
109
136
  return data;
110
137
  }
111
138
 
112
139
  public html(data: string) {
113
- this.setHeader('content-type', 'text/html; charset=utf-8');
140
+ this._headers['content-type'] = 'text/html; charset=utf-8';
114
141
  return data;
115
142
  }
116
143
 
@@ -119,21 +146,8 @@ export class Context {
119
146
  this.setHeader('location', url);
120
147
  return null;
121
148
  }
122
-
123
- // --- STATE MANAGEMENT ---
124
- public set(k: string, v: any): void { this.store[k] = v; }
125
- public get<T = any>(k: string): T { return this.store[k]; }
126
149
  }
127
150
 
128
- /**
129
- * 🎯 Hybrid Middleware Signature
130
- */
131
- export type Middleware =
132
- | ((ctx: Context, next: Next) => Promise<any> | any)
133
- | ((req: Request, params: Params, next: Next) => Promise<any> | any);
134
-
135
- export type Handler = (ctx: Context) => Promise<any> | any;
136
-
137
151
  export interface WSHandlers {
138
152
  open?: (ws: any) => void;
139
153
  message?: (ws: any, message: string | Buffer) => void;