@t2000/cli 0.23.0 → 0.24.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -2,10 +2,14 @@ import { createRequire as __createRequire } from 'module'; import { fileURLToPat
2
2
  import {
3
3
  SafeguardError,
4
4
  T2000,
5
- T2000Error
6
- } from "./chunk-4N76GQCL.js";
5
+ T2000Error,
6
+ ZodFirstPartyTypeKind,
7
+ ZodOptional,
8
+ external_exports,
9
+ objectType
10
+ } from "./chunk-JJCGJTSI.js";
7
11
  import "./chunk-V7PXDEKG.js";
8
- import "./chunk-DWOZSUBE.js";
12
+ import "./chunk-Q2LY5BHK.js";
9
13
  import "./chunk-3XUF7GM3.js";
10
14
  import {
11
15
  __commonJS,
@@ -1124,9 +1128,9 @@ var require_util = __commonJS({
1124
1128
  }
1125
1129
  }
1126
1130
  exports.eachItem = eachItem;
1127
- function makeMergeEvaluated({ mergeNames, mergeToName, mergeValues: mergeValues3, resultToName }) {
1131
+ function makeMergeEvaluated({ mergeNames, mergeToName, mergeValues: mergeValues2, resultToName }) {
1128
1132
  return (gen, from, to, toName) => {
1129
- 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);
1133
+ 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) : mergeValues2(from, to);
1130
1134
  return toName === codegen_1.Name && !(res instanceof codegen_1.Name) ? resultToName(gen, res) : res;
1131
1135
  };
1132
1136
  }
@@ -6782,4049 +6786,8 @@ var require_dist = __commonJS({
6782
6786
  }
6783
6787
  });
6784
6788
 
