barejs 0.1.26 โ†’ 0.1.28

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/README.md CHANGED
@@ -1,24 +1,34 @@
1
+ This version of the README integrates the **`bun create`** workflow and the **Hybrid Handler** support we just finalized. It emphasizes that users can now skip manual setup entirely by using the CLI.
2
+
3
+ ---
4
+
1
5
  # ๐Ÿš€ BareJS
2
6
 
3
- BareJS is an ultra-high-performance web engine built on the **Bun** runtime, specifically architected for minimalism and the lowest possible latency. It represents the pinnacle of **Mechanical Sympathy**, ensuring that every line of software execution aligns perfectly with how modern CPUs process data.
7
+ BareJS is an ultra-high-performance web engine built on the **Bun** runtime, specifically architected for minimalism and the lowest possible latency. It represents the pinnacle of **Mechanical Sympathy**, ensuring software execution aligns perfectly with modern CPU data processing.
4
8
 
5
9
  <p align="left">
6
- <a href="[https://github.com/xarhang/bareJS/actions](https://github.com/xarhang/bareJS/actions)">
7
- <img src="[https://github.com/xarhang/bareJS/actions/workflows/bench.yml/badge.svg](https://github.com/xarhang/bareJS/actions/workflows/bench.yml/badge.svg)" alt="Performance Benchmark">
8
- </a>
9
- <a href="[https://xarhang.github.io/bareJS/dev/benchmarks/](https://xarhang.github.io/bareJS/dev/benchmarks/)">
10
- <img src="[https://img.shields.io/badge/Performance-Dashboard-blueviolet?style=flat-square&logo=speedtest](https://img.shields.io/badge/Performance-Dashboard-blueviolet?style=flat-square&logo=speedtest)" alt="Performance Dashboard">
11
- </a>
12
- <a href="[https://bun.sh](https://bun.sh)">
13
- <img src="[https://img.shields.io/badge/Bun-%3E%3D1.0.0-black?style=flat-square&logo=bun](https://img.shields.io/badge/Bun-%3E%3D1.0.0-black?style=flat-square&logo=bun)" alt="Bun Version">
14
- </a>
10
+ <a href="https://github.com/xarhang/bareJS/tags">
11
+ <img src="https://img.shields.io/github/v/tag/xarhang/bareJS?style=flat-square&logo=github&label=github&color=black" alt="GitHub Tag">
12
+ </a>
13
+ <a href="https://www.npmjs.com/package/barejs">
14
+ <img src="https://img.shields.io/npm/v/barejs?style=flat-square&logo=npm&color=CB3837" alt="NPM Version">
15
+ </a>
16
+ <a href="https://github.com/xarhang/bareJS/actions/workflows/bench.yml">
17
+ <img src="https://github.com/xarhang/bareJS/actions/workflows/bench.yml/badge.svg" alt="Performance Benchmark">
18
+ </a>
19
+ <a href="https://xarhang.github.io/bareJS/dev/benchmarks/">
20
+ <img src="https://img.shields.io/badge/Performance-Dashboard-blueviolet?style=flat-square&logo=speedtest" alt="Performance Dashboard">
21
+ </a>
22
+ <a href="https://bun.sh">
23
+ <img src="https://img.shields.io/badge/Bun-%3E%3D1.0.0-black?style=flat-square&logo=bun" alt="Bun Version">
24
+ </a>
15
25
  </p>
16
26
 
17
27
  ---
18
28
 
19
29
  ## ๐Ÿ“Š Performance Benchmarks: Breaking the Nanosecond Barrier
20
30
 
21
- BareJS is designed to be the definitive baseline for speed in the JavaScript ecosystem. By ruthlessly eliminating common framework overhead, we consistently achieve sub-microsecond latency.
31
+ BareJS is the definitive baseline for speed in the JavaScript ecosystem. By ruthlessly eliminating common framework overhead, we consistently achieve sub-microsecond latency.
22
32
 
23
33
  ### ๐Ÿ“ˆ Global Latency Comparison (Lower is Better)
24
34
  <!-- MARKER: PERFORMANCE_TABLE_START -->
@@ -29,110 +39,110 @@ BareJS is designed to be the definitive baseline for speed in the JavaScript eco
29
39
  | Elysia | 2.26 ยตs | 4.19x slower |
30
40
  | Hono | 4.02 ยตs | 7.46x slower |
31
41
 
32
- > Last Updated: Tue, 06 Jan 2026 19:23:27 GMT
42
+ > Last Updated: Tue, 07 Jan 2026 14:19:23:27 GMT
33
43
 
34
44
  <!-- MARKER: PERFORMANCE_TABLE_END -->
35
45
 
36
46
  <!-- NOTE: The table above is automatically updated via scripts/update-readme.ts -->
37
47
 
48
+
49
+ ## ๐Ÿ› ๏ธ Rapid Scaffolding (Recommended)
50
+
51
+ The fastest way to initialize a production-ready environment is via the official **`bun create`** command. This scaffolds a pre-configured project with optimized `tsconfig.json` and production build scripts.
52
+
53
+ ```bash
54
+ bun create barejs my-app
55
+ cd my-app
56
+ bun dev
57
+
58
+ ```
59
+
38
60
  ---
39
61
 
40
62
  ## ๐Ÿ› Architectural Engineering Deep-Dive
41
63
 
42
- Why is BareJS significantly faster than established frameworks? The answer lies in three core engineering pillars.
43
-
44
64
  ### 1. Zero-Allocation Circular Context Pool
45
65
 
46
- Traditional frameworks create a new Request or Context object for every single incoming hit, triggering constant Garbage Collector (GC) activity and unpredictable latency spikes.
47
-
48
- * **Pre-allocation**: BareJS pre-allocates a fixed array of Context objects during startup.
49
- * **The Masking Logic**: It utilizes **Bitwise Masking** (`idx & mask`) to recycle these objects instantly. For a pool of 1024, the engine performs a bitwise `AND` operation, which is hardware-accelerated and exponentially faster than standard modulo division.
50
- * **Result**: Zero GC pressure during the request-response cycle.
66
+ Traditional frameworks create new objects for every hit, triggering Garbage Collector (GC) spikes. BareJS pre-allocates a fixed array of Context objects and utilizes **Bitwise Masking** (`idx & mask`) for instant recycling.
51
67
 
52
68
  ### 2. Synchronous Fast-Path Execution
53
69
 
54
- The "Promise Tax" is a silent performance killer. Most modern frameworks wrap every route in an `async` wrapper, forcing a ~800ns penalty even for simple operations.
55
-
56
- * **Automatic Detection**: BareJS identifies if your handler is synchronous.
57
- * **Queue Bypassing**: Synchronous handlers bypass the Microtask queue entirely, executing directly on the call stack.
70
+ BareJS identifies if your handler is synchronous. Synchronous handlers bypass the Microtask queue entirely, executing directly on the call stack to avoid the "Promise Tax."
58
71
 
59
72
  ### 3. JIT Route Compilation (The "Baking" Phase)
60
73
 
61
- Unlike standard routers that perform string matching or tree traversal during the request, BareJS uses a Compilation Step.
62
-
63
- * **Static Jump Table**: During `app.listen()`, the entire route tree is transformed into a static jump table.
64
- * **Flat Middleware Chains**: Middleware is recursively "baked" into a single flat execution function, removing the need for array iteration while the server is running.
74
+ During `app.listen()`, the route tree is transformed into a **Static Jump Table**. Middleware is recursively "baked" into a single flat execution function, removing array iteration overhead at runtime.
65
75
 
66
76
  ---
67
77
 
68
78
  ## โšก Comprehensive Usage Guide
69
79
 
70
- BareJS provides a unified API. All core utilities, validators, and types are exported from a single point to ensure your code remains as clean as the engine is fast.
71
-
72
- ### ๐Ÿ“ฆ Installation
73
-
74
- ```bash
75
- bun add barejs
76
-
77
- ```
80
+ BareJS supports **Hybrid Handler Signatures**, allowing you to choose between maximum performance (Context) or standard Web APIs (Request/Params).
78
81
 
79
- ### ๐Ÿš€ Full Implementation Manual
82
+ ### ๐Ÿš€ Implementation Example
80
83
 
81
84
  ```typescript
82
- import { BareJS, typebox, zod, type Context } from 'barejs';
83
- import * as TB from '@sinclair/typebox';
85
+ import { BareJS, type Context, type Params } from 'barejs';
84
86
 
85
- // 1. Core Initialization
86
- // poolSize must be a power of 2 (1024, 2048, 4096) for bitwise masking
87
87
  const app = new BareJS({
88
- poolSize: 2048
88
+ poolSize: 2048 // Power of 2 required for hardware-accelerated masking
89
89
  });
90
90
 
91
- // 2. Optimized Global Middleware
92
- app.use((ctx, next) => {
93
- ctx.set('server_id', 'BARE_NODE_01');
94
- return next();
91
+ // Style A: Zero-Allocation Context Pool (The 379ns Path)
92
+ app.get('/ctx', (ctx: Context) => ctx.json({ mode: "pooled" }));
93
+
94
+ // Style B: Native Request/Params (Legacy/Standard compatibility)
95
+ app.get('/user/:id', (req: Request, params: Params) => {
96
+ return { id: params.id, method: "native" };
95
97
  });
96
98
 
97
- // 3. High-Speed Static Route (Sync Fast-Path: ~571ns)
98
- app.get('/ping', () => "pong");
99
+ app.listen(3000);
99
100
 
100
- // 4. JIT Compiled Validation (TypeBox)
101
- // Data in ctx.body is automatically typed and validated
102
- const UserSchema = TB.Type.Object({
103
- username: TB.Type.String(),
104
- age: TB.Type.Number()
105
- });
101
+ ```
102
+ ---
103
+ ### โšก Example: Using Protected & Public Groups
104
+ Since you wanted separate variables for your groups:
106
105
 
