@pdfme/converter 6.2.2 → 6.2.3

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.
@@ -22,7 +22,7 @@
22
22
  enumerable: true
23
23
  }) : target, mod));
24
24
  //#endregion
25
- //#region \0@oxc-project+runtime@0.147.0/helpers/esm/typeof.js
25
+ //#region \0@oxc-project+runtime@0.151.0/helpers/esm/typeof.js
26
26
  function _typeof(o) {
27
27
  "@babel/helpers - typeof";
28
28
  return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
@@ -32,7 +32,7 @@
32
32
  }, _typeof(o);
33
33
  }
34
34
  //#endregion
35
- //#region \0@oxc-project+runtime@0.147.0/helpers/esm/toPrimitive.js
35
+ //#region \0@oxc-project+runtime@0.151.0/helpers/esm/toPrimitive.js
36
36
  function toPrimitive(t, r) {
37
37
  if ("object" != _typeof(t) || !t) return t;
38
38
  var e = t[Symbol.toPrimitive];
@@ -44,13 +44,13 @@
44
44
  return ("string" === r ? String : Number)(t);
45
45
  }
46
46
  //#endregion
47
- //#region \0@oxc-project+runtime@0.147.0/helpers/esm/toPropertyKey.js
47
+ //#region \0@oxc-project+runtime@0.151.0/helpers/esm/toPropertyKey.js
48
48
  function toPropertyKey(t) {
49
49
  var i = toPrimitive(t, "string");
50
50
  return "symbol" == _typeof(i) ? i : i + "";
51
51
  }
52
52
  //#endregion
53
- //#region \0@oxc-project+runtime@0.147.0/helpers/esm/defineProperty.js
53
+ //#region \0@oxc-project+runtime@0.151.0/helpers/esm/defineProperty.js
54
54
  function _defineProperty(e, r, t) {
55
55
  return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
56
56
  value: t,
@@ -5525,28 +5525,28 @@
5525
5525
  [_Symbol$dispose$1]() {}
5526
5526
  };
5527
5527
  //#endregion
5528
- //#region \0@oxc-project+runtime@0.147.0/helpers/esm/checkPrivateRedeclaration.js
5528
+ //#region \0@oxc-project+runtime@0.151.0/helpers/esm/checkPrivateRedeclaration.js
5529
5529
  function _checkPrivateRedeclaration(e, t) {
5530
5530
  if (t.has(e)) throw new TypeError("Cannot initialize the same private elements twice on an object");
5531
5531
  }
5532
5532
  //#endregion
5533
- //#region \0@oxc-project+runtime@0.147.0/helpers/esm/classPrivateFieldInitSpec.js
5533
+ //#region \0@oxc-project+runtime@0.151.0/helpers/esm/classPrivateFieldInitSpec.js
5534
5534
  function _classPrivateFieldInitSpec(e, t, a) {
5535
5535
  _checkPrivateRedeclaration(e, t), t.set(e, a);
5536
5536
  }
5537
5537
  //#endregion
5538
- //#region \0@oxc-project+runtime@0.147.0/helpers/esm/assertClassBrand.js
5538
+ //#region \0@oxc-project+runtime@0.151.0/helpers/esm/assertClassBrand.js
5539
5539
  function _assertClassBrand(e, t, n) {
5540
5540
  if ("function" == typeof e ? e === t : e.has(t)) return arguments.length < 3 ? t : n;
5541
5541
  throw new TypeError("Private element is not present on this object");
5542
5542
  }
5543
5543
  //#endregion
5544
- //#region \0@oxc-project+runtime@0.147.0/helpers/esm/classPrivateFieldGet2.js
5544
+ //#region \0@oxc-project+runtime@0.151.0/helpers/esm/classPrivateFieldGet2.js
5545
5545
  function _classPrivateFieldGet2(s, a) {
5546
5546
  return s.get(_assertClassBrand(s, a));
5547
5547
  }
5548
5548
  //#endregion
5549
- //#region \0@oxc-project+runtime@0.147.0/helpers/esm/classPrivateFieldSet2.js
5549
+ //#region \0@oxc-project+runtime@0.151.0/helpers/esm/classPrivateFieldSet2.js
5550
5550
  function _classPrivateFieldSet2(s, a, r) {
5551
5551
  return s.set(_assertClassBrand(s, a), r), r;
5552
5552
  }
@@ -5823,6 +5823,7 @@
5823
5823
  return readNodeFile(input);
5824
5824
  }
5825
5825
  const defaultFetchTimeoutMs = 3e4;
5826
+ const defaultFetchMaxBytes = 0;
5826
5827
  const maxTimerMs = 2147483647;
5827
5828
  async function readUrl(url, options) {
5828
5829
  if (url.protocol === "file:" && isNodeRuntime()) {
@@ -5835,6 +5836,7 @@
5835
5836
  "data:"
5836
5837
  ].includes(url.protocol)) throw new PdfFormatError(`Unsupported PDF URL protocol: ${url.protocol}`);
5837
5838
  const timeoutMs = resolveFetchTimeout(options.fetchTimeoutMs);
5839
+ const maxBytes = resolveFetchMaxBytes(options.fetchMaxBytes);
5838
5840
  const controller = new AbortController();
5839
5841
  let timedOut = false;
5840
5842
  let timeout;
@@ -5849,9 +5851,10 @@
5849
5851
  try {
5850
5852
  const response = await fetch(url, { signal: controller.signal });
5851
5853
  if (!response.ok) throw new PdfFormatError(`Failed to fetch PDF from ${url.href}: ${response.status} ${response.statusText}`);
5852
- return new Uint8Array(await response.arrayBuffer());
5854
+ return await readResponseBytes(url, response, maxBytes);
5853
5855
  } catch (error) {
5854
- if (error instanceof PdfFormatError) throw error;
5856
+ controller.abort();
5857
+ if (error instanceof PdfError) throw error;
5855
5858
  if (timedOut) throw new PdfFormatError(`Timed out fetching PDF from ${url.href} after ${timeoutMs}ms`, { cause: error });
5856
5859
  if (options.signal?.aborted || error instanceof Error && error.name === "AbortError") throw new PdfFormatError(`Aborted fetching PDF from ${url.href}`, { cause: error });
5857
5860
  throw new PdfFormatError(`Failed to fetch PDF from ${url.href}`, { cause: error });
@@ -5865,6 +5868,56 @@
5865
5868
  if (!Number.isSafeInteger(value) || value < 0 || value > maxTimerMs) throw new PdfFormatError(`fetchTimeoutMs must be an integer between 0 and ${maxTimerMs}`);
5866
5869
  return value;
5867
5870
  }
