@ayepi/files 0.4.1 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/server.cjs CHANGED
@@ -1,83 +1,34 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
2
  let node_crypto = require("node:crypto");
3
3
  let _ayepi_core = require("@ayepi/core");
4
- //#region ../../node_modules/.pnpm/zod@4.4.3/node_modules/zod/v4/core/core.js
5
- var _a$1;
6
- function $constructor(name, initializer, params) {
7
- function init(inst, def) {
8
- if (!inst._zod) Object.defineProperty(inst, "_zod", {
9
- value: {
10
- def,
11
- constr: _,
12
- traits: /* @__PURE__ */ new Set()
13
- },
14
- enumerable: false
15
- });
16
- if (inst._zod.traits.has(name)) return;
17
- inst._zod.traits.add(name);
18
- initializer(inst, def);
19
- const proto = _.prototype;
20
- const keys = Object.keys(proto);
21
- for (let i = 0; i < keys.length; i++) {
22
- const k = keys[i];
23
- if (!(k in inst)) inst[k] = proto[k].bind(inst);
24
- }
25
- }
26
- const Parent = params?.Parent ?? Object;
27
- class Definition extends Parent {}
28
- Object.defineProperty(Definition, "name", { value: name });
29
- function _(def) {
30
- var _a;
31
- const inst = params?.Parent ? new Definition() : this;
32
- init(inst, def);
33
- (_a = inst._zod).deferred ?? (_a.deferred = []);
34
- for (const fn of inst._zod.deferred) fn();
35
- return inst;
36
- }
37
- Object.defineProperty(_, "init", { value: init });
38
- Object.defineProperty(_, Symbol.hasInstance, { value: (inst) => {
39
- if (params?.Parent && inst instanceof params.Parent) return true;
40
- return inst?._zod?.traits?.has(name);
41
- } });
42
- Object.defineProperty(_, "name", { value: name });
43
- return _;
44
- }
45
- var $ZodAsyncError = class extends Error {
46
- constructor() {
47
- super(`Encountered Promise during synchronous parse. Use .parseAsync() instead.`);
48
- }
49
- };
50
- var $ZodEncodeError = class extends Error {
51
- constructor(name) {
52
- super(`Encountered unidirectional transform during encode: ${name}`);
53
- this.name = "ZodEncodeError";
54
- }
55
- };
56
- (_a$1 = globalThis).__zod_globalConfig ?? (_a$1.__zod_globalConfig = {});
57
- const globalConfig = globalThis.__zod_globalConfig;
58
- function config(newConfig) {
59
- if (newConfig) Object.assign(globalConfig, newConfig);
60
- return globalConfig;
61
- }
62
- //#endregion
63
- //#region ../../node_modules/.pnpm/zod@4.4.3/node_modules/zod/v4/core/util.js
4
+ //#region ../../node_modules/.pnpm/zod@4.6.7/node_modules/zod/v4/core/util.js
64
5
  function getEnumValues(entries) {
65
6
  const numericValues = Object.values(entries).filter((v) => typeof v === "number");
66
7
  return Object.entries(entries).filter(([k, _]) => numericValues.indexOf(+k) === -1).map(([_, v]) => v);
67
8
  }
9
+ function joinValues(array, separator = "|") {
10
+ return array.map((val) => stringifyPrimitive(val)).join(separator);
11
+ }
68
12
  function jsonStringifyReplacer(_, value) {
69
13
  if (typeof value === "bigint") return value.toString();
70
14
  return value;
71
15
  }