107
- app.post('/register', typebox(UserSchema), (ctx: Context) => {
108
- const name = ctx.body.username;
109
- return { status: 'created', user: name };
110
- });
106
+ ```TypeScript
107
+ import { BareJS, BareRouter, type Context } from 'barejs';
108
+ import { bareAuth, createToken } from 'barejs'; // Your new script
109
+
110
+ const app = new BareJS();
111
+ const SECRET = process.env.JWT_SECRET || "super-secret-key";
111
112
 
112
- // 5. Native Dynamic Parameters
113
- app.get('/user/:id', (ctx) => {
114
- return { userId: ctx.params.id };
113
+ // --- 1. Public Auth Router ---
114
+ const authRouter = new BareRouter("/auth");
115
+
116
+ authRouter.post("/login", async (ctx: Context) => {
117
+ // Logic to check DB password here...
118
+ const token = await createToken({ id: 1, name: "Admin" }, SECRET);
119
+ return { token };
115
120
  });
116
121
 
117
- // 6. Hardware-Accelerated WebSockets
118
- app.ws('/stream', {
119
- message(ws, msg) {
120
- ws.send(`BareJS Echo: ${msg}`);
121
- }
122
+ // --- 2. Protected Data Router ---
123
+ // Pass your bareAuth middleware directly to the constructor
124
+ const protectedRoute = new BareRouter("", [bareAuth(SECRET)]);
125
+
126
+ protectedRoute.group("/api/v1", (v1) => {
127
+ v1.get("/me", (ctx: Context) => {
128
+ // ctx.get('user') works because of ctx.set('user', ...) in bareAuth
129
+ return { user: ctx.get('user') };
130
+ });
131
+
132
+ v1.get("/dashboard", (ctx: Context) => ({ stats: [10, 20, 30] }));
122
133
  });
123
134
 
124
- // 7. The Baking Phase
125
- // app.listen() triggers JIT compilation of all routes
126
- app.listen(3000);
127
- console.log("BareJS is screaming on port 3000");
135
+ // --- 3. Mount ---
136
+ app.use(authRouter);
137
+ app.use(protectedRoute);
128
138
 
139
+ app.listen(3000);
129
140
  ```
130
-
131
141
  ---
132
142
 
133
- ## ๐Ÿ”Œ Advanced Deployment: BareJS JIT & Env
143
+ ## ๐Ÿ”Œ Advanced Deployment
134
144
 
135
- To achieve the benchmarked numbers, ensure you deploy using the BareJS optimized runtime environment variables.
145
+ To achieve the benchmarked numbers, ensure you deploy using the BareJS optimized runtime environment.
136
146
 
137
147
  | Variable | Description | Default |
138
148
  | --- | --- | --- |
@@ -142,7 +152,7 @@ To achieve the benchmarked numbers, ensure you deploy using the BareJS optimized
142
152
  **Deployment Command:**
143
153
 
144
154
  ```bash
145
- BARE_POOL_SIZE=4096 bun run index.ts
155
+ BARE_POOL_SIZE=4096 NODE_ENV=production bun run index.ts
146
156
 
147
157
  ```
148
158
 
@@ -153,10 +163,13 @@ BARE_POOL_SIZE=4096 bun run index.ts
153
163
  * [x] Zero-Allocation Context Pooling
154
164
  * [x] Bitwise Masking Optimization
155
165
  * [x] JIT Route Compilation
156
- * [x] Unified Export API (Typebox/Zod/Native)
166
+ * [x] Hybrid Handler Signatures (Context & Native)
167
+ * [x] Route Grouping: Zero-overhead route organization via JIT flattening.
168
+ * [x] **Native Cluster Mode Support**: Automatic horizontal scaling across CPU cores.
157
169
  * [ ] **Direct Buffer Response**: Aiming for 400ns latency by writing directly to the TCP stream.
158
- * [ ] **Native Cluster Mode Support**: Automatic horizontal scaling across CPU cores.
170
+
159
171
 
160
172
  ---
161
173
 
