barejs 0.1.9 → 0.1.12
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 +93 -88
- package/dist/benchmarks/index.d.ts +1 -0
- package/dist/example.d.ts +1 -0
- package/dist/index.js +7 -0
- package/dist/scripts/build.d.ts +1 -0
- package/dist/scripts/update-readme.d.ts +1 -0
- package/dist/src/auth.d.ts +23 -0
- package/dist/src/bare.d.ts +32 -0
- package/dist/src/context.d.ts +26 -0
- package/dist/src/cors.d.ts +5 -0
- package/dist/src/index.d.ts +8 -0
- package/dist/src/logger.d.ts +2 -0
- package/dist/src/static.d.ts +8 -0
- package/dist/src/validators.d.ts +13 -0
- package/package.json +67 -61
- package/src/auth.ts +100 -0
- package/src/bare.ts +125 -139
- package/src/context.ts +30 -48
- package/src/cors.ts +27 -0
- package/src/index.ts +23 -3
- package/src/logger.ts +23 -0
- package/src/static.ts +45 -0
- package/src/validators.ts +58 -21
package/README.md
CHANGED
|
@@ -3,55 +3,40 @@
|
|
|
3
3
|
|
|
4
4
|
BareJS is a minimalist, high-performance web engine architected for the **Bun** ecosystem. By utilizing a **Just-In-Time (JIT) Route Compilation** strategy and an asynchronous **Onion-Model** pipeline, BareJS achieves near-native throughput, outperforming traditional frameworks by eliminating runtime routing overhead.
|
|
5
5
|
|
|
6
|
-

