@r0cksolid/emerald-cli 0.0.0-stage → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/main.mjs ADDED
@@ -0,0 +1,4609 @@
1
+ #!/usr/bin/env node
2
+ import { $ as IsLiteralString, $t as IsMultipleOf$1, A as Instantiate, At as IsSet, B as Tuple, Bt as IsBoolean$1, Ct as Assign, Dt as Get$3, E as isLevelStyle, Et as Unreachable, F as IsRecord, Ft as Every$1, G as String$1, Gt as IsFunction$1, H as IsUnion, Ht as IsConstructor$1, I as Record, It as EveryAll, J as IsNull$2, Jt as IsInteger$1, K as IsSymbol$2, Kt as IsGreaterEqualThan$1, L as RecordPattern, Lt as HasPropertyKey$1, M as IsTemplateLiteral, Mt as Counted$1, N as IsVoid, Nt as Entries$1, O as Priority, Ot as IsMap, P as IsUndefined$2, Pt as EntriesRegExp, Q as IsLiteralNumber, Qt as IsMinLength$2, R as RecordValue, Rt as IsArray$1, S as createItemCatalog, St as IsSchema$1, T as LevelStyleSchema, Tt as hash_exports, U as Union, Ut as IsDeepEqual$1, V as TemplateLiteralDecode, Vt as IsClassInstance, W as IsString$2, Wt as IsEqual$1, X as IsLiteralBigInt, Xt as IsLessThan$1, Y as IsLiteral, Yt as IsLessEqualThan$1, Z as IsLiteralBoolean, Zt as IsMaxLength$2, _t as IsFunction$2, a as formatWays, an as IsSymbol$1, at as Intersect, b as SnapshotSchema, bt as IsArray$2, c as tagsText, cn as IsValueLike, ct as IsCyclic, d as heading, dn as SomeAll$1, dt as _Object_, en as IsNull$1, et as Literal, f as title, fn as Symbols, ft as IsOptional, gt as Ref$1, h as itemWays, ht as IsRef$1, i as durationText, in as IsString$1, it as IsCodec, j as With, jt as IsTypeArray, k as Evaluate$1, kt as IsRegExp, l as waySections, ln as Keys$1, lt as Unknown, m as isListedWay, mt as IsNever, n as NO_WAY, nn as IsObject$1, nt as IsBoolean$2, on as IsUndefined$1, ot as IsIntersect, p as itemPlan, pn as guard_exports, pt as Optional, q as IsNumber$2, qt as IsGreaterThan$1, rn as IsObjectNotArray$1, rt as IsBigInt$2, s as number, sn as IsUnsafePropertyKey, st as IsEnum$1, t as METHOD_NAMES, tn as IsNumber$1, tt as IsInteger$2, u as dim, un as Some$1, ut as IsObject$2, vt as IsConstructor$2, w as LEVEL_STYLES, wt as Hash, x as checkStatGlyphs, xt as _Array_, y as MetaSchema, yt as ArrayOptions, z as IsTuple, zt as IsBigInt$1 } from "./format-ways-CBqYIK0Q.mjs";
3
+ import { lstat, mkdir, readFile, realpath, writeFile } from "node:fs/promises";
4
+ import { dirname, isAbsolute, join, resolve } from "node:path";
5
+ import { fileURLToPath } from "node:url";
6
+ import { parseArgs } from "node:util";
7
+ import { homedir } from "node:os";
8
+ // ../../node_modules/.pnpm/typebox@1.4.3/node_modules/typebox/build/system/arguments/arguments.mjs
9
+ /**
10
+ * Match arguments for overloaded functions that use the `...args: unknown[]` pattern. Arguments
11
+ * are parsed using argument length only.
12
+ */
13
+ function Match$1(args, match) {
14
+ return match[args.length]?.(...args) ?? (() => {
15
+ throw Error("Invalid Arguments");
16
+ })();
17
+ }
18
+ // ../../node_modules/.pnpm/typebox@1.4.3/node_modules/typebox/build/guard/emit.mjs
19
+ const identifierRegExp = /^[\p{ID_Start}_$][\p{ID_Continue}_$\u200C\u200D]*$/u;
20
+ /** Returns true if this value is a valid JavaScript identifier */
21
+ function IsIdentifier(value) {
22
+ return identifierRegExp.test(value);
23
+ }
24
+ function And(left, right) {
25
+ return `(${left} && ${right})`;
26
+ }
27
+ function Or(left, right) {
28
+ return `(${left} || ${right})`;
29
+ }
30
+ function Not(expr) {
31
+ return `!(${expr})`;
32
+ }
33
+ /** Returns true if this value is an array */
34
+ function IsArray(value) {
35
+ return `Array.isArray(${value})`;
36
+ }
37
+ /** Returns true if this value is bigint */
38
+ function IsBigInt(value) {
39
+ return `typeof ${value} === "bigint"`;
40
+ }
41
+ /** Returns true if this value is a boolean */
42
+ function IsBoolean(value) {
43
+ return `typeof ${value} === "boolean"`;
44
+ }
45
+ /** Returns true if this value is integer */
46
+ function IsInteger(value) {
47
+ return `Number.isInteger(${value})`;
48
+ }
49
+ /** Returns true if this value is null */
50
+ function IsNull(value) {
51
+ return `${value} === null`;
52
+ }
53
+ /** Returns true if this value is number */
54
+ function IsNumber(value) {
55
+ return `Number.isFinite(${value})`;
56
+ }
57
+ /** Returns true if this value is an object but not an array */
58
+ function IsObjectNotArray(value) {
59
+ return And(IsObject(value), Not(IsArray(value)));
60
+ }
61
+ /** Returns true if this value is an object */
62
+ function IsObject(value) {
63
+ return `typeof ${value} === "object" && ${value} !== null`;
64
+ }
65
+ /** Returns true if this value is string */
66
+ function IsString(value) {
67
+ return `typeof ${value} === "string"`;
68
+ }
69
+ /** Returns true if this value is symbol */
70
+ function IsSymbol(value) {
71
+ return `typeof ${value} === "symbol"`;
72
+ }
73
+ /** Returns true if this value is undefined */
74
+ function IsUndefined(value) {
75
+ return `${value} === undefined`;
76
+ }
77
+ function IsFunction(value) {
78
+ return `typeof ${value} === "function"`;
79
+ }
80
+ function IsConstructor(value) {
81
+ return `Guard.IsConstructor(${value})`;
82
+ }
83
+ function IsEqual(left, right) {
84
+ return `${left} === ${right}`;
85
+ }
86
+ function IsGreaterThan(left, right) {
87
+ return `${left} > ${right}`;
88
+ }
89
+ function IsLessThan(left, right) {
90
+ return `${left} < ${right}`;
91
+ }
92
+ function IsLessEqualThan(left, right) {
93
+ return `${left} <= ${right}`;
94
+ }
95
+ function IsGreaterEqualThan(left, right) {
96
+ return `${left} >= ${right}`;
97
+ }
98
+ function IsMinLength$1(value, length) {
99
+ return `(${value}.length >= ${+length << 1} || (${value}.length >= ${length} && Guard.CodePointCount(${value}) >= ${length}))`;
100
+ }
101
+ function IsMaxLength$1(value, length) {
102
+ return `(${value}.length <= ${length} || (${value}.length <= ${+length << 1} && Guard.CodePointCount(${value}) <= ${length}))`;
103
+ }
104
+ function Every(value, offset, params, expression) {
105
+ return IsEqual$1(offset, "0") ? `${value}.every((${params[0]}, ${params[1]}) => (${expression}))` : `${value}.every((${params[0]}, ${params[1]}) => (${params[1]} < ${offset}) || (${expression}))`;
106
+ }
107
+ function Some(value, params, expression) {
108
+ return `${value}.some((${params[0]}, ${params[1]}) => ${expression})`;
109
+ }
110
+ function SomeAll(value, params, expression) {
111
+ return `((value) => { let result = false; value.forEach((${params[0]}, ${params[1]}) => { if (${expression}) result = true }); return result })(${value})`;
112
+ }
113
+ function Counted(value, params, expression) {
114
+ return `${value}.reduce((result, ${params[0]}, ${params[1]}) => (${expression}) ? ++result : result, 0)`;
115
+ }
116
+ function Entries(value) {
117
+ return `Object.entries(${value})`;
118
+ }
119
+ function Keys(value) {
120
+ return `Object.getOwnPropertyNames(${value})`;
121
+ }
122
+ function HasPropertyKey(value, key) {
123
+ return IsEqual$1(key, "\"__proto__\"") || IsEqual$1(key, "\"constructor\"") ? `Object.prototype.hasOwnProperty.call(${value}, ${key})` : `${key} in ${value}`;
124
+ }
125
+ function IsDeepEqual(left, right) {
126
+ return `Guard.IsDeepEqual(${left}, ${right})`;
127
+ }
128
+ function ArrayLiteral(elements) {
129
+ return `[${elements.join(", ")}]`;
130
+ }
131
+ function ArrowFunction(parameters, body) {
132
+ return `((${parameters.join(", ")}) => ${body})`;
133
+ }
134
+ function Call(value, arguments_) {
135
+ return `${value}(${arguments_.join(", ")})`;
136
+ }
137
+ function New(value, arguments_) {
138
+ return `new ${value}(${arguments_.join(", ")})`;
139
+ }
140
+ function Member(left, right) {
141
+ return `${left}${IsIdentifier(right) ? `.${right}` : `[${Constant(right)}]`}`;
142
+ }
143
+ function Constant(value) {
144
+ if (!IsValueLike(value)) throw Error("Unsupported Constant");
145
+ return IsString$1(value) ? JSON.stringify(value) : `${value}`;
146
+ }
147
+ function Ternary(condition, true_, false_) {
148
+ return `(${condition} ? ${true_} : ${false_})`;
149
+ }
150
+ function Statements(statements) {
151
+ return `{ ${statements.join("; ")}; }`;
152
+ }
153
+ function ConstDeclaration(identifier, expression) {
154
+ return `const ${identifier} = ${expression}`;
155
+ }
156
+ function If(condition, then) {
157
+ return `if(${condition}) { ${then} }`;
158
+ }
159
+ function Return(expression) {
160
+ return `return ${expression}`;
161
+ }
162
+ function ReduceAnd(operands) {
163
+ return IsEqual$1(operands.length, 0) ? "true" : operands.reduce((left, right) => And(left, right));
164
+ }
165
+ function ReduceOr(operands) {
166
+ return IsEqual$1(operands.length, 0) ? "false" : operands.reduce((left, right) => Or(left, right));
167
+ }
168
+ function MultipleOf(dividend, divisor) {
169
+ return `Guard.IsMultipleOf(${dividend}, ${divisor})`;
170
+ }
171
+ // ../../node_modules/.pnpm/typebox@1.4.3/node_modules/typebox/build/guard/index.mjs
172
+ var guard_default = guard_exports;
173
+ // ../../node_modules/.pnpm/typebox@1.4.3/node_modules/typebox/build/schema/types/_refine.mjs
174
+ /**
175
+ * Returns true if the schema contains an '~refine` keyword
176
+ * @specification None
177
+ */
178
+ function IsRefine(value) {
179
+ return HasPropertyKey$1(value, "~refine") && IsArray$1(value["~refine"]) && Every$1(value["~refine"], 0, (value) => IsObject$1(value) && HasPropertyKey$1(value, "check") && HasPropertyKey$1(value, "error") && IsFunction$1(value.check) && IsFunction$1(value.error));
180
+ }
181
+ // ../../node_modules/.pnpm/typebox@1.4.3/node_modules/typebox/build/schema/types/schema.mjs
182
+ /** Returns true if this value is object like */
183
+ function IsSchemaObject$1(value) {
184
+ return IsObject$1(value) && !IsArray$1(value);
185
+ }
186
+ /** Returns true if this value is a boolean */
187
+ function IsSchemaBoolean(value) {
188
+ return IsBoolean$1(value);
189
+ }
190
+ /** Returns true if this value is schema like */
191
+ function IsSchema(value) {
192
+ return IsSchemaObject$1(value) || IsSchemaBoolean(value);
193
+ }
194
+ // ../../node_modules/.pnpm/typebox@1.4.3/node_modules/typebox/build/schema/types/additionalItems.mjs
195
+ /**
196
+ * Returns true if the schema contains a valid additionalItems property
197
+ * @specification Json Schema 7
198
+ */
199
+ function IsAdditionalItems(schema) {
200
+ return HasPropertyKey$1(schema, "additionalItems") && IsSchema(schema.additionalItems);
201
+ }
202
+ // ../../node_modules/.pnpm/typebox@1.4.3/node_modules/typebox/build/schema/types/additionalProperties.mjs
203
+ /**
204
+ * Returns true if the schema contains a valid additionalProperties property
205
+ * @specification Json Schema 7
206
+ */
207
+ function IsAdditionalProperties(schema) {
208
+ return HasPropertyKey$1(schema, "additionalProperties") && IsSchema(schema.additionalProperties);
209
+ }
210
+ // ../../node_modules/.pnpm/typebox@1.4.3/node_modules/typebox/build/schema/types/allOf.mjs
211
+ /**
212
+ * Returns true if the schema contains a valid allOf property
213
+ * @specification Json Schema 7
214
+ */
215
+ function IsAllOf(schema) {
216
+ return HasPropertyKey$1(schema, "allOf") && IsArray$1(schema.allOf) && schema.allOf.every((value) => IsSchema(value));
217
+ }
218
+ // ../../node_modules/.pnpm/typebox@1.4.3/node_modules/typebox/build/schema/types/anchor.mjs
219
+ /**
220
+ * Returns true if the schema contains a valid $anchor property
221
+ */
222
+ function IsAnchor(schema) {
223
+ return HasPropertyKey$1(schema, "$anchor") && IsString$1(schema.$anchor);
224
+ }
225
+ // ../../node_modules/.pnpm/typebox@1.4.3/node_modules/typebox/build/schema/types/anyOf.mjs
226
+ /**
227
+ * Returns true if the schema contains a valid anyOf property
228
+ * @specification Json Schema 7
229
+ */
230
+ function IsAnyOf(schema) {
231
+ return HasPropertyKey$1(schema, "anyOf") && IsArray$1(schema.anyOf) && schema.anyOf.every((value) => IsSchema(value));
232
+ }
233
+ // ../../node_modules/.pnpm/typebox@1.4.3/node_modules/typebox/build/schema/types/const.mjs
234
+ /**
235
+ * Returns true if the schema contains a valid const property
236
+ * @specification Json Schema 7
237
+ */
238
+ function IsConst(value) {
239
+ return HasPropertyKey$1(value, "const");
240
+ }
241
+ // ../../node_modules/.pnpm/typebox@1.4.3/node_modules/typebox/build/schema/types/contains.mjs
242
+ /**
243
+ * Returns true if the schema contains a valid contains property
244
+ * @specification Json Schema 7
245
+ */
246
+ function IsContains(schema) {
247
+ return HasPropertyKey$1(schema, "contains") && IsSchema(schema.contains);
248
+ }
249
+ // ../../node_modules/.pnpm/typebox@1.4.3/node_modules/typebox/build/schema/types/default.mjs
250
+ /**
251
+ * Returns true if the schema contains a valid contentMediaType property
252
+ * @specification Json Schema 7
253
+ */
254
+ function IsDefault(schema) {
255
+ return HasPropertyKey$1(schema, "default");
256
+ }
257
+ // ../../node_modules/.pnpm/typebox@1.4.3/node_modules/typebox/build/schema/types/dependencies.mjs
258
+ /**
259
+ * Returns true if the schema contains a valid dependencies property
260
+ * @specification Json Schema 7
261
+ */
262
+ function IsDependencies(schema) {
263
+ return HasPropertyKey$1(schema, "dependencies") && IsObject$1(schema.dependencies) && Object.values(schema.dependencies).every((value) => IsSchema(value) || IsArray$1(value) && value.every((value) => IsString$1(value)));
264
+ }
265
+ // ../../node_modules/.pnpm/typebox@1.4.3/node_modules/typebox/build/schema/types/dependentRequired.mjs
266
+ /**
267
+ * Returns true if the schema contains a valid dependentRequired property
268
+ * @specification Json Schema 2019-09
269
+ */
270
+ function IsDependentRequired(schema) {
271
+ return HasPropertyKey$1(schema, "dependentRequired") && IsObject$1(schema.dependentRequired) && Object.values(schema.dependentRequired).every((value) => IsArray$1(value) && value.every((value) => IsString$1(value)));
272
+ }
273
+ // ../../node_modules/.pnpm/typebox@1.4.3/node_modules/typebox/build/schema/types/dependentSchemas.mjs
274
+ /**
275
+ * Returns true if the schema contains a valid dependentRequired property
276
+ * @specification Json Schema 2019-09
277
+ */
278
+ function IsDependentSchemas(schema) {
279
+ return HasPropertyKey$1(schema, "dependentSchemas") && IsObject$1(schema.dependentSchemas) && Object.values(schema.dependentSchemas).every((value) => IsSchema(value));
280
+ }
281
+ // ../../node_modules/.pnpm/typebox@1.4.3/node_modules/typebox/build/schema/types/dynamicAnchor.mjs
282
+ /**
283
+ * Returns true if the schema contains a valid $dynamicAnchor property
284
+ */
285
+ function IsDynamicAnchor(schema) {
286
+ return HasPropertyKey$1(schema, "$dynamicAnchor") && IsString$1(schema.$dynamicAnchor);
287
+ }
288
+ // ../../node_modules/.pnpm/typebox@1.4.3/node_modules/typebox/build/schema/types/dynamicRef.mjs
289
+ /**
290
+ * Returns true if the schema contains a valid $dynamicRef property
291
+ */
292
+ function IsDynamicRef(schema) {
293
+ return HasPropertyKey$1(schema, "$dynamicRef") && IsString$1(schema.$dynamicRef);
294
+ }
295
+ // ../../node_modules/.pnpm/typebox@1.4.3/node_modules/typebox/build/schema/types/else.mjs
296
+ /**
297
+ * Returns true if the schema contains a valid else property
298
+ * @specification Json Schema 7
299
+ */
300
+ function IsElse(schema) {
301
+ return HasPropertyKey$1(schema, "else") && IsSchema(schema.else);
302
+ }
303
+ // ../../node_modules/.pnpm/typebox@1.4.3/node_modules/typebox/build/schema/types/enum.mjs
304
+ /**
305
+ * Returns true if the schema contains a valid enum property
306
+ * @specification Json Schema 7
307
+ */
308
+ function IsEnum(schema) {
309
+ return HasPropertyKey$1(schema, "enum") && IsArray$1(schema.enum);
310
+ }
311
+ // ../../node_modules/.pnpm/typebox@1.4.3/node_modules/typebox/build/schema/types/exclusiveMaximum.mjs
312
+ /**
313
+ * Returns true if the schema contains a valid exclusiveMaximum property
314
+ * @specification Json Schema 7
315
+ */
316
+ function IsExclusiveMaximum(schema) {
317
+ return HasPropertyKey$1(schema, "exclusiveMaximum") && (IsNumber$1(schema.exclusiveMaximum) || IsBigInt$1(schema.exclusiveMaximum));
318
+ }
319
+ // ../../node_modules/.pnpm/typebox@1.4.3/node_modules/typebox/build/schema/types/exclusiveMinimum.mjs
320
+ /**
321
+ * Returns true if the schema contains a valid exclusiveMinimum property
322
+ * @specification Json Schema 7
323
+ */
324
+ function IsExclusiveMinimum(schema) {
325
+ return HasPropertyKey$1(schema, "exclusiveMinimum") && (IsNumber$1(schema.exclusiveMinimum) || IsBigInt$1(schema.exclusiveMinimum));
326
+ }
327
+ // ../../node_modules/.pnpm/typebox@1.4.3/node_modules/typebox/build/schema/types/format.mjs
328
+ /**
329
+ * Returns true if the schema contains a valid format property
330
+ * @specification Json Schema 7
331
+ */
332
+ function IsFormat(schema) {
333
+ return HasPropertyKey$1(schema, "format") && IsString$1(schema.format);
334
+ }
335
+ // ../../node_modules/.pnpm/typebox@1.4.3/node_modules/typebox/build/schema/types/id.mjs
336
+ /**
337
+ * Returns true if the schema contains a valid $id property
338
+ * @specification Json Schema 7
339
+ */
340
+ function IsId(schema) {
341
+ return HasPropertyKey$1(schema, "$id") && IsString$1(schema.$id);
342
+ }
343
+ // ../../node_modules/.pnpm/typebox@1.4.3/node_modules/typebox/build/schema/types/if.mjs
344
+ /**
345
+ * Returns true if the schema contains a valid $id property
346
+ * @specification Json Schema 7
347
+ */
348
+ function IsIf(schema) {
349
+ return HasPropertyKey$1(schema, "if") && IsSchema(schema.if);
350
+ }
351
+ // ../../node_modules/.pnpm/typebox@1.4.3/node_modules/typebox/build/schema/types/items.mjs
352
+ /**
353
+ * Returns true if the schema contains a valid items property
354
+ * @specification Json Schema 7
355
+ */
356
+ function IsItems(schema) {
357
+ return HasPropertyKey$1(schema, "items") && (IsSchema(schema.items) || IsArray$1(schema.items) && schema.items.every((value) => {
358
+ return IsSchema(value);
359
+ }));
360
+ }
361
+ /** Returns true if this schema is a sized items variant */
362
+ function IsItemsSized(schema) {
363
+ return IsItems(schema) && IsArray$1(schema.items);
364
+ }
365
+ // ../../node_modules/.pnpm/typebox@1.4.3/node_modules/typebox/build/schema/types/maximum.mjs
366
+ /**
367
+ * Returns true if the schema contains a valid maximum property
368
+ * @specification Json Schema 7
369
+ */
370
+ function IsMaximum(schema) {
371
+ return HasPropertyKey$1(schema, "maximum") && (IsNumber$1(schema.maximum) || IsBigInt$1(schema.maximum));
372
+ }
373
+ // ../../node_modules/.pnpm/typebox@1.4.3/node_modules/typebox/build/schema/types/maxContains.mjs
374
+ /**
375
+ * Returns true if the schema contains a valid maxContains property
376
+ * @specification Json Schema 2019-09
377
+ */
378
+ function IsMaxContains(schema) {
379
+ return HasPropertyKey$1(schema, "maxContains") && IsNumber$1(schema.maxContains);
380
+ }
381
+ // ../../node_modules/.pnpm/typebox@1.4.3/node_modules/typebox/build/schema/types/maxItems.mjs
382
+ /**
383
+ * Returns true if the schema contains a valid maxItems property
384
+ * @specification Json Schema 7
385
+ */
386
+ function IsMaxItems(schema) {
387
+ return HasPropertyKey$1(schema, "maxItems") && IsNumber$1(schema.maxItems);
388
+ }
389
+ // ../../node_modules/.pnpm/typebox@1.4.3/node_modules/typebox/build/schema/types/maxLength.mjs
390
+ /**
391
+ * Returns true if the schema contains a valid maxLength property
392
+ * @specification Json Schema 7
393
+ */
394
+ function IsMaxLength(schema) {
395
+ return HasPropertyKey$1(schema, "maxLength") && IsNumber$1(schema.maxLength);
396
+ }
397
+ // ../../node_modules/.pnpm/typebox@1.4.3/node_modules/typebox/build/schema/types/maxProperties.mjs
398
+ /**
399
+ * Returns true if the schema contains a valid maxProperties property
400
+ * @specification Json Schema 7
401
+ */
402
+ function IsMaxProperties(schema) {
403
+ return HasPropertyKey$1(schema, "maxProperties") && IsNumber$1(schema.maxProperties);
404
+ }
405
+ // ../../node_modules/.pnpm/typebox@1.4.3/node_modules/typebox/build/schema/types/minimum.mjs
406
+ /**
407
+ * Returns true if the schema contains a valid minimum property
408
+ * @specification Json Schema 7
409
+ */
410
+ function IsMinimum(schema) {
411
+ return HasPropertyKey$1(schema, "minimum") && (IsNumber$1(schema.minimum) || IsBigInt$1(schema.minimum));
412
+ }
413
+ // ../../node_modules/.pnpm/typebox@1.4.3/node_modules/typebox/build/schema/types/minContains.mjs
414
+ /**
415
+ * Returns true if the schema contains a valid maxContains property
416
+ * @specification Json Schema 2019-09
417
+ */
418
+ function IsMinContains(schema) {
419
+ return HasPropertyKey$1(schema, "minContains") && IsNumber$1(schema.minContains);
420
+ }
421
+ // ../../node_modules/.pnpm/typebox@1.4.3/node_modules/typebox/build/schema/types/minItems.mjs
422
+ /**
423
+ * Returns true if the schema contains a valid minItems property
424
+ * @specification Json Schema 7
425
+ */
426
+ function IsMinItems(schema) {
427
+ return HasPropertyKey$1(schema, "minItems") && IsNumber$1(schema.minItems);
428
+ }
429
+ // ../../node_modules/.pnpm/typebox@1.4.3/node_modules/typebox/build/schema/types/minLength.mjs
430
+ /**
431
+ * Returns true if the schema contains a valid minLength property
432
+ * @specification Json Schema 7
433
+ */
434
+ function IsMinLength(schema) {
435
+ return HasPropertyKey$1(schema, "minLength") && IsNumber$1(schema.minLength);
436
+ }
437
+ // ../../node_modules/.pnpm/typebox@1.4.3/node_modules/typebox/build/schema/types/minProperties.mjs
438
+ /**
439
+ * Returns true if the schema contains a valid minProperties property
440
+ * @specification Json Schema 7
441
+ */
442
+ function IsMinProperties(schema) {
443
+ return HasPropertyKey$1(schema, "minProperties") && IsNumber$1(schema.minProperties);
444
+ }
445
+ // ../../node_modules/.pnpm/typebox@1.4.3/node_modules/typebox/build/schema/types/multipleOf.mjs
446
+ /**
447
+ * Returns true if the schema contains a valid multipleOf property
448
+ * @specification Json Schema 7
449
+ */
450
+ function IsMultipleOf(schema) {
451
+ return HasPropertyKey$1(schema, "multipleOf") && (IsNumber$1(schema.multipleOf) || IsBigInt$1(schema.multipleOf));
452
+ }
453
+ // ../../node_modules/.pnpm/typebox@1.4.3/node_modules/typebox/build/schema/types/not.mjs
454
+ /**
455
+ * Returns true if the schema contains a valid not property
456
+ * @specification Json Schema 7
457
+ */
458
+ function IsNot(schema) {
459
+ return HasPropertyKey$1(schema, "not") && IsSchema(schema.not);
460
+ }
461
+ // ../../node_modules/.pnpm/typebox@1.4.3/node_modules/typebox/build/schema/types/oneOf.mjs
462
+ /**
463
+ * Returns true if the schema contains a valid oneOf property
464
+ * @specification Json Schema 7
465
+ */
466
+ function IsOneOf(schema) {
467
+ return HasPropertyKey$1(schema, "oneOf") && IsArray$1(schema.oneOf) && schema.oneOf.every((value) => IsSchema(value));
468
+ }
469
+ // ../../node_modules/.pnpm/typebox@1.4.3/node_modules/typebox/build/schema/types/pattern.mjs
470
+ /**
471
+ * Returns true if the schema contains a valid pattern property
472
+ * @specification Json Schema 7
473
+ */
474
+ function IsPattern(schema) {
475
+ return HasPropertyKey$1(schema, "pattern") && (IsString$1(schema.pattern) || schema.pattern instanceof RegExp);
476
+ }
477
+ // ../../node_modules/.pnpm/typebox@1.4.3/node_modules/typebox/build/schema/types/patternProperties.mjs
478
+ /**
479
+ * Returns true if the schema contains a valid patternProperties property
480
+ * @specification Json Schema 7
481
+ */
482
+ function IsPatternProperties(schema) {
483
+ return HasPropertyKey$1(schema, "patternProperties") && IsObject$1(schema.patternProperties) && Object.values(schema.patternProperties).every((value) => IsSchema(value));
484
+ }
485
+ // ../../node_modules/.pnpm/typebox@1.4.3/node_modules/typebox/build/schema/types/prefixItems.mjs
486
+ /**
487
+ * Returns true if the schema contains a valid prefixItems property
488
+ */
489
+ function IsPrefixItems(schema) {
490
+ return HasPropertyKey$1(schema, "prefixItems") && IsArray$1(schema.prefixItems) && schema.prefixItems.every((schema) => IsSchema(schema));
491
+ }
492
+ // ../../node_modules/.pnpm/typebox@1.4.3/node_modules/typebox/build/schema/types/properties.mjs
493
+ /**
494
+ * Returns true if the schema contains a valid properties property
495
+ * @specification Json Schema 7
496
+ */
497
+ function IsProperties(schema) {
498
+ return HasPropertyKey$1(schema, "properties") && IsObject$1(schema.properties) && Object.values(schema.properties).every((value) => IsSchema(value));
499
+ }
500
+ // ../../node_modules/.pnpm/typebox@1.4.3/node_modules/typebox/build/schema/types/propertyNames.mjs
501
+ /**
502
+ * Returns true if the schema contains a valid propertyNames property
503
+ * @specification Json Schema 7
504
+ */
505
+ function IsPropertyNames(schema) {
506
+ return HasPropertyKey$1(schema, "propertyNames") && (IsObject$1(schema.propertyNames) || IsSchema(schema.propertyNames));
507
+ }
508
+ // ../../node_modules/.pnpm/typebox@1.4.3/node_modules/typebox/build/schema/types/recursiveAnchor.mjs
509
+ /**
510
+ * Returns true if the schema contains a valid $recursiveAnchor property
511
+ */
512
+ function IsRecursiveAnchor(schema) {
513
+ return HasPropertyKey$1(schema, "$recursiveAnchor") && IsBoolean$1(schema.$recursiveAnchor);
514
+ }
515
+ /**
516
+ * Returns true if the schema contains a valid $recursiveAnchor property that is true
517
+ */
518
+ function IsRecursiveAnchorTrue(schema) {
519
+ return IsRecursiveAnchor(schema) && IsEqual$1(schema.$recursiveAnchor, true);
520
+ }
521
+ // ../../node_modules/.pnpm/typebox@1.4.3/node_modules/typebox/build/schema/types/recursiveRef.mjs
522
+ /**
523
+ * Returns true if the schema contains a valid $recursiveRef property
524
+ */
525
+ function IsRecursiveRef(schema) {
526
+ return HasPropertyKey$1(schema, "$recursiveRef") && IsString$1(schema.$recursiveRef);
527
+ }
528
+ // ../../node_modules/.pnpm/typebox@1.4.3/node_modules/typebox/build/schema/types/ref.mjs
529
+ /**
530
+ * Returns true if the schema contains a valid $ref property
531
+ * @specification Json Schema 7
532
+ */
533
+ function IsRef(schema) {
534
+ return HasPropertyKey$1(schema, "$ref") && IsString$1(schema.$ref);
535
+ }
536
+ // ../../node_modules/.pnpm/typebox@1.4.3/node_modules/typebox/build/schema/types/required.mjs
537
+ /**
538
+ * Returns true if the schema contains a valid required property
539
+ * @specification Json Schema 7
540
+ */
541
+ function IsRequired(schema) {
542
+ return HasPropertyKey$1(schema, "required") && IsArray$1(schema.required) && schema.required.every((value) => IsString$1(value));
543
+ }
544
+ // ../../node_modules/.pnpm/typebox@1.4.3/node_modules/typebox/build/schema/types/then.mjs
545
+ /**
546
+ * Returns true if the schema contains a valid then property
547
+ * @specification Json Schema 7
548
+ */
549
+ function IsThen(schema) {
550
+ return HasPropertyKey$1(schema, "then") && IsSchema(schema.then);
551
+ }
552
+ // ../../node_modules/.pnpm/typebox@1.4.3/node_modules/typebox/build/schema/types/type.mjs
553
+ /**
554
+ * Returns true if the schema contains a valid type property
555
+ * @specification Json Schema 7
556
+ */
557
+ function IsType(schema) {
558
+ return HasPropertyKey$1(schema, "type") && (IsString$1(schema.type) || IsArray$1(schema.type) && schema.type.every((value) => IsString$1(value)));
559
+ }
560
+ // ../../node_modules/.pnpm/typebox@1.4.3/node_modules/typebox/build/schema/types/uniqueItems.mjs
561
+ /**
562
+ * Returns true if the schema contains a valid uniqueItems property
563
+ * @specification Json Schema 7
564
+ */
565
+ function IsUniqueItems(schema) {
566
+ return HasPropertyKey$1(schema, "uniqueItems") && IsBoolean$1(schema.uniqueItems);
567
+ }
568
+ // ../../node_modules/.pnpm/typebox@1.4.3/node_modules/typebox/build/schema/types/unevaluatedItems.mjs
569
+ /**
570
+ * Returns true if the schema contains a valid unevaluatedItems property
571
+ * @specification Json Schema 2019-09
572
+ */
573
+ function IsUnevaluatedItems(schema) {
574
+ return HasPropertyKey$1(schema, "unevaluatedItems") && IsSchema(schema.unevaluatedItems);
575
+ }
576
+ // ../../node_modules/.pnpm/typebox@1.4.3/node_modules/typebox/build/schema/types/unevaluatedProperties.mjs
577
+ /**
578
+ * Returns true if the schema contains a valid unevaluatedProperties property
579
+ * @specification Json Schema 2019-09
580
+ */
581
+ function IsUnevaluatedProperties(schema) {
582
+ return HasPropertyKey$1(schema, "unevaluatedProperties") && IsSchema(schema.unevaluatedProperties);
583
+ }
584
+ // ../../node_modules/.pnpm/typebox@1.4.3/node_modules/typebox/build/schema/engine/_context.mjs
585
+ function HasUnevaluatedFromObject(value) {
586
+ return IsUnevaluatedItems(value) || IsUnevaluatedProperties(value) || Some$1(Keys$1(value), (key) => HasUnevaluatedFromUnknown(value[key]));
587
+ }
588
+ function HasUnevaluatedFromArray(value) {
589
+ return Some$1(value, (value) => HasUnevaluatedFromUnknown(value));
590
+ }
591
+ function HasUnevaluatedFromUnknown(value) {
592
+ return IsArray$1(value) ? HasUnevaluatedFromArray(value) : IsObject$1(value) ? HasUnevaluatedFromObject(value) : false;
593
+ }
594
+ function HasUnevaluated(context, schema) {
595
+ return HasUnevaluatedFromUnknown(schema) || Some$1(Keys$1(context), (key) => HasUnevaluatedFromUnknown(context[key]));
596
+ }
597
+ var BuildContext = class {
598
+ constructor(hasUnevaluated) {
599
+ this.hasUnevaluated = hasUnevaluated;
600
+ }
601
+ UseUnevaluated() {
602
+ return this.hasUnevaluated;
603
+ }
604
+ Push() {
605
+ return Call(Member("context", "Push"), []);
606
+ }
607
+ Pop() {
608
+ return Call(Member("context", "Pop"), []);
609
+ }
610
+ AddIndex(index) {
611
+ return Call(Member("context", "AddIndex"), [index]);
612
+ }
613
+ AddKey(key) {
614
+ return Call(Member("context", "AddKey"), [key]);
615
+ }
616
+ Merge(results) {
617
+ return Call(Member("context", "Merge"), [results]);
618
+ }
619
+ };
620
+ var CheckContext = class {
621
+ constructor() {
622
+ const indices = /* @__PURE__ */ new Set();
623
+ const keys = /* @__PURE__ */ new Set();
624
+ this.stack = [{
625
+ indices,
626
+ keys
627
+ }];
628
+ }
629
+ Push() {
630
+ const indices = /* @__PURE__ */ new Set();
631
+ const keys = /* @__PURE__ */ new Set();
632
+ this.stack.push({
633
+ indices,
634
+ keys
635
+ });
636
+ return true;
637
+ }
638
+ Pop() {
639
+ this.stack.pop();
640
+ return true;
641
+ }
642
+ AddIndex(index) {
643
+ this.GetIndices().add(index);
644
+ return true;
645
+ }
646
+ AddKey(key) {
647
+ this.GetKeys().add(key);
648
+ return true;
649
+ }
650
+ GetIndices() {
651
+ return this.stack[this.stack.length - 1].indices;
652
+ }
653
+ GetKeys() {
654
+ return this.stack[this.stack.length - 1].keys;
655
+ }
656
+ Merge(results) {
657
+ for (const context of results) {
658
+ context.GetIndices().forEach((value) => this.GetIndices().add(value));
659
+ context.GetKeys().forEach((value) => this.GetKeys().add(value));
660
+ }
661
+ return true;
662
+ }
663
+ };
664
+ var ErrorContext = class extends CheckContext {
665
+ constructor() {
666
+ super();
667
+ this.errors = [];
668
+ }
669
+ AtCapacity() {
670
+ return this.errors.length >= Get$3().maxErrors;
671
+ }
672
+ AddError(keyword, schemaPath, instancePath, params) {
673
+ return this.AddErrorObject({
674
+ keyword,
675
+ schemaPath,
676
+ instancePath,
677
+ params
678
+ });
679
+ }
680
+ AddErrors(error) {
681
+ error.forEach((error) => this.AddErrorObject(error));
682
+ return false;
683
+ }
684
+ GetErrors() {
685
+ return this.errors;
686
+ }
687
+ AddErrorObject(error) {
688
+ if (!this.AtCapacity()) this.errors.push(error);
689
+ return false;
690
+ }
691
+ };
692
+ // ../../node_modules/.pnpm/typebox@1.4.3/node_modules/typebox/build/schema/engine/_externals.mjs
693
+ const state = {
694
+ identifier: "External",
695
+ variables: []
696
+ };
697
+ function CreateVariable(value) {
698
+ const call = `External[${state.variables.length}]`;
699
+ state.variables.push(value);
700
+ return call;
701
+ }
702
+ function ResetExternal() {
703
+ state.variables = [];
704
+ }
705
+ function GetExternal() {
706
+ return { ...state };
707
+ }
708
+ // ../../node_modules/.pnpm/typebox@1.4.3/node_modules/typebox/build/schema/engine/_refine.mjs
709
+ function BuildRefineMultiple(_stack, _context, schema, value) {
710
+ return Every(CreateVariable(schema["~refine"]), Constant(0), ["refinement", "_"], Call(Member("refinement", "check"), [value]));
711
+ }
712
+ function BuildRefineSingle(_stack, _context, schema, value) {
713
+ return Call(Member(CreateVariable(schema["~refine"][0]), "check"), [value]);
714
+ }
715
+ function BuildRefine(_stack, _context, schema, value) {
716
+ return IsEqual$1(schema["~refine"].length, 1) ? BuildRefineSingle(_stack, _context, schema, value) : BuildRefineMultiple(_stack, _context, schema, value);
717
+ }
718
+ function CheckRefine(_stack, _context, schema, value) {
719
+ return Every$1(schema["~refine"], 0, (refinement, _) => refinement.check(value));
720
+ }
721
+ function ErrorRefine(_stack, context, schemaPath, instancePath, schema, value) {
722
+ return EveryAll(schema["~refine"], 0, (refinement, index) => {
723
+ return refinement.check(value) || context.AddError("~refine", schemaPath, instancePath, {
724
+ index,
725
+ message: refinement.error(value)
726
+ });
727
+ });
728
+ }
729
+ // ../../node_modules/.pnpm/typebox@1.4.3/node_modules/typebox/build/schema/engine/_stack.mjs
730
+ const DefaultUri = "urn:typebox:root";
731
+ function NextUri(ref, base) {
732
+ return URL.canParse(ref, base) ? new URL(ref, base) : IsEqual$1(base, "urn:typebox:root") ? new URL(`${base}:${ref}`) : new URL(`${base.slice(0, base.lastIndexOf(":"))}:${ref}`);
733
+ }
734
+ function Stack(context, schema) {
735
+ const base = IsSchemaObject$1(schema) && IsId(schema) ? NextUri(schema.$id, DefaultUri).href : DefaultUri;
736
+ return {
737
+ context,
738
+ schema,
739
+ lexicalSchema: schema,
740
+ lexicalBase: base,
741
+ resourceBase: base,
742
+ referenceBase: base,
743
+ ids: [],
744
+ useResourceBaseForReference: true,
745
+ recursiveAnchor: void 0,
746
+ dynamicAnchors: [],
747
+ resourceEntries: /* @__PURE__ */ new Map(),
748
+ pendingResource: true,
749
+ enteredResource: false
750
+ };
751
+ }
752
+ function RegisterResourceAnchors(anchors, schema, isRoot = true) {
753
+ if (IsSchemaBoolean(schema)) return anchors;
754
+ if (Array.isArray(schema)) return schema.reduce((result, item) => RegisterResourceAnchors(result, item, false), anchors);
755
+ if (!IsSchemaObject$1(schema)) return anchors;
756
+ if (!isRoot && IsId(schema)) return anchors;
757
+ const next = !isRoot && IsDynamicAnchor(schema) ? [...anchors, schema] : anchors;
758
+ return Object.keys(schema).reduce((result, key) => RegisterResourceAnchors(result, schema[key], false), next);
759
+ }
760
+ function ResourceEntry(stack, schema) {
761
+ return stack.resourceEntries.get(schema);
762
+ }
763
+ function NextEnteredResource(stack, schema) {
764
+ return stack.enteredResource || ResourceEntry(stack, schema) !== void 0;
765
+ }
766
+ function IsRelativeId(schema) {
767
+ return !/^[A-Za-z][A-Za-z0-9+.-]*:/.test(schema.$id);
768
+ }
769
+ function NextIds(stack, schema) {
770
+ return IsId(schema) ? [...stack.ids, schema] : stack.ids;
771
+ }
772
+ function NextRecursiveAnchor(stack, schema) {
773
+ return stack.recursiveAnchor ?? (IsRecursiveAnchorTrue(schema) ? schema : void 0);
774
+ }
775
+ function NextDynamicAnchors(stack, schema) {
776
+ const registered = IsId(schema) ? RegisterResourceAnchors(stack.dynamicAnchors, schema) : stack.dynamicAnchors;
777
+ return IsDynamicAnchor(schema) ? [...registered, schema] : registered;
778
+ }
779
+ function NextPendingResource(stack, schema) {
780
+ return IsId(schema) ? false : stack.pendingResource;
781
+ }
782
+ function NextLexicalBase(stack, schema) {
783
+ const entry = ResourceEntry(stack, schema);
784
+ if (entry) return entry.base;
785
+ return IsId(schema) ? NextUri(schema.$id, stack.lexicalBase).href : stack.lexicalBase;
786
+ }
787
+ function NextResourceBase(stack, schema) {
788
+ const entry = ResourceEntry(stack, schema);
789
+ if (entry) return entry.base;
790
+ return IsId(schema) && stack.pendingResource ? NextUri(schema.$id, stack.resourceBase).href : stack.resourceBase;
791
+ }
792
+ function NextUseResourceBaseForReference(stack, schema) {
793
+ return IsId(schema) ? !IsRelativeId(schema) : stack.useResourceBaseForReference;
794
+ }
795
+ function NextReferenceBase(stack, schema) {
796
+ const isRetrieved = NextEnteredResource(stack, schema);
797
+ const useResourceBaseForReference = NextUseResourceBaseForReference(stack, schema);
798
+ return isRetrieved || useResourceBaseForReference ? NextResourceBase(stack, schema) : NextLexicalBase(stack, schema);
799
+ }
800
+ function NextLexicalSchema(stack, schema) {
801
+ const entry = ResourceEntry(stack, schema);
802
+ if (entry) return entry.root;
803
+ return IsId(schema) ? schema : stack.lexicalSchema;
804
+ }
805
+ function HasStackKeywords(stack, schema) {
806
+ return IsSchemaObject$1(schema) && (IsId(schema) || IsDynamicAnchor(schema) || IsUndefined$1(stack.recursiveAnchor) && IsRecursiveAnchorTrue(schema) || !IsUndefined$1(ResourceEntry(stack, schema)));
807
+ }
808
+ function NextStack(stack, schema) {
809
+ return HasStackKeywords(stack, schema) ? {
810
+ ...stack,
811
+ ids: NextIds(stack, schema),
812
+ dynamicAnchors: NextDynamicAnchors(stack, schema),
813
+ recursiveAnchor: NextRecursiveAnchor(stack, schema),
814
+ pendingResource: NextPendingResource(stack, schema),
815
+ lexicalBase: NextLexicalBase(stack, schema),
816
+ resourceBase: NextResourceBase(stack, schema),
817
+ useResourceBaseForReference: NextUseResourceBaseForReference(stack, schema),
818
+ referenceBase: NextReferenceBase(stack, schema),
819
+ lexicalSchema: NextLexicalSchema(stack, schema),
820
+ enteredResource: NextEnteredResource(stack, schema)
821
+ } : stack;
822
+ }
823
+ // ../../node_modules/.pnpm/typebox@1.4.3/node_modules/typebox/build/schema/engine/_unique.mjs
824
+ let index$1 = 0;
825
+ /** Creates a unique variable name */
826
+ function CreateUnique() {
827
+ return `unique_${index$1++}`;
828
+ }
829
+ /** Resets the unique variable name counter */
830
+ function ResetUnique() {
831
+ index$1 = 0;
832
+ }
833
+ // ../../node_modules/.pnpm/typebox@1.4.3/node_modules/typebox/build/schema/engine/additionalItems.mjs
834
+ function IsValid$4(schema) {
835
+ return IsItems(schema) && IsArray$1(schema.items);
836
+ }
837
+ function BuildAdditionalItemsStandard(stack, context, schema, value) {
838
+ const [item, index] = [CreateUnique(), CreateUnique()];
839
+ const isSchema = BuildSchemaPushStack(stack, context, schema.additionalItems, item);
840
+ const isLength = IsLessThan(index, Constant(schema.items.length));
841
+ const addIndex = context.AddIndex(index);
842
+ return Every(value, Constant(0), [item, index], Or(isLength, And(isSchema, addIndex)));
843
+ }
844
+ function BuildAdditionalItemsFast(stack, context, schema, value) {
845
+ const [item, index] = [CreateUnique(), CreateUnique()];
846
+ const isSchema = BuildSchemaPushStack(stack, context, schema.additionalItems, item);
847
+ const isLength = IsLessThan(index, Constant(schema.items.length));
848
+ return Every(value, Constant(0), [item, index], Or(isLength, isSchema));
849
+ }
850
+ function BuildAdditionalItems(stack, context, schema, value) {
851
+ if (!IsValid$4(schema)) return Constant(true);
852
+ return context.UseUnevaluated() ? BuildAdditionalItemsStandard(stack, context, schema, value) : BuildAdditionalItemsFast(stack, context, schema, value);
853
+ }
854
+ function CheckAdditionalItems(stack, context, schema, value) {
855
+ if (!IsValid$4(schema)) return true;
856
+ return Every$1(value, 0, (item, index) => {
857
+ return IsLessThan$1(index, schema.items.length) || CheckSchemaPushStack(stack, context, schema.additionalItems, item) && context.AddIndex(index);
858
+ });
859
+ }
860
+ function ErrorAdditionalItems(stack, context, schemaPath, instancePath, schema, value) {
861
+ if (!IsValid$4(schema)) return true;
862
+ return Every$1(value, 0, (item, index) => {
863
+ const nextSchemaPath = `${schemaPath}/additionalItems`;
864
+ const nextInstancePath = `${instancePath}/${index}`;
865
+ return IsLessThan$1(index, schema.items.length) || ErrorSchemaPushStack(stack, context, nextSchemaPath, nextInstancePath, schema.additionalItems, item) && context.AddIndex(index);
866
+ });
867
+ }
868
+ // ../../node_modules/.pnpm/typebox@1.4.3/node_modules/typebox/build/schema/engine/_pathing.mjs
869
+ function EncodeFragment(fragment) {
870
+ return fragment.replace(/~/g, "~0").replace(/\//g, "~1");
871
+ }
872
+ // ../../node_modules/.pnpm/typebox@1.4.3/node_modules/typebox/build/schema/engine/_regexp.mjs
873
+ /** Standard RegExp with Unicode */
874
+ function UnicodeRegExp(pattern) {
875
+ return new RegExp(pattern, "u");
876
+ }
877
+ // ../../node_modules/.pnpm/typebox@1.4.3/node_modules/typebox/build/schema/engine/additionalProperties.mjs
878
+ function IsAdditionalPropertiesIgnored(context, additionalProperties) {
879
+ return !context.UseUnevaluated() && (IsEqual$1(additionalProperties, true) || IsObject$1(additionalProperties) && IsEqual$1(Keys$1(additionalProperties).length, 0));
880
+ }
881
+ function GetPropertyKeyAsPattern(key) {
882
+ return `^${key.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")}$`;
883
+ }
884
+ function GetPropertiesPattern(schema) {
885
+ const patterns = [];
886
+ if (IsPatternProperties(schema)) patterns.push(...Keys$1(schema.patternProperties));
887
+ if (IsProperties(schema)) patterns.push(...Keys$1(schema.properties).map(GetPropertyKeyAsPattern));
888
+ return IsEqual$1(patterns.length, 0) ? "(?!)" : `(${patterns.join("|")})`;
889
+ }
890
+ function HasExactRequiredProperties(schema) {
891
+ const keys = Keys$1(schema.properties);
892
+ return IsEqual$1(keys.length, schema.required.length) && Every$1(keys, 0, (key) => schema.required.includes(key));
893
+ }
894
+ function CanAdditionalPropertiesFast(_context, schema, _value) {
895
+ return IsRequired(schema) && IsProperties(schema) && !IsPatternProperties(schema) && IsEqual$1(schema.additionalProperties, false) && HasExactRequiredProperties(schema);
896
+ }
897
+ function BuildAdditionalPropertiesFast(_context, schema, value) {
898
+ return IsEqual(Member(Call(Member("Object", "getOwnPropertyNames"), [value]), "length"), Constant(schema.required.length));
899
+ }
900
+ function BuildAdditionalPropertiesStandard(stack, context, schema, value) {
901
+ const [key, _index] = [CreateUnique(), CreateUnique()];
902
+ const regexp = CreateVariable(UnicodeRegExp(GetPropertiesPattern(schema)));
903
+ const isSchema = BuildSchemaPushStack(stack, context, schema.additionalProperties, `${value}[${key}]`);
904
+ const isKey = Call(Member(regexp, "test"), [key]);
905
+ const addKey = context.AddKey(key);
906
+ const guarded = context.UseUnevaluated() ? Or(isKey, And(isSchema, addKey)) : Or(isKey, isSchema);
907
+ return Every(Keys(value), Constant(0), [key, _index], guarded);
908
+ }
909
+ function BuildAdditionalProperties(stack, context, schema, value) {
910
+ if (IsAdditionalPropertiesIgnored(context, schema.additionalProperties)) return Constant(true);
911
+ return CanAdditionalPropertiesFast(context, schema, value) ? BuildAdditionalPropertiesFast(context, schema, value) : BuildAdditionalPropertiesStandard(stack, context, schema, value);
912
+ }
913
+ function CheckAdditionalProperties(stack, context, schema, value) {
914
+ const regexp = UnicodeRegExp(GetPropertiesPattern(schema));
915
+ return Every$1(Keys$1(value), 0, (key, _index) => {
916
+ return regexp.test(key) || CheckSchemaPushStack(stack, context, schema.additionalProperties, value[key]) && context.AddKey(key);
917
+ });
918
+ }
919
+ function ErrorAdditionalProperties(stack, context, schemaPath, instancePath, schema, value) {
920
+ const regexp = UnicodeRegExp(GetPropertiesPattern(schema));
921
+ const additionalProperties = [];
922
+ return EveryAll(Keys$1(value), 0, (key, _index) => {
923
+ const nextSchemaPath = `${schemaPath}/additionalProperties`;
924
+ const nextInstancePath = `${instancePath}/${EncodeFragment(key)}`;
925
+ const isAdditionalProperty = regexp.test(key) || ErrorSchemaPushStack(stack, context, nextSchemaPath, nextInstancePath, schema.additionalProperties, value[key]) && context.AddKey(key);
926
+ if (!isAdditionalProperty) additionalProperties.push(key);
927
+ return isAdditionalProperty;
928
+ }) || context.AddError("additionalProperties", schemaPath, instancePath, { additionalProperties });
929
+ }
930
+ // ../../node_modules/.pnpm/typebox@1.4.3/node_modules/typebox/build/schema/engine/_reducer.mjs
931
+ function Reducer(stack, context, schemas, value, check) {
932
+ const results = ConstDeclaration("results", "[]");
933
+ const context_n = schemas.map((_schema, index) => ConstDeclaration(`context_${index}`, New("CheckContext", [])));
934
+ const condition_n = schemas.map((schema, index) => ConstDeclaration(`condition_${index}`, Call(ArrowFunction(["context"], BuildSchema(stack, context, schema, value)), [`context_${index}`])));
935
+ const checks = schemas.map((_schema, index) => If(`condition_${index}`, Call(Member("results", "push"), [`context_${index}`])));
936
+ const returns = Return(And(check, context.Merge("results")));
937
+ return Call(ArrowFunction([], Statements([
938
+ results,
939
+ ...context_n,
940
+ ...condition_n,
941
+ ...checks,
942
+ returns
943
+ ])), []);
944
+ }
945
+ // ../../node_modules/.pnpm/typebox@1.4.3/node_modules/typebox/build/schema/engine/allOf.mjs
946
+ function BuildAllOfStandard(stack, context, schema, value) {
947
+ return Reducer(stack, context, schema.allOf, value, IsEqual(Member("results", "length"), Constant(schema.allOf.length)));
948
+ }
949
+ function BuildAllOfFast(stack, context, schema, value) {
950
+ return ReduceAnd(schema.allOf.map((schema) => BuildSchema(stack, context, schema, value)));
951
+ }
952
+ function BuildAllOf(stack, context, schema, value) {
953
+ return context.UseUnevaluated() ? BuildAllOfStandard(stack, context, schema, value) : BuildAllOfFast(stack, context, schema, value);
954
+ }
955
+ function CheckAllOf(stack, context, schema, value) {
956
+ const results = schema.allOf.reduce((result, schema) => {
957
+ const nextContext = new CheckContext();
958
+ return CheckSchema(stack, nextContext, schema, value) ? [...result, nextContext] : result;
959
+ }, []);
960
+ return IsEqual$1(results.length, schema.allOf.length) && context.Merge(results);
961
+ }
962
+ function ErrorAllOf(stack, context, schemaPath, instancePath, schema, value) {
963
+ const failedContexts = [];
964
+ const results = schema.allOf.reduce((result, schema, index) => {
965
+ const nextSchemaPath = `${schemaPath}/allOf/${index}`;
966
+ const nextContext = new ErrorContext();
967
+ const isSchema = ErrorSchema(stack, nextContext, nextSchemaPath, instancePath, schema, value);
968
+ if (!isSchema) failedContexts.push(nextContext);
969
+ return isSchema ? [...result, nextContext] : result;
970
+ }, []);
971
+ const isAllOf = IsEqual$1(results.length, schema.allOf.length) && context.Merge(results);
972
+ if (!isAllOf) failedContexts.forEach((failed) => context.AddErrors(failed.GetErrors()));
973
+ return isAllOf;
974
+ }
975
+ // ../../node_modules/.pnpm/typebox@1.4.3/node_modules/typebox/build/schema/engine/anyOf.mjs
976
+ function BuildAnyOfStandard(stack, context, schema, value) {
977
+ return Reducer(stack, context, schema.anyOf, value, IsGreaterThan(Member("results", "length"), Constant(0)));
978
+ }
979
+ function BuildAnyOfFast(stack, context, schema, value) {
980
+ return ReduceOr(schema.anyOf.map((schema) => BuildSchema(stack, context, schema, value)));
981
+ }
982
+ function BuildAnyOf(stack, context, schema, value) {
983
+ return context.UseUnevaluated() ? BuildAnyOfStandard(stack, context, schema, value) : BuildAnyOfFast(stack, context, schema, value);
984
+ }
985
+ function CheckAnyOf(stack, context, schema, value) {
986
+ const results = schema.anyOf.reduce((result, schema) => {
987
+ const nextContext = new CheckContext();
988
+ return CheckSchema(stack, nextContext, schema, value) ? [...result, nextContext] : result;
989
+ }, []);
990
+ return IsGreaterThan$1(results.length, 0) && context.Merge(results);
991
+ }
992
+ function ErrorAnyOf(stack, context, schemaPath, instancePath, schema, value) {
993
+ const failedContexts = [];
994
+ const results = schema.anyOf.reduce((result, schema, index) => {
995
+ const nextContext = new ErrorContext();
996
+ const isSchema = ErrorSchema(stack, nextContext, `${schemaPath}/anyOf/${index}`, instancePath, schema, value);
997
+ if (!isSchema) failedContexts.push(nextContext);
998
+ return isSchema ? [...result, nextContext] : result;
999
+ }, []);
1000
+ const isAnyOf = IsGreaterThan$1(results.length, 0) && context.Merge(results);
1001
+ if (!isAnyOf) failedContexts.forEach((failed) => context.AddErrors(failed.GetErrors()));
1002
+ return isAnyOf || context.AddError("anyOf", schemaPath, instancePath, {});
1003
+ }
1004
+ // ../../node_modules/.pnpm/typebox@1.4.3/node_modules/typebox/build/schema/engine/boolean.mjs
1005
+ function BuildSchemaBoolean(_stack, _context, schema, _value) {
1006
+ return schema ? Constant(true) : Constant(false);
1007
+ }
1008
+ function CheckSchemaBoolean(_stack, _context, schema, _value) {
1009
+ return schema;
1010
+ }
1011
+ function ErrorSchemaBoolean(stack, context, schemaPath, instancePath, schema, value) {
1012
+ return CheckSchemaBoolean(stack, context, schema, value) || context.AddError("boolean", schemaPath, instancePath, {});
1013
+ }
1014
+ // ../../node_modules/.pnpm/typebox@1.4.3/node_modules/typebox/build/schema/engine/const.mjs
1015
+ function BuildConst(_stack, _context, schema, value) {
1016
+ return IsValueLike(schema.const) ? IsEqual(value, Constant(schema.const)) : IsDeepEqual(value, CreateVariable(schema.const));
1017
+ }
1018
+ function CheckConst(_stack, _context, schema, value) {
1019
+ return IsValueLike(schema.const) ? IsEqual$1(value, schema.const) : IsDeepEqual$1(value, schema.const);
1020
+ }
1021
+ function ErrorConst(stack, context, schemaPath, instancePath, schema, value) {
1022
+ return CheckConst(stack, context, schema, value) || context.AddError("const", schemaPath, instancePath, { allowedValue: schema.const });
1023
+ }
1024
+ // ../../node_modules/.pnpm/typebox@1.4.3/node_modules/typebox/build/schema/engine/contains.mjs
1025
+ function IsValid$3(schema) {
1026
+ return !(IsMinContains(schema) && IsEqual$1(schema.minContains, 0));
1027
+ }
1028
+ function BuildContainsStandard(stack, context, schema, value) {
1029
+ const [item, index] = [CreateUnique(), CreateUnique()];
1030
+ return And(Not(IsEqual(Member(value, "length"), Constant(0))), SomeAll(value, [item, index], And(BuildSchema(stack, context, schema.contains, item), context.AddIndex(index))));
1031
+ }
1032
+ function BuildContainsFast(stack, context, schema, value) {
1033
+ const [item] = [CreateUnique()];
1034
+ return And(Not(IsEqual(Member(value, "length"), Constant(0))), Some(value, [item, "_"], BuildSchema(stack, context, schema.contains, item)));
1035
+ }
1036
+ function BuildContains(stack, context, schema, value) {
1037
+ if (!IsValid$3(schema)) return Constant(true);
1038
+ return context.UseUnevaluated() ? BuildContainsStandard(stack, context, schema, value) : BuildContainsFast(stack, context, schema, value);
1039
+ }
1040
+ function CheckContains(stack, context, schema, value) {
1041
+ if (!IsValid$3(schema)) return true;
1042
+ return !IsEqual$1(value.length, 0) && SomeAll$1(value, (item, index) => {
1043
+ return CheckSchema(stack, context, schema.contains, item) && context.AddIndex(index);
1044
+ });
1045
+ }
1046
+ function ErrorContains(stack, context, schemaPath, instancePath, schema, value) {
1047
+ return CheckContains(stack, context, schema, value) || context.AddError("contains", schemaPath, instancePath, { minContains: 1 });
1048
+ }
1049
+ // ../../node_modules/.pnpm/typebox@1.4.3/node_modules/typebox/build/schema/engine/dependencies.mjs
1050
+ function BuildDependencies(stack, context, schema, value) {
1051
+ return Or(IsEqual(Member(Keys(value), "length"), Constant(0)), ReduceAnd(Entries$1(schema.dependencies).map(([key, schema]) => {
1052
+ const notKey = Not(HasPropertyKey(value, Constant(key)));
1053
+ const isSchema = BuildSchema(stack, context, schema, value);
1054
+ const isEveryKey = (schema) => ReduceAnd(schema.map((key) => HasPropertyKey(value, Constant(key))));
1055
+ return Or(notKey, IsArray$1(schema) ? isEveryKey(schema) : isSchema);
1056
+ })));
1057
+ }
1058
+ function CheckDependencies(stack, context, schema, value) {
1059
+ const isLength = IsEqual$1(Keys$1(value).length, 0);
1060
+ const isEvery = Every$1(Entries$1(schema.dependencies), 0, ([key, schema]) => {
1061
+ return !HasPropertyKey$1(value, key) || (IsArray$1(schema) ? schema.every((key) => HasPropertyKey$1(value, key)) : CheckSchema(stack, context, schema, value));
1062
+ });
1063
+ return isLength || isEvery;
1064
+ }
1065
+ function ErrorDependencies(stack, context, schemaPath, instancePath, schema, value) {
1066
+ const isLength = IsEqual$1(Keys$1(value).length, 0);
1067
+ const isEvery = EveryAll(Entries$1(schema.dependencies), 0, ([key, schema]) => {
1068
+ const nextSchemaPath = `${schemaPath}/dependencies/${EncodeFragment(key)}`;
1069
+ return !HasPropertyKey$1(value, key) || (IsArray$1(schema) ? schema.every((dependency) => HasPropertyKey$1(value, dependency) || context.AddError("dependencies", schemaPath, instancePath, {
1070
+ property: key,
1071
+ dependencies: schema
1072
+ })) : ErrorSchema(stack, context, nextSchemaPath, instancePath, schema, value));
1073
+ });
1074
+ return isLength || isEvery;
1075
+ }
1076
+ // ../../node_modules/.pnpm/typebox@1.4.3/node_modules/typebox/build/schema/engine/dependentRequired.mjs
1077
+ function BuildDependentRequired(_stack, _context, schema, value) {
1078
+ return Or(IsEqual(Member(Keys(value), "length"), Constant(0)), ReduceAnd(Entries$1(schema.dependentRequired).map(([key, keys]) => {
1079
+ return Or(Not(HasPropertyKey(value, Constant(key))), ReduceAnd(keys.map((key) => HasPropertyKey(value, Constant(key)))));
1080
+ })));
1081
+ }
1082
+ function CheckDependentRequired(_stack, _context, schema, value) {
1083
+ const isLength = IsEqual$1(Keys$1(value).length, 0);
1084
+ const isEvery = Every$1(Entries$1(schema.dependentRequired), 0, ([key, keys]) => {
1085
+ return !HasPropertyKey$1(value, key) || keys.every((key) => HasPropertyKey$1(value, key));
1086
+ });
1087
+ return isLength || isEvery;
1088
+ }
1089
+ function ErrorDependentRequired(_stack, context, schemaPath, instancePath, schema, value) {
1090
+ const isLength = IsEqual$1(Keys$1(value).length, 0);
1091
+ const isEveryEntry = EveryAll(Entries$1(schema.dependentRequired), 0, ([key, keys]) => {
1092
+ return !HasPropertyKey$1(value, key) || EveryAll(keys, 0, (dependency) => HasPropertyKey$1(value, dependency) || context.AddError("dependentRequired", schemaPath, instancePath, {
1093
+ property: key,
1094
+ dependencies: keys
1095
+ }));
1096
+ });
1097
+ return isLength || isEveryEntry;
1098
+ }
1099
+ // ../../node_modules/.pnpm/typebox@1.4.3/node_modules/typebox/build/schema/engine/dependentSchemas.mjs
1100
+ function BuildDependentSchemas(stack, context, schema, value) {
1101
+ return Or(IsEqual(Member(Keys(value), "length"), Constant(0)), ReduceAnd(Entries$1(schema.dependentSchemas).map(([key, schema]) => {
1102
+ return Or(Not(HasPropertyKey(value, Constant(key))), BuildSchema(stack, context, schema, value));
1103
+ })));
1104
+ }
1105
+ function CheckDependentSchemas(stack, context, schema, value) {
1106
+ const isLength = IsEqual$1(Keys$1(value).length, 0);
1107
+ const isEvery = Every$1(Entries$1(schema.dependentSchemas), 0, ([key, schema]) => {
1108
+ return !HasPropertyKey$1(value, key) || CheckSchema(stack, context, schema, value);
1109
+ });
1110
+ return isLength || isEvery;
1111
+ }
1112
+ function ErrorDependentSchemas(stack, context, schemaPath, instancePath, schema, value) {
1113
+ const isLength = IsEqual$1(Keys$1(value).length, 0);
1114
+ const isEvery = EveryAll(Entries$1(schema.dependentSchemas), 0, ([key, schema]) => {
1115
+ const nextSchemaPath = `${schemaPath}/dependentSchemas/${EncodeFragment(key)}`;
1116
+ return !HasPropertyKey$1(value, key) || ErrorSchema(stack, context, nextSchemaPath, instancePath, schema, value);
1117
+ });
1118
+ return isLength || isEvery;
1119
+ }
1120
+ // ../../node_modules/.pnpm/typebox@1.4.3/node_modules/typebox/build/schema/pointer/pointer.mjs
1121
+ function Indices(pointer) {
1122
+ const indices = pointer.split("/").map((index) => index.replace(/~1/g, "/").replace(/~0/g, "~"));
1123
+ return indices[0] === "" ? indices.slice(1) : indices;
1124
+ }
1125
+ function Get$2(value, pointer) {
1126
+ let current = value;
1127
+ for (const index of Indices(pointer)) {
1128
+ if (!IsObject$1(current) || IsUnsafePropertyKey(index)) return void 0;
1129
+ current = current[index];
1130
+ }
1131
+ return current;
1132
+ }
1133
+ // ../../node_modules/.pnpm/typebox@1.4.3/node_modules/typebox/build/schema/resolve/resolve.mjs
1134
+ function RelativeBase(schema, base) {
1135
+ return IsSchemaObject$1(schema) && IsId(schema) ? NextUri(schema.$id, base.href) : base;
1136
+ }
1137
+ function AbsoluteBase(base) {
1138
+ return NextUri(base, DefaultUri);
1139
+ }
1140
+ function CanonicalHref(url) {
1141
+ return url.href.split("#")[0];
1142
+ }
1143
+ function Base(schema, base, target) {
1144
+ return SearchBase(schema, AbsoluteBase(base), target);
1145
+ }
1146
+ function RefRoot(stack, ref) {
1147
+ return ref.$ref.startsWith("#") || stack.enteredResource ? stack.lexicalSchema : stack.schema;
1148
+ }
1149
+ function IsPointerFragment(fragment) {
1150
+ return fragment.startsWith("#/");
1151
+ }
1152
+ function SearchDynamicAnchor(schema, name) {
1153
+ if (IsObject$1(schema) && IsDynamicAnchor(schema) && IsEqual$1(schema.$dynamicAnchor, name)) return schema;
1154
+ if (IsObject$1(schema)) for (const key of Keys$1(schema)) {
1155
+ const result = SearchDynamicAnchor(schema[key], name);
1156
+ if (result) return result;
1157
+ }
1158
+ }
1159
+ function SearchBase(schema, base, target) {
1160
+ if (IsEqual$1(schema, target)) return base.href;
1161
+ const nextBase = RelativeBase(schema, base);
1162
+ if (IsArray$1(schema)) for (const item of schema) {
1163
+ const result = SearchBase(item, nextBase, target);
1164
+ if (!IsUndefined$1(result)) return result;
1165
+ }
1166
+ else if (IsObject$1(schema)) for (const key of Keys$1(schema)) {
1167
+ const result = SearchBase(schema[key], nextBase, target);
1168
+ if (!IsUndefined$1(result)) return result;
1169
+ }
1170
+ }
1171
+ function MatchWithHash(schema, ref) {
1172
+ if (ref.href.endsWith("#")) return schema;
1173
+ if (!ref.hash.startsWith("#")) return void 0;
1174
+ const fragment = decodeURIComponent(ref.hash.slice(1));
1175
+ if (!fragment.startsWith("/")) return void 0;
1176
+ return Get$2(schema, fragment);
1177
+ }
1178
+ function MatchWithId(schema, base, ref) {
1179
+ if (!IsId(schema)) return void 0;
1180
+ if (IsEqual$1(schema.$id, ref.hash)) return schema;
1181
+ const absoluteRef = new URL(ref.href, base.href);
1182
+ if (IsEqual$1(base.pathname, absoluteRef.pathname)) return ref.hash.startsWith("#") ? MatchWithHash(schema, ref) : schema;
1183
+ }
1184
+ function MatchWithAnchor(schema, base, ref) {
1185
+ if (!IsAnchor(schema)) return void 0;
1186
+ const absoluteAnchor = new URL(`#${schema.$anchor}`, base.href);
1187
+ const absoluteRef = new URL(ref.href, base.href);
1188
+ return IsEqual$1(absoluteAnchor.href, absoluteRef.href) ? schema : void 0;
1189
+ }
1190
+ function MatchWithDynamicAnchor(schema, base, ref) {
1191
+ if (!IsDynamicAnchor(schema)) return void 0;
1192
+ const absoluteAnchor = new URL(`#${schema.$dynamicAnchor}`, base.href);
1193
+ const absoluteRef = new URL(ref.href, base.href);
1194
+ return IsEqual$1(absoluteAnchor.href, absoluteRef.href) ? schema : void 0;
1195
+ }
1196
+ function MatchSchemaObject(schema, base, ref) {
1197
+ if (!IsSchemaObject$1(schema)) return void 0;
1198
+ return MatchWithId(schema, base, ref) ?? MatchWithAnchor(schema, base, ref) ?? MatchWithDynamicAnchor(schema, base, ref) ?? MatchWithHash(schema, ref);
1199
+ }
1200
+ function MatchFromArray(schema, base, ref) {
1201
+ if (!IsArray$1(schema)) return void 0;
1202
+ return schema.reduce((result, item) => {
1203
+ const match = Match(item, base, ref);
1204
+ return !IsUndefined$1(match) ? match : result;
1205
+ }, void 0);
1206
+ }
1207
+ function MatchFromObject(schema, base, ref) {
1208
+ if (!IsObject$1(schema)) return void 0;
1209
+ return Keys$1(schema).reduce((result, key) => {
1210
+ if (IsEqual$1(key, "const") || IsEqual$1(key, "enum")) return result;
1211
+ const match = Match(schema[key], base, ref);
1212
+ return !IsUndefined$1(match) ? match : result;
1213
+ }, void 0);
1214
+ }
1215
+ function Match(schema, base, ref) {
1216
+ const relativeBase = RelativeBase(schema, base);
1217
+ return MatchSchemaObject(schema, relativeBase, ref) ?? MatchFromArray(schema, relativeBase, ref) ?? MatchFromObject(schema, relativeBase, ref);
1218
+ }
1219
+ function Resource(context, schema, base, ref) {
1220
+ const result = RefInternal(context, schema, base, ref);
1221
+ return IsSchemaObject$1(result) && IsId(result) ? result : void 0;
1222
+ }
1223
+ function FindDeferredResourceLegacy(stack, ref, schema) {
1224
+ if (!ref.$ref.startsWith("#")) return void 0;
1225
+ if (!IsSchemaObject$1(stack.schema) || HasPropertyKey$1(stack.schema, "$schema")) return void 0;
1226
+ const targetBase = Base(stack.lexicalSchema, stack.referenceBase, schema);
1227
+ if (IsUndefined$1(targetBase) || IsEqual$1(targetBase, stack.referenceBase)) return void 0;
1228
+ return {
1229
+ target: schema,
1230
+ base: targetBase,
1231
+ root: stack.lexicalSchema
1232
+ };
1233
+ }
1234
+ function FindDeferredResourceModern(stack, canonical, schema) {
1235
+ const remoteRoot = stack.context[canonical];
1236
+ if (!IsSchemaObject$1(remoteRoot)) return void 0;
1237
+ return {
1238
+ target: schema,
1239
+ base: canonical,
1240
+ root: remoteRoot
1241
+ };
1242
+ }
1243
+ function FindDeferredResource(stack, ref, schema, canonical, isRemote) {
1244
+ const remote = isRemote ? FindDeferredResourceModern(stack, canonical, schema) : void 0;
1245
+ return IsUndefined$1(remote) ? FindDeferredResourceLegacy(stack, ref, schema) : remote;
1246
+ }
1247
+ function FindResolvedResource(stack, canonical, schema) {
1248
+ if (IsId(schema)) return void 0;
1249
+ const resource = Resource(stack.context, stack.schema, stack.referenceBase, canonical);
1250
+ if (!resource || stack.ids.includes(resource)) return void 0;
1251
+ return { resource };
1252
+ }
1253
+ function RefInternalWithContext(context, ref) {
1254
+ return HasPropertyKey$1(context, ref) ? context[ref] : void 0;
1255
+ }
1256
+ function RefInternalWithLocal(schema, base, ref) {
1257
+ return Match(schema, base, ref);
1258
+ }
1259
+ function RefInternalWithRemote(context, base, ref) {
1260
+ const canonicalHref = CanonicalHref(ref);
1261
+ if (!HasPropertyKey$1(context, canonicalHref) || IsEqual$1(canonicalHref, CanonicalHref(base))) return void 0;
1262
+ const remoteSchema = context[canonicalHref];
1263
+ const remoteBase = RelativeBase(remoteSchema, new URL(canonicalHref));
1264
+ return IsEqual$1(ref.hash, "") ? remoteSchema : Match(remoteSchema, remoteBase, ref);
1265
+ }
1266
+ function RefInternal(context, schema, base, ref) {
1267
+ const absoluteBase = AbsoluteBase(base);
1268
+ const target = NextUri(ref, absoluteBase.href);
1269
+ return RefInternalWithContext(context, ref) ?? RefInternalWithLocal(schema, absoluteBase, target) ?? RefInternalWithRemote(context, absoluteBase, target);
1270
+ }
1271
+ function RefNextStackDeferred(stack, deferredResource) {
1272
+ if (!deferredResource) return stack;
1273
+ const resourceEntries = new Map(stack.resourceEntries);
1274
+ resourceEntries.set(deferredResource.target, {
1275
+ base: deferredResource.base,
1276
+ root: deferredResource.root
1277
+ });
1278
+ return {
1279
+ ...stack,
1280
+ resourceEntries
1281
+ };
1282
+ }
1283
+ function RefNextStackResolved(stack, resolvedResource) {
1284
+ return resolvedResource ? NextStack(stack, resolvedResource.resource) : stack;
1285
+ }
1286
+ function RefNextStack(stack, pendingResource, deferredResource, resolvedResource) {
1287
+ return RefNextStackResolved(RefNextStackDeferred({
1288
+ ...stack,
1289
+ pendingResource
1290
+ }, deferredResource), resolvedResource);
1291
+ }
1292
+ function RefResultFound(stack, ref, schema) {
1293
+ const canonical = CanonicalHref(NextUri(ref.$ref, stack.referenceBase));
1294
+ const isRemote = !IsEqual$1(canonical, stack.resourceBase);
1295
+ return {
1296
+ schema,
1297
+ stack: RefNextStack(stack, true, FindDeferredResource(stack, ref, schema, canonical, isRemote), isRemote ? FindResolvedResource(stack, canonical, schema) : void 0)
1298
+ };
1299
+ }
1300
+ function RefResultNotFound(stack, schema) {
1301
+ return {
1302
+ schema,
1303
+ stack: RefNextStack(stack, !IsUndefined$1(schema))
1304
+ };
1305
+ }
1306
+ function Ref(stack, ref) {
1307
+ const schema = RefInternal(stack.context, RefRoot(stack, ref), stack.referenceBase, ref.$ref);
1308
+ return IsSchemaObject$1(schema) ? RefResultFound(stack, ref, schema) : RefResultNotFound(stack, schema);
1309
+ }
1310
+ function IsRecursiveAnchorInScope(stack) {
1311
+ return IsSchemaObject$1(stack.lexicalSchema) && IsRecursiveAnchorTrue(stack.lexicalSchema);
1312
+ }
1313
+ function RecursiveRef(stack, recursiveRef) {
1314
+ const schema = IsRecursiveAnchorInScope(stack) ? stack.recursiveAnchor : stack.lexicalSchema;
1315
+ return RefInternal(stack.context, schema, stack.lexicalBase, recursiveRef.$recursiveRef);
1316
+ }
1317
+ function DynamicRefFragment(stack, dynamicRef) {
1318
+ return NextUri(dynamicRef.$dynamicRef, AbsoluteBase(stack.lexicalBase).href).hash;
1319
+ }
1320
+ function FindScopedDynamicAnchor(stack, name) {
1321
+ return stack.dynamicAnchors.find((anchor) => IsEqual$1(anchor.$dynamicAnchor, name)) ?? SearchDynamicAnchor(stack.schema, name);
1322
+ }
1323
+ function DynamicRefWhenFound(stack, dynamicRef, fragmentTarget) {
1324
+ if (!IsSchemaObject$1(fragmentTarget) || !IsDynamicAnchor(fragmentTarget)) return fragmentTarget;
1325
+ return IsPointerFragment(DynamicRefFragment(stack, dynamicRef)) ? fragmentTarget : FindScopedDynamicAnchor(stack, fragmentTarget.$dynamicAnchor);
1326
+ }
1327
+ function DynamicRefWhenNotFound(stack, dynamicRef) {
1328
+ const fragment = DynamicRefFragment(stack, dynamicRef);
1329
+ return FindScopedDynamicAnchor(stack, decodeURIComponent(fragment.slice(1)));
1330
+ }
1331
+ function DynamicRef(stack, dynamicRef) {
1332
+ const fragmentRoot = dynamicRef.$dynamicRef.startsWith("#") ? stack.lexicalSchema : stack.schema;
1333
+ const fragmentTarget = RefInternal(stack.context, fragmentRoot, stack.lexicalBase, dynamicRef.$dynamicRef);
1334
+ return IsUndefined$1(fragmentTarget) ? DynamicRefWhenNotFound(stack, dynamicRef) : DynamicRefWhenFound(stack, dynamicRef, fragmentTarget);
1335
+ }
1336
+ // ../../node_modules/.pnpm/typebox@1.4.3/node_modules/typebox/build/schema/engine/dynamicRef.mjs
1337
+ function BuildDynamicRef(stack, context, schema, value) {
1338
+ const target = DynamicRef(stack, schema) ?? false;
1339
+ return CreateFunction(target ? {
1340
+ ...stack,
1341
+ pendingResource: true
1342
+ } : stack, context, target, value);
1343
+ }
1344
+ function CheckDynamicRef(stack, context, schema, value) {
1345
+ const target = DynamicRef(stack, schema) ?? false;
1346
+ const nextStack = target ? {
1347
+ ...stack,
1348
+ pendingResource: true
1349
+ } : stack;
1350
+ return IsSchema(target) && CheckSchema(nextStack, context, target, value);
1351
+ }
1352
+ function ErrorDynamicRef(stack, context, schemaPath, instancePath, schema, value) {
1353
+ const target = DynamicRef(stack, schema) ?? false;
1354
+ const nextStack = target ? {
1355
+ ...stack,
1356
+ pendingResource: true
1357
+ } : stack;
1358
+ return IsSchema(target) && ErrorSchema(nextStack, context, schemaPath, instancePath, target, value);
1359
+ }
1360
+ // ../../node_modules/.pnpm/typebox@1.4.3/node_modules/typebox/build/schema/engine/enum.mjs
1361
+ function BuildEnum(_stack, _context, schema, value) {
1362
+ return ReduceOr(schema.enum.map((option) => {
1363
+ if (IsValueLike(option)) return IsEqual(value, Constant(option));
1364
+ return IsDeepEqual(value, CreateVariable(option));
1365
+ }));
1366
+ }
1367
+ function CheckEnum(_stack, _context, schema, value) {
1368
+ return Some$1(schema.enum, (option) => IsValueLike(option) ? IsEqual$1(value, option) : IsDeepEqual$1(value, option));
1369
+ }
1370
+ function ErrorEnum(stack, context, schemaPath, instancePath, schema, value) {
1371
+ return CheckEnum(stack, context, schema, value) || context.AddError("enum", schemaPath, instancePath, { allowedValues: schema.enum });
1372
+ }
1373
+ // ../../node_modules/.pnpm/typebox@1.4.3/node_modules/typebox/build/schema/engine/exclusiveMaximum.mjs
1374
+ function BuildExclusiveMaximum(_stack, _context, schema, value) {
1375
+ return IsLessThan(value, Constant(schema.exclusiveMaximum));
1376
+ }
1377
+ function CheckExclusiveMaximum(_stack, _context, schema, value) {
1378
+ return IsLessThan$1(value, schema.exclusiveMaximum);
1379
+ }
1380
+ function ErrorExclusiveMaximum(stack, context, schemaPath, instancePath, schema, value) {
1381
+ return CheckExclusiveMaximum(stack, context, schema, value) || context.AddError("exclusiveMaximum", schemaPath, instancePath, {
1382
+ comparison: "<",
1383
+ limit: schema.exclusiveMaximum
1384
+ });
1385
+ }
1386
+ // ../../node_modules/.pnpm/typebox@1.4.3/node_modules/typebox/build/schema/engine/exclusiveMinimum.mjs
1387
+ function BuildExclusiveMinimum(_stack, _context, schema, value) {
1388
+ return IsGreaterThan(value, Constant(schema.exclusiveMinimum));
1389
+ }
1390
+ function CheckExclusiveMinimum(_stack, _context, schema, value) {
1391
+ return IsGreaterThan$1(value, schema.exclusiveMinimum);
1392
+ }
1393
+ function ErrorExclusiveMinimum(stack, context, schemaPath, instancePath, schema, value) {
1394
+ return CheckExclusiveMinimum(stack, context, schema, value) || context.AddError("exclusiveMinimum", schemaPath, instancePath, {
1395
+ comparison: ">",
1396
+ limit: schema.exclusiveMinimum
1397
+ });
1398
+ }
1399
+ // ../../node_modules/.pnpm/typebox@1.4.3/node_modules/typebox/build/format/date.mjs
1400
+ const DAYS = [
1401
+ 0,
1402
+ 31,
1403
+ 28,
1404
+ 31,
1405
+ 30,
1406
+ 31,
1407
+ 30,
1408
+ 31,
1409
+ 31,
1410
+ 30,
1411
+ 31,
1412
+ 30,
1413
+ 31
1414
+ ];
1415
+ const DATE = /^(\d\d\d\d)-(\d\d)-(\d\d)$/;
1416
+ function IsLeapYear(year) {
1417
+ return year % 4 === 0 && (year % 100 !== 0 || year % 400 === 0);
1418
+ }
1419
+ /**
1420
+ * Returns true if the value is a ISO8601 Date component string
1421
+ * @description https://datatracker.ietf.org/doc/html/rfc3339
1422
+ * @example `2020-12-12`
1423
+ */
1424
+ function IsDate(value) {
1425
+ const matches = DATE.exec(value);
1426
+ if (!matches) return false;
1427
+ const year = +matches[1];
1428
+ const month = +matches[2];
1429
+ const day = +matches[3];
1430
+ return month >= 1 && month <= 12 && day >= 1 && day <= (month === 2 && IsLeapYear(year) ? 29 : DAYS[month]);
1431
+ }
1432
+ // ../../node_modules/.pnpm/typebox@1.4.3/node_modules/typebox/build/format/time.mjs
1433
+ const TIME = /^(\d\d):(\d\d):(\d\d)(?:\.\d+)?(?:([Zz])|([+-])(\d\d):(\d\d))?$/;
1434
+ /**
1435
+ * Returns true if the value is an ISO time string
1436
+ * @specification https://datatracker.ietf.org/doc/html/rfc3339
1437
+ */
1438
+ function IsTime(value, strictTimeZone = true) {
1439
+ const matches = TIME.exec(value);
1440
+ if (!matches) return false;
1441
+ if (strictTimeZone && !matches[4] && !matches[5]) return false;
1442
+ const hr = +matches[1];
1443
+ const min = +matches[2];
1444
+ const sec = +matches[3];
1445
+ if (hr > 23 || min > 59 || sec > 60) return false;
1446
+ if (matches[5]) {
1447
+ const tzH = +matches[6];
1448
+ const tzM = +matches[7];
1449
+ if (tzH > 23 || tzM > 59) return false;
1450
+ }
1451
+ if (sec < 60) return true;
1452
+ const tzSign = matches[5] === "-" ? -1 : 1;
1453
+ const tzH = +(matches[6] || 0);
1454
+ const tzM = +(matches[7] || 0);
1455
+ return ((hr * 60 + min - tzSign * (tzH * 60 + tzM)) % 1440 + 1440) % 1440 === 1439;
1456
+ }
1457
+ // ../../node_modules/.pnpm/typebox@1.4.3/node_modules/typebox/build/format/date_time.mjs
1458
+ const DATE_TIME_SUFFIX = /^(?:\[!?(?:(?!\.{1,2}[/\]])[A-Za-z._][A-Za-z._0-9+-]{0,13}(?:\/(?!\.{1,2}[/\]])[A-Za-z._][A-Za-z._0-9+-]{0,13})*|[+-](?:[01][0-9]|2[0-3]):[0-5][0-9])\](?:\[!?[a-z_][a-z_0-9-]*=[A-Za-z0-9]+(?:-[A-Za-z0-9]+)*\])*|(?:\[!?[a-z_][a-z_0-9-]*=[A-Za-z0-9]+(?:-[A-Za-z0-9]+)*\])*)$/;
1459
+ /**
1460
+ * Returns true if the string is an [RFC 3339](https://datatracker.ietf.org/doc/html/rfc3339) date-time with optional [RFC 9557](https://datatracker.ietf.org/doc/html/rfc9557) suffix.
1461
+ * @specification https://datatracker.ietf.org/doc/html/rfc3339
1462
+ * @specification https://datatracker.ietf.org/doc/html/rfc9557
1463
+ * @example `2020-12-12T20:20:40+00:00`
1464
+ */
1465
+ function IsDateTime(value) {
1466
+ const index = value.indexOf("[");
1467
+ const datetime = index === -1 ? value : value.slice(0, index);
1468
+ if (index !== -1 && !DATE_TIME_SUFFIX.test(value.slice(index))) return false;
1469
+ const split = datetime.split(/T/i);
1470
+ return split.length === 2 && IsDate(split[0]) && IsTime(split[1]);
1471
+ }
1472
+ // ../../node_modules/.pnpm/typebox@1.4.3/node_modules/typebox/build/format/duration.mjs
1473
+ const Duration = /^P((\d+Y(\d+M(\d+D)?)?|\d+M(\d+D)?|\d+D)(T(\d+H(\d+M(\d+S)?)?|\d+M(\d+S)?|\d+S))?|T(\d+H(\d+M(\d+S)?)?|\d+M(\d+S)?|\d+S)|\d+W)$/;
1474
+ /**
1475
+ * Returns true if the value is a valid duration.
1476
+ * @specification https://www.rfc-editor.org/rfc/rfc3339.html#appendix-A
1477
+ */
1478
+ function IsDuration(value) {
1479
+ return Duration.test(value);
1480
+ }
1481
+ // ../../node_modules/.pnpm/typebox@1.4.3/node_modules/typebox/build/format/email.mjs
1482
+ const Email = /^(?:[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*|"(?:[^"\\]|\\[\x20-\x7e])*")@(?:[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?(?:\.[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?)*|\[(?:IPv6:[a-f0-9:]+|(?:25[0-5]|2[0-4][0-9]|1[0-9]{2}|[1-9]?[0-9])(?:\.(?:25[0-5]|2[0-4][0-9]|1[0-9]{2}|[1-9]?[0-9])){3})\])$/i;
1483
+ /**
1484
+ * Returns true if the value is an Email
1485
+ * @specification https://datatracker.ietf.org/doc/html/rfc5322
1486
+ */
1487
+ function IsEmail(value) {
1488
+ return Email.test(value);
1489
+ }
1490
+ // ../../node_modules/.pnpm/typebox@1.4.3/node_modules/typebox/build/format/idna/pattern/pattern.mjs
1491
+ const RE_RULE_HYPHEN_PLACEMENT = /^(?!-).*(?<!-)$/;
1492
+ const RE_RULE_NOT_RESERVED_ACE = /^(?!..--)/;
1493
+ const RE_ASCII_LDH = /^[a-zA-Z0-9-]*$/;
1494
+ const RE_NON_ASCII = /[^\p{ASCII}]/u;
1495
+ const RE_ASCII_DIGIT = /[0-9]/;
1496
+ const RE_ARABIC_INDIC_DIGIT = /[\u{0660}-\u{0669}]/u;
1497
+ const RE_EXT_ARABIC_INDIC_DIGIT = /[\u{06f0}-\u{06f9}]/u;
1498
+ const RE_COMMON_SEPARATOR = /[\u{002e}\u{002c}\u{003a}\u{002f}]/u;
1499
+ const RE_EUROPEAN_SEPARATOR = /[\u{002d}\u{002b}]/u;
1500
+ const RE_MARK_NONSPACING = /\p{Mn}/u;
1501
+ const RE_MARK_SPACING_COMBINING = /\p{Mc}/u;
1502
+ const RE_COMBINING_MARK = /[\p{Mn}\p{Mc}\p{Me}]/u;
1503
+ const RE_LETTER = /\p{L}/u;
1504
+ const RE_NUMBER_DECIMAL = /\p{Nd}/u;
1505
+ const RE_SCRIPT_GREEK = /\p{Script=Greek}/u;
1506
+ const RE_SCRIPT_HEBREW = /\p{Script=Hebrew}/u;
1507
+ const RE_SCRIPT_JAPANESE = /[\p{Script=Hiragana}\p{Script=Katakana}\p{Script=Han}]/u;
1508
+ const RE_SCRIPT_ARABIC_LETTER = /[\p{Script=Arabic}\p{Script=Syriac}\p{Script=Thaana}\p{Script=Mandaic}]/u;
1509
+ const RE_VIRAMA = /[\u{094d}\u{09cd}\u{0a4d}\u{0acd}\u{0b4d}\u{0bcd}\u{0c4d}\u{0ccd}\u{0d3b}\u{0d3c}\u{0d4d}\u{0dca}\u{1b44}\u{1baa}\u{1bab}\u{a9c0}\u{11046}\u{1107f}\u{110b9}\u{11133}\u{11134}\u{111c0}\u{11235}\u{1134d}\u{11442}\u{114c2}\u{115bf}\u{1163f}\u{116b6}\u{11c3f}\u{11d44}\u{11d45}]/u;
1510
+ const RE_RFC5892_DISALLOWED = /[\u{0640}\u{07fa}\u{302e}\u{302f}\u{3031}\u{3032}\u{3033}\u{3034}\u{3035}\u{303b}]/u;
1511
+ const RE_CONTEXTO_EXCEPTIONS = /[\u{00b7}\u{0375}\u{05f3}\u{05f4}\u{200c}\u{200d}\u{30fb}]/u;
1512
+ const RE_PVALID_EXCEPTIONS = /[\u{00df}\u{03c2}\u{06fd}\u{06fe}\u{0f0b}\u{3007}]/u;
1513
+ const RE_EUROPEAN_NUMBER = new RegExp([RE_ASCII_DIGIT, RE_EXT_ARABIC_INDIC_DIGIT].map((regexp) => regexp.source).join("|"), "u");
1514
+ const RE_PERMITTED_CATEGORY = new RegExp([
1515
+ RE_LETTER,
1516
+ RE_EUROPEAN_SEPARATOR,
1517
+ RE_COMMON_SEPARATOR,
1518
+ RE_NUMBER_DECIMAL,
1519
+ RE_MARK_NONSPACING,
1520
+ RE_MARK_SPACING_COMBINING,
1521
+ RE_CONTEXTO_EXCEPTIONS,
1522
+ RE_PVALID_EXCEPTIONS
1523
+ ].map((regexp) => regexp.source).join("|"), "u");
1524
+ // ../../node_modules/.pnpm/typebox@1.4.3/node_modules/typebox/build/format/idna/label/ascii.mjs
1525
+ function IsAsciiLabel(value) {
1526
+ return RE_RULE_HYPHEN_PLACEMENT.test(value) && RE_RULE_NOT_RESERVED_ACE.test(value) && RE_ASCII_LDH.test(value);
1527
+ }
1528
+ // ../../node_modules/.pnpm/typebox@1.4.3/node_modules/typebox/build/format/idna/format/puny.mjs
1529
+ const PUNYCODE_BASE = 36;
1530
+ const PUNYCODE_TMIN = 1;
1531
+ const PUNYCODE_TMAX = 26;
1532
+ const PUNYCODE_SKEW = 38;
1533
+ const PUNYCODE_DAMP = 700;
1534
+ const PUNYCODE_INITIAL_BIAS = 72;
1535
+ const PUNYCODE_INITIAL_N = 128;
1536
+ function ThrowDontCare() {
1537
+ throw null;
1538
+ }
1539
+ function IsAcePrefixed(value) {
1540
+ return value.toLowerCase().startsWith("xn--");
1541
+ }
1542
+ function Adapt(delta, numPoints, firstTime) {
1543
+ delta = firstTime ? Math.floor(delta / PUNYCODE_DAMP) : delta >> 1;
1544
+ delta += Math.floor(delta / numPoints);
1545
+ let k = 0;
1546
+ while (delta > 455) {
1547
+ delta = Math.floor(delta / 35);
1548
+ k += PUNYCODE_BASE;
1549
+ }
1550
+ return k + Math.floor(36 * delta / (delta + PUNYCODE_SKEW));
1551
+ }
1552
+ function Decode$8(value) {
1553
+ const output = [];
1554
+ let n = PUNYCODE_INITIAL_N;
1555
+ let i = 0;
1556
+ let bias = PUNYCODE_INITIAL_BIAS;
1557
+ const delimIdx = value.lastIndexOf("-");
1558
+ if (delimIdx > 0) for (let j = 0; j < delimIdx; j++) {
1559
+ const cp = value.charCodeAt(j);
1560
+ if (cp >= 128) ThrowDontCare();
1561
+ output.push(cp);
1562
+ }
1563
+ let inIdx = delimIdx < 0 ? 0 : delimIdx + 1;
1564
+ while (inIdx < value.length) {
1565
+ const oldi = i;
1566
+ let w = 1;
1567
+ let k = PUNYCODE_BASE;
1568
+ while (true) {
1569
+ if (inIdx >= value.length) ThrowDontCare();
1570
+ const ch = value.charCodeAt(inIdx++);
1571
+ let digit;
1572
+ if (ch >= 97 && ch <= 122) digit = ch - 97;
1573
+ else if (ch >= 48 && ch <= 57) digit = ch - 48 + 26;
1574
+ else ThrowDontCare();
1575
+ i += digit * w;
1576
+ const t = k <= bias ? PUNYCODE_TMIN : k >= bias + PUNYCODE_TMAX ? PUNYCODE_TMAX : k - bias;
1577
+ if (digit < t) break;
1578
+ w *= PUNYCODE_BASE - t;
1579
+ k += PUNYCODE_BASE;
1580
+ }
1581
+ const outLen = output.length + 1;
1582
+ bias = Adapt(i - oldi, outLen, oldi === 0);
1583
+ n += Math.floor(i / outLen);
1584
+ i %= outLen;
1585
+ output.splice(i, 0, n);
1586
+ i++;
1587
+ }
1588
+ return String.fromCodePoint(...output);
1589
+ }
1590
+ function DigitToChar(digit) {
1591
+ return digit < 26 ? String.fromCharCode(digit + 97) : String.fromCharCode(digit - 26 + 48);
1592
+ }
1593
+ const RE_REPLACE_NON_ASCII = new RegExp(RE_NON_ASCII.source, "gu");
1594
+ function Encode$8(input) {
1595
+ const basic = input.replace(RE_REPLACE_NON_ASCII, "");
1596
+ const basicLength = basic.length;
1597
+ const result = basicLength > 0 ? [basic, "-"] : [];
1598
+ const codePoints = Array.from(input, (char) => char.codePointAt(0));
1599
+ let n = PUNYCODE_INITIAL_N;
1600
+ let delta = 0;
1601
+ let bias = PUNYCODE_INITIAL_BIAS;
1602
+ let handledCPCount = basicLength;
1603
+ while (handledCPCount < codePoints.length) {
1604
+ let m = Infinity;
1605
+ for (const cp of codePoints) if (cp >= n && cp < m) m = cp;
1606
+ delta += (m - n) * (handledCPCount + 1);
1607
+ n = m;
1608
+ for (const cp of codePoints) {
1609
+ if (cp < n) delta++;
1610
+ if (cp === n) {
1611
+ let q = delta;
1612
+ for (let k = PUNYCODE_BASE;; k += PUNYCODE_BASE) {
1613
+ const t = k <= bias ? PUNYCODE_TMIN : k >= bias + PUNYCODE_TMAX ? PUNYCODE_TMAX : k - bias;
1614
+ if (q < t) break;
1615
+ const digit = t + (q - t) % (PUNYCODE_BASE - t);
1616
+ result.push(DigitToChar(digit));
1617
+ q = Math.floor((q - t) / (PUNYCODE_BASE - t));
1618
+ }
1619
+ result.push(DigitToChar(q));
1620
+ bias = Adapt(delta, handledCPCount + 1, handledCPCount === basicLength);
1621
+ delta = 0;
1622
+ handledCPCount++;
1623
+ }
1624
+ }
1625
+ delta++;
1626
+ n++;
1627
+ }
1628
+ return result.join("");
1629
+ }
1630
+ // ../../node_modules/.pnpm/typebox@1.4.3/node_modules/typebox/build/format/idna/format/bidi.mjs
1631
+ const RE_RTL_ALLOWED = /^(?:R|AL|AN|EN|ES|CS|ET|ON|BN|NSM)$/;
1632
+ const RE_LTR_ALLOWED = /^(?:L|EN|ES|CS|ET|ON|BN|NSM)$/;
1633
+ const RE_RTL_CLASSES = /^(?:R|AL|AN)$/;
1634
+ function HasBidiChars(value) {
1635
+ if (IsAcePrefixed(value)) try {
1636
+ return HasRightToLeftCharacters(Decode$8(value.slice(4).toLowerCase()));
1637
+ } catch {
1638
+ return false;
1639
+ }
1640
+ return HasRightToLeftCharacters(value);
1641
+ }
1642
+ function GetBidiClass(codePoint) {
1643
+ const char = String.fromCodePoint(codePoint);
1644
+ return RE_EUROPEAN_NUMBER.test(char) ? "EN" : RE_ARABIC_INDIC_DIGIT.test(char) ? "AN" : RE_MARK_NONSPACING.test(char) ? "NSM" : RE_SCRIPT_HEBREW.test(char) ? "R" : RE_SCRIPT_ARABIC_LETTER.test(char) ? "AL" : RE_LETTER.test(char) ? "L" : "ON";
1645
+ }
1646
+ function HasRightToLeftCharacters(value) {
1647
+ for (const ch of value) if (RE_RTL_CLASSES.test(GetBidiClass(ch.codePointAt(0)))) return true;
1648
+ return false;
1649
+ }
1650
+ function SatisfiesBidiRule(value) {
1651
+ let isRtl = false;
1652
+ let allowed = RE_LTR_ALLOWED;
1653
+ let sawEN = false;
1654
+ let sawAN = false;
1655
+ let isFirst = true;
1656
+ for (const ch of value) {
1657
+ const bidiClass = GetBidiClass(ch.codePointAt(0));
1658
+ if (isFirst) {
1659
+ if (bidiClass !== "L" && bidiClass !== "R" && bidiClass !== "AL") return false;
1660
+ isRtl = bidiClass === "R" || bidiClass === "AL";
1661
+ allowed = isRtl ? RE_RTL_ALLOWED : RE_LTR_ALLOWED;
1662
+ isFirst = false;
1663
+ }
1664
+ if (!allowed.test(bidiClass)) return false;
1665
+ if (bidiClass === "EN") sawEN = true;
1666
+ else if (bidiClass === "AN") sawAN = true;
1667
+ }
1668
+ if (isRtl && sawEN && sawAN) return false;
1669
+ return true;
1670
+ }
1671
+ // ../../node_modules/.pnpm/typebox@1.4.3/node_modules/typebox/build/format/idna/label/unicode.mjs
1672
+ function ExceedsMaxALabelLength(value) {
1673
+ return RE_NON_ASCII.test(value) && Encode$8(value).length + 4 > 63;
1674
+ }
1675
+ function HasInvalidHyphens(chars) {
1676
+ if (chars[0] === "-" || chars[chars.length - 1] === "-") return true;
1677
+ return chars.slice(2).join("").startsWith("--");
1678
+ }
1679
+ function IsUnicodeLabel(value) {
1680
+ if (ExceedsMaxALabelLength(value)) return false;
1681
+ if (HasRightToLeftCharacters(value) && !SatisfiesBidiRule(value)) return false;
1682
+ const chars = [...value];
1683
+ const codePoints = chars.map((c) => c.codePointAt(0));
1684
+ const length = codePoints.length;
1685
+ if (HasInvalidHyphens(chars)) return false;
1686
+ if (RE_COMBINING_MARK.test(chars[0])) return false;
1687
+ let hasJapanese = false;
1688
+ for (let i = 0; i < length; i++) {
1689
+ const codePoint = codePoints[i];
1690
+ const char = chars[i];
1691
+ if (RE_RFC5892_DISALLOWED.test(char)) return false;
1692
+ if (!RE_PERMITTED_CATEGORY.test(char)) return false;
1693
+ if (RE_SCRIPT_JAPANESE.test(char)) hasJapanese = true;
1694
+ const prev = codePoints[i - 1], next = codePoints[i + 1];
1695
+ switch (codePoint) {
1696
+ case 183:
1697
+ if (prev !== 108 || next !== 108) return false;
1698
+ break;
1699
+ case 885:
1700
+ if (!next || !RE_SCRIPT_GREEK.test(chars[i + 1])) return false;
1701
+ break;
1702
+ case 1523:
1703
+ case 1524:
1704
+ if (!prev || !RE_SCRIPT_HEBREW.test(chars[i - 1])) return false;
1705
+ break;
1706
+ case 8204:
1707
+ if (!prev || prev < 128 && !RE_VIRAMA.test(chars[i - 1])) return false;
1708
+ break;
1709
+ case 8205: if (!prev || !RE_VIRAMA.test(chars[i - 1])) return false;
1710
+ }
1711
+ }
1712
+ if (value.includes("・") && !hasJapanese) return false;
1713
+ return true;
1714
+ }
1715
+ // ../../node_modules/.pnpm/typebox@1.4.3/node_modules/typebox/build/format/idna/label/puny.mjs
1716
+ function IsPunyLabel(value) {
1717
+ if (!IsAcePrefixed(value)) return false;
1718
+ try {
1719
+ const body = value.slice(4).toLowerCase();
1720
+ if (body.lastIndexOf("-") === 0) return false;
1721
+ const decoded = Decode$8(body);
1722
+ if (!RE_NON_ASCII.test(decoded)) return false;
1723
+ return IsUnicodeLabel(decoded);
1724
+ } catch {
1725
+ return false;
1726
+ }
1727
+ }
1728
+ // ../../node_modules/.pnpm/typebox@1.4.3/node_modules/typebox/build/format/idna/hostname.mjs
1729
+ function IsValidLabelLength$1(value) {
1730
+ return value.length > 0 && value.length <= 63;
1731
+ }
1732
+ function IsLabel$1(value) {
1733
+ return IsValidLabelLength$1(value) && (IsPunyLabel(value) || IsAsciiLabel(value));
1734
+ }
1735
+ function IsHostname$1(value) {
1736
+ if (value.length === 0 || value.length > 253) return false;
1737
+ if (value.charCodeAt(value.length - 1) === 46) return false;
1738
+ return value.split(".").every((label) => IsLabel$1(label));
1739
+ }
1740
+ // ../../node_modules/.pnpm/typebox@1.4.3/node_modules/typebox/build/format/idna/idn-hostname.mjs
1741
+ function IsValidLabelLength(value) {
1742
+ return value.length > 0 && value.length <= 63;
1743
+ }
1744
+ function IsLabel(value) {
1745
+ return IsValidLabelLength(value) && (IsPunyLabel(value) || IsUnicodeLabel(value));
1746
+ }
1747
+ function NormalizeHostname(value) {
1748
+ return value.replace(/[\uff01-\uff5e]/g, (char) => String.fromCharCode(char.charCodeAt(0) - 65248)).normalize("NFC").replace(/[\u00ad\u034f\u180b-\u180d\u200b\ufe00-\ufe0f\u{e0100}-\u{e01ef}]/gu, "").replace(/[\u002E\u3002\uFF0E\uFF61]/g, ".");
1749
+ }
1750
+ function IsIdnHostname$1(value) {
1751
+ if (value.length === 0 || value.includes(" ")) return false;
1752
+ const normalized = NormalizeHostname(value);
1753
+ if (normalized.length > 253) return false;
1754
+ const labels = normalized.split(".");
1755
+ const hasBidiChars = labels.some((label) => HasBidiChars(label));
1756
+ return labels.every((label) => IsLabel(label) && (!hasBidiChars || SatisfiesBidiRule(label)));
1757
+ }
1758
+ // ../../node_modules/.pnpm/typebox@1.4.3/node_modules/typebox/build/format/hostname.mjs
1759
+ /**
1760
+ * Returns true if the value is a valid hostname.
1761
+ * @specification https://tools.ietf.org/html/rfc1123
1762
+ * @specification https://tools.ietf.org/html/rfc5891
1763
+ * @specification https://tools.ietf.org/html/rfc5892
1764
+ */
1765
+ function IsHostname(value) {
1766
+ return IsHostname$1(value);
1767
+ }
1768
+ // ../../node_modules/.pnpm/typebox@1.4.3/node_modules/typebox/build/format/idn_email.mjs
1769
+ const IdnEmail = /^(?:[A-Za-z0-9!#$%&'*+\/=?^_`{|}~\u{0080}-\u{10FFFF}-]+(?:\.[A-Za-z0-9!#$%&'*+\/=?^_`{|}~\u{0080}-\u{10FFFF}-]+)*|"(?:[^"\\]|\\.)*")@[\p{L}\p{N}](?:[\p{L}\p{N}-]{0,62})(?<!-)(?:\.[\p{L}\p{N}](?:[\p{L}\p{N}-]{0,62})(?<!-))*$/iu;
1770
+ /**
1771
+ * Returns true if the value is an IdnEmail
1772
+ * @specification https://datatracker.ietf.org/doc/html/rfc4952
1773
+ * @specification https://datatracker.ietf.org/doc/html/rfc6531
1774
+ */
1775
+ function IsIdnEmail(value) {
1776
+ return IdnEmail.test(value.normalize("NFC"));
1777
+ }
1778
+ // ../../node_modules/.pnpm/typebox@1.4.3/node_modules/typebox/build/format/idn_hostname.mjs
1779
+ /**
1780
+ * Returns true if the value is a valid internationalized (IDN) hostname.
1781
+ * @specification https://datatracker.ietf.org/doc/html/rfc5890
1782
+ * @specification https://tools.ietf.org/html/rfc5891
1783
+ * @specification https://tools.ietf.org/html/rfc5892
1784
+ * @specification https://tools.ietf.org/html/rfc5893
1785
+ */
1786
+ function IsIdnHostname(value) {
1787
+ return IsIdnHostname$1(value);
1788
+ }
1789
+ // ../../node_modules/.pnpm/typebox@1.4.3/node_modules/typebox/build/format/ipv4.mjs
1790
+ const IPv4 = /^(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)$/;
1791
+ /**
1792
+ * Returns true if the value is an IPv4 address
1793
+ * @specification https://datatracker.ietf.org/doc/html/rfc3986#section-3.2.2
1794
+ */
1795
+ function IsIPv4(value) {
1796
+ return IPv4.test(value);
1797
+ }
1798
+ // ../../node_modules/.pnpm/typebox@1.4.3/node_modules/typebox/build/format/ipv6.mjs
1799
+ const IPv6 = /^(?:(?:(?:[0-9a-f]{1,4}:){6}|::(?:[0-9a-f]{1,4}:){5}|(?:[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){4}|(?:(?:[0-9a-f]{1,4}:)?[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){3}|(?:(?:[0-9a-f]{1,4}:){0,2}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){2}|(?:(?:[0-9a-f]{1,4}:){0,3}[0-9a-f]{1,4})?::[0-9a-f]{1,4}:|(?:(?:[0-9a-f]{1,4}:){0,4}[0-9a-f]{1,4})?::)(?:[0-9a-f]{1,4}:[0-9a-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d))|(?:(?:[0-9a-f]{1,4}:){0,5}[0-9a-f]{1,4})?::[0-9a-f]{1,4}|(?:(?:[0-9a-f]{1,4}:){0,6}[0-9a-f]{1,4})?::)$/i;
1800
+ /**
1801
+ * Returns true if the value is an IPv6 address
1802
+ * @specification https://datatracker.ietf.org/doc/html/rfc4291#section-2.2
1803
+ */
1804
+ function IsIPv6(value) {
1805
+ return IPv6.test(value);
1806
+ }
1807
+ // ../../node_modules/.pnpm/typebox@1.4.3/node_modules/typebox/build/format/iri_reference.mjs
1808
+ const InvalidIriChars$1 = /[\x00-\x20\x7F\\]|%(?![0-9a-fA-F]{2})/;
1809
+ const MalformedScheme = /^[a-zA-Z][a-zA-Z0-9+\-.]*\/\//;
1810
+ /**
1811
+ * Returns true if the value is an IRI reference
1812
+ * @specification https://tools.ietf.org/html/rfc3987
1813
+ */
1814
+ function IsIriReference(value) {
1815
+ return !InvalidIriChars$1.test(value) && !MalformedScheme.test(value) && URL.canParse(value, "http://example.com");
1816
+ }
1817
+ // ../../node_modules/.pnpm/typebox@1.4.3/node_modules/typebox/build/format/iri.mjs
1818
+ const InvalidIriChars = /[\x00-\x20<>\^`{|}\\]/;
1819
+ const InvalidPercentEncoding = /%(?![0-9a-fA-F]{2})/;
1820
+ /**
1821
+ * Returns true if the value is a valid Internationalized Resource Identifier.
1822
+ * @specification https://datatracker.ietf.org/doc/html/rfc3987
1823
+ */
1824
+ function IsIri(value) {
1825
+ if (InvalidIriChars.test(value)) return false;
1826
+ if (InvalidPercentEncoding.test(value)) return false;
1827
+ return URL.canParse(value);
1828
+ }
1829
+ // ../../node_modules/.pnpm/typebox@1.4.3/node_modules/typebox/build/format/json_pointer_uri_fragment.mjs
1830
+ const JsonPointerUriFragment = /^#(?:\/(?:[a-z0-9_\-.!$&'()*+,;:=@]|%[0-9a-f]{2}|~0|~1)*)*$/i;
1831
+ /**
1832
+ * Returns true if the value is a json pointer uri fragment
1833
+ * @specification https://datatracker.ietf.org/doc/html/rfc6901
1834
+ * @source https://github.com/ajv-validator/ajv-formats
1835
+ */
1836
+ function IsJsonPointerUriFragment(value) {
1837
+ return JsonPointerUriFragment.test(value);
1838
+ }
1839
+ // ../../node_modules/.pnpm/typebox@1.4.3/node_modules/typebox/build/format/json_pointer.mjs
1840
+ const JsonPointer = /^(?:\/(?:[^~/]|~0|~1)*)*$/;
1841
+ /**
1842
+ * Returns true if the value is a json pointer
1843
+ * @specification https://datatracker.ietf.org/doc/html/rfc6901
1844
+ * @source https://github.com/ajv-validator/ajv-formats
1845
+ */
1846
+ function IsJsonPointer(value) {
1847
+ return JsonPointer.test(value);
1848
+ }
1849
+ // ../../node_modules/.pnpm/typebox@1.4.3/node_modules/typebox/build/format/regex.mjs
1850
+ /**
1851
+ * Returns true if the value is a regular expression string pattern
1852
+ * @specification https://ecma-international.org/ecma-262
1853
+ */
1854
+ function IsRegex(value) {
1855
+ try {
1856
+ new RegExp(value, "u");
1857
+ return true;
1858
+ } catch {
1859
+ return false;
1860
+ }
1861
+ }
1862
+ // ../../node_modules/.pnpm/typebox@1.4.3/node_modules/typebox/build/format/relative_json_pointer.mjs
1863
+ const RelativeJsonPointer = /^(?:0|[1-9][0-9]*)(?:#|(?:\/(?:[^~/]|~0|~1)*)*)$/;
1864
+ /**
1865
+ * Returns true if the value is a relative JSON Pointer
1866
+ * @specification https://datatracker.ietf.org/doc/html/draft-handrews-relative-json-pointer/
1867
+ * @source https://github.com/ajv-validator/ajv-formats
1868
+ */
1869
+ function IsRelativeJsonPointer(value) {
1870
+ return RelativeJsonPointer.test(value);
1871
+ }
1872
+ // ../../node_modules/.pnpm/typebox@1.4.3/node_modules/typebox/build/format/uri_reference.mjs
1873
+ const UriReference = /^(?:[a-z][a-z0-9+\-.]*:(?:\/\/(?:(?:[-a-z0-9._~!$&'()*+,;=:]|%[0-9a-f]{2})*@)?(?:\[(?:(?:(?:[\da-f]{1,4}:){6}(?:[\da-f]{1,4}:[\da-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d))|::(?:[\da-f]{1,4}:){5}(?:[\da-f]{1,4}:[\da-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d))|(?:[\da-f]{1,4})?::(?:[\da-f]{1,4}:){4}(?:[\da-f]{1,4}:[\da-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d))|(?:(?:[\da-f]{1,4}:){0,1}[\da-f]{1,4})?::(?:[\da-f]{1,4}:){3}(?:[\da-f]{1,4}:[\da-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d))|(?:(?:[\da-f]{1,4}:){0,2}[\da-f]{1,4})?::(?:[\da-f]{1,4}:){2}(?:[\da-f]{1,4}:[\da-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d))|(?:(?:[\da-f]{1,4}:){0,3}[\da-f]{1,4})?::[\da-f]{1,4}:(?:[\da-f]{1,4}:[\da-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d))|(?:(?:[\da-f]{1,4}:){0,4}[\da-f]{1,4})?::(?:[\da-f]{1,4}:[\da-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d))|(?:(?:[\da-f]{1,4}:){0,5}[\da-f]{1,4})?::[\da-f]{1,4}|(?:(?:[\da-f]{1,4}:){0,6}[\da-f]{1,4})?::)|v[0-9a-f]+\.[-a-z0-9._~!$&'()*+,;=:]+)\]|(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)|(?:[-a-z0-9._~!$&'()*+,;=]|%[0-9a-f]{2})*)(?::\d*)?(?:\/(?:[-a-z0-9._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*|\/(?:(?:[-a-z0-9._~!$&'()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[-a-z0-9._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*)?|(?:[-a-z0-9._~!$&'()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[-a-z0-9._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*)?|(?:\/\/(?:(?:[-a-z0-9._~!$&'()*+,;=:]|%[0-9a-f]{2})*@)?(?:\[(?:(?:(?:[\da-f]{1,4}:){6}(?:[\da-f]{1,4}:[\da-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d))|::(?:[\da-f]{1,4}:){5}(?:[\da-f]{1,4}:[\da-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d))|(?:[\da-f]{1,4})?::(?:[\da-f]{1,4}:){4}(?:[\da-f]{1,4}:[\da-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d))|(?:(?:[\da-f]{1,4}:){0,1}[\da-f]{1,4})?::(?:[\da-f]{1,4}:){3}(?:[\da-f]{1,4}:[\da-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d))|(?:(?:[\da-f]{1,4}:){0,2}[\da-f]{1,4})?::(?:[\da-f]{1,4}:){2}(?:[\da-f]{1,4}:[\da-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d))|(?:(?:[\da-f]{1,4}:){0,3}[\da-f]{1,4})?::[\da-f]{1,4}:(?:[\da-f]{1,4}:[\da-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d))|(?:(?:[\da-f]{1,4}:){0,4}[\da-f]{1,4})?::(?:[\da-f]{1,4}:[\da-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d))|(?:(?:[\da-f]{1,4}:){0,5}[\da-f]{1,4})?::[\da-f]{1,4}|(?:(?:[\da-f]{1,4}:){0,6}[\da-f]{1,4})?::)|v[0-9a-f]+\.[-a-z0-9._~!$&'()*+,;=:]+)\]|(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)|(?:[-a-z0-9._~!$&'()*+,;=]|%[0-9a-f]{2})*)(?::\d*)?(?:\/(?:[-a-z0-9._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*|\/(?:(?:[-a-z0-9._~!$&'()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[-a-z0-9._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*)?|(?:[-a-z0-9._~!$&'()*+,;=@]|%[0-9a-f]{2})+(?:\/(?:[-a-z0-9._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*)?)(?:\?(?:[-a-z0-9._~!$&'()*+,;=:@/?]|%[0-9a-f]{2})*)?(?:#(?:[-a-z0-9._~!$&'()*+,;=:@/?]|%[0-9a-f]{2})*)?$/i;
1874
+ /**
1875
+ * Returns true if the value is a valid Uri Reference.
1876
+ * @specification https://tools.ietf.org/html/rfc3986
1877
+ */
1878
+ function IsUriReference(value) {
1879
+ return UriReference.test(value);
1880
+ }
1881
+ // ../../node_modules/.pnpm/typebox@1.4.3/node_modules/typebox/build/format/uri_template.mjs
1882
+ const UriTemplate = /^(?:(?:[^\x00-\x20"<>%\\^`{|}\x7f]|%[0-9a-f]{2})|\{[+#./;?&=,!@|]?(?:[a-z0-9_]|%[0-9a-f]{2})+(?:\.(?:[a-z0-9_]|%[0-9a-f]{2})+)*(?::[1-9]\d{0,3}|\*)?(?:,(?:[a-z0-9_]|%[0-9a-f]{2})+(?:\.(?:[a-z0-9_]|%[0-9a-f]{2})+)*(?::[1-9]\d{0,3}|\*)?)*\})*$/i;
1883
+ /**
1884
+ * Returns true if the value is a valid Uri Template
1885
+ * @specification https://datatracker.ietf.org/doc/html/rfc6570
1886
+ */
1887
+ function IsUriTemplate(value) {
1888
+ return UriTemplate.test(value);
1889
+ }
1890
+ // ../../node_modules/.pnpm/typebox@1.4.3/node_modules/typebox/build/format/uri.mjs
1891
+ const Uri = /^[a-z][a-z0-9+\-.]*:(?:\/\/(?:(?:[-a-z0-9._~!$&'()*+,;=:]|%[0-9a-f]{2})*@)?(?:\[(?:(?:(?:[\da-f]{1,4}:){6}(?:[\da-f]{1,4}:[\da-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d))|::(?:[\da-f]{1,4}:){5}(?:[\da-f]{1,4}:[\da-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d))|(?:[\da-f]{1,4})?::(?:[\da-f]{1,4}:){4}(?:[\da-f]{1,4}:[\da-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d))|(?:(?:[\da-f]{1,4}:){0,1}[\da-f]{1,4})?::(?:[\da-f]{1,4}:){3}(?:[\da-f]{1,4}:[\da-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d))|(?:(?:[\da-f]{1,4}:){0,2}[\da-f]{1,4})?::(?:[\da-f]{1,4}:){2}(?:[\da-f]{1,4}:[\da-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d))|(?:(?:[\da-f]{1,4}:){0,3}[\da-f]{1,4})?::[\da-f]{1,4}:(?:[\da-f]{1,4}:[\da-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d))|(?:(?:[\da-f]{1,4}:){0,4}[\da-f]{1,4})?::(?:[\da-f]{1,4}:[\da-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d))|(?:(?:[\da-f]{1,4}:){0,5}[\da-f]{1,4})?::[\da-f]{1,4}|(?:(?:[\da-f]{1,4}:){0,6}[\da-f]{1,4})?::)|v[0-9a-f]+\.[-a-z0-9._~!$&'()*+,;=:]+)\]|(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)|(?:[-a-z0-9._~!$&'()*+,;=]|%[0-9a-f]{2})*)(?::\d*)?(?:\/(?:[-a-z0-9._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*|\/(?:(?:[-a-z0-9._~!$&'()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[-a-z0-9._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*)?|(?:[-a-z0-9._~!$&'()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[-a-z0-9._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*)?(?:\?(?:[-a-z0-9._~!$&'()*+,;=:@/?]|%[0-9a-f]{2})*)?(?:#(?:[-a-z0-9._~!$&'()*+,;=:@/?]|%[0-9a-f]{2})*)?$/i;
1892
+ /**
1893
+ * Returns true if the value is a valid Uniform Resource Identifier.
1894
+ * @specification https://tools.ietf.org/html/rfc3986
1895
+ */
1896
+ function IsUri(value) {
1897
+ return Uri.test(value);
1898
+ }
1899
+ // ../../node_modules/.pnpm/typebox@1.4.3/node_modules/typebox/build/format/url.mjs
1900
+ /**
1901
+ * Returns true if the value is a valid Uniform Resource Locator
1902
+ * @specification https://datatracker.ietf.org/doc/html/rfc3986
1903
+ * @specification https://datatracker.ietf.org/doc/html/rfc3987
1904
+ */
1905
+ function IsUrl(value) {
1906
+ return URL.canParse(value);
1907
+ }
1908
+ // ../../node_modules/.pnpm/typebox@1.4.3/node_modules/typebox/build/format/uuid.mjs
1909
+ const Uuid = /^[0-9a-f]{8}-(?:[0-9a-f]{4}-){3}[0-9a-f]{12}$/i;
1910
+ /**
1911
+ * Returns true if the value is a uuid
1912
+ * @specification https://www.rfc-editor.org/info/rfc4122/
1913
+ * @specification https://www.rfc-editor.org/info/rfc9562/
1914
+ */
1915
+ function IsUuid(value) {
1916
+ return Uuid.test(value);
1917
+ }
1918
+ // ../../node_modules/.pnpm/typebox@1.4.3/node_modules/typebox/build/format/_registry.mjs
1919
+ const formats = /* @__PURE__ */ new Map();
1920
+ /** Clears all entries */
1921
+ function Clear() {
1922
+ formats.clear();
1923
+ }
1924
+ /** Returns true if the registry has this format */
1925
+ function Has(format) {
1926
+ return formats.has(format);
1927
+ }
1928
+ /** Gets a format or undefined if not exists */
1929
+ function Get$1(format) {
1930
+ return formats.get(format);
1931
+ }
1932
+ /** Tests a value against a format, if the format is not registered, true */
1933
+ function Test(format, value) {
1934
+ return formats.get(format)?.(value) ?? true;
1935
+ }
1936
+ /** Resets all formats to defaults */
1937
+ function Reset() {
1938
+ Clear();
1939
+ formats.set("date-time", IsDateTime);
1940
+ formats.set("date", IsDate);
1941
+ formats.set("duration", IsDuration);
1942
+ formats.set("email", IsEmail);
1943
+ formats.set("hostname", IsHostname);
1944
+ formats.set("idn-email", IsIdnEmail);
1945
+ formats.set("idn-hostname", IsIdnHostname);
1946
+ formats.set("ipv4", IsIPv4);
1947
+ formats.set("ipv6", IsIPv6);
1948
+ formats.set("iri-reference", IsIriReference);
1949
+ formats.set("iri", IsIri);
1950
+ formats.set("json-pointer-uri-fragment", IsJsonPointerUriFragment);
1951
+ formats.set("json-pointer", IsJsonPointer);
1952
+ formats.set("regex", IsRegex);
1953
+ formats.set("relative-json-pointer", IsRelativeJsonPointer);
1954
+ formats.set("time", IsTime);
1955
+ formats.set("uri-reference", IsUriReference);
1956
+ formats.set("uri-template", IsUriTemplate);
1957
+ formats.set("uri", IsUri);
1958
+ formats.set("url", IsUrl);
1959
+ formats.set("uuid", IsUuid);
1960
+ }
1961
+ Reset();
1962
+ // ../../node_modules/.pnpm/typebox@1.4.3/node_modules/typebox/build/schema/engine/format.mjs
1963
+ function BuildFormat(_stack, _context, schema, value) {
1964
+ return Has(schema.format) ? Call(CreateVariable(Get$1(schema.format)), [value]) : Constant(true);
1965
+ }
1966
+ function CheckFormat(_stack, _context, schema, value) {
1967
+ return Test(schema.format, value);
1968
+ }
1969
+ function ErrorFormat(stack, context, schemaPath, instancePath, schema, value) {
1970
+ return CheckFormat(stack, context, schema, value) || context.AddError("format", schemaPath, instancePath, { format: schema.format });
1971
+ }
1972
+ // ../../node_modules/.pnpm/typebox@1.4.3/node_modules/typebox/build/schema/engine/if.mjs
1973
+ function BuildIf(stack, context, schema, value) {
1974
+ const thenSchema = IsThen(schema) ? schema.then : true;
1975
+ const elseSchema = IsElse(schema) ? schema.else : true;
1976
+ return Ternary(BuildSchema(stack, context, schema.if, value), BuildSchema(stack, context, thenSchema, value), BuildSchema(stack, context, elseSchema, value));
1977
+ }
1978
+ function CheckIf(stack, context, schema, value) {
1979
+ const thenSchema = IsThen(schema) ? schema.then : true;
1980
+ const elseSchema = IsElse(schema) ? schema.else : true;
1981
+ return CheckSchema(stack, context, schema.if, value) ? CheckSchema(stack, context, thenSchema, value) : CheckSchema(stack, context, elseSchema, value);
1982
+ }
1983
+ function ErrorIf(stack, context, schemaPath, instancePath, schema, value) {
1984
+ const thenSchema = IsThen(schema) ? schema.then : true;
1985
+ const elseSchema = IsElse(schema) ? schema.else : true;
1986
+ const trueContext = new ErrorContext();
1987
+ const isIf = ErrorSchema(stack, trueContext, `${schemaPath}/if`, instancePath, schema.if, value) ? ErrorSchema(stack, trueContext, `${schemaPath}/then`, instancePath, thenSchema, value) || context.AddError("if", schemaPath, instancePath, { failingKeyword: "then" }) : ErrorSchema(stack, context, `${schemaPath}/else`, instancePath, elseSchema, value) || context.AddError("if", schemaPath, instancePath, { failingKeyword: "else" });
1988
+ if (isIf) context.Merge([trueContext]);
1989
+ return isIf;
1990
+ }
1991
+ // ../../node_modules/.pnpm/typebox@1.4.3/node_modules/typebox/build/schema/engine/items.mjs
1992
+ function BuildItemsSizedStandard(stack, context, schema, value) {
1993
+ return ReduceAnd(schema.items.map((schema, index) => {
1994
+ return Or(IsLessEqualThan(Member(value, "length"), Constant(index)), And(BuildSchemaPushStack(stack, context, schema, `${value}[${index}]`), context.AddIndex(Constant(index))));
1995
+ }));
1996
+ }
1997
+ function BuildItemsSizedFast(stack, context, schema, value) {
1998
+ return ReduceAnd(schema.items.map((schema, index) => {
1999
+ return Or(IsLessEqualThan(Member(value, "length"), Constant(index)), BuildSchemaPushStack(stack, context, schema, `${value}[${index}]`));
2000
+ }));
2001
+ }
2002
+ function BuildItemsSized(stack, context, schema, value) {
2003
+ return context.UseUnevaluated() ? BuildItemsSizedStandard(stack, context, schema, value) : BuildItemsSizedFast(stack, context, schema, value);
2004
+ }
2005
+ function CheckItemsSized(stack, context, schema, value) {
2006
+ return Every$1(schema.items, 0, (schema, index) => {
2007
+ return IsLessEqualThan$1(value.length, index) || CheckSchemaPushStack(stack, context, schema, value[index]) && context.AddIndex(index);
2008
+ });
2009
+ }
2010
+ function ErrorItemsSized(stack, context, schemaPath, instancePath, schema, value) {
2011
+ return EveryAll(schema.items, 0, (schema, index) => {
2012
+ const nextSchemaPath = `${schemaPath}/items/${index}`;
2013
+ const nextInstancePath = `${instancePath}/${index}`;
2014
+ return IsLessEqualThan$1(value.length, index) || ErrorSchemaPushStack(stack, context, nextSchemaPath, nextInstancePath, schema, value[index]) && context.AddIndex(index);
2015
+ });
2016
+ }
2017
+ function BuildItemsUnsizedStandard(stack, context, schema, value) {
2018
+ const offset = IsPrefixItems(schema) ? schema.prefixItems.length : 0;
2019
+ const [item] = [CreateUnique()];
2020
+ const isSchema = BuildSchemaPushStack(stack, context, schema.items, item);
2021
+ const addIndex = context.AddIndex("index");
2022
+ return Every(value, Constant(offset), [item, "index"], And(isSchema, addIndex));
2023
+ }
2024
+ function BuildItemsUnsizedFast(stack, context, schema, value) {
2025
+ const offset = IsPrefixItems(schema) ? schema.prefixItems.length : 0;
2026
+ const [item] = [CreateUnique()];
2027
+ const isSchema = BuildSchemaPushStack(stack, context, schema.items, item);
2028
+ return Every(value, Constant(offset), [item, "index"], isSchema);
2029
+ }
2030
+ function BuildItemsUnsized(stack, context, schema, value) {
2031
+ return context.UseUnevaluated() ? BuildItemsUnsizedStandard(stack, context, schema, value) : BuildItemsUnsizedFast(stack, context, schema, value);
2032
+ }
2033
+ function CheckItemsUnsized(stack, context, schema, value) {
2034
+ const offset = IsPrefixItems(schema) ? schema.prefixItems.length : 0;
2035
+ return Every$1(value, offset, (element, index) => {
2036
+ return CheckSchemaPushStack(stack, context, schema.items, element) && context.AddIndex(index);
2037
+ });
2038
+ }
2039
+ function ErrorItemsUnsized(stack, context, schemaPath, instancePath, schema, value) {
2040
+ const offset = IsPrefixItems(schema) ? schema.prefixItems.length : 0;
2041
+ return EveryAll(value, offset, (element, index) => {
2042
+ return ErrorSchemaPushStack(stack, context, `${schemaPath}/items`, `${instancePath}/${index}`, schema.items, element) && context.AddIndex(index);
2043
+ });
2044
+ }
2045
+ function BuildItems(stack, context, schema, value) {
2046
+ return IsItemsSized(schema) ? BuildItemsSized(stack, context, schema, value) : BuildItemsUnsized(stack, context, schema, value);
2047
+ }
2048
+ function CheckItems(stack, context, schema, value) {
2049
+ return IsItemsSized(schema) ? CheckItemsSized(stack, context, schema, value) : CheckItemsUnsized(stack, context, schema, value);
2050
+ }
2051
+ function ErrorItems(stack, context, schemaPath, instancePath, schema, value) {
2052
+ return IsItemsSized(schema) ? ErrorItemsSized(stack, context, schemaPath, instancePath, schema, value) : ErrorItemsUnsized(stack, context, schemaPath, instancePath, schema, value);
2053
+ }
2054
+ // ../../node_modules/.pnpm/typebox@1.4.3/node_modules/typebox/build/schema/engine/maxContains.mjs
2055
+ function IsValid$2(schema) {
2056
+ return IsContains(schema);
2057
+ }
2058
+ function BuildMaxContains(stack, context, schema, value) {
2059
+ if (!IsValid$2(schema)) return Constant(true);
2060
+ const [item] = [CreateUnique()];
2061
+ return IsLessEqualThan(Counted(value, [item, "_"], BuildSchema(stack, context, schema.contains, item)), Constant(schema.maxContains));
2062
+ }
2063
+ function CheckMaxContains(stack, context, schema, value) {
2064
+ if (!IsValid$2(schema)) return true;
2065
+ const count = Counted$1(value, (item) => CheckSchema(stack, context, schema.contains, item));
2066
+ return IsLessEqualThan$1(count, schema.maxContains);
2067
+ }
2068
+ function ErrorMaxContains(stack, context, schemaPath, instancePath, schema, value) {
2069
+ const minContains = IsMinContains(schema) ? schema.minContains : 1;
2070
+ return CheckMaxContains(stack, context, schema, value) || context.AddError("contains", schemaPath, instancePath, {
2071
+ minContains,
2072
+ maxContains: schema.maxContains
2073
+ });
2074
+ }
2075
+ // ../../node_modules/.pnpm/typebox@1.4.3/node_modules/typebox/build/schema/engine/maximum.mjs
2076
+ function BuildMaximum(_stack, _context, schema, value) {
2077
+ return IsLessEqualThan(value, Constant(schema.maximum));
2078
+ }
2079
+ function CheckMaximum(_stack, _context, schema, value) {
2080
+ return IsLessEqualThan$1(value, schema.maximum);
2081
+ }
2082
+ function ErrorMaximum(stack, context, schemaPath, instancePath, schema, value) {
2083
+ return CheckMaximum(stack, context, schema, value) || context.AddError("maximum", schemaPath, instancePath, {
2084
+ comparison: "<=",
2085
+ limit: schema.maximum
2086
+ });
2087
+ }
2088
+ // ../../node_modules/.pnpm/typebox@1.4.3/node_modules/typebox/build/schema/engine/maxItems.mjs
2089
+ function BuildMaxItems(_stack, _context, schema, value) {
2090
+ return IsLessEqualThan(Member(value, "length"), Constant(schema.maxItems));
2091
+ }
2092
+ function CheckMaxItems(_stack, _context, schema, value) {
2093
+ return IsLessEqualThan$1(value.length, schema.maxItems);
2094
+ }
2095
+ function ErrorMaxItems(stack, context, schemaPath, instancePath, schema, value) {
2096
+ return CheckMaxItems(stack, context, schema, value) || context.AddError("maxItems", schemaPath, instancePath, { limit: schema.maxItems });
2097
+ }
2098
+ // ../../node_modules/.pnpm/typebox@1.4.3/node_modules/typebox/build/schema/engine/maxLength.mjs
2099
+ function BuildMaxLength(_stack, _context, schema, value) {
2100
+ return IsMaxLength$1(value, Constant(schema.maxLength));
2101
+ }
2102
+ function CheckMaxLength(_stack, _context, schema, value) {
2103
+ return IsMaxLength$2(value, schema.maxLength);
2104
+ }
2105
+ function ErrorMaxLength(stack, context, schemaPath, instancePath, schema, value) {
2106
+ return CheckMaxLength(stack, context, schema, value) || context.AddError("maxLength", schemaPath, instancePath, { limit: schema.maxLength });
2107
+ }
2108
+ // ../../node_modules/.pnpm/typebox@1.4.3/node_modules/typebox/build/schema/engine/maxProperties.mjs
2109
+ function BuildMaxProperties(_stack, _context, schema, value) {
2110
+ return IsLessEqualThan(Member(Keys(value), "length"), Constant(schema.maxProperties));
2111
+ }
2112
+ function CheckMaxProperties(_stack, _context, schema, value) {
2113
+ return IsLessEqualThan$1(Keys$1(value).length, schema.maxProperties);
2114
+ }
2115
+ function ErrorMaxProperties(stack, context, schemaPath, instancePath, schema, value) {
2116
+ return CheckMaxProperties(stack, context, schema, value) || context.AddError("maxProperties", schemaPath, instancePath, { limit: schema.maxProperties });
2117
+ }
2118
+ // ../../node_modules/.pnpm/typebox@1.4.3/node_modules/typebox/build/schema/engine/minContains.mjs
2119
+ function IsValid$1(schema) {
2120
+ return IsContains(schema);
2121
+ }
2122
+ function BuildMinContainsStandard(stack, context, schema, value) {
2123
+ const [item, index] = [CreateUnique(), CreateUnique()];
2124
+ return IsGreaterEqualThan(Counted(value, [item, index], And(BuildSchema(stack, context, schema.contains, item), context.AddIndex(index))), Constant(schema.minContains));
2125
+ }
2126
+ function BuildMinContainsFast(stack, context, schema, value) {
2127
+ const [item] = [CreateUnique()];
2128
+ return IsGreaterEqualThan(Counted(value, [item, "_"], BuildSchema(stack, context, schema.contains, item)), Constant(schema.minContains));
2129
+ }
2130
+ function BuildMinContains(stack, context, schema, value) {
2131
+ if (!IsValid$1(schema)) return Constant(true);
2132
+ return context.UseUnevaluated() ? BuildMinContainsStandard(stack, context, schema, value) : BuildMinContainsFast(stack, context, schema, value);
2133
+ }
2134
+ function CheckMinContains(stack, context, schema, value) {
2135
+ if (!IsValid$1(schema)) return true;
2136
+ const count = Counted$1(value, (item, index) => CheckSchema(stack, context, schema.contains, item) && context.AddIndex(index));
2137
+ return IsGreaterEqualThan$1(count, schema.minContains);
2138
+ }
2139
+ function ErrorMinContains(stack, context, schemaPath, instancePath, schema, value) {
2140
+ return CheckMinContains(stack, context, schema, value) || context.AddError("contains", schemaPath, instancePath, { minContains: schema.minContains });
2141
+ }
2142
+ // ../../node_modules/.pnpm/typebox@1.4.3/node_modules/typebox/build/schema/engine/minimum.mjs
2143
+ function BuildMinimum(_stack, _context, schema, value) {
2144
+ return IsGreaterEqualThan(value, Constant(schema.minimum));
2145
+ }
2146
+ function CheckMinimum(_stack, _context, schema, value) {
2147
+ return IsGreaterEqualThan$1(value, schema.minimum);
2148
+ }
2149
+ function ErrorMinimum(stack, context, schemaPath, instancePath, schema, value) {
2150
+ return CheckMinimum(stack, context, schema, value) || context.AddError("minimum", schemaPath, instancePath, {
2151
+ comparison: ">=",
2152
+ limit: schema.minimum
2153
+ });
2154
+ }
2155
+ // ../../node_modules/.pnpm/typebox@1.4.3/node_modules/typebox/build/schema/engine/minItems.mjs
2156
+ function BuildMinItems(_stack, _context, schema, value) {
2157
+ return IsGreaterEqualThan(Member(value, "length"), Constant(schema.minItems));
2158
+ }
2159
+ function CheckMinItems(_stack, _context, schema, value) {
2160
+ return IsGreaterEqualThan$1(value.length, schema.minItems);
2161
+ }
2162
+ function ErrorMinItems(stack, context, schemaPath, instancePath, schema, value) {
2163
+ return CheckMinItems(stack, context, schema, value) || context.AddError("minItems", schemaPath, instancePath, { limit: schema.minItems });
2164
+ }
2165
+ // ../../node_modules/.pnpm/typebox@1.4.3/node_modules/typebox/build/schema/engine/minLength.mjs
2166
+ function BuildMinLength(_stack, _context, schema, value) {
2167
+ return IsMinLength$1(value, Constant(schema.minLength));
2168
+ }
2169
+ function CheckMinLength(_stack, _context, schema, value) {
2170
+ return IsMinLength$2(value, schema.minLength);
2171
+ }
2172
+ function ErrorMinLength(stack, context, schemaPath, instancePath, schema, value) {
2173
+ return CheckMinLength(stack, context, schema, value) || context.AddError("minLength", schemaPath, instancePath, { limit: schema.minLength });
2174
+ }
2175
+ // ../../node_modules/.pnpm/typebox@1.4.3/node_modules/typebox/build/schema/engine/minProperties.mjs
2176
+ function BuildMinProperties(_stack, _context, schema, value) {
2177
+ return IsGreaterEqualThan(Member(Keys(value), "length"), Constant(schema.minProperties));
2178
+ }
2179
+ function CheckMinProperties(_stack, _context, schema, value) {
2180
+ return IsGreaterEqualThan$1(Keys$1(value).length, schema.minProperties);
2181
+ }
2182
+ function ErrorMinProperties(stack, context, schemaPath, instancePath, schema, value) {
2183
+ return CheckMinProperties(stack, context, schema, value) || context.AddError("minProperties", schemaPath, instancePath, { limit: schema.minProperties });
2184
+ }
2185
+ // ../../node_modules/.pnpm/typebox@1.4.3/node_modules/typebox/build/schema/engine/multipleOf.mjs
2186
+ function BuildMultipleOf(_stack, _context, schema, value) {
2187
+ return MultipleOf(value, Constant(schema.multipleOf));
2188
+ }
2189
+ function CheckMultipleOf(_stack, _context, schema, value) {
2190
+ return IsMultipleOf$1(value, schema.multipleOf);
2191
+ }
2192
+ function ErrorMultipleOf(stack, context, schemaPath, instancePath, schema, value) {
2193
+ return CheckMultipleOf(stack, context, schema, value) || context.AddError("multipleOf", schemaPath, instancePath, { multipleOf: schema.multipleOf });
2194
+ }
2195
+ // ../../node_modules/.pnpm/typebox@1.4.3/node_modules/typebox/build/schema/engine/not.mjs
2196
+ function BuildNotStandard(stack, context, schema, value) {
2197
+ return Reducer(stack, context, [schema.not], value, Not(IsEqual(Member("results", "length"), Constant(1))));
2198
+ }
2199
+ function BuildNotFast(stack, context, schema, value) {
2200
+ return Not(BuildSchema(stack, context, schema.not, value));
2201
+ }
2202
+ function BuildNot(stack, context, schema, value) {
2203
+ return context.UseUnevaluated() ? BuildNotStandard(stack, context, schema, value) : BuildNotFast(stack, context, schema, value);
2204
+ }
2205
+ function CheckNot(stack, context, schema, value) {
2206
+ const nextContext = new CheckContext();
2207
+ return !CheckSchema(stack, nextContext, schema.not, value) && context.Merge([nextContext]);
2208
+ }
2209
+ function ErrorNot(stack, context, schemaPath, instancePath, schema, value) {
2210
+ return CheckNot(stack, context, schema, value) || context.AddError("not", schemaPath, instancePath, {});
2211
+ }
2212
+ // ../../node_modules/.pnpm/typebox@1.4.3/node_modules/typebox/build/schema/engine/oneOf.mjs
2213
+ function BuildOneOfStandard(stack, context, schema, value) {
2214
+ return Reducer(stack, context, schema.oneOf, value, IsEqual(Member("results", "length"), Constant(1)));
2215
+ }
2216
+ function BuildOneOfFast(stack, context, schema, value) {
2217
+ const [result] = [CreateUnique()];
2218
+ return IsEqual(Counted(ArrayLiteral(schema.oneOf.map((schema) => BuildSchema(stack, context, schema, value))), [result, "_"], IsEqual(result, Constant(true))), Constant(1));
2219
+ }
2220
+ function BuildOneOf(stack, context, schema, value) {
2221
+ return context.UseUnevaluated() ? BuildOneOfStandard(stack, context, schema, value) : BuildOneOfFast(stack, context, schema, value);
2222
+ }
2223
+ function CheckOneOf(stack, context, schema, value) {
2224
+ const passedContexts = schema.oneOf.reduce((result, schema) => {
2225
+ const nextContext = new CheckContext();
2226
+ return CheckSchema(stack, nextContext, schema, value) ? [...result, nextContext] : result;
2227
+ }, []);
2228
+ return IsEqual$1(passedContexts.length, 1) && context.Merge(passedContexts);
2229
+ }
2230
+ function ErrorOneOf(stack, context, schemaPath, instancePath, schema, value) {
2231
+ const failedContexts = [];
2232
+ const passingSchemas = [];
2233
+ const passedContexts = schema.oneOf.reduce((result, schema, index) => {
2234
+ const nextContext = new ErrorContext();
2235
+ const isSchema = ErrorSchema(stack, nextContext, `${schemaPath}/oneOf/${index}`, instancePath, schema, value);
2236
+ if (isSchema) passingSchemas.push(index);
2237
+ if (!isSchema) failedContexts.push(nextContext);
2238
+ return isSchema ? [...result, nextContext] : result;
2239
+ }, []);
2240
+ const isOneOf = IsEqual$1(passedContexts.length, 1) && context.Merge(passedContexts);
2241
+ if (!isOneOf && IsEqual$1(passingSchemas.length, 0)) failedContexts.forEach((failed) => context.AddErrors(failed.GetErrors()));
2242
+ return isOneOf || context.AddError("oneOf", schemaPath, instancePath, { passingSchemas });
2243
+ }
2244
+ // ../../node_modules/.pnpm/typebox@1.4.3/node_modules/typebox/build/schema/engine/pattern.mjs
2245
+ function BuildPattern(_stack, _context, schema, value) {
2246
+ return Call(Member(CreateVariable(IsString$1(schema.pattern) ? UnicodeRegExp(schema.pattern) : schema.pattern), "test"), [value]);
2247
+ }
2248
+ function CheckPattern(_stack, _context, schema, value) {
2249
+ return (IsString$1(schema.pattern) ? UnicodeRegExp(schema.pattern) : schema.pattern).test(value);
2250
+ }
2251
+ function ErrorPattern(stack, context, schemaPath, instancePath, schema, value) {
2252
+ return CheckPattern(stack, context, schema, value) || context.AddError("pattern", schemaPath, instancePath, { pattern: schema.pattern });
2253
+ }
2254
+ // ../../node_modules/.pnpm/typebox@1.4.3/node_modules/typebox/build/schema/engine/patternProperties.mjs
2255
+ function BuildPatternProperties(stack, context, schema, value) {
2256
+ return ReduceAnd(Entries$1(schema.patternProperties).map(([pattern, schema]) => {
2257
+ const [key, prop] = [CreateUnique(), CreateUnique()];
2258
+ const notKey = Not(Call(Member(CreateVariable(UnicodeRegExp(pattern)), "test"), [key]));
2259
+ const isSchema = BuildSchemaPushStack(stack, context, schema, prop);
2260
+ const addKey = context.AddKey(key);
2261
+ const guarded = context.UseUnevaluated() ? Or(notKey, And(isSchema, addKey)) : Or(notKey, isSchema);
2262
+ return Every(Entries(value), Constant(0), [`[${key}, ${prop}]`, "_"], guarded);
2263
+ }));
2264
+ }
2265
+ function CheckPatternProperties(stack, context, schema, value) {
2266
+ return Every$1(Entries$1(schema.patternProperties), 0, ([pattern, schema]) => {
2267
+ const regexp = UnicodeRegExp(pattern);
2268
+ return Every$1(Entries$1(value), 0, ([key, prop]) => {
2269
+ return !regexp.test(key) || CheckSchemaPushStack(stack, context, schema, prop) && context.AddKey(key);
2270
+ });
2271
+ });
2272
+ }
2273
+ function ErrorPatternProperties(stack, context, schemaPath, instancePath, schema, value) {
2274
+ return EveryAll(Entries$1(schema.patternProperties), 0, ([pattern, schema]) => {
2275
+ const nextSchemaPath = `${schemaPath}/patternProperties/${EncodeFragment(pattern)}`;
2276
+ const regexp = UnicodeRegExp(pattern);
2277
+ return EveryAll(Entries$1(value), 0, ([key, value]) => {
2278
+ const nextInstancePath = `${instancePath}/${EncodeFragment(key)}`;
2279
+ return !regexp.test(key) || ErrorSchemaPushStack(stack, context, nextSchemaPath, nextInstancePath, schema, value) && context.AddKey(key);
2280
+ });
2281
+ });
2282
+ }
2283
+ // ../../node_modules/.pnpm/typebox@1.4.3/node_modules/typebox/build/schema/engine/prefixItems.mjs
2284
+ function BuildPrefixItems(stack, context, schema, value) {
2285
+ return ReduceAnd(schema.prefixItems.map((schema, index) => {
2286
+ const isLength = IsLessEqualThan(Member(value, "length"), Constant(index));
2287
+ const isSchema = BuildSchemaPushStack(stack, context, schema, `${value}[${index}]`);
2288
+ const addIndex = context.AddIndex(Constant(index));
2289
+ return Or(isLength, context.UseUnevaluated() ? And(isSchema, addIndex) : isSchema);
2290
+ }));
2291
+ }
2292
+ function CheckPrefixItems(stack, context, schema, value) {
2293
+ return IsEqual$1(value.length, 0) || Every$1(schema.prefixItems, 0, (schema, index) => {
2294
+ return IsLessEqualThan$1(value.length, index) || CheckSchemaPushStack(stack, context, schema, value[index]) && context.AddIndex(index);
2295
+ });
2296
+ }
2297
+ function ErrorPrefixItems(stack, context, schemaPath, instancePath, schema, value) {
2298
+ return IsEqual$1(value.length, 0) || EveryAll(schema.prefixItems, 0, (schema, index) => {
2299
+ const nextSchemaPath = `${schemaPath}/prefixItems/${index}`;
2300
+ const nextInstancePath = `${instancePath}/${index}`;
2301
+ return IsLessEqualThan$1(value.length, index) || ErrorSchemaPushStack(stack, context, nextSchemaPath, nextInstancePath, schema, value[index]) && context.AddIndex(index);
2302
+ });
2303
+ }
2304
+ // ../../node_modules/.pnpm/typebox@1.4.3/node_modules/typebox/build/schema/engine/_exact_optional.mjs
2305
+ function IsExactOptional(required, key) {
2306
+ return required.includes(key) || Get$3().exactOptionalPropertyTypes;
2307
+ }
2308
+ function InexactOptionalBuild(value, key) {
2309
+ return IsUndefined(Member(value, key));
2310
+ }
2311
+ function InexactOptionalCheck(value, key) {
2312
+ return IsUndefined$1(value[key]);
2313
+ }
2314
+ // ../../node_modules/.pnpm/typebox@1.4.3/node_modules/typebox/build/schema/engine/properties.mjs
2315
+ function BuildProperties(stack, context, schema, value) {
2316
+ const required = IsRequired(schema) ? schema.required : [];
2317
+ return ReduceAnd(Entries$1(schema.properties).map(([key, schema]) => {
2318
+ const notKey = Not(HasPropertyKey(value, Constant(key)));
2319
+ const isSchema = BuildSchemaPushStack(stack, context, schema, Member(value, key));
2320
+ const addKey = context.AddKey(Constant(key));
2321
+ const guarded = context.UseUnevaluated() ? And(isSchema, addKey) : isSchema;
2322
+ const isProperty = required.includes(key) ? guarded : Or(notKey, guarded);
2323
+ return IsExactOptional(required, key) ? isProperty : Or(InexactOptionalBuild(value, key), isProperty);
2324
+ }));
2325
+ }
2326
+ function CheckProperties(stack, context, schema, value) {
2327
+ const required = IsRequired(schema) ? schema.required : [];
2328
+ return Every$1(Entries$1(schema.properties), 0, ([key, schema]) => {
2329
+ const isProperty = !HasPropertyKey$1(value, key) || CheckSchemaPushStack(stack, context, schema, value[key]) && context.AddKey(key);
2330
+ return IsExactOptional(required, key) ? isProperty : InexactOptionalCheck(value, key) || isProperty;
2331
+ });
2332
+ }
2333
+ function ErrorProperties(stack, context, schemaPath, instancePath, schema, value) {
2334
+ const required = IsRequired(schema) ? schema.required : [];
2335
+ return EveryAll(Entries$1(schema.properties), 0, ([key, schema]) => {
2336
+ const nextSchemaPath = `${schemaPath}/properties/${EncodeFragment(key)}`;
2337
+ const nextInstancePath = `${instancePath}/${EncodeFragment(key)}`;
2338
+ const isProperty = () => !HasPropertyKey$1(value, key) || ErrorSchemaPushStack(stack, context, nextSchemaPath, nextInstancePath, schema, value[key]) && context.AddKey(key);
2339
+ return IsExactOptional(required, key) ? isProperty() : InexactOptionalCheck(value, key) || isProperty();
2340
+ });
2341
+ }
2342
+ // ../../node_modules/.pnpm/typebox@1.4.3/node_modules/typebox/build/schema/engine/propertyNames.mjs
2343
+ function BuildPropertyNames(stack, context, schema, value) {
2344
+ const [key, _index] = [CreateUnique(), CreateUnique()];
2345
+ return Every(Keys(value), Constant(0), [key, _index], BuildSchema(stack, context, schema.propertyNames, key));
2346
+ }
2347
+ function CheckPropertyNames(stack, context, schema, value) {
2348
+ return Every$1(Keys$1(value), 0, (key, _index) => CheckSchema(stack, context, schema.propertyNames, key));
2349
+ }
2350
+ function ErrorPropertyNames(stack, context, schemaPath, instancePath, schema, value) {
2351
+ const propertyNames = [];
2352
+ return EveryAll(Keys$1(value), 0, (key, _index) => {
2353
+ const nextInstancePath = `${instancePath}/${EncodeFragment(key)}`;
2354
+ const isPropertyName = ErrorSchema(stack, context, `${schemaPath}/propertyNames`, nextInstancePath, schema.propertyNames, key);
2355
+ if (!isPropertyName) propertyNames.push(key);
2356
+ return isPropertyName;
2357
+ }) || context.AddError("propertyNames", schemaPath, instancePath, { propertyNames });
2358
+ }
2359
+ // ../../node_modules/.pnpm/typebox@1.4.3/node_modules/typebox/build/schema/engine/recursiveRef.mjs
2360
+ function BuildRecursiveRef(stack, context, schema, value) {
2361
+ const target = RecursiveRef(stack, schema) ?? false;
2362
+ return CreateFunction(target ? {
2363
+ ...stack,
2364
+ pendingResource: true
2365
+ } : stack, context, target, value);
2366
+ }
2367
+ function CheckRecursiveRef(stack, context, schema, value) {
2368
+ const target = RecursiveRef(stack, schema) ?? false;
2369
+ const nextStack = target ? {
2370
+ ...stack,
2371
+ pendingResource: true
2372
+ } : stack;
2373
+ return IsSchema(target) && CheckSchema(nextStack, context, target, value);
2374
+ }
2375
+ function ErrorRecursiveRef(stack, context, schemaPath, instancePath, schema, value) {
2376
+ const target = RecursiveRef(stack, schema) ?? false;
2377
+ const nextStack = target ? {
2378
+ ...stack,
2379
+ pendingResource: true
2380
+ } : stack;
2381
+ return IsSchema(target) && ErrorSchema(nextStack, context, schemaPath, instancePath, target, value);
2382
+ }
2383
+ // ../../node_modules/.pnpm/typebox@1.4.3/node_modules/typebox/build/schema/engine/ref.mjs
2384
+ function BuildRefStandard(stack, context, target, value) {
2385
+ const interior = ArrowFunction(["context", "value"], CreateFunction(stack, context, target, "value"));
2386
+ return Call(ArrowFunction(["context", "value"], Statements([
2387
+ ConstDeclaration("nextContext", New("CheckContext", [])),
2388
+ ConstDeclaration("result", Call(interior, ["nextContext", "value"])),
2389
+ If("result", context.Merge("[nextContext]")),
2390
+ Return("result")
2391
+ ])), ["context", value]);
2392
+ }
2393
+ function BuildRefFast(stack, context, target, value) {
2394
+ return CreateFunction(stack, context, target, value);
2395
+ }
2396
+ function BuildRef(stack, context, schema, value) {
2397
+ const result = Ref(stack, schema);
2398
+ const target = result.schema ?? false;
2399
+ return context.UseUnevaluated() ? BuildRefStandard(result.stack, context, target, value) : BuildRefFast(result.stack, context, target, value);
2400
+ }
2401
+ function CheckRef(stack, context, schema, value) {
2402
+ const result = Ref(stack, schema);
2403
+ const target = result.schema ?? false;
2404
+ const nextContext = new CheckContext();
2405
+ const valid = IsSchema(target) && CheckSchema(result.stack, nextContext, target, value);
2406
+ if (valid) context.Merge([nextContext]);
2407
+ return valid;
2408
+ }
2409
+ function ErrorRef(stack, context, schemaPath, instancePath, schema, value) {
2410
+ const result = Ref(stack, schema);
2411
+ const target = result.schema ?? false;
2412
+ const nextContext = new ErrorContext();
2413
+ const valid = IsSchema(target) && ErrorSchema(result.stack, nextContext, schemaPath, instancePath, target, value);
2414
+ if (valid) context.Merge([nextContext]);
2415
+ if (!valid) context.AddErrors(nextContext.GetErrors());
2416
+ return valid;
2417
+ }
2418
+ // ../../node_modules/.pnpm/typebox@1.4.3/node_modules/typebox/build/schema/engine/required.mjs
2419
+ function BuildRequired(_stack, _context, schema, value) {
2420
+ return ReduceAnd(schema.required.map((key) => HasPropertyKey(value, Constant(key))));
2421
+ }
2422
+ function CheckRequired(_stack, _context, schema, value) {
2423
+ return Every$1(schema.required, 0, (key) => HasPropertyKey$1(value, key));
2424
+ }
2425
+ function ErrorRequired(_stack, context, schemaPath, instancePath, schema, value) {
2426
+ const requiredProperties = [];
2427
+ return EveryAll(schema.required, 0, (key) => {
2428
+ const hasKey = HasPropertyKey$1(value, key);
2429
+ if (!hasKey) requiredProperties.push(key);
2430
+ return hasKey;
2431
+ }) || context.AddError("required", schemaPath, instancePath, { requiredProperties });
2432
+ }
2433
+ // ../../node_modules/.pnpm/typebox@1.4.3/node_modules/typebox/build/schema/engine/type.mjs
2434
+ function BuildTypeName(_stack, _context, type, value) {
2435
+ return IsEqual$1(type, "object") ? IsObjectNotArray(value) : IsEqual$1(type, "array") ? IsArray(value) : IsEqual$1(type, "boolean") ? IsBoolean(value) : IsEqual$1(type, "integer") ? IsInteger(value) : IsEqual$1(type, "number") ? IsNumber(value) : IsEqual$1(type, "null") ? IsNull(value) : IsEqual$1(type, "string") ? IsString(value) : IsEqual$1(type, "bigint") ? IsBigInt(value) : IsEqual$1(type, "constructor") ? IsConstructor(value) : IsEqual$1(type, "function") ? IsFunction(value) : IsEqual$1(type, "symbol") ? IsSymbol(value) : IsEqual$1(type, "undefined") ? IsUndefined(value) : IsEqual$1(type, "void") ? IsUndefined(value) : Constant(true);
2436
+ }
2437
+ function CheckTypeName(_stack, _context, type, _schema, value) {
2438
+ return IsEqual$1(type, "object") ? IsObjectNotArray$1(value) : IsEqual$1(type, "array") ? IsArray$1(value) : IsEqual$1(type, "boolean") ? IsBoolean$1(value) : IsEqual$1(type, "integer") ? IsInteger$1(value) : IsEqual$1(type, "number") ? IsNumber$1(value) : IsEqual$1(type, "null") ? IsNull$1(value) : IsEqual$1(type, "string") ? IsString$1(value) : IsEqual$1(type, "bigint") ? IsBigInt$1(value) : IsEqual$1(type, "constructor") ? IsConstructor$1(value) : IsEqual$1(type, "function") ? IsFunction$1(value) : IsEqual$1(type, "symbol") ? IsSymbol$1(value) : IsEqual$1(type, "undefined") ? IsUndefined$1(value) : IsEqual$1(type, "void") ? IsUndefined$1(value) : true;
2439
+ }
2440
+ function BuildTypeNames(stack, context, typenames, value) {
2441
+ return ReduceOr(typenames.map((type) => BuildTypeName(stack, context, type, value)));
2442
+ }
2443
+ function CheckTypeNames(stack, context, types, schema, value) {
2444
+ return Some$1(types, (type) => CheckTypeName(stack, context, type, schema, value));
2445
+ }
2446
+ function BuildType(stack, context, schema, value) {
2447
+ return IsArray$1(schema.type) ? BuildTypeNames(stack, context, schema.type, value) : BuildTypeName(stack, context, schema.type, value);
2448
+ }
2449
+ function CheckType(stack, context, schema, value) {
2450
+ return IsArray$1(schema.type) ? CheckTypeNames(stack, context, schema.type, schema, value) : CheckTypeName(stack, context, schema.type, schema, value);
2451
+ }
2452
+ function ErrorType(stack, context, schemaPath, instancePath, schema, value) {
2453
+ return (IsArray$1(schema.type) ? CheckTypeNames(stack, context, schema.type, schema, value) : CheckTypeName(stack, context, schema.type, schema, value)) || context.AddError("type", schemaPath, instancePath, { type: schema.type });
2454
+ }
2455
+ // ../../node_modules/.pnpm/typebox@1.4.3/node_modules/typebox/build/schema/engine/unevaluatedItems.mjs
2456
+ function BuildUnevaluatedItems(stack, context, schema, value) {
2457
+ const [index, item] = [CreateUnique(), CreateUnique()];
2458
+ const indices = Call(Member("context", "GetIndices"), []);
2459
+ const hasIndex = Call(Member("indices", "has"), [index]);
2460
+ const isSchema = BuildSchema(stack, context, schema.unevaluatedItems, item);
2461
+ const addIndex = Call(Member("context", "AddIndex"), [index]);
2462
+ const isEvery = Every(value, Constant(0), [item, index], And(Or(hasIndex, isSchema), addIndex));
2463
+ return Call(ArrowFunction(["context"], Statements([ConstDeclaration("indices", indices), Return(isEvery)])), ["context"]);
2464
+ }
2465
+ function CheckUnevaluatedItems(stack, context, schema, value) {
2466
+ const indices = context.GetIndices();
2467
+ return Every$1(value, 0, (item, index) => {
2468
+ return (indices.has(index) || CheckSchema(stack, context, schema.unevaluatedItems, item)) && context.AddIndex(index);
2469
+ });
2470
+ }
2471
+ function ErrorUnevaluatedItems(stack, context, schemaPath, instancePath, schema, value) {
2472
+ const indices = context.GetIndices();
2473
+ const unevaluatedItems = [];
2474
+ return EveryAll(value, 0, (item, index) => {
2475
+ const nextContext = new ErrorContext();
2476
+ const isEvaluatedItem = (indices.has(index) || ErrorSchema(stack, nextContext, schemaPath, instancePath, schema.unevaluatedItems, item)) && context.AddIndex(index);
2477
+ if (!isEvaluatedItem) unevaluatedItems.push(index);
2478
+ return isEvaluatedItem;
2479
+ }) || context.AddError("unevaluatedItems", schemaPath, instancePath, { unevaluatedItems });
2480
+ }
2481
+ // ../../node_modules/.pnpm/typebox@1.4.3/node_modules/typebox/build/schema/engine/unevaluatedProperties.mjs
2482
+ function BuildUnevaluatedProperties(stack, context, schema, value) {
2483
+ const [key, prop] = [CreateUnique(), CreateUnique()];
2484
+ const keys = Call(Member("context", "GetKeys"), []);
2485
+ const hasKey = Call(Member("keys", "has"), [key]);
2486
+ const addKey = Call(Member("context", "AddKey"), [key]);
2487
+ const isSchema = BuildSchema(stack, context, schema.unevaluatedProperties, prop);
2488
+ const isEvery = Every(Entries(value), Constant(0), [`[${key}, ${prop}]`, "_"], Or(hasKey, And(isSchema, addKey)));
2489
+ return Call(ArrowFunction(["context"], Statements([ConstDeclaration("keys", keys), Return(isEvery)])), ["context"]);
2490
+ }
2491
+ function CheckUnevaluatedProperties(stack, context, schema, value) {
2492
+ const keys = context.GetKeys();
2493
+ return Every$1(Entries$1(value), 0, ([key, prop]) => {
2494
+ return keys.has(key) || CheckSchema(stack, context, schema.unevaluatedProperties, prop) && context.AddKey(key);
2495
+ });
2496
+ }
2497
+ function ErrorUnevaluatedProperties(stack, context, schemaPath, instancePath, schema, value) {
2498
+ const keys = context.GetKeys();
2499
+ const unevaluatedProperties = [];
2500
+ return EveryAll(Entries$1(value), 0, ([key, prop]) => {
2501
+ const nextContext = new ErrorContext();
2502
+ const isEvaluatedProperty = keys.has(key) || ErrorSchema(stack, nextContext, schemaPath, instancePath, schema.unevaluatedProperties, prop) && context.AddKey(key);
2503
+ if (!isEvaluatedProperty) unevaluatedProperties.push(key);
2504
+ return isEvaluatedProperty;
2505
+ }) || context.AddError("unevaluatedProperties", schemaPath, instancePath, { unevaluatedProperties });
2506
+ }
2507
+ // ../../node_modules/.pnpm/typebox@1.4.3/node_modules/typebox/build/schema/engine/uniqueItems.mjs
2508
+ function IsValid(schema) {
2509
+ return !IsEqual$1(schema.uniqueItems, false);
2510
+ }
2511
+ function BuildUniqueItems(_stack, _context, schema, value) {
2512
+ if (!IsValid(schema)) return Constant(true);
2513
+ return IsEqual(Member(New("Set", [Call(Member(value, "map"), [Member("Hashing", "Hash")])]), "size"), Member(value, "length"));
2514
+ }
2515
+ function CheckUniqueItems(_stack, _context, schema, value) {
2516
+ if (!IsValid(schema)) return true;
2517
+ const set = new Set(value.map(Hash)).size;
2518
+ const isLength = value.length;
2519
+ return IsEqual$1(set, isLength);
2520
+ }
2521
+ function ErrorUniqueItems(_stack, context, schemaPath, instancePath, schema, value) {
2522
+ if (!IsValid(schema)) return true;
2523
+ const set = /* @__PURE__ */ new Set();
2524
+ const duplicateItems = value.reduce((result, value, index) => {
2525
+ const hash = Hash(value);
2526
+ if (set.has(hash)) return [...result, index];
2527
+ set.add(hash);
2528
+ return result;
2529
+ }, []);
2530
+ return IsEqual$1(duplicateItems.length, 0) || context.AddError("uniqueItems", schemaPath, instancePath, { duplicateItems });
2531
+ }
2532
+ // ../../node_modules/.pnpm/typebox@1.4.3/node_modules/typebox/build/schema/engine/schema.mjs
2533
+ function HasTypeName(schema, typename) {
2534
+ return IsType(schema) && (IsArray$1(schema.type) && IsGreaterThan$1(schema.type.length, 0) && Every$1(schema.type, 0, (type) => IsEqual$1(type, typename)) || IsEqual$1(schema.type, typename));
2535
+ }
2536
+ function HasObjectType(schema) {
2537
+ return HasTypeName(schema, "object");
2538
+ }
2539
+ function HasObjectKeywords(schema) {
2540
+ return IsSchemaObject$1(schema) && (IsAdditionalProperties(schema) || IsDependencies(schema) || IsDependentRequired(schema) || IsDependentSchemas(schema) || IsProperties(schema) || IsPatternProperties(schema) || IsPropertyNames(schema) || IsMinProperties(schema) || IsMaxProperties(schema) || IsRequired(schema) || IsUnevaluatedProperties(schema));
2541
+ }
2542
+ function HasArrayType(schema) {
2543
+ return HasTypeName(schema, "array");
2544
+ }
2545
+ function HasArrayKeywords(schema) {
2546
+ return IsSchemaObject$1(schema) && (IsAdditionalItems(schema) || IsItems(schema) || IsContains(schema) || IsMaxContains(schema) || IsMaxItems(schema) || IsMinContains(schema) || IsMinItems(schema) || IsPrefixItems(schema) || IsUnevaluatedItems(schema) || IsUniqueItems(schema));
2547
+ }
2548
+ function HasStringType(schema) {
2549
+ return HasTypeName(schema, "string");
2550
+ }
2551
+ function HasStringKeywords(schema) {
2552
+ return IsSchemaObject$1(schema) && (IsMinLength(schema) || IsMaxLength(schema) || IsFormat(schema) || IsPattern(schema));
2553
+ }
2554
+ function HasNumberType(schema) {
2555
+ return HasTypeName(schema, "number") || HasTypeName(schema, "bigint");
2556
+ }
2557
+ function HasNumberKeywords(schema) {
2558
+ return IsSchemaObject$1(schema) && (IsMinimum(schema) || IsMaximum(schema) || IsExclusiveMaximum(schema) || IsExclusiveMinimum(schema) || IsMultipleOf(schema));
2559
+ }
2560
+ function BuildSchemaPushStack(stack, context, schema, value) {
2561
+ return context.UseUnevaluated() ? And(And(context.Push(), BuildSchema(stack, context, schema, value)), context.Pop()) : BuildSchema(stack, context, schema, value);
2562
+ }
2563
+ function BuildSchema(stack, context, schema, value) {
2564
+ const current = NextStack(stack, schema);
2565
+ const conditions = [];
2566
+ if (IsSchemaBoolean(schema)) return BuildSchemaBoolean(current, context, schema, value);
2567
+ if (IsType(schema)) conditions.push(BuildType(current, context, schema, value));
2568
+ if (HasObjectKeywords(schema)) {
2569
+ const constraints = [];
2570
+ if (IsRequired(schema)) constraints.push(BuildRequired(current, context, schema, value));
2571
+ if (IsAdditionalProperties(schema)) constraints.push(BuildAdditionalProperties(current, context, schema, value));
2572
+ if (IsDependencies(schema)) constraints.push(BuildDependencies(current, context, schema, value));
2573
+ if (IsDependentRequired(schema)) constraints.push(BuildDependentRequired(current, context, schema, value));
2574
+ if (IsDependentSchemas(schema)) constraints.push(BuildDependentSchemas(current, context, schema, value));
2575
+ if (IsPatternProperties(schema)) constraints.push(BuildPatternProperties(current, context, schema, value));
2576
+ if (IsProperties(schema)) constraints.push(BuildProperties(current, context, schema, value));
2577
+ if (IsPropertyNames(schema)) constraints.push(BuildPropertyNames(current, context, schema, value));
2578
+ if (IsMinProperties(schema)) constraints.push(BuildMinProperties(current, context, schema, value));
2579
+ if (IsMaxProperties(schema)) constraints.push(BuildMaxProperties(current, context, schema, value));
2580
+ const reduced = ReduceAnd(constraints);
2581
+ const guarded = Or(Not(IsObjectNotArray(value)), reduced);
2582
+ conditions.push(HasObjectType(schema) ? reduced : guarded);
2583
+ }
2584
+ if (HasArrayKeywords(schema)) {
2585
+ const constraints = [];
2586
+ if (IsAdditionalItems(schema)) constraints.push(BuildAdditionalItems(current, context, schema, value));
2587
+ if (IsContains(schema)) constraints.push(BuildContains(current, context, schema, value));
2588
+ if (IsItems(schema)) constraints.push(BuildItems(current, context, schema, value));
2589
+ if (IsMinContains(schema)) constraints.push(BuildMinContains(current, context, schema, value));
2590
+ if (IsMaxContains(schema)) constraints.push(BuildMaxContains(current, context, schema, value));
2591
+ if (IsMinItems(schema)) constraints.push(BuildMinItems(current, context, schema, value));
2592
+ if (IsMaxItems(schema)) constraints.push(BuildMaxItems(current, context, schema, value));
2593
+ if (IsPrefixItems(schema)) constraints.push(BuildPrefixItems(current, context, schema, value));
2594
+ if (IsUniqueItems(schema)) constraints.push(BuildUniqueItems(current, context, schema, value));
2595
+ const reduced = ReduceAnd(constraints);
2596
+ const guarded = Or(Not(IsArray(value)), reduced);
2597
+ conditions.push(HasArrayType(schema) ? reduced : guarded);
2598
+ }
2599
+ if (HasStringKeywords(schema)) {
2600
+ const constraints = [];
2601
+ if (IsMinLength(schema)) constraints.push(BuildMinLength(current, context, schema, value));
2602
+ if (IsMaxLength(schema)) constraints.push(BuildMaxLength(current, context, schema, value));
2603
+ if (IsFormat(schema)) constraints.push(BuildFormat(current, context, schema, value));
2604
+ if (IsPattern(schema)) constraints.push(BuildPattern(current, context, schema, value));
2605
+ const reduced = ReduceAnd(constraints);
2606
+ const guarded = Or(Not(IsString(value)), reduced);
2607
+ conditions.push(HasStringType(schema) ? reduced : guarded);
2608
+ }
2609
+ if (HasNumberKeywords(schema)) {
2610
+ const constraints = [];
2611
+ if (IsExclusiveMinimum(schema)) constraints.push(BuildExclusiveMinimum(current, context, schema, value));
2612
+ if (IsExclusiveMaximum(schema)) constraints.push(BuildExclusiveMaximum(current, context, schema, value));
2613
+ if (IsMinimum(schema)) constraints.push(BuildMinimum(current, context, schema, value));
2614
+ if (IsMaximum(schema)) constraints.push(BuildMaximum(current, context, schema, value));
2615
+ if (IsMultipleOf(schema)) constraints.push(BuildMultipleOf(current, context, schema, value));
2616
+ const reduced = ReduceAnd(constraints);
2617
+ const guarded = Or(Not(Or(IsNumber(value), IsBigInt(value))), reduced);
2618
+ conditions.push(HasNumberType(schema) ? reduced : guarded);
2619
+ }
2620
+ if (IsRef(schema)) conditions.push(BuildRef(current, context, schema, value));
2621
+ if (IsRecursiveRef(schema)) conditions.push(BuildRecursiveRef(current, context, schema, value));
2622
+ if (IsDynamicRef(schema)) conditions.push(BuildDynamicRef(current, context, schema, value));
2623
+ if (IsConst(schema)) conditions.push(BuildConst(current, context, schema, value));
2624
+ if (IsEnum(schema)) conditions.push(BuildEnum(current, context, schema, value));
2625
+ if (IsIf(schema)) conditions.push(BuildIf(current, context, schema, value));
2626
+ if (IsNot(schema)) conditions.push(BuildNot(current, context, schema, value));
2627
+ if (IsAllOf(schema)) conditions.push(BuildAllOf(current, context, schema, value));
2628
+ if (IsAnyOf(schema)) conditions.push(BuildAnyOf(current, context, schema, value));
2629
+ if (IsOneOf(schema)) conditions.push(BuildOneOf(current, context, schema, value));
2630
+ if (IsUnevaluatedItems(schema)) conditions.push(Or(Not(IsArray(value)), BuildUnevaluatedItems(current, context, schema, value)));
2631
+ if (IsUnevaluatedProperties(schema)) conditions.push(Or(Not(IsObject(value)), BuildUnevaluatedProperties(current, context, schema, value)));
2632
+ if (IsRefine(schema)) conditions.push(BuildRefine(current, context, schema, value));
2633
+ return ReduceAnd(conditions);
2634
+ }
2635
+ function CheckSchemaPushStack(stack, context, schema, value) {
2636
+ return context.Push() && CheckSchema(stack, context, schema, value) && context.Pop();
2637
+ }
2638
+ function CheckSchema(stack, context, schema, value) {
2639
+ const current = NextStack(stack, schema);
2640
+ return IsSchemaBoolean(schema) ? CheckSchemaBoolean(current, context, schema, value) : (!IsType(schema) || CheckType(current, context, schema, value)) && (!(IsObject$1(value) && !IsArray$1(value)) || (!IsRequired(schema) || CheckRequired(current, context, schema, value)) && (!IsAdditionalProperties(schema) || CheckAdditionalProperties(current, context, schema, value)) && (!IsDependencies(schema) || CheckDependencies(current, context, schema, value)) && (!IsDependentRequired(schema) || CheckDependentRequired(current, context, schema, value)) && (!IsDependentSchemas(schema) || CheckDependentSchemas(current, context, schema, value)) && (!IsPatternProperties(schema) || CheckPatternProperties(current, context, schema, value)) && (!IsProperties(schema) || CheckProperties(current, context, schema, value)) && (!IsPropertyNames(schema) || CheckPropertyNames(current, context, schema, value)) && (!IsMinProperties(schema) || CheckMinProperties(current, context, schema, value)) && (!IsMaxProperties(schema) || CheckMaxProperties(current, context, schema, value))) && (!IsArray$1(value) || (!IsAdditionalItems(schema) || CheckAdditionalItems(current, context, schema, value)) && (!IsContains(schema) || CheckContains(current, context, schema, value)) && (!IsItems(schema) || CheckItems(current, context, schema, value)) && (!IsMinContains(schema) || CheckMinContains(current, context, schema, value)) && (!IsMaxContains(schema) || CheckMaxContains(current, context, schema, value)) && (!IsMinItems(schema) || CheckMinItems(current, context, schema, value)) && (!IsMaxItems(schema) || CheckMaxItems(current, context, schema, value)) && (!IsPrefixItems(schema) || CheckPrefixItems(current, context, schema, value)) && (!IsUniqueItems(schema) || CheckUniqueItems(current, context, schema, value))) && (!IsString$1(value) || (!IsMinLength(schema) || CheckMinLength(current, context, schema, value)) && (!IsMaxLength(schema) || CheckMaxLength(current, context, schema, value)) && (!IsFormat(schema) || CheckFormat(current, context, schema, value)) && (!IsPattern(schema) || CheckPattern(current, context, schema, value))) && (!(IsNumber$1(value) || IsBigInt$1(value)) || (!IsExclusiveMinimum(schema) || CheckExclusiveMinimum(current, context, schema, value)) && (!IsExclusiveMaximum(schema) || CheckExclusiveMaximum(current, context, schema, value)) && (!IsMinimum(schema) || CheckMinimum(current, context, schema, value)) && (!IsMaximum(schema) || CheckMaximum(current, context, schema, value)) && (!IsMultipleOf(schema) || CheckMultipleOf(current, context, schema, value))) && (!IsRef(schema) || CheckRef(current, context, schema, value)) && (!IsRecursiveRef(schema) || CheckRecursiveRef(current, context, schema, value)) && (!IsDynamicRef(schema) || CheckDynamicRef(current, context, schema, value)) && (!IsConst(schema) || CheckConst(current, context, schema, value)) && (!IsEnum(schema) || CheckEnum(current, context, schema, value)) && (!IsIf(schema) || CheckIf(current, context, schema, value)) && (!IsNot(schema) || CheckNot(current, context, schema, value)) && (!IsAllOf(schema) || CheckAllOf(current, context, schema, value)) && (!IsAnyOf(schema) || CheckAnyOf(current, context, schema, value)) && (!IsOneOf(schema) || CheckOneOf(current, context, schema, value)) && (!IsUnevaluatedItems(schema) || !IsArray$1(value) || CheckUnevaluatedItems(current, context, schema, value)) && (!IsUnevaluatedProperties(schema) || !IsObject$1(value) || CheckUnevaluatedProperties(current, context, schema, value)) && (!IsRefine(schema) || CheckRefine(current, context, schema, value));
2641
+ }
2642
+ function ErrorSchemaPushStack(stack, context, schemaPath, instancePath, schema, value) {
2643
+ return context.Push() && ErrorSchema(stack, context, schemaPath, instancePath, schema, value) && context.Pop();
2644
+ }
2645
+ function ErrorSchema(stack, context, schemaPath, instancePath, schema, value) {
2646
+ if (context.AtCapacity()) return false;
2647
+ const current = NextStack(stack, schema);
2648
+ return IsSchemaBoolean(schema) ? ErrorSchemaBoolean(current, context, schemaPath, instancePath, schema, value) : !!(+(!IsType(schema) || ErrorType(current, context, schemaPath, instancePath, schema, value)) & +(!(IsObject$1(value) && !IsArray$1(value)) || !!(+(!IsRequired(schema) || ErrorRequired(current, context, schemaPath, instancePath, schema, value)) & +(!IsAdditionalProperties(schema) || ErrorAdditionalProperties(current, context, schemaPath, instancePath, schema, value)) & +(!IsDependencies(schema) || ErrorDependencies(current, context, schemaPath, instancePath, schema, value)) & +(!IsDependentRequired(schema) || ErrorDependentRequired(current, context, schemaPath, instancePath, schema, value)) & +(!IsDependentSchemas(schema) || ErrorDependentSchemas(current, context, schemaPath, instancePath, schema, value)) & +(!IsPatternProperties(schema) || ErrorPatternProperties(current, context, schemaPath, instancePath, schema, value)) & +(!IsProperties(schema) || ErrorProperties(current, context, schemaPath, instancePath, schema, value)) & +(!IsPropertyNames(schema) || ErrorPropertyNames(current, context, schemaPath, instancePath, schema, value)) & +(!IsMinProperties(schema) || ErrorMinProperties(current, context, schemaPath, instancePath, schema, value)) & +(!IsMaxProperties(schema) || ErrorMaxProperties(current, context, schemaPath, instancePath, schema, value)))) & +(!IsArray$1(value) || !!(+(!IsAdditionalItems(schema) || ErrorAdditionalItems(current, context, schemaPath, instancePath, schema, value)) & +(!IsContains(schema) || ErrorContains(current, context, schemaPath, instancePath, schema, value)) & +(!IsItems(schema) || ErrorItems(current, context, schemaPath, instancePath, schema, value)) & +(!IsMinContains(schema) || ErrorMinContains(current, context, schemaPath, instancePath, schema, value)) & +(!IsMaxContains(schema) || ErrorMaxContains(current, context, schemaPath, instancePath, schema, value)) & +(!IsMinItems(schema) || ErrorMinItems(current, context, schemaPath, instancePath, schema, value)) & +(!IsMaxItems(schema) || ErrorMaxItems(current, context, schemaPath, instancePath, schema, value)) & +(!IsPrefixItems(schema) || ErrorPrefixItems(current, context, schemaPath, instancePath, schema, value)) & +(!IsUniqueItems(schema) || ErrorUniqueItems(current, context, schemaPath, instancePath, schema, value)))) & +(!IsString$1(value) || !!(+(!IsMinLength(schema) || ErrorMinLength(current, context, schemaPath, instancePath, schema, value)) & +(!IsMaxLength(schema) || ErrorMaxLength(current, context, schemaPath, instancePath, schema, value)) & +(!IsFormat(schema) || ErrorFormat(current, context, schemaPath, instancePath, schema, value)) & +(!IsPattern(schema) || ErrorPattern(current, context, schemaPath, instancePath, schema, value)))) & +(!(IsNumber$1(value) || IsBigInt$1(value)) || !!(+(!IsExclusiveMinimum(schema) || ErrorExclusiveMinimum(current, context, schemaPath, instancePath, schema, value)) & +(!IsExclusiveMaximum(schema) || ErrorExclusiveMaximum(current, context, schemaPath, instancePath, schema, value)) & +(!IsMinimum(schema) || ErrorMinimum(current, context, schemaPath, instancePath, schema, value)) & +(!IsMaximum(schema) || ErrorMaximum(current, context, schemaPath, instancePath, schema, value)) & +(!IsMultipleOf(schema) || ErrorMultipleOf(current, context, schemaPath, instancePath, schema, value)))) & +(!IsRef(schema) || ErrorRef(current, context, schemaPath, instancePath, schema, value)) & +(!IsRecursiveRef(schema) || ErrorRecursiveRef(current, context, schemaPath, instancePath, schema, value)) & +(!IsDynamicRef(schema) || ErrorDynamicRef(current, context, schemaPath, instancePath, schema, value)) & +(!IsConst(schema) || ErrorConst(current, context, schemaPath, instancePath, schema, value)) & +(!IsEnum(schema) || ErrorEnum(current, context, schemaPath, instancePath, schema, value)) & +(!IsIf(schema) || ErrorIf(current, context, schemaPath, instancePath, schema, value)) & +(!IsNot(schema) || ErrorNot(current, context, schemaPath, instancePath, schema, value)) & +(!IsAllOf(schema) || ErrorAllOf(current, context, schemaPath, instancePath, schema, value)) & +(!IsAnyOf(schema) || ErrorAnyOf(current, context, schemaPath, instancePath, schema, value)) & +(!IsOneOf(schema) || ErrorOneOf(current, context, schemaPath, instancePath, schema, value)) & +(!IsUnevaluatedItems(schema) || !IsArray$1(value) || ErrorUnevaluatedItems(current, context, schemaPath, instancePath, schema, value)) & +(!IsUnevaluatedProperties(schema) || !IsObject$1(value) || ErrorUnevaluatedProperties(current, context, schemaPath, instancePath, schema, value))) && (!IsRefine(schema) || ErrorRefine(current, context, schemaPath, instancePath, schema, value));
2649
+ }
2650
+ // ../../node_modules/.pnpm/typebox@1.4.3/node_modules/typebox/build/schema/engine/_functions.mjs
2651
+ const index = [0];
2652
+ const names = /* @__PURE__ */ new Map();
2653
+ const funcs = /* @__PURE__ */ new Map();
2654
+ function NextName() {
2655
+ return `${index[0]++}`;
2656
+ }
2657
+ function CreateName(schema, href) {
2658
+ if (!names.has(schema)) names.set(schema, /* @__PURE__ */ new Map());
2659
+ const hrefs = names.get(schema);
2660
+ if (hrefs.has(href)) return hrefs.get(href);
2661
+ const name = NextName();
2662
+ hrefs.set(href, name);
2663
+ return name;
2664
+ }
2665
+ function CreateCallExpression(context, _schema, name, value) {
2666
+ return context.UseUnevaluated() ? Call(`check_${name}`, ["context", value]) : Call(`check_${name}`, [value]);
2667
+ }
2668
+ function CreateFunctionExpression(stack, context, schema, name) {
2669
+ const expression = BuildSchema(stack, context, schema, "value");
2670
+ return context.UseUnevaluated() ? ConstDeclaration(`check_${name}`, ArrowFunction(["context", "value"], expression)) : ConstDeclaration(`check_${name}`, ArrowFunction(["value"], expression));
2671
+ }
2672
+ function ResetFunctions() {
2673
+ index[0] = 0;
2674
+ names.clear();
2675
+ funcs.clear();
2676
+ }
2677
+ function GetFunctions() {
2678
+ return [...funcs.values()];
2679
+ }
2680
+ function CreateFunction(stack, context, schema, value) {
2681
+ const name = CreateName(schema, stack.lexicalBase);
2682
+ const call = CreateCallExpression(context, schema, name, value);
2683
+ if (funcs.has(name)) return call;
2684
+ funcs.set(name, "");
2685
+ funcs.set(name, CreateFunctionExpression(stack, context, schema, name));
2686
+ return call;
2687
+ }
2688
+ // ../../node_modules/.pnpm/typebox@1.4.3/node_modules/typebox/build/system/environment/evaluate.mjs
2689
+ let supported = void 0;
2690
+ function TryEvaluate() {
2691
+ try {
2692
+ Evaluate("null")();
2693
+ return true;
2694
+ } catch {
2695
+ return false;
2696
+ }
2697
+ }
2698
+ /** Returns true if the environment supports dynamic JavaScript evaluation */
2699
+ function CanEvaluate() {
2700
+ if (IsUndefined$1(supported)) supported = TryEvaluate();
2701
+ return supported && Get$3().useAcceleration;
2702
+ }
2703
+ /**
2704
+ * Evaluates code in the current environment. This function will throw if the
2705
+ * environment Content-Security-Policy does not support `unsafe-eval`. Use the
2706
+ * Environment.CanEvaluate() to determine if the environment supports Evaluate
2707
+ * before calling this function.
2708
+ */
2709
+ function Evaluate(...args) {
2710
+ return new globalThis.Function(...args);
2711
+ }
2712
+ // ../../node_modules/.pnpm/typebox@1.4.3/node_modules/typebox/build/system/locale/en_US.mjs
2713
+ /** en_US: English (United States) - ISO 639-1 language code 'en' with ISO 3166-1 alpha-2 country code 'US' for United States. */
2714
+ function en_US(error) {
2715
+ switch (error.keyword) {
2716
+ case "additionalProperties": return "must not have additional properties";
2717
+ case "anyOf": return "must match a schema in anyOf";
2718
+ case "boolean": return "schema is false";
2719
+ case "const": return "must be equal to constant";
2720
+ case "contains": return "must contain at least 1 valid item";
2721
+ case "dependencies": return `must have properties ${error.params.dependencies.join(", ")} when property ${error.params.property} is present`;
2722
+ case "dependentRequired": return `must have properties ${error.params.dependencies.join(", ")} when property ${error.params.property} is present`;
2723
+ case "enum": return "must be equal to one of the allowed values";
2724
+ case "exclusiveMaximum": return `must be ${error.params.comparison} ${error.params.limit}`;
2725
+ case "exclusiveMinimum": return `must be ${error.params.comparison} ${error.params.limit}`;
2726
+ case "format": return `must match format "${error.params.format}"`;
2727
+ case "if": return `must match "${error.params.failingKeyword}" schema`;
2728
+ case "maxItems": return `must not have more than ${error.params.limit} items`;
2729
+ case "maxLength": return `must not have more than ${error.params.limit} characters`;
2730
+ case "maxProperties": return `must not have more than ${error.params.limit} properties`;
2731
+ case "maximum": return `must be ${error.params.comparison} ${error.params.limit}`;
2732
+ case "minItems": return `must not have fewer than ${error.params.limit} items`;
2733
+ case "minLength": return `must not have fewer than ${error.params.limit} characters`;
2734
+ case "minProperties": return `must not have fewer than ${error.params.limit} properties`;
2735
+ case "minimum": return `must be ${error.params.comparison} ${error.params.limit}`;
2736
+ case "multipleOf": return `must be multiple of ${error.params.multipleOf}`;
2737
+ case "not": return "must not be valid";
2738
+ case "oneOf": return "must match exactly one schema in oneOf";
2739
+ case "pattern": return `must match pattern "${error.params.pattern}"`;
2740
+ case "propertyNames": return `property names ${error.params.propertyNames.join(", ")} are invalid`;
2741
+ case "required": return `must have required properties ${error.params.requiredProperties.join(", ")}`;
2742
+ case "type": return typeof error.params.type === "string" ? `must be ${error.params.type}` : `must be either ${error.params.type.join(" or ")}`;
2743
+ case "unevaluatedItems": return "must not have unevaluated items";
2744
+ case "unevaluatedProperties": return "must not have unevaluated properties";
2745
+ case "uniqueItems": return `must not have duplicate items`;
2746
+ case "~refine": return error.params.message;
2747
+ default: return "an unknown validation error occurred";
2748
+ }
2749
+ }
2750
+ // ../../node_modules/.pnpm/typebox@1.4.3/node_modules/typebox/build/system/locale/_config.mjs
2751
+ let locale = en_US;
2752
+ /** Gets the locale */
2753
+ function Get() {
2754
+ return locale;
2755
+ }
2756
+ // ../../node_modules/.pnpm/typebox@1.4.3/node_modules/typebox/build/schema/build.mjs
2757
+ function CreateCode(build) {
2758
+ return `${build.Functions().join(";\n")}; return (value) => { ${(build.UseUnevaluated() ? ["const context = new CheckContext({}, {})", `return ${build.Entry()}`] : [`return ${build.Entry()}`]).join("; ")} }`;
2759
+ }
2760
+ function CreateEvaluatedCheck(build, code) {
2761
+ return Evaluate("CheckContext", "Guard", "Hashing", build.External().identifier, code)(CheckContext, guard_exports, hash_exports, build.External().variables);
2762
+ }
2763
+ function CreateDynamicCheck(build) {
2764
+ const stack = Stack(build.Context(), build.Schema());
2765
+ const context = new CheckContext();
2766
+ return (value) => CheckSchema(stack, context, build.Schema(), value);
2767
+ }
2768
+ function CreateCheck(build, code) {
2769
+ return CanEvaluate() ? CreateEvaluatedCheck(build, code) : CreateDynamicCheck(build);
2770
+ }
2771
+ var EvaluateResult = class {
2772
+ constructor(isAccelerated, code, check) {
2773
+ this.isAccelerated = isAccelerated;
2774
+ this.code = code;
2775
+ this.check = check;
2776
+ }
2777
+ IsAccelerated() {
2778
+ return this.isAccelerated;
2779
+ }
2780
+ Code() {
2781
+ return this.code;
2782
+ }
2783
+ Check(value) {
2784
+ return this.check(value);
2785
+ }
2786
+ };
2787
+ var BuildResult = class {
2788
+ constructor(context, schema, external, functions, entry, useUnevaluated) {
2789
+ this.context = context;
2790
+ this.schema = schema;
2791
+ this.external = external;
2792
+ this.functions = functions;
2793
+ this.entry = entry;
2794
+ this.useUnevaluated = useUnevaluated;
2795
+ }
2796
+ /** Returns the Context used for this build */
2797
+ Context() {
2798
+ return this.context;
2799
+ }
2800
+ /** Returns the Schema used for this build */
2801
+ Schema() {
2802
+ return this.schema;
2803
+ }
2804
+ /** Returns true if this build requires a Unevaluated context */
2805
+ UseUnevaluated() {
2806
+ return this.useUnevaluated;
2807
+ }
2808
+ /** Returns external variables */
2809
+ External() {
2810
+ return this.external;
2811
+ }
2812
+ /** Returns check functions */
2813
+ Functions() {
2814
+ return this.functions;
2815
+ }
2816
+ /** Return entry function call. */
2817
+ Entry() {
2818
+ return this.entry;
2819
+ }
2820
+ /** Evaluates the build into a validation function */
2821
+ Evaluate() {
2822
+ const code = CreateCode(this);
2823
+ const check = CreateCheck(this, code);
2824
+ return new EvaluateResult(CanEvaluate(), code, check);
2825
+ }
2826
+ };
2827
+ /** Builds a schema into a optimized runtime validator */
2828
+ function Build(...args) {
2829
+ const [context, schema] = Match$1(args, {
2830
+ 2: (context, schema) => [context, schema],
2831
+ 1: (schema) => [{}, schema]
2832
+ });
2833
+ ResetUnique();
2834
+ ResetExternal();
2835
+ ResetFunctions();
2836
+ const stack = Stack(context, schema);
2837
+ const build = new BuildContext(HasUnevaluated(context, schema));
2838
+ const call = CreateFunction(stack, build, schema, "value");
2839
+ const functions = GetFunctions();
2840
+ return new BuildResult(context, schema, GetExternal(), functions, call, build.UseUnevaluated());
2841
+ }
2842
+ // ../../node_modules/.pnpm/typebox@1.4.3/node_modules/typebox/build/schema/errors.mjs
2843
+ /** Returns an array of validation errors for the given value. */
2844
+ function Errors$1(...args) {
2845
+ const [context, schema, value] = Match$1(args, {
2846
+ 3: (context, schema, value) => [
2847
+ context,
2848
+ schema,
2849
+ value
2850
+ ],
2851
+ 2: (schema, value) => [
2852
+ {},
2853
+ schema,
2854
+ value
2855
+ ]
2856
+ });
2857
+ const stack = Stack(context, schema);
2858
+ const errorContext = new ErrorContext();
2859
+ const result = ErrorSchema(stack, errorContext, "#", "", schema, value);
2860
+ const errors = errorContext.GetErrors();
2861
+ const locale = Get();
2862
+ return [result, errors.map((error) => ({
2863
+ ...error,
2864
+ message: locale(error)
2865
+ }))];
2866
+ }
2867
+ // ../../node_modules/.pnpm/typebox@1.4.3/node_modules/typebox/build/system/settings/internal.mjs
2868
+ let TempMaxErrors = 0;
2869
+ function EnableParseErrors() {
2870
+ const settings = Get$3();
2871
+ TempMaxErrors = settings.maxErrors;
2872
+ settings.maxErrors = settings.maxParseErrors;
2873
+ }
2874
+ function DisableParseErrors() {
2875
+ const settings = Get$3();
2876
+ settings.maxErrors = TempMaxErrors;
2877
+ }
2878
+ // ../../node_modules/.pnpm/typebox@1.4.3/node_modules/typebox/build/schema/check.mjs
2879
+ /** Checks a value against the provided schema */
2880
+ function Check$1(...args) {
2881
+ const [context, schema, value] = Match$1(args, {
2882
+ 3: (context, schema, value) => [
2883
+ context,
2884
+ schema,
2885
+ value
2886
+ ],
2887
+ 2: (schema, value) => [
2888
+ {},
2889
+ schema,
2890
+ value
2891
+ ]
2892
+ });
2893
+ return CheckSchema(Stack(context, schema), new CheckContext(), schema, value);
2894
+ }
2895
+ // ../../node_modules/.pnpm/typebox@1.4.3/node_modules/typebox/build/value/check/check.mjs
2896
+ /** Checks a value matches the provided type. */
2897
+ function Check(...args) {
2898
+ const [context, type, value] = Match$1(args, {
2899
+ 3: (context, type, value) => [
2900
+ context,
2901
+ type,
2902
+ value
2903
+ ],
2904
+ 2: (type, value) => [
2905
+ {},
2906
+ type,
2907
+ value
2908
+ ]
2909
+ });
2910
+ return Check$1(context, type, value);
2911
+ }
2912
+ // ../../node_modules/.pnpm/typebox@1.4.3/node_modules/typebox/build/value/errors/errors.mjs
2913
+ /** Returns an array of validation errors for the given value. */
2914
+ function Errors(...args) {
2915
+ const [context, type, value] = Match$1(args, {
2916
+ 3: (context, type, value) => [
2917
+ context,
2918
+ type,
2919
+ value
2920
+ ],
2921
+ 2: (type, value) => [
2922
+ {},
2923
+ type,
2924
+ value
2925
+ ]
2926
+ });
2927
+ const [_, errors] = Errors$1(context, type, value);
2928
+ return errors;
2929
+ }
2930
+ // ../../node_modules/.pnpm/typebox@1.4.3/node_modules/typebox/build/value/assert/assert.mjs
2931
+ var AssertError = class extends Error {
2932
+ constructor(source, value, errors) {
2933
+ super(source);
2934
+ Object.defineProperty(this, "cause", {
2935
+ value: {
2936
+ source,
2937
+ errors,
2938
+ value
2939
+ },
2940
+ writable: false,
2941
+ configurable: false,
2942
+ enumerable: false
2943
+ });
2944
+ }
2945
+ };
2946
+ // ../../node_modules/.pnpm/typebox@1.4.3/node_modules/typebox/build/value/clean/from_array.mjs
2947
+ function FromArray$6(context, type, value) {
2948
+ if (!IsArray$1(value)) return value;
2949
+ return value.map((value) => FromType$6(context, type.items, value));
2950
+ }
2951
+ // ../../node_modules/.pnpm/typebox@1.4.3/node_modules/typebox/build/value/clean/from_cyclic.mjs
2952
+ function FromCyclic$5(context, type, value) {
2953
+ return FromType$6({
2954
+ ...context,
2955
+ ...type.$defs
2956
+ }, Ref$1(type.$ref), value);
2957
+ }
2958
+ // ../../node_modules/.pnpm/typebox@1.4.3/node_modules/typebox/build/value/clean/from_intersect.mjs
2959
+ function EvaluateIntersection(context, type) {
2960
+ const additionalProperties = HasPropertyKey$1(type, "unevaluatedProperties") ? { additionalProperties: type.unevaluatedProperties } : {};
2961
+ const instantiated = Instantiate(context, type);
2962
+ const evaluated = Evaluate$1(instantiated);
2963
+ return IsObject$2(evaluated) ? With(evaluated, additionalProperties) : evaluated;
2964
+ }
2965
+ function FromIntersect$5(context, type, value) {
2966
+ return FromType$6(context, EvaluateIntersection(context, type), value);
2967
+ }
2968
+ // ../../node_modules/.pnpm/typebox@1.4.3/node_modules/typebox/build/value/clean/additional.mjs
2969
+ function GetAdditionalProperties(type) {
2970
+ return HasPropertyKey$1(type, "additionalProperties") ? type.additionalProperties : void 0;
2971
+ }
2972
+ // ../../node_modules/.pnpm/typebox@1.4.3/node_modules/typebox/build/value/clean/from_object.mjs
2973
+ function FromObject$6(context, type, value) {
2974
+ if (!IsObject$1(value) || IsArray$1(value)) return value;
2975
+ const additionalProperties = GetAdditionalProperties(type);
2976
+ for (const key of Keys$1(value)) {
2977
+ if (HasPropertyKey$1(type.properties, key) && IsSchema$1(type.properties[key])) {
2978
+ value[key] = FromType$6(context, type.properties[key], value[key]);
2979
+ continue;
2980
+ }
2981
+ if (IsBoolean$1(additionalProperties) && IsEqual$1(additionalProperties, true) || IsSchema$1(additionalProperties) && Check(context, additionalProperties, value[key])) {
2982
+ value[key] = FromType$6(context, additionalProperties, value[key]);
2983
+ continue;
2984
+ }
2985
+ delete value[key];
2986
+ }
2987
+ return value;
2988
+ }
2989
+ // ../../node_modules/.pnpm/typebox@1.4.3/node_modules/typebox/build/value/clean/from_record.mjs
2990
+ function FromRecord$5(context, type, value) {
2991
+ if (!IsObject$1(value)) return value;
2992
+ const additionalProperties = GetAdditionalProperties(type);
2993
+ const [recordPattern, recordValue] = [new RegExp(RecordPattern(type)), RecordValue(type)];
2994
+ for (const key of Keys$1(value)) {
2995
+ if (recordPattern.test(key)) {
2996
+ value[key] = FromType$6(context, recordValue, value[key]);
2997
+ continue;
2998
+ }
2999
+ if (IsBoolean$1(additionalProperties) && IsEqual$1(additionalProperties, true) || IsSchema$1(additionalProperties) && Check(context, additionalProperties, value[key])) {
3000
+ value[key] = FromType$6(context, additionalProperties, value[key]);
3001
+ continue;
3002
+ }
3003
+ delete value[key];
3004
+ }
3005
+ return value;
3006
+ }
3007
+ // ../../node_modules/.pnpm/typebox@1.4.3/node_modules/typebox/build/value/clean/from_ref.mjs
3008
+ function FromRef$5(context, type, value) {
3009
+ return HasPropertyKey$1(context, type.$ref) ? FromType$6(context, context[type.$ref], value) : value;
3010
+ }
3011
+ // ../../node_modules/.pnpm/typebox@1.4.3/node_modules/typebox/build/value/clean/from_tuple.mjs
3012
+ function FromTuple$5(context, schema, value) {
3013
+ if (!IsArray$1(value)) return value;
3014
+ const length = Math.min(value.length, schema.items.length);
3015
+ for (let index = 0; index < length; index++) value[index] = FromType$6(context, schema.items[index], value[index]);
3016
+ return IsGreaterThan$1(value.length, length) ? value.slice(0, length) : value;
3017
+ }
3018
+ // ../../node_modules/.pnpm/typebox@1.4.3/node_modules/typebox/build/system/memory/deep.mjs
3019
+ function FromClassInstance(value) {
3020
+ return value;
3021
+ }
3022
+ function IsSchemaObject(value) {
3023
+ return HasPropertyKey$1(value, "~kind") || HasPropertyKey$1(value, "~unsafe");
3024
+ }
3025
+ function FromSchemaObject(value) {
3026
+ const result = {};
3027
+ for (const key of Keys$1(value)) {
3028
+ if (IsUnsafePropertyKey(key)) continue;
3029
+ const descriptor = Object.getOwnPropertyDescriptor(value, key);
3030
+ descriptor.value = FromValue(descriptor.value);
3031
+ if (IsEqual$1(descriptor.enumerable, true)) result[key] = descriptor.value;
3032
+ else Object.defineProperty(result, key, descriptor);
3033
+ }
3034
+ return result;
3035
+ }
3036
+ function FromPlainObject(value) {
3037
+ const result = {};
3038
+ for (const key of Keys$1(value)) {
3039
+ if (IsUnsafePropertyKey(key)) continue;
3040
+ result[key] = FromValue(value[key]);
3041
+ }
3042
+ for (const key of Symbols(value)) result[key] = FromValue(value[key]);
3043
+ return result;
3044
+ }
3045
+ function FromObject$5(value) {
3046
+ return IsClassInstance(value) ? FromClassInstance(value) : IsSchemaObject(value) ? FromSchemaObject(value) : FromPlainObject(value);
3047
+ }
3048
+ function FromArray$5(value) {
3049
+ return value.map((element) => FromValue(element));
3050
+ }
3051
+ function FromTypedArray(value) {
3052
+ return value.slice();
3053
+ }
3054
+ function FromRegExp(value) {
3055
+ return new RegExp(value.source, value.flags);
3056
+ }
3057
+ function FromMap(value) {
3058
+ return new Map(FromValue([...value.entries()]));
3059
+ }
3060
+ function FromSet(value) {
3061
+ return new Set(FromValue([...value.values()]));
3062
+ }
3063
+ function FromValue(value) {
3064
+ return IsTypeArray(value) ? FromTypedArray(value) : IsRegExp(value) ? FromRegExp(value) : IsMap(value) ? FromMap(value) : IsSet(value) ? FromSet(value) : IsArray$1(value) ? FromArray$5(value) : IsObject$1(value) ? FromObject$5(value) : value;
3065
+ }
3066
+ /** Returns a deep Clone of the given value. This function is similar to structuredClone() but also supports deep cloning instances of Map, Set and TypeArray. */
3067
+ function Deep(value) {
3068
+ return FromValue(value);
3069
+ }
3070
+ // ../../node_modules/.pnpm/typebox@1.4.3/node_modules/typebox/build/value/clone/clone.mjs
3071
+ /**
3072
+ * Returns a deep Clone of the given value. This function is similar to `structuredClone()`,
3073
+ * but also supports deep cloning `Map`, `Set`, and `TypeArray` instances. This function can also be used
3074
+ * to clone TypeBox types while retaining their enumerable and non-enumerable properties.
3075
+ */
3076
+ function Clone(value) {
3077
+ return Deep(value);
3078
+ }
3079
+ // ../../node_modules/.pnpm/typebox@1.4.3/node_modules/typebox/build/value/clean/from_union.mjs
3080
+ function FromUnion$5(context, type, value) {
3081
+ for (const schema of type.anyOf) {
3082
+ const clean = FromType$6(context, schema, Clone(value));
3083
+ if (Check(context, schema, clean)) return clean;
3084
+ }
3085
+ return value;
3086
+ }
3087
+ // ../../node_modules/.pnpm/typebox@1.4.3/node_modules/typebox/build/value/clean/from_type.mjs
3088
+ function FromType$6(context, type, value) {
3089
+ return IsArray$2(type) ? FromArray$6(context, type, value) : IsCyclic(type) ? FromCyclic$5(context, type, value) : IsIntersect(type) ? FromIntersect$5(context, type, value) : IsObject$2(type) ? FromObject$6(context, type, value) : IsRecord(type) ? FromRecord$5(context, type, value) : IsRef$1(type) ? FromRef$5(context, type, value) : IsTuple(type) ? FromTuple$5(context, type, value) : IsUnion(type) ? FromUnion$5(context, type, value) : value;
3090
+ }
3091
+ // ../../node_modules/.pnpm/typebox@1.4.3/node_modules/typebox/build/value/shared/union_priority_sort.mjs
3092
+ function Modifiers(type, next) {
3093
+ return Assign(type, next);
3094
+ }
3095
+ function FromProperties$1(properties) {
3096
+ const result = {};
3097
+ for (const key of guard_default.Keys(properties)) result[key] = FromType$5(properties[key]);
3098
+ return result;
3099
+ }
3100
+ function FromRecordKey(type) {
3101
+ return String$1({ pattern: RecordPattern(type) });
3102
+ }
3103
+ function FromPriorityTypes(types) {
3104
+ return FromTypes(Priority(types));
3105
+ }
3106
+ function FromTypes(types) {
3107
+ return types.map((type) => FromType$5(type));
3108
+ }
3109
+ function FromType$5(type) {
3110
+ return Modifiers(type, IsArray$2(type) ? _Array_(FromType$5(type.items), ArrayOptions(type)) : IsIntersect(type) ? Intersect(FromTypes(type.allOf)) : IsUnion(type) ? Union(FromPriorityTypes(type.anyOf)) : IsObject$2(type) ? _Object_(FromProperties$1(type.properties)) : IsRecord(type) ? Record(FromRecordKey(type), FromType$5(RecordValue(type))) : IsTuple(type) ? Tuple(FromTypes(type.items)) : type);
3111
+ }
3112
+ /**
3113
+ * (Type-Preprocessor) Recursively reorders Union variants from narrowest to broadest, ensuring
3114
+ * more specific types (e.g. Literal) are evaluated before broader types (e.g. String). Used
3115
+ * prior to Clean, Decode, and Encode operations.
3116
+ */
3117
+ function UnionPrioritySort(type) {
3118
+ return FromType$5(type);
3119
+ }
3120
+ // ../../node_modules/.pnpm/typebox@1.4.3/node_modules/typebox/build/value/clean/clean.mjs
3121
+ /**
3122
+ * Cleans a value by removing non-evaluated properties and elements as derived from the provided type.
3123
+ * This function returns unknown so callers should Check the return value before use. This function
3124
+ * mutates the provided value. If mutation is not wanted, you should Clone the value before passing
3125
+ * to this function.
3126
+ */
3127
+ function Clean(...args) {
3128
+ const [context, type, value] = Match$1(args, {
3129
+ 3: (context, type, value) => [
3130
+ context,
3131
+ type,
3132
+ value
3133
+ ],
3134
+ 2: (type, value) => [
3135
+ {},
3136
+ type,
3137
+ value
3138
+ ]
3139
+ });
3140
+ return FromType$6(context, Get$3().unionPrioritySort ? UnionPrioritySort(type) : type, value);
3141
+ }
3142
+ // ../../node_modules/.pnpm/typebox@1.4.3/node_modules/typebox/build/value/convert/try/try_result.mjs
3143
+ function IsOk(value) {
3144
+ return IsObject$1(value) && HasPropertyKey$1(value, "value");
3145
+ }
3146
+ function Ok(value) {
3147
+ return { value };
3148
+ }
3149
+ // ../../node_modules/.pnpm/typebox@1.4.3/node_modules/typebox/build/value/convert/try/try_array.mjs
3150
+ function TryArray(value) {
3151
+ return IsArray$1(value) ? Ok(value) : Ok([value]);
3152
+ }
3153
+ // ../../node_modules/.pnpm/typebox@1.4.3/node_modules/typebox/build/value/convert/try/try_bigint.mjs
3154
+ function FromBoolean$5(value) {
3155
+ return IsEqual$1(value, true) ? Ok(BigInt(1)) : Ok(BigInt(0));
3156
+ }
3157
+ const bigintPattern = /^-?(0|[1-9]\d*)n$/;
3158
+ const decimalPattern = /^-?(0|[1-9]\d*)\.\d+$/;
3159
+ const integerPattern = /^-?(0|[1-9]\d*)$/;
3160
+ function IsStringBigIntLike(value) {
3161
+ return bigintPattern.test(value);
3162
+ }
3163
+ function IsStringDecimalLike(value) {
3164
+ return decimalPattern.test(value);
3165
+ }
3166
+ function IsStringIntegerLike(value) {
3167
+ return integerPattern.test(value);
3168
+ }
3169
+ function FromString$6(value) {
3170
+ const lowercase = value.toLowerCase();
3171
+ return IsStringBigIntLike(value) ? Ok(BigInt(value.slice(0, value.length - 1))) : IsStringDecimalLike(value) ? Ok(BigInt(value.split(".")[0])) : IsStringIntegerLike(value) ? Ok(BigInt(value)) : IsEqual$1(lowercase, "false") ? Ok(BigInt(0)) : IsEqual$1(lowercase, "true") ? Ok(BigInt(1)) : void 0;
3172
+ }
3173
+ function TryBigInt(value) {
3174
+ return IsBigInt$1(value) ? Ok(value) : IsBoolean$1(value) ? FromBoolean$5(value) : IsNumber$1(value) ? Ok(BigInt(Math.trunc(value))) : IsNull$1(value) ? Ok(BigInt(0)) : IsString$1(value) ? FromString$6(value) : IsUndefined$1(value) ? Ok(BigInt(0)) : void 0;
3175
+ }
3176
+ // ../../node_modules/.pnpm/typebox@1.4.3/node_modules/typebox/build/value/convert/try/try_boolean.mjs
3177
+ function FromBigInt$5(value) {
3178
+ return IsEqual$1(value, BigInt(0)) ? Ok(false) : IsEqual$1(value, BigInt(1)) ? Ok(true) : void 0;
3179
+ }
3180
+ function FromNumber$4(value) {
3181
+ return IsEqual$1(value, 0) ? Ok(false) : IsEqual$1(value, 1) ? Ok(true) : void 0;
3182
+ }
3183
+ function FromString$5(value) {
3184
+ return IsEqual$1(value.toLowerCase(), "false") ? Ok(false) : IsEqual$1(value.toLowerCase(), "true") ? Ok(true) : IsEqual$1(value, "0") ? Ok(false) : IsEqual$1(value, "1") ? Ok(true) : void 0;
3185
+ }
3186
+ function TryBoolean(value) {
3187
+ return IsBigInt$1(value) ? FromBigInt$5(value) : IsBoolean$1(value) ? Ok(value) : IsNumber$1(value) ? FromNumber$4(value) : IsNull$1(value) ? Ok(false) : IsString$1(value) ? FromString$5(value) : IsUndefined$1(value) ? Ok(false) : void 0;
3188
+ }
3189
+ // ../../node_modules/.pnpm/typebox@1.4.3/node_modules/typebox/build/value/convert/try/try_null.mjs
3190
+ function FromBigInt$4(value) {
3191
+ return IsEqual$1(value, BigInt(0)) ? Ok(null) : void 0;
3192
+ }
3193
+ function FromBoolean$4(value) {
3194
+ return IsEqual$1(value, false) ? Ok(null) : void 0;
3195
+ }
3196
+ function FromNumber$3(value) {
3197
+ return IsEqual$1(value, 0) ? Ok(null) : void 0;
3198
+ }
3199
+ function FromString$4(value) {
3200
+ const lowercase = value.toLowerCase();
3201
+ return IsEqual$1(lowercase, "undefined") || IsEqual$1(lowercase, "null") || IsEqual$1(value, "") || IsEqual$1(value, "0") ? Ok(null) : void 0;
3202
+ }
3203
+ function TryNull(value) {
3204
+ return IsBigInt$1(value) ? FromBigInt$4(value) : IsBoolean$1(value) ? FromBoolean$4(value) : IsNumber$1(value) ? FromNumber$3(value) : IsNull$1(value) ? Ok(null) : IsString$1(value) ? FromString$4(value) : IsUndefined$1(value) ? Ok(null) : void 0;
3205
+ }
3206
+ // ../../node_modules/.pnpm/typebox@1.4.3/node_modules/typebox/build/value/convert/try/try_number.mjs
3207
+ const maxBigInt = BigInt(Number.MAX_SAFE_INTEGER);
3208
+ const minBigInt = BigInt(Number.MIN_SAFE_INTEGER);
3209
+ function FromBigInt$3(value) {
3210
+ return value <= maxBigInt && value >= minBigInt ? Ok(Number(value)) : void 0;
3211
+ }
3212
+ function FromBoolean$3(value) {
3213
+ return Ok(value ? 1 : 0);
3214
+ }
3215
+ function FromString$3(value) {
3216
+ const coerced = +value;
3217
+ if (IsNumber$1(coerced)) return Ok(coerced);
3218
+ const lowercase = value.toLowerCase();
3219
+ if (IsEqual$1(lowercase, "false")) return Ok(0);
3220
+ if (IsEqual$1(lowercase, "true")) return Ok(1);
3221
+ const result = TryBigInt(value);
3222
+ if (IsOk(result)) return result.value <= maxBigInt && result.value >= minBigInt ? Ok(Number(result.value)) : void 0;
3223
+ }
3224
+ function TryNumber(value) {
3225
+ return IsBigInt$1(value) ? FromBigInt$3(value) : IsBoolean$1(value) ? FromBoolean$3(value) : IsNumber$1(value) ? Ok(value) : IsNull$1(value) ? Ok(0) : IsString$1(value) ? FromString$3(value) : IsUndefined$1(value) ? Ok(0) : void 0;
3226
+ }
3227
+ // ../../node_modules/.pnpm/typebox@1.4.3/node_modules/typebox/build/value/convert/try/try_string.mjs
3228
+ function TryString(value) {
3229
+ return IsBigInt$1(value) ? Ok(value.toString()) : IsBoolean$1(value) ? Ok(value.toString()) : IsNumber$1(value) ? Ok(value.toString()) : IsNull$1(value) ? Ok("null") : IsString$1(value) ? Ok(value) : IsUndefined$1(value) ? Ok("") : void 0;
3230
+ }
3231
+ // ../../node_modules/.pnpm/typebox@1.4.3/node_modules/typebox/build/value/convert/try/try_undefined.mjs
3232
+ function FromBigInt$2(value) {
3233
+ return IsEqual$1(value, BigInt(0)) ? Ok(void 0) : void 0;
3234
+ }
3235
+ function FromBoolean$2(value) {
3236
+ return IsEqual$1(value, false) ? Ok(void 0) : void 0;
3237
+ }
3238
+ function FromNumber$2(value) {
3239
+ return IsEqual$1(value, 0) ? Ok(void 0) : void 0;
3240
+ }
3241
+ function FromString$2(value) {
3242
+ const lowercase = value.toLowerCase();
3243
+ return IsEqual$1(lowercase, "undefined") || IsEqual$1(lowercase, "null") || IsEqual$1(value, "") || IsEqual$1(value, "0") ? Ok(void 0) : void 0;
3244
+ }
3245
+ function TryUndefined(value) {
3246
+ return IsBigInt$1(value) ? FromBigInt$2(value) : IsBoolean$1(value) ? FromBoolean$2(value) : IsNumber$1(value) ? FromNumber$2(value) : IsNull$1(value) ? Ok(void 0) : IsString$1(value) ? FromString$2(value) : IsUndefined$1(value) ? Ok(value) : void 0;
3247
+ }
3248
+ // ../../node_modules/.pnpm/typebox@1.4.3/node_modules/typebox/build/value/convert/from_array.mjs
3249
+ function FromArray$4(context, type, value) {
3250
+ return TryArray(value).value.map((value) => FromType$4(context, type.items, value));
3251
+ }
3252
+ // ../../node_modules/.pnpm/typebox@1.4.3/node_modules/typebox/build/value/convert/from_bigint.mjs
3253
+ function FromBigInt$1(_context, _type, value) {
3254
+ const result = TryBigInt(value);
3255
+ return IsOk(result) ? result.value : value;
3256
+ }
3257
+ // ../../node_modules/.pnpm/typebox@1.4.3/node_modules/typebox/build/value/convert/from_boolean.mjs
3258
+ function FromBoolean$1(_context, _type, value) {
3259
+ const result = TryBoolean(value);
3260
+ return IsOk(result) ? result.value : value;
3261
+ }
3262
+ // ../../node_modules/.pnpm/typebox@1.4.3/node_modules/typebox/build/value/convert/from_cyclic.mjs
3263
+ function FromCyclic$4(context, type, value) {
3264
+ return FromType$4({
3265
+ ...context,
3266
+ ...type.$defs
3267
+ }, Ref$1(type.$ref), value);
3268
+ }
3269
+ // ../../node_modules/.pnpm/typebox@1.4.3/node_modules/typebox/build/value/convert/from_enum.mjs
3270
+ function FromEnum$1(context, type, value) {
3271
+ return FromType$4(context, Evaluate$1(type), value);
3272
+ }
3273
+ // ../../node_modules/.pnpm/typebox@1.4.3/node_modules/typebox/build/value/convert/from_integer.mjs
3274
+ function FromInteger$1(_context, _type, value) {
3275
+ const result = TryNumber(value);
3276
+ return IsOk(result) ? Math.trunc(result.value) : value;
3277
+ }
3278
+ // ../../node_modules/.pnpm/typebox@1.4.3/node_modules/typebox/build/value/convert/from_intersect.mjs
3279
+ function FromIntersect$4(context, type, value) {
3280
+ const instantiated = Instantiate(context, type);
3281
+ return FromType$4(context, Evaluate$1(instantiated), value);
3282
+ }
3283
+ // ../../node_modules/.pnpm/typebox@1.4.3/node_modules/typebox/build/value/convert/from_literal.mjs
3284
+ function FromLiteralBigInt(_context, type, value) {
3285
+ const result = TryBigInt(value);
3286
+ return IsOk(result) && IsEqual$1(type.const, result.value) ? result.value : value;
3287
+ }
3288
+ function FromLiteralBoolean(_context, type, value) {
3289
+ const result = TryBoolean(value);
3290
+ return IsOk(result) && IsEqual$1(type.const, result.value) ? result.value : value;
3291
+ }
3292
+ function FromLiteralNumber(_context, type, value) {
3293
+ const result = TryNumber(value);
3294
+ return IsOk(result) && IsEqual$1(type.const, result.value) ? result.value : value;
3295
+ }
3296
+ function FromLiteralString(_context, type, value) {
3297
+ const result = TryString(value);
3298
+ return IsOk(result) && IsEqual$1(type.const, result.value) ? result.value : value;
3299
+ }
3300
+ function FromLiteral$1(context, type, value) {
3301
+ if (IsEqual$1(type.const, value)) return value;
3302
+ return IsLiteralBigInt(type) ? FromLiteralBigInt(context, type, value) : IsLiteralBoolean(type) ? FromLiteralBoolean(context, type, value) : IsLiteralNumber(type) ? FromLiteralNumber(context, type, value) : IsLiteralString(type) ? FromLiteralString(context, type, value) : Unreachable();
3303
+ }
3304
+ // ../../node_modules/.pnpm/typebox@1.4.3/node_modules/typebox/build/value/convert/from_null.mjs
3305
+ function FromNull$1(_context, _type, value) {
3306
+ const result = TryNull(value);
3307
+ return IsOk(result) ? result.value : value;
3308
+ }
3309
+ // ../../node_modules/.pnpm/typebox@1.4.3/node_modules/typebox/build/value/convert/from_number.mjs
3310
+ function FromNumber$1(_context, _type, value) {
3311
+ const result = TryNumber(value);
3312
+ return IsOk(result) ? result.value : value;
3313
+ }
3314
+ // ../../node_modules/.pnpm/typebox@1.4.3/node_modules/typebox/build/value/convert/from_additional.mjs
3315
+ /**
3316
+ * Used by Object and Record Types. The entries are derived from the known
3317
+ * properties obtained from 'properties' and 'patternProperties' respectively.
3318
+ */
3319
+ function FromAdditionalProperties(context, entries, additionalProperties, value) {
3320
+ const keys = Keys$1(value);
3321
+ for (const [regexp, _] of entries) for (const key of keys) if (!regexp.test(key)) value[key] = FromType$4(context, additionalProperties, value[key]);
3322
+ return value;
3323
+ }
3324
+ // ../../node_modules/.pnpm/typebox@1.4.3/node_modules/typebox/build/value/shared/optional_undefined.mjs
3325
+ function IsOptionalUndefined(property, key, value) {
3326
+ return IsOptional(property) && IsUndefined$1(value[key]);
3327
+ }
3328
+ // ../../node_modules/.pnpm/typebox@1.4.3/node_modules/typebox/build/value/convert/from_object.mjs
3329
+ function FromProperties(context, type, value) {
3330
+ const entries = EntriesRegExp(type.properties);
3331
+ const keys = Keys$1(value);
3332
+ for (const [regexp, property] of entries) for (const key of keys) {
3333
+ if (!regexp.test(key) || IsOptionalUndefined(property, key, value)) continue;
3334
+ value[key] = FromType$4(context, property, value[key]);
3335
+ }
3336
+ return HasPropertyKey$1(type, "additionalProperties") && IsObject$1(type.additionalProperties) ? FromAdditionalProperties(context, entries, type.additionalProperties, value) : value;
3337
+ }
3338
+ function FromObject$4(context, type, value) {
3339
+ return IsObjectNotArray$1(value) ? FromProperties(context, type, value) : value;
3340
+ }
3341
+ // ../../node_modules/.pnpm/typebox@1.4.3/node_modules/typebox/build/value/convert/from_record.mjs
3342
+ function FromPatternProperties(context, type, value) {
3343
+ const entries = EntriesRegExp(type.patternProperties);
3344
+ const keys = Keys$1(value);
3345
+ for (const [regexp, schema] of entries) for (const key of keys) if (regexp.test(key)) value[key] = FromType$4(context, schema, value[key]);
3346
+ return HasPropertyKey$1(type, "additionalProperties") && IsObject$1(type.additionalProperties) ? FromAdditionalProperties(context, entries, type.additionalProperties, value) : value;
3347
+ }
3348
+ function FromRecord$4(context, type, value) {
3349
+ return IsObjectNotArray$1(value) ? FromPatternProperties(context, type, value) : value;
3350
+ }
3351
+ // ../../node_modules/.pnpm/typebox@1.4.3/node_modules/typebox/build/value/convert/from_ref.mjs
3352
+ function FromRef$4(context, type, value) {
3353
+ return HasPropertyKey$1(context, type.$ref) ? FromType$4(context, context[type.$ref], value) : value;
3354
+ }
3355
+ // ../../node_modules/.pnpm/typebox@1.4.3/node_modules/typebox/build/value/convert/from_string.mjs
3356
+ function FromString$1(_context, _type, value) {
3357
+ const result = TryString(value);
3358
+ return IsOk(result) ? result.value : value;
3359
+ }
3360
+ // ../../node_modules/.pnpm/typebox@1.4.3/node_modules/typebox/build/value/convert/from_template_literal.mjs
3361
+ function FromTemplateLiteral$1(context, type, value) {
3362
+ return FromType$4(context, Evaluate$1(type), value);
3363
+ }
3364
+ // ../../node_modules/.pnpm/typebox@1.4.3/node_modules/typebox/build/value/convert/from_tuple.mjs
3365
+ function FromTuple$4(context, type, value) {
3366
+ if (!IsArray$1(value)) return value;
3367
+ for (let index = 0; index < Math.min(type.items.length, value.length); index++) value[index] = FromType$4(context, type.items[index], value[index]);
3368
+ return value;
3369
+ }
3370
+ // ../../node_modules/.pnpm/typebox@1.4.3/node_modules/typebox/build/value/convert/from_undefined.mjs
3371
+ function FromUndefined$1(_context, _type, value) {
3372
+ const result = TryUndefined(value);
3373
+ return IsOk(result) ? result.value : value;
3374
+ }
3375
+ // ../../node_modules/.pnpm/typebox@1.4.3/node_modules/typebox/build/value/convert/from_union.mjs
3376
+ function FromUnion$4(context, type, value) {
3377
+ if (type.anyOf.some((type) => Check(context, type, value))) return value;
3378
+ const selected = type.anyOf.map((type) => FromType$4(context, type, Clone(value))).find((value) => Check(context, type, value));
3379
+ return IsUndefined$1(selected) ? value : selected;
3380
+ }
3381
+ // ../../node_modules/.pnpm/typebox@1.4.3/node_modules/typebox/build/value/convert/from_void.mjs
3382
+ function FromVoid$1(_context, _type, value) {
3383
+ return IsOk(TryUndefined(value)) ? void 0 : value;
3384
+ }
3385
+ // ../../node_modules/.pnpm/typebox@1.4.3/node_modules/typebox/build/value/convert/from_type.mjs
3386
+ function FromType$4(context, type, value) {
3387
+ return IsArray$2(type) ? FromArray$4(context, type, value) : IsBigInt$2(type) ? FromBigInt$1(context, type, value) : IsBoolean$2(type) ? FromBoolean$1(context, type, value) : IsCyclic(type) ? FromCyclic$4(context, type, value) : IsEnum$1(type) ? FromEnum$1(context, type, value) : IsInteger$2(type) ? FromInteger$1(context, type, value) : IsIntersect(type) ? FromIntersect$4(context, type, value) : IsLiteral(type) ? FromLiteral$1(context, type, value) : IsNull$2(type) ? FromNull$1(context, type, value) : IsNumber$2(type) ? FromNumber$1(context, type, value) : IsObject$2(type) ? FromObject$4(context, type, value) : IsRecord(type) ? FromRecord$4(context, type, value) : IsRef$1(type) ? FromRef$4(context, type, value) : IsString$2(type) ? FromString$1(context, type, value) : IsTemplateLiteral(type) ? FromTemplateLiteral$1(context, type, value) : IsTuple(type) ? FromTuple$4(context, type, value) : IsUndefined$2(type) ? FromUndefined$1(context, type, value) : IsUnion(type) ? FromUnion$4(context, type, value) : IsVoid(type) ? FromVoid$1(context, type, value) : value;
3388
+ }
3389
+ // ../../node_modules/.pnpm/typebox@1.4.3/node_modules/typebox/build/value/convert/convert.mjs
3390
+ /**
3391
+ * Converts a value to the given type, coercing interior values if a reasonable conversion is possible. This
3392
+ * function returns unknown so callers should Check the return value before use. This function mutates the
3393
+ * provided value. If mutation is not wanted, you should Clone the value before passing to this function.
3394
+ */
3395
+ function Convert(...args) {
3396
+ const [context, type, value] = Match$1(args, {
3397
+ 3: (context, type, value) => [
3398
+ context,
3399
+ type,
3400
+ value
3401
+ ],
3402
+ 2: (type, value) => [
3403
+ {},
3404
+ type,
3405
+ value
3406
+ ]
3407
+ });
3408
+ return FromType$4(context, type, value);
3409
+ }
3410
+ // ../../node_modules/.pnpm/typebox@1.4.3/node_modules/typebox/build/value/default/from_array.mjs
3411
+ function FromArray$3(context, type, value) {
3412
+ if (!IsArray$1(value)) return value;
3413
+ for (let i = 0; i < value.length; i++) value[i] = FromType$3(context, type.items, value[i]);
3414
+ return value;
3415
+ }
3416
+ // ../../node_modules/.pnpm/typebox@1.4.3/node_modules/typebox/build/value/default/from_cyclic.mjs
3417
+ function FromCyclic$3(context, type, value) {
3418
+ return FromType$3({
3419
+ ...context,
3420
+ ...type.$defs
3421
+ }, Ref$1(type.$ref), value);
3422
+ }
3423
+ // ../../node_modules/.pnpm/typebox@1.4.3/node_modules/typebox/build/value/default/from_default.mjs
3424
+ function FromDefault$1(type, value) {
3425
+ if (!IsUndefined$1(value)) return value;
3426
+ return IsFunction$1(type.default) ? type.default() : Clone(type.default);
3427
+ }
3428
+ // ../../node_modules/.pnpm/typebox@1.4.3/node_modules/typebox/build/value/default/from_intersect.mjs
3429
+ function FromIntersect$3(context, type, value) {
3430
+ const instantiated = Instantiate(context, type);
3431
+ return FromType$3(context, Evaluate$1(instantiated), value);
3432
+ }
3433
+ // ../../node_modules/.pnpm/typebox@1.4.3/node_modules/typebox/build/value/default/from_object.mjs
3434
+ function FromObject$3(context, type, value) {
3435
+ if (!IsObject$1(value)) return value;
3436
+ const knownPropertyKeys = Keys$1(type.properties);
3437
+ for (const key of knownPropertyKeys) {
3438
+ const propertyValue = FromType$3(context, type.properties[key], value[key]);
3439
+ if (IsUndefined$1(propertyValue) && (IsOptional(type.properties[key]) || !HasPropertyKey$1(type.properties[key], "default"))) continue;
3440
+ value[key] = propertyValue;
3441
+ }
3442
+ if (!IsAdditionalProperties(type) || IsBoolean$1(type.additionalProperties)) return value;
3443
+ for (const key of Keys$1(value)) {
3444
+ if (knownPropertyKeys.includes(key)) continue;
3445
+ value[key] = FromType$3(context, type.additionalProperties, value[key]);
3446
+ }
3447
+ return value;
3448
+ }
3449
+ // ../../node_modules/.pnpm/typebox@1.4.3/node_modules/typebox/build/value/default/from_record.mjs
3450
+ function FromRecord$3(context, type, value) {
3451
+ if (!IsObject$1(value)) return value;
3452
+ const [recordKey, recordValue] = [new RegExp(RecordPattern(type)), RecordValue(type)];
3453
+ for (const key of Keys$1(value)) {
3454
+ if (!(recordKey.test(key) && IsDefault(recordValue))) continue;
3455
+ value[key] = FromType$3(context, recordValue, value[key]);
3456
+ }
3457
+ if (!IsAdditionalProperties(type)) return value;
3458
+ for (const key of Keys$1(value)) {
3459
+ if (recordKey.test(key)) continue;
3460
+ value[key] = FromType$3(context, type.additionalProperties, value[key]);
3461
+ }
3462
+ return value;
3463
+ }
3464
+ // ../../node_modules/.pnpm/typebox@1.4.3/node_modules/typebox/build/value/default/from_ref.mjs
3465
+ function FromRef$3(context, type, value) {
3466
+ return HasPropertyKey$1(context, type.$ref) ? FromType$3(context, context[type.$ref], value) : value;
3467
+ }
3468
+ // ../../node_modules/.pnpm/typebox@1.4.3/node_modules/typebox/build/value/default/from_tuple.mjs
3469
+ function FromTuple$3(context, schema, value) {
3470
+ if (!IsArray$1(value)) return value;
3471
+ const [items, max] = [schema.items, Math.max(schema.items.length, value.length)];
3472
+ for (let i = 0; i < max; i++) if (i < items.length) value[i] = FromType$3(context, items[i], value[i]);
3473
+ return value;
3474
+ }
3475
+ // ../../node_modules/.pnpm/typebox@1.4.3/node_modules/typebox/build/value/default/from_union.mjs
3476
+ function FromUnion$3(context, schema, value) {
3477
+ for (const inner of schema.anyOf) {
3478
+ const result = FromType$3(context, inner, Clone(value));
3479
+ if (Check(context, inner, result)) return result;
3480
+ }
3481
+ return value;
3482
+ }
3483
+ // ../../node_modules/.pnpm/typebox@1.4.3/node_modules/typebox/build/value/default/from_type.mjs
3484
+ function FromType$3(context, type, value) {
3485
+ const defaulted = IsDefault(type) ? FromDefault$1(type, value) : value;
3486
+ return IsArray$2(type) ? FromArray$3(context, type, defaulted) : IsCyclic(type) ? FromCyclic$3(context, type, defaulted) : IsIntersect(type) ? FromIntersect$3(context, type, defaulted) : IsObject$2(type) ? FromObject$3(context, type, defaulted) : IsRecord(type) ? FromRecord$3(context, type, defaulted) : IsRef$1(type) ? FromRef$3(context, type, defaulted) : IsTuple(type) ? FromTuple$3(context, type, defaulted) : IsUnion(type) ? FromUnion$3(context, type, defaulted) : defaulted;
3487
+ }
3488
+ // ../../node_modules/.pnpm/typebox@1.4.3/node_modules/typebox/build/value/default/default.mjs
3489
+ /**
3490
+ * Patches missing properties on the value using default annotations specified on the provided type. This
3491
+ * function returns unknown so callers should Check the return value before use. This function mutates the
3492
+ * provided value. If mutation is not wanted, you should Clone the value before passing to this function.
3493
+ */
3494
+ function Default(...args) {
3495
+ const [context, type, value] = Match$1(args, {
3496
+ 3: (context, type, value) => [
3497
+ context,
3498
+ type,
3499
+ value
3500
+ ],
3501
+ 2: (type, value) => [
3502
+ {},
3503
+ type,
3504
+ value
3505
+ ]
3506
+ });
3507
+ return FromType$3(context, type, value);
3508
+ }
3509
+ // ../../node_modules/.pnpm/typebox@1.4.3/node_modules/typebox/build/value/pipeline/pipeline.mjs
3510
+ /** Creates a value processing pipeline. */
3511
+ function Pipeline(pipeline) {
3512
+ return (...args) => {
3513
+ const [context, type, value] = Match$1(args, {
3514
+ 3: (context, type, value) => [
3515
+ context,
3516
+ type,
3517
+ value
3518
+ ],
3519
+ 2: (type, value) => [
3520
+ {},
3521
+ type,
3522
+ value
3523
+ ]
3524
+ });
3525
+ return pipeline.reduce((result, func) => func(context, type, result), value);
3526
+ };
3527
+ }
3528
+ // ../../node_modules/.pnpm/typebox@1.4.3/node_modules/typebox/build/value/codec/callback.mjs
3529
+ function Decode$7(_context, type, value) {
3530
+ return type["~codec"].decode(value);
3531
+ }
3532
+ function Encode$7(_context, type, value) {
3533
+ return type["~codec"].encode(value);
3534
+ }
3535
+ function Callback(direction, context, type, value) {
3536
+ if (!IsCodec(type)) return value;
3537
+ return IsEqual$1(direction, "Decode") ? Decode$7(context, type, value) : Encode$7(context, type, value);
3538
+ }
3539
+ // ../../node_modules/.pnpm/typebox@1.4.3/node_modules/typebox/build/value/codec/from_array.mjs
3540
+ function Decode$6(direction, context, type, value) {
3541
+ if (!IsArray$1(value)) return value;
3542
+ for (let i = 0; i < value.length; i++) value[i] = FromType$2(direction, context, type.items, value[i]);
3543
+ return Callback(direction, context, type, value);
3544
+ }
3545
+ function Encode$6(direction, context, type, value) {
3546
+ const exterior = Callback(direction, context, type, value);
3547
+ if (!IsArray$1(exterior)) return exterior;
3548
+ for (let i = 0; i < exterior.length; i++) exterior[i] = FromType$2(direction, context, type.items, exterior[i]);
3549
+ return exterior;
3550
+ }
3551
+ function FromArray$2(direction, context, type, value) {
3552
+ return IsEqual$1(direction, "Decode") ? Decode$6(direction, context, type, value) : Encode$6(direction, context, type, value);
3553
+ }
3554
+ // ../../node_modules/.pnpm/typebox@1.4.3/node_modules/typebox/build/value/codec/from_cyclic.mjs
3555
+ function FromCyclic$2(direction, context, type, value) {
3556
+ value = FromType$2(direction, {
3557
+ ...context,
3558
+ ...type.$defs
3559
+ }, Ref$1(type.$ref), value);
3560
+ return Callback(direction, context, type, value);
3561
+ }
3562
+ // ../../node_modules/.pnpm/typebox@1.4.3/node_modules/typebox/build/value/codec/from_intersect.mjs
3563
+ function MergeInteriors(interiors) {
3564
+ return interiors.reduce((results, interior) => ({
3565
+ ...results,
3566
+ ...interior
3567
+ }), {});
3568
+ }
3569
+ function NonMatchingInterior(value, interiors) {
3570
+ for (const interior of interiors) if (!IsDeepEqual$1(value, interior)) return interior;
3571
+ return value;
3572
+ }
3573
+ function Decode$5(direction, context, type, value) {
3574
+ if (IsEqual$1(type.allOf.length, 0)) return Callback(direction, context, type, value);
3575
+ const interiors = type.allOf.map((schema) => FromType$2(direction, context, schema, Clean(schema, Clone(value))));
3576
+ return Callback(direction, context, type, interiors.every((result) => IsObject$1(result)) ? MergeInteriors(interiors) : NonMatchingInterior(value, interiors));
3577
+ }
3578
+ function Encode$5(direction, context, type, value) {
3579
+ if (IsEqual$1(type.allOf.length, 0)) return Callback(direction, context, type, value);
3580
+ const exterior = Callback(direction, context, type, value);
3581
+ const interiors = type.allOf.map((schema) => FromType$2(direction, context, schema, Clean(schema, Clone(exterior))));
3582
+ if (interiors.every((result) => IsObject$1(result))) return MergeInteriors(interiors);
3583
+ return NonMatchingInterior(exterior, interiors);
3584
+ }
3585
+ function FromIntersect$2(direction, context, type, value) {
3586
+ return IsEqual$1(direction, "Decode") ? Decode$5(direction, context, type, value) : Encode$5(direction, context, type, value);
3587
+ }
3588
+ // ../../node_modules/.pnpm/typebox@1.4.3/node_modules/typebox/build/value/codec/from_object.mjs
3589
+ function Decode$4(direction, context, type, value) {
3590
+ if (!IsObjectNotArray$1(value)) return value;
3591
+ for (const key of Keys$1(type.properties)) {
3592
+ if (!HasPropertyKey$1(value, key) || IsOptionalUndefined(type.properties[key], key, value)) continue;
3593
+ value[key] = FromType$2(direction, context, type.properties[key], value[key]);
3594
+ }
3595
+ return Callback(direction, context, type, value);
3596
+ }
3597
+ function Encode$4(direction, context, type, value) {
3598
+ const exterior = Callback(direction, context, type, value);
3599
+ if (!IsObjectNotArray$1(exterior)) return exterior;
3600
+ for (const key of Keys$1(type.properties)) {
3601
+ if (!HasPropertyKey$1(exterior, key) || IsOptionalUndefined(type.properties[key], key, exterior)) continue;
3602
+ exterior[key] = FromType$2(direction, context, type.properties[key], exterior[key]);
3603
+ }
3604
+ return exterior;
3605
+ }
3606
+ function FromObject$2(direction, context, type, value) {
3607
+ return IsEqual$1(direction, "Decode") ? Decode$4(direction, context, type, value) : Encode$4(direction, context, type, value);
3608
+ }
3609
+ // ../../node_modules/.pnpm/typebox@1.4.3/node_modules/typebox/build/value/codec/from_record.mjs
3610
+ function Decode$3(direction, context, type, value) {
3611
+ if (!IsObjectNotArray$1(value)) return value;
3612
+ const regexp = new RegExp(RecordPattern(type));
3613
+ for (const key of Keys$1(value)) {
3614
+ if (!regexp.test(key)) continue;
3615
+ value[key] = FromType$2(direction, context, RecordValue(type), value[key]);
3616
+ }
3617
+ return Callback(direction, context, type, value);
3618
+ }
3619
+ function Encode$3(direction, context, type, value) {
3620
+ const exterior = Callback(direction, context, type, value);
3621
+ if (!IsObjectNotArray$1(exterior)) return exterior;
3622
+ const regexp = new RegExp(RecordPattern(type));
3623
+ for (const key of Keys$1(exterior)) {
3624
+ if (!regexp.test(key)) continue;
3625
+ exterior[key] = FromType$2(direction, context, RecordValue(type), exterior[key]);
3626
+ }
3627
+ return exterior;
3628
+ }
3629
+ function FromRecord$2(direction, context, type, value) {
3630
+ return IsEqual$1(direction, "Decode") ? Decode$3(direction, context, type, value) : Encode$3(direction, context, type, value);
3631
+ }
3632
+ // ../../node_modules/.pnpm/typebox@1.4.3/node_modules/typebox/build/value/codec/from_ref.mjs
3633
+ function ResolveRef(direction, context, type, value) {
3634
+ return HasPropertyKey$1(context, type.$ref) ? FromType$2(direction, context, context[type.$ref], value) : value;
3635
+ }
3636
+ function FromRef$2(direction, context, type, value) {
3637
+ return IsEqual$1(direction, "Decode") ? Callback(direction, context, type, ResolveRef(direction, context, type, value)) : ResolveRef(direction, context, type, Callback(direction, context, type, value));
3638
+ }
3639
+ // ../../node_modules/.pnpm/typebox@1.4.3/node_modules/typebox/build/value/codec/from_tuple.mjs
3640
+ function Decode$2(direction, context, type, value) {
3641
+ if (!IsArray$1(value)) return value;
3642
+ for (let i = 0; i < Math.min(type.items.length, value.length); i++) value[i] = FromType$2(direction, context, type.items[i], value[i]);
3643
+ return Callback(direction, context, type, value);
3644
+ }
3645
+ function Encode$2(direction, context, type, value) {
3646
+ const exterior = Callback(direction, context, type, value);
3647
+ if (!IsArray$1(exterior)) return value;
3648
+ for (let i = 0; i < Math.min(type.items.length, exterior.length); i++) exterior[i] = FromType$2(direction, context, type.items[i], exterior[i]);
3649
+ return exterior;
3650
+ }
3651
+ function FromTuple$2(direction, context, type, value) {
3652
+ return IsEqual$1(direction, "Decode") ? Decode$2(direction, context, type, value) : Encode$2(direction, context, type, value);
3653
+ }
3654
+ // ../../node_modules/.pnpm/typebox@1.4.3/node_modules/typebox/build/value/codec/from_union.mjs
3655
+ function Decode$1(direction, context, type, value) {
3656
+ for (const schema of type.anyOf) {
3657
+ if (!Check(context, schema, value)) continue;
3658
+ return Callback(direction, context, type, FromType$2(direction, context, schema, value));
3659
+ }
3660
+ return value;
3661
+ }
3662
+ function Encode$1(direction, context, type, value) {
3663
+ const exterior = Callback(direction, context, type, value);
3664
+ for (const schema of type.anyOf) {
3665
+ const variant = FromType$2(direction, context, schema, Clone(exterior));
3666
+ if (!Check(context, schema, variant)) continue;
3667
+ return variant;
3668
+ }
3669
+ return exterior;
3670
+ }
3671
+ function FromUnion$2(direction, context, type, value) {
3672
+ return IsEqual$1(direction, "Decode") ? Decode$1(direction, context, type, value) : Encode$1(direction, context, type, value);
3673
+ }
3674
+ // ../../node_modules/.pnpm/typebox@1.4.3/node_modules/typebox/build/value/codec/from_type.mjs
3675
+ function FromType$2(direction, context, type, value) {
3676
+ return IsArray$2(type) ? FromArray$2(direction, context, type, value) : IsCyclic(type) ? FromCyclic$2(direction, context, type, value) : IsIntersect(type) ? FromIntersect$2(direction, context, type, value) : IsObject$2(type) ? FromObject$2(direction, context, type, value) : IsRecord(type) ? FromRecord$2(direction, context, type, value) : IsRef$1(type) ? FromRef$2(direction, context, type, value) : IsTuple(type) ? FromTuple$2(direction, context, type, value) : IsUnion(type) ? FromUnion$2(direction, context, type, value) : Callback(direction, context, type, value);
3677
+ }
3678
+ // ../../node_modules/.pnpm/typebox@1.4.3/node_modules/typebox/build/value/codec/decode.mjs
3679
+ var DecodeError = class extends AssertError {
3680
+ constructor(value, errors) {
3681
+ super("Decode", value, errors);
3682
+ }
3683
+ };
3684
+ function Assert$2(context, type, value) {
3685
+ if (!Check(context, type, value)) throw new DecodeError(value, Errors(context, type, value));
3686
+ return value;
3687
+ }
3688
+ /** Executes Decode callbacks only */
3689
+ function DecodeUnsafe(context, type, value) {
3690
+ return FromType$2("Decode", context, Get$3().unionPrioritySort ? UnionPrioritySort(type) : type, value);
3691
+ }
3692
+ const Decoder = Pipeline([
3693
+ (_context, _type, value) => Clone(value),
3694
+ (context, type, value) => Default(context, type, value),
3695
+ (context, type, value) => Convert(context, type, value),
3696
+ (context, type, value) => Clean(context, type, value),
3697
+ (context, type, value) => Assert$2(context, type, value),
3698
+ (context, type, value) => DecodeUnsafe(context, type, value)
3699
+ ]);
3700
+ /** Decodes a value with the given type. */
3701
+ function Decode(...args) {
3702
+ const [context, type, value] = Match$1(args, {
3703
+ 3: (context, type, value) => [
3704
+ context,
3705
+ type,
3706
+ value
3707
+ ],
3708
+ 2: (type, value) => [
3709
+ {},
3710
+ type,
3711
+ value
3712
+ ]
3713
+ });
3714
+ return Decoder(context, type, value);
3715
+ }
3716
+ // ../../node_modules/.pnpm/typebox@1.4.3/node_modules/typebox/build/value/codec/encode.mjs
3717
+ var EncodeError = class extends AssertError {
3718
+ constructor(value, errors) {
3719
+ super("Encode", value, errors);
3720
+ }
3721
+ };
3722
+ function Assert$1(context, type, value) {
3723
+ if (!Check(context, type, value)) throw new EncodeError(value, Errors(context, type, value));
3724
+ return value;
3725
+ }
3726
+ /** Executes Encode callbacks only */
3727
+ function EncodeUnsafe(context, type, value) {
3728
+ return FromType$2("Encode", context, Get$3().unionPrioritySort ? UnionPrioritySort(type) : type, value);
3729
+ }
3730
+ const Encoder = Pipeline([
3731
+ (_context, _type, value) => Clone(value),
3732
+ (context, type, value) => EncodeUnsafe(context, type, value),
3733
+ (context, type, value) => Default(context, type, value),
3734
+ (context, type, value) => Convert(context, type, value),
3735
+ (context, type, value) => Clean(context, type, value),
3736
+ (context, type, value) => Assert$1(context, type, value)
3737
+ ]);
3738
+ /** Encodes a value with the given type. */
3739
+ function Encode(...args) {
3740
+ const [context, type, value] = Match$1(args, {
3741
+ 3: (context, type, value) => [
3742
+ context,
3743
+ type,
3744
+ value
3745
+ ],
3746
+ 2: (type, value) => [
3747
+ {},
3748
+ type,
3749
+ value
3750
+ ]
3751
+ });
3752
+ return Encoder(context, type, value);
3753
+ }
3754
+ // ../../node_modules/.pnpm/typebox@1.4.3/node_modules/typebox/build/value/codec/has.mjs
3755
+ function FromArray$1(context, type) {
3756
+ return IsCodec(type) || FromType$1(context, type.items);
3757
+ }
3758
+ function FromCyclic$1(context, type) {
3759
+ return IsCodec(type) || FromRef$1({
3760
+ ...context,
3761
+ ...type.$defs
3762
+ }, Ref$1(type.$ref));
3763
+ }
3764
+ function FromIntersect$1(context, type) {
3765
+ return IsCodec(type) || type.allOf.some((type) => FromType$1(context, type));
3766
+ }
3767
+ function FromObject$1(context, type) {
3768
+ return IsCodec(type) || Keys$1(type.properties).some((key) => {
3769
+ return FromType$1(context, type.properties[key]);
3770
+ });
3771
+ }
3772
+ function FromRecord$1(context, type) {
3773
+ return IsCodec(type) || FromType$1(context, RecordValue(type));
3774
+ }
3775
+ function FromRef$1(context, type) {
3776
+ if (visited.has(type.$ref)) return false;
3777
+ visited.add(type.$ref);
3778
+ return IsCodec(type) || HasPropertyKey$1(context, type.$ref) && FromType$1(context, context[type.$ref]);
3779
+ }
3780
+ function FromTuple$1(context, type) {
3781
+ return IsCodec(type) || type.items.some((type) => FromType$1(context, type));
3782
+ }
3783
+ function FromUnion$1(context, type) {
3784
+ return IsCodec(type) || type.anyOf.some((type) => FromType$1(context, type));
3785
+ }
3786
+ function FromType$1(context, type) {
3787
+ return IsArray$2(type) ? FromArray$1(context, type) : IsCyclic(type) ? FromCyclic$1(context, type) : IsIntersect(type) ? FromIntersect$1(context, type) : IsObject$2(type) ? FromObject$1(context, type) : IsRecord(type) ? FromRecord$1(context, type) : IsRef$1(type) ? FromRef$1(context, type) : IsTuple(type) ? FromTuple$1(context, type) : IsUnion(type) ? FromUnion$1(context, type) : IsCodec(type);
3788
+ }
3789
+ const visited = /* @__PURE__ */ new Set();
3790
+ /** Returns true if this type contains a Codec */
3791
+ function HasCodec(...args) {
3792
+ const [context, type] = Match$1(args, {
3793
+ 2: (context, type) => [context, type],
3794
+ 1: (type) => [{}, type]
3795
+ });
3796
+ visited.clear();
3797
+ return FromType$1(context, type);
3798
+ }
3799
+ // ../../node_modules/.pnpm/typebox@1.4.3/node_modules/typebox/build/value/create/error.mjs
3800
+ var CreateError = class extends Error {
3801
+ constructor(type, message) {
3802
+ super(message);
3803
+ this.type = type;
3804
+ }
3805
+ };
3806
+ // ../../node_modules/.pnpm/typebox@1.4.3/node_modules/typebox/build/value/create/from_default.mjs
3807
+ function FromDefault(_context, schema) {
3808
+ return IsFunction$1(schema.default) ? schema.default(schema) : IsObject$1(schema.default) ? Clone(schema.default) : schema.default;
3809
+ }
3810
+ // ../../node_modules/.pnpm/typebox@1.4.3/node_modules/typebox/build/value/create/from_array.mjs
3811
+ function FromArray(context, type) {
3812
+ if (IsUniqueItems(type) && !IsDefault(type)) throw new CreateError(type, "Arrays with uniqueItems constraints must specify a default annotation");
3813
+ const length = IsMinItems(type) ? type.minItems : 0;
3814
+ return Array.from({ length }, () => FromType(context, type.items));
3815
+ }
3816
+ // ../../node_modules/.pnpm/typebox@1.4.3/node_modules/typebox/build/value/create/from_bigint.mjs
3817
+ function FromBigInt(_context, type) {
3818
+ return IsExclusiveMinimum(type) ? BigInt(type.exclusiveMinimum) + BigInt(1) : IsMinimum(type) ? BigInt(type.minimum) : BigInt(0);
3819
+ }
3820
+ // ../../node_modules/.pnpm/typebox@1.4.3/node_modules/typebox/build/value/create/from_boolean.mjs
3821
+ function FromBoolean(_context, _type) {
3822
+ return false;
3823
+ }
3824
+ // ../../node_modules/.pnpm/typebox@1.4.3/node_modules/typebox/build/value/create/from_constructor.mjs
3825
+ function FromConstructor(context, type) {
3826
+ const instanceType = FromType(context, type.instanceType);
3827
+ return class {
3828
+ constructor() {
3829
+ Object.assign(this, instanceType);
3830
+ }
3831
+ };
3832
+ }
3833
+ // ../../node_modules/.pnpm/typebox@1.4.3/node_modules/typebox/build/value/create/from_cyclic.mjs
3834
+ function FromCyclic(context, type) {
3835
+ return FromType({
3836
+ ...context,
3837
+ ...type.$defs
3838
+ }, Ref$1(type.$ref));
3839
+ }
3840
+ // ../../node_modules/.pnpm/typebox@1.4.3/node_modules/typebox/build/value/create/from_enum.mjs
3841
+ function FromEnum(context, type) {
3842
+ return FromType(context, Evaluate$1(type));
3843
+ }
3844
+ // ../../node_modules/.pnpm/typebox@1.4.3/node_modules/typebox/build/value/create/from_function.mjs
3845
+ function FromFunction(context, type) {
3846
+ const returnType = FromType(context, type.returnType);
3847
+ return () => returnType;
3848
+ }
3849
+ // ../../node_modules/.pnpm/typebox@1.4.3/node_modules/typebox/build/value/create/from_integer.mjs
3850
+ function FromInteger(_context, type) {
3851
+ return IsExclusiveMinimum(type) && IsNumber$1(type.exclusiveMinimum) ? type.exclusiveMinimum + 1 : IsMinimum(type) ? type.minimum : 0;
3852
+ }
3853
+ // ../../node_modules/.pnpm/typebox@1.4.3/node_modules/typebox/build/value/create/from_intersect.mjs
3854
+ function FromIntersect(context, type) {
3855
+ const instantiated = Instantiate(context, type);
3856
+ return FromType(context, Evaluate$1(instantiated));
3857
+ }
3858
+ // ../../node_modules/.pnpm/typebox@1.4.3/node_modules/typebox/build/value/create/from_literal.mjs
3859
+ function FromLiteral(_context, type) {
3860
+ return type.const;
3861
+ }
3862
+ // ../../node_modules/.pnpm/typebox@1.4.3/node_modules/typebox/build/value/create/from_never.mjs
3863
+ function FromNever(_context, type) {
3864
+ throw new CreateError(type, "Cannot create TNever types");
3865
+ }
3866
+ // ../../node_modules/.pnpm/typebox@1.4.3/node_modules/typebox/build/value/create/from_null.mjs
3867
+ function FromNull(_context, _type) {
3868
+ return null;
3869
+ }
3870
+ // ../../node_modules/.pnpm/typebox@1.4.3/node_modules/typebox/build/value/create/from_number.mjs
3871
+ function FromNumber(_context, type) {
3872
+ return IsExclusiveMinimum(type) && IsNumber$1(type.exclusiveMinimum) ? type.exclusiveMinimum + 1 : IsMinimum(type) ? type.minimum : 0;
3873
+ }
3874
+ // ../../node_modules/.pnpm/typebox@1.4.3/node_modules/typebox/build/value/create/from_object.mjs
3875
+ function FromObject(context, type) {
3876
+ return (IsUndefined$1(type.required) ? [] : type.required).reduce((result, key) => {
3877
+ return {
3878
+ ...result,
3879
+ [key]: FromType(context, type.properties[key])
3880
+ };
3881
+ }, {});
3882
+ }
3883
+ // ../../node_modules/.pnpm/typebox@1.4.3/node_modules/typebox/build/value/create/from_record.mjs
3884
+ function FromRecord(_context, type) {
3885
+ if (IsMinProperties(type) && !IsDefault(type)) throw new CreateError(type, "Record with the minProperties constraint must have a default annotation");
3886
+ return {};
3887
+ }
3888
+ // ../../node_modules/.pnpm/typebox@1.4.3/node_modules/typebox/build/value/create/from_ref.mjs
3889
+ function FromRef(context, type) {
3890
+ return HasPropertyKey$1(context, type.$ref) ? FromType(context, context[type.$ref]) : (() => {
3891
+ throw new CreateError(type, "Unable to deref Ref");
3892
+ })();
3893
+ }
3894
+ // ../../node_modules/.pnpm/typebox@1.4.3/node_modules/typebox/build/value/create/from_string.mjs
3895
+ function FromString(_context, type) {
3896
+ if ((IsPattern(type) || IsFormat(type)) && !IsDefault(type)) throw Error("Strings with format or pattern constraints must specify default");
3897
+ const minLength = IsMinLength(type) ? type.minLength : 0;
3898
+ return "".padEnd(minLength);
3899
+ }
3900
+ // ../../node_modules/.pnpm/typebox@1.4.3/node_modules/typebox/build/value/create/from_symbol.mjs
3901
+ function FromSymbol(_context, _type) {
3902
+ return Symbol();
3903
+ }
3904
+ // ../../node_modules/.pnpm/typebox@1.4.3/node_modules/typebox/build/value/create/from_template_literal.mjs
3905
+ function FromTemplateLiteral(context, type) {
3906
+ const decoded = TemplateLiteralDecode(type.pattern);
3907
+ if (IsString$2(decoded)) throw new CreateError(type, "Unable to create TemplateLiteral due to infinite type expansion");
3908
+ return FromType(context, decoded);
3909
+ }
3910
+ // ../../node_modules/.pnpm/typebox@1.4.3/node_modules/typebox/build/value/create/from_tuple.mjs
3911
+ function FromTuple(context, type) {
3912
+ return Array.from({ length: type.minItems }, (_, i) => FromType(context, type.items[i]));
3913
+ }
3914
+ // ../../node_modules/.pnpm/typebox@1.4.3/node_modules/typebox/build/value/create/from_union.mjs
3915
+ function FromUnion(context, type) {
3916
+ if (IsEqual$1(type.anyOf.length, 0)) throw Error("Unable to create Union with no variants");
3917
+ return FromType(context, type.anyOf[0]);
3918
+ }
3919
+ // ../../node_modules/.pnpm/typebox@1.4.3/node_modules/typebox/build/value/create/from_type.mjs
3920
+ function FromType(context, type) {
3921
+ return IsDefault(type) ? FromDefault(context, type) : IsArray$2(type) ? FromArray(context, type) : IsBigInt$2(type) ? FromBigInt(context, type) : IsBoolean$2(type) ? FromBoolean(context, type) : IsConstructor$2(type) ? FromConstructor(context, type) : IsCyclic(type) ? FromCyclic(context, type) : IsEnum$1(type) ? FromEnum(context, type) : IsFunction$2(type) ? FromFunction(context, type) : IsInteger$2(type) ? FromInteger(context, type) : IsIntersect(type) ? FromIntersect(context, type) : IsLiteral(type) ? FromLiteral(context, type) : IsNever(type) ? FromNever(context, type) : IsNull$2(type) ? FromNull(context, type) : IsNumber$2(type) ? FromNumber(context, type) : IsObject$2(type) ? FromObject(context, type) : IsRecord(type) ? FromRecord(context, type) : IsRef$1(type) ? FromRef(context, type) : IsString$2(type) ? FromString(context, type) : IsSymbol$2(type) ? FromSymbol(context, type) : IsTemplateLiteral(type) ? FromTemplateLiteral(context, type) : IsTuple(type) ? FromTuple(context, type) : IsUndefined$2(type) ? void 0 : IsUnion(type) ? FromUnion(context, type) : IsVoid(type) ? void 0 : void 0;
3922
+ }
3923
+ // ../../node_modules/.pnpm/typebox@1.4.3/node_modules/typebox/build/value/create/create.mjs
3924
+ /** Creates a value from the provided type. This function will use `default` annotations if present. */
3925
+ function Create(...args) {
3926
+ const [context, type] = Match$1(args, {
3927
+ 2: (context, type) => [context, type],
3928
+ 1: (type) => [{}, type]
3929
+ });
3930
+ return FromType(context, type);
3931
+ }
3932
+ // ../../node_modules/.pnpm/typebox@1.4.3/node_modules/typebox/build/value/parse/parse.mjs
3933
+ var ParseError = class extends AssertError {
3934
+ constructor(value, errors) {
3935
+ super("Parse", value, errors);
3936
+ }
3937
+ };
3938
+ function Assert(context, type, value) {
3939
+ EnableParseErrors();
3940
+ const errors = Errors(context, type, value);
3941
+ DisableParseErrors();
3942
+ if (!Check(context, type, value)) throw new ParseError(value, errors);
3943
+ return value;
3944
+ }
3945
+ const Parser = Pipeline([
3946
+ (_context, _type, value) => Clone(value),
3947
+ (context, type, value) => Default(context, type, value),
3948
+ (context, type, value) => Convert(context, type, value),
3949
+ (context, type, value) => Clean(context, type, value),
3950
+ (context, type, value) => Assert(context, type, value)
3951
+ ]);
3952
+ // ../../node_modules/.pnpm/typebox@1.4.3/node_modules/typebox/build/value/delta/edit.mjs
3953
+ const Insert = _Object_({
3954
+ type: Literal("insert"),
3955
+ path: String$1(),
3956
+ value: Unknown()
3957
+ });
3958
+ const Update = Object({
3959
+ type: Literal("update"),
3960
+ path: String$1(),
3961
+ value: Unknown()
3962
+ });
3963
+ const Delete = _Object_({
3964
+ type: Literal("delete"),
3965
+ path: String$1()
3966
+ });
3967
+ Union([
3968
+ Insert,
3969
+ Update,
3970
+ Delete
3971
+ ]);
3972
+ // ../../node_modules/.pnpm/typebox@1.4.3/node_modules/typebox/build/compile/validator.mjs
3973
+ var Validator = class {
3974
+ /** Constructs a Validator. */
3975
+ constructor(context, type) {
3976
+ this.hasCodec = HasCodec(context, type);
3977
+ this.buildResult = Build(context, type);
3978
+ this.evaluateResult = this.buildResult.Evaluate();
3979
+ }
3980
+ /** Returns true if this Validator is using JIT acceleration. */
3981
+ IsAccelerated() {
3982
+ return this.evaluateResult.IsAccelerated();
3983
+ }
3984
+ /** Returns the Context for this validator. */
3985
+ Context() {
3986
+ return this.buildResult.Context();
3987
+ }
3988
+ /** Returns the underlying Type used to construct this Validator. */
3989
+ Type() {
3990
+ return this.buildResult.Schema();
3991
+ }
3992
+ /** Returns the generated code for this validator. */
3993
+ Code() {
3994
+ return this.evaluateResult.Code();
3995
+ }
3996
+ /** Performs a type-guard check on the provided value. */
3997
+ Check(value) {
3998
+ return this.evaluateResult.Check(value);
3999
+ }
4000
+ /** Validates a value and returns it. Will throw if invalid. */
4001
+ Parse(value) {
4002
+ if (this.Check(value)) return value;
4003
+ if (Get$3().correctiveParse) return Parser(this.Context(), this.Type(), value);
4004
+ EnableParseErrors();
4005
+ const errors = this.Errors(value);
4006
+ DisableParseErrors();
4007
+ throw new ParseError(value, errors);
4008
+ }
4009
+ /** Returns an array of validation errors for the given value. */
4010
+ Errors(value) {
4011
+ if (this.IsAccelerated() && this.Check(value)) return [];
4012
+ return Errors(this.Context(), this.Type(), value);
4013
+ }
4014
+ /** Cleans a value using the Validator type. */
4015
+ Clean(value) {
4016
+ return Clean(this.Context(), this.Type(), value);
4017
+ }
4018
+ /** Converts a value using the Validator type. */
4019
+ Convert(value) {
4020
+ return Convert(this.Context(), this.Type(), value);
4021
+ }
4022
+ /** Creates a value using the Validator type. */
4023
+ Create() {
4024
+ return Create(this.Context(), this.Type());
4025
+ }
4026
+ /** Creates defaults using the Validator type. */
4027
+ Default(value) {
4028
+ return Default(this.Context(), this.Type(), value);
4029
+ }
4030
+ /** Decodes a value */
4031
+ Decode(value) {
4032
+ return this.hasCodec ? Decode(this.Context(), this.Type(), value) : this.Parse(value);
4033
+ }
4034
+ /** Encodes a value */
4035
+ Encode(value) {
4036
+ return this.hasCodec ? Encode(this.Context(), this.Type(), value) : this.Parse(value);
4037
+ }
4038
+ };
4039
+ // ../../node_modules/.pnpm/typebox@1.4.3/node_modules/typebox/build/compile/compile.mjs
4040
+ /** Compiles a type into a high performance Validator */
4041
+ function Compile(...args) {
4042
+ const [context, type] = Match$1(args, {
4043
+ 2: (context, type) => [context, type],
4044
+ 1: (type) => [{}, type]
4045
+ });
4046
+ return new Validator(context, type);
4047
+ }
4048
+ // ../../packages/core/src/icon-path.ts
4049
+ /** Selects a finished PNG for either supported tile picture size. */
4050
+ function generatedIconFile(icon, size) {
4051
+ return `${icon.assetId}-${icon.variant === "native" ? "native" : size}.png`;
4052
+ }
4053
+ /**
4054
+ * Names the finished PNG of one game-font glyph.
4055
+ *
4056
+ * @param assetId - The glyph's asset id, from the snapshot's glyph table.
4057
+ * @returns Its filename under `generated-icons/`.
4058
+ */
4059
+ function generatedGlyphFile(assetId) {
4060
+ return `${assetId}-glyph.png`;
4061
+ }
4062
+ // ../../packages/core/src/loader.ts
4063
+ /**
4064
+ * Finds the committed snapshot's directory, `data/` in the `@r0cksolid/emerald-core`
4065
+ * package, for a caller that loads it with {@link loadItemCatalog}. An app reaches it only
4066
+ * through this entry, never by path. It is found through the package's name rather than
4067
+ * this file's location, so it stays right from the sources, from the built package, and
4068
+ * from a bundle that inlines this entry but installs the package beside it. It resolves
4069
+ * only when called, so a bundle that loads a snapshot of its own runs without the package
4070
+ * installed.
4071
+ *
4072
+ * @returns The directory's absolute path.
4073
+ * @throws Error when `@r0cksolid/emerald-core` is not installed where the caller runs.
4074
+ */
4075
+ function committedDataDirectory() {
4076
+ return fileURLToPath(new URL("data/", import.meta.resolve("@r0cksolid/emerald-core/package.json")));
4077
+ }
4078
+ const snapshotCheck = Compile(SnapshotSchema);
4079
+ const metaCheck = Compile(MetaSchema);
4080
+ /**
4081
+ * Parses one snapshot file and checks its schema version. Nothing else is checked.
4082
+ *
4083
+ * @param directory - The snapshot directory.
4084
+ * @param name - The file to read from it.
4085
+ * @returns The parsed content, known only to carry this build's schema version.
4086
+ * @throws Error naming the file when it cannot be parsed, or when its `schemaVersion` is not
4087
+ * {@link SCHEMA_VERSION}.
4088
+ */
4089
+ async function readVersioned(directory, name) {
4090
+ const text = await readFile(join(directory, name), "utf8");
4091
+ let content;
4092
+ try {
4093
+ content = JSON.parse(text);
4094
+ } catch (error) {
4095
+ throw new Error(`Item-catalog file ${name} could not be parsed: ${String(error)}`, { cause: error });
4096
+ }
4097
+ const version = typeof content === "object" && content !== null && "schemaVersion" in content ? content.schemaVersion : void 0;
4098
+ if (version !== 9) throw new Error(`Unsupported item-catalog schema version ${String(version)} in ${name}; this build reads version 9.`);
4099
+ return content;
4100
+ }
4101
+ /** The eight bytes every PNG starts with. */
4102
+ const PNG_SIGNATURE = Buffer.from("89504e470d0a1a0a", "hex");
4103
+ /**
4104
+ * Reads a glyph PNG's size from its header: the width and height of its `IHDR` chunk,
4105
+ * which every PNG holds first, at bytes 16 to 23.
4106
+ *
4107
+ * @param directory - The trusted directory holding the PNG, already checked.
4108
+ * @param file - The PNG's file name.
4109
+ * @returns Its width and height in pixels.
4110
+ * @throws Error naming the file when it is not a PNG.
4111
+ */
4112
+ async function glyphSize(directory, file) {
4113
+ const bytes = await readFile(join(directory, file));
4114
+ const width = bytes.length >= 24 ? bytes.readUInt32BE(16) : 0;
4115
+ const height = bytes.length >= 24 ? bytes.readUInt32BE(20) : 0;
4116
+ if (!bytes.subarray(0, 8).equals(PNG_SIGNATURE) || bytes.toString("latin1", 12, 16) !== "IHDR" || width === 0 || height === 0) throw new Error(`Generated glyph ${file} is not a PNG.`);
4117
+ return {
4118
+ width,
4119
+ height
4120
+ };
4121
+ }
4122
+ /**
4123
+ * Reads `snapshot.json` and `snapshot.meta.json` and indexes them once.
4124
+ *
4125
+ * @remarks
4126
+ * Records, including each stat glyph's entry in the glyph table, are always checked
4127
+ * before any image is read and before indexing. With a generated-image directory, every
4128
+ * unique generated PNG reference, icons and glyphs alike, is checked too, and each glyph's
4129
+ * size is read from its PNG's header, so a page can lay it out before the image loads.
4130
+ * Without one, no image is read and the catalog's glyph table is empty, so item answers
4131
+ * carry no glyphs; generated icon references are returned unchecked.
4132
+ *
4133
+ * @param directory - The directory holding both files.
4134
+ * @param generatedDirectory - The trusted directory containing their finished PNGs, or
4135
+ * `null` to load without images. It is never optional, so a missing setting cannot skip
4136
+ * the image checks unnoticed.
4137
+ * @param options - How to write levels; see `CatalogOptions`. Glyph sizes come from the
4138
+ * generated images.
4139
+ * @returns Lookups backed by maps built during this call.
4140
+ * @throws Error when either file is missing, cannot be parsed, or has an unsupported schema
4141
+ * version, malformed records, a stat glyph that the glyph table lacks, or a family whose
4142
+ * members fall in different categories. A parse failure names the file. With a
4143
+ * generated-image directory, also on a missing/redirected PNG or a glyph file that is not
4144
+ * a PNG.
4145
+ */
4146
+ async function loadItemCatalog(directory, generatedDirectory, options = {}) {
4147
+ const snapshot = await readVersioned(directory, "snapshot.json");
4148
+ const meta = await readVersioned(directory, "snapshot.meta.json");
4149
+ if (!snapshotCheck.Check(snapshot)) throw new Error("Invalid item-catalog records in snapshot.json.");
4150
+ if (!metaCheck.Check(meta)) throw new Error("Invalid item-catalog records in snapshot.meta.json.");
4151
+ checkStatGlyphs(snapshot);
4152
+ if (generatedDirectory === null) return createItemCatalog(snapshot, meta, options);
4153
+ const files = /* @__PURE__ */ new Set([...snapshot.items.flatMap(({ icon }) => icon.kind === "generated" ? [generatedIconFile(icon, 32), generatedIconFile(icon, 48)] : []), ...Object.values(snapshot.glyphs).map(generatedGlyphFile)]);
4154
+ if (files.size) try {
4155
+ const root = await lstat(generatedDirectory);
4156
+ if (!root.isDirectory() || root.isSymbolicLink()) throw new Error("Generated image directory is redirected or not a directory.");
4157
+ const physicalRoot = await realpath(generatedDirectory);
4158
+ if (physicalRoot !== resolve(generatedDirectory)) throw new Error("Generated image directory has a redirected ancestor.");
4159
+ for (const file of files) {
4160
+ const path = join(generatedDirectory, file);
4161
+ const stat = await lstat(path);
4162
+ if (!stat.isFile() || stat.isSymbolicLink() || await realpath(path) !== join(physicalRoot, file)) throw new Error(`Invalid generated image ${file}.`);
4163
+ }
4164
+ } catch (cause) {
4165
+ throw new Error("A required generated image is missing or redirected.", { cause });
4166
+ }
4167
+ const glyphSizes = new Map(await Promise.all([...new Set(Object.values(snapshot.glyphs))].map(async (assetId) => [assetId, await glyphSize(generatedDirectory, generatedGlyphFile(assetId))])));
4168
+ return createItemCatalog(snapshot, meta, {
4169
+ ...options,
4170
+ glyphSizes
4171
+ });
4172
+ }
4173
+ // src/settings.ts
4174
+ const SettingsSchema = _Object_({ levels: Optional(LevelStyleSchema) }, { additionalProperties: false });
4175
+ /**
4176
+ * Where the settings live: the platform's per-user configuration directory. A relative
4177
+ * `XDG_CONFIG_HOME` is ignored, as the XDG spec says, so the path never depends on the
4178
+ * directory a command runs in.
4179
+ */
4180
+ function settingsPath() {
4181
+ const { XDG_CONFIG_HOME: xdg, APPDATA: appData } = process.env;
4182
+ const base = xdg && isAbsolute(xdg) && xdg || process.platform === "win32" && appData || join(homedir(), ".config");
4183
+ return join(base, "emerald", "settings.json");
4184
+ }
4185
+ /** Whether an error says a file doesn't exist. */
4186
+ const isMissing = (error) => error instanceof Error && "code" in error && error.code === "ENOENT";
4187
+ /**
4188
+ * Reads the saved settings.
4189
+ *
4190
+ * @returns The settings, empty when none have been saved.
4191
+ * @throws Error naming the file when it can't be read as settings.
4192
+ */
4193
+ async function readSettings() {
4194
+ const path = settingsPath();
4195
+ let text;
4196
+ try {
4197
+ text = await readFile(path, "utf8");
4198
+ } catch (error) {
4199
+ if (isMissing(error)) return {};
4200
+ throw error;
4201
+ }
4202
+ let settings;
4203
+ try {
4204
+ settings = JSON.parse(text.replace(/^\uFEFF/, ""));
4205
+ } catch {
4206
+ settings = void 0;
4207
+ }
4208
+ if (!Check(SettingsSchema, settings)) throw new Error(`${path} holds no valid settings. Fix or delete it.`);
4209
+ return settings;
4210
+ }
4211
+ /**
4212
+ * Saves settings over any saved before, creating the directory they live in.
4213
+ *
4214
+ * @param settings - Every setting to keep.
4215
+ */
4216
+ async function saveSettings(settings) {
4217
+ const path = settingsPath();
4218
+ await mkdir(dirname(path), { recursive: true });
4219
+ await writeFile(path, `${JSON.stringify(settings, null, 2)}\n`);
4220
+ }
4221
+ // src/command.ts
4222
+ /** The exit codes every command uses, as `--help` lists them. */
4223
+ const EXIT_CODES = [
4224
+ "0 success",
4225
+ "1 the request can't be answered, such as an unknown id or an unreadable snapshot",
4226
+ "2 a usage error"
4227
+ ];
4228
+ /** The options every command takes. */
4229
+ const SHARED_OPTIONS = {
4230
+ snapshot: {
4231
+ type: "string",
4232
+ value: "dir",
4233
+ description: "Load this snapshot directory instead of the committed one."
4234
+ },
4235
+ levels: {
4236
+ type: "string",
4237
+ value: "style",
4238
+ description: `Write levels as ${LEVEL_STYLES.join(" or ")}, over the saved setting.`
4239
+ },
4240
+ help: {
4241
+ type: "boolean",
4242
+ short: "h",
4243
+ description: "Show this help."
4244
+ }
4245
+ };
4246
+ /** A usage error: emerald prints it with a pointer to the command's `--help` and exits 2. */
4247
+ var UsageError = class extends Error {};
4248
+ /**
4249
+ * Parses a whole number of at least `min`, for an option such as `--limit`. A number
4250
+ * too large to hold exactly is rejected too.
4251
+ *
4252
+ * @param min - The smallest value allowed.
4253
+ * @returns The option's `parse` step.
4254
+ */
4255
+ const wholeNumber = (min) => (text) => {
4256
+ const value = Number(text);
4257
+ if (!/^[0-9]+$/.test(text) || value < min) throw new UsageError(`must be a whole number of at least ${min}, not "${text}".`);
4258
+ if (!Number.isSafeInteger(value)) throw new UsageError(`must be at most ${Number.MAX_SAFE_INTEGER.toLocaleString("en")}, not "${text}".`);
4259
+ return value;
4260
+ };
4261
+ /**
4262
+ * Declares a subcommand. The returned command parses its arguments, prints `--help`,
4263
+ * loads the catalog from `--snapshot` or the committed snapshot, in the level style of
4264
+ * `--levels` or the saved setting, and then calls `run`.
4265
+ *
4266
+ * @param spec - The command's name, summary, its one argument (several words when
4267
+ * `variadic`), its own options, and what it does with them.
4268
+ */
4269
+ function defineCommand(spec) {
4270
+ const options = {
4271
+ ...spec.options,
4272
+ ...SHARED_OPTIONS
4273
+ };
4274
+ const help = [
4275
+ `Usage: emerald ${spec.name} <${spec.argument.name}>${spec.argument.variadic ? "..." : ""} [options]`,
4276
+ "",
4277
+ spec.summary,
4278
+ "",
4279
+ "Options:",
4280
+ ...Object.entries(options).map(([name, option]) => {
4281
+ const flag = [..."short" in option ? [`-${option.short},`] : [], `--${name}${"value" in option ? ` <${option.value}>` : ""}`].join(" ");
4282
+ const fallback = "default" in option ? ` (default: ${String(option.default)})` : "";
4283
+ return ` ${flag.padEnd(20)}${option.description}${fallback}`;
4284
+ }),
4285
+ "",
4286
+ "Exit codes:",
4287
+ ...EXIT_CODES.map((line) => ` ${line}`)
4288
+ ].join("\n");
4289
+ return {
4290
+ name: spec.name,
4291
+ summary: spec.summary,
4292
+ async run(args) {
4293
+ let parsed;
4294
+ try {
4295
+ parsed = parseArgs({
4296
+ args: [...args],
4297
+ options,
4298
+ allowPositionals: true
4299
+ });
4300
+ } catch (error) {
4301
+ throw new UsageError(error instanceof Error ? error.message : String(error));
4302
+ }
4303
+ const { values, positionals } = parsed;
4304
+ const shared = values;
4305
+ if (shared.help) {
4306
+ console.log(help);
4307
+ return;
4308
+ }
4309
+ const [first, ...rest] = positionals;
4310
+ if (first === void 0) throw new UsageError(`missing <${spec.argument.name}>.`);
4311
+ if (rest.length > 0 && !spec.argument.variadic) throw new UsageError(`unexpected argument "${rest[0]}".`);
4312
+ if (shared.snapshot === "") throw new UsageError("--snapshot needs a directory.");
4313
+ if (shared.levels !== void 0 && !isLevelStyle(shared.levels)) throw new UsageError(`--levels must be ${LEVEL_STYLES.join(" or ")}, not "${shared.levels}".`);
4314
+ const parsedValues = { ...values };
4315
+ for (const [name, option] of Object.entries(spec.options)) {
4316
+ const value = parsedValues[name];
4317
+ if (!option.parse || typeof value !== "string") continue;
4318
+ try {
4319
+ parsedValues[name] = option.parse(value);
4320
+ } catch (error) {
4321
+ if (!(error instanceof UsageError)) throw error;
4322
+ throw new UsageError(`--${name} ${error.message}`);
4323
+ }
4324
+ }
4325
+ const catalog = await loadItemCatalog(resolve(process.env["INIT_CWD"] ?? process.cwd(), shared.snapshot ?? committedDataDirectory()), null, { levels: shared.levels ?? (await readSettings()).levels });
4326
+ await spec.run({
4327
+ values: parsedValues,
4328
+ argument: positionals.join(" "),
4329
+ catalog,
4330
+ item: (id) => {
4331
+ const item = catalog.summaryOf(id);
4332
+ if (!item) throw new Error(`no item has the id "${id}".`);
4333
+ return item;
4334
+ }
4335
+ });
4336
+ }
4337
+ };
4338
+ }
4339
+ // src/config.ts
4340
+ const STYLES = LEVEL_STYLES.join("|");
4341
+ /** `emerald config --help`, built here because no option or argument is shared with the rest. */
4342
+ const help = () => [
4343
+ `Usage: emerald config levels [${STYLES}]`,
4344
+ "",
4345
+ "Show or save how runes, enchanted books and minions write their level. With a style,",
4346
+ "saves it; without one, prints the current style.",
4347
+ "",
4348
+ `Settings file: ${settingsPath()}`,
4349
+ "",
4350
+ "Exit codes:",
4351
+ ...EXIT_CODES.map((line) => ` ${line}`)
4352
+ ].join("\n");
4353
+ /**
4354
+ * `emerald config levels [roman|number]`: shows or saves the level style. It isn't declared
4355
+ * with `defineCommand`, because that loads the catalog, which a setting has no use for.
4356
+ */
4357
+ const config = {
4358
+ name: "config",
4359
+ summary: "Show or save a setting.",
4360
+ async run(args) {
4361
+ let parsed;
4362
+ try {
4363
+ parsed = parseArgs({
4364
+ args: [...args],
4365
+ options: { help: {
4366
+ type: "boolean",
4367
+ short: "h"
4368
+ } },
4369
+ allowPositionals: true
4370
+ });
4371
+ } catch (error) {
4372
+ throw new UsageError(error instanceof Error ? error.message : String(error));
4373
+ }
4374
+ if (parsed.values.help) {
4375
+ console.log(help());
4376
+ return;
4377
+ }
4378
+ const [setting, value, extra] = parsed.positionals;
4379
+ if (setting === void 0) throw new UsageError("missing <setting>.");
4380
+ if (setting !== "levels") throw new UsageError(`unknown setting "${setting}"; try levels.`);
4381
+ if (extra !== void 0) throw new UsageError(`unexpected argument "${extra}".`);
4382
+ if (value === void 0) {
4383
+ console.log((await readSettings()).levels ?? "roman");
4384
+ return;
4385
+ }
4386
+ if (!isLevelStyle(value)) throw new UsageError(`levels must be ${LEVEL_STYLES.join(" or ")}, not "${value}".`);
4387
+ await saveSettings({
4388
+ ...await readSettings().catch(() => ({})),
4389
+ levels: value
4390
+ });
4391
+ console.log(value);
4392
+ }
4393
+ };
4394
+ // src/format-plan.ts
4395
+ /** Where a step's way comes from, such as `Kat`, `Trade` or `Buy from Oringo`. */
4396
+ function wayName(way) {
4397
+ if (way.method !== "npcShopsAndTrades" || isListedWay(way)) return METHOD_NAMES[way.method];
4398
+ return way.record.kind === "npc" ? `Buy from ${way.record.seller.displayName}` : "Trade";
4399
+ }
4400
+ /** What a step takes over all its runs, such as `128 × RAW_CHICKEN, 10,000 coins · 1d`. */
4401
+ function takesText({ inputs, currencies, coins, durationSeconds }) {
4402
+ const costs = [...[...inputs, ...currencies].map(({ id, count }) => `${number(count)} × ${id}`), ...coins > 0 ? [`${number(coins)} coins`] : []].join(", ");
4403
+ return [...costs ? [costs] : [], ...durationSeconds > 0 ? [durationText(durationSeconds)] : []].join(" · ");
4404
+ }
4405
+ /**
4406
+ * Prints an item's plan as text: numbered steps, inputs first, each with its way, runs and
4407
+ * tags, then what it takes and its unlock requirement; then the materials, each with its
4408
+ * ways as `emerald ways` lists them, and a gathered one with what buying it instead would
4409
+ * cost; then the totals that are not zero, labelled as base values. A section with
4410
+ * nothing in it is left out. Items are named by id, so one can be passed straight to
4411
+ * `emerald ways` or `emerald plan`.
4412
+ *
4413
+ * @param item - The item planned, for the title line.
4414
+ * @param count - How many of it the plan is for.
4415
+ * @param plan - Its plan, as the plan query answers it.
4416
+ */
4417
+ function formatPlan(item, count, plan) {
4418
+ const lines = [title(`${number(count)} × ${item.id} ${item.displayName}`)];
4419
+ const { steps, materials, totals } = plan;
4420
+ if (steps.length > 0) lines.push("", heading("Steps"));
4421
+ const width = String(steps.length).length;
4422
+ steps.forEach((step, index) => {
4423
+ const runs = `${number(step.runs)} run${step.runs === 1 ? "" : "s"}`;
4424
+ const indent = " ".repeat(width + 4);
4425
+ const takes = takesText(step);
4426
+ lines.push(` ${`${index + 1}.`.padStart(width + 1)} ${number(step.count)} × ${step.item} · ${wayName(step.way)}, ${runs}${tagsText(step.way)}`, ...takes ? [`${indent}${takes}`] : [], ...step.requirement ? [`${indent}${dim(step.requirement)}`] : []);
4427
+ });
4428
+ if (materials.length > 0) lines.push("", heading("Materials"));
4429
+ for (const material of materials) {
4430
+ const sections = waySections(material.ways);
4431
+ const bought = material.purchase;
4432
+ const buy = bought ? ` · ${dim(`or buy for ${number(bought.coins)} coins from ${bought.offer.seller.displayName}`)}` : "";
4433
+ lines.push(` ${number(material.count)} × ${material.item}${buy}`, ...sections.length === 0 ? [` ${NO_WAY}`] : [], ...sections.flatMap(({ heading: heading$1, lines: ways }) => [` ${heading(heading$1)}`, ...ways.map((line) => ` ${line}`)]));
4434
+ }
4435
+ const totalLines = [
4436
+ ...totals.coins > 0 ? [` Coins: ${number(totals.coins)}`] : [],
4437
+ ...totals.currencies.map(({ id, count }) => ` ${id}: ${number(count)}`),
4438
+ ...totals.durationSeconds > 0 ? [` Station time: ${durationText(totals.durationSeconds)}`] : []
4439
+ ];
4440
+ if (totalLines.length > 0) lines.push("", heading("Totals, at base values"), ...totalLines);
4441
+ return lines.join("\n");
4442
+ }
4443
+ // src/plan.ts
4444
+ /**
4445
+ * `emerald plan <item-id>`: prints the steps to get a count of an item, the materials they
4446
+ * stop at and the totals, as text or, with `--json`, exactly as the plan query answers.
4447
+ */
4448
+ const plan = defineCommand({
4449
+ name: "plan",
4450
+ summary: "Plan every step to get an item.",
4451
+ argument: { name: "item-id" },
4452
+ options: {
4453
+ json: {
4454
+ type: "boolean",
4455
+ description: "Print the plan query's answer as JSON."
4456
+ },
4457
+ count: {
4458
+ type: "string",
4459
+ value: "n",
4460
+ default: "1",
4461
+ parse: wholeNumber(1),
4462
+ description: "How many of the item to plan for."
4463
+ }
4464
+ },
4465
+ async run({ values, argument, catalog, item }) {
4466
+ const found = item(argument);
4467
+ const answer = itemPlan(catalog, found.id, values.count);
4468
+ console.log(values.json ? JSON.stringify(answer, null, 2) : formatPlan(found, values.count, answer));
4469
+ }
4470
+ });
4471
+ // src/format-search.ts
4472
+ /**
4473
+ * Prints a search page as text: an item row as its id, shown name and category on one
4474
+ * line; a family row as a heading with the family's name and category, then one indented
4475
+ * line per member with its id, shown name and rarity, the member the query named marked
4476
+ * with `>`. When more rows follow, a last line gives the `--offset` that shows them. Every
4477
+ * id printed can be passed straight to `emerald ways`.
4478
+ *
4479
+ * @param page - A page the core's search answered.
4480
+ */
4481
+ function formatSearch({ rows, nextOffset }) {
4482
+ const lines = rows.flatMap((row) => {
4483
+ if (row.kind === "item") {
4484
+ const { id, displayName, category } = row.item;
4485
+ return [`${title(id)} ${displayName} ${dim(category)}`];
4486
+ }
4487
+ const [first] = row.members;
4488
+ return [`${heading(first?.family.base ?? row.key)} ${dim(`${first?.category ?? ""} family`)}`, ...row.members.map(({ id, displayName, rarity }) => `${id === row.target ? ">" : " "} ${title(id)} ${displayName} ${dim(rarity)}`)];
4489
+ });
4490
+ if (nextOffset !== null) lines.push(dim(`more: --offset ${nextOffset}`));
4491
+ return lines.join("\n");
4492
+ }
4493
+ // src/search.ts
4494
+ /**
4495
+ * `emerald search <query>...`: finds items by name or id, ranked as the core's search ranks
4496
+ * them, so a person or an agent can find the id `emerald ways` takes.
4497
+ */
4498
+ const search = defineCommand({
4499
+ name: "search",
4500
+ summary: "Find items by name or id.",
4501
+ argument: {
4502
+ name: "query",
4503
+ variadic: true
4504
+ },
4505
+ options: {
4506
+ json: {
4507
+ type: "boolean",
4508
+ description: "Print the search page as JSON."
4509
+ },
4510
+ limit: {
4511
+ type: "string",
4512
+ value: "n",
4513
+ default: "25",
4514
+ parse: wholeNumber(1),
4515
+ description: "The most rows to print."
4516
+ },
4517
+ offset: {
4518
+ type: "string",
4519
+ value: "n",
4520
+ default: "0",
4521
+ parse: wholeNumber(0),
4522
+ description: "How many of the best rows to skip, for the next page."
4523
+ }
4524
+ },
4525
+ async run({ values, argument, catalog }) {
4526
+ const page = catalog.search(argument, values.limit, values.offset);
4527
+ if (values.json) console.log(JSON.stringify(page, null, 2));
4528
+ else if (page.rows.length > 0) console.log(formatSearch(page));
4529
+ }
4530
+ });
4531
+ // src/ways.ts
4532
+ /**
4533
+ * `emerald ways <item-id>`: prints every way to get the item, as text or, with `--json`,
4534
+ * exactly as the ways query answers it.
4535
+ */
4536
+ const ways = defineCommand({
4537
+ name: "ways",
4538
+ summary: "Print every way to get an item.",
4539
+ argument: { name: "item-id" },
4540
+ options: { json: {
4541
+ type: "boolean",
4542
+ description: "Print the ways query's answer as JSON."
4543
+ } },
4544
+ async run({ values, argument, catalog, item }) {
4545
+ const found = item(argument);
4546
+ const answer = itemWays(catalog, found.id);
4547
+ console.log(values.json ? JSON.stringify(answer, null, 2) : formatWays(found, answer));
4548
+ }
4549
+ });
4550
+ // src/run.ts
4551
+ const COMMANDS = new Map([
4552
+ search,
4553
+ ways,
4554
+ plan,
4555
+ config
4556
+ ].map((command) => [command.name, command]));
4557
+ const usage = [
4558
+ "Usage: emerald <command> [arguments]",
4559
+ "",
4560
+ "Run emerald with no command in a terminal to browse items interactively.",
4561
+ "",
4562
+ "Commands:",
4563
+ ...[...COMMANDS.values()].map(({ name, summary }) => ` ${name.padEnd(8)}${summary}`),
4564
+ "",
4565
+ "Run 'emerald <command> --help' for a command's arguments and options.",
4566
+ "",
4567
+ "Exit codes:",
4568
+ ...EXIT_CODES.map((line) => ` ${line}`)
4569
+ ].join("\n");
4570
+ /** Shows a failure as one line: a stack trace adds only noise for a user. */
4571
+ const messageOf = (error) => error instanceof Error ? error.message : String(error);
4572
+ /**
4573
+ * Runs `emerald` with the arguments after the program name, printing to the console.
4574
+ * `main.ts` calls it for the real command; tests call it in-process.
4575
+ *
4576
+ * @returns The exit code: 0 success, 1 an unanswerable request, 2 a usage error.
4577
+ */
4578
+ async function run(argv) {
4579
+ const [name, ...args] = argv;
4580
+ const command = name === void 0 ? void 0 : COMMANDS.get(name);
4581
+ if (name === void 0 && process.stdin.isTTY && process.stdout.isTTY) try {
4582
+ const { levels } = await readSettings();
4583
+ const catalog = await loadItemCatalog(committedDataDirectory(), null, { levels });
4584
+ const { runInteractive } = await import("./terminal-CMDocsw8.mjs");
4585
+ await runInteractive(catalog);
4586
+ return 0;
4587
+ } catch (error) {
4588
+ console.error(`emerald: ${messageOf(error)}`);
4589
+ return 1;
4590
+ }
4591
+ if (name === "--help" || name === "-h") {
4592
+ console.log(usage);
4593
+ return 0;
4594
+ }
4595
+ if (command) try {
4596
+ await command.run(args);
4597
+ return 0;
4598
+ } catch (error) {
4599
+ console.error(`emerald ${command.name}: ${messageOf(error)}`);
4600
+ if (error instanceof UsageError) console.error(`Run 'emerald ${command.name} --help' for its usage.`);
4601
+ return error instanceof UsageError ? 2 : 1;
4602
+ }
4603
+ if (name !== void 0) console.error(`emerald: unknown command "${name}".\n`);
4604
+ console.error(usage);
4605
+ return 2;
4606
+ }
4607
+ // src/main.ts
4608
+ process.exitCode = await run(process.argv.slice(2));
4609
+ export {};