@dragonmastery/tamer 0.1.2 → 0.28.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.
Files changed (89) hide show
  1. package/README.md +569 -18
  2. package/dist/CFApiClient-DhbyyV71.mjs +868 -0
  3. package/dist/CFApiClient-DhbyyV71.mjs.map +1 -0
  4. package/dist/StateManager-DTqtLLVX.mjs +760 -0
  5. package/dist/StateManager-DTqtLLVX.mjs.map +1 -0
  6. package/dist/apply-B0b_jjGv.mjs +423 -0
  7. package/dist/apply-B0b_jjGv.mjs.map +1 -0
  8. package/dist/applyTarget-BetDYdeS.mjs +152 -0
  9. package/dist/applyTarget-BetDYdeS.mjs.map +1 -0
  10. package/dist/bootstrap-CBzPilB1.mjs +33 -0
  11. package/dist/bootstrap-CBzPilB1.mjs.map +1 -0
  12. package/dist/buildDispatchUploadForm-BoUB93b3.mjs +38 -0
  13. package/dist/buildDispatchUploadForm-BoUB93b3.mjs.map +1 -0
  14. package/dist/cloudflareSnapshot-B4FOaNr0.mjs +163 -0
  15. package/dist/cloudflareSnapshot-B4FOaNr0.mjs.map +1 -0
  16. package/dist/deploy-gHEQxhmx.mjs +119 -0
  17. package/dist/deploy-gHEQxhmx.mjs.map +1 -0
  18. package/dist/destroy-B21f3wgq.mjs +215 -0
  19. package/dist/destroy-B21f3wgq.mjs.map +1 -0
  20. package/dist/destroy-tenant-BW2nasnK.mjs +103 -0
  21. package/dist/destroy-tenant-BW2nasnK.mjs.map +1 -0
  22. package/dist/dev-Dt26nzMJ.mjs +103 -0
  23. package/dist/dev-Dt26nzMJ.mjs.map +1 -0
  24. package/dist/dns-records.resolve-C2T0m4NG.mjs +3 -0
  25. package/dist/dns-records.resolve-DwBR_1WI.mjs +47 -0
  26. package/dist/dns-records.resolve-DwBR_1WI.mjs.map +1 -0
  27. package/dist/dns-records.sync-Bpzz9H0s.mjs +75 -0
  28. package/dist/dns-records.sync-Bpzz9H0s.mjs.map +1 -0
  29. package/dist/doctor-C_hs7k2D.mjs +34 -0
  30. package/dist/doctor-C_hs7k2D.mjs.map +1 -0
  31. package/dist/drift-D5qzCTft.mjs +10 -0
  32. package/dist/drift-D8ZrSgTn.mjs +323 -0
  33. package/dist/drift-D8ZrSgTn.mjs.map +1 -0
  34. package/dist/events-BSwGdkGj.mjs +68 -0
  35. package/dist/events-BSwGdkGj.mjs.map +1 -0
  36. package/dist/fetchStackImports-B4ZJahOt.mjs +3817 -0
  37. package/dist/fetchStackImports-B4ZJahOt.mjs.map +1 -0
  38. package/dist/generator-CIMbcPzv.mjs +77 -0
  39. package/dist/generator-CIMbcPzv.mjs.map +1 -0
  40. package/dist/import-BrduwA9Z.mjs +164 -0
  41. package/dist/import-BrduwA9Z.mjs.map +1 -0
  42. package/dist/index.d.mts +5568 -1297
  43. package/dist/index.d.mts.map +1 -1
  44. package/dist/index.mjs +18 -1
  45. package/dist/index.mjs.map +1 -0
  46. package/dist/loader-DP7yXqT6.mjs +518 -0
  47. package/dist/loader-DP7yXqT6.mjs.map +1 -0
  48. package/dist/logpush-job-xS7270FZ.mjs +1106 -0
  49. package/dist/logpush-job-xS7270FZ.mjs.map +1 -0
  50. package/dist/migrate-CahG6BYV.mjs +87 -0
  51. package/dist/migrate-CahG6BYV.mjs.map +1 -0
  52. package/dist/normalize-Bx0bpFop.mjs +236 -0
  53. package/dist/normalize-Bx0bpFop.mjs.map +1 -0
  54. package/dist/plan-DWvsvy1U.mjs +453 -0
  55. package/dist/plan-DWvsvy1U.mjs.map +1 -0
  56. package/dist/planFormat-CJw8Kq2s.mjs +119 -0
  57. package/dist/planFormat-CJw8Kq2s.mjs.map +1 -0
  58. package/dist/provision-tenant-WTKo93Y0.mjs +192 -0
  59. package/dist/provision-tenant-WTKo93Y0.mjs.map +1 -0
  60. package/dist/r2S3EmptyBucket-DD81ZWQ7.mjs +92 -0
  61. package/dist/r2S3EmptyBucket-DD81ZWQ7.mjs.map +1 -0
  62. package/dist/stackOutputs-W9mnnJuj.mjs +69 -0
  63. package/dist/stackOutputs-W9mnnJuj.mjs.map +1 -0
  64. package/dist/status-DLwREPjb.mjs +198 -0
  65. package/dist/status-DLwREPjb.mjs.map +1 -0
  66. package/dist/sync-f2K2blwm.mjs +90 -0
  67. package/dist/sync-f2K2blwm.mjs.map +1 -0
  68. package/dist/tamer.d.mts +1 -0
  69. package/dist/tamer.mjs +4553 -0
  70. package/dist/tamer.mjs.map +1 -0
  71. package/dist/tamerArtifactsR2-Ccgplu2Q.mjs +52 -0
  72. package/dist/tamerArtifactsR2-Ccgplu2Q.mjs.map +1 -0
  73. package/dist/types-CqxqYnrT.mjs +44 -0
  74. package/dist/types-CqxqYnrT.mjs.map +1 -0
  75. package/dist/verifyPlanFile-c16z1AMH.mjs +33 -0
  76. package/dist/verifyPlanFile-c16z1AMH.mjs.map +1 -0
  77. package/dist/wfp-delete-DysvX1u7.mjs +36 -0
  78. package/dist/wfp-delete-DysvX1u7.mjs.map +1 -0
  79. package/dist/wfp-put-jaVd_LjO.mjs +52 -0
  80. package/dist/wfp-put-jaVd_LjO.mjs.map +1 -0
  81. package/dist/worker-route-Be2IvOdr.mjs +263 -0
  82. package/dist/worker-route-Be2IvOdr.mjs.map +1 -0
  83. package/dist/workers-aGILs77X.mjs +87 -0
  84. package/dist/workers-aGILs77X.mjs.map +1 -0
  85. package/dist/wranglerSpawn-DmEz0ldT.mjs +24 -0
  86. package/dist/wranglerSpawn-DmEz0ldT.mjs.map +1 -0
  87. package/dist/zoneResolver-VoxLHM4N.mjs +32 -0
  88. package/dist/zoneResolver-VoxLHM4N.mjs.map +1 -0
  89. package/package.json +38 -3