6785
- // ../../node_modules/.pnpm/zod@3.25.76/node_modules/zod/v3/external.js
6786
- var external_exports = {};
6787
- __export(external_exports, {
6788
- BRAND: () => BRAND,
6789
- DIRTY: () => DIRTY,
6790
- EMPTY_PATH: () => EMPTY_PATH,
6791
- INVALID: () => INVALID,
6792
- NEVER: () => NEVER,
6793
- OK: () => OK,
6794
- ParseStatus: () => ParseStatus,
6795
- Schema: () => ZodType,
6796
- ZodAny: () => ZodAny,
6797
- ZodArray: () => ZodArray,
6798
- ZodBigInt: () => ZodBigInt,
6799
- ZodBoolean: () => ZodBoolean,
6800
- ZodBranded: () => ZodBranded,
6801
- ZodCatch: () => ZodCatch,
6802
- ZodDate: () => ZodDate,
6803
- ZodDefault: () => ZodDefault,
6804
- ZodDiscriminatedUnion: () => ZodDiscriminatedUnion,
6805
- ZodEffects: () => ZodEffects,
6806
- ZodEnum: () => ZodEnum,
6807
- ZodError: () => ZodError,
6808
- ZodFirstPartyTypeKind: () => ZodFirstPartyTypeKind,
6809
- ZodFunction: () => ZodFunction,
6810
- ZodIntersection: () => ZodIntersection,
6811
- ZodIssueCode: () => ZodIssueCode,
6812
- ZodLazy: () => ZodLazy,
6813
- ZodLiteral: () => ZodLiteral,
6814
- ZodMap: () => ZodMap,
6815
- ZodNaN: () => ZodNaN,
6816
- ZodNativeEnum: () => ZodNativeEnum,
6817
- ZodNever: () => ZodNever,
6818
- ZodNull: () => ZodNull,
6819
- ZodNullable: () => ZodNullable,
6820
- ZodNumber: () => ZodNumber,
6821
- ZodObject: () => ZodObject,
6822
- ZodOptional: () => ZodOptional,
6823
- ZodParsedType: () => ZodParsedType,
6824
- ZodPipeline: () => ZodPipeline,
6825
- ZodPromise: () => ZodPromise,
6826
- ZodReadonly: () => ZodReadonly,
6827
- ZodRecord: () => ZodRecord,
6828
- ZodSchema: () => ZodType,
6829
- ZodSet: () => ZodSet,
6830
- ZodString: () => ZodString,
6831
- ZodSymbol: () => ZodSymbol,
6832
- ZodTransformer: () => ZodEffects,
6833
- ZodTuple: () => ZodTuple,
6834
- ZodType: () => ZodType,
6835
- ZodUndefined: () => ZodUndefined,
6836
- ZodUnion: () => ZodUnion,
6837
- ZodUnknown: () => ZodUnknown,
6838
- ZodVoid: () => ZodVoid,
6839
- addIssueToContext: () => addIssueToContext,
6840
- any: () => anyType,
6841
- array: () => arrayType,
6842
- bigint: () => bigIntType,
6843
- boolean: () => booleanType,
6844
- coerce: () => coerce,
6845
- custom: () => custom,
6846
- date: () => dateType,
6847
- datetimeRegex: () => datetimeRegex,
6848
- defaultErrorMap: () => en_default,
6849
- discriminatedUnion: () => discriminatedUnionType,
6850
- effect: () => effectsType,
6851
- enum: () => enumType,
6852
- function: () => functionType,
6853
- getErrorMap: () => getErrorMap,
6854
- getParsedType: () => getParsedType,
6855
- instanceof: () => instanceOfType,
6856
- intersection: () => intersectionType,
6857
- isAborted: () => isAborted,
6858
- isAsync: () => isAsync,
6859
- isDirty: () => isDirty,
6860
- isValid: () => isValid,
6861
- late: () => late,
6862
- lazy: () => lazyType,
6863
- literal: () => literalType,
6864
- makeIssue: () => makeIssue,
6865
- map: () => mapType,
6866
- nan: () => nanType,
6867
- nativeEnum: () => nativeEnumType,
6868
- never: () => neverType,
6869
- null: () => nullType,
6870
- nullable: () => nullableType,
6871
- number: () => numberType,
6872
- object: () => objectType,
6873
- objectUtil: () => objectUtil,
6874
- oboolean: () => oboolean,
6875
- onumber: () => onumber,
6876
- optional: () => optionalType,
6877
- ostring: () => ostring,
6878
- pipeline: () => pipelineType,
6879
- preprocess: () => preprocessType,
6880
- promise: () => promiseType,
6881
- quotelessJson: () => quotelessJson,
6882
- record: () => recordType,
6883
- set: () => setType,
6884
- setErrorMap: () => setErrorMap,
6885
- strictObject: () => strictObjectType,
6886
- string: () => stringType,
6887
- symbol: () => symbolType,
6888
- transformer: () => effectsType,
6889
- tuple: () => tupleType,
6890
- undefined: () => undefinedType,
6891
- union: () => unionType,
6892
- unknown: () => unknownType,
6893
- util: () => util,
6894
- void: () => voidType
6895
- });
6896
-
6897
- // ../../node_modules/.pnpm/zod@3.25.76/node_modules/zod/v3/helpers/util.js
6898
- var util;
6899
- (function(util2) {
6900
- util2.assertEqual = (_) => {
6901
- };
6902
- function assertIs2(_arg) {
6903
- }
6904
- util2.assertIs = assertIs2;
6905
- function assertNever2(_x) {
6906
- throw new Error();
6907
- }
6908
- util2.assertNever = assertNever2;
6909
- util2.arrayToEnum = (items) => {
6910
- const obj = {};
6911
- for (const item of items) {
6912
- obj[item] = item;
6913
- }
6914
- return obj;
6915
- };
6916
- util2.getValidEnumValues = (obj) => {
6917
- const validKeys = util2.objectKeys(obj).filter((k) => typeof obj[obj[k]] !== "number");
6918
- const filtered = {};
6919
- for (const k of validKeys) {
6920
- filtered[k] = obj[k];
6921
- }
6922
- return util2.objectValues(filtered);
6923
- };
6924
- util2.objectValues = (obj) => {
6925
- return util2.objectKeys(obj).map(function(e) {
6926
- return obj[e];
6927
- });
6928
- };
6929
- util2.objectKeys = typeof Object.keys === "function" ? (obj) => Object.keys(obj) : (object3) => {
6930
- const keys = [];
6931
- for (const key in object3) {
6932
- if (Object.prototype.hasOwnProperty.call(object3, key)) {
6933
- keys.push(key);
6934
- }
6935
- }
6936
- return keys;
6937
- };
6938
- util2.find = (arr, checker) => {
6939
- for (const item of arr) {
6940
- if (checker(item))
6941
- return item;
6942
- }
6943
- return void 0;
6944
- };
6945
- util2.isInteger = typeof Number.isInteger === "function" ? (val) => Number.isInteger(val) : (val) => typeof val === "number" && Number.isFinite(val) && Math.floor(val) === val;
6946
- function joinValues2(array2, separator = " | ") {
6947
- return array2.map((val) => typeof val === "string" ? `'${val}'` : val).join(separator);
6948
- }
6949
- util2.joinValues = joinValues2;
6950
- util2.jsonStringifyReplacer = (_, value) => {
6951
- if (typeof value === "bigint") {
6952
- return value.toString();
6953
- }
6954
- return value;
6955
- };
6956
- })(util || (util = {}));
6957
- var objectUtil;
6958
- (function(objectUtil2) {
6959
- objectUtil2.mergeShapes = (first, second) => {
6960
- return {
6961
- ...first,
6962
- ...second
6963
- // second overwrites first
6964
- };
6965
- };
6966
- })(objectUtil || (objectUtil = {}));
6967
- var ZodParsedType = util.arrayToEnum([
6968
- "string",
6969
- "nan",
6970
- "number",
6971
- "integer",
6972
- "float",
6973
- "boolean",
6974
- "date",
6975
- "bigint",
6976
- "symbol",
6977
- "function",
6978
- "undefined",
6979
- "null",
6980
- "array",
6981
- "object",
6982
- "unknown",
6983
- "promise",
6984
- "void",
6985
- "never",
6986
- "map",
6987
- "set"
6988
- ]);
6989
- var getParsedType = (data) => {
6990
- const t = typeof data;
6991
- switch (t) {
6992
- case "undefined":
6993
- return ZodParsedType.undefined;
6994
- case "string":
6995
- return ZodParsedType.string;
6996
- case "number":
6997
- return Number.isNaN(data) ? ZodParsedType.nan : ZodParsedType.number;
6998
- case "boolean":
6999
- return ZodParsedType.boolean;
7000
- case "function":
7001
- return ZodParsedType.function;
7002
- case "bigint":
7003
- return ZodParsedType.bigint;
7004
- case "symbol":
7005
- return ZodParsedType.symbol;
7006
- case "object":
7007
- if (Array.isArray(data)) {
7008
- return ZodParsedType.array;
7009
- }
7010
- if (data === null) {
7011
- return ZodParsedType.null;
7012
- }
7013
- if (data.then && typeof data.then === "function" && data.catch && typeof data.catch === "function") {
7014
- return ZodParsedType.promise;
7015
- }
7016
- if (typeof Map !== "undefined" && data instanceof Map) {
7017
- return ZodParsedType.map;
7018
- }
7019
- if (typeof Set !== "undefined" && data instanceof Set) {
7020
- return ZodParsedType.set;
7021
- }
7022
- if (typeof Date !== "undefined" && data instanceof Date) {
7023
- return ZodParsedType.date;
7024
- }
7025
- return ZodParsedType.object;
7026
- default:
7027
- return ZodParsedType.unknown;
7028
- }
7029
- };
7030
-
7031
- // ../../node_modules/.pnpm/zod@3.25.76/node_modules/zod/v3/ZodError.js
7032
- var ZodIssueCode = util.arrayToEnum([
7033
- "invalid_type",
7034
- "invalid_literal",
7035
- "custom",
7036
- "invalid_union",
7037
- "invalid_union_discriminator",
7038
- "invalid_enum_value",
7039
- "unrecognized_keys",
7040
- "invalid_arguments",
7041
- "invalid_return_type",
7042
- "invalid_date",
7043
- "invalid_string",
7044
- "too_small",
7045
- "too_big",
7046
- "invalid_intersection_types",
7047
- "not_multiple_of",
7048
- "not_finite"
7049
- ]);
7050
- var quotelessJson = (obj) => {
7051
- const json = JSON.stringify(obj, null, 2);
7052
- return json.replace(/"([^"]+)":/g, "$1:");
7053
- };
7054
- var ZodError = class _ZodError extends Error {
7055
- get errors() {
7056
- return this.issues;
7057
- }
7058
- constructor(issues) {
7059
- super();
7060
- this.issues = [];
7061
- this.addIssue = (sub) => {
7062
- this.issues = [...this.issues, sub];
7063
- };
7064
- this.addIssues = (subs = []) => {
7065
- this.issues = [...this.issues, ...subs];
7066
- };
7067
- const actualProto = new.target.prototype;
7068
- if (Object.setPrototypeOf) {
7069
- Object.setPrototypeOf(this, actualProto);
7070
- } else {
7071
- this.__proto__ = actualProto;
7072
- }
7073
- this.name = "ZodError";
7074
- this.issues = issues;
7075
- }
7076
- format(_mapper) {
7077
- const mapper = _mapper || function(issue2) {
7078
- return issue2.message;
7079
- };
7080
- const fieldErrors = { _errors: [] };
7081
- const processError = (error2) => {
7082
- for (const issue2 of error2.issues) {
7083
- if (issue2.code === "invalid_union") {
7084
- issue2.unionErrors.map(processError);
7085
- } else if (issue2.code === "invalid_return_type") {
7086
- processError(issue2.returnTypeError);
7087
- } else if (issue2.code === "invalid_arguments") {
7088
- processError(issue2.argumentsError);
7089
- } else if (issue2.path.length === 0) {
7090
- fieldErrors._errors.push(mapper(issue2));
7091
- } else {
7092
- let curr = fieldErrors;
7093
- let i = 0;
7094
- while (i < issue2.path.length) {
7095
- const el = issue2.path[i];
7096
- const terminal = i === issue2.path.length - 1;
7097
- if (!terminal) {
7098
- curr[el] = curr[el] || { _errors: [] };
7099
- } else {
7100
- curr[el] = curr[el] || { _errors: [] };
7101
- curr[el]._errors.push(mapper(issue2));
7102
- }
7103
- curr = curr[el];
7104
- i++;
7105
- }
7106
- }
7107
- }
7108
- };
7109
- processError(this);
7110
- return fieldErrors;
7111
- }
7112
- static assert(value) {
7113
- if (!(value instanceof _ZodError)) {
7114
- throw new Error(`Not a ZodError: ${value}`);
7115
- }
7116
- }
7117
- toString() {
7118
- return this.message;
7119
- }
7120
- get message() {
7121
- return JSON.stringify(this.issues, util.jsonStringifyReplacer, 2);
7122
- }
7123
- get isEmpty() {
7124
- return this.issues.length === 0;
7125
- }
7126
- flatten(mapper = (issue2) => issue2.message) {
7127
- const fieldErrors = {};
7128
- const formErrors = [];
7129
- for (const sub of this.issues) {
7130
- if (sub.path.length > 0) {
7131
- const firstEl = sub.path[0];
7132
- fieldErrors[firstEl] = fieldErrors[firstEl] || [];
7133
- fieldErrors[firstEl].push(mapper(sub));
7134
- } else {
7135
- formErrors.push(mapper(sub));
7136
- }
7137
- }
7138
- return { formErrors, fieldErrors };
7139
- }
7140
- get formErrors() {
7141
- return this.flatten();
7142
- }
7143
- };
7144
- ZodError.create = (issues) => {
7145
- const error2 = new ZodError(issues);
7146
- return error2;
7147
- };
7148
-
7149
- // ../../node_modules/.pnpm/zod@3.25.76/node_modules/zod/v3/locales/en.js
7150
- var errorMap = (issue2, _ctx) => {
7151
- let message;
7152
- switch (issue2.code) {
7153
- case ZodIssueCode.invalid_type:
7154
- if (issue2.received === ZodParsedType.undefined) {
7155
- message = "Required";
7156
- } else {
7157
- message = `Expected ${issue2.expected}, received ${issue2.received}`;
7158
- }
7159
- break;
7160
- case ZodIssueCode.invalid_literal:
7161
- message = `Invalid literal value, expected ${JSON.stringify(issue2.expected, util.jsonStringifyReplacer)}`;
7162
- break;
7163
- case ZodIssueCode.unrecognized_keys:
7164
- message = `Unrecognized key(s) in object: ${util.joinValues(issue2.keys, ", ")}`;
7165
- break;
7166
- case ZodIssueCode.invalid_union:
7167
- message = `Invalid input`;
7168
- break;
7169
- case ZodIssueCode.invalid_union_discriminator:
7170
- message = `Invalid discriminator value. Expected ${util.joinValues(issue2.options)}`;
7171
- break;
7172
- case ZodIssueCode.invalid_enum_value:
7173
- message = `Invalid enum value. Expected ${util.joinValues(issue2.options)}, received '${issue2.received}'`;
7174
- break;
7175
- case ZodIssueCode.invalid_arguments:
7176
- message = `Invalid function arguments`;
7177
- break;
7178
- case ZodIssueCode.invalid_return_type:
7179
- message = `Invalid function return type`;
7180
- break;
7181
- case ZodIssueCode.invalid_date:
7182
- message = `Invalid date`;
7183
- break;
7184
- case ZodIssueCode.invalid_string:
7185
- if (typeof issue2.validation === "object") {
7186
- if ("includes" in issue2.validation) {
7187
- message = `Invalid input: must include "${issue2.validation.includes}"`;
7188
- if (typeof issue2.validation.position === "number") {
7189
- message = `${message} at one or more positions greater than or equal to ${issue2.validation.position}`;
7190
- }
7191
- } else if ("startsWith" in issue2.validation) {
7192
- message = `Invalid input: must start with "${issue2.validation.startsWith}"`;
7193
- } else if ("endsWith" in issue2.validation) {
7194
- message = `Invalid input: must end with "${issue2.validation.endsWith}"`;
7195
- } else {
7196
- util.assertNever(issue2.validation);
7197
- }
7198
- } else if (issue2.validation !== "regex") {
7199
- message = `Invalid ${issue2.validation}`;
7200
- } else {
7201
- message = "Invalid";
7202
- }
7203
- break;
7204
- case ZodIssueCode.too_small:
7205
- if (issue2.type === "array")
7206
- message = `Array must contain ${issue2.exact ? "exactly" : issue2.inclusive ? `at least` : `more than`} ${issue2.minimum} element(s)`;
7207
- else if (issue2.type === "string")
7208
- message = `String must contain ${issue2.exact ? "exactly" : issue2.inclusive ? `at least` : `over`} ${issue2.minimum} character(s)`;
7209
- else if (issue2.type === "number")
7210
- message = `Number must be ${issue2.exact ? `exactly equal to ` : issue2.inclusive ? `greater than or equal to ` : `greater than `}${issue2.minimum}`;
7211
- else if (issue2.type === "bigint")
7212
- message = `Number must be ${issue2.exact ? `exactly equal to ` : issue2.inclusive ? `greater than or equal to ` : `greater than `}${issue2.minimum}`;
7213
- else if (issue2.type === "date")
7214
- message = `Date must be ${issue2.exact ? `exactly equal to ` : issue2.inclusive ? `greater than or equal to ` : `greater than `}${new Date(Number(issue2.minimum))}`;
7215
- else
7216
- message = "Invalid input";
7217
- break;
7218
- case ZodIssueCode.too_big:
7219
- if (issue2.type === "array")
7220
- message = `Array must contain ${issue2.exact ? `exactly` : issue2.inclusive ? `at most` : `less than`} ${issue2.maximum} element(s)`;
7221
- else if (issue2.type === "string")
7222
- message = `String must contain ${issue2.exact ? `exactly` : issue2.inclusive ? `at most` : `under`} ${issue2.maximum} character(s)`;
7223
- else if (issue2.type === "number")
7224
- message = `Number must be ${issue2.exact ? `exactly` : issue2.inclusive ? `less than or equal to` : `less than`} ${issue2.maximum}`;
7225
- else if (issue2.type === "bigint")
7226
- message = `BigInt must be ${issue2.exact ? `exactly` : issue2.inclusive ? `less than or equal to` : `less than`} ${issue2.maximum}`;
7227
- else if (issue2.type === "date")
7228
- message = `Date must be ${issue2.exact ? `exactly` : issue2.inclusive ? `smaller than or equal to` : `smaller than`} ${new Date(Number(issue2.maximum))}`;
7229
- else
7230
- message = "Invalid input";
7231
- break;
7232
- case ZodIssueCode.custom:
7233
- message = `Invalid input`;
7234
- break;
7235
- case ZodIssueCode.invalid_intersection_types:
7236
- message = `Intersection results could not be merged`;
7237
- break;
7238
- case ZodIssueCode.not_multiple_of:
7239
- message = `Number must be a multiple of ${issue2.multipleOf}`;
7240
- break;
7241
- case ZodIssueCode.not_finite:
7242
- message = "Number must be finite";
7243
- break;
7244
- default:
7245
- message = _ctx.defaultError;
7246
- util.assertNever(issue2);
7247
- }
7248
- return { message };
7249
- };
7250
- var en_default = errorMap;
7251
-
7252
- // ../../node_modules/.pnpm/zod@3.25.76/node_modules/zod/v3/errors.js
7253
- var overrideErrorMap = en_default;
7254
- function setErrorMap(map) {
7255
- overrideErrorMap = map;
7256
- }
7257
- function getErrorMap() {
7258
- return overrideErrorMap;
7259
- }
7260
-
7261
- // ../../node_modules/.pnpm/zod@3.25.76/node_modules/zod/v3/helpers/parseUtil.js
7262
- var makeIssue = (params) => {
7263
- const { data, path, errorMaps, issueData } = params;
7264
- const fullPath = [...path, ...issueData.path || []];
7265
- const fullIssue = {
7266
- ...issueData,
7267
- path: fullPath
7268
- };
7269
- if (issueData.message !== void 0) {
7270
- return {
7271
- ...issueData,
7272
- path: fullPath,
7273
- message: issueData.message
7274
- };
7275
- }
7276
- let errorMessage = "";
7277
- const maps = errorMaps.filter((m) => !!m).slice().reverse();
7278
- for (const map of maps) {
7279
- errorMessage = map(fullIssue, { data, defaultError: errorMessage }).message;
7280
- }
7281
- return {
7282
- ...issueData,
7283
- path: fullPath,
7284
- message: errorMessage
7285
- };
7286
- };
7287
- var EMPTY_PATH = [];
7288
- function addIssueToContext(ctx, issueData) {
7289
- const overrideMap = getErrorMap();
7290
- const issue2 = makeIssue({
7291
- issueData,
7292
- data: ctx.data,
7293
- path: ctx.path,
7294
- errorMaps: [
7295
- ctx.common.contextualErrorMap,
7296
- // contextual error map is first priority
7297
- ctx.schemaErrorMap,
7298
- // then schema-bound map if available
7299
- overrideMap,
7300
- // then global override map
7301
- overrideMap === en_default ? void 0 : en_default
7302
- // then global default map
7303
- ].filter((x) => !!x)
7304
- });
7305
- ctx.common.issues.push(issue2);
7306
- }
7307
- var ParseStatus = class _ParseStatus {
7308
- constructor() {
7309
- this.value = "valid";
7310
- }
7311
- dirty() {
7312
- if (this.value === "valid")
7313
- this.value = "dirty";
7314
- }
7315
- abort() {
7316
- if (this.value !== "aborted")
7317
- this.value = "aborted";
7318
- }
7319
- static mergeArray(status, results) {
7320
- const arrayValue = [];
7321
- for (const s of results) {
7322
- if (s.status === "aborted")
7323
- return INVALID;
7324
- if (s.status === "dirty")
7325
- status.dirty();
7326
- arrayValue.push(s.value);
7327
- }
7328
- return { status: status.value, value: arrayValue };
7329
- }
7330
- static async mergeObjectAsync(status, pairs) {
7331
- const syncPairs = [];
7332
- for (const pair of pairs) {
7333
- const key = await pair.key;
7334
- const value = await pair.value;
7335
- syncPairs.push({
7336
- key,
7337
- value
7338
- });
7339
- }
7340
- return _ParseStatus.mergeObjectSync(status, syncPairs);
7341
- }
7342
- static mergeObjectSync(status, pairs) {
7343
- const finalObject = {};
7344
- for (const pair of pairs) {
7345
- const { key, value } = pair;
7346
- if (key.status === "aborted")
7347
- return INVALID;
7348
- if (value.status === "aborted")
7349
- return INVALID;
7350
- if (key.status === "dirty")
7351
- status.dirty();
7352
- if (value.status === "dirty")
7353
- status.dirty();
7354
- if (key.value !== "__proto__" && (typeof value.value !== "undefined" || pair.alwaysSet)) {
7355
- finalObject[key.value] = value.value;
7356
- }
7357
- }
7358
- return { status: status.value, value: finalObject };
7359
- }
7360
- };
7361
- var INVALID = Object.freeze({
7362
- status: "aborted"
7363
- });
7364
- var DIRTY = (value) => ({ status: "dirty", value });
7365
- var OK = (value) => ({ status: "valid", value });
7366
- var isAborted = (x) => x.status === "aborted";
7367
- var isDirty = (x) => x.status === "dirty";
7368
- var isValid = (x) => x.status === "valid";
7369
- var isAsync = (x) => typeof Promise !== "undefined" && x instanceof Promise;
7370
-
7371
- // ../../node_modules/.pnpm/zod@3.25.76/node_modules/zod/v3/helpers/errorUtil.js
7372
- var errorUtil;
7373
- (function(errorUtil2) {
7374
- errorUtil2.errToObj = (message) => typeof message === "string" ? { message } : message || {};
7375
- errorUtil2.toString = (message) => typeof message === "string" ? message : message?.message;
7376
- })(errorUtil || (errorUtil = {}));
7377
-
7378
- // ../../node_modules/.pnpm/zod@3.25.76/node_modules/zod/v3/types.js
7379
- var ParseInputLazyPath = class {
7380
- constructor(parent, value, path, key) {
7381
- this._cachedPath = [];
7382
- this.parent = parent;
7383
- this.data = value;
7384
- this._path = path;
7385
- this._key = key;
7386
- }
7387
- get path() {
7388
- if (!this._cachedPath.length) {
7389
- if (Array.isArray(this._key)) {
7390
- this._cachedPath.push(...this._path, ...this._key);
7391
- } else {
7392
- this._cachedPath.push(...this._path, this._key);
7393
- }
7394
- }
7395
- return this._cachedPath;
7396
- }
7397
- };
7398
- var handleResult = (ctx, result) => {
7399
- if (isValid(result)) {
7400
- return { success: true, data: result.value };
7401
- } else {
7402
- if (!ctx.common.issues.length) {
7403
- throw new Error("Validation failed but no issues detected.");
7404
- }
7405
- return {
7406
- success: false,
7407
- get error() {
7408
- if (this._error)
7409
- return this._error;
7410
- const error2 = new ZodError(ctx.common.issues);
7411
- this._error = error2;
7412
- return this._error;
7413
- }
7414
- };
7415
- }
7416
- };
7417
- function processCreateParams(params) {
7418
- if (!params)
7419
- return {};
7420
- const { errorMap: errorMap2, invalid_type_error, required_error, description } = params;
7421
- if (errorMap2 && (invalid_type_error || required_error)) {
7422
- throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);
7423
- }
7424
- if (errorMap2)
7425
- return { errorMap: errorMap2, description };
7426
- const customMap = (iss, ctx) => {
7427
- const { message } = params;
7428
- if (iss.code === "invalid_enum_value") {
7429
- return { message: message ?? ctx.defaultError };
7430
- }
7431
- if (typeof ctx.data === "undefined") {
7432
- return { message: message ?? required_error ?? ctx.defaultError };
7433
- }
7434
- if (iss.code !== "invalid_type")
7435
- return { message: ctx.defaultError };
7436
- return { message: message ?? invalid_type_error ?? ctx.defaultError };
7437
- };
7438
- return { errorMap: customMap, description };
7439
- }
7440
- var ZodType = class {
7441
- get description() {
7442
- return this._def.description;
7443
- }
7444
- _getType(input) {
7445
- return getParsedType(input.data);
7446
- }
7447
- _getOrReturnCtx(input, ctx) {
7448
- return ctx || {
7449
- common: input.parent.common,
7450
- data: input.data,
7451
- parsedType: getParsedType(input.data),
7452
- schemaErrorMap: this._def.errorMap,
7453
- path: input.path,
7454
- parent: input.parent
7455
- };
7456
- }
7457
- _processInputParams(input) {
7458
- return {
7459
- status: new ParseStatus(),
7460
- ctx: {
7461
- common: input.parent.common,
7462
- data: input.data,
7463
- parsedType: getParsedType(input.data),
7464
- schemaErrorMap: this._def.errorMap,
7465
- path: input.path,
7466
- parent: input.parent
7467
- }
7468
- };
7469
- }
7470
- _parseSync(input) {
7471
- const result = this._parse(input);
7472
- if (isAsync(result)) {
7473
- throw new Error("Synchronous parse encountered promise.");
7474
- }
7475
- return result;
7476
- }
7477
- _parseAsync(input) {
7478
- const result = this._parse(input);
7479
- return Promise.resolve(result);
7480
- }
7481
- parse(data, params) {
7482
- const result = this.safeParse(data, params);
7483
- if (result.success)
7484
- return result.data;
7485
- throw result.error;
7486
- }
7487
- safeParse(data, params) {
7488
- const ctx = {
7489
- common: {
7490
- issues: [],
7491
- async: params?.async ?? false,
7492
- contextualErrorMap: params?.errorMap
7493
- },
7494
- path: params?.path || [],
7495
- schemaErrorMap: this._def.errorMap,
7496
- parent: null,
7497
- data,
7498
- parsedType: getParsedType(data)
7499
- };
7500
- const result = this._parseSync({ data, path: ctx.path, parent: ctx });
7501
- return handleResult(ctx, result);
7502
- }
7503
- "~validate"(data) {
7504
- const ctx = {
7505
- common: {
7506
- issues: [],
7507
- async: !!this["~standard"].async
7508
- },
7509
- path: [],
7510
- schemaErrorMap: this._def.errorMap,
7511
- parent: null,
7512
- data,
7513
- parsedType: getParsedType(data)
7514
- };
7515
- if (!this["~standard"].async) {
7516
- try {
7517
- const result = this._parseSync({ data, path: [], parent: ctx });
7518
- return isValid(result) ? {
7519
- value: result.value
7520
- } : {
7521
- issues: ctx.common.issues
7522
- };
7523
- } catch (err) {
7524
- if (err?.message?.toLowerCase()?.includes("encountered")) {
7525
- this["~standard"].async = true;
7526
- }
7527
- ctx.common = {
7528
- issues: [],
7529
- async: true
7530
- };
7531
- }
7532
- }
7533
- return this._parseAsync({ data, path: [], parent: ctx }).then((result) => isValid(result) ? {
7534
- value: result.value
7535
- } : {
7536
- issues: ctx.common.issues
7537
- });
7538
- }
7539
- async parseAsync(data, params) {
7540
- const result = await this.safeParseAsync(data, params);
7541
- if (result.success)
7542
- return result.data;
7543
- throw result.error;
7544
- }
7545
- async safeParseAsync(data, params) {
7546
- const ctx = {
7547
- common: {
7548
- issues: [],
7549
- contextualErrorMap: params?.errorMap,
7550
- async: true
7551
- },
7552
- path: params?.path || [],
7553
- schemaErrorMap: this._def.errorMap,
7554
- parent: null,
7555
- data,
7556
- parsedType: getParsedType(data)
7557
- };
7558
- const maybeAsyncResult = this._parse({ data, path: ctx.path, parent: ctx });
7559
- const result = await (isAsync(maybeAsyncResult) ? maybeAsyncResult : Promise.resolve(maybeAsyncResult));
7560
- return handleResult(ctx, result);
7561
- }
7562
- refine(check2, message) {
7563
- const getIssueProperties = (val) => {
7564
- if (typeof message === "string" || typeof message === "undefined") {
7565
- return { message };
7566
- } else if (typeof message === "function") {
7567
- return message(val);
7568
- } else {
7569
- return message;
7570
- }
7571
- };
7572
- return this._refinement((val, ctx) => {
7573
- const result = check2(val);
7574
- const setError = () => ctx.addIssue({
7575
- code: ZodIssueCode.custom,
7576
- ...getIssueProperties(val)
7577
- });
7578
- if (typeof Promise !== "undefined" && result instanceof Promise) {
7579
- return result.then((data) => {
7580
- if (!data) {
7581
- setError();
7582
- return false;
7583
- } else {
7584
- return true;
7585
- }
7586
- });
7587
- }
7588
- if (!result) {
7589
- setError();
7590
- return false;
7591
- } else {
7592
- return true;
7593
- }
7594
- });
7595
- }
7596
- refinement(check2, refinementData) {
7597
- return this._refinement((val, ctx) => {
7598
- if (!check2(val)) {
7599
- ctx.addIssue(typeof refinementData === "function" ? refinementData(val, ctx) : refinementData);
7600
- return false;
7601
- } else {
7602
- return true;
7603
- }
7604
- });
7605
- }
7606
- _refinement(refinement) {
7607
- return new ZodEffects({
7608
- schema: this,
7609
- typeName: ZodFirstPartyTypeKind.ZodEffects,
7610
- effect: { type: "refinement", refinement }
7611
- });
7612
- }
7613
- superRefine(refinement) {
7614
- return this._refinement(refinement);
7615
- }
7616
- constructor(def) {
7617
- this.spa = this.safeParseAsync;
7618
- this._def = def;
7619
- this.parse = this.parse.bind(this);
7620
- this.safeParse = this.safeParse.bind(this);
7621
- this.parseAsync = this.parseAsync.bind(this);
7622
- this.safeParseAsync = this.safeParseAsync.bind(this);
7623
- this.spa = this.spa.bind(this);
7624
- this.refine = this.refine.bind(this);
7625
- this.refinement = this.refinement.bind(this);
7626
- this.superRefine = this.superRefine.bind(this);
7627
- this.optional = this.optional.bind(this);
7628
- this.nullable = this.nullable.bind(this);
7629
- this.nullish = this.nullish.bind(this);
7630
- this.array = this.array.bind(this);
7631
- this.promise = this.promise.bind(this);
7632
- this.or = this.or.bind(this);
7633
- this.and = this.and.bind(this);
7634
- this.transform = this.transform.bind(this);
7635
- this.brand = this.brand.bind(this);
7636
- this.default = this.default.bind(this);
7637
- this.catch = this.catch.bind(this);
7638
- this.describe = this.describe.bind(this);
7639
- this.pipe = this.pipe.bind(this);
7640
- this.readonly = this.readonly.bind(this);
7641
- this.isNullable = this.isNullable.bind(this);
7642
- this.isOptional = this.isOptional.bind(this);
7643
- this["~standard"] = {
7644
- version: 1,
7645
- vendor: "zod",
7646
- validate: (data) => this["~validate"](data)
7647
- };
7648
- }
7649
- optional() {
7650
- return ZodOptional.create(this, this._def);
7651
- }
7652
- nullable() {
7653
- return ZodNullable.create(this, this._def);
7654
- }
7655
- nullish() {
7656
- return this.nullable().optional();
7657
- }
7658
- array() {
7659
- return ZodArray.create(this);
7660
- }
7661
- promise() {
7662
- return ZodPromise.create(this, this._def);
7663
- }
7664
- or(option) {
7665
- return ZodUnion.create([this, option], this._def);
7666
- }
7667
- and(incoming) {
7668
- return ZodIntersection.create(this, incoming, this._def);
7669
- }
7670
- transform(transform2) {
7671
- return new ZodEffects({
7672
- ...processCreateParams(this._def),
7673
- schema: this,
7674
- typeName: ZodFirstPartyTypeKind.ZodEffects,
7675
- effect: { type: "transform", transform: transform2 }
7676
- });
7677
- }
7678
- default(def) {
7679
- const defaultValueFunc = typeof def === "function" ? def : () => def;
7680
- return new ZodDefault({
7681
- ...processCreateParams(this._def),
7682
- innerType: this,
7683
- defaultValue: defaultValueFunc,
7684
- typeName: ZodFirstPartyTypeKind.ZodDefault
7685
- });
7686
- }
7687
- brand() {
7688
- return new ZodBranded({
7689
- typeName: ZodFirstPartyTypeKind.ZodBranded,
7690
- type: this,
7691
- ...processCreateParams(this._def)
7692
- });
7693
- }
7694
- catch(def) {
7695
- const catchValueFunc = typeof def === "function" ? def : () => def;
7696
- return new ZodCatch({
7697
- ...processCreateParams(this._def),
7698
- innerType: this,
7699
- catchValue: catchValueFunc,
7700
- typeName: ZodFirstPartyTypeKind.ZodCatch
7701
- });
7702
- }
7703
- describe(description) {
7704
- const This = this.constructor;
7705
- return new This({
7706
- ...this._def,
7707
- description
7708
- });
7709
- }
7710
- pipe(target) {
7711
- return ZodPipeline.create(this, target);
7712
- }
7713
- readonly() {
7714
- return ZodReadonly.create(this);
7715
- }
7716
- isOptional() {
7717
- return this.safeParse(void 0).success;
7718
- }
7719
- isNullable() {
7720
- return this.safeParse(null).success;
7721
- }
7722
- };
7723
- var cuidRegex = /^c[^\s-]{8,}$/i;
7724
- var cuid2Regex = /^[0-9a-z]+$/;
7725
- var ulidRegex = /^[0-9A-HJKMNP-TV-Z]{26}$/i;
7726
- var uuidRegex = /^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i;
7727
- var nanoidRegex = /^[a-z0-9_-]{21}$/i;
7728
- var jwtRegex = /^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/;
7729
- var durationRegex = /^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/;
7730
- var emailRegex = /^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i;
7731
- var _emojiRegex = `^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$`;
7732
- var emojiRegex;
7733
- var ipv4Regex = /^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/;
7734
- var ipv4CidrRegex = /^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/(3[0-2]|[12]?[0-9])$/;
7735
- var ipv6Regex = /^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/;
7736
- var ipv6CidrRegex = /^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/;
7737
- var base64Regex = /^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/;
7738
- var base64urlRegex = /^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/;
7739
- var dateRegexSource = `((\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-((0[13578]|1[02])-(0[1-9]|[12]\\d|3[01])|(0[469]|11)-(0[1-9]|[12]\\d|30)|(02)-(0[1-9]|1\\d|2[0-8])))`;
7740
- var dateRegex = new RegExp(`^${dateRegexSource}$`);
7741
- function timeRegexSource(args) {
7742
- let secondsRegexSource = `[0-5]\\d`;
7743
- if (args.precision) {
7744
- secondsRegexSource = `${secondsRegexSource}\\.\\d{${args.precision}}`;
7745
- } else if (args.precision == null) {
7746
- secondsRegexSource = `${secondsRegexSource}(\\.\\d+)?`;
7747
- }
7748
- const secondsQuantifier = args.precision ? "+" : "?";
7749
- return `([01]\\d|2[0-3]):[0-5]\\d(:${secondsRegexSource})${secondsQuantifier}`;
7750
- }
7751
- function timeRegex(args) {
7752
- return new RegExp(`^${timeRegexSource(args)}$`);
7753
- }
7754
- function datetimeRegex(args) {
7755
- let regex = `${dateRegexSource}T${timeRegexSource(args)}`;
7756
- const opts = [];
7757
- opts.push(args.local ? `Z?` : `Z`);
7758
- if (args.offset)
7759
- opts.push(`([+-]\\d{2}:?\\d{2})`);
7760
- regex = `${regex}(${opts.join("|")})`;
7761
- return new RegExp(`^${regex}$`);
7762
- }
7763
- function isValidIP(ip, version2) {
7764
- if ((version2 === "v4" || !version2) && ipv4Regex.test(ip)) {
7765
- return true;
7766
- }
7767
- if ((version2 === "v6" || !version2) && ipv6Regex.test(ip)) {
7768
- return true;
7769
- }
7770
- return false;
7771
- }
7772
- function isValidJWT(jwt, alg) {
7773
- if (!jwtRegex.test(jwt))
7774
- return false;
7775
- try {
7776
- const [header] = jwt.split(".");
7777
- if (!header)
7778
- return false;
7779
- const base642 = header.replace(/-/g, "+").replace(/_/g, "/").padEnd(header.length + (4 - header.length % 4) % 4, "=");
7780
- const decoded = JSON.parse(atob(base642));
7781
- if (typeof decoded !== "object" || decoded === null)
7782
- return false;
7783
- if ("typ" in decoded && decoded?.typ !== "JWT")
7784
- return false;
7785
- if (!decoded.alg)
7786
- return false;
7787
- if (alg && decoded.alg !== alg)
7788
- return false;
7789
- return true;
7790
- } catch {
7791
- return false;
7792
- }
7793
- }
7794
- function isValidCidr(ip, version2) {
7795
- if ((version2 === "v4" || !version2) && ipv4CidrRegex.test(ip)) {
7796
- return true;
7797
- }
7798
- if ((version2 === "v6" || !version2) && ipv6CidrRegex.test(ip)) {
7799
- return true;
7800
- }
7801
- return false;
7802
- }
7803
- var ZodString = class _ZodString2 extends ZodType {
7804
- _parse(input) {
7805
- if (this._def.coerce) {
7806
- input.data = String(input.data);
7807
- }
7808
- const parsedType2 = this._getType(input);
7809
- if (parsedType2 !== ZodParsedType.string) {
7810
- const ctx2 = this._getOrReturnCtx(input);
7811
- addIssueToContext(ctx2, {
7812
- code: ZodIssueCode.invalid_type,
7813
- expected: ZodParsedType.string,
7814
- received: ctx2.parsedType
7815
- });
7816
- return INVALID;
7817
- }
7818
- const status = new ParseStatus();
7819
- let ctx = void 0;
7820
- for (const check2 of this._def.checks) {
7821
- if (check2.kind === "min") {
7822
- if (input.data.length < check2.value) {
7823
- ctx = this._getOrReturnCtx(input, ctx);
7824
- addIssueToContext(ctx, {
7825
- code: ZodIssueCode.too_small,
7826
- minimum: check2.value,
7827
- type: "string",
7828
- inclusive: true,
7829
- exact: false,
7830
- message: check2.message
7831
- });
7832
- status.dirty();
7833
- }
7834
- } else if (check2.kind === "max") {
7835
- if (input.data.length > check2.value) {
7836
- ctx = this._getOrReturnCtx(input, ctx);
7837
- addIssueToContext(ctx, {
7838
- code: ZodIssueCode.too_big,
7839
- maximum: check2.value,
7840
- type: "string",
7841
- inclusive: true,
7842
- exact: false,
7843
- message: check2.message
7844
- });
7845
- status.dirty();
7846
- }
7847
- } else if (check2.kind === "length") {
7848
- const tooBig = input.data.length > check2.value;
7849
- const tooSmall = input.data.length < check2.value;
7850
- if (tooBig || tooSmall) {
7851
- ctx = this._getOrReturnCtx(input, ctx);
7852
- if (tooBig) {
7853
- addIssueToContext(ctx, {
7854
- code: ZodIssueCode.too_big,
7855
- maximum: check2.value,
7856
- type: "string",
7857
- inclusive: true,
7858
- exact: true,
7859
- message: check2.message
7860
- });
7861
- } else if (tooSmall) {
7862
- addIssueToContext(ctx, {
7863
- code: ZodIssueCode.too_small,
7864
- minimum: check2.value,
7865
- type: "string",
7866
- inclusive: true,
7867
- exact: true,
7868
- message: check2.message
7869
- });
7870
- }
7871
- status.dirty();
7872
- }
7873
- } else if (check2.kind === "email") {
7874
- if (!emailRegex.test(input.data)) {
7875
- ctx = this._getOrReturnCtx(input, ctx);
7876
- addIssueToContext(ctx, {
7877
- validation: "email",
7878
- code: ZodIssueCode.invalid_string,
7879
- message: check2.message
7880
- });
7881
- status.dirty();
7882
- }
7883
- } else if (check2.kind === "emoji") {
7884
- if (!emojiRegex) {
7885
- emojiRegex = new RegExp(_emojiRegex, "u");
7886
- }
7887
- if (!emojiRegex.test(input.data)) {
7888
- ctx = this._getOrReturnCtx(input, ctx);
7889
- addIssueToContext(ctx, {
7890
- validation: "emoji",
7891
- code: ZodIssueCode.invalid_string,
7892
- message: check2.message
7893
- });
7894
- status.dirty();
7895
- }
7896
- } else if (check2.kind === "uuid") {
7897
- if (!uuidRegex.test(input.data)) {
7898
- ctx = this._getOrReturnCtx(input, ctx);
7899
- addIssueToContext(ctx, {
7900
- validation: "uuid",
7901
- code: ZodIssueCode.invalid_string,
7902
- message: check2.message
7903
- });
7904
- status.dirty();
7905
- }
7906
- } else if (check2.kind === "nanoid") {
7907
- if (!nanoidRegex.test(input.data)) {
7908
- ctx = this._getOrReturnCtx(input, ctx);
7909
- addIssueToContext(ctx, {
7910
- validation: "nanoid",
7911
- code: ZodIssueCode.invalid_string,
7912
- message: check2.message
7913
- });
7914
- status.dirty();
7915
- }
7916
- } else if (check2.kind === "cuid") {
7917
- if (!cuidRegex.test(input.data)) {
7918
- ctx = this._getOrReturnCtx(input, ctx);
7919
- addIssueToContext(ctx, {
7920
- validation: "cuid",
7921
- code: ZodIssueCode.invalid_string,
7922
- message: check2.message
7923
- });
7924
- status.dirty();
7925
- }
7926
- } else if (check2.kind === "cuid2") {
7927
- if (!cuid2Regex.test(input.data)) {
7928
- ctx = this._getOrReturnCtx(input, ctx);
7929
- addIssueToContext(ctx, {
7930
- validation: "cuid2",
7931
- code: ZodIssueCode.invalid_string,
7932
- message: check2.message
7933
- });
7934
- status.dirty();
7935
- }
7936
- } else if (check2.kind === "ulid") {
7937
- if (!ulidRegex.test(input.data)) {
7938
- ctx = this._getOrReturnCtx(input, ctx);
7939
- addIssueToContext(ctx, {
7940
- validation: "ulid",
7941
- code: ZodIssueCode.invalid_string,
7942
- message: check2.message
7943
- });
7944
- status.dirty();
7945
- }
7946
- } else if (check2.kind === "url") {
7947
- try {
7948
- new URL(input.data);
7949
- } catch {
7950
- ctx = this._getOrReturnCtx(input, ctx);
7951
- addIssueToContext(ctx, {
7952
- validation: "url",
7953
- code: ZodIssueCode.invalid_string,
7954
- message: check2.message
7955
- });
7956
- status.dirty();
7957
- }
7958
- } else if (check2.kind === "regex") {
7959
- check2.regex.lastIndex = 0;
7960
- const testResult = check2.regex.test(input.data);
7961
- if (!testResult) {
7962
- ctx = this._getOrReturnCtx(input, ctx);
7963
- addIssueToContext(ctx, {
7964
- validation: "regex",
7965
- code: ZodIssueCode.invalid_string,
7966
- message: check2.message
7967
- });
7968
- status.dirty();
7969
- }
7970
- } else if (check2.kind === "trim") {
7971
- input.data = input.data.trim();
7972
- } else if (check2.kind === "includes") {
7973
- if (!input.data.includes(check2.value, check2.position)) {
7974
- ctx = this._getOrReturnCtx(input, ctx);
7975
- addIssueToContext(ctx, {
7976
- code: ZodIssueCode.invalid_string,
7977
- validation: { includes: check2.value, position: check2.position },
7978
- message: check2.message
7979
- });
7980
- status.dirty();
7981
- }
7982
- } else if (check2.kind === "toLowerCase") {
7983
- input.data = input.data.toLowerCase();
7984
- } else if (check2.kind === "toUpperCase") {
7985
- input.data = input.data.toUpperCase();
7986
- } else if (check2.kind === "startsWith") {
7987
- if (!input.data.startsWith(check2.value)) {
7988
- ctx = this._getOrReturnCtx(input, ctx);
7989
- addIssueToContext(ctx, {
7990
- code: ZodIssueCode.invalid_string,
7991
- validation: { startsWith: check2.value },
7992
- message: check2.message
7993
- });
7994
- status.dirty();
7995
- }
7996
- } else if (check2.kind === "endsWith") {
7997
- if (!input.data.endsWith(check2.value)) {
7998
- ctx = this._getOrReturnCtx(input, ctx);
7999
- addIssueToContext(ctx, {
8000
- code: ZodIssueCode.invalid_string,
8001
- validation: { endsWith: check2.value },
8002
- message: check2.message
8003
- });
8004
- status.dirty();
8005
- }
8006
- } else if (check2.kind === "datetime") {
8007
- const regex = datetimeRegex(check2);
8008
- if (!regex.test(input.data)) {
8009
- ctx = this._getOrReturnCtx(input, ctx);
8010
- addIssueToContext(ctx, {
8011
- code: ZodIssueCode.invalid_string,
8012
- validation: "datetime",
8013
- message: check2.message
8014
- });
8015
- status.dirty();
8016
- }
8017
- } else if (check2.kind === "date") {
8018
- const regex = dateRegex;
8019
- if (!regex.test(input.data)) {
8020
- ctx = this._getOrReturnCtx(input, ctx);
8021
- addIssueToContext(ctx, {
8022
- code: ZodIssueCode.invalid_string,
8023
- validation: "date",
8024
- message: check2.message
8025
- });
8026
- status.dirty();
8027
- }
8028
- } else if (check2.kind === "time") {
8029
- const regex = timeRegex(check2);
8030
- if (!regex.test(input.data)) {
8031
- ctx = this._getOrReturnCtx(input, ctx);
8032
- addIssueToContext(ctx, {
8033
- code: ZodIssueCode.invalid_string,
8034
- validation: "time",
8035
- message: check2.message
8036
- });
8037
- status.dirty();
8038
- }
8039
- } else if (check2.kind === "duration") {
8040
- if (!durationRegex.test(input.data)) {
8041
- ctx = this._getOrReturnCtx(input, ctx);
8042
- addIssueToContext(ctx, {
8043
- validation: "duration",
8044
- code: ZodIssueCode.invalid_string,
8045
- message: check2.message
8046
- });
8047
- status.dirty();
8048
- }
8049
- } else if (check2.kind === "ip") {
8050
- if (!isValidIP(input.data, check2.version)) {
8051
- ctx = this._getOrReturnCtx(input, ctx);
8052
- addIssueToContext(ctx, {
8053
- validation: "ip",
8054
- code: ZodIssueCode.invalid_string,
8055
- message: check2.message
8056
- });
8057
- status.dirty();
8058
- }
8059
- } else if (check2.kind === "jwt") {
8060
- if (!isValidJWT(input.data, check2.alg)) {
8061
- ctx = this._getOrReturnCtx(input, ctx);
8062
- addIssueToContext(ctx, {
8063
- validation: "jwt",
8064
- code: ZodIssueCode.invalid_string,
8065
- message: check2.message
8066
- });
8067
- status.dirty();
8068
- }
8069
- } else if (check2.kind === "cidr") {
8070
- if (!isValidCidr(input.data, check2.version)) {
8071
- ctx = this._getOrReturnCtx(input, ctx);
8072
- addIssueToContext(ctx, {
8073
- validation: "cidr",
8074
- code: ZodIssueCode.invalid_string,
8075
- message: check2.message
8076
- });
8077
- status.dirty();
8078
- }
8079
- } else if (check2.kind === "base64") {
8080
- if (!base64Regex.test(input.data)) {
8081
- ctx = this._getOrReturnCtx(input, ctx);
8082
- addIssueToContext(ctx, {
8083
- validation: "base64",
8084
- code: ZodIssueCode.invalid_string,
8085
- message: check2.message
8086
- });
8087
- status.dirty();
8088
- }
8089
- } else if (check2.kind === "base64url") {
8090
- if (!base64urlRegex.test(input.data)) {
8091
- ctx = this._getOrReturnCtx(input, ctx);
8092
- addIssueToContext(ctx, {
8093
- validation: "base64url",
8094
- code: ZodIssueCode.invalid_string,
8095
- message: check2.message
8096
- });
8097
- status.dirty();
8098
- }
8099
- } else {
8100
- util.assertNever(check2);
8101
- }
8102
- }
8103
- return { status: status.value, value: input.data };
8104
- }
8105
- _regex(regex, validation, message) {
8106
- return this.refinement((data) => regex.test(data), {
8107
- validation,
8108
- code: ZodIssueCode.invalid_string,
8109
- ...errorUtil.errToObj(message)
8110
- });
8111
- }
8112
- _addCheck(check2) {
8113
- return new _ZodString2({
8114
- ...this._def,
8115
- checks: [...this._def.checks, check2]
8116
- });
8117
- }
8118
- email(message) {
8119
- return this._addCheck({ kind: "email", ...errorUtil.errToObj(message) });
8120
- }
8121
- url(message) {
8122
- return this._addCheck({ kind: "url", ...errorUtil.errToObj(message) });
8123
- }
8124
- emoji(message) {
8125
- return this._addCheck({ kind: "emoji", ...errorUtil.errToObj(message) });
8126
- }
8127
- uuid(message) {
8128
- return this._addCheck({ kind: "uuid", ...errorUtil.errToObj(message) });
8129
- }
8130
- nanoid(message) {
8131
- return this._addCheck({ kind: "nanoid", ...errorUtil.errToObj(message) });
8132
- }
8133
- cuid(message) {
8134
- return this._addCheck({ kind: "cuid", ...errorUtil.errToObj(message) });
8135
- }
8136
- cuid2(message) {
8137
- return this._addCheck({ kind: "cuid2", ...errorUtil.errToObj(message) });
8138
- }
8139
- ulid(message) {
8140
- return this._addCheck({ kind: "ulid", ...errorUtil.errToObj(message) });
8141
- }
8142
- base64(message) {
8143
- return this._addCheck({ kind: "base64", ...errorUtil.errToObj(message) });
8144
- }
8145
- base64url(message) {
8146
- return this._addCheck({
8147
- kind: "base64url",
8148
- ...errorUtil.errToObj(message)
8149
- });
8150
- }
8151
- jwt(options) {
8152
- return this._addCheck({ kind: "jwt", ...errorUtil.errToObj(options) });
8153
- }
8154
- ip(options) {
8155
- return this._addCheck({ kind: "ip", ...errorUtil.errToObj(options) });
8156
- }
8157
- cidr(options) {
8158
- return this._addCheck({ kind: "cidr", ...errorUtil.errToObj(options) });
8159
- }
8160
- datetime(options) {
8161
- if (typeof options === "string") {
8162
- return this._addCheck({
8163
- kind: "datetime",
8164
- precision: null,
8165
- offset: false,
8166
- local: false,
8167
- message: options
8168
- });
8169
- }
8170
- return this._addCheck({
8171
- kind: "datetime",
8172
- precision: typeof options?.precision === "undefined" ? null : options?.precision,
8173
- offset: options?.offset ?? false,
8174
- local: options?.local ?? false,
8175
- ...errorUtil.errToObj(options?.message)
8176
- });
8177
- }
8178
- date(message) {
8179
- return this._addCheck({ kind: "date", message });
8180
- }
8181
- time(options) {
8182
- if (typeof options === "string") {
8183
- return this._addCheck({
8184
- kind: "time",
8185
- precision: null,
8186
- message: options
8187
- });
8188
- }
8189
- return this._addCheck({
8190
- kind: "time",
8191
- precision: typeof options?.precision === "undefined" ? null : options?.precision,
8192
- ...errorUtil.errToObj(options?.message)
8193
- });
8194
- }
8195
- duration(message) {
8196
- return this._addCheck({ kind: "duration", ...errorUtil.errToObj(message) });
8197
- }
8198
- regex(regex, message) {
8199
- return this._addCheck({
8200
- kind: "regex",
8201
- regex,
8202
- ...errorUtil.errToObj(message)
8203
- });
8204
- }
8205
- includes(value, options) {
8206
- return this._addCheck({
8207
- kind: "includes",
8208
- value,
8209
- position: options?.position,
8210
- ...errorUtil.errToObj(options?.message)
8211
- });
8212
- }
8213
- startsWith(value, message) {
8214
- return this._addCheck({
8215
- kind: "startsWith",
8216
- value,
8217
- ...errorUtil.errToObj(message)
8218
- });
8219
- }
8220
- endsWith(value, message) {
8221
- return this._addCheck({
8222
- kind: "endsWith",
8223
- value,
8224
- ...errorUtil.errToObj(message)
8225
- });
8226
- }
8227
- min(minLength, message) {
8228
- return this._addCheck({
8229
- kind: "min",
8230
- value: minLength,
8231
- ...errorUtil.errToObj(message)
8232
- });
8233
- }
8234
- max(maxLength, message) {
8235
- return this._addCheck({
8236
- kind: "max",
8237
- value: maxLength,
8238
- ...errorUtil.errToObj(message)
8239
- });
8240
- }
8241
- length(len, message) {
8242
- return this._addCheck({
8243
- kind: "length",
8244
- value: len,
8245
- ...errorUtil.errToObj(message)
8246
- });
8247
- }
8248
- /**
8249
- * Equivalent to `.min(1)`
8250
- */
8251
- nonempty(message) {
8252
- return this.min(1, errorUtil.errToObj(message));
8253
- }
8254
- trim() {
8255
- return new _ZodString2({
8256
- ...this._def,
8257
- checks: [...this._def.checks, { kind: "trim" }]
8258
- });
8259
- }
8260
- toLowerCase() {
8261
- return new _ZodString2({
8262
- ...this._def,
8263
- checks: [...this._def.checks, { kind: "toLowerCase" }]
8264
- });
8265
- }
8266
- toUpperCase() {
8267
- return new _ZodString2({
8268
- ...this._def,
8269
- checks: [...this._def.checks, { kind: "toUpperCase" }]
8270
- });
8271
- }
8272
- get isDatetime() {
8273
- return !!this._def.checks.find((ch) => ch.kind === "datetime");
8274
- }
8275
- get isDate() {
8276
- return !!this._def.checks.find((ch) => ch.kind === "date");
8277
- }
8278
- get isTime() {
8279
- return !!this._def.checks.find((ch) => ch.kind === "time");
8280
- }
8281
- get isDuration() {
8282
- return !!this._def.checks.find((ch) => ch.kind === "duration");
8283
- }
8284
- get isEmail() {
8285
- return !!this._def.checks.find((ch) => ch.kind === "email");
8286
- }
8287
- get isURL() {
8288
- return !!this._def.checks.find((ch) => ch.kind === "url");
8289
- }
8290
- get isEmoji() {
8291
- return !!this._def.checks.find((ch) => ch.kind === "emoji");
8292
- }
8293
- get isUUID() {
8294
- return !!this._def.checks.find((ch) => ch.kind === "uuid");
8295
- }
8296
- get isNANOID() {
8297
- return !!this._def.checks.find((ch) => ch.kind === "nanoid");
8298
- }
8299
- get isCUID() {
8300
- return !!this._def.checks.find((ch) => ch.kind === "cuid");
8301
- }
8302
- get isCUID2() {
8303
- return !!this._def.checks.find((ch) => ch.kind === "cuid2");
8304
- }
8305
- get isULID() {
8306
- return !!this._def.checks.find((ch) => ch.kind === "ulid");
8307
- }
8308
- get isIP() {
8309
- return !!this._def.checks.find((ch) => ch.kind === "ip");
8310
- }
8311
- get isCIDR() {
8312
- return !!this._def.checks.find((ch) => ch.kind === "cidr");
8313
- }
8314
- get isBase64() {
8315
- return !!this._def.checks.find((ch) => ch.kind === "base64");
8316
- }
8317
- get isBase64url() {
8318
- return !!this._def.checks.find((ch) => ch.kind === "base64url");
8319
- }
8320
- get minLength() {
8321
- let min = null;
8322
- for (const ch of this._def.checks) {
8323
- if (ch.kind === "min") {
8324
- if (min === null || ch.value > min)
8325
- min = ch.value;
8326
- }
8327
- }
8328
- return min;
8329
- }
8330
- get maxLength() {
8331
- let max = null;
8332
- for (const ch of this._def.checks) {
8333
- if (ch.kind === "max") {
8334
- if (max === null || ch.value < max)
8335
- max = ch.value;
8336
- }
8337
- }
8338
- return max;
8339
- }
8340
- };
8341
- ZodString.create = (params) => {
8342
- return new ZodString({
8343
- checks: [],
8344
- typeName: ZodFirstPartyTypeKind.ZodString,
8345
- coerce: params?.coerce ?? false,
8346
- ...processCreateParams(params)
8347
- });
8348
- };
8349
- function floatSafeRemainder(val, step) {
8350
- const valDecCount = (val.toString().split(".")[1] || "").length;
8351
- const stepDecCount = (step.toString().split(".")[1] || "").length;
8352
- const decCount = valDecCount > stepDecCount ? valDecCount : stepDecCount;
8353
- const valInt = Number.parseInt(val.toFixed(decCount).replace(".", ""));
8354
- const stepInt = Number.parseInt(step.toFixed(decCount).replace(".", ""));
8355
- return valInt % stepInt / 10 ** decCount;
8356
- }
8357
- var ZodNumber = class _ZodNumber extends ZodType {
8358
- constructor() {
8359
- super(...arguments);
8360
- this.min = this.gte;
8361
- this.max = this.lte;
8362
- this.step = this.multipleOf;
8363
- }
8364
- _parse(input) {
8365
- if (this._def.coerce) {
8366
- input.data = Number(input.data);
8367
- }
8368
- const parsedType2 = this._getType(input);
8369
- if (parsedType2 !== ZodParsedType.number) {
8370
- const ctx2 = this._getOrReturnCtx(input);
8371
- addIssueToContext(ctx2, {
8372
- code: ZodIssueCode.invalid_type,
8373
- expected: ZodParsedType.number,
8374
- received: ctx2.parsedType
8375
- });
8376
- return INVALID;
8377
- }
8378
- let ctx = void 0;
8379
- const status = new ParseStatus();
8380
- for (const check2 of this._def.checks) {
8381
- if (check2.kind === "int") {
8382
- if (!util.isInteger(input.data)) {
8383
- ctx = this._getOrReturnCtx(input, ctx);
8384
- addIssueToContext(ctx, {
8385
- code: ZodIssueCode.invalid_type,
8386
- expected: "integer",
8387
- received: "float",
8388
- message: check2.message
8389
- });
8390
- status.dirty();
8391
- }
8392
- } else if (check2.kind === "min") {
8393
- const tooSmall = check2.inclusive ? input.data < check2.value : input.data <= check2.value;
8394
- if (tooSmall) {
8395
- ctx = this._getOrReturnCtx(input, ctx);
8396
- addIssueToContext(ctx, {
8397
- code: ZodIssueCode.too_small,
8398
- minimum: check2.value,
8399
- type: "number",
8400
- inclusive: check2.inclusive,
8401
- exact: false,
8402
- message: check2.message
8403
- });
8404
- status.dirty();
8405
- }
8406
- } else if (check2.kind === "max") {
8407
- const tooBig = check2.inclusive ? input.data > check2.value : input.data >= check2.value;
8408
- if (tooBig) {
8409
- ctx = this._getOrReturnCtx(input, ctx);
8410
- addIssueToContext(ctx, {
8411
- code: ZodIssueCode.too_big,
8412
- maximum: check2.value,
8413
- type: "number",
8414
- inclusive: check2.inclusive,
8415
- exact: false,
8416
- message: check2.message
8417
- });
8418
- status.dirty();
8419
- }
8420
- } else if (check2.kind === "multipleOf") {
8421
- if (floatSafeRemainder(input.data, check2.value) !== 0) {
8422
- ctx = this._getOrReturnCtx(input, ctx);
8423
- addIssueToContext(ctx, {
8424
- code: ZodIssueCode.not_multiple_of,
8425
- multipleOf: check2.value,
8426
- message: check2.message
8427
- });
8428
- status.dirty();
8429
- }
8430
- } else if (check2.kind === "finite") {
8431
- if (!Number.isFinite(input.data)) {
8432
- ctx = this._getOrReturnCtx(input, ctx);
8433
- addIssueToContext(ctx, {
8434
- code: ZodIssueCode.not_finite,
8435
- message: check2.message
8436
- });
8437
- status.dirty();
8438
- }
8439
- } else {
8440
- util.assertNever(check2);
8441
- }
8442
- }
8443
- return { status: status.value, value: input.data };
8444
- }
8445
- gte(value, message) {
8446
- return this.setLimit("min", value, true, errorUtil.toString(message));
8447
- }
8448
- gt(value, message) {
8449
- return this.setLimit("min", value, false, errorUtil.toString(message));
8450
- }
8451
- lte(value, message) {
8452
- return this.setLimit("max", value, true, errorUtil.toString(message));
8453
- }
8454
- lt(value, message) {
8455
- return this.setLimit("max", value, false, errorUtil.toString(message));
8456
- }
8457
- setLimit(kind, value, inclusive, message) {
8458
- return new _ZodNumber({
8459
- ...this._def,
8460
- checks: [
8461
- ...this._def.checks,
8462
- {
8463
- kind,
8464
- value,
8465
- inclusive,
8466
- message: errorUtil.toString(message)
8467
- }
8468
- ]
8469
- });
8470
- }
8471
- _addCheck(check2) {
8472
- return new _ZodNumber({
8473
- ...this._def,
8474
- checks: [...this._def.checks, check2]
8475
- });
8476
- }
8477
- int(message) {
8478
- return this._addCheck({
8479
- kind: "int",
8480
- message: errorUtil.toString(message)
8481
- });
8482
- }
8483
- positive(message) {
8484
- return this._addCheck({
8485
- kind: "min",
8486
- value: 0,
8487
- inclusive: false,
8488
- message: errorUtil.toString(message)
8489
- });
8490
- }
8491
- negative(message) {
8492
- return this._addCheck({
8493
- kind: "max",
8494
- value: 0,
8495
- inclusive: false,
8496
- message: errorUtil.toString(message)
8497
- });
8498
- }
8499
- nonpositive(message) {
8500
- return this._addCheck({
8501
- kind: "max",
8502
- value: 0,
8503
- inclusive: true,
8504
- message: errorUtil.toString(message)
8505
- });
8506
- }
8507
- nonnegative(message) {
8508
- return this._addCheck({
8509
- kind: "min",
8510
- value: 0,
8511
- inclusive: true,
8512
- message: errorUtil.toString(message)
8513
- });
8514
- }
8515
- multipleOf(value, message) {
8516
- return this._addCheck({
8517
- kind: "multipleOf",
8518
- value,
8519
- message: errorUtil.toString(message)
8520
- });
8521
- }
8522
- finite(message) {
8523
- return this._addCheck({
8524
- kind: "finite",
8525
- message: errorUtil.toString(message)
8526
- });
8527
- }
8528
- safe(message) {
8529
- return this._addCheck({
8530
- kind: "min",
8531
- inclusive: true,
8532
- value: Number.MIN_SAFE_INTEGER,
8533
- message: errorUtil.toString(message)
8534
- })._addCheck({
8535
- kind: "max",
8536
- inclusive: true,
8537
- value: Number.MAX_SAFE_INTEGER,
8538
- message: errorUtil.toString(message)
8539
- });
8540
- }
8541
- get minValue() {
8542
- let min = null;
8543
- for (const ch of this._def.checks) {
8544
- if (ch.kind === "min") {
8545
- if (min === null || ch.value > min)
8546
- min = ch.value;
8547
- }
8548
- }
8549
- return min;
8550
- }
8551
- get maxValue() {
8552
- let max = null;
8553
- for (const ch of this._def.checks) {
8554
- if (ch.kind === "max") {
8555
- if (max === null || ch.value < max)
8556
- max = ch.value;
8557
- }
8558
- }
8559
- return max;
8560
- }
8561
- get isInt() {
8562
- return !!this._def.checks.find((ch) => ch.kind === "int" || ch.kind === "multipleOf" && util.isInteger(ch.value));
8563
- }
8564
- get isFinite() {
8565
- let max = null;
8566
- let min = null;
8567
- for (const ch of this._def.checks) {
8568
- if (ch.kind === "finite" || ch.kind === "int" || ch.kind === "multipleOf") {
8569
- return true;
8570
- } else if (ch.kind === "min") {
8571
- if (min === null || ch.value > min)
8572
- min = ch.value;
8573
- } else if (ch.kind === "max") {
8574
- if (max === null || ch.value < max)
8575
- max = ch.value;
8576
- }
8577
- }
8578
- return Number.isFinite(min) && Number.isFinite(max);
8579
- }
8580
- };
8581
- ZodNumber.create = (params) => {
8582
- return new ZodNumber({
8583
- checks: [],
8584
- typeName: ZodFirstPartyTypeKind.ZodNumber,
8585
- coerce: params?.coerce || false,
8586
- ...processCreateParams(params)
8587
- });
8588
- };
8589
- var ZodBigInt = class _ZodBigInt extends ZodType {
8590
- constructor() {
8591
- super(...arguments);
8592
- this.min = this.gte;
8593
- this.max = this.lte;
8594
- }
8595
- _parse(input) {
8596
- if (this._def.coerce) {
8597
- try {
8598
- input.data = BigInt(input.data);
8599
- } catch {
8600
- return this._getInvalidInput(input);
8601
- }
8602
- }
8603
- const parsedType2 = this._getType(input);
8604
- if (parsedType2 !== ZodParsedType.bigint) {
8605
- return this._getInvalidInput(input);
8606
- }
8607
- let ctx = void 0;
8608
- const status = new ParseStatus();
8609
- for (const check2 of this._def.checks) {
8610
- if (check2.kind === "min") {
8611
- const tooSmall = check2.inclusive ? input.data < check2.value : input.data <= check2.value;
8612
- if (tooSmall) {
8613
- ctx = this._getOrReturnCtx(input, ctx);
8614
- addIssueToContext(ctx, {
8615
- code: ZodIssueCode.too_small,
8616
- type: "bigint",
8617
- minimum: check2.value,
8618
- inclusive: check2.inclusive,
8619
- message: check2.message
8620
- });
8621
- status.dirty();
8622
- }
8623
- } else if (check2.kind === "max") {
8624
- const tooBig = check2.inclusive ? input.data > check2.value : input.data >= check2.value;
8625
- if (tooBig) {
8626
- ctx = this._getOrReturnCtx(input, ctx);
8627
- addIssueToContext(ctx, {
8628
- code: ZodIssueCode.too_big,
8629
- type: "bigint",
8630
- maximum: check2.value,
8631
- inclusive: check2.inclusive,
8632
- message: check2.message
8633
- });
8634
- status.dirty();
8635
- }
8636
- } else if (check2.kind === "multipleOf") {
8637
- if (input.data % check2.value !== BigInt(0)) {
8638
- ctx = this._getOrReturnCtx(input, ctx);
8639
- addIssueToContext(ctx, {
8640
- code: ZodIssueCode.not_multiple_of,
8641
- multipleOf: check2.value,
8642
- message: check2.message
8643
- });
8644
- status.dirty();
8645
- }
8646
- } else {
8647
- util.assertNever(check2);
8648
- }
8649
- }
8650
- return { status: status.value, value: input.data };
8651
- }
8652
- _getInvalidInput(input) {
8653
- const ctx = this._getOrReturnCtx(input);
8654
- addIssueToContext(ctx, {
8655
- code: ZodIssueCode.invalid_type,
8656
- expected: ZodParsedType.bigint,
8657
- received: ctx.parsedType
8658
- });
8659
- return INVALID;
8660
- }
8661
- gte(value, message) {
8662
- return this.setLimit("min", value, true, errorUtil.toString(message));
8663
- }
8664
- gt(value, message) {
8665
- return this.setLimit("min", value, false, errorUtil.toString(message));
8666
- }
8667
- lte(value, message) {
8668
- return this.setLimit("max", value, true, errorUtil.toString(message));
8669
- }
8670
- lt(value, message) {
8671
- return this.setLimit("max", value, false, errorUtil.toString(message));
8672
- }
8673
- setLimit(kind, value, inclusive, message) {
8674
- return new _ZodBigInt({
8675
- ...this._def,
8676
- checks: [
8677
- ...this._def.checks,
8678
- {
8679
- kind,
8680
- value,
8681
- inclusive,
8682
- message: errorUtil.toString(message)
8683
- }
8684
- ]
8685
- });
8686
- }
8687
- _addCheck(check2) {
8688
- return new _ZodBigInt({
8689
- ...this._def,
8690
- checks: [...this._def.checks, check2]
8691
- });
8692
- }
8693
- positive(message) {
8694
- return this._addCheck({
8695
- kind: "min",
8696
- value: BigInt(0),
8697
- inclusive: false,
8698
- message: errorUtil.toString(message)
8699
- });
8700
- }
8701
- negative(message) {
8702
- return this._addCheck({
8703
- kind: "max",
8704
- value: BigInt(0),
8705
- inclusive: false,
8706
- message: errorUtil.toString(message)
8707
- });
8708
- }
8709
- nonpositive(message) {
8710
- return this._addCheck({
8711
- kind: "max",
8712
- value: BigInt(0),
8713
- inclusive: true,
8714
- message: errorUtil.toString(message)
8715
- });
8716
- }
8717
- nonnegative(message) {
8718
- return this._addCheck({
8719
- kind: "min",
8720
- value: BigInt(0),
8721
- inclusive: true,
8722
- message: errorUtil.toString(message)
8723
- });
8724
- }
8725
- multipleOf(value, message) {
8726
- return this._addCheck({
8727
- kind: "multipleOf",
8728
- value,
8729
- message: errorUtil.toString(message)
8730
- });
8731
- }
8732
- get minValue() {
8733
- let min = null;
8734
- for (const ch of this._def.checks) {
8735
- if (ch.kind === "min") {
8736
- if (min === null || ch.value > min)
8737
- min = ch.value;
8738
- }
8739
- }
8740
- return min;
8741
- }
8742
- get maxValue() {
8743
- let max = null;
8744
- for (const ch of this._def.checks) {
8745
- if (ch.kind === "max") {
8746
- if (max === null || ch.value < max)
8747
- max = ch.value;
8748
- }
8749
- }
8750
- return max;
8751
- }
8752
- };
8753
- ZodBigInt.create = (params) => {
8754
- return new ZodBigInt({
8755
- checks: [],
8756
- typeName: ZodFirstPartyTypeKind.ZodBigInt,
8757
- coerce: params?.coerce ?? false,
8758
- ...processCreateParams(params)
8759
- });
8760
- };
8761
- var ZodBoolean = class extends ZodType {
8762
- _parse(input) {
8763
- if (this._def.coerce) {
8764
- input.data = Boolean(input.data);
8765
- }
8766
- const parsedType2 = this._getType(input);
8767
- if (parsedType2 !== ZodParsedType.boolean) {
8768
- const ctx = this._getOrReturnCtx(input);
8769
- addIssueToContext(ctx, {
8770
- code: ZodIssueCode.invalid_type,
8771
- expected: ZodParsedType.boolean,
8772
- received: ctx.parsedType
8773
- });
8774
- return INVALID;
8775
- }
8776
- return OK(input.data);
8777
- }
8778
- };
8779
- ZodBoolean.create = (params) => {
8780
- return new ZodBoolean({
8781
- typeName: ZodFirstPartyTypeKind.ZodBoolean,
8782
- coerce: params?.coerce || false,
8783
- ...processCreateParams(params)
8784
- });
8785
- };
8786
- var ZodDate = class _ZodDate extends ZodType {
8787
- _parse(input) {
8788
- if (this._def.coerce) {
8789
- input.data = new Date(input.data);
8790
- }
8791
- const parsedType2 = this._getType(input);
8792
- if (parsedType2 !== ZodParsedType.date) {
8793
- const ctx2 = this._getOrReturnCtx(input);
8794
- addIssueToContext(ctx2, {
8795
- code: ZodIssueCode.invalid_type,
8796
- expected: ZodParsedType.date,
8797
- received: ctx2.parsedType
8798
- });
8799
- return INVALID;
8800
- }
8801
- if (Number.isNaN(input.data.getTime())) {
8802
- const ctx2 = this._getOrReturnCtx(input);
8803
- addIssueToContext(ctx2, {
8804
- code: ZodIssueCode.invalid_date
8805
- });
8806
- return INVALID;
8807
- }
8808
- const status = new ParseStatus();
8809
- let ctx = void 0;
8810
- for (const check2 of this._def.checks) {
8811
- if (check2.kind === "min") {
8812
- if (input.data.getTime() < check2.value) {
8813
- ctx = this._getOrReturnCtx(input, ctx);
8814
- addIssueToContext(ctx, {
8815
- code: ZodIssueCode.too_small,
8816
- message: check2.message,
8817
- inclusive: true,
8818
- exact: false,
8819
- minimum: check2.value,
8820
- type: "date"
8821
- });
8822
- status.dirty();
8823
- }
8824
- } else if (check2.kind === "max") {
8825
- if (input.data.getTime() > check2.value) {
8826
- ctx = this._getOrReturnCtx(input, ctx);
8827
- addIssueToContext(ctx, {
8828
- code: ZodIssueCode.too_big,
8829
- message: check2.message,
8830
- inclusive: true,
8831
- exact: false,
8832
- maximum: check2.value,
8833
- type: "date"
8834
- });
8835
- status.dirty();
8836
- }
8837
- } else {
8838
- util.assertNever(check2);
8839
- }
8840
- }
8841
- return {
8842
- status: status.value,
8843
- value: new Date(input.data.getTime())
8844
- };
8845
- }
8846
- _addCheck(check2) {
8847
- return new _ZodDate({
8848
- ...this._def,
8849
- checks: [...this._def.checks, check2]
8850
- });
8851
- }
8852
- min(minDate, message) {
8853
- return this._addCheck({
8854
- kind: "min",
8855
- value: minDate.getTime(),
8856
- message: errorUtil.toString(message)
8857
- });
8858
- }
8859
- max(maxDate, message) {
8860
- return this._addCheck({
8861
- kind: "max",
8862
- value: maxDate.getTime(),
8863
- message: errorUtil.toString(message)
8864
- });
8865
- }
8866
- get minDate() {
8867
- let min = null;
8868
- for (const ch of this._def.checks) {
8869
- if (ch.kind === "min") {
8870
- if (min === null || ch.value > min)
8871
- min = ch.value;
8872
- }
8873
- }
8874
- return min != null ? new Date(min) : null;
8875
- }
8876
- get maxDate() {
8877
- let max = null;
8878
- for (const ch of this._def.checks) {
8879
- if (ch.kind === "max") {
8880
- if (max === null || ch.value < max)
8881
- max = ch.value;
8882
- }
8883
- }
8884
- return max != null ? new Date(max) : null;
8885
- }
8886
- };
8887
- ZodDate.create = (params) => {
8888
- return new ZodDate({
8889
- checks: [],
8890
- coerce: params?.coerce || false,
8891
- typeName: ZodFirstPartyTypeKind.ZodDate,
8892
- ...processCreateParams(params)
8893
- });
8894
- };
8895
- var ZodSymbol = class extends ZodType {
8896
- _parse(input) {
8897
- const parsedType2 = this._getType(input);
8898
- if (parsedType2 !== ZodParsedType.symbol) {
8899
- const ctx = this._getOrReturnCtx(input);
8900
- addIssueToContext(ctx, {
8901
- code: ZodIssueCode.invalid_type,
8902
- expected: ZodParsedType.symbol,
8903
- received: ctx.parsedType
8904
- });
8905
- return INVALID;
8906
- }
8907
- return OK(input.data);
8908
- }
8909
- };
8910
- ZodSymbol.create = (params) => {
8911
- return new ZodSymbol({
8912
- typeName: ZodFirstPartyTypeKind.ZodSymbol,
8913
- ...processCreateParams(params)
8914
- });
8915
- };
8916
- var ZodUndefined = class extends ZodType {
8917
- _parse(input) {
8918
- const parsedType2 = this._getType(input);
8919
- if (parsedType2 !== ZodParsedType.undefined) {
8920
- const ctx = this._getOrReturnCtx(input);
8921
- addIssueToContext(ctx, {
8922
- code: ZodIssueCode.invalid_type,
8923
- expected: ZodParsedType.undefined,
8924
- received: ctx.parsedType
8925
- });
8926
- return INVALID;
8927
- }
8928
- return OK(input.data);
8929
- }
8930
- };
8931
- ZodUndefined.create = (params) => {
8932
- return new ZodUndefined({
8933
- typeName: ZodFirstPartyTypeKind.ZodUndefined,
8934
- ...processCreateParams(params)
8935
- });
8936
- };
8937
- var ZodNull = class extends ZodType {
8938
- _parse(input) {
8939
- const parsedType2 = this._getType(input);
8940
- if (parsedType2 !== ZodParsedType.null) {
8941
- const ctx = this._getOrReturnCtx(input);
8942
- addIssueToContext(ctx, {
8943
- code: ZodIssueCode.invalid_type,
8944
- expected: ZodParsedType.null,
8945
- received: ctx.parsedType
8946
- });
8947
- return INVALID;
8948
- }
8949
- return OK(input.data);
8950
- }
8951
- };
8952
- ZodNull.create = (params) => {
8953
- return new ZodNull({
8954
- typeName: ZodFirstPartyTypeKind.ZodNull,
8955
- ...processCreateParams(params)
8956
- });
8957
- };
8958
- var ZodAny = class extends ZodType {
8959
- constructor() {
8960
- super(...arguments);
8961
- this._any = true;
8962
- }
8963
- _parse(input) {
8964
- return OK(input.data);
8965
- }
8966
- };
8967
- ZodAny.create = (params) => {
8968
- return new ZodAny({
8969
- typeName: ZodFirstPartyTypeKind.ZodAny,
8970
- ...processCreateParams(params)
8971
- });
8972
- };
8973
- var ZodUnknown = class extends ZodType {
8974
- constructor() {
8975
- super(...arguments);
8976
- this._unknown = true;
8977
- }
8978
- _parse(input) {
8979
- return OK(input.data);
8980
- }
8981
- };
8982
- ZodUnknown.create = (params) => {
8983
- return new ZodUnknown({
8984
- typeName: ZodFirstPartyTypeKind.ZodUnknown,
8985
- ...processCreateParams(params)
8986
- });
8987
- };
8988
- var ZodNever = class extends ZodType {
8989
- _parse(input) {
8990
- const ctx = this._getOrReturnCtx(input);
8991
- addIssueToContext(ctx, {
8992
- code: ZodIssueCode.invalid_type,
8993
- expected: ZodParsedType.never,
8994
- received: ctx.parsedType
8995
- });
8996
- return INVALID;
8997
- }
8998
- };
8999
- ZodNever.create = (params) => {
9000
- return new ZodNever({
9001
- typeName: ZodFirstPartyTypeKind.ZodNever,
9002
- ...processCreateParams(params)
9003
- });
9004
- };
9005
- var ZodVoid = class extends ZodType {
9006
- _parse(input) {
9007
- const parsedType2 = this._getType(input);
9008
- if (parsedType2 !== ZodParsedType.undefined) {
9009
- const ctx = this._getOrReturnCtx(input);
9010
- addIssueToContext(ctx, {
9011
- code: ZodIssueCode.invalid_type,
9012
- expected: ZodParsedType.void,
9013
- received: ctx.parsedType
9014
- });
9015
- return INVALID;
9016
- }
9017
- return OK(input.data);
9018
- }
9019
- };
9020
- ZodVoid.create = (params) => {
9021
- return new ZodVoid({
9022
- typeName: ZodFirstPartyTypeKind.ZodVoid,
9023
- ...processCreateParams(params)
9024
- });
9025
- };
9026
- var ZodArray = class _ZodArray extends ZodType {
9027
- _parse(input) {
9028
- const { ctx, status } = this._processInputParams(input);
9029
- const def = this._def;
9030
- if (ctx.parsedType !== ZodParsedType.array) {
9031
- addIssueToContext(ctx, {
9032
- code: ZodIssueCode.invalid_type,
9033
- expected: ZodParsedType.array,
9034
- received: ctx.parsedType
9035
- });
9036
- return INVALID;
9037
- }
9038
- if (def.exactLength !== null) {
9039
- const tooBig = ctx.data.length > def.exactLength.value;
9040
- const tooSmall = ctx.data.length < def.exactLength.value;
9041
- if (tooBig || tooSmall) {
9042
- addIssueToContext(ctx, {
9043
- code: tooBig ? ZodIssueCode.too_big : ZodIssueCode.too_small,
9044
- minimum: tooSmall ? def.exactLength.value : void 0,
9045
- maximum: tooBig ? def.exactLength.value : void 0,
9046
- type: "array",
9047
- inclusive: true,
9048
- exact: true,
9049
- message: def.exactLength.message
9050
- });
9051
- status.dirty();
9052
- }
9053
- }
9054
- if (def.minLength !== null) {
9055
- if (ctx.data.length < def.minLength.value) {
9056
- addIssueToContext(ctx, {
9057
- code: ZodIssueCode.too_small,
9058
- minimum: def.minLength.value,
9059
- type: "array",
9060
- inclusive: true,
9061
- exact: false,
9062
- message: def.minLength.message
9063
- });
9064
- status.dirty();
9065
- }
9066
- }
9067
- if (def.maxLength !== null) {
9068
- if (ctx.data.length > def.maxLength.value) {
9069
- addIssueToContext(ctx, {
9070
- code: ZodIssueCode.too_big,
9071
- maximum: def.maxLength.value,
9072
- type: "array",
9073
- inclusive: true,
9074
- exact: false,
9075
- message: def.maxLength.message
9076
- });
9077
- status.dirty();
9078
- }
9079
- }
9080
- if (ctx.common.async) {
9081
- return Promise.all([...ctx.data].map((item, i) => {
9082
- return def.type._parseAsync(new ParseInputLazyPath(ctx, item, ctx.path, i));
9083
- })).then((result2) => {
9084
- return ParseStatus.mergeArray(status, result2);
9085
- });
9086
- }
9087
- const result = [...ctx.data].map((item, i) => {
9088
- return def.type._parseSync(new ParseInputLazyPath(ctx, item, ctx.path, i));
9089
- });
9090
- return ParseStatus.mergeArray(status, result);
9091
- }
9092
- get element() {
9093
- return this._def.type;
9094
- }
9095
- min(minLength, message) {
9096
- return new _ZodArray({
9097
- ...this._def,
9098
- minLength: { value: minLength, message: errorUtil.toString(message) }
9099
- });
9100
- }
9101
- max(maxLength, message) {
9102
- return new _ZodArray({
9103
- ...this._def,
9104
- maxLength: { value: maxLength, message: errorUtil.toString(message) }
9105
- });
9106
- }
9107
- length(len, message) {
9108
- return new _ZodArray({
9109
- ...this._def,
9110
- exactLength: { value: len, message: errorUtil.toString(message) }
9111
- });
9112
- }
9113
- nonempty(message) {
9114
- return this.min(1, message);
9115
- }
9116
- };
9117
- ZodArray.create = (schema, params) => {
9118
- return new ZodArray({
9119
- type: schema,
9120
- minLength: null,
9121
- maxLength: null,
9122
- exactLength: null,
9123
- typeName: ZodFirstPartyTypeKind.ZodArray,
9124
- ...processCreateParams(params)
9125
- });
9126
- };
9127
- function deepPartialify(schema) {
9128
- if (schema instanceof ZodObject) {
9129
- const newShape = {};
9130
- for (const key in schema.shape) {
9131
- const fieldSchema = schema.shape[key];
9132
- newShape[key] = ZodOptional.create(deepPartialify(fieldSchema));
9133
- }
9134
- return new ZodObject({
9135
- ...schema._def,
9136
- shape: () => newShape
9137
- });
9138
- } else if (schema instanceof ZodArray) {
9139
- return new ZodArray({
9140
- ...schema._def,
9141
- type: deepPartialify(schema.element)
9142
- });
9143
- } else if (schema instanceof ZodOptional) {
9144
- return ZodOptional.create(deepPartialify(schema.unwrap()));
9145
- } else if (schema instanceof ZodNullable) {
9146
- return ZodNullable.create(deepPartialify(schema.unwrap()));
9147
- } else if (schema instanceof ZodTuple) {
9148
- return ZodTuple.create(schema.items.map((item) => deepPartialify(item)));
9149
- } else {
9150
- return schema;
9151
- }
9152
- }
9153
- var ZodObject = class _ZodObject extends ZodType {
9154
- constructor() {
9155
- super(...arguments);
9156
- this._cached = null;
9157
- this.nonstrict = this.passthrough;
9158
- this.augment = this.extend;
9159
- }
9160
- _getCached() {
9161
- if (this._cached !== null)
9162
- return this._cached;
9163
- const shape = this._def.shape();
9164
- const keys = util.objectKeys(shape);
9165
- this._cached = { shape, keys };
9166
- return this._cached;
9167
- }
9168
- _parse(input) {
9169
- const parsedType2 = this._getType(input);
9170
- if (parsedType2 !== ZodParsedType.object) {
9171
- const ctx2 = this._getOrReturnCtx(input);
9172
- addIssueToContext(ctx2, {
9173
- code: ZodIssueCode.invalid_type,
9174
- expected: ZodParsedType.object,
9175
- received: ctx2.parsedType
9176
- });
9177
- return INVALID;
9178
- }
9179
- const { status, ctx } = this._processInputParams(input);
9180
- const { shape, keys: shapeKeys } = this._getCached();
9181
- const extraKeys = [];
9182
- if (!(this._def.catchall instanceof ZodNever && this._def.unknownKeys === "strip")) {
9183
- for (const key in ctx.data) {
9184
- if (!shapeKeys.includes(key)) {
9185
- extraKeys.push(key);
9186
- }
9187
- }
9188
- }
9189
- const pairs = [];
9190
- for (const key of shapeKeys) {
9191
- const keyValidator = shape[key];
9192
- const value = ctx.data[key];
9193
- pairs.push({
9194
- key: { status: "valid", value: key },
9195
- value: keyValidator._parse(new ParseInputLazyPath(ctx, value, ctx.path, key)),
9196
- alwaysSet: key in ctx.data
9197
- });
9198
- }
9199
- if (this._def.catchall instanceof ZodNever) {
9200
- const unknownKeys = this._def.unknownKeys;
9201
- if (unknownKeys === "passthrough") {
9202
- for (const key of extraKeys) {
9203
- pairs.push({
9204
- key: { status: "valid", value: key },
9205
- value: { status: "valid", value: ctx.data[key] }
9206
- });
9207
- }
9208
- } else if (unknownKeys === "strict") {
9209
- if (extraKeys.length > 0) {
9210
- addIssueToContext(ctx, {
9211
- code: ZodIssueCode.unrecognized_keys,
9212
- keys: extraKeys
9213
- });
9214
- status.dirty();
9215
- }
9216
- } else if (unknownKeys === "strip") {
9217
- } else {
9218
- throw new Error(`Internal ZodObject error: invalid unknownKeys value.`);
9219
- }
9220
- } else {
9221
- const catchall = this._def.catchall;
9222
- for (const key of extraKeys) {
9223
- const value = ctx.data[key];
9224
- pairs.push({
9225
- key: { status: "valid", value: key },
9226
- value: catchall._parse(
9227
- new ParseInputLazyPath(ctx, value, ctx.path, key)
9228
- //, ctx.child(key), value, getParsedType(value)
9229
- ),
9230
- alwaysSet: key in ctx.data
9231
- });
9232
- }
9233
- }
9234
- if (ctx.common.async) {
9235
- return Promise.resolve().then(async () => {
9236
- const syncPairs = [];
9237
- for (const pair of pairs) {
9238
- const key = await pair.key;
9239
- const value = await pair.value;
9240
- syncPairs.push({
9241
- key,
9242
- value,
9243
- alwaysSet: pair.alwaysSet
9244
- });
9245
- }
9246
- return syncPairs;
9247
- }).then((syncPairs) => {
9248
- return ParseStatus.mergeObjectSync(status, syncPairs);
9249
- });
9250
- } else {
9251
- return ParseStatus.mergeObjectSync(status, pairs);
9252
- }
9253
- }
9254
- get shape() {
9255
- return this._def.shape();
9256
- }
9257
- strict(message) {
9258
- errorUtil.errToObj;
9259
- return new _ZodObject({
9260
- ...this._def,
9261
- unknownKeys: "strict",
9262
- ...message !== void 0 ? {
9263
- errorMap: (issue2, ctx) => {
9264
- const defaultError = this._def.errorMap?.(issue2, ctx).message ?? ctx.defaultError;
9265
- if (issue2.code === "unrecognized_keys")
9266
- return {
9267
- message: errorUtil.errToObj(message).message ?? defaultError
9268
- };
9269
- return {
9270
- message: defaultError
9271
- };
9272
- }
9273
- } : {}
9274
- });
9275
- }
9276
- strip() {
9277
- return new _ZodObject({
9278
- ...this._def,
9279
- unknownKeys: "strip"
9280
- });
9281
- }
9282
- passthrough() {
9283
- return new _ZodObject({
9284
- ...this._def,
9285
- unknownKeys: "passthrough"
9286
- });
9287
- }
9288
- // const AugmentFactory =
9289
- // <Def extends ZodObjectDef>(def: Def) =>
9290
- // <Augmentation extends ZodRawShape>(
9291
- // augmentation: Augmentation
9292
- // ): ZodObject<
9293
- // extendShape<ReturnType<Def["shape"]>, Augmentation>,
9294
- // Def["unknownKeys"],
9295
- // Def["catchall"]
9296
- // > => {
9297
- // return new ZodObject({
9298
- // ...def,
9299
- // shape: () => ({
9300
- // ...def.shape(),
9301
- // ...augmentation,
9302
- // }),
9303
- // }) as any;
9304
- // };
9305
- extend(augmentation) {
9306
- return new _ZodObject({
9307
- ...this._def,
9308
- shape: () => ({
9309
- ...this._def.shape(),
9310
- ...augmentation
9311
- })
9312
- });
9313
- }
9314
- /**
9315
- * Prior to zod@1.0.12 there was a bug in the
9316
- * inferred type of merged objects. Please
9317
- * upgrade if you are experiencing issues.
9318
- */
9319
- merge(merging) {
9320
- const merged = new _ZodObject({
9321
- unknownKeys: merging._def.unknownKeys,
9322
- catchall: merging._def.catchall,
9323
- shape: () => ({
9324
- ...this._def.shape(),
9325
- ...merging._def.shape()
9326
- }),
9327
- typeName: ZodFirstPartyTypeKind.ZodObject
9328
- });
9329
- return merged;
9330
- }
9331
- // merge<
9332
- // Incoming extends AnyZodObject,
9333
- // Augmentation extends Incoming["shape"],
9334
- // NewOutput extends {
9335
- // [k in keyof Augmentation | keyof Output]: k extends keyof Augmentation
9336
- // ? Augmentation[k]["_output"]
9337
- // : k extends keyof Output
9338
- // ? Output[k]
9339
- // : never;
9340
- // },
9341
- // NewInput extends {
9342
- // [k in keyof Augmentation | keyof Input]: k extends keyof Augmentation
9343
- // ? Augmentation[k]["_input"]
9344
- // : k extends keyof Input
9345
- // ? Input[k]
9346
- // : never;
9347
- // }
9348
- // >(
9349
- // merging: Incoming
9350
- // ): ZodObject<
9351
- // extendShape<T, ReturnType<Incoming["_def"]["shape"]>>,
9352
- // Incoming["_def"]["unknownKeys"],
9353
- // Incoming["_def"]["catchall"],
9354
- // NewOutput,
9355
- // NewInput
9356
- // > {
9357
- // const merged: any = new ZodObject({
9358
- // unknownKeys: merging._def.unknownKeys,
9359
- // catchall: merging._def.catchall,
9360
- // shape: () =>
9361
- // objectUtil.mergeShapes(this._def.shape(), merging._def.shape()),
9362
- // typeName: ZodFirstPartyTypeKind.ZodObject,
9363
- // }) as any;
9364
- // return merged;
9365
- // }
9366
- setKey(key, schema) {
9367
- return this.augment({ [key]: schema });
9368
- }
9369
- // merge<Incoming extends AnyZodObject>(
9370
- // merging: Incoming
9371
- // ): //ZodObject<T & Incoming["_shape"], UnknownKeys, Catchall> = (merging) => {
9372
- // ZodObject<
9373
- // extendShape<T, ReturnType<Incoming["_def"]["shape"]>>,
9374
- // Incoming["_def"]["unknownKeys"],
9375
- // Incoming["_def"]["catchall"]
9376
- // > {
9377
- // // const mergedShape = objectUtil.mergeShapes(
9378
- // // this._def.shape(),
9379
- // // merging._def.shape()
9380
- // // );
9381
- // const merged: any = new ZodObject({
9382
- // unknownKeys: merging._def.unknownKeys,
9383
- // catchall: merging._def.catchall,
9384
- // shape: () =>
9385
- // objectUtil.mergeShapes(this._def.shape(), merging._def.shape()),
9386
- // typeName: ZodFirstPartyTypeKind.ZodObject,
9387
- // }) as any;
9388
- // return merged;
9389
- // }
9390
- catchall(index) {
9391
- return new _ZodObject({
9392
- ...this._def,
9393
- catchall: index
9394
- });
9395
- }
9396
- pick(mask) {
9397
- const shape = {};
9398
- for (const key of util.objectKeys(mask)) {
9399
- if (mask[key] && this.shape[key]) {
9400
- shape[key] = this.shape[key];
9401
- }
9402
- }
9403
- return new _ZodObject({
9404
- ...this._def,
9405
- shape: () => shape
9406
- });
9407
- }
9408
- omit(mask) {
9409
- const shape = {};
9410
- for (const key of util.objectKeys(this.shape)) {
9411
- if (!mask[key]) {
9412
- shape[key] = this.shape[key];
9413
- }
9414
- }
9415
- return new _ZodObject({
9416
- ...this._def,
9417
- shape: () => shape
9418
- });
9419
- }
9420
- /**
9421
- * @deprecated
9422
- */
9423
- deepPartial() {
9424
- return deepPartialify(this);
9425
- }
9426
- partial(mask) {
9427
- const newShape = {};
9428
- for (const key of util.objectKeys(this.shape)) {
9429
- const fieldSchema = this.shape[key];
9430
- if (mask && !mask[key]) {
9431
- newShape[key] = fieldSchema;
9432
- } else {
9433
- newShape[key] = fieldSchema.optional();
9434
- }
9435
- }
9436
- return new _ZodObject({
9437
- ...this._def,
9438
- shape: () => newShape
9439
- });
9440
- }
9441
- required(mask) {
9442
- const newShape = {};
9443
- for (const key of util.objectKeys(this.shape)) {
9444
- if (mask && !mask[key]) {
9445
- newShape[key] = this.shape[key];
9446
- } else {
9447
- const fieldSchema = this.shape[key];
9448
- let newField = fieldSchema;
9449
- while (newField instanceof ZodOptional) {
9450
- newField = newField._def.innerType;
9451
- }
9452
- newShape[key] = newField;
9453
- }
9454
- }
9455
- return new _ZodObject({
9456
- ...this._def,
9457
- shape: () => newShape
9458
- });
9459
- }
9460
- keyof() {
9461
- return createZodEnum(util.objectKeys(this.shape));
9462
- }
9463
- };
9464
- ZodObject.create = (shape, params) => {
9465
- return new ZodObject({
9466
- shape: () => shape,
9467
- unknownKeys: "strip",
9468
- catchall: ZodNever.create(),
9469
- typeName: ZodFirstPartyTypeKind.ZodObject,
9470
- ...processCreateParams(params)
9471
- });
9472
- };
9473
- ZodObject.strictCreate = (shape, params) => {
9474
- return new ZodObject({
9475
- shape: () => shape,
9476
- unknownKeys: "strict",
9477
- catchall: ZodNever.create(),
9478
- typeName: ZodFirstPartyTypeKind.ZodObject,
9479
- ...processCreateParams(params)
9480
- });
9481
- };
9482
- ZodObject.lazycreate = (shape, params) => {
9483
- return new ZodObject({
9484
- shape,
9485
- unknownKeys: "strip",
9486
- catchall: ZodNever.create(),
9487
- typeName: ZodFirstPartyTypeKind.ZodObject,
9488
- ...processCreateParams(params)
9489
- });
9490
- };
9491
- var ZodUnion = class extends ZodType {
9492
- _parse(input) {
9493
- const { ctx } = this._processInputParams(input);
9494
- const options = this._def.options;
9495
- function handleResults(results) {
9496
- for (const result of results) {
9497
- if (result.result.status === "valid") {
9498
- return result.result;
9499
- }
9500
- }
9501
- for (const result of results) {
9502
- if (result.result.status === "dirty") {
9503
- ctx.common.issues.push(...result.ctx.common.issues);
9504
- return result.result;
9505
- }
9506
- }
9507
- const unionErrors = results.map((result) => new ZodError(result.ctx.common.issues));
9508
- addIssueToContext(ctx, {
9509
- code: ZodIssueCode.invalid_union,
9510
- unionErrors
9511
- });
9512
- return INVALID;
9513
- }
9514
- if (ctx.common.async) {
9515
- return Promise.all(options.map(async (option) => {
9516
- const childCtx = {
9517
- ...ctx,
9518
- common: {
9519
- ...ctx.common,
9520
- issues: []
9521
- },
9522
- parent: null
9523
- };
9524
- return {
9525
- result: await option._parseAsync({
9526
- data: ctx.data,
9527
- path: ctx.path,
9528
- parent: childCtx
9529
- }),
9530
- ctx: childCtx
9531
- };
9532
- })).then(handleResults);
9533
- } else {
9534
- let dirty = void 0;
9535
- const issues = [];
9536
- for (const option of options) {
9537
- const childCtx = {
9538
- ...ctx,
9539
- common: {
9540
- ...ctx.common,
9541
- issues: []
9542
- },
9543
- parent: null
9544
- };
9545
- const result = option._parseSync({
9546
- data: ctx.data,
9547
- path: ctx.path,
9548
- parent: childCtx
9549
- });
9550
- if (result.status === "valid") {
9551
- return result;
9552
- } else if (result.status === "dirty" && !dirty) {
9553
- dirty = { result, ctx: childCtx };
9554
- }
9555
- if (childCtx.common.issues.length) {
9556
- issues.push(childCtx.common.issues);
9557
- }
9558
- }
9559
- if (dirty) {
9560
- ctx.common.issues.push(...dirty.ctx.common.issues);
9561
- return dirty.result;
9562
- }
9563
- const unionErrors = issues.map((issues2) => new ZodError(issues2));
9564
- addIssueToContext(ctx, {
9565
- code: ZodIssueCode.invalid_union,
9566
- unionErrors
9567
- });
9568
- return INVALID;
9569
- }
9570
- }
9571
- get options() {
9572
- return this._def.options;
9573
- }
9574
- };
9575
- ZodUnion.create = (types, params) => {
9576
- return new ZodUnion({
9577
- options: types,
9578
- typeName: ZodFirstPartyTypeKind.ZodUnion,
9579
- ...processCreateParams(params)
9580
- });
9581
- };
9582
- var getDiscriminator = (type) => {
9583
- if (type instanceof ZodLazy) {
9584
- return getDiscriminator(type.schema);
9585
- } else if (type instanceof ZodEffects) {
9586
- return getDiscriminator(type.innerType());
9587
- } else if (type instanceof ZodLiteral) {
9588
- return [type.value];
9589
- } else if (type instanceof ZodEnum) {
9590
- return type.options;
9591
- } else if (type instanceof ZodNativeEnum) {
9592
- return util.objectValues(type.enum);
9593
- } else if (type instanceof ZodDefault) {
9594
- return getDiscriminator(type._def.innerType);
9595
- } else if (type instanceof ZodUndefined) {
9596
- return [void 0];
9597
- } else if (type instanceof ZodNull) {
9598
- return [null];
9599
- } else if (type instanceof ZodOptional) {
9600
- return [void 0, ...getDiscriminator(type.unwrap())];
9601
- } else if (type instanceof ZodNullable) {
9602
- return [null, ...getDiscriminator(type.unwrap())];
9603
- } else if (type instanceof ZodBranded) {
9604
- return getDiscriminator(type.unwrap());
9605
- } else if (type instanceof ZodReadonly) {
9606
- return getDiscriminator(type.unwrap());
9607
- } else if (type instanceof ZodCatch) {
9608
- return getDiscriminator(type._def.innerType);
9609
- } else {
9610
- return [];
9611
- }
9612
- };
9613
- var ZodDiscriminatedUnion = class _ZodDiscriminatedUnion extends ZodType {
9614
- _parse(input) {
9615
- const { ctx } = this._processInputParams(input);
9616
- if (ctx.parsedType !== ZodParsedType.object) {
9617
- addIssueToContext(ctx, {
9618
- code: ZodIssueCode.invalid_type,
9619
- expected: ZodParsedType.object,
9620
- received: ctx.parsedType
9621
- });
9622
- return INVALID;
9623
- }
9624
- const discriminator = this.discriminator;
9625
- const discriminatorValue = ctx.data[discriminator];
9626
- const option = this.optionsMap.get(discriminatorValue);
9627
- if (!option) {
9628
- addIssueToContext(ctx, {
9629
- code: ZodIssueCode.invalid_union_discriminator,
9630
- options: Array.from(this.optionsMap.keys()),
9631
- path: [discriminator]
9632
- });
9633
- return INVALID;
9634
- }
9635
- if (ctx.common.async) {
9636
- return option._parseAsync({
9637
- data: ctx.data,
9638
- path: ctx.path,
9639
- parent: ctx
9640
- });
9641
- } else {
9642
- return option._parseSync({
9643
- data: ctx.data,
9644
- path: ctx.path,
9645
- parent: ctx
9646
- });
9647
- }
9648
- }
9649
- get discriminator() {
9650
- return this._def.discriminator;
9651
- }
9652
- get options() {
9653
- return this._def.options;
9654
- }
9655
- get optionsMap() {
9656
- return this._def.optionsMap;
9657
- }
9658
- /**
9659
- * The constructor of the discriminated union schema. Its behaviour is very similar to that of the normal z.union() constructor.
9660
- * However, it only allows a union of objects, all of which need to share a discriminator property. This property must
9661
- * have a different value for each object in the union.
9662
- * @param discriminator the name of the discriminator property
9663
- * @param types an array of object schemas
9664
- * @param params
9665
- */
9666
- static create(discriminator, options, params) {
9667
- const optionsMap = /* @__PURE__ */ new Map();
9668
- for (const type of options) {
9669
- const discriminatorValues = getDiscriminator(type.shape[discriminator]);
9670
- if (!discriminatorValues.length) {
9671
- throw new Error(`A discriminator value for key \`${discriminator}\` could not be extracted from all schema options`);
9672
- }
9673
- for (const value of discriminatorValues) {
9674
- if (optionsMap.has(value)) {
9675
- throw new Error(`Discriminator property ${String(discriminator)} has duplicate value ${String(value)}`);
9676
- }
9677
- optionsMap.set(value, type);
9678
- }
9679
- }
9680
- return new _ZodDiscriminatedUnion({
9681
- typeName: ZodFirstPartyTypeKind.ZodDiscriminatedUnion,
9682
- discriminator,
9683
- options,
9684
- optionsMap,
9685
- ...processCreateParams(params)
9686
- });
9687
- }
9688
- };
9689
- function mergeValues(a, b) {
9690
- const aType = getParsedType(a);
9691
- const bType = getParsedType(b);
9692
- if (a === b) {
9693
- return { valid: true, data: a };
9694
- } else if (aType === ZodParsedType.object && bType === ZodParsedType.object) {
9695
- const bKeys = util.objectKeys(b);
9696
- const sharedKeys = util.objectKeys(a).filter((key) => bKeys.indexOf(key) !== -1);
9697
- const newObj = { ...a, ...b };
9698
- for (const key of sharedKeys) {
9699
- const sharedValue = mergeValues(a[key], b[key]);
9700
- if (!sharedValue.valid) {
9701
- return { valid: false };
9702
- }
9703
- newObj[key] = sharedValue.data;
9704
- }
9705
- return { valid: true, data: newObj };
9706
- } else if (aType === ZodParsedType.array && bType === ZodParsedType.array) {
9707
- if (a.length !== b.length) {
9708
- return { valid: false };
9709
- }
9710
- const newArray = [];
9711
- for (let index = 0; index < a.length; index++) {
9712
- const itemA = a[index];
9713
- const itemB = b[index];
9714
- const sharedValue = mergeValues(itemA, itemB);
9715
- if (!sharedValue.valid) {
9716
- return { valid: false };
9717
- }
9718
- newArray.push(sharedValue.data);
9719
- }
9720
- return { valid: true, data: newArray };
9721
- } else if (aType === ZodParsedType.date && bType === ZodParsedType.date && +a === +b) {
9722
- return { valid: true, data: a };
9723
- } else {
9724
- return { valid: false };
9725
- }
9726
- }
9727
- var ZodIntersection = class extends ZodType {
9728
- _parse(input) {
9729
- const { status, ctx } = this._processInputParams(input);
9730
- const handleParsed = (parsedLeft, parsedRight) => {
9731
- if (isAborted(parsedLeft) || isAborted(parsedRight)) {
9732
- return INVALID;
9733
- }
9734
- const merged = mergeValues(parsedLeft.value, parsedRight.value);
9735
- if (!merged.valid) {
9736
- addIssueToContext(ctx, {
9737
- code: ZodIssueCode.invalid_intersection_types
9738
- });
9739
- return INVALID;
9740
- }
9741
- if (isDirty(parsedLeft) || isDirty(parsedRight)) {
9742
- status.dirty();
9743
- }
9744
- return { status: status.value, value: merged.data };
9745
- };
9746
- if (ctx.common.async) {
9747
- return Promise.all([
9748
- this._def.left._parseAsync({
9749
- data: ctx.data,
9750
- path: ctx.path,
9751
- parent: ctx
9752
- }),
9753
- this._def.right._parseAsync({
9754
- data: ctx.data,
9755
- path: ctx.path,
9756
- parent: ctx
9757
- })
9758
- ]).then(([left, right]) => handleParsed(left, right));
9759
- } else {
9760
- return handleParsed(this._def.left._parseSync({
9761
- data: ctx.data,
9762
- path: ctx.path,
9763
- parent: ctx
9764
- }), this._def.right._parseSync({
9765
- data: ctx.data,
9766
- path: ctx.path,
9767
- parent: ctx
9768
- }));
9769
- }
9770
- }
9771
- };
9772
- ZodIntersection.create = (left, right, params) => {
9773
- return new ZodIntersection({
9774
- left,
9775
- right,
9776
- typeName: ZodFirstPartyTypeKind.ZodIntersection,
9777
- ...processCreateParams(params)
9778
- });
9779
- };
9780
- var ZodTuple = class _ZodTuple extends ZodType {
9781
- _parse(input) {
9782
- const { status, ctx } = this._processInputParams(input);
9783
- if (ctx.parsedType !== ZodParsedType.array) {
9784
- addIssueToContext(ctx, {
9785
- code: ZodIssueCode.invalid_type,
9786
- expected: ZodParsedType.array,
9787
- received: ctx.parsedType
9788
- });
9789
- return INVALID;
9790
- }
9791
- if (ctx.data.length < this._def.items.length) {
9792
- addIssueToContext(ctx, {
9793
- code: ZodIssueCode.too_small,
9794
- minimum: this._def.items.length,
9795
- inclusive: true,
9796
- exact: false,
9797
- type: "array"
9798
- });
9799
- return INVALID;
9800
- }
9801
- const rest = this._def.rest;
9802
- if (!rest && ctx.data.length > this._def.items.length) {
9803
- addIssueToContext(ctx, {
9804
- code: ZodIssueCode.too_big,
9805
- maximum: this._def.items.length,
9806
- inclusive: true,
9807
- exact: false,
9808
- type: "array"
9809
- });
9810
- status.dirty();
9811
- }
9812
- const items = [...ctx.data].map((item, itemIndex) => {
9813
- const schema = this._def.items[itemIndex] || this._def.rest;
9814
- if (!schema)
9815
- return null;
9816
- return schema._parse(new ParseInputLazyPath(ctx, item, ctx.path, itemIndex));
9817
- }).filter((x) => !!x);
9818
- if (ctx.common.async) {
9819
- return Promise.all(items).then((results) => {
9820
- return ParseStatus.mergeArray(status, results);
9821
- });
9822
- } else {
9823
- return ParseStatus.mergeArray(status, items);
9824
- }
9825
- }
9826
- get items() {
9827
- return this._def.items;
9828
- }
9829
- rest(rest) {
9830
- return new _ZodTuple({
9831
- ...this._def,
9832
- rest
9833
- });
9834
- }
9835
- };
9836
- ZodTuple.create = (schemas, params) => {
9837
- if (!Array.isArray(schemas)) {
9838
- throw new Error("You must pass an array of schemas to z.tuple([ ... ])");
9839
- }
9840
- return new ZodTuple({
9841
- items: schemas,
9842
- typeName: ZodFirstPartyTypeKind.ZodTuple,
9843
- rest: null,
9844
- ...processCreateParams(params)
9845
- });
9846
- };
9847
- var ZodRecord = class _ZodRecord extends ZodType {
9848
- get keySchema() {
9849
- return this._def.keyType;
9850
- }
9851
- get valueSchema() {
9852
- return this._def.valueType;
9853
- }
9854
- _parse(input) {
9855
- const { status, ctx } = this._processInputParams(input);
9856
- if (ctx.parsedType !== ZodParsedType.object) {
9857
- addIssueToContext(ctx, {
9858
- code: ZodIssueCode.invalid_type,
9859
- expected: ZodParsedType.object,
9860
- received: ctx.parsedType
9861
- });
9862
- return INVALID;
9863
- }
9864
- const pairs = [];
9865
- const keyType = this._def.keyType;
9866
- const valueType = this._def.valueType;
9867
- for (const key in ctx.data) {
9868
- pairs.push({
9869
- key: keyType._parse(new ParseInputLazyPath(ctx, key, ctx.path, key)),
9870
- value: valueType._parse(new ParseInputLazyPath(ctx, ctx.data[key], ctx.path, key)),
9871
- alwaysSet: key in ctx.data
9872
- });
9873
- }
9874
- if (ctx.common.async) {
9875
- return ParseStatus.mergeObjectAsync(status, pairs);
9876
- } else {
9877
- return ParseStatus.mergeObjectSync(status, pairs);
9878
- }
9879
- }
9880
- get element() {
9881
- return this._def.valueType;
9882
- }
9883
- static create(first, second, third) {
9884
- if (second instanceof ZodType) {
9885
- return new _ZodRecord({
9886
- keyType: first,
9887
- valueType: second,
9888
- typeName: ZodFirstPartyTypeKind.ZodRecord,
9889
- ...processCreateParams(third)
9890
- });
9891
- }
9892
- return new _ZodRecord({
9893
- keyType: ZodString.create(),
9894
- valueType: first,
9895
- typeName: ZodFirstPartyTypeKind.ZodRecord,
9896
- ...processCreateParams(second)
9897
- });
9898
- }
9899
- };
9900
- var ZodMap = class extends ZodType {
9901
- get keySchema() {
9902
- return this._def.keyType;
9903
- }
9904
- get valueSchema() {
9905
- return this._def.valueType;
9906
- }
9907
- _parse(input) {
9908
- const { status, ctx } = this._processInputParams(input);
9909
- if (ctx.parsedType !== ZodParsedType.map) {
9910
- addIssueToContext(ctx, {
9911
- code: ZodIssueCode.invalid_type,
9912
- expected: ZodParsedType.map,
9913
- received: ctx.parsedType
9914
- });
9915
- return INVALID;
9916
- }
9917
- const keyType = this._def.keyType;
9918
- const valueType = this._def.valueType;
9919
- const pairs = [...ctx.data.entries()].map(([key, value], index) => {
9920
- return {
9921
- key: keyType._parse(new ParseInputLazyPath(ctx, key, ctx.path, [index, "key"])),
9922
- value: valueType._parse(new ParseInputLazyPath(ctx, value, ctx.path, [index, "value"]))
9923
- };
9924
- });
9925
- if (ctx.common.async) {
9926
- const finalMap = /* @__PURE__ */ new Map();
9927
- return Promise.resolve().then(async () => {
9928
- for (const pair of pairs) {
9929
- const key = await pair.key;
9930
- const value = await pair.value;
9931
- if (key.status === "aborted" || value.status === "aborted") {
9932
- return INVALID;
9933
- }
9934
- if (key.status === "dirty" || value.status === "dirty") {
9935
- status.dirty();
9936
- }
9937
- finalMap.set(key.value, value.value);
9938
- }
9939
- return { status: status.value, value: finalMap };
9940
- });
9941
- } else {
9942
- const finalMap = /* @__PURE__ */ new Map();
9943
- for (const pair of pairs) {
9944
- const key = pair.key;
9945
- const value = pair.value;
9946
- if (key.status === "aborted" || value.status === "aborted") {
9947
- return INVALID;
9948
- }
9949
- if (key.status === "dirty" || value.status === "dirty") {
9950
- status.dirty();
9951
- }
9952
- finalMap.set(key.value, value.value);
9953
- }
9954
- return { status: status.value, value: finalMap };
9955
- }
9956
- }
9957
- };
9958
- ZodMap.create = (keyType, valueType, params) => {
9959
- return new ZodMap({
9960
- valueType,
9961
- keyType,
9962
- typeName: ZodFirstPartyTypeKind.ZodMap,
9963
- ...processCreateParams(params)
9964
- });
9965
- };
9966
- var ZodSet = class _ZodSet extends ZodType {
9967
- _parse(input) {
9968
- const { status, ctx } = this._processInputParams(input);
9969
- if (ctx.parsedType !== ZodParsedType.set) {
9970
- addIssueToContext(ctx, {
9971
- code: ZodIssueCode.invalid_type,
9972
- expected: ZodParsedType.set,
9973
- received: ctx.parsedType
9974
- });
9975
- return INVALID;
9976
- }
9977
- const def = this._def;
9978
- if (def.minSize !== null) {
9979
- if (ctx.data.size < def.minSize.value) {
9980
- addIssueToContext(ctx, {
9981
- code: ZodIssueCode.too_small,
9982
- minimum: def.minSize.value,
9983
- type: "set",
9984
- inclusive: true,
9985
- exact: false,
9986
- message: def.minSize.message
9987
- });
9988
- status.dirty();
9989
- }
9990
- }
9991
- if (def.maxSize !== null) {
9992
- if (ctx.data.size > def.maxSize.value) {
9993
- addIssueToContext(ctx, {
9994
- code: ZodIssueCode.too_big,
9995
- maximum: def.maxSize.value,
9996
- type: "set",
9997
- inclusive: true,
9998
- exact: false,
9999
- message: def.maxSize.message
10000
- });
10001
- status.dirty();
10002
- }
10003
- }
10004
- const valueType = this._def.valueType;
10005
- function finalizeSet(elements2) {
10006
- const parsedSet = /* @__PURE__ */ new Set();
10007
- for (const element of elements2) {
10008
- if (element.status === "aborted")
10009
- return INVALID;
10010
- if (element.status === "dirty")
10011
- status.dirty();
10012
- parsedSet.add(element.value);
10013
- }
10014
- return { status: status.value, value: parsedSet };
10015
- }
10016
- const elements = [...ctx.data.values()].map((item, i) => valueType._parse(new ParseInputLazyPath(ctx, item, ctx.path, i)));
10017
- if (ctx.common.async) {
10018
- return Promise.all(elements).then((elements2) => finalizeSet(elements2));
10019
- } else {
10020
- return finalizeSet(elements);
10021
- }
10022
- }
10023
- min(minSize, message) {
10024
- return new _ZodSet({
10025
- ...this._def,
10026
- minSize: { value: minSize, message: errorUtil.toString(message) }
10027
- });
10028
- }
10029
- max(maxSize, message) {
10030
- return new _ZodSet({
10031
- ...this._def,
10032
- maxSize: { value: maxSize, message: errorUtil.toString(message) }
10033
- });
10034
- }
10035
- size(size, message) {
10036
- return this.min(size, message).max(size, message);
10037
- }
10038
- nonempty(message) {
10039
- return this.min(1, message);
10040
- }
10041
- };
10042
- ZodSet.create = (valueType, params) => {
10043
- return new ZodSet({
10044
- valueType,
10045
- minSize: null,
10046
- maxSize: null,
10047
- typeName: ZodFirstPartyTypeKind.ZodSet,
10048
- ...processCreateParams(params)
10049
- });
10050
- };
10051
- var ZodFunction = class _ZodFunction extends ZodType {
10052
- constructor() {
10053
- super(...arguments);
10054
- this.validate = this.implement;
10055
- }
10056
- _parse(input) {
10057
- const { ctx } = this._processInputParams(input);
10058
- if (ctx.parsedType !== ZodParsedType.function) {
10059
- addIssueToContext(ctx, {
10060
- code: ZodIssueCode.invalid_type,
10061
- expected: ZodParsedType.function,
10062
- received: ctx.parsedType
10063
- });
10064
- return INVALID;
10065
- }
10066
- function makeArgsIssue(args, error2) {
10067
- return makeIssue({
10068
- data: args,
10069
- path: ctx.path,
10070
- errorMaps: [ctx.common.contextualErrorMap, ctx.schemaErrorMap, getErrorMap(), en_default].filter((x) => !!x),
10071
- issueData: {
10072
- code: ZodIssueCode.invalid_arguments,
10073
- argumentsError: error2
10074
- }
10075
- });
10076
- }
10077
- function makeReturnsIssue(returns, error2) {
10078
- return makeIssue({
10079
- data: returns,
10080
- path: ctx.path,
10081
- errorMaps: [ctx.common.contextualErrorMap, ctx.schemaErrorMap, getErrorMap(), en_default].filter((x) => !!x),
10082
- issueData: {
10083
- code: ZodIssueCode.invalid_return_type,
10084
- returnTypeError: error2
10085
- }
10086
- });
10087
- }
10088
- const params = { errorMap: ctx.common.contextualErrorMap };
10089
- const fn = ctx.data;
10090
- if (this._def.returns instanceof ZodPromise) {
10091
- const me = this;
10092
- return OK(async function(...args) {
10093
- const error2 = new ZodError([]);
10094
- const parsedArgs = await me._def.args.parseAsync(args, params).catch((e) => {
10095
- error2.addIssue(makeArgsIssue(args, e));
10096
- throw error2;
10097
- });
10098
- const result = await Reflect.apply(fn, this, parsedArgs);
10099
- const parsedReturns = await me._def.returns._def.type.parseAsync(result, params).catch((e) => {
10100
- error2.addIssue(makeReturnsIssue(result, e));
10101
- throw error2;
10102
- });
10103
- return parsedReturns;
10104
- });
10105
- } else {
10106
- const me = this;
10107
- return OK(function(...args) {
10108
- const parsedArgs = me._def.args.safeParse(args, params);
10109
- if (!parsedArgs.success) {
10110
- throw new ZodError([makeArgsIssue(args, parsedArgs.error)]);
10111
- }
10112
- const result = Reflect.apply(fn, this, parsedArgs.data);
10113
- const parsedReturns = me._def.returns.safeParse(result, params);
10114
- if (!parsedReturns.success) {
10115
- throw new ZodError([makeReturnsIssue(result, parsedReturns.error)]);
10116
- }
10117
- return parsedReturns.data;
10118
- });
10119
- }
10120
- }
10121
- parameters() {
10122
- return this._def.args;
10123
- }
10124
- returnType() {
10125
- return this._def.returns;
10126
- }
10127
- args(...items) {
10128
- return new _ZodFunction({
10129
- ...this._def,
10130
- args: ZodTuple.create(items).rest(ZodUnknown.create())
10131
- });
10132
- }
10133
- returns(returnType) {
10134
- return new _ZodFunction({
10135
- ...this._def,
10136
- returns: returnType
10137
- });
10138
- }
10139
- implement(func) {
10140
- const validatedFunc = this.parse(func);
10141
- return validatedFunc;
10142
- }
10143
- strictImplement(func) {
10144
- const validatedFunc = this.parse(func);
10145
- return validatedFunc;
10146
- }
10147
- static create(args, returns, params) {
10148
- return new _ZodFunction({
10149
- args: args ? args : ZodTuple.create([]).rest(ZodUnknown.create()),
10150
- returns: returns || ZodUnknown.create(),
10151
- typeName: ZodFirstPartyTypeKind.ZodFunction,
10152
- ...processCreateParams(params)
10153
- });
10154
- }
10155
- };
10156
- var ZodLazy = class extends ZodType {
10157
- get schema() {
10158
- return this._def.getter();
10159
- }
10160
- _parse(input) {
10161
- const { ctx } = this._processInputParams(input);
10162
- const lazySchema = this._def.getter();
10163
- return lazySchema._parse({ data: ctx.data, path: ctx.path, parent: ctx });
10164
- }
10165
- };
10166
- ZodLazy.create = (getter, params) => {
10167
- return new ZodLazy({
10168
- getter,
10169
- typeName: ZodFirstPartyTypeKind.ZodLazy,
10170
- ...processCreateParams(params)
10171
- });
10172
- };
10173
- var ZodLiteral = class extends ZodType {
10174
- _parse(input) {
10175
- if (input.data !== this._def.value) {
10176
- const ctx = this._getOrReturnCtx(input);
10177
- addIssueToContext(ctx, {
10178
- received: ctx.data,
10179
- code: ZodIssueCode.invalid_literal,
10180
- expected: this._def.value
10181
- });
10182
- return INVALID;
10183
- }
10184
- return { status: "valid", value: input.data };
10185
- }
10186
- get value() {
10187
- return this._def.value;
10188
- }
10189
- };
10190
- ZodLiteral.create = (value, params) => {
10191
- return new ZodLiteral({
10192
- value,
10193
- typeName: ZodFirstPartyTypeKind.ZodLiteral,
10194
- ...processCreateParams(params)
10195
- });
10196
- };
10197
- function createZodEnum(values, params) {
10198
- return new ZodEnum({
10199
- values,
10200
- typeName: ZodFirstPartyTypeKind.ZodEnum,
10201
- ...processCreateParams(params)
10202
- });
10203
- }
10204
- var ZodEnum = class _ZodEnum extends ZodType {
10205
- _parse(input) {
10206
- if (typeof input.data !== "string") {
10207
- const ctx = this._getOrReturnCtx(input);
10208
- const expectedValues = this._def.values;
10209
- addIssueToContext(ctx, {
10210
- expected: util.joinValues(expectedValues),
10211
- received: ctx.parsedType,
10212
- code: ZodIssueCode.invalid_type
10213
- });
10214
- return INVALID;
10215
- }
10216
- if (!this._cache) {
10217
- this._cache = new Set(this._def.values);
10218
- }
10219
- if (!this._cache.has(input.data)) {
10220
- const ctx = this._getOrReturnCtx(input);
10221
- const expectedValues = this._def.values;
10222
- addIssueToContext(ctx, {
10223
- received: ctx.data,
10224
- code: ZodIssueCode.invalid_enum_value,
10225
- options: expectedValues
10226
- });
10227
- return INVALID;
10228
- }
10229
- return OK(input.data);
10230
- }
10231
- get options() {
10232
- return this._def.values;
10233
- }
10234
- get enum() {
10235
- const enumValues = {};
10236
- for (const val of this._def.values) {
10237
- enumValues[val] = val;
10238
- }
10239
- return enumValues;
10240
- }
10241
- get Values() {
10242
- const enumValues = {};
10243
- for (const val of this._def.values) {
10244
- enumValues[val] = val;
10245
- }
10246
- return enumValues;
10247
- }
10248
- get Enum() {
10249
- const enumValues = {};
10250
- for (const val of this._def.values) {
10251
- enumValues[val] = val;
10252
- }
10253
- return enumValues;
10254
- }
10255
- extract(values, newDef = this._def) {
10256
- return _ZodEnum.create(values, {
10257
- ...this._def,
10258
- ...newDef
10259
- });
10260
- }
10261
- exclude(values, newDef = this._def) {
10262
- return _ZodEnum.create(this.options.filter((opt) => !values.includes(opt)), {
10263
- ...this._def,
10264
- ...newDef
10265
- });
10266
- }
10267
- };
10268
- ZodEnum.create = createZodEnum;
10269
- var ZodNativeEnum = class extends ZodType {
10270
- _parse(input) {
10271
- const nativeEnumValues = util.getValidEnumValues(this._def.values);
10272
- const ctx = this._getOrReturnCtx(input);
10273
- if (ctx.parsedType !== ZodParsedType.string && ctx.parsedType !== ZodParsedType.number) {
10274
- const expectedValues = util.objectValues(nativeEnumValues);
10275
- addIssueToContext(ctx, {
10276
- expected: util.joinValues(expectedValues),
10277
- received: ctx.parsedType,
10278
- code: ZodIssueCode.invalid_type
10279
- });
10280
- return INVALID;
10281
- }
10282
- if (!this._cache) {
10283
- this._cache = new Set(util.getValidEnumValues(this._def.values));
10284
- }
10285
- if (!this._cache.has(input.data)) {
10286
- const expectedValues = util.objectValues(nativeEnumValues);
10287
- addIssueToContext(ctx, {
10288
- received: ctx.data,
10289
- code: ZodIssueCode.invalid_enum_value,
10290
- options: expectedValues
10291
- });
10292
- return INVALID;
10293
- }
10294
- return OK(input.data);
10295
- }
10296
- get enum() {
10297
- return this._def.values;
10298
- }
10299
- };
10300
- ZodNativeEnum.create = (values, params) => {
10301
- return new ZodNativeEnum({
10302
- values,
10303
- typeName: ZodFirstPartyTypeKind.ZodNativeEnum,
10304
- ...processCreateParams(params)
10305
- });
10306
- };
10307
- var ZodPromise = class extends ZodType {
10308
- unwrap() {
10309
- return this._def.type;
10310
- }
10311
- _parse(input) {
10312
- const { ctx } = this._processInputParams(input);
10313
- if (ctx.parsedType !== ZodParsedType.promise && ctx.common.async === false) {
10314
- addIssueToContext(ctx, {
10315
- code: ZodIssueCode.invalid_type,
10316
- expected: ZodParsedType.promise,
10317
- received: ctx.parsedType
10318
- });
10319
- return INVALID;
10320
- }
10321
- const promisified = ctx.parsedType === ZodParsedType.promise ? ctx.data : Promise.resolve(ctx.data);
10322
- return OK(promisified.then((data) => {
10323
- return this._def.type.parseAsync(data, {
10324
- path: ctx.path,
10325
- errorMap: ctx.common.contextualErrorMap
10326
- });
10327
- }));
10328
- }
10329
- };
10330
- ZodPromise.create = (schema, params) => {
10331
- return new ZodPromise({
10332
- type: schema,
10333
- typeName: ZodFirstPartyTypeKind.ZodPromise,
10334
- ...processCreateParams(params)
10335
- });
10336
- };
10337
- var ZodEffects = class extends ZodType {
10338
- innerType() {
10339
- return this._def.schema;
10340
- }
10341
- sourceType() {
10342
- return this._def.schema._def.typeName === ZodFirstPartyTypeKind.ZodEffects ? this._def.schema.sourceType() : this._def.schema;
10343
- }
10344
- _parse(input) {
10345
- const { status, ctx } = this._processInputParams(input);
10346
- const effect = this._def.effect || null;
10347
- const checkCtx = {
10348
- addIssue: (arg) => {
10349
- addIssueToContext(ctx, arg);
10350
- if (arg.fatal) {
10351
- status.abort();
10352
- } else {
10353
- status.dirty();
10354
- }
10355
- },
10356
- get path() {
10357
- return ctx.path;
10358
- }
10359
- };
10360
- checkCtx.addIssue = checkCtx.addIssue.bind(checkCtx);
10361
- if (effect.type === "preprocess") {
10362
- const processed = effect.transform(ctx.data, checkCtx);
10363
- if (ctx.common.async) {
10364
- return Promise.resolve(processed).then(async (processed2) => {
10365
- if (status.value === "aborted")
10366
- return INVALID;
10367
- const result = await this._def.schema._parseAsync({
10368
- data: processed2,
10369
- path: ctx.path,
10370
- parent: ctx
10371
- });
10372
- if (result.status === "aborted")
10373
- return INVALID;
10374
- if (result.status === "dirty")
10375
- return DIRTY(result.value);
10376
- if (status.value === "dirty")
10377
- return DIRTY(result.value);
10378
- return result;
10379
- });
10380
- } else {
10381
- if (status.value === "aborted")
10382
- return INVALID;
10383
- const result = this._def.schema._parseSync({
10384
- data: processed,
10385
- path: ctx.path,
10386
- parent: ctx
10387
- });
10388
- if (result.status === "aborted")
10389
- return INVALID;
10390
- if (result.status === "dirty")
10391
- return DIRTY(result.value);
10392
- if (status.value === "dirty")
10393
- return DIRTY(result.value);
10394
- return result;
10395
- }
10396
- }
10397
- if (effect.type === "refinement") {
10398
- const executeRefinement = (acc) => {
10399
- const result = effect.refinement(acc, checkCtx);
10400
- if (ctx.common.async) {
10401
- return Promise.resolve(result);
10402
- }
10403
- if (result instanceof Promise) {
10404
- throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");
10405
- }
10406
- return acc;
10407
- };
10408
- if (ctx.common.async === false) {
10409
- const inner = this._def.schema._parseSync({
10410
- data: ctx.data,
10411
- path: ctx.path,
10412
- parent: ctx
10413
- });
10414
- if (inner.status === "aborted")
10415
- return INVALID;
10416
- if (inner.status === "dirty")
10417
- status.dirty();
10418
- executeRefinement(inner.value);
10419
- return { status: status.value, value: inner.value };
10420
- } else {
10421
- return this._def.schema._parseAsync({ data: ctx.data, path: ctx.path, parent: ctx }).then((inner) => {
10422
- if (inner.status === "aborted")
10423
- return INVALID;
10424
- if (inner.status === "dirty")
10425
- status.dirty();
10426
- return executeRefinement(inner.value).then(() => {
10427
- return { status: status.value, value: inner.value };
10428
- });
10429
- });
10430
- }
10431
- }
10432
- if (effect.type === "transform") {
10433
- if (ctx.common.async === false) {
10434
- const base = this._def.schema._parseSync({
10435
- data: ctx.data,
10436
- path: ctx.path,
10437
- parent: ctx
10438
- });
10439
- if (!isValid(base))
10440
- return INVALID;
10441
- const result = effect.transform(base.value, checkCtx);
10442
- if (result instanceof Promise) {
10443
- throw new Error(`Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.`);
10444
- }
10445
- return { status: status.value, value: result };
10446
- } else {
10447
- return this._def.schema._parseAsync({ data: ctx.data, path: ctx.path, parent: ctx }).then((base) => {
10448
- if (!isValid(base))
10449
- return INVALID;
10450
- return Promise.resolve(effect.transform(base.value, checkCtx)).then((result) => ({
10451
- status: status.value,
10452
- value: result
10453
- }));
10454
- });
10455
- }
10456
- }
10457
- util.assertNever(effect);
10458
- }
10459
- };
10460
- ZodEffects.create = (schema, effect, params) => {
10461
- return new ZodEffects({
10462
- schema,
10463
- typeName: ZodFirstPartyTypeKind.ZodEffects,
10464
- effect,
10465
- ...processCreateParams(params)
10466
- });
10467
- };
10468
- ZodEffects.createWithPreprocess = (preprocess2, schema, params) => {
10469
- return new ZodEffects({
10470
- schema,
10471
- effect: { type: "preprocess", transform: preprocess2 },
10472
- typeName: ZodFirstPartyTypeKind.ZodEffects,
10473
- ...processCreateParams(params)
10474
- });
10475
- };
10476
- var ZodOptional = class extends ZodType {
10477
- _parse(input) {
10478
- const parsedType2 = this._getType(input);
10479
- if (parsedType2 === ZodParsedType.undefined) {
10480
- return OK(void 0);
10481
- }
10482
- return this._def.innerType._parse(input);
10483
- }
10484
- unwrap() {
10485
- return this._def.innerType;
10486
- }
10487
- };
10488
- ZodOptional.create = (type, params) => {
10489
- return new ZodOptional({
10490
- innerType: type,
10491
- typeName: ZodFirstPartyTypeKind.ZodOptional,
10492
- ...processCreateParams(params)
10493
- });
10494
- };
10495
- var ZodNullable = class extends ZodType {
10496
- _parse(input) {
10497
- const parsedType2 = this._getType(input);
10498
- if (parsedType2 === ZodParsedType.null) {
10499
- return OK(null);
10500
- }
10501
- return this._def.innerType._parse(input);
10502
- }
10503
- unwrap() {
10504
- return this._def.innerType;
10505
- }
10506
- };
10507
- ZodNullable.create = (type, params) => {
10508
- return new ZodNullable({
10509
- innerType: type,
10510
- typeName: ZodFirstPartyTypeKind.ZodNullable,
10511
- ...processCreateParams(params)
10512
- });
10513
- };
10514
- var ZodDefault = class extends ZodType {
10515
- _parse(input) {
10516
- const { ctx } = this._processInputParams(input);
10517
- let data = ctx.data;
10518
- if (ctx.parsedType === ZodParsedType.undefined) {
10519
- data = this._def.defaultValue();
10520
- }
10521
- return this._def.innerType._parse({
10522
- data,
10523
- path: ctx.path,
10524
- parent: ctx
10525
- });
10526
- }
10527
- removeDefault() {
10528
- return this._def.innerType;
10529
- }
10530
- };
10531
- ZodDefault.create = (type, params) => {
10532
- return new ZodDefault({
10533
- innerType: type,
10534
- typeName: ZodFirstPartyTypeKind.ZodDefault,
10535
- defaultValue: typeof params.default === "function" ? params.default : () => params.default,
10536
- ...processCreateParams(params)
10537
- });
10538
- };
10539
- var ZodCatch = class extends ZodType {
10540
- _parse(input) {
10541
- const { ctx } = this._processInputParams(input);
10542
- const newCtx = {
10543
- ...ctx,
10544
- common: {
10545
- ...ctx.common,
10546
- issues: []
10547
- }
10548
- };
10549
- const result = this._def.innerType._parse({
10550
- data: newCtx.data,
10551
- path: newCtx.path,
10552
- parent: {
10553
- ...newCtx
10554
- }
10555
- });
10556
- if (isAsync(result)) {
10557
- return result.then((result2) => {
10558
- return {
10559
- status: "valid",
10560
- value: result2.status === "valid" ? result2.value : this._def.catchValue({
10561
- get error() {
10562
- return new ZodError(newCtx.common.issues);
10563
- },
10564
- input: newCtx.data
10565
- })
10566
- };
10567
- });
10568
- } else {
10569
- return {
10570
- status: "valid",
10571
- value: result.status === "valid" ? result.value : this._def.catchValue({
10572
- get error() {
10573
- return new ZodError(newCtx.common.issues);
10574
- },
10575
- input: newCtx.data
10576
- })
10577
- };
10578
- }
10579
- }
10580
- removeCatch() {
10581
- return this._def.innerType;
10582
- }
10583
- };
10584
- ZodCatch.create = (type, params) => {
10585
- return new ZodCatch({
10586
- innerType: type,
10587
- typeName: ZodFirstPartyTypeKind.ZodCatch,
10588
- catchValue: typeof params.catch === "function" ? params.catch : () => params.catch,
10589
- ...processCreateParams(params)
10590
- });
10591
- };
10592
- var ZodNaN = class extends ZodType {
10593
- _parse(input) {
10594
- const parsedType2 = this._getType(input);
10595
- if (parsedType2 !== ZodParsedType.nan) {
10596
- const ctx = this._getOrReturnCtx(input);
10597
- addIssueToContext(ctx, {
10598
- code: ZodIssueCode.invalid_type,
10599
- expected: ZodParsedType.nan,
10600
- received: ctx.parsedType
10601
- });
10602
- return INVALID;
10603
- }
10604
- return { status: "valid", value: input.data };
10605
- }
10606
- };
10607
- ZodNaN.create = (params) => {
10608
- return new ZodNaN({
10609
- typeName: ZodFirstPartyTypeKind.ZodNaN,
10610
- ...processCreateParams(params)
10611
- });
10612
- };
10613
- var BRAND = /* @__PURE__ */ Symbol("zod_brand");
10614
- var ZodBranded = class extends ZodType {
10615
- _parse(input) {
10616
- const { ctx } = this._processInputParams(input);
10617
- const data = ctx.data;
10618
- return this._def.type._parse({
10619
- data,
10620
- path: ctx.path,
10621
- parent: ctx
10622
- });
10623
- }
10624
- unwrap() {
10625
- return this._def.type;
10626
- }
10627
- };
10628
- var ZodPipeline = class _ZodPipeline extends ZodType {
10629
- _parse(input) {
10630
- const { status, ctx } = this._processInputParams(input);
10631
- if (ctx.common.async) {
10632
- const handleAsync = async () => {
10633
- const inResult = await this._def.in._parseAsync({
10634
- data: ctx.data,
10635
- path: ctx.path,
10636
- parent: ctx
10637
- });
10638
- if (inResult.status === "aborted")
10639
- return INVALID;
10640
- if (inResult.status === "dirty") {
10641
- status.dirty();
10642
- return DIRTY(inResult.value);
10643
- } else {
10644
- return this._def.out._parseAsync({
10645
- data: inResult.value,
10646
- path: ctx.path,
10647
- parent: ctx
10648
- });
10649
- }
10650
- };
10651
- return handleAsync();
10652
- } else {
10653
- const inResult = this._def.in._parseSync({
10654
- data: ctx.data,
10655
- path: ctx.path,
10656
- parent: ctx
10657
- });
10658
- if (inResult.status === "aborted")
10659
- return INVALID;
10660
- if (inResult.status === "dirty") {
10661
- status.dirty();
10662
- return {
10663
- status: "dirty",
10664
- value: inResult.value
10665
- };
10666
- } else {
10667
- return this._def.out._parseSync({
10668
- data: inResult.value,
10669
- path: ctx.path,
10670
- parent: ctx
10671
- });
10672
- }
10673
- }
10674
- }
10675
- static create(a, b) {
10676
- return new _ZodPipeline({
10677
- in: a,
10678
- out: b,
10679
- typeName: ZodFirstPartyTypeKind.ZodPipeline
10680
- });
10681
- }
10682
- };
10683
- var ZodReadonly = class extends ZodType {
10684
- _parse(input) {
10685
- const result = this._def.innerType._parse(input);
10686
- const freeze = (data) => {
10687
- if (isValid(data)) {
10688
- data.value = Object.freeze(data.value);
10689
- }
10690
- return data;
10691
- };
10692
- return isAsync(result) ? result.then((data) => freeze(data)) : freeze(result);
10693
- }
10694
- unwrap() {
10695
- return this._def.innerType;
10696
- }
10697
- };
10698
- ZodReadonly.create = (type, params) => {
10699
- return new ZodReadonly({
10700
- innerType: type,
10701
- typeName: ZodFirstPartyTypeKind.ZodReadonly,
10702
- ...processCreateParams(params)
10703
- });
10704
- };
10705
- function cleanParams(params, data) {
10706
- const p = typeof params === "function" ? params(data) : typeof params === "string" ? { message: params } : params;
10707
- const p2 = typeof p === "string" ? { message: p } : p;
10708
- return p2;
10709
- }
10710
- function custom(check2, _params = {}, fatal) {
10711
- if (check2)
10712
- return ZodAny.create().superRefine((data, ctx) => {
10713
- const r = check2(data);
10714
- if (r instanceof Promise) {
10715
- return r.then((r2) => {
10716
- if (!r2) {
10717
- const params = cleanParams(_params, data);
10718
- const _fatal = params.fatal ?? fatal ?? true;
10719
- ctx.addIssue({ code: "custom", ...params, fatal: _fatal });
10720
- }
10721
- });
10722
- }
10723
- if (!r) {
10724
- const params = cleanParams(_params, data);
10725
- const _fatal = params.fatal ?? fatal ?? true;
10726
- ctx.addIssue({ code: "custom", ...params, fatal: _fatal });
10727
- }
10728
- return;
10729
- });
10730
- return ZodAny.create();
10731
- }
10732
- var late = {
10733
- object: ZodObject.lazycreate
10734
- };
10735
- var ZodFirstPartyTypeKind;
10736
- (function(ZodFirstPartyTypeKind2) {
10737
- ZodFirstPartyTypeKind2["ZodString"] = "ZodString";
10738
- ZodFirstPartyTypeKind2["ZodNumber"] = "ZodNumber";
10739
- ZodFirstPartyTypeKind2["ZodNaN"] = "ZodNaN";
10740
- ZodFirstPartyTypeKind2["ZodBigInt"] = "ZodBigInt";
10741
- ZodFirstPartyTypeKind2["ZodBoolean"] = "ZodBoolean";
10742
- ZodFirstPartyTypeKind2["ZodDate"] = "ZodDate";
10743
- ZodFirstPartyTypeKind2["ZodSymbol"] = "ZodSymbol";
10744
- ZodFirstPartyTypeKind2["ZodUndefined"] = "ZodUndefined";
10745
- ZodFirstPartyTypeKind2["ZodNull"] = "ZodNull";
10746
- ZodFirstPartyTypeKind2["ZodAny"] = "ZodAny";
10747
- ZodFirstPartyTypeKind2["ZodUnknown"] = "ZodUnknown";
10748
- ZodFirstPartyTypeKind2["ZodNever"] = "ZodNever";
10749
- ZodFirstPartyTypeKind2["ZodVoid"] = "ZodVoid";
10750
- ZodFirstPartyTypeKind2["ZodArray"] = "ZodArray";
10751
- ZodFirstPartyTypeKind2["ZodObject"] = "ZodObject";
10752
- ZodFirstPartyTypeKind2["ZodUnion"] = "ZodUnion";
10753
- ZodFirstPartyTypeKind2["ZodDiscriminatedUnion"] = "ZodDiscriminatedUnion";
10754
- ZodFirstPartyTypeKind2["ZodIntersection"] = "ZodIntersection";
10755
- ZodFirstPartyTypeKind2["ZodTuple"] = "ZodTuple";
10756
- ZodFirstPartyTypeKind2["ZodRecord"] = "ZodRecord";
10757
- ZodFirstPartyTypeKind2["ZodMap"] = "ZodMap";
10758
- ZodFirstPartyTypeKind2["ZodSet"] = "ZodSet";
10759
- ZodFirstPartyTypeKind2["ZodFunction"] = "ZodFunction";
10760
- ZodFirstPartyTypeKind2["ZodLazy"] = "ZodLazy";
10761
- ZodFirstPartyTypeKind2["ZodLiteral"] = "ZodLiteral";
10762
- ZodFirstPartyTypeKind2["ZodEnum"] = "ZodEnum";
10763
- ZodFirstPartyTypeKind2["ZodEffects"] = "ZodEffects";
10764
- ZodFirstPartyTypeKind2["ZodNativeEnum"] = "ZodNativeEnum";
10765
- ZodFirstPartyTypeKind2["ZodOptional"] = "ZodOptional";
10766
- ZodFirstPartyTypeKind2["ZodNullable"] = "ZodNullable";
10767
- ZodFirstPartyTypeKind2["ZodDefault"] = "ZodDefault";
10768
- ZodFirstPartyTypeKind2["ZodCatch"] = "ZodCatch";
10769
- ZodFirstPartyTypeKind2["ZodPromise"] = "ZodPromise";
10770
- ZodFirstPartyTypeKind2["ZodBranded"] = "ZodBranded";
10771
- ZodFirstPartyTypeKind2["ZodPipeline"] = "ZodPipeline";
10772
- ZodFirstPartyTypeKind2["ZodReadonly"] = "ZodReadonly";
10773
- })(ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {}));
10774
- var instanceOfType = (cls, params = {
10775
- message: `Input not instance of ${cls.name}`
10776
- }) => custom((data) => data instanceof cls, params);
10777
- var stringType = ZodString.create;
10778
- var numberType = ZodNumber.create;
10779
- var nanType = ZodNaN.create;
10780
- var bigIntType = ZodBigInt.create;
10781
- var booleanType = ZodBoolean.create;
10782
- var dateType = ZodDate.create;
10783
- var symbolType = ZodSymbol.create;
10784
- var undefinedType = ZodUndefined.create;
10785
- var nullType = ZodNull.create;
10786
- var anyType = ZodAny.create;
10787
- var unknownType = ZodUnknown.create;
10788
- var neverType = ZodNever.create;
10789
- var voidType = ZodVoid.create;
10790
- var arrayType = ZodArray.create;
10791
- var objectType = ZodObject.create;
10792
- var strictObjectType = ZodObject.strictCreate;
10793
- var unionType = ZodUnion.create;
10794
- var discriminatedUnionType = ZodDiscriminatedUnion.create;
10795
- var intersectionType = ZodIntersection.create;
10796
- var tupleType = ZodTuple.create;
10797
- var recordType = ZodRecord.create;
10798
- var mapType = ZodMap.create;
10799
- var setType = ZodSet.create;
10800
- var functionType = ZodFunction.create;
10801
- var lazyType = ZodLazy.create;
10802
- var literalType = ZodLiteral.create;
10803
- var enumType = ZodEnum.create;
10804
- var nativeEnumType = ZodNativeEnum.create;
10805
- var promiseType = ZodPromise.create;
10806
- var effectsType = ZodEffects.create;
10807
- var optionalType = ZodOptional.create;
10808
- var nullableType = ZodNullable.create;
10809
- var preprocessType = ZodEffects.createWithPreprocess;
10810
- var pipelineType = ZodPipeline.create;
10811
- var ostring = () => stringType().optional();
10812
- var onumber = () => numberType().optional();
10813
- var oboolean = () => booleanType().optional();
10814
- var coerce = {
10815
- string: ((arg) => ZodString.create({ ...arg, coerce: true })),
10816
- number: ((arg) => ZodNumber.create({ ...arg, coerce: true })),
10817
- boolean: ((arg) => ZodBoolean.create({
10818
- ...arg,
10819
- coerce: true
10820
- })),
10821
- bigint: ((arg) => ZodBigInt.create({ ...arg, coerce: true })),
10822
- date: ((arg) => ZodDate.create({ ...arg, coerce: true }))
10823
- };
10824
- var NEVER = INVALID;
10825
-
10826
6789
  // ../../node_modules/.pnpm/zod@3.25.76/node_modules/zod/v4/core/core.js
