@swmansion/argent 0.7.1 → 0.8.1

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.
@@ -72,12 +72,12 @@ var require_code = __commonJS({
72
72
  return item === "" || item === '""';
73
73
  }
74
74
  get str() {
75
- var _a;
76
- return (_a = this._str) !== null && _a !== void 0 ? _a : this._str = this._items.reduce((s, c) => `${s}${c}`, "");
75
+ var _a3;
76
+ return (_a3 = this._str) !== null && _a3 !== void 0 ? _a3 : this._str = this._items.reduce((s, c) => `${s}${c}`, "");
77
77
  }
78
78
  get names() {
79
- var _a;
80
- return (_a = this._names) !== null && _a !== void 0 ? _a : this._names = this._items.reduce((names, c) => {
79
+ var _a3;
80
+ return (_a3 = this._names) !== null && _a3 !== void 0 ? _a3 : this._names = this._items.reduce((names, c) => {
81
81
  if (c instanceof Name)
82
82
  names[c.str] = (names[c.str] || 0) + 1;
83
83
  return names;
@@ -223,8 +223,8 @@ var require_scope = __commonJS({
223
223
  return `${prefix}${ng.index++}`;
224
224
  }
225
225
  _nameGroup(prefix) {
226
- var _a, _b;
227
- if (((_b = (_a = this._parent) === null || _a === void 0 ? void 0 : _a._prefixes) === null || _b === void 0 ? void 0 : _b.has(prefix)) || this._prefixes && !this._prefixes.has(prefix)) {
226
+ var _a3, _b;
227
+ if (((_b = (_a3 = this._parent) === null || _a3 === void 0 ? void 0 : _a3._prefixes) === null || _b === void 0 ? void 0 : _b.has(prefix)) || this._prefixes && !this._prefixes.has(prefix)) {
228
228
  throw new Error(`CodeGen: prefix "${prefix}" is not allowed in this scope`);
229
229
  }
230
230
  return this._names[prefix] = { prefix, index: 0 };
@@ -257,12 +257,12 @@ var require_scope = __commonJS({
257
257
  return new ValueScopeName(prefix, this._newName(prefix));
258
258
  }
259
259
  value(nameOrPrefix, value) {
260
- var _a;
260
+ var _a3;
261
261
  if (value.ref === void 0)
262
262
  throw new Error("CodeGen: ref must be passed in value");
263
263
  const name = this.toName(nameOrPrefix);
264
264
  const { prefix } = name;
265
- const valueKey = (_a = value.key) !== null && _a !== void 0 ? _a : value.ref;
265
+ const valueKey = (_a3 = value.key) !== null && _a3 !== void 0 ? _a3 : value.ref;
266
266
  let vs = this._values[prefix];
267
267
  if (vs) {
268
268
  const _name = vs.get(valueKey);
@@ -580,8 +580,8 @@ var require_codegen = __commonJS({
580
580
  return this;
581
581
  }
582
582
  optimizeNames(names, constants) {
583
- var _a;
584
- this.else = (_a = this.else) === null || _a === void 0 ? void 0 : _a.optimizeNames(names, constants);
583
+ var _a3;
584
+ this.else = (_a3 = this.else) === null || _a3 === void 0 ? void 0 : _a3.optimizeNames(names, constants);
585
585
  if (!(super.optimizeNames(names, constants) || this.else))
586
586
  return;
587
587
  this.condition = optimizeExpr(this.condition, names, constants);
@@ -685,16 +685,16 @@ var require_codegen = __commonJS({
685
685
  return code;
686
686
  }
687
687
  optimizeNodes() {
688
- var _a, _b;
688
+ var _a3, _b;
689
689
  super.optimizeNodes();
690
- (_a = this.catch) === null || _a === void 0 ? void 0 : _a.optimizeNodes();
690
+ (_a3 = this.catch) === null || _a3 === void 0 ? void 0 : _a3.optimizeNodes();
691
691
  (_b = this.finally) === null || _b === void 0 ? void 0 : _b.optimizeNodes();
692
692
  return this;
693
693
  }
694
694
  optimizeNames(names, constants) {
695
- var _a, _b;
695
+ var _a3, _b;
696
696
  super.optimizeNames(names, constants);
697
- (_a = this.catch) === null || _a === void 0 ? void 0 : _a.optimizeNames(names, constants);
697
+ (_a3 = this.catch) === null || _a3 === void 0 ? void 0 : _a3.optimizeNames(names, constants);
698
698
  (_b = this.finally) === null || _b === void 0 ? void 0 : _b.optimizeNames(names, constants);
699
699
  return this;
700
700
  }
@@ -1474,8 +1474,8 @@ var require_applicability = __commonJS({
1474
1474
  }
1475
1475
  exports.shouldUseGroup = shouldUseGroup;
1476
1476
  function shouldUseRule(schema, rule) {
1477
- var _a;
1478
- return schema[rule.keyword] !== void 0 || ((_a = rule.definition.implements) === null || _a === void 0 ? void 0 : _a.some((kwd) => schema[kwd] !== void 0));
1477
+ var _a3;
1478
+ return schema[rule.keyword] !== void 0 || ((_a3 = rule.definition.implements) === null || _a3 === void 0 ? void 0 : _a3.some((kwd) => schema[kwd] !== void 0));
1479
1479
  }
1480
1480
  exports.shouldUseRule = shouldUseRule;
1481
1481
  }
@@ -1863,14 +1863,14 @@ var require_keyword = __commonJS({
1863
1863
  }
1864
1864
  exports.macroKeywordCode = macroKeywordCode;
1865
1865
  function funcKeywordCode(cxt, def) {
1866
- var _a;
1866
+ var _a3;
1867
1867
  const { gen, keyword, schema, parentSchema, $data, it } = cxt;
1868
1868
  checkAsyncKeyword(it, def);
1869
1869
  const validate = !$data && def.compile ? def.compile.call(it.self, schema, parentSchema, it) : def.validate;
1870
1870
  const validateRef = useKeyword(gen, keyword, validate);
1871
1871
  const valid = gen.let("valid");
1872
1872
  cxt.block$data(valid, validateKeyword);
1873
- cxt.ok((_a = def.valid) !== null && _a !== void 0 ? _a : valid);
1873
+ cxt.ok((_a3 = def.valid) !== null && _a3 !== void 0 ? _a3 : valid);
1874
1874
  function validateKeyword() {
1875
1875
  if (def.errors === false) {
1876
1876
  assignValid();
@@ -1901,8 +1901,8 @@ var require_keyword = __commonJS({
1901
1901
  gen.assign(valid, (0, codegen_1._)`${_await}${(0, code_1.callValidateCode)(cxt, validateRef, passCxt, passSchema)}`, def.modifying);
1902
1902
  }
1903
1903
  function reportErrs(errors) {
1904
- var _a2;
1905
- gen.if((0, codegen_1.not)((_a2 = def.valid) !== null && _a2 !== void 0 ? _a2 : valid), errors);
1904
+ var _a4;
1905
+ gen.if((0, codegen_1.not)((_a4 = def.valid) !== null && _a4 !== void 0 ? _a4 : valid), errors);
1906
1906
  }
1907
1907
  }
1908
1908
  exports.funcKeywordCode = funcKeywordCode;
@@ -2870,7 +2870,7 @@ var require_compile = __commonJS({
2870
2870
  var validate_1 = require_validate();
2871
2871
  var SchemaEnv = class {
2872
2872
  constructor(env) {
2873
- var _a;
2873
+ var _a3;
2874
2874
  this.refs = {};
2875
2875
  this.dynamicAnchors = {};
2876
2876
  let schema;
@@ -2879,7 +2879,7 @@ var require_compile = __commonJS({
2879
2879
  this.schema = env.schema;
2880
2880
  this.schemaId = env.schemaId;
2881
2881
  this.root = env.root || this;
2882
- this.baseId = (_a = env.baseId) !== null && _a !== void 0 ? _a : (0, resolve_1.normalizeId)(schema === null || schema === void 0 ? void 0 : schema[env.schemaId || "$id"]);
2882
+ this.baseId = (_a3 = env.baseId) !== null && _a3 !== void 0 ? _a3 : (0, resolve_1.normalizeId)(schema === null || schema === void 0 ? void 0 : schema[env.schemaId || "$id"]);
2883
2883
  this.schemaPath = env.schemaPath;
2884
2884
  this.localRefs = env.localRefs;
2885
2885
  this.meta = env.meta;
@@ -2975,14 +2975,14 @@ var require_compile = __commonJS({
2975
2975
  }
2976
2976
  exports.compileSchema = compileSchema;
2977
2977
  function resolveRef(root, baseId, ref) {
2978
- var _a;
2978
+ var _a3;
2979
2979
  ref = (0, resolve_1.resolveUrl)(this.opts.uriResolver, baseId, ref);
2980
2980
  const schOrFunc = root.refs[ref];
2981
2981
  if (schOrFunc)
2982
2982
  return schOrFunc;
2983
2983
  let _sch = resolve.call(this, root, ref);
2984
2984
  if (_sch === void 0) {
2985
- const schema = (_a = root.localRefs) === null || _a === void 0 ? void 0 : _a[ref];
2985
+ const schema = (_a3 = root.localRefs) === null || _a3 === void 0 ? void 0 : _a3[ref];
2986
2986
  const { schemaId } = this.opts;
2987
2987
  if (schema)
2988
2988
  _sch = new SchemaEnv({ schema, schemaId, root, baseId });
@@ -3051,8 +3051,8 @@ var require_compile = __commonJS({
3051
3051
  "definitions"
3052
3052
  ]);
3053
3053
  function getJsonPointer(parsedRef, { baseId, schema, root }) {
3054
- var _a;
3055
- if (((_a = parsedRef.fragment) === null || _a === void 0 ? void 0 : _a[0]) !== "/")
3054
+ var _a3;
3055
+ if (((_a3 = parsedRef.fragment) === null || _a3 === void 0 ? void 0 : _a3[0]) !== "/")
3056
3056
  return;
3057
3057
  for (const part of parsedRef.fragment.slice(1).split("/")) {
3058
3058
  if (typeof schema === "boolean")
@@ -3105,6 +3105,9 @@ var require_utils = __commonJS({
3105
3105
  "use strict";
3106
3106
  var isUUID = RegExp.prototype.test.bind(/^[\da-f]{8}-[\da-f]{4}-[\da-f]{4}-[\da-f]{4}-[\da-f]{12}$/iu);
3107
3107
  var isIPv4 = RegExp.prototype.test.bind(/^(?:(?:25[0-5]|2[0-4]\d|1\d{2}|[1-9]\d|\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d{2}|[1-9]\d|\d)$/u);
3108
+ var isHexPair = RegExp.prototype.test.bind(/^[\da-f]{2}$/iu);
3109
+ var isUnreserved = RegExp.prototype.test.bind(/^[\da-z\-._~]$/iu);
3110
+ var isPathCharacter = RegExp.prototype.test.bind(/^[\da-z\-._~!$&'()*+,;=:@/]$/iu);
3108
3111
  function stringArrayToHexStripped(input) {
3109
3112
  let acc = "";
3110
3113
  let code = 0;
@@ -3297,27 +3300,77 @@ var require_utils = __commonJS({
3297
3300
  }
3298
3301
  return output.join("");
3299
3302
  }
3300
- function normalizeComponentEncoding(component, esc2) {
3301
- const func = esc2 !== true ? escape : unescape;
3302
- if (component.scheme !== void 0) {
3303
- component.scheme = func(component.scheme);
3304
- }
3305
- if (component.userinfo !== void 0) {
3306
- component.userinfo = func(component.userinfo);
3307
- }
3308
- if (component.host !== void 0) {
3309
- component.host = func(component.host);
3303
+ var HOST_DELIMS = { "@": "%40", "/": "%2F", "?": "%3F", "#": "%23", ":": "%3A" };
3304
+ var HOST_DELIM_RE = /[@/?#:]/g;
3305
+ var HOST_DELIM_NO_COLON_RE = /[@/?#]/g;
3306
+ function reescapeHostDelimiters(host, isIP) {
3307
+ const re = isIP ? HOST_DELIM_NO_COLON_RE : HOST_DELIM_RE;
3308
+ re.lastIndex = 0;
3309
+ return host.replace(re, (ch) => HOST_DELIMS[ch]);
3310
+ }
3311
+ function normalizePercentEncoding(input, decodeUnreserved = false) {
3312
+ if (input.indexOf("%") === -1) {
3313
+ return input;
3310
3314
  }
3311
- if (component.path !== void 0) {
3312
- component.path = func(component.path);
3315
+ let output = "";
3316
+ for (let i = 0; i < input.length; i++) {
3317
+ if (input[i] === "%" && i + 2 < input.length) {
3318
+ const hex = input.slice(i + 1, i + 3);
3319
+ if (isHexPair(hex)) {
3320
+ const normalizedHex = hex.toUpperCase();
3321
+ const decoded = String.fromCharCode(parseInt(normalizedHex, 16));
3322
+ if (decodeUnreserved && isUnreserved(decoded)) {
3323
+ output += decoded;
3324
+ } else {
3325
+ output += "%" + normalizedHex;
3326
+ }
3327
+ i += 2;
3328
+ continue;
3329
+ }
3330
+ }
3331
+ output += input[i];
3313
3332
  }
3314
- if (component.query !== void 0) {
3315
- component.query = func(component.query);
3333
+ return output;
3334
+ }
3335
+ function normalizePathEncoding(input) {
3336
+ let output = "";
3337
+ for (let i = 0; i < input.length; i++) {
3338
+ if (input[i] === "%" && i + 2 < input.length) {
3339
+ const hex = input.slice(i + 1, i + 3);
3340
+ if (isHexPair(hex)) {
3341
+ const normalizedHex = hex.toUpperCase();
3342
+ const decoded = String.fromCharCode(parseInt(normalizedHex, 16));
3343
+ if (decoded !== "." && isUnreserved(decoded)) {
3344
+ output += decoded;
3345
+ } else {
3346
+ output += "%" + normalizedHex;
3347
+ }
3348
+ i += 2;
3349
+ continue;
3350
+ }
3351
+ }
3352
+ if (isPathCharacter(input[i])) {
3353
+ output += input[i];
3354
+ } else {
3355
+ output += escape(input[i]);
3356
+ }
3316
3357
  }
3317
- if (component.fragment !== void 0) {
3318
- component.fragment = func(component.fragment);
3358
+ return output;
3359
+ }
3360
+ function escapePreservingEscapes(input) {
3361
+ let output = "";
3362
+ for (let i = 0; i < input.length; i++) {
3363
+ if (input[i] === "%" && i + 2 < input.length) {
3364
+ const hex = input.slice(i + 1, i + 3);
3365
+ if (isHexPair(hex)) {
3366
+ output += "%" + hex.toUpperCase();
3367
+ i += 2;
3368
+ continue;
3369
+ }
3370
+ }
3371
+ output += escape(input[i]);
3319
3372
  }
3320
- return component;
3373
+ return output;
3321
3374
  }
3322
3375
  function recomposeAuthority(component) {
3323
3376
  const uriTokens = [];
@@ -3332,7 +3385,7 @@ var require_utils = __commonJS({
3332
3385
  if (ipV6res.isIPV6 === true) {
3333
3386
  host = `[${ipV6res.escapedHost}]`;
3334
3387
  } else {
3335
- host = component.host;
3388
+ host = reescapeHostDelimiters(host, false);
3336
3389
  }
3337
3390
  }
3338
3391
  uriTokens.push(host);
@@ -3346,7 +3399,10 @@ var require_utils = __commonJS({
3346
3399
  module.exports = {
3347
3400
  nonSimpleDomain,
3348
3401
  recomposeAuthority,
3349
- normalizeComponentEncoding,
3402
+ reescapeHostDelimiters,
3403
+ normalizePercentEncoding,
3404
+ normalizePathEncoding,
3405
+ escapePreservingEscapes,
3350
3406
  removeDotSegments,
3351
3407
  isIPv4,
3352
3408
  isUUID,
@@ -3570,12 +3626,12 @@ var require_schemes = __commonJS({
3570
3626
  var require_fast_uri = __commonJS({
3571
3627
  "../../node_modules/fast-uri/index.js"(exports, module) {
3572
3628
  "use strict";
3573
- var { normalizeIPv6, removeDotSegments, recomposeAuthority, normalizeComponentEncoding, isIPv4, nonSimpleDomain } = require_utils();
3629
+ var { normalizeIPv6, removeDotSegments, recomposeAuthority, normalizePercentEncoding, normalizePathEncoding, escapePreservingEscapes, reescapeHostDelimiters, isIPv4, nonSimpleDomain } = require_utils();
3574
3630
  var { SCHEMES, getSchemeHandler } = require_schemes();
3575
3631
  function normalize(uri, options) {
3576
3632
  if (typeof uri === "string") {
3577
3633
  uri = /** @type {T} */
3578
- serialize(parse3(uri, options), options);
3634
+ normalizeString(uri, options);
3579
3635
  } else if (typeof uri === "object") {
3580
3636
  uri = /** @type {T} */
3581
3637
  parse3(serialize(uri, options), options);
@@ -3642,19 +3698,9 @@ var require_fast_uri = __commonJS({
3642
3698
  return target;
3643
3699
  }
3644
3700
  function equal(uriA, uriB, options) {
3645
- if (typeof uriA === "string") {
3646
- uriA = unescape(uriA);
3647
- uriA = serialize(normalizeComponentEncoding(parse3(uriA, options), true), { ...options, skipEscape: true });
3648
- } else if (typeof uriA === "object") {
3649
- uriA = serialize(normalizeComponentEncoding(uriA, true), { ...options, skipEscape: true });
3650
- }
3651
- if (typeof uriB === "string") {
3652
- uriB = unescape(uriB);
3653
- uriB = serialize(normalizeComponentEncoding(parse3(uriB, options), true), { ...options, skipEscape: true });
3654
- } else if (typeof uriB === "object") {
3655
- uriB = serialize(normalizeComponentEncoding(uriB, true), { ...options, skipEscape: true });
3656
- }
3657
- return uriA.toLowerCase() === uriB.toLowerCase();
3701
+ const normalizedA = normalizeComparableURI(uriA, options);
3702
+ const normalizedB = normalizeComparableURI(uriB, options);
3703
+ return normalizedA !== void 0 && normalizedB !== void 0 && normalizedA.toLowerCase() === normalizedB.toLowerCase();
3658
3704
  }
3659
3705
  function serialize(cmpts, opts) {
3660
3706
  const component = {
@@ -3679,12 +3725,12 @@ var require_fast_uri = __commonJS({
3679
3725
  if (schemeHandler && schemeHandler.serialize) schemeHandler.serialize(component, options);
3680
3726
  if (component.path !== void 0) {
3681
3727
  if (!options.skipEscape) {
3682
- component.path = escape(component.path);
3728
+ component.path = escapePreservingEscapes(component.path);
3683
3729
  if (component.scheme !== void 0) {
3684
3730
  component.path = component.path.split("%3A").join(":");
3685
3731
  }
3686
3732
  } else {
3687
- component.path = unescape(component.path);
3733
+ component.path = normalizePercentEncoding(component.path);
3688
3734
  }
3689
3735
  }
3690
3736
  if (options.reference !== "suffix" && component.scheme) {
@@ -3719,7 +3765,16 @@ var require_fast_uri = __commonJS({
3719
3765
  return uriTokens.join("");
3720
3766
  }
3721
3767
  var URI_PARSE = /^(?:([^#/:?]+):)?(?:\/\/((?:([^#/?@]*)@)?(\[[^#/?\]]+\]|[^#/:?]*)(?::(\d*))?))?([^#?]*)(?:\?([^#]*))?(?:#((?:.|[\n\r])*))?/u;
3722
- function parse3(uri, opts) {
3768
+ function getParseError(parsed, matches) {
3769
+ if (matches[2] !== void 0 && parsed.path && parsed.path[0] !== "/") {
3770
+ return 'URI path must start with "/" when authority is present.';
3771
+ }
3772
+ if (typeof parsed.port === "number" && (parsed.port < 0 || parsed.port > 65535)) {
3773
+ return "URI port is malformed.";
3774
+ }
3775
+ return void 0;
3776
+ }
3777
+ function parseWithStatus(uri, opts) {
3723
3778
  const options = Object.assign({}, opts);
3724
3779
  const parsed = {
3725
3780
  scheme: void 0,
@@ -3730,6 +3785,7 @@ var require_fast_uri = __commonJS({
3730
3785
  query: void 0,
3731
3786
  fragment: void 0
3732
3787
  };
3788
+ let malformedAuthorityOrPort = false;
3733
3789
  let isIP = false;
3734
3790
  if (options.reference === "suffix") {
3735
3791
  if (options.scheme) {
@@ -3750,6 +3806,11 @@ var require_fast_uri = __commonJS({
3750
3806
  if (isNaN(parsed.port)) {
3751
3807
  parsed.port = matches[5];
3752
3808
  }
3809
+ const parseError = getParseError(parsed, matches);
3810
+ if (parseError !== void 0) {
3811
+ parsed.error = parsed.error || parseError;
3812
+ malformedAuthorityOrPort = true;
3813
+ }
3753
3814
  if (parsed.host) {
3754
3815
  const ipv4result = isIPv4(parsed.host);
3755
3816
  if (ipv4result === false) {
@@ -3788,14 +3849,18 @@ var require_fast_uri = __commonJS({
3788
3849
  parsed.scheme = unescape(parsed.scheme);
3789
3850
  }
3790
3851
  if (parsed.host !== void 0) {
3791
- parsed.host = unescape(parsed.host);
3852
+ parsed.host = reescapeHostDelimiters(unescape(parsed.host), isIP);
3792
3853
  }
3793
3854
  }
3794
3855
  if (parsed.path) {
3795
- parsed.path = escape(unescape(parsed.path));
3856
+ parsed.path = normalizePathEncoding(parsed.path);
3796
3857
  }
3797
3858
  if (parsed.fragment) {
3798
- parsed.fragment = encodeURI(decodeURIComponent(parsed.fragment));
3859
+ try {
3860
+ parsed.fragment = encodeURI(decodeURIComponent(parsed.fragment));
3861
+ } catch {
3862
+ parsed.error = parsed.error || "URI malformed";
3863
+ }
3799
3864
  }
3800
3865
  }
3801
3866
  if (schemeHandler && schemeHandler.parse) {
@@ -3804,7 +3869,29 @@ var require_fast_uri = __commonJS({
3804
3869
  } else {
3805
3870
  parsed.error = parsed.error || "URI can not be parsed.";
3806
3871
  }
3807
- return parsed;
3872
+ return { parsed, malformedAuthorityOrPort };
3873
+ }
3874
+ function parse3(uri, opts) {
3875
+ return parseWithStatus(uri, opts).parsed;
3876
+ }
3877
+ function normalizeString(uri, opts) {
3878
+ return normalizeStringWithStatus(uri, opts).normalized;
3879
+ }
3880
+ function normalizeStringWithStatus(uri, opts) {
3881
+ const { parsed, malformedAuthorityOrPort } = parseWithStatus(uri, opts);
3882
+ return {
3883
+ normalized: malformedAuthorityOrPort ? uri : serialize(parsed, opts),
3884
+ malformedAuthorityOrPort
3885
+ };
3886
+ }
3887
+ function normalizeComparableURI(uri, opts) {
3888
+ if (typeof uri === "string") {
3889
+ const { normalized, malformedAuthorityOrPort } = normalizeStringWithStatus(uri, opts);
3890
+ return malformedAuthorityOrPort ? void 0 : normalized;
3891
+ }
3892
+ if (typeof uri === "object") {
3893
+ return serialize(uri, opts);
3894
+ }
3808
3895
  }
3809
3896
  var fastUri = {
3810
3897
  SCHEMES,
@@ -3913,9 +4000,9 @@ var require_core = __commonJS({
3913
4000
  };
3914
4001
  var MAX_EXPRESSION = 200;
3915
4002
  function requiredOptions(o) {
3916
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0;
4003
+ var _a3, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0;
3917
4004
  const s = o.strict;
3918
- const _optz = (_a = o.code) === null || _a === void 0 ? void 0 : _a.optimize;
4005
+ const _optz = (_a3 = o.code) === null || _a3 === void 0 ? void 0 : _a3.optimize;
3919
4006
  const optimize = _optz === true || _optz === void 0 ? 1 : _optz || 0;
3920
4007
  const regExp = (_c = (_b = o.code) === null || _b === void 0 ? void 0 : _b.regExp) !== null && _c !== void 0 ? _c : defaultRegExp;
3921
4008
  const uriResolver = (_d = o.uriResolver) !== null && _d !== void 0 ? _d : uri_1.default;
@@ -3973,19 +4060,19 @@ var require_core = __commonJS({
3973
4060
  this.addKeyword("$async");
3974
4061
  }
3975
4062
  _addDefaultMetaSchema() {
3976
- const { $data, meta, schemaId } = this.opts;
4063
+ const { $data, meta: meta2, schemaId } = this.opts;
3977
4064
  let _dataRefSchema = $dataRefSchema;
3978
4065
  if (schemaId === "id") {
3979
4066
  _dataRefSchema = { ...$dataRefSchema };
3980
4067
  _dataRefSchema.id = _dataRefSchema.$id;
3981
4068
  delete _dataRefSchema.$id;
3982
4069
  }
3983
- if (meta && $data)
4070
+ if (meta2 && $data)
3984
4071
  this.addMetaSchema(_dataRefSchema, _dataRefSchema[schemaId], false);
3985
4072
  }
3986
4073
  defaultMeta() {
3987
- const { meta, schemaId } = this.opts;
3988
- return this.opts.defaultMeta = typeof meta == "object" ? meta[schemaId] || meta : void 0;
4074
+ const { meta: meta2, schemaId } = this.opts;
4075
+ return this.opts.defaultMeta = typeof meta2 == "object" ? meta2[schemaId] || meta2 : void 0;
3989
4076
  }
3990
4077
  validate(schemaKeyRef, data) {
3991
4078
  let v;
@@ -4005,12 +4092,12 @@ var require_core = __commonJS({
4005
4092
  const sch = this._addSchema(schema, _meta);
4006
4093
  return sch.validate || this._compileSchemaEnv(sch);
4007
4094
  }
4008
- compileAsync(schema, meta) {
4095
+ compileAsync(schema, meta2) {
4009
4096
  if (typeof this.opts.loadSchema != "function") {
4010
4097
  throw new Error("options.loadSchema should be a function");
4011
4098
  }
4012
4099
  const { loadSchema } = this.opts;
4013
- return runCompileAsync.call(this, schema, meta);
4100
+ return runCompileAsync.call(this, schema, meta2);
4014
4101
  async function runCompileAsync(_schema, _meta) {
4015
4102
  await loadMetaSchema.call(this, _schema.$schema);
4016
4103
  const sch = this._addSchema(_schema, _meta);
@@ -4042,7 +4129,7 @@ var require_core = __commonJS({
4042
4129
  if (!this.refs[ref])
4043
4130
  await loadMetaSchema.call(this, _schema.$schema);
4044
4131
  if (!this.refs[ref])
4045
- this.addSchema(_schema, ref, meta);
4132
+ this.addSchema(_schema, ref, meta2);
4046
4133
  }
4047
4134
  async function _loadSchema(ref) {
4048
4135
  const p = this._loading[ref];
@@ -4259,7 +4346,7 @@ var require_core = __commonJS({
4259
4346
  }
4260
4347
  }
4261
4348
  }
4262
- _addSchema(schema, meta, baseId, validateSchema = this.opts.validateSchema, addSchema = this.opts.addUsedSchema) {
4349
+ _addSchema(schema, meta2, baseId, validateSchema = this.opts.validateSchema, addSchema = this.opts.addUsedSchema) {
4263
4350
  let id;
4264
4351
  const { schemaId } = this.opts;
4265
4352
  if (typeof schema == "object") {
@@ -4275,7 +4362,7 @@ var require_core = __commonJS({
4275
4362
  return sch;
4276
4363
  baseId = (0, resolve_1.normalizeId)(id || baseId);
4277
4364
  const localRefs = resolve_1.getSchemaRefs.call(this, schema, baseId);
4278
- sch = new compile_1.SchemaEnv({ schema, schemaId, meta, baseId, localRefs });
4365
+ sch = new compile_1.SchemaEnv({ schema, schemaId, meta: meta2, baseId, localRefs });
4279
4366
  this._cache.set(sch.schema, sch);
4280
4367
  if (addSchema && !baseId.startsWith("#")) {
4281
4368
  if (baseId)
@@ -4389,7 +4476,7 @@ var require_core = __commonJS({
4389
4476
  }
4390
4477
  }
4391
4478
  function addRule(keyword, definition, dataType) {
4392
- var _a;
4479
+ var _a3;
4393
4480
  const post = definition === null || definition === void 0 ? void 0 : definition.post;
4394
4481
  if (dataType && post)
4395
4482
  throw new Error('keyword with "post" flag cannot have "type"');
@@ -4415,7 +4502,7 @@ var require_core = __commonJS({
4415
4502
  else
4416
4503
  ruleGroup.rules.push(rule);
4417
4504
  RULES.all[keyword] = rule;
4418
- (_a = definition.implements) === null || _a === void 0 ? void 0 : _a.forEach((kwd) => this.addKeyword(kwd));
4505
+ (_a3 = definition.implements) === null || _a3 === void 0 ? void 0 : _a3.forEach((kwd) => this.addKeyword(kwd));
4419
4506
  }
4420
4507
  function addBeforeRule(ruleGroup, rule, before) {
4421
4508
  const i = ruleGroup.rules.findIndex((_rule) => _rule.keyword === before);
@@ -4549,10 +4636,10 @@ var require_ref = __commonJS({
4549
4636
  gen.assign(names_1.default.errors, (0, codegen_1._)`${names_1.default.vErrors}.length`);
4550
4637
  }
4551
4638
  function addEvaluatedFrom(source) {
4552
- var _a;
4639
+ var _a3;
4553
4640
  if (!it.opts.unevaluated)
4554
4641
  return;
4555
- const schEvaluated = (_a = sch === null || sch === void 0 ? void 0 : sch.validate) === null || _a === void 0 ? void 0 : _a.evaluated;
4642
+ const schEvaluated = (_a3 = sch === null || sch === void 0 ? void 0 : sch.validate) === null || _a3 === void 0 ? void 0 : _a3.evaluated;
4556
4643
  if (it.props !== true) {
4557
4644
  if (schEvaluated && !schEvaluated.dynamicProps) {
4558
4645
  if (schEvaluated.props !== void 0) {
@@ -6203,7 +6290,7 @@ var require_discriminator = __commonJS({
6203
6290
  return _valid;
6204
6291
  }
6205
6292
  function getMapping() {
6206
- var _a;
6293
+ var _a3;
6207
6294
  const oneOfMapping = {};
6208
6295
  const topRequired = hasRequired(parentSchema);
6209
6296
  let tagRequired = true;
@@ -6217,7 +6304,7 @@ var require_discriminator = __commonJS({
6217
6304
  if (sch === void 0)
6218
6305
  throw new ref_error_1.default(it.opts.uriResolver, it.baseId, ref);
6219
6306
  }
6220
- const propSch = (_a = sch === null || sch === void 0 ? void 0 : sch.properties) === null || _a === void 0 ? void 0 : _a[tagName];
6307
+ const propSch = (_a3 = sch === null || sch === void 0 ? void 0 : sch.properties) === null || _a3 === void 0 ? void 0 : _a3[tagName];
6221
6308
  if (typeof propSch != "object") {
6222
6309
  throw new Error(`discriminator: oneOf subschemas (or referenced schemas) must have "properties/${tagName}"`);
6223
6310
  }
@@ -6786,9 +6873,9 @@ var require_dist = __commonJS({
6786
6873
  return f;
6787
6874
  };
6788
6875
  function addFormats(ajv, list, fs2, exportName) {
6789
- var _a;
6876
+ var _a3;
6790
6877
  var _b;
6791
- (_a = (_b = ajv.opts.code).formats) !== null && _a !== void 0 ? _a : _b.formats = (0, codegen_1._)`require("ajv-formats/dist/formats").${exportName}`;
6878
+ (_a3 = (_b = ajv.opts.code).formats) !== null && _a3 !== void 0 ? _a3 : _b.formats = (0, codegen_1._)`require("ajv-formats/dist/formats").${exportName}`;
6792
6879
  for (const f of list)
6793
6880
  ajv.addFormat(f, fs2[f]);
6794
6881
  }
@@ -6804,39 +6891,46 @@ import { dirname } from "node:path";
6804
6891
  import { homedir as homedir2 } from "node:os";
6805
6892
 
6806
6893
  // ../../node_modules/@modelcontextprotocol/sdk/dist/esm/server/stdio.js
6807
- import process2 from "node:process";
6894
+ import process3 from "node:process";
6808
6895
 
6809
6896
  // ../../node_modules/zod/v4/core/core.js
6810
- var NEVER = Object.freeze({
6811
- status: "aborted"
6812
- });
6897
+ var _a;
6813
6898
  // @__NO_SIDE_EFFECTS__
6814
6899
  function $constructor(name, initializer3, params) {
6815
6900
  function init(inst, def) {
6816
- var _a;
6817
- Object.defineProperty(inst, "_zod", {
6818
- value: inst._zod ?? {},
6819
- enumerable: false
6820
- });
6821
- (_a = inst._zod).traits ?? (_a.traits = /* @__PURE__ */ new Set());
6901
+ if (!inst._zod) {
6902
+ Object.defineProperty(inst, "_zod", {
6903
+ value: {
6904
+ def,
6905
+ constr: _,
6906
+ traits: /* @__PURE__ */ new Set()
6907
+ },
6908
+ enumerable: false
6909
+ });
6910
+ }
6911
+ if (inst._zod.traits.has(name)) {
6912
+ return;
6913
+ }
6822
6914
  inst._zod.traits.add(name);
6823
6915
  initializer3(inst, def);
6824
- for (const k in _.prototype) {
6825
- if (!(k in inst))
6826
- Object.defineProperty(inst, k, { value: _.prototype[k].bind(inst) });
6916
+ const proto = _.prototype;
6917
+ const keys = Object.keys(proto);
6918
+ for (let i = 0; i < keys.length; i++) {
6919
+ const k = keys[i];
6920
+ if (!(k in inst)) {
6921
+ inst[k] = proto[k].bind(inst);
6922
+ }
6827
6923
  }
6828
- inst._zod.constr = _;
6829
- inst._zod.def = def;
6830
6924
  }
6831
6925
  const Parent = params?.Parent ?? Object;
6832
6926
  class Definition extends Parent {
6833
6927
  }
6834
6928
  Object.defineProperty(Definition, "name", { value: name });
6835
6929
  function _(def) {
6836
- var _a;
6930
+ var _a3;
6837
6931
  const inst = params?.Parent ? new Definition() : this;
6838
6932
  init(inst, def);
6839
- (_a = inst._zod).deferred ?? (_a.deferred = []);
6933
+ (_a3 = inst._zod).deferred ?? (_a3.deferred = []);
6840
6934
  for (const fn of inst._zod.deferred) {
6841
6935
  fn();
6842
6936
  }
@@ -6858,7 +6952,14 @@ var $ZodAsyncError = class extends Error {
6858
6952
  super(`Encountered Promise during synchronous parse. Use .parseAsync() instead.`);
6859
6953
  }
6860
6954
  };
6861
- var globalConfig = {};
6955
+ var $ZodEncodeError = class extends Error {
6956
+ constructor(name) {
6957
+ super(`Encountered unidirectional transform during encode: ${name}`);
6958
+ this.name = "ZodEncodeError";
6959
+ }
6960
+ };
6961
+ (_a = globalThis).__zod_globalConfig ?? (_a.__zod_globalConfig = {});
6962
+ var globalConfig = globalThis.__zod_globalConfig;
6862
6963
  function config(newConfig) {
6863
6964
  if (newConfig)
6864
6965
  Object.assign(globalConfig, newConfig);
@@ -6879,15 +6980,19 @@ __export(util_exports, {
6879
6980
  assertNever: () => assertNever,
6880
6981
  assertNotEqual: () => assertNotEqual,
6881
6982
  assignProp: () => assignProp,
6983
+ base64ToUint8Array: () => base64ToUint8Array,
6984
+ base64urlToUint8Array: () => base64urlToUint8Array,
6882
6985
  cached: () => cached,
6883
6986
  captureStackTrace: () => captureStackTrace,
6884
6987
  cleanEnum: () => cleanEnum,
6885
6988
  cleanRegex: () => cleanRegex,
6886
6989
  clone: () => clone,
6990
+ cloneDef: () => cloneDef,
6887
6991
  createTransparentProxy: () => createTransparentProxy,
6888
6992
  defineLazy: () => defineLazy,
6889
6993
  esc: () => esc,
6890
6994
  escapeRegex: () => escapeRegex,
6995
+ explicitlyAborted: () => explicitlyAborted,
6891
6996
  extend: () => extend,
6892
6997
  finalizeIssue: () => finalizeIssue,
6893
6998
  floatSafeRemainder: () => floatSafeRemainder,
@@ -6896,17 +7001,21 @@ __export(util_exports, {
6896
7001
  getLengthableOrigin: () => getLengthableOrigin,
6897
7002
  getParsedType: () => getParsedType,
6898
7003
  getSizableOrigin: () => getSizableOrigin,
7004
+ hexToUint8Array: () => hexToUint8Array,
6899
7005
  isObject: () => isObject,
6900
7006
  isPlainObject: () => isPlainObject,
6901
7007
  issue: () => issue,
6902
7008
  joinValues: () => joinValues,
6903
7009
  jsonStringifyReplacer: () => jsonStringifyReplacer,
6904
7010
  merge: () => merge,
7011
+ mergeDefs: () => mergeDefs,
6905
7012
  normalizeParams: () => normalizeParams,
6906
7013
  nullish: () => nullish,
6907
7014
  numKeys: () => numKeys,
7015
+ objectClone: () => objectClone,
6908
7016
  omit: () => omit,
6909
7017
  optionalKeys: () => optionalKeys,
7018
+ parsedType: () => parsedType,
6910
7019
  partial: () => partial,
6911
7020
  pick: () => pick,
6912
7021
  prefixIssues: () => prefixIssues,
@@ -6915,7 +7024,13 @@ __export(util_exports, {
6915
7024
  propertyKeyTypes: () => propertyKeyTypes,
6916
7025
  randomString: () => randomString,
6917
7026
  required: () => required,
7027
+ safeExtend: () => safeExtend,
7028
+ shallowClone: () => shallowClone,
7029
+ slugify: () => slugify,
6918
7030
  stringifyPrimitive: () => stringifyPrimitive,
7031
+ uint8ArrayToBase64: () => uint8ArrayToBase64,
7032
+ uint8ArrayToBase64url: () => uint8ArrayToBase64url,
7033
+ uint8ArrayToHex: () => uint8ArrayToHex,
6919
7034
  unwrapMessage: () => unwrapMessage
6920
7035
  });
6921
7036
  function assertEqual(val) {
@@ -6927,7 +7042,7 @@ function assertNotEqual(val) {
6927
7042
  function assertIs(_arg) {
6928
7043
  }
6929
7044
  function assertNever(_x) {
6930
- throw new Error();
7045
+ throw new Error("Unexpected value in exhaustive check");
6931
7046
  }
6932
7047
  function assert(_) {
6933
7048
  }
@@ -6966,23 +7081,26 @@ function cleanRegex(source) {
6966
7081
  return source.slice(start, end);
6967
7082
  }
6968
7083
  function floatSafeRemainder(val, step) {
6969
- const valDecCount = (val.toString().split(".")[1] || "").length;
6970
- const stepDecCount = (step.toString().split(".")[1] || "").length;
6971
- const decCount = valDecCount > stepDecCount ? valDecCount : stepDecCount;
6972
- const valInt = Number.parseInt(val.toFixed(decCount).replace(".", ""));
6973
- const stepInt = Number.parseInt(step.toFixed(decCount).replace(".", ""));
6974
- return valInt % stepInt / 10 ** decCount;
6975
- }
7084
+ const ratio = val / step;
7085
+ const roundedRatio = Math.round(ratio);
7086
+ const tolerance = Number.EPSILON * Math.max(Math.abs(ratio), 1);
7087
+ if (Math.abs(ratio - roundedRatio) < tolerance)
7088
+ return 0;
7089
+ return ratio - roundedRatio;
7090
+ }
7091
+ var EVALUATING = /* @__PURE__ */ Symbol("evaluating");
6976
7092
  function defineLazy(object3, key, getter) {
6977
- const set = false;
7093
+ let value = void 0;
6978
7094
  Object.defineProperty(object3, key, {
6979
7095
  get() {
6980
- if (!set) {
6981
- const value = getter();
6982
- object3[key] = value;
6983
- return value;
7096
+ if (value === EVALUATING) {
7097
+ return void 0;
6984
7098
  }
6985
- throw new Error("cached value already set");
7099
+ if (value === void 0) {
7100
+ value = EVALUATING;
7101
+ value = getter();
7102
+ }
7103
+ return value;
6986
7104
  },
6987
7105
  set(v) {
6988
7106
  Object.defineProperty(object3, key, {
@@ -6993,6 +7111,9 @@ function defineLazy(object3, key, getter) {
6993
7111
  configurable: true
6994
7112
  });
6995
7113
  }
7114
+ function objectClone(obj) {
7115
+ return Object.create(Object.getPrototypeOf(obj), Object.getOwnPropertyDescriptors(obj));
7116
+ }
6996
7117
  function assignProp(target, prop, value) {
6997
7118
  Object.defineProperty(target, prop, {
6998
7119
  value,
@@ -7001,6 +7122,17 @@ function assignProp(target, prop, value) {
7001
7122
  configurable: true
7002
7123
  });
7003
7124
  }
7125
+ function mergeDefs(...defs) {
7126
+ const mergedDescriptors = {};
7127
+ for (const def of defs) {
7128
+ const descriptors = Object.getOwnPropertyDescriptors(def);
7129
+ Object.assign(mergedDescriptors, descriptors);
7130
+ }
7131
+ return Object.defineProperties({}, mergedDescriptors);
7132
+ }
7133
+ function cloneDef(schema) {
7134
+ return mergeDefs(schema._zod.def);
7135
+ }
7004
7136
  function getElementAtPath(obj, path2) {
7005
7137
  if (!path2)
7006
7138
  return obj;
@@ -7028,12 +7160,18 @@ function randomString(length = 10) {
7028
7160
  function esc(str) {
7029
7161
  return JSON.stringify(str);
7030
7162
  }
7031
- var captureStackTrace = Error.captureStackTrace ? Error.captureStackTrace : (..._args) => {
7163
+ function slugify(input) {
7164
+ return input.toLowerCase().trim().replace(/[^\w\s-]/g, "").replace(/[\s_-]+/g, "-").replace(/^-+|-+$/g, "");
7165
+ }
7166
+ var captureStackTrace = "captureStackTrace" in Error ? Error.captureStackTrace : (..._args) => {
7032
7167
  };
7033
7168
  function isObject(data) {
7034
7169
  return typeof data === "object" && data !== null && !Array.isArray(data);
7035
7170
  }
7036
- var allowsEval = cached(() => {
7171
+ var allowsEval = /* @__PURE__ */ cached(() => {
7172
+ if (globalConfig.jitless) {
7173
+ return false;
7174
+ }
7037
7175
  if (typeof navigator !== "undefined" && navigator?.userAgent?.includes("Cloudflare")) {
7038
7176
  return false;
7039
7177
  }
@@ -7051,6 +7189,8 @@ function isPlainObject(o) {
7051
7189
  const ctor = o.constructor;
7052
7190
  if (ctor === void 0)
7053
7191
  return true;
7192
+ if (typeof ctor !== "function")
7193
+ return true;
7054
7194
  const prot = ctor.prototype;
7055
7195
  if (isObject(prot) === false)
7056
7196
  return false;
@@ -7059,6 +7199,17 @@ function isPlainObject(o) {
7059
7199
  }
7060
7200
  return true;
7061
7201
  }
7202
+ function shallowClone(o) {
7203
+ if (isPlainObject(o))
7204
+ return { ...o };
7205
+ if (Array.isArray(o))
7206
+ return [...o];
7207
+ if (o instanceof Map)
7208
+ return new Map(o);
7209
+ if (o instanceof Set)
7210
+ return new Set(o);
7211
+ return o;
7212
+ }
7062
7213
  function numKeys(data) {
7063
7214
  let keyCount = 0;
7064
7215
  for (const key in data) {
@@ -7113,7 +7264,14 @@ var getParsedType = (data) => {
7113
7264
  }
7114
7265
  };
7115
7266
  var propertyKeyTypes = /* @__PURE__ */ new Set(["string", "number", "symbol"]);
7116
- var primitiveTypes = /* @__PURE__ */ new Set(["string", "number", "bigint", "boolean", "symbol", "undefined"]);
7267
+ var primitiveTypes = /* @__PURE__ */ new Set([
7268
+ "string",
7269
+ "number",
7270
+ "bigint",
7271
+ "boolean",
7272
+ "symbol",
7273
+ "undefined"
7274
+ ]);
7117
7275
  function escapeRegex(str) {
7118
7276
  return str.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
7119
7277
  }
@@ -7196,138 +7354,201 @@ var BIGINT_FORMAT_RANGES = {
7196
7354
  uint64: [/* @__PURE__ */ BigInt(0), /* @__PURE__ */ BigInt("18446744073709551615")]
7197
7355
  };
7198
7356
  function pick(schema, mask) {
7199
- const newShape = {};
7200
7357
  const currDef = schema._zod.def;
7201
- for (const key in mask) {
7202
- if (!(key in currDef.shape)) {
7203
- throw new Error(`Unrecognized key: "${key}"`);
7204
- }
7205
- if (!mask[key])
7206
- continue;
7207
- newShape[key] = currDef.shape[key];
7358
+ const checks = currDef.checks;
7359
+ const hasChecks = checks && checks.length > 0;
7360
+ if (hasChecks) {
7361
+ throw new Error(".pick() cannot be used on object schemas containing refinements");
7208
7362
  }
7209
- return clone(schema, {
7210
- ...schema._zod.def,
7211
- shape: newShape,
7363
+ const def = mergeDefs(schema._zod.def, {
7364
+ get shape() {
7365
+ const newShape = {};
7366
+ for (const key in mask) {
7367
+ if (!(key in currDef.shape)) {
7368
+ throw new Error(`Unrecognized key: "${key}"`);
7369
+ }
7370
+ if (!mask[key])
7371
+ continue;
7372
+ newShape[key] = currDef.shape[key];
7373
+ }
7374
+ assignProp(this, "shape", newShape);
7375
+ return newShape;
7376
+ },
7212
7377
  checks: []
7213
7378
  });
7379
+ return clone(schema, def);
7214
7380
  }
7215
7381
  function omit(schema, mask) {
7216
- const newShape = { ...schema._zod.def.shape };
7217
7382
  const currDef = schema._zod.def;
7218
- for (const key in mask) {
7219
- if (!(key in currDef.shape)) {
7220
- throw new Error(`Unrecognized key: "${key}"`);
7221
- }
7222
- if (!mask[key])
7223
- continue;
7224
- delete newShape[key];
7383
+ const checks = currDef.checks;
7384
+ const hasChecks = checks && checks.length > 0;
7385
+ if (hasChecks) {
7386
+ throw new Error(".omit() cannot be used on object schemas containing refinements");
7225
7387
  }
7226
- return clone(schema, {
7227
- ...schema._zod.def,
7228
- shape: newShape,
7388
+ const def = mergeDefs(schema._zod.def, {
7389
+ get shape() {
7390
+ const newShape = { ...schema._zod.def.shape };
7391
+ for (const key in mask) {
7392
+ if (!(key in currDef.shape)) {
7393
+ throw new Error(`Unrecognized key: "${key}"`);
7394
+ }
7395
+ if (!mask[key])
7396
+ continue;
7397
+ delete newShape[key];
7398
+ }
7399
+ assignProp(this, "shape", newShape);
7400
+ return newShape;
7401
+ },
7229
7402
  checks: []
7230
7403
  });
7404
+ return clone(schema, def);
7231
7405
  }
7232
7406
  function extend(schema, shape) {
7233
7407
  if (!isPlainObject(shape)) {
7234
7408
  throw new Error("Invalid input to extend: expected a plain object");
7235
7409
  }
7236
- const def = {
7237
- ...schema._zod.def,
7410
+ const checks = schema._zod.def.checks;
7411
+ const hasChecks = checks && checks.length > 0;
7412
+ if (hasChecks) {
7413
+ const existingShape = schema._zod.def.shape;
7414
+ for (const key in shape) {
7415
+ if (Object.getOwnPropertyDescriptor(existingShape, key) !== void 0) {
7416
+ throw new Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.");
7417
+ }
7418
+ }
7419
+ }
7420
+ const def = mergeDefs(schema._zod.def, {
7238
7421
  get shape() {
7239
7422
  const _shape = { ...schema._zod.def.shape, ...shape };
7240
7423
  assignProp(this, "shape", _shape);
7241
7424
  return _shape;
7242
- },
7243
- checks: []
7244
- // delete existing checks
7245
- };
7425
+ }
7426
+ });
7427
+ return clone(schema, def);
7428
+ }
7429
+ function safeExtend(schema, shape) {
7430
+ if (!isPlainObject(shape)) {
7431
+ throw new Error("Invalid input to safeExtend: expected a plain object");
7432
+ }
7433
+ const def = mergeDefs(schema._zod.def, {
7434
+ get shape() {
7435
+ const _shape = { ...schema._zod.def.shape, ...shape };
7436
+ assignProp(this, "shape", _shape);
7437
+ return _shape;
7438
+ }
7439
+ });
7246
7440
  return clone(schema, def);
7247
7441
  }
7248
7442
  function merge(a, b) {
7249
- return clone(a, {
7250
- ...a._zod.def,
7443
+ if (a._zod.def.checks?.length) {
7444
+ throw new Error(".merge() cannot be used on object schemas containing refinements. Use .safeExtend() instead.");
7445
+ }
7446
+ const def = mergeDefs(a._zod.def, {
7251
7447
  get shape() {
7252
7448
  const _shape = { ...a._zod.def.shape, ...b._zod.def.shape };
7253
7449
  assignProp(this, "shape", _shape);
7254
7450
  return _shape;
7255
7451
  },
7256
- catchall: b._zod.def.catchall,
7257
- checks: []
7258
- // delete existing checks
7452
+ get catchall() {
7453
+ return b._zod.def.catchall;
7454
+ },
7455
+ checks: b._zod.def.checks ?? []
7259
7456
  });
7457
+ return clone(a, def);
7260
7458
  }
7261
7459
  function partial(Class2, schema, mask) {
7262
- const oldShape = schema._zod.def.shape;
7263
- const shape = { ...oldShape };
7264
- if (mask) {
7265
- for (const key in mask) {
7266
- if (!(key in oldShape)) {
7267
- throw new Error(`Unrecognized key: "${key}"`);
7268
- }
7269
- if (!mask[key])
7270
- continue;
7271
- shape[key] = Class2 ? new Class2({
7272
- type: "optional",
7273
- innerType: oldShape[key]
7274
- }) : oldShape[key];
7275
- }
7276
- } else {
7277
- for (const key in oldShape) {
7278
- shape[key] = Class2 ? new Class2({
7279
- type: "optional",
7280
- innerType: oldShape[key]
7281
- }) : oldShape[key];
7282
- }
7460
+ const currDef = schema._zod.def;
7461
+ const checks = currDef.checks;
7462
+ const hasChecks = checks && checks.length > 0;
7463
+ if (hasChecks) {
7464
+ throw new Error(".partial() cannot be used on object schemas containing refinements");
7283
7465
  }
7284
- return clone(schema, {
7285
- ...schema._zod.def,
7286
- shape,
7466
+ const def = mergeDefs(schema._zod.def, {
7467
+ get shape() {
7468
+ const oldShape = schema._zod.def.shape;
7469
+ const shape = { ...oldShape };
7470
+ if (mask) {
7471
+ for (const key in mask) {
7472
+ if (!(key in oldShape)) {
7473
+ throw new Error(`Unrecognized key: "${key}"`);
7474
+ }
7475
+ if (!mask[key])
7476
+ continue;
7477
+ shape[key] = Class2 ? new Class2({
7478
+ type: "optional",
7479
+ innerType: oldShape[key]
7480
+ }) : oldShape[key];
7481
+ }
7482
+ } else {
7483
+ for (const key in oldShape) {
7484
+ shape[key] = Class2 ? new Class2({
7485
+ type: "optional",
7486
+ innerType: oldShape[key]
7487
+ }) : oldShape[key];
7488
+ }
7489
+ }
7490
+ assignProp(this, "shape", shape);
7491
+ return shape;
7492
+ },
7287
7493
  checks: []
7288
7494
  });
7495
+ return clone(schema, def);
7289
7496
  }
7290
7497
  function required(Class2, schema, mask) {
7291
- const oldShape = schema._zod.def.shape;
7292
- const shape = { ...oldShape };
7293
- if (mask) {
7294
- for (const key in mask) {
7295
- if (!(key in shape)) {
7296
- throw new Error(`Unrecognized key: "${key}"`);
7297
- }
7298
- if (!mask[key])
7299
- continue;
7300
- shape[key] = new Class2({
7301
- type: "nonoptional",
7302
- innerType: oldShape[key]
7303
- });
7304
- }
7305
- } else {
7306
- for (const key in oldShape) {
7307
- shape[key] = new Class2({
7308
- type: "nonoptional",
7309
- innerType: oldShape[key]
7310
- });
7498
+ const def = mergeDefs(schema._zod.def, {
7499
+ get shape() {
7500
+ const oldShape = schema._zod.def.shape;
7501
+ const shape = { ...oldShape };
7502
+ if (mask) {
7503
+ for (const key in mask) {
7504
+ if (!(key in shape)) {
7505
+ throw new Error(`Unrecognized key: "${key}"`);
7506
+ }
7507
+ if (!mask[key])
7508
+ continue;
7509
+ shape[key] = new Class2({
7510
+ type: "nonoptional",
7511
+ innerType: oldShape[key]
7512
+ });
7513
+ }
7514
+ } else {
7515
+ for (const key in oldShape) {
7516
+ shape[key] = new Class2({
7517
+ type: "nonoptional",
7518
+ innerType: oldShape[key]
7519
+ });
7520
+ }
7521
+ }
7522
+ assignProp(this, "shape", shape);
7523
+ return shape;
7311
7524
  }
7312
- }
7313
- return clone(schema, {
7314
- ...schema._zod.def,
7315
- shape,
7316
- // optional: [],
7317
- checks: []
7318
7525
  });
7526
+ return clone(schema, def);
7319
7527
  }
7320
7528
  function aborted(x, startIndex = 0) {
7529
+ if (x.aborted === true)
7530
+ return true;
7531
+ for (let i = startIndex; i < x.issues.length; i++) {
7532
+ if (x.issues[i]?.continue !== true) {
7533
+ return true;
7534
+ }
7535
+ }
7536
+ return false;
7537
+ }
7538
+ function explicitlyAborted(x, startIndex = 0) {
7539
+ if (x.aborted === true)
7540
+ return true;
7321
7541
  for (let i = startIndex; i < x.issues.length; i++) {
7322
- if (x.issues[i]?.continue !== true)
7542
+ if (x.issues[i]?.continue === false) {
7323
7543
  return true;
7544
+ }
7324
7545
  }
7325
7546
  return false;
7326
7547
  }
7327
7548
  function prefixIssues(path2, issues) {
7328
7549
  return issues.map((iss) => {
7329
- var _a;
7330
- (_a = iss).path ?? (_a.path = []);
7550
+ var _a3;
7551
+ (_a3 = iss).path ?? (_a3.path = []);
7331
7552
  iss.path.unshift(path2);
7332
7553
  return iss;
7333
7554
  });
@@ -7336,17 +7557,14 @@ function unwrapMessage(message) {
7336
7557
  return typeof message === "string" ? message : message?.message;
7337
7558
  }
7338
7559
  function finalizeIssue(iss, ctx, config2) {
7339
- const full = { ...iss, path: iss.path ?? [] };
7340
- if (!iss.message) {
7341
- const message = unwrapMessage(iss.inst?._zod.def?.error?.(iss)) ?? unwrapMessage(ctx?.error?.(iss)) ?? unwrapMessage(config2.customError?.(iss)) ?? unwrapMessage(config2.localeError?.(iss)) ?? "Invalid input";
7342
- full.message = message;
7560
+ const message = iss.message ? iss.message : unwrapMessage(iss.inst?._zod.def?.error?.(iss)) ?? unwrapMessage(ctx?.error?.(iss)) ?? unwrapMessage(config2.customError?.(iss)) ?? unwrapMessage(config2.localeError?.(iss)) ?? "Invalid input";
7561
+ const { inst: _inst, continue: _continue, input: _input, ...rest } = iss;
7562
+ rest.path ?? (rest.path = []);
7563
+ rest.message = message;
7564
+ if (ctx?.reportInput) {
7565
+ rest.input = _input;
7343
7566
  }
7344
- delete full.inst;
7345
- delete full.continue;
7346
- if (!ctx?.reportInput) {
7347
- delete full.input;
7348
- }
7349
- return full;
7567
+ return rest;
7350
7568
  }
7351
7569
  function getSizableOrigin(input) {
7352
7570
  if (input instanceof Set)
@@ -7364,6 +7582,27 @@ function getLengthableOrigin(input) {
7364
7582
  return "string";
7365
7583
  return "unknown";
7366
7584
  }
7585
+ function parsedType(data) {
7586
+ const t = typeof data;
7587
+ switch (t) {
7588
+ case "number": {
7589
+ return Number.isNaN(data) ? "nan" : "number";
7590
+ }
7591
+ case "object": {
7592
+ if (data === null) {
7593
+ return "null";
7594
+ }
7595
+ if (Array.isArray(data)) {
7596
+ return "array";
7597
+ }
7598
+ const obj = data;
7599
+ if (obj && Object.getPrototypeOf(obj) !== Object.prototype && "constructor" in obj && obj.constructor) {
7600
+ return obj.constructor.name;
7601
+ }
7602
+ }
7603
+ }
7604
+ return t;
7605
+ }
7367
7606
  function issue(...args) {
7368
7607
  const [iss, input, inst] = args;
7369
7608
  if (typeof iss === "string") {
@@ -7381,6 +7620,43 @@ function cleanEnum(obj) {
7381
7620
  return Number.isNaN(Number.parseInt(k, 10));
7382
7621
  }).map((el) => el[1]);
7383
7622
  }
7623
+ function base64ToUint8Array(base642) {
7624
+ const binaryString = atob(base642);
7625
+ const bytes = new Uint8Array(binaryString.length);
7626
+ for (let i = 0; i < binaryString.length; i++) {
7627
+ bytes[i] = binaryString.charCodeAt(i);
7628
+ }
7629
+ return bytes;
7630
+ }
7631
+ function uint8ArrayToBase64(bytes) {
7632
+ let binaryString = "";
7633
+ for (let i = 0; i < bytes.length; i++) {
7634
+ binaryString += String.fromCharCode(bytes[i]);
7635
+ }
7636
+ return btoa(binaryString);
7637
+ }
7638
+ function base64urlToUint8Array(base64url2) {
7639
+ const base642 = base64url2.replace(/-/g, "+").replace(/_/g, "/");
7640
+ const padding = "=".repeat((4 - base642.length % 4) % 4);
7641
+ return base64ToUint8Array(base642 + padding);
7642
+ }
7643
+ function uint8ArrayToBase64url(bytes) {
7644
+ return uint8ArrayToBase64(bytes).replace(/\+/g, "-").replace(/\//g, "_").replace(/=/g, "");
7645
+ }
7646
+ function hexToUint8Array(hex) {
7647
+ const cleanHex = hex.replace(/^0x/, "");
7648
+ if (cleanHex.length % 2 !== 0) {
7649
+ throw new Error("Invalid hex string length");
7650
+ }
7651
+ const bytes = new Uint8Array(cleanHex.length / 2);
7652
+ for (let i = 0; i < cleanHex.length; i += 2) {
7653
+ bytes[i / 2] = Number.parseInt(cleanHex.slice(i, i + 2), 16);
7654
+ }
7655
+ return bytes;
7656
+ }
7657
+ function uint8ArrayToHex(bytes) {
7658
+ return Array.from(bytes).map((b) => b.toString(16).padStart(2, "0")).join("");
7659
+ }
7384
7660
  var Class = class {
7385
7661
  constructor(..._args) {
7386
7662
  }
@@ -7397,13 +7673,7 @@ var initializer = (inst, def) => {
7397
7673
  value: def,
7398
7674
  enumerable: false
7399
7675
  });
7400
- Object.defineProperty(inst, "message", {
7401
- get() {
7402
- return JSON.stringify(def, jsonStringifyReplacer, 2);
7403
- },
7404
- enumerable: true
7405
- // configurable: false,
7406
- });
7676
+ inst.message = JSON.stringify(def, jsonStringifyReplacer, 2);
7407
7677
  Object.defineProperty(inst, "toString", {
7408
7678
  value: () => inst.message,
7409
7679
  enumerable: false
@@ -7424,35 +7694,35 @@ function flattenError(error2, mapper = (issue2) => issue2.message) {
7424
7694
  }
7425
7695
  return { formErrors, fieldErrors };
7426
7696
  }
7427
- function formatError(error2, _mapper) {
7428
- const mapper = _mapper || function(issue2) {
7429
- return issue2.message;
7430
- };
7697
+ function formatError(error2, mapper = (issue2) => issue2.message) {
7431
7698
  const fieldErrors = { _errors: [] };
7432
- const processError = (error3) => {
7699
+ const processError = (error3, path2 = []) => {
7433
7700
  for (const issue2 of error3.issues) {
7434
7701
  if (issue2.code === "invalid_union" && issue2.errors.length) {
7435
- issue2.errors.map((issues) => processError({ issues }));
7702
+ issue2.errors.map((issues) => processError({ issues }, [...path2, ...issue2.path]));
7436
7703
  } else if (issue2.code === "invalid_key") {
7437
- processError({ issues: issue2.issues });
7704
+ processError({ issues: issue2.issues }, [...path2, ...issue2.path]);
7438
7705
  } else if (issue2.code === "invalid_element") {
7439
- processError({ issues: issue2.issues });
7440
- } else if (issue2.path.length === 0) {
7441
- fieldErrors._errors.push(mapper(issue2));
7706
+ processError({ issues: issue2.issues }, [...path2, ...issue2.path]);
7442
7707
  } else {
7443
- let curr = fieldErrors;
7444
- let i = 0;
7445
- while (i < issue2.path.length) {
7446
- const el = issue2.path[i];
7447
- const terminal = i === issue2.path.length - 1;
7448
- if (!terminal) {
7449
- curr[el] = curr[el] || { _errors: [] };
7450
- } else {
7451
- curr[el] = curr[el] || { _errors: [] };
7452
- curr[el]._errors.push(mapper(issue2));
7708
+ const fullpath = [...path2, ...issue2.path];
7709
+ if (fullpath.length === 0) {
7710
+ fieldErrors._errors.push(mapper(issue2));
7711
+ } else {
7712
+ let curr = fieldErrors;
7713
+ let i = 0;
7714
+ while (i < fullpath.length) {
7715
+ const el = fullpath[i];
7716
+ const terminal = i === fullpath.length - 1;
7717
+ if (!terminal) {
7718
+ curr[el] = curr[el] || { _errors: [] };
7719
+ } else {
7720
+ curr[el] = curr[el] || { _errors: [] };
7721
+ curr[el]._errors.push(mapper(issue2));
7722
+ }
7723
+ curr = curr[el];
7724
+ i++;
7453
7725
  }
7454
- curr = curr[el];
7455
- i++;
7456
7726
  }
7457
7727
  }
7458
7728
  }
@@ -7463,7 +7733,7 @@ function formatError(error2, _mapper) {
7463
7733
 
7464
7734
  // ../../node_modules/zod/v4/core/parse.js
7465
7735
  var _parse = (_Err) => (schema, value, _ctx, _params) => {
7466
- const ctx = _ctx ? Object.assign(_ctx, { async: false }) : { async: false };
7736
+ const ctx = _ctx ? { ..._ctx, async: false } : { async: false };
7467
7737
  const result = schema._zod.run({ value, issues: [] }, ctx);
7468
7738
  if (result instanceof Promise) {
7469
7739
  throw new $ZodAsyncError();
@@ -7476,7 +7746,7 @@ var _parse = (_Err) => (schema, value, _ctx, _params) => {
7476
7746
  return result.value;
7477
7747
  };
7478
7748
  var _parseAsync = (_Err) => async (schema, value, _ctx, params) => {
7479
- const ctx = _ctx ? Object.assign(_ctx, { async: true }) : { async: true };
7749
+ const ctx = _ctx ? { ..._ctx, async: true } : { async: true };
7480
7750
  let result = schema._zod.run({ value, issues: [] }, ctx);
7481
7751
  if (result instanceof Promise)
7482
7752
  result = await result;
@@ -7500,7 +7770,7 @@ var _safeParse = (_Err) => (schema, value, _ctx) => {
7500
7770
  };
7501
7771
  var safeParse = /* @__PURE__ */ _safeParse($ZodRealError);
7502
7772
  var _safeParseAsync = (_Err) => async (schema, value, _ctx) => {
7503
- const ctx = _ctx ? Object.assign(_ctx, { async: true }) : { async: true };
7773
+ const ctx = _ctx ? { ..._ctx, async: true } : { async: true };
7504
7774
  let result = schema._zod.run({ value, issues: [] }, ctx);
7505
7775
  if (result instanceof Promise)
7506
7776
  result = await result;
@@ -7510,9 +7780,37 @@ var _safeParseAsync = (_Err) => async (schema, value, _ctx) => {
7510
7780
  } : { success: true, data: result.value };
7511
7781
  };
7512
7782
  var safeParseAsync = /* @__PURE__ */ _safeParseAsync($ZodRealError);
7783
+ var _encode = (_Err) => (schema, value, _ctx) => {
7784
+ const ctx = _ctx ? { ..._ctx, direction: "backward" } : { direction: "backward" };
7785
+ return _parse(_Err)(schema, value, ctx);
7786
+ };
7787
+ var _decode = (_Err) => (schema, value, _ctx) => {
7788
+ return _parse(_Err)(schema, value, _ctx);
7789
+ };
7790
+ var _encodeAsync = (_Err) => async (schema, value, _ctx) => {
7791
+ const ctx = _ctx ? { ..._ctx, direction: "backward" } : { direction: "backward" };
7792
+ return _parseAsync(_Err)(schema, value, ctx);
7793
+ };
7794
+ var _decodeAsync = (_Err) => async (schema, value, _ctx) => {
7795
+ return _parseAsync(_Err)(schema, value, _ctx);
7796
+ };
7797
+ var _safeEncode = (_Err) => (schema, value, _ctx) => {
7798
+ const ctx = _ctx ? { ..._ctx, direction: "backward" } : { direction: "backward" };
7799
+ return _safeParse(_Err)(schema, value, ctx);
7800
+ };
7801
+ var _safeDecode = (_Err) => (schema, value, _ctx) => {
7802
+ return _safeParse(_Err)(schema, value, _ctx);
7803
+ };
7804
+ var _safeEncodeAsync = (_Err) => async (schema, value, _ctx) => {
7805
+ const ctx = _ctx ? { ..._ctx, direction: "backward" } : { direction: "backward" };
7806
+ return _safeParseAsync(_Err)(schema, value, ctx);
7807
+ };
7808
+ var _safeDecodeAsync = (_Err) => async (schema, value, _ctx) => {
7809
+ return _safeParseAsync(_Err)(schema, value, _ctx);
7810
+ };
7513
7811
 
7514
7812
  // ../../node_modules/zod/v4/core/regexes.js
7515
- var cuid = /^[cC][^\s-]{8,}$/;
7813
+ var cuid = /^[cC][0-9a-z]{6,}$/;
7516
7814
  var cuid2 = /^[0-9a-z]+$/;
7517
7815
  var ulid = /^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/;
7518
7816
  var xid = /^[0-9a-vA-V]{20}$/;
@@ -7522,7 +7820,7 @@ var duration = /^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)
7522
7820
  var guid = /^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/;
7523
7821
  var uuid = (version2) => {
7524
7822
  if (!version2)
7525
- return /^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000)$/;
7823
+ return /^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/;
7526
7824
  return new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${version2}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`);
7527
7825
  };
7528
7826
  var email = /^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/;
@@ -7531,13 +7829,13 @@ function emoji() {
7531
7829
  return new RegExp(_emoji, "u");
7532
7830
  }
7533
7831
  var ipv4 = /^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/;
7534
- var ipv6 = /^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})$/;
7832
+ var ipv6 = /^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))$/;
7535
7833
  var cidrv4 = /^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/([0-9]|[1-2][0-9]|3[0-2])$/;
7536
7834
  var cidrv6 = /^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/;
7537
7835
  var base64 = /^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/;
7538
7836
  var base64url = /^[A-Za-z0-9_-]*$/;
7539
- var hostname = /^([a-zA-Z0-9-]+\.)*[a-zA-Z0-9-]+$/;
7540
- var e164 = /^\+(?:[0-9]){6,14}[0-9]$/;
7837
+ var httpProtocol = /^https?$/;
7838
+ var e164 = /^\+[1-9]\d{6,14}$/;
7541
7839
  var dateSource = `(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))`;
7542
7840
  var date = /* @__PURE__ */ new RegExp(`^${dateSource}$`);
7543
7841
  function timeSource(args) {
@@ -7554,7 +7852,7 @@ function datetime(args) {
7554
7852
  if (args.local)
7555
7853
  opts.push("");
7556
7854
  if (args.offset)
7557
- opts.push(`([+-]\\d{2}:\\d{2})`);
7855
+ opts.push(`([+-](?:[01]\\d|2[0-3]):[0-5]\\d)`);
7558
7856
  const timeRegex = `${time3}(?:${opts.join("|")})`;
7559
7857
  return new RegExp(`^${dateSource}T(?:${timeRegex})$`);
7560
7858
  }
@@ -7562,19 +7860,19 @@ var string = (params) => {
7562
7860
  const regex = params ? `[\\s\\S]{${params?.minimum ?? 0},${params?.maximum ?? ""}}` : `[\\s\\S]*`;
7563
7861
  return new RegExp(`^${regex}$`);
7564
7862
  };
7565
- var integer = /^\d+$/;
7566
- var number = /^-?\d+(?:\.\d+)?/i;
7567
- var boolean = /true|false/i;
7568
- var _null = /null/i;
7863
+ var integer = /^-?\d+$/;
7864
+ var number = /^-?\d+(?:\.\d+)?$/;
7865
+ var boolean = /^(?:true|false)$/i;
7866
+ var _null = /^null$/i;
7569
7867
  var lowercase = /^[^A-Z]*$/;
7570
7868
  var uppercase = /^[^a-z]*$/;
7571
7869
 
7572
7870
  // ../../node_modules/zod/v4/core/checks.js
7573
7871
  var $ZodCheck = /* @__PURE__ */ $constructor("$ZodCheck", (inst, def) => {
7574
- var _a;
7872
+ var _a3;
7575
7873
  inst._zod ?? (inst._zod = {});
7576
7874
  inst._zod.def = def;
7577
- (_a = inst._zod).onattach ?? (_a.onattach = []);
7875
+ (_a3 = inst._zod).onattach ?? (_a3.onattach = []);
7578
7876
  });
7579
7877
  var numericOriginMap = {
7580
7878
  number: "number",
@@ -7601,7 +7899,7 @@ var $ZodCheckLessThan = /* @__PURE__ */ $constructor("$ZodCheckLessThan", (inst,
7601
7899
  payload.issues.push({
7602
7900
  origin,
7603
7901
  code: "too_big",
7604
- maximum: def.value,
7902
+ maximum: typeof def.value === "object" ? def.value.getTime() : def.value,
7605
7903
  input: payload.value,
7606
7904
  inclusive: def.inclusive,
7607
7905
  inst,
@@ -7629,7 +7927,7 @@ var $ZodCheckGreaterThan = /* @__PURE__ */ $constructor("$ZodCheckGreaterThan",
7629
7927
  payload.issues.push({
7630
7928
  origin,
7631
7929
  code: "too_small",
7632
- minimum: def.value,
7930
+ minimum: typeof def.value === "object" ? def.value.getTime() : def.value,
7633
7931
  input: payload.value,
7634
7932
  inclusive: def.inclusive,
7635
7933
  inst,
@@ -7640,8 +7938,8 @@ var $ZodCheckGreaterThan = /* @__PURE__ */ $constructor("$ZodCheckGreaterThan",
7640
7938
  var $ZodCheckMultipleOf = /* @__PURE__ */ $constructor("$ZodCheckMultipleOf", (inst, def) => {
7641
7939
  $ZodCheck.init(inst, def);
7642
7940
  inst._zod.onattach.push((inst2) => {
7643
- var _a;
7644
- (_a = inst2._zod.bag).multipleOf ?? (_a.multipleOf = def.value);
7941
+ var _a3;
7942
+ (_a3 = inst2._zod.bag).multipleOf ?? (_a3.multipleOf = def.value);
7645
7943
  });
7646
7944
  inst._zod.check = (payload) => {
7647
7945
  if (typeof payload.value !== typeof def.value)
@@ -7681,6 +7979,7 @@ var $ZodCheckNumberFormat = /* @__PURE__ */ $constructor("$ZodCheckNumberFormat"
7681
7979
  expected: origin,
7682
7980
  format: def.format,
7683
7981
  code: "invalid_type",
7982
+ continue: false,
7684
7983
  input,
7685
7984
  inst
7686
7985
  });
@@ -7695,6 +7994,7 @@ var $ZodCheckNumberFormat = /* @__PURE__ */ $constructor("$ZodCheckNumberFormat"
7695
7994
  note: "Integers must be within the safe integer range.",
7696
7995
  inst,
7697
7996
  origin,
7997
+ inclusive: true,
7698
7998
  continue: !def.abort
7699
7999
  });
7700
8000
  } else {
@@ -7705,6 +8005,7 @@ var $ZodCheckNumberFormat = /* @__PURE__ */ $constructor("$ZodCheckNumberFormat"
7705
8005
  note: "Integers must be within the safe integer range.",
7706
8006
  inst,
7707
8007
  origin,
8008
+ inclusive: true,
7708
8009
  continue: !def.abort
7709
8010
  });
7710
8011
  }
@@ -7728,15 +8029,17 @@ var $ZodCheckNumberFormat = /* @__PURE__ */ $constructor("$ZodCheckNumberFormat"
7728
8029
  input,
7729
8030
  code: "too_big",
7730
8031
  maximum,
7731
- inst
8032
+ inclusive: true,
8033
+ inst,
8034
+ continue: !def.abort
7732
8035
  });
7733
8036
  }
7734
8037
  };
7735
8038
  });
7736
8039
  var $ZodCheckMaxLength = /* @__PURE__ */ $constructor("$ZodCheckMaxLength", (inst, def) => {
7737
- var _a;
8040
+ var _a3;
7738
8041
  $ZodCheck.init(inst, def);
7739
- (_a = inst._zod.def).when ?? (_a.when = (payload) => {
8042
+ (_a3 = inst._zod.def).when ?? (_a3.when = (payload) => {
7740
8043
  const val = payload.value;
7741
8044
  return !nullish(val) && val.length !== void 0;
7742
8045
  });
@@ -7763,9 +8066,9 @@ var $ZodCheckMaxLength = /* @__PURE__ */ $constructor("$ZodCheckMaxLength", (ins
7763
8066
  };
7764
8067
  });
7765
8068
  var $ZodCheckMinLength = /* @__PURE__ */ $constructor("$ZodCheckMinLength", (inst, def) => {
7766
- var _a;
8069
+ var _a3;
7767
8070
  $ZodCheck.init(inst, def);
7768
- (_a = inst._zod.def).when ?? (_a.when = (payload) => {
8071
+ (_a3 = inst._zod.def).when ?? (_a3.when = (payload) => {
7769
8072
  const val = payload.value;
7770
8073
  return !nullish(val) && val.length !== void 0;
7771
8074
  });
@@ -7792,9 +8095,9 @@ var $ZodCheckMinLength = /* @__PURE__ */ $constructor("$ZodCheckMinLength", (ins
7792
8095
  };
7793
8096
  });
7794
8097
  var $ZodCheckLengthEquals = /* @__PURE__ */ $constructor("$ZodCheckLengthEquals", (inst, def) => {
7795
- var _a;
8098
+ var _a3;
7796
8099
  $ZodCheck.init(inst, def);
7797
- (_a = inst._zod.def).when ?? (_a.when = (payload) => {
8100
+ (_a3 = inst._zod.def).when ?? (_a3.when = (payload) => {
7798
8101
  const val = payload.value;
7799
8102
  return !nullish(val) && val.length !== void 0;
7800
8103
  });
@@ -7823,7 +8126,7 @@ var $ZodCheckLengthEquals = /* @__PURE__ */ $constructor("$ZodCheckLengthEquals"
7823
8126
  };
7824
8127
  });
7825
8128
  var $ZodCheckStringFormat = /* @__PURE__ */ $constructor("$ZodCheckStringFormat", (inst, def) => {
7826
- var _a, _b;
8129
+ var _a3, _b;
7827
8130
  $ZodCheck.init(inst, def);
7828
8131
  inst._zod.onattach.push((inst2) => {
7829
8132
  const bag = inst2._zod.bag;
@@ -7834,7 +8137,7 @@ var $ZodCheckStringFormat = /* @__PURE__ */ $constructor("$ZodCheckStringFormat"
7834
8137
  }
7835
8138
  });
7836
8139
  if (def.pattern)
7837
- (_a = inst._zod).check ?? (_a.check = (payload) => {
8140
+ (_a3 = inst._zod).check ?? (_a3.check = (payload) => {
7838
8141
  def.pattern.lastIndex = 0;
7839
8142
  if (def.pattern.test(payload.value))
7840
8143
  return;
@@ -7993,13 +8296,13 @@ var Doc = class {
7993
8296
  // ../../node_modules/zod/v4/core/versions.js
7994
8297
  var version = {
7995
8298
  major: 4,
7996
- minor: 0,
7997
- patch: 0
8299
+ minor: 4,
8300
+ patch: 3
7998
8301
  };
7999
8302
 
8000
8303
  // ../../node_modules/zod/v4/core/schemas.js
8001
8304
  var $ZodType = /* @__PURE__ */ $constructor("$ZodType", (inst, def) => {
8002
- var _a;
8305
+ var _a3;
8003
8306
  inst ?? (inst = {});
8004
8307
  inst._zod.def = def;
8005
8308
  inst._zod.bag = inst._zod.bag || {};
@@ -8014,7 +8317,7 @@ var $ZodType = /* @__PURE__ */ $constructor("$ZodType", (inst, def) => {
8014
8317
  }
8015
8318
  }
8016
8319
  if (checks.length === 0) {
8017
- (_a = inst._zod).deferred ?? (_a.deferred = []);
8320
+ (_a3 = inst._zod).deferred ?? (_a3.deferred = []);
8018
8321
  inst._zod.deferred?.push(() => {
8019
8322
  inst._zod.run = inst._zod.parse;
8020
8323
  });
@@ -8024,6 +8327,8 @@ var $ZodType = /* @__PURE__ */ $constructor("$ZodType", (inst, def) => {
8024
8327
  let asyncResult;
8025
8328
  for (const ch of checks2) {
8026
8329
  if (ch._zod.def.when) {
8330
+ if (explicitlyAborted(payload))
8331
+ continue;
8027
8332
  const shouldRun = ch._zod.def.when(payload);
8028
8333
  if (!shouldRun)
8029
8334
  continue;
@@ -8059,7 +8364,32 @@ var $ZodType = /* @__PURE__ */ $constructor("$ZodType", (inst, def) => {
8059
8364
  }
8060
8365
  return payload;
8061
8366
  };
8367
+ const handleCanaryResult = (canary, payload, ctx) => {
8368
+ if (aborted(canary)) {
8369
+ canary.aborted = true;
8370
+ return canary;
8371
+ }
8372
+ const checkResult = runChecks(payload, checks, ctx);
8373
+ if (checkResult instanceof Promise) {
8374
+ if (ctx.async === false)
8375
+ throw new $ZodAsyncError();
8376
+ return checkResult.then((checkResult2) => inst._zod.parse(checkResult2, ctx));
8377
+ }
8378
+ return inst._zod.parse(checkResult, ctx);
8379
+ };
8062
8380
  inst._zod.run = (payload, ctx) => {
8381
+ if (ctx.skipChecks) {
8382
+ return inst._zod.parse(payload, ctx);
8383
+ }
8384
+ if (ctx.direction === "backward") {
8385
+ const canary = inst._zod.parse({ value: payload.value, issues: [] }, { ...ctx, skipChecks: true });
8386
+ if (canary instanceof Promise) {
8387
+ return canary.then((canary2) => {
8388
+ return handleCanaryResult(canary2, payload, ctx);
8389
+ });
8390
+ }
8391
+ return handleCanaryResult(canary, payload, ctx);
8392
+ }
8063
8393
  const result = inst._zod.parse(payload, ctx);
8064
8394
  if (result instanceof Promise) {
8065
8395
  if (ctx.async === false)
@@ -8069,7 +8399,7 @@ var $ZodType = /* @__PURE__ */ $constructor("$ZodType", (inst, def) => {
8069
8399
  return runChecks(result, checks, ctx);
8070
8400
  };
8071
8401
  }
8072
- inst["~standard"] = {
8402
+ defineLazy(inst, "~standard", () => ({
8073
8403
  validate: (value) => {
8074
8404
  try {
8075
8405
  const r = safeParse(inst, value);
@@ -8080,7 +8410,7 @@ var $ZodType = /* @__PURE__ */ $constructor("$ZodType", (inst, def) => {
8080
8410
  },
8081
8411
  vendor: "zod",
8082
8412
  version: 1
8083
- };
8413
+ }));
8084
8414
  });
8085
8415
  var $ZodString = /* @__PURE__ */ $constructor("$ZodString", (inst, def) => {
8086
8416
  $ZodType.init(inst, def);
@@ -8138,9 +8468,21 @@ var $ZodURL = /* @__PURE__ */ $constructor("$ZodURL", (inst, def) => {
8138
8468
  $ZodStringFormat.init(inst, def);
8139
8469
  inst._zod.check = (payload) => {
8140
8470
  try {
8141
- const orig = payload.value;
8142
- const url = new URL(orig);
8143
- const href = url.href;
8471
+ const trimmed = payload.value.trim();
8472
+ if (!def.normalize && def.protocol?.source === httpProtocol.source) {
8473
+ if (!/^https?:\/\//i.test(trimmed)) {
8474
+ payload.issues.push({
8475
+ code: "invalid_format",
8476
+ format: "url",
8477
+ note: "Invalid URL format",
8478
+ input: payload.value,
8479
+ inst,
8480
+ continue: !def.abort
8481
+ });
8482
+ return;
8483
+ }
8484
+ }
8485
+ const url = new URL(trimmed);
8144
8486
  if (def.hostname) {
8145
8487
  def.hostname.lastIndex = 0;
8146
8488
  if (!def.hostname.test(url.hostname)) {
@@ -8148,7 +8490,7 @@ var $ZodURL = /* @__PURE__ */ $constructor("$ZodURL", (inst, def) => {
8148
8490
  code: "invalid_format",
8149
8491
  format: "url",
8150
8492
  note: "Invalid hostname",
8151
- pattern: hostname.source,
8493
+ pattern: def.hostname.source,
8152
8494
  input: payload.value,
8153
8495
  inst,
8154
8496
  continue: !def.abort
@@ -8169,10 +8511,10 @@ var $ZodURL = /* @__PURE__ */ $constructor("$ZodURL", (inst, def) => {
8169
8511
  });
8170
8512
  }
8171
8513
  }
8172
- if (!orig.endsWith("/") && href.endsWith("/")) {
8173
- payload.value = href.slice(0, -1);
8514
+ if (def.normalize) {
8515
+ payload.value = url.href;
8174
8516
  } else {
8175
- payload.value = href;
8517
+ payload.value = trimmed;
8176
8518
  }
8177
8519
  return;
8178
8520
  } catch (_) {
@@ -8233,18 +8575,12 @@ var $ZodISODuration = /* @__PURE__ */ $constructor("$ZodISODuration", (inst, def
8233
8575
  var $ZodIPv4 = /* @__PURE__ */ $constructor("$ZodIPv4", (inst, def) => {
8234
8576
  def.pattern ?? (def.pattern = ipv4);
8235
8577
  $ZodStringFormat.init(inst, def);
8236
- inst._zod.onattach.push((inst2) => {
8237
- const bag = inst2._zod.bag;
8238
- bag.format = `ipv4`;
8239
- });
8578
+ inst._zod.bag.format = `ipv4`;
8240
8579
  });
8241
8580
  var $ZodIPv6 = /* @__PURE__ */ $constructor("$ZodIPv6", (inst, def) => {
8242
8581
  def.pattern ?? (def.pattern = ipv6);
8243
8582
  $ZodStringFormat.init(inst, def);
8244
- inst._zod.onattach.push((inst2) => {
8245
- const bag = inst2._zod.bag;
8246
- bag.format = `ipv6`;
8247
- });
8583
+ inst._zod.bag.format = `ipv6`;
8248
8584
  inst._zod.check = (payload) => {
8249
8585
  try {
8250
8586
  new URL(`http://[${payload.value}]`);
@@ -8267,8 +8603,11 @@ var $ZodCIDRv6 = /* @__PURE__ */ $constructor("$ZodCIDRv6", (inst, def) => {
8267
8603
  def.pattern ?? (def.pattern = cidrv6);
8268
8604
  $ZodStringFormat.init(inst, def);
8269
8605
  inst._zod.check = (payload) => {
8270
- const [address, prefix] = payload.value.split("/");
8606
+ const parts = payload.value.split("/");
8271
8607
  try {
8608
+ if (parts.length !== 2)
8609
+ throw new Error();
8610
+ const [address, prefix] = parts;
8272
8611
  if (!prefix)
8273
8612
  throw new Error();
8274
8613
  const prefixNum = Number(prefix);
@@ -8291,6 +8630,8 @@ var $ZodCIDRv6 = /* @__PURE__ */ $constructor("$ZodCIDRv6", (inst, def) => {
8291
8630
  function isValidBase64(data) {
8292
8631
  if (data === "")
8293
8632
  return true;
8633
+ if (/\s/.test(data))
8634
+ return false;
8294
8635
  if (data.length % 4 !== 0)
8295
8636
  return false;
8296
8637
  try {
@@ -8303,9 +8644,7 @@ function isValidBase64(data) {
8303
8644
  var $ZodBase64 = /* @__PURE__ */ $constructor("$ZodBase64", (inst, def) => {
8304
8645
  def.pattern ?? (def.pattern = base64);
8305
8646
  $ZodStringFormat.init(inst, def);
8306
- inst._zod.onattach.push((inst2) => {
8307
- inst2._zod.bag.contentEncoding = "base64";
8308
- });
8647
+ inst._zod.bag.contentEncoding = "base64";
8309
8648
  inst._zod.check = (payload) => {
8310
8649
  if (isValidBase64(payload.value))
8311
8650
  return;
@@ -8328,9 +8667,7 @@ function isValidBase64URL(data) {
8328
8667
  var $ZodBase64URL = /* @__PURE__ */ $constructor("$ZodBase64URL", (inst, def) => {
8329
8668
  def.pattern ?? (def.pattern = base64url);
8330
8669
  $ZodStringFormat.init(inst, def);
8331
- inst._zod.onattach.push((inst2) => {
8332
- inst2._zod.bag.contentEncoding = "base64url";
8333
- });
8670
+ inst._zod.bag.contentEncoding = "base64url";
8334
8671
  inst._zod.check = (payload) => {
8335
8672
  if (isValidBase64URL(payload.value))
8336
8673
  return;
@@ -8405,7 +8742,7 @@ var $ZodNumber = /* @__PURE__ */ $constructor("$ZodNumber", (inst, def) => {
8405
8742
  return payload;
8406
8743
  };
8407
8744
  });
8408
- var $ZodNumberFormat = /* @__PURE__ */ $constructor("$ZodNumber", (inst, def) => {
8745
+ var $ZodNumberFormat = /* @__PURE__ */ $constructor("$ZodNumberFormat", (inst, def) => {
8409
8746
  $ZodCheckNumberFormat.init(inst, def);
8410
8747
  $ZodNumber.init(inst, def);
8411
8748
  });
@@ -8502,48 +8839,102 @@ var $ZodArray = /* @__PURE__ */ $constructor("$ZodArray", (inst, def) => {
8502
8839
  return payload;
8503
8840
  };
8504
8841
  });
8505
- function handleObjectResult(result, final, key) {
8842
+ function handlePropertyResult(result, final, key, input, isOptionalIn, isOptionalOut) {
8843
+ const isPresent = key in input;
8506
8844
  if (result.issues.length) {
8845
+ if (isOptionalIn && isOptionalOut && !isPresent) {
8846
+ return;
8847
+ }
8507
8848
  final.issues.push(...prefixIssues(key, result.issues));
8508
8849
  }
8509
- final.value[key] = result.value;
8510
- }
8511
- function handleOptionalObjectResult(result, final, key, input) {
8512
- if (result.issues.length) {
8513
- if (input[key] === void 0) {
8514
- if (key in input) {
8515
- final.value[key] = void 0;
8516
- } else {
8517
- final.value[key] = result.value;
8518
- }
8519
- } else {
8520
- final.issues.push(...prefixIssues(key, result.issues));
8850
+ if (!isPresent && !isOptionalIn) {
8851
+ if (!result.issues.length) {
8852
+ final.issues.push({
8853
+ code: "invalid_type",
8854
+ expected: "nonoptional",
8855
+ input: void 0,
8856
+ path: [key]
8857
+ });
8521
8858
  }
8522
- } else if (result.value === void 0) {
8523
- if (key in input)
8859
+ return;
8860
+ }
8861
+ if (result.value === void 0) {
8862
+ if (isPresent) {
8524
8863
  final.value[key] = void 0;
8864
+ }
8525
8865
  } else {
8526
8866
  final.value[key] = result.value;
8527
8867
  }
8528
8868
  }
8529
- var $ZodObject = /* @__PURE__ */ $constructor("$ZodObject", (inst, def) => {
8530
- $ZodType.init(inst, def);
8531
- const _normalized = cached(() => {
8532
- const keys = Object.keys(def.shape);
8533
- for (const k of keys) {
8534
- if (!(def.shape[k] instanceof $ZodType)) {
8535
- throw new Error(`Invalid element at key "${k}": expected a Zod schema`);
8536
- }
8869
+ function normalizeDef(def) {
8870
+ const keys = Object.keys(def.shape);
8871
+ for (const k of keys) {
8872
+ if (!def.shape?.[k]?._zod?.traits?.has("$ZodType")) {
8873
+ throw new Error(`Invalid element at key "${k}": expected a Zod schema`);
8537
8874
  }
8538
- const okeys = optionalKeys(def.shape);
8539
- return {
8540
- shape: def.shape,
8541
- keys,
8542
- keySet: new Set(keys),
8543
- numKeys: keys.length,
8544
- optionalKeys: new Set(okeys)
8545
- };
8875
+ }
8876
+ const okeys = optionalKeys(def.shape);
8877
+ return {
8878
+ ...def,
8879
+ keys,
8880
+ keySet: new Set(keys),
8881
+ numKeys: keys.length,
8882
+ optionalKeys: new Set(okeys)
8883
+ };
8884
+ }
8885
+ function handleCatchall(proms, input, payload, ctx, def, inst) {
8886
+ const unrecognized = [];
8887
+ const keySet = def.keySet;
8888
+ const _catchall = def.catchall._zod;
8889
+ const t = _catchall.def.type;
8890
+ const isOptionalIn = _catchall.optin === "optional";
8891
+ const isOptionalOut = _catchall.optout === "optional";
8892
+ for (const key in input) {
8893
+ if (key === "__proto__")
8894
+ continue;
8895
+ if (keySet.has(key))
8896
+ continue;
8897
+ if (t === "never") {
8898
+ unrecognized.push(key);
8899
+ continue;
8900
+ }
8901
+ const r = _catchall.run({ value: input[key], issues: [] }, ctx);
8902
+ if (r instanceof Promise) {
8903
+ proms.push(r.then((r2) => handlePropertyResult(r2, payload, key, input, isOptionalIn, isOptionalOut)));
8904
+ } else {
8905
+ handlePropertyResult(r, payload, key, input, isOptionalIn, isOptionalOut);
8906
+ }
8907
+ }
8908
+ if (unrecognized.length) {
8909
+ payload.issues.push({
8910
+ code: "unrecognized_keys",
8911
+ keys: unrecognized,
8912
+ input,
8913
+ inst
8914
+ });
8915
+ }
8916
+ if (!proms.length)
8917
+ return payload;
8918
+ return Promise.all(proms).then(() => {
8919
+ return payload;
8546
8920
  });
8921
+ }
8922
+ var $ZodObject = /* @__PURE__ */ $constructor("$ZodObject", (inst, def) => {
8923
+ $ZodType.init(inst, def);
8924
+ const desc = Object.getOwnPropertyDescriptor(def, "shape");
8925
+ if (!desc?.get) {
8926
+ const sh = def.shape;
8927
+ Object.defineProperty(def, "shape", {
8928
+ get: () => {
8929
+ const newSh = { ...sh };
8930
+ Object.defineProperty(def, "shape", {
8931
+ value: newSh
8932
+ });
8933
+ return newSh;
8934
+ }
8935
+ });
8936
+ }
8937
+ const _normalized = cached(() => normalizeDef(def));
8547
8938
  defineLazy(inst._zod, "propValues", () => {
8548
8939
  const shape = def.shape;
8549
8940
  const propValues = {};
@@ -8557,6 +8948,45 @@ var $ZodObject = /* @__PURE__ */ $constructor("$ZodObject", (inst, def) => {
8557
8948
  }
8558
8949
  return propValues;
8559
8950
  });
8951
+ const isObject2 = isObject;
8952
+ const catchall = def.catchall;
8953
+ let value;
8954
+ inst._zod.parse = (payload, ctx) => {
8955
+ value ?? (value = _normalized.value);
8956
+ const input = payload.value;
8957
+ if (!isObject2(input)) {
8958
+ payload.issues.push({
8959
+ expected: "object",
8960
+ code: "invalid_type",
8961
+ input,
8962
+ inst
8963
+ });
8964
+ return payload;
8965
+ }
8966
+ payload.value = {};
8967
+ const proms = [];
8968
+ const shape = value.shape;
8969
+ for (const key of value.keys) {
8970
+ const el = shape[key];
8971
+ const isOptionalIn = el._zod.optin === "optional";
8972
+ const isOptionalOut = el._zod.optout === "optional";
8973
+ const r = el._zod.run({ value: input[key], issues: [] }, ctx);
8974
+ if (r instanceof Promise) {
8975
+ proms.push(r.then((r2) => handlePropertyResult(r2, payload, key, input, isOptionalIn, isOptionalOut)));
8976
+ } else {
8977
+ handlePropertyResult(r, payload, key, input, isOptionalIn, isOptionalOut);
8978
+ }
8979
+ }
8980
+ if (!catchall) {
8981
+ return proms.length ? Promise.all(proms).then(() => payload) : payload;
8982
+ }
8983
+ return handleCatchall(proms, input, payload, ctx, _normalized.value, inst);
8984
+ };
8985
+ });
8986
+ var $ZodObjectJIT = /* @__PURE__ */ $constructor("$ZodObjectJIT", (inst, def) => {
8987
+ $ZodObject.init(inst, def);
8988
+ const superParse = inst._zod.parse;
8989
+ const _normalized = cached(() => normalizeDef(def));
8560
8990
  const generateFastpass = (shape) => {
8561
8991
  const doc = new Doc(["shape", "payload", "ctx"]);
8562
8992
  const normalized = _normalized.value;
@@ -8570,41 +9000,79 @@ var $ZodObject = /* @__PURE__ */ $constructor("$ZodObject", (inst, def) => {
8570
9000
  for (const key of normalized.keys) {
8571
9001
  ids[key] = `key_${counter++}`;
8572
9002
  }
8573
- doc.write(`const newResult = {}`);
9003
+ doc.write(`const newResult = {};`);
8574
9004
  for (const key of normalized.keys) {
8575
- if (normalized.optionalKeys.has(key)) {
8576
- const id = ids[key];
8577
- doc.write(`const ${id} = ${parseStr(key)};`);
8578
- const k = esc(key);
9005
+ const id = ids[key];
9006
+ const k = esc(key);
9007
+ const schema = shape[key];
9008
+ const isOptionalIn = schema?._zod?.optin === "optional";
9009
+ const isOptionalOut = schema?._zod?.optout === "optional";
9010
+ doc.write(`const ${id} = ${parseStr(key)};`);
9011
+ if (isOptionalIn && isOptionalOut) {
8579
9012
  doc.write(`
8580
9013
  if (${id}.issues.length) {
8581
- if (input[${k}] === undefined) {
8582
- if (${k} in input) {
8583
- newResult[${k}] = undefined;
8584
- }
8585
- } else {
8586
- payload.issues = payload.issues.concat(
8587
- ${id}.issues.map((iss) => ({
8588
- ...iss,
8589
- path: iss.path ? [${k}, ...iss.path] : [${k}],
8590
- }))
8591
- );
9014
+ if (${k} in input) {
9015
+ payload.issues = payload.issues.concat(${id}.issues.map(iss => ({
9016
+ ...iss,
9017
+ path: iss.path ? [${k}, ...iss.path] : [${k}]
9018
+ })));
9019
+ }
9020
+ }
9021
+
9022
+ if (${id}.value === undefined) {
9023
+ if (${k} in input) {
9024
+ newResult[${k}] = undefined;
8592
9025
  }
8593
- } else if (${id}.value === undefined) {
8594
- if (${k} in input) newResult[${k}] = undefined;
8595
9026
  } else {
8596
9027
  newResult[${k}] = ${id}.value;
8597
9028
  }
8598
- `);
9029
+
9030
+ `);
9031
+ } else if (!isOptionalIn) {
9032
+ doc.write(`
9033
+ const ${id}_present = ${k} in input;
9034
+ if (${id}.issues.length) {
9035
+ payload.issues = payload.issues.concat(${id}.issues.map(iss => ({
9036
+ ...iss,
9037
+ path: iss.path ? [${k}, ...iss.path] : [${k}]
9038
+ })));
9039
+ }
9040
+ if (!${id}_present && !${id}.issues.length) {
9041
+ payload.issues.push({
9042
+ code: "invalid_type",
9043
+ expected: "nonoptional",
9044
+ input: undefined,
9045
+ path: [${k}]
9046
+ });
9047
+ }
9048
+
9049
+ if (${id}_present) {
9050
+ if (${id}.value === undefined) {
9051
+ newResult[${k}] = undefined;
9052
+ } else {
9053
+ newResult[${k}] = ${id}.value;
9054
+ }
9055
+ }
9056
+
9057
+ `);
8599
9058
  } else {
8600
- const id = ids[key];
8601
- doc.write(`const ${id} = ${parseStr(key)};`);
8602
9059
  doc.write(`
8603
- if (${id}.issues.length) payload.issues = payload.issues.concat(${id}.issues.map(iss => ({
9060
+ if (${id}.issues.length) {
9061
+ payload.issues = payload.issues.concat(${id}.issues.map(iss => ({
8604
9062
  ...iss,
8605
- path: iss.path ? [${esc(key)}, ...iss.path] : [${esc(key)}]
8606
- })));`);
8607
- doc.write(`newResult[${esc(key)}] = ${id}.value`);
9063
+ path: iss.path ? [${k}, ...iss.path] : [${k}]
9064
+ })));
9065
+ }
9066
+
9067
+ if (${id}.value === undefined) {
9068
+ if (${k} in input) {
9069
+ newResult[${k}] = undefined;
9070
+ }
9071
+ } else {
9072
+ newResult[${k}] = ${id}.value;
9073
+ }
9074
+
9075
+ `);
8608
9076
  }
8609
9077
  }
8610
9078
  doc.write(`payload.value = newResult;`);
@@ -8631,61 +9099,15 @@ var $ZodObject = /* @__PURE__ */ $constructor("$ZodObject", (inst, def) => {
8631
9099
  });
8632
9100
  return payload;
8633
9101
  }
8634
- const proms = [];
8635
9102
  if (jit && fastEnabled && ctx?.async === false && ctx.jitless !== true) {
8636
9103
  if (!fastpass)
8637
9104
  fastpass = generateFastpass(def.shape);
8638
9105
  payload = fastpass(payload, ctx);
8639
- } else {
8640
- payload.value = {};
8641
- const shape = value.shape;
8642
- for (const key of value.keys) {
8643
- const el = shape[key];
8644
- const r = el._zod.run({ value: input[key], issues: [] }, ctx);
8645
- const isOptional = el._zod.optin === "optional" && el._zod.optout === "optional";
8646
- if (r instanceof Promise) {
8647
- proms.push(r.then((r2) => isOptional ? handleOptionalObjectResult(r2, payload, key, input) : handleObjectResult(r2, payload, key)));
8648
- } else if (isOptional) {
8649
- handleOptionalObjectResult(r, payload, key, input);
8650
- } else {
8651
- handleObjectResult(r, payload, key);
8652
- }
8653
- }
8654
- }
8655
- if (!catchall) {
8656
- return proms.length ? Promise.all(proms).then(() => payload) : payload;
8657
- }
8658
- const unrecognized = [];
8659
- const keySet = value.keySet;
8660
- const _catchall = catchall._zod;
8661
- const t = _catchall.def.type;
8662
- for (const key of Object.keys(input)) {
8663
- if (keySet.has(key))
8664
- continue;
8665
- if (t === "never") {
8666
- unrecognized.push(key);
8667
- continue;
8668
- }
8669
- const r = _catchall.run({ value: input[key], issues: [] }, ctx);
8670
- if (r instanceof Promise) {
8671
- proms.push(r.then((r2) => handleObjectResult(r2, payload, key)));
8672
- } else {
8673
- handleObjectResult(r, payload, key);
8674
- }
8675
- }
8676
- if (unrecognized.length) {
8677
- payload.issues.push({
8678
- code: "unrecognized_keys",
8679
- keys: unrecognized,
8680
- input,
8681
- inst
8682
- });
9106
+ if (!catchall)
9107
+ return payload;
9108
+ return handleCatchall([], input, payload, ctx, value, inst);
8683
9109
  }
8684
- if (!proms.length)
8685
- return payload;
8686
- return Promise.all(proms).then(() => {
8687
- return payload;
8688
- });
9110
+ return superParse(payload, ctx);
8689
9111
  };
8690
9112
  });
8691
9113
  function handleUnionResults(results, final, inst, ctx) {
@@ -8695,6 +9117,11 @@ function handleUnionResults(results, final, inst, ctx) {
8695
9117
  return final;
8696
9118
  }
8697
9119
  }
9120
+ const nonaborted = results.filter((r) => !aborted(r));
9121
+ if (nonaborted.length === 1) {
9122
+ final.value = nonaborted[0].value;
9123
+ return nonaborted[0];
9124
+ }
8698
9125
  final.issues.push({
8699
9126
  code: "invalid_union",
8700
9127
  input: final.value,
@@ -8720,7 +9147,11 @@ var $ZodUnion = /* @__PURE__ */ $constructor("$ZodUnion", (inst, def) => {
8720
9147
  }
8721
9148
  return void 0;
8722
9149
  });
9150
+ const first = def.options.length === 1 ? def.options[0]._zod.run : null;
8723
9151
  inst._zod.parse = (payload, ctx) => {
9152
+ if (first) {
9153
+ return first(payload, ctx);
9154
+ }
8724
9155
  let async = false;
8725
9156
  const results = [];
8726
9157
  for (const option of def.options) {
@@ -8745,6 +9176,7 @@ var $ZodUnion = /* @__PURE__ */ $constructor("$ZodUnion", (inst, def) => {
8745
9176
  };
8746
9177
  });
8747
9178
  var $ZodDiscriminatedUnion = /* @__PURE__ */ $constructor("$ZodDiscriminatedUnion", (inst, def) => {
9179
+ def.inclusive = false;
8748
9180
  $ZodUnion.init(inst, def);
8749
9181
  const _super = inst._zod.parse;
8750
9182
  defineLazy(inst._zod, "propValues", () => {
@@ -8767,7 +9199,7 @@ var $ZodDiscriminatedUnion = /* @__PURE__ */ $constructor("$ZodDiscriminatedUnio
8767
9199
  const opts = def.options;
8768
9200
  const map = /* @__PURE__ */ new Map();
8769
9201
  for (const o of opts) {
8770
- const values = o._zod.propValues[def.discriminator];
9202
+ const values = o._zod.propValues?.[def.discriminator];
8771
9203
  if (!values || values.size === 0)
8772
9204
  throw new Error(`Invalid discriminated union option at index "${def.options.indexOf(o)}"`);
8773
9205
  for (const v of values) {
@@ -8794,13 +9226,15 @@ var $ZodDiscriminatedUnion = /* @__PURE__ */ $constructor("$ZodDiscriminatedUnio
8794
9226
  if (opt) {
8795
9227
  return opt._zod.run(payload, ctx);
8796
9228
  }
8797
- if (def.unionFallback) {
9229
+ if (def.unionFallback || ctx.direction === "backward") {
8798
9230
  return _super(payload, ctx);
8799
9231
  }
8800
9232
  payload.issues.push({
8801
9233
  code: "invalid_union",
8802
9234
  errors: [],
8803
9235
  note: "No matching discriminator",
9236
+ discriminator: def.discriminator,
9237
+ options: Array.from(disc.value.keys()),
8804
9238
  input,
8805
9239
  path: [def.discriminator],
8806
9240
  inst
@@ -8868,11 +9302,34 @@ function mergeValues(a, b) {
8868
9302
  return { valid: false, mergeErrorPath: [] };
8869
9303
  }
8870
9304
  function handleIntersectionResults(result, left, right) {
8871
- if (left.issues.length) {
8872
- result.issues.push(...left.issues);
9305
+ const unrecKeys = /* @__PURE__ */ new Map();
9306
+ let unrecIssue;
9307
+ for (const iss of left.issues) {
9308
+ if (iss.code === "unrecognized_keys") {
9309
+ unrecIssue ?? (unrecIssue = iss);
9310
+ for (const k of iss.keys) {
9311
+ if (!unrecKeys.has(k))
9312
+ unrecKeys.set(k, {});
9313
+ unrecKeys.get(k).l = true;
9314
+ }
9315
+ } else {
9316
+ result.issues.push(iss);
9317
+ }
9318
+ }
9319
+ for (const iss of right.issues) {
9320
+ if (iss.code === "unrecognized_keys") {
9321
+ for (const k of iss.keys) {
9322
+ if (!unrecKeys.has(k))
9323
+ unrecKeys.set(k, {});
9324
+ unrecKeys.get(k).r = true;
9325
+ }
9326
+ } else {
9327
+ result.issues.push(iss);
9328
+ }
8873
9329
  }
8874
- if (right.issues.length) {
8875
- result.issues.push(...right.issues);
9330
+ const bothKeys = [...unrecKeys].filter(([, f]) => f.l && f.r).map(([k]) => k);
9331
+ if (bothKeys.length && unrecIssue) {
9332
+ result.issues.push({ ...unrecIssue, keys: bothKeys });
8876
9333
  }
8877
9334
  if (aborted(result))
8878
9335
  return result;
@@ -8897,30 +9354,48 @@ var $ZodRecord = /* @__PURE__ */ $constructor("$ZodRecord", (inst, def) => {
8897
9354
  return payload;
8898
9355
  }
8899
9356
  const proms = [];
8900
- if (def.keyType._zod.values) {
8901
- const values = def.keyType._zod.values;
9357
+ const values = def.keyType._zod.values;
9358
+ if (values) {
8902
9359
  payload.value = {};
9360
+ const recordKeys = /* @__PURE__ */ new Set();
8903
9361
  for (const key of values) {
8904
9362
  if (typeof key === "string" || typeof key === "number" || typeof key === "symbol") {
9363
+ recordKeys.add(typeof key === "number" ? key.toString() : key);
9364
+ const keyResult = def.keyType._zod.run({ value: key, issues: [] }, ctx);
9365
+ if (keyResult instanceof Promise) {
9366
+ throw new Error("Async schemas not supported in object keys currently");
9367
+ }
9368
+ if (keyResult.issues.length) {
9369
+ payload.issues.push({
9370
+ code: "invalid_key",
9371
+ origin: "record",
9372
+ issues: keyResult.issues.map((iss) => finalizeIssue(iss, ctx, config())),
9373
+ input: key,
9374
+ path: [key],
9375
+ inst
9376
+ });
9377
+ continue;
9378
+ }
9379
+ const outKey = keyResult.value;
8905
9380
  const result = def.valueType._zod.run({ value: input[key], issues: [] }, ctx);
8906
9381
  if (result instanceof Promise) {
8907
9382
  proms.push(result.then((result2) => {
8908
9383
  if (result2.issues.length) {
8909
9384
  payload.issues.push(...prefixIssues(key, result2.issues));
8910
9385
  }
8911
- payload.value[key] = result2.value;
9386
+ payload.value[outKey] = result2.value;
8912
9387
  }));
8913
9388
  } else {
8914
9389
  if (result.issues.length) {
8915
9390
  payload.issues.push(...prefixIssues(key, result.issues));
8916
9391
  }
8917
- payload.value[key] = result.value;
9392
+ payload.value[outKey] = result.value;
8918
9393
  }
8919
9394
  }
8920
9395
  }
8921
9396
  let unrecognized;
8922
9397
  for (const key in input) {
8923
- if (!values.has(key)) {
9398
+ if (!recordKeys.has(key)) {
8924
9399
  unrecognized = unrecognized ?? [];
8925
9400
  unrecognized.push(key);
8926
9401
  }
@@ -8938,20 +9413,35 @@ var $ZodRecord = /* @__PURE__ */ $constructor("$ZodRecord", (inst, def) => {
8938
9413
  for (const key of Reflect.ownKeys(input)) {
8939
9414
  if (key === "__proto__")
8940
9415
  continue;
8941
- const keyResult = def.keyType._zod.run({ value: key, issues: [] }, ctx);
9416
+ if (!Object.prototype.propertyIsEnumerable.call(input, key))
9417
+ continue;
9418
+ let keyResult = def.keyType._zod.run({ value: key, issues: [] }, ctx);
8942
9419
  if (keyResult instanceof Promise) {
8943
9420
  throw new Error("Async schemas not supported in object keys currently");
8944
9421
  }
9422
+ const checkNumericKey = typeof key === "string" && number.test(key) && keyResult.issues.length;
9423
+ if (checkNumericKey) {
9424
+ const retryResult = def.keyType._zod.run({ value: Number(key), issues: [] }, ctx);
9425
+ if (retryResult instanceof Promise) {
9426
+ throw new Error("Async schemas not supported in object keys currently");
9427
+ }
9428
+ if (retryResult.issues.length === 0) {
9429
+ keyResult = retryResult;
9430
+ }
9431
+ }
8945
9432
  if (keyResult.issues.length) {
8946
- payload.issues.push({
8947
- origin: "record",
8948
- code: "invalid_key",
8949
- issues: keyResult.issues.map((iss) => finalizeIssue(iss, ctx, config())),
8950
- input: key,
8951
- path: [key],
8952
- inst
8953
- });
8954
- payload.value[keyResult.value] = keyResult.value;
9433
+ if (def.mode === "loose") {
9434
+ payload.value[key] = input[key];
9435
+ } else {
9436
+ payload.issues.push({
9437
+ code: "invalid_key",
9438
+ origin: "record",
9439
+ issues: keyResult.issues.map((iss) => finalizeIssue(iss, ctx, config())),
9440
+ input: key,
9441
+ path: [key],
9442
+ inst
9443
+ });
9444
+ }
8955
9445
  continue;
8956
9446
  }
8957
9447
  const result = def.valueType._zod.run({ value: input[key], issues: [] }, ctx);
@@ -8979,11 +9469,12 @@ var $ZodRecord = /* @__PURE__ */ $constructor("$ZodRecord", (inst, def) => {
8979
9469
  var $ZodEnum = /* @__PURE__ */ $constructor("$ZodEnum", (inst, def) => {
8980
9470
  $ZodType.init(inst, def);
8981
9471
  const values = getEnumValues(def.entries);
8982
- inst._zod.values = new Set(values);
9472
+ const valuesSet = new Set(values);
9473
+ inst._zod.values = valuesSet;
8983
9474
  inst._zod.pattern = new RegExp(`^(${values.filter((k) => propertyKeyTypes.has(typeof k)).map((o) => typeof o === "string" ? escapeRegex(o) : o.toString()).join("|")})$`);
8984
9475
  inst._zod.parse = (payload, _ctx) => {
8985
9476
  const input = payload.value;
8986
- if (inst._zod.values.has(input)) {
9477
+ if (valuesSet.has(input)) {
8987
9478
  return payload;
8988
9479
  }
8989
9480
  payload.issues.push({
@@ -8997,11 +9488,15 @@ var $ZodEnum = /* @__PURE__ */ $constructor("$ZodEnum", (inst, def) => {
8997
9488
  });
8998
9489
  var $ZodLiteral = /* @__PURE__ */ $constructor("$ZodLiteral", (inst, def) => {
8999
9490
  $ZodType.init(inst, def);
9000
- inst._zod.values = new Set(def.values);
9001
- inst._zod.pattern = new RegExp(`^(${def.values.map((o) => typeof o === "string" ? escapeRegex(o) : o ? o.toString() : String(o)).join("|")})$`);
9491
+ if (def.values.length === 0) {
9492
+ throw new Error("Cannot create literal schema with no valid values");
9493
+ }
9494
+ const values = new Set(def.values);
9495
+ inst._zod.values = values;
9496
+ inst._zod.pattern = new RegExp(`^(${def.values.map((o) => typeof o === "string" ? escapeRegex(o) : o ? escapeRegex(o.toString()) : String(o)).join("|")})$`);
9002
9497
  inst._zod.parse = (payload, _ctx) => {
9003
9498
  const input = payload.value;
9004
- if (inst._zod.values.has(input)) {
9499
+ if (values.has(input)) {
9005
9500
  return payload;
9006
9501
  }
9007
9502
  payload.issues.push({
@@ -9015,12 +9510,17 @@ var $ZodLiteral = /* @__PURE__ */ $constructor("$ZodLiteral", (inst, def) => {
9015
9510
  });
9016
9511
  var $ZodTransform = /* @__PURE__ */ $constructor("$ZodTransform", (inst, def) => {
9017
9512
  $ZodType.init(inst, def);
9018
- inst._zod.parse = (payload, _ctx) => {
9513
+ inst._zod.optin = "optional";
9514
+ inst._zod.parse = (payload, ctx) => {
9515
+ if (ctx.direction === "backward") {
9516
+ throw new $ZodEncodeError(inst.constructor.name);
9517
+ }
9019
9518
  const _out = def.transform(payload.value, payload);
9020
- if (_ctx.async) {
9519
+ if (ctx.async) {
9021
9520
  const output = _out instanceof Promise ? _out : Promise.resolve(_out);
9022
9521
  return output.then((output2) => {
9023
9522
  payload.value = output2;
9523
+ payload.fallback = true;
9024
9524
  return payload;
9025
9525
  });
9026
9526
  }
@@ -9028,9 +9528,16 @@ var $ZodTransform = /* @__PURE__ */ $constructor("$ZodTransform", (inst, def) =>
9028
9528
  throw new $ZodAsyncError();
9029
9529
  }
9030
9530
  payload.value = _out;
9531
+ payload.fallback = true;
9031
9532
  return payload;
9032
9533
  };
9033
9534
  });
9535
+ function handleOptionalResult(result, input) {
9536
+ if (input === void 0 && (result.issues.length || result.fallback)) {
9537
+ return { issues: [], value: void 0 };
9538
+ }
9539
+ return result;
9540
+ }
9034
9541
  var $ZodOptional = /* @__PURE__ */ $constructor("$ZodOptional", (inst, def) => {
9035
9542
  $ZodType.init(inst, def);
9036
9543
  inst._zod.optin = "optional";
@@ -9044,7 +9551,11 @@ var $ZodOptional = /* @__PURE__ */ $constructor("$ZodOptional", (inst, def) => {
9044
9551
  });
9045
9552
  inst._zod.parse = (payload, ctx) => {
9046
9553
  if (def.innerType._zod.optin === "optional") {
9047
- return def.innerType._zod.run(payload, ctx);
9554
+ const input = payload.value;
9555
+ const result = def.innerType._zod.run(payload, ctx);
9556
+ if (result instanceof Promise)
9557
+ return result.then((r) => handleOptionalResult(r, input));
9558
+ return handleOptionalResult(result, input);
9048
9559
  }
9049
9560
  if (payload.value === void 0) {
9050
9561
  return payload;
@@ -9052,6 +9563,14 @@ var $ZodOptional = /* @__PURE__ */ $constructor("$ZodOptional", (inst, def) => {
9052
9563
  return def.innerType._zod.run(payload, ctx);
9053
9564
  };
9054
9565
  });
9566
+ var $ZodExactOptional = /* @__PURE__ */ $constructor("$ZodExactOptional", (inst, def) => {
9567
+ $ZodOptional.init(inst, def);
9568
+ defineLazy(inst._zod, "values", () => def.innerType._zod.values);
9569
+ defineLazy(inst._zod, "pattern", () => def.innerType._zod.pattern);
9570
+ inst._zod.parse = (payload, ctx) => {
9571
+ return def.innerType._zod.run(payload, ctx);
9572
+ };
9573
+ });
9055
9574
  var $ZodNullable = /* @__PURE__ */ $constructor("$ZodNullable", (inst, def) => {
9056
9575
  $ZodType.init(inst, def);
9057
9576
  defineLazy(inst._zod, "optin", () => def.innerType._zod.optin);
@@ -9074,6 +9593,9 @@ var $ZodDefault = /* @__PURE__ */ $constructor("$ZodDefault", (inst, def) => {
9074
9593
  inst._zod.optin = "optional";
9075
9594
  defineLazy(inst._zod, "values", () => def.innerType._zod.values);
9076
9595
  inst._zod.parse = (payload, ctx) => {
9596
+ if (ctx.direction === "backward") {
9597
+ return def.innerType._zod.run(payload, ctx);
9598
+ }
9077
9599
  if (payload.value === void 0) {
9078
9600
  payload.value = def.defaultValue;
9079
9601
  return payload;
@@ -9096,6 +9618,9 @@ var $ZodPrefault = /* @__PURE__ */ $constructor("$ZodPrefault", (inst, def) => {
9096
9618
  inst._zod.optin = "optional";
9097
9619
  defineLazy(inst._zod, "values", () => def.innerType._zod.values);
9098
9620
  inst._zod.parse = (payload, ctx) => {
9621
+ if (ctx.direction === "backward") {
9622
+ return def.innerType._zod.run(payload, ctx);
9623
+ }
9099
9624
  if (payload.value === void 0) {
9100
9625
  payload.value = def.defaultValue;
9101
9626
  }
@@ -9133,6 +9658,9 @@ var $ZodCatch = /* @__PURE__ */ $constructor("$ZodCatch", (inst, def) => {
9133
9658
  defineLazy(inst._zod, "optout", () => def.innerType._zod.optout);
9134
9659
  defineLazy(inst._zod, "values", () => def.innerType._zod.values);
9135
9660
  inst._zod.parse = (payload, ctx) => {
9661
+ if (ctx.direction === "backward") {
9662
+ return def.innerType._zod.run(payload, ctx);
9663
+ }
9136
9664
  const result = def.innerType._zod.run(payload, ctx);
9137
9665
  if (result instanceof Promise) {
9138
9666
  return result.then((result2) => {
@@ -9146,6 +9674,7 @@ var $ZodCatch = /* @__PURE__ */ $constructor("$ZodCatch", (inst, def) => {
9146
9674
  input: payload.value
9147
9675
  });
9148
9676
  payload.issues = [];
9677
+ payload.fallback = true;
9149
9678
  }
9150
9679
  return payload;
9151
9680
  });
@@ -9160,6 +9689,7 @@ var $ZodCatch = /* @__PURE__ */ $constructor("$ZodCatch", (inst, def) => {
9160
9689
  input: payload.value
9161
9690
  });
9162
9691
  payload.issues = [];
9692
+ payload.fallback = true;
9163
9693
  }
9164
9694
  return payload;
9165
9695
  };
@@ -9169,27 +9699,42 @@ var $ZodPipe = /* @__PURE__ */ $constructor("$ZodPipe", (inst, def) => {
9169
9699
  defineLazy(inst._zod, "values", () => def.in._zod.values);
9170
9700
  defineLazy(inst._zod, "optin", () => def.in._zod.optin);
9171
9701
  defineLazy(inst._zod, "optout", () => def.out._zod.optout);
9702
+ defineLazy(inst._zod, "propValues", () => def.in._zod.propValues);
9172
9703
  inst._zod.parse = (payload, ctx) => {
9704
+ if (ctx.direction === "backward") {
9705
+ const right = def.out._zod.run(payload, ctx);
9706
+ if (right instanceof Promise) {
9707
+ return right.then((right2) => handlePipeResult(right2, def.in, ctx));
9708
+ }
9709
+ return handlePipeResult(right, def.in, ctx);
9710
+ }
9173
9711
  const left = def.in._zod.run(payload, ctx);
9174
9712
  if (left instanceof Promise) {
9175
- return left.then((left2) => handlePipeResult(left2, def, ctx));
9713
+ return left.then((left2) => handlePipeResult(left2, def.out, ctx));
9176
9714
  }
9177
- return handlePipeResult(left, def, ctx);
9715
+ return handlePipeResult(left, def.out, ctx);
9178
9716
  };
9179
9717
  });
9180
- function handlePipeResult(left, def, ctx) {
9181
- if (aborted(left)) {
9718
+ function handlePipeResult(left, next, ctx) {
9719
+ if (left.issues.length) {
9720
+ left.aborted = true;
9182
9721
  return left;
9183
9722
  }
9184
- return def.out._zod.run({ value: left.value, issues: left.issues }, ctx);
9723
+ return next._zod.run({ value: left.value, issues: left.issues, fallback: left.fallback }, ctx);
9185
9724
  }
9725
+ var $ZodPreprocess = /* @__PURE__ */ $constructor("$ZodPreprocess", (inst, def) => {
9726
+ $ZodPipe.init(inst, def);
9727
+ });
9186
9728
  var $ZodReadonly = /* @__PURE__ */ $constructor("$ZodReadonly", (inst, def) => {
9187
9729
  $ZodType.init(inst, def);
9188
9730
  defineLazy(inst._zod, "propValues", () => def.innerType._zod.propValues);
9189
9731
  defineLazy(inst._zod, "values", () => def.innerType._zod.values);
9190
- defineLazy(inst._zod, "optin", () => def.innerType._zod.optin);
9191
- defineLazy(inst._zod, "optout", () => def.innerType._zod.optout);
9732
+ defineLazy(inst._zod, "optin", () => def.innerType?._zod?.optin);
9733
+ defineLazy(inst._zod, "optout", () => def.innerType?._zod?.optout);
9192
9734
  inst._zod.parse = (payload, ctx) => {
9735
+ if (ctx.direction === "backward") {
9736
+ return def.innerType._zod.run(payload, ctx);
9737
+ }
9193
9738
  const result = def.innerType._zod.run(payload, ctx);
9194
9739
  if (result instanceof Promise) {
9195
9740
  return result.then(handleReadonlyResult);
@@ -9236,37 +9781,18 @@ function handleRefineResult(result, payload, input, inst) {
9236
9781
  }
9237
9782
 
9238
9783
  // ../../node_modules/zod/v4/locales/en.js
9239
- var parsedType = (data) => {
9240
- const t = typeof data;
9241
- switch (t) {
9242
- case "number": {
9243
- return Number.isNaN(data) ? "NaN" : "number";
9244
- }
9245
- case "object": {
9246
- if (Array.isArray(data)) {
9247
- return "array";
9248
- }
9249
- if (data === null) {
9250
- return "null";
9251
- }
9252
- if (Object.getPrototypeOf(data) !== Object.prototype && data.constructor) {
9253
- return data.constructor.name;
9254
- }
9255
- }
9256
- }
9257
- return t;
9258
- };
9259
9784
  var error = () => {
9260
9785
  const Sizable = {
9261
9786
  string: { unit: "characters", verb: "to have" },
9262
9787
  file: { unit: "bytes", verb: "to have" },
9263
9788
  array: { unit: "items", verb: "to have" },
9264
- set: { unit: "items", verb: "to have" }
9789
+ set: { unit: "items", verb: "to have" },
9790
+ map: { unit: "entries", verb: "to have" }
9265
9791
  };
9266
9792
  function getSizing(origin) {
9267
9793
  return Sizable[origin] ?? null;
9268
9794
  }
9269
- const Nouns = {
9795
+ const FormatDictionary = {
9270
9796
  regex: "input",
9271
9797
  email: "email address",
9272
9798
  url: "URL",
@@ -9287,6 +9813,7 @@ var error = () => {
9287
9813
  duration: "ISO duration",
9288
9814
  ipv4: "IPv4 address",
9289
9815
  ipv6: "IPv6 address",
9816
+ mac: "MAC address",
9290
9817
  cidrv4: "IPv4 range",
9291
9818
  cidrv6: "IPv6 range",
9292
9819
  base64: "base64-encoded string",
@@ -9296,10 +9823,19 @@ var error = () => {
9296
9823
  jwt: "JWT",
9297
9824
  template_literal: "input"
9298
9825
  };
9826
+ const TypeDictionary = {
9827
+ // Compatibility: "nan" -> "NaN" for display
9828
+ nan: "NaN"
9829
+ // All other type names omitted - they fall back to raw values via ?? operator
9830
+ };
9299
9831
  return (issue2) => {
9300
9832
  switch (issue2.code) {
9301
- case "invalid_type":
9302
- return `Invalid input: expected ${issue2.expected}, received ${parsedType(issue2.input)}`;
9833
+ case "invalid_type": {
9834
+ const expected = TypeDictionary[issue2.expected] ?? issue2.expected;
9835
+ const receivedType = parsedType(issue2.input);
9836
+ const received = TypeDictionary[receivedType] ?? receivedType;
9837
+ return `Invalid input: expected ${expected}, received ${received}`;
9838
+ }
9303
9839
  case "invalid_value":
9304
9840
  if (issue2.values.length === 1)
9305
9841
  return `Invalid input: expected ${stringifyPrimitive(issue2.values[0])}`;
@@ -9330,7 +9866,7 @@ var error = () => {
9330
9866
  return `Invalid string: must include "${_issue.includes}"`;
9331
9867
  if (_issue.format === "regex")
9332
9868
  return `Invalid string: must match pattern ${_issue.pattern}`;
9333
- return `Invalid ${Nouns[_issue.format] ?? issue2.format}`;
9869
+ return `Invalid ${FormatDictionary[_issue.format] ?? issue2.format}`;
9334
9870
  }
9335
9871
  case "not_multiple_of":
9336
9872
  return `Invalid number: must be a multiple of ${issue2.divisor}`;
@@ -9339,6 +9875,10 @@ var error = () => {
9339
9875
  case "invalid_key":
9340
9876
  return `Invalid key in ${issue2.origin}`;
9341
9877
  case "invalid_union":
9878
+ if (issue2.options && Array.isArray(issue2.options) && issue2.options.length > 0) {
9879
+ const opts = issue2.options.map((o) => `'${o}'`).join(" | ");
9880
+ return `Invalid discriminator value. Expected ${opts}`;
9881
+ }
9342
9882
  return "Invalid input";
9343
9883
  case "invalid_element":
9344
9884
  return `Invalid value in ${issue2.origin}`;
@@ -9354,31 +9894,29 @@ function en_default() {
9354
9894
  }
9355
9895
 
9356
9896
  // ../../node_modules/zod/v4/core/registries.js
9897
+ var _a2;
9357
9898
  var $ZodRegistry = class {
9358
9899
  constructor() {
9359
- this._map = /* @__PURE__ */ new Map();
9900
+ this._map = /* @__PURE__ */ new WeakMap();
9360
9901
  this._idmap = /* @__PURE__ */ new Map();
9361
9902
  }
9362
9903
  add(schema, ..._meta) {
9363
- const meta = _meta[0];
9364
- this._map.set(schema, meta);
9365
- if (meta && typeof meta === "object" && "id" in meta) {
9366
- if (this._idmap.has(meta.id)) {
9367
- throw new Error(`ID ${meta.id} already exists in the registry`);
9368
- }
9369
- this._idmap.set(meta.id, schema);
9904
+ const meta2 = _meta[0];
9905
+ this._map.set(schema, meta2);
9906
+ if (meta2 && typeof meta2 === "object" && "id" in meta2) {
9907
+ this._idmap.set(meta2.id, schema);
9370
9908
  }
9371
9909
  return this;
9372
9910
  }
9373
9911
  clear() {
9374
- this._map = /* @__PURE__ */ new Map();
9912
+ this._map = /* @__PURE__ */ new WeakMap();
9375
9913
  this._idmap = /* @__PURE__ */ new Map();
9376
9914
  return this;
9377
9915
  }
9378
9916
  remove(schema) {
9379
- const meta = this._map.get(schema);
9380
- if (meta && typeof meta === "object" && "id" in meta) {
9381
- this._idmap.delete(meta.id);
9917
+ const meta2 = this._map.get(schema);
9918
+ if (meta2 && typeof meta2 === "object" && "id" in meta2) {
9919
+ this._idmap.delete(meta2.id);
9382
9920
  }
9383
9921
  this._map.delete(schema);
9384
9922
  return this;
@@ -9388,7 +9926,8 @@ var $ZodRegistry = class {
9388
9926
  if (p) {
9389
9927
  const pm = { ...this.get(p) ?? {} };
9390
9928
  delete pm.id;
9391
- return { ...pm, ...this._map.get(schema) };
9929
+ const f = { ...pm, ...this._map.get(schema) };
9930
+ return Object.keys(f).length ? f : void 0;
9392
9931
  }
9393
9932
  return this._map.get(schema);
9394
9933
  }
@@ -9399,15 +9938,18 @@ var $ZodRegistry = class {
9399
9938
  function registry() {
9400
9939
  return new $ZodRegistry();
9401
9940
  }
9402
- var globalRegistry = /* @__PURE__ */ registry();
9941
+ (_a2 = globalThis).__zod_globalRegistry ?? (_a2.__zod_globalRegistry = registry());
9942
+ var globalRegistry = globalThis.__zod_globalRegistry;
9403
9943
 
9404
9944
  // ../../node_modules/zod/v4/core/api.js
9945
+ // @__NO_SIDE_EFFECTS__
9405
9946
  function _string(Class2, params) {
9406
9947
  return new Class2({
9407
9948
  type: "string",
9408
9949
  ...normalizeParams(params)
9409
9950
  });
9410
9951
  }
9952
+ // @__NO_SIDE_EFFECTS__
9411
9953
  function _email(Class2, params) {
9412
9954
  return new Class2({
9413
9955
  type: "string",
@@ -9417,6 +9959,7 @@ function _email(Class2, params) {
9417
9959
  ...normalizeParams(params)
9418
9960
  });
9419
9961
  }
9962
+ // @__NO_SIDE_EFFECTS__
9420
9963
  function _guid(Class2, params) {
9421
9964
  return new Class2({
9422
9965
  type: "string",
@@ -9426,6 +9969,7 @@ function _guid(Class2, params) {
9426
9969
  ...normalizeParams(params)
9427
9970
  });
9428
9971
  }
9972
+ // @__NO_SIDE_EFFECTS__
9429
9973
  function _uuid(Class2, params) {
9430
9974
  return new Class2({
9431
9975
  type: "string",
@@ -9435,6 +9979,7 @@ function _uuid(Class2, params) {
9435
9979
  ...normalizeParams(params)
9436
9980
  });
9437
9981
  }
9982
+ // @__NO_SIDE_EFFECTS__
9438
9983
  function _uuidv4(Class2, params) {
9439
9984
  return new Class2({
9440
9985
  type: "string",
@@ -9445,6 +9990,7 @@ function _uuidv4(Class2, params) {
9445
9990
  ...normalizeParams(params)
9446
9991
  });
9447
9992
  }
9993
+ // @__NO_SIDE_EFFECTS__
9448
9994
  function _uuidv6(Class2, params) {
9449
9995
  return new Class2({
9450
9996
  type: "string",
@@ -9455,6 +10001,7 @@ function _uuidv6(Class2, params) {
9455
10001
  ...normalizeParams(params)
9456
10002
  });
9457
10003
  }
10004
+ // @__NO_SIDE_EFFECTS__
9458
10005
  function _uuidv7(Class2, params) {
9459
10006
  return new Class2({
9460
10007
  type: "string",
@@ -9465,6 +10012,7 @@ function _uuidv7(Class2, params) {
9465
10012
  ...normalizeParams(params)
9466
10013
  });
9467
10014
  }
10015
+ // @__NO_SIDE_EFFECTS__
9468
10016
  function _url(Class2, params) {
9469
10017
  return new Class2({
9470
10018
  type: "string",
@@ -9474,6 +10022,7 @@ function _url(Class2, params) {
9474
10022
  ...normalizeParams(params)
9475
10023
  });
9476
10024
  }
10025
+ // @__NO_SIDE_EFFECTS__
9477
10026
  function _emoji2(Class2, params) {
9478
10027
  return new Class2({
9479
10028
  type: "string",
@@ -9483,6 +10032,7 @@ function _emoji2(Class2, params) {
9483
10032
  ...normalizeParams(params)
9484
10033
  });
9485
10034
  }
10035
+ // @__NO_SIDE_EFFECTS__
9486
10036
  function _nanoid(Class2, params) {
9487
10037
  return new Class2({
9488
10038
  type: "string",
@@ -9492,6 +10042,7 @@ function _nanoid(Class2, params) {
9492
10042
  ...normalizeParams(params)
9493
10043
  });
9494
10044
  }
10045
+ // @__NO_SIDE_EFFECTS__
9495
10046
  function _cuid(Class2, params) {
9496
10047
  return new Class2({
9497
10048
  type: "string",
@@ -9501,6 +10052,7 @@ function _cuid(Class2, params) {
9501
10052
  ...normalizeParams(params)
9502
10053
  });
9503
10054
  }
10055
+ // @__NO_SIDE_EFFECTS__
9504
10056
  function _cuid2(Class2, params) {
9505
10057
  return new Class2({
9506
10058
  type: "string",
@@ -9510,6 +10062,7 @@ function _cuid2(Class2, params) {
9510
10062
  ...normalizeParams(params)
9511
10063
  });
9512
10064
  }
10065
+ // @__NO_SIDE_EFFECTS__
9513
10066
  function _ulid(Class2, params) {
9514
10067
  return new Class2({
9515
10068
  type: "string",
@@ -9519,6 +10072,7 @@ function _ulid(Class2, params) {
9519
10072
  ...normalizeParams(params)
9520
10073
  });
9521
10074
  }
10075
+ // @__NO_SIDE_EFFECTS__
9522
10076
  function _xid(Class2, params) {
9523
10077
  return new Class2({
9524
10078
  type: "string",
@@ -9528,6 +10082,7 @@ function _xid(Class2, params) {
9528
10082
  ...normalizeParams(params)
9529
10083
  });
9530
10084
  }
10085
+ // @__NO_SIDE_EFFECTS__
9531
10086
  function _ksuid(Class2, params) {
9532
10087
  return new Class2({
9533
10088
  type: "string",
@@ -9537,6 +10092,7 @@ function _ksuid(Class2, params) {
9537
10092
  ...normalizeParams(params)
9538
10093
  });
9539
10094
  }
10095
+ // @__NO_SIDE_EFFECTS__
9540
10096
  function _ipv4(Class2, params) {
9541
10097
  return new Class2({
9542
10098
  type: "string",
@@ -9546,6 +10102,7 @@ function _ipv4(Class2, params) {
9546
10102
  ...normalizeParams(params)
9547
10103
  });
9548
10104
  }
10105
+ // @__NO_SIDE_EFFECTS__
9549
10106
  function _ipv6(Class2, params) {
9550
10107
  return new Class2({
9551
10108
  type: "string",
@@ -9555,6 +10112,7 @@ function _ipv6(Class2, params) {
9555
10112
  ...normalizeParams(params)
9556
10113
  });
9557
10114
  }
10115
+ // @__NO_SIDE_EFFECTS__
9558
10116
  function _cidrv4(Class2, params) {
9559
10117
  return new Class2({
9560
10118
  type: "string",
@@ -9564,6 +10122,7 @@ function _cidrv4(Class2, params) {
9564
10122
  ...normalizeParams(params)
9565
10123
  });
9566
10124
  }
10125
+ // @__NO_SIDE_EFFECTS__
9567
10126
  function _cidrv6(Class2, params) {
9568
10127
  return new Class2({
9569
10128
  type: "string",
@@ -9573,6 +10132,7 @@ function _cidrv6(Class2, params) {
9573
10132
  ...normalizeParams(params)
9574
10133
  });
9575
10134
  }
10135
+ // @__NO_SIDE_EFFECTS__
9576
10136
  function _base64(Class2, params) {
9577
10137
  return new Class2({
9578
10138
  type: "string",
@@ -9582,6 +10142,7 @@ function _base64(Class2, params) {
9582
10142
  ...normalizeParams(params)
9583
10143
  });
9584
10144
  }
10145
+ // @__NO_SIDE_EFFECTS__
9585
10146
  function _base64url(Class2, params) {
9586
10147
  return new Class2({
9587
10148
  type: "string",
@@ -9591,6 +10152,7 @@ function _base64url(Class2, params) {
9591
10152
  ...normalizeParams(params)
9592
10153
  });
9593
10154
  }
10155
+ // @__NO_SIDE_EFFECTS__
9594
10156
  function _e164(Class2, params) {
9595
10157
  return new Class2({
9596
10158
  type: "string",
@@ -9600,6 +10162,7 @@ function _e164(Class2, params) {
9600
10162
  ...normalizeParams(params)
9601
10163
  });
9602
10164
  }
10165
+ // @__NO_SIDE_EFFECTS__
9603
10166
  function _jwt(Class2, params) {
9604
10167
  return new Class2({
9605
10168
  type: "string",
@@ -9609,6 +10172,7 @@ function _jwt(Class2, params) {
9609
10172
  ...normalizeParams(params)
9610
10173
  });
9611
10174
  }
10175
+ // @__NO_SIDE_EFFECTS__
9612
10176
  function _isoDateTime(Class2, params) {
9613
10177
  return new Class2({
9614
10178
  type: "string",
@@ -9620,6 +10184,7 @@ function _isoDateTime(Class2, params) {
9620
10184
  ...normalizeParams(params)
9621
10185
  });
9622
10186
  }
10187
+ // @__NO_SIDE_EFFECTS__
9623
10188
  function _isoDate(Class2, params) {
9624
10189
  return new Class2({
9625
10190
  type: "string",
@@ -9628,6 +10193,7 @@ function _isoDate(Class2, params) {
9628
10193
  ...normalizeParams(params)
9629
10194
  });
9630
10195
  }
10196
+ // @__NO_SIDE_EFFECTS__
9631
10197
  function _isoTime(Class2, params) {
9632
10198
  return new Class2({
9633
10199
  type: "string",
@@ -9637,6 +10203,7 @@ function _isoTime(Class2, params) {
9637
10203
  ...normalizeParams(params)
9638
10204
  });
9639
10205
  }
10206
+ // @__NO_SIDE_EFFECTS__
9640
10207
  function _isoDuration(Class2, params) {
9641
10208
  return new Class2({
9642
10209
  type: "string",
@@ -9645,6 +10212,7 @@ function _isoDuration(Class2, params) {
9645
10212
  ...normalizeParams(params)
9646
10213
  });
9647
10214
  }
10215
+ // @__NO_SIDE_EFFECTS__
9648
10216
  function _number(Class2, params) {
9649
10217
  return new Class2({
9650
10218
  type: "number",
@@ -9652,6 +10220,7 @@ function _number(Class2, params) {
9652
10220
  ...normalizeParams(params)
9653
10221
  });
9654
10222
  }
10223
+ // @__NO_SIDE_EFFECTS__
9655
10224
  function _int(Class2, params) {
9656
10225
  return new Class2({
9657
10226
  type: "number",
@@ -9661,29 +10230,34 @@ function _int(Class2, params) {
9661
10230
  ...normalizeParams(params)
9662
10231
  });
9663
10232
  }
10233
+ // @__NO_SIDE_EFFECTS__
9664
10234
  function _boolean(Class2, params) {
9665
10235
  return new Class2({
9666
10236
  type: "boolean",
9667
10237
  ...normalizeParams(params)
9668
10238
  });
9669
10239
  }
10240
+ // @__NO_SIDE_EFFECTS__
9670
10241
  function _null2(Class2, params) {
9671
10242
  return new Class2({
9672
10243
  type: "null",
9673
10244
  ...normalizeParams(params)
9674
10245
  });
9675
10246
  }
10247
+ // @__NO_SIDE_EFFECTS__
9676
10248
  function _unknown(Class2) {
9677
10249
  return new Class2({
9678
10250
  type: "unknown"
9679
10251
  });
9680
10252
  }
10253
+ // @__NO_SIDE_EFFECTS__
9681
10254
  function _never(Class2, params) {
9682
10255
  return new Class2({
9683
10256
  type: "never",
9684
10257
  ...normalizeParams(params)
9685
10258
  });
9686
10259
  }
10260
+ // @__NO_SIDE_EFFECTS__
9687
10261
  function _lt(value, params) {
9688
10262
  return new $ZodCheckLessThan({
9689
10263
  check: "less_than",
@@ -9692,6 +10266,7 @@ function _lt(value, params) {
9692
10266
  inclusive: false
9693
10267
  });
9694
10268
  }
10269
+ // @__NO_SIDE_EFFECTS__
9695
10270
  function _lte(value, params) {
9696
10271
  return new $ZodCheckLessThan({
9697
10272
  check: "less_than",
@@ -9700,6 +10275,7 @@ function _lte(value, params) {
9700
10275
  inclusive: true
9701
10276
  });
9702
10277
  }
10278
+ // @__NO_SIDE_EFFECTS__
9703
10279
  function _gt(value, params) {
9704
10280
  return new $ZodCheckGreaterThan({
9705
10281
  check: "greater_than",
@@ -9708,6 +10284,7 @@ function _gt(value, params) {
9708
10284
  inclusive: false
9709
10285
  });
9710
10286
  }
10287
+ // @__NO_SIDE_EFFECTS__
9711
10288
  function _gte(value, params) {
9712
10289
  return new $ZodCheckGreaterThan({
9713
10290
  check: "greater_than",
@@ -9716,6 +10293,7 @@ function _gte(value, params) {
9716
10293
  inclusive: true
9717
10294
  });
9718
10295
  }
10296
+ // @__NO_SIDE_EFFECTS__
9719
10297
  function _multipleOf(value, params) {
9720
10298
  return new $ZodCheckMultipleOf({
9721
10299
  check: "multiple_of",
@@ -9723,6 +10301,7 @@ function _multipleOf(value, params) {
9723
10301
  value
9724
10302
  });
9725
10303
  }
10304
+ // @__NO_SIDE_EFFECTS__
9726
10305
  function _maxLength(maximum, params) {
9727
10306
  const ch = new $ZodCheckMaxLength({
9728
10307
  check: "max_length",
@@ -9731,6 +10310,7 @@ function _maxLength(maximum, params) {
9731
10310
  });
9732
10311
  return ch;
9733
10312
  }
10313
+ // @__NO_SIDE_EFFECTS__
9734
10314
  function _minLength(minimum, params) {
9735
10315
  return new $ZodCheckMinLength({
9736
10316
  check: "min_length",
@@ -9738,6 +10318,7 @@ function _minLength(minimum, params) {
9738
10318
  minimum
9739
10319
  });
9740
10320
  }
10321
+ // @__NO_SIDE_EFFECTS__
9741
10322
  function _length(length, params) {
9742
10323
  return new $ZodCheckLengthEquals({
9743
10324
  check: "length_equals",
@@ -9745,6 +10326,7 @@ function _length(length, params) {
9745
10326
  length
9746
10327
  });
9747
10328
  }
10329
+ // @__NO_SIDE_EFFECTS__
9748
10330
  function _regex(pattern, params) {
9749
10331
  return new $ZodCheckRegex({
9750
10332
  check: "string_format",
@@ -9753,6 +10335,7 @@ function _regex(pattern, params) {
9753
10335
  pattern
9754
10336
  });
9755
10337
  }
10338
+ // @__NO_SIDE_EFFECTS__
9756
10339
  function _lowercase(params) {
9757
10340
  return new $ZodCheckLowerCase({
9758
10341
  check: "string_format",
@@ -9760,6 +10343,7 @@ function _lowercase(params) {
9760
10343
  ...normalizeParams(params)
9761
10344
  });
9762
10345
  }
10346
+ // @__NO_SIDE_EFFECTS__
9763
10347
  function _uppercase(params) {
9764
10348
  return new $ZodCheckUpperCase({
9765
10349
  check: "string_format",
@@ -9767,6 +10351,7 @@ function _uppercase(params) {
9767
10351
  ...normalizeParams(params)
9768
10352
  });
9769
10353
  }
10354
+ // @__NO_SIDE_EFFECTS__
9770
10355
  function _includes(includes, params) {
9771
10356
  return new $ZodCheckIncludes({
9772
10357
  check: "string_format",
@@ -9775,6 +10360,7 @@ function _includes(includes, params) {
9775
10360
  includes
9776
10361
  });
9777
10362
  }
10363
+ // @__NO_SIDE_EFFECTS__
9778
10364
  function _startsWith(prefix, params) {
9779
10365
  return new $ZodCheckStartsWith({
9780
10366
  check: "string_format",
@@ -9783,6 +10369,7 @@ function _startsWith(prefix, params) {
9783
10369
  prefix
9784
10370
  });
9785
10371
  }
10372
+ // @__NO_SIDE_EFFECTS__
9786
10373
  function _endsWith(suffix, params) {
9787
10374
  return new $ZodCheckEndsWith({
9788
10375
  check: "string_format",
@@ -9791,24 +10378,34 @@ function _endsWith(suffix, params) {
9791
10378
  suffix
9792
10379
  });
9793
10380
  }
10381
+ // @__NO_SIDE_EFFECTS__
9794
10382
  function _overwrite(tx) {
9795
10383
  return new $ZodCheckOverwrite({
9796
10384
  check: "overwrite",
9797
10385
  tx
9798
10386
  });
9799
10387
  }
10388
+ // @__NO_SIDE_EFFECTS__
9800
10389
  function _normalize(form) {
9801
- return _overwrite((input) => input.normalize(form));
10390
+ return /* @__PURE__ */ _overwrite((input) => input.normalize(form));
9802
10391
  }
10392
+ // @__NO_SIDE_EFFECTS__
9803
10393
  function _trim() {
9804
- return _overwrite((input) => input.trim());
10394
+ return /* @__PURE__ */ _overwrite((input) => input.trim());
9805
10395
  }
10396
+ // @__NO_SIDE_EFFECTS__
9806
10397
  function _toLowerCase() {
9807
- return _overwrite((input) => input.toLowerCase());
10398
+ return /* @__PURE__ */ _overwrite((input) => input.toLowerCase());
9808
10399
  }
10400
+ // @__NO_SIDE_EFFECTS__
9809
10401
  function _toUpperCase() {
9810
- return _overwrite((input) => input.toUpperCase());
10402
+ return /* @__PURE__ */ _overwrite((input) => input.toUpperCase());
10403
+ }
10404
+ // @__NO_SIDE_EFFECTS__
10405
+ function _slugify() {
10406
+ return /* @__PURE__ */ _overwrite((input) => slugify(input));
9811
10407
  }
10408
+ // @__NO_SIDE_EFFECTS__
9812
10409
  function _array(Class2, element, params) {
9813
10410
  return new Class2({
9814
10411
  type: "array",
@@ -9818,27 +10415,751 @@ function _array(Class2, element, params) {
9818
10415
  // },
9819
10416
  ...normalizeParams(params)
9820
10417
  });
9821
- }
9822
- function _custom(Class2, fn, _params) {
9823
- const norm = normalizeParams(_params);
9824
- norm.abort ?? (norm.abort = true);
9825
- const schema = new Class2({
9826
- type: "custom",
9827
- check: "custom",
9828
- fn,
9829
- ...norm
10418
+ }
10419
+ // @__NO_SIDE_EFFECTS__
10420
+ function _custom(Class2, fn, _params) {
10421
+ const norm = normalizeParams(_params);
10422
+ norm.abort ?? (norm.abort = true);
10423
+ const schema = new Class2({
10424
+ type: "custom",
10425
+ check: "custom",
10426
+ fn,
10427
+ ...norm
10428
+ });
10429
+ return schema;
10430
+ }
10431
+ // @__NO_SIDE_EFFECTS__
10432
+ function _refine(Class2, fn, _params) {
10433
+ const schema = new Class2({
10434
+ type: "custom",
10435
+ check: "custom",
10436
+ fn,
10437
+ ...normalizeParams(_params)
10438
+ });
10439
+ return schema;
10440
+ }
10441
+ // @__NO_SIDE_EFFECTS__
10442
+ function _superRefine(fn, params) {
10443
+ const ch = /* @__PURE__ */ _check((payload) => {
10444
+ payload.addIssue = (issue2) => {
10445
+ if (typeof issue2 === "string") {
10446
+ payload.issues.push(issue(issue2, payload.value, ch._zod.def));
10447
+ } else {
10448
+ const _issue = issue2;
10449
+ if (_issue.fatal)
10450
+ _issue.continue = false;
10451
+ _issue.code ?? (_issue.code = "custom");
10452
+ _issue.input ?? (_issue.input = payload.value);
10453
+ _issue.inst ?? (_issue.inst = ch);
10454
+ _issue.continue ?? (_issue.continue = !ch._zod.def.abort);
10455
+ payload.issues.push(issue(_issue));
10456
+ }
10457
+ };
10458
+ return fn(payload.value, payload);
10459
+ }, params);
10460
+ return ch;
10461
+ }
10462
+ // @__NO_SIDE_EFFECTS__
10463
+ function _check(fn, params) {
10464
+ const ch = new $ZodCheck({
10465
+ check: "custom",
10466
+ ...normalizeParams(params)
10467
+ });
10468
+ ch._zod.check = fn;
10469
+ return ch;
10470
+ }
10471
+
10472
+ // ../../node_modules/zod/v4/core/to-json-schema.js
10473
+ function initializeContext(params) {
10474
+ let target = params?.target ?? "draft-2020-12";
10475
+ if (target === "draft-4")
10476
+ target = "draft-04";
10477
+ if (target === "draft-7")
10478
+ target = "draft-07";
10479
+ return {
10480
+ processors: params.processors ?? {},
10481
+ metadataRegistry: params?.metadata ?? globalRegistry,
10482
+ target,
10483
+ unrepresentable: params?.unrepresentable ?? "throw",
10484
+ override: params?.override ?? (() => {
10485
+ }),
10486
+ io: params?.io ?? "output",
10487
+ counter: 0,
10488
+ seen: /* @__PURE__ */ new Map(),
10489
+ cycles: params?.cycles ?? "ref",
10490
+ reused: params?.reused ?? "inline",
10491
+ external: params?.external ?? void 0
10492
+ };
10493
+ }
10494
+ function process2(schema, ctx, _params = { path: [], schemaPath: [] }) {
10495
+ var _a3;
10496
+ const def = schema._zod.def;
10497
+ const seen = ctx.seen.get(schema);
10498
+ if (seen) {
10499
+ seen.count++;
10500
+ const isCycle = _params.schemaPath.includes(schema);
10501
+ if (isCycle) {
10502
+ seen.cycle = _params.path;
10503
+ }
10504
+ return seen.schema;
10505
+ }
10506
+ const result = { schema: {}, count: 1, cycle: void 0, path: _params.path };
10507
+ ctx.seen.set(schema, result);
10508
+ const overrideSchema = schema._zod.toJSONSchema?.();
10509
+ if (overrideSchema) {
10510
+ result.schema = overrideSchema;
10511
+ } else {
10512
+ const params = {
10513
+ ..._params,
10514
+ schemaPath: [..._params.schemaPath, schema],
10515
+ path: _params.path
10516
+ };
10517
+ if (schema._zod.processJSONSchema) {
10518
+ schema._zod.processJSONSchema(ctx, result.schema, params);
10519
+ } else {
10520
+ const _json = result.schema;
10521
+ const processor = ctx.processors[def.type];
10522
+ if (!processor) {
10523
+ throw new Error(`[toJSONSchema]: Non-representable type encountered: ${def.type}`);
10524
+ }
10525
+ processor(schema, ctx, _json, params);
10526
+ }
10527
+ const parent = schema._zod.parent;
10528
+ if (parent) {
10529
+ if (!result.ref)
10530
+ result.ref = parent;
10531
+ process2(parent, ctx, params);
10532
+ ctx.seen.get(parent).isParent = true;
10533
+ }
10534
+ }
10535
+ const meta2 = ctx.metadataRegistry.get(schema);
10536
+ if (meta2)
10537
+ Object.assign(result.schema, meta2);
10538
+ if (ctx.io === "input" && isTransforming(schema)) {
10539
+ delete result.schema.examples;
10540
+ delete result.schema.default;
10541
+ }
10542
+ if (ctx.io === "input" && "_prefault" in result.schema)
10543
+ (_a3 = result.schema).default ?? (_a3.default = result.schema._prefault);
10544
+ delete result.schema._prefault;
10545
+ const _result = ctx.seen.get(schema);
10546
+ return _result.schema;
10547
+ }
10548
+ function extractDefs(ctx, schema) {
10549
+ const root = ctx.seen.get(schema);
10550
+ if (!root)
10551
+ throw new Error("Unprocessed schema. This is a bug in Zod.");
10552
+ const idToSchema = /* @__PURE__ */ new Map();
10553
+ for (const entry of ctx.seen.entries()) {
10554
+ const id = ctx.metadataRegistry.get(entry[0])?.id;
10555
+ if (id) {
10556
+ const existing = idToSchema.get(id);
10557
+ if (existing && existing !== entry[0]) {
10558
+ throw new Error(`Duplicate schema id "${id}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);
10559
+ }
10560
+ idToSchema.set(id, entry[0]);
10561
+ }
10562
+ }
10563
+ const makeURI = (entry) => {
10564
+ const defsSegment = ctx.target === "draft-2020-12" ? "$defs" : "definitions";
10565
+ if (ctx.external) {
10566
+ const externalId = ctx.external.registry.get(entry[0])?.id;
10567
+ const uriGenerator = ctx.external.uri ?? ((id2) => id2);
10568
+ if (externalId) {
10569
+ return { ref: uriGenerator(externalId) };
10570
+ }
10571
+ const id = entry[1].defId ?? entry[1].schema.id ?? `schema${ctx.counter++}`;
10572
+ entry[1].defId = id;
10573
+ return { defId: id, ref: `${uriGenerator("__shared")}#/${defsSegment}/${id}` };
10574
+ }
10575
+ if (entry[1] === root) {
10576
+ return { ref: "#" };
10577
+ }
10578
+ const uriPrefix = `#`;
10579
+ const defUriPrefix = `${uriPrefix}/${defsSegment}/`;
10580
+ const defId = entry[1].schema.id ?? `__schema${ctx.counter++}`;
10581
+ return { defId, ref: defUriPrefix + defId };
10582
+ };
10583
+ const extractToDef = (entry) => {
10584
+ if (entry[1].schema.$ref) {
10585
+ return;
10586
+ }
10587
+ const seen = entry[1];
10588
+ const { ref, defId } = makeURI(entry);
10589
+ seen.def = { ...seen.schema };
10590
+ if (defId)
10591
+ seen.defId = defId;
10592
+ const schema2 = seen.schema;
10593
+ for (const key in schema2) {
10594
+ delete schema2[key];
10595
+ }
10596
+ schema2.$ref = ref;
10597
+ };
10598
+ if (ctx.cycles === "throw") {
10599
+ for (const entry of ctx.seen.entries()) {
10600
+ const seen = entry[1];
10601
+ if (seen.cycle) {
10602
+ throw new Error(`Cycle detected: #/${seen.cycle?.join("/")}/<root>
10603
+
10604
+ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`);
10605
+ }
10606
+ }
10607
+ }
10608
+ for (const entry of ctx.seen.entries()) {
10609
+ const seen = entry[1];
10610
+ if (schema === entry[0]) {
10611
+ extractToDef(entry);
10612
+ continue;
10613
+ }
10614
+ if (ctx.external) {
10615
+ const ext = ctx.external.registry.get(entry[0])?.id;
10616
+ if (schema !== entry[0] && ext) {
10617
+ extractToDef(entry);
10618
+ continue;
10619
+ }
10620
+ }
10621
+ const id = ctx.metadataRegistry.get(entry[0])?.id;
10622
+ if (id) {
10623
+ extractToDef(entry);
10624
+ continue;
10625
+ }
10626
+ if (seen.cycle) {
10627
+ extractToDef(entry);
10628
+ continue;
10629
+ }
10630
+ if (seen.count > 1) {
10631
+ if (ctx.reused === "ref") {
10632
+ extractToDef(entry);
10633
+ continue;
10634
+ }
10635
+ }
10636
+ }
10637
+ }
10638
+ function finalize(ctx, schema) {
10639
+ const root = ctx.seen.get(schema);
10640
+ if (!root)
10641
+ throw new Error("Unprocessed schema. This is a bug in Zod.");
10642
+ const flattenRef = (zodSchema) => {
10643
+ const seen = ctx.seen.get(zodSchema);
10644
+ if (seen.ref === null)
10645
+ return;
10646
+ const schema2 = seen.def ?? seen.schema;
10647
+ const _cached = { ...schema2 };
10648
+ const ref = seen.ref;
10649
+ seen.ref = null;
10650
+ if (ref) {
10651
+ flattenRef(ref);
10652
+ const refSeen = ctx.seen.get(ref);
10653
+ const refSchema = refSeen.schema;
10654
+ if (refSchema.$ref && (ctx.target === "draft-07" || ctx.target === "draft-04" || ctx.target === "openapi-3.0")) {
10655
+ schema2.allOf = schema2.allOf ?? [];
10656
+ schema2.allOf.push(refSchema);
10657
+ } else {
10658
+ Object.assign(schema2, refSchema);
10659
+ }
10660
+ Object.assign(schema2, _cached);
10661
+ const isParentRef = zodSchema._zod.parent === ref;
10662
+ if (isParentRef) {
10663
+ for (const key in schema2) {
10664
+ if (key === "$ref" || key === "allOf")
10665
+ continue;
10666
+ if (!(key in _cached)) {
10667
+ delete schema2[key];
10668
+ }
10669
+ }
10670
+ }
10671
+ if (refSchema.$ref && refSeen.def) {
10672
+ for (const key in schema2) {
10673
+ if (key === "$ref" || key === "allOf")
10674
+ continue;
10675
+ if (key in refSeen.def && JSON.stringify(schema2[key]) === JSON.stringify(refSeen.def[key])) {
10676
+ delete schema2[key];
10677
+ }
10678
+ }
10679
+ }
10680
+ }
10681
+ const parent = zodSchema._zod.parent;
10682
+ if (parent && parent !== ref) {
10683
+ flattenRef(parent);
10684
+ const parentSeen = ctx.seen.get(parent);
10685
+ if (parentSeen?.schema.$ref) {
10686
+ schema2.$ref = parentSeen.schema.$ref;
10687
+ if (parentSeen.def) {
10688
+ for (const key in schema2) {
10689
+ if (key === "$ref" || key === "allOf")
10690
+ continue;
10691
+ if (key in parentSeen.def && JSON.stringify(schema2[key]) === JSON.stringify(parentSeen.def[key])) {
10692
+ delete schema2[key];
10693
+ }
10694
+ }
10695
+ }
10696
+ }
10697
+ }
10698
+ ctx.override({
10699
+ zodSchema,
10700
+ jsonSchema: schema2,
10701
+ path: seen.path ?? []
10702
+ });
10703
+ };
10704
+ for (const entry of [...ctx.seen.entries()].reverse()) {
10705
+ flattenRef(entry[0]);
10706
+ }
10707
+ const result = {};
10708
+ if (ctx.target === "draft-2020-12") {
10709
+ result.$schema = "https://json-schema.org/draft/2020-12/schema";
10710
+ } else if (ctx.target === "draft-07") {
10711
+ result.$schema = "http://json-schema.org/draft-07/schema#";
10712
+ } else if (ctx.target === "draft-04") {
10713
+ result.$schema = "http://json-schema.org/draft-04/schema#";
10714
+ } else if (ctx.target === "openapi-3.0") {
10715
+ } else {
10716
+ }
10717
+ if (ctx.external?.uri) {
10718
+ const id = ctx.external.registry.get(schema)?.id;
10719
+ if (!id)
10720
+ throw new Error("Schema is missing an `id` property");
10721
+ result.$id = ctx.external.uri(id);
10722
+ }
10723
+ Object.assign(result, root.def ?? root.schema);
10724
+ const rootMetaId = ctx.metadataRegistry.get(schema)?.id;
10725
+ if (rootMetaId !== void 0 && result.id === rootMetaId)
10726
+ delete result.id;
10727
+ const defs = ctx.external?.defs ?? {};
10728
+ for (const entry of ctx.seen.entries()) {
10729
+ const seen = entry[1];
10730
+ if (seen.def && seen.defId) {
10731
+ if (seen.def.id === seen.defId)
10732
+ delete seen.def.id;
10733
+ defs[seen.defId] = seen.def;
10734
+ }
10735
+ }
10736
+ if (ctx.external) {
10737
+ } else {
10738
+ if (Object.keys(defs).length > 0) {
10739
+ if (ctx.target === "draft-2020-12") {
10740
+ result.$defs = defs;
10741
+ } else {
10742
+ result.definitions = defs;
10743
+ }
10744
+ }
10745
+ }
10746
+ try {
10747
+ const finalized = JSON.parse(JSON.stringify(result));
10748
+ Object.defineProperty(finalized, "~standard", {
10749
+ value: {
10750
+ ...schema["~standard"],
10751
+ jsonSchema: {
10752
+ input: createStandardJSONSchemaMethod(schema, "input", ctx.processors),
10753
+ output: createStandardJSONSchemaMethod(schema, "output", ctx.processors)
10754
+ }
10755
+ },
10756
+ enumerable: false,
10757
+ writable: false
10758
+ });
10759
+ return finalized;
10760
+ } catch (_err) {
10761
+ throw new Error("Error converting schema to JSON.");
10762
+ }
10763
+ }
10764
+ function isTransforming(_schema, _ctx) {
10765
+ const ctx = _ctx ?? { seen: /* @__PURE__ */ new Set() };
10766
+ if (ctx.seen.has(_schema))
10767
+ return false;
10768
+ ctx.seen.add(_schema);
10769
+ const def = _schema._zod.def;
10770
+ if (def.type === "transform")
10771
+ return true;
10772
+ if (def.type === "array")
10773
+ return isTransforming(def.element, ctx);
10774
+ if (def.type === "set")
10775
+ return isTransforming(def.valueType, ctx);
10776
+ if (def.type === "lazy")
10777
+ return isTransforming(def.getter(), ctx);
10778
+ if (def.type === "promise" || def.type === "optional" || def.type === "nonoptional" || def.type === "nullable" || def.type === "readonly" || def.type === "default" || def.type === "prefault") {
10779
+ return isTransforming(def.innerType, ctx);
10780
+ }
10781
+ if (def.type === "intersection") {
10782
+ return isTransforming(def.left, ctx) || isTransforming(def.right, ctx);
10783
+ }
10784
+ if (def.type === "record" || def.type === "map") {
10785
+ return isTransforming(def.keyType, ctx) || isTransforming(def.valueType, ctx);
10786
+ }
10787
+ if (def.type === "pipe") {
10788
+ if (_schema._zod.traits.has("$ZodCodec"))
10789
+ return true;
10790
+ return isTransforming(def.in, ctx) || isTransforming(def.out, ctx);
10791
+ }
10792
+ if (def.type === "object") {
10793
+ for (const key in def.shape) {
10794
+ if (isTransforming(def.shape[key], ctx))
10795
+ return true;
10796
+ }
10797
+ return false;
10798
+ }
10799
+ if (def.type === "union") {
10800
+ for (const option of def.options) {
10801
+ if (isTransforming(option, ctx))
10802
+ return true;
10803
+ }
10804
+ return false;
10805
+ }
10806
+ if (def.type === "tuple") {
10807
+ for (const item of def.items) {
10808
+ if (isTransforming(item, ctx))
10809
+ return true;
10810
+ }
10811
+ if (def.rest && isTransforming(def.rest, ctx))
10812
+ return true;
10813
+ return false;
10814
+ }
10815
+ return false;
10816
+ }
10817
+ var createToJSONSchemaMethod = (schema, processors = {}) => (params) => {
10818
+ const ctx = initializeContext({ ...params, processors });
10819
+ process2(schema, ctx);
10820
+ extractDefs(ctx, schema);
10821
+ return finalize(ctx, schema);
10822
+ };
10823
+ var createStandardJSONSchemaMethod = (schema, io, processors = {}) => (params) => {
10824
+ const { libraryOptions, target } = params ?? {};
10825
+ const ctx = initializeContext({ ...libraryOptions ?? {}, target, io, processors });
10826
+ process2(schema, ctx);
10827
+ extractDefs(ctx, schema);
10828
+ return finalize(ctx, schema);
10829
+ };
10830
+
10831
+ // ../../node_modules/zod/v4/core/json-schema-processors.js
10832
+ var formatMap = {
10833
+ guid: "uuid",
10834
+ url: "uri",
10835
+ datetime: "date-time",
10836
+ json_string: "json-string",
10837
+ regex: ""
10838
+ // do not set
10839
+ };
10840
+ var stringProcessor = (schema, ctx, _json, _params) => {
10841
+ const json = _json;
10842
+ json.type = "string";
10843
+ const { minimum, maximum, format, patterns, contentEncoding } = schema._zod.bag;
10844
+ if (typeof minimum === "number")
10845
+ json.minLength = minimum;
10846
+ if (typeof maximum === "number")
10847
+ json.maxLength = maximum;
10848
+ if (format) {
10849
+ json.format = formatMap[format] ?? format;
10850
+ if (json.format === "")
10851
+ delete json.format;
10852
+ if (format === "time") {
10853
+ delete json.format;
10854
+ }
10855
+ }
10856
+ if (contentEncoding)
10857
+ json.contentEncoding = contentEncoding;
10858
+ if (patterns && patterns.size > 0) {
10859
+ const regexes = [...patterns];
10860
+ if (regexes.length === 1)
10861
+ json.pattern = regexes[0].source;
10862
+ else if (regexes.length > 1) {
10863
+ json.allOf = [
10864
+ ...regexes.map((regex) => ({
10865
+ ...ctx.target === "draft-07" || ctx.target === "draft-04" || ctx.target === "openapi-3.0" ? { type: "string" } : {},
10866
+ pattern: regex.source
10867
+ }))
10868
+ ];
10869
+ }
10870
+ }
10871
+ };
10872
+ var numberProcessor = (schema, ctx, _json, _params) => {
10873
+ const json = _json;
10874
+ const { minimum, maximum, format, multipleOf, exclusiveMaximum, exclusiveMinimum } = schema._zod.bag;
10875
+ if (typeof format === "string" && format.includes("int"))
10876
+ json.type = "integer";
10877
+ else
10878
+ json.type = "number";
10879
+ const exMin = typeof exclusiveMinimum === "number" && exclusiveMinimum >= (minimum ?? Number.NEGATIVE_INFINITY);
10880
+ const exMax = typeof exclusiveMaximum === "number" && exclusiveMaximum <= (maximum ?? Number.POSITIVE_INFINITY);
10881
+ const legacy = ctx.target === "draft-04" || ctx.target === "openapi-3.0";
10882
+ if (exMin) {
10883
+ if (legacy) {
10884
+ json.minimum = exclusiveMinimum;
10885
+ json.exclusiveMinimum = true;
10886
+ } else {
10887
+ json.exclusiveMinimum = exclusiveMinimum;
10888
+ }
10889
+ } else if (typeof minimum === "number") {
10890
+ json.minimum = minimum;
10891
+ }
10892
+ if (exMax) {
10893
+ if (legacy) {
10894
+ json.maximum = exclusiveMaximum;
10895
+ json.exclusiveMaximum = true;
10896
+ } else {
10897
+ json.exclusiveMaximum = exclusiveMaximum;
10898
+ }
10899
+ } else if (typeof maximum === "number") {
10900
+ json.maximum = maximum;
10901
+ }
10902
+ if (typeof multipleOf === "number")
10903
+ json.multipleOf = multipleOf;
10904
+ };
10905
+ var booleanProcessor = (_schema, _ctx, json, _params) => {
10906
+ json.type = "boolean";
10907
+ };
10908
+ var nullProcessor = (_schema, ctx, json, _params) => {
10909
+ if (ctx.target === "openapi-3.0") {
10910
+ json.type = "string";
10911
+ json.nullable = true;
10912
+ json.enum = [null];
10913
+ } else {
10914
+ json.type = "null";
10915
+ }
10916
+ };
10917
+ var neverProcessor = (_schema, _ctx, json, _params) => {
10918
+ json.not = {};
10919
+ };
10920
+ var unknownProcessor = (_schema, _ctx, _json, _params) => {
10921
+ };
10922
+ var enumProcessor = (schema, _ctx, json, _params) => {
10923
+ const def = schema._zod.def;
10924
+ const values = getEnumValues(def.entries);
10925
+ if (values.every((v) => typeof v === "number"))
10926
+ json.type = "number";
10927
+ if (values.every((v) => typeof v === "string"))
10928
+ json.type = "string";
10929
+ json.enum = values;
10930
+ };
10931
+ var literalProcessor = (schema, ctx, json, _params) => {
10932
+ const def = schema._zod.def;
10933
+ const vals = [];
10934
+ for (const val of def.values) {
10935
+ if (val === void 0) {
10936
+ if (ctx.unrepresentable === "throw") {
10937
+ throw new Error("Literal `undefined` cannot be represented in JSON Schema");
10938
+ } else {
10939
+ }
10940
+ } else if (typeof val === "bigint") {
10941
+ if (ctx.unrepresentable === "throw") {
10942
+ throw new Error("BigInt literals cannot be represented in JSON Schema");
10943
+ } else {
10944
+ vals.push(Number(val));
10945
+ }
10946
+ } else {
10947
+ vals.push(val);
10948
+ }
10949
+ }
10950
+ if (vals.length === 0) {
10951
+ } else if (vals.length === 1) {
10952
+ const val = vals[0];
10953
+ json.type = val === null ? "null" : typeof val;
10954
+ if (ctx.target === "draft-04" || ctx.target === "openapi-3.0") {
10955
+ json.enum = [val];
10956
+ } else {
10957
+ json.const = val;
10958
+ }
10959
+ } else {
10960
+ if (vals.every((v) => typeof v === "number"))
10961
+ json.type = "number";
10962
+ if (vals.every((v) => typeof v === "string"))
10963
+ json.type = "string";
10964
+ if (vals.every((v) => typeof v === "boolean"))
10965
+ json.type = "boolean";
10966
+ if (vals.every((v) => v === null))
10967
+ json.type = "null";
10968
+ json.enum = vals;
10969
+ }
10970
+ };
10971
+ var customProcessor = (_schema, ctx, _json, _params) => {
10972
+ if (ctx.unrepresentable === "throw") {
10973
+ throw new Error("Custom types cannot be represented in JSON Schema");
10974
+ }
10975
+ };
10976
+ var transformProcessor = (_schema, ctx, _json, _params) => {
10977
+ if (ctx.unrepresentable === "throw") {
10978
+ throw new Error("Transforms cannot be represented in JSON Schema");
10979
+ }
10980
+ };
10981
+ var arrayProcessor = (schema, ctx, _json, params) => {
10982
+ const json = _json;
10983
+ const def = schema._zod.def;
10984
+ const { minimum, maximum } = schema._zod.bag;
10985
+ if (typeof minimum === "number")
10986
+ json.minItems = minimum;
10987
+ if (typeof maximum === "number")
10988
+ json.maxItems = maximum;
10989
+ json.type = "array";
10990
+ json.items = process2(def.element, ctx, {
10991
+ ...params,
10992
+ path: [...params.path, "items"]
10993
+ });
10994
+ };
10995
+ var objectProcessor = (schema, ctx, _json, params) => {
10996
+ const json = _json;
10997
+ const def = schema._zod.def;
10998
+ json.type = "object";
10999
+ json.properties = {};
11000
+ const shape = def.shape;
11001
+ for (const key in shape) {
11002
+ json.properties[key] = process2(shape[key], ctx, {
11003
+ ...params,
11004
+ path: [...params.path, "properties", key]
11005
+ });
11006
+ }
11007
+ const allKeys = new Set(Object.keys(shape));
11008
+ const requiredKeys = new Set([...allKeys].filter((key) => {
11009
+ const v = def.shape[key]._zod;
11010
+ if (ctx.io === "input") {
11011
+ return v.optin === void 0;
11012
+ } else {
11013
+ return v.optout === void 0;
11014
+ }
11015
+ }));
11016
+ if (requiredKeys.size > 0) {
11017
+ json.required = Array.from(requiredKeys);
11018
+ }
11019
+ if (def.catchall?._zod.def.type === "never") {
11020
+ json.additionalProperties = false;
11021
+ } else if (!def.catchall) {
11022
+ if (ctx.io === "output")
11023
+ json.additionalProperties = false;
11024
+ } else if (def.catchall) {
11025
+ json.additionalProperties = process2(def.catchall, ctx, {
11026
+ ...params,
11027
+ path: [...params.path, "additionalProperties"]
11028
+ });
11029
+ }
11030
+ };
11031
+ var unionProcessor = (schema, ctx, json, params) => {
11032
+ const def = schema._zod.def;
11033
+ const isExclusive = def.inclusive === false;
11034
+ const options = def.options.map((x, i) => process2(x, ctx, {
11035
+ ...params,
11036
+ path: [...params.path, isExclusive ? "oneOf" : "anyOf", i]
11037
+ }));
11038
+ if (isExclusive) {
11039
+ json.oneOf = options;
11040
+ } else {
11041
+ json.anyOf = options;
11042
+ }
11043
+ };
11044
+ var intersectionProcessor = (schema, ctx, json, params) => {
11045
+ const def = schema._zod.def;
11046
+ const a = process2(def.left, ctx, {
11047
+ ...params,
11048
+ path: [...params.path, "allOf", 0]
9830
11049
  });
9831
- return schema;
9832
- }
9833
- function _refine(Class2, fn, _params) {
9834
- const schema = new Class2({
9835
- type: "custom",
9836
- check: "custom",
9837
- fn,
9838
- ...normalizeParams(_params)
11050
+ const b = process2(def.right, ctx, {
11051
+ ...params,
11052
+ path: [...params.path, "allOf", 1]
9839
11053
  });
9840
- return schema;
9841
- }
11054
+ const isSimpleIntersection = (val) => "allOf" in val && Object.keys(val).length === 1;
11055
+ const allOf = [
11056
+ ...isSimpleIntersection(a) ? a.allOf : [a],
11057
+ ...isSimpleIntersection(b) ? b.allOf : [b]
11058
+ ];
11059
+ json.allOf = allOf;
11060
+ };
11061
+ var recordProcessor = (schema, ctx, _json, params) => {
11062
+ const json = _json;
11063
+ const def = schema._zod.def;
11064
+ json.type = "object";
11065
+ const keyType = def.keyType;
11066
+ const keyBag = keyType._zod.bag;
11067
+ const patterns = keyBag?.patterns;
11068
+ if (def.mode === "loose" && patterns && patterns.size > 0) {
11069
+ const valueSchema = process2(def.valueType, ctx, {
11070
+ ...params,
11071
+ path: [...params.path, "patternProperties", "*"]
11072
+ });
11073
+ json.patternProperties = {};
11074
+ for (const pattern of patterns) {
11075
+ json.patternProperties[pattern.source] = valueSchema;
11076
+ }
11077
+ } else {
11078
+ if (ctx.target === "draft-07" || ctx.target === "draft-2020-12") {
11079
+ json.propertyNames = process2(def.keyType, ctx, {
11080
+ ...params,
11081
+ path: [...params.path, "propertyNames"]
11082
+ });
11083
+ }
11084
+ json.additionalProperties = process2(def.valueType, ctx, {
11085
+ ...params,
11086
+ path: [...params.path, "additionalProperties"]
11087
+ });
11088
+ }
11089
+ const keyValues = keyType._zod.values;
11090
+ if (keyValues) {
11091
+ const validKeyValues = [...keyValues].filter((v) => typeof v === "string" || typeof v === "number");
11092
+ if (validKeyValues.length > 0) {
11093
+ json.required = validKeyValues;
11094
+ }
11095
+ }
11096
+ };
11097
+ var nullableProcessor = (schema, ctx, json, params) => {
11098
+ const def = schema._zod.def;
11099
+ const inner = process2(def.innerType, ctx, params);
11100
+ const seen = ctx.seen.get(schema);
11101
+ if (ctx.target === "openapi-3.0") {
11102
+ seen.ref = def.innerType;
11103
+ json.nullable = true;
11104
+ } else {
11105
+ json.anyOf = [inner, { type: "null" }];
11106
+ }
11107
+ };
11108
+ var nonoptionalProcessor = (schema, ctx, _json, params) => {
11109
+ const def = schema._zod.def;
11110
+ process2(def.innerType, ctx, params);
11111
+ const seen = ctx.seen.get(schema);
11112
+ seen.ref = def.innerType;
11113
+ };
11114
+ var defaultProcessor = (schema, ctx, json, params) => {
11115
+ const def = schema._zod.def;
11116
+ process2(def.innerType, ctx, params);
11117
+ const seen = ctx.seen.get(schema);
11118
+ seen.ref = def.innerType;
11119
+ json.default = JSON.parse(JSON.stringify(def.defaultValue));
11120
+ };
11121
+ var prefaultProcessor = (schema, ctx, json, params) => {
11122
+ const def = schema._zod.def;
11123
+ process2(def.innerType, ctx, params);
11124
+ const seen = ctx.seen.get(schema);
11125
+ seen.ref = def.innerType;
11126
+ if (ctx.io === "input")
11127
+ json._prefault = JSON.parse(JSON.stringify(def.defaultValue));
11128
+ };
11129
+ var catchProcessor = (schema, ctx, json, params) => {
11130
+ const def = schema._zod.def;
11131
+ process2(def.innerType, ctx, params);
11132
+ const seen = ctx.seen.get(schema);
11133
+ seen.ref = def.innerType;
11134
+ let catchValue;
11135
+ try {
11136
+ catchValue = def.catchValue(void 0);
11137
+ } catch {
11138
+ throw new Error("Dynamic catch values are not supported in JSON Schema");
11139
+ }
11140
+ json.default = catchValue;
11141
+ };
11142
+ var pipeProcessor = (schema, ctx, _json, params) => {
11143
+ const def = schema._zod.def;
11144
+ const inIsTransform = def.in._zod.traits.has("$ZodTransform");
11145
+ const innerType = ctx.io === "input" ? inIsTransform ? def.out : def.in : def.out;
11146
+ process2(innerType, ctx, params);
11147
+ const seen = ctx.seen.get(schema);
11148
+ seen.ref = innerType;
11149
+ };
11150
+ var readonlyProcessor = (schema, ctx, json, params) => {
11151
+ const def = schema._zod.def;
11152
+ process2(def.innerType, ctx, params);
11153
+ const seen = ctx.seen.get(schema);
11154
+ seen.ref = def.innerType;
11155
+ json.readOnly = true;
11156
+ };
11157
+ var optionalProcessor = (schema, ctx, _json, params) => {
11158
+ const def = schema._zod.def;
11159
+ process2(def.innerType, ctx, params);
11160
+ const seen = ctx.seen.get(schema);
11161
+ seen.ref = def.innerType;
11162
+ };
9842
11163
 
9843
11164
  // ../../node_modules/zod/v4/classic/iso.js
9844
11165
  var iso_exports = {};
@@ -9895,11 +11216,17 @@ var initializer2 = (inst, issues) => {
9895
11216
  // enumerable: false,
9896
11217
  },
9897
11218
  addIssue: {
9898
- value: (issue2) => inst.issues.push(issue2)
11219
+ value: (issue2) => {
11220
+ inst.issues.push(issue2);
11221
+ inst.message = JSON.stringify(inst.issues, jsonStringifyReplacer, 2);
11222
+ }
9899
11223
  // enumerable: false,
9900
11224
  },
9901
11225
  addIssues: {
9902
- value: (issues2) => inst.issues.push(...issues2)
11226
+ value: (issues2) => {
11227
+ inst.issues.push(...issues2);
11228
+ inst.message = JSON.stringify(inst.issues, jsonStringifyReplacer, 2);
11229
+ }
9903
11230
  // enumerable: false,
9904
11231
  },
9905
11232
  isEmpty: {
@@ -9910,105 +11237,246 @@ var initializer2 = (inst, issues) => {
9910
11237
  }
9911
11238
  });
9912
11239
  };
9913
- var ZodError = $constructor("ZodError", initializer2);
9914
- var ZodRealError = $constructor("ZodError", initializer2, {
11240
+ var ZodRealError = /* @__PURE__ */ $constructor("ZodError", initializer2, {
9915
11241
  Parent: Error
9916
11242
  });
9917
11243
 
9918
11244
  // ../../node_modules/zod/v4/classic/parse.js
9919
- var parse = /* @__PURE__ */ _parse(ZodRealError);
9920
- var parseAsync = /* @__PURE__ */ _parseAsync(ZodRealError);
11245
+ var parse2 = /* @__PURE__ */ _parse(ZodRealError);
11246
+ var parseAsync2 = /* @__PURE__ */ _parseAsync(ZodRealError);
9921
11247
  var safeParse2 = /* @__PURE__ */ _safeParse(ZodRealError);
9922
11248
  var safeParseAsync2 = /* @__PURE__ */ _safeParseAsync(ZodRealError);
11249
+ var encode = /* @__PURE__ */ _encode(ZodRealError);
11250
+ var decode = /* @__PURE__ */ _decode(ZodRealError);
11251
+ var encodeAsync = /* @__PURE__ */ _encodeAsync(ZodRealError);
11252
+ var decodeAsync = /* @__PURE__ */ _decodeAsync(ZodRealError);
11253
+ var safeEncode = /* @__PURE__ */ _safeEncode(ZodRealError);
11254
+ var safeDecode = /* @__PURE__ */ _safeDecode(ZodRealError);
11255
+ var safeEncodeAsync = /* @__PURE__ */ _safeEncodeAsync(ZodRealError);
11256
+ var safeDecodeAsync = /* @__PURE__ */ _safeDecodeAsync(ZodRealError);
9923
11257
 
9924
11258
  // ../../node_modules/zod/v4/classic/schemas.js
11259
+ var _installedGroups = /* @__PURE__ */ new WeakMap();
11260
+ function _installLazyMethods(inst, group, methods) {
11261
+ const proto = Object.getPrototypeOf(inst);
11262
+ let installed = _installedGroups.get(proto);
11263
+ if (!installed) {
11264
+ installed = /* @__PURE__ */ new Set();
11265
+ _installedGroups.set(proto, installed);
11266
+ }
11267
+ if (installed.has(group))
11268
+ return;
11269
+ installed.add(group);
11270
+ for (const key in methods) {
11271
+ const fn = methods[key];
11272
+ Object.defineProperty(proto, key, {
11273
+ configurable: true,
11274
+ enumerable: false,
11275
+ get() {
11276
+ const bound = fn.bind(this);
11277
+ Object.defineProperty(this, key, {
11278
+ configurable: true,
11279
+ writable: true,
11280
+ enumerable: true,
11281
+ value: bound
11282
+ });
11283
+ return bound;
11284
+ },
11285
+ set(v) {
11286
+ Object.defineProperty(this, key, {
11287
+ configurable: true,
11288
+ writable: true,
11289
+ enumerable: true,
11290
+ value: v
11291
+ });
11292
+ }
11293
+ });
11294
+ }
11295
+ }
9925
11296
  var ZodType = /* @__PURE__ */ $constructor("ZodType", (inst, def) => {
9926
11297
  $ZodType.init(inst, def);
11298
+ Object.assign(inst["~standard"], {
11299
+ jsonSchema: {
11300
+ input: createStandardJSONSchemaMethod(inst, "input"),
11301
+ output: createStandardJSONSchemaMethod(inst, "output")
11302
+ }
11303
+ });
11304
+ inst.toJSONSchema = createToJSONSchemaMethod(inst, {});
9927
11305
  inst.def = def;
11306
+ inst.type = def.type;
9928
11307
  Object.defineProperty(inst, "_def", { value: def });
9929
- inst.check = (...checks) => {
9930
- return inst.clone(
9931
- {
9932
- ...def,
9933
- checks: [
9934
- ...def.checks ?? [],
9935
- ...checks.map((ch) => typeof ch === "function" ? { _zod: { check: ch, def: { check: "custom" }, onattach: [] } } : ch)
9936
- ]
9937
- }
9938
- // { parent: true }
9939
- );
9940
- };
9941
- inst.clone = (def2, params) => clone(inst, def2, params);
9942
- inst.brand = () => inst;
9943
- inst.register = ((reg, meta) => {
9944
- reg.add(inst, meta);
9945
- return inst;
9946
- });
9947
- inst.parse = (data, params) => parse(inst, data, params, { callee: inst.parse });
11308
+ inst.parse = (data, params) => parse2(inst, data, params, { callee: inst.parse });
9948
11309
  inst.safeParse = (data, params) => safeParse2(inst, data, params);
9949
- inst.parseAsync = async (data, params) => parseAsync(inst, data, params, { callee: inst.parseAsync });
11310
+ inst.parseAsync = async (data, params) => parseAsync2(inst, data, params, { callee: inst.parseAsync });
9950
11311
  inst.safeParseAsync = async (data, params) => safeParseAsync2(inst, data, params);
9951
11312
  inst.spa = inst.safeParseAsync;
9952
- inst.refine = (check2, params) => inst.check(refine(check2, params));
9953
- inst.superRefine = (refinement) => inst.check(superRefine(refinement));
9954
- inst.overwrite = (fn) => inst.check(_overwrite(fn));
9955
- inst.optional = () => optional(inst);
9956
- inst.nullable = () => nullable(inst);
9957
- inst.nullish = () => optional(nullable(inst));
9958
- inst.nonoptional = (params) => nonoptional(inst, params);
9959
- inst.array = () => array(inst);
9960
- inst.or = (arg) => union([inst, arg]);
9961
- inst.and = (arg) => intersection(inst, arg);
9962
- inst.transform = (tx) => pipe(inst, transform(tx));
9963
- inst.default = (def2) => _default(inst, def2);
9964
- inst.prefault = (def2) => prefault(inst, def2);
9965
- inst.catch = (params) => _catch(inst, params);
9966
- inst.pipe = (target) => pipe(inst, target);
9967
- inst.readonly = () => readonly(inst);
9968
- inst.describe = (description) => {
9969
- const cl = inst.clone();
9970
- globalRegistry.add(cl, { description });
9971
- return cl;
9972
- };
11313
+ inst.encode = (data, params) => encode(inst, data, params);
11314
+ inst.decode = (data, params) => decode(inst, data, params);
11315
+ inst.encodeAsync = async (data, params) => encodeAsync(inst, data, params);
11316
+ inst.decodeAsync = async (data, params) => decodeAsync(inst, data, params);
11317
+ inst.safeEncode = (data, params) => safeEncode(inst, data, params);
11318
+ inst.safeDecode = (data, params) => safeDecode(inst, data, params);
11319
+ inst.safeEncodeAsync = async (data, params) => safeEncodeAsync(inst, data, params);
11320
+ inst.safeDecodeAsync = async (data, params) => safeDecodeAsync(inst, data, params);
11321
+ _installLazyMethods(inst, "ZodType", {
11322
+ check(...chks) {
11323
+ const def2 = this.def;
11324
+ return this.clone(util_exports.mergeDefs(def2, {
11325
+ checks: [
11326
+ ...def2.checks ?? [],
11327
+ ...chks.map((ch) => typeof ch === "function" ? { _zod: { check: ch, def: { check: "custom" }, onattach: [] } } : ch)
11328
+ ]
11329
+ }), { parent: true });
11330
+ },
11331
+ with(...chks) {
11332
+ return this.check(...chks);
11333
+ },
11334
+ clone(def2, params) {
11335
+ return clone(this, def2, params);
11336
+ },
11337
+ brand() {
11338
+ return this;
11339
+ },
11340
+ register(reg, meta2) {
11341
+ reg.add(this, meta2);
11342
+ return this;
11343
+ },
11344
+ refine(check, params) {
11345
+ return this.check(refine(check, params));
11346
+ },
11347
+ superRefine(refinement, params) {
11348
+ return this.check(superRefine(refinement, params));
11349
+ },
11350
+ overwrite(fn) {
11351
+ return this.check(_overwrite(fn));
11352
+ },
11353
+ optional() {
11354
+ return optional(this);
11355
+ },
11356
+ exactOptional() {
11357
+ return exactOptional(this);
11358
+ },
11359
+ nullable() {
11360
+ return nullable(this);
11361
+ },
11362
+ nullish() {
11363
+ return optional(nullable(this));
11364
+ },
11365
+ nonoptional(params) {
11366
+ return nonoptional(this, params);
11367
+ },
11368
+ array() {
11369
+ return array(this);
11370
+ },
11371
+ or(arg) {
11372
+ return union([this, arg]);
11373
+ },
11374
+ and(arg) {
11375
+ return intersection(this, arg);
11376
+ },
11377
+ transform(tx) {
11378
+ return pipe(this, transform(tx));
11379
+ },
11380
+ default(d) {
11381
+ return _default(this, d);
11382
+ },
11383
+ prefault(d) {
11384
+ return prefault(this, d);
11385
+ },
11386
+ catch(params) {
11387
+ return _catch(this, params);
11388
+ },
11389
+ pipe(target) {
11390
+ return pipe(this, target);
11391
+ },
11392
+ readonly() {
11393
+ return readonly(this);
11394
+ },
11395
+ describe(description) {
11396
+ const cl = this.clone();
11397
+ globalRegistry.add(cl, { description });
11398
+ return cl;
11399
+ },
11400
+ meta(...args) {
11401
+ if (args.length === 0)
11402
+ return globalRegistry.get(this);
11403
+ const cl = this.clone();
11404
+ globalRegistry.add(cl, args[0]);
11405
+ return cl;
11406
+ },
11407
+ isOptional() {
11408
+ return this.safeParse(void 0).success;
11409
+ },
11410
+ isNullable() {
11411
+ return this.safeParse(null).success;
11412
+ },
11413
+ apply(fn) {
11414
+ return fn(this);
11415
+ }
11416
+ });
9973
11417
  Object.defineProperty(inst, "description", {
9974
11418
  get() {
9975
11419
  return globalRegistry.get(inst)?.description;
9976
11420
  },
9977
11421
  configurable: true
9978
11422
  });
9979
- inst.meta = (...args) => {
9980
- if (args.length === 0) {
9981
- return globalRegistry.get(inst);
9982
- }
9983
- const cl = inst.clone();
9984
- globalRegistry.add(cl, args[0]);
9985
- return cl;
9986
- };
9987
- inst.isOptional = () => inst.safeParse(void 0).success;
9988
- inst.isNullable = () => inst.safeParse(null).success;
9989
11423
  return inst;
9990
11424
  });
9991
11425
  var _ZodString = /* @__PURE__ */ $constructor("_ZodString", (inst, def) => {
9992
11426
  $ZodString.init(inst, def);
9993
11427
  ZodType.init(inst, def);
11428
+ inst._zod.processJSONSchema = (ctx, json, params) => stringProcessor(inst, ctx, json, params);
9994
11429
  const bag = inst._zod.bag;
9995
11430
  inst.format = bag.format ?? null;
9996
11431
  inst.minLength = bag.minimum ?? null;
9997
11432
  inst.maxLength = bag.maximum ?? null;
9998
- inst.regex = (...args) => inst.check(_regex(...args));
9999
- inst.includes = (...args) => inst.check(_includes(...args));
10000
- inst.startsWith = (...args) => inst.check(_startsWith(...args));
10001
- inst.endsWith = (...args) => inst.check(_endsWith(...args));
10002
- inst.min = (...args) => inst.check(_minLength(...args));
10003
- inst.max = (...args) => inst.check(_maxLength(...args));
10004
- inst.length = (...args) => inst.check(_length(...args));
10005
- inst.nonempty = (...args) => inst.check(_minLength(1, ...args));
10006
- inst.lowercase = (params) => inst.check(_lowercase(params));
10007
- inst.uppercase = (params) => inst.check(_uppercase(params));
10008
- inst.trim = () => inst.check(_trim());
10009
- inst.normalize = (...args) => inst.check(_normalize(...args));
10010
- inst.toLowerCase = () => inst.check(_toLowerCase());
10011
- inst.toUpperCase = () => inst.check(_toUpperCase());
11433
+ _installLazyMethods(inst, "_ZodString", {
11434
+ regex(...args) {
11435
+ return this.check(_regex(...args));
11436
+ },
11437
+ includes(...args) {
11438
+ return this.check(_includes(...args));
11439
+ },
11440
+ startsWith(...args) {
11441
+ return this.check(_startsWith(...args));
11442
+ },
11443
+ endsWith(...args) {
11444
+ return this.check(_endsWith(...args));
11445
+ },
11446
+ min(...args) {
11447
+ return this.check(_minLength(...args));
11448
+ },
11449
+ max(...args) {
11450
+ return this.check(_maxLength(...args));
11451
+ },
11452
+ length(...args) {
11453
+ return this.check(_length(...args));
11454
+ },
11455
+ nonempty(...args) {
11456
+ return this.check(_minLength(1, ...args));
11457
+ },
11458
+ lowercase(params) {
11459
+ return this.check(_lowercase(params));
11460
+ },
11461
+ uppercase(params) {
11462
+ return this.check(_uppercase(params));
11463
+ },
11464
+ trim() {
11465
+ return this.check(_trim());
11466
+ },
11467
+ normalize(...args) {
11468
+ return this.check(_normalize(...args));
11469
+ },
11470
+ toLowerCase() {
11471
+ return this.check(_toLowerCase());
11472
+ },
11473
+ toUpperCase() {
11474
+ return this.check(_toUpperCase());
11475
+ },
11476
+ slugify() {
11477
+ return this.check(_slugify());
11478
+ }
11479
+ });
10012
11480
  });
10013
11481
  var ZodString = /* @__PURE__ */ $constructor("ZodString", (inst, def) => {
10014
11482
  $ZodString.init(inst, def);
@@ -10127,21 +11595,54 @@ var ZodJWT = /* @__PURE__ */ $constructor("ZodJWT", (inst, def) => {
10127
11595
  var ZodNumber = /* @__PURE__ */ $constructor("ZodNumber", (inst, def) => {
10128
11596
  $ZodNumber.init(inst, def);
10129
11597
  ZodType.init(inst, def);
10130
- inst.gt = (value, params) => inst.check(_gt(value, params));
10131
- inst.gte = (value, params) => inst.check(_gte(value, params));
10132
- inst.min = (value, params) => inst.check(_gte(value, params));
10133
- inst.lt = (value, params) => inst.check(_lt(value, params));
10134
- inst.lte = (value, params) => inst.check(_lte(value, params));
10135
- inst.max = (value, params) => inst.check(_lte(value, params));
10136
- inst.int = (params) => inst.check(int(params));
10137
- inst.safe = (params) => inst.check(int(params));
10138
- inst.positive = (params) => inst.check(_gt(0, params));
10139
- inst.nonnegative = (params) => inst.check(_gte(0, params));
10140
- inst.negative = (params) => inst.check(_lt(0, params));
10141
- inst.nonpositive = (params) => inst.check(_lte(0, params));
10142
- inst.multipleOf = (value, params) => inst.check(_multipleOf(value, params));
10143
- inst.step = (value, params) => inst.check(_multipleOf(value, params));
10144
- inst.finite = () => inst;
11598
+ inst._zod.processJSONSchema = (ctx, json, params) => numberProcessor(inst, ctx, json, params);
11599
+ _installLazyMethods(inst, "ZodNumber", {
11600
+ gt(value, params) {
11601
+ return this.check(_gt(value, params));
11602
+ },
11603
+ gte(value, params) {
11604
+ return this.check(_gte(value, params));
11605
+ },
11606
+ min(value, params) {
11607
+ return this.check(_gte(value, params));
11608
+ },
11609
+ lt(value, params) {
11610
+ return this.check(_lt(value, params));
11611
+ },
11612
+ lte(value, params) {
11613
+ return this.check(_lte(value, params));
11614
+ },
11615
+ max(value, params) {
11616
+ return this.check(_lte(value, params));
11617
+ },
11618
+ int(params) {
11619
+ return this.check(int(params));
11620
+ },
11621
+ safe(params) {
11622
+ return this.check(int(params));
11623
+ },
11624
+ positive(params) {
11625
+ return this.check(_gt(0, params));
11626
+ },
11627
+ nonnegative(params) {
11628
+ return this.check(_gte(0, params));
11629
+ },
11630
+ negative(params) {
11631
+ return this.check(_lt(0, params));
11632
+ },
11633
+ nonpositive(params) {
11634
+ return this.check(_lte(0, params));
11635
+ },
11636
+ multipleOf(value, params) {
11637
+ return this.check(_multipleOf(value, params));
11638
+ },
11639
+ step(value, params) {
11640
+ return this.check(_multipleOf(value, params));
11641
+ },
11642
+ finite() {
11643
+ return this;
11644
+ }
11645
+ });
10145
11646
  const bag = inst._zod.bag;
10146
11647
  inst.minValue = Math.max(bag.minimum ?? Number.NEGATIVE_INFINITY, bag.exclusiveMinimum ?? Number.NEGATIVE_INFINITY) ?? null;
10147
11648
  inst.maxValue = Math.min(bag.maximum ?? Number.POSITIVE_INFINITY, bag.exclusiveMaximum ?? Number.POSITIVE_INFINITY) ?? null;
@@ -10162,6 +11663,7 @@ function int(params) {
10162
11663
  var ZodBoolean = /* @__PURE__ */ $constructor("ZodBoolean", (inst, def) => {
10163
11664
  $ZodBoolean.init(inst, def);
10164
11665
  ZodType.init(inst, def);
11666
+ inst._zod.processJSONSchema = (ctx, json, params) => booleanProcessor(inst, ctx, json, params);
10165
11667
  });
10166
11668
  function boolean2(params) {
10167
11669
  return _boolean(ZodBoolean, params);
@@ -10169,6 +11671,7 @@ function boolean2(params) {
10169
11671
  var ZodNull = /* @__PURE__ */ $constructor("ZodNull", (inst, def) => {
10170
11672
  $ZodNull.init(inst, def);
10171
11673
  ZodType.init(inst, def);
11674
+ inst._zod.processJSONSchema = (ctx, json, params) => nullProcessor(inst, ctx, json, params);
10172
11675
  });
10173
11676
  function _null3(params) {
10174
11677
  return _null2(ZodNull, params);
@@ -10176,6 +11679,7 @@ function _null3(params) {
10176
11679
  var ZodUnknown = /* @__PURE__ */ $constructor("ZodUnknown", (inst, def) => {
10177
11680
  $ZodUnknown.init(inst, def);
10178
11681
  ZodType.init(inst, def);
11682
+ inst._zod.processJSONSchema = (ctx, json, params) => unknownProcessor(inst, ctx, json, params);
10179
11683
  });
10180
11684
  function unknown() {
10181
11685
  return _unknown(ZodUnknown);
@@ -10183,6 +11687,7 @@ function unknown() {
10183
11687
  var ZodNever = /* @__PURE__ */ $constructor("ZodNever", (inst, def) => {
10184
11688
  $ZodNever.init(inst, def);
10185
11689
  ZodType.init(inst, def);
11690
+ inst._zod.processJSONSchema = (ctx, json, params) => neverProcessor(inst, ctx, json, params);
10186
11691
  });
10187
11692
  function never(params) {
10188
11693
  return _never(ZodNever, params);
@@ -10190,42 +11695,82 @@ function never(params) {
10190
11695
  var ZodArray = /* @__PURE__ */ $constructor("ZodArray", (inst, def) => {
10191
11696
  $ZodArray.init(inst, def);
10192
11697
  ZodType.init(inst, def);
11698
+ inst._zod.processJSONSchema = (ctx, json, params) => arrayProcessor(inst, ctx, json, params);
10193
11699
  inst.element = def.element;
10194
- inst.min = (minLength, params) => inst.check(_minLength(minLength, params));
10195
- inst.nonempty = (params) => inst.check(_minLength(1, params));
10196
- inst.max = (maxLength, params) => inst.check(_maxLength(maxLength, params));
10197
- inst.length = (len, params) => inst.check(_length(len, params));
10198
- inst.unwrap = () => inst.element;
11700
+ _installLazyMethods(inst, "ZodArray", {
11701
+ min(n, params) {
11702
+ return this.check(_minLength(n, params));
11703
+ },
11704
+ nonempty(params) {
11705
+ return this.check(_minLength(1, params));
11706
+ },
11707
+ max(n, params) {
11708
+ return this.check(_maxLength(n, params));
11709
+ },
11710
+ length(n, params) {
11711
+ return this.check(_length(n, params));
11712
+ },
11713
+ unwrap() {
11714
+ return this.element;
11715
+ }
11716
+ });
10199
11717
  });
10200
11718
  function array(element, params) {
10201
11719
  return _array(ZodArray, element, params);
10202
11720
  }
10203
11721
  var ZodObject = /* @__PURE__ */ $constructor("ZodObject", (inst, def) => {
10204
- $ZodObject.init(inst, def);
11722
+ $ZodObjectJIT.init(inst, def);
10205
11723
  ZodType.init(inst, def);
10206
- util_exports.defineLazy(inst, "shape", () => def.shape);
10207
- inst.keyof = () => _enum(Object.keys(inst._zod.def.shape));
10208
- inst.catchall = (catchall) => inst.clone({ ...inst._zod.def, catchall });
10209
- inst.passthrough = () => inst.clone({ ...inst._zod.def, catchall: unknown() });
10210
- inst.loose = () => inst.clone({ ...inst._zod.def, catchall: unknown() });
10211
- inst.strict = () => inst.clone({ ...inst._zod.def, catchall: never() });
10212
- inst.strip = () => inst.clone({ ...inst._zod.def, catchall: void 0 });
10213
- inst.extend = (incoming) => {
10214
- return util_exports.extend(inst, incoming);
10215
- };
10216
- inst.merge = (other) => util_exports.merge(inst, other);
10217
- inst.pick = (mask) => util_exports.pick(inst, mask);
10218
- inst.omit = (mask) => util_exports.omit(inst, mask);
10219
- inst.partial = (...args) => util_exports.partial(ZodOptional, inst, args[0]);
10220
- inst.required = (...args) => util_exports.required(ZodNonOptional, inst, args[0]);
11724
+ inst._zod.processJSONSchema = (ctx, json, params) => objectProcessor(inst, ctx, json, params);
11725
+ util_exports.defineLazy(inst, "shape", () => {
11726
+ return def.shape;
11727
+ });
11728
+ _installLazyMethods(inst, "ZodObject", {
11729
+ keyof() {
11730
+ return _enum(Object.keys(this._zod.def.shape));
11731
+ },
11732
+ catchall(catchall) {
11733
+ return this.clone({ ...this._zod.def, catchall });
11734
+ },
11735
+ passthrough() {
11736
+ return this.clone({ ...this._zod.def, catchall: unknown() });
11737
+ },
11738
+ loose() {
11739
+ return this.clone({ ...this._zod.def, catchall: unknown() });
11740
+ },
11741
+ strict() {
11742
+ return this.clone({ ...this._zod.def, catchall: never() });
11743
+ },
11744
+ strip() {
11745
+ return this.clone({ ...this._zod.def, catchall: void 0 });
11746
+ },
11747
+ extend(incoming) {
11748
+ return util_exports.extend(this, incoming);
11749
+ },
11750
+ safeExtend(incoming) {
11751
+ return util_exports.safeExtend(this, incoming);
11752
+ },
11753
+ merge(other) {
11754
+ return util_exports.merge(this, other);
11755
+ },
11756
+ pick(mask) {
11757
+ return util_exports.pick(this, mask);
11758
+ },
11759
+ omit(mask) {
11760
+ return util_exports.omit(this, mask);
11761
+ },
11762
+ partial(...args) {
11763
+ return util_exports.partial(ZodOptional, this, args[0]);
11764
+ },
11765
+ required(...args) {
11766
+ return util_exports.required(ZodNonOptional, this, args[0]);
11767
+ }
11768
+ });
10221
11769
  });
10222
11770
  function object(shape, params) {
10223
11771
  const def = {
10224
11772
  type: "object",
10225
- get shape() {
10226
- util_exports.assignProp(this, "shape", { ...shape });
10227
- return this.shape;
10228
- },
11773
+ shape: shape ?? {},
10229
11774
  ...util_exports.normalizeParams(params)
10230
11775
  };
10231
11776
  return new ZodObject(def);
@@ -10233,10 +11778,7 @@ function object(shape, params) {
10233
11778
  function looseObject(shape, params) {
10234
11779
  return new ZodObject({
10235
11780
  type: "object",
10236
- get shape() {
10237
- util_exports.assignProp(this, "shape", { ...shape });
10238
- return this.shape;
10239
- },
11781
+ shape,
10240
11782
  catchall: unknown(),
10241
11783
  ...util_exports.normalizeParams(params)
10242
11784
  });
@@ -10244,6 +11786,7 @@ function looseObject(shape, params) {
10244
11786
  var ZodUnion = /* @__PURE__ */ $constructor("ZodUnion", (inst, def) => {
10245
11787
  $ZodUnion.init(inst, def);
10246
11788
  ZodType.init(inst, def);
11789
+ inst._zod.processJSONSchema = (ctx, json, params) => unionProcessor(inst, ctx, json, params);
10247
11790
  inst.options = def.options;
10248
11791
  });
10249
11792
  function union(options, params) {
@@ -10268,6 +11811,7 @@ function discriminatedUnion(discriminator, options, params) {
10268
11811
  var ZodIntersection = /* @__PURE__ */ $constructor("ZodIntersection", (inst, def) => {
10269
11812
  $ZodIntersection.init(inst, def);
10270
11813
  ZodType.init(inst, def);
11814
+ inst._zod.processJSONSchema = (ctx, json, params) => intersectionProcessor(inst, ctx, json, params);
10271
11815
  });
10272
11816
  function intersection(left, right) {
10273
11817
  return new ZodIntersection({
@@ -10279,10 +11823,19 @@ function intersection(left, right) {
10279
11823
  var ZodRecord = /* @__PURE__ */ $constructor("ZodRecord", (inst, def) => {
10280
11824
  $ZodRecord.init(inst, def);
10281
11825
  ZodType.init(inst, def);
11826
+ inst._zod.processJSONSchema = (ctx, json, params) => recordProcessor(inst, ctx, json, params);
10282
11827
  inst.keyType = def.keyType;
10283
11828
  inst.valueType = def.valueType;
10284
11829
  });
10285
11830
  function record(keyType, valueType, params) {
11831
+ if (!valueType || !valueType._zod) {
11832
+ return new ZodRecord({
11833
+ type: "record",
11834
+ keyType: string2(),
11835
+ valueType: keyType,
11836
+ ...util_exports.normalizeParams(valueType)
11837
+ });
11838
+ }
10286
11839
  return new ZodRecord({
10287
11840
  type: "record",
10288
11841
  keyType,
@@ -10293,6 +11846,7 @@ function record(keyType, valueType, params) {
10293
11846
  var ZodEnum = /* @__PURE__ */ $constructor("ZodEnum", (inst, def) => {
10294
11847
  $ZodEnum.init(inst, def);
10295
11848
  ZodType.init(inst, def);
11849
+ inst._zod.processJSONSchema = (ctx, json, params) => enumProcessor(inst, ctx, json, params);
10296
11850
  inst.enum = def.entries;
10297
11851
  inst.options = Object.values(def.entries);
10298
11852
  const keys = new Set(Object.keys(def.entries));
@@ -10338,6 +11892,7 @@ function _enum(values, params) {
10338
11892
  var ZodLiteral = /* @__PURE__ */ $constructor("ZodLiteral", (inst, def) => {
10339
11893
  $ZodLiteral.init(inst, def);
10340
11894
  ZodType.init(inst, def);
11895
+ inst._zod.processJSONSchema = (ctx, json, params) => literalProcessor(inst, ctx, json, params);
10341
11896
  inst.values = new Set(def.values);
10342
11897
  Object.defineProperty(inst, "value", {
10343
11898
  get() {
@@ -10358,7 +11913,11 @@ function literal(value, params) {
10358
11913
  var ZodTransform = /* @__PURE__ */ $constructor("ZodTransform", (inst, def) => {
10359
11914
  $ZodTransform.init(inst, def);
10360
11915
  ZodType.init(inst, def);
11916
+ inst._zod.processJSONSchema = (ctx, json, params) => transformProcessor(inst, ctx, json, params);
10361
11917
  inst._zod.parse = (payload, _ctx) => {
11918
+ if (_ctx.direction === "backward") {
11919
+ throw new $ZodEncodeError(inst.constructor.name);
11920
+ }
10362
11921
  payload.addIssue = (issue2) => {
10363
11922
  if (typeof issue2 === "string") {
10364
11923
  payload.issues.push(util_exports.issue(issue2, payload.value, def));
@@ -10369,7 +11928,6 @@ var ZodTransform = /* @__PURE__ */ $constructor("ZodTransform", (inst, def) => {
10369
11928
  _issue.code ?? (_issue.code = "custom");
10370
11929
  _issue.input ?? (_issue.input = payload.value);
10371
11930
  _issue.inst ?? (_issue.inst = inst);
10372
- _issue.continue ?? (_issue.continue = true);
10373
11931
  payload.issues.push(util_exports.issue(_issue));
10374
11932
  }
10375
11933
  };
@@ -10377,10 +11935,12 @@ var ZodTransform = /* @__PURE__ */ $constructor("ZodTransform", (inst, def) => {
10377
11935
  if (output instanceof Promise) {
10378
11936
  return output.then((output2) => {
10379
11937
  payload.value = output2;
11938
+ payload.fallback = true;
10380
11939
  return payload;
10381
11940
  });
10382
11941
  }
10383
11942
  payload.value = output;
11943
+ payload.fallback = true;
10384
11944
  return payload;
10385
11945
  };
10386
11946
  });
@@ -10393,6 +11953,7 @@ function transform(fn) {
10393
11953
  var ZodOptional = /* @__PURE__ */ $constructor("ZodOptional", (inst, def) => {
10394
11954
  $ZodOptional.init(inst, def);
10395
11955
  ZodType.init(inst, def);
11956
+ inst._zod.processJSONSchema = (ctx, json, params) => optionalProcessor(inst, ctx, json, params);
10396
11957
  inst.unwrap = () => inst._zod.def.innerType;
10397
11958
  });
10398
11959
  function optional(innerType) {
@@ -10401,9 +11962,22 @@ function optional(innerType) {
10401
11962
  innerType
10402
11963
  });
10403
11964
  }
11965
+ var ZodExactOptional = /* @__PURE__ */ $constructor("ZodExactOptional", (inst, def) => {
11966
+ $ZodExactOptional.init(inst, def);
11967
+ ZodType.init(inst, def);
11968
+ inst._zod.processJSONSchema = (ctx, json, params) => optionalProcessor(inst, ctx, json, params);
11969
+ inst.unwrap = () => inst._zod.def.innerType;
11970
+ });
11971
+ function exactOptional(innerType) {
11972
+ return new ZodExactOptional({
11973
+ type: "optional",
11974
+ innerType
11975
+ });
11976
+ }
10404
11977
  var ZodNullable = /* @__PURE__ */ $constructor("ZodNullable", (inst, def) => {
10405
11978
  $ZodNullable.init(inst, def);
10406
11979
  ZodType.init(inst, def);
11980
+ inst._zod.processJSONSchema = (ctx, json, params) => nullableProcessor(inst, ctx, json, params);
10407
11981
  inst.unwrap = () => inst._zod.def.innerType;
10408
11982
  });
10409
11983
  function nullable(innerType) {
@@ -10415,6 +11989,7 @@ function nullable(innerType) {
10415
11989
  var ZodDefault = /* @__PURE__ */ $constructor("ZodDefault", (inst, def) => {
10416
11990
  $ZodDefault.init(inst, def);
10417
11991
  ZodType.init(inst, def);
11992
+ inst._zod.processJSONSchema = (ctx, json, params) => defaultProcessor(inst, ctx, json, params);
10418
11993
  inst.unwrap = () => inst._zod.def.innerType;
10419
11994
  inst.removeDefault = inst.unwrap;
10420
11995
  });
@@ -10423,13 +11998,14 @@ function _default(innerType, defaultValue) {
10423
11998
  type: "default",
10424
11999
  innerType,
10425
12000
  get defaultValue() {
10426
- return typeof defaultValue === "function" ? defaultValue() : defaultValue;
12001
+ return typeof defaultValue === "function" ? defaultValue() : util_exports.shallowClone(defaultValue);
10427
12002
  }
10428
12003
  });
10429
12004
  }
10430
12005
  var ZodPrefault = /* @__PURE__ */ $constructor("ZodPrefault", (inst, def) => {
10431
12006
  $ZodPrefault.init(inst, def);
10432
12007
  ZodType.init(inst, def);
12008
+ inst._zod.processJSONSchema = (ctx, json, params) => prefaultProcessor(inst, ctx, json, params);
10433
12009
  inst.unwrap = () => inst._zod.def.innerType;
10434
12010
  });
10435
12011
  function prefault(innerType, defaultValue) {
@@ -10437,13 +12013,14 @@ function prefault(innerType, defaultValue) {
10437
12013
  type: "prefault",
10438
12014
  innerType,
10439
12015
  get defaultValue() {
10440
- return typeof defaultValue === "function" ? defaultValue() : defaultValue;
12016
+ return typeof defaultValue === "function" ? defaultValue() : util_exports.shallowClone(defaultValue);
10441
12017
  }
10442
12018
  });
10443
12019
  }
10444
12020
  var ZodNonOptional = /* @__PURE__ */ $constructor("ZodNonOptional", (inst, def) => {
10445
12021
  $ZodNonOptional.init(inst, def);
10446
12022
  ZodType.init(inst, def);
12023
+ inst._zod.processJSONSchema = (ctx, json, params) => nonoptionalProcessor(inst, ctx, json, params);
10447
12024
  inst.unwrap = () => inst._zod.def.innerType;
10448
12025
  });
10449
12026
  function nonoptional(innerType, params) {
@@ -10456,6 +12033,7 @@ function nonoptional(innerType, params) {
10456
12033
  var ZodCatch = /* @__PURE__ */ $constructor("ZodCatch", (inst, def) => {
10457
12034
  $ZodCatch.init(inst, def);
10458
12035
  ZodType.init(inst, def);
12036
+ inst._zod.processJSONSchema = (ctx, json, params) => catchProcessor(inst, ctx, json, params);
10459
12037
  inst.unwrap = () => inst._zod.def.innerType;
10460
12038
  inst.removeCatch = inst.unwrap;
10461
12039
  });
@@ -10469,6 +12047,7 @@ function _catch(innerType, catchValue) {
10469
12047
  var ZodPipe = /* @__PURE__ */ $constructor("ZodPipe", (inst, def) => {
10470
12048
  $ZodPipe.init(inst, def);
10471
12049
  ZodType.init(inst, def);
12050
+ inst._zod.processJSONSchema = (ctx, json, params) => pipeProcessor(inst, ctx, json, params);
10472
12051
  inst.in = def.in;
10473
12052
  inst.out = def.out;
10474
12053
  });
@@ -10480,9 +12059,15 @@ function pipe(in_, out) {
10480
12059
  // ...util.normalizeParams(params),
10481
12060
  });
10482
12061
  }
12062
+ var ZodPreprocess = /* @__PURE__ */ $constructor("ZodPreprocess", (inst, def) => {
12063
+ ZodPipe.init(inst, def);
12064
+ $ZodPreprocess.init(inst, def);
12065
+ });
10483
12066
  var ZodReadonly = /* @__PURE__ */ $constructor("ZodReadonly", (inst, def) => {
10484
12067
  $ZodReadonly.init(inst, def);
10485
12068
  ZodType.init(inst, def);
12069
+ inst._zod.processJSONSchema = (ctx, json, params) => readonlyProcessor(inst, ctx, json, params);
12070
+ inst.unwrap = () => inst._zod.def.innerType;
10486
12071
  });
10487
12072
  function readonly(innerType) {
10488
12073
  return new ZodReadonly({
@@ -10493,43 +12078,23 @@ function readonly(innerType) {
10493
12078
  var ZodCustom = /* @__PURE__ */ $constructor("ZodCustom", (inst, def) => {
10494
12079
  $ZodCustom.init(inst, def);
10495
12080
  ZodType.init(inst, def);
12081
+ inst._zod.processJSONSchema = (ctx, json, params) => customProcessor(inst, ctx, json, params);
10496
12082
  });
10497
- function check(fn) {
10498
- const ch = new $ZodCheck({
10499
- check: "custom"
10500
- // ...util.normalizeParams(params),
10501
- });
10502
- ch._zod.check = fn;
10503
- return ch;
10504
- }
10505
12083
  function custom(fn, _params) {
10506
12084
  return _custom(ZodCustom, fn ?? (() => true), _params);
10507
12085
  }
10508
12086
  function refine(fn, _params = {}) {
10509
12087
  return _refine(ZodCustom, fn, _params);
10510
12088
  }
10511
- function superRefine(fn) {
10512
- const ch = check((payload) => {
10513
- payload.addIssue = (issue2) => {
10514
- if (typeof issue2 === "string") {
10515
- payload.issues.push(util_exports.issue(issue2, payload.value, ch._zod.def));
10516
- } else {
10517
- const _issue = issue2;
10518
- if (_issue.fatal)
10519
- _issue.continue = false;
10520
- _issue.code ?? (_issue.code = "custom");
10521
- _issue.input ?? (_issue.input = payload.value);
10522
- _issue.inst ?? (_issue.inst = ch);
10523
- _issue.continue ?? (_issue.continue = !ch._zod.def.abort);
10524
- payload.issues.push(util_exports.issue(_issue));
10525
- }
10526
- };
10527
- return fn(payload.value, payload);
10528
- });
10529
- return ch;
12089
+ function superRefine(fn, params) {
12090
+ return _superRefine(fn, params);
10530
12091
  }
10531
12092
  function preprocess(fn, schema) {
10532
- return pipe(transform(fn), schema);
12093
+ return new ZodPreprocess({
12094
+ type: "pipe",
12095
+ in: transform(fn),
12096
+ out: schema
12097
+ });
10533
12098
  }
10534
12099
 
10535
12100
  // ../../node_modules/zod/v4/classic/external.js
@@ -10545,10 +12110,9 @@ var ProgressTokenSchema = union([string2(), number2().int()]);
10545
12110
  var CursorSchema = string2();
10546
12111
  var TaskCreationParamsSchema = looseObject({
10547
12112
  /**
10548
- * Time in milliseconds to keep task results available after completion.
10549
- * If null, the task has unlimited lifetime until manually cleaned up.
12113
+ * Requested duration in milliseconds to retain task from creation.
10550
12114
  */
10551
- ttl: union([number2(), _null3()]).optional(),
12115
+ ttl: number2().optional(),
10552
12116
  /**
10553
12117
  * Time in milliseconds to wait between task status requests.
10554
12118
  */
@@ -10848,7 +12412,11 @@ var ClientCapabilitiesSchema = object({
10848
12412
  /**
10849
12413
  * Present if the client supports task creation.
10850
12414
  */
10851
- tasks: ClientTasksCapabilitySchema.optional()
12415
+ tasks: ClientTasksCapabilitySchema.optional(),
12416
+ /**
12417
+ * Extensions that the client supports. Keys are extension identifiers (vendor-prefix/extension-name).
12418
+ */
12419
+ extensions: record(string2(), AssertObjectSchema).optional()
10852
12420
  });
10853
12421
  var InitializeRequestParamsSchema = BaseRequestParamsSchema.extend({
10854
12422
  /**
@@ -10909,7 +12477,11 @@ var ServerCapabilitiesSchema = object({
10909
12477
  /**
10910
12478
  * Present if the server supports task creation.
10911
12479
  */
10912
- tasks: ServerTasksCapabilitySchema.optional()
12480
+ tasks: ServerTasksCapabilitySchema.optional(),
12481
+ /**
12482
+ * Extensions that the server supports. Keys are extension identifiers (vendor-prefix/extension-name).
12483
+ */
12484
+ extensions: record(string2(), AssertObjectSchema).optional()
10913
12485
  });
10914
12486
  var InitializeResultSchema = ResultSchema.extend({
10915
12487
  /**
@@ -11101,6 +12673,12 @@ var ResourceSchema = object({
11101
12673
  * The MIME type of this resource, if known.
11102
12674
  */
11103
12675
  mimeType: optional(string2()),
12676
+ /**
12677
+ * The size of the raw resource content, in bytes (i.e., before base64 encoding or any tokenization), if known.
12678
+ *
12679
+ * This can be used by Hosts to display file sizes and estimate context window usage.
12680
+ */
12681
+ size: optional(number2()),
11104
12682
  /**
11105
12683
  * Optional annotations for the client.
11106
12684
  */
@@ -12071,7 +13649,7 @@ function serializeMessage(message) {
12071
13649
 
12072
13650
  // ../../node_modules/@modelcontextprotocol/sdk/dist/esm/server/stdio.js
12073
13651
  var StdioServerTransport = class {
12074
- constructor(_stdin = process2.stdin, _stdout = process2.stdout) {
13652
+ constructor(_stdin = process3.stdin, _stdout = process3.stdout) {
12075
13653
  this._stdin = _stdin;
12076
13654
  this._stdout = _stdout;
12077
13655
  this._readBuffer = new ReadBuffer();
@@ -12434,6 +14012,10 @@ var Protocol = class {
12434
14012
  this._progressHandlers.clear();
12435
14013
  this._taskProgressTokens.clear();
12436
14014
  this._pendingDebouncedNotifications.clear();
14015
+ for (const info of this._timeoutInfo.values()) {
14016
+ clearTimeout(info.timeoutId);
14017
+ }
14018
+ this._timeoutInfo.clear();
12437
14019
  for (const controller of this._requestHandlerAbortControllers.values()) {
12438
14020
  controller.abort();
12439
14021
  }
@@ -12564,7 +14146,9 @@ var Protocol = class {
12564
14146
  await capturedTransport?.send(errorResponse);
12565
14147
  }
12566
14148
  }).catch((error2) => this._onerror(new Error(`Failed to send response: ${error2}`))).finally(() => {
12567
- this._requestHandlerAbortControllers.delete(request.id);
14149
+ if (this._requestHandlerAbortControllers.get(request.id) === abortController) {
14150
+ this._requestHandlerAbortControllers.delete(request.id);
14151
+ }
12568
14152
  });
12569
14153
  }
12570
14154
  _onprogress(notification) {
@@ -14018,18 +15602,38 @@ async function ensureToolsServer(paths) {
14018
15602
  }
14019
15603
 
14020
15604
  // ../argent-mcp/src/content.ts
15605
+ var PNG_SIGNATURE = Buffer.from([137, 80, 78, 71, 13, 10, 26, 10]);
15606
+ async function fetchPngBytes(url) {
15607
+ try {
15608
+ const res = await fetch(url);
15609
+ if (!res.ok) return null;
15610
+ const buf = Buffer.from(await res.arrayBuffer());
15611
+ if (buf.length < PNG_SIGNATURE.length) return null;
15612
+ if (!buf.subarray(0, PNG_SIGNATURE.length).equals(PNG_SIGNATURE)) return null;
15613
+ return buf;
15614
+ } catch {
15615
+ return null;
15616
+ }
15617
+ }
14021
15618
  async function toMcpContent(result, outputHint) {
14022
15619
  if (outputHint === "image" && result && typeof result === "object" && "url" in result) {
14023
- const imgRes = await fetch(result.url);
14024
- const buf = Buffer.from(await imgRes.arrayBuffer());
14025
- const filePath = result.path ?? "";
15620
+ const r = result;
15621
+ const buf = await fetchPngBytes(r.url);
15622
+ if (buf) {
15623
+ return [
15624
+ {
15625
+ type: "image",
15626
+ data: buf.toString("base64"),
15627
+ mimeType: "image/png"
15628
+ },
15629
+ { type: "text", text: `Saved: ${r.path ?? ""}` }
15630
+ ];
15631
+ }
14026
15632
  return [
14027
15633
  {
14028
- type: "image",
14029
- data: buf.toString("base64"),
14030
- mimeType: "image/png"
14031
- },
14032
- { type: "text", text: `Saved: ${filePath}` }
15634
+ type: "text",
15635
+ text: `(Screenshot unavailable: no valid PNG at ${r.url}. Take a new screenshot.)`
15636
+ }
14033
15637
  ];
14034
15638
  }
14035
15639
  return [{ type: "text", text: JSON.stringify(result, null, 2) }];
@@ -14129,14 +15733,14 @@ function getAutoScreenshotDelayMs(toolName) {
14129
15733
 
14130
15734
  // ../argent-mcp/src/tool-mapping.ts
14131
15735
  function toMcpTool(t) {
14132
- const meta = {};
14133
- if (t.alwaysLoad) meta["anthropic/alwaysLoad"] = true;
14134
- if (t.searchHint) meta["anthropic/searchHint"] = t.searchHint;
15736
+ const meta2 = {};
15737
+ if (t.alwaysLoad) meta2["anthropic/alwaysLoad"] = true;
15738
+ if (t.searchHint) meta2["anthropic/searchHint"] = t.searchHint;
14135
15739
  return {
14136
15740
  name: t.name,
14137
15741
  description: t.description,
14138
15742
  inputSchema: { type: "object", ...t.inputSchema },
14139
- ...Object.keys(meta).length > 0 ? { _meta: meta } : {}
15743
+ ...Object.keys(meta2).length > 0 ? { _meta: meta2 } : {}
14140
15744
  };
14141
15745
  }
14142
15746
 
@@ -14214,18 +15818,18 @@ async function startMcpServer(options) {
14214
15818
  }
14215
15819
  async function callTool(name, args) {
14216
15820
  const tools = await fetchTools();
14217
- const meta = tools.find((t) => t.name === name);
15821
+ const meta2 = tools.find((t) => t.name === name);
14218
15822
  const res = await fetchWithReconnect(() => `${TOOLS_URL}/tools/${name}`, reconnect, {
14219
15823
  init: {
14220
15824
  method: "POST",
14221
15825
  headers: { "Content-Type": "application/json" },
14222
15826
  body: JSON.stringify(args ?? {})
14223
15827
  },
14224
- fetchTimeoutMs: meta?.longRunning ? null : FETCH_TIMEOUT_MS
15828
+ fetchTimeoutMs: meta2?.longRunning ? null : FETCH_TIMEOUT_MS
14225
15829
  });
14226
15830
  const json = await res.json();
14227
15831
  if (!res.ok) throw new Error(json.error ?? json.message ?? res.statusText);
14228
- return { result: json.data, outputHint: meta?.outputHint, note: json.note };
15832
+ return { result: json.data, outputHint: meta2?.outputHint, note: json.note };
14229
15833
  }
14230
15834
  const server = new Server(
14231
15835
  { name: "argent", version: "0.5.3" },
@@ -14277,22 +15881,18 @@ async function startMcpServer(options) {
14277
15881
  try {
14278
15882
  const screenshotResult = await callTool("screenshot", { udid });
14279
15883
  const screenshotContent = await toMcpContent(screenshotResult.result, "image");
14280
- content = [
14281
- ...content,
14282
- {
14283
- type: "text",
14284
- text: "--- Screen after action ---"
14285
- },
14286
- ...screenshotContent
14287
- ];
14288
- } catch (ssErr) {
14289
- content = [
14290
- ...content,
14291
- {
14292
- type: "text",
14293
- text: `(Auto-screenshot skipped: ${ssErr instanceof Error ? ssErr.message : String(ssErr)})`
14294
- }
14295
- ];
15884
+ const hasImage = screenshotContent.some((b) => b.type === "image");
15885
+ if (hasImage) {
15886
+ content = [
15887
+ ...content,
15888
+ {
15889
+ type: "text",
15890
+ text: "--- Screen after action ---"
15891
+ },
15892
+ ...screenshotContent
15893
+ ];
15894
+ }
15895
+ } catch {
14296
15896
  }
14297
15897
  }
14298
15898
  if (note) {