@saar-ai/web-widget 0.12.0 → 0.13.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (47) hide show
  1. package/dist/capture-card/capture-card-dom.d.ts +52 -0
  2. package/dist/capture-card/capture-card-dom.d.ts.map +1 -0
  3. package/dist/capture-card/capture-card-host.d.ts +9 -0
  4. package/dist/capture-card/capture-card-host.d.ts.map +1 -0
  5. package/dist/chunks/capture-card-BlJ6EkWn.js +156 -0
  6. package/dist/chunks/capture-card-dom-BqDqOvQF.js +383 -0
  7. package/dist/chunks/{chat-CU9VPqVO.js → chat-R7z4DtMM.js} +110 -8
  8. package/dist/chunks/form-fill-B-h6Uw1t.js +45 -0
  9. package/dist/chunks/form-fill-dom-skU-ZwLB.js +191 -0
  10. package/dist/chunks/{host-widget-Cc0KjJwZ.js → host-widget-BZAYL5tQ.js} +958 -449
  11. package/dist/chunks/{schemas-YN3wGSGZ.js → schemas-B2B3k74u.js} +2427 -1167
  12. package/dist/chunks/{telemetry-B1xBTk1s.js → telemetry-3f--vvdX.js} +18 -12
  13. package/dist/concierge-shell.css +1 -1
  14. package/dist/consent/consent-prompt-dom.d.ts +57 -0
  15. package/dist/consent/consent-prompt-dom.d.ts.map +1 -0
  16. package/dist/consent/consent-prompt-preview.d.ts +16 -0
  17. package/dist/consent/consent-prompt-preview.d.ts.map +1 -0
  18. package/dist/dock/dock-renderer.d.ts +1 -1
  19. package/dist/dock/dock-renderer.d.ts.map +1 -1
  20. package/dist/dock/dock.d.ts +11 -0
  21. package/dist/dock/dock.d.ts.map +1 -1
  22. package/dist/flow-link.d.ts +13 -0
  23. package/dist/flow-link.d.ts.map +1 -0
  24. package/dist/form-fill/form-fill-dom.d.ts +39 -0
  25. package/dist/form-fill/form-fill-dom.d.ts.map +1 -0
  26. package/dist/format-money.d.ts +3 -2
  27. package/dist/format-money.d.ts.map +1 -1
  28. package/dist/generated/concierge-shell-css.d.ts.map +1 -1
  29. package/dist/host-widget.d.ts +8 -5
  30. package/dist/host-widget.d.ts.map +1 -1
  31. package/dist/index.d.ts +5 -1
  32. package/dist/index.d.ts.map +1 -1
  33. package/dist/index.js +139 -3
  34. package/dist/next/index.js +1 -1
  35. package/dist/use-chat-session.d.ts +23 -3
  36. package/dist/use-chat-session.d.ts.map +1 -1
  37. package/dist/use-voice-session.d.ts +39 -4
  38. package/dist/use-voice-session.d.ts.map +1 -1
  39. package/dist/voice-widget.d.ts +11 -5
  40. package/dist/voice-widget.d.ts.map +1 -1
  41. package/dist/widget/concierge-shell.d.ts +4 -2
  42. package/dist/widget/concierge-shell.d.ts.map +1 -1
  43. package/dist/widget/shell-renderer.d.ts +1 -1
  44. package/dist/widget/shell-renderer.d.ts.map +1 -1
  45. package/dist/widget-cart-summary.d.ts +4 -3
  46. package/dist/widget-cart-summary.d.ts.map +1 -1
  47. package/package.json +16 -16
@@ -1,80 +1,31 @@
1
- //#region ../../node_modules/.pnpm/zod@4.4.3/node_modules/zod/v4/core/core.js
2
- var _a$1;
3
- function $constructor(name, initializer, params) {
4
- function init(inst, def) {
5
- if (!inst._zod) Object.defineProperty(inst, "_zod", {
6
- value: {
7
- def,
8
- constr: _,
9
- traits: /* @__PURE__ */ new Set()
10
- },
11
- enumerable: false
12
- });
13
- if (inst._zod.traits.has(name)) return;
14
- inst._zod.traits.add(name);
15
- initializer(inst, def);
16
- const proto = _.prototype;
17
- const keys = Object.keys(proto);
18
- for (let i = 0; i < keys.length; i++) {
19
- const k = keys[i];
20
- if (!(k in inst)) inst[k] = proto[k].bind(inst);
21
- }
22
- }
23
- const Parent = params?.Parent ?? Object;
24
- class Definition extends Parent {}
25
- Object.defineProperty(Definition, "name", { value: name });
26
- function _(def) {
27
- var _a;
28
- const inst = params?.Parent ? new Definition() : this;
29
- init(inst, def);
30
- (_a = inst._zod).deferred ?? (_a.deferred = []);
31
- for (const fn of inst._zod.deferred) fn();
32
- return inst;
33
- }
34
- Object.defineProperty(_, "init", { value: init });
35
- Object.defineProperty(_, Symbol.hasInstance, { value: (inst) => {
36
- if (params?.Parent && inst instanceof params.Parent) return true;
37
- return inst?._zod?.traits?.has(name);
38
- } });
39
- Object.defineProperty(_, "name", { value: name });
40
- return _;
41
- }
42
- var $ZodAsyncError = class extends Error {
43
- constructor() {
44
- super(`Encountered Promise during synchronous parse. Use .parseAsync() instead.`);
45
- }
46
- };
47
- var $ZodEncodeError = class extends Error {
48
- constructor(name) {
49
- super(`Encountered unidirectional transform during encode: ${name}`);
50
- this.name = "ZodEncodeError";
51
- }
52
- };
53
- (_a$1 = globalThis).__zod_globalConfig ?? (_a$1.__zod_globalConfig = {});
54
- var globalConfig = globalThis.__zod_globalConfig;
55
- function config(newConfig) {
56
- if (newConfig) Object.assign(globalConfig, newConfig);
57
- return globalConfig;
58
- }
59
- //#endregion
60
- //#region ../../node_modules/.pnpm/zod@4.4.3/node_modules/zod/v4/core/util.js
1
+ //#region ../../node_modules/.pnpm/zod@4.6.5/node_modules/zod/v4/core/util.js
61
2
  function getEnumValues(entries) {
62
3
  const numericValues = Object.values(entries).filter((v) => typeof v === "number");
63
4
  return Object.entries(entries).filter(([k, _]) => numericValues.indexOf(+k) === -1).map(([_, v]) => v);
64
5
  }
6
+ function joinValues(array, separator = "|") {
7
+ return array.map((val) => stringifyPrimitive(val)).join(separator);
8
+ }
65
9
  function jsonStringifyReplacer(_, value) {
66
10
  if (typeof value === "bigint") return value.toString();
67
11
  return value;
68
12
  }