package/dist/tamer.mjs ADDED
@@ -0,0 +1,4553 @@
1
+ #!/usr/bin/env node
2
+ //#region node_modules/zod/v4/core/core.js
3
+ /** A special constant with type `never` */
4
+ const NEVER = Object.freeze({ status: "aborted" });
5
+ function $constructor(name, initializer$2, params) {
6
+ function init(inst, def) {
7
+ if (!inst._zod) Object.defineProperty(inst, "_zod", {
8
+ value: {
9
+ def,
10
+ constr: _,
11
+ traits: /* @__PURE__ */ new Set()
12
+ },
13
+ enumerable: false
14
+ });
15
+ if (inst._zod.traits.has(name)) return;
16
+ inst._zod.traits.add(name);
17
+ initializer$2(inst, def);
18
+ const proto = _.prototype;
19
+ const keys = Object.keys(proto);
20
+ for (let i = 0; i < keys.length; i++) {
21
+ const k = keys[i];
22
+ if (!(k in inst)) inst[k] = proto[k].bind(inst);
23
+ }
24
+ }
25
+ const Parent = params?.Parent ?? Object;
26
+ class Definition extends Parent {}
27
+ Object.defineProperty(Definition, "name", { value: name });
28
+ function _(def) {
29
+ var _a$1;
30
+ const inst = params?.Parent ? new Definition() : this;
31
+ init(inst, def);
32
+ (_a$1 = inst._zod).deferred ?? (_a$1.deferred = []);
33
+ for (const fn of inst._zod.deferred) fn();
34
+ return inst;
35
+ }
36
+ Object.defineProperty(_, "init", { value: init });
37
+ Object.defineProperty(_, Symbol.hasInstance, { value: (inst) => {
38
+ if (params?.Parent && inst instanceof params.Parent) return true;
39
+ return inst?._zod?.traits?.has(name);
40
+ } });
41
+ Object.defineProperty(_, "name", { value: name });
42
+ return _;
43
+ }
44
+ var $ZodAsyncError = class extends Error {
45
+ constructor() {
46
+ super(`Encountered Promise during synchronous parse. Use .parseAsync() instead.`);
47
+ }
48
+ };
49
+ var $ZodEncodeError = class extends Error {
50
+ constructor(name) {
51
+ super(`Encountered unidirectional transform during encode: ${name}`);
52
+ this.name = "ZodEncodeError";
53
+ }
54
+ };
55
+ const globalConfig = {};
56
+ function config(newConfig) {
57
+ if (newConfig) Object.assign(globalConfig, newConfig);
58
+ return globalConfig;
59
+ }
60
+
61
+ //#endregion
62
+ //#region node_modules/zod/v4/core/util.js
63
+ function getEnumValues(entries) {
64
+ const numericValues = Object.values(entries).filter((v) => typeof v === "number");
65
+ return Object.entries(entries).filter(([k, _]) => numericValues.indexOf(+k) === -1).map(([_, v]) => v);
66
+ }
67
+ function jsonStringifyReplacer(_, value) {
68
+ if (typeof value === "bigint") return value.toString();
69
+ return value;
70
+ }
71
+ function cached(getter) {
72
+ return { get value() {
73
+ {
74
+ const value = getter();
75
+ Object.defineProperty(this, "value", { value });
76
+ return value;
77
+ }
78
+ throw new Error("cached value already set");
79
+ } };
80
+ }
81
+ function nullish(input) {
82
+ return input === null || input === void 0;
83
+ }
84
+ function cleanRegex(source) {
85
+ const start = source.startsWith("^") ? 1 : 0;
86
+ const end = source.endsWith("$") ? source.length - 1 : source.length;
87
+ return source.slice(start, end);
88
+ }
89
+ function floatSafeRemainder(val, step) {
90
+ const valDecCount = (val.toString().split(".")[1] || "").length;
91
+ const stepString = step.toString();
92
+ let stepDecCount = (stepString.split(".")[1] || "").length;
93
+ if (stepDecCount === 0 && /\d?e-\d?/.test(stepString)) {
94
+ const match = stepString.match(/\d?e-(\d?)/);
95
+ if (match?.[1]) stepDecCount = Number.parseInt(match[1]);
96
+ }
97
+ const decCount = valDecCount > stepDecCount ? valDecCount : stepDecCount;
98
+ return Number.parseInt(val.toFixed(decCount).replace(".", "")) % Number.parseInt(step.toFixed(decCount).replace(".", "")) / 10 ** decCount;
99
+ }
100
+ const EVALUATING = Symbol("evaluating");
101
+ function defineLazy(object$1, key, getter) {
102
+ let value = void 0;
103
+ Object.defineProperty(object$1, key, {
104
+ get() {
105
+ if (value === EVALUATING) return;
106
+ if (value === void 0) {
107
+ value = EVALUATING;
108
+ value = getter();
109
+ }
110
+ return value;
111
+ },
112
+ set(v) {
113
+ Object.defineProperty(object$1, key, { value: v });
114
+ },
115
+ configurable: true
116
+ });
117
+ }
118
+ function assignProp(target, prop, value) {
119
+ Object.defineProperty(target, prop, {
120
+ value,
121
+ writable: true,
122
+ enumerable: true,
123
+ configurable: true
124
+ });
125
+ }
126
+ function mergeDefs(...defs) {
127
+ const mergedDescriptors = {};
128
+ for (const def of defs) {
129
+ const descriptors = Object.getOwnPropertyDescriptors(def);
130
+ Object.assign(mergedDescriptors, descriptors);
131
+ }
132
+ return Object.defineProperties({}, mergedDescriptors);
133
+ }
134
+ function esc(str) {
135
+ return JSON.stringify(str);
136
+ }
137
+ function slugify(input) {
138
+ return input.toLowerCase().trim().replace(/[^\w\s-]/g, "").replace(/[\s_-]+/g, "-").replace(/^-+|-+$/g, "");
139
+ }
140
+ const captureStackTrace = "captureStackTrace" in Error ? Error.captureStackTrace : (..._args) => {};
141
+ function isObject(data) {
142
+ return typeof data === "object" && data !== null && !Array.isArray(data);
143
+ }
144
+ const allowsEval = cached(() => {
145
+ if (typeof navigator !== "undefined" && navigator?.userAgent?.includes("Cloudflare")) return false;
146
+ try {
147
+ new Function("");
148
+ return true;
149
+ } catch (_) {
150
+ return false;
151
+ }
152
+ });
153
+ function isPlainObject(o) {
154
+ if (isObject(o) === false) return false;
155
+ const ctor = o.constructor;
156
+ if (ctor === void 0) return true;
157
+ if (typeof ctor !== "function") return true;
158
+ const prot = ctor.prototype;
159
+ if (isObject(prot) === false) return false;
160
+ if (Object.prototype.hasOwnProperty.call(prot, "isPrototypeOf") === false) return false;
161
+ return true;
162
+ }
163
+ function shallowClone(o) {
164
+ if (isPlainObject(o)) return { ...o };
165
+ if (Array.isArray(o)) return [...o];
166
+ return o;
167
+ }
168
+ const propertyKeyTypes = new Set([
169
+ "string",
170
+ "number",
171
+ "symbol"
172
+ ]);
173
+ function escapeRegex(str) {
174
+ return str.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
175
+ }
176
+ function clone(inst, def, params) {
177
+ const cl = new inst._zod.constr(def ?? inst._zod.def);
178
+ if (!def || params?.parent) cl._zod.parent = inst;
179
+ return cl;
180
+ }
181
+ function normalizeParams(_params) {
182
+ const params = _params;
183
+ if (!params) return {};
184
+ if (typeof params === "string") return { error: () => params };
185
+ if (params?.message !== void 0) {
186
+ if (params?.error !== void 0) throw new Error("Cannot specify both `message` and `error` params");
187
+ params.error = params.message;
188
+ }
189
+ delete params.message;
190
+ if (typeof params.error === "string") return {
191
+ ...params,
192
+ error: () => params.error
193
+ };
194
+ return params;
195
+ }
196
+ function optionalKeys(shape) {
197
+ return Object.keys(shape).filter((k) => {
198
+ return shape[k]._zod.optin === "optional" && shape[k]._zod.optout === "optional";
199
+ });
200
+ }
201
+ const NUMBER_FORMAT_RANGES = {
202
+ safeint: [Number.MIN_SAFE_INTEGER, Number.MAX_SAFE_INTEGER],
203
+ int32: [-2147483648, 2147483647],
204
+ uint32: [0, 4294967295],
205
+ float32: [-34028234663852886e22, 34028234663852886e22],
206
+ float64: [-Number.MAX_VALUE, Number.MAX_VALUE]
207
+ };
208
+ function pick(schema, mask) {
209
+ const currDef = schema._zod.def;
210
+ const checks = currDef.checks;
211
+ if (checks && checks.length > 0) throw new Error(".pick() cannot be used on object schemas containing refinements");
212
+ return clone(schema, mergeDefs(schema._zod.def, {
213
+ get shape() {
214
+ const newShape = {};
215
+ for (const key in mask) {
216
+ if (!(key in currDef.shape)) throw new Error(`Unrecognized key: "${key}"`);
217
+ if (!mask[key]) continue;
218
+ newShape[key] = currDef.shape[key];
219
+ }
220
+ assignProp(this, "shape", newShape);
221
+ return newShape;
222
+ },
223
+ checks: []
224
+ }));
225
+ }
226
+ function omit(schema, mask) {
227
+ const currDef = schema._zod.def;
228
+ const checks = currDef.checks;
229
+ if (checks && checks.length > 0) throw new Error(".omit() cannot be used on object schemas containing refinements");
230
+ return clone(schema, mergeDefs(schema._zod.def, {
231
+ get shape() {
232
+ const newShape = { ...schema._zod.def.shape };
233
+ for (const key in mask) {
234
+ if (!(key in currDef.shape)) throw new Error(`Unrecognized key: "${key}"`);
235
+ if (!mask[key]) continue;
236
+ delete newShape[key];
237
+ }
238
+ assignProp(this, "shape", newShape);
239
+ return newShape;
240
+ },
241
+ checks: []
242
+ }));
243
+ }
244
+ function extend(schema, shape) {
245
+ if (!isPlainObject(shape)) throw new Error("Invalid input to extend: expected a plain object");
246
+ const checks = schema._zod.def.checks;
247
+ if (checks && checks.length > 0) {
248
+ const existingShape = schema._zod.def.shape;
249
+ 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.");
250
+ }
251
+ return clone(schema, mergeDefs(schema._zod.def, { get shape() {
252
+ const _shape = {
253
+ ...schema._zod.def.shape,
254
+ ...shape
255
+ };
256
+ assignProp(this, "shape", _shape);
257
+ return _shape;
258
+ } }));
259
+ }
260
+ function safeExtend(schema, shape) {
261
+ if (!isPlainObject(shape)) throw new Error("Invalid input to safeExtend: expected a plain object");
262
+ return clone(schema, mergeDefs(schema._zod.def, { get shape() {
263
+ const _shape = {
264
+ ...schema._zod.def.shape,
265
+ ...shape
266
+ };
267
+ assignProp(this, "shape", _shape);
268
+ return _shape;
269
+ } }));
270
+ }
271
+ function merge(a, b) {
272
+ return clone(a, mergeDefs(a._zod.def, {
273
+ get shape() {
274
+ const _shape = {
275
+ ...a._zod.def.shape,
276
+ ...b._zod.def.shape
277
+ };
278
+ assignProp(this, "shape", _shape);
279
+ return _shape;
280
+ },
281
+ get catchall() {
282
+ return b._zod.def.catchall;
283
+ },
284
+ checks: []
285
+ }));
286
+ }
287
+ function partial(Class, schema, mask) {
288
+ const checks = schema._zod.def.checks;
289
+ if (checks && checks.length > 0) throw new Error(".partial() cannot be used on object schemas containing refinements");
290
+ return clone(schema, mergeDefs(schema._zod.def, {
291
+ get shape() {
292
+ const oldShape = schema._zod.def.shape;
293
+ const shape = { ...oldShape };
294
+ if (mask) for (const key in mask) {
295
+ if (!(key in oldShape)) throw new Error(`Unrecognized key: "${key}"`);
296
+ if (!mask[key]) continue;
297
+ shape[key] = Class ? new Class({
298
+ type: "optional",
299
+ innerType: oldShape[key]
300
+ }) : oldShape[key];
301
+ }
302
+ else for (const key in oldShape) shape[key] = Class ? new Class({
303
+ type: "optional",
304
+ innerType: oldShape[key]
305
+ }) : oldShape[key];
306
+ assignProp(this, "shape", shape);
307
+ return shape;
308
+ },
309
+ checks: []
310
+ }));
311
+ }
312
+ function required(Class, schema, mask) {
313
+ return clone(schema, mergeDefs(schema._zod.def, { get shape() {
314
+ const oldShape = schema._zod.def.shape;
315
+ const shape = { ...oldShape };
316
+ if (mask) for (const key in mask) {
317
+ if (!(key in shape)) throw new Error(`Unrecognized key: "${key}"`);
318
+ if (!mask[key]) continue;
319
+ shape[key] = new Class({
320
+ type: "nonoptional",
321
+ innerType: oldShape[key]
322
+ });
323
+ }
324
+ else for (const key in oldShape) shape[key] = new Class({
325
+ type: "nonoptional",
326
+ innerType: oldShape[key]
327
+ });
328
+ assignProp(this, "shape", shape);
329
+ return shape;
330
+ } }));
331
+ }
332
+ function aborted(x, startIndex = 0) {
333
+ if (x.aborted === true) return true;
334
+ for (let i = startIndex; i < x.issues.length; i++) if (x.issues[i]?.continue !== true) return true;
335
+ return false;
336
+ }
337
+ function prefixIssues(path, issues) {
338
+ return issues.map((iss) => {
339
+ var _a$1;
340
+ (_a$1 = iss).path ?? (_a$1.path = []);
341
+ iss.path.unshift(path);
342
+ return iss;
343
+ });
344
+ }
345
+ function unwrapMessage(message) {
346
+ return typeof message === "string" ? message : message?.message;
347
+ }
348
+ function finalizeIssue(iss, ctx, config$1) {
349
+ const full = {
350
+ ...iss,
351
+ path: iss.path ?? []
352
+ };
353
+ if (!iss.message) full.message = unwrapMessage(iss.inst?._zod.def?.error?.(iss)) ?? unwrapMessage(ctx?.error?.(iss)) ?? unwrapMessage(config$1.customError?.(iss)) ?? unwrapMessage(config$1.localeError?.(iss)) ?? "Invalid input";
354
+ delete full.inst;
355
+ delete full.continue;
356
+ if (!ctx?.reportInput) delete full.input;
357
+ return full;
358
+ }
359
+ function getLengthableOrigin(input) {
360
+ if (Array.isArray(input)) return "array";
361
+ if (typeof input === "string") return "string";
362
+ return "unknown";
363
+ }
364
+ function issue(...args$1) {
365
+ const [iss, input, inst] = args$1;
366
+ if (typeof iss === "string") return {
367
+ message: iss,
368
+ code: "custom",
369
+ input,
370
+ inst
371
+ };
372
+ return { ...iss };
373
+ }
374
+
375
+ //#endregion
376
+ //#region node_modules/zod/v4/core/errors.js
377
+ const initializer$1 = (inst, def) => {
378
+ inst.name = "$ZodError";
379
+ Object.defineProperty(inst, "_zod", {
380
+ value: inst._zod,
381
+ enumerable: false
382
+ });
383
+ Object.defineProperty(inst, "issues", {
384
+ value: def,
385
+ enumerable: false
386
+ });
387
+ inst.message = JSON.stringify(def, jsonStringifyReplacer, 2);
388
+ Object.defineProperty(inst, "toString", {
389
+ value: () => inst.message,
390
+ enumerable: false
391
+ });
392
+ };
393
+ const $ZodError = $constructor("$ZodError", initializer$1);
394
+ const $ZodRealError = $constructor("$ZodError", initializer$1, { Parent: Error });
395
+ function flattenError(error, mapper = (issue$1) => issue$1.message) {
396
+ const fieldErrors = {};
397
+ const formErrors = [];
398
+ for (const sub of error.issues) if (sub.path.length > 0) {
399
+ fieldErrors[sub.path[0]] = fieldErrors[sub.path[0]] || [];
400
+ fieldErrors[sub.path[0]].push(mapper(sub));
401
+ } else formErrors.push(mapper(sub));
402
+ return {
403
+ formErrors,
404
+ fieldErrors
405
+ };
406
+ }
407
+ function formatError(error, mapper = (issue$1) => issue$1.message) {
408
+ const fieldErrors = { _errors: [] };
409
+ const processError = (error$1) => {
410
+ for (const issue$1 of error$1.issues) if (issue$1.code === "invalid_union" && issue$1.errors.length) issue$1.errors.map((issues) => processError({ issues }));
411
+ else if (issue$1.code === "invalid_key") processError({ issues: issue$1.issues });
412
+ else if (issue$1.code === "invalid_element") processError({ issues: issue$1.issues });
413
+ else if (issue$1.path.length === 0) fieldErrors._errors.push(mapper(issue$1));
414
+ else {
415
+ let curr = fieldErrors;
416
+ let i = 0;
417
+ while (i < issue$1.path.length) {
418
+ const el = issue$1.path[i];
419
+ if (!(i === issue$1.path.length - 1)) curr[el] = curr[el] || { _errors: [] };
420
+ else {
421
+ curr[el] = curr[el] || { _errors: [] };
422
+ curr[el]._errors.push(mapper(issue$1));
423
+ }
424
+ curr = curr[el];
425
+ i++;
426
+ }
427
+ }
428
+ };
429
+ processError(error);
430
+ return fieldErrors;
431
+ }
432
+
433
+ //#endregion
434
+ //#region node_modules/zod/v4/core/parse.js
435
+ const _parse = (_Err) => (schema, value, _ctx, _params) => {
436
+ const ctx = _ctx ? Object.assign(_ctx, { async: false }) : { async: false };
437
+ const result = schema._zod.run({
438
+ value,
439
+ issues: []
440
+ }, ctx);
441
+ if (result instanceof Promise) throw new $ZodAsyncError();
442
+ if (result.issues.length) {
443
+ const e = new (_params?.Err ?? _Err)(result.issues.map((iss) => finalizeIssue(iss, ctx, config())));
444
+ captureStackTrace(e, _params?.callee);
445
+ throw e;
446
+ }
447
+ return result.value;
448
+ };
449
+ const parse$1 = /* @__PURE__ */ _parse($ZodRealError);
450
+ const _parseAsync = (_Err) => async (schema, value, _ctx, params) => {
451
+ const ctx = _ctx ? Object.assign(_ctx, { async: true }) : { async: true };
452
+ let result = schema._zod.run({
453
+ value,
454
+ issues: []
455
+ }, ctx);
456
+ if (result instanceof Promise) result = await result;
457
+ if (result.issues.length) {
458
+ const e = new (params?.Err ?? _Err)(result.issues.map((iss) => finalizeIssue(iss, ctx, config())));
459
+ captureStackTrace(e, params?.callee);
460
+ throw e;
461
+ }
462
+ return result.value;
463
+ };
464
+ const parseAsync$1 = /* @__PURE__ */ _parseAsync($ZodRealError);
465
+ const _safeParse = (_Err) => (schema, value, _ctx) => {
466
+ const ctx = _ctx ? {
467
+ ..._ctx,
468
+ async: false
469
+ } : { async: false };
470
+ const result = schema._zod.run({
471
+ value,
472
+ issues: []
473
+ }, ctx);
474
+ if (result instanceof Promise) throw new $ZodAsyncError();
475
+ return result.issues.length ? {
476
+ success: false,
477
+ error: new (_Err ?? $ZodError)(result.issues.map((iss) => finalizeIssue(iss, ctx, config())))
478
+ } : {
479
+ success: true,
480
+ data: result.value
481
+ };
482
+ };
483
+ const safeParse$1 = /* @__PURE__ */ _safeParse($ZodRealError);
484
+ const _safeParseAsync = (_Err) => async (schema, value, _ctx) => {
485
+ const ctx = _ctx ? Object.assign(_ctx, { async: true }) : { async: true };
486
+ let result = schema._zod.run({
487
+ value,
488
+ issues: []
489
+ }, ctx);
490
+ if (result instanceof Promise) result = await result;
491
+ return result.issues.length ? {
492
+ success: false,
493
+ error: new _Err(result.issues.map((iss) => finalizeIssue(iss, ctx, config())))
494
+ } : {
495
+ success: true,
496
+ data: result.value
497
+ };
498
+ };
499
+ const safeParseAsync$1 = /* @__PURE__ */ _safeParseAsync($ZodRealError);
500
+ const _encode = (_Err) => (schema, value, _ctx) => {
501
+ const ctx = _ctx ? Object.assign(_ctx, { direction: "backward" }) : { direction: "backward" };
502
+ return _parse(_Err)(schema, value, ctx);
503
+ };
504
+ const encode$1 = /* @__PURE__ */ _encode($ZodRealError);
505
+ const _decode = (_Err) => (schema, value, _ctx) => {
506
+ return _parse(_Err)(schema, value, _ctx);
507
+ };
508
+ const decode$1 = /* @__PURE__ */ _decode($ZodRealError);
509
+ const _encodeAsync = (_Err) => async (schema, value, _ctx) => {
510
+ const ctx = _ctx ? Object.assign(_ctx, { direction: "backward" }) : { direction: "backward" };
511
+ return _parseAsync(_Err)(schema, value, ctx);
512
+ };
513
+ const encodeAsync$1 = /* @__PURE__ */ _encodeAsync($ZodRealError);
514
+ const _decodeAsync = (_Err) => async (schema, value, _ctx) => {
515
+ return _parseAsync(_Err)(schema, value, _ctx);
516
+ };
517
+ const decodeAsync$1 = /* @__PURE__ */ _decodeAsync($ZodRealError);
518
+ const _safeEncode = (_Err) => (schema, value, _ctx) => {
519
+ const ctx = _ctx ? Object.assign(_ctx, { direction: "backward" }) : { direction: "backward" };
520
+ return _safeParse(_Err)(schema, value, ctx);
521
+ };
522
+ const safeEncode$1 = /* @__PURE__ */ _safeEncode($ZodRealError);
523
+ const _safeDecode = (_Err) => (schema, value, _ctx) => {
524
+ return _safeParse(_Err)(schema, value, _ctx);
525
+ };
526
+ const safeDecode$1 = /* @__PURE__ */ _safeDecode($ZodRealError);
527
+ const _safeEncodeAsync = (_Err) => async (schema, value, _ctx) => {
528
+ const ctx = _ctx ? Object.assign(_ctx, { direction: "backward" }) : { direction: "backward" };
529
+ return _safeParseAsync(_Err)(schema, value, ctx);
530
+ };
531
+ const safeEncodeAsync$1 = /* @__PURE__ */ _safeEncodeAsync($ZodRealError);
532
+ const _safeDecodeAsync = (_Err) => async (schema, value, _ctx) => {
533
+ return _safeParseAsync(_Err)(schema, value, _ctx);
534
+ };
535
+ const safeDecodeAsync$1 = /* @__PURE__ */ _safeDecodeAsync($ZodRealError);
536
+
537
+ //#endregion
538
+ //#region node_modules/zod/v4/core/regexes.js
539
+ const cuid = /^[cC][^\s-]{8,}$/;
540
+ const cuid2 = /^[0-9a-z]+$/;
541
+ const ulid = /^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/;
542
+ const xid = /^[0-9a-vA-V]{20}$/;
543
+ const ksuid = /^[A-Za-z0-9]{27}$/;
544
+ const nanoid = /^[a-zA-Z0-9_-]{21}$/;
545
+ /** ISO 8601-1 duration regex. Does not support the 8601-2 extensions like negative durations or fractional/negative components. */
546
+ const duration$1 = /^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/;
547
+ /** A regex for any UUID-like identifier: 8-4-4-4-12 hex pattern */
548
+ const guid = /^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/;
549
+ /** Returns a regex for validating an RFC 9562/4122 UUID.
550
+ *
551
+ * @param version Optionally specify a version 1-8. If no version is specified, all versions are supported. */
552
+ const uuid = (version$1) => {
553
+ if (!version$1) return /^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/;
554
+ return /* @__PURE__ */ new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${version$1}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`);
555
+ };
556
+ /** Practical email validation */
557
+ const email = /^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/;
558
+ const _emoji$1 = `^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$`;
559
+ function emoji() {
560
+ return new RegExp(_emoji$1, "u");
561
+ }
562
+ const ipv4 = /^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/;
563
+ const ipv6 = /^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))$/;
564
+ const cidrv4 = /^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/([0-9]|[1-2][0-9]|3[0-2])$/;
565
+ const cidrv6 = /^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/;
566
+ const base64 = /^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/;
567
+ const base64url = /^[A-Za-z0-9_-]*$/;
568
+ const e164 = /^\+[1-9]\d{6,14}$/;
569
+ const dateSource = `(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))`;
570
+ const date$1 = /* @__PURE__ */ new RegExp(`^${dateSource}$`);
571
+ function timeSource(args$1) {
572
+ const hhmm = `(?:[01]\\d|2[0-3]):[0-5]\\d`;
573
+ return typeof args$1.precision === "number" ? args$1.precision === -1 ? `${hhmm}` : args$1.precision === 0 ? `${hhmm}:[0-5]\\d` : `${hhmm}:[0-5]\\d\\.\\d{${args$1.precision}}` : `${hhmm}(?::[0-5]\\d(?:\\.\\d+)?)?`;
574
+ }
575
+ function time$1(args$1) {
576
+ return /* @__PURE__ */ new RegExp(`^${timeSource(args$1)}$`);
577
+ }
578
+ function datetime$1(args$1) {
579
+ const time$2 = timeSource({ precision: args$1.precision });
580
+ const opts = ["Z"];
581
+ if (args$1.local) opts.push("");
582
+ if (args$1.offset) opts.push(`([+-](?:[01]\\d|2[0-3]):[0-5]\\d)`);
583
+ const timeRegex = `${time$2}(?:${opts.join("|")})`;
584
+ return /* @__PURE__ */ new RegExp(`^${dateSource}T(?:${timeRegex})$`);
585
+ }
586
+ const string$1 = (params) => {
587
+ const regex = params ? `[\\s\\S]{${params?.minimum ?? 0},${params?.maximum ?? ""}}` : `[\\s\\S]*`;
588
+ return /* @__PURE__ */ new RegExp(`^${regex}$`);
589
+ };
590
+ const integer = /^-?\d+$/;
591
+ const number$2 = /^-?\d+(?:\.\d+)?$/;
592
+ const boolean$1 = /^(?:true|false)$/i;
593
+ const lowercase = /^[^A-Z]*$/;
594
+ const uppercase = /^[^a-z]*$/;
595
+
596
+ //#endregion
597
+ //#region node_modules/zod/v4/core/checks.js
598
+ const $ZodCheck = /* @__PURE__ */ $constructor("$ZodCheck", (inst, def) => {
599
+ var _a$1;
600
+ inst._zod ?? (inst._zod = {});
601
+ inst._zod.def = def;
602
+ (_a$1 = inst._zod).onattach ?? (_a$1.onattach = []);
603
+ });
604
+ const numericOriginMap = {
605
+ number: "number",
606
+ bigint: "bigint",
607
+ object: "date"
608
+ };
609
+ const $ZodCheckLessThan = /* @__PURE__ */ $constructor("$ZodCheckLessThan", (inst, def) => {
610
+ $ZodCheck.init(inst, def);
611
+ const origin = numericOriginMap[typeof def.value];
612
+ inst._zod.onattach.push((inst$1) => {
613
+ const bag = inst$1._zod.bag;
614
+ const curr = (def.inclusive ? bag.maximum : bag.exclusiveMaximum) ?? Number.POSITIVE_INFINITY;
615
+ if (def.value < curr) if (def.inclusive) bag.maximum = def.value;
616
+ else bag.exclusiveMaximum = def.value;
617
+ });
618
+ inst._zod.check = (payload) => {
619
+ if (def.inclusive ? payload.value <= def.value : payload.value < def.value) return;
620
+ payload.issues.push({
621
+ origin,
622
+ code: "too_big",
623
+ maximum: typeof def.value === "object" ? def.value.getTime() : def.value,
624
+ input: payload.value,
625
+ inclusive: def.inclusive,
626
+ inst,
627
+ continue: !def.abort
628
+ });
629
+ };
630
+ });
631
+ const $ZodCheckGreaterThan = /* @__PURE__ */ $constructor("$ZodCheckGreaterThan", (inst, def) => {
632
+ $ZodCheck.init(inst, def);
633
+ const origin = numericOriginMap[typeof def.value];
634
+ inst._zod.onattach.push((inst$1) => {
635
+ const bag = inst$1._zod.bag;
636
+ const curr = (def.inclusive ? bag.minimum : bag.exclusiveMinimum) ?? Number.NEGATIVE_INFINITY;
637
+ if (def.value > curr) if (def.inclusive) bag.minimum = def.value;
638
+ else bag.exclusiveMinimum = def.value;
639
+ });
640
+ inst._zod.check = (payload) => {
641
+ if (def.inclusive ? payload.value >= def.value : payload.value > def.value) return;
642
+ payload.issues.push({
643
+ origin,
644
+ code: "too_small",
645
+ minimum: typeof def.value === "object" ? def.value.getTime() : def.value,
646
+ input: payload.value,
647
+ inclusive: def.inclusive,
648
+ inst,
649
+ continue: !def.abort
650
+ });
651
+ };
652
+ });
653
+ const $ZodCheckMultipleOf = /* @__PURE__ */ $constructor("$ZodCheckMultipleOf", (inst, def) => {
654
+ $ZodCheck.init(inst, def);
655
+ inst._zod.onattach.push((inst$1) => {
656
+ var _a$1;
657
+ (_a$1 = inst$1._zod.bag).multipleOf ?? (_a$1.multipleOf = def.value);
658
+ });
659
+ inst._zod.check = (payload) => {
660
+ if (typeof payload.value !== typeof def.value) throw new Error("Cannot mix number and bigint in multiple_of check.");
661
+ if (typeof payload.value === "bigint" ? payload.value % def.value === BigInt(0) : floatSafeRemainder(payload.value, def.value) === 0) return;
662
+ payload.issues.push({
663
+ origin: typeof payload.value,
664
+ code: "not_multiple_of",
665
+ divisor: def.value,
666
+ input: payload.value,
667
+ inst,
668
+ continue: !def.abort
669
+ });
670
+ };
671
+ });
672
+ const $ZodCheckNumberFormat = /* @__PURE__ */ $constructor("$ZodCheckNumberFormat", (inst, def) => {
673
+ $ZodCheck.init(inst, def);
674
+ def.format = def.format || "float64";
675
+ const isInt = def.format?.includes("int");
676
+ const origin = isInt ? "int" : "number";
677
+ const [minimum, maximum] = NUMBER_FORMAT_RANGES[def.format];
678
+ inst._zod.onattach.push((inst$1) => {
679
+ const bag = inst$1._zod.bag;
680
+ bag.format = def.format;
681
+ bag.minimum = minimum;
682
+ bag.maximum = maximum;
683
+ if (isInt) bag.pattern = integer;
684
+ });
685
+ inst._zod.check = (payload) => {
686
+ const input = payload.value;
687
+ if (isInt) {
688
+ if (!Number.isInteger(input)) {
689
+ payload.issues.push({
690
+ expected: origin,
691
+ format: def.format,
692
+ code: "invalid_type",
693
+ continue: false,
694
+ input,
695
+ inst
696
+ });
697
+ return;
698
+ }
699
+ if (!Number.isSafeInteger(input)) {
700
+ if (input > 0) payload.issues.push({
701
+ input,
702
+ code: "too_big",
703
+ maximum: Number.MAX_SAFE_INTEGER,
704
+ note: "Integers must be within the safe integer range.",
705
+ inst,
706
+ origin,
707
+ inclusive: true,
708
+ continue: !def.abort
709
+ });
710
+ else payload.issues.push({
711
+ input,
712
+ code: "too_small",
713
+ minimum: Number.MIN_SAFE_INTEGER,
714
+ note: "Integers must be within the safe integer range.",
715
+ inst,
716
+ origin,
717
+ inclusive: true,
718
+ continue: !def.abort
719
+ });
720
+ return;
721
+ }
722
+ }
723
+ if (input < minimum) payload.issues.push({
724
+ origin: "number",
725
+ input,
726
+ code: "too_small",
727
+ minimum,
728
+ inclusive: true,
729
+ inst,
730
+ continue: !def.abort
731
+ });
732
+ if (input > maximum) payload.issues.push({
733
+ origin: "number",
734
+ input,
735
+ code: "too_big",
736
+ maximum,
737
+ inclusive: true,
738
+ inst,
739
+ continue: !def.abort
740
+ });
741
+ };
742
+ });
743
+ const $ZodCheckMaxLength = /* @__PURE__ */ $constructor("$ZodCheckMaxLength", (inst, def) => {
744
+ var _a$1;
745
+ $ZodCheck.init(inst, def);
746
+ (_a$1 = inst._zod.def).when ?? (_a$1.when = (payload) => {
747
+ const val = payload.value;
748
+ return !nullish(val) && val.length !== void 0;
749
+ });
750
+ inst._zod.onattach.push((inst$1) => {
751
+ const curr = inst$1._zod.bag.maximum ?? Number.POSITIVE_INFINITY;
752
+ if (def.maximum < curr) inst$1._zod.bag.maximum = def.maximum;
753
+ });
754
+ inst._zod.check = (payload) => {
755
+ const input = payload.value;
756
+ if (input.length <= def.maximum) return;
757
+ const origin = getLengthableOrigin(input);
758
+ payload.issues.push({
759
+ origin,
760
+ code: "too_big",
761
+ maximum: def.maximum,
762
+ inclusive: true,
763
+ input,
764
+ inst,
765
+ continue: !def.abort
766
+ });
767
+ };
768
+ });
769
+ const $ZodCheckMinLength = /* @__PURE__ */ $constructor("$ZodCheckMinLength", (inst, def) => {
770
+ var _a$1;
771
+ $ZodCheck.init(inst, def);
772
+ (_a$1 = inst._zod.def).when ?? (_a$1.when = (payload) => {
773
+ const val = payload.value;
774
+ return !nullish(val) && val.length !== void 0;
775
+ });
776
+ inst._zod.onattach.push((inst$1) => {
777
+ const curr = inst$1._zod.bag.minimum ?? Number.NEGATIVE_INFINITY;
778
+ if (def.minimum > curr) inst$1._zod.bag.minimum = def.minimum;
779
+ });
780
+ inst._zod.check = (payload) => {
781
+ const input = payload.value;
782
+ if (input.length >= def.minimum) return;
783
+ const origin = getLengthableOrigin(input);
784
+ payload.issues.push({
785
+ origin,
786
+ code: "too_small",
787
+ minimum: def.minimum,
788
+ inclusive: true,
789
+ input,
790
+ inst,
791
+ continue: !def.abort
792
+ });
793
+ };
794
+ });
795
+ const $ZodCheckLengthEquals = /* @__PURE__ */ $constructor("$ZodCheckLengthEquals", (inst, def) => {
796
+ var _a$1;
797
+ $ZodCheck.init(inst, def);
798
+ (_a$1 = inst._zod.def).when ?? (_a$1.when = (payload) => {
799
+ const val = payload.value;
800
+ return !nullish(val) && val.length !== void 0;
801
+ });
802
+ inst._zod.onattach.push((inst$1) => {
803
+ const bag = inst$1._zod.bag;
804
+ bag.minimum = def.length;
805
+ bag.maximum = def.length;
806
+ bag.length = def.length;
807
+ });
808
+ inst._zod.check = (payload) => {
809
+ const input = payload.value;
810
+ const length = input.length;
811
+ if (length === def.length) return;
812
+ const origin = getLengthableOrigin(input);
813
+ const tooBig = length > def.length;
814
+ payload.issues.push({
815
+ origin,
816
+ ...tooBig ? {
817
+ code: "too_big",
818
+ maximum: def.length
819
+ } : {
820
+ code: "too_small",
821
+ minimum: def.length
822
+ },
823
+ inclusive: true,
824
+ exact: true,
825
+ input: payload.value,
826
+ inst,
827
+ continue: !def.abort
828
+ });
829
+ };
830
+ });
831
+ const $ZodCheckStringFormat = /* @__PURE__ */ $constructor("$ZodCheckStringFormat", (inst, def) => {
832
+ var _a$1, _b;
833
+ $ZodCheck.init(inst, def);
834
+ inst._zod.onattach.push((inst$1) => {
835
+ const bag = inst$1._zod.bag;
836
+ bag.format = def.format;
837
+ if (def.pattern) {
838
+ bag.patterns ?? (bag.patterns = /* @__PURE__ */ new Set());
839
+ bag.patterns.add(def.pattern);
840
+ }
841
+ });
842
+ if (def.pattern) (_a$1 = inst._zod).check ?? (_a$1.check = (payload) => {
843
+ def.pattern.lastIndex = 0;
844
+ if (def.pattern.test(payload.value)) return;
845
+ payload.issues.push({
846
+ origin: "string",
847
+ code: "invalid_format",
848
+ format: def.format,
849
+ input: payload.value,
850
+ ...def.pattern ? { pattern: def.pattern.toString() } : {},
851
+ inst,
852
+ continue: !def.abort
853
+ });
854
+ });
855
+ else (_b = inst._zod).check ?? (_b.check = () => {});
856
+ });
857
+ const $ZodCheckRegex = /* @__PURE__ */ $constructor("$ZodCheckRegex", (inst, def) => {
858
+ $ZodCheckStringFormat.init(inst, def);
859
+ inst._zod.check = (payload) => {
860
+ def.pattern.lastIndex = 0;
861
+ if (def.pattern.test(payload.value)) return;
862
+ payload.issues.push({
863
+ origin: "string",
864
+ code: "invalid_format",
865
+ format: "regex",
866
+ input: payload.value,
867
+ pattern: def.pattern.toString(),
868
+ inst,
869
+ continue: !def.abort
870
+ });
871
+ };
872
+ });
873
+ const $ZodCheckLowerCase = /* @__PURE__ */ $constructor("$ZodCheckLowerCase", (inst, def) => {
874
+ def.pattern ?? (def.pattern = lowercase);
875
+ $ZodCheckStringFormat.init(inst, def);
876
+ });
877
+ const $ZodCheckUpperCase = /* @__PURE__ */ $constructor("$ZodCheckUpperCase", (inst, def) => {
878
+ def.pattern ?? (def.pattern = uppercase);
879
+ $ZodCheckStringFormat.init(inst, def);
880
+ });
881
+ const $ZodCheckIncludes = /* @__PURE__ */ $constructor("$ZodCheckIncludes", (inst, def) => {
882
+ $ZodCheck.init(inst, def);
883
+ const escapedRegex = escapeRegex(def.includes);
884
+ const pattern = new RegExp(typeof def.position === "number" ? `^.{${def.position}}${escapedRegex}` : escapedRegex);
885
+ def.pattern = pattern;
886
+ inst._zod.onattach.push((inst$1) => {
887
+ const bag = inst$1._zod.bag;
888
+ bag.patterns ?? (bag.patterns = /* @__PURE__ */ new Set());
889
+ bag.patterns.add(pattern);
890
+ });
891
+ inst._zod.check = (payload) => {
892
+ if (payload.value.includes(def.includes, def.position)) return;
893
+ payload.issues.push({
894
+ origin: "string",
895
+ code: "invalid_format",
896
+ format: "includes",
897
+ includes: def.includes,
898
+ input: payload.value,
899
+ inst,
900
+ continue: !def.abort
901
+ });
902
+ };
903
+ });
904
+ const $ZodCheckStartsWith = /* @__PURE__ */ $constructor("$ZodCheckStartsWith", (inst, def) => {
905
+ $ZodCheck.init(inst, def);
906
+ const pattern = /* @__PURE__ */ new RegExp(`^${escapeRegex(def.prefix)}.*`);
907
+ def.pattern ?? (def.pattern = pattern);
908
+ inst._zod.onattach.push((inst$1) => {
909
+ const bag = inst$1._zod.bag;
910
+ bag.patterns ?? (bag.patterns = /* @__PURE__ */ new Set());
911
+ bag.patterns.add(pattern);
912
+ });
913
+ inst._zod.check = (payload) => {
914
+ if (payload.value.startsWith(def.prefix)) return;
915
+ payload.issues.push({
916
+ origin: "string",
917
+ code: "invalid_format",
918
+ format: "starts_with",
919
+ prefix: def.prefix,
920
+ input: payload.value,
921
+ inst,
922
+ continue: !def.abort
923
+ });
924
+ };
925
+ });
926
+ const $ZodCheckEndsWith = /* @__PURE__ */ $constructor("$ZodCheckEndsWith", (inst, def) => {
927
+ $ZodCheck.init(inst, def);
928
+ const pattern = /* @__PURE__ */ new RegExp(`.*${escapeRegex(def.suffix)}$`);
929
+ def.pattern ?? (def.pattern = pattern);
930
+ inst._zod.onattach.push((inst$1) => {
931
+ const bag = inst$1._zod.bag;
932
+ bag.patterns ?? (bag.patterns = /* @__PURE__ */ new Set());
933
+ bag.patterns.add(pattern);
934
+ });
935
+ inst._zod.check = (payload) => {
936
+ if (payload.value.endsWith(def.suffix)) return;
937
+ payload.issues.push({
938
+ origin: "string",
939
+ code: "invalid_format",
940
+ format: "ends_with",
941
+ suffix: def.suffix,
942
+ input: payload.value,
943
+ inst,
944
+ continue: !def.abort
945
+ });
946
+ };
947
+ });
948
+ const $ZodCheckOverwrite = /* @__PURE__ */ $constructor("$ZodCheckOverwrite", (inst, def) => {
949
+ $ZodCheck.init(inst, def);
950
+ inst._zod.check = (payload) => {
951
+ payload.value = def.tx(payload.value);
952
+ };
953
+ });
954
+
955
+ //#endregion
956
+ //#region node_modules/zod/v4/core/doc.js
957
+ var Doc = class {
958
+ constructor(args$1 = []) {
959
+ this.content = [];
960
+ this.indent = 0;
961
+ if (this) this.args = args$1;
962
+ }
963
+ indented(fn) {
964
+ this.indent += 1;
965
+ fn(this);
966
+ this.indent -= 1;
967
+ }
968
+ write(arg) {
969
+ if (typeof arg === "function") {
970
+ arg(this, { execution: "sync" });
971
+ arg(this, { execution: "async" });
972
+ return;
973
+ }
974
+ const lines = arg.split("\n").filter((x) => x);
975
+ const minIndent = Math.min(...lines.map((x) => x.length - x.trimStart().length));
976
+ const dedented = lines.map((x) => x.slice(minIndent)).map((x) => " ".repeat(this.indent * 2) + x);
977
+ for (const line of dedented) this.content.push(line);
978
+ }
979
+ compile() {
980
+ const F = Function;
981
+ const args$1 = this?.args;
982
+ const lines = [...(this?.content ?? [``]).map((x) => ` ${x}`)];
983
+ return new F(...args$1, lines.join("\n"));
984
+ }
985
+ };
986
+
987
+ //#endregion
988
+ //#region node_modules/zod/v4/core/versions.js
989
+ const version = {
990
+ major: 4,
991
+ minor: 3,
992
+ patch: 6
993
+ };
994
+
995
+ //#endregion
996
+ //#region node_modules/zod/v4/core/schemas.js
997
+ const $ZodType = /* @__PURE__ */ $constructor("$ZodType", (inst, def) => {
998
+ var _a$1;
999
+ inst ?? (inst = {});
1000
+ inst._zod.def = def;
1001
+ inst._zod.bag = inst._zod.bag || {};
1002
+ inst._zod.version = version;
1003
+ const checks = [...inst._zod.def.checks ?? []];
1004
+ if (inst._zod.traits.has("$ZodCheck")) checks.unshift(inst);
1005
+ for (const ch of checks) for (const fn of ch._zod.onattach) fn(inst);
1006
+ if (checks.length === 0) {
1007
+ (_a$1 = inst._zod).deferred ?? (_a$1.deferred = []);
1008
+ inst._zod.deferred?.push(() => {
1009
+ inst._zod.run = inst._zod.parse;
1010
+ });
1011
+ } else {
1012
+ const runChecks = (payload, checks$1, ctx) => {
1013
+ let isAborted = aborted(payload);
1014
+ let asyncResult;
1015
+ for (const ch of checks$1) {
1016
+ if (ch._zod.def.when) {
1017
+ if (!ch._zod.def.when(payload)) continue;
1018
+ } else if (isAborted) continue;
1019
+ const currLen = payload.issues.length;
1020
+ const _ = ch._zod.check(payload);
1021
+ if (_ instanceof Promise && ctx?.async === false) throw new $ZodAsyncError();
1022
+ if (asyncResult || _ instanceof Promise) asyncResult = (asyncResult ?? Promise.resolve()).then(async () => {
1023
+ await _;
1024
+ if (payload.issues.length === currLen) return;
1025
+ if (!isAborted) isAborted = aborted(payload, currLen);
1026
+ });
1027
+ else {
1028
+ if (payload.issues.length === currLen) continue;
1029
+ if (!isAborted) isAborted = aborted(payload, currLen);
1030
+ }
1031
+ }
1032
+ if (asyncResult) return asyncResult.then(() => {
1033
+ return payload;
1034
+ });
1035
+ return payload;
1036
+ };
1037
+ const handleCanaryResult = (canary, payload, ctx) => {
1038
+ if (aborted(canary)) {
1039
+ canary.aborted = true;
1040
+ return canary;
1041
+ }
1042
+ const checkResult = runChecks(payload, checks, ctx);
1043
+ if (checkResult instanceof Promise) {
1044
+ if (ctx.async === false) throw new $ZodAsyncError();
1045
+ return checkResult.then((checkResult$1) => inst._zod.parse(checkResult$1, ctx));
1046
+ }
1047
+ return inst._zod.parse(checkResult, ctx);
1048
+ };
1049
+ inst._zod.run = (payload, ctx) => {
1050
+ if (ctx.skipChecks) return inst._zod.parse(payload, ctx);
1051
+ if (ctx.direction === "backward") {
1052
+ const canary = inst._zod.parse({
1053
+ value: payload.value,
1054
+ issues: []
1055
+ }, {
1056
+ ...ctx,
1057
+ skipChecks: true
1058
+ });
1059
+ if (canary instanceof Promise) return canary.then((canary$1) => {
1060
+ return handleCanaryResult(canary$1, payload, ctx);
1061
+ });
1062
+ return handleCanaryResult(canary, payload, ctx);
1063
+ }
1064
+ const result = inst._zod.parse(payload, ctx);
1065
+ if (result instanceof Promise) {
1066
+ if (ctx.async === false) throw new $ZodAsyncError();
1067
+ return result.then((result$1) => runChecks(result$1, checks, ctx));
1068
+ }
1069
+ return runChecks(result, checks, ctx);
1070
+ };
1071
+ }
1072
+ defineLazy(inst, "~standard", () => ({
1073
+ validate: (value) => {
1074
+ try {
1075
+ const r = safeParse$1(inst, value);
1076
+ return r.success ? { value: r.data } : { issues: r.error?.issues };
1077
+ } catch (_) {
1078
+ return safeParseAsync$1(inst, value).then((r) => r.success ? { value: r.data } : { issues: r.error?.issues });
1079
+ }
1080
+ },
1081
+ vendor: "zod",
1082
+ version: 1
1083
+ }));
1084
+ });
1085
+ const $ZodString = /* @__PURE__ */ $constructor("$ZodString", (inst, def) => {
1086
+ $ZodType.init(inst, def);
1087
+ inst._zod.pattern = [...inst?._zod.bag?.patterns ?? []].pop() ?? string$1(inst._zod.bag);
1088
+ inst._zod.parse = (payload, _) => {
1089
+ if (def.coerce) try {
1090
+ payload.value = String(payload.value);
1091
+ } catch (_$1) {}
1092
+ if (typeof payload.value === "string") return payload;
1093
+ payload.issues.push({
1094
+ expected: "string",
1095
+ code: "invalid_type",
1096
+ input: payload.value,
1097
+ inst
1098
+ });
1099
+ return payload;
1100
+ };
1101
+ });
1102
+ const $ZodStringFormat = /* @__PURE__ */ $constructor("$ZodStringFormat", (inst, def) => {
1103
+ $ZodCheckStringFormat.init(inst, def);
1104
+ $ZodString.init(inst, def);
1105
+ });
1106
+ const $ZodGUID = /* @__PURE__ */ $constructor("$ZodGUID", (inst, def) => {
1107
+ def.pattern ?? (def.pattern = guid);
1108
+ $ZodStringFormat.init(inst, def);
1109
+ });
1110
+ const $ZodUUID = /* @__PURE__ */ $constructor("$ZodUUID", (inst, def) => {
1111
+ if (def.version) {
1112
+ const v = {
1113
+ v1: 1,
1114
+ v2: 2,
1115
+ v3: 3,
1116
+ v4: 4,
1117
+ v5: 5,
1118
+ v6: 6,
1119
+ v7: 7,
1120
+ v8: 8
1121
+ }[def.version];
1122
+ if (v === void 0) throw new Error(`Invalid UUID version: "${def.version}"`);
1123
+ def.pattern ?? (def.pattern = uuid(v));
1124
+ } else def.pattern ?? (def.pattern = uuid());
1125
+ $ZodStringFormat.init(inst, def);
1126
+ });
1127
+ const $ZodEmail = /* @__PURE__ */ $constructor("$ZodEmail", (inst, def) => {
1128
+ def.pattern ?? (def.pattern = email);
1129
+ $ZodStringFormat.init(inst, def);
1130
+ });
1131
+ const $ZodURL = /* @__PURE__ */ $constructor("$ZodURL", (inst, def) => {
1132
+ $ZodStringFormat.init(inst, def);
1133
+ inst._zod.check = (payload) => {
1134
+ try {
1135
+ const trimmed = payload.value.trim();
1136
+ const url = new URL(trimmed);
1137
+ if (def.hostname) {
1138
+ def.hostname.lastIndex = 0;
1139
+ if (!def.hostname.test(url.hostname)) payload.issues.push({
1140
+ code: "invalid_format",
1141
+ format: "url",
1142
+ note: "Invalid hostname",
1143
+ pattern: def.hostname.source,
1144
+ input: payload.value,
1145
+ inst,
1146
+ continue: !def.abort
1147
+ });
1148
+ }
1149
+ if (def.protocol) {
1150
+ def.protocol.lastIndex = 0;
1151
+ if (!def.protocol.test(url.protocol.endsWith(":") ? url.protocol.slice(0, -1) : url.protocol)) payload.issues.push({
1152
+ code: "invalid_format",
1153
+ format: "url",
1154
+ note: "Invalid protocol",
1155
+ pattern: def.protocol.source,
1156
+ input: payload.value,
1157
+ inst,
1158
+ continue: !def.abort
1159
+ });
1160
+ }
1161
+ if (def.normalize) payload.value = url.href;
1162
+ else payload.value = trimmed;
1163
+ return;
1164
+ } catch (_) {
1165
+ payload.issues.push({
1166
+ code: "invalid_format",
1167
+ format: "url",
1168
+ input: payload.value,
1169
+ inst,
1170
+ continue: !def.abort
1171
+ });
1172
+ }
1173
+ };
1174
+ });
1175
+ const $ZodEmoji = /* @__PURE__ */ $constructor("$ZodEmoji", (inst, def) => {
1176
+ def.pattern ?? (def.pattern = emoji());
1177
+ $ZodStringFormat.init(inst, def);
1178
+ });
1179
+ const $ZodNanoID = /* @__PURE__ */ $constructor("$ZodNanoID", (inst, def) => {
1180
+ def.pattern ?? (def.pattern = nanoid);
1181
+ $ZodStringFormat.init(inst, def);
1182
+ });
1183
+ const $ZodCUID = /* @__PURE__ */ $constructor("$ZodCUID", (inst, def) => {
1184
+ def.pattern ?? (def.pattern = cuid);
1185
+ $ZodStringFormat.init(inst, def);
1186
+ });
1187
+ const $ZodCUID2 = /* @__PURE__ */ $constructor("$ZodCUID2", (inst, def) => {
1188
+ def.pattern ?? (def.pattern = cuid2);
1189
+ $ZodStringFormat.init(inst, def);
1190
+ });
1191
+ const $ZodULID = /* @__PURE__ */ $constructor("$ZodULID", (inst, def) => {
1192
+ def.pattern ?? (def.pattern = ulid);
1193
+ $ZodStringFormat.init(inst, def);
1194
+ });
1195
+ const $ZodXID = /* @__PURE__ */ $constructor("$ZodXID", (inst, def) => {
1196
+ def.pattern ?? (def.pattern = xid);
1197
+ $ZodStringFormat.init(inst, def);
1198
+ });
1199
+ const $ZodKSUID = /* @__PURE__ */ $constructor("$ZodKSUID", (inst, def) => {
1200
+ def.pattern ?? (def.pattern = ksuid);
1201
+ $ZodStringFormat.init(inst, def);
1202
+ });
1203
+ const $ZodISODateTime = /* @__PURE__ */ $constructor("$ZodISODateTime", (inst, def) => {
1204
+ def.pattern ?? (def.pattern = datetime$1(def));
1205
+ $ZodStringFormat.init(inst, def);
1206
+ });
1207
+ const $ZodISODate = /* @__PURE__ */ $constructor("$ZodISODate", (inst, def) => {
1208
+ def.pattern ?? (def.pattern = date$1);
1209
+ $ZodStringFormat.init(inst, def);
1210
+ });
1211
+ const $ZodISOTime = /* @__PURE__ */ $constructor("$ZodISOTime", (inst, def) => {
1212
+ def.pattern ?? (def.pattern = time$1(def));
1213
+ $ZodStringFormat.init(inst, def);
1214
+ });
1215
+ const $ZodISODuration = /* @__PURE__ */ $constructor("$ZodISODuration", (inst, def) => {
1216
+ def.pattern ?? (def.pattern = duration$1);
1217
+ $ZodStringFormat.init(inst, def);
1218
+ });
1219
+ const $ZodIPv4 = /* @__PURE__ */ $constructor("$ZodIPv4", (inst, def) => {
1220
+ def.pattern ?? (def.pattern = ipv4);
1221
+ $ZodStringFormat.init(inst, def);
1222
+ inst._zod.bag.format = `ipv4`;
1223
+ });
1224
+ const $ZodIPv6 = /* @__PURE__ */ $constructor("$ZodIPv6", (inst, def) => {
1225
+ def.pattern ?? (def.pattern = ipv6);
1226
+ $ZodStringFormat.init(inst, def);
1227
+ inst._zod.bag.format = `ipv6`;
1228
+ inst._zod.check = (payload) => {
1229
+ try {
1230
+ new URL(`http://[${payload.value}]`);
1231
+ } catch {
1232
+ payload.issues.push({
1233
+ code: "invalid_format",
1234
+ format: "ipv6",
1235
+ input: payload.value,
1236
+ inst,
1237
+ continue: !def.abort
1238
+ });
1239
+ }
1240
+ };
1241
+ });
1242
+ const $ZodCIDRv4 = /* @__PURE__ */ $constructor("$ZodCIDRv4", (inst, def) => {
1243
+ def.pattern ?? (def.pattern = cidrv4);
1244
+ $ZodStringFormat.init(inst, def);
1245
+ });
1246
+ const $ZodCIDRv6 = /* @__PURE__ */ $constructor("$ZodCIDRv6", (inst, def) => {
1247
+ def.pattern ?? (def.pattern = cidrv6);
1248
+ $ZodStringFormat.init(inst, def);
1249
+ inst._zod.check = (payload) => {
1250
+ const parts = payload.value.split("/");
1251
+ try {
1252
+ if (parts.length !== 2) throw new Error();
1253
+ const [address, prefix] = parts;
1254
+ if (!prefix) throw new Error();
1255
+ const prefixNum = Number(prefix);
1256
+ if (`${prefixNum}` !== prefix) throw new Error();
1257
+ if (prefixNum < 0 || prefixNum > 128) throw new Error();
1258
+ new URL(`http://[${address}]`);
1259
+ } catch {
1260
+ payload.issues.push({
1261
+ code: "invalid_format",
1262
+ format: "cidrv6",
1263
+ input: payload.value,
1264
+ inst,
1265
+ continue: !def.abort
1266
+ });
1267
+ }
1268
+ };
1269
+ });
1270
+ function isValidBase64(data) {
1271
+ if (data === "") return true;
1272
+ if (data.length % 4 !== 0) return false;
1273
+ try {
1274
+ atob(data);
1275
+ return true;
1276
+ } catch {
1277
+ return false;
1278
+ }
1279
+ }
1280
+ const $ZodBase64 = /* @__PURE__ */ $constructor("$ZodBase64", (inst, def) => {
1281
+ def.pattern ?? (def.pattern = base64);
1282
+ $ZodStringFormat.init(inst, def);
1283
+ inst._zod.bag.contentEncoding = "base64";
1284
+ inst._zod.check = (payload) => {
1285
+ if (isValidBase64(payload.value)) return;
1286
+ payload.issues.push({
1287
+ code: "invalid_format",
1288
+ format: "base64",
1289
+ input: payload.value,
1290
+ inst,
1291
+ continue: !def.abort
1292
+ });
1293
+ };
1294
+ });
1295
+ function isValidBase64URL(data) {
1296
+ if (!base64url.test(data)) return false;
1297
+ const base64$1 = data.replace(/[-_]/g, (c) => c === "-" ? "+" : "/");
1298
+ return isValidBase64(base64$1.padEnd(Math.ceil(base64$1.length / 4) * 4, "="));
1299
+ }
1300
+ const $ZodBase64URL = /* @__PURE__ */ $constructor("$ZodBase64URL", (inst, def) => {
1301
+ def.pattern ?? (def.pattern = base64url);
1302
+ $ZodStringFormat.init(inst, def);
1303
+ inst._zod.bag.contentEncoding = "base64url";
1304
+ inst._zod.check = (payload) => {
1305
+ if (isValidBase64URL(payload.value)) return;
1306
+ payload.issues.push({
1307
+ code: "invalid_format",
1308
+ format: "base64url",
1309
+ input: payload.value,
1310
+ inst,
1311
+ continue: !def.abort
1312
+ });
1313
+ };
1314
+ });
1315
+ const $ZodE164 = /* @__PURE__ */ $constructor("$ZodE164", (inst, def) => {
1316
+ def.pattern ?? (def.pattern = e164);
1317
+ $ZodStringFormat.init(inst, def);
1318
+ });
1319
+ function isValidJWT(token, algorithm = null) {
1320
+ try {
1321
+ const tokensParts = token.split(".");
1322
+ if (tokensParts.length !== 3) return false;
1323
+ const [header] = tokensParts;
1324
+ if (!header) return false;
1325
+ const parsedHeader = JSON.parse(atob(header));
1326
+ if ("typ" in parsedHeader && parsedHeader?.typ !== "JWT") return false;
1327
+ if (!parsedHeader.alg) return false;
1328
+ if (algorithm && (!("alg" in parsedHeader) || parsedHeader.alg !== algorithm)) return false;
1329
+ return true;
1330
+ } catch {
1331
+ return false;
1332
+ }
1333
+ }
1334
+ const $ZodJWT = /* @__PURE__ */ $constructor("$ZodJWT", (inst, def) => {
1335
+ $ZodStringFormat.init(inst, def);
1336
+ inst._zod.check = (payload) => {
1337
+ if (isValidJWT(payload.value, def.alg)) return;
1338
+ payload.issues.push({
1339
+ code: "invalid_format",
1340
+ format: "jwt",
1341
+ input: payload.value,
1342
+ inst,
1343
+ continue: !def.abort
1344
+ });
1345
+ };
1346
+ });
1347
+ const $ZodNumber = /* @__PURE__ */ $constructor("$ZodNumber", (inst, def) => {
1348
+ $ZodType.init(inst, def);
1349
+ inst._zod.pattern = inst._zod.bag.pattern ?? number$2;
1350
+ inst._zod.parse = (payload, _ctx) => {
1351
+ if (def.coerce) try {
1352
+ payload.value = Number(payload.value);
1353
+ } catch (_) {}
1354
+ const input = payload.value;
1355
+ if (typeof input === "number" && !Number.isNaN(input) && Number.isFinite(input)) return payload;
1356
+ const received = typeof input === "number" ? Number.isNaN(input) ? "NaN" : !Number.isFinite(input) ? "Infinity" : void 0 : void 0;
1357
+ payload.issues.push({
1358
+ expected: "number",
1359
+ code: "invalid_type",
1360
+ input,
1361
+ inst,
1362
+ ...received ? { received } : {}
1363
+ });
1364
+ return payload;
1365
+ };
1366
+ });
1367
+ const $ZodNumberFormat = /* @__PURE__ */ $constructor("$ZodNumberFormat", (inst, def) => {
1368
+ $ZodCheckNumberFormat.init(inst, def);
1369
+ $ZodNumber.init(inst, def);
1370
+ });
1371
+ const $ZodBoolean = /* @__PURE__ */ $constructor("$ZodBoolean", (inst, def) => {
1372
+ $ZodType.init(inst, def);
1373
+ inst._zod.pattern = boolean$1;
1374
+ inst._zod.parse = (payload, _ctx) => {
1375
+ if (def.coerce) try {
1376
+ payload.value = Boolean(payload.value);
1377
+ } catch (_) {}
1378
+ const input = payload.value;
1379
+ if (typeof input === "boolean") return payload;
1380
+ payload.issues.push({
1381
+ expected: "boolean",
1382
+ code: "invalid_type",
1383
+ input,
1384
+ inst
1385
+ });
1386
+ return payload;
1387
+ };
1388
+ });
1389
+ const $ZodAny = /* @__PURE__ */ $constructor("$ZodAny", (inst, def) => {
1390
+ $ZodType.init(inst, def);
1391
+ inst._zod.parse = (payload) => payload;
1392
+ });
1393
+ const $ZodUnknown = /* @__PURE__ */ $constructor("$ZodUnknown", (inst, def) => {
1394
+ $ZodType.init(inst, def);
1395
+ inst._zod.parse = (payload) => payload;
1396
+ });
1397
+ const $ZodNever = /* @__PURE__ */ $constructor("$ZodNever", (inst, def) => {
1398
+ $ZodType.init(inst, def);
1399
+ inst._zod.parse = (payload, _ctx) => {
1400
+ payload.issues.push({
1401
+ expected: "never",
1402
+ code: "invalid_type",
1403
+ input: payload.value,
1404
+ inst
1405
+ });
1406
+ return payload;
1407
+ };
1408
+ });
1409
+ function handleArrayResult(result, final, index) {
1410
+ if (result.issues.length) final.issues.push(...prefixIssues(index, result.issues));
1411
+ final.value[index] = result.value;
1412
+ }
1413
+ const $ZodArray = /* @__PURE__ */ $constructor("$ZodArray", (inst, def) => {
1414
+ $ZodType.init(inst, def);
1415
+ inst._zod.parse = (payload, ctx) => {
1416
+ const input = payload.value;
1417
+ if (!Array.isArray(input)) {
1418
+ payload.issues.push({
1419
+ expected: "array",
1420
+ code: "invalid_type",
1421
+ input,
1422
+ inst
1423
+ });
1424
+ return payload;
1425
+ }
1426
+ payload.value = Array(input.length);
1427
+ const proms = [];
1428
+ for (let i = 0; i < input.length; i++) {
1429
+ const item = input[i];
1430
+ const result = def.element._zod.run({
1431
+ value: item,
1432
+ issues: []
1433
+ }, ctx);
1434
+ if (result instanceof Promise) proms.push(result.then((result$1) => handleArrayResult(result$1, payload, i)));
1435
+ else handleArrayResult(result, payload, i);
1436
+ }
1437
+ if (proms.length) return Promise.all(proms).then(() => payload);
1438
+ return payload;
1439
+ };
1440
+ });
1441
+ function handlePropertyResult(result, final, key, input, isOptionalOut) {
1442
+ if (result.issues.length) {
1443
+ if (isOptionalOut && !(key in input)) return;
1444
+ final.issues.push(...prefixIssues(key, result.issues));
1445
+ }
1446
+ if (result.value === void 0) {
1447
+ if (key in input) final.value[key] = void 0;
1448
+ } else final.value[key] = result.value;
1449
+ }
1450
+ function normalizeDef(def) {
1451
+ const keys = Object.keys(def.shape);
1452
+ 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`);
1453
+ const okeys = optionalKeys(def.shape);
1454
+ return {
1455
+ ...def,
1456
+ keys,
1457
+ keySet: new Set(keys),
1458
+ numKeys: keys.length,
1459
+ optionalKeys: new Set(okeys)
1460
+ };
1461
+ }
1462
+ function handleCatchall(proms, input, payload, ctx, def, inst) {
1463
+ const unrecognized = [];
1464
+ const keySet = def.keySet;
1465
+ const _catchall = def.catchall._zod;
1466
+ const t = _catchall.def.type;
1467
+ const isOptionalOut = _catchall.optout === "optional";
1468
+ for (const key in input) {
1469
+ if (keySet.has(key)) continue;
1470
+ if (t === "never") {
1471
+ unrecognized.push(key);
1472
+ continue;
1473
+ }
1474
+ const r = _catchall.run({
1475
+ value: input[key],
1476
+ issues: []
1477
+ }, ctx);
1478
+ if (r instanceof Promise) proms.push(r.then((r$1) => handlePropertyResult(r$1, payload, key, input, isOptionalOut)));
1479
+ else handlePropertyResult(r, payload, key, input, isOptionalOut);
1480
+ }
1481
+ if (unrecognized.length) payload.issues.push({
1482
+ code: "unrecognized_keys",
1483
+ keys: unrecognized,
1484
+ input,
1485
+ inst
1486
+ });
1487
+ if (!proms.length) return payload;
1488
+ return Promise.all(proms).then(() => {
1489
+ return payload;
1490
+ });
1491
+ }
1492
+ const $ZodObject = /* @__PURE__ */ $constructor("$ZodObject", (inst, def) => {
1493
+ $ZodType.init(inst, def);
1494
+ if (!Object.getOwnPropertyDescriptor(def, "shape")?.get) {
1495
+ const sh = def.shape;
1496
+ Object.defineProperty(def, "shape", { get: () => {
1497
+ const newSh = { ...sh };
1498
+ Object.defineProperty(def, "shape", { value: newSh });
1499
+ return newSh;
1500
+ } });
1501
+ }
1502
+ const _normalized = cached(() => normalizeDef(def));
1503
+ defineLazy(inst._zod, "propValues", () => {
1504
+ const shape = def.shape;
1505
+ const propValues = {};
1506
+ for (const key in shape) {
1507
+ const field = shape[key]._zod;
1508
+ if (field.values) {
1509
+ propValues[key] ?? (propValues[key] = /* @__PURE__ */ new Set());
1510
+ for (const v of field.values) propValues[key].add(v);
1511
+ }
1512
+ }
1513
+ return propValues;
1514
+ });
1515
+ const isObject$1 = isObject;
1516
+ const catchall = def.catchall;
1517
+ let value;
1518
+ inst._zod.parse = (payload, ctx) => {
1519
+ value ?? (value = _normalized.value);
1520
+ const input = payload.value;
1521
+ if (!isObject$1(input)) {
1522
+ payload.issues.push({
1523
+ expected: "object",
1524
+ code: "invalid_type",
1525
+ input,
1526
+ inst
1527
+ });
1528
+ return payload;
1529
+ }
1530
+ payload.value = {};
1531
+ const proms = [];
1532
+ const shape = value.shape;
1533
+ for (const key of value.keys) {
1534
+ const el = shape[key];
1535
+ const isOptionalOut = el._zod.optout === "optional";
1536
+ const r = el._zod.run({
1537
+ value: input[key],
1538
+ issues: []
1539
+ }, ctx);
1540
+ if (r instanceof Promise) proms.push(r.then((r$1) => handlePropertyResult(r$1, payload, key, input, isOptionalOut)));
1541
+ else handlePropertyResult(r, payload, key, input, isOptionalOut);
1542
+ }
1543
+ if (!catchall) return proms.length ? Promise.all(proms).then(() => payload) : payload;
1544
+ return handleCatchall(proms, input, payload, ctx, _normalized.value, inst);
1545
+ };
1546
+ });
1547
+ const $ZodObjectJIT = /* @__PURE__ */ $constructor("$ZodObjectJIT", (inst, def) => {
1548
+ $ZodObject.init(inst, def);
1549
+ const superParse = inst._zod.parse;
1550
+ const _normalized = cached(() => normalizeDef(def));
1551
+ const generateFastpass = (shape) => {
1552
+ const doc = new Doc([
1553
+ "shape",
1554
+ "payload",
1555
+ "ctx"
1556
+ ]);
1557
+ const normalized = _normalized.value;
1558
+ const parseStr = (key) => {
1559
+ const k = esc(key);
1560
+ return `shape[${k}]._zod.run({ value: input[${k}], issues: [] }, ctx)`;
1561
+ };
1562
+ doc.write(`const input = payload.value;`);
1563
+ const ids = Object.create(null);
1564
+ let counter = 0;
1565
+ for (const key of normalized.keys) ids[key] = `key_${counter++}`;
1566
+ doc.write(`const newResult = {};`);
1567
+ for (const key of normalized.keys) {
1568
+ const id = ids[key];
1569
+ const k = esc(key);
1570
+ const isOptionalOut = shape[key]?._zod?.optout === "optional";
1571
+ doc.write(`const ${id} = ${parseStr(key)};`);
1572
+ if (isOptionalOut) doc.write(`
1573
+ if (${id}.issues.length) {
1574
+ if (${k} in input) {
1575
+ payload.issues = payload.issues.concat(${id}.issues.map(iss => ({
1576
+ ...iss,
1577
+ path: iss.path ? [${k}, ...iss.path] : [${k}]
1578
+ })));
1579
+ }
1580
+ }
1581
+
1582
+ if (${id}.value === undefined) {
1583
+ if (${k} in input) {
1584
+ newResult[${k}] = undefined;
1585
+ }
1586
+ } else {
1587
+ newResult[${k}] = ${id}.value;
1588
+ }
1589
+
1590
+ `);
1591
+ else doc.write(`
1592
+ if (${id}.issues.length) {
1593
+ payload.issues = payload.issues.concat(${id}.issues.map(iss => ({
1594
+ ...iss,
1595
+ path: iss.path ? [${k}, ...iss.path] : [${k}]
1596
+ })));
1597
+ }
1598
+
1599
+ if (${id}.value === undefined) {
1600
+ if (${k} in input) {
1601
+ newResult[${k}] = undefined;
1602
+ }
1603
+ } else {
1604
+ newResult[${k}] = ${id}.value;
1605
+ }
1606
+
1607
+ `);
1608
+ }
1609
+ doc.write(`payload.value = newResult;`);
1610
+ doc.write(`return payload;`);
1611
+ const fn = doc.compile();
1612
+ return (payload, ctx) => fn(shape, payload, ctx);
1613
+ };
1614
+ let fastpass;
1615
+ const isObject$1 = isObject;
1616
+ const jit = !globalConfig.jitless;
1617
+ const allowsEval$1 = allowsEval;
1618
+ const fastEnabled = jit && allowsEval$1.value;
1619
+ const catchall = def.catchall;
1620
+ let value;
1621
+ inst._zod.parse = (payload, ctx) => {
1622
+ value ?? (value = _normalized.value);
1623
+ const input = payload.value;
1624
+ if (!isObject$1(input)) {
1625
+ payload.issues.push({
1626
+ expected: "object",
1627
+ code: "invalid_type",
1628
+ input,
1629
+ inst
1630
+ });
1631
+ return payload;
1632
+ }
1633
+ if (jit && fastEnabled && ctx?.async === false && ctx.jitless !== true) {
1634
+ if (!fastpass) fastpass = generateFastpass(def.shape);
1635
+ payload = fastpass(payload, ctx);
1636
+ if (!catchall) return payload;
1637
+ return handleCatchall([], input, payload, ctx, value, inst);
1638
+ }
1639
+ return superParse(payload, ctx);
1640
+ };
1641
+ });
1642
+ function handleUnionResults(results, final, inst, ctx) {
1643
+ for (const result of results) if (result.issues.length === 0) {
1644
+ final.value = result.value;
1645
+ return final;
1646
+ }
1647
+ const nonaborted = results.filter((r) => !aborted(r));
1648
+ if (nonaborted.length === 1) {
1649
+ final.value = nonaborted[0].value;
1650
+ return nonaborted[0];
1651
+ }
1652
+ final.issues.push({
1653
+ code: "invalid_union",
1654
+ input: final.value,
1655
+ inst,
1656
+ errors: results.map((result) => result.issues.map((iss) => finalizeIssue(iss, ctx, config())))
1657
+ });
1658
+ return final;
1659
+ }
1660
+ const $ZodUnion = /* @__PURE__ */ $constructor("$ZodUnion", (inst, def) => {
1661
+ $ZodType.init(inst, def);
1662
+ defineLazy(inst._zod, "optin", () => def.options.some((o) => o._zod.optin === "optional") ? "optional" : void 0);
1663
+ defineLazy(inst._zod, "optout", () => def.options.some((o) => o._zod.optout === "optional") ? "optional" : void 0);
1664
+ defineLazy(inst._zod, "values", () => {
1665
+ if (def.options.every((o) => o._zod.values)) return new Set(def.options.flatMap((option) => Array.from(option._zod.values)));
1666
+ });
1667
+ defineLazy(inst._zod, "pattern", () => {
1668
+ if (def.options.every((o) => o._zod.pattern)) {
1669
+ const patterns = def.options.map((o) => o._zod.pattern);
1670
+ return /* @__PURE__ */ new RegExp(`^(${patterns.map((p) => cleanRegex(p.source)).join("|")})$`);
1671
+ }
1672
+ });
1673
+ const single = def.options.length === 1;
1674
+ const first = def.options[0]._zod.run;
1675
+ inst._zod.parse = (payload, ctx) => {
1676
+ if (single) return first(payload, ctx);
1677
+ let async = false;
1678
+ const results = [];
1679
+ for (const option of def.options) {
1680
+ const result = option._zod.run({
1681
+ value: payload.value,
1682
+ issues: []
1683
+ }, ctx);
1684
+ if (result instanceof Promise) {
1685
+ results.push(result);
1686
+ async = true;
1687
+ } else {
1688
+ if (result.issues.length === 0) return result;
1689
+ results.push(result);
1690
+ }
1691
+ }
1692
+ if (!async) return handleUnionResults(results, payload, inst, ctx);
1693
+ return Promise.all(results).then((results$1) => {
1694
+ return handleUnionResults(results$1, payload, inst, ctx);
1695
+ });
1696
+ };
1697
+ });
1698
+ const $ZodDiscriminatedUnion = /* @__PURE__ */ $constructor("$ZodDiscriminatedUnion", (inst, def) => {
1699
+ def.inclusive = false;
1700
+ $ZodUnion.init(inst, def);
1701
+ const _super = inst._zod.parse;
1702
+ defineLazy(inst._zod, "propValues", () => {
1703
+ const propValues = {};
1704
+ for (const option of def.options) {
1705
+ const pv = option._zod.propValues;
1706
+ if (!pv || Object.keys(pv).length === 0) throw new Error(`Invalid discriminated union option at index "${def.options.indexOf(option)}"`);
1707
+ for (const [k, v] of Object.entries(pv)) {
1708
+ if (!propValues[k]) propValues[k] = /* @__PURE__ */ new Set();
1709
+ for (const val of v) propValues[k].add(val);
1710
+ }
1711
+ }
1712
+ return propValues;
1713
+ });
1714
+ const disc = cached(() => {
1715
+ const opts = def.options;
1716
+ const map = /* @__PURE__ */ new Map();
1717
+ for (const o of opts) {
1718
+ const values = o._zod.propValues?.[def.discriminator];
1719
+ if (!values || values.size === 0) throw new Error(`Invalid discriminated union option at index "${def.options.indexOf(o)}"`);
1720
+ for (const v of values) {
1721
+ if (map.has(v)) throw new Error(`Duplicate discriminator value "${String(v)}"`);
1722
+ map.set(v, o);
1723
+ }
1724
+ }
1725
+ return map;
1726
+ });
1727
+ inst._zod.parse = (payload, ctx) => {
1728
+ const input = payload.value;
1729
+ if (!isObject(input)) {
1730
+ payload.issues.push({
1731
+ code: "invalid_type",
1732
+ expected: "object",
1733
+ input,
1734
+ inst
1735
+ });
1736
+ return payload;
1737
+ }
1738
+ const opt = disc.value.get(input?.[def.discriminator]);
1739
+ if (opt) return opt._zod.run(payload, ctx);
1740
+ if (def.unionFallback) return _super(payload, ctx);
1741
+ payload.issues.push({
1742
+ code: "invalid_union",
1743
+ errors: [],
1744
+ note: "No matching discriminator",
1745
+ discriminator: def.discriminator,
1746
+ input,
1747
+ path: [def.discriminator],
1748
+ inst
1749
+ });
1750
+ return payload;
1751
+ };
1752
+ });
1753
+ const $ZodIntersection = /* @__PURE__ */ $constructor("$ZodIntersection", (inst, def) => {
1754
+ $ZodType.init(inst, def);
1755
+ inst._zod.parse = (payload, ctx) => {
1756
+ const input = payload.value;
1757
+ const left = def.left._zod.run({
1758
+ value: input,
1759
+ issues: []
1760
+ }, ctx);
1761
+ const right = def.right._zod.run({
1762
+ value: input,
1763
+ issues: []
1764
+ }, ctx);
1765
+ if (left instanceof Promise || right instanceof Promise) return Promise.all([left, right]).then(([left$1, right$1]) => {
1766
+ return handleIntersectionResults(payload, left$1, right$1);
1767
+ });
1768
+ return handleIntersectionResults(payload, left, right);
1769
+ };
1770
+ });
1771
+ function mergeValues(a, b) {
1772
+ if (a === b) return {
1773
+ valid: true,
1774
+ data: a
1775
+ };
1776
+ if (a instanceof Date && b instanceof Date && +a === +b) return {
1777
+ valid: true,
1778
+ data: a
1779
+ };
1780
+ if (isPlainObject(a) && isPlainObject(b)) {
1781
+ const bKeys = Object.keys(b);
1782
+ const sharedKeys = Object.keys(a).filter((key) => bKeys.indexOf(key) !== -1);
1783
+ const newObj = {
1784
+ ...a,
1785
+ ...b
1786
+ };
1787
+ for (const key of sharedKeys) {
1788
+ const sharedValue = mergeValues(a[key], b[key]);
1789
+ if (!sharedValue.valid) return {
1790
+ valid: false,
1791
+ mergeErrorPath: [key, ...sharedValue.mergeErrorPath]
1792
+ };
1793
+ newObj[key] = sharedValue.data;
1794
+ }
1795
+ return {
1796
+ valid: true,
1797
+ data: newObj
1798
+ };
1799
+ }
1800
+ if (Array.isArray(a) && Array.isArray(b)) {
1801
+ if (a.length !== b.length) return {
1802
+ valid: false,
1803
+ mergeErrorPath: []
1804
+ };
1805
+ const newArray = [];
1806
+ for (let index = 0; index < a.length; index++) {
1807
+ const itemA = a[index];
1808
+ const itemB = b[index];
1809
+ const sharedValue = mergeValues(itemA, itemB);
1810
+ if (!sharedValue.valid) return {
1811
+ valid: false,
1812
+ mergeErrorPath: [index, ...sharedValue.mergeErrorPath]
1813
+ };
1814
+ newArray.push(sharedValue.data);
1815
+ }
1816
+ return {
1817
+ valid: true,
1818
+ data: newArray
1819
+ };
1820
+ }
1821
+ return {
1822
+ valid: false,
1823
+ mergeErrorPath: []
1824
+ };
1825
+ }
1826
+ function handleIntersectionResults(result, left, right) {
1827
+ const unrecKeys = /* @__PURE__ */ new Map();
1828
+ let unrecIssue;
1829
+ for (const iss of left.issues) if (iss.code === "unrecognized_keys") {
1830
+ unrecIssue ?? (unrecIssue = iss);
1831
+ for (const k of iss.keys) {
1832
+ if (!unrecKeys.has(k)) unrecKeys.set(k, {});
1833
+ unrecKeys.get(k).l = true;
1834
+ }
1835
+ } else result.issues.push(iss);
1836
+ for (const iss of right.issues) if (iss.code === "unrecognized_keys") for (const k of iss.keys) {
1837
+ if (!unrecKeys.has(k)) unrecKeys.set(k, {});
1838
+ unrecKeys.get(k).r = true;
1839
+ }
1840
+ else result.issues.push(iss);
1841
+ const bothKeys = [...unrecKeys].filter(([, f]) => f.l && f.r).map(([k]) => k);
1842
+ if (bothKeys.length && unrecIssue) result.issues.push({
1843
+ ...unrecIssue,
1844
+ keys: bothKeys
1845
+ });
1846
+ if (aborted(result)) return result;
1847
+ const merged = mergeValues(left.value, right.value);
1848
+ if (!merged.valid) throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(merged.mergeErrorPath)}`);
1849
+ result.value = merged.data;
1850
+ return result;
1851
+ }
1852
+ const $ZodRecord = /* @__PURE__ */ $constructor("$ZodRecord", (inst, def) => {
1853
+ $ZodType.init(inst, def);
1854
+ inst._zod.parse = (payload, ctx) => {
1855
+ const input = payload.value;
1856
+ if (!isPlainObject(input)) {
1857
+ payload.issues.push({
1858
+ expected: "record",
1859
+ code: "invalid_type",
1860
+ input,
1861
+ inst
1862
+ });
1863
+ return payload;
1864
+ }
1865
+ const proms = [];
1866
+ const values = def.keyType._zod.values;
1867
+ if (values) {
1868
+ payload.value = {};
1869
+ const recordKeys = /* @__PURE__ */ new Set();
1870
+ for (const key of values) if (typeof key === "string" || typeof key === "number" || typeof key === "symbol") {
1871
+ recordKeys.add(typeof key === "number" ? key.toString() : key);
1872
+ const result = def.valueType._zod.run({
1873
+ value: input[key],
1874
+ issues: []
1875
+ }, ctx);
1876
+ if (result instanceof Promise) proms.push(result.then((result$1) => {
1877
+ if (result$1.issues.length) payload.issues.push(...prefixIssues(key, result$1.issues));
1878
+ payload.value[key] = result$1.value;
1879
+ }));
1880
+ else {
1881
+ if (result.issues.length) payload.issues.push(...prefixIssues(key, result.issues));
1882
+ payload.value[key] = result.value;
1883
+ }
1884
+ }
1885
+ let unrecognized;
1886
+ for (const key in input) if (!recordKeys.has(key)) {
1887
+ unrecognized = unrecognized ?? [];
1888
+ unrecognized.push(key);
1889
+ }
1890
+ if (unrecognized && unrecognized.length > 0) payload.issues.push({
1891
+ code: "unrecognized_keys",
1892
+ input,
1893
+ inst,
1894
+ keys: unrecognized
1895
+ });
1896
+ } else {
1897
+ payload.value = {};
1898
+ for (const key of Reflect.ownKeys(input)) {
1899
+ if (key === "__proto__") continue;
1900
+ let keyResult = def.keyType._zod.run({
1901
+ value: key,
1902
+ issues: []
1903
+ }, ctx);
1904
+ if (keyResult instanceof Promise) throw new Error("Async schemas not supported in object keys currently");
1905
+ if (typeof key === "string" && number$2.test(key) && keyResult.issues.length) {
1906
+ const retryResult = def.keyType._zod.run({
1907
+ value: Number(key),
1908
+ issues: []
1909
+ }, ctx);
1910
+ if (retryResult instanceof Promise) throw new Error("Async schemas not supported in object keys currently");
1911
+ if (retryResult.issues.length === 0) keyResult = retryResult;
1912
+ }
1913
+ if (keyResult.issues.length) {
1914
+ if (def.mode === "loose") payload.value[key] = input[key];
1915
+ else payload.issues.push({
1916
+ code: "invalid_key",
1917
+ origin: "record",
1918
+ issues: keyResult.issues.map((iss) => finalizeIssue(iss, ctx, config())),
1919
+ input: key,
1920
+ path: [key],
1921
+ inst
1922
+ });
1923
+ continue;
1924
+ }
1925
+ const result = def.valueType._zod.run({
1926
+ value: input[key],
1927
+ issues: []
1928
+ }, ctx);
1929
+ if (result instanceof Promise) proms.push(result.then((result$1) => {
1930
+ if (result$1.issues.length) payload.issues.push(...prefixIssues(key, result$1.issues));
1931
+ payload.value[keyResult.value] = result$1.value;
1932
+ }));
1933
+ else {
1934
+ if (result.issues.length) payload.issues.push(...prefixIssues(key, result.issues));
1935
+ payload.value[keyResult.value] = result.value;
1936
+ }
1937
+ }
1938
+ }
1939
+ if (proms.length) return Promise.all(proms).then(() => payload);
1940
+ return payload;
1941
+ };
1942
+ });
1943
+ const $ZodEnum = /* @__PURE__ */ $constructor("$ZodEnum", (inst, def) => {
1944
+ $ZodType.init(inst, def);
1945
+ const values = getEnumValues(def.entries);
1946
+ const valuesSet = new Set(values);
1947
+ inst._zod.values = valuesSet;
1948
+ inst._zod.pattern = /* @__PURE__ */ new RegExp(`^(${values.filter((k) => propertyKeyTypes.has(typeof k)).map((o) => typeof o === "string" ? escapeRegex(o) : o.toString()).join("|")})$`);
1949
+ inst._zod.parse = (payload, _ctx) => {
1950
+ const input = payload.value;
1951
+ if (valuesSet.has(input)) return payload;
1952
+ payload.issues.push({
1953
+ code: "invalid_value",
1954
+ values,
1955
+ input,
1956
+ inst
1957
+ });
1958
+ return payload;
1959
+ };
1960
+ });
1961
+ const $ZodLiteral = /* @__PURE__ */ $constructor("$ZodLiteral", (inst, def) => {
1962
+ $ZodType.init(inst, def);
1963
+ if (def.values.length === 0) throw new Error("Cannot create literal schema with no valid values");
1964
+ const values = new Set(def.values);
1965
+ inst._zod.values = values;
1966
+ inst._zod.pattern = /* @__PURE__ */ new RegExp(`^(${def.values.map((o) => typeof o === "string" ? escapeRegex(o) : o ? escapeRegex(o.toString()) : String(o)).join("|")})$`);
1967
+ inst._zod.parse = (payload, _ctx) => {
1968
+ const input = payload.value;
1969
+ if (values.has(input)) return payload;
1970
+ payload.issues.push({
1971
+ code: "invalid_value",
1972
+ values: def.values,
1973
+ input,
1974
+ inst
1975
+ });
1976
+ return payload;
1977
+ };
1978
+ });
1979
+ const $ZodTransform = /* @__PURE__ */ $constructor("$ZodTransform", (inst, def) => {
1980
+ $ZodType.init(inst, def);
1981
+ inst._zod.parse = (payload, ctx) => {
1982
+ if (ctx.direction === "backward") throw new $ZodEncodeError(inst.constructor.name);
1983
+ const _out = def.transform(payload.value, payload);
1984
+ if (ctx.async) return (_out instanceof Promise ? _out : Promise.resolve(_out)).then((output) => {
1985
+ payload.value = output;
1986
+ return payload;
1987
+ });
1988
+ if (_out instanceof Promise) throw new $ZodAsyncError();
1989
+ payload.value = _out;
1990
+ return payload;
1991
+ };
1992
+ });
1993
+ function handleOptionalResult(result, input) {
1994
+ if (result.issues.length && input === void 0) return {
1995
+ issues: [],
1996
+ value: void 0
1997
+ };
1998
+ return result;
1999
+ }
2000
+ const $ZodOptional = /* @__PURE__ */ $constructor("$ZodOptional", (inst, def) => {
2001
+ $ZodType.init(inst, def);
2002
+ inst._zod.optin = "optional";
2003
+ inst._zod.optout = "optional";
2004
+ defineLazy(inst._zod, "values", () => {
2005
+ return def.innerType._zod.values ? new Set([...def.innerType._zod.values, void 0]) : void 0;
2006
+ });
2007
+ defineLazy(inst._zod, "pattern", () => {
2008
+ const pattern = def.innerType._zod.pattern;
2009
+ return pattern ? /* @__PURE__ */ new RegExp(`^(${cleanRegex(pattern.source)})?$`) : void 0;
2010
+ });
2011
+ inst._zod.parse = (payload, ctx) => {
2012
+ if (def.innerType._zod.optin === "optional") {
2013
+ const result = def.innerType._zod.run(payload, ctx);
2014
+ if (result instanceof Promise) return result.then((r) => handleOptionalResult(r, payload.value));
2015
+ return handleOptionalResult(result, payload.value);
2016
+ }
2017
+ if (payload.value === void 0) return payload;
2018
+ return def.innerType._zod.run(payload, ctx);
2019
+ };
2020
+ });
2021
+ const $ZodExactOptional = /* @__PURE__ */ $constructor("$ZodExactOptional", (inst, def) => {
2022
+ $ZodOptional.init(inst, def);
2023
+ defineLazy(inst._zod, "values", () => def.innerType._zod.values);
2024
+ defineLazy(inst._zod, "pattern", () => def.innerType._zod.pattern);
2025
+ inst._zod.parse = (payload, ctx) => {
2026
+ return def.innerType._zod.run(payload, ctx);
2027
+ };
2028
+ });
2029
+ const $ZodNullable = /* @__PURE__ */ $constructor("$ZodNullable", (inst, def) => {
2030
+ $ZodType.init(inst, def);
2031
+ defineLazy(inst._zod, "optin", () => def.innerType._zod.optin);
2032
+ defineLazy(inst._zod, "optout", () => def.innerType._zod.optout);
2033
+ defineLazy(inst._zod, "pattern", () => {
2034
+ const pattern = def.innerType._zod.pattern;
2035
+ return pattern ? /* @__PURE__ */ new RegExp(`^(${cleanRegex(pattern.source)}|null)$`) : void 0;
2036
+ });
2037
+ defineLazy(inst._zod, "values", () => {
2038
+ return def.innerType._zod.values ? new Set([...def.innerType._zod.values, null]) : void 0;
2039
+ });
2040
+ inst._zod.parse = (payload, ctx) => {
2041
+ if (payload.value === null) return payload;
2042
+ return def.innerType._zod.run(payload, ctx);
2043
+ };
2044
+ });
2045
+ const $ZodDefault = /* @__PURE__ */ $constructor("$ZodDefault", (inst, def) => {
2046
+ $ZodType.init(inst, def);
2047
+ inst._zod.optin = "optional";
2048
+ defineLazy(inst._zod, "values", () => def.innerType._zod.values);
2049
+ inst._zod.parse = (payload, ctx) => {
2050
+ if (ctx.direction === "backward") return def.innerType._zod.run(payload, ctx);
2051
+ if (payload.value === void 0) {
2052
+ payload.value = def.defaultValue;
2053
+ /**
2054
+ * $ZodDefault returns the default value immediately in forward direction.
2055
+ * 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. */
2056
+ return payload;
2057
+ }
2058
+ const result = def.innerType._zod.run(payload, ctx);
2059
+ if (result instanceof Promise) return result.then((result$1) => handleDefaultResult(result$1, def));
2060
+ return handleDefaultResult(result, def);
2061
+ };
2062
+ });
2063
+ function handleDefaultResult(payload, def) {
2064
+ if (payload.value === void 0) payload.value = def.defaultValue;
2065
+ return payload;
2066
+ }
2067
+ const $ZodPrefault = /* @__PURE__ */ $constructor("$ZodPrefault", (inst, def) => {
2068
+ $ZodType.init(inst, def);
2069
+ inst._zod.optin = "optional";
2070
+ defineLazy(inst._zod, "values", () => def.innerType._zod.values);
2071
+ inst._zod.parse = (payload, ctx) => {
2072
+ if (ctx.direction === "backward") return def.innerType._zod.run(payload, ctx);
2073
+ if (payload.value === void 0) payload.value = def.defaultValue;
2074
+ return def.innerType._zod.run(payload, ctx);
2075
+ };
2076
+ });
2077
+ const $ZodNonOptional = /* @__PURE__ */ $constructor("$ZodNonOptional", (inst, def) => {
2078
+ $ZodType.init(inst, def);
2079
+ defineLazy(inst._zod, "values", () => {
2080
+ const v = def.innerType._zod.values;
2081
+ return v ? new Set([...v].filter((x) => x !== void 0)) : void 0;
2082
+ });
2083
+ inst._zod.parse = (payload, ctx) => {
2084
+ const result = def.innerType._zod.run(payload, ctx);
2085
+ if (result instanceof Promise) return result.then((result$1) => handleNonOptionalResult(result$1, inst));
2086
+ return handleNonOptionalResult(result, inst);
2087
+ };
2088
+ });
2089
+ function handleNonOptionalResult(payload, inst) {
2090
+ if (!payload.issues.length && payload.value === void 0) payload.issues.push({
2091
+ code: "invalid_type",
2092
+ expected: "nonoptional",
2093
+ input: payload.value,
2094
+ inst
2095
+ });
2096
+ return payload;
2097
+ }
2098
+ const $ZodCatch = /* @__PURE__ */ $constructor("$ZodCatch", (inst, def) => {
2099
+ $ZodType.init(inst, def);
2100
+ defineLazy(inst._zod, "optin", () => def.innerType._zod.optin);
2101
+ defineLazy(inst._zod, "optout", () => def.innerType._zod.optout);
2102
+ defineLazy(inst._zod, "values", () => def.innerType._zod.values);
2103
+ inst._zod.parse = (payload, ctx) => {
2104
+ if (ctx.direction === "backward") return def.innerType._zod.run(payload, ctx);
2105
+ const result = def.innerType._zod.run(payload, ctx);
2106
+ if (result instanceof Promise) return result.then((result$1) => {
2107
+ payload.value = result$1.value;
2108
+ if (result$1.issues.length) {
2109
+ payload.value = def.catchValue({
2110
+ ...payload,
2111
+ error: { issues: result$1.issues.map((iss) => finalizeIssue(iss, ctx, config())) },
2112
+ input: payload.value
2113
+ });
2114
+ payload.issues = [];
2115
+ }
2116
+ return payload;
2117
+ });
2118
+ payload.value = result.value;
2119
+ if (result.issues.length) {
2120
+ payload.value = def.catchValue({
2121
+ ...payload,
2122
+ error: { issues: result.issues.map((iss) => finalizeIssue(iss, ctx, config())) },
2123
+ input: payload.value
2124
+ });
2125
+ payload.issues = [];
2126
+ }
2127
+ return payload;
2128
+ };
2129
+ });
2130
+ const $ZodPipe = /* @__PURE__ */ $constructor("$ZodPipe", (inst, def) => {
2131
+ $ZodType.init(inst, def);
2132
+ defineLazy(inst._zod, "values", () => def.in._zod.values);
2133
+ defineLazy(inst._zod, "optin", () => def.in._zod.optin);
2134
+ defineLazy(inst._zod, "optout", () => def.out._zod.optout);
2135
+ defineLazy(inst._zod, "propValues", () => def.in._zod.propValues);
2136
+ inst._zod.parse = (payload, ctx) => {
2137
+ if (ctx.direction === "backward") {
2138
+ const right = def.out._zod.run(payload, ctx);
2139
+ if (right instanceof Promise) return right.then((right$1) => handlePipeResult(right$1, def.in, ctx));
2140
+ return handlePipeResult(right, def.in, ctx);
2141
+ }
2142
+ const left = def.in._zod.run(payload, ctx);
2143
+ if (left instanceof Promise) return left.then((left$1) => handlePipeResult(left$1, def.out, ctx));
2144
+ return handlePipeResult(left, def.out, ctx);
2145
+ };
2146
+ });
2147
+ function handlePipeResult(left, next, ctx) {
2148
+ if (left.issues.length) {
2149
+ left.aborted = true;
2150
+ return left;
2151
+ }
2152
+ return next._zod.run({
2153
+ value: left.value,
2154
+ issues: left.issues
2155
+ }, ctx);
2156
+ }
2157
+ const $ZodReadonly = /* @__PURE__ */ $constructor("$ZodReadonly", (inst, def) => {
2158
+ $ZodType.init(inst, def);
2159
+ defineLazy(inst._zod, "propValues", () => def.innerType._zod.propValues);
2160
+ defineLazy(inst._zod, "values", () => def.innerType._zod.values);
2161
+ defineLazy(inst._zod, "optin", () => def.innerType?._zod?.optin);
2162
+ defineLazy(inst._zod, "optout", () => def.innerType?._zod?.optout);
2163
+ inst._zod.parse = (payload, ctx) => {
2164
+ if (ctx.direction === "backward") return def.innerType._zod.run(payload, ctx);
2165
+ const result = def.innerType._zod.run(payload, ctx);
2166
+ if (result instanceof Promise) return result.then(handleReadonlyResult);
2167
+ return handleReadonlyResult(result);
2168
+ };
2169
+ });
2170
+ function handleReadonlyResult(payload) {
2171
+ payload.value = Object.freeze(payload.value);
2172
+ return payload;
2173
+ }
2174
+ const $ZodCustom = /* @__PURE__ */ $constructor("$ZodCustom", (inst, def) => {
2175
+ $ZodCheck.init(inst, def);
2176
+ $ZodType.init(inst, def);
2177
+ inst._zod.parse = (payload, _) => {
2178
+ return payload;
2179
+ };
2180
+ inst._zod.check = (payload) => {
2181
+ const input = payload.value;
2182
+ const r = def.fn(input);
2183
+ if (r instanceof Promise) return r.then((r$1) => handleRefineResult(r$1, payload, input, inst));
2184
+ handleRefineResult(r, payload, input, inst);
2185
+ };
2186
+ });
2187
+ function handleRefineResult(result, payload, input, inst) {
2188
+ if (!result) {
2189
+ const _iss = {
2190
+ code: "custom",
2191
+ input,
2192
+ inst,
2193
+ path: [...inst._zod.def.path ?? []],
2194
+ continue: !inst._zod.def.abort
2195
+ };
2196
+ if (inst._zod.def.params) _iss.params = inst._zod.def.params;
2197
+ payload.issues.push(issue(_iss));
2198
+ }
2199
+ }
2200
+
2201
+ //#endregion
2202
+ //#region node_modules/zod/v4/core/registries.js
2203
+ var _a;
2204
+ var $ZodRegistry = class {
2205
+ constructor() {
2206
+ this._map = /* @__PURE__ */ new WeakMap();
2207
+ this._idmap = /* @__PURE__ */ new Map();
2208
+ }
2209
+ add(schema, ..._meta) {
2210
+ const meta$2 = _meta[0];
2211
+ this._map.set(schema, meta$2);
2212
+ if (meta$2 && typeof meta$2 === "object" && "id" in meta$2) this._idmap.set(meta$2.id, schema);
2213
+ return this;
2214
+ }
2215
+ clear() {
2216
+ this._map = /* @__PURE__ */ new WeakMap();
2217
+ this._idmap = /* @__PURE__ */ new Map();
2218
+ return this;
2219
+ }
2220
+ remove(schema) {
2221
+ const meta$2 = this._map.get(schema);
2222
+ if (meta$2 && typeof meta$2 === "object" && "id" in meta$2) this._idmap.delete(meta$2.id);
2223
+ this._map.delete(schema);
2224
+ return this;
2225
+ }
2226
+ get(schema) {
2227
+ const p = schema._zod.parent;
2228
+ if (p) {
2229
+ const pm = { ...this.get(p) ?? {} };
2230
+ delete pm.id;
2231
+ const f = {
2232
+ ...pm,
2233
+ ...this._map.get(schema)
2234
+ };
2235
+ return Object.keys(f).length ? f : void 0;
2236
+ }
2237
+ return this._map.get(schema);
2238
+ }
2239
+ has(schema) {
2240
+ return this._map.has(schema);
2241
+ }
2242
+ };
2243
+ function registry() {
2244
+ return new $ZodRegistry();
2245
+ }
2246
+ (_a = globalThis).__zod_globalRegistry ?? (_a.__zod_globalRegistry = registry());
2247
+ const globalRegistry = globalThis.__zod_globalRegistry;
2248
+
2249
+ //#endregion
2250
+ //#region node_modules/zod/v4/core/api.js
2251
+ /* @__NO_SIDE_EFFECTS__ */
2252
+ function _string(Class, params) {
2253
+ return new Class({
2254
+ type: "string",
2255
+ ...normalizeParams(params)
2256
+ });
2257
+ }
2258
+ /* @__NO_SIDE_EFFECTS__ */
2259
+ function _email(Class, params) {
2260
+ return new Class({
2261
+ type: "string",
2262
+ format: "email",
2263
+ check: "string_format",
2264
+ abort: false,
2265
+ ...normalizeParams(params)
2266
+ });
2267
+ }
2268
+ /* @__NO_SIDE_EFFECTS__ */
2269
+ function _guid(Class, params) {
2270
+ return new Class({
2271
+ type: "string",
2272
+ format: "guid",
2273
+ check: "string_format",
2274
+ abort: false,
2275
+ ...normalizeParams(params)
2276
+ });
2277
+ }
2278
+ /* @__NO_SIDE_EFFECTS__ */
2279
+ function _uuid(Class, params) {
2280
+ return new Class({
2281
+ type: "string",
2282
+ format: "uuid",
2283
+ check: "string_format",
2284
+ abort: false,
2285
+ ...normalizeParams(params)
2286
+ });
2287
+ }
2288
+ /* @__NO_SIDE_EFFECTS__ */
2289
+ function _uuidv4(Class, params) {
2290
+ return new Class({
2291
+ type: "string",
2292
+ format: "uuid",
2293
+ check: "string_format",
2294
+ abort: false,
2295
+ version: "v4",
2296
+ ...normalizeParams(params)
2297
+ });
2298
+ }
2299
+ /* @__NO_SIDE_EFFECTS__ */
2300
+ function _uuidv6(Class, params) {
2301
+ return new Class({
2302
+ type: "string",
2303
+ format: "uuid",
2304
+ check: "string_format",
2305
+ abort: false,
2306
+ version: "v6",
2307
+ ...normalizeParams(params)
2308
+ });
2309
+ }
2310
+ /* @__NO_SIDE_EFFECTS__ */
2311
+ function _uuidv7(Class, params) {
2312
+ return new Class({
2313
+ type: "string",
2314
+ format: "uuid",
2315
+ check: "string_format",
2316
+ abort: false,
2317
+ version: "v7",
2318
+ ...normalizeParams(params)
2319
+ });
2320
+ }
2321
+ /* @__NO_SIDE_EFFECTS__ */
2322
+ function _url(Class, params) {
2323
+ return new Class({
2324
+ type: "string",
2325
+ format: "url",
2326
+ check: "string_format",
2327
+ abort: false,
2328
+ ...normalizeParams(params)
2329
+ });
2330
+ }
2331
+ /* @__NO_SIDE_EFFECTS__ */
2332
+ function _emoji(Class, params) {
2333
+ return new Class({
2334
+ type: "string",
2335
+ format: "emoji",
2336
+ check: "string_format",
2337
+ abort: false,
2338
+ ...normalizeParams(params)
2339
+ });
2340
+ }
2341
+ /* @__NO_SIDE_EFFECTS__ */
2342
+ function _nanoid(Class, params) {
2343
+ return new Class({
2344
+ type: "string",
2345
+ format: "nanoid",
2346
+ check: "string_format",
2347
+ abort: false,
2348
+ ...normalizeParams(params)
2349
+ });
2350
+ }
2351
+ /* @__NO_SIDE_EFFECTS__ */
2352
+ function _cuid(Class, params) {
2353
+ return new Class({
2354
+ type: "string",
2355
+ format: "cuid",
2356
+ check: "string_format",
2357
+ abort: false,
2358
+ ...normalizeParams(params)
2359
+ });
2360
+ }
2361
+ /* @__NO_SIDE_EFFECTS__ */
2362
+ function _cuid2(Class, params) {
2363
+ return new Class({
2364
+ type: "string",
2365
+ format: "cuid2",
2366
+ check: "string_format",
2367
+ abort: false,
2368
+ ...normalizeParams(params)
2369
+ });
2370
+ }
2371
+ /* @__NO_SIDE_EFFECTS__ */
2372
+ function _ulid(Class, params) {
2373
+ return new Class({
2374
+ type: "string",
2375
+ format: "ulid",
2376
+ check: "string_format",
2377
+ abort: false,
2378
+ ...normalizeParams(params)
2379
+ });
2380
+ }
2381
+ /* @__NO_SIDE_EFFECTS__ */
2382
+ function _xid(Class, params) {
2383
+ return new Class({
2384
+ type: "string",
2385
+ format: "xid",
2386
+ check: "string_format",
2387
+ abort: false,
2388
+ ...normalizeParams(params)
2389
+ });
2390
+ }
2391
+ /* @__NO_SIDE_EFFECTS__ */
2392
+ function _ksuid(Class, params) {
2393
+ return new Class({
2394
+ type: "string",
2395
+ format: "ksuid",
2396
+ check: "string_format",
2397
+ abort: false,
2398
+ ...normalizeParams(params)
2399
+ });
2400
+ }
2401
+ /* @__NO_SIDE_EFFECTS__ */
2402
+ function _ipv4(Class, params) {
2403
+ return new Class({
2404
+ type: "string",
2405
+ format: "ipv4",
2406
+ check: "string_format",
2407
+ abort: false,
2408
+ ...normalizeParams(params)
2409
+ });
2410
+ }
2411
+ /* @__NO_SIDE_EFFECTS__ */
2412
+ function _ipv6(Class, params) {
2413
+ return new Class({
2414
+ type: "string",
2415
+ format: "ipv6",
2416
+ check: "string_format",
2417
+ abort: false,
2418
+ ...normalizeParams(params)
2419
+ });
2420
+ }
2421
+ /* @__NO_SIDE_EFFECTS__ */
2422
+ function _cidrv4(Class, params) {
2423
+ return new Class({
2424
+ type: "string",
2425
+ format: "cidrv4",
2426
+ check: "string_format",
2427
+ abort: false,
2428
+ ...normalizeParams(params)
2429
+ });
2430
+ }
2431
+ /* @__NO_SIDE_EFFECTS__ */
2432
+ function _cidrv6(Class, params) {
2433
+ return new Class({
2434
+ type: "string",
2435
+ format: "cidrv6",
2436
+ check: "string_format",
2437
+ abort: false,
2438
+ ...normalizeParams(params)
2439
+ });
2440
+ }
2441
+ /* @__NO_SIDE_EFFECTS__ */
2442
+ function _base64(Class, params) {
2443
+ return new Class({
2444
+ type: "string",
2445
+ format: "base64",
2446
+ check: "string_format",
2447
+ abort: false,
2448
+ ...normalizeParams(params)
2449
+ });
2450
+ }
2451
+ /* @__NO_SIDE_EFFECTS__ */
2452
+ function _base64url(Class, params) {
2453
+ return new Class({
2454
+ type: "string",
2455
+ format: "base64url",
2456
+ check: "string_format",
2457
+ abort: false,
2458
+ ...normalizeParams(params)
2459
+ });
2460
+ }
2461
+ /* @__NO_SIDE_EFFECTS__ */
2462
+ function _e164(Class, params) {
2463
+ return new Class({
2464
+ type: "string",
2465
+ format: "e164",
2466
+ check: "string_format",
2467
+ abort: false,
2468
+ ...normalizeParams(params)
2469
+ });
2470
+ }
2471
+ /* @__NO_SIDE_EFFECTS__ */
2472
+ function _jwt(Class, params) {
2473
+ return new Class({
2474
+ type: "string",
2475
+ format: "jwt",
2476
+ check: "string_format",
2477
+ abort: false,
2478
+ ...normalizeParams(params)
2479
+ });
2480
+ }
2481
+ /* @__NO_SIDE_EFFECTS__ */
2482
+ function _isoDateTime(Class, params) {
2483
+ return new Class({
2484
+ type: "string",
2485
+ format: "datetime",
2486
+ check: "string_format",
2487
+ offset: false,
2488
+ local: false,
2489
+ precision: null,
2490
+ ...normalizeParams(params)
2491
+ });
2492
+ }
2493
+ /* @__NO_SIDE_EFFECTS__ */
2494
+ function _isoDate(Class, params) {
2495
+ return new Class({
2496
+ type: "string",
2497
+ format: "date",
2498
+ check: "string_format",
2499
+ ...normalizeParams(params)
2500
+ });
2501
+ }
2502
+ /* @__NO_SIDE_EFFECTS__ */
2503
+ function _isoTime(Class, params) {
2504
+ return new Class({
2505
+ type: "string",
2506
+ format: "time",
2507
+ check: "string_format",
2508
+ precision: null,
2509
+ ...normalizeParams(params)
2510
+ });
2511
+ }
2512
+ /* @__NO_SIDE_EFFECTS__ */
2513
+ function _isoDuration(Class, params) {
2514
+ return new Class({
2515
+ type: "string",
2516
+ format: "duration",
2517
+ check: "string_format",
2518
+ ...normalizeParams(params)
2519
+ });
2520
+ }
2521
+ /* @__NO_SIDE_EFFECTS__ */
2522
+ function _number(Class, params) {
2523
+ return new Class({
2524
+ type: "number",
2525
+ checks: [],
2526
+ ...normalizeParams(params)
2527
+ });
2528
+ }
2529
+ /* @__NO_SIDE_EFFECTS__ */
2530
+ function _coercedNumber(Class, params) {
2531
+ return new Class({
2532
+ type: "number",
2533
+ coerce: true,
2534
+ checks: [],
2535
+ ...normalizeParams(params)
2536
+ });
2537
+ }
2538
+ /* @__NO_SIDE_EFFECTS__ */
2539
+ function _int(Class, params) {
2540
+ return new Class({
2541
+ type: "number",
2542
+ check: "number_format",
2543
+ abort: false,
2544
+ format: "safeint",
2545
+ ...normalizeParams(params)
2546
+ });
2547
+ }
2548
+ /* @__NO_SIDE_EFFECTS__ */
2549
+ function _boolean(Class, params) {
2550
+ return new Class({
2551
+ type: "boolean",
2552
+ ...normalizeParams(params)
2553
+ });
2554
+ }
2555
+ /* @__NO_SIDE_EFFECTS__ */
2556
+ function _any(Class) {
2557
+ return new Class({ type: "any" });
2558
+ }
2559
+ /* @__NO_SIDE_EFFECTS__ */
2560
+ function _unknown(Class) {
2561
+ return new Class({ type: "unknown" });
2562
+ }
2563
+ /* @__NO_SIDE_EFFECTS__ */
2564
+ function _never(Class, params) {
2565
+ return new Class({
2566
+ type: "never",
2567
+ ...normalizeParams(params)
2568
+ });
2569
+ }
2570
+ /* @__NO_SIDE_EFFECTS__ */
2571
+ function _lt(value, params) {
2572
+ return new $ZodCheckLessThan({
2573
+ check: "less_than",
2574
+ ...normalizeParams(params),
2575
+ value,
2576
+ inclusive: false
2577
+ });
2578
+ }
2579
+ /* @__NO_SIDE_EFFECTS__ */
2580
+ function _lte(value, params) {
2581
+ return new $ZodCheckLessThan({
2582
+ check: "less_than",
2583
+ ...normalizeParams(params),
2584
+ value,
2585
+ inclusive: true
2586
+ });
2587
+ }
2588
+ /* @__NO_SIDE_EFFECTS__ */
2589
+ function _gt(value, params) {
2590
+ return new $ZodCheckGreaterThan({
2591
+ check: "greater_than",
2592
+ ...normalizeParams(params),
2593
+ value,
2594
+ inclusive: false
2595
+ });
2596
+ }
2597
+ /* @__NO_SIDE_EFFECTS__ */
2598
+ function _gte(value, params) {
2599
+ return new $ZodCheckGreaterThan({
2600
+ check: "greater_than",
2601
+ ...normalizeParams(params),
2602
+ value,
2603
+ inclusive: true
2604
+ });
2605
+ }
2606
+ /* @__NO_SIDE_EFFECTS__ */
2607
+ function _multipleOf(value, params) {
2608
+ return new $ZodCheckMultipleOf({
2609
+ check: "multiple_of",
2610
+ ...normalizeParams(params),
2611
+ value
2612
+ });
2613
+ }
2614
+ /* @__NO_SIDE_EFFECTS__ */
2615
+ function _maxLength(maximum, params) {
2616
+ return new $ZodCheckMaxLength({
2617
+ check: "max_length",
2618
+ ...normalizeParams(params),
2619
+ maximum
2620
+ });
2621
+ }
2622
+ /* @__NO_SIDE_EFFECTS__ */
2623
+ function _minLength(minimum, params) {
2624
+ return new $ZodCheckMinLength({
2625
+ check: "min_length",
2626
+ ...normalizeParams(params),
2627
+ minimum
2628
+ });
2629
+ }
2630
+ /* @__NO_SIDE_EFFECTS__ */
2631
+ function _length(length, params) {
2632
+ return new $ZodCheckLengthEquals({
2633
+ check: "length_equals",
2634
+ ...normalizeParams(params),
2635
+ length
2636
+ });
2637
+ }
2638
+ /* @__NO_SIDE_EFFECTS__ */
2639
+ function _regex(pattern, params) {
2640
+ return new $ZodCheckRegex({
2641
+ check: "string_format",
2642
+ format: "regex",
2643
+ ...normalizeParams(params),
2644
+ pattern
2645
+ });
2646
+ }
2647
+ /* @__NO_SIDE_EFFECTS__ */
2648
+ function _lowercase(params) {
2649
+ return new $ZodCheckLowerCase({
2650
+ check: "string_format",
2651
+ format: "lowercase",
2652
+ ...normalizeParams(params)
2653
+ });
2654
+ }
2655
+ /* @__NO_SIDE_EFFECTS__ */
2656
+ function _uppercase(params) {
2657
+ return new $ZodCheckUpperCase({
2658
+ check: "string_format",
2659
+ format: "uppercase",
2660
+ ...normalizeParams(params)
2661
+ });
2662
+ }
2663
+ /* @__NO_SIDE_EFFECTS__ */
2664
+ function _includes(includes, params) {
2665
+ return new $ZodCheckIncludes({
2666
+ check: "string_format",
2667
+ format: "includes",
2668
+ ...normalizeParams(params),
2669
+ includes
2670
+ });
2671
+ }
2672
+ /* @__NO_SIDE_EFFECTS__ */
2673
+ function _startsWith(prefix, params) {
2674
+ return new $ZodCheckStartsWith({
2675
+ check: "string_format",
2676
+ format: "starts_with",
2677
+ ...normalizeParams(params),
2678
+ prefix
2679
+ });
2680
+ }
2681
+ /* @__NO_SIDE_EFFECTS__ */
2682
+ function _endsWith(suffix, params) {
2683
+ return new $ZodCheckEndsWith({
2684
+ check: "string_format",
2685
+ format: "ends_with",
2686
+ ...normalizeParams(params),
2687
+ suffix
2688
+ });
2689
+ }
2690
+ /* @__NO_SIDE_EFFECTS__ */
2691
+ function _overwrite(tx) {
2692
+ return new $ZodCheckOverwrite({
2693
+ check: "overwrite",
2694
+ tx
2695
+ });
2696
+ }
2697
+ /* @__NO_SIDE_EFFECTS__ */
2698
+ function _normalize(form) {
2699
+ return /* @__PURE__ */ _overwrite((input) => input.normalize(form));
2700
+ }
2701
+ /* @__NO_SIDE_EFFECTS__ */
2702
+ function _trim() {
2703
+ return /* @__PURE__ */ _overwrite((input) => input.trim());
2704
+ }
2705
+ /* @__NO_SIDE_EFFECTS__ */
2706
+ function _toLowerCase() {
2707
+ return /* @__PURE__ */ _overwrite((input) => input.toLowerCase());
2708
+ }
2709
+ /* @__NO_SIDE_EFFECTS__ */
2710
+ function _toUpperCase() {
2711
+ return /* @__PURE__ */ _overwrite((input) => input.toUpperCase());
2712
+ }
2713
+ /* @__NO_SIDE_EFFECTS__ */
2714
+ function _slugify() {
2715
+ return /* @__PURE__ */ _overwrite((input) => slugify(input));
2716
+ }
2717
+ /* @__NO_SIDE_EFFECTS__ */
2718
+ function _array(Class, element, params) {
2719
+ return new Class({
2720
+ type: "array",
2721
+ element,
2722
+ ...normalizeParams(params)
2723
+ });
2724
+ }
2725
+ /* @__NO_SIDE_EFFECTS__ */
2726
+ function _refine(Class, fn, _params) {
2727
+ return new Class({
2728
+ type: "custom",
2729
+ check: "custom",
2730
+ fn,
2731
+ ...normalizeParams(_params)
2732
+ });
2733
+ }
2734
+ /* @__NO_SIDE_EFFECTS__ */
2735
+ function _superRefine(fn) {
2736
+ const ch = /* @__PURE__ */ _check((payload) => {
2737
+ payload.addIssue = (issue$1) => {
2738
+ if (typeof issue$1 === "string") payload.issues.push(issue(issue$1, payload.value, ch._zod.def));
2739
+ else {
2740
+ const _issue = issue$1;
2741
+ if (_issue.fatal) _issue.continue = false;
2742
+ _issue.code ?? (_issue.code = "custom");
2743
+ _issue.input ?? (_issue.input = payload.value);
2744
+ _issue.inst ?? (_issue.inst = ch);
2745
+ _issue.continue ?? (_issue.continue = !ch._zod.def.abort);
2746
+ payload.issues.push(issue(_issue));
2747
+ }
2748
+ };
2749
+ return fn(payload.value, payload);
2750
+ });
2751
+ return ch;
2752
+ }
2753
+ /* @__NO_SIDE_EFFECTS__ */
2754
+ function _check(fn, params) {
2755
+ const ch = new $ZodCheck({
2756
+ check: "custom",
2757
+ ...normalizeParams(params)
2758
+ });
2759
+ ch._zod.check = fn;
2760
+ return ch;
2761
+ }
2762
+ /* @__NO_SIDE_EFFECTS__ */
2763
+ function describe$1(description) {
2764
+ const ch = new $ZodCheck({ check: "describe" });
2765
+ ch._zod.onattach = [(inst) => {
2766
+ const existing = globalRegistry.get(inst) ?? {};
2767
+ globalRegistry.add(inst, {
2768
+ ...existing,
2769
+ description
2770
+ });
2771
+ }];
2772
+ ch._zod.check = () => {};
2773
+ return ch;
2774
+ }
2775
+ /* @__NO_SIDE_EFFECTS__ */
2776
+ function meta$1(metadata) {
2777
+ const ch = new $ZodCheck({ check: "meta" });
2778
+ ch._zod.onattach = [(inst) => {
2779
+ const existing = globalRegistry.get(inst) ?? {};
2780
+ globalRegistry.add(inst, {
2781
+ ...existing,
2782
+ ...metadata
2783
+ });
2784
+ }];
2785
+ ch._zod.check = () => {};
2786
+ return ch;
2787
+ }
2788
+
2789
+ //#endregion
2790
+ //#region node_modules/zod/v4/core/to-json-schema.js
2791
+ function initializeContext(params) {
2792
+ let target = params?.target ?? "draft-2020-12";
2793
+ if (target === "draft-4") target = "draft-04";
2794
+ if (target === "draft-7") target = "draft-07";
2795
+ return {
2796
+ processors: params.processors ?? {},
2797
+ metadataRegistry: params?.metadata ?? globalRegistry,
2798
+ target,
2799
+ unrepresentable: params?.unrepresentable ?? "throw",
2800
+ override: params?.override ?? (() => {}),
2801
+ io: params?.io ?? "output",
2802
+ counter: 0,
2803
+ seen: /* @__PURE__ */ new Map(),
2804
+ cycles: params?.cycles ?? "ref",
2805
+ reused: params?.reused ?? "inline",
2806
+ external: params?.external ?? void 0
2807
+ };
2808
+ }
2809
+ function process$1(schema, ctx, _params = {
2810
+ path: [],
2811
+ schemaPath: []
2812
+ }) {
2813
+ var _a$1;
2814
+ const def = schema._zod.def;
2815
+ const seen = ctx.seen.get(schema);
2816
+ if (seen) {
2817
+ seen.count++;
2818
+ if (_params.schemaPath.includes(schema)) seen.cycle = _params.path;
2819
+ return seen.schema;
2820
+ }
2821
+ const result = {
2822
+ schema: {},
2823
+ count: 1,
2824
+ cycle: void 0,
2825
+ path: _params.path
2826
+ };
2827
+ ctx.seen.set(schema, result);
2828
+ const overrideSchema = schema._zod.toJSONSchema?.();
2829
+ if (overrideSchema) result.schema = overrideSchema;
2830
+ else {
2831
+ const params = {
2832
+ ..._params,
2833
+ schemaPath: [..._params.schemaPath, schema],
2834
+ path: _params.path
2835
+ };
2836
+ if (schema._zod.processJSONSchema) schema._zod.processJSONSchema(ctx, result.schema, params);
2837
+ else {
2838
+ const _json = result.schema;
2839
+ const processor = ctx.processors[def.type];
2840
+ if (!processor) throw new Error(`[toJSONSchema]: Non-representable type encountered: ${def.type}`);
2841
+ processor(schema, ctx, _json, params);
2842
+ }
2843
+ const parent = schema._zod.parent;
2844
+ if (parent) {
2845
+ if (!result.ref) result.ref = parent;
2846
+ process$1(parent, ctx, params);
2847
+ ctx.seen.get(parent).isParent = true;
2848
+ }
2849
+ }
2850
+ const meta$2 = ctx.metadataRegistry.get(schema);
2851
+ if (meta$2) Object.assign(result.schema, meta$2);
2852
+ if (ctx.io === "input" && isTransforming(schema)) {
2853
+ delete result.schema.examples;
2854
+ delete result.schema.default;
2855
+ }
2856
+ if (ctx.io === "input" && result.schema._prefault) (_a$1 = result.schema).default ?? (_a$1.default = result.schema._prefault);
2857
+ delete result.schema._prefault;
2858
+ return ctx.seen.get(schema).schema;
2859
+ }
2860
+ function extractDefs(ctx, schema) {
2861
+ const root = ctx.seen.get(schema);
2862
+ if (!root) throw new Error("Unprocessed schema. This is a bug in Zod.");
2863
+ const idToSchema = /* @__PURE__ */ new Map();
2864
+ for (const entry of ctx.seen.entries()) {
2865
+ const id = ctx.metadataRegistry.get(entry[0])?.id;
2866
+ if (id) {
2867
+ const existing = idToSchema.get(id);
2868
+ 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.`);
2869
+ idToSchema.set(id, entry[0]);
2870
+ }
2871
+ }
2872
+ const makeURI = (entry) => {
2873
+ const defsSegment = ctx.target === "draft-2020-12" ? "$defs" : "definitions";
2874
+ if (ctx.external) {
2875
+ const externalId = ctx.external.registry.get(entry[0])?.id;
2876
+ const uriGenerator = ctx.external.uri ?? ((id$1) => id$1);
2877
+ if (externalId) return { ref: uriGenerator(externalId) };
2878
+ const id = entry[1].defId ?? entry[1].schema.id ?? `schema${ctx.counter++}`;
2879
+ entry[1].defId = id;
2880
+ return {
2881
+ defId: id,
2882
+ ref: `${uriGenerator("__shared")}#/${defsSegment}/${id}`
2883
+ };
2884
+ }
2885
+ if (entry[1] === root) return { ref: "#" };
2886
+ const defUriPrefix = `#/${defsSegment}/`;
2887
+ const defId = entry[1].schema.id ?? `__schema${ctx.counter++}`;
2888
+ return {
2889
+ defId,
2890
+ ref: defUriPrefix + defId
2891
+ };
2892
+ };
2893
+ const extractToDef = (entry) => {
2894
+ if (entry[1].schema.$ref) return;
2895
+ const seen = entry[1];
2896
+ const { ref, defId } = makeURI(entry);
2897
+ seen.def = { ...seen.schema };
2898
+ if (defId) seen.defId = defId;
2899
+ const schema$1 = seen.schema;
2900
+ for (const key in schema$1) delete schema$1[key];
2901
+ schema$1.$ref = ref;
2902
+ };
2903
+ if (ctx.cycles === "throw") for (const entry of ctx.seen.entries()) {
2904
+ const seen = entry[1];
2905
+ if (seen.cycle) throw new Error(`Cycle detected: #/${seen.cycle?.join("/")}/<root>
2906
+
2907
+ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`);
2908
+ }
2909
+ for (const entry of ctx.seen.entries()) {
2910
+ const seen = entry[1];
2911
+ if (schema === entry[0]) {
2912
+ extractToDef(entry);
2913
+ continue;
2914
+ }
2915
+ if (ctx.external) {
2916
+ const ext = ctx.external.registry.get(entry[0])?.id;
2917
+ if (schema !== entry[0] && ext) {
2918
+ extractToDef(entry);
2919
+ continue;
2920
+ }
2921
+ }
2922
+ if (ctx.metadataRegistry.get(entry[0])?.id) {
2923
+ extractToDef(entry);
2924
+ continue;
2925
+ }
2926
+ if (seen.cycle) {
2927
+ extractToDef(entry);
2928
+ continue;
2929
+ }
2930
+ if (seen.count > 1) {
2931
+ if (ctx.reused === "ref") {
2932
+ extractToDef(entry);
2933
+ continue;
2934
+ }
2935
+ }
2936
+ }
2937
+ }
2938
+ function finalize(ctx, schema) {
2939
+ const root = ctx.seen.get(schema);
2940
+ if (!root) throw new Error("Unprocessed schema. This is a bug in Zod.");
2941
+ const flattenRef = (zodSchema) => {
2942
+ const seen = ctx.seen.get(zodSchema);
2943
+ if (seen.ref === null) return;
2944
+ const schema$1 = seen.def ?? seen.schema;
2945
+ const _cached = { ...schema$1 };
2946
+ const ref = seen.ref;
2947
+ seen.ref = null;
2948
+ if (ref) {
2949
+ flattenRef(ref);
2950
+ const refSeen = ctx.seen.get(ref);
2951
+ const refSchema = refSeen.schema;
2952
+ if (refSchema.$ref && (ctx.target === "draft-07" || ctx.target === "draft-04" || ctx.target === "openapi-3.0")) {
2953
+ schema$1.allOf = schema$1.allOf ?? [];
2954
+ schema$1.allOf.push(refSchema);
2955
+ } else Object.assign(schema$1, refSchema);
2956
+ Object.assign(schema$1, _cached);
2957
+ if (zodSchema._zod.parent === ref) for (const key in schema$1) {
2958
+ if (key === "$ref" || key === "allOf") continue;
2959
+ if (!(key in _cached)) delete schema$1[key];
2960
+ }
2961
+ if (refSchema.$ref && refSeen.def) for (const key in schema$1) {
2962
+ if (key === "$ref" || key === "allOf") continue;
2963
+ if (key in refSeen.def && JSON.stringify(schema$1[key]) === JSON.stringify(refSeen.def[key])) delete schema$1[key];
2964
+ }
2965
+ }
2966
+ const parent = zodSchema._zod.parent;
2967
+ if (parent && parent !== ref) {
2968
+ flattenRef(parent);
2969
+ const parentSeen = ctx.seen.get(parent);
2970
+ if (parentSeen?.schema.$ref) {
2971
+ schema$1.$ref = parentSeen.schema.$ref;
2972
+ if (parentSeen.def) for (const key in schema$1) {
2973
+ if (key === "$ref" || key === "allOf") continue;
2974
+ if (key in parentSeen.def && JSON.stringify(schema$1[key]) === JSON.stringify(parentSeen.def[key])) delete schema$1[key];
2975
+ }
2976
+ }
2977
+ }
2978
+ ctx.override({
2979
+ zodSchema,
2980
+ jsonSchema: schema$1,
2981
+ path: seen.path ?? []
2982
+ });
2983
+ };
2984
+ for (const entry of [...ctx.seen.entries()].reverse()) flattenRef(entry[0]);
2985
+ const result = {};
2986
+ if (ctx.target === "draft-2020-12") result.$schema = "https://json-schema.org/draft/2020-12/schema";
2987
+ else if (ctx.target === "draft-07") result.$schema = "http://json-schema.org/draft-07/schema#";
2988
+ else if (ctx.target === "draft-04") result.$schema = "http://json-schema.org/draft-04/schema#";
2989
+ else if (ctx.target === "openapi-3.0") {}
2990
+ if (ctx.external?.uri) {
2991
+ const id = ctx.external.registry.get(schema)?.id;
2992
+ if (!id) throw new Error("Schema is missing an `id` property");
2993
+ result.$id = ctx.external.uri(id);
2994
+ }
2995
+ Object.assign(result, root.def ?? root.schema);
2996
+ const defs = ctx.external?.defs ?? {};
2997
+ for (const entry of ctx.seen.entries()) {
2998
+ const seen = entry[1];
2999
+ if (seen.def && seen.defId) defs[seen.defId] = seen.def;
3000
+ }
3001
+ if (ctx.external) {} else if (Object.keys(defs).length > 0) if (ctx.target === "draft-2020-12") result.$defs = defs;
3002
+ else result.definitions = defs;
3003
+ try {
3004
+ const finalized = JSON.parse(JSON.stringify(result));
3005
+ Object.defineProperty(finalized, "~standard", {
3006
+ value: {
3007
+ ...schema["~standard"],
3008
+ jsonSchema: {
3009
+ input: createStandardJSONSchemaMethod(schema, "input", ctx.processors),
3010
+ output: createStandardJSONSchemaMethod(schema, "output", ctx.processors)
3011
+ }
3012
+ },
3013
+ enumerable: false,
3014
+ writable: false
3015
+ });
3016
+ return finalized;
3017
+ } catch (_err) {
3018
+ throw new Error("Error converting schema to JSON.");
3019
+ }
3020
+ }
3021
+ function isTransforming(_schema, _ctx) {
3022
+ const ctx = _ctx ?? { seen: /* @__PURE__ */ new Set() };
3023
+ if (ctx.seen.has(_schema)) return false;
3024
+ ctx.seen.add(_schema);
3025
+ const def = _schema._zod.def;
3026
+ if (def.type === "transform") return true;
3027
+ if (def.type === "array") return isTransforming(def.element, ctx);
3028
+ if (def.type === "set") return isTransforming(def.valueType, ctx);
3029
+ if (def.type === "lazy") return isTransforming(def.getter(), ctx);
3030
+ 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);
3031
+ if (def.type === "intersection") return isTransforming(def.left, ctx) || isTransforming(def.right, ctx);
3032
+ if (def.type === "record" || def.type === "map") return isTransforming(def.keyType, ctx) || isTransforming(def.valueType, ctx);
3033
+ if (def.type === "pipe") return isTransforming(def.in, ctx) || isTransforming(def.out, ctx);
3034
+ if (def.type === "object") {
3035
+ for (const key in def.shape) if (isTransforming(def.shape[key], ctx)) return true;
3036
+ return false;
3037
+ }
3038
+ if (def.type === "union") {
3039
+ for (const option of def.options) if (isTransforming(option, ctx)) return true;
3040
+ return false;
3041
+ }
3042
+ if (def.type === "tuple") {
3043
+ for (const item of def.items) if (isTransforming(item, ctx)) return true;
3044
+ if (def.rest && isTransforming(def.rest, ctx)) return true;
3045
+ return false;
3046
+ }
3047
+ return false;
3048
+ }
3049
+ /**
3050
+ * Creates a toJSONSchema method for a schema instance.
3051
+ * This encapsulates the logic of initializing context, processing, extracting defs, and finalizing.
3052
+ */
3053
+ const createToJSONSchemaMethod = (schema, processors = {}) => (params) => {
3054
+ const ctx = initializeContext({
3055
+ ...params,
3056
+ processors
3057
+ });
3058
+ process$1(schema, ctx);
3059
+ extractDefs(ctx, schema);
3060
+ return finalize(ctx, schema);
3061
+ };
3062
+ const createStandardJSONSchemaMethod = (schema, io, processors = {}) => (params) => {
3063
+ const { libraryOptions, target } = params ?? {};
3064
+ const ctx = initializeContext({
3065
+ ...libraryOptions ?? {},
3066
+ target,
3067
+ io,
3068
+ processors
3069
+ });
3070
+ process$1(schema, ctx);
3071
+ extractDefs(ctx, schema);
3072
+ return finalize(ctx, schema);
3073
+ };
3074
+
3075
+ //#endregion
3076
+ //#region node_modules/zod/v4/core/json-schema-processors.js
3077
+ const formatMap = {
3078
+ guid: "uuid",
3079
+ url: "uri",
3080
+ datetime: "date-time",
3081
+ json_string: "json-string",
3082
+ regex: ""
3083
+ };
3084
+ const stringProcessor = (schema, ctx, _json, _params) => {
3085
+ const json = _json;
3086
+ json.type = "string";
3087
+ const { minimum, maximum, format, patterns, contentEncoding } = schema._zod.bag;
3088
+ if (typeof minimum === "number") json.minLength = minimum;
3089
+ if (typeof maximum === "number") json.maxLength = maximum;
3090
+ if (format) {
3091
+ json.format = formatMap[format] ?? format;
3092
+ if (json.format === "") delete json.format;
3093
+ if (format === "time") delete json.format;
3094
+ }
3095
+ if (contentEncoding) json.contentEncoding = contentEncoding;
3096
+ if (patterns && patterns.size > 0) {
3097
+ const regexes = [...patterns];
3098
+ if (regexes.length === 1) json.pattern = regexes[0].source;
3099
+ else if (regexes.length > 1) json.allOf = [...regexes.map((regex) => ({
3100
+ ...ctx.target === "draft-07" || ctx.target === "draft-04" || ctx.target === "openapi-3.0" ? { type: "string" } : {},
3101
+ pattern: regex.source
3102
+ }))];
3103
+ }
3104
+ };
3105
+ const numberProcessor = (schema, ctx, _json, _params) => {
3106
+ const json = _json;
3107
+ const { minimum, maximum, format, multipleOf, exclusiveMaximum, exclusiveMinimum } = schema._zod.bag;
3108
+ if (typeof format === "string" && format.includes("int")) json.type = "integer";
3109
+ else json.type = "number";
3110
+ if (typeof exclusiveMinimum === "number") if (ctx.target === "draft-04" || ctx.target === "openapi-3.0") {
3111
+ json.minimum = exclusiveMinimum;
3112
+ json.exclusiveMinimum = true;
3113
+ } else json.exclusiveMinimum = exclusiveMinimum;
3114
+ if (typeof minimum === "number") {
3115
+ json.minimum = minimum;
3116
+ if (typeof exclusiveMinimum === "number" && ctx.target !== "draft-04") if (exclusiveMinimum >= minimum) delete json.minimum;
3117
+ else delete json.exclusiveMinimum;
3118
+ }
3119
+ if (typeof exclusiveMaximum === "number") if (ctx.target === "draft-04" || ctx.target === "openapi-3.0") {
3120
+ json.maximum = exclusiveMaximum;
3121
+ json.exclusiveMaximum = true;
3122
+ } else json.exclusiveMaximum = exclusiveMaximum;
3123
+ if (typeof maximum === "number") {
3124
+ json.maximum = maximum;
3125
+ if (typeof exclusiveMaximum === "number" && ctx.target !== "draft-04") if (exclusiveMaximum <= maximum) delete json.maximum;
3126
+ else delete json.exclusiveMaximum;
3127
+ }
3128
+ if (typeof multipleOf === "number") json.multipleOf = multipleOf;
3129
+ };
3130
+ const booleanProcessor = (_schema, _ctx, json, _params) => {
3131
+ json.type = "boolean";
3132
+ };
3133
+ const neverProcessor = (_schema, _ctx, json, _params) => {
3134
+ json.not = {};
3135
+ };
3136
+ const anyProcessor = (_schema, _ctx, _json, _params) => {};
3137
+ const unknownProcessor = (_schema, _ctx, _json, _params) => {};
3138
+ const enumProcessor = (schema, _ctx, json, _params) => {
3139
+ const def = schema._zod.def;
3140
+ const values = getEnumValues(def.entries);
3141
+ if (values.every((v) => typeof v === "number")) json.type = "number";
3142
+ if (values.every((v) => typeof v === "string")) json.type = "string";
3143
+ json.enum = values;
3144
+ };
3145
+ const literalProcessor = (schema, ctx, json, _params) => {
3146
+ const def = schema._zod.def;
3147
+ const vals = [];
3148
+ for (const val of def.values) if (val === void 0) {
3149
+ if (ctx.unrepresentable === "throw") throw new Error("Literal `undefined` cannot be represented in JSON Schema");
3150
+ } else if (typeof val === "bigint") if (ctx.unrepresentable === "throw") throw new Error("BigInt literals cannot be represented in JSON Schema");
3151
+ else vals.push(Number(val));
3152
+ else vals.push(val);
3153
+ if (vals.length === 0) {} else if (vals.length === 1) {
3154
+ const val = vals[0];
3155
+ json.type = val === null ? "null" : typeof val;
3156
+ if (ctx.target === "draft-04" || ctx.target === "openapi-3.0") json.enum = [val];
3157
+ else json.const = val;
3158
+ } else {
3159
+ if (vals.every((v) => typeof v === "number")) json.type = "number";
3160
+ if (vals.every((v) => typeof v === "string")) json.type = "string";
3161
+ if (vals.every((v) => typeof v === "boolean")) json.type = "boolean";
3162
+ if (vals.every((v) => v === null)) json.type = "null";
3163
+ json.enum = vals;
3164
+ }
3165
+ };
3166
+ const customProcessor = (_schema, ctx, _json, _params) => {
3167
+ if (ctx.unrepresentable === "throw") throw new Error("Custom types cannot be represented in JSON Schema");
3168
+ };
3169
+ const transformProcessor = (_schema, ctx, _json, _params) => {
3170
+ if (ctx.unrepresentable === "throw") throw new Error("Transforms cannot be represented in JSON Schema");
3171
+ };
3172
+ const arrayProcessor = (schema, ctx, _json, params) => {
3173
+ const json = _json;
3174
+ const def = schema._zod.def;
3175
+ const { minimum, maximum } = schema._zod.bag;
3176
+ if (typeof minimum === "number") json.minItems = minimum;
3177
+ if (typeof maximum === "number") json.maxItems = maximum;
3178
+ json.type = "array";
3179
+ json.items = process$1(def.element, ctx, {
3180
+ ...params,
3181
+ path: [...params.path, "items"]
3182
+ });
3183
+ };
3184
+ const objectProcessor = (schema, ctx, _json, params) => {
3185
+ const json = _json;
3186
+ const def = schema._zod.def;
3187
+ json.type = "object";
3188
+ json.properties = {};
3189
+ const shape = def.shape;
3190
+ for (const key in shape) json.properties[key] = process$1(shape[key], ctx, {
3191
+ ...params,
3192
+ path: [
3193
+ ...params.path,
3194
+ "properties",
3195
+ key
3196
+ ]
3197
+ });
3198
+ const allKeys = new Set(Object.keys(shape));
3199
+ const requiredKeys = new Set([...allKeys].filter((key) => {
3200
+ const v = def.shape[key]._zod;
3201
+ if (ctx.io === "input") return v.optin === void 0;
3202
+ else return v.optout === void 0;
3203
+ }));
3204
+ if (requiredKeys.size > 0) json.required = Array.from(requiredKeys);
3205
+ if (def.catchall?._zod.def.type === "never") json.additionalProperties = false;
3206
+ else if (!def.catchall) {
3207
+ if (ctx.io === "output") json.additionalProperties = false;
3208
+ } else if (def.catchall) json.additionalProperties = process$1(def.catchall, ctx, {
3209
+ ...params,
3210
+ path: [...params.path, "additionalProperties"]
3211
+ });
3212
+ };
3213
+ const unionProcessor = (schema, ctx, json, params) => {
3214
+ const def = schema._zod.def;
3215
+ const isExclusive = def.inclusive === false;
3216
+ const options = def.options.map((x, i) => process$1(x, ctx, {
3217
+ ...params,
3218
+ path: [
3219
+ ...params.path,
3220
+ isExclusive ? "oneOf" : "anyOf",
3221
+ i
3222
+ ]
3223
+ }));
3224
+ if (isExclusive) json.oneOf = options;
3225
+ else json.anyOf = options;
3226
+ };
3227
+ const intersectionProcessor = (schema, ctx, json, params) => {
3228
+ const def = schema._zod.def;
3229
+ const a = process$1(def.left, ctx, {
3230
+ ...params,
3231
+ path: [
3232
+ ...params.path,
3233
+ "allOf",
3234
+ 0
3235
+ ]
3236
+ });
3237
+ const b = process$1(def.right, ctx, {
3238
+ ...params,
3239
+ path: [
3240
+ ...params.path,
3241
+ "allOf",
3242
+ 1
3243
+ ]
3244
+ });
3245
+ const isSimpleIntersection = (val) => "allOf" in val && Object.keys(val).length === 1;
3246
+ json.allOf = [...isSimpleIntersection(a) ? a.allOf : [a], ...isSimpleIntersection(b) ? b.allOf : [b]];
3247
+ };
3248
+ const recordProcessor = (schema, ctx, _json, params) => {
3249
+ const json = _json;
3250
+ const def = schema._zod.def;
3251
+ json.type = "object";
3252
+ const keyType = def.keyType;
3253
+ const patterns = keyType._zod.bag?.patterns;
3254
+ if (def.mode === "loose" && patterns && patterns.size > 0) {
3255
+ const valueSchema = process$1(def.valueType, ctx, {
3256
+ ...params,
3257
+ path: [
3258
+ ...params.path,
3259
+ "patternProperties",
3260
+ "*"
3261
+ ]
3262
+ });
3263
+ json.patternProperties = {};
3264
+ for (const pattern of patterns) json.patternProperties[pattern.source] = valueSchema;
3265
+ } else {
3266
+ if (ctx.target === "draft-07" || ctx.target === "draft-2020-12") json.propertyNames = process$1(def.keyType, ctx, {
3267
+ ...params,
3268
+ path: [...params.path, "propertyNames"]
3269
+ });
3270
+ json.additionalProperties = process$1(def.valueType, ctx, {
3271
+ ...params,
3272
+ path: [...params.path, "additionalProperties"]
3273
+ });
3274
+ }
3275
+ const keyValues = keyType._zod.values;
3276
+ if (keyValues) {
3277
+ const validKeyValues = [...keyValues].filter((v) => typeof v === "string" || typeof v === "number");
3278
+ if (validKeyValues.length > 0) json.required = validKeyValues;
3279
+ }
3280
+ };
3281
+ const nullableProcessor = (schema, ctx, json, params) => {
3282
+ const def = schema._zod.def;
3283
+ const inner = process$1(def.innerType, ctx, params);
3284
+ const seen = ctx.seen.get(schema);
3285
+ if (ctx.target === "openapi-3.0") {
3286
+ seen.ref = def.innerType;
3287
+ json.nullable = true;
3288
+ } else json.anyOf = [inner, { type: "null" }];
3289
+ };
3290
+ const nonoptionalProcessor = (schema, ctx, _json, params) => {
3291
+ const def = schema._zod.def;
3292
+ process$1(def.innerType, ctx, params);
3293
+ const seen = ctx.seen.get(schema);
3294
+ seen.ref = def.innerType;
3295
+ };
3296
+ const defaultProcessor = (schema, ctx, json, params) => {
3297
+ const def = schema._zod.def;
3298
+ process$1(def.innerType, ctx, params);
3299
+ const seen = ctx.seen.get(schema);
3300
+ seen.ref = def.innerType;
3301
+ json.default = JSON.parse(JSON.stringify(def.defaultValue));
3302
+ };
3303
+ const prefaultProcessor = (schema, ctx, json, params) => {
3304
+ const def = schema._zod.def;
3305
+ process$1(def.innerType, ctx, params);
3306
+ const seen = ctx.seen.get(schema);
3307
+ seen.ref = def.innerType;
3308
+ if (ctx.io === "input") json._prefault = JSON.parse(JSON.stringify(def.defaultValue));
3309
+ };
3310
+ const catchProcessor = (schema, ctx, json, params) => {
3311
+ const def = schema._zod.def;
3312
+ process$1(def.innerType, ctx, params);
3313
+ const seen = ctx.seen.get(schema);
3314
+ seen.ref = def.innerType;
3315
+ let catchValue;
3316
+ try {
3317
+ catchValue = def.catchValue(void 0);
3318
+ } catch {
3319
+ throw new Error("Dynamic catch values are not supported in JSON Schema");
3320
+ }
3321
+ json.default = catchValue;
3322
+ };
3323
+ const pipeProcessor = (schema, ctx, _json, params) => {
3324
+ const def = schema._zod.def;
3325
+ const innerType = ctx.io === "input" ? def.in._zod.def.type === "transform" ? def.out : def.in : def.out;
3326
+ process$1(innerType, ctx, params);
3327
+ const seen = ctx.seen.get(schema);
3328
+ seen.ref = innerType;
3329
+ };
3330
+ const readonlyProcessor = (schema, ctx, json, params) => {
3331
+ const def = schema._zod.def;
3332
+ process$1(def.innerType, ctx, params);
3333
+ const seen = ctx.seen.get(schema);
3334
+ seen.ref = def.innerType;
3335
+ json.readOnly = true;
3336
+ };
3337
+ const optionalProcessor = (schema, ctx, _json, params) => {
3338
+ const def = schema._zod.def;
3339
+ process$1(def.innerType, ctx, params);
3340
+ const seen = ctx.seen.get(schema);
3341
+ seen.ref = def.innerType;
3342
+ };
3343
+
3344
+ //#endregion
3345
+ //#region node_modules/zod/v4/classic/iso.js
3346
+ const ZodISODateTime = /* @__PURE__ */ $constructor("ZodISODateTime", (inst, def) => {
3347
+ $ZodISODateTime.init(inst, def);
3348
+ ZodStringFormat.init(inst, def);
3349
+ });
3350
+ function datetime(params) {
3351
+ return _isoDateTime(ZodISODateTime, params);
3352
+ }
3353
+ const ZodISODate = /* @__PURE__ */ $constructor("ZodISODate", (inst, def) => {
3354
+ $ZodISODate.init(inst, def);
3355
+ ZodStringFormat.init(inst, def);
3356
+ });
3357
+ function date(params) {
3358
+ return _isoDate(ZodISODate, params);
3359
+ }
3360
+ const ZodISOTime = /* @__PURE__ */ $constructor("ZodISOTime", (inst, def) => {
3361
+ $ZodISOTime.init(inst, def);
3362
+ ZodStringFormat.init(inst, def);
3363
+ });
3364
+ function time(params) {
3365
+ return _isoTime(ZodISOTime, params);
3366
+ }
3367
+ const ZodISODuration = /* @__PURE__ */ $constructor("ZodISODuration", (inst, def) => {
3368
+ $ZodISODuration.init(inst, def);
3369
+ ZodStringFormat.init(inst, def);
3370
+ });
3371
+ function duration(params) {
3372
+ return _isoDuration(ZodISODuration, params);
3373
+ }
3374
+
3375
+ //#endregion
3376
+ //#region node_modules/zod/v4/classic/errors.js
3377
+ const initializer = (inst, issues) => {
3378
+ $ZodError.init(inst, issues);
3379
+ inst.name = "ZodError";
3380
+ Object.defineProperties(inst, {
3381
+ format: { value: (mapper) => formatError(inst, mapper) },
3382
+ flatten: { value: (mapper) => flattenError(inst, mapper) },
3383
+ addIssue: { value: (issue$1) => {
3384
+ inst.issues.push(issue$1);
3385
+ inst.message = JSON.stringify(inst.issues, jsonStringifyReplacer, 2);
3386
+ } },
3387
+ addIssues: { value: (issues$1) => {
3388
+ inst.issues.push(...issues$1);
3389
+ inst.message = JSON.stringify(inst.issues, jsonStringifyReplacer, 2);
3390
+ } },
3391
+ isEmpty: { get() {
3392
+ return inst.issues.length === 0;
3393
+ } }
3394
+ });
3395
+ };
3396
+ const ZodError = $constructor("ZodError", initializer);
3397
+ const ZodRealError = $constructor("ZodError", initializer, { Parent: Error });
3398
+
3399
+ //#endregion
3400
+ //#region node_modules/zod/v4/classic/parse.js
3401
+ const parse = /* @__PURE__ */ _parse(ZodRealError);
3402
+ const parseAsync = /* @__PURE__ */ _parseAsync(ZodRealError);
3403
+ const safeParse = /* @__PURE__ */ _safeParse(ZodRealError);
3404
+ const safeParseAsync = /* @__PURE__ */ _safeParseAsync(ZodRealError);
3405
+ const encode = /* @__PURE__ */ _encode(ZodRealError);
3406
+ const decode = /* @__PURE__ */ _decode(ZodRealError);
3407
+ const encodeAsync = /* @__PURE__ */ _encodeAsync(ZodRealError);
3408
+ const decodeAsync = /* @__PURE__ */ _decodeAsync(ZodRealError);
3409
+ const safeEncode = /* @__PURE__ */ _safeEncode(ZodRealError);
3410
+ const safeDecode = /* @__PURE__ */ _safeDecode(ZodRealError);
3411
+ const safeEncodeAsync = /* @__PURE__ */ _safeEncodeAsync(ZodRealError);
3412
+ const safeDecodeAsync = /* @__PURE__ */ _safeDecodeAsync(ZodRealError);
3413
+
3414
+ //#endregion
3415
+ //#region node_modules/zod/v4/classic/schemas.js
3416
+ const ZodType = /* @__PURE__ */ $constructor("ZodType", (inst, def) => {
3417
+ $ZodType.init(inst, def);
3418
+ Object.assign(inst["~standard"], { jsonSchema: {
3419
+ input: createStandardJSONSchemaMethod(inst, "input"),
3420
+ output: createStandardJSONSchemaMethod(inst, "output")
3421
+ } });
3422
+ inst.toJSONSchema = createToJSONSchemaMethod(inst, {});
3423
+ inst.def = def;
3424
+ inst.type = def.type;
3425
+ Object.defineProperty(inst, "_def", { value: def });
3426
+ inst.check = (...checks) => {
3427
+ return inst.clone(mergeDefs(def, { checks: [...def.checks ?? [], ...checks.map((ch) => typeof ch === "function" ? { _zod: {
3428
+ check: ch,
3429
+ def: { check: "custom" },
3430
+ onattach: []
3431
+ } } : ch)] }), { parent: true });
3432
+ };
3433
+ inst.with = inst.check;
3434
+ inst.clone = (def$1, params) => clone(inst, def$1, params);
3435
+ inst.brand = () => inst;
3436
+ inst.register = ((reg, meta$2) => {
3437
+ reg.add(inst, meta$2);
3438
+ return inst;
3439
+ });
3440
+ inst.parse = (data, params) => parse(inst, data, params, { callee: inst.parse });
3441
+ inst.safeParse = (data, params) => safeParse(inst, data, params);
3442
+ inst.parseAsync = async (data, params) => parseAsync(inst, data, params, { callee: inst.parseAsync });
3443
+ inst.safeParseAsync = async (data, params) => safeParseAsync(inst, data, params);
3444
+ inst.spa = inst.safeParseAsync;
3445
+ inst.encode = (data, params) => encode(inst, data, params);
3446
+ inst.decode = (data, params) => decode(inst, data, params);
3447
+ inst.encodeAsync = async (data, params) => encodeAsync(inst, data, params);
3448
+ inst.decodeAsync = async (data, params) => decodeAsync(inst, data, params);
3449
+ inst.safeEncode = (data, params) => safeEncode(inst, data, params);
3450
+ inst.safeDecode = (data, params) => safeDecode(inst, data, params);
3451
+ inst.safeEncodeAsync = async (data, params) => safeEncodeAsync(inst, data, params);
3452
+ inst.safeDecodeAsync = async (data, params) => safeDecodeAsync(inst, data, params);
3453
+ inst.refine = (check, params) => inst.check(refine(check, params));
3454
+ inst.superRefine = (refinement) => inst.check(superRefine(refinement));
3455
+ inst.overwrite = (fn) => inst.check(_overwrite(fn));
3456
+ inst.optional = () => optional(inst);
3457
+ inst.exactOptional = () => exactOptional(inst);
3458
+ inst.nullable = () => nullable(inst);
3459
+ inst.nullish = () => optional(nullable(inst));
3460
+ inst.nonoptional = (params) => nonoptional(inst, params);
3461
+ inst.array = () => array(inst);
3462
+ inst.or = (arg) => union([inst, arg]);
3463
+ inst.and = (arg) => intersection(inst, arg);
3464
+ inst.transform = (tx) => pipe(inst, transform(tx));
3465
+ inst.default = (def$1) => _default(inst, def$1);
3466
+ inst.prefault = (def$1) => prefault(inst, def$1);
3467
+ inst.catch = (params) => _catch(inst, params);
3468
+ inst.pipe = (target) => pipe(inst, target);
3469
+ inst.readonly = () => readonly(inst);
3470
+ inst.describe = (description) => {
3471
+ const cl = inst.clone();
3472
+ globalRegistry.add(cl, { description });
3473
+ return cl;
3474
+ };
3475
+ Object.defineProperty(inst, "description", {
3476
+ get() {
3477
+ return globalRegistry.get(inst)?.description;
3478
+ },
3479
+ configurable: true
3480
+ });
3481
+ inst.meta = (...args$1) => {
3482
+ if (args$1.length === 0) return globalRegistry.get(inst);
3483
+ const cl = inst.clone();
3484
+ globalRegistry.add(cl, args$1[0]);
3485
+ return cl;
3486
+ };
3487
+ inst.isOptional = () => inst.safeParse(void 0).success;
3488
+ inst.isNullable = () => inst.safeParse(null).success;
3489
+ inst.apply = (fn) => fn(inst);
3490
+ return inst;
3491
+ });
3492
+ /** @internal */
3493
+ const _ZodString = /* @__PURE__ */ $constructor("_ZodString", (inst, def) => {
3494
+ $ZodString.init(inst, def);
3495
+ ZodType.init(inst, def);
3496
+ inst._zod.processJSONSchema = (ctx, json, params) => stringProcessor(inst, ctx, json, params);
3497
+ const bag = inst._zod.bag;
3498
+ inst.format = bag.format ?? null;
3499
+ inst.minLength = bag.minimum ?? null;
3500
+ inst.maxLength = bag.maximum ?? null;
3501
+ inst.regex = (...args$1) => inst.check(_regex(...args$1));
3502
+ inst.includes = (...args$1) => inst.check(_includes(...args$1));
3503
+ inst.startsWith = (...args$1) => inst.check(_startsWith(...args$1));
3504
+ inst.endsWith = (...args$1) => inst.check(_endsWith(...args$1));
3505
+ inst.min = (...args$1) => inst.check(_minLength(...args$1));
3506
+ inst.max = (...args$1) => inst.check(_maxLength(...args$1));
3507
+ inst.length = (...args$1) => inst.check(_length(...args$1));
3508
+ inst.nonempty = (...args$1) => inst.check(_minLength(1, ...args$1));
3509
+ inst.lowercase = (params) => inst.check(_lowercase(params));
3510
+ inst.uppercase = (params) => inst.check(_uppercase(params));
3511
+ inst.trim = () => inst.check(_trim());
3512
+ inst.normalize = (...args$1) => inst.check(_normalize(...args$1));
3513
+ inst.toLowerCase = () => inst.check(_toLowerCase());
3514
+ inst.toUpperCase = () => inst.check(_toUpperCase());
3515
+ inst.slugify = () => inst.check(_slugify());
3516
+ });
3517
+ const ZodString = /* @__PURE__ */ $constructor("ZodString", (inst, def) => {
3518
+ $ZodString.init(inst, def);
3519
+ _ZodString.init(inst, def);
3520
+ inst.email = (params) => inst.check(_email(ZodEmail, params));
3521
+ inst.url = (params) => inst.check(_url(ZodURL, params));
3522
+ inst.jwt = (params) => inst.check(_jwt(ZodJWT, params));
3523
+ inst.emoji = (params) => inst.check(_emoji(ZodEmoji, params));
3524
+ inst.guid = (params) => inst.check(_guid(ZodGUID, params));
3525
+ inst.uuid = (params) => inst.check(_uuid(ZodUUID, params));
3526
+ inst.uuidv4 = (params) => inst.check(_uuidv4(ZodUUID, params));
3527
+ inst.uuidv6 = (params) => inst.check(_uuidv6(ZodUUID, params));
3528
+ inst.uuidv7 = (params) => inst.check(_uuidv7(ZodUUID, params));
3529
+ inst.nanoid = (params) => inst.check(_nanoid(ZodNanoID, params));
3530
+ inst.guid = (params) => inst.check(_guid(ZodGUID, params));
3531
+ inst.cuid = (params) => inst.check(_cuid(ZodCUID, params));
3532
+ inst.cuid2 = (params) => inst.check(_cuid2(ZodCUID2, params));
3533
+ inst.ulid = (params) => inst.check(_ulid(ZodULID, params));
3534
+ inst.base64 = (params) => inst.check(_base64(ZodBase64, params));
3535
+ inst.base64url = (params) => inst.check(_base64url(ZodBase64URL, params));
3536
+ inst.xid = (params) => inst.check(_xid(ZodXID, params));
3537
+ inst.ksuid = (params) => inst.check(_ksuid(ZodKSUID, params));
3538
+ inst.ipv4 = (params) => inst.check(_ipv4(ZodIPv4, params));
3539
+ inst.ipv6 = (params) => inst.check(_ipv6(ZodIPv6, params));
3540
+ inst.cidrv4 = (params) => inst.check(_cidrv4(ZodCIDRv4, params));
3541
+ inst.cidrv6 = (params) => inst.check(_cidrv6(ZodCIDRv6, params));
3542
+ inst.e164 = (params) => inst.check(_e164(ZodE164, params));
3543
+ inst.datetime = (params) => inst.check(datetime(params));
3544
+ inst.date = (params) => inst.check(date(params));
3545
+ inst.time = (params) => inst.check(time(params));
3546
+ inst.duration = (params) => inst.check(duration(params));
3547
+ });
3548
+ function string(params) {
3549
+ return _string(ZodString, params);
3550
+ }
3551
+ const ZodStringFormat = /* @__PURE__ */ $constructor("ZodStringFormat", (inst, def) => {
3552
+ $ZodStringFormat.init(inst, def);
3553
+ _ZodString.init(inst, def);
3554
+ });
3555
+ const ZodEmail = /* @__PURE__ */ $constructor("ZodEmail", (inst, def) => {
3556
+ $ZodEmail.init(inst, def);
3557
+ ZodStringFormat.init(inst, def);
3558
+ });
3559
+ const ZodGUID = /* @__PURE__ */ $constructor("ZodGUID", (inst, def) => {
3560
+ $ZodGUID.init(inst, def);
3561
+ ZodStringFormat.init(inst, def);
3562
+ });
3563
+ const ZodUUID = /* @__PURE__ */ $constructor("ZodUUID", (inst, def) => {
3564
+ $ZodUUID.init(inst, def);
3565
+ ZodStringFormat.init(inst, def);
3566
+ });
3567
+ const ZodURL = /* @__PURE__ */ $constructor("ZodURL", (inst, def) => {
3568
+ $ZodURL.init(inst, def);
3569
+ ZodStringFormat.init(inst, def);
3570
+ });
3571
+ const ZodEmoji = /* @__PURE__ */ $constructor("ZodEmoji", (inst, def) => {
3572
+ $ZodEmoji.init(inst, def);
3573
+ ZodStringFormat.init(inst, def);
3574
+ });
3575
+ const ZodNanoID = /* @__PURE__ */ $constructor("ZodNanoID", (inst, def) => {
3576
+ $ZodNanoID.init(inst, def);
3577
+ ZodStringFormat.init(inst, def);
3578
+ });
3579
+ const ZodCUID = /* @__PURE__ */ $constructor("ZodCUID", (inst, def) => {
3580
+ $ZodCUID.init(inst, def);
3581
+ ZodStringFormat.init(inst, def);
3582
+ });
3583
+ const ZodCUID2 = /* @__PURE__ */ $constructor("ZodCUID2", (inst, def) => {
3584
+ $ZodCUID2.init(inst, def);
3585
+ ZodStringFormat.init(inst, def);
3586
+ });
3587
+ const ZodULID = /* @__PURE__ */ $constructor("ZodULID", (inst, def) => {
3588
+ $ZodULID.init(inst, def);
3589
+ ZodStringFormat.init(inst, def);
3590
+ });
3591
+ const ZodXID = /* @__PURE__ */ $constructor("ZodXID", (inst, def) => {
3592
+ $ZodXID.init(inst, def);
3593
+ ZodStringFormat.init(inst, def);
3594
+ });
3595
+ const ZodKSUID = /* @__PURE__ */ $constructor("ZodKSUID", (inst, def) => {
3596
+ $ZodKSUID.init(inst, def);
3597
+ ZodStringFormat.init(inst, def);
3598
+ });
3599
+ const ZodIPv4 = /* @__PURE__ */ $constructor("ZodIPv4", (inst, def) => {
3600
+ $ZodIPv4.init(inst, def);
3601
+ ZodStringFormat.init(inst, def);
3602
+ });
3603
+ const ZodIPv6 = /* @__PURE__ */ $constructor("ZodIPv6", (inst, def) => {
3604
+ $ZodIPv6.init(inst, def);
3605
+ ZodStringFormat.init(inst, def);
3606
+ });
3607
+ const ZodCIDRv4 = /* @__PURE__ */ $constructor("ZodCIDRv4", (inst, def) => {
3608
+ $ZodCIDRv4.init(inst, def);
3609
+ ZodStringFormat.init(inst, def);
3610
+ });
3611
+ const ZodCIDRv6 = /* @__PURE__ */ $constructor("ZodCIDRv6", (inst, def) => {
3612
+ $ZodCIDRv6.init(inst, def);
3613
+ ZodStringFormat.init(inst, def);
3614
+ });
3615
+ const ZodBase64 = /* @__PURE__ */ $constructor("ZodBase64", (inst, def) => {
3616
+ $ZodBase64.init(inst, def);
3617
+ ZodStringFormat.init(inst, def);
3618
+ });
3619
+ const ZodBase64URL = /* @__PURE__ */ $constructor("ZodBase64URL", (inst, def) => {
3620
+ $ZodBase64URL.init(inst, def);
3621
+ ZodStringFormat.init(inst, def);
3622
+ });
3623
+ const ZodE164 = /* @__PURE__ */ $constructor("ZodE164", (inst, def) => {
3624
+ $ZodE164.init(inst, def);
3625
+ ZodStringFormat.init(inst, def);
3626
+ });
3627
+ const ZodJWT = /* @__PURE__ */ $constructor("ZodJWT", (inst, def) => {
3628
+ $ZodJWT.init(inst, def);
3629
+ ZodStringFormat.init(inst, def);
3630
+ });
3631
+ const ZodNumber = /* @__PURE__ */ $constructor("ZodNumber", (inst, def) => {
3632
+ $ZodNumber.init(inst, def);
3633
+ ZodType.init(inst, def);
3634
+ inst._zod.processJSONSchema = (ctx, json, params) => numberProcessor(inst, ctx, json, params);
3635
+ inst.gt = (value, params) => inst.check(_gt(value, params));
3636
+ inst.gte = (value, params) => inst.check(_gte(value, params));
3637
+ inst.min = (value, params) => inst.check(_gte(value, params));
3638
+ inst.lt = (value, params) => inst.check(_lt(value, params));
3639
+ inst.lte = (value, params) => inst.check(_lte(value, params));
3640
+ inst.max = (value, params) => inst.check(_lte(value, params));
3641
+ inst.int = (params) => inst.check(int(params));
3642
+ inst.safe = (params) => inst.check(int(params));
3643
+ inst.positive = (params) => inst.check(_gt(0, params));
3644
+ inst.nonnegative = (params) => inst.check(_gte(0, params));
3645
+ inst.negative = (params) => inst.check(_lt(0, params));
3646
+ inst.nonpositive = (params) => inst.check(_lte(0, params));
3647
+ inst.multipleOf = (value, params) => inst.check(_multipleOf(value, params));
3648
+ inst.step = (value, params) => inst.check(_multipleOf(value, params));
3649
+ inst.finite = () => inst;
3650
+ const bag = inst._zod.bag;
3651
+ inst.minValue = Math.max(bag.minimum ?? Number.NEGATIVE_INFINITY, bag.exclusiveMinimum ?? Number.NEGATIVE_INFINITY) ?? null;
3652
+ inst.maxValue = Math.min(bag.maximum ?? Number.POSITIVE_INFINITY, bag.exclusiveMaximum ?? Number.POSITIVE_INFINITY) ?? null;
3653
+ inst.isInt = (bag.format ?? "").includes("int") || Number.isSafeInteger(bag.multipleOf ?? .5);
3654
+ inst.isFinite = true;
3655
+ inst.format = bag.format ?? null;
3656
+ });
3657
+ function number$1(params) {
3658
+ return _number(ZodNumber, params);
3659
+ }
3660
+ const ZodNumberFormat = /* @__PURE__ */ $constructor("ZodNumberFormat", (inst, def) => {
3661
+ $ZodNumberFormat.init(inst, def);
3662
+ ZodNumber.init(inst, def);
3663
+ });
3664
+ function int(params) {
3665
+ return _int(ZodNumberFormat, params);
3666
+ }
3667
+ const ZodBoolean = /* @__PURE__ */ $constructor("ZodBoolean", (inst, def) => {
3668
+ $ZodBoolean.init(inst, def);
3669
+ ZodType.init(inst, def);
3670
+ inst._zod.processJSONSchema = (ctx, json, params) => booleanProcessor(inst, ctx, json, params);
3671
+ });
3672
+ function boolean(params) {
3673
+ return _boolean(ZodBoolean, params);
3674
+ }
3675
+ const ZodAny = /* @__PURE__ */ $constructor("ZodAny", (inst, def) => {
3676
+ $ZodAny.init(inst, def);
3677
+ ZodType.init(inst, def);
3678
+ inst._zod.processJSONSchema = (ctx, json, params) => anyProcessor(inst, ctx, json, params);
3679
+ });
3680
+ function any() {
3681
+ return _any(ZodAny);
3682
+ }
3683
+ const ZodUnknown = /* @__PURE__ */ $constructor("ZodUnknown", (inst, def) => {
3684
+ $ZodUnknown.init(inst, def);
3685
+ ZodType.init(inst, def);
3686
+ inst._zod.processJSONSchema = (ctx, json, params) => unknownProcessor(inst, ctx, json, params);
3687
+ });
3688
+ function unknown() {
3689
+ return _unknown(ZodUnknown);
3690
+ }
3691
+ const ZodNever = /* @__PURE__ */ $constructor("ZodNever", (inst, def) => {
3692
+ $ZodNever.init(inst, def);
3693
+ ZodType.init(inst, def);
3694
+ inst._zod.processJSONSchema = (ctx, json, params) => neverProcessor(inst, ctx, json, params);
3695
+ });
3696
+ function never(params) {
3697
+ return _never(ZodNever, params);
3698
+ }
3699
+ const ZodArray = /* @__PURE__ */ $constructor("ZodArray", (inst, def) => {
3700
+ $ZodArray.init(inst, def);
3701
+ ZodType.init(inst, def);
3702
+ inst._zod.processJSONSchema = (ctx, json, params) => arrayProcessor(inst, ctx, json, params);
3703
+ inst.element = def.element;
3704
+ inst.min = (minLength, params) => inst.check(_minLength(minLength, params));
3705
+ inst.nonempty = (params) => inst.check(_minLength(1, params));
3706
+ inst.max = (maxLength, params) => inst.check(_maxLength(maxLength, params));
3707
+ inst.length = (len, params) => inst.check(_length(len, params));
3708
+ inst.unwrap = () => inst.element;
3709
+ });
3710
+ function array(element, params) {
3711
+ return _array(ZodArray, element, params);
3712
+ }
3713
+ const ZodObject = /* @__PURE__ */ $constructor("ZodObject", (inst, def) => {
3714
+ $ZodObjectJIT.init(inst, def);
3715
+ ZodType.init(inst, def);
3716
+ inst._zod.processJSONSchema = (ctx, json, params) => objectProcessor(inst, ctx, json, params);
3717
+ defineLazy(inst, "shape", () => {
3718
+ return def.shape;
3719
+ });
3720
+ inst.keyof = () => _enum(Object.keys(inst._zod.def.shape));
3721
+ inst.catchall = (catchall) => inst.clone({
3722
+ ...inst._zod.def,
3723
+ catchall
3724
+ });
3725
+ inst.passthrough = () => inst.clone({
3726
+ ...inst._zod.def,
3727
+ catchall: unknown()
3728
+ });
3729
+ inst.loose = () => inst.clone({
3730
+ ...inst._zod.def,
3731
+ catchall: unknown()
3732
+ });
3733
+ inst.strict = () => inst.clone({
3734
+ ...inst._zod.def,
3735
+ catchall: never()
3736
+ });
3737
+ inst.strip = () => inst.clone({
3738
+ ...inst._zod.def,
3739
+ catchall: void 0
3740
+ });
3741
+ inst.extend = (incoming) => {
3742
+ return extend(inst, incoming);
3743
+ };
3744
+ inst.safeExtend = (incoming) => {
3745
+ return safeExtend(inst, incoming);
3746
+ };
3747
+ inst.merge = (other) => merge(inst, other);
3748
+ inst.pick = (mask) => pick(inst, mask);
3749
+ inst.omit = (mask) => omit(inst, mask);
3750
+ inst.partial = (...args$1) => partial(ZodOptional, inst, args$1[0]);
3751
+ inst.required = (...args$1) => required(ZodNonOptional, inst, args$1[0]);
3752
+ });
3753
+ function object(shape, params) {
3754
+ return new ZodObject({
3755
+ type: "object",
3756
+ shape: shape ?? {},
3757
+ ...normalizeParams(params)
3758
+ });
3759
+ }
3760
+ const ZodUnion = /* @__PURE__ */ $constructor("ZodUnion", (inst, def) => {
3761
+ $ZodUnion.init(inst, def);
3762
+ ZodType.init(inst, def);
3763
+ inst._zod.processJSONSchema = (ctx, json, params) => unionProcessor(inst, ctx, json, params);
3764
+ inst.options = def.options;
3765
+ });
3766
+ function union(options, params) {
3767
+ return new ZodUnion({
3768
+ type: "union",
3769
+ options,
3770
+ ...normalizeParams(params)
3771
+ });
3772
+ }
3773
+ const ZodDiscriminatedUnion = /* @__PURE__ */ $constructor("ZodDiscriminatedUnion", (inst, def) => {
3774
+ ZodUnion.init(inst, def);
3775
+ $ZodDiscriminatedUnion.init(inst, def);
3776
+ });
3777
+ function discriminatedUnion(discriminator, options, params) {
3778
+ return new ZodDiscriminatedUnion({
3779
+ type: "union",
3780
+ options,
3781
+ discriminator,
3782
+ ...normalizeParams(params)
3783
+ });
3784
+ }
3785
+ const ZodIntersection = /* @__PURE__ */ $constructor("ZodIntersection", (inst, def) => {
3786
+ $ZodIntersection.init(inst, def);
3787
+ ZodType.init(inst, def);
3788
+ inst._zod.processJSONSchema = (ctx, json, params) => intersectionProcessor(inst, ctx, json, params);
3789
+ });
3790
+ function intersection(left, right) {
3791
+ return new ZodIntersection({
3792
+ type: "intersection",
3793
+ left,
3794
+ right
3795
+ });
3796
+ }
3797
+ const ZodRecord = /* @__PURE__ */ $constructor("ZodRecord", (inst, def) => {
3798
+ $ZodRecord.init(inst, def);
3799
+ ZodType.init(inst, def);
3800
+ inst._zod.processJSONSchema = (ctx, json, params) => recordProcessor(inst, ctx, json, params);
3801
+ inst.keyType = def.keyType;
3802
+ inst.valueType = def.valueType;
3803
+ });
3804
+ function record(keyType, valueType, params) {
3805
+ return new ZodRecord({
3806
+ type: "record",
3807
+ keyType,
3808
+ valueType,
3809
+ ...normalizeParams(params)
3810
+ });
3811
+ }
3812
+ const ZodEnum = /* @__PURE__ */ $constructor("ZodEnum", (inst, def) => {
3813
+ $ZodEnum.init(inst, def);
3814
+ ZodType.init(inst, def);
3815
+ inst._zod.processJSONSchema = (ctx, json, params) => enumProcessor(inst, ctx, json, params);
3816
+ inst.enum = def.entries;
3817
+ inst.options = Object.values(def.entries);
3818
+ const keys = new Set(Object.keys(def.entries));
3819
+ inst.extract = (values, params) => {
3820
+ const newEntries = {};
3821
+ for (const value of values) if (keys.has(value)) newEntries[value] = def.entries[value];
3822
+ else throw new Error(`Key ${value} not found in enum`);
3823
+ return new ZodEnum({
3824
+ ...def,
3825
+ checks: [],
3826
+ ...normalizeParams(params),
3827
+ entries: newEntries
3828
+ });
3829
+ };
3830
+ inst.exclude = (values, params) => {
3831
+ const newEntries = { ...def.entries };
3832
+ for (const value of values) if (keys.has(value)) delete newEntries[value];
3833
+ else throw new Error(`Key ${value} not found in enum`);
3834
+ return new ZodEnum({
3835
+ ...def,
3836
+ checks: [],
3837
+ ...normalizeParams(params),
3838
+ entries: newEntries
3839
+ });
3840
+ };
3841
+ });
3842
+ function _enum(values, params) {
3843
+ return new ZodEnum({
3844
+ type: "enum",
3845
+ entries: Array.isArray(values) ? Object.fromEntries(values.map((v) => [v, v])) : values,
3846
+ ...normalizeParams(params)
3847
+ });
3848
+ }
3849
+ const ZodLiteral = /* @__PURE__ */ $constructor("ZodLiteral", (inst, def) => {
3850
+ $ZodLiteral.init(inst, def);
3851
+ ZodType.init(inst, def);
3852
+ inst._zod.processJSONSchema = (ctx, json, params) => literalProcessor(inst, ctx, json, params);
3853
+ inst.values = new Set(def.values);
3854
+ Object.defineProperty(inst, "value", { get() {
3855
+ if (def.values.length > 1) throw new Error("This schema contains multiple valid literal values. Use `.values` instead.");
3856
+ return def.values[0];
3857
+ } });
3858
+ });
3859
+ function literal(value, params) {
3860
+ return new ZodLiteral({
3861
+ type: "literal",
3862
+ values: Array.isArray(value) ? value : [value],
3863
+ ...normalizeParams(params)
3864
+ });
3865
+ }
3866
+ const ZodTransform = /* @__PURE__ */ $constructor("ZodTransform", (inst, def) => {
3867
+ $ZodTransform.init(inst, def);
3868
+ ZodType.init(inst, def);
3869
+ inst._zod.processJSONSchema = (ctx, json, params) => transformProcessor(inst, ctx, json, params);
3870
+ inst._zod.parse = (payload, _ctx) => {
3871
+ if (_ctx.direction === "backward") throw new $ZodEncodeError(inst.constructor.name);
3872
+ payload.addIssue = (issue$1) => {
3873
+ if (typeof issue$1 === "string") payload.issues.push(issue(issue$1, payload.value, def));
3874
+ else {
3875
+ const _issue = issue$1;
3876
+ if (_issue.fatal) _issue.continue = false;
3877
+ _issue.code ?? (_issue.code = "custom");
3878
+ _issue.input ?? (_issue.input = payload.value);
3879
+ _issue.inst ?? (_issue.inst = inst);
3880
+ payload.issues.push(issue(_issue));
3881
+ }
3882
+ };
3883
+ const output = def.transform(payload.value, payload);
3884
+ if (output instanceof Promise) return output.then((output$1) => {
3885
+ payload.value = output$1;
3886
+ return payload;
3887
+ });
3888
+ payload.value = output;
3889
+ return payload;
3890
+ };
3891
+ });
3892
+ function transform(fn) {
3893
+ return new ZodTransform({
3894
+ type: "transform",
3895
+ transform: fn
3896
+ });
3897
+ }
3898
+ const ZodOptional = /* @__PURE__ */ $constructor("ZodOptional", (inst, def) => {
3899
+ $ZodOptional.init(inst, def);
3900
+ ZodType.init(inst, def);
3901
+ inst._zod.processJSONSchema = (ctx, json, params) => optionalProcessor(inst, ctx, json, params);
3902
+ inst.unwrap = () => inst._zod.def.innerType;
3903
+ });
3904
+ function optional(innerType) {
3905
+ return new ZodOptional({
3906
+ type: "optional",
3907
+ innerType
3908
+ });
3909
+ }
3910
+ const ZodExactOptional = /* @__PURE__ */ $constructor("ZodExactOptional", (inst, def) => {
3911
+ $ZodExactOptional.init(inst, def);
3912
+ ZodType.init(inst, def);
3913
+ inst._zod.processJSONSchema = (ctx, json, params) => optionalProcessor(inst, ctx, json, params);
3914
+ inst.unwrap = () => inst._zod.def.innerType;
3915
+ });
3916
+ function exactOptional(innerType) {
3917
+ return new ZodExactOptional({
3918
+ type: "optional",
3919
+ innerType
3920
+ });
3921
+ }
3922
+ const ZodNullable = /* @__PURE__ */ $constructor("ZodNullable", (inst, def) => {
3923
+ $ZodNullable.init(inst, def);
3924
+ ZodType.init(inst, def);
3925
+ inst._zod.processJSONSchema = (ctx, json, params) => nullableProcessor(inst, ctx, json, params);
3926
+ inst.unwrap = () => inst._zod.def.innerType;
3927
+ });
3928
+ function nullable(innerType) {
3929
+ return new ZodNullable({
3930
+ type: "nullable",
3931
+ innerType
3932
+ });
3933
+ }
3934
+ const ZodDefault = /* @__PURE__ */ $constructor("ZodDefault", (inst, def) => {
3935
+ $ZodDefault.init(inst, def);
3936
+ ZodType.init(inst, def);
3937
+ inst._zod.processJSONSchema = (ctx, json, params) => defaultProcessor(inst, ctx, json, params);
3938
+ inst.unwrap = () => inst._zod.def.innerType;
3939
+ inst.removeDefault = inst.unwrap;
3940
+ });
3941
+ function _default(innerType, defaultValue) {
3942
+ return new ZodDefault({
3943
+ type: "default",
3944
+ innerType,
3945
+ get defaultValue() {
3946
+ return typeof defaultValue === "function" ? defaultValue() : shallowClone(defaultValue);
3947
+ }
3948
+ });
3949
+ }
3950
+ const ZodPrefault = /* @__PURE__ */ $constructor("ZodPrefault", (inst, def) => {
3951
+ $ZodPrefault.init(inst, def);
3952
+ ZodType.init(inst, def);
3953
+ inst._zod.processJSONSchema = (ctx, json, params) => prefaultProcessor(inst, ctx, json, params);
3954
+ inst.unwrap = () => inst._zod.def.innerType;
3955
+ });
3956
+ function prefault(innerType, defaultValue) {
3957
+ return new ZodPrefault({
3958
+ type: "prefault",
3959
+ innerType,
3960
+ get defaultValue() {
3961
+ return typeof defaultValue === "function" ? defaultValue() : shallowClone(defaultValue);
3962
+ }
3963
+ });
3964
+ }
3965
+ const ZodNonOptional = /* @__PURE__ */ $constructor("ZodNonOptional", (inst, def) => {
3966
+ $ZodNonOptional.init(inst, def);
3967
+ ZodType.init(inst, def);
3968
+ inst._zod.processJSONSchema = (ctx, json, params) => nonoptionalProcessor(inst, ctx, json, params);
3969
+ inst.unwrap = () => inst._zod.def.innerType;
3970
+ });
3971
+ function nonoptional(innerType, params) {
3972
+ return new ZodNonOptional({
3973
+ type: "nonoptional",
3974
+ innerType,
3975
+ ...normalizeParams(params)
3976
+ });
3977
+ }
3978
+ const ZodCatch = /* @__PURE__ */ $constructor("ZodCatch", (inst, def) => {
3979
+ $ZodCatch.init(inst, def);
3980
+ ZodType.init(inst, def);
3981
+ inst._zod.processJSONSchema = (ctx, json, params) => catchProcessor(inst, ctx, json, params);
3982
+ inst.unwrap = () => inst._zod.def.innerType;
3983
+ inst.removeCatch = inst.unwrap;
3984
+ });
3985
+ function _catch(innerType, catchValue) {
3986
+ return new ZodCatch({
3987
+ type: "catch",
3988
+ innerType,
3989
+ catchValue: typeof catchValue === "function" ? catchValue : () => catchValue
3990
+ });
3991
+ }
3992
+ const ZodPipe = /* @__PURE__ */ $constructor("ZodPipe", (inst, def) => {
3993
+ $ZodPipe.init(inst, def);
3994
+ ZodType.init(inst, def);
3995
+ inst._zod.processJSONSchema = (ctx, json, params) => pipeProcessor(inst, ctx, json, params);
3996
+ inst.in = def.in;
3997
+ inst.out = def.out;
3998
+ });
3999
+ function pipe(in_, out) {
4000
+ return new ZodPipe({
4001
+ type: "pipe",
4002
+ in: in_,
4003
+ out
4004
+ });
4005
+ }
4006
+ const ZodReadonly = /* @__PURE__ */ $constructor("ZodReadonly", (inst, def) => {
4007
+ $ZodReadonly.init(inst, def);
4008
+ ZodType.init(inst, def);
4009
+ inst._zod.processJSONSchema = (ctx, json, params) => readonlyProcessor(inst, ctx, json, params);
4010
+ inst.unwrap = () => inst._zod.def.innerType;
4011
+ });
4012
+ function readonly(innerType) {
4013
+ return new ZodReadonly({
4014
+ type: "readonly",
4015
+ innerType
4016
+ });
4017
+ }
4018
+ const ZodCustom = /* @__PURE__ */ $constructor("ZodCustom", (inst, def) => {
4019
+ $ZodCustom.init(inst, def);
4020
+ ZodType.init(inst, def);
4021
+ inst._zod.processJSONSchema = (ctx, json, params) => customProcessor(inst, ctx, json, params);
4022
+ });
4023
+ function refine(fn, _params = {}) {
4024
+ return _refine(ZodCustom, fn, _params);
4025
+ }
4026
+ function superRefine(fn) {
4027
+ return _superRefine(fn);
4028
+ }
4029
+ const describe = describe$1;
4030
+ const meta = meta$1;
4031
+
4032
+ //#endregion
4033
+ //#region node_modules/zod/v4/classic/coerce.js
4034
+ function number(params) {
4035
+ return _coercedNumber(ZodNumber, params);
4036
+ }
4037
+
4038
+ //#endregion
4039
+ //#region src/cli/args.ts
4040
+ const BaseArgsSchema = object({
4041
+ env: string().optional(),
4042
+ config: string().optional(),
4043
+ worker: string().optional()
4044
+ });
4045
+ const ApplyArgsSchema = BaseArgsSchema.extend({
4046
+ add_shard: string().optional(),
4047
+ plan: string().optional(),
4048
+ allow_stale: boolean().optional(),
4049
+ rollback_on_failure: boolean().optional(),
4050
+ target: string().optional()
4051
+ });
4052
+ const DestroyArgsSchema = BaseArgsSchema.extend({
4053
+ env: string().min(1, { error: "env is required for destroy" }),
4054
+ force: boolean().optional(),
4055
+ skip_workers: boolean().optional(),
4056
+ confirm_env: string().optional(),
4057
+ wipe_metadata: boolean().optional(),
4058
+ plan: string().optional(),
4059
+ allow_stale: boolean().optional()
4060
+ });
4061
+ const BootstrapArgsSchema = object({
4062
+ env: string().min(1, { error: "env is required for bootstrap" }),
4063
+ config: string().optional()
4064
+ });
4065
+ const DriftArgsSchema = BaseArgsSchema.extend({ json: boolean().optional() });
4066
+ const PlanArgsSchema = BaseArgsSchema.extend({
4067
+ json: boolean().optional(),
4068
+ detailed_exitcode: boolean().optional(),
4069
+ out: string().optional(),
4070
+ destroy: boolean().optional(),
4071
+ target: string().optional()
4072
+ });
4073
+ const ImportArgsSchema = object({
4074
+ env: string().min(1, { error: "env is required for import" }),
4075
+ config: string().optional(),
4076
+ kind: _enum([
4077
+ "d1",
4078
+ "r2",
4079
+ "kv",
4080
+ "queue",
4081
+ "hyperdrive",
4082
+ "vectorize",
4083
+ "ai_gateway",
4084
+ "pipeline",
4085
+ "workflow",
4086
+ "secret_store",
4087
+ "dns_record",
4088
+ "dispatch_namespace",
4089
+ "worker_route"
4090
+ ], { error: "kind must be one of d1 | r2 | kv | queue | hyperdrive | vectorize | ai_gateway | pipeline | workflow | secret_store | dns_record | dispatch_namespace | worker_route" }),
4091
+ logical: string().min(1, { error: "logical is required" }),
4092
+ cf_id: string().optional(),
4093
+ shard_date: string().optional(),
4094
+ created_date: string().optional(),
4095
+ route_id: string().optional(),
4096
+ zone_name: string().optional()
4097
+ });
4098
+ const StatusArgsSchema = BaseArgsSchema.extend({ tenant: string().optional() });
4099
+ const EventsArgsSchema = BaseArgsSchema.extend({
4100
+ json: boolean().optional(),
4101
+ limit: number().int().min(1).max(100).optional()
4102
+ });
4103
+ const DoctorArgsSchema = object({ json: boolean().optional() });
4104
+ const ProvisionTenantArgsSchema = object({
4105
+ env: string().min(1, { error: "env is required" }),
4106
+ product: string().min(1, { error: "product is required" }),
4107
+ workspace: string().min(1, { error: "workspace is required" }),
4108
+ main: string().optional(),
4109
+ artifact_key: string().optional(),
4110
+ module_name: string().optional(),
4111
+ config: string().optional(),
4112
+ compatibility_date: string().optional(),
4113
+ compat_flags: string().optional(),
4114
+ shards: string().optional(),
4115
+ json: boolean().optional()
4116
+ }).refine((d) => !!(d.main || d.artifact_key), { message: "Provide --main <file> or --artifact-key <r2-key> (under tamer-artifacts-{env})" });
4117
+ const DestroyTenantArgsSchema = object({
4118
+ env: string().min(1, { error: "env is required" }),
4119
+ product: string().min(1, { error: "product is required" }),
4120
+ workspace: string().min(1, { error: "workspace is required" }),
4121
+ force: boolean().optional(),
4122
+ confirm_tenant: string().optional(),
4123
+ config: string().optional(),
4124
+ json: boolean().optional()
4125
+ });
4126
+ const DeployArgsSchema = BaseArgsSchema.extend({ dispatch_namespace: string().optional() });
4127
+ const DevArgsSchema = BaseArgsSchema.extend({ all: boolean().optional() });
4128
+ function parseArgs(argv) {
4129
+ const opts = {};
4130
+ for (let i = 0; i < argv.length; i++) {
4131
+ const arg = argv[i];
4132
+ if (arg.startsWith("--")) {
4133
+ const key = arg.slice(2).replace(/-/g, "_");
4134
+ const next = argv[i + 1];
4135
+ if (next && !next.startsWith("--")) {
4136
+ opts[key] = next;
4137
+ i++;
4138
+ } else opts[key] = true;
4139
+ }
4140
+ }
4141
+ return opts;
4142
+ }
4143
+ function toOpts(raw) {
4144
+ const opts = {};
4145
+ for (const [k, v] of Object.entries(raw)) opts[k] = v;
4146
+ return opts;
4147
+ }
4148
+ function formatZodError(error) {
4149
+ return error.issues.map((e) => e.path.length ? `${e.path.join(".")}: ${e.message}` : e.message).join("; ");
4150
+ }
4151
+ function parseSyncArgs(argv) {
4152
+ const parsed = BaseArgsSchema.safeParse(toOpts(parseArgs(argv)));
4153
+ if (!parsed.success) throw new Error(`Invalid arguments: ${formatZodError(parsed.error)}`);
4154
+ return {
4155
+ env: parsed.data.env,
4156
+ configPath: parsed.data.config
4157
+ };
4158
+ }
4159
+ function parseApplyArgs(argv) {
4160
+ const parsed = ApplyArgsSchema.safeParse(toOpts(parseArgs(argv)));
4161
+ if (!parsed.success) throw new Error(`Invalid arguments: ${formatZodError(parsed.error)}`);
4162
+ return {
4163
+ env: parsed.data.env,
4164
+ addShard: parsed.data.add_shard,
4165
+ configPath: parsed.data.config,
4166
+ planFile: parsed.data.plan,
4167
+ allowStale: parsed.data.allow_stale,
4168
+ rollbackOnFailure: parsed.data.rollback_on_failure,
4169
+ target: parsed.data.target
4170
+ };
4171
+ }
4172
+ function parseDevArgs(argv) {
4173
+ const parsed = DevArgsSchema.safeParse(toOpts(parseArgs(argv)));
4174
+ if (!parsed.success) throw new Error(`Invalid arguments: ${formatZodError(parsed.error)}`);
4175
+ return {
4176
+ worker: parsed.data.worker,
4177
+ env: parsed.data.env,
4178
+ configPath: parsed.data.config,
4179
+ all: parsed.data.all
4180
+ };
4181
+ }
4182
+ function parseDeployArgs(argv) {
4183
+ const parsed = DeployArgsSchema.safeParse(toOpts(parseArgs(argv)));
4184
+ if (!parsed.success) throw new Error(`Invalid arguments: ${formatZodError(parsed.error)}`);
4185
+ return {
4186
+ worker: parsed.data.worker,
4187
+ env: parsed.data.env,
4188
+ configPath: parsed.data.config,
4189
+ dispatchNamespace: parsed.data.dispatch_namespace
4190
+ };
4191
+ }
4192
+ function parseMigrateArgs(argv) {
4193
+ const parsed = BaseArgsSchema.safeParse(toOpts(parseArgs(argv)));
4194
+ if (!parsed.success) throw new Error(`Invalid arguments: ${formatZodError(parsed.error)}`);
4195
+ return {
4196
+ worker: parsed.data.worker,
4197
+ env: parsed.data.env,
4198
+ configPath: parsed.data.config
4199
+ };
4200
+ }
4201
+ function parseTypesArgs(argv) {
4202
+ const parsed = BaseArgsSchema.safeParse(toOpts(parseArgs(argv)));
4203
+ if (!parsed.success) throw new Error(`Invalid arguments: ${formatZodError(parsed.error)}`);
4204
+ return {
4205
+ worker: parsed.data.worker,
4206
+ env: parsed.data.env,
4207
+ configPath: parsed.data.config
4208
+ };
4209
+ }
4210
+ function parseStatusArgs(argv) {
4211
+ const parsed = StatusArgsSchema.safeParse(toOpts(parseArgs(argv)));
4212
+ if (!parsed.success) throw new Error(`Invalid arguments: ${formatZodError(parsed.error)}`);
4213
+ return {
4214
+ env: parsed.data.env,
4215
+ configPath: parsed.data.config,
4216
+ tenant: parsed.data.tenant
4217
+ };
4218
+ }
4219
+ function parseEventsArgs(argv) {
4220
+ const parsed = EventsArgsSchema.safeParse(toOpts(parseArgs(argv)));
4221
+ if (!parsed.success) throw new Error(`Invalid arguments: ${formatZodError(parsed.error)}`);
4222
+ return {
4223
+ env: parsed.data.env,
4224
+ configPath: parsed.data.config,
4225
+ limit: parsed.data.limit,
4226
+ json: parsed.data.json
4227
+ };
4228
+ }
4229
+ function parseDoctorArgs(argv) {
4230
+ const parsed = DoctorArgsSchema.safeParse(toOpts(parseArgs(argv)));
4231
+ if (!parsed.success) throw new Error(`Invalid arguments: ${formatZodError(parsed.error)}`);
4232
+ return { json: parsed.data.json };
4233
+ }
4234
+ function parseProvisionTenantArgs(argv) {
4235
+ const parsed = ProvisionTenantArgsSchema.safeParse(toOpts(parseArgs(argv)));
4236
+ if (!parsed.success) throw new Error(`Invalid arguments: ${formatZodError(parsed.error)}`);
4237
+ const d = parsed.data;
4238
+ return {
4239
+ env: d.env,
4240
+ product: d.product,
4241
+ workspace: d.workspace,
4242
+ main: d.main,
4243
+ artifactKey: d.artifact_key,
4244
+ moduleName: d.module_name,
4245
+ configPath: d.config,
4246
+ compatibilityDate: d.compatibility_date,
4247
+ compatibilityFlags: d.compat_flags?.split(",").map((s) => s.trim()).filter(Boolean),
4248
+ shardsRaw: d.shards,
4249
+ json: d.json
4250
+ };
4251
+ }
4252
+ function parseDestroyTenantArgs(argv) {
4253
+ const parsed = DestroyTenantArgsSchema.safeParse(toOpts(parseArgs(argv)));
4254
+ if (!parsed.success) throw new Error(`Invalid arguments: ${formatZodError(parsed.error)}`);
4255
+ const d = parsed.data;
4256
+ return {
4257
+ env: d.env,
4258
+ product: d.product,
4259
+ workspace: d.workspace,
4260
+ force: d.force,
4261
+ confirmTenant: d.confirm_tenant,
4262
+ configPath: d.config,
4263
+ json: d.json
4264
+ };
4265
+ }
4266
+ function parseDestroyArgs(argv) {
4267
+ const opts = toOpts(parseArgs(argv));
4268
+ const parsed = DestroyArgsSchema.safeParse(opts);
4269
+ if (!parsed.success) throw new Error(`Invalid arguments: ${formatZodError(parsed.error)}`);
4270
+ return {
4271
+ env: parsed.data.env,
4272
+ force: parsed.data.force,
4273
+ skipWorkers: parsed.data.skip_workers,
4274
+ confirmEnv: parsed.data.confirm_env,
4275
+ configPath: parsed.data.config,
4276
+ wipeMetadata: parsed.data.wipe_metadata,
4277
+ planFile: parsed.data.plan,
4278
+ allowStale: parsed.data.allow_stale
4279
+ };
4280
+ }
4281
+ function parseDriftArgs(argv) {
4282
+ const parsed = DriftArgsSchema.safeParse(toOpts(parseArgs(argv)));
4283
+ if (!parsed.success) throw new Error(`Invalid arguments: ${formatZodError(parsed.error)}`);
4284
+ return {
4285
+ env: parsed.data.env,
4286
+ configPath: parsed.data.config,
4287
+ json: parsed.data.json
4288
+ };
4289
+ }
4290
+ function parsePlanArgs(argv) {
4291
+ const parsed = PlanArgsSchema.safeParse(toOpts(parseArgs(argv)));
4292
+ if (!parsed.success) throw new Error(`Invalid arguments: ${formatZodError(parsed.error)}`);
4293
+ return {
4294
+ env: parsed.data.env,
4295
+ configPath: parsed.data.config,
4296
+ json: parsed.data.json,
4297
+ detailedExitcode: parsed.data.detailed_exitcode,
4298
+ out: parsed.data.out,
4299
+ destroy: parsed.data.destroy,
4300
+ target: parsed.data.target
4301
+ };
4302
+ }
4303
+ function parseImportArgs(argv) {
4304
+ const parsed = ImportArgsSchema.safeParse(toOpts(parseArgs(argv)));
4305
+ if (!parsed.success) throw new Error(`Invalid arguments: ${formatZodError(parsed.error)}`);
4306
+ const d = parsed.data;
4307
+ return {
4308
+ env: d.env,
4309
+ configPath: d.config,
4310
+ kind: d.kind,
4311
+ logical: d.logical,
4312
+ cfId: d.cf_id,
4313
+ shardDate: d.shard_date,
4314
+ createdDate: d.created_date,
4315
+ routeId: d.route_id,
4316
+ zoneName: d.zone_name
4317
+ };
4318
+ }
4319
+ function parseBootstrapArgs(argv) {
4320
+ const parsed = BootstrapArgsSchema.safeParse(toOpts(parseArgs(argv)));
4321
+ if (!parsed.success) throw new Error(`Invalid arguments: ${formatZodError(parsed.error)}`);
4322
+ return {
4323
+ env: parsed.data.env,
4324
+ configPath: parsed.data.config
4325
+ };
4326
+ }
4327
+
4328
+ //#endregion
4329
+ //#region src/core/state/StateConflictError.ts
4330
+ /** Thrown when D1 `cfi_state` was updated by another writer since {@link StateManager.hydrate}. */
4331
+ var StateConflictError = class extends Error {
4332
+ code = "STATE_CONFLICT";
4333
+ constructor(message) {
4334
+ super(message);
4335
+ this.name = "StateConflictError";
4336
+ }
4337
+ };
4338
+
4339
+ //#endregion
4340
+ //#region src/cli/index.ts
4341
+ const args = process.argv.slice(2);
4342
+ const command = args[0];
4343
+ const rest = args.slice(1);
4344
+ async function main() {
4345
+ let exitStatus = 0;
4346
+ try {
4347
+ switch (command) {
4348
+ case "bootstrap":
4349
+ await import("./bootstrap-CBzPilB1.mjs").then((m) => m.runBootstrap(parseBootstrapArgs(rest)));
4350
+ break;
4351
+ case "sync":
4352
+ await import("./sync-f2K2blwm.mjs").then((m) => m.runSync(parseSyncArgs(rest)));
4353
+ break;
4354
+ case "apply": {
4355
+ const a = parseApplyArgs(rest);
4356
+ await import("./apply-B0b_jjGv.mjs").then((m) => m.runApply({
4357
+ env: a.env,
4358
+ addShard: a.addShard,
4359
+ configPath: a.configPath,
4360
+ planFile: a.planFile,
4361
+ allowStale: a.allowStale,
4362
+ rollbackOnFailure: a.rollbackOnFailure,
4363
+ target: a.target
4364
+ }));
4365
+ break;
4366
+ }
4367
+ case "dev":
4368
+ await import("./dev-Dt26nzMJ.mjs").then((m) => m.runDev(parseDevArgs(rest)));
4369
+ break;
4370
+ case "deploy": {
4371
+ const d = parseDeployArgs(rest);
4372
+ await import("./deploy-gHEQxhmx.mjs").then((m) => m.runDeploy({
4373
+ worker: d.worker,
4374
+ env: d.env,
4375
+ configPath: d.configPath,
4376
+ dispatchNamespace: d.dispatchNamespace
4377
+ }));
4378
+ break;
4379
+ }
4380
+ case "migrate":
4381
+ await import("./migrate-CahG6BYV.mjs").then((m) => m.runMigrate(parseMigrateArgs(rest)));
4382
+ break;
4383
+ case "types":
4384
+ await import("./types-CqxqYnrT.mjs").then((m) => m.runTypes(parseTypesArgs(rest)));
4385
+ break;
4386
+ case "status":
4387
+ await import("./status-DLwREPjb.mjs").then((m) => m.runStatus(parseStatusArgs(rest)));
4388
+ break;
4389
+ case "events":
4390
+ await import("./events-BSwGdkGj.mjs").then((m) => m.runEvents(parseEventsArgs(rest)));
4391
+ break;
4392
+ case "drift":
4393
+ exitStatus = await import("./drift-D5qzCTft.mjs").then((m) => m.runDrift(parseDriftArgs(rest)));
4394
+ break;
4395
+ case "plan": {
4396
+ const p = parsePlanArgs(rest);
4397
+ exitStatus = await import("./plan-DWvsvy1U.mjs").then((m) => m.runPlan({
4398
+ env: p.env,
4399
+ configPath: p.configPath,
4400
+ json: p.json,
4401
+ detailedExitcode: p.detailedExitcode,
4402
+ out: p.out,
4403
+ destroy: p.destroy,
4404
+ target: p.target
4405
+ }));
4406
+ break;
4407
+ }
4408
+ case "import":
4409
+ await import("./import-BrduwA9Z.mjs").then((m) => m.runImport(parseImportArgs(rest)));
4410
+ break;
4411
+ case "doctor":
4412
+ exitStatus = await import("./doctor-C_hs7k2D.mjs").then((m) => m.runDoctor(parseDoctorArgs(rest)));
4413
+ break;
4414
+ case "provision-tenant": {
4415
+ const p = parseProvisionTenantArgs(rest);
4416
+ await import("./provision-tenant-WTKo93Y0.mjs").then((m) => m.runProvisionTenant({
4417
+ env: p.env,
4418
+ product: p.product,
4419
+ workspace: p.workspace,
4420
+ main: p.main,
4421
+ artifactKey: p.artifactKey,
4422
+ moduleName: p.moduleName,
4423
+ configPath: p.configPath,
4424
+ compatibilityDate: p.compatibilityDate,
4425
+ compatibilityFlags: p.compatibilityFlags,
4426
+ shardsRaw: p.shardsRaw,
4427
+ json: p.json
4428
+ }));
4429
+ break;
4430
+ }
4431
+ case "destroy-tenant": {
4432
+ const t = parseDestroyTenantArgs(rest);
4433
+ await import("./destroy-tenant-BW2nasnK.mjs").then((m) => m.runDestroyTenant({
4434
+ env: t.env,
4435
+ product: t.product,
4436
+ workspace: t.workspace,
4437
+ force: t.force,
4438
+ confirmTenant: t.confirmTenant,
4439
+ configPath: t.configPath,
4440
+ json: t.json
4441
+ }));
4442
+ break;
4443
+ }
4444
+ case "destroy": {
4445
+ const d = parseDestroyArgs(rest);
4446
+ await import("./destroy-B21f3wgq.mjs").then((m) => m.runDestroy({
4447
+ env: d.env,
4448
+ force: d.force,
4449
+ skipWorkers: d.skipWorkers,
4450
+ confirmEnv: d.confirmEnv,
4451
+ configPath: d.configPath,
4452
+ wipeMetadata: d.wipeMetadata,
4453
+ planFile: d.planFile,
4454
+ allowStale: d.allowStale
4455
+ }));
4456
+ break;
4457
+ }
4458
+ case "wfp": {
4459
+ const [sub, ...wfpRest] = rest;
4460
+ if (sub === "put") {
4461
+ const { parseWfpPutArgs, runWfpPut } = await import("./wfp-put-jaVd_LjO.mjs");
4462
+ await runWfpPut(parseWfpPutArgs(wfpRest));
4463
+ break;
4464
+ }
4465
+ if (sub === "delete") {
4466
+ const { parseWfpDeleteArgs, runWfpDelete } = await import("./wfp-delete-DysvX1u7.mjs");
4467
+ await runWfpDelete(parseWfpDeleteArgs(wfpRest));
4468
+ break;
4469
+ }
4470
+ console.error("usage:\n tamer wfp put --namespace <n> --script-name <s> --main <file> [--compatibility-date <d>] [--compat-flags a,b] [--config <path>]\n tamer wfp delete --namespace <n> --script-name <s> [--force] [--config <path>]");
4471
+ process.exit(1);
4472
+ }
4473
+ case "help":
4474
+ case "-h":
4475
+ case "--help":
4476
+ case void 0:
4477
+ console.log(`
4478
+ tamer — Cloudflare Workers infrastructure manager
4479
+
4480
+ Usage: tamer <command> [options]
4481
+
4482
+ Commands:
4483
+ bootstrap Create per-env Tamer metadata: tamer-state-<env> (D1) and tamer-artifacts-<env> (R2)
4484
+ sync Sync state from Cloudflare API
4485
+ apply Provision missing resources
4486
+ dev Start wrangler dev (use --all for every worker)
4487
+ deploy Deploy workers
4488
+ migrate Run D1 migrations
4489
+ types Generate worker-configuration.d.ts
4490
+ status Show resource status (optional --tenant product:workspace)
4491
+ events Show recent stack operations from state (read-only; --limit, --json)
4492
+ drift Compare state vs Cloudflare and report differences (read-only)
4493
+ plan CloudFormation-style preview of apply+deploy (read-only)
4494
+ import Register an existing Cloudflare resource into Tamer state by logical name
4495
+ doctor Verify CLOUDFLARE_* credentials can read the account API
4496
+ provision-tenant Runtime: create per-tenant D1 shards declared in tenant.d1Shards + upload dispatch script (--main or --artifact-key); --shards a,b trims to a subset of the configured layout (omit for all); --json emits machine-readable result for Cloudflare Container callers
4497
+ destroy-tenant Runtime: remove tenant script + D1 + state (shared envs need --confirm-tenant); --json emits machine-readable result
4498
+ destroy Delete all resources for an env (use with caution)
4499
+ wfp put Upload a single-module user Worker to a dispatch namespace (multipart API)
4500
+ wfp delete Delete a user Worker from a dispatch namespace
4501
+
4502
+ Options:
4503
+ --env <name> Environment (default: local for most commands; deploy requires explicit --env)
4504
+ --worker <name> Target specific worker (monorepo)
4505
+ --config <path> Path to tamer/project.config.ts (or another .ts file; tamer.config.ts is not supported)
4506
+ --all dev: run all workers on ports BASE, BASE+1, ... (see TAMER_DEV_BASE_PORT)
4507
+ --add-shard <name> Add a new shard (apply only)
4508
+ --target <kind>:<logical> apply / plan: only that declared resource (not with apply --plan or plan --out)
4509
+ --dispatch-namespace <name> Workers for Platforms: pass to wrangler deploy (deploy only)
4510
+ --force Bypass shared-env destroy confirmation (destroy only)
4511
+ --confirm-env <name> destroy: required for envs dev, staging, prod, production; must match --env
4512
+ --skip-workers destroy: do not run wrangler delete / dispatch script delete (storage + namespaces only)
4513
+ --wipe-metadata destroy: after resources, delete shared tamer-state-{env} D1 + tamer-artifacts-{env} R2 (use on last stack only)
4514
+ --json drift / plan: emit JSON instead of human-readable output
4515
+ --detailed-exitcode plan: exit 2 instead of 0 when there are pending changes (Terraform-style)
4516
+ --destroy plan: preview deletions instead of creates/updates (read-only "tamer destroy" dry-run)
4517
+ --kind <k> import: d1 | r2 | kv | queue | hyperdrive | vectorize | ai_gateway | pipeline | workflow | dispatch_namespace | worker_route
4518
+ --logical <n> import: logical resource name from the Tamer project config (or worker key)
4519
+ --cf-id <id> import: Cloudflare id (D1 uuid, KV id, R2 bucket name, dispatch namespace name)
4520
+ --shard-date <date> import d1: required for sharded D1 databases (YYYY-MM-DD)
4521
+ --created-date <date> import r2: bucket creation date (defaults to extracting from name)
4522
+ --route-id <id> import worker_route: route id from /zones/{id}/workers/routes
4523
+ --zone-name <z> import worker_route: optional zone hint when a worker has multiple routes
4524
+
4525
+ Environment variables (same as Wrangler):
4526
+ CLOUDFLARE_ACCOUNT_ID Cloudflare account ID
4527
+ CLOUDFLARE_API_TOKEN Cloudflare API token
4528
+ R2_ACCESS_KEY_ID (optional) R2 S3 API access key for "tamer destroy" — empty bucket (objects + abort incomplete multipart) before delete
4529
+ R2_SECRET_ACCESS_KEY (optional) R2 S3 API secret; create under R2 → Manage R2 API Tokens; not the same as CLOUDFLARE_API_TOKEN
4530
+ TAMER_DEV_BASE_PORT First port for "tamer dev --all" (default 8787)
4531
+ `);
4532
+ break;
4533
+ default:
4534
+ console.error(`Unknown command: ${command}`);
4535
+ console.error("Run 'tamer help' for usage.");
4536
+ process.exit(1);
4537
+ }
4538
+ if (exitStatus !== 0) process.exit(exitStatus);
4539
+ } catch (err) {
4540
+ if (err instanceof StateConflictError) {
4541
+ console.error(err.message);
4542
+ process.exit(3);
4543
+ return;
4544
+ }
4545
+ console.error(err instanceof Error ? err.message : err);
4546
+ process.exit(1);
4547
+ }
4548
+ }
4549
+ main();
4550
+
4551
+ //#endregion
4552
+ export { boolean as a, number$1 as c, string as d, union as f, array as i, object as l, _enum as n, discriminatedUnion as o, any as r, literal as s, StateConflictError as t, record as u };
4553
+ //# sourceMappingURL=tamer.mjs.map