@clawkeepers/cli 0.1.0-beta.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 (54) hide show
  1. package/LICENSE +21 -0
  2. package/NOTICE +206 -0
  3. package/README.md +52 -0
  4. package/dist/bin/clawos.js +2 -0
  5. package/dist/bin/config-transaction.mjs +56 -0
  6. package/dist/bin/gateway-rpc.mjs +57 -0
  7. package/dist/index.d.ts +8 -0
  8. package/dist/index.js +6709 -0
  9. package/dist/templates/blueprints/LICENSE +21 -0
  10. package/dist/templates/blueprints/NOTICE +206 -0
  11. package/dist/templates/blueprints/assistant/AGENTS.md +7 -0
  12. package/dist/templates/blueprints/assistant/README.md +11 -0
  13. package/dist/templates/blueprints/assistant/SOUL.md +3 -0
  14. package/dist/templates/blueprints/assistant/blueprint.json +27 -0
  15. package/dist/templates/blueprints/blueprint.schema.json +148 -0
  16. package/dist/templates/blueprints/coder/AGENTS.md +7 -0
  17. package/dist/templates/blueprints/coder/README.md +11 -0
  18. package/dist/templates/blueprints/coder/SOUL.md +3 -0
  19. package/dist/templates/blueprints/coder/blueprint.json +30 -0
  20. package/dist/templates/blueprints/ops/AGENTS.md +7 -0
  21. package/dist/templates/blueprints/ops/README.md +11 -0
  22. package/dist/templates/blueprints/ops/SOUL.md +3 -0
  23. package/dist/templates/blueprints/ops/blueprint.json +27 -0
  24. package/dist/templates/blueprints/package.json +22 -0
  25. package/dist/templates/blueprints/researcher/AGENTS.md +7 -0
  26. package/dist/templates/blueprints/researcher/README.md +11 -0
  27. package/dist/templates/blueprints/researcher/SOUL.md +3 -0
  28. package/dist/templates/blueprints/researcher/blueprint.json +30 -0
  29. package/dist/templates/clawos.conf +10 -0
  30. package/dist/templates/clawos.lock.json +19 -0
  31. package/dist/templates/config.d/00-baseline.json5 +26 -0
  32. package/dist/templates/config.d/05-policy-runtime.json5 +18 -0
  33. package/dist/templates/config.d/10-plugins.json5 +4 -0
  34. package/dist/templates/config.d/20-sandbox.json5 +8 -0
  35. package/dist/templates/config.d/30-agents.json5 +4 -0
  36. package/dist/templates/config.d/90-local.json5 +2 -0
  37. package/dist/templates/gatekeepers.json +13 -0
  38. package/dist/templates/plugins/THIRD-PARTY-NOTICES +23 -0
  39. package/dist/templates/plugins/catalog.json +1 -0
  40. package/dist/templates/plugins/clawos-kernel/LICENSE +21 -0
  41. package/dist/templates/plugins/clawos-kernel/NOTICE +206 -0
  42. package/dist/templates/plugins/clawos-kernel/THIRD-PARTY-NOTICES +23 -0
  43. package/dist/templates/plugins/clawos-kernel/config.schema.json +14 -0
  44. package/dist/templates/plugins/clawos-kernel/dist/index.js +9847 -0
  45. package/dist/templates/plugins/clawos-kernel/openclaw.plugin.json +137 -0
  46. package/dist/templates/plugins/clawos-kernel/package.json +1 -0
  47. package/dist/templates/plugins/gatekeeper-fs/LICENSE +21 -0
  48. package/dist/templates/plugins/gatekeeper-fs/NOTICE +206 -0
  49. package/dist/templates/plugins/gatekeeper-fs/THIRD-PARTY-NOTICES +23 -0
  50. package/dist/templates/plugins/gatekeeper-fs/dist/index.js +9581 -0
  51. package/dist/templates/plugins/gatekeeper-fs/openclaw.plugin.json +30 -0
  52. package/dist/templates/plugins/gatekeeper-fs/package.json +1 -0
  53. package/dist/templates/plugins/install-policy.mjs +4734 -0
  54. package/package.json +51 -0