69
- function cached(getter) {
70
- return { get value() {
71
- {
72
- const value = getter();
73
- Object.defineProperty(this, "value", { value });
74
- return value;
13
+ var Cached = class {
14
+ constructor(getter) {
15
+ this._getter = getter;
16
+ this._value = void 0;
17
+ }
18
+ get value() {
19
+ const getter = this._getter;
20
+ if (getter !== void 0) {
21
+ this._value = getter();
22
+ this._getter = void 0;
75
23
  }
76
- throw new Error("cached value already set");
77
- } };
24
+ return this._value;
25
+ }
26
+ };
27
+ function cached(getter) {
28
+ return new Cached(getter);
78
29
  }
79
30
  function nullish(input) {
80
31
  return input === null || input === void 0;
@@ -87,28 +38,10 @@ function cleanRegex(source) {
87
38
  function floatSafeRemainder(val, step) {
88
39
  const ratio = val / step;
89
40
  const roundedRatio = Math.round(ratio);
90
- const tolerance = Number.EPSILON * Math.max(Math.abs(ratio), 1);
41
+ const tolerance = 4 * Number.EPSILON * Math.max(Math.abs(ratio), 1);
91
42
  if (Math.abs(ratio - roundedRatio) < tolerance) return 0;
92
43
  return ratio - roundedRatio;
93
44
  }
94
- var EVALUATING = /* @__PURE__*/ Symbol("evaluating");
95
- function defineLazy(object, key, getter) {
96
- let value = void 0;
97
- Object.defineProperty(object, key, {
98
- get() {
99
- if (value === EVALUATING) return;
100
- if (value === void 0) {
101
- value = EVALUATING;
102
- value = getter();
103
- }
104
- return value;
105
- },
106
- set(v) {
107
- Object.defineProperty(object, key, { value: v });
108
- },
109
- configurable: true
110
- });
111
- }
112
45
  function assignProp(target, prop, value) {
113
46
  Object.defineProperty(target, prop, {
114
47
  value,
@@ -117,6 +50,58 @@ function assignProp(target, prop, value) {
117
50
  configurable: true
118
51
  });
119
52
  }
53
+ /**
54
+ * Whichever object a def's `shape` currently answers from: the one the caller passed until the first read, the frozen copy after it.
55
+ *
56
+ * Its keys and descriptors read without invoking anything, which is what lets a discriminated union check its discriminator, and the cycle walk read a shape, without resolving a getter that references the schema being constructed. A def that answers `shape` from an accessor of its own has none.
57
+ */
58
+ function rawShape(def) {
59
+ const desc = Object.getOwnPropertyDescriptor(def, "shape");
60
+ return desc?.get ? desc.get.raw : desc?.value;
61
+ }
62
+ function sourceShape(schema) {
63
+ return rawShape(schema._zod.def) ?? schema._zod.def.shape;
64
+ }
65
+ function deferProp(target, key, getter) {
66
+ Object.defineProperty(target, key, {
67
+ get() {
68
+ const value = getter();
69
+ assignProp(this, key, value);
70
+ return value;
71
+ },
72
+ enumerable: true,
73
+ configurable: true
74
+ });
75
+ }
76
+ function putProp(target, key, value) {
77
+ if (key in target) assignProp(target, key, value);
78
+ else target[key] = value;
79
+ }
80
+ /**
81
+ * Copies `keys` of `source`'s shape onto `target`, each value passed through `wrap`.
82
+ *
83
+ * A key the source has resolved is copied through now, so the derived shape states it outright and nothing has to resolve it to learn what it holds. A key the source still defers stays deferred, and reads back through the source's own `shape`, so it resolves once and both shapes get that one schema.
84
+ */
85
+ function mirrorShape(target, source, keys, wrap) {
86
+ const raw = sourceShape(source);
87
+ for (const key of keys) {
88
+ const desc = Object.getOwnPropertyDescriptor(raw, key);
89
+ if (!desc.enumerable) continue;
90
+ if (desc.get) deferProp(target, key, () => {
91
+ const value = source._zod.def.shape[key];
92
+ return wrap ? wrap(value, key) : value;
93
+ });
94
+ else putProp(target, key, wrap ? wrap(desc.value, key) : desc.value);
95
+ }
96
+ }
97
+ function mirrorProps(target, source) {
98
+ for (const key of Reflect.ownKeys(source)) {
99
+ const desc = Object.getOwnPropertyDescriptor(source, key);
100
+ if (!desc.enumerable) continue;
101
+ if (desc.get) deferProp(target, key, () => source[key]);
102
+ else putProp(target, key, desc.value);
103
+ }
104
+ }
120
105
  function mergeDefs(...defs) {
121
106
  const mergedDescriptors = {};
122
107
  for (const def of defs) Object.assign(mergedDescriptors, Object.getOwnPropertyDescriptors(def));
@@ -187,51 +172,56 @@ function normalizeParams(_params) {
187
172
  };
188
173
  return params;
189
174
  }
175
+ function stringifyPrimitive(value) {
176
+ if (typeof value === "bigint") return value.toString() + "n";
177
+ if (typeof value === "string") return `"${value}"`;
178
+ return `${value}`;
179
+ }
190
180
  function optionalKeys(shape) {
191
181
  return Object.keys(shape).filter((k) => {
192
- return shape[k]._zod.optin === "optional" && shape[k]._zod.optout === "optional";
182
+ return shape[k]._zod.optin !== void 0 && shape[k]._zod.optout === "optional";
193
183
  });
194
184
  }
195
- var NUMBER_FORMAT_RANGES = {
185
+ var NUMBER_FORMAT_RANGES = /*@__PURE__*/ (() => ({
196
186
  safeint: [Number.MIN_SAFE_INTEGER, Number.MAX_SAFE_INTEGER],
197
187
  int32: [-2147483648, 2147483647],
198
188
  uint32: [0, 4294967295],
199
189
  float32: [-34028234663852886e22, 34028234663852886e22],
200
190
  float64: [-Number.MAX_VALUE, Number.MAX_VALUE]
191
+ }))();
192
+ var BIGINT_FORMAT_RANGES = {
193
+ int64: [/* @__PURE__*/ BigInt("-9223372036854775808"), /* @__PURE__*/ BigInt("9223372036854775807")],
194
+ uint64: [/* @__PURE__*/ BigInt(0), /* @__PURE__*/ BigInt("18446744073709551615")]
201
195
  };
202
196
  function pick(schema, mask) {
203
197
  const currDef = schema._zod.def;
204
198
  const checks = currDef.checks;
205
199
  if (checks && checks.length > 0) throw new Error(".pick() cannot be used on object schemas containing refinements");
206
- return clone(schema, mergeDefs(schema._zod.def, {
207
- get shape() {
208
- const newShape = {};
209
- for (const key in mask) {
210
- if (!(key in currDef.shape)) throw new Error(`Unrecognized key: "${key}"`);
211
- if (!mask[key]) continue;
212
- newShape[key] = currDef.shape[key];
213
- }
214
- assignProp(this, "shape", newShape);
215
- return newShape;
216
- },
200
+ const newShape = {};
201
+ mirrorShape(newShape, schema, maskedKeys(schema, mask));
202
+ return clone(schema, mergeDefs(currDef, {
203
+ shape: newShape,
217
204
  checks: []
218
205
  }));
219
206
  }
207
+ function maskedKeys(schema, mask) {
208
+ const raw = sourceShape(schema);
209
+ const keys = [];
210
+ for (const key of Reflect.ownKeys(mask)) {
211
+ if (!Object.getOwnPropertyDescriptor(raw, key)?.enumerable) throw new Error(`Unrecognized key: "${String(key)}"`);
212
+ if (mask[key]) keys.push(key);
213
+ }
214
+ return keys;
215
+ }
220
216
  function omit(schema, mask) {
221
217
  const currDef = schema._zod.def;
222
218
  const checks = currDef.checks;
223
219
  if (checks && checks.length > 0) throw new Error(".omit() cannot be used on object schemas containing refinements");
224
- return clone(schema, mergeDefs(schema._zod.def, {
225
- get shape() {
226
- const newShape = { ...schema._zod.def.shape };
227
- for (const key in mask) {
228
- if (!(key in currDef.shape)) throw new Error(`Unrecognized key: "${key}"`);
229
- if (!mask[key]) continue;
230
- delete newShape[key];
231
- }
232
- assignProp(this, "shape", newShape);
233
- return newShape;
234
- },
220
+ const omitted = new Set(maskedKeys(schema, mask));
221
+ const newShape = {};
222
+ mirrorShape(newShape, schema, Reflect.ownKeys(sourceShape(schema)).filter((key) => !omitted.has(key)));
223
+ return clone(schema, mergeDefs(currDef, {
224
+ shape: newShape,
235
225
  checks: []
236
226
  }));
237
227
  }
@@ -239,90 +229,57 @@ function extend(schema, shape) {
239
229
  if (!isPlainObject(shape)) throw new Error("Invalid input to extend: expected a plain object");
240
230
  const checks = schema._zod.def.checks;
241
231
  if (checks && checks.length > 0) {
242
- const existingShape = schema._zod.def.shape;
243
- 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.");
232
+ const existingShape = sourceShape(schema);
233
+ for (const key of Reflect.ownKeys(shape)) if (Object.getOwnPropertyDescriptor(existingShape, key) !== void 0) throw new Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.");
244
234
  }
245
- return clone(schema, mergeDefs(schema._zod.def, { get shape() {
246
- const _shape = {
247
- ...schema._zod.def.shape,
248
- ...shape
249
- };
250
- assignProp(this, "shape", _shape);
251
- return _shape;
252
- } }));
235
+ return clone(schema, mergeDefs(schema._zod.def, { shape: extended(schema, shape) }));
236
+ }
237
+ function extended(schema, shape) {
238
+ const newShape = {};
239
+ mirrorShape(newShape, schema, Reflect.ownKeys(sourceShape(schema)));
240
+ mirrorProps(newShape, shape);
241
+ return newShape;
253
242
  }
254
243
  function safeExtend(schema, shape) {
255
244
  if (!isPlainObject(shape)) throw new Error("Invalid input to safeExtend: expected a plain object");
256
- return clone(schema, mergeDefs(schema._zod.def, { get shape() {
257
- const _shape = {
258
- ...schema._zod.def.shape,
259
- ...shape
260
- };
261
- assignProp(this, "shape", _shape);
262
- return _shape;
263
- } }));
245
+ return clone(schema, mergeDefs(schema._zod.def, { shape: extended(schema, shape) }));
264
246
  }
265
247
  function merge(a, b) {
248
+ if (!b?._zod?.def) throw new Error("Invalid input to merge: expected an object schema. To merge a plain shape, use `.extend()`.");
266
249
  if (a._zod.def.checks?.length) throw new Error(".merge() cannot be used on object schemas containing refinements. Use .safeExtend() instead.");
250
+ const newShape = {};
251
+ mirrorShape(newShape, a, Reflect.ownKeys(sourceShape(a)));
252
+ mirrorShape(newShape, b, Reflect.ownKeys(sourceShape(b)));
267
253
  return clone(a, mergeDefs(a._zod.def, {
268
- get shape() {
269
- const _shape = {
270
- ...a._zod.def.shape,
271
- ...b._zod.def.shape
272
- };
273
- assignProp(this, "shape", _shape);
274
- return _shape;
275
- },
254
+ shape: newShape,
276
255
  get catchall() {
277
256
  return b._zod.def.catchall;
278
257
  },
279
258
  checks: b._zod.def.checks ?? []
280
259
  }));
281
260
  }
282
- function partial(Class, schema, mask) {
261
+ function partial(Class, schema, mask, name = "partial") {
283
262
  const checks = schema._zod.def.checks;
284
- if (checks && checks.length > 0) throw new Error(".partial() cannot be used on object schemas containing refinements");
263
+ if (checks && checks.length > 0) throw new Error(`.${name}() cannot be used on object schemas containing refinements`);
264
+ const selected = mask ? new Set(maskedKeys(schema, mask)) : void 0;
265
+ const newShape = {};
266
+ mirrorShape(newShape, schema, Reflect.ownKeys(sourceShape(schema)), Class && ((value, key) => selected && !selected.has(key) ? value : new Class({
267
+ type: "optional",
268
+ innerType: value
269
+ })));
285
270
  return clone(schema, mergeDefs(schema._zod.def, {
286
- get shape() {
287
- const oldShape = schema._zod.def.shape;
288
- const shape = { ...oldShape };
289
- if (mask) for (const key in mask) {
290
- if (!(key in oldShape)) throw new Error(`Unrecognized key: "${key}"`);
291
- if (!mask[key]) continue;
292
- shape[key] = Class ? new Class({
293
- type: "optional",
294
- innerType: oldShape[key]
295
- }) : oldShape[key];
296
- }
297
- else for (const key in oldShape) shape[key] = Class ? new Class({
298
- type: "optional",
299
- innerType: oldShape[key]
300
- }) : oldShape[key];
301
- assignProp(this, "shape", shape);
302
- return shape;
303
- },
271
+ shape: newShape,
304
272
  checks: []
305
273
  }));
306
274
  }
307
275
  function required(Class, schema, mask) {
308
- return clone(schema, mergeDefs(schema._zod.def, { get shape() {
309
- const oldShape = schema._zod.def.shape;
310
- const shape = { ...oldShape };
311
- if (mask) for (const key in mask) {
312
- if (!(key in shape)) throw new Error(`Unrecognized key: "${key}"`);
313
- if (!mask[key]) continue;
314
- shape[key] = new Class({
315
- type: "nonoptional",
316
- innerType: oldShape[key]
317
- });
318
- }
319
- else for (const key in oldShape) shape[key] = new Class({
320
- type: "nonoptional",
321
- innerType: oldShape[key]
322
- });
323
- assignProp(this, "shape", shape);
324
- return shape;
325
- } }));
276
+ const selected = mask ? new Set(maskedKeys(schema, mask)) : void 0;
277
+ const newShape = {};
278
+ mirrorShape(newShape, schema, Reflect.ownKeys(sourceShape(schema)), (value, key) => selected && !selected.has(key) ? value : new Class({
279
+ type: "nonoptional",
280
+ innerType: value
281
+ }));
282
+ return clone(schema, mergeDefs(schema._zod.def, { shape: newShape }));
326
283
  }
327
284
  function aborted(x, startIndex = 0) {
328
285
  if (x.aborted === true) return true;
@@ -345,19 +302,56 @@ function prefixIssues(path, issues) {
345
302
  function unwrapMessage(message) {
346
303
  return typeof message === "string" ? message : message?.message;
347
304
  }
305
+ function attachSchema(issues, start, inst) {
306
+ var _a;
307
+ for (let i = start; i < issues.length; i++) (_a = issues[i]).schema ?? (_a.schema = inst);
308
+ }
348
309
  function finalizeIssue(iss, ctx, config) {
349
- 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";
350
- const { inst: _inst, continue: _continue, input: _input, ...rest } = iss;
351
- rest.path ?? (rest.path = []);
352
- rest.message = message;
353
- if (ctx?.reportInput) rest.input = _input;
354
- return rest;
310
+ var _a;
311
+ const traits = iss.inst?._zod?.traits;
312
+ if (traits?.has("$ZodType")) if (traits.has("$ZodCheck")) (_a = iss).schema ?? (_a.schema = iss.inst);
313
+ else iss.schema = iss.inst;
314
+ const schemaError = iss.schema !== iss.inst ? iss.schema?._zod.def?.error : void 0;
315
+ const message = iss.message ? iss.message : unwrapMessage(iss.inst?._zod.def?.error?.(iss)) ?? unwrapMessage(schemaError?.(iss)) ?? unwrapMessage(ctx?.error?.(iss)) ?? unwrapMessage(config.customError?.(iss)) ?? unwrapMessage(config.localeError?.(iss)) ?? "Invalid input";
316
+ const full = {};
317
+ for (const k of Object.keys(iss)) {
318
+ if (k === "inst" || k === "schema" || k === "continue" || k === "input" || k === "__proto__") continue;
319
+ full[k] = iss[k];
320
+ }
321
+ full.path ?? (full.path = []);
322
+ full.message = message;
323
+ if (ctx?.reportInput) full.input = iss.input;
324
+ return full;
325
+ }
326
+ var highSurrogate = /[\uD800-\uDBFF]/;
327
+ function codePointLength(str) {
328
+ const units = str.length;
329
+ if (!highSurrogate.test(str)) return units;
330
+ let count = units;
331
+ for (let i = 0; i < units - 1; i++) if ((str.charCodeAt(i) & 64512) === 55296 && (str.charCodeAt(i + 1) & 64512) === 56320) {
332
+ count--;
333
+ i++;
334
+ }
335
+ return count;
355
336
  }
356
337
  function getLengthableOrigin(input) {
357
338
  if (Array.isArray(input)) return "array";
358
339
  if (typeof input === "string") return "string";
359
340
  return "unknown";
360
341
  }
342
+ function parsedType(data) {
343
+ const t = typeof data;
344
+ switch (t) {
345
+ case "number": return Number.isNaN(data) ? "nan" : "number";
346
+ case "object": {
347
+ if (data === null) return "null";
348
+ if (Array.isArray(data)) return "array";
349
+ const obj = data;
350
+ if (obj && Object.getPrototypeOf(obj) !== Object.prototype && "constructor" in obj && obj.constructor) return obj.constructor.name;
351
+ }
352
+ }
353
+ return t;
354
+ }
361
355
  function issue(...args) {
362
356
  const [iss, input, inst] = args;
363
357
  if (typeof iss === "string") return {
@@ -368,33 +362,337 @@ function issue(...args) {
368
362
  };
369
363
  return { ...iss };
370
364
  }
371
- //#endregion
372
- //#region ../../node_modules/.pnpm/zod@4.4.3/node_modules/zod/v4/core/errors.js
373
- var initializer$1 = (inst, def) => {
374
- inst.name = "$ZodError";
375
- Object.defineProperty(inst, "_zod", {
376
- value: inst._zod,
377
- enumerable: false
365
+ /**
366
+ * Installs a trait's members on its prototype. Each value builds that member for the instance on first read; the built value shadows the accessor as an own property, so a detached `const { parse } = schema` keeps working.
367
+ *
368
+ * Call this from a `proto` initializer, which runs once per prototype — never per instance.
369
+ */
370
+ function members(proto, table) {
371
+ for (const key in table) {
372
+ const desc = Object.getOwnPropertyDescriptor(table, key);
373
+ if (desc.get) Object.defineProperty(proto, key, {
374
+ ...desc,
375
+ enumerable: false
376
+ });
377
+ else defineBound(proto, key, desc.value);
378
+ }
379
+ }
380
+ /** Shadows a prototype member with an own value, so a getter that builds from the instance runs once. */
381
+ function own(inst, key, value, enumerable = true) {
382
+ Object.defineProperty(inst, key, {
383
+ configurable: true,
384
+ writable: true,
385
+ enumerable,
386
+ value
387
+ });
388
+ return value;
389
+ }
390
+ /** Like {@link own}, for a member that was never an own data property and has to stay out of `Object.keys`. */
391
+ function hide(inst, key, value) {
392
+ return own(inst, key, value, false);
393
+ }
394
+ /** Adds members a table derives from the instance: each builds on first read and shadows as own data, and assignment shadows the same way, as when these were own properties. */
395
+ function derived(computes, table) {
396
+ for (const key in computes) {
397
+ const compute = computes[key];
398
+ Object.defineProperty(table, key, {
399
+ configurable: true,
400
+ enumerable: true,
401
+ get() {
402
+ return own(this, key, compute(this));
403
+ },
404
+ set(value) {
405
+ own(this, key, value);
406
+ }
407
+ });
408
+ }
409
+ return table;
410
+ }
411
+ function defineBound(proto, key, fn) {
412
+ Object.defineProperty(proto, key, {
413
+ configurable: true,
414
+ get() {
415
+ return this == null ? fn : own(this, key, fn.bind(this));
416
+ },
417
+ set(value) {
418
+ own(this, key, value);
419
+ }
378
420
  });
379
- Object.defineProperty(inst, "issues", {
380
- value: def,
381
- enumerable: false
421
+ }
422
+ /** Returns the prototype to install on, or `undefined` if this group is already installed on it. */
423
+ function claim(inst, sentinel) {
424
+ const proto = Object.getPrototypeOf(inst);
425
+ return sentinel in proto ? void 0 : proto;
426
+ }
427
+ var installing;
428
+ var broke = false;
429
+ var breaker = {
430
+ configurable: true,
431
+ get() {
432
+ broke = true;
433
+ }
434
+ };
435
+ /**
436
+ * Installs a lazily-derived internal on the `_zod` prototype of `inst`'s
437
+ * constructor, computed from the internals object itself and cached there on
438
+ * first read. One accessor per constructor rather than one per instance.
439
+ */
440
+ function defineLazyInternal(inst, key, compute) {
441
+ const proto = Object.getPrototypeOf(inst._zod);
442
+ if (key in proto && installing !== inst._zod) {
443
+ installing = void 0;
444
+ return;
445
+ }
446
+ installing = inst._zod;
447
+ Object.defineProperty(proto, key, {
448
+ configurable: true,
449
+ get() {
450
+ Object.defineProperty(this, key, breaker);
451
+ const outer = broke;
452
+ broke = false;
453
+ try {
454
+ const value = compute(this);
455
+ if (broke) delete this[key];
456
+ else Object.defineProperty(this, key, {
457
+ configurable: true,
458
+ writable: true,
459
+ value
460
+ });
461
+ broke = broke || outer;
462
+ return value;
463
+ } catch (err) {
464
+ delete this[key];
465
+ broke = broke || outer;
466
+ throw err;
467
+ }
468
+ },
469
+ set(value) {
470
+ Object.defineProperty(this, key, {
471
+ configurable: true,
472
+ writable: true,
473
+ value
474
+ });
475
+ }
382
476
  });
383
- inst.message = JSON.stringify(def, jsonStringifyReplacer, 2);
384
- Object.defineProperty(inst, "toString", {
385
- value: () => inst.message,
386
- enumerable: false
477
+ }
478
+ /**
479
+ * Installs `key` on `inst`'s prototype, computed by `make` on first read and cached there as an own
480
+ * data property. One accessor per constructor rather than one per instance, because an own accessor
481
+ * puts every instance after the first into v8 dictionary mode. The key doubles as the sentinel.
482
+ */
483
+ function installLazyProp(inst, key, make, enumerable) {
484
+ const proto = claim(inst, key);
485
+ if (!proto) return;
486
+ Object.defineProperty(proto, key, {
487
+ configurable: true,
488
+ get() {
489
+ const desc = {
490
+ configurable: true,
491
+ writable: true,
492
+ enumerable,
493
+ value: void 0
494
+ };
495
+ Object.defineProperty(this, key, desc);
496
+ desc.value = make(this);
497
+ Object.defineProperty(this, key, desc);
498
+ return desc.value;
499
+ },
500
+ set(value) {
501
+ Object.defineProperty(this, key, {
502
+ configurable: true,
503
+ writable: true,
504
+ enumerable,
505
+ value
506
+ });
507
+ }
387
508
  });
509
+ }
510
+ /** Marks the thunk `_catch` synthesises for a constant catch value. `Function.length` cannot tell that thunk from a user callback — rest and defaulted parameters both report arity 0 — and a user callback reads `ctx.error`, whose issues only finalize correctly against the caller's per-parse error map. Provenance can say what arity cannot. A plain string key rather than `Symbol.for`, whose call at module scope no bundler can prove pure — the same shape that anchored `urlCanParse` into every build. */
511
+ var CONSTANT_CATCH = "~constantCatch";
512
+ /** Wraps a constant catch value in a thunk tagged with {@link CONSTANT_CATCH}. */
513
+ function constantCatch(value) {
514
+ const fn = () => value;
515
+ fn[CONSTANT_CATCH] = true;
516
+ return fn;
517
+ }
518
+ //#endregion
519
+ //#region ../../node_modules/.pnpm/zod@4.6.5/node_modules/zod/v4/core/core.js
520
+ var _a$1;
521
+ var _zodDesc = {
522
+ value: void 0,
523
+ enumerable: false
524
+ };
525
+ var _E = "captureStackTrace" in Error ? Error : null;
526
+ function newError(Definition) {
527
+ const E = _E;
528
+ if (E) {
529
+ const saved = E.stackTraceLimit;
530
+ if (typeof saved === "number") {
531
+ try {
532
+ E.stackTraceLimit = 0;
533
+ } catch {
534
+ _E = null;
535
+ return new Definition();
536
+ }
537
+ try {
538
+ return new Definition();
539
+ } finally {
540
+ E.stackTraceLimit = saved;
541
+ }
542
+ }
543
+ }
544
+ return new Definition();
545
+ }
546
+ function $constructor(name, initializer, proto, params) {
547
+ const zodProto = {};
548
+ function Internals(def) {
549
+ this.def = def;
550
+ this.constr = _;
551
+ this.traits = /* @__PURE__ */ new Set();
552
+ }
553
+ Internals.prototype = zodProto;
554
+ const protoMembers = proto;
555
+ const initialized = protoMembers && /* @__PURE__ */ new WeakSet();
556
+ function init(inst, def) {
557
+ if (!inst._zod) {
558
+ _zodDesc.value = new Internals(def);
559
+ try {
560
+ Object.defineProperty(inst, "_zod", _zodDesc);
561
+ } finally {
562
+ _zodDesc.value = void 0;
563
+ }
564
+ } else if (inst._zod.traits.has(name)) return;
565
+ inst._zod.traits.add(name);
566
+ initializer(inst, def);
567
+ if (initialized) {
568
+ const own = Object.getPrototypeOf(inst);
569
+ const ctorProto = inst._zod.constr.prototype;
570
+ let up = own;
571
+ while (up && up !== ctorProto) up = Object.getPrototypeOf(up);
572
+ const target = up ?? own;
573
+ if (!initialized.has(target)) {
574
+ initialized.add(target);
575
+ members(target, protoMembers);
576
+ }
577
+ }
578
+ const proto = _.prototype;
579
+ for (const k in proto) {
580
+ if (!Object.prototype.hasOwnProperty.call(proto, k)) continue;
581
+ if (!(k in inst)) inst[k] = proto[k].bind(inst);
582
+ }
583
+ }
584
+ const Parent = params?.Parent ?? Object;
585
+ class Definition extends Parent {}
586
+ Object.defineProperty(Definition, "name", { value: name });
587
+ function _(def) {
588
+ const inst = params?.Parent ? newError(Definition) : this;
589
+ init(inst, def);
590
+ const deferred = inst._zod.deferred;
591
+ if (deferred) {
592
+ for (const fn of deferred) fn();
593
+ inst._zod.deferred = void 0;
594
+ }
595
+ const pp = globalThis.__zod_globalConfig?.postProcessor;
596
+ if (pp) pp(inst);
597
+ return inst;
598
+ }
599
+ Object.defineProperty(_, "init", { value: init });
600
+ Object.defineProperty(_, Symbol.hasInstance, { value: (inst) => {
601
+ if (params?.Parent && inst instanceof params.Parent) return true;
602
+ return inst?._zod?.traits?.has(name);
603
+ } });
604
+ Object.defineProperty(_, "name", { value: name });
605
+ return _;
606
+ }
607
+ var $ZodAsyncError = class extends Error {
608
+ constructor() {
609
+ super(`Encountered Promise during synchronous parse. Use .parseAsync() instead.`);
610
+ }
611
+ };
612
+ var $ZodEncodeError = class extends Error {
613
+ constructor(name) {
614
+ super(`Encountered unidirectional transform during encode: ${name}`);
615
+ this.name = "ZodEncodeError";
616
+ }
617
+ };
618
+ (_a$1 = globalThis).__zod_globalConfig ?? (_a$1.__zod_globalConfig = {});
619
+ var globalConfig = globalThis.__zod_globalConfig;
620
+ function config(newConfig) {
621
+ if (newConfig) Object.assign(globalConfig, newConfig);
622
+ return globalConfig;
623
+ }
624
+ //#endregion
625
+ //#region ../../node_modules/.pnpm/zod@4.6.5/node_modules/zod/v4/core/errors.js
626
+ function _getMessage() {
627
+ const internals = this._zod;
628
+ internals.message ?? (internals.message = JSON.stringify(internals.def, jsonStringifyReplacer, 2));
629
+ return internals.message;
630
+ }
631
+ function _setMessage(value) {
632
+ this._zod.message = value;
633
+ }
634
+ var _messageDesc = {
635
+ get: _getMessage,
636
+ set: _setMessage,
637
+ enumerable: true,
638
+ configurable: true
639
+ };
640
+ var _issuesDesc = {
641
+ value: void 0,
642
+ enumerable: false
643
+ };
644
+ var _installedToString = /* @__PURE__ */ new WeakSet([Object.prototype, Error.prototype]);
645
+ var initializer$1 = (inst, def) => {
646
+ inst.name = "$ZodError";
647
+ _issuesDesc.value = def;
648
+ Object.defineProperty(inst, "issues", _issuesDesc);
649
+ _issuesDesc.value = void 0;
650
+ Object.defineProperty(inst, "message", _messageDesc);
651
+ const proto = Object.getPrototypeOf(inst);
652
+ if (!_installedToString.has(proto)) {
653
+ _installedToString.add(proto);
654
+ Object.defineProperty(proto, "toString", {
655
+ configurable: true,
656
+ enumerable: false,
657
+ get() {
658
+ const value = () => this.message;
659
+ Object.defineProperty(this, "toString", {
660
+ value,
661
+ configurable: true,
662
+ writable: true
663
+ });
664
+ return value;
665
+ },
666
+ set(value) {
667
+ Object.defineProperty(this, "toString", {
668
+ value,
669
+ configurable: true,
670
+ writable: true
671
+ });
672
+ }
673
+ });
674
+ }
388
675
  };
389
676
  var $ZodError = $constructor("$ZodError", initializer$1);
390
- var $ZodRealError = $constructor("$ZodError", initializer$1, { Parent: Error });
677
+ $constructor("$ZodError", initializer$1, void 0, { Parent: Error });
678
+ /** Get-or-create `obj[key]` as an own data property. A path segment naming an inherited member
679
+ * ("toString", "constructor") would otherwise read through to the prototype, and assigning
680
+ * "__proto__" would hit the setter instead of creating a key. */
681
+ function node(obj, key, make) {
682
+ if (!Object.prototype.hasOwnProperty.call(obj, key)) if (key === "__proto__") Object.defineProperty(obj, key, {
683
+ value: make(),
684
+ writable: true,
685
+ enumerable: true,
686
+ configurable: true
687
+ });
688
+ else obj[key] = make();
689
+ return obj[key];
690
+ }
391
691
  function flattenError(error, mapper = (issue) => issue.message) {
392
692
  const fieldErrors = {};
393
693
  const formErrors = [];
394
- for (const sub of error.issues) if (sub.path.length > 0) {
395
- fieldErrors[sub.path[0]] = fieldErrors[sub.path[0]] || [];
396
- fieldErrors[sub.path[0]].push(mapper(sub));
397
- } else formErrors.push(mapper(sub));
694
+ for (const sub of error.issues) if (sub.path.length > 0) node(fieldErrors, sub.path[0], () => []).push(mapper(sub));
695
+ else formErrors.push(mapper(sub));
398
696
  return {
399
697
  formErrors,
400
698
  fieldErrors
@@ -414,12 +712,21 @@ function formatError(error, mapper = (issue) => issue.message) {
414
712
  let i = 0;
415
713
  while (i < fullpath.length) {
416
714
  const el = fullpath[i];
417
- if (!(i === fullpath.length - 1)) curr[el] = curr[el] || { _errors: [] };
418
- else {
419
- curr[el] = curr[el] || { _errors: [] };
420
- curr[el]._errors.push(mapper(issue));
715
+ const terminal = i === fullpath.length - 1;
716
+ if (el === "_errors") {
717
+ if (terminal) curr._errors.push(mapper(issue));
718
+ i++;
719
+ continue;
421
720
  }
422
- curr = curr[el];
721
+ if (!Object.prototype.hasOwnProperty.call(curr, el)) Object.defineProperty(curr, el, {
722
+ value: { _errors: [] },
723
+ enumerable: true,
724
+ writable: true,
725
+ configurable: true
726
+ });
727
+ const node = curr[el];
728
+ if (terminal) node._errors.push(mapper(issue));
729
+ curr = node;
423
730
  i++;
424
731
  }
425
732
  }
@@ -429,40 +736,52 @@ function formatError(error, mapper = (issue) => issue.message) {
429
736
  return fieldErrors;
430
737
  }
431
738
  //#endregion
432
- //#region ../../node_modules/.pnpm/zod@4.4.3/node_modules/zod/v4/core/parse.js
433
- var _parse = (_Err) => (schema, value, _ctx, _params) => {
434
- const ctx = _ctx ? {
435
- ..._ctx,
436
- async: false
437
- } : { async: false };
438
- const result = schema._zod.run({
439
- value,
440
- issues: []
441
- }, ctx);
442
- if (result instanceof Promise) throw new $ZodAsyncError();
443
- if (result.issues.length) {
444
- const e = new (_params?.Err ?? _Err)(result.issues.map((iss) => finalizeIssue(iss, ctx, config())));
445
- captureStackTrace(e, _params?.callee);
446
- throw e;
447
- }
448
- return result.value;
739
+ //#region ../../node_modules/.pnpm/zod@4.6.5/node_modules/zod/v4/core/parse.js
740
+ function finalizeParams(callee, params) {
741
+ return {
742
+ callee: params?.callee ?? callee,
743
+ Err: params?.Err
744
+ };
745
+ }
746
+ var _parse = (_Err) => {
747
+ const fn = (schema, value, _ctx, _params) => {
748
+ const ctx = _ctx ? {
749
+ ..._ctx,
750
+ async: false
751
+ } : { async: false };
752
+ const result = schema._zod.run({
753
+ value,
754
+ issues: []
755
+ }, ctx);
756
+ if (result instanceof Promise) throw new $ZodAsyncError();
757
+ if (result.issues.length) {
758
+ const e = new (_params?.Err ?? _Err)(result.issues.map((iss) => finalizeIssue(iss, ctx, config())));
759
+ captureStackTrace(e, _params?.callee ?? fn);
760
+ throw e;
761
+ }
762
+ return result.value;
763
+ };
764
+ return fn;
449
765
  };
450
- var _parseAsync = (_Err) => async (schema, value, _ctx, params) => {
451
- const ctx = _ctx ? {
452
- ..._ctx,
453
- async: true
454
- } : { async: true };
455
- let result = schema._zod.run({
456
- value,
457
- issues: []
458
- }, ctx);
459
- if (result instanceof Promise) result = await result;
460
- if (result.issues.length) {
461
- const e = new (params?.Err ?? _Err)(result.issues.map((iss) => finalizeIssue(iss, ctx, config())));
462
- captureStackTrace(e, params?.callee);
463
- throw e;
464
- }
465
- return result.value;
766
+ var _parseAsync = (_Err) => {
767
+ const fn = async (schema, value, _ctx, params) => {
768
+ const ctx = _ctx ? {
769
+ ..._ctx,
770
+ async: true
771
+ } : { async: true };
772
+ let result = schema._zod.run({
773
+ value,
774
+ issues: []
775
+ }, ctx);
776
+ if (result instanceof Promise) result = await result;
777
+ if (result.issues.length) {
778
+ const e = new (params?.Err ?? _Err)(result.issues.map((iss) => finalizeIssue(iss, ctx, config())));
779
+ captureStackTrace(e, params?.callee ?? fn);
780
+ throw e;
781
+ }
782
+ return result.value;
783
+ };
784
+ return fn;
466
785
  };
467
786
  var _safeParse = (_Err) => (schema, value, _ctx) => {
468
787
  const ctx = _ctx ? {
@@ -474,15 +793,30 @@ var _safeParse = (_Err) => (schema, value, _ctx) => {
474
793
  issues: []
475
794
  }, ctx);
476
795
  if (result instanceof Promise) throw new $ZodAsyncError();
477
- return result.issues.length ? {
478
- success: false,
479
- error: new (_Err ?? $ZodError)(result.issues.map((iss) => finalizeIssue(iss, ctx, config())))
480
- } : {
796
+ return result.issues.length ? failure(_Err, result.issues, ctx) : {
481
797
  success: true,
482
798
  data: result.value
483
799
  };
484
- };
485
- var safeParse$1 = /* @__PURE__*/ _safeParse($ZodRealError);
800
+ };
801
+ function failure(Err, issues, ctx) {
802
+ let error;
803
+ return {
804
+ success: false,
805
+ get error() {
806
+ if (!error) {
807
+ error = new Err(issues.map((iss) => finalizeIssue(iss, ctx, config())));
808
+ issues = void 0;
809
+ ctx = void 0;
810
+ }
811
+ return error;
812
+ },
813
+ set error(e) {
814
+ error = e;
815
+ issues = void 0;
816
+ ctx = void 0;
817
+ }
818
+ };
819
+ }
486
820
  var _safeParseAsync = (_Err) => async (schema, value, _ctx) => {
487
821
  const ctx = _ctx ? {
488
822
  ..._ctx,
@@ -493,34 +827,94 @@ var _safeParseAsync = (_Err) => async (schema, value, _ctx) => {
493
827
  issues: []
494
828
  }, ctx);
495
829
  if (result instanceof Promise) result = await result;
496
- return result.issues.length ? {
497
- success: false,
498
- error: new _Err(result.issues.map((iss) => finalizeIssue(iss, ctx, config())))
499
- } : {
830
+ return result.issues.length ? failure(_Err, result.issues, ctx) : {
500
831
  success: true,
501
832
  data: result.value
502
833
  };
503
834
  };
504
- var safeParseAsync$1 = /* @__PURE__*/ _safeParseAsync($ZodRealError);
505
- var _encode = (_Err) => (schema, value, _ctx) => {
835
+ var COMPILE_INVALID = /* @__PURE__ */ Symbol.for("zod.compile.invalid");
836
+ var COMPILE_FALLBACK = /* @__PURE__ */ Symbol.for("zod.compile.fallback");
837
+ var validate = ((schema, value, _ctx) => {
838
+ const validator = schema._zod.bag.validator;
839
+ if (validator !== void 0) {
840
+ if (validator(value) !== COMPILE_INVALID) return true;
841
+ if (validator.definite === true && _ctx === void 0) return false;
842
+ }
843
+ return validateFallback(schema, value, _ctx);
844
+ });
845
+ function validateFallback(schema, value, _ctx) {
506
846
  const ctx = _ctx ? {
507
847
  ..._ctx,
508
- direction: "backward"
509
- } : { direction: "backward" };
510
- return _parse(_Err)(schema, value, ctx);
511
- };
512
- var _decode = (_Err) => (schema, value, _ctx) => {
513
- return _parse(_Err)(schema, value, _ctx);
514
- };
515
- var _encodeAsync = (_Err) => async (schema, value, _ctx) => {
848
+ async: false,
849
+ abortEarly: true
850
+ } : {
851
+ async: false,
852
+ abortEarly: true
853
+ };
854
+ const fallbackRun = schema._zod.bag.fallbackRun;
855
+ let result;
856
+ if (fallbackRun) {
857
+ ctx[COMPILE_FALLBACK] = true;
858
+ result = fallbackRun({
859
+ value,
860
+ issues: []
861
+ }, ctx);
862
+ } else result = schema._zod.run({
863
+ value,
864
+ issues: []
865
+ }, ctx);
866
+ if (result instanceof Promise) throw new $ZodAsyncError();
867
+ return result.issues.length === 0;
868
+ }
869
+ var validateAsync$1 = async (schema, value, _ctx) => {
516
870
  const ctx = _ctx ? {
517
871
  ..._ctx,
518
- direction: "backward"
519
- } : { direction: "backward" };
520
- return _parseAsync(_Err)(schema, value, ctx);
872
+ async: true,
873
+ abortEarly: true
874
+ } : {
875
+ async: true,
876
+ abortEarly: true
877
+ };
878
+ let result = schema._zod.run({
879
+ value,
880
+ issues: []
881
+ }, ctx);
882
+ if (result instanceof Promise) result = await result;
883
+ return result.issues.length === 0;
884
+ };
885
+ var _encode = (_Err) => {
886
+ const parse = _parse(_Err);
887
+ const fn = (schema, value, _ctx, _params) => {
888
+ return parse(schema, value, _ctx ? {
889
+ ..._ctx,
890
+ direction: "backward"
891
+ } : { direction: "backward" }, finalizeParams(fn, _params));
892
+ };
893
+ return fn;
894
+ };
895
+ var _decode = (_Err) => {
896
+ const parse = _parse(_Err);
897
+ const fn = (schema, value, _ctx, _params) => {
898
+ return parse(schema, value, _ctx, finalizeParams(fn, _params));
899
+ };
900
+ return fn;
521
901
  };
522
- var _decodeAsync = (_Err) => async (schema, value, _ctx) => {
523
- return _parseAsync(_Err)(schema, value, _ctx);
902
+ var _encodeAsync = (_Err) => {
903
+ const parseAsync = _parseAsync(_Err);
904
+ const fn = async (schema, value, _ctx, _params) => {
905
+ return await parseAsync(schema, value, _ctx ? {
906
+ ..._ctx,
907
+ direction: "backward"
908
+ } : { direction: "backward" }, finalizeParams(fn, _params));
909
+ };
910
+ return fn;
911
+ };
912
+ var _decodeAsync = (_Err) => {
913
+ const parseAsync = _parseAsync(_Err);
914
+ const fn = async (schema, value, _ctx, _params) => {
915
+ return await parseAsync(schema, value, _ctx, finalizeParams(fn, _params));
916
+ };
917
+ return fn;
524
918
  };
525
919
  var _safeEncode = (_Err) => (schema, value, _ctx) => {
526
920
  const ctx = _ctx ? {
@@ -543,7 +937,7 @@ var _safeDecodeAsync = (_Err) => async (schema, value, _ctx) => {
543
937
  return _safeParseAsync(_Err)(schema, value, _ctx);
544
938
  };
545
939
  //#endregion
546
- //#region ../../node_modules/.pnpm/zod@4.4.3/node_modules/zod/v4/core/regexes.js
940
+ //#region ../../node_modules/.pnpm/zod@4.6.5/node_modules/zod/v4/core/regexes.js
547
941
  /**
548
942
  * @deprecated CUID v1 is deprecated by its authors due to information leakage
549
943
  * (timestamps embedded in the id). Use {@link cuid2} instead.
@@ -551,12 +945,15 @@ var _safeDecodeAsync = (_Err) => async (schema, value, _ctx) => {
551
945
  */
552
946
  var cuid = /^[cC][0-9a-z]{6,}$/;
553
947
  var cuid2 = /^[0-9a-z]+$/;
554
- var ulid = /^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/;
948
+ var ulid = /^[0-7][0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{25}$/;
555
949
  var xid = /^[0-9a-vA-V]{20}$/;
556
950
  var ksuid = /^[A-Za-z0-9]{27}$/;
557
951
  var nanoid = /^[a-zA-Z0-9_-]{21}$/;
952
+ function nanoidOfLength(length) {
953
+ return new RegExp(`^[a-zA-Z0-9_-]{${length}}$`);
954
+ }
558
955
  /** ISO 8601-1 duration regex. Does not support the 8601-2 extensions like negative durations or fractional/negative components. */
559
- var duration$1 = /^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/;
956
+ var duration = /^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/;
560
957
  /** A regex for any UUID-like identifier: 8-4-4-4-12 hex pattern */
561
958
  var 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})$/;
562
959
  /** Returns a regex for validating an RFC 9562/4122 UUID.
@@ -567,54 +964,64 @@ var uuid$1 = (version) => {
567
964
  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})$`);
568
965
  };
569
966
  /** Practical email validation */
570
- var email = /^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/;
571
- var _emoji$1 = `^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$`;
967
+ var email = /^(?:[A-Za-z0-9_'+\-]+\.)*[A-Za-z0-9_'+\-]*[A-Za-z0-9_+-]@(?:[A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/;
968
+ var _emoji$1 = `^(?=[\\s\\S]*[\\p{Extended_Pictographic}\\p{Regional_Indicator}\\u20E3])[\\p{Extended_Pictographic}\\p{Emoji_Component}]+$`;
572
969
  function emoji() {
573
970
  return new RegExp(_emoji$1, "u");
574
971
  }
575
972
  var 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])$/;
576
973
  var 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}|:))$/;
577
974
  var 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])$/;
578
- var 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])$/;
975
+ var cidrv6 = /^(([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}|:))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/;
579
976
  var base64 = /^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/;
580
- var base64url = /^[A-Za-z0-9_-]*$/;
581
- var domain = /^([a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?\.)+[a-zA-Z]{2,}$/;
977
+ var base64url = /^(?:[A-Za-z0-9_-]{4})*(?:[A-Za-z0-9_-]{2,3})?$/;
978
+ var domain = /^(?=.{1,253}$)([a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?\.)+[a-zA-Z]{2,63}$/;
582
979
  var httpProtocol = /^https?$/;
583
980
  var e164 = /^\+[1-9]\d{6,14}$/;
584
981
  var 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])))`;
585
- var date$1 = /*@__PURE__*/ new RegExp(`^${dateSource}$`);
982
+ /** Anchors a pattern source. The interpolation lives here rather than at the call site because
983
+ * esbuild will not drop a `@__PURE__` call whose own argument interpolates a variable, but it
984
+ * will drop `anchor(dateSource)`. Keeping it inline pinned `date` into every bundle. */
985
+ function anchor(source) {
986
+ return new RegExp(`^${source}$`);
987
+ }
988
+ var date = /*@__PURE__*/ anchor(dateSource);
586
989
  function timeSource(args) {
587
990
  const hhmm = `(?:[01]\\d|2[0-3]):[0-5]\\d`;
588
- 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+)?)?`;
991
+ return typeof args.precision === "number" ? args.precision === -1 ? `${hhmm}` : args.precision === 0 ? `${hhmm}:[0-5]\\d` : `${hhmm}:[0-5]\\d\\.\\d{${args.precision}}` : args.seconds ? `${hhmm}:[0-5]\\d(?:\\.\\d+)?` : `${hhmm}(?::[0-5]\\d(?:\\.\\d+)?)?`;
589
992
  }
590
- function time$1(args) {
993
+ function time(args) {
591
994
  return new RegExp(`^${timeSource(args)}$`);
592
995
  }
593
- function datetime$1(args) {
594
- const time = timeSource({ precision: args.precision });
996
+ function datetime(args) {
595
997
  const opts = ["Z"];
596
- if (args.local) opts.push("");
597
998
  if (args.offset) opts.push(`([+-](?:[01]\\d|2[0-3]):[0-5]\\d)`);
598
- const timeRegex = `${time}(?:${opts.join("|")})`;
999
+ const qualified = `${timeSource({
1000
+ precision: args.precision,
1001
+ seconds: true
1002
+ })}(?:${opts.join("|")})`;
1003
+ const timeRegex = args.local ? `${qualified}|${timeSource({ precision: args.precision })}` : qualified;
599
1004
  return new RegExp(`^${dateSource}T(?:${timeRegex})$`);
600
1005
  }
601
- var string$1 = (params) => {
602
- const regex = params ? `[\\s\\S]{${params?.minimum ?? 0},${params?.maximum ?? ""}}` : `[\\s\\S]*`;
603
- return new RegExp(`^${regex}$`);
604
- };
1006
+ var anyString = /^[\s\S]{0,}$/;
605
1007
  var integer = /^-?\d+$/;
606
1008
  var number$1 = /^-?\d+(?:\.\d+)?$/;
607
1009
  var boolean$1 = /^(?:true|false)$/i;
608
1010
  var lowercase = /^[^A-Z]*$/;
609
1011
  var uppercase = /^[^a-z]*$/;
610
1012
  //#endregion
611
- //#region ../../node_modules/.pnpm/zod@4.4.3/node_modules/zod/v4/core/checks.js
1013
+ //#region ../../node_modules/.pnpm/zod@4.6.5/node_modules/zod/v4/core/checks.js
612
1014
  var $ZodCheck = /*@__PURE__*/ $constructor("$ZodCheck", (inst, def) => {
613
1015
  var _a;
614
1016
  inst._zod ?? (inst._zod = {});
615
1017
  inst._zod.def = def;
616
1018
  (_a = inst._zod).onattach ?? (_a.onattach = []);
617
1019
  });
1020
+ /** Default `when` for length-based checks: run only on non-nullish values with a `length`. */
1021
+ var _whenHasLength = (payload) => {
1022
+ const val = payload.value;
1023
+ return !nullish(val) && val.length !== void 0;
1024
+ };
618
1025
  var numericOriginMap = {
619
1026
  number: "number",
620
1027
  bigint: "bigint",
@@ -623,16 +1030,10 @@ var numericOriginMap = {
623
1030
  var $ZodCheckLessThan = /*@__PURE__*/ $constructor("$ZodCheckLessThan", (inst, def) => {
624
1031
  $ZodCheck.init(inst, def);
625
1032
  const origin = numericOriginMap[typeof def.value];
626
- inst._zod.onattach.push((inst) => {
627
- const bag = inst._zod.bag;
628
- const curr = (def.inclusive ? bag.maximum : bag.exclusiveMaximum) ?? Number.POSITIVE_INFINITY;
629
- if (def.value < curr) if (def.inclusive) bag.maximum = def.value;
630
- else bag.exclusiveMaximum = def.value;
631
- });
632
1033
  inst._zod.check = (payload) => {
633
1034
  if (def.inclusive ? payload.value <= def.value : payload.value < def.value) return;
634
1035
  payload.issues.push({
635
- origin,
1036
+ origin: numericOriginMap[typeof payload.value] ?? origin,
636
1037
  code: "too_big",
637
1038
  maximum: typeof def.value === "object" ? def.value.getTime() : def.value,
638
1039
  input: payload.value,
@@ -645,16 +1046,10 @@ var $ZodCheckLessThan = /*@__PURE__*/ $constructor("$ZodCheckLessThan", (inst, d
645
1046
  var $ZodCheckGreaterThan = /*@__PURE__*/ $constructor("$ZodCheckGreaterThan", (inst, def) => {
646
1047
  $ZodCheck.init(inst, def);
647
1048
  const origin = numericOriginMap[typeof def.value];
648
- inst._zod.onattach.push((inst) => {
649
- const bag = inst._zod.bag;
650
- const curr = (def.inclusive ? bag.minimum : bag.exclusiveMinimum) ?? Number.NEGATIVE_INFINITY;
651
- if (def.value > curr) if (def.inclusive) bag.minimum = def.value;
652
- else bag.exclusiveMinimum = def.value;
653
- });
654
1049
  inst._zod.check = (payload) => {
655
1050
  if (def.inclusive ? payload.value >= def.value : payload.value > def.value) return;
656
1051
  payload.issues.push({
657
- origin,
1052
+ origin: numericOriginMap[typeof payload.value] ?? origin,
658
1053
  code: "too_small",
659
1054
  minimum: typeof def.value === "object" ? def.value.getTime() : def.value,
660
1055
  input: payload.value,
@@ -666,13 +1061,9 @@ var $ZodCheckGreaterThan = /*@__PURE__*/ $constructor("$ZodCheckGreaterThan", (i
666
1061
  });
667
1062
  var $ZodCheckMultipleOf = /*@__PURE__*/ $constructor("$ZodCheckMultipleOf", (inst, def) => {
668
1063
  $ZodCheck.init(inst, def);
669
- inst._zod.onattach.push((inst) => {
670
- var _a;
671
- (_a = inst._zod.bag).multipleOf ?? (_a.multipleOf = def.value);
672
- });
673
1064
  inst._zod.check = (payload) => {
674
1065
  if (typeof payload.value !== typeof def.value) throw new Error("Cannot mix number and bigint in multiple_of check.");
675
- if (typeof payload.value === "bigint" ? payload.value % def.value === BigInt(0) : floatSafeRemainder(payload.value, def.value) === 0) return;
1066
+ if (typeof payload.value === "bigint" ? def.value !== BigInt(0) && payload.value % def.value === BigInt(0) : floatSafeRemainder(payload.value, def.value) === 0) return;
676
1067
  payload.issues.push({
677
1068
  origin: typeof payload.value,
678
1069
  code: "not_multiple_of",
@@ -689,13 +1080,6 @@ var $ZodCheckNumberFormat = /*@__PURE__*/ $constructor("$ZodCheckNumberFormat",
689
1080
  const isInt = def.format?.includes("int");
690
1081
  const origin = isInt ? "int" : "number";
691
1082
  const [minimum, maximum] = NUMBER_FORMAT_RANGES[def.format];
692
- inst._zod.onattach.push((inst) => {
693
- const bag = inst._zod.bag;
694
- bag.format = def.format;
695
- bag.minimum = minimum;
696
- bag.maximum = maximum;
697
- if (isInt) bag.pattern = integer;
698
- });
699
1083
  inst._zod.check = (payload) => {
700
1084
  const input = payload.value;
701
1085
  if (isInt) {
@@ -757,17 +1141,11 @@ var $ZodCheckNumberFormat = /*@__PURE__*/ $constructor("$ZodCheckNumberFormat",
757
1141
  var $ZodCheckMaxLength = /*@__PURE__*/ $constructor("$ZodCheckMaxLength", (inst, def) => {
758
1142
  var _a;
759
1143
  $ZodCheck.init(inst, def);
760
- (_a = inst._zod.def).when ?? (_a.when = (payload) => {
761
- const val = payload.value;
762
- return !nullish(val) && val.length !== void 0;
763
- });
764
- inst._zod.onattach.push((inst) => {
765
- const curr = inst._zod.bag.maximum ?? Number.POSITIVE_INFINITY;
766
- if (def.maximum < curr) inst._zod.bag.maximum = def.maximum;
767
- });
1144
+ (_a = inst._zod.def).when ?? (_a.when = _whenHasLength);
768
1145
  inst._zod.check = (payload) => {
769
1146
  const input = payload.value;
770
- if (input.length <= def.maximum) return;
1147
+ const units = input.length;
1148
+ if ((typeof input === "string" && units > def.maximum ? codePointLength(input) : units) <= def.maximum) return;
771
1149
  const origin = getLengthableOrigin(input);
772
1150
  payload.issues.push({
773
1151
  origin,
@@ -783,17 +1161,11 @@ var $ZodCheckMaxLength = /*@__PURE__*/ $constructor("$ZodCheckMaxLength", (inst,
783
1161
  var $ZodCheckMinLength = /*@__PURE__*/ $constructor("$ZodCheckMinLength", (inst, def) => {
784
1162
  var _a;
785
1163
  $ZodCheck.init(inst, def);
786
- (_a = inst._zod.def).when ?? (_a.when = (payload) => {
787
- const val = payload.value;
788
- return !nullish(val) && val.length !== void 0;
789
- });
790
- inst._zod.onattach.push((inst) => {
791
- const curr = inst._zod.bag.minimum ?? Number.NEGATIVE_INFINITY;
792
- if (def.minimum > curr) inst._zod.bag.minimum = def.minimum;
793
- });
1164
+ (_a = inst._zod.def).when ?? (_a.when = _whenHasLength);
794
1165
  inst._zod.check = (payload) => {
795
1166
  const input = payload.value;
796
- if (input.length >= def.minimum) return;
1167
+ const units = input.length;
1168
+ if ((typeof input === "string" && units >= def.minimum && units < def.minimum * 2 ? codePointLength(input) : units) >= def.minimum) return;
797
1169
  const origin = getLengthableOrigin(input);
798
1170
  payload.issues.push({
799
1171
  origin,
@@ -809,19 +1181,11 @@ var $ZodCheckMinLength = /*@__PURE__*/ $constructor("$ZodCheckMinLength", (inst,
809
1181
  var $ZodCheckLengthEquals = /*@__PURE__*/ $constructor("$ZodCheckLengthEquals", (inst, def) => {
810
1182
  var _a;
811
1183
  $ZodCheck.init(inst, def);
812
- (_a = inst._zod.def).when ?? (_a.when = (payload) => {
813
- const val = payload.value;
814
- return !nullish(val) && val.length !== void 0;
815
- });
816
- inst._zod.onattach.push((inst) => {
817
- const bag = inst._zod.bag;
818
- bag.minimum = def.length;
819
- bag.maximum = def.length;
820
- bag.length = def.length;
821
- });
1184
+ (_a = inst._zod.def).when ?? (_a.when = _whenHasLength);
822
1185
  inst._zod.check = (payload) => {
823
1186
  const input = payload.value;
824
- const length = input.length;
1187
+ const units = input.length;
1188
+ const length = typeof input === "string" && units >= def.length && units <= def.length * 2 ? codePointLength(input) : units;
825
1189
  if (length === def.length) return;
826
1190
  const origin = getLengthableOrigin(input);
827
1191
  const tooBig = length > def.length;
@@ -845,14 +1209,6 @@ var $ZodCheckLengthEquals = /*@__PURE__*/ $constructor("$ZodCheckLengthEquals",
845
1209
  var $ZodCheckStringFormat = /*@__PURE__*/ $constructor("$ZodCheckStringFormat", (inst, def) => {
846
1210
  var _a, _b;
847
1211
  $ZodCheck.init(inst, def);
848
- inst._zod.onattach.push((inst) => {
849
- const bag = inst._zod.bag;
850
- bag.format = def.format;
851
- if (def.pattern) {
852
- bag.patterns ?? (bag.patterns = /* @__PURE__ */ new Set());
853
- bag.patterns.add(def.pattern);
854
- }
855
- });
856
1212
  if (def.pattern) (_a = inst._zod).check ?? (_a.check = (payload) => {
857
1213
  def.pattern.lastIndex = 0;
858
1214
  if (def.pattern.test(payload.value)) return;
@@ -895,13 +1251,7 @@ var $ZodCheckUpperCase = /*@__PURE__*/ $constructor("$ZodCheckUpperCase", (inst,
895
1251
  var $ZodCheckIncludes = /*@__PURE__*/ $constructor("$ZodCheckIncludes", (inst, def) => {
896
1252
  $ZodCheck.init(inst, def);
897
1253
  const escapedRegex = escapeRegex(def.includes);
898
- const pattern = new RegExp(typeof def.position === "number" ? `^.{${def.position}}${escapedRegex}` : escapedRegex);
899
- def.pattern = pattern;
900
- inst._zod.onattach.push((inst) => {
901
- const bag = inst._zod.bag;
902
- bag.patterns ?? (bag.patterns = /* @__PURE__ */ new Set());
903
- bag.patterns.add(pattern);
904
- });
1254
+ def.pattern = new RegExp(typeof def.position === "number" ? `^.{${def.position},}${escapedRegex}` : escapedRegex);
905
1255
  inst._zod.check = (payload) => {
906
1256
  if (payload.value.includes(def.includes, def.position)) return;
907
1257
  payload.issues.push({
@@ -919,11 +1269,6 @@ var $ZodCheckStartsWith = /*@__PURE__*/ $constructor("$ZodCheckStartsWith", (ins
919
1269
  $ZodCheck.init(inst, def);
920
1270
  const pattern = new RegExp(`^${escapeRegex(def.prefix)}.*`);
921
1271
  def.pattern ?? (def.pattern = pattern);
922
- inst._zod.onattach.push((inst) => {
923
- const bag = inst._zod.bag;
924
- bag.patterns ?? (bag.patterns = /* @__PURE__ */ new Set());
925
- bag.patterns.add(pattern);
926
- });
927
1272
  inst._zod.check = (payload) => {
928
1273
  if (payload.value.startsWith(def.prefix)) return;
929
1274
  payload.issues.push({
@@ -941,11 +1286,6 @@ var $ZodCheckEndsWith = /*@__PURE__*/ $constructor("$ZodCheckEndsWith", (inst, d
941
1286
  $ZodCheck.init(inst, def);
942
1287
  const pattern = new RegExp(`.*${escapeRegex(def.suffix)}$`);
943
1288
  def.pattern ?? (def.pattern = pattern);
944
- inst._zod.onattach.push((inst) => {
945
- const bag = inst._zod.bag;
946
- bag.patterns ?? (bag.patterns = /* @__PURE__ */ new Set());
947
- bag.patterns.add(pattern);
948
- });
949
1289
  inst._zod.check = (payload) => {
950
1290
  if (payload.value.endsWith(def.suffix)) return;
951
1291
  payload.issues.push({
@@ -966,17 +1306,21 @@ var $ZodCheckOverwrite = /*@__PURE__*/ $constructor("$ZodCheckOverwrite", (inst,
966
1306
  };
967
1307
  });
968
1308
  //#endregion
969
- //#region ../../node_modules/.pnpm/zod@4.4.3/node_modules/zod/v4/core/doc.js
1309
+ //#region ../../node_modules/.pnpm/zod@4.6.5/node_modules/zod/v4/core/doc.js
970
1310
  var Doc = class {
971
- constructor(args = []) {
1311
+ constructor(args = [], closed = {}) {
972
1312
  this.content = [];
973
1313
  this.indent = 0;
974
- if (this) this.args = args;
1314
+ this.args = args;
1315
+ this.closed = closed;
975
1316
  }
976
1317
  indented(fn) {
977
1318
  this.indent += 1;
978
- fn(this);
979
- this.indent -= 1;
1319
+ try {
1320
+ fn(this);
1321
+ } finally {
1322
+ this.indent -= 1;
1323
+ }
980
1324
  }
981
1325
  write(arg) {
982
1326
  if (typeof arg === "function") {
@@ -991,28 +1335,27 @@ var Doc = class {
991
1335
  }
992
1336
  compile() {
993
1337
  const F = Function;
994
- const args = this?.args;
995
- const lines = [...(this?.content ?? [``]).map((x) => ` ${x}`)];
996
- return new F(...args, lines.join("\n"));
1338
+ const content = this?.content ?? [``];
1339
+ return new F(...Object.keys(this.closed), `return function (${this.args.join(", ")}) {\n${content.join("\n")}\n};`)(...Object.values(this.closed));
997
1340
  }
998
1341
  };
999
1342
  //#endregion
1000
- //#region ../../node_modules/.pnpm/zod@4.4.3/node_modules/zod/v4/core/versions.js
1343
+ //#region ../../node_modules/.pnpm/zod@4.6.5/node_modules/zod/v4/core/versions.js
1001
1344
  var version = {
1002
1345
  major: 4,
1003
- minor: 4,
1004
- patch: 3
1346
+ minor: 6,
1347
+ patch: 5
1005
1348
  };
1006
1349
  //#endregion
1007
- //#region ../../node_modules/.pnpm/zod@4.4.3/node_modules/zod/v4/core/schemas.js
1350
+ //#region ../../node_modules/.pnpm/zod@4.6.5/node_modules/zod/v4/core/schemas.js
1008
1351
  var $ZodType = /*@__PURE__*/ $constructor("$ZodType", (inst, def) => {
1009
1352
  var _a;
1010
1353
  inst ?? (inst = {});
1011
1354
  inst._zod.def = def;
1012
1355
  inst._zod.bag = inst._zod.bag || {};
1013
1356
  inst._zod.version = version;
1014
- const checks = [...inst._zod.def.checks ?? []];
1015
- if (inst._zod.traits.has("$ZodCheck")) checks.unshift(inst);
1357
+ const defChecks = inst._zod.def.checks;
1358
+ const checks = inst._zod.traits.has("$ZodCheck") ? [inst, ...defChecks ?? []] : defChecks?.length ? [...defChecks] : [];
1016
1359
  for (const ch of checks) for (const fn of ch._zod.onattach) fn(inst);
1017
1360
  if (checks.length === 0) {
1018
1361
  (_a = inst._zod).deferred ?? (_a.deferred = []);
@@ -1021,6 +1364,7 @@ var $ZodType = /*@__PURE__*/ $constructor("$ZodType", (inst, def) => {
1021
1364
  });
1022
1365
  } else {
1023
1366
  const runChecks = (payload, checks, ctx) => {
1367
+ if (payload.memo) return payload;
1024
1368
  let isAborted = aborted(payload);
1025
1369
  let asyncResult;
1026
1370
  for (const ch of checks) {
@@ -1034,10 +1378,12 @@ var $ZodType = /*@__PURE__*/ $constructor("$ZodType", (inst, def) => {
1034
1378
  if (asyncResult || _ instanceof Promise) asyncResult = (asyncResult ?? Promise.resolve()).then(async () => {
1035
1379
  await _;
1036
1380
  if (payload.issues.length === currLen) return;
1381
+ attachSchema(payload.issues, currLen, inst);
1037
1382
  if (!isAborted) isAborted = aborted(payload, currLen);
1038
1383
  });
1039
1384
  else {
1040
1385
  if (payload.issues.length === currLen) continue;
1386
+ attachSchema(payload.issues, currLen, inst);
1041
1387
  if (!isAborted) isAborted = aborted(payload, currLen);
1042
1388
  }
1043
1389
  }
@@ -1081,22 +1427,43 @@ var $ZodType = /*@__PURE__*/ $constructor("$ZodType", (inst, def) => {
1081
1427
  return runChecks(result, checks, ctx);
1082
1428
  };
1083
1429
  }
1084
- defineLazy(inst, "~standard", () => ({
1430
+ }, {
1431
+ get "~standard"() {
1432
+ return hide(this, "~standard", standardProps(this));
1433
+ },
1434
+ set "~standard"(value) {
1435
+ own(this, "~standard", value);
1436
+ }
1437
+ });
1438
+ /** The Standard Schema surface for `inst`. Shared so wrappers can extend it without forcing it. */
1439
+ var toStandardResult = (r, ctx) => r.issues.length ? { issues: r.issues.map((iss) => finalizeIssue(iss, ctx, config())) } : { value: r.value };
1440
+ async function validateAsync(inst, value) {
1441
+ const ctx = { async: true };
1442
+ return toStandardResult(await inst._zod.run({
1443
+ value,
1444
+ issues: []
1445
+ }, ctx), ctx);
1446
+ }
1447
+ function standardProps(inst) {
1448
+ return {
1085
1449
  validate: (value) => {
1450
+ const ctx = { async: false };
1086
1451
  try {
1087
- const r = safeParse$1(inst, value);
1088
- return r.success ? { value: r.data } : { issues: r.error?.issues };
1089
- } catch (_) {
1090
- return safeParseAsync$1(inst, value).then((r) => r.success ? { value: r.data } : { issues: r.error?.issues });
1091
- }
1452
+ const r = inst._zod.run({
1453
+ value,
1454
+ issues: []
1455
+ }, ctx);
1456
+ if (!(r instanceof Promise)) return toStandardResult(r, ctx);
1457
+ } catch (_) {}
1458
+ return validateAsync(inst, value);
1092
1459
  },
1093
1460
  vendor: "zod",
1094
1461
  version: 1
1095
- }));
1096
- });
1462
+ };
1463
+ }
1097
1464
  var $ZodString = /*@__PURE__*/ $constructor("$ZodString", (inst, def) => {
1098
1465
  $ZodType.init(inst, def);
1099
- inst._zod.pattern = [...inst?._zod.bag?.patterns ?? []].pop() ?? string$1(inst._zod.bag);
1466
+ inst._zod.pattern = def.pattern ?? anyString;
1100
1467
  inst._zod.parse = (payload, _) => {
1101
1468
  if (def.coerce) try {
1102
1469
  payload.value = String(payload.value);
@@ -1140,51 +1507,95 @@ var $ZodEmail = /*@__PURE__*/ $constructor("$ZodEmail", (inst, def) => {
1140
1507
  def.pattern ?? (def.pattern = email);
1141
1508
  $ZodStringFormat.init(inst, def);
1142
1509
  });
1510
+ function canParseURL(input) {
1511
+ try {
1512
+ if (typeof URL !== "undefined" && typeof URL.canParse === "function") return URL.canParse(input);
1513
+ new URL(input);
1514
+ return true;
1515
+ } catch {
1516
+ return false;
1517
+ }
1518
+ }
1519
+ function validateURL(trimmed, def) {
1520
+ if (!("normalize" in def) && !("hostname" in def) && !("protocol" in def)) return canParseURL(trimmed) || 2;
1521
+ return parseURLObject(trimmed, def);
1522
+ }
1523
+ /** Parses a URL while preserving the non-normalizing HTTP guard. */
1524
+ function parseURLObject(trimmed, def) {
1525
+ if (!def.normalize && def.protocol?.source === httpProtocol.source && !/^https?:\/\//i.test(trimmed)) return 1;
1526
+ try {
1527
+ if (typeof URL !== "undefined") {
1528
+ const URLStatic = URL;
1529
+ if (typeof URLStatic.parse === "function") return URLStatic.parse(trimmed) ?? 2;
1530
+ }
1531
+ return new URL(trimmed);
1532
+ } catch {
1533
+ return 2;
1534
+ }
1535
+ }
1536
+ var asciiTabOrNewline = /[\t\n\r]/g;
1537
+ /** The URL parser deletes every ASCII tab, LF and CR from its input before it parses, so `new URL("https://exa\nmple.com")` reports on `example.com`. Applying the same deletion to the returned value closes the half of that divergence which can move the host; the parser's other rewrite, stripping C0 controls at the edges, cannot. */
1538
+ function stripTabAndNewline(value) {
1539
+ return value.replace(asciiTabOrNewline, "");
1540
+ }
1541
+ function urlHostnameOk(url, hostname) {
1542
+ hostname.lastIndex = 0;
1543
+ return hostname.test(url.hostname);
1544
+ }
1545
+ function urlProtocolOk(url, protocol) {
1546
+ protocol.lastIndex = 0;
1547
+ return protocol.test(url.protocol.endsWith(":") ? url.protocol.slice(0, -1) : url.protocol);
1548
+ }
1143
1549
  var $ZodURL = /*@__PURE__*/ $constructor("$ZodURL", (inst, def) => {
1144
1550
  $ZodStringFormat.init(inst, def);
1145
1551
  inst._zod.check = (payload) => {
1146
1552
  try {
1147
1553
  const trimmed = payload.value.trim();
1148
- if (!def.normalize && def.protocol?.source === httpProtocol.source) {
1149
- if (!/^https?:\/\//i.test(trimmed)) {
1150
- payload.issues.push({
1151
- code: "invalid_format",
1152
- format: "url",
1153
- note: "Invalid URL format",
1154
- input: payload.value,
1155
- inst,
1156
- continue: !def.abort
1157
- });
1158
- return;
1159
- }
1160
- }
1161
- const url = new URL(trimmed);
1162
- if (def.hostname) {
1163
- def.hostname.lastIndex = 0;
1164
- if (!def.hostname.test(url.hostname)) payload.issues.push({
1554
+ const url = validateURL(trimmed, def);
1555
+ if (url === 1) {
1556
+ payload.issues.push({
1165
1557
  code: "invalid_format",
1166
1558
  format: "url",
1167
- note: "Invalid hostname",
1168
- pattern: def.hostname.source,
1559
+ note: "Invalid URL format",
1169
1560
  input: payload.value,
1170
1561
  inst,
1171
1562
  continue: !def.abort
1172
1563
  });
1564
+ return;
1173
1565
  }
1174
- if (def.protocol) {
1175
- def.protocol.lastIndex = 0;
1176
- if (!def.protocol.test(url.protocol.endsWith(":") ? url.protocol.slice(0, -1) : url.protocol)) payload.issues.push({
1566
+ if (url === 2) {
1567
+ payload.issues.push({
1177
1568
  code: "invalid_format",
1178
1569
  format: "url",
1179
- note: "Invalid protocol",
1180
- pattern: def.protocol.source,
1181
1570
  input: payload.value,
1182
1571
  inst,
1183
1572
  continue: !def.abort
1184
1573
  });
1574
+ return;
1575
+ }
1576
+ if (url === true) {
1577
+ payload.value = stripTabAndNewline(trimmed);
1578
+ return;
1185
1579
  }
1186
- if (def.normalize) payload.value = url.href;
1187
- else payload.value = trimmed;
1580
+ if (def.hostname && !urlHostnameOk(url, def.hostname)) payload.issues.push({
1581
+ code: "invalid_format",
1582
+ format: "url",
1583
+ note: "Invalid hostname",
1584
+ pattern: def.hostname.source,
1585
+ input: payload.value,
1586
+ inst,
1587
+ continue: !def.abort
1588
+ });
1589
+ if (def.protocol && !urlProtocolOk(url, def.protocol)) payload.issues.push({
1590
+ code: "invalid_format",
1591
+ format: "url",
1592
+ note: "Invalid protocol",
1593
+ pattern: def.protocol.source,
1594
+ input: payload.value,
1595
+ inst,
1596
+ continue: !def.abort
1597
+ });
1598
+ payload.value = def.normalize ? url.href : stripTabAndNewline(trimmed);
1188
1599
  return;
1189
1600
  } catch (_) {
1190
1601
  payload.issues.push({
@@ -1202,7 +1613,8 @@ var $ZodEmoji = /*@__PURE__*/ $constructor("$ZodEmoji", (inst, def) => {
1202
1613
  $ZodStringFormat.init(inst, def);
1203
1614
  });
1204
1615
  var $ZodNanoID = /*@__PURE__*/ $constructor("$ZodNanoID", (inst, def) => {
1205
- def.pattern ?? (def.pattern = nanoid);
1616
+ if (def.length !== void 0 && (!Number.isInteger(def.length) || def.length < 1)) throw new Error(`Invalid nanoid length: ${def.length}`);
1617
+ def.pattern ?? (def.pattern = def.length === void 0 ? nanoid : nanoidOfLength(def.length));
1206
1618
  $ZodStringFormat.init(inst, def);
1207
1619
  });
1208
1620
  /**
@@ -1231,70 +1643,69 @@ var $ZodKSUID = /*@__PURE__*/ $constructor("$ZodKSUID", (inst, def) => {
1231
1643
  $ZodStringFormat.init(inst, def);
1232
1644
  });
1233
1645
  var $ZodISODateTime = /*@__PURE__*/ $constructor("$ZodISODateTime", (inst, def) => {
1234
- def.pattern ?? (def.pattern = datetime$1(def));
1646
+ def.pattern ?? (def.pattern = datetime(def));
1235
1647
  $ZodStringFormat.init(inst, def);
1236
1648
  });
1237
1649
  var $ZodISODate = /*@__PURE__*/ $constructor("$ZodISODate", (inst, def) => {
1238
- def.pattern ?? (def.pattern = date$1);
1650
+ def.pattern ?? (def.pattern = date);
1239
1651
  $ZodStringFormat.init(inst, def);
1240
1652
  });
1241
1653
  var $ZodISOTime = /*@__PURE__*/ $constructor("$ZodISOTime", (inst, def) => {
1242
- def.pattern ?? (def.pattern = time$1(def));
1654
+ def.pattern ?? (def.pattern = time(def));
1243
1655
  $ZodStringFormat.init(inst, def);
1244
1656
  });
1245
1657
  var $ZodISODuration = /*@__PURE__*/ $constructor("$ZodISODuration", (inst, def) => {
1246
- def.pattern ?? (def.pattern = duration$1);
1658
+ def.pattern ?? (def.pattern = duration);
1247
1659
  $ZodStringFormat.init(inst, def);
1248
1660
  });
1249
1661
  var $ZodIPv4 = /*@__PURE__*/ $constructor("$ZodIPv4", (inst, def) => {
1250
1662
  def.pattern ?? (def.pattern = ipv4);
1251
1663
  $ZodStringFormat.init(inst, def);
1252
- inst._zod.bag.format = `ipv4`;
1253
1664
  });
1665
+ /** An IPv6 address is written with hex digits, colons and dots, and nothing else. The guard is what makes the check below an IPv6 check: `new URL("http://[...]")` parses an authority, not an address, so `@` and `\` re-delimit it and `"::@1\\"` validates against the host `0.0.0.1`. The URL parser also deletes ASCII tab, LF and CR rather than failing, which is how `"::1\n"` validated as `::1`. */
1666
+ var ipv6Alphabet = /^[0-9a-fA-F:.]+$/;
1667
+ function isValidIPv6(value) {
1668
+ if (!ipv6Alphabet.test(value)) return false;
1669
+ return canParseURL(`http://[${value}]`);
1670
+ }
1254
1671
  var $ZodIPv6 = /*@__PURE__*/ $constructor("$ZodIPv6", (inst, def) => {
1255
1672
  def.pattern ?? (def.pattern = ipv6);
1256
1673
  $ZodStringFormat.init(inst, def);
1257
- inst._zod.bag.format = `ipv6`;
1258
1674
  inst._zod.check = (payload) => {
1259
- try {
1260
- new URL(`http://[${payload.value}]`);
1261
- } catch {
1262
- payload.issues.push({
1263
- code: "invalid_format",
1264
- format: "ipv6",
1265
- input: payload.value,
1266
- inst,
1267
- continue: !def.abort
1268
- });
1269
- }
1675
+ if (!isValidIPv6(payload.value)) payload.issues.push({
1676
+ code: "invalid_format",
1677
+ format: "ipv6",
1678
+ input: payload.value,
1679
+ inst,
1680
+ continue: !def.abort
1681
+ });
1270
1682
  };
1271
1683
  });
1272
1684
  var $ZodCIDRv4 = /*@__PURE__*/ $constructor("$ZodCIDRv4", (inst, def) => {
1273
1685
  def.pattern ?? (def.pattern = cidrv4);
1274
1686
  $ZodStringFormat.init(inst, def);
1275
1687
  });
1688
+ function isValidCIDRv6(value) {
1689
+ const parts = value.split("/");
1690
+ if (parts.length !== 2) return false;
1691
+ const [address, prefix] = parts;
1692
+ if (!prefix) return false;
1693
+ const prefixNum = Number(prefix);
1694
+ if (`${prefixNum}` !== prefix) return false;
1695
+ if (prefixNum < 0 || prefixNum > 128) return false;
1696
+ return isValidIPv6(address);
1697
+ }
1276
1698
  var $ZodCIDRv6 = /*@__PURE__*/ $constructor("$ZodCIDRv6", (inst, def) => {
1277
1699
  def.pattern ?? (def.pattern = cidrv6);
1278
1700
  $ZodStringFormat.init(inst, def);
1279
1701
  inst._zod.check = (payload) => {
1280
- const parts = payload.value.split("/");
1281
- try {
1282
- if (parts.length !== 2) throw new Error();
1283
- const [address, prefix] = parts;
1284
- if (!prefix) throw new Error();
1285
- const prefixNum = Number(prefix);
1286
- if (`${prefixNum}` !== prefix) throw new Error();
1287
- if (prefixNum < 0 || prefixNum > 128) throw new Error();
1288
- new URL(`http://[${address}]`);
1289
- } catch {
1290
- payload.issues.push({
1291
- code: "invalid_format",
1292
- format: "cidrv6",
1293
- input: payload.value,
1294
- inst,
1295
- continue: !def.abort
1296
- });
1297
- }
1702
+ if (!isValidCIDRv6(payload.value)) payload.issues.push({
1703
+ code: "invalid_format",
1704
+ format: "cidrv6",
1705
+ input: payload.value,
1706
+ inst,
1707
+ continue: !def.abort
1708
+ });
1298
1709
  };
1299
1710
  });
1300
1711
  function isValidBase64(data) {
@@ -1308,10 +1719,10 @@ function isValidBase64(data) {
1308
1719
  return false;
1309
1720
  }
1310
1721
  }
1722
+ var base64Charset = /^[0-9a-zA-Z+/]*={0,2}$/;
1311
1723
  var $ZodBase64 = /*@__PURE__*/ $constructor("$ZodBase64", (inst, def) => {
1312
- def.pattern ?? (def.pattern = base64);
1724
+ def.pattern ?? (def.pattern = base64Charset);
1313
1725
  $ZodStringFormat.init(inst, def);
1314
- inst._zod.bag.contentEncoding = "base64";
1315
1726
  inst._zod.check = (payload) => {
1316
1727
  if (isValidBase64(payload.value)) return;
1317
1728
  payload.issues.push({
@@ -1323,15 +1734,15 @@ var $ZodBase64 = /*@__PURE__*/ $constructor("$ZodBase64", (inst, def) => {
1323
1734
  });
1324
1735
  };
1325
1736
  });
1737
+ var base64urlCharset = /^[A-Za-z0-9_-]*$/;
1326
1738
  function isValidBase64URL(data) {
1327
- if (!base64url.test(data)) return false;
1739
+ if (!base64urlCharset.test(data)) return false;
1328
1740
  const base64 = data.replace(/[-_]/g, (c) => c === "-" ? "+" : "/");
1329
1741
  return isValidBase64(base64.padEnd(Math.ceil(base64.length / 4) * 4, "="));
1330
1742
  }
1331
1743
  var $ZodBase64URL = /*@__PURE__*/ $constructor("$ZodBase64URL", (inst, def) => {
1332
- def.pattern ?? (def.pattern = base64url);
1744
+ def.pattern ?? (def.pattern = base64urlCharset);
1333
1745
  $ZodStringFormat.init(inst, def);
1334
- inst._zod.bag.contentEncoding = "base64url";
1335
1746
  inst._zod.check = (payload) => {
1336
1747
  if (isValidBase64URL(payload.value)) return;
1337
1748
  payload.issues.push({
@@ -1377,14 +1788,14 @@ var $ZodJWT = /*@__PURE__*/ $constructor("$ZodJWT", (inst, def) => {
1377
1788
  });
1378
1789
  var $ZodNumber = /*@__PURE__*/ $constructor("$ZodNumber", (inst, def) => {
1379
1790
  $ZodType.init(inst, def);
1380
- inst._zod.pattern = inst._zod.bag.pattern ?? number$1;
1791
+ inst._zod.pattern = number$1;
1381
1792
  inst._zod.parse = (payload, _ctx) => {
1382
1793
  if (def.coerce) try {
1383
1794
  payload.value = Number(payload.value);
1384
1795
  } catch (_) {}
1385
1796
  const input = payload.value;
1386
1797
  if (typeof input === "number" && !Number.isNaN(input) && Number.isFinite(input)) return payload;
1387
- const received = typeof input === "number" ? Number.isNaN(input) ? "NaN" : !Number.isFinite(input) ? "Infinity" : void 0 : void 0;
1798
+ const received = typeof input === "number" ? Number.isNaN(input) ? "NaN" : !Number.isFinite(input) ? String(input) : void 0 : void 0;
1388
1799
  payload.issues.push({
1389
1800
  expected: "number",
1390
1801
  code: "invalid_type",
@@ -1439,6 +1850,8 @@ function handleArrayResult(result, final, index) {
1439
1850
  }
1440
1851
  var $ZodArray = /*@__PURE__*/ $constructor("$ZodArray", (inst, def) => {
1441
1852
  $ZodType.init(inst, def);
1853
+ const memo = globalConfig.memoizer;
1854
+ memo?.attach(inst);
1442
1855
  inst._zod.parse = (payload, ctx) => {
1443
1856
  const input = payload.value;
1444
1857
  if (!Array.isArray(input)) {
@@ -1450,8 +1863,9 @@ var $ZodArray = /*@__PURE__*/ $constructor("$ZodArray", (inst, def) => {
1450
1863
  });
1451
1864
  return payload;
1452
1865
  }
1453
- payload.value = Array(input.length);
1866
+ payload.value = memo ? memo.alloc(inst, payload, Array(input.length), ctx) : Array(input.length);
1454
1867
  const proms = [];
1868
+ const abortEarly = ctx?.abortEarly;
1455
1869
  for (let i = 0; i < input.length; i++) {
1456
1870
  const item = input[i];
1457
1871
  const result = def.element._zod.run({
@@ -1459,19 +1873,24 @@ var $ZodArray = /*@__PURE__*/ $constructor("$ZodArray", (inst, def) => {
1459
1873
  issues: []
1460
1874
  }, ctx);
1461
1875
  if (result instanceof Promise) proms.push(result.then((result) => handleArrayResult(result, payload, i)));
1462
- else handleArrayResult(result, payload, i);
1876
+ else {
1877
+ handleArrayResult(result, payload, i);
1878
+ if (abortEarly && result.issues.length !== 0 && aborted(result)) break;
1879
+ }
1463
1880
  }
1464
1881
  if (proms.length) return Promise.all(proms).then(() => payload);
1465
1882
  return payload;
1466
1883
  };
1467
1884
  });
1468
- function handlePropertyResult(result, final, key, input, isOptionalIn, isOptionalOut) {
1885
+ function handlePropertyResult(result, final, key, input, optin, optout) {
1469
1886
  const isPresent = key in input;
1887
+ const isOptionalOut = optout === "optional";
1888
+ if (!isPresent && isOptionalOut && optin === "optional") return;
1470
1889
  if (result.issues.length) {
1471
- if (isOptionalIn && isOptionalOut && !isPresent) return;
1890
+ if (optin !== void 0 && isOptionalOut && !isPresent) return;
1472
1891
  final.issues.push(...prefixIssues(key, result.issues));
1473
1892
  }
1474
- if (!isPresent && !isOptionalIn) {
1893
+ if (!isPresent && optin === void 0) {
1475
1894
  if (!result.issues.length) final.issues.push({
1476
1895
  code: "invalid_type",
1477
1896
  expected: "nonoptional",
@@ -1481,31 +1900,44 @@ function handlePropertyResult(result, final, key, input, isOptionalIn, isOptiona
1481
1900
  return;
1482
1901
  }
1483
1902
  if (result.value === void 0) {
1484
- if (isPresent) final.value[key] = void 0;
1903
+ if (isPresent || optin === "defaulted" && !isOptionalOut) final.value[key] = void 0;
1485
1904
  } else final.value[key] = result.value;
1486
1905
  }
1906
+ var NO_SYMBOL_KEYS = [];
1487
1907
  function normalizeDef(def) {
1488
1908
  const keys = Object.keys(def.shape);
1489
- 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`);
1909
+ const ownSymbols = Object.getOwnPropertySymbols(def.shape);
1910
+ const symbolKeys = ownSymbols.length ? ownSymbols : NO_SYMBOL_KEYS;
1911
+ const allKeys = symbolKeys.length ? [...keys, ...symbolKeys] : keys;
1912
+ for (const k of allKeys) if (!def.shape?.[k]?._zod?.traits?.has("$ZodType")) throw new Error(`Invalid element at key "${String(k)}": expected a Zod schema`);
1490
1913
  const okeys = optionalKeys(def.shape);
1491
1914
  return {
1492
1915
  ...def,
1493
- keys,
1916
+ allKeys,
1917
+ symbolKeys,
1494
1918
  keySet: new Set(keys),
1495
1919
  numKeys: keys.length,
1496
1920
  optionalKeys: new Set(okeys)
1497
1921
  };
1498
1922
  }
1499
- function handleCatchall(proms, input, payload, ctx, def, inst) {
1923
+ function handleCatchall(proms, input, payload, ctx, def, inst, abortEarly) {
1500
1924
  const unrecognized = [];
1501
1925
  const keySet = def.keySet;
1502
1926
  const _catchall = def.catchall._zod;
1503
1927
  const t = _catchall.def.type;
1504
- const isOptionalIn = _catchall.optin === "optional";
1505
- const isOptionalOut = _catchall.optout === "optional";
1928
+ const optin = _catchall.optin;
1929
+ const optout = _catchall.optout;
1930
+ let seen = 0;
1506
1931
  for (const key in input) {
1507
- if (key === "__proto__") continue;
1932
+ if (abortEarly && payload.issues.length !== seen) {
1933
+ if (aborted(payload, seen)) break;
1934
+ seen = payload.issues.length;
1935
+ }
1508
1936
  if (keySet.has(key)) continue;
1937
+ if (key === "__proto__") {
1938
+ if (t === "never") unrecognized.push(key);
1939
+ continue;
1940
+ }
1509
1941
  if (t === "never") {
1510
1942
  unrecognized.push(key);
1511
1943
  continue;
@@ -1514,14 +1946,15 @@ function handleCatchall(proms, input, payload, ctx, def, inst) {
1514
1946
  value: input[key],
1515
1947
  issues: []
1516
1948
  }, ctx);
1517
- if (r instanceof Promise) proms.push(r.then((r) => handlePropertyResult(r, payload, key, input, isOptionalIn, isOptionalOut)));
1518
- else handlePropertyResult(r, payload, key, input, isOptionalIn, isOptionalOut);
1949
+ if (r instanceof Promise) proms.push(r.then((r) => handlePropertyResult(r, payload, key, input, optin, optout)));
1950
+ else handlePropertyResult(r, payload, key, input, optin, optout);
1519
1951
  }
1520
1952
  if (unrecognized.length) payload.issues.push({
1521
1953
  code: "unrecognized_keys",
1522
1954
  keys: unrecognized,
1523
1955
  input,
1524
- inst
1956
+ inst,
1957
+ continue: true
1525
1958
  });
1526
1959
  if (!proms.length) return payload;
1527
1960
  return Promise.all(proms).then(() => {
@@ -1530,23 +1963,28 @@ function handleCatchall(proms, input, payload, ctx, def, inst) {
1530
1963
  }
1531
1964
  var $ZodObject = /*@__PURE__*/ $constructor("$ZodObject", (inst, def) => {
1532
1965
  $ZodType.init(inst, def);
1533
- if (!Object.getOwnPropertyDescriptor(def, "shape")?.get) {
1534
- const sh = def.shape;
1535
- Object.defineProperty(def, "shape", { get: () => {
1966
+ const desc = Object.getOwnPropertyDescriptor(def, "shape");
1967
+ const sh = desc?.get ? desc.get.raw : def.shape ?? {};
1968
+ if (sh) {
1969
+ const get = () => {
1536
1970
  const newSh = { ...sh };
1537
1971
  Object.defineProperty(def, "shape", { value: newSh });
1972
+ get.raw = newSh;
1538
1973
  return newSh;
1539
- } });
1974
+ };
1975
+ get.raw = sh;
1976
+ Object.defineProperty(def, "shape", { get });
1540
1977
  }
1541
1978
  const _normalized = cached(() => normalizeDef(def));
1542
- defineLazy(inst._zod, "propValues", () => {
1543
- const shape = def.shape;
1979
+ defineLazyInternal(inst, "propValues", (zod) => {
1980
+ const shape = zod.def.shape;
1544
1981
  const propValues = {};
1545
1982
  for (const key in shape) {
1546
1983
  const field = shape[key]._zod;
1547
1984
  if (field.values) {
1548
- propValues[key] ?? (propValues[key] = /* @__PURE__ */ new Set());
1985
+ if (!Object.prototype.hasOwnProperty.call(propValues, key)) assignProp(propValues, key, /* @__PURE__ */ new Set());
1549
1986
  for (const v of field.values) propValues[key].add(v);
1987
+ if (field.optin !== void 0) propValues[key].add(void 0);
1550
1988
  }
1551
1989
  }
1552
1990
  return propValues;
@@ -1554,6 +1992,8 @@ var $ZodObject = /*@__PURE__*/ $constructor("$ZodObject", (inst, def) => {
1554
1992
  const isObject$1 = isObject;
1555
1993
  const catchall = def.catchall;
1556
1994
  let value;
1995
+ const memo = globalConfig.memoizer;
1996
+ memo?.attach(inst);
1557
1997
  inst._zod.parse = (payload, ctx) => {
1558
1998
  value ?? (value = _normalized.value);
1559
1999
  const input = payload.value;
@@ -1566,77 +2006,90 @@ var $ZodObject = /*@__PURE__*/ $constructor("$ZodObject", (inst, def) => {
1566
2006
  });
1567
2007
  return payload;
1568
2008
  }
1569
- payload.value = {};
2009
+ payload.value = memo ? memo.alloc(inst, payload, {}, ctx) : {};
1570
2010
  const proms = [];
1571
2011
  const shape = value.shape;
1572
- for (const key of value.keys) {
2012
+ const abortEarly = ctx?.abortEarly;
2013
+ let seen = payload.issues.length;
2014
+ for (const key of value.allKeys) {
2015
+ if (abortEarly && payload.issues.length !== seen) {
2016
+ if (aborted(payload, seen)) break;
2017
+ seen = payload.issues.length;
2018
+ }
2019
+ if (key === "__proto__") continue;
1573
2020
  const el = shape[key];
1574
- const isOptionalIn = el._zod.optin === "optional";
1575
- const isOptionalOut = el._zod.optout === "optional";
2021
+ const optin = el._zod.optin;
2022
+ const optout = el._zod.optout;
1576
2023
  const r = el._zod.run({
1577
2024
  value: input[key],
1578
2025
  issues: []
1579
2026
  }, ctx);
1580
- if (r instanceof Promise) proms.push(r.then((r) => handlePropertyResult(r, payload, key, input, isOptionalIn, isOptionalOut)));
1581
- else handlePropertyResult(r, payload, key, input, isOptionalIn, isOptionalOut);
2027
+ if (r instanceof Promise) proms.push(r.then((r) => handlePropertyResult(r, payload, key, input, optin, optout)));
2028
+ else handlePropertyResult(r, payload, key, input, optin, optout);
1582
2029
  }
1583
2030
  if (!catchall) return proms.length ? Promise.all(proms).then(() => payload) : payload;
1584
- return handleCatchall(proms, input, payload, ctx, _normalized.value, inst);
2031
+ return handleCatchall(proms, input, payload, ctx, _normalized.value, inst, abortEarly === true);
1585
2032
  };
1586
2033
  });
1587
2034
  var $ZodObjectJIT = /*@__PURE__*/ $constructor("$ZodObjectJIT", (inst, def) => {
1588
2035
  $ZodObject.init(inst, def);
1589
2036
  const superParse = inst._zod.parse;
1590
2037
  const _normalized = cached(() => normalizeDef(def));
2038
+ const memo = globalConfig.memoizer;
1591
2039
  const generateFastpass = (shape) => {
1592
- const doc = new Doc([
1593
- "shape",
1594
- "payload",
1595
- "ctx"
1596
- ]);
1597
2040
  const normalized = _normalized.value;
1598
- const parseStr = (key) => {
1599
- const k = esc(key);
1600
- return `shape[${k}]._zod.run({ value: input[${k}], issues: [] }, ctx)`;
1601
- };
2041
+ const syms = normalized.symbolKeys;
2042
+ const doc = new Doc(["payload", "ctx"], {
2043
+ shape,
2044
+ inst,
2045
+ memo,
2046
+ syms
2047
+ });
2048
+ const parseStr = (k) => `shape[${k}]._zod.run({ value: input[${k}], issues: [] }, ctx)`;
2049
+ const prefixStr = (id, k) => `
2050
+ let ${id}_ab = false;
2051
+ for (let i = 0; i < ${id}.issues.length; i++) {
2052
+ const iss = ${id}.issues[i];
2053
+ iss.path = iss.path ? [${k}, ...iss.path] : [${k}];
2054
+ payload.issues.push(iss);
2055
+ if (iss.continue !== true) ${id}_ab = true;
2056
+ }
2057
+ if (${id}_ab && ctx && ctx.abortEarly) {
2058
+ payload.value = newResult;
2059
+ return payload;
2060
+ }`;
1602
2061
  doc.write(`const input = payload.value;`);
1603
2062
  const ids = Object.create(null);
1604
2063
  let counter = 0;
1605
- for (const key of normalized.keys) ids[key] = `key_${counter++}`;
1606
- doc.write(`const newResult = {};`);
1607
- for (const key of normalized.keys) {
2064
+ for (const key of normalized.allKeys) ids[key] = `key_${counter++}`;
2065
+ doc.write(memo ? `const newResult = memo.alloc(inst, payload, {}, ctx);` : `const newResult = {};`);
2066
+ for (const key of normalized.allKeys) {
2067
+ if (key === "__proto__") continue;
1608
2068
  const id = ids[key];
1609
- const k = esc(key);
2069
+ const k = typeof key === "symbol" ? `syms[${syms.indexOf(key)}]` : esc(key);
2070
+ const isPresent = `${k} in input`;
1610
2071
  const schema = shape[key];
1611
- const isOptionalIn = schema?._zod?.optin === "optional";
2072
+ const optin = schema?._zod?.optin;
2073
+ const isOptionalIn = optin !== void 0;
1612
2074
  const isOptionalOut = schema?._zod?.optout === "optional";
1613
- doc.write(`const ${id} = ${parseStr(key)};`);
1614
- if (isOptionalIn && isOptionalOut) doc.write(`
1615
- if (${id}.issues.length) {
1616
- if (${k} in input) {
1617
- payload.issues = payload.issues.concat(${id}.issues.map(iss => ({
1618
- ...iss,
1619
- path: iss.path ? [${k}, ...iss.path] : [${k}]
1620
- })));
2075
+ doc.write(`const ${id} = ${parseStr(k)};`);
2076
+ if (isOptionalIn && isOptionalOut) {
2077
+ const assign = optin === "optional" ? `${id}_present` : `${id}.value !== undefined || ${id}_present`;
2078
+ doc.write(`
2079
+ const ${id}_present = ${isPresent};
2080
+ if (!${id}.issues.length || ${id}_present) {
2081
+ if (${id}.issues.length) {${prefixStr(id, k)}
1621
2082
  }
1622
- }
1623
-
1624
- if (${id}.value === undefined) {
1625
- if (${k} in input) {
1626
- newResult[${k}] = undefined;
2083
+
2084
+ if (${assign}) {
2085
+ newResult[${k}] = ${id}.value;
1627
2086
  }
1628
- } else {
1629
- newResult[${k}] = ${id}.value;
1630
2087
  }
1631
-
2088
+
1632
2089
  `);
1633
- else if (!isOptionalIn) doc.write(`
1634
- const ${id}_present = ${k} in input;
1635
- if (${id}.issues.length) {
1636
- payload.issues = payload.issues.concat(${id}.issues.map(iss => ({
1637
- ...iss,
1638
- path: iss.path ? [${k}, ...iss.path] : [${k}]
1639
- })));
2090
+ } else if (!isOptionalIn) doc.write(`
2091
+ const ${id}_present = ${isPresent};
2092
+ if (${id}.issues.length) {${prefixStr(id, k)}
1640
2093
  }
1641
2094
  if (!${id}_present && !${id}.issues.length) {
1642
2095
  payload.issues.push({
@@ -1645,39 +2098,33 @@ var $ZodObjectJIT = /*@__PURE__*/ $constructor("$ZodObjectJIT", (inst, def) => {
1645
2098
  input: undefined,
1646
2099
  path: [${k}]
1647
2100
  });
2101
+ if (ctx && ctx.abortEarly) {
2102
+ payload.value = newResult;
2103
+ return payload;
2104
+ }
1648
2105
  }
1649
2106
 
1650
2107
  if (${id}_present) {
1651
- if (${id}.value === undefined) {
1652
- newResult[${k}] = undefined;
1653
- } else {
1654
- newResult[${k}] = ${id}.value;
1655
- }
2108
+ newResult[${k}] = ${id}.value;
1656
2109
  }
1657
2110
 
1658
2111
  `);
1659
- else doc.write(`
1660
- if (${id}.issues.length) {
1661
- payload.issues = payload.issues.concat(${id}.issues.map(iss => ({
1662
- ...iss,
1663
- path: iss.path ? [${k}, ...iss.path] : [${k}]
1664
- })));
2112
+ else {
2113
+ doc.write(`
2114
+ if (${id}.issues.length) {${prefixStr(id, k)}
1665
2115
  }
1666
-
1667
- if (${id}.value === undefined) {
1668
- if (${k} in input) {
1669
- newResult[${k}] = undefined;
1670
- }
1671
- } else {
2116
+ `);
2117
+ if (optin === "defaulted") doc.write(`newResult[${k}] = ${id}.value;`);
2118
+ else doc.write(`
2119
+ if (${id}.value !== undefined || ${isPresent}) {
1672
2120
  newResult[${k}] = ${id}.value;
1673
2121
  }
1674
-
1675
2122
  `);
2123
+ }
1676
2124
  }
1677
2125
  doc.write(`payload.value = newResult;`);
1678
2126
  doc.write(`return payload;`);
1679
- const fn = doc.compile();
1680
- return (payload, ctx) => fn(shape, payload, ctx);
2127
+ return doc.compile();
1681
2128
  };
1682
2129
  let fastpass;
1683
2130
  const isObject$2 = isObject;
@@ -1701,7 +2148,7 @@ var $ZodObjectJIT = /*@__PURE__*/ $constructor("$ZodObjectJIT", (inst, def) => {
1701
2148
  if (!fastpass) fastpass = generateFastpass(def.shape);
1702
2149
  payload = fastpass(payload, ctx);
1703
2150
  if (!catchall) return payload;
1704
- return handleCatchall([], input, payload, ctx, value, inst);
2151
+ return handleCatchall([], input, payload, ctx, value, inst, ctx?.abortEarly === true);
1705
2152
  }
1706
2153
  return superParse(payload, ctx);
1707
2154
  };
@@ -1726,14 +2173,14 @@ function handleUnionResults(results, final, inst, ctx) {
1726
2173
  }
1727
2174
  var $ZodUnion = /*@__PURE__*/ $constructor("$ZodUnion", (inst, def) => {
1728
2175
  $ZodType.init(inst, def);
1729
- defineLazy(inst._zod, "optin", () => def.options.some((o) => o._zod.optin === "optional") ? "optional" : void 0);
1730
- defineLazy(inst._zod, "optout", () => def.options.some((o) => o._zod.optout === "optional") ? "optional" : void 0);
1731
- defineLazy(inst._zod, "values", () => {
1732
- if (def.options.every((o) => o._zod.values)) return new Set(def.options.flatMap((option) => Array.from(option._zod.values)));
2176
+ defineLazyInternal(inst, "optin", (zod) => zod.def.options.some((o) => o._zod.optin === "defaulted") ? "defaulted" : zod.def.options.some((o) => o._zod.optin !== void 0) ? "optional" : void 0);
2177
+ defineLazyInternal(inst, "optout", (zod) => zod.def.options.some((o) => o._zod.optout === "optional") ? "optional" : void 0);
2178
+ defineLazyInternal(inst, "values", (zod) => {
2179
+ if (zod.def.options.every((o) => o._zod.values)) return new Set(zod.def.options.flatMap((option) => Array.from(option._zod.values)));
1733
2180
  });
1734
- defineLazy(inst._zod, "pattern", () => {
1735
- if (def.options.every((o) => o._zod.pattern)) {
1736
- const patterns = def.options.map((o) => o._zod.pattern);
2181
+ defineLazyInternal(inst, "pattern", (zod) => {
2182
+ if (zod.def.options.every((o) => o._zod.pattern)) {
2183
+ const patterns = zod.def.options.map((o) => o._zod.pattern);
1737
2184
  return new RegExp(`^(${patterns.map((p) => cleanRegex(p.source)).join("|")})$`);
1738
2185
  }
1739
2186
  });
@@ -1761,35 +2208,42 @@ var $ZodUnion = /*@__PURE__*/ $constructor("$ZodUnion", (inst, def) => {
1761
2208
  });
1762
2209
  };
1763
2210
  });
2211
+ function discriminatorMap(def) {
2212
+ const map = /* @__PURE__ */ new Map();
2213
+ for (const option of def.options) {
2214
+ const values = option._zod.propValues?.[def.discriminator];
2215
+ if (!values || values.size === 0) throw new Error(`Invalid discriminated union option at index "${def.options.indexOf(option)}"`);
2216
+ for (const value of values) if (map.has(value)) {
2217
+ if (value !== void 0) throw new Error(`Duplicate discriminator value "${String(value)}"`);
2218
+ map.set(value, null);
2219
+ } else map.set(value, option);
2220
+ }
2221
+ return map;
2222
+ }
1764
2223
  var $ZodDiscriminatedUnion = /*@__PURE__*/ $constructor("$ZodDiscriminatedUnion", (inst, def) => {
1765
2224
  def.inclusive = false;
1766
2225
  $ZodUnion.init(inst, def);
1767
2226
  const _super = inst._zod.parse;
1768
- defineLazy(inst._zod, "propValues", () => {
2227
+ defineLazyInternal(inst, "propValues", (zod) => {
1769
2228
  const propValues = {};
1770
- for (const option of def.options) {
2229
+ let undefinedCount = 0;
2230
+ for (const option of zod.def.options) {
1771
2231
  const pv = option._zod.propValues;
1772
- if (!pv || Object.keys(pv).length === 0) throw new Error(`Invalid discriminated union option at index "${def.options.indexOf(option)}"`);
2232
+ if (!pv || Object.keys(pv).length === 0) throw new Error(`Invalid discriminated union option at index "${zod.def.options.indexOf(option)}"`);
2233
+ if (pv[zod.def.discriminator]?.has(void 0)) undefinedCount++;
1773
2234
  for (const [k, v] of Object.entries(pv)) {
1774
- if (!propValues[k]) propValues[k] = /* @__PURE__ */ new Set();
2235
+ if (!Object.prototype.hasOwnProperty.call(propValues, k)) assignProp(propValues, k, /* @__PURE__ */ new Set());
1775
2236
  for (const val of v) propValues[k].add(val);
1776
2237
  }
1777
2238
  }
2239
+ if (!zod.def.unionFallback && undefinedCount > 1) propValues[zod.def.discriminator]?.delete(void 0);
1778
2240
  return propValues;
1779
2241
  });
1780
- const disc = cached(() => {
1781
- const opts = def.options;
1782
- const map = /* @__PURE__ */ new Map();
1783
- for (const o of opts) {
1784
- const values = o._zod.propValues?.[def.discriminator];
1785
- if (!values || values.size === 0) throw new Error(`Invalid discriminated union option at index "${def.options.indexOf(o)}"`);
1786
- for (const v of values) {
1787
- if (map.has(v)) throw new Error(`Duplicate discriminator value "${String(v)}"`);
1788
- map.set(v, o);
1789
- }
1790
- }
1791
- return map;
2242
+ def.options.forEach((option, i) => {
2243
+ const propShape = rawShape(option._zod.def);
2244
+ if (propShape && !Object.prototype.hasOwnProperty.call(propShape, def.discriminator)) throw new Error(`Invalid discriminated union option at index "${i}"`);
1792
2245
  });
2246
+ const disc = cached(() => discriminatorMap(def));
1793
2247
  inst._zod.parse = (payload, ctx) => {
1794
2248
  const input = payload.value;
1795
2249
  if (!isObject(input)) {
@@ -1801,15 +2255,16 @@ var $ZodDiscriminatedUnion = /*@__PURE__*/ $constructor("$ZodDiscriminatedUnion"
1801
2255
  });
1802
2256
  return payload;
1803
2257
  }
1804
- const opt = disc.value.get(input?.[def.discriminator]);
1805
- if (opt) return opt._zod.run(payload, ctx);
2258
+ const value = input?.[def.discriminator];
2259
+ const opt = disc.value.get(value);
2260
+ if (opt && (value !== void 0 || ctx.direction !== "backward")) return opt._zod.run(payload, ctx);
1806
2261
  if (def.unionFallback || ctx.direction === "backward") return _super(payload, ctx);
1807
2262
  payload.issues.push({
1808
2263
  code: "invalid_union",
1809
2264
  errors: [],
1810
2265
  note: "No matching discriminator",
1811
2266
  discriminator: def.discriminator,
1812
- options: Array.from(disc.value.keys()),
2267
+ options: Array.from(disc.value.keys()).filter((value) => disc.value.get(value) !== null),
1813
2268
  input,
1814
2269
  path: [def.discriminator],
1815
2270
  inst
@@ -1851,7 +2306,9 @@ function mergeValues(a, b) {
1851
2306
  ...a,
1852
2307
  ...b
1853
2308
  };
2309
+ if (Object.prototype.hasOwnProperty.call(newObj, "__proto__")) delete newObj.__proto__;
1854
2310
  for (const key of sharedKeys) {
2311
+ if (key === "__proto__") continue;
1855
2312
  const sharedValue = mergeValues(a[key], b[key]);
1856
2313
  if (!sharedValue.valid) return {
1857
2314
  valid: false,
@@ -1893,31 +2350,46 @@ function mergeValues(a, b) {
1893
2350
  function handleIntersectionResults(result, left, right) {
1894
2351
  const unrecKeys = /* @__PURE__ */ new Map();
1895
2352
  let unrecIssue;
1896
- for (const iss of left.issues) if (iss.code === "unrecognized_keys") {
1897
- unrecIssue ?? (unrecIssue = iss);
1898
- for (const k of iss.keys) {
2353
+ const keyIssues = /* @__PURE__ */ new Map();
2354
+ const collect = (iss, side) => {
2355
+ let keys;
2356
+ if (iss.code === "unrecognized_keys" && !iss.path?.length) {
2357
+ unrecIssue ?? (unrecIssue = iss);
2358
+ keys = iss.keys;
2359
+ } else if (iss.code === "invalid_key" && iss.origin === "record" && iss.path?.length === 1) {
2360
+ const k = String(iss.path[0]);
2361
+ if (!keyIssues.has(k)) keyIssues.set(k, iss);
2362
+ keys = [k];
2363
+ } else return false;
2364
+ for (const k of keys) {
1899
2365
  if (!unrecKeys.has(k)) unrecKeys.set(k, {});
1900
- unrecKeys.get(k).l = true;
2366
+ unrecKeys.get(k)[side] = true;
1901
2367
  }
1902
- } else result.issues.push(iss);
1903
- for (const iss of right.issues) if (iss.code === "unrecognized_keys") for (const k of iss.keys) {
1904
- if (!unrecKeys.has(k)) unrecKeys.set(k, {});
1905
- unrecKeys.get(k).r = true;
1906
- }
1907
- else result.issues.push(iss);
2368
+ return true;
2369
+ };
2370
+ for (const iss of left.issues) if (!collect(iss, "l")) result.issues.push(iss);
2371
+ for (const iss of right.issues) if (!collect(iss, "r")) result.issues.push(iss);
1908
2372
  const bothKeys = [...unrecKeys].filter(([, f]) => f.l && f.r).map(([k]) => k);
1909
- if (bothKeys.length && unrecIssue) result.issues.push({
1910
- ...unrecIssue,
1911
- keys: bothKeys
1912
- });
1913
- if (aborted(result)) return result;
2373
+ if (bothKeys.length) {
2374
+ const aggregated = unrecIssue ? bothKeys.filter((k) => unrecIssue.keys.includes(k)) : [];
2375
+ if (aggregated.length) result.issues.push({
2376
+ ...unrecIssue,
2377
+ keys: aggregated
2378
+ });
2379
+ for (const k of bothKeys) if (!aggregated.includes(k) && keyIssues.has(k)) result.issues.push(keyIssues.get(k));
2380
+ }
1914
2381
  const merged = mergeValues(left.value, right.value);
1915
- if (!merged.valid) throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(merged.mergeErrorPath)}`);
2382
+ if (!merged.valid) {
2383
+ if (aborted(result)) return result;
2384
+ throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(merged.mergeErrorPath)}`);
2385
+ }
1916
2386
  result.value = merged.data;
1917
2387
  return result;
1918
2388
  }
1919
2389
  var $ZodRecord = /*@__PURE__*/ $constructor("$ZodRecord", (inst, def) => {
1920
2390
  $ZodType.init(inst, def);
2391
+ const memo = globalConfig.memoizer;
2392
+ memo?.attach(inst);
1921
2393
  inst._zod.parse = (payload, ctx) => {
1922
2394
  const input = payload.value;
1923
2395
  if (!isPlainObject(input)) {
@@ -1931,11 +2403,12 @@ var $ZodRecord = /*@__PURE__*/ $constructor("$ZodRecord", (inst, def) => {
1931
2403
  }
1932
2404
  const proms = [];
1933
2405
  const values = def.keyType._zod.values;
1934
- if (values) {
1935
- payload.value = {};
2406
+ if (values && !def.partial) {
2407
+ payload.value = memo ? memo.alloc(inst, payload, {}, ctx) : {};
1936
2408
  const recordKeys = /* @__PURE__ */ new Set();
1937
2409
  for (const key of values) if (typeof key === "string" || typeof key === "number" || typeof key === "symbol") {
1938
2410
  recordKeys.add(typeof key === "number" ? key.toString() : key);
2411
+ if (key === "__proto__") continue;
1939
2412
  const keyResult = def.keyType._zod.run({
1940
2413
  value: key,
1941
2414
  issues: []
@@ -1953,6 +2426,7 @@ var $ZodRecord = /*@__PURE__*/ $constructor("$ZodRecord", (inst, def) => {
1953
2426
  continue;
1954
2427
  }
1955
2428
  const outKey = keyResult.value;
2429
+ if (outKey === "__proto__") continue;
1956
2430
  const result = def.valueType._zod.run({
1957
2431
  value: input[key],
1958
2432
  issues: []
@@ -1967,7 +2441,10 @@ var $ZodRecord = /*@__PURE__*/ $constructor("$ZodRecord", (inst, def) => {
1967
2441
  }
1968
2442
  }
1969
2443
  let unrecognized;
1970
- for (const key in input) if (!recordKeys.has(key)) {
2444
+ for (const key in input) if (!recordKeys.has(key)) if (def.mode === "loose") {
2445
+ if (key === "__proto__") continue;
2446
+ payload.value[key] = input[key];
2447
+ } else {
1971
2448
  unrecognized = unrecognized ?? [];
1972
2449
  unrecognized.push(key);
1973
2450
  }
@@ -1975,10 +2452,12 @@ var $ZodRecord = /*@__PURE__*/ $constructor("$ZodRecord", (inst, def) => {
1975
2452
  code: "unrecognized_keys",
1976
2453
  input,
1977
2454
  inst,
1978
- keys: unrecognized
2455
+ keys: unrecognized,
2456
+ continue: true
1979
2457
  });
1980
2458
  } else {
1981
- payload.value = {};
2459
+ payload.value = memo ? memo.alloc(inst, payload, {}, ctx) : {};
2460
+ let unrecognized;
1982
2461
  for (const key of Reflect.ownKeys(input)) {
1983
2462
  if (key === "__proto__") continue;
1984
2463
  if (!Object.prototype.propertyIsEnumerable.call(input, key)) continue;
@@ -1997,7 +2476,10 @@ var $ZodRecord = /*@__PURE__*/ $constructor("$ZodRecord", (inst, def) => {
1997
2476
  }
1998
2477
  if (keyResult.issues.length) {
1999
2478
  if (def.mode === "loose") payload.value[key] = input[key];
2000
- else payload.issues.push({
2479
+ else if (values) {
2480
+ unrecognized = unrecognized ?? [];
2481
+ unrecognized.push(key);
2482
+ } else payload.issues.push({
2001
2483
  code: "invalid_key",
2002
2484
  origin: "record",
2003
2485
  issues: keyResult.issues.map((iss) => finalizeIssue(iss, ctx, config())),
@@ -2007,19 +2489,28 @@ var $ZodRecord = /*@__PURE__*/ $constructor("$ZodRecord", (inst, def) => {
2007
2489
  });
2008
2490
  continue;
2009
2491
  }
2492
+ const outKey = keyResult.value;
2493
+ if (outKey === "__proto__") continue;
2010
2494
  const result = def.valueType._zod.run({
2011
2495
  value: input[key],
2012
2496
  issues: []
2013
2497
  }, ctx);
2014
2498
  if (result instanceof Promise) proms.push(result.then((result) => {
2015
2499
  if (result.issues.length) payload.issues.push(...prefixIssues(key, result.issues));
2016
- payload.value[keyResult.value] = result.value;
2500
+ payload.value[outKey] = result.value;
2017
2501
  }));
2018
2502
  else {
2019
2503
  if (result.issues.length) payload.issues.push(...prefixIssues(key, result.issues));
2020
- payload.value[keyResult.value] = result.value;
2504
+ payload.value[outKey] = result.value;
2021
2505
  }
2022
2506
  }
2507
+ if (unrecognized && unrecognized.length > 0) payload.issues.push({
2508
+ code: "unrecognized_keys",
2509
+ input,
2510
+ inst,
2511
+ keys: unrecognized,
2512
+ continue: true
2513
+ });
2023
2514
  }
2024
2515
  if (proms.length) return Promise.all(proms).then(() => payload);
2025
2516
  return payload;
@@ -2030,7 +2521,10 @@ var $ZodEnum = /*@__PURE__*/ $constructor("$ZodEnum", (inst, def) => {
2030
2521
  const values = getEnumValues(def.entries);
2031
2522
  const valuesSet = new Set(values);
2032
2523
  inst._zod.values = valuesSet;
2033
- inst._zod.pattern = new RegExp(`^(${values.filter((k) => propertyKeyTypes.has(typeof k)).map((o) => typeof o === "string" ? escapeRegex(o) : o.toString()).join("|")})$`);
2524
+ defineLazyInternal(inst, "pattern", (zod) => {
2525
+ const patternValues = getEnumValues(zod.def.entries).filter((k) => propertyKeyTypes.has(typeof k));
2526
+ return new RegExp(patternValues.length ? `^(${patternValues.map((o) => escapeRegex(o.toString())).join("|")})$` : "^[^\\s\\S]$");
2527
+ });
2034
2528
  inst._zod.parse = (payload, _ctx) => {
2035
2529
  const input = payload.value;
2036
2530
  if (valuesSet.has(input)) return payload;
@@ -2045,10 +2539,12 @@ var $ZodEnum = /*@__PURE__*/ $constructor("$ZodEnum", (inst, def) => {
2045
2539
  });
2046
2540
  var $ZodLiteral = /*@__PURE__*/ $constructor("$ZodLiteral", (inst, def) => {
2047
2541
  $ZodType.init(inst, def);
2048
- if (def.values.length === 0) throw new Error("Cannot create literal schema with no valid values");
2049
2542
  const values = new Set(def.values);
2050
2543
  inst._zod.values = values;
2051
- inst._zod.pattern = new RegExp(`^(${def.values.map((o) => typeof o === "string" ? escapeRegex(o) : o ? escapeRegex(o.toString()) : String(o)).join("|")})$`);
2544
+ defineLazyInternal(inst, "pattern", (zod) => {
2545
+ const vals = zod.def.values;
2546
+ return new RegExp(vals.length ? `^(${vals.map((o) => typeof o === "string" ? escapeRegex(o) : o ? escapeRegex(o.toString()) : String(o)).join("|")})$` : "^[^\\s\\S]$");
2547
+ });
2052
2548
  inst._zod.parse = (payload, _ctx) => {
2053
2549
  const input = payload.value;
2054
2550
  if (values.has(input)) return payload;
@@ -2064,67 +2560,66 @@ var $ZodLiteral = /*@__PURE__*/ $constructor("$ZodLiteral", (inst, def) => {
2064
2560
  var $ZodTransform = /*@__PURE__*/ $constructor("$ZodTransform", (inst, def) => {
2065
2561
  $ZodType.init(inst, def);
2066
2562
  inst._zod.optin = "optional";
2563
+ globalConfig.memoizer?.guard(inst);
2067
2564
  inst._zod.parse = (payload, ctx) => {
2068
2565
  if (ctx.direction === "backward") throw new $ZodEncodeError(inst.constructor.name);
2069
2566
  const _out = def.transform(payload.value, payload);
2070
2567
  if (ctx.async) return (_out instanceof Promise ? _out : Promise.resolve(_out)).then((output) => {
2071
2568
  payload.value = output;
2072
- payload.fallback = true;
2073
2569
  return payload;
2074
2570
  });
2075
2571
  if (_out instanceof Promise) throw new $ZodAsyncError();
2076
2572
  payload.value = _out;
2077
- payload.fallback = true;
2078
2573
  return payload;
2079
2574
  };
2080
2575
  });
2081
- function handleOptionalResult(result, input) {
2082
- if (input === void 0 && (result.issues.length || result.fallback)) return {
2083
- issues: [],
2084
- value: void 0
2085
- };
2086
- return result;
2576
+ function handleOptionalResult(payload, result) {
2577
+ payload.value = result.issues.length ? void 0 : result.value;
2578
+ return payload;
2087
2579
  }
2088
2580
  var $ZodOptional = /*@__PURE__*/ $constructor("$ZodOptional", (inst, def) => {
2089
2581
  $ZodType.init(inst, def);
2090
- inst._zod.optin = "optional";
2582
+ defineLazyInternal(inst, "optin", (zod) => zod.def.innerType._zod.optin === "defaulted" ? "defaulted" : "optional");
2091
2583
  inst._zod.optout = "optional";
2092
- defineLazy(inst._zod, "values", () => {
2093
- return def.innerType._zod.values ? new Set([...def.innerType._zod.values, void 0]) : void 0;
2584
+ defineLazyInternal(inst, "values", (zod) => {
2585
+ const values = zod.def.innerType._zod.values;
2586
+ return values ? new Set([...values, void 0]) : void 0;
2094
2587
  });
2095
- defineLazy(inst._zod, "pattern", () => {
2096
- const pattern = def.innerType._zod.pattern;
2588
+ defineLazyInternal(inst, "pattern", (zod) => {
2589
+ const pattern = zod.def.innerType._zod.pattern;
2097
2590
  return pattern ? new RegExp(`^(${cleanRegex(pattern.source)})?$`) : void 0;
2098
2591
  });
2099
2592
  inst._zod.parse = (payload, ctx) => {
2100
- if (def.innerType._zod.optin === "optional") {
2101
- const input = payload.value;
2102
- const result = def.innerType._zod.run(payload, ctx);
2103
- if (result instanceof Promise) return result.then((r) => handleOptionalResult(r, input));
2104
- return handleOptionalResult(result, input);
2593
+ if (payload.value === void 0) {
2594
+ if (def.innerType._zod.optin !== "defaulted") return payload;
2595
+ const result = def.innerType._zod.run({
2596
+ value: payload.value,
2597
+ issues: []
2598
+ }, ctx);
2599
+ if (result instanceof Promise) return result.then((result) => handleOptionalResult(payload, result));
2600
+ return handleOptionalResult(payload, result);
2105
2601
  }
2106
- if (payload.value === void 0) return payload;
2107
2602
  return def.innerType._zod.run(payload, ctx);
2108
2603
  };
2109
2604
  });
2110
2605
  var $ZodExactOptional = /*@__PURE__*/ $constructor("$ZodExactOptional", (inst, def) => {
2111
2606
  $ZodOptional.init(inst, def);
2112
- defineLazy(inst._zod, "values", () => def.innerType._zod.values);
2113
- defineLazy(inst._zod, "pattern", () => def.innerType._zod.pattern);
2607
+ defineLazyInternal(inst, "values", (zod) => zod.def.innerType._zod.values);
2608
+ defineLazyInternal(inst, "pattern", (zod) => zod.def.innerType._zod.pattern);
2114
2609
  inst._zod.parse = (payload, ctx) => {
2115
2610
  return def.innerType._zod.run(payload, ctx);
2116
2611
  };
2117
2612
  });
2118
2613
  var $ZodNullable = /*@__PURE__*/ $constructor("$ZodNullable", (inst, def) => {
2119
2614
  $ZodType.init(inst, def);
2120
- defineLazy(inst._zod, "optin", () => def.innerType._zod.optin);
2121
- defineLazy(inst._zod, "optout", () => def.innerType._zod.optout);
2122
- defineLazy(inst._zod, "pattern", () => {
2123
- const pattern = def.innerType._zod.pattern;
2615
+ defineLazyInternal(inst, "optin", (zod) => zod.def.innerType._zod.optin);
2616
+ defineLazyInternal(inst, "optout", (zod) => zod.def.innerType._zod.optout);
2617
+ defineLazyInternal(inst, "pattern", (zod) => {
2618
+ const pattern = zod.def.innerType._zod.pattern;
2124
2619
  return pattern ? new RegExp(`^(${cleanRegex(pattern.source)}|null)$`) : void 0;
2125
2620
  });
2126
- defineLazy(inst._zod, "values", () => {
2127
- return def.innerType._zod.values ? new Set([...def.innerType._zod.values, null]) : void 0;
2621
+ defineLazyInternal(inst, "values", (zod) => {
2622
+ return zod.def.innerType._zod.values ? new Set([...zod.def.innerType._zod.values, null]) : void 0;
2128
2623
  });
2129
2624
  inst._zod.parse = (payload, ctx) => {
2130
2625
  if (payload.value === null) return payload;
@@ -2133,8 +2628,8 @@ var $ZodNullable = /*@__PURE__*/ $constructor("$ZodNullable", (inst, def) => {
2133
2628
  });
2134
2629
  var $ZodDefault = /*@__PURE__*/ $constructor("$ZodDefault", (inst, def) => {
2135
2630
  $ZodType.init(inst, def);
2136
- inst._zod.optin = "optional";
2137
- defineLazy(inst._zod, "values", () => def.innerType._zod.values);
2631
+ inst._zod.optin = "defaulted";
2632
+ defineLazyInternal(inst, "values", (zod) => zod.def.innerType._zod.values);
2138
2633
  inst._zod.parse = (payload, ctx) => {
2139
2634
  if (ctx.direction === "backward") return def.innerType._zod.run(payload, ctx);
2140
2635
  if (payload.value === void 0) {
@@ -2155,8 +2650,8 @@ function handleDefaultResult(payload, def) {
2155
2650
  }
2156
2651
  var $ZodPrefault = /*@__PURE__*/ $constructor("$ZodPrefault", (inst, def) => {
2157
2652
  $ZodType.init(inst, def);
2158
- inst._zod.optin = "optional";
2159
- defineLazy(inst._zod, "values", () => def.innerType._zod.values);
2653
+ inst._zod.optin = "defaulted";
2654
+ defineLazyInternal(inst, "values", (zod) => zod.def.innerType._zod.values);
2160
2655
  inst._zod.parse = (payload, ctx) => {
2161
2656
  if (ctx.direction === "backward") return def.innerType._zod.run(payload, ctx);
2162
2657
  if (payload.value === void 0) payload.value = def.defaultValue;
@@ -2165,8 +2660,8 @@ var $ZodPrefault = /*@__PURE__*/ $constructor("$ZodPrefault", (inst, def) => {
2165
2660
  });
2166
2661
  var $ZodNonOptional = /*@__PURE__*/ $constructor("$ZodNonOptional", (inst, def) => {
2167
2662
  $ZodType.init(inst, def);
2168
- defineLazy(inst._zod, "values", () => {
2169
- const v = def.innerType._zod.values;
2663
+ defineLazyInternal(inst, "values", (zod) => {
2664
+ const v = zod.def.innerType._zod.values;
2170
2665
  return v ? new Set([...v].filter((x) => x !== void 0)) : void 0;
2171
2666
  });
2172
2667
  inst._zod.parse = (payload, ctx) => {
@@ -2184,46 +2679,41 @@ function handleNonOptionalResult(payload, inst) {
2184
2679
  });
2185
2680
  return payload;
2186
2681
  }
2682
+ function handleCatchResult(payload, result, def, ctx) {
2683
+ if (!result.issues.length) {
2684
+ payload.value = result.value;
2685
+ if (result.memo) payload.memo = true;
2686
+ return payload;
2687
+ }
2688
+ payload.value = def.catchValue({
2689
+ ...result,
2690
+ value: payload.value,
2691
+ error: { issues: result.issues.map((iss) => finalizeIssue(iss, ctx, config())) },
2692
+ input: payload.value
2693
+ });
2694
+ return payload;
2695
+ }
2187
2696
  var $ZodCatch = /*@__PURE__*/ $constructor("$ZodCatch", (inst, def) => {
2188
2697
  $ZodType.init(inst, def);
2189
- inst._zod.optin = "optional";
2190
- defineLazy(inst._zod, "optout", () => def.innerType._zod.optout);
2191
- defineLazy(inst._zod, "values", () => def.innerType._zod.values);
2698
+ defineLazyInternal(inst, "optin", (zod) => zod.def.innerType._zod.optin === "defaulted" ? "defaulted" : "optional");
2699
+ defineLazyInternal(inst, "optout", (zod) => zod.def.innerType._zod.optout);
2700
+ defineLazyInternal(inst, "values", (zod) => zod.def.innerType._zod.values);
2192
2701
  inst._zod.parse = (payload, ctx) => {
2193
2702
  if (ctx.direction === "backward") return def.innerType._zod.run(payload, ctx);
2194
- const result = def.innerType._zod.run(payload, ctx);
2195
- if (result instanceof Promise) return result.then((result) => {
2196
- payload.value = result.value;
2197
- if (result.issues.length) {
2198
- payload.value = def.catchValue({
2199
- ...payload,
2200
- error: { issues: result.issues.map((iss) => finalizeIssue(iss, ctx, config())) },
2201
- input: payload.value
2202
- });
2203
- payload.issues = [];
2204
- payload.fallback = true;
2205
- }
2206
- return payload;
2207
- });
2208
- payload.value = result.value;
2209
- if (result.issues.length) {
2210
- payload.value = def.catchValue({
2211
- ...payload,
2212
- error: { issues: result.issues.map((iss) => finalizeIssue(iss, ctx, config())) },
2213
- input: payload.value
2214
- });
2215
- payload.issues = [];
2216
- payload.fallback = true;
2217
- }
2218
- return payload;
2703
+ const result = def.innerType._zod.run({
2704
+ value: payload.value,
2705
+ issues: []
2706
+ }, ctx);
2707
+ if (result instanceof Promise) return result.then((result) => handleCatchResult(payload, result, def, ctx));
2708
+ return handleCatchResult(payload, result, def, ctx);
2219
2709
  };
2220
2710
  });
2221
2711
  var $ZodPipe = /*@__PURE__*/ $constructor("$ZodPipe", (inst, def) => {
2222
2712
  $ZodType.init(inst, def);
2223
- defineLazy(inst._zod, "values", () => def.in._zod.values);
2224
- defineLazy(inst._zod, "optin", () => def.in._zod.optin);
2225
- defineLazy(inst._zod, "optout", () => def.out._zod.optout);
2226
- defineLazy(inst._zod, "propValues", () => def.in._zod.propValues);
2713
+ defineLazyInternal(inst, "values", (zod) => zod.def.in._zod.values);
2714
+ defineLazyInternal(inst, "optin", (zod) => zod.def.in._zod.optin);
2715
+ defineLazyInternal(inst, "optout", (zod) => zod.def.out._zod.optout);
2716
+ defineLazyInternal(inst, "propValues", (zod) => zod.def.in._zod.propValues);
2227
2717
  inst._zod.parse = (payload, ctx) => {
2228
2718
  if (ctx.direction === "backward") {
2229
2719
  const right = def.out._zod.run(payload, ctx);
@@ -2236,22 +2726,21 @@ var $ZodPipe = /*@__PURE__*/ $constructor("$ZodPipe", (inst, def) => {
2236
2726
  };
2237
2727
  });
2238
2728
  function handlePipeResult(left, next, ctx) {
2239
- if (left.issues.length) {
2729
+ if (left.issues.some((iss) => iss.code !== "unrecognized_keys")) {
2240
2730
  left.aborted = true;
2241
2731
  return left;
2242
2732
  }
2243
2733
  return next._zod.run({
2244
2734
  value: left.value,
2245
- issues: left.issues,
2246
- fallback: left.fallback
2735
+ issues: left.issues
2247
2736
  }, ctx);
2248
2737
  }
2249
2738
  var $ZodReadonly = /*@__PURE__*/ $constructor("$ZodReadonly", (inst, def) => {
2250
2739
  $ZodType.init(inst, def);
2251
- defineLazy(inst._zod, "propValues", () => def.innerType._zod.propValues);
2252
- defineLazy(inst._zod, "values", () => def.innerType._zod.values);
2253
- defineLazy(inst._zod, "optin", () => def.innerType?._zod?.optin);
2254
- defineLazy(inst._zod, "optout", () => def.innerType?._zod?.optout);
2740
+ defineLazyInternal(inst, "propValues", (zod) => zod.def.innerType._zod.propValues);
2741
+ defineLazyInternal(inst, "values", (zod) => zod.def.innerType._zod.values);
2742
+ defineLazyInternal(inst, "optin", (zod) => zod.def.innerType?._zod?.optin);
2743
+ defineLazyInternal(inst, "optout", (zod) => zod.def.innerType?._zod?.optout);
2255
2744
  inst._zod.parse = (payload, ctx) => {
2256
2745
  if (ctx.direction === "backward") return def.innerType._zod.run(payload, ctx);
2257
2746
  const result = def.innerType._zod.run(payload, ctx);
@@ -2260,7 +2749,7 @@ var $ZodReadonly = /*@__PURE__*/ $constructor("$ZodReadonly", (inst, def) => {
2260
2749
  };
2261
2750
  });
2262
2751
  function handleReadonlyResult(payload) {
2263
- payload.value = Object.freeze(payload.value);
2752
+ if (!payload.memo) payload.value = Object.freeze(payload.value);
2264
2753
  return payload;
2265
2754
  }
2266
2755
  var $ZodCustom = /*@__PURE__*/ $constructor("$ZodCustom", (inst, def) => {
@@ -2290,7 +2779,368 @@ function handleRefineResult(result, payload, input, inst) {
2290
2779
  }
2291
2780
  }
2292
2781
  //#endregion
2293
- //#region ../../node_modules/.pnpm/zod@4.4.3/node_modules/zod/v4/core/registries.js
2782
+ //#region ../../node_modules/.pnpm/zod@4.6.5/node_modules/zod/v4/core/memoizer.js
2783
+ var $ZodCyclicError = class extends Error {
2784
+ constructor() {
2785
+ super(`Cannot parse a reference cycle that closes through a transform`);
2786
+ this.name = "ZodCyclicError";
2787
+ }
2788
+ };
2789
+ /** Keyed off the context object every schema in one parse call already shares. */
2790
+ var STATE = "~memo";
2791
+ var NO_ISSUES = [];
2792
+ function isRef(value) {
2793
+ return value !== null && typeof value === "object";
2794
+ }
2795
+ function cloneIssues(issues) {
2796
+ return issues.map((iss) => iss.path ? {
2797
+ ...iss,
2798
+ path: iss.path.slice()
2799
+ } : { ...iss });
2800
+ }
2801
+ var recursive = /*@__PURE__*/ new WeakMap();
2802
+ /** What the walk established, in order of certainty: ordered so the strongest answer among children wins. */
2803
+ var NONE = 0;
2804
+ var ASSUMED = 1;
2805
+ var PROVEN = 2;
2806
+ /** Whether this schema's subtree contains a cycle, so one parse can re-enter it. */
2807
+ function isRecursive(inst, stack, resolve) {
2808
+ const cached = recursive.get(inst);
2809
+ if (cached !== void 0) return cached ? PROVEN : NONE;
2810
+ if (stack.has(inst)) return PROVEN;
2811
+ stack.add(inst);
2812
+ let result = NONE;
2813
+ const check = (child) => {
2814
+ if (result !== PROVEN && child?._zod) {
2815
+ const answer = isRecursive(child, stack, resolve);
2816
+ if (answer > result) result = answer;
2817
+ }
2818
+ };
2819
+ const shape = (sh, spread) => {
2820
+ let answer = NONE;
2821
+ for (const key of Reflect.ownKeys(sh)) {
2822
+ const desc = Object.getOwnPropertyDescriptor(sh, key);
2823
+ if (spread && !desc.enumerable) continue;
2824
+ const child = desc.get ? ASSUMED : desc.value?._zod ? isRecursive(desc.value, stack, resolve) : NONE;
2825
+ if (child > answer) answer = child;
2826
+ }
2827
+ return answer;
2828
+ };
2829
+ const merge = (answer) => {
2830
+ if (answer > result) result = answer;
2831
+ };
2832
+ const def = inst._zod.def;
2833
+ switch (def.type) {
2834
+ case "object": {
2835
+ const raw = rawShape(def);
2836
+ merge(raw ? shape(raw, true) : ASSUMED);
2837
+ check(def.catchall);
2838
+ break;
2839
+ }
2840
+ case "array":
2841
+ check(def.element);
2842
+ break;
2843
+ case "tuple":
2844
+ for (const el of def.items) check(el);
2845
+ check(def.rest);
2846
+ break;
2847
+ case "record":
2848
+ case "map":
2849
+ check(def.keyType);
2850
+ check(def.valueType);
2851
+ break;
2852
+ case "set":
2853
+ check(def.valueType);
2854
+ break;
2855
+ case "union":
2856
+ for (const el of def.options) check(el);
2857
+ break;
2858
+ case "intersection":
2859
+ check(def.left);
2860
+ check(def.right);
2861
+ break;
2862
+ case "optional":
2863
+ case "nullable":
2864
+ case "default":
2865
+ case "prefault":
2866
+ case "catch":
2867
+ case "readonly":
2868
+ case "nonoptional":
2869
+ case "promise":
2870
+ case "success":
2871
+ check(def.innerType);
2872
+ break;
2873
+ case "pipe":
2874
+ check(def.in);
2875
+ check(def.out);
2876
+ break;
2877
+ case "function":
2878
+ check(def.input);
2879
+ check(def.output);
2880
+ break;
2881
+ case "lazy": {
2882
+ const inner = def._cachedInner ?? (resolve ? inst._zod.innerType : void 0);
2883
+ merge(inner ? isRecursive(inner, stack, false) : ASSUMED);
2884
+ break;
2885
+ }
2886
+ case "template_literal":
2887
+ case "string":
2888
+ case "number":
2889
+ case "int":
2890
+ case "boolean":
2891
+ case "bigint":
2892
+ case "symbol":
2893
+ case "undefined":
2894
+ case "null":
2895
+ case "void":
2896
+ case "never":
2897
+ case "any":
2898
+ case "unknown":
2899
+ case "date":
2900
+ case "nan":
2901
+ case "enum":
2902
+ case "literal":
2903
+ case "file":
2904
+ case "transform":
2905
+ case "custom": break;
2906
+ default: for (const key in def) {
2907
+ const desc = Object.getOwnPropertyDescriptor(def, key);
2908
+ if (!desc || desc.get) continue;
2909
+ const value = desc.value;
2910
+ if (!value || typeof value !== "object") continue;
2911
+ if (value._zod) check(value);
2912
+ else if (Array.isArray(value)) for (const el of value) check(el);
2913
+ }
2914
+ }
2915
+ stack.delete(inst);
2916
+ return settle(inst, result);
2917
+ }
2918
+ /** An assumed answer must not outlive the resolution that settles it, so only a certain one is cached. */
2919
+ function settle(inst, answer) {
2920
+ if (answer !== ASSUMED) recursive.set(inst, answer === PROVEN);
2921
+ return answer;
2922
+ }
2923
+ function bucketFor(state, inst) {
2924
+ let bucket = state.buckets.get(inst);
2925
+ if (!bucket) {
2926
+ bucket = /* @__PURE__ */ new WeakMap();
2927
+ state.buckets.set(inst, bucket);
2928
+ }
2929
+ return bucket;
2930
+ }
2931
+ var handoff;
2932
+ var open = [];
2933
+ var memo = {
2934
+ alloc(_inst, payload, empty) {
2935
+ const bucket = handoff;
2936
+ if (!bucket) return empty;
2937
+ handoff = void 0;
2938
+ const entry = {
2939
+ value: empty,
2940
+ issues: null
2941
+ };
2942
+ bucket.set(payload.value, entry);
2943
+ open.push(entry);
2944
+ return empty;
2945
+ },
2946
+ guard(inst) {
2947
+ var _a;
2948
+ (_a = inst._zod).deferred ?? (_a.deferred = []);
2949
+ inst._zod.deferred.push(() => {
2950
+ const base = inst._zod.parse;
2951
+ const wrapped = (payload, ctx) => {
2952
+ if (ctx.direction !== "backward" && isBackEdge(ctx, payload.value)) throw new $ZodCyclicError();
2953
+ return base(payload, ctx);
2954
+ };
2955
+ inst._zod.parse = wrapped;
2956
+ if (inst._zod.run === base) inst._zod.run = wrapped;
2957
+ });
2958
+ },
2959
+ attach(inst) {
2960
+ var _a;
2961
+ let isRecursiveInst;
2962
+ let rechecked = false;
2963
+ let lastCtx;
2964
+ let lastBucket;
2965
+ (_a = inst._zod).deferred ?? (_a.deferred = []);
2966
+ inst._zod.deferred.push(() => {
2967
+ const base = inst._zod.parse;
2968
+ const wrapped = (payload, ctx) => {
2969
+ if (isRecursiveInst === void 0) {
2970
+ const walked = isRecursive(inst, /* @__PURE__ */ new Set(), false);
2971
+ if (walked === NONE) {
2972
+ inst._zod.parse = base;
2973
+ if (inst._zod.run === wrapped) inst._zod.run = base;
2974
+ return base(payload, ctx);
2975
+ }
2976
+ if (walked === PROVEN || rechecked) isRecursiveInst = true;
2977
+ else rechecked = true;
2978
+ }
2979
+ const input = payload.value;
2980
+ if (!isRef(input)) return base(payload, ctx);
2981
+ let state = ctx[STATE];
2982
+ if (!state) {
2983
+ state = {
2984
+ buckets: /* @__PURE__ */ new WeakMap(),
2985
+ backEdges: void 0
2986
+ };
2987
+ ctx[STATE] = state;
2988
+ }
2989
+ let bucket;
2990
+ if (lastCtx === ctx) bucket = lastBucket;
2991
+ else {
2992
+ bucket = bucketFor(state, inst);
2993
+ lastCtx = ctx;
2994
+ lastBucket = bucket;
2995
+ }
2996
+ const hit = bucket.get(input);
2997
+ if (hit) {
2998
+ payload.value = hit.value;
2999
+ if (hit.issues) {
3000
+ if (hit.issues.length) payload.issues.push(...cloneIssues(hit.issues));
3001
+ } else {
3002
+ payload.memo = true;
3003
+ state.backEdges ?? (state.backEdges = /* @__PURE__ */ new WeakSet());
3004
+ state.backEdges.add(hit.value);
3005
+ }
3006
+ return payload;
3007
+ }
3008
+ handoff = bucket;
3009
+ const depth = open.length;
3010
+ const result = base(payload, ctx);
3011
+ handoff = void 0;
3012
+ const entry = open.length > depth ? open.pop() : void 0;
3013
+ if (result instanceof Promise) return result.then((r) => {
3014
+ if (entry) entry.issues = r.issues.length ? cloneIssues(r.issues) : NO_ISSUES;
3015
+ return r;
3016
+ });
3017
+ if (entry) entry.issues = result.issues.length ? cloneIssues(result.issues) : NO_ISSUES;
3018
+ return result;
3019
+ };
3020
+ inst._zod.parse = wrapped;
3021
+ if (inst._zod.run === base) inst._zod.run = wrapped;
3022
+ });
3023
+ }
3024
+ };
3025
+ /** The memoizer that gives containers cycle support. `zod` installs it by default; `zod/mini` opts in with `config({ memoizer: memoizer() })`. */
3026
+ function memoizer() {
3027
+ return memo;
3028
+ }
3029
+ /** Whether this value is a node a back-edge resolved to before it finished. */
3030
+ function isBackEdge(ctx, value) {
3031
+ const backEdges = ctx[STATE]?.backEdges;
3032
+ return backEdges !== void 0 && isRef(value) && backEdges.has(value);
3033
+ }
3034
+ //#endregion
3035
+ //#region ../../node_modules/.pnpm/zod@4.6.5/node_modules/zod/v4/locales/en.js
3036
+ var error = () => {
3037
+ const Sizable = {
3038
+ string: {
3039
+ unit: "characters",
3040
+ verb: "to have"
3041
+ },
3042
+ file: {
3043
+ unit: "bytes",
3044
+ verb: "to have"
3045
+ },
3046
+ array: {
3047
+ unit: "items",
3048
+ verb: "to have"
3049
+ },
3050
+ set: {
3051
+ unit: "items",
3052
+ verb: "to have"
3053
+ },
3054
+ map: {
3055
+ unit: "entries",
3056
+ verb: "to have"
3057
+ }
3058
+ };
3059
+ function getSizing(origin) {
3060
+ return Sizable[origin] ?? null;
3061
+ }
3062
+ const FormatDictionary = {
3063
+ regex: "input",
3064
+ email: "email address",
3065
+ url: "URL",
3066
+ emoji: "emoji",
3067
+ uuid: "UUID",
3068
+ uuidv4: "UUIDv4",
3069
+ uuidv6: "UUIDv6",
3070
+ nanoid: "nanoid",
3071
+ guid: "GUID",
3072
+ cuid: "cuid",
3073
+ cuid2: "cuid2",
3074
+ ulid: "ULID",
3075
+ xid: "XID",
3076
+ ksuid: "KSUID",
3077
+ datetime: "ISO datetime",
3078
+ date: "ISO date",
3079
+ time: "ISO time",
3080
+ duration: "ISO duration",
3081
+ ipv4: "IPv4 address",
3082
+ ipv6: "IPv6 address",
3083
+ mac: "MAC address",
3084
+ cidrv4: "IPv4 range",
3085
+ cidrv6: "IPv6 range",
3086
+ base64: "base64-encoded string",
3087
+ base64url: "base64url-encoded string",
3088
+ json_string: "JSON string",
3089
+ e164: "E.164 number",
3090
+ currency_code: "currency code",
3091
+ credit_card: "credit card number",
3092
+ iban: "IBAN",
3093
+ jwt: "JWT",
3094
+ template_literal: "input"
3095
+ };
3096
+ const TypeDictionary = { nan: "NaN" };
3097
+ function getTypeName(type, input) {
3098
+ if (type === "number" && typeof input === "number" && !Number.isFinite(input)) return String(input);
3099
+ return TypeDictionary[type] ?? type;
3100
+ }
3101
+ return (issue) => {
3102
+ switch (issue.code) {
3103
+ case "invalid_type": return `Invalid input: expected ${getTypeName(issue.expected)}, received ${getTypeName(parsedType(issue.input), issue.input)}`;
3104
+ case "invalid_value":
3105
+ if (issue.values.length === 1) return `Invalid input: expected ${stringifyPrimitive(issue.values[0])}`;
3106
+ return `Invalid option: expected one of ${joinValues(issue.values, "|")}`;
3107
+ case "too_big": {
3108
+ const adj = issue.exact ? "exactly " : issue.inclusive ? "<=" : "<";
3109
+ const sizing = getSizing(issue.origin);
3110
+ if (sizing) return `Too big: expected ${issue.origin ?? "value"} to have ${adj}${issue.maximum.toString()} ${sizing.unit ?? "elements"}`;
3111
+ return `Too big: expected ${issue.origin ?? "value"} to be ${adj}${issue.maximum.toString()}`;
3112
+ }
3113
+ case "too_small": {
3114
+ const adj = issue.exact ? "exactly " : issue.inclusive ? ">=" : ">";
3115
+ const sizing = getSizing(issue.origin);
3116
+ if (sizing) return `Too small: expected ${issue.origin} to have ${adj}${issue.minimum.toString()} ${sizing.unit}`;
3117
+ return `Too small: expected ${issue.origin} to be ${adj}${issue.minimum.toString()}`;
3118
+ }
3119
+ case "invalid_format": {
3120
+ const _issue = issue;
3121
+ if (_issue.format === "starts_with") return `Invalid string: must start with "${_issue.prefix}"`;
3122
+ if (_issue.format === "ends_with") return `Invalid string: must end with "${_issue.suffix}"`;
3123
+ if (_issue.format === "includes") return `Invalid string: must include "${_issue.includes}"`;
3124
+ if (_issue.format === "regex") return `Invalid string: must match pattern ${_issue.pattern}`;
3125
+ return `Invalid ${FormatDictionary[_issue.format] ?? issue.format}`;
3126
+ }
3127
+ case "not_multiple_of": return `Invalid number: must be a multiple of ${issue.divisor}`;
3128
+ case "unrecognized_keys": return `Unrecognized key${issue.keys.length > 1 ? "s" : ""}: ${joinValues(issue.keys, ", ")}`;
3129
+ case "invalid_key": return `Invalid key in ${issue.origin}`;
3130
+ case "invalid_union":
3131
+ if (issue.options && Array.isArray(issue.options) && issue.options.length > 0) return `Invalid discriminator value. Expected ${issue.options.map((o) => `'${o}'`).join(" | ")}`;
3132
+ if (issue.inclusive === false) return "Invalid input: more than one option matched";
3133
+ return "Invalid input";
3134
+ case "invalid_element": return `Invalid value in ${issue.origin}`;
3135
+ default: return `Invalid input`;
3136
+ }
3137
+ };
3138
+ };
3139
+ function en_default() {
3140
+ return { localeError: error() };
3141
+ }
3142
+ //#endregion
3143
+ //#region ../../node_modules/.pnpm/zod@4.6.5/node_modules/zod/v4/core/registries.js
2294
3144
  var _a;
2295
3145
  var $ZodRegistry = class {
2296
3146
  constructor() {
@@ -2337,13 +3187,17 @@ function registry() {
2337
3187
  (_a = globalThis).__zod_globalRegistry ?? (_a.__zod_globalRegistry = registry());
2338
3188
  var globalRegistry = globalThis.__zod_globalRegistry;
2339
3189
  //#endregion
2340
- //#region ../../node_modules/.pnpm/zod@4.4.3/node_modules/zod/v4/core/api.js
3190
+ //#region ../../node_modules/.pnpm/zod@4.6.5/node_modules/zod/v4/core/api.js
3191
+ function snapshotChecks(def) {
3192
+ if (def.checks) def.checks = [...def.checks];
3193
+ return def;
3194
+ }
2341
3195
  // @__NO_SIDE_EFFECTS__
2342
3196
  function _string(Class, params) {
2343
- return new Class({
3197
+ return new Class(snapshotChecks({
2344
3198
  type: "string",
2345
3199
  ...normalizeParams(params)
2346
- });
3200
+ }));
2347
3201
  }
2348
3202
  // @__NO_SIDE_EFFECTS__
2349
3203
  function _email(Class, params) {
@@ -2615,11 +3469,11 @@ function _isoDuration(Class, params) {
2615
3469
  }
2616
3470
  // @__NO_SIDE_EFFECTS__
2617
3471
  function _number(Class, params) {
2618
- return new Class({
3472
+ return new Class(snapshotChecks({
2619
3473
  type: "number",
2620
3474
  checks: [],
2621
3475
  ...normalizeParams(params)
2622
- });
3476
+ }));
2623
3477
  }
2624
3478
  // @__NO_SIDE_EFFECTS__
2625
3479
  function _int(Class, params) {
@@ -2822,7 +3676,7 @@ function _superRefine(fn, params) {
2822
3676
  const _issue = issue$2;
2823
3677
  if (_issue.fatal) _issue.continue = false;
2824
3678
  _issue.code ?? (_issue.code = "custom");
2825
- _issue.input ?? (_issue.input = payload.value);
3679
+ if (!("input" in _issue)) _issue.input = payload.value;
2826
3680
  _issue.inst ?? (_issue.inst = ch);
2827
3681
  _issue.continue ?? (_issue.continue = !ch._zod.def.abort);
2828
3682
  payload.issues.push(issue(_issue));
@@ -2842,7 +3696,11 @@ function _check(fn, params) {
2842
3696
  return ch;
2843
3697
  }
2844
3698
  //#endregion
2845
- //#region ../../node_modules/.pnpm/zod@4.4.3/node_modules/zod/v4/core/to-json-schema.js
3699
+ //#region ../../node_modules/.pnpm/zod@4.6.5/node_modules/zod/v4/core/to-json-schema.js
3700
+ function assignProps(target, ...sources) {
3701
+ for (const source of sources) for (const key of Reflect.ownKeys(source)) if (Object.prototype.propertyIsEnumerable.call(source, key)) assignProp(target, key, source[key]);
3702
+ return target;
3703
+ }
2846
3704
  function initializeContext(params) {
2847
3705
  let target = params?.target ?? "draft-2020-12";
2848
3706
  if (target === "draft-4") target = "draft-04";
@@ -2856,12 +3714,32 @@ function initializeContext(params) {
2856
3714
  io: params?.io ?? "output",
2857
3715
  counter: 0,
2858
3716
  seen: /* @__PURE__ */ new Map(),
3717
+ sharedDefsExtractedFor: void 0,
3718
+ sharedEmitDoneFor: void 0,
2859
3719
  cycles: params?.cycles ?? "ref",
2860
3720
  reused: params?.reused ?? "inline",
3721
+ intersections: [],
3722
+ deferred: [],
2861
3723
  external: params?.external ?? void 0
2862
3724
  };
2863
3725
  }
2864
- function process(schema, ctx, _params = {
3726
+ /**
3727
+ * Applies the `unrepresentable` setting at a site that has no JSON Schema equivalent. Throws
3728
+ * `message` unless the setting (or the handler's return value) says otherwise. Returns `true` if a
3729
+ * custom JSON Schema was written into `json`, in which case the caller must not write its own.
3730
+ */
3731
+ function handleUnrepresentable(schema, ctx, json, params, message) {
3732
+ const result = typeof ctx.unrepresentable === "function" ? ctx.unrepresentable({
3733
+ zodSchema: schema,
3734
+ path: params.path,
3735
+ message
3736
+ }) : ctx.unrepresentable;
3737
+ if (result === "any") return false;
3738
+ if (result === void 0 || result === "throw") throw new Error(message);
3739
+ Object.assign(json, result);
3740
+ return true;
3741
+ }
3742
+ function processSchema(schema, ctx, _params = {
2865
3743
  path: [],
2866
3744
  schemaPath: []
2867
3745
  }) {
@@ -2880,6 +3758,8 @@ function process(schema, ctx, _params = {
2880
3758
  path: _params.path
2881
3759
  };
2882
3760
  ctx.seen.set(schema, result);
3761
+ ctx.sharedDefsExtractedFor = void 0;
3762
+ ctx.sharedEmitDoneFor = void 0;
2883
3763
  const overrideSchema = schema._zod.toJSONSchema?.();
2884
3764
  if (overrideSchema) result.schema = overrideSchema;
2885
3765
  else {
@@ -2898,12 +3778,12 @@ function process(schema, ctx, _params = {
2898
3778
  const parent = schema._zod.parent;
2899
3779
  if (parent) {
2900
3780
  if (!result.ref) result.ref = parent;
2901
- process(parent, ctx, params);
3781
+ processSchema(parent, ctx, params);
2902
3782
  ctx.seen.get(parent).isParent = true;
2903
3783
  }
2904
3784
  }
2905
3785
  const meta = ctx.metadataRegistry.get(schema);
2906
- if (meta) Object.assign(result.schema, meta);
3786
+ if (meta) assignProps(result.schema, meta);
2907
3787
  if (ctx.io === "input" && isTransforming(schema)) {
2908
3788
  delete result.schema.examples;
2909
3789
  delete result.schema.default;
@@ -2912,9 +3792,13 @@ function process(schema, ctx, _params = {
2912
3792
  delete result.schema._prefault;
2913
3793
  return ctx.seen.get(schema).schema;
2914
3794
  }
3795
+ function encodeJSONPointerSegment(segment) {
3796
+ return segment.replace(/~/g, "~0").replace(/\//g, "~1");
3797
+ }
2915
3798
  function extractDefs(ctx, schema) {
2916
3799
  const root = ctx.seen.get(schema);
2917
3800
  if (!root) throw new Error("Unprocessed schema. This is a bug in Zod.");
3801
+ if (ctx.external && ctx.sharedDefsExtractedFor === ctx.external) return;
2918
3802
  const idToSchema = /* @__PURE__ */ new Map();
2919
3803
  for (const entry of ctx.seen.entries()) {
2920
3804
  const id = ctx.metadataRegistry.get(entry[0])?.id;
@@ -2934,15 +3818,16 @@ function extractDefs(ctx, schema) {
2934
3818
  entry[1].defId = id;
2935
3819
  return {
2936
3820
  defId: id,
2937
- ref: `${uriGenerator("__shared")}#/${defsSegment}/${id}`
3821
+ ref: `${uriGenerator("__shared")}#/${defsSegment}/${encodeJSONPointerSegment(id)}`
2938
3822
  };
2939
3823
  }
2940
- if (entry[1] === root) return { ref: "#" };
2941
- const defUriPrefix = `#/${defsSegment}/`;
3824
+ const uriPrefix = `#`;
3825
+ const defUriPrefix = `${uriPrefix}/${defsSegment}/`;
3826
+ if (entry[1] === root && !entry[1].schema.id) return { ref: uriPrefix };
2942
3827
  const defId = entry[1].schema.id ?? `__schema${ctx.counter++}`;
2943
3828
  return {
2944
3829
  defId,
2945
- ref: defUriPrefix + defId
3830
+ ref: defUriPrefix + encodeJSONPointerSegment(defId)
2946
3831
  };
2947
3832
  };
2948
3833
  const extractToDef = (entry) => {
@@ -2983,12 +3868,114 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
2983
3868
  continue;
2984
3869
  }
2985
3870
  if (seen.count > 1) {
2986
- if (ctx.reused === "ref") {
2987
- extractToDef(entry);
2988
- continue;
3871
+ if (ctx.reused === "ref") extractToDef(entry);
3872
+ }
3873
+ }
3874
+ if (ctx.external) ctx.sharedDefsExtractedFor = ctx.external;
3875
+ }
3876
+ /** Rewrites `anyOf: [{type: "a"}, {type: "b"}]` to `type: ["a", "b"]`, which every JSON Schema draft treats as equivalent and most consumers render far better for the nullable case. Only branches that are a bare type assertion qualify — anything carrying a constraint, `$ref`, `const` or metadata is left alone. Runs after `flattenRef`, so a branch an override decorated or `$defs` extraction turned into a `$ref` is no longer bare and correctly stays in `anyOf`. `oneOf` is excluded: `integer` and `number` overlap, so "exactly one" and "at least one" are not the same there. OpenAPI 3.0 is excluded: its `type` must be a single string. */
3877
+ function compactTypeUnion(schema) {
3878
+ const options = schema.anyOf;
3879
+ if (!Array.isArray(options) || options.length === 0 || schema.type !== void 0) return;
3880
+ const types = [];
3881
+ for (const option of options) {
3882
+ if (!option || typeof option !== "object") return;
3883
+ compactTypeUnion(option);
3884
+ const keys = Object.keys(option);
3885
+ if (keys.length !== 1 || keys[0] !== "type") return;
3886
+ const type = option.type;
3887
+ for (const member of Array.isArray(type) ? type : [type]) {
3888
+ if (typeof member !== "string") return;
3889
+ if (!types.includes(member)) types.push(member);
3890
+ }
3891
+ }
3892
+ delete schema.anyOf;
3893
+ schema.type = types.length === 1 ? types[0] : types;
3894
+ }
3895
+ /** Keywords `foldIntersection` knows how to combine. Anything else — `$ref`, `patternProperties`,
3896
+ * an annotation like `description` — makes a member unfoldable, so a constraint this does not
3897
+ * understand leaves the `allOf` alone instead of being silently dropped or misattributed. */
3898
+ var FOLDABLE_KEYS = new Set([
3899
+ "type",
3900
+ "properties",
3901
+ "required",
3902
+ "additionalProperties"
3903
+ ]);
3904
+ var UNION_KEYS = ["oneOf", "anyOf"];
3905
+ /** A member's constraint on a key it does not declare itself. A `catchall` states one; `false`, an absent `additionalProperties`, and the empty schema a loose object emits state nothing. */
3906
+ function undeclaredConstraint(member) {
3907
+ const extra = member.additionalProperties;
3908
+ if (extra === void 0 || extra === false || typeof extra !== "object" || extra === null) return null;
3909
+ return Object.keys(extra).length ? extra : null;
3910
+ }
3911
+ /** Combines object members into the single object they describe together, or returns `null` if any of them carries a keyword outside {@link FOLDABLE_KEYS}. */
3912
+ function foldObjects(members) {
3913
+ const objects = [];
3914
+ for (const member of members) {
3915
+ if (typeof member !== "object" || member.type !== "object") return null;
3916
+ for (const key in member) if (!FOLDABLE_KEYS.has(key)) return null;
3917
+ objects.push(member);
3918
+ }
3919
+ const properties = {};
3920
+ const required = /* @__PURE__ */ new Set();
3921
+ for (const object of objects) {
3922
+ for (const key in object.properties) {
3923
+ if (Object.prototype.hasOwnProperty.call(properties, key)) continue;
3924
+ const parts = [];
3925
+ for (const other of objects) {
3926
+ const part = other.properties?.[key] ?? undeclaredConstraint(other);
3927
+ if (part === null || part === void 0) continue;
3928
+ if (!parts.some((seen) => JSON.stringify(seen) === JSON.stringify(part))) parts.push(part);
2989
3929
  }
3930
+ assignProp(properties, key, parts.length === 1 ? parts[0] : foldObjects(parts) ?? { allOf: parts });
3931
+ }
3932
+ for (const key of object.required ?? []) required.add(key);
3933
+ }
3934
+ const folded = {
3935
+ type: "object",
3936
+ properties
3937
+ };
3938
+ if (required.size) folded.required = [...required];
3939
+ if (objects.every((object) => object.additionalProperties === false)) folded.additionalProperties = false;
3940
+ else {
3941
+ const constraints = [];
3942
+ for (const object of objects) {
3943
+ const constraint = undeclaredConstraint(object);
3944
+ if (constraint && !constraints.some((seen) => JSON.stringify(seen) === JSON.stringify(constraint))) constraints.push(constraint);
2990
3945
  }
3946
+ if (constraints.length === 1) folded.additionalProperties = constraints[0];
3947
+ else if (constraints.length > 1) folded.additionalProperties = { allOf: constraints };
2991
3948
  }
3949
+ return folded;
3950
+ }
3951
+ /** `additionalProperties` in an `allOf` member sees only that member's own `properties`, so two
3952
+ * closed object members reject each other's keys and the schema validates nothing. Zod's parser
3953
+ * pools the key sets instead — `handleIntersectionResults` reports a key as unrecognized only when
3954
+ * *every* side rejects it — so the emitted schema has to pool them too, and folding the members
3955
+ * into one object is the encoding that says so on every target.
3956
+ *
3957
+ * This runs from `finalize`, after `extractDefs`, which is what keeps it clear of the `$ref`
3958
+ * machinery: a member extracted into `$defs` is already a `$ref` by now and declines to fold, so it
3959
+ * keeps its reference and its own closedness rather than being inlined as a stale copy. */
3960
+ function foldIntersection(json) {
3961
+ const allOf = json.allOf;
3962
+ if (!Array.isArray(allOf) || allOf.length < 2) return;
3963
+ for (const key of FOLDABLE_KEYS) if (key in json) return;
3964
+ const unions = allOf.filter((m) => UNION_KEYS.some((k) => Array.isArray(m[k])));
3965
+ let folded = null;
3966
+ if (!unions.length) folded = foldObjects(allOf);
3967
+ else {
3968
+ const union = unions[0];
3969
+ const keyword = UNION_KEYS.find((k) => Array.isArray(union[k]));
3970
+ if (Object.keys(union).length !== 1) return;
3971
+ const rest = allOf.filter((m) => m !== union);
3972
+ const branches = union[keyword].map((branch) => foldObjects([...rest, branch]));
3973
+ if (branches.some((b) => !b)) return;
3974
+ folded = { [keyword]: branches };
3975
+ }
3976
+ if (!folded) return;
3977
+ delete json.allOf;
3978
+ assignProps(json, folded);
2992
3979
  }
2993
3980
  function finalize(ctx, schema) {
2994
3981
  const root = ctx.seen.get(schema);
@@ -3007,8 +3994,8 @@ function finalize(ctx, schema) {
3007
3994
  if (refSchema.$ref && (ctx.target === "draft-07" || ctx.target === "draft-04" || ctx.target === "openapi-3.0")) {
3008
3995
  schema.allOf = schema.allOf ?? [];
3009
3996
  schema.allOf.push(refSchema);
3010
- } else Object.assign(schema, refSchema);
3011
- Object.assign(schema, _cached);
3997
+ } else assignProps(schema, refSchema);
3998
+ assignProps(schema, _cached);
3012
3999
  if (zodSchema._zod.parent === ref) for (const key in schema) {
3013
4000
  if (key === "$ref" || key === "allOf") continue;
3014
4001
  if (!(key in _cached)) delete schema[key];
@@ -3036,7 +4023,22 @@ function finalize(ctx, schema) {
3036
4023
  path: seen.path ?? []
3037
4024
  });
3038
4025
  };
3039
- for (const entry of [...ctx.seen.entries()].reverse()) flattenRef(entry[0]);
4026
+ if (!ctx.external || ctx.sharedEmitDoneFor !== ctx.external) {
4027
+ for (const entry of [...ctx.seen.entries()].reverse()) flattenRef(entry[0]);
4028
+ if (ctx.target !== "openapi-3.0") for (const entry of ctx.seen.entries()) compactTypeUnion(entry[1].def ?? entry[1].schema);
4029
+ for (const rewrite of ctx.deferred) rewrite();
4030
+ if (ctx.intersections.length) {
4031
+ const carriers = /* @__PURE__ */ new Map();
4032
+ for (const seen of ctx.seen.values()) for (const json of [seen.schema, seen.def]) {
4033
+ const allOf = json?.allOf;
4034
+ if (!Array.isArray(allOf)) continue;
4035
+ const existing = carriers.get(allOf);
4036
+ if (existing) existing.push(json);
4037
+ else carriers.set(allOf, [json]);
4038
+ }
4039
+ for (const allOf of ctx.intersections) for (const json of carriers.get(allOf) ?? []) foldIntersection(json);
4040
+ }
4041
+ }
3040
4042
  const result = {};
3041
4043
  if (ctx.target === "draft-2020-12") result.$schema = "https://json-schema.org/draft/2020-12/schema";
3042
4044
  else if (ctx.target === "draft-07") result.$schema = "http://json-schema.org/draft-07/schema#";
@@ -3047,17 +4049,18 @@ function finalize(ctx, schema) {
3047
4049
  if (!id) throw new Error("Schema is missing an `id` property");
3048
4050
  result.$id = ctx.external.uri(id);
3049
4051
  }
3050
- Object.assign(result, root.def ?? root.schema);
4052
+ assignProps(result, root.defId ? root.schema : root.def ?? root.schema);
3051
4053
  const rootMetaId = ctx.metadataRegistry.get(schema)?.id;
3052
4054
  if (rootMetaId !== void 0 && result.id === rootMetaId) delete result.id;
3053
4055
  const defs = ctx.external?.defs ?? {};
3054
- for (const entry of ctx.seen.entries()) {
4056
+ if (!ctx.external || ctx.sharedEmitDoneFor !== ctx.external) for (const entry of ctx.seen.entries()) {
3055
4057
  const seen = entry[1];
3056
4058
  if (seen.def && seen.defId) {
3057
4059
  if (seen.def.id === seen.defId) delete seen.def.id;
3058
- defs[seen.defId] = seen.def;
4060
+ assignProp(defs, seen.defId, seen.def);
3059
4061
  }
3060
4062
  }
4063
+ if (ctx.external) ctx.sharedEmitDoneFor = ctx.external;
3061
4064
  if (ctx.external) {} else if (Object.keys(defs).length > 0) if (ctx.target === "draft-2020-12") result.$defs = defs;
3062
4065
  else result.definitions = defs;
3063
4066
  try {
@@ -3087,7 +4090,7 @@ function isTransforming(_schema, _ctx) {
3087
4090
  if (def.type === "array") return isTransforming(def.element, ctx);
3088
4091
  if (def.type === "set") return isTransforming(def.valueType, ctx);
3089
4092
  if (def.type === "lazy") return isTransforming(def.getter(), ctx);
3090
- 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);
4093
+ if (def.type === "promise" || def.type === "optional" || def.type === "nonoptional" || def.type === "nullable" || def.type === "readonly" || def.type === "default" || def.type === "prefault" || def.type === "catch") return isTransforming(def.innerType, ctx);
3091
4094
  if (def.type === "intersection") return isTransforming(def.left, ctx) || isTransforming(def.right, ctx);
3092
4095
  if (def.type === "record" || def.type === "map") return isTransforming(def.keyType, ctx) || isTransforming(def.valueType, ctx);
3093
4096
  if (def.type === "pipe") {
@@ -3118,7 +4121,7 @@ var createToJSONSchemaMethod = (schema, processors = {}) => (params) => {
3118
4121
  ...params,
3119
4122
  processors
3120
4123
  });
3121
- process(schema, ctx);
4124
+ processSchema(schema, ctx);
3122
4125
  extractDefs(ctx, schema);
3123
4126
  return finalize(ctx, schema);
3124
4127
  };
@@ -3130,12 +4133,84 @@ var createStandardJSONSchemaMethod = (schema, io, processors = {}) => (params) =
3130
4133
  io,
3131
4134
  processors
3132
4135
  });
3133
- process(schema, ctx);
4136
+ processSchema(schema, ctx);
3134
4137
  extractDefs(ctx, schema);
3135
4138
  return finalize(ctx, schema);
3136
4139
  };
3137
4140
  //#endregion
3138
- //#region ../../node_modules/.pnpm/zod@4.4.3/node_modules/zod/v4/core/json-schema-processors.js
4141
+ //#region ../../node_modules/.pnpm/zod@4.6.5/node_modules/zod/v4/core/json-schema-processors.js
4142
+ var narrowMin = (agg, key, value) => {
4143
+ if (agg[key] === void 0 || value > agg[key]) agg[key] = value;
4144
+ };
4145
+ var narrowMax = (agg, key, value) => {
4146
+ if (agg[key] === void 0 || value < agg[key]) agg[key] = value;
4147
+ };
4148
+ var narrowBoth = (agg, value) => {
4149
+ narrowMin(agg, "minimum", value);
4150
+ narrowMax(agg, "maximum", value);
4151
+ };
4152
+ var addDivisor = (agg, value) => {
4153
+ agg.multipleOf ?? (agg.multipleOf = []);
4154
+ if (!agg.multipleOf.includes(value)) agg.multipleOf.push(value);
4155
+ };
4156
+ var addPattern = (agg, pattern) => {
4157
+ agg.patterns ?? (agg.patterns = /* @__PURE__ */ new Set());
4158
+ agg.patterns.add(pattern);
4159
+ };
4160
+ var intersectMime = (agg, mime) => {
4161
+ agg.mime = agg.mime ? agg.mime.filter((m) => mime.includes(m)) : [...mime];
4162
+ };
4163
+ var setFormat = (agg, format) => {
4164
+ agg.format = format;
4165
+ if (format.includes("int")) agg.isInt = true;
4166
+ };
4167
+ var minContributor = (agg, def) => narrowMin(agg, "minimum", def.minimum);
4168
+ var maxContributor = (agg, def) => narrowMax(agg, "maximum", def.maximum);
4169
+ var formatContributor = (ranges) => (agg, def) => {
4170
+ setFormat(agg, def.format);
4171
+ const [minimum, maximum] = ranges[def.format];
4172
+ narrowMin(agg, "minimum", minimum);
4173
+ narrowMax(agg, "maximum", maximum);
4174
+ };
4175
+ var contributors = {
4176
+ greater_than: (agg, def) => narrowMin(agg, def.inclusive ? "minimum" : "exclusiveMinimum", def.value),
4177
+ less_than: (agg, def) => narrowMax(agg, def.inclusive ? "maximum" : "exclusiveMaximum", def.value),
4178
+ multiple_of: (agg, def) => addDivisor(agg, def.value),
4179
+ number_format: formatContributor(NUMBER_FORMAT_RANGES),
4180
+ bigint_format: formatContributor(BIGINT_FORMAT_RANGES),
4181
+ min_length: minContributor,
4182
+ max_length: maxContributor,
4183
+ length_equals: (agg, def) => narrowBoth(agg, def.length),
4184
+ min_size: minContributor,
4185
+ max_size: maxContributor,
4186
+ size_equals: (agg, def) => narrowBoth(agg, def.size),
4187
+ string_format: (agg, def) => {
4188
+ setFormat(agg, def.format);
4189
+ if (def.pattern) addPattern(agg, def.pattern);
4190
+ if (def.format === "base64" || def.format === "base64url") agg.contentEncoding = def.format;
4191
+ if (def.local || def.precision === -1) agg.laxFormat = true;
4192
+ },
4193
+ mime_type: (agg, def) => intersectMime(agg, def.mime)
4194
+ };
4195
+ function aggregateChecks(schema) {
4196
+ const agg = {};
4197
+ const def = schema._zod.def;
4198
+ const list = schema._zod.traits.has("$ZodCheck") ? [schema, ...def.checks ?? []] : def.checks ?? [];
4199
+ for (const ch of list) contributors[ch._zod.def.check]?.(agg, ch._zod.def);
4200
+ const bag = schema._zod.bag;
4201
+ if (bag.minimum !== void 0) narrowMin(agg, "minimum", bag.minimum);
4202
+ if (bag.exclusiveMinimum !== void 0) narrowMin(agg, "exclusiveMinimum", bag.exclusiveMinimum);
4203
+ if (bag.maximum !== void 0) narrowMax(agg, "maximum", bag.maximum);
4204
+ if (bag.exclusiveMaximum !== void 0) narrowMax(agg, "exclusiveMaximum", bag.exclusiveMaximum);
4205
+ if (bag.multipleOf !== void 0) addDivisor(agg, bag.multipleOf);
4206
+ if (bag.format !== void 0) {
4207
+ agg.format ?? (agg.format = bag.format);
4208
+ if (bag.format.includes("int")) agg.isInt = true;
4209
+ }
4210
+ if (bag.mime) intersectMime(agg, bag.mime);
4211
+ for (const pattern of bag.patterns ?? []) addPattern(agg, pattern);
4212
+ return agg;
4213
+ }
3139
4214
  var formatMap = {
3140
4215
  guid: "uuid",
3141
4216
  url: "uri",
@@ -3143,32 +4218,33 @@ var formatMap = {
3143
4218
  json_string: "json-string",
3144
4219
  regex: ""
3145
4220
  };
4221
+ var exactPatterns = new Map([[base64Charset, base64], [base64urlCharset, base64url]]);
4222
+ var exactPattern = (p) => exactPatterns.get(p) ?? p;
3146
4223
  var stringProcessor = (schema, ctx, _json, _params) => {
3147
4224
  const json = _json;
3148
4225
  json.type = "string";
3149
- const { minimum, maximum, format, patterns, contentEncoding } = schema._zod.bag;
4226
+ const { minimum, maximum, format, patterns, contentEncoding, laxFormat } = aggregateChecks(schema);
3150
4227
  if (typeof minimum === "number") json.minLength = minimum;
3151
4228
  if (typeof maximum === "number") json.maxLength = maximum;
3152
4229
  if (format) {
3153
4230
  json.format = formatMap[format] ?? format;
3154
4231
  if (json.format === "") delete json.format;
3155
- if (format === "time") delete json.format;
4232
+ if (format === "time" || laxFormat) delete json.format;
3156
4233
  }
3157
4234
  if (contentEncoding) json.contentEncoding = contentEncoding;
3158
4235
  if (patterns && patterns.size > 0) {
3159
- const regexes = [...patterns];
3160
- if (regexes.length === 1) json.pattern = regexes[0].source;
3161
- else if (regexes.length > 1) json.allOf = [...regexes.map((regex) => ({
4236
+ const patternList = [...patterns].map(exactPattern);
4237
+ if (patternList.length === 1) json.pattern = patternList[0].source;
4238
+ else if (patternList.length > 1) json.allOf = [...patternList.map((regex) => ({
3162
4239
  ...ctx.target === "draft-07" || ctx.target === "draft-04" || ctx.target === "openapi-3.0" ? { type: "string" } : {},
3163
4240
  pattern: regex.source
3164
4241
  }))];
3165
4242
  }
3166
4243
  };
3167
- var numberProcessor = (schema, ctx, _json, _params) => {
4244
+ var numberProcessor = (schema, ctx, _json, params) => {
3168
4245
  const json = _json;
3169
- const { minimum, maximum, format, multipleOf, exclusiveMaximum, exclusiveMinimum } = schema._zod.bag;
3170
- if (typeof format === "string" && format.includes("int")) json.type = "integer";
3171
- else json.type = "number";
4246
+ const { minimum, maximum, multipleOf, exclusiveMaximum, exclusiveMinimum, isInt } = aggregateChecks(schema);
4247
+ json.type = isInt ? "integer" : "number";
3172
4248
  const exMin = typeof exclusiveMinimum === "number" && exclusiveMinimum >= (minimum ?? Number.NEGATIVE_INFINITY);
3173
4249
  const exMax = typeof exclusiveMaximum === "number" && exclusiveMaximum <= (maximum ?? Number.POSITIVE_INFINITY);
3174
4250
  const legacy = ctx.target === "draft-04" || ctx.target === "openapi-3.0";
@@ -3182,7 +4258,14 @@ var numberProcessor = (schema, ctx, _json, _params) => {
3182
4258
  json.exclusiveMaximum = true;
3183
4259
  } else json.exclusiveMaximum = exclusiveMaximum;
3184
4260
  else if (typeof maximum === "number") json.maximum = maximum;
3185
- if (typeof multipleOf === "number") json.multipleOf = multipleOf;
4261
+ if (multipleOf) {
4262
+ const divisors = /* @__PURE__ */ new Set();
4263
+ for (const divisor of multipleOf) if (Number.isFinite(divisor) && divisor !== 0) divisors.add(Math.abs(divisor));
4264
+ else handleUnrepresentable(schema, ctx, json, params, `A multipleOf divisor of ${divisor} cannot be represented in JSON Schema`);
4265
+ const [first, ...rest] = divisors;
4266
+ if (first !== void 0) json.multipleOf = first;
4267
+ if (rest.length) json.allOf = [...json.allOf ?? [], ...rest.map((m) => ({ multipleOf: m }))];
4268
+ }
3186
4269
  };
3187
4270
  var booleanProcessor = (_schema, _ctx, json, _params) => {
3188
4271
  json.type = "boolean";
@@ -3193,18 +4276,27 @@ var neverProcessor = (_schema, _ctx, json, _params) => {
3193
4276
  var enumProcessor = (schema, _ctx, json, _params) => {
3194
4277
  const def = schema._zod.def;
3195
4278
  const values = getEnumValues(def.entries);
4279
+ if (values.length === 0) {
4280
+ json.not = {};
4281
+ return;
4282
+ }
3196
4283
  if (values.every((v) => typeof v === "number")) json.type = "number";
3197
4284
  if (values.every((v) => typeof v === "string")) json.type = "string";
3198
4285
  json.enum = values;
3199
4286
  };
3200
- var literalProcessor = (schema, ctx, json, _params) => {
4287
+ var literalProcessor = (schema, ctx, json, params) => {
3201
4288
  const def = schema._zod.def;
4289
+ if (def.values.length === 0) {
4290
+ json.not = {};
4291
+ return;
4292
+ }
3202
4293
  const vals = [];
3203
4294
  for (const val of def.values) if (val === void 0) {
3204
- if (ctx.unrepresentable === "throw") throw new Error("Literal `undefined` cannot be represented in JSON Schema");
3205
- } else if (typeof val === "bigint") if (ctx.unrepresentable === "throw") throw new Error("BigInt literals cannot be represented in JSON Schema");
3206
- else vals.push(Number(val));
3207
- else vals.push(val);
4295
+ if (handleUnrepresentable(schema, ctx, json, params, "Literal `undefined` cannot be represented in JSON Schema")) return;
4296
+ } else if (typeof val === "bigint") {
4297
+ if (handleUnrepresentable(schema, ctx, json, params, "BigInt literals cannot be represented in JSON Schema")) return;
4298
+ vals.push(Number(val));
4299
+ } else vals.push(val);
3208
4300
  if (vals.length === 0) {} else if (vals.length === 1) {
3209
4301
  const val = vals[0];
3210
4302
  json.type = val === null ? "null" : typeof val;
@@ -3218,49 +4310,55 @@ var literalProcessor = (schema, ctx, json, _params) => {
3218
4310
  json.enum = vals;
3219
4311
  }
3220
4312
  };
3221
- var customProcessor = (_schema, ctx, _json, _params) => {
3222
- if (ctx.unrepresentable === "throw") throw new Error("Custom types cannot be represented in JSON Schema");
4313
+ var customProcessor = (schema, ctx, json, params) => {
4314
+ handleUnrepresentable(schema, ctx, json, params, "Custom types cannot be represented in JSON Schema");
3223
4315
  };
3224
- var transformProcessor = (_schema, ctx, _json, _params) => {
3225
- if (ctx.unrepresentable === "throw") throw new Error("Transforms cannot be represented in JSON Schema");
4316
+ var transformProcessor = (schema, ctx, json, params) => {
4317
+ handleUnrepresentable(schema, ctx, json, params, "Transforms cannot be represented in JSON Schema");
3226
4318
  };
3227
4319
  var arrayProcessor = (schema, ctx, _json, params) => {
3228
4320
  const json = _json;
3229
4321
  const def = schema._zod.def;
3230
- const { minimum, maximum } = schema._zod.bag;
4322
+ const { minimum, maximum } = aggregateChecks(schema);
3231
4323
  if (typeof minimum === "number") json.minItems = minimum;
3232
4324
  if (typeof maximum === "number") json.maxItems = maximum;
3233
4325
  json.type = "array";
3234
- json.items = process(def.element, ctx, {
4326
+ json.items = processSchema(def.element, ctx, {
3235
4327
  ...params,
3236
4328
  path: [...params.path, "items"]
3237
4329
  });
3238
4330
  };
4331
+ function inputOptin(schema) {
4332
+ const def = schema._zod.def;
4333
+ if (def.type === "pipe" && def.in._zod.traits.has("$ZodTransform")) return inputOptin(def.out);
4334
+ if (def.type === "catch") return inputOptin(def.innerType);
4335
+ return schema._zod.optin;
4336
+ }
3239
4337
  var objectProcessor = (schema, ctx, _json, params) => {
3240
4338
  const json = _json;
3241
4339
  const def = schema._zod.def;
4340
+ const shape = def.shape;
4341
+ if (Object.getOwnPropertySymbols(shape).length && handleUnrepresentable(schema, ctx, json, params, "Symbol keys cannot be represented in JSON Schema")) return;
3242
4342
  json.type = "object";
3243
4343
  json.properties = {};
3244
- const shape = def.shape;
3245
- for (const key in shape) json.properties[key] = process(shape[key], ctx, {
4344
+ for (const key in shape) assignProp(json.properties, key, processSchema(shape[key], ctx, {
3246
4345
  ...params,
3247
4346
  path: [
3248
4347
  ...params.path,
3249
4348
  "properties",
3250
4349
  key
3251
4350
  ]
3252
- });
3253
- const allKeys = new Set(Object.keys(shape));
3254
- const requiredKeys = new Set([...allKeys].filter((key) => {
3255
- const v = def.shape[key]._zod;
3256
- if (ctx.io === "input") return v.optin === void 0;
3257
- else return v.optout === void 0;
3258
4351
  }));
3259
- if (requiredKeys.size > 0) json.required = Array.from(requiredKeys);
4352
+ const requiredKeys = [];
4353
+ for (const key of Object.keys(shape)) {
4354
+ const field = def.shape[key];
4355
+ if (ctx.io === "input" ? inputOptin(field) === void 0 : field._zod.optout === void 0) requiredKeys.push(key);
4356
+ }
4357
+ if (requiredKeys.length > 0) json.required = requiredKeys;
3260
4358
  if (def.catchall?._zod.def.type === "never") json.additionalProperties = false;
3261
4359
  else if (!def.catchall) {
3262
4360
  if (ctx.io === "output") json.additionalProperties = false;
3263
- } else if (def.catchall) json.additionalProperties = process(def.catchall, ctx, {
4361
+ } else if (def.catchall) json.additionalProperties = processSchema(def.catchall, ctx, {
3264
4362
  ...params,
3265
4363
  path: [...params.path, "additionalProperties"]
3266
4364
  });
@@ -3268,7 +4366,7 @@ var objectProcessor = (schema, ctx, _json, params) => {
3268
4366
  var unionProcessor = (schema, ctx, json, params) => {
3269
4367
  const def = schema._zod.def;
3270
4368
  const isExclusive = def.inclusive === false;
3271
- const options = def.options.map((x, i) => process(x, ctx, {
4369
+ const options = def.options.map((x, i) => processSchema(x, ctx, {
3272
4370
  ...params,
3273
4371
  path: [
3274
4372
  ...params.path,
@@ -3281,7 +4379,7 @@ var unionProcessor = (schema, ctx, json, params) => {
3281
4379
  };
3282
4380
  var intersectionProcessor = (schema, ctx, json, params) => {
3283
4381
  const def = schema._zod.def;
3284
- const a = process(def.left, ctx, {
4382
+ const a = processSchema(def.left, ctx, {
3285
4383
  ...params,
3286
4384
  path: [
3287
4385
  ...params.path,
@@ -3289,7 +4387,7 @@ var intersectionProcessor = (schema, ctx, json, params) => {
3289
4387
  0
3290
4388
  ]
3291
4389
  });
3292
- const b = process(def.right, ctx, {
4390
+ const b = processSchema(def.right, ctx, {
3293
4391
  ...params,
3294
4392
  path: [
3295
4393
  ...params.path,
@@ -3298,16 +4396,76 @@ var intersectionProcessor = (schema, ctx, json, params) => {
3298
4396
  ]
3299
4397
  });
3300
4398
  const isSimpleIntersection = (val) => "allOf" in val && Object.keys(val).length === 1;
3301
- json.allOf = [...isSimpleIntersection(a) ? a.allOf : [a], ...isSimpleIntersection(b) ? b.allOf : [b]];
4399
+ const allOf = [...isSimpleIntersection(a) ? a.allOf : [a], ...isSimpleIntersection(b) ? b.allOf : [b]];
4400
+ json.allOf = allOf;
4401
+ ctx.intersections.push(allOf);
3302
4402
  };
4403
+ /** JSON object keys are always strings, so a numeric record key schema is re-expressed over the
4404
+ * numeric-string form the record parser matches. Deferred to `finalize`, after the flatten: a key
4405
+ * behind a wrapper only carries its own `type` before then, and a union key only has its branches.
4406
+ *
4407
+ * A numeric bound cannot apply to a property name, so `minimum` and its siblings are dropped rather
4408
+ * than carried over: keeping them beside `type: "string"` reproduces the match-nothing schema this
4409
+ * exists to fix. A key that carries one therefore emits wider than the record parses — `z.record(z.number().min(5), V)`
4410
+ * accepts `"3"` — which is the deliberate trade, since throwing on it would reject an ordinary schema
4411
+ * outright. */
4412
+ function stringifyKeyNames(bySchema, json, visited) {
4413
+ if (json.$ref) {
4414
+ if (visited.has(json)) return json;
4415
+ visited.add(json);
4416
+ const def = bySchema.get(json)?.def;
4417
+ if (!def) return json;
4418
+ const inlined = stringifyKeyNames(bySchema, def, visited);
4419
+ return inlined === def ? json : inlined;
4420
+ }
4421
+ for (const keyword of ["anyOf", "oneOf"]) {
4422
+ const branches = json[keyword];
4423
+ if (!Array.isArray(branches)) continue;
4424
+ const mapped = branches.map((branch) => stringifyKeyNames(bySchema, branch, visited));
4425
+ if (mapped.some((branch, i) => branch !== branches[i])) json = {
4426
+ ...json,
4427
+ [keyword]: mapped
4428
+ };
4429
+ }
4430
+ const types = Array.isArray(json.type) ? json.type : [json.type];
4431
+ const numericType = !types.includes("string") && types.some((t) => t === "number" || t === "integer");
4432
+ const values = json.enum ?? (json.const !== void 0 ? [json.const] : void 0);
4433
+ if (!numericType && !values?.some((v) => typeof v === "number")) return json;
4434
+ const { minimum, maximum, exclusiveMinimum, exclusiveMaximum, multipleOf, format, id, ...rest } = json;
4435
+ if (rest.enum) rest.enum = rest.enum.map((v) => typeof v === "number" ? String(v) : v);
4436
+ else if (typeof rest.const === "number") rest.const = String(rest.const);
4437
+ if (!numericType) return rest;
4438
+ rest.type = "string";
4439
+ if (!values) rest.pattern = (types.includes("number") ? number$1 : integer).source;
4440
+ return rest;
4441
+ }
4442
+ /** Every record of one conversion, so the carriers are found in a single pass rather than once per record. */
4443
+ var pendingRecords = /* @__PURE__ */ new WeakMap();
4444
+ function rewriteKeyNames(ctx) {
4445
+ const bySchema = /* @__PURE__ */ new Map();
4446
+ for (const entry of ctx.seen.values()) if (entry.def && !bySchema.has(entry.schema)) bySchema.set(entry.schema, entry);
4447
+ const rewrites = /* @__PURE__ */ new Map();
4448
+ for (const record of pendingRecords.get(ctx) ?? []) {
4449
+ const seen = ctx.seen.get(record);
4450
+ const names = (seen?.def ?? seen?.schema)?.propertyNames;
4451
+ if (!names || names === true || rewrites.has(names)) continue;
4452
+ const rewritten = stringifyKeyNames(bySchema, names, /* @__PURE__ */ new Set());
4453
+ if (rewritten !== names) rewrites.set(names, rewritten);
4454
+ }
4455
+ if (!rewrites.size) return;
4456
+ for (const entry of ctx.seen.values()) for (const carrier of [entry.schema, entry.def]) {
4457
+ const rewritten = carrier && rewrites.get(carrier.propertyNames);
4458
+ if (rewritten) carrier.propertyNames = rewritten;
4459
+ }
4460
+ }
3303
4461
  var recordProcessor = (schema, ctx, _json, params) => {
3304
4462
  const json = _json;
3305
4463
  const def = schema._zod.def;
3306
4464
  json.type = "object";
3307
4465
  const keyType = def.keyType;
3308
- const patterns = keyType._zod.bag?.patterns;
4466
+ const patterns = aggregateChecks(keyType).patterns;
3309
4467
  if (def.mode === "loose" && patterns && patterns.size > 0) {
3310
- const valueSchema = process(def.valueType, ctx, {
4468
+ const valueSchema = processSchema(def.valueType, ctx, {
3311
4469
  ...params,
3312
4470
  path: [
3313
4471
  ...params.path,
@@ -3316,26 +4474,36 @@ var recordProcessor = (schema, ctx, _json, params) => {
3316
4474
  ]
3317
4475
  });
3318
4476
  json.patternProperties = {};
3319
- for (const pattern of patterns) json.patternProperties[pattern.source] = valueSchema;
4477
+ for (const pattern of patterns) assignProp(json.patternProperties, exactPattern(pattern).source, valueSchema);
3320
4478
  } else {
3321
- if (ctx.target === "draft-07" || ctx.target === "draft-2020-12") json.propertyNames = process(def.keyType, ctx, {
3322
- ...params,
3323
- path: [...params.path, "propertyNames"]
3324
- });
3325
- json.additionalProperties = process(def.valueType, ctx, {
4479
+ if (ctx.target === "draft-07" || ctx.target === "draft-2020-12") {
4480
+ json.propertyNames = processSchema(def.keyType, ctx, {
4481
+ ...params,
4482
+ path: [...params.path, "propertyNames"]
4483
+ });
4484
+ let pending = pendingRecords.get(ctx);
4485
+ if (!pending) {
4486
+ pending = [];
4487
+ pendingRecords.set(ctx, pending);
4488
+ ctx.deferred.push(() => rewriteKeyNames(ctx));
4489
+ }
4490
+ pending.push(schema);
4491
+ }
4492
+ json.additionalProperties = processSchema(def.valueType, ctx, {
3326
4493
  ...params,
3327
4494
  path: [...params.path, "additionalProperties"]
3328
4495
  });
3329
4496
  }
3330
4497
  const keyValues = keyType._zod.values;
3331
- if (keyValues) {
4498
+ const omittableOnInput = ctx.io === "input" && inputOptin(def.valueType) !== void 0;
4499
+ if (keyValues && !def.partial && !omittableOnInput) {
3332
4500
  const validKeyValues = [...keyValues].filter((v) => typeof v === "string" || typeof v === "number");
3333
- if (validKeyValues.length > 0) json.required = validKeyValues;
4501
+ if (validKeyValues.length > 0) json.required = validKeyValues.map(String);
3334
4502
  }
3335
4503
  };
3336
4504
  var nullableProcessor = (schema, ctx, json, params) => {
3337
4505
  const def = schema._zod.def;
3338
- const inner = process(def.innerType, ctx, params);
4506
+ const inner = processSchema(def.innerType, ctx, params);
3339
4507
  const seen = ctx.seen.get(schema);
3340
4508
  if (ctx.target === "openapi-3.0") {
3341
4509
  seen.ref = def.innerType;
@@ -3344,34 +4512,53 @@ var nullableProcessor = (schema, ctx, json, params) => {
3344
4512
  };
3345
4513
  var nonoptionalProcessor = (schema, ctx, _json, params) => {
3346
4514
  const def = schema._zod.def;
3347
- process(def.innerType, ctx, params);
4515
+ processSchema(def.innerType, ctx, params);
3348
4516
  const seen = ctx.seen.get(schema);
3349
4517
  seen.ref = def.innerType;
3350
4518
  };
4519
+ /** Round-trips a default value through JSON so the emitted schema is guaranteed to be valid JSON.
4520
+ * A BigInt has no reliable encoding, so it goes through `unrepresentable` like any other
4521
+ * unrepresentable value. Returns a sentinel when the caller must not write a default of its own. */
4522
+ var UNREPRESENTABLE_DEFAULT = Symbol();
4523
+ function serializeDefaultValue(value, schema, ctx, json, params) {
4524
+ let unrepresentable = false;
4525
+ const serialized = JSON.stringify(value, (_, val) => {
4526
+ if (typeof val !== "bigint") return val;
4527
+ unrepresentable = true;
4528
+ return null;
4529
+ });
4530
+ if (!unrepresentable) return JSON.parse(serialized);
4531
+ handleUnrepresentable(schema, ctx, json, params, "BigInt defaults cannot be represented in JSON Schema");
4532
+ return UNREPRESENTABLE_DEFAULT;
4533
+ }
3351
4534
  var defaultProcessor = (schema, ctx, json, params) => {
3352
4535
  const def = schema._zod.def;
3353
- process(def.innerType, ctx, params);
4536
+ processSchema(def.innerType, ctx, params);
3354
4537
  const seen = ctx.seen.get(schema);
3355
4538
  seen.ref = def.innerType;
3356
- json.default = JSON.parse(JSON.stringify(def.defaultValue));
4539
+ const value = serializeDefaultValue(def.defaultValue, schema, ctx, json, params);
4540
+ if (value !== UNREPRESENTABLE_DEFAULT) json.default = value;
3357
4541
  };
3358
4542
  var prefaultProcessor = (schema, ctx, json, params) => {
3359
4543
  const def = schema._zod.def;
3360
- process(def.innerType, ctx, params);
4544
+ processSchema(def.innerType, ctx, params);
3361
4545
  const seen = ctx.seen.get(schema);
3362
4546
  seen.ref = def.innerType;
3363
- if (ctx.io === "input") json._prefault = JSON.parse(JSON.stringify(def.defaultValue));
4547
+ if (ctx.io !== "input") return;
4548
+ const value = serializeDefaultValue(def.defaultValue, schema, ctx, json, params);
4549
+ if (value !== UNREPRESENTABLE_DEFAULT) json._prefault = value;
3364
4550
  };
3365
4551
  var catchProcessor = (schema, ctx, json, params) => {
3366
4552
  const def = schema._zod.def;
3367
- process(def.innerType, ctx, params);
4553
+ processSchema(def.innerType, ctx, params);
3368
4554
  const seen = ctx.seen.get(schema);
3369
4555
  seen.ref = def.innerType;
3370
4556
  let catchValue;
3371
4557
  try {
3372
4558
  catchValue = def.catchValue(void 0);
3373
4559
  } catch {
3374
- throw new Error("Dynamic catch values are not supported in JSON Schema");
4560
+ handleUnrepresentable(schema, ctx, json, params, "Dynamic catch values are not supported in JSON Schema");
4561
+ return;
3375
4562
  }
3376
4563
  json.default = catchValue;
3377
4564
  };
@@ -3379,77 +4566,75 @@ var pipeProcessor = (schema, ctx, _json, params) => {
3379
4566
  const def = schema._zod.def;
3380
4567
  const inIsTransform = def.in._zod.traits.has("$ZodTransform");
3381
4568
  const innerType = ctx.io === "input" ? inIsTransform ? def.out : def.in : def.out;
3382
- process(innerType, ctx, params);
4569
+ processSchema(innerType, ctx, params);
3383
4570
  const seen = ctx.seen.get(schema);
3384
4571
  seen.ref = innerType;
3385
4572
  };
3386
4573
  var readonlyProcessor = (schema, ctx, json, params) => {
3387
4574
  const def = schema._zod.def;
3388
- process(def.innerType, ctx, params);
4575
+ processSchema(def.innerType, ctx, params);
3389
4576
  const seen = ctx.seen.get(schema);
3390
4577
  seen.ref = def.innerType;
3391
4578
  json.readOnly = true;
3392
4579
  };
3393
4580
  var optionalProcessor = (schema, ctx, _json, params) => {
3394
4581
  const def = schema._zod.def;
3395
- process(def.innerType, ctx, params);
4582
+ processSchema(def.innerType, ctx, params);
3396
4583
  const seen = ctx.seen.get(schema);
3397
4584
  seen.ref = def.innerType;
3398
4585
  };
3399
4586
  //#endregion
3400
- //#region ../../node_modules/.pnpm/zod@4.4.3/node_modules/zod/v4/classic/iso.js
3401
- var ZodISODateTime = /*@__PURE__*/ $constructor("ZodISODateTime", (inst, def) => {
3402
- $ZodISODateTime.init(inst, def);
3403
- ZodStringFormat.init(inst, def);
3404
- });
3405
- function datetime(params) {
3406
- return /* @__PURE__ */ _isoDateTime(ZodISODateTime, params);
3407
- }
3408
- var ZodISODate = /*@__PURE__*/ $constructor("ZodISODate", (inst, def) => {
3409
- $ZodISODate.init(inst, def);
3410
- ZodStringFormat.init(inst, def);
3411
- });
3412
- function date(params) {
3413
- return /* @__PURE__ */ _isoDate(ZodISODate, params);
3414
- }
3415
- var ZodISOTime = /*@__PURE__*/ $constructor("ZodISOTime", (inst, def) => {
3416
- $ZodISOTime.init(inst, def);
3417
- ZodStringFormat.init(inst, def);
3418
- });
3419
- function time(params) {
3420
- return /* @__PURE__ */ _isoTime(ZodISOTime, params);
3421
- }
3422
- var ZodISODuration = /*@__PURE__*/ $constructor("ZodISODuration", (inst, def) => {
3423
- $ZodISODuration.init(inst, def);
3424
- ZodStringFormat.init(inst, def);
3425
- });
3426
- function duration(params) {
3427
- return /* @__PURE__ */ _isoDuration(ZodISODuration, params);
4587
+ //#region ../../node_modules/.pnpm/zod@4.6.5/node_modules/zod/v4/classic/errors.js
4588
+ var _installedErrorProtos = /* @__PURE__ */ new WeakSet([Object.prototype, Error.prototype]);
4589
+ function _lazyMethod(proto, key, make) {
4590
+ Object.defineProperty(proto, key, {
4591
+ configurable: true,
4592
+ enumerable: false,
4593
+ get() {
4594
+ const value = make(this);
4595
+ Object.defineProperty(this, key, {
4596
+ value,
4597
+ configurable: true,
4598
+ writable: true
4599
+ });
4600
+ return value;
4601
+ },
4602
+ set(value) {
4603
+ Object.defineProperty(this, key, {
4604
+ value,
4605
+ configurable: true,
4606
+ writable: true
4607
+ });
4608
+ }
4609
+ });
3428
4610
  }
3429
- //#endregion
3430
- //#region ../../node_modules/.pnpm/zod@4.4.3/node_modules/zod/v4/classic/errors.js
3431
4611
  var initializer = (inst, issues) => {
3432
4612
  $ZodError.init(inst, issues);
3433
4613
  inst.name = "ZodError";
3434
- Object.defineProperties(inst, {
3435
- format: { value: (mapper) => formatError(inst, mapper) },
3436
- flatten: { value: (mapper) => flattenError(inst, mapper) },
3437
- addIssue: { value: (issue) => {
3438
- inst.issues.push(issue);
3439
- inst.message = JSON.stringify(inst.issues, jsonStringifyReplacer, 2);
3440
- } },
3441
- addIssues: { value: (issues) => {
3442
- inst.issues.push(...issues);
3443
- inst.message = JSON.stringify(inst.issues, jsonStringifyReplacer, 2);
3444
- } },
3445
- isEmpty: { get() {
3446
- return inst.issues.length === 0;
3447
- } }
4614
+ const proto = Object.getPrototypeOf(inst);
4615
+ if (_installedErrorProtos.has(proto)) return;
4616
+ _installedErrorProtos.add(proto);
4617
+ _lazyMethod(proto, "format", (self) => (mapper) => formatError(self, mapper));
4618
+ _lazyMethod(proto, "flatten", (self) => (mapper) => flattenError(self, mapper));
4619
+ _lazyMethod(proto, "addIssue", (self) => (issue) => {
4620
+ self.issues.push(issue);
4621
+ self.message = JSON.stringify(self.issues, jsonStringifyReplacer, 2);
4622
+ });
4623
+ _lazyMethod(proto, "addIssues", (self) => (issues) => {
4624
+ self.issues.push(...issues);
4625
+ self.message = JSON.stringify(self.issues, jsonStringifyReplacer, 2);
4626
+ });
4627
+ Object.defineProperty(proto, "isEmpty", {
4628
+ configurable: true,
4629
+ enumerable: false,
4630
+ get() {
4631
+ return this.issues.length === 0;
4632
+ }
3448
4633
  });
3449
4634
  };
3450
- var ZodRealError = /*@__PURE__*/ $constructor("ZodError", initializer, { Parent: Error });
4635
+ var ZodRealError = /*@__PURE__*/ $constructor("ZodError", initializer, void 0, { Parent: Error });
3451
4636
  //#endregion
3452
- //#region ../../node_modules/.pnpm/zod@4.4.3/node_modules/zod/v4/classic/parse.js
4637
+ //#region ../../node_modules/.pnpm/zod@4.6.5/node_modules/zod/v4/classic/parse.js
3453
4638
  var parse = /* @__PURE__ */ _parse(ZodRealError);
3454
4639
  var parseAsync = /* @__PURE__ */ _parseAsync(ZodRealError);
3455
4640
  var safeParse = /* @__PURE__ */ _safeParse(ZodRealError);
@@ -3463,255 +4648,320 @@ var safeDecode = /* @__PURE__ */ _safeDecode(ZodRealError);
3463
4648
  var safeEncodeAsync = /* @__PURE__ */ _safeEncodeAsync(ZodRealError);
3464
4649
  var safeDecodeAsync = /* @__PURE__ */ _safeDecodeAsync(ZodRealError);
3465
4650
  //#endregion
3466
- //#region ../../node_modules/.pnpm/zod@4.4.3/node_modules/zod/v4/classic/schemas.js
3467
- var _installedGroups = /* @__PURE__ */ new WeakMap();
3468
- function _installLazyMethods(inst, group, methods) {
3469
- const proto = Object.getPrototypeOf(inst);
3470
- let installed = _installedGroups.get(proto);
3471
- if (!installed) {
3472
- installed = /* @__PURE__ */ new Set();
3473
- _installedGroups.set(proto, installed);
3474
- }
3475
- if (installed.has(group)) return;
3476
- installed.add(group);
3477
- for (const key in methods) {
3478
- const fn = methods[key];
3479
- Object.defineProperty(proto, key, {
3480
- configurable: true,
3481
- enumerable: false,
3482
- get() {
3483
- const bound = fn.bind(this);
3484
- Object.defineProperty(this, key, {
3485
- configurable: true,
3486
- writable: true,
3487
- enumerable: true,
3488
- value: bound
3489
- });
3490
- return bound;
3491
- },
3492
- set(v) {
3493
- Object.defineProperty(this, key, {
3494
- configurable: true,
3495
- writable: true,
3496
- enumerable: true,
3497
- value: v
3498
- });
3499
- }
3500
- });
3501
- }
4651
+ //#region ../../node_modules/.pnpm/zod@4.6.5/node_modules/zod/v4/classic/schemas.js
4652
+ function _ensureDefaultLocale() {
4653
+ if (!globalConfig.localeError) config(en_default());
4654
+ }
4655
+ function _ensureDefaultMemoizer() {
4656
+ if (!globalConfig.memoizer) config({ memoizer: memoizer() });
3502
4657
  }
3503
4658
  var ZodType = /*@__PURE__*/ $constructor("ZodType", (inst, def) => {
4659
+ _ensureDefaultLocale();
3504
4660
  $ZodType.init(inst, def);
3505
- Object.assign(inst["~standard"], { jsonSchema: {
3506
- input: createStandardJSONSchemaMethod(inst, "input"),
3507
- output: createStandardJSONSchemaMethod(inst, "output")
3508
- } });
3509
- inst.toJSONSchema = createToJSONSchemaMethod(inst, {});
3510
4661
  inst.def = def;
3511
4662
  inst.type = def.type;
3512
- Object.defineProperty(inst, "_def", { value: def });
3513
- inst.parse = (data, params) => parse(inst, data, params, { callee: inst.parse });
3514
- inst.safeParse = (data, params) => safeParse(inst, data, params);
3515
- inst.parseAsync = async (data, params) => parseAsync(inst, data, params, { callee: inst.parseAsync });
3516
- inst.safeParseAsync = async (data, params) => safeParseAsync(inst, data, params);
3517
- inst.spa = inst.safeParseAsync;
3518
- inst.encode = (data, params) => encode(inst, data, params);
3519
- inst.decode = (data, params) => decode(inst, data, params);
3520
- inst.encodeAsync = async (data, params) => encodeAsync(inst, data, params);
3521
- inst.decodeAsync = async (data, params) => decodeAsync(inst, data, params);
3522
- inst.safeEncode = (data, params) => safeEncode(inst, data, params);
3523
- inst.safeDecode = (data, params) => safeDecode(inst, data, params);
3524
- inst.safeEncodeAsync = async (data, params) => safeEncodeAsync(inst, data, params);
3525
- inst.safeDecodeAsync = async (data, params) => safeDecodeAsync(inst, data, params);
3526
- _installLazyMethods(inst, "ZodType", {
3527
- check(...chks) {
3528
- const def = this.def;
3529
- return this.clone(mergeDefs(def, { checks: [...def.checks ?? [], ...chks.map((ch) => typeof ch === "function" ? { _zod: {
3530
- check: ch,
3531
- def: { check: "custom" },
3532
- onattach: []
3533
- } } : ch)] }), { parent: true });
3534
- },
3535
- with(...chks) {
3536
- return this.check(...chks);
3537
- },
3538
- clone(def, params) {
3539
- return clone(this, def, params);
3540
- },
3541
- brand() {
3542
- return this;
3543
- },
3544
- register(reg, meta) {
3545
- reg.add(this, meta);
3546
- return this;
3547
- },
3548
- refine(check, params) {
3549
- return this.check(refine(check, params));
3550
- },
3551
- superRefine(refinement, params) {
3552
- return this.check(superRefine(refinement, params));
3553
- },
3554
- overwrite(fn) {
3555
- return this.check(/* @__PURE__ */ _overwrite(fn));
3556
- },
3557
- optional() {
3558
- return optional(this);
3559
- },
3560
- exactOptional() {
3561
- return exactOptional(this);
3562
- },
3563
- nullable() {
3564
- return nullable(this);
3565
- },
3566
- nullish() {
3567
- return optional(nullable(this));
3568
- },
3569
- nonoptional(params) {
3570
- return nonoptional(this, params);
3571
- },
3572
- array() {
3573
- return array(this);
3574
- },
3575
- or(arg) {
3576
- return union([this, arg]);
3577
- },
3578
- and(arg) {
3579
- return intersection(this, arg);
3580
- },
3581
- transform(tx) {
3582
- return pipe(this, transform(tx));
3583
- },
3584
- default(d) {
3585
- return _default(this, d);
3586
- },
3587
- prefault(d) {
3588
- return prefault(this, d);
3589
- },
3590
- catch(params) {
3591
- return _catch(this, params);
3592
- },
3593
- pipe(target) {
3594
- return pipe(this, target);
3595
- },
3596
- readonly() {
3597
- return readonly(this);
3598
- },
3599
- describe(description) {
3600
- const cl = this.clone();
3601
- globalRegistry.add(cl, { description });
3602
- return cl;
3603
- },
3604
- meta(...args) {
3605
- if (args.length === 0) return globalRegistry.get(this);
3606
- const cl = this.clone();
3607
- globalRegistry.add(cl, args[0]);
3608
- return cl;
3609
- },
3610
- isOptional() {
3611
- return this.safeParse(void 0).success;
3612
- },
3613
- isNullable() {
3614
- return this.safeParse(null).success;
3615
- },
3616
- apply(fn) {
3617
- return fn(this);
3618
- }
3619
- });
3620
- Object.defineProperty(inst, "description", {
3621
- get() {
3622
- return globalRegistry.get(inst)?.description;
3623
- },
3624
- configurable: true
3625
- });
3626
4663
  return inst;
4664
+ }, {
4665
+ check(...chks) {
4666
+ const def = this.def;
4667
+ return this.clone(mergeDefs(def, { checks: [...def.checks ?? [], ...chks.map((ch) => typeof ch === "function" ? { _zod: {
4668
+ check: ch,
4669
+ def: { check: "custom" },
4670
+ onattach: []
4671
+ } } : ch)] }), { parent: true });
4672
+ },
4673
+ with(...chks) {
4674
+ return this.check(...chks);
4675
+ },
4676
+ clone(def, params) {
4677
+ return clone(this, def, params);
4678
+ },
4679
+ brand() {
4680
+ return this;
4681
+ },
4682
+ register(reg, meta) {
4683
+ reg.add(this, meta);
4684
+ return this;
4685
+ },
4686
+ refine(check, params) {
4687
+ return this.check(refine(check, params));
4688
+ },
4689
+ superRefine(refinement, params) {
4690
+ return this.check(superRefine(refinement, params));
4691
+ },
4692
+ overwrite(fn) {
4693
+ return this.check(/* @__PURE__ */ _overwrite(fn));
4694
+ },
4695
+ optional() {
4696
+ return optional(this);
4697
+ },
4698
+ exactOptional() {
4699
+ return exactOptional(this);
4700
+ },
4701
+ nullable() {
4702
+ return nullable(this);
4703
+ },
4704
+ nullish() {
4705
+ return optional(nullable(this));
4706
+ },
4707
+ nonoptional(params) {
4708
+ return nonoptional(this, params);
4709
+ },
4710
+ array() {
4711
+ return array(this);
4712
+ },
4713
+ or(arg) {
4714
+ return union([this, arg]);
4715
+ },
4716
+ and(arg) {
4717
+ return intersection(this, arg);
4718
+ },
4719
+ transform(tx) {
4720
+ return pipe(this, transform(tx));
4721
+ },
4722
+ default(d) {
4723
+ return _default(this, d);
4724
+ },
4725
+ prefault(d) {
4726
+ return prefault(this, d);
4727
+ },
4728
+ catch(params) {
4729
+ return _catch(this, params);
4730
+ },
4731
+ pipe(target) {
4732
+ return pipe(this, target);
4733
+ },
4734
+ readonly() {
4735
+ return readonly(this);
4736
+ },
4737
+ describe(description) {
4738
+ const cl = this.clone();
4739
+ globalRegistry.add(cl, { description });
4740
+ return cl;
4741
+ },
4742
+ meta(...args) {
4743
+ if (args.length === 0) return globalRegistry.get(this);
4744
+ const cl = this.clone();
4745
+ globalRegistry.add(cl, args[0]);
4746
+ return cl;
4747
+ },
4748
+ isOptional() {
4749
+ return this.safeParse(void 0).success;
4750
+ },
4751
+ isNullable() {
4752
+ return this.safeParse(null).success;
4753
+ },
4754
+ apply(fn, ...args) {
4755
+ return args.length === 0 ? fn(this) : fn(this, ...args);
4756
+ },
4757
+ get "~standard"() {
4758
+ return hide(this, "~standard", {
4759
+ ...standardProps(this),
4760
+ jsonSchema: {
4761
+ input: createStandardJSONSchemaMethod(this, "input"),
4762
+ output: createStandardJSONSchemaMethod(this, "output")
4763
+ }
4764
+ });
4765
+ },
4766
+ set "~standard"(value) {
4767
+ own(this, "~standard", value);
4768
+ },
4769
+ parse: function _parse(data, params) {
4770
+ return parse(this, data, params, { callee: _parse });
4771
+ },
4772
+ parseAsync: async function _parseAsync(data, params) {
4773
+ return await parseAsync(this, data, params, { callee: _parseAsync });
4774
+ },
4775
+ safeParse(data, params) {
4776
+ return safeParse(this, data, params);
4777
+ },
4778
+ async safeParseAsync(data, params) {
4779
+ return safeParseAsync(this, data, params);
4780
+ },
4781
+ get spa() {
4782
+ return this?.safeParseAsync;
4783
+ },
4784
+ set spa(value) {
4785
+ own(this, "spa", value);
4786
+ },
4787
+ validate(data, params) {
4788
+ return validate(this, data, params);
4789
+ },
4790
+ validateAsync(data, params) {
4791
+ return validateAsync$1(this, data, params);
4792
+ },
4793
+ encode: function _encode(data, params) {
4794
+ return encode(this, data, params, { callee: _encode });
4795
+ },
4796
+ decode: function _decode(data, params) {
4797
+ return decode(this, data, params, { callee: _decode });
4798
+ },
4799
+ encodeAsync: async function _encodeAsync(data, params) {
4800
+ return await encodeAsync(this, data, params, { callee: _encodeAsync });
4801
+ },
4802
+ decodeAsync: async function _decodeAsync(data, params) {
4803
+ return await decodeAsync(this, data, params, { callee: _decodeAsync });
4804
+ },
4805
+ safeEncode(data, params) {
4806
+ return safeEncode(this, data, params);
4807
+ },
4808
+ safeDecode(data, params) {
4809
+ return safeDecode(this, data, params);
4810
+ },
4811
+ async safeEncodeAsync(data, params) {
4812
+ return safeEncodeAsync(this, data, params);
4813
+ },
4814
+ async safeDecodeAsync(data, params) {
4815
+ return safeDecodeAsync(this, data, params);
4816
+ },
4817
+ toJSONSchema(params) {
4818
+ return createToJSONSchemaMethod(this, {})(params);
4819
+ },
4820
+ get description() {
4821
+ return globalRegistry.get(this)?.description;
4822
+ },
4823
+ get _def() {
4824
+ return this._zod.def;
4825
+ }
3627
4826
  });
3628
4827
  /** @internal */
3629
4828
  var _ZodString = /*@__PURE__*/ $constructor("_ZodString", (inst, def) => {
3630
4829
  $ZodString.init(inst, def);
3631
4830
  ZodType.init(inst, def);
3632
4831
  inst._zod.processJSONSchema = (ctx, json, params) => stringProcessor(inst, ctx, json, params);
3633
- const bag = inst._zod.bag;
3634
- inst.format = bag.format ?? null;
3635
- inst.minLength = bag.minimum ?? null;
3636
- inst.maxLength = bag.maximum ?? null;
3637
- _installLazyMethods(inst, "_ZodString", {
3638
- regex(...args) {
3639
- return this.check(/* @__PURE__ */ _regex(...args));
3640
- },
3641
- includes(...args) {
3642
- return this.check(/* @__PURE__ */ _includes(...args));
3643
- },
3644
- startsWith(...args) {
3645
- return this.check(/* @__PURE__ */ _startsWith(...args));
3646
- },
3647
- endsWith(...args) {
3648
- return this.check(/* @__PURE__ */ _endsWith(...args));
3649
- },
3650
- min(...args) {
3651
- return this.check(/* @__PURE__ */ _minLength(...args));
3652
- },
3653
- max(...args) {
3654
- return this.check(/* @__PURE__ */ _maxLength(...args));
3655
- },
3656
- length(...args) {
3657
- return this.check(/* @__PURE__ */ _length(...args));
3658
- },
3659
- nonempty(...args) {
3660
- return this.check(/* @__PURE__ */ _minLength(1, ...args));
3661
- },
3662
- lowercase(params) {
3663
- return this.check(/* @__PURE__ */ _lowercase(params));
3664
- },
3665
- uppercase(params) {
3666
- return this.check(/* @__PURE__ */ _uppercase(params));
3667
- },
3668
- trim() {
3669
- return this.check(/* @__PURE__ */ _trim());
3670
- },
3671
- normalize(...args) {
3672
- return this.check(/* @__PURE__ */ _normalize(...args));
3673
- },
3674
- toLowerCase() {
3675
- return this.check(/* @__PURE__ */ _toLowerCase());
3676
- },
3677
- toUpperCase() {
3678
- return this.check(/* @__PURE__ */ _toUpperCase());
3679
- },
3680
- slugify() {
3681
- return this.check(/* @__PURE__ */ _slugify());
3682
- }
3683
- });
3684
- });
4832
+ }, /*@__PURE__*/ derived({
4833
+ format: (inst) => aggregateChecks(inst).format ?? null,
4834
+ minLength: (inst) => aggregateChecks(inst).minimum ?? null,
4835
+ maxLength: (inst) => aggregateChecks(inst).maximum ?? null
4836
+ }, {
4837
+ regex(...args) {
4838
+ return this.check(/* @__PURE__ */ _regex(...args));
4839
+ },
4840
+ includes(...args) {
4841
+ return this.check(/* @__PURE__ */ _includes(...args));
4842
+ },
4843
+ startsWith(...args) {
4844
+ return this.check(/* @__PURE__ */ _startsWith(...args));
4845
+ },
4846
+ endsWith(...args) {
4847
+ return this.check(/* @__PURE__ */ _endsWith(...args));
4848
+ },
4849
+ min(...args) {
4850
+ return this.check(/* @__PURE__ */ _minLength(...args));
4851
+ },
4852
+ max(...args) {
4853
+ return this.check(/* @__PURE__ */ _maxLength(...args));
4854
+ },
4855
+ length(...args) {
4856
+ return this.check(/* @__PURE__ */ _length(...args));
4857
+ },
4858
+ nonempty(...args) {
4859
+ return this.check(/* @__PURE__ */ _minLength(1, ...args));
4860
+ },
4861
+ lowercase(params) {
4862
+ return this.check(/* @__PURE__ */ _lowercase(params));
4863
+ },
4864
+ uppercase(params) {
4865
+ return this.check(/* @__PURE__ */ _uppercase(params));
4866
+ },
4867
+ trim() {
4868
+ return this.check(/* @__PURE__ */ _trim());
4869
+ },
4870
+ normalize(...args) {
4871
+ return this.check(/* @__PURE__ */ _normalize(...args));
4872
+ },
4873
+ toLowerCase() {
4874
+ return this.check(/* @__PURE__ */ _toLowerCase());
4875
+ },
4876
+ toUpperCase() {
4877
+ return this.check(/* @__PURE__ */ _toUpperCase());
4878
+ },
4879
+ slugify() {
4880
+ return this.check(/* @__PURE__ */ _slugify());
4881
+ }
4882
+ }));
3685
4883
  var ZodString = /*@__PURE__*/ $constructor("ZodString", (inst, def) => {
3686
4884
  $ZodString.init(inst, def);
3687
4885
  _ZodString.init(inst, def);
3688
- inst.email = (params) => inst.check(/* @__PURE__ */ _email(ZodEmail, params));
3689
- inst.url = (params) => inst.check(/* @__PURE__ */ _url(ZodURL, params));
3690
- inst.jwt = (params) => inst.check(/* @__PURE__ */ _jwt(ZodJWT, params));
3691
- inst.emoji = (params) => inst.check(/* @__PURE__ */ _emoji(ZodEmoji, params));
3692
- inst.guid = (params) => inst.check(/* @__PURE__ */ _guid(ZodGUID, params));
3693
- inst.uuid = (params) => inst.check(/* @__PURE__ */ _uuid(ZodUUID, params));
3694
- inst.uuidv4 = (params) => inst.check(/* @__PURE__ */ _uuidv4(ZodUUID, params));
3695
- inst.uuidv6 = (params) => inst.check(/* @__PURE__ */ _uuidv6(ZodUUID, params));
3696
- inst.uuidv7 = (params) => inst.check(/* @__PURE__ */ _uuidv7(ZodUUID, params));
3697
- inst.nanoid = (params) => inst.check(/* @__PURE__ */ _nanoid(ZodNanoID, params));
3698
- inst.guid = (params) => inst.check(/* @__PURE__ */ _guid(ZodGUID, params));
3699
- inst.cuid = (params) => inst.check(/* @__PURE__ */ _cuid(ZodCUID, params));
3700
- inst.cuid2 = (params) => inst.check(/* @__PURE__ */ _cuid2(ZodCUID2, params));
3701
- inst.ulid = (params) => inst.check(/* @__PURE__ */ _ulid(ZodULID, params));
3702
- inst.base64 = (params) => inst.check(/* @__PURE__ */ _base64(ZodBase64, params));
3703
- inst.base64url = (params) => inst.check(/* @__PURE__ */ _base64url(ZodBase64URL, params));
3704
- inst.xid = (params) => inst.check(/* @__PURE__ */ _xid(ZodXID, params));
3705
- inst.ksuid = (params) => inst.check(/* @__PURE__ */ _ksuid(ZodKSUID, params));
3706
- inst.ipv4 = (params) => inst.check(/* @__PURE__ */ _ipv4(ZodIPv4, params));
3707
- inst.ipv6 = (params) => inst.check(/* @__PURE__ */ _ipv6(ZodIPv6, params));
3708
- inst.cidrv4 = (params) => inst.check(/* @__PURE__ */ _cidrv4(ZodCIDRv4, params));
3709
- inst.cidrv6 = (params) => inst.check(/* @__PURE__ */ _cidrv6(ZodCIDRv6, params));
3710
- inst.e164 = (params) => inst.check(/* @__PURE__ */ _e164(ZodE164, params));
3711
- inst.datetime = (params) => inst.check(datetime(params));
3712
- inst.date = (params) => inst.check(date(params));
3713
- inst.time = (params) => inst.check(time(params));
3714
- inst.duration = (params) => inst.check(duration(params));
4886
+ }, {
4887
+ email(params) {
4888
+ return this.check(/* @__PURE__ */ _email(ZodEmail, params));
4889
+ },
4890
+ url(params) {
4891
+ return this.check(/* @__PURE__ */ _url(ZodURL, params));
4892
+ },
4893
+ jwt(params) {
4894
+ return this.check(/* @__PURE__ */ _jwt(ZodJWT, params));
4895
+ },
4896
+ emoji(params) {
4897
+ return this.check(/* @__PURE__ */ _emoji(ZodEmoji, params));
4898
+ },
4899
+ guid(params) {
4900
+ return this.check(/* @__PURE__ */ _guid(ZodGUID, params));
4901
+ },
4902
+ uuid(params) {
4903
+ return this.check(/* @__PURE__ */ _uuid(ZodUUID, params));
4904
+ },
4905
+ uuidv4(params) {
4906
+ return this.check(/* @__PURE__ */ _uuidv4(ZodUUID, params));
4907
+ },
4908
+ uuidv6(params) {
4909
+ return this.check(/* @__PURE__ */ _uuidv6(ZodUUID, params));
4910
+ },
4911
+ uuidv7(params) {
4912
+ return this.check(/* @__PURE__ */ _uuidv7(ZodUUID, params));
4913
+ },
4914
+ nanoid(params) {
4915
+ return this.check(/* @__PURE__ */ _nanoid(ZodNanoID, params));
4916
+ },
4917
+ cuid(params) {
4918
+ return this.check(/* @__PURE__ */ _cuid(ZodCUID, params));
4919
+ },
4920
+ cuid2(params) {
4921
+ return this.check(/* @__PURE__ */ _cuid2(ZodCUID2, params));
4922
+ },
4923
+ ulid(params) {
4924
+ return this.check(/* @__PURE__ */ _ulid(ZodULID, params));
4925
+ },
4926
+ base64(params) {
4927
+ return this.check(/* @__PURE__ */ _base64(ZodBase64, params));
4928
+ },
4929
+ base64url(params) {
4930
+ return this.check(/* @__PURE__ */ _base64url(ZodBase64URL, params));
4931
+ },
4932
+ xid(params) {
4933
+ return this.check(/* @__PURE__ */ _xid(ZodXID, params));
4934
+ },
4935
+ ksuid(params) {
4936
+ return this.check(/* @__PURE__ */ _ksuid(ZodKSUID, params));
4937
+ },
4938
+ ipv4(params) {
4939
+ return this.check(/* @__PURE__ */ _ipv4(ZodIPv4, params));
4940
+ },
4941
+ ipv6(params) {
4942
+ return this.check(/* @__PURE__ */ _ipv6(ZodIPv6, params));
4943
+ },
4944
+ cidrv4(params) {
4945
+ return this.check(/* @__PURE__ */ _cidrv4(ZodCIDRv4, params));
4946
+ },
4947
+ cidrv6(params) {
4948
+ return this.check(/* @__PURE__ */ _cidrv6(ZodCIDRv6, params));
4949
+ },
4950
+ e164(params) {
4951
+ return this.check(/* @__PURE__ */ _e164(ZodE164, params));
4952
+ },
4953
+ datetime(params) {
4954
+ return this.check(/* @__PURE__ */ _isoDateTime(ZodISODateTime, params));
4955
+ },
4956
+ date(params) {
4957
+ return this.check(/* @__PURE__ */ _isoDate(ZodISODate, params));
4958
+ },
4959
+ time(params) {
4960
+ return this.check(/* @__PURE__ */ _isoTime(ZodISOTime, params));
4961
+ },
4962
+ duration(params) {
4963
+ return this.check(/* @__PURE__ */ _isoDuration(ZodISODuration, params));
4964
+ }
3715
4965
  });
3716
4966
  function string(params) {
3717
4967
  return /* @__PURE__ */ _string(ZodString, params);
@@ -3720,6 +4970,22 @@ var ZodStringFormat = /*@__PURE__*/ $constructor("ZodStringFormat", (inst, def)
3720
4970
  $ZodStringFormat.init(inst, def);
3721
4971
  _ZodString.init(inst, def);
3722
4972
  });
4973
+ var ZodISODateTime = /*@__PURE__*/ $constructor("ZodISODateTime", (inst, def) => {
4974
+ $ZodISODateTime.init(inst, def);
4975
+ ZodStringFormat.init(inst, def);
4976
+ });
4977
+ var ZodISODate = /*@__PURE__*/ $constructor("ZodISODate", (inst, def) => {
4978
+ $ZodISODate.init(inst, def);
4979
+ ZodStringFormat.init(inst, def);
4980
+ });
4981
+ var ZodISOTime = /*@__PURE__*/ $constructor("ZodISOTime", (inst, def) => {
4982
+ $ZodISOTime.init(inst, def);
4983
+ ZodStringFormat.init(inst, def);
4984
+ });
4985
+ var ZodISODuration = /*@__PURE__*/ $constructor("ZodISODuration", (inst, def) => {
4986
+ $ZodISODuration.init(inst, def);
4987
+ ZodStringFormat.init(inst, def);
4988
+ });
3723
4989
  var ZodEmail = /*@__PURE__*/ $constructor("ZodEmail", (inst, def) => {
3724
4990
  $ZodEmail.init(inst, def);
3725
4991
  ZodStringFormat.init(inst, def);
@@ -3815,60 +5081,68 @@ var ZodNumber = /*@__PURE__*/ $constructor("ZodNumber", (inst, def) => {
3815
5081
  $ZodNumber.init(inst, def);
3816
5082
  ZodType.init(inst, def);
3817
5083
  inst._zod.processJSONSchema = (ctx, json, params) => numberProcessor(inst, ctx, json, params);
3818
- _installLazyMethods(inst, "ZodNumber", {
3819
- gt(value, params) {
3820
- return this.check(/* @__PURE__ */ _gt(value, params));
3821
- },
3822
- gte(value, params) {
3823
- return this.check(/* @__PURE__ */ _gte(value, params));
3824
- },
3825
- min(value, params) {
3826
- return this.check(/* @__PURE__ */ _gte(value, params));
3827
- },
3828
- lt(value, params) {
3829
- return this.check(/* @__PURE__ */ _lt(value, params));
3830
- },
3831
- lte(value, params) {
3832
- return this.check(/* @__PURE__ */ _lte(value, params));
3833
- },
3834
- max(value, params) {
3835
- return this.check(/* @__PURE__ */ _lte(value, params));
3836
- },
3837
- int(params) {
3838
- return this.check(int(params));
3839
- },
3840
- safe(params) {
3841
- return this.check(int(params));
3842
- },
3843
- positive(params) {
3844
- return this.check(/* @__PURE__ */ _gt(0, params));
3845
- },
3846
- nonnegative(params) {
3847
- return this.check(/* @__PURE__ */ _gte(0, params));
3848
- },
3849
- negative(params) {
3850
- return this.check(/* @__PURE__ */ _lt(0, params));
3851
- },
3852
- nonpositive(params) {
3853
- return this.check(/* @__PURE__ */ _lte(0, params));
3854
- },
3855
- multipleOf(value, params) {
3856
- return this.check(/* @__PURE__ */ _multipleOf(value, params));
3857
- },
3858
- step(value, params) {
3859
- return this.check(/* @__PURE__ */ _multipleOf(value, params));
3860
- },
3861
- finite() {
3862
- return this;
3863
- }
3864
- });
3865
- const bag = inst._zod.bag;
3866
- inst.minValue = Math.max(bag.minimum ?? Number.NEGATIVE_INFINITY, bag.exclusiveMinimum ?? Number.NEGATIVE_INFINITY) ?? null;
3867
- inst.maxValue = Math.min(bag.maximum ?? Number.POSITIVE_INFINITY, bag.exclusiveMaximum ?? Number.POSITIVE_INFINITY) ?? null;
3868
- inst.isInt = (bag.format ?? "").includes("int") || Number.isSafeInteger(bag.multipleOf ?? .5);
3869
5084
  inst.isFinite = true;
3870
- inst.format = bag.format ?? null;
3871
- });
5085
+ }, /*@__PURE__*/ derived({
5086
+ minValue: (inst) => {
5087
+ const { minimum, exclusiveMinimum } = aggregateChecks(inst);
5088
+ return Math.max(minimum ?? Number.NEGATIVE_INFINITY, exclusiveMinimum ?? Number.NEGATIVE_INFINITY);
5089
+ },
5090
+ maxValue: (inst) => {
5091
+ const { maximum, exclusiveMaximum } = aggregateChecks(inst);
5092
+ return Math.min(maximum ?? Number.POSITIVE_INFINITY, exclusiveMaximum ?? Number.POSITIVE_INFINITY);
5093
+ },
5094
+ isInt: (inst) => {
5095
+ const { isInt, multipleOf } = aggregateChecks(inst);
5096
+ return !!isInt || !!multipleOf?.some(Number.isSafeInteger);
5097
+ },
5098
+ format: (inst) => aggregateChecks(inst).format ?? null
5099
+ }, {
5100
+ gt(value, params) {
5101
+ return this.check(/* @__PURE__ */ _gt(value, params));
5102
+ },
5103
+ gte(value, params) {
5104
+ return this.check(/* @__PURE__ */ _gte(value, params));
5105
+ },
5106
+ min(value, params) {
5107
+ return this.check(/* @__PURE__ */ _gte(value, params));
5108
+ },
5109
+ lt(value, params) {
5110
+ return this.check(/* @__PURE__ */ _lt(value, params));
5111
+ },
5112
+ lte(value, params) {
5113
+ return this.check(/* @__PURE__ */ _lte(value, params));
5114
+ },
5115
+ max(value, params) {
5116
+ return this.check(/* @__PURE__ */ _lte(value, params));
5117
+ },
5118
+ int(params) {
5119
+ return this.check(int(params));
5120
+ },
5121
+ safe(params) {
5122
+ return this.check(int(params));
5123
+ },
5124
+ positive(params) {
5125
+ return this.check(/* @__PURE__ */ _gt(0, params));
5126
+ },
5127
+ nonnegative(params) {
5128
+ return this.check(/* @__PURE__ */ _gte(0, params));
5129
+ },
5130
+ negative(params) {
5131
+ return this.check(/* @__PURE__ */ _lt(0, params));
5132
+ },
5133
+ nonpositive(params) {
5134
+ return this.check(/* @__PURE__ */ _lte(0, params));
5135
+ },
5136
+ multipleOf(value, params) {
5137
+ return this.check(/* @__PURE__ */ _multipleOf(value, params));
5138
+ },
5139
+ step(value, params) {
5140
+ return this.check(/* @__PURE__ */ _multipleOf(value, params));
5141
+ },
5142
+ finite() {
5143
+ return this;
5144
+ }
5145
+ }));
3872
5146
  function number(params) {
3873
5147
  return /* @__PURE__ */ _number(ZodNumber, params);
3874
5148
  }
@@ -3904,94 +5178,80 @@ function never(params) {
3904
5178
  return /* @__PURE__ */ _never(ZodNever, params);
3905
5179
  }
3906
5180
  var ZodArray = /*@__PURE__*/ $constructor("ZodArray", (inst, def) => {
5181
+ _ensureDefaultMemoizer();
3907
5182
  $ZodArray.init(inst, def);
3908
5183
  ZodType.init(inst, def);
3909
5184
  inst._zod.processJSONSchema = (ctx, json, params) => arrayProcessor(inst, ctx, json, params);
3910
5185
  inst.element = def.element;
3911
- _installLazyMethods(inst, "ZodArray", {
3912
- min(n, params) {
3913
- return this.check(/* @__PURE__ */ _minLength(n, params));
3914
- },
3915
- nonempty(params) {
3916
- return this.check(/* @__PURE__ */ _minLength(1, params));
3917
- },
3918
- max(n, params) {
3919
- return this.check(/* @__PURE__ */ _maxLength(n, params));
3920
- },
3921
- length(n, params) {
3922
- return this.check(/* @__PURE__ */ _length(n, params));
3923
- },
3924
- unwrap() {
3925
- return this.element;
3926
- }
3927
- });
5186
+ }, {
5187
+ min(n, params) {
5188
+ return this.check(/* @__PURE__ */ _minLength(n, params));
5189
+ },
5190
+ nonempty(params) {
5191
+ return this.check(/* @__PURE__ */ _minLength(1, params));
5192
+ },
5193
+ max(n, params) {
5194
+ return this.check(/* @__PURE__ */ _maxLength(n, params));
5195
+ },
5196
+ length(n, params) {
5197
+ return this.check(/* @__PURE__ */ _length(n, params));
5198
+ },
5199
+ unwrap() {
5200
+ return this.element;
5201
+ }
3928
5202
  });
3929
5203
  function array(element, params) {
3930
5204
  return /* @__PURE__ */ _array(ZodArray, element, params);
3931
5205
  }
3932
5206
  var ZodObject = /*@__PURE__*/ $constructor("ZodObject", (inst, def) => {
5207
+ _ensureDefaultMemoizer();
3933
5208
  $ZodObjectJIT.init(inst, def);
3934
5209
  ZodType.init(inst, def);
3935
5210
  inst._zod.processJSONSchema = (ctx, json, params) => objectProcessor(inst, ctx, json, params);
3936
- defineLazy(inst, "shape", () => {
3937
- return def.shape;
3938
- });
3939
- _installLazyMethods(inst, "ZodObject", {
3940
- keyof() {
3941
- return _enum(Object.keys(this._zod.def.shape));
3942
- },
3943
- catchall(catchall) {
3944
- return this.clone({
3945
- ...this._zod.def,
3946
- catchall
3947
- });
3948
- },
3949
- passthrough() {
3950
- return this.clone({
3951
- ...this._zod.def,
3952
- catchall: unknown()
3953
- });
3954
- },
3955
- loose() {
3956
- return this.clone({
3957
- ...this._zod.def,
3958
- catchall: unknown()
3959
- });
3960
- },
3961
- strict() {
3962
- return this.clone({
3963
- ...this._zod.def,
3964
- catchall: never()
3965
- });
3966
- },
3967
- strip() {
3968
- return this.clone({
3969
- ...this._zod.def,
3970
- catchall: void 0
3971
- });
3972
- },
3973
- extend(incoming) {
3974
- return extend(this, incoming);
3975
- },
3976
- safeExtend(incoming) {
3977
- return safeExtend(this, incoming);
3978
- },
3979
- merge(other) {
3980
- return merge(this, other);
3981
- },
3982
- pick(mask) {
3983
- return pick(this, mask);
3984
- },
3985
- omit(mask) {
3986
- return omit(this, mask);
3987
- },
3988
- partial(...args) {
3989
- return partial(ZodOptional, this, args[0]);
3990
- },
3991
- required(...args) {
3992
- return required(ZodNonOptional, this, args[0]);
3993
- }
3994
- });
5211
+ installLazyProp(inst, "shape", (self) => self._zod.def.shape, false);
5212
+ }, {
5213
+ keyof() {
5214
+ return _enum(Object.keys(this._zod.def.shape));
5215
+ },
5216
+ catchall(catchall) {
5217
+ return this.clone(mergeDefs(this._zod.def, { catchall }));
5218
+ },
5219
+ passthrough() {
5220
+ return this.clone(mergeDefs(this._zod.def, { catchall: unknown() }));
5221
+ },
5222
+ loose() {
5223
+ return this.clone(mergeDefs(this._zod.def, { catchall: unknown() }));
5224
+ },
5225
+ strict() {
5226
+ return this.clone(mergeDefs(this._zod.def, { catchall: never() }));
5227
+ },
5228
+ strip() {
5229
+ return this.clone(mergeDefs(this._zod.def, { catchall: void 0 }));
5230
+ },
5231
+ extend(incoming) {
5232
+ return extend(this, incoming);
5233
+ },
5234
+ safeExtend(incoming) {
5235
+ return safeExtend(this, incoming);
5236
+ },
5237
+ merge(other) {
5238
+ return merge(this, other);
5239
+ },
5240
+ pick(mask) {
5241
+ return pick(this, mask);
5242
+ },
5243
+ omit(mask) {
5244
+ return omit(this, mask);
5245
+ },
5246
+ partial(...args) {
5247
+ return partial(ZodOptional, this, args[0]);
5248
+ },
5249
+ exactPartial(...args) {
5250
+ return partial(ZodExactOptional, this, args[0], "exactPartial");
5251
+ },
5252
+ required(...args) {
5253
+ return required(ZodNonOptional, this, args[0]);
5254
+ }
3995
5255
  });
3996
5256
  function object(shape, params) {
3997
5257
  return new ZodObject({
@@ -4046,6 +5306,7 @@ function intersection(left, right) {
4046
5306
  });
4047
5307
  }
4048
5308
  var ZodRecord = /*@__PURE__*/ $constructor("ZodRecord", (inst, def) => {
5309
+ _ensureDefaultMemoizer();
4049
5310
  $ZodRecord.init(inst, def);
4050
5311
  ZodType.init(inst, def);
4051
5312
  inst._zod.processJSONSchema = (ctx, json, params) => recordProcessor(inst, ctx, json, params);
@@ -4071,7 +5332,7 @@ var ZodEnum = /*@__PURE__*/ $constructor("ZodEnum", (inst, def) => {
4071
5332
  ZodType.init(inst, def);
4072
5333
  inst._zod.processJSONSchema = (ctx, json, params) => enumProcessor(inst, ctx, json, params);
4073
5334
  inst.enum = def.entries;
4074
- inst.options = Object.values(def.entries);
5335
+ inst.options = [...inst._zod.values];
4075
5336
  const keys = new Set(Object.keys(def.entries));
4076
5337
  inst.extract = (values, params) => {
4077
5338
  const newEntries = {};
@@ -4121,6 +5382,7 @@ function literal(value, params) {
4121
5382
  });
4122
5383
  }
4123
5384
  var ZodTransform = /*@__PURE__*/ $constructor("ZodTransform", (inst, def) => {
5385
+ _ensureDefaultMemoizer();
4124
5386
  $ZodTransform.init(inst, def);
4125
5387
  ZodType.init(inst, def);
4126
5388
  inst._zod.processJSONSchema = (ctx, json, params) => transformProcessor(inst, ctx, json, params);
@@ -4132,7 +5394,7 @@ var ZodTransform = /*@__PURE__*/ $constructor("ZodTransform", (inst, def) => {
4132
5394
  const _issue = issue$1;
4133
5395
  if (_issue.fatal) _issue.continue = false;
4134
5396
  _issue.code ?? (_issue.code = "custom");
4135
- _issue.input ?? (_issue.input = payload.value);
5397
+ if (!("input" in _issue)) _issue.input = payload.value;
4136
5398
  _issue.inst ?? (_issue.inst = inst);
4137
5399
  payload.issues.push(issue(_issue));
4138
5400
  }
@@ -4140,11 +5402,9 @@ var ZodTransform = /*@__PURE__*/ $constructor("ZodTransform", (inst, def) => {
4140
5402
  const output = def.transform(payload.value, payload);
4141
5403
  if (output instanceof Promise) return output.then((output) => {
4142
5404
  payload.value = output;
4143
- payload.fallback = true;
4144
5405
  return payload;
4145
5406
  });
4146
5407
  payload.value = output;
4147
- payload.fallback = true;
4148
5408
  return payload;
4149
5409
  };
4150
5410
  });
@@ -4245,7 +5505,7 @@ function _catch(innerType, catchValue) {
4245
5505
  return new ZodCatch({
4246
5506
  type: "catch",
4247
5507
  innerType,
4248
- catchValue: typeof catchValue === "function" ? catchValue : () => catchValue
5508
+ catchValue: typeof catchValue === "function" ? catchValue : constantCatch(catchValue)
4249
5509
  });
4250
5510
  }
4251
5511
  var ZodPipe = /*@__PURE__*/ $constructor("ZodPipe", (inst, def) => {
@@ -4286,4 +5546,4 @@ function superRefine(fn, params) {
4286
5546
  return /* @__PURE__ */ _superRefine(fn, params);
4287
5547
  }
4288
5548
  //#endregion
4289
- export { httpUrl as a, number as c, string as d, uuid as f, discriminatedUnion as i, object as l, array as n, literal as o, boolean as r, looseObject as s, _enum as t, record as u };
5549
+ export { httpUrl as a, number as c, string as d, union as f, discriminatedUnion as i, object as l, array as n, literal as o, uuid as p, boolean as r, looseObject as s, _enum as t, record as u };