|
|
7
|
-
[](https://xarhang.github.io/bareJS/dev/benchmarks/)
|
|
8
|
-
[](https://bun.sh)
|
|
9
|
-
[](https://www.npmjs.com/package/barejs)
|
|
10
|
-
|
|
11
6
|
---
|
|
12
7
|
|
|
13
8
|
## 🏛 Architectural Engineering
|
|
14
9
|
|
|
15
10
|
Unlike traditional frameworks that iterate through arrays or regex patterns on every request, BareJS utilizes a **Static Compilation Phase**.
|
|
16
11
|
|
|
17
|
-
|
|
18
|
-
|
|
19
12
|
### The JIT Lifecycle
|
|
13
|
+
|
|
20
14
|
When `app.listen()` is invoked, the engine:
|
|
15
|
+
|
|
21
16
|
1. **Analyzes** the complete route tree and global middleware stack.
|
|
22
17
|
2. **Serializes** the execution logic into a flat, optimized JavaScript function.
|
|
23
18
|
3. **Binds** the function using `new Function()`, allowing the **JavaScriptCore (JSC)** engine to perform aggressive inline caching and speculative optimizations.
|
|
24
19
|
|
|
25
20
|
---
|
|
26
21
|
|
|
27
|
-
---
|
|
28
|
-
|
|
29
22
|
## 📊 Performance Benchmarks
|
|
30
23
|
|
|
31
24
|
Performance comparison between **BareJS**, **Elysia**, and **Hono**.
|
|
32
25
|
|
|
33
26
|
### 🚀 Latest Benchmark Results
|
|
34
|
-
*Awaiting automated update...*
|
|
35
|
-
|
|
36
27
|
<!-- MARKER: PERFORMANCE_TABLE_START -->
|
|
37
|
-
|
|
28
|
+
*Awaiting automated update...*
|
|
29
|
+
| Framework | Latency | Speed |
|
|
38
30
|
| :--- | :--- | :--- |
|
|
39
|
-
| **BareJS** |
|
|
40
|
-
| Elysia |
|
|
41
|
-
| Hono |
|
|
42
|
-
<!-- MARKER: PERFORMANCE_TABLE_END -->
|
|
31
|
+
| **BareJS** | **1.04 µs** | **Baseline** |
|
|
32
|
+
| Elysia | 2.12 µs | 2.03x slower |
|
|
33
|
+
| Hono | 3.97 µs | 3.81x slower |
|
|
43
34
|
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
---
|
|
35
|
+
> Last Updated: Tue, 06 Jan 2026 13:27:36 GMT
|
|
47
36
|
|
|
37
|
+
<!-- MARKER: PERFORMANCE_TABLE_END -->
|
|
48
38
|
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
* **Ultra Low Latency:** Optimized to minimize processing overhead.
|
|
52
|
-
* **Zero Dependency:** Built natively for security and raw speed.
|
|
53
|
-
* **Optimized for Bun:** Leverages native Bun APIs for maximum performance.
|
|
54
|
-
* **Memory Efficient:** Minimal heap usage and clean garbage collection.
|
|
39
|
+
<!-- NOTE: The table above is automatically updated via scripts/update-readme.ts -->
|
|
55
40
|
|
|
56
41
|
---
|
|
57
42
|
|
|
@@ -59,94 +44,112 @@ Performance comparison between **BareJS**, **Elysia**, and **Hono**.
|
|
|
59
44
|
|
|
60
45
|
```bash
|
|
61
46
|
bun add barejs
|
|
47
|
+
|
|
62
48
|
```
|
|
63
49
|
|
|
64
50
|
---
|
|
65
51
|
|
|
66
|
-
## ⚡ Quick Start
|
|
52
|
+
## ⚡ Quick Start (All-in-One)
|
|
67
53
|
|
|
68
|
-
|
|
54
|
+
BareJS provides everything you need in a single entry point. No more messy imports.
|
|
69
55
|
|
|
70
56
|
```typescript
|
|
71
|
-
import {
|
|
57
|
+
import {
|
|
58
|
+
BareJS,
|
|
59
|
+
typebox,
|
|
60
|
+
logger,
|
|
61
|
+
cors,
|
|
62
|
+
staticFile,
|
|
63
|
+
bareAuth,
|
|
64
|
+
type Context
|
|
65
|
+
} from 'barejs';
|
|
66
|
+
import * as TB from '@sinclair/typebox';
|
|
72
67
|
|
|
73
68
|
const app = new BareJS();
|
|
74
69
|
|
|
75
|
-
//
|
|
76
|
-
app.
|
|
70
|
+
// 1. Global Middlewares
|
|
71
|
+
app.use(logger); // Beautiful terminal logs
|
|
72
|
+
app.use(cors()); // Enable CORS for all origins
|
|
73
|
+
app.use(staticFile('public')); // Serve images/css from /public
|
|
77
74
|
|
|
78
|
-
//
|
|
79
|
-
|
|
75
|
+
// 2. Schema Validation (TypeBox)
|
|
76
|
+
const UserSchema = TB.Type.Object({
|
|
77
|
+
name: TB.Type.String(),
|
|
78
|
+
age: TB.Type.Number()
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
// 3. Protected Route with Native Auth (Bun.crypto)
|
|
82
|
+
app.get('/admin', bareAuth('MY_SECRET'), (ctx: Context) => {
|
|
83
|
+
return ctx.json({
|
|
84
|
+
message: "Welcome Admin",
|
|
85
|
+
user: ctx.get('user')
|
|
86
|
+
});
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
// 4. Standard Route
|
|
90
|
+
app.post('/users', typebox(UserSchema), (ctx: Context) => {
|
|
91
|
+
return ctx.status(201).json({
|
|
92
|
+
message: "User Created",
|
|
93
|
+
data: ctx.body
|
|
94
|
+
});
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
app.listen(3000);
|
|
80
98
|
|
|
81
99
|
```
|
|
100
|
+
|
|
82
101
|
---
|
|
83
102
|
|
|
84
|
-
## 📖
|
|
103
|
+
## 📖 Deep Dive: Full Option Manual
|
|
85
104
|
|
|
86
|
-
### 1.
|
|
105
|
+
### 1. Essential Middlewares
|
|
87
106
|
|
|
88
|
-
|
|
107
|
+
BareJS comes with built-in high-performance middlewares:
|
|
89
108
|
|
|
90
|
-
*
|
|
91
|
-
*
|
|
92
|
-
*
|
|
93
|
-
* `ctx.params`: Route parameters (e.g., `/user/:id`).
|
|
109
|
+
* **`logger`**: Prints colored logs with response time (ms).
|
|
110
|
+
* **`cors(options?)`**: Configurable CORS headers.
|
|
111
|
+
* **`staticFile(root)`**: High-speed static file serving using `Bun.file()` (Zero-copy).
|
|
94
112
|
|
|
95
|
-
### 2.
|
|
113
|
+
### 2. Native Authentication (`bareAuth`)
|
|
96
114
|
|
|
97
|
-
|
|
115
|
+
No need for `jsonwebtoken` or `jose`. BareJS uses **Bun's Native Crypto API** for signing and verifying tokens.
|
|
98
116
|
|
|
99
117
|
```typescript
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
118
|
+
import { bareAuth, createToken } from 'barejs';
|
|
119
|
+
|
|
120
|
+
// Generate a token (e.g., in a login route)
|
|
121
|
+
const token = await createToken({ id: 1, role: 'admin' }, 'SECRET_KEY');
|
|
122
|
+
|
|
123
|
+
// Protect routes
|
|
124
|
+
app.get('/secure', bareAuth('SECRET_KEY'), (ctx) => {
|
|
125
|
+
const user = ctx.get('user'); // Access decoded payload
|
|
126
|
+
return { hello: user.role };
|
|
105
127
|
});
|
|
106
128
|
|
|
107
129
|
```
|
|
108
130
|
|
|
109
|
-
### 3.
|
|
131
|
+
### 3. Schema Validation Tiers
|
|
110
132
|
|
|
111
|
-
|
|
133
|
+
Choose the validator that fits your needs. `typebox` is recommended for maximum performance.
|
|
112
134
|
|
|
113
135
|
```typescript
|
|
114
|
-
|
|
115
|
-
name: 'barejs-db',
|
|
116
|
-
version: '1.0.0',
|
|
117
|
-
install: (app: BareJS) => {
|
|
118
|
-
app.use(async (ctx, next) => {
|
|
119
|
-
ctx.db = "CONNECTED";
|
|
120
|
-
return await next();
|
|
121
|
-
});
|
|
122
|
-
}
|
|
123
|
-
};
|
|
124
|
-
|
|
125
|
-
app.use(databasePlugin);
|
|
136
|
+
import { typebox, zod, native } from 'barejs';
|
|
126
137
|
|
|
127
|
-
|
|
138
|
+
app.post('/tb', typebox(Schema), handler); // JIT-Compiled (Fastest)
|
|
139
|
+
app.post('/zod', zod(ZodSchema), handler); // Industry Standard
|
|
140
|
+
app.post('/native', native(Schema), handler); // Zero dependencies
|
|
128
141
|
|
|
129
|
-
|
|
142
|
+
```
|
|
130
143
|
|
|
131
|
-
|
|
144
|
+
### 4. Direct Response Control
|
|
132
145
|
|
|
133
|
-
BareJS
|
|
146
|
+
BareJS context provides a chainable and intuitive API:
|
|
134
147
|
|
|
135
148
|
```typescript
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
// High Performance: TypeBox
|
|
141
|
-
const UserSchema = Type.Object({ name: Type.String() });
|
|
142
|
-
app.post('/tb', typebox(UserSchema), (ctx) => ctx.json(ctx.body));
|
|
143
|
-
|
|
144
|
-
// Popular Choice: Zod
|
|
145
|
-
const ZodSchema = z.object({ age: z.number() });
|
|
146
|
-
app.post('/zod', zod(ZodSchema), (ctx) => ctx.json(ctx.body));
|
|
147
|
-
|
|
148
|
-
// Zero Dependency: Native
|
|
149
|
-
app.post('/native', native({ properties: { id: { type: 'number' } } }), (ctx) => ctx.json(ctx.body));
|
|
149
|
+
app.get('/custom', (ctx) => {
|
|
150
|
+
ctx.setResHeader('X-Powered-By', 'BareJS');
|
|
151
|
+
return ctx.status(418).json({ message: "I'm a teapot" });
|
|
152
|
+
});
|
|
150
153
|
|
|
151
154
|
```
|
|
152
155
|
|
|
@@ -154,21 +157,23 @@ app.post('/native', native({ properties: { id: { type: 'number' } } }), (ctx) =>
|
|
|
154
157
|
|
|
155
158
|
## 🏗 Roadmap
|
|
156
159
|
|
|
157
|
-
* [x] **Middleware
|
|
158
|
-
* [x] **JIT Static Routing**:
|
|
159
|
-
* [x] **
|
|
160
|
-
* [x] **
|
|
161
|
-
* [x] **
|
|
162
|
-
* [
|
|
160
|
+
* [x] **Middleware Onion Model**: Async execution chain.
|
|
161
|
+
* [x] **JIT Static Routing**: Zero-overhead route lookup.
|
|
162
|
+
* [x] **Native Auth**: HMAC-SHA256 signing via Bun.crypto.
|
|
163
|
+
* [x] **Zero-Copy Static Server**: Direct `sendfile` via Bun.file.
|
|
164
|
+
* [x] **Full Plugin System**: Modular extensibility.
|
|
165
|
+
* [ ] **Auto-Generated Swagger**: OpenAPI documentation support.
|
|
166
|
+
* [ ] **Native Database Drivers**: Optimized Drizzle/Prisma integration.
|
|
163
167
|
|
|
164
168
|
---
|
|
165
169
|
|
|
166
170
|
## 💎 Credits & Dependencies
|
|
167
171
|
|
|
168
|
-
* **[Bun](https://bun.sh/)**: The foundational runtime
|
|
169
|
-
* **[TypeBox](https://github.com/sinclairzx81/typebox)
|
|
170
|
-
* **Inspiration**: Architectural patterns from **Koa** and **ElysiaJS**.
|
|
172
|
+
* **[Bun](https://bun.sh/)**: The foundational runtime.
|
|
173
|
+
* **[TypeBox](https://github.com/sinclairzx81/typebox)**: High-speed validation.
|
|
174
|
+
* **[Inspiration]**: Architectural patterns from **Koa** and **ElysiaJS**.
|
|
171
175
|
|
|
172
176
|
**Maintained by [xarhang**](https://www.google.com/search?q=https://github.com/xarhang)
|
|
173
177
|
**License: MIT**
|
|
174
|
-
|
|
178
|
+
|
|
179
|
+
---
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
var t8=Object.defineProperty;var g0=(Q,Y)=>{for(var X in Y)t8(Q,X,{get:Y[X],enumerable:!0,configurable:!0,set:(Z)=>Y[X]=()=>Z})};function u1(Q){return s(Q)&&globalThis.Symbol.asyncIterator in Q}function l1(Q){return s(Q)&&globalThis.Symbol.iterator in Q}function s1(Q){return Q instanceof globalThis.Promise}function F1(Q){return Q instanceof Date&&globalThis.Number.isFinite(Q.getTime())}function K1(Q){return Q instanceof globalThis.Uint8Array}function r1(Q,Y){return Y in Q}function s(Q){return Q!==null&&typeof Q==="object"}function V(Q){return globalThis.Array.isArray(Q)&&!globalThis.ArrayBuffer.isView(Q)}function v(Q){return Q===void 0}function D1(Q){return Q===null}function N1(Q){return typeof Q==="boolean"}function N(Q){return typeof Q==="number"}function a1(Q){return globalThis.Number.isInteger(Q)}function a(Q){return typeof Q==="bigint"}function f(Q){return typeof Q==="string"}function e1(Q){return typeof Q==="function"}function P1(Q){return typeof Q==="symbol"}function Q0(Q){return a(Q)||N1(Q)||D1(Q)||N(Q)||f(Q)||P1(Q)||v(Q)}var _;(function(Q){Q.InstanceMode="default",Q.ExactOptionalPropertyTypes=!1,Q.AllowArrayObject=!1,Q.AllowNaN=!1,Q.AllowNullVoid=!1;function Y(J,q){return Q.ExactOptionalPropertyTypes?q in J:J[q]!==void 0}Q.IsExactOptionalProperty=Y;function X(J){let q=s(J);return Q.AllowArrayObject?q:q&&!V(J)}Q.IsObjectLike=X;function Z(J){return X(J)&&!(J instanceof Date)&&!(J instanceof Uint8Array)}Q.IsRecordLike=Z;function G(J){return Q.AllowNaN?N(J):Number.isFinite(J)}Q.IsNumberLike=G;function W(J){let q=v(J);return Q.AllowNullVoid?q||J===null:q}Q.IsVoidLike=W})(_||(_={}));var Q1={};g0(Q1,{Set:()=>u8,Has:()=>c8,Get:()=>l8,Entries:()=>m8,Delete:()=>v8,Clear:()=>h8});var g1=new Map;function m8(){return new Map(g1)}function h8(){return g1.clear()}function v8(Q){return g1.delete(Q)}function c8(Q){return g1.has(Q)}function u8(Q,Y){g1.set(Q,Y)}function l8(Q){return g1.get(Q)}var r={};g0(r,{Set:()=>QQ,Has:()=>e8,Get:()=>XQ,Entries:()=>s8,Delete:()=>a8,Clear:()=>r8});var _1=new Map;function s8(){return new Map(_1)}function r8(){return _1.clear()}function a8(Q){return _1.delete(Q)}function e8(Q){return _1.has(Q)}function QQ(Q,Y){_1.set(Q,Y)}function XQ(Q){return _1.get(Q)}function X1(Q){return Array.isArray(Q)}function _0(Q){return typeof Q==="bigint"}function X0(Q){return typeof Q==="boolean"}function Y0(Q){return Q instanceof globalThis.Date}function A1(Q){return typeof Q==="number"}function I(Q){return typeof Q==="object"&&Q!==null}function Z0(Q){return Q instanceof globalThis.RegExp}function n(Q){return typeof Q==="string"}function G0(Q){return Q instanceof globalThis.Uint8Array}function $1(Q){return Q===void 0}function YQ(Q){return globalThis.Object.freeze(Q).map((Y)=>i1(Y))}function ZQ(Q){return Q}function GQ(Q){return Q}function WQ(Q){return Q}function zQ(Q){let Y={};for(let X of Object.getOwnPropertyNames(Q))Y[X]=i1(Q[X]);for(let X of Object.getOwnPropertySymbols(Q))Y[X]=i1(Q[X]);return globalThis.Object.freeze(Y)}function i1(Q){return X1(Q)?YQ(Q):Y0(Q)?ZQ(Q):G0(Q)?GQ(Q):Z0(Q)?WQ(Q):I(Q)?zQ(Q):Q}function $Q(Q){return Q.map((Y)=>z0(Y))}function JQ(Q){return new Date(Q.getTime())}function HQ(Q){return new Uint8Array(Q)}function qQ(Q){return new RegExp(Q.source,Q.flags)}function LQ(Q){let Y={};for(let X of Object.getOwnPropertyNames(Q))Y[X]=z0(Q[X]);for(let X of Object.getOwnPropertySymbols(Q))Y[X]=z0(Q[X]);return Y}function z0(Q){return X1(Q)?$Q(Q):Y0(Q)?JQ(Q):G0(Q)?HQ(Q):Z0(Q)?qQ(Q):I(Q)?LQ(Q):Q}function k0(Q){return z0(Q)}function t(Q,Y){let X=Y!==void 0?{...Y,...Q}:Q;switch(_.InstanceMode){case"freeze":return i1(X);case"clone":return k0(X);default:return X}}var B1=Symbol.for("TypeBox.Transform");var J1=Symbol.for("TypeBox.Optional");var j=Symbol.for("TypeBox.Kind");class T extends Error{constructor(Q){super(Q)}}function E0(Q){return t({[j]:"MappedResult",properties:Q})}function MQ(Q,Y){let{[Y]:X,...Z}=Q;return Z}function k1(Q,Y){return Y.reduce((X,Z)=>MQ(X,Z),Q)}function c(Q){return t({[j]:"Never",not:{}},Q)}function E1(Q){return I(Q)&&Q[J1]==="Optional"}function AQ(Q){return S(Q,"Any")}function BQ(Q){return S(Q,"Argument")}function y1(Q){return S(Q,"Array")}function 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 xQ(Q){return S(Q,"Integer")}function p1(Q){return S(Q,"Intersect")}function CQ(Q){return S(Q,"Iterator")}function S(Q,Y){return I(Q)&&j in Q&&Q[j]===Y}function OQ(Q){return S(Q,"Literal")}function V0(Q){return S(Q,"MappedKey")}function $0(Q){return S(Q,"MappedResult")}function J0(Q){return S(Q,"Never")}function FQ(Q){return S(Q,"Not")}function KQ(Q){return S(Q,"Null")}function gQ(Q){return S(Q,"Number")}function b1(Q){return S(Q,"Object")}function _Q(Q){return S(Q,"Promise")}function M0(Q){return S(Q,"Record")}function T0(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 F(Q){return I(Q)&&B1 in Q}function o1(Q){return S(Q,"Tuple")}function n1(Q){return S(Q,"Undefined")}function t1(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)&&j in Q&&n(Q[j])}function u(Q){return AQ(Q)||BQ(Q)||y1(Q)||DQ(Q)||jQ(Q)||wQ(Q)||NQ(Q)||PQ(Q)||bQ(Q)||SQ(Q)||xQ(Q)||p1(Q)||CQ(Q)||OQ(Q)||V0(Q)||$0(Q)||J0(Q)||FQ(Q)||KQ(Q)||gQ(Q)||b1(Q)||_Q(Q)||M0(Q)||T0(Q)||kQ(Q)||EQ(Q)||VQ(Q)||TQ(Q)||IQ(Q)||o1(Q)||n1(Q)||t1(Q)||dQ(Q)||fQ(Q)||iQ(Q)||yQ(Q)||pQ(Q)}function oQ(Q){return t(k1(Q,[J1]))}function nQ(Q){return t({...Q,[J1]:"Optional"})}function tQ(Q,Y){return Y===!1?oQ(Q):nQ(Q)}function V1(Q,Y){let X=Y??!0;return $0(Q)?I0(Q,X):tQ(Q,X)}function mQ(Q,Y){let X={};for(let Z of globalThis.Object.getOwnPropertyNames(Q))X[Z]=V1(Q[Z],Y);return X}function hQ(Q,Y){return mQ(Q.properties,Y)}function I0(Q,Y){let X=hQ(Q,Y);return E0(X)}function U0(Q,Y={}){let X=Q.every((G)=>b1(G)),Z=u(Y.unevaluatedProperties)?{unevaluatedProperties:Y.unevaluatedProperties}:{};return t(Y.unevaluatedProperties===!1||u(Y.unevaluatedProperties)||X?{...Z,[j]:"Intersect",type:"object",allOf:Q}:{...Z,[j]:"Intersect",allOf:Q},Y)}function vQ(Q){return Q.every((Y)=>E1(Y))}function cQ(Q){return k1(Q,[J1])}function d0(Q){return Q.map((Y)=>E1(Y)?cQ(Y):Y)}function uQ(Q,Y){return vQ(Q)?V1(U0(d0(Q),Y)):U0(d0(Q),Y)}function f0(Q,Y={}){if(Q.length===1)return t(Q[0],Y);if(Q.length===0)return c(Y);if(Q.some((X)=>F(X)))throw Error("Cannot intersect transform types");return uQ(Q,Y)}function R0(Q,Y){return t({[j]:"Union",anyOf:Q},Y)}function lQ(Q){return Q.some((Y)=>E1(Y))}function i0(Q){return Q.map((Y)=>E1(Y)?sQ(Y):Y)}function sQ(Q){return k1(Q,[J1])}function rQ(Q,Y){return lQ(Q)?V1(R0(i0(Q),Y)):R0(i0(Q),Y)}function A0(Q,Y){return Q.length===1?t(Q[0],Y):Q.length===0?c(Y):rQ(Q,Y)}function y0(Q,Y){return Q.map((X)=>p0(X,Y))}function aQ(Q){return Q.filter((Y)=>!J0(Y))}function eQ(Q,Y){return f0(aQ(y0(Q,Y)))}function QX(Q){return Q.some((Y)=>J0(Y))?[]:Q}function XX(Q,Y){return A0(QX(y0(Q,Y)))}function YX(Q,Y){return Y in Q?Q[Y]:Y==="[number]"?A0(Q):c()}function ZX(Q,Y){return Y==="[number]"?Q:c()}function GX(Q,Y){return Y in Q?Q[Y]:c()}function p0(Q,Y){return p1(Q)?eQ(Q.allOf,Y):t1(Q)?XX(Q.anyOf,Y):o1(Q)?YX(Q.items??[],Y):y1(Q)?ZX(Q.items,Y):b1(Q)?GX(Q.properties,Y):c()}function o0(Q,Y){return Y.map((X)=>p0(Q,X))}function WX(Q,Y){return Q.filter((X)=>Y.includes(X))}function zX(Q,Y){return Q.reduce((X,Z)=>{return WX(X,Z)},Y)}function n0(Q){return Q.length===1?Q[0]:Q.length>1?zX(Q.slice(1),Q[0]):[]}function t0(Q){let Y=[];for(let X of Q)Y.push(...X);return Y}function m0(...Q){let[Y,X]=typeof Q[0]==="string"?[Q[0],Q[1]]:[Q[0].$id,Q[1]];if(typeof Y!=="string")throw new T("Ref: $ref must be a string");return t({[j]:"Ref",$ref:Y},X)}function h0(Q){let Y=[];for(let X of Q)Y.push(w1(X));return Y}function $X(Q){let Y=h0(Q);return t0(Y)}function JX(Q){let Y=h0(Q);return n0(Y)}function HX(Q){return Q.map((Y,X)=>X.toString())}function qX(Q){return["[number]"]}function LX(Q){return globalThis.Object.getOwnPropertyNames(Q)}function MX(Q){if(!B0)return[];return globalThis.Object.getOwnPropertyNames(Q).map((X)=>{return X[0]==="^"&&X[X.length-1]==="$"?X.slice(1,X.length-1):X})}function w1(Q){return p1(Q)?$X(Q.allOf):t1(Q)?JX(Q.anyOf):o1(Q)?HX(Q.items??[]):y1(Q)?qX(Q.items):b1(Q)?LX(Q.properties):M0(Q)?MX(Q.patternProperties):[]}var B0=!1;function q1(Q){B0=!0;let Y=w1(Q);return B0=!1,`^(${Y.map((Z)=>`(${Z})`).join("|")})$`}function H0(Q){let Y=w1(Q),X=o0(Q,Y);return Y.map((Z,G)=>[Y[G],X[G]])}function UX(Q){return Q.allOf.every((Y)=>L1(Y))}function RX(Q){return Q.anyOf.some((Y)=>L1(Y))}function AX(Q){return!L1(Q.not)}function L1(Q){return Q[j]==="Intersect"?UX(Q):Q[j]==="Union"?RX(Q):Q[j]==="Not"?AX(Q):Q[j]==="Undefined"?!0:!1}function BX(Q){switch(Q.errorType){case H.ArrayContains:return"Expected array to contain at least one matching value";case H.ArrayMaxContains:return`Expected array to contain no more than ${Q.schema.maxContains} matching values`;case H.ArrayMinContains:return`Expected array to contain at least ${Q.schema.minContains} matching values`;case H.ArrayMaxItems:return`Expected array length to be less or equal to ${Q.schema.maxItems}`;case H.ArrayMinItems:return`Expected array length to be greater or equal to ${Q.schema.minItems}`;case H.ArrayUniqueItems:return"Expected array elements to be unique";case H.Array:return"Expected array";case H.AsyncIterator:return"Expected AsyncIterator";case H.BigIntExclusiveMaximum:return`Expected bigint to be less than ${Q.schema.exclusiveMaximum}`;case H.BigIntExclusiveMinimum:return`Expected bigint to be greater than ${Q.schema.exclusiveMinimum}`;case H.BigIntMaximum:return`Expected bigint to be less or equal to ${Q.schema.maximum}`;case H.BigIntMinimum:return`Expected bigint to be greater or equal to ${Q.schema.minimum}`;case H.BigIntMultipleOf:return`Expected bigint to be a multiple of ${Q.schema.multipleOf}`;case H.BigInt:return"Expected bigint";case H.Boolean:return"Expected boolean";case H.DateExclusiveMinimumTimestamp:return`Expected Date timestamp to be greater than ${Q.schema.exclusiveMinimumTimestamp}`;case H.DateExclusiveMaximumTimestamp:return`Expected Date timestamp to be less than ${Q.schema.exclusiveMaximumTimestamp}`;case H.DateMinimumTimestamp:return`Expected Date timestamp to be greater or equal to ${Q.schema.minimumTimestamp}`;case H.DateMaximumTimestamp:return`Expected Date timestamp to be less or equal to ${Q.schema.maximumTimestamp}`;case H.DateMultipleOfTimestamp:return`Expected Date timestamp to be a multiple of ${Q.schema.multipleOfTimestamp}`;case H.Date:return"Expected Date";case H.Function:return"Expected function";case H.IntegerExclusiveMaximum:return`Expected integer to be less than ${Q.schema.exclusiveMaximum}`;case H.IntegerExclusiveMinimum:return`Expected integer to be greater than ${Q.schema.exclusiveMinimum}`;case H.IntegerMaximum:return`Expected integer to be less or equal to ${Q.schema.maximum}`;case H.IntegerMinimum:return`Expected integer to be greater or equal to ${Q.schema.minimum}`;case H.IntegerMultipleOf:return`Expected integer to be a multiple of ${Q.schema.multipleOf}`;case H.Integer:return"Expected integer";case H.IntersectUnevaluatedProperties:return"Unexpected property";case H.Intersect:return"Expected all values to match";case H.Iterator:return"Expected Iterator";case H.Literal:return`Expected ${typeof Q.schema.const==="string"?`'${Q.schema.const}'`:Q.schema.const}`;case H.Never:return"Never";case H.Not:return"Value should not match";case H.Null:return"Expected null";case H.NumberExclusiveMaximum:return`Expected number to be less than ${Q.schema.exclusiveMaximum}`;case H.NumberExclusiveMinimum:return`Expected number to be greater than ${Q.schema.exclusiveMinimum}`;case H.NumberMaximum:return`Expected number to be less or equal to ${Q.schema.maximum}`;case H.NumberMinimum:return`Expected number to be greater or equal to ${Q.schema.minimum}`;case H.NumberMultipleOf:return`Expected number to be a multiple of ${Q.schema.multipleOf}`;case H.Number:return"Expected number";case H.Object:return"Expected object";case H.ObjectAdditionalProperties:return"Unexpected property";case H.ObjectMaxProperties:return`Expected object to have no more than ${Q.schema.maxProperties} properties`;case H.ObjectMinProperties:return`Expected object to have at least ${Q.schema.minProperties} properties`;case H.ObjectRequiredProperty:return"Expected required property";case H.Promise:return"Expected Promise";case H.RegExp:return"Expected string to match regular expression";case H.StringFormatUnknown:return`Unknown format '${Q.schema.format}'`;case H.StringFormat:return`Expected string to match '${Q.schema.format}' format`;case H.StringMaxLength:return`Expected string length less or equal to ${Q.schema.maxLength}`;case H.StringMinLength:return`Expected string length greater or equal to ${Q.schema.minLength}`;case H.StringPattern:return`Expected string to match '${Q.schema.pattern}'`;case H.String:return"Expected string";case H.Symbol:return"Expected symbol";case H.TupleLength:return`Expected tuple to have ${Q.schema.maxItems||0} elements`;case H.Tuple:return"Expected tuple";case H.Uint8ArrayMaxByteLength:return`Expected byte length less or equal to ${Q.schema.maxByteLength}`;case H.Uint8ArrayMinByteLength:return`Expected byte length greater or equal to ${Q.schema.minByteLength}`;case H.Uint8Array:return"Expected Uint8Array";case H.Undefined:return"Expected undefined";case H.Union:return"Expected union value";case H.Void:return"Expected void";case H.Kind:return`Expected kind '${Q.schema[j]}'`;default:return"Unknown error type"}}var wX=BX;function v0(){return wX}class c0 extends T{constructor(Q){super(`Unable to dereference schema with $id '${Q.$ref}'`);this.schema=Q}}function jX(Q,Y){let X=Y.find((Z)=>Z.$id===Q.$ref);if(X===void 0)throw new c0(Q);return i(X,Y)}function j1(Q,Y){if(!f(Q.$id)||Y.some((X)=>X.$id===Q.$id))return Y;return Y.push(Q),Y}function i(Q,Y){return Q[j]==="This"||Q[j]==="Ref"?jX(Q,Y):Q}class u0 extends T{constructor(Q){super("Unable to hash value");this.value=Q}}var e;(function(Q){Q[Q.Undefined=0]="Undefined",Q[Q.Null=1]="Null",Q[Q.Boolean=2]="Boolean",Q[Q.Number=3]="Number",Q[Q.String=4]="String",Q[Q.Object=5]="Object",Q[Q.Array=6]="Array",Q[Q.Date=7]="Date",Q[Q.Uint8Array=8]="Uint8Array",Q[Q.Symbol=9]="Symbol",Q[Q.BigInt=10]="BigInt"})(e||(e={}));var T1=BigInt("14695981039346656037"),[DX,NX]=[BigInt("1099511628211"),BigInt("18446744073709551616")],PX=Array.from({length:256}).map((Q,Y)=>BigInt(Y)),l0=new Float64Array(1),s0=new DataView(l0.buffer),r0=new Uint8Array(l0.buffer);function*bX(Q){let Y=Q===0?1:Math.ceil(Math.floor(Math.log2(Q)+1)/8);for(let X=0;X<Y;X++)yield Q>>8*(Y-1-X)&255}function SX(Q){h(e.Array);for(let Y of Q)I1(Y)}function xX(Q){h(e.Boolean),h(Q?1:0)}function CX(Q){h(e.BigInt),s0.setBigInt64(0,Q);for(let Y of r0)h(Y)}function OX(Q){h(e.Date),I1(Q.getTime())}function FX(Q){h(e.Null)}function KX(Q){h(e.Number),s0.setFloat64(0,Q);for(let Y of r0)h(Y)}function gX(Q){h(e.Object);for(let Y of globalThis.Object.getOwnPropertyNames(Q).sort())I1(Y),I1(Q[Y])}function _X(Q){h(e.String);for(let Y=0;Y<Q.length;Y++)for(let X of bX(Q.charCodeAt(Y)))h(X)}function kX(Q){h(e.Symbol),I1(Q.description)}function EX(Q){h(e.Uint8Array);for(let Y=0;Y<Q.length;Y++)h(Q[Y])}function VX(Q){return h(e.Undefined)}function I1(Q){if(V(Q))return SX(Q);if(N1(Q))return xX(Q);if(a(Q))return CX(Q);if(F1(Q))return OX(Q);if(D1(Q))return FX(Q);if(N(Q))return KX(Q);if(s(Q))return gX(Q);if(f(Q))return _X(Q);if(P1(Q))return kX(Q);if(K1(Q))return EX(Q);if(v(Q))return VX(Q);throw new u0(Q)}function h(Q){T1=T1^PX[Q],T1=T1*DX%NX}function d1(Q){return T1=BigInt("14695981039346656037"),I1(Q),T1}var TX=["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 a0(Q){try{return new RegExp(Q),!0}catch{return!1}}function w0(Q){if(!n(Q))return!1;for(let Y=0;Y<Q.length;Y++){let X=Q.charCodeAt(Y);if(X>=7&&X<=13||X===27||X===127)return!1}return!0}function e0(Q){return j0(Q)||k(Q)}function m1(Q){return $1(Q)||_0(Q)}function K(Q){return $1(Q)||A1(Q)}function j0(Q){return $1(Q)||X0(Q)}function C(Q){return $1(Q)||n(Q)}function IX(Q){return $1(Q)||n(Q)&&w0(Q)&&a0(Q)}function dX(Q){return $1(Q)||n(Q)&&w0(Q)}function Q8(Q){return $1(Q)||k(Q)}function fX(Q){return x(Q,"Any")&&C(Q.$id)}function iX(Q){return x(Q,"Argument")&&A1(Q.index)}function yX(Q){return x(Q,"Array")&&Q.type==="array"&&C(Q.$id)&&k(Q.items)&&K(Q.minItems)&&K(Q.maxItems)&&j0(Q.uniqueItems)&&Q8(Q.contains)&&K(Q.minContains)&&K(Q.maxContains)}function pX(Q){return x(Q,"AsyncIterator")&&Q.type==="AsyncIterator"&&C(Q.$id)&&k(Q.items)}function oX(Q){return x(Q,"BigInt")&&Q.type==="bigint"&&C(Q.$id)&&m1(Q.exclusiveMaximum)&&m1(Q.exclusiveMinimum)&&m1(Q.maximum)&&m1(Q.minimum)&&m1(Q.multipleOf)}function nX(Q){return x(Q,"Boolean")&&Q.type==="boolean"&&C(Q.$id)}function tX(Q){return x(Q,"Computed")&&n(Q.target)&&X1(Q.parameters)&&Q.parameters.every((Y)=>k(Y))}function mX(Q){return x(Q,"Constructor")&&Q.type==="Constructor"&&C(Q.$id)&&X1(Q.parameters)&&Q.parameters.every((Y)=>k(Y))&&k(Q.returns)}function hX(Q){return x(Q,"Date")&&Q.type==="Date"&&C(Q.$id)&&K(Q.exclusiveMaximumTimestamp)&&K(Q.exclusiveMinimumTimestamp)&&K(Q.maximumTimestamp)&&K(Q.minimumTimestamp)&&K(Q.multipleOfTimestamp)}function vX(Q){return x(Q,"Function")&&Q.type==="Function"&&C(Q.$id)&&X1(Q.parameters)&&Q.parameters.every((Y)=>k(Y))&&k(Q.returns)}function cX(Q){return x(Q,"Integer")&&Q.type==="integer"&&C(Q.$id)&&K(Q.exclusiveMaximum)&&K(Q.exclusiveMinimum)&&K(Q.maximum)&&K(Q.minimum)&&K(Q.multipleOf)}function X8(Q){return I(Q)&&Object.entries(Q).every(([Y,X])=>w0(Y)&&k(X))}function uX(Q){return x(Q,"Intersect")&&(n(Q.type)&&Q.type!=="object"?!1:!0)&&X1(Q.allOf)&&Q.allOf.every((Y)=>k(Y)&&!UY(Y))&&C(Q.type)&&(j0(Q.unevaluatedProperties)||Q8(Q.unevaluatedProperties))&&C(Q.$id)}function lX(Q){return x(Q,"Iterator")&&Q.type==="Iterator"&&C(Q.$id)&&k(Q.items)}function x(Q,Y){return I(Q)&&j in Q&&Q[j]===Y}function sX(Q){return x(Q,"Literal")&&C(Q.$id)&&rX(Q.const)}function rX(Q){return X0(Q)||A1(Q)||n(Q)}function aX(Q){return x(Q,"MappedKey")&&X1(Q.keys)&&Q.keys.every((Y)=>A1(Y)||n(Y))}function eX(Q){return x(Q,"MappedResult")&&X8(Q.properties)}function QY(Q){return x(Q,"Never")&&I(Q.not)&&Object.getOwnPropertyNames(Q.not).length===0}function XY(Q){return x(Q,"Not")&&k(Q.not)}function YY(Q){return x(Q,"Null")&&Q.type==="null"&&C(Q.$id)}function ZY(Q){return x(Q,"Number")&&Q.type==="number"&&C(Q.$id)&&K(Q.exclusiveMaximum)&&K(Q.exclusiveMinimum)&&K(Q.maximum)&&K(Q.minimum)&&K(Q.multipleOf)}function GY(Q){return x(Q,"Object")&&Q.type==="object"&&C(Q.$id)&&X8(Q.properties)&&e0(Q.additionalProperties)&&K(Q.minProperties)&&K(Q.maxProperties)}function WY(Q){return x(Q,"Promise")&&Q.type==="Promise"&&C(Q.$id)&&k(Q.item)}function zY(Q){return x(Q,"Record")&&Q.type==="object"&&C(Q.$id)&&e0(Q.additionalProperties)&&I(Q.patternProperties)&&((Y)=>{let X=Object.getOwnPropertyNames(Y.patternProperties);return X.length===1&&a0(X[0])&&I(Y.patternProperties)&&k(Y.patternProperties[X[0]])})(Q)}function $Y(Q){return x(Q,"Ref")&&C(Q.$id)&&n(Q.$ref)}function JY(Q){return x(Q,"RegExp")&&C(Q.$id)&&n(Q.source)&&n(Q.flags)&&K(Q.maxLength)&&K(Q.minLength)}function HY(Q){return x(Q,"String")&&Q.type==="string"&&C(Q.$id)&&K(Q.minLength)&&K(Q.maxLength)&&IX(Q.pattern)&&dX(Q.format)}function qY(Q){return x(Q,"Symbol")&&Q.type==="symbol"&&C(Q.$id)}function LY(Q){return x(Q,"TemplateLiteral")&&Q.type==="string"&&n(Q.pattern)&&Q.pattern[0]==="^"&&Q.pattern[Q.pattern.length-1]==="$"}function MY(Q){return x(Q,"This")&&C(Q.$id)&&n(Q.$ref)}function UY(Q){return I(Q)&&B1 in Q}function RY(Q){return x(Q,"Tuple")&&Q.type==="array"&&C(Q.$id)&&A1(Q.minItems)&&A1(Q.maxItems)&&Q.minItems===Q.maxItems&&($1(Q.items)&&$1(Q.additionalItems)&&Q.minItems===0||X1(Q.items)&&Q.items.every((Y)=>k(Y)))}function AY(Q){return x(Q,"Undefined")&&Q.type==="undefined"&&C(Q.$id)}function BY(Q){return x(Q,"Union")&&C(Q.$id)&&I(Q)&&X1(Q.anyOf)&&Q.anyOf.every((Y)=>k(Y))}function wY(Q){return x(Q,"Uint8Array")&&Q.type==="Uint8Array"&&C(Q.$id)&&K(Q.minByteLength)&&K(Q.maxByteLength)}function jY(Q){return x(Q,"Unknown")&&C(Q.$id)}function DY(Q){return x(Q,"Unsafe")}function NY(Q){return x(Q,"Void")&&Q.type==="void"&&C(Q.$id)}function PY(Q){return I(Q)&&j in Q&&n(Q[j])&&!TX.includes(Q[j])}function k(Q){return I(Q)&&(fX(Q)||iX(Q)||yX(Q)||nX(Q)||oX(Q)||pX(Q)||tX(Q)||mX(Q)||hX(Q)||vX(Q)||cX(Q)||uX(Q)||lX(Q)||sX(Q)||aX(Q)||eX(Q)||QY(Q)||XY(Q)||YY(Q)||ZY(Q)||GY(Q)||WY(Q)||zY(Q)||$Y(Q)||JY(Q)||HY(Q)||qY(Q)||LY(Q)||MY(Q)||RY(Q)||AY(Q)||BY(Q)||wY(Q)||jY(Q)||DY(Q)||NY(Q)||PY(Q))}class Y8 extends T{constructor(Q){super("Unknown type");this.schema=Q}}function bY(Q){return Q[j]==="Any"||Q[j]==="Unknown"}function P(Q){return Q!==void 0}function SY(Q,Y,X){return!0}function xY(Q,Y,X){return!0}function CY(Q,Y,X){if(!V(X))return!1;if(P(Q.minItems)&&!(X.length>=Q.minItems))return!1;if(P(Q.maxItems)&&!(X.length<=Q.maxItems))return!1;if(!X.every((W)=>y(Q.items,Y,W)))return!1;if(Q.uniqueItems===!0&&!function(){let W=new Set;for(let J of X){let q=d1(J);if(W.has(q))return!1;else W.add(q)}return!0}())return!1;if(!(P(Q.contains)||N(Q.minContains)||N(Q.maxContains)))return!0;let Z=P(Q.contains)?Q.contains:c(),G=X.reduce((W,J)=>y(Z,Y,J)?W+1:W,0);if(G===0)return!1;if(N(Q.minContains)&&G<Q.minContains)return!1;if(N(Q.maxContains)&&G>Q.maxContains)return!1;return!0}function OY(Q,Y,X){return u1(X)}function FY(Q,Y,X){if(!a(X))return!1;if(P(Q.exclusiveMaximum)&&!(X<Q.exclusiveMaximum))return!1;if(P(Q.exclusiveMinimum)&&!(X>Q.exclusiveMinimum))return!1;if(P(Q.maximum)&&!(X<=Q.maximum))return!1;if(P(Q.minimum)&&!(X>=Q.minimum))return!1;if(P(Q.multipleOf)&&X%Q.multipleOf!==BigInt(0))return!1;return!0}function KY(Q,Y,X){return N1(X)}function gY(Q,Y,X){return y(Q.returns,Y,X.prototype)}function _Y(Q,Y,X){if(!F1(X))return!1;if(P(Q.exclusiveMaximumTimestamp)&&!(X.getTime()<Q.exclusiveMaximumTimestamp))return!1;if(P(Q.exclusiveMinimumTimestamp)&&!(X.getTime()>Q.exclusiveMinimumTimestamp))return!1;if(P(Q.maximumTimestamp)&&!(X.getTime()<=Q.maximumTimestamp))return!1;if(P(Q.minimumTimestamp)&&!(X.getTime()>=Q.minimumTimestamp))return!1;if(P(Q.multipleOfTimestamp)&&X.getTime()%Q.multipleOfTimestamp!==0)return!1;return!0}function kY(Q,Y,X){return e1(X)}function EY(Q,Y,X){let Z=globalThis.Object.values(Q.$defs),G=Q.$defs[Q.$ref];return y(G,[...Y,...Z],X)}function VY(Q,Y,X){if(!a1(X))return!1;if(P(Q.exclusiveMaximum)&&!(X<Q.exclusiveMaximum))return!1;if(P(Q.exclusiveMinimum)&&!(X>Q.exclusiveMinimum))return!1;if(P(Q.maximum)&&!(X<=Q.maximum))return!1;if(P(Q.minimum)&&!(X>=Q.minimum))return!1;if(P(Q.multipleOf)&&X%Q.multipleOf!==0)return!1;return!0}function TY(Q,Y,X){let Z=Q.allOf.every((G)=>y(G,Y,X));if(Q.unevaluatedProperties===!1){let G=new RegExp(q1(Q)),W=Object.getOwnPropertyNames(X).every((J)=>G.test(J));return Z&&W}else if(u(Q.unevaluatedProperties)){let G=new RegExp(q1(Q)),W=Object.getOwnPropertyNames(X).every((J)=>G.test(J)||y(Q.unevaluatedProperties,Y,X[J]));return Z&&W}else return Z}function IY(Q,Y,X){return l1(X)}function dY(Q,Y,X){return X===Q.const}function fY(Q,Y,X){return!1}function iY(Q,Y,X){return!y(Q.not,Y,X)}function yY(Q,Y,X){return D1(X)}function pY(Q,Y,X){if(!_.IsNumberLike(X))return!1;if(P(Q.exclusiveMaximum)&&!(X<Q.exclusiveMaximum))return!1;if(P(Q.exclusiveMinimum)&&!(X>Q.exclusiveMinimum))return!1;if(P(Q.minimum)&&!(X>=Q.minimum))return!1;if(P(Q.maximum)&&!(X<=Q.maximum))return!1;if(P(Q.multipleOf)&&X%Q.multipleOf!==0)return!1;return!0}function oY(Q,Y,X){if(!_.IsObjectLike(X))return!1;if(P(Q.minProperties)&&!(Object.getOwnPropertyNames(X).length>=Q.minProperties))return!1;if(P(Q.maxProperties)&&!(Object.getOwnPropertyNames(X).length<=Q.maxProperties))return!1;let Z=Object.getOwnPropertyNames(Q.properties);for(let G of Z){let W=Q.properties[G];if(Q.required&&Q.required.includes(G)){if(!y(W,Y,X[G]))return!1;if((L1(W)||bY(W))&&!(G in X))return!1}else if(_.IsExactOptionalProperty(X,G)&&!y(W,Y,X[G]))return!1}if(Q.additionalProperties===!1){let G=Object.getOwnPropertyNames(X);if(Q.required&&Q.required.length===Z.length&&G.length===Z.length)return!0;else return G.every((W)=>Z.includes(W))}else if(typeof Q.additionalProperties==="object")return Object.getOwnPropertyNames(X).every((W)=>Z.includes(W)||y(Q.additionalProperties,Y,X[W]));else return!0}function nY(Q,Y,X){return s1(X)}function tY(Q,Y,X){if(!_.IsRecordLike(X))return!1;if(P(Q.minProperties)&&!(Object.getOwnPropertyNames(X).length>=Q.minProperties))return!1;if(P(Q.maxProperties)&&!(Object.getOwnPropertyNames(X).length<=Q.maxProperties))return!1;let[Z,G]=Object.entries(Q.patternProperties)[0],W=new RegExp(Z),J=Object.entries(X).every(([w,B])=>{return W.test(w)?y(G,Y,B):!0}),q=typeof Q.additionalProperties==="object"?Object.entries(X).every(([w,B])=>{return!W.test(w)?y(Q.additionalProperties,Y,B):!0}):!0,A=Q.additionalProperties===!1?Object.getOwnPropertyNames(X).every((w)=>{return W.test(w)}):!0;return J&&q&&A}function mY(Q,Y,X){return y(i(Q,Y),Y,X)}function hY(Q,Y,X){let Z=new RegExp(Q.source,Q.flags);if(P(Q.minLength)){if(!(X.length>=Q.minLength))return!1}if(P(Q.maxLength)){if(!(X.length<=Q.maxLength))return!1}return Z.test(X)}function vY(Q,Y,X){if(!f(X))return!1;if(P(Q.minLength)){if(!(X.length>=Q.minLength))return!1}if(P(Q.maxLength)){if(!(X.length<=Q.maxLength))return!1}if(P(Q.pattern)){if(!new RegExp(Q.pattern).test(X))return!1}if(P(Q.format)){if(!Q1.Has(Q.format))return!1;return Q1.Get(Q.format)(X)}return!0}function cY(Q,Y,X){return P1(X)}function uY(Q,Y,X){return f(X)&&new RegExp(Q.pattern).test(X)}function lY(Q,Y,X){return y(i(Q,Y),Y,X)}function sY(Q,Y,X){if(!V(X))return!1;if(Q.items===void 0&&X.length!==0)return!1;if(X.length!==Q.maxItems)return!1;if(!Q.items)return!0;for(let Z=0;Z<Q.items.length;Z++)if(!y(Q.items[Z],Y,X[Z]))return!1;return!0}function rY(Q,Y,X){return v(X)}function aY(Q,Y,X){return Q.anyOf.some((Z)=>y(Z,Y,X))}function eY(Q,Y,X){if(!K1(X))return!1;if(P(Q.maxByteLength)&&!(X.length<=Q.maxByteLength))return!1;if(P(Q.minByteLength)&&!(X.length>=Q.minByteLength))return!1;return!0}function Q4(Q,Y,X){return!0}function X4(Q,Y,X){return _.IsVoidLike(X)}function Y4(Q,Y,X){if(!r.Has(Q[j]))return!1;return r.Get(Q[j])(Q,X)}function y(Q,Y,X){let Z=P(Q.$id)?j1(Q,Y):Y,G=Q;switch(G[j]){case"Any":return SY(G,Z,X);case"Argument":return xY(G,Z,X);case"Array":return CY(G,Z,X);case"AsyncIterator":return OY(G,Z,X);case"BigInt":return FY(G,Z,X);case"Boolean":return KY(G,Z,X);case"Constructor":return gY(G,Z,X);case"Date":return _Y(G,Z,X);case"Function":return kY(G,Z,X);case"Import":return EY(G,Z,X);case"Integer":return VY(G,Z,X);case"Intersect":return TY(G,Z,X);case"Iterator":return IY(G,Z,X);case"Literal":return dY(G,Z,X);case"Never":return fY(G,Z,X);case"Not":return iY(G,Z,X);case"Null":return yY(G,Z,X);case"Number":return pY(G,Z,X);case"Object":return oY(G,Z,X);case"Promise":return nY(G,Z,X);case"Record":return tY(G,Z,X);case"Ref":return mY(G,Z,X);case"RegExp":return hY(G,Z,X);case"String":return vY(G,Z,X);case"Symbol":return cY(G,Z,X);case"TemplateLiteral":return uY(G,Z,X);case"This":return lY(G,Z,X);case"Tuple":return sY(G,Z,X);case"Undefined":return rY(G,Z,X);case"Union":return aY(G,Z,X);case"Uint8Array":return eY(G,Z,X);case"Unknown":return Q4(G,Z,X);case"Void":return X4(G,Z,X);default:if(!r.Has(G[j]))throw new Y8(G);return Y4(G,Z,X)}}function S1(...Q){return Q.length===3?y(Q[0],Q[1],Q[2]):y(Q[0],[],Q[1])}var H;(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"})(H||(H={}));class Z8 extends T{constructor(Q){super("Unknown type");this.schema=Q}}function M1(Q){return Q.replace(/~/g,"~0").replace(/\//g,"~1")}function b(Q){return Q!==void 0}class D0{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,Y,X,Z,G=[]){return{type:Q,schema:Y,path:X,value:Z,message:v0()({errorType:Q,path:X,schema:Y,value:Z,errors:G}),errors:G}}function*Z4(Q,Y,X,Z){}function*G4(Q,Y,X,Z){}function*W4(Q,Y,X,Z){if(!V(Z))return yield L(H.Array,Q,X,Z);if(b(Q.minItems)&&!(Z.length>=Q.minItems))yield L(H.ArrayMinItems,Q,X,Z);if(b(Q.maxItems)&&!(Z.length<=Q.maxItems))yield L(H.ArrayMaxItems,Q,X,Z);for(let J=0;J<Z.length;J++)yield*p(Q.items,Y,`${X}/${J}`,Z[J]);if(Q.uniqueItems===!0&&!function(){let J=new Set;for(let q of Z){let A=d1(q);if(J.has(A))return!1;else J.add(A)}return!0}())yield L(H.ArrayUniqueItems,Q,X,Z);if(!(b(Q.contains)||b(Q.minContains)||b(Q.maxContains)))return;let G=b(Q.contains)?Q.contains:c(),W=Z.reduce((J,q,A)=>p(G,Y,`${X}${A}`,q).next().done===!0?J+1:J,0);if(W===0)yield L(H.ArrayContains,Q,X,Z);if(N(Q.minContains)&&W<Q.minContains)yield L(H.ArrayMinContains,Q,X,Z);if(N(Q.maxContains)&&W>Q.maxContains)yield L(H.ArrayMaxContains,Q,X,Z)}function*z4(Q,Y,X,Z){if(!u1(Z))yield L(H.AsyncIterator,Q,X,Z)}function*$4(Q,Y,X,Z){if(!a(Z))return yield L(H.BigInt,Q,X,Z);if(b(Q.exclusiveMaximum)&&!(Z<Q.exclusiveMaximum))yield L(H.BigIntExclusiveMaximum,Q,X,Z);if(b(Q.exclusiveMinimum)&&!(Z>Q.exclusiveMinimum))yield L(H.BigIntExclusiveMinimum,Q,X,Z);if(b(Q.maximum)&&!(Z<=Q.maximum))yield L(H.BigIntMaximum,Q,X,Z);if(b(Q.minimum)&&!(Z>=Q.minimum))yield L(H.BigIntMinimum,Q,X,Z);if(b(Q.multipleOf)&&Z%Q.multipleOf!==BigInt(0))yield L(H.BigIntMultipleOf,Q,X,Z)}function*J4(Q,Y,X,Z){if(!N1(Z))yield L(H.Boolean,Q,X,Z)}function*H4(Q,Y,X,Z){yield*p(Q.returns,Y,X,Z.prototype)}function*q4(Q,Y,X,Z){if(!F1(Z))return yield L(H.Date,Q,X,Z);if(b(Q.exclusiveMaximumTimestamp)&&!(Z.getTime()<Q.exclusiveMaximumTimestamp))yield L(H.DateExclusiveMaximumTimestamp,Q,X,Z);if(b(Q.exclusiveMinimumTimestamp)&&!(Z.getTime()>Q.exclusiveMinimumTimestamp))yield L(H.DateExclusiveMinimumTimestamp,Q,X,Z);if(b(Q.maximumTimestamp)&&!(Z.getTime()<=Q.maximumTimestamp))yield L(H.DateMaximumTimestamp,Q,X,Z);if(b(Q.minimumTimestamp)&&!(Z.getTime()>=Q.minimumTimestamp))yield L(H.DateMinimumTimestamp,Q,X,Z);if(b(Q.multipleOfTimestamp)&&Z.getTime()%Q.multipleOfTimestamp!==0)yield L(H.DateMultipleOfTimestamp,Q,X,Z)}function*L4(Q,Y,X,Z){if(!e1(Z))yield L(H.Function,Q,X,Z)}function*M4(Q,Y,X,Z){let G=globalThis.Object.values(Q.$defs),W=Q.$defs[Q.$ref];yield*p(W,[...Y,...G],X,Z)}function*U4(Q,Y,X,Z){if(!a1(Z))return yield L(H.Integer,Q,X,Z);if(b(Q.exclusiveMaximum)&&!(Z<Q.exclusiveMaximum))yield L(H.IntegerExclusiveMaximum,Q,X,Z);if(b(Q.exclusiveMinimum)&&!(Z>Q.exclusiveMinimum))yield L(H.IntegerExclusiveMinimum,Q,X,Z);if(b(Q.maximum)&&!(Z<=Q.maximum))yield L(H.IntegerMaximum,Q,X,Z);if(b(Q.minimum)&&!(Z>=Q.minimum))yield L(H.IntegerMinimum,Q,X,Z);if(b(Q.multipleOf)&&Z%Q.multipleOf!==0)yield L(H.IntegerMultipleOf,Q,X,Z)}function*R4(Q,Y,X,Z){let G=!1;for(let W of Q.allOf)for(let J of p(W,Y,X,Z))G=!0,yield J;if(G)return yield L(H.Intersect,Q,X,Z);if(Q.unevaluatedProperties===!1){let W=new RegExp(q1(Q));for(let J of Object.getOwnPropertyNames(Z))if(!W.test(J))yield L(H.IntersectUnevaluatedProperties,Q,`${X}/${J}`,Z)}if(typeof Q.unevaluatedProperties==="object"){let W=new RegExp(q1(Q));for(let J of Object.getOwnPropertyNames(Z))if(!W.test(J)){let q=p(Q.unevaluatedProperties,Y,`${X}/${J}`,Z[J]).next();if(!q.done)yield q.value}}}function*A4(Q,Y,X,Z){if(!l1(Z))yield L(H.Iterator,Q,X,Z)}function*B4(Q,Y,X,Z){if(Z!==Q.const)yield L(H.Literal,Q,X,Z)}function*w4(Q,Y,X,Z){yield L(H.Never,Q,X,Z)}function*j4(Q,Y,X,Z){if(p(Q.not,Y,X,Z).next().done===!0)yield L(H.Not,Q,X,Z)}function*D4(Q,Y,X,Z){if(!D1(Z))yield L(H.Null,Q,X,Z)}function*N4(Q,Y,X,Z){if(!_.IsNumberLike(Z))return yield L(H.Number,Q,X,Z);if(b(Q.exclusiveMaximum)&&!(Z<Q.exclusiveMaximum))yield L(H.NumberExclusiveMaximum,Q,X,Z);if(b(Q.exclusiveMinimum)&&!(Z>Q.exclusiveMinimum))yield L(H.NumberExclusiveMinimum,Q,X,Z);if(b(Q.maximum)&&!(Z<=Q.maximum))yield L(H.NumberMaximum,Q,X,Z);if(b(Q.minimum)&&!(Z>=Q.minimum))yield L(H.NumberMinimum,Q,X,Z);if(b(Q.multipleOf)&&Z%Q.multipleOf!==0)yield L(H.NumberMultipleOf,Q,X,Z)}function*P4(Q,Y,X,Z){if(!_.IsObjectLike(Z))return yield L(H.Object,Q,X,Z);if(b(Q.minProperties)&&!(Object.getOwnPropertyNames(Z).length>=Q.minProperties))yield L(H.ObjectMinProperties,Q,X,Z);if(b(Q.maxProperties)&&!(Object.getOwnPropertyNames(Z).length<=Q.maxProperties))yield L(H.ObjectMaxProperties,Q,X,Z);let G=Array.isArray(Q.required)?Q.required:[],W=Object.getOwnPropertyNames(Q.properties),J=Object.getOwnPropertyNames(Z);for(let q of G){if(J.includes(q))continue;yield L(H.ObjectRequiredProperty,Q.properties[q],`${X}/${M1(q)}`,void 0)}if(Q.additionalProperties===!1){for(let q of J)if(!W.includes(q))yield L(H.ObjectAdditionalProperties,Q,`${X}/${M1(q)}`,Z[q])}if(typeof Q.additionalProperties==="object")for(let q of J){if(W.includes(q))continue;yield*p(Q.additionalProperties,Y,`${X}/${M1(q)}`,Z[q])}for(let q of W){let A=Q.properties[q];if(Q.required&&Q.required.includes(q)){if(yield*p(A,Y,`${X}/${M1(q)}`,Z[q]),L1(Q)&&!(q in Z))yield L(H.ObjectRequiredProperty,A,`${X}/${M1(q)}`,void 0)}else if(_.IsExactOptionalProperty(Z,q))yield*p(A,Y,`${X}/${M1(q)}`,Z[q])}}function*b4(Q,Y,X,Z){if(!s1(Z))yield L(H.Promise,Q,X,Z)}function*S4(Q,Y,X,Z){if(!_.IsRecordLike(Z))return yield L(H.Object,Q,X,Z);if(b(Q.minProperties)&&!(Object.getOwnPropertyNames(Z).length>=Q.minProperties))yield L(H.ObjectMinProperties,Q,X,Z);if(b(Q.maxProperties)&&!(Object.getOwnPropertyNames(Z).length<=Q.maxProperties))yield L(H.ObjectMaxProperties,Q,X,Z);let[G,W]=Object.entries(Q.patternProperties)[0],J=new RegExp(G);for(let[q,A]of Object.entries(Z))if(J.test(q))yield*p(W,Y,`${X}/${M1(q)}`,A);if(typeof Q.additionalProperties==="object"){for(let[q,A]of Object.entries(Z))if(!J.test(q))yield*p(Q.additionalProperties,Y,`${X}/${M1(q)}`,A)}if(Q.additionalProperties===!1)for(let[q,A]of Object.entries(Z)){if(J.test(q))continue;return yield L(H.ObjectAdditionalProperties,Q,`${X}/${M1(q)}`,A)}}function*x4(Q,Y,X,Z){yield*p(i(Q,Y),Y,X,Z)}function*C4(Q,Y,X,Z){if(!f(Z))return yield L(H.String,Q,X,Z);if(b(Q.minLength)&&!(Z.length>=Q.minLength))yield L(H.StringMinLength,Q,X,Z);if(b(Q.maxLength)&&!(Z.length<=Q.maxLength))yield L(H.StringMaxLength,Q,X,Z);if(!new RegExp(Q.source,Q.flags).test(Z))return yield L(H.RegExp,Q,X,Z)}function*O4(Q,Y,X,Z){if(!f(Z))return yield L(H.String,Q,X,Z);if(b(Q.minLength)&&!(Z.length>=Q.minLength))yield L(H.StringMinLength,Q,X,Z);if(b(Q.maxLength)&&!(Z.length<=Q.maxLength))yield L(H.StringMaxLength,Q,X,Z);if(f(Q.pattern)){if(!new RegExp(Q.pattern).test(Z))yield L(H.StringPattern,Q,X,Z)}if(f(Q.format)){if(!Q1.Has(Q.format))yield L(H.StringFormatUnknown,Q,X,Z);else if(!Q1.Get(Q.format)(Z))yield L(H.StringFormat,Q,X,Z)}}function*F4(Q,Y,X,Z){if(!P1(Z))yield L(H.Symbol,Q,X,Z)}function*K4(Q,Y,X,Z){if(!f(Z))return yield L(H.String,Q,X,Z);if(!new RegExp(Q.pattern).test(Z))yield L(H.StringPattern,Q,X,Z)}function*g4(Q,Y,X,Z){yield*p(i(Q,Y),Y,X,Z)}function*_4(Q,Y,X,Z){if(!V(Z))return yield L(H.Tuple,Q,X,Z);if(Q.items===void 0&&Z.length!==0)return yield L(H.TupleLength,Q,X,Z);if(Z.length!==Q.maxItems)return yield L(H.TupleLength,Q,X,Z);if(!Q.items)return;for(let G=0;G<Q.items.length;G++)yield*p(Q.items[G],Y,`${X}/${G}`,Z[G])}function*k4(Q,Y,X,Z){if(!v(Z))yield L(H.Undefined,Q,X,Z)}function*E4(Q,Y,X,Z){if(S1(Q,Y,Z))return;let G=Q.anyOf.map((W)=>new D0(p(W,Y,X,Z)));yield L(H.Union,Q,X,Z,G)}function*V4(Q,Y,X,Z){if(!K1(Z))return yield L(H.Uint8Array,Q,X,Z);if(b(Q.maxByteLength)&&!(Z.length<=Q.maxByteLength))yield L(H.Uint8ArrayMaxByteLength,Q,X,Z);if(b(Q.minByteLength)&&!(Z.length>=Q.minByteLength))yield L(H.Uint8ArrayMinByteLength,Q,X,Z)}function*T4(Q,Y,X,Z){}function*I4(Q,Y,X,Z){if(!_.IsVoidLike(Z))yield L(H.Void,Q,X,Z)}function*d4(Q,Y,X,Z){if(!r.Get(Q[j])(Q,Z))yield L(H.Kind,Q,X,Z)}function*p(Q,Y,X,Z){let G=b(Q.$id)?[...Y,Q]:Y,W=Q;switch(W[j]){case"Any":return yield*Z4(W,G,X,Z);case"Argument":return yield*G4(W,G,X,Z);case"Array":return yield*W4(W,G,X,Z);case"AsyncIterator":return yield*z4(W,G,X,Z);case"BigInt":return yield*$4(W,G,X,Z);case"Boolean":return yield*J4(W,G,X,Z);case"Constructor":return yield*H4(W,G,X,Z);case"Date":return yield*q4(W,G,X,Z);case"Function":return yield*L4(W,G,X,Z);case"Import":return yield*M4(W,G,X,Z);case"Integer":return yield*U4(W,G,X,Z);case"Intersect":return yield*R4(W,G,X,Z);case"Iterator":return yield*A4(W,G,X,Z);case"Literal":return yield*B4(W,G,X,Z);case"Never":return yield*w4(W,G,X,Z);case"Not":return yield*j4(W,G,X,Z);case"Null":return yield*D4(W,G,X,Z);case"Number":return yield*N4(W,G,X,Z);case"Object":return yield*P4(W,G,X,Z);case"Promise":return yield*b4(W,G,X,Z);case"Record":return yield*S4(W,G,X,Z);case"Ref":return yield*x4(W,G,X,Z);case"RegExp":return yield*C4(W,G,X,Z);case"String":return yield*O4(W,G,X,Z);case"Symbol":return yield*F4(W,G,X,Z);case"TemplateLiteral":return yield*K4(W,G,X,Z);case"This":return yield*g4(W,G,X,Z);case"Tuple":return yield*_4(W,G,X,Z);case"Undefined":return yield*k4(W,G,X,Z);case"Union":return yield*E4(W,G,X,Z);case"Uint8Array":return yield*V4(W,G,X,Z);case"Unknown":return yield*T4(W,G,X,Z);case"Void":return yield*I4(W,G,X,Z);default:if(!r.Has(W[j]))throw new Z8(Q);return yield*d4(W,G,X,Z)}}function G8(...Q){let Y=Q.length===3?p(Q[0],Q[1],"",Q[2]):p(Q[0],[],"",Q[1]);return new D0(Y)}class N0 extends T{constructor(Q,Y,X){super("Unable to decode value as it does not match the expected schema");this.schema=Q,this.value=Y,this.error=X}}class W8 extends T{constructor(Q,Y,X,Z){super(Z instanceof Error?Z.message:"Unknown error");this.schema=Q,this.path=Y,this.value=X,this.error=Z}}function E(Q,Y,X){try{return F(Q)?Q[B1].Decode(X):X}catch(Z){throw new W8(Q,Y,X,Z)}}function f4(Q,Y,X,Z){return V(Z)?E(Q,X,Z.map((G,W)=>G1(Q.items,Y,`${X}/${W}`,G))):E(Q,X,Z)}function i4(Q,Y,X,Z){if(!s(Z)||Q0(Z))return E(Q,X,Z);let G=H0(Q),W=G.map((B)=>B[0]),J={...Z};for(let[B,O]of G)if(B in J)J[B]=G1(O,Y,`${X}/${B}`,J[B]);if(!F(Q.unevaluatedProperties))return E(Q,X,J);let q=Object.getOwnPropertyNames(J),A=Q.unevaluatedProperties,w={...J};for(let B of q)if(!W.includes(B))w[B]=E(A,`${X}/${B}`,w[B]);return E(Q,X,w)}function y4(Q,Y,X,Z){let G=globalThis.Object.values(Q.$defs),W=Q.$defs[Q.$ref],J=G1(W,[...Y,...G],X,Z);return E(Q,X,J)}function p4(Q,Y,X,Z){return E(Q,X,G1(Q.not,Y,X,Z))}function o4(Q,Y,X,Z){if(!s(Z))return E(Q,X,Z);let G=w1(Q),W={...Z};for(let w of G){if(!r1(W,w))continue;if(v(W[w])&&(!n1(Q.properties[w])||_.IsExactOptionalProperty(W,w)))continue;W[w]=G1(Q.properties[w],Y,`${X}/${w}`,W[w])}if(!u(Q.additionalProperties))return E(Q,X,W);let J=Object.getOwnPropertyNames(W),q=Q.additionalProperties,A={...W};for(let w of J)if(!G.includes(w))A[w]=E(q,`${X}/${w}`,A[w]);return E(Q,X,A)}function n4(Q,Y,X,Z){if(!s(Z))return E(Q,X,Z);let G=Object.getOwnPropertyNames(Q.patternProperties)[0],W=new RegExp(G),J={...Z};for(let B of Object.getOwnPropertyNames(Z))if(W.test(B))J[B]=G1(Q.patternProperties[G],Y,`${X}/${B}`,J[B]);if(!u(Q.additionalProperties))return E(Q,X,J);let q=Object.getOwnPropertyNames(J),A=Q.additionalProperties,w={...J};for(let B of q)if(!W.test(B))w[B]=E(A,`${X}/${B}`,w[B]);return E(Q,X,w)}function t4(Q,Y,X,Z){let G=i(Q,Y);return E(Q,X,G1(G,Y,X,Z))}function m4(Q,Y,X,Z){let G=i(Q,Y);return E(Q,X,G1(G,Y,X,Z))}function h4(Q,Y,X,Z){return V(Z)&&V(Q.items)?E(Q,X,Q.items.map((G,W)=>G1(G,Y,`${X}/${W}`,Z[W]))):E(Q,X,Z)}function v4(Q,Y,X,Z){for(let G of Q.anyOf){if(!S1(G,Y,Z))continue;let W=G1(G,Y,X,Z);return E(Q,X,W)}return E(Q,X,Z)}function G1(Q,Y,X,Z){let G=j1(Q,Y),W=Q;switch(Q[j]){case"Array":return f4(W,G,X,Z);case"Import":return y4(W,G,X,Z);case"Intersect":return i4(W,G,X,Z);case"Not":return p4(W,G,X,Z);case"Object":return o4(W,G,X,Z);case"Record":return n4(W,G,X,Z);case"Ref":return t4(W,G,X,Z);case"Symbol":return E(W,X,Z);case"This":return m4(W,G,X,Z);case"Tuple":return h4(W,G,X,Z);case"Union":return v4(W,G,X,Z);default:return E(W,X,Z)}}function z8(Q,Y,X){return G1(Q,Y,"",X)}class P0 extends T{constructor(Q,Y,X){super("The encoded value does not match the expected schema");this.schema=Q,this.value=Y,this.error=X}}class $8 extends T{constructor(Q,Y,X,Z){super(`${Z instanceof Error?Z.message:"Unknown error"}`);this.schema=Q,this.path=Y,this.value=X,this.error=Z}}function m(Q,Y,X){try{return F(Q)?Q[B1].Encode(X):X}catch(Z){throw new $8(Q,Y,X,Z)}}function c4(Q,Y,X,Z){let G=m(Q,X,Z);return V(G)?G.map((W,J)=>W1(Q.items,Y,`${X}/${J}`,W)):G}function u4(Q,Y,X,Z){let G=globalThis.Object.values(Q.$defs),W=Q.$defs[Q.$ref],J=m(Q,X,Z);return W1(W,[...Y,...G],X,J)}function l4(Q,Y,X,Z){let G=m(Q,X,Z);if(!s(Z)||Q0(Z))return G;let W=H0(Q),J=W.map((O)=>O[0]),q={...G};for(let[O,R1]of W)if(O in q)q[O]=W1(R1,Y,`${X}/${O}`,q[O]);if(!F(Q.unevaluatedProperties))return q;let A=Object.getOwnPropertyNames(q),w=Q.unevaluatedProperties,B={...q};for(let O of A)if(!J.includes(O))B[O]=m(w,`${X}/${O}`,B[O]);return B}function s4(Q,Y,X,Z){return m(Q.not,X,m(Q,X,Z))}function r4(Q,Y,X,Z){let G=m(Q,X,Z);if(!s(G))return G;let W=w1(Q),J={...G};for(let B of W){if(!r1(J,B))continue;if(v(J[B])&&(!n1(Q.properties[B])||_.IsExactOptionalProperty(J,B)))continue;J[B]=W1(Q.properties[B],Y,`${X}/${B}`,J[B])}if(!u(Q.additionalProperties))return J;let q=Object.getOwnPropertyNames(J),A=Q.additionalProperties,w={...J};for(let B of q)if(!W.includes(B))w[B]=m(A,`${X}/${B}`,w[B]);return w}function a4(Q,Y,X,Z){let G=m(Q,X,Z);if(!s(Z))return G;let W=Object.getOwnPropertyNames(Q.patternProperties)[0],J=new RegExp(W),q={...G};for(let O of Object.getOwnPropertyNames(Z))if(J.test(O))q[O]=W1(Q.patternProperties[W],Y,`${X}/${O}`,q[O]);if(!u(Q.additionalProperties))return q;let A=Object.getOwnPropertyNames(q),w=Q.additionalProperties,B={...q};for(let O of A)if(!J.test(O))B[O]=m(w,`${X}/${O}`,B[O]);return B}function e4(Q,Y,X,Z){let G=i(Q,Y),W=W1(G,Y,X,Z);return m(Q,X,W)}function QZ(Q,Y,X,Z){let G=i(Q,Y),W=W1(G,Y,X,Z);return m(Q,X,W)}function XZ(Q,Y,X,Z){let G=m(Q,X,Z);return V(Q.items)?Q.items.map((W,J)=>W1(W,Y,`${X}/${J}`,G[J])):[]}function YZ(Q,Y,X,Z){for(let G of Q.anyOf){if(!S1(G,Y,Z))continue;let W=W1(G,Y,X,Z);return m(Q,X,W)}for(let G of Q.anyOf){let W=W1(G,Y,X,Z);if(!S1(Q,Y,W))continue;return m(Q,X,W)}return m(Q,X,Z)}function W1(Q,Y,X,Z){let G=j1(Q,Y),W=Q;switch(Q[j]){case"Array":return c4(W,G,X,Z);case"Import":return u4(W,G,X,Z);case"Intersect":return l4(W,G,X,Z);case"Not":return s4(W,G,X,Z);case"Object":return r4(W,G,X,Z);case"Record":return a4(W,G,X,Z);case"Ref":return e4(W,G,X,Z);case"This":return QZ(W,G,X,Z);case"Tuple":return XZ(W,G,X,Z);case"Union":return YZ(W,G,X,Z);default:return m(W,X,Z)}}function J8(Q,Y,X){return W1(Q,Y,"",X)}function ZZ(Q,Y){return F(Q)||d(Q.items,Y)}function GZ(Q,Y){return F(Q)||d(Q.items,Y)}function WZ(Q,Y){return F(Q)||d(Q.returns,Y)||Q.parameters.some((X)=>d(X,Y))}function zZ(Q,Y){return F(Q)||d(Q.returns,Y)||Q.parameters.some((X)=>d(X,Y))}function $Z(Q,Y){return F(Q)||F(Q.unevaluatedProperties)||Q.allOf.some((X)=>d(X,Y))}function JZ(Q,Y){let X=globalThis.Object.getOwnPropertyNames(Q.$defs).reduce((G,W)=>[...G,Q.$defs[W]],[]),Z=Q.$defs[Q.$ref];return F(Q)||d(Z,[...X,...Y])}function HZ(Q,Y){return F(Q)||d(Q.items,Y)}function qZ(Q,Y){return F(Q)||d(Q.not,Y)}function LZ(Q,Y){return F(Q)||Object.values(Q.properties).some((X)=>d(X,Y))||u(Q.additionalProperties)&&d(Q.additionalProperties,Y)}function MZ(Q,Y){return F(Q)||d(Q.item,Y)}function UZ(Q,Y){let X=Object.getOwnPropertyNames(Q.patternProperties)[0],Z=Q.patternProperties[X];return F(Q)||d(Z,Y)||u(Q.additionalProperties)&&F(Q.additionalProperties)}function RZ(Q,Y){if(F(Q))return!0;return d(i(Q,Y),Y)}function AZ(Q,Y){if(F(Q))return!0;return d(i(Q,Y),Y)}function BZ(Q,Y){return F(Q)||!v(Q.items)&&Q.items.some((X)=>d(X,Y))}function wZ(Q,Y){return F(Q)||Q.anyOf.some((X)=>d(X,Y))}function d(Q,Y){let X=j1(Q,Y),Z=Q;if(Q.$id&&b0.has(Q.$id))return!1;if(Q.$id)b0.add(Q.$id);switch(Q[j]){case"Array":return ZZ(Z,X);case"AsyncIterator":return GZ(Z,X);case"Constructor":return WZ(Z,X);case"Function":return zZ(Z,X);case"Import":return JZ(Z,X);case"Intersect":return $Z(Z,X);case"Iterator":return HZ(Z,X);case"Not":return qZ(Z,X);case"Object":return LZ(Z,X);case"Promise":return MZ(Z,X);case"Record":return UZ(Z,X);case"Ref":return RZ(Z,X);case"This":return AZ(Z,X);case"Tuple":return BZ(Z,X);case"Union":return wZ(Z,X);default:return F(Q)}}var b0=new Set;function H8(Q,Y){return b0.clear(),d(Q,Y)}class q8{constructor(Q,Y,X,Z){this.schema=Q,this.references=Y,this.checkFunc=X,this.code=Z,this.hasTransform=H8(Q,Y)}Code(){return this.code}Schema(){return this.schema}References(){return this.references}Errors(Q){return G8(this.schema,this.references,Q)}Check(Q){return this.checkFunc(Q)}Decode(Q){if(!this.checkFunc(Q))throw new N0(this.schema,Q,this.Errors(Q).First());return this.hasTransform?z8(this.schema,this.references,Q):Q}Encode(Q){let Y=this.hasTransform?J8(this.schema,this.references,Q):Q;if(!this.checkFunc(Y))throw new P0(this.schema,Q,this.Errors(Q).First());return Y}}var U1;(function(Q){function Y(W){return W===36}Q.DollarSign=Y;function X(W){return W===95}Q.IsUnderscore=X;function Z(W){return W>=65&&W<=90||W>=97&&W<=122}Q.IsAlpha=Z;function G(W){return W>=48&&W<=57}Q.IsNumeric=G})(U1||(U1={}));var q0;(function(Q){function Y(W){if(W.length===0)return!1;return U1.IsNumeric(W.charCodeAt(0))}function X(W){if(Y(W))return!1;for(let J=0;J<W.length;J++){let q=W.charCodeAt(J);if(!(U1.IsAlpha(q)||U1.IsNumeric(q)||U1.DollarSign(q)||U1.IsUnderscore(q)))return!1}return!0}function Z(W){return W.replace(/'/g,"\\'")}function G(W,J){return X(J)?`${W}.${J}`:`${W}['${Z(J)}']`}Q.Encode=G})(q0||(q0={}));var S0;(function(Q){function Y(X){let Z=[];for(let G=0;G<X.length;G++){let W=X.charCodeAt(G);if(U1.IsNumeric(W)||U1.IsAlpha(W))Z.push(X.charAt(G));else Z.push(`_${W}_`)}return Z.join("").replace(/__/g,"_")}Q.Encode=Y})(S0||(S0={}));var x0;(function(Q){function Y(X){return X.replace(/'/g,"\\'")}Q.Escape=Y})(x0||(x0={}));class L8 extends T{constructor(Q){super("Unknown type");this.schema=Q}}class C0 extends T{constructor(Q){super("Preflight validation check failed to guard for the given schema");this.schema=Q}}var x1;(function(Q){function Y(J,q,A){return _.ExactOptionalPropertyTypes?`('${q}' in ${J} ? ${A} : true)`:`(${q0.Encode(J,q)} !== undefined ? ${A} : true)`}Q.IsExactOptionalProperty=Y;function X(J){return!_.AllowArrayObject?`(typeof ${J} === 'object' && ${J} !== null && !Array.isArray(${J}))`:`(typeof ${J} === 'object' && ${J} !== null)`}Q.IsObjectLike=X;function Z(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=Z;function G(J){return _.AllowNaN?`typeof ${J} === 'number'`:`Number.isFinite(${J})`}Q.IsNumberLike=G;function W(J){return _.AllowNullVoid?`(${J} === undefined || ${J} === null)`:`${J} === undefined`}Q.IsVoidLike=W})(x1||(x1={}));var L0;(function(Q){function Y(z){return z[j]==="Any"||z[j]==="Unknown"}function*X(z,M,$){yield"true"}function*Z(z,M,$){yield"true"}function*G(z,M,$){yield`Array.isArray(${$})`;let[D,U]=[v1("value","any"),v1("acc","number")];if(N(z.maxItems))yield`${$}.length <= ${z.maxItems}`;if(N(z.minItems))yield`${$}.length >= ${z.minItems}`;let R=Y1(z.items,M,"value");if(yield`${$}.every((${D}) => ${R})`,k(z.contains)||N(z.minContains)||N(z.maxContains)){let g=k(z.contains)?z.contains:c(),l=Y1(g,M,"value"),H1=N(z.minContains)?[`(count >= ${z.minContains})`]:[],Z1=N(z.maxContains)?[`(count <= ${z.maxContains})`]:[],z1=`const count = value.reduce((${U}, ${D}) => ${l} ? acc + 1 : acc, 0)`,c1=["(count > 0)",...H1,...Z1].join(" && ");yield`((${D}) => { ${z1}; return ${c1}})(${$})`}if(z.uniqueItems===!0)yield`((${D}) => { const set = new Set(); for(const element of value) { const hashed = hash(element); if(set.has(hashed)) { return false } else { set.add(hashed) } } return true } )(${$})`}function*W(z,M,$){yield`(typeof value === 'object' && Symbol.asyncIterator in ${$})`}function*J(z,M,$){if(yield`(typeof ${$} === 'bigint')`,a(z.exclusiveMaximum))yield`${$} < BigInt(${z.exclusiveMaximum})`;if(a(z.exclusiveMinimum))yield`${$} > BigInt(${z.exclusiveMinimum})`;if(a(z.maximum))yield`${$} <= BigInt(${z.maximum})`;if(a(z.minimum))yield`${$} >= BigInt(${z.minimum})`;if(a(z.multipleOf))yield`(${$} % BigInt(${z.multipleOf})) === 0`}function*q(z,M,$){yield`(typeof ${$} === 'boolean')`}function*A(z,M,$){yield*C1(z.returns,M,`${$}.prototype`)}function*w(z,M,$){if(yield`(${$} instanceof Date) && Number.isFinite(${$}.getTime())`,N(z.exclusiveMaximumTimestamp))yield`${$}.getTime() < ${z.exclusiveMaximumTimestamp}`;if(N(z.exclusiveMinimumTimestamp))yield`${$}.getTime() > ${z.exclusiveMinimumTimestamp}`;if(N(z.maximumTimestamp))yield`${$}.getTime() <= ${z.maximumTimestamp}`;if(N(z.minimumTimestamp))yield`${$}.getTime() >= ${z.minimumTimestamp}`;if(N(z.multipleOfTimestamp))yield`(${$}.getTime() % ${z.multipleOfTimestamp}) === 0`}function*B(z,M,$){yield`(typeof ${$} === 'function')`}function*O(z,M,$){let D=globalThis.Object.getOwnPropertyNames(z.$defs).reduce((U,R)=>{return[...U,z.$defs[R]]},[]);yield*C1(m0(z.$ref),[...M,...D],$)}function*R1(z,M,$){if(yield`Number.isInteger(${$})`,N(z.exclusiveMaximum))yield`${$} < ${z.exclusiveMaximum}`;if(N(z.exclusiveMinimum))yield`${$} > ${z.exclusiveMinimum}`;if(N(z.maximum))yield`${$} <= ${z.maximum}`;if(N(z.minimum))yield`${$} >= ${z.minimum}`;if(N(z.multipleOf))yield`(${$} % ${z.multipleOf}) === 0`}function*B8(z,M,$){let D=z.allOf.map((U)=>Y1(U,M,$)).join(" && ");if(z.unevaluatedProperties===!1){let U=O1(`${new RegExp(q1(z))};`),R=`Object.getOwnPropertyNames(${$}).every(key => ${U}.test(key))`;yield`(${D} && ${R})`}else if(k(z.unevaluatedProperties)){let U=O1(`${new RegExp(q1(z))};`),R=`Object.getOwnPropertyNames(${$}).every(key => ${U}.test(key) || ${Y1(z.unevaluatedProperties,M,`${$}[key]`)})`;yield`(${D} && ${R})`}else yield`(${D})`}function*w8(z,M,$){yield`(typeof value === 'object' && Symbol.iterator in ${$})`}function*j8(z,M,$){if(typeof z.const==="number"||typeof z.const==="boolean")yield`(${$} === ${z.const})`;else yield`(${$} === '${x0.Escape(z.const)}')`}function*D8(z,M,$){yield"false"}function*N8(z,M,$){yield`(!${Y1(z.not,M,$)})`}function*P8(z,M,$){yield`(${$} === null)`}function*b8(z,M,$){if(yield x1.IsNumberLike($),N(z.exclusiveMaximum))yield`${$} < ${z.exclusiveMaximum}`;if(N(z.exclusiveMinimum))yield`${$} > ${z.exclusiveMinimum}`;if(N(z.maximum))yield`${$} <= ${z.maximum}`;if(N(z.minimum))yield`${$} >= ${z.minimum}`;if(N(z.multipleOf))yield`(${$} % ${z.multipleOf}) === 0`}function*S8(z,M,$){if(yield x1.IsObjectLike($),N(z.minProperties))yield`Object.getOwnPropertyNames(${$}).length >= ${z.minProperties}`;if(N(z.maxProperties))yield`Object.getOwnPropertyNames(${$}).length <= ${z.maxProperties}`;let D=Object.getOwnPropertyNames(z.properties);for(let U of D){let R=q0.Encode($,U),g=z.properties[U];if(z.required&&z.required.includes(U)){if(yield*C1(g,M,R),L1(g)||Y(g))yield`('${U}' in ${$})`}else{let l=Y1(g,M,R);yield x1.IsExactOptionalProperty($,U,l)}}if(z.additionalProperties===!1)if(z.required&&z.required.length===D.length)yield`Object.getOwnPropertyNames(${$}).length === ${D.length}`;else{let U=`[${D.map((R)=>`'${R}'`).join(", ")}]`;yield`Object.getOwnPropertyNames(${$}).every(key => ${U}.includes(key))`}if(typeof z.additionalProperties==="object"){let U=Y1(z.additionalProperties,M,`${$}[key]`),R=`[${D.map((g)=>`'${g}'`).join(", ")}]`;yield`(Object.getOwnPropertyNames(${$}).every(key => ${R}.includes(key) || ${U}))`}}function*x8(z,M,$){yield`${$} instanceof Promise`}function*C8(z,M,$){if(yield x1.IsRecordLike($),N(z.minProperties))yield`Object.getOwnPropertyNames(${$}).length >= ${z.minProperties}`;if(N(z.maxProperties))yield`Object.getOwnPropertyNames(${$}).length <= ${z.maxProperties}`;let[D,U]=Object.entries(z.patternProperties)[0],R=O1(`${new RegExp(D)}`),g=Y1(U,M,"value"),l=k(z.additionalProperties)?Y1(z.additionalProperties,M,$):z.additionalProperties===!1?"false":"true",H1=`(${R}.test(key) ? ${g} : ${l})`;yield`(Object.entries(${$}).every(([key, value]) => ${H1}))`}function*O8(z,M,$){let D=i(z,M);if(o.functions.has(z.$ref))return yield`${h1(z.$ref)}(${$})`;yield*C1(D,M,$)}function*F8(z,M,$){let D=O1(`${new RegExp(z.source,z.flags)};`);if(yield`(typeof ${$} === 'string')`,N(z.maxLength))yield`${$}.length <= ${z.maxLength}`;if(N(z.minLength))yield`${$}.length >= ${z.minLength}`;yield`${D}.test(${$})`}function*K8(z,M,$){if(yield`(typeof ${$} === 'string')`,N(z.maxLength))yield`${$}.length <= ${z.maxLength}`;if(N(z.minLength))yield`${$}.length >= ${z.minLength}`;if(z.pattern!==void 0)yield`${O1(`${new RegExp(z.pattern)};`)}.test(${$})`;if(z.format!==void 0)yield`format('${z.format}', ${$})`}function*g8(z,M,$){yield`(typeof ${$} === 'symbol')`}function*_8(z,M,$){yield`(typeof ${$} === 'string')`,yield`${O1(`${new RegExp(z.pattern)};`)}.test(${$})`}function*k8(z,M,$){yield`${h1(z.$ref)}(${$})`}function*E8(z,M,$){if(yield`Array.isArray(${$})`,z.items===void 0)return yield`${$}.length === 0`;yield`(${$}.length === ${z.maxItems})`;for(let D=0;D<z.items.length;D++)yield`${Y1(z.items[D],M,`${$}[${D}]`)}`}function*V8(z,M,$){yield`${$} === undefined`}function*T8(z,M,$){yield`(${z.anyOf.map((U)=>Y1(U,M,$)).join(" || ")})`}function*I8(z,M,$){if(yield`${$} instanceof Uint8Array`,N(z.maxByteLength))yield`(${$}.length <= ${z.maxByteLength})`;if(N(z.minByteLength))yield`(${$}.length >= ${z.minByteLength})`}function*d8(z,M,$){yield"true"}function*f8(z,M,$){yield x1.IsVoidLike($)}function*i8(z,M,$){let D=o.instances.size;o.instances.set(D,z),yield`kind('${z[j]}', ${D}, ${$})`}function*C1(z,M,$,D=!0){let U=f(z.$id)?[...M,z]:M,R=z;if(D&&f(z.$id)){let g=h1(z.$id);if(o.functions.has(g))return yield`${g}(${$})`;else{o.functions.set(g,"<deferred>");let l=O0(g,z,M,"value",!1);return o.functions.set(g,l),yield`${g}(${$})`}}switch(R[j]){case"Any":return yield*X(R,U,$);case"Argument":return yield*Z(R,U,$);case"Array":return yield*G(R,U,$);case"AsyncIterator":return yield*W(R,U,$);case"BigInt":return yield*J(R,U,$);case"Boolean":return yield*q(R,U,$);case"Constructor":return yield*A(R,U,$);case"Date":return yield*w(R,U,$);case"Function":return yield*B(R,U,$);case"Import":return yield*O(R,U,$);case"Integer":return yield*R1(R,U,$);case"Intersect":return yield*B8(R,U,$);case"Iterator":return yield*w8(R,U,$);case"Literal":return yield*j8(R,U,$);case"Never":return yield*D8(R,U,$);case"Not":return yield*N8(R,U,$);case"Null":return yield*P8(R,U,$);case"Number":return yield*b8(R,U,$);case"Object":return yield*S8(R,U,$);case"Promise":return yield*x8(R,U,$);case"Record":return yield*C8(R,U,$);case"Ref":return yield*O8(R,U,$);case"RegExp":return yield*F8(R,U,$);case"String":return yield*K8(R,U,$);case"Symbol":return yield*g8(R,U,$);case"TemplateLiteral":return yield*_8(R,U,$);case"This":return yield*k8(R,U,$);case"Tuple":return yield*E8(R,U,$);case"Undefined":return yield*V8(R,U,$);case"Union":return yield*T8(R,U,$);case"Uint8Array":return yield*I8(R,U,$);case"Unknown":return yield*d8(R,U,$);case"Void":return yield*f8(R,U,$);default:if(!r.Has(R[j]))throw new L8(z);return yield*i8(R,U,$)}}let o={language:"javascript",functions:new Map,variables:new Map,instances:new Map};function Y1(z,M,$,D=!0){return`(${[...C1(z,M,$,D)].join(" && ")})`}function h1(z){return`check_${S0.Encode(z)}`}function O1(z){let M=`local_${o.variables.size}`;return o.variables.set(M,`const ${M} = ${z}`),M}function O0(z,M,$,D,U=!0){let[R,g]=[`
|
|
3
|
+
`,(z1)=>"".padStart(z1," ")],l=v1("value","any"),H1=F0("boolean"),Z1=[...C1(M,$,D,U)].map((z1)=>`${g(4)}${z1}`).join(` &&${R}`);return`function ${z}(${l})${H1} {${R}${g(2)}return (${R}${Z1}${R}${g(2)})
|
|
4
|
+
}`}function v1(z,M){let $=o.language==="typescript"?`: ${M}`:"";return`${z}${$}`}function F0(z){return o.language==="typescript"?`: ${z}`:""}function y8(z,M,$){let D=O0("check",z,M,"value"),U=v1("value","any"),R=F0("boolean"),g=[...o.functions.values()],l=[...o.variables.values()],H1=f(z.$id)?`return function check(${U})${R} {
|
|
5
|
+
return ${h1(z.$id)}(value)
|
|
6
|
+
}`:`return ${D}`;return[...l,...g,H1].join(`
|
|
7
|
+
`)}function K0(...z){let M={language:"javascript"},[$,D,U]=z.length===2&&V(z[1])?[z[0],z[1],M]:z.length===2&&!V(z[1])?[z[0],[],z[1]]:z.length===3?[z[0],z[1],z[2]]:z.length===1?[z[0],[],M]:[null,[],M];if(o.language=U.language,o.variables.clear(),o.functions.clear(),o.instances.clear(),!k($))throw new C0($);for(let R of D)if(!k(R))throw new C0(R);return y8($,D,U)}Q.Code=K0;function p8(z,M=[]){let $=K0(z,M,{language:"javascript"}),D=globalThis.Function("kind","format","hash",$),U=new Map(o.instances);function R(Z1,z1,c1){if(!r.Has(Z1)||!U.has(z1))return!1;let o8=r.Get(Z1),n8=U.get(z1);return o8(n8,c1)}function g(Z1,z1){if(!Q1.Has(Z1))return!1;return Q1.Get(Z1)(z1)}function l(Z1){return d1(Z1)}let H1=D(R,g,l);return new q8(z,M,H1,$)}Q.Compile=p8})(L0||(L0={}));var f1=(Q,Y=400)=>new Response(JSON.stringify(Q),{status:Y,headers:{"Content-Type":"application/json"}}),jZ=(Q)=>{let Y=L0.Compile(Q);return async(Z,G,W)=>{try{let J=await Z.json();if(!Y.Check(J)){let q=Y.Errors(J).First();return f1({status:"error",code:"VALIDATION_FAILED",message:q?.message||"Invalid input",path:q?.path||"body"})}return Z.parsedBody=J,W()}catch{return f1({status:"error",message:"Invalid JSON payload"})}}},DZ=(Q)=>{let Y=Q.properties||{},X=Object.keys(Y),Z=X.length;return async(W,J,q)=>{try{let A=await W.json();for(let w=0;w<Z;w++){let B=X[w];if(typeof A[B]!==Y[B]?.type)return f1({status:"error",code:"TYPE_MISMATCH",message:`Field '${B}' must be of type ${Y[B]?.type}`,field:B})}return W.parsedBody=A,q()}catch{return f1({status:"error",message:"Invalid JSON payload"})}}},NZ=(Q)=>{return async(X,Z,G)=>{try{let W=await X.json(),J=Q.safeParse(W);if(!J.success)return f1({status:"error",code:"ZOD_ERROR",errors:J.error.format()});return X.parsedBody=J.data,G()}catch{return f1({status:"error",message:"Invalid JSON payload"})}}};class M8{routes=[];globalMiddlewares=[];compiledFetch;_reusePort=!0;_server=null;staticMap=new Map;dynamicRoutes=[];wsHandler=null;get server(){return this._server}set server(Q){this._server=Q}get=(Q,...Y)=>{return this.routes.push({method:"GET",path:Q,handlers:Y}),this};post=(Q,...Y)=>{return this.routes.push({method:"POST",path:Q,handlers:Y}),this};put=(Q,...Y)=>{return this.routes.push({method:"PUT",path:Q,handlers:Y}),this};patch=(Q,...Y)=>{return this.routes.push({method:"PATCH",path:Q,handlers:Y}),this};delete=(Q,...Y)=>{return this.routes.push({method:"DELETE",path:Q,handlers:Y}),this};ws=(Q,Y)=>{return this.wsHandler={path:Q,handlers:Y},this};reusePort=(Q)=>{return this._reusePort=Q,this};use=(Q)=>{if(typeof Q==="object"&&"install"in Q)Q.install(this);else this.globalMiddlewares.push(Q);return this};compile(){this.staticMap.clear(),this.dynamicRoutes.length=0;for(let Q=0;Q<this.routes.length;Q++){let Y=this.routes[Q],X=[...this.globalMiddlewares,...Y.handlers],Z=X.length,G=(W,J)=>{let q=0,A=()=>{if(q<Z){let w=X[q++](W,J,A);if(w&&w.constructor===Object)return new Response(JSON.stringify(w),{headers:{"Content-Type":"application/json"}});return w}return new Response(null,{status:404})};return A()};if(Y.path.indexOf(":")!==-1){let W=[],J=Y.path.replace(/:([^/]+)/g,(q,A)=>{return W.push(A),"([^/]+)"});this.dynamicRoutes.push({m:Y.method,r:new RegExp(`^${J}$`),p:W,c:G})}else this.staticMap.set(Y.method+Y.path,G)}this.compiledFetch=(Q,Y)=>{if(this.wsHandler&&Q.headers.get("upgrade")==="websocket"){let A=Q.url.indexOf("/",8);if((A===-1?"/":Q.url.substring(A))===this.wsHandler.path){if(Y?.upgrade(Q))return}}let X=Q.url,Z=X.indexOf("/",8),G=Z===-1?"/":X.substring(Z),W=Q.method,J=this.staticMap.get(W+G);if(J)return J(Q,{});let q=this.dynamicRoutes;for(let A=0;A<q.length;A++){let w=q[A];if(w.m===W){let B=w.r.exec(G);if(B){let O={};for(let R1=0;R1<w.p.length;R1++)O[w.p[R1]]=B[R1+1];return w.c(Q,O)}}}return new Response("404 Not Found",{status:404})}}fetch=(Q,Y)=>{if(!this.compiledFetch)this.compile();return this.compiledFetch(Q,Y)};async listen(Q,Y){this.compile();let X=3000,Z="0.0.0.0";if(typeof Q==="number"){if(X=Q,typeof Y==="string")Z=Y}else if(typeof Q==="string"){if(!isNaN(Number(Q)))X=Number(Q);else Z=Q;if(typeof Y==="number")X=Y}let G={hostname:Z,port:X,reusePort:this._reusePort,fetch:(J,q)=>this.fetch(J,q)};if(this.wsHandler)G.websocket={open:(J)=>this.wsHandler?.handlers.open?.(J),message:(J,q)=>this.wsHandler?.handlers.message?.(J,q),close:(J,q,A)=>this.wsHandler?.handlers.close?.(J,q,A),drain:(J)=>this.wsHandler?.handlers.drain?.(J)};this.server=Bun.serve(G),console.log(`[BAREJS] \uD83D\uDE80 Server started at http://${Z}:${X}`);let W=()=>{if(this.server)this.server.stop(),process.exit(0)};return process.on("SIGINT",W),process.on("SIGTERM",W),this.server}}var PZ=async(Q,Y,X)=>{let Z=performance.now(),G=new URL(Q.url).pathname,W=await X(),J=(performance.now()-Z).toFixed(2),q=W instanceof Response?W.status:200,A=q>=500?"\x1B[31m":q>=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${G}\x1B[0m ${A}${q}\x1B[0m \x1B[90m(${J}ms)\x1B[0m`),W};var bZ=(Q={})=>{let Y=Q.origin||"*",X=Q.methods||"GET,POST,PUT,PATCH,DELETE,OPTIONS";return async(G,W,J)=>{if(G.method==="OPTIONS")return new Response(null,{status:204,headers:{"Access-Control-Allow-Origin":Y,"Access-Control-Allow-Methods":X,"Access-Control-Allow-Headers":"Content-Type, Authorization"}});let q=await J();if(q instanceof Response)q.headers.set("Access-Control-Allow-Origin",Y),q.headers.set("Access-Control-Allow-Methods",X);return q}};import{join as U8,normalize as SZ,sep as xZ}from"path";var CZ=(Q="public",Y={index:"index.html"})=>{return async(X,Z)=>{if(X.req.method!=="GET"&&X.req.method!=="HEAD")return Z();let G=new URL(X.req.url),W=decodeURIComponent(G.pathname),J=SZ(W).replace(/^(\.\.(\/|\\|$))+/,""),q=U8(process.cwd(),Q,J);if(q.endsWith(xZ)||await Bun.file(q).exists()===!1){let w=U8(q,Y.index);if(await Bun.file(w).exists())q=w;else return Z()}let A=Bun.file(q);if(await A.exists())return new Response(A);return Z()}};var R8=new TextEncoder,A8=async(Q,Y)=>{let X=Bun.crypto.hmac("sha256",Y,Q);return Buffer.from(X).toString("hex")},OZ=async(Q,Y,X)=>{let Z=await A8(Q,X);return Bun.crypto.timingSafeEqual(R8.encode(Y),R8.encode(Z))},FZ=(Q)=>{return async(Y,X)=>{let Z=Y.req.headers.get("Authorization");if(!Z?.startsWith("Bearer "))return Y.status(401).json({status:"error",message:"Bearer token required"});let G=Z.split(" ")[1];if(!G)return Y.status(401).json({status:"error",message:"Invalid token format"});let W=G.split(".");if(W.length!==2)return Y.status(401).json({status:"error",message:"Malformed token"});let[J,q]=W;try{let A=Buffer.from(J,"base64").toString();if(!await OZ(A,q,Q))return Y.status(401).json({status:"error",message:"Invalid signature"});return Y.set("user",JSON.parse(A)),X()}catch(A){return Y.status(401).json({status:"error",message:"Token verification failed"})}}};var KZ={hash:(Q)=>Bun.password.hash(Q,{algorithm:"argon2id"}),verify:(Q,Y)=>Bun.password.verify(Q,Y)},gZ=async(Q,Y)=>{let X=JSON.stringify(Q),Z=Buffer.from(X).toString("base64"),G=await A8(X,Y);return`${Z}.${G}`};export{NZ as zod,jZ as typebox,CZ as staticFile,DZ as native,PZ as logger,gZ as createToken,bZ as cors,FZ as bareAuth,KZ as Password,M8 as BareJS};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { Next } from './context';
|
|
2
|
+
/**
|
|
3
|
+
* 1. BARE TOKEN AUTH (High Performance JWT-like)
|
|
4
|
+
*/
|
|
5
|
+
export declare const bareAuth: (secret: string) => (ctx: any, next: Next) => Promise<any>;
|
|
6
|
+
/**
|
|
7
|
+
* 2. BASIC AUTH
|
|
8
|
+
*/
|
|
9
|
+
export declare const basicAuth: (credentials: {
|
|
10
|
+
user: string;
|
|
11
|
+
pass: string;
|
|
12
|
+
}) => (ctx: any, next: Next) => Promise<any>;
|
|
13
|
+
/**
|
|
14
|
+
* 3. PASSWORD UTILS (Bun Native)
|
|
15
|
+
*/
|
|
16
|
+
export declare const Password: {
|
|
17
|
+
hash: (password: string) => Promise<string>;
|
|
18
|
+
verify: (password: string, hash: string) => Promise<boolean>;
|
|
19
|
+
};
|
|
20
|
+
/**
|
|
21
|
+
* 4. TOKEN GENERATOR
|
|
22
|
+
*/
|
|
23
|
+
export declare const createToken: (payload: object, secret: string) => Promise<string>;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
export * from './context';
|
|
2
|
+
export * from './validators';
|
|
3
|
+
import type { Middleware, WSHandlers } from './context';
|
|
4
|
+
import type { Server } from "bun";
|
|
5
|
+
export interface BarePlugin {
|
|
6
|
+
name: string;
|
|
7
|
+
version: string;
|
|
8
|
+
install: (app: BareJS) => void;
|
|
9
|
+
}
|
|
10
|
+
export declare class BareJS {
|
|
11
|
+
private routes;
|
|
12
|
+
private globalMiddlewares;
|
|
13
|
+
private compiledFetch?;
|
|
14
|
+
private _reusePort;
|
|
15
|
+
private _server;
|
|
16
|
+
private staticMap;
|
|
17
|
+
private dynamicRoutes;
|
|
18
|
+
private wsHandler;
|
|
19
|
+
get server(): Server<any> | null;
|
|
20
|
+
set server(value: Server<any> | null);
|
|
21
|
+
get: (path: string, ...h: any[]) => this;
|
|
22
|
+
post: (path: string, ...h: any[]) => this;
|
|
23
|
+
put: (path: string, ...h: any[]) => this;
|
|
24
|
+
patch: (path: string, ...h: any[]) => this;
|
|
25
|
+
delete: (path: string, ...h: any[]) => this;
|
|
26
|
+
ws: (path: string, handlers: WSHandlers) => this;
|
|
27
|
+
reusePort: (enabled: boolean) => this;
|
|
28
|
+
use: (arg: Middleware | BarePlugin) => this;
|
|
29
|
+
private compile;
|
|
30
|
+
fetch: (req: Request, server?: Server<any>) => any;
|
|
31
|
+
listen(arg1?: number | string, arg2?: number | string): Promise<Server<any>>;
|
|
32
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* High-performance Middleware signature
|
|
3
|
+
* Arguments are passed directly to avoid object allocation overhead.
|
|
4
|
+
*/
|
|
5
|
+
export type Middleware = (req: Request, params: Record<string, string>, next: Next) => any;
|
|
6
|
+
export type Next = () => any;
|
|
7
|
+
/**
|
|
8
|
+
* The Elysia-style Context
|
|
9
|
+
* Extends the native Request with params and high-speed state
|
|
10
|
+
*/
|
|
11
|
+
export type Context = Request & {
|
|
12
|
+
params: Record<string, string>;
|
|
13
|
+
set: (key: string, value: any) => void;
|
|
14
|
+
get: <T>(key: string) => T;
|
|
15
|
+
store: Map<string, any>;
|
|
16
|
+
};
|
|
17
|
+
/**
|
|
18
|
+
* Unified Handler type for auto-inference
|
|
19
|
+
*/
|
|
20
|
+
export type Handler = (c: Context, next: Next) => any;
|
|
21
|
+
export interface WSHandlers {
|
|
22
|
+
open?: (ws: any) => void;
|
|
23
|
+
message?: (ws: any, message: string | Buffer) => void;
|
|
24
|
+
close?: (ws: any, code: number, reason: string) => void;
|
|
25
|
+
drain?: (ws: any) => void;
|
|
26
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export { BareJS } from './bare';
|
|
2
|
+
export type { BarePlugin } from './bare';
|
|
3
|
+
export type { Middleware, Handler, Next, WSHandlers } from './context';
|
|
4
|
+
export { typebox, native, zod } from './validators';
|
|
5
|
+
export { logger } from './logger';
|
|
6
|
+
export { cors } from './cors';
|
|
7
|
+
export { staticFile } from './static';
|
|
8
|
+
export { bareAuth, createToken, Password } from './auth';
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { Middleware } from './context';
|
|
2
|
+
/**
|
|
3
|
+
* TypeBox Validator (JIT Compiled)
|
|
4
|
+
*/
|
|
5
|
+
export declare const typebox: (schema: any) => Middleware;
|
|
6
|
+
/**
|
|
7
|
+
* Native Schema Validator
|
|
8
|
+
*/
|
|
9
|
+
export declare const native: (schema: any) => Middleware;
|
|
10
|
+
/**
|
|
11
|
+
* Zod Validator
|
|
12
|
+
*/
|
|
13
|
+
export declare const zod: (schema: any) => Middleware;
|