@betternotify/discord 0.0.2-alpha.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js ADDED
@@ -0,0 +1,2553 @@
1
+ import { NotifyRpcProviderError, consoleLogger, defineChannel, slot } from "@betternotify/core";
2
+ import { createHttpClient, createMockTransport, createTransport } from "@betternotify/core/transports";
3
+ Object.freeze({ status: "aborted" });
4
+ function $constructor(name, initializer, params) {
5
+ function init(inst, def) {
6
+ if (!inst._zod) Object.defineProperty(inst, "_zod", {
7
+ value: {
8
+ def,
9
+ constr: _,
10
+ traits: /* @__PURE__ */ new Set()
11
+ },
12
+ enumerable: false
13
+ });
14
+ if (inst._zod.traits.has(name)) return;
15
+ inst._zod.traits.add(name);
16
+ initializer(inst, def);
17
+ const proto = _.prototype;
18
+ const keys = Object.keys(proto);
19
+ for (let i = 0; i < keys.length; i++) {
20
+ const k = keys[i];
21
+ if (!(k in inst)) inst[k] = proto[k].bind(inst);
22
+ }
23
+ }
24
+ const Parent = params?.Parent ?? Object;
25
+ class Definition extends Parent {}
26
+ Object.defineProperty(Definition, "name", { value: name });
27
+ function _(def) {
28
+ var _a;
29
+ const inst = params?.Parent ? new Definition() : this;
30
+ init(inst, def);
31
+ (_a = inst._zod).deferred ?? (_a.deferred = []);
32
+ for (const fn of inst._zod.deferred) fn();
33
+ return inst;
34
+ }
35
+ Object.defineProperty(_, "init", { value: init });
36
+ Object.defineProperty(_, Symbol.hasInstance, { value: (inst) => {
37
+ if (params?.Parent && inst instanceof params.Parent) return true;
38
+ return inst?._zod?.traits?.has(name);
39
+ } });
40
+ Object.defineProperty(_, "name", { value: name });
41
+ return _;
42
+ }
43
+ var $ZodAsyncError = class extends Error {
44
+ constructor() {
45
+ super(`Encountered Promise during synchronous parse. Use .parseAsync() instead.`);
46
+ }
47
+ };
48
+ var $ZodEncodeError = class extends Error {
49
+ constructor(name) {
50
+ super(`Encountered unidirectional transform during encode: ${name}`);
51
+ this.name = "ZodEncodeError";
52
+ }
53
+ };
54
+ const globalConfig = {};
55
+ function config(newConfig) {
56
+ if (newConfig) Object.assign(globalConfig, newConfig);
57
+ return globalConfig;
58
+ }
59
+ //#endregion
60
+ //#region ../../node_modules/.pnpm/zod@4.3.6/node_modules/zod/v4/core/util.js
61
+ function getEnumValues(entries) {
62
+ const numericValues = Object.values(entries).filter((v) => typeof v === "number");
63
+ return Object.entries(entries).filter(([k, _]) => numericValues.indexOf(+k) === -1).map(([_, v]) => v);
64
+ }
65
+ function jsonStringifyReplacer(_, value) {
66
+ if (typeof value === "bigint") return value.toString();
67
+ return value;
68
+ }
69
+ function cached(getter) {
70
+ return { get value() {
71
+ {
72
+ const value = getter();
73
+ Object.defineProperty(this, "value", { value });
74
+ return value;
75
+ }
76
+ throw new Error("cached value already set");
77
+ } };
78
+ }
79
+ function nullish(input) {
80
+ return input === null || input === void 0;
81
+ }
82
+ function cleanRegex(source) {
83
+ const start = source.startsWith("^") ? 1 : 0;
84
+ const end = source.endsWith("$") ? source.length - 1 : source.length;
85
+ return source.slice(start, end);
86
+ }
87
+ const EVALUATING = Symbol("evaluating");
88
+ function defineLazy(object, key, getter) {
89
+ let value = void 0;
90
+ Object.defineProperty(object, key, {
91
+ get() {
92
+ if (value === EVALUATING) return;
93
+ if (value === void 0) {
94
+ value = EVALUATING;
95
+ value = getter();
96
+ }
97
+ return value;
98
+ },
99
+ set(v) {
100
+ Object.defineProperty(object, key, { value: v });
101
+ },
102
+ configurable: true
103
+ });
104
+ }
105
+ function assignProp(target, prop, value) {
106
+ Object.defineProperty(target, prop, {
107
+ value,
108
+ writable: true,
109
+ enumerable: true,
110
+ configurable: true
111
+ });
112
+ }
113
+ function mergeDefs(...defs) {
114
+ const mergedDescriptors = {};
115
+ for (const def of defs) Object.assign(mergedDescriptors, Object.getOwnPropertyDescriptors(def));
116
+ return Object.defineProperties({}, mergedDescriptors);
117
+ }
118
+ function esc(str) {
119
+ return JSON.stringify(str);
120
+ }
121
+ const captureStackTrace = "captureStackTrace" in Error ? Error.captureStackTrace : (..._args) => {};
122
+ function isObject(data) {
123
+ return typeof data === "object" && data !== null && !Array.isArray(data);
124
+ }
125
+ const allowsEval = cached(() => {
126
+ if (typeof navigator !== "undefined" && navigator?.userAgent?.includes("Cloudflare")) return false;
127
+ try {
128
+ new Function("");
129
+ return true;
130
+ } catch (_) {
131
+ return false;
132
+ }
133
+ });
134
+ function isPlainObject(o) {
135
+ if (isObject(o) === false) return false;
136
+ const ctor = o.constructor;
137
+ if (ctor === void 0) return true;
138
+ if (typeof ctor !== "function") return true;
139
+ const prot = ctor.prototype;
140
+ if (isObject(prot) === false) return false;
141
+ if (Object.prototype.hasOwnProperty.call(prot, "isPrototypeOf") === false) return false;
142
+ return true;
143
+ }
144
+ function shallowClone(o) {
145
+ if (isPlainObject(o)) return { ...o };
146
+ if (Array.isArray(o)) return [...o];
147
+ return o;
148
+ }
149
+ const propertyKeyTypes = new Set([
150
+ "string",
151
+ "number",
152
+ "symbol"
153
+ ]);
154
+ function escapeRegex(str) {
155
+ return str.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
156
+ }
157
+ function clone(inst, def, params) {
158
+ const cl = new inst._zod.constr(def ?? inst._zod.def);
159
+ if (!def || params?.parent) cl._zod.parent = inst;
160
+ return cl;
161
+ }
162
+ function normalizeParams(_params) {
163
+ const params = _params;
164
+ if (!params) return {};
165
+ if (typeof params === "string") return { error: () => params };
166
+ if (params?.message !== void 0) {
167
+ if (params?.error !== void 0) throw new Error("Cannot specify both `message` and `error` params");
168
+ params.error = params.message;
169
+ }
170
+ delete params.message;
171
+ if (typeof params.error === "string") return {
172
+ ...params,
173
+ error: () => params.error
174
+ };
175
+ return params;
176
+ }
177
+ function optionalKeys(shape) {
178
+ return Object.keys(shape).filter((k) => {
179
+ return shape[k]._zod.optin === "optional" && shape[k]._zod.optout === "optional";
180
+ });
181
+ }
182
+ Number.MIN_SAFE_INTEGER, Number.MAX_SAFE_INTEGER, -Number.MAX_VALUE, Number.MAX_VALUE;
183
+ function pick(schema, mask) {
184
+ const currDef = schema._zod.def;
185
+ const checks = currDef.checks;
186
+ if (checks && checks.length > 0) throw new Error(".pick() cannot be used on object schemas containing refinements");
187
+ return clone(schema, mergeDefs(schema._zod.def, {
188
+ get shape() {
189
+ const newShape = {};
190
+ for (const key in mask) {
191
+ if (!(key in currDef.shape)) throw new Error(`Unrecognized key: "${key}"`);
192
+ if (!mask[key]) continue;
193
+ newShape[key] = currDef.shape[key];
194
+ }
195
+ assignProp(this, "shape", newShape);
196
+ return newShape;
197
+ },
198
+ checks: []
199
+ }));
200
+ }
201
+ function omit(schema, mask) {
202
+ const currDef = schema._zod.def;
203
+ const checks = currDef.checks;
204
+ if (checks && checks.length > 0) throw new Error(".omit() cannot be used on object schemas containing refinements");
205
+ return clone(schema, mergeDefs(schema._zod.def, {
206
+ get shape() {
207
+ const newShape = { ...schema._zod.def.shape };
208
+ for (const key in mask) {
209
+ if (!(key in currDef.shape)) throw new Error(`Unrecognized key: "${key}"`);
210
+ if (!mask[key]) continue;
211
+ delete newShape[key];
212
+ }
213
+ assignProp(this, "shape", newShape);
214
+ return newShape;
215
+ },
216
+ checks: []
217
+ }));
218
+ }
219
+ function extend(schema, shape) {
220
+ if (!isPlainObject(shape)) throw new Error("Invalid input to extend: expected a plain object");
221
+ const checks = schema._zod.def.checks;
222
+ if (checks && checks.length > 0) {
223
+ const existingShape = schema._zod.def.shape;
224
+ for (const key in shape) if (Object.getOwnPropertyDescriptor(existingShape, key) !== void 0) throw new Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.");
225
+ }
226
+ return clone(schema, mergeDefs(schema._zod.def, { get shape() {
227
+ const _shape = {
228
+ ...schema._zod.def.shape,
229
+ ...shape
230
+ };
231
+ assignProp(this, "shape", _shape);
232
+ return _shape;
233
+ } }));
234
+ }
235
+ function safeExtend(schema, shape) {
236
+ if (!isPlainObject(shape)) throw new Error("Invalid input to safeExtend: expected a plain object");
237
+ return clone(schema, mergeDefs(schema._zod.def, { get shape() {
238
+ const _shape = {
239
+ ...schema._zod.def.shape,
240
+ ...shape
241
+ };
242
+ assignProp(this, "shape", _shape);
243
+ return _shape;
244
+ } }));
245
+ }
246
+ function merge(a, b) {
247
+ return clone(a, mergeDefs(a._zod.def, {
248
+ get shape() {
249
+ const _shape = {
250
+ ...a._zod.def.shape,
251
+ ...b._zod.def.shape
252
+ };
253
+ assignProp(this, "shape", _shape);
254
+ return _shape;
255
+ },
256
+ get catchall() {
257
+ return b._zod.def.catchall;
258
+ },
259
+ checks: []
260
+ }));
261
+ }
262
+ function partial(Class, schema, mask) {
263
+ const checks = schema._zod.def.checks;
264
+ if (checks && checks.length > 0) throw new Error(".partial() cannot be used on object schemas containing refinements");
265
+ return clone(schema, mergeDefs(schema._zod.def, {
266
+ get shape() {
267
+ const oldShape = schema._zod.def.shape;
268
+ const shape = { ...oldShape };
269
+ if (mask) for (const key in mask) {
270
+ if (!(key in oldShape)) throw new Error(`Unrecognized key: "${key}"`);
271
+ if (!mask[key]) continue;
272
+ shape[key] = Class ? new Class({
273
+ type: "optional",
274
+ innerType: oldShape[key]
275
+ }) : oldShape[key];
276
+ }
277
+ else for (const key in oldShape) shape[key] = Class ? new Class({
278
+ type: "optional",
279
+ innerType: oldShape[key]
280
+ }) : oldShape[key];
281
+ assignProp(this, "shape", shape);
282
+ return shape;
283
+ },
284
+ checks: []
285
+ }));
286
+ }
287
+ function required(Class, schema, mask) {
288
+ return clone(schema, mergeDefs(schema._zod.def, { get shape() {
289
+ const oldShape = schema._zod.def.shape;
290
+ const shape = { ...oldShape };
291
+ if (mask) for (const key in mask) {
292
+ if (!(key in shape)) throw new Error(`Unrecognized key: "${key}"`);
293
+ if (!mask[key]) continue;
294
+ shape[key] = new Class({
295
+ type: "nonoptional",
296
+ innerType: oldShape[key]
297
+ });
298
+ }
299
+ else for (const key in oldShape) shape[key] = new Class({
300
+ type: "nonoptional",
301
+ innerType: oldShape[key]
302
+ });
303
+ assignProp(this, "shape", shape);
304
+ return shape;
305
+ } }));
306
+ }
307
+ function aborted(x, startIndex = 0) {
308
+ if (x.aborted === true) return true;
309
+ for (let i = startIndex; i < x.issues.length; i++) if (x.issues[i]?.continue !== true) return true;
310
+ return false;
311
+ }
312
+ function prefixIssues(path, issues) {
313
+ return issues.map((iss) => {
314
+ var _a;
315
+ (_a = iss).path ?? (_a.path = []);
316
+ iss.path.unshift(path);
317
+ return iss;
318
+ });
319
+ }
320
+ function unwrapMessage(message) {
321
+ return typeof message === "string" ? message : message?.message;
322
+ }
323
+ function finalizeIssue(iss, ctx, config) {
324
+ const full = {
325
+ ...iss,
326
+ path: iss.path ?? []
327
+ };
328
+ if (!iss.message) full.message = unwrapMessage(iss.inst?._zod.def?.error?.(iss)) ?? unwrapMessage(ctx?.error?.(iss)) ?? unwrapMessage(config.customError?.(iss)) ?? unwrapMessage(config.localeError?.(iss)) ?? "Invalid input";
329
+ delete full.inst;
330
+ delete full.continue;
331
+ if (!ctx?.reportInput) delete full.input;
332
+ return full;
333
+ }
334
+ function getLengthableOrigin(input) {
335
+ if (Array.isArray(input)) return "array";
336
+ if (typeof input === "string") return "string";
337
+ return "unknown";
338
+ }
339
+ function issue(...args) {
340
+ const [iss, input, inst] = args;
341
+ if (typeof iss === "string") return {
342
+ message: iss,
343
+ code: "custom",
344
+ input,
345
+ inst
346
+ };
347
+ return { ...iss };
348
+ }
349
+ //#endregion
350
+ //#region ../../node_modules/.pnpm/zod@4.3.6/node_modules/zod/v4/core/errors.js
351
+ const initializer$1 = (inst, def) => {
352
+ inst.name = "$ZodError";
353
+ Object.defineProperty(inst, "_zod", {
354
+ value: inst._zod,
355
+ enumerable: false
356
+ });
357
+ Object.defineProperty(inst, "issues", {
358
+ value: def,
359
+ enumerable: false
360
+ });
361
+ inst.message = JSON.stringify(def, jsonStringifyReplacer, 2);
362
+ Object.defineProperty(inst, "toString", {
363
+ value: () => inst.message,
364
+ enumerable: false
365
+ });
366
+ };
367
+ const $ZodError = $constructor("$ZodError", initializer$1);
368
+ const $ZodRealError = $constructor("$ZodError", initializer$1, { Parent: Error });
369
+ function flattenError(error, mapper = (issue) => issue.message) {
370
+ const fieldErrors = {};
371
+ const formErrors = [];
372
+ for (const sub of error.issues) if (sub.path.length > 0) {
373
+ fieldErrors[sub.path[0]] = fieldErrors[sub.path[0]] || [];
374
+ fieldErrors[sub.path[0]].push(mapper(sub));
375
+ } else formErrors.push(mapper(sub));
376
+ return {
377
+ formErrors,
378
+ fieldErrors
379
+ };
380
+ }
381
+ function formatError(error, mapper = (issue) => issue.message) {
382
+ const fieldErrors = { _errors: [] };
383
+ const processError = (error) => {
384
+ for (const issue of error.issues) if (issue.code === "invalid_union" && issue.errors.length) issue.errors.map((issues) => processError({ issues }));
385
+ else if (issue.code === "invalid_key") processError({ issues: issue.issues });
386
+ else if (issue.code === "invalid_element") processError({ issues: issue.issues });
387
+ else if (issue.path.length === 0) fieldErrors._errors.push(mapper(issue));
388
+ else {
389
+ let curr = fieldErrors;
390
+ let i = 0;
391
+ while (i < issue.path.length) {
392
+ const el = issue.path[i];
393
+ if (!(i === issue.path.length - 1)) curr[el] = curr[el] || { _errors: [] };
394
+ else {
395
+ curr[el] = curr[el] || { _errors: [] };
396
+ curr[el]._errors.push(mapper(issue));
397
+ }
398
+ curr = curr[el];
399
+ i++;
400
+ }
401
+ }
402
+ };
403
+ processError(error);
404
+ return fieldErrors;
405
+ }
406
+ //#endregion
407
+ //#region ../../node_modules/.pnpm/zod@4.3.6/node_modules/zod/v4/core/parse.js
408
+ const _parse = (_Err) => (schema, value, _ctx, _params) => {
409
+ const ctx = _ctx ? Object.assign(_ctx, { async: false }) : { async: false };
410
+ const result = schema._zod.run({
411
+ value,
412
+ issues: []
413
+ }, ctx);
414
+ if (result instanceof Promise) throw new $ZodAsyncError();
415
+ if (result.issues.length) {
416
+ const e = new (_params?.Err ?? _Err)(result.issues.map((iss) => finalizeIssue(iss, ctx, config())));
417
+ captureStackTrace(e, _params?.callee);
418
+ throw e;
419
+ }
420
+ return result.value;
421
+ };
422
+ const _parseAsync = (_Err) => async (schema, value, _ctx, params) => {
423
+ const ctx = _ctx ? Object.assign(_ctx, { async: true }) : { async: true };
424
+ let result = schema._zod.run({
425
+ value,
426
+ issues: []
427
+ }, ctx);
428
+ if (result instanceof Promise) result = await result;
429
+ if (result.issues.length) {
430
+ const e = new (params?.Err ?? _Err)(result.issues.map((iss) => finalizeIssue(iss, ctx, config())));
431
+ captureStackTrace(e, params?.callee);
432
+ throw e;
433
+ }
434
+ return result.value;
435
+ };
436
+ const _safeParse = (_Err) => (schema, value, _ctx) => {
437
+ const ctx = _ctx ? {
438
+ ..._ctx,
439
+ async: false
440
+ } : { async: false };
441
+ const result = schema._zod.run({
442
+ value,
443
+ issues: []
444
+ }, ctx);
445
+ if (result instanceof Promise) throw new $ZodAsyncError();
446
+ return result.issues.length ? {
447
+ success: false,
448
+ error: new (_Err ?? $ZodError)(result.issues.map((iss) => finalizeIssue(iss, ctx, config())))
449
+ } : {
450
+ success: true,
451
+ data: result.value
452
+ };
453
+ };
454
+ const safeParse$1 = /* @__PURE__ */ _safeParse($ZodRealError);
455
+ const _safeParseAsync = (_Err) => async (schema, value, _ctx) => {
456
+ const ctx = _ctx ? Object.assign(_ctx, { async: true }) : { async: true };
457
+ let result = schema._zod.run({
458
+ value,
459
+ issues: []
460
+ }, ctx);
461
+ if (result instanceof Promise) result = await result;
462
+ return result.issues.length ? {
463
+ success: false,
464
+ error: new _Err(result.issues.map((iss) => finalizeIssue(iss, ctx, config())))
465
+ } : {
466
+ success: true,
467
+ data: result.value
468
+ };
469
+ };
470
+ const safeParseAsync$1 = /* @__PURE__ */ _safeParseAsync($ZodRealError);
471
+ const _encode = (_Err) => (schema, value, _ctx) => {
472
+ const ctx = _ctx ? Object.assign(_ctx, { direction: "backward" }) : { direction: "backward" };
473
+ return _parse(_Err)(schema, value, ctx);
474
+ };
475
+ const _decode = (_Err) => (schema, value, _ctx) => {
476
+ return _parse(_Err)(schema, value, _ctx);
477
+ };
478
+ const _encodeAsync = (_Err) => async (schema, value, _ctx) => {
479
+ const ctx = _ctx ? Object.assign(_ctx, { direction: "backward" }) : { direction: "backward" };
480
+ return _parseAsync(_Err)(schema, value, ctx);
481
+ };
482
+ const _decodeAsync = (_Err) => async (schema, value, _ctx) => {
483
+ return _parseAsync(_Err)(schema, value, _ctx);
484
+ };
485
+ const _safeEncode = (_Err) => (schema, value, _ctx) => {
486
+ const ctx = _ctx ? Object.assign(_ctx, { direction: "backward" }) : { direction: "backward" };
487
+ return _safeParse(_Err)(schema, value, ctx);
488
+ };
489
+ const _safeDecode = (_Err) => (schema, value, _ctx) => {
490
+ return _safeParse(_Err)(schema, value, _ctx);
491
+ };
492
+ const _safeEncodeAsync = (_Err) => async (schema, value, _ctx) => {
493
+ const ctx = _ctx ? Object.assign(_ctx, { direction: "backward" }) : { direction: "backward" };
494
+ return _safeParseAsync(_Err)(schema, value, ctx);
495
+ };
496
+ const _safeDecodeAsync = (_Err) => async (schema, value, _ctx) => {
497
+ return _safeParseAsync(_Err)(schema, value, _ctx);
498
+ };
499
+ //#endregion
500
+ //#region ../../node_modules/.pnpm/zod@4.3.6/node_modules/zod/v4/core/checks.js
501
+ const $ZodCheck = /* @__PURE__ */ $constructor("$ZodCheck", (inst, def) => {
502
+ var _a;
503
+ inst._zod ?? (inst._zod = {});
504
+ inst._zod.def = def;
505
+ (_a = inst._zod).onattach ?? (_a.onattach = []);
506
+ });
507
+ const $ZodCheckMaxLength = /* @__PURE__ */ $constructor("$ZodCheckMaxLength", (inst, def) => {
508
+ var _a;
509
+ $ZodCheck.init(inst, def);
510
+ (_a = inst._zod.def).when ?? (_a.when = (payload) => {
511
+ const val = payload.value;
512
+ return !nullish(val) && val.length !== void 0;
513
+ });
514
+ inst._zod.onattach.push((inst) => {
515
+ const curr = inst._zod.bag.maximum ?? Number.POSITIVE_INFINITY;
516
+ if (def.maximum < curr) inst._zod.bag.maximum = def.maximum;
517
+ });
518
+ inst._zod.check = (payload) => {
519
+ const input = payload.value;
520
+ if (input.length <= def.maximum) return;
521
+ const origin = getLengthableOrigin(input);
522
+ payload.issues.push({
523
+ origin,
524
+ code: "too_big",
525
+ maximum: def.maximum,
526
+ inclusive: true,
527
+ input,
528
+ inst,
529
+ continue: !def.abort
530
+ });
531
+ };
532
+ });
533
+ const $ZodCheckMinLength = /* @__PURE__ */ $constructor("$ZodCheckMinLength", (inst, def) => {
534
+ var _a;
535
+ $ZodCheck.init(inst, def);
536
+ (_a = inst._zod.def).when ?? (_a.when = (payload) => {
537
+ const val = payload.value;
538
+ return !nullish(val) && val.length !== void 0;
539
+ });
540
+ inst._zod.onattach.push((inst) => {
541
+ const curr = inst._zod.bag.minimum ?? Number.NEGATIVE_INFINITY;
542
+ if (def.minimum > curr) inst._zod.bag.minimum = def.minimum;
543
+ });
544
+ inst._zod.check = (payload) => {
545
+ const input = payload.value;
546
+ if (input.length >= def.minimum) return;
547
+ const origin = getLengthableOrigin(input);
548
+ payload.issues.push({
549
+ origin,
550
+ code: "too_small",
551
+ minimum: def.minimum,
552
+ inclusive: true,
553
+ input,
554
+ inst,
555
+ continue: !def.abort
556
+ });
557
+ };
558
+ });
559
+ const $ZodCheckLengthEquals = /* @__PURE__ */ $constructor("$ZodCheckLengthEquals", (inst, def) => {
560
+ var _a;
561
+ $ZodCheck.init(inst, def);
562
+ (_a = inst._zod.def).when ?? (_a.when = (payload) => {
563
+ const val = payload.value;
564
+ return !nullish(val) && val.length !== void 0;
565
+ });
566
+ inst._zod.onattach.push((inst) => {
567
+ const bag = inst._zod.bag;
568
+ bag.minimum = def.length;
569
+ bag.maximum = def.length;
570
+ bag.length = def.length;
571
+ });
572
+ inst._zod.check = (payload) => {
573
+ const input = payload.value;
574
+ const length = input.length;
575
+ if (length === def.length) return;
576
+ const origin = getLengthableOrigin(input);
577
+ const tooBig = length > def.length;
578
+ payload.issues.push({
579
+ origin,
580
+ ...tooBig ? {
581
+ code: "too_big",
582
+ maximum: def.length
583
+ } : {
584
+ code: "too_small",
585
+ minimum: def.length
586
+ },
587
+ inclusive: true,
588
+ exact: true,
589
+ input: payload.value,
590
+ inst,
591
+ continue: !def.abort
592
+ });
593
+ };
594
+ });
595
+ const $ZodCheckOverwrite = /* @__PURE__ */ $constructor("$ZodCheckOverwrite", (inst, def) => {
596
+ $ZodCheck.init(inst, def);
597
+ inst._zod.check = (payload) => {
598
+ payload.value = def.tx(payload.value);
599
+ };
600
+ });
601
+ //#endregion
602
+ //#region ../../node_modules/.pnpm/zod@4.3.6/node_modules/zod/v4/core/doc.js
603
+ var Doc = class {
604
+ constructor(args = []) {
605
+ this.content = [];
606
+ this.indent = 0;
607
+ if (this) this.args = args;
608
+ }
609
+ indented(fn) {
610
+ this.indent += 1;
611
+ fn(this);
612
+ this.indent -= 1;
613
+ }
614
+ write(arg) {
615
+ if (typeof arg === "function") {
616
+ arg(this, { execution: "sync" });
617
+ arg(this, { execution: "async" });
618
+ return;
619
+ }
620
+ const lines = arg.split("\n").filter((x) => x);
621
+ const minIndent = Math.min(...lines.map((x) => x.length - x.trimStart().length));
622
+ const dedented = lines.map((x) => x.slice(minIndent)).map((x) => " ".repeat(this.indent * 2) + x);
623
+ for (const line of dedented) this.content.push(line);
624
+ }
625
+ compile() {
626
+ const F = Function;
627
+ const args = this?.args;
628
+ const lines = [...(this?.content ?? [``]).map((x) => ` ${x}`)];
629
+ return new F(...args, lines.join("\n"));
630
+ }
631
+ };
632
+ //#endregion
633
+ //#region ../../node_modules/.pnpm/zod@4.3.6/node_modules/zod/v4/core/versions.js
634
+ const version = {
635
+ major: 4,
636
+ minor: 3,
637
+ patch: 6
638
+ };
639
+ //#endregion
640
+ //#region ../../node_modules/.pnpm/zod@4.3.6/node_modules/zod/v4/core/schemas.js
641
+ const $ZodType = /* @__PURE__ */ $constructor("$ZodType", (inst, def) => {
642
+ var _a;
643
+ inst ?? (inst = {});
644
+ inst._zod.def = def;
645
+ inst._zod.bag = inst._zod.bag || {};
646
+ inst._zod.version = version;
647
+ const checks = [...inst._zod.def.checks ?? []];
648
+ if (inst._zod.traits.has("$ZodCheck")) checks.unshift(inst);
649
+ for (const ch of checks) for (const fn of ch._zod.onattach) fn(inst);
650
+ if (checks.length === 0) {
651
+ (_a = inst._zod).deferred ?? (_a.deferred = []);
652
+ inst._zod.deferred?.push(() => {
653
+ inst._zod.run = inst._zod.parse;
654
+ });
655
+ } else {
656
+ const runChecks = (payload, checks, ctx) => {
657
+ let isAborted = aborted(payload);
658
+ let asyncResult;
659
+ for (const ch of checks) {
660
+ if (ch._zod.def.when) {
661
+ if (!ch._zod.def.when(payload)) continue;
662
+ } else if (isAborted) continue;
663
+ const currLen = payload.issues.length;
664
+ const _ = ch._zod.check(payload);
665
+ if (_ instanceof Promise && ctx?.async === false) throw new $ZodAsyncError();
666
+ if (asyncResult || _ instanceof Promise) asyncResult = (asyncResult ?? Promise.resolve()).then(async () => {
667
+ await _;
668
+ if (payload.issues.length === currLen) return;
669
+ if (!isAborted) isAborted = aborted(payload, currLen);
670
+ });
671
+ else {
672
+ if (payload.issues.length === currLen) continue;
673
+ if (!isAborted) isAborted = aborted(payload, currLen);
674
+ }
675
+ }
676
+ if (asyncResult) return asyncResult.then(() => {
677
+ return payload;
678
+ });
679
+ return payload;
680
+ };
681
+ const handleCanaryResult = (canary, payload, ctx) => {
682
+ if (aborted(canary)) {
683
+ canary.aborted = true;
684
+ return canary;
685
+ }
686
+ const checkResult = runChecks(payload, checks, ctx);
687
+ if (checkResult instanceof Promise) {
688
+ if (ctx.async === false) throw new $ZodAsyncError();
689
+ return checkResult.then((checkResult) => inst._zod.parse(checkResult, ctx));
690
+ }
691
+ return inst._zod.parse(checkResult, ctx);
692
+ };
693
+ inst._zod.run = (payload, ctx) => {
694
+ if (ctx.skipChecks) return inst._zod.parse(payload, ctx);
695
+ if (ctx.direction === "backward") {
696
+ const canary = inst._zod.parse({
697
+ value: payload.value,
698
+ issues: []
699
+ }, {
700
+ ...ctx,
701
+ skipChecks: true
702
+ });
703
+ if (canary instanceof Promise) return canary.then((canary) => {
704
+ return handleCanaryResult(canary, payload, ctx);
705
+ });
706
+ return handleCanaryResult(canary, payload, ctx);
707
+ }
708
+ const result = inst._zod.parse(payload, ctx);
709
+ if (result instanceof Promise) {
710
+ if (ctx.async === false) throw new $ZodAsyncError();
711
+ return result.then((result) => runChecks(result, checks, ctx));
712
+ }
713
+ return runChecks(result, checks, ctx);
714
+ };
715
+ }
716
+ defineLazy(inst, "~standard", () => ({
717
+ validate: (value) => {
718
+ try {
719
+ const r = safeParse$1(inst, value);
720
+ return r.success ? { value: r.data } : { issues: r.error?.issues };
721
+ } catch (_) {
722
+ return safeParseAsync$1(inst, value).then((r) => r.success ? { value: r.data } : { issues: r.error?.issues });
723
+ }
724
+ },
725
+ vendor: "zod",
726
+ version: 1
727
+ }));
728
+ });
729
+ const $ZodUnknown = /* @__PURE__ */ $constructor("$ZodUnknown", (inst, def) => {
730
+ $ZodType.init(inst, def);
731
+ inst._zod.parse = (payload) => payload;
732
+ });
733
+ const $ZodNever = /* @__PURE__ */ $constructor("$ZodNever", (inst, def) => {
734
+ $ZodType.init(inst, def);
735
+ inst._zod.parse = (payload, _ctx) => {
736
+ payload.issues.push({
737
+ expected: "never",
738
+ code: "invalid_type",
739
+ input: payload.value,
740
+ inst
741
+ });
742
+ return payload;
743
+ };
744
+ });
745
+ function handleArrayResult(result, final, index) {
746
+ if (result.issues.length) final.issues.push(...prefixIssues(index, result.issues));
747
+ final.value[index] = result.value;
748
+ }
749
+ const $ZodArray = /* @__PURE__ */ $constructor("$ZodArray", (inst, def) => {
750
+ $ZodType.init(inst, def);
751
+ inst._zod.parse = (payload, ctx) => {
752
+ const input = payload.value;
753
+ if (!Array.isArray(input)) {
754
+ payload.issues.push({
755
+ expected: "array",
756
+ code: "invalid_type",
757
+ input,
758
+ inst
759
+ });
760
+ return payload;
761
+ }
762
+ payload.value = Array(input.length);
763
+ const proms = [];
764
+ for (let i = 0; i < input.length; i++) {
765
+ const item = input[i];
766
+ const result = def.element._zod.run({
767
+ value: item,
768
+ issues: []
769
+ }, ctx);
770
+ if (result instanceof Promise) proms.push(result.then((result) => handleArrayResult(result, payload, i)));
771
+ else handleArrayResult(result, payload, i);
772
+ }
773
+ if (proms.length) return Promise.all(proms).then(() => payload);
774
+ return payload;
775
+ };
776
+ });
777
+ function handlePropertyResult(result, final, key, input, isOptionalOut) {
778
+ if (result.issues.length) {
779
+ if (isOptionalOut && !(key in input)) return;
780
+ final.issues.push(...prefixIssues(key, result.issues));
781
+ }
782
+ if (result.value === void 0) {
783
+ if (key in input) final.value[key] = void 0;
784
+ } else final.value[key] = result.value;
785
+ }
786
+ function normalizeDef(def) {
787
+ const keys = Object.keys(def.shape);
788
+ for (const k of keys) if (!def.shape?.[k]?._zod?.traits?.has("$ZodType")) throw new Error(`Invalid element at key "${k}": expected a Zod schema`);
789
+ const okeys = optionalKeys(def.shape);
790
+ return {
791
+ ...def,
792
+ keys,
793
+ keySet: new Set(keys),
794
+ numKeys: keys.length,
795
+ optionalKeys: new Set(okeys)
796
+ };
797
+ }
798
+ function handleCatchall(proms, input, payload, ctx, def, inst) {
799
+ const unrecognized = [];
800
+ const keySet = def.keySet;
801
+ const _catchall = def.catchall._zod;
802
+ const t = _catchall.def.type;
803
+ const isOptionalOut = _catchall.optout === "optional";
804
+ for (const key in input) {
805
+ if (keySet.has(key)) continue;
806
+ if (t === "never") {
807
+ unrecognized.push(key);
808
+ continue;
809
+ }
810
+ const r = _catchall.run({
811
+ value: input[key],
812
+ issues: []
813
+ }, ctx);
814
+ if (r instanceof Promise) proms.push(r.then((r) => handlePropertyResult(r, payload, key, input, isOptionalOut)));
815
+ else handlePropertyResult(r, payload, key, input, isOptionalOut);
816
+ }
817
+ if (unrecognized.length) payload.issues.push({
818
+ code: "unrecognized_keys",
819
+ keys: unrecognized,
820
+ input,
821
+ inst
822
+ });
823
+ if (!proms.length) return payload;
824
+ return Promise.all(proms).then(() => {
825
+ return payload;
826
+ });
827
+ }
828
+ const $ZodObject = /* @__PURE__ */ $constructor("$ZodObject", (inst, def) => {
829
+ $ZodType.init(inst, def);
830
+ if (!Object.getOwnPropertyDescriptor(def, "shape")?.get) {
831
+ const sh = def.shape;
832
+ Object.defineProperty(def, "shape", { get: () => {
833
+ const newSh = { ...sh };
834
+ Object.defineProperty(def, "shape", { value: newSh });
835
+ return newSh;
836
+ } });
837
+ }
838
+ const _normalized = cached(() => normalizeDef(def));
839
+ defineLazy(inst._zod, "propValues", () => {
840
+ const shape = def.shape;
841
+ const propValues = {};
842
+ for (const key in shape) {
843
+ const field = shape[key]._zod;
844
+ if (field.values) {
845
+ propValues[key] ?? (propValues[key] = /* @__PURE__ */ new Set());
846
+ for (const v of field.values) propValues[key].add(v);
847
+ }
848
+ }
849
+ return propValues;
850
+ });
851
+ const isObject$2 = isObject;
852
+ const catchall = def.catchall;
853
+ let value;
854
+ inst._zod.parse = (payload, ctx) => {
855
+ value ?? (value = _normalized.value);
856
+ const input = payload.value;
857
+ if (!isObject$2(input)) {
858
+ payload.issues.push({
859
+ expected: "object",
860
+ code: "invalid_type",
861
+ input,
862
+ inst
863
+ });
864
+ return payload;
865
+ }
866
+ payload.value = {};
867
+ const proms = [];
868
+ const shape = value.shape;
869
+ for (const key of value.keys) {
870
+ const el = shape[key];
871
+ const isOptionalOut = el._zod.optout === "optional";
872
+ const r = el._zod.run({
873
+ value: input[key],
874
+ issues: []
875
+ }, ctx);
876
+ if (r instanceof Promise) proms.push(r.then((r) => handlePropertyResult(r, payload, key, input, isOptionalOut)));
877
+ else handlePropertyResult(r, payload, key, input, isOptionalOut);
878
+ }
879
+ if (!catchall) return proms.length ? Promise.all(proms).then(() => payload) : payload;
880
+ return handleCatchall(proms, input, payload, ctx, _normalized.value, inst);
881
+ };
882
+ });
883
+ const $ZodObjectJIT = /* @__PURE__ */ $constructor("$ZodObjectJIT", (inst, def) => {
884
+ $ZodObject.init(inst, def);
885
+ const superParse = inst._zod.parse;
886
+ const _normalized = cached(() => normalizeDef(def));
887
+ const generateFastpass = (shape) => {
888
+ const doc = new Doc([
889
+ "shape",
890
+ "payload",
891
+ "ctx"
892
+ ]);
893
+ const normalized = _normalized.value;
894
+ const parseStr = (key) => {
895
+ const k = esc(key);
896
+ return `shape[${k}]._zod.run({ value: input[${k}], issues: [] }, ctx)`;
897
+ };
898
+ doc.write(`const input = payload.value;`);
899
+ const ids = Object.create(null);
900
+ let counter = 0;
901
+ for (const key of normalized.keys) ids[key] = `key_${counter++}`;
902
+ doc.write(`const newResult = {};`);
903
+ for (const key of normalized.keys) {
904
+ const id = ids[key];
905
+ const k = esc(key);
906
+ const isOptionalOut = shape[key]?._zod?.optout === "optional";
907
+ doc.write(`const ${id} = ${parseStr(key)};`);
908
+ if (isOptionalOut) doc.write(`
909
+ if (${id}.issues.length) {
910
+ if (${k} in input) {
911
+ payload.issues = payload.issues.concat(${id}.issues.map(iss => ({
912
+ ...iss,
913
+ path: iss.path ? [${k}, ...iss.path] : [${k}]
914
+ })));
915
+ }
916
+ }
917
+
918
+ if (${id}.value === undefined) {
919
+ if (${k} in input) {
920
+ newResult[${k}] = undefined;
921
+ }
922
+ } else {
923
+ newResult[${k}] = ${id}.value;
924
+ }
925
+
926
+ `);
927
+ else doc.write(`
928
+ if (${id}.issues.length) {
929
+ payload.issues = payload.issues.concat(${id}.issues.map(iss => ({
930
+ ...iss,
931
+ path: iss.path ? [${k}, ...iss.path] : [${k}]
932
+ })));
933
+ }
934
+
935
+ if (${id}.value === undefined) {
936
+ if (${k} in input) {
937
+ newResult[${k}] = undefined;
938
+ }
939
+ } else {
940
+ newResult[${k}] = ${id}.value;
941
+ }
942
+
943
+ `);
944
+ }
945
+ doc.write(`payload.value = newResult;`);
946
+ doc.write(`return payload;`);
947
+ const fn = doc.compile();
948
+ return (payload, ctx) => fn(shape, payload, ctx);
949
+ };
950
+ let fastpass;
951
+ const isObject$1 = isObject;
952
+ const jit = !globalConfig.jitless;
953
+ const fastEnabled = jit && allowsEval.value;
954
+ const catchall = def.catchall;
955
+ let value;
956
+ inst._zod.parse = (payload, ctx) => {
957
+ value ?? (value = _normalized.value);
958
+ const input = payload.value;
959
+ if (!isObject$1(input)) {
960
+ payload.issues.push({
961
+ expected: "object",
962
+ code: "invalid_type",
963
+ input,
964
+ inst
965
+ });
966
+ return payload;
967
+ }
968
+ if (jit && fastEnabled && ctx?.async === false && ctx.jitless !== true) {
969
+ if (!fastpass) fastpass = generateFastpass(def.shape);
970
+ payload = fastpass(payload, ctx);
971
+ if (!catchall) return payload;
972
+ return handleCatchall([], input, payload, ctx, value, inst);
973
+ }
974
+ return superParse(payload, ctx);
975
+ };
976
+ });
977
+ function handleUnionResults(results, final, inst, ctx) {
978
+ for (const result of results) if (result.issues.length === 0) {
979
+ final.value = result.value;
980
+ return final;
981
+ }
982
+ const nonaborted = results.filter((r) => !aborted(r));
983
+ if (nonaborted.length === 1) {
984
+ final.value = nonaborted[0].value;
985
+ return nonaborted[0];
986
+ }
987
+ final.issues.push({
988
+ code: "invalid_union",
989
+ input: final.value,
990
+ inst,
991
+ errors: results.map((result) => result.issues.map((iss) => finalizeIssue(iss, ctx, config())))
992
+ });
993
+ return final;
994
+ }
995
+ const $ZodUnion = /* @__PURE__ */ $constructor("$ZodUnion", (inst, def) => {
996
+ $ZodType.init(inst, def);
997
+ defineLazy(inst._zod, "optin", () => def.options.some((o) => o._zod.optin === "optional") ? "optional" : void 0);
998
+ defineLazy(inst._zod, "optout", () => def.options.some((o) => o._zod.optout === "optional") ? "optional" : void 0);
999
+ defineLazy(inst._zod, "values", () => {
1000
+ if (def.options.every((o) => o._zod.values)) return new Set(def.options.flatMap((option) => Array.from(option._zod.values)));
1001
+ });
1002
+ defineLazy(inst._zod, "pattern", () => {
1003
+ if (def.options.every((o) => o._zod.pattern)) {
1004
+ const patterns = def.options.map((o) => o._zod.pattern);
1005
+ return new RegExp(`^(${patterns.map((p) => cleanRegex(p.source)).join("|")})$`);
1006
+ }
1007
+ });
1008
+ const single = def.options.length === 1;
1009
+ const first = def.options[0]._zod.run;
1010
+ inst._zod.parse = (payload, ctx) => {
1011
+ if (single) return first(payload, ctx);
1012
+ let async = false;
1013
+ const results = [];
1014
+ for (const option of def.options) {
1015
+ const result = option._zod.run({
1016
+ value: payload.value,
1017
+ issues: []
1018
+ }, ctx);
1019
+ if (result instanceof Promise) {
1020
+ results.push(result);
1021
+ async = true;
1022
+ } else {
1023
+ if (result.issues.length === 0) return result;
1024
+ results.push(result);
1025
+ }
1026
+ }
1027
+ if (!async) return handleUnionResults(results, payload, inst, ctx);
1028
+ return Promise.all(results).then((results) => {
1029
+ return handleUnionResults(results, payload, inst, ctx);
1030
+ });
1031
+ };
1032
+ });
1033
+ const $ZodIntersection = /* @__PURE__ */ $constructor("$ZodIntersection", (inst, def) => {
1034
+ $ZodType.init(inst, def);
1035
+ inst._zod.parse = (payload, ctx) => {
1036
+ const input = payload.value;
1037
+ const left = def.left._zod.run({
1038
+ value: input,
1039
+ issues: []
1040
+ }, ctx);
1041
+ const right = def.right._zod.run({
1042
+ value: input,
1043
+ issues: []
1044
+ }, ctx);
1045
+ if (left instanceof Promise || right instanceof Promise) return Promise.all([left, right]).then(([left, right]) => {
1046
+ return handleIntersectionResults(payload, left, right);
1047
+ });
1048
+ return handleIntersectionResults(payload, left, right);
1049
+ };
1050
+ });
1051
+ function mergeValues(a, b) {
1052
+ if (a === b) return {
1053
+ valid: true,
1054
+ data: a
1055
+ };
1056
+ if (a instanceof Date && b instanceof Date && +a === +b) return {
1057
+ valid: true,
1058
+ data: a
1059
+ };
1060
+ if (isPlainObject(a) && isPlainObject(b)) {
1061
+ const bKeys = Object.keys(b);
1062
+ const sharedKeys = Object.keys(a).filter((key) => bKeys.indexOf(key) !== -1);
1063
+ const newObj = {
1064
+ ...a,
1065
+ ...b
1066
+ };
1067
+ for (const key of sharedKeys) {
1068
+ const sharedValue = mergeValues(a[key], b[key]);
1069
+ if (!sharedValue.valid) return {
1070
+ valid: false,
1071
+ mergeErrorPath: [key, ...sharedValue.mergeErrorPath]
1072
+ };
1073
+ newObj[key] = sharedValue.data;
1074
+ }
1075
+ return {
1076
+ valid: true,
1077
+ data: newObj
1078
+ };
1079
+ }
1080
+ if (Array.isArray(a) && Array.isArray(b)) {
1081
+ if (a.length !== b.length) return {
1082
+ valid: false,
1083
+ mergeErrorPath: []
1084
+ };
1085
+ const newArray = [];
1086
+ for (let index = 0; index < a.length; index++) {
1087
+ const itemA = a[index];
1088
+ const itemB = b[index];
1089
+ const sharedValue = mergeValues(itemA, itemB);
1090
+ if (!sharedValue.valid) return {
1091
+ valid: false,
1092
+ mergeErrorPath: [index, ...sharedValue.mergeErrorPath]
1093
+ };
1094
+ newArray.push(sharedValue.data);
1095
+ }
1096
+ return {
1097
+ valid: true,
1098
+ data: newArray
1099
+ };
1100
+ }
1101
+ return {
1102
+ valid: false,
1103
+ mergeErrorPath: []
1104
+ };
1105
+ }
1106
+ function handleIntersectionResults(result, left, right) {
1107
+ const unrecKeys = /* @__PURE__ */ new Map();
1108
+ let unrecIssue;
1109
+ for (const iss of left.issues) if (iss.code === "unrecognized_keys") {
1110
+ unrecIssue ?? (unrecIssue = iss);
1111
+ for (const k of iss.keys) {
1112
+ if (!unrecKeys.has(k)) unrecKeys.set(k, {});
1113
+ unrecKeys.get(k).l = true;
1114
+ }
1115
+ } else result.issues.push(iss);
1116
+ for (const iss of right.issues) if (iss.code === "unrecognized_keys") for (const k of iss.keys) {
1117
+ if (!unrecKeys.has(k)) unrecKeys.set(k, {});
1118
+ unrecKeys.get(k).r = true;
1119
+ }
1120
+ else result.issues.push(iss);
1121
+ const bothKeys = [...unrecKeys].filter(([, f]) => f.l && f.r).map(([k]) => k);
1122
+ if (bothKeys.length && unrecIssue) result.issues.push({
1123
+ ...unrecIssue,
1124
+ keys: bothKeys
1125
+ });
1126
+ if (aborted(result)) return result;
1127
+ const merged = mergeValues(left.value, right.value);
1128
+ if (!merged.valid) throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(merged.mergeErrorPath)}`);
1129
+ result.value = merged.data;
1130
+ return result;
1131
+ }
1132
+ const $ZodEnum = /* @__PURE__ */ $constructor("$ZodEnum", (inst, def) => {
1133
+ $ZodType.init(inst, def);
1134
+ const values = getEnumValues(def.entries);
1135
+ const valuesSet = new Set(values);
1136
+ inst._zod.values = valuesSet;
1137
+ inst._zod.pattern = new RegExp(`^(${values.filter((k) => propertyKeyTypes.has(typeof k)).map((o) => typeof o === "string" ? escapeRegex(o) : o.toString()).join("|")})$`);
1138
+ inst._zod.parse = (payload, _ctx) => {
1139
+ const input = payload.value;
1140
+ if (valuesSet.has(input)) return payload;
1141
+ payload.issues.push({
1142
+ code: "invalid_value",
1143
+ values,
1144
+ input,
1145
+ inst
1146
+ });
1147
+ return payload;
1148
+ };
1149
+ });
1150
+ const $ZodTransform = /* @__PURE__ */ $constructor("$ZodTransform", (inst, def) => {
1151
+ $ZodType.init(inst, def);
1152
+ inst._zod.parse = (payload, ctx) => {
1153
+ if (ctx.direction === "backward") throw new $ZodEncodeError(inst.constructor.name);
1154
+ const _out = def.transform(payload.value, payload);
1155
+ if (ctx.async) return (_out instanceof Promise ? _out : Promise.resolve(_out)).then((output) => {
1156
+ payload.value = output;
1157
+ return payload;
1158
+ });
1159
+ if (_out instanceof Promise) throw new $ZodAsyncError();
1160
+ payload.value = _out;
1161
+ return payload;
1162
+ };
1163
+ });
1164
+ function handleOptionalResult(result, input) {
1165
+ if (result.issues.length && input === void 0) return {
1166
+ issues: [],
1167
+ value: void 0
1168
+ };
1169
+ return result;
1170
+ }
1171
+ const $ZodOptional = /* @__PURE__ */ $constructor("$ZodOptional", (inst, def) => {
1172
+ $ZodType.init(inst, def);
1173
+ inst._zod.optin = "optional";
1174
+ inst._zod.optout = "optional";
1175
+ defineLazy(inst._zod, "values", () => {
1176
+ return def.innerType._zod.values ? new Set([...def.innerType._zod.values, void 0]) : void 0;
1177
+ });
1178
+ defineLazy(inst._zod, "pattern", () => {
1179
+ const pattern = def.innerType._zod.pattern;
1180
+ return pattern ? new RegExp(`^(${cleanRegex(pattern.source)})?$`) : void 0;
1181
+ });
1182
+ inst._zod.parse = (payload, ctx) => {
1183
+ if (def.innerType._zod.optin === "optional") {
1184
+ const result = def.innerType._zod.run(payload, ctx);
1185
+ if (result instanceof Promise) return result.then((r) => handleOptionalResult(r, payload.value));
1186
+ return handleOptionalResult(result, payload.value);
1187
+ }
1188
+ if (payload.value === void 0) return payload;
1189
+ return def.innerType._zod.run(payload, ctx);
1190
+ };
1191
+ });
1192
+ const $ZodExactOptional = /* @__PURE__ */ $constructor("$ZodExactOptional", (inst, def) => {
1193
+ $ZodOptional.init(inst, def);
1194
+ defineLazy(inst._zod, "values", () => def.innerType._zod.values);
1195
+ defineLazy(inst._zod, "pattern", () => def.innerType._zod.pattern);
1196
+ inst._zod.parse = (payload, ctx) => {
1197
+ return def.innerType._zod.run(payload, ctx);
1198
+ };
1199
+ });
1200
+ const $ZodNullable = /* @__PURE__ */ $constructor("$ZodNullable", (inst, def) => {
1201
+ $ZodType.init(inst, def);
1202
+ defineLazy(inst._zod, "optin", () => def.innerType._zod.optin);
1203
+ defineLazy(inst._zod, "optout", () => def.innerType._zod.optout);
1204
+ defineLazy(inst._zod, "pattern", () => {
1205
+ const pattern = def.innerType._zod.pattern;
1206
+ return pattern ? new RegExp(`^(${cleanRegex(pattern.source)}|null)$`) : void 0;
1207
+ });
1208
+ defineLazy(inst._zod, "values", () => {
1209
+ return def.innerType._zod.values ? new Set([...def.innerType._zod.values, null]) : void 0;
1210
+ });
1211
+ inst._zod.parse = (payload, ctx) => {
1212
+ if (payload.value === null) return payload;
1213
+ return def.innerType._zod.run(payload, ctx);
1214
+ };
1215
+ });
1216
+ const $ZodDefault = /* @__PURE__ */ $constructor("$ZodDefault", (inst, def) => {
1217
+ $ZodType.init(inst, def);
1218
+ inst._zod.optin = "optional";
1219
+ defineLazy(inst._zod, "values", () => def.innerType._zod.values);
1220
+ inst._zod.parse = (payload, ctx) => {
1221
+ if (ctx.direction === "backward") return def.innerType._zod.run(payload, ctx);
1222
+ if (payload.value === void 0) {
1223
+ payload.value = def.defaultValue;
1224
+ /**
1225
+ * $ZodDefault returns the default value immediately in forward direction.
1226
+ * It doesn't pass the default value into the validator ("prefault"). There's no reason to pass the default value through validation. The validity of the default is enforced by TypeScript statically. Otherwise, it's the responsibility of the user to ensure the default is valid. In the case of pipes with divergent in/out types, you can specify the default on the `in` schema of your ZodPipe to set a "prefault" for the pipe. */
1227
+ return payload;
1228
+ }
1229
+ const result = def.innerType._zod.run(payload, ctx);
1230
+ if (result instanceof Promise) return result.then((result) => handleDefaultResult(result, def));
1231
+ return handleDefaultResult(result, def);
1232
+ };
1233
+ });
1234
+ function handleDefaultResult(payload, def) {
1235
+ if (payload.value === void 0) payload.value = def.defaultValue;
1236
+ return payload;
1237
+ }
1238
+ const $ZodPrefault = /* @__PURE__ */ $constructor("$ZodPrefault", (inst, def) => {
1239
+ $ZodType.init(inst, def);
1240
+ inst._zod.optin = "optional";
1241
+ defineLazy(inst._zod, "values", () => def.innerType._zod.values);
1242
+ inst._zod.parse = (payload, ctx) => {
1243
+ if (ctx.direction === "backward") return def.innerType._zod.run(payload, ctx);
1244
+ if (payload.value === void 0) payload.value = def.defaultValue;
1245
+ return def.innerType._zod.run(payload, ctx);
1246
+ };
1247
+ });
1248
+ const $ZodNonOptional = /* @__PURE__ */ $constructor("$ZodNonOptional", (inst, def) => {
1249
+ $ZodType.init(inst, def);
1250
+ defineLazy(inst._zod, "values", () => {
1251
+ const v = def.innerType._zod.values;
1252
+ return v ? new Set([...v].filter((x) => x !== void 0)) : void 0;
1253
+ });
1254
+ inst._zod.parse = (payload, ctx) => {
1255
+ const result = def.innerType._zod.run(payload, ctx);
1256
+ if (result instanceof Promise) return result.then((result) => handleNonOptionalResult(result, inst));
1257
+ return handleNonOptionalResult(result, inst);
1258
+ };
1259
+ });
1260
+ function handleNonOptionalResult(payload, inst) {
1261
+ if (!payload.issues.length && payload.value === void 0) payload.issues.push({
1262
+ code: "invalid_type",
1263
+ expected: "nonoptional",
1264
+ input: payload.value,
1265
+ inst
1266
+ });
1267
+ return payload;
1268
+ }
1269
+ const $ZodCatch = /* @__PURE__ */ $constructor("$ZodCatch", (inst, def) => {
1270
+ $ZodType.init(inst, def);
1271
+ defineLazy(inst._zod, "optin", () => def.innerType._zod.optin);
1272
+ defineLazy(inst._zod, "optout", () => def.innerType._zod.optout);
1273
+ defineLazy(inst._zod, "values", () => def.innerType._zod.values);
1274
+ inst._zod.parse = (payload, ctx) => {
1275
+ if (ctx.direction === "backward") return def.innerType._zod.run(payload, ctx);
1276
+ const result = def.innerType._zod.run(payload, ctx);
1277
+ if (result instanceof Promise) return result.then((result) => {
1278
+ payload.value = result.value;
1279
+ if (result.issues.length) {
1280
+ payload.value = def.catchValue({
1281
+ ...payload,
1282
+ error: { issues: result.issues.map((iss) => finalizeIssue(iss, ctx, config())) },
1283
+ input: payload.value
1284
+ });
1285
+ payload.issues = [];
1286
+ }
1287
+ return payload;
1288
+ });
1289
+ payload.value = result.value;
1290
+ if (result.issues.length) {
1291
+ payload.value = def.catchValue({
1292
+ ...payload,
1293
+ error: { issues: result.issues.map((iss) => finalizeIssue(iss, ctx, config())) },
1294
+ input: payload.value
1295
+ });
1296
+ payload.issues = [];
1297
+ }
1298
+ return payload;
1299
+ };
1300
+ });
1301
+ const $ZodPipe = /* @__PURE__ */ $constructor("$ZodPipe", (inst, def) => {
1302
+ $ZodType.init(inst, def);
1303
+ defineLazy(inst._zod, "values", () => def.in._zod.values);
1304
+ defineLazy(inst._zod, "optin", () => def.in._zod.optin);
1305
+ defineLazy(inst._zod, "optout", () => def.out._zod.optout);
1306
+ defineLazy(inst._zod, "propValues", () => def.in._zod.propValues);
1307
+ inst._zod.parse = (payload, ctx) => {
1308
+ if (ctx.direction === "backward") {
1309
+ const right = def.out._zod.run(payload, ctx);
1310
+ if (right instanceof Promise) return right.then((right) => handlePipeResult(right, def.in, ctx));
1311
+ return handlePipeResult(right, def.in, ctx);
1312
+ }
1313
+ const left = def.in._zod.run(payload, ctx);
1314
+ if (left instanceof Promise) return left.then((left) => handlePipeResult(left, def.out, ctx));
1315
+ return handlePipeResult(left, def.out, ctx);
1316
+ };
1317
+ });
1318
+ function handlePipeResult(left, next, ctx) {
1319
+ if (left.issues.length) {
1320
+ left.aborted = true;
1321
+ return left;
1322
+ }
1323
+ return next._zod.run({
1324
+ value: left.value,
1325
+ issues: left.issues
1326
+ }, ctx);
1327
+ }
1328
+ const $ZodReadonly = /* @__PURE__ */ $constructor("$ZodReadonly", (inst, def) => {
1329
+ $ZodType.init(inst, def);
1330
+ defineLazy(inst._zod, "propValues", () => def.innerType._zod.propValues);
1331
+ defineLazy(inst._zod, "values", () => def.innerType._zod.values);
1332
+ defineLazy(inst._zod, "optin", () => def.innerType?._zod?.optin);
1333
+ defineLazy(inst._zod, "optout", () => def.innerType?._zod?.optout);
1334
+ inst._zod.parse = (payload, ctx) => {
1335
+ if (ctx.direction === "backward") return def.innerType._zod.run(payload, ctx);
1336
+ const result = def.innerType._zod.run(payload, ctx);
1337
+ if (result instanceof Promise) return result.then(handleReadonlyResult);
1338
+ return handleReadonlyResult(result);
1339
+ };
1340
+ });
1341
+ function handleReadonlyResult(payload) {
1342
+ payload.value = Object.freeze(payload.value);
1343
+ return payload;
1344
+ }
1345
+ const $ZodCustom = /* @__PURE__ */ $constructor("$ZodCustom", (inst, def) => {
1346
+ $ZodCheck.init(inst, def);
1347
+ $ZodType.init(inst, def);
1348
+ inst._zod.parse = (payload, _) => {
1349
+ return payload;
1350
+ };
1351
+ inst._zod.check = (payload) => {
1352
+ const input = payload.value;
1353
+ const r = def.fn(input);
1354
+ if (r instanceof Promise) return r.then((r) => handleRefineResult(r, payload, input, inst));
1355
+ handleRefineResult(r, payload, input, inst);
1356
+ };
1357
+ });
1358
+ function handleRefineResult(result, payload, input, inst) {
1359
+ if (!result) {
1360
+ const _iss = {
1361
+ code: "custom",
1362
+ input,
1363
+ inst,
1364
+ path: [...inst._zod.def.path ?? []],
1365
+ continue: !inst._zod.def.abort
1366
+ };
1367
+ if (inst._zod.def.params) _iss.params = inst._zod.def.params;
1368
+ payload.issues.push(issue(_iss));
1369
+ }
1370
+ }
1371
+ //#endregion
1372
+ //#region ../../node_modules/.pnpm/zod@4.3.6/node_modules/zod/v4/core/registries.js
1373
+ var _a;
1374
+ var $ZodRegistry = class {
1375
+ constructor() {
1376
+ this._map = /* @__PURE__ */ new WeakMap();
1377
+ this._idmap = /* @__PURE__ */ new Map();
1378
+ }
1379
+ add(schema, ..._meta) {
1380
+ const meta = _meta[0];
1381
+ this._map.set(schema, meta);
1382
+ if (meta && typeof meta === "object" && "id" in meta) this._idmap.set(meta.id, schema);
1383
+ return this;
1384
+ }
1385
+ clear() {
1386
+ this._map = /* @__PURE__ */ new WeakMap();
1387
+ this._idmap = /* @__PURE__ */ new Map();
1388
+ return this;
1389
+ }
1390
+ remove(schema) {
1391
+ const meta = this._map.get(schema);
1392
+ if (meta && typeof meta === "object" && "id" in meta) this._idmap.delete(meta.id);
1393
+ this._map.delete(schema);
1394
+ return this;
1395
+ }
1396
+ get(schema) {
1397
+ const p = schema._zod.parent;
1398
+ if (p) {
1399
+ const pm = { ...this.get(p) ?? {} };
1400
+ delete pm.id;
1401
+ const f = {
1402
+ ...pm,
1403
+ ...this._map.get(schema)
1404
+ };
1405
+ return Object.keys(f).length ? f : void 0;
1406
+ }
1407
+ return this._map.get(schema);
1408
+ }
1409
+ has(schema) {
1410
+ return this._map.has(schema);
1411
+ }
1412
+ };
1413
+ function registry() {
1414
+ return new $ZodRegistry();
1415
+ }
1416
+ (_a = globalThis).__zod_globalRegistry ?? (_a.__zod_globalRegistry = registry());
1417
+ const globalRegistry = globalThis.__zod_globalRegistry;
1418
+ //#endregion
1419
+ //#region ../../node_modules/.pnpm/zod@4.3.6/node_modules/zod/v4/core/api.js
1420
+ /* @__NO_SIDE_EFFECTS__ */
1421
+ function _unknown(Class) {
1422
+ return new Class({ type: "unknown" });
1423
+ }
1424
+ /* @__NO_SIDE_EFFECTS__ */
1425
+ function _never(Class, params) {
1426
+ return new Class({
1427
+ type: "never",
1428
+ ...normalizeParams(params)
1429
+ });
1430
+ }
1431
+ /* @__NO_SIDE_EFFECTS__ */
1432
+ function _maxLength(maximum, params) {
1433
+ return new $ZodCheckMaxLength({
1434
+ check: "max_length",
1435
+ ...normalizeParams(params),
1436
+ maximum
1437
+ });
1438
+ }
1439
+ /* @__NO_SIDE_EFFECTS__ */
1440
+ function _minLength(minimum, params) {
1441
+ return new $ZodCheckMinLength({
1442
+ check: "min_length",
1443
+ ...normalizeParams(params),
1444
+ minimum
1445
+ });
1446
+ }
1447
+ /* @__NO_SIDE_EFFECTS__ */
1448
+ function _length(length, params) {
1449
+ return new $ZodCheckLengthEquals({
1450
+ check: "length_equals",
1451
+ ...normalizeParams(params),
1452
+ length
1453
+ });
1454
+ }
1455
+ /* @__NO_SIDE_EFFECTS__ */
1456
+ function _overwrite(tx) {
1457
+ return new $ZodCheckOverwrite({
1458
+ check: "overwrite",
1459
+ tx
1460
+ });
1461
+ }
1462
+ /* @__NO_SIDE_EFFECTS__ */
1463
+ function _array(Class, element, params) {
1464
+ return new Class({
1465
+ type: "array",
1466
+ element,
1467
+ ...normalizeParams(params)
1468
+ });
1469
+ }
1470
+ /* @__NO_SIDE_EFFECTS__ */
1471
+ function _refine(Class, fn, _params) {
1472
+ return new Class({
1473
+ type: "custom",
1474
+ check: "custom",
1475
+ fn,
1476
+ ...normalizeParams(_params)
1477
+ });
1478
+ }
1479
+ /* @__NO_SIDE_EFFECTS__ */
1480
+ function _superRefine(fn) {
1481
+ const ch = /* @__PURE__ */ _check((payload) => {
1482
+ payload.addIssue = (issue$2) => {
1483
+ if (typeof issue$2 === "string") payload.issues.push(issue(issue$2, payload.value, ch._zod.def));
1484
+ else {
1485
+ const _issue = issue$2;
1486
+ if (_issue.fatal) _issue.continue = false;
1487
+ _issue.code ?? (_issue.code = "custom");
1488
+ _issue.input ?? (_issue.input = payload.value);
1489
+ _issue.inst ?? (_issue.inst = ch);
1490
+ _issue.continue ?? (_issue.continue = !ch._zod.def.abort);
1491
+ payload.issues.push(issue(_issue));
1492
+ }
1493
+ };
1494
+ return fn(payload.value, payload);
1495
+ });
1496
+ return ch;
1497
+ }
1498
+ /* @__NO_SIDE_EFFECTS__ */
1499
+ function _check(fn, params) {
1500
+ const ch = new $ZodCheck({
1501
+ check: "custom",
1502
+ ...normalizeParams(params)
1503
+ });
1504
+ ch._zod.check = fn;
1505
+ return ch;
1506
+ }
1507
+ //#endregion
1508
+ //#region ../../node_modules/.pnpm/zod@4.3.6/node_modules/zod/v4/core/to-json-schema.js
1509
+ function initializeContext(params) {
1510
+ let target = params?.target ?? "draft-2020-12";
1511
+ if (target === "draft-4") target = "draft-04";
1512
+ if (target === "draft-7") target = "draft-07";
1513
+ return {
1514
+ processors: params.processors ?? {},
1515
+ metadataRegistry: params?.metadata ?? globalRegistry,
1516
+ target,
1517
+ unrepresentable: params?.unrepresentable ?? "throw",
1518
+ override: params?.override ?? (() => {}),
1519
+ io: params?.io ?? "output",
1520
+ counter: 0,
1521
+ seen: /* @__PURE__ */ new Map(),
1522
+ cycles: params?.cycles ?? "ref",
1523
+ reused: params?.reused ?? "inline",
1524
+ external: params?.external ?? void 0
1525
+ };
1526
+ }
1527
+ function process(schema, ctx, _params = {
1528
+ path: [],
1529
+ schemaPath: []
1530
+ }) {
1531
+ var _a;
1532
+ const def = schema._zod.def;
1533
+ const seen = ctx.seen.get(schema);
1534
+ if (seen) {
1535
+ seen.count++;
1536
+ if (_params.schemaPath.includes(schema)) seen.cycle = _params.path;
1537
+ return seen.schema;
1538
+ }
1539
+ const result = {
1540
+ schema: {},
1541
+ count: 1,
1542
+ cycle: void 0,
1543
+ path: _params.path
1544
+ };
1545
+ ctx.seen.set(schema, result);
1546
+ const overrideSchema = schema._zod.toJSONSchema?.();
1547
+ if (overrideSchema) result.schema = overrideSchema;
1548
+ else {
1549
+ const params = {
1550
+ ..._params,
1551
+ schemaPath: [..._params.schemaPath, schema],
1552
+ path: _params.path
1553
+ };
1554
+ if (schema._zod.processJSONSchema) schema._zod.processJSONSchema(ctx, result.schema, params);
1555
+ else {
1556
+ const _json = result.schema;
1557
+ const processor = ctx.processors[def.type];
1558
+ if (!processor) throw new Error(`[toJSONSchema]: Non-representable type encountered: ${def.type}`);
1559
+ processor(schema, ctx, _json, params);
1560
+ }
1561
+ const parent = schema._zod.parent;
1562
+ if (parent) {
1563
+ if (!result.ref) result.ref = parent;
1564
+ process(parent, ctx, params);
1565
+ ctx.seen.get(parent).isParent = true;
1566
+ }
1567
+ }
1568
+ const meta = ctx.metadataRegistry.get(schema);
1569
+ if (meta) Object.assign(result.schema, meta);
1570
+ if (ctx.io === "input" && isTransforming(schema)) {
1571
+ delete result.schema.examples;
1572
+ delete result.schema.default;
1573
+ }
1574
+ if (ctx.io === "input" && result.schema._prefault) (_a = result.schema).default ?? (_a.default = result.schema._prefault);
1575
+ delete result.schema._prefault;
1576
+ return ctx.seen.get(schema).schema;
1577
+ }
1578
+ function extractDefs(ctx, schema) {
1579
+ const root = ctx.seen.get(schema);
1580
+ if (!root) throw new Error("Unprocessed schema. This is a bug in Zod.");
1581
+ const idToSchema = /* @__PURE__ */ new Map();
1582
+ for (const entry of ctx.seen.entries()) {
1583
+ const id = ctx.metadataRegistry.get(entry[0])?.id;
1584
+ if (id) {
1585
+ const existing = idToSchema.get(id);
1586
+ if (existing && existing !== entry[0]) throw new Error(`Duplicate schema id "${id}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);
1587
+ idToSchema.set(id, entry[0]);
1588
+ }
1589
+ }
1590
+ const makeURI = (entry) => {
1591
+ const defsSegment = ctx.target === "draft-2020-12" ? "$defs" : "definitions";
1592
+ if (ctx.external) {
1593
+ const externalId = ctx.external.registry.get(entry[0])?.id;
1594
+ const uriGenerator = ctx.external.uri ?? ((id) => id);
1595
+ if (externalId) return { ref: uriGenerator(externalId) };
1596
+ const id = entry[1].defId ?? entry[1].schema.id ?? `schema${ctx.counter++}`;
1597
+ entry[1].defId = id;
1598
+ return {
1599
+ defId: id,
1600
+ ref: `${uriGenerator("__shared")}#/${defsSegment}/${id}`
1601
+ };
1602
+ }
1603
+ if (entry[1] === root) return { ref: "#" };
1604
+ const defUriPrefix = `#/${defsSegment}/`;
1605
+ const defId = entry[1].schema.id ?? `__schema${ctx.counter++}`;
1606
+ return {
1607
+ defId,
1608
+ ref: defUriPrefix + defId
1609
+ };
1610
+ };
1611
+ const extractToDef = (entry) => {
1612
+ if (entry[1].schema.$ref) return;
1613
+ const seen = entry[1];
1614
+ const { ref, defId } = makeURI(entry);
1615
+ seen.def = { ...seen.schema };
1616
+ if (defId) seen.defId = defId;
1617
+ const schema = seen.schema;
1618
+ for (const key in schema) delete schema[key];
1619
+ schema.$ref = ref;
1620
+ };
1621
+ if (ctx.cycles === "throw") for (const entry of ctx.seen.entries()) {
1622
+ const seen = entry[1];
1623
+ if (seen.cycle) throw new Error(`Cycle detected: #/${seen.cycle?.join("/")}/<root>
1624
+
1625
+ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`);
1626
+ }
1627
+ for (const entry of ctx.seen.entries()) {
1628
+ const seen = entry[1];
1629
+ if (schema === entry[0]) {
1630
+ extractToDef(entry);
1631
+ continue;
1632
+ }
1633
+ if (ctx.external) {
1634
+ const ext = ctx.external.registry.get(entry[0])?.id;
1635
+ if (schema !== entry[0] && ext) {
1636
+ extractToDef(entry);
1637
+ continue;
1638
+ }
1639
+ }
1640
+ if (ctx.metadataRegistry.get(entry[0])?.id) {
1641
+ extractToDef(entry);
1642
+ continue;
1643
+ }
1644
+ if (seen.cycle) {
1645
+ extractToDef(entry);
1646
+ continue;
1647
+ }
1648
+ if (seen.count > 1) {
1649
+ if (ctx.reused === "ref") {
1650
+ extractToDef(entry);
1651
+ continue;
1652
+ }
1653
+ }
1654
+ }
1655
+ }
1656
+ function finalize(ctx, schema) {
1657
+ const root = ctx.seen.get(schema);
1658
+ if (!root) throw new Error("Unprocessed schema. This is a bug in Zod.");
1659
+ const flattenRef = (zodSchema) => {
1660
+ const seen = ctx.seen.get(zodSchema);
1661
+ if (seen.ref === null) return;
1662
+ const schema = seen.def ?? seen.schema;
1663
+ const _cached = { ...schema };
1664
+ const ref = seen.ref;
1665
+ seen.ref = null;
1666
+ if (ref) {
1667
+ flattenRef(ref);
1668
+ const refSeen = ctx.seen.get(ref);
1669
+ const refSchema = refSeen.schema;
1670
+ if (refSchema.$ref && (ctx.target === "draft-07" || ctx.target === "draft-04" || ctx.target === "openapi-3.0")) {
1671
+ schema.allOf = schema.allOf ?? [];
1672
+ schema.allOf.push(refSchema);
1673
+ } else Object.assign(schema, refSchema);
1674
+ Object.assign(schema, _cached);
1675
+ if (zodSchema._zod.parent === ref) for (const key in schema) {
1676
+ if (key === "$ref" || key === "allOf") continue;
1677
+ if (!(key in _cached)) delete schema[key];
1678
+ }
1679
+ if (refSchema.$ref && refSeen.def) for (const key in schema) {
1680
+ if (key === "$ref" || key === "allOf") continue;
1681
+ if (key in refSeen.def && JSON.stringify(schema[key]) === JSON.stringify(refSeen.def[key])) delete schema[key];
1682
+ }
1683
+ }
1684
+ const parent = zodSchema._zod.parent;
1685
+ if (parent && parent !== ref) {
1686
+ flattenRef(parent);
1687
+ const parentSeen = ctx.seen.get(parent);
1688
+ if (parentSeen?.schema.$ref) {
1689
+ schema.$ref = parentSeen.schema.$ref;
1690
+ if (parentSeen.def) for (const key in schema) {
1691
+ if (key === "$ref" || key === "allOf") continue;
1692
+ if (key in parentSeen.def && JSON.stringify(schema[key]) === JSON.stringify(parentSeen.def[key])) delete schema[key];
1693
+ }
1694
+ }
1695
+ }
1696
+ ctx.override({
1697
+ zodSchema,
1698
+ jsonSchema: schema,
1699
+ path: seen.path ?? []
1700
+ });
1701
+ };
1702
+ for (const entry of [...ctx.seen.entries()].reverse()) flattenRef(entry[0]);
1703
+ const result = {};
1704
+ if (ctx.target === "draft-2020-12") result.$schema = "https://json-schema.org/draft/2020-12/schema";
1705
+ else if (ctx.target === "draft-07") result.$schema = "http://json-schema.org/draft-07/schema#";
1706
+ else if (ctx.target === "draft-04") result.$schema = "http://json-schema.org/draft-04/schema#";
1707
+ else if (ctx.target === "openapi-3.0") {}
1708
+ if (ctx.external?.uri) {
1709
+ const id = ctx.external.registry.get(schema)?.id;
1710
+ if (!id) throw new Error("Schema is missing an `id` property");
1711
+ result.$id = ctx.external.uri(id);
1712
+ }
1713
+ Object.assign(result, root.def ?? root.schema);
1714
+ const defs = ctx.external?.defs ?? {};
1715
+ for (const entry of ctx.seen.entries()) {
1716
+ const seen = entry[1];
1717
+ if (seen.def && seen.defId) defs[seen.defId] = seen.def;
1718
+ }
1719
+ if (ctx.external) {} else if (Object.keys(defs).length > 0) if (ctx.target === "draft-2020-12") result.$defs = defs;
1720
+ else result.definitions = defs;
1721
+ try {
1722
+ const finalized = JSON.parse(JSON.stringify(result));
1723
+ Object.defineProperty(finalized, "~standard", {
1724
+ value: {
1725
+ ...schema["~standard"],
1726
+ jsonSchema: {
1727
+ input: createStandardJSONSchemaMethod(schema, "input", ctx.processors),
1728
+ output: createStandardJSONSchemaMethod(schema, "output", ctx.processors)
1729
+ }
1730
+ },
1731
+ enumerable: false,
1732
+ writable: false
1733
+ });
1734
+ return finalized;
1735
+ } catch (_err) {
1736
+ throw new Error("Error converting schema to JSON.");
1737
+ }
1738
+ }
1739
+ function isTransforming(_schema, _ctx) {
1740
+ const ctx = _ctx ?? { seen: /* @__PURE__ */ new Set() };
1741
+ if (ctx.seen.has(_schema)) return false;
1742
+ ctx.seen.add(_schema);
1743
+ const def = _schema._zod.def;
1744
+ if (def.type === "transform") return true;
1745
+ if (def.type === "array") return isTransforming(def.element, ctx);
1746
+ if (def.type === "set") return isTransforming(def.valueType, ctx);
1747
+ if (def.type === "lazy") return isTransforming(def.getter(), ctx);
1748
+ if (def.type === "promise" || def.type === "optional" || def.type === "nonoptional" || def.type === "nullable" || def.type === "readonly" || def.type === "default" || def.type === "prefault") return isTransforming(def.innerType, ctx);
1749
+ if (def.type === "intersection") return isTransforming(def.left, ctx) || isTransforming(def.right, ctx);
1750
+ if (def.type === "record" || def.type === "map") return isTransforming(def.keyType, ctx) || isTransforming(def.valueType, ctx);
1751
+ if (def.type === "pipe") return isTransforming(def.in, ctx) || isTransforming(def.out, ctx);
1752
+ if (def.type === "object") {
1753
+ for (const key in def.shape) if (isTransforming(def.shape[key], ctx)) return true;
1754
+ return false;
1755
+ }
1756
+ if (def.type === "union") {
1757
+ for (const option of def.options) if (isTransforming(option, ctx)) return true;
1758
+ return false;
1759
+ }
1760
+ if (def.type === "tuple") {
1761
+ for (const item of def.items) if (isTransforming(item, ctx)) return true;
1762
+ if (def.rest && isTransforming(def.rest, ctx)) return true;
1763
+ return false;
1764
+ }
1765
+ return false;
1766
+ }
1767
+ /**
1768
+ * Creates a toJSONSchema method for a schema instance.
1769
+ * This encapsulates the logic of initializing context, processing, extracting defs, and finalizing.
1770
+ */
1771
+ const createToJSONSchemaMethod = (schema, processors = {}) => (params) => {
1772
+ const ctx = initializeContext({
1773
+ ...params,
1774
+ processors
1775
+ });
1776
+ process(schema, ctx);
1777
+ extractDefs(ctx, schema);
1778
+ return finalize(ctx, schema);
1779
+ };
1780
+ const createStandardJSONSchemaMethod = (schema, io, processors = {}) => (params) => {
1781
+ const { libraryOptions, target } = params ?? {};
1782
+ const ctx = initializeContext({
1783
+ ...libraryOptions ?? {},
1784
+ target,
1785
+ io,
1786
+ processors
1787
+ });
1788
+ process(schema, ctx);
1789
+ extractDefs(ctx, schema);
1790
+ return finalize(ctx, schema);
1791
+ };
1792
+ //#endregion
1793
+ //#region ../../node_modules/.pnpm/zod@4.3.6/node_modules/zod/v4/core/json-schema-processors.js
1794
+ const neverProcessor = (_schema, _ctx, json, _params) => {
1795
+ json.not = {};
1796
+ };
1797
+ const unknownProcessor = (_schema, _ctx, _json, _params) => {};
1798
+ const enumProcessor = (schema, _ctx, json, _params) => {
1799
+ const def = schema._zod.def;
1800
+ const values = getEnumValues(def.entries);
1801
+ if (values.every((v) => typeof v === "number")) json.type = "number";
1802
+ if (values.every((v) => typeof v === "string")) json.type = "string";
1803
+ json.enum = values;
1804
+ };
1805
+ const customProcessor = (_schema, ctx, _json, _params) => {
1806
+ if (ctx.unrepresentable === "throw") throw new Error("Custom types cannot be represented in JSON Schema");
1807
+ };
1808
+ const transformProcessor = (_schema, ctx, _json, _params) => {
1809
+ if (ctx.unrepresentable === "throw") throw new Error("Transforms cannot be represented in JSON Schema");
1810
+ };
1811
+ const arrayProcessor = (schema, ctx, _json, params) => {
1812
+ const json = _json;
1813
+ const def = schema._zod.def;
1814
+ const { minimum, maximum } = schema._zod.bag;
1815
+ if (typeof minimum === "number") json.minItems = minimum;
1816
+ if (typeof maximum === "number") json.maxItems = maximum;
1817
+ json.type = "array";
1818
+ json.items = process(def.element, ctx, {
1819
+ ...params,
1820
+ path: [...params.path, "items"]
1821
+ });
1822
+ };
1823
+ const objectProcessor = (schema, ctx, _json, params) => {
1824
+ const json = _json;
1825
+ const def = schema._zod.def;
1826
+ json.type = "object";
1827
+ json.properties = {};
1828
+ const shape = def.shape;
1829
+ for (const key in shape) json.properties[key] = process(shape[key], ctx, {
1830
+ ...params,
1831
+ path: [
1832
+ ...params.path,
1833
+ "properties",
1834
+ key
1835
+ ]
1836
+ });
1837
+ const allKeys = new Set(Object.keys(shape));
1838
+ const requiredKeys = new Set([...allKeys].filter((key) => {
1839
+ const v = def.shape[key]._zod;
1840
+ if (ctx.io === "input") return v.optin === void 0;
1841
+ else return v.optout === void 0;
1842
+ }));
1843
+ if (requiredKeys.size > 0) json.required = Array.from(requiredKeys);
1844
+ if (def.catchall?._zod.def.type === "never") json.additionalProperties = false;
1845
+ else if (!def.catchall) {
1846
+ if (ctx.io === "output") json.additionalProperties = false;
1847
+ } else if (def.catchall) json.additionalProperties = process(def.catchall, ctx, {
1848
+ ...params,
1849
+ path: [...params.path, "additionalProperties"]
1850
+ });
1851
+ };
1852
+ const unionProcessor = (schema, ctx, json, params) => {
1853
+ const def = schema._zod.def;
1854
+ const isExclusive = def.inclusive === false;
1855
+ const options = def.options.map((x, i) => process(x, ctx, {
1856
+ ...params,
1857
+ path: [
1858
+ ...params.path,
1859
+ isExclusive ? "oneOf" : "anyOf",
1860
+ i
1861
+ ]
1862
+ }));
1863
+ if (isExclusive) json.oneOf = options;
1864
+ else json.anyOf = options;
1865
+ };
1866
+ const intersectionProcessor = (schema, ctx, json, params) => {
1867
+ const def = schema._zod.def;
1868
+ const a = process(def.left, ctx, {
1869
+ ...params,
1870
+ path: [
1871
+ ...params.path,
1872
+ "allOf",
1873
+ 0
1874
+ ]
1875
+ });
1876
+ const b = process(def.right, ctx, {
1877
+ ...params,
1878
+ path: [
1879
+ ...params.path,
1880
+ "allOf",
1881
+ 1
1882
+ ]
1883
+ });
1884
+ const isSimpleIntersection = (val) => "allOf" in val && Object.keys(val).length === 1;
1885
+ json.allOf = [...isSimpleIntersection(a) ? a.allOf : [a], ...isSimpleIntersection(b) ? b.allOf : [b]];
1886
+ };
1887
+ const nullableProcessor = (schema, ctx, json, params) => {
1888
+ const def = schema._zod.def;
1889
+ const inner = process(def.innerType, ctx, params);
1890
+ const seen = ctx.seen.get(schema);
1891
+ if (ctx.target === "openapi-3.0") {
1892
+ seen.ref = def.innerType;
1893
+ json.nullable = true;
1894
+ } else json.anyOf = [inner, { type: "null" }];
1895
+ };
1896
+ const nonoptionalProcessor = (schema, ctx, _json, params) => {
1897
+ const def = schema._zod.def;
1898
+ process(def.innerType, ctx, params);
1899
+ const seen = ctx.seen.get(schema);
1900
+ seen.ref = def.innerType;
1901
+ };
1902
+ const defaultProcessor = (schema, ctx, json, params) => {
1903
+ const def = schema._zod.def;
1904
+ process(def.innerType, ctx, params);
1905
+ const seen = ctx.seen.get(schema);
1906
+ seen.ref = def.innerType;
1907
+ json.default = JSON.parse(JSON.stringify(def.defaultValue));
1908
+ };
1909
+ const prefaultProcessor = (schema, ctx, json, params) => {
1910
+ const def = schema._zod.def;
1911
+ process(def.innerType, ctx, params);
1912
+ const seen = ctx.seen.get(schema);
1913
+ seen.ref = def.innerType;
1914
+ if (ctx.io === "input") json._prefault = JSON.parse(JSON.stringify(def.defaultValue));
1915
+ };
1916
+ const catchProcessor = (schema, ctx, json, params) => {
1917
+ const def = schema._zod.def;
1918
+ process(def.innerType, ctx, params);
1919
+ const seen = ctx.seen.get(schema);
1920
+ seen.ref = def.innerType;
1921
+ let catchValue;
1922
+ try {
1923
+ catchValue = def.catchValue(void 0);
1924
+ } catch {
1925
+ throw new Error("Dynamic catch values are not supported in JSON Schema");
1926
+ }
1927
+ json.default = catchValue;
1928
+ };
1929
+ const pipeProcessor = (schema, ctx, _json, params) => {
1930
+ const def = schema._zod.def;
1931
+ const innerType = ctx.io === "input" ? def.in._zod.def.type === "transform" ? def.out : def.in : def.out;
1932
+ process(innerType, ctx, params);
1933
+ const seen = ctx.seen.get(schema);
1934
+ seen.ref = innerType;
1935
+ };
1936
+ const readonlyProcessor = (schema, ctx, json, params) => {
1937
+ const def = schema._zod.def;
1938
+ process(def.innerType, ctx, params);
1939
+ const seen = ctx.seen.get(schema);
1940
+ seen.ref = def.innerType;
1941
+ json.readOnly = true;
1942
+ };
1943
+ const optionalProcessor = (schema, ctx, _json, params) => {
1944
+ const def = schema._zod.def;
1945
+ process(def.innerType, ctx, params);
1946
+ const seen = ctx.seen.get(schema);
1947
+ seen.ref = def.innerType;
1948
+ };
1949
+ //#endregion
1950
+ //#region ../../node_modules/.pnpm/zod@4.3.6/node_modules/zod/v4/classic/errors.js
1951
+ const initializer = (inst, issues) => {
1952
+ $ZodError.init(inst, issues);
1953
+ inst.name = "ZodError";
1954
+ Object.defineProperties(inst, {
1955
+ format: { value: (mapper) => formatError(inst, mapper) },
1956
+ flatten: { value: (mapper) => flattenError(inst, mapper) },
1957
+ addIssue: { value: (issue) => {
1958
+ inst.issues.push(issue);
1959
+ inst.message = JSON.stringify(inst.issues, jsonStringifyReplacer, 2);
1960
+ } },
1961
+ addIssues: { value: (issues) => {
1962
+ inst.issues.push(...issues);
1963
+ inst.message = JSON.stringify(inst.issues, jsonStringifyReplacer, 2);
1964
+ } },
1965
+ isEmpty: { get() {
1966
+ return inst.issues.length === 0;
1967
+ } }
1968
+ });
1969
+ };
1970
+ $constructor("ZodError", initializer);
1971
+ const ZodRealError = $constructor("ZodError", initializer, { Parent: Error });
1972
+ //#endregion
1973
+ //#region ../../node_modules/.pnpm/zod@4.3.6/node_modules/zod/v4/classic/parse.js
1974
+ const parse = /* @__PURE__ */ _parse(ZodRealError);
1975
+ const parseAsync = /* @__PURE__ */ _parseAsync(ZodRealError);
1976
+ const safeParse = /* @__PURE__ */ _safeParse(ZodRealError);
1977
+ const safeParseAsync = /* @__PURE__ */ _safeParseAsync(ZodRealError);
1978
+ const encode = /* @__PURE__ */ _encode(ZodRealError);
1979
+ const decode = /* @__PURE__ */ _decode(ZodRealError);
1980
+ const encodeAsync = /* @__PURE__ */ _encodeAsync(ZodRealError);
1981
+ const decodeAsync = /* @__PURE__ */ _decodeAsync(ZodRealError);
1982
+ const safeEncode = /* @__PURE__ */ _safeEncode(ZodRealError);
1983
+ const safeDecode = /* @__PURE__ */ _safeDecode(ZodRealError);
1984
+ const safeEncodeAsync = /* @__PURE__ */ _safeEncodeAsync(ZodRealError);
1985
+ const safeDecodeAsync = /* @__PURE__ */ _safeDecodeAsync(ZodRealError);
1986
+ //#endregion
1987
+ //#region ../../node_modules/.pnpm/zod@4.3.6/node_modules/zod/v4/classic/schemas.js
1988
+ const ZodType = /* @__PURE__ */ $constructor("ZodType", (inst, def) => {
1989
+ $ZodType.init(inst, def);
1990
+ Object.assign(inst["~standard"], { jsonSchema: {
1991
+ input: createStandardJSONSchemaMethod(inst, "input"),
1992
+ output: createStandardJSONSchemaMethod(inst, "output")
1993
+ } });
1994
+ inst.toJSONSchema = createToJSONSchemaMethod(inst, {});
1995
+ inst.def = def;
1996
+ inst.type = def.type;
1997
+ Object.defineProperty(inst, "_def", { value: def });
1998
+ inst.check = (...checks) => {
1999
+ return inst.clone(mergeDefs(def, { checks: [...def.checks ?? [], ...checks.map((ch) => typeof ch === "function" ? { _zod: {
2000
+ check: ch,
2001
+ def: { check: "custom" },
2002
+ onattach: []
2003
+ } } : ch)] }), { parent: true });
2004
+ };
2005
+ inst.with = inst.check;
2006
+ inst.clone = (def, params) => clone(inst, def, params);
2007
+ inst.brand = () => inst;
2008
+ inst.register = ((reg, meta) => {
2009
+ reg.add(inst, meta);
2010
+ return inst;
2011
+ });
2012
+ inst.parse = (data, params) => parse(inst, data, params, { callee: inst.parse });
2013
+ inst.safeParse = (data, params) => safeParse(inst, data, params);
2014
+ inst.parseAsync = async (data, params) => parseAsync(inst, data, params, { callee: inst.parseAsync });
2015
+ inst.safeParseAsync = async (data, params) => safeParseAsync(inst, data, params);
2016
+ inst.spa = inst.safeParseAsync;
2017
+ inst.encode = (data, params) => encode(inst, data, params);
2018
+ inst.decode = (data, params) => decode(inst, data, params);
2019
+ inst.encodeAsync = async (data, params) => encodeAsync(inst, data, params);
2020
+ inst.decodeAsync = async (data, params) => decodeAsync(inst, data, params);
2021
+ inst.safeEncode = (data, params) => safeEncode(inst, data, params);
2022
+ inst.safeDecode = (data, params) => safeDecode(inst, data, params);
2023
+ inst.safeEncodeAsync = async (data, params) => safeEncodeAsync(inst, data, params);
2024
+ inst.safeDecodeAsync = async (data, params) => safeDecodeAsync(inst, data, params);
2025
+ inst.refine = (check, params) => inst.check(refine(check, params));
2026
+ inst.superRefine = (refinement) => inst.check(superRefine(refinement));
2027
+ inst.overwrite = (fn) => inst.check(/* @__PURE__ */ _overwrite(fn));
2028
+ inst.optional = () => optional(inst);
2029
+ inst.exactOptional = () => exactOptional(inst);
2030
+ inst.nullable = () => nullable(inst);
2031
+ inst.nullish = () => optional(nullable(inst));
2032
+ inst.nonoptional = (params) => nonoptional(inst, params);
2033
+ inst.array = () => array(inst);
2034
+ inst.or = (arg) => union([inst, arg]);
2035
+ inst.and = (arg) => intersection(inst, arg);
2036
+ inst.transform = (tx) => pipe(inst, transform(tx));
2037
+ inst.default = (def) => _default(inst, def);
2038
+ inst.prefault = (def) => prefault(inst, def);
2039
+ inst.catch = (params) => _catch(inst, params);
2040
+ inst.pipe = (target) => pipe(inst, target);
2041
+ inst.readonly = () => readonly(inst);
2042
+ inst.describe = (description) => {
2043
+ const cl = inst.clone();
2044
+ globalRegistry.add(cl, { description });
2045
+ return cl;
2046
+ };
2047
+ Object.defineProperty(inst, "description", {
2048
+ get() {
2049
+ return globalRegistry.get(inst)?.description;
2050
+ },
2051
+ configurable: true
2052
+ });
2053
+ inst.meta = (...args) => {
2054
+ if (args.length === 0) return globalRegistry.get(inst);
2055
+ const cl = inst.clone();
2056
+ globalRegistry.add(cl, args[0]);
2057
+ return cl;
2058
+ };
2059
+ inst.isOptional = () => inst.safeParse(void 0).success;
2060
+ inst.isNullable = () => inst.safeParse(null).success;
2061
+ inst.apply = (fn) => fn(inst);
2062
+ return inst;
2063
+ });
2064
+ const ZodUnknown = /* @__PURE__ */ $constructor("ZodUnknown", (inst, def) => {
2065
+ $ZodUnknown.init(inst, def);
2066
+ ZodType.init(inst, def);
2067
+ inst._zod.processJSONSchema = (ctx, json, params) => unknownProcessor(inst, ctx, json, params);
2068
+ });
2069
+ function unknown() {
2070
+ return /* @__PURE__ */ _unknown(ZodUnknown);
2071
+ }
2072
+ const ZodNever = /* @__PURE__ */ $constructor("ZodNever", (inst, def) => {
2073
+ $ZodNever.init(inst, def);
2074
+ ZodType.init(inst, def);
2075
+ inst._zod.processJSONSchema = (ctx, json, params) => neverProcessor(inst, ctx, json, params);
2076
+ });
2077
+ function never(params) {
2078
+ return /* @__PURE__ */ _never(ZodNever, params);
2079
+ }
2080
+ const ZodArray = /* @__PURE__ */ $constructor("ZodArray", (inst, def) => {
2081
+ $ZodArray.init(inst, def);
2082
+ ZodType.init(inst, def);
2083
+ inst._zod.processJSONSchema = (ctx, json, params) => arrayProcessor(inst, ctx, json, params);
2084
+ inst.element = def.element;
2085
+ inst.min = (minLength, params) => inst.check(/* @__PURE__ */ _minLength(minLength, params));
2086
+ inst.nonempty = (params) => inst.check(/* @__PURE__ */ _minLength(1, params));
2087
+ inst.max = (maxLength, params) => inst.check(/* @__PURE__ */ _maxLength(maxLength, params));
2088
+ inst.length = (len, params) => inst.check(/* @__PURE__ */ _length(len, params));
2089
+ inst.unwrap = () => inst.element;
2090
+ });
2091
+ function array(element, params) {
2092
+ return /* @__PURE__ */ _array(ZodArray, element, params);
2093
+ }
2094
+ const ZodObject = /* @__PURE__ */ $constructor("ZodObject", (inst, def) => {
2095
+ $ZodObjectJIT.init(inst, def);
2096
+ ZodType.init(inst, def);
2097
+ inst._zod.processJSONSchema = (ctx, json, params) => objectProcessor(inst, ctx, json, params);
2098
+ defineLazy(inst, "shape", () => {
2099
+ return def.shape;
2100
+ });
2101
+ inst.keyof = () => _enum(Object.keys(inst._zod.def.shape));
2102
+ inst.catchall = (catchall) => inst.clone({
2103
+ ...inst._zod.def,
2104
+ catchall
2105
+ });
2106
+ inst.passthrough = () => inst.clone({
2107
+ ...inst._zod.def,
2108
+ catchall: unknown()
2109
+ });
2110
+ inst.loose = () => inst.clone({
2111
+ ...inst._zod.def,
2112
+ catchall: unknown()
2113
+ });
2114
+ inst.strict = () => inst.clone({
2115
+ ...inst._zod.def,
2116
+ catchall: never()
2117
+ });
2118
+ inst.strip = () => inst.clone({
2119
+ ...inst._zod.def,
2120
+ catchall: void 0
2121
+ });
2122
+ inst.extend = (incoming) => {
2123
+ return extend(inst, incoming);
2124
+ };
2125
+ inst.safeExtend = (incoming) => {
2126
+ return safeExtend(inst, incoming);
2127
+ };
2128
+ inst.merge = (other) => merge(inst, other);
2129
+ inst.pick = (mask) => pick(inst, mask);
2130
+ inst.omit = (mask) => omit(inst, mask);
2131
+ inst.partial = (...args) => partial(ZodOptional, inst, args[0]);
2132
+ inst.required = (...args) => required(ZodNonOptional, inst, args[0]);
2133
+ });
2134
+ function object(shape, params) {
2135
+ return new ZodObject({
2136
+ type: "object",
2137
+ shape: shape ?? {},
2138
+ ...normalizeParams(params)
2139
+ });
2140
+ }
2141
+ const ZodUnion = /* @__PURE__ */ $constructor("ZodUnion", (inst, def) => {
2142
+ $ZodUnion.init(inst, def);
2143
+ ZodType.init(inst, def);
2144
+ inst._zod.processJSONSchema = (ctx, json, params) => unionProcessor(inst, ctx, json, params);
2145
+ inst.options = def.options;
2146
+ });
2147
+ function union(options, params) {
2148
+ return new ZodUnion({
2149
+ type: "union",
2150
+ options,
2151
+ ...normalizeParams(params)
2152
+ });
2153
+ }
2154
+ const ZodIntersection = /* @__PURE__ */ $constructor("ZodIntersection", (inst, def) => {
2155
+ $ZodIntersection.init(inst, def);
2156
+ ZodType.init(inst, def);
2157
+ inst._zod.processJSONSchema = (ctx, json, params) => intersectionProcessor(inst, ctx, json, params);
2158
+ });
2159
+ function intersection(left, right) {
2160
+ return new ZodIntersection({
2161
+ type: "intersection",
2162
+ left,
2163
+ right
2164
+ });
2165
+ }
2166
+ const ZodEnum = /* @__PURE__ */ $constructor("ZodEnum", (inst, def) => {
2167
+ $ZodEnum.init(inst, def);
2168
+ ZodType.init(inst, def);
2169
+ inst._zod.processJSONSchema = (ctx, json, params) => enumProcessor(inst, ctx, json, params);
2170
+ inst.enum = def.entries;
2171
+ inst.options = Object.values(def.entries);
2172
+ const keys = new Set(Object.keys(def.entries));
2173
+ inst.extract = (values, params) => {
2174
+ const newEntries = {};
2175
+ for (const value of values) if (keys.has(value)) newEntries[value] = def.entries[value];
2176
+ else throw new Error(`Key ${value} not found in enum`);
2177
+ return new ZodEnum({
2178
+ ...def,
2179
+ checks: [],
2180
+ ...normalizeParams(params),
2181
+ entries: newEntries
2182
+ });
2183
+ };
2184
+ inst.exclude = (values, params) => {
2185
+ const newEntries = { ...def.entries };
2186
+ for (const value of values) if (keys.has(value)) delete newEntries[value];
2187
+ else throw new Error(`Key ${value} not found in enum`);
2188
+ return new ZodEnum({
2189
+ ...def,
2190
+ checks: [],
2191
+ ...normalizeParams(params),
2192
+ entries: newEntries
2193
+ });
2194
+ };
2195
+ });
2196
+ function _enum(values, params) {
2197
+ return new ZodEnum({
2198
+ type: "enum",
2199
+ entries: Array.isArray(values) ? Object.fromEntries(values.map((v) => [v, v])) : values,
2200
+ ...normalizeParams(params)
2201
+ });
2202
+ }
2203
+ const ZodTransform = /* @__PURE__ */ $constructor("ZodTransform", (inst, def) => {
2204
+ $ZodTransform.init(inst, def);
2205
+ ZodType.init(inst, def);
2206
+ inst._zod.processJSONSchema = (ctx, json, params) => transformProcessor(inst, ctx, json, params);
2207
+ inst._zod.parse = (payload, _ctx) => {
2208
+ if (_ctx.direction === "backward") throw new $ZodEncodeError(inst.constructor.name);
2209
+ payload.addIssue = (issue$1) => {
2210
+ if (typeof issue$1 === "string") payload.issues.push(issue(issue$1, payload.value, def));
2211
+ else {
2212
+ const _issue = issue$1;
2213
+ if (_issue.fatal) _issue.continue = false;
2214
+ _issue.code ?? (_issue.code = "custom");
2215
+ _issue.input ?? (_issue.input = payload.value);
2216
+ _issue.inst ?? (_issue.inst = inst);
2217
+ payload.issues.push(issue(_issue));
2218
+ }
2219
+ };
2220
+ const output = def.transform(payload.value, payload);
2221
+ if (output instanceof Promise) return output.then((output) => {
2222
+ payload.value = output;
2223
+ return payload;
2224
+ });
2225
+ payload.value = output;
2226
+ return payload;
2227
+ };
2228
+ });
2229
+ function transform(fn) {
2230
+ return new ZodTransform({
2231
+ type: "transform",
2232
+ transform: fn
2233
+ });
2234
+ }
2235
+ const ZodOptional = /* @__PURE__ */ $constructor("ZodOptional", (inst, def) => {
2236
+ $ZodOptional.init(inst, def);
2237
+ ZodType.init(inst, def);
2238
+ inst._zod.processJSONSchema = (ctx, json, params) => optionalProcessor(inst, ctx, json, params);
2239
+ inst.unwrap = () => inst._zod.def.innerType;
2240
+ });
2241
+ function optional(innerType) {
2242
+ return new ZodOptional({
2243
+ type: "optional",
2244
+ innerType
2245
+ });
2246
+ }
2247
+ const ZodExactOptional = /* @__PURE__ */ $constructor("ZodExactOptional", (inst, def) => {
2248
+ $ZodExactOptional.init(inst, def);
2249
+ ZodType.init(inst, def);
2250
+ inst._zod.processJSONSchema = (ctx, json, params) => optionalProcessor(inst, ctx, json, params);
2251
+ inst.unwrap = () => inst._zod.def.innerType;
2252
+ });
2253
+ function exactOptional(innerType) {
2254
+ return new ZodExactOptional({
2255
+ type: "optional",
2256
+ innerType
2257
+ });
2258
+ }
2259
+ const ZodNullable = /* @__PURE__ */ $constructor("ZodNullable", (inst, def) => {
2260
+ $ZodNullable.init(inst, def);
2261
+ ZodType.init(inst, def);
2262
+ inst._zod.processJSONSchema = (ctx, json, params) => nullableProcessor(inst, ctx, json, params);
2263
+ inst.unwrap = () => inst._zod.def.innerType;
2264
+ });
2265
+ function nullable(innerType) {
2266
+ return new ZodNullable({
2267
+ type: "nullable",
2268
+ innerType
2269
+ });
2270
+ }
2271
+ const ZodDefault = /* @__PURE__ */ $constructor("ZodDefault", (inst, def) => {
2272
+ $ZodDefault.init(inst, def);
2273
+ ZodType.init(inst, def);
2274
+ inst._zod.processJSONSchema = (ctx, json, params) => defaultProcessor(inst, ctx, json, params);
2275
+ inst.unwrap = () => inst._zod.def.innerType;
2276
+ inst.removeDefault = inst.unwrap;
2277
+ });
2278
+ function _default(innerType, defaultValue) {
2279
+ return new ZodDefault({
2280
+ type: "default",
2281
+ innerType,
2282
+ get defaultValue() {
2283
+ return typeof defaultValue === "function" ? defaultValue() : shallowClone(defaultValue);
2284
+ }
2285
+ });
2286
+ }
2287
+ const ZodPrefault = /* @__PURE__ */ $constructor("ZodPrefault", (inst, def) => {
2288
+ $ZodPrefault.init(inst, def);
2289
+ ZodType.init(inst, def);
2290
+ inst._zod.processJSONSchema = (ctx, json, params) => prefaultProcessor(inst, ctx, json, params);
2291
+ inst.unwrap = () => inst._zod.def.innerType;
2292
+ });
2293
+ function prefault(innerType, defaultValue) {
2294
+ return new ZodPrefault({
2295
+ type: "prefault",
2296
+ innerType,
2297
+ get defaultValue() {
2298
+ return typeof defaultValue === "function" ? defaultValue() : shallowClone(defaultValue);
2299
+ }
2300
+ });
2301
+ }
2302
+ const ZodNonOptional = /* @__PURE__ */ $constructor("ZodNonOptional", (inst, def) => {
2303
+ $ZodNonOptional.init(inst, def);
2304
+ ZodType.init(inst, def);
2305
+ inst._zod.processJSONSchema = (ctx, json, params) => nonoptionalProcessor(inst, ctx, json, params);
2306
+ inst.unwrap = () => inst._zod.def.innerType;
2307
+ });
2308
+ function nonoptional(innerType, params) {
2309
+ return new ZodNonOptional({
2310
+ type: "nonoptional",
2311
+ innerType,
2312
+ ...normalizeParams(params)
2313
+ });
2314
+ }
2315
+ const ZodCatch = /* @__PURE__ */ $constructor("ZodCatch", (inst, def) => {
2316
+ $ZodCatch.init(inst, def);
2317
+ ZodType.init(inst, def);
2318
+ inst._zod.processJSONSchema = (ctx, json, params) => catchProcessor(inst, ctx, json, params);
2319
+ inst.unwrap = () => inst._zod.def.innerType;
2320
+ inst.removeCatch = inst.unwrap;
2321
+ });
2322
+ function _catch(innerType, catchValue) {
2323
+ return new ZodCatch({
2324
+ type: "catch",
2325
+ innerType,
2326
+ catchValue: typeof catchValue === "function" ? catchValue : () => catchValue
2327
+ });
2328
+ }
2329
+ const ZodPipe = /* @__PURE__ */ $constructor("ZodPipe", (inst, def) => {
2330
+ $ZodPipe.init(inst, def);
2331
+ ZodType.init(inst, def);
2332
+ inst._zod.processJSONSchema = (ctx, json, params) => pipeProcessor(inst, ctx, json, params);
2333
+ inst.in = def.in;
2334
+ inst.out = def.out;
2335
+ });
2336
+ function pipe(in_, out) {
2337
+ return new ZodPipe({
2338
+ type: "pipe",
2339
+ in: in_,
2340
+ out
2341
+ });
2342
+ }
2343
+ const ZodReadonly = /* @__PURE__ */ $constructor("ZodReadonly", (inst, def) => {
2344
+ $ZodReadonly.init(inst, def);
2345
+ ZodType.init(inst, def);
2346
+ inst._zod.processJSONSchema = (ctx, json, params) => readonlyProcessor(inst, ctx, json, params);
2347
+ inst.unwrap = () => inst._zod.def.innerType;
2348
+ });
2349
+ function readonly(innerType) {
2350
+ return new ZodReadonly({
2351
+ type: "readonly",
2352
+ innerType
2353
+ });
2354
+ }
2355
+ const ZodCustom = /* @__PURE__ */ $constructor("ZodCustom", (inst, def) => {
2356
+ $ZodCustom.init(inst, def);
2357
+ ZodType.init(inst, def);
2358
+ inst._zod.processJSONSchema = (ctx, json, params) => customProcessor(inst, ctx, json, params);
2359
+ });
2360
+ function refine(fn, _params = {}) {
2361
+ return /* @__PURE__ */ _refine(ZodCustom, fn, _params);
2362
+ }
2363
+ function superRefine(fn) {
2364
+ return /* @__PURE__ */ _superRefine(fn);
2365
+ }
2366
+ //#endregion
2367
+ //#region src/channel.ts
2368
+ const discordArgsSchema = object({ input: unknown() });
2369
+ const validateDiscordArgs = (args) => discordArgsSchema.parse(args);
2370
+ const discordChannel = () => defineChannel({
2371
+ name: "discord",
2372
+ slots: {
2373
+ body: slot.resolver(),
2374
+ embeds: slot.resolver().optional(),
2375
+ username: slot.resolver().optional(),
2376
+ avatarUrl: slot.resolver().optional(),
2377
+ attachments: slot.resolver().optional()
2378
+ },
2379
+ validateArgs: validateDiscordArgs,
2380
+ render: ({ runtime, args: _args }) => {
2381
+ const result = { body: runtime.body };
2382
+ if (runtime.embeds !== void 0) result.embeds = runtime.embeds;
2383
+ if (runtime.username !== void 0) result.username = runtime.username;
2384
+ if (runtime.avatarUrl !== void 0) result.avatarUrl = runtime.avatarUrl;
2385
+ if (runtime.attachments !== void 0) result.attachments = runtime.attachments;
2386
+ return result;
2387
+ }
2388
+ });
2389
+ //#endregion
2390
+ //#region src/transports/mock.ts
2391
+ const mockDiscordTransport = () => {
2392
+ let counter = 0;
2393
+ const messages = [];
2394
+ const base = createMockTransport({
2395
+ name: "mock-discord",
2396
+ reply: (rendered) => {
2397
+ counter += 1;
2398
+ const id = `discord-mock-${counter}`;
2399
+ messages.push({
2400
+ ...rendered,
2401
+ id
2402
+ });
2403
+ return {
2404
+ transportMessageId: id,
2405
+ raw: {}
2406
+ };
2407
+ }
2408
+ });
2409
+ return Object.assign(base, { get messages() {
2410
+ return messages;
2411
+ } });
2412
+ };
2413
+ //#endregion
2414
+ //#region src/transports/discord.ts
2415
+ const DEFAULT_TIMEOUT_MS = 3e4;
2416
+ const mapError = (status) => {
2417
+ if (status === 400) return {
2418
+ code: "VALIDATION",
2419
+ retriable: false
2420
+ };
2421
+ if (status === 401 || status === 403 || status === 404) return {
2422
+ code: "CONFIG",
2423
+ retriable: false
2424
+ };
2425
+ if (status === 429) return {
2426
+ code: "RATE_LIMITED",
2427
+ retriable: true
2428
+ };
2429
+ return {
2430
+ code: "PROVIDER",
2431
+ retriable: status >= 500
2432
+ };
2433
+ };
2434
+ const buildJsonPayload = (rendered, opts) => {
2435
+ const body = { content: rendered.body };
2436
+ if (rendered.embeds?.length) body.embeds = rendered.embeds;
2437
+ const username = rendered.username ?? opts.username;
2438
+ if (username) body.username = username;
2439
+ const avatarUrl = rendered.avatarUrl ?? opts.avatarUrl;
2440
+ if (avatarUrl) body.avatar_url = avatarUrl;
2441
+ if (rendered.attachments?.length) body.attachments = rendered.attachments.map((att, i) => ({
2442
+ id: i,
2443
+ filename: att.filename,
2444
+ ...att.description ? { description: att.description } : {}
2445
+ }));
2446
+ return body;
2447
+ };
2448
+ const buildRequest = (rendered, opts) => {
2449
+ const payload = buildJsonPayload(rendered, opts);
2450
+ if (!rendered.attachments?.length) return {
2451
+ body: JSON.stringify(payload),
2452
+ headers: { "Content-Type": "application/json" }
2453
+ };
2454
+ const form = new FormData();
2455
+ form.append("payload_json", JSON.stringify(payload));
2456
+ for (const [i, att] of rendered.attachments.entries()) {
2457
+ const raw = typeof att.content === "string" ? att.content : new Uint8Array(att.content);
2458
+ const file = new File([raw], att.filename, { type: att.contentType ?? "application/octet-stream" });
2459
+ form.append(`files[${i}]`, file);
2460
+ }
2461
+ return { body: form };
2462
+ };
2463
+ const discordTransport = (opts) => {
2464
+ const parsed = new URL(opts.webhookUrl);
2465
+ if (opts.wait === true) parsed.searchParams.set("wait", "true");
2466
+ const url = parsed.toString();
2467
+ const log = (opts.logger ?? consoleLogger()).child({ component: "discord" });
2468
+ const http = createHttpClient({
2469
+ ...opts.http,
2470
+ timeoutMs: opts.http?.timeoutMs ?? DEFAULT_TIMEOUT_MS
2471
+ });
2472
+ return createTransport({
2473
+ name: "discord",
2474
+ async send(rendered, ctx) {
2475
+ const { body, headers } = buildRequest(rendered, opts);
2476
+ const result = await http.request(url, {
2477
+ method: "POST",
2478
+ body,
2479
+ headers
2480
+ });
2481
+ if (!result.ok) {
2482
+ if (result.kind === "network") {
2483
+ log.error("Discord fetch failed", {
2484
+ err: result.cause,
2485
+ route: ctx.route
2486
+ });
2487
+ return {
2488
+ ok: false,
2489
+ error: new NotifyRpcProviderError({
2490
+ message: `Discord transport: ${result.timedOut ? "request timed out" : `network error: ${result.cause.message}`}`,
2491
+ code: result.timedOut ? "TIMEOUT" : "PROVIDER",
2492
+ provider: "discord",
2493
+ retriable: true,
2494
+ route: ctx.route,
2495
+ messageId: ctx.messageId,
2496
+ cause: result.cause
2497
+ })
2498
+ };
2499
+ }
2500
+ const errData = result.body;
2501
+ const { code, retriable } = mapError(result.status);
2502
+ const retryAfterBody = errData.retry_after;
2503
+ const retryAfterMs = retryAfterBody ? Math.ceil(retryAfterBody * 1e3) : void 0;
2504
+ const suffix = retryAfterBody ? ` (retry after ${retryAfterBody}s)` : "";
2505
+ const errorMessage = `Discord transport: ${errData.message ?? `HTTP ${result.status}`}${suffix}`;
2506
+ log.error(errorMessage, {
2507
+ err: {
2508
+ status: result.status,
2509
+ code: errData.code,
2510
+ message: errData.message
2511
+ },
2512
+ route: ctx.route
2513
+ });
2514
+ return {
2515
+ ok: false,
2516
+ error: new NotifyRpcProviderError({
2517
+ message: errorMessage,
2518
+ code,
2519
+ provider: "discord",
2520
+ httpStatus: result.status,
2521
+ providerCode: errData.code,
2522
+ retryAfterMs,
2523
+ retriable,
2524
+ route: ctx.route,
2525
+ messageId: ctx.messageId
2526
+ })
2527
+ };
2528
+ }
2529
+ if (!result.data || !("id" in result.data)) return {
2530
+ ok: true,
2531
+ data: {
2532
+ transportMessageId: void 0,
2533
+ raw: {}
2534
+ }
2535
+ };
2536
+ return {
2537
+ ok: true,
2538
+ data: {
2539
+ transportMessageId: result.data.id,
2540
+ raw: result.data
2541
+ }
2542
+ };
2543
+ }
2544
+ });
2545
+ };
2546
+ //#endregion
2547
+ //#region src/is-retriable.ts
2548
+ const isDiscordRetriable = (err) => {
2549
+ if (err instanceof NotifyRpcProviderError) return err.retriable;
2550
+ return true;
2551
+ };
2552
+ //#endregion
2553
+ export { discordChannel, discordTransport, isDiscordRetriable, mockDiscordTransport };