@dynamicalsystems/idl-conformance 0.6.1

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.
Files changed (104) hide show
  1. package/LICENSE +191 -0
  2. package/assets/vectors/dsg.infra.adoption-fact_1/accept/fact-cutover-transfer.json +7 -0
  3. package/assets/vectors/dsg.infra.adoption-fact_1/accept/fact-synthetic-initialize.json +7 -0
  4. package/assets/vectors/dsg.infra.adoption-fact_1/reject/fact-extra-field.json +8 -0
  5. package/assets/vectors/dsg.infra.adoption-fact_1/reject/fact-generation-zero.json +8 -0
  6. package/assets/vectors/dsg.infra.adoption-fact_1/reject/fact-restore-claims-ownership.json +8 -0
  7. package/assets/vectors/dsg.infra.adoption-fact_1/reject/fact-short-snapshot-digest.json +8 -0
  8. package/assets/vectors/dsg.infra.adoption-fact_1/reject/fact-wrong-profile-v2.json +8 -0
  9. package/assets/vectors/dsg.infra.resource-descriptor_1/accept/descriptor-cpu-only-null-accelerator.json +7 -0
  10. package/assets/vectors/dsg.infra.resource-descriptor_1/accept/descriptor-s02-batch-fixture.json +7 -0
  11. package/assets/vectors/dsg.infra.resource-descriptor_1/accept/descriptor-s02-fake-provider-fixture.json +7 -0
  12. package/assets/vectors/dsg.infra.resource-descriptor_1/reject/descriptor-external-ip-true.json +8 -0
  13. package/assets/vectors/dsg.infra.resource-descriptor_1/reject/descriptor-extra-field.json +8 -0
  14. package/assets/vectors/dsg.infra.resource-descriptor_1/reject/descriptor-missing-reservation.json +8 -0
  15. package/assets/vectors/dsg.infra.resource-descriptor_1/reject/descriptor-open-machine-shape.json +8 -0
  16. package/assets/vectors/dsg.infra.resource-descriptor_1/reject/descriptor-public-network.json +8 -0
  17. package/assets/vectors/dsg.infra.resource-descriptor_1/reject/descriptor-schema-version-2.json +8 -0
  18. package/assets/vectors/dsg.infra.resource-descriptor_1/reject/descriptor-unprefixed-image-digest.json +8 -0
  19. package/assets/vectors/dsg.infra.resource-descriptor_1/reject/descriptor-wrong-kind.json +8 -0
  20. package/assets/vectors/dsg.infra.signed-law_1/accept/bundle-k02-automation-control.json +7 -0
  21. package/assets/vectors/dsg.infra.signed-law_1/accept/bundle-k02-synthetic-law.json +7 -0
  22. package/assets/vectors/dsg.infra.signed-law_1/reject/bundle-bootstrap-two-uses.json +8 -0
  23. package/assets/vectors/dsg.infra.signed-law_1/reject/bundle-capabilities-descriptor-version-mismatch.json +8 -0
  24. package/assets/vectors/dsg.infra.signed-law_1/reject/bundle-capability-public-network.json +8 -0
  25. package/assets/vectors/dsg.infra.signed-law_1/reject/bundle-ceiling-negative-value.json +8 -0
  26. package/assets/vectors/dsg.infra.signed-law_1/reject/bundle-extra-field.json +8 -0
  27. package/assets/vectors/dsg.infra.signed-law_1/reject/bundle-policy-manifest-traversal-key.json +8 -0
  28. package/assets/vectors/dsg.infra.signed-law_1/reject/bundle-scope-descriptor-version-v2.json +8 -0
  29. package/assets/vectors/dsg.infra.signed-law_1/reject/bundle-short-signature.json +8 -0
  30. package/assets/vectors/dsg.infra.signed-law_1/reject/bundle-unknown-key-class.json +8 -0
  31. package/assets/vectors/dsg.infra.signed-law_1/reject/bundle-wrong-kind.json +8 -0
  32. package/assets/vectors/dsg.kernel.bootstrap_1/accept/intent-enroll-human-root.json +7 -0
  33. package/assets/vectors/dsg.kernel.bootstrap_1/accept/intent-initialize.json +7 -0
  34. package/assets/vectors/dsg.kernel.bootstrap_1/accept/signed-enroll-signed.json +7 -0
  35. package/assets/vectors/dsg.kernel.bootstrap_1/reject/intent-empty-resources.json +8 -0
  36. package/assets/vectors/dsg.kernel.bootstrap_1/reject/intent-extra-field.json +8 -0
  37. package/assets/vectors/dsg.kernel.bootstrap_1/reject/intent-two-uses.json +8 -0
  38. package/assets/vectors/dsg.kernel.bootstrap_1/reject/intent-unknown-action.json +8 -0
  39. package/assets/vectors/dsg.kernel.bootstrap_1/reject/intent-version-v2.json +8 -0
  40. package/assets/vectors/dsg.kernel.bootstrap_1/reject/signed-short-signature.json +8 -0
  41. package/assets/vectors/dsg.kernel.dispatch-consume_1/accept/lease-kernel-201-live-capture.json +7 -0
  42. package/assets/vectors/dsg.kernel.dispatch-consume_1/accept/lease-replayed-stale.json +7 -0
  43. package/assets/vectors/dsg.kernel.dispatch-consume_1/accept/refusal-revoked.json +7 -0
  44. package/assets/vectors/dsg.kernel.dispatch-consume_1/accept/request-first-consume.json +7 -0
  45. package/assets/vectors/dsg.kernel.dispatch-consume_1/accept/request-renewal.json +7 -0
  46. package/assets/vectors/dsg.kernel.dispatch-consume_1/reject/lease-fractional-expires-at.json +8 -0
  47. package/assets/vectors/dsg.kernel.dispatch-consume_1/reject/lease-missing-profile.json +8 -0
  48. package/assets/vectors/dsg.kernel.dispatch-consume_1/reject/lease-renewal-wrong-literal.json +8 -0
  49. package/assets/vectors/dsg.kernel.dispatch-consume_1/reject/lease-skew-above-bound.json +8 -0
  50. package/assets/vectors/dsg.kernel.dispatch-consume_1/reject/refusal-empty-issues.json +8 -0
  51. package/assets/vectors/dsg.kernel.dispatch-consume_1/reject/refusal-unknown-code.json +8 -0
  52. package/assets/vectors/dsg.kernel.dispatch-consume_1/reject/request-extra-field.json +8 -0
  53. package/assets/vectors/dsg.kernel.dispatch-consume_1/reject/request-fractional-requested-at.json +8 -0
  54. package/assets/vectors/dsg.kernel.dispatch-consume_1/reject/request-malformed-case-orn.json +8 -0
  55. package/assets/vectors/dsg.kernel.dispatch-consume_1/reject/request-negative-generation.json +8 -0
  56. package/assets/vectors/dsg.kernel.dispatch-consume_1/reject/request-uppercase-envelope-digest.json +8 -0
  57. package/assets/vectors/dsg.kernel.ordinary-authority_1/accept/authority-human-enrollment.json +7 -0
  58. package/assets/vectors/dsg.kernel.ordinary-authority_1/accept/authority-synthetic-enrollment.json +7 -0
  59. package/assets/vectors/dsg.kernel.ordinary-authority_1/reject/authority-empty-actions.json +8 -0
  60. package/assets/vectors/dsg.kernel.ordinary-authority_1/reject/authority-extra-field.json +8 -0
  61. package/assets/vectors/dsg.kernel.ordinary-authority_1/reject/authority-fractional-not-before.json +8 -0
  62. package/assets/vectors/dsg.kernel.ordinary-authority_1/reject/authority-missing-ceilings.json +8 -0
  63. package/assets/vectors/dsg.kernel.ordinary-authority_1/reject/authority-release-automation-key-class.json +8 -0
  64. package/assets/vectors/dsg.kernel.ordinary-authority_1/reject/authority-version-v2.json +8 -0
  65. package/assets/vectors/dsg.registry.revocations_1/accept/pointer-v2.json +7 -0
  66. package/assets/vectors/dsg.registry.revocations_1/accept/snapshot-chained-with-entries.json +7 -0
  67. package/assets/vectors/dsg.registry.revocations_1/accept/snapshot-genesis.json +7 -0
  68. package/assets/vectors/dsg.registry.revocations_1/reject/pointer-traversal-url.json +8 -0
  69. package/assets/vectors/dsg.registry.revocations_1/reject/snapshot-extra-field.json +8 -0
  70. package/assets/vectors/dsg.registry.revocations_1/reject/snapshot-not-test-only.json +8 -0
  71. package/assets/vectors/dsg.registry.revocations_1/reject/snapshot-version-zero.json +8 -0
  72. package/assets/vectors/dsg.registry.revocations_1/reject/snapshot-wrong-domain-v2.json +8 -0
  73. package/assets/vectors/dsg.run.operation_1/accept/accepted-receipt-fractional-accepted-at.json +7 -0
  74. package/assets/vectors/dsg.run.operation_1/accept/readback-queued-pending.json +7 -0
  75. package/assets/vectors/dsg.run.operation_1/accept/request-minimal-valid.json +7 -0
  76. package/assets/vectors/dsg.run.operation_1/digest/envelope-m010-envelope-digest.json +8 -0
  77. package/assets/vectors/dsg.run.operation_1/reject/accepted-missing-plan-digest.json +8 -0
  78. package/assets/vectors/dsg.run.operation_1/reject/request-document-schema-version-2.json +8 -0
  79. package/assets/vectors/dsg.run.operation_1/reject/request-extra-field.json +8 -0
  80. package/assets/vectors/dsg.run.operation_1/reject/request-r01-original-short-orn.json +8 -0
  81. package/assets/vectors/dsg.run.operation_1/reject/request-uppercase-plan-digest.json +8 -0
  82. package/assets/vectors/dsg.run.operation_1/reject/request-wrong-profile-other.json +8 -0
  83. package/assets/vectors/dsg.run.operation_1/reject/request-wrong-profile-v2.json +8 -0
  84. package/checklist.json +12 -0
  85. package/dist/cli.cjs +16 -0
  86. package/dist/cli.d.cts +1 -0
  87. package/dist/cli.d.mts +1 -0
  88. package/dist/cli.mjs +19 -0
  89. package/dist/cli.mjs.map +1 -0
  90. package/dist/index.cjs +4 -0
  91. package/dist/index.d.cts +57 -0
  92. package/dist/index.d.cts.map +1 -0
  93. package/dist/index.d.mts +57 -0
  94. package/dist/index.d.mts.map +1 -0
  95. package/dist/index.mjs +2 -0
  96. package/dist/reference-adapter-CaAo2iIH.mjs +1441 -0
  97. package/dist/reference-adapter-CaAo2iIH.mjs.map +1 -0
  98. package/dist/reference-adapter-DWurDAI9.cjs +1450 -0
  99. package/package.json +64 -0
  100. package/src/adapter.ts +32 -0
  101. package/src/cli.ts +19 -0
  102. package/src/index.ts +4 -0
  103. package/src/reference-adapter.ts +42 -0
  104. package/src/runner.ts +89 -0