@@ -0,0 +1,4734 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __export = (target, all) => {
3
+ for (var name in all)
4
+ __defProp(target, name, { get: all[name], enumerable: true });
5
+ };
6
+
7
+ // src/commands/install-policy.ts
8
+ import { readFileSync as readFileSync2 } from "fs";
9
+
10
+ // ../../node_modules/.pnpm/typebox@1.1.39/node_modules/typebox/build/system/memory/memory.mjs
11
+ var memory_exports = {};
12
+ __export(memory_exports, {
13
+ Assign: () => Assign,
14
+ Clone: () => Clone,
15
+ Create: () => Create,
16
+ Discard: () => Discard,
17
+ Metrics: () => Metrics,
18
+ Update: () => Update
19
+ });
20
+
21
+ // ../../node_modules/.pnpm/typebox@1.1.39/node_modules/typebox/build/system/memory/metrics.mjs
22
+ var Metrics = {
23
+ assign: 0,
24
+ create: 0,
25
+ clone: 0,
26
+ discard: 0,
27
+ update: 0
28
+ };
29
+
30
+ // ../../node_modules/.pnpm/typebox@1.1.39/node_modules/typebox/build/system/memory/assign.mjs
31
+ function Assign(left, right) {
32
+ Metrics.assign += 1;
33
+ return { ...left, ...right };
34
+ }
35
+
36
+ // ../../node_modules/.pnpm/typebox@1.1.39/node_modules/typebox/build/guard/guard.mjs
37
+ var guard_exports = {};
38
+ __export(guard_exports, {
39
+ Entries: () => Entries,
40
+ EntriesRegExp: () => EntriesRegExp,
41
+ Every: () => Every,
42
+ EveryAll: () => EveryAll,
43
+ GraphemeCount: () => GraphemeCount2,
44
+ HasPropertyKey: () => HasPropertyKey,
45
+ IsArray: () => IsArray,
46
+ IsAsyncIterator: () => IsAsyncIterator,
47
+ IsBigInt: () => IsBigInt,
48
+ IsBoolean: () => IsBoolean,
49
+ IsClassInstance: () => IsClassInstance,
50
+ IsConstructor: () => IsConstructor,
51
+ IsDeepEqual: () => IsDeepEqual,
52
+ IsEqual: () => IsEqual,
53
+ IsFunction: () => IsFunction,
54
+ IsGreaterEqualThan: () => IsGreaterEqualThan,
55
+ IsGreaterThan: () => IsGreaterThan,
56
+ IsInteger: () => IsInteger,
57
+ IsIterator: () => IsIterator,
58
+ IsLessEqualThan: () => IsLessEqualThan,
59
+ IsLessThan: () => IsLessThan,
60
+ IsMaxLength: () => IsMaxLength2,
61
+ IsMinLength: () => IsMinLength2,
62
+ IsMultipleOf: () => IsMultipleOf,
63
+ IsNull: () => IsNull,
64
+ IsNumber: () => IsNumber,
65
+ IsObject: () => IsObject,
66
+ IsObjectNotArray: () => IsObjectNotArray,
67
+ IsString: () => IsString,
68
+ IsSymbol: () => IsSymbol,
69
+ IsUndefined: () => IsUndefined,
70
+ IsUnsafePropertyKey: () => IsUnsafePropertyKey,
71
+ IsValueLike: () => IsValueLike,
72
+ Keys: () => Keys,
73
+ Symbols: () => Symbols,
74
+ TakeLeft: () => TakeLeft,
75
+ Values: () => Values
76
+ });
77
+
78
+ // ../../node_modules/.pnpm/typebox@1.1.39/node_modules/typebox/build/guard/string.mjs
79
+ function IsBetween(value, min, max) {
80
+ return value >= min && value <= max;
81
+ }
82
+ function IsRegionalIndicator(value) {
83
+ return IsBetween(value, 127462, 127487);
84
+ }
85
+ function IsVariationSelector(value) {
86
+ return IsBetween(value, 65024, 65039);
87
+ }
88
+ function IsCombiningMark(value) {
89
+ return IsBetween(value, 768, 879) || IsBetween(value, 6832, 6911) || IsBetween(value, 7616, 7679) || IsBetween(value, 65056, 65071);
90
+ }
91
+ function CodePointLength(value) {
92
+ return value > 65535 ? 2 : 1;
93
+ }
94
+ function ConsumeModifiers(value, index) {
95
+ while (index < value.length) {
96
+ const point = value.codePointAt(index);
97
+ if (IsCombiningMark(point) || IsVariationSelector(point)) {
98
+ index += CodePointLength(point);
99
+ } else {
100
+ break;
101
+ }
102
+ }
103
+ return index;
104
+ }
105
+ function NextGraphemeClusterIndex(value, clusterStart) {
106
+ const startCP = value.codePointAt(clusterStart);
107
+ let clusterEnd = clusterStart + CodePointLength(startCP);
108
+ clusterEnd = ConsumeModifiers(value, clusterEnd);
109
+ while (clusterEnd < value.length - 1 && value[clusterEnd] === "\u200D") {
110
+ const nextCP = value.codePointAt(clusterEnd + 1);
111
+ clusterEnd += 1 + CodePointLength(nextCP);
112
+ clusterEnd = ConsumeModifiers(value, clusterEnd);
113
+ }
114
+ if (IsRegionalIndicator(startCP) && clusterEnd < value.length && IsRegionalIndicator(value.codePointAt(clusterEnd))) {
115
+ clusterEnd += CodePointLength(value.codePointAt(clusterEnd));
116
+ }
117
+ return clusterEnd;
118
+ }
119
+ function IsGraphemeCodePoint(value) {
120
+ return IsBetween(value, 55296, 56319) || // High surrogate
121
+ IsBetween(value, 768, 879) || // Combining diacritical marks
122
+ value === 8205;
123
+ }
124
+ function GraphemeCount(value) {
125
+ let count = 0;
126
+ let index = 0;
127
+ while (index < value.length) {
128
+ index = NextGraphemeClusterIndex(value, index);
129
+ count++;
130
+ }
131
+ return count;
132
+ }
133
+ function IsMinLength(value, minLength) {
134
+ if (minLength === 0)
135
+ return true;
136
+ let count = 0;
137
+ let index = 0;
138
+ while (index < value.length) {
139
+ index = NextGraphemeClusterIndex(value, index);
140
+ count++;
141
+ if (count >= minLength)
142
+ return true;
143
+ }
144
+ return false;
145
+ }
146
+ function IsMaxLength(value, maxLength) {
147
+ let count = 0;
148
+ let index = 0;
149
+ while (index < value.length) {
150
+ index = NextGraphemeClusterIndex(value, index);
151
+ count++;
152
+ if (count > maxLength)
153
+ return false;
154
+ }
155
+ return true;
156
+ }
157
+ function IsMinLengthFast(value, minLength) {
158
+ if (minLength === 0)
159
+ return true;
160
+ let index = 0;
161
+ while (index < value.length) {
162
+ if (IsGraphemeCodePoint(value.charCodeAt(index))) {
163
+ return IsMinLength(value, minLength);
164
+ }
165
+ index++;
166
+ if (index >= minLength)
167
+ return true;
168
+ }
169
+ return false;
170
+ }
171
+ function IsMaxLengthFast(value, maxLength) {
172
+ let index = 0;
173
+ while (index < value.length) {
174
+ if (IsGraphemeCodePoint(value.charCodeAt(index))) {
175
+ return IsMaxLength(value, maxLength);
176
+ }
177
+ index++;
178
+ if (index > maxLength)
179
+ return false;
180
+ }
181
+ return true;
182
+ }
183
+
184
+ // ../../node_modules/.pnpm/typebox@1.1.39/node_modules/typebox/build/guard/guard.mjs
185
+ function IsArray(value) {
186
+ return Array.isArray(value);
187
+ }
188
+ function IsAsyncIterator(value) {
189
+ return IsObject(value) && Symbol.asyncIterator in value;
190
+ }
191
+ function IsBigInt(value) {
192
+ return IsEqual(typeof value, "bigint");
193
+ }
194
+ function IsBoolean(value) {
195
+ return IsEqual(typeof value, "boolean");
196
+ }
197
+ function IsConstructor(value) {
198
+ if (IsUndefined(value) || !IsFunction(value))
199
+ return false;
200
+ const result = Function.prototype.toString.call(value);
201
+ if (/^class\s/.test(result))
202
+ return true;
203
+ if (/\[native code\]/.test(result))
204
+ return true;
205
+ return false;
206
+ }
207
+ function IsFunction(value) {
208
+ return IsEqual(typeof value, "function");
209
+ }
210
+ function IsInteger(value) {
211
+ return Number.isInteger(value);
212
+ }
213
+ function IsIterator(value) {
214
+ return IsObject(value) && Symbol.iterator in value;
215
+ }
216
+ function IsNull(value) {
217
+ return IsEqual(value, null);
218
+ }
219
+ function IsNumber(value) {
220
+ return Number.isFinite(value);
221
+ }
222
+ function IsObjectNotArray(value) {
223
+ return IsObject(value) && !IsArray(value);
224
+ }
225
+ function IsObject(value) {
226
+ return IsEqual(typeof value, "object") && !IsNull(value);
227
+ }
228
+ function IsString(value) {
229
+ return IsEqual(typeof value, "string");
230
+ }
231
+ function IsSymbol(value) {
232
+ return IsEqual(typeof value, "symbol");
233
+ }
234
+ function IsUndefined(value) {
235
+ return IsEqual(value, void 0);
236
+ }
237
+ function IsEqual(left, right) {
238
+ return left === right;
239
+ }
240
+ function IsGreaterThan(left, right) {
241
+ return left > right;
242
+ }
243
+ function IsLessThan(left, right) {
244
+ return left < right;
245
+ }
246
+ function IsLessEqualThan(left, right) {
247
+ return left <= right;
248
+ }
249
+ function IsGreaterEqualThan(left, right) {
250
+ return left >= right;
251
+ }
252
+ function IsMultipleOf(dividend, divisor) {
253
+ if (IsBigInt(dividend) || IsBigInt(divisor)) {
254
+ return BigInt(dividend) % BigInt(divisor) === 0n;
255
+ }
256
+ const tolerance = 1e-10;
257
+ if (!IsNumber(dividend))
258
+ return true;
259
+ if (IsInteger(dividend) && 1 / divisor % 1 === 0)
260
+ return true;
261
+ const mod = dividend % divisor;
262
+ return Math.min(Math.abs(mod), Math.abs(mod - divisor)) < tolerance;
263
+ }
264
+ function IsClassInstance(value) {
265
+ if (!IsObject(value))
266
+ return false;
267
+ const proto = globalThis.Object.getPrototypeOf(value);
268
+ if (IsNull(proto))
269
+ return false;
270
+ return IsEqual(typeof proto.constructor, "function") && !(IsEqual(proto.constructor, globalThis.Object) || IsEqual(proto.constructor.name, "Object"));
271
+ }
272
+ function IsValueLike(value) {
273
+ return IsBigInt(value) || IsBoolean(value) || IsNull(value) || IsNumber(value) || IsString(value) || IsUndefined(value);
274
+ }
275
+ function GraphemeCount2(value) {
276
+ return GraphemeCount(value);
277
+ }
278
+ function IsMaxLength2(value, length) {
279
+ return IsMaxLengthFast(value, length);
280
+ }
281
+ function IsMinLength2(value, length) {
282
+ return IsMinLengthFast(value, length);
283
+ }
284
+ function Every(value, offset, callback) {
285
+ for (let index = offset; index < value.length; index++) {
286
+ if (!callback(value[index], index))
287
+ return false;
288
+ }
289
+ return true;
290
+ }
291
+ function EveryAll(value, offset, callback) {
292
+ let result = true;
293
+ for (let index = offset; index < value.length; index++) {
294
+ if (!callback(value[index], index))
295
+ result = false;
296
+ }
297
+ return result;
298
+ }
299
+ function TakeLeft(array, true_, false_) {
300
+ return IsEqual(array.length, 0) ? false_() : true_(array[0], array.slice(1));
301
+ }
302
+ function IsUnsafePropertyKey(key) {
303
+ return IsEqual(key, "__proto__") || IsEqual(key, "constructor") || IsEqual(key, "prototype");
304
+ }
305
+ function HasPropertyKey(value, key) {
306
+ return IsUnsafePropertyKey(key) ? Object.prototype.hasOwnProperty.call(value, key) : key in value;
307
+ }
308
+ function EntriesRegExp(value) {
309
+ return Keys(value).map((key) => [new RegExp(`^${key}$`), value[key]]);
310
+ }
311
+ function Entries(value) {
312
+ return Object.entries(value);
313
+ }
314
+ function Keys(value) {
315
+ return Object.getOwnPropertyNames(value);
316
+ }
317
+ function Symbols(value) {
318
+ return Object.getOwnPropertySymbols(value);
319
+ }
320
+ function Values(value) {
321
+ return Object.values(value);
322
+ }
323
+ function DeepEqualObject(left, right) {
324
+ if (!IsObject(right))
325
+ return false;
326
+ const keys = Keys(left);
327
+ return IsEqual(keys.length, Keys(right).length) && keys.every((key) => IsDeepEqual(left[key], right[key]));
328
+ }
329
+ function DeepEqualArray(left, right) {
330
+ return IsArray(right) && IsEqual(left.length, right.length) && left.every((_, index) => IsDeepEqual(left[index], right[index]));
331
+ }
332
+ function IsDeepEqual(left, right) {
333
+ return IsArray(left) ? DeepEqualArray(left, right) : IsObject(left) ? DeepEqualObject(left, right) : IsEqual(left, right);
334
+ }
335
+
336
+ // ../../node_modules/.pnpm/typebox@1.1.39/node_modules/typebox/build/system/memory/clone.mjs
337
+ function IsGuard(value) {
338
+ return guard_exports.IsObject(value) && guard_exports.HasPropertyKey(value, "~guard");
339
+ }
340
+ function FromGuard(value) {
341
+ return value;
342
+ }
343
+ function FromArray(value) {
344
+ return value.map((value2) => FromValue(value2));
345
+ }
346
+ function FromObject(value) {
347
+ const result = {};
348
+ const descriptors = Object.getOwnPropertyDescriptors(value);
349
+ for (const key of Object.keys(descriptors)) {
350
+ const descriptor = descriptors[key];
351
+ if (guard_exports.HasPropertyKey(descriptor, "value")) {
352
+ Object.defineProperty(result, key, { ...descriptor, value: FromValue(descriptor.value) });
353
+ }
354
+ }
355
+ return result;
356
+ }
357
+ function FromRegExp(value) {
358
+ return new RegExp(value.source, value.flags);
359
+ }
360
+ function FromUnknown(value) {
361
+ return value;
362
+ }
363
+ function FromValue(value) {
364
+ return value instanceof RegExp ? FromRegExp(value) : IsGuard(value) ? FromGuard(value) : guard_exports.IsArray(value) ? FromArray(value) : guard_exports.IsObject(value) ? FromObject(value) : FromUnknown(value);
365
+ }
366
+ function Clone(value) {
367
+ Metrics.clone += 1;
368
+ return FromValue(value);
369
+ }
370
+
371
+ // ../../node_modules/.pnpm/typebox@1.1.39/node_modules/typebox/build/system/settings/settings.mjs
372
+ var settings_exports = {};
373
+ __export(settings_exports, {
374
+ Get: () => Get,
375
+ Reset: () => Reset,
376
+ Set: () => Set2
377
+ });
378
+ var settings = {
379
+ immutableTypes: false,
380
+ maxErrors: 8,
381
+ useAcceleration: true,
382
+ exactOptionalPropertyTypes: false,
383
+ enumerableKind: false,
384
+ correctiveParse: false
385
+ };
386
+ function Reset() {
387
+ settings.immutableTypes = false;
388
+ settings.maxErrors = 8;
389
+ settings.useAcceleration = true;
390
+ settings.exactOptionalPropertyTypes = false;
391
+ settings.enumerableKind = false;
392
+ settings.correctiveParse = false;
393
+ }
394
+ function Set2(options) {
395
+ for (const key of guard_exports.Keys(options)) {
396
+ const value = options[key];
397
+ if (value !== void 0) {
398
+ Object.defineProperty(settings, key, { value });
399
+ }
400
+ }
401
+ }
402
+ function Get() {
403
+ return settings;
404
+ }
405
+
406
+ // ../../node_modules/.pnpm/typebox@1.1.39/node_modules/typebox/build/system/memory/create.mjs
407
+ function MergeHidden(left, right) {
408
+ for (const key of Object.keys(right)) {
409
+ Object.defineProperty(left, key, {
410
+ configurable: true,
411
+ writable: true,
412
+ enumerable: false,
413
+ value: right[key]
414
+ });
415
+ }
416
+ return left;
417
+ }
418
+ function Merge(left, right) {
419
+ return { ...left, ...right };
420
+ }
421
+ function Create(hidden, enumerable, options = {}) {
422
+ Metrics.create += 1;
423
+ const settings2 = settings_exports.Get();
424
+ const withOptions = Merge(enumerable, options);
425
+ const withHidden = settings2.enumerableKind ? Merge(withOptions, hidden) : MergeHidden(withOptions, hidden);
426
+ return settings2.immutableTypes ? Object.freeze(withHidden) : withHidden;
427
+ }
428
+
429
+ // ../../node_modules/.pnpm/typebox@1.1.39/node_modules/typebox/build/system/memory/discard.mjs
430
+ function Discard(value, propertyKeys) {
431
+ Metrics.discard += 1;
432
+ const result = {};
433
+ const descriptors = Object.getOwnPropertyDescriptors(Clone(value));
434
+ const keysToDiscard = new Set(propertyKeys);
435
+ for (const key of Object.keys(descriptors)) {
436
+ if (keysToDiscard.has(key))
437
+ continue;
438
+ Object.defineProperty(result, key, descriptors[key]);
439
+ }
440
+ return result;
441
+ }
442
+
443
+ // ../../node_modules/.pnpm/typebox@1.1.39/node_modules/typebox/build/system/memory/update.mjs
444
+ function Update(current, hidden, enumerable) {
445
+ Metrics.update += 1;
446
+ const settings2 = settings_exports.Get();
447
+ const result = Clone(current);
448
+ for (const key of Object.keys(hidden)) {
449
+ Object.defineProperty(result, key, {
450
+ configurable: true,
451
+ writable: true,
452
+ enumerable: settings2.enumerableKind,
453
+ value: hidden[key]
454
+ });
455
+ }
456
+ for (const key of Object.keys(enumerable)) {
457
+ Object.defineProperty(result, key, {
458
+ configurable: true,
459
+ enumerable: true,
460
+ writable: true,
461
+ value: enumerable[key]
462
+ });
463
+ }
464
+ return result;
465
+ }
466
+
467
+ // ../../node_modules/.pnpm/typebox@1.1.39/node_modules/typebox/build/type/types/schema.mjs
468
+ function IsKind(value, kind) {
469
+ return guard_exports.IsObject(value) && guard_exports.HasPropertyKey(value, "~kind") && guard_exports.IsEqual(value["~kind"], kind);
470
+ }
471
+ function IsSchema(value) {
472
+ return guard_exports.IsObject(value);
473
+ }
474
+
475
+ // ../../node_modules/.pnpm/typebox@1.1.39/node_modules/typebox/build/type/action/_optional.mjs
476
+ function OptionalAddAction(type) {
477
+ return memory_exports.Create({ ["~kind"]: "OptionalAddAction" }, { type }, {});
478
+ }
479
+ function IsOptionalAddAction(value) {
480
+ return guard_exports.IsObject(value) && guard_exports.HasPropertyKey(value, "~kind") && guard_exports.HasPropertyKey(value, "type") && guard_exports.IsEqual(value["~kind"], "OptionalAddAction") && IsSchema(value.type);
481
+ }
482
+ function OptionalRemoveAction(type) {
483
+ return memory_exports.Create({ ["~kind"]: "OptionalRemoveAction" }, { type }, {});
484
+ }
485
+ function IsOptionalRemoveAction(value) {
486
+ return guard_exports.IsObject(value) && guard_exports.HasPropertyKey(value, "~kind") && guard_exports.HasPropertyKey(value, "type") && guard_exports.IsEqual(value["~kind"], "OptionalRemoveAction") && IsSchema(value.type);
487
+ }
488
+
489
+ // ../../node_modules/.pnpm/typebox@1.1.39/node_modules/typebox/build/type/action/_readonly.mjs
490
+ function ReadonlyAddAction(type) {
491
+ return memory_exports.Create({ ["~kind"]: "ReadonlyAddAction" }, { type }, {});
492
+ }
493
+ function IsReadonlyAddAction(value) {
494
+ return guard_exports.IsObject(value) && guard_exports.HasPropertyKey(value, "~kind") && guard_exports.HasPropertyKey(value, "type") && guard_exports.IsEqual(value["~kind"], "ReadonlyAddAction") && IsSchema(value.type);
495
+ }
496
+ function ReadonlyRemoveAction(type) {
497
+ return memory_exports.Create({ ["~kind"]: "ReadonlyRemoveAction" }, { type }, {});
498
+ }
499
+ function IsReadonlyRemoveAction(value) {
500
+ return guard_exports.IsObject(value) && guard_exports.HasPropertyKey(value, "~kind") && guard_exports.HasPropertyKey(value, "type") && guard_exports.IsEqual(value["~kind"], "ReadonlyRemoveAction") && IsSchema(value.type);
501
+ }
502
+
503
+ // ../../node_modules/.pnpm/typebox@1.1.39/node_modules/typebox/build/type/types/deferred.mjs
504
+ function Deferred(action, parameters, options) {
505
+ return memory_exports.Create({ "~kind": "Deferred" }, { action, parameters, options }, {});
506
+ }
507
+ function IsDeferred(value) {
508
+ return IsKind(value, "Deferred");
509
+ }
510
+
511
+ // ../../node_modules/.pnpm/typebox@1.1.39/node_modules/typebox/build/type/types/promise.mjs
512
+ function _Promise_(item, options) {
513
+ return memory_exports.Create({ ["~kind"]: "Promise" }, { type: "promise", item }, options);
514
+ }
515
+ function IsPromise(value) {
516
+ return IsKind(value, "Promise");
517
+ }
518
+ function PromiseOptions(type) {
519
+ return memory_exports.Discard(type, ["~kind", "type", "item"]);
520
+ }
521
+
522
+ // ../../node_modules/.pnpm/typebox@1.1.39/node_modules/typebox/build/type/types/_immutable.mjs
523
+ function ImmutableAdd(type) {
524
+ return memory_exports.Update(type, { "~immutable": true }, {});
525
+ }
526
+ function Immutable(type) {
527
+ return ImmutableAdd(type);
528
+ }
529
+ function IsImmutable(value) {
530
+ return IsSchema(value) && guard_exports.HasPropertyKey(value, "~immutable");
531
+ }
532
+
533
+ // ../../node_modules/.pnpm/typebox@1.1.39/node_modules/typebox/build/type/types/_optional.mjs
534
+ function OptionalRemove(type) {
535
+ const result = memory_exports.Discard(type, ["~optional"]);
536
+ return result;
537
+ }
538
+ function OptionalAdd(type) {
539
+ return memory_exports.Update(type, { "~optional": true }, {});
540
+ }
541
+ function Optional(type) {
542
+ return OptionalAdd(type);
543
+ }
544
+ function IsOptional(value) {
545
+ return IsSchema(value) && guard_exports.HasPropertyKey(value, "~optional");
546
+ }
547
+
548
+ // ../../node_modules/.pnpm/typebox@1.1.39/node_modules/typebox/build/type/types/_readonly.mjs
549
+ function ReadonlyRemove(type) {
550
+ return memory_exports.Discard(type, ["~readonly"]);
551
+ }
552
+ function ReadonlyAdd(type) {
553
+ return memory_exports.Update(type, { "~readonly": true }, {});
554
+ }
555
+ function Readonly(type) {
556
+ return ReadonlyAdd(type);
557
+ }
558
+ function IsReadonly(value) {
559
+ return IsSchema(value) && guard_exports.HasPropertyKey(value, "~readonly");
560
+ }
561
+
562
+ // ../../node_modules/.pnpm/typebox@1.1.39/node_modules/typebox/build/type/types/base.mjs
563
+ function BaseProperty(value) {
564
+ return {
565
+ enumerable: settings_exports.Get().enumerableKind,
566
+ writable: false,
567
+ configurable: false,
568
+ value
569
+ };
570
+ }
571
+ var Base = class {
572
+ constructor() {
573
+ globalThis.Object.defineProperty(this, "~kind", BaseProperty("Base"));
574
+ globalThis.Object.defineProperty(this, "~guard", BaseProperty({
575
+ check: (value) => this.Check(value),
576
+ errors: (value) => this.Errors(value)
577
+ }));
578
+ }
579
+ /** Checks a value or returns false if invalid */
580
+ Check(_value) {
581
+ return true;
582
+ }
583
+ /** Returns errors for a value. Return an empty array if valid. */
584
+ Errors(_value) {
585
+ return [];
586
+ }
587
+ /** Converts a value into this type */
588
+ Convert(value) {
589
+ return value;
590
+ }
591
+ /** Cleans a value according to this type */
592
+ Clean(value) {
593
+ return value;
594
+ }
595
+ /** Returns a default value for this type */
596
+ Default(value) {
597
+ return value;
598
+ }
599
+ /** Creates a new instance of this type */
600
+ Create() {
601
+ throw new Error("Create not implemented");
602
+ }
603
+ /** Clones this type */
604
+ Clone() {
605
+ throw Error("Clone not implemented");
606
+ }
607
+ };
608
+ function IsBase(value) {
609
+ return IsKind(value, "Base");
610
+ }
611
+
612
+ // ../../node_modules/.pnpm/typebox@1.1.39/node_modules/typebox/build/type/types/array.mjs
613
+ function _Array_(items, options) {
614
+ return memory_exports.Create({ "~kind": "Array" }, { type: "array", items }, options);
615
+ }
616
+ function IsArray2(value) {
617
+ return IsKind(value, "Array");
618
+ }
619
+ function ArrayOptions(type) {
620
+ return memory_exports.Discard(type, ["~kind", "type", "items"]);
621
+ }
622
+
623
+ // ../../node_modules/.pnpm/typebox@1.1.39/node_modules/typebox/build/type/types/async_iterator.mjs
624
+ function AsyncIterator(iteratorItems, options) {
625
+ return memory_exports.Create({ "~kind": "AsyncIterator" }, { type: "asyncIterator", iteratorItems }, options);
626
+ }
627
+ function IsAsyncIterator2(value) {
628
+ return IsKind(value, "AsyncIterator");
629
+ }
630
+ function AsyncIteratorOptions(type) {
631
+ return memory_exports.Discard(type, ["~kind", "type", "iteratorItems"]);
632
+ }
633
+
634
+ // ../../node_modules/.pnpm/typebox@1.1.39/node_modules/typebox/build/type/types/constructor.mjs
635
+ function Constructor(parameters, instanceType, options = {}) {
636
+ return memory_exports.Create({ "~kind": "Constructor" }, { type: "constructor", parameters, instanceType }, options);
637
+ }
638
+ function IsConstructor2(value) {
639
+ return IsKind(value, "Constructor");
640
+ }
641
+ function ConstructorOptions(type) {
642
+ return memory_exports.Discard(type, ["~kind", "type", "parameters", "instanceType"]);
643
+ }
644
+
645
+ // ../../node_modules/.pnpm/typebox@1.1.39/node_modules/typebox/build/type/types/function.mjs
646
+ function _Function_(parameters, returnType, options = {}) {
647
+ return memory_exports.Create({ ["~kind"]: "Function" }, { type: "function", parameters, returnType }, options);
648
+ }
649
+ function IsFunction2(value) {
650
+ return IsKind(value, "Function");
651
+ }
652
+ function FunctionOptions(type) {
653
+ return memory_exports.Discard(type, ["~kind", "type", "parameters", "returnType"]);
654
+ }
655
+
656
+ // ../../node_modules/.pnpm/typebox@1.1.39/node_modules/typebox/build/type/types/ref.mjs
657
+ function Ref(ref, options) {
658
+ return memory_exports.Create({ ["~kind"]: "Ref" }, { $ref: ref }, options);
659
+ }
660
+ function IsRef(value) {
661
+ return IsKind(value, "Ref");
662
+ }
663
+
664
+ // ../../node_modules/.pnpm/typebox@1.1.39/node_modules/typebox/build/type/types/generic.mjs
665
+ function Generic(parameters, expression) {
666
+ return memory_exports.Create({ "~kind": "Generic" }, { type: "generic", parameters, expression });
667
+ }
668
+ function IsGeneric(value) {
669
+ return IsKind(value, "Generic");
670
+ }
671
+
672
+ // ../../node_modules/.pnpm/typebox@1.1.39/node_modules/typebox/build/type/types/any.mjs
673
+ function Any(options) {
674
+ return memory_exports.Create({ ["~kind"]: "Any" }, {}, options);
675
+ }
676
+ function IsAny(value) {
677
+ return IsKind(value, "Any");
678
+ }
679
+
680
+ // ../../node_modules/.pnpm/typebox@1.1.39/node_modules/typebox/build/type/types/never.mjs
681
+ var NeverPattern = "(?!)";
682
+ function Never(options) {
683
+ return memory_exports.Create({ "~kind": "Never" }, { not: {} }, options);
684
+ }
685
+ function IsNever(value) {
686
+ return IsKind(value, "Never");
687
+ }
688
+
689
+ // ../../node_modules/.pnpm/typebox@1.1.39/node_modules/typebox/build/type/types/properties.mjs
690
+ function RequiredArray(properties) {
691
+ return guard_exports.Keys(properties).filter((key) => !IsOptional(properties[key]));
692
+ }
693
+ function PropertyKeys(properties) {
694
+ return guard_exports.Keys(properties);
695
+ }
696
+ function PropertyValues(properties) {
697
+ return guard_exports.Values(properties);
698
+ }
699
+
700
+ // ../../node_modules/.pnpm/typebox@1.1.39/node_modules/typebox/build/type/types/object.mjs
701
+ function _Object_(properties, options = {}) {
702
+ const requiredKeys = RequiredArray(properties);
703
+ const required = requiredKeys.length > 0 ? { required: requiredKeys } : {};
704
+ return memory_exports.Create({ "~kind": "Object" }, { type: "object", ...required, properties }, options);
705
+ }
706
+ function IsObject2(value) {
707
+ return IsKind(value, "Object");
708
+ }
709
+ function ObjectOptions(type) {
710
+ return memory_exports.Discard(type, ["~kind", "type", "properties", "required"]);
711
+ }
712
+
713
+ // ../../node_modules/.pnpm/typebox@1.1.39/node_modules/typebox/build/type/types/union.mjs
714
+ function Union(anyOf, options = {}) {
715
+ return memory_exports.Create({ "~kind": "Union" }, { anyOf }, options);
716
+ }
717
+ function IsUnion(value) {
718
+ return IsKind(value, "Union");
719
+ }
720
+ function UnionOptions(type) {
721
+ return memory_exports.Discard(type, ["~kind", "anyOf"]);
722
+ }
723
+
724
+ // ../../node_modules/.pnpm/typebox@1.1.39/node_modules/typebox/build/type/types/unknown.mjs
725
+ function Unknown(options) {
726
+ return memory_exports.Create({ ["~kind"]: "Unknown" }, {}, options);
727
+ }
728
+ function IsUnknown(value) {
729
+ return IsKind(value, "Unknown");
730
+ }
731
+
732
+ // ../../node_modules/.pnpm/typebox@1.1.39/node_modules/typebox/build/type/types/cyclic.mjs
733
+ function Cyclic($defs, $ref, options) {
734
+ const defs = guard_exports.Keys($defs).reduce((result, key) => {
735
+ return { ...result, [key]: memory_exports.Update($defs[key], {}, { $id: key }) };
736
+ }, {});
737
+ return memory_exports.Create({ ["~kind"]: "Cyclic" }, { $defs: defs, $ref }, options);
738
+ }
739
+ function IsCyclic(value) {
740
+ return IsKind(value, "Cyclic");
741
+ }
742
+
743
+ // ../../node_modules/.pnpm/typebox@1.1.39/node_modules/typebox/build/type/types/unsafe.mjs
744
+ function Unsafe(schema) {
745
+ return memory_exports.Update(schema, { ["~unsafe"]: null }, {});
746
+ }
747
+ function IsUnsafe(value) {
748
+ return guard_exports.IsObjectNotArray(value) && guard_exports.HasPropertyKey(value, "~unsafe") && guard_exports.IsNull(value["~unsafe"]);
749
+ }
750
+
751
+ // ../../node_modules/.pnpm/typebox@1.1.39/node_modules/typebox/build/system/arguments/arguments.mjs
752
+ var arguments_exports = {};
753
+ __export(arguments_exports, {
754
+ Match: () => Match
755
+ });
756
+ function Match(args, match) {
757
+ return match[args.length]?.(...args) ?? (() => {
758
+ throw Error("Invalid Arguments");
759
+ })();
760
+ }
761
+
762
+ // ../../node_modules/.pnpm/typebox@1.1.39/node_modules/typebox/build/type/types/infer.mjs
763
+ function Infer(...args) {
764
+ const [name, extends_] = arguments_exports.Match(args, {
765
+ 2: (name2, extends_2) => [name2, extends_2, extends_2],
766
+ 1: (name2) => [name2, Unknown(), Unknown()]
767
+ });
768
+ return memory_exports.Create({ ["~kind"]: "Infer" }, { type: "infer", name, extends: extends_ }, {});
769
+ }
770
+ function IsInfer(value) {
771
+ return IsKind(value, "Infer");
772
+ }
773
+
774
+ // ../../node_modules/.pnpm/typebox@1.1.39/node_modules/typebox/build/type/engine/enum/typescript_enum_to_enum_values.mjs
775
+ function IsTypeScriptEnumLike(value) {
776
+ return guard_exports.IsObjectNotArray(value);
777
+ }
778
+ function TypeScriptEnumToEnumValues(type) {
779
+ const keys = guard_exports.Keys(type).filter((key) => isNaN(key));
780
+ return keys.reduce((result, key) => [...result, type[key]], []);
781
+ }
782
+
783
+ // ../../node_modules/.pnpm/typebox@1.1.39/node_modules/typebox/build/type/types/enum.mjs
784
+ function Enum(value, options) {
785
+ const values = IsTypeScriptEnumLike(value) ? TypeScriptEnumToEnumValues(value) : value;
786
+ return memory_exports.Create({ "~kind": "Enum" }, { enum: values }, options);
787
+ }
788
+ function IsEnum(value) {
789
+ return IsKind(value, "Enum");
790
+ }
791
+
792
+ // ../../node_modules/.pnpm/typebox@1.1.39/node_modules/typebox/build/type/types/intersect.mjs
793
+ function Intersect(types, options = {}) {
794
+ return memory_exports.Create({ "~kind": "Intersect" }, { allOf: types }, options);
795
+ }
796
+ function IsIntersect(value) {
797
+ return IsKind(value, "Intersect");
798
+ }
799
+ function IntersectOptions(type) {
800
+ return memory_exports.Discard(type, ["~kind", "allOf"]);
801
+ }
802
+
803
+ // ../../node_modules/.pnpm/typebox@1.1.39/node_modules/typebox/build/system/unreachable/unreachable.mjs
804
+ function Unreachable() {
805
+ throw new Error("Unreachable");
806
+ }
807
+
808
+ // ../../node_modules/.pnpm/typebox@1.1.39/node_modules/typebox/build/system/hashing/hash.mjs
809
+ var ByteMarker;
810
+ (function(ByteMarker2) {
811
+ ByteMarker2[ByteMarker2["Array"] = 0] = "Array";
812
+ ByteMarker2[ByteMarker2["BigInt"] = 1] = "BigInt";
813
+ ByteMarker2[ByteMarker2["Boolean"] = 2] = "Boolean";
814
+ ByteMarker2[ByteMarker2["Date"] = 3] = "Date";
815
+ ByteMarker2[ByteMarker2["Constructor"] = 4] = "Constructor";
816
+ ByteMarker2[ByteMarker2["Function"] = 5] = "Function";
817
+ ByteMarker2[ByteMarker2["Null"] = 6] = "Null";
818
+ ByteMarker2[ByteMarker2["Number"] = 7] = "Number";
819
+ ByteMarker2[ByteMarker2["Object"] = 8] = "Object";
820
+ ByteMarker2[ByteMarker2["RegExp"] = 9] = "RegExp";
821
+ ByteMarker2[ByteMarker2["String"] = 10] = "String";
822
+ ByteMarker2[ByteMarker2["Symbol"] = 11] = "Symbol";
823
+ ByteMarker2[ByteMarker2["TypeArray"] = 12] = "TypeArray";
824
+ ByteMarker2[ByteMarker2["Undefined"] = 13] = "Undefined";
825
+ })(ByteMarker || (ByteMarker = {}));
826
+ var Accumulator = BigInt("14695981039346656037");
827
+ var [Prime, Size] = [BigInt("1099511628211"), BigInt(
828
+ "18446744073709551616"
829
+ /* 2 ^ 64 */
830
+ )];
831
+ var Bytes = Array.from({ length: 256 }).map((_, i) => BigInt(i));
832
+ var F64 = new Float64Array(1);
833
+ var F64In = new DataView(F64.buffer);
834
+ var F64Out = new Uint8Array(F64.buffer);
835
+ var encoder = new TextEncoder();
836
+
837
+ // ../../node_modules/.pnpm/typebox@1.1.39/node_modules/typebox/build/type/types/_codec.mjs
838
+ var EncodeBuilder = class {
839
+ constructor(type, decode) {
840
+ this.type = type;
841
+ this.decode = decode;
842
+ }
843
+ Encode(callback) {
844
+ const type = this.type;
845
+ const decode = IsCodec(type) ? (value) => this.decode(type["~codec"].decode(value)) : this.decode;
846
+ const encode = IsCodec(type) ? (value) => type["~codec"].encode(callback(value)) : callback;
847
+ const codec = { decode, encode };
848
+ return memory_exports.Update(this.type, { "~codec": codec }, {});
849
+ }
850
+ };
851
+ var DecodeBuilder = class {
852
+ constructor(type) {
853
+ this.type = type;
854
+ }
855
+ Decode(callback) {
856
+ return new EncodeBuilder(this.type, callback);
857
+ }
858
+ };
859
+ function Codec(type) {
860
+ return new DecodeBuilder(type);
861
+ }
862
+ function Decode(type, callback) {
863
+ return Codec(type).Decode(callback).Encode(() => {
864
+ throw Error("Encode not implemented");
865
+ });
866
+ }
867
+ function Encode(type, callback) {
868
+ return Codec(type).Decode(() => {
869
+ throw Error("Decode not implemented");
870
+ }).Encode(callback);
871
+ }
872
+ function IsCodec(value) {
873
+ return IsSchema(value) && guard_exports.HasPropertyKey(value, "~codec") && guard_exports.IsObject(value["~codec"]) && guard_exports.HasPropertyKey(value["~codec"], "encode") && guard_exports.HasPropertyKey(value["~codec"], "decode");
874
+ }
875
+
876
+ // ../../node_modules/.pnpm/typebox@1.1.39/node_modules/typebox/build/type/types/_refine.mjs
877
+ function RefineAdd(type, refinement) {
878
+ const refinements = IsRefine(type) ? [...type["~refine"], refinement] : [refinement];
879
+ return memory_exports.Update(type, { "~refine": refinements }, {});
880
+ }
881
+ function Refine(...args) {
882
+ const [type, check, error_or_message] = arguments_exports.Match(args, {
883
+ 3: (type2, check2, error2) => [type2, check2, error2],
884
+ 2: (type2, check2) => [type2, check2, () => "Refine Error"]
885
+ });
886
+ const error = guard_exports.IsString(error_or_message) ? () => error_or_message : error_or_message;
887
+ return RefineAdd(type, { check, error });
888
+ }
889
+ function IsRefinement(value) {
890
+ return guard_exports.IsObjectNotArray(value) && guard_exports.HasPropertyKey(value, "check") && guard_exports.HasPropertyKey(value, "error") && guard_exports.IsFunction(value.check) && guard_exports.IsFunction(value.error);
891
+ }
892
+ function IsRefine(value) {
893
+ return IsSchema(value) && guard_exports.HasPropertyKey(value, "~refine") && guard_exports.IsArray(value["~refine"]) && guard_exports.Every(value["~refine"], 0, (value2) => IsRefinement(value2));
894
+ }
895
+
896
+ // ../../node_modules/.pnpm/typebox@1.1.39/node_modules/typebox/build/type/types/bigint.mjs
897
+ var BigIntPattern = "-?(?:0|[1-9][0-9]*)n";
898
+ function BigInt2(options) {
899
+ return memory_exports.Create({ "~kind": "BigInt" }, { type: "bigint" }, options);
900
+ }
901
+ function IsBigInt2(value) {
902
+ return IsKind(value, "BigInt");
903
+ }
904
+
905
+ // ../../node_modules/.pnpm/typebox@1.1.39/node_modules/typebox/build/type/types/boolean.mjs
906
+ function Boolean2(options) {
907
+ return memory_exports.Create({ "~kind": "Boolean" }, { type: "boolean" }, options);
908
+ }
909
+ function IsBoolean2(value) {
910
+ return IsKind(value, "Boolean");
911
+ }
912
+
913
+ // ../../node_modules/.pnpm/typebox@1.1.39/node_modules/typebox/build/type/types/identifier.mjs
914
+ function Identifier(name) {
915
+ return memory_exports.Create({ "~kind": "Identifier" }, { name });
916
+ }
917
+ function IsIdentifier(value) {
918
+ return IsKind(value, "Identifier");
919
+ }
920
+
921
+ // ../../node_modules/.pnpm/typebox@1.1.39/node_modules/typebox/build/type/types/integer.mjs
922
+ var IntegerPattern = "-?(?:0|[1-9][0-9]*)";
923
+ function Integer(options) {
924
+ return memory_exports.Create({ "~kind": "Integer" }, { type: "integer" }, options);
925
+ }
926
+ function IsInteger2(value) {
927
+ return IsKind(value, "Integer");
928
+ }
929
+
930
+ // ../../node_modules/.pnpm/typebox@1.1.39/node_modules/typebox/build/type/types/iterator.mjs
931
+ function Iterator(iteratorItems, options) {
932
+ return memory_exports.Create({ "~kind": "Iterator" }, { type: "iterator", iteratorItems }, options);
933
+ }
934
+ function IsIterator2(value) {
935
+ return IsKind(value, "Iterator");
936
+ }
937
+ function IteratorOptions(type) {
938
+ return memory_exports.Discard(type, ["~kind", "type", "iteratorItems"]);
939
+ }
940
+
941
+ // ../../node_modules/.pnpm/typebox@1.1.39/node_modules/typebox/build/type/types/literal.mjs
942
+ var InvalidLiteralValue = class extends Error {
943
+ constructor(value) {
944
+ super(`Invalid Literal value`);
945
+ Object.defineProperty(this, "cause", {
946
+ value: { value },
947
+ writable: false,
948
+ configurable: false,
949
+ enumerable: false
950
+ });
951
+ }
952
+ };
953
+ function LiteralTypeName(value) {
954
+ return guard_exports.IsBigInt(value) ? "bigint" : guard_exports.IsBoolean(value) ? "boolean" : guard_exports.IsNumber(value) ? "number" : guard_exports.IsString(value) ? "string" : (() => {
955
+ throw new InvalidLiteralValue(value);
956
+ })();
957
+ }
958
+ function Literal(value, options) {
959
+ return memory_exports.Create({ "~kind": "Literal" }, { type: LiteralTypeName(value), const: value }, options);
960
+ }
961
+ function IsLiteralValue(value) {
962
+ return guard_exports.IsBigInt(value) || guard_exports.IsBoolean(value) || guard_exports.IsNumber(value) || guard_exports.IsString(value);
963
+ }
964
+ function IsLiteralNumber(value) {
965
+ return IsLiteral(value) && guard_exports.IsNumber(value.const);
966
+ }
967
+ function IsLiteralString(value) {
968
+ return IsLiteral(value) && guard_exports.IsString(value.const);
969
+ }
970
+ function IsLiteral(value) {
971
+ return IsKind(value, "Literal");
972
+ }
973
+
974
+ // ../../node_modules/.pnpm/typebox@1.1.39/node_modules/typebox/build/type/types/null.mjs
975
+ function Null(options) {
976
+ return memory_exports.Create({ "~kind": "Null" }, { type: "null" }, options);
977
+ }
978
+ function IsNull2(value) {
979
+ return IsKind(value, "Null");
980
+ }
981
+
982
+ // ../../node_modules/.pnpm/typebox@1.1.39/node_modules/typebox/build/type/types/number.mjs
983
+ var NumberPattern = "-?(?:0|[1-9][0-9]*)(?:.[0-9]+)?";
984
+ function Number2(options) {
985
+ return memory_exports.Create({ "~kind": "Number" }, { type: "number" }, options);
986
+ }
987
+ function IsNumber2(value) {
988
+ return IsKind(value, "Number");
989
+ }
990
+
991
+ // ../../node_modules/.pnpm/typebox@1.1.39/node_modules/typebox/build/type/types/symbol.mjs
992
+ function Symbol2(options) {
993
+ return memory_exports.Create({ "~kind": "Symbol" }, { type: "symbol" }, options);
994
+ }
995
+ function IsSymbol2(value) {
996
+ return IsKind(value, "Symbol");
997
+ }
998
+
999
+ // ../../node_modules/.pnpm/typebox@1.1.39/node_modules/typebox/build/type/types/parameter.mjs
1000
+ function Parameter(...args) {
1001
+ const [name, extends_, equals] = arguments_exports.Match(args, {
1002
+ 3: (name2, extends_2, equals2) => [name2, extends_2, equals2],
1003
+ 2: (name2, extends_2) => [name2, extends_2, extends_2],
1004
+ 1: (name2) => [name2, Unknown(), Unknown()]
1005
+ });
1006
+ return memory_exports.Create({ "~kind": "Parameter" }, { name, extends: extends_, equals }, {});
1007
+ }
1008
+ function IsParameter(value) {
1009
+ return IsKind(value, "Parameter");
1010
+ }
1011
+
1012
+ // ../../node_modules/.pnpm/typebox@1.1.39/node_modules/typebox/build/type/types/string.mjs
1013
+ var StringPattern = ".*";
1014
+ function String2(options) {
1015
+ return memory_exports.Create({ "~kind": "String" }, { type: "string" }, options);
1016
+ }
1017
+ function IsString2(value) {
1018
+ return IsKind(value, "String");
1019
+ }
1020
+
1021
+ // ../../node_modules/.pnpm/typebox@1.1.39/node_modules/typebox/build/type/engine/patterns/pattern.mjs
1022
+ function ParsePatternIntoTypes(pattern) {
1023
+ const parsed = Pattern(pattern);
1024
+ const result = guard_exports.IsEqual(parsed.length, 2) ? parsed[0] : [];
1025
+ return result;
1026
+ }
1027
+
1028
+ // ../../node_modules/.pnpm/typebox@1.1.39/node_modules/typebox/build/type/engine/template_literal/is_finite.mjs
1029
+ function FromLiteral(_value) {
1030
+ return true;
1031
+ }
1032
+ function FromTypesReduce(types) {
1033
+ return guard_exports.TakeLeft(types, (left, right) => FromType(left) ? FromTypesReduce(right) : false, () => true);
1034
+ }
1035
+ function FromTypes(types) {
1036
+ const result = guard_exports.IsEqual(types.length, 0) ? false : FromTypesReduce(types);
1037
+ return result;
1038
+ }
1039
+ function FromType(type) {
1040
+ return IsUnion(type) ? FromTypes(type.anyOf) : IsLiteral(type) ? FromLiteral(type.const) : false;
1041
+ }
1042
+ function IsTemplateLiteralFinite(types) {
1043
+ const result = FromTypes(types);
1044
+ return result;
1045
+ }
1046
+
1047
+ // ../../node_modules/.pnpm/typebox@1.1.39/node_modules/typebox/build/type/engine/template_literal/create.mjs
1048
+ function TemplateLiteralCreate(pattern) {
1049
+ return memory_exports.Create({ ["~kind"]: "TemplateLiteral" }, { type: "string", pattern }, {});
1050
+ }
1051
+
1052
+ // ../../node_modules/.pnpm/typebox@1.1.39/node_modules/typebox/build/type/engine/template_literal/decode.mjs
1053
+ function FromLiteralPush(variants, value, result = []) {
1054
+ return guard_exports.TakeLeft(variants, (left, right) => FromLiteralPush(right, value, [...result, `${left}${value}`]), () => result);
1055
+ }
1056
+ function FromLiteral2(variants, value) {
1057
+ return guard_exports.IsEqual(variants.length, 0) ? [`${value}`] : FromLiteralPush(variants, value);
1058
+ }
1059
+ function FromUnion(variants, types, result = []) {
1060
+ return guard_exports.TakeLeft(types, (left, right) => FromUnion(variants, right, [...result, ...FromType2(variants, left)]), () => result);
1061
+ }
1062
+ function FromType2(variants, type) {
1063
+ const result = IsUnion(type) ? FromUnion(variants, type.anyOf) : IsLiteral(type) ? FromLiteral2(variants, type.const) : Unreachable();
1064
+ return result;
1065
+ }
1066
+ function DecodeFromSpan(variants, types) {
1067
+ return guard_exports.TakeLeft(types, (left, right) => DecodeFromSpan(FromType2(variants, left), right), () => variants);
1068
+ }
1069
+ function VariantsToLiterals(variants) {
1070
+ return variants.map((variant) => Literal(variant));
1071
+ }
1072
+ function DecodeTypesAsUnion(types) {
1073
+ const variants = DecodeFromSpan([], types);
1074
+ const literals = VariantsToLiterals(variants);
1075
+ const result = Union(literals);
1076
+ return result;
1077
+ }
1078
+ function DecodeTypes(types) {
1079
+ return guard_exports.IsEqual(types.length, 0) ? Unreachable() : (
1080
+ // Literal('') :
1081
+ guard_exports.IsEqual(types.length, 1) && IsLiteral(types[0]) ? types[0] : DecodeTypesAsUnion(types)
1082
+ );
1083
+ }
1084
+ function TemplateLiteralDecodeUnsafe(pattern) {
1085
+ const types = ParsePatternIntoTypes(pattern);
1086
+ const result = guard_exports.IsEqual(types.length, 0) ? String2() : IsTemplateLiteralFinite(types) ? DecodeTypes(types) : TemplateLiteralCreate(pattern);
1087
+ return result;
1088
+ }
1089
+ function TemplateLiteralDecode(pattern) {
1090
+ const decoded = TemplateLiteralDecodeUnsafe(pattern);
1091
+ const result = IsTemplateLiteral(decoded) ? String2() : decoded;
1092
+ return result;
1093
+ }
1094
+
1095
+ // ../../node_modules/.pnpm/typebox@1.1.39/node_modules/typebox/build/type/engine/record/record_create.mjs
1096
+ function CreateRecord(key, value) {
1097
+ const type = "object";
1098
+ const patternProperties = { [key]: value };
1099
+ return memory_exports.Create({ ["~kind"]: "Record" }, { type, patternProperties });
1100
+ }
1101
+
1102
+ // ../../node_modules/.pnpm/typebox@1.1.39/node_modules/typebox/build/type/engine/record/from_key_any.mjs
1103
+ function FromAnyKey(value) {
1104
+ return CreateRecord(StringKey, value);
1105
+ }
1106
+
1107
+ // ../../node_modules/.pnpm/typebox@1.1.39/node_modules/typebox/build/type/engine/record/from_key_boolean.mjs
1108
+ function FromBooleanKey(value) {
1109
+ return _Object_({ true: value, false: value });
1110
+ }
1111
+
1112
+ // ../../node_modules/.pnpm/typebox@1.1.39/node_modules/typebox/build/type/engine/enum/enum_to_union.mjs
1113
+ function FromEnumValue(value) {
1114
+ return guard_exports.IsString(value) || guard_exports.IsNumber(value) ? Literal(value) : guard_exports.IsNull(value) ? Null() : Never();
1115
+ }
1116
+ function EnumValuesToVariants(values) {
1117
+ const result = values.map((value) => FromEnumValue(value));
1118
+ return result;
1119
+ }
1120
+ function EnumValuesToUnion(values) {
1121
+ const variants = EnumValuesToVariants(values);
1122
+ const result = Union(variants);
1123
+ return result;
1124
+ }
1125
+ function EnumToUnion(type) {
1126
+ const result = EnumValuesToUnion(type.enum);
1127
+ return result;
1128
+ }
1129
+
1130
+ // ../../node_modules/.pnpm/typebox@1.1.39/node_modules/typebox/build/type/engine/record/from_key_enum.mjs
1131
+ function FromEnumKey(values, value) {
1132
+ const unionKey = EnumValuesToUnion(values);
1133
+ const result = FromKey(unionKey, value);
1134
+ return result;
1135
+ }
1136
+
1137
+ // ../../node_modules/.pnpm/typebox@1.1.39/node_modules/typebox/build/type/engine/record/from_key_integer.mjs
1138
+ function FromIntegerKey(_key, value) {
1139
+ const result = CreateRecord(IntegerKey, value);
1140
+ return result;
1141
+ }
1142
+
1143
+ // ../../node_modules/.pnpm/typebox@1.1.39/node_modules/typebox/build/type/types/tuple.mjs
1144
+ function Tuple(types, options = {}) {
1145
+ const [items, minItems, additionalItems] = [types, types.length, false];
1146
+ return memory_exports.Create({ ["~kind"]: "Tuple" }, { type: "array", additionalItems, items, minItems }, options);
1147
+ }
1148
+ function IsTuple(value) {
1149
+ return IsKind(value, "Tuple");
1150
+ }
1151
+ function TupleOptions(type) {
1152
+ return memory_exports.Discard(type, ["~kind", "type", "items", "minItems", "additionalItems"]);
1153
+ }
1154
+
1155
+ // ../../node_modules/.pnpm/typebox@1.1.39/node_modules/typebox/build/type/engine/tuple/to_object.mjs
1156
+ function TupleElementsToProperties(types) {
1157
+ const result = types.reduceRight((result2, right, index) => {
1158
+ return { [index]: right, ...result2 };
1159
+ }, {});
1160
+ return result;
1161
+ }
1162
+ function TupleToObject(type) {
1163
+ const properties = TupleElementsToProperties(type.items);
1164
+ const result = _Object_(properties);
1165
+ return result;
1166
+ }
1167
+
1168
+ // ../../node_modules/.pnpm/typebox@1.1.39/node_modules/typebox/build/type/engine/evaluate/composite.mjs
1169
+ function IsReadonlyProperty(left, right) {
1170
+ return IsReadonly(left) ? IsReadonly(right) ? true : false : false;
1171
+ }
1172
+ function IsOptionalProperty(left, right) {
1173
+ return IsOptional(left) ? IsOptional(right) ? true : false : false;
1174
+ }
1175
+ function CompositeProperty(left, right) {
1176
+ const isReadonly = IsReadonlyProperty(left, right);
1177
+ const isOptional = IsOptionalProperty(left, right);
1178
+ const evaluated = EvaluateIntersect([left, right]);
1179
+ const property = ReadonlyRemove(OptionalRemove(evaluated));
1180
+ return isReadonly && isOptional ? ReadonlyAdd(OptionalAdd(property)) : isReadonly && !isOptional ? ReadonlyAdd(property) : !isReadonly && isOptional ? OptionalAdd(property) : property;
1181
+ }
1182
+ function CompositePropertyKey(left, right, key) {
1183
+ return key in left ? key in right ? CompositeProperty(left[key], right[key]) : left[key] : key in right ? right[key] : Never();
1184
+ }
1185
+ function CompositeProperties(left, right) {
1186
+ const keys = /* @__PURE__ */ new Set([...guard_exports.Keys(right), ...guard_exports.Keys(left)]);
1187
+ return [...keys].reduce((result, key) => {
1188
+ return { ...result, [key]: CompositePropertyKey(left, right, key) };
1189
+ }, {});
1190
+ }
1191
+ function GetProperties(type) {
1192
+ const result = IsObject2(type) ? type.properties : IsTuple(type) ? TupleElementsToProperties(type.items) : Unreachable();
1193
+ return result;
1194
+ }
1195
+ function Composite(left, right) {
1196
+ const leftProperties = GetProperties(left);
1197
+ const rightProperties = GetProperties(right);
1198
+ const properties = CompositeProperties(leftProperties, rightProperties);
1199
+ return _Object_(properties);
1200
+ }
1201
+
1202
+ // ../../node_modules/.pnpm/typebox@1.1.39/node_modules/typebox/build/type/engine/evaluate/narrow.mjs
1203
+ function Narrow(left, right) {
1204
+ const result = Compare(left, right);
1205
+ return guard_exports.IsEqual(result, ResultLeftInside) ? left : guard_exports.IsEqual(result, ResultRightInside) ? right : guard_exports.IsEqual(result, ResultEqual) ? right : Never();
1206
+ }
1207
+
1208
+ // ../../node_modules/.pnpm/typebox@1.1.39/node_modules/typebox/build/type/engine/evaluate/distribute.mjs
1209
+ function IsObjectLike(type) {
1210
+ return IsObject2(type) || IsTuple(type);
1211
+ }
1212
+ function IsUnionOperand(left, right) {
1213
+ const isUnionLeft = IsUnion(left);
1214
+ const isUnionRight = IsUnion(right);
1215
+ const result = isUnionLeft || isUnionRight;
1216
+ return result;
1217
+ }
1218
+ function DistributeOperation(left, right) {
1219
+ const evaluatedLeft = EvaluateType(left);
1220
+ const evaluatedRight = EvaluateType(right);
1221
+ const isUnionOperand = IsUnionOperand(evaluatedLeft, evaluatedRight);
1222
+ const isObjectLeft = IsObjectLike(evaluatedLeft);
1223
+ const IsObjectRight = IsObjectLike(evaluatedRight);
1224
+ const result = isUnionOperand ? EvaluateIntersect([evaluatedLeft, evaluatedRight]) : isObjectLeft && IsObjectRight ? Composite(evaluatedLeft, evaluatedRight) : isObjectLeft && !IsObjectRight ? evaluatedLeft : !isObjectLeft && IsObjectRight ? evaluatedRight : Narrow(evaluatedLeft, evaluatedRight);
1225
+ return result;
1226
+ }
1227
+ function DistributeType(type, types, result = []) {
1228
+ return guard_exports.TakeLeft(types, (left, right) => DistributeType(type, right, [...result, DistributeOperation(type, left)]), () => guard_exports.IsEqual(result.length, 0) ? [type] : result);
1229
+ }
1230
+ function DistributeUnion(types, distribution, result = []) {
1231
+ return guard_exports.TakeLeft(types, (left, right) => DistributeUnion(right, distribution, [...result, ...Distribute([left], distribution)]), () => result);
1232
+ }
1233
+ function Distribute(types, result = []) {
1234
+ return guard_exports.TakeLeft(types, (left, right) => IsUnion(left) ? Distribute(right, DistributeUnion(left.anyOf, result)) : Distribute(right, DistributeType(left, result)), () => result);
1235
+ }
1236
+
1237
+ // ../../node_modules/.pnpm/typebox@1.1.39/node_modules/typebox/build/type/engine/evaluate/evaluate.mjs
1238
+ function EvaluateIntersect(types) {
1239
+ const distribution = Distribute(types);
1240
+ const result = Broaden(distribution);
1241
+ return result;
1242
+ }
1243
+ function EvaluateUnion(types) {
1244
+ const result = Broaden(types);
1245
+ return result;
1246
+ }
1247
+ function EvaluateType(type) {
1248
+ return IsIntersect(type) ? EvaluateIntersect(type.allOf) : IsUnion(type) ? EvaluateUnion(type.anyOf) : type;
1249
+ }
1250
+ function EvaluateUnionFast(types) {
1251
+ const result = guard_exports.IsEqual(types.length, 1) ? types[0] : guard_exports.IsEqual(types.length, 0) ? Never() : Union(types);
1252
+ return result;
1253
+ }
1254
+
1255
+ // ../../node_modules/.pnpm/typebox@1.1.39/node_modules/typebox/build/type/engine/record/from_key_intersect.mjs
1256
+ function FromIntersectKey(types, value) {
1257
+ const evaluatedKey = EvaluateIntersect(types);
1258
+ const result = FromKey(evaluatedKey, value);
1259
+ return result;
1260
+ }
1261
+
1262
+ // ../../node_modules/.pnpm/typebox@1.1.39/node_modules/typebox/build/type/engine/record/from_key_literal.mjs
1263
+ function FromLiteralKey(key, value) {
1264
+ return guard_exports.IsString(key) || guard_exports.IsNumber(key) ? _Object_({ [key]: value }) : guard_exports.IsEqual(key, false) ? _Object_({ false: value }) : guard_exports.IsEqual(key, true) ? _Object_({ true: value }) : _Object_({});
1265
+ }
1266
+
1267
+ // ../../node_modules/.pnpm/typebox@1.1.39/node_modules/typebox/build/type/engine/record/from_key_number.mjs
1268
+ function FromNumberKey(_key, value) {
1269
+ const result = CreateRecord(NumberKey, value);
1270
+ return result;
1271
+ }
1272
+
1273
+ // ../../node_modules/.pnpm/typebox@1.1.39/node_modules/typebox/build/type/engine/record/from_key_string.mjs
1274
+ function FromStringKey(key, value) {
1275
+ return guard_exports.HasPropertyKey(key, "pattern") && (guard_exports.IsString(key.pattern) || key.pattern instanceof RegExp) ? CreateRecord(key.pattern.toString(), value) : CreateRecord(StringKey, value);
1276
+ }
1277
+
1278
+ // ../../node_modules/.pnpm/typebox@1.1.39/node_modules/typebox/build/type/engine/record/from_key_template_literal.mjs
1279
+ function FromTemplateKey(pattern, value) {
1280
+ const types = ParsePatternIntoTypes(pattern);
1281
+ const finite = IsTemplateLiteralFinite(types);
1282
+ const result = finite ? FromKey(TemplateLiteralDecode(pattern), value) : CreateRecord(pattern, value);
1283
+ return result;
1284
+ }
1285
+
1286
+ // ../../node_modules/.pnpm/typebox@1.1.39/node_modules/typebox/build/type/engine/evaluate/flatten.mjs
1287
+ function FlattenType(type) {
1288
+ const result = IsUnion(type) ? Flatten(type.anyOf) : [type];
1289
+ return result;
1290
+ }
1291
+ function Flatten(types) {
1292
+ return types.reduce((result, type) => {
1293
+ return [...result, ...FlattenType(type)];
1294
+ }, []);
1295
+ }
1296
+
1297
+ // ../../node_modules/.pnpm/typebox@1.1.39/node_modules/typebox/build/type/engine/record/from_key_union.mjs
1298
+ function StringOrNumberCheck(types) {
1299
+ return types.some((type) => IsString2(type) || IsNumber2(type) || IsInteger2(type));
1300
+ }
1301
+ function TryBuildRecord(types, value) {
1302
+ return guard_exports.IsEqual(StringOrNumberCheck(types), true) ? CreateRecord(StringKey, value) : void 0;
1303
+ }
1304
+ function CreateProperties(types, value) {
1305
+ return types.reduce((result, left) => {
1306
+ return IsLiteral(left) && (guard_exports.IsString(left.const) || guard_exports.IsNumber(left.const)) ? { ...result, [left.const]: value } : result;
1307
+ }, {});
1308
+ }
1309
+ function CreateObject(types, value) {
1310
+ const properties = CreateProperties(types, value);
1311
+ const result = _Object_(properties);
1312
+ return result;
1313
+ }
1314
+ function FromUnionKey(types, value) {
1315
+ const flattened = Flatten(types);
1316
+ const record = TryBuildRecord(flattened, value);
1317
+ return IsSchema(record) ? record : CreateObject(flattened, value);
1318
+ }
1319
+
1320
+ // ../../node_modules/.pnpm/typebox@1.1.39/node_modules/typebox/build/type/engine/record/from_key.mjs
1321
+ function FromKey(key, value) {
1322
+ const result = IsAny(key) ? FromAnyKey(value) : IsBoolean2(key) ? FromBooleanKey(value) : IsEnum(key) ? FromEnumKey(key.enum, value) : IsInteger2(key) ? FromIntegerKey(key, value) : IsIntersect(key) ? FromIntersectKey(key.allOf, value) : IsLiteral(key) ? FromLiteralKey(key.const, value) : IsNumber2(key) ? FromNumberKey(key, value) : IsUnion(key) ? FromUnionKey(key.anyOf, value) : IsString2(key) ? FromStringKey(key, value) : IsTemplateLiteral(key) ? FromTemplateKey(key.pattern, value) : _Object_({});
1323
+ return result;
1324
+ }
1325
+
1326
+ // ../../node_modules/.pnpm/typebox@1.1.39/node_modules/typebox/build/type/engine/record/instantiate.mjs
1327
+ function RecordAction(key, value, options) {
1328
+ const result = CanInstantiate([key]) ? memory_exports.Update(FromKey(key, value), {}, options) : RecordDeferred(key, value, options);
1329
+ return result;
1330
+ }
1331
+ function RecordInstantiate(context, state, key, value, options) {
1332
+ const instantiatedKey = InstantiateType(context, state, key);
1333
+ const instantiatedValue = InstantiateType(context, state, value);
1334
+ return RecordAction(instantiatedKey, instantiatedValue, options);
1335
+ }
1336
+
1337
+ // ../../node_modules/.pnpm/typebox@1.1.39/node_modules/typebox/build/type/types/record.mjs
1338
+ var IntegerKey = `^${IntegerPattern}$`;
1339
+ var NumberKey = `^${NumberPattern}$`;
1340
+ var StringKey = `^${StringPattern}$`;
1341
+ function RecordDeferred(key, value, options = {}) {
1342
+ return Deferred("Record", [key, value], options);
1343
+ }
1344
+ function Record(key, value, options = {}) {
1345
+ return RecordAction(key, value, options);
1346
+ }
1347
+ function RecordFromPattern(key, value) {
1348
+ return CreateRecord(key, value);
1349
+ }
1350
+ function RecordPattern(type) {
1351
+ return guard_exports.Keys(type.patternProperties)[0];
1352
+ }
1353
+ function RecordKey(type) {
1354
+ const pattern = RecordPattern(type);
1355
+ const result = guard_exports.IsEqual(pattern, StringKey) ? String2() : guard_exports.IsEqual(pattern, IntegerKey) ? Integer() : guard_exports.IsEqual(pattern, NumberKey) ? Number2() : TemplateLiteralDecodeUnsafe(pattern);
1356
+ return result;
1357
+ }
1358
+ function RecordValue(type) {
1359
+ return type.patternProperties[RecordPattern(type)];
1360
+ }
1361
+ function IsRecord(value) {
1362
+ return IsKind(value, "Record");
1363
+ }
1364
+
1365
+ // ../../node_modules/.pnpm/typebox@1.1.39/node_modules/typebox/build/type/types/rest.mjs
1366
+ function Rest(type) {
1367
+ return memory_exports.Create({ "~kind": "Rest" }, { type: "rest", items: type }, {});
1368
+ }
1369
+ function IsRest(value) {
1370
+ return IsKind(value, "Rest");
1371
+ }
1372
+
1373
+ // ../../node_modules/.pnpm/typebox@1.1.39/node_modules/typebox/build/type/types/this.mjs
1374
+ function This(options) {
1375
+ return memory_exports.Create({ ["~kind"]: "This" }, { $ref: "#" }, options);
1376
+ }
1377
+ function IsThis(value) {
1378
+ return IsKind(value, "This");
1379
+ }
1380
+
1381
+ // ../../node_modules/.pnpm/typebox@1.1.39/node_modules/typebox/build/type/types/undefined.mjs
1382
+ function Undefined(options) {
1383
+ return memory_exports.Create({ "~kind": "Undefined" }, { type: "undefined" }, options);
1384
+ }
1385
+ function IsUndefined2(value) {
1386
+ return IsKind(value, "Undefined");
1387
+ }
1388
+
1389
+ // ../../node_modules/.pnpm/typebox@1.1.39/node_modules/typebox/build/type/types/void.mjs
1390
+ function Void(options) {
1391
+ return memory_exports.Create({ "~kind": "Void" }, { type: "void" }, options);
1392
+ }
1393
+ function IsVoid(value) {
1394
+ return IsKind(value, "Void");
1395
+ }
1396
+
1397
+ // ../../node_modules/.pnpm/typebox@1.1.39/node_modules/typebox/build/type/script/mapping.mjs
1398
+ function IntrinsicOrCall(ref, parameters) {
1399
+ return guard_exports.IsEqual(ref, "Array") ? _Array_(parameters[0]) : guard_exports.IsEqual(ref, "AsyncIterator") ? AsyncIterator(parameters[0]) : guard_exports.IsEqual(ref, "Iterator") ? Iterator(parameters[0]) : guard_exports.IsEqual(ref, "Promise") ? _Promise_(parameters[0]) : guard_exports.IsEqual(ref, "Awaited") ? AwaitedDeferred(parameters[0]) : guard_exports.IsEqual(ref, "Capitalize") ? CapitalizeDeferred(parameters[0]) : guard_exports.IsEqual(ref, "ConstructorParameters") ? ConstructorParametersDeferred(parameters[0]) : guard_exports.IsEqual(ref, "Evaluate") ? EvaluateDeferred(parameters[0]) : guard_exports.IsEqual(ref, "Exclude") ? ExcludeDeferred(parameters[0], parameters[1]) : guard_exports.IsEqual(ref, "Extract") ? ExtractDeferred(parameters[0], parameters[1]) : guard_exports.IsEqual(ref, "Index") ? IndexDeferred(parameters[0], parameters[1]) : guard_exports.IsEqual(ref, "InstanceType") ? InstanceTypeDeferred(parameters[0]) : guard_exports.IsEqual(ref, "Lowercase") ? LowercaseDeferred(parameters[0]) : guard_exports.IsEqual(ref, "NonNullable") ? NonNullableDeferred(parameters[0]) : guard_exports.IsEqual(ref, "Omit") ? OmitDeferred(parameters[0], parameters[1]) : guard_exports.IsEqual(ref, "Options") ? OptionsDeferred(parameters[0], parameters[1]) : guard_exports.IsEqual(ref, "Parameters") ? ParametersDeferred(parameters[0]) : guard_exports.IsEqual(ref, "Partial") ? PartialDeferred(parameters[0]) : guard_exports.IsEqual(ref, "Pick") ? PickDeferred(parameters[0], parameters[1]) : guard_exports.IsEqual(ref, "Readonly") ? ReadonlyObjectDeferred(parameters[0]) : guard_exports.IsEqual(ref, "KeyOf") ? KeyOfDeferred(parameters[0]) : guard_exports.IsEqual(ref, "Record") ? RecordDeferred(parameters[0], parameters[1]) : guard_exports.IsEqual(ref, "Required") ? RequiredDeferred(parameters[0]) : guard_exports.IsEqual(ref, "ReturnType") ? ReturnTypeDeferred(parameters[0]) : guard_exports.IsEqual(ref, "Uncapitalize") ? UncapitalizeDeferred(parameters[0]) : guard_exports.IsEqual(ref, "Uppercase") ? UppercaseDeferred(parameters[0]) : CallConstruct(Ref(ref), parameters);
1400
+ }
1401
+ function Unreachable2() {
1402
+ throw Error("Unreachable");
1403
+ }
1404
+ var DelimitedDecode = (input, result = []) => {
1405
+ return input.reduce((result2, left) => {
1406
+ return guard_exports.IsArray(left) && guard_exports.IsEqual(left.length, 2) ? [...result2, left[0]] : [...result2, left];
1407
+ }, []);
1408
+ };
1409
+ var Delimited = (input) => {
1410
+ const [left, right] = input;
1411
+ return DelimitedDecode([...left, ...right]);
1412
+ };
1413
+ function GenericParameterExtendsEqualsMapping(input) {
1414
+ return Parameter(input[0], input[2], input[4]);
1415
+ }
1416
+ function GenericParameterExtendsMapping(input) {
1417
+ return Parameter(input[0], input[2], input[2]);
1418
+ }
1419
+ function GenericParameterEqualsMapping(input) {
1420
+ return Parameter(input[0], Unknown(), input[2]);
1421
+ }
1422
+ function GenericParameterIdentifierMapping(input) {
1423
+ return Parameter(input, Unknown(), Unknown());
1424
+ }
1425
+ function GenericParameterMapping(input) {
1426
+ return input;
1427
+ }
1428
+ function GenericParameterListMapping(input) {
1429
+ return Delimited(input);
1430
+ }
1431
+ function GenericParametersMapping(input) {
1432
+ return input[1];
1433
+ }
1434
+ function GenericCallArgumentListMapping(input) {
1435
+ return Delimited(input);
1436
+ }
1437
+ function GenericCallArgumentsMapping(input) {
1438
+ return input[1];
1439
+ }
1440
+ function GenericCallMapping(input) {
1441
+ return IntrinsicOrCall(input[0], input[1]);
1442
+ }
1443
+ function OptionalSemiColonMapping(input) {
1444
+ return null;
1445
+ }
1446
+ function KeywordStringMapping(input) {
1447
+ return String2();
1448
+ }
1449
+ function KeywordNumberMapping(input) {
1450
+ return Number2();
1451
+ }
1452
+ function KeywordBooleanMapping(input) {
1453
+ return Boolean2();
1454
+ }
1455
+ function KeywordUndefinedMapping(input) {
1456
+ return Undefined();
1457
+ }
1458
+ function KeywordNullMapping(input) {
1459
+ return Null();
1460
+ }
1461
+ function KeywordIntegerMapping(input) {
1462
+ return Integer();
1463
+ }
1464
+ function KeywordBigIntMapping(input) {
1465
+ return BigInt2();
1466
+ }
1467
+ function KeywordUnknownMapping(input) {
1468
+ return Unknown();
1469
+ }
1470
+ function KeywordAnyMapping(input) {
1471
+ return Any();
1472
+ }
1473
+ function KeywordObjectMapping(input) {
1474
+ return _Object_({});
1475
+ }
1476
+ function KeywordNeverMapping(input) {
1477
+ return Never();
1478
+ }
1479
+ function KeywordSymbolMapping(input) {
1480
+ return Symbol2();
1481
+ }
1482
+ function KeywordVoidMapping(input) {
1483
+ return Void();
1484
+ }
1485
+ function KeywordThisMapping(input) {
1486
+ return This();
1487
+ }
1488
+ function KeywordMapping(input) {
1489
+ return input;
1490
+ }
1491
+ function TemplateInterpolateMapping(input) {
1492
+ return input[1];
1493
+ }
1494
+ function TemplateSpanMapping(input) {
1495
+ return Literal(input);
1496
+ }
1497
+ function TemplateBodyMapping(input) {
1498
+ return guard_exports.IsEqual(input.length, 3) ? [input[0], input[1], ...input[2]] : [input[0]];
1499
+ }
1500
+ function TemplateLiteralTypesMapping(input) {
1501
+ return input[1];
1502
+ }
1503
+ function TemplateLiteralMapping(input) {
1504
+ return TemplateLiteralDeferred(input);
1505
+ }
1506
+ function LiteralBigIntMapping(input) {
1507
+ return Literal(BigInt(input));
1508
+ }
1509
+ function LiteralBooleanMapping(input) {
1510
+ return Literal(guard_exports.IsEqual(input, "true"));
1511
+ }
1512
+ function LiteralNumberMapping(input) {
1513
+ return Literal(parseFloat(input));
1514
+ }
1515
+ function LiteralStringMapping(input) {
1516
+ return Literal(input);
1517
+ }
1518
+ function LiteralMapping(input) {
1519
+ return input;
1520
+ }
1521
+ function KeyOfMapping(input) {
1522
+ return input.length > 0;
1523
+ }
1524
+ function IndexArrayMapping(input) {
1525
+ return input.reduce((result, current) => {
1526
+ return guard_exports.IsEqual(current.length, 3) ? [...result, [current[1]]] : [...result, []];
1527
+ }, []);
1528
+ }
1529
+ function ExtendsMapping(input) {
1530
+ return guard_exports.IsEqual(input.length, 6) ? [input[1], input[3], input[5]] : [];
1531
+ }
1532
+ function BaseMapping(input) {
1533
+ return guard_exports.IsArray(input) && guard_exports.IsEqual(input.length, 3) ? input[1] : input;
1534
+ }
1535
+ function WithMapping(input) {
1536
+ return guard_exports.IsEqual(input.length, 2) ? input[1] : [];
1537
+ }
1538
+ function FactorIndexArray(Type2, indexArray) {
1539
+ return indexArray.reduce((result, left) => {
1540
+ const _left = left;
1541
+ return guard_exports.IsEqual(_left.length, 1) ? IndexDeferred(result, _left[0]) : guard_exports.IsEqual(_left.length, 0) ? _Array_(result) : Unreachable2();
1542
+ }, Type2);
1543
+ }
1544
+ function FactorExtends(type, extend) {
1545
+ return guard_exports.IsEqual(extend.length, 3) ? ConditionalDeferred(type, extend[0], extend[1], extend[2]) : type;
1546
+ }
1547
+ function FactorWith(type, withClause) {
1548
+ return guard_exports.IsArray(withClause) && guard_exports.IsEqual(withClause.length, 0) ? type : OptionsDeferred(type, withClause);
1549
+ }
1550
+ function FactorMapping(input) {
1551
+ const [keyOf, type, indexArray, extend, withClause] = input;
1552
+ return FactorWith(keyOf ? FactorExtends(KeyOfDeferred(FactorIndexArray(type, indexArray)), extend) : FactorExtends(FactorIndexArray(type, indexArray), extend), withClause);
1553
+ }
1554
+ function ExprBinaryMapping(left, rest) {
1555
+ return guard_exports.IsEqual(rest.length, 3) ? (() => {
1556
+ const [operator, right, next] = rest;
1557
+ const Schema = ExprBinaryMapping(right, next);
1558
+ if (guard_exports.IsEqual(operator, "&")) {
1559
+ return IsIntersect(Schema) ? Intersect([left, ...Schema.allOf]) : Intersect([left, Schema]);
1560
+ }
1561
+ if (guard_exports.IsEqual(operator, "|")) {
1562
+ return IsUnion(Schema) ? Union([left, ...Schema.anyOf]) : Union([left, Schema]);
1563
+ }
1564
+ Unreachable2();
1565
+ })() : left;
1566
+ }
1567
+ function ExprTermTailMapping(input) {
1568
+ return input;
1569
+ }
1570
+ function ExprTermMapping(input) {
1571
+ const [left, rest] = input;
1572
+ return ExprBinaryMapping(left, rest);
1573
+ }
1574
+ function ExprTailMapping(input) {
1575
+ return input;
1576
+ }
1577
+ function ExprMapping(input) {
1578
+ const [left, rest] = input;
1579
+ return ExprBinaryMapping(left, rest);
1580
+ }
1581
+ function ExprReadonlyMapping(input) {
1582
+ return ImmutableAdd(input[1]);
1583
+ }
1584
+ function ExprPipeMapping(input) {
1585
+ return input[1];
1586
+ }
1587
+ function GenericTypeMapping(input) {
1588
+ return Generic(input[0], input[2]);
1589
+ }
1590
+ function InferTypeMapping(input) {
1591
+ return guard_exports.IsEqual(input.length, 4) ? Infer(input[1], input[3]) : guard_exports.IsEqual(input.length, 2) ? Infer(input[1], Unknown()) : Unreachable2();
1592
+ }
1593
+ function TypeMapping(input) {
1594
+ return input;
1595
+ }
1596
+ function PropertyKeyNumberMapping(input) {
1597
+ return `${input}`;
1598
+ }
1599
+ function PropertyKeyIdentMapping(input) {
1600
+ return input;
1601
+ }
1602
+ function PropertyKeyQuotedMapping(input) {
1603
+ return input;
1604
+ }
1605
+ function PropertyKeyIndexMapping(input) {
1606
+ return IsInteger2(input[3]) ? IntegerKey : IsNumber2(input[3]) ? NumberKey : IsSymbol2(input[3]) ? StringKey : IsString2(input[3]) ? StringKey : Unreachable2();
1607
+ }
1608
+ function PropertyKeyMapping(input) {
1609
+ return input;
1610
+ }
1611
+ function ReadonlyMapping(input) {
1612
+ return input.length > 0;
1613
+ }
1614
+ function OptionalMapping(input) {
1615
+ return input.length > 0;
1616
+ }
1617
+ function PropertyMapping(input) {
1618
+ const [isReadonly, key, isOptional, _colon, type] = input;
1619
+ return {
1620
+ [key]: isReadonly && isOptional ? ReadonlyAdd(OptionalAdd(type)) : isReadonly && !isOptional ? ReadonlyAdd(type) : !isReadonly && isOptional ? OptionalAdd(type) : type
1621
+ };
1622
+ }
1623
+ function PropertyDelimiterMapping(input) {
1624
+ return input;
1625
+ }
1626
+ function PropertyListMapping(input) {
1627
+ return Delimited(input);
1628
+ }
1629
+ function PropertiesReduce(propertyList) {
1630
+ return propertyList.reduce((result, left) => {
1631
+ const isPatternProperties = guard_exports.HasPropertyKey(left, IntegerKey) || guard_exports.HasPropertyKey(left, NumberKey) || guard_exports.HasPropertyKey(left, StringKey);
1632
+ return isPatternProperties ? [result[0], memory_exports.Assign(result[1], left)] : [memory_exports.Assign(result[0], left), result[1]];
1633
+ }, [{}, {}]);
1634
+ }
1635
+ function PropertiesMapping(input) {
1636
+ return PropertiesReduce(input[1]);
1637
+ }
1638
+ function _Object_Mapping(input) {
1639
+ const [properties, patternProperties] = input;
1640
+ const options = guard_exports.IsEqual(guard_exports.Keys(patternProperties).length, 0) ? {} : { patternProperties };
1641
+ return _Object_(properties, options);
1642
+ }
1643
+ function ElementNamedMapping(input) {
1644
+ return guard_exports.IsEqual(input.length, 5) ? ReadonlyAdd(OptionalAdd(input[4])) : guard_exports.IsEqual(input.length, 3) ? input[2] : guard_exports.IsEqual(input.length, 4) ? guard_exports.IsEqual(input[2], "readonly") ? ReadonlyAdd(input[3]) : OptionalAdd(input[3]) : Unreachable2();
1645
+ }
1646
+ function ElementReadonlyOptionalMapping(input) {
1647
+ return ReadonlyAdd(OptionalAdd(input[1]));
1648
+ }
1649
+ function ElementReadonlyMapping(input) {
1650
+ return ReadonlyAdd(input[1]);
1651
+ }
1652
+ function ElementOptionalMapping(input) {
1653
+ return OptionalAdd(input[0]);
1654
+ }
1655
+ function ElementBaseMapping(input) {
1656
+ return input;
1657
+ }
1658
+ function ElementMapping(input) {
1659
+ return guard_exports.IsEqual(input.length, 2) ? Rest(input[1]) : guard_exports.IsEqual(input.length, 1) ? input[0] : Unreachable2();
1660
+ }
1661
+ function ElementListMapping(input) {
1662
+ return Delimited(input);
1663
+ }
1664
+ function TupleMapping(input) {
1665
+ return Tuple(input[1]);
1666
+ }
1667
+ function ParameterReadonlyOptionalMapping(input) {
1668
+ return ReadonlyAdd(OptionalAdd(input[4]));
1669
+ }
1670
+ function ParameterReadonlyMapping(input) {
1671
+ return ReadonlyAdd(input[3]);
1672
+ }
1673
+ function ParameterOptionalMapping(input) {
1674
+ return OptionalAdd(input[3]);
1675
+ }
1676
+ function ParameterTypeMapping(input) {
1677
+ return input[2];
1678
+ }
1679
+ function ParameterBaseMapping(input) {
1680
+ return input;
1681
+ }
1682
+ function ParameterMapping(input) {
1683
+ return guard_exports.IsEqual(input.length, 2) ? Rest(input[1]) : guard_exports.IsEqual(input.length, 1) ? input[0] : Unreachable2();
1684
+ }
1685
+ function ParameterListMapping(input) {
1686
+ return Delimited(input);
1687
+ }
1688
+ function _Function_Mapping(input) {
1689
+ return _Function_(input[1], input[4]);
1690
+ }
1691
+ function ConstructorMapping(input) {
1692
+ return Constructor(input[2], input[5]);
1693
+ }
1694
+ function ApplyReadonly(state, type) {
1695
+ return guard_exports.IsEqual(state, "remove") ? ReadonlyRemoveAction(type) : guard_exports.IsEqual(state, "add") ? ReadonlyAddAction(type) : type;
1696
+ }
1697
+ function MappedReadonlyMapping(input) {
1698
+ return guard_exports.IsEqual(input.length, 2) && guard_exports.IsEqual(input[0], "-") ? "remove" : guard_exports.IsEqual(input.length, 2) && guard_exports.IsEqual(input[0], "+") ? "add" : guard_exports.IsEqual(input.length, 1) ? "add" : "none";
1699
+ }
1700
+ function ApplyOptional(state, type) {
1701
+ return guard_exports.IsEqual(state, "remove") ? OptionalRemoveAction(type) : guard_exports.IsEqual(state, "add") ? OptionalAddAction(type) : type;
1702
+ }
1703
+ function MappedOptionalMapping(input) {
1704
+ return guard_exports.IsEqual(input.length, 2) && guard_exports.IsEqual(input[0], "-") ? "remove" : guard_exports.IsEqual(input.length, 2) && guard_exports.IsEqual(input[0], "+") ? "add" : guard_exports.IsEqual(input.length, 1) ? "add" : "none";
1705
+ }
1706
+ function MappedAsMapping(input) {
1707
+ return guard_exports.IsEqual(input.length, 2) ? [input[1]] : [];
1708
+ }
1709
+ function MappedMapping(input) {
1710
+ return guard_exports.IsArray(input[6]) && guard_exports.IsEqual(input[6].length, 1) ? MappedDeferred(Identifier(input[3]), input[5], input[6][0], ApplyReadonly(input[1], ApplyOptional(input[8], input[10]))) : MappedDeferred(Identifier(input[3]), input[5], Ref(input[3]), ApplyReadonly(input[1], ApplyOptional(input[8], input[10])));
1711
+ }
1712
+ function ReferenceMapping(input) {
1713
+ return Ref(input);
1714
+ }
1715
+ function OptionsMapping(input) {
1716
+ return OptionsDeferred(input[2], input[4]);
1717
+ }
1718
+ function JsonNumberMapping(input) {
1719
+ return parseFloat(input);
1720
+ }
1721
+ function JsonBooleanMapping(input) {
1722
+ return guard_exports.IsEqual(input, "true");
1723
+ }
1724
+ function JsonStringMapping(input) {
1725
+ return input;
1726
+ }
1727
+ function JsonNullMapping(input) {
1728
+ return null;
1729
+ }
1730
+ function JsonPropertyMapping(input) {
1731
+ return { [input[0]]: input[2] };
1732
+ }
1733
+ function JsonPropertyListMapping(input) {
1734
+ return Delimited(input);
1735
+ }
1736
+ function JsonObjectMappingReduce(propertyList) {
1737
+ return propertyList.reduce((result, left) => {
1738
+ return memory_exports.Assign(result, left);
1739
+ }, {});
1740
+ }
1741
+ function JsonObjectMapping(input) {
1742
+ return JsonObjectMappingReduce(input[1]);
1743
+ }
1744
+ function JsonElementListMapping(input) {
1745
+ return Delimited(input);
1746
+ }
1747
+ function JsonArrayMapping(input) {
1748
+ return input[1];
1749
+ }
1750
+ function JsonMapping(input) {
1751
+ return input;
1752
+ }
1753
+ function PatternBigIntMapping(input) {
1754
+ return BigInt2();
1755
+ }
1756
+ function PatternStringMapping(input) {
1757
+ return String2();
1758
+ }
1759
+ function PatternNumberMapping(input) {
1760
+ return Number2();
1761
+ }
1762
+ function PatternIntegerMapping(input) {
1763
+ return Integer();
1764
+ }
1765
+ function PatternNeverMapping(input) {
1766
+ return Never();
1767
+ }
1768
+ function PatternTextMapping(input) {
1769
+ return Literal(input);
1770
+ }
1771
+ function PatternBaseMapping(input) {
1772
+ return input;
1773
+ }
1774
+ function PatternGroupMapping(input) {
1775
+ return Union(input[1]);
1776
+ }
1777
+ function PatternUnionMapping(input) {
1778
+ return input.length === 3 ? [...input[0], ...input[2]] : input.length === 1 ? [...input[0]] : [];
1779
+ }
1780
+ function PatternTermMapping(input) {
1781
+ return [input[0], ...input[1]];
1782
+ }
1783
+ function PatternBodyMapping(input) {
1784
+ return input;
1785
+ }
1786
+ function PatternMapping(input) {
1787
+ return input[1];
1788
+ }
1789
+ function InterfaceDeclarationHeritageListMapping(input) {
1790
+ return Delimited(input);
1791
+ }
1792
+ function InterfaceDeclarationHeritageMapping(input) {
1793
+ return guard_exports.IsEqual(input.length, 2) ? input[1] : [];
1794
+ }
1795
+ function InterfaceDeclarationGenericMapping(input) {
1796
+ const parameters = input[2];
1797
+ const heritage = input[3];
1798
+ const [properties, patternProperties] = input[4];
1799
+ const options = guard_exports.IsEqual(guard_exports.Keys(patternProperties).length, 0) ? {} : { patternProperties };
1800
+ return { [input[1]]: Generic(parameters, InterfaceDeferred(heritage, properties, options)) };
1801
+ }
1802
+ function InterfaceDeclarationMapping(input) {
1803
+ const heritage = input[2];
1804
+ const [properties, patternProperties] = input[3];
1805
+ const options = guard_exports.IsEqual(guard_exports.Keys(patternProperties).length, 0) ? {} : { patternProperties };
1806
+ return { [input[1]]: InterfaceDeferred(heritage, properties, options) };
1807
+ }
1808
+ function TypeAliasDeclarationGenericMapping(input) {
1809
+ return { [input[1]]: Generic(input[2], input[4]) };
1810
+ }
1811
+ function TypeAliasDeclarationMapping(input) {
1812
+ return { [input[1]]: input[3] };
1813
+ }
1814
+ function ExportKeywordMapping(input) {
1815
+ return null;
1816
+ }
1817
+ function ModuleDeclarationDelimiterMapping(input) {
1818
+ return input;
1819
+ }
1820
+ function ModuleDeclarationListMapping(input) {
1821
+ return PropertiesReduce(Delimited(input));
1822
+ }
1823
+ function ModuleDeclarationMapping(input) {
1824
+ return input[1];
1825
+ }
1826
+ function ModuleMapping(input) {
1827
+ const moduleDeclaration = input[0];
1828
+ const moduleDeclarationList = input[1];
1829
+ return ModuleDeferred(memory_exports.Assign(moduleDeclaration, moduleDeclarationList[0]));
1830
+ }
1831
+ function ScriptMapping(input) {
1832
+ return input;
1833
+ }
1834
+
1835
+ // ../../node_modules/.pnpm/typebox@1.1.39/node_modules/typebox/build/type/script/token/internal/match.mjs
1836
+ function IsMatch(value) {
1837
+ return IsEqual(value.length, 2);
1838
+ }
1839
+ function Match2(input, ok, fail) {
1840
+ return IsMatch(input) ? ok(input[0], input[1]) : fail();
1841
+ }
1842
+
1843
+ // ../../node_modules/.pnpm/typebox@1.1.39/node_modules/typebox/build/type/script/token/internal/take.mjs
1844
+ function TakeVariant(variant, input) {
1845
+ return IsEqual(input.indexOf(variant), 0) ? [variant, input.slice(variant.length)] : [];
1846
+ }
1847
+ function Take(variants, input) {
1848
+ for (let i = 0; i < variants.length; i++) {
1849
+ const result = TakeVariant(variants[i], input);
1850
+ if (IsMatch(result))
1851
+ return result;
1852
+ }
1853
+ return [];
1854
+ }
1855
+
1856
+ // ../../node_modules/.pnpm/typebox@1.1.39/node_modules/typebox/build/type/script/token/internal/char.mjs
1857
+ function Range(start, end) {
1858
+ return Array.from({ length: end - start + 1 }, (_, i) => String.fromCharCode(start + i));
1859
+ }
1860
+ var Alpha = [
1861
+ ...Range(97, 122),
1862
+ // Lowercase
1863
+ ...Range(65, 90)
1864
+ // Uppercase
1865
+ ];
1866
+ var Zero = "0";
1867
+ var NonZero = Range(49, 57);
1868
+ var Digit = [Zero, ...NonZero];
1869
+ var WhiteSpace = " ";
1870
+ var NewLine = "\n";
1871
+ var UnderScore = "_";
1872
+ var Dot = ".";
1873
+ var DollarSign = "$";
1874
+ var Hyphen = "-";
1875
+
1876
+ // ../../node_modules/.pnpm/typebox@1.1.39/node_modules/typebox/build/type/script/token/internal/trim.mjs
1877
+ var LineComment = "//";
1878
+ var OpenComment = "/*";
1879
+ var CloseComment = "*/";
1880
+ function DiscardMultilineComment(input) {
1881
+ const index = input.indexOf(CloseComment);
1882
+ const result = IsEqual(index, -1) ? "" : input.slice(index + 2);
1883
+ return result;
1884
+ }
1885
+ function DiscardLineComment(input) {
1886
+ const index = input.indexOf(NewLine);
1887
+ const result = IsEqual(index, -1) ? "" : input.slice(index);
1888
+ return result;
1889
+ }
1890
+ function TrimStartUntilNewline(input) {
1891
+ return input.replace(/^[ \t\r\f\v]+/, "");
1892
+ }
1893
+ function TrimWhitespace(input) {
1894
+ const trimmed = TrimStartUntilNewline(input);
1895
+ return trimmed.startsWith(OpenComment) ? TrimWhitespace(DiscardMultilineComment(trimmed.slice(2))) : trimmed.startsWith(LineComment) ? TrimWhitespace(DiscardLineComment(trimmed.slice(2))) : trimmed;
1896
+ }
1897
+ function Trim(input) {
1898
+ const trimmed = input.trimStart();
1899
+ return trimmed.startsWith(OpenComment) ? Trim(DiscardMultilineComment(trimmed.slice(2))) : trimmed.startsWith(LineComment) ? Trim(DiscardLineComment(trimmed.slice(2))) : trimmed;
1900
+ }
1901
+
1902
+ // ../../node_modules/.pnpm/typebox@1.1.39/node_modules/typebox/build/type/script/token/internal/optional.mjs
1903
+ function Optional2(value, input) {
1904
+ return Match2(Take([value], input), (Optional4, Rest2) => [Optional4, Rest2], () => ["", input]);
1905
+ }
1906
+
1907
+ // ../../node_modules/.pnpm/typebox@1.1.39/node_modules/typebox/build/type/script/token/internal/many.mjs
1908
+ function IsDiscard(discard, input) {
1909
+ return discard.includes(input);
1910
+ }
1911
+ function Many(allowed, discard, input, result = "") {
1912
+ return Match2(Take(allowed, input), (Char, Rest2) => IsDiscard(discard, Char) ? Many(allowed, discard, Rest2, result) : Many(allowed, discard, Rest2, `${result}${Char}`), () => [result, input]);
1913
+ }
1914
+
1915
+ // ../../node_modules/.pnpm/typebox@1.1.39/node_modules/typebox/build/type/script/token/unsigned_integer.mjs
1916
+ function TakeNonZero(input) {
1917
+ return Take(NonZero, input);
1918
+ }
1919
+ var AllowedDigits = [...Digit, UnderScore];
1920
+ function TakeDigits(input) {
1921
+ return Many(AllowedDigits, [UnderScore], input);
1922
+ }
1923
+ function TakeUnsignedInteger(input) {
1924
+ return Match2(Take([Zero], input), (Zero2, ZeroRest) => [Zero2, ZeroRest], () => Match2(
1925
+ TakeNonZero(input),
1926
+ (NonZero2, NonZeroRest) => Match2(TakeDigits(NonZeroRest), (Digits, DigitsRest) => [`${NonZero2}${Digits}`, DigitsRest], () => []),
1927
+ // fail: did not match Digits
1928
+ () => []
1929
+ ));
1930
+ }
1931
+ function UnsignedInteger(input) {
1932
+ return TakeUnsignedInteger(Trim(input));
1933
+ }
1934
+
1935
+ // ../../node_modules/.pnpm/typebox@1.1.39/node_modules/typebox/build/type/script/token/integer.mjs
1936
+ function TakeSign(input) {
1937
+ return Optional2(Hyphen, input);
1938
+ }
1939
+ function TakeSignedInteger(input) {
1940
+ return Match2(
1941
+ TakeSign(input),
1942
+ (Sign, SignRest) => Match2(UnsignedInteger(SignRest), (UnsignedInteger2, UnsignedIntegerRest) => [`${Sign}${UnsignedInteger2}`, UnsignedIntegerRest], () => []),
1943
+ // fail: did not match unsigned integer
1944
+ () => []
1945
+ );
1946
+ }
1947
+ function Integer2(input) {
1948
+ return TakeSignedInteger(Trim(input));
1949
+ }
1950
+
1951
+ // ../../node_modules/.pnpm/typebox@1.1.39/node_modules/typebox/build/type/script/token/bigint.mjs
1952
+ function TakeBigInt(input) {
1953
+ return Match2(
1954
+ Integer2(input),
1955
+ (Integer3, IntegerRest) => Match2(Take(["n"], IntegerRest), (_N, NRest) => [`${Integer3}`, NRest], () => []),
1956
+ // fail: did not match 'n'
1957
+ () => []
1958
+ );
1959
+ }
1960
+ function BigInt3(input) {
1961
+ return TakeBigInt(input);
1962
+ }
1963
+
1964
+ // ../../node_modules/.pnpm/typebox@1.1.39/node_modules/typebox/build/type/script/token/const.mjs
1965
+ function TakeConst(const_, input) {
1966
+ return Take([const_], input);
1967
+ }
1968
+ function Const(const_, input) {
1969
+ return IsEqual(const_, "") ? ["", input] : const_.startsWith(NewLine) ? TakeConst(const_, TrimWhitespace(input)) : const_.startsWith(WhiteSpace) ? TakeConst(const_, input) : TakeConst(const_, Trim(input));
1970
+ }
1971
+
1972
+ // ../../node_modules/.pnpm/typebox@1.1.39/node_modules/typebox/build/type/script/token/ident.mjs
1973
+ var Initial = [...Alpha, UnderScore, DollarSign];
1974
+ function TakeInitial(input) {
1975
+ return Take(Initial, input);
1976
+ }
1977
+ var Remaining = [...Initial, ...Digit];
1978
+ function TakeRemaining(input, result = "") {
1979
+ return Match2(Take(Remaining, input), (Remaining2, RemainingRest) => TakeRemaining(RemainingRest, `${result}${Remaining2}`), () => [result, input]);
1980
+ }
1981
+ function TakeIdent(input) {
1982
+ return Match2(
1983
+ TakeInitial(input),
1984
+ (Initial2, InitialRest) => Match2(TakeRemaining(InitialRest), (Remaining2, RemainingRest) => [`${Initial2}${Remaining2}`, RemainingRest], () => []),
1985
+ // fail: did not match Remaining
1986
+ () => []
1987
+ );
1988
+ }
1989
+ function Ident(input) {
1990
+ return TakeIdent(Trim(input));
1991
+ }
1992
+
1993
+ // ../../node_modules/.pnpm/typebox@1.1.39/node_modules/typebox/build/type/script/token/unsigned_number.mjs
1994
+ var AllowedDigits2 = [...Digit, UnderScore];
1995
+ function IsLeadingDot(input) {
1996
+ return IsMatch(Take([Dot], input));
1997
+ }
1998
+ function TakeFractional(input) {
1999
+ return Match2(Many(AllowedDigits2, [UnderScore], input), (Digits, DigitsRest) => IsEqual(Digits, "") ? [] : [Digits, DigitsRest], () => []);
2000
+ }
2001
+ function LeadingDot(input) {
2002
+ return Match2(
2003
+ Take([Dot], input),
2004
+ (Dot2, DotRest) => Match2(TakeFractional(DotRest), (Fractional, FractionalRest) => [`0${Dot2}${Fractional}`, FractionalRest], () => []),
2005
+ // fail: did not match Fractional
2006
+ () => []
2007
+ );
2008
+ }
2009
+ function LeadingInteger(input) {
2010
+ return Match2(
2011
+ UnsignedInteger(input),
2012
+ (Integer3, IntegerRest) => Match2(
2013
+ Take([Dot], IntegerRest),
2014
+ (Dot2, DotRest) => Match2(TakeFractional(DotRest), (Fractional, FractionalRest) => [`${Integer3}${Dot2}${Fractional}`, FractionalRest], () => [`${Integer3}`, DotRest]),
2015
+ // fail: did not match Fractional, use Integer
2016
+ () => [`${Integer3}`, IntegerRest]
2017
+ ),
2018
+ // fail: did not match Dot, use Integer
2019
+ () => []
2020
+ );
2021
+ }
2022
+ function TakeUnsignedNumber(input) {
2023
+ return IsLeadingDot(input) ? LeadingDot(input) : LeadingInteger(input);
2024
+ }
2025
+ function UnsignedNumber(input) {
2026
+ return TakeUnsignedNumber(Trim(input));
2027
+ }
2028
+
2029
+ // ../../node_modules/.pnpm/typebox@1.1.39/node_modules/typebox/build/type/script/token/number.mjs
2030
+ function TakeSign2(input) {
2031
+ return Optional2(Hyphen, input);
2032
+ }
2033
+ function TakeSignedNumber(input) {
2034
+ return Match2(
2035
+ TakeSign2(input),
2036
+ (Sign, SignRest) => Match2(UnsignedNumber(SignRest), (UnsignedInteger2, UnsignedIntegerRest) => [`${Sign}${UnsignedInteger2}`, UnsignedIntegerRest], () => []),
2037
+ // fail: did not match unsigned integer
2038
+ () => []
2039
+ );
2040
+ }
2041
+ function Number3(input) {
2042
+ return TakeSignedNumber(Trim(input));
2043
+ }
2044
+
2045
+ // ../../node_modules/.pnpm/typebox@1.1.39/node_modules/typebox/build/type/script/token/until.mjs
2046
+ function TakeOne(input) {
2047
+ const result = IsEqual(input, "") ? [] : [input.slice(0, 1), input.slice(1)];
2048
+ return result;
2049
+ }
2050
+ function IsInputMatchSentinal(end, input) {
2051
+ return TakeLeft(end, (left, right) => input.startsWith(left) ? true : IsInputMatchSentinal(right, input), () => false);
2052
+ }
2053
+ function Until(end, input, result = "") {
2054
+ return Match2(
2055
+ TakeOne(input),
2056
+ (One, Rest2) => IsInputMatchSentinal(end, input) ? [result, input] : Until(end, Rest2, `${result}${One}`),
2057
+ () => []
2058
+ );
2059
+ }
2060
+
2061
+ // ../../node_modules/.pnpm/typebox@1.1.39/node_modules/typebox/build/type/script/token/span.mjs
2062
+ function MultiLine(start, end, input) {
2063
+ return Match2(
2064
+ Take([start], input),
2065
+ (_, Rest2) => Match2(
2066
+ Until([end], Rest2),
2067
+ (Until2, UntilRest) => Match2(Take([end], UntilRest), (_2, Rest3) => [`${Until2}`, Rest3], () => []),
2068
+ // fail: did not match End
2069
+ () => []
2070
+ ),
2071
+ // fail: did not match Until
2072
+ () => []
2073
+ );
2074
+ }
2075
+ function SingleLine(start, end, input) {
2076
+ return Match2(
2077
+ Take([start], input),
2078
+ (_, Rest2) => Match2(
2079
+ Until([NewLine, end], Rest2),
2080
+ (Until2, UntilRest) => Match2(Take([end], UntilRest), (_2, EndRest) => [`${Until2}`, EndRest], () => []),
2081
+ // fail: did not match End
2082
+ () => []
2083
+ ),
2084
+ // fail: did not match Until
2085
+ () => []
2086
+ );
2087
+ }
2088
+ function Span(start, end, multiLine, input) {
2089
+ return multiLine ? MultiLine(start, end, Trim(input)) : SingleLine(start, end, Trim(input));
2090
+ }
2091
+
2092
+ // ../../node_modules/.pnpm/typebox@1.1.39/node_modules/typebox/build/type/script/token/string.mjs
2093
+ function TakeInitial2(quotes, input) {
2094
+ return Take(quotes, input);
2095
+ }
2096
+ function TakeSpan(quote, input) {
2097
+ return Span(quote, quote, false, input);
2098
+ }
2099
+ function TakeString(quotes, input) {
2100
+ return Match2(TakeInitial2(quotes, input), (Initial2, InitialRest) => TakeSpan(Initial2, `${Initial2}${InitialRest}`), () => []);
2101
+ }
2102
+ function String3(quotes, input) {
2103
+ return TakeString(quotes, Trim(input));
2104
+ }
2105
+
2106
+ // ../../node_modules/.pnpm/typebox@1.1.39/node_modules/typebox/build/type/script/token/until_1.mjs
2107
+ function Until_1(end, input) {
2108
+ return Match2(Until(end, input), (Until2, UntilRest) => IsEqual(Until2, "") ? [] : [Until2, UntilRest], () => []);
2109
+ }
2110
+
2111
+ // ../../node_modules/.pnpm/typebox@1.1.39/node_modules/typebox/build/type/script/parser.mjs
2112
+ var If = (result, left, right = () => []) => result.length === 2 ? left(result) : right();
2113
+ var GenericParameterExtendsEquals = (input) => If(If(Ident(input), ([_0, input2]) => If(Const("extends", input2), ([_1, input3]) => If(Type(input3), ([_2, input4]) => If(Const("=", input4), ([_3, input5]) => If(Type(input5), ([_4, input6]) => [[_0, _1, _2, _3, _4], input6]))))), ([_0, input2]) => [GenericParameterExtendsEqualsMapping(_0), input2]);
2114
+ var GenericParameterExtends = (input) => If(If(Ident(input), ([_0, input2]) => If(Const("extends", input2), ([_1, input3]) => If(Type(input3), ([_2, input4]) => [[_0, _1, _2], input4]))), ([_0, input2]) => [GenericParameterExtendsMapping(_0), input2]);
2115
+ var GenericParameterEquals = (input) => If(If(Ident(input), ([_0, input2]) => If(Const("=", input2), ([_1, input3]) => If(Type(input3), ([_2, input4]) => [[_0, _1, _2], input4]))), ([_0, input2]) => [GenericParameterEqualsMapping(_0), input2]);
2116
+ var GenericParameterIdentifier = (input) => If(Ident(input), ([_0, input2]) => [GenericParameterIdentifierMapping(_0), input2]);
2117
+ var GenericParameter = (input) => If(If(GenericParameterExtendsEquals(input), ([_0, input2]) => [_0, input2], () => If(GenericParameterExtends(input), ([_0, input2]) => [_0, input2], () => If(GenericParameterEquals(input), ([_0, input2]) => [_0, input2], () => If(GenericParameterIdentifier(input), ([_0, input2]) => [_0, input2], () => [])))), ([_0, input2]) => [GenericParameterMapping(_0), input2]);
2118
+ var GenericParameterList_0 = (input, result = []) => If(If(GenericParameter(input), ([_0, input2]) => If(Const(",", input2), ([_1, input3]) => [[_0, _1], input3])), ([_0, input2]) => GenericParameterList_0(input2, [...result, _0]), () => [result, input]);
2119
+ var GenericParameterList = (input) => If(If(GenericParameterList_0(input), ([_0, input2]) => If(If(If(GenericParameter(input2), ([_02, input3]) => [[_02], input3]), ([_02, input3]) => [_02, input3], () => If([[], input2], ([_02, input3]) => [_02, input3], () => [])), ([_1, input3]) => [[_0, _1], input3])), ([_0, input2]) => [GenericParameterListMapping(_0), input2]);
2120
+ var GenericParameters = (input) => If(If(Const("<", input), ([_0, input2]) => If(GenericParameterList(input2), ([_1, input3]) => If(Const(">", input3), ([_2, input4]) => [[_0, _1, _2], input4]))), ([_0, input2]) => [GenericParametersMapping(_0), input2]);
2121
+ var GenericCallArgumentList_0 = (input, result = []) => If(If(Type(input), ([_0, input2]) => If(Const(",", input2), ([_1, input3]) => [[_0, _1], input3])), ([_0, input2]) => GenericCallArgumentList_0(input2, [...result, _0]), () => [result, input]);
2122
+ var GenericCallArgumentList = (input) => If(If(GenericCallArgumentList_0(input), ([_0, input2]) => If(If(If(Type(input2), ([_02, input3]) => [[_02], input3]), ([_02, input3]) => [_02, input3], () => If([[], input2], ([_02, input3]) => [_02, input3], () => [])), ([_1, input3]) => [[_0, _1], input3])), ([_0, input2]) => [GenericCallArgumentListMapping(_0), input2]);
2123
+ var GenericCallArguments = (input) => If(If(Const("<", input), ([_0, input2]) => If(GenericCallArgumentList(input2), ([_1, input3]) => If(Const(">", input3), ([_2, input4]) => [[_0, _1, _2], input4]))), ([_0, input2]) => [GenericCallArgumentsMapping(_0), input2]);
2124
+ var GenericCall = (input) => If(If(Ident(input), ([_0, input2]) => If(GenericCallArguments(input2), ([_1, input3]) => [[_0, _1], input3])), ([_0, input2]) => [GenericCallMapping(_0), input2]);
2125
+ var OptionalSemiColon = (input) => If(If(If(Const(";", input), ([_0, input2]) => [[_0], input2]), ([_0, input2]) => [_0, input2], () => If([[], input], ([_0, input2]) => [_0, input2], () => [])), ([_0, input2]) => [OptionalSemiColonMapping(_0), input2]);
2126
+ var KeywordString = (input) => If(Const("string", input), ([_0, input2]) => [KeywordStringMapping(_0), input2]);
2127
+ var KeywordNumber = (input) => If(Const("number", input), ([_0, input2]) => [KeywordNumberMapping(_0), input2]);
2128
+ var KeywordBoolean = (input) => If(Const("boolean", input), ([_0, input2]) => [KeywordBooleanMapping(_0), input2]);
2129
+ var KeywordUndefined = (input) => If(Const("undefined", input), ([_0, input2]) => [KeywordUndefinedMapping(_0), input2]);
2130
+ var KeywordNull = (input) => If(Const("null", input), ([_0, input2]) => [KeywordNullMapping(_0), input2]);
2131
+ var KeywordInteger = (input) => If(Const("integer", input), ([_0, input2]) => [KeywordIntegerMapping(_0), input2]);
2132
+ var KeywordBigInt = (input) => If(Const("bigint", input), ([_0, input2]) => [KeywordBigIntMapping(_0), input2]);
2133
+ var KeywordUnknown = (input) => If(Const("unknown", input), ([_0, input2]) => [KeywordUnknownMapping(_0), input2]);
2134
+ var KeywordAny = (input) => If(Const("any", input), ([_0, input2]) => [KeywordAnyMapping(_0), input2]);
2135
+ var KeywordObject = (input) => If(Const("object", input), ([_0, input2]) => [KeywordObjectMapping(_0), input2]);
2136
+ var KeywordNever = (input) => If(Const("never", input), ([_0, input2]) => [KeywordNeverMapping(_0), input2]);
2137
+ var KeywordSymbol = (input) => If(Const("symbol", input), ([_0, input2]) => [KeywordSymbolMapping(_0), input2]);
2138
+ var KeywordVoid = (input) => If(Const("void", input), ([_0, input2]) => [KeywordVoidMapping(_0), input2]);
2139
+ var KeywordThis = (input) => If(Const("this", input), ([_0, input2]) => [KeywordThisMapping(_0), input2]);
2140
+ var Keyword = (input) => If(If(KeywordString(input), ([_0, input2]) => [_0, input2], () => If(KeywordNumber(input), ([_0, input2]) => [_0, input2], () => If(KeywordBoolean(input), ([_0, input2]) => [_0, input2], () => If(KeywordUndefined(input), ([_0, input2]) => [_0, input2], () => If(KeywordNull(input), ([_0, input2]) => [_0, input2], () => If(KeywordInteger(input), ([_0, input2]) => [_0, input2], () => If(KeywordBigInt(input), ([_0, input2]) => [_0, input2], () => If(KeywordUnknown(input), ([_0, input2]) => [_0, input2], () => If(KeywordAny(input), ([_0, input2]) => [_0, input2], () => If(KeywordObject(input), ([_0, input2]) => [_0, input2], () => If(KeywordNever(input), ([_0, input2]) => [_0, input2], () => If(KeywordSymbol(input), ([_0, input2]) => [_0, input2], () => If(KeywordVoid(input), ([_0, input2]) => [_0, input2], () => If(KeywordThis(input), ([_0, input2]) => [_0, input2], () => [])))))))))))))), ([_0, input2]) => [KeywordMapping(_0), input2]);
2141
+ var TemplateInterpolate = (input) => If(If(Const("${", input), ([_0, input2]) => If(Type(input2), ([_1, input3]) => If(Const("}", input3), ([_2, input4]) => [[_0, _1, _2], input4]))), ([_0, input2]) => [TemplateInterpolateMapping(_0), input2]);
2142
+ var TemplateSpan = (input) => If(Until(["${", "`"], input), ([_0, input2]) => [TemplateSpanMapping(_0), input2]);
2143
+ var TemplateBody = (input) => If(If(If(TemplateSpan(input), ([_0, input2]) => If(TemplateInterpolate(input2), ([_1, input3]) => If(TemplateBody(input3), ([_2, input4]) => [[_0, _1, _2], input4]))), ([_0, input2]) => [_0, input2], () => If(If(TemplateSpan(input), ([_0, input2]) => [[_0], input2]), ([_0, input2]) => [_0, input2], () => If(If(TemplateSpan(input), ([_0, input2]) => [[_0], input2]), ([_0, input2]) => [_0, input2], () => []))), ([_0, input2]) => [TemplateBodyMapping(_0), input2]);
2144
+ var TemplateLiteralTypes = (input) => If(If(Const("`", input), ([_0, input2]) => If(TemplateBody(input2), ([_1, input3]) => If(Const("`", input3), ([_2, input4]) => [[_0, _1, _2], input4]))), ([_0, input2]) => [TemplateLiteralTypesMapping(_0), input2]);
2145
+ var TemplateLiteral = (input) => If(TemplateLiteralTypes(input), ([_0, input2]) => [TemplateLiteralMapping(_0), input2]);
2146
+ var LiteralBigInt = (input) => If(BigInt3(input), ([_0, input2]) => [LiteralBigIntMapping(_0), input2]);
2147
+ var LiteralBoolean = (input) => If(If(Const("true", input), ([_0, input2]) => [_0, input2], () => If(Const("false", input), ([_0, input2]) => [_0, input2], () => [])), ([_0, input2]) => [LiteralBooleanMapping(_0), input2]);
2148
+ var LiteralNumber = (input) => If(Number3(input), ([_0, input2]) => [LiteralNumberMapping(_0), input2]);
2149
+ var LiteralString = (input) => If(String3(["'", '"'], input), ([_0, input2]) => [LiteralStringMapping(_0), input2]);
2150
+ var Literal2 = (input) => If(If(LiteralBigInt(input), ([_0, input2]) => [_0, input2], () => If(LiteralBoolean(input), ([_0, input2]) => [_0, input2], () => If(LiteralNumber(input), ([_0, input2]) => [_0, input2], () => If(LiteralString(input), ([_0, input2]) => [_0, input2], () => [])))), ([_0, input2]) => [LiteralMapping(_0), input2]);
2151
+ var KeyOf = (input) => If(If(If(Const("keyof", input), ([_0, input2]) => [[_0], input2]), ([_0, input2]) => [_0, input2], () => If([[], input], ([_0, input2]) => [_0, input2], () => [])), ([_0, input2]) => [KeyOfMapping(_0), input2]);
2152
+ var IndexArray_0 = (input, result = []) => If(If(If(Const("[", input), ([_0, input2]) => If(Type(input2), ([_1, input3]) => If(Const("]", input3), ([_2, input4]) => [[_0, _1, _2], input4]))), ([_0, input2]) => [_0, input2], () => If(If(Const("[", input), ([_0, input2]) => If(Const("]", input2), ([_1, input3]) => [[_0, _1], input3])), ([_0, input2]) => [_0, input2], () => [])), ([_0, input2]) => IndexArray_0(input2, [...result, _0]), () => [result, input]);
2153
+ var IndexArray = (input) => If(IndexArray_0(input), ([_0, input2]) => [IndexArrayMapping(_0), input2]);
2154
+ var Extends = (input) => If(If(If(Const("extends", input), ([_0, input2]) => If(Type(input2), ([_1, input3]) => If(Const("?", input3), ([_2, input4]) => If(Type(input4), ([_3, input5]) => If(Const(":", input5), ([_4, input6]) => If(Type(input6), ([_5, input7]) => [[_0, _1, _2, _3, _4, _5], input7])))))), ([_0, input2]) => [_0, input2], () => If([[], input], ([_0, input2]) => [_0, input2], () => [])), ([_0, input2]) => [ExtendsMapping(_0), input2]);
2155
+ var Base2 = (input) => If(If(If(Const("(", input), ([_0, input2]) => If(Type(input2), ([_1, input3]) => If(Const(")", input3), ([_2, input4]) => [[_0, _1, _2], input4]))), ([_0, input2]) => [_0, input2], () => If(Keyword(input), ([_0, input2]) => [_0, input2], () => If(_Object_2(input), ([_0, input2]) => [_0, input2], () => If(Tuple2(input), ([_0, input2]) => [_0, input2], () => If(TemplateLiteral(input), ([_0, input2]) => [_0, input2], () => If(Literal2(input), ([_0, input2]) => [_0, input2], () => If(Constructor2(input), ([_0, input2]) => [_0, input2], () => If(_Function_2(input), ([_0, input2]) => [_0, input2], () => If(Mapped(input), ([_0, input2]) => [_0, input2], () => If(Options(input), ([_0, input2]) => [_0, input2], () => If(GenericCall(input), ([_0, input2]) => [_0, input2], () => If(Reference(input), ([_0, input2]) => [_0, input2], () => [])))))))))))), ([_0, input2]) => [BaseMapping(_0), input2]);
2156
+ var With = (input) => If(If(If(Const("with", input), ([_0, input2]) => If(JsonObject(input2), ([_1, input3]) => [[_0, _1], input3])), ([_0, input2]) => [_0, input2], () => If([[], input], ([_0, input2]) => [_0, input2], () => [])), ([_0, input2]) => [WithMapping(_0), input2]);
2157
+ var Factor = (input) => If(If(KeyOf(input), ([_0, input2]) => If(Base2(input2), ([_1, input3]) => If(IndexArray(input3), ([_2, input4]) => If(Extends(input4), ([_3, input5]) => If(With(input5), ([_4, input6]) => [[_0, _1, _2, _3, _4], input6]))))), ([_0, input2]) => [FactorMapping(_0), input2]);
2158
+ var ExprTermTail = (input) => If(If(If(Const("&", input), ([_0, input2]) => If(Factor(input2), ([_1, input3]) => If(ExprTermTail(input3), ([_2, input4]) => [[_0, _1, _2], input4]))), ([_0, input2]) => [_0, input2], () => If([[], input], ([_0, input2]) => [_0, input2], () => [])), ([_0, input2]) => [ExprTermTailMapping(_0), input2]);
2159
+ var ExprTerm = (input) => If(If(Factor(input), ([_0, input2]) => If(ExprTermTail(input2), ([_1, input3]) => [[_0, _1], input3])), ([_0, input2]) => [ExprTermMapping(_0), input2]);
2160
+ var ExprTail = (input) => If(If(If(Const("|", input), ([_0, input2]) => If(ExprTerm(input2), ([_1, input3]) => If(ExprTail(input3), ([_2, input4]) => [[_0, _1, _2], input4]))), ([_0, input2]) => [_0, input2], () => If([[], input], ([_0, input2]) => [_0, input2], () => [])), ([_0, input2]) => [ExprTailMapping(_0), input2]);
2161
+ var Expr = (input) => If(If(ExprTerm(input), ([_0, input2]) => If(ExprTail(input2), ([_1, input3]) => [[_0, _1], input3])), ([_0, input2]) => [ExprMapping(_0), input2]);
2162
+ var ExprReadonly = (input) => If(If(Const("readonly", input), ([_0, input2]) => If(Expr(input2), ([_1, input3]) => [[_0, _1], input3])), ([_0, input2]) => [ExprReadonlyMapping(_0), input2]);
2163
+ var ExprPipe = (input) => If(If(Const("|", input), ([_0, input2]) => If(Expr(input2), ([_1, input3]) => [[_0, _1], input3])), ([_0, input2]) => [ExprPipeMapping(_0), input2]);
2164
+ var GenericType = (input) => If(If(GenericParameters(input), ([_0, input2]) => If(Const("=", input2), ([_1, input3]) => If(Type(input3), ([_2, input4]) => [[_0, _1, _2], input4]))), ([_0, input2]) => [GenericTypeMapping(_0), input2]);
2165
+ var InferType = (input) => If(If(If(Const("infer", input), ([_0, input2]) => If(Ident(input2), ([_1, input3]) => If(Const("extends", input3), ([_2, input4]) => If(Expr(input4), ([_3, input5]) => [[_0, _1, _2, _3], input5])))), ([_0, input2]) => [_0, input2], () => If(If(Const("infer", input), ([_0, input2]) => If(Ident(input2), ([_1, input3]) => [[_0, _1], input3])), ([_0, input2]) => [_0, input2], () => [])), ([_0, input2]) => [InferTypeMapping(_0), input2]);
2166
+ var Type = (input) => If(If(InferType(input), ([_0, input2]) => [_0, input2], () => If(ExprPipe(input), ([_0, input2]) => [_0, input2], () => If(ExprReadonly(input), ([_0, input2]) => [_0, input2], () => If(Expr(input), ([_0, input2]) => [_0, input2], () => [])))), ([_0, input2]) => [TypeMapping(_0), input2]);
2167
+ var PropertyKeyNumber = (input) => If(Number3(input), ([_0, input2]) => [PropertyKeyNumberMapping(_0), input2]);
2168
+ var PropertyKeyIdent = (input) => If(Ident(input), ([_0, input2]) => [PropertyKeyIdentMapping(_0), input2]);
2169
+ var PropertyKeyQuoted = (input) => If(String3(["'", '"'], input), ([_0, input2]) => [PropertyKeyQuotedMapping(_0), input2]);
2170
+ var PropertyKeyIndex = (input) => If(If(Const("[", input), ([_0, input2]) => If(Ident(input2), ([_1, input3]) => If(Const(":", input3), ([_2, input4]) => If(If(KeywordInteger(input4), ([_02, input5]) => [_02, input5], () => If(KeywordNumber(input4), ([_02, input5]) => [_02, input5], () => If(KeywordString(input4), ([_02, input5]) => [_02, input5], () => If(KeywordSymbol(input4), ([_02, input5]) => [_02, input5], () => [])))), ([_3, input5]) => If(Const("]", input5), ([_4, input6]) => [[_0, _1, _2, _3, _4], input6]))))), ([_0, input2]) => [PropertyKeyIndexMapping(_0), input2]);
2171
+ var PropertyKey = (input) => If(If(PropertyKeyNumber(input), ([_0, input2]) => [_0, input2], () => If(PropertyKeyIdent(input), ([_0, input2]) => [_0, input2], () => If(PropertyKeyQuoted(input), ([_0, input2]) => [_0, input2], () => If(PropertyKeyIndex(input), ([_0, input2]) => [_0, input2], () => [])))), ([_0, input2]) => [PropertyKeyMapping(_0), input2]);
2172
+ var Readonly2 = (input) => If(If(If(Const("readonly", input), ([_0, input2]) => [[_0], input2]), ([_0, input2]) => [_0, input2], () => If([[], input], ([_0, input2]) => [_0, input2], () => [])), ([_0, input2]) => [ReadonlyMapping(_0), input2]);
2173
+ var Optional3 = (input) => If(If(If(Const("?", input), ([_0, input2]) => [[_0], input2]), ([_0, input2]) => [_0, input2], () => If([[], input], ([_0, input2]) => [_0, input2], () => [])), ([_0, input2]) => [OptionalMapping(_0), input2]);
2174
+ var Property = (input) => If(If(Readonly2(input), ([_0, input2]) => If(PropertyKey(input2), ([_1, input3]) => If(Optional3(input3), ([_2, input4]) => If(Const(":", input4), ([_3, input5]) => If(Type(input5), ([_4, input6]) => [[_0, _1, _2, _3, _4], input6]))))), ([_0, input2]) => [PropertyMapping(_0), input2]);
2175
+ var PropertyDelimiter = (input) => If(If(If(Const(",", input), ([_0, input2]) => If(Const("\n", input2), ([_1, input3]) => [[_0, _1], input3])), ([_0, input2]) => [_0, input2], () => If(If(Const(";", input), ([_0, input2]) => If(Const("\n", input2), ([_1, input3]) => [[_0, _1], input3])), ([_0, input2]) => [_0, input2], () => If(If(Const(",", input), ([_0, input2]) => [[_0], input2]), ([_0, input2]) => [_0, input2], () => If(If(Const(";", input), ([_0, input2]) => [[_0], input2]), ([_0, input2]) => [_0, input2], () => If(If(Const("\n", input), ([_0, input2]) => [[_0], input2]), ([_0, input2]) => [_0, input2], () => []))))), ([_0, input2]) => [PropertyDelimiterMapping(_0), input2]);
2176
+ var PropertyList_0 = (input, result = []) => If(If(Property(input), ([_0, input2]) => If(PropertyDelimiter(input2), ([_1, input3]) => [[_0, _1], input3])), ([_0, input2]) => PropertyList_0(input2, [...result, _0]), () => [result, input]);
2177
+ var PropertyList = (input) => If(If(PropertyList_0(input), ([_0, input2]) => If(If(If(Property(input2), ([_02, input3]) => [[_02], input3]), ([_02, input3]) => [_02, input3], () => If([[], input2], ([_02, input3]) => [_02, input3], () => [])), ([_1, input3]) => [[_0, _1], input3])), ([_0, input2]) => [PropertyListMapping(_0), input2]);
2178
+ var Properties = (input) => If(If(Const("{", input), ([_0, input2]) => If(PropertyList(input2), ([_1, input3]) => If(Const("}", input3), ([_2, input4]) => [[_0, _1, _2], input4]))), ([_0, input2]) => [PropertiesMapping(_0), input2]);
2179
+ var _Object_2 = (input) => If(Properties(input), ([_0, input2]) => [_Object_Mapping(_0), input2]);
2180
+ var ElementNamed = (input) => If(If(If(Ident(input), ([_0, input2]) => If(Const("?", input2), ([_1, input3]) => If(Const(":", input3), ([_2, input4]) => If(Const("readonly", input4), ([_3, input5]) => If(Type(input5), ([_4, input6]) => [[_0, _1, _2, _3, _4], input6]))))), ([_0, input2]) => [_0, input2], () => If(If(Ident(input), ([_0, input2]) => If(Const(":", input2), ([_1, input3]) => If(Const("readonly", input3), ([_2, input4]) => If(Type(input4), ([_3, input5]) => [[_0, _1, _2, _3], input5])))), ([_0, input2]) => [_0, input2], () => If(If(Ident(input), ([_0, input2]) => If(Const("?", input2), ([_1, input3]) => If(Const(":", input3), ([_2, input4]) => If(Type(input4), ([_3, input5]) => [[_0, _1, _2, _3], input5])))), ([_0, input2]) => [_0, input2], () => If(If(Ident(input), ([_0, input2]) => If(Const(":", input2), ([_1, input3]) => If(Type(input3), ([_2, input4]) => [[_0, _1, _2], input4]))), ([_0, input2]) => [_0, input2], () => [])))), ([_0, input2]) => [ElementNamedMapping(_0), input2]);
2181
+ var ElementReadonlyOptional = (input) => If(If(Const("readonly", input), ([_0, input2]) => If(Type(input2), ([_1, input3]) => If(Const("?", input3), ([_2, input4]) => [[_0, _1, _2], input4]))), ([_0, input2]) => [ElementReadonlyOptionalMapping(_0), input2]);
2182
+ var ElementReadonly = (input) => If(If(Const("readonly", input), ([_0, input2]) => If(Type(input2), ([_1, input3]) => [[_0, _1], input3])), ([_0, input2]) => [ElementReadonlyMapping(_0), input2]);
2183
+ var ElementOptional = (input) => If(If(Type(input), ([_0, input2]) => If(Const("?", input2), ([_1, input3]) => [[_0, _1], input3])), ([_0, input2]) => [ElementOptionalMapping(_0), input2]);
2184
+ var ElementBase = (input) => If(If(ElementNamed(input), ([_0, input2]) => [_0, input2], () => If(ElementReadonlyOptional(input), ([_0, input2]) => [_0, input2], () => If(ElementReadonly(input), ([_0, input2]) => [_0, input2], () => If(ElementOptional(input), ([_0, input2]) => [_0, input2], () => If(Type(input), ([_0, input2]) => [_0, input2], () => []))))), ([_0, input2]) => [ElementBaseMapping(_0), input2]);
2185
+ var Element = (input) => If(If(If(Const("...", input), ([_0, input2]) => If(ElementBase(input2), ([_1, input3]) => [[_0, _1], input3])), ([_0, input2]) => [_0, input2], () => If(If(ElementBase(input), ([_0, input2]) => [[_0], input2]), ([_0, input2]) => [_0, input2], () => [])), ([_0, input2]) => [ElementMapping(_0), input2]);
2186
+ var ElementList_0 = (input, result = []) => If(If(Element(input), ([_0, input2]) => If(Const(",", input2), ([_1, input3]) => [[_0, _1], input3])), ([_0, input2]) => ElementList_0(input2, [...result, _0]), () => [result, input]);
2187
+ var ElementList = (input) => If(If(ElementList_0(input), ([_0, input2]) => If(If(If(Element(input2), ([_02, input3]) => [[_02], input3]), ([_02, input3]) => [_02, input3], () => If([[], input2], ([_02, input3]) => [_02, input3], () => [])), ([_1, input3]) => [[_0, _1], input3])), ([_0, input2]) => [ElementListMapping(_0), input2]);
2188
+ var Tuple2 = (input) => If(If(Const("[", input), ([_0, input2]) => If(ElementList(input2), ([_1, input3]) => If(Const("]", input3), ([_2, input4]) => [[_0, _1, _2], input4]))), ([_0, input2]) => [TupleMapping(_0), input2]);
2189
+ var ParameterReadonlyOptional = (input) => If(If(Ident(input), ([_0, input2]) => If(Const("?", input2), ([_1, input3]) => If(Const(":", input3), ([_2, input4]) => If(Const("readonly", input4), ([_3, input5]) => If(Type(input5), ([_4, input6]) => [[_0, _1, _2, _3, _4], input6]))))), ([_0, input2]) => [ParameterReadonlyOptionalMapping(_0), input2]);
2190
+ var ParameterReadonly = (input) => If(If(Ident(input), ([_0, input2]) => If(Const(":", input2), ([_1, input3]) => If(Const("readonly", input3), ([_2, input4]) => If(Type(input4), ([_3, input5]) => [[_0, _1, _2, _3], input5])))), ([_0, input2]) => [ParameterReadonlyMapping(_0), input2]);
2191
+ var ParameterOptional = (input) => If(If(Ident(input), ([_0, input2]) => If(Const("?", input2), ([_1, input3]) => If(Const(":", input3), ([_2, input4]) => If(Type(input4), ([_3, input5]) => [[_0, _1, _2, _3], input5])))), ([_0, input2]) => [ParameterOptionalMapping(_0), input2]);
2192
+ var ParameterType = (input) => If(If(Ident(input), ([_0, input2]) => If(Const(":", input2), ([_1, input3]) => If(Type(input3), ([_2, input4]) => [[_0, _1, _2], input4]))), ([_0, input2]) => [ParameterTypeMapping(_0), input2]);
2193
+ var ParameterBase = (input) => If(If(ParameterReadonlyOptional(input), ([_0, input2]) => [_0, input2], () => If(ParameterReadonly(input), ([_0, input2]) => [_0, input2], () => If(ParameterOptional(input), ([_0, input2]) => [_0, input2], () => If(ParameterType(input), ([_0, input2]) => [_0, input2], () => [])))), ([_0, input2]) => [ParameterBaseMapping(_0), input2]);
2194
+ var Parameter2 = (input) => If(If(If(Const("...", input), ([_0, input2]) => If(ParameterBase(input2), ([_1, input3]) => [[_0, _1], input3])), ([_0, input2]) => [_0, input2], () => If(If(ParameterBase(input), ([_0, input2]) => [[_0], input2]), ([_0, input2]) => [_0, input2], () => [])), ([_0, input2]) => [ParameterMapping(_0), input2]);
2195
+ var ParameterList_0 = (input, result = []) => If(If(Parameter2(input), ([_0, input2]) => If(Const(",", input2), ([_1, input3]) => [[_0, _1], input3])), ([_0, input2]) => ParameterList_0(input2, [...result, _0]), () => [result, input]);
2196
+ var ParameterList = (input) => If(If(ParameterList_0(input), ([_0, input2]) => If(If(If(Parameter2(input2), ([_02, input3]) => [[_02], input3]), ([_02, input3]) => [_02, input3], () => If([[], input2], ([_02, input3]) => [_02, input3], () => [])), ([_1, input3]) => [[_0, _1], input3])), ([_0, input2]) => [ParameterListMapping(_0), input2]);
2197
+ var _Function_2 = (input) => If(If(Const("(", input), ([_0, input2]) => If(ParameterList(input2), ([_1, input3]) => If(Const(")", input3), ([_2, input4]) => If(Const("=>", input4), ([_3, input5]) => If(Type(input5), ([_4, input6]) => [[_0, _1, _2, _3, _4], input6]))))), ([_0, input2]) => [_Function_Mapping(_0), input2]);
2198
+ var Constructor2 = (input) => If(If(Const("new", input), ([_0, input2]) => If(Const("(", input2), ([_1, input3]) => If(ParameterList(input3), ([_2, input4]) => If(Const(")", input4), ([_3, input5]) => If(Const("=>", input5), ([_4, input6]) => If(Type(input6), ([_5, input7]) => [[_0, _1, _2, _3, _4, _5], input7])))))), ([_0, input2]) => [ConstructorMapping(_0), input2]);
2199
+ var MappedReadonly = (input) => If(If(If(Const("+", input), ([_0, input2]) => If(Const("readonly", input2), ([_1, input3]) => [[_0, _1], input3])), ([_0, input2]) => [_0, input2], () => If(If(Const("-", input), ([_0, input2]) => If(Const("readonly", input2), ([_1, input3]) => [[_0, _1], input3])), ([_0, input2]) => [_0, input2], () => If(If(Const("readonly", input), ([_0, input2]) => [[_0], input2]), ([_0, input2]) => [_0, input2], () => If([[], input], ([_0, input2]) => [_0, input2], () => [])))), ([_0, input2]) => [MappedReadonlyMapping(_0), input2]);
2200
+ var MappedOptional = (input) => If(If(If(Const("+", input), ([_0, input2]) => If(Const("?", input2), ([_1, input3]) => [[_0, _1], input3])), ([_0, input2]) => [_0, input2], () => If(If(Const("-", input), ([_0, input2]) => If(Const("?", input2), ([_1, input3]) => [[_0, _1], input3])), ([_0, input2]) => [_0, input2], () => If(If(Const("?", input), ([_0, input2]) => [[_0], input2]), ([_0, input2]) => [_0, input2], () => If([[], input], ([_0, input2]) => [_0, input2], () => [])))), ([_0, input2]) => [MappedOptionalMapping(_0), input2]);
2201
+ var MappedAs = (input) => If(If(If(Const("as", input), ([_0, input2]) => If(Type(input2), ([_1, input3]) => [[_0, _1], input3])), ([_0, input2]) => [_0, input2], () => If([[], input], ([_0, input2]) => [_0, input2], () => [])), ([_0, input2]) => [MappedAsMapping(_0), input2]);
2202
+ var Mapped = (input) => If(If(Const("{", input), ([_0, input2]) => If(MappedReadonly(input2), ([_1, input3]) => If(Const("[", input3), ([_2, input4]) => If(Ident(input4), ([_3, input5]) => If(Const("in", input5), ([_4, input6]) => If(Type(input6), ([_5, input7]) => If(MappedAs(input7), ([_6, input8]) => If(Const("]", input8), ([_7, input9]) => If(MappedOptional(input9), ([_8, input10]) => If(Const(":", input10), ([_9, input11]) => If(Type(input11), ([_10, input12]) => If(OptionalSemiColon(input12), ([_11, input13]) => If(Const("}", input13), ([_12, input14]) => [[_0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12], input14]))))))))))))), ([_0, input2]) => [MappedMapping(_0), input2]);
2203
+ var Reference = (input) => If(Ident(input), ([_0, input2]) => [ReferenceMapping(_0), input2]);
2204
+ var Options = (input) => If(If(Const("Options", input), ([_0, input2]) => If(Const("<", input2), ([_1, input3]) => If(Type(input3), ([_2, input4]) => If(Const(",", input4), ([_3, input5]) => If(JsonObject(input5), ([_4, input6]) => If(Const(">", input6), ([_5, input7]) => [[_0, _1, _2, _3, _4, _5], input7])))))), ([_0, input2]) => [OptionsMapping(_0), input2]);
2205
+ var JsonNumber = (input) => If(Number3(input), ([_0, input2]) => [JsonNumberMapping(_0), input2]);
2206
+ var JsonBoolean = (input) => If(If(Const("true", input), ([_0, input2]) => [_0, input2], () => If(Const("false", input), ([_0, input2]) => [_0, input2], () => [])), ([_0, input2]) => [JsonBooleanMapping(_0), input2]);
2207
+ var JsonString = (input) => If(String3(['"', "'"], input), ([_0, input2]) => [JsonStringMapping(_0), input2]);
2208
+ var JsonNull = (input) => If(Const("null", input), ([_0, input2]) => [JsonNullMapping(_0), input2]);
2209
+ var JsonProperty = (input) => If(If(PropertyKey(input), ([_0, input2]) => If(Const(":", input2), ([_1, input3]) => If(Json(input3), ([_2, input4]) => [[_0, _1, _2], input4]))), ([_0, input2]) => [JsonPropertyMapping(_0), input2]);
2210
+ var JsonPropertyList_0 = (input, result = []) => If(If(JsonProperty(input), ([_0, input2]) => If(PropertyDelimiter(input2), ([_1, input3]) => [[_0, _1], input3])), ([_0, input2]) => JsonPropertyList_0(input2, [...result, _0]), () => [result, input]);
2211
+ var JsonPropertyList = (input) => If(If(JsonPropertyList_0(input), ([_0, input2]) => If(If(If(JsonProperty(input2), ([_02, input3]) => [[_02], input3]), ([_02, input3]) => [_02, input3], () => If([[], input2], ([_02, input3]) => [_02, input3], () => [])), ([_1, input3]) => [[_0, _1], input3])), ([_0, input2]) => [JsonPropertyListMapping(_0), input2]);
2212
+ var JsonObject = (input) => If(If(Const("{", input), ([_0, input2]) => If(JsonPropertyList(input2), ([_1, input3]) => If(Const("}", input3), ([_2, input4]) => [[_0, _1, _2], input4]))), ([_0, input2]) => [JsonObjectMapping(_0), input2]);
2213
+ var JsonElementList_0 = (input, result = []) => If(If(Json(input), ([_0, input2]) => If(Const(",", input2), ([_1, input3]) => [[_0, _1], input3])), ([_0, input2]) => JsonElementList_0(input2, [...result, _0]), () => [result, input]);
2214
+ var JsonElementList = (input) => If(If(JsonElementList_0(input), ([_0, input2]) => If(If(If(Json(input2), ([_02, input3]) => [[_02], input3]), ([_02, input3]) => [_02, input3], () => If([[], input2], ([_02, input3]) => [_02, input3], () => [])), ([_1, input3]) => [[_0, _1], input3])), ([_0, input2]) => [JsonElementListMapping(_0), input2]);
2215
+ var JsonArray = (input) => If(If(Const("[", input), ([_0, input2]) => If(JsonElementList(input2), ([_1, input3]) => If(Const("]", input3), ([_2, input4]) => [[_0, _1, _2], input4]))), ([_0, input2]) => [JsonArrayMapping(_0), input2]);
2216
+ var Json = (input) => If(If(JsonNumber(input), ([_0, input2]) => [_0, input2], () => If(JsonBoolean(input), ([_0, input2]) => [_0, input2], () => If(JsonString(input), ([_0, input2]) => [_0, input2], () => If(JsonNull(input), ([_0, input2]) => [_0, input2], () => If(JsonObject(input), ([_0, input2]) => [_0, input2], () => If(JsonArray(input), ([_0, input2]) => [_0, input2], () => [])))))), ([_0, input2]) => [JsonMapping(_0), input2]);
2217
+ var PatternBigInt = (input) => If(Const("-?(?:0|[1-9][0-9]*)n", input), ([_0, input2]) => [PatternBigIntMapping(_0), input2]);
2218
+ var PatternString = (input) => If(Const(".*", input), ([_0, input2]) => [PatternStringMapping(_0), input2]);
2219
+ var PatternNumber = (input) => If(Const("-?(?:0|[1-9][0-9]*)(?:.[0-9]+)?", input), ([_0, input2]) => [PatternNumberMapping(_0), input2]);
2220
+ var PatternInteger = (input) => If(Const("-?(?:0|[1-9][0-9]*)", input), ([_0, input2]) => [PatternIntegerMapping(_0), input2]);
2221
+ var PatternNever = (input) => If(Const("(?!)", input), ([_0, input2]) => [PatternNeverMapping(_0), input2]);
2222
+ var PatternText = (input) => If(Until_1(["-?(?:0|[1-9][0-9]*)n", ".*", "-?(?:0|[1-9][0-9]*)(?:.[0-9]+)?", "-?(?:0|[1-9][0-9]*)", "(?!)", "(", ")", "$", "|"], input), ([_0, input2]) => [PatternTextMapping(_0), input2]);
2223
+ var PatternBase = (input) => If(If(PatternBigInt(input), ([_0, input2]) => [_0, input2], () => If(PatternString(input), ([_0, input2]) => [_0, input2], () => If(PatternNumber(input), ([_0, input2]) => [_0, input2], () => If(PatternInteger(input), ([_0, input2]) => [_0, input2], () => If(PatternNever(input), ([_0, input2]) => [_0, input2], () => If(PatternGroup(input), ([_0, input2]) => [_0, input2], () => If(PatternText(input), ([_0, input2]) => [_0, input2], () => []))))))), ([_0, input2]) => [PatternBaseMapping(_0), input2]);
2224
+ var PatternGroup = (input) => If(If(Const("(", input), ([_0, input2]) => If(PatternBody(input2), ([_1, input3]) => If(Const(")", input3), ([_2, input4]) => [[_0, _1, _2], input4]))), ([_0, input2]) => [PatternGroupMapping(_0), input2]);
2225
+ var PatternUnion = (input) => If(If(If(PatternTerm(input), ([_0, input2]) => If(Const("|", input2), ([_1, input3]) => If(PatternUnion(input3), ([_2, input4]) => [[_0, _1, _2], input4]))), ([_0, input2]) => [_0, input2], () => If(If(PatternTerm(input), ([_0, input2]) => [[_0], input2]), ([_0, input2]) => [_0, input2], () => If([[], input], ([_0, input2]) => [_0, input2], () => []))), ([_0, input2]) => [PatternUnionMapping(_0), input2]);
2226
+ var PatternTerm = (input) => If(If(PatternBase(input), ([_0, input2]) => If(PatternBody(input2), ([_1, input3]) => [[_0, _1], input3])), ([_0, input2]) => [PatternTermMapping(_0), input2]);
2227
+ var PatternBody = (input) => If(If(PatternUnion(input), ([_0, input2]) => [_0, input2], () => If(PatternTerm(input), ([_0, input2]) => [_0, input2], () => [])), ([_0, input2]) => [PatternBodyMapping(_0), input2]);
2228
+ var Pattern = (input) => If(If(Const("^", input), ([_0, input2]) => If(PatternBody(input2), ([_1, input3]) => If(Const("$", input3), ([_2, input4]) => [[_0, _1, _2], input4]))), ([_0, input2]) => [PatternMapping(_0), input2]);
2229
+ var InterfaceDeclarationHeritageList_0 = (input, result = []) => If(If(Type(input), ([_0, input2]) => If(Const(",", input2), ([_1, input3]) => [[_0, _1], input3])), ([_0, input2]) => InterfaceDeclarationHeritageList_0(input2, [...result, _0]), () => [result, input]);
2230
+ var InterfaceDeclarationHeritageList = (input) => If(If(InterfaceDeclarationHeritageList_0(input), ([_0, input2]) => If(If(If(Type(input2), ([_02, input3]) => [[_02], input3]), ([_02, input3]) => [_02, input3], () => If([[], input2], ([_02, input3]) => [_02, input3], () => [])), ([_1, input3]) => [[_0, _1], input3])), ([_0, input2]) => [InterfaceDeclarationHeritageListMapping(_0), input2]);
2231
+ var InterfaceDeclarationHeritage = (input) => If(If(If(Const("extends", input), ([_0, input2]) => If(InterfaceDeclarationHeritageList(input2), ([_1, input3]) => [[_0, _1], input3])), ([_0, input2]) => [_0, input2], () => If([[], input], ([_0, input2]) => [_0, input2], () => [])), ([_0, input2]) => [InterfaceDeclarationHeritageMapping(_0), input2]);
2232
+ var InterfaceDeclarationGeneric = (input) => If(If(Const("interface", input), ([_0, input2]) => If(Ident(input2), ([_1, input3]) => If(GenericParameters(input3), ([_2, input4]) => If(InterfaceDeclarationHeritage(input4), ([_3, input5]) => If(Properties(input5), ([_4, input6]) => [[_0, _1, _2, _3, _4], input6]))))), ([_0, input2]) => [InterfaceDeclarationGenericMapping(_0), input2]);
2233
+ var InterfaceDeclaration = (input) => If(If(Const("interface", input), ([_0, input2]) => If(Ident(input2), ([_1, input3]) => If(InterfaceDeclarationHeritage(input3), ([_2, input4]) => If(Properties(input4), ([_3, input5]) => [[_0, _1, _2, _3], input5])))), ([_0, input2]) => [InterfaceDeclarationMapping(_0), input2]);
2234
+ var TypeAliasDeclarationGeneric = (input) => If(If(Const("type", input), ([_0, input2]) => If(Ident(input2), ([_1, input3]) => If(GenericParameters(input3), ([_2, input4]) => If(Const("=", input4), ([_3, input5]) => If(Type(input5), ([_4, input6]) => [[_0, _1, _2, _3, _4], input6]))))), ([_0, input2]) => [TypeAliasDeclarationGenericMapping(_0), input2]);
2235
+ var TypeAliasDeclaration = (input) => If(If(Const("type", input), ([_0, input2]) => If(Ident(input2), ([_1, input3]) => If(Const("=", input3), ([_2, input4]) => If(Type(input4), ([_3, input5]) => [[_0, _1, _2, _3], input5])))), ([_0, input2]) => [TypeAliasDeclarationMapping(_0), input2]);
2236
+ var ExportKeyword = (input) => If(If(If(Const("export", input), ([_0, input2]) => [[_0], input2]), ([_0, input2]) => [_0, input2], () => If([[], input], ([_0, input2]) => [_0, input2], () => [])), ([_0, input2]) => [ExportKeywordMapping(_0), input2]);
2237
+ var ModuleDeclarationDelimiter = (input) => If(If(If(Const(";", input), ([_0, input2]) => If(Const("\n", input2), ([_1, input3]) => [[_0, _1], input3])), ([_0, input2]) => [_0, input2], () => If(If(Const(";", input), ([_0, input2]) => [[_0], input2]), ([_0, input2]) => [_0, input2], () => If(If(Const("\n", input), ([_0, input2]) => [[_0], input2]), ([_0, input2]) => [_0, input2], () => []))), ([_0, input2]) => [ModuleDeclarationDelimiterMapping(_0), input2]);
2238
+ var ModuleDeclarationList_0 = (input, result = []) => If(If(ModuleDeclaration(input), ([_0, input2]) => If(ModuleDeclarationDelimiter(input2), ([_1, input3]) => [[_0, _1], input3])), ([_0, input2]) => ModuleDeclarationList_0(input2, [...result, _0]), () => [result, input]);
2239
+ var ModuleDeclarationList = (input) => If(If(ModuleDeclarationList_0(input), ([_0, input2]) => If(If(If(ModuleDeclaration(input2), ([_02, input3]) => [[_02], input3]), ([_02, input3]) => [_02, input3], () => If([[], input2], ([_02, input3]) => [_02, input3], () => [])), ([_1, input3]) => [[_0, _1], input3])), ([_0, input2]) => [ModuleDeclarationListMapping(_0), input2]);
2240
+ var ModuleDeclaration = (input) => If(If(ExportKeyword(input), ([_0, input2]) => If(If(InterfaceDeclarationGeneric(input2), ([_02, input3]) => [_02, input3], () => If(InterfaceDeclaration(input2), ([_02, input3]) => [_02, input3], () => If(TypeAliasDeclarationGeneric(input2), ([_02, input3]) => [_02, input3], () => If(TypeAliasDeclaration(input2), ([_02, input3]) => [_02, input3], () => [])))), ([_1, input3]) => If(OptionalSemiColon(input3), ([_2, input4]) => [[_0, _1, _2], input4]))), ([_0, input2]) => [ModuleDeclarationMapping(_0), input2]);
2241
+ var Module = (input) => If(If(ModuleDeclaration(input), ([_0, input2]) => If(ModuleDeclarationList(input2), ([_1, input3]) => [[_0, _1], input3])), ([_0, input2]) => [ModuleMapping(_0), input2]);
2242
+ var Script = (input) => If(If(Module(input), ([_0, input2]) => [_0, input2], () => If(GenericType(input), ([_0, input2]) => [_0, input2], () => If(Type(input), ([_0, input2]) => [_0, input2], () => []))), ([_0, input2]) => [ScriptMapping(_0), input2]);
2243
+
2244
+ // ../../node_modules/.pnpm/typebox@1.1.39/node_modules/typebox/build/type/engine/patterns/template.mjs
2245
+ function ParseTemplateIntoTypes(template) {
2246
+ const parsed = TemplateLiteralTypes(`\`${template}\``);
2247
+ const result = guard_exports.IsEqual(parsed.length, 2) ? parsed[0] : Unreachable();
2248
+ return result;
2249
+ }
2250
+
2251
+ // ../../node_modules/.pnpm/typebox@1.1.39/node_modules/typebox/build/type/engine/template_literal/encode.mjs
2252
+ function JoinString(input) {
2253
+ return input.join("|");
2254
+ }
2255
+ function UnwrapTemplateLiteralPattern(pattern) {
2256
+ return pattern.slice(1, pattern.length - 1);
2257
+ }
2258
+ function EncodeLiteral(value, right, pattern) {
2259
+ return EncodeTypes(right, `${pattern}${value}`);
2260
+ }
2261
+ function EncodeBigInt(right, pattern) {
2262
+ return EncodeTypes(right, `${pattern}${BigIntPattern}`);
2263
+ }
2264
+ function EncodeInteger(right, pattern) {
2265
+ return EncodeTypes(right, `${pattern}${IntegerPattern}`);
2266
+ }
2267
+ function EncodeNumber(right, pattern) {
2268
+ return EncodeTypes(right, `${pattern}${NumberPattern}`);
2269
+ }
2270
+ function EncodeBoolean(right, pattern) {
2271
+ return EncodeType(Union([Literal("false"), Literal("true")]), right, pattern);
2272
+ }
2273
+ function EncodeString(right, pattern) {
2274
+ return EncodeTypes(right, `${pattern}${StringPattern}`);
2275
+ }
2276
+ function EncodeTemplateLiteral(templatePattern, right, pattern) {
2277
+ return EncodeTypes(right, `${pattern}${UnwrapTemplateLiteralPattern(templatePattern)}`);
2278
+ }
2279
+ function EncodeTemplateLiteralDeferred(types, right, pattern) {
2280
+ const templateLiteral = TemplateLiteralAction(types, {});
2281
+ const result = EncodeType(templateLiteral, right, pattern);
2282
+ return result;
2283
+ }
2284
+ function EncodeEnum(types, right, pattern) {
2285
+ const variants = EnumValuesToVariants(types);
2286
+ return EncodeUnion(variants, right, pattern);
2287
+ }
2288
+ function EncodeUnion(types, right, pattern, result = []) {
2289
+ return guard_exports.TakeLeft(types, (head, tail) => EncodeUnion(tail, right, pattern, [...result, EncodeType(head, [], "")]), () => EncodeTypes(right, `${pattern}(${JoinString(result)})`));
2290
+ }
2291
+ function EncodeType(type, right, pattern) {
2292
+ return IsEnum(type) ? EncodeEnum(type.enum, right, pattern) : IsInteger2(type) ? EncodeInteger(right, pattern) : IsLiteral(type) ? EncodeLiteral(type.const, right, pattern) : IsBigInt2(type) ? EncodeBigInt(right, pattern) : IsBoolean2(type) ? EncodeBoolean(right, pattern) : IsNumber2(type) ? EncodeNumber(right, pattern) : IsString2(type) ? EncodeString(right, pattern) : IsTemplateLiteral(type) ? EncodeTemplateLiteral(type.pattern, right, pattern) : IsTemplateLiteralDeferred(type) ? EncodeTemplateLiteralDeferred(type.parameters[0], right, pattern) : IsUnion(type) ? EncodeUnion(type.anyOf, right, pattern) : NeverPattern;
2293
+ }
2294
+ function EncodeTypes(types, pattern) {
2295
+ return guard_exports.TakeLeft(types, (left, right) => EncodeType(left, right, pattern), () => pattern);
2296
+ }
2297
+ function EncodePattern(types) {
2298
+ const encoded = EncodeTypes(types, "");
2299
+ const result = `^${encoded}$`;
2300
+ return result;
2301
+ }
2302
+ function TemplateLiteralEncode(types) {
2303
+ const pattern = EncodePattern(types);
2304
+ const result = TemplateLiteralCreate(pattern);
2305
+ return result;
2306
+ }
2307
+
2308
+ // ../../node_modules/.pnpm/typebox@1.1.39/node_modules/typebox/build/type/engine/template_literal/instantiate.mjs
2309
+ function TemplateLiteralAction(types, options) {
2310
+ const result = CanInstantiate(types) ? memory_exports.Update(TemplateLiteralEncode(types), {}, options) : TemplateLiteralDeferred(types, options);
2311
+ return result;
2312
+ }
2313
+ function TemplateLiteralInstantiate(context, state, types, options) {
2314
+ const instantiatedTypes = InstantiateTypes(context, state, types);
2315
+ return TemplateLiteralAction(instantiatedTypes, options);
2316
+ }
2317
+
2318
+ // ../../node_modules/.pnpm/typebox@1.1.39/node_modules/typebox/build/type/types/template_literal.mjs
2319
+ function TemplateLiteralDeferred(types, options = {}) {
2320
+ return Deferred("TemplateLiteral", [types], options);
2321
+ }
2322
+ function IsTemplateLiteralDeferred(value) {
2323
+ return IsSchema(value) && guard_exports.HasPropertyKey(value, "action") && guard_exports.IsEqual(value.action, "TemplateLiteral");
2324
+ }
2325
+ function TemplateLiteralFromTypes(types) {
2326
+ return TemplateLiteralAction(types, {});
2327
+ }
2328
+ function TemplateLiteralFromString(template) {
2329
+ const types = ParseTemplateIntoTypes(template);
2330
+ return TemplateLiteralFromTypes(types);
2331
+ }
2332
+ function TemplateLiteral2(input, options = {}) {
2333
+ const type = guard_exports.IsString(input) ? TemplateLiteralFromString(input) : TemplateLiteralFromTypes(input);
2334
+ return memory_exports.Update(type, {}, options);
2335
+ }
2336
+ function IsTemplateLiteral(value) {
2337
+ return IsKind(value, "TemplateLiteral");
2338
+ }
2339
+
2340
+ // ../../node_modules/.pnpm/typebox@1.1.39/node_modules/typebox/build/type/extends/result.mjs
2341
+ var result_exports = {};
2342
+ __export(result_exports, {
2343
+ ExtendsFalse: () => ExtendsFalse,
2344
+ ExtendsTrue: () => ExtendsTrue,
2345
+ ExtendsUnion: () => ExtendsUnion,
2346
+ IsExtendsFalse: () => IsExtendsFalse,
2347
+ IsExtendsTrue: () => IsExtendsTrue,
2348
+ IsExtendsTrueLike: () => IsExtendsTrueLike,
2349
+ IsExtendsUnion: () => IsExtendsUnion,
2350
+ Match: () => Match3
2351
+ });
2352
+ function ExtendsUnion(inferred) {
2353
+ return memory_exports.Create({ ["~kind"]: "ExtendsUnion" }, { inferred });
2354
+ }
2355
+ function IsExtendsUnion(value) {
2356
+ return guard_exports.IsObject(value) && guard_exports.HasPropertyKey(value, "~kind") && guard_exports.HasPropertyKey(value, "inferred") && guard_exports.IsEqual(value["~kind"], "ExtendsUnion") && guard_exports.IsObject(value.inferred);
2357
+ }
2358
+ function ExtendsTrue(inferred) {
2359
+ return memory_exports.Create({ ["~kind"]: "ExtendsTrue" }, { inferred });
2360
+ }
2361
+ function IsExtendsTrue(value) {
2362
+ return guard_exports.IsObject(value) && guard_exports.HasPropertyKey(value, "~kind") && guard_exports.HasPropertyKey(value, "inferred") && guard_exports.IsEqual(value["~kind"], "ExtendsTrue") && guard_exports.IsObject(value.inferred);
2363
+ }
2364
+ function ExtendsFalse() {
2365
+ return memory_exports.Create({ ["~kind"]: "ExtendsFalse" }, {});
2366
+ }
2367
+ function IsExtendsFalse(value) {
2368
+ return guard_exports.IsObject(value) && guard_exports.HasPropertyKey(value, "~kind") && guard_exports.IsEqual(value["~kind"], "ExtendsFalse");
2369
+ }
2370
+ function IsExtendsTrueLike(value) {
2371
+ return IsExtendsUnion(value) || IsExtendsTrue(value);
2372
+ }
2373
+ function Match3(result, true_, false_) {
2374
+ return IsExtendsTrueLike(result) ? true_(result.inferred) : false_();
2375
+ }
2376
+
2377
+ // ../../node_modules/.pnpm/typebox@1.1.39/node_modules/typebox/build/type/extends/extends_right.mjs
2378
+ function ExtendsRightInfer(inferred, name, left, right) {
2379
+ return Match3(ExtendsLeft(inferred, left, right), (checkInferred) => ExtendsTrue(memory_exports.Assign(memory_exports.Assign(inferred, checkInferred), { [name]: left })), () => ExtendsFalse());
2380
+ }
2381
+ function ExtendsRightAny(inferred, _left) {
2382
+ return ExtendsTrue(inferred);
2383
+ }
2384
+ function ExtendsRightEnum(inferred, left, right) {
2385
+ const union = EnumValuesToUnion(right);
2386
+ return ExtendsLeft(inferred, left, union);
2387
+ }
2388
+ function ExtendsRightIntersect(inferred, left, right) {
2389
+ return guard_exports.TakeLeft(right, (head, tail) => Match3(ExtendsLeft(inferred, left, head), (inferred2) => ExtendsRightIntersect(inferred2, left, tail), () => ExtendsFalse()), () => ExtendsTrue(inferred));
2390
+ }
2391
+ function ExtendsRightTemplateLiteral(inferred, left, right) {
2392
+ const decoded = TemplateLiteralDecode(right);
2393
+ return ExtendsLeft(inferred, left, decoded);
2394
+ }
2395
+ function ExtendsRightUnion(inferred, left, right) {
2396
+ return guard_exports.TakeLeft(right, (head, tail) => Match3(ExtendsLeft(inferred, left, head), (inferred2) => ExtendsTrue(inferred2), () => ExtendsRightUnion(inferred, left, tail)), () => ExtendsFalse());
2397
+ }
2398
+ function ExtendsRight(inferred, left, right) {
2399
+ return IsAny(right) ? ExtendsRightAny(inferred, left) : IsEnum(right) ? ExtendsRightEnum(inferred, left, right.enum) : IsInfer(right) ? ExtendsRightInfer(inferred, right.name, left, right.extends) : IsIntersect(right) ? ExtendsRightIntersect(inferred, left, right.allOf) : IsTemplateLiteral(right) ? ExtendsRightTemplateLiteral(inferred, left, right.pattern) : IsUnion(right) ? ExtendsRightUnion(inferred, left, right.anyOf) : IsUnknown(right) ? ExtendsTrue(inferred) : ExtendsFalse();
2400
+ }
2401
+
2402
+ // ../../node_modules/.pnpm/typebox@1.1.39/node_modules/typebox/build/type/extends/any.mjs
2403
+ function ExtendsAny(inferred, left, right) {
2404
+ return IsInfer(right) ? ExtendsRight(inferred, left, right) : IsAny(right) ? ExtendsTrue(inferred) : IsUnknown(right) ? ExtendsTrue(inferred) : ExtendsUnion(inferred);
2405
+ }
2406
+
2407
+ // ../../node_modules/.pnpm/typebox@1.1.39/node_modules/typebox/build/type/extends/array.mjs
2408
+ function ExtendsImmutable(left, right) {
2409
+ const isImmutableLeft = IsImmutable(left);
2410
+ const isImmutableRight = IsImmutable(right);
2411
+ return isImmutableLeft && isImmutableRight ? true : !isImmutableLeft && isImmutableRight ? true : isImmutableLeft && !isImmutableRight ? false : true;
2412
+ }
2413
+ function ExtendsArray(inferred, arrayLeft, left, right) {
2414
+ return IsArray2(right) ? ExtendsImmutable(arrayLeft, right) ? ExtendsLeft(inferred, left, right.items) : ExtendsFalse() : ExtendsRight(inferred, arrayLeft, right);
2415
+ }
2416
+
2417
+ // ../../node_modules/.pnpm/typebox@1.1.39/node_modules/typebox/build/type/extends/async_iterator.mjs
2418
+ function ExtendsAsyncIterator(inferred, left, right) {
2419
+ return IsAsyncIterator2(right) ? ExtendsLeft(inferred, left, right.iteratorItems) : ExtendsRight(inferred, AsyncIterator(left), right);
2420
+ }
2421
+
2422
+ // ../../node_modules/.pnpm/typebox@1.1.39/node_modules/typebox/build/type/extends/bigint.mjs
2423
+ function ExtendsBigInt(inferred, left, right) {
2424
+ return IsBigInt2(right) ? ExtendsTrue(inferred) : ExtendsRight(inferred, left, right);
2425
+ }
2426
+
2427
+ // ../../node_modules/.pnpm/typebox@1.1.39/node_modules/typebox/build/type/extends/boolean.mjs
2428
+ function ExtendsBoolean(inferred, left, right) {
2429
+ return IsBoolean2(right) ? ExtendsTrue(inferred) : ExtendsRight(inferred, left, right);
2430
+ }
2431
+
2432
+ // ../../node_modules/.pnpm/typebox@1.1.39/node_modules/typebox/build/type/extends/parameters.mjs
2433
+ function ParameterCompare(inferred, left, leftRest, right, rightRest) {
2434
+ const checkLeft = IsInfer(right) ? left : right;
2435
+ const checkRight = IsInfer(right) ? right : left;
2436
+ const isLeftOptional = IsOptional(left);
2437
+ const isRightOptional = IsOptional(right);
2438
+ return !isLeftOptional && isRightOptional ? ExtendsFalse() : Match3(ExtendsLeft(inferred, checkLeft, checkRight), (inferred2) => ExtendsParameters(inferred2, leftRest, rightRest), () => ExtendsFalse());
2439
+ }
2440
+ function ParameterRight(inferred, left, leftRest, rightRest) {
2441
+ return guard_exports.TakeLeft(rightRest, (head, tail) => ParameterCompare(inferred, left, leftRest, head, tail), () => IsOptional(left) ? ExtendsTrue(inferred) : ExtendsFalse());
2442
+ }
2443
+ function ParametersLeft(inferred, left, rightRest) {
2444
+ return guard_exports.TakeLeft(left, (head, tail) => ParameterRight(inferred, head, tail, rightRest), () => ExtendsTrue(inferred));
2445
+ }
2446
+ function ExtendsParameters(inferred, left, right) {
2447
+ return ParametersLeft(inferred, left, right);
2448
+ }
2449
+
2450
+ // ../../node_modules/.pnpm/typebox@1.1.39/node_modules/typebox/build/type/extends/return_type.mjs
2451
+ function ExtendsReturnType(inferred, left, right) {
2452
+ return IsVoid(right) ? ExtendsTrue(inferred) : ExtendsLeft(inferred, left, right);
2453
+ }
2454
+
2455
+ // ../../node_modules/.pnpm/typebox@1.1.39/node_modules/typebox/build/type/extends/constructor.mjs
2456
+ function ExtendsConstructor(inferred, parameters, returnType, right) {
2457
+ return IsAny(right) ? ExtendsTrue(inferred) : IsUnknown(right) ? ExtendsTrue(inferred) : IsConstructor2(right) ? Match3(ExtendsParameters(inferred, parameters, right["parameters"]), (inferred2) => ExtendsReturnType(inferred2, returnType, right["instanceType"]), () => ExtendsFalse()) : ExtendsFalse();
2458
+ }
2459
+
2460
+ // ../../node_modules/.pnpm/typebox@1.1.39/node_modules/typebox/build/type/extends/enum.mjs
2461
+ function ExtendsEnum(inferred, left, right) {
2462
+ return ExtendsLeft(inferred, EnumToUnion(left), right);
2463
+ }
2464
+
2465
+ // ../../node_modules/.pnpm/typebox@1.1.39/node_modules/typebox/build/type/extends/function.mjs
2466
+ function ExtendsFunction(inferred, parameters, returnType, right) {
2467
+ return IsAny(right) ? ExtendsTrue(inferred) : IsUnknown(right) ? ExtendsTrue(inferred) : IsFunction2(right) ? Match3(ExtendsParameters(inferred, parameters, right["parameters"]), (inferred2) => ExtendsReturnType(inferred2, returnType, right["returnType"]), () => ExtendsFalse()) : ExtendsFalse();
2468
+ }
2469
+
2470
+ // ../../node_modules/.pnpm/typebox@1.1.39/node_modules/typebox/build/type/extends/integer.mjs
2471
+ function ExtendsInteger(inferred, left, right) {
2472
+ return IsInteger2(right) ? ExtendsTrue(inferred) : IsNumber2(right) ? ExtendsTrue(inferred) : ExtendsRight(inferred, left, right);
2473
+ }
2474
+
2475
+ // ../../node_modules/.pnpm/typebox@1.1.39/node_modules/typebox/build/type/extends/intersect.mjs
2476
+ function ExtendsIntersect(inferred, left, right) {
2477
+ const evaluated = EvaluateIntersect(left);
2478
+ return ExtendsLeft(inferred, evaluated, right);
2479
+ }
2480
+
2481
+ // ../../node_modules/.pnpm/typebox@1.1.39/node_modules/typebox/build/type/extends/iterator.mjs
2482
+ function ExtendsIterator(inferred, left, right) {
2483
+ return IsIterator2(right) ? ExtendsLeft(inferred, left, right.iteratorItems) : ExtendsRight(inferred, Iterator(left), right);
2484
+ }
2485
+
2486
+ // ../../node_modules/.pnpm/typebox@1.1.39/node_modules/typebox/build/type/extends/literal.mjs
2487
+ function ExtendsLiteralValue(inferred, left, right) {
2488
+ return left === right ? ExtendsTrue(inferred) : ExtendsFalse();
2489
+ }
2490
+ function ExtendsLiteralBigInt(inferred, left, right) {
2491
+ return IsLiteral(right) ? ExtendsLiteralValue(inferred, left, right.const) : IsBigInt2(right) ? ExtendsTrue(inferred) : ExtendsRight(inferred, Literal(left), right);
2492
+ }
2493
+ function ExtendsLiteralBoolean(inferred, left, right) {
2494
+ return IsLiteral(right) ? ExtendsLiteralValue(inferred, left, right.const) : IsBoolean2(right) ? ExtendsTrue(inferred) : ExtendsRight(inferred, Literal(left), right);
2495
+ }
2496
+ function ExtendsLiteralNumber(inferred, left, right) {
2497
+ return IsLiteral(right) ? ExtendsLiteralValue(inferred, left, right.const) : IsNumber2(right) ? ExtendsTrue(inferred) : ExtendsRight(inferred, Literal(left), right);
2498
+ }
2499
+ function ExtendsLiteralString(inferred, left, right) {
2500
+ return IsLiteral(right) ? ExtendsLiteralValue(inferred, left, right.const) : IsString2(right) ? ExtendsTrue(inferred) : ExtendsRight(inferred, Literal(left), right);
2501
+ }
2502
+ function ExtendsLiteral(inferred, left, right) {
2503
+ return guard_exports.IsBigInt(left.const) ? ExtendsLiteralBigInt(inferred, left.const, right) : guard_exports.IsBoolean(left.const) ? ExtendsLiteralBoolean(inferred, left.const, right) : guard_exports.IsNumber(left.const) ? ExtendsLiteralNumber(inferred, left.const, right) : guard_exports.IsString(left.const) ? ExtendsLiteralString(inferred, left.const, right) : Unreachable();
2504
+ }
2505
+
2506
+ // ../../node_modules/.pnpm/typebox@1.1.39/node_modules/typebox/build/type/extends/never.mjs
2507
+ function ExtendsNever(inferred, left, right) {
2508
+ return IsInfer(right) ? ExtendsRight(inferred, left, right) : ExtendsTrue(inferred);
2509
+ }
2510
+
2511
+ // ../../node_modules/.pnpm/typebox@1.1.39/node_modules/typebox/build/type/extends/null.mjs
2512
+ function ExtendsNull(inferred, left, right) {
2513
+ return IsNull2(right) ? ExtendsTrue(inferred) : ExtendsRight(inferred, left, right);
2514
+ }
2515
+
2516
+ // ../../node_modules/.pnpm/typebox@1.1.39/node_modules/typebox/build/type/extends/number.mjs
2517
+ function ExtendsNumber(inferred, left, right) {
2518
+ return IsNumber2(right) ? ExtendsTrue(inferred) : ExtendsRight(inferred, left, right);
2519
+ }
2520
+
2521
+ // ../../node_modules/.pnpm/typebox@1.1.39/node_modules/typebox/build/type/extends/object.mjs
2522
+ function ExtendsPropertyOptional(inferred, left, right) {
2523
+ return IsOptional(left) ? IsOptional(right) ? ExtendsTrue(inferred) : ExtendsFalse() : ExtendsTrue(inferred);
2524
+ }
2525
+ function ExtendsProperty(inferred, left, right) {
2526
+ return (
2527
+ // Right TInfer<TNever> is TExtendsFalse
2528
+ IsInfer(right) && IsNever(right.extends) ? ExtendsFalse() : Match3(ExtendsLeft(inferred, left, right), (inferred2) => ExtendsPropertyOptional(inferred2, left, right), () => ExtendsFalse())
2529
+ );
2530
+ }
2531
+ function ExtractInferredProperties(keys, properties) {
2532
+ return keys.reduce((result, key) => {
2533
+ return key in properties ? IsExtendsTrueLike(properties[key]) ? { ...result, ...properties[key].inferred } : Unreachable() : Unreachable();
2534
+ }, {});
2535
+ }
2536
+ function ExtendsPropertiesComparer(inferred, left, right) {
2537
+ const properties = {};
2538
+ for (const rightKey of guard_exports.Keys(right)) {
2539
+ properties[rightKey] = rightKey in left ? ExtendsProperty({}, left[rightKey], right[rightKey]) : IsOptional(right[rightKey]) ? IsInfer(right[rightKey]) ? ExtendsTrue(memory_exports.Assign(inferred, { [right[rightKey].name]: right[rightKey].extends })) : ExtendsTrue(inferred) : ExtendsFalse();
2540
+ }
2541
+ const checked = guard_exports.Values(properties).every((result) => IsExtendsTrueLike(result));
2542
+ const extracted = checked ? ExtractInferredProperties(guard_exports.Keys(properties), properties) : {};
2543
+ return checked ? ExtendsTrue(extracted) : ExtendsFalse();
2544
+ }
2545
+ function ExtendsProperties(inferred, left, right) {
2546
+ const compared = ExtendsPropertiesComparer(inferred, left, right);
2547
+ return IsExtendsTrueLike(compared) ? ExtendsTrue(memory_exports.Assign(inferred, compared.inferred)) : ExtendsFalse();
2548
+ }
2549
+ function ExtendsObjectToObject(inferred, left, right) {
2550
+ return ExtendsProperties(inferred, left, right);
2551
+ }
2552
+ function ExtendsObject(inferred, left, right) {
2553
+ return IsObject2(right) ? ExtendsObjectToObject(inferred, left, right.properties) : ExtendsRight(inferred, _Object_(left), right);
2554
+ }
2555
+
2556
+ // ../../node_modules/.pnpm/typebox@1.1.39/node_modules/typebox/build/type/extends/promise.mjs
2557
+ function ExtendsPromise(inferred, left, right) {
2558
+ return IsPromise(right) ? ExtendsLeft(inferred, left, right.item) : ExtendsRight(inferred, _Promise_(left), right);
2559
+ }
2560
+
2561
+ // ../../node_modules/.pnpm/typebox@1.1.39/node_modules/typebox/build/type/extends/string.mjs
2562
+ function ExtendsString(inferred, left, right) {
2563
+ return IsString2(right) ? ExtendsTrue(inferred) : ExtendsRight(inferred, left, right);
2564
+ }
2565
+
2566
+ // ../../node_modules/.pnpm/typebox@1.1.39/node_modules/typebox/build/type/extends/symbol.mjs
2567
+ function ExtendsSymbol(inferred, left, right) {
2568
+ return IsSymbol2(right) ? ExtendsTrue(inferred) : ExtendsRight(inferred, left, right);
2569
+ }
2570
+
2571
+ // ../../node_modules/.pnpm/typebox@1.1.39/node_modules/typebox/build/type/extends/template_literal.mjs
2572
+ function ExtendsTemplateLiteral(inferred, left, right) {
2573
+ const decoded = TemplateLiteralDecode(left);
2574
+ return ExtendsLeft(inferred, decoded, right);
2575
+ }
2576
+
2577
+ // ../../node_modules/.pnpm/typebox@1.1.39/node_modules/typebox/build/type/extends/inference.mjs
2578
+ function Inferrable(name, type) {
2579
+ return memory_exports.Create({ "~kind": "Inferrable" }, { name, type }, {});
2580
+ }
2581
+ function IsInferable(value) {
2582
+ return guard_exports.IsObject(value) && guard_exports.HasPropertyKey(value, "~kind") && guard_exports.HasPropertyKey(value, "name") && guard_exports.HasPropertyKey(value, "type") && guard_exports.IsEqual(value["~kind"], "Inferrable") && guard_exports.IsString(value.name) && guard_exports.IsObject(value.type);
2583
+ }
2584
+ function TryRestInferable(type) {
2585
+ return IsRest(type) ? IsInfer(type.items) ? IsArray2(type.items.extends) ? Inferrable(type.items.name, type.items.extends.items) : IsUnknown(type.items.extends) ? Inferrable(type.items.name, type.items.extends) : void 0 : Unreachable() : void 0;
2586
+ }
2587
+ function TryInferable(type) {
2588
+ return IsInfer(type) ? Inferrable(type.name, type.extends) : void 0;
2589
+ }
2590
+ function TryInferResults(rest, right, result = []) {
2591
+ return guard_exports.TakeLeft(rest, (head, tail) => Match3(ExtendsLeft({}, head, right), () => TryInferResults(tail, right, [...result, head]), () => void 0), () => result);
2592
+ }
2593
+ function InferTupleResult(inferred, name, left, right) {
2594
+ const results = TryInferResults(left, right);
2595
+ return guard_exports.IsArray(results) ? ExtendsTrue(memory_exports.Assign(inferred, { [name]: Tuple(results) })) : ExtendsFalse();
2596
+ }
2597
+ function InferUnionResult(inferred, name, left, right) {
2598
+ const results = TryInferResults(left, right);
2599
+ return guard_exports.IsArray(results) ? ExtendsTrue(memory_exports.Assign(inferred, { [name]: Union(results) })) : ExtendsFalse();
2600
+ }
2601
+
2602
+ // ../../node_modules/.pnpm/typebox@1.1.39/node_modules/typebox/build/type/extends/tuple.mjs
2603
+ function Reverse(types) {
2604
+ return [...types].reverse();
2605
+ }
2606
+ function ApplyReverse(types, reversed) {
2607
+ return reversed ? Reverse(types) : types;
2608
+ }
2609
+ function Reversed(types) {
2610
+ const first = types.length > 0 ? types[0] : void 0;
2611
+ const inferrable = IsSchema(first) ? TryRestInferable(first) : void 0;
2612
+ return IsSchema(inferrable);
2613
+ }
2614
+ function ElementsCompare(inferred, reversed, left, leftRest, right, rightRest) {
2615
+ return Match3(ExtendsLeft(inferred, left, right), (checkInferred) => Elements(checkInferred, reversed, leftRest, rightRest), () => ExtendsFalse());
2616
+ }
2617
+ function ElementsLeft(inferred, reversed, leftRest, right, rightRest) {
2618
+ const inferable = TryRestInferable(right);
2619
+ return (
2620
+ // Rest Inferrable Right Means we delegate to TInferTupleResult to Generate a Result
2621
+ IsInferable(inferable) ? InferTupleResult(inferred, inferable["name"], ApplyReverse(leftRest, reversed), inferable["type"]) : guard_exports.TakeLeft(leftRest, (head, tail) => ElementsCompare(inferred, reversed, head, tail, right, rightRest), () => ExtendsFalse())
2622
+ );
2623
+ }
2624
+ function ElementsRight(inferred, reversed, leftRest, rightRest) {
2625
+ return guard_exports.TakeLeft(rightRest, (head, tail) => ElementsLeft(inferred, reversed, leftRest, head, tail), () => guard_exports.IsEqual(leftRest.length, 0) ? ExtendsTrue(inferred) : ExtendsFalse());
2626
+ }
2627
+ function Elements(inferred, reversed, leftRest, rightRest) {
2628
+ return ElementsRight(inferred, reversed, leftRest, rightRest);
2629
+ }
2630
+ function ExtendsTupleToTuple(inferred, left, right) {
2631
+ const instantiatedRight = InstantiateElements(inferred, { callstack: [] }, right);
2632
+ const reversed = Reversed(instantiatedRight);
2633
+ return Elements(inferred, reversed, ApplyReverse(left, reversed), ApplyReverse(instantiatedRight, reversed));
2634
+ }
2635
+ function ExtendsTupleToArray(inferred, left, right) {
2636
+ const inferrable = TryInferable(right);
2637
+ return IsInferable(inferrable) ? InferUnionResult(inferred, inferrable["name"], left, inferrable["type"]) : guard_exports.TakeLeft(left, (head, tail) => Match3(ExtendsLeft(inferred, head, right), (inferred2) => ExtendsTupleToArray(inferred2, tail, right), () => ExtendsFalse()), () => ExtendsTrue(inferred));
2638
+ }
2639
+ function ExtendsTuple(inferred, left, right) {
2640
+ const instantiatedLeft = InstantiateElements(inferred, { callstack: [] }, left);
2641
+ return IsTuple(right) ? ExtendsTupleToTuple(inferred, instantiatedLeft, right.items) : IsArray2(right) ? ExtendsTupleToArray(inferred, instantiatedLeft, right.items) : ExtendsRight(inferred, Tuple(instantiatedLeft), right);
2642
+ }
2643
+
2644
+ // ../../node_modules/.pnpm/typebox@1.1.39/node_modules/typebox/build/type/extends/undefined.mjs
2645
+ function ExtendsUndefined(inferred, left, right) {
2646
+ return IsVoid(right) ? ExtendsTrue(inferred) : IsUndefined2(right) ? ExtendsTrue(inferred) : ExtendsRight(inferred, left, right);
2647
+ }
2648
+
2649
+ // ../../node_modules/.pnpm/typebox@1.1.39/node_modules/typebox/build/type/extends/union.mjs
2650
+ function ExtendsUnionSome(inferred, type, unionTypes) {
2651
+ return guard_exports.TakeLeft(unionTypes, (head, tail) => Match3(ExtendsLeft(inferred, type, head), (inferred2) => ExtendsTrue(inferred2), () => ExtendsUnionSome(inferred, type, tail)), () => ExtendsFalse());
2652
+ }
2653
+ function ExtendsUnionLeft(inferred, left, right) {
2654
+ return guard_exports.TakeLeft(left, (head, tail) => Match3(ExtendsUnionSome(inferred, head, right), (inferred2) => ExtendsUnionLeft(inferred2, tail, right), () => ExtendsFalse()), () => ExtendsTrue(inferred));
2655
+ }
2656
+ function ExtendsUnion2(inferred, left, right) {
2657
+ const inferrable = TryInferable(right);
2658
+ return IsInferable(inferrable) ? InferUnionResult(inferred, inferrable.name, left, inferrable.type) : IsUnion(right) ? ExtendsUnionLeft(inferred, left, right.anyOf) : ExtendsUnionLeft(inferred, left, [right]);
2659
+ }
2660
+
2661
+ // ../../node_modules/.pnpm/typebox@1.1.39/node_modules/typebox/build/type/extends/unknown.mjs
2662
+ function ExtendsUnknown(inferred, left, right) {
2663
+ return IsInfer(right) ? ExtendsRight(inferred, left, right) : IsAny(right) ? ExtendsTrue(inferred) : IsUnknown(right) ? ExtendsTrue(inferred) : ExtendsFalse();
2664
+ }
2665
+
2666
+ // ../../node_modules/.pnpm/typebox@1.1.39/node_modules/typebox/build/type/extends/void.mjs
2667
+ function ExtendsVoid(inferred, left, right) {
2668
+ return IsVoid(right) ? ExtendsTrue(inferred) : ExtendsRight(inferred, left, right);
2669
+ }
2670
+
2671
+ // ../../node_modules/.pnpm/typebox@1.1.39/node_modules/typebox/build/type/extends/extends_left.mjs
2672
+ function ExtendsLeft(inferred, left, right) {
2673
+ return IsAny(left) ? ExtendsAny(inferred, left, right) : IsArray2(left) ? ExtendsArray(inferred, left, left.items, right) : IsAsyncIterator2(left) ? ExtendsAsyncIterator(inferred, left.iteratorItems, right) : IsBigInt2(left) ? ExtendsBigInt(inferred, left, right) : IsBoolean2(left) ? ExtendsBoolean(inferred, left, right) : IsConstructor2(left) ? ExtendsConstructor(inferred, left.parameters, left.instanceType, right) : IsEnum(left) ? ExtendsEnum(inferred, left, right) : IsFunction2(left) ? ExtendsFunction(inferred, left.parameters, left.returnType, right) : IsInteger2(left) ? ExtendsInteger(inferred, left, right) : IsIntersect(left) ? ExtendsIntersect(inferred, left.allOf, right) : IsIterator2(left) ? ExtendsIterator(inferred, left.iteratorItems, right) : IsLiteral(left) ? ExtendsLiteral(inferred, left, right) : IsNever(left) ? ExtendsNever(inferred, left, right) : IsNull2(left) ? ExtendsNull(inferred, left, right) : IsNumber2(left) ? ExtendsNumber(inferred, left, right) : IsObject2(left) ? ExtendsObject(inferred, left.properties, right) : IsPromise(left) ? ExtendsPromise(inferred, left.item, right) : IsString2(left) ? ExtendsString(inferred, left, right) : IsSymbol2(left) ? ExtendsSymbol(inferred, left, right) : IsTemplateLiteral(left) ? ExtendsTemplateLiteral(inferred, left.pattern, right) : IsTuple(left) ? ExtendsTuple(inferred, left.items, right) : IsUndefined2(left) ? ExtendsUndefined(inferred, left, right) : IsUnion(left) ? ExtendsUnion2(inferred, left.anyOf, right) : IsUnknown(left) ? ExtendsUnknown(inferred, left, right) : IsVoid(left) ? ExtendsVoid(inferred, left, right) : ExtendsFalse();
2674
+ }
2675
+
2676
+ // ../../node_modules/.pnpm/typebox@1.1.39/node_modules/typebox/build/type/engine/interface/instantiate.mjs
2677
+ function InterfaceOperation(heritage, properties) {
2678
+ const result = EvaluateIntersect([...heritage, _Object_(properties)]);
2679
+ return result;
2680
+ }
2681
+ function InterfaceAction(heritage, properties, options) {
2682
+ const result = CanInstantiate(heritage) ? memory_exports.Update(InterfaceOperation(heritage, properties), {}, options) : InterfaceDeferred(heritage, properties, options);
2683
+ return result;
2684
+ }
2685
+ function InterfaceInstantiate(context, state, heritage, properties, options) {
2686
+ const instantiatedHeritage = InstantiateTypes(context, state, heritage);
2687
+ const instantiatedProperties = InstantiateProperties(context, state, properties);
2688
+ return InterfaceAction(instantiatedHeritage, instantiatedProperties, options);
2689
+ }
2690
+
2691
+ // ../../node_modules/.pnpm/typebox@1.1.39/node_modules/typebox/build/type/action/interface.mjs
2692
+ function InterfaceDeferred(heritage, properties, options = {}) {
2693
+ return Deferred("Interface", [heritage, properties], options);
2694
+ }
2695
+ function IsInterfaceDeferred(value) {
2696
+ return IsSchema(value) && guard_exports.HasPropertyKey(value, "action") && guard_exports.IsEqual(value.action, "Interface");
2697
+ }
2698
+ function Interface(heritage, properties, options = {}) {
2699
+ return InterfaceAction(heritage, properties, options);
2700
+ }
2701
+
2702
+ // ../../node_modules/.pnpm/typebox@1.1.39/node_modules/typebox/build/type/engine/cyclic/check.mjs
2703
+ function FromRef(stack, context, ref) {
2704
+ return stack.includes(ref) ? true : FromType3([...stack, ref], context, context[ref]);
2705
+ }
2706
+ function FromProperties(stack, context, properties) {
2707
+ const types = PropertyValues(properties);
2708
+ return FromTypes2(stack, context, types);
2709
+ }
2710
+ function FromTypes2(stack, context, types) {
2711
+ return guard_exports.TakeLeft(types, (left, right) => FromType3(stack, context, left) ? true : FromTypes2(stack, context, right), () => false);
2712
+ }
2713
+ function FromType3(stack, context, type) {
2714
+ return IsRef(type) ? FromRef(stack, context, type.$ref) : IsArray2(type) ? FromType3(stack, context, type.items) : IsAsyncIterator2(type) ? FromType3(stack, context, type.iteratorItems) : IsConstructor2(type) ? FromTypes2(stack, context, [...type.parameters, type.instanceType]) : IsFunction2(type) ? FromTypes2(stack, context, [...type.parameters, type.returnType]) : IsInterfaceDeferred(type) ? FromProperties(stack, context, type.parameters[1]) : IsIntersect(type) ? FromTypes2(stack, context, type.allOf) : IsIterator2(type) ? FromType3(stack, context, type.iteratorItems) : IsObject2(type) ? FromProperties(stack, context, type.properties) : IsPromise(type) ? FromType3(stack, context, type.item) : IsUnion(type) ? FromTypes2(stack, context, type.anyOf) : IsTuple(type) ? FromTypes2(stack, context, type.items) : IsRecord(type) ? FromType3(stack, context, RecordValue(type)) : false;
2715
+ }
2716
+ function CyclicCheck(stack, context, type) {
2717
+ const result = FromType3(stack, context, type);
2718
+ return result;
2719
+ }
2720
+
2721
+ // ../../node_modules/.pnpm/typebox@1.1.39/node_modules/typebox/build/type/engine/cyclic/candidates.mjs
2722
+ function ResolveCandidateKeys(context, keys) {
2723
+ return keys.reduce((result, left) => {
2724
+ return left in context ? CyclicCheck([left], context, context[left]) ? [...result, left] : result : Unreachable();
2725
+ }, []);
2726
+ }
2727
+ function CyclicCandidates(context) {
2728
+ const keys = PropertyKeys(context);
2729
+ const result = ResolveCandidateKeys(context, keys);
2730
+ return result;
2731
+ }
2732
+
2733
+ // ../../node_modules/.pnpm/typebox@1.1.39/node_modules/typebox/build/type/engine/cyclic/dependencies.mjs
2734
+ function FromRef2(context, ref, result) {
2735
+ return result.includes(ref) ? result : ref in context ? FromType4(context, context[ref], [...result, ref]) : Unreachable();
2736
+ }
2737
+ function FromProperties2(context, properties, result) {
2738
+ const types = PropertyValues(properties);
2739
+ return FromTypes3(context, types, result);
2740
+ }
2741
+ function FromTypes3(context, types, result) {
2742
+ return types.reduce((result2, left) => {
2743
+ return FromType4(context, left, result2);
2744
+ }, result);
2745
+ }
2746
+ function FromType4(context, type, result) {
2747
+ return IsRef(type) ? FromRef2(context, type.$ref, result) : IsArray2(type) ? FromType4(context, type.items, result) : IsAsyncIterator2(type) ? FromType4(context, type.iteratorItems, result) : IsConstructor2(type) ? FromTypes3(context, [...type.parameters, type.instanceType], result) : IsFunction2(type) ? FromTypes3(context, [...type.parameters, type.returnType], result) : IsInterfaceDeferred(type) ? FromProperties2(context, type.parameters[1], result) : IsIntersect(type) ? FromTypes3(context, type.allOf, result) : IsIterator2(type) ? FromType4(context, type.iteratorItems, result) : IsObject2(type) ? FromProperties2(context, type.properties, result) : IsPromise(type) ? FromType4(context, type.item, result) : IsUnion(type) ? FromTypes3(context, type.anyOf, result) : IsTuple(type) ? FromTypes3(context, type.items, result) : IsRecord(type) ? FromType4(context, RecordValue(type), result) : result;
2748
+ }
2749
+ function CyclicDependencies(context, key, type) {
2750
+ const result = FromType4(context, type, [key]);
2751
+ return result;
2752
+ }
2753
+
2754
+ // ../../node_modules/.pnpm/typebox@1.1.39/node_modules/typebox/build/type/engine/cyclic/extends.mjs
2755
+ function FromRef3(_ref) {
2756
+ return Any();
2757
+ }
2758
+ function FromProperties3(properties) {
2759
+ return guard_exports.Keys(properties).reduce((result, key) => {
2760
+ return { ...result, [key]: FromType5(properties[key]) };
2761
+ }, {});
2762
+ }
2763
+ function FromTypes4(types) {
2764
+ return types.reduce((result, left) => {
2765
+ return [...result, FromType5(left)];
2766
+ }, []);
2767
+ }
2768
+ function FromType5(type) {
2769
+ return IsRef(type) ? FromRef3(type.$ref) : IsArray2(type) ? _Array_(FromType5(type.items), ArrayOptions(type)) : IsAsyncIterator2(type) ? AsyncIterator(FromType5(type.iteratorItems)) : IsConstructor2(type) ? Constructor(FromTypes4(type.parameters), FromType5(type.instanceType)) : IsFunction2(type) ? _Function_(FromTypes4(type.parameters), FromType5(type.returnType)) : IsIntersect(type) ? Intersect(FromTypes4(type.allOf)) : IsIterator2(type) ? Iterator(FromType5(type.iteratorItems)) : IsObject2(type) ? _Object_(FromProperties3(type.properties)) : IsPromise(type) ? _Promise_(FromType5(type.item)) : IsRecord(type) ? Record(RecordKey(type), FromType5(RecordValue(type))) : IsUnion(type) ? Union(FromTypes4(type.anyOf)) : IsTuple(type) ? Tuple(FromTypes4(type.items)) : type;
2770
+ }
2771
+ function CyclicAnyFromParameters(defs, ref) {
2772
+ return ref in defs ? FromType5(defs[ref]) : Unknown();
2773
+ }
2774
+ function CyclicExtends(type) {
2775
+ return CyclicAnyFromParameters(type.$defs, type.$ref);
2776
+ }
2777
+
2778
+ // ../../node_modules/.pnpm/typebox@1.1.39/node_modules/typebox/build/type/engine/cyclic/instantiate.mjs
2779
+ function CyclicInterface(context, heritage, properties) {
2780
+ const instantiatedHeritage = InstantiateTypes(context, { callstack: [] }, heritage);
2781
+ const instantiatedProperties = InstantiateProperties({}, { callstack: [] }, properties);
2782
+ const evaluatedInterface = EvaluateIntersect([...instantiatedHeritage, _Object_(instantiatedProperties)]);
2783
+ return evaluatedInterface;
2784
+ }
2785
+ function CyclicDefinitions(context, dependencies) {
2786
+ const keys = guard_exports.Keys(context).filter((key) => dependencies.includes(key));
2787
+ return keys.reduce((result, key) => {
2788
+ const type = context[key];
2789
+ const instantiatedType = IsInterfaceDeferred(type) ? CyclicInterface(context, type.parameters[0], type.parameters[1]) : type;
2790
+ return { ...result, [key]: instantiatedType };
2791
+ }, {});
2792
+ }
2793
+ function InstantiateCyclic(context, ref, type) {
2794
+ const dependencies = CyclicDependencies(context, ref, type);
2795
+ const definitions = CyclicDefinitions(context, dependencies);
2796
+ const result = Cyclic(definitions, ref);
2797
+ return result;
2798
+ }
2799
+
2800
+ // ../../node_modules/.pnpm/typebox@1.1.39/node_modules/typebox/build/type/engine/cyclic/target.mjs
2801
+ function Resolve(defs, ref) {
2802
+ return ref in defs ? IsRef(defs[ref]) ? Resolve(defs, defs[ref].$ref) : defs[ref] : Never();
2803
+ }
2804
+ function CyclicTarget(defs, ref) {
2805
+ const result = Resolve(defs, ref);
2806
+ return result;
2807
+ }
2808
+
2809
+ // ../../node_modules/.pnpm/typebox@1.1.39/node_modules/typebox/build/type/extends/extends.mjs
2810
+ function Canonical(type) {
2811
+ return IsCyclic(type) ? CyclicExtends(type) : IsUnsafe(type) ? Unknown() : type;
2812
+ }
2813
+ function Extends2(inferred, left, right) {
2814
+ const canonicalLeft = Canonical(left);
2815
+ const canonicalRight = Canonical(right);
2816
+ return ExtendsLeft(inferred, canonicalLeft, canonicalRight);
2817
+ }
2818
+
2819
+ // ../../node_modules/.pnpm/typebox@1.1.39/node_modules/typebox/build/type/engine/evaluate/compare.mjs
2820
+ var ResultEqual = "equal";
2821
+ var ResultDisjoint = "disjoint";
2822
+ var ResultLeftInside = "left-inside";
2823
+ var ResultRightInside = "right-inside";
2824
+ function Compare(left, right) {
2825
+ const extendsCheck = [
2826
+ IsUnknown(left) ? result_exports.ExtendsFalse() : Extends2({}, left, right),
2827
+ IsUnknown(left) ? result_exports.ExtendsTrue({}) : Extends2({}, right, left)
2828
+ ];
2829
+ return result_exports.IsExtendsTrueLike(extendsCheck[0]) && result_exports.IsExtendsTrueLike(extendsCheck[1]) ? ResultEqual : result_exports.IsExtendsTrueLike(extendsCheck[0]) && result_exports.IsExtendsFalse(extendsCheck[1]) ? ResultLeftInside : result_exports.IsExtendsFalse(extendsCheck[0]) && result_exports.IsExtendsTrueLike(extendsCheck[1]) ? ResultRightInside : ResultDisjoint;
2830
+ }
2831
+
2832
+ // ../../node_modules/.pnpm/typebox@1.1.39/node_modules/typebox/build/type/engine/evaluate/broaden.mjs
2833
+ function BroadFilter(type, types) {
2834
+ return types.filter((left) => {
2835
+ return Compare(type, left) === ResultRightInside ? false : true;
2836
+ });
2837
+ }
2838
+ function IsBroadestType(type, types) {
2839
+ const result = types.some((left) => {
2840
+ const result2 = Compare(type, left);
2841
+ return guard_exports.IsEqual(result2, ResultLeftInside) || guard_exports.IsEqual(result2, ResultEqual);
2842
+ });
2843
+ return guard_exports.IsEqual(result, false);
2844
+ }
2845
+ function BroadenType(type, types) {
2846
+ const evaluated = EvaluateType(type);
2847
+ return IsAny(evaluated) ? [evaluated] : IsBroadestType(evaluated, types) ? [...BroadFilter(evaluated, types), evaluated] : types;
2848
+ }
2849
+ function BroadenTypes(types) {
2850
+ return types.reduce((result, left) => {
2851
+ return IsObject2(left) ? [...result, left] : (
2852
+ // push
2853
+ IsNever(left) ? result : (
2854
+ // ignore
2855
+ BroadenType(left, result)
2856
+ )
2857
+ );
2858
+ }, []);
2859
+ }
2860
+ function Broaden(types) {
2861
+ const broadened = BroadenTypes(types);
2862
+ const flattened = Flatten(broadened);
2863
+ const result = flattened.length === 0 ? Never() : flattened.length === 1 ? flattened[0] : Union(flattened);
2864
+ return result;
2865
+ }
2866
+
2867
+ // ../../node_modules/.pnpm/typebox@1.1.39/node_modules/typebox/build/type/engine/evaluate/instantiate.mjs
2868
+ function EvaluateAction(type, options) {
2869
+ const result = memory_exports.Update(EvaluateType(type), {}, options);
2870
+ return result;
2871
+ }
2872
+ function EvaluateInstantiate(context, state, type, options) {
2873
+ const instantiatedType = InstantiateType(context, state, type);
2874
+ return EvaluateAction(instantiatedType, options);
2875
+ }
2876
+
2877
+ // ../../node_modules/.pnpm/typebox@1.1.39/node_modules/typebox/build/type/engine/call/distribute_arguments.mjs
2878
+ function CollectDistributionNames(expression, result = []) {
2879
+ return (
2880
+ // Conditional
2881
+ IsDeferred(expression) && guard_exports.IsEqual(expression.action, "Conditional") ? IsRef(expression.parameters[0]) ? CollectDistributionNames(expression.parameters[2], CollectDistributionNames(expression.parameters[3], [...result, expression.parameters[0]["$ref"]])) : CollectDistributionNames(expression.parameters[2], CollectDistributionNames(expression.parameters[3], result)) : IsDeferred(expression) && guard_exports.IsEqual(expression.action, "Mapped") ? IsDeferred(expression.parameters[1]) && guard_exports.IsEqual(expression.parameters[1].action, "KeyOf") && IsRef(expression.parameters[1].parameters[0]) ? [...result, expression.parameters[1].parameters[0]["$ref"]] : result : result
2882
+ );
2883
+ }
2884
+ function BuildDistributionArray(parameters, names) {
2885
+ return parameters.reduce((result, left) => [...result, names.includes(left.name)], []);
2886
+ }
2887
+ function ZipDistributionArray(arguments_, distributionArray, result = []) {
2888
+ return guard_exports.TakeLeft(arguments_, (argumentLeft, argumentRight) => guard_exports.TakeLeft(distributionArray, (booleanLeft, booleanRight) => ZipDistributionArray(argumentRight, booleanRight, [...result, [booleanLeft, argumentLeft]]), () => result), () => result);
2889
+ }
2890
+ function Expand(type) {
2891
+ return IsUnion(type) ? [...type.anyOf] : [type];
2892
+ }
2893
+ function Append(current, type) {
2894
+ return current.reduce((result, left) => [...result, [...left, type]], []);
2895
+ }
2896
+ function Cross(current, variants) {
2897
+ return variants.reduce((result, left) => {
2898
+ return [...result, ...Append(current, left)];
2899
+ }, []);
2900
+ }
2901
+ function Distribute2(zipped) {
2902
+ return zipped.reduce((result, left) => {
2903
+ return guard_exports.IsEqual(left[0], true) ? Cross(result, Expand(left[1])) : Cross(result, [left[1]]);
2904
+ }, [[]]);
2905
+ }
2906
+ function DistributeArguments(parameters, arguments_, expression) {
2907
+ const distributionNames = CollectDistributionNames(expression);
2908
+ const distributionArray = BuildDistributionArray(parameters, distributionNames);
2909
+ const zippedArguments = ZipDistributionArray(arguments_, distributionArray);
2910
+ return IsDeferred(expression) && guard_exports.IsEqual(expression.action, "Conditional") ? Distribute2(zippedArguments) : IsDeferred(expression) && guard_exports.IsEqual(expression.action, "Mapped") ? Distribute2(zippedArguments) : [arguments_];
2911
+ }
2912
+
2913
+ // ../../node_modules/.pnpm/typebox@1.1.39/node_modules/typebox/build/type/engine/call/resolve_target.mjs
2914
+ function FromNotResolvable() {
2915
+ return ["(not-resolvable)", Never()];
2916
+ }
2917
+ function FromNotGeneric() {
2918
+ return ["(not-generic)", Never()];
2919
+ }
2920
+ function FromGeneric(name, parameters, expression) {
2921
+ return [name, Generic(parameters, expression)];
2922
+ }
2923
+ function FromRef4(context, ref, arguments_) {
2924
+ return ref in context ? FromType6(context, ref, context[ref], arguments_) : FromNotResolvable();
2925
+ }
2926
+ function FromType6(context, name, target, arguments_) {
2927
+ return IsGeneric(target) ? FromGeneric(name, target.parameters, target.expression) : IsRef(target) ? FromRef4(context, target.$ref, arguments_) : FromNotGeneric();
2928
+ }
2929
+ function ResolveTarget(context, target, arguments_) {
2930
+ return FromType6(context, "(anonymous)", target, arguments_);
2931
+ }
2932
+
2933
+ // ../../node_modules/.pnpm/typebox@1.1.39/node_modules/typebox/build/type/engine/call/resolve_arguments.mjs
2934
+ function AssertArgumentExtends(name, type, extends_) {
2935
+ if (IsInfer(type) || IsCall(type) || result_exports.IsExtendsTrueLike(Extends2({}, type, extends_)))
2936
+ return;
2937
+ const cause = { parameter: name, expect: extends_, actual: type };
2938
+ throw new Error(`Argument for parameter ${name} does not satisfy constraint`, { cause });
2939
+ }
2940
+ function BindArgument(context, state, name, extends_, type) {
2941
+ const instantiatedArgument = InstantiateType(context, state, type);
2942
+ AssertArgumentExtends(name, instantiatedArgument, extends_);
2943
+ return memory_exports.Assign(context, { [name]: instantiatedArgument });
2944
+ }
2945
+ function BindArguments(context, state, parameterLeft, parameterRight, arguments_) {
2946
+ const instantiatedExtends = InstantiateType(context, state, parameterLeft.extends);
2947
+ const instantiatedEquals = InstantiateType(context, state, parameterLeft.equals);
2948
+ return guard_exports.TakeLeft(arguments_, (left, right) => BindParameters(BindArgument(context, state, parameterLeft["name"], instantiatedExtends, left), state, parameterRight, right), () => BindParameters(BindArgument(context, state, parameterLeft["name"], instantiatedExtends, instantiatedEquals), state, parameterRight, []));
2949
+ }
2950
+ function BindParameters(context, state, parameters, arguments_) {
2951
+ return guard_exports.TakeLeft(parameters, (left, right) => BindArguments(context, state, left, right, arguments_), () => context);
2952
+ }
2953
+ function ResolveArgumentsContext(context, state, parameters, arguments_) {
2954
+ return BindParameters(context, state, parameters, arguments_);
2955
+ }
2956
+
2957
+ // ../../node_modules/.pnpm/typebox@1.1.39/node_modules/typebox/build/type/engine/call/instantiate.mjs
2958
+ function Peek(state) {
2959
+ const result = guard_exports.IsGreaterThan(state.callstack.length, 0) ? state.callstack[state.callstack.length - 1] : "";
2960
+ return result;
2961
+ }
2962
+ function IsTailCall(state, name) {
2963
+ const result = guard_exports.IsEqual(Peek(state), name);
2964
+ return result;
2965
+ }
2966
+ function CallDispatch(context, state, target, parameters, expression, arguments_) {
2967
+ const argumentsContext = ResolveArgumentsContext(context, state, parameters, arguments_);
2968
+ const returnType = InstantiateType(argumentsContext, { callstack: [...state.callstack, target.$ref] }, expression);
2969
+ return InstantiateType(context, state, returnType);
2970
+ }
2971
+ function CallDistributed(context, state, target, parameters, expression, distributedArguments) {
2972
+ return distributedArguments.reduce((result, arguments_) => [...result, CallDispatch(context, state, target, parameters, expression, arguments_)], []);
2973
+ }
2974
+ function CallImmediate(context, state, target, parameters, expression, arguments_) {
2975
+ const distributedArguments = DistributeArguments(parameters, arguments_, expression);
2976
+ const returnTypes = CallDistributed(context, state, target, parameters, expression, distributedArguments);
2977
+ const result = guard_exports.IsEqual(returnTypes.length, 1) ? returnTypes[0] : EvaluateUnion(returnTypes);
2978
+ return result;
2979
+ }
2980
+ function CallInstantiate(context, state, target, arguments_) {
2981
+ const instantiatedArguments = InstantiateTypes(context, state, arguments_);
2982
+ const resolved = ResolveTarget(context, target, arguments_);
2983
+ const name = resolved[0];
2984
+ const type = resolved[1];
2985
+ const result = IsGeneric(type) ? IsTailCall(state, name) ? CallConstruct(Ref(name), instantiatedArguments) : CallImmediate(context, state, Ref(name), type.parameters, type.expression, instantiatedArguments) : CallConstruct(target, instantiatedArguments);
2986
+ return result;
2987
+ }
2988
+
2989
+ // ../../node_modules/.pnpm/typebox@1.1.39/node_modules/typebox/build/type/types/call.mjs
2990
+ function CallConstruct(target, arguments_) {
2991
+ return memory_exports.Create({ ["~kind"]: "Call" }, { target, arguments: arguments_ }, {});
2992
+ }
2993
+ function Call(target, arguments_) {
2994
+ return CallInstantiate({}, { callstack: [] }, target, arguments_);
2995
+ }
2996
+ function IsCall(value) {
2997
+ return IsKind(value, "Call");
2998
+ }
2999
+
3000
+ // ../../node_modules/.pnpm/typebox@1.1.39/node_modules/typebox/build/type/engine/intrinsics/mapping.mjs
3001
+ function ApplyMapping(mapping, value) {
3002
+ return mapping(value);
3003
+ }
3004
+
3005
+ // ../../node_modules/.pnpm/typebox@1.1.39/node_modules/typebox/build/type/engine/intrinsics/from_literal.mjs
3006
+ function FromLiteral3(mapping, value) {
3007
+ return guard_exports.IsString(value) ? Literal(ApplyMapping(mapping, value)) : Literal(value);
3008
+ }
3009
+
3010
+ // ../../node_modules/.pnpm/typebox@1.1.39/node_modules/typebox/build/type/engine/intrinsics/from_template_literal.mjs
3011
+ function FromTemplateLiteral(mapping, pattern) {
3012
+ const decoded = TemplateLiteralDecode(pattern);
3013
+ const result = FromType7(mapping, decoded);
3014
+ return result;
3015
+ }
3016
+
3017
+ // ../../node_modules/.pnpm/typebox@1.1.39/node_modules/typebox/build/type/engine/intrinsics/from_union.mjs
3018
+ function FromUnion2(mapping, types) {
3019
+ const result = types.map((type) => FromType7(mapping, type));
3020
+ return Union(result);
3021
+ }
3022
+
3023
+ // ../../node_modules/.pnpm/typebox@1.1.39/node_modules/typebox/build/type/engine/intrinsics/from_type.mjs
3024
+ function FromType7(mapping, type) {
3025
+ return IsLiteral(type) ? FromLiteral3(mapping, type.const) : IsTemplateLiteral(type) ? FromTemplateLiteral(mapping, type.pattern) : IsUnion(type) ? FromUnion2(mapping, type.anyOf) : type;
3026
+ }
3027
+
3028
+ // ../../node_modules/.pnpm/typebox@1.1.39/node_modules/typebox/build/type/action/capitalize.mjs
3029
+ function CapitalizeDeferred(type, options = {}) {
3030
+ return Deferred("Capitalize", [type], options);
3031
+ }
3032
+ function Capitalize(type, options = {}) {
3033
+ return CapitalizeAction(type, options);
3034
+ }
3035
+
3036
+ // ../../node_modules/.pnpm/typebox@1.1.39/node_modules/typebox/build/type/action/lowercase.mjs
3037
+ function LowercaseDeferred(type, options = {}) {
3038
+ return Deferred("Lowercase", [type], options);
3039
+ }
3040
+ function Lowercase(type, options = {}) {
3041
+ return LowercaseAction(type, options);
3042
+ }
3043
+
3044
+ // ../../node_modules/.pnpm/typebox@1.1.39/node_modules/typebox/build/type/action/uncapitalize.mjs
3045
+ function UncapitalizeDeferred(type, options = {}) {
3046
+ return Deferred("Uncapitalize", [type], options);
3047
+ }
3048
+ function Uncapitalize(type, options = {}) {
3049
+ return UncapitalizeAction(type, options);
3050
+ }
3051
+
3052
+ // ../../node_modules/.pnpm/typebox@1.1.39/node_modules/typebox/build/type/action/uppercase.mjs
3053
+ function UppercaseDeferred(type, options = {}) {
3054
+ return Deferred("Uppercase", [type], options);
3055
+ }
3056
+ function Uppercase(type, options = {}) {
3057
+ return UppercaseAction(type, options);
3058
+ }
3059
+
3060
+ // ../../node_modules/.pnpm/typebox@1.1.39/node_modules/typebox/build/type/engine/intrinsics/instantiate.mjs
3061
+ var CapitalizeMapping = (input) => input[0].toUpperCase() + input.slice(1);
3062
+ var LowercaseMapping = (input) => input.toLowerCase();
3063
+ var UncapitalizeMapping = (input) => input[0].toLowerCase() + input.slice(1);
3064
+ var UppercaseMapping = (input) => input.toUpperCase();
3065
+ function CapitalizeAction(type, options) {
3066
+ const result = CanInstantiate([type]) ? memory_exports.Update(FromType7(CapitalizeMapping, type), {}, options) : CapitalizeDeferred(type, options);
3067
+ return result;
3068
+ }
3069
+ function LowercaseAction(type, options) {
3070
+ const result = CanInstantiate([type]) ? memory_exports.Update(FromType7(LowercaseMapping, type), {}, options) : LowercaseDeferred(type, options);
3071
+ return result;
3072
+ }
3073
+ function UncapitalizeAction(type, options) {
3074
+ const result = CanInstantiate([type]) ? memory_exports.Update(FromType7(UncapitalizeMapping, type), {}, options) : UncapitalizeDeferred(type, options);
3075
+ return result;
3076
+ }
3077
+ function UppercaseAction(type, options) {
3078
+ const result = CanInstantiate([type]) ? memory_exports.Update(FromType7(UppercaseMapping, type), {}, options) : UppercaseDeferred(type, options);
3079
+ return result;
3080
+ }
3081
+ function CapitalizeInstantiate(context, state, type, options) {
3082
+ const instantiatedType = InstantiateType(context, state, type);
3083
+ return CapitalizeAction(instantiatedType, options);
3084
+ }
3085
+ function LowercaseInstantiate(context, state, type, options) {
3086
+ const instantiatedType = InstantiateType(context, state, type);
3087
+ return LowercaseAction(instantiatedType, options);
3088
+ }
3089
+ function UncapitalizeInstantiate(context, state, type, options) {
3090
+ const instantiatedType = InstantiateType(context, state, type);
3091
+ return UncapitalizeAction(instantiatedType, options);
3092
+ }
3093
+ function UppercaseInstantiate(context, state, type, options) {
3094
+ const instantiatedType = InstantiateType(context, state, type);
3095
+ return UppercaseAction(instantiatedType, options);
3096
+ }
3097
+
3098
+ // ../../node_modules/.pnpm/typebox@1.1.39/node_modules/typebox/build/type/action/conditional.mjs
3099
+ function ConditionalDeferred(left, right, true_, false_, options = {}) {
3100
+ return Deferred("Conditional", [left, right, true_, false_], options);
3101
+ }
3102
+ function Conditional(left, right, true_, false_, options = {}) {
3103
+ return ConditionalAction({}, { callstack: [] }, left, right, true_, false_, options);
3104
+ }
3105
+
3106
+ // ../../node_modules/.pnpm/typebox@1.1.39/node_modules/typebox/build/type/engine/conditional/instantiate.mjs
3107
+ function ConditionalOperation(context, state, left, right, true_, false_) {
3108
+ const extendsResult = Extends2(context, left, right);
3109
+ return result_exports.IsExtendsUnion(extendsResult) ? Union([InstantiateType(extendsResult.inferred, state, true_), InstantiateType(context, state, false_)]) : result_exports.IsExtendsTrue(extendsResult) ? InstantiateType(extendsResult.inferred, state, true_) : InstantiateType(context, state, false_);
3110
+ }
3111
+ function ConditionalAction(context, state, left, right, true_, false_, options) {
3112
+ const result = CanInstantiate([left, right]) ? memory_exports.Update(ConditionalOperation(context, state, left, right, true_, false_), {}, options) : ConditionalDeferred(left, right, true_, false_, options);
3113
+ return result;
3114
+ }
3115
+ function ConditionalInstantiate(context, state, left, right, true_, false_, options) {
3116
+ const instantiatedLeft = InstantiateType(context, state, left);
3117
+ const instantiatedRight = InstantiateType(context, state, right);
3118
+ return ConditionalAction(context, state, instantiatedLeft, instantiatedRight, true_, false_, options);
3119
+ }
3120
+
3121
+ // ../../node_modules/.pnpm/typebox@1.1.39/node_modules/typebox/build/type/action/constructor_parameters.mjs
3122
+ function ConstructorParametersDeferred(type, options = {}) {
3123
+ return Deferred("ConstructorParameters", [type], options);
3124
+ }
3125
+ function ConstructorParameters(type, options = {}) {
3126
+ return ConstructorParametersAction(type, options);
3127
+ }
3128
+
3129
+ // ../../node_modules/.pnpm/typebox@1.1.39/node_modules/typebox/build/type/engine/constructor_parameters/instantiate.mjs
3130
+ function ConstructorParametersOperation(type) {
3131
+ const parameters = IsConstructor2(type) ? type["parameters"] : [];
3132
+ const instantiatedParameters = InstantiateElements({}, { callstack: [] }, parameters);
3133
+ const result = Tuple(instantiatedParameters);
3134
+ return result;
3135
+ }
3136
+ function ConstructorParametersAction(type, options) {
3137
+ const result = CanInstantiate([type]) ? memory_exports.Update(ConstructorParametersOperation(type), {}, options) : ConstructorParametersDeferred(type, options);
3138
+ return result;
3139
+ }
3140
+ function ConstructorParametersInstantiate(context, state, type, options) {
3141
+ const instantiatedType = InstantiateType(context, state, type);
3142
+ return ConstructorParametersAction(instantiatedType, options);
3143
+ }
3144
+
3145
+ // ../../node_modules/.pnpm/typebox@1.1.39/node_modules/typebox/build/type/action/exclude.mjs
3146
+ function ExcludeDeferred(left, right, options = {}) {
3147
+ return Deferred("Exclude", [left, right], options);
3148
+ }
3149
+ function Exclude(left, right, options = {}) {
3150
+ return ExcludeAction(left, right, options);
3151
+ }
3152
+
3153
+ // ../../node_modules/.pnpm/typebox@1.1.39/node_modules/typebox/build/type/engine/exclude/operation.mjs
3154
+ function ExcludeUnionLeft(types, right) {
3155
+ return types.reduce((result, head) => {
3156
+ return [...result, ...ExcludeTypeLeft(head, right)];
3157
+ }, []);
3158
+ }
3159
+ function ExcludeTypeLeft(left, right) {
3160
+ const check = Extends2({}, left, right);
3161
+ const result = result_exports.IsExtendsTrueLike(check) ? [] : [left];
3162
+ return result;
3163
+ }
3164
+ function ExcludeOperation(left, right) {
3165
+ const remaining = IsEnum(left) ? ExcludeUnionLeft(EnumValuesToVariants(left.enum), right) : IsUnion(left) ? ExcludeUnionLeft(Flatten(left.anyOf), right) : ExcludeTypeLeft(left, right);
3166
+ const result = EvaluateUnion(remaining);
3167
+ return result;
3168
+ }
3169
+
3170
+ // ../../node_modules/.pnpm/typebox@1.1.39/node_modules/typebox/build/type/engine/exclude/instantiate.mjs
3171
+ function ExcludeAction(left, right, options) {
3172
+ const result = CanInstantiate([left, right]) ? memory_exports.Update(ExcludeOperation(left, right), {}, options) : ExcludeDeferred(left, right, options);
3173
+ return result;
3174
+ }
3175
+ function ExcludeInstantiate(context, state, left, right, options) {
3176
+ const instantiatedLeft = InstantiateType(context, state, left);
3177
+ const instantiatedRight = InstantiateType(context, state, right);
3178
+ return ExcludeAction(instantiatedLeft, instantiatedRight, options);
3179
+ }
3180
+
3181
+ // ../../node_modules/.pnpm/typebox@1.1.39/node_modules/typebox/build/type/action/extract.mjs
3182
+ function ExtractDeferred(left, right, options = {}) {
3183
+ return Deferred("Extract", [left, right], options);
3184
+ }
3185
+ function Extract(left, right, options = {}) {
3186
+ return ExtractAction(left, right, options);
3187
+ }
3188
+
3189
+ // ../../node_modules/.pnpm/typebox@1.1.39/node_modules/typebox/build/type/engine/extract/operation.mjs
3190
+ function ExtractUnionLeft(types, right) {
3191
+ return types.reduce((result, head) => {
3192
+ return [...result, ...ExtractTypeLeft(head, right)];
3193
+ }, []);
3194
+ }
3195
+ function ExtractTypeLeft(left, right) {
3196
+ const check = Extends2({}, left, right);
3197
+ const result = result_exports.IsExtendsTrueLike(check) ? [left] : [];
3198
+ return result;
3199
+ }
3200
+ function ExtractOperation(left, right) {
3201
+ const remaining = IsEnum(left) ? ExtractUnionLeft(EnumValuesToVariants(left.enum), right) : IsUnion(left) ? ExtractUnionLeft(Flatten(left.anyOf), right) : ExtractTypeLeft(left, right);
3202
+ const result = EvaluateUnion(remaining);
3203
+ return result;
3204
+ }
3205
+
3206
+ // ../../node_modules/.pnpm/typebox@1.1.39/node_modules/typebox/build/type/engine/extract/instantiate.mjs
3207
+ function ExtractAction(left, right, options) {
3208
+ const result = CanInstantiate([left, right]) ? memory_exports.Update(ExtractOperation(left, right), {}, options) : ExtractDeferred(left, right, options);
3209
+ return result;
3210
+ }
3211
+ function ExtractInstantiate(context, state, left, right, options) {
3212
+ const instantiatedLeft = InstantiateType(context, state, left);
3213
+ const instantiatedRight = InstantiateType(context, state, right);
3214
+ return ExtractAction(instantiatedLeft, instantiatedRight, options);
3215
+ }
3216
+
3217
+ // ../../node_modules/.pnpm/typebox@1.1.39/node_modules/typebox/build/type/engine/helpers/keys_to_indexer.mjs
3218
+ function KeysToLiterals(keys) {
3219
+ return keys.reduce((result, left) => {
3220
+ return IsLiteralValue(left) ? [...result, Literal(left)] : result;
3221
+ }, []);
3222
+ }
3223
+ function KeysToIndexer(keys) {
3224
+ const literals = KeysToLiterals(keys);
3225
+ const result = Union(literals);
3226
+ return result;
3227
+ }
3228
+
3229
+ // ../../node_modules/.pnpm/typebox@1.1.39/node_modules/typebox/build/type/action/indexed.mjs
3230
+ function IndexDeferred(type, indexer, options = {}) {
3231
+ return Deferred("Index", [type, indexer], options);
3232
+ }
3233
+ function Index(type, indexer_or_keys, options = {}) {
3234
+ const indexer = guard_exports.IsArray(indexer_or_keys) ? KeysToIndexer(indexer_or_keys) : indexer_or_keys;
3235
+ return IndexAction(type, indexer, options);
3236
+ }
3237
+
3238
+ // ../../node_modules/.pnpm/typebox@1.1.39/node_modules/typebox/build/type/engine/object/from_cyclic.mjs
3239
+ function FromCyclic(defs, ref) {
3240
+ const target = CyclicTarget(defs, ref);
3241
+ const result = FromType8(target);
3242
+ return result;
3243
+ }
3244
+
3245
+ // ../../node_modules/.pnpm/typebox@1.1.39/node_modules/typebox/build/type/engine/object/from_intersect.mjs
3246
+ function CollapseIntersectProperties(left, right) {
3247
+ const leftKeys = guard_exports.Keys(left).filter((key) => !guard_exports.HasPropertyKey(right, key));
3248
+ const rightKeys = guard_exports.Keys(right).filter((key) => !guard_exports.HasPropertyKey(left, key));
3249
+ const sharedKeys = guard_exports.Keys(left).filter((key) => guard_exports.HasPropertyKey(right, key));
3250
+ const leftProperties = leftKeys.reduce((result, key) => ({ ...result, [key]: left[key] }), {});
3251
+ const rightProperties = rightKeys.reduce((result, key) => ({ ...result, [key]: right[key] }), {});
3252
+ const sharedProperties = sharedKeys.reduce((result, key) => ({ ...result, [key]: EvaluateIntersect([left[key], right[key]]) }), {});
3253
+ const unique = memory_exports.Assign(leftProperties, rightProperties);
3254
+ const shared = memory_exports.Assign(unique, sharedProperties);
3255
+ return shared;
3256
+ }
3257
+ function FromIntersect(types) {
3258
+ return types.reduce((result, left) => {
3259
+ return CollapseIntersectProperties(result, FromType8(left));
3260
+ }, {});
3261
+ }
3262
+
3263
+ // ../../node_modules/.pnpm/typebox@1.1.39/node_modules/typebox/build/type/engine/object/from_object.mjs
3264
+ function FromObject2(properties) {
3265
+ return properties;
3266
+ }
3267
+
3268
+ // ../../node_modules/.pnpm/typebox@1.1.39/node_modules/typebox/build/type/engine/object/from_tuple.mjs
3269
+ function FromTuple(types) {
3270
+ const object = TupleToObject(Tuple(types));
3271
+ const result = FromType8(object);
3272
+ return result;
3273
+ }
3274
+
3275
+ // ../../node_modules/.pnpm/typebox@1.1.39/node_modules/typebox/build/type/engine/object/from_union.mjs
3276
+ function CollapseUnionProperties(left, right) {
3277
+ const sharedKeys = guard_exports.Keys(left).filter((key) => key in right);
3278
+ const result = sharedKeys.reduce((result2, key) => {
3279
+ return { ...result2, [key]: EvaluateUnion([left[key], right[key]]) };
3280
+ }, {});
3281
+ return result;
3282
+ }
3283
+ function ReduceVariants(types, result) {
3284
+ return guard_exports.TakeLeft(types, (left, right) => ReduceVariants(right, CollapseUnionProperties(result, FromType8(left))), () => result);
3285
+ }
3286
+ function FromUnion3(types) {
3287
+ return guard_exports.TakeLeft(types, (left, right) => ReduceVariants(right, FromType8(left)), () => Unreachable());
3288
+ }
3289
+
3290
+ // ../../node_modules/.pnpm/typebox@1.1.39/node_modules/typebox/build/type/engine/object/from_type.mjs
3291
+ function FromType8(type) {
3292
+ return IsCyclic(type) ? FromCyclic(type.$defs, type.$ref) : IsIntersect(type) ? FromIntersect(type.allOf) : IsUnion(type) ? FromUnion3(type.anyOf) : IsTuple(type) ? FromTuple(type.items) : IsObject2(type) ? FromObject2(type.properties) : {};
3293
+ }
3294
+
3295
+ // ../../node_modules/.pnpm/typebox@1.1.39/node_modules/typebox/build/type/engine/object/collapse.mjs
3296
+ function CollapseToObject(type) {
3297
+ const properties = FromType8(type);
3298
+ const result = _Object_(properties);
3299
+ return result;
3300
+ }
3301
+
3302
+ // ../../node_modules/.pnpm/typebox@1.1.39/node_modules/typebox/build/type/engine/helpers/keys.mjs
3303
+ var integerKeyPattern = new RegExp("^(?:0|[1-9][0-9]*)$");
3304
+ function ConvertToIntegerKey(value) {
3305
+ const normal = `${value}`;
3306
+ return integerKeyPattern.test(normal) ? parseInt(normal) : value;
3307
+ }
3308
+
3309
+ // ../../node_modules/.pnpm/typebox@1.1.39/node_modules/typebox/build/type/engine/indexed/from_array.mjs
3310
+ function NormalizeLiteral(value) {
3311
+ return Literal(ConvertToIntegerKey(value));
3312
+ }
3313
+ function NormalizeIndexerTypes(types) {
3314
+ return types.map((type) => NormalizeIndexer(type));
3315
+ }
3316
+ function NormalizeIndexer(type) {
3317
+ return IsIntersect(type) ? Intersect(NormalizeIndexerTypes(type.allOf)) : IsUnion(type) ? Union(NormalizeIndexerTypes(type.anyOf)) : IsLiteral(type) ? NormalizeLiteral(type.const) : type;
3318
+ }
3319
+ function FromArray2(type, indexer) {
3320
+ const normalizedIndexer = NormalizeIndexer(indexer);
3321
+ const check = Extends2({}, normalizedIndexer, Number2());
3322
+ const result = (
3323
+ // indexer
3324
+ result_exports.IsExtendsTrueLike(check) ? type : IsLiteral(indexer) && guard_exports.IsEqual(indexer.const, "length") ? Number2() : Never()
3325
+ );
3326
+ return result;
3327
+ }
3328
+
3329
+ // ../../node_modules/.pnpm/typebox@1.1.39/node_modules/typebox/build/type/engine/indexable/from_cyclic.mjs
3330
+ function FromCyclic2(defs, ref) {
3331
+ const target = CyclicTarget(defs, ref);
3332
+ const result = FromType9(target);
3333
+ return result;
3334
+ }
3335
+
3336
+ // ../../node_modules/.pnpm/typebox@1.1.39/node_modules/typebox/build/type/engine/indexable/from_union.mjs
3337
+ function FromUnion4(types) {
3338
+ return types.reduce((result, left) => {
3339
+ return [...result, ...FromType9(left)];
3340
+ }, []);
3341
+ }
3342
+
3343
+ // ../../node_modules/.pnpm/typebox@1.1.39/node_modules/typebox/build/type/engine/indexable/from_enum.mjs
3344
+ function FromEnum(values) {
3345
+ const variants = EnumValuesToVariants(values);
3346
+ const result = FromUnion4(variants);
3347
+ return result;
3348
+ }
3349
+
3350
+ // ../../node_modules/.pnpm/typebox@1.1.39/node_modules/typebox/build/type/engine/indexable/from_intersect.mjs
3351
+ function FromIntersect2(types) {
3352
+ const evaluated = EvaluateIntersect(types);
3353
+ const result = FromType9(evaluated);
3354
+ return result;
3355
+ }
3356
+
3357
+ // ../../node_modules/.pnpm/typebox@1.1.39/node_modules/typebox/build/type/engine/indexable/from_literal.mjs
3358
+ function FromLiteral4(value) {
3359
+ const result = [`${value}`];
3360
+ return result;
3361
+ }
3362
+
3363
+ // ../../node_modules/.pnpm/typebox@1.1.39/node_modules/typebox/build/type/engine/indexable/from_template_literal.mjs
3364
+ function FromTemplateLiteral2(pattern) {
3365
+ const decoded = TemplateLiteralDecode(pattern);
3366
+ const result = FromType9(decoded);
3367
+ return result;
3368
+ }
3369
+
3370
+ // ../../node_modules/.pnpm/typebox@1.1.39/node_modules/typebox/build/type/engine/indexable/from_type.mjs
3371
+ function FromType9(type) {
3372
+ return IsCyclic(type) ? FromCyclic2(type.$defs, type.$ref) : IsEnum(type) ? FromEnum(type.enum) : IsIntersect(type) ? FromIntersect2(type.allOf) : IsLiteral(type) ? FromLiteral4(type.const) : IsTemplateLiteral(type) ? FromTemplateLiteral2(type.pattern) : IsUnion(type) ? FromUnion4(type.anyOf) : [];
3373
+ }
3374
+
3375
+ // ../../node_modules/.pnpm/typebox@1.1.39/node_modules/typebox/build/type/engine/indexable/to_indexable_keys.mjs
3376
+ function ToIndexableKeys(type) {
3377
+ const result = FromType9(type);
3378
+ return result;
3379
+ }
3380
+
3381
+ // ../../node_modules/.pnpm/typebox@1.1.39/node_modules/typebox/build/type/engine/this/expand_this.mjs
3382
+ function FromTypes5(properties, types) {
3383
+ return types.map((type) => FromType10(properties, type));
3384
+ }
3385
+ function FromType10(properties, type) {
3386
+ return IsArray2(type) ? _Array_(FromType10(properties, type.items)) : IsAsyncIterator2(type) ? AsyncIterator(FromType10(properties, type.iteratorItems)) : IsConstructor2(type) ? Constructor(FromTypes5(properties, type.parameters), FromType10(properties, type.instanceType)) : IsFunction2(type) ? _Function_(FromTypes5(properties, type.parameters), FromType10(properties, type.returnType)) : IsIterator2(type) ? Iterator(FromType10(properties, type.iteratorItems)) : IsPromise(type) ? _Promise_(FromType10(properties, type.item)) : IsTuple(type) ? Tuple(FromTypes5(properties, type.items)) : IsUnion(type) ? Union(FromTypes5(properties, type.anyOf)) : IsIntersect(type) ? Intersect(FromTypes5(properties, type.allOf)) : IsThis(type) ? _Object_(properties) : type;
3387
+ }
3388
+ function ExpandThis(properties, type) {
3389
+ const result = FromType10(properties, type);
3390
+ return result;
3391
+ }
3392
+
3393
+ // ../../node_modules/.pnpm/typebox@1.1.39/node_modules/typebox/build/type/engine/indexed/from_object.mjs
3394
+ function IndexProperty(properties, key) {
3395
+ const selectedType = key in properties ? properties[key] : Never();
3396
+ const result = ExpandThis(properties, selectedType);
3397
+ return result;
3398
+ }
3399
+ function IndexProperties(properties, keys) {
3400
+ return keys.reduce((result, left) => {
3401
+ return [...result, IndexProperty(properties, left)];
3402
+ }, []);
3403
+ }
3404
+ function FromIndexer(properties, indexer) {
3405
+ const keys = ToIndexableKeys(indexer);
3406
+ const variants = IndexProperties(properties, keys);
3407
+ const result = EvaluateUnion(variants);
3408
+ return result;
3409
+ }
3410
+ var NumericKeyPattern = new RegExp(IntegerKey);
3411
+ function NumericKeys(keys) {
3412
+ const result = keys.filter((key) => NumericKeyPattern.test(key));
3413
+ return result;
3414
+ }
3415
+ function FromIndexerNumber(properties) {
3416
+ const keys = PropertyKeys(properties);
3417
+ const numericKeys = NumericKeys(keys);
3418
+ const variants = IndexProperties(properties, numericKeys);
3419
+ const result = EvaluateUnion(variants);
3420
+ return result;
3421
+ }
3422
+ function FromObject3(properties, indexer) {
3423
+ const result = IsNumber2(indexer) ? FromIndexerNumber(properties) : FromIndexer(properties, indexer);
3424
+ return result;
3425
+ }
3426
+
3427
+ // ../../node_modules/.pnpm/typebox@1.1.39/node_modules/typebox/build/type/engine/indexed/array_indexer.mjs
3428
+ function ConvertLiteral(value) {
3429
+ return Literal(ConvertToIntegerKey(value));
3430
+ }
3431
+ function ArrayIndexerTypes(types) {
3432
+ return types.map((type) => FormatArrayIndexer(type));
3433
+ }
3434
+ function FormatArrayIndexer(type) {
3435
+ return IsIntersect(type) ? Intersect(ArrayIndexerTypes(type.allOf)) : IsUnion(type) ? Union(ArrayIndexerTypes(type.anyOf)) : IsLiteral(type) ? ConvertLiteral(type.const) : type;
3436
+ }
3437
+
3438
+ // ../../node_modules/.pnpm/typebox@1.1.39/node_modules/typebox/build/type/engine/indexed/from_tuple.mjs
3439
+ function IndexElementsWithIndexer(types, indexer) {
3440
+ return types.reduceRight((result, right, index) => {
3441
+ const check = Extends2({}, Literal(index), indexer);
3442
+ return result_exports.IsExtendsTrueLike(check) ? [right, ...result] : result;
3443
+ }, []);
3444
+ }
3445
+ function FromTupleWithIndexer(types, indexer) {
3446
+ const formattedArrayIndexer = FormatArrayIndexer(indexer);
3447
+ const elements = IndexElementsWithIndexer(types, formattedArrayIndexer);
3448
+ return EvaluateUnionFast(elements);
3449
+ }
3450
+ function FromTupleWithoutIndexer(types) {
3451
+ return EvaluateUnionFast(types);
3452
+ }
3453
+ function FromTuple2(types, indexer) {
3454
+ return (
3455
+ // length (intrinsic)
3456
+ IsLiteral(indexer) && guard_exports.IsEqual(indexer.const, "length") ? Literal(types.length) : IsNumber2(indexer) || IsInteger2(indexer) ? FromTupleWithoutIndexer(types) : FromTupleWithIndexer(types, indexer)
3457
+ );
3458
+ }
3459
+
3460
+ // ../../node_modules/.pnpm/typebox@1.1.39/node_modules/typebox/build/type/engine/indexed/from_type.mjs
3461
+ function FromType11(type, indexer) {
3462
+ return IsArray2(type) ? FromArray2(type.items, indexer) : IsObject2(type) ? FromObject3(type.properties, indexer) : IsTuple(type) ? FromTuple2(type.items, indexer) : Never();
3463
+ }
3464
+
3465
+ // ../../node_modules/.pnpm/typebox@1.1.39/node_modules/typebox/build/type/engine/indexed/instantiate.mjs
3466
+ function NormalizeType(type) {
3467
+ const result = IsCyclic(type) || IsIntersect(type) || IsUnion(type) ? CollapseToObject(type) : type;
3468
+ return result;
3469
+ }
3470
+ function IndexAction(type, indexer, options) {
3471
+ const result = CanInstantiate([type, indexer]) ? memory_exports.Update(FromType11(NormalizeType(type), indexer), {}, options) : IndexDeferred(type, indexer, options);
3472
+ return result;
3473
+ }
3474
+ function IndexInstantiate(context, state, type, indexer, options) {
3475
+ const instantiatedType = InstantiateType(context, state, type);
3476
+ const instantiatedIndexer = InstantiateType(context, state, indexer);
3477
+ return IndexAction(instantiatedType, instantiatedIndexer, options);
3478
+ }
3479
+
3480
+ // ../../node_modules/.pnpm/typebox@1.1.39/node_modules/typebox/build/type/action/instance_type.mjs
3481
+ function InstanceTypeDeferred(type, options = {}) {
3482
+ return Deferred("InstanceType", [type], options);
3483
+ }
3484
+ function InstanceType(type, options = {}) {
3485
+ return InstanceTypeAction(type, options);
3486
+ }
3487
+
3488
+ // ../../node_modules/.pnpm/typebox@1.1.39/node_modules/typebox/build/type/engine/instance_type/instantiate.mjs
3489
+ function InstanceTypeOperation(type) {
3490
+ return IsConstructor2(type) ? type["instanceType"] : Never();
3491
+ }
3492
+ function InstanceTypeAction(type, options) {
3493
+ const result = CanInstantiate([type]) ? memory_exports.Update(InstanceTypeOperation(type), {}, options) : InstanceTypeDeferred(type, options);
3494
+ return result;
3495
+ }
3496
+ function InstanceTypeInstantiate(context, state, type, options = {}) {
3497
+ const instantiatedType = InstantiateType(context, state, type);
3498
+ return InstanceTypeAction(instantiatedType, options);
3499
+ }
3500
+
3501
+ // ../../node_modules/.pnpm/typebox@1.1.39/node_modules/typebox/build/type/action/keyof.mjs
3502
+ function KeyOfDeferred(type, options = {}) {
3503
+ return Deferred("KeyOf", [type], options);
3504
+ }
3505
+ function KeyOf2(type, options = {}) {
3506
+ return KeyOfAction(type, options);
3507
+ }
3508
+
3509
+ // ../../node_modules/.pnpm/typebox@1.1.39/node_modules/typebox/build/type/engine/keyof/from_any.mjs
3510
+ function FromAny() {
3511
+ return Union([Number2(), String2(), Symbol2()]);
3512
+ }
3513
+
3514
+ // ../../node_modules/.pnpm/typebox@1.1.39/node_modules/typebox/build/type/engine/keyof/from_array.mjs
3515
+ function FromArray3(_type) {
3516
+ return Number2();
3517
+ }
3518
+
3519
+ // ../../node_modules/.pnpm/typebox@1.1.39/node_modules/typebox/build/type/engine/keyof/from_object.mjs
3520
+ function FromPropertyKeys(keys) {
3521
+ const result = keys.reduce((result2, left) => {
3522
+ return IsLiteralValue(left) ? [...result2, Literal(ConvertToIntegerKey(left))] : Unreachable();
3523
+ }, []);
3524
+ return result;
3525
+ }
3526
+ function FromObject4(properties) {
3527
+ const propertyKeys = guard_exports.Keys(properties);
3528
+ const variants = FromPropertyKeys(propertyKeys);
3529
+ const result = EvaluateUnionFast(variants);
3530
+ return result;
3531
+ }
3532
+
3533
+ // ../../node_modules/.pnpm/typebox@1.1.39/node_modules/typebox/build/type/engine/keyof/from_record.mjs
3534
+ function FromRecord(type) {
3535
+ return RecordKey(type);
3536
+ }
3537
+
3538
+ // ../../node_modules/.pnpm/typebox@1.1.39/node_modules/typebox/build/type/engine/keyof/from_tuple.mjs
3539
+ function FromTuple3(types) {
3540
+ const result = types.map((_, index) => Literal(index));
3541
+ return EvaluateUnionFast(result);
3542
+ }
3543
+
3544
+ // ../../node_modules/.pnpm/typebox@1.1.39/node_modules/typebox/build/type/engine/keyof/from_type.mjs
3545
+ function FromType12(type) {
3546
+ return IsAny(type) ? FromAny() : IsArray2(type) ? FromArray3(type.items) : IsObject2(type) ? FromObject4(type.properties) : IsRecord(type) ? FromRecord(type) : IsTuple(type) ? FromTuple3(type.items) : Never();
3547
+ }
3548
+
3549
+ // ../../node_modules/.pnpm/typebox@1.1.39/node_modules/typebox/build/type/engine/keyof/instantiate.mjs
3550
+ function NormalizeType2(type) {
3551
+ const result = IsCyclic(type) || IsIntersect(type) || IsUnion(type) ? CollapseToObject(type) : type;
3552
+ return result;
3553
+ }
3554
+ function KeyOfAction(type, options) {
3555
+ return CanInstantiate([type]) ? memory_exports.Update(FromType12(NormalizeType2(type)), {}, options) : KeyOfDeferred(type, options);
3556
+ }
3557
+ function KeyOfInstantiate(context, state, type, options) {
3558
+ const instantiatedType = InstantiateType(context, state, type);
3559
+ return KeyOfAction(instantiatedType, options);
3560
+ }
3561
+
3562
+ // ../../node_modules/.pnpm/typebox@1.1.39/node_modules/typebox/build/type/action/mapped.mjs
3563
+ function MappedDeferred(identifier, type, as, property, options = {}) {
3564
+ return Deferred("Mapped", [identifier, type, as, property], options);
3565
+ }
3566
+ function Mapped2(identifier, type, as, property, options = {}) {
3567
+ return MappedAction({}, { callstack: [] }, identifier, type, as, property, options);
3568
+ }
3569
+
3570
+ // ../../node_modules/.pnpm/typebox@1.1.39/node_modules/typebox/build/type/engine/mapped/mapped_variants.mjs
3571
+ function FromTemplateLiteral3(pattern) {
3572
+ const decoded = TemplateLiteralDecode(pattern);
3573
+ const result = FromType13(decoded);
3574
+ return result;
3575
+ }
3576
+ function FromUnion5(types) {
3577
+ return types.reduce((result, left) => {
3578
+ return [...result, ...FromType13(left)];
3579
+ }, []);
3580
+ }
3581
+ function FromLiteral5(value) {
3582
+ const result = guard_exports.IsNumber(value) ? [Literal(`${value}`)] : [Literal(value)];
3583
+ return result;
3584
+ }
3585
+ function FromType13(type) {
3586
+ const result = IsEnum(type) ? FromUnion5(EnumValuesToVariants(type.enum)) : IsLiteral(type) ? FromLiteral5(type.const) : IsTemplateLiteral(type) ? FromTemplateLiteral3(type.pattern) : IsUnion(type) ? FromUnion5(type.anyOf) : [type];
3587
+ return result;
3588
+ }
3589
+ function MappedVariants(type) {
3590
+ const result = FromType13(type);
3591
+ return result;
3592
+ }
3593
+
3594
+ // ../../node_modules/.pnpm/typebox@1.1.39/node_modules/typebox/build/type/engine/mapped/mapped_operation.mjs
3595
+ function CanonicalAs(instantiatedAs) {
3596
+ const result = IsTemplateLiteral(instantiatedAs) ? TemplateLiteralDecode(instantiatedAs.pattern) : instantiatedAs;
3597
+ return result;
3598
+ }
3599
+ function MappedVariant(context, state, identifier, variant, as, property) {
3600
+ const variantContext = memory_exports.Assign(context, { [identifier["name"]]: variant });
3601
+ const instantiatedAs = InstantiateType(variantContext, state, as);
3602
+ const canonicalAs = CanonicalAs(instantiatedAs);
3603
+ const instantiatedProperty = InstantiateType(variantContext, state, property);
3604
+ return IsLiteralNumber(canonicalAs) || IsLiteralString(canonicalAs) ? { [canonicalAs.const]: instantiatedProperty } : {};
3605
+ }
3606
+ function MappedProperties(context, state, identifier, variants, as, property) {
3607
+ return variants.reduce((result, left) => {
3608
+ return [...result, MappedVariant(context, state, identifier, left, as, property)];
3609
+ }, []);
3610
+ }
3611
+ function MappedObjects(properties) {
3612
+ return properties.reduce((result, left) => {
3613
+ return [...result, _Object_(left)];
3614
+ }, []);
3615
+ }
3616
+ function MappedOperation(context, state, identifier, type, as, property) {
3617
+ const variants = MappedVariants(type);
3618
+ const mappedProperties = MappedProperties(context, state, identifier, variants, as, property);
3619
+ const mappedObjects = MappedObjects(mappedProperties);
3620
+ const result = EvaluateIntersect(mappedObjects);
3621
+ return result;
3622
+ }
3623
+
3624
+ // ../../node_modules/.pnpm/typebox@1.1.39/node_modules/typebox/build/type/engine/mapped/instantiate.mjs
3625
+ function MappedAction(context, state, identifier, type, as, property, options) {
3626
+ const result = CanInstantiate([type]) ? memory_exports.Update(MappedOperation(context, state, identifier, type, as, property), {}, options) : MappedDeferred(identifier, type, as, property, options);
3627
+ return result;
3628
+ }
3629
+ function MappedInstantiate(context, state, identifier, type, as, property, options) {
3630
+ const instantiatedType = InstantiateType(context, state, type);
3631
+ return MappedAction(context, state, identifier, instantiatedType, as, property, options);
3632
+ }
3633
+
3634
+ // ../../node_modules/.pnpm/typebox@1.1.39/node_modules/typebox/build/type/engine/module/instantiate.mjs
3635
+ function InstantiateCyclics(context, cyclicKeys) {
3636
+ const keys = guard_exports.Keys(context).filter((key) => cyclicKeys.includes(key));
3637
+ return keys.reduce((result, key) => {
3638
+ return { ...result, [key]: InstantiateCyclic(context, key, context[key]) };
3639
+ }, {});
3640
+ }
3641
+ function InstantiateNonCyclics(context, cyclicKeys) {
3642
+ const keys = guard_exports.Keys(context).filter((key) => !cyclicKeys.includes(key));
3643
+ return keys.reduce((result, key) => {
3644
+ return { ...result, [key]: InstantiateType(context, { callstack: [] }, context[key]) };
3645
+ }, {});
3646
+ }
3647
+ function InstantiateModule(context, options) {
3648
+ const cyclicCandidates = CyclicCandidates(context);
3649
+ const instantiatedCyclics = InstantiateCyclics(context, cyclicCandidates);
3650
+ const instantiatedNonCyclics = InstantiateNonCyclics(context, cyclicCandidates);
3651
+ const instantiatedModule = { ...instantiatedCyclics, ...instantiatedNonCyclics };
3652
+ return memory_exports.Update(instantiatedModule, {}, options);
3653
+ }
3654
+ function ModuleInstantiate(context, _state, properties, options) {
3655
+ const moduleContext = memory_exports.Assign(context, properties);
3656
+ const instantiatedModule = InstantiateModule(moduleContext, options);
3657
+ return instantiatedModule;
3658
+ }
3659
+
3660
+ // ../../node_modules/.pnpm/typebox@1.1.39/node_modules/typebox/build/type/action/non_nullable.mjs
3661
+ function NonNullableDeferred(type, options = {}) {
3662
+ return Deferred("NonNullable", [type], options);
3663
+ }
3664
+ function NonNullable(type, options = {}) {
3665
+ return NonNullableAction(type, options);
3666
+ }
3667
+
3668
+ // ../../node_modules/.pnpm/typebox@1.1.39/node_modules/typebox/build/type/engine/non_nullable/instantiate.mjs
3669
+ function NonNullableOperation(type) {
3670
+ const excluded = Union([Null(), Undefined()]);
3671
+ return ExcludeAction(type, excluded, {});
3672
+ }
3673
+ function NonNullableAction(type, options) {
3674
+ const result = CanInstantiate([type]) ? memory_exports.Update(NonNullableOperation(type), {}, options) : NonNullableDeferred(type, options);
3675
+ return result;
3676
+ }
3677
+ function NonNullableInstantiate(context, state, type, options) {
3678
+ const instantiatedType = InstantiateType(context, state, type);
3679
+ return NonNullableAction(instantiatedType, options);
3680
+ }
3681
+
3682
+ // ../../node_modules/.pnpm/typebox@1.1.39/node_modules/typebox/build/type/action/omit.mjs
3683
+ function OmitDeferred(type, indexer, options = {}) {
3684
+ return Deferred("Omit", [type, indexer], options);
3685
+ }
3686
+ function Omit(type, indexer_or_keys, options = {}) {
3687
+ const indexer = guard_exports.IsArray(indexer_or_keys) ? KeysToIndexer(indexer_or_keys) : indexer_or_keys;
3688
+ return OmitAction(type, indexer, options);
3689
+ }
3690
+
3691
+ // ../../node_modules/.pnpm/typebox@1.1.39/node_modules/typebox/build/type/engine/indexable/to_indexable.mjs
3692
+ function ToIndexable(type) {
3693
+ const collapsed = CollapseToObject(type);
3694
+ const result = IsObject2(collapsed) ? collapsed.properties : Unreachable();
3695
+ return result;
3696
+ }
3697
+
3698
+ // ../../node_modules/.pnpm/typebox@1.1.39/node_modules/typebox/build/type/engine/omit/from_type.mjs
3699
+ function FromKeys(properties, keys) {
3700
+ const result = guard_exports.Keys(properties).reduce((result2, key) => {
3701
+ return keys.includes(key) ? result2 : { ...result2, [key]: properties[key] };
3702
+ }, {});
3703
+ return result;
3704
+ }
3705
+ function FromType14(type, indexer) {
3706
+ const indexable = ToIndexable(type);
3707
+ const indexableKeys = ToIndexableKeys(indexer);
3708
+ const omitted = FromKeys(indexable, indexableKeys);
3709
+ const result = _Object_(omitted);
3710
+ return result;
3711
+ }
3712
+
3713
+ // ../../node_modules/.pnpm/typebox@1.1.39/node_modules/typebox/build/type/engine/omit/instantiate.mjs
3714
+ function OmitAction(type, indexer, options) {
3715
+ const result = CanInstantiate([type, indexer]) ? memory_exports.Update(FromType14(type, indexer), {}, options) : OmitDeferred(type, indexer, options);
3716
+ return result;
3717
+ }
3718
+ function OmitInstantiate(context, state, type, indexer, options) {
3719
+ const instantiatedType = InstantiateType(context, state, type);
3720
+ const instantiatedIndexer = InstantiateType(context, state, indexer);
3721
+ return OmitAction(instantiatedType, instantiatedIndexer, options);
3722
+ }
3723
+
3724
+ // ../../node_modules/.pnpm/typebox@1.1.39/node_modules/typebox/build/type/action/options.mjs
3725
+ function OptionsDeferred(type, options) {
3726
+ return Deferred("Options", [type, options], {});
3727
+ }
3728
+ function Options2(type, options) {
3729
+ return OptionsAction(type, options);
3730
+ }
3731
+
3732
+ // ../../node_modules/.pnpm/typebox@1.1.39/node_modules/typebox/build/type/engine/options/instantiate.mjs
3733
+ function OptionsAction(type, options) {
3734
+ const result = CanInstantiate([type]) ? memory_exports.Update(type, {}, options) : OptionsDeferred(type, options);
3735
+ return result;
3736
+ }
3737
+ function OptionsInstantiate(context, state, type, options) {
3738
+ const instaniatedType = InstantiateType(context, state, type);
3739
+ return OptionsAction(instaniatedType, options);
3740
+ }
3741
+
3742
+ // ../../node_modules/.pnpm/typebox@1.1.39/node_modules/typebox/build/type/action/parameters.mjs
3743
+ function ParametersDeferred(type, options = {}) {
3744
+ return Deferred("Parameters", [type], options);
3745
+ }
3746
+ function Parameters(type, options = {}) {
3747
+ return ParametersAction(type, options);
3748
+ }
3749
+
3750
+ // ../../node_modules/.pnpm/typebox@1.1.39/node_modules/typebox/build/type/engine/parameters/instantiate.mjs
3751
+ function ParametersOperation(type) {
3752
+ const parameters = IsFunction2(type) ? type["parameters"] : [];
3753
+ const instantiatedParameters = InstantiateElements({}, { callstack: [] }, parameters);
3754
+ const result = Tuple(instantiatedParameters);
3755
+ return result;
3756
+ }
3757
+ function ParametersAction(type, options) {
3758
+ const result = CanInstantiate([type]) ? memory_exports.Update(ParametersOperation(type), {}, options) : ParametersDeferred(type, options);
3759
+ return result;
3760
+ }
3761
+ function ParametersInstantiate(context, state, type, options) {
3762
+ const instantiatedType = InstantiateType(context, state, type);
3763
+ return ParametersAction(instantiatedType, options);
3764
+ }
3765
+
3766
+ // ../../node_modules/.pnpm/typebox@1.1.39/node_modules/typebox/build/type/action/partial.mjs
3767
+ function PartialDeferred(type, options = {}) {
3768
+ return Deferred("Partial", [type], options);
3769
+ }
3770
+ function Partial(type, options = {}) {
3771
+ return PartialAction(type, options);
3772
+ }
3773
+
3774
+ // ../../node_modules/.pnpm/typebox@1.1.39/node_modules/typebox/build/type/engine/partial/from_cyclic.mjs
3775
+ function FromCyclic3(defs, ref) {
3776
+ const target = CyclicTarget(defs, ref);
3777
+ const partial = FromType15(target);
3778
+ const result = Cyclic(memory_exports.Assign(defs, { [ref]: partial }), ref);
3779
+ return result;
3780
+ }
3781
+
3782
+ // ../../node_modules/.pnpm/typebox@1.1.39/node_modules/typebox/build/type/engine/partial/from_intersect.mjs
3783
+ function FromIntersect3(types) {
3784
+ const result = types.map((type) => FromType15(type));
3785
+ return EvaluateIntersect(result);
3786
+ }
3787
+
3788
+ // ../../node_modules/.pnpm/typebox@1.1.39/node_modules/typebox/build/type/engine/partial/from_union.mjs
3789
+ function FromUnion6(types) {
3790
+ const result = types.map((type) => FromType15(type));
3791
+ return Union(result);
3792
+ }
3793
+
3794
+ // ../../node_modules/.pnpm/typebox@1.1.39/node_modules/typebox/build/type/engine/partial/from_object.mjs
3795
+ function FromObject5(properties) {
3796
+ const mapped = guard_exports.Keys(properties).reduce((result2, left) => {
3797
+ return { ...result2, [left]: Optional(properties[left]) };
3798
+ }, {});
3799
+ const result = _Object_(mapped);
3800
+ return result;
3801
+ }
3802
+
3803
+ // ../../node_modules/.pnpm/typebox@1.1.39/node_modules/typebox/build/type/engine/partial/from_type.mjs
3804
+ function FromType15(type) {
3805
+ return IsCyclic(type) ? FromCyclic3(type.$defs, type.$ref) : IsIntersect(type) ? FromIntersect3(type.allOf) : IsUnion(type) ? FromUnion6(type.anyOf) : IsObject2(type) ? FromObject5(type.properties) : _Object_({});
3806
+ }
3807
+
3808
+ // ../../node_modules/.pnpm/typebox@1.1.39/node_modules/typebox/build/type/engine/partial/instantiate.mjs
3809
+ function PartialAction(type, options) {
3810
+ const result = CanInstantiate([type]) ? memory_exports.Update(FromType15(type), {}, options) : PartialDeferred(type, options);
3811
+ return result;
3812
+ }
3813
+ function PartialInstantiate(context, state, type, options) {
3814
+ const instantiatedType = InstantiateType(context, state, type);
3815
+ return PartialAction(instantiatedType, options);
3816
+ }
3817
+
3818
+ // ../../node_modules/.pnpm/typebox@1.1.39/node_modules/typebox/build/type/action/pick.mjs
3819
+ function PickDeferred(type, indexer, options = {}) {
3820
+ return Deferred("Pick", [type, indexer], options);
3821
+ }
3822
+ function Pick(type, indexer_or_keys, options = {}) {
3823
+ const indexer = guard_exports.IsArray(indexer_or_keys) ? KeysToIndexer(indexer_or_keys) : indexer_or_keys;
3824
+ return PickAction(type, indexer, options);
3825
+ }
3826
+
3827
+ // ../../node_modules/.pnpm/typebox@1.1.39/node_modules/typebox/build/type/engine/pick/from_type.mjs
3828
+ function FromKeys2(properties, keys) {
3829
+ const result = guard_exports.Keys(properties).reduce((result2, key) => {
3830
+ return keys.includes(key) ? memory_exports.Assign(result2, { [key]: properties[key] }) : result2;
3831
+ }, {});
3832
+ return result;
3833
+ }
3834
+ function FromType16(type, indexer) {
3835
+ const indexable = ToIndexable(type);
3836
+ const keys = ToIndexableKeys(indexer);
3837
+ const applied = FromKeys2(indexable, keys);
3838
+ const result = _Object_(applied);
3839
+ return result;
3840
+ }
3841
+
3842
+ // ../../node_modules/.pnpm/typebox@1.1.39/node_modules/typebox/build/type/engine/pick/instantiate.mjs
3843
+ function PickAction(type, indexer, options) {
3844
+ const result = CanInstantiate([type, indexer]) ? memory_exports.Update(FromType16(type, indexer), {}, options) : PickDeferred(type, indexer, options);
3845
+ return result;
3846
+ }
3847
+ function PickInstantiate(context, state, type, indexer, options) {
3848
+ const instantiatedType = InstantiateType(context, state, type);
3849
+ const instantiatedIndexer = InstantiateType(context, state, indexer);
3850
+ return PickAction(instantiatedType, instantiatedIndexer, options);
3851
+ }
3852
+
3853
+ // ../../node_modules/.pnpm/typebox@1.1.39/node_modules/typebox/build/type/action/readonly_object.mjs
3854
+ function ReadonlyObjectDeferred(type, options = {}) {
3855
+ return Deferred("ReadonlyObject", [type], options);
3856
+ }
3857
+ function ReadonlyObject(type, options = {}) {
3858
+ return ReadonlyObjectAction(type, options);
3859
+ }
3860
+ var ReadonlyType = ReadonlyObject;
3861
+
3862
+ // ../../node_modules/.pnpm/typebox@1.1.39/node_modules/typebox/build/type/engine/readonly_object/from_array.mjs
3863
+ function FromArray4(type) {
3864
+ const result = Immutable(_Array_(type));
3865
+ return result;
3866
+ }
3867
+
3868
+ // ../../node_modules/.pnpm/typebox@1.1.39/node_modules/typebox/build/type/engine/readonly_object/from_cyclic.mjs
3869
+ function FromCyclic4(defs, ref) {
3870
+ const target = CyclicTarget(defs, ref);
3871
+ const partial = FromType17(target);
3872
+ const result = Cyclic(memory_exports.Assign(defs, { [ref]: partial }), ref);
3873
+ return result;
3874
+ }
3875
+
3876
+ // ../../node_modules/.pnpm/typebox@1.1.39/node_modules/typebox/build/type/engine/readonly_object/from_intersect.mjs
3877
+ function FromIntersect4(types) {
3878
+ const result = types.map((type) => FromType17(type));
3879
+ return EvaluateIntersect(result);
3880
+ }
3881
+
3882
+ // ../../node_modules/.pnpm/typebox@1.1.39/node_modules/typebox/build/type/engine/readonly_object/from_object.mjs
3883
+ function FromObject6(properties) {
3884
+ const mapped = guard_exports.Keys(properties).reduce((result2, left) => {
3885
+ return { ...result2, [left]: Readonly(properties[left]) };
3886
+ }, {});
3887
+ const result = _Object_(mapped);
3888
+ return result;
3889
+ }
3890
+
3891
+ // ../../node_modules/.pnpm/typebox@1.1.39/node_modules/typebox/build/type/engine/readonly_object/from_tuple.mjs
3892
+ function FromTuple4(types) {
3893
+ const result = Immutable(Tuple(types));
3894
+ return result;
3895
+ }
3896
+
3897
+ // ../../node_modules/.pnpm/typebox@1.1.39/node_modules/typebox/build/type/engine/readonly_object/from_union.mjs
3898
+ function FromUnion7(types) {
3899
+ const result = types.map((type) => FromType17(type));
3900
+ return Union(result);
3901
+ }
3902
+
3903
+ // ../../node_modules/.pnpm/typebox@1.1.39/node_modules/typebox/build/type/engine/readonly_object/from_type.mjs
3904
+ function FromType17(type) {
3905
+ return IsArray2(type) ? FromArray4(type.items) : IsCyclic(type) ? FromCyclic4(type.$defs, type.$ref) : IsIntersect(type) ? FromIntersect4(type.allOf) : IsObject2(type) ? FromObject6(type.properties) : IsTuple(type) ? FromTuple4(type.items) : IsUnion(type) ? FromUnion7(type.anyOf) : type;
3906
+ }
3907
+
3908
+ // ../../node_modules/.pnpm/typebox@1.1.39/node_modules/typebox/build/type/engine/readonly_object/instantiate.mjs
3909
+ function ReadonlyObjectAction(type, options) {
3910
+ const result = CanInstantiate([type]) ? memory_exports.Update(FromType17(type), {}, options) : ReadonlyObjectDeferred(type);
3911
+ return result;
3912
+ }
3913
+ function ReadonlyObjectInstantiate(context, state, type, options) {
3914
+ const instantiatedType = InstantiateType(context, state, type);
3915
+ return ReadonlyObjectAction(instantiatedType, options);
3916
+ }
3917
+
3918
+ // ../../node_modules/.pnpm/typebox@1.1.39/node_modules/typebox/build/type/engine/ref/instantiate.mjs
3919
+ function RefInstantiate(context, state, type, ref) {
3920
+ return ref in context ? CyclicCheck([ref], context, context[ref]) ? type : InstantiateType(context, state, context[ref]) : type;
3921
+ }
3922
+
3923
+ // ../../node_modules/.pnpm/typebox@1.1.39/node_modules/typebox/build/type/engine/required/from_cyclic.mjs
3924
+ function FromCyclic5(defs, ref) {
3925
+ const target = CyclicTarget(defs, ref);
3926
+ const partial = FromType18(target);
3927
+ const result = Cyclic(memory_exports.Assign(defs, { [ref]: partial }), ref);
3928
+ return result;
3929
+ }
3930
+
3931
+ // ../../node_modules/.pnpm/typebox@1.1.39/node_modules/typebox/build/type/engine/required/from_intersect.mjs
3932
+ function FromIntersect5(types) {
3933
+ const result = types.map((type) => FromType18(type));
3934
+ return EvaluateIntersect(result);
3935
+ }
3936
+
3937
+ // ../../node_modules/.pnpm/typebox@1.1.39/node_modules/typebox/build/type/engine/required/from_union.mjs
3938
+ function FromUnion8(types) {
3939
+ const result = types.map((type) => FromType18(type));
3940
+ return Union(result);
3941
+ }
3942
+
3943
+ // ../../node_modules/.pnpm/typebox@1.1.39/node_modules/typebox/build/type/engine/required/from_object.mjs
3944
+ function FromObject7(properties) {
3945
+ const mapped = guard_exports.Keys(properties).reduce((result2, left) => {
3946
+ return { ...result2, [left]: OptionalRemove(properties[left]) };
3947
+ }, {});
3948
+ const result = _Object_(mapped);
3949
+ return result;
3950
+ }
3951
+
3952
+ // ../../node_modules/.pnpm/typebox@1.1.39/node_modules/typebox/build/type/engine/required/from_type.mjs
3953
+ function FromType18(type) {
3954
+ return IsCyclic(type) ? FromCyclic5(type.$defs, type.$ref) : IsIntersect(type) ? FromIntersect5(type.allOf) : IsUnion(type) ? FromUnion8(type.anyOf) : IsObject2(type) ? FromObject7(type.properties) : _Object_({});
3955
+ }
3956
+
3957
+ // ../../node_modules/.pnpm/typebox@1.1.39/node_modules/typebox/build/type/action/required.mjs
3958
+ function RequiredDeferred(type, options = {}) {
3959
+ return Deferred("Required", [type], options);
3960
+ }
3961
+ function Required(type, options = {}) {
3962
+ return RequiredAction(type, options);
3963
+ }
3964
+
3965
+ // ../../node_modules/.pnpm/typebox@1.1.39/node_modules/typebox/build/type/engine/required/instantiate.mjs
3966
+ function RequiredAction(type, options) {
3967
+ const result = CanInstantiate([type]) ? memory_exports.Update(FromType18(type), {}, options) : RequiredDeferred(type, options);
3968
+ return result;
3969
+ }
3970
+ function RequiredInstantiate(context, state, type, options) {
3971
+ const instaniatedType = InstantiateType(context, state, type);
3972
+ return RequiredAction(instaniatedType, options);
3973
+ }
3974
+
3975
+ // ../../node_modules/.pnpm/typebox@1.1.39/node_modules/typebox/build/type/action/return_type.mjs
3976
+ function ReturnTypeDeferred(type, options = {}) {
3977
+ return Deferred("ReturnType", [type], options);
3978
+ }
3979
+ function ReturnType(type, options = {}) {
3980
+ return ReturnTypeAction(type, options);
3981
+ }
3982
+
3983
+ // ../../node_modules/.pnpm/typebox@1.1.39/node_modules/typebox/build/type/engine/return_type/instantiate.mjs
3984
+ function ReturnTypeOperation(type) {
3985
+ return IsFunction2(type) ? type["returnType"] : Never();
3986
+ }
3987
+ function ReturnTypeAction(type, options) {
3988
+ const result = CanInstantiate([type]) ? memory_exports.Update(ReturnTypeOperation(type), {}, options) : ReturnTypeDeferred(type, options);
3989
+ return result;
3990
+ }
3991
+ function ReturnTypeInstantiate(context, state, type, options = {}) {
3992
+ const instantiatedType = InstantiateType(context, state, type);
3993
+ return ReturnTypeAction(instantiatedType, options);
3994
+ }
3995
+
3996
+ // ../../node_modules/.pnpm/typebox@1.1.39/node_modules/typebox/build/type/engine/rest/spread.mjs
3997
+ function SpreadElement(type) {
3998
+ const result = IsRest(type) ? IsTuple(type.items) ? RestSpread(type.items.items) : IsInfer(type.items) ? [type] : IsRef(type.items) ? [type] : [Never()] : [type];
3999
+ return result;
4000
+ }
4001
+ function RestSpread(types) {
4002
+ const result = types.reduce((result2, left) => {
4003
+ return [...result2, ...SpreadElement(left)];
4004
+ }, []);
4005
+ return result;
4006
+ }
4007
+
4008
+ // ../../node_modules/.pnpm/typebox@1.1.39/node_modules/typebox/build/type/engine/instantiate.mjs
4009
+ function CanInstantiate(types) {
4010
+ return guard_exports.TakeLeft(types, (left, right) => IsRef(left) ? false : CanInstantiate(right), () => true);
4011
+ }
4012
+ function ModifierActions(type, readonly, optional) {
4013
+ return IsReadonlyRemoveAction(type) ? ModifierActions(type.type, "remove", optional) : IsOptionalRemoveAction(type) ? ModifierActions(type.type, readonly, "remove") : IsReadonlyAddAction(type) ? ModifierActions(type.type, "add", optional) : IsOptionalAddAction(type) ? ModifierActions(type.type, readonly, "add") : [type, readonly, optional];
4014
+ }
4015
+ function ApplyReadonly2(action, type) {
4016
+ return guard_exports.IsEqual(action, "remove") ? ReadonlyRemove(type) : guard_exports.IsEqual(action, "add") ? ReadonlyAdd(type) : type;
4017
+ }
4018
+ function ApplyOptional2(action, type) {
4019
+ return guard_exports.IsEqual(action, "remove") ? OptionalRemove(type) : guard_exports.IsEqual(action, "add") ? OptionalAdd(type) : type;
4020
+ }
4021
+ function InstantiateProperties(context, state, properties) {
4022
+ return guard_exports.Keys(properties).reduce((result, key) => {
4023
+ return { ...result, [key]: InstantiateType(context, state, properties[key]) };
4024
+ }, {});
4025
+ }
4026
+ function InstantiateElements(context, state, types) {
4027
+ const elements = InstantiateTypes(context, state, types);
4028
+ const result = RestSpread(elements);
4029
+ return result;
4030
+ }
4031
+ function InstantiateTypes(context, state, types) {
4032
+ return types.map((type) => InstantiateType(context, state, type));
4033
+ }
4034
+ function InstantiateDeferred(context, state, action, parameters, options) {
4035
+ return guard_exports.IsEqual(action, "Awaited") ? AwaitedInstantiate(context, state, parameters[0], options) : guard_exports.IsEqual(action, "Capitalize") ? CapitalizeInstantiate(context, state, parameters[0], options) : guard_exports.IsEqual(action, "Conditional") ? ConditionalInstantiate(context, state, parameters[0], parameters[1], parameters[2], parameters[3], options) : guard_exports.IsEqual(action, "ConstructorParameters") ? ConstructorParametersInstantiate(context, state, parameters[0], options) : guard_exports.IsEqual(action, "Evaluate") ? EvaluateInstantiate(context, state, parameters[0], options) : guard_exports.IsEqual(action, "Exclude") ? ExcludeInstantiate(context, state, parameters[0], parameters[1], options) : guard_exports.IsEqual(action, "Extract") ? ExtractInstantiate(context, state, parameters[0], parameters[1], options) : guard_exports.IsEqual(action, "Index") ? IndexInstantiate(context, state, parameters[0], parameters[1], options) : guard_exports.IsEqual(action, "InstanceType") ? InstanceTypeInstantiate(context, state, parameters[0], options) : guard_exports.IsEqual(action, "Interface") ? InterfaceInstantiate(context, state, parameters[0], parameters[1], options) : guard_exports.IsEqual(action, "KeyOf") ? KeyOfInstantiate(context, state, parameters[0], options) : guard_exports.IsEqual(action, "Lowercase") ? LowercaseInstantiate(context, state, parameters[0], options) : guard_exports.IsEqual(action, "Mapped") ? MappedInstantiate(context, state, parameters[0], parameters[1], parameters[2], parameters[3], options) : guard_exports.IsEqual(action, "Module") ? ModuleInstantiate(context, state, parameters[0], options) : guard_exports.IsEqual(action, "NonNullable") ? NonNullableInstantiate(context, state, parameters[0], options) : guard_exports.IsEqual(action, "Pick") ? PickInstantiate(context, state, parameters[0], parameters[1], options) : guard_exports.IsEqual(action, "Options") ? OptionsInstantiate(context, state, parameters[0], parameters[1]) : guard_exports.IsEqual(action, "Parameters") ? ParametersInstantiate(context, state, parameters[0], options) : guard_exports.IsEqual(action, "Partial") ? PartialInstantiate(context, state, parameters[0], options) : guard_exports.IsEqual(action, "Omit") ? OmitInstantiate(context, state, parameters[0], parameters[1], options) : guard_exports.IsEqual(action, "ReadonlyObject") ? ReadonlyObjectInstantiate(context, state, parameters[0], options) : guard_exports.IsEqual(action, "Record") ? RecordInstantiate(context, state, parameters[0], parameters[1], options) : guard_exports.IsEqual(action, "Required") ? RequiredInstantiate(context, state, parameters[0], options) : guard_exports.IsEqual(action, "ReturnType") ? ReturnTypeInstantiate(context, state, parameters[0], options) : guard_exports.IsEqual(action, "TemplateLiteral") ? TemplateLiteralInstantiate(context, state, parameters[0], options) : guard_exports.IsEqual(action, "Uncapitalize") ? UncapitalizeInstantiate(context, state, parameters[0], options) : guard_exports.IsEqual(action, "Uppercase") ? UppercaseInstantiate(context, state, parameters[0], options) : Deferred(action, parameters, options);
4036
+ }
4037
+ function InstantiateType(context, state, input) {
4038
+ const immutable = IsImmutable(input);
4039
+ const modifiers = ModifierActions(input, IsReadonly(input) ? "add" : "none", IsOptional(input) ? "add" : "none");
4040
+ const type = IsBase(modifiers[0]) ? modifiers[0].Clone() : modifiers[0];
4041
+ const instantiated = IsRef(type) ? RefInstantiate(context, state, type, type.$ref) : IsArray2(type) ? _Array_(InstantiateType(context, state, type.items), ArrayOptions(type)) : IsAsyncIterator2(type) ? AsyncIterator(InstantiateType(context, state, type.iteratorItems), AsyncIteratorOptions(type)) : IsCall(type) ? CallInstantiate(context, state, type.target, type.arguments) : IsConstructor2(type) ? Constructor(InstantiateTypes(context, state, type.parameters), InstantiateType(context, state, type.instanceType), ConstructorOptions(type)) : IsDeferred(type) ? InstantiateDeferred(context, state, type.action, type.parameters, type.options) : IsFunction2(type) ? _Function_(InstantiateTypes(context, state, type.parameters), InstantiateType(context, state, type.returnType), FunctionOptions(type)) : IsIntersect(type) ? Intersect(InstantiateTypes(context, state, type.allOf), IntersectOptions(type)) : IsIterator2(type) ? Iterator(InstantiateType(context, state, type.iteratorItems), IteratorOptions(type)) : IsObject2(type) ? _Object_(InstantiateProperties(context, state, type.properties), ObjectOptions(type)) : IsPromise(type) ? _Promise_(InstantiateType(context, state, type.item), PromiseOptions(type)) : IsRecord(type) ? RecordFromPattern(RecordPattern(type), InstantiateType(context, state, RecordValue(type))) : IsRest(type) ? Rest(InstantiateType(context, state, type.items)) : IsTuple(type) ? Tuple(InstantiateElements(context, state, type.items), TupleOptions(type)) : IsUnion(type) ? Union(InstantiateTypes(context, state, type.anyOf), UnionOptions(type)) : type;
4042
+ const withImmutable = immutable ? Immutable(instantiated) : instantiated;
4043
+ const withModifiers = ApplyReadonly2(modifiers[1], ApplyOptional2(modifiers[2], withImmutable));
4044
+ return withModifiers;
4045
+ }
4046
+ function Instantiate(context, type) {
4047
+ return InstantiateType(context, { callstack: [] }, type);
4048
+ }
4049
+
4050
+ // ../../node_modules/.pnpm/typebox@1.1.39/node_modules/typebox/build/type/engine/awaited/instantiate.mjs
4051
+ function AwaitedOperation(type) {
4052
+ return IsPromise(type) ? AwaitedOperation(type.item) : type;
4053
+ }
4054
+ function AwaitedAction(type, options) {
4055
+ const result = CanInstantiate([type]) ? memory_exports.Update(AwaitedOperation(type), {}, options) : AwaitedDeferred(type, options);
4056
+ return result;
4057
+ }
4058
+ function AwaitedInstantiate(context, state, type, options) {
4059
+ const instantiatedType = InstantiateType(context, state, type);
4060
+ return AwaitedAction(instantiatedType, options);
4061
+ }
4062
+
4063
+ // ../../node_modules/.pnpm/typebox@1.1.39/node_modules/typebox/build/type/action/awaited.mjs
4064
+ function AwaitedDeferred(type, options = {}) {
4065
+ return Deferred("Awaited", [type], options);
4066
+ }
4067
+ function Awaited(type, options = {}) {
4068
+ return AwaitedAction(type, options);
4069
+ }
4070
+
4071
+ // ../../node_modules/.pnpm/typebox@1.1.39/node_modules/typebox/build/type/action/evaluate.mjs
4072
+ function EvaluateDeferred(type, options = {}) {
4073
+ return Deferred("Evaluate", [type], options);
4074
+ }
4075
+ function Evaluate(type, options = {}) {
4076
+ return EvaluateAction(type, options);
4077
+ }
4078
+
4079
+ // ../../node_modules/.pnpm/typebox@1.1.39/node_modules/typebox/build/type/action/module.mjs
4080
+ function ModuleDeferred(context, options = {}) {
4081
+ return Deferred("Module", [context], options);
4082
+ }
4083
+ function Module2(context, options = {}) {
4084
+ return Instantiate({}, ModuleDeferred(context, options));
4085
+ }
4086
+
4087
+ // ../../node_modules/.pnpm/typebox@1.1.39/node_modules/typebox/build/type/script/script.mjs
4088
+ function Script2(...args) {
4089
+ const [context, input, options] = arguments_exports.Match(args, {
4090
+ 2: (script, options2) => guard_exports.IsString(script) ? [{}, script, options2] : [script, options2, {}],
4091
+ 3: (context2, script, options2) => [context2, script, options2],
4092
+ 1: (script) => [{}, script, {}]
4093
+ });
4094
+ const result = Script(input);
4095
+ const parsed = guard_exports.IsArray(result) && guard_exports.IsEqual(result.length, 2) ? InstantiateType(context, { callstack: [] }, result[0]) : Never();
4096
+ return memory_exports.Update(parsed, {}, options);
4097
+ }
4098
+
4099
+ // ../../node_modules/.pnpm/typebox@1.1.39/node_modules/typebox/build/typebox.mjs
4100
+ var typebox_exports = {};
4101
+ __export(typebox_exports, {
4102
+ Any: () => Any,
4103
+ Array: () => _Array_,
4104
+ AsyncIterator: () => AsyncIterator,
4105
+ Awaited: () => Awaited,
4106
+ Base: () => Base,
4107
+ BigInt: () => BigInt2,
4108
+ Boolean: () => Boolean2,
4109
+ Call: () => Call,
4110
+ Capitalize: () => Capitalize,
4111
+ Codec: () => Codec,
4112
+ Conditional: () => Conditional,
4113
+ Constructor: () => Constructor,
4114
+ ConstructorParameters: () => ConstructorParameters,
4115
+ Cyclic: () => Cyclic,
4116
+ Decode: () => Decode,
4117
+ DecodeBuilder: () => DecodeBuilder,
4118
+ Encode: () => Encode,
4119
+ EncodeBuilder: () => EncodeBuilder,
4120
+ Enum: () => Enum,
4121
+ Evaluate: () => Evaluate,
4122
+ Exclude: () => Exclude,
4123
+ Extends: () => Extends2,
4124
+ ExtendsResult: () => result_exports,
4125
+ Extract: () => Extract,
4126
+ Function: () => _Function_,
4127
+ Generic: () => Generic,
4128
+ Identifier: () => Identifier,
4129
+ Immutable: () => Immutable,
4130
+ Index: () => Index,
4131
+ Infer: () => Infer,
4132
+ InstanceType: () => InstanceType,
4133
+ Instantiate: () => Instantiate,
4134
+ Integer: () => Integer,
4135
+ Interface: () => Interface,
4136
+ Intersect: () => Intersect,
4137
+ IsAny: () => IsAny,
4138
+ IsArray: () => IsArray2,
4139
+ IsAsyncIterator: () => IsAsyncIterator2,
4140
+ IsBase: () => IsBase,
4141
+ IsBigInt: () => IsBigInt2,
4142
+ IsBoolean: () => IsBoolean2,
4143
+ IsCall: () => IsCall,
4144
+ IsCodec: () => IsCodec,
4145
+ IsConstructor: () => IsConstructor2,
4146
+ IsCyclic: () => IsCyclic,
4147
+ IsEnum: () => IsEnum,
4148
+ IsFunction: () => IsFunction2,
4149
+ IsGeneric: () => IsGeneric,
4150
+ IsIdentifier: () => IsIdentifier,
4151
+ IsImmutable: () => IsImmutable,
4152
+ IsInfer: () => IsInfer,
4153
+ IsInteger: () => IsInteger2,
4154
+ IsIntersect: () => IsIntersect,
4155
+ IsIterator: () => IsIterator2,
4156
+ IsKind: () => IsKind,
4157
+ IsLiteral: () => IsLiteral,
4158
+ IsNever: () => IsNever,
4159
+ IsNull: () => IsNull2,
4160
+ IsNumber: () => IsNumber2,
4161
+ IsObject: () => IsObject2,
4162
+ IsOptional: () => IsOptional,
4163
+ IsParameter: () => IsParameter,
4164
+ IsPromise: () => IsPromise,
4165
+ IsReadonly: () => IsReadonly,
4166
+ IsRecord: () => IsRecord,
4167
+ IsRef: () => IsRef,
4168
+ IsRefine: () => IsRefine,
4169
+ IsRest: () => IsRest,
4170
+ IsSchema: () => IsSchema,
4171
+ IsString: () => IsString2,
4172
+ IsSymbol: () => IsSymbol2,
4173
+ IsTemplateLiteral: () => IsTemplateLiteral,
4174
+ IsThis: () => IsThis,
4175
+ IsTuple: () => IsTuple,
4176
+ IsUndefined: () => IsUndefined2,
4177
+ IsUnion: () => IsUnion,
4178
+ IsUnknown: () => IsUnknown,
4179
+ IsUnsafe: () => IsUnsafe,
4180
+ IsVoid: () => IsVoid,
4181
+ Iterator: () => Iterator,
4182
+ KeyOf: () => KeyOf2,
4183
+ Literal: () => Literal,
4184
+ Lowercase: () => Lowercase,
4185
+ Mapped: () => Mapped2,
4186
+ Module: () => Module2,
4187
+ Never: () => Never,
4188
+ NonNullable: () => NonNullable,
4189
+ Null: () => Null,
4190
+ Number: () => Number2,
4191
+ Object: () => _Object_,
4192
+ Omit: () => Omit,
4193
+ Optional: () => Optional,
4194
+ Options: () => Options2,
4195
+ Parameter: () => Parameter,
4196
+ Parameters: () => Parameters,
4197
+ Partial: () => Partial,
4198
+ Pick: () => Pick,
4199
+ Promise: () => _Promise_,
4200
+ Readonly: () => Readonly,
4201
+ ReadonlyObject: () => ReadonlyObject,
4202
+ ReadonlyType: () => ReadonlyType,
4203
+ Record: () => Record,
4204
+ RecordKey: () => RecordKey,
4205
+ RecordPattern: () => RecordPattern,
4206
+ RecordValue: () => RecordValue,
4207
+ Ref: () => Ref,
4208
+ Refine: () => Refine,
4209
+ Required: () => Required,
4210
+ Rest: () => Rest,
4211
+ ReturnType: () => ReturnType,
4212
+ Script: () => Script2,
4213
+ String: () => String2,
4214
+ Symbol: () => Symbol2,
4215
+ TemplateLiteral: () => TemplateLiteral2,
4216
+ This: () => This,
4217
+ Tuple: () => Tuple,
4218
+ Uncapitalize: () => Uncapitalize,
4219
+ Undefined: () => Undefined,
4220
+ Union: () => Union,
4221
+ Unknown: () => Unknown,
4222
+ Unsafe: () => Unsafe,
4223
+ Uppercase: () => Uppercase,
4224
+ Void: () => Void
4225
+ });
4226
+
4227
+ // ../clawos-shared/dist/index.js
4228
+ import { createHash } from "crypto";
4229
+ import { constants, closeSync, fstatSync, openSync, readSync } from "fs";
4230
+ var GRANT_HANDLE_RE = /^grant:[0-9a-hjkmnp-tv-z]{8}$/;
4231
+ var closed = { additionalProperties: false };
4232
+ var text = typebox_exports.String({ minLength: 1 });
4233
+ var namespace = typebox_exports.String({ pattern: "^[a-z][a-z0-9_]*$" });
4234
+ var timestamp = typebox_exports.Integer({ minimum: 0, maximum: Number.MAX_SAFE_INTEGER });
4235
+ var actionId = typebox_exports.Integer({ minimum: 1, maximum: Number.MAX_SAFE_INTEGER });
4236
+ var JsonValueSchema = typebox_exports.Cyclic({ Value: typebox_exports.Union([
4237
+ typebox_exports.Null(),
4238
+ typebox_exports.Boolean(),
4239
+ typebox_exports.Number(),
4240
+ typebox_exports.String(),
4241
+ typebox_exports.Array(typebox_exports.Ref("Value")),
4242
+ typebox_exports.Record(typebox_exports.String(), typebox_exports.Ref("Value"))
4243
+ ]) }, "Value");
4244
+ var GrantHandle = typebox_exports.String({ pattern: GRANT_HANDLE_RE.source });
4245
+ var ToolNameSchema = typebox_exports.String({ pattern: "^gk_[a-z0-9]+(?:_[a-z0-9]+){2,}$", maxLength: 64 });
4246
+ var SupportedResourceSchema = typebox_exports.Object({
4247
+ urlPattern: text,
4248
+ type: namespace,
4249
+ title: text,
4250
+ description: typebox_exports.String(),
4251
+ grantable: typebox_exports.Boolean(),
4252
+ observerStrategy: typebox_exports.Enum(["private-only", "acl-check", "dataset-tracking", "low-stakes"]),
4253
+ tools: typebox_exports.Array(ToolNameSchema, { uniqueItems: true })
4254
+ }, closed);
4255
+ var ObservationDescriptionSchema = typebox_exports.Object({
4256
+ title: text,
4257
+ description: typebox_exports.String(),
4258
+ prohibitAllSharing: typebox_exports.Optional(typebox_exports.Boolean()),
4259
+ excludeObservers: typebox_exports.Optional(typebox_exports.Array(text, { uniqueItems: true }))
4260
+ }, closed);
4261
+ var ActionKindSchema = typebox_exports.Object({ tag: text, label: text }, closed);
4262
+ var ActionDescriptionSchema = typebox_exports.Object({
4263
+ title: text,
4264
+ description: typebox_exports.String(),
4265
+ actionKind: typebox_exports.Optional(ActionKindSchema),
4266
+ autoApprovable: typebox_exports.Optional(typebox_exports.Boolean()),
4267
+ implementsRevert: typebox_exports.Boolean(),
4268
+ awaitDecision: typebox_exports.Optional(typebox_exports.Boolean()),
4269
+ preview: typebox_exports.Optional(JsonValueSchema)
4270
+ }, closed);
4271
+ var DryRunResultSchema = typebox_exports.Union([
4272
+ typebox_exports.Object({ kind: typebox_exports.Literal("observation"), description: ObservationDescriptionSchema }, closed),
4273
+ typebox_exports.Object({ kind: typebox_exports.Literal("action"), description: ActionDescriptionSchema }, closed)
4274
+ ]);
4275
+ var ToolResultSchema = typebox_exports.Object({
4276
+ content: typebox_exports.Array(typebox_exports.Object({ type: typebox_exports.Literal("text"), text: typebox_exports.String() }, closed)),
4277
+ details: typebox_exports.Optional(JsonValueSchema)
4278
+ }, closed);
4279
+ var ObserverVerifierSchema = typebox_exports.Object({ vendor: namespace, opaque: text }, closed);
4280
+ var GatekeeperToolDefSchema = typebox_exports.Object({
4281
+ name: ToolNameSchema,
4282
+ resourceType: namespace,
4283
+ kind: typebox_exports.Enum(["observation", "action"]),
4284
+ description: text,
4285
+ parameters: typebox_exports.Record(typebox_exports.String(), JsonValueSchema),
4286
+ outputSchema: typebox_exports.Optional(typebox_exports.Record(typebox_exports.String(), JsonValueSchema))
4287
+ }, closed);
4288
+ var AccountDescriptionSchema = typebox_exports.Object({
4289
+ email: typebox_exports.Optional(text),
4290
+ displayName: typebox_exports.Optional(text),
4291
+ expiresAt: typebox_exports.Optional(timestamp)
4292
+ }, closed);
4293
+ var VendorDescriptionSchema = typebox_exports.Object({
4294
+ title: text,
4295
+ description: typebox_exports.String(),
4296
+ icon: typebox_exports.Optional(text),
4297
+ autoProvisionsAccount: typebox_exports.Optional(typebox_exports.Boolean())
4298
+ }, closed);
4299
+ var GatekeeperDescriptionSchema = typebox_exports.Object({ resource: SupportedResourceSchema, title: text, suggestedName: text }, closed);
4300
+ var ConnectionResultSchema = typebox_exports.Object({ url: text }, closed);
4301
+ var RejectActionResultSchema = typebox_exports.Object({ restart: typebox_exports.Optional(typebox_exports.Boolean()) }, closed);
4302
+ var RevertActionResultSchema = typebox_exports.Object({ message: typebox_exports.Optional(typebox_exports.String()), canRetry: typebox_exports.Optional(typebox_exports.Boolean()) }, closed);
4303
+ var GrantSchema = typebox_exports.Object({
4304
+ handle: GrantHandle,
4305
+ agentId: text,
4306
+ cellId: text,
4307
+ vendor: namespace,
4308
+ resourceType: namespace,
4309
+ resourceKey: text,
4310
+ operatorId: text,
4311
+ scope: typebox_exports.Union([typebox_exports.Literal("agent"), typebox_exports.TemplateLiteral([typebox_exports.Literal("session:"), typebox_exports.String()], { pattern: "^session:.+$" })]),
4312
+ audience: typebox_exports.Enum(["owner-only", "shared"]),
4313
+ status: typebox_exports.Enum(["pending", "active", "revoked", "lockdown"]),
4314
+ createdAt: timestamp,
4315
+ createdBy: typebox_exports.Enum(["operator", "agent-request"]),
4316
+ expiresAt: typebox_exports.Optional(timestamp),
4317
+ title: typebox_exports.Optional(typebox_exports.String())
4318
+ }, closed);
4319
+ var PendingActionSchema = typebox_exports.Object({
4320
+ id: actionId,
4321
+ gatekeeperInstance: text,
4322
+ actionId,
4323
+ descriptionJson: text,
4324
+ status: typebox_exports.Enum(["pending", "applied", "rejected", "reverted", "failed"]),
4325
+ submittedAt: timestamp,
4326
+ decidedBy: typebox_exports.Optional(text),
4327
+ decidedAt: typebox_exports.Optional(timestamp),
4328
+ appliedAt: typebox_exports.Optional(timestamp),
4329
+ error: typebox_exports.Optional(typebox_exports.String())
4330
+ }, closed);
4331
+ var AuditRecordSchema = typebox_exports.Object({
4332
+ ts: typebox_exports.String({ pattern: "^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(?:\\.\\d{3})?Z$" }),
4333
+ cell: text,
4334
+ agentId: typebox_exports.Optional(text),
4335
+ sessionKey: typebox_exports.Optional(text),
4336
+ kind: typebox_exports.Enum(["observation", "action.submit", "action.decide", "action.apply", "action.revert", "grant", "auth", "tool", "install", "egress"]),
4337
+ vendor: typebox_exports.Optional(namespace),
4338
+ resourceType: typebox_exports.Optional(namespace),
4339
+ handle: typebox_exports.Optional(GrantHandle),
4340
+ actionId: typebox_exports.Optional(actionId),
4341
+ title: typebox_exports.String(),
4342
+ decision: typebox_exports.Optional(text),
4343
+ by: typebox_exports.Optional(text),
4344
+ durationMs: typebox_exports.Optional(typebox_exports.Number({ minimum: 0 })),
4345
+ ok: typebox_exports.Optional(typebox_exports.Boolean())
4346
+ }, closed);
4347
+ var OsStatus = typebox_exports.Object({
4348
+ cell: text,
4349
+ upstreamVersion: text,
4350
+ kernelVersion: text,
4351
+ healthy: typebox_exports.Boolean(),
4352
+ maintenance: typebox_exports.Boolean(),
4353
+ gatekeepers: typebox_exports.Array(typebox_exports.Object({ vendor: namespace, healthy: typebox_exports.Boolean(), accounts: timestamp }, closed)),
4354
+ pendingApprovals: timestamp,
4355
+ pendingRequests: timestamp,
4356
+ lastUpdate: typebox_exports.Optional(typebox_exports.Object({ to: text, ok: typebox_exports.Boolean(), at: text }, closed))
4357
+ }, closed);
4358
+ var IntroduceParams = typebox_exports.Object({
4359
+ agentId: text,
4360
+ url: text,
4361
+ title: typebox_exports.Optional(typebox_exports.String()),
4362
+ audience: typebox_exports.Optional(typebox_exports.Enum(["owner-only", "shared"]))
4363
+ }, closed);
4364
+ var ApprovalDecisionParams = typebox_exports.Object({ ids: typebox_exports.Union([
4365
+ typebox_exports.Array(actionId, { minItems: 1, uniqueItems: true }),
4366
+ typebox_exports.Literal("all")
4367
+ ]) }, closed);
4368
+ var RevokeGrantParams = typebox_exports.Object({ handle: GrantHandle }, closed);
4369
+ var RequestAccessParams = typebox_exports.Object({ url: text, reason: text }, closed);
4370
+ var ListGrantsParams = typebox_exports.Object({ agentId: typebox_exports.Optional(text) }, closed);
4371
+ var ConnectGatekeeperParams = typebox_exports.Object({ vendor: namespace, resourceTypes: typebox_exports.Optional(typebox_exports.Array(namespace, { uniqueItems: true })) }, closed);
4372
+ var blocked = () => ({ protocolVersion: 1, decision: "block", reason: "Install material is not authorized by cell policy." });
4373
+ function evaluateInstall(rules, material) {
4374
+ try {
4375
+ if (!rules || !["plugin", "skill"].includes(material.targetType) || !["install", "update"].includes(material.request.mode) || typeof material.request.kind !== "string" || typeof material.sourcePath !== "string" || !material.sourcePath.startsWith("/") || !["file", "directory"].includes(material.sourcePathKind)) return blocked();
4376
+ for (const entries of [rules.allowSources, rules.allowHashes]) if (entries !== void 0 && (!Array.isArray(entries) || entries.some((s) => typeof s !== "string" || s.length === 0 || s.length > 4096))) return blocked();
4377
+ const specifier = material.request.requestedSpecifier;
4378
+ if (typeof specifier === "string" && registrySpecifierSafe(specifier) && specifier.length > 0 && specifier.length <= 4096 && !/[\x00-\x20\x7f]/u.test(specifier) && rules.allowSources?.some((pattern) => new RegExp(`^${pattern.split("*").map((s) => s.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")).join(".*")}$`, "u").test(specifier))) return { protocolVersion: 1, decision: "allow" };
4379
+ if (material.sourcePathKind === "file" && rules.allowHashes?.length) {
4380
+ const fd = openSync(material.sourcePath, constants.O_RDONLY | constants.O_NOFOLLOW | constants.O_NONBLOCK);
4381
+ try {
4382
+ const before = fstatSync(fd);
4383
+ if (!before.isFile() || before.size > 16 * 1024 * 1024) return blocked();
4384
+ const bytes = Buffer.alloc(before.size + 1);
4385
+ let length = 0;
4386
+ while (length < bytes.length) {
4387
+ const n = readSync(fd, bytes, length, bytes.length - length, null);
4388
+ if (n === 0) break;
4389
+ length += n;
4390
+ }
4391
+ if (length !== before.size) return blocked();
4392
+ const hash = `sha256:${createHash("sha256").update(bytes.subarray(0, length)).digest("hex")}`;
4393
+ const after = fstatSync(fd);
4394
+ if (before.size === after.size && before.mtimeMs === after.mtimeMs && before.ctimeMs === after.ctimeMs && rules.allowHashes.includes(hash)) return { protocolVersion: 1, decision: "allow" };
4395
+ } finally {
4396
+ closeSync(fd);
4397
+ }
4398
+ }
4399
+ } catch {
4400
+ }
4401
+ return blocked();
4402
+ }
4403
+ function registrySpecifierSafe(specifier) {
4404
+ const prefixed = /^(?:npm|clawhub):/.test(specifier);
4405
+ const value = prefixed ? specifier.slice(specifier.indexOf(":") + 1) : specifier;
4406
+ if (!prefixed && !value.startsWith("@") && !/^[a-z0-9][a-z0-9._-]*(?:@|$)/.test(value)) return true;
4407
+ return /^(?:@[a-z0-9][a-z0-9._-]*\/)?[a-z0-9][a-z0-9._-]*(?:@[A-Za-z0-9._+~^<>=|*-]+)?$/.test(value);
4408
+ }
4409
+
4410
+ // src/util/cell.ts
4411
+ import { readFileSync } from "fs";
4412
+ import { homedir } from "os";
4413
+ import { join } from "path";
4414
+ var CELL_NAME = /^[a-z][a-z0-9-]{0,30}[a-z0-9]$|^[a-z]$/;
4415
+ var CELLS_REGISTRY = join(homedir(), ".clawos", "cells.json");
4416
+ var DEFAULT_PORT = 18789;
4417
+ function assertCellName(name) {
4418
+ if (!CELL_NAME.test(name)) {
4419
+ throw new Error(`invalid cell name '${name}': use lowercase letters, digits and hyphens (2\u201332 chars)`);
4420
+ }
4421
+ }
4422
+ function resolveCell(name = "default", port, platform = process.platform) {
4423
+ assertCellName(name);
4424
+ if (platform === "darwin" && ["gateway", "node"].includes(name)) throw new Error("cell name collides with an upstream LaunchAgent label");
4425
+ const isDefault = name === "default";
4426
+ const stateDir = isDefault ? join(homedir(), ".openclaw") : join(homedir(), `.openclaw-${name}`);
4427
+ const unit = platform === "darwin" ? isDefault ? "ai.openclaw.gateway" : `ai.openclaw.${name}` : isDefault ? "openclaw-gateway.service" : `openclaw-gateway-${name}.service`;
4428
+ const resolvedPort = port ?? DEFAULT_PORT;
4429
+ const env = {
4430
+ OPENCLAW_STATE_DIR: stateDir,
4431
+ OPENCLAW_CONFIG_PATH: join(stateDir, "openclaw.json"),
4432
+ OPENCLAW_PROFILE: name,
4433
+ OPENCLAW_GATEWAY_PORT: String(resolvedPort),
4434
+ OPENCLAW_NO_AUTO_UPDATE: "1",
4435
+ CLAWOS_CELL: name
4436
+ };
4437
+ if (!isDefault) {
4438
+ env.OPENCLAW_PROFILE = name;
4439
+ env.OPENCLAW_GATEWAY_PORT = String(resolvedPort);
4440
+ }
4441
+ return {
4442
+ name,
4443
+ stateDir,
4444
+ osDir: join(stateDir, "os"),
4445
+ configPath: join(stateDir, "openclaw.json"),
4446
+ unit,
4447
+ dropInDir: join(homedir(), ".config", "systemd", "user", `${unit}.d`),
4448
+ port: resolvedPort,
4449
+ env
4450
+ };
4451
+ }
4452
+
4453
+ // src/util/json5.ts
4454
+ var Json5Error = class extends Error {
4455
+ constructor(message, line, column, file) {
4456
+ super(`${file ? `${file}:` : ""}${line}:${column}: ${message}`);
4457
+ this.line = line;
4458
+ this.column = column;
4459
+ this.file = file;
4460
+ this.name = "Json5Error";
4461
+ }
4462
+ };
4463
+ var IDENT_START = /[A-Za-z_$]/;
4464
+ var IDENT_PART = /[A-Za-z0-9_$]/;
4465
+ function parseJson5(text2, file) {
4466
+ let i = 0;
4467
+ const posOf = (at) => {
4468
+ let line = 1;
4469
+ let lineStart = 0;
4470
+ for (let k = 0; k < at && k < text2.length; k++) {
4471
+ if (text2[k] === "\n") {
4472
+ line++;
4473
+ lineStart = k + 1;
4474
+ }
4475
+ }
4476
+ return [line, at - lineStart + 1];
4477
+ };
4478
+ const fail = (message, at = i) => {
4479
+ const [line, column] = posOf(at);
4480
+ throw new Json5Error(message, line, column, file);
4481
+ };
4482
+ const skip = () => {
4483
+ for (; ; ) {
4484
+ while (i < text2.length && /\s/.test(text2[i])) i++;
4485
+ if (text2[i] === "/" && text2[i + 1] === "/") {
4486
+ while (i < text2.length && text2[i] !== "\n") i++;
4487
+ continue;
4488
+ }
4489
+ if (text2[i] === "/" && text2[i + 1] === "*") {
4490
+ const start = i;
4491
+ const end = text2.indexOf("*/", i + 2);
4492
+ if (end === -1) fail("unterminated block comment", start);
4493
+ i = end + 2;
4494
+ continue;
4495
+ }
4496
+ return;
4497
+ }
4498
+ };
4499
+ const parseString = () => {
4500
+ const quote = text2[i];
4501
+ i++;
4502
+ let out = "";
4503
+ for (; ; ) {
4504
+ if (i >= text2.length) fail("unterminated string");
4505
+ const c = text2[i];
4506
+ if (c === quote) {
4507
+ i++;
4508
+ return out;
4509
+ }
4510
+ if (c === "\n") fail("unescaped newline in string");
4511
+ if (c !== "\\") {
4512
+ out += c;
4513
+ i++;
4514
+ continue;
4515
+ }
4516
+ i++;
4517
+ const esc = text2[i];
4518
+ if (esc === void 0) fail("unterminated escape");
4519
+ i++;
4520
+ switch (esc) {
4521
+ case "n":
4522
+ out += "\n";
4523
+ break;
4524
+ case "t":
4525
+ out += " ";
4526
+ break;
4527
+ case "r":
4528
+ out += "\r";
4529
+ break;
4530
+ case "b":
4531
+ out += "\b";
4532
+ break;
4533
+ case "f":
4534
+ out += "\f";
4535
+ break;
4536
+ case "0":
4537
+ out += "\0";
4538
+ break;
4539
+ case "\n":
4540
+ break;
4541
+ // line continuation
4542
+ case "u": {
4543
+ const hex = text2.slice(i, i + 4);
4544
+ if (!/^[0-9a-fA-F]{4}$/.test(hex)) fail("invalid \\u escape");
4545
+ out += String.fromCharCode(parseInt(hex, 16));
4546
+ i += 4;
4547
+ break;
4548
+ }
4549
+ default:
4550
+ out += esc;
4551
+ }
4552
+ }
4553
+ };
4554
+ const parseNumber = () => {
4555
+ const start = i;
4556
+ if (text2[i] === "+" || text2[i] === "-") i++;
4557
+ if (/^0[xX]/.test(text2.slice(i, i + 2))) {
4558
+ i += 2;
4559
+ while (i < text2.length && /[0-9a-fA-F]/.test(text2[i])) i++;
4560
+ } else {
4561
+ while (i < text2.length && /[0-9]/.test(text2[i])) i++;
4562
+ if (text2[i] === ".") {
4563
+ i++;
4564
+ while (i < text2.length && /[0-9]/.test(text2[i])) i++;
4565
+ }
4566
+ if (text2[i] === "e" || text2[i] === "E") {
4567
+ i++;
4568
+ if (text2[i] === "+" || text2[i] === "-") i++;
4569
+ while (i < text2.length && /[0-9]/.test(text2[i])) i++;
4570
+ }
4571
+ }
4572
+ const raw = text2.slice(start, i);
4573
+ const value2 = Number(raw);
4574
+ if (raw === "" || !Number.isFinite(value2)) fail(`invalid number '${raw}'`, start);
4575
+ return value2;
4576
+ };
4577
+ const parseKey = () => {
4578
+ const c = text2[i];
4579
+ if (c === '"' || c === "'") return parseString();
4580
+ if (c !== void 0 && IDENT_START.test(c)) {
4581
+ const start = i;
4582
+ while (i < text2.length && IDENT_PART.test(text2[i])) i++;
4583
+ return text2.slice(start, i);
4584
+ }
4585
+ return fail("expected an object key");
4586
+ };
4587
+ const parseValue = () => {
4588
+ skip();
4589
+ const c = text2[i];
4590
+ if (c === void 0) return fail("unexpected end of input");
4591
+ if (c === "{") {
4592
+ i++;
4593
+ const out = {};
4594
+ skip();
4595
+ if (text2[i] === "}") {
4596
+ i++;
4597
+ return out;
4598
+ }
4599
+ for (; ; ) {
4600
+ skip();
4601
+ const key = parseKey();
4602
+ skip();
4603
+ if (text2[i] !== ":") fail("expected ':' after object key");
4604
+ i++;
4605
+ out[key] = parseValue();
4606
+ skip();
4607
+ if (text2[i] === ",") {
4608
+ i++;
4609
+ skip();
4610
+ if (text2[i] === "}") {
4611
+ i++;
4612
+ return out;
4613
+ }
4614
+ continue;
4615
+ }
4616
+ if (text2[i] === "}") {
4617
+ i++;
4618
+ return out;
4619
+ }
4620
+ return fail("expected ',' or '}' in object");
4621
+ }
4622
+ }
4623
+ if (c === "[") {
4624
+ i++;
4625
+ const out = [];
4626
+ skip();
4627
+ if (text2[i] === "]") {
4628
+ i++;
4629
+ return out;
4630
+ }
4631
+ for (; ; ) {
4632
+ out.push(parseValue());
4633
+ skip();
4634
+ if (text2[i] === ",") {
4635
+ i++;
4636
+ skip();
4637
+ if (text2[i] === "]") {
4638
+ i++;
4639
+ return out;
4640
+ }
4641
+ continue;
4642
+ }
4643
+ if (text2[i] === "]") {
4644
+ i++;
4645
+ return out;
4646
+ }
4647
+ return fail("expected ',' or ']' in array");
4648
+ }
4649
+ }
4650
+ if (c === '"' || c === "'") return parseString();
4651
+ if (text2.startsWith("true", i)) {
4652
+ i += 4;
4653
+ return true;
4654
+ }
4655
+ if (text2.startsWith("false", i)) {
4656
+ i += 5;
4657
+ return false;
4658
+ }
4659
+ if (text2.startsWith("null", i)) {
4660
+ i += 4;
4661
+ return null;
4662
+ }
4663
+ if (/[-+0-9.]/.test(c)) return parseNumber();
4664
+ return fail(`unexpected character '${c}'`);
4665
+ };
4666
+ const value = parseValue();
4667
+ skip();
4668
+ if (i !== text2.length) fail("trailing content after the top-level value");
4669
+ return value;
4670
+ }
4671
+ function parseFragment(text2, file) {
4672
+ const value = parseJson5(text2, file);
4673
+ if (value === null || typeof value !== "object" || Array.isArray(value)) {
4674
+ throw new Json5Error("a config fragment must be a JSON object at the top level", 1, 1, file);
4675
+ }
4676
+ return value;
4677
+ }
4678
+
4679
+ // src/commands/install-policy.ts
4680
+ async function installPolicy(args, globals) {
4681
+ let verdict = { protocolVersion: 1, decision: "block", reason: "Cell install policy is unavailable or invalid." };
4682
+ try {
4683
+ if (args.length) throw new Error();
4684
+ const cell = resolveCell(globals.cell);
4685
+ for (const [key, expected] of [["OPENCLAW_STATE_DIR", cell.stateDir], ["OPENCLAW_CONFIG_PATH", cell.configPath], ["CLAWOS_CELL", cell.name]]) {
4686
+ if (process.env[key] && process.env[key] !== expected) throw new Error();
4687
+ }
4688
+ let input = "";
4689
+ for await (const chunk of process.stdin) {
4690
+ input += chunk;
4691
+ if (Buffer.byteLength(input) > 1024 * 1024) throw new Error();
4692
+ }
4693
+ const material = JSON.parse(input);
4694
+ if (material.protocolVersion !== 1) throw new Error();
4695
+ const config = parseFragment(readFileSync2(cell.configPath, "utf8"), "cell config");
4696
+ const result = evaluateInstall(config.plugins?.entries?.["clawos-kernel"]?.config?.install, material);
4697
+ verdict = { ...result, reason: result.reason ?? "Cell install policy allows this material." };
4698
+ } catch {
4699
+ }
4700
+ process.stdout.write(`${JSON.stringify(verdict)}
4701
+ `);
4702
+ return 0;
4703
+ }
4704
+
4705
+ // src/options.ts
4706
+ function parseGlobals(argv) {
4707
+ const globals = { cell: "default", json: false, yes: false };
4708
+ const rest = [];
4709
+ for (let i = 0; i < argv.length; i++) {
4710
+ const arg = argv[i];
4711
+ if (arg === "--cell") {
4712
+ const value = argv[++i];
4713
+ if (!value) throw new Error("--cell requires a name");
4714
+ globals.cell = value;
4715
+ } else if (arg.startsWith("--cell=")) {
4716
+ globals.cell = arg.slice("--cell=".length);
4717
+ } else if (arg === "--json") {
4718
+ globals.json = true;
4719
+ } else if (arg === "--yes" || arg === "-y") {
4720
+ globals.yes = true;
4721
+ } else {
4722
+ rest.push(arg);
4723
+ }
4724
+ }
4725
+ return { globals, rest };
4726
+ }
4727
+
4728
+ // src/policy-entry.ts
4729
+ try {
4730
+ const { globals, rest } = parseGlobals(process.argv.slice(2));
4731
+ void installPolicy(rest, globals).then((code) => process.exit(code)).catch(() => process.exit(1));
4732
+ } catch {
4733
+ process.exit(1);
4734
+ }