162
- **Maintained by [xarhang]** | **License: MIT**
174
+ **Maintained by [xarhang]** | **License: MIT**
175
+
package/dist/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  // @bun
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};
2
+ var h8=Object.defineProperty;var y0=(Q,Z)=>{for(var Y in Z)h8(Q,Y,{get:Z[Y],enumerable:!0,configurable:!0,set:(G)=>Z[Y]=()=>G})};class P0{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}}class E1{prefix;groupMiddleware;routes=[];constructor(Q="",Z=[]){this.prefix=Q;this.groupMiddleware=Z}_add(Q,Z,Y){let G=(this.prefix+Z).replace(/\/+/g,"/")||"/";return this.routes.push({method:Q.toUpperCase(),path:G,handlers:[...this.groupMiddleware,...Y]}),this}get=(Q,...Z)=>this._add("GET",Q,Z);post=(Q,...Z)=>this._add("POST",Q,Z);put=(Q,...Z)=>this._add("PUT",Q,Z);patch=(Q,...Z)=>this._add("PATCH",Q,Z);delete=(Q,...Z)=>this._add("DELETE",Q,Z);group=(Q,...Z)=>{let Y=Z.pop(),G=Z,W=new E1((this.prefix+Q).replace(/\/+/g,"/"),[...this.groupMiddleware,...G]);return Y(W),this.routes.push(...W.routes),this}}function Z0(Q){return r(Q)&&globalThis.Symbol.asyncIterator in Q}function G0(Q){return r(Q)&&globalThis.Symbol.iterator in Q}function W0(Q){return Q instanceof globalThis.Promise}function V1(Q){return Q instanceof Date&&globalThis.Number.isFinite(Q.getTime())}function T1(Q){return Q instanceof globalThis.Uint8Array}function X0(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 S1(Q){return Q===null}function b1(Q){return typeof Q==="boolean"}function D(Q){return typeof Q==="number"}function $0(Q){return globalThis.Number.isInteger(Q)}function e(Q){return typeof Q==="bigint"}function f(Q){return typeof Q==="string"}function z0(Q){return typeof Q==="function"}function C1(Q){return typeof Q==="symbol"}function J0(Q){return e(Q)||b1(Q)||S1(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={};y0(Y1,{Set:()=>l8,Has:()=>u8,Get:()=>s8,Entries:()=>t8,Delete:()=>c8,Clear:()=>v8});var I1=new Map;function t8(){return new Map(I1)}function v8(){return I1.clear()}function c8(Q){return I1.delete(Q)}function u8(Q){return I1.has(Q)}function l8(Q,Z){I1.set(Q,Z)}function s8(Q){return I1.get(Q)}var a={};y0(a,{Set:()=>YQ,Has:()=>QQ,Get:()=>ZQ,Entries:()=>r8,Delete:()=>e8,Clear:()=>a8});var d1=new Map;function r8(){return new Map(d1)}function a8(){return d1.clear()}function e8(Q){return d1.delete(Q)}function QQ(Q){return d1.has(Q)}function YQ(Q,Z){d1.set(Q,Z)}function ZQ(Q){return d1.get(Q)}function Z1(Q){return Array.isArray(Q)}function p0(Q){return typeof Q==="bigint"}function q0(Q){return typeof Q==="boolean"}function H0(Q){return Q instanceof globalThis.Date}function R1(Q){return typeof Q==="number"}function I(Q){return typeof Q==="object"&&Q!==null}function L0(Q){return Q instanceof globalThis.RegExp}function n(Q){return typeof Q==="string"}function M0(Q){return Q instanceof globalThis.Uint8Array}function J1(Q){return Q===void 0}function GQ(Q){return globalThis.Object.freeze(Q).map((Z)=>h1(Z))}function WQ(Q){return Q}function XQ(Q){return Q}function $Q(Q){return Q}function zQ(Q){let Z={};for(let Y of Object.getOwnPropertyNames(Q))Z[Y]=h1(Q[Y]);for(let Y of Object.getOwnPropertySymbols(Q))Z[Y]=h1(Q[Y]);return globalThis.Object.freeze(Z)}function h1(Q){return Z1(Q)?GQ(Q):H0(Q)?WQ(Q):M0(Q)?XQ(Q):L0(Q)?$Q(Q):I(Q)?zQ(Q):Q}function JQ(Q){return Q.map((Z)=>A0(Z))}function qQ(Q){return new Date(Q.getTime())}function HQ(Q){return new Uint8Array(Q)}function LQ(Q){return new RegExp(Q.source,Q.flags)}function MQ(Q){let Z={};for(let Y of Object.getOwnPropertyNames(Q))Z[Y]=A0(Q[Y]);for(let Y of Object.getOwnPropertySymbols(Q))Z[Y]=A0(Q[Y]);return Z}function A0(Q){return Z1(Q)?JQ(Q):H0(Q)?qQ(Q):M0(Q)?HQ(Q):L0(Q)?LQ(Q):I(Q)?MQ(Q):Q}function o0(Q){return A0(Q)}function m(Q,Z){let Y=Z!==void 0?{...Z,...Q}:Q;switch(_.InstanceMode){case"freeze":return h1(Y);case"clone":return o0(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 n0(Q){return m({[B]:"MappedResult",properties:Q})}function UQ(Q,Z){let{[Z]:Y,...G}=Q;return G}function f1(Q,Z){return Z.reduce((Y,G)=>UQ(Y,G),Q)}function c(Q){return m({[B]:"Never",not:{}},Q)}function i1(Q){return I(Q)&&Q[q1]==="Optional"}function BQ(Q){return b(Q,"Any")}function wQ(Q){return b(Q,"Argument")}function t1(Q){return b(Q,"Array")}function jQ(Q){return b(Q,"AsyncIterator")}function DQ(Q){return b(Q,"BigInt")}function NQ(Q){return b(Q,"Boolean")}function PQ(Q){return b(Q,"Computed")}function SQ(Q){return b(Q,"Constructor")}function bQ(Q){return b(Q,"Date")}function CQ(Q){return b(Q,"Function")}function OQ(Q){return b(Q,"Integer")}function v1(Q){return b(Q,"Intersect")}function FQ(Q){return b(Q,"Iterator")}function b(Q,Z){return I(Q)&&B in Q&&Q[B]===Z}function xQ(Q){return b(Q,"Literal")}function m0(Q){return b(Q,"MappedKey")}function R0(Q){return b(Q,"MappedResult")}function B0(Q){return b(Q,"Never")}function KQ(Q){return b(Q,"Not")}function gQ(Q){return b(Q,"Null")}function _Q(Q){return b(Q,"Number")}function O1(Q){return b(Q,"Object")}function kQ(Q){return b(Q,"Promise")}function S0(Q){return b(Q,"Record")}function h0(Q){return b(Q,"Ref")}function EQ(Q){return b(Q,"RegExp")}function VQ(Q){return b(Q,"String")}function TQ(Q){return b(Q,"Symbol")}function IQ(Q){return b(Q,"TemplateLiteral")}function dQ(Q){return b(Q,"This")}function x(Q){return I(Q)&&B1 in Q}function c1(Q){return b(Q,"Tuple")}function u1(Q){return b(Q,"Undefined")}function l1(Q){return b(Q,"Union")}function fQ(Q){return b(Q,"Uint8Array")}function iQ(Q){return b(Q,"Unknown")}function yQ(Q){return b(Q,"Unsafe")}function pQ(Q){return b(Q,"Void")}function oQ(Q){return I(Q)&&B in Q&&n(Q[B])}function u(Q){return BQ(Q)||wQ(Q)||t1(Q)||NQ(Q)||DQ(Q)||jQ(Q)||PQ(Q)||SQ(Q)||bQ(Q)||CQ(Q)||OQ(Q)||v1(Q)||FQ(Q)||xQ(Q)||m0(Q)||R0(Q)||B0(Q)||KQ(Q)||gQ(Q)||_Q(Q)||O1(Q)||kQ(Q)||S0(Q)||h0(Q)||EQ(Q)||VQ(Q)||TQ(Q)||IQ(Q)||dQ(Q)||c1(Q)||u1(Q)||l1(Q)||fQ(Q)||iQ(Q)||yQ(Q)||pQ(Q)||oQ(Q)}function nQ(Q){return m(f1(Q,[q1]))}function mQ(Q){return m({...Q,[q1]:"Optional"})}function hQ(Q,Z){return Z===!1?nQ(Q):mQ(Q)}function y1(Q,Z){let Y=Z??!0;return R0(Q)?t0(Q,Y):hQ(Q,Y)}function tQ(Q,Z){let Y={};for(let G of globalThis.Object.getOwnPropertyNames(Q))Y[G]=y1(Q[G],Z);return Y}function vQ(Q,Z){return tQ(Q.properties,Z)}function t0(Q,Z){let Y=vQ(Q,Z);return n0(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 cQ(Q){return Q.every((Z)=>i1(Z))}function uQ(Q){return f1(Q,[q1])}function v0(Q){return Q.map((Z)=>i1(Z)?uQ(Z):Z)}function lQ(Q,Z){return cQ(Q)?y1(b0(v0(Q),Z)):b0(v0(Q),Z)}function c0(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 lQ(Q,Z)}function C0(Q,Z){return m({[B]:"Union",anyOf:Q},Z)}function sQ(Q){return Q.some((Z)=>i1(Z))}function u0(Q){return Q.map((Z)=>i1(Z)?rQ(Z):Z)}function rQ(Q){return f1(Q,[q1])}function aQ(Q,Z){return sQ(Q)?y1(C0(u0(Q),Z)):C0(u0(Q),Z)}function O0(Q,Z){return Q.length===1?m(Q[0],Z):Q.length===0?c(Z):aQ(Q,Z)}function l0(Q,Z){return Q.map((Y)=>s0(Y,Z))}function eQ(Q){return Q.filter((Z)=>!B0(Z))}function QY(Q,Z){return c0(eQ(l0(Q,Z)))}function YY(Q){return Q.some((Z)=>B0(Z))?[]:Q}function ZY(Q,Z){return O0(YY(l0(Q,Z)))}function GY(Q,Z){return Z in Q?Q[Z]:Z==="[number]"?O0(Q):c()}function WY(Q,Z){return Z==="[number]"?Q:c()}function XY(Q,Z){return Z in Q?Q[Z]:c()}function s0(Q,Z){return v1(Q)?QY(Q.allOf,Z):l1(Q)?ZY(Q.anyOf,Z):c1(Q)?GY(Q.items??[],Z):t1(Q)?WY(Q.items,Z):O1(Q)?XY(Q.properties,Z):c()}function r0(Q,Z){return Z.map((Y)=>s0(Q,Y))}function $Y(Q,Z){return Q.filter((Y)=>Z.includes(Y))}function zY(Q,Z){return Q.reduce((Y,G)=>{return $Y(Y,G)},Z)}function a0(Q){return Q.length===1?Q[0]:Q.length>1?zY(Q.slice(1),Q[0]):[]}function e0(Q){let Z=[];for(let Y of Q)Z.push(...Y);return Z}function Q8(...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 Y8(Q){let Z=[];for(let Y of Q)Z.push(w1(Y));return Z}function JY(Q){let Z=Y8(Q);return e0(Z)}function qY(Q){let Z=Y8(Q);return a0(Z)}function HY(Q){return Q.map((Z,Y)=>Y.toString())}function LY(Q){return["[number]"]}function MY(Q){return globalThis.Object.getOwnPropertyNames(Q)}function UY(Q){if(!F0)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 v1(Q)?JY(Q.allOf):l1(Q)?qY(Q.anyOf):c1(Q)?HY(Q.items??[]):t1(Q)?LY(Q.items):O1(Q)?MY(Q.properties):S0(Q)?UY(Q.patternProperties):[]}var F0=!1;function L1(Q){F0=!0;let Z=w1(Q);return F0=!1,`^(${Z.map((G)=>`(${G})`).join("|")})$`}function w0(Q){let Z=w1(Q),Y=r0(Q,Z);return Z.map((G,W)=>[Z[W],Y[W]])}function AY(Q){return Q.allOf.every((Z)=>M1(Z))}function RY(Q){return Q.anyOf.some((Z)=>M1(Z))}function BY(Q){return!M1(Q.not)}function M1(Q){return Q[B]==="Intersect"?AY(Q):Q[B]==="Union"?RY(Q):Q[B]==="Not"?BY(Q):Q[B]==="Undefined"?!0:!1}function wY(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=wY;function Z8(){return jY}class G8 extends T{constructor(Q){super(`Unable to dereference schema with $id '${Q.$ref}'`);this.schema=Q}}function DY(Q,Z){let Y=Z.find((G)=>G.$id===Q.$ref);if(Y===void 0)throw new G8(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"?DY(Q,Z):Q}class W8 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 p1=BigInt("14695981039346656037"),[NY,PY]=[BigInt("1099511628211"),BigInt("18446744073709551616")],SY=Array.from({length:256}).map((Q,Z)=>BigInt(Z)),X8=new Float64Array(1),$8=new DataView(X8.buffer),z8=new Uint8Array(X8.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 CY(Q){t(Q1.Array);for(let Z of Q)o1(Z)}function OY(Q){t(Q1.Boolean),t(Q?1:0)}function FY(Q){t(Q1.BigInt),$8.setBigInt64(0,Q);for(let Z of z8)t(Z)}function xY(Q){t(Q1.Date),o1(Q.getTime())}function KY(Q){t(Q1.Null)}function gY(Q){t(Q1.Number),$8.setFloat64(0,Q);for(let Z of z8)t(Z)}function _Y(Q){t(Q1.Object);for(let Z of globalThis.Object.getOwnPropertyNames(Q).sort())o1(Z),o1(Q[Z])}function kY(Q){t(Q1.String);for(let Z=0;Z<Q.length;Z++)for(let Y of bY(Q.charCodeAt(Z)))t(Y)}function EY(Q){t(Q1.Symbol),o1(Q.description)}function VY(Q){t(Q1.Uint8Array);for(let Z=0;Z<Q.length;Z++)t(Q[Z])}function TY(Q){return t(Q1.Undefined)}function o1(Q){if(V(Q))return CY(Q);if(b1(Q))return OY(Q);if(e(Q))return FY(Q);if(V1(Q))return xY(Q);if(S1(Q))return KY(Q);if(D(Q))return gY(Q);if(r(Q))return _Y(Q);if(f(Q))return kY(Q);if(C1(Q))return EY(Q);if(T1(Q))return VY(Q);if(v(Q))return TY(Q);throw new W8(Q)}function t(Q){p1=p1^SY[Q],p1=p1*NY%PY}function n1(Q){return p1=BigInt("14695981039346656037"),o1(Q),p1}var IY=["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 J8(Q){try{return new RegExp(Q),!0}catch{return!1}}function x0(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 K0(Q)||k(Q)}function s1(Q){return J1(Q)||p0(Q)}function K(Q){return J1(Q)||R1(Q)}function K0(Q){return J1(Q)||q0(Q)}function F(Q){return J1(Q)||n(Q)}function dY(Q){return J1(Q)||n(Q)&&x0(Q)&&J8(Q)}function fY(Q){return J1(Q)||n(Q)&&x0(Q)}function H8(Q){return J1(Q)||k(Q)}function iY(Q){return C(Q,"Any")&&F(Q.$id)}function yY(Q){return C(Q,"Argument")&&R1(Q.index)}function pY(Q){return C(Q,"Array")&&Q.type==="array"&&F(Q.$id)&&k(Q.items)&&K(Q.minItems)&&K(Q.maxItems)&&K0(Q.uniqueItems)&&H8(Q.contains)&&K(Q.minContains)&&K(Q.maxContains)}function oY(Q){return C(Q,"AsyncIterator")&&Q.type==="AsyncIterator"&&F(Q.$id)&&k(Q.items)}function nY(Q){return C(Q,"BigInt")&&Q.type==="bigint"&&F(Q.$id)&&s1(Q.exclusiveMaximum)&&s1(Q.exclusiveMinimum)&&s1(Q.maximum)&&s1(Q.minimum)&&s1(Q.multipleOf)}function mY(Q){return C(Q,"Boolean")&&Q.type==="boolean"&&F(Q.$id)}function hY(Q){return C(Q,"Computed")&&n(Q.target)&&Z1(Q.parameters)&&Q.parameters.every((Z)=>k(Z))}function tY(Q){return C(Q,"Constructor")&&Q.type==="Constructor"&&F(Q.$id)&&Z1(Q.parameters)&&Q.parameters.every((Z)=>k(Z))&&k(Q.returns)}function vY(Q){return C(Q,"Date")&&Q.type==="Date"&&F(Q.$id)&&K(Q.exclusiveMaximumTimestamp)&&K(Q.exclusiveMinimumTimestamp)&&K(Q.maximumTimestamp)&&K(Q.minimumTimestamp)&&K(Q.multipleOfTimestamp)}function cY(Q){return C(Q,"Function")&&Q.type==="Function"&&F(Q.$id)&&Z1(Q.parameters)&&Q.parameters.every((Z)=>k(Z))&&k(Q.returns)}function uY(Q){return C(Q,"Integer")&&Q.type==="integer"&&F(Q.$id)&&K(Q.exclusiveMaximum)&&K(Q.exclusiveMinimum)&&K(Q.maximum)&&K(Q.minimum)&&K(Q.multipleOf)}function L8(Q){return I(Q)&&Object.entries(Q).every(([Z,Y])=>x0(Z)&&k(Y))}function lY(Q){return C(Q,"Intersect")&&(n(Q.type)&&Q.type!=="object"?!1:!0)&&Z1(Q.allOf)&&Q.allOf.every((Z)=>k(Z)&&!AZ(Z))&&F(Q.type)&&(K0(Q.unevaluatedProperties)||H8(Q.unevaluatedProperties))&&F(Q.$id)}function sY(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 rY(Q){return C(Q,"Literal")&&F(Q.$id)&&aY(Q.const)}function aY(Q){return q0(Q)||R1(Q)||n(Q)}function eY(Q){return C(Q,"MappedKey")&&Z1(Q.keys)&&Q.keys.every((Z)=>R1(Z)||n(Z))}function QZ(Q){return C(Q,"MappedResult")&&L8(Q.properties)}function YZ(Q){return C(Q,"Never")&&I(Q.not)&&Object.getOwnPropertyNames(Q.not).length===0}function ZZ(Q){return C(Q,"Not")&&k(Q.not)}function GZ(Q){return C(Q,"Null")&&Q.type==="null"&&F(Q.$id)}function WZ(Q){return C(Q,"Number")&&Q.type==="number"&&F(Q.$id)&&K(Q.exclusiveMaximum)&&K(Q.exclusiveMinimum)&&K(Q.maximum)&&K(Q.minimum)&&K(Q.multipleOf)}function XZ(Q){return C(Q,"Object")&&Q.type==="object"&&F(Q.$id)&&L8(Q.properties)&&q8(Q.additionalProperties)&&K(Q.minProperties)&&K(Q.maxProperties)}function $Z(Q){return C(Q,"Promise")&&Q.type==="Promise"&&F(Q.$id)&&k(Q.item)}function zZ(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&&J8(Y[0])&&I(Z.patternProperties)&&k(Z.patternProperties[Y[0]])})(Q)}function JZ(Q){return C(Q,"Ref")&&F(Q.$id)&&n(Q.$ref)}function qZ(Q){return C(Q,"RegExp")&&F(Q.$id)&&n(Q.source)&&n(Q.flags)&&K(Q.maxLength)&&K(Q.minLength)}function HZ(Q){return C(Q,"String")&&Q.type==="string"&&F(Q.$id)&&K(Q.minLength)&&K(Q.maxLength)&&dY(Q.pattern)&&fY(Q.format)}function LZ(Q){return C(Q,"Symbol")&&Q.type==="symbol"&&F(Q.$id)}function MZ(Q){return C(Q,"TemplateLiteral")&&Q.type==="string"&&n(Q.pattern)&&Q.pattern[0]==="^"&&Q.pattern[Q.pattern.length-1]==="$"}function UZ(Q){return C(Q,"This")&&F(Q.$id)&&n(Q.$ref)}function AZ(Q){return I(Q)&&B1 in Q}function RZ(Q){return C(Q,"Tuple")&&Q.type==="array"&&F(Q.$id)&&R1(Q.minItems)&&R1(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 BZ(Q){return C(Q,"Undefined")&&Q.type==="undefined"&&F(Q.$id)}function wZ(Q){return C(Q,"Union")&&F(Q.$id)&&I(Q)&&Z1(Q.anyOf)&&Q.anyOf.every((Z)=>k(Z))}function jZ(Q){return C(Q,"Uint8Array")&&Q.type==="Uint8Array"&&F(Q.$id)&&K(Q.minByteLength)&&K(Q.maxByteLength)}function DZ(Q){return C(Q,"Unknown")&&F(Q.$id)}function NZ(Q){return C(Q,"Unsafe")}function PZ(Q){return C(Q,"Void")&&Q.type==="void"&&F(Q.$id)}function SZ(Q){return I(Q)&&B in Q&&n(Q[B])&&!IY.includes(Q[B])}function k(Q){return I(Q)&&(iY(Q)||yY(Q)||pY(Q)||mY(Q)||nY(Q)||oY(Q)||hY(Q)||tY(Q)||vY(Q)||cY(Q)||uY(Q)||lY(Q)||sY(Q)||rY(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)||UZ(Q)||RZ(Q)||BZ(Q)||wZ(Q)||jZ(Q)||DZ(Q)||NZ(Q)||PZ(Q)||SZ(Q))}class M8 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 CZ(Q,Z,Y){return!0}function OZ(Q,Z,Y){return!0}function FZ(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=n1(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 xZ(Q,Z,Y){return Z0(Y)}function KZ(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 gZ(Q,Z,Y){return b1(Y)}function _Z(Q,Z,Y){return y(Q.returns,Z,Y.prototype)}function kZ(Q,Z,Y){if(!V1(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 z0(Y)}function VZ(Q,Z,Y){let G=globalThis.Object.values(Q.$defs),W=Q.$defs[Q.$ref];return y(W,[...Z,...G],Y)}function TZ(Q,Z,Y){if(!$0(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 IZ(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 dZ(Q,Z,Y){return G0(Y)}function fZ(Q,Z,Y){return Y===Q.const}function iZ(Q,Z,Y){return!1}function yZ(Q,Z,Y){return!y(Q.not,Z,Y)}function pZ(Q,Z,Y){return S1(Y)}function oZ(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 nZ(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)||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 mZ(Q,Z,Y){return W0(Y)}function hZ(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,R])=>{return X.test(N)?y(W,Z,R):!0}),H=typeof Q.additionalProperties==="object"?Object.entries(Y).every(([N,R])=>{return!X.test(N)?y(Q.additionalProperties,Z,R):!0}):!0,w=Q.additionalProperties===!1?Object.getOwnPropertyNames(Y).every((N)=>{return X.test(N)}):!0;return J&&H&&w}function tZ(Q,Z,Y){return y(i(Q,Z),Z,Y)}function vZ(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 cZ(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 uZ(Q,Z,Y){return C1(Y)}function lZ(Q,Z,Y){return f(Y)&&new RegExp(Q.pattern).test(Y)}function sZ(Q,Z,Y){return y(i(Q,Z),Z,Y)}function rZ(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 aZ(Q,Z,Y){return v(Y)}function eZ(Q,Z,Y){return Q.anyOf.some((G)=>y(G,Z,Y))}function Q6(Q,Z,Y){if(!T1(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 Y6(Q,Z,Y){return!0}function Z6(Q,Z,Y){return _.IsVoidLike(Y)}function G6(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 CZ(W,G,Y);case"Argument":return OZ(W,G,Y);case"Array":return FZ(W,G,Y);case"AsyncIterator":return xZ(W,G,Y);case"BigInt":return KZ(W,G,Y);case"Boolean":return gZ(W,G,Y);case"Constructor":return _Z(W,G,Y);case"Date":return kZ(W,G,Y);case"Function":return EZ(W,G,Y);case"Import":return VZ(W,G,Y);case"Integer":return TZ(W,G,Y);case"Intersect":return IZ(W,G,Y);case"Iterator":return dZ(W,G,Y);case"Literal":return fZ(W,G,Y);case"Never":return iZ(W,G,Y);case"Not":return yZ(W,G,Y);case"Null":return pZ(W,G,Y);case"Number":return oZ(W,G,Y);case"Object":return nZ(W,G,Y);case"Promise":return mZ(W,G,Y);case"Record":return hZ(W,G,Y);case"Ref":return tZ(W,G,Y);case"RegExp":return vZ(W,G,Y);case"String":return cZ(W,G,Y);case"Symbol":return uZ(W,G,Y);case"TemplateLiteral":return lZ(W,G,Y);case"This":return sZ(W,G,Y);case"Tuple":return rZ(W,G,Y);case"Undefined":return aZ(W,G,Y);case"Union":return eZ(W,G,Y);case"Uint8Array":return Q6(W,G,Y);case"Unknown":return Y6(W,G,Y);case"Void":return Z6(W,G,Y);default:if(!a.Has(W[B]))throw new M8(W);return G6(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 U8 extends T{constructor(Q){super("Unknown type");this.schema=Q}}function U1(Q){return Q.replace(/~/g,"~0").replace(/\//g,"~1")}function S(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:Z8()({errorType:Q,path:Y,schema:Z,value:G,errors:W}),errors:W}}function*W6(Q,Z,Y,G){}function*X6(Q,Z,Y,G){}function*$6(Q,Z,Y,G){if(!V(G))return yield L(q.Array,Q,Y,G);if(S(Q.minItems)&&!(G.length>=Q.minItems))yield L(q.ArrayMinItems,Q,Y,G);if(S(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=n1(H);if(J.has(w))return!1;else J.add(w)}return!0}())yield L(q.ArrayUniqueItems,Q,Y,G);if(!(S(Q.contains)||S(Q.minContains)||S(Q.maxContains)))return;let W=S(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*z6(Q,Z,Y,G){if(!Z0(G))yield L(q.AsyncIterator,Q,Y,G)}function*J6(Q,Z,Y,G){if(!e(G))return yield L(q.BigInt,Q,Y,G);if(S(Q.exclusiveMaximum)&&!(G<Q.exclusiveMaximum))yield L(q.BigIntExclusiveMaximum,Q,Y,G);if(S(Q.exclusiveMinimum)&&!(G>Q.exclusiveMinimum))yield L(q.BigIntExclusiveMinimum,Q,Y,G);if(S(Q.maximum)&&!(G<=Q.maximum))yield L(q.BigIntMaximum,Q,Y,G);if(S(Q.minimum)&&!(G>=Q.minimum))yield L(q.BigIntMinimum,Q,Y,G);if(S(Q.multipleOf)&&G%Q.multipleOf!==BigInt(0))yield L(q.BigIntMultipleOf,Q,Y,G)}function*q6(Q,Z,Y,G){if(!b1(G))yield L(q.Boolean,Q,Y,G)}function*H6(Q,Z,Y,G){yield*p(Q.returns,Z,Y,G.prototype)}function*L6(Q,Z,Y,G){if(!V1(G))return yield L(q.Date,Q,Y,G);if(S(Q.exclusiveMaximumTimestamp)&&!(G.getTime()<Q.exclusiveMaximumTimestamp))yield L(q.DateExclusiveMaximumTimestamp,Q,Y,G);if(S(Q.exclusiveMinimumTimestamp)&&!(G.getTime()>Q.exclusiveMinimumTimestamp))yield L(q.DateExclusiveMinimumTimestamp,Q,Y,G);if(S(Q.maximumTimestamp)&&!(G.getTime()<=Q.maximumTimestamp))yield L(q.DateMaximumTimestamp,Q,Y,G);if(S(Q.minimumTimestamp)&&!(G.getTime()>=Q.minimumTimestamp))yield L(q.DateMinimumTimestamp,Q,Y,G);if(S(Q.multipleOfTimestamp)&&G.getTime()%Q.multipleOfTimestamp!==0)yield L(q.DateMultipleOfTimestamp,Q,Y,G)}function*M6(Q,Z,Y,G){if(!z0(G))yield L(q.Function,Q,Y,G)}function*U6(Q,Z,Y,G){let W=globalThis.Object.values(Q.$defs),X=Q.$defs[Q.$ref];yield*p(X,[...Z,...W],Y,G)}function*A6(Q,Z,Y,G){if(!$0(G))return yield L(q.Integer,Q,Y,G);if(S(Q.exclusiveMaximum)&&!(G<Q.exclusiveMaximum))yield L(q.IntegerExclusiveMaximum,Q,Y,G);if(S(Q.exclusiveMinimum)&&!(G>Q.exclusiveMinimum))yield L(q.IntegerExclusiveMinimum,Q,Y,G);if(S(Q.maximum)&&!(G<=Q.maximum))yield L(q.IntegerMaximum,Q,Y,G);if(S(Q.minimum)&&!(G>=Q.minimum))yield L(q.IntegerMinimum,Q,Y,G);if(S(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(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*B6(Q,Z,Y,G){if(!G0(G))yield L(q.Iterator,Q,Y,G)}function*w6(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*D6(Q,Z,Y,G){if(p(Q.not,Z,Y,G).next().done===!0)yield L(q.Not,Q,Y,G)}function*N6(Q,Z,Y,G){if(!S1(G))yield L(q.Null,Q,Y,G)}function*P6(Q,Z,Y,G){if(!_.IsNumberLike(G))return yield L(q.Number,Q,Y,G);if(S(Q.exclusiveMaximum)&&!(G<Q.exclusiveMaximum))yield L(q.NumberExclusiveMaximum,Q,Y,G);if(S(Q.exclusiveMinimum)&&!(G>Q.exclusiveMinimum))yield L(q.NumberExclusiveMinimum,Q,Y,G);if(S(Q.maximum)&&!(G<=Q.maximum))yield L(q.NumberMaximum,Q,Y,G);if(S(Q.minimum)&&!(G>=Q.minimum))yield L(q.NumberMinimum,Q,Y,G);if(S(Q.multipleOf)&&G%Q.multipleOf!==0)yield L(q.NumberMultipleOf,Q,Y,G)}function*S6(Q,Z,Y,G){if(!_.IsObjectLike(G))return yield L(q.Object,Q,Y,G);if(S(Q.minProperties)&&!(Object.getOwnPropertyNames(G).length>=Q.minProperties))yield L(q.ObjectMinProperties,Q,Y,G);if(S(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*b6(Q,Z,Y,G){if(!W0(G))yield L(q.Promise,Q,Y,G)}function*C6(Q,Z,Y,G){if(!_.IsRecordLike(G))return yield L(q.Object,Q,Y,G);if(S(Q.minProperties)&&!(Object.getOwnPropertyNames(G).length>=Q.minProperties))yield L(q.ObjectMinProperties,Q,Y,G);if(S(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*O6(Q,Z,Y,G){yield*p(i(Q,Z),Z,Y,G)}function*F6(Q,Z,Y,G){if(!f(G))return yield L(q.String,Q,Y,G);if(S(Q.minLength)&&!(G.length>=Q.minLength))yield L(q.StringMinLength,Q,Y,G);if(S(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*x6(Q,Z,Y,G){if(!f(G))return yield L(q.String,Q,Y,G);if(S(Q.minLength)&&!(G.length>=Q.minLength))yield L(q.StringMinLength,Q,Y,G);if(S(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*K6(Q,Z,Y,G){if(!C1(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*_6(Q,Z,Y,G){yield*p(i(Q,Z),Z,Y,G)}function*k6(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*V6(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*T6(Q,Z,Y,G){if(!T1(G))return yield L(q.Uint8Array,Q,Y,G);if(S(Q.maxByteLength)&&!(G.length<=Q.maxByteLength))yield L(q.Uint8ArrayMaxByteLength,Q,Y,G);if(S(Q.minByteLength)&&!(G.length>=Q.minByteLength))yield L(q.Uint8ArrayMinByteLength,Q,Y,G)}function*I6(Q,Z,Y,G){}function*d6(Q,Z,Y,G){if(!_.IsVoidLike(G))yield L(q.Void,Q,Y,G)}function*f6(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=S(Q.$id)?[...Z,Q]:Z,X=Q;switch(X[B]){case"Any":return yield*W6(X,W,Y,G);case"Argument":return yield*X6(X,W,Y,G);case"Array":return yield*$6(X,W,Y,G);case"AsyncIterator":return yield*z6(X,W,Y,G);case"BigInt":return yield*J6(X,W,Y,G);case"Boolean":return yield*q6(X,W,Y,G);case"Constructor":return yield*H6(X,W,Y,G);case"Date":return yield*L6(X,W,Y,G);case"Function":return yield*M6(X,W,Y,G);case"Import":return yield*U6(X,W,Y,G);case"Integer":return yield*A6(X,W,Y,G);case"Intersect":return yield*R6(X,W,Y,G);case"Iterator":return yield*B6(X,W,Y,G);case"Literal":return yield*w6(X,W,Y,G);case"Never":return yield*j6(X,W,Y,G);case"Not":return yield*D6(X,W,Y,G);case"Null":return yield*N6(X,W,Y,G);case"Number":return yield*P6(X,W,Y,G);case"Object":return yield*S6(X,W,Y,G);case"Promise":return yield*b6(X,W,Y,G);case"Record":return yield*C6(X,W,Y,G);case"Ref":return yield*O6(X,W,Y,G);case"RegExp":return yield*F6(X,W,Y,G);case"String":return yield*x6(X,W,Y,G);case"Symbol":return yield*K6(X,W,Y,G);case"TemplateLiteral":return yield*g6(X,W,Y,G);case"This":return yield*_6(X,W,Y,G);case"Tuple":return yield*k6(X,W,Y,G);case"Undefined":return yield*E6(X,W,Y,G);case"Union":return yield*V6(X,W,Y,G);case"Uint8Array":return yield*T6(X,W,Y,G);case"Unknown":return yield*I6(X,W,Y,G);case"Void":return yield*d6(X,W,Y,G);default:if(!a.Has(X[B]))throw new U8(Q);return yield*f6(X,W,Y,G)}}function A8(...Q){let Z=Q.length===3?p(Q[0],Q[1],"",Q[2]):p(Q[0],[],"",Q[1]);return new g0(Z)}class _0 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 i6(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 y6(Q,Z,Y,G){if(!r(G)||J0(G))return E(Q,Y,G);let W=w0(Q),X=W.map((R)=>R[0]),J={...G};for(let[R,O]of W)if(R in J)J[R]=X1(O,Z,`${Y}/${R}`,J[R]);if(!x(Q.unevaluatedProperties))return E(Q,Y,J);let H=Object.getOwnPropertyNames(J),w=Q.unevaluatedProperties,N={...J};for(let R of H)if(!X.includes(R))N[R]=E(w,`${Y}/${R}`,N[R]);return E(Q,Y,N)}function p6(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 o6(Q,Z,Y,G){return E(Q,Y,X1(Q.not,Z,Y,G))}function n6(Q,Z,Y,G){if(!r(G))return E(Q,Y,G);let W=w1(Q),X={...G};for(let N of W){if(!X0(X,N))continue;if(v(X[N])&&(!u1(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 m6(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 R of Object.getOwnPropertyNames(G))if(X.test(R))J[R]=X1(Q.patternProperties[W],Z,`${Y}/${R}`,J[R]);if(!u(Q.additionalProperties))return E(Q,Y,J);let H=Object.getOwnPropertyNames(J),w=Q.additionalProperties,N={...J};for(let R of H)if(!X.test(R))N[R]=E(w,`${Y}/${R}`,N[R]);return E(Q,Y,N)}function h6(Q,Z,Y,G){let W=i(Q,Z);return E(Q,Y,X1(W,Z,Y,G))}function t6(Q,Z,Y,G){let W=i(Q,Z);return E(Q,Y,X1(W,Z,Y,G))}function v6(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 c6(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 i6(X,W,Y,G);case"Import":return p6(X,W,Y,G);case"Intersect":return y6(X,W,Y,G);case"Not":return o6(X,W,Y,G);case"Object":return n6(X,W,Y,G);case"Record":return m6(X,W,Y,G);case"Ref":return h6(X,W,Y,G);case"Symbol":return E(X,Y,G);case"This":return t6(X,W,Y,G);case"Tuple":return v6(X,W,Y,G);case"Union":return c6(X,W,Y,G);default:return E(X,Y,G)}}function B8(Q,Z,Y){return X1(Q,Z,"",Y)}class k0 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 w8 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 w8(Q,Z,Y,G)}}function u6(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 l6(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 s6(Q,Z,Y,G){let W=h(Q,Y,G);if(!r(G)||J0(G))return W;let X=w0(Q),J=X.map((O)=>O[0]),H={...W};for(let[O,K1]of X)if(O in H)H[O]=$1(K1,Z,`${Y}/${O}`,H[O]);if(!x(Q.unevaluatedProperties))return H;let w=Object.getOwnPropertyNames(H),N=Q.unevaluatedProperties,R={...H};for(let O of w)if(!J.includes(O))R[O]=h(N,`${Y}/${O}`,R[O]);return R}function r6(Q,Z,Y,G){return h(Q.not,Y,h(Q,Y,G))}function a6(Q,Z,Y,G){let W=h(Q,Y,G);if(!r(W))return W;let X=w1(Q),J={...W};for(let R of X){if(!X0(J,R))continue;if(v(J[R])&&(!u1(Q.properties[R])||_.IsExactOptionalProperty(J,R)))continue;J[R]=$1(Q.properties[R],Z,`${Y}/${R}`,J[R])}if(!u(Q.additionalProperties))return J;let H=Object.getOwnPropertyNames(J),w=Q.additionalProperties,N={...J};for(let R of H)if(!X.includes(R))N[R]=h(w,`${Y}/${R}`,N[R]);return N}function e6(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,R={...H};for(let O of w)if(!J.test(O))R[O]=h(N,`${Y}/${O}`,R[O]);return R}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=i(Q,Z),X=$1(W,Z,Y,G);return h(Q,Y,X)}function ZG(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 GG(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 u6(X,W,Y,G);case"Import":return l6(X,W,Y,G);case"Intersect":return s6(X,W,Y,G);case"Not":return r6(X,W,Y,G);case"Object":return a6(X,W,Y,G);case"Record":return e6(X,W,Y,G);case"Ref":return QG(X,W,Y,G);case"This":return YG(X,W,Y,G);case"Tuple":return ZG(X,W,Y,G);case"Union":return GG(X,W,Y,G);default:return h(X,Y,G)}}function j8(Q,Z,Y){return $1(Q,Z,"",Y)}function WG(Q,Z){return x(Q)||d(Q.items,Z)}function XG(Q,Z){return x(Q)||d(Q.items,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)||d(Q.returns,Z)||Q.parameters.some((Y)=>d(Y,Z))}function JG(Q,Z){return x(Q)||x(Q.unevaluatedProperties)||Q.allOf.some((Y)=>d(Y,Z))}function qG(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 HG(Q,Z){return x(Q)||d(Q.items,Z)}function LG(Q,Z){return x(Q)||d(Q.not,Z)}function MG(Q,Z){return x(Q)||Object.values(Q.properties).some((Y)=>d(Y,Z))||u(Q.additionalProperties)&&d(Q.additionalProperties,Z)}function UG(Q,Z){return x(Q)||d(Q.item,Z)}function AG(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 BG(Q,Z){if(x(Q))return!0;return d(i(Q,Z),Z)}function wG(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=j1(Q,Z),G=Q;if(Q.$id&&E0.has(Q.$id))return!1;if(Q.$id)E0.add(Q.$id);switch(Q[B]){case"Array":return WG(G,Y);case"AsyncIterator":return XG(G,Y);case"Constructor":return $G(G,Y);case"Function":return zG(G,Y);case"Import":return qG(G,Y);case"Intersect":return JG(G,Y);case"Iterator":return HG(G,Y);case"Not":return LG(G,Y);case"Object":return MG(G,Y);case"Promise":return UG(G,Y);case"Record":return AG(G,Y);case"Ref":return RG(G,Y);case"This":return BG(G,Y);case"Tuple":return wG(G,Y);case"Union":return jG(G,Y);default:return x(Q)}}var E0=new Set;function D8(Q,Z){return E0.clear(),d(Q,Z)}class N8{constructor(Q,Z,Y,G){this.schema=Q,this.references=Z,this.checkFunc=Y,this.code=G,this.hasTransform=D8(Q,Z)}Code(){return this.code}Schema(){return this.schema}References(){return this.references}Errors(Q){return A8(this.schema,this.references,Q)}Check(Q){return this.checkFunc(Q)}Decode(Q){if(!this.checkFunc(Q))throw new _0(this.schema,Q,this.Errors(Q).First());return this.hasTransform?B8(this.schema,this.references,Q):Q}Encode(Q){let Z=this.hasTransform?j8(this.schema,this.references,Q):Q;if(!this.checkFunc(Z))throw new k0(this.schema,Q,this.Errors(Q).First());return Z}}var A1;(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})(A1||(A1={}));var j0;(function(Q){function Z(X){if(X.length===0)return!1;return A1.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(!(A1.IsAlpha(H)||A1.IsNumeric(H)||A1.DollarSign(H)||A1.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})(j0||(j0={}));var V0;(function(Q){function Z(Y){let G=[];for(let W=0;W<Y.length;W++){let X=Y.charCodeAt(W);if(A1.IsNumeric(X)||A1.IsAlpha(X))G.push(Y.charAt(W));else G.push(`_${X}_`)}return G.join("").replace(/__/g,"_")}Q.Encode=Z})(V0||(V0={}));var T0;(function(Q){function Z(Y){return Y.replace(/'/g,"\\'")}Q.Escape=Z})(T0||(T0={}));class P8 extends T{constructor(Q){super("Unknown type");this.schema=Q}}class I0 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)`:`(${j0.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 D0;(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]=[Q0("value","any"),Q0("acc","number")];if(D($.maxItems))yield`${z}.length <= ${$.maxItems}`;if(D($.minItems))yield`${z}.length >= ${$.minItems}`;let A=G1($.items,M,"value");if(yield`${z}.every((${j}) => ${A})`,k($.contains)||D($.minContains)||D($.maxContains)){let g=k($.contains)?$.contains:c(),s=G1(g,M,"value"),H1=D($.minContains)?[`(count >= ${$.minContains})`]:[],W1=D($.maxContains)?[`(count <= ${$.maxContains})`]:[],z1=`const count = value.reduce((${U}, ${j}) => ${s} ? acc + 1 : acc, 0)`,Y0=["(count > 0)",...H1,...W1].join(" && ");yield`((${j}) => { ${z1}; return ${Y0}})(${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*R($,M,z){yield`(typeof ${z} === 'function')`}function*O($,M,z){let j=globalThis.Object.getOwnPropertyNames($.$defs).reduce((U,A)=>{return[...U,$.$defs[A]]},[]);yield*_1(Q8($.$ref),[...M,...j],z)}function*K1($,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($))};`),A=`Object.getOwnPropertyNames(${z}).every(key => ${U}.test(key))`;yield`(${j} && ${A})`}else if(k($.unevaluatedProperties)){let U=k1(`${new RegExp(L1($))};`),A=`Object.getOwnPropertyNames(${z}).every(key => ${U}.test(key) || ${G1($.unevaluatedProperties,M,`${z}[key]`)})`;yield`(${j} && ${A})`}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} === '${T0.Escape($.const)}')`}function*N0($,M,z){yield"false"}function*P1($,M,z){yield`(!${G1($.not,M,z)})`}function*r1($,M,z){yield`(${z} === null)`}function*a1($,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*g1($,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 A=j0.Encode(z,U),g=$.properties[U];if($.required&&$.required.includes(U)){if(yield*_1(g,M,A),M1(g)||Z(g))yield`('${U}' in ${z})`}else{let s=G1(g,M,A);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((A)=>`'${A}'`).join(", ")}]`;yield`Object.getOwnPropertyNames(${z}).every(key => ${U}.includes(key))`}if(typeof $.additionalProperties==="object"){let U=G1($.additionalProperties,M,`${z}[key]`),A=`[${j.map((g)=>`'${g}'`).join(", ")}]`;yield`(Object.getOwnPropertyNames(${z}).every(key => ${A}.includes(key) || ${U}))`}}function*O8($,M,z){yield`${z} instanceof Promise`}function*F8($,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],A=k1(`${new RegExp(j)}`),g=G1(U,M,"value"),s=k($.additionalProperties)?G1($.additionalProperties,M,z):$.additionalProperties===!1?"false":"true",H1=`(${A}.test(key) ? ${g} : ${s})`;yield`(Object.entries(${z}).every(([key, value]) => ${H1}))`}function*x8($,M,z){let j=i($,M);if(o.functions.has($.$ref))return yield`${e1($.$ref)}(${z})`;yield*_1(j,M,z)}function*K8($,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*_8($,M,z){yield`(typeof ${z} === 'symbol')`}function*k8($,M,z){yield`(typeof ${z} === 'string')`,yield`${k1(`${new RegExp($.pattern)};`)}.test(${z})`}function*E8($,M,z){yield`${e1($.$ref)}(${z})`}function*V8($,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*T8($,M,z){yield`${z} === undefined`}function*I8($,M,z){yield`(${$.anyOf.map((U)=>G1(U,M,z)).join(" || ")})`}function*d8($,M,z){if(yield`${z} instanceof Uint8Array`,D($.maxByteLength))yield`(${z}.length <= ${$.maxByteLength})`;if(D($.minByteLength))yield`(${z}.length >= ${$.minByteLength})`}function*f8($,M,z){yield"true"}function*i8($,M,z){yield x1.IsVoidLike(z)}function*y8($,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,A=$;if(j&&f($.$id)){let g=e1($.$id);if(o.functions.has(g))return yield`${g}(${z})`;else{o.functions.set(g,"<deferred>");let s=d0(g,$,M,"value",!1);return o.functions.set(g,s),yield`${g}(${z})`}}switch(A[B]){case"Any":return yield*Y(A,U,z);case"Argument":return yield*G(A,U,z);case"Array":return yield*W(A,U,z);case"AsyncIterator":return yield*X(A,U,z);case"BigInt":return yield*J(A,U,z);case"Boolean":return yield*H(A,U,z);case"Constructor":return yield*w(A,U,z);case"Date":return yield*N(A,U,z);case"Function":return yield*R(A,U,z);case"Import":return yield*O(A,U,z);case"Integer":return yield*K1(A,U,z);case"Intersect":return yield*l(A,U,z);case"Iterator":return yield*D1(A,U,z);case"Literal":return yield*N1(A,U,z);case"Never":return yield*N0(A,U,z);case"Not":return yield*P1(A,U,z);case"Null":return yield*r1(A,U,z);case"Number":return yield*a1(A,U,z);case"Object":return yield*g1(A,U,z);case"Promise":return yield*O8(A,U,z);case"Record":return yield*F8(A,U,z);case"Ref":return yield*x8(A,U,z);case"RegExp":return yield*K8(A,U,z);case"String":return yield*g8(A,U,z);case"Symbol":return yield*_8(A,U,z);case"TemplateLiteral":return yield*k8(A,U,z);case"This":return yield*E8(A,U,z);case"Tuple":return yield*V8(A,U,z);case"Undefined":return yield*T8(A,U,z);case"Union":return yield*I8(A,U,z);case"Uint8Array":return yield*d8(A,U,z);case"Unknown":return yield*f8(A,U,z);case"Void":return yield*i8(A,U,z);default:if(!a.Has(A[B]))throw new P8($);return yield*y8(A,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 e1($){return`check_${V0.Encode($)}`}function k1($){let M=`local_${o.variables.size}`;return o.variables.set(M,`const ${M} = ${$}`),M}function d0($,M,z,j,U=!0){let[A,g]=[`
3
+ `,(z1)=>"".padStart(z1," ")],s=Q0("value","any"),H1=f0("boolean"),W1=[..._1(M,z,j,U)].map((z1)=>`${g(4)}${z1}`).join(` &&${A}`);return`function ${$}(${s})${H1} {${A}${g(2)}return (${A}${W1}${A}${g(2)})
4
+ }`}function Q0($,M){let z=o.language==="typescript"?`: ${M}`:"";return`${$}${z}`}function f0($){return o.language==="typescript"?`: ${$}`:""}function p8($,M,z){let j=d0("check",$,M,"value"),U=Q0("value","any"),A=f0("boolean"),g=[...o.functions.values()],s=[...o.variables.values()],H1=f($.$id)?`return function check(${U})${A} {
5
+ return ${e1($.$id)}(value)
6
+ }`:`return ${j}`;return[...s,...g,H1].join(`
7
+ `)}function i0(...$){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 I0(z);for(let A of j)if(!k(A))throw new I0(A);return p8(z,j,U)}Q.Code=i0;function o8($,M=[]){let z=i0($,M,{language:"javascript"}),j=globalThis.Function("kind","format","hash",z),U=new Map(o.instances);function A(W1,z1,Y0){if(!a.Has(W1)||!U.has(z1))return!1;let n8=a.Get(W1),m8=U.get(z1);return n8(m8,Y0)}function g(W1,z1){if(!Y1.Has(W1))return!1;return Y1.Get(W1)(z1)}function s(W1){return n1(W1)}let H1=j(A,g,s);return new N8($,M,H1,z)}Q.Compile=o8})(D0||(D0={}));var m1=(Q,Z=400)=>new Response(JSON.stringify(Q),{status:Z,headers:{"Content-Type":"application/json"}}),DG=(Q)=>{let Z=D0.Compile(Q);return async(Y,G)=>{try{let W=await Y.req.json();if(!Z.Check(W)){let X=Z.Errors(W).First();return m1({status:"error",code:"VALIDATION_FAILED",message:X?.message||"Invalid input",path:X?.path||"body"})}return Y.body=W,G?G():void 0}catch{return m1({status:"error",message:"Invalid JSON payload"})}}},NG=(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 R=0;R<G;R++){let O=Y[R];if(typeof N[O]!==Z[O]?.type)return m1({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 m1({status:"error",message:"Invalid JSON payload"})}}},PG=(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 m1({status:"error",code:"ZOD_ERROR",errors:H.error.format()});if(W)Y.body=H.data;return G?G():void 0}catch{return m1({status:"error",message:"Invalid JSON payload"})}}};class S8 extends E1{_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){super();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 P0)}get server(){return this._server}set server(Q){this._server=Q}use(Q){if(Q instanceof E1)this.routes.push(...Q.routes);else if(Q&&typeof Q==="object"&&"install"in Q)Q.install(this);else this.groupMiddleware.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)}}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,N0=D1.length;N1<N0;N1++){let P1=D1[N1];if(P1.m===X){let r1=P1.r.exec(W);if(r1){let a1=Object.create(null);for(let g1=0;g1<P1.p.length;g1++)a1[P1.p[g1]]=r1[g1+1];H=P1.c(J.reset(Q,a1)),l=!0;break}}}if(!l)H=this.defaultHandler(J.reset(Q,{}))}if(H instanceof Response)return H;let N=J._status,R=new Headers,O=J._headers;for(let l in O)R.set(l.toLowerCase(),O[l]);let K1=(l)=>{if(l instanceof Response)return l;let D1=l!==null&&typeof l==="object";if(D1&&!R.has("content-type"))R.set("content-type","application/json");let N1=D1?JSON.stringify(l):l??"";return new Response(N1,{status:N,headers:R})};return H instanceof Promise?H.then(K1):K1(H)};compile(){for(let Q of this.routes){let Z=[...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{if(!this.router[Q.method])this.router[Q.method]={};this.router[Q.method][Q.path]=W}}this.defaultHandler=this.compileHandler((Q)=>new Response("404 Not Found",{status:404}),this.groupMiddleware)}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 SG=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 CG}from"path";var OG=(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=CG(process.cwd(),Q,W),J=Bun.file(X);if(await J.exists())return new Response(J);return Y()}};var b8=new TextEncoder,C8=async(Q,Z)=>{let Y=Bun.crypto.hmac("sha256",Z,Q);return Buffer.from(Y).toString("hex")},FG=async(Q,Z,Y)=>{let G=await C8(Q,Y);return Bun.crypto.timingSafeEqual(b8.encode(Z),b8.encode(G))},xG=(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 FG(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 KG={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 C8(Y,Z);return`${G}.${W}`};export{PG as zod,DG as typebox,OG as staticFile,NG as native,SG as logger,gG as createToken,bG as cors,xG as bareAuth,KG as Password,E1 as BareRouter,S8 as BareJS};
@@ -1,14 +1,14 @@
1
1
  import { type Middleware, type Handler, type WSHandlers, type Next } from './context';
2
+ import { BareRouter } from './router';
2
3
  export * from './context';
3
4
  export * from './validators';
5
+ export { BareRouter };
4
6
  export type { Middleware, Handler, WSHandlers, Next };
5
7
  import type { Server } from "bun";
6
8
  export interface BarePlugin {
7
9
  install: (app: BareJS) => void;
8
10
  }
9
- export declare class BareJS {
10
- private routes;
11
- private globalMiddlewares;
11
+ export declare class BareJS extends BareRouter {
12
12
  private _server;
13
13
  private _reusePort;
14
14
  private wsHandler;
@@ -23,17 +23,19 @@ export declare class BareJS {
23
23
  });
24
24
  get server(): Server<any> | null;
25
25
  set server(value: Server<any> | null);
26
- use(arg: Middleware | {
26
+ /**
27
+ * Overloaded use() to support Middleware, Plugins, and Routers
28
+ */
29
+ use(arg: Middleware | BareRouter | {
27
30
  install: (app: BareJS) => void;
28
31
  }): this;
29
32
  private compileHandler;
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
33
  ws: (path: string, handlers: WSHandlers) => this;
36
34
  fetch: (req: Request, server?: Server<any>) => any;
35
+ /**
36
+ * The JIT "Baking" Phase
37
+ * Converts route definitions into flattened executable functions
38
+ */
37
39
  compile(): void;
38
40
  listen(arg1?: number | string, arg2?: number | string): Promise<Server<any>>;
39
41
  }
@@ -1,5 +1,6 @@
1
1
  export type Params = Record<string, string>;
2
2
  export type Next = () => Promise<any> | any;
3
+ export type GroupCallback = (router: any) => void;
3
4
  /**
4
5
  * ๐ŸŽฏ Hybrid Middleware Signature
5
6
  * Supports Context-only (379ns path), Standard Middleware, and Legacy Style.
@@ -7,4 +7,5 @@ export { typebox, native, zod } from './validators';
7
7
  export { logger } from './logger';
8
8
  export { cors } from './cors';
9
9
  export { staticFile } from './static';
10
+ export { BareRouter } from './router';
10
11
  export { bareAuth, createToken, Password } from './auth';
@@ -0,0 +1,20 @@
1
+ import { type Middleware, type Handler, type GroupCallback } from './context';
2
+ type HandlersChain = [...any[], Handler];
3
+ export declare class BareRouter {
4
+ prefix: string;
5
+ groupMiddleware: Middleware[];
6
+ routes: {
7
+ method: string;
8
+ path: string;
9
+ handlers: any[];
10
+ }[];
11
+ constructor(prefix?: string, groupMiddleware?: Middleware[]);
12
+ private _add;
13
+ get: (path: string, ...handlers: HandlersChain) => this;
14
+ post: (path: string, ...handlers: HandlersChain) => this;
15
+ put: (path: string, ...handlers: HandlersChain) => this;
16
+ patch: (path: string, ...handlers: HandlersChain) => this;
17
+ delete: (path: string, ...handlers: HandlersChain) => this;
18
+ group: (path: string, ...args: [...any[], GroupCallback]) => this;
19
+ }
20
+ export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "barejs",
3
- "version": "0.1.26",
3
+ "version": "0.1.28",
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,12 +181,15 @@
181
181
  // return this.server;
182
182
  // }
183
183
  // }
184
+
184
185
  // All comments in English
185
186
  import { Context, type Middleware, type Handler, type WSHandlers, type Next } from './context';
186
187
  import { typebox, zod, native } from './validators';
188
+ import { BareRouter } from './router'; // Import your new router
187
189
 
188
190
  export * from './context';
189
191
  export * from './validators';
192
+ export { BareRouter }; // Export for user use
190
193
  export type { Middleware, Handler, WSHandlers, Next };
191
194
 
192
195
  import type { Server, ServerWebSocket } from "bun";
@@ -195,13 +198,12 @@ export interface BarePlugin {
195
198
  install: (app: BareJS) => void;
196
199
  }
197
200
 
198
- export class BareJS {
199
- private routes: Array<{ method: string; path: string; handlers: any[] }> = [];
200
- private globalMiddlewares: Array<Middleware> = [];
201
+ export class BareJS extends BareRouter { // Inherit methods like .get, .post, .group
201
202
  private _server: Server<any> | null = null;
202
203
  private _reusePort: boolean = true;
203
204
  private wsHandler: { path: string; handlers: WSHandlers } | null = null;
204
205
 
206
+ // Jump tables for "Baked" routes
205
207
  private router: Record<string, Record<string, Function>> = {
206
208
  GET: {}, POST: {}, PUT: {}, PATCH: {}, DELETE: {}
207
209
  };
@@ -215,6 +217,7 @@ export class BareJS {
215
217
  private defaultHandler: Function = (ctx: Context) => new Response('404 Not Found', { status: 404 });
216
218
 
217
219
  constructor(options?: { poolSize?: number }) {
220
+ super(); // Initialize BareRouter
218
221
  let size = options?.poolSize || Number(process.env.BARE_POOL_SIZE) || 1024;
219
222
  if ((size & (size - 1)) !== 0) {
220
223
  size = Math.pow(2, Math.ceil(Math.log2(size)));
@@ -226,11 +229,19 @@ export class BareJS {
226
229
  public get server(): Server<any> | null { return this._server; }
227
230
  public set server(value: Server<any> | null) { this._server = value; }
228
231
 
229
- public use(arg: Middleware | { install: (app: BareJS) => void }) {
230
- if (arg && typeof arg === 'object' && 'install' in arg) {
232
+ /**
233
+ * Overloaded use() to support Middleware, Plugins, and Routers
234
+ */
235
+ public use(arg: Middleware | BareRouter | { install: (app: BareJS) => void }) {
236
+ if (arg instanceof BareRouter) {
237
+ // Transfer routes from the external router to the main app registry
238
+ this.routes.push(...arg.routes);
239
+ } else if (arg && typeof arg === 'object' && 'install' in arg) {
231
240
  arg.install(this);
232
241
  } else {
233
- this.globalMiddlewares.push(arg as Middleware);
242
+ // Global Middleware (applied to the base group)
243
+ // Note: In BareRouter, this is groupMiddleware
244
+ (this as any).groupMiddleware.push(arg as Middleware);
234
245
  }
235
246
  return this;
236
247
  }
@@ -246,6 +257,7 @@ export class BareJS {
246
257
  const fn = pipeline[idx];
247
258
  if (!fn) return;
248
259
 
260
+ // Optimization: Branchless middleware execution
249
261
  if (fn.length === 1) return (fn as any)(ctx);
250
262
  if (fn.length > 2) return (fn as any)(ctx.req, ctx.params, () => runner(idx + 1));
251
263
  return (fn as any)(ctx, () => runner(idx + 1));
@@ -255,15 +267,6 @@ export class BareJS {
255
267
  };
256
268
  }
257
269
 
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
-
267
270
  public ws = (path: string, handlers: WSHandlers) => {
268
271
  this.wsHandler = { path, handlers };
269
272
  return this;
@@ -283,7 +286,7 @@ export class BareJS {
283
286
  if (handler) {
284
287
  res = handler(ctx.reset(req, {}));
285
288
  } else {
286
- // 2. Dynamic Lookup (Fixed with your null-check logic)
289
+ // 2. Dynamic Lookup
287
290
  let matched = false;
288
291
  const routes = this.dynamicRoutes;
289
292
  for (let i = 0, l = routes.length; i < l; i++) {
@@ -295,7 +298,6 @@ export class BareJS {
295
298
  for (let k = 0; k < d.p.length; k++) {
296
299
  params[d.p[k]!] = match[k + 1];
297
300
  }
298
- // Ensure ctx is reset with params before passing to dynamic handler
299
301
  res = d.c(ctx.reset(req, params));
300
302
  matched = true;
301
303
  break;
@@ -305,14 +307,12 @@ export class BareJS {
305
307
  if (!matched) res = this.defaultHandler(ctx.reset(req, {}));
306
308
  }
307
309
 
308
- // --- Response Processing ---
309
310
  if (res instanceof Response) return res;
310
311
 
311
312
  const status = ctx._status;
312
313
  const h = new Headers();
313
314
  const raw = ctx._headers!;
314
315
 
315
- // Standardize headers (Fixes the 'null' error in tests)
316
316
  for (const key in raw) {
317
317
  h.set(key.toLowerCase(), raw[key]!);
318
318
  }
@@ -329,9 +329,14 @@ export class BareJS {
329
329
  return res instanceof Promise ? res.then(build) : build(res);
330
330
  };
331
331
 
332
+ /**
333
+ * The JIT "Baking" Phase
334
+ * Converts route definitions into flattened executable functions
335
+ */
332
336
  public compile() {
333
337
  for (const route of this.routes) {
334
- const pipeline = [...this.globalMiddlewares, ...route.handlers];
338
+ // Handlers in route already contain group-level middleware from BareRouter._add
339
+ const pipeline = [...route.handlers];
335
340
  const handler = pipeline.pop() || ((ctx: Context) => new Response('Not Found', { status: 404 }));
336
341
  const middlewares = pipeline as Middleware[];
337
342
  const compiled = this.compileHandler(handler, middlewares);
@@ -341,16 +346,15 @@ export class BareJS {
341
346
  const regexPath = route.path.replace(/:([^/]+)/g, (_, n) => { pNames.push(n); return "([^/]+)"; });
342
347
  this.dynamicRoutes.push({ m: route.method, r: new RegExp(`^${regexPath}$`), p: pNames, c: compiled });
343
348
  } else {
349
+ if (!this.router[route.method]) this.router[route.method] = {};
344
350
  this.router[route.method]![route.path] = compiled;
345
351
  }
346
352
  }
347
353
 
348
- /**
349
- * โœ… [FIX 6] Default Handler: Compile after global middlewares are registered
350
- */
354
+ // Default 404 handler includes global middleware
351
355
  this.defaultHandler = this.compileHandler(
352
356
  (ctx: Context) => new Response('404 Not Found', { status: 404 }),
353
- this.globalMiddlewares
357
+ (this as any).groupMiddleware
354
358
  );
355
359
  }
356
360
 
package/src/context.ts CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  export type Params = Record<string, string>;
4
4
  export type Next = () => Promise<any> | any;
5
-
5
+ export type GroupCallback = (router: any) => void;
6
6
  /**
7
7
  * ๐ŸŽฏ Hybrid Middleware Signature
8
8
  * Supports Context-only (379ns path), Standard Middleware, and Legacy Style.
package/src/index.ts CHANGED
@@ -22,6 +22,6 @@ export { typebox, native, zod } from './validators';
22
22
  export { logger } from './logger';
23
23
  export { cors } from './cors';
24
24
  export { staticFile } from './static';
25
-
25
+ export { BareRouter } from './router';
26
26
  // Authentication & Security (Bun Native)
27
27
  export { bareAuth, createToken, Password } from './auth';
package/src/router.ts ADDED
@@ -0,0 +1,50 @@
1
+ // src/router.ts
2
+ import {
3
+ Context,
4
+ type Middleware,
5
+ type Handler,
6
+ type GroupCallback
7
+ } from './context';
8
+
9
+ // Use 'any' here for the tuple definition to prevent the "source not compatible" error,
10
+ // but the runtime will still be protected by your BareJS.compileHandler logic.
11
+ type HandlersChain = [...any[], Handler];
12
+
13
+ export class BareRouter {
14
+ public routes: { method: string; path: string; handlers: any[] }[] = [];
15
+
16
+ constructor(
17
+ public prefix: string = "",
18
+ public groupMiddleware: Middleware[] = []
19
+ ) {}
20
+
21
+ private _add(method: string, path: string, handlers: HandlersChain) {
22
+ const fullPath = (this.prefix + path).replace(/\/+/g, "/") || "/";
23
+ this.routes.push({
24
+ method: method.toUpperCase(),
25
+ path: fullPath,
26
+ handlers: [...this.groupMiddleware, ...handlers]
27
+ });
28
+ return this;
29
+ }
30
+
31
+ public get = (path: string, ...handlers: HandlersChain) => this._add("GET", path, handlers);
32
+ public post = (path: string, ...handlers: HandlersChain) => this._add("POST", path, handlers);
33
+ public put = (path: string, ...handlers: HandlersChain) => this._add("PUT", path, handlers);
34
+ public patch = (path: string, ...handlers: HandlersChain) => this._add("PATCH", path, handlers);
35
+ public delete = (path: string, ...handlers: HandlersChain) => this._add("DELETE", path, handlers);
36
+
37
+ public group = (path: string, ...args: [...any[], GroupCallback]) => {
38
+ const callback = args.pop() as GroupCallback;
39
+ const middleware = args as Middleware[];
40
+
41
+ const subRouter = new BareRouter(
42
+ (this.prefix + path).replace(/\/+/g, "/"),
43
+ [...this.groupMiddleware, ...middleware]
44
+ );
45
+
46
+ callback(subRouter);
47
+ this.routes.push(...subRouter.routes);
48
+ return this;
49
+ };
50
+ }