@@ -0,0 +1,1441 @@
1
+ import { readFileSync, readdirSync } from "node:fs";
2
+ import { join } from "node:path";
3
+ import { createHash } from "node:crypto";
4
+ import { jcsStringify } from "@dynamicalsystems/orn-schemas";
5
+ import { PROFILES } from "@dynamicalsystems/idl";
6
+ //#region src/runner.ts
7
+ /** Runs every vector under `assetsDir` through the adapter. The checklist
8
+ * is the coverage floor: a profile listed there with fewer vectors on disk
9
+ * than promised fails the run, so a silently deleted directory cannot pass. */
10
+ function runVectors(adapter, assetsDir, checklist) {
11
+ const verdicts = [];
12
+ for (const [profile, expectedCount] of Object.entries(checklist.profiles)) {
13
+ const dir = join(assetsDir, profile.replaceAll("/", "_"));
14
+ let files = [];
15
+ for (const verdict of [
16
+ "accept",
17
+ "reject",
18
+ "digest"
19
+ ]) {
20
+ let names = [];
21
+ try {
22
+ names = readdirSync(join(dir, verdict)).filter((f) => f.endsWith(".json"));
23
+ } catch {
24
+ names = [];
25
+ }
26
+ files = files.concat(names.map((n) => join(dir, verdict, n)));
27
+ }
28
+ if (files.length < expectedCount) {
29
+ verdicts.push({
30
+ id: profile,
31
+ expected: "accept",
32
+ outcome: "fail",
33
+ detail: `checklist promises ${expectedCount} vectors, found ${files.length}`
34
+ });
35
+ continue;
36
+ }
37
+ for (const file of files) {
38
+ const vector = JSON.parse(readFileSync(file, "utf8"));
39
+ const isDigest = file.includes("/digest/");
40
+ const key = isDigest ? `${vector.profile}#digest.${vector.shape}` : `${vector.profile}#${vector.shape}`;
41
+ const parse = adapter[key];
42
+ if (parse === void 0 && vector.obligation === "semantic") continue;
43
+ if (parse === void 0) {
44
+ verdicts.push({
45
+ id: `${key}/${vector.name}`,
46
+ expected: vector.verdict,
47
+ outcome: "fail",
48
+ detail: "adapter has no parser for this shape"
49
+ });
50
+ continue;
51
+ }
52
+ const result = parse(Buffer.from(vector.bytes, "base64"));
53
+ const agreed = isDigest ? result.ok && result.digest === vector.sha256 : result.ok === (vector.verdict === "accept");
54
+ verdicts.push({
55
+ id: `${vector.profile}#${vector.shape}/${vector.name}`,
56
+ expected: vector.verdict,
57
+ outcome: agreed ? "pass" : "fail",
58
+ detail: agreed ? vector.rule ?? "" : isDigest ? result.ok ? `digest mismatch: computed ${result.digest ?? "nothing"}, vector pins ${vector.sha256 ?? "nothing"}` : `could not digest: ${result.reason}` : result.ok ? `accepted but must reject: ${vector.rule ?? "unnamed rule"}` : `rejected but must accept: ${result.reason}`
59
+ });
60
+ }
61
+ }
62
+ const failed = verdicts.filter((v) => v.outcome === "fail").length;
63
+ return {
64
+ passed: verdicts.length - failed,
65
+ failed,
66
+ verdicts
67
+ };
68
+ }
69
+ //#endregion
70
+ //#region ../../node_modules/.pnpm/@sinclair+typebox@0.34.52/node_modules/@sinclair/typebox/build/esm/value/guard/guard.mjs
71
+ /** Returns true if this value is an async iterator */
72
+ function IsAsyncIterator$1(value) {
73
+ return IsObject$2(value) && globalThis.Symbol.asyncIterator in value;
74
+ }
75
+ /** Returns true if this value is an iterator */
76
+ function IsIterator$1(value) {
77
+ return IsObject$2(value) && globalThis.Symbol.iterator in value;
78
+ }
79
+ /** Returns true if this value is a Promise */
80
+ function IsPromise$1(value) {
81
+ return value instanceof globalThis.Promise;
82
+ }
83
+ /** Returns true if this value is a Date */
84
+ function IsDate$2(value) {
85
+ return value instanceof Date && globalThis.Number.isFinite(value.getTime());
86
+ }
87
+ /** Returns true if the value is a Uint8Array */
88
+ function IsUint8Array$2(value) {
89
+ return value instanceof globalThis.Uint8Array;
90
+ }
91
+ /** Returns true of this value is an object type */
92
+ function IsObject$2(value) {
93
+ return value !== null && typeof value === "object";
94
+ }
95
+ /** Returns true if this value is an array, but not a typed array */
96
+ function IsArray$2(value) {
97
+ return globalThis.Array.isArray(value) && !globalThis.ArrayBuffer.isView(value);
98
+ }
99
+ /** Returns true if this value is an undefined */
100
+ function IsUndefined$1(value) {
101
+ return value === void 0;
102
+ }
103
+ /** Returns true if this value is an null */
104
+ function IsNull$1(value) {
105
+ return value === null;
106
+ }
107
+ /** Returns true if this value is an boolean */
108
+ function IsBoolean$1(value) {
109
+ return typeof value === "boolean";
110
+ }
111
+ /** Returns true if this value is an number */
112
+ function IsNumber$1(value) {
113
+ return typeof value === "number";
114
+ }
115
+ /** Returns true if this value is an integer */
116
+ function IsInteger$1(value) {
117
+ return globalThis.Number.isInteger(value);
118
+ }
119
+ /** Returns true if this value is bigint */
120
+ function IsBigInt$1(value) {
121
+ return typeof value === "bigint";
122
+ }
123
+ /** Returns true if this value is string */
124
+ function IsString$2(value) {
125
+ return typeof value === "string";
126
+ }
127
+ /** Returns true if this value is a function */
128
+ function IsFunction$1(value) {
129
+ return typeof value === "function";
130
+ }
131
+ /** Returns true if this value is a symbol */
132
+ function IsSymbol$1(value) {
133
+ return typeof value === "symbol";
134
+ }
135
+ //#endregion
136
+ //#region ../../node_modules/.pnpm/@sinclair+typebox@0.34.52/node_modules/@sinclair/typebox/build/esm/system/policy.mjs
137
+ var TypeSystemPolicy;
138
+ (function(TypeSystemPolicy) {
139
+ /**
140
+ * Configures the instantiation behavior of TypeBox types. The `default` option assigns raw JavaScript
141
+ * references for embedded types, which may cause side effects if type properties are explicitly updated
142
+ * outside the TypeBox type builder. The `clone` option creates copies of any shared types upon creation,
143
+ * preventing unintended side effects. The `freeze` option applies `Object.freeze()` to the type, making
144
+ * it fully readonly and immutable. Implementations should use `default` whenever possible, as it is the
145
+ * fastest way to instantiate types. The default setting is `default`.
146
+ */
147
+ TypeSystemPolicy.InstanceMode = "default";
148
+ /** Sets whether TypeBox should assert optional properties using the TypeScript `exactOptionalPropertyTypes` assertion policy. The default is `false` */
149
+ TypeSystemPolicy.ExactOptionalPropertyTypes = false;
150
+ /** Sets whether arrays should be treated as a kind of objects. The default is `false` */
151
+ TypeSystemPolicy.AllowArrayObject = false;
152
+ /** Sets whether `NaN` or `Infinity` should be treated as valid numeric values. The default is `false` */
153
+ TypeSystemPolicy.AllowNaN = false;
154
+ /** Sets whether `null` should validate for void types. The default is `false` */
155
+ TypeSystemPolicy.AllowNullVoid = false;
156
+ /** Checks this value using the ExactOptionalPropertyTypes policy */
157
+ function IsExactOptionalProperty(value, key) {
158
+ return TypeSystemPolicy.ExactOptionalPropertyTypes ? key in value : value[key] !== void 0;
159
+ }
160
+ TypeSystemPolicy.IsExactOptionalProperty = IsExactOptionalProperty;
161
+ /** Checks this value using the AllowArrayObjects policy */
162
+ function IsObjectLike(value) {
163
+ const isObject = IsObject$2(value);
164
+ return TypeSystemPolicy.AllowArrayObject ? isObject : isObject && !IsArray$2(value);
165
+ }
166
+ TypeSystemPolicy.IsObjectLike = IsObjectLike;
167
+ /** Checks this value as a record using the AllowArrayObjects policy */
168
+ function IsRecordLike(value) {
169
+ return IsObjectLike(value) && !(value instanceof Date) && !(value instanceof Uint8Array);
170
+ }
171
+ TypeSystemPolicy.IsRecordLike = IsRecordLike;
172
+ /** Checks this value using the AllowNaN policy */
173
+ function IsNumberLike(value) {
174
+ return TypeSystemPolicy.AllowNaN ? IsNumber$1(value) : Number.isFinite(value);
175
+ }
176
+ TypeSystemPolicy.IsNumberLike = IsNumberLike;
177
+ /** Checks this value using the AllowVoidNull policy */
178
+ function IsVoidLike(value) {
179
+ const isUndefined = IsUndefined$1(value);
180
+ return TypeSystemPolicy.AllowNullVoid ? isUndefined || value === null : isUndefined;
181
+ }
182
+ TypeSystemPolicy.IsVoidLike = IsVoidLike;
183
+ })(TypeSystemPolicy || (TypeSystemPolicy = {}));
184
+ //#endregion
185
+ //#region ../../node_modules/.pnpm/@sinclair+typebox@0.34.52/node_modules/@sinclair/typebox/build/esm/type/registry/format.mjs
186
+ /** A registry for user defined string formats */
187
+ const map$1 = /* @__PURE__ */ new Map();
188
+ /** Returns true if the user defined string format exists */
189
+ function Has$1(format) {
190
+ return map$1.has(format);
191
+ }
192
+ /** Gets a validation function for a user defined string format */
193
+ function Get$1(format) {
194
+ return map$1.get(format);
195
+ }
196
+ //#endregion
197
+ //#region ../../node_modules/.pnpm/@sinclair+typebox@0.34.52/node_modules/@sinclair/typebox/build/esm/type/registry/type.mjs
198
+ /** A registry for user defined types */
199
+ const map = /* @__PURE__ */ new Map();
200
+ /** Returns true if this registry contains this kind */
201
+ function Has(kind) {
202
+ return map.has(kind);
203
+ }
204
+ /** Gets a custom validation function for a user defined type */
205
+ function Get(kind) {
206
+ return map.get(kind);
207
+ }
208
+ //#endregion
209
+ //#region ../../node_modules/.pnpm/@sinclair+typebox@0.34.52/node_modules/@sinclair/typebox/build/esm/type/guard/value.mjs
210
+ /** Returns true if this value is an array */
211
+ function IsArray$1(value) {
212
+ return Array.isArray(value);
213
+ }
214
+ /** Returns true if this value is a Date object */
215
+ function IsDate$1(value) {
216
+ return value instanceof globalThis.Date;
217
+ }
218
+ /** Returns true if this value is an object */
219
+ function IsObject$1(value) {
220
+ return typeof value === "object" && value !== null;
221
+ }
222
+ /** Returns true if this value is RegExp */
223
+ function IsRegExp$1(value) {
224
+ return value instanceof globalThis.RegExp;
225
+ }
226
+ /** Returns true if this value is string */
227
+ function IsString$1(value) {
228
+ return typeof value === "string";
229
+ }
230
+ /** Returns true if this value is a Uint8Array */
231
+ function IsUint8Array$1(value) {
232
+ return value instanceof globalThis.Uint8Array;
233
+ }
234
+ //#endregion
235
+ //#region ../../node_modules/.pnpm/@sinclair+typebox@0.34.52/node_modules/@sinclair/typebox/build/esm/type/create/immutable.mjs
236
+ function ImmutableArray(value) {
237
+ return globalThis.Object.freeze(value).map((value) => Immutable(value));
238
+ }
239
+ function ImmutableDate(value) {
240
+ return value;
241
+ }
242
+ function ImmutableUint8Array(value) {
243
+ return value;
244
+ }
245
+ function ImmutableRegExp(value) {
246
+ return value;
247
+ }
248
+ function ImmutableObject(value) {
249
+ const result = {};
250
+ for (const key of Object.getOwnPropertyNames(value)) result[key] = Immutable(value[key]);
251
+ for (const key of Object.getOwnPropertySymbols(value)) result[key] = Immutable(value[key]);
252
+ return globalThis.Object.freeze(result);
253
+ }
254
+ /** Specialized deep immutable value. Applies freeze recursively to the given value */
255
+ function Immutable(value) {
256
+ return IsArray$1(value) ? ImmutableArray(value) : IsDate$1(value) ? ImmutableDate(value) : IsUint8Array$1(value) ? ImmutableUint8Array(value) : IsRegExp$1(value) ? ImmutableRegExp(value) : IsObject$1(value) ? ImmutableObject(value) : value;
257
+ }
258
+ //#endregion
259
+ //#region ../../node_modules/.pnpm/@sinclair+typebox@0.34.52/node_modules/@sinclair/typebox/build/esm/type/clone/value.mjs
260
+ function ArrayType$1(value) {
261
+ return value.map((value) => Visit$3(value));
262
+ }
263
+ function DateType$1(value) {
264
+ return new Date(value.getTime());
265
+ }
266
+ function Uint8ArrayType$1(value) {
267
+ return new Uint8Array(value);
268
+ }
269
+ function RegExpType(value) {
270
+ return new RegExp(value.source, value.flags);
271
+ }
272
+ function ObjectType$1(value) {
273
+ const result = {};
274
+ for (const key of Object.getOwnPropertyNames(value)) result[key] = Visit$3(value[key]);
275
+ for (const key of Object.getOwnPropertySymbols(value)) result[key] = Visit$3(value[key]);
276
+ return result;
277
+ }
278
+ function Visit$3(value) {
279
+ return IsArray$1(value) ? ArrayType$1(value) : IsDate$1(value) ? DateType$1(value) : IsUint8Array$1(value) ? Uint8ArrayType$1(value) : IsRegExp$1(value) ? RegExpType(value) : IsObject$1(value) ? ObjectType$1(value) : value;
280
+ }
281
+ /** Clones a value */
282
+ function Clone(value) {
283
+ return Visit$3(value);
284
+ }
285
+ //#endregion
286
+ //#region ../../node_modules/.pnpm/@sinclair+typebox@0.34.52/node_modules/@sinclair/typebox/build/esm/type/create/type.mjs
287
+ /** Creates TypeBox schematics using the configured InstanceMode */
288
+ function CreateType(schema, options) {
289
+ const result = options !== void 0 ? {
290
+ ...options,
291
+ ...schema
292
+ } : schema;
293
+ switch (TypeSystemPolicy.InstanceMode) {
294
+ case "freeze": return Immutable(result);
295
+ case "clone": return Clone(result);
296
+ default: return result;
297
+ }
298
+ }
299
+ //#endregion
300
+ //#region ../../node_modules/.pnpm/@sinclair+typebox@0.34.52/node_modules/@sinclair/typebox/build/esm/type/symbols/symbols.mjs
301
+ /** Symbol key applied to types */
302
+ const Kind = Symbol.for("TypeBox.Kind");
303
+ //#endregion
304
+ //#region ../../node_modules/.pnpm/@sinclair+typebox@0.34.52/node_modules/@sinclair/typebox/build/esm/type/error/error.mjs
305
+ /** The base Error type thrown for all TypeBox exceptions */
306
+ var TypeBoxError = class extends Error {
307
+ constructor(message) {
308
+ super(message);
309
+ }
310
+ };
311
+ //#endregion
312
+ //#region ../../node_modules/.pnpm/@sinclair+typebox@0.34.52/node_modules/@sinclair/typebox/build/esm/type/never/never.mjs
313
+ /** `[Json]` Creates a Never type */
314
+ function Never(options) {
315
+ return CreateType({
316
+ [Kind]: "Never",
317
+ not: {}
318
+ }, options);
319
+ }
320
+ //#endregion
321
+ //#region ../../node_modules/.pnpm/@sinclair+typebox@0.34.52/node_modules/@sinclair/typebox/build/esm/type/guard/kind.mjs
322
+ /** `[Kind-Only]` Returns true if the given value is TAny */
323
+ function IsAny(value) {
324
+ return IsKindOf(value, "Any");
325
+ }
326
+ /** `[Kind-Only]` Returns true if the given value is TArgument */
327
+ function IsArgument(value) {
328
+ return IsKindOf(value, "Argument");
329
+ }
330
+ /** `[Kind-Only]` Returns true if the given value is TArray */
331
+ function IsArray(value) {
332
+ return IsKindOf(value, "Array");
333
+ }
334
+ /** `[Kind-Only]` Returns true if the given value is TAsyncIterator */
335
+ function IsAsyncIterator(value) {
336
+ return IsKindOf(value, "AsyncIterator");
337
+ }
338
+ /** `[Kind-Only]` Returns true if the given value is TBigInt */
339
+ function IsBigInt(value) {
340
+ return IsKindOf(value, "BigInt");
341
+ }
342
+ /** `[Kind-Only]` Returns true if the given value is TBoolean */
343
+ function IsBoolean(value) {
344
+ return IsKindOf(value, "Boolean");
345
+ }
346
+ /** `[Kind-Only]` Returns true if the given value is TComputed */
347
+ function IsComputed(value) {
348
+ return IsKindOf(value, "Computed");
349
+ }
350
+ /** `[Kind-Only]` Returns true if the given value is TConstructor */
351
+ function IsConstructor(value) {
352
+ return IsKindOf(value, "Constructor");
353
+ }
354
+ /** `[Kind-Only]` Returns true if the given value is TDate */
355
+ function IsDate(value) {
356
+ return IsKindOf(value, "Date");
357
+ }
358
+ /** `[Kind-Only]` Returns true if the given value is TFunction */
359
+ function IsFunction(value) {
360
+ return IsKindOf(value, "Function");
361
+ }
362
+ /** `[Kind-Only]` Returns true if the given value is TInteger */
363
+ function IsInteger(value) {
364
+ return IsKindOf(value, "Integer");
365
+ }
366
+ /** `[Kind-Only]` Returns true if the given value is TIntersect */
367
+ function IsIntersect(value) {
368
+ return IsKindOf(value, "Intersect");
369
+ }
370
+ /** `[Kind-Only]` Returns true if the given value is TIterator */
371
+ function IsIterator(value) {
372
+ return IsKindOf(value, "Iterator");
373
+ }
374
+ /** `[Kind-Only]` Returns true if the given value is a TKind with the given name. */
375
+ function IsKindOf(value, kind) {
376
+ return IsObject$1(value) && Kind in value && value[Kind] === kind;
377
+ }
378
+ /** `[Kind-Only]` Returns true if the given value is TLiteral */
379
+ function IsLiteral(value) {
380
+ return IsKindOf(value, "Literal");
381
+ }
382
+ /** `[Kind-Only]` Returns true if the given value is a TMappedKey */
383
+ function IsMappedKey(value) {
384
+ return IsKindOf(value, "MappedKey");
385
+ }
386
+ /** `[Kind-Only]` Returns true if the given value is TMappedResult */
387
+ function IsMappedResult(value) {
388
+ return IsKindOf(value, "MappedResult");
389
+ }
390
+ /** `[Kind-Only]` Returns true if the given value is TNever */
391
+ function IsNever(value) {
392
+ return IsKindOf(value, "Never");
393
+ }
394
+ /** `[Kind-Only]` Returns true if the given value is TNot */
395
+ function IsNot(value) {
396
+ return IsKindOf(value, "Not");
397
+ }
398
+ /** `[Kind-Only]` Returns true if the given value is TNull */
399
+ function IsNull(value) {
400
+ return IsKindOf(value, "Null");
401
+ }
402
+ /** `[Kind-Only]` Returns true if the given value is TNumber */
403
+ function IsNumber(value) {
404
+ return IsKindOf(value, "Number");
405
+ }
406
+ /** `[Kind-Only]` Returns true if the given value is TObject */
407
+ function IsObject(value) {
408
+ return IsKindOf(value, "Object");
409
+ }
410
+ /** `[Kind-Only]` Returns true if the given value is TPromise */
411
+ function IsPromise(value) {
412
+ return IsKindOf(value, "Promise");
413
+ }
414
+ /** `[Kind-Only]` Returns true if the given value is TRecord */
415
+ function IsRecord(value) {
416
+ return IsKindOf(value, "Record");
417
+ }
418
+ /** `[Kind-Only]` Returns true if the given value is TRef */
419
+ function IsRef(value) {
420
+ return IsKindOf(value, "Ref");
421
+ }
422
+ /** `[Kind-Only]` Returns true if the given value is TRegExp */
423
+ function IsRegExp(value) {
424
+ return IsKindOf(value, "RegExp");
425
+ }
426
+ /** `[Kind-Only]` Returns true if the given value is TString */
427
+ function IsString(value) {
428
+ return IsKindOf(value, "String");
429
+ }
430
+ /** `[Kind-Only]` Returns true if the given value is TSymbol */
431
+ function IsSymbol(value) {
432
+ return IsKindOf(value, "Symbol");
433
+ }
434
+ /** `[Kind-Only]` Returns true if the given value is TTemplateLiteral */
435
+ function IsTemplateLiteral(value) {
436
+ return IsKindOf(value, "TemplateLiteral");
437
+ }
438
+ /** `[Kind-Only]` Returns true if the given value is TThis */
439
+ function IsThis(value) {
440
+ return IsKindOf(value, "This");
441
+ }
442
+ /** `[Kind-Only]` Returns true if the given value is TTuple */
443
+ function IsTuple(value) {
444
+ return IsKindOf(value, "Tuple");
445
+ }
446
+ /** `[Kind-Only]` Returns true if the given value is TUndefined */
447
+ function IsUndefined(value) {
448
+ return IsKindOf(value, "Undefined");
449
+ }
450
+ /** `[Kind-Only]` Returns true if the given value is TUnion */
451
+ function IsUnion(value) {
452
+ return IsKindOf(value, "Union");
453
+ }
454
+ /** `[Kind-Only]` Returns true if the given value is TUint8Array */
455
+ function IsUint8Array(value) {
456
+ return IsKindOf(value, "Uint8Array");
457
+ }
458
+ /** `[Kind-Only]` Returns true if the given value is TUnknown */
459
+ function IsUnknown(value) {
460
+ return IsKindOf(value, "Unknown");
461
+ }
462
+ /** `[Kind-Only]` Returns true if the given value is a raw TUnsafe */
463
+ function IsUnsafe(value) {
464
+ return IsKindOf(value, "Unsafe");
465
+ }
466
+ /** `[Kind-Only]` Returns true if the given value is TVoid */
467
+ function IsVoid(value) {
468
+ return IsKindOf(value, "Void");
469
+ }
470
+ /** `[Kind-Only]` Returns true if the given value is TKind */
471
+ function IsKind(value) {
472
+ return IsObject$1(value) && Kind in value && IsString$1(value[Kind]);
473
+ }
474
+ /** `[Kind-Only]` Returns true if the given value is TSchema */
475
+ function IsSchema(value) {
476
+ return IsAny(value) || IsArgument(value) || IsArray(value) || IsBoolean(value) || IsBigInt(value) || IsAsyncIterator(value) || IsComputed(value) || IsConstructor(value) || IsDate(value) || IsFunction(value) || IsInteger(value) || IsIntersect(value) || IsIterator(value) || IsLiteral(value) || IsMappedKey(value) || IsMappedResult(value) || IsNever(value) || IsNot(value) || IsNull(value) || IsNumber(value) || IsObject(value) || IsPromise(value) || IsRecord(value) || IsRef(value) || IsRegExp(value) || IsString(value) || IsSymbol(value) || IsTemplateLiteral(value) || IsThis(value) || IsTuple(value) || IsUndefined(value) || IsUnion(value) || IsUint8Array(value) || IsUnknown(value) || IsUnsafe(value) || IsVoid(value) || IsKind(value);
477
+ }
478
+ //#endregion
479
+ //#region ../../node_modules/.pnpm/@sinclair+typebox@0.34.52/node_modules/@sinclair/typebox/build/esm/type/sets/set.mjs
480
+ /** Returns the Intersect of the given sets */
481
+ function SetIntersect(T, S) {
482
+ return T.filter((L) => S.includes(L));
483
+ }
484
+ function SetIntersectManyResolve(T, Init) {
485
+ return T.reduce((Acc, L) => {
486
+ return SetIntersect(Acc, L);
487
+ }, Init);
488
+ }
489
+ function SetIntersectMany(T) {
490
+ return T.length === 1 ? T[0] : T.length > 1 ? SetIntersectManyResolve(T.slice(1), T[0]) : [];
491
+ }
492
+ /** Returns the Union of multiple sets */
493
+ function SetUnionMany(T) {
494
+ const Acc = [];
495
+ for (const L of T) Acc.push(...L);
496
+ return Acc;
497
+ }
498
+ //#endregion
499
+ //#region ../../node_modules/.pnpm/@sinclair+typebox@0.34.52/node_modules/@sinclair/typebox/build/esm/type/keyof/keyof-property-keys.mjs
500
+ function FromRest(types) {
501
+ const result = [];
502
+ for (const L of types) result.push(KeyOfPropertyKeys(L));
503
+ return result;
504
+ }
505
+ function FromIntersect$2(types) {
506
+ return SetUnionMany(FromRest(types));
507
+ }
508
+ function FromUnion$2(types) {
509
+ return SetIntersectMany(FromRest(types));
510
+ }
511
+ function FromTuple$2(types) {
512
+ return types.map((_, indexer) => indexer.toString());
513
+ }
514
+ function FromArray$2(_) {
515
+ return ["[number]"];
516
+ }
517
+ function FromProperties(T) {
518
+ return globalThis.Object.getOwnPropertyNames(T);
519
+ }
520
+ function FromPatternProperties(patternProperties) {
521
+ if (!includePatternProperties) return [];
522
+ return globalThis.Object.getOwnPropertyNames(patternProperties).map((key) => {
523
+ return key[0] === "^" && key[key.length - 1] === "$" ? key.slice(1, key.length - 1) : key;
524
+ });
525
+ }
526
+ /** Returns a tuple of PropertyKeys derived from the given TSchema. */
527
+ function KeyOfPropertyKeys(type) {
528
+ return IsIntersect(type) ? FromIntersect$2(type.allOf) : IsUnion(type) ? FromUnion$2(type.anyOf) : IsTuple(type) ? FromTuple$2(type.items ?? []) : IsArray(type) ? FromArray$2(type.items) : IsObject(type) ? FromProperties(type.properties) : IsRecord(type) ? FromPatternProperties(type.patternProperties) : [];
529
+ }
530
+ let includePatternProperties = false;
531
+ /** Returns a regular expression pattern derived from the given TSchema */
532
+ function KeyOfPattern(schema) {
533
+ includePatternProperties = true;
534
+ const keys = KeyOfPropertyKeys(schema);
535
+ includePatternProperties = false;
536
+ return `^(${keys.map((key) => `(${key})`).join("|")})$`;
537
+ }
538
+ //#endregion
539
+ //#region ../../node_modules/.pnpm/@sinclair+typebox@0.34.52/node_modules/@sinclair/typebox/build/esm/type/extends/extends-undefined.mjs
540
+ /** Fast undefined check used for properties of type undefined */
541
+ function Intersect(schema) {
542
+ return schema.allOf.every((schema) => ExtendsUndefinedCheck(schema));
543
+ }
544
+ function Union(schema) {
545
+ return schema.anyOf.some((schema) => ExtendsUndefinedCheck(schema));
546
+ }
547
+ function Not(schema) {
548
+ return !ExtendsUndefinedCheck(schema.not);
549
+ }
550
+ /** Fast undefined check used for properties of type undefined */
551
+ function ExtendsUndefinedCheck(schema) {
552
+ return schema[Kind] === "Intersect" ? Intersect(schema) : schema[Kind] === "Union" ? Union(schema) : schema[Kind] === "Not" ? Not(schema) : schema[Kind] === "Undefined" ? true : false;
553
+ }
554
+ //#endregion
555
+ //#region ../../node_modules/.pnpm/@sinclair+typebox@0.34.52/node_modules/@sinclair/typebox/build/esm/errors/function.mjs
556
+ /** Creates an error message using en-US as the default locale */
557
+ function DefaultErrorFunction(error) {
558
+ switch (error.errorType) {
559
+ case ValueErrorType.ArrayContains: return "Expected array to contain at least one matching value";
560
+ case ValueErrorType.ArrayMaxContains: return `Expected array to contain no more than ${error.schema.maxContains} matching values`;
561
+ case ValueErrorType.ArrayMinContains: return `Expected array to contain at least ${error.schema.minContains} matching values`;
562
+ case ValueErrorType.ArrayMaxItems: return `Expected array length to be less or equal to ${error.schema.maxItems}`;
563
+ case ValueErrorType.ArrayMinItems: return `Expected array length to be greater or equal to ${error.schema.minItems}`;
564
+ case ValueErrorType.ArrayUniqueItems: return "Expected array elements to be unique";
565
+ case ValueErrorType.Array: return "Expected array";
566
+ case ValueErrorType.AsyncIterator: return "Expected AsyncIterator";
567
+ case ValueErrorType.BigIntExclusiveMaximum: return `Expected bigint to be less than ${error.schema.exclusiveMaximum}`;
568
+ case ValueErrorType.BigIntExclusiveMinimum: return `Expected bigint to be greater than ${error.schema.exclusiveMinimum}`;
569
+ case ValueErrorType.BigIntMaximum: return `Expected bigint to be less or equal to ${error.schema.maximum}`;
570
+ case ValueErrorType.BigIntMinimum: return `Expected bigint to be greater or equal to ${error.schema.minimum}`;
571
+ case ValueErrorType.BigIntMultipleOf: return `Expected bigint to be a multiple of ${error.schema.multipleOf}`;
572
+ case ValueErrorType.BigInt: return "Expected bigint";
573
+ case ValueErrorType.Boolean: return "Expected boolean";
574
+ case ValueErrorType.DateExclusiveMinimumTimestamp: return `Expected Date timestamp to be greater than ${error.schema.exclusiveMinimumTimestamp}`;
575
+ case ValueErrorType.DateExclusiveMaximumTimestamp: return `Expected Date timestamp to be less than ${error.schema.exclusiveMaximumTimestamp}`;
576
+ case ValueErrorType.DateMinimumTimestamp: return `Expected Date timestamp to be greater or equal to ${error.schema.minimumTimestamp}`;
577
+ case ValueErrorType.DateMaximumTimestamp: return `Expected Date timestamp to be less or equal to ${error.schema.maximumTimestamp}`;
578
+ case ValueErrorType.DateMultipleOfTimestamp: return `Expected Date timestamp to be a multiple of ${error.schema.multipleOfTimestamp}`;
579
+ case ValueErrorType.Date: return "Expected Date";
580
+ case ValueErrorType.Function: return "Expected function";
581
+ case ValueErrorType.IntegerExclusiveMaximum: return `Expected integer to be less than ${error.schema.exclusiveMaximum}`;
582
+ case ValueErrorType.IntegerExclusiveMinimum: return `Expected integer to be greater than ${error.schema.exclusiveMinimum}`;
583
+ case ValueErrorType.IntegerMaximum: return `Expected integer to be less or equal to ${error.schema.maximum}`;
584
+ case ValueErrorType.IntegerMinimum: return `Expected integer to be greater or equal to ${error.schema.minimum}`;
585
+ case ValueErrorType.IntegerMultipleOf: return `Expected integer to be a multiple of ${error.schema.multipleOf}`;
586
+ case ValueErrorType.Integer: return "Expected integer";
587
+ case ValueErrorType.IntersectUnevaluatedProperties: return "Unexpected property";
588
+ case ValueErrorType.Intersect: return "Expected all values to match";
589
+ case ValueErrorType.Iterator: return "Expected Iterator";
590
+ case ValueErrorType.Literal: return `Expected ${typeof error.schema.const === "string" ? `'${error.schema.const}'` : error.schema.const}`;
591
+ case ValueErrorType.Never: return "Never";
592
+ case ValueErrorType.Not: return "Value should not match";
593
+ case ValueErrorType.Null: return "Expected null";
594
+ case ValueErrorType.NumberExclusiveMaximum: return `Expected number to be less than ${error.schema.exclusiveMaximum}`;
595
+ case ValueErrorType.NumberExclusiveMinimum: return `Expected number to be greater than ${error.schema.exclusiveMinimum}`;
596
+ case ValueErrorType.NumberMaximum: return `Expected number to be less or equal to ${error.schema.maximum}`;
597
+ case ValueErrorType.NumberMinimum: return `Expected number to be greater or equal to ${error.schema.minimum}`;
598
+ case ValueErrorType.NumberMultipleOf: return `Expected number to be a multiple of ${error.schema.multipleOf}`;
599
+ case ValueErrorType.Number: return "Expected number";
600
+ case ValueErrorType.Object: return "Expected object";
601
+ case ValueErrorType.ObjectAdditionalProperties: return "Unexpected property";
602
+ case ValueErrorType.ObjectMaxProperties: return `Expected object to have no more than ${error.schema.maxProperties} properties`;
603
+ case ValueErrorType.ObjectMinProperties: return `Expected object to have at least ${error.schema.minProperties} properties`;
604
+ case ValueErrorType.ObjectRequiredProperty: return "Expected required property";
605
+ case ValueErrorType.Promise: return "Expected Promise";
606
+ case ValueErrorType.RegExp: return "Expected string to match regular expression";
607
+ case ValueErrorType.StringFormatUnknown: return `Unknown format '${error.schema.format}'`;
608
+ case ValueErrorType.StringFormat: return `Expected string to match '${error.schema.format}' format`;
609
+ case ValueErrorType.StringMaxLength: return `Expected string length less or equal to ${error.schema.maxLength}`;
610
+ case ValueErrorType.StringMinLength: return `Expected string length greater or equal to ${error.schema.minLength}`;
611
+ case ValueErrorType.StringPattern: return `Expected string to match '${error.schema.pattern}'`;
612
+ case ValueErrorType.String: return "Expected string";
613
+ case ValueErrorType.Symbol: return "Expected symbol";
614
+ case ValueErrorType.TupleLength: return `Expected tuple to have ${error.schema.maxItems || 0} elements`;
615
+ case ValueErrorType.Tuple: return "Expected tuple";
616
+ case ValueErrorType.Uint8ArrayMaxByteLength: return `Expected byte length less or equal to ${error.schema.maxByteLength}`;
617
+ case ValueErrorType.Uint8ArrayMinByteLength: return `Expected byte length greater or equal to ${error.schema.minByteLength}`;
618
+ case ValueErrorType.Uint8Array: return "Expected Uint8Array";
619
+ case ValueErrorType.Undefined: return "Expected undefined";
620
+ case ValueErrorType.Union: return "Expected union value";
621
+ case ValueErrorType.Void: return "Expected void";
622
+ case ValueErrorType.Kind: return `Expected kind '${error.schema[Kind]}'`;
623
+ default: return "Unknown error type";
624
+ }
625
+ }
626
+ /** Manages error message providers */
627
+ let errorFunction = DefaultErrorFunction;
628
+ /** Gets the error function used to generate error messages */
629
+ function GetErrorFunction() {
630
+ return errorFunction;
631
+ }
632
+ //#endregion
633
+ //#region ../../node_modules/.pnpm/@sinclair+typebox@0.34.52/node_modules/@sinclair/typebox/build/esm/value/deref/deref.mjs
634
+ var TypeDereferenceError = class extends TypeBoxError {
635
+ constructor(schema) {
636
+ super(`Unable to dereference schema with $id '${schema.$ref}'`);
637
+ this.schema = schema;
638
+ }
639
+ };
640
+ function Resolve(schema, references) {
641
+ const target = references.find((target) => target.$id === schema.$ref);
642
+ if (target === void 0) throw new TypeDereferenceError(schema);
643
+ return Deref(target, references);
644
+ }
645
+ /** `[Internal]` Pushes a schema onto references if the schema has an $id and does not exist on references */
646
+ function Pushref(schema, references) {
647
+ if (!IsString$2(schema.$id) || references.some((target) => target.$id === schema.$id)) return references;
648
+ references.push(schema);
649
+ return references;
650
+ }
651
+ /** `[Internal]` Dereferences a schema from the references array or throws if not found */
652
+ function Deref(schema, references) {
653
+ return schema[Kind] === "This" || schema[Kind] === "Ref" ? Resolve(schema, references) : schema;
654
+ }
655
+ //#endregion
656
+ //#region ../../node_modules/.pnpm/@sinclair+typebox@0.34.52/node_modules/@sinclair/typebox/build/esm/value/hash/hash.mjs
657
+ var ValueHashError = class extends TypeBoxError {
658
+ constructor(value) {
659
+ super(`Unable to hash value`);
660
+ this.value = value;
661
+ }
662
+ };
663
+ var ByteMarker;
664
+ (function(ByteMarker) {
665
+ ByteMarker[ByteMarker["Undefined"] = 0] = "Undefined";
666
+ ByteMarker[ByteMarker["Null"] = 1] = "Null";
667
+ ByteMarker[ByteMarker["Boolean"] = 2] = "Boolean";
668
+ ByteMarker[ByteMarker["Number"] = 3] = "Number";
669
+ ByteMarker[ByteMarker["String"] = 4] = "String";
670
+ ByteMarker[ByteMarker["Object"] = 5] = "Object";
671
+ ByteMarker[ByteMarker["Array"] = 6] = "Array";
672
+ ByteMarker[ByteMarker["Date"] = 7] = "Date";
673
+ ByteMarker[ByteMarker["Uint8Array"] = 8] = "Uint8Array";
674
+ ByteMarker[ByteMarker["Symbol"] = 9] = "Symbol";
675
+ ByteMarker[ByteMarker["BigInt"] = 10] = "BigInt";
676
+ })(ByteMarker || (ByteMarker = {}));
677
+ let Accumulator = BigInt("14695981039346656037");
678
+ const [Prime, Size] = [BigInt("1099511628211"), BigInt("18446744073709551616")];
679
+ const Bytes = Array.from({ length: 256 }).map((_, i) => BigInt(i));
680
+ const F64 = /* @__PURE__ */ new Float64Array(1);
681
+ const F64In = new DataView(F64.buffer);
682
+ const F64Out = new Uint8Array(F64.buffer);
683
+ function* NumberToBytes(value) {
684
+ const byteCount = value === 0 ? 1 : Math.ceil(Math.floor(Math.log2(value) + 1) / 8);
685
+ for (let i = 0; i < byteCount; i++) yield value >> 8 * (byteCount - 1 - i) & 255;
686
+ }
687
+ function ArrayType(value) {
688
+ FNV1A64(ByteMarker.Array);
689
+ for (const item of value) Visit$2(item);
690
+ }
691
+ function BooleanType(value) {
692
+ FNV1A64(ByteMarker.Boolean);
693
+ FNV1A64(value ? 1 : 0);
694
+ }
695
+ function BigIntType(value) {
696
+ FNV1A64(ByteMarker.BigInt);
697
+ F64In.setBigInt64(0, value);
698
+ for (const byte of F64Out) FNV1A64(byte);
699
+ }
700
+ function DateType(value) {
701
+ FNV1A64(ByteMarker.Date);
702
+ Visit$2(value.getTime());
703
+ }
704
+ function NullType(value) {
705
+ FNV1A64(ByteMarker.Null);
706
+ }
707
+ function NumberType(value) {
708
+ FNV1A64(ByteMarker.Number);
709
+ F64In.setFloat64(0, value);
710
+ for (const byte of F64Out) FNV1A64(byte);
711
+ }
712
+ function ObjectType(value) {
713
+ FNV1A64(ByteMarker.Object);
714
+ for (const key of globalThis.Object.getOwnPropertyNames(value).sort()) {
715
+ Visit$2(key);
716
+ Visit$2(value[key]);
717
+ }
718
+ }
719
+ function StringType(value) {
720
+ FNV1A64(ByteMarker.String);
721
+ for (let i = 0; i < value.length; i++) for (const byte of NumberToBytes(value.charCodeAt(i))) FNV1A64(byte);
722
+ }
723
+ function SymbolType(value) {
724
+ FNV1A64(ByteMarker.Symbol);
725
+ Visit$2(value.description);
726
+ }
727
+ function Uint8ArrayType(value) {
728
+ FNV1A64(ByteMarker.Uint8Array);
729
+ for (let i = 0; i < value.length; i++) FNV1A64(value[i]);
730
+ }
731
+ function UndefinedType(value) {
732
+ return FNV1A64(ByteMarker.Undefined);
733
+ }
734
+ function Visit$2(value) {
735
+ if (IsArray$2(value)) return ArrayType(value);
736
+ if (IsBoolean$1(value)) return BooleanType(value);
737
+ if (IsBigInt$1(value)) return BigIntType(value);
738
+ if (IsDate$2(value)) return DateType(value);
739
+ if (IsNull$1(value)) return NullType(value);
740
+ if (IsNumber$1(value)) return NumberType(value);
741
+ if (IsObject$2(value)) return ObjectType(value);
742
+ if (IsString$2(value)) return StringType(value);
743
+ if (IsSymbol$1(value)) return SymbolType(value);
744
+ if (IsUint8Array$2(value)) return Uint8ArrayType(value);
745
+ if (IsUndefined$1(value)) return UndefinedType(value);
746
+ throw new ValueHashError(value);
747
+ }
748
+ function FNV1A64(byte) {
749
+ Accumulator = Accumulator ^ Bytes[byte];
750
+ Accumulator = Accumulator * Prime % Size;
751
+ }
752
+ /** Creates a FNV1A-64 non cryptographic hash of the given value */
753
+ function Hash(value) {
754
+ Accumulator = BigInt("14695981039346656037");
755
+ Visit$2(value);
756
+ return Accumulator;
757
+ }
758
+ //#endregion
759
+ //#region ../../node_modules/.pnpm/@sinclair+typebox@0.34.52/node_modules/@sinclair/typebox/build/esm/value/check/check.mjs
760
+ var ValueCheckUnknownTypeError = class extends TypeBoxError {
761
+ constructor(schema) {
762
+ super(`Unknown type`);
763
+ this.schema = schema;
764
+ }
765
+ };
766
+ function IsAnyOrUnknown(schema) {
767
+ return schema[Kind] === "Any" || schema[Kind] === "Unknown";
768
+ }
769
+ function IsDefined$1(value) {
770
+ return value !== void 0;
771
+ }
772
+ function FromAny$1(schema, references, value) {
773
+ return true;
774
+ }
775
+ function FromArgument$1(schema, references, value) {
776
+ return true;
777
+ }
778
+ function FromArray$1(schema, references, value) {
779
+ if (!IsArray$2(value)) return false;
780
+ if (IsDefined$1(schema.minItems) && !(value.length >= schema.minItems)) return false;
781
+ if (IsDefined$1(schema.maxItems) && !(value.length <= schema.maxItems)) return false;
782
+ for (const element of value) if (!Visit$1(schema.items, references, element)) return false;
783
+ if (schema.uniqueItems === true && !(function() {
784
+ const set = /* @__PURE__ */ new Set();
785
+ for (const element of value) {
786
+ const hashed = Hash(element);
787
+ if (set.has(hashed)) return false;
788
+ else set.add(hashed);
789
+ }
790
+ return true;
791
+ })()) return false;
792
+ if (!(IsDefined$1(schema.contains) || IsNumber$1(schema.minContains) || IsNumber$1(schema.maxContains))) return true;
793
+ const containsSchema = IsDefined$1(schema.contains) ? schema.contains : Never();
794
+ const containsCount = value.reduce((acc, value) => Visit$1(containsSchema, references, value) ? acc + 1 : acc, 0);
795
+ if (containsCount === 0) return false;
796
+ if (IsNumber$1(schema.minContains) && containsCount < schema.minContains) return false;
797
+ if (IsNumber$1(schema.maxContains) && containsCount > schema.maxContains) return false;
798
+ return true;
799
+ }
800
+ function FromAsyncIterator$1(schema, references, value) {
801
+ return IsAsyncIterator$1(value);
802
+ }
803
+ function FromBigInt$1(schema, references, value) {
804
+ if (!IsBigInt$1(value)) return false;
805
+ if (IsDefined$1(schema.exclusiveMaximum) && !(value < schema.exclusiveMaximum)) return false;
806
+ if (IsDefined$1(schema.exclusiveMinimum) && !(value > schema.exclusiveMinimum)) return false;
807
+ if (IsDefined$1(schema.maximum) && !(value <= schema.maximum)) return false;
808
+ if (IsDefined$1(schema.minimum) && !(value >= schema.minimum)) return false;
809
+ if (IsDefined$1(schema.multipleOf) && !(value % schema.multipleOf === BigInt(0))) return false;
810
+ return true;
811
+ }
812
+ function FromBoolean$1(schema, references, value) {
813
+ return IsBoolean$1(value);
814
+ }
815
+ function FromConstructor$1(schema, references, value) {
816
+ return Visit$1(schema.returns, references, value.prototype);
817
+ }
818
+ function FromDate$1(schema, references, value) {
819
+ if (!IsDate$2(value)) return false;
820
+ if (IsDefined$1(schema.exclusiveMaximumTimestamp) && !(value.getTime() < schema.exclusiveMaximumTimestamp)) return false;
821
+ if (IsDefined$1(schema.exclusiveMinimumTimestamp) && !(value.getTime() > schema.exclusiveMinimumTimestamp)) return false;
822
+ if (IsDefined$1(schema.maximumTimestamp) && !(value.getTime() <= schema.maximumTimestamp)) return false;
823
+ if (IsDefined$1(schema.minimumTimestamp) && !(value.getTime() >= schema.minimumTimestamp)) return false;
824
+ if (IsDefined$1(schema.multipleOfTimestamp) && !(value.getTime() % schema.multipleOfTimestamp === 0)) return false;
825
+ return true;
826
+ }
827
+ function FromFunction$1(schema, references, value) {
828
+ return IsFunction$1(value);
829
+ }
830
+ function FromImport$1(schema, references, value) {
831
+ const definitions = globalThis.Object.values(schema.$defs);
832
+ const target = schema.$defs[schema.$ref];
833
+ return Visit$1(target, [...references, ...definitions], value);
834
+ }
835
+ function FromInteger$1(schema, references, value) {
836
+ if (!IsInteger$1(value)) return false;
837
+ if (IsDefined$1(schema.exclusiveMaximum) && !(value < schema.exclusiveMaximum)) return false;
838
+ if (IsDefined$1(schema.exclusiveMinimum) && !(value > schema.exclusiveMinimum)) return false;
839
+ if (IsDefined$1(schema.maximum) && !(value <= schema.maximum)) return false;
840
+ if (IsDefined$1(schema.minimum) && !(value >= schema.minimum)) return false;
841
+ if (IsDefined$1(schema.multipleOf) && !(value % schema.multipleOf === 0)) return false;
842
+ return true;
843
+ }
844
+ function FromIntersect$1(schema, references, value) {
845
+ const check1 = schema.allOf.every((schema) => Visit$1(schema, references, value));
846
+ if (schema.unevaluatedProperties === false) {
847
+ const keyPattern = new RegExp(KeyOfPattern(schema));
848
+ const check2 = Object.getOwnPropertyNames(value).every((key) => keyPattern.test(key));
849
+ return check1 && check2;
850
+ } else if (IsSchema(schema.unevaluatedProperties)) {
851
+ const keyCheck = new RegExp(KeyOfPattern(schema));
852
+ const check2 = Object.getOwnPropertyNames(value).every((key) => keyCheck.test(key) || Visit$1(schema.unevaluatedProperties, references, value[key]));
853
+ return check1 && check2;
854
+ } else return check1;
855
+ }
856
+ function FromIterator$1(schema, references, value) {
857
+ return IsIterator$1(value);
858
+ }
859
+ function FromLiteral$1(schema, references, value) {
860
+ return value === schema.const;
861
+ }
862
+ function FromNever$1(schema, references, value) {
863
+ return false;
864
+ }
865
+ function FromNot$1(schema, references, value) {
866
+ return !Visit$1(schema.not, references, value);
867
+ }
868
+ function FromNull$1(schema, references, value) {
869
+ return IsNull$1(value);
870
+ }
871
+ function FromNumber$1(schema, references, value) {
872
+ if (!TypeSystemPolicy.IsNumberLike(value)) return false;
873
+ if (IsDefined$1(schema.exclusiveMaximum) && !(value < schema.exclusiveMaximum)) return false;
874
+ if (IsDefined$1(schema.exclusiveMinimum) && !(value > schema.exclusiveMinimum)) return false;
875
+ if (IsDefined$1(schema.minimum) && !(value >= schema.minimum)) return false;
876
+ if (IsDefined$1(schema.maximum) && !(value <= schema.maximum)) return false;
877
+ if (IsDefined$1(schema.multipleOf) && !(value % schema.multipleOf === 0)) return false;
878
+ return true;
879
+ }
880
+ function FromObject$1(schema, references, value) {
881
+ if (!TypeSystemPolicy.IsObjectLike(value)) return false;
882
+ if (IsDefined$1(schema.minProperties) && !(Object.getOwnPropertyNames(value).length >= schema.minProperties)) return false;
883
+ if (IsDefined$1(schema.maxProperties) && !(Object.getOwnPropertyNames(value).length <= schema.maxProperties)) return false;
884
+ const knownKeys = Object.getOwnPropertyNames(schema.properties);
885
+ for (const knownKey of knownKeys) {
886
+ const property = schema.properties[knownKey];
887
+ if (schema.required && schema.required.includes(knownKey)) {
888
+ if (!Visit$1(property, references, value[knownKey])) return false;
889
+ if ((ExtendsUndefinedCheck(property) || IsAnyOrUnknown(property)) && !(knownKey in value)) return false;
890
+ } else if (TypeSystemPolicy.IsExactOptionalProperty(value, knownKey) && !Visit$1(property, references, value[knownKey])) return false;
891
+ }
892
+ if (schema.additionalProperties === false) {
893
+ const valueKeys = Object.getOwnPropertyNames(value);
894
+ if (schema.required && schema.required.length === knownKeys.length && valueKeys.length === knownKeys.length) return true;
895
+ else return valueKeys.every((valueKey) => knownKeys.includes(valueKey));
896
+ } else if (typeof schema.additionalProperties === "object") return Object.getOwnPropertyNames(value).every((key) => knownKeys.includes(key) || Visit$1(schema.additionalProperties, references, value[key]));
897
+ else return true;
898
+ }
899
+ function FromPromise$1(schema, references, value) {
900
+ return IsPromise$1(value);
901
+ }
902
+ function FromRecord$1(schema, references, value) {
903
+ if (!TypeSystemPolicy.IsRecordLike(value)) return false;
904
+ if (IsDefined$1(schema.minProperties) && !(Object.getOwnPropertyNames(value).length >= schema.minProperties)) return false;
905
+ if (IsDefined$1(schema.maxProperties) && !(Object.getOwnPropertyNames(value).length <= schema.maxProperties)) return false;
906
+ const [patternKey, patternSchema] = Object.entries(schema.patternProperties)[0];
907
+ const regex = new RegExp(patternKey);
908
+ const check1 = Object.entries(value).every(([key, value]) => {
909
+ return regex.test(key) ? Visit$1(patternSchema, references, value) : true;
910
+ });
911
+ const check2 = typeof schema.additionalProperties === "object" ? Object.entries(value).every(([key, value]) => {
912
+ return !regex.test(key) ? Visit$1(schema.additionalProperties, references, value) : true;
913
+ }) : true;
914
+ const check3 = schema.additionalProperties === false ? Object.getOwnPropertyNames(value).every((key) => {
915
+ return regex.test(key);
916
+ }) : true;
917
+ return check1 && check2 && check3;
918
+ }
919
+ function FromRef$1(schema, references, value) {
920
+ return Visit$1(Deref(schema, references), references, value);
921
+ }
922
+ function FromRegExp$1(schema, references, value) {
923
+ const regex = new RegExp(schema.source, schema.flags);
924
+ if (IsDefined$1(schema.minLength)) {
925
+ if (!(value.length >= schema.minLength)) return false;
926
+ }
927
+ if (IsDefined$1(schema.maxLength)) {
928
+ if (!(value.length <= schema.maxLength)) return false;
929
+ }
930
+ return regex.test(value);
931
+ }
932
+ function FromString$1(schema, references, value) {
933
+ if (!IsString$2(value)) return false;
934
+ if (IsDefined$1(schema.minLength)) {
935
+ if (!(value.length >= schema.minLength)) return false;
936
+ }
937
+ if (IsDefined$1(schema.maxLength)) {
938
+ if (!(value.length <= schema.maxLength)) return false;
939
+ }
940
+ if (IsDefined$1(schema.pattern)) {
941
+ if (!new RegExp(schema.pattern).test(value)) return false;
942
+ }
943
+ if (IsDefined$1(schema.format)) {
944
+ if (!Has$1(schema.format)) return false;
945
+ return Get$1(schema.format)(value);
946
+ }
947
+ return true;
948
+ }
949
+ function FromSymbol$1(schema, references, value) {
950
+ return IsSymbol$1(value);
951
+ }
952
+ function FromTemplateLiteral$1(schema, references, value) {
953
+ return IsString$2(value) && new RegExp(schema.pattern).test(value);
954
+ }
955
+ function FromThis$1(schema, references, value) {
956
+ return Visit$1(Deref(schema, references), references, value);
957
+ }
958
+ function FromTuple$1(schema, references, value) {
959
+ if (!IsArray$2(value)) return false;
960
+ if (schema.items === void 0 && !(value.length === 0)) return false;
961
+ if (!(value.length === schema.maxItems)) return false;
962
+ if (!schema.items) return true;
963
+ for (let i = 0; i < schema.items.length; i++) if (!Visit$1(schema.items[i], references, value[i])) return false;
964
+ return true;
965
+ }
966
+ function FromUndefined$1(schema, references, value) {
967
+ return IsUndefined$1(value);
968
+ }
969
+ function FromUnion$1(schema, references, value) {
970
+ return schema.anyOf.some((inner) => Visit$1(inner, references, value));
971
+ }
972
+ function FromUint8Array$1(schema, references, value) {
973
+ if (!IsUint8Array$2(value)) return false;
974
+ if (IsDefined$1(schema.maxByteLength) && !(value.length <= schema.maxByteLength)) return false;
975
+ if (IsDefined$1(schema.minByteLength) && !(value.length >= schema.minByteLength)) return false;
976
+ return true;
977
+ }
978
+ function FromUnknown$1(schema, references, value) {
979
+ return true;
980
+ }
981
+ function FromVoid$1(schema, references, value) {
982
+ return TypeSystemPolicy.IsVoidLike(value);
983
+ }
984
+ function FromKind$1(schema, references, value) {
985
+ if (!Has(schema[Kind])) return false;
986
+ return Get(schema[Kind])(schema, value);
987
+ }
988
+ function Visit$1(schema, references, value) {
989
+ const references_ = IsDefined$1(schema.$id) ? Pushref(schema, references) : references;
990
+ const schema_ = schema;
991
+ switch (schema_[Kind]) {
992
+ case "Any": return FromAny$1(schema_, references_, value);
993
+ case "Argument": return FromArgument$1(schema_, references_, value);
994
+ case "Array": return FromArray$1(schema_, references_, value);
995
+ case "AsyncIterator": return FromAsyncIterator$1(schema_, references_, value);
996
+ case "BigInt": return FromBigInt$1(schema_, references_, value);
997
+ case "Boolean": return FromBoolean$1(schema_, references_, value);
998
+ case "Constructor": return FromConstructor$1(schema_, references_, value);
999
+ case "Date": return FromDate$1(schema_, references_, value);
1000
+ case "Function": return FromFunction$1(schema_, references_, value);
1001
+ case "Import": return FromImport$1(schema_, references_, value);
1002
+ case "Integer": return FromInteger$1(schema_, references_, value);
1003
+ case "Intersect": return FromIntersect$1(schema_, references_, value);
1004
+ case "Iterator": return FromIterator$1(schema_, references_, value);
1005
+ case "Literal": return FromLiteral$1(schema_, references_, value);
1006
+ case "Never": return FromNever$1(schema_, references_, value);
1007
+ case "Not": return FromNot$1(schema_, references_, value);
1008
+ case "Null": return FromNull$1(schema_, references_, value);
1009
+ case "Number": return FromNumber$1(schema_, references_, value);
1010
+ case "Object": return FromObject$1(schema_, references_, value);
1011
+ case "Promise": return FromPromise$1(schema_, references_, value);
1012
+ case "Record": return FromRecord$1(schema_, references_, value);
1013
+ case "Ref": return FromRef$1(schema_, references_, value);
1014
+ case "RegExp": return FromRegExp$1(schema_, references_, value);
1015
+ case "String": return FromString$1(schema_, references_, value);
1016
+ case "Symbol": return FromSymbol$1(schema_, references_, value);
1017
+ case "TemplateLiteral": return FromTemplateLiteral$1(schema_, references_, value);
1018
+ case "This": return FromThis$1(schema_, references_, value);
1019
+ case "Tuple": return FromTuple$1(schema_, references_, value);
1020
+ case "Undefined": return FromUndefined$1(schema_, references_, value);
1021
+ case "Union": return FromUnion$1(schema_, references_, value);
1022
+ case "Uint8Array": return FromUint8Array$1(schema_, references_, value);
1023
+ case "Unknown": return FromUnknown$1(schema_, references_, value);
1024
+ case "Void": return FromVoid$1(schema_, references_, value);
1025
+ default:
1026
+ if (!Has(schema_[Kind])) throw new ValueCheckUnknownTypeError(schema_);
1027
+ return FromKind$1(schema_, references_, value);
1028
+ }
1029
+ }
1030
+ /** Returns true if the value matches the given type. */
1031
+ function Check(...args) {
1032
+ return args.length === 3 ? Visit$1(args[0], args[1], args[2]) : Visit$1(args[0], [], args[1]);
1033
+ }
1034
+ //#endregion
1035
+ //#region ../../node_modules/.pnpm/@sinclair+typebox@0.34.52/node_modules/@sinclair/typebox/build/esm/errors/errors.mjs
1036
+ var ValueErrorType;
1037
+ (function(ValueErrorType) {
1038
+ ValueErrorType[ValueErrorType["ArrayContains"] = 0] = "ArrayContains";
1039
+ ValueErrorType[ValueErrorType["ArrayMaxContains"] = 1] = "ArrayMaxContains";
1040
+ ValueErrorType[ValueErrorType["ArrayMaxItems"] = 2] = "ArrayMaxItems";
1041
+ ValueErrorType[ValueErrorType["ArrayMinContains"] = 3] = "ArrayMinContains";
1042
+ ValueErrorType[ValueErrorType["ArrayMinItems"] = 4] = "ArrayMinItems";
1043
+ ValueErrorType[ValueErrorType["ArrayUniqueItems"] = 5] = "ArrayUniqueItems";
1044
+ ValueErrorType[ValueErrorType["Array"] = 6] = "Array";
1045
+ ValueErrorType[ValueErrorType["AsyncIterator"] = 7] = "AsyncIterator";
1046
+ ValueErrorType[ValueErrorType["BigIntExclusiveMaximum"] = 8] = "BigIntExclusiveMaximum";
1047
+ ValueErrorType[ValueErrorType["BigIntExclusiveMinimum"] = 9] = "BigIntExclusiveMinimum";
1048
+ ValueErrorType[ValueErrorType["BigIntMaximum"] = 10] = "BigIntMaximum";
1049
+ ValueErrorType[ValueErrorType["BigIntMinimum"] = 11] = "BigIntMinimum";
1050
+ ValueErrorType[ValueErrorType["BigIntMultipleOf"] = 12] = "BigIntMultipleOf";
1051
+ ValueErrorType[ValueErrorType["BigInt"] = 13] = "BigInt";
1052
+ ValueErrorType[ValueErrorType["Boolean"] = 14] = "Boolean";
1053
+ ValueErrorType[ValueErrorType["DateExclusiveMaximumTimestamp"] = 15] = "DateExclusiveMaximumTimestamp";
1054
+ ValueErrorType[ValueErrorType["DateExclusiveMinimumTimestamp"] = 16] = "DateExclusiveMinimumTimestamp";
1055
+ ValueErrorType[ValueErrorType["DateMaximumTimestamp"] = 17] = "DateMaximumTimestamp";
1056
+ ValueErrorType[ValueErrorType["DateMinimumTimestamp"] = 18] = "DateMinimumTimestamp";
1057
+ ValueErrorType[ValueErrorType["DateMultipleOfTimestamp"] = 19] = "DateMultipleOfTimestamp";
1058
+ ValueErrorType[ValueErrorType["Date"] = 20] = "Date";
1059
+ ValueErrorType[ValueErrorType["Function"] = 21] = "Function";
1060
+ ValueErrorType[ValueErrorType["IntegerExclusiveMaximum"] = 22] = "IntegerExclusiveMaximum";
1061
+ ValueErrorType[ValueErrorType["IntegerExclusiveMinimum"] = 23] = "IntegerExclusiveMinimum";
1062
+ ValueErrorType[ValueErrorType["IntegerMaximum"] = 24] = "IntegerMaximum";
1063
+ ValueErrorType[ValueErrorType["IntegerMinimum"] = 25] = "IntegerMinimum";
1064
+ ValueErrorType[ValueErrorType["IntegerMultipleOf"] = 26] = "IntegerMultipleOf";
1065
+ ValueErrorType[ValueErrorType["Integer"] = 27] = "Integer";
1066
+ ValueErrorType[ValueErrorType["IntersectUnevaluatedProperties"] = 28] = "IntersectUnevaluatedProperties";
1067
+ ValueErrorType[ValueErrorType["Intersect"] = 29] = "Intersect";
1068
+ ValueErrorType[ValueErrorType["Iterator"] = 30] = "Iterator";
1069
+ ValueErrorType[ValueErrorType["Kind"] = 31] = "Kind";
1070
+ ValueErrorType[ValueErrorType["Literal"] = 32] = "Literal";
1071
+ ValueErrorType[ValueErrorType["Never"] = 33] = "Never";
1072
+ ValueErrorType[ValueErrorType["Not"] = 34] = "Not";
1073
+ ValueErrorType[ValueErrorType["Null"] = 35] = "Null";
1074
+ ValueErrorType[ValueErrorType["NumberExclusiveMaximum"] = 36] = "NumberExclusiveMaximum";
1075
+ ValueErrorType[ValueErrorType["NumberExclusiveMinimum"] = 37] = "NumberExclusiveMinimum";
1076
+ ValueErrorType[ValueErrorType["NumberMaximum"] = 38] = "NumberMaximum";
1077
+ ValueErrorType[ValueErrorType["NumberMinimum"] = 39] = "NumberMinimum";
1078
+ ValueErrorType[ValueErrorType["NumberMultipleOf"] = 40] = "NumberMultipleOf";
1079
+ ValueErrorType[ValueErrorType["Number"] = 41] = "Number";
1080
+ ValueErrorType[ValueErrorType["ObjectAdditionalProperties"] = 42] = "ObjectAdditionalProperties";
1081
+ ValueErrorType[ValueErrorType["ObjectMaxProperties"] = 43] = "ObjectMaxProperties";
1082
+ ValueErrorType[ValueErrorType["ObjectMinProperties"] = 44] = "ObjectMinProperties";
1083
+ ValueErrorType[ValueErrorType["ObjectRequiredProperty"] = 45] = "ObjectRequiredProperty";
1084
+ ValueErrorType[ValueErrorType["Object"] = 46] = "Object";
1085
+ ValueErrorType[ValueErrorType["Promise"] = 47] = "Promise";
1086
+ ValueErrorType[ValueErrorType["RegExp"] = 48] = "RegExp";
1087
+ ValueErrorType[ValueErrorType["StringFormatUnknown"] = 49] = "StringFormatUnknown";
1088
+ ValueErrorType[ValueErrorType["StringFormat"] = 50] = "StringFormat";
1089
+ ValueErrorType[ValueErrorType["StringMaxLength"] = 51] = "StringMaxLength";
1090
+ ValueErrorType[ValueErrorType["StringMinLength"] = 52] = "StringMinLength";
1091
+ ValueErrorType[ValueErrorType["StringPattern"] = 53] = "StringPattern";
1092
+ ValueErrorType[ValueErrorType["String"] = 54] = "String";
1093
+ ValueErrorType[ValueErrorType["Symbol"] = 55] = "Symbol";
1094
+ ValueErrorType[ValueErrorType["TupleLength"] = 56] = "TupleLength";
1095
+ ValueErrorType[ValueErrorType["Tuple"] = 57] = "Tuple";
1096
+ ValueErrorType[ValueErrorType["Uint8ArrayMaxByteLength"] = 58] = "Uint8ArrayMaxByteLength";
1097
+ ValueErrorType[ValueErrorType["Uint8ArrayMinByteLength"] = 59] = "Uint8ArrayMinByteLength";
1098
+ ValueErrorType[ValueErrorType["Uint8Array"] = 60] = "Uint8Array";
1099
+ ValueErrorType[ValueErrorType["Undefined"] = 61] = "Undefined";
1100
+ ValueErrorType[ValueErrorType["Union"] = 62] = "Union";
1101
+ ValueErrorType[ValueErrorType["Void"] = 63] = "Void";
1102
+ })(ValueErrorType || (ValueErrorType = {}));
1103
+ var ValueErrorsUnknownTypeError = class extends TypeBoxError {
1104
+ constructor(schema) {
1105
+ super("Unknown type");
1106
+ this.schema = schema;
1107
+ }
1108
+ };
1109
+ function EscapeKey(key) {
1110
+ return key.replace(/~/g, "~0").replace(/\//g, "~1");
1111
+ }
1112
+ function IsDefined(value) {
1113
+ return value !== void 0;
1114
+ }
1115
+ var ValueErrorIterator = class {
1116
+ constructor(iterator) {
1117
+ this.iterator = iterator;
1118
+ }
1119
+ [Symbol.iterator]() {
1120
+ return this.iterator;
1121
+ }
1122
+ /** Returns the first value error or undefined if no errors */
1123
+ First() {
1124
+ const next = this.iterator.next();
1125
+ return next.done ? void 0 : next.value;
1126
+ }
1127
+ };
1128
+ function Create(errorType, schema, path, value, errors = []) {
1129
+ return {
1130
+ type: errorType,
1131
+ schema,
1132
+ path,
1133
+ value,
1134
+ message: GetErrorFunction()({
1135
+ errorType,
1136
+ path,
1137
+ schema,
1138
+ value,
1139
+ errors
1140
+ }),
1141
+ errors
1142
+ };
1143
+ }
1144
+ function* FromAny(schema, references, path, value) {}
1145
+ function* FromArgument(schema, references, path, value) {}
1146
+ function* FromArray(schema, references, path, value) {
1147
+ if (!IsArray$2(value)) return yield Create(ValueErrorType.Array, schema, path, value);
1148
+ if (IsDefined(schema.minItems) && !(value.length >= schema.minItems)) yield Create(ValueErrorType.ArrayMinItems, schema, path, value);
1149
+ if (IsDefined(schema.maxItems) && !(value.length <= schema.maxItems)) yield Create(ValueErrorType.ArrayMaxItems, schema, path, value);
1150
+ for (let i = 0; i < value.length; i++) yield* Visit(schema.items, references, `${path}/${i}`, value[i]);
1151
+ if (schema.uniqueItems === true && !(function() {
1152
+ const set = /* @__PURE__ */ new Set();
1153
+ for (const element of value) {
1154
+ const hashed = Hash(element);
1155
+ if (set.has(hashed)) return false;
1156
+ else set.add(hashed);
1157
+ }
1158
+ return true;
1159
+ })()) yield Create(ValueErrorType.ArrayUniqueItems, schema, path, value);
1160
+ if (!(IsDefined(schema.contains) || IsDefined(schema.minContains) || IsDefined(schema.maxContains))) return;
1161
+ const containsSchema = IsDefined(schema.contains) ? schema.contains : Never();
1162
+ const containsCount = value.reduce((acc, value, index) => Visit(containsSchema, references, `${path}${index}`, value).next().done === true ? acc + 1 : acc, 0);
1163
+ if (containsCount === 0) yield Create(ValueErrorType.ArrayContains, schema, path, value);
1164
+ if (IsNumber$1(schema.minContains) && containsCount < schema.minContains) yield Create(ValueErrorType.ArrayMinContains, schema, path, value);
1165
+ if (IsNumber$1(schema.maxContains) && containsCount > schema.maxContains) yield Create(ValueErrorType.ArrayMaxContains, schema, path, value);
1166
+ }
1167
+ function* FromAsyncIterator(schema, references, path, value) {
1168
+ if (!IsAsyncIterator$1(value)) yield Create(ValueErrorType.AsyncIterator, schema, path, value);
1169
+ }
1170
+ function* FromBigInt(schema, references, path, value) {
1171
+ if (!IsBigInt$1(value)) return yield Create(ValueErrorType.BigInt, schema, path, value);
1172
+ if (IsDefined(schema.exclusiveMaximum) && !(value < schema.exclusiveMaximum)) yield Create(ValueErrorType.BigIntExclusiveMaximum, schema, path, value);
1173
+ if (IsDefined(schema.exclusiveMinimum) && !(value > schema.exclusiveMinimum)) yield Create(ValueErrorType.BigIntExclusiveMinimum, schema, path, value);
1174
+ if (IsDefined(schema.maximum) && !(value <= schema.maximum)) yield Create(ValueErrorType.BigIntMaximum, schema, path, value);
1175
+ if (IsDefined(schema.minimum) && !(value >= schema.minimum)) yield Create(ValueErrorType.BigIntMinimum, schema, path, value);
1176
+ if (IsDefined(schema.multipleOf) && !(value % schema.multipleOf === BigInt(0))) yield Create(ValueErrorType.BigIntMultipleOf, schema, path, value);
1177
+ }
1178
+ function* FromBoolean(schema, references, path, value) {
1179
+ if (!IsBoolean$1(value)) yield Create(ValueErrorType.Boolean, schema, path, value);
1180
+ }
1181
+ function* FromConstructor(schema, references, path, value) {
1182
+ yield* Visit(schema.returns, references, path, value.prototype);
1183
+ }
1184
+ function* FromDate(schema, references, path, value) {
1185
+ if (!IsDate$2(value)) return yield Create(ValueErrorType.Date, schema, path, value);
1186
+ if (IsDefined(schema.exclusiveMaximumTimestamp) && !(value.getTime() < schema.exclusiveMaximumTimestamp)) yield Create(ValueErrorType.DateExclusiveMaximumTimestamp, schema, path, value);
1187
+ if (IsDefined(schema.exclusiveMinimumTimestamp) && !(value.getTime() > schema.exclusiveMinimumTimestamp)) yield Create(ValueErrorType.DateExclusiveMinimumTimestamp, schema, path, value);
1188
+ if (IsDefined(schema.maximumTimestamp) && !(value.getTime() <= schema.maximumTimestamp)) yield Create(ValueErrorType.DateMaximumTimestamp, schema, path, value);
1189
+ if (IsDefined(schema.minimumTimestamp) && !(value.getTime() >= schema.minimumTimestamp)) yield Create(ValueErrorType.DateMinimumTimestamp, schema, path, value);
1190
+ if (IsDefined(schema.multipleOfTimestamp) && !(value.getTime() % schema.multipleOfTimestamp === 0)) yield Create(ValueErrorType.DateMultipleOfTimestamp, schema, path, value);
1191
+ }
1192
+ function* FromFunction(schema, references, path, value) {
1193
+ if (!IsFunction$1(value)) yield Create(ValueErrorType.Function, schema, path, value);
1194
+ }
1195
+ function* FromImport(schema, references, path, value) {
1196
+ const definitions = globalThis.Object.values(schema.$defs);
1197
+ const target = schema.$defs[schema.$ref];
1198
+ yield* Visit(target, [...references, ...definitions], path, value);
1199
+ }
1200
+ function* FromInteger(schema, references, path, value) {
1201
+ if (!IsInteger$1(value)) return yield Create(ValueErrorType.Integer, schema, path, value);
1202
+ if (IsDefined(schema.exclusiveMaximum) && !(value < schema.exclusiveMaximum)) yield Create(ValueErrorType.IntegerExclusiveMaximum, schema, path, value);
1203
+ if (IsDefined(schema.exclusiveMinimum) && !(value > schema.exclusiveMinimum)) yield Create(ValueErrorType.IntegerExclusiveMinimum, schema, path, value);
1204
+ if (IsDefined(schema.maximum) && !(value <= schema.maximum)) yield Create(ValueErrorType.IntegerMaximum, schema, path, value);
1205
+ if (IsDefined(schema.minimum) && !(value >= schema.minimum)) yield Create(ValueErrorType.IntegerMinimum, schema, path, value);
1206
+ if (IsDefined(schema.multipleOf) && !(value % schema.multipleOf === 0)) yield Create(ValueErrorType.IntegerMultipleOf, schema, path, value);
1207
+ }
1208
+ function* FromIntersect(schema, references, path, value) {
1209
+ let hasError = false;
1210
+ for (const inner of schema.allOf) for (const error of Visit(inner, references, path, value)) {
1211
+ hasError = true;
1212
+ yield error;
1213
+ }
1214
+ if (hasError) return yield Create(ValueErrorType.Intersect, schema, path, value);
1215
+ if (schema.unevaluatedProperties === false) {
1216
+ const keyCheck = new RegExp(KeyOfPattern(schema));
1217
+ for (const valueKey of Object.getOwnPropertyNames(value)) if (!keyCheck.test(valueKey)) yield Create(ValueErrorType.IntersectUnevaluatedProperties, schema, `${path}/${valueKey}`, value);
1218
+ }
1219
+ if (typeof schema.unevaluatedProperties === "object") {
1220
+ const keyCheck = new RegExp(KeyOfPattern(schema));
1221
+ for (const valueKey of Object.getOwnPropertyNames(value)) if (!keyCheck.test(valueKey)) {
1222
+ const next = Visit(schema.unevaluatedProperties, references, `${path}/${valueKey}`, value[valueKey]).next();
1223
+ if (!next.done) yield next.value;
1224
+ }
1225
+ }
1226
+ }
1227
+ function* FromIterator(schema, references, path, value) {
1228
+ if (!IsIterator$1(value)) yield Create(ValueErrorType.Iterator, schema, path, value);
1229
+ }
1230
+ function* FromLiteral(schema, references, path, value) {
1231
+ if (!(value === schema.const)) yield Create(ValueErrorType.Literal, schema, path, value);
1232
+ }
1233
+ function* FromNever(schema, references, path, value) {
1234
+ yield Create(ValueErrorType.Never, schema, path, value);
1235
+ }
1236
+ function* FromNot(schema, references, path, value) {
1237
+ if (Visit(schema.not, references, path, value).next().done === true) yield Create(ValueErrorType.Not, schema, path, value);
1238
+ }
1239
+ function* FromNull(schema, references, path, value) {
1240
+ if (!IsNull$1(value)) yield Create(ValueErrorType.Null, schema, path, value);
1241
+ }
1242
+ function* FromNumber(schema, references, path, value) {
1243
+ if (!TypeSystemPolicy.IsNumberLike(value)) return yield Create(ValueErrorType.Number, schema, path, value);
1244
+ if (IsDefined(schema.exclusiveMaximum) && !(value < schema.exclusiveMaximum)) yield Create(ValueErrorType.NumberExclusiveMaximum, schema, path, value);
1245
+ if (IsDefined(schema.exclusiveMinimum) && !(value > schema.exclusiveMinimum)) yield Create(ValueErrorType.NumberExclusiveMinimum, schema, path, value);
1246
+ if (IsDefined(schema.maximum) && !(value <= schema.maximum)) yield Create(ValueErrorType.NumberMaximum, schema, path, value);
1247
+ if (IsDefined(schema.minimum) && !(value >= schema.minimum)) yield Create(ValueErrorType.NumberMinimum, schema, path, value);
1248
+ if (IsDefined(schema.multipleOf) && !(value % schema.multipleOf === 0)) yield Create(ValueErrorType.NumberMultipleOf, schema, path, value);
1249
+ }
1250
+ function* FromObject(schema, references, path, value) {
1251
+ if (!TypeSystemPolicy.IsObjectLike(value)) return yield Create(ValueErrorType.Object, schema, path, value);
1252
+ if (IsDefined(schema.minProperties) && !(Object.getOwnPropertyNames(value).length >= schema.minProperties)) yield Create(ValueErrorType.ObjectMinProperties, schema, path, value);
1253
+ if (IsDefined(schema.maxProperties) && !(Object.getOwnPropertyNames(value).length <= schema.maxProperties)) yield Create(ValueErrorType.ObjectMaxProperties, schema, path, value);
1254
+ const requiredKeys = Array.isArray(schema.required) ? schema.required : [];
1255
+ const knownKeys = Object.getOwnPropertyNames(schema.properties);
1256
+ const unknownKeys = Object.getOwnPropertyNames(value);
1257
+ for (const requiredKey of requiredKeys) {
1258
+ if (unknownKeys.includes(requiredKey)) continue;
1259
+ yield Create(ValueErrorType.ObjectRequiredProperty, schema.properties[requiredKey], `${path}/${EscapeKey(requiredKey)}`, void 0);
1260
+ }
1261
+ if (schema.additionalProperties === false) {
1262
+ for (const valueKey of unknownKeys) if (!knownKeys.includes(valueKey)) yield Create(ValueErrorType.ObjectAdditionalProperties, schema, `${path}/${EscapeKey(valueKey)}`, value[valueKey]);
1263
+ }
1264
+ if (typeof schema.additionalProperties === "object") for (const valueKey of unknownKeys) {
1265
+ if (knownKeys.includes(valueKey)) continue;
1266
+ yield* Visit(schema.additionalProperties, references, `${path}/${EscapeKey(valueKey)}`, value[valueKey]);
1267
+ }
1268
+ for (const knownKey of knownKeys) {
1269
+ const property = schema.properties[knownKey];
1270
+ if (schema.required && schema.required.includes(knownKey)) {
1271
+ yield* Visit(property, references, `${path}/${EscapeKey(knownKey)}`, value[knownKey]);
1272
+ if (ExtendsUndefinedCheck(schema) && !(knownKey in value)) yield Create(ValueErrorType.ObjectRequiredProperty, property, `${path}/${EscapeKey(knownKey)}`, void 0);
1273
+ } else if (TypeSystemPolicy.IsExactOptionalProperty(value, knownKey)) yield* Visit(property, references, `${path}/${EscapeKey(knownKey)}`, value[knownKey]);
1274
+ }
1275
+ }
1276
+ function* FromPromise(schema, references, path, value) {
1277
+ if (!IsPromise$1(value)) yield Create(ValueErrorType.Promise, schema, path, value);
1278
+ }
1279
+ function* FromRecord(schema, references, path, value) {
1280
+ if (!TypeSystemPolicy.IsRecordLike(value)) return yield Create(ValueErrorType.Object, schema, path, value);
1281
+ if (IsDefined(schema.minProperties) && !(Object.getOwnPropertyNames(value).length >= schema.minProperties)) yield Create(ValueErrorType.ObjectMinProperties, schema, path, value);
1282
+ if (IsDefined(schema.maxProperties) && !(Object.getOwnPropertyNames(value).length <= schema.maxProperties)) yield Create(ValueErrorType.ObjectMaxProperties, schema, path, value);
1283
+ const [patternKey, patternSchema] = Object.entries(schema.patternProperties)[0];
1284
+ const regex = new RegExp(patternKey);
1285
+ for (const [propertyKey, propertyValue] of Object.entries(value)) if (regex.test(propertyKey)) yield* Visit(patternSchema, references, `${path}/${EscapeKey(propertyKey)}`, propertyValue);
1286
+ if (typeof schema.additionalProperties === "object") {
1287
+ for (const [propertyKey, propertyValue] of Object.entries(value)) if (!regex.test(propertyKey)) yield* Visit(schema.additionalProperties, references, `${path}/${EscapeKey(propertyKey)}`, propertyValue);
1288
+ }
1289
+ if (schema.additionalProperties === false) for (const [propertyKey, propertyValue] of Object.entries(value)) {
1290
+ if (regex.test(propertyKey)) continue;
1291
+ return yield Create(ValueErrorType.ObjectAdditionalProperties, schema, `${path}/${EscapeKey(propertyKey)}`, propertyValue);
1292
+ }
1293
+ }
1294
+ function* FromRef(schema, references, path, value) {
1295
+ yield* Visit(Deref(schema, references), references, path, value);
1296
+ }
1297
+ function* FromRegExp(schema, references, path, value) {
1298
+ if (!IsString$2(value)) return yield Create(ValueErrorType.String, schema, path, value);
1299
+ if (IsDefined(schema.minLength) && !(value.length >= schema.minLength)) yield Create(ValueErrorType.StringMinLength, schema, path, value);
1300
+ if (IsDefined(schema.maxLength) && !(value.length <= schema.maxLength)) yield Create(ValueErrorType.StringMaxLength, schema, path, value);
1301
+ if (!new RegExp(schema.source, schema.flags).test(value)) return yield Create(ValueErrorType.RegExp, schema, path, value);
1302
+ }
1303
+ function* FromString(schema, references, path, value) {
1304
+ if (!IsString$2(value)) return yield Create(ValueErrorType.String, schema, path, value);
1305
+ if (IsDefined(schema.minLength) && !(value.length >= schema.minLength)) yield Create(ValueErrorType.StringMinLength, schema, path, value);
1306
+ if (IsDefined(schema.maxLength) && !(value.length <= schema.maxLength)) yield Create(ValueErrorType.StringMaxLength, schema, path, value);
1307
+ if (IsString$2(schema.pattern)) {
1308
+ if (!new RegExp(schema.pattern).test(value)) yield Create(ValueErrorType.StringPattern, schema, path, value);
1309
+ }
1310
+ if (IsString$2(schema.format)) {
1311
+ if (!Has$1(schema.format)) yield Create(ValueErrorType.StringFormatUnknown, schema, path, value);
1312
+ else if (!Get$1(schema.format)(value)) yield Create(ValueErrorType.StringFormat, schema, path, value);
1313
+ }
1314
+ }
1315
+ function* FromSymbol(schema, references, path, value) {
1316
+ if (!IsSymbol$1(value)) yield Create(ValueErrorType.Symbol, schema, path, value);
1317
+ }
1318
+ function* FromTemplateLiteral(schema, references, path, value) {
1319
+ if (!IsString$2(value)) return yield Create(ValueErrorType.String, schema, path, value);
1320
+ if (!new RegExp(schema.pattern).test(value)) yield Create(ValueErrorType.StringPattern, schema, path, value);
1321
+ }
1322
+ function* FromThis(schema, references, path, value) {
1323
+ yield* Visit(Deref(schema, references), references, path, value);
1324
+ }
1325
+ function* FromTuple(schema, references, path, value) {
1326
+ if (!IsArray$2(value)) return yield Create(ValueErrorType.Tuple, schema, path, value);
1327
+ if (schema.items === void 0 && !(value.length === 0)) return yield Create(ValueErrorType.TupleLength, schema, path, value);
1328
+ if (!(value.length === schema.maxItems)) return yield Create(ValueErrorType.TupleLength, schema, path, value);
1329
+ if (!schema.items) return;
1330
+ for (let i = 0; i < schema.items.length; i++) yield* Visit(schema.items[i], references, `${path}/${i}`, value[i]);
1331
+ }
1332
+ function* FromUndefined(schema, references, path, value) {
1333
+ if (!IsUndefined$1(value)) yield Create(ValueErrorType.Undefined, schema, path, value);
1334
+ }
1335
+ function* FromUnion(schema, references, path, value) {
1336
+ if (Check(schema, references, value)) return;
1337
+ const errors = schema.anyOf.map((variant) => new ValueErrorIterator(Visit(variant, references, path, value)));
1338
+ yield Create(ValueErrorType.Union, schema, path, value, errors);
1339
+ }
1340
+ function* FromUint8Array(schema, references, path, value) {
1341
+ if (!IsUint8Array$2(value)) return yield Create(ValueErrorType.Uint8Array, schema, path, value);
1342
+ if (IsDefined(schema.maxByteLength) && !(value.length <= schema.maxByteLength)) yield Create(ValueErrorType.Uint8ArrayMaxByteLength, schema, path, value);
1343
+ if (IsDefined(schema.minByteLength) && !(value.length >= schema.minByteLength)) yield Create(ValueErrorType.Uint8ArrayMinByteLength, schema, path, value);
1344
+ }
1345
+ function* FromUnknown(schema, references, path, value) {}
1346
+ function* FromVoid(schema, references, path, value) {
1347
+ if (!TypeSystemPolicy.IsVoidLike(value)) yield Create(ValueErrorType.Void, schema, path, value);
1348
+ }
1349
+ function* FromKind(schema, references, path, value) {
1350
+ if (!Get(schema[Kind])(schema, value)) yield Create(ValueErrorType.Kind, schema, path, value);
1351
+ }
1352
+ function* Visit(schema, references, path, value) {
1353
+ const references_ = IsDefined(schema.$id) ? [...references, schema] : references;
1354
+ const schema_ = schema;
1355
+ switch (schema_[Kind]) {
1356
+ case "Any": return yield* FromAny(schema_, references_, path, value);
1357
+ case "Argument": return yield* FromArgument(schema_, references_, path, value);
1358
+ case "Array": return yield* FromArray(schema_, references_, path, value);
1359
+ case "AsyncIterator": return yield* FromAsyncIterator(schema_, references_, path, value);
1360
+ case "BigInt": return yield* FromBigInt(schema_, references_, path, value);
1361
+ case "Boolean": return yield* FromBoolean(schema_, references_, path, value);
1362
+ case "Constructor": return yield* FromConstructor(schema_, references_, path, value);
1363
+ case "Date": return yield* FromDate(schema_, references_, path, value);
1364
+ case "Function": return yield* FromFunction(schema_, references_, path, value);
1365
+ case "Import": return yield* FromImport(schema_, references_, path, value);
1366
+ case "Integer": return yield* FromInteger(schema_, references_, path, value);
1367
+ case "Intersect": return yield* FromIntersect(schema_, references_, path, value);
1368
+ case "Iterator": return yield* FromIterator(schema_, references_, path, value);
1369
+ case "Literal": return yield* FromLiteral(schema_, references_, path, value);
1370
+ case "Never": return yield* FromNever(schema_, references_, path, value);
1371
+ case "Not": return yield* FromNot(schema_, references_, path, value);
1372
+ case "Null": return yield* FromNull(schema_, references_, path, value);
1373
+ case "Number": return yield* FromNumber(schema_, references_, path, value);
1374
+ case "Object": return yield* FromObject(schema_, references_, path, value);
1375
+ case "Promise": return yield* FromPromise(schema_, references_, path, value);
1376
+ case "Record": return yield* FromRecord(schema_, references_, path, value);
1377
+ case "Ref": return yield* FromRef(schema_, references_, path, value);
1378
+ case "RegExp": return yield* FromRegExp(schema_, references_, path, value);
1379
+ case "String": return yield* FromString(schema_, references_, path, value);
1380
+ case "Symbol": return yield* FromSymbol(schema_, references_, path, value);
1381
+ case "TemplateLiteral": return yield* FromTemplateLiteral(schema_, references_, path, value);
1382
+ case "This": return yield* FromThis(schema_, references_, path, value);
1383
+ case "Tuple": return yield* FromTuple(schema_, references_, path, value);
1384
+ case "Undefined": return yield* FromUndefined(schema_, references_, path, value);
1385
+ case "Union": return yield* FromUnion(schema_, references_, path, value);
1386
+ case "Uint8Array": return yield* FromUint8Array(schema_, references_, path, value);
1387
+ case "Unknown": return yield* FromUnknown(schema_, references_, path, value);
1388
+ case "Void": return yield* FromVoid(schema_, references_, path, value);
1389
+ default:
1390
+ if (!Has(schema_[Kind])) throw new ValueErrorsUnknownTypeError(schema);
1391
+ return yield* FromKind(schema_, references_, path, value);
1392
+ }
1393
+ }
1394
+ /** Returns an iterator for each error in this value. */
1395
+ function Errors(...args) {
1396
+ return new ValueErrorIterator(args.length === 3 ? Visit(args[0], args[1], "", args[2]) : Visit(args[0], [], "", args[1]));
1397
+ }
1398
+ //#endregion
1399
+ //#region src/reference-adapter.ts
1400
+ function referenceAdapter() {
1401
+ const adapter = {};
1402
+ for (const entry of Object.values(PROFILES)) {
1403
+ adapter[`${entry.literal}#digest.envelope`] = (bytes) => {
1404
+ let parsed;
1405
+ try {
1406
+ parsed = JSON.parse(new TextDecoder("utf-8", { fatal: true }).decode(bytes));
1407
+ } catch (error) {
1408
+ return {
1409
+ ok: false,
1410
+ reason: `not UTF-8 JSON: ${String(error)}`
1411
+ };
1412
+ }
1413
+ return {
1414
+ ok: true,
1415
+ digest: createHash("sha256").update(jcsStringify(parsed)).digest("hex")
1416
+ };
1417
+ };
1418
+ for (const [shapeName, shape] of Object.entries(entry.shapes)) adapter[`${entry.literal}#${shapeName}`] = (bytes) => {
1419
+ let parsed;
1420
+ try {
1421
+ parsed = JSON.parse(new TextDecoder("utf-8", { fatal: true }).decode(bytes));
1422
+ } catch (error) {
1423
+ return {
1424
+ ok: false,
1425
+ reason: `not UTF-8 JSON: ${String(error)}`
1426
+ };
1427
+ }
1428
+ if (Check(shape, parsed)) return { ok: true };
1429
+ const first = Errors(shape, parsed).First();
1430
+ return {
1431
+ ok: false,
1432
+ reason: `${first?.path ?? ""}: ${first?.message ?? "schema mismatch"}`
1433
+ };
1434
+ };
1435
+ }
1436
+ return adapter;
1437
+ }
1438
+ //#endregion
1439
+ export { runVectors as n, referenceAdapter as t };
1440
+
1441
+ //# sourceMappingURL=reference-adapter-CaAo2iIH.mjs.map