@alfe.ai/openclaw 0.0.22 → 0.0.24

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.
@@ -0,0 +1,3302 @@
1
+ //#region \0rolldown/runtime.js
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __commonJSMin = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports);
9
+ var __exportAll = (all, no_symbols) => {
10
+ let target = {};
11
+ for (var name in all) __defProp(target, name, {
12
+ get: all[name],
13
+ enumerable: true
14
+ });
15
+ if (!no_symbols) __defProp(target, Symbol.toStringTag, { value: "Module" });
16
+ return target;
17
+ };
18
+ var __copyProps = (to, from, except, desc) => {
19
+ if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
20
+ key = keys[i];
21
+ if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
22
+ get: ((k) => from[k]).bind(null, key),
23
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
24
+ });
25
+ }
26
+ return to;
27
+ };
28
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
29
+ value: mod,
30
+ enumerable: true
31
+ }) : target, mod));
32
+ //#endregion
33
+ let node_path = require("node:path");
34
+ let node_os = require("node:os");
35
+ let _alfe_ai_config = require("@alfe.ai/config");
36
+ let _alfe_ai_agent_api_client = require("@alfe.ai/agent-api-client");
37
+ let node_net = require("node:net");
38
+ let node_crypto = require("node:crypto");
39
+ let node_events = require("node:events");
40
+ let _auriclabs_logger = require("@auriclabs/logger");
41
+ //#region ../../node_modules/.pnpm/@sinclair+typebox@0.34.48/node_modules/@sinclair/typebox/build/esm/type/guard/value.mjs
42
+ /** Returns true if this value is an async iterator */
43
+ function IsAsyncIterator$2(value) {
44
+ return IsObject$3(value) && !IsArray$3(value) && !IsUint8Array$2(value) && Symbol.asyncIterator in value;
45
+ }
46
+ /** Returns true if this value is an array */
47
+ function IsArray$3(value) {
48
+ return Array.isArray(value);
49
+ }
50
+ /** Returns true if this value is bigint */
51
+ function IsBigInt$2(value) {
52
+ return typeof value === "bigint";
53
+ }
54
+ /** Returns true if this value is a boolean */
55
+ function IsBoolean$2(value) {
56
+ return typeof value === "boolean";
57
+ }
58
+ /** Returns true if this value is a Date object */
59
+ function IsDate$2(value) {
60
+ return value instanceof globalThis.Date;
61
+ }
62
+ /** Returns true if this value is a function */
63
+ function IsFunction$2(value) {
64
+ return typeof value === "function";
65
+ }
66
+ /** Returns true if this value is an iterator */
67
+ function IsIterator$2(value) {
68
+ return IsObject$3(value) && !IsArray$3(value) && !IsUint8Array$2(value) && Symbol.iterator in value;
69
+ }
70
+ /** Returns true if this value is null */
71
+ function IsNull$2(value) {
72
+ return value === null;
73
+ }
74
+ /** Returns true if this value is number */
75
+ function IsNumber$3(value) {
76
+ return typeof value === "number";
77
+ }
78
+ /** Returns true if this value is an object */
79
+ function IsObject$3(value) {
80
+ return typeof value === "object" && value !== null;
81
+ }
82
+ /** Returns true if this value is RegExp */
83
+ function IsRegExp$2(value) {
84
+ return value instanceof globalThis.RegExp;
85
+ }
86
+ /** Returns true if this value is string */
87
+ function IsString$2(value) {
88
+ return typeof value === "string";
89
+ }
90
+ /** Returns true if this value is symbol */
91
+ function IsSymbol$2(value) {
92
+ return typeof value === "symbol";
93
+ }
94
+ /** Returns true if this value is a Uint8Array */
95
+ function IsUint8Array$2(value) {
96
+ return value instanceof globalThis.Uint8Array;
97
+ }
98
+ /** Returns true if this value is undefined */
99
+ function IsUndefined$3(value) {
100
+ return value === void 0;
101
+ }
102
+ //#endregion
103
+ //#region ../../node_modules/.pnpm/@sinclair+typebox@0.34.48/node_modules/@sinclair/typebox/build/esm/type/clone/value.mjs
104
+ function ArrayType(value) {
105
+ return value.map((value) => Visit$2(value));
106
+ }
107
+ function DateType(value) {
108
+ return new Date(value.getTime());
109
+ }
110
+ function Uint8ArrayType(value) {
111
+ return new Uint8Array(value);
112
+ }
113
+ function RegExpType(value) {
114
+ return new RegExp(value.source, value.flags);
115
+ }
116
+ function ObjectType(value) {
117
+ const result = {};
118
+ for (const key of Object.getOwnPropertyNames(value)) result[key] = Visit$2(value[key]);
119
+ for (const key of Object.getOwnPropertySymbols(value)) result[key] = Visit$2(value[key]);
120
+ return result;
121
+ }
122
+ function Visit$2(value) {
123
+ return IsArray$3(value) ? ArrayType(value) : IsDate$2(value) ? DateType(value) : IsUint8Array$2(value) ? Uint8ArrayType(value) : IsRegExp$2(value) ? RegExpType(value) : IsObject$3(value) ? ObjectType(value) : value;
124
+ }
125
+ /** Clones a value */
126
+ function Clone(value) {
127
+ return Visit$2(value);
128
+ }
129
+ //#endregion
130
+ //#region ../../node_modules/.pnpm/@sinclair+typebox@0.34.48/node_modules/@sinclair/typebox/build/esm/type/clone/type.mjs
131
+ /** Clones a Type */
132
+ function CloneType(schema, options) {
133
+ return options === void 0 ? Clone(schema) : Clone({
134
+ ...options,
135
+ ...schema
136
+ });
137
+ }
138
+ //#endregion
139
+ //#region ../../node_modules/.pnpm/@sinclair+typebox@0.34.48/node_modules/@sinclair/typebox/build/esm/value/guard/guard.mjs
140
+ /** Returns true of this value is an object type */
141
+ function IsObject$2(value) {
142
+ return value !== null && typeof value === "object";
143
+ }
144
+ /** Returns true if this value is an array, but not a typed array */
145
+ function IsArray$2(value) {
146
+ return globalThis.Array.isArray(value) && !globalThis.ArrayBuffer.isView(value);
147
+ }
148
+ /** Returns true if this value is an undefined */
149
+ function IsUndefined$2(value) {
150
+ return value === void 0;
151
+ }
152
+ /** Returns true if this value is an number */
153
+ function IsNumber$2(value) {
154
+ return typeof value === "number";
155
+ }
156
+ //#endregion
157
+ //#region ../../node_modules/.pnpm/@sinclair+typebox@0.34.48/node_modules/@sinclair/typebox/build/esm/system/policy.mjs
158
+ var TypeSystemPolicy;
159
+ (function(TypeSystemPolicy) {
160
+ /**
161
+ * Configures the instantiation behavior of TypeBox types. The `default` option assigns raw JavaScript
162
+ * references for embedded types, which may cause side effects if type properties are explicitly updated
163
+ * outside the TypeBox type builder. The `clone` option creates copies of any shared types upon creation,
164
+ * preventing unintended side effects. The `freeze` option applies `Object.freeze()` to the type, making
165
+ * it fully readonly and immutable. Implementations should use `default` whenever possible, as it is the
166
+ * fastest way to instantiate types. The default setting is `default`.
167
+ */
168
+ TypeSystemPolicy.InstanceMode = "default";
169
+ /** Sets whether TypeBox should assert optional properties using the TypeScript `exactOptionalPropertyTypes` assertion policy. The default is `false` */
170
+ TypeSystemPolicy.ExactOptionalPropertyTypes = false;
171
+ /** Sets whether arrays should be treated as a kind of objects. The default is `false` */
172
+ TypeSystemPolicy.AllowArrayObject = false;
173
+ /** Sets whether `NaN` or `Infinity` should be treated as valid numeric values. The default is `false` */
174
+ TypeSystemPolicy.AllowNaN = false;
175
+ /** Sets whether `null` should validate for void types. The default is `false` */
176
+ TypeSystemPolicy.AllowNullVoid = false;
177
+ /** Checks this value using the ExactOptionalPropertyTypes policy */
178
+ function IsExactOptionalProperty(value, key) {
179
+ return TypeSystemPolicy.ExactOptionalPropertyTypes ? key in value : value[key] !== void 0;
180
+ }
181
+ TypeSystemPolicy.IsExactOptionalProperty = IsExactOptionalProperty;
182
+ /** Checks this value using the AllowArrayObjects policy */
183
+ function IsObjectLike(value) {
184
+ const isObject = IsObject$2(value);
185
+ return TypeSystemPolicy.AllowArrayObject ? isObject : isObject && !IsArray$2(value);
186
+ }
187
+ TypeSystemPolicy.IsObjectLike = IsObjectLike;
188
+ /** Checks this value as a record using the AllowArrayObjects policy */
189
+ function IsRecordLike(value) {
190
+ return IsObjectLike(value) && !(value instanceof Date) && !(value instanceof Uint8Array);
191
+ }
192
+ TypeSystemPolicy.IsRecordLike = IsRecordLike;
193
+ /** Checks this value using the AllowNaN policy */
194
+ function IsNumberLike(value) {
195
+ return TypeSystemPolicy.AllowNaN ? IsNumber$2(value) : Number.isFinite(value);
196
+ }
197
+ TypeSystemPolicy.IsNumberLike = IsNumberLike;
198
+ /** Checks this value using the AllowVoidNull policy */
199
+ function IsVoidLike(value) {
200
+ const isUndefined = IsUndefined$2(value);
201
+ return TypeSystemPolicy.AllowNullVoid ? isUndefined || value === null : isUndefined;
202
+ }
203
+ TypeSystemPolicy.IsVoidLike = IsVoidLike;
204
+ })(TypeSystemPolicy || (TypeSystemPolicy = {}));
205
+ //#endregion
206
+ //#region ../../node_modules/.pnpm/@sinclair+typebox@0.34.48/node_modules/@sinclair/typebox/build/esm/type/create/immutable.mjs
207
+ function ImmutableArray(value) {
208
+ return globalThis.Object.freeze(value).map((value) => Immutable(value));
209
+ }
210
+ function ImmutableDate(value) {
211
+ return value;
212
+ }
213
+ function ImmutableUint8Array(value) {
214
+ return value;
215
+ }
216
+ function ImmutableRegExp(value) {
217
+ return value;
218
+ }
219
+ function ImmutableObject(value) {
220
+ const result = {};
221
+ for (const key of Object.getOwnPropertyNames(value)) result[key] = Immutable(value[key]);
222
+ for (const key of Object.getOwnPropertySymbols(value)) result[key] = Immutable(value[key]);
223
+ return globalThis.Object.freeze(result);
224
+ }
225
+ /** Specialized deep immutable value. Applies freeze recursively to the given value */
226
+ function Immutable(value) {
227
+ return IsArray$3(value) ? ImmutableArray(value) : IsDate$2(value) ? ImmutableDate(value) : IsUint8Array$2(value) ? ImmutableUint8Array(value) : IsRegExp$2(value) ? ImmutableRegExp(value) : IsObject$3(value) ? ImmutableObject(value) : value;
228
+ }
229
+ //#endregion
230
+ //#region ../../node_modules/.pnpm/@sinclair+typebox@0.34.48/node_modules/@sinclair/typebox/build/esm/type/create/type.mjs
231
+ /** Creates TypeBox schematics using the configured InstanceMode */
232
+ function CreateType(schema, options) {
233
+ const result = options !== void 0 ? {
234
+ ...options,
235
+ ...schema
236
+ } : schema;
237
+ switch (TypeSystemPolicy.InstanceMode) {
238
+ case "freeze": return Immutable(result);
239
+ case "clone": return Clone(result);
240
+ default: return result;
241
+ }
242
+ }
243
+ //#endregion
244
+ //#region ../../node_modules/.pnpm/@sinclair+typebox@0.34.48/node_modules/@sinclair/typebox/build/esm/type/error/error.mjs
245
+ /** The base Error type thrown for all TypeBox exceptions */
246
+ var TypeBoxError = class extends Error {
247
+ constructor(message) {
248
+ super(message);
249
+ }
250
+ };
251
+ //#endregion
252
+ //#region ../../node_modules/.pnpm/@sinclair+typebox@0.34.48/node_modules/@sinclair/typebox/build/esm/type/symbols/symbols.mjs
253
+ /** Symbol key applied to transform types */
254
+ const TransformKind = Symbol.for("TypeBox.Transform");
255
+ /** Symbol key applied to readonly types */
256
+ const ReadonlyKind = Symbol.for("TypeBox.Readonly");
257
+ /** Symbol key applied to optional types */
258
+ const OptionalKind = Symbol.for("TypeBox.Optional");
259
+ /** Symbol key applied to types */
260
+ const Hint = Symbol.for("TypeBox.Hint");
261
+ /** Symbol key applied to types */
262
+ const Kind = Symbol.for("TypeBox.Kind");
263
+ //#endregion
264
+ //#region ../../node_modules/.pnpm/@sinclair+typebox@0.34.48/node_modules/@sinclair/typebox/build/esm/type/guard/kind.mjs
265
+ /** `[Kind-Only]` Returns true if this value has a Readonly symbol */
266
+ function IsReadonly(value) {
267
+ return IsObject$3(value) && value[ReadonlyKind] === "Readonly";
268
+ }
269
+ /** `[Kind-Only]` Returns true if this value has a Optional symbol */
270
+ function IsOptional$1(value) {
271
+ return IsObject$3(value) && value[OptionalKind] === "Optional";
272
+ }
273
+ /** `[Kind-Only]` Returns true if the given value is TAny */
274
+ function IsAny$1(value) {
275
+ return IsKindOf$1(value, "Any");
276
+ }
277
+ /** `[Kind-Only]` Returns true if the given value is TArgument */
278
+ function IsArgument$1(value) {
279
+ return IsKindOf$1(value, "Argument");
280
+ }
281
+ /** `[Kind-Only]` Returns true if the given value is TArray */
282
+ function IsArray$1(value) {
283
+ return IsKindOf$1(value, "Array");
284
+ }
285
+ /** `[Kind-Only]` Returns true if the given value is TAsyncIterator */
286
+ function IsAsyncIterator$1(value) {
287
+ return IsKindOf$1(value, "AsyncIterator");
288
+ }
289
+ /** `[Kind-Only]` Returns true if the given value is TBigInt */
290
+ function IsBigInt$1(value) {
291
+ return IsKindOf$1(value, "BigInt");
292
+ }
293
+ /** `[Kind-Only]` Returns true if the given value is TBoolean */
294
+ function IsBoolean$1(value) {
295
+ return IsKindOf$1(value, "Boolean");
296
+ }
297
+ /** `[Kind-Only]` Returns true if the given value is TComputed */
298
+ function IsComputed$1(value) {
299
+ return IsKindOf$1(value, "Computed");
300
+ }
301
+ /** `[Kind-Only]` Returns true if the given value is TConstructor */
302
+ function IsConstructor$1(value) {
303
+ return IsKindOf$1(value, "Constructor");
304
+ }
305
+ /** `[Kind-Only]` Returns true if the given value is TDate */
306
+ function IsDate$1(value) {
307
+ return IsKindOf$1(value, "Date");
308
+ }
309
+ /** `[Kind-Only]` Returns true if the given value is TFunction */
310
+ function IsFunction$1(value) {
311
+ return IsKindOf$1(value, "Function");
312
+ }
313
+ /** `[Kind-Only]` Returns true if the given value is TInteger */
314
+ function IsInteger$1(value) {
315
+ return IsKindOf$1(value, "Integer");
316
+ }
317
+ /** `[Kind-Only]` Returns true if the given value is TIntersect */
318
+ function IsIntersect$1(value) {
319
+ return IsKindOf$1(value, "Intersect");
320
+ }
321
+ /** `[Kind-Only]` Returns true if the given value is TIterator */
322
+ function IsIterator$1(value) {
323
+ return IsKindOf$1(value, "Iterator");
324
+ }
325
+ /** `[Kind-Only]` Returns true if the given value is a TKind with the given name. */
326
+ function IsKindOf$1(value, kind) {
327
+ return IsObject$3(value) && Kind in value && value[Kind] === kind;
328
+ }
329
+ /** `[Kind-Only]` Returns true if the given value is TLiteralValue */
330
+ function IsLiteralValue$1(value) {
331
+ return IsBoolean$2(value) || IsNumber$3(value) || IsString$2(value);
332
+ }
333
+ /** `[Kind-Only]` Returns true if the given value is TLiteral */
334
+ function IsLiteral$1(value) {
335
+ return IsKindOf$1(value, "Literal");
336
+ }
337
+ /** `[Kind-Only]` Returns true if the given value is a TMappedKey */
338
+ function IsMappedKey$1(value) {
339
+ return IsKindOf$1(value, "MappedKey");
340
+ }
341
+ /** `[Kind-Only]` Returns true if the given value is TMappedResult */
342
+ function IsMappedResult$1(value) {
343
+ return IsKindOf$1(value, "MappedResult");
344
+ }
345
+ /** `[Kind-Only]` Returns true if the given value is TNever */
346
+ function IsNever$1(value) {
347
+ return IsKindOf$1(value, "Never");
348
+ }
349
+ /** `[Kind-Only]` Returns true if the given value is TNot */
350
+ function IsNot$1(value) {
351
+ return IsKindOf$1(value, "Not");
352
+ }
353
+ /** `[Kind-Only]` Returns true if the given value is TNull */
354
+ function IsNull$1(value) {
355
+ return IsKindOf$1(value, "Null");
356
+ }
357
+ /** `[Kind-Only]` Returns true if the given value is TNumber */
358
+ function IsNumber$1(value) {
359
+ return IsKindOf$1(value, "Number");
360
+ }
361
+ /** `[Kind-Only]` Returns true if the given value is TObject */
362
+ function IsObject$1(value) {
363
+ return IsKindOf$1(value, "Object");
364
+ }
365
+ /** `[Kind-Only]` Returns true if the given value is TPromise */
366
+ function IsPromise$1(value) {
367
+ return IsKindOf$1(value, "Promise");
368
+ }
369
+ /** `[Kind-Only]` Returns true if the given value is TRecord */
370
+ function IsRecord$1(value) {
371
+ return IsKindOf$1(value, "Record");
372
+ }
373
+ /** `[Kind-Only]` Returns true if the given value is TRef */
374
+ function IsRef$1(value) {
375
+ return IsKindOf$1(value, "Ref");
376
+ }
377
+ /** `[Kind-Only]` Returns true if the given value is TRegExp */
378
+ function IsRegExp$1(value) {
379
+ return IsKindOf$1(value, "RegExp");
380
+ }
381
+ /** `[Kind-Only]` Returns true if the given value is TString */
382
+ function IsString$1(value) {
383
+ return IsKindOf$1(value, "String");
384
+ }
385
+ /** `[Kind-Only]` Returns true if the given value is TSymbol */
386
+ function IsSymbol$1(value) {
387
+ return IsKindOf$1(value, "Symbol");
388
+ }
389
+ /** `[Kind-Only]` Returns true if the given value is TTemplateLiteral */
390
+ function IsTemplateLiteral$1(value) {
391
+ return IsKindOf$1(value, "TemplateLiteral");
392
+ }
393
+ /** `[Kind-Only]` Returns true if the given value is TThis */
394
+ function IsThis$1(value) {
395
+ return IsKindOf$1(value, "This");
396
+ }
397
+ /** `[Kind-Only]` Returns true of this value is TTransform */
398
+ function IsTransform$1(value) {
399
+ return IsObject$3(value) && TransformKind in value;
400
+ }
401
+ /** `[Kind-Only]` Returns true if the given value is TTuple */
402
+ function IsTuple$1(value) {
403
+ return IsKindOf$1(value, "Tuple");
404
+ }
405
+ /** `[Kind-Only]` Returns true if the given value is TUndefined */
406
+ function IsUndefined$1(value) {
407
+ return IsKindOf$1(value, "Undefined");
408
+ }
409
+ /** `[Kind-Only]` Returns true if the given value is TUnion */
410
+ function IsUnion$1(value) {
411
+ return IsKindOf$1(value, "Union");
412
+ }
413
+ /** `[Kind-Only]` Returns true if the given value is TUint8Array */
414
+ function IsUint8Array$1(value) {
415
+ return IsKindOf$1(value, "Uint8Array");
416
+ }
417
+ /** `[Kind-Only]` Returns true if the given value is TUnknown */
418
+ function IsUnknown$1(value) {
419
+ return IsKindOf$1(value, "Unknown");
420
+ }
421
+ /** `[Kind-Only]` Returns true if the given value is a raw TUnsafe */
422
+ function IsUnsafe$1(value) {
423
+ return IsKindOf$1(value, "Unsafe");
424
+ }
425
+ /** `[Kind-Only]` Returns true if the given value is TVoid */
426
+ function IsVoid$1(value) {
427
+ return IsKindOf$1(value, "Void");
428
+ }
429
+ /** `[Kind-Only]` Returns true if the given value is TKind */
430
+ function IsKind$1(value) {
431
+ return IsObject$3(value) && Kind in value && IsString$2(value[Kind]);
432
+ }
433
+ /** `[Kind-Only]` Returns true if the given value is TSchema */
434
+ function IsSchema$1(value) {
435
+ return IsAny$1(value) || IsArgument$1(value) || IsArray$1(value) || IsBoolean$1(value) || IsBigInt$1(value) || IsAsyncIterator$1(value) || IsComputed$1(value) || IsConstructor$1(value) || IsDate$1(value) || IsFunction$1(value) || IsInteger$1(value) || IsIntersect$1(value) || IsIterator$1(value) || IsLiteral$1(value) || IsMappedKey$1(value) || IsMappedResult$1(value) || IsNever$1(value) || IsNot$1(value) || IsNull$1(value) || IsNumber$1(value) || IsObject$1(value) || IsPromise$1(value) || IsRecord$1(value) || IsRef$1(value) || IsRegExp$1(value) || IsString$1(value) || IsSymbol$1(value) || IsTemplateLiteral$1(value) || IsThis$1(value) || IsTuple$1(value) || IsUndefined$1(value) || IsUnion$1(value) || IsUint8Array$1(value) || IsUnknown$1(value) || IsUnsafe$1(value) || IsVoid$1(value) || IsKind$1(value);
436
+ }
437
+ //#endregion
438
+ //#region ../../node_modules/.pnpm/@sinclair+typebox@0.34.48/node_modules/@sinclair/typebox/build/esm/type/guard/type.mjs
439
+ const KnownTypes = [
440
+ "Argument",
441
+ "Any",
442
+ "Array",
443
+ "AsyncIterator",
444
+ "BigInt",
445
+ "Boolean",
446
+ "Computed",
447
+ "Constructor",
448
+ "Date",
449
+ "Enum",
450
+ "Function",
451
+ "Integer",
452
+ "Intersect",
453
+ "Iterator",
454
+ "Literal",
455
+ "MappedKey",
456
+ "MappedResult",
457
+ "Not",
458
+ "Null",
459
+ "Number",
460
+ "Object",
461
+ "Promise",
462
+ "Record",
463
+ "Ref",
464
+ "RegExp",
465
+ "String",
466
+ "Symbol",
467
+ "TemplateLiteral",
468
+ "This",
469
+ "Tuple",
470
+ "Undefined",
471
+ "Union",
472
+ "Uint8Array",
473
+ "Unknown",
474
+ "Void"
475
+ ];
476
+ function IsPattern(value) {
477
+ try {
478
+ new RegExp(value);
479
+ return true;
480
+ } catch {
481
+ return false;
482
+ }
483
+ }
484
+ function IsControlCharacterFree(value) {
485
+ if (!IsString$2(value)) return false;
486
+ for (let i = 0; i < value.length; i++) {
487
+ const code = value.charCodeAt(i);
488
+ if (code >= 7 && code <= 13 || code === 27 || code === 127) return false;
489
+ }
490
+ return true;
491
+ }
492
+ function IsAdditionalProperties(value) {
493
+ return IsOptionalBoolean(value) || IsSchema(value);
494
+ }
495
+ function IsOptionalBigInt(value) {
496
+ return IsUndefined$3(value) || IsBigInt$2(value);
497
+ }
498
+ function IsOptionalNumber(value) {
499
+ return IsUndefined$3(value) || IsNumber$3(value);
500
+ }
501
+ function IsOptionalBoolean(value) {
502
+ return IsUndefined$3(value) || IsBoolean$2(value);
503
+ }
504
+ function IsOptionalString(value) {
505
+ return IsUndefined$3(value) || IsString$2(value);
506
+ }
507
+ function IsOptionalPattern(value) {
508
+ return IsUndefined$3(value) || IsString$2(value) && IsControlCharacterFree(value) && IsPattern(value);
509
+ }
510
+ function IsOptionalFormat(value) {
511
+ return IsUndefined$3(value) || IsString$2(value) && IsControlCharacterFree(value);
512
+ }
513
+ function IsOptionalSchema(value) {
514
+ return IsUndefined$3(value) || IsSchema(value);
515
+ }
516
+ /** Returns true if this value has a Optional symbol */
517
+ function IsOptional(value) {
518
+ return IsObject$3(value) && value[OptionalKind] === "Optional";
519
+ }
520
+ /** Returns true if the given value is TAny */
521
+ function IsAny(value) {
522
+ return IsKindOf(value, "Any") && IsOptionalString(value.$id);
523
+ }
524
+ /** Returns true if the given value is TArgument */
525
+ function IsArgument(value) {
526
+ return IsKindOf(value, "Argument") && IsNumber$3(value.index);
527
+ }
528
+ /** Returns true if the given value is TArray */
529
+ function IsArray(value) {
530
+ return IsKindOf(value, "Array") && value.type === "array" && IsOptionalString(value.$id) && IsSchema(value.items) && IsOptionalNumber(value.minItems) && IsOptionalNumber(value.maxItems) && IsOptionalBoolean(value.uniqueItems) && IsOptionalSchema(value.contains) && IsOptionalNumber(value.minContains) && IsOptionalNumber(value.maxContains);
531
+ }
532
+ /** Returns true if the given value is TAsyncIterator */
533
+ function IsAsyncIterator(value) {
534
+ return IsKindOf(value, "AsyncIterator") && value.type === "AsyncIterator" && IsOptionalString(value.$id) && IsSchema(value.items);
535
+ }
536
+ /** Returns true if the given value is TBigInt */
537
+ function IsBigInt(value) {
538
+ return IsKindOf(value, "BigInt") && value.type === "bigint" && IsOptionalString(value.$id) && IsOptionalBigInt(value.exclusiveMaximum) && IsOptionalBigInt(value.exclusiveMinimum) && IsOptionalBigInt(value.maximum) && IsOptionalBigInt(value.minimum) && IsOptionalBigInt(value.multipleOf);
539
+ }
540
+ /** Returns true if the given value is TBoolean */
541
+ function IsBoolean(value) {
542
+ return IsKindOf(value, "Boolean") && value.type === "boolean" && IsOptionalString(value.$id);
543
+ }
544
+ /** Returns true if the given value is TComputed */
545
+ function IsComputed(value) {
546
+ return IsKindOf(value, "Computed") && IsString$2(value.target) && IsArray$3(value.parameters) && value.parameters.every((schema) => IsSchema(schema));
547
+ }
548
+ /** Returns true if the given value is TConstructor */
549
+ function IsConstructor(value) {
550
+ return IsKindOf(value, "Constructor") && value.type === "Constructor" && IsOptionalString(value.$id) && IsArray$3(value.parameters) && value.parameters.every((schema) => IsSchema(schema)) && IsSchema(value.returns);
551
+ }
552
+ /** Returns true if the given value is TDate */
553
+ function IsDate(value) {
554
+ return IsKindOf(value, "Date") && value.type === "Date" && IsOptionalString(value.$id) && IsOptionalNumber(value.exclusiveMaximumTimestamp) && IsOptionalNumber(value.exclusiveMinimumTimestamp) && IsOptionalNumber(value.maximumTimestamp) && IsOptionalNumber(value.minimumTimestamp) && IsOptionalNumber(value.multipleOfTimestamp);
555
+ }
556
+ /** Returns true if the given value is TFunction */
557
+ function IsFunction(value) {
558
+ return IsKindOf(value, "Function") && value.type === "Function" && IsOptionalString(value.$id) && IsArray$3(value.parameters) && value.parameters.every((schema) => IsSchema(schema)) && IsSchema(value.returns);
559
+ }
560
+ /** Returns true if the given value is TInteger */
561
+ function IsInteger(value) {
562
+ return IsKindOf(value, "Integer") && value.type === "integer" && IsOptionalString(value.$id) && IsOptionalNumber(value.exclusiveMaximum) && IsOptionalNumber(value.exclusiveMinimum) && IsOptionalNumber(value.maximum) && IsOptionalNumber(value.minimum) && IsOptionalNumber(value.multipleOf);
563
+ }
564
+ /** Returns true if the given schema is TProperties */
565
+ function IsProperties(value) {
566
+ return IsObject$3(value) && Object.entries(value).every(([key, schema]) => IsControlCharacterFree(key) && IsSchema(schema));
567
+ }
568
+ /** Returns true if the given value is TIntersect */
569
+ function IsIntersect(value) {
570
+ return IsKindOf(value, "Intersect") && (IsString$2(value.type) && value.type !== "object" ? false : true) && IsArray$3(value.allOf) && value.allOf.every((schema) => IsSchema(schema) && !IsTransform(schema)) && IsOptionalString(value.type) && (IsOptionalBoolean(value.unevaluatedProperties) || IsOptionalSchema(value.unevaluatedProperties)) && IsOptionalString(value.$id);
571
+ }
572
+ /** Returns true if the given value is TIterator */
573
+ function IsIterator(value) {
574
+ return IsKindOf(value, "Iterator") && value.type === "Iterator" && IsOptionalString(value.$id) && IsSchema(value.items);
575
+ }
576
+ /** Returns true if the given value is a TKind with the given name. */
577
+ function IsKindOf(value, kind) {
578
+ return IsObject$3(value) && Kind in value && value[Kind] === kind;
579
+ }
580
+ /** Returns true if the given value is TLiteral<string> */
581
+ function IsLiteralString(value) {
582
+ return IsLiteral(value) && IsString$2(value.const);
583
+ }
584
+ /** Returns true if the given value is TLiteral<number> */
585
+ function IsLiteralNumber(value) {
586
+ return IsLiteral(value) && IsNumber$3(value.const);
587
+ }
588
+ /** Returns true if the given value is TLiteral<boolean> */
589
+ function IsLiteralBoolean(value) {
590
+ return IsLiteral(value) && IsBoolean$2(value.const);
591
+ }
592
+ /** Returns true if the given value is TLiteral */
593
+ function IsLiteral(value) {
594
+ return IsKindOf(value, "Literal") && IsOptionalString(value.$id) && IsLiteralValue(value.const);
595
+ }
596
+ /** Returns true if the given value is a TLiteralValue */
597
+ function IsLiteralValue(value) {
598
+ return IsBoolean$2(value) || IsNumber$3(value) || IsString$2(value);
599
+ }
600
+ /** Returns true if the given value is a TMappedKey */
601
+ function IsMappedKey(value) {
602
+ return IsKindOf(value, "MappedKey") && IsArray$3(value.keys) && value.keys.every((key) => IsNumber$3(key) || IsString$2(key));
603
+ }
604
+ /** Returns true if the given value is TMappedResult */
605
+ function IsMappedResult(value) {
606
+ return IsKindOf(value, "MappedResult") && IsProperties(value.properties);
607
+ }
608
+ /** Returns true if the given value is TNever */
609
+ function IsNever(value) {
610
+ return IsKindOf(value, "Never") && IsObject$3(value.not) && Object.getOwnPropertyNames(value.not).length === 0;
611
+ }
612
+ /** Returns true if the given value is TNot */
613
+ function IsNot(value) {
614
+ return IsKindOf(value, "Not") && IsSchema(value.not);
615
+ }
616
+ /** Returns true if the given value is TNull */
617
+ function IsNull(value) {
618
+ return IsKindOf(value, "Null") && value.type === "null" && IsOptionalString(value.$id);
619
+ }
620
+ /** Returns true if the given value is TNumber */
621
+ function IsNumber(value) {
622
+ return IsKindOf(value, "Number") && value.type === "number" && IsOptionalString(value.$id) && IsOptionalNumber(value.exclusiveMaximum) && IsOptionalNumber(value.exclusiveMinimum) && IsOptionalNumber(value.maximum) && IsOptionalNumber(value.minimum) && IsOptionalNumber(value.multipleOf);
623
+ }
624
+ /** Returns true if the given value is TObject */
625
+ function IsObject(value) {
626
+ return IsKindOf(value, "Object") && value.type === "object" && IsOptionalString(value.$id) && IsProperties(value.properties) && IsAdditionalProperties(value.additionalProperties) && IsOptionalNumber(value.minProperties) && IsOptionalNumber(value.maxProperties);
627
+ }
628
+ /** Returns true if the given value is TPromise */
629
+ function IsPromise(value) {
630
+ return IsKindOf(value, "Promise") && value.type === "Promise" && IsOptionalString(value.$id) && IsSchema(value.item);
631
+ }
632
+ /** Returns true if the given value is TRecord */
633
+ function IsRecord(value) {
634
+ return IsKindOf(value, "Record") && value.type === "object" && IsOptionalString(value.$id) && IsAdditionalProperties(value.additionalProperties) && IsObject$3(value.patternProperties) && ((schema) => {
635
+ const keys = Object.getOwnPropertyNames(schema.patternProperties);
636
+ return keys.length === 1 && IsPattern(keys[0]) && IsObject$3(schema.patternProperties) && IsSchema(schema.patternProperties[keys[0]]);
637
+ })(value);
638
+ }
639
+ /** Returns true if the given value is TRef */
640
+ function IsRef(value) {
641
+ return IsKindOf(value, "Ref") && IsOptionalString(value.$id) && IsString$2(value.$ref);
642
+ }
643
+ /** Returns true if the given value is TRegExp */
644
+ function IsRegExp(value) {
645
+ return IsKindOf(value, "RegExp") && IsOptionalString(value.$id) && IsString$2(value.source) && IsString$2(value.flags) && IsOptionalNumber(value.maxLength) && IsOptionalNumber(value.minLength);
646
+ }
647
+ /** Returns true if the given value is TString */
648
+ function IsString(value) {
649
+ return IsKindOf(value, "String") && value.type === "string" && IsOptionalString(value.$id) && IsOptionalNumber(value.minLength) && IsOptionalNumber(value.maxLength) && IsOptionalPattern(value.pattern) && IsOptionalFormat(value.format);
650
+ }
651
+ /** Returns true if the given value is TSymbol */
652
+ function IsSymbol(value) {
653
+ return IsKindOf(value, "Symbol") && value.type === "symbol" && IsOptionalString(value.$id);
654
+ }
655
+ /** Returns true if the given value is TTemplateLiteral */
656
+ function IsTemplateLiteral(value) {
657
+ return IsKindOf(value, "TemplateLiteral") && value.type === "string" && IsString$2(value.pattern) && value.pattern[0] === "^" && value.pattern[value.pattern.length - 1] === "$";
658
+ }
659
+ /** Returns true if the given value is TThis */
660
+ function IsThis(value) {
661
+ return IsKindOf(value, "This") && IsOptionalString(value.$id) && IsString$2(value.$ref);
662
+ }
663
+ /** Returns true of this value is TTransform */
664
+ function IsTransform(value) {
665
+ return IsObject$3(value) && TransformKind in value;
666
+ }
667
+ /** Returns true if the given value is TTuple */
668
+ function IsTuple(value) {
669
+ return IsKindOf(value, "Tuple") && value.type === "array" && IsOptionalString(value.$id) && IsNumber$3(value.minItems) && IsNumber$3(value.maxItems) && value.minItems === value.maxItems && (IsUndefined$3(value.items) && IsUndefined$3(value.additionalItems) && value.minItems === 0 || IsArray$3(value.items) && value.items.every((schema) => IsSchema(schema)));
670
+ }
671
+ /** Returns true if the given value is TUndefined */
672
+ function IsUndefined(value) {
673
+ return IsKindOf(value, "Undefined") && value.type === "undefined" && IsOptionalString(value.$id);
674
+ }
675
+ /** Returns true if the given value is TUnion */
676
+ function IsUnion(value) {
677
+ return IsKindOf(value, "Union") && IsOptionalString(value.$id) && IsObject$3(value) && IsArray$3(value.anyOf) && value.anyOf.every((schema) => IsSchema(schema));
678
+ }
679
+ /** Returns true if the given value is TUint8Array */
680
+ function IsUint8Array(value) {
681
+ return IsKindOf(value, "Uint8Array") && value.type === "Uint8Array" && IsOptionalString(value.$id) && IsOptionalNumber(value.minByteLength) && IsOptionalNumber(value.maxByteLength);
682
+ }
683
+ /** Returns true if the given value is TUnknown */
684
+ function IsUnknown(value) {
685
+ return IsKindOf(value, "Unknown") && IsOptionalString(value.$id);
686
+ }
687
+ /** Returns true if the given value is a raw TUnsafe */
688
+ function IsUnsafe(value) {
689
+ return IsKindOf(value, "Unsafe");
690
+ }
691
+ /** Returns true if the given value is TVoid */
692
+ function IsVoid(value) {
693
+ return IsKindOf(value, "Void") && value.type === "void" && IsOptionalString(value.$id);
694
+ }
695
+ /** Returns true if the given value is TKind */
696
+ function IsKind(value) {
697
+ return IsObject$3(value) && Kind in value && IsString$2(value[Kind]) && !KnownTypes.includes(value[Kind]);
698
+ }
699
+ /** Returns true if the given value is TSchema */
700
+ function IsSchema(value) {
701
+ return IsObject$3(value) && (IsAny(value) || IsArgument(value) || IsArray(value) || IsBoolean(value) || IsBigInt(value) || IsAsyncIterator(value) || IsComputed(value) || IsConstructor(value) || IsDate(value) || IsFunction(value) || IsInteger(value) || IsIntersect(value) || IsIterator(value) || IsLiteral(value) || IsMappedKey(value) || IsMappedResult(value) || IsNever(value) || IsNot(value) || IsNull(value) || IsNumber(value) || IsObject(value) || IsPromise(value) || IsRecord(value) || IsRef(value) || IsRegExp(value) || IsString(value) || IsSymbol(value) || IsTemplateLiteral(value) || IsThis(value) || IsTuple(value) || IsUndefined(value) || IsUnion(value) || IsUint8Array(value) || IsUnknown(value) || IsUnsafe(value) || IsVoid(value) || IsKind(value));
702
+ }
703
+ //#endregion
704
+ //#region ../../node_modules/.pnpm/@sinclair+typebox@0.34.48/node_modules/@sinclair/typebox/build/esm/type/patterns/patterns.mjs
705
+ const PatternBoolean = "(true|false)";
706
+ const PatternNumber = "(0|[1-9][0-9]*)";
707
+ const PatternString = "(.*)";
708
+ const PatternNever = "(?!.*)";
709
+ `${PatternBoolean}`;
710
+ const PatternNumberExact = `^${PatternNumber}$`;
711
+ const PatternStringExact = `^${PatternString}$`;
712
+ const PatternNeverExact = `^${PatternNever}$`;
713
+ //#endregion
714
+ //#region ../../node_modules/.pnpm/@sinclair+typebox@0.34.48/node_modules/@sinclair/typebox/build/esm/type/sets/set.mjs
715
+ /** Returns true if element right is in the set of left */
716
+ function SetIncludes(T, S) {
717
+ return T.includes(S);
718
+ }
719
+ /** Returns a distinct set of elements */
720
+ function SetDistinct(T) {
721
+ return [...new Set(T)];
722
+ }
723
+ /** Returns the Intersect of the given sets */
724
+ function SetIntersect(T, S) {
725
+ return T.filter((L) => S.includes(L));
726
+ }
727
+ function SetIntersectManyResolve(T, Init) {
728
+ return T.reduce((Acc, L) => {
729
+ return SetIntersect(Acc, L);
730
+ }, Init);
731
+ }
732
+ function SetIntersectMany(T) {
733
+ return T.length === 1 ? T[0] : T.length > 1 ? SetIntersectManyResolve(T.slice(1), T[0]) : [];
734
+ }
735
+ /** Returns the Union of multiple sets */
736
+ function SetUnionMany(T) {
737
+ const Acc = [];
738
+ for (const L of T) Acc.push(...L);
739
+ return Acc;
740
+ }
741
+ //#endregion
742
+ //#region ../../node_modules/.pnpm/@sinclair+typebox@0.34.48/node_modules/@sinclair/typebox/build/esm/type/any/any.mjs
743
+ /** `[Json]` Creates an Any type */
744
+ function Any(options) {
745
+ return CreateType({ [Kind]: "Any" }, options);
746
+ }
747
+ //#endregion
748
+ //#region ../../node_modules/.pnpm/@sinclair+typebox@0.34.48/node_modules/@sinclair/typebox/build/esm/type/array/array.mjs
749
+ /** `[Json]` Creates an Array type */
750
+ function Array$1(items, options) {
751
+ return CreateType({
752
+ [Kind]: "Array",
753
+ type: "array",
754
+ items
755
+ }, options);
756
+ }
757
+ //#endregion
758
+ //#region ../../node_modules/.pnpm/@sinclair+typebox@0.34.48/node_modules/@sinclair/typebox/build/esm/type/argument/argument.mjs
759
+ /** `[JavaScript]` Creates an Argument Type. */
760
+ function Argument(index) {
761
+ return CreateType({
762
+ [Kind]: "Argument",
763
+ index
764
+ });
765
+ }
766
+ //#endregion
767
+ //#region ../../node_modules/.pnpm/@sinclair+typebox@0.34.48/node_modules/@sinclair/typebox/build/esm/type/async-iterator/async-iterator.mjs
768
+ /** `[JavaScript]` Creates a AsyncIterator type */
769
+ function AsyncIterator(items, options) {
770
+ return CreateType({
771
+ [Kind]: "AsyncIterator",
772
+ type: "AsyncIterator",
773
+ items
774
+ }, options);
775
+ }
776
+ //#endregion
777
+ //#region ../../node_modules/.pnpm/@sinclair+typebox@0.34.48/node_modules/@sinclair/typebox/build/esm/type/computed/computed.mjs
778
+ /** `[Internal]` Creates a deferred computed type. This type is used exclusively in modules to defer resolution of computable types that contain interior references */
779
+ function Computed(target, parameters, options) {
780
+ return CreateType({
781
+ [Kind]: "Computed",
782
+ target,
783
+ parameters
784
+ }, options);
785
+ }
786
+ //#endregion
787
+ //#region ../../node_modules/.pnpm/@sinclair+typebox@0.34.48/node_modules/@sinclair/typebox/build/esm/type/discard/discard.mjs
788
+ function DiscardKey(value, key) {
789
+ const { [key]: _, ...rest } = value;
790
+ return rest;
791
+ }
792
+ /** Discards property keys from the given value. This function returns a shallow Clone. */
793
+ function Discard(value, keys) {
794
+ return keys.reduce((acc, key) => DiscardKey(acc, key), value);
795
+ }
796
+ //#endregion
797
+ //#region ../../node_modules/.pnpm/@sinclair+typebox@0.34.48/node_modules/@sinclair/typebox/build/esm/type/never/never.mjs
798
+ /** `[Json]` Creates a Never type */
799
+ function Never(options) {
800
+ return CreateType({
801
+ [Kind]: "Never",
802
+ not: {}
803
+ }, options);
804
+ }
805
+ //#endregion
806
+ //#region ../../node_modules/.pnpm/@sinclair+typebox@0.34.48/node_modules/@sinclair/typebox/build/esm/type/mapped/mapped-result.mjs
807
+ function MappedResult(properties) {
808
+ return CreateType({
809
+ [Kind]: "MappedResult",
810
+ properties
811
+ });
812
+ }
813
+ //#endregion
814
+ //#region ../../node_modules/.pnpm/@sinclair+typebox@0.34.48/node_modules/@sinclair/typebox/build/esm/type/constructor/constructor.mjs
815
+ /** `[JavaScript]` Creates a Constructor type */
816
+ function Constructor(parameters, returns, options) {
817
+ return CreateType({
818
+ [Kind]: "Constructor",
819
+ type: "Constructor",
820
+ parameters,
821
+ returns
822
+ }, options);
823
+ }
824
+ //#endregion
825
+ //#region ../../node_modules/.pnpm/@sinclair+typebox@0.34.48/node_modules/@sinclair/typebox/build/esm/type/function/function.mjs
826
+ /** `[JavaScript]` Creates a Function type */
827
+ function Function(parameters, returns, options) {
828
+ return CreateType({
829
+ [Kind]: "Function",
830
+ type: "Function",
831
+ parameters,
832
+ returns
833
+ }, options);
834
+ }
835
+ //#endregion
836
+ //#region ../../node_modules/.pnpm/@sinclair+typebox@0.34.48/node_modules/@sinclair/typebox/build/esm/type/union/union-create.mjs
837
+ function UnionCreate(T, options) {
838
+ return CreateType({
839
+ [Kind]: "Union",
840
+ anyOf: T
841
+ }, options);
842
+ }
843
+ //#endregion
844
+ //#region ../../node_modules/.pnpm/@sinclair+typebox@0.34.48/node_modules/@sinclair/typebox/build/esm/type/union/union-evaluated.mjs
845
+ function IsUnionOptional(types) {
846
+ return types.some((type) => IsOptional$1(type));
847
+ }
848
+ function RemoveOptionalFromRest$1(types) {
849
+ return types.map((left) => IsOptional$1(left) ? RemoveOptionalFromType$1(left) : left);
850
+ }
851
+ function RemoveOptionalFromType$1(T) {
852
+ return Discard(T, [OptionalKind]);
853
+ }
854
+ function ResolveUnion(types, options) {
855
+ return IsUnionOptional(types) ? Optional(UnionCreate(RemoveOptionalFromRest$1(types), options)) : UnionCreate(RemoveOptionalFromRest$1(types), options);
856
+ }
857
+ /** `[Json]` Creates an evaluated Union type */
858
+ function UnionEvaluated(T, options) {
859
+ return T.length === 1 ? CreateType(T[0], options) : T.length === 0 ? Never(options) : ResolveUnion(T, options);
860
+ }
861
+ //#endregion
862
+ //#region ../../node_modules/.pnpm/@sinclair+typebox@0.34.48/node_modules/@sinclair/typebox/build/esm/type/union/union.mjs
863
+ /** `[Json]` Creates a Union type */
864
+ function Union(types, options) {
865
+ return types.length === 0 ? Never(options) : types.length === 1 ? CreateType(types[0], options) : UnionCreate(types, options);
866
+ }
867
+ //#endregion
868
+ //#region ../../node_modules/.pnpm/@sinclair+typebox@0.34.48/node_modules/@sinclair/typebox/build/esm/type/template-literal/parse.mjs
869
+ var TemplateLiteralParserError = class extends TypeBoxError {};
870
+ function Unescape(pattern) {
871
+ return pattern.replace(/\\\$/g, "$").replace(/\\\*/g, "*").replace(/\\\^/g, "^").replace(/\\\|/g, "|").replace(/\\\(/g, "(").replace(/\\\)/g, ")");
872
+ }
873
+ function IsNonEscaped(pattern, index, char) {
874
+ return pattern[index] === char && pattern.charCodeAt(index - 1) !== 92;
875
+ }
876
+ function IsOpenParen(pattern, index) {
877
+ return IsNonEscaped(pattern, index, "(");
878
+ }
879
+ function IsCloseParen(pattern, index) {
880
+ return IsNonEscaped(pattern, index, ")");
881
+ }
882
+ function IsSeparator(pattern, index) {
883
+ return IsNonEscaped(pattern, index, "|");
884
+ }
885
+ function IsGroup(pattern) {
886
+ if (!(IsOpenParen(pattern, 0) && IsCloseParen(pattern, pattern.length - 1))) return false;
887
+ let count = 0;
888
+ for (let index = 0; index < pattern.length; index++) {
889
+ if (IsOpenParen(pattern, index)) count += 1;
890
+ if (IsCloseParen(pattern, index)) count -= 1;
891
+ if (count === 0 && index !== pattern.length - 1) return false;
892
+ }
893
+ return true;
894
+ }
895
+ function InGroup(pattern) {
896
+ return pattern.slice(1, pattern.length - 1);
897
+ }
898
+ function IsPrecedenceOr(pattern) {
899
+ let count = 0;
900
+ for (let index = 0; index < pattern.length; index++) {
901
+ if (IsOpenParen(pattern, index)) count += 1;
902
+ if (IsCloseParen(pattern, index)) count -= 1;
903
+ if (IsSeparator(pattern, index) && count === 0) return true;
904
+ }
905
+ return false;
906
+ }
907
+ function IsPrecedenceAnd(pattern) {
908
+ for (let index = 0; index < pattern.length; index++) if (IsOpenParen(pattern, index)) return true;
909
+ return false;
910
+ }
911
+ function Or(pattern) {
912
+ let [count, start] = [0, 0];
913
+ const expressions = [];
914
+ for (let index = 0; index < pattern.length; index++) {
915
+ if (IsOpenParen(pattern, index)) count += 1;
916
+ if (IsCloseParen(pattern, index)) count -= 1;
917
+ if (IsSeparator(pattern, index) && count === 0) {
918
+ const range = pattern.slice(start, index);
919
+ if (range.length > 0) expressions.push(TemplateLiteralParse(range));
920
+ start = index + 1;
921
+ }
922
+ }
923
+ const range = pattern.slice(start);
924
+ if (range.length > 0) expressions.push(TemplateLiteralParse(range));
925
+ if (expressions.length === 0) return {
926
+ type: "const",
927
+ const: ""
928
+ };
929
+ if (expressions.length === 1) return expressions[0];
930
+ return {
931
+ type: "or",
932
+ expr: expressions
933
+ };
934
+ }
935
+ function And(pattern) {
936
+ function Group(value, index) {
937
+ if (!IsOpenParen(value, index)) throw new TemplateLiteralParserError(`TemplateLiteralParser: Index must point to open parens`);
938
+ let count = 0;
939
+ for (let scan = index; scan < value.length; scan++) {
940
+ if (IsOpenParen(value, scan)) count += 1;
941
+ if (IsCloseParen(value, scan)) count -= 1;
942
+ if (count === 0) return [index, scan];
943
+ }
944
+ throw new TemplateLiteralParserError(`TemplateLiteralParser: Unclosed group parens in expression`);
945
+ }
946
+ function Range(pattern, index) {
947
+ for (let scan = index; scan < pattern.length; scan++) if (IsOpenParen(pattern, scan)) return [index, scan];
948
+ return [index, pattern.length];
949
+ }
950
+ const expressions = [];
951
+ for (let index = 0; index < pattern.length; index++) if (IsOpenParen(pattern, index)) {
952
+ const [start, end] = Group(pattern, index);
953
+ const range = pattern.slice(start, end + 1);
954
+ expressions.push(TemplateLiteralParse(range));
955
+ index = end;
956
+ } else {
957
+ const [start, end] = Range(pattern, index);
958
+ const range = pattern.slice(start, end);
959
+ if (range.length > 0) expressions.push(TemplateLiteralParse(range));
960
+ index = end - 1;
961
+ }
962
+ return expressions.length === 0 ? {
963
+ type: "const",
964
+ const: ""
965
+ } : expressions.length === 1 ? expressions[0] : {
966
+ type: "and",
967
+ expr: expressions
968
+ };
969
+ }
970
+ /** Parses a pattern and returns an expression tree */
971
+ function TemplateLiteralParse(pattern) {
972
+ return IsGroup(pattern) ? TemplateLiteralParse(InGroup(pattern)) : IsPrecedenceOr(pattern) ? Or(pattern) : IsPrecedenceAnd(pattern) ? And(pattern) : {
973
+ type: "const",
974
+ const: Unescape(pattern)
975
+ };
976
+ }
977
+ /** Parses a pattern and strips forward and trailing ^ and $ */
978
+ function TemplateLiteralParseExact(pattern) {
979
+ return TemplateLiteralParse(pattern.slice(1, pattern.length - 1));
980
+ }
981
+ //#endregion
982
+ //#region ../../node_modules/.pnpm/@sinclair+typebox@0.34.48/node_modules/@sinclair/typebox/build/esm/type/template-literal/finite.mjs
983
+ var TemplateLiteralFiniteError = class extends TypeBoxError {};
984
+ function IsNumberExpression(expression) {
985
+ return expression.type === "or" && expression.expr.length === 2 && expression.expr[0].type === "const" && expression.expr[0].const === "0" && expression.expr[1].type === "const" && expression.expr[1].const === "[1-9][0-9]*";
986
+ }
987
+ function IsBooleanExpression(expression) {
988
+ return expression.type === "or" && expression.expr.length === 2 && expression.expr[0].type === "const" && expression.expr[0].const === "true" && expression.expr[1].type === "const" && expression.expr[1].const === "false";
989
+ }
990
+ function IsStringExpression(expression) {
991
+ return expression.type === "const" && expression.const === ".*";
992
+ }
993
+ function IsTemplateLiteralExpressionFinite(expression) {
994
+ return IsNumberExpression(expression) || IsStringExpression(expression) ? false : IsBooleanExpression(expression) ? true : expression.type === "and" ? expression.expr.every((expr) => IsTemplateLiteralExpressionFinite(expr)) : expression.type === "or" ? expression.expr.every((expr) => IsTemplateLiteralExpressionFinite(expr)) : expression.type === "const" ? true : (() => {
995
+ throw new TemplateLiteralFiniteError(`Unknown expression type`);
996
+ })();
997
+ }
998
+ /** Returns true if this TemplateLiteral resolves to a finite set of values */
999
+ function IsTemplateLiteralFinite(schema) {
1000
+ return IsTemplateLiteralExpressionFinite(TemplateLiteralParseExact(schema.pattern));
1001
+ }
1002
+ //#endregion
1003
+ //#region ../../node_modules/.pnpm/@sinclair+typebox@0.34.48/node_modules/@sinclair/typebox/build/esm/type/template-literal/generate.mjs
1004
+ var TemplateLiteralGenerateError = class extends TypeBoxError {};
1005
+ function* GenerateReduce(buffer) {
1006
+ if (buffer.length === 1) return yield* buffer[0];
1007
+ for (const left of buffer[0]) for (const right of GenerateReduce(buffer.slice(1))) yield `${left}${right}`;
1008
+ }
1009
+ function* GenerateAnd(expression) {
1010
+ return yield* GenerateReduce(expression.expr.map((expr) => [...TemplateLiteralExpressionGenerate(expr)]));
1011
+ }
1012
+ function* GenerateOr(expression) {
1013
+ for (const expr of expression.expr) yield* TemplateLiteralExpressionGenerate(expr);
1014
+ }
1015
+ function* GenerateConst(expression) {
1016
+ return yield expression.const;
1017
+ }
1018
+ function* TemplateLiteralExpressionGenerate(expression) {
1019
+ return expression.type === "and" ? yield* GenerateAnd(expression) : expression.type === "or" ? yield* GenerateOr(expression) : expression.type === "const" ? yield* GenerateConst(expression) : (() => {
1020
+ throw new TemplateLiteralGenerateError("Unknown expression");
1021
+ })();
1022
+ }
1023
+ /** Generates a tuple of strings from the given TemplateLiteral. Returns an empty tuple if infinite. */
1024
+ function TemplateLiteralGenerate(schema) {
1025
+ const expression = TemplateLiteralParseExact(schema.pattern);
1026
+ return IsTemplateLiteralExpressionFinite(expression) ? [...TemplateLiteralExpressionGenerate(expression)] : [];
1027
+ }
1028
+ //#endregion
1029
+ //#region ../../node_modules/.pnpm/@sinclair+typebox@0.34.48/node_modules/@sinclair/typebox/build/esm/type/literal/literal.mjs
1030
+ /** `[Json]` Creates a Literal type */
1031
+ function Literal(value, options) {
1032
+ return CreateType({
1033
+ [Kind]: "Literal",
1034
+ const: value,
1035
+ type: typeof value
1036
+ }, options);
1037
+ }
1038
+ //#endregion
1039
+ //#region ../../node_modules/.pnpm/@sinclair+typebox@0.34.48/node_modules/@sinclair/typebox/build/esm/type/boolean/boolean.mjs
1040
+ /** `[Json]` Creates a Boolean type */
1041
+ function Boolean(options) {
1042
+ return CreateType({
1043
+ [Kind]: "Boolean",
1044
+ type: "boolean"
1045
+ }, options);
1046
+ }
1047
+ //#endregion
1048
+ //#region ../../node_modules/.pnpm/@sinclair+typebox@0.34.48/node_modules/@sinclair/typebox/build/esm/type/bigint/bigint.mjs
1049
+ /** `[JavaScript]` Creates a BigInt type */
1050
+ function BigInt(options) {
1051
+ return CreateType({
1052
+ [Kind]: "BigInt",
1053
+ type: "bigint"
1054
+ }, options);
1055
+ }
1056
+ //#endregion
1057
+ //#region ../../node_modules/.pnpm/@sinclair+typebox@0.34.48/node_modules/@sinclair/typebox/build/esm/type/number/number.mjs
1058
+ /** `[Json]` Creates a Number type */
1059
+ function Number$1(options) {
1060
+ return CreateType({
1061
+ [Kind]: "Number",
1062
+ type: "number"
1063
+ }, options);
1064
+ }
1065
+ //#endregion
1066
+ //#region ../../node_modules/.pnpm/@sinclair+typebox@0.34.48/node_modules/@sinclair/typebox/build/esm/type/string/string.mjs
1067
+ /** `[Json]` Creates a String type */
1068
+ function String$1(options) {
1069
+ return CreateType({
1070
+ [Kind]: "String",
1071
+ type: "string"
1072
+ }, options);
1073
+ }
1074
+ //#endregion
1075
+ //#region ../../node_modules/.pnpm/@sinclair+typebox@0.34.48/node_modules/@sinclair/typebox/build/esm/type/template-literal/syntax.mjs
1076
+ function* FromUnion$9(syntax) {
1077
+ const trim = syntax.trim().replace(/"|'/g, "");
1078
+ return trim === "boolean" ? yield Boolean() : trim === "number" ? yield Number$1() : trim === "bigint" ? yield BigInt() : trim === "string" ? yield String$1() : yield (() => {
1079
+ const literals = trim.split("|").map((literal) => Literal(literal.trim()));
1080
+ return literals.length === 0 ? Never() : literals.length === 1 ? literals[0] : UnionEvaluated(literals);
1081
+ })();
1082
+ }
1083
+ function* FromTerminal(syntax) {
1084
+ if (syntax[1] !== "{") return yield* [Literal("$"), ...FromSyntax(syntax.slice(1))];
1085
+ for (let i = 2; i < syntax.length; i++) if (syntax[i] === "}") {
1086
+ const L = FromUnion$9(syntax.slice(2, i));
1087
+ const R = FromSyntax(syntax.slice(i + 1));
1088
+ return yield* [...L, ...R];
1089
+ }
1090
+ yield Literal(syntax);
1091
+ }
1092
+ function* FromSyntax(syntax) {
1093
+ for (let i = 0; i < syntax.length; i++) if (syntax[i] === "$") return yield* [Literal(syntax.slice(0, i)), ...FromTerminal(syntax.slice(i))];
1094
+ yield Literal(syntax);
1095
+ }
1096
+ /** Parses TemplateLiteralSyntax and returns a tuple of TemplateLiteralKinds */
1097
+ function TemplateLiteralSyntax(syntax) {
1098
+ return [...FromSyntax(syntax)];
1099
+ }
1100
+ //#endregion
1101
+ //#region ../../node_modules/.pnpm/@sinclair+typebox@0.34.48/node_modules/@sinclair/typebox/build/esm/type/template-literal/pattern.mjs
1102
+ var TemplateLiteralPatternError = class extends TypeBoxError {};
1103
+ function Escape(value) {
1104
+ return value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
1105
+ }
1106
+ function Visit$1(schema, acc) {
1107
+ return IsTemplateLiteral$1(schema) ? schema.pattern.slice(1, schema.pattern.length - 1) : IsUnion$1(schema) ? `(${schema.anyOf.map((schema) => Visit$1(schema, acc)).join("|")})` : IsNumber$1(schema) ? `${acc}${PatternNumber}` : IsInteger$1(schema) ? `${acc}${PatternNumber}` : IsBigInt$1(schema) ? `${acc}${PatternNumber}` : IsString$1(schema) ? `${acc}${PatternString}` : IsLiteral$1(schema) ? `${acc}${Escape(schema.const.toString())}` : IsBoolean$1(schema) ? `${acc}${PatternBoolean}` : (() => {
1108
+ throw new TemplateLiteralPatternError(`Unexpected Kind '${schema[Kind]}'`);
1109
+ })();
1110
+ }
1111
+ function TemplateLiteralPattern(kinds) {
1112
+ return `^${kinds.map((schema) => Visit$1(schema, "")).join("")}\$`;
1113
+ }
1114
+ //#endregion
1115
+ //#region ../../node_modules/.pnpm/@sinclair+typebox@0.34.48/node_modules/@sinclair/typebox/build/esm/type/template-literal/union.mjs
1116
+ /** Returns a Union from the given TemplateLiteral */
1117
+ function TemplateLiteralToUnion(schema) {
1118
+ return UnionEvaluated(TemplateLiteralGenerate(schema).map((S) => Literal(S)));
1119
+ }
1120
+ //#endregion
1121
+ //#region ../../node_modules/.pnpm/@sinclair+typebox@0.34.48/node_modules/@sinclair/typebox/build/esm/type/template-literal/template-literal.mjs
1122
+ /** `[Json]` Creates a TemplateLiteral type */
1123
+ function TemplateLiteral(unresolved, options) {
1124
+ const pattern = IsString$2(unresolved) ? TemplateLiteralPattern(TemplateLiteralSyntax(unresolved)) : TemplateLiteralPattern(unresolved);
1125
+ return CreateType({
1126
+ [Kind]: "TemplateLiteral",
1127
+ type: "string",
1128
+ pattern
1129
+ }, options);
1130
+ }
1131
+ //#endregion
1132
+ //#region ../../node_modules/.pnpm/@sinclair+typebox@0.34.48/node_modules/@sinclair/typebox/build/esm/type/indexed/indexed-property-keys.mjs
1133
+ function FromTemplateLiteral$2(templateLiteral) {
1134
+ return TemplateLiteralGenerate(templateLiteral).map((key) => key.toString());
1135
+ }
1136
+ function FromUnion$8(types) {
1137
+ const result = [];
1138
+ for (const type of types) result.push(...IndexPropertyKeys(type));
1139
+ return result;
1140
+ }
1141
+ function FromLiteral$1(literalValue) {
1142
+ return [literalValue.toString()];
1143
+ }
1144
+ /** Returns a tuple of PropertyKeys derived from the given TSchema */
1145
+ function IndexPropertyKeys(type) {
1146
+ return [...new Set(IsTemplateLiteral$1(type) ? FromTemplateLiteral$2(type) : IsUnion$1(type) ? FromUnion$8(type.anyOf) : IsLiteral$1(type) ? FromLiteral$1(type.const) : IsNumber$1(type) ? ["[number]"] : IsInteger$1(type) ? ["[number]"] : [])];
1147
+ }
1148
+ //#endregion
1149
+ //#region ../../node_modules/.pnpm/@sinclair+typebox@0.34.48/node_modules/@sinclair/typebox/build/esm/type/indexed/indexed-from-mapped-result.mjs
1150
+ function FromProperties$18(type, properties, options) {
1151
+ const result = {};
1152
+ for (const K2 of Object.getOwnPropertyNames(properties)) result[K2] = Index(type, IndexPropertyKeys(properties[K2]), options);
1153
+ return result;
1154
+ }
1155
+ function FromMappedResult$11(type, mappedResult, options) {
1156
+ return FromProperties$18(type, mappedResult.properties, options);
1157
+ }
1158
+ function IndexFromMappedResult(type, mappedResult, options) {
1159
+ return MappedResult(FromMappedResult$11(type, mappedResult, options));
1160
+ }
1161
+ //#endregion
1162
+ //#region ../../node_modules/.pnpm/@sinclair+typebox@0.34.48/node_modules/@sinclair/typebox/build/esm/type/indexed/indexed.mjs
1163
+ function FromRest$6(types, key) {
1164
+ return types.map((type) => IndexFromPropertyKey(type, key));
1165
+ }
1166
+ function FromIntersectRest(types) {
1167
+ return types.filter((type) => !IsNever$1(type));
1168
+ }
1169
+ function FromIntersect$7(types, key) {
1170
+ return IntersectEvaluated(FromIntersectRest(FromRest$6(types, key)));
1171
+ }
1172
+ function FromUnionRest(types) {
1173
+ return types.some((L) => IsNever$1(L)) ? [] : types;
1174
+ }
1175
+ function FromUnion$7(types, key) {
1176
+ return UnionEvaluated(FromUnionRest(FromRest$6(types, key)));
1177
+ }
1178
+ function FromTuple$4(types, key) {
1179
+ return key in types ? types[key] : key === "[number]" ? UnionEvaluated(types) : Never();
1180
+ }
1181
+ function FromArray$5(type, key) {
1182
+ return key === "[number]" ? type : Never();
1183
+ }
1184
+ function FromProperty$2(properties, propertyKey) {
1185
+ return propertyKey in properties ? properties[propertyKey] : Never();
1186
+ }
1187
+ function IndexFromPropertyKey(type, propertyKey) {
1188
+ return IsIntersect$1(type) ? FromIntersect$7(type.allOf, propertyKey) : IsUnion$1(type) ? FromUnion$7(type.anyOf, propertyKey) : IsTuple$1(type) ? FromTuple$4(type.items ?? [], propertyKey) : IsArray$1(type) ? FromArray$5(type.items, propertyKey) : IsObject$1(type) ? FromProperty$2(type.properties, propertyKey) : Never();
1189
+ }
1190
+ function IndexFromPropertyKeys(type, propertyKeys) {
1191
+ return propertyKeys.map((propertyKey) => IndexFromPropertyKey(type, propertyKey));
1192
+ }
1193
+ function FromSchema(type, propertyKeys) {
1194
+ return UnionEvaluated(IndexFromPropertyKeys(type, propertyKeys));
1195
+ }
1196
+ /** `[Json]` Returns an Indexed property type for the given keys */
1197
+ function Index(type, key, options) {
1198
+ if (IsRef$1(type) || IsRef$1(key)) {
1199
+ const error = `Index types using Ref parameters require both Type and Key to be of TSchema`;
1200
+ if (!IsSchema$1(type) || !IsSchema$1(key)) throw new TypeBoxError(error);
1201
+ return Computed("Index", [type, key]);
1202
+ }
1203
+ if (IsMappedResult$1(key)) return IndexFromMappedResult(type, key, options);
1204
+ if (IsMappedKey$1(key)) return IndexFromMappedKey(type, key, options);
1205
+ return CreateType(IsSchema$1(key) ? FromSchema(type, IndexPropertyKeys(key)) : FromSchema(type, key), options);
1206
+ }
1207
+ //#endregion
1208
+ //#region ../../node_modules/.pnpm/@sinclair+typebox@0.34.48/node_modules/@sinclair/typebox/build/esm/type/indexed/indexed-from-mapped-key.mjs
1209
+ function MappedIndexPropertyKey(type, key, options) {
1210
+ return { [key]: Index(type, [key], Clone(options)) };
1211
+ }
1212
+ function MappedIndexPropertyKeys(type, propertyKeys, options) {
1213
+ return propertyKeys.reduce((result, left) => {
1214
+ return {
1215
+ ...result,
1216
+ ...MappedIndexPropertyKey(type, left, options)
1217
+ };
1218
+ }, {});
1219
+ }
1220
+ function MappedIndexProperties(type, mappedKey, options) {
1221
+ return MappedIndexPropertyKeys(type, mappedKey.keys, options);
1222
+ }
1223
+ function IndexFromMappedKey(type, mappedKey, options) {
1224
+ return MappedResult(MappedIndexProperties(type, mappedKey, options));
1225
+ }
1226
+ //#endregion
1227
+ //#region ../../node_modules/.pnpm/@sinclair+typebox@0.34.48/node_modules/@sinclair/typebox/build/esm/type/iterator/iterator.mjs
1228
+ /** `[JavaScript]` Creates an Iterator type */
1229
+ function Iterator(items, options) {
1230
+ return CreateType({
1231
+ [Kind]: "Iterator",
1232
+ type: "Iterator",
1233
+ items
1234
+ }, options);
1235
+ }
1236
+ //#endregion
1237
+ //#region ../../node_modules/.pnpm/@sinclair+typebox@0.34.48/node_modules/@sinclair/typebox/build/esm/type/object/object.mjs
1238
+ /** Creates a RequiredArray derived from the given TProperties value. */
1239
+ function RequiredArray(properties) {
1240
+ return globalThis.Object.keys(properties).filter((key) => !IsOptional$1(properties[key]));
1241
+ }
1242
+ /** `[Json]` Creates an Object type */
1243
+ function _Object(properties, options) {
1244
+ const required = RequiredArray(properties);
1245
+ return CreateType(required.length > 0 ? {
1246
+ [Kind]: "Object",
1247
+ type: "object",
1248
+ required,
1249
+ properties
1250
+ } : {
1251
+ [Kind]: "Object",
1252
+ type: "object",
1253
+ properties
1254
+ }, options);
1255
+ }
1256
+ /** `[Json]` Creates an Object type */
1257
+ var Object$1 = _Object;
1258
+ //#endregion
1259
+ //#region ../../node_modules/.pnpm/@sinclair+typebox@0.34.48/node_modules/@sinclair/typebox/build/esm/type/promise/promise.mjs
1260
+ /** `[JavaScript]` Creates a Promise type */
1261
+ function Promise$1(item, options) {
1262
+ return CreateType({
1263
+ [Kind]: "Promise",
1264
+ type: "Promise",
1265
+ item
1266
+ }, options);
1267
+ }
1268
+ //#endregion
1269
+ //#region ../../node_modules/.pnpm/@sinclair+typebox@0.34.48/node_modules/@sinclair/typebox/build/esm/type/readonly/readonly.mjs
1270
+ function RemoveReadonly(schema) {
1271
+ return CreateType(Discard(schema, [ReadonlyKind]));
1272
+ }
1273
+ function AddReadonly(schema) {
1274
+ return CreateType({
1275
+ ...schema,
1276
+ [ReadonlyKind]: "Readonly"
1277
+ });
1278
+ }
1279
+ function ReadonlyWithFlag(schema, F) {
1280
+ return F === false ? RemoveReadonly(schema) : AddReadonly(schema);
1281
+ }
1282
+ /** `[Json]` Creates a Readonly property */
1283
+ function Readonly(schema, enable) {
1284
+ const F = enable ?? true;
1285
+ return IsMappedResult$1(schema) ? ReadonlyFromMappedResult(schema, F) : ReadonlyWithFlag(schema, F);
1286
+ }
1287
+ //#endregion
1288
+ //#region ../../node_modules/.pnpm/@sinclair+typebox@0.34.48/node_modules/@sinclair/typebox/build/esm/type/readonly/readonly-from-mapped-result.mjs
1289
+ function FromProperties$17(K, F) {
1290
+ const Acc = {};
1291
+ for (const K2 of globalThis.Object.getOwnPropertyNames(K)) Acc[K2] = Readonly(K[K2], F);
1292
+ return Acc;
1293
+ }
1294
+ function FromMappedResult$10(R, F) {
1295
+ return FromProperties$17(R.properties, F);
1296
+ }
1297
+ function ReadonlyFromMappedResult(R, F) {
1298
+ return MappedResult(FromMappedResult$10(R, F));
1299
+ }
1300
+ //#endregion
1301
+ //#region ../../node_modules/.pnpm/@sinclair+typebox@0.34.48/node_modules/@sinclair/typebox/build/esm/type/tuple/tuple.mjs
1302
+ /** `[Json]` Creates a Tuple type */
1303
+ function Tuple(types, options) {
1304
+ return CreateType(types.length > 0 ? {
1305
+ [Kind]: "Tuple",
1306
+ type: "array",
1307
+ items: types,
1308
+ additionalItems: false,
1309
+ minItems: types.length,
1310
+ maxItems: types.length
1311
+ } : {
1312
+ [Kind]: "Tuple",
1313
+ type: "array",
1314
+ minItems: types.length,
1315
+ maxItems: types.length
1316
+ }, options);
1317
+ }
1318
+ //#endregion
1319
+ //#region ../../node_modules/.pnpm/@sinclair+typebox@0.34.48/node_modules/@sinclair/typebox/build/esm/type/mapped/mapped.mjs
1320
+ function FromMappedResult$9(K, P) {
1321
+ return K in P ? FromSchemaType(K, P[K]) : MappedResult(P);
1322
+ }
1323
+ function MappedKeyToKnownMappedResultProperties(K) {
1324
+ return { [K]: Literal(K) };
1325
+ }
1326
+ function MappedKeyToUnknownMappedResultProperties(P) {
1327
+ const Acc = {};
1328
+ for (const L of P) Acc[L] = Literal(L);
1329
+ return Acc;
1330
+ }
1331
+ function MappedKeyToMappedResultProperties(K, P) {
1332
+ return SetIncludes(P, K) ? MappedKeyToKnownMappedResultProperties(K) : MappedKeyToUnknownMappedResultProperties(P);
1333
+ }
1334
+ function FromMappedKey$3(K, P) {
1335
+ return FromMappedResult$9(K, MappedKeyToMappedResultProperties(K, P));
1336
+ }
1337
+ function FromRest$5(K, T) {
1338
+ return T.map((L) => FromSchemaType(K, L));
1339
+ }
1340
+ function FromProperties$16(K, T) {
1341
+ const Acc = {};
1342
+ for (const K2 of globalThis.Object.getOwnPropertyNames(T)) Acc[K2] = FromSchemaType(K, T[K2]);
1343
+ return Acc;
1344
+ }
1345
+ function FromSchemaType(K, T) {
1346
+ const options = { ...T };
1347
+ return IsOptional$1(T) ? Optional(FromSchemaType(K, Discard(T, [OptionalKind]))) : IsReadonly(T) ? Readonly(FromSchemaType(K, Discard(T, [ReadonlyKind]))) : IsMappedResult$1(T) ? FromMappedResult$9(K, T.properties) : IsMappedKey$1(T) ? FromMappedKey$3(K, T.keys) : IsConstructor$1(T) ? Constructor(FromRest$5(K, T.parameters), FromSchemaType(K, T.returns), options) : IsFunction$1(T) ? Function(FromRest$5(K, T.parameters), FromSchemaType(K, T.returns), options) : IsAsyncIterator$1(T) ? AsyncIterator(FromSchemaType(K, T.items), options) : IsIterator$1(T) ? Iterator(FromSchemaType(K, T.items), options) : IsIntersect$1(T) ? Intersect(FromRest$5(K, T.allOf), options) : IsUnion$1(T) ? Union(FromRest$5(K, T.anyOf), options) : IsTuple$1(T) ? Tuple(FromRest$5(K, T.items ?? []), options) : IsObject$1(T) ? Object$1(FromProperties$16(K, T.properties), options) : IsArray$1(T) ? Array$1(FromSchemaType(K, T.items), options) : IsPromise$1(T) ? Promise$1(FromSchemaType(K, T.item), options) : T;
1348
+ }
1349
+ function MappedFunctionReturnType(K, T) {
1350
+ const Acc = {};
1351
+ for (const L of K) Acc[L] = FromSchemaType(L, T);
1352
+ return Acc;
1353
+ }
1354
+ /** `[Json]` Creates a Mapped object type */
1355
+ function Mapped(key, map, options) {
1356
+ const K = IsSchema$1(key) ? IndexPropertyKeys(key) : key;
1357
+ return Object$1(MappedFunctionReturnType(K, map({
1358
+ [Kind]: "MappedKey",
1359
+ keys: K
1360
+ })), options);
1361
+ }
1362
+ //#endregion
1363
+ //#region ../../node_modules/.pnpm/@sinclair+typebox@0.34.48/node_modules/@sinclair/typebox/build/esm/type/optional/optional.mjs
1364
+ function RemoveOptional(schema) {
1365
+ return CreateType(Discard(schema, [OptionalKind]));
1366
+ }
1367
+ function AddOptional(schema) {
1368
+ return CreateType({
1369
+ ...schema,
1370
+ [OptionalKind]: "Optional"
1371
+ });
1372
+ }
1373
+ function OptionalWithFlag(schema, F) {
1374
+ return F === false ? RemoveOptional(schema) : AddOptional(schema);
1375
+ }
1376
+ /** `[Json]` Creates a Optional property */
1377
+ function Optional(schema, enable) {
1378
+ const F = enable ?? true;
1379
+ return IsMappedResult$1(schema) ? OptionalFromMappedResult(schema, F) : OptionalWithFlag(schema, F);
1380
+ }
1381
+ //#endregion
1382
+ //#region ../../node_modules/.pnpm/@sinclair+typebox@0.34.48/node_modules/@sinclair/typebox/build/esm/type/optional/optional-from-mapped-result.mjs
1383
+ function FromProperties$15(P, F) {
1384
+ const Acc = {};
1385
+ for (const K2 of globalThis.Object.getOwnPropertyNames(P)) Acc[K2] = Optional(P[K2], F);
1386
+ return Acc;
1387
+ }
1388
+ function FromMappedResult$8(R, F) {
1389
+ return FromProperties$15(R.properties, F);
1390
+ }
1391
+ function OptionalFromMappedResult(R, F) {
1392
+ return MappedResult(FromMappedResult$8(R, F));
1393
+ }
1394
+ //#endregion
1395
+ //#region ../../node_modules/.pnpm/@sinclair+typebox@0.34.48/node_modules/@sinclair/typebox/build/esm/type/intersect/intersect-create.mjs
1396
+ function IntersectCreate(T, options = {}) {
1397
+ const allObjects = T.every((schema) => IsObject$1(schema));
1398
+ const clonedUnevaluatedProperties = IsSchema$1(options.unevaluatedProperties) ? { unevaluatedProperties: options.unevaluatedProperties } : {};
1399
+ return CreateType(options.unevaluatedProperties === false || IsSchema$1(options.unevaluatedProperties) || allObjects ? {
1400
+ ...clonedUnevaluatedProperties,
1401
+ [Kind]: "Intersect",
1402
+ type: "object",
1403
+ allOf: T
1404
+ } : {
1405
+ ...clonedUnevaluatedProperties,
1406
+ [Kind]: "Intersect",
1407
+ allOf: T
1408
+ }, options);
1409
+ }
1410
+ //#endregion
1411
+ //#region ../../node_modules/.pnpm/@sinclair+typebox@0.34.48/node_modules/@sinclair/typebox/build/esm/type/intersect/intersect-evaluated.mjs
1412
+ function IsIntersectOptional(types) {
1413
+ return types.every((left) => IsOptional$1(left));
1414
+ }
1415
+ function RemoveOptionalFromType(type) {
1416
+ return Discard(type, [OptionalKind]);
1417
+ }
1418
+ function RemoveOptionalFromRest(types) {
1419
+ return types.map((left) => IsOptional$1(left) ? RemoveOptionalFromType(left) : left);
1420
+ }
1421
+ function ResolveIntersect(types, options) {
1422
+ return IsIntersectOptional(types) ? Optional(IntersectCreate(RemoveOptionalFromRest(types), options)) : IntersectCreate(RemoveOptionalFromRest(types), options);
1423
+ }
1424
+ /** `[Json]` Creates an evaluated Intersect type */
1425
+ function IntersectEvaluated(types, options = {}) {
1426
+ if (types.length === 1) return CreateType(types[0], options);
1427
+ if (types.length === 0) return Never(options);
1428
+ if (types.some((schema) => IsTransform$1(schema))) throw new Error("Cannot intersect transform types");
1429
+ return ResolveIntersect(types, options);
1430
+ }
1431
+ //#endregion
1432
+ //#region ../../node_modules/.pnpm/@sinclair+typebox@0.34.48/node_modules/@sinclair/typebox/build/esm/type/intersect/intersect.mjs
1433
+ /** `[Json]` Creates an evaluated Intersect type */
1434
+ function Intersect(types, options) {
1435
+ if (types.length === 1) return CreateType(types[0], options);
1436
+ if (types.length === 0) return Never(options);
1437
+ if (types.some((schema) => IsTransform$1(schema))) throw new Error("Cannot intersect transform types");
1438
+ return IntersectCreate(types, options);
1439
+ }
1440
+ //#endregion
1441
+ //#region ../../node_modules/.pnpm/@sinclair+typebox@0.34.48/node_modules/@sinclair/typebox/build/esm/type/ref/ref.mjs
1442
+ /** `[Json]` Creates a Ref type. The referenced type must contain a $id */
1443
+ function Ref(...args) {
1444
+ const [$ref, options] = typeof args[0] === "string" ? [args[0], args[1]] : [args[0].$id, args[1]];
1445
+ if (typeof $ref !== "string") throw new TypeBoxError("Ref: $ref must be a string");
1446
+ return CreateType({
1447
+ [Kind]: "Ref",
1448
+ $ref
1449
+ }, options);
1450
+ }
1451
+ //#endregion
1452
+ //#region ../../node_modules/.pnpm/@sinclair+typebox@0.34.48/node_modules/@sinclair/typebox/build/esm/type/awaited/awaited.mjs
1453
+ function FromComputed$4(target, parameters) {
1454
+ return Computed("Awaited", [Computed(target, parameters)]);
1455
+ }
1456
+ function FromRef$3($ref) {
1457
+ return Computed("Awaited", [Ref($ref)]);
1458
+ }
1459
+ function FromIntersect$6(types) {
1460
+ return Intersect(FromRest$4(types));
1461
+ }
1462
+ function FromUnion$6(types) {
1463
+ return Union(FromRest$4(types));
1464
+ }
1465
+ function FromPromise$2(type) {
1466
+ return Awaited(type);
1467
+ }
1468
+ function FromRest$4(types) {
1469
+ return types.map((type) => Awaited(type));
1470
+ }
1471
+ /** `[JavaScript]` Constructs a type by recursively unwrapping Promise types */
1472
+ function Awaited(type, options) {
1473
+ return CreateType(IsComputed$1(type) ? FromComputed$4(type.target, type.parameters) : IsIntersect$1(type) ? FromIntersect$6(type.allOf) : IsUnion$1(type) ? FromUnion$6(type.anyOf) : IsPromise$1(type) ? FromPromise$2(type.item) : IsRef$1(type) ? FromRef$3(type.$ref) : type, options);
1474
+ }
1475
+ //#endregion
1476
+ //#region ../../node_modules/.pnpm/@sinclair+typebox@0.34.48/node_modules/@sinclair/typebox/build/esm/type/keyof/keyof-property-keys.mjs
1477
+ function FromRest$3(types) {
1478
+ const result = [];
1479
+ for (const L of types) result.push(KeyOfPropertyKeys(L));
1480
+ return result;
1481
+ }
1482
+ function FromIntersect$5(types) {
1483
+ return SetUnionMany(FromRest$3(types));
1484
+ }
1485
+ function FromUnion$5(types) {
1486
+ return SetIntersectMany(FromRest$3(types));
1487
+ }
1488
+ function FromTuple$3(types) {
1489
+ return types.map((_, indexer) => indexer.toString());
1490
+ }
1491
+ function FromArray$4(_) {
1492
+ return ["[number]"];
1493
+ }
1494
+ function FromProperties$14(T) {
1495
+ return globalThis.Object.getOwnPropertyNames(T);
1496
+ }
1497
+ function FromPatternProperties(patternProperties) {
1498
+ if (!includePatternProperties) return [];
1499
+ return globalThis.Object.getOwnPropertyNames(patternProperties).map((key) => {
1500
+ return key[0] === "^" && key[key.length - 1] === "$" ? key.slice(1, key.length - 1) : key;
1501
+ });
1502
+ }
1503
+ /** Returns a tuple of PropertyKeys derived from the given TSchema. */
1504
+ function KeyOfPropertyKeys(type) {
1505
+ return IsIntersect$1(type) ? FromIntersect$5(type.allOf) : IsUnion$1(type) ? FromUnion$5(type.anyOf) : IsTuple$1(type) ? FromTuple$3(type.items ?? []) : IsArray$1(type) ? FromArray$4(type.items) : IsObject$1(type) ? FromProperties$14(type.properties) : IsRecord$1(type) ? FromPatternProperties(type.patternProperties) : [];
1506
+ }
1507
+ let includePatternProperties = false;
1508
+ //#endregion
1509
+ //#region ../../node_modules/.pnpm/@sinclair+typebox@0.34.48/node_modules/@sinclair/typebox/build/esm/type/keyof/keyof.mjs
1510
+ function FromComputed$3(target, parameters) {
1511
+ return Computed("KeyOf", [Computed(target, parameters)]);
1512
+ }
1513
+ function FromRef$2($ref) {
1514
+ return Computed("KeyOf", [Ref($ref)]);
1515
+ }
1516
+ function KeyOfFromType(type, options) {
1517
+ return CreateType(UnionEvaluated(KeyOfPropertyKeysToRest(KeyOfPropertyKeys(type))), options);
1518
+ }
1519
+ function KeyOfPropertyKeysToRest(propertyKeys) {
1520
+ return propertyKeys.map((L) => L === "[number]" ? Number$1() : Literal(L));
1521
+ }
1522
+ /** `[Json]` Creates a KeyOf type */
1523
+ function KeyOf(type, options) {
1524
+ return IsComputed$1(type) ? FromComputed$3(type.target, type.parameters) : IsRef$1(type) ? FromRef$2(type.$ref) : IsMappedResult$1(type) ? KeyOfFromMappedResult(type, options) : KeyOfFromType(type, options);
1525
+ }
1526
+ //#endregion
1527
+ //#region ../../node_modules/.pnpm/@sinclair+typebox@0.34.48/node_modules/@sinclair/typebox/build/esm/type/keyof/keyof-from-mapped-result.mjs
1528
+ function FromProperties$13(properties, options) {
1529
+ const result = {};
1530
+ for (const K2 of globalThis.Object.getOwnPropertyNames(properties)) result[K2] = KeyOf(properties[K2], Clone(options));
1531
+ return result;
1532
+ }
1533
+ function FromMappedResult$7(mappedResult, options) {
1534
+ return FromProperties$13(mappedResult.properties, options);
1535
+ }
1536
+ function KeyOfFromMappedResult(mappedResult, options) {
1537
+ return MappedResult(FromMappedResult$7(mappedResult, options));
1538
+ }
1539
+ //#endregion
1540
+ //#region ../../node_modules/.pnpm/@sinclair+typebox@0.34.48/node_modules/@sinclair/typebox/build/esm/type/composite/composite.mjs
1541
+ function CompositeKeys(T) {
1542
+ const Acc = [];
1543
+ for (const L of T) Acc.push(...KeyOfPropertyKeys(L));
1544
+ return SetDistinct(Acc);
1545
+ }
1546
+ function FilterNever(T) {
1547
+ return T.filter((L) => !IsNever$1(L));
1548
+ }
1549
+ function CompositeProperty(T, K) {
1550
+ const Acc = [];
1551
+ for (const L of T) Acc.push(...IndexFromPropertyKeys(L, [K]));
1552
+ return FilterNever(Acc);
1553
+ }
1554
+ function CompositeProperties(T, K) {
1555
+ const Acc = {};
1556
+ for (const L of K) Acc[L] = IntersectEvaluated(CompositeProperty(T, L));
1557
+ return Acc;
1558
+ }
1559
+ function Composite(T, options) {
1560
+ return Object$1(CompositeProperties(T, CompositeKeys(T)), options);
1561
+ }
1562
+ //#endregion
1563
+ //#region ../../node_modules/.pnpm/@sinclair+typebox@0.34.48/node_modules/@sinclair/typebox/build/esm/type/date/date.mjs
1564
+ /** `[JavaScript]` Creates a Date type */
1565
+ function Date$1(options) {
1566
+ return CreateType({
1567
+ [Kind]: "Date",
1568
+ type: "Date"
1569
+ }, options);
1570
+ }
1571
+ //#endregion
1572
+ //#region ../../node_modules/.pnpm/@sinclair+typebox@0.34.48/node_modules/@sinclair/typebox/build/esm/type/null/null.mjs
1573
+ /** `[Json]` Creates a Null type */
1574
+ function Null(options) {
1575
+ return CreateType({
1576
+ [Kind]: "Null",
1577
+ type: "null"
1578
+ }, options);
1579
+ }
1580
+ //#endregion
1581
+ //#region ../../node_modules/.pnpm/@sinclair+typebox@0.34.48/node_modules/@sinclair/typebox/build/esm/type/symbol/symbol.mjs
1582
+ /** `[JavaScript]` Creates a Symbol type */
1583
+ function Symbol$1(options) {
1584
+ return CreateType({
1585
+ [Kind]: "Symbol",
1586
+ type: "symbol"
1587
+ }, options);
1588
+ }
1589
+ //#endregion
1590
+ //#region ../../node_modules/.pnpm/@sinclair+typebox@0.34.48/node_modules/@sinclair/typebox/build/esm/type/undefined/undefined.mjs
1591
+ /** `[JavaScript]` Creates a Undefined type */
1592
+ function Undefined(options) {
1593
+ return CreateType({
1594
+ [Kind]: "Undefined",
1595
+ type: "undefined"
1596
+ }, options);
1597
+ }
1598
+ //#endregion
1599
+ //#region ../../node_modules/.pnpm/@sinclair+typebox@0.34.48/node_modules/@sinclair/typebox/build/esm/type/uint8array/uint8array.mjs
1600
+ /** `[JavaScript]` Creates a Uint8Array type */
1601
+ function Uint8Array$1(options) {
1602
+ return CreateType({
1603
+ [Kind]: "Uint8Array",
1604
+ type: "Uint8Array"
1605
+ }, options);
1606
+ }
1607
+ //#endregion
1608
+ //#region ../../node_modules/.pnpm/@sinclair+typebox@0.34.48/node_modules/@sinclair/typebox/build/esm/type/unknown/unknown.mjs
1609
+ /** `[Json]` Creates an Unknown type */
1610
+ function Unknown(options) {
1611
+ return CreateType({ [Kind]: "Unknown" }, options);
1612
+ }
1613
+ //#endregion
1614
+ //#region ../../node_modules/.pnpm/@sinclair+typebox@0.34.48/node_modules/@sinclair/typebox/build/esm/type/const/const.mjs
1615
+ function FromArray$3(T) {
1616
+ return T.map((L) => FromValue(L, false));
1617
+ }
1618
+ function FromProperties$12(value) {
1619
+ const Acc = {};
1620
+ for (const K of globalThis.Object.getOwnPropertyNames(value)) Acc[K] = Readonly(FromValue(value[K], false));
1621
+ return Acc;
1622
+ }
1623
+ function ConditionalReadonly(T, root) {
1624
+ return root === true ? T : Readonly(T);
1625
+ }
1626
+ function FromValue(value, root) {
1627
+ return IsAsyncIterator$2(value) ? ConditionalReadonly(Any(), root) : IsIterator$2(value) ? ConditionalReadonly(Any(), root) : IsArray$3(value) ? Readonly(Tuple(FromArray$3(value))) : IsUint8Array$2(value) ? Uint8Array$1() : IsDate$2(value) ? Date$1() : IsObject$3(value) ? ConditionalReadonly(Object$1(FromProperties$12(value)), root) : IsFunction$2(value) ? ConditionalReadonly(Function([], Unknown()), root) : IsUndefined$3(value) ? Undefined() : IsNull$2(value) ? Null() : IsSymbol$2(value) ? Symbol$1() : IsBigInt$2(value) ? BigInt() : IsNumber$3(value) ? Literal(value) : IsBoolean$2(value) ? Literal(value) : IsString$2(value) ? Literal(value) : Object$1({});
1628
+ }
1629
+ /** `[JavaScript]` Creates a readonly const type from the given value. */
1630
+ function Const(T, options) {
1631
+ return CreateType(FromValue(T, true), options);
1632
+ }
1633
+ //#endregion
1634
+ //#region ../../node_modules/.pnpm/@sinclair+typebox@0.34.48/node_modules/@sinclair/typebox/build/esm/type/constructor-parameters/constructor-parameters.mjs
1635
+ /** `[JavaScript]` Extracts the ConstructorParameters from the given Constructor type */
1636
+ function ConstructorParameters(schema, options) {
1637
+ return IsConstructor$1(schema) ? Tuple(schema.parameters, options) : Never(options);
1638
+ }
1639
+ //#endregion
1640
+ //#region ../../node_modules/.pnpm/@sinclair+typebox@0.34.48/node_modules/@sinclair/typebox/build/esm/type/enum/enum.mjs
1641
+ /** `[Json]` Creates a Enum type */
1642
+ function Enum(item, options) {
1643
+ if (IsUndefined$3(item)) throw new Error("Enum undefined or empty");
1644
+ const values1 = globalThis.Object.getOwnPropertyNames(item).filter((key) => isNaN(key)).map((key) => item[key]);
1645
+ return Union([...new Set(values1)].map((value) => Literal(value)), {
1646
+ ...options,
1647
+ [Hint]: "Enum"
1648
+ });
1649
+ }
1650
+ //#endregion
1651
+ //#region ../../node_modules/.pnpm/@sinclair+typebox@0.34.48/node_modules/@sinclair/typebox/build/esm/type/extends/extends-check.mjs
1652
+ var ExtendsResolverError = class extends TypeBoxError {};
1653
+ var ExtendsResult;
1654
+ (function(ExtendsResult) {
1655
+ ExtendsResult[ExtendsResult["Union"] = 0] = "Union";
1656
+ ExtendsResult[ExtendsResult["True"] = 1] = "True";
1657
+ ExtendsResult[ExtendsResult["False"] = 2] = "False";
1658
+ })(ExtendsResult || (ExtendsResult = {}));
1659
+ function IntoBooleanResult(result) {
1660
+ return result === ExtendsResult.False ? result : ExtendsResult.True;
1661
+ }
1662
+ function Throw(message) {
1663
+ throw new ExtendsResolverError(message);
1664
+ }
1665
+ function IsStructuralRight(right) {
1666
+ return IsNever(right) || IsIntersect(right) || IsUnion(right) || IsUnknown(right) || IsAny(right);
1667
+ }
1668
+ function StructuralRight(left, right) {
1669
+ return IsNever(right) ? FromNeverRight(left, right) : IsIntersect(right) ? FromIntersectRight(left, right) : IsUnion(right) ? FromUnionRight(left, right) : IsUnknown(right) ? FromUnknownRight(left, right) : IsAny(right) ? FromAnyRight(left, right) : Throw("StructuralRight");
1670
+ }
1671
+ function FromAnyRight(left, right) {
1672
+ return ExtendsResult.True;
1673
+ }
1674
+ function FromAny(left, right) {
1675
+ return IsIntersect(right) ? FromIntersectRight(left, right) : IsUnion(right) && right.anyOf.some((schema) => IsAny(schema) || IsUnknown(schema)) ? ExtendsResult.True : IsUnion(right) ? ExtendsResult.Union : IsUnknown(right) ? ExtendsResult.True : IsAny(right) ? ExtendsResult.True : ExtendsResult.Union;
1676
+ }
1677
+ function FromArrayRight(left, right) {
1678
+ return IsUnknown(left) ? ExtendsResult.False : IsAny(left) ? ExtendsResult.Union : IsNever(left) ? ExtendsResult.True : ExtendsResult.False;
1679
+ }
1680
+ function FromArray$2(left, right) {
1681
+ return IsObject(right) && IsObjectArrayLike(right) ? ExtendsResult.True : IsStructuralRight(right) ? StructuralRight(left, right) : !IsArray(right) ? ExtendsResult.False : IntoBooleanResult(Visit(left.items, right.items));
1682
+ }
1683
+ function FromAsyncIterator$2(left, right) {
1684
+ return IsStructuralRight(right) ? StructuralRight(left, right) : !IsAsyncIterator(right) ? ExtendsResult.False : IntoBooleanResult(Visit(left.items, right.items));
1685
+ }
1686
+ function FromBigInt(left, right) {
1687
+ return IsStructuralRight(right) ? StructuralRight(left, right) : IsObject(right) ? FromObjectRight(left, right) : IsRecord(right) ? FromRecordRight(left, right) : IsBigInt(right) ? ExtendsResult.True : ExtendsResult.False;
1688
+ }
1689
+ function FromBooleanRight(left, right) {
1690
+ return IsLiteralBoolean(left) ? ExtendsResult.True : IsBoolean(left) ? ExtendsResult.True : ExtendsResult.False;
1691
+ }
1692
+ function FromBoolean(left, right) {
1693
+ return IsStructuralRight(right) ? StructuralRight(left, right) : IsObject(right) ? FromObjectRight(left, right) : IsRecord(right) ? FromRecordRight(left, right) : IsBoolean(right) ? ExtendsResult.True : ExtendsResult.False;
1694
+ }
1695
+ function FromConstructor$2(left, right) {
1696
+ return IsStructuralRight(right) ? StructuralRight(left, right) : IsObject(right) ? FromObjectRight(left, right) : !IsConstructor(right) ? ExtendsResult.False : left.parameters.length > right.parameters.length ? ExtendsResult.False : !left.parameters.every((schema, index) => IntoBooleanResult(Visit(right.parameters[index], schema)) === ExtendsResult.True) ? ExtendsResult.False : IntoBooleanResult(Visit(left.returns, right.returns));
1697
+ }
1698
+ function FromDate(left, right) {
1699
+ return IsStructuralRight(right) ? StructuralRight(left, right) : IsObject(right) ? FromObjectRight(left, right) : IsRecord(right) ? FromRecordRight(left, right) : IsDate(right) ? ExtendsResult.True : ExtendsResult.False;
1700
+ }
1701
+ function FromFunction$2(left, right) {
1702
+ return IsStructuralRight(right) ? StructuralRight(left, right) : IsObject(right) ? FromObjectRight(left, right) : !IsFunction(right) ? ExtendsResult.False : left.parameters.length > right.parameters.length ? ExtendsResult.False : !left.parameters.every((schema, index) => IntoBooleanResult(Visit(right.parameters[index], schema)) === ExtendsResult.True) ? ExtendsResult.False : IntoBooleanResult(Visit(left.returns, right.returns));
1703
+ }
1704
+ function FromIntegerRight(left, right) {
1705
+ return IsLiteral(left) && IsNumber$3(left.const) ? ExtendsResult.True : IsNumber(left) || IsInteger(left) ? ExtendsResult.True : ExtendsResult.False;
1706
+ }
1707
+ function FromInteger(left, right) {
1708
+ return IsInteger(right) || IsNumber(right) ? ExtendsResult.True : IsStructuralRight(right) ? StructuralRight(left, right) : IsObject(right) ? FromObjectRight(left, right) : IsRecord(right) ? FromRecordRight(left, right) : ExtendsResult.False;
1709
+ }
1710
+ function FromIntersectRight(left, right) {
1711
+ return right.allOf.every((schema) => Visit(left, schema) === ExtendsResult.True) ? ExtendsResult.True : ExtendsResult.False;
1712
+ }
1713
+ function FromIntersect$4(left, right) {
1714
+ return left.allOf.some((schema) => Visit(schema, right) === ExtendsResult.True) ? ExtendsResult.True : ExtendsResult.False;
1715
+ }
1716
+ function FromIterator$2(left, right) {
1717
+ return IsStructuralRight(right) ? StructuralRight(left, right) : !IsIterator(right) ? ExtendsResult.False : IntoBooleanResult(Visit(left.items, right.items));
1718
+ }
1719
+ function FromLiteral(left, right) {
1720
+ return IsLiteral(right) && right.const === left.const ? ExtendsResult.True : IsStructuralRight(right) ? StructuralRight(left, right) : IsObject(right) ? FromObjectRight(left, right) : IsRecord(right) ? FromRecordRight(left, right) : IsString(right) ? FromStringRight(left, right) : IsNumber(right) ? FromNumberRight(left, right) : IsInteger(right) ? FromIntegerRight(left, right) : IsBoolean(right) ? FromBooleanRight(left, right) : ExtendsResult.False;
1721
+ }
1722
+ function FromNeverRight(left, right) {
1723
+ return ExtendsResult.False;
1724
+ }
1725
+ function FromNever(left, right) {
1726
+ return ExtendsResult.True;
1727
+ }
1728
+ function UnwrapTNot(schema) {
1729
+ let [current, depth] = [schema, 0];
1730
+ while (true) {
1731
+ if (!IsNot(current)) break;
1732
+ current = current.not;
1733
+ depth += 1;
1734
+ }
1735
+ return depth % 2 === 0 ? current : Unknown();
1736
+ }
1737
+ function FromNot(left, right) {
1738
+ return IsNot(left) ? Visit(UnwrapTNot(left), right) : IsNot(right) ? Visit(left, UnwrapTNot(right)) : Throw("Invalid fallthrough for Not");
1739
+ }
1740
+ function FromNull(left, right) {
1741
+ return IsStructuralRight(right) ? StructuralRight(left, right) : IsObject(right) ? FromObjectRight(left, right) : IsRecord(right) ? FromRecordRight(left, right) : IsNull(right) ? ExtendsResult.True : ExtendsResult.False;
1742
+ }
1743
+ function FromNumberRight(left, right) {
1744
+ return IsLiteralNumber(left) ? ExtendsResult.True : IsNumber(left) || IsInteger(left) ? ExtendsResult.True : ExtendsResult.False;
1745
+ }
1746
+ function FromNumber(left, right) {
1747
+ return IsStructuralRight(right) ? StructuralRight(left, right) : IsObject(right) ? FromObjectRight(left, right) : IsRecord(right) ? FromRecordRight(left, right) : IsInteger(right) || IsNumber(right) ? ExtendsResult.True : ExtendsResult.False;
1748
+ }
1749
+ function IsObjectPropertyCount(schema, count) {
1750
+ return Object.getOwnPropertyNames(schema.properties).length === count;
1751
+ }
1752
+ function IsObjectStringLike(schema) {
1753
+ return IsObjectArrayLike(schema);
1754
+ }
1755
+ function IsObjectSymbolLike(schema) {
1756
+ return IsObjectPropertyCount(schema, 0) || IsObjectPropertyCount(schema, 1) && "description" in schema.properties && IsUnion(schema.properties.description) && schema.properties.description.anyOf.length === 2 && (IsString(schema.properties.description.anyOf[0]) && IsUndefined(schema.properties.description.anyOf[1]) || IsString(schema.properties.description.anyOf[1]) && IsUndefined(schema.properties.description.anyOf[0]));
1757
+ }
1758
+ function IsObjectNumberLike(schema) {
1759
+ return IsObjectPropertyCount(schema, 0);
1760
+ }
1761
+ function IsObjectBooleanLike(schema) {
1762
+ return IsObjectPropertyCount(schema, 0);
1763
+ }
1764
+ function IsObjectBigIntLike(schema) {
1765
+ return IsObjectPropertyCount(schema, 0);
1766
+ }
1767
+ function IsObjectDateLike(schema) {
1768
+ return IsObjectPropertyCount(schema, 0);
1769
+ }
1770
+ function IsObjectUint8ArrayLike(schema) {
1771
+ return IsObjectArrayLike(schema);
1772
+ }
1773
+ function IsObjectFunctionLike(schema) {
1774
+ const length = Number$1();
1775
+ return IsObjectPropertyCount(schema, 0) || IsObjectPropertyCount(schema, 1) && "length" in schema.properties && IntoBooleanResult(Visit(schema.properties["length"], length)) === ExtendsResult.True;
1776
+ }
1777
+ function IsObjectConstructorLike(schema) {
1778
+ return IsObjectPropertyCount(schema, 0);
1779
+ }
1780
+ function IsObjectArrayLike(schema) {
1781
+ const length = Number$1();
1782
+ return IsObjectPropertyCount(schema, 0) || IsObjectPropertyCount(schema, 1) && "length" in schema.properties && IntoBooleanResult(Visit(schema.properties["length"], length)) === ExtendsResult.True;
1783
+ }
1784
+ function IsObjectPromiseLike(schema) {
1785
+ const then = Function([Any()], Any());
1786
+ return IsObjectPropertyCount(schema, 0) || IsObjectPropertyCount(schema, 1) && "then" in schema.properties && IntoBooleanResult(Visit(schema.properties["then"], then)) === ExtendsResult.True;
1787
+ }
1788
+ function Property(left, right) {
1789
+ return Visit(left, right) === ExtendsResult.False ? ExtendsResult.False : IsOptional(left) && !IsOptional(right) ? ExtendsResult.False : ExtendsResult.True;
1790
+ }
1791
+ function FromObjectRight(left, right) {
1792
+ return IsUnknown(left) ? ExtendsResult.False : IsAny(left) ? ExtendsResult.Union : IsNever(left) || IsLiteralString(left) && IsObjectStringLike(right) || IsLiteralNumber(left) && IsObjectNumberLike(right) || IsLiteralBoolean(left) && IsObjectBooleanLike(right) || IsSymbol(left) && IsObjectSymbolLike(right) || IsBigInt(left) && IsObjectBigIntLike(right) || IsString(left) && IsObjectStringLike(right) || IsSymbol(left) && IsObjectSymbolLike(right) || IsNumber(left) && IsObjectNumberLike(right) || IsInteger(left) && IsObjectNumberLike(right) || IsBoolean(left) && IsObjectBooleanLike(right) || IsUint8Array(left) && IsObjectUint8ArrayLike(right) || IsDate(left) && IsObjectDateLike(right) || IsConstructor(left) && IsObjectConstructorLike(right) || IsFunction(left) && IsObjectFunctionLike(right) ? ExtendsResult.True : IsRecord(left) && IsString(RecordKey$1(left)) ? right[Hint] === "Record" ? ExtendsResult.True : ExtendsResult.False : IsRecord(left) && IsNumber(RecordKey$1(left)) ? IsObjectPropertyCount(right, 0) ? ExtendsResult.True : ExtendsResult.False : ExtendsResult.False;
1793
+ }
1794
+ function FromObject$6(left, right) {
1795
+ return IsStructuralRight(right) ? StructuralRight(left, right) : IsRecord(right) ? FromRecordRight(left, right) : !IsObject(right) ? ExtendsResult.False : (() => {
1796
+ for (const key of Object.getOwnPropertyNames(right.properties)) {
1797
+ if (!(key in left.properties) && !IsOptional(right.properties[key])) return ExtendsResult.False;
1798
+ if (IsOptional(right.properties[key])) return ExtendsResult.True;
1799
+ if (Property(left.properties[key], right.properties[key]) === ExtendsResult.False) return ExtendsResult.False;
1800
+ }
1801
+ return ExtendsResult.True;
1802
+ })();
1803
+ }
1804
+ function FromPromise$1(left, right) {
1805
+ return IsStructuralRight(right) ? StructuralRight(left, right) : IsObject(right) && IsObjectPromiseLike(right) ? ExtendsResult.True : !IsPromise(right) ? ExtendsResult.False : IntoBooleanResult(Visit(left.item, right.item));
1806
+ }
1807
+ function RecordKey$1(schema) {
1808
+ return PatternNumberExact in schema.patternProperties ? Number$1() : PatternStringExact in schema.patternProperties ? String$1() : Throw("Unknown record key pattern");
1809
+ }
1810
+ function RecordValue$1(schema) {
1811
+ return PatternNumberExact in schema.patternProperties ? schema.patternProperties[PatternNumberExact] : PatternStringExact in schema.patternProperties ? schema.patternProperties[PatternStringExact] : Throw("Unable to get record value schema");
1812
+ }
1813
+ function FromRecordRight(left, right) {
1814
+ const [Key, Value] = [RecordKey$1(right), RecordValue$1(right)];
1815
+ return IsLiteralString(left) && IsNumber(Key) && IntoBooleanResult(Visit(left, Value)) === ExtendsResult.True ? ExtendsResult.True : IsUint8Array(left) && IsNumber(Key) ? Visit(left, Value) : IsString(left) && IsNumber(Key) ? Visit(left, Value) : IsArray(left) && IsNumber(Key) ? Visit(left, Value) : IsObject(left) ? (() => {
1816
+ for (const key of Object.getOwnPropertyNames(left.properties)) if (Property(Value, left.properties[key]) === ExtendsResult.False) return ExtendsResult.False;
1817
+ return ExtendsResult.True;
1818
+ })() : ExtendsResult.False;
1819
+ }
1820
+ function FromRecord$2(left, right) {
1821
+ return IsStructuralRight(right) ? StructuralRight(left, right) : IsObject(right) ? FromObjectRight(left, right) : !IsRecord(right) ? ExtendsResult.False : Visit(RecordValue$1(left), RecordValue$1(right));
1822
+ }
1823
+ function FromRegExp(left, right) {
1824
+ return Visit(IsRegExp(left) ? String$1() : left, IsRegExp(right) ? String$1() : right);
1825
+ }
1826
+ function FromStringRight(left, right) {
1827
+ return IsLiteral(left) && IsString$2(left.const) ? ExtendsResult.True : IsString(left) ? ExtendsResult.True : ExtendsResult.False;
1828
+ }
1829
+ function FromString(left, right) {
1830
+ return IsStructuralRight(right) ? StructuralRight(left, right) : IsObject(right) ? FromObjectRight(left, right) : IsRecord(right) ? FromRecordRight(left, right) : IsString(right) ? ExtendsResult.True : ExtendsResult.False;
1831
+ }
1832
+ function FromSymbol(left, right) {
1833
+ return IsStructuralRight(right) ? StructuralRight(left, right) : IsObject(right) ? FromObjectRight(left, right) : IsRecord(right) ? FromRecordRight(left, right) : IsSymbol(right) ? ExtendsResult.True : ExtendsResult.False;
1834
+ }
1835
+ function FromTemplateLiteral$1(left, right) {
1836
+ return IsTemplateLiteral(left) ? Visit(TemplateLiteralToUnion(left), right) : IsTemplateLiteral(right) ? Visit(left, TemplateLiteralToUnion(right)) : Throw("Invalid fallthrough for TemplateLiteral");
1837
+ }
1838
+ function IsArrayOfTuple(left, right) {
1839
+ return IsArray(right) && left.items !== void 0 && left.items.every((schema) => Visit(schema, right.items) === ExtendsResult.True);
1840
+ }
1841
+ function FromTupleRight(left, right) {
1842
+ return IsNever(left) ? ExtendsResult.True : IsUnknown(left) ? ExtendsResult.False : IsAny(left) ? ExtendsResult.Union : ExtendsResult.False;
1843
+ }
1844
+ function FromTuple$2(left, right) {
1845
+ return IsStructuralRight(right) ? StructuralRight(left, right) : IsObject(right) && IsObjectArrayLike(right) ? ExtendsResult.True : IsArray(right) && IsArrayOfTuple(left, right) ? ExtendsResult.True : !IsTuple(right) ? ExtendsResult.False : IsUndefined$3(left.items) && !IsUndefined$3(right.items) || !IsUndefined$3(left.items) && IsUndefined$3(right.items) ? ExtendsResult.False : IsUndefined$3(left.items) && !IsUndefined$3(right.items) ? ExtendsResult.True : left.items.every((schema, index) => Visit(schema, right.items[index]) === ExtendsResult.True) ? ExtendsResult.True : ExtendsResult.False;
1846
+ }
1847
+ function FromUint8Array(left, right) {
1848
+ return IsStructuralRight(right) ? StructuralRight(left, right) : IsObject(right) ? FromObjectRight(left, right) : IsRecord(right) ? FromRecordRight(left, right) : IsUint8Array(right) ? ExtendsResult.True : ExtendsResult.False;
1849
+ }
1850
+ function FromUndefined(left, right) {
1851
+ return IsStructuralRight(right) ? StructuralRight(left, right) : IsObject(right) ? FromObjectRight(left, right) : IsRecord(right) ? FromRecordRight(left, right) : IsVoid(right) ? FromVoidRight(left, right) : IsUndefined(right) ? ExtendsResult.True : ExtendsResult.False;
1852
+ }
1853
+ function FromUnionRight(left, right) {
1854
+ return right.anyOf.some((schema) => Visit(left, schema) === ExtendsResult.True) ? ExtendsResult.True : ExtendsResult.False;
1855
+ }
1856
+ function FromUnion$4(left, right) {
1857
+ return left.anyOf.every((schema) => Visit(schema, right) === ExtendsResult.True) ? ExtendsResult.True : ExtendsResult.False;
1858
+ }
1859
+ function FromUnknownRight(left, right) {
1860
+ return ExtendsResult.True;
1861
+ }
1862
+ function FromUnknown(left, right) {
1863
+ return IsNever(right) ? FromNeverRight(left, right) : IsIntersect(right) ? FromIntersectRight(left, right) : IsUnion(right) ? FromUnionRight(left, right) : IsAny(right) ? FromAnyRight(left, right) : IsString(right) ? FromStringRight(left, right) : IsNumber(right) ? FromNumberRight(left, right) : IsInteger(right) ? FromIntegerRight(left, right) : IsBoolean(right) ? FromBooleanRight(left, right) : IsArray(right) ? FromArrayRight(left, right) : IsTuple(right) ? FromTupleRight(left, right) : IsObject(right) ? FromObjectRight(left, right) : IsUnknown(right) ? ExtendsResult.True : ExtendsResult.False;
1864
+ }
1865
+ function FromVoidRight(left, right) {
1866
+ return IsUndefined(left) ? ExtendsResult.True : IsUndefined(left) ? ExtendsResult.True : ExtendsResult.False;
1867
+ }
1868
+ function FromVoid(left, right) {
1869
+ return IsIntersect(right) ? FromIntersectRight(left, right) : IsUnion(right) ? FromUnionRight(left, right) : IsUnknown(right) ? FromUnknownRight(left, right) : IsAny(right) ? FromAnyRight(left, right) : IsObject(right) ? FromObjectRight(left, right) : IsVoid(right) ? ExtendsResult.True : ExtendsResult.False;
1870
+ }
1871
+ function Visit(left, right) {
1872
+ return IsTemplateLiteral(left) || IsTemplateLiteral(right) ? FromTemplateLiteral$1(left, right) : IsRegExp(left) || IsRegExp(right) ? FromRegExp(left, right) : IsNot(left) || IsNot(right) ? FromNot(left, right) : IsAny(left) ? FromAny(left, right) : IsArray(left) ? FromArray$2(left, right) : IsBigInt(left) ? FromBigInt(left, right) : IsBoolean(left) ? FromBoolean(left, right) : IsAsyncIterator(left) ? FromAsyncIterator$2(left, right) : IsConstructor(left) ? FromConstructor$2(left, right) : IsDate(left) ? FromDate(left, right) : IsFunction(left) ? FromFunction$2(left, right) : IsInteger(left) ? FromInteger(left, right) : IsIntersect(left) ? FromIntersect$4(left, right) : IsIterator(left) ? FromIterator$2(left, right) : IsLiteral(left) ? FromLiteral(left, right) : IsNever(left) ? FromNever(left, right) : IsNull(left) ? FromNull(left, right) : IsNumber(left) ? FromNumber(left, right) : IsObject(left) ? FromObject$6(left, right) : IsRecord(left) ? FromRecord$2(left, right) : IsString(left) ? FromString(left, right) : IsSymbol(left) ? FromSymbol(left, right) : IsTuple(left) ? FromTuple$2(left, right) : IsPromise(left) ? FromPromise$1(left, right) : IsUint8Array(left) ? FromUint8Array(left, right) : IsUndefined(left) ? FromUndefined(left, right) : IsUnion(left) ? FromUnion$4(left, right) : IsUnknown(left) ? FromUnknown(left, right) : IsVoid(left) ? FromVoid(left, right) : Throw(`Unknown left type operand '${left[Kind]}'`);
1873
+ }
1874
+ function ExtendsCheck(left, right) {
1875
+ return Visit(left, right);
1876
+ }
1877
+ //#endregion
1878
+ //#region ../../node_modules/.pnpm/@sinclair+typebox@0.34.48/node_modules/@sinclair/typebox/build/esm/type/extends/extends-from-mapped-result.mjs
1879
+ function FromProperties$11(P, Right, True, False, options) {
1880
+ const Acc = {};
1881
+ for (const K2 of globalThis.Object.getOwnPropertyNames(P)) Acc[K2] = Extends(P[K2], Right, True, False, Clone(options));
1882
+ return Acc;
1883
+ }
1884
+ function FromMappedResult$6(Left, Right, True, False, options) {
1885
+ return FromProperties$11(Left.properties, Right, True, False, options);
1886
+ }
1887
+ function ExtendsFromMappedResult(Left, Right, True, False, options) {
1888
+ return MappedResult(FromMappedResult$6(Left, Right, True, False, options));
1889
+ }
1890
+ //#endregion
1891
+ //#region ../../node_modules/.pnpm/@sinclair+typebox@0.34.48/node_modules/@sinclair/typebox/build/esm/type/extends/extends.mjs
1892
+ function ExtendsResolve(left, right, trueType, falseType) {
1893
+ const R = ExtendsCheck(left, right);
1894
+ return R === ExtendsResult.Union ? Union([trueType, falseType]) : R === ExtendsResult.True ? trueType : falseType;
1895
+ }
1896
+ /** `[Json]` Creates a Conditional type */
1897
+ function Extends(L, R, T, F, options) {
1898
+ return IsMappedResult$1(L) ? ExtendsFromMappedResult(L, R, T, F, options) : IsMappedKey$1(L) ? CreateType(ExtendsFromMappedKey(L, R, T, F, options)) : CreateType(ExtendsResolve(L, R, T, F), options);
1899
+ }
1900
+ //#endregion
1901
+ //#region ../../node_modules/.pnpm/@sinclair+typebox@0.34.48/node_modules/@sinclair/typebox/build/esm/type/extends/extends-from-mapped-key.mjs
1902
+ function FromPropertyKey$2(K, U, L, R, options) {
1903
+ return { [K]: Extends(Literal(K), U, L, R, Clone(options)) };
1904
+ }
1905
+ function FromPropertyKeys$2(K, U, L, R, options) {
1906
+ return K.reduce((Acc, LK) => {
1907
+ return {
1908
+ ...Acc,
1909
+ ...FromPropertyKey$2(LK, U, L, R, options)
1910
+ };
1911
+ }, {});
1912
+ }
1913
+ function FromMappedKey$2(K, U, L, R, options) {
1914
+ return FromPropertyKeys$2(K.keys, U, L, R, options);
1915
+ }
1916
+ function ExtendsFromMappedKey(T, U, L, R, options) {
1917
+ return MappedResult(FromMappedKey$2(T, U, L, R, options));
1918
+ }
1919
+ //#endregion
1920
+ //#region ../../node_modules/.pnpm/@sinclair+typebox@0.34.48/node_modules/@sinclair/typebox/build/esm/type/exclude/exclude-from-template-literal.mjs
1921
+ function ExcludeFromTemplateLiteral(L, R) {
1922
+ return Exclude(TemplateLiteralToUnion(L), R);
1923
+ }
1924
+ //#endregion
1925
+ //#region ../../node_modules/.pnpm/@sinclair+typebox@0.34.48/node_modules/@sinclair/typebox/build/esm/type/exclude/exclude.mjs
1926
+ function ExcludeRest(L, R) {
1927
+ const excluded = L.filter((inner) => ExtendsCheck(inner, R) === ExtendsResult.False);
1928
+ return excluded.length === 1 ? excluded[0] : Union(excluded);
1929
+ }
1930
+ /** `[Json]` Constructs a type by excluding from unionType all union members that are assignable to excludedMembers */
1931
+ function Exclude(L, R, options = {}) {
1932
+ if (IsTemplateLiteral$1(L)) return CreateType(ExcludeFromTemplateLiteral(L, R), options);
1933
+ if (IsMappedResult$1(L)) return CreateType(ExcludeFromMappedResult(L, R), options);
1934
+ return CreateType(IsUnion$1(L) ? ExcludeRest(L.anyOf, R) : ExtendsCheck(L, R) !== ExtendsResult.False ? Never() : L, options);
1935
+ }
1936
+ //#endregion
1937
+ //#region ../../node_modules/.pnpm/@sinclair+typebox@0.34.48/node_modules/@sinclair/typebox/build/esm/type/exclude/exclude-from-mapped-result.mjs
1938
+ function FromProperties$10(P, U) {
1939
+ const Acc = {};
1940
+ for (const K2 of globalThis.Object.getOwnPropertyNames(P)) Acc[K2] = Exclude(P[K2], U);
1941
+ return Acc;
1942
+ }
1943
+ function FromMappedResult$5(R, T) {
1944
+ return FromProperties$10(R.properties, T);
1945
+ }
1946
+ function ExcludeFromMappedResult(R, T) {
1947
+ return MappedResult(FromMappedResult$5(R, T));
1948
+ }
1949
+ //#endregion
1950
+ //#region ../../node_modules/.pnpm/@sinclair+typebox@0.34.48/node_modules/@sinclair/typebox/build/esm/type/extract/extract-from-template-literal.mjs
1951
+ function ExtractFromTemplateLiteral(L, R) {
1952
+ return Extract(TemplateLiteralToUnion(L), R);
1953
+ }
1954
+ //#endregion
1955
+ //#region ../../node_modules/.pnpm/@sinclair+typebox@0.34.48/node_modules/@sinclair/typebox/build/esm/type/extract/extract.mjs
1956
+ function ExtractRest(L, R) {
1957
+ const extracted = L.filter((inner) => ExtendsCheck(inner, R) !== ExtendsResult.False);
1958
+ return extracted.length === 1 ? extracted[0] : Union(extracted);
1959
+ }
1960
+ /** `[Json]` Constructs a type by extracting from type all union members that are assignable to union */
1961
+ function Extract(L, R, options) {
1962
+ if (IsTemplateLiteral$1(L)) return CreateType(ExtractFromTemplateLiteral(L, R), options);
1963
+ if (IsMappedResult$1(L)) return CreateType(ExtractFromMappedResult(L, R), options);
1964
+ return CreateType(IsUnion$1(L) ? ExtractRest(L.anyOf, R) : ExtendsCheck(L, R) !== ExtendsResult.False ? L : Never(), options);
1965
+ }
1966
+ //#endregion
1967
+ //#region ../../node_modules/.pnpm/@sinclair+typebox@0.34.48/node_modules/@sinclair/typebox/build/esm/type/extract/extract-from-mapped-result.mjs
1968
+ function FromProperties$9(P, T) {
1969
+ const Acc = {};
1970
+ for (const K2 of globalThis.Object.getOwnPropertyNames(P)) Acc[K2] = Extract(P[K2], T);
1971
+ return Acc;
1972
+ }
1973
+ function FromMappedResult$4(R, T) {
1974
+ return FromProperties$9(R.properties, T);
1975
+ }
1976
+ function ExtractFromMappedResult(R, T) {
1977
+ return MappedResult(FromMappedResult$4(R, T));
1978
+ }
1979
+ //#endregion
1980
+ //#region ../../node_modules/.pnpm/@sinclair+typebox@0.34.48/node_modules/@sinclair/typebox/build/esm/type/instance-type/instance-type.mjs
1981
+ /** `[JavaScript]` Extracts the InstanceType from the given Constructor type */
1982
+ function InstanceType(schema, options) {
1983
+ return IsConstructor$1(schema) ? CreateType(schema.returns, options) : Never(options);
1984
+ }
1985
+ //#endregion
1986
+ //#region ../../node_modules/.pnpm/@sinclair+typebox@0.34.48/node_modules/@sinclair/typebox/build/esm/type/readonly-optional/readonly-optional.mjs
1987
+ /** `[Json]` Creates a Readonly and Optional property */
1988
+ function ReadonlyOptional(schema) {
1989
+ return Readonly(Optional(schema));
1990
+ }
1991
+ //#endregion
1992
+ //#region ../../node_modules/.pnpm/@sinclair+typebox@0.34.48/node_modules/@sinclair/typebox/build/esm/type/record/record.mjs
1993
+ function RecordCreateFromPattern(pattern, T, options) {
1994
+ return CreateType({
1995
+ [Kind]: "Record",
1996
+ type: "object",
1997
+ patternProperties: { [pattern]: T }
1998
+ }, options);
1999
+ }
2000
+ function RecordCreateFromKeys(K, T, options) {
2001
+ const result = {};
2002
+ for (const K2 of K) result[K2] = T;
2003
+ return Object$1(result, {
2004
+ ...options,
2005
+ [Hint]: "Record"
2006
+ });
2007
+ }
2008
+ function FromTemplateLiteralKey(K, T, options) {
2009
+ return IsTemplateLiteralFinite(K) ? RecordCreateFromKeys(IndexPropertyKeys(K), T, options) : RecordCreateFromPattern(K.pattern, T, options);
2010
+ }
2011
+ function FromUnionKey(key, type, options) {
2012
+ return RecordCreateFromKeys(IndexPropertyKeys(Union(key)), type, options);
2013
+ }
2014
+ function FromLiteralKey(key, type, options) {
2015
+ return RecordCreateFromKeys([key.toString()], type, options);
2016
+ }
2017
+ function FromRegExpKey(key, type, options) {
2018
+ return RecordCreateFromPattern(key.source, type, options);
2019
+ }
2020
+ function FromStringKey(key, type, options) {
2021
+ return RecordCreateFromPattern(IsUndefined$3(key.pattern) ? PatternStringExact : key.pattern, type, options);
2022
+ }
2023
+ function FromAnyKey(_, type, options) {
2024
+ return RecordCreateFromPattern(PatternStringExact, type, options);
2025
+ }
2026
+ function FromNeverKey(_key, type, options) {
2027
+ return RecordCreateFromPattern(PatternNeverExact, type, options);
2028
+ }
2029
+ function FromBooleanKey(_key, type, options) {
2030
+ return Object$1({
2031
+ true: type,
2032
+ false: type
2033
+ }, options);
2034
+ }
2035
+ function FromIntegerKey(_key, type, options) {
2036
+ return RecordCreateFromPattern(PatternNumberExact, type, options);
2037
+ }
2038
+ function FromNumberKey(_, type, options) {
2039
+ return RecordCreateFromPattern(PatternNumberExact, type, options);
2040
+ }
2041
+ /** `[Json]` Creates a Record type */
2042
+ function Record(key, type, options = {}) {
2043
+ return IsUnion$1(key) ? FromUnionKey(key.anyOf, type, options) : IsTemplateLiteral$1(key) ? FromTemplateLiteralKey(key, type, options) : IsLiteral$1(key) ? FromLiteralKey(key.const, type, options) : IsBoolean$1(key) ? FromBooleanKey(key, type, options) : IsInteger$1(key) ? FromIntegerKey(key, type, options) : IsNumber$1(key) ? FromNumberKey(key, type, options) : IsRegExp$1(key) ? FromRegExpKey(key, type, options) : IsString$1(key) ? FromStringKey(key, type, options) : IsAny$1(key) ? FromAnyKey(key, type, options) : IsNever$1(key) ? FromNeverKey(key, type, options) : Never(options);
2044
+ }
2045
+ /** Gets the Records Pattern */
2046
+ function RecordPattern(record) {
2047
+ return globalThis.Object.getOwnPropertyNames(record.patternProperties)[0];
2048
+ }
2049
+ /** Gets the Records Key Type */
2050
+ function RecordKey(type) {
2051
+ const pattern = RecordPattern(type);
2052
+ return pattern === PatternStringExact ? String$1() : pattern === PatternNumberExact ? Number$1() : String$1({ pattern });
2053
+ }
2054
+ /** Gets a Record Value Type */
2055
+ function RecordValue(type) {
2056
+ return type.patternProperties[RecordPattern(type)];
2057
+ }
2058
+ //#endregion
2059
+ //#region ../../node_modules/.pnpm/@sinclair+typebox@0.34.48/node_modules/@sinclair/typebox/build/esm/type/instantiate/instantiate.mjs
2060
+ function FromConstructor$1(args, type) {
2061
+ type.parameters = FromTypes$1(args, type.parameters);
2062
+ type.returns = FromType$1(args, type.returns);
2063
+ return type;
2064
+ }
2065
+ function FromFunction$1(args, type) {
2066
+ type.parameters = FromTypes$1(args, type.parameters);
2067
+ type.returns = FromType$1(args, type.returns);
2068
+ return type;
2069
+ }
2070
+ function FromIntersect$3(args, type) {
2071
+ type.allOf = FromTypes$1(args, type.allOf);
2072
+ return type;
2073
+ }
2074
+ function FromUnion$3(args, type) {
2075
+ type.anyOf = FromTypes$1(args, type.anyOf);
2076
+ return type;
2077
+ }
2078
+ function FromTuple$1(args, type) {
2079
+ if (IsUndefined$3(type.items)) return type;
2080
+ type.items = FromTypes$1(args, type.items);
2081
+ return type;
2082
+ }
2083
+ function FromArray$1(args, type) {
2084
+ type.items = FromType$1(args, type.items);
2085
+ return type;
2086
+ }
2087
+ function FromAsyncIterator$1(args, type) {
2088
+ type.items = FromType$1(args, type.items);
2089
+ return type;
2090
+ }
2091
+ function FromIterator$1(args, type) {
2092
+ type.items = FromType$1(args, type.items);
2093
+ return type;
2094
+ }
2095
+ function FromPromise(args, type) {
2096
+ type.item = FromType$1(args, type.item);
2097
+ return type;
2098
+ }
2099
+ function FromObject$5(args, type) {
2100
+ const mappedProperties = FromProperties$8(args, type.properties);
2101
+ return {
2102
+ ...type,
2103
+ ...Object$1(mappedProperties)
2104
+ };
2105
+ }
2106
+ function FromRecord$1(args, type) {
2107
+ const result = Record(FromType$1(args, RecordKey(type)), FromType$1(args, RecordValue(type)));
2108
+ return {
2109
+ ...type,
2110
+ ...result
2111
+ };
2112
+ }
2113
+ function FromArgument(args, argument) {
2114
+ return argument.index in args ? args[argument.index] : Unknown();
2115
+ }
2116
+ function FromProperty$1(args, type) {
2117
+ const isReadonly = IsReadonly(type);
2118
+ const isOptional = IsOptional$1(type);
2119
+ const mapped = FromType$1(args, type);
2120
+ return isReadonly && isOptional ? ReadonlyOptional(mapped) : isReadonly && !isOptional ? Readonly(mapped) : !isReadonly && isOptional ? Optional(mapped) : mapped;
2121
+ }
2122
+ function FromProperties$8(args, properties) {
2123
+ return globalThis.Object.getOwnPropertyNames(properties).reduce((result, key) => {
2124
+ return {
2125
+ ...result,
2126
+ [key]: FromProperty$1(args, properties[key])
2127
+ };
2128
+ }, {});
2129
+ }
2130
+ function FromTypes$1(args, types) {
2131
+ return types.map((type) => FromType$1(args, type));
2132
+ }
2133
+ function FromType$1(args, type) {
2134
+ return IsConstructor$1(type) ? FromConstructor$1(args, type) : IsFunction$1(type) ? FromFunction$1(args, type) : IsIntersect$1(type) ? FromIntersect$3(args, type) : IsUnion$1(type) ? FromUnion$3(args, type) : IsTuple$1(type) ? FromTuple$1(args, type) : IsArray$1(type) ? FromArray$1(args, type) : IsAsyncIterator$1(type) ? FromAsyncIterator$1(args, type) : IsIterator$1(type) ? FromIterator$1(args, type) : IsPromise$1(type) ? FromPromise(args, type) : IsObject$1(type) ? FromObject$5(args, type) : IsRecord$1(type) ? FromRecord$1(args, type) : IsArgument$1(type) ? FromArgument(args, type) : type;
2135
+ }
2136
+ /** `[JavaScript]` Instantiates a type with the given parameters */
2137
+ function Instantiate(type, args) {
2138
+ return FromType$1(args, CloneType(type));
2139
+ }
2140
+ //#endregion
2141
+ //#region ../../node_modules/.pnpm/@sinclair+typebox@0.34.48/node_modules/@sinclair/typebox/build/esm/type/integer/integer.mjs
2142
+ /** `[Json]` Creates an Integer type */
2143
+ function Integer(options) {
2144
+ return CreateType({
2145
+ [Kind]: "Integer",
2146
+ type: "integer"
2147
+ }, options);
2148
+ }
2149
+ //#endregion
2150
+ //#region ../../node_modules/.pnpm/@sinclair+typebox@0.34.48/node_modules/@sinclair/typebox/build/esm/type/intrinsic/intrinsic-from-mapped-key.mjs
2151
+ function MappedIntrinsicPropertyKey(K, M, options) {
2152
+ return { [K]: Intrinsic(Literal(K), M, Clone(options)) };
2153
+ }
2154
+ function MappedIntrinsicPropertyKeys(K, M, options) {
2155
+ return K.reduce((Acc, L) => {
2156
+ return {
2157
+ ...Acc,
2158
+ ...MappedIntrinsicPropertyKey(L, M, options)
2159
+ };
2160
+ }, {});
2161
+ }
2162
+ function MappedIntrinsicProperties(T, M, options) {
2163
+ return MappedIntrinsicPropertyKeys(T["keys"], M, options);
2164
+ }
2165
+ function IntrinsicFromMappedKey(T, M, options) {
2166
+ return MappedResult(MappedIntrinsicProperties(T, M, options));
2167
+ }
2168
+ //#endregion
2169
+ //#region ../../node_modules/.pnpm/@sinclair+typebox@0.34.48/node_modules/@sinclair/typebox/build/esm/type/intrinsic/intrinsic.mjs
2170
+ function ApplyUncapitalize(value) {
2171
+ const [first, rest] = [value.slice(0, 1), value.slice(1)];
2172
+ return [first.toLowerCase(), rest].join("");
2173
+ }
2174
+ function ApplyCapitalize(value) {
2175
+ const [first, rest] = [value.slice(0, 1), value.slice(1)];
2176
+ return [first.toUpperCase(), rest].join("");
2177
+ }
2178
+ function ApplyUppercase(value) {
2179
+ return value.toUpperCase();
2180
+ }
2181
+ function ApplyLowercase(value) {
2182
+ return value.toLowerCase();
2183
+ }
2184
+ function FromTemplateLiteral(schema, mode, options) {
2185
+ const expression = TemplateLiteralParseExact(schema.pattern);
2186
+ if (!IsTemplateLiteralExpressionFinite(expression)) return {
2187
+ ...schema,
2188
+ pattern: FromLiteralValue(schema.pattern, mode)
2189
+ };
2190
+ return TemplateLiteral([Union(FromRest$2([...TemplateLiteralExpressionGenerate(expression)].map((value) => Literal(value)), mode))], options);
2191
+ }
2192
+ function FromLiteralValue(value, mode) {
2193
+ return typeof value === "string" ? mode === "Uncapitalize" ? ApplyUncapitalize(value) : mode === "Capitalize" ? ApplyCapitalize(value) : mode === "Uppercase" ? ApplyUppercase(value) : mode === "Lowercase" ? ApplyLowercase(value) : value : value.toString();
2194
+ }
2195
+ function FromRest$2(T, M) {
2196
+ return T.map((L) => Intrinsic(L, M));
2197
+ }
2198
+ /** Applies an intrinsic string manipulation to the given type. */
2199
+ function Intrinsic(schema, mode, options = {}) {
2200
+ return IsMappedKey$1(schema) ? IntrinsicFromMappedKey(schema, mode, options) : IsTemplateLiteral$1(schema) ? FromTemplateLiteral(schema, mode, options) : IsUnion$1(schema) ? Union(FromRest$2(schema.anyOf, mode), options) : IsLiteral$1(schema) ? Literal(FromLiteralValue(schema.const, mode), options) : CreateType(schema, options);
2201
+ }
2202
+ //#endregion
2203
+ //#region ../../node_modules/.pnpm/@sinclair+typebox@0.34.48/node_modules/@sinclair/typebox/build/esm/type/intrinsic/capitalize.mjs
2204
+ /** `[Json]` Intrinsic function to Capitalize LiteralString types */
2205
+ function Capitalize(T, options = {}) {
2206
+ return Intrinsic(T, "Capitalize", options);
2207
+ }
2208
+ //#endregion
2209
+ //#region ../../node_modules/.pnpm/@sinclair+typebox@0.34.48/node_modules/@sinclair/typebox/build/esm/type/intrinsic/lowercase.mjs
2210
+ /** `[Json]` Intrinsic function to Lowercase LiteralString types */
2211
+ function Lowercase(T, options = {}) {
2212
+ return Intrinsic(T, "Lowercase", options);
2213
+ }
2214
+ //#endregion
2215
+ //#region ../../node_modules/.pnpm/@sinclair+typebox@0.34.48/node_modules/@sinclair/typebox/build/esm/type/intrinsic/uncapitalize.mjs
2216
+ /** `[Json]` Intrinsic function to Uncapitalize LiteralString types */
2217
+ function Uncapitalize(T, options = {}) {
2218
+ return Intrinsic(T, "Uncapitalize", options);
2219
+ }
2220
+ //#endregion
2221
+ //#region ../../node_modules/.pnpm/@sinclair+typebox@0.34.48/node_modules/@sinclair/typebox/build/esm/type/intrinsic/uppercase.mjs
2222
+ /** `[Json]` Intrinsic function to Uppercase LiteralString types */
2223
+ function Uppercase(T, options = {}) {
2224
+ return Intrinsic(T, "Uppercase", options);
2225
+ }
2226
+ //#endregion
2227
+ //#region ../../node_modules/.pnpm/@sinclair+typebox@0.34.48/node_modules/@sinclair/typebox/build/esm/type/omit/omit-from-mapped-result.mjs
2228
+ function FromProperties$7(properties, propertyKeys, options) {
2229
+ const result = {};
2230
+ for (const K2 of globalThis.Object.getOwnPropertyNames(properties)) result[K2] = Omit(properties[K2], propertyKeys, Clone(options));
2231
+ return result;
2232
+ }
2233
+ function FromMappedResult$3(mappedResult, propertyKeys, options) {
2234
+ return FromProperties$7(mappedResult.properties, propertyKeys, options);
2235
+ }
2236
+ function OmitFromMappedResult(mappedResult, propertyKeys, options) {
2237
+ return MappedResult(FromMappedResult$3(mappedResult, propertyKeys, options));
2238
+ }
2239
+ //#endregion
2240
+ //#region ../../node_modules/.pnpm/@sinclair+typebox@0.34.48/node_modules/@sinclair/typebox/build/esm/type/omit/omit.mjs
2241
+ function FromIntersect$2(types, propertyKeys) {
2242
+ return types.map((type) => OmitResolve(type, propertyKeys));
2243
+ }
2244
+ function FromUnion$2(types, propertyKeys) {
2245
+ return types.map((type) => OmitResolve(type, propertyKeys));
2246
+ }
2247
+ function FromProperty(properties, key) {
2248
+ const { [key]: _, ...R } = properties;
2249
+ return R;
2250
+ }
2251
+ function FromProperties$6(properties, propertyKeys) {
2252
+ return propertyKeys.reduce((T, K2) => FromProperty(T, K2), properties);
2253
+ }
2254
+ function FromObject$4(type, propertyKeys, properties) {
2255
+ const options = Discard(type, [
2256
+ TransformKind,
2257
+ "$id",
2258
+ "required",
2259
+ "properties"
2260
+ ]);
2261
+ return Object$1(FromProperties$6(properties, propertyKeys), options);
2262
+ }
2263
+ function UnionFromPropertyKeys$1(propertyKeys) {
2264
+ return Union(propertyKeys.reduce((result, key) => IsLiteralValue$1(key) ? [...result, Literal(key)] : result, []));
2265
+ }
2266
+ function OmitResolve(type, propertyKeys) {
2267
+ return IsIntersect$1(type) ? Intersect(FromIntersect$2(type.allOf, propertyKeys)) : IsUnion$1(type) ? Union(FromUnion$2(type.anyOf, propertyKeys)) : IsObject$1(type) ? FromObject$4(type, propertyKeys, type.properties) : Object$1({});
2268
+ }
2269
+ /** `[Json]` Constructs a type whose keys are picked from the given type */
2270
+ function Omit(type, key, options) {
2271
+ const typeKey = IsArray$3(key) ? UnionFromPropertyKeys$1(key) : key;
2272
+ const propertyKeys = IsSchema$1(key) ? IndexPropertyKeys(key) : key;
2273
+ const isTypeRef = IsRef$1(type);
2274
+ const isKeyRef = IsRef$1(key);
2275
+ return IsMappedResult$1(type) ? OmitFromMappedResult(type, propertyKeys, options) : IsMappedKey$1(key) ? OmitFromMappedKey(type, key, options) : isTypeRef && isKeyRef ? Computed("Omit", [type, typeKey], options) : !isTypeRef && isKeyRef ? Computed("Omit", [type, typeKey], options) : isTypeRef && !isKeyRef ? Computed("Omit", [type, typeKey], options) : CreateType({
2276
+ ...OmitResolve(type, propertyKeys),
2277
+ ...options
2278
+ });
2279
+ }
2280
+ //#endregion
2281
+ //#region ../../node_modules/.pnpm/@sinclair+typebox@0.34.48/node_modules/@sinclair/typebox/build/esm/type/omit/omit-from-mapped-key.mjs
2282
+ function FromPropertyKey$1(type, key, options) {
2283
+ return { [key]: Omit(type, [key], Clone(options)) };
2284
+ }
2285
+ function FromPropertyKeys$1(type, propertyKeys, options) {
2286
+ return propertyKeys.reduce((Acc, LK) => {
2287
+ return {
2288
+ ...Acc,
2289
+ ...FromPropertyKey$1(type, LK, options)
2290
+ };
2291
+ }, {});
2292
+ }
2293
+ function FromMappedKey$1(type, mappedKey, options) {
2294
+ return FromPropertyKeys$1(type, mappedKey.keys, options);
2295
+ }
2296
+ function OmitFromMappedKey(type, mappedKey, options) {
2297
+ return MappedResult(FromMappedKey$1(type, mappedKey, options));
2298
+ }
2299
+ //#endregion
2300
+ //#region ../../node_modules/.pnpm/@sinclair+typebox@0.34.48/node_modules/@sinclair/typebox/build/esm/type/pick/pick-from-mapped-result.mjs
2301
+ function FromProperties$5(properties, propertyKeys, options) {
2302
+ const result = {};
2303
+ for (const K2 of globalThis.Object.getOwnPropertyNames(properties)) result[K2] = Pick(properties[K2], propertyKeys, Clone(options));
2304
+ return result;
2305
+ }
2306
+ function FromMappedResult$2(mappedResult, propertyKeys, options) {
2307
+ return FromProperties$5(mappedResult.properties, propertyKeys, options);
2308
+ }
2309
+ function PickFromMappedResult(mappedResult, propertyKeys, options) {
2310
+ return MappedResult(FromMappedResult$2(mappedResult, propertyKeys, options));
2311
+ }
2312
+ //#endregion
2313
+ //#region ../../node_modules/.pnpm/@sinclair+typebox@0.34.48/node_modules/@sinclair/typebox/build/esm/type/pick/pick.mjs
2314
+ function FromIntersect$1(types, propertyKeys) {
2315
+ return types.map((type) => PickResolve(type, propertyKeys));
2316
+ }
2317
+ function FromUnion$1(types, propertyKeys) {
2318
+ return types.map((type) => PickResolve(type, propertyKeys));
2319
+ }
2320
+ function FromProperties$4(properties, propertyKeys) {
2321
+ const result = {};
2322
+ for (const K2 of propertyKeys) if (K2 in properties) result[K2] = properties[K2];
2323
+ return result;
2324
+ }
2325
+ function FromObject$3(Type, keys, properties) {
2326
+ const options = Discard(Type, [
2327
+ TransformKind,
2328
+ "$id",
2329
+ "required",
2330
+ "properties"
2331
+ ]);
2332
+ return Object$1(FromProperties$4(properties, keys), options);
2333
+ }
2334
+ function UnionFromPropertyKeys(propertyKeys) {
2335
+ return Union(propertyKeys.reduce((result, key) => IsLiteralValue$1(key) ? [...result, Literal(key)] : result, []));
2336
+ }
2337
+ function PickResolve(type, propertyKeys) {
2338
+ return IsIntersect$1(type) ? Intersect(FromIntersect$1(type.allOf, propertyKeys)) : IsUnion$1(type) ? Union(FromUnion$1(type.anyOf, propertyKeys)) : IsObject$1(type) ? FromObject$3(type, propertyKeys, type.properties) : Object$1({});
2339
+ }
2340
+ /** `[Json]` Constructs a type whose keys are picked from the given type */
2341
+ function Pick(type, key, options) {
2342
+ const typeKey = IsArray$3(key) ? UnionFromPropertyKeys(key) : key;
2343
+ const propertyKeys = IsSchema$1(key) ? IndexPropertyKeys(key) : key;
2344
+ const isTypeRef = IsRef$1(type);
2345
+ const isKeyRef = IsRef$1(key);
2346
+ return IsMappedResult$1(type) ? PickFromMappedResult(type, propertyKeys, options) : IsMappedKey$1(key) ? PickFromMappedKey(type, key, options) : isTypeRef && isKeyRef ? Computed("Pick", [type, typeKey], options) : !isTypeRef && isKeyRef ? Computed("Pick", [type, typeKey], options) : isTypeRef && !isKeyRef ? Computed("Pick", [type, typeKey], options) : CreateType({
2347
+ ...PickResolve(type, propertyKeys),
2348
+ ...options
2349
+ });
2350
+ }
2351
+ //#endregion
2352
+ //#region ../../node_modules/.pnpm/@sinclair+typebox@0.34.48/node_modules/@sinclair/typebox/build/esm/type/pick/pick-from-mapped-key.mjs
2353
+ function FromPropertyKey(type, key, options) {
2354
+ return { [key]: Pick(type, [key], Clone(options)) };
2355
+ }
2356
+ function FromPropertyKeys(type, propertyKeys, options) {
2357
+ return propertyKeys.reduce((result, leftKey) => {
2358
+ return {
2359
+ ...result,
2360
+ ...FromPropertyKey(type, leftKey, options)
2361
+ };
2362
+ }, {});
2363
+ }
2364
+ function FromMappedKey(type, mappedKey, options) {
2365
+ return FromPropertyKeys(type, mappedKey.keys, options);
2366
+ }
2367
+ function PickFromMappedKey(type, mappedKey, options) {
2368
+ return MappedResult(FromMappedKey(type, mappedKey, options));
2369
+ }
2370
+ //#endregion
2371
+ //#region ../../node_modules/.pnpm/@sinclair+typebox@0.34.48/node_modules/@sinclair/typebox/build/esm/type/partial/partial.mjs
2372
+ function FromComputed$2(target, parameters) {
2373
+ return Computed("Partial", [Computed(target, parameters)]);
2374
+ }
2375
+ function FromRef$1($ref) {
2376
+ return Computed("Partial", [Ref($ref)]);
2377
+ }
2378
+ function FromProperties$3(properties) {
2379
+ const partialProperties = {};
2380
+ for (const K of globalThis.Object.getOwnPropertyNames(properties)) partialProperties[K] = Optional(properties[K]);
2381
+ return partialProperties;
2382
+ }
2383
+ function FromObject$2(type, properties) {
2384
+ const options = Discard(type, [
2385
+ TransformKind,
2386
+ "$id",
2387
+ "required",
2388
+ "properties"
2389
+ ]);
2390
+ return Object$1(FromProperties$3(properties), options);
2391
+ }
2392
+ function FromRest$1(types) {
2393
+ return types.map((type) => PartialResolve(type));
2394
+ }
2395
+ function PartialResolve(type) {
2396
+ return IsComputed$1(type) ? FromComputed$2(type.target, type.parameters) : IsRef$1(type) ? FromRef$1(type.$ref) : IsIntersect$1(type) ? Intersect(FromRest$1(type.allOf)) : IsUnion$1(type) ? Union(FromRest$1(type.anyOf)) : IsObject$1(type) ? FromObject$2(type, type.properties) : IsBigInt$1(type) ? type : IsBoolean$1(type) ? type : IsInteger$1(type) ? type : IsLiteral$1(type) ? type : IsNull$1(type) ? type : IsNumber$1(type) ? type : IsString$1(type) ? type : IsSymbol$1(type) ? type : IsUndefined$1(type) ? type : Object$1({});
2397
+ }
2398
+ /** `[Json]` Constructs a type where all properties are optional */
2399
+ function Partial(type, options) {
2400
+ if (IsMappedResult$1(type)) return PartialFromMappedResult(type, options);
2401
+ else return CreateType({
2402
+ ...PartialResolve(type),
2403
+ ...options
2404
+ });
2405
+ }
2406
+ //#endregion
2407
+ //#region ../../node_modules/.pnpm/@sinclair+typebox@0.34.48/node_modules/@sinclair/typebox/build/esm/type/partial/partial-from-mapped-result.mjs
2408
+ function FromProperties$2(K, options) {
2409
+ const Acc = {};
2410
+ for (const K2 of globalThis.Object.getOwnPropertyNames(K)) Acc[K2] = Partial(K[K2], Clone(options));
2411
+ return Acc;
2412
+ }
2413
+ function FromMappedResult$1(R, options) {
2414
+ return FromProperties$2(R.properties, options);
2415
+ }
2416
+ function PartialFromMappedResult(R, options) {
2417
+ return MappedResult(FromMappedResult$1(R, options));
2418
+ }
2419
+ //#endregion
2420
+ //#region ../../node_modules/.pnpm/@sinclair+typebox@0.34.48/node_modules/@sinclair/typebox/build/esm/type/required/required.mjs
2421
+ function FromComputed$1(target, parameters) {
2422
+ return Computed("Required", [Computed(target, parameters)]);
2423
+ }
2424
+ function FromRef($ref) {
2425
+ return Computed("Required", [Ref($ref)]);
2426
+ }
2427
+ function FromProperties$1(properties) {
2428
+ const requiredProperties = {};
2429
+ for (const K of globalThis.Object.getOwnPropertyNames(properties)) requiredProperties[K] = Discard(properties[K], [OptionalKind]);
2430
+ return requiredProperties;
2431
+ }
2432
+ function FromObject$1(type, properties) {
2433
+ const options = Discard(type, [
2434
+ TransformKind,
2435
+ "$id",
2436
+ "required",
2437
+ "properties"
2438
+ ]);
2439
+ return Object$1(FromProperties$1(properties), options);
2440
+ }
2441
+ function FromRest(types) {
2442
+ return types.map((type) => RequiredResolve(type));
2443
+ }
2444
+ function RequiredResolve(type) {
2445
+ return IsComputed$1(type) ? FromComputed$1(type.target, type.parameters) : IsRef$1(type) ? FromRef(type.$ref) : IsIntersect$1(type) ? Intersect(FromRest(type.allOf)) : IsUnion$1(type) ? Union(FromRest(type.anyOf)) : IsObject$1(type) ? FromObject$1(type, type.properties) : IsBigInt$1(type) ? type : IsBoolean$1(type) ? type : IsInteger$1(type) ? type : IsLiteral$1(type) ? type : IsNull$1(type) ? type : IsNumber$1(type) ? type : IsString$1(type) ? type : IsSymbol$1(type) ? type : IsUndefined$1(type) ? type : Object$1({});
2446
+ }
2447
+ /** `[Json]` Constructs a type where all properties are required */
2448
+ function Required(type, options) {
2449
+ if (IsMappedResult$1(type)) return RequiredFromMappedResult(type, options);
2450
+ else return CreateType({
2451
+ ...RequiredResolve(type),
2452
+ ...options
2453
+ });
2454
+ }
2455
+ //#endregion
2456
+ //#region ../../node_modules/.pnpm/@sinclair+typebox@0.34.48/node_modules/@sinclair/typebox/build/esm/type/required/required-from-mapped-result.mjs
2457
+ function FromProperties(P, options) {
2458
+ const Acc = {};
2459
+ for (const K2 of globalThis.Object.getOwnPropertyNames(P)) Acc[K2] = Required(P[K2], options);
2460
+ return Acc;
2461
+ }
2462
+ function FromMappedResult(R, options) {
2463
+ return FromProperties(R.properties, options);
2464
+ }
2465
+ function RequiredFromMappedResult(R, options) {
2466
+ return MappedResult(FromMappedResult(R, options));
2467
+ }
2468
+ //#endregion
2469
+ //#region ../../node_modules/.pnpm/@sinclair+typebox@0.34.48/node_modules/@sinclair/typebox/build/esm/type/module/compute.mjs
2470
+ function DereferenceParameters(moduleProperties, types) {
2471
+ return types.map((type) => {
2472
+ return IsRef$1(type) ? Dereference(moduleProperties, type.$ref) : FromType(moduleProperties, type);
2473
+ });
2474
+ }
2475
+ function Dereference(moduleProperties, ref) {
2476
+ return ref in moduleProperties ? IsRef$1(moduleProperties[ref]) ? Dereference(moduleProperties, moduleProperties[ref].$ref) : FromType(moduleProperties, moduleProperties[ref]) : Never();
2477
+ }
2478
+ function FromAwaited(parameters) {
2479
+ return Awaited(parameters[0]);
2480
+ }
2481
+ function FromIndex(parameters) {
2482
+ return Index(parameters[0], parameters[1]);
2483
+ }
2484
+ function FromKeyOf(parameters) {
2485
+ return KeyOf(parameters[0]);
2486
+ }
2487
+ function FromPartial(parameters) {
2488
+ return Partial(parameters[0]);
2489
+ }
2490
+ function FromOmit(parameters) {
2491
+ return Omit(parameters[0], parameters[1]);
2492
+ }
2493
+ function FromPick(parameters) {
2494
+ return Pick(parameters[0], parameters[1]);
2495
+ }
2496
+ function FromRequired(parameters) {
2497
+ return Required(parameters[0]);
2498
+ }
2499
+ function FromComputed(moduleProperties, target, parameters) {
2500
+ const dereferenced = DereferenceParameters(moduleProperties, parameters);
2501
+ return target === "Awaited" ? FromAwaited(dereferenced) : target === "Index" ? FromIndex(dereferenced) : target === "KeyOf" ? FromKeyOf(dereferenced) : target === "Partial" ? FromPartial(dereferenced) : target === "Omit" ? FromOmit(dereferenced) : target === "Pick" ? FromPick(dereferenced) : target === "Required" ? FromRequired(dereferenced) : Never();
2502
+ }
2503
+ function FromArray(moduleProperties, type) {
2504
+ return Array$1(FromType(moduleProperties, type));
2505
+ }
2506
+ function FromAsyncIterator(moduleProperties, type) {
2507
+ return AsyncIterator(FromType(moduleProperties, type));
2508
+ }
2509
+ function FromConstructor(moduleProperties, parameters, instanceType) {
2510
+ return Constructor(FromTypes(moduleProperties, parameters), FromType(moduleProperties, instanceType));
2511
+ }
2512
+ function FromFunction(moduleProperties, parameters, returnType) {
2513
+ return Function(FromTypes(moduleProperties, parameters), FromType(moduleProperties, returnType));
2514
+ }
2515
+ function FromIntersect(moduleProperties, types) {
2516
+ return Intersect(FromTypes(moduleProperties, types));
2517
+ }
2518
+ function FromIterator(moduleProperties, type) {
2519
+ return Iterator(FromType(moduleProperties, type));
2520
+ }
2521
+ function FromObject(moduleProperties, properties) {
2522
+ return Object$1(globalThis.Object.keys(properties).reduce((result, key) => {
2523
+ return {
2524
+ ...result,
2525
+ [key]: FromType(moduleProperties, properties[key])
2526
+ };
2527
+ }, {}));
2528
+ }
2529
+ function FromRecord(moduleProperties, type) {
2530
+ const [value, pattern] = [FromType(moduleProperties, RecordValue(type)), RecordPattern(type)];
2531
+ const result = CloneType(type);
2532
+ result.patternProperties[pattern] = value;
2533
+ return result;
2534
+ }
2535
+ function FromTransform(moduleProperties, transform) {
2536
+ return IsRef$1(transform) ? {
2537
+ ...Dereference(moduleProperties, transform.$ref),
2538
+ [TransformKind]: transform[TransformKind]
2539
+ } : transform;
2540
+ }
2541
+ function FromTuple(moduleProperties, types) {
2542
+ return Tuple(FromTypes(moduleProperties, types));
2543
+ }
2544
+ function FromUnion(moduleProperties, types) {
2545
+ return Union(FromTypes(moduleProperties, types));
2546
+ }
2547
+ function FromTypes(moduleProperties, types) {
2548
+ return types.map((type) => FromType(moduleProperties, type));
2549
+ }
2550
+ function FromType(moduleProperties, type) {
2551
+ return IsOptional$1(type) ? CreateType(FromType(moduleProperties, Discard(type, [OptionalKind])), type) : IsReadonly(type) ? CreateType(FromType(moduleProperties, Discard(type, [ReadonlyKind])), type) : IsTransform$1(type) ? CreateType(FromTransform(moduleProperties, type), type) : IsArray$1(type) ? CreateType(FromArray(moduleProperties, type.items), type) : IsAsyncIterator$1(type) ? CreateType(FromAsyncIterator(moduleProperties, type.items), type) : IsComputed$1(type) ? CreateType(FromComputed(moduleProperties, type.target, type.parameters)) : IsConstructor$1(type) ? CreateType(FromConstructor(moduleProperties, type.parameters, type.returns), type) : IsFunction$1(type) ? CreateType(FromFunction(moduleProperties, type.parameters, type.returns), type) : IsIntersect$1(type) ? CreateType(FromIntersect(moduleProperties, type.allOf), type) : IsIterator$1(type) ? CreateType(FromIterator(moduleProperties, type.items), type) : IsObject$1(type) ? CreateType(FromObject(moduleProperties, type.properties), type) : IsRecord$1(type) ? CreateType(FromRecord(moduleProperties, type)) : IsTuple$1(type) ? CreateType(FromTuple(moduleProperties, type.items || []), type) : IsUnion$1(type) ? CreateType(FromUnion(moduleProperties, type.anyOf), type) : type;
2552
+ }
2553
+ function ComputeType(moduleProperties, key) {
2554
+ return key in moduleProperties ? FromType(moduleProperties, moduleProperties[key]) : Never();
2555
+ }
2556
+ function ComputeModuleProperties(moduleProperties) {
2557
+ return globalThis.Object.getOwnPropertyNames(moduleProperties).reduce((result, key) => {
2558
+ return {
2559
+ ...result,
2560
+ [key]: ComputeType(moduleProperties, key)
2561
+ };
2562
+ }, {});
2563
+ }
2564
+ //#endregion
2565
+ //#region ../../node_modules/.pnpm/@sinclair+typebox@0.34.48/node_modules/@sinclair/typebox/build/esm/type/module/module.mjs
2566
+ var TModule = class {
2567
+ constructor($defs) {
2568
+ const computed = ComputeModuleProperties($defs);
2569
+ this.$defs = this.WithIdentifiers(computed);
2570
+ }
2571
+ /** `[Json]` Imports a Type by Key. */
2572
+ Import(key, options) {
2573
+ const $defs = {
2574
+ ...this.$defs,
2575
+ [key]: CreateType(this.$defs[key], options)
2576
+ };
2577
+ return CreateType({
2578
+ [Kind]: "Import",
2579
+ $defs,
2580
+ $ref: key
2581
+ });
2582
+ }
2583
+ WithIdentifiers($defs) {
2584
+ return globalThis.Object.getOwnPropertyNames($defs).reduce((result, key) => {
2585
+ return {
2586
+ ...result,
2587
+ [key]: {
2588
+ ...$defs[key],
2589
+ $id: key
2590
+ }
2591
+ };
2592
+ }, {});
2593
+ }
2594
+ };
2595
+ /** `[Json]` Creates a Type Definition Module. */
2596
+ function Module(properties) {
2597
+ return new TModule(properties);
2598
+ }
2599
+ //#endregion
2600
+ //#region ../../node_modules/.pnpm/@sinclair+typebox@0.34.48/node_modules/@sinclair/typebox/build/esm/type/not/not.mjs
2601
+ /** `[Json]` Creates a Not type */
2602
+ function Not(type, options) {
2603
+ return CreateType({
2604
+ [Kind]: "Not",
2605
+ not: type
2606
+ }, options);
2607
+ }
2608
+ //#endregion
2609
+ //#region ../../node_modules/.pnpm/@sinclair+typebox@0.34.48/node_modules/@sinclair/typebox/build/esm/type/parameters/parameters.mjs
2610
+ /** `[JavaScript]` Extracts the Parameters from the given Function type */
2611
+ function Parameters(schema, options) {
2612
+ return IsFunction$1(schema) ? Tuple(schema.parameters, options) : Never();
2613
+ }
2614
+ //#endregion
2615
+ //#region ../../node_modules/.pnpm/@sinclair+typebox@0.34.48/node_modules/@sinclair/typebox/build/esm/type/recursive/recursive.mjs
2616
+ let Ordinal = 0;
2617
+ /** `[Json]` Creates a Recursive type */
2618
+ function Recursive(callback, options = {}) {
2619
+ if (IsUndefined$3(options.$id)) options.$id = `T${Ordinal++}`;
2620
+ const thisType = CloneType(callback({
2621
+ [Kind]: "This",
2622
+ $ref: `${options.$id}`
2623
+ }));
2624
+ thisType.$id = options.$id;
2625
+ return CreateType({
2626
+ [Hint]: "Recursive",
2627
+ ...thisType
2628
+ }, options);
2629
+ }
2630
+ //#endregion
2631
+ //#region ../../node_modules/.pnpm/@sinclair+typebox@0.34.48/node_modules/@sinclair/typebox/build/esm/type/regexp/regexp.mjs
2632
+ /** `[JavaScript]` Creates a RegExp type */
2633
+ function RegExp$1(unresolved, options) {
2634
+ const expr = IsString$2(unresolved) ? new globalThis.RegExp(unresolved) : unresolved;
2635
+ return CreateType({
2636
+ [Kind]: "RegExp",
2637
+ type: "RegExp",
2638
+ source: expr.source,
2639
+ flags: expr.flags
2640
+ }, options);
2641
+ }
2642
+ //#endregion
2643
+ //#region ../../node_modules/.pnpm/@sinclair+typebox@0.34.48/node_modules/@sinclair/typebox/build/esm/type/rest/rest.mjs
2644
+ function RestResolve(T) {
2645
+ return IsIntersect$1(T) ? T.allOf : IsUnion$1(T) ? T.anyOf : IsTuple$1(T) ? T.items ?? [] : [];
2646
+ }
2647
+ /** `[Json]` Extracts interior Rest elements from Tuple, Intersect and Union types */
2648
+ function Rest(T) {
2649
+ return RestResolve(T);
2650
+ }
2651
+ //#endregion
2652
+ //#region ../../node_modules/.pnpm/@sinclair+typebox@0.34.48/node_modules/@sinclair/typebox/build/esm/type/return-type/return-type.mjs
2653
+ /** `[JavaScript]` Extracts the ReturnType from the given Function type */
2654
+ function ReturnType(schema, options) {
2655
+ return IsFunction$1(schema) ? CreateType(schema.returns, options) : Never(options);
2656
+ }
2657
+ //#endregion
2658
+ //#region ../../node_modules/.pnpm/@sinclair+typebox@0.34.48/node_modules/@sinclair/typebox/build/esm/type/transform/transform.mjs
2659
+ var TransformDecodeBuilder = class {
2660
+ constructor(schema) {
2661
+ this.schema = schema;
2662
+ }
2663
+ Decode(decode) {
2664
+ return new TransformEncodeBuilder(this.schema, decode);
2665
+ }
2666
+ };
2667
+ var TransformEncodeBuilder = class {
2668
+ constructor(schema, decode) {
2669
+ this.schema = schema;
2670
+ this.decode = decode;
2671
+ }
2672
+ EncodeTransform(encode, schema) {
2673
+ const Encode = (value) => schema[TransformKind].Encode(encode(value));
2674
+ const Decode = (value) => this.decode(schema[TransformKind].Decode(value));
2675
+ const Codec = {
2676
+ Encode,
2677
+ Decode
2678
+ };
2679
+ return {
2680
+ ...schema,
2681
+ [TransformKind]: Codec
2682
+ };
2683
+ }
2684
+ EncodeSchema(encode, schema) {
2685
+ const Codec = {
2686
+ Decode: this.decode,
2687
+ Encode: encode
2688
+ };
2689
+ return {
2690
+ ...schema,
2691
+ [TransformKind]: Codec
2692
+ };
2693
+ }
2694
+ Encode(encode) {
2695
+ return IsTransform$1(this.schema) ? this.EncodeTransform(encode, this.schema) : this.EncodeSchema(encode, this.schema);
2696
+ }
2697
+ };
2698
+ /** `[Json]` Creates a Transform type */
2699
+ function Transform(schema) {
2700
+ return new TransformDecodeBuilder(schema);
2701
+ }
2702
+ //#endregion
2703
+ //#region ../../node_modules/.pnpm/@sinclair+typebox@0.34.48/node_modules/@sinclair/typebox/build/esm/type/unsafe/unsafe.mjs
2704
+ /** `[Json]` Creates a Unsafe type that will infers as the generic argument T */
2705
+ function Unsafe(options = {}) {
2706
+ return CreateType({ [Kind]: options[Kind] ?? "Unsafe" }, options);
2707
+ }
2708
+ //#endregion
2709
+ //#region ../../node_modules/.pnpm/@sinclair+typebox@0.34.48/node_modules/@sinclair/typebox/build/esm/type/void/void.mjs
2710
+ /** `[JavaScript]` Creates a Void type */
2711
+ function Void(options) {
2712
+ return CreateType({
2713
+ [Kind]: "Void",
2714
+ type: "void"
2715
+ }, options);
2716
+ }
2717
+ //#endregion
2718
+ //#region ../../node_modules/.pnpm/@sinclair+typebox@0.34.48/node_modules/@sinclair/typebox/build/esm/type/type/index.mjs
2719
+ /** JavaScript Type Builder with Static Resolution for TypeScript */
2720
+ const Type = /* @__PURE__ */ __exportAll({
2721
+ Any: () => Any,
2722
+ Argument: () => Argument,
2723
+ Array: () => Array$1,
2724
+ AsyncIterator: () => AsyncIterator,
2725
+ Awaited: () => Awaited,
2726
+ BigInt: () => BigInt,
2727
+ Boolean: () => Boolean,
2728
+ Capitalize: () => Capitalize,
2729
+ Composite: () => Composite,
2730
+ Const: () => Const,
2731
+ Constructor: () => Constructor,
2732
+ ConstructorParameters: () => ConstructorParameters,
2733
+ Date: () => Date$1,
2734
+ Enum: () => Enum,
2735
+ Exclude: () => Exclude,
2736
+ Extends: () => Extends,
2737
+ Extract: () => Extract,
2738
+ Function: () => Function,
2739
+ Index: () => Index,
2740
+ InstanceType: () => InstanceType,
2741
+ Instantiate: () => Instantiate,
2742
+ Integer: () => Integer,
2743
+ Intersect: () => Intersect,
2744
+ Iterator: () => Iterator,
2745
+ KeyOf: () => KeyOf,
2746
+ Literal: () => Literal,
2747
+ Lowercase: () => Lowercase,
2748
+ Mapped: () => Mapped,
2749
+ Module: () => Module,
2750
+ Never: () => Never,
2751
+ Not: () => Not,
2752
+ Null: () => Null,
2753
+ Number: () => Number$1,
2754
+ Object: () => Object$1,
2755
+ Omit: () => Omit,
2756
+ Optional: () => Optional,
2757
+ Parameters: () => Parameters,
2758
+ Partial: () => Partial,
2759
+ Pick: () => Pick,
2760
+ Promise: () => Promise$1,
2761
+ Readonly: () => Readonly,
2762
+ ReadonlyOptional: () => ReadonlyOptional,
2763
+ Record: () => Record,
2764
+ Recursive: () => Recursive,
2765
+ Ref: () => Ref,
2766
+ RegExp: () => RegExp$1,
2767
+ Required: () => Required,
2768
+ Rest: () => Rest,
2769
+ ReturnType: () => ReturnType,
2770
+ String: () => String$1,
2771
+ Symbol: () => Symbol$1,
2772
+ TemplateLiteral: () => TemplateLiteral,
2773
+ Transform: () => Transform,
2774
+ Tuple: () => Tuple,
2775
+ Uint8Array: () => Uint8Array$1,
2776
+ Uncapitalize: () => Uncapitalize,
2777
+ Undefined: () => Undefined,
2778
+ Union: () => Union,
2779
+ Unknown: () => Unknown,
2780
+ Unsafe: () => Unsafe,
2781
+ Uppercase: () => Uppercase,
2782
+ Void: () => Void
2783
+ });
2784
+ //#endregion
2785
+ //#region src/types.ts
2786
+ function isIPCRequest(msg) {
2787
+ return typeof msg === "object" && msg !== null && msg.type === "req" && typeof msg.id === "string" && typeof msg.method === "string";
2788
+ }
2789
+ function isIPCResponse(msg) {
2790
+ return typeof msg === "object" && msg !== null && typeof msg.id === "string" && typeof msg.ok === "boolean" && !("type" in msg);
2791
+ }
2792
+ function isIPCEvent(msg) {
2793
+ return typeof msg === "object" && msg !== null && msg.type === "event" && typeof msg.event === "string";
2794
+ }
2795
+ /** IPC protocol version — must match daemon's PROTOCOL_VERSION */
2796
+ const PROTOCOL_VERSION = 1;
2797
+ //#endregion
2798
+ //#region src/ipc-client.ts
2799
+ /**
2800
+ * IPC Client — connects to the Alfe gateway daemon via Unix socket.
2801
+ *
2802
+ * Protocol: newline-delimited JSON over Unix socket.
2803
+ * Request: { type: 'req', id, method, params }
2804
+ * Response: { id, ok, payload?, error? }
2805
+ * Event: { type: 'event', event, payload }
2806
+ *
2807
+ * Features:
2808
+ * - Automatic reconnection with exponential backoff (1s → 30s)
2809
+ * - Request/response correlation via message ID
2810
+ * - Event emission for incoming daemon events + requests
2811
+ * - Graceful handling if daemon not running (warns, retries, doesn't crash)
2812
+ */
2813
+ const MIN_BACKOFF_MS = 1e3;
2814
+ const MAX_BACKOFF_MS = 3e4;
2815
+ const DEFAULT_REQUEST_TIMEOUT_MS = 3e4;
2816
+ var IPCClient = class extends node_events.EventEmitter {
2817
+ socket = null;
2818
+ socketPath;
2819
+ buffer = "";
2820
+ backoffMs = MIN_BACKOFF_MS;
2821
+ closed = false;
2822
+ _connected = false;
2823
+ reconnectTimer = null;
2824
+ pending = /* @__PURE__ */ new Map();
2825
+ log = (0, _auriclabs_logger.createLogger)("IpcClient");
2826
+ constructor(socketPath) {
2827
+ super();
2828
+ this.socketPath = socketPath;
2829
+ }
2830
+ get connected() {
2831
+ return this._connected;
2832
+ }
2833
+ /**
2834
+ * Start the IPC connection with auto-reconnect.
2835
+ */
2836
+ start() {
2837
+ this.closed = false;
2838
+ this.doConnect();
2839
+ }
2840
+ /**
2841
+ * Stop the IPC connection and all timers.
2842
+ */
2843
+ stop() {
2844
+ this.closed = true;
2845
+ this.clearReconnectTimer();
2846
+ for (const [id, pending] of this.pending) {
2847
+ clearTimeout(pending.timer);
2848
+ pending.resolve({
2849
+ id,
2850
+ ok: false,
2851
+ error: {
2852
+ code: "CLIENT_STOPPED",
2853
+ message: "IPC client stopped"
2854
+ }
2855
+ });
2856
+ }
2857
+ this.pending.clear();
2858
+ if (this.socket) {
2859
+ try {
2860
+ this.socket.end();
2861
+ } catch {}
2862
+ this.socket = null;
2863
+ }
2864
+ this._connected = false;
2865
+ }
2866
+ /**
2867
+ * Send a request to the daemon and wait for a response.
2868
+ */
2869
+ async request(method, params = {}, timeoutMs = DEFAULT_REQUEST_TIMEOUT_MS) {
2870
+ if (!this._connected || !this.socket) return {
2871
+ id: "",
2872
+ ok: false,
2873
+ error: {
2874
+ code: "NOT_CONNECTED",
2875
+ message: "Not connected to daemon"
2876
+ }
2877
+ };
2878
+ const id = (0, node_crypto.randomUUID)();
2879
+ const request = {
2880
+ type: "req",
2881
+ id,
2882
+ method,
2883
+ params
2884
+ };
2885
+ return new Promise((resolve) => {
2886
+ const timer = setTimeout(() => {
2887
+ this.pending.delete(id);
2888
+ resolve({
2889
+ id,
2890
+ ok: false,
2891
+ error: {
2892
+ code: "TIMEOUT",
2893
+ message: `Request ${method} timed out after ${String(timeoutMs)}ms`
2894
+ }
2895
+ });
2896
+ }, timeoutMs);
2897
+ this.pending.set(id, {
2898
+ resolve,
2899
+ timer
2900
+ });
2901
+ try {
2902
+ const socket = this.socket;
2903
+ if (socket) socket.write(JSON.stringify(request) + "\n");
2904
+ } catch (err) {
2905
+ clearTimeout(timer);
2906
+ this.pending.delete(id);
2907
+ resolve({
2908
+ id,
2909
+ ok: false,
2910
+ error: {
2911
+ code: "SEND_FAILED",
2912
+ message: `Failed to send: ${err instanceof Error ? err.message : String(err)}`
2913
+ }
2914
+ });
2915
+ }
2916
+ });
2917
+ }
2918
+ /**
2919
+ * Send a response to a daemon request.
2920
+ * Used internally by the request event handler.
2921
+ */
2922
+ sendResponse(response) {
2923
+ if (!this._connected || !this.socket) return;
2924
+ try {
2925
+ this.socket.write(JSON.stringify(response) + "\n");
2926
+ } catch {}
2927
+ }
2928
+ doConnect() {
2929
+ if (this.closed) return;
2930
+ this.log.debug(`Connecting to daemon at ${this.socketPath}...`);
2931
+ this.socket = (0, node_net.createConnection)(this.socketPath, () => {
2932
+ this.log.info(`Connected to daemon (${this.socketPath})`);
2933
+ this._connected = true;
2934
+ this.backoffMs = MIN_BACKOFF_MS;
2935
+ this.buffer = "";
2936
+ this.emit("connected");
2937
+ });
2938
+ this.socket.on("data", (data) => {
2939
+ this.buffer += data.toString();
2940
+ this.processBuffer();
2941
+ });
2942
+ this.socket.on("close", () => {
2943
+ const wasConnected = this._connected;
2944
+ this._connected = false;
2945
+ for (const [id, pending] of this.pending) {
2946
+ clearTimeout(pending.timer);
2947
+ pending.resolve({
2948
+ id,
2949
+ ok: false,
2950
+ error: {
2951
+ code: "DISCONNECTED",
2952
+ message: "Connection closed"
2953
+ }
2954
+ });
2955
+ }
2956
+ this.pending.clear();
2957
+ if (wasConnected) {
2958
+ this.log.warn("Disconnected from daemon");
2959
+ this.emit("disconnected", "connection closed");
2960
+ }
2961
+ this.scheduleReconnect();
2962
+ });
2963
+ this.socket.on("error", (err) => {
2964
+ if (err.code === "ECONNREFUSED" || err.code === "ENOENT" || err.code === "ECONNRESET") this.log.debug(`Daemon not available: ${err.code}`);
2965
+ else {
2966
+ this.log.error(`IPC socket error: ${err.message}`);
2967
+ this.emit("error", err);
2968
+ }
2969
+ });
2970
+ }
2971
+ processBuffer() {
2972
+ let newlineIdx;
2973
+ while ((newlineIdx = this.buffer.indexOf("\n")) !== -1) {
2974
+ const line = this.buffer.slice(0, newlineIdx).trim();
2975
+ this.buffer = this.buffer.slice(newlineIdx + 1);
2976
+ if (!line) continue;
2977
+ let parsed;
2978
+ try {
2979
+ parsed = JSON.parse(line);
2980
+ } catch {
2981
+ this.log.warn("Received invalid JSON from daemon");
2982
+ continue;
2983
+ }
2984
+ if (isIPCResponse(parsed)) {
2985
+ this.handleResponse(parsed);
2986
+ continue;
2987
+ }
2988
+ if (isIPCEvent(parsed)) {
2989
+ this.emit("event", parsed.event, parsed.payload);
2990
+ continue;
2991
+ }
2992
+ if (isIPCRequest(parsed)) {
2993
+ this.handleIncomingRequest(parsed);
2994
+ continue;
2995
+ }
2996
+ this.log.debug({ msg: parsed }, "Unhandled message from daemon");
2997
+ }
2998
+ }
2999
+ handleResponse(response) {
3000
+ const pending = this.pending.get(response.id);
3001
+ if (!pending) return;
3002
+ clearTimeout(pending.timer);
3003
+ this.pending.delete(response.id);
3004
+ pending.resolve(response);
3005
+ }
3006
+ handleIncomingRequest(request) {
3007
+ const respond = (partial) => {
3008
+ const response = {
3009
+ id: request.id,
3010
+ ...partial
3011
+ };
3012
+ this.sendResponse(response);
3013
+ };
3014
+ this.emit("request", request.method, request.params, respond);
3015
+ }
3016
+ scheduleReconnect() {
3017
+ if (this.closed) return;
3018
+ this.clearReconnectTimer();
3019
+ const delay = this.backoffMs;
3020
+ this.backoffMs = Math.min(this.backoffMs * 2, MAX_BACKOFF_MS);
3021
+ this.log.debug(`Reconnecting in ${String(delay)}ms...`);
3022
+ this.reconnectTimer = setTimeout(() => {
3023
+ this.doConnect();
3024
+ }, delay);
3025
+ }
3026
+ clearReconnectTimer() {
3027
+ if (this.reconnectTimer) {
3028
+ clearTimeout(this.reconnectTimer);
3029
+ this.reconnectTimer = null;
3030
+ }
3031
+ }
3032
+ };
3033
+ //#endregion
3034
+ //#region src/capability-reporter.ts
3035
+ const PLUGIN_VERSION = "0.1.0";
3036
+ const OPENCLAW_CAPABILITIES = [
3037
+ "sessions",
3038
+ "tools",
3039
+ "plugins"
3040
+ ];
3041
+ /**
3042
+ * Register this OpenClaw plugin with the daemon.
3043
+ * Should be called on every (re)connect.
3044
+ *
3045
+ * @returns Registration result or null on failure
3046
+ */
3047
+ async function registerWithDaemon(client, log) {
3048
+ const response = await client.request("register", {
3049
+ framework: "openclaw",
3050
+ name: "@alfe.ai/openclaw",
3051
+ version: PLUGIN_VERSION,
3052
+ protocolVersion: 1,
3053
+ capabilities: [...OPENCLAW_CAPABILITIES],
3054
+ pid: process.pid
3055
+ });
3056
+ if (!response.ok) {
3057
+ const err = response.error;
3058
+ if (err?.code === "PROTOCOL_MISMATCH") {
3059
+ log.error(`Daemon protocol version mismatch: ${err.message}`);
3060
+ log.error("Update @alfe.ai/openclaw or the daemon to a compatible version.");
3061
+ } else log.error(`Registration failed: ${err?.message ?? "unknown error"}`);
3062
+ return null;
3063
+ }
3064
+ const result = response.payload;
3065
+ log.info(`Registered with daemon v${result.daemonVersion} (protocol v${String(result.protocolVersion)})`);
3066
+ return result;
3067
+ }
3068
+ //#endregion
3069
+ //#region src/plugin.ts
3070
+ /**
3071
+ * @alfe.ai/openclaw — OpenClaw plugin for Alfe.
3072
+ *
3073
+ * Connects to the local Alfe gateway daemon via IPC socket and:
3074
+ * 1. Registers OpenClaw capabilities with the daemon on connect
3075
+ * 2. Handles incoming requests from the daemon
3076
+ * 3. Re-registers on reconnect (daemon may restart)
3077
+ * 4. Gracefully handles daemon being unavailable
3078
+ *
3079
+ * Follows the same plugin pattern as @alfe.ai/openclaw-voice.
3080
+ */
3081
+ const DEFAULT_SOCKET_PATH = (0, node_path.join)((0, node_os.homedir)(), ".alfe", "gateway.sock");
3082
+ let ipcClient = null;
3083
+ function ok(result) {
3084
+ return { content: [{
3085
+ type: "text",
3086
+ text: JSON.stringify(result)
3087
+ }] };
3088
+ }
3089
+ function errResult(message) {
3090
+ return { content: [{
3091
+ type: "text",
3092
+ text: JSON.stringify({ error: message })
3093
+ }] };
3094
+ }
3095
+ function defineTool(def) {
3096
+ return {
3097
+ name: def.name,
3098
+ description: def.description,
3099
+ label: def.name,
3100
+ parameters: def.parameters,
3101
+ execute: async (_toolCallId, params) => {
3102
+ try {
3103
+ return ok(await def.handler(params));
3104
+ } catch (e) {
3105
+ return errResult(e.message);
3106
+ }
3107
+ }
3108
+ };
3109
+ }
3110
+ function buildIntegrationTools(client) {
3111
+ return [
3112
+ defineTool({
3113
+ name: "list_integrations",
3114
+ description: "List all integrations installed for this agent, including their status and available config fields.",
3115
+ parameters: Type.Object({}),
3116
+ handler: async () => client.listIntegrations()
3117
+ }),
3118
+ defineTool({
3119
+ name: "get_integration_config",
3120
+ description: "Get the current configuration and editable fields for a specific integration.",
3121
+ parameters: Type.Object({ integrationId: Type.String({ description: "The integration to inspect (e.g. \"voice\", \"slack\")" }) }),
3122
+ handler: async (params) => {
3123
+ const integrationId = params.integrationId;
3124
+ return client.getIntegrationConfig(integrationId);
3125
+ }
3126
+ }),
3127
+ defineTool({
3128
+ name: "update_integration_config",
3129
+ description: "Update configuration for an installed integration. Only agent-editable fields can be changed.",
3130
+ parameters: Type.Object({
3131
+ integrationId: Type.String({ description: "The integration to update" }),
3132
+ fields: Type.Record(Type.String(), Type.Unknown(), { description: "Key-value pairs of config fields to update" })
3133
+ }),
3134
+ handler: async (params) => {
3135
+ const integrationId = params.integrationId;
3136
+ const fields = params.fields;
3137
+ return client.updateIntegrationConfig(integrationId, fields);
3138
+ }
3139
+ }),
3140
+ defineTool({
3141
+ name: "install_integration",
3142
+ description: "Install an integration from the registry. Returns the newly created integration record.",
3143
+ parameters: Type.Object({
3144
+ integrationId: Type.String({ description: "The integration to install (e.g. \"voice\", \"slack\", \"discord\")" }),
3145
+ version: Type.Optional(Type.String({ description: "Specific version to install (defaults to latest)" })),
3146
+ config: Type.Optional(Type.Record(Type.String(), Type.Unknown(), { description: "Initial configuration key-value pairs" }))
3147
+ }),
3148
+ handler: async (params) => {
3149
+ const integrationId = params.integrationId;
3150
+ const version = params.version;
3151
+ const config = params.config;
3152
+ return client.installIntegration(integrationId, {
3153
+ version,
3154
+ config
3155
+ });
3156
+ }
3157
+ }),
3158
+ defineTool({
3159
+ name: "remove_integration",
3160
+ description: "Remove an installed integration. The daemon will handle teardown during reconciliation.",
3161
+ parameters: Type.Object({ integrationId: Type.String({ description: "The integration to remove" }) }),
3162
+ handler: async (params) => {
3163
+ const integrationId = params.integrationId;
3164
+ return client.removeIntegration(integrationId);
3165
+ }
3166
+ }),
3167
+ defineTool({
3168
+ name: "browse_integration_registry",
3169
+ description: "Browse available integrations in the registry. Shows all integrations that can be installed.",
3170
+ parameters: Type.Object({}),
3171
+ handler: async () => client.getRegistry()
3172
+ })
3173
+ ];
3174
+ }
3175
+ const plugin = {
3176
+ id: "@alfe.ai/openclaw",
3177
+ name: "Alfe OpenClaw Plugin",
3178
+ description: "Connects OpenClaw to the local Alfe gateway daemon",
3179
+ version: "0.1.0",
3180
+ activate(api) {
3181
+ const log = api.logger;
3182
+ log.info("Alfe OpenClaw Plugin activating...");
3183
+ const socketPath = ((api.config ?? {}).plugins?.entries?.["@alfe.ai/openclaw"]?.config ?? {}).socketPath ?? process.env.ALFE_GATEWAY_SOCKET ?? DEFAULT_SOCKET_PATH;
3184
+ let cfg = null;
3185
+ try {
3186
+ cfg = (0, _alfe_ai_config.resolveConfig)();
3187
+ } catch (err) {
3188
+ log.warn(`Integration tools not registered — config not available: ${err.message}`);
3189
+ }
3190
+ if (cfg) {
3191
+ const tools = buildIntegrationTools(new _alfe_ai_agent_api_client.AgentApiClient({
3192
+ apiKey: cfg.apiKey,
3193
+ apiUrl: cfg.apiUrl
3194
+ }));
3195
+ for (const tool of tools) api.registerTool(tool);
3196
+ log.info(`Registered ${String(tools.length)} integration tools: ${tools.map((t) => t.name).join(", ")}`);
3197
+ }
3198
+ ipcClient = new IPCClient(socketPath);
3199
+ ipcClient.on("event", (event, payload) => {
3200
+ switch (event) {
3201
+ case "cloud.status": {
3202
+ const status = payload;
3203
+ log.info(`Alfe cloud: ${status.connected ? "connected" : "disconnected"}`);
3204
+ break;
3205
+ }
3206
+ case "daemon.shutdown":
3207
+ log.info("Daemon shutting down — will reconnect when available");
3208
+ break;
3209
+ default: log.debug(`Daemon event: ${event}`, payload);
3210
+ }
3211
+ });
3212
+ ipcClient.on("request", (method, _params, respond) => {
3213
+ log.info(`Daemon request: ${method}`);
3214
+ respond({
3215
+ ok: false,
3216
+ error: {
3217
+ code: "UNKNOWN_METHOD",
3218
+ message: `Plugin does not handle method: ${method}`
3219
+ }
3220
+ });
3221
+ });
3222
+ const client = ipcClient;
3223
+ ipcClient.on("connected", () => {
3224
+ log.info("Connected to Alfe daemon — registering capabilities...");
3225
+ registerWithDaemon(client, log).then((result) => {
3226
+ if (!result) log.error("Failed to register with daemon — commands may not be routed");
3227
+ });
3228
+ });
3229
+ ipcClient.on("disconnected", (reason) => {
3230
+ log.warn(`Disconnected from Alfe daemon: ${reason}`);
3231
+ });
3232
+ ipcClient.on("error", (err) => {
3233
+ log.error(`IPC error: ${err.message}`);
3234
+ });
3235
+ ipcClient.start();
3236
+ log.info(`Alfe OpenClaw Plugin activated (socket: ${socketPath})`);
3237
+ },
3238
+ deactivate(api) {
3239
+ const log = api.logger;
3240
+ log.info("Alfe OpenClaw Plugin deactivating...");
3241
+ if (ipcClient) {
3242
+ ipcClient.stop();
3243
+ ipcClient = null;
3244
+ }
3245
+ log.info("Alfe OpenClaw Plugin deactivated");
3246
+ }
3247
+ };
3248
+ //#endregion
3249
+ Object.defineProperty(exports, "IPCClient", {
3250
+ enumerable: true,
3251
+ get: function() {
3252
+ return IPCClient;
3253
+ }
3254
+ });
3255
+ Object.defineProperty(exports, "PROTOCOL_VERSION", {
3256
+ enumerable: true,
3257
+ get: function() {
3258
+ return PROTOCOL_VERSION;
3259
+ }
3260
+ });
3261
+ Object.defineProperty(exports, "__commonJSMin", {
3262
+ enumerable: true,
3263
+ get: function() {
3264
+ return __commonJSMin;
3265
+ }
3266
+ });
3267
+ Object.defineProperty(exports, "__toESM", {
3268
+ enumerable: true,
3269
+ get: function() {
3270
+ return __toESM;
3271
+ }
3272
+ });
3273
+ Object.defineProperty(exports, "isIPCEvent", {
3274
+ enumerable: true,
3275
+ get: function() {
3276
+ return isIPCEvent;
3277
+ }
3278
+ });
3279
+ Object.defineProperty(exports, "isIPCRequest", {
3280
+ enumerable: true,
3281
+ get: function() {
3282
+ return isIPCRequest;
3283
+ }
3284
+ });
3285
+ Object.defineProperty(exports, "isIPCResponse", {
3286
+ enumerable: true,
3287
+ get: function() {
3288
+ return isIPCResponse;
3289
+ }
3290
+ });
3291
+ Object.defineProperty(exports, "plugin", {
3292
+ enumerable: true,
3293
+ get: function() {
3294
+ return plugin;
3295
+ }
3296
+ });
3297
+ Object.defineProperty(exports, "registerWithDaemon", {
3298
+ enumerable: true,
3299
+ get: function() {
3300
+ return registerWithDaemon;
3301
+ }
3302
+ });