72
- function cached(getter) {
73
- return { get value() {
74
- {
75
- const value = getter();
76
- Object.defineProperty(this, "value", { value });
77
- return value;
16
+ var Cached = class {
17
+ constructor(getter) {
18
+ this._getter = getter;
19
+ this._value = void 0;
20
+ }
21
+ get value() {
22
+ const getter = this._getter;
23
+ if (getter !== void 0) {
24
+ this._value = getter();
25
+ this._getter = void 0;
78
26
  }
79
- throw new Error("cached value already set");
80
- } };
27
+ return this._value;
28
+ }
29
+ };
30
+ function cached(getter) {
31
+ return new Cached(getter);
81
32
  }
82
33
  function nullish(input) {
83
34
  return input === null || input === void 0;
@@ -90,28 +41,10 @@ function cleanRegex(source) {
90
41
  function floatSafeRemainder(val, step) {
91
42
  const ratio = val / step;
92
43
  const roundedRatio = Math.round(ratio);
93
- const tolerance = Number.EPSILON * Math.max(Math.abs(ratio), 1);
44
+ const tolerance = 4 * Number.EPSILON * Math.max(Math.abs(ratio), 1);
94
45
  if (Math.abs(ratio - roundedRatio) < tolerance) return 0;
95
46
  return ratio - roundedRatio;
96
47
  }
97
- const EVALUATING = /* @__PURE__*/ Symbol("evaluating");
98
- function defineLazy(object, key, getter) {
99
- let value = void 0;
100
- Object.defineProperty(object, key, {
101
- get() {
102
- if (value === EVALUATING) return;
103
- if (value === void 0) {
104
- value = EVALUATING;
105
- value = getter();
106
- }
107
- return value;
108
- },
109
- set(v) {
110
- Object.defineProperty(object, key, { value: v });
111
- },
112
- configurable: true
113
- });
114
- }
115
48
  function assignProp(target, prop, value) {
116
49
  Object.defineProperty(target, prop, {
117
50
  value,
@@ -120,6 +53,58 @@ function assignProp(target, prop, value) {
120
53
  configurable: true
121
54
  });
122
55
  }
56
+ /**
57
+ * Whichever object a def's `shape` currently answers from: the one the caller passed until the first read, the frozen copy after it.
58
+ *
59
+ * 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.
60
+ */
61
+ function rawShape(def) {
62
+ const desc = Object.getOwnPropertyDescriptor(def, "shape");
63
+ return desc?.get ? desc.get.raw : desc?.value;
64
+ }
65
+ function sourceShape(schema) {
66
+ return rawShape(schema._zod.def) ?? schema._zod.def.shape;
67
+ }
68
+ function deferProp(target, key, getter) {
69
+ Object.defineProperty(target, key, {
70
+ get() {
71
+ const value = getter();
72
+ assignProp(this, key, value);
73
+ return value;
74
+ },
75
+ enumerable: true,
76
+ configurable: true
77
+ });
78
+ }
79
+ function putProp(target, key, value) {
80
+ if (key in target) assignProp(target, key, value);
81
+ else target[key] = value;
82
+ }
83
+ /**
84
+ * Copies `keys` of `source`'s shape onto `target`, each value passed through `wrap`.
85
+ *
86
+ * 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.
87
+ */
88
+ function mirrorShape(target, source, keys, wrap) {
89
+ const raw = sourceShape(source);
90
+ for (const key of keys) {
91
+ const desc = Object.getOwnPropertyDescriptor(raw, key);
92
+ if (!desc.enumerable) continue;
93
+ if (desc.get) deferProp(target, key, () => {
94
+ const value = source._zod.def.shape[key];
95
+ return wrap ? wrap(value, key) : value;
96
+ });
97
+ else putProp(target, key, wrap ? wrap(desc.value, key) : desc.value);
98
+ }
99
+ }
100
+ function mirrorProps(target, source) {
101
+ for (const key of Reflect.ownKeys(source)) {
102
+ const desc = Object.getOwnPropertyDescriptor(source, key);
103
+ if (!desc.enumerable) continue;
104
+ if (desc.get) deferProp(target, key, () => source[key]);
105
+ else putProp(target, key, desc.value);
106
+ }
107
+ }
123
108
  function mergeDefs(...defs) {
124
109
  const mergedDescriptors = {};
125
110
  for (const def of defs) Object.assign(mergedDescriptors, Object.getOwnPropertyDescriptors(def));
@@ -190,51 +175,56 @@ function normalizeParams(_params) {
190
175
  };
191
176
  return params;
192
177
  }
178
+ function stringifyPrimitive(value) {
179
+ if (typeof value === "bigint") return value.toString() + "n";
180
+ if (typeof value === "string") return `"${value}"`;
181
+ return `${value}`;
182
+ }
193
183
  function optionalKeys(shape) {
194
184
  return Object.keys(shape).filter((k) => {
195
- return shape[k]._zod.optin === "optional" && shape[k]._zod.optout === "optional";
185
+ return shape[k]._zod.optin !== void 0 && shape[k]._zod.optout === "optional";
196
186
  });
197
187
  }
198
- const NUMBER_FORMAT_RANGES = {
188
+ const NUMBER_FORMAT_RANGES = /*@__PURE__*/ (() => ({
199
189
  safeint: [Number.MIN_SAFE_INTEGER, Number.MAX_SAFE_INTEGER],
200
190
  int32: [-2147483648, 2147483647],
201
191
  uint32: [0, 4294967295],
202
192
  float32: [-34028234663852886e22, 34028234663852886e22],
203
193
  float64: [-Number.MAX_VALUE, Number.MAX_VALUE]
194
+ }))();
195
+ const BIGINT_FORMAT_RANGES = {
196
+ int64: [/* @__PURE__*/ BigInt("-9223372036854775808"), /* @__PURE__*/ BigInt("9223372036854775807")],
197
+ uint64: [/* @__PURE__*/ BigInt(0), /* @__PURE__*/ BigInt("18446744073709551615")]
204
198
  };
205
199
  function pick(schema, mask) {
206
200
  const currDef = schema._zod.def;
207
201
  const checks = currDef.checks;
208
202
  if (checks && checks.length > 0) throw new Error(".pick() cannot be used on object schemas containing refinements");
209
- return clone(schema, mergeDefs(schema._zod.def, {
210
- get shape() {
211
- const newShape = {};
212
- for (const key in mask) {
213
- if (!(key in currDef.shape)) throw new Error(`Unrecognized key: "${key}"`);
214
- if (!mask[key]) continue;
215
- newShape[key] = currDef.shape[key];
216
- }
217
- assignProp(this, "shape", newShape);
218
- return newShape;
219
- },
203
+ const newShape = {};
204
+ mirrorShape(newShape, schema, maskedKeys(schema, mask));
205
+ return clone(schema, mergeDefs(currDef, {
206
+ shape: newShape,
220
207
  checks: []
221
208
  }));
222
209
  }
210
+ function maskedKeys(schema, mask) {
211
+ const raw = sourceShape(schema);
212
+ const keys = [];
213
+ for (const key of Reflect.ownKeys(mask)) {
214
+ if (!Object.getOwnPropertyDescriptor(raw, key)?.enumerable) throw new Error(`Unrecognized key: "${String(key)}"`);
215
+ if (mask[key]) keys.push(key);
216
+ }
217
+ return keys;
218
+ }
223
219
  function omit(schema, mask) {
224
220
  const currDef = schema._zod.def;
225
221
  const checks = currDef.checks;
226
222
  if (checks && checks.length > 0) throw new Error(".omit() cannot be used on object schemas containing refinements");
227
- return clone(schema, mergeDefs(schema._zod.def, {
228
- get shape() {
229
- const newShape = { ...schema._zod.def.shape };
230
- for (const key in mask) {
231
- if (!(key in currDef.shape)) throw new Error(`Unrecognized key: "${key}"`);
232
- if (!mask[key]) continue;
233
- delete newShape[key];
234
- }
235
- assignProp(this, "shape", newShape);
236
- return newShape;
237
- },
223
+ const omitted = new Set(maskedKeys(schema, mask));
224
+ const newShape = {};
225
+ mirrorShape(newShape, schema, Reflect.ownKeys(sourceShape(schema)).filter((key) => !omitted.has(key)));
226
+ return clone(schema, mergeDefs(currDef, {
227
+ shape: newShape,
238
228
  checks: []
239
229
  }));
240
230
  }
@@ -242,90 +232,57 @@ function extend(schema, shape) {
242
232
  if (!isPlainObject(shape)) throw new Error("Invalid input to extend: expected a plain object");
243
233
  const checks = schema._zod.def.checks;
244
234
  if (checks && checks.length > 0) {
245
- const existingShape = schema._zod.def.shape;
246
- 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.");
235
+ const existingShape = sourceShape(schema);
236
+ 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.");
247
237
  }
248
- return clone(schema, mergeDefs(schema._zod.def, { get shape() {
249
- const _shape = {
250
- ...schema._zod.def.shape,
251
- ...shape
252
- };
253
- assignProp(this, "shape", _shape);
254
- return _shape;
255
- } }));
238
+ return clone(schema, mergeDefs(schema._zod.def, { shape: extended(schema, shape) }));
239
+ }
240
+ function extended(schema, shape) {
241
+ const newShape = {};
242
+ mirrorShape(newShape, schema, Reflect.ownKeys(sourceShape(schema)));
243
+ mirrorProps(newShape, shape);
244
+ return newShape;
256
245
  }
257
246
  function safeExtend(schema, shape) {
258
247
  if (!isPlainObject(shape)) throw new Error("Invalid input to safeExtend: expected a plain object");
259
- return clone(schema, mergeDefs(schema._zod.def, { get shape() {
260
- const _shape = {
261
- ...schema._zod.def.shape,
262
- ...shape
263
- };
264
- assignProp(this, "shape", _shape);
265
- return _shape;
266
- } }));
248
+ return clone(schema, mergeDefs(schema._zod.def, { shape: extended(schema, shape) }));
267
249
  }
268
250
  function merge(a, b) {
251
+ if (!b?._zod?.def) throw new Error("Invalid input to merge: expected an object schema. To merge a plain shape, use `.extend()`.");
269
252
  if (a._zod.def.checks?.length) throw new Error(".merge() cannot be used on object schemas containing refinements. Use .safeExtend() instead.");
253
+ const newShape = {};
254
+ mirrorShape(newShape, a, Reflect.ownKeys(sourceShape(a)));
255
+ mirrorShape(newShape, b, Reflect.ownKeys(sourceShape(b)));
270
256
  return clone(a, mergeDefs(a._zod.def, {
271
- get shape() {
272
- const _shape = {
273
- ...a._zod.def.shape,
274
- ...b._zod.def.shape
275
- };
276
- assignProp(this, "shape", _shape);
277
- return _shape;
278
- },
257
+ shape: newShape,
279
258
  get catchall() {
280
259
  return b._zod.def.catchall;
281
260
  },
282
261
  checks: b._zod.def.checks ?? []
283
262
  }));
284
263
  }
285
- function partial(Class, schema, mask) {
264
+ function partial(Class, schema, mask, name = "partial") {
286
265
  const checks = schema._zod.def.checks;
287
- if (checks && checks.length > 0) throw new Error(".partial() cannot be used on object schemas containing refinements");
266
+ if (checks && checks.length > 0) throw new Error(`.${name}() cannot be used on object schemas containing refinements`);
267
+ const selected = mask ? new Set(maskedKeys(schema, mask)) : void 0;
268
+ const newShape = {};
269
+ mirrorShape(newShape, schema, Reflect.ownKeys(sourceShape(schema)), Class && ((value, key) => selected && !selected.has(key) ? value : new Class({
270
+ type: "optional",
271
+ innerType: value
272
+ })));
288
273
  return clone(schema, mergeDefs(schema._zod.def, {
289
- get shape() {
290
- const oldShape = schema._zod.def.shape;
291
- const shape = { ...oldShape };
292
- if (mask) for (const key in mask) {
293
- if (!(key in oldShape)) throw new Error(`Unrecognized key: "${key}"`);
294
- if (!mask[key]) continue;
295
- shape[key] = Class ? new Class({
296
- type: "optional",
297
- innerType: oldShape[key]
298
- }) : oldShape[key];
299
- }
300
- else for (const key in oldShape) shape[key] = Class ? new Class({
301
- type: "optional",
302
- innerType: oldShape[key]
303
- }) : oldShape[key];
304
- assignProp(this, "shape", shape);
305
- return shape;
306
- },
274
+ shape: newShape,
307
275
  checks: []
308
276
  }));
309
277
  }
310
278
  function required(Class, schema, mask) {
311
- return clone(schema, mergeDefs(schema._zod.def, { get shape() {
312
- const oldShape = schema._zod.def.shape;
313
- const shape = { ...oldShape };
314
- if (mask) for (const key in mask) {
315
- if (!(key in shape)) throw new Error(`Unrecognized key: "${key}"`);
316
- if (!mask[key]) continue;
317
- shape[key] = new Class({
318
- type: "nonoptional",
319
- innerType: oldShape[key]
320
- });
321
- }
322
- else for (const key in oldShape) shape[key] = new Class({
323
- type: "nonoptional",
324
- innerType: oldShape[key]
325
- });
326
- assignProp(this, "shape", shape);
327
- return shape;
328
- } }));
279
+ const selected = mask ? new Set(maskedKeys(schema, mask)) : void 0;
280
+ const newShape = {};
281
+ mirrorShape(newShape, schema, Reflect.ownKeys(sourceShape(schema)), (value, key) => selected && !selected.has(key) ? value : new Class({
282
+ type: "nonoptional",
283
+ innerType: value
284
+ }));
285
+ return clone(schema, mergeDefs(schema._zod.def, { shape: newShape }));
329
286
  }
330
287
  function aborted(x, startIndex = 0) {
331
288
  if (x.aborted === true) return true;
@@ -348,19 +305,67 @@ function prefixIssues(path, issues) {
348
305
  function unwrapMessage(message) {
349
306
  return typeof message === "string" ? message : message?.message;
350
307
  }
308
+ /** The leading size checks of `defChecks` that set an upper bound, each paired with it. */
309
+ function sizeCaps(defChecks) {
310
+ const caps = [];
311
+ for (const ch of defChecks ?? []) {
312
+ const d = ch._zod.def;
313
+ if (!/_(length|size)$|_equals$/.test(d.check)) break;
314
+ const max = d.maximum ?? d.length ?? d.size;
315
+ if (max >= 0) caps.push([max, ch]);
316
+ }
317
+ return caps;
318
+ }
319
+ function attachSchema(issues, start, inst) {
320
+ var _a;
321
+ for (let i = start; i < issues.length; i++) (_a = issues[i]).schema ?? (_a.schema = inst);
322
+ }
351
323
  function finalizeIssue(iss, ctx, config) {
352
- 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";
353
- const { inst: _inst, continue: _continue, input: _input, ...rest } = iss;
354
- rest.path ?? (rest.path = []);
355
- rest.message = message;
356
- if (ctx?.reportInput) rest.input = _input;
357
- return rest;
324
+ var _a;
325
+ const traits = iss.inst?._zod?.traits;
326
+ if (traits?.has("$ZodType")) if (traits.has("$ZodCheck")) (_a = iss).schema ?? (_a.schema = iss.inst);
327
+ else iss.schema = iss.inst;
328
+ const schemaError = iss.schema !== iss.inst ? iss.schema?._zod.def?.error : void 0;
329
+ 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";
330
+ const full = {};
331
+ for (const k of Object.keys(iss)) {
332
+ if (k === "inst" || k === "schema" || k === "continue" || k === "input" || k === "__proto__") continue;
333
+ full[k] = iss[k];
334
+ }
335
+ full.path ?? (full.path = []);
336
+ full.message = message;
337
+ if (ctx?.reportInput) full.input = iss.input;
338
+ return full;
339
+ }
340
+ const highSurrogate = /[\uD800-\uDBFF]/;
341
+ function codePointLength(str) {
342
+ const units = str.length;
343
+ if (!highSurrogate.test(str)) return units;
344
+ let count = units;
345
+ for (let i = 0; i < units - 1; i++) if ((str.charCodeAt(i) & 64512) === 55296 && (str.charCodeAt(i + 1) & 64512) === 56320) {
346
+ count--;
347
+ i++;
348
+ }
349
+ return count;
358
350
  }
359
351
  function getLengthableOrigin(input) {
360
352
  if (Array.isArray(input)) return "array";
361
353
  if (typeof input === "string") return "string";
362
354
  return "unknown";
363
355
  }
356
+ function parsedType(data) {
357
+ const t = typeof data;
358
+ switch (t) {
359
+ case "number": return Number.isNaN(data) ? "nan" : "number";
360
+ case "object": {
361
+ if (data === null) return "null";
362
+ if (Array.isArray(data)) return "array";
363
+ const obj = data;
364
+ if (obj && Object.getPrototypeOf(obj) !== Object.prototype && "constructor" in obj && obj.constructor) return obj.constructor.name;
365
+ }
366
+ }
367
+ return t;
368
+ }
364
369
  function issue(...args) {
365
370
  const [iss, input, inst] = args;
366
371
  if (typeof iss === "string") return {
@@ -371,33 +376,337 @@ function issue(...args) {
371
376
  };
372
377
  return { ...iss };
373
378
  }
374
- //#endregion
375
- //#region ../../node_modules/.pnpm/zod@4.4.3/node_modules/zod/v4/core/errors.js
376
- const initializer$1 = (inst, def) => {
377
- inst.name = "$ZodError";
378
- Object.defineProperty(inst, "_zod", {
379
- value: inst._zod,
380
- enumerable: false
379
+ /**
380
+ * 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.
381
+ *
382
+ * Call this from a `proto` initializer, which runs once per prototype — never per instance.
383
+ */
384
+ function members(proto, table) {
385
+ for (const key in table) {
386
+ const desc = Object.getOwnPropertyDescriptor(table, key);
387
+ if (desc.get) Object.defineProperty(proto, key, {
388
+ ...desc,
389
+ enumerable: false
390
+ });
391
+ else defineBound(proto, key, desc.value);
392
+ }
393
+ }
394
+ /** Shadows a prototype member with an own value, so a getter that builds from the instance runs once. */
395
+ function own(inst, key, value, enumerable = true) {
396
+ Object.defineProperty(inst, key, {
397
+ configurable: true,
398
+ writable: true,
399
+ enumerable,
400
+ value
381
401
  });
382
- Object.defineProperty(inst, "issues", {
383
- value: def,
384
- enumerable: false
402
+ return value;
403
+ }
404
+ /** Like {@link own}, for a member that was never an own data property and has to stay out of `Object.keys`. */
405
+ function hide(inst, key, value) {
406
+ return own(inst, key, value, false);
407
+ }
408
+ /** 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. */
409
+ function derived(computes, table) {
410
+ for (const key in computes) {
411
+ const compute = computes[key];
412
+ Object.defineProperty(table, key, {
413
+ configurable: true,
414
+ enumerable: true,
415
+ get() {
416
+ return own(this, key, compute(this));
417
+ },
418
+ set(value) {
419
+ own(this, key, value);
420
+ }
421
+ });
422
+ }
423
+ return table;
424
+ }
425
+ function defineBound(proto, key, fn) {
426
+ Object.defineProperty(proto, key, {
427
+ configurable: true,
428
+ get() {
429
+ return this == null ? fn : own(this, key, fn.bind(this));
430
+ },
431
+ set(value) {
432
+ own(this, key, value);
433
+ }
385
434
  });
386
- inst.message = JSON.stringify(def, jsonStringifyReplacer, 2);
387
- Object.defineProperty(inst, "toString", {
388
- value: () => inst.message,
389
- enumerable: false
435
+ }
436
+ /** Returns the prototype to install on, or `undefined` if this group is already installed on it. */
437
+ function claim(inst, sentinel) {
438
+ const proto = Object.getPrototypeOf(inst);
439
+ return sentinel in proto ? void 0 : proto;
440
+ }
441
+ let installing;
442
+ let broke = false;
443
+ const breaker = {
444
+ configurable: true,
445
+ get() {
446
+ broke = true;
447
+ }
448
+ };
449
+ /**
450
+ * Installs a lazily-derived internal on the `_zod` prototype of `inst`'s
451
+ * constructor, computed from the internals object itself and cached there on
452
+ * first read. One accessor per constructor rather than one per instance.
453
+ */
454
+ function defineLazyInternal(inst, key, compute) {
455
+ const proto = Object.getPrototypeOf(inst._zod);
456
+ if (key in proto && installing !== inst._zod) {
457
+ installing = void 0;
458
+ return;
459
+ }
460
+ installing = inst._zod;
461
+ Object.defineProperty(proto, key, {
462
+ configurable: true,
463
+ get() {
464
+ Object.defineProperty(this, key, breaker);
465
+ const outer = broke;
466
+ broke = false;
467
+ try {
468
+ const value = compute(this);
469
+ if (broke) delete this[key];
470
+ else Object.defineProperty(this, key, {
471
+ configurable: true,
472
+ writable: true,
473
+ value
474
+ });
475
+ broke = broke || outer;
476
+ return value;
477
+ } catch (err) {
478
+ delete this[key];
479
+ broke = broke || outer;
480
+ throw err;
481
+ }
482
+ },
483
+ set(value) {
484
+ Object.defineProperty(this, key, {
485
+ configurable: true,
486
+ writable: true,
487
+ value
488
+ });
489
+ }
490
+ });
491
+ }
492
+ /**
493
+ * Installs `key` on `inst`'s prototype, computed by `make` on first read and cached there as an own
494
+ * data property. One accessor per constructor rather than one per instance, because an own accessor
495
+ * puts every instance after the first into v8 dictionary mode. The key doubles as the sentinel.
496
+ */
497
+ function installLazyProp(inst, key, make, enumerable) {
498
+ const proto = claim(inst, key);
499
+ if (!proto) return;
500
+ Object.defineProperty(proto, key, {
501
+ configurable: true,
502
+ get() {
503
+ const desc = {
504
+ configurable: true,
505
+ writable: true,
506
+ enumerable,
507
+ value: void 0
508
+ };
509
+ Object.defineProperty(this, key, desc);
510
+ desc.value = make(this);
511
+ Object.defineProperty(this, key, desc);
512
+ return desc.value;
513
+ },
514
+ set(value) {
515
+ Object.defineProperty(this, key, {
516
+ configurable: true,
517
+ writable: true,
518
+ enumerable,
519
+ value
520
+ });
521
+ }
390
522
  });
523
+ }
524
+ /** 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. */
525
+ const CONSTANT_CATCH = "~constantCatch";
526
+ /** Wraps a constant catch value in a thunk tagged with {@link CONSTANT_CATCH}. */
527
+ function constantCatch(value) {
528
+ const fn = () => value;
529
+ fn[CONSTANT_CATCH] = true;
530
+ return fn;
531
+ }
532
+ //#endregion
533
+ //#region ../../node_modules/.pnpm/zod@4.6.7/node_modules/zod/v4/core/core.js
534
+ var _a$1;
535
+ const _zodDesc = {
536
+ value: void 0,
537
+ enumerable: false
538
+ };
539
+ let _E = "captureStackTrace" in Error ? Error : null;
540
+ function newError(Definition) {
541
+ const E = _E;
542
+ if (E) {
543
+ const saved = E.stackTraceLimit;
544
+ if (typeof saved === "number") {
545
+ try {
546
+ E.stackTraceLimit = 0;
547
+ } catch {
548
+ _E = null;
549
+ return new Definition();
550
+ }
551
+ try {
552
+ return new Definition();
553
+ } finally {
554
+ E.stackTraceLimit = saved;
555
+ }
556
+ }
557
+ }
558
+ return new Definition();
559
+ }
560
+ function $constructor(name, initializer, proto, params) {
561
+ const zodProto = {};
562
+ function Internals(def) {
563
+ this.def = def;
564
+ this.constr = _;
565
+ this.traits = /* @__PURE__ */ new Set();
566
+ }
567
+ Internals.prototype = zodProto;
568
+ const protoMembers = proto;
569
+ const initialized = protoMembers && /* @__PURE__ */ new WeakSet();
570
+ function init(inst, def) {
571
+ if (!inst._zod) {
572
+ _zodDesc.value = new Internals(def);
573
+ try {
574
+ Object.defineProperty(inst, "_zod", _zodDesc);
575
+ } finally {
576
+ _zodDesc.value = void 0;
577
+ }
578
+ } else if (inst._zod.traits.has(name)) return;
579
+ inst._zod.traits.add(name);
580
+ initializer(inst, def);
581
+ if (initialized) {
582
+ const own = Object.getPrototypeOf(inst);
583
+ const ctorProto = inst._zod.constr.prototype;
584
+ let up = own;
585
+ while (up && up !== ctorProto) up = Object.getPrototypeOf(up);
586
+ const target = up ?? own;
587
+ if (!initialized.has(target)) {
588
+ initialized.add(target);
589
+ members(target, protoMembers);
590
+ }
591
+ }
592
+ const proto = _.prototype;
593
+ for (const k in proto) {
594
+ if (!Object.prototype.hasOwnProperty.call(proto, k)) continue;
595
+ if (!(k in inst)) inst[k] = proto[k].bind(inst);
596
+ }
597
+ }
598
+ const Parent = params?.Parent ?? Object;
599
+ class Definition extends Parent {}
600
+ Object.defineProperty(Definition, "name", { value: name });
601
+ function _(def) {
602
+ const inst = params?.Parent ? newError(Definition) : this;
603
+ init(inst, def);
604
+ const deferred = inst._zod.deferred;
605
+ if (deferred) {
606
+ for (const fn of deferred) fn();
607
+ inst._zod.deferred = void 0;
608
+ }
609
+ const pp = globalThis.__zod_globalConfig?.postProcessor;
610
+ if (pp) pp(inst);
611
+ return inst;
612
+ }
613
+ Object.defineProperty(_, "init", { value: init });
614
+ Object.defineProperty(_, Symbol.hasInstance, { value: (inst) => {
615
+ if (params?.Parent && inst instanceof params.Parent) return true;
616
+ return inst?._zod?.traits?.has(name);
617
+ } });
618
+ Object.defineProperty(_, "name", { value: name });
619
+ return _;
620
+ }
621
+ var $ZodAsyncError = class extends Error {
622
+ constructor() {
623
+ super(`Encountered Promise during synchronous parse. Use .parseAsync() instead.`);
624
+ }
625
+ };
626
+ var $ZodEncodeError = class extends Error {
627
+ constructor(name) {
628
+ super(`Encountered unidirectional transform during encode: ${name}`);
629
+ this.name = "ZodEncodeError";
630
+ }
631
+ };
632
+ (_a$1 = globalThis).__zod_globalConfig ?? (_a$1.__zod_globalConfig = {});
633
+ const globalConfig = globalThis.__zod_globalConfig;
634
+ function config(newConfig) {
635
+ if (newConfig) Object.assign(globalConfig, newConfig);
636
+ return globalConfig;
637
+ }
638
+ //#endregion
639
+ //#region ../../node_modules/.pnpm/zod@4.6.7/node_modules/zod/v4/core/errors.js
640
+ function _getMessage() {
641
+ const internals = this._zod;
642
+ internals.message ?? (internals.message = JSON.stringify(internals.def, jsonStringifyReplacer, 2));
643
+ return internals.message;
644
+ }
645
+ function _setMessage(value) {
646
+ this._zod.message = value;
647
+ }
648
+ const _messageDesc = {
649
+ get: _getMessage,
650
+ set: _setMessage,
651
+ enumerable: true,
652
+ configurable: true
653
+ };
654
+ const _issuesDesc = {
655
+ value: void 0,
656
+ enumerable: false
657
+ };
658
+ const _installedToString = /* @__PURE__ */ new WeakSet([Object.prototype, Error.prototype]);
659
+ const initializer$1 = (inst, def) => {
660
+ inst.name = "$ZodError";
661
+ _issuesDesc.value = def;
662
+ Object.defineProperty(inst, "issues", _issuesDesc);
663
+ _issuesDesc.value = void 0;
664
+ Object.defineProperty(inst, "message", _messageDesc);
665
+ const proto = Object.getPrototypeOf(inst);
666
+ if (!_installedToString.has(proto)) {
667
+ _installedToString.add(proto);
668
+ Object.defineProperty(proto, "toString", {
669
+ configurable: true,
670
+ enumerable: false,
671
+ get() {
672
+ const value = () => this.message;
673
+ Object.defineProperty(this, "toString", {
674
+ value,
675
+ configurable: true,
676
+ writable: true
677
+ });
678
+ return value;
679
+ },
680
+ set(value) {
681
+ Object.defineProperty(this, "toString", {
682
+ value,
683
+ configurable: true,
684
+ writable: true
685
+ });
686
+ }
687
+ });
688
+ }
391
689
  };
392
690
  const $ZodError = $constructor("$ZodError", initializer$1);
393
- const $ZodRealError = $constructor("$ZodError", initializer$1, { Parent: Error });
691
+ $constructor("$ZodError", initializer$1, void 0, { Parent: Error });
692
+ /** Get-or-create `obj[key]` as an own data property. A path segment naming an inherited member
693
+ * ("toString", "constructor") would otherwise read through to the prototype, and assigning
694
+ * "__proto__" would hit the setter instead of creating a key. */
695
+ function node(obj, key, make) {
696
+ if (!Object.prototype.hasOwnProperty.call(obj, key)) if (key === "__proto__") Object.defineProperty(obj, key, {
697
+ value: make(),
698
+ writable: true,
699
+ enumerable: true,
700
+ configurable: true
701
+ });
702
+ else obj[key] = make();
703
+ return obj[key];
704
+ }
394
705
  function flattenError(error, mapper = (issue) => issue.message) {
395
706
  const fieldErrors = {};
396
707
  const formErrors = [];
397
- for (const sub of error.issues) if (sub.path.length > 0) {
398
- fieldErrors[sub.path[0]] = fieldErrors[sub.path[0]] || [];
399
- fieldErrors[sub.path[0]].push(mapper(sub));
400
- } else formErrors.push(mapper(sub));
708
+ for (const sub of error.issues) if (sub.path.length > 0) node(fieldErrors, sub.path[0], () => []).push(mapper(sub));
709
+ else formErrors.push(mapper(sub));
401
710
  return {
402
711
  formErrors,
403
712
  fieldErrors
@@ -417,12 +726,21 @@ function formatError(error, mapper = (issue) => issue.message) {
417
726
  let i = 0;
418
727
  while (i < fullpath.length) {
419
728
  const el = fullpath[i];
420
- if (!(i === fullpath.length - 1)) curr[el] = curr[el] || { _errors: [] };
421
- else {
422
- curr[el] = curr[el] || { _errors: [] };
423
- curr[el]._errors.push(mapper(issue));
729
+ const terminal = i === fullpath.length - 1;
730
+ if (el === "_errors") {
731
+ if (terminal) curr._errors.push(mapper(issue));
732
+ i++;
733
+ continue;
424
734
  }
425
- curr = curr[el];
735
+ if (!Object.prototype.hasOwnProperty.call(curr, el)) Object.defineProperty(curr, el, {
736
+ value: { _errors: [] },
737
+ enumerable: true,
738
+ writable: true,
739
+ configurable: true
740
+ });
741
+ const node = curr[el];
742
+ if (terminal) node._errors.push(mapper(issue));
743
+ curr = node;
426
744
  i++;
427
745
  }
428
746
  }
@@ -432,40 +750,52 @@ function formatError(error, mapper = (issue) => issue.message) {
432
750
  return fieldErrors;
433
751
  }
434
752
  //#endregion
435
- //#region ../../node_modules/.pnpm/zod@4.4.3/node_modules/zod/v4/core/parse.js
436
- const _parse = (_Err) => (schema, value, _ctx, _params) => {
437
- const ctx = _ctx ? {
438
- ..._ctx,
439
- async: false
440
- } : { async: false };
441
- const result = schema._zod.run({
442
- value,
443
- issues: []
444
- }, ctx);
445
- if (result instanceof Promise) throw new $ZodAsyncError();
446
- if (result.issues.length) {
447
- const e = new (_params?.Err ?? _Err)(result.issues.map((iss) => finalizeIssue(iss, ctx, config())));
448
- captureStackTrace(e, _params?.callee);
449
- throw e;
450
- }
451
- return result.value;
753
+ //#region ../../node_modules/.pnpm/zod@4.6.7/node_modules/zod/v4/core/parse.js
754
+ function finalizeParams(callee, params) {
755
+ return {
756
+ callee: params?.callee ?? callee,
757
+ Err: params?.Err
758
+ };
759
+ }
760
+ const _parse = (_Err) => {
761
+ const fn = (schema, value, _ctx, _params) => {
762
+ const ctx = _ctx ? {
763
+ ..._ctx,
764
+ async: false
765
+ } : { async: false };
766
+ const result = schema._zod.run({
767
+ value,
768
+ issues: []
769
+ }, ctx);
770
+ if (result instanceof Promise) throw new $ZodAsyncError();
771
+ if (result.issues.length) {
772
+ const e = new (_params?.Err ?? _Err)(result.issues.map((iss) => finalizeIssue(iss, ctx, config())));
773
+ captureStackTrace(e, _params?.callee ?? fn);
774
+ throw e;
775
+ }
776
+ return result.value;
777
+ };
778
+ return fn;
452
779
  };
453
- const _parseAsync = (_Err) => async (schema, value, _ctx, params) => {
454
- const ctx = _ctx ? {
455
- ..._ctx,
456
- async: true
457
- } : { async: true };
458
- let result = schema._zod.run({
459
- value,
460
- issues: []
461
- }, ctx);
462
- if (result instanceof Promise) result = await result;
463
- if (result.issues.length) {
464
- const e = new (params?.Err ?? _Err)(result.issues.map((iss) => finalizeIssue(iss, ctx, config())));
465
- captureStackTrace(e, params?.callee);
466
- throw e;
467
- }
468
- return result.value;
780
+ const _parseAsync = (_Err) => {
781
+ const fn = async (schema, value, _ctx, params) => {
782
+ const ctx = _ctx ? {
783
+ ..._ctx,
784
+ async: true
785
+ } : { async: true };
786
+ let result = schema._zod.run({
787
+ value,
788
+ issues: []
789
+ }, ctx);
790
+ if (result instanceof Promise) result = await result;
791
+ if (result.issues.length) {
792
+ const e = new (params?.Err ?? _Err)(result.issues.map((iss) => finalizeIssue(iss, ctx, config())));
793
+ captureStackTrace(e, params?.callee ?? fn);
794
+ throw e;
795
+ }
796
+ return result.value;
797
+ };
798
+ return fn;
469
799
  };
470
800
  const _safeParse = (_Err) => (schema, value, _ctx) => {
471
801
  const ctx = _ctx ? {
@@ -476,16 +806,31 @@ const _safeParse = (_Err) => (schema, value, _ctx) => {
476
806
  value,
477
807
  issues: []
478
808
  }, ctx);
479
- if (result instanceof Promise) throw new $ZodAsyncError();
480
- return result.issues.length ? {
481
- success: false,
482
- error: new (_Err ?? $ZodError)(result.issues.map((iss) => finalizeIssue(iss, ctx, config())))
483
- } : {
809
+ if (result instanceof Promise) throw new $ZodAsyncError();
810
+ return result.issues.length ? failure(_Err, result.issues, ctx) : {
484
811
  success: true,
485
812
  data: result.value
486
813
  };
487
814
  };
488
- const safeParse$1 = /* @__PURE__*/ _safeParse($ZodRealError);
815
+ function failure(Err, issues, ctx) {
816
+ let error;
817
+ return {
818
+ success: false,
819
+ get error() {
820
+ if (!error) {
821
+ error = new Err(issues.map((iss) => finalizeIssue(iss, ctx, config())));
822
+ issues = void 0;
823
+ ctx = void 0;
824
+ }
825
+ return error;
826
+ },
827
+ set error(e) {
828
+ error = e;
829
+ issues = void 0;
830
+ ctx = void 0;
831
+ }
832
+ };
833
+ }
489
834
  const _safeParseAsync = (_Err) => async (schema, value, _ctx) => {
490
835
  const ctx = _ctx ? {
491
836
  ..._ctx,
@@ -496,34 +841,94 @@ const _safeParseAsync = (_Err) => async (schema, value, _ctx) => {
496
841
  issues: []
497
842
  }, ctx);
498
843
  if (result instanceof Promise) result = await result;
499
- return result.issues.length ? {
500
- success: false,
501
- error: new _Err(result.issues.map((iss) => finalizeIssue(iss, ctx, config())))
502
- } : {
844
+ return result.issues.length ? failure(_Err, result.issues, ctx) : {
503
845
  success: true,
504
846
  data: result.value
505
847
  };
506
848
  };
507
- const safeParseAsync$1 = /* @__PURE__*/ _safeParseAsync($ZodRealError);
508
- const _encode = (_Err) => (schema, value, _ctx) => {
849
+ const COMPILE_INVALID = /* @__PURE__ */ Symbol.for("zod.compile.invalid");
850
+ const COMPILE_FALLBACK = /* @__PURE__ */ Symbol.for("zod.compile.fallback");
851
+ const validate = ((schema, value, _ctx) => {
852
+ const validator = schema._zod.bag.validator;
853
+ if (validator !== void 0) {
854
+ if (validator(value) !== COMPILE_INVALID) return true;
855
+ if (validator.definite === true && _ctx === void 0) return false;
856
+ }
857
+ return validateFallback(schema, value, _ctx);
858
+ });
859
+ function validateFallback(schema, value, _ctx) {
509
860
  const ctx = _ctx ? {
510
861
  ..._ctx,
511
- direction: "backward"
512
- } : { direction: "backward" };
513
- return _parse(_Err)(schema, value, ctx);
514
- };
515
- const _decode = (_Err) => (schema, value, _ctx) => {
516
- return _parse(_Err)(schema, value, _ctx);
517
- };
518
- const _encodeAsync = (_Err) => async (schema, value, _ctx) => {
862
+ async: false,
863
+ abortEarly: true
864
+ } : {
865
+ async: false,
866
+ abortEarly: true
867
+ };
868
+ const fallbackRun = schema._zod.bag.fallbackRun;
869
+ let result;
870
+ if (fallbackRun) {
871
+ ctx[COMPILE_FALLBACK] = true;
872
+ result = fallbackRun({
873
+ value,
874
+ issues: []
875
+ }, ctx);
876
+ } else result = schema._zod.run({
877
+ value,
878
+ issues: []
879
+ }, ctx);
880
+ if (result instanceof Promise) throw new $ZodAsyncError();
881
+ return result.issues.length === 0;
882
+ }
883
+ const validateAsync$1 = async (schema, value, _ctx) => {
519
884
  const ctx = _ctx ? {
520
885
  ..._ctx,
521
- direction: "backward"
522
- } : { direction: "backward" };
523
- return _parseAsync(_Err)(schema, value, ctx);
886
+ async: true,
887
+ abortEarly: true
888
+ } : {
889
+ async: true,
890
+ abortEarly: true
891
+ };
892
+ let result = schema._zod.run({
893
+ value,
894
+ issues: []
895
+ }, ctx);
896
+ if (result instanceof Promise) result = await result;
897
+ return result.issues.length === 0;
898
+ };
899
+ const _encode = (_Err) => {
900
+ const parse = _parse(_Err);
901
+ const fn = (schema, value, _ctx, _params) => {
902
+ return parse(schema, value, _ctx ? {
903
+ ..._ctx,
904
+ direction: "backward"
905
+ } : { direction: "backward" }, finalizeParams(fn, _params));
906
+ };
907
+ return fn;
908
+ };
909
+ const _decode = (_Err) => {
910
+ const parse = _parse(_Err);
911
+ const fn = (schema, value, _ctx, _params) => {
912
+ return parse(schema, value, _ctx, finalizeParams(fn, _params));
913
+ };
914
+ return fn;
915
+ };
916
+ const _encodeAsync = (_Err) => {
917
+ const parseAsync = _parseAsync(_Err);
918
+ const fn = async (schema, value, _ctx, _params) => {
919
+ return await parseAsync(schema, value, _ctx ? {
920
+ ..._ctx,
921
+ direction: "backward"
922
+ } : { direction: "backward" }, finalizeParams(fn, _params));
923
+ };
924
+ return fn;
524
925
  };
525
- const _decodeAsync = (_Err) => async (schema, value, _ctx) => {
526
- return _parseAsync(_Err)(schema, value, _ctx);
926
+ const _decodeAsync = (_Err) => {
927
+ const parseAsync = _parseAsync(_Err);
928
+ const fn = async (schema, value, _ctx, _params) => {
929
+ return await parseAsync(schema, value, _ctx, finalizeParams(fn, _params));
930
+ };
931
+ return fn;
527
932
  };
528
933
  const _safeEncode = (_Err) => (schema, value, _ctx) => {
529
934
  const ctx = _ctx ? {
@@ -546,7 +951,7 @@ const _safeDecodeAsync = (_Err) => async (schema, value, _ctx) => {
546
951
  return _safeParseAsync(_Err)(schema, value, _ctx);
547
952
  };
548
953
  //#endregion
549
- //#region ../../node_modules/.pnpm/zod@4.4.3/node_modules/zod/v4/core/regexes.js
954
+ //#region ../../node_modules/.pnpm/zod@4.6.7/node_modules/zod/v4/core/regexes.js
550
955
  /**
551
956
  * @deprecated CUID v1 is deprecated by its authors due to information leakage
552
957
  * (timestamps embedded in the id). Use {@link cuid2} instead.
@@ -554,12 +959,15 @@ const _safeDecodeAsync = (_Err) => async (schema, value, _ctx) => {
554
959
  */
555
960
  const cuid = /^[cC][0-9a-z]{6,}$/;
556
961
  const cuid2 = /^[0-9a-z]+$/;
557
- const ulid = /^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/;
962
+ const ulid = /^[0-7][0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{25}$/;
558
963
  const xid = /^[0-9a-vA-V]{20}$/;
559
964
  const ksuid = /^[A-Za-z0-9]{27}$/;
560
965
  const nanoid = /^[a-zA-Z0-9_-]{21}$/;
966
+ function nanoidOfLength(length) {
967
+ return new RegExp(`^[a-zA-Z0-9_-]{${length}}$`);
968
+ }
561
969
  /** ISO 8601-1 duration regex. Does not support the 8601-2 extensions like negative durations or fractional/negative components. */
562
- const duration$1 = /^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/;
970
+ const duration = /^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/;
563
971
  /** A regex for any UUID-like identifier: 8-4-4-4-12 hex pattern */
564
972
  const guid = /^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/;
565
973
  /** Returns a regex for validating an RFC 9562/4122 UUID.
@@ -570,52 +978,61 @@ const uuid = (version) => {
570
978
  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})$`);
571
979
  };
572
980
  /** Practical email validation */
573
- const email = /^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/;
574
- const _emoji$1 = `^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$`;
981
+ const 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,}$/;
982
+ const _emoji$1 = `^(?=[\\s\\S]*[\\p{Extended_Pictographic}\\p{Regional_Indicator}\\u20E3])[\\p{Extended_Pictographic}\\p{Emoji_Component}]+$`;
575
983
  function emoji() {
576
984
  return new RegExp(_emoji$1, "u");
577
985
  }
578
986
  const ipv4 = /^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/;
579
987
  const ipv6 = /^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))$/;
580
988
  const cidrv4 = /^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/([0-9]|[1-2][0-9]|3[0-2])$/;
581
- const cidrv6 = /^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/;
989
+ const 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])$/;
582
990
  const base64 = /^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/;
583
- const base64url = /^[A-Za-z0-9_-]*$/;
991
+ const base64url = /^(?:[A-Za-z0-9_-]{4})*(?:[A-Za-z0-9_-]{2,3})?$/;
584
992
  const httpProtocol = /^https?$/;
585
993
  const e164 = /^\+[1-9]\d{6,14}$/;
586
994
  const dateSource = `(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))`;
587
- const date$1 = /*@__PURE__*/ new RegExp(`^${dateSource}$`);
995
+ /** Anchors a pattern source. The interpolation lives here rather than at the call site because
996
+ * esbuild will not drop a `@__PURE__` call whose own argument interpolates a variable, but it
997
+ * will drop `anchor(dateSource)`. Keeping it inline pinned `date` into every bundle. */
998
+ function anchor(source) {
999
+ return new RegExp(`^${source}$`);
1000
+ }
1001
+ const date = /*@__PURE__*/ anchor(dateSource);
588
1002
  function timeSource(args) {
589
1003
  const hhmm = `(?:[01]\\d|2[0-3]):[0-5]\\d`;
590
- 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+)?)?`;
1004
+ 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+)?)?`;
591
1005
  }
592
- function time$1(args) {
1006
+ function time(args) {
593
1007
  return new RegExp(`^${timeSource(args)}$`);
594
1008
  }
595
- function datetime$1(args) {
596
- const time = timeSource({ precision: args.precision });
1009
+ function datetime(args) {
597
1010
  const opts = ["Z"];
598
- if (args.local) opts.push("");
599
1011
  if (args.offset) opts.push(`([+-](?:[01]\\d|2[0-3]):[0-5]\\d)`);
600
- const timeRegex = `${time}(?:${opts.join("|")})`;
1012
+ const qualified = `${timeSource({
1013
+ precision: args.precision,
1014
+ seconds: true
1015
+ })}(?:${opts.join("|")})`;
1016
+ const timeRegex = args.local ? `${qualified}|${timeSource({ precision: args.precision })}` : qualified;
601
1017
  return new RegExp(`^${dateSource}T(?:${timeRegex})$`);
602
1018
  }
603
- const string$1 = (params) => {
604
- const regex = params ? `[\\s\\S]{${params?.minimum ?? 0},${params?.maximum ?? ""}}` : `[\\s\\S]*`;
605
- return new RegExp(`^${regex}$`);
606
- };
607
- const integer = /^-?\d+$/;
1019
+ const anyString = /^[\s\S]{0,}$/;
608
1020
  const number$1 = /^-?\d+(?:\.\d+)?$/;
609
1021
  const lowercase = /^[^A-Z]*$/;
610
1022
  const uppercase = /^[^a-z]*$/;
611
1023
  //#endregion
612
- //#region ../../node_modules/.pnpm/zod@4.4.3/node_modules/zod/v4/core/checks.js
1024
+ //#region ../../node_modules/.pnpm/zod@4.6.7/node_modules/zod/v4/core/checks.js
613
1025
  const $ZodCheck = /*@__PURE__*/ $constructor("$ZodCheck", (inst, def) => {
614
1026
  var _a;
615
1027
  inst._zod ?? (inst._zod = {});
616
1028
  inst._zod.def = def;
617
1029
  (_a = inst._zod).onattach ?? (_a.onattach = []);
618
1030
  });
1031
+ /** Default `when` for length-based checks: run only on non-nullish values with a `length`. */
1032
+ const _whenHasLength = (payload) => {
1033
+ const val = payload.value;
1034
+ return !nullish(val) && val.length !== void 0;
1035
+ };
619
1036
  const numericOriginMap = {
620
1037
  number: "number",
621
1038
  bigint: "bigint",
@@ -624,16 +1041,10 @@ const numericOriginMap = {
624
1041
  const $ZodCheckLessThan = /*@__PURE__*/ $constructor("$ZodCheckLessThan", (inst, def) => {
625
1042
  $ZodCheck.init(inst, def);
626
1043
  const origin = numericOriginMap[typeof def.value];
627
- inst._zod.onattach.push((inst) => {
628
- const bag = inst._zod.bag;
629
- const curr = (def.inclusive ? bag.maximum : bag.exclusiveMaximum) ?? Number.POSITIVE_INFINITY;
630
- if (def.value < curr) if (def.inclusive) bag.maximum = def.value;
631
- else bag.exclusiveMaximum = def.value;
632
- });
633
1044
  inst._zod.check = (payload) => {
634
1045
  if (def.inclusive ? payload.value <= def.value : payload.value < def.value) return;
635
1046
  payload.issues.push({
636
- origin,
1047
+ origin: numericOriginMap[typeof payload.value] ?? origin,
637
1048
  code: "too_big",
638
1049
  maximum: typeof def.value === "object" ? def.value.getTime() : def.value,
639
1050
  input: payload.value,
@@ -646,16 +1057,10 @@ const $ZodCheckLessThan = /*@__PURE__*/ $constructor("$ZodCheckLessThan", (inst,
646
1057
  const $ZodCheckGreaterThan = /*@__PURE__*/ $constructor("$ZodCheckGreaterThan", (inst, def) => {
647
1058
  $ZodCheck.init(inst, def);
648
1059
  const origin = numericOriginMap[typeof def.value];
649
- inst._zod.onattach.push((inst) => {
650
- const bag = inst._zod.bag;
651
- const curr = (def.inclusive ? bag.minimum : bag.exclusiveMinimum) ?? Number.NEGATIVE_INFINITY;
652
- if (def.value > curr) if (def.inclusive) bag.minimum = def.value;
653
- else bag.exclusiveMinimum = def.value;
654
- });
655
1060
  inst._zod.check = (payload) => {
656
1061
  if (def.inclusive ? payload.value >= def.value : payload.value > def.value) return;
657
1062
  payload.issues.push({
658
- origin,
1063
+ origin: numericOriginMap[typeof payload.value] ?? origin,
659
1064
  code: "too_small",
660
1065
  minimum: typeof def.value === "object" ? def.value.getTime() : def.value,
661
1066
  input: payload.value,
@@ -667,13 +1072,9 @@ const $ZodCheckGreaterThan = /*@__PURE__*/ $constructor("$ZodCheckGreaterThan",
667
1072
  });
668
1073
  const $ZodCheckMultipleOf = /*@__PURE__*/ $constructor("$ZodCheckMultipleOf", (inst, def) => {
669
1074
  $ZodCheck.init(inst, def);
670
- inst._zod.onattach.push((inst) => {
671
- var _a;
672
- (_a = inst._zod.bag).multipleOf ?? (_a.multipleOf = def.value);
673
- });
674
1075
  inst._zod.check = (payload) => {
675
1076
  if (typeof payload.value !== typeof def.value) throw new Error("Cannot mix number and bigint in multiple_of check.");
676
- if (typeof payload.value === "bigint" ? payload.value % def.value === BigInt(0) : floatSafeRemainder(payload.value, def.value) === 0) return;
1077
+ if (typeof payload.value === "bigint" ? def.value !== BigInt(0) && payload.value % def.value === BigInt(0) : floatSafeRemainder(payload.value, def.value) === 0) return;
677
1078
  payload.issues.push({
678
1079
  origin: typeof payload.value,
679
1080
  code: "not_multiple_of",
@@ -690,13 +1091,6 @@ const $ZodCheckNumberFormat = /*@__PURE__*/ $constructor("$ZodCheckNumberFormat"
690
1091
  const isInt = def.format?.includes("int");
691
1092
  const origin = isInt ? "int" : "number";
692
1093
  const [minimum, maximum] = NUMBER_FORMAT_RANGES[def.format];
693
- inst._zod.onattach.push((inst) => {
694
- const bag = inst._zod.bag;
695
- bag.format = def.format;
696
- bag.minimum = minimum;
697
- bag.maximum = maximum;
698
- if (isInt) bag.pattern = integer;
699
- });
700
1094
  inst._zod.check = (payload) => {
701
1095
  const input = payload.value;
702
1096
  if (isInt) {
@@ -758,17 +1152,11 @@ const $ZodCheckNumberFormat = /*@__PURE__*/ $constructor("$ZodCheckNumberFormat"
758
1152
  const $ZodCheckMaxLength = /*@__PURE__*/ $constructor("$ZodCheckMaxLength", (inst, def) => {
759
1153
  var _a;
760
1154
  $ZodCheck.init(inst, def);
761
- (_a = inst._zod.def).when ?? (_a.when = (payload) => {
762
- const val = payload.value;
763
- return !nullish(val) && val.length !== void 0;
764
- });
765
- inst._zod.onattach.push((inst) => {
766
- const curr = inst._zod.bag.maximum ?? Number.POSITIVE_INFINITY;
767
- if (def.maximum < curr) inst._zod.bag.maximum = def.maximum;
768
- });
1155
+ (_a = inst._zod.def).when ?? (_a.when = _whenHasLength);
769
1156
  inst._zod.check = (payload) => {
770
1157
  const input = payload.value;
771
- if (input.length <= def.maximum) return;
1158
+ const units = input.length;
1159
+ if ((typeof input === "string" && units > def.maximum ? codePointLength(input) : units) <= def.maximum) return;
772
1160
  const origin = getLengthableOrigin(input);
773
1161
  payload.issues.push({
774
1162
  origin,
@@ -784,17 +1172,11 @@ const $ZodCheckMaxLength = /*@__PURE__*/ $constructor("$ZodCheckMaxLength", (ins
784
1172
  const $ZodCheckMinLength = /*@__PURE__*/ $constructor("$ZodCheckMinLength", (inst, def) => {
785
1173
  var _a;
786
1174
  $ZodCheck.init(inst, def);
787
- (_a = inst._zod.def).when ?? (_a.when = (payload) => {
788
- const val = payload.value;
789
- return !nullish(val) && val.length !== void 0;
790
- });
791
- inst._zod.onattach.push((inst) => {
792
- const curr = inst._zod.bag.minimum ?? Number.NEGATIVE_INFINITY;
793
- if (def.minimum > curr) inst._zod.bag.minimum = def.minimum;
794
- });
1175
+ (_a = inst._zod.def).when ?? (_a.when = _whenHasLength);
795
1176
  inst._zod.check = (payload) => {
796
1177
  const input = payload.value;
797
- if (input.length >= def.minimum) return;
1178
+ const units = input.length;
1179
+ if ((typeof input === "string" && units >= def.minimum && units < def.minimum * 2 ? codePointLength(input) : units) >= def.minimum) return;
798
1180
  const origin = getLengthableOrigin(input);
799
1181
  payload.issues.push({
800
1182
  origin,
@@ -810,19 +1192,11 @@ const $ZodCheckMinLength = /*@__PURE__*/ $constructor("$ZodCheckMinLength", (ins
810
1192
  const $ZodCheckLengthEquals = /*@__PURE__*/ $constructor("$ZodCheckLengthEquals", (inst, def) => {
811
1193
  var _a;
812
1194
  $ZodCheck.init(inst, def);
813
- (_a = inst._zod.def).when ?? (_a.when = (payload) => {
814
- const val = payload.value;
815
- return !nullish(val) && val.length !== void 0;
816
- });
817
- inst._zod.onattach.push((inst) => {
818
- const bag = inst._zod.bag;
819
- bag.minimum = def.length;
820
- bag.maximum = def.length;
821
- bag.length = def.length;
822
- });
1195
+ (_a = inst._zod.def).when ?? (_a.when = _whenHasLength);
823
1196
  inst._zod.check = (payload) => {
824
1197
  const input = payload.value;
825
- const length = input.length;
1198
+ const units = input.length;
1199
+ const length = typeof input === "string" && units >= def.length && units <= def.length * 2 ? codePointLength(input) : units;
826
1200
  if (length === def.length) return;
827
1201
  const origin = getLengthableOrigin(input);
828
1202
  const tooBig = length > def.length;
@@ -846,14 +1220,6 @@ const $ZodCheckLengthEquals = /*@__PURE__*/ $constructor("$ZodCheckLengthEquals"
846
1220
  const $ZodCheckStringFormat = /*@__PURE__*/ $constructor("$ZodCheckStringFormat", (inst, def) => {
847
1221
  var _a, _b;
848
1222
  $ZodCheck.init(inst, def);
849
- inst._zod.onattach.push((inst) => {
850
- const bag = inst._zod.bag;
851
- bag.format = def.format;
852
- if (def.pattern) {
853
- bag.patterns ?? (bag.patterns = /* @__PURE__ */ new Set());
854
- bag.patterns.add(def.pattern);
855
- }
856
- });
857
1223
  if (def.pattern) (_a = inst._zod).check ?? (_a.check = (payload) => {
858
1224
  def.pattern.lastIndex = 0;
859
1225
  if (def.pattern.test(payload.value)) return;
@@ -896,13 +1262,7 @@ const $ZodCheckUpperCase = /*@__PURE__*/ $constructor("$ZodCheckUpperCase", (ins
896
1262
  const $ZodCheckIncludes = /*@__PURE__*/ $constructor("$ZodCheckIncludes", (inst, def) => {
897
1263
  $ZodCheck.init(inst, def);
898
1264
  const escapedRegex = escapeRegex(def.includes);
899
- const pattern = new RegExp(typeof def.position === "number" ? `^.{${def.position}}${escapedRegex}` : escapedRegex);
900
- def.pattern = pattern;
901
- inst._zod.onattach.push((inst) => {
902
- const bag = inst._zod.bag;
903
- bag.patterns ?? (bag.patterns = /* @__PURE__ */ new Set());
904
- bag.patterns.add(pattern);
905
- });
1265
+ def.pattern = new RegExp(typeof def.position === "number" ? `^.{${def.position},}${escapedRegex}` : escapedRegex);
906
1266
  inst._zod.check = (payload) => {
907
1267
  if (payload.value.includes(def.includes, def.position)) return;
908
1268
  payload.issues.push({
@@ -920,11 +1280,6 @@ const $ZodCheckStartsWith = /*@__PURE__*/ $constructor("$ZodCheckStartsWith", (i
920
1280
  $ZodCheck.init(inst, def);
921
1281
  const pattern = new RegExp(`^${escapeRegex(def.prefix)}.*`);
922
1282
  def.pattern ?? (def.pattern = pattern);
923
- inst._zod.onattach.push((inst) => {
924
- const bag = inst._zod.bag;
925
- bag.patterns ?? (bag.patterns = /* @__PURE__ */ new Set());
926
- bag.patterns.add(pattern);
927
- });
928
1283
  inst._zod.check = (payload) => {
929
1284
  if (payload.value.startsWith(def.prefix)) return;
930
1285
  payload.issues.push({
@@ -942,11 +1297,6 @@ const $ZodCheckEndsWith = /*@__PURE__*/ $constructor("$ZodCheckEndsWith", (inst,
942
1297
  $ZodCheck.init(inst, def);
943
1298
  const pattern = new RegExp(`.*${escapeRegex(def.suffix)}$`);
944
1299
  def.pattern ?? (def.pattern = pattern);
945
- inst._zod.onattach.push((inst) => {
946
- const bag = inst._zod.bag;
947
- bag.patterns ?? (bag.patterns = /* @__PURE__ */ new Set());
948
- bag.patterns.add(pattern);
949
- });
950
1300
  inst._zod.check = (payload) => {
951
1301
  if (payload.value.endsWith(def.suffix)) return;
952
1302
  payload.issues.push({
@@ -967,17 +1317,21 @@ const $ZodCheckOverwrite = /*@__PURE__*/ $constructor("$ZodCheckOverwrite", (ins
967
1317
  };
968
1318
  });
969
1319
  //#endregion
970
- //#region ../../node_modules/.pnpm/zod@4.4.3/node_modules/zod/v4/core/doc.js
1320
+ //#region ../../node_modules/.pnpm/zod@4.6.7/node_modules/zod/v4/core/doc.js
971
1321
  var Doc = class {
972
- constructor(args = []) {
1322
+ constructor(args = [], closed = {}) {
973
1323
  this.content = [];
974
1324
  this.indent = 0;
975
- if (this) this.args = args;
1325
+ this.args = args;
1326
+ this.closed = closed;
976
1327
  }
977
1328
  indented(fn) {
978
1329
  this.indent += 1;
979
- fn(this);
980
- this.indent -= 1;
1330
+ try {
1331
+ fn(this);
1332
+ } finally {
1333
+ this.indent -= 1;
1334
+ }
981
1335
  }
982
1336
  write(arg) {
983
1337
  if (typeof arg === "function") {
@@ -992,28 +1346,27 @@ var Doc = class {
992
1346
  }
993
1347
  compile() {
994
1348
  const F = Function;
995
- const args = this?.args;
996
- const lines = [...(this?.content ?? [``]).map((x) => ` ${x}`)];
997
- return new F(...args, lines.join("\n"));
1349
+ const content = this?.content ?? [``];
1350
+ return new F(...Object.keys(this.closed), `return function (${this.args.join(", ")}) {\n${content.join("\n")}\n};`)(...Object.values(this.closed));
998
1351
  }
999
1352
  };
1000
1353
  //#endregion
1001
- //#region ../../node_modules/.pnpm/zod@4.4.3/node_modules/zod/v4/core/versions.js
1354
+ //#region ../../node_modules/.pnpm/zod@4.6.7/node_modules/zod/v4/core/versions.js
1002
1355
  const version = {
1003
1356
  major: 4,
1004
- minor: 4,
1005
- patch: 3
1357
+ minor: 6,
1358
+ patch: 7
1006
1359
  };
1007
1360
  //#endregion
1008
- //#region ../../node_modules/.pnpm/zod@4.4.3/node_modules/zod/v4/core/schemas.js
1361
+ //#region ../../node_modules/.pnpm/zod@4.6.7/node_modules/zod/v4/core/schemas.js
1009
1362
  const $ZodType = /*@__PURE__*/ $constructor("$ZodType", (inst, def) => {
1010
1363
  var _a;
1011
1364
  inst ?? (inst = {});
1012
1365
  inst._zod.def = def;
1013
1366
  inst._zod.bag = inst._zod.bag || {};
1014
1367
  inst._zod.version = version;
1015
- const checks = [...inst._zod.def.checks ?? []];
1016
- if (inst._zod.traits.has("$ZodCheck")) checks.unshift(inst);
1368
+ const defChecks = inst._zod.def.checks;
1369
+ const checks = inst._zod.traits.has("$ZodCheck") ? [inst, ...defChecks ?? []] : defChecks?.length ? [...defChecks] : [];
1017
1370
  for (const ch of checks) for (const fn of ch._zod.onattach) fn(inst);
1018
1371
  if (checks.length === 0) {
1019
1372
  (_a = inst._zod).deferred ?? (_a.deferred = []);
@@ -1022,6 +1375,7 @@ const $ZodType = /*@__PURE__*/ $constructor("$ZodType", (inst, def) => {
1022
1375
  });
1023
1376
  } else {
1024
1377
  const runChecks = (payload, checks, ctx) => {
1378
+ if (payload.memo) return payload;
1025
1379
  let isAborted = aborted(payload);
1026
1380
  let asyncResult;
1027
1381
  for (const ch of checks) {
@@ -1035,10 +1389,12 @@ const $ZodType = /*@__PURE__*/ $constructor("$ZodType", (inst, def) => {
1035
1389
  if (asyncResult || _ instanceof Promise) asyncResult = (asyncResult ?? Promise.resolve()).then(async () => {
1036
1390
  await _;
1037
1391
  if (payload.issues.length === currLen) return;
1392
+ attachSchema(payload.issues, currLen, inst);
1038
1393
  if (!isAborted) isAborted = aborted(payload, currLen);
1039
1394
  });
1040
1395
  else {
1041
1396
  if (payload.issues.length === currLen) continue;
1397
+ attachSchema(payload.issues, currLen, inst);
1042
1398
  if (!isAborted) isAborted = aborted(payload, currLen);
1043
1399
  }
1044
1400
  }
@@ -1082,22 +1438,43 @@ const $ZodType = /*@__PURE__*/ $constructor("$ZodType", (inst, def) => {
1082
1438
  return runChecks(result, checks, ctx);
1083
1439
  };
1084
1440
  }
1085
- defineLazy(inst, "~standard", () => ({
1441
+ }, {
1442
+ get "~standard"() {
1443
+ return hide(this, "~standard", standardProps(this));
1444
+ },
1445
+ set "~standard"(value) {
1446
+ own(this, "~standard", value);
1447
+ }
1448
+ });
1449
+ /** The Standard Schema surface for `inst`. Shared so wrappers can extend it without forcing it. */
1450
+ const toStandardResult = (r, ctx) => r.issues.length ? { issues: r.issues.map((iss) => finalizeIssue(iss, ctx, config())) } : { value: r.value };
1451
+ async function validateAsync(inst, value) {
1452
+ const ctx = { async: true };
1453
+ return toStandardResult(await inst._zod.run({
1454
+ value,
1455
+ issues: []
1456
+ }, ctx), ctx);
1457
+ }
1458
+ function standardProps(inst) {
1459
+ return {
1086
1460
  validate: (value) => {
1461
+ const ctx = { async: false };
1087
1462
  try {
1088
- const r = safeParse$1(inst, value);
1089
- return r.success ? { value: r.data } : { issues: r.error?.issues };
1090
- } catch (_) {
1091
- return safeParseAsync$1(inst, value).then((r) => r.success ? { value: r.data } : { issues: r.error?.issues });
1092
- }
1463
+ const r = inst._zod.run({
1464
+ value,
1465
+ issues: []
1466
+ }, ctx);
1467
+ if (!(r instanceof Promise)) return toStandardResult(r, ctx);
1468
+ } catch (_) {}
1469
+ return validateAsync(inst, value);
1093
1470
  },
1094
1471
  vendor: "zod",
1095
1472
  version: 1
1096
- }));
1097
- });
1473
+ };
1474
+ }
1098
1475
  const $ZodString = /*@__PURE__*/ $constructor("$ZodString", (inst, def) => {
1099
1476
  $ZodType.init(inst, def);
1100
- inst._zod.pattern = [...inst?._zod.bag?.patterns ?? []].pop() ?? string$1(inst._zod.bag);
1477
+ inst._zod.pattern = def.pattern ?? anyString;
1101
1478
  inst._zod.parse = (payload, _) => {
1102
1479
  if (def.coerce) try {
1103
1480
  payload.value = String(payload.value);
@@ -1141,51 +1518,95 @@ const $ZodEmail = /*@__PURE__*/ $constructor("$ZodEmail", (inst, def) => {
1141
1518
  def.pattern ?? (def.pattern = email);
1142
1519
  $ZodStringFormat.init(inst, def);
1143
1520
  });
1521
+ function canParseURL(input) {
1522
+ try {
1523
+ if (typeof URL !== "undefined" && typeof URL.canParse === "function") return URL.canParse(input);
1524
+ new URL(input);
1525
+ return true;
1526
+ } catch {
1527
+ return false;
1528
+ }
1529
+ }
1530
+ function validateURL(trimmed, def) {
1531
+ if (!("normalize" in def) && !("hostname" in def) && !("protocol" in def)) return canParseURL(trimmed) || 2;
1532
+ return parseURLObject(trimmed, def);
1533
+ }
1534
+ /** Parses a URL while preserving the non-normalizing HTTP guard. */
1535
+ function parseURLObject(trimmed, def) {
1536
+ if (!def.normalize && def.protocol?.source === httpProtocol.source && !/^https?:\/\//i.test(trimmed)) return 1;
1537
+ try {
1538
+ if (typeof URL !== "undefined") {
1539
+ const URLStatic = URL;
1540
+ if (typeof URLStatic.parse === "function") return URLStatic.parse(trimmed) ?? 2;
1541
+ }
1542
+ return new URL(trimmed);
1543
+ } catch {
1544
+ return 2;
1545
+ }
1546
+ }
1547
+ const asciiTabOrNewline = /[\t\n\r]/g;
1548
+ /** 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. */
1549
+ function stripTabAndNewline(value) {
1550
+ return value.replace(asciiTabOrNewline, "");
1551
+ }
1552
+ function urlHostnameOk(url, hostname) {
1553
+ hostname.lastIndex = 0;
1554
+ return hostname.test(url.hostname);
1555
+ }
1556
+ function urlProtocolOk(url, protocol) {
1557
+ protocol.lastIndex = 0;
1558
+ return protocol.test(url.protocol.endsWith(":") ? url.protocol.slice(0, -1) : url.protocol);
1559
+ }
1144
1560
  const $ZodURL = /*@__PURE__*/ $constructor("$ZodURL", (inst, def) => {
1145
1561
  $ZodStringFormat.init(inst, def);
1146
1562
  inst._zod.check = (payload) => {
1147
1563
  try {
1148
1564
  const trimmed = payload.value.trim();
1149
- if (!def.normalize && def.protocol?.source === httpProtocol.source) {
1150
- if (!/^https?:\/\//i.test(trimmed)) {
1151
- payload.issues.push({
1152
- code: "invalid_format",
1153
- format: "url",
1154
- note: "Invalid URL format",
1155
- input: payload.value,
1156
- inst,
1157
- continue: !def.abort
1158
- });
1159
- return;
1160
- }
1161
- }
1162
- const url = new URL(trimmed);
1163
- if (def.hostname) {
1164
- def.hostname.lastIndex = 0;
1165
- if (!def.hostname.test(url.hostname)) payload.issues.push({
1565
+ const url = validateURL(trimmed, def);
1566
+ if (url === 1) {
1567
+ payload.issues.push({
1166
1568
  code: "invalid_format",
1167
1569
  format: "url",
1168
- note: "Invalid hostname",
1169
- pattern: def.hostname.source,
1570
+ note: "Invalid URL format",
1170
1571
  input: payload.value,
1171
1572
  inst,
1172
1573
  continue: !def.abort
1173
1574
  });
1575
+ return;
1174
1576
  }
1175
- if (def.protocol) {
1176
- def.protocol.lastIndex = 0;
1177
- if (!def.protocol.test(url.protocol.endsWith(":") ? url.protocol.slice(0, -1) : url.protocol)) payload.issues.push({
1577
+ if (url === 2) {
1578
+ payload.issues.push({
1178
1579
  code: "invalid_format",
1179
1580
  format: "url",
1180
- note: "Invalid protocol",
1181
- pattern: def.protocol.source,
1182
1581
  input: payload.value,
1183
1582
  inst,
1184
1583
  continue: !def.abort
1185
1584
  });
1585
+ return;
1586
+ }
1587
+ if (url === true) {
1588
+ payload.value = stripTabAndNewline(trimmed);
1589
+ return;
1186
1590
  }
1187
- if (def.normalize) payload.value = url.href;
1188
- else payload.value = trimmed;
1591
+ if (def.hostname && !urlHostnameOk(url, def.hostname)) payload.issues.push({
1592
+ code: "invalid_format",
1593
+ format: "url",
1594
+ note: "Invalid hostname",
1595
+ pattern: def.hostname.source,
1596
+ input: payload.value,
1597
+ inst,
1598
+ continue: !def.abort
1599
+ });
1600
+ if (def.protocol && !urlProtocolOk(url, def.protocol)) payload.issues.push({
1601
+ code: "invalid_format",
1602
+ format: "url",
1603
+ note: "Invalid protocol",
1604
+ pattern: def.protocol.source,
1605
+ input: payload.value,
1606
+ inst,
1607
+ continue: !def.abort
1608
+ });
1609
+ payload.value = def.normalize ? url.href : stripTabAndNewline(trimmed);
1189
1610
  return;
1190
1611
  } catch (_) {
1191
1612
  payload.issues.push({
@@ -1203,7 +1624,8 @@ const $ZodEmoji = /*@__PURE__*/ $constructor("$ZodEmoji", (inst, def) => {
1203
1624
  $ZodStringFormat.init(inst, def);
1204
1625
  });
1205
1626
  const $ZodNanoID = /*@__PURE__*/ $constructor("$ZodNanoID", (inst, def) => {
1206
- def.pattern ?? (def.pattern = nanoid);
1627
+ if (def.length !== void 0 && (!Number.isInteger(def.length) || def.length < 1)) throw new Error(`Invalid nanoid length: ${def.length}`);
1628
+ def.pattern ?? (def.pattern = def.length === void 0 ? nanoid : nanoidOfLength(def.length));
1207
1629
  $ZodStringFormat.init(inst, def);
1208
1630
  });
1209
1631
  /**
@@ -1232,70 +1654,69 @@ const $ZodKSUID = /*@__PURE__*/ $constructor("$ZodKSUID", (inst, def) => {
1232
1654
  $ZodStringFormat.init(inst, def);
1233
1655
  });
1234
1656
  const $ZodISODateTime = /*@__PURE__*/ $constructor("$ZodISODateTime", (inst, def) => {
1235
- def.pattern ?? (def.pattern = datetime$1(def));
1657
+ def.pattern ?? (def.pattern = datetime(def));
1236
1658
  $ZodStringFormat.init(inst, def);
1237
1659
  });
1238
1660
  const $ZodISODate = /*@__PURE__*/ $constructor("$ZodISODate", (inst, def) => {
1239
- def.pattern ?? (def.pattern = date$1);
1661
+ def.pattern ?? (def.pattern = date);
1240
1662
  $ZodStringFormat.init(inst, def);
1241
1663
  });
1242
1664
  const $ZodISOTime = /*@__PURE__*/ $constructor("$ZodISOTime", (inst, def) => {
1243
- def.pattern ?? (def.pattern = time$1(def));
1665
+ def.pattern ?? (def.pattern = time(def));
1244
1666
  $ZodStringFormat.init(inst, def);
1245
1667
  });
1246
1668
  const $ZodISODuration = /*@__PURE__*/ $constructor("$ZodISODuration", (inst, def) => {
1247
- def.pattern ?? (def.pattern = duration$1);
1669
+ def.pattern ?? (def.pattern = duration);
1248
1670
  $ZodStringFormat.init(inst, def);
1249
1671
  });
1250
1672
  const $ZodIPv4 = /*@__PURE__*/ $constructor("$ZodIPv4", (inst, def) => {
1251
1673
  def.pattern ?? (def.pattern = ipv4);
1252
1674
  $ZodStringFormat.init(inst, def);
1253
- inst._zod.bag.format = `ipv4`;
1254
1675
  });
1676
+ /** 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`. */
1677
+ const ipv6Alphabet = /^[0-9a-fA-F:.]+$/;
1678
+ function isValidIPv6(value) {
1679
+ if (!ipv6Alphabet.test(value)) return false;
1680
+ return canParseURL(`http://[${value}]`);
1681
+ }
1255
1682
  const $ZodIPv6 = /*@__PURE__*/ $constructor("$ZodIPv6", (inst, def) => {
1256
1683
  def.pattern ?? (def.pattern = ipv6);
1257
1684
  $ZodStringFormat.init(inst, def);
1258
- inst._zod.bag.format = `ipv6`;
1259
1685
  inst._zod.check = (payload) => {
1260
- try {
1261
- new URL(`http://[${payload.value}]`);
1262
- } catch {
1263
- payload.issues.push({
1264
- code: "invalid_format",
1265
- format: "ipv6",
1266
- input: payload.value,
1267
- inst,
1268
- continue: !def.abort
1269
- });
1270
- }
1686
+ if (!isValidIPv6(payload.value)) payload.issues.push({
1687
+ code: "invalid_format",
1688
+ format: "ipv6",
1689
+ input: payload.value,
1690
+ inst,
1691
+ continue: !def.abort
1692
+ });
1271
1693
  };
1272
1694
  });
1273
1695
  const $ZodCIDRv4 = /*@__PURE__*/ $constructor("$ZodCIDRv4", (inst, def) => {
1274
1696
  def.pattern ?? (def.pattern = cidrv4);
1275
1697
  $ZodStringFormat.init(inst, def);
1276
1698
  });
1699
+ function isValidCIDRv6(value) {
1700
+ const parts = value.split("/");
1701
+ if (parts.length !== 2) return false;
1702
+ const [address, prefix] = parts;
1703
+ if (!prefix) return false;
1704
+ const prefixNum = Number(prefix);
1705
+ if (`${prefixNum}` !== prefix) return false;
1706
+ if (prefixNum < 0 || prefixNum > 128) return false;
1707
+ return isValidIPv6(address);
1708
+ }
1277
1709
  const $ZodCIDRv6 = /*@__PURE__*/ $constructor("$ZodCIDRv6", (inst, def) => {
1278
1710
  def.pattern ?? (def.pattern = cidrv6);
1279
1711
  $ZodStringFormat.init(inst, def);
1280
1712
  inst._zod.check = (payload) => {
1281
- const parts = payload.value.split("/");
1282
- try {
1283
- if (parts.length !== 2) throw new Error();
1284
- const [address, prefix] = parts;
1285
- if (!prefix) throw new Error();
1286
- const prefixNum = Number(prefix);
1287
- if (`${prefixNum}` !== prefix) throw new Error();
1288
- if (prefixNum < 0 || prefixNum > 128) throw new Error();
1289
- new URL(`http://[${address}]`);
1290
- } catch {
1291
- payload.issues.push({
1292
- code: "invalid_format",
1293
- format: "cidrv6",
1294
- input: payload.value,
1295
- inst,
1296
- continue: !def.abort
1297
- });
1298
- }
1713
+ if (!isValidCIDRv6(payload.value)) payload.issues.push({
1714
+ code: "invalid_format",
1715
+ format: "cidrv6",
1716
+ input: payload.value,
1717
+ inst,
1718
+ continue: !def.abort
1719
+ });
1299
1720
  };
1300
1721
  });
1301
1722
  function isValidBase64(data) {
@@ -1309,10 +1730,10 @@ function isValidBase64(data) {
1309
1730
  return false;
1310
1731
  }
1311
1732
  }
1733
+ const base64Charset = /^[0-9a-zA-Z+/]*={0,2}$/;
1312
1734
  const $ZodBase64 = /*@__PURE__*/ $constructor("$ZodBase64", (inst, def) => {
1313
- def.pattern ?? (def.pattern = base64);
1735
+ def.pattern ?? (def.pattern = base64Charset);
1314
1736
  $ZodStringFormat.init(inst, def);
1315
- inst._zod.bag.contentEncoding = "base64";
1316
1737
  inst._zod.check = (payload) => {
1317
1738
  if (isValidBase64(payload.value)) return;
1318
1739
  payload.issues.push({
@@ -1324,15 +1745,15 @@ const $ZodBase64 = /*@__PURE__*/ $constructor("$ZodBase64", (inst, def) => {
1324
1745
  });
1325
1746
  };
1326
1747
  });
1748
+ const base64urlCharset = /^[A-Za-z0-9_-]*$/;
1327
1749
  function isValidBase64URL(data) {
1328
- if (!base64url.test(data)) return false;
1750
+ if (!base64urlCharset.test(data)) return false;
1329
1751
  const base64 = data.replace(/[-_]/g, (c) => c === "-" ? "+" : "/");
1330
1752
  return isValidBase64(base64.padEnd(Math.ceil(base64.length / 4) * 4, "="));
1331
1753
  }
1332
1754
  const $ZodBase64URL = /*@__PURE__*/ $constructor("$ZodBase64URL", (inst, def) => {
1333
- def.pattern ?? (def.pattern = base64url);
1755
+ def.pattern ?? (def.pattern = base64urlCharset);
1334
1756
  $ZodStringFormat.init(inst, def);
1335
- inst._zod.bag.contentEncoding = "base64url";
1336
1757
  inst._zod.check = (payload) => {
1337
1758
  if (isValidBase64URL(payload.value)) return;
1338
1759
  payload.issues.push({
@@ -1378,14 +1799,14 @@ const $ZodJWT = /*@__PURE__*/ $constructor("$ZodJWT", (inst, def) => {
1378
1799
  });
1379
1800
  const $ZodNumber = /*@__PURE__*/ $constructor("$ZodNumber", (inst, def) => {
1380
1801
  $ZodType.init(inst, def);
1381
- inst._zod.pattern = inst._zod.bag.pattern ?? number$1;
1802
+ inst._zod.pattern = number$1;
1382
1803
  inst._zod.parse = (payload, _ctx) => {
1383
1804
  if (def.coerce) try {
1384
1805
  payload.value = Number(payload.value);
1385
1806
  } catch (_) {}
1386
1807
  const input = payload.value;
1387
1808
  if (typeof input === "number" && !Number.isNaN(input) && Number.isFinite(input)) return payload;
1388
- const received = typeof input === "number" ? Number.isNaN(input) ? "NaN" : !Number.isFinite(input) ? "Infinity" : void 0 : void 0;
1809
+ const received = typeof input === "number" ? Number.isNaN(input) ? "NaN" : !Number.isFinite(input) ? String(input) : void 0 : void 0;
1389
1810
  payload.issues.push({
1390
1811
  expected: "number",
1391
1812
  code: "invalid_type",
@@ -1416,12 +1837,34 @@ const $ZodNever = /*@__PURE__*/ $constructor("$ZodNever", (inst, def) => {
1416
1837
  return payload;
1417
1838
  };
1418
1839
  });
1840
+ function capSize(inst, size) {
1841
+ const caps = sizeCaps(inst._zod.def.checks);
1842
+ if (!caps.length) return;
1843
+ const cap = Math.min(...caps.map((c) => c[0]));
1844
+ const parse = inst._zod.parse;
1845
+ inst._zod.parse = (payload, ctx) => {
1846
+ const n = size(payload.value);
1847
+ if (n > cap && !ctx?.skipChecks && ctx?.direction !== "backward") {
1848
+ for (const [max, ch] of sizeCaps(inst._zod.def.checks)) if (n > max && ch._zod.def.when(payload)) {
1849
+ const start = payload.issues.length;
1850
+ ch._zod.check(payload);
1851
+ payload.issues[start].continue = false;
1852
+ attachSchema(payload.issues, start, inst);
1853
+ return payload;
1854
+ }
1855
+ }
1856
+ return parse(payload, ctx);
1857
+ };
1858
+ }
1859
+ const arraySize = (input) => Array.isArray(input) ? input.length : -1;
1419
1860
  function handleArrayResult(result, final, index) {
1420
1861
  if (result.issues.length) final.issues.push(...prefixIssues(index, result.issues));
1421
1862
  final.value[index] = result.value;
1422
1863
  }
1423
1864
  const $ZodArray = /*@__PURE__*/ $constructor("$ZodArray", (inst, def) => {
1424
1865
  $ZodType.init(inst, def);
1866
+ const memo = globalConfig.memoizer;
1867
+ memo?.attach(inst);
1425
1868
  inst._zod.parse = (payload, ctx) => {
1426
1869
  const input = payload.value;
1427
1870
  if (!Array.isArray(input)) {
@@ -1433,8 +1876,9 @@ const $ZodArray = /*@__PURE__*/ $constructor("$ZodArray", (inst, def) => {
1433
1876
  });
1434
1877
  return payload;
1435
1878
  }
1436
- payload.value = Array(input.length);
1879
+ payload.value = memo ? memo.alloc(inst, payload, Array(input.length), ctx) : Array(input.length);
1437
1880
  const proms = [];
1881
+ const abortEarly = ctx?.abortEarly;
1438
1882
  for (let i = 0; i < input.length; i++) {
1439
1883
  const item = input[i];
1440
1884
  const result = def.element._zod.run({
@@ -1442,19 +1886,25 @@ const $ZodArray = /*@__PURE__*/ $constructor("$ZodArray", (inst, def) => {
1442
1886
  issues: []
1443
1887
  }, ctx);
1444
1888
  if (result instanceof Promise) proms.push(result.then((result) => handleArrayResult(result, payload, i)));
1445
- else handleArrayResult(result, payload, i);
1889
+ else {
1890
+ handleArrayResult(result, payload, i);
1891
+ if (abortEarly && result.issues.length !== 0 && aborted(result)) break;
1892
+ }
1446
1893
  }
1447
1894
  if (proms.length) return Promise.all(proms).then(() => payload);
1448
1895
  return payload;
1449
1896
  };
1897
+ capSize(inst, arraySize);
1450
1898
  });
1451
- function handlePropertyResult(result, final, key, input, isOptionalIn, isOptionalOut) {
1899
+ function handlePropertyResult(result, final, key, input, optin, optout) {
1452
1900
  const isPresent = key in input;
1901
+ const isOptionalOut = optout === "optional";
1902
+ if (!isPresent && isOptionalOut && optin === "optional") return;
1453
1903
  if (result.issues.length) {
1454
- if (isOptionalIn && isOptionalOut && !isPresent) return;
1904
+ if (optin !== void 0 && isOptionalOut && !isPresent) return;
1455
1905
  final.issues.push(...prefixIssues(key, result.issues));
1456
1906
  }
1457
- if (!isPresent && !isOptionalIn) {
1907
+ if (!isPresent && optin === void 0) {
1458
1908
  if (!result.issues.length) final.issues.push({
1459
1909
  code: "invalid_type",
1460
1910
  expected: "nonoptional",
@@ -1464,31 +1914,44 @@ function handlePropertyResult(result, final, key, input, isOptionalIn, isOptiona
1464
1914
  return;
1465
1915
  }
1466
1916
  if (result.value === void 0) {
1467
- if (isPresent) final.value[key] = void 0;
1917
+ if (isPresent || optin === "defaulted" && !isOptionalOut) final.value[key] = void 0;
1468
1918
  } else final.value[key] = result.value;
1469
1919
  }
1920
+ const NO_SYMBOL_KEYS = [];
1470
1921
  function normalizeDef(def) {
1471
1922
  const keys = Object.keys(def.shape);
1472
- 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`);
1923
+ const ownSymbols = Object.getOwnPropertySymbols(def.shape);
1924
+ const symbolKeys = ownSymbols.length ? ownSymbols : NO_SYMBOL_KEYS;
1925
+ const allKeys = symbolKeys.length ? [...keys, ...symbolKeys] : keys;
1926
+ 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`);
1473
1927
  const okeys = optionalKeys(def.shape);
1474
1928
  return {
1475
1929
  ...def,
1476
- keys,
1930
+ allKeys,
1931
+ symbolKeys,
1477
1932
  keySet: new Set(keys),
1478
1933
  numKeys: keys.length,
1479
1934
  optionalKeys: new Set(okeys)
1480
1935
  };
1481
1936
  }
1482
- function handleCatchall(proms, input, payload, ctx, def, inst) {
1937
+ function handleCatchall(proms, input, payload, ctx, def, inst, abortEarly) {
1483
1938
  const unrecognized = [];
1484
1939
  const keySet = def.keySet;
1485
1940
  const _catchall = def.catchall._zod;
1486
1941
  const t = _catchall.def.type;
1487
- const isOptionalIn = _catchall.optin === "optional";
1488
- const isOptionalOut = _catchall.optout === "optional";
1942
+ const optin = _catchall.optin;
1943
+ const optout = _catchall.optout;
1944
+ let seen = 0;
1489
1945
  for (const key in input) {
1490
- if (key === "__proto__") continue;
1946
+ if (abortEarly && payload.issues.length !== seen) {
1947
+ if (aborted(payload, seen)) break;
1948
+ seen = payload.issues.length;
1949
+ }
1491
1950
  if (keySet.has(key)) continue;
1951
+ if (key === "__proto__") {
1952
+ if (t === "never") unrecognized.push(key);
1953
+ continue;
1954
+ }
1492
1955
  if (t === "never") {
1493
1956
  unrecognized.push(key);
1494
1957
  continue;
@@ -1497,14 +1960,15 @@ function handleCatchall(proms, input, payload, ctx, def, inst) {
1497
1960
  value: input[key],
1498
1961
  issues: []
1499
1962
  }, ctx);
1500
- if (r instanceof Promise) proms.push(r.then((r) => handlePropertyResult(r, payload, key, input, isOptionalIn, isOptionalOut)));
1501
- else handlePropertyResult(r, payload, key, input, isOptionalIn, isOptionalOut);
1963
+ if (r instanceof Promise) proms.push(r.then((r) => handlePropertyResult(r, payload, key, input, optin, optout)));
1964
+ else handlePropertyResult(r, payload, key, input, optin, optout);
1502
1965
  }
1503
1966
  if (unrecognized.length) payload.issues.push({
1504
1967
  code: "unrecognized_keys",
1505
1968
  keys: unrecognized,
1506
1969
  input,
1507
- inst
1970
+ inst,
1971
+ continue: true
1508
1972
  });
1509
1973
  if (!proms.length) return payload;
1510
1974
  return Promise.all(proms).then(() => {
@@ -1513,23 +1977,28 @@ function handleCatchall(proms, input, payload, ctx, def, inst) {
1513
1977
  }
1514
1978
  const $ZodObject = /*@__PURE__*/ $constructor("$ZodObject", (inst, def) => {
1515
1979
  $ZodType.init(inst, def);
1516
- if (!Object.getOwnPropertyDescriptor(def, "shape")?.get) {
1517
- const sh = def.shape;
1518
- Object.defineProperty(def, "shape", { get: () => {
1980
+ const desc = Object.getOwnPropertyDescriptor(def, "shape");
1981
+ const sh = desc?.get ? desc.get.raw : def.shape ?? {};
1982
+ if (sh) {
1983
+ const get = () => {
1519
1984
  const newSh = { ...sh };
1520
1985
  Object.defineProperty(def, "shape", { value: newSh });
1986
+ get.raw = newSh;
1521
1987
  return newSh;
1522
- } });
1988
+ };
1989
+ get.raw = sh;
1990
+ Object.defineProperty(def, "shape", { get });
1523
1991
  }
1524
1992
  const _normalized = cached(() => normalizeDef(def));
1525
- defineLazy(inst._zod, "propValues", () => {
1526
- const shape = def.shape;
1993
+ defineLazyInternal(inst, "propValues", (zod) => {
1994
+ const shape = zod.def.shape;
1527
1995
  const propValues = {};
1528
1996
  for (const key in shape) {
1529
1997
  const field = shape[key]._zod;
1530
1998
  if (field.values) {
1531
- propValues[key] ?? (propValues[key] = /* @__PURE__ */ new Set());
1999
+ if (!Object.prototype.hasOwnProperty.call(propValues, key)) assignProp(propValues, key, /* @__PURE__ */ new Set());
1532
2000
  for (const v of field.values) propValues[key].add(v);
2001
+ if (field.optin !== void 0) propValues[key].add(void 0);
1533
2002
  }
1534
2003
  }
1535
2004
  return propValues;
@@ -1537,6 +2006,8 @@ const $ZodObject = /*@__PURE__*/ $constructor("$ZodObject", (inst, def) => {
1537
2006
  const isObject$1 = isObject;
1538
2007
  const catchall = def.catchall;
1539
2008
  let value;
2009
+ const memo = globalConfig.memoizer;
2010
+ memo?.attach(inst);
1540
2011
  inst._zod.parse = (payload, ctx) => {
1541
2012
  value ?? (value = _normalized.value);
1542
2013
  const input = payload.value;
@@ -1549,77 +2020,90 @@ const $ZodObject = /*@__PURE__*/ $constructor("$ZodObject", (inst, def) => {
1549
2020
  });
1550
2021
  return payload;
1551
2022
  }
1552
- payload.value = {};
2023
+ payload.value = memo ? memo.alloc(inst, payload, {}, ctx) : {};
1553
2024
  const proms = [];
1554
2025
  const shape = value.shape;
1555
- for (const key of value.keys) {
2026
+ const abortEarly = ctx?.abortEarly;
2027
+ let seen = payload.issues.length;
2028
+ for (const key of value.allKeys) {
2029
+ if (abortEarly && payload.issues.length !== seen) {
2030
+ if (aborted(payload, seen)) break;
2031
+ seen = payload.issues.length;
2032
+ }
2033
+ if (key === "__proto__") continue;
1556
2034
  const el = shape[key];
1557
- const isOptionalIn = el._zod.optin === "optional";
1558
- const isOptionalOut = el._zod.optout === "optional";
2035
+ const optin = el._zod.optin;
2036
+ const optout = el._zod.optout;
1559
2037
  const r = el._zod.run({
1560
2038
  value: input[key],
1561
2039
  issues: []
1562
2040
  }, ctx);
1563
- if (r instanceof Promise) proms.push(r.then((r) => handlePropertyResult(r, payload, key, input, isOptionalIn, isOptionalOut)));
1564
- else handlePropertyResult(r, payload, key, input, isOptionalIn, isOptionalOut);
2041
+ if (r instanceof Promise) proms.push(r.then((r) => handlePropertyResult(r, payload, key, input, optin, optout)));
2042
+ else handlePropertyResult(r, payload, key, input, optin, optout);
1565
2043
  }
1566
2044
  if (!catchall) return proms.length ? Promise.all(proms).then(() => payload) : payload;
1567
- return handleCatchall(proms, input, payload, ctx, _normalized.value, inst);
2045
+ return handleCatchall(proms, input, payload, ctx, _normalized.value, inst, abortEarly === true);
1568
2046
  };
1569
2047
  });
1570
2048
  const $ZodObjectJIT = /*@__PURE__*/ $constructor("$ZodObjectJIT", (inst, def) => {
1571
2049
  $ZodObject.init(inst, def);
1572
2050
  const superParse = inst._zod.parse;
1573
2051
  const _normalized = cached(() => normalizeDef(def));
2052
+ const memo = globalConfig.memoizer;
1574
2053
  const generateFastpass = (shape) => {
1575
- const doc = new Doc([
1576
- "shape",
1577
- "payload",
1578
- "ctx"
1579
- ]);
1580
2054
  const normalized = _normalized.value;
1581
- const parseStr = (key) => {
1582
- const k = esc(key);
1583
- return `shape[${k}]._zod.run({ value: input[${k}], issues: [] }, ctx)`;
1584
- };
2055
+ const syms = normalized.symbolKeys;
2056
+ const doc = new Doc(["payload", "ctx"], {
2057
+ shape,
2058
+ inst,
2059
+ memo,
2060
+ syms
2061
+ });
2062
+ const parseStr = (k) => `shape[${k}]._zod.run({ value: input[${k}], issues: [] }, ctx)`;
2063
+ const prefixStr = (id, k) => `
2064
+ let ${id}_ab = false;
2065
+ for (let i = 0; i < ${id}.issues.length; i++) {
2066
+ const iss = ${id}.issues[i];
2067
+ iss.path = iss.path ? [${k}, ...iss.path] : [${k}];
2068
+ payload.issues.push(iss);
2069
+ if (iss.continue !== true) ${id}_ab = true;
2070
+ }
2071
+ if (${id}_ab && ctx && ctx.abortEarly) {
2072
+ payload.value = newResult;
2073
+ return payload;
2074
+ }`;
1585
2075
  doc.write(`const input = payload.value;`);
1586
2076
  const ids = Object.create(null);
1587
2077
  let counter = 0;
1588
- for (const key of normalized.keys) ids[key] = `key_${counter++}`;
1589
- doc.write(`const newResult = {};`);
1590
- for (const key of normalized.keys) {
2078
+ for (const key of normalized.allKeys) ids[key] = `key_${counter++}`;
2079
+ doc.write(memo ? `const newResult = memo.alloc(inst, payload, {}, ctx);` : `const newResult = {};`);
2080
+ for (const key of normalized.allKeys) {
2081
+ if (key === "__proto__") continue;
1591
2082
  const id = ids[key];
1592
- const k = esc(key);
2083
+ const k = typeof key === "symbol" ? `syms[${syms.indexOf(key)}]` : esc(key);
2084
+ const isPresent = `${k} in input`;
1593
2085
  const schema = shape[key];
1594
- const isOptionalIn = schema?._zod?.optin === "optional";
2086
+ const optin = schema?._zod?.optin;
2087
+ const isOptionalIn = optin !== void 0;
1595
2088
  const isOptionalOut = schema?._zod?.optout === "optional";
1596
- doc.write(`const ${id} = ${parseStr(key)};`);
1597
- if (isOptionalIn && isOptionalOut) doc.write(`
1598
- if (${id}.issues.length) {
1599
- if (${k} in input) {
1600
- payload.issues = payload.issues.concat(${id}.issues.map(iss => ({
1601
- ...iss,
1602
- path: iss.path ? [${k}, ...iss.path] : [${k}]
1603
- })));
2089
+ doc.write(`const ${id} = ${parseStr(k)};`);
2090
+ if (isOptionalIn && isOptionalOut) {
2091
+ const assign = optin === "optional" ? `${id}_present` : `${id}.value !== undefined || ${id}_present`;
2092
+ doc.write(`
2093
+ const ${id}_present = ${isPresent};
2094
+ if (!${id}.issues.length || ${id}_present) {
2095
+ if (${id}.issues.length) {${prefixStr(id, k)}
1604
2096
  }
1605
- }
1606
-
1607
- if (${id}.value === undefined) {
1608
- if (${k} in input) {
1609
- newResult[${k}] = undefined;
2097
+
2098
+ if (${assign}) {
2099
+ newResult[${k}] = ${id}.value;
1610
2100
  }
1611
- } else {
1612
- newResult[${k}] = ${id}.value;
1613
2101
  }
1614
-
2102
+
1615
2103
  `);
1616
- else if (!isOptionalIn) doc.write(`
1617
- const ${id}_present = ${k} in input;
1618
- if (${id}.issues.length) {
1619
- payload.issues = payload.issues.concat(${id}.issues.map(iss => ({
1620
- ...iss,
1621
- path: iss.path ? [${k}, ...iss.path] : [${k}]
1622
- })));
2104
+ } else if (!isOptionalIn) doc.write(`
2105
+ const ${id}_present = ${isPresent};
2106
+ if (${id}.issues.length) {${prefixStr(id, k)}
1623
2107
  }
1624
2108
  if (!${id}_present && !${id}.issues.length) {
1625
2109
  payload.issues.push({
@@ -1628,39 +2112,33 @@ const $ZodObjectJIT = /*@__PURE__*/ $constructor("$ZodObjectJIT", (inst, def) =>
1628
2112
  input: undefined,
1629
2113
  path: [${k}]
1630
2114
  });
2115
+ if (ctx && ctx.abortEarly) {
2116
+ payload.value = newResult;
2117
+ return payload;
2118
+ }
1631
2119
  }
1632
2120
 
1633
2121
  if (${id}_present) {
1634
- if (${id}.value === undefined) {
1635
- newResult[${k}] = undefined;
1636
- } else {
1637
- newResult[${k}] = ${id}.value;
1638
- }
2122
+ newResult[${k}] = ${id}.value;
1639
2123
  }
1640
2124
 
1641
2125
  `);
1642
- else doc.write(`
1643
- if (${id}.issues.length) {
1644
- payload.issues = payload.issues.concat(${id}.issues.map(iss => ({
1645
- ...iss,
1646
- path: iss.path ? [${k}, ...iss.path] : [${k}]
1647
- })));
2126
+ else {
2127
+ doc.write(`
2128
+ if (${id}.issues.length) {${prefixStr(id, k)}
1648
2129
  }
1649
-
1650
- if (${id}.value === undefined) {
1651
- if (${k} in input) {
1652
- newResult[${k}] = undefined;
1653
- }
1654
- } else {
2130
+ `);
2131
+ if (optin === "defaulted") doc.write(`newResult[${k}] = ${id}.value;`);
2132
+ else doc.write(`
2133
+ if (${id}.value !== undefined || ${isPresent}) {
1655
2134
  newResult[${k}] = ${id}.value;
1656
2135
  }
1657
-
1658
2136
  `);
2137
+ }
1659
2138
  }
1660
2139
  doc.write(`payload.value = newResult;`);
1661
2140
  doc.write(`return payload;`);
1662
- const fn = doc.compile();
1663
- return (payload, ctx) => fn(shape, payload, ctx);
2141
+ return doc.compile();
1664
2142
  };
1665
2143
  let fastpass;
1666
2144
  const isObject$2 = isObject;
@@ -1684,7 +2162,7 @@ const $ZodObjectJIT = /*@__PURE__*/ $constructor("$ZodObjectJIT", (inst, def) =>
1684
2162
  if (!fastpass) fastpass = generateFastpass(def.shape);
1685
2163
  payload = fastpass(payload, ctx);
1686
2164
  if (!catchall) return payload;
1687
- return handleCatchall([], input, payload, ctx, value, inst);
2165
+ return handleCatchall([], input, payload, ctx, value, inst, ctx?.abortEarly === true);
1688
2166
  }
1689
2167
  return superParse(payload, ctx);
1690
2168
  };
@@ -1709,14 +2187,14 @@ function handleUnionResults(results, final, inst, ctx) {
1709
2187
  }
1710
2188
  const $ZodUnion = /*@__PURE__*/ $constructor("$ZodUnion", (inst, def) => {
1711
2189
  $ZodType.init(inst, def);
1712
- defineLazy(inst._zod, "optin", () => def.options.some((o) => o._zod.optin === "optional") ? "optional" : void 0);
1713
- defineLazy(inst._zod, "optout", () => def.options.some((o) => o._zod.optout === "optional") ? "optional" : void 0);
1714
- defineLazy(inst._zod, "values", () => {
1715
- if (def.options.every((o) => o._zod.values)) return new Set(def.options.flatMap((option) => Array.from(option._zod.values)));
2190
+ 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);
2191
+ defineLazyInternal(inst, "optout", (zod) => zod.def.options.some((o) => o._zod.optout === "optional") ? "optional" : void 0);
2192
+ defineLazyInternal(inst, "values", (zod) => {
2193
+ if (zod.def.options.every((o) => o._zod.values)) return new Set(zod.def.options.flatMap((option) => Array.from(option._zod.values)));
1716
2194
  });
1717
- defineLazy(inst._zod, "pattern", () => {
1718
- if (def.options.every((o) => o._zod.pattern)) {
1719
- const patterns = def.options.map((o) => o._zod.pattern);
2195
+ defineLazyInternal(inst, "pattern", (zod) => {
2196
+ if (zod.def.options.every((o) => o._zod.pattern)) {
2197
+ const patterns = zod.def.options.map((o) => o._zod.pattern);
1720
2198
  return new RegExp(`^(${patterns.map((p) => cleanRegex(p.source)).join("|")})$`);
1721
2199
  }
1722
2200
  });
@@ -1778,7 +2256,9 @@ function mergeValues(a, b) {
1778
2256
  ...a,
1779
2257
  ...b
1780
2258
  };
2259
+ if (Object.prototype.hasOwnProperty.call(newObj, "__proto__")) delete newObj.__proto__;
1781
2260
  for (const key of sharedKeys) {
2261
+ if (key === "__proto__") continue;
1782
2262
  const sharedValue = mergeValues(a[key], b[key]);
1783
2263
  if (!sharedValue.valid) return {
1784
2264
  valid: false,
@@ -1820,26 +2300,39 @@ function mergeValues(a, b) {
1820
2300
  function handleIntersectionResults(result, left, right) {
1821
2301
  const unrecKeys = /* @__PURE__ */ new Map();
1822
2302
  let unrecIssue;
1823
- for (const iss of left.issues) if (iss.code === "unrecognized_keys") {
1824
- unrecIssue ?? (unrecIssue = iss);
1825
- for (const k of iss.keys) {
2303
+ const keyIssues = /* @__PURE__ */ new Map();
2304
+ const collect = (iss, side) => {
2305
+ let keys;
2306
+ if (iss.code === "unrecognized_keys" && !iss.path?.length) {
2307
+ unrecIssue ?? (unrecIssue = iss);
2308
+ keys = iss.keys;
2309
+ } else if (iss.code === "invalid_key" && iss.origin === "record" && iss.path?.length === 1) {
2310
+ const k = String(iss.path[0]);
2311
+ if (!keyIssues.has(k)) keyIssues.set(k, iss);
2312
+ keys = [k];
2313
+ } else return false;
2314
+ for (const k of keys) {
1826
2315
  if (!unrecKeys.has(k)) unrecKeys.set(k, {});
1827
- unrecKeys.get(k).l = true;
2316
+ unrecKeys.get(k)[side] = true;
1828
2317
  }
1829
- } else result.issues.push(iss);
1830
- for (const iss of right.issues) if (iss.code === "unrecognized_keys") for (const k of iss.keys) {
1831
- if (!unrecKeys.has(k)) unrecKeys.set(k, {});
1832
- unrecKeys.get(k).r = true;
1833
- }
1834
- else result.issues.push(iss);
2318
+ return true;
2319
+ };
2320
+ for (const iss of left.issues) if (!collect(iss, "l")) result.issues.push(iss);
2321
+ for (const iss of right.issues) if (!collect(iss, "r")) result.issues.push(iss);
1835
2322
  const bothKeys = [...unrecKeys].filter(([, f]) => f.l && f.r).map(([k]) => k);
1836
- if (bothKeys.length && unrecIssue) result.issues.push({
1837
- ...unrecIssue,
1838
- keys: bothKeys
1839
- });
1840
- if (aborted(result)) return result;
2323
+ if (bothKeys.length) {
2324
+ const aggregated = unrecIssue ? bothKeys.filter((k) => unrecIssue.keys.includes(k)) : [];
2325
+ if (aggregated.length) result.issues.push({
2326
+ ...unrecIssue,
2327
+ keys: aggregated
2328
+ });
2329
+ for (const k of bothKeys) if (!aggregated.includes(k) && keyIssues.has(k)) result.issues.push(keyIssues.get(k));
2330
+ }
1841
2331
  const merged = mergeValues(left.value, right.value);
1842
- if (!merged.valid) throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(merged.mergeErrorPath)}`);
2332
+ if (!merged.valid) {
2333
+ if (aborted(result)) return result;
2334
+ throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(merged.mergeErrorPath)}`);
2335
+ }
1843
2336
  result.value = merged.data;
1844
2337
  return result;
1845
2338
  }
@@ -1848,7 +2341,10 @@ const $ZodEnum = /*@__PURE__*/ $constructor("$ZodEnum", (inst, def) => {
1848
2341
  const values = getEnumValues(def.entries);
1849
2342
  const valuesSet = new Set(values);
1850
2343
  inst._zod.values = valuesSet;
1851
- inst._zod.pattern = new RegExp(`^(${values.filter((k) => propertyKeyTypes.has(typeof k)).map((o) => typeof o === "string" ? escapeRegex(o) : o.toString()).join("|")})$`);
2344
+ defineLazyInternal(inst, "pattern", (zod) => {
2345
+ const patternValues = getEnumValues(zod.def.entries).filter((k) => propertyKeyTypes.has(typeof k));
2346
+ return new RegExp(patternValues.length ? `^(${patternValues.map((o) => escapeRegex(o.toString())).join("|")})$` : "^[^\\s\\S]$");
2347
+ });
1852
2348
  inst._zod.parse = (payload, _ctx) => {
1853
2349
  const input = payload.value;
1854
2350
  if (valuesSet.has(input)) return payload;
@@ -1864,67 +2360,66 @@ const $ZodEnum = /*@__PURE__*/ $constructor("$ZodEnum", (inst, def) => {
1864
2360
  const $ZodTransform = /*@__PURE__*/ $constructor("$ZodTransform", (inst, def) => {
1865
2361
  $ZodType.init(inst, def);
1866
2362
  inst._zod.optin = "optional";
2363
+ globalConfig.memoizer?.guard(inst);
1867
2364
  inst._zod.parse = (payload, ctx) => {
1868
2365
  if (ctx.direction === "backward") throw new $ZodEncodeError(inst.constructor.name);
1869
2366
  const _out = def.transform(payload.value, payload);
1870
2367
  if (ctx.async) return (_out instanceof Promise ? _out : Promise.resolve(_out)).then((output) => {
1871
2368
  payload.value = output;
1872
- payload.fallback = true;
1873
2369
  return payload;
1874
2370
  });
1875
2371
  if (_out instanceof Promise) throw new $ZodAsyncError();
1876
2372
  payload.value = _out;
1877
- payload.fallback = true;
1878
2373
  return payload;
1879
2374
  };
1880
2375
  });
1881
- function handleOptionalResult(result, input) {
1882
- if (input === void 0 && (result.issues.length || result.fallback)) return {
1883
- issues: [],
1884
- value: void 0
1885
- };
1886
- return result;
2376
+ function handleOptionalResult(payload, result) {
2377
+ payload.value = result.issues.length ? void 0 : result.value;
2378
+ return payload;
1887
2379
  }
1888
2380
  const $ZodOptional = /*@__PURE__*/ $constructor("$ZodOptional", (inst, def) => {
1889
2381
  $ZodType.init(inst, def);
1890
- inst._zod.optin = "optional";
2382
+ defineLazyInternal(inst, "optin", (zod) => zod.def.innerType._zod.optin === "defaulted" ? "defaulted" : "optional");
1891
2383
  inst._zod.optout = "optional";
1892
- defineLazy(inst._zod, "values", () => {
1893
- return def.innerType._zod.values ? new Set([...def.innerType._zod.values, void 0]) : void 0;
2384
+ defineLazyInternal(inst, "values", (zod) => {
2385
+ const values = zod.def.innerType._zod.values;
2386
+ return values ? new Set([...values, void 0]) : void 0;
1894
2387
  });
1895
- defineLazy(inst._zod, "pattern", () => {
1896
- const pattern = def.innerType._zod.pattern;
2388
+ defineLazyInternal(inst, "pattern", (zod) => {
2389
+ const pattern = zod.def.innerType._zod.pattern;
1897
2390
  return pattern ? new RegExp(`^(${cleanRegex(pattern.source)})?$`) : void 0;
1898
2391
  });
1899
2392
  inst._zod.parse = (payload, ctx) => {
1900
- if (def.innerType._zod.optin === "optional") {
1901
- const input = payload.value;
1902
- const result = def.innerType._zod.run(payload, ctx);
1903
- if (result instanceof Promise) return result.then((r) => handleOptionalResult(r, input));
1904
- return handleOptionalResult(result, input);
2393
+ if (payload.value === void 0) {
2394
+ if (def.innerType._zod.optin !== "defaulted") return payload;
2395
+ const result = def.innerType._zod.run({
2396
+ value: payload.value,
2397
+ issues: []
2398
+ }, ctx);
2399
+ if (result instanceof Promise) return result.then((result) => handleOptionalResult(payload, result));
2400
+ return handleOptionalResult(payload, result);
1905
2401
  }
1906
- if (payload.value === void 0) return payload;
1907
2402
  return def.innerType._zod.run(payload, ctx);
1908
2403
  };
1909
2404
  });
1910
2405
  const $ZodExactOptional = /*@__PURE__*/ $constructor("$ZodExactOptional", (inst, def) => {
1911
2406
  $ZodOptional.init(inst, def);
1912
- defineLazy(inst._zod, "values", () => def.innerType._zod.values);
1913
- defineLazy(inst._zod, "pattern", () => def.innerType._zod.pattern);
2407
+ defineLazyInternal(inst, "values", (zod) => zod.def.innerType._zod.values);
2408
+ defineLazyInternal(inst, "pattern", (zod) => zod.def.innerType._zod.pattern);
1914
2409
  inst._zod.parse = (payload, ctx) => {
1915
2410
  return def.innerType._zod.run(payload, ctx);
1916
2411
  };
1917
2412
  });
1918
2413
  const $ZodNullable = /*@__PURE__*/ $constructor("$ZodNullable", (inst, def) => {
1919
2414
  $ZodType.init(inst, def);
1920
- defineLazy(inst._zod, "optin", () => def.innerType._zod.optin);
1921
- defineLazy(inst._zod, "optout", () => def.innerType._zod.optout);
1922
- defineLazy(inst._zod, "pattern", () => {
1923
- const pattern = def.innerType._zod.pattern;
2415
+ defineLazyInternal(inst, "optin", (zod) => zod.def.innerType._zod.optin);
2416
+ defineLazyInternal(inst, "optout", (zod) => zod.def.innerType._zod.optout);
2417
+ defineLazyInternal(inst, "pattern", (zod) => {
2418
+ const pattern = zod.def.innerType._zod.pattern;
1924
2419
  return pattern ? new RegExp(`^(${cleanRegex(pattern.source)}|null)$`) : void 0;
1925
2420
  });
1926
- defineLazy(inst._zod, "values", () => {
1927
- return def.innerType._zod.values ? new Set([...def.innerType._zod.values, null]) : void 0;
2421
+ defineLazyInternal(inst, "values", (zod) => {
2422
+ return zod.def.innerType._zod.values ? new Set([...zod.def.innerType._zod.values, null]) : void 0;
1928
2423
  });
1929
2424
  inst._zod.parse = (payload, ctx) => {
1930
2425
  if (payload.value === null) return payload;
@@ -1933,8 +2428,8 @@ const $ZodNullable = /*@__PURE__*/ $constructor("$ZodNullable", (inst, def) => {
1933
2428
  });
1934
2429
  const $ZodDefault = /*@__PURE__*/ $constructor("$ZodDefault", (inst, def) => {
1935
2430
  $ZodType.init(inst, def);
1936
- inst._zod.optin = "optional";
1937
- defineLazy(inst._zod, "values", () => def.innerType._zod.values);
2431
+ inst._zod.optin = "defaulted";
2432
+ defineLazyInternal(inst, "values", (zod) => zod.def.innerType._zod.values);
1938
2433
  inst._zod.parse = (payload, ctx) => {
1939
2434
  if (ctx.direction === "backward") return def.innerType._zod.run(payload, ctx);
1940
2435
  if (payload.value === void 0) {
@@ -1955,8 +2450,8 @@ function handleDefaultResult(payload, def) {
1955
2450
  }
1956
2451
  const $ZodPrefault = /*@__PURE__*/ $constructor("$ZodPrefault", (inst, def) => {
1957
2452
  $ZodType.init(inst, def);
1958
- inst._zod.optin = "optional";
1959
- defineLazy(inst._zod, "values", () => def.innerType._zod.values);
2453
+ inst._zod.optin = "defaulted";
2454
+ defineLazyInternal(inst, "values", (zod) => zod.def.innerType._zod.values);
1960
2455
  inst._zod.parse = (payload, ctx) => {
1961
2456
  if (ctx.direction === "backward") return def.innerType._zod.run(payload, ctx);
1962
2457
  if (payload.value === void 0) payload.value = def.defaultValue;
@@ -1965,8 +2460,8 @@ const $ZodPrefault = /*@__PURE__*/ $constructor("$ZodPrefault", (inst, def) => {
1965
2460
  });
1966
2461
  const $ZodNonOptional = /*@__PURE__*/ $constructor("$ZodNonOptional", (inst, def) => {
1967
2462
  $ZodType.init(inst, def);
1968
- defineLazy(inst._zod, "values", () => {
1969
- const v = def.innerType._zod.values;
2463
+ defineLazyInternal(inst, "values", (zod) => {
2464
+ const v = zod.def.innerType._zod.values;
1970
2465
  return v ? new Set([...v].filter((x) => x !== void 0)) : void 0;
1971
2466
  });
1972
2467
  inst._zod.parse = (payload, ctx) => {
@@ -1984,46 +2479,41 @@ function handleNonOptionalResult(payload, inst) {
1984
2479
  });
1985
2480
  return payload;
1986
2481
  }
2482
+ function handleCatchResult(payload, result, def, ctx) {
2483
+ if (!result.issues.length) {
2484
+ payload.value = result.value;
2485
+ if (result.memo) payload.memo = true;
2486
+ return payload;
2487
+ }
2488
+ payload.value = def.catchValue({
2489
+ ...result,
2490
+ value: payload.value,
2491
+ error: { issues: result.issues.map((iss) => finalizeIssue(iss, ctx, config())) },
2492
+ input: payload.value
2493
+ });
2494
+ return payload;
2495
+ }
1987
2496
  const $ZodCatch = /*@__PURE__*/ $constructor("$ZodCatch", (inst, def) => {
1988
2497
  $ZodType.init(inst, def);
1989
- inst._zod.optin = "optional";
1990
- defineLazy(inst._zod, "optout", () => def.innerType._zod.optout);
1991
- defineLazy(inst._zod, "values", () => def.innerType._zod.values);
2498
+ defineLazyInternal(inst, "optin", (zod) => zod.def.innerType._zod.optin === "defaulted" ? "defaulted" : "optional");
2499
+ defineLazyInternal(inst, "optout", (zod) => zod.def.innerType._zod.optout);
2500
+ defineLazyInternal(inst, "values", (zod) => zod.def.innerType._zod.values);
1992
2501
  inst._zod.parse = (payload, ctx) => {
1993
2502
  if (ctx.direction === "backward") return def.innerType._zod.run(payload, ctx);
1994
- const result = def.innerType._zod.run(payload, ctx);
1995
- if (result instanceof Promise) return result.then((result) => {
1996
- payload.value = result.value;
1997
- if (result.issues.length) {
1998
- payload.value = def.catchValue({
1999
- ...payload,
2000
- error: { issues: result.issues.map((iss) => finalizeIssue(iss, ctx, config())) },
2001
- input: payload.value
2002
- });
2003
- payload.issues = [];
2004
- payload.fallback = true;
2005
- }
2006
- return payload;
2007
- });
2008
- payload.value = result.value;
2009
- if (result.issues.length) {
2010
- payload.value = def.catchValue({
2011
- ...payload,
2012
- error: { issues: result.issues.map((iss) => finalizeIssue(iss, ctx, config())) },
2013
- input: payload.value
2014
- });
2015
- payload.issues = [];
2016
- payload.fallback = true;
2017
- }
2018
- return payload;
2503
+ const result = def.innerType._zod.run({
2504
+ value: payload.value,
2505
+ issues: []
2506
+ }, ctx);
2507
+ if (result instanceof Promise) return result.then((result) => handleCatchResult(payload, result, def, ctx));
2508
+ return handleCatchResult(payload, result, def, ctx);
2019
2509
  };
2020
2510
  });
2021
2511
  const $ZodPipe = /*@__PURE__*/ $constructor("$ZodPipe", (inst, def) => {
2022
2512
  $ZodType.init(inst, def);
2023
- defineLazy(inst._zod, "values", () => def.in._zod.values);
2024
- defineLazy(inst._zod, "optin", () => def.in._zod.optin);
2025
- defineLazy(inst._zod, "optout", () => def.out._zod.optout);
2026
- defineLazy(inst._zod, "propValues", () => def.in._zod.propValues);
2513
+ defineLazyInternal(inst, "values", (zod) => zod.def.in._zod.values);
2514
+ defineLazyInternal(inst, "optin", (zod) => zod.def.in._zod.optin);
2515
+ defineLazyInternal(inst, "optout", (zod) => zod.def.out._zod.optout);
2516
+ defineLazyInternal(inst, "propValues", (zod) => zod.def.in._zod.propValues);
2027
2517
  inst._zod.parse = (payload, ctx) => {
2028
2518
  if (ctx.direction === "backward") {
2029
2519
  const right = def.out._zod.run(payload, ctx);
@@ -2036,22 +2526,21 @@ const $ZodPipe = /*@__PURE__*/ $constructor("$ZodPipe", (inst, def) => {
2036
2526
  };
2037
2527
  });
2038
2528
  function handlePipeResult(left, next, ctx) {
2039
- if (left.issues.length) {
2529
+ if (left.issues.some((iss) => iss.code !== "unrecognized_keys")) {
2040
2530
  left.aborted = true;
2041
2531
  return left;
2042
2532
  }
2043
2533
  return next._zod.run({
2044
2534
  value: left.value,
2045
- issues: left.issues,
2046
- fallback: left.fallback
2535
+ issues: left.issues
2047
2536
  }, ctx);
2048
2537
  }
2049
2538
  const $ZodReadonly = /*@__PURE__*/ $constructor("$ZodReadonly", (inst, def) => {
2050
2539
  $ZodType.init(inst, def);
2051
- defineLazy(inst._zod, "propValues", () => def.innerType._zod.propValues);
2052
- defineLazy(inst._zod, "values", () => def.innerType._zod.values);
2053
- defineLazy(inst._zod, "optin", () => def.innerType?._zod?.optin);
2054
- defineLazy(inst._zod, "optout", () => def.innerType?._zod?.optout);
2540
+ defineLazyInternal(inst, "propValues", (zod) => zod.def.innerType._zod.propValues);
2541
+ defineLazyInternal(inst, "values", (zod) => zod.def.innerType._zod.values);
2542
+ defineLazyInternal(inst, "optin", (zod) => zod.def.innerType?._zod?.optin);
2543
+ defineLazyInternal(inst, "optout", (zod) => zod.def.innerType?._zod?.optout);
2055
2544
  inst._zod.parse = (payload, ctx) => {
2056
2545
  if (ctx.direction === "backward") return def.innerType._zod.run(payload, ctx);
2057
2546
  const result = def.innerType._zod.run(payload, ctx);
@@ -2060,7 +2549,7 @@ const $ZodReadonly = /*@__PURE__*/ $constructor("$ZodReadonly", (inst, def) => {
2060
2549
  };
2061
2550
  });
2062
2551
  function handleReadonlyResult(payload) {
2063
- payload.value = Object.freeze(payload.value);
2552
+ if (!payload.memo) payload.value = Object.freeze(payload.value);
2064
2553
  return payload;
2065
2554
  }
2066
2555
  const $ZodCustom = /*@__PURE__*/ $constructor("$ZodCustom", (inst, def) => {
@@ -2090,7 +2579,368 @@ function handleRefineResult(result, payload, input, inst) {
2090
2579
  }
2091
2580
  }
2092
2581
  //#endregion
2093
- //#region ../../node_modules/.pnpm/zod@4.4.3/node_modules/zod/v4/core/registries.js
2582
+ //#region ../../node_modules/.pnpm/zod@4.6.7/node_modules/zod/v4/core/memoizer.js
2583
+ var $ZodCyclicError = class extends Error {
2584
+ constructor() {
2585
+ super(`Cannot parse a reference cycle that closes through a transform`);
2586
+ this.name = "ZodCyclicError";
2587
+ }
2588
+ };
2589
+ /** Keyed off the context object every schema in one parse call already shares. */
2590
+ const STATE = "~memo";
2591
+ const NO_ISSUES = [];
2592
+ function isRef(value) {
2593
+ return value !== null && typeof value === "object";
2594
+ }
2595
+ function cloneIssues(issues) {
2596
+ return issues.map((iss) => iss.path ? {
2597
+ ...iss,
2598
+ path: iss.path.slice()
2599
+ } : { ...iss });
2600
+ }
2601
+ const recursive = /*@__PURE__*/ new WeakMap();
2602
+ /** What the walk established, in order of certainty: ordered so the strongest answer among children wins. */
2603
+ const NONE = 0;
2604
+ const ASSUMED = 1;
2605
+ const PROVEN = 2;
2606
+ /** Whether this schema's subtree contains a cycle, so one parse can re-enter it. */
2607
+ function isRecursive(inst, stack, resolve) {
2608
+ const cached = recursive.get(inst);
2609
+ if (cached !== void 0) return cached ? PROVEN : NONE;
2610
+ if (stack.has(inst)) return PROVEN;
2611
+ stack.add(inst);
2612
+ let result = NONE;
2613
+ const check = (child) => {
2614
+ if (result !== PROVEN && child?._zod) {
2615
+ const answer = isRecursive(child, stack, resolve);
2616
+ if (answer > result) result = answer;
2617
+ }
2618
+ };
2619
+ const shape = (sh, spread) => {
2620
+ let answer = NONE;
2621
+ for (const key of Reflect.ownKeys(sh)) {
2622
+ const desc = Object.getOwnPropertyDescriptor(sh, key);
2623
+ if (spread && !desc.enumerable) continue;
2624
+ const child = desc.get ? ASSUMED : desc.value?._zod ? isRecursive(desc.value, stack, resolve) : NONE;
2625
+ if (child > answer) answer = child;
2626
+ }
2627
+ return answer;
2628
+ };
2629
+ const merge = (answer) => {
2630
+ if (answer > result) result = answer;
2631
+ };
2632
+ const def = inst._zod.def;
2633
+ switch (def.type) {
2634
+ case "object": {
2635
+ const raw = rawShape(def);
2636
+ merge(raw ? shape(raw, true) : ASSUMED);
2637
+ check(def.catchall);
2638
+ break;
2639
+ }
2640
+ case "array":
2641
+ check(def.element);
2642
+ break;
2643
+ case "tuple":
2644
+ for (const el of def.items) check(el);
2645
+ check(def.rest);
2646
+ break;
2647
+ case "record":
2648
+ case "map":
2649
+ check(def.keyType);
2650
+ check(def.valueType);
2651
+ break;
2652
+ case "set":
2653
+ check(def.valueType);
2654
+ break;
2655
+ case "union":
2656
+ for (const el of def.options) check(el);
2657
+ break;
2658
+ case "intersection":
2659
+ check(def.left);
2660
+ check(def.right);
2661
+ break;
2662
+ case "optional":
2663
+ case "nullable":
2664
+ case "default":
2665
+ case "prefault":
2666
+ case "catch":
2667
+ case "readonly":
2668
+ case "nonoptional":
2669
+ case "promise":
2670
+ case "success":
2671
+ check(def.innerType);
2672
+ break;
2673
+ case "pipe":
2674
+ check(def.in);
2675
+ check(def.out);
2676
+ break;
2677
+ case "function":
2678
+ check(def.input);
2679
+ check(def.output);
2680
+ break;
2681
+ case "lazy": {
2682
+ const inner = def._cachedInner ?? (resolve ? inst._zod.innerType : void 0);
2683
+ merge(inner ? isRecursive(inner, stack, false) : ASSUMED);
2684
+ break;
2685
+ }
2686
+ case "template_literal":
2687
+ case "string":
2688
+ case "number":
2689
+ case "int":
2690
+ case "boolean":
2691
+ case "bigint":
2692
+ case "symbol":
2693
+ case "undefined":
2694
+ case "null":
2695
+ case "void":
2696
+ case "never":
2697
+ case "any":
2698
+ case "unknown":
2699
+ case "date":
2700
+ case "nan":
2701
+ case "enum":
2702
+ case "literal":
2703
+ case "file":
2704
+ case "transform":
2705
+ case "custom": break;
2706
+ default: for (const key in def) {
2707
+ const desc = Object.getOwnPropertyDescriptor(def, key);
2708
+ if (!desc || desc.get) continue;
2709
+ const value = desc.value;
2710
+ if (!value || typeof value !== "object") continue;
2711
+ if (value._zod) check(value);
2712
+ else if (Array.isArray(value)) for (const el of value) check(el);
2713
+ }
2714
+ }
2715
+ stack.delete(inst);
2716
+ return settle(inst, result);
2717
+ }
2718
+ /** An assumed answer must not outlive the resolution that settles it, so only a certain one is cached. */
2719
+ function settle(inst, answer) {
2720
+ if (answer !== ASSUMED) recursive.set(inst, answer === PROVEN);
2721
+ return answer;
2722
+ }
2723
+ function bucketFor(state, inst) {
2724
+ let bucket = state.buckets.get(inst);
2725
+ if (!bucket) {
2726
+ bucket = /* @__PURE__ */ new WeakMap();
2727
+ state.buckets.set(inst, bucket);
2728
+ }
2729
+ return bucket;
2730
+ }
2731
+ let handoff;
2732
+ const open = [];
2733
+ const memo = {
2734
+ alloc(_inst, payload, empty) {
2735
+ const bucket = handoff;
2736
+ if (!bucket) return empty;
2737
+ handoff = void 0;
2738
+ const entry = {
2739
+ value: empty,
2740
+ issues: null
2741
+ };
2742
+ bucket.set(payload.value, entry);
2743
+ open.push(entry);
2744
+ return empty;
2745
+ },
2746
+ guard(inst) {
2747
+ var _a;
2748
+ (_a = inst._zod).deferred ?? (_a.deferred = []);
2749
+ inst._zod.deferred.push(() => {
2750
+ const base = inst._zod.parse;
2751
+ const wrapped = (payload, ctx) => {
2752
+ if (ctx.direction !== "backward" && isBackEdge(ctx, payload.value)) throw new $ZodCyclicError();
2753
+ return base(payload, ctx);
2754
+ };
2755
+ inst._zod.parse = wrapped;
2756
+ if (inst._zod.run === base) inst._zod.run = wrapped;
2757
+ });
2758
+ },
2759
+ attach(inst) {
2760
+ var _a;
2761
+ let isRecursiveInst;
2762
+ let rechecked = false;
2763
+ let lastCtx;
2764
+ let lastBucket;
2765
+ (_a = inst._zod).deferred ?? (_a.deferred = []);
2766
+ inst._zod.deferred.push(() => {
2767
+ const base = inst._zod.parse;
2768
+ const wrapped = (payload, ctx) => {
2769
+ if (isRecursiveInst === void 0) {
2770
+ const walked = isRecursive(inst, /* @__PURE__ */ new Set(), false);
2771
+ if (walked === NONE) {
2772
+ inst._zod.parse = base;
2773
+ if (inst._zod.run === wrapped) inst._zod.run = base;
2774
+ return base(payload, ctx);
2775
+ }
2776
+ if (walked === PROVEN || rechecked) isRecursiveInst = true;
2777
+ else rechecked = true;
2778
+ }
2779
+ const input = payload.value;
2780
+ if (!isRef(input)) return base(payload, ctx);
2781
+ let state = ctx[STATE];
2782
+ if (!state) {
2783
+ state = {
2784
+ buckets: /* @__PURE__ */ new WeakMap(),
2785
+ backEdges: void 0
2786
+ };
2787
+ ctx[STATE] = state;
2788
+ }
2789
+ let bucket;
2790
+ if (lastCtx === ctx) bucket = lastBucket;
2791
+ else {
2792
+ bucket = bucketFor(state, inst);
2793
+ lastCtx = ctx;
2794
+ lastBucket = bucket;
2795
+ }
2796
+ const hit = bucket.get(input);
2797
+ if (hit) {
2798
+ payload.value = hit.value;
2799
+ if (hit.issues) {
2800
+ if (hit.issues.length) payload.issues.push(...cloneIssues(hit.issues));
2801
+ } else {
2802
+ payload.memo = true;
2803
+ state.backEdges ?? (state.backEdges = /* @__PURE__ */ new WeakSet());
2804
+ state.backEdges.add(hit.value);
2805
+ }
2806
+ return payload;
2807
+ }
2808
+ handoff = bucket;
2809
+ const depth = open.length;
2810
+ const result = base(payload, ctx);
2811
+ handoff = void 0;
2812
+ const entry = open.length > depth ? open.pop() : void 0;
2813
+ if (result instanceof Promise) return result.then((r) => {
2814
+ if (entry) entry.issues = r.issues.length ? cloneIssues(r.issues) : NO_ISSUES;
2815
+ return r;
2816
+ });
2817
+ if (entry) entry.issues = result.issues.length ? cloneIssues(result.issues) : NO_ISSUES;
2818
+ return result;
2819
+ };
2820
+ inst._zod.parse = wrapped;
2821
+ if (inst._zod.run === base) inst._zod.run = wrapped;
2822
+ });
2823
+ }
2824
+ };
2825
+ /** The memoizer that gives containers cycle support. `zod` installs it by default; `zod/mini` opts in with `config({ memoizer: memoizer() })`. */
2826
+ function memoizer() {
2827
+ return memo;
2828
+ }
2829
+ /** Whether this value is a node a back-edge resolved to before it finished. */
2830
+ function isBackEdge(ctx, value) {
2831
+ const backEdges = ctx[STATE]?.backEdges;
2832
+ return backEdges !== void 0 && isRef(value) && backEdges.has(value);
2833
+ }
2834
+ //#endregion
2835
+ //#region ../../node_modules/.pnpm/zod@4.6.7/node_modules/zod/v4/locales/en.js
2836
+ const error = () => {
2837
+ const Sizable = {
2838
+ string: {
2839
+ unit: "characters",
2840
+ verb: "to have"
2841
+ },
2842
+ file: {
2843
+ unit: "bytes",
2844
+ verb: "to have"
2845
+ },
2846
+ array: {
2847
+ unit: "items",
2848
+ verb: "to have"
2849
+ },
2850
+ set: {
2851
+ unit: "items",
2852
+ verb: "to have"
2853
+ },
2854
+ map: {
2855
+ unit: "entries",
2856
+ verb: "to have"
2857
+ }
2858
+ };
2859
+ function getSizing(origin) {
2860
+ return Sizable[origin] ?? null;
2861
+ }
2862
+ const FormatDictionary = {
2863
+ regex: "input",
2864
+ email: "email address",
2865
+ url: "URL",
2866
+ emoji: "emoji",
2867
+ uuid: "UUID",
2868
+ uuidv4: "UUIDv4",
2869
+ uuidv6: "UUIDv6",
2870
+ nanoid: "nanoid",
2871
+ guid: "GUID",
2872
+ cuid: "cuid",
2873
+ cuid2: "cuid2",
2874
+ ulid: "ULID",
2875
+ xid: "XID",
2876
+ ksuid: "KSUID",
2877
+ datetime: "ISO datetime",
2878
+ date: "ISO date",
2879
+ time: "ISO time",
2880
+ duration: "ISO duration",
2881
+ ipv4: "IPv4 address",
2882
+ ipv6: "IPv6 address",
2883
+ mac: "MAC address",
2884
+ cidrv4: "IPv4 range",
2885
+ cidrv6: "IPv6 range",
2886
+ base64: "base64-encoded string",
2887
+ base64url: "base64url-encoded string",
2888
+ json_string: "JSON string",
2889
+ e164: "E.164 number",
2890
+ currency_code: "currency code",
2891
+ credit_card: "credit card number",
2892
+ iban: "IBAN",
2893
+ jwt: "JWT",
2894
+ template_literal: "input"
2895
+ };
2896
+ const TypeDictionary = { nan: "NaN" };
2897
+ function getTypeName(type, input) {
2898
+ if (type === "number" && typeof input === "number" && !Number.isFinite(input)) return String(input);
2899
+ return TypeDictionary[type] ?? type;
2900
+ }
2901
+ return (issue) => {
2902
+ switch (issue.code) {
2903
+ case "invalid_type": return `Invalid input: expected ${getTypeName(issue.expected)}, received ${getTypeName(parsedType(issue.input), issue.input)}`;
2904
+ case "invalid_value":
2905
+ if (issue.values.length === 1) return `Invalid input: expected ${stringifyPrimitive(issue.values[0])}`;
2906
+ return `Invalid option: expected one of ${joinValues(issue.values, "|")}`;
2907
+ case "too_big": {
2908
+ const adj = issue.exact ? "exactly " : issue.inclusive ? "<=" : "<";
2909
+ const sizing = getSizing(issue.origin);
2910
+ if (sizing) return `Too big: expected ${issue.origin ?? "value"} to have ${adj}${issue.maximum.toString()} ${sizing.unit ?? "elements"}`;
2911
+ return `Too big: expected ${issue.origin ?? "value"} to be ${adj}${issue.maximum.toString()}`;
2912
+ }
2913
+ case "too_small": {
2914
+ const adj = issue.exact ? "exactly " : issue.inclusive ? ">=" : ">";
2915
+ const sizing = getSizing(issue.origin);
2916
+ if (sizing) return `Too small: expected ${issue.origin} to have ${adj}${issue.minimum.toString()} ${sizing.unit}`;
2917
+ return `Too small: expected ${issue.origin} to be ${adj}${issue.minimum.toString()}`;
2918
+ }
2919
+ case "invalid_format": {
2920
+ const _issue = issue;
2921
+ if (_issue.format === "starts_with") return `Invalid string: must start with "${_issue.prefix}"`;
2922
+ if (_issue.format === "ends_with") return `Invalid string: must end with "${_issue.suffix}"`;
2923
+ if (_issue.format === "includes") return `Invalid string: must include "${_issue.includes}"`;
2924
+ if (_issue.format === "regex") return `Invalid string: must match pattern ${_issue.pattern}`;
2925
+ return `Invalid ${FormatDictionary[_issue.format] ?? issue.format}`;
2926
+ }
2927
+ case "not_multiple_of": return `Invalid number: must be a multiple of ${issue.divisor}`;
2928
+ case "unrecognized_keys": return `Unrecognized key${issue.keys.length > 1 ? "s" : ""}: ${joinValues(issue.keys, ", ")}`;
2929
+ case "invalid_key": return `Invalid key in ${issue.origin}`;
2930
+ case "invalid_union":
2931
+ if (issue.options && Array.isArray(issue.options) && issue.options.length > 0) return `Invalid discriminator value. Expected ${issue.options.map((o) => `'${o}'`).join(" | ")}`;
2932
+ if (issue.inclusive === false) return "Invalid input: more than one option matched";
2933
+ return "Invalid input";
2934
+ case "invalid_element": return `Invalid value in ${issue.origin}`;
2935
+ default: return `Invalid input`;
2936
+ }
2937
+ };
2938
+ };
2939
+ function en_default() {
2940
+ return { localeError: error() };
2941
+ }
2942
+ //#endregion
2943
+ //#region ../../node_modules/.pnpm/zod@4.6.7/node_modules/zod/v4/core/registries.js
2094
2944
  var _a;
2095
2945
  var $ZodRegistry = class {
2096
2946
  constructor() {
@@ -2137,13 +2987,17 @@ function registry() {
2137
2987
  (_a = globalThis).__zod_globalRegistry ?? (_a.__zod_globalRegistry = registry());
2138
2988
  const globalRegistry = globalThis.__zod_globalRegistry;
2139
2989
  //#endregion
2140
- //#region ../../node_modules/.pnpm/zod@4.4.3/node_modules/zod/v4/core/api.js
2990
+ //#region ../../node_modules/.pnpm/zod@4.6.7/node_modules/zod/v4/core/api.js
2991
+ function snapshotChecks(def) {
2992
+ if (def.checks) def.checks = [...def.checks];
2993
+ return def;
2994
+ }
2141
2995
  // @__NO_SIDE_EFFECTS__
2142
2996
  function _string(Class, params) {
2143
- return new Class({
2997
+ return new Class(snapshotChecks({
2144
2998
  type: "string",
2145
2999
  ...normalizeParams(params)
2146
- });
3000
+ }));
2147
3001
  }
2148
3002
  // @__NO_SIDE_EFFECTS__
2149
3003
  function _email(Class, params) {
@@ -2415,11 +3269,11 @@ function _isoDuration(Class, params) {
2415
3269
  }
2416
3270
  // @__NO_SIDE_EFFECTS__
2417
3271
  function _number(Class, params) {
2418
- return new Class({
3272
+ return new Class(snapshotChecks({
2419
3273
  type: "number",
2420
3274
  checks: [],
2421
3275
  ...normalizeParams(params)
2422
- });
3276
+ }));
2423
3277
  }
2424
3278
  // @__NO_SIDE_EFFECTS__
2425
3279
  function _int(Class, params) {
@@ -2615,7 +3469,7 @@ function _superRefine(fn, params) {
2615
3469
  const _issue = issue$2;
2616
3470
  if (_issue.fatal) _issue.continue = false;
2617
3471
  _issue.code ?? (_issue.code = "custom");
2618
- _issue.input ?? (_issue.input = payload.value);
3472
+ if (!("input" in _issue)) _issue.input = payload.value;
2619
3473
  _issue.inst ?? (_issue.inst = ch);
2620
3474
  _issue.continue ?? (_issue.continue = !ch._zod.def.abort);
2621
3475
  payload.issues.push(issue(_issue));
@@ -2635,7 +3489,11 @@ function _check(fn, params) {
2635
3489
  return ch;
2636
3490
  }
2637
3491
  //#endregion
2638
- //#region ../../node_modules/.pnpm/zod@4.4.3/node_modules/zod/v4/core/to-json-schema.js
3492
+ //#region ../../node_modules/.pnpm/zod@4.6.7/node_modules/zod/v4/core/to-json-schema.js
3493
+ function assignProps(target, ...sources) {
3494
+ for (const source of sources) for (const key of Reflect.ownKeys(source)) if (Object.prototype.propertyIsEnumerable.call(source, key)) assignProp(target, key, source[key]);
3495
+ return target;
3496
+ }
2639
3497
  function initializeContext(params) {
2640
3498
  let target = params?.target ?? "draft-2020-12";
2641
3499
  if (target === "draft-4") target = "draft-04";
@@ -2649,12 +3507,32 @@ function initializeContext(params) {
2649
3507
  io: params?.io ?? "output",
2650
3508
  counter: 0,
2651
3509
  seen: /* @__PURE__ */ new Map(),
3510
+ sharedDefsExtractedFor: void 0,
3511
+ sharedEmitDoneFor: void 0,
2652
3512
  cycles: params?.cycles ?? "ref",
2653
3513
  reused: params?.reused ?? "inline",
3514
+ intersections: [],
3515
+ deferred: [],
2654
3516
  external: params?.external ?? void 0
2655
3517
  };
2656
3518
  }
2657
- function process(schema, ctx, _params = {
3519
+ /**
3520
+ * Applies the `unrepresentable` setting at a site that has no JSON Schema equivalent. Throws
3521
+ * `message` unless the setting (or the handler's return value) says otherwise. Returns `true` if a
3522
+ * custom JSON Schema was written into `json`, in which case the caller must not write its own.
3523
+ */
3524
+ function handleUnrepresentable(schema, ctx, json, params, message) {
3525
+ const result = typeof ctx.unrepresentable === "function" ? ctx.unrepresentable({
3526
+ zodSchema: schema,
3527
+ path: params.path,
3528
+ message
3529
+ }) : ctx.unrepresentable;
3530
+ if (result === "any") return false;
3531
+ if (result === void 0 || result === "throw") throw new Error(message);
3532
+ Object.assign(json, result);
3533
+ return true;
3534
+ }
3535
+ function processSchema(schema, ctx, _params = {
2658
3536
  path: [],
2659
3537
  schemaPath: []
2660
3538
  }) {
@@ -2673,6 +3551,8 @@ function process(schema, ctx, _params = {
2673
3551
  path: _params.path
2674
3552
  };
2675
3553
  ctx.seen.set(schema, result);
3554
+ ctx.sharedDefsExtractedFor = void 0;
3555
+ ctx.sharedEmitDoneFor = void 0;
2676
3556
  const overrideSchema = schema._zod.toJSONSchema?.();
2677
3557
  if (overrideSchema) result.schema = overrideSchema;
2678
3558
  else {
@@ -2691,12 +3571,12 @@ function process(schema, ctx, _params = {
2691
3571
  const parent = schema._zod.parent;
2692
3572
  if (parent) {
2693
3573
  if (!result.ref) result.ref = parent;
2694
- process(parent, ctx, params);
3574
+ processSchema(parent, ctx, params);
2695
3575
  ctx.seen.get(parent).isParent = true;
2696
3576
  }
2697
3577
  }
2698
3578
  const meta = ctx.metadataRegistry.get(schema);
2699
- if (meta) Object.assign(result.schema, meta);
3579
+ if (meta) assignProps(result.schema, meta);
2700
3580
  if (ctx.io === "input" && isTransforming(schema)) {
2701
3581
  delete result.schema.examples;
2702
3582
  delete result.schema.default;
@@ -2705,9 +3585,13 @@ function process(schema, ctx, _params = {
2705
3585
  delete result.schema._prefault;
2706
3586
  return ctx.seen.get(schema).schema;
2707
3587
  }
3588
+ function encodeJSONPointerSegment(segment) {
3589
+ return segment.replace(/~/g, "~0").replace(/\//g, "~1");
3590
+ }
2708
3591
  function extractDefs(ctx, schema) {
2709
3592
  const root = ctx.seen.get(schema);
2710
3593
  if (!root) throw new Error("Unprocessed schema. This is a bug in Zod.");
3594
+ if (ctx.external && ctx.sharedDefsExtractedFor === ctx.external) return;
2711
3595
  const idToSchema = /* @__PURE__ */ new Map();
2712
3596
  for (const entry of ctx.seen.entries()) {
2713
3597
  const id = ctx.metadataRegistry.get(entry[0])?.id;
@@ -2727,15 +3611,16 @@ function extractDefs(ctx, schema) {
2727
3611
  entry[1].defId = id;
2728
3612
  return {
2729
3613
  defId: id,
2730
- ref: `${uriGenerator("__shared")}#/${defsSegment}/${id}`
3614
+ ref: `${uriGenerator("__shared")}#/${defsSegment}/${encodeJSONPointerSegment(id)}`
2731
3615
  };
2732
3616
  }
2733
- if (entry[1] === root) return { ref: "#" };
2734
- const defUriPrefix = `#/${defsSegment}/`;
3617
+ const uriPrefix = `#`;
3618
+ const defUriPrefix = `${uriPrefix}/${defsSegment}/`;
3619
+ if (entry[1] === root && !entry[1].schema.id) return { ref: uriPrefix };
2735
3620
  const defId = entry[1].schema.id ?? `__schema${ctx.counter++}`;
2736
3621
  return {
2737
3622
  defId,
2738
- ref: defUriPrefix + defId
3623
+ ref: defUriPrefix + encodeJSONPointerSegment(defId)
2739
3624
  };
2740
3625
  };
2741
3626
  const extractToDef = (entry) => {
@@ -2776,12 +3661,114 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
2776
3661
  continue;
2777
3662
  }
2778
3663
  if (seen.count > 1) {
2779
- if (ctx.reused === "ref") {
2780
- extractToDef(entry);
2781
- continue;
3664
+ if (ctx.reused === "ref") extractToDef(entry);
3665
+ }
3666
+ }
3667
+ if (ctx.external) ctx.sharedDefsExtractedFor = ctx.external;
3668
+ }
3669
+ /** 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. */
3670
+ function compactTypeUnion(schema) {
3671
+ const options = schema.anyOf;
3672
+ if (!Array.isArray(options) || options.length === 0 || schema.type !== void 0) return;
3673
+ const types = [];
3674
+ for (const option of options) {
3675
+ if (!option || typeof option !== "object") return;
3676
+ compactTypeUnion(option);
3677
+ const keys = Object.keys(option);
3678
+ if (keys.length !== 1 || keys[0] !== "type") return;
3679
+ const type = option.type;
3680
+ for (const member of Array.isArray(type) ? type : [type]) {
3681
+ if (typeof member !== "string") return;
3682
+ if (!types.includes(member)) types.push(member);
3683
+ }
3684
+ }
3685
+ delete schema.anyOf;
3686
+ schema.type = types.length === 1 ? types[0] : types;
3687
+ }
3688
+ /** Keywords `foldIntersection` knows how to combine. Anything else — `$ref`, `patternProperties`,
3689
+ * an annotation like `description` — makes a member unfoldable, so a constraint this does not
3690
+ * understand leaves the `allOf` alone instead of being silently dropped or misattributed. */
3691
+ const FOLDABLE_KEYS = new Set([
3692
+ "type",
3693
+ "properties",
3694
+ "required",
3695
+ "additionalProperties"
3696
+ ]);
3697
+ const UNION_KEYS = ["oneOf", "anyOf"];
3698
+ /** 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. */
3699
+ function undeclaredConstraint(member) {
3700
+ const extra = member.additionalProperties;
3701
+ if (extra === void 0 || extra === false || typeof extra !== "object" || extra === null) return null;
3702
+ return Object.keys(extra).length ? extra : null;
3703
+ }
3704
+ /** Combines object members into the single object they describe together, or returns `null` if any of them carries a keyword outside {@link FOLDABLE_KEYS}. */
3705
+ function foldObjects(members) {
3706
+ const objects = [];
3707
+ for (const member of members) {
3708
+ if (typeof member !== "object" || member.type !== "object") return null;
3709
+ for (const key in member) if (!FOLDABLE_KEYS.has(key)) return null;
3710
+ objects.push(member);
3711
+ }
3712
+ const properties = {};
3713
+ const required = /* @__PURE__ */ new Set();
3714
+ for (const object of objects) {
3715
+ for (const key in object.properties) {
3716
+ if (Object.prototype.hasOwnProperty.call(properties, key)) continue;
3717
+ const parts = [];
3718
+ for (const other of objects) {
3719
+ const part = other.properties?.[key] ?? undeclaredConstraint(other);
3720
+ if (part === null || part === void 0) continue;
3721
+ if (!parts.some((seen) => JSON.stringify(seen) === JSON.stringify(part))) parts.push(part);
2782
3722
  }
3723
+ assignProp(properties, key, parts.length === 1 ? parts[0] : foldObjects(parts) ?? { allOf: parts });
3724
+ }
3725
+ for (const key of object.required ?? []) required.add(key);
3726
+ }
3727
+ const folded = {
3728
+ type: "object",
3729
+ properties
3730
+ };
3731
+ if (required.size) folded.required = [...required];
3732
+ if (objects.every((object) => object.additionalProperties === false)) folded.additionalProperties = false;
3733
+ else {
3734
+ const constraints = [];
3735
+ for (const object of objects) {
3736
+ const constraint = undeclaredConstraint(object);
3737
+ if (constraint && !constraints.some((seen) => JSON.stringify(seen) === JSON.stringify(constraint))) constraints.push(constraint);
2783
3738
  }
3739
+ if (constraints.length === 1) folded.additionalProperties = constraints[0];
3740
+ else if (constraints.length > 1) folded.additionalProperties = { allOf: constraints };
2784
3741
  }
3742
+ return folded;
3743
+ }
3744
+ /** `additionalProperties` in an `allOf` member sees only that member's own `properties`, so two
3745
+ * closed object members reject each other's keys and the schema validates nothing. Zod's parser
3746
+ * pools the key sets instead — `handleIntersectionResults` reports a key as unrecognized only when
3747
+ * *every* side rejects it — so the emitted schema has to pool them too, and folding the members
3748
+ * into one object is the encoding that says so on every target.
3749
+ *
3750
+ * This runs from `finalize`, after `extractDefs`, which is what keeps it clear of the `$ref`
3751
+ * machinery: a member extracted into `$defs` is already a `$ref` by now and declines to fold, so it
3752
+ * keeps its reference and its own closedness rather than being inlined as a stale copy. */
3753
+ function foldIntersection(json) {
3754
+ const allOf = json.allOf;
3755
+ if (!Array.isArray(allOf) || allOf.length < 2) return;
3756
+ for (const key of FOLDABLE_KEYS) if (key in json) return;
3757
+ const unions = allOf.filter((m) => UNION_KEYS.some((k) => Array.isArray(m[k])));
3758
+ let folded = null;
3759
+ if (!unions.length) folded = foldObjects(allOf);
3760
+ else {
3761
+ const union = unions[0];
3762
+ const keyword = UNION_KEYS.find((k) => Array.isArray(union[k]));
3763
+ if (Object.keys(union).length !== 1) return;
3764
+ const rest = allOf.filter((m) => m !== union);
3765
+ const branches = union[keyword].map((branch) => foldObjects([...rest, branch]));
3766
+ if (branches.some((b) => !b)) return;
3767
+ folded = { [keyword]: branches };
3768
+ }
3769
+ if (!folded) return;
3770
+ delete json.allOf;
3771
+ assignProps(json, folded);
2785
3772
  }
2786
3773
  function finalize(ctx, schema) {
2787
3774
  const root = ctx.seen.get(schema);
@@ -2800,8 +3787,8 @@ function finalize(ctx, schema) {
2800
3787
  if (refSchema.$ref && (ctx.target === "draft-07" || ctx.target === "draft-04" || ctx.target === "openapi-3.0")) {
2801
3788
  schema.allOf = schema.allOf ?? [];
2802
3789
  schema.allOf.push(refSchema);
2803
- } else Object.assign(schema, refSchema);
2804
- Object.assign(schema, _cached);
3790
+ } else assignProps(schema, refSchema);
3791
+ assignProps(schema, _cached);
2805
3792
  if (zodSchema._zod.parent === ref) for (const key in schema) {
2806
3793
  if (key === "$ref" || key === "allOf") continue;
2807
3794
  if (!(key in _cached)) delete schema[key];
@@ -2829,7 +3816,22 @@ function finalize(ctx, schema) {
2829
3816
  path: seen.path ?? []
2830
3817
  });
2831
3818
  };
2832
- for (const entry of [...ctx.seen.entries()].reverse()) flattenRef(entry[0]);
3819
+ if (!ctx.external || ctx.sharedEmitDoneFor !== ctx.external) {
3820
+ for (const entry of [...ctx.seen.entries()].reverse()) flattenRef(entry[0]);
3821
+ if (ctx.target !== "openapi-3.0") for (const entry of ctx.seen.entries()) compactTypeUnion(entry[1].def ?? entry[1].schema);
3822
+ for (const rewrite of ctx.deferred) rewrite();
3823
+ if (ctx.intersections.length) {
3824
+ const carriers = /* @__PURE__ */ new Map();
3825
+ for (const seen of ctx.seen.values()) for (const json of [seen.schema, seen.def]) {
3826
+ const allOf = json?.allOf;
3827
+ if (!Array.isArray(allOf)) continue;
3828
+ const existing = carriers.get(allOf);
3829
+ if (existing) existing.push(json);
3830
+ else carriers.set(allOf, [json]);
3831
+ }
3832
+ for (const allOf of ctx.intersections) for (const json of carriers.get(allOf) ?? []) foldIntersection(json);
3833
+ }
3834
+ }
2833
3835
  const result = {};
2834
3836
  if (ctx.target === "draft-2020-12") result.$schema = "https://json-schema.org/draft/2020-12/schema";
2835
3837
  else if (ctx.target === "draft-07") result.$schema = "http://json-schema.org/draft-07/schema#";
@@ -2840,17 +3842,18 @@ function finalize(ctx, schema) {
2840
3842
  if (!id) throw new Error("Schema is missing an `id` property");
2841
3843
  result.$id = ctx.external.uri(id);
2842
3844
  }
2843
- Object.assign(result, root.def ?? root.schema);
3845
+ assignProps(result, root.defId ? root.schema : root.def ?? root.schema);
2844
3846
  const rootMetaId = ctx.metadataRegistry.get(schema)?.id;
2845
3847
  if (rootMetaId !== void 0 && result.id === rootMetaId) delete result.id;
2846
3848
  const defs = ctx.external?.defs ?? {};
2847
- for (const entry of ctx.seen.entries()) {
3849
+ if (!ctx.external || ctx.sharedEmitDoneFor !== ctx.external) for (const entry of ctx.seen.entries()) {
2848
3850
  const seen = entry[1];
2849
3851
  if (seen.def && seen.defId) {
2850
3852
  if (seen.def.id === seen.defId) delete seen.def.id;
2851
- defs[seen.defId] = seen.def;
3853
+ assignProp(defs, seen.defId, seen.def);
2852
3854
  }
2853
3855
  }
3856
+ if (ctx.external) ctx.sharedEmitDoneFor = ctx.external;
2854
3857
  if (ctx.external) {} else if (Object.keys(defs).length > 0) if (ctx.target === "draft-2020-12") result.$defs = defs;
2855
3858
  else result.definitions = defs;
2856
3859
  try {
@@ -2880,7 +3883,7 @@ function isTransforming(_schema, _ctx) {
2880
3883
  if (def.type === "array") return isTransforming(def.element, ctx);
2881
3884
  if (def.type === "set") return isTransforming(def.valueType, ctx);
2882
3885
  if (def.type === "lazy") return isTransforming(def.getter(), ctx);
2883
- 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);
3886
+ 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);
2884
3887
  if (def.type === "intersection") return isTransforming(def.left, ctx) || isTransforming(def.right, ctx);
2885
3888
  if (def.type === "record" || def.type === "map") return isTransforming(def.keyType, ctx) || isTransforming(def.valueType, ctx);
2886
3889
  if (def.type === "pipe") {
@@ -2911,7 +3914,7 @@ const createToJSONSchemaMethod = (schema, processors = {}) => (params) => {
2911
3914
  ...params,
2912
3915
  processors
2913
3916
  });
2914
- process(schema, ctx);
3917
+ processSchema(schema, ctx);
2915
3918
  extractDefs(ctx, schema);
2916
3919
  return finalize(ctx, schema);
2917
3920
  };
@@ -2923,12 +3926,84 @@ const createStandardJSONSchemaMethod = (schema, io, processors = {}) => (params)
2923
3926
  io,
2924
3927
  processors
2925
3928
  });
2926
- process(schema, ctx);
3929
+ processSchema(schema, ctx);
2927
3930
  extractDefs(ctx, schema);
2928
3931
  return finalize(ctx, schema);
2929
3932
  };
2930
3933
  //#endregion
2931
- //#region ../../node_modules/.pnpm/zod@4.4.3/node_modules/zod/v4/core/json-schema-processors.js
3934
+ //#region ../../node_modules/.pnpm/zod@4.6.7/node_modules/zod/v4/core/json-schema-processors.js
3935
+ const narrowMin = (agg, key, value) => {
3936
+ if (agg[key] === void 0 || value > agg[key]) agg[key] = value;
3937
+ };
3938
+ const narrowMax = (agg, key, value) => {
3939
+ if (agg[key] === void 0 || value < agg[key]) agg[key] = value;
3940
+ };
3941
+ const narrowBoth = (agg, value) => {
3942
+ narrowMin(agg, "minimum", value);
3943
+ narrowMax(agg, "maximum", value);
3944
+ };
3945
+ const addDivisor = (agg, value) => {
3946
+ agg.multipleOf ?? (agg.multipleOf = []);
3947
+ if (!agg.multipleOf.includes(value)) agg.multipleOf.push(value);
3948
+ };
3949
+ const addPattern = (agg, pattern) => {
3950
+ agg.patterns ?? (agg.patterns = /* @__PURE__ */ new Set());
3951
+ agg.patterns.add(pattern);
3952
+ };
3953
+ const intersectMime = (agg, mime) => {
3954
+ agg.mime = agg.mime ? agg.mime.filter((m) => mime.includes(m)) : [...mime];
3955
+ };
3956
+ const setFormat = (agg, format) => {
3957
+ agg.format = format;
3958
+ if (format.includes("int")) agg.isInt = true;
3959
+ };
3960
+ const minContributor = (agg, def) => narrowMin(agg, "minimum", def.minimum);
3961
+ const maxContributor = (agg, def) => narrowMax(agg, "maximum", def.maximum);
3962
+ const formatContributor = (ranges) => (agg, def) => {
3963
+ setFormat(agg, def.format);
3964
+ const [minimum, maximum] = ranges[def.format];
3965
+ narrowMin(agg, "minimum", minimum);
3966
+ narrowMax(agg, "maximum", maximum);
3967
+ };
3968
+ const contributors = {
3969
+ greater_than: (agg, def) => narrowMin(agg, def.inclusive ? "minimum" : "exclusiveMinimum", def.value),
3970
+ less_than: (agg, def) => narrowMax(agg, def.inclusive ? "maximum" : "exclusiveMaximum", def.value),
3971
+ multiple_of: (agg, def) => addDivisor(agg, def.value),
3972
+ number_format: formatContributor(NUMBER_FORMAT_RANGES),
3973
+ bigint_format: formatContributor(BIGINT_FORMAT_RANGES),
3974
+ min_length: minContributor,
3975
+ max_length: maxContributor,
3976
+ length_equals: (agg, def) => narrowBoth(agg, def.length),
3977
+ min_size: minContributor,
3978
+ max_size: maxContributor,
3979
+ size_equals: (agg, def) => narrowBoth(agg, def.size),
3980
+ string_format: (agg, def) => {
3981
+ setFormat(agg, def.format);
3982
+ if (def.pattern) addPattern(agg, def.pattern);
3983
+ if (def.format === "base64" || def.format === "base64url") agg.contentEncoding = def.format;
3984
+ if (def.local || def.precision === -1) agg.laxFormat = true;
3985
+ },
3986
+ mime_type: (agg, def) => intersectMime(agg, def.mime)
3987
+ };
3988
+ function aggregateChecks(schema) {
3989
+ const agg = {};
3990
+ const def = schema._zod.def;
3991
+ const list = schema._zod.traits.has("$ZodCheck") ? [schema, ...def.checks ?? []] : def.checks ?? [];
3992
+ for (const ch of list) contributors[ch._zod.def.check]?.(agg, ch._zod.def);
3993
+ const bag = schema._zod.bag;
3994
+ if (bag.minimum !== void 0) narrowMin(agg, "minimum", bag.minimum);
3995
+ if (bag.exclusiveMinimum !== void 0) narrowMin(agg, "exclusiveMinimum", bag.exclusiveMinimum);
3996
+ if (bag.maximum !== void 0) narrowMax(agg, "maximum", bag.maximum);
3997
+ if (bag.exclusiveMaximum !== void 0) narrowMax(agg, "exclusiveMaximum", bag.exclusiveMaximum);
3998
+ if (bag.multipleOf !== void 0) addDivisor(agg, bag.multipleOf);
3999
+ if (bag.format !== void 0) {
4000
+ agg.format ?? (agg.format = bag.format);
4001
+ if (bag.format.includes("int")) agg.isInt = true;
4002
+ }
4003
+ if (bag.mime) intersectMime(agg, bag.mime);
4004
+ for (const pattern of bag.patterns ?? []) addPattern(agg, pattern);
4005
+ return agg;
4006
+ }
2932
4007
  const formatMap = {
2933
4008
  guid: "uuid",
2934
4009
  url: "uri",
@@ -2936,32 +4011,33 @@ const formatMap = {
2936
4011
  json_string: "json-string",
2937
4012
  regex: ""
2938
4013
  };
4014
+ const exactPatterns = new Map([[base64Charset, base64], [base64urlCharset, base64url]]);
4015
+ const exactPattern = (p) => exactPatterns.get(p) ?? p;
2939
4016
  const stringProcessor = (schema, ctx, _json, _params) => {
2940
4017
  const json = _json;
2941
4018
  json.type = "string";
2942
- const { minimum, maximum, format, patterns, contentEncoding } = schema._zod.bag;
4019
+ const { minimum, maximum, format, patterns, contentEncoding, laxFormat } = aggregateChecks(schema);
2943
4020
  if (typeof minimum === "number") json.minLength = minimum;
2944
4021
  if (typeof maximum === "number") json.maxLength = maximum;
2945
4022
  if (format) {
2946
4023
  json.format = formatMap[format] ?? format;
2947
4024
  if (json.format === "") delete json.format;
2948
- if (format === "time") delete json.format;
4025
+ if (format === "time" || laxFormat) delete json.format;
2949
4026
  }
2950
4027
  if (contentEncoding) json.contentEncoding = contentEncoding;
2951
4028
  if (patterns && patterns.size > 0) {
2952
- const regexes = [...patterns];
2953
- if (regexes.length === 1) json.pattern = regexes[0].source;
2954
- else if (regexes.length > 1) json.allOf = [...regexes.map((regex) => ({
4029
+ const patternList = [...patterns].map(exactPattern);
4030
+ if (patternList.length === 1) json.pattern = patternList[0].source;
4031
+ else if (patternList.length > 1) json.allOf = [...patternList.map((regex) => ({
2955
4032
  ...ctx.target === "draft-07" || ctx.target === "draft-04" || ctx.target === "openapi-3.0" ? { type: "string" } : {},
2956
4033
  pattern: regex.source
2957
4034
  }))];
2958
4035
  }
2959
4036
  };
2960
- const numberProcessor = (schema, ctx, _json, _params) => {
4037
+ const numberProcessor = (schema, ctx, _json, params) => {
2961
4038
  const json = _json;
2962
- const { minimum, maximum, format, multipleOf, exclusiveMaximum, exclusiveMinimum } = schema._zod.bag;
2963
- if (typeof format === "string" && format.includes("int")) json.type = "integer";
2964
- else json.type = "number";
4039
+ const { minimum, maximum, multipleOf, exclusiveMaximum, exclusiveMinimum, isInt } = aggregateChecks(schema);
4040
+ json.type = isInt ? "integer" : "number";
2965
4041
  const exMin = typeof exclusiveMinimum === "number" && exclusiveMinimum >= (minimum ?? Number.NEGATIVE_INFINITY);
2966
4042
  const exMax = typeof exclusiveMaximum === "number" && exclusiveMaximum <= (maximum ?? Number.POSITIVE_INFINITY);
2967
4043
  const legacy = ctx.target === "draft-04" || ctx.target === "openapi-3.0";
@@ -2975,7 +4051,14 @@ const numberProcessor = (schema, ctx, _json, _params) => {
2975
4051
  json.exclusiveMaximum = true;
2976
4052
  } else json.exclusiveMaximum = exclusiveMaximum;
2977
4053
  else if (typeof maximum === "number") json.maximum = maximum;
2978
- if (typeof multipleOf === "number") json.multipleOf = multipleOf;
4054
+ if (multipleOf) {
4055
+ const divisors = /* @__PURE__ */ new Set();
4056
+ for (const divisor of multipleOf) if (Number.isFinite(divisor) && divisor !== 0) divisors.add(Math.abs(divisor));
4057
+ else handleUnrepresentable(schema, ctx, json, params, `A multipleOf divisor of ${divisor} cannot be represented in JSON Schema`);
4058
+ const [first, ...rest] = divisors;
4059
+ if (first !== void 0) json.multipleOf = first;
4060
+ if (rest.length) json.allOf = [...json.allOf ?? [], ...rest.map((m) => ({ multipleOf: m }))];
4061
+ }
2979
4062
  };
2980
4063
  const neverProcessor = (_schema, _ctx, json, _params) => {
2981
4064
  json.not = {};
@@ -2983,53 +4066,63 @@ const neverProcessor = (_schema, _ctx, json, _params) => {
2983
4066
  const enumProcessor = (schema, _ctx, json, _params) => {
2984
4067
  const def = schema._zod.def;
2985
4068
  const values = getEnumValues(def.entries);
4069
+ if (values.length === 0) {
4070
+ json.not = {};
4071
+ return;
4072
+ }
2986
4073
  if (values.every((v) => typeof v === "number")) json.type = "number";
2987
4074
  if (values.every((v) => typeof v === "string")) json.type = "string";
2988
4075
  json.enum = values;
2989
4076
  };
2990
- const customProcessor = (_schema, ctx, _json, _params) => {
2991
- if (ctx.unrepresentable === "throw") throw new Error("Custom types cannot be represented in JSON Schema");
4077
+ const customProcessor = (schema, ctx, json, params) => {
4078
+ handleUnrepresentable(schema, ctx, json, params, "Custom types cannot be represented in JSON Schema");
2992
4079
  };
2993
- const transformProcessor = (_schema, ctx, _json, _params) => {
2994
- if (ctx.unrepresentable === "throw") throw new Error("Transforms cannot be represented in JSON Schema");
4080
+ const transformProcessor = (schema, ctx, json, params) => {
4081
+ handleUnrepresentable(schema, ctx, json, params, "Transforms cannot be represented in JSON Schema");
2995
4082
  };
2996
4083
  const arrayProcessor = (schema, ctx, _json, params) => {
2997
4084
  const json = _json;
2998
4085
  const def = schema._zod.def;
2999
- const { minimum, maximum } = schema._zod.bag;
4086
+ const { minimum, maximum } = aggregateChecks(schema);
3000
4087
  if (typeof minimum === "number") json.minItems = minimum;
3001
4088
  if (typeof maximum === "number") json.maxItems = maximum;
3002
4089
  json.type = "array";
3003
- json.items = process(def.element, ctx, {
4090
+ json.items = processSchema(def.element, ctx, {
3004
4091
  ...params,
3005
4092
  path: [...params.path, "items"]
3006
4093
  });
3007
4094
  };
4095
+ function inputOptin(schema) {
4096
+ const def = schema._zod.def;
4097
+ if (def.type === "pipe" && def.in._zod.traits.has("$ZodTransform")) return inputOptin(def.out);
4098
+ if (def.type === "catch") return inputOptin(def.innerType);
4099
+ return schema._zod.optin;
4100
+ }
3008
4101
  const objectProcessor = (schema, ctx, _json, params) => {
3009
4102
  const json = _json;
3010
4103
  const def = schema._zod.def;
4104
+ const shape = def.shape;
4105
+ if (Object.getOwnPropertySymbols(shape).length && handleUnrepresentable(schema, ctx, json, params, "Symbol keys cannot be represented in JSON Schema")) return;
3011
4106
  json.type = "object";
3012
4107
  json.properties = {};
3013
- const shape = def.shape;
3014
- for (const key in shape) json.properties[key] = process(shape[key], ctx, {
4108
+ for (const key in shape) assignProp(json.properties, key, processSchema(shape[key], ctx, {
3015
4109
  ...params,
3016
4110
  path: [
3017
4111
  ...params.path,
3018
4112
  "properties",
3019
4113
  key
3020
4114
  ]
3021
- });
3022
- const allKeys = new Set(Object.keys(shape));
3023
- const requiredKeys = new Set([...allKeys].filter((key) => {
3024
- const v = def.shape[key]._zod;
3025
- if (ctx.io === "input") return v.optin === void 0;
3026
- else return v.optout === void 0;
3027
4115
  }));
3028
- if (requiredKeys.size > 0) json.required = Array.from(requiredKeys);
4116
+ const requiredKeys = [];
4117
+ for (const key of Object.keys(shape)) {
4118
+ const field = def.shape[key];
4119
+ if (ctx.io === "input" ? inputOptin(field) === void 0 : field._zod.optout === void 0) requiredKeys.push(key);
4120
+ }
4121
+ if (requiredKeys.length > 0) json.required = requiredKeys;
3029
4122
  if (def.catchall?._zod.def.type === "never") json.additionalProperties = false;
3030
4123
  else if (!def.catchall) {
3031
4124
  if (ctx.io === "output") json.additionalProperties = false;
3032
- } else if (def.catchall) json.additionalProperties = process(def.catchall, ctx, {
4125
+ } else if (def.catchall) json.additionalProperties = processSchema(def.catchall, ctx, {
3033
4126
  ...params,
3034
4127
  path: [...params.path, "additionalProperties"]
3035
4128
  });
@@ -3037,7 +4130,7 @@ const objectProcessor = (schema, ctx, _json, params) => {
3037
4130
  const unionProcessor = (schema, ctx, json, params) => {
3038
4131
  const def = schema._zod.def;
3039
4132
  const isExclusive = def.inclusive === false;
3040
- const options = def.options.map((x, i) => process(x, ctx, {
4133
+ const options = def.options.map((x, i) => processSchema(x, ctx, {
3041
4134
  ...params,
3042
4135
  path: [
3043
4136
  ...params.path,
@@ -3050,7 +4143,7 @@ const unionProcessor = (schema, ctx, json, params) => {
3050
4143
  };
3051
4144
  const intersectionProcessor = (schema, ctx, json, params) => {
3052
4145
  const def = schema._zod.def;
3053
- const a = process(def.left, ctx, {
4146
+ const a = processSchema(def.left, ctx, {
3054
4147
  ...params,
3055
4148
  path: [
3056
4149
  ...params.path,
@@ -3058,7 +4151,7 @@ const intersectionProcessor = (schema, ctx, json, params) => {
3058
4151
  0
3059
4152
  ]
3060
4153
  });
3061
- const b = process(def.right, ctx, {
4154
+ const b = processSchema(def.right, ctx, {
3062
4155
  ...params,
3063
4156
  path: [
3064
4157
  ...params.path,
@@ -3067,11 +4160,13 @@ const intersectionProcessor = (schema, ctx, json, params) => {
3067
4160
  ]
3068
4161
  });
3069
4162
  const isSimpleIntersection = (val) => "allOf" in val && Object.keys(val).length === 1;
3070
- json.allOf = [...isSimpleIntersection(a) ? a.allOf : [a], ...isSimpleIntersection(b) ? b.allOf : [b]];
4163
+ const allOf = [...isSimpleIntersection(a) ? a.allOf : [a], ...isSimpleIntersection(b) ? b.allOf : [b]];
4164
+ json.allOf = allOf;
4165
+ ctx.intersections.push(allOf);
3071
4166
  };
3072
4167
  const nullableProcessor = (schema, ctx, json, params) => {
3073
4168
  const def = schema._zod.def;
3074
- const inner = process(def.innerType, ctx, params);
4169
+ const inner = processSchema(def.innerType, ctx, params);
3075
4170
  const seen = ctx.seen.get(schema);
3076
4171
  if (ctx.target === "openapi-3.0") {
3077
4172
  seen.ref = def.innerType;
@@ -3080,34 +4175,53 @@ const nullableProcessor = (schema, ctx, json, params) => {
3080
4175
  };
3081
4176
  const nonoptionalProcessor = (schema, ctx, _json, params) => {
3082
4177
  const def = schema._zod.def;
3083
- process(def.innerType, ctx, params);
4178
+ processSchema(def.innerType, ctx, params);
3084
4179
  const seen = ctx.seen.get(schema);
3085
4180
  seen.ref = def.innerType;
3086
4181
  };
4182
+ /** Round-trips a default value through JSON so the emitted schema is guaranteed to be valid JSON.
4183
+ * A BigInt has no reliable encoding, so it goes through `unrepresentable` like any other
4184
+ * unrepresentable value. Returns a sentinel when the caller must not write a default of its own. */
4185
+ const UNREPRESENTABLE_DEFAULT = Symbol();
4186
+ function serializeDefaultValue(value, schema, ctx, json, params) {
4187
+ let unrepresentable = false;
4188
+ const serialized = JSON.stringify(value, (_, val) => {
4189
+ if (typeof val !== "bigint") return val;
4190
+ unrepresentable = true;
4191
+ return null;
4192
+ });
4193
+ if (!unrepresentable) return JSON.parse(serialized);
4194
+ handleUnrepresentable(schema, ctx, json, params, "BigInt defaults cannot be represented in JSON Schema");
4195
+ return UNREPRESENTABLE_DEFAULT;
4196
+ }
3087
4197
  const defaultProcessor = (schema, ctx, json, params) => {
3088
4198
  const def = schema._zod.def;
3089
- process(def.innerType, ctx, params);
4199
+ processSchema(def.innerType, ctx, params);
3090
4200
  const seen = ctx.seen.get(schema);
3091
4201
  seen.ref = def.innerType;
3092
- json.default = JSON.parse(JSON.stringify(def.defaultValue));
4202
+ const value = serializeDefaultValue(def.defaultValue, schema, ctx, json, params);
4203
+ if (value !== UNREPRESENTABLE_DEFAULT) json.default = value;
3093
4204
  };
3094
4205
  const prefaultProcessor = (schema, ctx, json, params) => {
3095
4206
  const def = schema._zod.def;
3096
- process(def.innerType, ctx, params);
4207
+ processSchema(def.innerType, ctx, params);
3097
4208
  const seen = ctx.seen.get(schema);
3098
4209
  seen.ref = def.innerType;
3099
- if (ctx.io === "input") json._prefault = JSON.parse(JSON.stringify(def.defaultValue));
4210
+ if (ctx.io !== "input") return;
4211
+ const value = serializeDefaultValue(def.defaultValue, schema, ctx, json, params);
4212
+ if (value !== UNREPRESENTABLE_DEFAULT) json._prefault = value;
3100
4213
  };
3101
4214
  const catchProcessor = (schema, ctx, json, params) => {
3102
4215
  const def = schema._zod.def;
3103
- process(def.innerType, ctx, params);
4216
+ processSchema(def.innerType, ctx, params);
3104
4217
  const seen = ctx.seen.get(schema);
3105
4218
  seen.ref = def.innerType;
3106
4219
  let catchValue;
3107
4220
  try {
3108
4221
  catchValue = def.catchValue(void 0);
3109
4222
  } catch {
3110
- throw new Error("Dynamic catch values are not supported in JSON Schema");
4223
+ handleUnrepresentable(schema, ctx, json, params, "Dynamic catch values are not supported in JSON Schema");
4224
+ return;
3111
4225
  }
3112
4226
  json.default = catchValue;
3113
4227
  };
@@ -3115,77 +4229,75 @@ const pipeProcessor = (schema, ctx, _json, params) => {
3115
4229
  const def = schema._zod.def;
3116
4230
  const inIsTransform = def.in._zod.traits.has("$ZodTransform");
3117
4231
  const innerType = ctx.io === "input" ? inIsTransform ? def.out : def.in : def.out;
3118
- process(innerType, ctx, params);
4232
+ processSchema(innerType, ctx, params);
3119
4233
  const seen = ctx.seen.get(schema);
3120
4234
  seen.ref = innerType;
3121
4235
  };
3122
4236
  const readonlyProcessor = (schema, ctx, json, params) => {
3123
4237
  const def = schema._zod.def;
3124
- process(def.innerType, ctx, params);
4238
+ processSchema(def.innerType, ctx, params);
3125
4239
  const seen = ctx.seen.get(schema);
3126
4240
  seen.ref = def.innerType;
3127
4241
  json.readOnly = true;
3128
4242
  };
3129
4243
  const optionalProcessor = (schema, ctx, _json, params) => {
3130
4244
  const def = schema._zod.def;
3131
- process(def.innerType, ctx, params);
4245
+ processSchema(def.innerType, ctx, params);
3132
4246
  const seen = ctx.seen.get(schema);
3133
4247
  seen.ref = def.innerType;
3134
4248
  };
3135
4249
  //#endregion
3136
- //#region ../../node_modules/.pnpm/zod@4.4.3/node_modules/zod/v4/classic/iso.js
3137
- const ZodISODateTime = /*@__PURE__*/ $constructor("ZodISODateTime", (inst, def) => {
3138
- $ZodISODateTime.init(inst, def);
3139
- ZodStringFormat.init(inst, def);
3140
- });
3141
- function datetime(params) {
3142
- return /* @__PURE__ */ _isoDateTime(ZodISODateTime, params);
3143
- }
3144
- const ZodISODate = /*@__PURE__*/ $constructor("ZodISODate", (inst, def) => {
3145
- $ZodISODate.init(inst, def);
3146
- ZodStringFormat.init(inst, def);
3147
- });
3148
- function date(params) {
3149
- return /* @__PURE__ */ _isoDate(ZodISODate, params);
3150
- }
3151
- const ZodISOTime = /*@__PURE__*/ $constructor("ZodISOTime", (inst, def) => {
3152
- $ZodISOTime.init(inst, def);
3153
- ZodStringFormat.init(inst, def);
3154
- });
3155
- function time(params) {
3156
- return /* @__PURE__ */ _isoTime(ZodISOTime, params);
3157
- }
3158
- const ZodISODuration = /*@__PURE__*/ $constructor("ZodISODuration", (inst, def) => {
3159
- $ZodISODuration.init(inst, def);
3160
- ZodStringFormat.init(inst, def);
3161
- });
3162
- function duration(params) {
3163
- return /* @__PURE__ */ _isoDuration(ZodISODuration, params);
4250
+ //#region ../../node_modules/.pnpm/zod@4.6.7/node_modules/zod/v4/classic/errors.js
4251
+ const _installedErrorProtos = /* @__PURE__ */ new WeakSet([Object.prototype, Error.prototype]);
4252
+ function _lazyMethod(proto, key, make) {
4253
+ Object.defineProperty(proto, key, {
4254
+ configurable: true,
4255
+ enumerable: false,
4256
+ get() {
4257
+ const value = make(this);
4258
+ Object.defineProperty(this, key, {
4259
+ value,
4260
+ configurable: true,
4261
+ writable: true
4262
+ });
4263
+ return value;
4264
+ },
4265
+ set(value) {
4266
+ Object.defineProperty(this, key, {
4267
+ value,
4268
+ configurable: true,
4269
+ writable: true
4270
+ });
4271
+ }
4272
+ });
3164
4273
  }
3165
- //#endregion
3166
- //#region ../../node_modules/.pnpm/zod@4.4.3/node_modules/zod/v4/classic/errors.js
3167
4274
  const initializer = (inst, issues) => {
3168
4275
  $ZodError.init(inst, issues);
3169
4276
  inst.name = "ZodError";
3170
- Object.defineProperties(inst, {
3171
- format: { value: (mapper) => formatError(inst, mapper) },
3172
- flatten: { value: (mapper) => flattenError(inst, mapper) },
3173
- addIssue: { value: (issue) => {
3174
- inst.issues.push(issue);
3175
- inst.message = JSON.stringify(inst.issues, jsonStringifyReplacer, 2);
3176
- } },
3177
- addIssues: { value: (issues) => {
3178
- inst.issues.push(...issues);
3179
- inst.message = JSON.stringify(inst.issues, jsonStringifyReplacer, 2);
3180
- } },
3181
- isEmpty: { get() {
3182
- return inst.issues.length === 0;
3183
- } }
4277
+ const proto = Object.getPrototypeOf(inst);
4278
+ if (_installedErrorProtos.has(proto)) return;
4279
+ _installedErrorProtos.add(proto);
4280
+ _lazyMethod(proto, "format", (self) => (mapper) => formatError(self, mapper));
4281
+ _lazyMethod(proto, "flatten", (self) => (mapper) => flattenError(self, mapper));
4282
+ _lazyMethod(proto, "addIssue", (self) => (issue) => {
4283
+ self.issues.push(issue);
4284
+ self.message = JSON.stringify(self.issues, jsonStringifyReplacer, 2);
4285
+ });
4286
+ _lazyMethod(proto, "addIssues", (self) => (issues) => {
4287
+ self.issues.push(...issues);
4288
+ self.message = JSON.stringify(self.issues, jsonStringifyReplacer, 2);
4289
+ });
4290
+ Object.defineProperty(proto, "isEmpty", {
4291
+ configurable: true,
4292
+ enumerable: false,
4293
+ get() {
4294
+ return this.issues.length === 0;
4295
+ }
3184
4296
  });
3185
4297
  };
3186
- const ZodRealError = /*@__PURE__*/ $constructor("ZodError", initializer, { Parent: Error });
4298
+ const ZodRealError = /*@__PURE__*/ $constructor("ZodError", initializer, void 0, { Parent: Error });
3187
4299
  //#endregion
3188
- //#region ../../node_modules/.pnpm/zod@4.4.3/node_modules/zod/v4/classic/parse.js
4300
+ //#region ../../node_modules/.pnpm/zod@4.6.7/node_modules/zod/v4/classic/parse.js
3189
4301
  const parse = /* @__PURE__ */ _parse(ZodRealError);
3190
4302
  const parseAsync = /* @__PURE__ */ _parseAsync(ZodRealError);
3191
4303
  const safeParse = /* @__PURE__ */ _safeParse(ZodRealError);
@@ -3199,255 +4311,320 @@ const safeDecode = /* @__PURE__ */ _safeDecode(ZodRealError);
3199
4311
  const safeEncodeAsync = /* @__PURE__ */ _safeEncodeAsync(ZodRealError);
3200
4312
  const safeDecodeAsync = /* @__PURE__ */ _safeDecodeAsync(ZodRealError);
3201
4313
  //#endregion
3202
- //#region ../../node_modules/.pnpm/zod@4.4.3/node_modules/zod/v4/classic/schemas.js
3203
- const _installedGroups = /* @__PURE__ */ new WeakMap();
3204
- function _installLazyMethods(inst, group, methods) {
3205
- const proto = Object.getPrototypeOf(inst);
3206
- let installed = _installedGroups.get(proto);
3207
- if (!installed) {
3208
- installed = /* @__PURE__ */ new Set();
3209
- _installedGroups.set(proto, installed);
3210
- }
3211
- if (installed.has(group)) return;
3212
- installed.add(group);
3213
- for (const key in methods) {
3214
- const fn = methods[key];
3215
- Object.defineProperty(proto, key, {
3216
- configurable: true,
3217
- enumerable: false,
3218
- get() {
3219
- const bound = fn.bind(this);
3220
- Object.defineProperty(this, key, {
3221
- configurable: true,
3222
- writable: true,
3223
- enumerable: true,
3224
- value: bound
3225
- });
3226
- return bound;
3227
- },
3228
- set(v) {
3229
- Object.defineProperty(this, key, {
3230
- configurable: true,
3231
- writable: true,
3232
- enumerable: true,
3233
- value: v
3234
- });
3235
- }
3236
- });
3237
- }
4314
+ //#region ../../node_modules/.pnpm/zod@4.6.7/node_modules/zod/v4/classic/schemas.js
4315
+ function _ensureDefaultLocale() {
4316
+ if (!globalConfig.localeError) config(en_default());
4317
+ }
4318
+ function _ensureDefaultMemoizer() {
4319
+ if (!globalConfig.memoizer) config({ memoizer: memoizer() });
3238
4320
  }
3239
4321
  const ZodType = /*@__PURE__*/ $constructor("ZodType", (inst, def) => {
4322
+ _ensureDefaultLocale();
3240
4323
  $ZodType.init(inst, def);
3241
- Object.assign(inst["~standard"], { jsonSchema: {
3242
- input: createStandardJSONSchemaMethod(inst, "input"),
3243
- output: createStandardJSONSchemaMethod(inst, "output")
3244
- } });
3245
- inst.toJSONSchema = createToJSONSchemaMethod(inst, {});
3246
4324
  inst.def = def;
3247
4325
  inst.type = def.type;
3248
- Object.defineProperty(inst, "_def", { value: def });
3249
- inst.parse = (data, params) => parse(inst, data, params, { callee: inst.parse });
3250
- inst.safeParse = (data, params) => safeParse(inst, data, params);
3251
- inst.parseAsync = async (data, params) => parseAsync(inst, data, params, { callee: inst.parseAsync });
3252
- inst.safeParseAsync = async (data, params) => safeParseAsync(inst, data, params);
3253
- inst.spa = inst.safeParseAsync;
3254
- inst.encode = (data, params) => encode(inst, data, params);
3255
- inst.decode = (data, params) => decode(inst, data, params);
3256
- inst.encodeAsync = async (data, params) => encodeAsync(inst, data, params);
3257
- inst.decodeAsync = async (data, params) => decodeAsync(inst, data, params);
3258
- inst.safeEncode = (data, params) => safeEncode(inst, data, params);
3259
- inst.safeDecode = (data, params) => safeDecode(inst, data, params);
3260
- inst.safeEncodeAsync = async (data, params) => safeEncodeAsync(inst, data, params);
3261
- inst.safeDecodeAsync = async (data, params) => safeDecodeAsync(inst, data, params);
3262
- _installLazyMethods(inst, "ZodType", {
3263
- check(...chks) {
3264
- const def = this.def;
3265
- return this.clone(mergeDefs(def, { checks: [...def.checks ?? [], ...chks.map((ch) => typeof ch === "function" ? { _zod: {
3266
- check: ch,
3267
- def: { check: "custom" },
3268
- onattach: []
3269
- } } : ch)] }), { parent: true });
3270
- },
3271
- with(...chks) {
3272
- return this.check(...chks);
3273
- },
3274
- clone(def, params) {
3275
- return clone(this, def, params);
3276
- },
3277
- brand() {
3278
- return this;
3279
- },
3280
- register(reg, meta) {
3281
- reg.add(this, meta);
3282
- return this;
3283
- },
3284
- refine(check, params) {
3285
- return this.check(refine(check, params));
3286
- },
3287
- superRefine(refinement, params) {
3288
- return this.check(superRefine(refinement, params));
3289
- },
3290
- overwrite(fn) {
3291
- return this.check(/* @__PURE__ */ _overwrite(fn));
3292
- },
3293
- optional() {
3294
- return optional(this);
3295
- },
3296
- exactOptional() {
3297
- return exactOptional(this);
3298
- },
3299
- nullable() {
3300
- return nullable(this);
3301
- },
3302
- nullish() {
3303
- return optional(nullable(this));
3304
- },
3305
- nonoptional(params) {
3306
- return nonoptional(this, params);
3307
- },
3308
- array() {
3309
- return array(this);
3310
- },
3311
- or(arg) {
3312
- return union([this, arg]);
3313
- },
3314
- and(arg) {
3315
- return intersection(this, arg);
3316
- },
3317
- transform(tx) {
3318
- return pipe(this, transform(tx));
3319
- },
3320
- default(d) {
3321
- return _default(this, d);
3322
- },
3323
- prefault(d) {
3324
- return prefault(this, d);
3325
- },
3326
- catch(params) {
3327
- return _catch(this, params);
3328
- },
3329
- pipe(target) {
3330
- return pipe(this, target);
3331
- },
3332
- readonly() {
3333
- return readonly(this);
3334
- },
3335
- describe(description) {
3336
- const cl = this.clone();
3337
- globalRegistry.add(cl, { description });
3338
- return cl;
3339
- },
3340
- meta(...args) {
3341
- if (args.length === 0) return globalRegistry.get(this);
3342
- const cl = this.clone();
3343
- globalRegistry.add(cl, args[0]);
3344
- return cl;
3345
- },
3346
- isOptional() {
3347
- return this.safeParse(void 0).success;
3348
- },
3349
- isNullable() {
3350
- return this.safeParse(null).success;
3351
- },
3352
- apply(fn) {
3353
- return fn(this);
3354
- }
3355
- });
3356
- Object.defineProperty(inst, "description", {
3357
- get() {
3358
- return globalRegistry.get(inst)?.description;
3359
- },
3360
- configurable: true
3361
- });
3362
4326
  return inst;
4327
+ }, {
4328
+ check(...chks) {
4329
+ const def = this.def;
4330
+ return this.clone(mergeDefs(def, { checks: [...def.checks ?? [], ...chks.map((ch) => typeof ch === "function" ? { _zod: {
4331
+ check: ch,
4332
+ def: { check: "custom" },
4333
+ onattach: []
4334
+ } } : ch)] }), { parent: true });
4335
+ },
4336
+ with(...chks) {
4337
+ return this.check(...chks);
4338
+ },
4339
+ clone(def, params) {
4340
+ return clone(this, def, params);
4341
+ },
4342
+ brand() {
4343
+ return this;
4344
+ },
4345
+ register(reg, meta) {
4346
+ reg.add(this, meta);
4347
+ return this;
4348
+ },
4349
+ refine(check, params) {
4350
+ return this.check(refine(check, params));
4351
+ },
4352
+ superRefine(refinement, params) {
4353
+ return this.check(superRefine(refinement, params));
4354
+ },
4355
+ overwrite(fn) {
4356
+ return this.check(/* @__PURE__ */ _overwrite(fn));
4357
+ },
4358
+ optional() {
4359
+ return optional(this);
4360
+ },
4361
+ exactOptional() {
4362
+ return exactOptional(this);
4363
+ },
4364
+ nullable() {
4365
+ return nullable(this);
4366
+ },
4367
+ nullish() {
4368
+ return optional(nullable(this));
4369
+ },
4370
+ nonoptional(params) {
4371
+ return nonoptional(this, params);
4372
+ },
4373
+ array() {
4374
+ return array(this);
4375
+ },
4376
+ or(arg) {
4377
+ return union([this, arg]);
4378
+ },
4379
+ and(arg) {
4380
+ return intersection(this, arg);
4381
+ },
4382
+ transform(tx) {
4383
+ return pipe(this, transform(tx));
4384
+ },
4385
+ default(d) {
4386
+ return _default(this, d);
4387
+ },
4388
+ prefault(d) {
4389
+ return prefault(this, d);
4390
+ },
4391
+ catch(params) {
4392
+ return _catch(this, params);
4393
+ },
4394
+ pipe(target) {
4395
+ return pipe(this, target);
4396
+ },
4397
+ readonly() {
4398
+ return readonly(this);
4399
+ },
4400
+ describe(description) {
4401
+ const cl = this.clone();
4402
+ globalRegistry.add(cl, { description });
4403
+ return cl;
4404
+ },
4405
+ meta(...args) {
4406
+ if (args.length === 0) return globalRegistry.get(this);
4407
+ const cl = this.clone();
4408
+ globalRegistry.add(cl, args[0]);
4409
+ return cl;
4410
+ },
4411
+ isOptional() {
4412
+ return this.safeParse(void 0).success;
4413
+ },
4414
+ isNullable() {
4415
+ return this.safeParse(null).success;
4416
+ },
4417
+ apply(fn, ...args) {
4418
+ return args.length === 0 ? fn(this) : fn(this, ...args);
4419
+ },
4420
+ get "~standard"() {
4421
+ return hide(this, "~standard", {
4422
+ ...standardProps(this),
4423
+ jsonSchema: {
4424
+ input: createStandardJSONSchemaMethod(this, "input"),
4425
+ output: createStandardJSONSchemaMethod(this, "output")
4426
+ }
4427
+ });
4428
+ },
4429
+ set "~standard"(value) {
4430
+ own(this, "~standard", value);
4431
+ },
4432
+ parse: function _parse(data, params) {
4433
+ return parse(this, data, params, { callee: _parse });
4434
+ },
4435
+ parseAsync: async function _parseAsync(data, params) {
4436
+ return await parseAsync(this, data, params, { callee: _parseAsync });
4437
+ },
4438
+ safeParse(data, params) {
4439
+ return safeParse(this, data, params);
4440
+ },
4441
+ async safeParseAsync(data, params) {
4442
+ return safeParseAsync(this, data, params);
4443
+ },
4444
+ get spa() {
4445
+ return this?.safeParseAsync;
4446
+ },
4447
+ set spa(value) {
4448
+ own(this, "spa", value);
4449
+ },
4450
+ validate(data, params) {
4451
+ return validate(this, data, params);
4452
+ },
4453
+ validateAsync(data, params) {
4454
+ return validateAsync$1(this, data, params);
4455
+ },
4456
+ encode: function _encode(data, params) {
4457
+ return encode(this, data, params, { callee: _encode });
4458
+ },
4459
+ decode: function _decode(data, params) {
4460
+ return decode(this, data, params, { callee: _decode });
4461
+ },
4462
+ encodeAsync: async function _encodeAsync(data, params) {
4463
+ return await encodeAsync(this, data, params, { callee: _encodeAsync });
4464
+ },
4465
+ decodeAsync: async function _decodeAsync(data, params) {
4466
+ return await decodeAsync(this, data, params, { callee: _decodeAsync });
4467
+ },
4468
+ safeEncode(data, params) {
4469
+ return safeEncode(this, data, params);
4470
+ },
4471
+ safeDecode(data, params) {
4472
+ return safeDecode(this, data, params);
4473
+ },
4474
+ async safeEncodeAsync(data, params) {
4475
+ return safeEncodeAsync(this, data, params);
4476
+ },
4477
+ async safeDecodeAsync(data, params) {
4478
+ return safeDecodeAsync(this, data, params);
4479
+ },
4480
+ toJSONSchema(params) {
4481
+ return createToJSONSchemaMethod(this, {})(params);
4482
+ },
4483
+ get description() {
4484
+ return globalRegistry.get(this)?.description;
4485
+ },
4486
+ get _def() {
4487
+ return this._zod.def;
4488
+ }
3363
4489
  });
3364
4490
  /** @internal */
3365
4491
  const _ZodString = /*@__PURE__*/ $constructor("_ZodString", (inst, def) => {
3366
4492
  $ZodString.init(inst, def);
3367
4493
  ZodType.init(inst, def);
3368
4494
  inst._zod.processJSONSchema = (ctx, json, params) => stringProcessor(inst, ctx, json, params);
3369
- const bag = inst._zod.bag;
3370
- inst.format = bag.format ?? null;
3371
- inst.minLength = bag.minimum ?? null;
3372
- inst.maxLength = bag.maximum ?? null;
3373
- _installLazyMethods(inst, "_ZodString", {
3374
- regex(...args) {
3375
- return this.check(/* @__PURE__ */ _regex(...args));
3376
- },
3377
- includes(...args) {
3378
- return this.check(/* @__PURE__ */ _includes(...args));
3379
- },
3380
- startsWith(...args) {
3381
- return this.check(/* @__PURE__ */ _startsWith(...args));
3382
- },
3383
- endsWith(...args) {
3384
- return this.check(/* @__PURE__ */ _endsWith(...args));
3385
- },
3386
- min(...args) {
3387
- return this.check(/* @__PURE__ */ _minLength(...args));
3388
- },
3389
- max(...args) {
3390
- return this.check(/* @__PURE__ */ _maxLength(...args));
3391
- },
3392
- length(...args) {
3393
- return this.check(/* @__PURE__ */ _length(...args));
3394
- },
3395
- nonempty(...args) {
3396
- return this.check(/* @__PURE__ */ _minLength(1, ...args));
3397
- },
3398
- lowercase(params) {
3399
- return this.check(/* @__PURE__ */ _lowercase(params));
3400
- },
3401
- uppercase(params) {
3402
- return this.check(/* @__PURE__ */ _uppercase(params));
3403
- },
3404
- trim() {
3405
- return this.check(/* @__PURE__ */ _trim());
3406
- },
3407
- normalize(...args) {
3408
- return this.check(/* @__PURE__ */ _normalize(...args));
3409
- },
3410
- toLowerCase() {
3411
- return this.check(/* @__PURE__ */ _toLowerCase());
3412
- },
3413
- toUpperCase() {
3414
- return this.check(/* @__PURE__ */ _toUpperCase());
3415
- },
3416
- slugify() {
3417
- return this.check(/* @__PURE__ */ _slugify());
3418
- }
3419
- });
3420
- });
4495
+ }, /*@__PURE__*/ derived({
4496
+ format: (inst) => aggregateChecks(inst).format ?? null,
4497
+ minLength: (inst) => aggregateChecks(inst).minimum ?? null,
4498
+ maxLength: (inst) => aggregateChecks(inst).maximum ?? null
4499
+ }, {
4500
+ regex(...args) {
4501
+ return this.check(/* @__PURE__ */ _regex(...args));
4502
+ },
4503
+ includes(...args) {
4504
+ return this.check(/* @__PURE__ */ _includes(...args));
4505
+ },
4506
+ startsWith(...args) {
4507
+ return this.check(/* @__PURE__ */ _startsWith(...args));
4508
+ },
4509
+ endsWith(...args) {
4510
+ return this.check(/* @__PURE__ */ _endsWith(...args));
4511
+ },
4512
+ min(...args) {
4513
+ return this.check(/* @__PURE__ */ _minLength(...args));
4514
+ },
4515
+ max(...args) {
4516
+ return this.check(/* @__PURE__ */ _maxLength(...args));
4517
+ },
4518
+ length(...args) {
4519
+ return this.check(/* @__PURE__ */ _length(...args));
4520
+ },
4521
+ nonempty(...args) {
4522
+ return this.check(/* @__PURE__ */ _minLength(1, ...args));
4523
+ },
4524
+ lowercase(params) {
4525
+ return this.check(/* @__PURE__ */ _lowercase(params));
4526
+ },
4527
+ uppercase(params) {
4528
+ return this.check(/* @__PURE__ */ _uppercase(params));
4529
+ },
4530
+ trim() {
4531
+ return this.check(/* @__PURE__ */ _trim());
4532
+ },
4533
+ normalize(...args) {
4534
+ return this.check(/* @__PURE__ */ _normalize(...args));
4535
+ },
4536
+ toLowerCase() {
4537
+ return this.check(/* @__PURE__ */ _toLowerCase());
4538
+ },
4539
+ toUpperCase() {
4540
+ return this.check(/* @__PURE__ */ _toUpperCase());
4541
+ },
4542
+ slugify() {
4543
+ return this.check(/* @__PURE__ */ _slugify());
4544
+ }
4545
+ }));
3421
4546
  const ZodString = /*@__PURE__*/ $constructor("ZodString", (inst, def) => {
3422
4547
  $ZodString.init(inst, def);
3423
4548
  _ZodString.init(inst, def);
3424
- inst.email = (params) => inst.check(/* @__PURE__ */ _email(ZodEmail, params));
3425
- inst.url = (params) => inst.check(/* @__PURE__ */ _url(ZodURL, params));
3426
- inst.jwt = (params) => inst.check(/* @__PURE__ */ _jwt(ZodJWT, params));
3427
- inst.emoji = (params) => inst.check(/* @__PURE__ */ _emoji(ZodEmoji, params));
3428
- inst.guid = (params) => inst.check(/* @__PURE__ */ _guid(ZodGUID, params));
3429
- inst.uuid = (params) => inst.check(/* @__PURE__ */ _uuid(ZodUUID, params));
3430
- inst.uuidv4 = (params) => inst.check(/* @__PURE__ */ _uuidv4(ZodUUID, params));
3431
- inst.uuidv6 = (params) => inst.check(/* @__PURE__ */ _uuidv6(ZodUUID, params));
3432
- inst.uuidv7 = (params) => inst.check(/* @__PURE__ */ _uuidv7(ZodUUID, params));
3433
- inst.nanoid = (params) => inst.check(/* @__PURE__ */ _nanoid(ZodNanoID, params));
3434
- inst.guid = (params) => inst.check(/* @__PURE__ */ _guid(ZodGUID, params));
3435
- inst.cuid = (params) => inst.check(/* @__PURE__ */ _cuid(ZodCUID, params));
3436
- inst.cuid2 = (params) => inst.check(/* @__PURE__ */ _cuid2(ZodCUID2, params));
3437
- inst.ulid = (params) => inst.check(/* @__PURE__ */ _ulid(ZodULID, params));
3438
- inst.base64 = (params) => inst.check(/* @__PURE__ */ _base64(ZodBase64, params));
3439
- inst.base64url = (params) => inst.check(/* @__PURE__ */ _base64url(ZodBase64URL, params));
3440
- inst.xid = (params) => inst.check(/* @__PURE__ */ _xid(ZodXID, params));
3441
- inst.ksuid = (params) => inst.check(/* @__PURE__ */ _ksuid(ZodKSUID, params));
3442
- inst.ipv4 = (params) => inst.check(/* @__PURE__ */ _ipv4(ZodIPv4, params));
3443
- inst.ipv6 = (params) => inst.check(/* @__PURE__ */ _ipv6(ZodIPv6, params));
3444
- inst.cidrv4 = (params) => inst.check(/* @__PURE__ */ _cidrv4(ZodCIDRv4, params));
3445
- inst.cidrv6 = (params) => inst.check(/* @__PURE__ */ _cidrv6(ZodCIDRv6, params));
3446
- inst.e164 = (params) => inst.check(/* @__PURE__ */ _e164(ZodE164, params));
3447
- inst.datetime = (params) => inst.check(datetime(params));
3448
- inst.date = (params) => inst.check(date(params));
3449
- inst.time = (params) => inst.check(time(params));
3450
- inst.duration = (params) => inst.check(duration(params));
4549
+ }, {
4550
+ email(params) {
4551
+ return this.check(/* @__PURE__ */ _email(ZodEmail, params));
4552
+ },
4553
+ url(params) {
4554
+ return this.check(/* @__PURE__ */ _url(ZodURL, params));
4555
+ },
4556
+ jwt(params) {
4557
+ return this.check(/* @__PURE__ */ _jwt(ZodJWT, params));
4558
+ },
4559
+ emoji(params) {
4560
+ return this.check(/* @__PURE__ */ _emoji(ZodEmoji, params));
4561
+ },
4562
+ guid(params) {
4563
+ return this.check(/* @__PURE__ */ _guid(ZodGUID, params));
4564
+ },
4565
+ uuid(params) {
4566
+ return this.check(/* @__PURE__ */ _uuid(ZodUUID, params));
4567
+ },
4568
+ uuidv4(params) {
4569
+ return this.check(/* @__PURE__ */ _uuidv4(ZodUUID, params));
4570
+ },
4571
+ uuidv6(params) {
4572
+ return this.check(/* @__PURE__ */ _uuidv6(ZodUUID, params));
4573
+ },
4574
+ uuidv7(params) {
4575
+ return this.check(/* @__PURE__ */ _uuidv7(ZodUUID, params));
4576
+ },
4577
+ nanoid(params) {
4578
+ return this.check(/* @__PURE__ */ _nanoid(ZodNanoID, params));
4579
+ },
4580
+ cuid(params) {
4581
+ return this.check(/* @__PURE__ */ _cuid(ZodCUID, params));
4582
+ },
4583
+ cuid2(params) {
4584
+ return this.check(/* @__PURE__ */ _cuid2(ZodCUID2, params));
4585
+ },
4586
+ ulid(params) {
4587
+ return this.check(/* @__PURE__ */ _ulid(ZodULID, params));
4588
+ },
4589
+ base64(params) {
4590
+ return this.check(/* @__PURE__ */ _base64(ZodBase64, params));
4591
+ },
4592
+ base64url(params) {
4593
+ return this.check(/* @__PURE__ */ _base64url(ZodBase64URL, params));
4594
+ },
4595
+ xid(params) {
4596
+ return this.check(/* @__PURE__ */ _xid(ZodXID, params));
4597
+ },
4598
+ ksuid(params) {
4599
+ return this.check(/* @__PURE__ */ _ksuid(ZodKSUID, params));
4600
+ },
4601
+ ipv4(params) {
4602
+ return this.check(/* @__PURE__ */ _ipv4(ZodIPv4, params));
4603
+ },
4604
+ ipv6(params) {
4605
+ return this.check(/* @__PURE__ */ _ipv6(ZodIPv6, params));
4606
+ },
4607
+ cidrv4(params) {
4608
+ return this.check(/* @__PURE__ */ _cidrv4(ZodCIDRv4, params));
4609
+ },
4610
+ cidrv6(params) {
4611
+ return this.check(/* @__PURE__ */ _cidrv6(ZodCIDRv6, params));
4612
+ },
4613
+ e164(params) {
4614
+ return this.check(/* @__PURE__ */ _e164(ZodE164, params));
4615
+ },
4616
+ datetime(params) {
4617
+ return this.check(/* @__PURE__ */ _isoDateTime(ZodISODateTime, params));
4618
+ },
4619
+ date(params) {
4620
+ return this.check(/* @__PURE__ */ _isoDate(ZodISODate, params));
4621
+ },
4622
+ time(params) {
4623
+ return this.check(/* @__PURE__ */ _isoTime(ZodISOTime, params));
4624
+ },
4625
+ duration(params) {
4626
+ return this.check(/* @__PURE__ */ _isoDuration(ZodISODuration, params));
4627
+ }
3451
4628
  });
3452
4629
  function string(params) {
3453
4630
  return /* @__PURE__ */ _string(ZodString, params);
@@ -3456,6 +4633,22 @@ const ZodStringFormat = /*@__PURE__*/ $constructor("ZodStringFormat", (inst, def
3456
4633
  $ZodStringFormat.init(inst, def);
3457
4634
  _ZodString.init(inst, def);
3458
4635
  });
4636
+ const ZodISODateTime = /*@__PURE__*/ $constructor("ZodISODateTime", (inst, def) => {
4637
+ $ZodISODateTime.init(inst, def);
4638
+ ZodStringFormat.init(inst, def);
4639
+ });
4640
+ const ZodISODate = /*@__PURE__*/ $constructor("ZodISODate", (inst, def) => {
4641
+ $ZodISODate.init(inst, def);
4642
+ ZodStringFormat.init(inst, def);
4643
+ });
4644
+ const ZodISOTime = /*@__PURE__*/ $constructor("ZodISOTime", (inst, def) => {
4645
+ $ZodISOTime.init(inst, def);
4646
+ ZodStringFormat.init(inst, def);
4647
+ });
4648
+ const ZodISODuration = /*@__PURE__*/ $constructor("ZodISODuration", (inst, def) => {
4649
+ $ZodISODuration.init(inst, def);
4650
+ ZodStringFormat.init(inst, def);
4651
+ });
3459
4652
  const ZodEmail = /*@__PURE__*/ $constructor("ZodEmail", (inst, def) => {
3460
4653
  $ZodEmail.init(inst, def);
3461
4654
  ZodStringFormat.init(inst, def);
@@ -3541,60 +4734,68 @@ const ZodNumber = /*@__PURE__*/ $constructor("ZodNumber", (inst, def) => {
3541
4734
  $ZodNumber.init(inst, def);
3542
4735
  ZodType.init(inst, def);
3543
4736
  inst._zod.processJSONSchema = (ctx, json, params) => numberProcessor(inst, ctx, json, params);
3544
- _installLazyMethods(inst, "ZodNumber", {
3545
- gt(value, params) {
3546
- return this.check(/* @__PURE__ */ _gt(value, params));
3547
- },
3548
- gte(value, params) {
3549
- return this.check(/* @__PURE__ */ _gte(value, params));
3550
- },
3551
- min(value, params) {
3552
- return this.check(/* @__PURE__ */ _gte(value, params));
3553
- },
3554
- lt(value, params) {
3555
- return this.check(/* @__PURE__ */ _lt(value, params));
3556
- },
3557
- lte(value, params) {
3558
- return this.check(/* @__PURE__ */ _lte(value, params));
3559
- },
3560
- max(value, params) {
3561
- return this.check(/* @__PURE__ */ _lte(value, params));
3562
- },
3563
- int(params) {
3564
- return this.check(int(params));
3565
- },
3566
- safe(params) {
3567
- return this.check(int(params));
3568
- },
3569
- positive(params) {
3570
- return this.check(/* @__PURE__ */ _gt(0, params));
3571
- },
3572
- nonnegative(params) {
3573
- return this.check(/* @__PURE__ */ _gte(0, params));
3574
- },
3575
- negative(params) {
3576
- return this.check(/* @__PURE__ */ _lt(0, params));
3577
- },
3578
- nonpositive(params) {
3579
- return this.check(/* @__PURE__ */ _lte(0, params));
3580
- },
3581
- multipleOf(value, params) {
3582
- return this.check(/* @__PURE__ */ _multipleOf(value, params));
3583
- },
3584
- step(value, params) {
3585
- return this.check(/* @__PURE__ */ _multipleOf(value, params));
3586
- },
3587
- finite() {
3588
- return this;
3589
- }
3590
- });
3591
- const bag = inst._zod.bag;
3592
- inst.minValue = Math.max(bag.minimum ?? Number.NEGATIVE_INFINITY, bag.exclusiveMinimum ?? Number.NEGATIVE_INFINITY) ?? null;
3593
- inst.maxValue = Math.min(bag.maximum ?? Number.POSITIVE_INFINITY, bag.exclusiveMaximum ?? Number.POSITIVE_INFINITY) ?? null;
3594
- inst.isInt = (bag.format ?? "").includes("int") || Number.isSafeInteger(bag.multipleOf ?? .5);
3595
4737
  inst.isFinite = true;
3596
- inst.format = bag.format ?? null;
3597
- });
4738
+ }, /*@__PURE__*/ derived({
4739
+ minValue: (inst) => {
4740
+ const { minimum, exclusiveMinimum } = aggregateChecks(inst);
4741
+ return Math.max(minimum ?? Number.NEGATIVE_INFINITY, exclusiveMinimum ?? Number.NEGATIVE_INFINITY);
4742
+ },
4743
+ maxValue: (inst) => {
4744
+ const { maximum, exclusiveMaximum } = aggregateChecks(inst);
4745
+ return Math.min(maximum ?? Number.POSITIVE_INFINITY, exclusiveMaximum ?? Number.POSITIVE_INFINITY);
4746
+ },
4747
+ isInt: (inst) => {
4748
+ const { isInt, multipleOf } = aggregateChecks(inst);
4749
+ return !!isInt || !!multipleOf?.some(Number.isSafeInteger);
4750
+ },
4751
+ format: (inst) => aggregateChecks(inst).format ?? null
4752
+ }, {
4753
+ gt(value, params) {
4754
+ return this.check(/* @__PURE__ */ _gt(value, params));
4755
+ },
4756
+ gte(value, params) {
4757
+ return this.check(/* @__PURE__ */ _gte(value, params));
4758
+ },
4759
+ min(value, params) {
4760
+ return this.check(/* @__PURE__ */ _gte(value, params));
4761
+ },
4762
+ lt(value, params) {
4763
+ return this.check(/* @__PURE__ */ _lt(value, params));
4764
+ },
4765
+ lte(value, params) {
4766
+ return this.check(/* @__PURE__ */ _lte(value, params));
4767
+ },
4768
+ max(value, params) {
4769
+ return this.check(/* @__PURE__ */ _lte(value, params));
4770
+ },
4771
+ int(params) {
4772
+ return this.check(int(params));
4773
+ },
4774
+ safe(params) {
4775
+ return this.check(int(params));
4776
+ },
4777
+ positive(params) {
4778
+ return this.check(/* @__PURE__ */ _gt(0, params));
4779
+ },
4780
+ nonnegative(params) {
4781
+ return this.check(/* @__PURE__ */ _gte(0, params));
4782
+ },
4783
+ negative(params) {
4784
+ return this.check(/* @__PURE__ */ _lt(0, params));
4785
+ },
4786
+ nonpositive(params) {
4787
+ return this.check(/* @__PURE__ */ _lte(0, params));
4788
+ },
4789
+ multipleOf(value, params) {
4790
+ return this.check(/* @__PURE__ */ _multipleOf(value, params));
4791
+ },
4792
+ step(value, params) {
4793
+ return this.check(/* @__PURE__ */ _multipleOf(value, params));
4794
+ },
4795
+ finite() {
4796
+ return this;
4797
+ }
4798
+ }));
3598
4799
  function number(params) {
3599
4800
  return /* @__PURE__ */ _number(ZodNumber, params);
3600
4801
  }
@@ -3622,94 +4823,80 @@ function never(params) {
3622
4823
  return /* @__PURE__ */ _never(ZodNever, params);
3623
4824
  }
3624
4825
  const ZodArray = /*@__PURE__*/ $constructor("ZodArray", (inst, def) => {
4826
+ _ensureDefaultMemoizer();
3625
4827
  $ZodArray.init(inst, def);
3626
4828
  ZodType.init(inst, def);
3627
4829
  inst._zod.processJSONSchema = (ctx, json, params) => arrayProcessor(inst, ctx, json, params);
3628
4830
  inst.element = def.element;
3629
- _installLazyMethods(inst, "ZodArray", {
3630
- min(n, params) {
3631
- return this.check(/* @__PURE__ */ _minLength(n, params));
3632
- },
3633
- nonempty(params) {
3634
- return this.check(/* @__PURE__ */ _minLength(1, params));
3635
- },
3636
- max(n, params) {
3637
- return this.check(/* @__PURE__ */ _maxLength(n, params));
3638
- },
3639
- length(n, params) {
3640
- return this.check(/* @__PURE__ */ _length(n, params));
3641
- },
3642
- unwrap() {
3643
- return this.element;
3644
- }
3645
- });
4831
+ }, {
4832
+ min(n, params) {
4833
+ return this.check(/* @__PURE__ */ _minLength(n, params));
4834
+ },
4835
+ nonempty(params) {
4836
+ return this.check(/* @__PURE__ */ _minLength(1, params));
4837
+ },
4838
+ max(n, params) {
4839
+ return this.check(/* @__PURE__ */ _maxLength(n, params));
4840
+ },
4841
+ length(n, params) {
4842
+ return this.check(/* @__PURE__ */ _length(n, params));
4843
+ },
4844
+ unwrap() {
4845
+ return this.element;
4846
+ }
3646
4847
  });
3647
4848
  function array(element, params) {
3648
4849
  return /* @__PURE__ */ _array(ZodArray, element, params);
3649
4850
  }
3650
4851
  const ZodObject = /*@__PURE__*/ $constructor("ZodObject", (inst, def) => {
4852
+ _ensureDefaultMemoizer();
3651
4853
  $ZodObjectJIT.init(inst, def);
3652
4854
  ZodType.init(inst, def);
3653
4855
  inst._zod.processJSONSchema = (ctx, json, params) => objectProcessor(inst, ctx, json, params);
3654
- defineLazy(inst, "shape", () => {
3655
- return def.shape;
3656
- });
3657
- _installLazyMethods(inst, "ZodObject", {
3658
- keyof() {
3659
- return _enum(Object.keys(this._zod.def.shape));
3660
- },
3661
- catchall(catchall) {
3662
- return this.clone({
3663
- ...this._zod.def,
3664
- catchall
3665
- });
3666
- },
3667
- passthrough() {
3668
- return this.clone({
3669
- ...this._zod.def,
3670
- catchall: unknown()
3671
- });
3672
- },
3673
- loose() {
3674
- return this.clone({
3675
- ...this._zod.def,
3676
- catchall: unknown()
3677
- });
3678
- },
3679
- strict() {
3680
- return this.clone({
3681
- ...this._zod.def,
3682
- catchall: never()
3683
- });
3684
- },
3685
- strip() {
3686
- return this.clone({
3687
- ...this._zod.def,
3688
- catchall: void 0
3689
- });
3690
- },
3691
- extend(incoming) {
3692
- return extend(this, incoming);
3693
- },
3694
- safeExtend(incoming) {
3695
- return safeExtend(this, incoming);
3696
- },
3697
- merge(other) {
3698
- return merge(this, other);
3699
- },
3700
- pick(mask) {
3701
- return pick(this, mask);
3702
- },
3703
- omit(mask) {
3704
- return omit(this, mask);
3705
- },
3706
- partial(...args) {
3707
- return partial(ZodOptional, this, args[0]);
3708
- },
3709
- required(...args) {
3710
- return required(ZodNonOptional, this, args[0]);
3711
- }
3712
- });
4856
+ installLazyProp(inst, "shape", (self) => self._zod.def.shape, false);
4857
+ }, {
4858
+ keyof() {
4859
+ return _enum(Object.keys(this._zod.def.shape));
4860
+ },
4861
+ catchall(catchall) {
4862
+ return this.clone(mergeDefs(this._zod.def, { catchall }));
4863
+ },
4864
+ passthrough() {
4865
+ return this.clone(mergeDefs(this._zod.def, { catchall: unknown() }));
4866
+ },
4867
+ loose() {
4868
+ return this.clone(mergeDefs(this._zod.def, { catchall: unknown() }));
4869
+ },
4870
+ strict() {
4871
+ return this.clone(mergeDefs(this._zod.def, { catchall: never() }));
4872
+ },
4873
+ strip() {
4874
+ return this.clone(mergeDefs(this._zod.def, { catchall: void 0 }));
4875
+ },
4876
+ extend(incoming) {
4877
+ return extend(this, incoming);
4878
+ },
4879
+ safeExtend(incoming) {
4880
+ return safeExtend(this, incoming);
4881
+ },
4882
+ merge(other) {
4883
+ return merge(this, other);
4884
+ },
4885
+ pick(mask) {
4886
+ return pick(this, mask);
4887
+ },
4888
+ omit(mask) {
4889
+ return omit(this, mask);
4890
+ },
4891
+ partial(...args) {
4892
+ return partial(ZodOptional, this, args[0]);
4893
+ },
4894
+ exactPartial(...args) {
4895
+ return partial(ZodExactOptional, this, args[0], "exactPartial");
4896
+ },
4897
+ required(...args) {
4898
+ return required(ZodNonOptional, this, args[0]);
4899
+ }
3713
4900
  });
3714
4901
  function object(shape, params) {
3715
4902
  return new ZodObject({
@@ -3748,7 +4935,7 @@ const ZodEnum = /*@__PURE__*/ $constructor("ZodEnum", (inst, def) => {
3748
4935
  ZodType.init(inst, def);
3749
4936
  inst._zod.processJSONSchema = (ctx, json, params) => enumProcessor(inst, ctx, json, params);
3750
4937
  inst.enum = def.entries;
3751
- inst.options = Object.values(def.entries);
4938
+ inst.options = [...inst._zod.values];
3752
4939
  const keys = new Set(Object.keys(def.entries));
3753
4940
  inst.extract = (values, params) => {
3754
4941
  const newEntries = {};
@@ -3781,6 +4968,7 @@ function _enum(values, params) {
3781
4968
  });
3782
4969
  }
3783
4970
  const ZodTransform = /*@__PURE__*/ $constructor("ZodTransform", (inst, def) => {
4971
+ _ensureDefaultMemoizer();
3784
4972
  $ZodTransform.init(inst, def);
3785
4973
  ZodType.init(inst, def);
3786
4974
  inst._zod.processJSONSchema = (ctx, json, params) => transformProcessor(inst, ctx, json, params);
@@ -3792,7 +4980,7 @@ const ZodTransform = /*@__PURE__*/ $constructor("ZodTransform", (inst, def) => {
3792
4980
  const _issue = issue$1;
3793
4981
  if (_issue.fatal) _issue.continue = false;
3794
4982
  _issue.code ?? (_issue.code = "custom");
3795
- _issue.input ?? (_issue.input = payload.value);
4983
+ if (!("input" in _issue)) _issue.input = payload.value;
3796
4984
  _issue.inst ?? (_issue.inst = inst);
3797
4985
  payload.issues.push(issue(_issue));
3798
4986
  }
@@ -3800,11 +4988,9 @@ const ZodTransform = /*@__PURE__*/ $constructor("ZodTransform", (inst, def) => {
3800
4988
  const output = def.transform(payload.value, payload);
3801
4989
  if (output instanceof Promise) return output.then((output) => {
3802
4990
  payload.value = output;
3803
- payload.fallback = true;
3804
4991
  return payload;
3805
4992
  });
3806
4993
  payload.value = output;
3807
- payload.fallback = true;
3808
4994
  return payload;
3809
4995
  };
3810
4996
  });
@@ -3905,7 +5091,7 @@ function _catch(innerType, catchValue) {
3905
5091
  return new ZodCatch({
3906
5092
  type: "catch",
3907
5093
  innerType,
3908
- catchValue: typeof catchValue === "function" ? catchValue : () => catchValue
5094
+ catchValue: typeof catchValue === "function" ? catchValue : constantCatch(catchValue)
3909
5095
  });
3910
5096
  }
3911
5097
  const ZodPipe = /*@__PURE__*/ $constructor("ZodPipe", (inst, def) => {
@@ -3970,6 +5156,60 @@ const DEFAULT_EXPIRES_IN = 900;
3970
5156
  const DEFAULT_BASE_PATH = "/_files";
3971
5157
  const OCTET_STREAM = "application/octet-stream";
3972
5158
  const MS_PER_SECOND = 1e3;
5159
+ /** Why an upload was refused: its body broke a limit its token pins. */
5160
+ var UploadRefused = class extends Error {
5161
+ /** The HTTP status the refusal answers with. */
5162
+ status;
5163
+ /** A stable code: `TOO_LARGE` or `CHECKSUM_MISMATCH`. */
5164
+ code;
5165
+ constructor(status, code, message) {
5166
+ super(message);
5167
+ this.name = "UploadRefused";
5168
+ this.status = status;
5169
+ this.code = code;
5170
+ }
5171
+ };
5172
+ /**
5173
+ * Check an upload body against its token while it streams: past `m` bytes, or at the end when the bytes don't
5174
+ * hash to `h`, the stream errors with {@link UploadRefused}, so the store never publishes the object.
5175
+ */
5176
+ function guardUpload(body, token) {
5177
+ const { m: max, h: sha256 } = token;
5178
+ if (max === void 0 && sha256 === void 0) return body;
5179
+ const hash = sha256 === void 0 ? void 0 : (0, node_crypto.createHash)("sha256");
5180
+ let size = 0;
5181
+ return body.pipeThrough(new TransformStream({
5182
+ transform(chunk, controller) {
5183
+ size += chunk.length;
5184
+ if (max !== void 0 && size > max) throw new UploadRefused(413, "TOO_LARGE", `upload is larger than ${max} bytes`);
5185
+ hash?.update(chunk);
5186
+ controller.enqueue(chunk);
5187
+ },
5188
+ flush() {
5189
+ if (hash !== void 0 && hash.digest("hex") !== sha256) throw new UploadRefused(422, "CHECKSUM_MISMATCH", "upload does not match its sha256");
5190
+ }
5191
+ }));
5192
+ }
5193
+ /**
5194
+ * Store a presigned upload under its token's key, refusing it up front when a declared `Content-Length` already
5195
+ * breaks the token's `maxSize`. Throws {@link UploadRefused} when the body breaks a pinned limit.
5196
+ */
5197
+ async function storeUpload(store, token, body, declared) {
5198
+ const length = declared === null ? void 0 : Number(declared);
5199
+ if (token.m !== void 0 && length !== void 0 && length > token.m) {
5200
+ await body.cancel().catch(() => void 0);
5201
+ throw new UploadRefused(413, "TOO_LARGE", `upload is larger than ${token.m} bytes`);
5202
+ }
5203
+ try {
5204
+ return await store.put(token.k, guardUpload(body, token), { contentType: token.c });
5205
+ } catch (err) {
5206
+ throw refusalIn(err) ?? err;
5207
+ }
5208
+ }
5209
+ /** The {@link UploadRefused} behind a store failure, if a guard caused it (stores may wrap stream errors). */
5210
+ function refusalIn(err) {
5211
+ for (let e = err, depth = 0; e instanceof Error && depth < 4; e = e.cause, depth++) if (e instanceof UploadRefused) return e;
5212
+ }
3973
5213
  const b64url = (buf) => Buffer.from(buf).toString("base64url");
3974
5214
  /** Sign a {@link Token} into the opaque `?t=` value. */
3975
5215
  function signToken(secret, token) {
@@ -4012,7 +5252,9 @@ function makePresigner(opts) {
4012
5252
  k: key,
4013
5253
  o: "put",
4014
5254
  e: exp(o?.expiresIn),
4015
- c: o?.contentType
5255
+ c: o?.contentType,
5256
+ m: o?.maxSize,
5257
+ h: o?.sha256?.toLowerCase()
4016
5258
  }))
4017
5259
  };
4018
5260
  }
@@ -4059,14 +5301,19 @@ function mountFiles(app, store, opts) {
4059
5301
  length(obj.info.size);
4060
5302
  return obj.stream();
4061
5303
  },
4062
- ayepiFilesUpload: async ({ data, stream }) => {
5304
+ ayepiFilesUpload: async ({ data, stream, req }) => {
4063
5305
  const token = verifyToken(opts.secret, data.t, Math.floor((opts.now ?? Date.now)() / MS_PER_SECOND));
4064
5306
  if (!token || token.o !== "put") throw (0, _ayepi_core.reject)(403, "FORBIDDEN", "invalid or expired token");
4065
- const info = await store.put(token.k, stream, { contentType: token.c });
4066
- return {
4067
- key: info.key,
4068
- size: info.size
4069
- };
5307
+ try {
5308
+ const info = await storeUpload(store, token, stream, req.headers.get("content-length"));
5309
+ return {
5310
+ key: info.key,
5311
+ size: info.size
5312
+ };
5313
+ } catch (err) {
5314
+ if (err instanceof UploadRefused) throw (0, _ayepi_core.reject)(err.status, err.code, err.message);
5315
+ throw err;
5316
+ }
4070
5317
  }
4071
5318
  });
4072
5319
  const install = app.install;
@@ -4107,11 +5354,19 @@ function createFilesHandler(store, opts) {
4107
5354
  if (req.method === "PUT") {
4108
5355
  if (!token || token.o !== "put") return new Response("forbidden", { status: 403 });
4109
5356
  const body = req.body ?? new ReadableStream({ start: (c) => c.close() });
4110
- const info = await store.put(token.k, body, { contentType: token.c });
4111
- return Response.json({
4112
- key: info.key,
4113
- size: info.size
4114
- });
5357
+ try {
5358
+ const info = await storeUpload(store, token, body, req.headers.get("content-length"));
5359
+ return Response.json({
5360
+ key: info.key,
5361
+ size: info.size
5362
+ });
5363
+ } catch (err) {
5364
+ if (err instanceof UploadRefused) return Response.json({ error: {
5365
+ code: err.code,
5366
+ message: err.message
5367
+ } }, { status: err.status });
5368
+ throw err;
5369
+ }
4115
5370
  }
4116
5371
  return new Response("method not allowed", { status: 405 });
4117
5372
  };
@@ -4121,5 +5376,6 @@ function createFilesHandler(store, opts) {
4121
5376
  };
4122
5377
  }
4123
5378
  //#endregion
5379
+ exports.UploadRefused = UploadRefused;
4124
5380
  exports.createFilesHandler = createFilesHandler;
4125
5381
  exports.mountFiles = mountFiles;