@vibeprospecting/vpai 0.1.1 → 0.1.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/vpai.js CHANGED
@@ -5666,9 +5666,9 @@ var require_util = __commonJS((exports) => {
5666
5666
  }
5667
5667
  }
5668
5668
  exports.eachItem = eachItem;
5669
- function makeMergeEvaluated({ mergeNames, mergeToName, mergeValues: mergeValues3, resultToName }) {
5669
+ function makeMergeEvaluated({ mergeNames, mergeToName, mergeValues: mergeValues4, resultToName }) {
5670
5670
  return (gen, from, to, toName) => {
5671
- const res = to === undefined ? from : to instanceof codegen_1.Name ? (from instanceof codegen_1.Name ? mergeNames(gen, from, to) : mergeToName(gen, from, to), to) : from instanceof codegen_1.Name ? (mergeToName(gen, to, from), from) : mergeValues3(from, to);
5671
+ const res = to === undefined ? from : to instanceof codegen_1.Name ? (from instanceof codegen_1.Name ? mergeNames(gen, from, to) : mergeToName(gen, from, to), to) : from instanceof codegen_1.Name ? (mergeToName(gen, to, from), from) : mergeValues4(from, to);
5672
5672
  return toName === codegen_1.Name && !(res instanceof codegen_1.Name) ? resultToName(gen, res) : res;
5673
5673
  };
5674
5674
  }
@@ -5994,37 +5994,37 @@ var require_dataType = __commonJS((exports) => {
5994
5994
  DataType2[DataType2["Wrong"] = 1] = "Wrong";
5995
5995
  })(DataType || (exports.DataType = DataType = {}));
5996
5996
  function getSchemaTypes(schema) {
5997
- const types = getJSONTypes(schema.type);
5998
- const hasNull = types.includes("null");
5997
+ const types2 = getJSONTypes(schema.type);
5998
+ const hasNull = types2.includes("null");
5999
5999
  if (hasNull) {
6000
6000
  if (schema.nullable === false)
6001
6001
  throw new Error("type: null contradicts nullable: false");
6002
6002
  } else {
6003
- if (!types.length && schema.nullable !== undefined) {
6003
+ if (!types2.length && schema.nullable !== undefined) {
6004
6004
  throw new Error('"nullable" cannot be used without "type"');
6005
6005
  }
6006
6006
  if (schema.nullable === true)
6007
- types.push("null");
6007
+ types2.push("null");
6008
6008
  }
6009
- return types;
6009
+ return types2;
6010
6010
  }
6011
6011
  exports.getSchemaTypes = getSchemaTypes;
6012
6012
  function getJSONTypes(ts) {
6013
- const types = Array.isArray(ts) ? ts : ts ? [ts] : [];
6014
- if (types.every(rules_1.isJSONType))
6015
- return types;
6016
- throw new Error("type must be JSONType or JSONType[]: " + types.join(","));
6013
+ const types2 = Array.isArray(ts) ? ts : ts ? [ts] : [];
6014
+ if (types2.every(rules_1.isJSONType))
6015
+ return types2;
6016
+ throw new Error("type must be JSONType or JSONType[]: " + types2.join(","));
6017
6017
  }
6018
6018
  exports.getJSONTypes = getJSONTypes;
6019
- function coerceAndCheckDataType(it, types) {
6019
+ function coerceAndCheckDataType(it, types2) {
6020
6020
  const { gen, data, opts } = it;
6021
- const coerceTo = coerceToTypes(types, opts.coerceTypes);
6022
- const checkTypes = types.length > 0 && !(coerceTo.length === 0 && types.length === 1 && (0, applicability_1.schemaHasRulesForType)(it, types[0]));
6021
+ const coerceTo = coerceToTypes(types2, opts.coerceTypes);
6022
+ const checkTypes = types2.length > 0 && !(coerceTo.length === 0 && types2.length === 1 && (0, applicability_1.schemaHasRulesForType)(it, types2[0]));
6023
6023
  if (checkTypes) {
6024
- const wrongType = checkDataTypes(types, data, opts.strictNumbers, DataType.Wrong);
6024
+ const wrongType = checkDataTypes(types2, data, opts.strictNumbers, DataType.Wrong);
6025
6025
  gen.if(wrongType, () => {
6026
6026
  if (coerceTo.length)
6027
- coerceData(it, types, coerceTo);
6027
+ coerceData(it, types2, coerceTo);
6028
6028
  else
6029
6029
  reportTypeError(it);
6030
6030
  });
@@ -6033,15 +6033,15 @@ var require_dataType = __commonJS((exports) => {
6033
6033
  }
6034
6034
  exports.coerceAndCheckDataType = coerceAndCheckDataType;
6035
6035
  var COERCIBLE = new Set(["string", "number", "integer", "boolean", "null"]);
6036
- function coerceToTypes(types, coerceTypes) {
6037
- return coerceTypes ? types.filter((t) => COERCIBLE.has(t) || coerceTypes === "array" && t === "array") : [];
6036
+ function coerceToTypes(types2, coerceTypes) {
6037
+ return coerceTypes ? types2.filter((t) => COERCIBLE.has(t) || coerceTypes === "array" && t === "array") : [];
6038
6038
  }
6039
- function coerceData(it, types, coerceTo) {
6039
+ function coerceData(it, types2, coerceTo) {
6040
6040
  const { gen, data, opts } = it;
6041
6041
  const dataType = gen.let("dataType", (0, codegen_1._)`typeof ${data}`);
6042
6042
  const coerced = gen.let("coerced", (0, codegen_1._)`undefined`);
6043
6043
  if (opts.coerceTypes === "array") {
6044
- gen.if((0, codegen_1._)`${dataType} == 'object' && Array.isArray(${data}) && ${data}.length == 1`, () => gen.assign(data, (0, codegen_1._)`${data}[0]`).assign(dataType, (0, codegen_1._)`typeof ${data}`).if(checkDataTypes(types, data, opts.strictNumbers), () => gen.assign(coerced, data)));
6044
+ gen.if((0, codegen_1._)`${dataType} == 'object' && Array.isArray(${data}) && ${data}.length == 1`, () => gen.assign(data, (0, codegen_1._)`${data}[0]`).assign(dataType, (0, codegen_1._)`typeof ${data}`).if(checkDataTypes(types2, data, opts.strictNumbers), () => gen.assign(coerced, data)));
6045
6045
  }
6046
6046
  gen.if((0, codegen_1._)`${coerced} !== undefined`);
6047
6047
  for (const t of coerceTo) {
@@ -6117,19 +6117,19 @@ var require_dataType = __commonJS((exports) => {
6117
6117
  return checkDataType(dataTypes[0], data, strictNums, correct);
6118
6118
  }
6119
6119
  let cond;
6120
- const types = (0, util_1.toHash)(dataTypes);
6121
- if (types.array && types.object) {
6120
+ const types2 = (0, util_1.toHash)(dataTypes);
6121
+ if (types2.array && types2.object) {
6122
6122
  const notObj = (0, codegen_1._)`typeof ${data} != "object"`;
6123
- cond = types.null ? notObj : (0, codegen_1._)`!${data} || ${notObj}`;
6124
- delete types.null;
6125
- delete types.array;
6126
- delete types.object;
6123
+ cond = types2.null ? notObj : (0, codegen_1._)`!${data} || ${notObj}`;
6124
+ delete types2.null;
6125
+ delete types2.array;
6126
+ delete types2.object;
6127
6127
  } else {
6128
6128
  cond = codegen_1.nil;
6129
6129
  }
6130
- if (types.number)
6131
- delete types.integer;
6132
- for (const t in types)
6130
+ if (types2.number)
6131
+ delete types2.integer;
6132
+ for (const t in types2)
6133
6133
  cond = (0, codegen_1.and)(cond, checkDataType(t, data, strictNums, correct));
6134
6134
  return cond;
6135
6135
  }
@@ -6386,9 +6386,9 @@ var require_keyword = __commonJS((exports) => {
6386
6386
  const passSchema = !(("compile" in def) && !$data || def.schema === false);
6387
6387
  gen.assign(valid, (0, codegen_1._)`${_await}${(0, code_1.callValidateCode)(cxt, validateRef, passCxt, passSchema)}`, def.modifying);
6388
6388
  }
6389
- function reportErrs(errors5) {
6389
+ function reportErrs(errors6) {
6390
6390
  var _a3;
6391
- gen.if((0, codegen_1.not)((_a3 = def.valid) !== null && _a3 !== undefined ? _a3 : valid), errors5);
6391
+ gen.if((0, codegen_1.not)((_a3 = def.valid) !== null && _a3 !== undefined ? _a3 : valid), errors6);
6392
6392
  }
6393
6393
  }
6394
6394
  exports.funcKeywordCode = funcKeywordCode;
@@ -6917,9 +6917,9 @@ var require_validate = __commonJS((exports) => {
6917
6917
  function typeAndKeywords(it, errsCount) {
6918
6918
  if (it.opts.jtd)
6919
6919
  return schemaKeywords(it, [], false, errsCount);
6920
- const types = (0, dataType_1.getSchemaTypes)(it.schema);
6921
- const checkedTypes = (0, dataType_1.coerceAndCheckDataType)(it, types);
6922
- schemaKeywords(it, types, !checkedTypes, errsCount);
6920
+ const types2 = (0, dataType_1.getSchemaTypes)(it.schema);
6921
+ const checkedTypes = (0, dataType_1.coerceAndCheckDataType)(it, types2);
6922
+ schemaKeywords(it, types2, !checkedTypes, errsCount);
6923
6923
  }
6924
6924
  function checkRefsAndKeywords(it) {
6925
6925
  const { schema, errSchemaPath, opts, self } = it;
@@ -6969,7 +6969,7 @@ var require_validate = __commonJS((exports) => {
6969
6969
  if (items instanceof codegen_1.Name)
6970
6970
  gen.assign((0, codegen_1._)`${evaluated}.items`, items);
6971
6971
  }
6972
- function schemaKeywords(it, types, typeErrors, errsCount) {
6972
+ function schemaKeywords(it, types2, typeErrors, errsCount) {
6973
6973
  const { gen, schema, data, allErrors, opts, self } = it;
6974
6974
  const { RULES } = self;
6975
6975
  if (schema.$ref && (opts.ignoreKeywordsWithRef || !(0, util_1.schemaHasRulesButRef)(schema, RULES))) {
@@ -6977,7 +6977,7 @@ var require_validate = __commonJS((exports) => {
6977
6977
  return;
6978
6978
  }
6979
6979
  if (!opts.jtd)
6980
- checkStrictTypes(it, types);
6980
+ checkStrictTypes(it, types2);
6981
6981
  gen.block(() => {
6982
6982
  for (const group of RULES.rules)
6983
6983
  groupKeywords(group);
@@ -6989,7 +6989,7 @@ var require_validate = __commonJS((exports) => {
6989
6989
  if (group.type) {
6990
6990
  gen.if((0, dataType_2.checkDataType)(group.type, data, opts.strictNumbers));
6991
6991
  iterateKeywords(it, group);
6992
- if (types.length === 1 && types[0] === group.type && typeErrors) {
6992
+ if (types2.length === 1 && types2[0] === group.type && typeErrors) {
6993
6993
  gen.else();
6994
6994
  (0, dataType_2.reportTypeError)(it);
6995
6995
  }
@@ -7013,27 +7013,27 @@ var require_validate = __commonJS((exports) => {
7013
7013
  }
7014
7014
  });
7015
7015
  }
7016
- function checkStrictTypes(it, types) {
7016
+ function checkStrictTypes(it, types2) {
7017
7017
  if (it.schemaEnv.meta || !it.opts.strictTypes)
7018
7018
  return;
7019
- checkContextTypes(it, types);
7019
+ checkContextTypes(it, types2);
7020
7020
  if (!it.opts.allowUnionTypes)
7021
- checkMultipleTypes(it, types);
7021
+ checkMultipleTypes(it, types2);
7022
7022
  checkKeywordTypes(it, it.dataTypes);
7023
7023
  }
7024
- function checkContextTypes(it, types) {
7025
- if (!types.length)
7024
+ function checkContextTypes(it, types2) {
7025
+ if (!types2.length)
7026
7026
  return;
7027
7027
  if (!it.dataTypes.length) {
7028
- it.dataTypes = types;
7028
+ it.dataTypes = types2;
7029
7029
  return;
7030
7030
  }
7031
- types.forEach((t) => {
7031
+ types2.forEach((t) => {
7032
7032
  if (!includesType(it.dataTypes, t)) {
7033
7033
  strictTypesError(it, `type "${t}" not allowed by context "${it.dataTypes.join(",")}"`);
7034
7034
  }
7035
7035
  });
7036
- narrowSchemaTypes(it, types);
7036
+ narrowSchemaTypes(it, types2);
7037
7037
  }
7038
7038
  function checkMultipleTypes(it, ts) {
7039
7039
  if (ts.length > 1 && !(ts.length === 2 && ts.includes("null"))) {
@@ -7306,9 +7306,9 @@ var require_validation_error = __commonJS((exports) => {
7306
7306
  Object.defineProperty(exports, "__esModule", { value: true });
7307
7307
 
7308
7308
  class ValidationError extends Error {
7309
- constructor(errors5) {
7309
+ constructor(errors6) {
7310
7310
  super("validation failed");
7311
- this.errors = errors5;
7311
+ this.errors = errors6;
7312
7312
  this.ajv = this.validation = true;
7313
7313
  }
7314
7314
  }
@@ -8631,10 +8631,10 @@ var require_core = __commonJS((exports) => {
8631
8631
  this.formats[name] = format2;
8632
8632
  return this;
8633
8633
  }
8634
- errorsText(errors5 = this.errors, { separator = ", ", dataVar = "data" } = {}) {
8635
- if (!errors5 || errors5.length === 0)
8634
+ errorsText(errors6 = this.errors, { separator = ", ", dataVar = "data" } = {}) {
8635
+ if (!errors6 || errors6.length === 0)
8636
8636
  return "No errors";
8637
- return errors5.map((e) => `${dataVar}${e.instancePath} ${e.message}`).reduce((text, msg) => text + separator + msg);
8637
+ return errors6.map((e) => `${dataVar}${e.instancePath} ${e.message}`).reduce((text, msg) => text + separator + msg);
8638
8638
  }
8639
8639
  $dataMetaSchema(metaSchema, keywordsJsonPointers) {
8640
8640
  const rules = this.RULES.all;
@@ -9892,13 +9892,13 @@ var require_additionalProperties = __commonJS((exports) => {
9892
9892
  }
9893
9893
  }
9894
9894
  }
9895
- function applyAdditionalSchema(key, valid, errors5) {
9895
+ function applyAdditionalSchema(key, valid, errors6) {
9896
9896
  const subschema = {
9897
9897
  keyword: "additionalProperties",
9898
9898
  dataProp: key,
9899
9899
  dataPropType: util_1.Type.Str
9900
9900
  };
9901
- if (errors5 === false) {
9901
+ if (errors6 === false) {
9902
9902
  Object.assign(subschema, {
9903
9903
  compositeRule: true,
9904
9904
  createErrors: false,
@@ -33310,6 +33310,3980 @@ function parseOAuthTimeout(raw) {
33310
33310
  function resolveOAuthTimeoutFromEnv() {
33311
33311
  return parseOAuthTimeout(process.env.MCPORTER_OAUTH_TIMEOUT_MS ?? process.env.MCPORTER_OAUTH_TIMEOUT);
33312
33312
  }
33313
+
33314
+ // node_modules/zod/v3/external.js
33315
+ var exports_external2 = {};
33316
+ __export(exports_external2, {
33317
+ void: () => voidType,
33318
+ util: () => util,
33319
+ unknown: () => unknownType,
33320
+ union: () => unionType,
33321
+ undefined: () => undefinedType,
33322
+ tuple: () => tupleType,
33323
+ transformer: () => effectsType,
33324
+ symbol: () => symbolType,
33325
+ string: () => stringType,
33326
+ strictObject: () => strictObjectType,
33327
+ setErrorMap: () => setErrorMap2,
33328
+ set: () => setType,
33329
+ record: () => recordType,
33330
+ quotelessJson: () => quotelessJson,
33331
+ promise: () => promiseType,
33332
+ preprocess: () => preprocessType,
33333
+ pipeline: () => pipelineType,
33334
+ ostring: () => ostring,
33335
+ optional: () => optionalType,
33336
+ onumber: () => onumber,
33337
+ oboolean: () => oboolean,
33338
+ objectUtil: () => objectUtil,
33339
+ object: () => objectType,
33340
+ number: () => numberType,
33341
+ nullable: () => nullableType,
33342
+ null: () => nullType,
33343
+ never: () => neverType,
33344
+ nativeEnum: () => nativeEnumType,
33345
+ nan: () => nanType,
33346
+ map: () => mapType,
33347
+ makeIssue: () => makeIssue,
33348
+ literal: () => literalType,
33349
+ lazy: () => lazyType,
33350
+ late: () => late,
33351
+ isValid: () => isValid,
33352
+ isDirty: () => isDirty,
33353
+ isAsync: () => isAsync,
33354
+ isAborted: () => isAborted,
33355
+ intersection: () => intersectionType,
33356
+ instanceof: () => instanceOfType,
33357
+ getParsedType: () => getParsedType3,
33358
+ getErrorMap: () => getErrorMap2,
33359
+ function: () => functionType,
33360
+ enum: () => enumType,
33361
+ effect: () => effectsType,
33362
+ discriminatedUnion: () => discriminatedUnionType,
33363
+ defaultErrorMap: () => en_default3,
33364
+ datetimeRegex: () => datetimeRegex,
33365
+ date: () => dateType,
33366
+ custom: () => custom3,
33367
+ coerce: () => coerce,
33368
+ boolean: () => booleanType,
33369
+ bigint: () => bigIntType,
33370
+ array: () => arrayType,
33371
+ any: () => anyType,
33372
+ addIssueToContext: () => addIssueToContext,
33373
+ ZodVoid: () => ZodVoid2,
33374
+ ZodUnknown: () => ZodUnknown3,
33375
+ ZodUnion: () => ZodUnion3,
33376
+ ZodUndefined: () => ZodUndefined2,
33377
+ ZodType: () => ZodType3,
33378
+ ZodTuple: () => ZodTuple2,
33379
+ ZodTransformer: () => ZodEffects,
33380
+ ZodSymbol: () => ZodSymbol2,
33381
+ ZodString: () => ZodString3,
33382
+ ZodSet: () => ZodSet2,
33383
+ ZodSchema: () => ZodType3,
33384
+ ZodRecord: () => ZodRecord3,
33385
+ ZodReadonly: () => ZodReadonly3,
33386
+ ZodPromise: () => ZodPromise2,
33387
+ ZodPipeline: () => ZodPipeline,
33388
+ ZodParsedType: () => ZodParsedType,
33389
+ ZodOptional: () => ZodOptional3,
33390
+ ZodObject: () => ZodObject3,
33391
+ ZodNumber: () => ZodNumber3,
33392
+ ZodNullable: () => ZodNullable3,
33393
+ ZodNull: () => ZodNull3,
33394
+ ZodNever: () => ZodNever3,
33395
+ ZodNativeEnum: () => ZodNativeEnum,
33396
+ ZodNaN: () => ZodNaN2,
33397
+ ZodMap: () => ZodMap2,
33398
+ ZodLiteral: () => ZodLiteral3,
33399
+ ZodLazy: () => ZodLazy2,
33400
+ ZodIssueCode: () => ZodIssueCode3,
33401
+ ZodIntersection: () => ZodIntersection3,
33402
+ ZodFunction: () => ZodFunction2,
33403
+ ZodFirstPartyTypeKind: () => ZodFirstPartyTypeKind2,
33404
+ ZodError: () => ZodError3,
33405
+ ZodEnum: () => ZodEnum3,
33406
+ ZodEffects: () => ZodEffects,
33407
+ ZodDiscriminatedUnion: () => ZodDiscriminatedUnion3,
33408
+ ZodDefault: () => ZodDefault3,
33409
+ ZodDate: () => ZodDate3,
33410
+ ZodCatch: () => ZodCatch3,
33411
+ ZodBranded: () => ZodBranded,
33412
+ ZodBoolean: () => ZodBoolean3,
33413
+ ZodBigInt: () => ZodBigInt3,
33414
+ ZodArray: () => ZodArray3,
33415
+ ZodAny: () => ZodAny3,
33416
+ Schema: () => ZodType3,
33417
+ ParseStatus: () => ParseStatus,
33418
+ OK: () => OK,
33419
+ NEVER: () => NEVER3,
33420
+ INVALID: () => INVALID,
33421
+ EMPTY_PATH: () => EMPTY_PATH,
33422
+ DIRTY: () => DIRTY,
33423
+ BRAND: () => BRAND
33424
+ });
33425
+
33426
+ // node_modules/zod/v3/helpers/util.js
33427
+ var util;
33428
+ (function(util2) {
33429
+ util2.assertEqual = (_) => {};
33430
+ function assertIs3(_arg) {}
33431
+ util2.assertIs = assertIs3;
33432
+ function assertNever3(_x) {
33433
+ throw new Error;
33434
+ }
33435
+ util2.assertNever = assertNever3;
33436
+ util2.arrayToEnum = (items) => {
33437
+ const obj = {};
33438
+ for (const item of items) {
33439
+ obj[item] = item;
33440
+ }
33441
+ return obj;
33442
+ };
33443
+ util2.getValidEnumValues = (obj) => {
33444
+ const validKeys = util2.objectKeys(obj).filter((k) => typeof obj[obj[k]] !== "number");
33445
+ const filtered = {};
33446
+ for (const k of validKeys) {
33447
+ filtered[k] = obj[k];
33448
+ }
33449
+ return util2.objectValues(filtered);
33450
+ };
33451
+ util2.objectValues = (obj) => {
33452
+ return util2.objectKeys(obj).map(function(e) {
33453
+ return obj[e];
33454
+ });
33455
+ };
33456
+ util2.objectKeys = typeof Object.keys === "function" ? (obj) => Object.keys(obj) : (object3) => {
33457
+ const keys = [];
33458
+ for (const key in object3) {
33459
+ if (Object.prototype.hasOwnProperty.call(object3, key)) {
33460
+ keys.push(key);
33461
+ }
33462
+ }
33463
+ return keys;
33464
+ };
33465
+ util2.find = (arr, checker) => {
33466
+ for (const item of arr) {
33467
+ if (checker(item))
33468
+ return item;
33469
+ }
33470
+ return;
33471
+ };
33472
+ util2.isInteger = typeof Number.isInteger === "function" ? (val) => Number.isInteger(val) : (val) => typeof val === "number" && Number.isFinite(val) && Math.floor(val) === val;
33473
+ function joinValues3(array3, separator = " | ") {
33474
+ return array3.map((val) => typeof val === "string" ? `'${val}'` : val).join(separator);
33475
+ }
33476
+ util2.joinValues = joinValues3;
33477
+ util2.jsonStringifyReplacer = (_, value) => {
33478
+ if (typeof value === "bigint") {
33479
+ return value.toString();
33480
+ }
33481
+ return value;
33482
+ };
33483
+ })(util || (util = {}));
33484
+ var objectUtil;
33485
+ (function(objectUtil2) {
33486
+ objectUtil2.mergeShapes = (first, second) => {
33487
+ return {
33488
+ ...first,
33489
+ ...second
33490
+ };
33491
+ };
33492
+ })(objectUtil || (objectUtil = {}));
33493
+ var ZodParsedType = util.arrayToEnum([
33494
+ "string",
33495
+ "nan",
33496
+ "number",
33497
+ "integer",
33498
+ "float",
33499
+ "boolean",
33500
+ "date",
33501
+ "bigint",
33502
+ "symbol",
33503
+ "function",
33504
+ "undefined",
33505
+ "null",
33506
+ "array",
33507
+ "object",
33508
+ "unknown",
33509
+ "promise",
33510
+ "void",
33511
+ "never",
33512
+ "map",
33513
+ "set"
33514
+ ]);
33515
+ var getParsedType3 = (data) => {
33516
+ const t = typeof data;
33517
+ switch (t) {
33518
+ case "undefined":
33519
+ return ZodParsedType.undefined;
33520
+ case "string":
33521
+ return ZodParsedType.string;
33522
+ case "number":
33523
+ return Number.isNaN(data) ? ZodParsedType.nan : ZodParsedType.number;
33524
+ case "boolean":
33525
+ return ZodParsedType.boolean;
33526
+ case "function":
33527
+ return ZodParsedType.function;
33528
+ case "bigint":
33529
+ return ZodParsedType.bigint;
33530
+ case "symbol":
33531
+ return ZodParsedType.symbol;
33532
+ case "object":
33533
+ if (Array.isArray(data)) {
33534
+ return ZodParsedType.array;
33535
+ }
33536
+ if (data === null) {
33537
+ return ZodParsedType.null;
33538
+ }
33539
+ if (data.then && typeof data.then === "function" && data.catch && typeof data.catch === "function") {
33540
+ return ZodParsedType.promise;
33541
+ }
33542
+ if (typeof Map !== "undefined" && data instanceof Map) {
33543
+ return ZodParsedType.map;
33544
+ }
33545
+ if (typeof Set !== "undefined" && data instanceof Set) {
33546
+ return ZodParsedType.set;
33547
+ }
33548
+ if (typeof Date !== "undefined" && data instanceof Date) {
33549
+ return ZodParsedType.date;
33550
+ }
33551
+ return ZodParsedType.object;
33552
+ default:
33553
+ return ZodParsedType.unknown;
33554
+ }
33555
+ };
33556
+
33557
+ // node_modules/zod/v3/ZodError.js
33558
+ var ZodIssueCode3 = util.arrayToEnum([
33559
+ "invalid_type",
33560
+ "invalid_literal",
33561
+ "custom",
33562
+ "invalid_union",
33563
+ "invalid_union_discriminator",
33564
+ "invalid_enum_value",
33565
+ "unrecognized_keys",
33566
+ "invalid_arguments",
33567
+ "invalid_return_type",
33568
+ "invalid_date",
33569
+ "invalid_string",
33570
+ "too_small",
33571
+ "too_big",
33572
+ "invalid_intersection_types",
33573
+ "not_multiple_of",
33574
+ "not_finite"
33575
+ ]);
33576
+ var quotelessJson = (obj) => {
33577
+ const json2 = JSON.stringify(obj, null, 2);
33578
+ return json2.replace(/"([^"]+)":/g, "$1:");
33579
+ };
33580
+
33581
+ class ZodError3 extends Error {
33582
+ get errors() {
33583
+ return this.issues;
33584
+ }
33585
+ constructor(issues) {
33586
+ super();
33587
+ this.issues = [];
33588
+ this.addIssue = (sub) => {
33589
+ this.issues = [...this.issues, sub];
33590
+ };
33591
+ this.addIssues = (subs = []) => {
33592
+ this.issues = [...this.issues, ...subs];
33593
+ };
33594
+ const actualProto = new.target.prototype;
33595
+ if (Object.setPrototypeOf) {
33596
+ Object.setPrototypeOf(this, actualProto);
33597
+ } else {
33598
+ this.__proto__ = actualProto;
33599
+ }
33600
+ this.name = "ZodError";
33601
+ this.issues = issues;
33602
+ }
33603
+ format(_mapper) {
33604
+ const mapper = _mapper || function(issue3) {
33605
+ return issue3.message;
33606
+ };
33607
+ const fieldErrors = { _errors: [] };
33608
+ const processError = (error49) => {
33609
+ for (const issue3 of error49.issues) {
33610
+ if (issue3.code === "invalid_union") {
33611
+ issue3.unionErrors.map(processError);
33612
+ } else if (issue3.code === "invalid_return_type") {
33613
+ processError(issue3.returnTypeError);
33614
+ } else if (issue3.code === "invalid_arguments") {
33615
+ processError(issue3.argumentsError);
33616
+ } else if (issue3.path.length === 0) {
33617
+ fieldErrors._errors.push(mapper(issue3));
33618
+ } else {
33619
+ let curr = fieldErrors;
33620
+ let i = 0;
33621
+ while (i < issue3.path.length) {
33622
+ const el = issue3.path[i];
33623
+ const terminal = i === issue3.path.length - 1;
33624
+ if (!terminal) {
33625
+ curr[el] = curr[el] || { _errors: [] };
33626
+ } else {
33627
+ curr[el] = curr[el] || { _errors: [] };
33628
+ curr[el]._errors.push(mapper(issue3));
33629
+ }
33630
+ curr = curr[el];
33631
+ i++;
33632
+ }
33633
+ }
33634
+ }
33635
+ };
33636
+ processError(this);
33637
+ return fieldErrors;
33638
+ }
33639
+ static assert(value) {
33640
+ if (!(value instanceof ZodError3)) {
33641
+ throw new Error(`Not a ZodError: ${value}`);
33642
+ }
33643
+ }
33644
+ toString() {
33645
+ return this.message;
33646
+ }
33647
+ get message() {
33648
+ return JSON.stringify(this.issues, util.jsonStringifyReplacer, 2);
33649
+ }
33650
+ get isEmpty() {
33651
+ return this.issues.length === 0;
33652
+ }
33653
+ flatten(mapper = (issue3) => issue3.message) {
33654
+ const fieldErrors = {};
33655
+ const formErrors = [];
33656
+ for (const sub of this.issues) {
33657
+ if (sub.path.length > 0) {
33658
+ const firstEl = sub.path[0];
33659
+ fieldErrors[firstEl] = fieldErrors[firstEl] || [];
33660
+ fieldErrors[firstEl].push(mapper(sub));
33661
+ } else {
33662
+ formErrors.push(mapper(sub));
33663
+ }
33664
+ }
33665
+ return { formErrors, fieldErrors };
33666
+ }
33667
+ get formErrors() {
33668
+ return this.flatten();
33669
+ }
33670
+ }
33671
+ ZodError3.create = (issues) => {
33672
+ const error49 = new ZodError3(issues);
33673
+ return error49;
33674
+ };
33675
+
33676
+ // node_modules/zod/v3/locales/en.js
33677
+ var errorMap = (issue3, _ctx) => {
33678
+ let message;
33679
+ switch (issue3.code) {
33680
+ case ZodIssueCode3.invalid_type:
33681
+ if (issue3.received === ZodParsedType.undefined) {
33682
+ message = "Required";
33683
+ } else {
33684
+ message = `Expected ${issue3.expected}, received ${issue3.received}`;
33685
+ }
33686
+ break;
33687
+ case ZodIssueCode3.invalid_literal:
33688
+ message = `Invalid literal value, expected ${JSON.stringify(issue3.expected, util.jsonStringifyReplacer)}`;
33689
+ break;
33690
+ case ZodIssueCode3.unrecognized_keys:
33691
+ message = `Unrecognized key(s) in object: ${util.joinValues(issue3.keys, ", ")}`;
33692
+ break;
33693
+ case ZodIssueCode3.invalid_union:
33694
+ message = `Invalid input`;
33695
+ break;
33696
+ case ZodIssueCode3.invalid_union_discriminator:
33697
+ message = `Invalid discriminator value. Expected ${util.joinValues(issue3.options)}`;
33698
+ break;
33699
+ case ZodIssueCode3.invalid_enum_value:
33700
+ message = `Invalid enum value. Expected ${util.joinValues(issue3.options)}, received '${issue3.received}'`;
33701
+ break;
33702
+ case ZodIssueCode3.invalid_arguments:
33703
+ message = `Invalid function arguments`;
33704
+ break;
33705
+ case ZodIssueCode3.invalid_return_type:
33706
+ message = `Invalid function return type`;
33707
+ break;
33708
+ case ZodIssueCode3.invalid_date:
33709
+ message = `Invalid date`;
33710
+ break;
33711
+ case ZodIssueCode3.invalid_string:
33712
+ if (typeof issue3.validation === "object") {
33713
+ if ("includes" in issue3.validation) {
33714
+ message = `Invalid input: must include "${issue3.validation.includes}"`;
33715
+ if (typeof issue3.validation.position === "number") {
33716
+ message = `${message} at one or more positions greater than or equal to ${issue3.validation.position}`;
33717
+ }
33718
+ } else if ("startsWith" in issue3.validation) {
33719
+ message = `Invalid input: must start with "${issue3.validation.startsWith}"`;
33720
+ } else if ("endsWith" in issue3.validation) {
33721
+ message = `Invalid input: must end with "${issue3.validation.endsWith}"`;
33722
+ } else {
33723
+ util.assertNever(issue3.validation);
33724
+ }
33725
+ } else if (issue3.validation !== "regex") {
33726
+ message = `Invalid ${issue3.validation}`;
33727
+ } else {
33728
+ message = "Invalid";
33729
+ }
33730
+ break;
33731
+ case ZodIssueCode3.too_small:
33732
+ if (issue3.type === "array")
33733
+ message = `Array must contain ${issue3.exact ? "exactly" : issue3.inclusive ? `at least` : `more than`} ${issue3.minimum} element(s)`;
33734
+ else if (issue3.type === "string")
33735
+ message = `String must contain ${issue3.exact ? "exactly" : issue3.inclusive ? `at least` : `over`} ${issue3.minimum} character(s)`;
33736
+ else if (issue3.type === "number")
33737
+ message = `Number must be ${issue3.exact ? `exactly equal to ` : issue3.inclusive ? `greater than or equal to ` : `greater than `}${issue3.minimum}`;
33738
+ else if (issue3.type === "bigint")
33739
+ message = `Number must be ${issue3.exact ? `exactly equal to ` : issue3.inclusive ? `greater than or equal to ` : `greater than `}${issue3.minimum}`;
33740
+ else if (issue3.type === "date")
33741
+ message = `Date must be ${issue3.exact ? `exactly equal to ` : issue3.inclusive ? `greater than or equal to ` : `greater than `}${new Date(Number(issue3.minimum))}`;
33742
+ else
33743
+ message = "Invalid input";
33744
+ break;
33745
+ case ZodIssueCode3.too_big:
33746
+ if (issue3.type === "array")
33747
+ message = `Array must contain ${issue3.exact ? `exactly` : issue3.inclusive ? `at most` : `less than`} ${issue3.maximum} element(s)`;
33748
+ else if (issue3.type === "string")
33749
+ message = `String must contain ${issue3.exact ? `exactly` : issue3.inclusive ? `at most` : `under`} ${issue3.maximum} character(s)`;
33750
+ else if (issue3.type === "number")
33751
+ message = `Number must be ${issue3.exact ? `exactly` : issue3.inclusive ? `less than or equal to` : `less than`} ${issue3.maximum}`;
33752
+ else if (issue3.type === "bigint")
33753
+ message = `BigInt must be ${issue3.exact ? `exactly` : issue3.inclusive ? `less than or equal to` : `less than`} ${issue3.maximum}`;
33754
+ else if (issue3.type === "date")
33755
+ message = `Date must be ${issue3.exact ? `exactly` : issue3.inclusive ? `smaller than or equal to` : `smaller than`} ${new Date(Number(issue3.maximum))}`;
33756
+ else
33757
+ message = "Invalid input";
33758
+ break;
33759
+ case ZodIssueCode3.custom:
33760
+ message = `Invalid input`;
33761
+ break;
33762
+ case ZodIssueCode3.invalid_intersection_types:
33763
+ message = `Intersection results could not be merged`;
33764
+ break;
33765
+ case ZodIssueCode3.not_multiple_of:
33766
+ message = `Number must be a multiple of ${issue3.multipleOf}`;
33767
+ break;
33768
+ case ZodIssueCode3.not_finite:
33769
+ message = "Number must be finite";
33770
+ break;
33771
+ default:
33772
+ message = _ctx.defaultError;
33773
+ util.assertNever(issue3);
33774
+ }
33775
+ return { message };
33776
+ };
33777
+ var en_default3 = errorMap;
33778
+
33779
+ // node_modules/zod/v3/errors.js
33780
+ var overrideErrorMap = en_default3;
33781
+ function setErrorMap2(map2) {
33782
+ overrideErrorMap = map2;
33783
+ }
33784
+ function getErrorMap2() {
33785
+ return overrideErrorMap;
33786
+ }
33787
+ // node_modules/zod/v3/helpers/parseUtil.js
33788
+ var makeIssue = (params) => {
33789
+ const { data, path: path5, errorMaps, issueData } = params;
33790
+ const fullPath = [...path5, ...issueData.path || []];
33791
+ const fullIssue = {
33792
+ ...issueData,
33793
+ path: fullPath
33794
+ };
33795
+ if (issueData.message !== undefined) {
33796
+ return {
33797
+ ...issueData,
33798
+ path: fullPath,
33799
+ message: issueData.message
33800
+ };
33801
+ }
33802
+ let errorMessage = "";
33803
+ const maps = errorMaps.filter((m) => !!m).slice().reverse();
33804
+ for (const map2 of maps) {
33805
+ errorMessage = map2(fullIssue, { data, defaultError: errorMessage }).message;
33806
+ }
33807
+ return {
33808
+ ...issueData,
33809
+ path: fullPath,
33810
+ message: errorMessage
33811
+ };
33812
+ };
33813
+ var EMPTY_PATH = [];
33814
+ function addIssueToContext(ctx, issueData) {
33815
+ const overrideMap = getErrorMap2();
33816
+ const issue3 = makeIssue({
33817
+ issueData,
33818
+ data: ctx.data,
33819
+ path: ctx.path,
33820
+ errorMaps: [
33821
+ ctx.common.contextualErrorMap,
33822
+ ctx.schemaErrorMap,
33823
+ overrideMap,
33824
+ overrideMap === en_default3 ? undefined : en_default3
33825
+ ].filter((x) => !!x)
33826
+ });
33827
+ ctx.common.issues.push(issue3);
33828
+ }
33829
+
33830
+ class ParseStatus {
33831
+ constructor() {
33832
+ this.value = "valid";
33833
+ }
33834
+ dirty() {
33835
+ if (this.value === "valid")
33836
+ this.value = "dirty";
33837
+ }
33838
+ abort() {
33839
+ if (this.value !== "aborted")
33840
+ this.value = "aborted";
33841
+ }
33842
+ static mergeArray(status, results) {
33843
+ const arrayValue = [];
33844
+ for (const s of results) {
33845
+ if (s.status === "aborted")
33846
+ return INVALID;
33847
+ if (s.status === "dirty")
33848
+ status.dirty();
33849
+ arrayValue.push(s.value);
33850
+ }
33851
+ return { status: status.value, value: arrayValue };
33852
+ }
33853
+ static async mergeObjectAsync(status, pairs) {
33854
+ const syncPairs = [];
33855
+ for (const pair of pairs) {
33856
+ const key = await pair.key;
33857
+ const value = await pair.value;
33858
+ syncPairs.push({
33859
+ key,
33860
+ value
33861
+ });
33862
+ }
33863
+ return ParseStatus.mergeObjectSync(status, syncPairs);
33864
+ }
33865
+ static mergeObjectSync(status, pairs) {
33866
+ const finalObject = {};
33867
+ for (const pair of pairs) {
33868
+ const { key, value } = pair;
33869
+ if (key.status === "aborted")
33870
+ return INVALID;
33871
+ if (value.status === "aborted")
33872
+ return INVALID;
33873
+ if (key.status === "dirty")
33874
+ status.dirty();
33875
+ if (value.status === "dirty")
33876
+ status.dirty();
33877
+ if (key.value !== "__proto__" && (typeof value.value !== "undefined" || pair.alwaysSet)) {
33878
+ finalObject[key.value] = value.value;
33879
+ }
33880
+ }
33881
+ return { status: status.value, value: finalObject };
33882
+ }
33883
+ }
33884
+ var INVALID = Object.freeze({
33885
+ status: "aborted"
33886
+ });
33887
+ var DIRTY = (value) => ({ status: "dirty", value });
33888
+ var OK = (value) => ({ status: "valid", value });
33889
+ var isAborted = (x) => x.status === "aborted";
33890
+ var isDirty = (x) => x.status === "dirty";
33891
+ var isValid = (x) => x.status === "valid";
33892
+ var isAsync = (x) => typeof Promise !== "undefined" && x instanceof Promise;
33893
+ // node_modules/zod/v3/helpers/errorUtil.js
33894
+ var errorUtil;
33895
+ (function(errorUtil2) {
33896
+ errorUtil2.errToObj = (message) => typeof message === "string" ? { message } : message || {};
33897
+ errorUtil2.toString = (message) => typeof message === "string" ? message : message?.message;
33898
+ })(errorUtil || (errorUtil = {}));
33899
+
33900
+ // node_modules/zod/v3/types.js
33901
+ class ParseInputLazyPath {
33902
+ constructor(parent, value, path5, key) {
33903
+ this._cachedPath = [];
33904
+ this.parent = parent;
33905
+ this.data = value;
33906
+ this._path = path5;
33907
+ this._key = key;
33908
+ }
33909
+ get path() {
33910
+ if (!this._cachedPath.length) {
33911
+ if (Array.isArray(this._key)) {
33912
+ this._cachedPath.push(...this._path, ...this._key);
33913
+ } else {
33914
+ this._cachedPath.push(...this._path, this._key);
33915
+ }
33916
+ }
33917
+ return this._cachedPath;
33918
+ }
33919
+ }
33920
+ var handleResult = (ctx, result) => {
33921
+ if (isValid(result)) {
33922
+ return { success: true, data: result.value };
33923
+ } else {
33924
+ if (!ctx.common.issues.length) {
33925
+ throw new Error("Validation failed but no issues detected.");
33926
+ }
33927
+ return {
33928
+ success: false,
33929
+ get error() {
33930
+ if (this._error)
33931
+ return this._error;
33932
+ const error49 = new ZodError3(ctx.common.issues);
33933
+ this._error = error49;
33934
+ return this._error;
33935
+ }
33936
+ };
33937
+ }
33938
+ };
33939
+ function processCreateParams(params) {
33940
+ if (!params)
33941
+ return {};
33942
+ const { errorMap: errorMap2, invalid_type_error, required_error, description } = params;
33943
+ if (errorMap2 && (invalid_type_error || required_error)) {
33944
+ throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);
33945
+ }
33946
+ if (errorMap2)
33947
+ return { errorMap: errorMap2, description };
33948
+ const customMap = (iss, ctx) => {
33949
+ const { message } = params;
33950
+ if (iss.code === "invalid_enum_value") {
33951
+ return { message: message ?? ctx.defaultError };
33952
+ }
33953
+ if (typeof ctx.data === "undefined") {
33954
+ return { message: message ?? required_error ?? ctx.defaultError };
33955
+ }
33956
+ if (iss.code !== "invalid_type")
33957
+ return { message: ctx.defaultError };
33958
+ return { message: message ?? invalid_type_error ?? ctx.defaultError };
33959
+ };
33960
+ return { errorMap: customMap, description };
33961
+ }
33962
+
33963
+ class ZodType3 {
33964
+ get description() {
33965
+ return this._def.description;
33966
+ }
33967
+ _getType(input) {
33968
+ return getParsedType3(input.data);
33969
+ }
33970
+ _getOrReturnCtx(input, ctx) {
33971
+ return ctx || {
33972
+ common: input.parent.common,
33973
+ data: input.data,
33974
+ parsedType: getParsedType3(input.data),
33975
+ schemaErrorMap: this._def.errorMap,
33976
+ path: input.path,
33977
+ parent: input.parent
33978
+ };
33979
+ }
33980
+ _processInputParams(input) {
33981
+ return {
33982
+ status: new ParseStatus,
33983
+ ctx: {
33984
+ common: input.parent.common,
33985
+ data: input.data,
33986
+ parsedType: getParsedType3(input.data),
33987
+ schemaErrorMap: this._def.errorMap,
33988
+ path: input.path,
33989
+ parent: input.parent
33990
+ }
33991
+ };
33992
+ }
33993
+ _parseSync(input) {
33994
+ const result = this._parse(input);
33995
+ if (isAsync(result)) {
33996
+ throw new Error("Synchronous parse encountered promise.");
33997
+ }
33998
+ return result;
33999
+ }
34000
+ _parseAsync(input) {
34001
+ const result = this._parse(input);
34002
+ return Promise.resolve(result);
34003
+ }
34004
+ parse(data, params) {
34005
+ const result = this.safeParse(data, params);
34006
+ if (result.success)
34007
+ return result.data;
34008
+ throw result.error;
34009
+ }
34010
+ safeParse(data, params) {
34011
+ const ctx = {
34012
+ common: {
34013
+ issues: [],
34014
+ async: params?.async ?? false,
34015
+ contextualErrorMap: params?.errorMap
34016
+ },
34017
+ path: params?.path || [],
34018
+ schemaErrorMap: this._def.errorMap,
34019
+ parent: null,
34020
+ data,
34021
+ parsedType: getParsedType3(data)
34022
+ };
34023
+ const result = this._parseSync({ data, path: ctx.path, parent: ctx });
34024
+ return handleResult(ctx, result);
34025
+ }
34026
+ "~validate"(data) {
34027
+ const ctx = {
34028
+ common: {
34029
+ issues: [],
34030
+ async: !!this["~standard"].async
34031
+ },
34032
+ path: [],
34033
+ schemaErrorMap: this._def.errorMap,
34034
+ parent: null,
34035
+ data,
34036
+ parsedType: getParsedType3(data)
34037
+ };
34038
+ if (!this["~standard"].async) {
34039
+ try {
34040
+ const result = this._parseSync({ data, path: [], parent: ctx });
34041
+ return isValid(result) ? {
34042
+ value: result.value
34043
+ } : {
34044
+ issues: ctx.common.issues
34045
+ };
34046
+ } catch (err) {
34047
+ if (err?.message?.toLowerCase()?.includes("encountered")) {
34048
+ this["~standard"].async = true;
34049
+ }
34050
+ ctx.common = {
34051
+ issues: [],
34052
+ async: true
34053
+ };
34054
+ }
34055
+ }
34056
+ return this._parseAsync({ data, path: [], parent: ctx }).then((result) => isValid(result) ? {
34057
+ value: result.value
34058
+ } : {
34059
+ issues: ctx.common.issues
34060
+ });
34061
+ }
34062
+ async parseAsync(data, params) {
34063
+ const result = await this.safeParseAsync(data, params);
34064
+ if (result.success)
34065
+ return result.data;
34066
+ throw result.error;
34067
+ }
34068
+ async safeParseAsync(data, params) {
34069
+ const ctx = {
34070
+ common: {
34071
+ issues: [],
34072
+ contextualErrorMap: params?.errorMap,
34073
+ async: true
34074
+ },
34075
+ path: params?.path || [],
34076
+ schemaErrorMap: this._def.errorMap,
34077
+ parent: null,
34078
+ data,
34079
+ parsedType: getParsedType3(data)
34080
+ };
34081
+ const maybeAsyncResult = this._parse({ data, path: ctx.path, parent: ctx });
34082
+ const result = await (isAsync(maybeAsyncResult) ? maybeAsyncResult : Promise.resolve(maybeAsyncResult));
34083
+ return handleResult(ctx, result);
34084
+ }
34085
+ refine(check3, message) {
34086
+ const getIssueProperties = (val) => {
34087
+ if (typeof message === "string" || typeof message === "undefined") {
34088
+ return { message };
34089
+ } else if (typeof message === "function") {
34090
+ return message(val);
34091
+ } else {
34092
+ return message;
34093
+ }
34094
+ };
34095
+ return this._refinement((val, ctx) => {
34096
+ const result = check3(val);
34097
+ const setError = () => ctx.addIssue({
34098
+ code: ZodIssueCode3.custom,
34099
+ ...getIssueProperties(val)
34100
+ });
34101
+ if (typeof Promise !== "undefined" && result instanceof Promise) {
34102
+ return result.then((data) => {
34103
+ if (!data) {
34104
+ setError();
34105
+ return false;
34106
+ } else {
34107
+ return true;
34108
+ }
34109
+ });
34110
+ }
34111
+ if (!result) {
34112
+ setError();
34113
+ return false;
34114
+ } else {
34115
+ return true;
34116
+ }
34117
+ });
34118
+ }
34119
+ refinement(check3, refinementData) {
34120
+ return this._refinement((val, ctx) => {
34121
+ if (!check3(val)) {
34122
+ ctx.addIssue(typeof refinementData === "function" ? refinementData(val, ctx) : refinementData);
34123
+ return false;
34124
+ } else {
34125
+ return true;
34126
+ }
34127
+ });
34128
+ }
34129
+ _refinement(refinement) {
34130
+ return new ZodEffects({
34131
+ schema: this,
34132
+ typeName: ZodFirstPartyTypeKind2.ZodEffects,
34133
+ effect: { type: "refinement", refinement }
34134
+ });
34135
+ }
34136
+ superRefine(refinement) {
34137
+ return this._refinement(refinement);
34138
+ }
34139
+ constructor(def) {
34140
+ this.spa = this.safeParseAsync;
34141
+ this._def = def;
34142
+ this.parse = this.parse.bind(this);
34143
+ this.safeParse = this.safeParse.bind(this);
34144
+ this.parseAsync = this.parseAsync.bind(this);
34145
+ this.safeParseAsync = this.safeParseAsync.bind(this);
34146
+ this.spa = this.spa.bind(this);
34147
+ this.refine = this.refine.bind(this);
34148
+ this.refinement = this.refinement.bind(this);
34149
+ this.superRefine = this.superRefine.bind(this);
34150
+ this.optional = this.optional.bind(this);
34151
+ this.nullable = this.nullable.bind(this);
34152
+ this.nullish = this.nullish.bind(this);
34153
+ this.array = this.array.bind(this);
34154
+ this.promise = this.promise.bind(this);
34155
+ this.or = this.or.bind(this);
34156
+ this.and = this.and.bind(this);
34157
+ this.transform = this.transform.bind(this);
34158
+ this.brand = this.brand.bind(this);
34159
+ this.default = this.default.bind(this);
34160
+ this.catch = this.catch.bind(this);
34161
+ this.describe = this.describe.bind(this);
34162
+ this.pipe = this.pipe.bind(this);
34163
+ this.readonly = this.readonly.bind(this);
34164
+ this.isNullable = this.isNullable.bind(this);
34165
+ this.isOptional = this.isOptional.bind(this);
34166
+ this["~standard"] = {
34167
+ version: 1,
34168
+ vendor: "zod",
34169
+ validate: (data) => this["~validate"](data)
34170
+ };
34171
+ }
34172
+ optional() {
34173
+ return ZodOptional3.create(this, this._def);
34174
+ }
34175
+ nullable() {
34176
+ return ZodNullable3.create(this, this._def);
34177
+ }
34178
+ nullish() {
34179
+ return this.nullable().optional();
34180
+ }
34181
+ array() {
34182
+ return ZodArray3.create(this);
34183
+ }
34184
+ promise() {
34185
+ return ZodPromise2.create(this, this._def);
34186
+ }
34187
+ or(option) {
34188
+ return ZodUnion3.create([this, option], this._def);
34189
+ }
34190
+ and(incoming) {
34191
+ return ZodIntersection3.create(this, incoming, this._def);
34192
+ }
34193
+ transform(transform3) {
34194
+ return new ZodEffects({
34195
+ ...processCreateParams(this._def),
34196
+ schema: this,
34197
+ typeName: ZodFirstPartyTypeKind2.ZodEffects,
34198
+ effect: { type: "transform", transform: transform3 }
34199
+ });
34200
+ }
34201
+ default(def) {
34202
+ const defaultValueFunc = typeof def === "function" ? def : () => def;
34203
+ return new ZodDefault3({
34204
+ ...processCreateParams(this._def),
34205
+ innerType: this,
34206
+ defaultValue: defaultValueFunc,
34207
+ typeName: ZodFirstPartyTypeKind2.ZodDefault
34208
+ });
34209
+ }
34210
+ brand() {
34211
+ return new ZodBranded({
34212
+ typeName: ZodFirstPartyTypeKind2.ZodBranded,
34213
+ type: this,
34214
+ ...processCreateParams(this._def)
34215
+ });
34216
+ }
34217
+ catch(def) {
34218
+ const catchValueFunc = typeof def === "function" ? def : () => def;
34219
+ return new ZodCatch3({
34220
+ ...processCreateParams(this._def),
34221
+ innerType: this,
34222
+ catchValue: catchValueFunc,
34223
+ typeName: ZodFirstPartyTypeKind2.ZodCatch
34224
+ });
34225
+ }
34226
+ describe(description) {
34227
+ const This = this.constructor;
34228
+ return new This({
34229
+ ...this._def,
34230
+ description
34231
+ });
34232
+ }
34233
+ pipe(target) {
34234
+ return ZodPipeline.create(this, target);
34235
+ }
34236
+ readonly() {
34237
+ return ZodReadonly3.create(this);
34238
+ }
34239
+ isOptional() {
34240
+ return this.safeParse(undefined).success;
34241
+ }
34242
+ isNullable() {
34243
+ return this.safeParse(null).success;
34244
+ }
34245
+ }
34246
+ var cuidRegex = /^c[^\s-]{8,}$/i;
34247
+ var cuid2Regex = /^[0-9a-z]+$/;
34248
+ var ulidRegex = /^[0-9A-HJKMNP-TV-Z]{26}$/i;
34249
+ var uuidRegex = /^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i;
34250
+ var nanoidRegex = /^[a-z0-9_-]{21}$/i;
34251
+ var jwtRegex = /^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/;
34252
+ var durationRegex = /^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/;
34253
+ var emailRegex = /^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i;
34254
+ var _emojiRegex = `^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$`;
34255
+ var emojiRegex;
34256
+ var ipv4Regex = /^(?:(?: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])$/;
34257
+ var ipv4CidrRegex = /^(?:(?: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])\/(3[0-2]|[12]?[0-9])$/;
34258
+ var ipv6Regex = /^(([0-9a-fA-F]{1,4}:){7,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}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/;
34259
+ var ipv6CidrRegex = /^(([0-9a-fA-F]{1,4}:){7,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}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/;
34260
+ var base64Regex = /^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/;
34261
+ var base64urlRegex = /^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/;
34262
+ var dateRegexSource = `((\\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])))`;
34263
+ var dateRegex = new RegExp(`^${dateRegexSource}$`);
34264
+ function timeRegexSource(args) {
34265
+ let secondsRegexSource = `[0-5]\\d`;
34266
+ if (args.precision) {
34267
+ secondsRegexSource = `${secondsRegexSource}\\.\\d{${args.precision}}`;
34268
+ } else if (args.precision == null) {
34269
+ secondsRegexSource = `${secondsRegexSource}(\\.\\d+)?`;
34270
+ }
34271
+ const secondsQuantifier = args.precision ? "+" : "?";
34272
+ return `([01]\\d|2[0-3]):[0-5]\\d(:${secondsRegexSource})${secondsQuantifier}`;
34273
+ }
34274
+ function timeRegex(args) {
34275
+ return new RegExp(`^${timeRegexSource(args)}$`);
34276
+ }
34277
+ function datetimeRegex(args) {
34278
+ let regex = `${dateRegexSource}T${timeRegexSource(args)}`;
34279
+ const opts = [];
34280
+ opts.push(args.local ? `Z?` : `Z`);
34281
+ if (args.offset)
34282
+ opts.push(`([+-]\\d{2}:?\\d{2})`);
34283
+ regex = `${regex}(${opts.join("|")})`;
34284
+ return new RegExp(`^${regex}$`);
34285
+ }
34286
+ function isValidIP(ip, version3) {
34287
+ if ((version3 === "v4" || !version3) && ipv4Regex.test(ip)) {
34288
+ return true;
34289
+ }
34290
+ if ((version3 === "v6" || !version3) && ipv6Regex.test(ip)) {
34291
+ return true;
34292
+ }
34293
+ return false;
34294
+ }
34295
+ function isValidJWT3(jwt2, alg) {
34296
+ if (!jwtRegex.test(jwt2))
34297
+ return false;
34298
+ try {
34299
+ const [header] = jwt2.split(".");
34300
+ if (!header)
34301
+ return false;
34302
+ const base644 = header.replace(/-/g, "+").replace(/_/g, "/").padEnd(header.length + (4 - header.length % 4) % 4, "=");
34303
+ const decoded = JSON.parse(atob(base644));
34304
+ if (typeof decoded !== "object" || decoded === null)
34305
+ return false;
34306
+ if ("typ" in decoded && decoded?.typ !== "JWT")
34307
+ return false;
34308
+ if (!decoded.alg)
34309
+ return false;
34310
+ if (alg && decoded.alg !== alg)
34311
+ return false;
34312
+ return true;
34313
+ } catch {
34314
+ return false;
34315
+ }
34316
+ }
34317
+ function isValidCidr(ip, version3) {
34318
+ if ((version3 === "v4" || !version3) && ipv4CidrRegex.test(ip)) {
34319
+ return true;
34320
+ }
34321
+ if ((version3 === "v6" || !version3) && ipv6CidrRegex.test(ip)) {
34322
+ return true;
34323
+ }
34324
+ return false;
34325
+ }
34326
+
34327
+ class ZodString3 extends ZodType3 {
34328
+ _parse(input) {
34329
+ if (this._def.coerce) {
34330
+ input.data = String(input.data);
34331
+ }
34332
+ const parsedType3 = this._getType(input);
34333
+ if (parsedType3 !== ZodParsedType.string) {
34334
+ const ctx2 = this._getOrReturnCtx(input);
34335
+ addIssueToContext(ctx2, {
34336
+ code: ZodIssueCode3.invalid_type,
34337
+ expected: ZodParsedType.string,
34338
+ received: ctx2.parsedType
34339
+ });
34340
+ return INVALID;
34341
+ }
34342
+ const status = new ParseStatus;
34343
+ let ctx = undefined;
34344
+ for (const check3 of this._def.checks) {
34345
+ if (check3.kind === "min") {
34346
+ if (input.data.length < check3.value) {
34347
+ ctx = this._getOrReturnCtx(input, ctx);
34348
+ addIssueToContext(ctx, {
34349
+ code: ZodIssueCode3.too_small,
34350
+ minimum: check3.value,
34351
+ type: "string",
34352
+ inclusive: true,
34353
+ exact: false,
34354
+ message: check3.message
34355
+ });
34356
+ status.dirty();
34357
+ }
34358
+ } else if (check3.kind === "max") {
34359
+ if (input.data.length > check3.value) {
34360
+ ctx = this._getOrReturnCtx(input, ctx);
34361
+ addIssueToContext(ctx, {
34362
+ code: ZodIssueCode3.too_big,
34363
+ maximum: check3.value,
34364
+ type: "string",
34365
+ inclusive: true,
34366
+ exact: false,
34367
+ message: check3.message
34368
+ });
34369
+ status.dirty();
34370
+ }
34371
+ } else if (check3.kind === "length") {
34372
+ const tooBig = input.data.length > check3.value;
34373
+ const tooSmall = input.data.length < check3.value;
34374
+ if (tooBig || tooSmall) {
34375
+ ctx = this._getOrReturnCtx(input, ctx);
34376
+ if (tooBig) {
34377
+ addIssueToContext(ctx, {
34378
+ code: ZodIssueCode3.too_big,
34379
+ maximum: check3.value,
34380
+ type: "string",
34381
+ inclusive: true,
34382
+ exact: true,
34383
+ message: check3.message
34384
+ });
34385
+ } else if (tooSmall) {
34386
+ addIssueToContext(ctx, {
34387
+ code: ZodIssueCode3.too_small,
34388
+ minimum: check3.value,
34389
+ type: "string",
34390
+ inclusive: true,
34391
+ exact: true,
34392
+ message: check3.message
34393
+ });
34394
+ }
34395
+ status.dirty();
34396
+ }
34397
+ } else if (check3.kind === "email") {
34398
+ if (!emailRegex.test(input.data)) {
34399
+ ctx = this._getOrReturnCtx(input, ctx);
34400
+ addIssueToContext(ctx, {
34401
+ validation: "email",
34402
+ code: ZodIssueCode3.invalid_string,
34403
+ message: check3.message
34404
+ });
34405
+ status.dirty();
34406
+ }
34407
+ } else if (check3.kind === "emoji") {
34408
+ if (!emojiRegex) {
34409
+ emojiRegex = new RegExp(_emojiRegex, "u");
34410
+ }
34411
+ if (!emojiRegex.test(input.data)) {
34412
+ ctx = this._getOrReturnCtx(input, ctx);
34413
+ addIssueToContext(ctx, {
34414
+ validation: "emoji",
34415
+ code: ZodIssueCode3.invalid_string,
34416
+ message: check3.message
34417
+ });
34418
+ status.dirty();
34419
+ }
34420
+ } else if (check3.kind === "uuid") {
34421
+ if (!uuidRegex.test(input.data)) {
34422
+ ctx = this._getOrReturnCtx(input, ctx);
34423
+ addIssueToContext(ctx, {
34424
+ validation: "uuid",
34425
+ code: ZodIssueCode3.invalid_string,
34426
+ message: check3.message
34427
+ });
34428
+ status.dirty();
34429
+ }
34430
+ } else if (check3.kind === "nanoid") {
34431
+ if (!nanoidRegex.test(input.data)) {
34432
+ ctx = this._getOrReturnCtx(input, ctx);
34433
+ addIssueToContext(ctx, {
34434
+ validation: "nanoid",
34435
+ code: ZodIssueCode3.invalid_string,
34436
+ message: check3.message
34437
+ });
34438
+ status.dirty();
34439
+ }
34440
+ } else if (check3.kind === "cuid") {
34441
+ if (!cuidRegex.test(input.data)) {
34442
+ ctx = this._getOrReturnCtx(input, ctx);
34443
+ addIssueToContext(ctx, {
34444
+ validation: "cuid",
34445
+ code: ZodIssueCode3.invalid_string,
34446
+ message: check3.message
34447
+ });
34448
+ status.dirty();
34449
+ }
34450
+ } else if (check3.kind === "cuid2") {
34451
+ if (!cuid2Regex.test(input.data)) {
34452
+ ctx = this._getOrReturnCtx(input, ctx);
34453
+ addIssueToContext(ctx, {
34454
+ validation: "cuid2",
34455
+ code: ZodIssueCode3.invalid_string,
34456
+ message: check3.message
34457
+ });
34458
+ status.dirty();
34459
+ }
34460
+ } else if (check3.kind === "ulid") {
34461
+ if (!ulidRegex.test(input.data)) {
34462
+ ctx = this._getOrReturnCtx(input, ctx);
34463
+ addIssueToContext(ctx, {
34464
+ validation: "ulid",
34465
+ code: ZodIssueCode3.invalid_string,
34466
+ message: check3.message
34467
+ });
34468
+ status.dirty();
34469
+ }
34470
+ } else if (check3.kind === "url") {
34471
+ try {
34472
+ new URL(input.data);
34473
+ } catch {
34474
+ ctx = this._getOrReturnCtx(input, ctx);
34475
+ addIssueToContext(ctx, {
34476
+ validation: "url",
34477
+ code: ZodIssueCode3.invalid_string,
34478
+ message: check3.message
34479
+ });
34480
+ status.dirty();
34481
+ }
34482
+ } else if (check3.kind === "regex") {
34483
+ check3.regex.lastIndex = 0;
34484
+ const testResult = check3.regex.test(input.data);
34485
+ if (!testResult) {
34486
+ ctx = this._getOrReturnCtx(input, ctx);
34487
+ addIssueToContext(ctx, {
34488
+ validation: "regex",
34489
+ code: ZodIssueCode3.invalid_string,
34490
+ message: check3.message
34491
+ });
34492
+ status.dirty();
34493
+ }
34494
+ } else if (check3.kind === "trim") {
34495
+ input.data = input.data.trim();
34496
+ } else if (check3.kind === "includes") {
34497
+ if (!input.data.includes(check3.value, check3.position)) {
34498
+ ctx = this._getOrReturnCtx(input, ctx);
34499
+ addIssueToContext(ctx, {
34500
+ code: ZodIssueCode3.invalid_string,
34501
+ validation: { includes: check3.value, position: check3.position },
34502
+ message: check3.message
34503
+ });
34504
+ status.dirty();
34505
+ }
34506
+ } else if (check3.kind === "toLowerCase") {
34507
+ input.data = input.data.toLowerCase();
34508
+ } else if (check3.kind === "toUpperCase") {
34509
+ input.data = input.data.toUpperCase();
34510
+ } else if (check3.kind === "startsWith") {
34511
+ if (!input.data.startsWith(check3.value)) {
34512
+ ctx = this._getOrReturnCtx(input, ctx);
34513
+ addIssueToContext(ctx, {
34514
+ code: ZodIssueCode3.invalid_string,
34515
+ validation: { startsWith: check3.value },
34516
+ message: check3.message
34517
+ });
34518
+ status.dirty();
34519
+ }
34520
+ } else if (check3.kind === "endsWith") {
34521
+ if (!input.data.endsWith(check3.value)) {
34522
+ ctx = this._getOrReturnCtx(input, ctx);
34523
+ addIssueToContext(ctx, {
34524
+ code: ZodIssueCode3.invalid_string,
34525
+ validation: { endsWith: check3.value },
34526
+ message: check3.message
34527
+ });
34528
+ status.dirty();
34529
+ }
34530
+ } else if (check3.kind === "datetime") {
34531
+ const regex = datetimeRegex(check3);
34532
+ if (!regex.test(input.data)) {
34533
+ ctx = this._getOrReturnCtx(input, ctx);
34534
+ addIssueToContext(ctx, {
34535
+ code: ZodIssueCode3.invalid_string,
34536
+ validation: "datetime",
34537
+ message: check3.message
34538
+ });
34539
+ status.dirty();
34540
+ }
34541
+ } else if (check3.kind === "date") {
34542
+ const regex = dateRegex;
34543
+ if (!regex.test(input.data)) {
34544
+ ctx = this._getOrReturnCtx(input, ctx);
34545
+ addIssueToContext(ctx, {
34546
+ code: ZodIssueCode3.invalid_string,
34547
+ validation: "date",
34548
+ message: check3.message
34549
+ });
34550
+ status.dirty();
34551
+ }
34552
+ } else if (check3.kind === "time") {
34553
+ const regex = timeRegex(check3);
34554
+ if (!regex.test(input.data)) {
34555
+ ctx = this._getOrReturnCtx(input, ctx);
34556
+ addIssueToContext(ctx, {
34557
+ code: ZodIssueCode3.invalid_string,
34558
+ validation: "time",
34559
+ message: check3.message
34560
+ });
34561
+ status.dirty();
34562
+ }
34563
+ } else if (check3.kind === "duration") {
34564
+ if (!durationRegex.test(input.data)) {
34565
+ ctx = this._getOrReturnCtx(input, ctx);
34566
+ addIssueToContext(ctx, {
34567
+ validation: "duration",
34568
+ code: ZodIssueCode3.invalid_string,
34569
+ message: check3.message
34570
+ });
34571
+ status.dirty();
34572
+ }
34573
+ } else if (check3.kind === "ip") {
34574
+ if (!isValidIP(input.data, check3.version)) {
34575
+ ctx = this._getOrReturnCtx(input, ctx);
34576
+ addIssueToContext(ctx, {
34577
+ validation: "ip",
34578
+ code: ZodIssueCode3.invalid_string,
34579
+ message: check3.message
34580
+ });
34581
+ status.dirty();
34582
+ }
34583
+ } else if (check3.kind === "jwt") {
34584
+ if (!isValidJWT3(input.data, check3.alg)) {
34585
+ ctx = this._getOrReturnCtx(input, ctx);
34586
+ addIssueToContext(ctx, {
34587
+ validation: "jwt",
34588
+ code: ZodIssueCode3.invalid_string,
34589
+ message: check3.message
34590
+ });
34591
+ status.dirty();
34592
+ }
34593
+ } else if (check3.kind === "cidr") {
34594
+ if (!isValidCidr(input.data, check3.version)) {
34595
+ ctx = this._getOrReturnCtx(input, ctx);
34596
+ addIssueToContext(ctx, {
34597
+ validation: "cidr",
34598
+ code: ZodIssueCode3.invalid_string,
34599
+ message: check3.message
34600
+ });
34601
+ status.dirty();
34602
+ }
34603
+ } else if (check3.kind === "base64") {
34604
+ if (!base64Regex.test(input.data)) {
34605
+ ctx = this._getOrReturnCtx(input, ctx);
34606
+ addIssueToContext(ctx, {
34607
+ validation: "base64",
34608
+ code: ZodIssueCode3.invalid_string,
34609
+ message: check3.message
34610
+ });
34611
+ status.dirty();
34612
+ }
34613
+ } else if (check3.kind === "base64url") {
34614
+ if (!base64urlRegex.test(input.data)) {
34615
+ ctx = this._getOrReturnCtx(input, ctx);
34616
+ addIssueToContext(ctx, {
34617
+ validation: "base64url",
34618
+ code: ZodIssueCode3.invalid_string,
34619
+ message: check3.message
34620
+ });
34621
+ status.dirty();
34622
+ }
34623
+ } else {
34624
+ util.assertNever(check3);
34625
+ }
34626
+ }
34627
+ return { status: status.value, value: input.data };
34628
+ }
34629
+ _regex(regex, validation, message) {
34630
+ return this.refinement((data) => regex.test(data), {
34631
+ validation,
34632
+ code: ZodIssueCode3.invalid_string,
34633
+ ...errorUtil.errToObj(message)
34634
+ });
34635
+ }
34636
+ _addCheck(check3) {
34637
+ return new ZodString3({
34638
+ ...this._def,
34639
+ checks: [...this._def.checks, check3]
34640
+ });
34641
+ }
34642
+ email(message) {
34643
+ return this._addCheck({ kind: "email", ...errorUtil.errToObj(message) });
34644
+ }
34645
+ url(message) {
34646
+ return this._addCheck({ kind: "url", ...errorUtil.errToObj(message) });
34647
+ }
34648
+ emoji(message) {
34649
+ return this._addCheck({ kind: "emoji", ...errorUtil.errToObj(message) });
34650
+ }
34651
+ uuid(message) {
34652
+ return this._addCheck({ kind: "uuid", ...errorUtil.errToObj(message) });
34653
+ }
34654
+ nanoid(message) {
34655
+ return this._addCheck({ kind: "nanoid", ...errorUtil.errToObj(message) });
34656
+ }
34657
+ cuid(message) {
34658
+ return this._addCheck({ kind: "cuid", ...errorUtil.errToObj(message) });
34659
+ }
34660
+ cuid2(message) {
34661
+ return this._addCheck({ kind: "cuid2", ...errorUtil.errToObj(message) });
34662
+ }
34663
+ ulid(message) {
34664
+ return this._addCheck({ kind: "ulid", ...errorUtil.errToObj(message) });
34665
+ }
34666
+ base64(message) {
34667
+ return this._addCheck({ kind: "base64", ...errorUtil.errToObj(message) });
34668
+ }
34669
+ base64url(message) {
34670
+ return this._addCheck({
34671
+ kind: "base64url",
34672
+ ...errorUtil.errToObj(message)
34673
+ });
34674
+ }
34675
+ jwt(options) {
34676
+ return this._addCheck({ kind: "jwt", ...errorUtil.errToObj(options) });
34677
+ }
34678
+ ip(options) {
34679
+ return this._addCheck({ kind: "ip", ...errorUtil.errToObj(options) });
34680
+ }
34681
+ cidr(options) {
34682
+ return this._addCheck({ kind: "cidr", ...errorUtil.errToObj(options) });
34683
+ }
34684
+ datetime(options) {
34685
+ if (typeof options === "string") {
34686
+ return this._addCheck({
34687
+ kind: "datetime",
34688
+ precision: null,
34689
+ offset: false,
34690
+ local: false,
34691
+ message: options
34692
+ });
34693
+ }
34694
+ return this._addCheck({
34695
+ kind: "datetime",
34696
+ precision: typeof options?.precision === "undefined" ? null : options?.precision,
34697
+ offset: options?.offset ?? false,
34698
+ local: options?.local ?? false,
34699
+ ...errorUtil.errToObj(options?.message)
34700
+ });
34701
+ }
34702
+ date(message) {
34703
+ return this._addCheck({ kind: "date", message });
34704
+ }
34705
+ time(options) {
34706
+ if (typeof options === "string") {
34707
+ return this._addCheck({
34708
+ kind: "time",
34709
+ precision: null,
34710
+ message: options
34711
+ });
34712
+ }
34713
+ return this._addCheck({
34714
+ kind: "time",
34715
+ precision: typeof options?.precision === "undefined" ? null : options?.precision,
34716
+ ...errorUtil.errToObj(options?.message)
34717
+ });
34718
+ }
34719
+ duration(message) {
34720
+ return this._addCheck({ kind: "duration", ...errorUtil.errToObj(message) });
34721
+ }
34722
+ regex(regex, message) {
34723
+ return this._addCheck({
34724
+ kind: "regex",
34725
+ regex,
34726
+ ...errorUtil.errToObj(message)
34727
+ });
34728
+ }
34729
+ includes(value, options) {
34730
+ return this._addCheck({
34731
+ kind: "includes",
34732
+ value,
34733
+ position: options?.position,
34734
+ ...errorUtil.errToObj(options?.message)
34735
+ });
34736
+ }
34737
+ startsWith(value, message) {
34738
+ return this._addCheck({
34739
+ kind: "startsWith",
34740
+ value,
34741
+ ...errorUtil.errToObj(message)
34742
+ });
34743
+ }
34744
+ endsWith(value, message) {
34745
+ return this._addCheck({
34746
+ kind: "endsWith",
34747
+ value,
34748
+ ...errorUtil.errToObj(message)
34749
+ });
34750
+ }
34751
+ min(minLength, message) {
34752
+ return this._addCheck({
34753
+ kind: "min",
34754
+ value: minLength,
34755
+ ...errorUtil.errToObj(message)
34756
+ });
34757
+ }
34758
+ max(maxLength, message) {
34759
+ return this._addCheck({
34760
+ kind: "max",
34761
+ value: maxLength,
34762
+ ...errorUtil.errToObj(message)
34763
+ });
34764
+ }
34765
+ length(len, message) {
34766
+ return this._addCheck({
34767
+ kind: "length",
34768
+ value: len,
34769
+ ...errorUtil.errToObj(message)
34770
+ });
34771
+ }
34772
+ nonempty(message) {
34773
+ return this.min(1, errorUtil.errToObj(message));
34774
+ }
34775
+ trim() {
34776
+ return new ZodString3({
34777
+ ...this._def,
34778
+ checks: [...this._def.checks, { kind: "trim" }]
34779
+ });
34780
+ }
34781
+ toLowerCase() {
34782
+ return new ZodString3({
34783
+ ...this._def,
34784
+ checks: [...this._def.checks, { kind: "toLowerCase" }]
34785
+ });
34786
+ }
34787
+ toUpperCase() {
34788
+ return new ZodString3({
34789
+ ...this._def,
34790
+ checks: [...this._def.checks, { kind: "toUpperCase" }]
34791
+ });
34792
+ }
34793
+ get isDatetime() {
34794
+ return !!this._def.checks.find((ch) => ch.kind === "datetime");
34795
+ }
34796
+ get isDate() {
34797
+ return !!this._def.checks.find((ch) => ch.kind === "date");
34798
+ }
34799
+ get isTime() {
34800
+ return !!this._def.checks.find((ch) => ch.kind === "time");
34801
+ }
34802
+ get isDuration() {
34803
+ return !!this._def.checks.find((ch) => ch.kind === "duration");
34804
+ }
34805
+ get isEmail() {
34806
+ return !!this._def.checks.find((ch) => ch.kind === "email");
34807
+ }
34808
+ get isURL() {
34809
+ return !!this._def.checks.find((ch) => ch.kind === "url");
34810
+ }
34811
+ get isEmoji() {
34812
+ return !!this._def.checks.find((ch) => ch.kind === "emoji");
34813
+ }
34814
+ get isUUID() {
34815
+ return !!this._def.checks.find((ch) => ch.kind === "uuid");
34816
+ }
34817
+ get isNANOID() {
34818
+ return !!this._def.checks.find((ch) => ch.kind === "nanoid");
34819
+ }
34820
+ get isCUID() {
34821
+ return !!this._def.checks.find((ch) => ch.kind === "cuid");
34822
+ }
34823
+ get isCUID2() {
34824
+ return !!this._def.checks.find((ch) => ch.kind === "cuid2");
34825
+ }
34826
+ get isULID() {
34827
+ return !!this._def.checks.find((ch) => ch.kind === "ulid");
34828
+ }
34829
+ get isIP() {
34830
+ return !!this._def.checks.find((ch) => ch.kind === "ip");
34831
+ }
34832
+ get isCIDR() {
34833
+ return !!this._def.checks.find((ch) => ch.kind === "cidr");
34834
+ }
34835
+ get isBase64() {
34836
+ return !!this._def.checks.find((ch) => ch.kind === "base64");
34837
+ }
34838
+ get isBase64url() {
34839
+ return !!this._def.checks.find((ch) => ch.kind === "base64url");
34840
+ }
34841
+ get minLength() {
34842
+ let min = null;
34843
+ for (const ch of this._def.checks) {
34844
+ if (ch.kind === "min") {
34845
+ if (min === null || ch.value > min)
34846
+ min = ch.value;
34847
+ }
34848
+ }
34849
+ return min;
34850
+ }
34851
+ get maxLength() {
34852
+ let max = null;
34853
+ for (const ch of this._def.checks) {
34854
+ if (ch.kind === "max") {
34855
+ if (max === null || ch.value < max)
34856
+ max = ch.value;
34857
+ }
34858
+ }
34859
+ return max;
34860
+ }
34861
+ }
34862
+ ZodString3.create = (params) => {
34863
+ return new ZodString3({
34864
+ checks: [],
34865
+ typeName: ZodFirstPartyTypeKind2.ZodString,
34866
+ coerce: params?.coerce ?? false,
34867
+ ...processCreateParams(params)
34868
+ });
34869
+ };
34870
+ function floatSafeRemainder3(val, step) {
34871
+ const valDecCount = (val.toString().split(".")[1] || "").length;
34872
+ const stepDecCount = (step.toString().split(".")[1] || "").length;
34873
+ const decCount = valDecCount > stepDecCount ? valDecCount : stepDecCount;
34874
+ const valInt = Number.parseInt(val.toFixed(decCount).replace(".", ""));
34875
+ const stepInt = Number.parseInt(step.toFixed(decCount).replace(".", ""));
34876
+ return valInt % stepInt / 10 ** decCount;
34877
+ }
34878
+
34879
+ class ZodNumber3 extends ZodType3 {
34880
+ constructor() {
34881
+ super(...arguments);
34882
+ this.min = this.gte;
34883
+ this.max = this.lte;
34884
+ this.step = this.multipleOf;
34885
+ }
34886
+ _parse(input) {
34887
+ if (this._def.coerce) {
34888
+ input.data = Number(input.data);
34889
+ }
34890
+ const parsedType3 = this._getType(input);
34891
+ if (parsedType3 !== ZodParsedType.number) {
34892
+ const ctx2 = this._getOrReturnCtx(input);
34893
+ addIssueToContext(ctx2, {
34894
+ code: ZodIssueCode3.invalid_type,
34895
+ expected: ZodParsedType.number,
34896
+ received: ctx2.parsedType
34897
+ });
34898
+ return INVALID;
34899
+ }
34900
+ let ctx = undefined;
34901
+ const status = new ParseStatus;
34902
+ for (const check3 of this._def.checks) {
34903
+ if (check3.kind === "int") {
34904
+ if (!util.isInteger(input.data)) {
34905
+ ctx = this._getOrReturnCtx(input, ctx);
34906
+ addIssueToContext(ctx, {
34907
+ code: ZodIssueCode3.invalid_type,
34908
+ expected: "integer",
34909
+ received: "float",
34910
+ message: check3.message
34911
+ });
34912
+ status.dirty();
34913
+ }
34914
+ } else if (check3.kind === "min") {
34915
+ const tooSmall = check3.inclusive ? input.data < check3.value : input.data <= check3.value;
34916
+ if (tooSmall) {
34917
+ ctx = this._getOrReturnCtx(input, ctx);
34918
+ addIssueToContext(ctx, {
34919
+ code: ZodIssueCode3.too_small,
34920
+ minimum: check3.value,
34921
+ type: "number",
34922
+ inclusive: check3.inclusive,
34923
+ exact: false,
34924
+ message: check3.message
34925
+ });
34926
+ status.dirty();
34927
+ }
34928
+ } else if (check3.kind === "max") {
34929
+ const tooBig = check3.inclusive ? input.data > check3.value : input.data >= check3.value;
34930
+ if (tooBig) {
34931
+ ctx = this._getOrReturnCtx(input, ctx);
34932
+ addIssueToContext(ctx, {
34933
+ code: ZodIssueCode3.too_big,
34934
+ maximum: check3.value,
34935
+ type: "number",
34936
+ inclusive: check3.inclusive,
34937
+ exact: false,
34938
+ message: check3.message
34939
+ });
34940
+ status.dirty();
34941
+ }
34942
+ } else if (check3.kind === "multipleOf") {
34943
+ if (floatSafeRemainder3(input.data, check3.value) !== 0) {
34944
+ ctx = this._getOrReturnCtx(input, ctx);
34945
+ addIssueToContext(ctx, {
34946
+ code: ZodIssueCode3.not_multiple_of,
34947
+ multipleOf: check3.value,
34948
+ message: check3.message
34949
+ });
34950
+ status.dirty();
34951
+ }
34952
+ } else if (check3.kind === "finite") {
34953
+ if (!Number.isFinite(input.data)) {
34954
+ ctx = this._getOrReturnCtx(input, ctx);
34955
+ addIssueToContext(ctx, {
34956
+ code: ZodIssueCode3.not_finite,
34957
+ message: check3.message
34958
+ });
34959
+ status.dirty();
34960
+ }
34961
+ } else {
34962
+ util.assertNever(check3);
34963
+ }
34964
+ }
34965
+ return { status: status.value, value: input.data };
34966
+ }
34967
+ gte(value, message) {
34968
+ return this.setLimit("min", value, true, errorUtil.toString(message));
34969
+ }
34970
+ gt(value, message) {
34971
+ return this.setLimit("min", value, false, errorUtil.toString(message));
34972
+ }
34973
+ lte(value, message) {
34974
+ return this.setLimit("max", value, true, errorUtil.toString(message));
34975
+ }
34976
+ lt(value, message) {
34977
+ return this.setLimit("max", value, false, errorUtil.toString(message));
34978
+ }
34979
+ setLimit(kind, value, inclusive, message) {
34980
+ return new ZodNumber3({
34981
+ ...this._def,
34982
+ checks: [
34983
+ ...this._def.checks,
34984
+ {
34985
+ kind,
34986
+ value,
34987
+ inclusive,
34988
+ message: errorUtil.toString(message)
34989
+ }
34990
+ ]
34991
+ });
34992
+ }
34993
+ _addCheck(check3) {
34994
+ return new ZodNumber3({
34995
+ ...this._def,
34996
+ checks: [...this._def.checks, check3]
34997
+ });
34998
+ }
34999
+ int(message) {
35000
+ return this._addCheck({
35001
+ kind: "int",
35002
+ message: errorUtil.toString(message)
35003
+ });
35004
+ }
35005
+ positive(message) {
35006
+ return this._addCheck({
35007
+ kind: "min",
35008
+ value: 0,
35009
+ inclusive: false,
35010
+ message: errorUtil.toString(message)
35011
+ });
35012
+ }
35013
+ negative(message) {
35014
+ return this._addCheck({
35015
+ kind: "max",
35016
+ value: 0,
35017
+ inclusive: false,
35018
+ message: errorUtil.toString(message)
35019
+ });
35020
+ }
35021
+ nonpositive(message) {
35022
+ return this._addCheck({
35023
+ kind: "max",
35024
+ value: 0,
35025
+ inclusive: true,
35026
+ message: errorUtil.toString(message)
35027
+ });
35028
+ }
35029
+ nonnegative(message) {
35030
+ return this._addCheck({
35031
+ kind: "min",
35032
+ value: 0,
35033
+ inclusive: true,
35034
+ message: errorUtil.toString(message)
35035
+ });
35036
+ }
35037
+ multipleOf(value, message) {
35038
+ return this._addCheck({
35039
+ kind: "multipleOf",
35040
+ value,
35041
+ message: errorUtil.toString(message)
35042
+ });
35043
+ }
35044
+ finite(message) {
35045
+ return this._addCheck({
35046
+ kind: "finite",
35047
+ message: errorUtil.toString(message)
35048
+ });
35049
+ }
35050
+ safe(message) {
35051
+ return this._addCheck({
35052
+ kind: "min",
35053
+ inclusive: true,
35054
+ value: Number.MIN_SAFE_INTEGER,
35055
+ message: errorUtil.toString(message)
35056
+ })._addCheck({
35057
+ kind: "max",
35058
+ inclusive: true,
35059
+ value: Number.MAX_SAFE_INTEGER,
35060
+ message: errorUtil.toString(message)
35061
+ });
35062
+ }
35063
+ get minValue() {
35064
+ let min = null;
35065
+ for (const ch of this._def.checks) {
35066
+ if (ch.kind === "min") {
35067
+ if (min === null || ch.value > min)
35068
+ min = ch.value;
35069
+ }
35070
+ }
35071
+ return min;
35072
+ }
35073
+ get maxValue() {
35074
+ let max = null;
35075
+ for (const ch of this._def.checks) {
35076
+ if (ch.kind === "max") {
35077
+ if (max === null || ch.value < max)
35078
+ max = ch.value;
35079
+ }
35080
+ }
35081
+ return max;
35082
+ }
35083
+ get isInt() {
35084
+ return !!this._def.checks.find((ch) => ch.kind === "int" || ch.kind === "multipleOf" && util.isInteger(ch.value));
35085
+ }
35086
+ get isFinite() {
35087
+ let max = null;
35088
+ let min = null;
35089
+ for (const ch of this._def.checks) {
35090
+ if (ch.kind === "finite" || ch.kind === "int" || ch.kind === "multipleOf") {
35091
+ return true;
35092
+ } else if (ch.kind === "min") {
35093
+ if (min === null || ch.value > min)
35094
+ min = ch.value;
35095
+ } else if (ch.kind === "max") {
35096
+ if (max === null || ch.value < max)
35097
+ max = ch.value;
35098
+ }
35099
+ }
35100
+ return Number.isFinite(min) && Number.isFinite(max);
35101
+ }
35102
+ }
35103
+ ZodNumber3.create = (params) => {
35104
+ return new ZodNumber3({
35105
+ checks: [],
35106
+ typeName: ZodFirstPartyTypeKind2.ZodNumber,
35107
+ coerce: params?.coerce || false,
35108
+ ...processCreateParams(params)
35109
+ });
35110
+ };
35111
+
35112
+ class ZodBigInt3 extends ZodType3 {
35113
+ constructor() {
35114
+ super(...arguments);
35115
+ this.min = this.gte;
35116
+ this.max = this.lte;
35117
+ }
35118
+ _parse(input) {
35119
+ if (this._def.coerce) {
35120
+ try {
35121
+ input.data = BigInt(input.data);
35122
+ } catch {
35123
+ return this._getInvalidInput(input);
35124
+ }
35125
+ }
35126
+ const parsedType3 = this._getType(input);
35127
+ if (parsedType3 !== ZodParsedType.bigint) {
35128
+ return this._getInvalidInput(input);
35129
+ }
35130
+ let ctx = undefined;
35131
+ const status = new ParseStatus;
35132
+ for (const check3 of this._def.checks) {
35133
+ if (check3.kind === "min") {
35134
+ const tooSmall = check3.inclusive ? input.data < check3.value : input.data <= check3.value;
35135
+ if (tooSmall) {
35136
+ ctx = this._getOrReturnCtx(input, ctx);
35137
+ addIssueToContext(ctx, {
35138
+ code: ZodIssueCode3.too_small,
35139
+ type: "bigint",
35140
+ minimum: check3.value,
35141
+ inclusive: check3.inclusive,
35142
+ message: check3.message
35143
+ });
35144
+ status.dirty();
35145
+ }
35146
+ } else if (check3.kind === "max") {
35147
+ const tooBig = check3.inclusive ? input.data > check3.value : input.data >= check3.value;
35148
+ if (tooBig) {
35149
+ ctx = this._getOrReturnCtx(input, ctx);
35150
+ addIssueToContext(ctx, {
35151
+ code: ZodIssueCode3.too_big,
35152
+ type: "bigint",
35153
+ maximum: check3.value,
35154
+ inclusive: check3.inclusive,
35155
+ message: check3.message
35156
+ });
35157
+ status.dirty();
35158
+ }
35159
+ } else if (check3.kind === "multipleOf") {
35160
+ if (input.data % check3.value !== BigInt(0)) {
35161
+ ctx = this._getOrReturnCtx(input, ctx);
35162
+ addIssueToContext(ctx, {
35163
+ code: ZodIssueCode3.not_multiple_of,
35164
+ multipleOf: check3.value,
35165
+ message: check3.message
35166
+ });
35167
+ status.dirty();
35168
+ }
35169
+ } else {
35170
+ util.assertNever(check3);
35171
+ }
35172
+ }
35173
+ return { status: status.value, value: input.data };
35174
+ }
35175
+ _getInvalidInput(input) {
35176
+ const ctx = this._getOrReturnCtx(input);
35177
+ addIssueToContext(ctx, {
35178
+ code: ZodIssueCode3.invalid_type,
35179
+ expected: ZodParsedType.bigint,
35180
+ received: ctx.parsedType
35181
+ });
35182
+ return INVALID;
35183
+ }
35184
+ gte(value, message) {
35185
+ return this.setLimit("min", value, true, errorUtil.toString(message));
35186
+ }
35187
+ gt(value, message) {
35188
+ return this.setLimit("min", value, false, errorUtil.toString(message));
35189
+ }
35190
+ lte(value, message) {
35191
+ return this.setLimit("max", value, true, errorUtil.toString(message));
35192
+ }
35193
+ lt(value, message) {
35194
+ return this.setLimit("max", value, false, errorUtil.toString(message));
35195
+ }
35196
+ setLimit(kind, value, inclusive, message) {
35197
+ return new ZodBigInt3({
35198
+ ...this._def,
35199
+ checks: [
35200
+ ...this._def.checks,
35201
+ {
35202
+ kind,
35203
+ value,
35204
+ inclusive,
35205
+ message: errorUtil.toString(message)
35206
+ }
35207
+ ]
35208
+ });
35209
+ }
35210
+ _addCheck(check3) {
35211
+ return new ZodBigInt3({
35212
+ ...this._def,
35213
+ checks: [...this._def.checks, check3]
35214
+ });
35215
+ }
35216
+ positive(message) {
35217
+ return this._addCheck({
35218
+ kind: "min",
35219
+ value: BigInt(0),
35220
+ inclusive: false,
35221
+ message: errorUtil.toString(message)
35222
+ });
35223
+ }
35224
+ negative(message) {
35225
+ return this._addCheck({
35226
+ kind: "max",
35227
+ value: BigInt(0),
35228
+ inclusive: false,
35229
+ message: errorUtil.toString(message)
35230
+ });
35231
+ }
35232
+ nonpositive(message) {
35233
+ return this._addCheck({
35234
+ kind: "max",
35235
+ value: BigInt(0),
35236
+ inclusive: true,
35237
+ message: errorUtil.toString(message)
35238
+ });
35239
+ }
35240
+ nonnegative(message) {
35241
+ return this._addCheck({
35242
+ kind: "min",
35243
+ value: BigInt(0),
35244
+ inclusive: true,
35245
+ message: errorUtil.toString(message)
35246
+ });
35247
+ }
35248
+ multipleOf(value, message) {
35249
+ return this._addCheck({
35250
+ kind: "multipleOf",
35251
+ value,
35252
+ message: errorUtil.toString(message)
35253
+ });
35254
+ }
35255
+ get minValue() {
35256
+ let min = null;
35257
+ for (const ch of this._def.checks) {
35258
+ if (ch.kind === "min") {
35259
+ if (min === null || ch.value > min)
35260
+ min = ch.value;
35261
+ }
35262
+ }
35263
+ return min;
35264
+ }
35265
+ get maxValue() {
35266
+ let max = null;
35267
+ for (const ch of this._def.checks) {
35268
+ if (ch.kind === "max") {
35269
+ if (max === null || ch.value < max)
35270
+ max = ch.value;
35271
+ }
35272
+ }
35273
+ return max;
35274
+ }
35275
+ }
35276
+ ZodBigInt3.create = (params) => {
35277
+ return new ZodBigInt3({
35278
+ checks: [],
35279
+ typeName: ZodFirstPartyTypeKind2.ZodBigInt,
35280
+ coerce: params?.coerce ?? false,
35281
+ ...processCreateParams(params)
35282
+ });
35283
+ };
35284
+
35285
+ class ZodBoolean3 extends ZodType3 {
35286
+ _parse(input) {
35287
+ if (this._def.coerce) {
35288
+ input.data = Boolean(input.data);
35289
+ }
35290
+ const parsedType3 = this._getType(input);
35291
+ if (parsedType3 !== ZodParsedType.boolean) {
35292
+ const ctx = this._getOrReturnCtx(input);
35293
+ addIssueToContext(ctx, {
35294
+ code: ZodIssueCode3.invalid_type,
35295
+ expected: ZodParsedType.boolean,
35296
+ received: ctx.parsedType
35297
+ });
35298
+ return INVALID;
35299
+ }
35300
+ return OK(input.data);
35301
+ }
35302
+ }
35303
+ ZodBoolean3.create = (params) => {
35304
+ return new ZodBoolean3({
35305
+ typeName: ZodFirstPartyTypeKind2.ZodBoolean,
35306
+ coerce: params?.coerce || false,
35307
+ ...processCreateParams(params)
35308
+ });
35309
+ };
35310
+
35311
+ class ZodDate3 extends ZodType3 {
35312
+ _parse(input) {
35313
+ if (this._def.coerce) {
35314
+ input.data = new Date(input.data);
35315
+ }
35316
+ const parsedType3 = this._getType(input);
35317
+ if (parsedType3 !== ZodParsedType.date) {
35318
+ const ctx2 = this._getOrReturnCtx(input);
35319
+ addIssueToContext(ctx2, {
35320
+ code: ZodIssueCode3.invalid_type,
35321
+ expected: ZodParsedType.date,
35322
+ received: ctx2.parsedType
35323
+ });
35324
+ return INVALID;
35325
+ }
35326
+ if (Number.isNaN(input.data.getTime())) {
35327
+ const ctx2 = this._getOrReturnCtx(input);
35328
+ addIssueToContext(ctx2, {
35329
+ code: ZodIssueCode3.invalid_date
35330
+ });
35331
+ return INVALID;
35332
+ }
35333
+ const status = new ParseStatus;
35334
+ let ctx = undefined;
35335
+ for (const check3 of this._def.checks) {
35336
+ if (check3.kind === "min") {
35337
+ if (input.data.getTime() < check3.value) {
35338
+ ctx = this._getOrReturnCtx(input, ctx);
35339
+ addIssueToContext(ctx, {
35340
+ code: ZodIssueCode3.too_small,
35341
+ message: check3.message,
35342
+ inclusive: true,
35343
+ exact: false,
35344
+ minimum: check3.value,
35345
+ type: "date"
35346
+ });
35347
+ status.dirty();
35348
+ }
35349
+ } else if (check3.kind === "max") {
35350
+ if (input.data.getTime() > check3.value) {
35351
+ ctx = this._getOrReturnCtx(input, ctx);
35352
+ addIssueToContext(ctx, {
35353
+ code: ZodIssueCode3.too_big,
35354
+ message: check3.message,
35355
+ inclusive: true,
35356
+ exact: false,
35357
+ maximum: check3.value,
35358
+ type: "date"
35359
+ });
35360
+ status.dirty();
35361
+ }
35362
+ } else {
35363
+ util.assertNever(check3);
35364
+ }
35365
+ }
35366
+ return {
35367
+ status: status.value,
35368
+ value: new Date(input.data.getTime())
35369
+ };
35370
+ }
35371
+ _addCheck(check3) {
35372
+ return new ZodDate3({
35373
+ ...this._def,
35374
+ checks: [...this._def.checks, check3]
35375
+ });
35376
+ }
35377
+ min(minDate, message) {
35378
+ return this._addCheck({
35379
+ kind: "min",
35380
+ value: minDate.getTime(),
35381
+ message: errorUtil.toString(message)
35382
+ });
35383
+ }
35384
+ max(maxDate, message) {
35385
+ return this._addCheck({
35386
+ kind: "max",
35387
+ value: maxDate.getTime(),
35388
+ message: errorUtil.toString(message)
35389
+ });
35390
+ }
35391
+ get minDate() {
35392
+ let min = null;
35393
+ for (const ch of this._def.checks) {
35394
+ if (ch.kind === "min") {
35395
+ if (min === null || ch.value > min)
35396
+ min = ch.value;
35397
+ }
35398
+ }
35399
+ return min != null ? new Date(min) : null;
35400
+ }
35401
+ get maxDate() {
35402
+ let max = null;
35403
+ for (const ch of this._def.checks) {
35404
+ if (ch.kind === "max") {
35405
+ if (max === null || ch.value < max)
35406
+ max = ch.value;
35407
+ }
35408
+ }
35409
+ return max != null ? new Date(max) : null;
35410
+ }
35411
+ }
35412
+ ZodDate3.create = (params) => {
35413
+ return new ZodDate3({
35414
+ checks: [],
35415
+ coerce: params?.coerce || false,
35416
+ typeName: ZodFirstPartyTypeKind2.ZodDate,
35417
+ ...processCreateParams(params)
35418
+ });
35419
+ };
35420
+
35421
+ class ZodSymbol2 extends ZodType3 {
35422
+ _parse(input) {
35423
+ const parsedType3 = this._getType(input);
35424
+ if (parsedType3 !== ZodParsedType.symbol) {
35425
+ const ctx = this._getOrReturnCtx(input);
35426
+ addIssueToContext(ctx, {
35427
+ code: ZodIssueCode3.invalid_type,
35428
+ expected: ZodParsedType.symbol,
35429
+ received: ctx.parsedType
35430
+ });
35431
+ return INVALID;
35432
+ }
35433
+ return OK(input.data);
35434
+ }
35435
+ }
35436
+ ZodSymbol2.create = (params) => {
35437
+ return new ZodSymbol2({
35438
+ typeName: ZodFirstPartyTypeKind2.ZodSymbol,
35439
+ ...processCreateParams(params)
35440
+ });
35441
+ };
35442
+
35443
+ class ZodUndefined2 extends ZodType3 {
35444
+ _parse(input) {
35445
+ const parsedType3 = this._getType(input);
35446
+ if (parsedType3 !== ZodParsedType.undefined) {
35447
+ const ctx = this._getOrReturnCtx(input);
35448
+ addIssueToContext(ctx, {
35449
+ code: ZodIssueCode3.invalid_type,
35450
+ expected: ZodParsedType.undefined,
35451
+ received: ctx.parsedType
35452
+ });
35453
+ return INVALID;
35454
+ }
35455
+ return OK(input.data);
35456
+ }
35457
+ }
35458
+ ZodUndefined2.create = (params) => {
35459
+ return new ZodUndefined2({
35460
+ typeName: ZodFirstPartyTypeKind2.ZodUndefined,
35461
+ ...processCreateParams(params)
35462
+ });
35463
+ };
35464
+
35465
+ class ZodNull3 extends ZodType3 {
35466
+ _parse(input) {
35467
+ const parsedType3 = this._getType(input);
35468
+ if (parsedType3 !== ZodParsedType.null) {
35469
+ const ctx = this._getOrReturnCtx(input);
35470
+ addIssueToContext(ctx, {
35471
+ code: ZodIssueCode3.invalid_type,
35472
+ expected: ZodParsedType.null,
35473
+ received: ctx.parsedType
35474
+ });
35475
+ return INVALID;
35476
+ }
35477
+ return OK(input.data);
35478
+ }
35479
+ }
35480
+ ZodNull3.create = (params) => {
35481
+ return new ZodNull3({
35482
+ typeName: ZodFirstPartyTypeKind2.ZodNull,
35483
+ ...processCreateParams(params)
35484
+ });
35485
+ };
35486
+
35487
+ class ZodAny3 extends ZodType3 {
35488
+ constructor() {
35489
+ super(...arguments);
35490
+ this._any = true;
35491
+ }
35492
+ _parse(input) {
35493
+ return OK(input.data);
35494
+ }
35495
+ }
35496
+ ZodAny3.create = (params) => {
35497
+ return new ZodAny3({
35498
+ typeName: ZodFirstPartyTypeKind2.ZodAny,
35499
+ ...processCreateParams(params)
35500
+ });
35501
+ };
35502
+
35503
+ class ZodUnknown3 extends ZodType3 {
35504
+ constructor() {
35505
+ super(...arguments);
35506
+ this._unknown = true;
35507
+ }
35508
+ _parse(input) {
35509
+ return OK(input.data);
35510
+ }
35511
+ }
35512
+ ZodUnknown3.create = (params) => {
35513
+ return new ZodUnknown3({
35514
+ typeName: ZodFirstPartyTypeKind2.ZodUnknown,
35515
+ ...processCreateParams(params)
35516
+ });
35517
+ };
35518
+
35519
+ class ZodNever3 extends ZodType3 {
35520
+ _parse(input) {
35521
+ const ctx = this._getOrReturnCtx(input);
35522
+ addIssueToContext(ctx, {
35523
+ code: ZodIssueCode3.invalid_type,
35524
+ expected: ZodParsedType.never,
35525
+ received: ctx.parsedType
35526
+ });
35527
+ return INVALID;
35528
+ }
35529
+ }
35530
+ ZodNever3.create = (params) => {
35531
+ return new ZodNever3({
35532
+ typeName: ZodFirstPartyTypeKind2.ZodNever,
35533
+ ...processCreateParams(params)
35534
+ });
35535
+ };
35536
+
35537
+ class ZodVoid2 extends ZodType3 {
35538
+ _parse(input) {
35539
+ const parsedType3 = this._getType(input);
35540
+ if (parsedType3 !== ZodParsedType.undefined) {
35541
+ const ctx = this._getOrReturnCtx(input);
35542
+ addIssueToContext(ctx, {
35543
+ code: ZodIssueCode3.invalid_type,
35544
+ expected: ZodParsedType.void,
35545
+ received: ctx.parsedType
35546
+ });
35547
+ return INVALID;
35548
+ }
35549
+ return OK(input.data);
35550
+ }
35551
+ }
35552
+ ZodVoid2.create = (params) => {
35553
+ return new ZodVoid2({
35554
+ typeName: ZodFirstPartyTypeKind2.ZodVoid,
35555
+ ...processCreateParams(params)
35556
+ });
35557
+ };
35558
+
35559
+ class ZodArray3 extends ZodType3 {
35560
+ _parse(input) {
35561
+ const { ctx, status } = this._processInputParams(input);
35562
+ const def = this._def;
35563
+ if (ctx.parsedType !== ZodParsedType.array) {
35564
+ addIssueToContext(ctx, {
35565
+ code: ZodIssueCode3.invalid_type,
35566
+ expected: ZodParsedType.array,
35567
+ received: ctx.parsedType
35568
+ });
35569
+ return INVALID;
35570
+ }
35571
+ if (def.exactLength !== null) {
35572
+ const tooBig = ctx.data.length > def.exactLength.value;
35573
+ const tooSmall = ctx.data.length < def.exactLength.value;
35574
+ if (tooBig || tooSmall) {
35575
+ addIssueToContext(ctx, {
35576
+ code: tooBig ? ZodIssueCode3.too_big : ZodIssueCode3.too_small,
35577
+ minimum: tooSmall ? def.exactLength.value : undefined,
35578
+ maximum: tooBig ? def.exactLength.value : undefined,
35579
+ type: "array",
35580
+ inclusive: true,
35581
+ exact: true,
35582
+ message: def.exactLength.message
35583
+ });
35584
+ status.dirty();
35585
+ }
35586
+ }
35587
+ if (def.minLength !== null) {
35588
+ if (ctx.data.length < def.minLength.value) {
35589
+ addIssueToContext(ctx, {
35590
+ code: ZodIssueCode3.too_small,
35591
+ minimum: def.minLength.value,
35592
+ type: "array",
35593
+ inclusive: true,
35594
+ exact: false,
35595
+ message: def.minLength.message
35596
+ });
35597
+ status.dirty();
35598
+ }
35599
+ }
35600
+ if (def.maxLength !== null) {
35601
+ if (ctx.data.length > def.maxLength.value) {
35602
+ addIssueToContext(ctx, {
35603
+ code: ZodIssueCode3.too_big,
35604
+ maximum: def.maxLength.value,
35605
+ type: "array",
35606
+ inclusive: true,
35607
+ exact: false,
35608
+ message: def.maxLength.message
35609
+ });
35610
+ status.dirty();
35611
+ }
35612
+ }
35613
+ if (ctx.common.async) {
35614
+ return Promise.all([...ctx.data].map((item, i) => {
35615
+ return def.type._parseAsync(new ParseInputLazyPath(ctx, item, ctx.path, i));
35616
+ })).then((result2) => {
35617
+ return ParseStatus.mergeArray(status, result2);
35618
+ });
35619
+ }
35620
+ const result = [...ctx.data].map((item, i) => {
35621
+ return def.type._parseSync(new ParseInputLazyPath(ctx, item, ctx.path, i));
35622
+ });
35623
+ return ParseStatus.mergeArray(status, result);
35624
+ }
35625
+ get element() {
35626
+ return this._def.type;
35627
+ }
35628
+ min(minLength, message) {
35629
+ return new ZodArray3({
35630
+ ...this._def,
35631
+ minLength: { value: minLength, message: errorUtil.toString(message) }
35632
+ });
35633
+ }
35634
+ max(maxLength, message) {
35635
+ return new ZodArray3({
35636
+ ...this._def,
35637
+ maxLength: { value: maxLength, message: errorUtil.toString(message) }
35638
+ });
35639
+ }
35640
+ length(len, message) {
35641
+ return new ZodArray3({
35642
+ ...this._def,
35643
+ exactLength: { value: len, message: errorUtil.toString(message) }
35644
+ });
35645
+ }
35646
+ nonempty(message) {
35647
+ return this.min(1, message);
35648
+ }
35649
+ }
35650
+ ZodArray3.create = (schema, params) => {
35651
+ return new ZodArray3({
35652
+ type: schema,
35653
+ minLength: null,
35654
+ maxLength: null,
35655
+ exactLength: null,
35656
+ typeName: ZodFirstPartyTypeKind2.ZodArray,
35657
+ ...processCreateParams(params)
35658
+ });
35659
+ };
35660
+ function deepPartialify(schema) {
35661
+ if (schema instanceof ZodObject3) {
35662
+ const newShape = {};
35663
+ for (const key in schema.shape) {
35664
+ const fieldSchema = schema.shape[key];
35665
+ newShape[key] = ZodOptional3.create(deepPartialify(fieldSchema));
35666
+ }
35667
+ return new ZodObject3({
35668
+ ...schema._def,
35669
+ shape: () => newShape
35670
+ });
35671
+ } else if (schema instanceof ZodArray3) {
35672
+ return new ZodArray3({
35673
+ ...schema._def,
35674
+ type: deepPartialify(schema.element)
35675
+ });
35676
+ } else if (schema instanceof ZodOptional3) {
35677
+ return ZodOptional3.create(deepPartialify(schema.unwrap()));
35678
+ } else if (schema instanceof ZodNullable3) {
35679
+ return ZodNullable3.create(deepPartialify(schema.unwrap()));
35680
+ } else if (schema instanceof ZodTuple2) {
35681
+ return ZodTuple2.create(schema.items.map((item) => deepPartialify(item)));
35682
+ } else {
35683
+ return schema;
35684
+ }
35685
+ }
35686
+
35687
+ class ZodObject3 extends ZodType3 {
35688
+ constructor() {
35689
+ super(...arguments);
35690
+ this._cached = null;
35691
+ this.nonstrict = this.passthrough;
35692
+ this.augment = this.extend;
35693
+ }
35694
+ _getCached() {
35695
+ if (this._cached !== null)
35696
+ return this._cached;
35697
+ const shape = this._def.shape();
35698
+ const keys = util.objectKeys(shape);
35699
+ this._cached = { shape, keys };
35700
+ return this._cached;
35701
+ }
35702
+ _parse(input) {
35703
+ const parsedType3 = this._getType(input);
35704
+ if (parsedType3 !== ZodParsedType.object) {
35705
+ const ctx2 = this._getOrReturnCtx(input);
35706
+ addIssueToContext(ctx2, {
35707
+ code: ZodIssueCode3.invalid_type,
35708
+ expected: ZodParsedType.object,
35709
+ received: ctx2.parsedType
35710
+ });
35711
+ return INVALID;
35712
+ }
35713
+ const { status, ctx } = this._processInputParams(input);
35714
+ const { shape, keys: shapeKeys } = this._getCached();
35715
+ const extraKeys = [];
35716
+ if (!(this._def.catchall instanceof ZodNever3 && this._def.unknownKeys === "strip")) {
35717
+ for (const key in ctx.data) {
35718
+ if (!shapeKeys.includes(key)) {
35719
+ extraKeys.push(key);
35720
+ }
35721
+ }
35722
+ }
35723
+ const pairs = [];
35724
+ for (const key of shapeKeys) {
35725
+ const keyValidator = shape[key];
35726
+ const value = ctx.data[key];
35727
+ pairs.push({
35728
+ key: { status: "valid", value: key },
35729
+ value: keyValidator._parse(new ParseInputLazyPath(ctx, value, ctx.path, key)),
35730
+ alwaysSet: key in ctx.data
35731
+ });
35732
+ }
35733
+ if (this._def.catchall instanceof ZodNever3) {
35734
+ const unknownKeys = this._def.unknownKeys;
35735
+ if (unknownKeys === "passthrough") {
35736
+ for (const key of extraKeys) {
35737
+ pairs.push({
35738
+ key: { status: "valid", value: key },
35739
+ value: { status: "valid", value: ctx.data[key] }
35740
+ });
35741
+ }
35742
+ } else if (unknownKeys === "strict") {
35743
+ if (extraKeys.length > 0) {
35744
+ addIssueToContext(ctx, {
35745
+ code: ZodIssueCode3.unrecognized_keys,
35746
+ keys: extraKeys
35747
+ });
35748
+ status.dirty();
35749
+ }
35750
+ } else if (unknownKeys === "strip") {} else {
35751
+ throw new Error(`Internal ZodObject error: invalid unknownKeys value.`);
35752
+ }
35753
+ } else {
35754
+ const catchall = this._def.catchall;
35755
+ for (const key of extraKeys) {
35756
+ const value = ctx.data[key];
35757
+ pairs.push({
35758
+ key: { status: "valid", value: key },
35759
+ value: catchall._parse(new ParseInputLazyPath(ctx, value, ctx.path, key)),
35760
+ alwaysSet: key in ctx.data
35761
+ });
35762
+ }
35763
+ }
35764
+ if (ctx.common.async) {
35765
+ return Promise.resolve().then(async () => {
35766
+ const syncPairs = [];
35767
+ for (const pair of pairs) {
35768
+ const key = await pair.key;
35769
+ const value = await pair.value;
35770
+ syncPairs.push({
35771
+ key,
35772
+ value,
35773
+ alwaysSet: pair.alwaysSet
35774
+ });
35775
+ }
35776
+ return syncPairs;
35777
+ }).then((syncPairs) => {
35778
+ return ParseStatus.mergeObjectSync(status, syncPairs);
35779
+ });
35780
+ } else {
35781
+ return ParseStatus.mergeObjectSync(status, pairs);
35782
+ }
35783
+ }
35784
+ get shape() {
35785
+ return this._def.shape();
35786
+ }
35787
+ strict(message) {
35788
+ errorUtil.errToObj;
35789
+ return new ZodObject3({
35790
+ ...this._def,
35791
+ unknownKeys: "strict",
35792
+ ...message !== undefined ? {
35793
+ errorMap: (issue3, ctx) => {
35794
+ const defaultError = this._def.errorMap?.(issue3, ctx).message ?? ctx.defaultError;
35795
+ if (issue3.code === "unrecognized_keys")
35796
+ return {
35797
+ message: errorUtil.errToObj(message).message ?? defaultError
35798
+ };
35799
+ return {
35800
+ message: defaultError
35801
+ };
35802
+ }
35803
+ } : {}
35804
+ });
35805
+ }
35806
+ strip() {
35807
+ return new ZodObject3({
35808
+ ...this._def,
35809
+ unknownKeys: "strip"
35810
+ });
35811
+ }
35812
+ passthrough() {
35813
+ return new ZodObject3({
35814
+ ...this._def,
35815
+ unknownKeys: "passthrough"
35816
+ });
35817
+ }
35818
+ extend(augmentation) {
35819
+ return new ZodObject3({
35820
+ ...this._def,
35821
+ shape: () => ({
35822
+ ...this._def.shape(),
35823
+ ...augmentation
35824
+ })
35825
+ });
35826
+ }
35827
+ merge(merging) {
35828
+ const merged = new ZodObject3({
35829
+ unknownKeys: merging._def.unknownKeys,
35830
+ catchall: merging._def.catchall,
35831
+ shape: () => ({
35832
+ ...this._def.shape(),
35833
+ ...merging._def.shape()
35834
+ }),
35835
+ typeName: ZodFirstPartyTypeKind2.ZodObject
35836
+ });
35837
+ return merged;
35838
+ }
35839
+ setKey(key, schema) {
35840
+ return this.augment({ [key]: schema });
35841
+ }
35842
+ catchall(index) {
35843
+ return new ZodObject3({
35844
+ ...this._def,
35845
+ catchall: index
35846
+ });
35847
+ }
35848
+ pick(mask) {
35849
+ const shape = {};
35850
+ for (const key of util.objectKeys(mask)) {
35851
+ if (mask[key] && this.shape[key]) {
35852
+ shape[key] = this.shape[key];
35853
+ }
35854
+ }
35855
+ return new ZodObject3({
35856
+ ...this._def,
35857
+ shape: () => shape
35858
+ });
35859
+ }
35860
+ omit(mask) {
35861
+ const shape = {};
35862
+ for (const key of util.objectKeys(this.shape)) {
35863
+ if (!mask[key]) {
35864
+ shape[key] = this.shape[key];
35865
+ }
35866
+ }
35867
+ return new ZodObject3({
35868
+ ...this._def,
35869
+ shape: () => shape
35870
+ });
35871
+ }
35872
+ deepPartial() {
35873
+ return deepPartialify(this);
35874
+ }
35875
+ partial(mask) {
35876
+ const newShape = {};
35877
+ for (const key of util.objectKeys(this.shape)) {
35878
+ const fieldSchema = this.shape[key];
35879
+ if (mask && !mask[key]) {
35880
+ newShape[key] = fieldSchema;
35881
+ } else {
35882
+ newShape[key] = fieldSchema.optional();
35883
+ }
35884
+ }
35885
+ return new ZodObject3({
35886
+ ...this._def,
35887
+ shape: () => newShape
35888
+ });
35889
+ }
35890
+ required(mask) {
35891
+ const newShape = {};
35892
+ for (const key of util.objectKeys(this.shape)) {
35893
+ if (mask && !mask[key]) {
35894
+ newShape[key] = this.shape[key];
35895
+ } else {
35896
+ const fieldSchema = this.shape[key];
35897
+ let newField = fieldSchema;
35898
+ while (newField instanceof ZodOptional3) {
35899
+ newField = newField._def.innerType;
35900
+ }
35901
+ newShape[key] = newField;
35902
+ }
35903
+ }
35904
+ return new ZodObject3({
35905
+ ...this._def,
35906
+ shape: () => newShape
35907
+ });
35908
+ }
35909
+ keyof() {
35910
+ return createZodEnum(util.objectKeys(this.shape));
35911
+ }
35912
+ }
35913
+ ZodObject3.create = (shape, params) => {
35914
+ return new ZodObject3({
35915
+ shape: () => shape,
35916
+ unknownKeys: "strip",
35917
+ catchall: ZodNever3.create(),
35918
+ typeName: ZodFirstPartyTypeKind2.ZodObject,
35919
+ ...processCreateParams(params)
35920
+ });
35921
+ };
35922
+ ZodObject3.strictCreate = (shape, params) => {
35923
+ return new ZodObject3({
35924
+ shape: () => shape,
35925
+ unknownKeys: "strict",
35926
+ catchall: ZodNever3.create(),
35927
+ typeName: ZodFirstPartyTypeKind2.ZodObject,
35928
+ ...processCreateParams(params)
35929
+ });
35930
+ };
35931
+ ZodObject3.lazycreate = (shape, params) => {
35932
+ return new ZodObject3({
35933
+ shape,
35934
+ unknownKeys: "strip",
35935
+ catchall: ZodNever3.create(),
35936
+ typeName: ZodFirstPartyTypeKind2.ZodObject,
35937
+ ...processCreateParams(params)
35938
+ });
35939
+ };
35940
+
35941
+ class ZodUnion3 extends ZodType3 {
35942
+ _parse(input) {
35943
+ const { ctx } = this._processInputParams(input);
35944
+ const options = this._def.options;
35945
+ function handleResults(results) {
35946
+ for (const result of results) {
35947
+ if (result.result.status === "valid") {
35948
+ return result.result;
35949
+ }
35950
+ }
35951
+ for (const result of results) {
35952
+ if (result.result.status === "dirty") {
35953
+ ctx.common.issues.push(...result.ctx.common.issues);
35954
+ return result.result;
35955
+ }
35956
+ }
35957
+ const unionErrors = results.map((result) => new ZodError3(result.ctx.common.issues));
35958
+ addIssueToContext(ctx, {
35959
+ code: ZodIssueCode3.invalid_union,
35960
+ unionErrors
35961
+ });
35962
+ return INVALID;
35963
+ }
35964
+ if (ctx.common.async) {
35965
+ return Promise.all(options.map(async (option) => {
35966
+ const childCtx = {
35967
+ ...ctx,
35968
+ common: {
35969
+ ...ctx.common,
35970
+ issues: []
35971
+ },
35972
+ parent: null
35973
+ };
35974
+ return {
35975
+ result: await option._parseAsync({
35976
+ data: ctx.data,
35977
+ path: ctx.path,
35978
+ parent: childCtx
35979
+ }),
35980
+ ctx: childCtx
35981
+ };
35982
+ })).then(handleResults);
35983
+ } else {
35984
+ let dirty = undefined;
35985
+ const issues = [];
35986
+ for (const option of options) {
35987
+ const childCtx = {
35988
+ ...ctx,
35989
+ common: {
35990
+ ...ctx.common,
35991
+ issues: []
35992
+ },
35993
+ parent: null
35994
+ };
35995
+ const result = option._parseSync({
35996
+ data: ctx.data,
35997
+ path: ctx.path,
35998
+ parent: childCtx
35999
+ });
36000
+ if (result.status === "valid") {
36001
+ return result;
36002
+ } else if (result.status === "dirty" && !dirty) {
36003
+ dirty = { result, ctx: childCtx };
36004
+ }
36005
+ if (childCtx.common.issues.length) {
36006
+ issues.push(childCtx.common.issues);
36007
+ }
36008
+ }
36009
+ if (dirty) {
36010
+ ctx.common.issues.push(...dirty.ctx.common.issues);
36011
+ return dirty.result;
36012
+ }
36013
+ const unionErrors = issues.map((issues2) => new ZodError3(issues2));
36014
+ addIssueToContext(ctx, {
36015
+ code: ZodIssueCode3.invalid_union,
36016
+ unionErrors
36017
+ });
36018
+ return INVALID;
36019
+ }
36020
+ }
36021
+ get options() {
36022
+ return this._def.options;
36023
+ }
36024
+ }
36025
+ ZodUnion3.create = (types, params) => {
36026
+ return new ZodUnion3({
36027
+ options: types,
36028
+ typeName: ZodFirstPartyTypeKind2.ZodUnion,
36029
+ ...processCreateParams(params)
36030
+ });
36031
+ };
36032
+ var getDiscriminator = (type) => {
36033
+ if (type instanceof ZodLazy2) {
36034
+ return getDiscriminator(type.schema);
36035
+ } else if (type instanceof ZodEffects) {
36036
+ return getDiscriminator(type.innerType());
36037
+ } else if (type instanceof ZodLiteral3) {
36038
+ return [type.value];
36039
+ } else if (type instanceof ZodEnum3) {
36040
+ return type.options;
36041
+ } else if (type instanceof ZodNativeEnum) {
36042
+ return util.objectValues(type.enum);
36043
+ } else if (type instanceof ZodDefault3) {
36044
+ return getDiscriminator(type._def.innerType);
36045
+ } else if (type instanceof ZodUndefined2) {
36046
+ return [undefined];
36047
+ } else if (type instanceof ZodNull3) {
36048
+ return [null];
36049
+ } else if (type instanceof ZodOptional3) {
36050
+ return [undefined, ...getDiscriminator(type.unwrap())];
36051
+ } else if (type instanceof ZodNullable3) {
36052
+ return [null, ...getDiscriminator(type.unwrap())];
36053
+ } else if (type instanceof ZodBranded) {
36054
+ return getDiscriminator(type.unwrap());
36055
+ } else if (type instanceof ZodReadonly3) {
36056
+ return getDiscriminator(type.unwrap());
36057
+ } else if (type instanceof ZodCatch3) {
36058
+ return getDiscriminator(type._def.innerType);
36059
+ } else {
36060
+ return [];
36061
+ }
36062
+ };
36063
+
36064
+ class ZodDiscriminatedUnion3 extends ZodType3 {
36065
+ _parse(input) {
36066
+ const { ctx } = this._processInputParams(input);
36067
+ if (ctx.parsedType !== ZodParsedType.object) {
36068
+ addIssueToContext(ctx, {
36069
+ code: ZodIssueCode3.invalid_type,
36070
+ expected: ZodParsedType.object,
36071
+ received: ctx.parsedType
36072
+ });
36073
+ return INVALID;
36074
+ }
36075
+ const discriminator = this.discriminator;
36076
+ const discriminatorValue = ctx.data[discriminator];
36077
+ const option = this.optionsMap.get(discriminatorValue);
36078
+ if (!option) {
36079
+ addIssueToContext(ctx, {
36080
+ code: ZodIssueCode3.invalid_union_discriminator,
36081
+ options: Array.from(this.optionsMap.keys()),
36082
+ path: [discriminator]
36083
+ });
36084
+ return INVALID;
36085
+ }
36086
+ if (ctx.common.async) {
36087
+ return option._parseAsync({
36088
+ data: ctx.data,
36089
+ path: ctx.path,
36090
+ parent: ctx
36091
+ });
36092
+ } else {
36093
+ return option._parseSync({
36094
+ data: ctx.data,
36095
+ path: ctx.path,
36096
+ parent: ctx
36097
+ });
36098
+ }
36099
+ }
36100
+ get discriminator() {
36101
+ return this._def.discriminator;
36102
+ }
36103
+ get options() {
36104
+ return this._def.options;
36105
+ }
36106
+ get optionsMap() {
36107
+ return this._def.optionsMap;
36108
+ }
36109
+ static create(discriminator, options, params) {
36110
+ const optionsMap = new Map;
36111
+ for (const type of options) {
36112
+ const discriminatorValues = getDiscriminator(type.shape[discriminator]);
36113
+ if (!discriminatorValues.length) {
36114
+ throw new Error(`A discriminator value for key \`${discriminator}\` could not be extracted from all schema options`);
36115
+ }
36116
+ for (const value of discriminatorValues) {
36117
+ if (optionsMap.has(value)) {
36118
+ throw new Error(`Discriminator property ${String(discriminator)} has duplicate value ${String(value)}`);
36119
+ }
36120
+ optionsMap.set(value, type);
36121
+ }
36122
+ }
36123
+ return new ZodDiscriminatedUnion3({
36124
+ typeName: ZodFirstPartyTypeKind2.ZodDiscriminatedUnion,
36125
+ discriminator,
36126
+ options,
36127
+ optionsMap,
36128
+ ...processCreateParams(params)
36129
+ });
36130
+ }
36131
+ }
36132
+ function mergeValues3(a, b) {
36133
+ const aType = getParsedType3(a);
36134
+ const bType = getParsedType3(b);
36135
+ if (a === b) {
36136
+ return { valid: true, data: a };
36137
+ } else if (aType === ZodParsedType.object && bType === ZodParsedType.object) {
36138
+ const bKeys = util.objectKeys(b);
36139
+ const sharedKeys = util.objectKeys(a).filter((key) => bKeys.indexOf(key) !== -1);
36140
+ const newObj = { ...a, ...b };
36141
+ for (const key of sharedKeys) {
36142
+ const sharedValue = mergeValues3(a[key], b[key]);
36143
+ if (!sharedValue.valid) {
36144
+ return { valid: false };
36145
+ }
36146
+ newObj[key] = sharedValue.data;
36147
+ }
36148
+ return { valid: true, data: newObj };
36149
+ } else if (aType === ZodParsedType.array && bType === ZodParsedType.array) {
36150
+ if (a.length !== b.length) {
36151
+ return { valid: false };
36152
+ }
36153
+ const newArray = [];
36154
+ for (let index = 0;index < a.length; index++) {
36155
+ const itemA = a[index];
36156
+ const itemB = b[index];
36157
+ const sharedValue = mergeValues3(itemA, itemB);
36158
+ if (!sharedValue.valid) {
36159
+ return { valid: false };
36160
+ }
36161
+ newArray.push(sharedValue.data);
36162
+ }
36163
+ return { valid: true, data: newArray };
36164
+ } else if (aType === ZodParsedType.date && bType === ZodParsedType.date && +a === +b) {
36165
+ return { valid: true, data: a };
36166
+ } else {
36167
+ return { valid: false };
36168
+ }
36169
+ }
36170
+
36171
+ class ZodIntersection3 extends ZodType3 {
36172
+ _parse(input) {
36173
+ const { status, ctx } = this._processInputParams(input);
36174
+ const handleParsed = (parsedLeft, parsedRight) => {
36175
+ if (isAborted(parsedLeft) || isAborted(parsedRight)) {
36176
+ return INVALID;
36177
+ }
36178
+ const merged = mergeValues3(parsedLeft.value, parsedRight.value);
36179
+ if (!merged.valid) {
36180
+ addIssueToContext(ctx, {
36181
+ code: ZodIssueCode3.invalid_intersection_types
36182
+ });
36183
+ return INVALID;
36184
+ }
36185
+ if (isDirty(parsedLeft) || isDirty(parsedRight)) {
36186
+ status.dirty();
36187
+ }
36188
+ return { status: status.value, value: merged.data };
36189
+ };
36190
+ if (ctx.common.async) {
36191
+ return Promise.all([
36192
+ this._def.left._parseAsync({
36193
+ data: ctx.data,
36194
+ path: ctx.path,
36195
+ parent: ctx
36196
+ }),
36197
+ this._def.right._parseAsync({
36198
+ data: ctx.data,
36199
+ path: ctx.path,
36200
+ parent: ctx
36201
+ })
36202
+ ]).then(([left, right]) => handleParsed(left, right));
36203
+ } else {
36204
+ return handleParsed(this._def.left._parseSync({
36205
+ data: ctx.data,
36206
+ path: ctx.path,
36207
+ parent: ctx
36208
+ }), this._def.right._parseSync({
36209
+ data: ctx.data,
36210
+ path: ctx.path,
36211
+ parent: ctx
36212
+ }));
36213
+ }
36214
+ }
36215
+ }
36216
+ ZodIntersection3.create = (left, right, params) => {
36217
+ return new ZodIntersection3({
36218
+ left,
36219
+ right,
36220
+ typeName: ZodFirstPartyTypeKind2.ZodIntersection,
36221
+ ...processCreateParams(params)
36222
+ });
36223
+ };
36224
+
36225
+ class ZodTuple2 extends ZodType3 {
36226
+ _parse(input) {
36227
+ const { status, ctx } = this._processInputParams(input);
36228
+ if (ctx.parsedType !== ZodParsedType.array) {
36229
+ addIssueToContext(ctx, {
36230
+ code: ZodIssueCode3.invalid_type,
36231
+ expected: ZodParsedType.array,
36232
+ received: ctx.parsedType
36233
+ });
36234
+ return INVALID;
36235
+ }
36236
+ if (ctx.data.length < this._def.items.length) {
36237
+ addIssueToContext(ctx, {
36238
+ code: ZodIssueCode3.too_small,
36239
+ minimum: this._def.items.length,
36240
+ inclusive: true,
36241
+ exact: false,
36242
+ type: "array"
36243
+ });
36244
+ return INVALID;
36245
+ }
36246
+ const rest = this._def.rest;
36247
+ if (!rest && ctx.data.length > this._def.items.length) {
36248
+ addIssueToContext(ctx, {
36249
+ code: ZodIssueCode3.too_big,
36250
+ maximum: this._def.items.length,
36251
+ inclusive: true,
36252
+ exact: false,
36253
+ type: "array"
36254
+ });
36255
+ status.dirty();
36256
+ }
36257
+ const items = [...ctx.data].map((item, itemIndex) => {
36258
+ const schema = this._def.items[itemIndex] || this._def.rest;
36259
+ if (!schema)
36260
+ return null;
36261
+ return schema._parse(new ParseInputLazyPath(ctx, item, ctx.path, itemIndex));
36262
+ }).filter((x) => !!x);
36263
+ if (ctx.common.async) {
36264
+ return Promise.all(items).then((results) => {
36265
+ return ParseStatus.mergeArray(status, results);
36266
+ });
36267
+ } else {
36268
+ return ParseStatus.mergeArray(status, items);
36269
+ }
36270
+ }
36271
+ get items() {
36272
+ return this._def.items;
36273
+ }
36274
+ rest(rest) {
36275
+ return new ZodTuple2({
36276
+ ...this._def,
36277
+ rest
36278
+ });
36279
+ }
36280
+ }
36281
+ ZodTuple2.create = (schemas5, params) => {
36282
+ if (!Array.isArray(schemas5)) {
36283
+ throw new Error("You must pass an array of schemas to z.tuple([ ... ])");
36284
+ }
36285
+ return new ZodTuple2({
36286
+ items: schemas5,
36287
+ typeName: ZodFirstPartyTypeKind2.ZodTuple,
36288
+ rest: null,
36289
+ ...processCreateParams(params)
36290
+ });
36291
+ };
36292
+
36293
+ class ZodRecord3 extends ZodType3 {
36294
+ get keySchema() {
36295
+ return this._def.keyType;
36296
+ }
36297
+ get valueSchema() {
36298
+ return this._def.valueType;
36299
+ }
36300
+ _parse(input) {
36301
+ const { status, ctx } = this._processInputParams(input);
36302
+ if (ctx.parsedType !== ZodParsedType.object) {
36303
+ addIssueToContext(ctx, {
36304
+ code: ZodIssueCode3.invalid_type,
36305
+ expected: ZodParsedType.object,
36306
+ received: ctx.parsedType
36307
+ });
36308
+ return INVALID;
36309
+ }
36310
+ const pairs = [];
36311
+ const keyType = this._def.keyType;
36312
+ const valueType = this._def.valueType;
36313
+ for (const key in ctx.data) {
36314
+ pairs.push({
36315
+ key: keyType._parse(new ParseInputLazyPath(ctx, key, ctx.path, key)),
36316
+ value: valueType._parse(new ParseInputLazyPath(ctx, ctx.data[key], ctx.path, key)),
36317
+ alwaysSet: key in ctx.data
36318
+ });
36319
+ }
36320
+ if (ctx.common.async) {
36321
+ return ParseStatus.mergeObjectAsync(status, pairs);
36322
+ } else {
36323
+ return ParseStatus.mergeObjectSync(status, pairs);
36324
+ }
36325
+ }
36326
+ get element() {
36327
+ return this._def.valueType;
36328
+ }
36329
+ static create(first, second, third) {
36330
+ if (second instanceof ZodType3) {
36331
+ return new ZodRecord3({
36332
+ keyType: first,
36333
+ valueType: second,
36334
+ typeName: ZodFirstPartyTypeKind2.ZodRecord,
36335
+ ...processCreateParams(third)
36336
+ });
36337
+ }
36338
+ return new ZodRecord3({
36339
+ keyType: ZodString3.create(),
36340
+ valueType: first,
36341
+ typeName: ZodFirstPartyTypeKind2.ZodRecord,
36342
+ ...processCreateParams(second)
36343
+ });
36344
+ }
36345
+ }
36346
+
36347
+ class ZodMap2 extends ZodType3 {
36348
+ get keySchema() {
36349
+ return this._def.keyType;
36350
+ }
36351
+ get valueSchema() {
36352
+ return this._def.valueType;
36353
+ }
36354
+ _parse(input) {
36355
+ const { status, ctx } = this._processInputParams(input);
36356
+ if (ctx.parsedType !== ZodParsedType.map) {
36357
+ addIssueToContext(ctx, {
36358
+ code: ZodIssueCode3.invalid_type,
36359
+ expected: ZodParsedType.map,
36360
+ received: ctx.parsedType
36361
+ });
36362
+ return INVALID;
36363
+ }
36364
+ const keyType = this._def.keyType;
36365
+ const valueType = this._def.valueType;
36366
+ const pairs = [...ctx.data.entries()].map(([key, value], index) => {
36367
+ return {
36368
+ key: keyType._parse(new ParseInputLazyPath(ctx, key, ctx.path, [index, "key"])),
36369
+ value: valueType._parse(new ParseInputLazyPath(ctx, value, ctx.path, [index, "value"]))
36370
+ };
36371
+ });
36372
+ if (ctx.common.async) {
36373
+ const finalMap = new Map;
36374
+ return Promise.resolve().then(async () => {
36375
+ for (const pair of pairs) {
36376
+ const key = await pair.key;
36377
+ const value = await pair.value;
36378
+ if (key.status === "aborted" || value.status === "aborted") {
36379
+ return INVALID;
36380
+ }
36381
+ if (key.status === "dirty" || value.status === "dirty") {
36382
+ status.dirty();
36383
+ }
36384
+ finalMap.set(key.value, value.value);
36385
+ }
36386
+ return { status: status.value, value: finalMap };
36387
+ });
36388
+ } else {
36389
+ const finalMap = new Map;
36390
+ for (const pair of pairs) {
36391
+ const key = pair.key;
36392
+ const value = pair.value;
36393
+ if (key.status === "aborted" || value.status === "aborted") {
36394
+ return INVALID;
36395
+ }
36396
+ if (key.status === "dirty" || value.status === "dirty") {
36397
+ status.dirty();
36398
+ }
36399
+ finalMap.set(key.value, value.value);
36400
+ }
36401
+ return { status: status.value, value: finalMap };
36402
+ }
36403
+ }
36404
+ }
36405
+ ZodMap2.create = (keyType, valueType, params) => {
36406
+ return new ZodMap2({
36407
+ valueType,
36408
+ keyType,
36409
+ typeName: ZodFirstPartyTypeKind2.ZodMap,
36410
+ ...processCreateParams(params)
36411
+ });
36412
+ };
36413
+
36414
+ class ZodSet2 extends ZodType3 {
36415
+ _parse(input) {
36416
+ const { status, ctx } = this._processInputParams(input);
36417
+ if (ctx.parsedType !== ZodParsedType.set) {
36418
+ addIssueToContext(ctx, {
36419
+ code: ZodIssueCode3.invalid_type,
36420
+ expected: ZodParsedType.set,
36421
+ received: ctx.parsedType
36422
+ });
36423
+ return INVALID;
36424
+ }
36425
+ const def = this._def;
36426
+ if (def.minSize !== null) {
36427
+ if (ctx.data.size < def.minSize.value) {
36428
+ addIssueToContext(ctx, {
36429
+ code: ZodIssueCode3.too_small,
36430
+ minimum: def.minSize.value,
36431
+ type: "set",
36432
+ inclusive: true,
36433
+ exact: false,
36434
+ message: def.minSize.message
36435
+ });
36436
+ status.dirty();
36437
+ }
36438
+ }
36439
+ if (def.maxSize !== null) {
36440
+ if (ctx.data.size > def.maxSize.value) {
36441
+ addIssueToContext(ctx, {
36442
+ code: ZodIssueCode3.too_big,
36443
+ maximum: def.maxSize.value,
36444
+ type: "set",
36445
+ inclusive: true,
36446
+ exact: false,
36447
+ message: def.maxSize.message
36448
+ });
36449
+ status.dirty();
36450
+ }
36451
+ }
36452
+ const valueType = this._def.valueType;
36453
+ function finalizeSet(elements2) {
36454
+ const parsedSet = new Set;
36455
+ for (const element of elements2) {
36456
+ if (element.status === "aborted")
36457
+ return INVALID;
36458
+ if (element.status === "dirty")
36459
+ status.dirty();
36460
+ parsedSet.add(element.value);
36461
+ }
36462
+ return { status: status.value, value: parsedSet };
36463
+ }
36464
+ const elements = [...ctx.data.values()].map((item, i) => valueType._parse(new ParseInputLazyPath(ctx, item, ctx.path, i)));
36465
+ if (ctx.common.async) {
36466
+ return Promise.all(elements).then((elements2) => finalizeSet(elements2));
36467
+ } else {
36468
+ return finalizeSet(elements);
36469
+ }
36470
+ }
36471
+ min(minSize, message) {
36472
+ return new ZodSet2({
36473
+ ...this._def,
36474
+ minSize: { value: minSize, message: errorUtil.toString(message) }
36475
+ });
36476
+ }
36477
+ max(maxSize, message) {
36478
+ return new ZodSet2({
36479
+ ...this._def,
36480
+ maxSize: { value: maxSize, message: errorUtil.toString(message) }
36481
+ });
36482
+ }
36483
+ size(size, message) {
36484
+ return this.min(size, message).max(size, message);
36485
+ }
36486
+ nonempty(message) {
36487
+ return this.min(1, message);
36488
+ }
36489
+ }
36490
+ ZodSet2.create = (valueType, params) => {
36491
+ return new ZodSet2({
36492
+ valueType,
36493
+ minSize: null,
36494
+ maxSize: null,
36495
+ typeName: ZodFirstPartyTypeKind2.ZodSet,
36496
+ ...processCreateParams(params)
36497
+ });
36498
+ };
36499
+
36500
+ class ZodFunction2 extends ZodType3 {
36501
+ constructor() {
36502
+ super(...arguments);
36503
+ this.validate = this.implement;
36504
+ }
36505
+ _parse(input) {
36506
+ const { ctx } = this._processInputParams(input);
36507
+ if (ctx.parsedType !== ZodParsedType.function) {
36508
+ addIssueToContext(ctx, {
36509
+ code: ZodIssueCode3.invalid_type,
36510
+ expected: ZodParsedType.function,
36511
+ received: ctx.parsedType
36512
+ });
36513
+ return INVALID;
36514
+ }
36515
+ function makeArgsIssue(args, error49) {
36516
+ return makeIssue({
36517
+ data: args,
36518
+ path: ctx.path,
36519
+ errorMaps: [ctx.common.contextualErrorMap, ctx.schemaErrorMap, getErrorMap2(), en_default3].filter((x) => !!x),
36520
+ issueData: {
36521
+ code: ZodIssueCode3.invalid_arguments,
36522
+ argumentsError: error49
36523
+ }
36524
+ });
36525
+ }
36526
+ function makeReturnsIssue(returns, error49) {
36527
+ return makeIssue({
36528
+ data: returns,
36529
+ path: ctx.path,
36530
+ errorMaps: [ctx.common.contextualErrorMap, ctx.schemaErrorMap, getErrorMap2(), en_default3].filter((x) => !!x),
36531
+ issueData: {
36532
+ code: ZodIssueCode3.invalid_return_type,
36533
+ returnTypeError: error49
36534
+ }
36535
+ });
36536
+ }
36537
+ const params = { errorMap: ctx.common.contextualErrorMap };
36538
+ const fn = ctx.data;
36539
+ if (this._def.returns instanceof ZodPromise2) {
36540
+ const me = this;
36541
+ return OK(async function(...args) {
36542
+ const error49 = new ZodError3([]);
36543
+ const parsedArgs = await me._def.args.parseAsync(args, params).catch((e) => {
36544
+ error49.addIssue(makeArgsIssue(args, e));
36545
+ throw error49;
36546
+ });
36547
+ const result = await Reflect.apply(fn, this, parsedArgs);
36548
+ const parsedReturns = await me._def.returns._def.type.parseAsync(result, params).catch((e) => {
36549
+ error49.addIssue(makeReturnsIssue(result, e));
36550
+ throw error49;
36551
+ });
36552
+ return parsedReturns;
36553
+ });
36554
+ } else {
36555
+ const me = this;
36556
+ return OK(function(...args) {
36557
+ const parsedArgs = me._def.args.safeParse(args, params);
36558
+ if (!parsedArgs.success) {
36559
+ throw new ZodError3([makeArgsIssue(args, parsedArgs.error)]);
36560
+ }
36561
+ const result = Reflect.apply(fn, this, parsedArgs.data);
36562
+ const parsedReturns = me._def.returns.safeParse(result, params);
36563
+ if (!parsedReturns.success) {
36564
+ throw new ZodError3([makeReturnsIssue(result, parsedReturns.error)]);
36565
+ }
36566
+ return parsedReturns.data;
36567
+ });
36568
+ }
36569
+ }
36570
+ parameters() {
36571
+ return this._def.args;
36572
+ }
36573
+ returnType() {
36574
+ return this._def.returns;
36575
+ }
36576
+ args(...items) {
36577
+ return new ZodFunction2({
36578
+ ...this._def,
36579
+ args: ZodTuple2.create(items).rest(ZodUnknown3.create())
36580
+ });
36581
+ }
36582
+ returns(returnType) {
36583
+ return new ZodFunction2({
36584
+ ...this._def,
36585
+ returns: returnType
36586
+ });
36587
+ }
36588
+ implement(func) {
36589
+ const validatedFunc = this.parse(func);
36590
+ return validatedFunc;
36591
+ }
36592
+ strictImplement(func) {
36593
+ const validatedFunc = this.parse(func);
36594
+ return validatedFunc;
36595
+ }
36596
+ static create(args, returns, params) {
36597
+ return new ZodFunction2({
36598
+ args: args ? args : ZodTuple2.create([]).rest(ZodUnknown3.create()),
36599
+ returns: returns || ZodUnknown3.create(),
36600
+ typeName: ZodFirstPartyTypeKind2.ZodFunction,
36601
+ ...processCreateParams(params)
36602
+ });
36603
+ }
36604
+ }
36605
+
36606
+ class ZodLazy2 extends ZodType3 {
36607
+ get schema() {
36608
+ return this._def.getter();
36609
+ }
36610
+ _parse(input) {
36611
+ const { ctx } = this._processInputParams(input);
36612
+ const lazySchema = this._def.getter();
36613
+ return lazySchema._parse({ data: ctx.data, path: ctx.path, parent: ctx });
36614
+ }
36615
+ }
36616
+ ZodLazy2.create = (getter, params) => {
36617
+ return new ZodLazy2({
36618
+ getter,
36619
+ typeName: ZodFirstPartyTypeKind2.ZodLazy,
36620
+ ...processCreateParams(params)
36621
+ });
36622
+ };
36623
+
36624
+ class ZodLiteral3 extends ZodType3 {
36625
+ _parse(input) {
36626
+ if (input.data !== this._def.value) {
36627
+ const ctx = this._getOrReturnCtx(input);
36628
+ addIssueToContext(ctx, {
36629
+ received: ctx.data,
36630
+ code: ZodIssueCode3.invalid_literal,
36631
+ expected: this._def.value
36632
+ });
36633
+ return INVALID;
36634
+ }
36635
+ return { status: "valid", value: input.data };
36636
+ }
36637
+ get value() {
36638
+ return this._def.value;
36639
+ }
36640
+ }
36641
+ ZodLiteral3.create = (value, params) => {
36642
+ return new ZodLiteral3({
36643
+ value,
36644
+ typeName: ZodFirstPartyTypeKind2.ZodLiteral,
36645
+ ...processCreateParams(params)
36646
+ });
36647
+ };
36648
+ function createZodEnum(values, params) {
36649
+ return new ZodEnum3({
36650
+ values,
36651
+ typeName: ZodFirstPartyTypeKind2.ZodEnum,
36652
+ ...processCreateParams(params)
36653
+ });
36654
+ }
36655
+
36656
+ class ZodEnum3 extends ZodType3 {
36657
+ _parse(input) {
36658
+ if (typeof input.data !== "string") {
36659
+ const ctx = this._getOrReturnCtx(input);
36660
+ const expectedValues = this._def.values;
36661
+ addIssueToContext(ctx, {
36662
+ expected: util.joinValues(expectedValues),
36663
+ received: ctx.parsedType,
36664
+ code: ZodIssueCode3.invalid_type
36665
+ });
36666
+ return INVALID;
36667
+ }
36668
+ if (!this._cache) {
36669
+ this._cache = new Set(this._def.values);
36670
+ }
36671
+ if (!this._cache.has(input.data)) {
36672
+ const ctx = this._getOrReturnCtx(input);
36673
+ const expectedValues = this._def.values;
36674
+ addIssueToContext(ctx, {
36675
+ received: ctx.data,
36676
+ code: ZodIssueCode3.invalid_enum_value,
36677
+ options: expectedValues
36678
+ });
36679
+ return INVALID;
36680
+ }
36681
+ return OK(input.data);
36682
+ }
36683
+ get options() {
36684
+ return this._def.values;
36685
+ }
36686
+ get enum() {
36687
+ const enumValues = {};
36688
+ for (const val of this._def.values) {
36689
+ enumValues[val] = val;
36690
+ }
36691
+ return enumValues;
36692
+ }
36693
+ get Values() {
36694
+ const enumValues = {};
36695
+ for (const val of this._def.values) {
36696
+ enumValues[val] = val;
36697
+ }
36698
+ return enumValues;
36699
+ }
36700
+ get Enum() {
36701
+ const enumValues = {};
36702
+ for (const val of this._def.values) {
36703
+ enumValues[val] = val;
36704
+ }
36705
+ return enumValues;
36706
+ }
36707
+ extract(values, newDef = this._def) {
36708
+ return ZodEnum3.create(values, {
36709
+ ...this._def,
36710
+ ...newDef
36711
+ });
36712
+ }
36713
+ exclude(values, newDef = this._def) {
36714
+ return ZodEnum3.create(this.options.filter((opt) => !values.includes(opt)), {
36715
+ ...this._def,
36716
+ ...newDef
36717
+ });
36718
+ }
36719
+ }
36720
+ ZodEnum3.create = createZodEnum;
36721
+
36722
+ class ZodNativeEnum extends ZodType3 {
36723
+ _parse(input) {
36724
+ const nativeEnumValues = util.getValidEnumValues(this._def.values);
36725
+ const ctx = this._getOrReturnCtx(input);
36726
+ if (ctx.parsedType !== ZodParsedType.string && ctx.parsedType !== ZodParsedType.number) {
36727
+ const expectedValues = util.objectValues(nativeEnumValues);
36728
+ addIssueToContext(ctx, {
36729
+ expected: util.joinValues(expectedValues),
36730
+ received: ctx.parsedType,
36731
+ code: ZodIssueCode3.invalid_type
36732
+ });
36733
+ return INVALID;
36734
+ }
36735
+ if (!this._cache) {
36736
+ this._cache = new Set(util.getValidEnumValues(this._def.values));
36737
+ }
36738
+ if (!this._cache.has(input.data)) {
36739
+ const expectedValues = util.objectValues(nativeEnumValues);
36740
+ addIssueToContext(ctx, {
36741
+ received: ctx.data,
36742
+ code: ZodIssueCode3.invalid_enum_value,
36743
+ options: expectedValues
36744
+ });
36745
+ return INVALID;
36746
+ }
36747
+ return OK(input.data);
36748
+ }
36749
+ get enum() {
36750
+ return this._def.values;
36751
+ }
36752
+ }
36753
+ ZodNativeEnum.create = (values, params) => {
36754
+ return new ZodNativeEnum({
36755
+ values,
36756
+ typeName: ZodFirstPartyTypeKind2.ZodNativeEnum,
36757
+ ...processCreateParams(params)
36758
+ });
36759
+ };
36760
+
36761
+ class ZodPromise2 extends ZodType3 {
36762
+ unwrap() {
36763
+ return this._def.type;
36764
+ }
36765
+ _parse(input) {
36766
+ const { ctx } = this._processInputParams(input);
36767
+ if (ctx.parsedType !== ZodParsedType.promise && ctx.common.async === false) {
36768
+ addIssueToContext(ctx, {
36769
+ code: ZodIssueCode3.invalid_type,
36770
+ expected: ZodParsedType.promise,
36771
+ received: ctx.parsedType
36772
+ });
36773
+ return INVALID;
36774
+ }
36775
+ const promisified = ctx.parsedType === ZodParsedType.promise ? ctx.data : Promise.resolve(ctx.data);
36776
+ return OK(promisified.then((data) => {
36777
+ return this._def.type.parseAsync(data, {
36778
+ path: ctx.path,
36779
+ errorMap: ctx.common.contextualErrorMap
36780
+ });
36781
+ }));
36782
+ }
36783
+ }
36784
+ ZodPromise2.create = (schema, params) => {
36785
+ return new ZodPromise2({
36786
+ type: schema,
36787
+ typeName: ZodFirstPartyTypeKind2.ZodPromise,
36788
+ ...processCreateParams(params)
36789
+ });
36790
+ };
36791
+
36792
+ class ZodEffects extends ZodType3 {
36793
+ innerType() {
36794
+ return this._def.schema;
36795
+ }
36796
+ sourceType() {
36797
+ return this._def.schema._def.typeName === ZodFirstPartyTypeKind2.ZodEffects ? this._def.schema.sourceType() : this._def.schema;
36798
+ }
36799
+ _parse(input) {
36800
+ const { status, ctx } = this._processInputParams(input);
36801
+ const effect = this._def.effect || null;
36802
+ const checkCtx = {
36803
+ addIssue: (arg) => {
36804
+ addIssueToContext(ctx, arg);
36805
+ if (arg.fatal) {
36806
+ status.abort();
36807
+ } else {
36808
+ status.dirty();
36809
+ }
36810
+ },
36811
+ get path() {
36812
+ return ctx.path;
36813
+ }
36814
+ };
36815
+ checkCtx.addIssue = checkCtx.addIssue.bind(checkCtx);
36816
+ if (effect.type === "preprocess") {
36817
+ const processed = effect.transform(ctx.data, checkCtx);
36818
+ if (ctx.common.async) {
36819
+ return Promise.resolve(processed).then(async (processed2) => {
36820
+ if (status.value === "aborted")
36821
+ return INVALID;
36822
+ const result = await this._def.schema._parseAsync({
36823
+ data: processed2,
36824
+ path: ctx.path,
36825
+ parent: ctx
36826
+ });
36827
+ if (result.status === "aborted")
36828
+ return INVALID;
36829
+ if (result.status === "dirty")
36830
+ return DIRTY(result.value);
36831
+ if (status.value === "dirty")
36832
+ return DIRTY(result.value);
36833
+ return result;
36834
+ });
36835
+ } else {
36836
+ if (status.value === "aborted")
36837
+ return INVALID;
36838
+ const result = this._def.schema._parseSync({
36839
+ data: processed,
36840
+ path: ctx.path,
36841
+ parent: ctx
36842
+ });
36843
+ if (result.status === "aborted")
36844
+ return INVALID;
36845
+ if (result.status === "dirty")
36846
+ return DIRTY(result.value);
36847
+ if (status.value === "dirty")
36848
+ return DIRTY(result.value);
36849
+ return result;
36850
+ }
36851
+ }
36852
+ if (effect.type === "refinement") {
36853
+ const executeRefinement = (acc) => {
36854
+ const result = effect.refinement(acc, checkCtx);
36855
+ if (ctx.common.async) {
36856
+ return Promise.resolve(result);
36857
+ }
36858
+ if (result instanceof Promise) {
36859
+ throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");
36860
+ }
36861
+ return acc;
36862
+ };
36863
+ if (ctx.common.async === false) {
36864
+ const inner = this._def.schema._parseSync({
36865
+ data: ctx.data,
36866
+ path: ctx.path,
36867
+ parent: ctx
36868
+ });
36869
+ if (inner.status === "aborted")
36870
+ return INVALID;
36871
+ if (inner.status === "dirty")
36872
+ status.dirty();
36873
+ executeRefinement(inner.value);
36874
+ return { status: status.value, value: inner.value };
36875
+ } else {
36876
+ return this._def.schema._parseAsync({ data: ctx.data, path: ctx.path, parent: ctx }).then((inner) => {
36877
+ if (inner.status === "aborted")
36878
+ return INVALID;
36879
+ if (inner.status === "dirty")
36880
+ status.dirty();
36881
+ return executeRefinement(inner.value).then(() => {
36882
+ return { status: status.value, value: inner.value };
36883
+ });
36884
+ });
36885
+ }
36886
+ }
36887
+ if (effect.type === "transform") {
36888
+ if (ctx.common.async === false) {
36889
+ const base = this._def.schema._parseSync({
36890
+ data: ctx.data,
36891
+ path: ctx.path,
36892
+ parent: ctx
36893
+ });
36894
+ if (!isValid(base))
36895
+ return INVALID;
36896
+ const result = effect.transform(base.value, checkCtx);
36897
+ if (result instanceof Promise) {
36898
+ throw new Error(`Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.`);
36899
+ }
36900
+ return { status: status.value, value: result };
36901
+ } else {
36902
+ return this._def.schema._parseAsync({ data: ctx.data, path: ctx.path, parent: ctx }).then((base) => {
36903
+ if (!isValid(base))
36904
+ return INVALID;
36905
+ return Promise.resolve(effect.transform(base.value, checkCtx)).then((result) => ({
36906
+ status: status.value,
36907
+ value: result
36908
+ }));
36909
+ });
36910
+ }
36911
+ }
36912
+ util.assertNever(effect);
36913
+ }
36914
+ }
36915
+ ZodEffects.create = (schema, effect, params) => {
36916
+ return new ZodEffects({
36917
+ schema,
36918
+ typeName: ZodFirstPartyTypeKind2.ZodEffects,
36919
+ effect,
36920
+ ...processCreateParams(params)
36921
+ });
36922
+ };
36923
+ ZodEffects.createWithPreprocess = (preprocess3, schema, params) => {
36924
+ return new ZodEffects({
36925
+ schema,
36926
+ effect: { type: "preprocess", transform: preprocess3 },
36927
+ typeName: ZodFirstPartyTypeKind2.ZodEffects,
36928
+ ...processCreateParams(params)
36929
+ });
36930
+ };
36931
+ class ZodOptional3 extends ZodType3 {
36932
+ _parse(input) {
36933
+ const parsedType3 = this._getType(input);
36934
+ if (parsedType3 === ZodParsedType.undefined) {
36935
+ return OK(undefined);
36936
+ }
36937
+ return this._def.innerType._parse(input);
36938
+ }
36939
+ unwrap() {
36940
+ return this._def.innerType;
36941
+ }
36942
+ }
36943
+ ZodOptional3.create = (type, params) => {
36944
+ return new ZodOptional3({
36945
+ innerType: type,
36946
+ typeName: ZodFirstPartyTypeKind2.ZodOptional,
36947
+ ...processCreateParams(params)
36948
+ });
36949
+ };
36950
+
36951
+ class ZodNullable3 extends ZodType3 {
36952
+ _parse(input) {
36953
+ const parsedType3 = this._getType(input);
36954
+ if (parsedType3 === ZodParsedType.null) {
36955
+ return OK(null);
36956
+ }
36957
+ return this._def.innerType._parse(input);
36958
+ }
36959
+ unwrap() {
36960
+ return this._def.innerType;
36961
+ }
36962
+ }
36963
+ ZodNullable3.create = (type, params) => {
36964
+ return new ZodNullable3({
36965
+ innerType: type,
36966
+ typeName: ZodFirstPartyTypeKind2.ZodNullable,
36967
+ ...processCreateParams(params)
36968
+ });
36969
+ };
36970
+
36971
+ class ZodDefault3 extends ZodType3 {
36972
+ _parse(input) {
36973
+ const { ctx } = this._processInputParams(input);
36974
+ let data = ctx.data;
36975
+ if (ctx.parsedType === ZodParsedType.undefined) {
36976
+ data = this._def.defaultValue();
36977
+ }
36978
+ return this._def.innerType._parse({
36979
+ data,
36980
+ path: ctx.path,
36981
+ parent: ctx
36982
+ });
36983
+ }
36984
+ removeDefault() {
36985
+ return this._def.innerType;
36986
+ }
36987
+ }
36988
+ ZodDefault3.create = (type, params) => {
36989
+ return new ZodDefault3({
36990
+ innerType: type,
36991
+ typeName: ZodFirstPartyTypeKind2.ZodDefault,
36992
+ defaultValue: typeof params.default === "function" ? params.default : () => params.default,
36993
+ ...processCreateParams(params)
36994
+ });
36995
+ };
36996
+
36997
+ class ZodCatch3 extends ZodType3 {
36998
+ _parse(input) {
36999
+ const { ctx } = this._processInputParams(input);
37000
+ const newCtx = {
37001
+ ...ctx,
37002
+ common: {
37003
+ ...ctx.common,
37004
+ issues: []
37005
+ }
37006
+ };
37007
+ const result = this._def.innerType._parse({
37008
+ data: newCtx.data,
37009
+ path: newCtx.path,
37010
+ parent: {
37011
+ ...newCtx
37012
+ }
37013
+ });
37014
+ if (isAsync(result)) {
37015
+ return result.then((result2) => {
37016
+ return {
37017
+ status: "valid",
37018
+ value: result2.status === "valid" ? result2.value : this._def.catchValue({
37019
+ get error() {
37020
+ return new ZodError3(newCtx.common.issues);
37021
+ },
37022
+ input: newCtx.data
37023
+ })
37024
+ };
37025
+ });
37026
+ } else {
37027
+ return {
37028
+ status: "valid",
37029
+ value: result.status === "valid" ? result.value : this._def.catchValue({
37030
+ get error() {
37031
+ return new ZodError3(newCtx.common.issues);
37032
+ },
37033
+ input: newCtx.data
37034
+ })
37035
+ };
37036
+ }
37037
+ }
37038
+ removeCatch() {
37039
+ return this._def.innerType;
37040
+ }
37041
+ }
37042
+ ZodCatch3.create = (type, params) => {
37043
+ return new ZodCatch3({
37044
+ innerType: type,
37045
+ typeName: ZodFirstPartyTypeKind2.ZodCatch,
37046
+ catchValue: typeof params.catch === "function" ? params.catch : () => params.catch,
37047
+ ...processCreateParams(params)
37048
+ });
37049
+ };
37050
+
37051
+ class ZodNaN2 extends ZodType3 {
37052
+ _parse(input) {
37053
+ const parsedType3 = this._getType(input);
37054
+ if (parsedType3 !== ZodParsedType.nan) {
37055
+ const ctx = this._getOrReturnCtx(input);
37056
+ addIssueToContext(ctx, {
37057
+ code: ZodIssueCode3.invalid_type,
37058
+ expected: ZodParsedType.nan,
37059
+ received: ctx.parsedType
37060
+ });
37061
+ return INVALID;
37062
+ }
37063
+ return { status: "valid", value: input.data };
37064
+ }
37065
+ }
37066
+ ZodNaN2.create = (params) => {
37067
+ return new ZodNaN2({
37068
+ typeName: ZodFirstPartyTypeKind2.ZodNaN,
37069
+ ...processCreateParams(params)
37070
+ });
37071
+ };
37072
+ var BRAND = Symbol("zod_brand");
37073
+
37074
+ class ZodBranded extends ZodType3 {
37075
+ _parse(input) {
37076
+ const { ctx } = this._processInputParams(input);
37077
+ const data = ctx.data;
37078
+ return this._def.type._parse({
37079
+ data,
37080
+ path: ctx.path,
37081
+ parent: ctx
37082
+ });
37083
+ }
37084
+ unwrap() {
37085
+ return this._def.type;
37086
+ }
37087
+ }
37088
+
37089
+ class ZodPipeline extends ZodType3 {
37090
+ _parse(input) {
37091
+ const { status, ctx } = this._processInputParams(input);
37092
+ if (ctx.common.async) {
37093
+ const handleAsync = async () => {
37094
+ const inResult = await this._def.in._parseAsync({
37095
+ data: ctx.data,
37096
+ path: ctx.path,
37097
+ parent: ctx
37098
+ });
37099
+ if (inResult.status === "aborted")
37100
+ return INVALID;
37101
+ if (inResult.status === "dirty") {
37102
+ status.dirty();
37103
+ return DIRTY(inResult.value);
37104
+ } else {
37105
+ return this._def.out._parseAsync({
37106
+ data: inResult.value,
37107
+ path: ctx.path,
37108
+ parent: ctx
37109
+ });
37110
+ }
37111
+ };
37112
+ return handleAsync();
37113
+ } else {
37114
+ const inResult = this._def.in._parseSync({
37115
+ data: ctx.data,
37116
+ path: ctx.path,
37117
+ parent: ctx
37118
+ });
37119
+ if (inResult.status === "aborted")
37120
+ return INVALID;
37121
+ if (inResult.status === "dirty") {
37122
+ status.dirty();
37123
+ return {
37124
+ status: "dirty",
37125
+ value: inResult.value
37126
+ };
37127
+ } else {
37128
+ return this._def.out._parseSync({
37129
+ data: inResult.value,
37130
+ path: ctx.path,
37131
+ parent: ctx
37132
+ });
37133
+ }
37134
+ }
37135
+ }
37136
+ static create(a, b) {
37137
+ return new ZodPipeline({
37138
+ in: a,
37139
+ out: b,
37140
+ typeName: ZodFirstPartyTypeKind2.ZodPipeline
37141
+ });
37142
+ }
37143
+ }
37144
+
37145
+ class ZodReadonly3 extends ZodType3 {
37146
+ _parse(input) {
37147
+ const result = this._def.innerType._parse(input);
37148
+ const freeze = (data) => {
37149
+ if (isValid(data)) {
37150
+ data.value = Object.freeze(data.value);
37151
+ }
37152
+ return data;
37153
+ };
37154
+ return isAsync(result) ? result.then((data) => freeze(data)) : freeze(result);
37155
+ }
37156
+ unwrap() {
37157
+ return this._def.innerType;
37158
+ }
37159
+ }
37160
+ ZodReadonly3.create = (type, params) => {
37161
+ return new ZodReadonly3({
37162
+ innerType: type,
37163
+ typeName: ZodFirstPartyTypeKind2.ZodReadonly,
37164
+ ...processCreateParams(params)
37165
+ });
37166
+ };
37167
+ function cleanParams(params, data) {
37168
+ const p = typeof params === "function" ? params(data) : typeof params === "string" ? { message: params } : params;
37169
+ const p2 = typeof p === "string" ? { message: p } : p;
37170
+ return p2;
37171
+ }
37172
+ function custom3(check3, _params = {}, fatal) {
37173
+ if (check3)
37174
+ return ZodAny3.create().superRefine((data, ctx) => {
37175
+ const r = check3(data);
37176
+ if (r instanceof Promise) {
37177
+ return r.then((r2) => {
37178
+ if (!r2) {
37179
+ const params = cleanParams(_params, data);
37180
+ const _fatal = params.fatal ?? fatal ?? true;
37181
+ ctx.addIssue({ code: "custom", ...params, fatal: _fatal });
37182
+ }
37183
+ });
37184
+ }
37185
+ if (!r) {
37186
+ const params = cleanParams(_params, data);
37187
+ const _fatal = params.fatal ?? fatal ?? true;
37188
+ ctx.addIssue({ code: "custom", ...params, fatal: _fatal });
37189
+ }
37190
+ return;
37191
+ });
37192
+ return ZodAny3.create();
37193
+ }
37194
+ var late = {
37195
+ object: ZodObject3.lazycreate
37196
+ };
37197
+ var ZodFirstPartyTypeKind2;
37198
+ (function(ZodFirstPartyTypeKind3) {
37199
+ ZodFirstPartyTypeKind3["ZodString"] = "ZodString";
37200
+ ZodFirstPartyTypeKind3["ZodNumber"] = "ZodNumber";
37201
+ ZodFirstPartyTypeKind3["ZodNaN"] = "ZodNaN";
37202
+ ZodFirstPartyTypeKind3["ZodBigInt"] = "ZodBigInt";
37203
+ ZodFirstPartyTypeKind3["ZodBoolean"] = "ZodBoolean";
37204
+ ZodFirstPartyTypeKind3["ZodDate"] = "ZodDate";
37205
+ ZodFirstPartyTypeKind3["ZodSymbol"] = "ZodSymbol";
37206
+ ZodFirstPartyTypeKind3["ZodUndefined"] = "ZodUndefined";
37207
+ ZodFirstPartyTypeKind3["ZodNull"] = "ZodNull";
37208
+ ZodFirstPartyTypeKind3["ZodAny"] = "ZodAny";
37209
+ ZodFirstPartyTypeKind3["ZodUnknown"] = "ZodUnknown";
37210
+ ZodFirstPartyTypeKind3["ZodNever"] = "ZodNever";
37211
+ ZodFirstPartyTypeKind3["ZodVoid"] = "ZodVoid";
37212
+ ZodFirstPartyTypeKind3["ZodArray"] = "ZodArray";
37213
+ ZodFirstPartyTypeKind3["ZodObject"] = "ZodObject";
37214
+ ZodFirstPartyTypeKind3["ZodUnion"] = "ZodUnion";
37215
+ ZodFirstPartyTypeKind3["ZodDiscriminatedUnion"] = "ZodDiscriminatedUnion";
37216
+ ZodFirstPartyTypeKind3["ZodIntersection"] = "ZodIntersection";
37217
+ ZodFirstPartyTypeKind3["ZodTuple"] = "ZodTuple";
37218
+ ZodFirstPartyTypeKind3["ZodRecord"] = "ZodRecord";
37219
+ ZodFirstPartyTypeKind3["ZodMap"] = "ZodMap";
37220
+ ZodFirstPartyTypeKind3["ZodSet"] = "ZodSet";
37221
+ ZodFirstPartyTypeKind3["ZodFunction"] = "ZodFunction";
37222
+ ZodFirstPartyTypeKind3["ZodLazy"] = "ZodLazy";
37223
+ ZodFirstPartyTypeKind3["ZodLiteral"] = "ZodLiteral";
37224
+ ZodFirstPartyTypeKind3["ZodEnum"] = "ZodEnum";
37225
+ ZodFirstPartyTypeKind3["ZodEffects"] = "ZodEffects";
37226
+ ZodFirstPartyTypeKind3["ZodNativeEnum"] = "ZodNativeEnum";
37227
+ ZodFirstPartyTypeKind3["ZodOptional"] = "ZodOptional";
37228
+ ZodFirstPartyTypeKind3["ZodNullable"] = "ZodNullable";
37229
+ ZodFirstPartyTypeKind3["ZodDefault"] = "ZodDefault";
37230
+ ZodFirstPartyTypeKind3["ZodCatch"] = "ZodCatch";
37231
+ ZodFirstPartyTypeKind3["ZodPromise"] = "ZodPromise";
37232
+ ZodFirstPartyTypeKind3["ZodBranded"] = "ZodBranded";
37233
+ ZodFirstPartyTypeKind3["ZodPipeline"] = "ZodPipeline";
37234
+ ZodFirstPartyTypeKind3["ZodReadonly"] = "ZodReadonly";
37235
+ })(ZodFirstPartyTypeKind2 || (ZodFirstPartyTypeKind2 = {}));
37236
+ var instanceOfType = (cls, params = {
37237
+ message: `Input not instance of ${cls.name}`
37238
+ }) => custom3((data) => data instanceof cls, params);
37239
+ var stringType = ZodString3.create;
37240
+ var numberType = ZodNumber3.create;
37241
+ var nanType = ZodNaN2.create;
37242
+ var bigIntType = ZodBigInt3.create;
37243
+ var booleanType = ZodBoolean3.create;
37244
+ var dateType = ZodDate3.create;
37245
+ var symbolType = ZodSymbol2.create;
37246
+ var undefinedType = ZodUndefined2.create;
37247
+ var nullType = ZodNull3.create;
37248
+ var anyType = ZodAny3.create;
37249
+ var unknownType = ZodUnknown3.create;
37250
+ var neverType = ZodNever3.create;
37251
+ var voidType = ZodVoid2.create;
37252
+ var arrayType = ZodArray3.create;
37253
+ var objectType = ZodObject3.create;
37254
+ var strictObjectType = ZodObject3.strictCreate;
37255
+ var unionType = ZodUnion3.create;
37256
+ var discriminatedUnionType = ZodDiscriminatedUnion3.create;
37257
+ var intersectionType = ZodIntersection3.create;
37258
+ var tupleType = ZodTuple2.create;
37259
+ var recordType = ZodRecord3.create;
37260
+ var mapType = ZodMap2.create;
37261
+ var setType = ZodSet2.create;
37262
+ var functionType = ZodFunction2.create;
37263
+ var lazyType = ZodLazy2.create;
37264
+ var literalType = ZodLiteral3.create;
37265
+ var enumType = ZodEnum3.create;
37266
+ var nativeEnumType = ZodNativeEnum.create;
37267
+ var promiseType = ZodPromise2.create;
37268
+ var effectsType = ZodEffects.create;
37269
+ var optionalType = ZodOptional3.create;
37270
+ var nullableType = ZodNullable3.create;
37271
+ var preprocessType = ZodEffects.createWithPreprocess;
37272
+ var pipelineType = ZodPipeline.create;
37273
+ var ostring = () => stringType().optional();
37274
+ var onumber = () => numberType().optional();
37275
+ var oboolean = () => booleanType().optional();
37276
+ var coerce = {
37277
+ string: (arg) => ZodString3.create({ ...arg, coerce: true }),
37278
+ number: (arg) => ZodNumber3.create({ ...arg, coerce: true }),
37279
+ boolean: (arg) => ZodBoolean3.create({
37280
+ ...arg,
37281
+ coerce: true
37282
+ }),
37283
+ bigint: (arg) => ZodBigInt3.create({ ...arg, coerce: true }),
37284
+ date: (arg) => ZodDate3.create({ ...arg, coerce: true })
37285
+ };
37286
+ var NEVER3 = INVALID;
33313
37287
  // node_modules/@modelcontextprotocol/sdk/dist/esm/server/zod-compat.js
33314
37288
  function isZ4Schema(s) {
33315
37289
  const schema = s;
@@ -37029,12 +41003,23 @@ async function executeTool(options) {
37029
41003
  args,
37030
41004
  timeoutMs
37031
41005
  });
41006
+ const raw = result?.raw;
41007
+ if (raw && typeof raw === "object" && raw.isError === true) {
41008
+ const content = raw.content;
41009
+ const msg = Array.isArray(content) && content[0] && typeof content[0].text === "string" ? String(content[0].text) : "Tool returned error";
41010
+ throw new Error(msg);
41011
+ }
37032
41012
  printResult(result);
37033
41013
  }
37034
41014
 
41015
+ // src/constants.ts
41016
+ var CLI_NAME = "vpai";
41017
+ var CLI_DESCRIPTION = "Find company & contact data. Build lead lists, research prospects, identify talent. 150M+ companies, 800M+ professionals.";
41018
+ var DEFAULT_SERVER_NAME = "vpai";
41019
+
37035
41020
  // src/embedded-config.ts
37036
41021
  var EMBEDDED_SERVER = {
37037
- name: "vpai",
41022
+ name: DEFAULT_SERVER_NAME,
37038
41023
  description: "Explorium research MCP (production)",
37039
41024
  command: {
37040
41025
  kind: "http",
@@ -37053,29 +41038,72 @@ async function ensureRuntime() {
37053
41038
  });
37054
41039
  }
37055
41040
 
41041
+ // src/logger.ts
41042
+ function formatEntry(level, message, meta3) {
41043
+ const entry = {
41044
+ level,
41045
+ message,
41046
+ timestamp: new Date().toISOString(),
41047
+ ...meta3
41048
+ };
41049
+ return JSON.stringify(entry);
41050
+ }
41051
+ var logger = {
41052
+ error(message, meta3) {
41053
+ console.error(formatEntry("error", message, meta3));
41054
+ },
41055
+ warn(message, meta3) {
41056
+ console.error(formatEntry("warn", message, meta3));
41057
+ },
41058
+ info(message, meta3) {
41059
+ console.error(formatEntry("info", message, meta3));
41060
+ }
41061
+ };
41062
+
37056
41063
  // src/proxy.ts
37057
41064
  var ALL_PARAMS_HELP = "Show input and output schemas instead of calling the tool. Use before --args to inspect parameters.";
37058
41065
  var ARGS_HELP = `JSON object with tool arguments. Example: --args '{"country_code":{"values":["US"]}}'`;
37059
41066
  var JSON_HELP = "With --all-parameters, output schemas as JSON.";
37060
41067
  async function registerProxyCommands(program2, ctx) {
37061
- const runtime = await ensureRuntime();
37062
- const tools = await runtime.listTools(ctx.serverName, {
37063
- includeSchema: false,
37064
- autoAuthorize: true,
37065
- allowCachedAuth: true
37066
- });
41068
+ let runtime;
41069
+ try {
41070
+ runtime = await ensureRuntime();
41071
+ } catch (error49) {
41072
+ const msg = error49 instanceof Error ? error49.message : String(error49);
41073
+ logger.error(msg, { context: "MCP runtime initialization" });
41074
+ throw error49;
41075
+ }
41076
+ let tools;
41077
+ try {
41078
+ tools = await runtime.listTools(ctx.serverName, {
41079
+ includeSchema: false,
41080
+ autoAuthorize: true,
41081
+ allowCachedAuth: true
41082
+ });
41083
+ } catch (error49) {
41084
+ const msg = error49 instanceof Error ? error49.message : String(error49);
41085
+ logger.error(msg, { serverName: ctx.serverName, context: "list tools" });
41086
+ throw error49;
41087
+ }
37067
41088
  for (const tool of tools) {
37068
41089
  const name = tool.name;
37069
41090
  const description = tool.description ?? tool.name;
37070
41091
  program2.command(name).description(description).usage("[options]").option("--all-parameters", ALL_PARAMS_HELP).option("--args <json>", ARGS_HELP).option("--json", JSON_HELP).action(async (cmdOpts) => {
37071
- const runtime2 = await ensureRuntime();
37072
41092
  try {
37073
41093
  if (cmdOpts.allParameters && !cmdOpts.args) {
37074
- const resolved = await resolveToolSchema({
37075
- runtime: runtime2,
37076
- serverName: ctx.serverName,
37077
- toolName: name
37078
- });
41094
+ let resolved;
41095
+ try {
41096
+ resolved = await resolveToolSchema({
41097
+ runtime,
41098
+ serverName: ctx.serverName,
41099
+ toolName: name
41100
+ });
41101
+ } catch (error49) {
41102
+ const msg = error49 instanceof Error ? error49.message : String(error49);
41103
+ logger.error(msg, { toolName: name, serverName: ctx.serverName });
41104
+ process.exitCode = 1;
41105
+ return;
41106
+ }
37079
41107
  if (resolved) {
37080
41108
  printToolSchemas({
37081
41109
  toolName: resolved.name,
@@ -37085,65 +41113,105 @@ async function registerProxyCommands(program2, ctx) {
37085
41113
  asJson: Boolean(cmdOpts.json)
37086
41114
  });
37087
41115
  } else {
37088
- console.error(`Tool '${name}' not found.`);
41116
+ logger.error("Tool not found", { toolName: name, serverName: ctx.serverName });
37089
41117
  process.exitCode = 1;
37090
41118
  }
37091
41119
  return;
37092
41120
  }
37093
- const args = cmdOpts.args ? JSON.parse(cmdOpts.args) : {};
37094
- await executeTool({
37095
- runtime: runtime2,
37096
- serverName: ctx.serverName,
37097
- toolName: name,
37098
- args,
37099
- timeoutMs: ctx.defaultTimeout
37100
- });
37101
- } finally {
37102
- await runtime2.close(ctx.serverName).catch(() => {});
41121
+ let args = {};
41122
+ if (cmdOpts.args != null) {
41123
+ let parsed;
41124
+ try {
41125
+ parsed = JSON.parse(cmdOpts.args);
41126
+ } catch (error49) {
41127
+ const msg = error49 instanceof Error ? error49.message : String(error49);
41128
+ logger.error(msg, { args: cmdOpts.args });
41129
+ process.exitCode = 1;
41130
+ return;
41131
+ }
41132
+ if (typeof parsed !== "object" || parsed === null || Array.isArray(parsed)) {
41133
+ logger.error("--args must be a JSON object", { args: cmdOpts.args });
41134
+ process.exitCode = 1;
41135
+ return;
41136
+ }
41137
+ args = parsed;
41138
+ }
41139
+ try {
41140
+ await executeTool({
41141
+ runtime,
41142
+ serverName: ctx.serverName,
41143
+ toolName: name,
41144
+ args,
41145
+ timeoutMs: ctx.defaultTimeout
41146
+ });
41147
+ } catch (error49) {
41148
+ const msg = error49 instanceof Error ? error49.message : String(error49);
41149
+ logger.error(`Tool call failed: ${msg}`, { toolName: name, serverName: ctx.serverName });
41150
+ process.exitCode = 1;
41151
+ }
41152
+ } catch (error49) {
41153
+ const msg = error49 instanceof Error ? error49.message : String(error49);
41154
+ logger.error(`Command failed: ${msg}`, { toolName: name });
41155
+ process.exitCode = 1;
37103
41156
  }
37104
41157
  });
37105
41158
  }
37106
- await runtime.close(ctx.serverName).catch(() => {});
41159
+ return runtime;
37107
41160
  }
37108
-
37109
41161
  // src/config.ts
41162
+ var TIMEOUT_MIN_MS = 1000;
41163
+ var TIMEOUT_MAX_MS = 600000;
41164
+ var CliConfigSchema = exports_external2.object({
41165
+ timeout: exports_external2.number().min(TIMEOUT_MIN_MS, `timeout must be at least ${TIMEOUT_MIN_MS}ms`).max(TIMEOUT_MAX_MS, `timeout must be at most ${TIMEOUT_MAX_MS}ms`).describe("Request timeout in ms (1s-10m)")
41166
+ });
37110
41167
  function loadConfig() {
37111
- return { ...EMBEDDED_CLI_CONFIG };
41168
+ const raw = { ...EMBEDDED_CLI_CONFIG };
41169
+ return CliConfigSchema.parse(raw);
37112
41170
  }
37113
41171
 
37114
41172
  // src/cli.ts
37115
- var EMBEDDED_NAME = "vpai";
37116
- var EMBEDDED_DESCRIPTION = "Find company & contact data. Build lead lists, research prospects, identify talent. 150M+ companies, 800M+ professionals.";
41173
+ function closeRuntime(runtime, serverName) {
41174
+ runtime.close(serverName).catch((err) => {
41175
+ logger.warn("Failed to close runtime", {
41176
+ serverName,
41177
+ error: err instanceof Error ? err.message : String(err)
41178
+ });
41179
+ });
41180
+ }
37117
41181
  var config3 = loadConfig();
37118
41182
  var program2 = new Command;
37119
- program2.name(EMBEDDED_NAME);
37120
- program2.description(EMBEDDED_DESCRIPTION);
41183
+ program2.name(CLI_NAME);
41184
+ program2.description(CLI_DESCRIPTION);
37121
41185
  program2.addHelpText("before", `
37122
41186
  Workflow (run in order):
37123
- 1. vpai --help Discover available tools and descriptions
37124
- 2. vpai <tool> --all-parameters Inspect input/output JSON schema before executing
37125
- 3. vpai <tool> --args '<json>' Execute tool with JSON arguments matching the schema
41187
+ 1. ${CLI_NAME} --help Discover available tools and descriptions
41188
+ 2. ${CLI_NAME} <tool> --all-parameters Inspect input/output JSON schema before executing
41189
+ 3. ${CLI_NAME} <tool> --args '<json>' Execute tool with JSON arguments matching the schema
37126
41190
 
37127
41191
  Examples:
37128
- vpai --help
37129
- vpai match-business --all-parameters
37130
- vpai match-business --args '{"businesses_to_match":[{"name":"Google"}]}'
41192
+ ${CLI_NAME} --help
41193
+ ${CLI_NAME} match-business --all-parameters
41194
+ ${CLI_NAME} match-business --args '{"businesses_to_match":[{"name":"Google"}]}'
37131
41195
 
37132
41196
  `);
37133
- var ctx = { serverName: "vpai", defaultTimeout: config3.timeout };
41197
+ var ctx = { serverName: DEFAULT_SERVER_NAME, defaultTimeout: config3.timeout };
37134
41198
  async function runCli() {
37135
- await registerProxyCommands(program2, ctx);
37136
- const args = process.argv.slice(2);
37137
- if (args.length === 0) {
37138
- program2.outputHelp();
37139
- return;
41199
+ const runtime = await registerProxyCommands(program2, ctx);
41200
+ try {
41201
+ const args = process.argv.slice(2);
41202
+ if (args.length === 0) {
41203
+ program2.outputHelp();
41204
+ return;
41205
+ }
41206
+ await program2.parseAsync(process.argv);
41207
+ } finally {
41208
+ closeRuntime(runtime, ctx.serverName);
37140
41209
  }
37141
- await program2.parseAsync(process.argv);
37142
41210
  }
37143
41211
  if (process.env.MCPORTER_DISABLE_AUTORUN !== "1") {
37144
41212
  runCli().catch((error49) => {
37145
41213
  const message = error49 instanceof Error ? error49.message : String(error49);
37146
- console.error(message);
37147
- process.exit(1);
41214
+ logger.error(`CLI execution failed: ${message}`, { context: "CLI execution" });
41215
+ process.exitCode = 1;
37148
41216
  });
37149
41217
  }