10827
- var NEVER2 = Object.freeze({
6790
+ var NEVER = Object.freeze({
10828
6791
  status: "aborted"
10829
6792
  });
10830
6793
  // @__NO_SIDE_EFFECTS__
@@ -10907,11 +6870,11 @@ __export(util_exports, {
10907
6870
  escapeRegex: () => escapeRegex,
10908
6871
  extend: () => extend,
10909
6872
  finalizeIssue: () => finalizeIssue,
10910
- floatSafeRemainder: () => floatSafeRemainder2,
6873
+ floatSafeRemainder: () => floatSafeRemainder,
10911
6874
  getElementAtPath: () => getElementAtPath,
10912
6875
  getEnumValues: () => getEnumValues,
10913
6876
  getLengthableOrigin: () => getLengthableOrigin,
10914
- getParsedType: () => getParsedType2,
6877
+ getParsedType: () => getParsedType,
10915
6878
  getSizableOrigin: () => getSizableOrigin,
10916
6879
  isObject: () => isObject,
10917
6880
  isPlainObject: () => isPlainObject,
@@ -10982,7 +6945,7 @@ function cleanRegex(source) {
10982
6945
  const end = source.endsWith("$") ? source.length - 1 : source.length;
10983
6946
  return source.slice(start, end);
10984
6947
  }
10985
- function floatSafeRemainder2(val, step) {
6948
+ function floatSafeRemainder(val, step) {
10986
6949
  const valDecCount = (val.toString().split(".")[1] || "").length;
10987
6950
  const stepDecCount = (step.toString().split(".")[1] || "").length;
10988
6951
  const decCount = valDecCount > stepDecCount ? valDecCount : stepDecCount;
@@ -11085,7 +7048,7 @@ function numKeys(data) {
11085
7048
  }
11086
7049
  return keyCount;
11087
7050
  }
11088
- var getParsedType2 = (data) => {
7051
+ var getParsedType = (data) => {
11089
7052
  const t = typeof data;
11090
7053
  switch (t) {
11091
7054
  case "undefined":
@@ -11574,8 +7537,8 @@ function datetime(args) {
11574
7537
  opts.push("");
11575
7538
  if (args.offset)
11576
7539
  opts.push(`([+-]\\d{2}:\\d{2})`);
11577
- const timeRegex2 = `${time3}(?:${opts.join("|")})`;
11578
- return new RegExp(`^${dateSource}T(?:${timeRegex2})$`);
7540
+ const timeRegex = `${time3}(?:${opts.join("|")})`;
7541
+ return new RegExp(`^${dateSource}T(?:${timeRegex})$`);
11579
7542
  }
11580
7543
  var string = (params) => {
11581
7544
  const regex = params ? `[\\s\\S]{${params?.minimum ?? 0},${params?.maximum ?? ""}}` : `[\\s\\S]*`;
@@ -11665,7 +7628,7 @@ var $ZodCheckMultipleOf = /* @__PURE__ */ $constructor("$ZodCheckMultipleOf", (i
11665
7628
  inst._zod.check = (payload) => {
11666
7629
  if (typeof payload.value !== typeof def.value)
11667
7630
  throw new Error("Cannot mix number and bigint in multiple_of check.");
11668
- const isMultiple = typeof payload.value === "bigint" ? payload.value % def.value === BigInt(0) : floatSafeRemainder2(payload.value, def.value) === 0;
7631
+ const isMultiple = typeof payload.value === "bigint" ? payload.value % def.value === BigInt(0) : floatSafeRemainder(payload.value, def.value) === 0;
11669
7632
  if (isMultiple)
11670
7633
  return;
11671
7634
  payload.issues.push({
@@ -12039,14 +8002,14 @@ var $ZodType = /* @__PURE__ */ $constructor("$ZodType", (inst, def) => {
12039
8002
  });
12040
8003
  } else {
12041
8004
  const runChecks = (payload, checks2, ctx) => {
12042
- let isAborted2 = aborted(payload);
8005
+ let isAborted = aborted(payload);
12043
8006
  let asyncResult;
12044
8007
  for (const ch of checks2) {
12045
8008
  if (ch._zod.def.when) {
12046
8009
  const shouldRun = ch._zod.def.when(payload);
12047
8010
  if (!shouldRun)
12048
8011
  continue;
12049
- } else if (isAborted2) {
8012
+ } else if (isAborted) {
12050
8013
  continue;
12051
8014
  }
12052
8015
  const currLen = payload.issues.length;
@@ -12060,15 +8023,15 @@ var $ZodType = /* @__PURE__ */ $constructor("$ZodType", (inst, def) => {
12060
8023
  const nextLen = payload.issues.length;
12061
8024
  if (nextLen === currLen)
12062
8025
  return;
12063
- if (!isAborted2)
12064
- isAborted2 = aborted(payload, currLen);
8026
+ if (!isAborted)
8027
+ isAborted = aborted(payload, currLen);
12065
8028
  });
12066
8029
  } else {
12067
8030
  const nextLen = payload.issues.length;
12068
8031
  if (nextLen === currLen)
12069
8032
  continue;
12070
- if (!isAborted2)
12071
- isAborted2 = aborted(payload, currLen);
8033
+ if (!isAborted)
8034
+ isAborted = aborted(payload, currLen);
12072
8035
  }
12073
8036
  }
12074
8037
  if (asyncResult) {
@@ -12366,7 +8329,7 @@ var $ZodE164 = /* @__PURE__ */ $constructor("$ZodE164", (inst, def) => {
12366
8329
  def.pattern ?? (def.pattern = e164);
12367
8330
  $ZodStringFormat.init(inst, def);
12368
8331
  });
12369
- function isValidJWT2(token, algorithm = null) {
8332
+ function isValidJWT(token, algorithm = null) {
12370
8333
  try {
12371
8334
  const tokensParts = token.split(".");
12372
8335
  if (tokensParts.length !== 3)
@@ -12389,7 +8352,7 @@ function isValidJWT2(token, algorithm = null) {
12389
8352
  var $ZodJWT = /* @__PURE__ */ $constructor("$ZodJWT", (inst, def) => {
12390
8353
  $ZodStringFormat.init(inst, def);
12391
8354
  inst._zod.check = (payload) => {
12392
- if (isValidJWT2(payload.value, def.alg))
8355
+ if (isValidJWT(payload.value, def.alg))
12393
8356
  return;
12394
8357
  payload.issues.push({
12395
8358
  code: "invalid_format",
@@ -12842,7 +8805,7 @@ var $ZodIntersection = /* @__PURE__ */ $constructor("$ZodIntersection", (inst, d
12842
8805
  return handleIntersectionResults(payload, left, right);
12843
8806
  };
12844
8807
  });
12845
- function mergeValues2(a, b) {
8808
+ function mergeValues(a, b) {
12846
8809
  if (a === b) {
12847
8810
  return { valid: true, data: a };
12848
8811
  }
@@ -12854,7 +8817,7 @@ function mergeValues2(a, b) {
12854
8817
  const sharedKeys = Object.keys(a).filter((key) => bKeys.indexOf(key) !== -1);
12855
8818
  const newObj = { ...a, ...b };
12856
8819
  for (const key of sharedKeys) {
12857
- const sharedValue = mergeValues2(a[key], b[key]);
8820
+ const sharedValue = mergeValues(a[key], b[key]);
12858
8821
  if (!sharedValue.valid) {
12859
8822
  return {
12860
8823
  valid: false,
@@ -12873,7 +8836,7 @@ function mergeValues2(a, b) {
12873
8836
  for (let index = 0; index < a.length; index++) {
12874
8837
  const itemA = a[index];
12875
8838
  const itemB = b[index];
12876
- const sharedValue = mergeValues2(itemA, itemB);
8839
+ const sharedValue = mergeValues(itemA, itemB);
12877
8840
  if (!sharedValue.valid) {
12878
8841
  return {
12879
8842
  valid: false,
@@ -12895,7 +8858,7 @@ function handleIntersectionResults(result, left, right) {
12895
8858
  }
12896
8859
  if (aborted(result))
12897
8860
  return result;
12898
- const merged = mergeValues2(left.value, right.value);
8861
+ const merged = mergeValues(left.value, right.value);
12899
8862
  if (!merged.valid) {
12900
8863
  throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(merged.mergeErrorPath)}`);
12901
8864
  }
@@ -13366,7 +9329,7 @@ var error = () => {
13366
9329
  }
13367
9330
  };
13368
9331
  };
13369
- function en_default2() {
9332
+ function en_default() {
13370
9333
  return {
13371
9334
  localeError: error()
13372
9335
  };
@@ -14886,7 +10849,7 @@ var initializer2 = (inst, issues) => {
14886
10849
  }
14887
10850
  });
14888
10851
  };
14889
- var ZodError2 = $constructor("ZodError", initializer2);
10852
+ var ZodError = $constructor("ZodError", initializer2);
14890
10853
  var ZodRealError = $constructor("ZodError", initializer2, {
14891
10854
  Parent: Error
14892
10855
  });
@@ -14898,7 +10861,7 @@ var safeParse3 = /* @__PURE__ */ _safeParse(ZodRealError);
14898
10861
  var safeParseAsync3 = /* @__PURE__ */ _safeParseAsync(ZodRealError);
14899
10862
 
14900
10863
  // ../../node_modules/.pnpm/zod@3.25.76/node_modules/zod/v4/classic/schemas.js
14901
- var ZodType2 = /* @__PURE__ */ $constructor("ZodType", (inst, def) => {
10864
+ var ZodType = /* @__PURE__ */ $constructor("ZodType", (inst, def) => {
14902
10865
  $ZodType.init(inst, def);
14903
10866
  inst.def = def;
14904
10867
  Object.defineProperty(inst, "_def", { value: def });
@@ -14966,7 +10929,7 @@ var ZodType2 = /* @__PURE__ */ $constructor("ZodType", (inst, def) => {
14966
10929
  });
14967
10930
  var _ZodString = /* @__PURE__ */ $constructor("_ZodString", (inst, def) => {
14968
10931
  $ZodString.init(inst, def);
14969
- ZodType2.init(inst, def);
10932
+ ZodType.init(inst, def);
14970
10933
  const bag = inst._zod.bag;
14971
10934
  inst.format = bag.format ?? null;
14972
10935
  inst.minLength = bag.minimum ?? null;
@@ -14986,7 +10949,7 @@ var _ZodString = /* @__PURE__ */ $constructor("_ZodString", (inst, def) => {
14986
10949
  inst.toLowerCase = () => inst.check(_toLowerCase());
14987
10950
  inst.toUpperCase = () => inst.check(_toUpperCase());
14988
10951
  });
14989
- var ZodString2 = /* @__PURE__ */ $constructor("ZodString", (inst, def) => {
10952
+ var ZodString = /* @__PURE__ */ $constructor("ZodString", (inst, def) => {
14990
10953
  $ZodString.init(inst, def);
14991
10954
  _ZodString.init(inst, def);
14992
10955
  inst.email = (params) => inst.check(_email(ZodEmail, params));
@@ -15018,7 +10981,7 @@ var ZodString2 = /* @__PURE__ */ $constructor("ZodString", (inst, def) => {
15018
10981
  inst.duration = (params) => inst.check(duration2(params));
15019
10982
  });
15020
10983
  function string2(params) {
15021
- return _string(ZodString2, params);
10984
+ return _string(ZodString, params);
15022
10985
  }
15023
10986
  var ZodStringFormat = /* @__PURE__ */ $constructor("ZodStringFormat", (inst, def) => {
15024
10987
  $ZodStringFormat.init(inst, def);
@@ -15100,9 +11063,9 @@ var ZodJWT = /* @__PURE__ */ $constructor("ZodJWT", (inst, def) => {
15100
11063
  $ZodJWT.init(inst, def);
15101
11064
  ZodStringFormat.init(inst, def);
15102
11065
  });
15103
- var ZodNumber2 = /* @__PURE__ */ $constructor("ZodNumber", (inst, def) => {
11066
+ var ZodNumber = /* @__PURE__ */ $constructor("ZodNumber", (inst, def) => {
15104
11067
  $ZodNumber.init(inst, def);
15105
- ZodType2.init(inst, def);
11068
+ ZodType.init(inst, def);
15106
11069
  inst.gt = (value, params) => inst.check(_gt(value, params));
15107
11070
  inst.gte = (value, params) => inst.check(_gte(value, params));
15108
11071
  inst.min = (value, params) => inst.check(_gte(value, params));
@@ -15126,46 +11089,46 @@ var ZodNumber2 = /* @__PURE__ */ $constructor("ZodNumber", (inst, def) => {
15126
11089
  inst.format = bag.format ?? null;
15127
11090
  });
15128
11091
  function number2(params) {
15129
- return _number(ZodNumber2, params);
11092
+ return _number(ZodNumber, params);
15130
11093
  }
15131
11094
  var ZodNumberFormat = /* @__PURE__ */ $constructor("ZodNumberFormat", (inst, def) => {
15132
11095
  $ZodNumberFormat.init(inst, def);
15133
- ZodNumber2.init(inst, def);
11096
+ ZodNumber.init(inst, def);
15134
11097
  });
15135
11098
  function int(params) {
15136
11099
  return _int(ZodNumberFormat, params);
15137
11100
  }
15138
- var ZodBoolean2 = /* @__PURE__ */ $constructor("ZodBoolean", (inst, def) => {
11101
+ var ZodBoolean = /* @__PURE__ */ $constructor("ZodBoolean", (inst, def) => {
15139
11102
  $ZodBoolean.init(inst, def);
15140
- ZodType2.init(inst, def);
11103
+ ZodType.init(inst, def);
15141
11104
  });
15142
11105
  function boolean2(params) {
15143
- return _boolean(ZodBoolean2, params);
11106
+ return _boolean(ZodBoolean, params);
15144
11107
  }
15145
- var ZodNull2 = /* @__PURE__ */ $constructor("ZodNull", (inst, def) => {
11108
+ var ZodNull = /* @__PURE__ */ $constructor("ZodNull", (inst, def) => {
15146
11109
  $ZodNull.init(inst, def);
15147
- ZodType2.init(inst, def);
11110
+ ZodType.init(inst, def);
15148
11111
  });
15149
11112
  function _null3(params) {
15150
- return _null2(ZodNull2, params);
11113
+ return _null2(ZodNull, params);
15151
11114
  }
15152
- var ZodUnknown2 = /* @__PURE__ */ $constructor("ZodUnknown", (inst, def) => {
11115
+ var ZodUnknown = /* @__PURE__ */ $constructor("ZodUnknown", (inst, def) => {
15153
11116
  $ZodUnknown.init(inst, def);
15154
- ZodType2.init(inst, def);
11117
+ ZodType.init(inst, def);
15155
11118
  });
15156
11119
  function unknown() {
15157
- return _unknown(ZodUnknown2);
11120
+ return _unknown(ZodUnknown);
15158
11121
  }
15159
- var ZodNever2 = /* @__PURE__ */ $constructor("ZodNever", (inst, def) => {
11122
+ var ZodNever = /* @__PURE__ */ $constructor("ZodNever", (inst, def) => {
15160
11123
  $ZodNever.init(inst, def);
15161
- ZodType2.init(inst, def);
11124
+ ZodType.init(inst, def);
15162
11125
  });
15163
11126
  function never(params) {
15164
- return _never(ZodNever2, params);
11127
+ return _never(ZodNever, params);
15165
11128
  }
15166
- var ZodArray2 = /* @__PURE__ */ $constructor("ZodArray", (inst, def) => {
11129
+ var ZodArray = /* @__PURE__ */ $constructor("ZodArray", (inst, def) => {
15167
11130
  $ZodArray.init(inst, def);
15168
- ZodType2.init(inst, def);
11131
+ ZodType.init(inst, def);
15169
11132
  inst.element = def.element;
15170
11133
  inst.min = (minLength, params) => inst.check(_minLength(minLength, params));
15171
11134
  inst.nonempty = (params) => inst.check(_minLength(1, params));
@@ -15174,11 +11137,11 @@ var ZodArray2 = /* @__PURE__ */ $constructor("ZodArray", (inst, def) => {
15174
11137
  inst.unwrap = () => inst.element;
15175
11138
  });
15176
11139
  function array(element, params) {
15177
- return _array(ZodArray2, element, params);
11140
+ return _array(ZodArray, element, params);
15178
11141
  }
15179
- var ZodObject2 = /* @__PURE__ */ $constructor("ZodObject", (inst, def) => {
11142
+ var ZodObject = /* @__PURE__ */ $constructor("ZodObject", (inst, def) => {
15180
11143
  $ZodObject.init(inst, def);
15181
- ZodType2.init(inst, def);
11144
+ ZodType.init(inst, def);
15182
11145
  util_exports.defineLazy(inst, "shape", () => def.shape);
15183
11146
  inst.keyof = () => _enum(Object.keys(inst._zod.def.shape));
15184
11147
  inst.catchall = (catchall) => inst.clone({ ...inst._zod.def, catchall });
@@ -15204,10 +11167,10 @@ function object2(shape, params) {
15204
11167
  },
15205
11168
  ...util_exports.normalizeParams(params)
15206
11169
  };
15207
- return new ZodObject2(def);
11170
+ return new ZodObject(def);
15208
11171
  }
15209
11172
  function looseObject(shape, params) {
15210
- return new ZodObject2({
11173
+ return new ZodObject({
15211
11174
  type: "object",
15212
11175
  get shape() {
15213
11176
  util_exports.assignProp(this, "shape", { ...shape });
@@ -15217,58 +11180,58 @@ function looseObject(shape, params) {
15217
11180
  ...util_exports.normalizeParams(params)
15218
11181
  });
15219
11182
  }
15220
- var ZodUnion2 = /* @__PURE__ */ $constructor("ZodUnion", (inst, def) => {
11183
+ var ZodUnion = /* @__PURE__ */ $constructor("ZodUnion", (inst, def) => {
15221
11184
  $ZodUnion.init(inst, def);
15222
- ZodType2.init(inst, def);
11185
+ ZodType.init(inst, def);
15223
11186
  inst.options = def.options;
15224
11187
  });
15225
11188
  function union(options, params) {
15226
- return new ZodUnion2({
11189
+ return new ZodUnion({
15227
11190
  type: "union",
15228
11191
  options,
15229
11192
  ...util_exports.normalizeParams(params)
15230
11193
  });
15231
11194
  }
15232
- var ZodDiscriminatedUnion2 = /* @__PURE__ */ $constructor("ZodDiscriminatedUnion", (inst, def) => {
15233
- ZodUnion2.init(inst, def);
11195
+ var ZodDiscriminatedUnion = /* @__PURE__ */ $constructor("ZodDiscriminatedUnion", (inst, def) => {
11196
+ ZodUnion.init(inst, def);
15234
11197
  $ZodDiscriminatedUnion.init(inst, def);
15235
11198
  });
15236
11199
  function discriminatedUnion(discriminator, options, params) {
15237
- return new ZodDiscriminatedUnion2({
11200
+ return new ZodDiscriminatedUnion({
15238
11201
  type: "union",
15239
11202
  options,
15240
11203
  discriminator,
15241
11204
  ...util_exports.normalizeParams(params)
15242
11205
  });
15243
11206
  }
15244
- var ZodIntersection2 = /* @__PURE__ */ $constructor("ZodIntersection", (inst, def) => {
11207
+ var ZodIntersection = /* @__PURE__ */ $constructor("ZodIntersection", (inst, def) => {
15245
11208
  $ZodIntersection.init(inst, def);
15246
- ZodType2.init(inst, def);
11209
+ ZodType.init(inst, def);
15247
11210
  });
15248
11211
  function intersection(left, right) {
15249
- return new ZodIntersection2({
11212
+ return new ZodIntersection({
15250
11213
  type: "intersection",
15251
11214
  left,
15252
11215
  right
15253
11216
  });
15254
11217
  }
15255
- var ZodRecord2 = /* @__PURE__ */ $constructor("ZodRecord", (inst, def) => {
11218
+ var ZodRecord = /* @__PURE__ */ $constructor("ZodRecord", (inst, def) => {
15256
11219
  $ZodRecord.init(inst, def);
15257
- ZodType2.init(inst, def);
11220
+ ZodType.init(inst, def);
15258
11221
  inst.keyType = def.keyType;
15259
11222
  inst.valueType = def.valueType;
15260
11223
  });
15261
11224
  function record(keyType, valueType, params) {
15262
- return new ZodRecord2({
11225
+ return new ZodRecord({
15263
11226
  type: "record",
15264
11227
  keyType,
15265
11228
  valueType,
15266
11229
  ...util_exports.normalizeParams(params)
15267
11230
  });
15268
11231
  }
15269
- var ZodEnum2 = /* @__PURE__ */ $constructor("ZodEnum", (inst, def) => {
11232
+ var ZodEnum = /* @__PURE__ */ $constructor("ZodEnum", (inst, def) => {
15270
11233
  $ZodEnum.init(inst, def);
15271
- ZodType2.init(inst, def);
11234
+ ZodType.init(inst, def);
15272
11235
  inst.enum = def.entries;
15273
11236
  inst.options = Object.values(def.entries);
15274
11237
  const keys = new Set(Object.keys(def.entries));
@@ -15280,7 +11243,7 @@ var ZodEnum2 = /* @__PURE__ */ $constructor("ZodEnum", (inst, def) => {
15280
11243
  } else
15281
11244
  throw new Error(`Key ${value} not found in enum`);
15282
11245
  }
15283
- return new ZodEnum2({
11246
+ return new ZodEnum({
15284
11247
  ...def,
15285
11248
  checks: [],
15286
11249
  ...util_exports.normalizeParams(params),
@@ -15295,7 +11258,7 @@ var ZodEnum2 = /* @__PURE__ */ $constructor("ZodEnum", (inst, def) => {
15295
11258
  } else
15296
11259
  throw new Error(`Key ${value} not found in enum`);
15297
11260
  }
15298
- return new ZodEnum2({
11261
+ return new ZodEnum({
15299
11262
  ...def,
15300
11263
  checks: [],
15301
11264
  ...util_exports.normalizeParams(params),
@@ -15305,15 +11268,15 @@ var ZodEnum2 = /* @__PURE__ */ $constructor("ZodEnum", (inst, def) => {
15305
11268
  });
15306
11269
  function _enum(values, params) {
15307
11270
  const entries = Array.isArray(values) ? Object.fromEntries(values.map((v) => [v, v])) : values;
15308
- return new ZodEnum2({
11271
+ return new ZodEnum({
15309
11272
  type: "enum",
15310
11273
  entries,
15311
11274
  ...util_exports.normalizeParams(params)
15312
11275
  });
15313
11276
  }
15314
- var ZodLiteral2 = /* @__PURE__ */ $constructor("ZodLiteral", (inst, def) => {
11277
+ var ZodLiteral = /* @__PURE__ */ $constructor("ZodLiteral", (inst, def) => {
15315
11278
  $ZodLiteral.init(inst, def);
15316
- ZodType2.init(inst, def);
11279
+ ZodType.init(inst, def);
15317
11280
  inst.values = new Set(def.values);
15318
11281
  Object.defineProperty(inst, "value", {
15319
11282
  get() {
@@ -15325,7 +11288,7 @@ var ZodLiteral2 = /* @__PURE__ */ $constructor("ZodLiteral", (inst, def) => {
15325
11288
  });
15326
11289
  });
15327
11290
  function literal(value, params) {
15328
- return new ZodLiteral2({
11291
+ return new ZodLiteral({
15329
11292
  type: "literal",
15330
11293
  values: Array.isArray(value) ? value : [value],
15331
11294
  ...util_exports.normalizeParams(params)
@@ -15333,7 +11296,7 @@ function literal(value, params) {
15333
11296
  }
15334
11297
  var ZodTransform = /* @__PURE__ */ $constructor("ZodTransform", (inst, def) => {
15335
11298
  $ZodTransform.init(inst, def);
15336
- ZodType2.init(inst, def);
11299
+ ZodType.init(inst, def);
15337
11300
  inst._zod.parse = (payload, _ctx) => {
15338
11301
  payload.addIssue = (issue2) => {
15339
11302
  if (typeof issue2 === "string") {
@@ -15368,7 +11331,7 @@ function transform(fn) {
15368
11331
  }
15369
11332
  var ZodOptional2 = /* @__PURE__ */ $constructor("ZodOptional", (inst, def) => {
15370
11333
  $ZodOptional.init(inst, def);
15371
- ZodType2.init(inst, def);
11334
+ ZodType.init(inst, def);
15372
11335
  inst.unwrap = () => inst._zod.def.innerType;
15373
11336
  });
15374
11337
  function optional(innerType) {
@@ -15377,25 +11340,25 @@ function optional(innerType) {
15377
11340
  innerType
15378
11341
  });
15379
11342
  }
15380
- var ZodNullable2 = /* @__PURE__ */ $constructor("ZodNullable", (inst, def) => {
11343
+ var ZodNullable = /* @__PURE__ */ $constructor("ZodNullable", (inst, def) => {
15381
11344
  $ZodNullable.init(inst, def);
15382
- ZodType2.init(inst, def);
11345
+ ZodType.init(inst, def);
15383
11346
  inst.unwrap = () => inst._zod.def.innerType;
15384
11347
  });
15385
11348
  function nullable(innerType) {
15386
- return new ZodNullable2({
11349
+ return new ZodNullable({
15387
11350
  type: "nullable",
15388
11351
  innerType
15389
11352
  });
15390
11353
  }
15391
- var ZodDefault2 = /* @__PURE__ */ $constructor("ZodDefault", (inst, def) => {
11354
+ var ZodDefault = /* @__PURE__ */ $constructor("ZodDefault", (inst, def) => {
15392
11355
  $ZodDefault.init(inst, def);
15393
- ZodType2.init(inst, def);
11356
+ ZodType.init(inst, def);
15394
11357
  inst.unwrap = () => inst._zod.def.innerType;
15395
11358
  inst.removeDefault = inst.unwrap;
15396
11359
  });
15397
11360
  function _default(innerType, defaultValue) {
15398
- return new ZodDefault2({
11361
+ return new ZodDefault({
15399
11362
  type: "default",
15400
11363
  innerType,
15401
11364
  get defaultValue() {
@@ -15405,7 +11368,7 @@ function _default(innerType, defaultValue) {
15405
11368
  }
15406
11369
  var ZodPrefault = /* @__PURE__ */ $constructor("ZodPrefault", (inst, def) => {
15407
11370
  $ZodPrefault.init(inst, def);
15408
- ZodType2.init(inst, def);
11371
+ ZodType.init(inst, def);
15409
11372
  inst.unwrap = () => inst._zod.def.innerType;
15410
11373
  });
15411
11374
  function prefault(innerType, defaultValue) {
@@ -15419,7 +11382,7 @@ function prefault(innerType, defaultValue) {
15419
11382
  }
15420
11383
  var ZodNonOptional = /* @__PURE__ */ $constructor("ZodNonOptional", (inst, def) => {
15421
11384
  $ZodNonOptional.init(inst, def);
15422
- ZodType2.init(inst, def);
11385
+ ZodType.init(inst, def);
15423
11386
  inst.unwrap = () => inst._zod.def.innerType;
15424
11387
  });
15425
11388
  function nonoptional(innerType, params) {
@@ -15429,14 +11392,14 @@ function nonoptional(innerType, params) {
15429
11392
  ...util_exports.normalizeParams(params)
15430
11393
  });
15431
11394
  }
15432
- var ZodCatch2 = /* @__PURE__ */ $constructor("ZodCatch", (inst, def) => {
11395
+ var ZodCatch = /* @__PURE__ */ $constructor("ZodCatch", (inst, def) => {
15433
11396
  $ZodCatch.init(inst, def);
15434
- ZodType2.init(inst, def);
11397
+ ZodType.init(inst, def);
15435
11398
  inst.unwrap = () => inst._zod.def.innerType;
15436
11399
  inst.removeCatch = inst.unwrap;
15437
11400
  });
15438
11401
  function _catch(innerType, catchValue) {
15439
- return new ZodCatch2({
11402
+ return new ZodCatch({
15440
11403
  type: "catch",
15441
11404
  innerType,
15442
11405
  catchValue: typeof catchValue === "function" ? catchValue : () => catchValue
@@ -15444,7 +11407,7 @@ function _catch(innerType, catchValue) {
15444
11407
  }
15445
11408
  var ZodPipe = /* @__PURE__ */ $constructor("ZodPipe", (inst, def) => {
15446
11409
  $ZodPipe.init(inst, def);
15447
- ZodType2.init(inst, def);
11410
+ ZodType.init(inst, def);
15448
11411
  inst.in = def.in;
15449
11412
  inst.out = def.out;
15450
11413
  });
@@ -15456,19 +11419,19 @@ function pipe(in_, out) {
15456
11419
  // ...util.normalizeParams(params),
15457
11420
  });
15458
11421
  }
15459
- var ZodReadonly2 = /* @__PURE__ */ $constructor("ZodReadonly", (inst, def) => {
11422
+ var ZodReadonly = /* @__PURE__ */ $constructor("ZodReadonly", (inst, def) => {
15460
11423
  $ZodReadonly.init(inst, def);
15461
- ZodType2.init(inst, def);
11424
+ ZodType.init(inst, def);
15462
11425
  });
15463
11426
  function readonly(innerType) {
15464
- return new ZodReadonly2({
11427
+ return new ZodReadonly({
15465
11428
  type: "readonly",
15466
11429
  innerType
15467
11430
  });
15468
11431
  }
15469
11432
  var ZodCustom = /* @__PURE__ */ $constructor("ZodCustom", (inst, def) => {
15470
11433
  $ZodCustom.init(inst, def);
15471
- ZodType2.init(inst, def);
11434
+ ZodType.init(inst, def);
15472
11435
  });
15473
11436
  function check(fn) {
15474
11437
  const ch = new $ZodCheck({
@@ -15478,7 +11441,7 @@ function check(fn) {
15478
11441
  ch._zod.check = fn;
15479
11442
  return ch;
15480
11443
  }
15481
- function custom2(fn, _params) {
11444
+ function custom(fn, _params) {
15482
11445
  return _custom(ZodCustom, fn ?? (() => true), _params);
15483
11446
  }
15484
11447
  function refine(fn, _params = {}) {
@@ -15509,14 +11472,14 @@ function preprocess(fn, schema) {
15509
11472
  }
15510
11473
 
15511
11474
  // ../../node_modules/.pnpm/zod@3.25.76/node_modules/zod/v4/classic/external.js
15512
- config(en_default2());
11475
+ config(en_default());
15513
11476
 
15514
11477
  // ../../node_modules/.pnpm/@modelcontextprotocol+sdk@1.28.0_zod@3.25.76/node_modules/@modelcontextprotocol/sdk/dist/esm/types.js
15515
11478
  var LATEST_PROTOCOL_VERSION = "2025-11-25";
15516
11479
  var SUPPORTED_PROTOCOL_VERSIONS = [LATEST_PROTOCOL_VERSION, "2025-06-18", "2025-03-26", "2024-11-05", "2024-10-07"];
15517
11480
  var RELATED_TASK_META_KEY = "io.modelcontextprotocol/related-task";
15518
11481
  var JSONRPC_VERSION = "2.0";
15519
- var AssertObjectSchema = custom2((v) => v !== null && (typeof v === "object" || typeof v === "function"));
11482
+ var AssertObjectSchema = custom((v) => v !== null && (typeof v === "object" || typeof v === "function"));
15520
11483
  var ProgressTokenSchema = union([string2(), number2().int()]);
15521
11484
  var CursorSchema = string2();
15522
11485
  var TaskCreationParamsSchema = looseObject({
@@ -17361,7 +13324,7 @@ function parseLiteralDef(def, refs) {
17361
13324
  }
17362
13325
 
17363
13326
  // ../../node_modules/.pnpm/zod-to-json-schema@3.25.1_zod@3.25.76/node_modules/zod-to-json-schema/dist/esm/parsers/string.js
17364
- var emojiRegex2 = void 0;
13327
+ var emojiRegex = void 0;
17365
13328
  var zodPatterns = {
17366
13329
  /**
17367
13330
  * `c` was changed to `[cC]` to replicate /i flag
@@ -17385,10 +13348,10 @@ var zodPatterns = {
17385
13348
  * https://github.com/colinhacks/zod/commit/9340fd51e48576a75adc919bff65dbc4a5d4c99b
17386
13349
  */
17387
13350
  emoji: () => {
17388
- if (emojiRegex2 === void 0) {
17389
- emojiRegex2 = RegExp("^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$", "u");
13351
+ if (emojiRegex === void 0) {
13352
+ emojiRegex = RegExp("^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$", "u");
17390
13353
  }
17391
- return emojiRegex2;
13354
+ return emojiRegex;
17392
13355
  },
17393
13356
  /**
17394
13357
  * Unused
@@ -21324,17 +17287,19 @@ function registerWriteTools(server, agent) {
21324
17287
  );
21325
17288
  server.tool(
21326
17289
  "t2000_save",
21327
- 'Deposit USDC to savings at the best USDC rate (earns yield). Amount is in dollars. Use "all" to save entire available balance. Set dryRun: true to preview.',
17290
+ 'Deposit to NAVI lending to earn yield. Supports USDC (default), USDT, SUI, USDe, USDsui. Amount is in token units. Use "all" to save entire available balance. Set dryRun: true to preview.',
21328
17291
  {
21329
- amount: external_exports.union([external_exports.number(), external_exports.literal("all")]).describe('Dollar amount to save, or "all"'),
17292
+ amount: external_exports.union([external_exports.number(), external_exports.literal("all")]).describe('Amount to save, or "all"'),
17293
+ asset: external_exports.enum(["USDC", "USDT", "SUI", "USDe", "USDsui"]).optional().describe("Asset to deposit (default: USDC)"),
21330
17294
  dryRun: external_exports.boolean().optional().describe("Preview without signing (default: false)")
21331
17295
  },
21332
- async ({ amount, dryRun }) => {
17296
+ async ({ amount, asset, dryRun }) => {
21333
17297
  try {
21334
17298
  if (dryRun) {
21335
17299
  agent.enforcer.assertNotLocked();
21336
17300
  const balance = await agent.balance();
21337
17301
  const rates = await agent.rates();
17302
+ const assetKey = asset ?? "USDC";
21338
17303
  const saveAmount = amount === "all" ? balance.available - 1 : amount;
21339
17304
  return {
21340
17305
  content: [{
@@ -21342,13 +17307,14 @@ function registerWriteTools(server, agent) {
21342
17307
  text: JSON.stringify({
21343
17308
  preview: true,
21344
17309
  amount: saveAmount,
21345
- currentApy: rates.USDC?.saveApy ?? 0,
17310
+ asset: assetKey,
17311
+ currentApy: rates[assetKey]?.saveApy ?? rates.USDC?.saveApy ?? 0,
21346
17312
  savingsBalanceAfter: balance.savings + saveAmount
21347
17313
  })
21348
17314
  }]
21349
17315
  };
21350
17316
  }
21351
- const result = await mutex.run(() => agent.save({ amount }));
17317
+ const result = await mutex.run(() => agent.save({ amount, asset }));
21352
17318
  return { content: [{ type: "text", text: JSON.stringify(result) }] };
21353
17319
  } catch (err) {
21354
17320
  return errorResult(err);
@@ -21357,31 +17323,33 @@ function registerWriteTools(server, agent) {
21357
17323
  );
21358
17324
  server.tool(
21359
17325
  "t2000_withdraw",
21360
- 'Withdraw from savings back to checking. Amount is in dollars. Use "all" to withdraw everything. Set dryRun: true to preview.',
17326
+ 'Withdraw from NAVI lending back to wallet. Supports any deposited asset. Amount is in token units. Use "all" to withdraw everything. Set dryRun: true to preview.',
21361
17327
  {
21362
- amount: external_exports.union([external_exports.number(), external_exports.literal("all")]).describe('Dollar amount to withdraw, or "all"'),
17328
+ amount: external_exports.union([external_exports.number(), external_exports.literal("all")]).describe('Amount to withdraw, or "all"'),
17329
+ asset: external_exports.string().optional().describe("Asset to withdraw (default: auto-selects largest position)"),
21363
17330
  dryRun: external_exports.boolean().optional().describe("Preview without signing (default: false)")
21364
17331
  },
21365
- async ({ amount, dryRun }) => {
17332
+ async ({ amount, asset, dryRun }) => {
21366
17333
  try {
21367
17334
  if (dryRun) {
21368
17335
  agent.enforcer.assertNotLocked();
21369
17336
  const positions = await agent.positions();
21370
17337
  const health = await agent.healthFactor();
21371
- const savings = positions.positions.filter((p) => p.type === "save").reduce((sum, p) => sum + p.amount, 0);
17338
+ const savings = positions.positions.filter((p) => p.type === "save" && (!asset || p.asset === asset)).reduce((sum, p) => sum + p.amount, 0);
21372
17339
  return {
21373
17340
  content: [{
21374
17341
  type: "text",
21375
17342
  text: JSON.stringify({
21376
17343
  preview: true,
21377
17344
  amount: amount === "all" ? savings : amount,
17345
+ asset: asset ?? "auto",
21378
17346
  currentSavings: savings,
21379
17347
  currentHealthFactor: health.healthFactor
21380
17348
  })
21381
17349
  }]
21382
17350
  };
21383
17351
  }
21384
- const result = await mutex.run(() => agent.withdraw({ amount }));
17352
+ const result = await mutex.run(() => agent.withdraw({ amount, asset }));
21385
17353
  return { content: [{ type: "text", text: JSON.stringify(result) }] };
21386
17354
  } catch (err) {
21387
17355
  return errorResult(err);
@@ -21533,6 +17501,54 @@ ${text}`;
21533
17501
  }
21534
17502
  }
21535
17503
  );
17504
+ server.tool(
17505
+ "t2000_swap",
17506
+ "Swap tokens on Sui via Cetus Aggregator (20+ DEXs). Supports any token pair with liquidity. Use user-friendly names (SUI, USDC, CETUS, DEEP, etc.) or full coin types.",
17507
+ {
17508
+ from: external_exports.string().describe('Source token (e.g. "SUI", "USDC", or full coin type)'),
17509
+ to: external_exports.string().describe('Target token (e.g. "USDC", "CETUS", or full coin type)'),
17510
+ amount: external_exports.number().positive().describe("Amount to swap"),
17511
+ slippage: external_exports.number().min(1e-3).max(0.05).optional().describe("Max slippage (default 0.01 = 1%, max 5%)")
17512
+ },
17513
+ async ({ from, to, amount, slippage }) => {
17514
+ try {
17515
+ const result = await mutex.run(() => agent.swap({ from, to, amount, slippage }));
17516
+ return { content: [{ type: "text", text: JSON.stringify(result) }] };
17517
+ } catch (err) {
17518
+ return errorResult(err);
17519
+ }
17520
+ }
17521
+ );
17522
+ server.tool(
17523
+ "t2000_stake",
17524
+ "Stake SUI for vSUI via VOLO liquid staking. Earn ~3-5% APY. Rewards compound automatically via exchange rate. Minimum 1 SUI.",
17525
+ {
17526
+ amount: external_exports.number().min(1).describe("Amount of SUI to stake (minimum 1)")
17527
+ },
17528
+ async ({ amount }) => {
17529
+ try {
17530
+ const result = await mutex.run(() => agent.stakeVSui({ amount }));
17531
+ return { content: [{ type: "text", text: JSON.stringify(result) }] };
17532
+ } catch (err) {
17533
+ return errorResult(err);
17534
+ }
17535
+ }
17536
+ );
17537
+ server.tool(
17538
+ "t2000_unstake",
17539
+ 'Unstake vSUI back to SUI. Returns SUI including accumulated yield. Use amount in vSUI units or "all" to unstake entire position.',
17540
+ {
17541
+ amount: external_exports.union([external_exports.number().positive(), external_exports.literal("all")]).describe('Amount of vSUI to unstake, or "all"')
17542
+ },
17543
+ async ({ amount }) => {
17544
+ try {
17545
+ const result = await mutex.run(() => agent.unstakeVSui({ amount }));
17546
+ return { content: [{ type: "text", text: JSON.stringify(result) }] };
17547
+ } catch (err) {
17548
+ return errorResult(err);
17549
+ }
17550
+ }
17551
+ );
21536
17552
  server.tool(
21537
17553
  "t2000_contact_add",
21538
17554
  'Save a contact name \u2192 Sui address mapping. After saving, use the name with t2000_send instead of pasting addresses. Example: save "Tom" as 0x1234... then send to "Tom".',
@@ -22298,4 +18314,4 @@ async function startMcpServer(opts) {
22298
18314
  export {
22299
18315
  startMcpServer
22300
18316
  };
22301
- //# sourceMappingURL=dist-W4Q4YXD7.js.map
18317
+ //# sourceMappingURL=dist-22NK522A.js.map