5871
+ function resolveFetchMaxBytes(value) {
5872
+ if (value === void 0) return defaultFetchMaxBytes;
5873
+ if (!Number.isSafeInteger(value) || value < 0) throw new PdfFormatError(`fetchMaxBytes must be an integer between 0 and ${Number.MAX_SAFE_INTEGER}`);
5874
+ return value;
5875
+ }
5876
+ async function readResponseBytes(url, response, maxBytes) {
5877
+ if (url.protocol !== "http:" && url.protocol !== "https:") return new Uint8Array(await response.arrayBuffer());
5878
+ const declared = parseContentLength(response.headers.get("content-length"));
5879
+ if (maxBytes > 0 && declared !== void 0 && declared > maxBytes) {
5880
+ await response.body?.cancel().catch(() => void 0);
5881
+ throw new PdfBudgetError("fetchMaxBytes", declared, `PDF response from ${url.href} exceeds the ${maxBytes}-byte fetch budget`);
5882
+ }
5883
+ if (maxBytes === 0) return new Uint8Array(await response.arrayBuffer());
5884
+ return readCappedBody(url, response, maxBytes);
5885
+ }
5886
+ async function readCappedBody(url, response, maxBytes) {
5887
+ if (!response.body) return /* @__PURE__ */ new Uint8Array();
5888
+ const reader = response.body.getReader();
5889
+ const chunks = [];
5890
+ let received = 0;
5891
+ try {
5892
+ for (;;) {
5893
+ const { done, value } = await reader.read();
5894
+ if (done) break;
5895
+ received += value.byteLength;
5896
+ if (received > maxBytes) {
5897
+ await reader.cancel().catch(() => void 0);
5898
+ throw new PdfBudgetError("fetchMaxBytes", received, `PDF response from ${url.href} exceeds the ${maxBytes}-byte fetch budget`);
5899
+ }
5900
+ chunks.push(value);
5901
+ }
5902
+ } finally {
5903
+ reader.releaseLock();
5904
+ }
5905
+ return concatUint8(chunks, received);
5906
+ }
5907
+ function parseContentLength(header) {
5908
+ if (header === null || header === "") return;
5909
+ if (!/^\d+$/.test(header)) return;
5910
+ return Number(header);
5911
+ }
5912
+ function concatUint8(chunks, total) {
5913
+ const out = new Uint8Array(total);
5914
+ let offset = 0;
5915
+ for (const chunk of chunks) {
5916
+ out.set(chunk, offset);
5917
+ offset += chunk.byteLength;
5918
+ }
5919
+ return out;
5920
+ }
5868
5921
  function isSupportedUrlProtocol(protocol) {
5869
5922
  return [
5870
5923
  "file:",
@@ -5946,6 +5999,7 @@
5946
5999
  if (options.password !== void 0) openOptions.password = options.password;
5947
6000
  if (options.signal !== void 0) openOptions.signal = options.signal;
5948
6001
  if (options.fetchTimeoutMs !== void 0) openOptions.fetchTimeoutMs = options.fetchTimeoutMs;
6002
+ if (options.fetchMaxBytes !== void 0) openOptions.fetchMaxBytes = options.fetchMaxBytes;
5949
6003
  const document = await this.open(input, openOptions);
5950
6004
  try {
5951
6005
  return await extractDocument(document, options);
@@ -6072,14 +6126,22 @@
6072
6126
  if (typeof value === "bigint") return value.toString();
6073
6127
  return value;
6074
6128
  }
6075
- function cached(getter) {
6076
- return { get value() {
6077
- {
6078
- const value = getter();
6079
- Object.defineProperty(this, "value", { value });
6080
- return value;
6129
+ var Cached = class {
6130
+ constructor(getter) {
6131
+ this._getter = getter;
6132
+ this._value = void 0;
6133
+ }
6134
+ get value() {
6135
+ const getter = this._getter;
6136
+ if (getter !== void 0) {
6137
+ this._value = getter();
6138
+ this._getter = void 0;
6081
6139
  }
6082
- } };
6140
+ return this._value;
6141
+ }
6142
+ };
6143
+ function cached(getter) {
6144
+ return new Cached(getter);
6083
6145
  }
6084
6146
  function nullish(input) {
6085
6147
  return input === null || input === void 0;
@@ -6104,6 +6166,58 @@
6104
6166
  configurable: true
6105
6167
  });
6106
6168
  }
6169
+ /**
6170
+ * Whichever object a def's `shape` currently answers from: the one the caller passed until the first read, the frozen copy after it.
6171
+ *
6172
+ * 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.
6173
+ */
6174
+ function rawShape(def) {
6175
+ const desc = Object.getOwnPropertyDescriptor(def, "shape");
6176
+ return desc?.get ? desc.get.raw : desc?.value;
6177
+ }
6178
+ function sourceShape(schema) {
6179
+ return rawShape(schema._zod.def) ?? schema._zod.def.shape;
6180
+ }
6181
+ function deferProp(target, key, getter) {
6182
+ Object.defineProperty(target, key, {
6183
+ get() {
6184
+ const value = getter();
6185
+ assignProp(this, key, value);
6186
+ return value;
6187
+ },
6188
+ enumerable: true,
6189
+ configurable: true
6190
+ });
6191
+ }
6192
+ function putProp(target, key, value) {
6193
+ if (key in target) assignProp(target, key, value);
6194
+ else target[key] = value;
6195
+ }
6196
+ /**
6197
+ * Copies `keys` of `source`'s shape onto `target`, each value passed through `wrap`.
6198
+ *
6199
+ * 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.
6200
+ */
6201
+ function mirrorShape(target, source, keys, wrap) {
6202
+ const raw = sourceShape(source);
6203
+ for (const key of keys) {
6204
+ const desc = Object.getOwnPropertyDescriptor(raw, key);
6205
+ if (!desc.enumerable) continue;
6206
+ if (desc.get) deferProp(target, key, () => {
6207
+ const value = source._zod.def.shape[key];
6208
+ return wrap ? wrap(value, key) : value;
6209
+ });
6210
+ else putProp(target, key, wrap ? wrap(desc.value, key) : desc.value);
6211
+ }
6212
+ }
6213
+ function mirrorProps(target, source) {
6214
+ for (const key of Reflect.ownKeys(source)) {
6215
+ const desc = Object.getOwnPropertyDescriptor(source, key);
6216
+ if (!desc.enumerable) continue;
6217
+ if (desc.get) deferProp(target, key, () => source[key]);
6218
+ else putProp(target, key, desc.value);
6219
+ }
6220
+ }
6107
6221
  function mergeDefs(...defs) {
6108
6222
  const mergedDescriptors = {};
6109
6223
  for (const def of defs) {
@@ -6194,39 +6308,39 @@
6194
6308
  float32: [-34028234663852886e22, 34028234663852886e22],
6195
6309
  float64: [-Number.MAX_VALUE, Number.MAX_VALUE]
6196
6310
  }))();
6311
+ const BIGINT_FORMAT_RANGES = {
6312
+ int64: [/* @__PURE__*/ BigInt("-9223372036854775808"), /* @__PURE__*/ BigInt("9223372036854775807")],
6313
+ uint64: [/* @__PURE__*/ BigInt(0), /* @__PURE__*/ BigInt("18446744073709551615")]
6314
+ };
6197
6315
  function pick(schema, mask) {
6198
6316
  const currDef = schema._zod.def;
6199
6317
  const checks = currDef.checks;
6200
6318
  if (checks && checks.length > 0) throw new Error(".pick() cannot be used on object schemas containing refinements");
6201
- return clone(schema, mergeDefs(schema._zod.def, {
6202
- get shape() {
6203
- const newShape = {};
6204
- for (const key of Reflect.ownKeys(mask)) {
6205
- if (!Object.prototype.hasOwnProperty.call(currDef.shape, key)) throw new Error(`Unrecognized key: "${String(key)}"`);
6206
- if (!mask[key]) continue;
6207
- assignProp(newShape, key, currDef.shape[key]);
6208
- }
6209
- assignProp(this, "shape", newShape);
6210
- return newShape;
6211
- },
6319
+ const newShape = {};
6320
+ mirrorShape(newShape, schema, maskedKeys(schema, mask));
6321
+ return clone(schema, mergeDefs(currDef, {
6322
+ shape: newShape,
6212
6323
  checks: []
6213
6324
  }));
6214
6325
  }
6326
+ function maskedKeys(schema, mask) {
6327
+ const raw = sourceShape(schema);
6328
+ const keys = [];
6329
+ for (const key of Reflect.ownKeys(mask)) {
6330
+ if (!Object.getOwnPropertyDescriptor(raw, key)?.enumerable) throw new Error(`Unrecognized key: "${String(key)}"`);
6331
+ if (mask[key]) keys.push(key);
6332
+ }
6333
+ return keys;
6334
+ }
6215
6335
  function omit(schema, mask) {
6216
6336
  const currDef = schema._zod.def;
6217
6337
  const checks = currDef.checks;
6218
6338
  if (checks && checks.length > 0) throw new Error(".omit() cannot be used on object schemas containing refinements");
6219
- return clone(schema, mergeDefs(schema._zod.def, {
6220
- get shape() {
6221
- const newShape = { ...schema._zod.def.shape };
6222
- for (const key of Reflect.ownKeys(mask)) {
6223
- if (!Object.prototype.hasOwnProperty.call(currDef.shape, key)) throw new Error(`Unrecognized key: "${String(key)}"`);
6224
- if (!mask[key]) continue;
6225
- delete newShape[key];
6226
- }
6227
- assignProp(this, "shape", newShape);
6228
- return newShape;
6229
- },
6339
+ const omitted = new Set(maskedKeys(schema, mask));
6340
+ const newShape = {};
6341
+ mirrorShape(newShape, schema, Reflect.ownKeys(sourceShape(schema)).filter((key) => !omitted.has(key)));
6342
+ return clone(schema, mergeDefs(currDef, {
6343
+ shape: newShape,
6230
6344
  checks: []
6231
6345
  }));
6232
6346
  }
@@ -6234,41 +6348,29 @@
6234
6348
  if (!isPlainObject(shape)) throw new Error("Invalid input to extend: expected a plain object");
6235
6349
  const checks = schema._zod.def.checks;
6236
6350
  if (checks && checks.length > 0) {
6237
- const existingShape = schema._zod.def.shape;
6351
+ const existingShape = sourceShape(schema);
6238
6352
  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.");
6239
6353
  }
6240
- return clone(schema, mergeDefs(schema._zod.def, { get shape() {
6241
- const _shape = {
6242
- ...schema._zod.def.shape,
6243
- ...shape
6244
- };
6245
- assignProp(this, "shape", _shape);
6246
- return _shape;
6247
- } }));
6354
+ return clone(schema, mergeDefs(schema._zod.def, { shape: extended(schema, shape) }));
6355
+ }
6356
+ function extended(schema, shape) {
6357
+ const newShape = {};
6358
+ mirrorShape(newShape, schema, Reflect.ownKeys(sourceShape(schema)));
6359
+ mirrorProps(newShape, shape);
6360
+ return newShape;
6248
6361
  }
6249
6362
  function safeExtend(schema, shape) {
6250
6363
  if (!isPlainObject(shape)) throw new Error("Invalid input to safeExtend: expected a plain object");
6251
- return clone(schema, mergeDefs(schema._zod.def, { get shape() {
6252
- const _shape = {
6253
- ...schema._zod.def.shape,
6254
- ...shape
6255
- };
6256
- assignProp(this, "shape", _shape);
6257
- return _shape;
6258
- } }));
6364
+ return clone(schema, mergeDefs(schema._zod.def, { shape: extended(schema, shape) }));
6259
6365
  }
6260
6366
  function merge(a, b) {
6261
6367
  if (!b?._zod?.def) throw new Error("Invalid input to merge: expected an object schema. To merge a plain shape, use `.extend()`.");
6262
6368
  if (a._zod.def.checks?.length) throw new Error(".merge() cannot be used on object schemas containing refinements. Use .safeExtend() instead.");
6369
+ const newShape = {};
6370
+ mirrorShape(newShape, a, Reflect.ownKeys(sourceShape(a)));
6371
+ mirrorShape(newShape, b, Reflect.ownKeys(sourceShape(b)));
6263
6372
  return clone(a, mergeDefs(a._zod.def, {
6264
- get shape() {
6265
- const _shape = {
6266
- ...a._zod.def.shape,
6267
- ...b._zod.def.shape
6268
- };
6269
- assignProp(this, "shape", _shape);
6270
- return _shape;
6271
- },
6373
+ shape: newShape,
6272
6374
  get catchall() {
6273
6375
  return b._zod.def.catchall;
6274
6376
  },
@@ -6278,47 +6380,25 @@
6278
6380
  function partial(Class, schema, mask, name = "partial") {
6279
6381
  const checks = schema._zod.def.checks;
6280
6382
  if (checks && checks.length > 0) throw new Error(`.${name}() cannot be used on object schemas containing refinements`);
6383
+ const selected = mask ? new Set(maskedKeys(schema, mask)) : void 0;
6384
+ const newShape = {};
6385
+ mirrorShape(newShape, schema, Reflect.ownKeys(sourceShape(schema)), Class && ((value, key) => selected && !selected.has(key) ? value : new Class({
6386
+ type: "optional",
6387
+ innerType: value
6388
+ })));
6281
6389
  return clone(schema, mergeDefs(schema._zod.def, {
6282
- get shape() {
6283
- const oldShape = schema._zod.def.shape;
6284
- const shape = { ...oldShape };
6285
- if (mask) for (const key of Reflect.ownKeys(mask)) {
6286
- if (!Object.prototype.hasOwnProperty.call(oldShape, key)) throw new Error(`Unrecognized key: "${String(key)}"`);
6287
- if (!mask[key]) continue;
6288
- shape[key] = Class ? new Class({
6289
- type: "optional",
6290
- innerType: oldShape[key]
6291
- }) : oldShape[key];
6292
- }
6293
- else for (const key of Reflect.ownKeys(oldShape)) shape[key] = Class ? new Class({
6294
- type: "optional",
6295
- innerType: oldShape[key]
6296
- }) : oldShape[key];
6297
- assignProp(this, "shape", shape);
6298
- return shape;
6299
- },
6390
+ shape: newShape,
6300
6391
  checks: []
6301
6392
  }));
6302
6393
  }
6303
6394
  function required(Class, schema, mask) {
6304
- return clone(schema, mergeDefs(schema._zod.def, { get shape() {
6305
- const oldShape = schema._zod.def.shape;
6306
- const shape = { ...oldShape };
6307
- if (mask) for (const key of Reflect.ownKeys(mask)) {
6308
- if (!Object.prototype.hasOwnProperty.call(shape, key)) throw new Error(`Unrecognized key: "${String(key)}"`);
6309
- if (!mask[key]) continue;
6310
- shape[key] = new Class({
6311
- type: "nonoptional",
6312
- innerType: oldShape[key]
6313
- });
6314
- }
6315
- else for (const key of Reflect.ownKeys(oldShape)) shape[key] = new Class({
6316
- type: "nonoptional",
6317
- innerType: oldShape[key]
6318
- });
6319
- assignProp(this, "shape", shape);
6320
- return shape;
6321
- } }));
6395
+ const selected = mask ? new Set(maskedKeys(schema, mask)) : void 0;
6396
+ const newShape = {};
6397
+ mirrorShape(newShape, schema, Reflect.ownKeys(sourceShape(schema)), (value, key) => selected && !selected.has(key) ? value : new Class({
6398
+ type: "nonoptional",
6399
+ innerType: value
6400
+ }));
6401
+ return clone(schema, mergeDefs(schema._zod.def, { shape: newShape }));
6322
6402
  }
6323
6403
  function aborted(x, startIndex = 0) {
6324
6404
  if (x.aborted === true) return true;
@@ -6354,11 +6434,15 @@
6354
6434
  }
6355
6435
  const schemaError = iss.schema !== iss.inst ? iss.schema?._zod.def?.error : void 0;
6356
6436
  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";
6357
- const { inst: _inst, schema: _schema, continue: _continue, input: _input, ...rest } = iss;
6358
- rest.path ?? (rest.path = []);
6359
- rest.message = message;
6360
- if (ctx?.reportInput) rest.input = _input;
6361
- return rest;
6437
+ const full = {};
6438
+ for (const k of Object.keys(iss)) {
6439
+ if (k === "inst" || k === "schema" || k === "continue" || k === "input" || k === "__proto__") continue;
6440
+ full[k] = iss[k];
6441
+ }
6442
+ full.path ?? (full.path = []);
6443
+ full.message = message;
6444
+ if (ctx?.reportInput) full.input = iss.input;
6445
+ return full;
6362
6446
  }
6363
6447
  const highSurrogate = /[\uD800-\uDBFF]/;
6364
6448
  function codePointLength(str) {
@@ -6428,6 +6512,23 @@
6428
6512
  function hide(inst, key, value) {
6429
6513
  return own(inst, key, value, false);
6430
6514
  }
6515
+ /** 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. */
6516
+ function derived(computes, table) {
6517
+ for (const key in computes) {
6518
+ const compute = computes[key];
6519
+ Object.defineProperty(table, key, {
6520
+ configurable: true,
6521
+ enumerable: true,
6522
+ get() {
6523
+ return own(this, key, compute(this));
6524
+ },
6525
+ set(value) {
6526
+ own(this, key, value);
6527
+ }
6528
+ });
6529
+ }
6530
+ return table;
6531
+ }
6431
6532
  function defineBound(proto, key, fn) {
6432
6533
  Object.defineProperty(proto, key, {
6433
6534
  configurable: true,
@@ -6538,7 +6639,7 @@
6538
6639
  //#endregion
6539
6640
  //#region ../../node_modules/zod/v4/core/core.js
6540
6641
  var _a$1;
6541
- const _zodDesc$1 = {
6642
+ const _zodDesc = {
6542
6643
  value: void 0,
6543
6644
  enumerable: false
6544
6645
  };
@@ -6575,14 +6676,13 @@
6575
6676
  const initialized = protoMembers && /* @__PURE__ */ new WeakSet();
6576
6677
  function init(inst, def) {
6577
6678
  if (!inst._zod) {
6578
- _zodDesc$1.value = new Internals(def);
6679
+ _zodDesc.value = new Internals(def);
6579
6680
  try {
6580
- Object.defineProperty(inst, "_zod", _zodDesc$1);
6681
+ Object.defineProperty(inst, "_zod", _zodDesc);
6581
6682
  } finally {
6582
- _zodDesc$1.value = void 0;
6683
+ _zodDesc.value = void 0;
6583
6684
  }
6584
- }
6585
- if (inst._zod.traits.has(name)) return;
6685
+ } else if (inst._zod.traits.has(name)) return;
6586
6686
  inst._zod.traits.add(name);
6587
6687
  initializer(inst, def);
6588
6688
  if (initialized) {
@@ -6658,10 +6758,6 @@
6658
6758
  enumerable: true,
6659
6759
  configurable: true
6660
6760
  };
6661
- const _zodDesc = {
6662
- value: void 0,
6663
- enumerable: false
6664
- };
6665
6761
  const _issuesDesc = {
6666
6762
  value: void 0,
6667
6763
  enumerable: false
@@ -6669,11 +6765,8 @@
6669
6765
  const _installedToString = /* @__PURE__ */ new WeakSet([Object.prototype, Error.prototype]);
6670
6766
  const initializer$1 = (inst, def) => {
6671
6767
  inst.name = "$ZodError";
6672
- _zodDesc.value = inst._zod;
6673
- Object.defineProperty(inst, "_zod", _zodDesc);
6674
6768
  _issuesDesc.value = def;
6675
6769
  Object.defineProperty(inst, "issues", _issuesDesc);
6676
- _zodDesc.value = void 0;
6677
6770
  _issuesDesc.value = void 0;
6678
6771
  Object.defineProperty(inst, "message", _messageDesc);
6679
6772
  const proto = Object.getPrototypeOf(inst);
@@ -6702,7 +6795,7 @@
6702
6795
  }
6703
6796
  };
6704
6797
  const $ZodError = $constructor("$ZodError", initializer$1);
6705
- const $ZodRealError = $constructor("$ZodError", initializer$1, void 0, { Parent: Error });
6798
+ $constructor("$ZodError", initializer$1, void 0, { Parent: Error });
6706
6799
  /** Get-or-create `obj[key]` as an own data property. A path segment naming an inherited member
6707
6800
  * ("toString", "constructor") would otherwise read through to the prototype, and assigning
6708
6801
  * "__proto__" would hit the setter instead of creating a key. */
@@ -6823,15 +6916,30 @@
6823
6916
  issues: []
6824
6917
  }, ctx);
6825
6918
  if (result instanceof Promise) throw new $ZodAsyncError();
6826
- return result.issues.length ? {
6827
- success: false,
6828
- error: new (_Err ?? $ZodError)(result.issues.map((iss) => finalizeIssue(iss, ctx, config())))
6829
- } : {
6919
+ return result.issues.length ? failure(_Err, result.issues, ctx) : {
6830
6920
  success: true,
6831
6921
  data: result.value
6832
6922
  };
6833
6923
  };
6834
- const safeParse$1 = /* @__PURE__*/ _safeParse($ZodRealError);
6924
+ function failure(Err, issues, ctx) {
6925
+ let error;
6926
+ return {
6927
+ success: false,
6928
+ get error() {
6929
+ if (!error) {
6930
+ error = new Err(issues.map((iss) => finalizeIssue(iss, ctx, config())));
6931
+ issues = void 0;
6932
+ ctx = void 0;
6933
+ }
6934
+ return error;
6935
+ },
6936
+ set error(e) {
6937
+ error = e;
6938
+ issues = void 0;
6939
+ ctx = void 0;
6940
+ }
6941
+ };
6942
+ }
6835
6943
  const _safeParseAsync = (_Err) => async (schema, value, _ctx) => {
6836
6944
  const ctx = _ctx ? {
6837
6945
  ..._ctx,
@@ -6842,15 +6950,61 @@
6842
6950
  issues: []
6843
6951
  }, ctx);
6844
6952
  if (result instanceof Promise) result = await result;
6845
- return result.issues.length ? {
6846
- success: false,
6847
- error: new _Err(result.issues.map((iss) => finalizeIssue(iss, ctx, config())))
6848
- } : {
6953
+ return result.issues.length ? failure(_Err, result.issues, ctx) : {
6849
6954
  success: true,
6850
6955
  data: result.value
6851
6956
  };
6852
6957
  };
6853
- const safeParseAsync$1 = /* @__PURE__*/ _safeParseAsync($ZodRealError);
6958
+ const COMPILE_INVALID = /* @__PURE__ */ Symbol.for("zod.compile.invalid");
6959
+ const COMPILE_FALLBACK = /* @__PURE__ */ Symbol.for("zod.compile.fallback");
6960
+ const validate = ((schema, value, _ctx) => {
6961
+ const validator = schema._zod.bag.validator;
6962
+ if (validator !== void 0) {
6963
+ if (validator(value) !== COMPILE_INVALID) return true;
6964
+ if (validator.definite === true && _ctx === void 0) return false;
6965
+ }
6966
+ return validateFallback(schema, value, _ctx);
6967
+ });
6968
+ function validateFallback(schema, value, _ctx) {
6969
+ const ctx = _ctx ? {
6970
+ ..._ctx,
6971
+ async: false,
6972
+ abortEarly: true
6973
+ } : {
6974
+ async: false,
6975
+ abortEarly: true
6976
+ };
6977
+ const fallbackRun = schema._zod.bag.fallbackRun;
6978
+ let result;
6979
+ if (fallbackRun) {
6980
+ ctx[COMPILE_FALLBACK] = true;
6981
+ result = fallbackRun({
6982
+ value,
6983
+ issues: []
6984
+ }, ctx);
6985
+ } else result = schema._zod.run({
6986
+ value,
6987
+ issues: []
6988
+ }, ctx);
6989
+ if (result instanceof Promise) throw new $ZodAsyncError();
6990
+ return result.issues.length === 0;
6991
+ }
6992
+ const validateAsync$1 = async (schema, value, _ctx) => {
6993
+ const ctx = _ctx ? {
6994
+ ..._ctx,
6995
+ async: true,
6996
+ abortEarly: true
6997
+ } : {
6998
+ async: true,
6999
+ abortEarly: true
7000
+ };
7001
+ let result = schema._zod.run({
7002
+ value,
7003
+ issues: []
7004
+ }, ctx);
7005
+ if (result instanceof Promise) result = await result;
7006
+ return result.issues.length === 0;
7007
+ };
6854
7008
  const _encode = (_Err) => {
6855
7009
  const parse = _parse(_Err);
6856
7010
  const fn = (schema, value, _ctx, _params) => {
@@ -6935,8 +7089,8 @@
6935
7089
  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})$`);
6936
7090
  };
6937
7091
  /** Practical email validation */
6938
- const email = /^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/;
6939
- const _emoji$1 = `^[\\p{Extended_Pictographic}\\p{Emoji_Component}]+$`;
7092
+ 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,}$/;
7093
+ const _emoji$1 = `^(?=[\\s\\S]*[\\p{Extended_Pictographic}\\p{Regional_Indicator}\\u20E3])[\\p{Extended_Pictographic}\\p{Emoji_Component}]+$`;
6940
7094
  function emoji() {
6941
7095
  return new RegExp(_emoji$1, "u");
6942
7096
  }
@@ -6945,7 +7099,7 @@
6945
7099
  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])$/;
6946
7100
  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])$/;
6947
7101
  const base64 = /^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/;
6948
- const base64url = /^[A-Za-z0-9_-]*$/;
7102
+ const base64url = /^(?:[A-Za-z0-9_-]{4})*(?:[A-Za-z0-9_-]{2,3})?$/;
6949
7103
  const httpProtocol = /^https?$/;
6950
7104
  const e164 = /^\+[1-9]\d{6,14}$/;
6951
7105
  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])))`;
@@ -6973,10 +7127,7 @@
6973
7127
  const timeRegex = args.local ? `${qualified}|${timeSource({ precision: args.precision })}` : qualified;
6974
7128
  return new RegExp(`^${dateSource}T(?:${timeRegex})$`);
6975
7129
  }
6976
- const string$1 = (params) => {
6977
- const regex = params ? `[\\s\\S]{${params?.minimum ?? 0},${params?.maximum ?? ""}}` : `[\\s\\S]*`;
6978
- return new RegExp(`^${regex}$`);
6979
- };
7130
+ const anyString = /^[\s\S]{0,}$/;
6980
7131
  const integer = /^-?\d+$/;
6981
7132
  const number$1 = /^-?\d+(?:\.\d+)?$/;
6982
7133
  const boolean$1 = /^(?:true|false)$/i;
@@ -7003,14 +7154,6 @@
7003
7154
  const $ZodCheckLessThan = /*@__PURE__*/ $constructor("$ZodCheckLessThan", (inst, def) => {
7004
7155
  $ZodCheck.init(inst, def);
7005
7156
  const origin = numericOriginMap[typeof def.value];
7006
- inst._zod.onattach.push((inst) => {
7007
- const bag = inst._zod.bag;
7008
- const curr = (def.inclusive ? bag.maximum : bag.exclusiveMaximum) ?? Number.POSITIVE_INFINITY;
7009
- if (def.value < curr) {
7010
- if (def.inclusive) bag.maximum = def.value;
7011
- else bag.exclusiveMaximum = def.value;
7012
- }
7013
- });
7014
7157
  inst._zod.check = (payload) => {
7015
7158
  if (def.inclusive ? payload.value <= def.value : payload.value < def.value) return;
7016
7159
  payload.issues.push({
@@ -7027,14 +7170,6 @@
7027
7170
  const $ZodCheckGreaterThan = /*@__PURE__*/ $constructor("$ZodCheckGreaterThan", (inst, def) => {
7028
7171
  $ZodCheck.init(inst, def);
7029
7172
  const origin = numericOriginMap[typeof def.value];
7030
- inst._zod.onattach.push((inst) => {
7031
- const bag = inst._zod.bag;
7032
- const curr = (def.inclusive ? bag.minimum : bag.exclusiveMinimum) ?? Number.NEGATIVE_INFINITY;
7033
- if (def.value > curr) {
7034
- if (def.inclusive) bag.minimum = def.value;
7035
- else bag.exclusiveMinimum = def.value;
7036
- }
7037
- });
7038
7173
  inst._zod.check = (payload) => {
7039
7174
  if (def.inclusive ? payload.value >= def.value : payload.value > def.value) return;
7040
7175
  payload.issues.push({
@@ -7050,10 +7185,6 @@
7050
7185
  });
7051
7186
  const $ZodCheckMultipleOf = /*@__PURE__*/ $constructor("$ZodCheckMultipleOf", (inst, def) => {
7052
7187
  $ZodCheck.init(inst, def);
7053
- inst._zod.onattach.push((inst) => {
7054
- var _a;
7055
- (_a = inst._zod.bag).multipleOf ?? (_a.multipleOf = def.value);
7056
- });
7057
7188
  inst._zod.check = (payload) => {
7058
7189
  if (typeof payload.value !== typeof def.value) throw new Error("Cannot mix number and bigint in multiple_of check.");
7059
7190
  if (typeof payload.value === "bigint" ? def.value !== BigInt(0) && payload.value % def.value === BigInt(0) : floatSafeRemainder(payload.value, def.value) === 0) return;
@@ -7073,13 +7204,6 @@
7073
7204
  const isInt = def.format?.includes("int");
7074
7205
  const origin = isInt ? "int" : "number";
7075
7206
  const [minimum, maximum] = NUMBER_FORMAT_RANGES[def.format];
7076
- inst._zod.onattach.push((inst) => {
7077
- const bag = inst._zod.bag;
7078
- bag.format = def.format;
7079
- bag.minimum = minimum;
7080
- bag.maximum = maximum;
7081
- if (isInt) bag.pattern = integer;
7082
- });
7083
7207
  inst._zod.check = (payload) => {
7084
7208
  const input = payload.value;
7085
7209
  if (isInt) {
@@ -7142,10 +7266,6 @@
7142
7266
  var _a;
7143
7267
  $ZodCheck.init(inst, def);
7144
7268
  (_a = inst._zod.def).when ?? (_a.when = _whenHasLength);
7145
- inst._zod.onattach.push((inst) => {
7146
- const curr = inst._zod.bag.maximum ?? Number.POSITIVE_INFINITY;
7147
- if (def.maximum < curr) inst._zod.bag.maximum = def.maximum;
7148
- });
7149
7269
  inst._zod.check = (payload) => {
7150
7270
  const input = payload.value;
7151
7271
  const units = input.length;
@@ -7166,10 +7286,6 @@
7166
7286
  var _a;
7167
7287
  $ZodCheck.init(inst, def);
7168
7288
  (_a = inst._zod.def).when ?? (_a.when = _whenHasLength);
7169
- inst._zod.onattach.push((inst) => {
7170
- const curr = inst._zod.bag.minimum ?? Number.NEGATIVE_INFINITY;
7171
- if (def.minimum > curr) inst._zod.bag.minimum = def.minimum;
7172
- });
7173
7289
  inst._zod.check = (payload) => {
7174
7290
  const input = payload.value;
7175
7291
  const units = input.length;
@@ -7190,12 +7306,6 @@
7190
7306
  var _a;
7191
7307
  $ZodCheck.init(inst, def);
7192
7308
  (_a = inst._zod.def).when ?? (_a.when = _whenHasLength);
7193
- inst._zod.onattach.push((inst) => {
7194
- const bag = inst._zod.bag;
7195
- bag.minimum = def.length;
7196
- bag.maximum = def.length;
7197
- bag.length = def.length;
7198
- });
7199
7309
  inst._zod.check = (payload) => {
7200
7310
  const input = payload.value;
7201
7311
  const units = input.length;
@@ -7223,14 +7333,6 @@
7223
7333
  const $ZodCheckStringFormat = /*@__PURE__*/ $constructor("$ZodCheckStringFormat", (inst, def) => {
7224
7334
  var _a, _b;
7225
7335
  $ZodCheck.init(inst, def);
7226
- inst._zod.onattach.push((inst) => {
7227
- const bag = inst._zod.bag;
7228
- bag.format = def.format;
7229
- if (def.pattern) {
7230
- bag.patterns ?? (bag.patterns = /* @__PURE__ */ new Set());
7231
- bag.patterns.add(def.pattern);
7232
- }
7233
- });
7234
7336
  if (def.pattern) (_a = inst._zod).check ?? (_a.check = (payload) => {
7235
7337
  def.pattern.lastIndex = 0;
7236
7338
  if (def.pattern.test(payload.value)) return;
@@ -7273,13 +7375,7 @@
7273
7375
  const $ZodCheckIncludes = /*@__PURE__*/ $constructor("$ZodCheckIncludes", (inst, def) => {
7274
7376
  $ZodCheck.init(inst, def);
7275
7377
  const escapedRegex = escapeRegex(def.includes);
7276
- const pattern = new RegExp(typeof def.position === "number" ? `^.{${def.position},}${escapedRegex}` : escapedRegex);
7277
- def.pattern = pattern;
7278
- inst._zod.onattach.push((inst) => {
7279
- const bag = inst._zod.bag;
7280
- bag.patterns ?? (bag.patterns = /* @__PURE__ */ new Set());
7281
- bag.patterns.add(pattern);
7282
- });
7378
+ def.pattern = new RegExp(typeof def.position === "number" ? `^.{${def.position},}${escapedRegex}` : escapedRegex);
7283
7379
  inst._zod.check = (payload) => {
7284
7380
  if (payload.value.includes(def.includes, def.position)) return;
7285
7381
  payload.issues.push({
@@ -7297,11 +7393,6 @@
7297
7393
  $ZodCheck.init(inst, def);
7298
7394
  const pattern = new RegExp(`^${escapeRegex(def.prefix)}.*`);
7299
7395
  def.pattern ?? (def.pattern = pattern);
7300
- inst._zod.onattach.push((inst) => {
7301
- const bag = inst._zod.bag;
7302
- bag.patterns ?? (bag.patterns = /* @__PURE__ */ new Set());
7303
- bag.patterns.add(pattern);
7304
- });
7305
7396
  inst._zod.check = (payload) => {
7306
7397
  if (payload.value.startsWith(def.prefix)) return;
7307
7398
  payload.issues.push({
@@ -7319,11 +7410,6 @@
7319
7410
  $ZodCheck.init(inst, def);
7320
7411
  const pattern = new RegExp(`.*${escapeRegex(def.suffix)}$`);
7321
7412
  def.pattern ?? (def.pattern = pattern);
7322
- inst._zod.onattach.push((inst) => {
7323
- const bag = inst._zod.bag;
7324
- bag.patterns ?? (bag.patterns = /* @__PURE__ */ new Set());
7325
- bag.patterns.add(pattern);
7326
- });
7327
7413
  inst._zod.check = (payload) => {
7328
7414
  if (payload.value.endsWith(def.suffix)) return;
7329
7415
  payload.issues.push({
@@ -7354,8 +7440,11 @@
7354
7440
  }
7355
7441
  indented(fn) {
7356
7442
  this.indent += 1;
7357
- fn(this);
7358
- this.indent -= 1;
7443
+ try {
7444
+ fn(this);
7445
+ } finally {
7446
+ this.indent -= 1;
7447
+ }
7359
7448
  }
7360
7449
  write(arg) {
7361
7450
  if (typeof arg === "function") {
@@ -7378,8 +7467,8 @@
7378
7467
  //#region ../../node_modules/zod/v4/core/versions.js
7379
7468
  const version$1 = {
7380
7469
  major: 4,
7381
- minor: 5,
7382
- patch: 2
7470
+ minor: 6,
7471
+ patch: 5
7383
7472
  };
7384
7473
  //#endregion
7385
7474
  //#region ../../node_modules/zod/v4/core/schemas.js
@@ -7471,15 +7560,26 @@
7471
7560
  }
7472
7561
  });
7473
7562
  /** The Standard Schema surface for `inst`. Shared so wrappers can extend it without forcing it. */
7474
- const toStandardResult = (r) => r.success ? { value: r.data } : { issues: r.error?.issues };
7563
+ const toStandardResult = (r, ctx) => r.issues.length ? { issues: r.issues.map((iss) => finalizeIssue(iss, ctx, config())) } : { value: r.value };
7564
+ async function validateAsync(inst, value) {
7565
+ const ctx = { async: true };
7566
+ return toStandardResult(await inst._zod.run({
7567
+ value,
7568
+ issues: []
7569
+ }, ctx), ctx);
7570
+ }
7475
7571
  function standardProps(inst) {
7476
7572
  return {
7477
7573
  validate: (value) => {
7574
+ const ctx = { async: false };
7478
7575
  try {
7479
- return toStandardResult(safeParse$1(inst, value));
7480
- } catch (_) {
7481
- return safeParseAsync$1(inst, value).then(toStandardResult);
7482
- }
7576
+ const r = inst._zod.run({
7577
+ value,
7578
+ issues: []
7579
+ }, ctx);
7580
+ if (!(r instanceof Promise)) return toStandardResult(r, ctx);
7581
+ } catch (_) {}
7582
+ return validateAsync(inst, value);
7483
7583
  },
7484
7584
  vendor: "zod",
7485
7585
  version: 1
@@ -7487,7 +7587,7 @@
7487
7587
  }
7488
7588
  const $ZodString = /*@__PURE__*/ $constructor("$ZodString", (inst, def) => {
7489
7589
  $ZodType.init(inst, def);
7490
- inst._zod.pattern = [...inst?._zod.bag?.patterns ?? []].pop() ?? string$1(inst._zod.bag);
7590
+ inst._zod.pattern = def.pattern ?? anyString;
7491
7591
  inst._zod.parse = (payload, _) => {
7492
7592
  if (def.coerce) try {
7493
7593
  payload.value = String(payload.value);
@@ -7531,10 +7631,27 @@
7531
7631
  def.pattern ?? (def.pattern = email);
7532
7632
  $ZodStringFormat.init(inst, def);
7533
7633
  });
7534
- /** Parses a URL for `$ZodURL`, applying the one guard the URL constructor cannot express. Returns the parsed URL, or a code naming the stage that rejected it — the runtime needs that distinction to pick an issue note, and compiled code only needs to know it is not a URL. */
7634
+ function canParseURL(input) {
7635
+ try {
7636
+ if (typeof URL !== "undefined" && typeof URL.canParse === "function") return URL.canParse(input);
7637
+ new URL(input);
7638
+ return true;
7639
+ } catch {
7640
+ return false;
7641
+ }
7642
+ }
7643
+ function validateURL(trimmed, def) {
7644
+ if (!("normalize" in def) && !("hostname" in def) && !("protocol" in def)) return canParseURL(trimmed) || 2;
7645
+ return parseURLObject(trimmed, def);
7646
+ }
7647
+ /** Parses a URL while preserving the non-normalizing HTTP guard. */
7535
7648
  function parseURLObject(trimmed, def) {
7536
7649
  if (!def.normalize && def.protocol?.source === httpProtocol.source && !/^https?:\/\//i.test(trimmed)) return 1;
7537
7650
  try {
7651
+ if (typeof URL !== "undefined") {
7652
+ const URLStatic = URL;
7653
+ if (typeof URLStatic.parse === "function") return URLStatic.parse(trimmed) ?? 2;
7654
+ }
7538
7655
  return new URL(trimmed);
7539
7656
  } catch {
7540
7657
  return 2;
@@ -7558,7 +7675,7 @@
7558
7675
  inst._zod.check = (payload) => {
7559
7676
  try {
7560
7677
  const trimmed = payload.value.trim();
7561
- const url = parseURLObject(trimmed, def);
7678
+ const url = validateURL(trimmed, def);
7562
7679
  if (url === 1) {
7563
7680
  payload.issues.push({
7564
7681
  code: "invalid_format",
@@ -7580,6 +7697,10 @@
7580
7697
  });
7581
7698
  return;
7582
7699
  }
7700
+ if (url === true) {
7701
+ payload.value = stripTabAndNewline(trimmed);
7702
+ return;
7703
+ }
7583
7704
  if (def.hostname && !urlHostnameOk(url, def.hostname)) payload.issues.push({
7584
7705
  code: "invalid_format",
7585
7706
  format: "url",
@@ -7648,12 +7769,6 @@
7648
7769
  const $ZodISODateTime = /*@__PURE__*/ $constructor("$ZodISODateTime", (inst, def) => {
7649
7770
  def.pattern ?? (def.pattern = datetime(def));
7650
7771
  $ZodStringFormat.init(inst, def);
7651
- if (def.local || def.precision === -1) {
7652
- inst._zod.bag.laxFormat = true;
7653
- inst._zod.onattach.push((s) => {
7654
- s._zod.bag.laxFormat = true;
7655
- });
7656
- }
7657
7772
  });
7658
7773
  const $ZodISODate = /*@__PURE__*/ $constructor("$ZodISODate", (inst, def) => {
7659
7774
  def.pattern ?? (def.pattern = date$1);
@@ -7670,23 +7785,16 @@
7670
7785
  const $ZodIPv4 = /*@__PURE__*/ $constructor("$ZodIPv4", (inst, def) => {
7671
7786
  def.pattern ?? (def.pattern = ipv4);
7672
7787
  $ZodStringFormat.init(inst, def);
7673
- inst._zod.bag.format = `ipv4`;
7674
7788
  });
7675
7789
  /** 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`. */
7676
7790
  const ipv6Alphabet = /^[0-9a-fA-F:.]+$/;
7677
7791
  function isValidIPv6(value) {
7678
7792
  if (!ipv6Alphabet.test(value)) return false;
7679
- try {
7680
- new URL(`http://[${value}]`);
7681
- return true;
7682
- } catch {
7683
- return false;
7684
- }
7793
+ return canParseURL(`http://[${value}]`);
7685
7794
  }
7686
7795
  const $ZodIPv6 = /*@__PURE__*/ $constructor("$ZodIPv6", (inst, def) => {
7687
7796
  def.pattern ?? (def.pattern = ipv6);
7688
7797
  $ZodStringFormat.init(inst, def);
7689
- inst._zod.bag.format = `ipv6`;
7690
7798
  inst._zod.check = (payload) => {
7691
7799
  if (!isValidIPv6(payload.value)) payload.issues.push({
7692
7800
  code: "invalid_format",
@@ -7735,10 +7843,10 @@
7735
7843
  return false;
7736
7844
  }
7737
7845
  }
7846
+ const base64Charset = /^[0-9a-zA-Z+/]*={0,2}$/;
7738
7847
  const $ZodBase64 = /*@__PURE__*/ $constructor("$ZodBase64", (inst, def) => {
7739
- def.pattern ?? (def.pattern = base64);
7848
+ def.pattern ?? (def.pattern = base64Charset);
7740
7849
  $ZodStringFormat.init(inst, def);
7741
- inst._zod.bag.contentEncoding = "base64";
7742
7850
  inst._zod.check = (payload) => {
7743
7851
  if (isValidBase64(payload.value)) return;
7744
7852
  payload.issues.push({
@@ -7750,15 +7858,15 @@
7750
7858
  });
7751
7859
  };
7752
7860
  });
7861
+ const base64urlCharset = /^[A-Za-z0-9_-]*$/;
7753
7862
  function isValidBase64URL(data) {
7754
- if (!base64url.test(data)) return false;
7863
+ if (!base64urlCharset.test(data)) return false;
7755
7864
  const base64 = data.replace(/[-_]/g, (c) => c === "-" ? "+" : "/");
7756
7865
  return isValidBase64(base64.padEnd(Math.ceil(base64.length / 4) * 4, "="));
7757
7866
  }
7758
7867
  const $ZodBase64URL = /*@__PURE__*/ $constructor("$ZodBase64URL", (inst, def) => {
7759
- def.pattern ?? (def.pattern = base64url);
7868
+ def.pattern ?? (def.pattern = base64urlCharset);
7760
7869
  $ZodStringFormat.init(inst, def);
7761
- inst._zod.bag.contentEncoding = "base64url";
7762
7870
  inst._zod.check = (payload) => {
7763
7871
  if (isValidBase64URL(payload.value)) return;
7764
7872
  payload.issues.push({
@@ -7804,7 +7912,7 @@
7804
7912
  });
7805
7913
  const $ZodNumber = /*@__PURE__*/ $constructor("$ZodNumber", (inst, def) => {
7806
7914
  $ZodType.init(inst, def);
7807
- inst._zod.pattern = inst._zod.bag.pattern ?? number$1;
7915
+ inst._zod.pattern = number$1;
7808
7916
  inst._zod.parse = (payload, _ctx) => {
7809
7917
  if (def.coerce) try {
7810
7918
  payload.value = Number(payload.value);
@@ -7904,6 +8012,7 @@
7904
8012
  }
7905
8013
  payload.value = memo ? memo.alloc(inst, payload, Array(input.length), ctx) : Array(input.length);
7906
8014
  const proms = [];
8015
+ const abortEarly = ctx?.abortEarly;
7907
8016
  for (let i = 0; i < input.length; i++) {
7908
8017
  const item = input[i];
7909
8018
  const result = def.element._zod.run({
@@ -7911,7 +8020,10 @@
7911
8020
  issues: []
7912
8021
  }, ctx);
7913
8022
  if (result instanceof Promise) proms.push(result.then((result) => handleArrayResult(result, payload, i)));
7914
- else handleArrayResult(result, payload, i);
8023
+ else {
8024
+ handleArrayResult(result, payload, i);
8025
+ if (abortEarly && result.issues.length !== 0 && aborted(result)) break;
8026
+ }
7915
8027
  }
7916
8028
  if (proms.length) return Promise.all(proms).then(() => payload);
7917
8029
  return payload;
@@ -7935,7 +8047,7 @@
7935
8047
  return;
7936
8048
  }
7937
8049
  if (result.value === void 0) {
7938
- if (isPresent) final.value[key] = void 0;
8050
+ if (isPresent || optin === "defaulted" && !isOptionalOut) final.value[key] = void 0;
7939
8051
  } else final.value[key] = result.value;
7940
8052
  }
7941
8053
  const NO_SYMBOL_KEYS = [];
@@ -7955,14 +8067,19 @@
7955
8067
  optionalKeys: new Set(okeys)
7956
8068
  };
7957
8069
  }
7958
- function handleCatchall(proms, input, payload, ctx, def, inst) {
8070
+ function handleCatchall(proms, input, payload, ctx, def, inst, abortEarly) {
7959
8071
  const unrecognized = [];
7960
8072
  const keySet = def.keySet;
7961
8073
  const _catchall = def.catchall._zod;
7962
8074
  const t = _catchall.def.type;
7963
8075
  const optin = _catchall.optin;
7964
8076
  const optout = _catchall.optout;
8077
+ let seen = 0;
7965
8078
  for (const key in input) {
8079
+ if (abortEarly && payload.issues.length !== seen) {
8080
+ if (aborted(payload, seen)) break;
8081
+ seen = payload.issues.length;
8082
+ }
7966
8083
  if (keySet.has(key)) continue;
7967
8084
  if (key === "__proto__") {
7968
8085
  if (t === "never") unrecognized.push(key);
@@ -7991,18 +8108,19 @@
7991
8108
  return payload;
7992
8109
  });
7993
8110
  }
7994
- const propShapes = /* @__PURE__ */ new WeakMap();
7995
8111
  const $ZodObject = /*@__PURE__*/ $constructor("$ZodObject", (inst, def) => {
7996
8112
  $ZodType.init(inst, def);
7997
- if (!Object.getOwnPropertyDescriptor(def, "shape")?.get) {
7998
- const sh = def.shape;
7999
- propShapes.set(def, sh);
8000
- Object.defineProperty(def, "shape", { get: () => {
8113
+ const desc = Object.getOwnPropertyDescriptor(def, "shape");
8114
+ const sh = desc?.get ? desc.get.raw : def.shape ?? {};
8115
+ if (sh) {
8116
+ const get = () => {
8001
8117
  const newSh = { ...sh };
8002
8118
  Object.defineProperty(def, "shape", { value: newSh });
8003
- propShapes.set(def, newSh);
8119
+ get.raw = newSh;
8004
8120
  return newSh;
8005
- } });
8121
+ };
8122
+ get.raw = sh;
8123
+ Object.defineProperty(def, "shape", { get });
8006
8124
  }
8007
8125
  const _normalized = cached(() => normalizeDef(def));
8008
8126
  defineLazyInternal(inst, "propValues", (zod) => {
@@ -8018,7 +8136,7 @@
8018
8136
  }
8019
8137
  return propValues;
8020
8138
  });
8021
- const isObject$1 = isObject;
8139
+ const isObject$2 = isObject;
8022
8140
  const catchall = def.catchall;
8023
8141
  let value;
8024
8142
  const memo = globalConfig.memoizer;
@@ -8026,7 +8144,7 @@
8026
8144
  inst._zod.parse = (payload, ctx) => {
8027
8145
  value ?? (value = _normalized.value);
8028
8146
  const input = payload.value;
8029
- if (!isObject$1(input)) {
8147
+ if (!isObject$2(input)) {
8030
8148
  payload.issues.push({
8031
8149
  expected: "object",
8032
8150
  code: "invalid_type",
@@ -8038,7 +8156,13 @@
8038
8156
  payload.value = memo ? memo.alloc(inst, payload, {}, ctx) : {};
8039
8157
  const proms = [];
8040
8158
  const shape = value.shape;
8159
+ const abortEarly = ctx?.abortEarly;
8160
+ let seen = payload.issues.length;
8041
8161
  for (const key of value.allKeys) {
8162
+ if (abortEarly && payload.issues.length !== seen) {
8163
+ if (aborted(payload, seen)) break;
8164
+ seen = payload.issues.length;
8165
+ }
8042
8166
  if (key === "__proto__") continue;
8043
8167
  const el = shape[key];
8044
8168
  const optin = el._zod.optin;
@@ -8051,7 +8175,7 @@
8051
8175
  else handlePropertyResult(r, payload, key, input, optin, optout);
8052
8176
  }
8053
8177
  if (!catchall) return proms.length ? Promise.all(proms).then(() => payload) : payload;
8054
- return handleCatchall(proms, input, payload, ctx, _normalized.value, inst);
8178
+ return handleCatchall(proms, input, payload, ctx, _normalized.value, inst, abortEarly === true);
8055
8179
  };
8056
8180
  });
8057
8181
  const $ZodObjectJIT = /*@__PURE__*/ $constructor("$ZodObjectJIT", (inst, def) => {
@@ -8070,10 +8194,16 @@
8070
8194
  });
8071
8195
  const parseStr = (k) => `shape[${k}]._zod.run({ value: input[${k}], issues: [] }, ctx)`;
8072
8196
  const prefixStr = (id, k) => `
8197
+ let ${id}_ab = false;
8073
8198
  for (let i = 0; i < ${id}.issues.length; i++) {
8074
8199
  const iss = ${id}.issues[i];
8075
8200
  iss.path = iss.path ? [${k}, ...iss.path] : [${k}];
8076
8201
  payload.issues.push(iss);
8202
+ if (iss.continue !== true) ${id}_ab = true;
8203
+ }
8204
+ if (${id}_ab && ctx && ctx.abortEarly) {
8205
+ payload.value = newResult;
8206
+ return payload;
8077
8207
  }`;
8078
8208
  doc.write(`const input = payload.value;`);
8079
8209
  const ids = Object.create(null);
@@ -8115,6 +8245,10 @@
8115
8245
  input: undefined,
8116
8246
  path: [${k}]
8117
8247
  });
8248
+ if (ctx && ctx.abortEarly) {
8249
+ payload.value = newResult;
8250
+ return payload;
8251
+ }
8118
8252
  }
8119
8253
 
8120
8254
  if (${id}_present) {
@@ -8122,26 +8256,25 @@
8122
8256
  }
8123
8257
 
8124
8258
  `);
8125
- else doc.write(`
8259
+ else {
8260
+ doc.write(`
8126
8261
  if (${id}.issues.length) {${prefixStr(id, k)}
8127
8262
  }
8128
-
8129
- if (${id}.value === undefined) {
8130
- if (${isPresent}) {
8131
- newResult[${k}] = undefined;
8132
- }
8133
- } else {
8263
+ `);
8264
+ if (optin === "defaulted") doc.write(`newResult[${k}] = ${id}.value;`);
8265
+ else doc.write(`
8266
+ if (${id}.value !== undefined || ${isPresent}) {
8134
8267
  newResult[${k}] = ${id}.value;
8135
8268
  }
8136
-
8137
8269
  `);
8270
+ }
8138
8271
  }
8139
8272
  doc.write(`payload.value = newResult;`);
8140
8273
  doc.write(`return payload;`);
8141
8274
  return doc.compile();
8142
8275
  };
8143
8276
  let fastpass;
8144
- const isObject$2 = isObject;
8277
+ const isObject$1 = isObject;
8145
8278
  const jit = !globalConfig.jitless;
8146
8279
  const fastEnabled = jit && allowsEval.value;
8147
8280
  const catchall = def.catchall;
@@ -8149,7 +8282,7 @@
8149
8282
  inst._zod.parse = (payload, ctx) => {
8150
8283
  value ?? (value = _normalized.value);
8151
8284
  const input = payload.value;
8152
- if (!isObject$2(input)) {
8285
+ if (!isObject$1(input)) {
8153
8286
  payload.issues.push({
8154
8287
  expected: "object",
8155
8288
  code: "invalid_type",
@@ -8162,7 +8295,7 @@
8162
8295
  if (!fastpass) fastpass = generateFastpass(def.shape);
8163
8296
  payload = fastpass(payload, ctx);
8164
8297
  if (!catchall) return payload;
8165
- return handleCatchall([], input, payload, ctx, value, inst);
8298
+ return handleCatchall([], input, payload, ctx, value, inst, ctx?.abortEarly === true);
8166
8299
  }
8167
8300
  return superParse(payload, ctx);
8168
8301
  };
@@ -8378,6 +8511,8 @@
8378
8511
  });
8379
8512
  }
8380
8513
  const itemResults = new Array(items.length);
8514
+ const abortEarly = def.rest ? ctx?.abortEarly : void 0;
8515
+ let itemAborted = false;
8381
8516
  for (let i = 0; i < items.length; i++) {
8382
8517
  const r = items[i]._zod.run({
8383
8518
  value: input[i],
@@ -8386,12 +8521,20 @@
8386
8521
  if (r instanceof Promise) proms.push(r.then((rr) => {
8387
8522
  itemResults[i] = rr;
8388
8523
  }));
8389
- else itemResults[i] = r;
8524
+ else {
8525
+ itemResults[i] = r;
8526
+ if (abortEarly && !itemAborted && r.issues.length) itemAborted = aborted(r);
8527
+ }
8390
8528
  }
8391
- if (def.rest) {
8529
+ if (def.rest && !itemAborted) {
8392
8530
  let i = items.length - 1;
8393
8531
  const rest = input.slice(items.length);
8532
+ let seen = payload.issues.length;
8394
8533
  for (const el of rest) {
8534
+ if (abortEarly && payload.issues.length !== seen) {
8535
+ if (aborted(payload, seen)) break;
8536
+ seen = payload.issues.length;
8537
+ }
8395
8538
  i++;
8396
8539
  const result = def.rest._zod.run({
8397
8540
  value: el,
@@ -8571,8 +8714,10 @@
8571
8714
  const values = getEnumValues(def.entries);
8572
8715
  const valuesSet = new Set(values);
8573
8716
  inst._zod.values = valuesSet;
8574
- const patternValues = values.filter((k) => propertyKeyTypes.has(typeof k));
8575
- inst._zod.pattern = new RegExp(patternValues.length ? `^(${patternValues.map((o) => escapeRegex(o.toString())).join("|")})$` : "^[^\\s\\S]$");
8717
+ defineLazyInternal(inst, "pattern", (zod) => {
8718
+ const patternValues = getEnumValues(zod.def.entries).filter((k) => propertyKeyTypes.has(typeof k));
8719
+ return new RegExp(patternValues.length ? `^(${patternValues.map((o) => escapeRegex(o.toString())).join("|")})$` : "^[^\\s\\S]$");
8720
+ });
8576
8721
  inst._zod.parse = (payload, _ctx) => {
8577
8722
  const input = payload.value;
8578
8723
  if (valuesSet.has(input)) return payload;
@@ -8817,6 +8962,9 @@
8817
8962
  /** Keyed off the context object every schema in one parse call already shares. */
8818
8963
  const STATE = "~memo";
8819
8964
  const NO_ISSUES = [];
8965
+ function isRef(value) {
8966
+ return value !== null && typeof value === "object";
8967
+ }
8820
8968
  function cloneIssues(issues) {
8821
8969
  return issues.map((iss) => iss.path ? {
8822
8970
  ...iss,
@@ -8824,36 +8972,131 @@
8824
8972
  } : { ...iss });
8825
8973
  }
8826
8974
  const recursive = /*@__PURE__*/ new WeakMap();
8975
+ /** What the walk established, in order of certainty: ordered so the strongest answer among children wins. */
8976
+ const NONE = 0;
8977
+ const ASSUMED = 1;
8978
+ const PROVEN = 2;
8827
8979
  /** Whether this schema's subtree contains a cycle, so one parse can re-enter it. */
8828
- function isRecursive(inst, stack) {
8980
+ function isRecursive(inst, stack, resolve) {
8829
8981
  const cached = recursive.get(inst);
8830
- if (cached !== void 0) return cached;
8831
- if (stack.has(inst)) return true;
8982
+ if (cached !== void 0) return cached ? PROVEN : NONE;
8983
+ if (stack.has(inst)) return PROVEN;
8832
8984
  stack.add(inst);
8833
- let result = false;
8985
+ let result = NONE;
8834
8986
  const check = (child) => {
8835
- if (!result && child?._zod && isRecursive(child, stack)) result = true;
8987
+ if (result !== PROVEN && child?._zod) {
8988
+ const answer = isRecursive(child, stack, resolve);
8989
+ if (answer > result) result = answer;
8990
+ }
8991
+ };
8992
+ const shape = (sh, spread) => {
8993
+ let answer = NONE;
8994
+ for (const key of Reflect.ownKeys(sh)) {
8995
+ const desc = Object.getOwnPropertyDescriptor(sh, key);
8996
+ if (spread && !desc.enumerable) continue;
8997
+ const child = desc.get ? ASSUMED : desc.value?._zod ? isRecursive(desc.value, stack, resolve) : NONE;
8998
+ if (child > answer) answer = child;
8999
+ }
9000
+ return answer;
9001
+ };
9002
+ const merge = (answer) => {
9003
+ if (answer > result) result = answer;
8836
9004
  };
8837
9005
  const def = inst._zod.def;
8838
- if (def.type === "lazy") check(inst._zod.innerType);
8839
- else {
8840
- const shape = def.shape;
8841
- if (shape) for (const key of Reflect.ownKeys(shape)) check(shape[key]);
8842
- for (const key in def) {
8843
- const value = def[key];
9006
+ switch (def.type) {
9007
+ case "object": {
9008
+ const raw = rawShape(def);
9009
+ merge(raw ? shape(raw, true) : ASSUMED);
9010
+ check(def.catchall);
9011
+ break;
9012
+ }
9013
+ case "array":
9014
+ check(def.element);
9015
+ break;
9016
+ case "tuple":
9017
+ for (const el of def.items) check(el);
9018
+ check(def.rest);
9019
+ break;
9020
+ case "record":
9021
+ case "map":
9022
+ check(def.keyType);
9023
+ check(def.valueType);
9024
+ break;
9025
+ case "set":
9026
+ check(def.valueType);
9027
+ break;
9028
+ case "union":
9029
+ for (const el of def.options) check(el);
9030
+ break;
9031
+ case "intersection":
9032
+ check(def.left);
9033
+ check(def.right);
9034
+ break;
9035
+ case "optional":
9036
+ case "nullable":
9037
+ case "default":
9038
+ case "prefault":
9039
+ case "catch":
9040
+ case "readonly":
9041
+ case "nonoptional":
9042
+ case "promise":
9043
+ case "success":
9044
+ check(def.innerType);
9045
+ break;
9046
+ case "pipe":
9047
+ check(def.in);
9048
+ check(def.out);
9049
+ break;
9050
+ case "function":
9051
+ check(def.input);
9052
+ check(def.output);
9053
+ break;
9054
+ case "lazy": {
9055
+ const inner = def._cachedInner ?? (resolve ? inst._zod.innerType : void 0);
9056
+ merge(inner ? isRecursive(inner, stack, false) : ASSUMED);
9057
+ break;
9058
+ }
9059
+ case "template_literal":
9060
+ case "string":
9061
+ case "number":
9062
+ case "int":
9063
+ case "boolean":
9064
+ case "bigint":
9065
+ case "symbol":
9066
+ case "undefined":
9067
+ case "null":
9068
+ case "void":
9069
+ case "never":
9070
+ case "any":
9071
+ case "unknown":
9072
+ case "date":
9073
+ case "nan":
9074
+ case "enum":
9075
+ case "literal":
9076
+ case "file":
9077
+ case "transform":
9078
+ case "custom": break;
9079
+ default: for (const key in def) {
9080
+ const desc = Object.getOwnPropertyDescriptor(def, key);
9081
+ if (!desc || desc.get) continue;
9082
+ const value = desc.value;
8844
9083
  if (!value || typeof value !== "object") continue;
8845
9084
  if (value._zod) check(value);
8846
9085
  else if (Array.isArray(value)) for (const el of value) check(el);
8847
9086
  }
8848
9087
  }
8849
9088
  stack.delete(inst);
8850
- recursive.set(inst, result);
8851
- return result;
9089
+ return settle(inst, result);
9090
+ }
9091
+ /** An assumed answer must not outlive the resolution that settles it, so only a certain one is cached. */
9092
+ function settle(inst, answer) {
9093
+ if (answer !== ASSUMED) recursive.set(inst, answer === PROVEN);
9094
+ return answer;
8852
9095
  }
8853
9096
  function bucketFor(state, inst) {
8854
9097
  let bucket = state.buckets.get(inst);
8855
9098
  if (!bucket) {
8856
- bucket = /* @__PURE__ */ new Map();
9099
+ bucket = /* @__PURE__ */ new WeakMap();
8857
9100
  state.buckets.set(inst, bucket);
8858
9101
  }
8859
9102
  return bucket;
@@ -8889,6 +9132,7 @@
8889
9132
  attach(inst) {
8890
9133
  var _a;
8891
9134
  let isRecursiveInst;
9135
+ let rechecked = false;
8892
9136
  let lastCtx;
8893
9137
  let lastBucket;
8894
9138
  (_a = inst._zod).deferred ?? (_a.deferred = []);
@@ -8896,19 +9140,21 @@
8896
9140
  const base = inst._zod.parse;
8897
9141
  const wrapped = (payload, ctx) => {
8898
9142
  if (isRecursiveInst === void 0) {
8899
- isRecursiveInst = isRecursive(inst, /* @__PURE__ */ new Set());
8900
- if (!isRecursiveInst) {
9143
+ const walked = isRecursive(inst, /* @__PURE__ */ new Set(), false);
9144
+ if (walked === NONE) {
8901
9145
  inst._zod.parse = base;
8902
9146
  if (inst._zod.run === wrapped) inst._zod.run = base;
8903
9147
  return base(payload, ctx);
8904
9148
  }
9149
+ if (walked === PROVEN || rechecked) isRecursiveInst = true;
9150
+ else rechecked = true;
8905
9151
  }
8906
9152
  const input = payload.value;
8907
- if (input === null || typeof input !== "object") return base(payload, ctx);
9153
+ if (!isRef(input)) return base(payload, ctx);
8908
9154
  let state = ctx[STATE];
8909
9155
  if (!state) {
8910
9156
  state = {
8911
- buckets: /* @__PURE__ */ new Map(),
9157
+ buckets: /* @__PURE__ */ new WeakMap(),
8912
9158
  backEdges: void 0
8913
9159
  };
8914
9160
  ctx[STATE] = state;
@@ -8927,7 +9173,7 @@
8927
9173
  if (hit.issues.length) payload.issues.push(...cloneIssues(hit.issues));
8928
9174
  } else {
8929
9175
  payload.memo = true;
8930
- state.backEdges ?? (state.backEdges = /* @__PURE__ */ new Set());
9176
+ state.backEdges ?? (state.backEdges = /* @__PURE__ */ new WeakSet());
8931
9177
  state.backEdges.add(hit.value);
8932
9178
  }
8933
9179
  return payload;
@@ -8956,7 +9202,7 @@
8956
9202
  /** Whether this value is a node a back-edge resolved to before it finished. */
8957
9203
  function isBackEdge(ctx, value) {
8958
9204
  const backEdges = ctx[STATE]?.backEdges;
8959
- return backEdges !== void 0 && value !== null && typeof value === "object" && backEdges.has(value);
9205
+ return backEdges !== void 0 && isRef(value) && backEdges.has(value);
8960
9206
  }
8961
9207
  //#endregion
8962
9208
  //#region ../../node_modules/zod/v4/locales/en.js
@@ -9014,7 +9260,9 @@
9014
9260
  base64url: "base64url-encoded string",
9015
9261
  json_string: "JSON string",
9016
9262
  e164: "E.164 number",
9263
+ currency_code: "currency code",
9017
9264
  credit_card: "credit card number",
9265
+ iban: "IBAN",
9018
9266
  jwt: "JWT",
9019
9267
  template_literal: "input"
9020
9268
  };
@@ -9113,12 +9361,16 @@
9113
9361
  const globalRegistry = globalThis.__zod_globalRegistry;
9114
9362
  //#endregion
9115
9363
  //#region ../../node_modules/zod/v4/core/api.js
9364
+ function snapshotChecks(def) {
9365
+ if (def.checks) def.checks = [...def.checks];
9366
+ return def;
9367
+ }
9116
9368
  // @__NO_SIDE_EFFECTS__
9117
9369
  function _string(Class, params) {
9118
- return new Class({
9370
+ return new Class(snapshotChecks({
9119
9371
  type: "string",
9120
9372
  ...normalizeParams(params)
9121
- });
9373
+ }));
9122
9374
  }
9123
9375
  // @__NO_SIDE_EFFECTS__
9124
9376
  function _email(Class, params) {
@@ -9390,11 +9642,11 @@
9390
9642
  }
9391
9643
  // @__NO_SIDE_EFFECTS__
9392
9644
  function _number(Class, params) {
9393
- return new Class({
9645
+ return new Class(snapshotChecks({
9394
9646
  type: "number",
9395
9647
  checks: [],
9396
9648
  ...normalizeParams(params)
9397
- });
9649
+ }));
9398
9650
  }
9399
9651
  // @__NO_SIDE_EFFECTS__
9400
9652
  function _int(Class, params) {
@@ -9651,6 +9903,7 @@
9651
9903
  cycles: params?.cycles ?? "ref",
9652
9904
  reused: params?.reused ?? "inline",
9653
9905
  intersections: [],
9906
+ deferred: [],
9654
9907
  external: params?.external ?? void 0
9655
9908
  };
9656
9909
  }
@@ -9670,7 +9923,7 @@
9670
9923
  Object.assign(json, result);
9671
9924
  return true;
9672
9925
  }
9673
- function process$1(schema, ctx, _params = {
9926
+ function processSchema(schema, ctx, _params = {
9674
9927
  path: [],
9675
9928
  schemaPath: []
9676
9929
  }) {
@@ -9709,7 +9962,7 @@
9709
9962
  const parent = schema._zod.parent;
9710
9963
  if (parent) {
9711
9964
  if (!result.ref) result.ref = parent;
9712
- process$1(parent, ctx, params);
9965
+ processSchema(parent, ctx, params);
9713
9966
  ctx.seen.get(parent).isParent = true;
9714
9967
  }
9715
9968
  }
@@ -9799,10 +10052,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
9799
10052
  continue;
9800
10053
  }
9801
10054
  if (seen.count > 1) {
9802
- if (ctx.reused === "ref") {
9803
- extractToDef(entry);
9804
- continue;
9805
- }
10055
+ if (ctx.reused === "ref") extractToDef(entry);
9806
10056
  }
9807
10057
  }
9808
10058
  if (ctx.external) ctx.sharedDefsExtractedFor = ctx.external;
@@ -9960,6 +10210,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
9960
10210
  if (!ctx.external || ctx.sharedEmitDoneFor !== ctx.external) {
9961
10211
  for (const entry of [...ctx.seen.entries()].reverse()) flattenRef(entry[0]);
9962
10212
  if (ctx.target !== "openapi-3.0") for (const entry of ctx.seen.entries()) compactTypeUnion(entry[1].def ?? entry[1].schema);
10213
+ for (const rewrite of ctx.deferred) rewrite();
9963
10214
  if (ctx.intersections.length) {
9964
10215
  const carriers = /* @__PURE__ */ new Map();
9965
10216
  for (const seen of ctx.seen.values()) for (const json of [seen.schema, seen.def]) {
@@ -10056,7 +10307,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
10056
10307
  ...params,
10057
10308
  processors
10058
10309
  });
10059
- process$1(schema, ctx);
10310
+ processSchema(schema, ctx);
10060
10311
  extractDefs(ctx, schema);
10061
10312
  return finalize(ctx, schema);
10062
10313
  };
@@ -10068,12 +10319,84 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
10068
10319
  io,
10069
10320
  processors
10070
10321
  });
10071
- process$1(schema, ctx);
10322
+ processSchema(schema, ctx);
10072
10323
  extractDefs(ctx, schema);
10073
10324
  return finalize(ctx, schema);
10074
10325
  };
10075
10326
  //#endregion
10076
10327
  //#region ../../node_modules/zod/v4/core/json-schema-processors.js
10328
+ const narrowMin = (agg, key, value) => {
10329
+ if (agg[key] === void 0 || value > agg[key]) agg[key] = value;
10330
+ };
10331
+ const narrowMax = (agg, key, value) => {
10332
+ if (agg[key] === void 0 || value < agg[key]) agg[key] = value;
10333
+ };
10334
+ const narrowBoth = (agg, value) => {
10335
+ narrowMin(agg, "minimum", value);
10336
+ narrowMax(agg, "maximum", value);
10337
+ };
10338
+ const addDivisor = (agg, value) => {
10339
+ agg.multipleOf ?? (agg.multipleOf = []);
10340
+ if (!agg.multipleOf.includes(value)) agg.multipleOf.push(value);
10341
+ };
10342
+ const addPattern = (agg, pattern) => {
10343
+ agg.patterns ?? (agg.patterns = /* @__PURE__ */ new Set());
10344
+ agg.patterns.add(pattern);
10345
+ };
10346
+ const intersectMime = (agg, mime) => {
10347
+ agg.mime = agg.mime ? agg.mime.filter((m) => mime.includes(m)) : [...mime];
10348
+ };
10349
+ const setFormat = (agg, format) => {
10350
+ agg.format = format;
10351
+ if (format.includes("int")) agg.isInt = true;
10352
+ };
10353
+ const minContributor = (agg, def) => narrowMin(agg, "minimum", def.minimum);
10354
+ const maxContributor = (agg, def) => narrowMax(agg, "maximum", def.maximum);
10355
+ const formatContributor = (ranges) => (agg, def) => {
10356
+ setFormat(agg, def.format);
10357
+ const [minimum, maximum] = ranges[def.format];
10358
+ narrowMin(agg, "minimum", minimum);
10359
+ narrowMax(agg, "maximum", maximum);
10360
+ };
10361
+ const contributors = {
10362
+ greater_than: (agg, def) => narrowMin(agg, def.inclusive ? "minimum" : "exclusiveMinimum", def.value),
10363
+ less_than: (agg, def) => narrowMax(agg, def.inclusive ? "maximum" : "exclusiveMaximum", def.value),
10364
+ multiple_of: (agg, def) => addDivisor(agg, def.value),
10365
+ number_format: formatContributor(NUMBER_FORMAT_RANGES),
10366
+ bigint_format: formatContributor(BIGINT_FORMAT_RANGES),
10367
+ min_length: minContributor,
10368
+ max_length: maxContributor,
10369
+ length_equals: (agg, def) => narrowBoth(agg, def.length),
10370
+ min_size: minContributor,
10371
+ max_size: maxContributor,
10372
+ size_equals: (agg, def) => narrowBoth(agg, def.size),
10373
+ string_format: (agg, def) => {
10374
+ setFormat(agg, def.format);
10375
+ if (def.pattern) addPattern(agg, def.pattern);
10376
+ if (def.format === "base64" || def.format === "base64url") agg.contentEncoding = def.format;
10377
+ if (def.local || def.precision === -1) agg.laxFormat = true;
10378
+ },
10379
+ mime_type: (agg, def) => intersectMime(agg, def.mime)
10380
+ };
10381
+ function aggregateChecks(schema) {
10382
+ const agg = {};
10383
+ const def = schema._zod.def;
10384
+ const list = schema._zod.traits.has("$ZodCheck") ? [schema, ...def.checks ?? []] : def.checks ?? [];
10385
+ for (const ch of list) contributors[ch._zod.def.check]?.(agg, ch._zod.def);
10386
+ const bag = schema._zod.bag;
10387
+ if (bag.minimum !== void 0) narrowMin(agg, "minimum", bag.minimum);
10388
+ if (bag.exclusiveMinimum !== void 0) narrowMin(agg, "exclusiveMinimum", bag.exclusiveMinimum);
10389
+ if (bag.maximum !== void 0) narrowMax(agg, "maximum", bag.maximum);
10390
+ if (bag.exclusiveMaximum !== void 0) narrowMax(agg, "exclusiveMaximum", bag.exclusiveMaximum);
10391
+ if (bag.multipleOf !== void 0) addDivisor(agg, bag.multipleOf);
10392
+ if (bag.format !== void 0) {
10393
+ agg.format ?? (agg.format = bag.format);
10394
+ if (bag.format.includes("int")) agg.isInt = true;
10395
+ }
10396
+ if (bag.mime) intersectMime(agg, bag.mime);
10397
+ for (const pattern of bag.patterns ?? []) addPattern(agg, pattern);
10398
+ return agg;
10399
+ }
10077
10400
  const formatMap = {
10078
10401
  guid: "uuid",
10079
10402
  url: "uri",
@@ -10081,10 +10404,12 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
10081
10404
  json_string: "json-string",
10082
10405
  regex: ""
10083
10406
  };
10407
+ const exactPatterns = /* @__PURE__ */ new Map([[base64Charset, base64], [base64urlCharset, base64url]]);
10408
+ const exactPattern = (p) => exactPatterns.get(p) ?? p;
10084
10409
  const stringProcessor = (schema, ctx, _json, _params) => {
10085
10410
  const json = _json;
10086
10411
  json.type = "string";
10087
- const { minimum, maximum, format, patterns, contentEncoding, laxFormat } = schema._zod.bag;
10412
+ const { minimum, maximum, format, patterns, contentEncoding, laxFormat } = aggregateChecks(schema);
10088
10413
  if (typeof minimum === "number") json.minLength = minimum;
10089
10414
  if (typeof maximum === "number") json.maxLength = maximum;
10090
10415
  if (format) {
@@ -10094,9 +10419,9 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
10094
10419
  }
10095
10420
  if (contentEncoding) json.contentEncoding = contentEncoding;
10096
10421
  if (patterns && patterns.size > 0) {
10097
- const regexes = [...patterns];
10098
- if (regexes.length === 1) json.pattern = regexes[0].source;
10099
- else if (regexes.length > 1) json.allOf = [...regexes.map((regex) => ({
10422
+ const patternList = [...patterns].map(exactPattern);
10423
+ if (patternList.length === 1) json.pattern = patternList[0].source;
10424
+ else if (patternList.length > 1) json.allOf = [...patternList.map((regex) => ({
10100
10425
  ...ctx.target === "draft-07" || ctx.target === "draft-04" || ctx.target === "openapi-3.0" ? { type: "string" } : {},
10101
10426
  pattern: regex.source
10102
10427
  }))];
@@ -10104,9 +10429,8 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
10104
10429
  };
10105
10430
  const numberProcessor = (schema, ctx, _json, params) => {
10106
10431
  const json = _json;
10107
- const { minimum, maximum, format, multipleOf, exclusiveMaximum, exclusiveMinimum } = schema._zod.bag;
10108
- if (typeof format === "string" && format.includes("int")) json.type = "integer";
10109
- else json.type = "number";
10432
+ const { minimum, maximum, multipleOf, exclusiveMaximum, exclusiveMinimum, isInt } = aggregateChecks(schema);
10433
+ json.type = isInt ? "integer" : "number";
10110
10434
  const exMin = typeof exclusiveMinimum === "number" && exclusiveMinimum >= (minimum ?? Number.NEGATIVE_INFINITY);
10111
10435
  const exMax = typeof exclusiveMaximum === "number" && exclusiveMaximum <= (maximum ?? Number.POSITIVE_INFINITY);
10112
10436
  const legacy = ctx.target === "draft-04" || ctx.target === "openapi-3.0";
@@ -10122,9 +10446,13 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
10122
10446
  json.exclusiveMaximum = true;
10123
10447
  } else json.exclusiveMaximum = exclusiveMaximum;
10124
10448
  } else if (typeof maximum === "number") json.maximum = maximum;
10125
- if (typeof multipleOf === "number") {
10126
- if (Number.isFinite(multipleOf) && multipleOf !== 0) json.multipleOf = Math.abs(multipleOf);
10127
- else handleUnrepresentable(schema, ctx, json, params, `A multipleOf divisor of ${multipleOf} cannot be represented in JSON Schema`);
10449
+ if (multipleOf) {
10450
+ const divisors = /* @__PURE__ */ new Set();
10451
+ for (const divisor of multipleOf) if (Number.isFinite(divisor) && divisor !== 0) divisors.add(Math.abs(divisor));
10452
+ else handleUnrepresentable(schema, ctx, json, params, `A multipleOf divisor of ${divisor} cannot be represented in JSON Schema`);
10453
+ const [first, ...rest] = divisors;
10454
+ if (first !== void 0) json.multipleOf = first;
10455
+ if (rest.length) json.allOf = [...json.allOf ?? [], ...rest.map((m) => ({ multipleOf: m }))];
10128
10456
  }
10129
10457
  };
10130
10458
  const booleanProcessor = (_schema, _ctx, json, _params) => {
@@ -10156,11 +10484,11 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
10156
10484
  const arrayProcessor = (schema, ctx, _json, params) => {
10157
10485
  const json = _json;
10158
10486
  const def = schema._zod.def;
10159
- const { minimum, maximum } = schema._zod.bag;
10487
+ const { minimum, maximum } = aggregateChecks(schema);
10160
10488
  if (typeof minimum === "number") json.minItems = minimum;
10161
10489
  if (typeof maximum === "number") json.maxItems = maximum;
10162
10490
  json.type = "array";
10163
- json.items = process$1(def.element, ctx, {
10491
+ json.items = processSchema(def.element, ctx, {
10164
10492
  ...params,
10165
10493
  path: [...params.path, "items"]
10166
10494
  });
@@ -10178,7 +10506,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
10178
10506
  if (Object.getOwnPropertySymbols(shape).length && handleUnrepresentable(schema, ctx, json, params, "Symbol keys cannot be represented in JSON Schema")) return;
10179
10507
  json.type = "object";
10180
10508
  json.properties = {};
10181
- for (const key in shape) assignProp(json.properties, key, process$1(shape[key], ctx, {
10509
+ for (const key in shape) assignProp(json.properties, key, processSchema(shape[key], ctx, {
10182
10510
  ...params,
10183
10511
  path: [
10184
10512
  ...params.path,
@@ -10186,17 +10514,16 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
10186
10514
  key
10187
10515
  ]
10188
10516
  }));
10189
- const allKeys = new Set(Object.keys(shape));
10190
- const requiredKeys = new Set([...allKeys].filter((key) => {
10517
+ const requiredKeys = [];
10518
+ for (const key of Object.keys(shape)) {
10191
10519
  const field = def.shape[key];
10192
- if (ctx.io === "input") return inputOptin(field) === void 0;
10193
- else return field._zod.optout === void 0;
10194
- }));
10195
- if (requiredKeys.size > 0) json.required = Array.from(requiredKeys);
10520
+ if (ctx.io === "input" ? inputOptin(field) === void 0 : field._zod.optout === void 0) requiredKeys.push(key);
10521
+ }
10522
+ if (requiredKeys.length > 0) json.required = requiredKeys;
10196
10523
  if (def.catchall?._zod.def.type === "never") json.additionalProperties = false;
10197
10524
  else if (!def.catchall) {
10198
10525
  if (ctx.io === "output") json.additionalProperties = false;
10199
- } else if (def.catchall) json.additionalProperties = process$1(def.catchall, ctx, {
10526
+ } else if (def.catchall) json.additionalProperties = processSchema(def.catchall, ctx, {
10200
10527
  ...params,
10201
10528
  path: [...params.path, "additionalProperties"]
10202
10529
  });
@@ -10204,7 +10531,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
10204
10531
  const unionProcessor = (schema, ctx, json, params) => {
10205
10532
  const def = schema._zod.def;
10206
10533
  const isExclusive = def.inclusive === false;
10207
- const options = def.options.map((x, i) => process$1(x, ctx, {
10534
+ const options = def.options.map((x, i) => processSchema(x, ctx, {
10208
10535
  ...params,
10209
10536
  path: [
10210
10537
  ...params.path,
@@ -10217,7 +10544,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
10217
10544
  };
10218
10545
  const intersectionProcessor = (schema, ctx, json, params) => {
10219
10546
  const def = schema._zod.def;
10220
- const a = process$1(def.left, ctx, {
10547
+ const a = processSchema(def.left, ctx, {
10221
10548
  ...params,
10222
10549
  path: [
10223
10550
  ...params.path,
@@ -10225,7 +10552,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
10225
10552
  0
10226
10553
  ]
10227
10554
  });
10228
- const b = process$1(def.right, ctx, {
10555
+ const b = processSchema(def.right, ctx, {
10229
10556
  ...params,
10230
10557
  path: [
10231
10558
  ...params.path,
@@ -10244,7 +10571,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
10244
10571
  json.type = "array";
10245
10572
  const prefixPath = ctx.target === "draft-2020-12" ? "prefixItems" : "items";
10246
10573
  const restPath = ctx.target === "draft-2020-12" ? "items" : ctx.target === "openapi-3.0" ? "items" : "additionalItems";
10247
- const prefixItems = def.items.map((x, i) => process$1(x, ctx, {
10574
+ const prefixItems = def.items.map((x, i) => processSchema(x, ctx, {
10248
10575
  ...params,
10249
10576
  path: [
10250
10577
  ...params.path,
@@ -10252,7 +10579,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
10252
10579
  i
10253
10580
  ]
10254
10581
  }));
10255
- const rest = def.rest ? process$1(def.rest, ctx, {
10582
+ const rest = def.rest ? processSchema(def.rest, ctx, {
10256
10583
  ...params,
10257
10584
  path: [
10258
10585
  ...params.path,
@@ -10286,18 +10613,76 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
10286
10613
  if (minItems > 0) json.minItems = minItems;
10287
10614
  if (isClosed) json.maxItems = maxItems;
10288
10615
  }
10289
- const { minimum, maximum } = schema._zod.bag;
10616
+ const { minimum, maximum } = aggregateChecks(schema);
10290
10617
  if (typeof minimum === "number") json.minItems = minimum;
10291
10618
  if (typeof maximum === "number") json.maxItems = maximum;
10292
10619
  };
10620
+ /** JSON object keys are always strings, so a numeric record key schema is re-expressed over the
10621
+ * numeric-string form the record parser matches. Deferred to `finalize`, after the flatten: a key
10622
+ * behind a wrapper only carries its own `type` before then, and a union key only has its branches.
10623
+ *
10624
+ * A numeric bound cannot apply to a property name, so `minimum` and its siblings are dropped rather
10625
+ * than carried over: keeping them beside `type: "string"` reproduces the match-nothing schema this
10626
+ * exists to fix. A key that carries one therefore emits wider than the record parses — `z.record(z.number().min(5), V)`
10627
+ * accepts `"3"` — which is the deliberate trade, since throwing on it would reject an ordinary schema
10628
+ * outright. */
10629
+ function stringifyKeyNames(bySchema, json, visited) {
10630
+ if (json.$ref) {
10631
+ if (visited.has(json)) return json;
10632
+ visited.add(json);
10633
+ const def = bySchema.get(json)?.def;
10634
+ if (!def) return json;
10635
+ const inlined = stringifyKeyNames(bySchema, def, visited);
10636
+ return inlined === def ? json : inlined;
10637
+ }
10638
+ for (const keyword of ["anyOf", "oneOf"]) {
10639
+ const branches = json[keyword];
10640
+ if (!Array.isArray(branches)) continue;
10641
+ const mapped = branches.map((branch) => stringifyKeyNames(bySchema, branch, visited));
10642
+ if (mapped.some((branch, i) => branch !== branches[i])) json = {
10643
+ ...json,
10644
+ [keyword]: mapped
10645
+ };
10646
+ }
10647
+ const types = Array.isArray(json.type) ? json.type : [json.type];
10648
+ const numericType = !types.includes("string") && types.some((t) => t === "number" || t === "integer");
10649
+ const values = json.enum ?? (json.const !== void 0 ? [json.const] : void 0);
10650
+ if (!numericType && !values?.some((v) => typeof v === "number")) return json;
10651
+ const { minimum, maximum, exclusiveMinimum, exclusiveMaximum, multipleOf, format, id, ...rest } = json;
10652
+ if (rest.enum) rest.enum = rest.enum.map((v) => typeof v === "number" ? String(v) : v);
10653
+ else if (typeof rest.const === "number") rest.const = String(rest.const);
10654
+ if (!numericType) return rest;
10655
+ rest.type = "string";
10656
+ if (!values) rest.pattern = (types.includes("number") ? number$1 : integer).source;
10657
+ return rest;
10658
+ }
10659
+ /** Every record of one conversion, so the carriers are found in a single pass rather than once per record. */
10660
+ const pendingRecords = /* @__PURE__ */ new WeakMap();
10661
+ function rewriteKeyNames(ctx) {
10662
+ const bySchema = /* @__PURE__ */ new Map();
10663
+ for (const entry of ctx.seen.values()) if (entry.def && !bySchema.has(entry.schema)) bySchema.set(entry.schema, entry);
10664
+ const rewrites = /* @__PURE__ */ new Map();
10665
+ for (const record of pendingRecords.get(ctx) ?? []) {
10666
+ const seen = ctx.seen.get(record);
10667
+ const names = (seen?.def ?? seen?.schema)?.propertyNames;
10668
+ if (!names || names === true || rewrites.has(names)) continue;
10669
+ const rewritten = stringifyKeyNames(bySchema, names, /* @__PURE__ */ new Set());
10670
+ if (rewritten !== names) rewrites.set(names, rewritten);
10671
+ }
10672
+ if (!rewrites.size) return;
10673
+ for (const entry of ctx.seen.values()) for (const carrier of [entry.schema, entry.def]) {
10674
+ const rewritten = carrier && rewrites.get(carrier.propertyNames);
10675
+ if (rewritten) carrier.propertyNames = rewritten;
10676
+ }
10677
+ }
10293
10678
  const recordProcessor = (schema, ctx, _json, params) => {
10294
10679
  const json = _json;
10295
10680
  const def = schema._zod.def;
10296
10681
  json.type = "object";
10297
10682
  const keyType = def.keyType;
10298
- const patterns = keyType._zod.bag?.patterns;
10683
+ const patterns = aggregateChecks(keyType).patterns;
10299
10684
  if (def.mode === "loose" && patterns && patterns.size > 0) {
10300
- const valueSchema = process$1(def.valueType, ctx, {
10685
+ const valueSchema = processSchema(def.valueType, ctx, {
10301
10686
  ...params,
10302
10687
  path: [
10303
10688
  ...params.path,
@@ -10306,13 +10691,22 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
10306
10691
  ]
10307
10692
  });
10308
10693
  json.patternProperties = {};
10309
- for (const pattern of patterns) assignProp(json.patternProperties, pattern.source, valueSchema);
10694
+ for (const pattern of patterns) assignProp(json.patternProperties, exactPattern(pattern).source, valueSchema);
10310
10695
  } else {
10311
- if (ctx.target === "draft-07" || ctx.target === "draft-2020-12") json.propertyNames = process$1(def.keyType, ctx, {
10312
- ...params,
10313
- path: [...params.path, "propertyNames"]
10314
- });
10315
- json.additionalProperties = process$1(def.valueType, ctx, {
10696
+ if (ctx.target === "draft-07" || ctx.target === "draft-2020-12") {
10697
+ json.propertyNames = processSchema(def.keyType, ctx, {
10698
+ ...params,
10699
+ path: [...params.path, "propertyNames"]
10700
+ });
10701
+ let pending = pendingRecords.get(ctx);
10702
+ if (!pending) {
10703
+ pending = [];
10704
+ pendingRecords.set(ctx, pending);
10705
+ ctx.deferred.push(() => rewriteKeyNames(ctx));
10706
+ }
10707
+ pending.push(schema);
10708
+ }
10709
+ json.additionalProperties = processSchema(def.valueType, ctx, {
10316
10710
  ...params,
10317
10711
  path: [...params.path, "additionalProperties"]
10318
10712
  });
@@ -10321,12 +10715,12 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
10321
10715
  const omittableOnInput = ctx.io === "input" && inputOptin(def.valueType) !== void 0;
10322
10716
  if (keyValues && !def.partial && !omittableOnInput) {
10323
10717
  const validKeyValues = [...keyValues].filter((v) => typeof v === "string" || typeof v === "number");
10324
- if (validKeyValues.length > 0) json.required = validKeyValues;
10718
+ if (validKeyValues.length > 0) json.required = validKeyValues.map(String);
10325
10719
  }
10326
10720
  };
10327
10721
  const nullableProcessor = (schema, ctx, json, params) => {
10328
10722
  const def = schema._zod.def;
10329
- const inner = process$1(def.innerType, ctx, params);
10723
+ const inner = processSchema(def.innerType, ctx, params);
10330
10724
  const seen = ctx.seen.get(schema);
10331
10725
  if (ctx.target === "openapi-3.0") {
10332
10726
  seen.ref = def.innerType;
@@ -10335,7 +10729,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
10335
10729
  };
10336
10730
  const nonoptionalProcessor = (schema, ctx, _json, params) => {
10337
10731
  const def = schema._zod.def;
10338
- process$1(def.innerType, ctx, params);
10732
+ processSchema(def.innerType, ctx, params);
10339
10733
  const seen = ctx.seen.get(schema);
10340
10734
  seen.ref = def.innerType;
10341
10735
  };
@@ -10356,7 +10750,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
10356
10750
  }
10357
10751
  const defaultProcessor = (schema, ctx, json, params) => {
10358
10752
  const def = schema._zod.def;
10359
- process$1(def.innerType, ctx, params);
10753
+ processSchema(def.innerType, ctx, params);
10360
10754
  const seen = ctx.seen.get(schema);
10361
10755
  seen.ref = def.innerType;
10362
10756
  const value = serializeDefaultValue(def.defaultValue, schema, ctx, json, params);
@@ -10364,7 +10758,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
10364
10758
  };
10365
10759
  const prefaultProcessor = (schema, ctx, json, params) => {
10366
10760
  const def = schema._zod.def;
10367
- process$1(def.innerType, ctx, params);
10761
+ processSchema(def.innerType, ctx, params);
10368
10762
  const seen = ctx.seen.get(schema);
10369
10763
  seen.ref = def.innerType;
10370
10764
  if (ctx.io !== "input") return;
@@ -10373,7 +10767,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
10373
10767
  };
10374
10768
  const catchProcessor = (schema, ctx, json, params) => {
10375
10769
  const def = schema._zod.def;
10376
- process$1(def.innerType, ctx, params);
10770
+ processSchema(def.innerType, ctx, params);
10377
10771
  const seen = ctx.seen.get(schema);
10378
10772
  seen.ref = def.innerType;
10379
10773
  let catchValue;
@@ -10389,20 +10783,20 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
10389
10783
  const def = schema._zod.def;
10390
10784
  const inIsTransform = def.in._zod.traits.has("$ZodTransform");
10391
10785
  const innerType = ctx.io === "input" ? inIsTransform ? def.out : def.in : def.out;
10392
- process$1(innerType, ctx, params);
10786
+ processSchema(innerType, ctx, params);
10393
10787
  const seen = ctx.seen.get(schema);
10394
10788
  seen.ref = innerType;
10395
10789
  };
10396
10790
  const readonlyProcessor = (schema, ctx, json, params) => {
10397
10791
  const def = schema._zod.def;
10398
- process$1(def.innerType, ctx, params);
10792
+ processSchema(def.innerType, ctx, params);
10399
10793
  const seen = ctx.seen.get(schema);
10400
10794
  seen.ref = def.innerType;
10401
10795
  json.readOnly = true;
10402
10796
  };
10403
10797
  const optionalProcessor = (schema, ctx, _json, params) => {
10404
10798
  const def = schema._zod.def;
10405
- process$1(def.innerType, ctx, params);
10799
+ processSchema(def.innerType, ctx, params);
10406
10800
  const seen = ctx.seen.get(schema);
10407
10801
  seen.ref = def.innerType;
10408
10802
  };
@@ -10607,6 +11001,12 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
10607
11001
  set spa(value) {
10608
11002
  own(this, "spa", value);
10609
11003
  },
11004
+ validate(data, params) {
11005
+ return validate(this, data, params);
11006
+ },
11007
+ validateAsync(data, params) {
11008
+ return validateAsync$1(this, data, params);
11009
+ },
10610
11010
  encode: function _encode(data, params) {
10611
11011
  return encode(this, data, params, { callee: _encode });
10612
11012
  },
@@ -10646,10 +11046,10 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
10646
11046
  $ZodString.init(inst, def);
10647
11047
  ZodType.init(inst, def);
10648
11048
  inst._zod.processJSONSchema = (ctx, json, params) => stringProcessor(inst, ctx, json, params);
10649
- const bag = inst._zod.bag;
10650
- inst.format = bag.format ?? null;
10651
- inst.minLength = bag.minimum ?? null;
10652
- inst.maxLength = bag.maximum ?? null;
11049
+ }, /*@__PURE__*/ derived({
11050
+ format: (inst) => aggregateChecks(inst).format ?? null,
11051
+ minLength: (inst) => aggregateChecks(inst).minimum ?? null,
11052
+ maxLength: (inst) => aggregateChecks(inst).maximum ?? null
10653
11053
  }, {
10654
11054
  regex(...args) {
10655
11055
  return this.check(/* @__PURE__ */ _regex(...args));
@@ -10696,7 +11096,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
10696
11096
  slugify() {
10697
11097
  return this.check(/* @__PURE__ */ _slugify());
10698
11098
  }
10699
- });
11099
+ }));
10700
11100
  const ZodString = /*@__PURE__*/ $constructor("ZodString", (inst, def) => {
10701
11101
  $ZodString.init(inst, def);
10702
11102
  _ZodString.init(inst, def);
@@ -10888,12 +11288,21 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
10888
11288
  $ZodNumber.init(inst, def);
10889
11289
  ZodType.init(inst, def);
10890
11290
  inst._zod.processJSONSchema = (ctx, json, params) => numberProcessor(inst, ctx, json, params);
10891
- const bag = inst._zod.bag;
10892
- inst.minValue = Math.max(bag.minimum ?? Number.NEGATIVE_INFINITY, bag.exclusiveMinimum ?? Number.NEGATIVE_INFINITY) ?? null;
10893
- inst.maxValue = Math.min(bag.maximum ?? Number.POSITIVE_INFINITY, bag.exclusiveMaximum ?? Number.POSITIVE_INFINITY) ?? null;
10894
- inst.isInt = (bag.format ?? "").includes("int") || Number.isSafeInteger(bag.multipleOf ?? .5);
10895
11291
  inst.isFinite = true;
10896
- inst.format = bag.format ?? null;
11292
+ }, /*@__PURE__*/ derived({
11293
+ minValue: (inst) => {
11294
+ const { minimum, exclusiveMinimum } = aggregateChecks(inst);
11295
+ return Math.max(minimum ?? Number.NEGATIVE_INFINITY, exclusiveMinimum ?? Number.NEGATIVE_INFINITY);
11296
+ },
11297
+ maxValue: (inst) => {
11298
+ const { maximum, exclusiveMaximum } = aggregateChecks(inst);
11299
+ return Math.min(maximum ?? Number.POSITIVE_INFINITY, exclusiveMaximum ?? Number.POSITIVE_INFINITY);
11300
+ },
11301
+ isInt: (inst) => {
11302
+ const { isInt, multipleOf } = aggregateChecks(inst);
11303
+ return !!isInt || !!multipleOf?.some(Number.isSafeInteger);
11304
+ },
11305
+ format: (inst) => aggregateChecks(inst).format ?? null
10897
11306
  }, {
10898
11307
  gt(value, params) {
10899
11308
  return this.check(/* @__PURE__ */ _gt(value, params));
@@ -10940,7 +11349,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
10940
11349
  finite() {
10941
11350
  return this;
10942
11351
  }
10943
- });
11352
+ }));
10944
11353
  function number(params) {
10945
11354
  return /* @__PURE__ */ _number(ZodNumber, params);
10946
11355
  }
@@ -10989,10 +11398,16 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
10989
11398
  inst._zod.processJSONSchema = (ctx, json, params) => dateProcessor(inst, ctx, json, params);
10990
11399
  inst.min = (value, params) => inst.check(/* @__PURE__ */ _gte(value, params));
10991
11400
  inst.max = (value, params) => inst.check(/* @__PURE__ */ _lte(value, params));
10992
- const c = inst._zod.bag;
10993
- inst.minDate = c.minimum ? new Date(c.minimum) : null;
10994
- inst.maxDate = c.maximum ? new Date(c.maximum) : null;
10995
- });
11401
+ }, /*@__PURE__*/ derived({
11402
+ minDate: (inst) => {
11403
+ const { minimum } = aggregateChecks(inst);
11404
+ return minimum ? new Date(minimum) : null;
11405
+ },
11406
+ maxDate: (inst) => {
11407
+ const { maximum } = aggregateChecks(inst);
11408
+ return maximum ? new Date(maximum) : null;
11409
+ }
11410
+ }, {}));
10996
11411
  function date(params) {
10997
11412
  return /* @__PURE__ */ _date(ZodDate, params);
10998
11413
  }
@@ -11033,34 +11448,19 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
11033
11448
  return _enum(Object.keys(this._zod.def.shape));
11034
11449
  },
11035
11450
  catchall(catchall) {
11036
- return this.clone({
11037
- ...this._zod.def,
11038
- catchall
11039
- });
11451
+ return this.clone(mergeDefs(this._zod.def, { catchall }));
11040
11452
  },
11041
11453
  passthrough() {
11042
- return this.clone({
11043
- ...this._zod.def,
11044
- catchall: unknown()
11045
- });
11454
+ return this.clone(mergeDefs(this._zod.def, { catchall: unknown() }));
11046
11455
  },
11047
11456
  loose() {
11048
- return this.clone({
11049
- ...this._zod.def,
11050
- catchall: unknown()
11051
- });
11457
+ return this.clone(mergeDefs(this._zod.def, { catchall: unknown() }));
11052
11458
  },
11053
11459
  strict() {
11054
- return this.clone({
11055
- ...this._zod.def,
11056
- catchall: never()
11057
- });
11460
+ return this.clone(mergeDefs(this._zod.def, { catchall: never() }));
11058
11461
  },
11059
11462
  strip() {
11060
- return this.clone({
11061
- ...this._zod.def,
11062
- catchall: void 0
11063
- });
11463
+ return this.clone(mergeDefs(this._zod.def, { catchall: void 0 }));
11064
11464
  },
11065
11465
  extend(incoming) {
11066
11466
  return extend(this, incoming);
@@ -11180,7 +11580,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
11180
11580
  ZodType.init(inst, def);
11181
11581
  inst._zod.processJSONSchema = (ctx, json, params) => enumProcessor(inst, ctx, json, params);
11182
11582
  inst.enum = def.entries;
11183
- inst.options = Object.values(def.entries);
11583
+ inst.options = [...inst._zod.values];
11184
11584
  const keys = new Set(Object.keys(def.entries));
11185
11585
  inst.extract = (values, params) => {
11186
11586
  const newEntries = {};
@@ -11418,8 +11818,8 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
11418
11818
  var arr = new Arr(_byteLength(b64, validLen, placeHoldersLen));
11419
11819
  var curByte = 0;
11420
11820
  var len = placeHoldersLen > 0 ? validLen - 4 : validLen;
11421
- var i;
11422
- for (i = 0; i < len; i += 4) {
11821
+ var i = 0;
11822
+ for (; i < len; i += 4) {
11423
11823
  tmp = revLookup[b64.charCodeAt(i)] << 18 | revLookup[b64.charCodeAt(i + 1)] << 12 | revLookup[b64.charCodeAt(i + 2)] << 6 | revLookup[b64.charCodeAt(i + 3)];
11424
11824
  arr[curByte++] = tmp >> 16 & 255;
11425
11825
  arr[curByte++] = tmp >> 8 & 255;
@@ -12019,8 +12419,8 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
12019
12419
  }
12020
12420
  const strLen = string.length;
12021
12421
  if (length > strLen / 2) length = strLen / 2;
12022
- let i;
12023
- for (i = 0; i < length; ++i) {
12422
+ let i = 0;
12423
+ for (; i < length; ++i) {
12024
12424
  const parsed = parseInt(string.substr(i * 2, 2), 16);
12025
12425
  if (numberIsNaN(parsed)) return i;
12026
12426
  buf[offset + i] = parsed;
@@ -12801,8 +13201,8 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
12801
13201
  return base64.toByteArray(base64clean(str));
12802
13202
  }
12803
13203
  function blitBuffer(src, dst, offset, length) {
12804
- let i;
12805
- for (i = 0; i < length; ++i) {
13204
+ let i = 0;
13205
+ for (; i < length; ++i) {
12806
13206
  if (i + offset >= dst.length || i >= src.length) break;
12807
13207
  dst[i + offset] = src[i];
12808
13208
  }
@@ -18338,4 +18738,4 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
18338
18738
  //#endregion
18339
18739
  })();
18340
18740
 
18341
- //# sourceMappingURL=clawpdf-worker-Db3u5RVE.js.map
18741
+ //# sourceMappingURL=clawpdf-worker-Duh5SOSc.js.map