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