@fre4x/yahoo-finance 1.0.19 → 1.0.20

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/index.js +104 -4145
  2. package/package.json +6 -4
package/dist/index.js CHANGED
@@ -1147,9 +1147,9 @@ var require_util = __commonJS({
1147
1147
  }
1148
1148
  }
1149
1149
  exports.eachItem = eachItem;
1150
- function makeMergeEvaluated({ mergeNames, mergeToName, mergeValues: mergeValues4, resultToName }) {
1150
+ function makeMergeEvaluated({ mergeNames, mergeToName, mergeValues: mergeValues3, resultToName }) {
1151
1151
  return (gen, from, to, toName) => {
1152
- const res = to === void 0 ? 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);
1152
+ const res = to === void 0 ? 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);
1153
1153
  return toName === codegen_1.Name && !(res instanceof codegen_1.Name) ? resultToName(gen, res) : res;
1154
1154
  };
1155
1155
  }
@@ -7777,14 +7777,14 @@ var require_utilHelper = __commonJS({
7777
7777
  }
7778
7778
  function tryReadingCustomSymbolFromUtilInspect(options3) {
7779
7779
  const _requireUtil = options3.requireUtil || requireUtil;
7780
- const util3 = _requireUtil();
7781
- return util3 ? util3.inspect.custom : null;
7780
+ const util2 = _requireUtil();
7781
+ return util2 ? util2.inspect.custom : null;
7782
7782
  }
7783
7783
  exports.getUtilInspect = function getUtilInspect(fallback, options3 = {}) {
7784
7784
  const _requireUtil = options3.requireUtil || requireUtil;
7785
- const util3 = _requireUtil();
7785
+ const util2 = _requireUtil();
7786
7786
  return function inspect(value, showHidden, depth) {
7787
- return util3 ? util3.inspect(value, showHidden, depth) : fallback(value);
7787
+ return util2 ? util2.inspect(value, showHidden, depth) : fallback(value);
7788
7788
  };
7789
7789
  };
7790
7790
  exports.getCustomInspectSymbol = function getCustomInspectSymbol(options3 = {}) {
@@ -7814,8 +7814,8 @@ var require_memstore = __commonJS({
7814
7814
  }
7815
7815
  }
7816
7816
  inspect() {
7817
- const util3 = { inspect: getUtilInspect(inspectFallback) };
7818
- return `{ idx: ${util3.inspect(this.idx, false, 2)} }`;
7817
+ const util2 = { inspect: getUtilInspect(inspectFallback) };
7818
+ return `{ idx: ${util2.inspect(this.idx, false, 2)} }`;
7819
7819
  }
7820
7820
  findCookie(domain2, path, key, cb) {
7821
7821
  if (!this.idx[domain2]) {
@@ -9242,37 +9242,37 @@ var require_cookie = __commonJS({
9242
9242
 
9243
9243
  // ../node_modules/zod/v3/helpers/util.js
9244
9244
  var util;
9245
- (function(util3) {
9246
- util3.assertEqual = (_) => {
9245
+ (function(util2) {
9246
+ util2.assertEqual = (_) => {
9247
9247
  };
9248
9248
  function assertIs2(_arg) {
9249
9249
  }
9250
- util3.assertIs = assertIs2;
9250
+ util2.assertIs = assertIs2;
9251
9251
  function assertNever2(_x) {
9252
9252
  throw new Error();
9253
9253
  }
9254
- util3.assertNever = assertNever2;
9255
- util3.arrayToEnum = (items) => {
9254
+ util2.assertNever = assertNever2;
9255
+ util2.arrayToEnum = (items) => {
9256
9256
  const obj = {};
9257
9257
  for (const item of items) {
9258
9258
  obj[item] = item;
9259
9259
  }
9260
9260
  return obj;
9261
9261
  };
9262
- util3.getValidEnumValues = (obj) => {
9263
- const validKeys = util3.objectKeys(obj).filter((k) => typeof obj[obj[k]] !== "number");
9262
+ util2.getValidEnumValues = (obj) => {
9263
+ const validKeys = util2.objectKeys(obj).filter((k) => typeof obj[obj[k]] !== "number");
9264
9264
  const filtered = {};
9265
9265
  for (const k of validKeys) {
9266
9266
  filtered[k] = obj[k];
9267
9267
  }
9268
- return util3.objectValues(filtered);
9268
+ return util2.objectValues(filtered);
9269
9269
  };
9270
- util3.objectValues = (obj) => {
9271
- return util3.objectKeys(obj).map(function(e) {
9270
+ util2.objectValues = (obj) => {
9271
+ return util2.objectKeys(obj).map(function(e) {
9272
9272
  return obj[e];
9273
9273
  });
9274
9274
  };
9275
- util3.objectKeys = typeof Object.keys === "function" ? (obj) => Object.keys(obj) : (object3) => {
9275
+ util2.objectKeys = typeof Object.keys === "function" ? (obj) => Object.keys(obj) : (object3) => {
9276
9276
  const keys = [];
9277
9277
  for (const key in object3) {
9278
9278
  if (Object.prototype.hasOwnProperty.call(object3, key)) {
@@ -9281,19 +9281,19 @@ var util;
9281
9281
  }
9282
9282
  return keys;
9283
9283
  };
9284
- util3.find = (arr, checker) => {
9284
+ util2.find = (arr, checker) => {
9285
9285
  for (const item of arr) {
9286
9286
  if (checker(item))
9287
9287
  return item;
9288
9288
  }
9289
9289
  return void 0;
9290
9290
  };
9291
- util3.isInteger = typeof Number.isInteger === "function" ? (val) => Number.isInteger(val) : (val) => typeof val === "number" && Number.isFinite(val) && Math.floor(val) === val;
9291
+ util2.isInteger = typeof Number.isInteger === "function" ? (val) => Number.isInteger(val) : (val) => typeof val === "number" && Number.isFinite(val) && Math.floor(val) === val;
9292
9292
  function joinValues2(array2, separator = " | ") {
9293
9293
  return array2.map((val) => typeof val === "string" ? `'${val}'` : val).join(separator);
9294
9294
  }
9295
- util3.joinValues = joinValues2;
9296
- util3.jsonStringifyReplacer = (_, value) => {
9295
+ util2.joinValues = joinValues2;
9296
+ util2.jsonStringifyReplacer = (_, value) => {
9297
9297
  if (typeof value === "bigint") {
9298
9298
  return value.toString();
9299
9299
  }
@@ -9301,8 +9301,8 @@ var util;
9301
9301
  };
9302
9302
  })(util || (util = {}));
9303
9303
  var objectUtil;
9304
- (function(objectUtil3) {
9305
- objectUtil3.mergeShapes = (first, second) => {
9304
+ (function(objectUtil2) {
9305
+ objectUtil2.mergeShapes = (first, second) => {
9306
9306
  return {
9307
9307
  ...first,
9308
9308
  ...second
@@ -9708,9 +9708,9 @@ var isAsync = (x) => typeof Promise !== "undefined" && x instanceof Promise;
9708
9708
 
9709
9709
  // ../node_modules/zod/v3/helpers/errorUtil.js
9710
9710
  var errorUtil;
9711
- (function(errorUtil3) {
9712
- errorUtil3.errToObj = (message) => typeof message === "string" ? { message } : message || {};
9713
- errorUtil3.toString = (message) => typeof message === "string" ? message : message?.message;
9711
+ (function(errorUtil2) {
9712
+ errorUtil2.errToObj = (message) => typeof message === "string" ? { message } : message || {};
9713
+ errorUtil2.toString = (message) => typeof message === "string" ? message : message?.message;
9714
9714
  })(errorUtil || (errorUtil = {}));
9715
9715
 
9716
9716
  // ../node_modules/zod/v3/types.js
@@ -9755,12 +9755,12 @@ var handleResult = (ctx, result) => {
9755
9755
  function processCreateParams(params) {
9756
9756
  if (!params)
9757
9757
  return {};
9758
- const { errorMap: errorMap3, invalid_type_error, required_error, description } = params;
9759
- if (errorMap3 && (invalid_type_error || required_error)) {
9758
+ const { errorMap: errorMap2, invalid_type_error, required_error, description } = params;
9759
+ if (errorMap2 && (invalid_type_error || required_error)) {
9760
9760
  throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);
9761
9761
  }
9762
- if (errorMap3)
9763
- return { errorMap: errorMap3, description };
9762
+ if (errorMap2)
9763
+ return { errorMap: errorMap2, description };
9764
9764
  const customMap = (iss, ctx) => {
9765
9765
  const { message } = params;
9766
9766
  if (iss.code === "invalid_enum_value") {
@@ -13043,43 +13043,43 @@ var late = {
13043
13043
  object: ZodObject.lazycreate
13044
13044
  };
13045
13045
  var ZodFirstPartyTypeKind;
13046
- (function(ZodFirstPartyTypeKind4) {
13047
- ZodFirstPartyTypeKind4["ZodString"] = "ZodString";
13048
- ZodFirstPartyTypeKind4["ZodNumber"] = "ZodNumber";
13049
- ZodFirstPartyTypeKind4["ZodNaN"] = "ZodNaN";
13050
- ZodFirstPartyTypeKind4["ZodBigInt"] = "ZodBigInt";
13051
- ZodFirstPartyTypeKind4["ZodBoolean"] = "ZodBoolean";
13052
- ZodFirstPartyTypeKind4["ZodDate"] = "ZodDate";
13053
- ZodFirstPartyTypeKind4["ZodSymbol"] = "ZodSymbol";
13054
- ZodFirstPartyTypeKind4["ZodUndefined"] = "ZodUndefined";
13055
- ZodFirstPartyTypeKind4["ZodNull"] = "ZodNull";
13056
- ZodFirstPartyTypeKind4["ZodAny"] = "ZodAny";
13057
- ZodFirstPartyTypeKind4["ZodUnknown"] = "ZodUnknown";
13058
- ZodFirstPartyTypeKind4["ZodNever"] = "ZodNever";
13059
- ZodFirstPartyTypeKind4["ZodVoid"] = "ZodVoid";
13060
- ZodFirstPartyTypeKind4["ZodArray"] = "ZodArray";
13061
- ZodFirstPartyTypeKind4["ZodObject"] = "ZodObject";
13062
- ZodFirstPartyTypeKind4["ZodUnion"] = "ZodUnion";
13063
- ZodFirstPartyTypeKind4["ZodDiscriminatedUnion"] = "ZodDiscriminatedUnion";
13064
- ZodFirstPartyTypeKind4["ZodIntersection"] = "ZodIntersection";
13065
- ZodFirstPartyTypeKind4["ZodTuple"] = "ZodTuple";
13066
- ZodFirstPartyTypeKind4["ZodRecord"] = "ZodRecord";
13067
- ZodFirstPartyTypeKind4["ZodMap"] = "ZodMap";
13068
- ZodFirstPartyTypeKind4["ZodSet"] = "ZodSet";
13069
- ZodFirstPartyTypeKind4["ZodFunction"] = "ZodFunction";
13070
- ZodFirstPartyTypeKind4["ZodLazy"] = "ZodLazy";
13071
- ZodFirstPartyTypeKind4["ZodLiteral"] = "ZodLiteral";
13072
- ZodFirstPartyTypeKind4["ZodEnum"] = "ZodEnum";
13073
- ZodFirstPartyTypeKind4["ZodEffects"] = "ZodEffects";
13074
- ZodFirstPartyTypeKind4["ZodNativeEnum"] = "ZodNativeEnum";
13075
- ZodFirstPartyTypeKind4["ZodOptional"] = "ZodOptional";
13076
- ZodFirstPartyTypeKind4["ZodNullable"] = "ZodNullable";
13077
- ZodFirstPartyTypeKind4["ZodDefault"] = "ZodDefault";
13078
- ZodFirstPartyTypeKind4["ZodCatch"] = "ZodCatch";
13079
- ZodFirstPartyTypeKind4["ZodPromise"] = "ZodPromise";
13080
- ZodFirstPartyTypeKind4["ZodBranded"] = "ZodBranded";
13081
- ZodFirstPartyTypeKind4["ZodPipeline"] = "ZodPipeline";
13082
- ZodFirstPartyTypeKind4["ZodReadonly"] = "ZodReadonly";
13046
+ (function(ZodFirstPartyTypeKind3) {
13047
+ ZodFirstPartyTypeKind3["ZodString"] = "ZodString";
13048
+ ZodFirstPartyTypeKind3["ZodNumber"] = "ZodNumber";
13049
+ ZodFirstPartyTypeKind3["ZodNaN"] = "ZodNaN";
13050
+ ZodFirstPartyTypeKind3["ZodBigInt"] = "ZodBigInt";
13051
+ ZodFirstPartyTypeKind3["ZodBoolean"] = "ZodBoolean";
13052
+ ZodFirstPartyTypeKind3["ZodDate"] = "ZodDate";
13053
+ ZodFirstPartyTypeKind3["ZodSymbol"] = "ZodSymbol";
13054
+ ZodFirstPartyTypeKind3["ZodUndefined"] = "ZodUndefined";
13055
+ ZodFirstPartyTypeKind3["ZodNull"] = "ZodNull";
13056
+ ZodFirstPartyTypeKind3["ZodAny"] = "ZodAny";
13057
+ ZodFirstPartyTypeKind3["ZodUnknown"] = "ZodUnknown";
13058
+ ZodFirstPartyTypeKind3["ZodNever"] = "ZodNever";
13059
+ ZodFirstPartyTypeKind3["ZodVoid"] = "ZodVoid";
13060
+ ZodFirstPartyTypeKind3["ZodArray"] = "ZodArray";
13061
+ ZodFirstPartyTypeKind3["ZodObject"] = "ZodObject";
13062
+ ZodFirstPartyTypeKind3["ZodUnion"] = "ZodUnion";
13063
+ ZodFirstPartyTypeKind3["ZodDiscriminatedUnion"] = "ZodDiscriminatedUnion";
13064
+ ZodFirstPartyTypeKind3["ZodIntersection"] = "ZodIntersection";
13065
+ ZodFirstPartyTypeKind3["ZodTuple"] = "ZodTuple";
13066
+ ZodFirstPartyTypeKind3["ZodRecord"] = "ZodRecord";
13067
+ ZodFirstPartyTypeKind3["ZodMap"] = "ZodMap";
13068
+ ZodFirstPartyTypeKind3["ZodSet"] = "ZodSet";
13069
+ ZodFirstPartyTypeKind3["ZodFunction"] = "ZodFunction";
13070
+ ZodFirstPartyTypeKind3["ZodLazy"] = "ZodLazy";
13071
+ ZodFirstPartyTypeKind3["ZodLiteral"] = "ZodLiteral";
13072
+ ZodFirstPartyTypeKind3["ZodEnum"] = "ZodEnum";
13073
+ ZodFirstPartyTypeKind3["ZodEffects"] = "ZodEffects";
13074
+ ZodFirstPartyTypeKind3["ZodNativeEnum"] = "ZodNativeEnum";
13075
+ ZodFirstPartyTypeKind3["ZodOptional"] = "ZodOptional";
13076
+ ZodFirstPartyTypeKind3["ZodNullable"] = "ZodNullable";
13077
+ ZodFirstPartyTypeKind3["ZodDefault"] = "ZodDefault";
13078
+ ZodFirstPartyTypeKind3["ZodCatch"] = "ZodCatch";
13079
+ ZodFirstPartyTypeKind3["ZodPromise"] = "ZodPromise";
13080
+ ZodFirstPartyTypeKind3["ZodBranded"] = "ZodBranded";
13081
+ ZodFirstPartyTypeKind3["ZodPipeline"] = "ZodPipeline";
13082
+ ZodFirstPartyTypeKind3["ZodReadonly"] = "ZodReadonly";
13083
13083
  })(ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {}));
13084
13084
  var stringType = ZodString.create;
13085
13085
  var numberType = ZodNumber.create;
@@ -14491,8 +14491,8 @@ function datetime(args) {
14491
14491
  opts.push("");
14492
14492
  if (args.offset)
14493
14493
  opts.push(`([+-](?:[01]\\d|2[0-3]):[0-5]\\d)`);
14494
- const timeRegex3 = `${time3}(?:${opts.join("|")})`;
14495
- return new RegExp(`^${dateSource}T(?:${timeRegex3})$`);
14494
+ const timeRegex2 = `${time3}(?:${opts.join("|")})`;
14495
+ return new RegExp(`^${dateSource}T(?:${timeRegex2})$`);
14496
14496
  }
14497
14497
  var string = (params) => {
14498
14498
  const regex = params ? `[\\s\\S]{${params?.minimum ?? 0},${params?.maximum ?? ""}}` : `[\\s\\S]*`;
@@ -15143,14 +15143,14 @@ var $ZodType = /* @__PURE__ */ $constructor("$ZodType", (inst, def) => {
15143
15143
  });
15144
15144
  } else {
15145
15145
  const runChecks = (payload, checks2, ctx) => {
15146
- let isAborted3 = aborted(payload);
15146
+ let isAborted2 = aborted(payload);
15147
15147
  let asyncResult;
15148
15148
  for (const ch of checks2) {
15149
15149
  if (ch._zod.def.when) {
15150
15150
  const shouldRun = ch._zod.def.when(payload);
15151
15151
  if (!shouldRun)
15152
15152
  continue;
15153
- } else if (isAborted3) {
15153
+ } else if (isAborted2) {
15154
15154
  continue;
15155
15155
  }
15156
15156
  const currLen = payload.issues.length;
@@ -15164,15 +15164,15 @@ var $ZodType = /* @__PURE__ */ $constructor("$ZodType", (inst, def) => {
15164
15164
  const nextLen = payload.issues.length;
15165
15165
  if (nextLen === currLen)
15166
15166
  return;
15167
- if (!isAborted3)
15168
- isAborted3 = aborted(payload, currLen);
15167
+ if (!isAborted2)
15168
+ isAborted2 = aborted(payload, currLen);
15169
15169
  });
15170
15170
  } else {
15171
15171
  const nextLen = payload.issues.length;
15172
15172
  if (nextLen === currLen)
15173
15173
  continue;
15174
- if (!isAborted3)
15175
- isAborted3 = aborted(payload, currLen);
15174
+ if (!isAborted2)
15175
+ isAborted2 = aborted(payload, currLen);
15176
15176
  }
15177
15177
  }
15178
15178
  if (asyncResult) {
@@ -26567,7 +26567,7 @@ function getErrorMap2() {
26567
26567
  return config().customError;
26568
26568
  }
26569
26569
  var ZodFirstPartyTypeKind2;
26570
- /* @__PURE__ */ (function(ZodFirstPartyTypeKind4) {
26570
+ /* @__PURE__ */ (function(ZodFirstPartyTypeKind3) {
26571
26571
  })(ZodFirstPartyTypeKind2 || (ZodFirstPartyTypeKind2 = {}));
26572
26572
 
26573
26573
  // ../node_modules/zod/v4/classic/from-json-schema.js
@@ -32774,4047 +32774,6 @@ var StdioServerTransport = class {
32774
32774
  }
32775
32775
  };
32776
32776
 
32777
- // node_modules/zod/v3/external.js
32778
- var external_exports4 = {};
32779
- __export(external_exports4, {
32780
- BRAND: () => BRAND,
32781
- DIRTY: () => DIRTY2,
32782
- EMPTY_PATH: () => EMPTY_PATH,
32783
- INVALID: () => INVALID2,
32784
- NEVER: () => NEVER2,
32785
- OK: () => OK2,
32786
- ParseStatus: () => ParseStatus2,
32787
- Schema: () => ZodType3,
32788
- ZodAny: () => ZodAny3,
32789
- ZodArray: () => ZodArray3,
32790
- ZodBigInt: () => ZodBigInt3,
32791
- ZodBoolean: () => ZodBoolean3,
32792
- ZodBranded: () => ZodBranded2,
32793
- ZodCatch: () => ZodCatch3,
32794
- ZodDate: () => ZodDate3,
32795
- ZodDefault: () => ZodDefault3,
32796
- ZodDiscriminatedUnion: () => ZodDiscriminatedUnion3,
32797
- ZodEffects: () => ZodEffects2,
32798
- ZodEnum: () => ZodEnum3,
32799
- ZodError: () => ZodError3,
32800
- ZodFirstPartyTypeKind: () => ZodFirstPartyTypeKind3,
32801
- ZodFunction: () => ZodFunction3,
32802
- ZodIntersection: () => ZodIntersection3,
32803
- ZodIssueCode: () => ZodIssueCode3,
32804
- ZodLazy: () => ZodLazy3,
32805
- ZodLiteral: () => ZodLiteral3,
32806
- ZodMap: () => ZodMap3,
32807
- ZodNaN: () => ZodNaN3,
32808
- ZodNativeEnum: () => ZodNativeEnum2,
32809
- ZodNever: () => ZodNever3,
32810
- ZodNull: () => ZodNull3,
32811
- ZodNullable: () => ZodNullable3,
32812
- ZodNumber: () => ZodNumber3,
32813
- ZodObject: () => ZodObject3,
32814
- ZodOptional: () => ZodOptional3,
32815
- ZodParsedType: () => ZodParsedType2,
32816
- ZodPipeline: () => ZodPipeline2,
32817
- ZodPromise: () => ZodPromise3,
32818
- ZodReadonly: () => ZodReadonly3,
32819
- ZodRecord: () => ZodRecord3,
32820
- ZodSchema: () => ZodType3,
32821
- ZodSet: () => ZodSet3,
32822
- ZodString: () => ZodString3,
32823
- ZodSymbol: () => ZodSymbol3,
32824
- ZodTransformer: () => ZodEffects2,
32825
- ZodTuple: () => ZodTuple3,
32826
- ZodType: () => ZodType3,
32827
- ZodUndefined: () => ZodUndefined3,
32828
- ZodUnion: () => ZodUnion3,
32829
- ZodUnknown: () => ZodUnknown3,
32830
- ZodVoid: () => ZodVoid3,
32831
- addIssueToContext: () => addIssueToContext2,
32832
- any: () => anyType2,
32833
- array: () => arrayType2,
32834
- bigint: () => bigIntType2,
32835
- boolean: () => booleanType2,
32836
- coerce: () => coerce,
32837
- custom: () => custom2,
32838
- date: () => dateType2,
32839
- datetimeRegex: () => datetimeRegex2,
32840
- defaultErrorMap: () => en_default3,
32841
- discriminatedUnion: () => discriminatedUnionType2,
32842
- effect: () => effectsType2,
32843
- enum: () => enumType2,
32844
- function: () => functionType2,
32845
- getErrorMap: () => getErrorMap3,
32846
- getParsedType: () => getParsedType3,
32847
- instanceof: () => instanceOfType,
32848
- intersection: () => intersectionType2,
32849
- isAborted: () => isAborted2,
32850
- isAsync: () => isAsync2,
32851
- isDirty: () => isDirty2,
32852
- isValid: () => isValid2,
32853
- late: () => late2,
32854
- lazy: () => lazyType2,
32855
- literal: () => literalType2,
32856
- makeIssue: () => makeIssue2,
32857
- map: () => mapType2,
32858
- nan: () => nanType2,
32859
- nativeEnum: () => nativeEnumType2,
32860
- never: () => neverType2,
32861
- null: () => nullType2,
32862
- nullable: () => nullableType2,
32863
- number: () => numberType2,
32864
- object: () => objectType2,
32865
- objectUtil: () => objectUtil2,
32866
- oboolean: () => oboolean,
32867
- onumber: () => onumber,
32868
- optional: () => optionalType2,
32869
- ostring: () => ostring,
32870
- pipeline: () => pipelineType2,
32871
- preprocess: () => preprocessType2,
32872
- promise: () => promiseType2,
32873
- quotelessJson: () => quotelessJson,
32874
- record: () => recordType2,
32875
- set: () => setType2,
32876
- setErrorMap: () => setErrorMap2,
32877
- strictObject: () => strictObjectType2,
32878
- string: () => stringType2,
32879
- symbol: () => symbolType2,
32880
- transformer: () => effectsType2,
32881
- tuple: () => tupleType2,
32882
- undefined: () => undefinedType2,
32883
- union: () => unionType2,
32884
- unknown: () => unknownType2,
32885
- util: () => util2,
32886
- void: () => voidType2
32887
- });
32888
-
32889
- // node_modules/zod/v3/helpers/util.js
32890
- var util2;
32891
- (function(util3) {
32892
- util3.assertEqual = (_) => {
32893
- };
32894
- function assertIs2(_arg) {
32895
- }
32896
- util3.assertIs = assertIs2;
32897
- function assertNever2(_x) {
32898
- throw new Error();
32899
- }
32900
- util3.assertNever = assertNever2;
32901
- util3.arrayToEnum = (items) => {
32902
- const obj = {};
32903
- for (const item of items) {
32904
- obj[item] = item;
32905
- }
32906
- return obj;
32907
- };
32908
- util3.getValidEnumValues = (obj) => {
32909
- const validKeys = util3.objectKeys(obj).filter((k) => typeof obj[obj[k]] !== "number");
32910
- const filtered = {};
32911
- for (const k of validKeys) {
32912
- filtered[k] = obj[k];
32913
- }
32914
- return util3.objectValues(filtered);
32915
- };
32916
- util3.objectValues = (obj) => {
32917
- return util3.objectKeys(obj).map(function(e) {
32918
- return obj[e];
32919
- });
32920
- };
32921
- util3.objectKeys = typeof Object.keys === "function" ? (obj) => Object.keys(obj) : (object3) => {
32922
- const keys = [];
32923
- for (const key in object3) {
32924
- if (Object.prototype.hasOwnProperty.call(object3, key)) {
32925
- keys.push(key);
32926
- }
32927
- }
32928
- return keys;
32929
- };
32930
- util3.find = (arr, checker) => {
32931
- for (const item of arr) {
32932
- if (checker(item))
32933
- return item;
32934
- }
32935
- return void 0;
32936
- };
32937
- util3.isInteger = typeof Number.isInteger === "function" ? (val) => Number.isInteger(val) : (val) => typeof val === "number" && Number.isFinite(val) && Math.floor(val) === val;
32938
- function joinValues2(array2, separator = " | ") {
32939
- return array2.map((val) => typeof val === "string" ? `'${val}'` : val).join(separator);
32940
- }
32941
- util3.joinValues = joinValues2;
32942
- util3.jsonStringifyReplacer = (_, value) => {
32943
- if (typeof value === "bigint") {
32944
- return value.toString();
32945
- }
32946
- return value;
32947
- };
32948
- })(util2 || (util2 = {}));
32949
- var objectUtil2;
32950
- (function(objectUtil3) {
32951
- objectUtil3.mergeShapes = (first, second) => {
32952
- return {
32953
- ...first,
32954
- ...second
32955
- // second overwrites first
32956
- };
32957
- };
32958
- })(objectUtil2 || (objectUtil2 = {}));
32959
- var ZodParsedType2 = util2.arrayToEnum([
32960
- "string",
32961
- "nan",
32962
- "number",
32963
- "integer",
32964
- "float",
32965
- "boolean",
32966
- "date",
32967
- "bigint",
32968
- "symbol",
32969
- "function",
32970
- "undefined",
32971
- "null",
32972
- "array",
32973
- "object",
32974
- "unknown",
32975
- "promise",
32976
- "void",
32977
- "never",
32978
- "map",
32979
- "set"
32980
- ]);
32981
- var getParsedType3 = (data) => {
32982
- const t = typeof data;
32983
- switch (t) {
32984
- case "undefined":
32985
- return ZodParsedType2.undefined;
32986
- case "string":
32987
- return ZodParsedType2.string;
32988
- case "number":
32989
- return Number.isNaN(data) ? ZodParsedType2.nan : ZodParsedType2.number;
32990
- case "boolean":
32991
- return ZodParsedType2.boolean;
32992
- case "function":
32993
- return ZodParsedType2.function;
32994
- case "bigint":
32995
- return ZodParsedType2.bigint;
32996
- case "symbol":
32997
- return ZodParsedType2.symbol;
32998
- case "object":
32999
- if (Array.isArray(data)) {
33000
- return ZodParsedType2.array;
33001
- }
33002
- if (data === null) {
33003
- return ZodParsedType2.null;
33004
- }
33005
- if (data.then && typeof data.then === "function" && data.catch && typeof data.catch === "function") {
33006
- return ZodParsedType2.promise;
33007
- }
33008
- if (typeof Map !== "undefined" && data instanceof Map) {
33009
- return ZodParsedType2.map;
33010
- }
33011
- if (typeof Set !== "undefined" && data instanceof Set) {
33012
- return ZodParsedType2.set;
33013
- }
33014
- if (typeof Date !== "undefined" && data instanceof Date) {
33015
- return ZodParsedType2.date;
33016
- }
33017
- return ZodParsedType2.object;
33018
- default:
33019
- return ZodParsedType2.unknown;
33020
- }
33021
- };
33022
-
33023
- // node_modules/zod/v3/ZodError.js
33024
- var ZodIssueCode3 = util2.arrayToEnum([
33025
- "invalid_type",
33026
- "invalid_literal",
33027
- "custom",
33028
- "invalid_union",
33029
- "invalid_union_discriminator",
33030
- "invalid_enum_value",
33031
- "unrecognized_keys",
33032
- "invalid_arguments",
33033
- "invalid_return_type",
33034
- "invalid_date",
33035
- "invalid_string",
33036
- "too_small",
33037
- "too_big",
33038
- "invalid_intersection_types",
33039
- "not_multiple_of",
33040
- "not_finite"
33041
- ]);
33042
- var quotelessJson = (obj) => {
33043
- const json2 = JSON.stringify(obj, null, 2);
33044
- return json2.replace(/"([^"]+)":/g, "$1:");
33045
- };
33046
- var ZodError3 = class _ZodError extends Error {
33047
- get errors() {
33048
- return this.issues;
33049
- }
33050
- constructor(issues) {
33051
- super();
33052
- this.issues = [];
33053
- this.addIssue = (sub) => {
33054
- this.issues = [...this.issues, sub];
33055
- };
33056
- this.addIssues = (subs = []) => {
33057
- this.issues = [...this.issues, ...subs];
33058
- };
33059
- const actualProto = new.target.prototype;
33060
- if (Object.setPrototypeOf) {
33061
- Object.setPrototypeOf(this, actualProto);
33062
- } else {
33063
- this.__proto__ = actualProto;
33064
- }
33065
- this.name = "ZodError";
33066
- this.issues = issues;
33067
- }
33068
- format(_mapper) {
33069
- const mapper = _mapper || function(issue2) {
33070
- return issue2.message;
33071
- };
33072
- const fieldErrors = { _errors: [] };
33073
- const processError = (error48) => {
33074
- for (const issue2 of error48.issues) {
33075
- if (issue2.code === "invalid_union") {
33076
- issue2.unionErrors.map(processError);
33077
- } else if (issue2.code === "invalid_return_type") {
33078
- processError(issue2.returnTypeError);
33079
- } else if (issue2.code === "invalid_arguments") {
33080
- processError(issue2.argumentsError);
33081
- } else if (issue2.path.length === 0) {
33082
- fieldErrors._errors.push(mapper(issue2));
33083
- } else {
33084
- let curr = fieldErrors;
33085
- let i = 0;
33086
- while (i < issue2.path.length) {
33087
- const el = issue2.path[i];
33088
- const terminal = i === issue2.path.length - 1;
33089
- if (!terminal) {
33090
- curr[el] = curr[el] || { _errors: [] };
33091
- } else {
33092
- curr[el] = curr[el] || { _errors: [] };
33093
- curr[el]._errors.push(mapper(issue2));
33094
- }
33095
- curr = curr[el];
33096
- i++;
33097
- }
33098
- }
33099
- }
33100
- };
33101
- processError(this);
33102
- return fieldErrors;
33103
- }
33104
- static assert(value) {
33105
- if (!(value instanceof _ZodError)) {
33106
- throw new Error(`Not a ZodError: ${value}`);
33107
- }
33108
- }
33109
- toString() {
33110
- return this.message;
33111
- }
33112
- get message() {
33113
- return JSON.stringify(this.issues, util2.jsonStringifyReplacer, 2);
33114
- }
33115
- get isEmpty() {
33116
- return this.issues.length === 0;
33117
- }
33118
- flatten(mapper = (issue2) => issue2.message) {
33119
- const fieldErrors = {};
33120
- const formErrors = [];
33121
- for (const sub of this.issues) {
33122
- if (sub.path.length > 0) {
33123
- const firstEl = sub.path[0];
33124
- fieldErrors[firstEl] = fieldErrors[firstEl] || [];
33125
- fieldErrors[firstEl].push(mapper(sub));
33126
- } else {
33127
- formErrors.push(mapper(sub));
33128
- }
33129
- }
33130
- return { formErrors, fieldErrors };
33131
- }
33132
- get formErrors() {
33133
- return this.flatten();
33134
- }
33135
- };
33136
- ZodError3.create = (issues) => {
33137
- const error48 = new ZodError3(issues);
33138
- return error48;
33139
- };
33140
-
33141
- // node_modules/zod/v3/locales/en.js
33142
- var errorMap2 = (issue2, _ctx) => {
33143
- let message;
33144
- switch (issue2.code) {
33145
- case ZodIssueCode3.invalid_type:
33146
- if (issue2.received === ZodParsedType2.undefined) {
33147
- message = "Required";
33148
- } else {
33149
- message = `Expected ${issue2.expected}, received ${issue2.received}`;
33150
- }
33151
- break;
33152
- case ZodIssueCode3.invalid_literal:
33153
- message = `Invalid literal value, expected ${JSON.stringify(issue2.expected, util2.jsonStringifyReplacer)}`;
33154
- break;
33155
- case ZodIssueCode3.unrecognized_keys:
33156
- message = `Unrecognized key(s) in object: ${util2.joinValues(issue2.keys, ", ")}`;
33157
- break;
33158
- case ZodIssueCode3.invalid_union:
33159
- message = `Invalid input`;
33160
- break;
33161
- case ZodIssueCode3.invalid_union_discriminator:
33162
- message = `Invalid discriminator value. Expected ${util2.joinValues(issue2.options)}`;
33163
- break;
33164
- case ZodIssueCode3.invalid_enum_value:
33165
- message = `Invalid enum value. Expected ${util2.joinValues(issue2.options)}, received '${issue2.received}'`;
33166
- break;
33167
- case ZodIssueCode3.invalid_arguments:
33168
- message = `Invalid function arguments`;
33169
- break;
33170
- case ZodIssueCode3.invalid_return_type:
33171
- message = `Invalid function return type`;
33172
- break;
33173
- case ZodIssueCode3.invalid_date:
33174
- message = `Invalid date`;
33175
- break;
33176
- case ZodIssueCode3.invalid_string:
33177
- if (typeof issue2.validation === "object") {
33178
- if ("includes" in issue2.validation) {
33179
- message = `Invalid input: must include "${issue2.validation.includes}"`;
33180
- if (typeof issue2.validation.position === "number") {
33181
- message = `${message} at one or more positions greater than or equal to ${issue2.validation.position}`;
33182
- }
33183
- } else if ("startsWith" in issue2.validation) {
33184
- message = `Invalid input: must start with "${issue2.validation.startsWith}"`;
33185
- } else if ("endsWith" in issue2.validation) {
33186
- message = `Invalid input: must end with "${issue2.validation.endsWith}"`;
33187
- } else {
33188
- util2.assertNever(issue2.validation);
33189
- }
33190
- } else if (issue2.validation !== "regex") {
33191
- message = `Invalid ${issue2.validation}`;
33192
- } else {
33193
- message = "Invalid";
33194
- }
33195
- break;
33196
- case ZodIssueCode3.too_small:
33197
- if (issue2.type === "array")
33198
- message = `Array must contain ${issue2.exact ? "exactly" : issue2.inclusive ? `at least` : `more than`} ${issue2.minimum} element(s)`;
33199
- else if (issue2.type === "string")
33200
- message = `String must contain ${issue2.exact ? "exactly" : issue2.inclusive ? `at least` : `over`} ${issue2.minimum} character(s)`;
33201
- else if (issue2.type === "number")
33202
- message = `Number must be ${issue2.exact ? `exactly equal to ` : issue2.inclusive ? `greater than or equal to ` : `greater than `}${issue2.minimum}`;
33203
- else if (issue2.type === "bigint")
33204
- message = `Number must be ${issue2.exact ? `exactly equal to ` : issue2.inclusive ? `greater than or equal to ` : `greater than `}${issue2.minimum}`;
33205
- else if (issue2.type === "date")
33206
- message = `Date must be ${issue2.exact ? `exactly equal to ` : issue2.inclusive ? `greater than or equal to ` : `greater than `}${new Date(Number(issue2.minimum))}`;
33207
- else
33208
- message = "Invalid input";
33209
- break;
33210
- case ZodIssueCode3.too_big:
33211
- if (issue2.type === "array")
33212
- message = `Array must contain ${issue2.exact ? `exactly` : issue2.inclusive ? `at most` : `less than`} ${issue2.maximum} element(s)`;
33213
- else if (issue2.type === "string")
33214
- message = `String must contain ${issue2.exact ? `exactly` : issue2.inclusive ? `at most` : `under`} ${issue2.maximum} character(s)`;
33215
- else if (issue2.type === "number")
33216
- message = `Number must be ${issue2.exact ? `exactly` : issue2.inclusive ? `less than or equal to` : `less than`} ${issue2.maximum}`;
33217
- else if (issue2.type === "bigint")
33218
- message = `BigInt must be ${issue2.exact ? `exactly` : issue2.inclusive ? `less than or equal to` : `less than`} ${issue2.maximum}`;
33219
- else if (issue2.type === "date")
33220
- message = `Date must be ${issue2.exact ? `exactly` : issue2.inclusive ? `smaller than or equal to` : `smaller than`} ${new Date(Number(issue2.maximum))}`;
33221
- else
33222
- message = "Invalid input";
33223
- break;
33224
- case ZodIssueCode3.custom:
33225
- message = `Invalid input`;
33226
- break;
33227
- case ZodIssueCode3.invalid_intersection_types:
33228
- message = `Intersection results could not be merged`;
33229
- break;
33230
- case ZodIssueCode3.not_multiple_of:
33231
- message = `Number must be a multiple of ${issue2.multipleOf}`;
33232
- break;
33233
- case ZodIssueCode3.not_finite:
33234
- message = "Number must be finite";
33235
- break;
33236
- default:
33237
- message = _ctx.defaultError;
33238
- util2.assertNever(issue2);
33239
- }
33240
- return { message };
33241
- };
33242
- var en_default3 = errorMap2;
33243
-
33244
- // node_modules/zod/v3/errors.js
33245
- var overrideErrorMap2 = en_default3;
33246
- function setErrorMap2(map4) {
33247
- overrideErrorMap2 = map4;
33248
- }
33249
- function getErrorMap3() {
33250
- return overrideErrorMap2;
33251
- }
33252
-
33253
- // node_modules/zod/v3/helpers/parseUtil.js
33254
- var makeIssue2 = (params) => {
33255
- const { data, path, errorMaps, issueData } = params;
33256
- const fullPath = [...path, ...issueData.path || []];
33257
- const fullIssue = {
33258
- ...issueData,
33259
- path: fullPath
33260
- };
33261
- if (issueData.message !== void 0) {
33262
- return {
33263
- ...issueData,
33264
- path: fullPath,
33265
- message: issueData.message
33266
- };
33267
- }
33268
- let errorMessage = "";
33269
- const maps = errorMaps.filter((m) => !!m).slice().reverse();
33270
- for (const map4 of maps) {
33271
- errorMessage = map4(fullIssue, { data, defaultError: errorMessage }).message;
33272
- }
33273
- return {
33274
- ...issueData,
33275
- path: fullPath,
33276
- message: errorMessage
33277
- };
33278
- };
33279
- var EMPTY_PATH = [];
33280
- function addIssueToContext2(ctx, issueData) {
33281
- const overrideMap = getErrorMap3();
33282
- const issue2 = makeIssue2({
33283
- issueData,
33284
- data: ctx.data,
33285
- path: ctx.path,
33286
- errorMaps: [
33287
- ctx.common.contextualErrorMap,
33288
- // contextual error map is first priority
33289
- ctx.schemaErrorMap,
33290
- // then schema-bound map if available
33291
- overrideMap,
33292
- // then global override map
33293
- overrideMap === en_default3 ? void 0 : en_default3
33294
- // then global default map
33295
- ].filter((x) => !!x)
33296
- });
33297
- ctx.common.issues.push(issue2);
33298
- }
33299
- var ParseStatus2 = class _ParseStatus {
33300
- constructor() {
33301
- this.value = "valid";
33302
- }
33303
- dirty() {
33304
- if (this.value === "valid")
33305
- this.value = "dirty";
33306
- }
33307
- abort() {
33308
- if (this.value !== "aborted")
33309
- this.value = "aborted";
33310
- }
33311
- static mergeArray(status, results) {
33312
- const arrayValue = [];
33313
- for (const s of results) {
33314
- if (s.status === "aborted")
33315
- return INVALID2;
33316
- if (s.status === "dirty")
33317
- status.dirty();
33318
- arrayValue.push(s.value);
33319
- }
33320
- return { status: status.value, value: arrayValue };
33321
- }
33322
- static async mergeObjectAsync(status, pairs) {
33323
- const syncPairs = [];
33324
- for (const pair of pairs) {
33325
- const key = await pair.key;
33326
- const value = await pair.value;
33327
- syncPairs.push({
33328
- key,
33329
- value
33330
- });
33331
- }
33332
- return _ParseStatus.mergeObjectSync(status, syncPairs);
33333
- }
33334
- static mergeObjectSync(status, pairs) {
33335
- const finalObject = {};
33336
- for (const pair of pairs) {
33337
- const { key, value } = pair;
33338
- if (key.status === "aborted")
33339
- return INVALID2;
33340
- if (value.status === "aborted")
33341
- return INVALID2;
33342
- if (key.status === "dirty")
33343
- status.dirty();
33344
- if (value.status === "dirty")
33345
- status.dirty();
33346
- if (key.value !== "__proto__" && (typeof value.value !== "undefined" || pair.alwaysSet)) {
33347
- finalObject[key.value] = value.value;
33348
- }
33349
- }
33350
- return { status: status.value, value: finalObject };
33351
- }
33352
- };
33353
- var INVALID2 = Object.freeze({
33354
- status: "aborted"
33355
- });
33356
- var DIRTY2 = (value) => ({ status: "dirty", value });
33357
- var OK2 = (value) => ({ status: "valid", value });
33358
- var isAborted2 = (x) => x.status === "aborted";
33359
- var isDirty2 = (x) => x.status === "dirty";
33360
- var isValid2 = (x) => x.status === "valid";
33361
- var isAsync2 = (x) => typeof Promise !== "undefined" && x instanceof Promise;
33362
-
33363
- // node_modules/zod/v3/helpers/errorUtil.js
33364
- var errorUtil2;
33365
- (function(errorUtil3) {
33366
- errorUtil3.errToObj = (message) => typeof message === "string" ? { message } : message || {};
33367
- errorUtil3.toString = (message) => typeof message === "string" ? message : message?.message;
33368
- })(errorUtil2 || (errorUtil2 = {}));
33369
-
33370
- // node_modules/zod/v3/types.js
33371
- var ParseInputLazyPath2 = class {
33372
- constructor(parent, value, path, key) {
33373
- this._cachedPath = [];
33374
- this.parent = parent;
33375
- this.data = value;
33376
- this._path = path;
33377
- this._key = key;
33378
- }
33379
- get path() {
33380
- if (!this._cachedPath.length) {
33381
- if (Array.isArray(this._key)) {
33382
- this._cachedPath.push(...this._path, ...this._key);
33383
- } else {
33384
- this._cachedPath.push(...this._path, this._key);
33385
- }
33386
- }
33387
- return this._cachedPath;
33388
- }
33389
- };
33390
- var handleResult2 = (ctx, result) => {
33391
- if (isValid2(result)) {
33392
- return { success: true, data: result.value };
33393
- } else {
33394
- if (!ctx.common.issues.length) {
33395
- throw new Error("Validation failed but no issues detected.");
33396
- }
33397
- return {
33398
- success: false,
33399
- get error() {
33400
- if (this._error)
33401
- return this._error;
33402
- const error48 = new ZodError3(ctx.common.issues);
33403
- this._error = error48;
33404
- return this._error;
33405
- }
33406
- };
33407
- }
33408
- };
33409
- function processCreateParams2(params) {
33410
- if (!params)
33411
- return {};
33412
- const { errorMap: errorMap3, invalid_type_error, required_error, description } = params;
33413
- if (errorMap3 && (invalid_type_error || required_error)) {
33414
- throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);
33415
- }
33416
- if (errorMap3)
33417
- return { errorMap: errorMap3, description };
33418
- const customMap = (iss, ctx) => {
33419
- const { message } = params;
33420
- if (iss.code === "invalid_enum_value") {
33421
- return { message: message ?? ctx.defaultError };
33422
- }
33423
- if (typeof ctx.data === "undefined") {
33424
- return { message: message ?? required_error ?? ctx.defaultError };
33425
- }
33426
- if (iss.code !== "invalid_type")
33427
- return { message: ctx.defaultError };
33428
- return { message: message ?? invalid_type_error ?? ctx.defaultError };
33429
- };
33430
- return { errorMap: customMap, description };
33431
- }
33432
- var ZodType3 = class {
33433
- get description() {
33434
- return this._def.description;
33435
- }
33436
- _getType(input) {
33437
- return getParsedType3(input.data);
33438
- }
33439
- _getOrReturnCtx(input, ctx) {
33440
- return ctx || {
33441
- common: input.parent.common,
33442
- data: input.data,
33443
- parsedType: getParsedType3(input.data),
33444
- schemaErrorMap: this._def.errorMap,
33445
- path: input.path,
33446
- parent: input.parent
33447
- };
33448
- }
33449
- _processInputParams(input) {
33450
- return {
33451
- status: new ParseStatus2(),
33452
- ctx: {
33453
- common: input.parent.common,
33454
- data: input.data,
33455
- parsedType: getParsedType3(input.data),
33456
- schemaErrorMap: this._def.errorMap,
33457
- path: input.path,
33458
- parent: input.parent
33459
- }
33460
- };
33461
- }
33462
- _parseSync(input) {
33463
- const result = this._parse(input);
33464
- if (isAsync2(result)) {
33465
- throw new Error("Synchronous parse encountered promise.");
33466
- }
33467
- return result;
33468
- }
33469
- _parseAsync(input) {
33470
- const result = this._parse(input);
33471
- return Promise.resolve(result);
33472
- }
33473
- parse(data, params) {
33474
- const result = this.safeParse(data, params);
33475
- if (result.success)
33476
- return result.data;
33477
- throw result.error;
33478
- }
33479
- safeParse(data, params) {
33480
- const ctx = {
33481
- common: {
33482
- issues: [],
33483
- async: params?.async ?? false,
33484
- contextualErrorMap: params?.errorMap
33485
- },
33486
- path: params?.path || [],
33487
- schemaErrorMap: this._def.errorMap,
33488
- parent: null,
33489
- data,
33490
- parsedType: getParsedType3(data)
33491
- };
33492
- const result = this._parseSync({ data, path: ctx.path, parent: ctx });
33493
- return handleResult2(ctx, result);
33494
- }
33495
- "~validate"(data) {
33496
- const ctx = {
33497
- common: {
33498
- issues: [],
33499
- async: !!this["~standard"].async
33500
- },
33501
- path: [],
33502
- schemaErrorMap: this._def.errorMap,
33503
- parent: null,
33504
- data,
33505
- parsedType: getParsedType3(data)
33506
- };
33507
- if (!this["~standard"].async) {
33508
- try {
33509
- const result = this._parseSync({ data, path: [], parent: ctx });
33510
- return isValid2(result) ? {
33511
- value: result.value
33512
- } : {
33513
- issues: ctx.common.issues
33514
- };
33515
- } catch (err) {
33516
- if (err?.message?.toLowerCase()?.includes("encountered")) {
33517
- this["~standard"].async = true;
33518
- }
33519
- ctx.common = {
33520
- issues: [],
33521
- async: true
33522
- };
33523
- }
33524
- }
33525
- return this._parseAsync({ data, path: [], parent: ctx }).then((result) => isValid2(result) ? {
33526
- value: result.value
33527
- } : {
33528
- issues: ctx.common.issues
33529
- });
33530
- }
33531
- async parseAsync(data, params) {
33532
- const result = await this.safeParseAsync(data, params);
33533
- if (result.success)
33534
- return result.data;
33535
- throw result.error;
33536
- }
33537
- async safeParseAsync(data, params) {
33538
- const ctx = {
33539
- common: {
33540
- issues: [],
33541
- contextualErrorMap: params?.errorMap,
33542
- async: true
33543
- },
33544
- path: params?.path || [],
33545
- schemaErrorMap: this._def.errorMap,
33546
- parent: null,
33547
- data,
33548
- parsedType: getParsedType3(data)
33549
- };
33550
- const maybeAsyncResult = this._parse({ data, path: ctx.path, parent: ctx });
33551
- const result = await (isAsync2(maybeAsyncResult) ? maybeAsyncResult : Promise.resolve(maybeAsyncResult));
33552
- return handleResult2(ctx, result);
33553
- }
33554
- refine(check2, message) {
33555
- const getIssueProperties = (val) => {
33556
- if (typeof message === "string" || typeof message === "undefined") {
33557
- return { message };
33558
- } else if (typeof message === "function") {
33559
- return message(val);
33560
- } else {
33561
- return message;
33562
- }
33563
- };
33564
- return this._refinement((val, ctx) => {
33565
- const result = check2(val);
33566
- const setError = () => ctx.addIssue({
33567
- code: ZodIssueCode3.custom,
33568
- ...getIssueProperties(val)
33569
- });
33570
- if (typeof Promise !== "undefined" && result instanceof Promise) {
33571
- return result.then((data) => {
33572
- if (!data) {
33573
- setError();
33574
- return false;
33575
- } else {
33576
- return true;
33577
- }
33578
- });
33579
- }
33580
- if (!result) {
33581
- setError();
33582
- return false;
33583
- } else {
33584
- return true;
33585
- }
33586
- });
33587
- }
33588
- refinement(check2, refinementData) {
33589
- return this._refinement((val, ctx) => {
33590
- if (!check2(val)) {
33591
- ctx.addIssue(typeof refinementData === "function" ? refinementData(val, ctx) : refinementData);
33592
- return false;
33593
- } else {
33594
- return true;
33595
- }
33596
- });
33597
- }
33598
- _refinement(refinement) {
33599
- return new ZodEffects2({
33600
- schema: this,
33601
- typeName: ZodFirstPartyTypeKind3.ZodEffects,
33602
- effect: { type: "refinement", refinement }
33603
- });
33604
- }
33605
- superRefine(refinement) {
33606
- return this._refinement(refinement);
33607
- }
33608
- constructor(def) {
33609
- this.spa = this.safeParseAsync;
33610
- this._def = def;
33611
- this.parse = this.parse.bind(this);
33612
- this.safeParse = this.safeParse.bind(this);
33613
- this.parseAsync = this.parseAsync.bind(this);
33614
- this.safeParseAsync = this.safeParseAsync.bind(this);
33615
- this.spa = this.spa.bind(this);
33616
- this.refine = this.refine.bind(this);
33617
- this.refinement = this.refinement.bind(this);
33618
- this.superRefine = this.superRefine.bind(this);
33619
- this.optional = this.optional.bind(this);
33620
- this.nullable = this.nullable.bind(this);
33621
- this.nullish = this.nullish.bind(this);
33622
- this.array = this.array.bind(this);
33623
- this.promise = this.promise.bind(this);
33624
- this.or = this.or.bind(this);
33625
- this.and = this.and.bind(this);
33626
- this.transform = this.transform.bind(this);
33627
- this.brand = this.brand.bind(this);
33628
- this.default = this.default.bind(this);
33629
- this.catch = this.catch.bind(this);
33630
- this.describe = this.describe.bind(this);
33631
- this.pipe = this.pipe.bind(this);
33632
- this.readonly = this.readonly.bind(this);
33633
- this.isNullable = this.isNullable.bind(this);
33634
- this.isOptional = this.isOptional.bind(this);
33635
- this["~standard"] = {
33636
- version: 1,
33637
- vendor: "zod",
33638
- validate: (data) => this["~validate"](data)
33639
- };
33640
- }
33641
- optional() {
33642
- return ZodOptional3.create(this, this._def);
33643
- }
33644
- nullable() {
33645
- return ZodNullable3.create(this, this._def);
33646
- }
33647
- nullish() {
33648
- return this.nullable().optional();
33649
- }
33650
- array() {
33651
- return ZodArray3.create(this);
33652
- }
33653
- promise() {
33654
- return ZodPromise3.create(this, this._def);
33655
- }
33656
- or(option) {
33657
- return ZodUnion3.create([this, option], this._def);
33658
- }
33659
- and(incoming) {
33660
- return ZodIntersection3.create(this, incoming, this._def);
33661
- }
33662
- transform(transform2) {
33663
- return new ZodEffects2({
33664
- ...processCreateParams2(this._def),
33665
- schema: this,
33666
- typeName: ZodFirstPartyTypeKind3.ZodEffects,
33667
- effect: { type: "transform", transform: transform2 }
33668
- });
33669
- }
33670
- default(def) {
33671
- const defaultValueFunc = typeof def === "function" ? def : () => def;
33672
- return new ZodDefault3({
33673
- ...processCreateParams2(this._def),
33674
- innerType: this,
33675
- defaultValue: defaultValueFunc,
33676
- typeName: ZodFirstPartyTypeKind3.ZodDefault
33677
- });
33678
- }
33679
- brand() {
33680
- return new ZodBranded2({
33681
- typeName: ZodFirstPartyTypeKind3.ZodBranded,
33682
- type: this,
33683
- ...processCreateParams2(this._def)
33684
- });
33685
- }
33686
- catch(def) {
33687
- const catchValueFunc = typeof def === "function" ? def : () => def;
33688
- return new ZodCatch3({
33689
- ...processCreateParams2(this._def),
33690
- innerType: this,
33691
- catchValue: catchValueFunc,
33692
- typeName: ZodFirstPartyTypeKind3.ZodCatch
33693
- });
33694
- }
33695
- describe(description) {
33696
- const This = this.constructor;
33697
- return new This({
33698
- ...this._def,
33699
- description
33700
- });
33701
- }
33702
- pipe(target) {
33703
- return ZodPipeline2.create(this, target);
33704
- }
33705
- readonly() {
33706
- return ZodReadonly3.create(this);
33707
- }
33708
- isOptional() {
33709
- return this.safeParse(void 0).success;
33710
- }
33711
- isNullable() {
33712
- return this.safeParse(null).success;
33713
- }
33714
- };
33715
- var cuidRegex2 = /^c[^\s-]{8,}$/i;
33716
- var cuid2Regex2 = /^[0-9a-z]+$/;
33717
- var ulidRegex2 = /^[0-9A-HJKMNP-TV-Z]{26}$/i;
33718
- var uuidRegex2 = /^[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;
33719
- var nanoidRegex2 = /^[a-z0-9_-]{21}$/i;
33720
- var jwtRegex2 = /^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/;
33721
- var durationRegex2 = /^[-+]?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)?)??$/;
33722
- var emailRegex2 = /^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i;
33723
- var _emojiRegex2 = `^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$`;
33724
- var emojiRegex3;
33725
- var ipv4Regex2 = /^(?:(?: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])$/;
33726
- var ipv4CidrRegex2 = /^(?:(?: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])$/;
33727
- var ipv6Regex2 = /^(([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]))$/;
33728
- var ipv6CidrRegex2 = /^(([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])$/;
33729
- var base64Regex2 = /^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/;
33730
- var base64urlRegex2 = /^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/;
33731
- var dateRegexSource2 = `((\\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])))`;
33732
- var dateRegex2 = new RegExp(`^${dateRegexSource2}$`);
33733
- function timeRegexSource2(args) {
33734
- let secondsRegexSource = `[0-5]\\d`;
33735
- if (args.precision) {
33736
- secondsRegexSource = `${secondsRegexSource}\\.\\d{${args.precision}}`;
33737
- } else if (args.precision == null) {
33738
- secondsRegexSource = `${secondsRegexSource}(\\.\\d+)?`;
33739
- }
33740
- const secondsQuantifier = args.precision ? "+" : "?";
33741
- return `([01]\\d|2[0-3]):[0-5]\\d(:${secondsRegexSource})${secondsQuantifier}`;
33742
- }
33743
- function timeRegex2(args) {
33744
- return new RegExp(`^${timeRegexSource2(args)}$`);
33745
- }
33746
- function datetimeRegex2(args) {
33747
- let regex = `${dateRegexSource2}T${timeRegexSource2(args)}`;
33748
- const opts = [];
33749
- opts.push(args.local ? `Z?` : `Z`);
33750
- if (args.offset)
33751
- opts.push(`([+-]\\d{2}:?\\d{2})`);
33752
- regex = `${regex}(${opts.join("|")})`;
33753
- return new RegExp(`^${regex}$`);
33754
- }
33755
- function isValidIP2(ip, version2) {
33756
- if ((version2 === "v4" || !version2) && ipv4Regex2.test(ip)) {
33757
- return true;
33758
- }
33759
- if ((version2 === "v6" || !version2) && ipv6Regex2.test(ip)) {
33760
- return true;
33761
- }
33762
- return false;
33763
- }
33764
- function isValidJWT3(jwt2, alg) {
33765
- if (!jwtRegex2.test(jwt2))
33766
- return false;
33767
- try {
33768
- const [header] = jwt2.split(".");
33769
- if (!header)
33770
- return false;
33771
- const base643 = header.replace(/-/g, "+").replace(/_/g, "/").padEnd(header.length + (4 - header.length % 4) % 4, "=");
33772
- const decoded = JSON.parse(atob(base643));
33773
- if (typeof decoded !== "object" || decoded === null)
33774
- return false;
33775
- if ("typ" in decoded && decoded?.typ !== "JWT")
33776
- return false;
33777
- if (!decoded.alg)
33778
- return false;
33779
- if (alg && decoded.alg !== alg)
33780
- return false;
33781
- return true;
33782
- } catch {
33783
- return false;
33784
- }
33785
- }
33786
- function isValidCidr2(ip, version2) {
33787
- if ((version2 === "v4" || !version2) && ipv4CidrRegex2.test(ip)) {
33788
- return true;
33789
- }
33790
- if ((version2 === "v6" || !version2) && ipv6CidrRegex2.test(ip)) {
33791
- return true;
33792
- }
33793
- return false;
33794
- }
33795
- var ZodString3 = class _ZodString2 extends ZodType3 {
33796
- _parse(input) {
33797
- if (this._def.coerce) {
33798
- input.data = String(input.data);
33799
- }
33800
- const parsedType2 = this._getType(input);
33801
- if (parsedType2 !== ZodParsedType2.string) {
33802
- const ctx2 = this._getOrReturnCtx(input);
33803
- addIssueToContext2(ctx2, {
33804
- code: ZodIssueCode3.invalid_type,
33805
- expected: ZodParsedType2.string,
33806
- received: ctx2.parsedType
33807
- });
33808
- return INVALID2;
33809
- }
33810
- const status = new ParseStatus2();
33811
- let ctx = void 0;
33812
- for (const check2 of this._def.checks) {
33813
- if (check2.kind === "min") {
33814
- if (input.data.length < check2.value) {
33815
- ctx = this._getOrReturnCtx(input, ctx);
33816
- addIssueToContext2(ctx, {
33817
- code: ZodIssueCode3.too_small,
33818
- minimum: check2.value,
33819
- type: "string",
33820
- inclusive: true,
33821
- exact: false,
33822
- message: check2.message
33823
- });
33824
- status.dirty();
33825
- }
33826
- } else if (check2.kind === "max") {
33827
- if (input.data.length > check2.value) {
33828
- ctx = this._getOrReturnCtx(input, ctx);
33829
- addIssueToContext2(ctx, {
33830
- code: ZodIssueCode3.too_big,
33831
- maximum: check2.value,
33832
- type: "string",
33833
- inclusive: true,
33834
- exact: false,
33835
- message: check2.message
33836
- });
33837
- status.dirty();
33838
- }
33839
- } else if (check2.kind === "length") {
33840
- const tooBig = input.data.length > check2.value;
33841
- const tooSmall = input.data.length < check2.value;
33842
- if (tooBig || tooSmall) {
33843
- ctx = this._getOrReturnCtx(input, ctx);
33844
- if (tooBig) {
33845
- addIssueToContext2(ctx, {
33846
- code: ZodIssueCode3.too_big,
33847
- maximum: check2.value,
33848
- type: "string",
33849
- inclusive: true,
33850
- exact: true,
33851
- message: check2.message
33852
- });
33853
- } else if (tooSmall) {
33854
- addIssueToContext2(ctx, {
33855
- code: ZodIssueCode3.too_small,
33856
- minimum: check2.value,
33857
- type: "string",
33858
- inclusive: true,
33859
- exact: true,
33860
- message: check2.message
33861
- });
33862
- }
33863
- status.dirty();
33864
- }
33865
- } else if (check2.kind === "email") {
33866
- if (!emailRegex2.test(input.data)) {
33867
- ctx = this._getOrReturnCtx(input, ctx);
33868
- addIssueToContext2(ctx, {
33869
- validation: "email",
33870
- code: ZodIssueCode3.invalid_string,
33871
- message: check2.message
33872
- });
33873
- status.dirty();
33874
- }
33875
- } else if (check2.kind === "emoji") {
33876
- if (!emojiRegex3) {
33877
- emojiRegex3 = new RegExp(_emojiRegex2, "u");
33878
- }
33879
- if (!emojiRegex3.test(input.data)) {
33880
- ctx = this._getOrReturnCtx(input, ctx);
33881
- addIssueToContext2(ctx, {
33882
- validation: "emoji",
33883
- code: ZodIssueCode3.invalid_string,
33884
- message: check2.message
33885
- });
33886
- status.dirty();
33887
- }
33888
- } else if (check2.kind === "uuid") {
33889
- if (!uuidRegex2.test(input.data)) {
33890
- ctx = this._getOrReturnCtx(input, ctx);
33891
- addIssueToContext2(ctx, {
33892
- validation: "uuid",
33893
- code: ZodIssueCode3.invalid_string,
33894
- message: check2.message
33895
- });
33896
- status.dirty();
33897
- }
33898
- } else if (check2.kind === "nanoid") {
33899
- if (!nanoidRegex2.test(input.data)) {
33900
- ctx = this._getOrReturnCtx(input, ctx);
33901
- addIssueToContext2(ctx, {
33902
- validation: "nanoid",
33903
- code: ZodIssueCode3.invalid_string,
33904
- message: check2.message
33905
- });
33906
- status.dirty();
33907
- }
33908
- } else if (check2.kind === "cuid") {
33909
- if (!cuidRegex2.test(input.data)) {
33910
- ctx = this._getOrReturnCtx(input, ctx);
33911
- addIssueToContext2(ctx, {
33912
- validation: "cuid",
33913
- code: ZodIssueCode3.invalid_string,
33914
- message: check2.message
33915
- });
33916
- status.dirty();
33917
- }
33918
- } else if (check2.kind === "cuid2") {
33919
- if (!cuid2Regex2.test(input.data)) {
33920
- ctx = this._getOrReturnCtx(input, ctx);
33921
- addIssueToContext2(ctx, {
33922
- validation: "cuid2",
33923
- code: ZodIssueCode3.invalid_string,
33924
- message: check2.message
33925
- });
33926
- status.dirty();
33927
- }
33928
- } else if (check2.kind === "ulid") {
33929
- if (!ulidRegex2.test(input.data)) {
33930
- ctx = this._getOrReturnCtx(input, ctx);
33931
- addIssueToContext2(ctx, {
33932
- validation: "ulid",
33933
- code: ZodIssueCode3.invalid_string,
33934
- message: check2.message
33935
- });
33936
- status.dirty();
33937
- }
33938
- } else if (check2.kind === "url") {
33939
- try {
33940
- new URL(input.data);
33941
- } catch {
33942
- ctx = this._getOrReturnCtx(input, ctx);
33943
- addIssueToContext2(ctx, {
33944
- validation: "url",
33945
- code: ZodIssueCode3.invalid_string,
33946
- message: check2.message
33947
- });
33948
- status.dirty();
33949
- }
33950
- } else if (check2.kind === "regex") {
33951
- check2.regex.lastIndex = 0;
33952
- const testResult = check2.regex.test(input.data);
33953
- if (!testResult) {
33954
- ctx = this._getOrReturnCtx(input, ctx);
33955
- addIssueToContext2(ctx, {
33956
- validation: "regex",
33957
- code: ZodIssueCode3.invalid_string,
33958
- message: check2.message
33959
- });
33960
- status.dirty();
33961
- }
33962
- } else if (check2.kind === "trim") {
33963
- input.data = input.data.trim();
33964
- } else if (check2.kind === "includes") {
33965
- if (!input.data.includes(check2.value, check2.position)) {
33966
- ctx = this._getOrReturnCtx(input, ctx);
33967
- addIssueToContext2(ctx, {
33968
- code: ZodIssueCode3.invalid_string,
33969
- validation: { includes: check2.value, position: check2.position },
33970
- message: check2.message
33971
- });
33972
- status.dirty();
33973
- }
33974
- } else if (check2.kind === "toLowerCase") {
33975
- input.data = input.data.toLowerCase();
33976
- } else if (check2.kind === "toUpperCase") {
33977
- input.data = input.data.toUpperCase();
33978
- } else if (check2.kind === "startsWith") {
33979
- if (!input.data.startsWith(check2.value)) {
33980
- ctx = this._getOrReturnCtx(input, ctx);
33981
- addIssueToContext2(ctx, {
33982
- code: ZodIssueCode3.invalid_string,
33983
- validation: { startsWith: check2.value },
33984
- message: check2.message
33985
- });
33986
- status.dirty();
33987
- }
33988
- } else if (check2.kind === "endsWith") {
33989
- if (!input.data.endsWith(check2.value)) {
33990
- ctx = this._getOrReturnCtx(input, ctx);
33991
- addIssueToContext2(ctx, {
33992
- code: ZodIssueCode3.invalid_string,
33993
- validation: { endsWith: check2.value },
33994
- message: check2.message
33995
- });
33996
- status.dirty();
33997
- }
33998
- } else if (check2.kind === "datetime") {
33999
- const regex = datetimeRegex2(check2);
34000
- if (!regex.test(input.data)) {
34001
- ctx = this._getOrReturnCtx(input, ctx);
34002
- addIssueToContext2(ctx, {
34003
- code: ZodIssueCode3.invalid_string,
34004
- validation: "datetime",
34005
- message: check2.message
34006
- });
34007
- status.dirty();
34008
- }
34009
- } else if (check2.kind === "date") {
34010
- const regex = dateRegex2;
34011
- if (!regex.test(input.data)) {
34012
- ctx = this._getOrReturnCtx(input, ctx);
34013
- addIssueToContext2(ctx, {
34014
- code: ZodIssueCode3.invalid_string,
34015
- validation: "date",
34016
- message: check2.message
34017
- });
34018
- status.dirty();
34019
- }
34020
- } else if (check2.kind === "time") {
34021
- const regex = timeRegex2(check2);
34022
- if (!regex.test(input.data)) {
34023
- ctx = this._getOrReturnCtx(input, ctx);
34024
- addIssueToContext2(ctx, {
34025
- code: ZodIssueCode3.invalid_string,
34026
- validation: "time",
34027
- message: check2.message
34028
- });
34029
- status.dirty();
34030
- }
34031
- } else if (check2.kind === "duration") {
34032
- if (!durationRegex2.test(input.data)) {
34033
- ctx = this._getOrReturnCtx(input, ctx);
34034
- addIssueToContext2(ctx, {
34035
- validation: "duration",
34036
- code: ZodIssueCode3.invalid_string,
34037
- message: check2.message
34038
- });
34039
- status.dirty();
34040
- }
34041
- } else if (check2.kind === "ip") {
34042
- if (!isValidIP2(input.data, check2.version)) {
34043
- ctx = this._getOrReturnCtx(input, ctx);
34044
- addIssueToContext2(ctx, {
34045
- validation: "ip",
34046
- code: ZodIssueCode3.invalid_string,
34047
- message: check2.message
34048
- });
34049
- status.dirty();
34050
- }
34051
- } else if (check2.kind === "jwt") {
34052
- if (!isValidJWT3(input.data, check2.alg)) {
34053
- ctx = this._getOrReturnCtx(input, ctx);
34054
- addIssueToContext2(ctx, {
34055
- validation: "jwt",
34056
- code: ZodIssueCode3.invalid_string,
34057
- message: check2.message
34058
- });
34059
- status.dirty();
34060
- }
34061
- } else if (check2.kind === "cidr") {
34062
- if (!isValidCidr2(input.data, check2.version)) {
34063
- ctx = this._getOrReturnCtx(input, ctx);
34064
- addIssueToContext2(ctx, {
34065
- validation: "cidr",
34066
- code: ZodIssueCode3.invalid_string,
34067
- message: check2.message
34068
- });
34069
- status.dirty();
34070
- }
34071
- } else if (check2.kind === "base64") {
34072
- if (!base64Regex2.test(input.data)) {
34073
- ctx = this._getOrReturnCtx(input, ctx);
34074
- addIssueToContext2(ctx, {
34075
- validation: "base64",
34076
- code: ZodIssueCode3.invalid_string,
34077
- message: check2.message
34078
- });
34079
- status.dirty();
34080
- }
34081
- } else if (check2.kind === "base64url") {
34082
- if (!base64urlRegex2.test(input.data)) {
34083
- ctx = this._getOrReturnCtx(input, ctx);
34084
- addIssueToContext2(ctx, {
34085
- validation: "base64url",
34086
- code: ZodIssueCode3.invalid_string,
34087
- message: check2.message
34088
- });
34089
- status.dirty();
34090
- }
34091
- } else {
34092
- util2.assertNever(check2);
34093
- }
34094
- }
34095
- return { status: status.value, value: input.data };
34096
- }
34097
- _regex(regex, validation, message) {
34098
- return this.refinement((data) => regex.test(data), {
34099
- validation,
34100
- code: ZodIssueCode3.invalid_string,
34101
- ...errorUtil2.errToObj(message)
34102
- });
34103
- }
34104
- _addCheck(check2) {
34105
- return new _ZodString2({
34106
- ...this._def,
34107
- checks: [...this._def.checks, check2]
34108
- });
34109
- }
34110
- email(message) {
34111
- return this._addCheck({ kind: "email", ...errorUtil2.errToObj(message) });
34112
- }
34113
- url(message) {
34114
- return this._addCheck({ kind: "url", ...errorUtil2.errToObj(message) });
34115
- }
34116
- emoji(message) {
34117
- return this._addCheck({ kind: "emoji", ...errorUtil2.errToObj(message) });
34118
- }
34119
- uuid(message) {
34120
- return this._addCheck({ kind: "uuid", ...errorUtil2.errToObj(message) });
34121
- }
34122
- nanoid(message) {
34123
- return this._addCheck({ kind: "nanoid", ...errorUtil2.errToObj(message) });
34124
- }
34125
- cuid(message) {
34126
- return this._addCheck({ kind: "cuid", ...errorUtil2.errToObj(message) });
34127
- }
34128
- cuid2(message) {
34129
- return this._addCheck({ kind: "cuid2", ...errorUtil2.errToObj(message) });
34130
- }
34131
- ulid(message) {
34132
- return this._addCheck({ kind: "ulid", ...errorUtil2.errToObj(message) });
34133
- }
34134
- base64(message) {
34135
- return this._addCheck({ kind: "base64", ...errorUtil2.errToObj(message) });
34136
- }
34137
- base64url(message) {
34138
- return this._addCheck({
34139
- kind: "base64url",
34140
- ...errorUtil2.errToObj(message)
34141
- });
34142
- }
34143
- jwt(options3) {
34144
- return this._addCheck({ kind: "jwt", ...errorUtil2.errToObj(options3) });
34145
- }
34146
- ip(options3) {
34147
- return this._addCheck({ kind: "ip", ...errorUtil2.errToObj(options3) });
34148
- }
34149
- cidr(options3) {
34150
- return this._addCheck({ kind: "cidr", ...errorUtil2.errToObj(options3) });
34151
- }
34152
- datetime(options3) {
34153
- if (typeof options3 === "string") {
34154
- return this._addCheck({
34155
- kind: "datetime",
34156
- precision: null,
34157
- offset: false,
34158
- local: false,
34159
- message: options3
34160
- });
34161
- }
34162
- return this._addCheck({
34163
- kind: "datetime",
34164
- precision: typeof options3?.precision === "undefined" ? null : options3?.precision,
34165
- offset: options3?.offset ?? false,
34166
- local: options3?.local ?? false,
34167
- ...errorUtil2.errToObj(options3?.message)
34168
- });
34169
- }
34170
- date(message) {
34171
- return this._addCheck({ kind: "date", message });
34172
- }
34173
- time(options3) {
34174
- if (typeof options3 === "string") {
34175
- return this._addCheck({
34176
- kind: "time",
34177
- precision: null,
34178
- message: options3
34179
- });
34180
- }
34181
- return this._addCheck({
34182
- kind: "time",
34183
- precision: typeof options3?.precision === "undefined" ? null : options3?.precision,
34184
- ...errorUtil2.errToObj(options3?.message)
34185
- });
34186
- }
34187
- duration(message) {
34188
- return this._addCheck({ kind: "duration", ...errorUtil2.errToObj(message) });
34189
- }
34190
- regex(regex, message) {
34191
- return this._addCheck({
34192
- kind: "regex",
34193
- regex,
34194
- ...errorUtil2.errToObj(message)
34195
- });
34196
- }
34197
- includes(value, options3) {
34198
- return this._addCheck({
34199
- kind: "includes",
34200
- value,
34201
- position: options3?.position,
34202
- ...errorUtil2.errToObj(options3?.message)
34203
- });
34204
- }
34205
- startsWith(value, message) {
34206
- return this._addCheck({
34207
- kind: "startsWith",
34208
- value,
34209
- ...errorUtil2.errToObj(message)
34210
- });
34211
- }
34212
- endsWith(value, message) {
34213
- return this._addCheck({
34214
- kind: "endsWith",
34215
- value,
34216
- ...errorUtil2.errToObj(message)
34217
- });
34218
- }
34219
- min(minLength, message) {
34220
- return this._addCheck({
34221
- kind: "min",
34222
- value: minLength,
34223
- ...errorUtil2.errToObj(message)
34224
- });
34225
- }
34226
- max(maxLength, message) {
34227
- return this._addCheck({
34228
- kind: "max",
34229
- value: maxLength,
34230
- ...errorUtil2.errToObj(message)
34231
- });
34232
- }
34233
- length(len, message) {
34234
- return this._addCheck({
34235
- kind: "length",
34236
- value: len,
34237
- ...errorUtil2.errToObj(message)
34238
- });
34239
- }
34240
- /**
34241
- * Equivalent to `.min(1)`
34242
- */
34243
- nonempty(message) {
34244
- return this.min(1, errorUtil2.errToObj(message));
34245
- }
34246
- trim() {
34247
- return new _ZodString2({
34248
- ...this._def,
34249
- checks: [...this._def.checks, { kind: "trim" }]
34250
- });
34251
- }
34252
- toLowerCase() {
34253
- return new _ZodString2({
34254
- ...this._def,
34255
- checks: [...this._def.checks, { kind: "toLowerCase" }]
34256
- });
34257
- }
34258
- toUpperCase() {
34259
- return new _ZodString2({
34260
- ...this._def,
34261
- checks: [...this._def.checks, { kind: "toUpperCase" }]
34262
- });
34263
- }
34264
- get isDatetime() {
34265
- return !!this._def.checks.find((ch) => ch.kind === "datetime");
34266
- }
34267
- get isDate() {
34268
- return !!this._def.checks.find((ch) => ch.kind === "date");
34269
- }
34270
- get isTime() {
34271
- return !!this._def.checks.find((ch) => ch.kind === "time");
34272
- }
34273
- get isDuration() {
34274
- return !!this._def.checks.find((ch) => ch.kind === "duration");
34275
- }
34276
- get isEmail() {
34277
- return !!this._def.checks.find((ch) => ch.kind === "email");
34278
- }
34279
- get isURL() {
34280
- return !!this._def.checks.find((ch) => ch.kind === "url");
34281
- }
34282
- get isEmoji() {
34283
- return !!this._def.checks.find((ch) => ch.kind === "emoji");
34284
- }
34285
- get isUUID() {
34286
- return !!this._def.checks.find((ch) => ch.kind === "uuid");
34287
- }
34288
- get isNANOID() {
34289
- return !!this._def.checks.find((ch) => ch.kind === "nanoid");
34290
- }
34291
- get isCUID() {
34292
- return !!this._def.checks.find((ch) => ch.kind === "cuid");
34293
- }
34294
- get isCUID2() {
34295
- return !!this._def.checks.find((ch) => ch.kind === "cuid2");
34296
- }
34297
- get isULID() {
34298
- return !!this._def.checks.find((ch) => ch.kind === "ulid");
34299
- }
34300
- get isIP() {
34301
- return !!this._def.checks.find((ch) => ch.kind === "ip");
34302
- }
34303
- get isCIDR() {
34304
- return !!this._def.checks.find((ch) => ch.kind === "cidr");
34305
- }
34306
- get isBase64() {
34307
- return !!this._def.checks.find((ch) => ch.kind === "base64");
34308
- }
34309
- get isBase64url() {
34310
- return !!this._def.checks.find((ch) => ch.kind === "base64url");
34311
- }
34312
- get minLength() {
34313
- let min = null;
34314
- for (const ch of this._def.checks) {
34315
- if (ch.kind === "min") {
34316
- if (min === null || ch.value > min)
34317
- min = ch.value;
34318
- }
34319
- }
34320
- return min;
34321
- }
34322
- get maxLength() {
34323
- let max = null;
34324
- for (const ch of this._def.checks) {
34325
- if (ch.kind === "max") {
34326
- if (max === null || ch.value < max)
34327
- max = ch.value;
34328
- }
34329
- }
34330
- return max;
34331
- }
34332
- };
34333
- ZodString3.create = (params) => {
34334
- return new ZodString3({
34335
- checks: [],
34336
- typeName: ZodFirstPartyTypeKind3.ZodString,
34337
- coerce: params?.coerce ?? false,
34338
- ...processCreateParams2(params)
34339
- });
34340
- };
34341
- function floatSafeRemainder3(val, step) {
34342
- const valDecCount = (val.toString().split(".")[1] || "").length;
34343
- const stepDecCount = (step.toString().split(".")[1] || "").length;
34344
- const decCount = valDecCount > stepDecCount ? valDecCount : stepDecCount;
34345
- const valInt = Number.parseInt(val.toFixed(decCount).replace(".", ""));
34346
- const stepInt = Number.parseInt(step.toFixed(decCount).replace(".", ""));
34347
- return valInt % stepInt / 10 ** decCount;
34348
- }
34349
- var ZodNumber3 = class _ZodNumber extends ZodType3 {
34350
- constructor() {
34351
- super(...arguments);
34352
- this.min = this.gte;
34353
- this.max = this.lte;
34354
- this.step = this.multipleOf;
34355
- }
34356
- _parse(input) {
34357
- if (this._def.coerce) {
34358
- input.data = Number(input.data);
34359
- }
34360
- const parsedType2 = this._getType(input);
34361
- if (parsedType2 !== ZodParsedType2.number) {
34362
- const ctx2 = this._getOrReturnCtx(input);
34363
- addIssueToContext2(ctx2, {
34364
- code: ZodIssueCode3.invalid_type,
34365
- expected: ZodParsedType2.number,
34366
- received: ctx2.parsedType
34367
- });
34368
- return INVALID2;
34369
- }
34370
- let ctx = void 0;
34371
- const status = new ParseStatus2();
34372
- for (const check2 of this._def.checks) {
34373
- if (check2.kind === "int") {
34374
- if (!util2.isInteger(input.data)) {
34375
- ctx = this._getOrReturnCtx(input, ctx);
34376
- addIssueToContext2(ctx, {
34377
- code: ZodIssueCode3.invalid_type,
34378
- expected: "integer",
34379
- received: "float",
34380
- message: check2.message
34381
- });
34382
- status.dirty();
34383
- }
34384
- } else if (check2.kind === "min") {
34385
- const tooSmall = check2.inclusive ? input.data < check2.value : input.data <= check2.value;
34386
- if (tooSmall) {
34387
- ctx = this._getOrReturnCtx(input, ctx);
34388
- addIssueToContext2(ctx, {
34389
- code: ZodIssueCode3.too_small,
34390
- minimum: check2.value,
34391
- type: "number",
34392
- inclusive: check2.inclusive,
34393
- exact: false,
34394
- message: check2.message
34395
- });
34396
- status.dirty();
34397
- }
34398
- } else if (check2.kind === "max") {
34399
- const tooBig = check2.inclusive ? input.data > check2.value : input.data >= check2.value;
34400
- if (tooBig) {
34401
- ctx = this._getOrReturnCtx(input, ctx);
34402
- addIssueToContext2(ctx, {
34403
- code: ZodIssueCode3.too_big,
34404
- maximum: check2.value,
34405
- type: "number",
34406
- inclusive: check2.inclusive,
34407
- exact: false,
34408
- message: check2.message
34409
- });
34410
- status.dirty();
34411
- }
34412
- } else if (check2.kind === "multipleOf") {
34413
- if (floatSafeRemainder3(input.data, check2.value) !== 0) {
34414
- ctx = this._getOrReturnCtx(input, ctx);
34415
- addIssueToContext2(ctx, {
34416
- code: ZodIssueCode3.not_multiple_of,
34417
- multipleOf: check2.value,
34418
- message: check2.message
34419
- });
34420
- status.dirty();
34421
- }
34422
- } else if (check2.kind === "finite") {
34423
- if (!Number.isFinite(input.data)) {
34424
- ctx = this._getOrReturnCtx(input, ctx);
34425
- addIssueToContext2(ctx, {
34426
- code: ZodIssueCode3.not_finite,
34427
- message: check2.message
34428
- });
34429
- status.dirty();
34430
- }
34431
- } else {
34432
- util2.assertNever(check2);
34433
- }
34434
- }
34435
- return { status: status.value, value: input.data };
34436
- }
34437
- gte(value, message) {
34438
- return this.setLimit("min", value, true, errorUtil2.toString(message));
34439
- }
34440
- gt(value, message) {
34441
- return this.setLimit("min", value, false, errorUtil2.toString(message));
34442
- }
34443
- lte(value, message) {
34444
- return this.setLimit("max", value, true, errorUtil2.toString(message));
34445
- }
34446
- lt(value, message) {
34447
- return this.setLimit("max", value, false, errorUtil2.toString(message));
34448
- }
34449
- setLimit(kind, value, inclusive, message) {
34450
- return new _ZodNumber({
34451
- ...this._def,
34452
- checks: [
34453
- ...this._def.checks,
34454
- {
34455
- kind,
34456
- value,
34457
- inclusive,
34458
- message: errorUtil2.toString(message)
34459
- }
34460
- ]
34461
- });
34462
- }
34463
- _addCheck(check2) {
34464
- return new _ZodNumber({
34465
- ...this._def,
34466
- checks: [...this._def.checks, check2]
34467
- });
34468
- }
34469
- int(message) {
34470
- return this._addCheck({
34471
- kind: "int",
34472
- message: errorUtil2.toString(message)
34473
- });
34474
- }
34475
- positive(message) {
34476
- return this._addCheck({
34477
- kind: "min",
34478
- value: 0,
34479
- inclusive: false,
34480
- message: errorUtil2.toString(message)
34481
- });
34482
- }
34483
- negative(message) {
34484
- return this._addCheck({
34485
- kind: "max",
34486
- value: 0,
34487
- inclusive: false,
34488
- message: errorUtil2.toString(message)
34489
- });
34490
- }
34491
- nonpositive(message) {
34492
- return this._addCheck({
34493
- kind: "max",
34494
- value: 0,
34495
- inclusive: true,
34496
- message: errorUtil2.toString(message)
34497
- });
34498
- }
34499
- nonnegative(message) {
34500
- return this._addCheck({
34501
- kind: "min",
34502
- value: 0,
34503
- inclusive: true,
34504
- message: errorUtil2.toString(message)
34505
- });
34506
- }
34507
- multipleOf(value, message) {
34508
- return this._addCheck({
34509
- kind: "multipleOf",
34510
- value,
34511
- message: errorUtil2.toString(message)
34512
- });
34513
- }
34514
- finite(message) {
34515
- return this._addCheck({
34516
- kind: "finite",
34517
- message: errorUtil2.toString(message)
34518
- });
34519
- }
34520
- safe(message) {
34521
- return this._addCheck({
34522
- kind: "min",
34523
- inclusive: true,
34524
- value: Number.MIN_SAFE_INTEGER,
34525
- message: errorUtil2.toString(message)
34526
- })._addCheck({
34527
- kind: "max",
34528
- inclusive: true,
34529
- value: Number.MAX_SAFE_INTEGER,
34530
- message: errorUtil2.toString(message)
34531
- });
34532
- }
34533
- get minValue() {
34534
- let min = null;
34535
- for (const ch of this._def.checks) {
34536
- if (ch.kind === "min") {
34537
- if (min === null || ch.value > min)
34538
- min = ch.value;
34539
- }
34540
- }
34541
- return min;
34542
- }
34543
- get maxValue() {
34544
- let max = null;
34545
- for (const ch of this._def.checks) {
34546
- if (ch.kind === "max") {
34547
- if (max === null || ch.value < max)
34548
- max = ch.value;
34549
- }
34550
- }
34551
- return max;
34552
- }
34553
- get isInt() {
34554
- return !!this._def.checks.find((ch) => ch.kind === "int" || ch.kind === "multipleOf" && util2.isInteger(ch.value));
34555
- }
34556
- get isFinite() {
34557
- let max = null;
34558
- let min = null;
34559
- for (const ch of this._def.checks) {
34560
- if (ch.kind === "finite" || ch.kind === "int" || ch.kind === "multipleOf") {
34561
- return true;
34562
- } else if (ch.kind === "min") {
34563
- if (min === null || ch.value > min)
34564
- min = ch.value;
34565
- } else if (ch.kind === "max") {
34566
- if (max === null || ch.value < max)
34567
- max = ch.value;
34568
- }
34569
- }
34570
- return Number.isFinite(min) && Number.isFinite(max);
34571
- }
34572
- };
34573
- ZodNumber3.create = (params) => {
34574
- return new ZodNumber3({
34575
- checks: [],
34576
- typeName: ZodFirstPartyTypeKind3.ZodNumber,
34577
- coerce: params?.coerce || false,
34578
- ...processCreateParams2(params)
34579
- });
34580
- };
34581
- var ZodBigInt3 = class _ZodBigInt extends ZodType3 {
34582
- constructor() {
34583
- super(...arguments);
34584
- this.min = this.gte;
34585
- this.max = this.lte;
34586
- }
34587
- _parse(input) {
34588
- if (this._def.coerce) {
34589
- try {
34590
- input.data = BigInt(input.data);
34591
- } catch {
34592
- return this._getInvalidInput(input);
34593
- }
34594
- }
34595
- const parsedType2 = this._getType(input);
34596
- if (parsedType2 !== ZodParsedType2.bigint) {
34597
- return this._getInvalidInput(input);
34598
- }
34599
- let ctx = void 0;
34600
- const status = new ParseStatus2();
34601
- for (const check2 of this._def.checks) {
34602
- if (check2.kind === "min") {
34603
- const tooSmall = check2.inclusive ? input.data < check2.value : input.data <= check2.value;
34604
- if (tooSmall) {
34605
- ctx = this._getOrReturnCtx(input, ctx);
34606
- addIssueToContext2(ctx, {
34607
- code: ZodIssueCode3.too_small,
34608
- type: "bigint",
34609
- minimum: check2.value,
34610
- inclusive: check2.inclusive,
34611
- message: check2.message
34612
- });
34613
- status.dirty();
34614
- }
34615
- } else if (check2.kind === "max") {
34616
- const tooBig = check2.inclusive ? input.data > check2.value : input.data >= check2.value;
34617
- if (tooBig) {
34618
- ctx = this._getOrReturnCtx(input, ctx);
34619
- addIssueToContext2(ctx, {
34620
- code: ZodIssueCode3.too_big,
34621
- type: "bigint",
34622
- maximum: check2.value,
34623
- inclusive: check2.inclusive,
34624
- message: check2.message
34625
- });
34626
- status.dirty();
34627
- }
34628
- } else if (check2.kind === "multipleOf") {
34629
- if (input.data % check2.value !== BigInt(0)) {
34630
- ctx = this._getOrReturnCtx(input, ctx);
34631
- addIssueToContext2(ctx, {
34632
- code: ZodIssueCode3.not_multiple_of,
34633
- multipleOf: check2.value,
34634
- message: check2.message
34635
- });
34636
- status.dirty();
34637
- }
34638
- } else {
34639
- util2.assertNever(check2);
34640
- }
34641
- }
34642
- return { status: status.value, value: input.data };
34643
- }
34644
- _getInvalidInput(input) {
34645
- const ctx = this._getOrReturnCtx(input);
34646
- addIssueToContext2(ctx, {
34647
- code: ZodIssueCode3.invalid_type,
34648
- expected: ZodParsedType2.bigint,
34649
- received: ctx.parsedType
34650
- });
34651
- return INVALID2;
34652
- }
34653
- gte(value, message) {
34654
- return this.setLimit("min", value, true, errorUtil2.toString(message));
34655
- }
34656
- gt(value, message) {
34657
- return this.setLimit("min", value, false, errorUtil2.toString(message));
34658
- }
34659
- lte(value, message) {
34660
- return this.setLimit("max", value, true, errorUtil2.toString(message));
34661
- }
34662
- lt(value, message) {
34663
- return this.setLimit("max", value, false, errorUtil2.toString(message));
34664
- }
34665
- setLimit(kind, value, inclusive, message) {
34666
- return new _ZodBigInt({
34667
- ...this._def,
34668
- checks: [
34669
- ...this._def.checks,
34670
- {
34671
- kind,
34672
- value,
34673
- inclusive,
34674
- message: errorUtil2.toString(message)
34675
- }
34676
- ]
34677
- });
34678
- }
34679
- _addCheck(check2) {
34680
- return new _ZodBigInt({
34681
- ...this._def,
34682
- checks: [...this._def.checks, check2]
34683
- });
34684
- }
34685
- positive(message) {
34686
- return this._addCheck({
34687
- kind: "min",
34688
- value: BigInt(0),
34689
- inclusive: false,
34690
- message: errorUtil2.toString(message)
34691
- });
34692
- }
34693
- negative(message) {
34694
- return this._addCheck({
34695
- kind: "max",
34696
- value: BigInt(0),
34697
- inclusive: false,
34698
- message: errorUtil2.toString(message)
34699
- });
34700
- }
34701
- nonpositive(message) {
34702
- return this._addCheck({
34703
- kind: "max",
34704
- value: BigInt(0),
34705
- inclusive: true,
34706
- message: errorUtil2.toString(message)
34707
- });
34708
- }
34709
- nonnegative(message) {
34710
- return this._addCheck({
34711
- kind: "min",
34712
- value: BigInt(0),
34713
- inclusive: true,
34714
- message: errorUtil2.toString(message)
34715
- });
34716
- }
34717
- multipleOf(value, message) {
34718
- return this._addCheck({
34719
- kind: "multipleOf",
34720
- value,
34721
- message: errorUtil2.toString(message)
34722
- });
34723
- }
34724
- get minValue() {
34725
- let min = null;
34726
- for (const ch of this._def.checks) {
34727
- if (ch.kind === "min") {
34728
- if (min === null || ch.value > min)
34729
- min = ch.value;
34730
- }
34731
- }
34732
- return min;
34733
- }
34734
- get maxValue() {
34735
- let max = null;
34736
- for (const ch of this._def.checks) {
34737
- if (ch.kind === "max") {
34738
- if (max === null || ch.value < max)
34739
- max = ch.value;
34740
- }
34741
- }
34742
- return max;
34743
- }
34744
- };
34745
- ZodBigInt3.create = (params) => {
34746
- return new ZodBigInt3({
34747
- checks: [],
34748
- typeName: ZodFirstPartyTypeKind3.ZodBigInt,
34749
- coerce: params?.coerce ?? false,
34750
- ...processCreateParams2(params)
34751
- });
34752
- };
34753
- var ZodBoolean3 = class extends ZodType3 {
34754
- _parse(input) {
34755
- if (this._def.coerce) {
34756
- input.data = Boolean(input.data);
34757
- }
34758
- const parsedType2 = this._getType(input);
34759
- if (parsedType2 !== ZodParsedType2.boolean) {
34760
- const ctx = this._getOrReturnCtx(input);
34761
- addIssueToContext2(ctx, {
34762
- code: ZodIssueCode3.invalid_type,
34763
- expected: ZodParsedType2.boolean,
34764
- received: ctx.parsedType
34765
- });
34766
- return INVALID2;
34767
- }
34768
- return OK2(input.data);
34769
- }
34770
- };
34771
- ZodBoolean3.create = (params) => {
34772
- return new ZodBoolean3({
34773
- typeName: ZodFirstPartyTypeKind3.ZodBoolean,
34774
- coerce: params?.coerce || false,
34775
- ...processCreateParams2(params)
34776
- });
34777
- };
34778
- var ZodDate3 = class _ZodDate extends ZodType3 {
34779
- _parse(input) {
34780
- if (this._def.coerce) {
34781
- input.data = new Date(input.data);
34782
- }
34783
- const parsedType2 = this._getType(input);
34784
- if (parsedType2 !== ZodParsedType2.date) {
34785
- const ctx2 = this._getOrReturnCtx(input);
34786
- addIssueToContext2(ctx2, {
34787
- code: ZodIssueCode3.invalid_type,
34788
- expected: ZodParsedType2.date,
34789
- received: ctx2.parsedType
34790
- });
34791
- return INVALID2;
34792
- }
34793
- if (Number.isNaN(input.data.getTime())) {
34794
- const ctx2 = this._getOrReturnCtx(input);
34795
- addIssueToContext2(ctx2, {
34796
- code: ZodIssueCode3.invalid_date
34797
- });
34798
- return INVALID2;
34799
- }
34800
- const status = new ParseStatus2();
34801
- let ctx = void 0;
34802
- for (const check2 of this._def.checks) {
34803
- if (check2.kind === "min") {
34804
- if (input.data.getTime() < check2.value) {
34805
- ctx = this._getOrReturnCtx(input, ctx);
34806
- addIssueToContext2(ctx, {
34807
- code: ZodIssueCode3.too_small,
34808
- message: check2.message,
34809
- inclusive: true,
34810
- exact: false,
34811
- minimum: check2.value,
34812
- type: "date"
34813
- });
34814
- status.dirty();
34815
- }
34816
- } else if (check2.kind === "max") {
34817
- if (input.data.getTime() > check2.value) {
34818
- ctx = this._getOrReturnCtx(input, ctx);
34819
- addIssueToContext2(ctx, {
34820
- code: ZodIssueCode3.too_big,
34821
- message: check2.message,
34822
- inclusive: true,
34823
- exact: false,
34824
- maximum: check2.value,
34825
- type: "date"
34826
- });
34827
- status.dirty();
34828
- }
34829
- } else {
34830
- util2.assertNever(check2);
34831
- }
34832
- }
34833
- return {
34834
- status: status.value,
34835
- value: new Date(input.data.getTime())
34836
- };
34837
- }
34838
- _addCheck(check2) {
34839
- return new _ZodDate({
34840
- ...this._def,
34841
- checks: [...this._def.checks, check2]
34842
- });
34843
- }
34844
- min(minDate, message) {
34845
- return this._addCheck({
34846
- kind: "min",
34847
- value: minDate.getTime(),
34848
- message: errorUtil2.toString(message)
34849
- });
34850
- }
34851
- max(maxDate, message) {
34852
- return this._addCheck({
34853
- kind: "max",
34854
- value: maxDate.getTime(),
34855
- message: errorUtil2.toString(message)
34856
- });
34857
- }
34858
- get minDate() {
34859
- let min = null;
34860
- for (const ch of this._def.checks) {
34861
- if (ch.kind === "min") {
34862
- if (min === null || ch.value > min)
34863
- min = ch.value;
34864
- }
34865
- }
34866
- return min != null ? new Date(min) : null;
34867
- }
34868
- get maxDate() {
34869
- let max = null;
34870
- for (const ch of this._def.checks) {
34871
- if (ch.kind === "max") {
34872
- if (max === null || ch.value < max)
34873
- max = ch.value;
34874
- }
34875
- }
34876
- return max != null ? new Date(max) : null;
34877
- }
34878
- };
34879
- ZodDate3.create = (params) => {
34880
- return new ZodDate3({
34881
- checks: [],
34882
- coerce: params?.coerce || false,
34883
- typeName: ZodFirstPartyTypeKind3.ZodDate,
34884
- ...processCreateParams2(params)
34885
- });
34886
- };
34887
- var ZodSymbol3 = class extends ZodType3 {
34888
- _parse(input) {
34889
- const parsedType2 = this._getType(input);
34890
- if (parsedType2 !== ZodParsedType2.symbol) {
34891
- const ctx = this._getOrReturnCtx(input);
34892
- addIssueToContext2(ctx, {
34893
- code: ZodIssueCode3.invalid_type,
34894
- expected: ZodParsedType2.symbol,
34895
- received: ctx.parsedType
34896
- });
34897
- return INVALID2;
34898
- }
34899
- return OK2(input.data);
34900
- }
34901
- };
34902
- ZodSymbol3.create = (params) => {
34903
- return new ZodSymbol3({
34904
- typeName: ZodFirstPartyTypeKind3.ZodSymbol,
34905
- ...processCreateParams2(params)
34906
- });
34907
- };
34908
- var ZodUndefined3 = class extends ZodType3 {
34909
- _parse(input) {
34910
- const parsedType2 = this._getType(input);
34911
- if (parsedType2 !== ZodParsedType2.undefined) {
34912
- const ctx = this._getOrReturnCtx(input);
34913
- addIssueToContext2(ctx, {
34914
- code: ZodIssueCode3.invalid_type,
34915
- expected: ZodParsedType2.undefined,
34916
- received: ctx.parsedType
34917
- });
34918
- return INVALID2;
34919
- }
34920
- return OK2(input.data);
34921
- }
34922
- };
34923
- ZodUndefined3.create = (params) => {
34924
- return new ZodUndefined3({
34925
- typeName: ZodFirstPartyTypeKind3.ZodUndefined,
34926
- ...processCreateParams2(params)
34927
- });
34928
- };
34929
- var ZodNull3 = class extends ZodType3 {
34930
- _parse(input) {
34931
- const parsedType2 = this._getType(input);
34932
- if (parsedType2 !== ZodParsedType2.null) {
34933
- const ctx = this._getOrReturnCtx(input);
34934
- addIssueToContext2(ctx, {
34935
- code: ZodIssueCode3.invalid_type,
34936
- expected: ZodParsedType2.null,
34937
- received: ctx.parsedType
34938
- });
34939
- return INVALID2;
34940
- }
34941
- return OK2(input.data);
34942
- }
34943
- };
34944
- ZodNull3.create = (params) => {
34945
- return new ZodNull3({
34946
- typeName: ZodFirstPartyTypeKind3.ZodNull,
34947
- ...processCreateParams2(params)
34948
- });
34949
- };
34950
- var ZodAny3 = class extends ZodType3 {
34951
- constructor() {
34952
- super(...arguments);
34953
- this._any = true;
34954
- }
34955
- _parse(input) {
34956
- return OK2(input.data);
34957
- }
34958
- };
34959
- ZodAny3.create = (params) => {
34960
- return new ZodAny3({
34961
- typeName: ZodFirstPartyTypeKind3.ZodAny,
34962
- ...processCreateParams2(params)
34963
- });
34964
- };
34965
- var ZodUnknown3 = class extends ZodType3 {
34966
- constructor() {
34967
- super(...arguments);
34968
- this._unknown = true;
34969
- }
34970
- _parse(input) {
34971
- return OK2(input.data);
34972
- }
34973
- };
34974
- ZodUnknown3.create = (params) => {
34975
- return new ZodUnknown3({
34976
- typeName: ZodFirstPartyTypeKind3.ZodUnknown,
34977
- ...processCreateParams2(params)
34978
- });
34979
- };
34980
- var ZodNever3 = class extends ZodType3 {
34981
- _parse(input) {
34982
- const ctx = this._getOrReturnCtx(input);
34983
- addIssueToContext2(ctx, {
34984
- code: ZodIssueCode3.invalid_type,
34985
- expected: ZodParsedType2.never,
34986
- received: ctx.parsedType
34987
- });
34988
- return INVALID2;
34989
- }
34990
- };
34991
- ZodNever3.create = (params) => {
34992
- return new ZodNever3({
34993
- typeName: ZodFirstPartyTypeKind3.ZodNever,
34994
- ...processCreateParams2(params)
34995
- });
34996
- };
34997
- var ZodVoid3 = class extends ZodType3 {
34998
- _parse(input) {
34999
- const parsedType2 = this._getType(input);
35000
- if (parsedType2 !== ZodParsedType2.undefined) {
35001
- const ctx = this._getOrReturnCtx(input);
35002
- addIssueToContext2(ctx, {
35003
- code: ZodIssueCode3.invalid_type,
35004
- expected: ZodParsedType2.void,
35005
- received: ctx.parsedType
35006
- });
35007
- return INVALID2;
35008
- }
35009
- return OK2(input.data);
35010
- }
35011
- };
35012
- ZodVoid3.create = (params) => {
35013
- return new ZodVoid3({
35014
- typeName: ZodFirstPartyTypeKind3.ZodVoid,
35015
- ...processCreateParams2(params)
35016
- });
35017
- };
35018
- var ZodArray3 = class _ZodArray extends ZodType3 {
35019
- _parse(input) {
35020
- const { ctx, status } = this._processInputParams(input);
35021
- const def = this._def;
35022
- if (ctx.parsedType !== ZodParsedType2.array) {
35023
- addIssueToContext2(ctx, {
35024
- code: ZodIssueCode3.invalid_type,
35025
- expected: ZodParsedType2.array,
35026
- received: ctx.parsedType
35027
- });
35028
- return INVALID2;
35029
- }
35030
- if (def.exactLength !== null) {
35031
- const tooBig = ctx.data.length > def.exactLength.value;
35032
- const tooSmall = ctx.data.length < def.exactLength.value;
35033
- if (tooBig || tooSmall) {
35034
- addIssueToContext2(ctx, {
35035
- code: tooBig ? ZodIssueCode3.too_big : ZodIssueCode3.too_small,
35036
- minimum: tooSmall ? def.exactLength.value : void 0,
35037
- maximum: tooBig ? def.exactLength.value : void 0,
35038
- type: "array",
35039
- inclusive: true,
35040
- exact: true,
35041
- message: def.exactLength.message
35042
- });
35043
- status.dirty();
35044
- }
35045
- }
35046
- if (def.minLength !== null) {
35047
- if (ctx.data.length < def.minLength.value) {
35048
- addIssueToContext2(ctx, {
35049
- code: ZodIssueCode3.too_small,
35050
- minimum: def.minLength.value,
35051
- type: "array",
35052
- inclusive: true,
35053
- exact: false,
35054
- message: def.minLength.message
35055
- });
35056
- status.dirty();
35057
- }
35058
- }
35059
- if (def.maxLength !== null) {
35060
- if (ctx.data.length > def.maxLength.value) {
35061
- addIssueToContext2(ctx, {
35062
- code: ZodIssueCode3.too_big,
35063
- maximum: def.maxLength.value,
35064
- type: "array",
35065
- inclusive: true,
35066
- exact: false,
35067
- message: def.maxLength.message
35068
- });
35069
- status.dirty();
35070
- }
35071
- }
35072
- if (ctx.common.async) {
35073
- return Promise.all([...ctx.data].map((item, i) => {
35074
- return def.type._parseAsync(new ParseInputLazyPath2(ctx, item, ctx.path, i));
35075
- })).then((result2) => {
35076
- return ParseStatus2.mergeArray(status, result2);
35077
- });
35078
- }
35079
- const result = [...ctx.data].map((item, i) => {
35080
- return def.type._parseSync(new ParseInputLazyPath2(ctx, item, ctx.path, i));
35081
- });
35082
- return ParseStatus2.mergeArray(status, result);
35083
- }
35084
- get element() {
35085
- return this._def.type;
35086
- }
35087
- min(minLength, message) {
35088
- return new _ZodArray({
35089
- ...this._def,
35090
- minLength: { value: minLength, message: errorUtil2.toString(message) }
35091
- });
35092
- }
35093
- max(maxLength, message) {
35094
- return new _ZodArray({
35095
- ...this._def,
35096
- maxLength: { value: maxLength, message: errorUtil2.toString(message) }
35097
- });
35098
- }
35099
- length(len, message) {
35100
- return new _ZodArray({
35101
- ...this._def,
35102
- exactLength: { value: len, message: errorUtil2.toString(message) }
35103
- });
35104
- }
35105
- nonempty(message) {
35106
- return this.min(1, message);
35107
- }
35108
- };
35109
- ZodArray3.create = (schema, params) => {
35110
- return new ZodArray3({
35111
- type: schema,
35112
- minLength: null,
35113
- maxLength: null,
35114
- exactLength: null,
35115
- typeName: ZodFirstPartyTypeKind3.ZodArray,
35116
- ...processCreateParams2(params)
35117
- });
35118
- };
35119
- function deepPartialify2(schema) {
35120
- if (schema instanceof ZodObject3) {
35121
- const newShape = {};
35122
- for (const key in schema.shape) {
35123
- const fieldSchema = schema.shape[key];
35124
- newShape[key] = ZodOptional3.create(deepPartialify2(fieldSchema));
35125
- }
35126
- return new ZodObject3({
35127
- ...schema._def,
35128
- shape: () => newShape
35129
- });
35130
- } else if (schema instanceof ZodArray3) {
35131
- return new ZodArray3({
35132
- ...schema._def,
35133
- type: deepPartialify2(schema.element)
35134
- });
35135
- } else if (schema instanceof ZodOptional3) {
35136
- return ZodOptional3.create(deepPartialify2(schema.unwrap()));
35137
- } else if (schema instanceof ZodNullable3) {
35138
- return ZodNullable3.create(deepPartialify2(schema.unwrap()));
35139
- } else if (schema instanceof ZodTuple3) {
35140
- return ZodTuple3.create(schema.items.map((item) => deepPartialify2(item)));
35141
- } else {
35142
- return schema;
35143
- }
35144
- }
35145
- var ZodObject3 = class _ZodObject extends ZodType3 {
35146
- constructor() {
35147
- super(...arguments);
35148
- this._cached = null;
35149
- this.nonstrict = this.passthrough;
35150
- this.augment = this.extend;
35151
- }
35152
- _getCached() {
35153
- if (this._cached !== null)
35154
- return this._cached;
35155
- const shape = this._def.shape();
35156
- const keys = util2.objectKeys(shape);
35157
- this._cached = { shape, keys };
35158
- return this._cached;
35159
- }
35160
- _parse(input) {
35161
- const parsedType2 = this._getType(input);
35162
- if (parsedType2 !== ZodParsedType2.object) {
35163
- const ctx2 = this._getOrReturnCtx(input);
35164
- addIssueToContext2(ctx2, {
35165
- code: ZodIssueCode3.invalid_type,
35166
- expected: ZodParsedType2.object,
35167
- received: ctx2.parsedType
35168
- });
35169
- return INVALID2;
35170
- }
35171
- const { status, ctx } = this._processInputParams(input);
35172
- const { shape, keys: shapeKeys } = this._getCached();
35173
- const extraKeys = [];
35174
- if (!(this._def.catchall instanceof ZodNever3 && this._def.unknownKeys === "strip")) {
35175
- for (const key in ctx.data) {
35176
- if (!shapeKeys.includes(key)) {
35177
- extraKeys.push(key);
35178
- }
35179
- }
35180
- }
35181
- const pairs = [];
35182
- for (const key of shapeKeys) {
35183
- const keyValidator = shape[key];
35184
- const value = ctx.data[key];
35185
- pairs.push({
35186
- key: { status: "valid", value: key },
35187
- value: keyValidator._parse(new ParseInputLazyPath2(ctx, value, ctx.path, key)),
35188
- alwaysSet: key in ctx.data
35189
- });
35190
- }
35191
- if (this._def.catchall instanceof ZodNever3) {
35192
- const unknownKeys = this._def.unknownKeys;
35193
- if (unknownKeys === "passthrough") {
35194
- for (const key of extraKeys) {
35195
- pairs.push({
35196
- key: { status: "valid", value: key },
35197
- value: { status: "valid", value: ctx.data[key] }
35198
- });
35199
- }
35200
- } else if (unknownKeys === "strict") {
35201
- if (extraKeys.length > 0) {
35202
- addIssueToContext2(ctx, {
35203
- code: ZodIssueCode3.unrecognized_keys,
35204
- keys: extraKeys
35205
- });
35206
- status.dirty();
35207
- }
35208
- } else if (unknownKeys === "strip") {
35209
- } else {
35210
- throw new Error(`Internal ZodObject error: invalid unknownKeys value.`);
35211
- }
35212
- } else {
35213
- const catchall = this._def.catchall;
35214
- for (const key of extraKeys) {
35215
- const value = ctx.data[key];
35216
- pairs.push({
35217
- key: { status: "valid", value: key },
35218
- value: catchall._parse(
35219
- new ParseInputLazyPath2(ctx, value, ctx.path, key)
35220
- //, ctx.child(key), value, getParsedType(value)
35221
- ),
35222
- alwaysSet: key in ctx.data
35223
- });
35224
- }
35225
- }
35226
- if (ctx.common.async) {
35227
- return Promise.resolve().then(async () => {
35228
- const syncPairs = [];
35229
- for (const pair of pairs) {
35230
- const key = await pair.key;
35231
- const value = await pair.value;
35232
- syncPairs.push({
35233
- key,
35234
- value,
35235
- alwaysSet: pair.alwaysSet
35236
- });
35237
- }
35238
- return syncPairs;
35239
- }).then((syncPairs) => {
35240
- return ParseStatus2.mergeObjectSync(status, syncPairs);
35241
- });
35242
- } else {
35243
- return ParseStatus2.mergeObjectSync(status, pairs);
35244
- }
35245
- }
35246
- get shape() {
35247
- return this._def.shape();
35248
- }
35249
- strict(message) {
35250
- errorUtil2.errToObj;
35251
- return new _ZodObject({
35252
- ...this._def,
35253
- unknownKeys: "strict",
35254
- ...message !== void 0 ? {
35255
- errorMap: (issue2, ctx) => {
35256
- const defaultError = this._def.errorMap?.(issue2, ctx).message ?? ctx.defaultError;
35257
- if (issue2.code === "unrecognized_keys")
35258
- return {
35259
- message: errorUtil2.errToObj(message).message ?? defaultError
35260
- };
35261
- return {
35262
- message: defaultError
35263
- };
35264
- }
35265
- } : {}
35266
- });
35267
- }
35268
- strip() {
35269
- return new _ZodObject({
35270
- ...this._def,
35271
- unknownKeys: "strip"
35272
- });
35273
- }
35274
- passthrough() {
35275
- return new _ZodObject({
35276
- ...this._def,
35277
- unknownKeys: "passthrough"
35278
- });
35279
- }
35280
- // const AugmentFactory =
35281
- // <Def extends ZodObjectDef>(def: Def) =>
35282
- // <Augmentation extends ZodRawShape>(
35283
- // augmentation: Augmentation
35284
- // ): ZodObject<
35285
- // extendShape<ReturnType<Def["shape"]>, Augmentation>,
35286
- // Def["unknownKeys"],
35287
- // Def["catchall"]
35288
- // > => {
35289
- // return new ZodObject({
35290
- // ...def,
35291
- // shape: () => ({
35292
- // ...def.shape(),
35293
- // ...augmentation,
35294
- // }),
35295
- // }) as any;
35296
- // };
35297
- extend(augmentation) {
35298
- return new _ZodObject({
35299
- ...this._def,
35300
- shape: () => ({
35301
- ...this._def.shape(),
35302
- ...augmentation
35303
- })
35304
- });
35305
- }
35306
- /**
35307
- * Prior to zod@1.0.12 there was a bug in the
35308
- * inferred type of merged objects. Please
35309
- * upgrade if you are experiencing issues.
35310
- */
35311
- merge(merging) {
35312
- const merged = new _ZodObject({
35313
- unknownKeys: merging._def.unknownKeys,
35314
- catchall: merging._def.catchall,
35315
- shape: () => ({
35316
- ...this._def.shape(),
35317
- ...merging._def.shape()
35318
- }),
35319
- typeName: ZodFirstPartyTypeKind3.ZodObject
35320
- });
35321
- return merged;
35322
- }
35323
- // merge<
35324
- // Incoming extends AnyZodObject,
35325
- // Augmentation extends Incoming["shape"],
35326
- // NewOutput extends {
35327
- // [k in keyof Augmentation | keyof Output]: k extends keyof Augmentation
35328
- // ? Augmentation[k]["_output"]
35329
- // : k extends keyof Output
35330
- // ? Output[k]
35331
- // : never;
35332
- // },
35333
- // NewInput extends {
35334
- // [k in keyof Augmentation | keyof Input]: k extends keyof Augmentation
35335
- // ? Augmentation[k]["_input"]
35336
- // : k extends keyof Input
35337
- // ? Input[k]
35338
- // : never;
35339
- // }
35340
- // >(
35341
- // merging: Incoming
35342
- // ): ZodObject<
35343
- // extendShape<T, ReturnType<Incoming["_def"]["shape"]>>,
35344
- // Incoming["_def"]["unknownKeys"],
35345
- // Incoming["_def"]["catchall"],
35346
- // NewOutput,
35347
- // NewInput
35348
- // > {
35349
- // const merged: any = new ZodObject({
35350
- // unknownKeys: merging._def.unknownKeys,
35351
- // catchall: merging._def.catchall,
35352
- // shape: () =>
35353
- // objectUtil.mergeShapes(this._def.shape(), merging._def.shape()),
35354
- // typeName: ZodFirstPartyTypeKind.ZodObject,
35355
- // }) as any;
35356
- // return merged;
35357
- // }
35358
- setKey(key, schema) {
35359
- return this.augment({ [key]: schema });
35360
- }
35361
- // merge<Incoming extends AnyZodObject>(
35362
- // merging: Incoming
35363
- // ): //ZodObject<T & Incoming["_shape"], UnknownKeys, Catchall> = (merging) => {
35364
- // ZodObject<
35365
- // extendShape<T, ReturnType<Incoming["_def"]["shape"]>>,
35366
- // Incoming["_def"]["unknownKeys"],
35367
- // Incoming["_def"]["catchall"]
35368
- // > {
35369
- // // const mergedShape = objectUtil.mergeShapes(
35370
- // // this._def.shape(),
35371
- // // merging._def.shape()
35372
- // // );
35373
- // const merged: any = new ZodObject({
35374
- // unknownKeys: merging._def.unknownKeys,
35375
- // catchall: merging._def.catchall,
35376
- // shape: () =>
35377
- // objectUtil.mergeShapes(this._def.shape(), merging._def.shape()),
35378
- // typeName: ZodFirstPartyTypeKind.ZodObject,
35379
- // }) as any;
35380
- // return merged;
35381
- // }
35382
- catchall(index) {
35383
- return new _ZodObject({
35384
- ...this._def,
35385
- catchall: index
35386
- });
35387
- }
35388
- pick(mask) {
35389
- const shape = {};
35390
- for (const key of util2.objectKeys(mask)) {
35391
- if (mask[key] && this.shape[key]) {
35392
- shape[key] = this.shape[key];
35393
- }
35394
- }
35395
- return new _ZodObject({
35396
- ...this._def,
35397
- shape: () => shape
35398
- });
35399
- }
35400
- omit(mask) {
35401
- const shape = {};
35402
- for (const key of util2.objectKeys(this.shape)) {
35403
- if (!mask[key]) {
35404
- shape[key] = this.shape[key];
35405
- }
35406
- }
35407
- return new _ZodObject({
35408
- ...this._def,
35409
- shape: () => shape
35410
- });
35411
- }
35412
- /**
35413
- * @deprecated
35414
- */
35415
- deepPartial() {
35416
- return deepPartialify2(this);
35417
- }
35418
- partial(mask) {
35419
- const newShape = {};
35420
- for (const key of util2.objectKeys(this.shape)) {
35421
- const fieldSchema = this.shape[key];
35422
- if (mask && !mask[key]) {
35423
- newShape[key] = fieldSchema;
35424
- } else {
35425
- newShape[key] = fieldSchema.optional();
35426
- }
35427
- }
35428
- return new _ZodObject({
35429
- ...this._def,
35430
- shape: () => newShape
35431
- });
35432
- }
35433
- required(mask) {
35434
- const newShape = {};
35435
- for (const key of util2.objectKeys(this.shape)) {
35436
- if (mask && !mask[key]) {
35437
- newShape[key] = this.shape[key];
35438
- } else {
35439
- const fieldSchema = this.shape[key];
35440
- let newField = fieldSchema;
35441
- while (newField instanceof ZodOptional3) {
35442
- newField = newField._def.innerType;
35443
- }
35444
- newShape[key] = newField;
35445
- }
35446
- }
35447
- return new _ZodObject({
35448
- ...this._def,
35449
- shape: () => newShape
35450
- });
35451
- }
35452
- keyof() {
35453
- return createZodEnum2(util2.objectKeys(this.shape));
35454
- }
35455
- };
35456
- ZodObject3.create = (shape, params) => {
35457
- return new ZodObject3({
35458
- shape: () => shape,
35459
- unknownKeys: "strip",
35460
- catchall: ZodNever3.create(),
35461
- typeName: ZodFirstPartyTypeKind3.ZodObject,
35462
- ...processCreateParams2(params)
35463
- });
35464
- };
35465
- ZodObject3.strictCreate = (shape, params) => {
35466
- return new ZodObject3({
35467
- shape: () => shape,
35468
- unknownKeys: "strict",
35469
- catchall: ZodNever3.create(),
35470
- typeName: ZodFirstPartyTypeKind3.ZodObject,
35471
- ...processCreateParams2(params)
35472
- });
35473
- };
35474
- ZodObject3.lazycreate = (shape, params) => {
35475
- return new ZodObject3({
35476
- shape,
35477
- unknownKeys: "strip",
35478
- catchall: ZodNever3.create(),
35479
- typeName: ZodFirstPartyTypeKind3.ZodObject,
35480
- ...processCreateParams2(params)
35481
- });
35482
- };
35483
- var ZodUnion3 = class extends ZodType3 {
35484
- _parse(input) {
35485
- const { ctx } = this._processInputParams(input);
35486
- const options3 = this._def.options;
35487
- function handleResults(results) {
35488
- for (const result of results) {
35489
- if (result.result.status === "valid") {
35490
- return result.result;
35491
- }
35492
- }
35493
- for (const result of results) {
35494
- if (result.result.status === "dirty") {
35495
- ctx.common.issues.push(...result.ctx.common.issues);
35496
- return result.result;
35497
- }
35498
- }
35499
- const unionErrors = results.map((result) => new ZodError3(result.ctx.common.issues));
35500
- addIssueToContext2(ctx, {
35501
- code: ZodIssueCode3.invalid_union,
35502
- unionErrors
35503
- });
35504
- return INVALID2;
35505
- }
35506
- if (ctx.common.async) {
35507
- return Promise.all(options3.map(async (option) => {
35508
- const childCtx = {
35509
- ...ctx,
35510
- common: {
35511
- ...ctx.common,
35512
- issues: []
35513
- },
35514
- parent: null
35515
- };
35516
- return {
35517
- result: await option._parseAsync({
35518
- data: ctx.data,
35519
- path: ctx.path,
35520
- parent: childCtx
35521
- }),
35522
- ctx: childCtx
35523
- };
35524
- })).then(handleResults);
35525
- } else {
35526
- let dirty = void 0;
35527
- const issues = [];
35528
- for (const option of options3) {
35529
- const childCtx = {
35530
- ...ctx,
35531
- common: {
35532
- ...ctx.common,
35533
- issues: []
35534
- },
35535
- parent: null
35536
- };
35537
- const result = option._parseSync({
35538
- data: ctx.data,
35539
- path: ctx.path,
35540
- parent: childCtx
35541
- });
35542
- if (result.status === "valid") {
35543
- return result;
35544
- } else if (result.status === "dirty" && !dirty) {
35545
- dirty = { result, ctx: childCtx };
35546
- }
35547
- if (childCtx.common.issues.length) {
35548
- issues.push(childCtx.common.issues);
35549
- }
35550
- }
35551
- if (dirty) {
35552
- ctx.common.issues.push(...dirty.ctx.common.issues);
35553
- return dirty.result;
35554
- }
35555
- const unionErrors = issues.map((issues2) => new ZodError3(issues2));
35556
- addIssueToContext2(ctx, {
35557
- code: ZodIssueCode3.invalid_union,
35558
- unionErrors
35559
- });
35560
- return INVALID2;
35561
- }
35562
- }
35563
- get options() {
35564
- return this._def.options;
35565
- }
35566
- };
35567
- ZodUnion3.create = (types, params) => {
35568
- return new ZodUnion3({
35569
- options: types,
35570
- typeName: ZodFirstPartyTypeKind3.ZodUnion,
35571
- ...processCreateParams2(params)
35572
- });
35573
- };
35574
- var getDiscriminator2 = (type) => {
35575
- if (type instanceof ZodLazy3) {
35576
- return getDiscriminator2(type.schema);
35577
- } else if (type instanceof ZodEffects2) {
35578
- return getDiscriminator2(type.innerType());
35579
- } else if (type instanceof ZodLiteral3) {
35580
- return [type.value];
35581
- } else if (type instanceof ZodEnum3) {
35582
- return type.options;
35583
- } else if (type instanceof ZodNativeEnum2) {
35584
- return util2.objectValues(type.enum);
35585
- } else if (type instanceof ZodDefault3) {
35586
- return getDiscriminator2(type._def.innerType);
35587
- } else if (type instanceof ZodUndefined3) {
35588
- return [void 0];
35589
- } else if (type instanceof ZodNull3) {
35590
- return [null];
35591
- } else if (type instanceof ZodOptional3) {
35592
- return [void 0, ...getDiscriminator2(type.unwrap())];
35593
- } else if (type instanceof ZodNullable3) {
35594
- return [null, ...getDiscriminator2(type.unwrap())];
35595
- } else if (type instanceof ZodBranded2) {
35596
- return getDiscriminator2(type.unwrap());
35597
- } else if (type instanceof ZodReadonly3) {
35598
- return getDiscriminator2(type.unwrap());
35599
- } else if (type instanceof ZodCatch3) {
35600
- return getDiscriminator2(type._def.innerType);
35601
- } else {
35602
- return [];
35603
- }
35604
- };
35605
- var ZodDiscriminatedUnion3 = class _ZodDiscriminatedUnion extends ZodType3 {
35606
- _parse(input) {
35607
- const { ctx } = this._processInputParams(input);
35608
- if (ctx.parsedType !== ZodParsedType2.object) {
35609
- addIssueToContext2(ctx, {
35610
- code: ZodIssueCode3.invalid_type,
35611
- expected: ZodParsedType2.object,
35612
- received: ctx.parsedType
35613
- });
35614
- return INVALID2;
35615
- }
35616
- const discriminator = this.discriminator;
35617
- const discriminatorValue = ctx.data[discriminator];
35618
- const option = this.optionsMap.get(discriminatorValue);
35619
- if (!option) {
35620
- addIssueToContext2(ctx, {
35621
- code: ZodIssueCode3.invalid_union_discriminator,
35622
- options: Array.from(this.optionsMap.keys()),
35623
- path: [discriminator]
35624
- });
35625
- return INVALID2;
35626
- }
35627
- if (ctx.common.async) {
35628
- return option._parseAsync({
35629
- data: ctx.data,
35630
- path: ctx.path,
35631
- parent: ctx
35632
- });
35633
- } else {
35634
- return option._parseSync({
35635
- data: ctx.data,
35636
- path: ctx.path,
35637
- parent: ctx
35638
- });
35639
- }
35640
- }
35641
- get discriminator() {
35642
- return this._def.discriminator;
35643
- }
35644
- get options() {
35645
- return this._def.options;
35646
- }
35647
- get optionsMap() {
35648
- return this._def.optionsMap;
35649
- }
35650
- /**
35651
- * The constructor of the discriminated union schema. Its behaviour is very similar to that of the normal z.union() constructor.
35652
- * However, it only allows a union of objects, all of which need to share a discriminator property. This property must
35653
- * have a different value for each object in the union.
35654
- * @param discriminator the name of the discriminator property
35655
- * @param types an array of object schemas
35656
- * @param params
35657
- */
35658
- static create(discriminator, options3, params) {
35659
- const optionsMap = /* @__PURE__ */ new Map();
35660
- for (const type of options3) {
35661
- const discriminatorValues = getDiscriminator2(type.shape[discriminator]);
35662
- if (!discriminatorValues.length) {
35663
- throw new Error(`A discriminator value for key \`${discriminator}\` could not be extracted from all schema options`);
35664
- }
35665
- for (const value of discriminatorValues) {
35666
- if (optionsMap.has(value)) {
35667
- throw new Error(`Discriminator property ${String(discriminator)} has duplicate value ${String(value)}`);
35668
- }
35669
- optionsMap.set(value, type);
35670
- }
35671
- }
35672
- return new _ZodDiscriminatedUnion({
35673
- typeName: ZodFirstPartyTypeKind3.ZodDiscriminatedUnion,
35674
- discriminator,
35675
- options: options3,
35676
- optionsMap,
35677
- ...processCreateParams2(params)
35678
- });
35679
- }
35680
- };
35681
- function mergeValues3(a, b) {
35682
- const aType = getParsedType3(a);
35683
- const bType = getParsedType3(b);
35684
- if (a === b) {
35685
- return { valid: true, data: a };
35686
- } else if (aType === ZodParsedType2.object && bType === ZodParsedType2.object) {
35687
- const bKeys = util2.objectKeys(b);
35688
- const sharedKeys = util2.objectKeys(a).filter((key) => bKeys.indexOf(key) !== -1);
35689
- const newObj = { ...a, ...b };
35690
- for (const key of sharedKeys) {
35691
- const sharedValue = mergeValues3(a[key], b[key]);
35692
- if (!sharedValue.valid) {
35693
- return { valid: false };
35694
- }
35695
- newObj[key] = sharedValue.data;
35696
- }
35697
- return { valid: true, data: newObj };
35698
- } else if (aType === ZodParsedType2.array && bType === ZodParsedType2.array) {
35699
- if (a.length !== b.length) {
35700
- return { valid: false };
35701
- }
35702
- const newArray = [];
35703
- for (let index = 0; index < a.length; index++) {
35704
- const itemA = a[index];
35705
- const itemB = b[index];
35706
- const sharedValue = mergeValues3(itemA, itemB);
35707
- if (!sharedValue.valid) {
35708
- return { valid: false };
35709
- }
35710
- newArray.push(sharedValue.data);
35711
- }
35712
- return { valid: true, data: newArray };
35713
- } else if (aType === ZodParsedType2.date && bType === ZodParsedType2.date && +a === +b) {
35714
- return { valid: true, data: a };
35715
- } else {
35716
- return { valid: false };
35717
- }
35718
- }
35719
- var ZodIntersection3 = class extends ZodType3 {
35720
- _parse(input) {
35721
- const { status, ctx } = this._processInputParams(input);
35722
- const handleParsed = (parsedLeft, parsedRight) => {
35723
- if (isAborted2(parsedLeft) || isAborted2(parsedRight)) {
35724
- return INVALID2;
35725
- }
35726
- const merged = mergeValues3(parsedLeft.value, parsedRight.value);
35727
- if (!merged.valid) {
35728
- addIssueToContext2(ctx, {
35729
- code: ZodIssueCode3.invalid_intersection_types
35730
- });
35731
- return INVALID2;
35732
- }
35733
- if (isDirty2(parsedLeft) || isDirty2(parsedRight)) {
35734
- status.dirty();
35735
- }
35736
- return { status: status.value, value: merged.data };
35737
- };
35738
- if (ctx.common.async) {
35739
- return Promise.all([
35740
- this._def.left._parseAsync({
35741
- data: ctx.data,
35742
- path: ctx.path,
35743
- parent: ctx
35744
- }),
35745
- this._def.right._parseAsync({
35746
- data: ctx.data,
35747
- path: ctx.path,
35748
- parent: ctx
35749
- })
35750
- ]).then(([left, right]) => handleParsed(left, right));
35751
- } else {
35752
- return handleParsed(this._def.left._parseSync({
35753
- data: ctx.data,
35754
- path: ctx.path,
35755
- parent: ctx
35756
- }), this._def.right._parseSync({
35757
- data: ctx.data,
35758
- path: ctx.path,
35759
- parent: ctx
35760
- }));
35761
- }
35762
- }
35763
- };
35764
- ZodIntersection3.create = (left, right, params) => {
35765
- return new ZodIntersection3({
35766
- left,
35767
- right,
35768
- typeName: ZodFirstPartyTypeKind3.ZodIntersection,
35769
- ...processCreateParams2(params)
35770
- });
35771
- };
35772
- var ZodTuple3 = class _ZodTuple extends ZodType3 {
35773
- _parse(input) {
35774
- const { status, ctx } = this._processInputParams(input);
35775
- if (ctx.parsedType !== ZodParsedType2.array) {
35776
- addIssueToContext2(ctx, {
35777
- code: ZodIssueCode3.invalid_type,
35778
- expected: ZodParsedType2.array,
35779
- received: ctx.parsedType
35780
- });
35781
- return INVALID2;
35782
- }
35783
- if (ctx.data.length < this._def.items.length) {
35784
- addIssueToContext2(ctx, {
35785
- code: ZodIssueCode3.too_small,
35786
- minimum: this._def.items.length,
35787
- inclusive: true,
35788
- exact: false,
35789
- type: "array"
35790
- });
35791
- return INVALID2;
35792
- }
35793
- const rest = this._def.rest;
35794
- if (!rest && ctx.data.length > this._def.items.length) {
35795
- addIssueToContext2(ctx, {
35796
- code: ZodIssueCode3.too_big,
35797
- maximum: this._def.items.length,
35798
- inclusive: true,
35799
- exact: false,
35800
- type: "array"
35801
- });
35802
- status.dirty();
35803
- }
35804
- const items = [...ctx.data].map((item, itemIndex) => {
35805
- const schema = this._def.items[itemIndex] || this._def.rest;
35806
- if (!schema)
35807
- return null;
35808
- return schema._parse(new ParseInputLazyPath2(ctx, item, ctx.path, itemIndex));
35809
- }).filter((x) => !!x);
35810
- if (ctx.common.async) {
35811
- return Promise.all(items).then((results) => {
35812
- return ParseStatus2.mergeArray(status, results);
35813
- });
35814
- } else {
35815
- return ParseStatus2.mergeArray(status, items);
35816
- }
35817
- }
35818
- get items() {
35819
- return this._def.items;
35820
- }
35821
- rest(rest) {
35822
- return new _ZodTuple({
35823
- ...this._def,
35824
- rest
35825
- });
35826
- }
35827
- };
35828
- ZodTuple3.create = (schemas, params) => {
35829
- if (!Array.isArray(schemas)) {
35830
- throw new Error("You must pass an array of schemas to z.tuple([ ... ])");
35831
- }
35832
- return new ZodTuple3({
35833
- items: schemas,
35834
- typeName: ZodFirstPartyTypeKind3.ZodTuple,
35835
- rest: null,
35836
- ...processCreateParams2(params)
35837
- });
35838
- };
35839
- var ZodRecord3 = class _ZodRecord extends ZodType3 {
35840
- get keySchema() {
35841
- return this._def.keyType;
35842
- }
35843
- get valueSchema() {
35844
- return this._def.valueType;
35845
- }
35846
- _parse(input) {
35847
- const { status, ctx } = this._processInputParams(input);
35848
- if (ctx.parsedType !== ZodParsedType2.object) {
35849
- addIssueToContext2(ctx, {
35850
- code: ZodIssueCode3.invalid_type,
35851
- expected: ZodParsedType2.object,
35852
- received: ctx.parsedType
35853
- });
35854
- return INVALID2;
35855
- }
35856
- const pairs = [];
35857
- const keyType = this._def.keyType;
35858
- const valueType = this._def.valueType;
35859
- for (const key in ctx.data) {
35860
- pairs.push({
35861
- key: keyType._parse(new ParseInputLazyPath2(ctx, key, ctx.path, key)),
35862
- value: valueType._parse(new ParseInputLazyPath2(ctx, ctx.data[key], ctx.path, key)),
35863
- alwaysSet: key in ctx.data
35864
- });
35865
- }
35866
- if (ctx.common.async) {
35867
- return ParseStatus2.mergeObjectAsync(status, pairs);
35868
- } else {
35869
- return ParseStatus2.mergeObjectSync(status, pairs);
35870
- }
35871
- }
35872
- get element() {
35873
- return this._def.valueType;
35874
- }
35875
- static create(first, second, third) {
35876
- if (second instanceof ZodType3) {
35877
- return new _ZodRecord({
35878
- keyType: first,
35879
- valueType: second,
35880
- typeName: ZodFirstPartyTypeKind3.ZodRecord,
35881
- ...processCreateParams2(third)
35882
- });
35883
- }
35884
- return new _ZodRecord({
35885
- keyType: ZodString3.create(),
35886
- valueType: first,
35887
- typeName: ZodFirstPartyTypeKind3.ZodRecord,
35888
- ...processCreateParams2(second)
35889
- });
35890
- }
35891
- };
35892
- var ZodMap3 = class extends ZodType3 {
35893
- get keySchema() {
35894
- return this._def.keyType;
35895
- }
35896
- get valueSchema() {
35897
- return this._def.valueType;
35898
- }
35899
- _parse(input) {
35900
- const { status, ctx } = this._processInputParams(input);
35901
- if (ctx.parsedType !== ZodParsedType2.map) {
35902
- addIssueToContext2(ctx, {
35903
- code: ZodIssueCode3.invalid_type,
35904
- expected: ZodParsedType2.map,
35905
- received: ctx.parsedType
35906
- });
35907
- return INVALID2;
35908
- }
35909
- const keyType = this._def.keyType;
35910
- const valueType = this._def.valueType;
35911
- const pairs = [...ctx.data.entries()].map(([key, value], index) => {
35912
- return {
35913
- key: keyType._parse(new ParseInputLazyPath2(ctx, key, ctx.path, [index, "key"])),
35914
- value: valueType._parse(new ParseInputLazyPath2(ctx, value, ctx.path, [index, "value"]))
35915
- };
35916
- });
35917
- if (ctx.common.async) {
35918
- const finalMap = /* @__PURE__ */ new Map();
35919
- return Promise.resolve().then(async () => {
35920
- for (const pair of pairs) {
35921
- const key = await pair.key;
35922
- const value = await pair.value;
35923
- if (key.status === "aborted" || value.status === "aborted") {
35924
- return INVALID2;
35925
- }
35926
- if (key.status === "dirty" || value.status === "dirty") {
35927
- status.dirty();
35928
- }
35929
- finalMap.set(key.value, value.value);
35930
- }
35931
- return { status: status.value, value: finalMap };
35932
- });
35933
- } else {
35934
- const finalMap = /* @__PURE__ */ new Map();
35935
- for (const pair of pairs) {
35936
- const key = pair.key;
35937
- const value = pair.value;
35938
- if (key.status === "aborted" || value.status === "aborted") {
35939
- return INVALID2;
35940
- }
35941
- if (key.status === "dirty" || value.status === "dirty") {
35942
- status.dirty();
35943
- }
35944
- finalMap.set(key.value, value.value);
35945
- }
35946
- return { status: status.value, value: finalMap };
35947
- }
35948
- }
35949
- };
35950
- ZodMap3.create = (keyType, valueType, params) => {
35951
- return new ZodMap3({
35952
- valueType,
35953
- keyType,
35954
- typeName: ZodFirstPartyTypeKind3.ZodMap,
35955
- ...processCreateParams2(params)
35956
- });
35957
- };
35958
- var ZodSet3 = class _ZodSet extends ZodType3 {
35959
- _parse(input) {
35960
- const { status, ctx } = this._processInputParams(input);
35961
- if (ctx.parsedType !== ZodParsedType2.set) {
35962
- addIssueToContext2(ctx, {
35963
- code: ZodIssueCode3.invalid_type,
35964
- expected: ZodParsedType2.set,
35965
- received: ctx.parsedType
35966
- });
35967
- return INVALID2;
35968
- }
35969
- const def = this._def;
35970
- if (def.minSize !== null) {
35971
- if (ctx.data.size < def.minSize.value) {
35972
- addIssueToContext2(ctx, {
35973
- code: ZodIssueCode3.too_small,
35974
- minimum: def.minSize.value,
35975
- type: "set",
35976
- inclusive: true,
35977
- exact: false,
35978
- message: def.minSize.message
35979
- });
35980
- status.dirty();
35981
- }
35982
- }
35983
- if (def.maxSize !== null) {
35984
- if (ctx.data.size > def.maxSize.value) {
35985
- addIssueToContext2(ctx, {
35986
- code: ZodIssueCode3.too_big,
35987
- maximum: def.maxSize.value,
35988
- type: "set",
35989
- inclusive: true,
35990
- exact: false,
35991
- message: def.maxSize.message
35992
- });
35993
- status.dirty();
35994
- }
35995
- }
35996
- const valueType = this._def.valueType;
35997
- function finalizeSet(elements2) {
35998
- const parsedSet = /* @__PURE__ */ new Set();
35999
- for (const element of elements2) {
36000
- if (element.status === "aborted")
36001
- return INVALID2;
36002
- if (element.status === "dirty")
36003
- status.dirty();
36004
- parsedSet.add(element.value);
36005
- }
36006
- return { status: status.value, value: parsedSet };
36007
- }
36008
- const elements = [...ctx.data.values()].map((item, i) => valueType._parse(new ParseInputLazyPath2(ctx, item, ctx.path, i)));
36009
- if (ctx.common.async) {
36010
- return Promise.all(elements).then((elements2) => finalizeSet(elements2));
36011
- } else {
36012
- return finalizeSet(elements);
36013
- }
36014
- }
36015
- min(minSize, message) {
36016
- return new _ZodSet({
36017
- ...this._def,
36018
- minSize: { value: minSize, message: errorUtil2.toString(message) }
36019
- });
36020
- }
36021
- max(maxSize, message) {
36022
- return new _ZodSet({
36023
- ...this._def,
36024
- maxSize: { value: maxSize, message: errorUtil2.toString(message) }
36025
- });
36026
- }
36027
- size(size, message) {
36028
- return this.min(size, message).max(size, message);
36029
- }
36030
- nonempty(message) {
36031
- return this.min(1, message);
36032
- }
36033
- };
36034
- ZodSet3.create = (valueType, params) => {
36035
- return new ZodSet3({
36036
- valueType,
36037
- minSize: null,
36038
- maxSize: null,
36039
- typeName: ZodFirstPartyTypeKind3.ZodSet,
36040
- ...processCreateParams2(params)
36041
- });
36042
- };
36043
- var ZodFunction3 = class _ZodFunction extends ZodType3 {
36044
- constructor() {
36045
- super(...arguments);
36046
- this.validate = this.implement;
36047
- }
36048
- _parse(input) {
36049
- const { ctx } = this._processInputParams(input);
36050
- if (ctx.parsedType !== ZodParsedType2.function) {
36051
- addIssueToContext2(ctx, {
36052
- code: ZodIssueCode3.invalid_type,
36053
- expected: ZodParsedType2.function,
36054
- received: ctx.parsedType
36055
- });
36056
- return INVALID2;
36057
- }
36058
- function makeArgsIssue(args, error48) {
36059
- return makeIssue2({
36060
- data: args,
36061
- path: ctx.path,
36062
- errorMaps: [ctx.common.contextualErrorMap, ctx.schemaErrorMap, getErrorMap3(), en_default3].filter((x) => !!x),
36063
- issueData: {
36064
- code: ZodIssueCode3.invalid_arguments,
36065
- argumentsError: error48
36066
- }
36067
- });
36068
- }
36069
- function makeReturnsIssue(returns, error48) {
36070
- return makeIssue2({
36071
- data: returns,
36072
- path: ctx.path,
36073
- errorMaps: [ctx.common.contextualErrorMap, ctx.schemaErrorMap, getErrorMap3(), en_default3].filter((x) => !!x),
36074
- issueData: {
36075
- code: ZodIssueCode3.invalid_return_type,
36076
- returnTypeError: error48
36077
- }
36078
- });
36079
- }
36080
- const params = { errorMap: ctx.common.contextualErrorMap };
36081
- const fn = ctx.data;
36082
- if (this._def.returns instanceof ZodPromise3) {
36083
- const me = this;
36084
- return OK2(async function(...args) {
36085
- const error48 = new ZodError3([]);
36086
- const parsedArgs = await me._def.args.parseAsync(args, params).catch((e) => {
36087
- error48.addIssue(makeArgsIssue(args, e));
36088
- throw error48;
36089
- });
36090
- const result = await Reflect.apply(fn, this, parsedArgs);
36091
- const parsedReturns = await me._def.returns._def.type.parseAsync(result, params).catch((e) => {
36092
- error48.addIssue(makeReturnsIssue(result, e));
36093
- throw error48;
36094
- });
36095
- return parsedReturns;
36096
- });
36097
- } else {
36098
- const me = this;
36099
- return OK2(function(...args) {
36100
- const parsedArgs = me._def.args.safeParse(args, params);
36101
- if (!parsedArgs.success) {
36102
- throw new ZodError3([makeArgsIssue(args, parsedArgs.error)]);
36103
- }
36104
- const result = Reflect.apply(fn, this, parsedArgs.data);
36105
- const parsedReturns = me._def.returns.safeParse(result, params);
36106
- if (!parsedReturns.success) {
36107
- throw new ZodError3([makeReturnsIssue(result, parsedReturns.error)]);
36108
- }
36109
- return parsedReturns.data;
36110
- });
36111
- }
36112
- }
36113
- parameters() {
36114
- return this._def.args;
36115
- }
36116
- returnType() {
36117
- return this._def.returns;
36118
- }
36119
- args(...items) {
36120
- return new _ZodFunction({
36121
- ...this._def,
36122
- args: ZodTuple3.create(items).rest(ZodUnknown3.create())
36123
- });
36124
- }
36125
- returns(returnType) {
36126
- return new _ZodFunction({
36127
- ...this._def,
36128
- returns: returnType
36129
- });
36130
- }
36131
- implement(func) {
36132
- const validatedFunc = this.parse(func);
36133
- return validatedFunc;
36134
- }
36135
- strictImplement(func) {
36136
- const validatedFunc = this.parse(func);
36137
- return validatedFunc;
36138
- }
36139
- static create(args, returns, params) {
36140
- return new _ZodFunction({
36141
- args: args ? args : ZodTuple3.create([]).rest(ZodUnknown3.create()),
36142
- returns: returns || ZodUnknown3.create(),
36143
- typeName: ZodFirstPartyTypeKind3.ZodFunction,
36144
- ...processCreateParams2(params)
36145
- });
36146
- }
36147
- };
36148
- var ZodLazy3 = class extends ZodType3 {
36149
- get schema() {
36150
- return this._def.getter();
36151
- }
36152
- _parse(input) {
36153
- const { ctx } = this._processInputParams(input);
36154
- const lazySchema = this._def.getter();
36155
- return lazySchema._parse({ data: ctx.data, path: ctx.path, parent: ctx });
36156
- }
36157
- };
36158
- ZodLazy3.create = (getter, params) => {
36159
- return new ZodLazy3({
36160
- getter,
36161
- typeName: ZodFirstPartyTypeKind3.ZodLazy,
36162
- ...processCreateParams2(params)
36163
- });
36164
- };
36165
- var ZodLiteral3 = class extends ZodType3 {
36166
- _parse(input) {
36167
- if (input.data !== this._def.value) {
36168
- const ctx = this._getOrReturnCtx(input);
36169
- addIssueToContext2(ctx, {
36170
- received: ctx.data,
36171
- code: ZodIssueCode3.invalid_literal,
36172
- expected: this._def.value
36173
- });
36174
- return INVALID2;
36175
- }
36176
- return { status: "valid", value: input.data };
36177
- }
36178
- get value() {
36179
- return this._def.value;
36180
- }
36181
- };
36182
- ZodLiteral3.create = (value, params) => {
36183
- return new ZodLiteral3({
36184
- value,
36185
- typeName: ZodFirstPartyTypeKind3.ZodLiteral,
36186
- ...processCreateParams2(params)
36187
- });
36188
- };
36189
- function createZodEnum2(values, params) {
36190
- return new ZodEnum3({
36191
- values,
36192
- typeName: ZodFirstPartyTypeKind3.ZodEnum,
36193
- ...processCreateParams2(params)
36194
- });
36195
- }
36196
- var ZodEnum3 = class _ZodEnum extends ZodType3 {
36197
- _parse(input) {
36198
- if (typeof input.data !== "string") {
36199
- const ctx = this._getOrReturnCtx(input);
36200
- const expectedValues = this._def.values;
36201
- addIssueToContext2(ctx, {
36202
- expected: util2.joinValues(expectedValues),
36203
- received: ctx.parsedType,
36204
- code: ZodIssueCode3.invalid_type
36205
- });
36206
- return INVALID2;
36207
- }
36208
- if (!this._cache) {
36209
- this._cache = new Set(this._def.values);
36210
- }
36211
- if (!this._cache.has(input.data)) {
36212
- const ctx = this._getOrReturnCtx(input);
36213
- const expectedValues = this._def.values;
36214
- addIssueToContext2(ctx, {
36215
- received: ctx.data,
36216
- code: ZodIssueCode3.invalid_enum_value,
36217
- options: expectedValues
36218
- });
36219
- return INVALID2;
36220
- }
36221
- return OK2(input.data);
36222
- }
36223
- get options() {
36224
- return this._def.values;
36225
- }
36226
- get enum() {
36227
- const enumValues = {};
36228
- for (const val of this._def.values) {
36229
- enumValues[val] = val;
36230
- }
36231
- return enumValues;
36232
- }
36233
- get Values() {
36234
- const enumValues = {};
36235
- for (const val of this._def.values) {
36236
- enumValues[val] = val;
36237
- }
36238
- return enumValues;
36239
- }
36240
- get Enum() {
36241
- const enumValues = {};
36242
- for (const val of this._def.values) {
36243
- enumValues[val] = val;
36244
- }
36245
- return enumValues;
36246
- }
36247
- extract(values, newDef = this._def) {
36248
- return _ZodEnum.create(values, {
36249
- ...this._def,
36250
- ...newDef
36251
- });
36252
- }
36253
- exclude(values, newDef = this._def) {
36254
- return _ZodEnum.create(this.options.filter((opt) => !values.includes(opt)), {
36255
- ...this._def,
36256
- ...newDef
36257
- });
36258
- }
36259
- };
36260
- ZodEnum3.create = createZodEnum2;
36261
- var ZodNativeEnum2 = class extends ZodType3 {
36262
- _parse(input) {
36263
- const nativeEnumValues = util2.getValidEnumValues(this._def.values);
36264
- const ctx = this._getOrReturnCtx(input);
36265
- if (ctx.parsedType !== ZodParsedType2.string && ctx.parsedType !== ZodParsedType2.number) {
36266
- const expectedValues = util2.objectValues(nativeEnumValues);
36267
- addIssueToContext2(ctx, {
36268
- expected: util2.joinValues(expectedValues),
36269
- received: ctx.parsedType,
36270
- code: ZodIssueCode3.invalid_type
36271
- });
36272
- return INVALID2;
36273
- }
36274
- if (!this._cache) {
36275
- this._cache = new Set(util2.getValidEnumValues(this._def.values));
36276
- }
36277
- if (!this._cache.has(input.data)) {
36278
- const expectedValues = util2.objectValues(nativeEnumValues);
36279
- addIssueToContext2(ctx, {
36280
- received: ctx.data,
36281
- code: ZodIssueCode3.invalid_enum_value,
36282
- options: expectedValues
36283
- });
36284
- return INVALID2;
36285
- }
36286
- return OK2(input.data);
36287
- }
36288
- get enum() {
36289
- return this._def.values;
36290
- }
36291
- };
36292
- ZodNativeEnum2.create = (values, params) => {
36293
- return new ZodNativeEnum2({
36294
- values,
36295
- typeName: ZodFirstPartyTypeKind3.ZodNativeEnum,
36296
- ...processCreateParams2(params)
36297
- });
36298
- };
36299
- var ZodPromise3 = class extends ZodType3 {
36300
- unwrap() {
36301
- return this._def.type;
36302
- }
36303
- _parse(input) {
36304
- const { ctx } = this._processInputParams(input);
36305
- if (ctx.parsedType !== ZodParsedType2.promise && ctx.common.async === false) {
36306
- addIssueToContext2(ctx, {
36307
- code: ZodIssueCode3.invalid_type,
36308
- expected: ZodParsedType2.promise,
36309
- received: ctx.parsedType
36310
- });
36311
- return INVALID2;
36312
- }
36313
- const promisified = ctx.parsedType === ZodParsedType2.promise ? ctx.data : Promise.resolve(ctx.data);
36314
- return OK2(promisified.then((data) => {
36315
- return this._def.type.parseAsync(data, {
36316
- path: ctx.path,
36317
- errorMap: ctx.common.contextualErrorMap
36318
- });
36319
- }));
36320
- }
36321
- };
36322
- ZodPromise3.create = (schema, params) => {
36323
- return new ZodPromise3({
36324
- type: schema,
36325
- typeName: ZodFirstPartyTypeKind3.ZodPromise,
36326
- ...processCreateParams2(params)
36327
- });
36328
- };
36329
- var ZodEffects2 = class extends ZodType3 {
36330
- innerType() {
36331
- return this._def.schema;
36332
- }
36333
- sourceType() {
36334
- return this._def.schema._def.typeName === ZodFirstPartyTypeKind3.ZodEffects ? this._def.schema.sourceType() : this._def.schema;
36335
- }
36336
- _parse(input) {
36337
- const { status, ctx } = this._processInputParams(input);
36338
- const effect = this._def.effect || null;
36339
- const checkCtx = {
36340
- addIssue: (arg) => {
36341
- addIssueToContext2(ctx, arg);
36342
- if (arg.fatal) {
36343
- status.abort();
36344
- } else {
36345
- status.dirty();
36346
- }
36347
- },
36348
- get path() {
36349
- return ctx.path;
36350
- }
36351
- };
36352
- checkCtx.addIssue = checkCtx.addIssue.bind(checkCtx);
36353
- if (effect.type === "preprocess") {
36354
- const processed = effect.transform(ctx.data, checkCtx);
36355
- if (ctx.common.async) {
36356
- return Promise.resolve(processed).then(async (processed2) => {
36357
- if (status.value === "aborted")
36358
- return INVALID2;
36359
- const result = await this._def.schema._parseAsync({
36360
- data: processed2,
36361
- path: ctx.path,
36362
- parent: ctx
36363
- });
36364
- if (result.status === "aborted")
36365
- return INVALID2;
36366
- if (result.status === "dirty")
36367
- return DIRTY2(result.value);
36368
- if (status.value === "dirty")
36369
- return DIRTY2(result.value);
36370
- return result;
36371
- });
36372
- } else {
36373
- if (status.value === "aborted")
36374
- return INVALID2;
36375
- const result = this._def.schema._parseSync({
36376
- data: processed,
36377
- path: ctx.path,
36378
- parent: ctx
36379
- });
36380
- if (result.status === "aborted")
36381
- return INVALID2;
36382
- if (result.status === "dirty")
36383
- return DIRTY2(result.value);
36384
- if (status.value === "dirty")
36385
- return DIRTY2(result.value);
36386
- return result;
36387
- }
36388
- }
36389
- if (effect.type === "refinement") {
36390
- const executeRefinement = (acc) => {
36391
- const result = effect.refinement(acc, checkCtx);
36392
- if (ctx.common.async) {
36393
- return Promise.resolve(result);
36394
- }
36395
- if (result instanceof Promise) {
36396
- throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");
36397
- }
36398
- return acc;
36399
- };
36400
- if (ctx.common.async === false) {
36401
- const inner = this._def.schema._parseSync({
36402
- data: ctx.data,
36403
- path: ctx.path,
36404
- parent: ctx
36405
- });
36406
- if (inner.status === "aborted")
36407
- return INVALID2;
36408
- if (inner.status === "dirty")
36409
- status.dirty();
36410
- executeRefinement(inner.value);
36411
- return { status: status.value, value: inner.value };
36412
- } else {
36413
- return this._def.schema._parseAsync({ data: ctx.data, path: ctx.path, parent: ctx }).then((inner) => {
36414
- if (inner.status === "aborted")
36415
- return INVALID2;
36416
- if (inner.status === "dirty")
36417
- status.dirty();
36418
- return executeRefinement(inner.value).then(() => {
36419
- return { status: status.value, value: inner.value };
36420
- });
36421
- });
36422
- }
36423
- }
36424
- if (effect.type === "transform") {
36425
- if (ctx.common.async === false) {
36426
- const base = this._def.schema._parseSync({
36427
- data: ctx.data,
36428
- path: ctx.path,
36429
- parent: ctx
36430
- });
36431
- if (!isValid2(base))
36432
- return INVALID2;
36433
- const result = effect.transform(base.value, checkCtx);
36434
- if (result instanceof Promise) {
36435
- throw new Error(`Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.`);
36436
- }
36437
- return { status: status.value, value: result };
36438
- } else {
36439
- return this._def.schema._parseAsync({ data: ctx.data, path: ctx.path, parent: ctx }).then((base) => {
36440
- if (!isValid2(base))
36441
- return INVALID2;
36442
- return Promise.resolve(effect.transform(base.value, checkCtx)).then((result) => ({
36443
- status: status.value,
36444
- value: result
36445
- }));
36446
- });
36447
- }
36448
- }
36449
- util2.assertNever(effect);
36450
- }
36451
- };
36452
- ZodEffects2.create = (schema, effect, params) => {
36453
- return new ZodEffects2({
36454
- schema,
36455
- typeName: ZodFirstPartyTypeKind3.ZodEffects,
36456
- effect,
36457
- ...processCreateParams2(params)
36458
- });
36459
- };
36460
- ZodEffects2.createWithPreprocess = (preprocess2, schema, params) => {
36461
- return new ZodEffects2({
36462
- schema,
36463
- effect: { type: "preprocess", transform: preprocess2 },
36464
- typeName: ZodFirstPartyTypeKind3.ZodEffects,
36465
- ...processCreateParams2(params)
36466
- });
36467
- };
36468
- var ZodOptional3 = class extends ZodType3 {
36469
- _parse(input) {
36470
- const parsedType2 = this._getType(input);
36471
- if (parsedType2 === ZodParsedType2.undefined) {
36472
- return OK2(void 0);
36473
- }
36474
- return this._def.innerType._parse(input);
36475
- }
36476
- unwrap() {
36477
- return this._def.innerType;
36478
- }
36479
- };
36480
- ZodOptional3.create = (type, params) => {
36481
- return new ZodOptional3({
36482
- innerType: type,
36483
- typeName: ZodFirstPartyTypeKind3.ZodOptional,
36484
- ...processCreateParams2(params)
36485
- });
36486
- };
36487
- var ZodNullable3 = class extends ZodType3 {
36488
- _parse(input) {
36489
- const parsedType2 = this._getType(input);
36490
- if (parsedType2 === ZodParsedType2.null) {
36491
- return OK2(null);
36492
- }
36493
- return this._def.innerType._parse(input);
36494
- }
36495
- unwrap() {
36496
- return this._def.innerType;
36497
- }
36498
- };
36499
- ZodNullable3.create = (type, params) => {
36500
- return new ZodNullable3({
36501
- innerType: type,
36502
- typeName: ZodFirstPartyTypeKind3.ZodNullable,
36503
- ...processCreateParams2(params)
36504
- });
36505
- };
36506
- var ZodDefault3 = class extends ZodType3 {
36507
- _parse(input) {
36508
- const { ctx } = this._processInputParams(input);
36509
- let data = ctx.data;
36510
- if (ctx.parsedType === ZodParsedType2.undefined) {
36511
- data = this._def.defaultValue();
36512
- }
36513
- return this._def.innerType._parse({
36514
- data,
36515
- path: ctx.path,
36516
- parent: ctx
36517
- });
36518
- }
36519
- removeDefault() {
36520
- return this._def.innerType;
36521
- }
36522
- };
36523
- ZodDefault3.create = (type, params) => {
36524
- return new ZodDefault3({
36525
- innerType: type,
36526
- typeName: ZodFirstPartyTypeKind3.ZodDefault,
36527
- defaultValue: typeof params.default === "function" ? params.default : () => params.default,
36528
- ...processCreateParams2(params)
36529
- });
36530
- };
36531
- var ZodCatch3 = class extends ZodType3 {
36532
- _parse(input) {
36533
- const { ctx } = this._processInputParams(input);
36534
- const newCtx = {
36535
- ...ctx,
36536
- common: {
36537
- ...ctx.common,
36538
- issues: []
36539
- }
36540
- };
36541
- const result = this._def.innerType._parse({
36542
- data: newCtx.data,
36543
- path: newCtx.path,
36544
- parent: {
36545
- ...newCtx
36546
- }
36547
- });
36548
- if (isAsync2(result)) {
36549
- return result.then((result2) => {
36550
- return {
36551
- status: "valid",
36552
- value: result2.status === "valid" ? result2.value : this._def.catchValue({
36553
- get error() {
36554
- return new ZodError3(newCtx.common.issues);
36555
- },
36556
- input: newCtx.data
36557
- })
36558
- };
36559
- });
36560
- } else {
36561
- return {
36562
- status: "valid",
36563
- value: result.status === "valid" ? result.value : this._def.catchValue({
36564
- get error() {
36565
- return new ZodError3(newCtx.common.issues);
36566
- },
36567
- input: newCtx.data
36568
- })
36569
- };
36570
- }
36571
- }
36572
- removeCatch() {
36573
- return this._def.innerType;
36574
- }
36575
- };
36576
- ZodCatch3.create = (type, params) => {
36577
- return new ZodCatch3({
36578
- innerType: type,
36579
- typeName: ZodFirstPartyTypeKind3.ZodCatch,
36580
- catchValue: typeof params.catch === "function" ? params.catch : () => params.catch,
36581
- ...processCreateParams2(params)
36582
- });
36583
- };
36584
- var ZodNaN3 = class extends ZodType3 {
36585
- _parse(input) {
36586
- const parsedType2 = this._getType(input);
36587
- if (parsedType2 !== ZodParsedType2.nan) {
36588
- const ctx = this._getOrReturnCtx(input);
36589
- addIssueToContext2(ctx, {
36590
- code: ZodIssueCode3.invalid_type,
36591
- expected: ZodParsedType2.nan,
36592
- received: ctx.parsedType
36593
- });
36594
- return INVALID2;
36595
- }
36596
- return { status: "valid", value: input.data };
36597
- }
36598
- };
36599
- ZodNaN3.create = (params) => {
36600
- return new ZodNaN3({
36601
- typeName: ZodFirstPartyTypeKind3.ZodNaN,
36602
- ...processCreateParams2(params)
36603
- });
36604
- };
36605
- var BRAND = /* @__PURE__ */ Symbol("zod_brand");
36606
- var ZodBranded2 = class extends ZodType3 {
36607
- _parse(input) {
36608
- const { ctx } = this._processInputParams(input);
36609
- const data = ctx.data;
36610
- return this._def.type._parse({
36611
- data,
36612
- path: ctx.path,
36613
- parent: ctx
36614
- });
36615
- }
36616
- unwrap() {
36617
- return this._def.type;
36618
- }
36619
- };
36620
- var ZodPipeline2 = class _ZodPipeline extends ZodType3 {
36621
- _parse(input) {
36622
- const { status, ctx } = this._processInputParams(input);
36623
- if (ctx.common.async) {
36624
- const handleAsync = async () => {
36625
- const inResult = await this._def.in._parseAsync({
36626
- data: ctx.data,
36627
- path: ctx.path,
36628
- parent: ctx
36629
- });
36630
- if (inResult.status === "aborted")
36631
- return INVALID2;
36632
- if (inResult.status === "dirty") {
36633
- status.dirty();
36634
- return DIRTY2(inResult.value);
36635
- } else {
36636
- return this._def.out._parseAsync({
36637
- data: inResult.value,
36638
- path: ctx.path,
36639
- parent: ctx
36640
- });
36641
- }
36642
- };
36643
- return handleAsync();
36644
- } else {
36645
- const inResult = this._def.in._parseSync({
36646
- data: ctx.data,
36647
- path: ctx.path,
36648
- parent: ctx
36649
- });
36650
- if (inResult.status === "aborted")
36651
- return INVALID2;
36652
- if (inResult.status === "dirty") {
36653
- status.dirty();
36654
- return {
36655
- status: "dirty",
36656
- value: inResult.value
36657
- };
36658
- } else {
36659
- return this._def.out._parseSync({
36660
- data: inResult.value,
36661
- path: ctx.path,
36662
- parent: ctx
36663
- });
36664
- }
36665
- }
36666
- }
36667
- static create(a, b) {
36668
- return new _ZodPipeline({
36669
- in: a,
36670
- out: b,
36671
- typeName: ZodFirstPartyTypeKind3.ZodPipeline
36672
- });
36673
- }
36674
- };
36675
- var ZodReadonly3 = class extends ZodType3 {
36676
- _parse(input) {
36677
- const result = this._def.innerType._parse(input);
36678
- const freeze = (data) => {
36679
- if (isValid2(data)) {
36680
- data.value = Object.freeze(data.value);
36681
- }
36682
- return data;
36683
- };
36684
- return isAsync2(result) ? result.then((data) => freeze(data)) : freeze(result);
36685
- }
36686
- unwrap() {
36687
- return this._def.innerType;
36688
- }
36689
- };
36690
- ZodReadonly3.create = (type, params) => {
36691
- return new ZodReadonly3({
36692
- innerType: type,
36693
- typeName: ZodFirstPartyTypeKind3.ZodReadonly,
36694
- ...processCreateParams2(params)
36695
- });
36696
- };
36697
- function cleanParams(params, data) {
36698
- const p = typeof params === "function" ? params(data) : typeof params === "string" ? { message: params } : params;
36699
- const p2 = typeof p === "string" ? { message: p } : p;
36700
- return p2;
36701
- }
36702
- function custom2(check2, _params = {}, fatal) {
36703
- if (check2)
36704
- return ZodAny3.create().superRefine((data, ctx) => {
36705
- const r = check2(data);
36706
- if (r instanceof Promise) {
36707
- return r.then((r2) => {
36708
- if (!r2) {
36709
- const params = cleanParams(_params, data);
36710
- const _fatal = params.fatal ?? fatal ?? true;
36711
- ctx.addIssue({ code: "custom", ...params, fatal: _fatal });
36712
- }
36713
- });
36714
- }
36715
- if (!r) {
36716
- const params = cleanParams(_params, data);
36717
- const _fatal = params.fatal ?? fatal ?? true;
36718
- ctx.addIssue({ code: "custom", ...params, fatal: _fatal });
36719
- }
36720
- return;
36721
- });
36722
- return ZodAny3.create();
36723
- }
36724
- var late2 = {
36725
- object: ZodObject3.lazycreate
36726
- };
36727
- var ZodFirstPartyTypeKind3;
36728
- (function(ZodFirstPartyTypeKind4) {
36729
- ZodFirstPartyTypeKind4["ZodString"] = "ZodString";
36730
- ZodFirstPartyTypeKind4["ZodNumber"] = "ZodNumber";
36731
- ZodFirstPartyTypeKind4["ZodNaN"] = "ZodNaN";
36732
- ZodFirstPartyTypeKind4["ZodBigInt"] = "ZodBigInt";
36733
- ZodFirstPartyTypeKind4["ZodBoolean"] = "ZodBoolean";
36734
- ZodFirstPartyTypeKind4["ZodDate"] = "ZodDate";
36735
- ZodFirstPartyTypeKind4["ZodSymbol"] = "ZodSymbol";
36736
- ZodFirstPartyTypeKind4["ZodUndefined"] = "ZodUndefined";
36737
- ZodFirstPartyTypeKind4["ZodNull"] = "ZodNull";
36738
- ZodFirstPartyTypeKind4["ZodAny"] = "ZodAny";
36739
- ZodFirstPartyTypeKind4["ZodUnknown"] = "ZodUnknown";
36740
- ZodFirstPartyTypeKind4["ZodNever"] = "ZodNever";
36741
- ZodFirstPartyTypeKind4["ZodVoid"] = "ZodVoid";
36742
- ZodFirstPartyTypeKind4["ZodArray"] = "ZodArray";
36743
- ZodFirstPartyTypeKind4["ZodObject"] = "ZodObject";
36744
- ZodFirstPartyTypeKind4["ZodUnion"] = "ZodUnion";
36745
- ZodFirstPartyTypeKind4["ZodDiscriminatedUnion"] = "ZodDiscriminatedUnion";
36746
- ZodFirstPartyTypeKind4["ZodIntersection"] = "ZodIntersection";
36747
- ZodFirstPartyTypeKind4["ZodTuple"] = "ZodTuple";
36748
- ZodFirstPartyTypeKind4["ZodRecord"] = "ZodRecord";
36749
- ZodFirstPartyTypeKind4["ZodMap"] = "ZodMap";
36750
- ZodFirstPartyTypeKind4["ZodSet"] = "ZodSet";
36751
- ZodFirstPartyTypeKind4["ZodFunction"] = "ZodFunction";
36752
- ZodFirstPartyTypeKind4["ZodLazy"] = "ZodLazy";
36753
- ZodFirstPartyTypeKind4["ZodLiteral"] = "ZodLiteral";
36754
- ZodFirstPartyTypeKind4["ZodEnum"] = "ZodEnum";
36755
- ZodFirstPartyTypeKind4["ZodEffects"] = "ZodEffects";
36756
- ZodFirstPartyTypeKind4["ZodNativeEnum"] = "ZodNativeEnum";
36757
- ZodFirstPartyTypeKind4["ZodOptional"] = "ZodOptional";
36758
- ZodFirstPartyTypeKind4["ZodNullable"] = "ZodNullable";
36759
- ZodFirstPartyTypeKind4["ZodDefault"] = "ZodDefault";
36760
- ZodFirstPartyTypeKind4["ZodCatch"] = "ZodCatch";
36761
- ZodFirstPartyTypeKind4["ZodPromise"] = "ZodPromise";
36762
- ZodFirstPartyTypeKind4["ZodBranded"] = "ZodBranded";
36763
- ZodFirstPartyTypeKind4["ZodPipeline"] = "ZodPipeline";
36764
- ZodFirstPartyTypeKind4["ZodReadonly"] = "ZodReadonly";
36765
- })(ZodFirstPartyTypeKind3 || (ZodFirstPartyTypeKind3 = {}));
36766
- var instanceOfType = (cls, params = {
36767
- message: `Input not instance of ${cls.name}`
36768
- }) => custom2((data) => data instanceof cls, params);
36769
- var stringType2 = ZodString3.create;
36770
- var numberType2 = ZodNumber3.create;
36771
- var nanType2 = ZodNaN3.create;
36772
- var bigIntType2 = ZodBigInt3.create;
36773
- var booleanType2 = ZodBoolean3.create;
36774
- var dateType2 = ZodDate3.create;
36775
- var symbolType2 = ZodSymbol3.create;
36776
- var undefinedType2 = ZodUndefined3.create;
36777
- var nullType2 = ZodNull3.create;
36778
- var anyType2 = ZodAny3.create;
36779
- var unknownType2 = ZodUnknown3.create;
36780
- var neverType2 = ZodNever3.create;
36781
- var voidType2 = ZodVoid3.create;
36782
- var arrayType2 = ZodArray3.create;
36783
- var objectType2 = ZodObject3.create;
36784
- var strictObjectType2 = ZodObject3.strictCreate;
36785
- var unionType2 = ZodUnion3.create;
36786
- var discriminatedUnionType2 = ZodDiscriminatedUnion3.create;
36787
- var intersectionType2 = ZodIntersection3.create;
36788
- var tupleType2 = ZodTuple3.create;
36789
- var recordType2 = ZodRecord3.create;
36790
- var mapType2 = ZodMap3.create;
36791
- var setType2 = ZodSet3.create;
36792
- var functionType2 = ZodFunction3.create;
36793
- var lazyType2 = ZodLazy3.create;
36794
- var literalType2 = ZodLiteral3.create;
36795
- var enumType2 = ZodEnum3.create;
36796
- var nativeEnumType2 = ZodNativeEnum2.create;
36797
- var promiseType2 = ZodPromise3.create;
36798
- var effectsType2 = ZodEffects2.create;
36799
- var optionalType2 = ZodOptional3.create;
36800
- var nullableType2 = ZodNullable3.create;
36801
- var preprocessType2 = ZodEffects2.createWithPreprocess;
36802
- var pipelineType2 = ZodPipeline2.create;
36803
- var ostring = () => stringType2().optional();
36804
- var onumber = () => numberType2().optional();
36805
- var oboolean = () => booleanType2().optional();
36806
- var coerce = {
36807
- string: ((arg) => ZodString3.create({ ...arg, coerce: true })),
36808
- number: ((arg) => ZodNumber3.create({ ...arg, coerce: true })),
36809
- boolean: ((arg) => ZodBoolean3.create({
36810
- ...arg,
36811
- coerce: true
36812
- })),
36813
- bigint: ((arg) => ZodBigInt3.create({ ...arg, coerce: true })),
36814
- date: ((arg) => ZodDate3.create({ ...arg, coerce: true }))
36815
- };
36816
- var NEVER2 = INVALID2;
36817
-
36818
32777
  // ../packages/shared/dist/errors.js
36819
32778
  function createNotFoundError(resource) {
36820
32779
  return {
@@ -47607,9 +43566,9 @@ server.registerTool(
47607
43566
  {
47608
43567
  title: "Get Historical Stock Prices",
47609
43568
  description: "Get historical OHLCV stock price data for a ticker.",
47610
- inputSchema: external_exports4.object({
47611
- ticker: external_exports4.string().describe("Ticker symbol e.g. 'AAPL'"),
47612
- period: external_exports4.enum([
43569
+ inputSchema: external_exports3.object({
43570
+ ticker: external_exports3.string().describe("Ticker symbol e.g. 'AAPL'"),
43571
+ period: external_exports3.enum([
47613
43572
  "1d",
47614
43573
  "5d",
47615
43574
  "1mo",
@@ -47622,7 +43581,7 @@ server.registerTool(
47622
43581
  "ytd",
47623
43582
  "max"
47624
43583
  ]).default("1mo").describe("Time period"),
47625
- interval: external_exports4.enum([
43584
+ interval: external_exports3.enum([
47626
43585
  "1m",
47627
43586
  "2m",
47628
43587
  "5m",
@@ -47684,8 +43643,8 @@ server.registerTool(
47684
43643
  {
47685
43644
  title: "Get Stock Info",
47686
43645
  description: "Get comprehensive stock info including price, profile, and financials.",
47687
- inputSchema: external_exports4.object({
47688
- ticker: external_exports4.string().describe("Ticker symbol e.g. 'AAPL'")
43646
+ inputSchema: external_exports3.object({
43647
+ ticker: external_exports3.string().describe("Ticker symbol e.g. 'AAPL'")
47689
43648
  }),
47690
43649
  annotations: { readOnlyHint: true, openWorldHint: true }
47691
43650
  },
@@ -47754,8 +43713,8 @@ server.registerTool(
47754
43713
  {
47755
43714
  title: "Get Yahoo Finance News",
47756
43715
  description: "Get latest news articles for a ticker symbol.",
47757
- inputSchema: external_exports4.object({
47758
- ticker: external_exports4.string().describe("Ticker symbol e.g. 'AAPL'"),
43716
+ inputSchema: external_exports3.object({
43717
+ ticker: external_exports3.string().describe("Ticker symbol e.g. 'AAPL'"),
47759
43718
  ...paginationSchema.shape
47760
43719
  }),
47761
43720
  annotations: { readOnlyHint: true, openWorldHint: true }
@@ -47787,8 +43746,8 @@ server.registerTool(
47787
43746
  {
47788
43747
  title: "Get Stock Actions",
47789
43748
  description: "Get stock dividend and split history.",
47790
- inputSchema: external_exports4.object({
47791
- ticker: external_exports4.string().describe("Ticker symbol e.g. 'AAPL'")
43749
+ inputSchema: external_exports3.object({
43750
+ ticker: external_exports3.string().describe("Ticker symbol e.g. 'AAPL'")
47792
43751
  }),
47793
43752
  annotations: { readOnlyHint: true, openWorldHint: true }
47794
43753
  },
@@ -47832,9 +43791,9 @@ server.registerTool(
47832
43791
  {
47833
43792
  title: "Get Financial Statement",
47834
43793
  description: "Get income statement, balance sheet, or cashflow for a ticker.",
47835
- inputSchema: external_exports4.object({
47836
- ticker: external_exports4.string().describe("Ticker symbol e.g. 'AAPL'"),
47837
- financial_type: external_exports4.enum([
43794
+ inputSchema: external_exports3.object({
43795
+ ticker: external_exports3.string().describe("Ticker symbol e.g. 'AAPL'"),
43796
+ financial_type: external_exports3.enum([
47838
43797
  "income_stmt",
47839
43798
  "quarterly_income_stmt",
47840
43799
  "balance_sheet",
@@ -47872,9 +43831,9 @@ server.registerTool(
47872
43831
  {
47873
43832
  title: "Get Holder Info",
47874
43833
  description: "Get major, institutional, mutual fund, or insider holder data.",
47875
- inputSchema: external_exports4.object({
47876
- ticker: external_exports4.string().describe("Ticker symbol e.g. 'AAPL'"),
47877
- holder_type: external_exports4.enum([
43834
+ inputSchema: external_exports3.object({
43835
+ ticker: external_exports3.string().describe("Ticker symbol e.g. 'AAPL'"),
43836
+ holder_type: external_exports3.enum([
47878
43837
  "major_holders",
47879
43838
  "institutional_holders",
47880
43839
  "mutualfund_holders",
@@ -47925,8 +43884,8 @@ server.registerTool(
47925
43884
  {
47926
43885
  title: "Get Option Expiration Dates",
47927
43886
  description: "Get available option expiration dates for a ticker.",
47928
- inputSchema: external_exports4.object({
47929
- ticker: external_exports4.string().describe("Ticker symbol e.g. 'AAPL'")
43887
+ inputSchema: external_exports3.object({
43888
+ ticker: external_exports3.string().describe("Ticker symbol e.g. 'AAPL'")
47930
43889
  }),
47931
43890
  annotations: { readOnlyHint: true, openWorldHint: true }
47932
43891
  },
@@ -47950,10 +43909,10 @@ server.registerTool(
47950
43909
  {
47951
43910
  title: "Get Option Chain",
47952
43911
  description: "Get calls or puts option chain for a ticker and expiration date.",
47953
- inputSchema: external_exports4.object({
47954
- ticker: external_exports4.string().describe("Ticker symbol e.g. 'AAPL'"),
47955
- expiration_date: external_exports4.string().describe("Expiration date YYYY-MM-DD"),
47956
- option_type: external_exports4.enum(["calls", "puts"]).describe("Option type"),
43912
+ inputSchema: external_exports3.object({
43913
+ ticker: external_exports3.string().describe("Ticker symbol e.g. 'AAPL'"),
43914
+ expiration_date: external_exports3.string().describe("Expiration date YYYY-MM-DD"),
43915
+ option_type: external_exports3.enum(["calls", "puts"]).describe("Option type"),
47957
43916
  ...paginationSchema.shape
47958
43917
  }),
47959
43918
  annotations: { readOnlyHint: true, openWorldHint: true }
@@ -47998,10 +43957,10 @@ server.registerTool(
47998
43957
  {
47999
43958
  title: "Get Analyst Recommendations",
48000
43959
  description: "Get analyst recommendations or upgrade/downgrade history.",
48001
- inputSchema: external_exports4.object({
48002
- ticker: external_exports4.string().describe("Ticker symbol e.g. 'AAPL'"),
48003
- recommendation_type: external_exports4.enum(["recommendations", "upgrades_downgrades"]).default("recommendations").describe("Type of recommendation data"),
48004
- months_back: external_exports4.number().int().min(1).max(120).default(12).describe("Months back for upgrades/downgrades"),
43960
+ inputSchema: external_exports3.object({
43961
+ ticker: external_exports3.string().describe("Ticker symbol e.g. 'AAPL'"),
43962
+ recommendation_type: external_exports3.enum(["recommendations", "upgrades_downgrades"]).default("recommendations").describe("Type of recommendation data"),
43963
+ months_back: external_exports3.number().int().min(1).max(120).default(12).describe("Months back for upgrades/downgrades"),
48005
43964
  ...paginationSchema.shape
48006
43965
  }),
48007
43966
  annotations: { readOnlyHint: true, openWorldHint: true }