sixseconds-modules 1.6.139 → 1.6.140

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.
@@ -0,0 +1,4259 @@
1
+ (function() {
2
+ "use strict";
3
+ try {
4
+ if (typeof document != "undefined") {
5
+ var elementStyle = document.createElement("style");
6
+ elementStyle.appendChild(document.createTextNode('@import url("https://fonts.googleapis.com/css2?family=Inter:wght@100..900&display=swap");\r\n\r\nblockquote,\r\ndl,\r\ndd,\r\nh1,\r\nh2,\r\nh3,\r\nh4,\r\nh5,\r\nh6,\r\nhr,\r\nfigure,\r\np,\r\npre {\r\n font-family: "Inter", serif !important;\r\n}\r\n\r\n/* .MuiDialog-root {\r\n z-index: 999999999 !important;\r\n}\r\n\r\n.MuiModal-root {\r\n z-index: 999999999 !important;\r\n} */\r\n\r\n.main_list_Menu {\r\n display: flex;\r\n}\r\n\r\n.main_list_Menu li {\r\n padding: 0.5rem 0.5rem;\r\n}\r\n\r\n.main_list_Menu li a {\r\n padding: 0 0.25rem;\r\n font-weight: 600;\r\n font-size: 14px;\r\n}\r\n\r\n.main_list_Menu .menu-item {\r\n position: relative;\r\n padding: 15px;\r\n}\r\n\r\n.main_list_Menu .menu-link {\r\n text-decoration: none;\r\n color: #2c2e35;\r\n transition: color 0.3s ease;\r\n}\r\n\r\n.main_list_Menu .menu-link:hover {\r\n color: #2ea3f2;\r\n}\r\n\r\n/* Submenu (Dropdown) */\r\n\r\n.main_list_Menu .submenuData {\r\n position: absolute;\r\n top: 85%;\r\n left: 0;\r\n background: white;\r\n border-top: 3px solid #2ea3f2;\r\n box-shadow: 0px 4px 6px rgba(0, 0, 0, 0.1);\r\n display: none;\r\n min-width: 200px;\r\n z-index: 10;\r\n}\r\n\r\n.main_list_Menu .submenuData li {\r\n list-style: none;\r\n}\r\n\r\n.main_list_Menu .submenu-link {\r\n display: block;\r\n padding: 1px 15px;\r\n text-decoration: none;\r\n color: rgba(0, 0, 0, 0.7);\r\n font-weight: 600;\r\n}\r\n\r\n.main_list_Menu .submenu-link:hover {\r\n background: #f1f1f1;\r\n}\r\n\r\n/* Show dropdown on hover */\r\n\r\n.main_list_Menu .menu-item:hover .submenuData {\r\n display: block;\r\n}\r\n\r\n.smallDeviceMenu {\r\n display: none;\r\n width: 100%;\r\n left: 0;\r\n top: 72px;\r\n background-color: #fff;\r\n position: fixed;\r\n overflow-y: auto;\r\n height: 95vh;\r\n}\r\n\r\n.smallDeviceMenu a.bg_main_menu {\r\n display: block;\r\n text-decoration: none;\r\n}\r\n\r\n.submenu_child li {\r\n padding: 0.5rem 0;\r\n}\r\n\r\n.submenu_child li a {\r\n text-decoration: none;\r\n}\r\n\r\n.layout_mobile_menu {\r\n padding-bottom: 12px;\r\n padding-inline: 0;\r\n height: 95vh;\r\n overflow-y: auto;\r\n padding-top: 8px;\r\n}\r\n\r\n.smallDeviceMenu a {\r\n background-color: rgba(0, 0, 0, 0.03);\r\n font-size: 15px;\r\n font-weight: 600;\r\n color: #2c2e35;\r\n margin-bottom: 4px;\r\n padding: 12px 8px;\r\n}\r\n\r\n.smallDeviceMenu .submenu_child {\r\n padding-left: 0px;\r\n min-width: 90%;\r\n max-width: 90%;\r\n top: 57px;\r\n margin-top: 8px;\r\n background-color: #fff;\r\n color: #000;\r\n margin-inline: auto;\r\n}\r\n\r\n.smallDeviceMenu ul li .submenu_child_link {\r\n padding: 12px 20px;\r\n}\r\n\r\n.smallDeviceMenu ul li a {\r\n background-color: transparent;\r\n color: #000000b3;\r\n}\r\n\r\n.smallDeviceMenu ul {\r\n padding-left: 15px;\r\n}\r\n\r\n.desktopMenu {\r\n display: flex;\r\n}\r\n\r\n.button_hamburger {\r\n display: none;\r\n position: absolute;\r\n right: 20px;\r\n top: 25px;\r\n z-index: 9;\r\n}\r\n\r\n.tox-editor-header {\r\n background-color: transparent;\r\n}\r\n\r\n.hamburger-icon-btn {\r\n padding: 8px;\r\n color: rgba(0, 0, 0, 0.54);\r\n}\r\n\r\n.desktopMenu .menu-item .menu-link {\r\n font-size: 15px;\r\n}\r\n\r\n.smallDeviceMenu {\r\n padding-inline: 20px;\r\n}\r\n\r\n@media screen and (max-width: 600px) and (min-width: 320px) {\r\n .notification_icon_error .MuiBadge-badge {\r\n font-size: 11px;\r\n padding: 0 3px;\r\n min-width: 16px;\r\n right: 5px;\r\n }\r\n\r\n .submenu nav {\r\n padding: 0 !important;\r\n }\r\n\r\n .MuiPagination-root.MuiPagination-outlined {\r\n /* margin-top: 10px; */\r\n display: flex;\r\n justify-content: center;\r\n margin-left: 0;\r\n }\r\n\r\n .toogle_btn_menu {\r\n position: absolute;\r\n right: 20px;\r\n top: 18px;\r\n z-index: 99;\r\n }\r\n\r\n .right_header_icons {\r\n padding-right: 25px;\r\n }\r\n\r\n .button_hamburger {\r\n display: block;\r\n }\r\n\r\n .desktopMenu {\r\n display: none;\r\n }\r\n\r\n .smallDeviceMenu {\r\n display: block;\r\n width: 100%;\r\n position: fixed;\r\n left: 0;\r\n background: #fff;\r\n top: 69px;\r\n }\r\n\r\n .main.login_page .loginBody {\r\n width: 400px !important;\r\n }\r\n\r\n .submenu {\r\n width: 100%;\r\n max-width: 100% !important;\r\n }\r\n\r\n .sideBar {\r\n width: 300px !important;\r\n background-color: #fff;\r\n z-index: 99;\r\n }\r\n\r\n .sideMenu {\r\n width: 300px;\r\n background-color: #fff;\r\n }\r\n\r\n .logo_header {\r\n opacity: 1;\r\n }\r\n\r\n .profile .headerMenu {\r\n min-width: 320px;\r\n width: 500px !important;\r\n }\r\n}\r\n\r\n@media screen and (max-width: 1024px) and (min-width: 600px) {\r\n .toogle_btn_menu {\r\n position: absolute;\r\n right: 20px;\r\n top: 18px;\r\n }\r\n\r\n .right_header_icons {\r\n padding-right: 25px;\r\n }\r\n\r\n .button_hamburger {\r\n display: block;\r\n }\r\n\r\n .desktopMenu {\r\n display: none;\r\n }\r\n\r\n .smallDeviceMenu {\r\n display: block;\r\n }\r\n\r\n .main.login_page .loginBody {\r\n width: 500px !important;\r\n }\r\n\r\n .banner {\r\n margin-left: 0 !important;\r\n }\r\n\r\n .submenu {\r\n width: 100%;\r\n max-width: 100% !important;\r\n }\r\n\r\n .sideBar {\r\n width: 300px !important;\r\n background-color: #fff;\r\n z-index: 99;\r\n }\r\n\r\n .sideMenu {\r\n width: 300px;\r\n background-color: #fff;\r\n }\r\n\r\n .logo_header {\r\n opacity: 1;\r\n }\r\n\r\n .profile .headerMenu {\r\n min-width: 320px;\r\n width: 500px !important;\r\n }\r\n}\r\n\r\n@media screen and (max-width: 1380px) and (min-width: 1024px) {\r\n .right_header_icons {\r\n padding-right: 25px;\r\n }\r\n\r\n .button_hamburger {\r\n display: block;\r\n }\r\n\r\n .desktopMenu {\r\n display: none;\r\n }\r\n\r\n .smallDeviceMenu {\r\n display: block;\r\n width: 100%;\r\n position: fixed;\r\n left: 0;\r\n background: #fff;\r\n top: 72px;\r\n }\r\n\r\n .button_hamburger {\r\n display: block;\r\n }\r\n\r\n .right_header_icons {\r\n padding-right: 25px;\r\n }\r\n}'));
7
+ document.head.appendChild(elementStyle);
8
+ }
9
+ } catch (e) {
10
+ console.error("vite-plugin-css-injected-by-js", e);
11
+ }
12
+ })();
13
+ "use strict";
14
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
15
+ function createEnv(opts) {
16
+ const runtimeEnv = opts.runtimeEnvStrict ?? opts.runtimeEnv ?? process.env;
17
+ const emptyStringAsUndefined = opts.emptyStringAsUndefined ?? false;
18
+ if (emptyStringAsUndefined) {
19
+ for (const [key, value] of Object.entries(runtimeEnv)) if (value === "") delete runtimeEnv[key];
20
+ }
21
+ return runtimeEnv;
22
+ }
23
+ var util;
24
+ (function(util2) {
25
+ util2.assertEqual = (val) => val;
26
+ function assertIs(_arg) {
27
+ }
28
+ util2.assertIs = assertIs;
29
+ function assertNever(_x) {
30
+ throw new Error();
31
+ }
32
+ util2.assertNever = assertNever;
33
+ util2.arrayToEnum = (items) => {
34
+ const obj = {};
35
+ for (const item of items) {
36
+ obj[item] = item;
37
+ }
38
+ return obj;
39
+ };
40
+ util2.getValidEnumValues = (obj) => {
41
+ const validKeys = util2.objectKeys(obj).filter((k) => typeof obj[obj[k]] !== "number");
42
+ const filtered = {};
43
+ for (const k of validKeys) {
44
+ filtered[k] = obj[k];
45
+ }
46
+ return util2.objectValues(filtered);
47
+ };
48
+ util2.objectValues = (obj) => {
49
+ return util2.objectKeys(obj).map(function(e) {
50
+ return obj[e];
51
+ });
52
+ };
53
+ util2.objectKeys = typeof Object.keys === "function" ? (obj) => Object.keys(obj) : (object) => {
54
+ const keys = [];
55
+ for (const key in object) {
56
+ if (Object.prototype.hasOwnProperty.call(object, key)) {
57
+ keys.push(key);
58
+ }
59
+ }
60
+ return keys;
61
+ };
62
+ util2.find = (arr, checker) => {
63
+ for (const item of arr) {
64
+ if (checker(item))
65
+ return item;
66
+ }
67
+ return void 0;
68
+ };
69
+ util2.isInteger = typeof Number.isInteger === "function" ? (val) => Number.isInteger(val) : (val) => typeof val === "number" && isFinite(val) && Math.floor(val) === val;
70
+ function joinValues(array, separator = " | ") {
71
+ return array.map((val) => typeof val === "string" ? `'${val}'` : val).join(separator);
72
+ }
73
+ util2.joinValues = joinValues;
74
+ util2.jsonStringifyReplacer = (_, value) => {
75
+ if (typeof value === "bigint") {
76
+ return value.toString();
77
+ }
78
+ return value;
79
+ };
80
+ })(util || (util = {}));
81
+ var objectUtil;
82
+ (function(objectUtil2) {
83
+ objectUtil2.mergeShapes = (first, second) => {
84
+ return {
85
+ ...first,
86
+ ...second
87
+ // second overwrites first
88
+ };
89
+ };
90
+ })(objectUtil || (objectUtil = {}));
91
+ const ZodParsedType = util.arrayToEnum([
92
+ "string",
93
+ "nan",
94
+ "number",
95
+ "integer",
96
+ "float",
97
+ "boolean",
98
+ "date",
99
+ "bigint",
100
+ "symbol",
101
+ "function",
102
+ "undefined",
103
+ "null",
104
+ "array",
105
+ "object",
106
+ "unknown",
107
+ "promise",
108
+ "void",
109
+ "never",
110
+ "map",
111
+ "set"
112
+ ]);
113
+ const getParsedType = (data) => {
114
+ const t = typeof data;
115
+ switch (t) {
116
+ case "undefined":
117
+ return ZodParsedType.undefined;
118
+ case "string":
119
+ return ZodParsedType.string;
120
+ case "number":
121
+ return isNaN(data) ? ZodParsedType.nan : ZodParsedType.number;
122
+ case "boolean":
123
+ return ZodParsedType.boolean;
124
+ case "function":
125
+ return ZodParsedType.function;
126
+ case "bigint":
127
+ return ZodParsedType.bigint;
128
+ case "symbol":
129
+ return ZodParsedType.symbol;
130
+ case "object":
131
+ if (Array.isArray(data)) {
132
+ return ZodParsedType.array;
133
+ }
134
+ if (data === null) {
135
+ return ZodParsedType.null;
136
+ }
137
+ if (data.then && typeof data.then === "function" && data.catch && typeof data.catch === "function") {
138
+ return ZodParsedType.promise;
139
+ }
140
+ if (typeof Map !== "undefined" && data instanceof Map) {
141
+ return ZodParsedType.map;
142
+ }
143
+ if (typeof Set !== "undefined" && data instanceof Set) {
144
+ return ZodParsedType.set;
145
+ }
146
+ if (typeof Date !== "undefined" && data instanceof Date) {
147
+ return ZodParsedType.date;
148
+ }
149
+ return ZodParsedType.object;
150
+ default:
151
+ return ZodParsedType.unknown;
152
+ }
153
+ };
154
+ const ZodIssueCode = util.arrayToEnum([
155
+ "invalid_type",
156
+ "invalid_literal",
157
+ "custom",
158
+ "invalid_union",
159
+ "invalid_union_discriminator",
160
+ "invalid_enum_value",
161
+ "unrecognized_keys",
162
+ "invalid_arguments",
163
+ "invalid_return_type",
164
+ "invalid_date",
165
+ "invalid_string",
166
+ "too_small",
167
+ "too_big",
168
+ "invalid_intersection_types",
169
+ "not_multiple_of",
170
+ "not_finite"
171
+ ]);
172
+ const quotelessJson = (obj) => {
173
+ const json = JSON.stringify(obj, null, 2);
174
+ return json.replace(/"([^"]+)":/g, "$1:");
175
+ };
176
+ class ZodError extends Error {
177
+ get errors() {
178
+ return this.issues;
179
+ }
180
+ constructor(issues) {
181
+ super();
182
+ this.issues = [];
183
+ this.addIssue = (sub) => {
184
+ this.issues = [...this.issues, sub];
185
+ };
186
+ this.addIssues = (subs = []) => {
187
+ this.issues = [...this.issues, ...subs];
188
+ };
189
+ const actualProto = new.target.prototype;
190
+ if (Object.setPrototypeOf) {
191
+ Object.setPrototypeOf(this, actualProto);
192
+ } else {
193
+ this.__proto__ = actualProto;
194
+ }
195
+ this.name = "ZodError";
196
+ this.issues = issues;
197
+ }
198
+ format(_mapper) {
199
+ const mapper = _mapper || function(issue) {
200
+ return issue.message;
201
+ };
202
+ const fieldErrors = { _errors: [] };
203
+ const processError = (error) => {
204
+ for (const issue of error.issues) {
205
+ if (issue.code === "invalid_union") {
206
+ issue.unionErrors.map(processError);
207
+ } else if (issue.code === "invalid_return_type") {
208
+ processError(issue.returnTypeError);
209
+ } else if (issue.code === "invalid_arguments") {
210
+ processError(issue.argumentsError);
211
+ } else if (issue.path.length === 0) {
212
+ fieldErrors._errors.push(mapper(issue));
213
+ } else {
214
+ let curr = fieldErrors;
215
+ let i = 0;
216
+ while (i < issue.path.length) {
217
+ const el = issue.path[i];
218
+ const terminal = i === issue.path.length - 1;
219
+ if (!terminal) {
220
+ curr[el] = curr[el] || { _errors: [] };
221
+ } else {
222
+ curr[el] = curr[el] || { _errors: [] };
223
+ curr[el]._errors.push(mapper(issue));
224
+ }
225
+ curr = curr[el];
226
+ i++;
227
+ }
228
+ }
229
+ }
230
+ };
231
+ processError(this);
232
+ return fieldErrors;
233
+ }
234
+ static assert(value) {
235
+ if (!(value instanceof ZodError)) {
236
+ throw new Error(`Not a ZodError: ${value}`);
237
+ }
238
+ }
239
+ toString() {
240
+ return this.message;
241
+ }
242
+ get message() {
243
+ return JSON.stringify(this.issues, util.jsonStringifyReplacer, 2);
244
+ }
245
+ get isEmpty() {
246
+ return this.issues.length === 0;
247
+ }
248
+ flatten(mapper = (issue) => issue.message) {
249
+ const fieldErrors = {};
250
+ const formErrors = [];
251
+ for (const sub of this.issues) {
252
+ if (sub.path.length > 0) {
253
+ fieldErrors[sub.path[0]] = fieldErrors[sub.path[0]] || [];
254
+ fieldErrors[sub.path[0]].push(mapper(sub));
255
+ } else {
256
+ formErrors.push(mapper(sub));
257
+ }
258
+ }
259
+ return { formErrors, fieldErrors };
260
+ }
261
+ get formErrors() {
262
+ return this.flatten();
263
+ }
264
+ }
265
+ ZodError.create = (issues) => {
266
+ const error = new ZodError(issues);
267
+ return error;
268
+ };
269
+ const errorMap = (issue, _ctx) => {
270
+ let message;
271
+ switch (issue.code) {
272
+ case ZodIssueCode.invalid_type:
273
+ if (issue.received === ZodParsedType.undefined) {
274
+ message = "Required";
275
+ } else {
276
+ message = `Expected ${issue.expected}, received ${issue.received}`;
277
+ }
278
+ break;
279
+ case ZodIssueCode.invalid_literal:
280
+ message = `Invalid literal value, expected ${JSON.stringify(issue.expected, util.jsonStringifyReplacer)}`;
281
+ break;
282
+ case ZodIssueCode.unrecognized_keys:
283
+ message = `Unrecognized key(s) in object: ${util.joinValues(issue.keys, ", ")}`;
284
+ break;
285
+ case ZodIssueCode.invalid_union:
286
+ message = `Invalid input`;
287
+ break;
288
+ case ZodIssueCode.invalid_union_discriminator:
289
+ message = `Invalid discriminator value. Expected ${util.joinValues(issue.options)}`;
290
+ break;
291
+ case ZodIssueCode.invalid_enum_value:
292
+ message = `Invalid enum value. Expected ${util.joinValues(issue.options)}, received '${issue.received}'`;
293
+ break;
294
+ case ZodIssueCode.invalid_arguments:
295
+ message = `Invalid function arguments`;
296
+ break;
297
+ case ZodIssueCode.invalid_return_type:
298
+ message = `Invalid function return type`;
299
+ break;
300
+ case ZodIssueCode.invalid_date:
301
+ message = `Invalid date`;
302
+ break;
303
+ case ZodIssueCode.invalid_string:
304
+ if (typeof issue.validation === "object") {
305
+ if ("includes" in issue.validation) {
306
+ message = `Invalid input: must include "${issue.validation.includes}"`;
307
+ if (typeof issue.validation.position === "number") {
308
+ message = `${message} at one or more positions greater than or equal to ${issue.validation.position}`;
309
+ }
310
+ } else if ("startsWith" in issue.validation) {
311
+ message = `Invalid input: must start with "${issue.validation.startsWith}"`;
312
+ } else if ("endsWith" in issue.validation) {
313
+ message = `Invalid input: must end with "${issue.validation.endsWith}"`;
314
+ } else {
315
+ util.assertNever(issue.validation);
316
+ }
317
+ } else if (issue.validation !== "regex") {
318
+ message = `Invalid ${issue.validation}`;
319
+ } else {
320
+ message = "Invalid";
321
+ }
322
+ break;
323
+ case ZodIssueCode.too_small:
324
+ if (issue.type === "array")
325
+ message = `Array must contain ${issue.exact ? "exactly" : issue.inclusive ? `at least` : `more than`} ${issue.minimum} element(s)`;
326
+ else if (issue.type === "string")
327
+ message = `String must contain ${issue.exact ? "exactly" : issue.inclusive ? `at least` : `over`} ${issue.minimum} character(s)`;
328
+ else if (issue.type === "number")
329
+ message = `Number must be ${issue.exact ? `exactly equal to ` : issue.inclusive ? `greater than or equal to ` : `greater than `}${issue.minimum}`;
330
+ else if (issue.type === "date")
331
+ message = `Date must be ${issue.exact ? `exactly equal to ` : issue.inclusive ? `greater than or equal to ` : `greater than `}${new Date(Number(issue.minimum))}`;
332
+ else
333
+ message = "Invalid input";
334
+ break;
335
+ case ZodIssueCode.too_big:
336
+ if (issue.type === "array")
337
+ message = `Array must contain ${issue.exact ? `exactly` : issue.inclusive ? `at most` : `less than`} ${issue.maximum} element(s)`;
338
+ else if (issue.type === "string")
339
+ message = `String must contain ${issue.exact ? `exactly` : issue.inclusive ? `at most` : `under`} ${issue.maximum} character(s)`;
340
+ else if (issue.type === "number")
341
+ message = `Number must be ${issue.exact ? `exactly` : issue.inclusive ? `less than or equal to` : `less than`} ${issue.maximum}`;
342
+ else if (issue.type === "bigint")
343
+ message = `BigInt must be ${issue.exact ? `exactly` : issue.inclusive ? `less than or equal to` : `less than`} ${issue.maximum}`;
344
+ else if (issue.type === "date")
345
+ message = `Date must be ${issue.exact ? `exactly` : issue.inclusive ? `smaller than or equal to` : `smaller than`} ${new Date(Number(issue.maximum))}`;
346
+ else
347
+ message = "Invalid input";
348
+ break;
349
+ case ZodIssueCode.custom:
350
+ message = `Invalid input`;
351
+ break;
352
+ case ZodIssueCode.invalid_intersection_types:
353
+ message = `Intersection results could not be merged`;
354
+ break;
355
+ case ZodIssueCode.not_multiple_of:
356
+ message = `Number must be a multiple of ${issue.multipleOf}`;
357
+ break;
358
+ case ZodIssueCode.not_finite:
359
+ message = "Number must be finite";
360
+ break;
361
+ default:
362
+ message = _ctx.defaultError;
363
+ util.assertNever(issue);
364
+ }
365
+ return { message };
366
+ };
367
+ let overrideErrorMap = errorMap;
368
+ function setErrorMap(map) {
369
+ overrideErrorMap = map;
370
+ }
371
+ function getErrorMap() {
372
+ return overrideErrorMap;
373
+ }
374
+ const makeIssue = (params) => {
375
+ const { data, path, errorMaps, issueData } = params;
376
+ const fullPath = [...path, ...issueData.path || []];
377
+ const fullIssue = {
378
+ ...issueData,
379
+ path: fullPath
380
+ };
381
+ if (issueData.message !== void 0) {
382
+ return {
383
+ ...issueData,
384
+ path: fullPath,
385
+ message: issueData.message
386
+ };
387
+ }
388
+ let errorMessage = "";
389
+ const maps = errorMaps.filter((m) => !!m).slice().reverse();
390
+ for (const map of maps) {
391
+ errorMessage = map(fullIssue, { data, defaultError: errorMessage }).message;
392
+ }
393
+ return {
394
+ ...issueData,
395
+ path: fullPath,
396
+ message: errorMessage
397
+ };
398
+ };
399
+ const EMPTY_PATH = [];
400
+ function addIssueToContext(ctx, issueData) {
401
+ const overrideMap = getErrorMap();
402
+ const issue = makeIssue({
403
+ issueData,
404
+ data: ctx.data,
405
+ path: ctx.path,
406
+ errorMaps: [
407
+ ctx.common.contextualErrorMap,
408
+ // contextual error map is first priority
409
+ ctx.schemaErrorMap,
410
+ // then schema-bound map if available
411
+ overrideMap,
412
+ // then global override map
413
+ overrideMap === errorMap ? void 0 : errorMap
414
+ // then global default map
415
+ ].filter((x) => !!x)
416
+ });
417
+ ctx.common.issues.push(issue);
418
+ }
419
+ class ParseStatus {
420
+ constructor() {
421
+ this.value = "valid";
422
+ }
423
+ dirty() {
424
+ if (this.value === "valid")
425
+ this.value = "dirty";
426
+ }
427
+ abort() {
428
+ if (this.value !== "aborted")
429
+ this.value = "aborted";
430
+ }
431
+ static mergeArray(status, results) {
432
+ const arrayValue = [];
433
+ for (const s of results) {
434
+ if (s.status === "aborted")
435
+ return INVALID;
436
+ if (s.status === "dirty")
437
+ status.dirty();
438
+ arrayValue.push(s.value);
439
+ }
440
+ return { status: status.value, value: arrayValue };
441
+ }
442
+ static async mergeObjectAsync(status, pairs) {
443
+ const syncPairs = [];
444
+ for (const pair of pairs) {
445
+ const key = await pair.key;
446
+ const value = await pair.value;
447
+ syncPairs.push({
448
+ key,
449
+ value
450
+ });
451
+ }
452
+ return ParseStatus.mergeObjectSync(status, syncPairs);
453
+ }
454
+ static mergeObjectSync(status, pairs) {
455
+ const finalObject = {};
456
+ for (const pair of pairs) {
457
+ const { key, value } = pair;
458
+ if (key.status === "aborted")
459
+ return INVALID;
460
+ if (value.status === "aborted")
461
+ return INVALID;
462
+ if (key.status === "dirty")
463
+ status.dirty();
464
+ if (value.status === "dirty")
465
+ status.dirty();
466
+ if (key.value !== "__proto__" && (typeof value.value !== "undefined" || pair.alwaysSet)) {
467
+ finalObject[key.value] = value.value;
468
+ }
469
+ }
470
+ return { status: status.value, value: finalObject };
471
+ }
472
+ }
473
+ const INVALID = Object.freeze({
474
+ status: "aborted"
475
+ });
476
+ const DIRTY = (value) => ({ status: "dirty", value });
477
+ const OK = (value) => ({ status: "valid", value });
478
+ const isAborted = (x) => x.status === "aborted";
479
+ const isDirty = (x) => x.status === "dirty";
480
+ const isValid = (x) => x.status === "valid";
481
+ const isAsync = (x) => typeof Promise !== "undefined" && x instanceof Promise;
482
+ function __classPrivateFieldGet(receiver, state, kind, f) {
483
+ if (typeof state === "function" ? receiver !== state || true : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
484
+ return state.get(receiver);
485
+ }
486
+ function __classPrivateFieldSet(receiver, state, value, kind, f) {
487
+ if (typeof state === "function" ? receiver !== state || true : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
488
+ return state.set(receiver, value), value;
489
+ }
490
+ typeof SuppressedError === "function" ? SuppressedError : function(error, suppressed, message) {
491
+ var e = new Error(message);
492
+ return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
493
+ };
494
+ var errorUtil;
495
+ (function(errorUtil2) {
496
+ errorUtil2.errToObj = (message) => typeof message === "string" ? { message } : message || {};
497
+ errorUtil2.toString = (message) => typeof message === "string" ? message : message === null || message === void 0 ? void 0 : message.message;
498
+ })(errorUtil || (errorUtil = {}));
499
+ var _ZodEnum_cache, _ZodNativeEnum_cache;
500
+ class ParseInputLazyPath {
501
+ constructor(parent, value, path, key) {
502
+ this._cachedPath = [];
503
+ this.parent = parent;
504
+ this.data = value;
505
+ this._path = path;
506
+ this._key = key;
507
+ }
508
+ get path() {
509
+ if (!this._cachedPath.length) {
510
+ if (this._key instanceof Array) {
511
+ this._cachedPath.push(...this._path, ...this._key);
512
+ } else {
513
+ this._cachedPath.push(...this._path, this._key);
514
+ }
515
+ }
516
+ return this._cachedPath;
517
+ }
518
+ }
519
+ const handleResult = (ctx, result) => {
520
+ if (isValid(result)) {
521
+ return { success: true, data: result.value };
522
+ } else {
523
+ if (!ctx.common.issues.length) {
524
+ throw new Error("Validation failed but no issues detected.");
525
+ }
526
+ return {
527
+ success: false,
528
+ get error() {
529
+ if (this._error)
530
+ return this._error;
531
+ const error = new ZodError(ctx.common.issues);
532
+ this._error = error;
533
+ return this._error;
534
+ }
535
+ };
536
+ }
537
+ };
538
+ function processCreateParams(params) {
539
+ if (!params)
540
+ return {};
541
+ const { errorMap: errorMap2, invalid_type_error, required_error, description } = params;
542
+ if (errorMap2 && (invalid_type_error || required_error)) {
543
+ throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);
544
+ }
545
+ if (errorMap2)
546
+ return { errorMap: errorMap2, description };
547
+ const customMap = (iss, ctx) => {
548
+ var _a, _b;
549
+ const { message } = params;
550
+ if (iss.code === "invalid_enum_value") {
551
+ return { message: message !== null && message !== void 0 ? message : ctx.defaultError };
552
+ }
553
+ if (typeof ctx.data === "undefined") {
554
+ return { message: (_a = message !== null && message !== void 0 ? message : required_error) !== null && _a !== void 0 ? _a : ctx.defaultError };
555
+ }
556
+ if (iss.code !== "invalid_type")
557
+ return { message: ctx.defaultError };
558
+ return { message: (_b = message !== null && message !== void 0 ? message : invalid_type_error) !== null && _b !== void 0 ? _b : ctx.defaultError };
559
+ };
560
+ return { errorMap: customMap, description };
561
+ }
562
+ class ZodType {
563
+ get description() {
564
+ return this._def.description;
565
+ }
566
+ _getType(input) {
567
+ return getParsedType(input.data);
568
+ }
569
+ _getOrReturnCtx(input, ctx) {
570
+ return ctx || {
571
+ common: input.parent.common,
572
+ data: input.data,
573
+ parsedType: getParsedType(input.data),
574
+ schemaErrorMap: this._def.errorMap,
575
+ path: input.path,
576
+ parent: input.parent
577
+ };
578
+ }
579
+ _processInputParams(input) {
580
+ return {
581
+ status: new ParseStatus(),
582
+ ctx: {
583
+ common: input.parent.common,
584
+ data: input.data,
585
+ parsedType: getParsedType(input.data),
586
+ schemaErrorMap: this._def.errorMap,
587
+ path: input.path,
588
+ parent: input.parent
589
+ }
590
+ };
591
+ }
592
+ _parseSync(input) {
593
+ const result = this._parse(input);
594
+ if (isAsync(result)) {
595
+ throw new Error("Synchronous parse encountered promise.");
596
+ }
597
+ return result;
598
+ }
599
+ _parseAsync(input) {
600
+ const result = this._parse(input);
601
+ return Promise.resolve(result);
602
+ }
603
+ parse(data, params) {
604
+ const result = this.safeParse(data, params);
605
+ if (result.success)
606
+ return result.data;
607
+ throw result.error;
608
+ }
609
+ safeParse(data, params) {
610
+ var _a;
611
+ const ctx = {
612
+ common: {
613
+ issues: [],
614
+ async: (_a = params === null || params === void 0 ? void 0 : params.async) !== null && _a !== void 0 ? _a : false,
615
+ contextualErrorMap: params === null || params === void 0 ? void 0 : params.errorMap
616
+ },
617
+ path: (params === null || params === void 0 ? void 0 : params.path) || [],
618
+ schemaErrorMap: this._def.errorMap,
619
+ parent: null,
620
+ data,
621
+ parsedType: getParsedType(data)
622
+ };
623
+ const result = this._parseSync({ data, path: ctx.path, parent: ctx });
624
+ return handleResult(ctx, result);
625
+ }
626
+ "~validate"(data) {
627
+ var _a, _b;
628
+ const ctx = {
629
+ common: {
630
+ issues: [],
631
+ async: !!this["~standard"].async
632
+ },
633
+ path: [],
634
+ schemaErrorMap: this._def.errorMap,
635
+ parent: null,
636
+ data,
637
+ parsedType: getParsedType(data)
638
+ };
639
+ if (!this["~standard"].async) {
640
+ try {
641
+ const result = this._parseSync({ data, path: [], parent: ctx });
642
+ return isValid(result) ? {
643
+ value: result.value
644
+ } : {
645
+ issues: ctx.common.issues
646
+ };
647
+ } catch (err) {
648
+ if ((_b = (_a = err === null || err === void 0 ? void 0 : err.message) === null || _a === void 0 ? void 0 : _a.toLowerCase()) === null || _b === void 0 ? void 0 : _b.includes("encountered")) {
649
+ this["~standard"].async = true;
650
+ }
651
+ ctx.common = {
652
+ issues: [],
653
+ async: true
654
+ };
655
+ }
656
+ }
657
+ return this._parseAsync({ data, path: [], parent: ctx }).then((result) => isValid(result) ? {
658
+ value: result.value
659
+ } : {
660
+ issues: ctx.common.issues
661
+ });
662
+ }
663
+ async parseAsync(data, params) {
664
+ const result = await this.safeParseAsync(data, params);
665
+ if (result.success)
666
+ return result.data;
667
+ throw result.error;
668
+ }
669
+ async safeParseAsync(data, params) {
670
+ const ctx = {
671
+ common: {
672
+ issues: [],
673
+ contextualErrorMap: params === null || params === void 0 ? void 0 : params.errorMap,
674
+ async: true
675
+ },
676
+ path: (params === null || params === void 0 ? void 0 : params.path) || [],
677
+ schemaErrorMap: this._def.errorMap,
678
+ parent: null,
679
+ data,
680
+ parsedType: getParsedType(data)
681
+ };
682
+ const maybeAsyncResult = this._parse({ data, path: ctx.path, parent: ctx });
683
+ const result = await (isAsync(maybeAsyncResult) ? maybeAsyncResult : Promise.resolve(maybeAsyncResult));
684
+ return handleResult(ctx, result);
685
+ }
686
+ refine(check, message) {
687
+ const getIssueProperties = (val) => {
688
+ if (typeof message === "string" || typeof message === "undefined") {
689
+ return { message };
690
+ } else if (typeof message === "function") {
691
+ return message(val);
692
+ } else {
693
+ return message;
694
+ }
695
+ };
696
+ return this._refinement((val, ctx) => {
697
+ const result = check(val);
698
+ const setError = () => ctx.addIssue({
699
+ code: ZodIssueCode.custom,
700
+ ...getIssueProperties(val)
701
+ });
702
+ if (typeof Promise !== "undefined" && result instanceof Promise) {
703
+ return result.then((data) => {
704
+ if (!data) {
705
+ setError();
706
+ return false;
707
+ } else {
708
+ return true;
709
+ }
710
+ });
711
+ }
712
+ if (!result) {
713
+ setError();
714
+ return false;
715
+ } else {
716
+ return true;
717
+ }
718
+ });
719
+ }
720
+ refinement(check, refinementData) {
721
+ return this._refinement((val, ctx) => {
722
+ if (!check(val)) {
723
+ ctx.addIssue(typeof refinementData === "function" ? refinementData(val, ctx) : refinementData);
724
+ return false;
725
+ } else {
726
+ return true;
727
+ }
728
+ });
729
+ }
730
+ _refinement(refinement) {
731
+ return new ZodEffects({
732
+ schema: this,
733
+ typeName: ZodFirstPartyTypeKind.ZodEffects,
734
+ effect: { type: "refinement", refinement }
735
+ });
736
+ }
737
+ superRefine(refinement) {
738
+ return this._refinement(refinement);
739
+ }
740
+ constructor(def) {
741
+ this.spa = this.safeParseAsync;
742
+ this._def = def;
743
+ this.parse = this.parse.bind(this);
744
+ this.safeParse = this.safeParse.bind(this);
745
+ this.parseAsync = this.parseAsync.bind(this);
746
+ this.safeParseAsync = this.safeParseAsync.bind(this);
747
+ this.spa = this.spa.bind(this);
748
+ this.refine = this.refine.bind(this);
749
+ this.refinement = this.refinement.bind(this);
750
+ this.superRefine = this.superRefine.bind(this);
751
+ this.optional = this.optional.bind(this);
752
+ this.nullable = this.nullable.bind(this);
753
+ this.nullish = this.nullish.bind(this);
754
+ this.array = this.array.bind(this);
755
+ this.promise = this.promise.bind(this);
756
+ this.or = this.or.bind(this);
757
+ this.and = this.and.bind(this);
758
+ this.transform = this.transform.bind(this);
759
+ this.brand = this.brand.bind(this);
760
+ this.default = this.default.bind(this);
761
+ this.catch = this.catch.bind(this);
762
+ this.describe = this.describe.bind(this);
763
+ this.pipe = this.pipe.bind(this);
764
+ this.readonly = this.readonly.bind(this);
765
+ this.isNullable = this.isNullable.bind(this);
766
+ this.isOptional = this.isOptional.bind(this);
767
+ this["~standard"] = {
768
+ version: 1,
769
+ vendor: "zod",
770
+ validate: (data) => this["~validate"](data)
771
+ };
772
+ }
773
+ optional() {
774
+ return ZodOptional.create(this, this._def);
775
+ }
776
+ nullable() {
777
+ return ZodNullable.create(this, this._def);
778
+ }
779
+ nullish() {
780
+ return this.nullable().optional();
781
+ }
782
+ array() {
783
+ return ZodArray.create(this);
784
+ }
785
+ promise() {
786
+ return ZodPromise.create(this, this._def);
787
+ }
788
+ or(option) {
789
+ return ZodUnion.create([this, option], this._def);
790
+ }
791
+ and(incoming) {
792
+ return ZodIntersection.create(this, incoming, this._def);
793
+ }
794
+ transform(transform) {
795
+ return new ZodEffects({
796
+ ...processCreateParams(this._def),
797
+ schema: this,
798
+ typeName: ZodFirstPartyTypeKind.ZodEffects,
799
+ effect: { type: "transform", transform }
800
+ });
801
+ }
802
+ default(def) {
803
+ const defaultValueFunc = typeof def === "function" ? def : () => def;
804
+ return new ZodDefault({
805
+ ...processCreateParams(this._def),
806
+ innerType: this,
807
+ defaultValue: defaultValueFunc,
808
+ typeName: ZodFirstPartyTypeKind.ZodDefault
809
+ });
810
+ }
811
+ brand() {
812
+ return new ZodBranded({
813
+ typeName: ZodFirstPartyTypeKind.ZodBranded,
814
+ type: this,
815
+ ...processCreateParams(this._def)
816
+ });
817
+ }
818
+ catch(def) {
819
+ const catchValueFunc = typeof def === "function" ? def : () => def;
820
+ return new ZodCatch({
821
+ ...processCreateParams(this._def),
822
+ innerType: this,
823
+ catchValue: catchValueFunc,
824
+ typeName: ZodFirstPartyTypeKind.ZodCatch
825
+ });
826
+ }
827
+ describe(description) {
828
+ const This = this.constructor;
829
+ return new This({
830
+ ...this._def,
831
+ description
832
+ });
833
+ }
834
+ pipe(target) {
835
+ return ZodPipeline.create(this, target);
836
+ }
837
+ readonly() {
838
+ return ZodReadonly.create(this);
839
+ }
840
+ isOptional() {
841
+ return this.safeParse(void 0).success;
842
+ }
843
+ isNullable() {
844
+ return this.safeParse(null).success;
845
+ }
846
+ }
847
+ const cuidRegex = /^c[^\s-]{8,}$/i;
848
+ const cuid2Regex = /^[0-9a-z]+$/;
849
+ const ulidRegex = /^[0-9A-HJKMNP-TV-Z]{26}$/i;
850
+ const 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;
851
+ const nanoidRegex = /^[a-z0-9_-]{21}$/i;
852
+ const jwtRegex = /^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/;
853
+ const 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)?)??$/;
854
+ const emailRegex = /^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i;
855
+ const _emojiRegex = `^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$`;
856
+ let emojiRegex;
857
+ const 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])$/;
858
+ const 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])$/;
859
+ const 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]))$/;
860
+ const 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])$/;
861
+ const base64Regex = /^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/;
862
+ const base64urlRegex = /^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/;
863
+ const 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])))`;
864
+ const dateRegex = new RegExp(`^${dateRegexSource}$`);
865
+ function timeRegexSource(args) {
866
+ let secondsRegexSource = `[0-5]\\d`;
867
+ if (args.precision) {
868
+ secondsRegexSource = `${secondsRegexSource}\\.\\d{${args.precision}}`;
869
+ } else if (args.precision == null) {
870
+ secondsRegexSource = `${secondsRegexSource}(\\.\\d+)?`;
871
+ }
872
+ const secondsQuantifier = args.precision ? "+" : "?";
873
+ return `([01]\\d|2[0-3]):[0-5]\\d(:${secondsRegexSource})${secondsQuantifier}`;
874
+ }
875
+ function timeRegex(args) {
876
+ return new RegExp(`^${timeRegexSource(args)}$`);
877
+ }
878
+ function datetimeRegex(args) {
879
+ let regex = `${dateRegexSource}T${timeRegexSource(args)}`;
880
+ const opts = [];
881
+ opts.push(args.local ? `Z?` : `Z`);
882
+ if (args.offset)
883
+ opts.push(`([+-]\\d{2}:?\\d{2})`);
884
+ regex = `${regex}(${opts.join("|")})`;
885
+ return new RegExp(`^${regex}$`);
886
+ }
887
+ function isValidIP(ip, version) {
888
+ if ((version === "v4" || !version) && ipv4Regex.test(ip)) {
889
+ return true;
890
+ }
891
+ if ((version === "v6" || !version) && ipv6Regex.test(ip)) {
892
+ return true;
893
+ }
894
+ return false;
895
+ }
896
+ function isValidJWT(jwt, alg) {
897
+ if (!jwtRegex.test(jwt))
898
+ return false;
899
+ try {
900
+ const [header] = jwt.split(".");
901
+ const base64 = header.replace(/-/g, "+").replace(/_/g, "/").padEnd(header.length + (4 - header.length % 4) % 4, "=");
902
+ const decoded = JSON.parse(atob(base64));
903
+ if (typeof decoded !== "object" || decoded === null)
904
+ return false;
905
+ if (!decoded.typ || !decoded.alg)
906
+ return false;
907
+ if (alg && decoded.alg !== alg)
908
+ return false;
909
+ return true;
910
+ } catch (_a) {
911
+ return false;
912
+ }
913
+ }
914
+ function isValidCidr(ip, version) {
915
+ if ((version === "v4" || !version) && ipv4CidrRegex.test(ip)) {
916
+ return true;
917
+ }
918
+ if ((version === "v6" || !version) && ipv6CidrRegex.test(ip)) {
919
+ return true;
920
+ }
921
+ return false;
922
+ }
923
+ class ZodString extends ZodType {
924
+ _parse(input) {
925
+ if (this._def.coerce) {
926
+ input.data = String(input.data);
927
+ }
928
+ const parsedType = this._getType(input);
929
+ if (parsedType !== ZodParsedType.string) {
930
+ const ctx2 = this._getOrReturnCtx(input);
931
+ addIssueToContext(ctx2, {
932
+ code: ZodIssueCode.invalid_type,
933
+ expected: ZodParsedType.string,
934
+ received: ctx2.parsedType
935
+ });
936
+ return INVALID;
937
+ }
938
+ const status = new ParseStatus();
939
+ let ctx = void 0;
940
+ for (const check of this._def.checks) {
941
+ if (check.kind === "min") {
942
+ if (input.data.length < check.value) {
943
+ ctx = this._getOrReturnCtx(input, ctx);
944
+ addIssueToContext(ctx, {
945
+ code: ZodIssueCode.too_small,
946
+ minimum: check.value,
947
+ type: "string",
948
+ inclusive: true,
949
+ exact: false,
950
+ message: check.message
951
+ });
952
+ status.dirty();
953
+ }
954
+ } else if (check.kind === "max") {
955
+ if (input.data.length > check.value) {
956
+ ctx = this._getOrReturnCtx(input, ctx);
957
+ addIssueToContext(ctx, {
958
+ code: ZodIssueCode.too_big,
959
+ maximum: check.value,
960
+ type: "string",
961
+ inclusive: true,
962
+ exact: false,
963
+ message: check.message
964
+ });
965
+ status.dirty();
966
+ }
967
+ } else if (check.kind === "length") {
968
+ const tooBig = input.data.length > check.value;
969
+ const tooSmall = input.data.length < check.value;
970
+ if (tooBig || tooSmall) {
971
+ ctx = this._getOrReturnCtx(input, ctx);
972
+ if (tooBig) {
973
+ addIssueToContext(ctx, {
974
+ code: ZodIssueCode.too_big,
975
+ maximum: check.value,
976
+ type: "string",
977
+ inclusive: true,
978
+ exact: true,
979
+ message: check.message
980
+ });
981
+ } else if (tooSmall) {
982
+ addIssueToContext(ctx, {
983
+ code: ZodIssueCode.too_small,
984
+ minimum: check.value,
985
+ type: "string",
986
+ inclusive: true,
987
+ exact: true,
988
+ message: check.message
989
+ });
990
+ }
991
+ status.dirty();
992
+ }
993
+ } else if (check.kind === "email") {
994
+ if (!emailRegex.test(input.data)) {
995
+ ctx = this._getOrReturnCtx(input, ctx);
996
+ addIssueToContext(ctx, {
997
+ validation: "email",
998
+ code: ZodIssueCode.invalid_string,
999
+ message: check.message
1000
+ });
1001
+ status.dirty();
1002
+ }
1003
+ } else if (check.kind === "emoji") {
1004
+ if (!emojiRegex) {
1005
+ emojiRegex = new RegExp(_emojiRegex, "u");
1006
+ }
1007
+ if (!emojiRegex.test(input.data)) {
1008
+ ctx = this._getOrReturnCtx(input, ctx);
1009
+ addIssueToContext(ctx, {
1010
+ validation: "emoji",
1011
+ code: ZodIssueCode.invalid_string,
1012
+ message: check.message
1013
+ });
1014
+ status.dirty();
1015
+ }
1016
+ } else if (check.kind === "uuid") {
1017
+ if (!uuidRegex.test(input.data)) {
1018
+ ctx = this._getOrReturnCtx(input, ctx);
1019
+ addIssueToContext(ctx, {
1020
+ validation: "uuid",
1021
+ code: ZodIssueCode.invalid_string,
1022
+ message: check.message
1023
+ });
1024
+ status.dirty();
1025
+ }
1026
+ } else if (check.kind === "nanoid") {
1027
+ if (!nanoidRegex.test(input.data)) {
1028
+ ctx = this._getOrReturnCtx(input, ctx);
1029
+ addIssueToContext(ctx, {
1030
+ validation: "nanoid",
1031
+ code: ZodIssueCode.invalid_string,
1032
+ message: check.message
1033
+ });
1034
+ status.dirty();
1035
+ }
1036
+ } else if (check.kind === "cuid") {
1037
+ if (!cuidRegex.test(input.data)) {
1038
+ ctx = this._getOrReturnCtx(input, ctx);
1039
+ addIssueToContext(ctx, {
1040
+ validation: "cuid",
1041
+ code: ZodIssueCode.invalid_string,
1042
+ message: check.message
1043
+ });
1044
+ status.dirty();
1045
+ }
1046
+ } else if (check.kind === "cuid2") {
1047
+ if (!cuid2Regex.test(input.data)) {
1048
+ ctx = this._getOrReturnCtx(input, ctx);
1049
+ addIssueToContext(ctx, {
1050
+ validation: "cuid2",
1051
+ code: ZodIssueCode.invalid_string,
1052
+ message: check.message
1053
+ });
1054
+ status.dirty();
1055
+ }
1056
+ } else if (check.kind === "ulid") {
1057
+ if (!ulidRegex.test(input.data)) {
1058
+ ctx = this._getOrReturnCtx(input, ctx);
1059
+ addIssueToContext(ctx, {
1060
+ validation: "ulid",
1061
+ code: ZodIssueCode.invalid_string,
1062
+ message: check.message
1063
+ });
1064
+ status.dirty();
1065
+ }
1066
+ } else if (check.kind === "url") {
1067
+ try {
1068
+ new URL(input.data);
1069
+ } catch (_a) {
1070
+ ctx = this._getOrReturnCtx(input, ctx);
1071
+ addIssueToContext(ctx, {
1072
+ validation: "url",
1073
+ code: ZodIssueCode.invalid_string,
1074
+ message: check.message
1075
+ });
1076
+ status.dirty();
1077
+ }
1078
+ } else if (check.kind === "regex") {
1079
+ check.regex.lastIndex = 0;
1080
+ const testResult = check.regex.test(input.data);
1081
+ if (!testResult) {
1082
+ ctx = this._getOrReturnCtx(input, ctx);
1083
+ addIssueToContext(ctx, {
1084
+ validation: "regex",
1085
+ code: ZodIssueCode.invalid_string,
1086
+ message: check.message
1087
+ });
1088
+ status.dirty();
1089
+ }
1090
+ } else if (check.kind === "trim") {
1091
+ input.data = input.data.trim();
1092
+ } else if (check.kind === "includes") {
1093
+ if (!input.data.includes(check.value, check.position)) {
1094
+ ctx = this._getOrReturnCtx(input, ctx);
1095
+ addIssueToContext(ctx, {
1096
+ code: ZodIssueCode.invalid_string,
1097
+ validation: { includes: check.value, position: check.position },
1098
+ message: check.message
1099
+ });
1100
+ status.dirty();
1101
+ }
1102
+ } else if (check.kind === "toLowerCase") {
1103
+ input.data = input.data.toLowerCase();
1104
+ } else if (check.kind === "toUpperCase") {
1105
+ input.data = input.data.toUpperCase();
1106
+ } else if (check.kind === "startsWith") {
1107
+ if (!input.data.startsWith(check.value)) {
1108
+ ctx = this._getOrReturnCtx(input, ctx);
1109
+ addIssueToContext(ctx, {
1110
+ code: ZodIssueCode.invalid_string,
1111
+ validation: { startsWith: check.value },
1112
+ message: check.message
1113
+ });
1114
+ status.dirty();
1115
+ }
1116
+ } else if (check.kind === "endsWith") {
1117
+ if (!input.data.endsWith(check.value)) {
1118
+ ctx = this._getOrReturnCtx(input, ctx);
1119
+ addIssueToContext(ctx, {
1120
+ code: ZodIssueCode.invalid_string,
1121
+ validation: { endsWith: check.value },
1122
+ message: check.message
1123
+ });
1124
+ status.dirty();
1125
+ }
1126
+ } else if (check.kind === "datetime") {
1127
+ const regex = datetimeRegex(check);
1128
+ if (!regex.test(input.data)) {
1129
+ ctx = this._getOrReturnCtx(input, ctx);
1130
+ addIssueToContext(ctx, {
1131
+ code: ZodIssueCode.invalid_string,
1132
+ validation: "datetime",
1133
+ message: check.message
1134
+ });
1135
+ status.dirty();
1136
+ }
1137
+ } else if (check.kind === "date") {
1138
+ const regex = dateRegex;
1139
+ if (!regex.test(input.data)) {
1140
+ ctx = this._getOrReturnCtx(input, ctx);
1141
+ addIssueToContext(ctx, {
1142
+ code: ZodIssueCode.invalid_string,
1143
+ validation: "date",
1144
+ message: check.message
1145
+ });
1146
+ status.dirty();
1147
+ }
1148
+ } else if (check.kind === "time") {
1149
+ const regex = timeRegex(check);
1150
+ if (!regex.test(input.data)) {
1151
+ ctx = this._getOrReturnCtx(input, ctx);
1152
+ addIssueToContext(ctx, {
1153
+ code: ZodIssueCode.invalid_string,
1154
+ validation: "time",
1155
+ message: check.message
1156
+ });
1157
+ status.dirty();
1158
+ }
1159
+ } else if (check.kind === "duration") {
1160
+ if (!durationRegex.test(input.data)) {
1161
+ ctx = this._getOrReturnCtx(input, ctx);
1162
+ addIssueToContext(ctx, {
1163
+ validation: "duration",
1164
+ code: ZodIssueCode.invalid_string,
1165
+ message: check.message
1166
+ });
1167
+ status.dirty();
1168
+ }
1169
+ } else if (check.kind === "ip") {
1170
+ if (!isValidIP(input.data, check.version)) {
1171
+ ctx = this._getOrReturnCtx(input, ctx);
1172
+ addIssueToContext(ctx, {
1173
+ validation: "ip",
1174
+ code: ZodIssueCode.invalid_string,
1175
+ message: check.message
1176
+ });
1177
+ status.dirty();
1178
+ }
1179
+ } else if (check.kind === "jwt") {
1180
+ if (!isValidJWT(input.data, check.alg)) {
1181
+ ctx = this._getOrReturnCtx(input, ctx);
1182
+ addIssueToContext(ctx, {
1183
+ validation: "jwt",
1184
+ code: ZodIssueCode.invalid_string,
1185
+ message: check.message
1186
+ });
1187
+ status.dirty();
1188
+ }
1189
+ } else if (check.kind === "cidr") {
1190
+ if (!isValidCidr(input.data, check.version)) {
1191
+ ctx = this._getOrReturnCtx(input, ctx);
1192
+ addIssueToContext(ctx, {
1193
+ validation: "cidr",
1194
+ code: ZodIssueCode.invalid_string,
1195
+ message: check.message
1196
+ });
1197
+ status.dirty();
1198
+ }
1199
+ } else if (check.kind === "base64") {
1200
+ if (!base64Regex.test(input.data)) {
1201
+ ctx = this._getOrReturnCtx(input, ctx);
1202
+ addIssueToContext(ctx, {
1203
+ validation: "base64",
1204
+ code: ZodIssueCode.invalid_string,
1205
+ message: check.message
1206
+ });
1207
+ status.dirty();
1208
+ }
1209
+ } else if (check.kind === "base64url") {
1210
+ if (!base64urlRegex.test(input.data)) {
1211
+ ctx = this._getOrReturnCtx(input, ctx);
1212
+ addIssueToContext(ctx, {
1213
+ validation: "base64url",
1214
+ code: ZodIssueCode.invalid_string,
1215
+ message: check.message
1216
+ });
1217
+ status.dirty();
1218
+ }
1219
+ } else {
1220
+ util.assertNever(check);
1221
+ }
1222
+ }
1223
+ return { status: status.value, value: input.data };
1224
+ }
1225
+ _regex(regex, validation, message) {
1226
+ return this.refinement((data) => regex.test(data), {
1227
+ validation,
1228
+ code: ZodIssueCode.invalid_string,
1229
+ ...errorUtil.errToObj(message)
1230
+ });
1231
+ }
1232
+ _addCheck(check) {
1233
+ return new ZodString({
1234
+ ...this._def,
1235
+ checks: [...this._def.checks, check]
1236
+ });
1237
+ }
1238
+ email(message) {
1239
+ return this._addCheck({ kind: "email", ...errorUtil.errToObj(message) });
1240
+ }
1241
+ url(message) {
1242
+ return this._addCheck({ kind: "url", ...errorUtil.errToObj(message) });
1243
+ }
1244
+ emoji(message) {
1245
+ return this._addCheck({ kind: "emoji", ...errorUtil.errToObj(message) });
1246
+ }
1247
+ uuid(message) {
1248
+ return this._addCheck({ kind: "uuid", ...errorUtil.errToObj(message) });
1249
+ }
1250
+ nanoid(message) {
1251
+ return this._addCheck({ kind: "nanoid", ...errorUtil.errToObj(message) });
1252
+ }
1253
+ cuid(message) {
1254
+ return this._addCheck({ kind: "cuid", ...errorUtil.errToObj(message) });
1255
+ }
1256
+ cuid2(message) {
1257
+ return this._addCheck({ kind: "cuid2", ...errorUtil.errToObj(message) });
1258
+ }
1259
+ ulid(message) {
1260
+ return this._addCheck({ kind: "ulid", ...errorUtil.errToObj(message) });
1261
+ }
1262
+ base64(message) {
1263
+ return this._addCheck({ kind: "base64", ...errorUtil.errToObj(message) });
1264
+ }
1265
+ base64url(message) {
1266
+ return this._addCheck({
1267
+ kind: "base64url",
1268
+ ...errorUtil.errToObj(message)
1269
+ });
1270
+ }
1271
+ jwt(options) {
1272
+ return this._addCheck({ kind: "jwt", ...errorUtil.errToObj(options) });
1273
+ }
1274
+ ip(options) {
1275
+ return this._addCheck({ kind: "ip", ...errorUtil.errToObj(options) });
1276
+ }
1277
+ cidr(options) {
1278
+ return this._addCheck({ kind: "cidr", ...errorUtil.errToObj(options) });
1279
+ }
1280
+ datetime(options) {
1281
+ var _a, _b;
1282
+ if (typeof options === "string") {
1283
+ return this._addCheck({
1284
+ kind: "datetime",
1285
+ precision: null,
1286
+ offset: false,
1287
+ local: false,
1288
+ message: options
1289
+ });
1290
+ }
1291
+ return this._addCheck({
1292
+ kind: "datetime",
1293
+ precision: typeof (options === null || options === void 0 ? void 0 : options.precision) === "undefined" ? null : options === null || options === void 0 ? void 0 : options.precision,
1294
+ offset: (_a = options === null || options === void 0 ? void 0 : options.offset) !== null && _a !== void 0 ? _a : false,
1295
+ local: (_b = options === null || options === void 0 ? void 0 : options.local) !== null && _b !== void 0 ? _b : false,
1296
+ ...errorUtil.errToObj(options === null || options === void 0 ? void 0 : options.message)
1297
+ });
1298
+ }
1299
+ date(message) {
1300
+ return this._addCheck({ kind: "date", message });
1301
+ }
1302
+ time(options) {
1303
+ if (typeof options === "string") {
1304
+ return this._addCheck({
1305
+ kind: "time",
1306
+ precision: null,
1307
+ message: options
1308
+ });
1309
+ }
1310
+ return this._addCheck({
1311
+ kind: "time",
1312
+ precision: typeof (options === null || options === void 0 ? void 0 : options.precision) === "undefined" ? null : options === null || options === void 0 ? void 0 : options.precision,
1313
+ ...errorUtil.errToObj(options === null || options === void 0 ? void 0 : options.message)
1314
+ });
1315
+ }
1316
+ duration(message) {
1317
+ return this._addCheck({ kind: "duration", ...errorUtil.errToObj(message) });
1318
+ }
1319
+ regex(regex, message) {
1320
+ return this._addCheck({
1321
+ kind: "regex",
1322
+ regex,
1323
+ ...errorUtil.errToObj(message)
1324
+ });
1325
+ }
1326
+ includes(value, options) {
1327
+ return this._addCheck({
1328
+ kind: "includes",
1329
+ value,
1330
+ position: options === null || options === void 0 ? void 0 : options.position,
1331
+ ...errorUtil.errToObj(options === null || options === void 0 ? void 0 : options.message)
1332
+ });
1333
+ }
1334
+ startsWith(value, message) {
1335
+ return this._addCheck({
1336
+ kind: "startsWith",
1337
+ value,
1338
+ ...errorUtil.errToObj(message)
1339
+ });
1340
+ }
1341
+ endsWith(value, message) {
1342
+ return this._addCheck({
1343
+ kind: "endsWith",
1344
+ value,
1345
+ ...errorUtil.errToObj(message)
1346
+ });
1347
+ }
1348
+ min(minLength, message) {
1349
+ return this._addCheck({
1350
+ kind: "min",
1351
+ value: minLength,
1352
+ ...errorUtil.errToObj(message)
1353
+ });
1354
+ }
1355
+ max(maxLength, message) {
1356
+ return this._addCheck({
1357
+ kind: "max",
1358
+ value: maxLength,
1359
+ ...errorUtil.errToObj(message)
1360
+ });
1361
+ }
1362
+ length(len, message) {
1363
+ return this._addCheck({
1364
+ kind: "length",
1365
+ value: len,
1366
+ ...errorUtil.errToObj(message)
1367
+ });
1368
+ }
1369
+ /**
1370
+ * Equivalent to `.min(1)`
1371
+ */
1372
+ nonempty(message) {
1373
+ return this.min(1, errorUtil.errToObj(message));
1374
+ }
1375
+ trim() {
1376
+ return new ZodString({
1377
+ ...this._def,
1378
+ checks: [...this._def.checks, { kind: "trim" }]
1379
+ });
1380
+ }
1381
+ toLowerCase() {
1382
+ return new ZodString({
1383
+ ...this._def,
1384
+ checks: [...this._def.checks, { kind: "toLowerCase" }]
1385
+ });
1386
+ }
1387
+ toUpperCase() {
1388
+ return new ZodString({
1389
+ ...this._def,
1390
+ checks: [...this._def.checks, { kind: "toUpperCase" }]
1391
+ });
1392
+ }
1393
+ get isDatetime() {
1394
+ return !!this._def.checks.find((ch) => ch.kind === "datetime");
1395
+ }
1396
+ get isDate() {
1397
+ return !!this._def.checks.find((ch) => ch.kind === "date");
1398
+ }
1399
+ get isTime() {
1400
+ return !!this._def.checks.find((ch) => ch.kind === "time");
1401
+ }
1402
+ get isDuration() {
1403
+ return !!this._def.checks.find((ch) => ch.kind === "duration");
1404
+ }
1405
+ get isEmail() {
1406
+ return !!this._def.checks.find((ch) => ch.kind === "email");
1407
+ }
1408
+ get isURL() {
1409
+ return !!this._def.checks.find((ch) => ch.kind === "url");
1410
+ }
1411
+ get isEmoji() {
1412
+ return !!this._def.checks.find((ch) => ch.kind === "emoji");
1413
+ }
1414
+ get isUUID() {
1415
+ return !!this._def.checks.find((ch) => ch.kind === "uuid");
1416
+ }
1417
+ get isNANOID() {
1418
+ return !!this._def.checks.find((ch) => ch.kind === "nanoid");
1419
+ }
1420
+ get isCUID() {
1421
+ return !!this._def.checks.find((ch) => ch.kind === "cuid");
1422
+ }
1423
+ get isCUID2() {
1424
+ return !!this._def.checks.find((ch) => ch.kind === "cuid2");
1425
+ }
1426
+ get isULID() {
1427
+ return !!this._def.checks.find((ch) => ch.kind === "ulid");
1428
+ }
1429
+ get isIP() {
1430
+ return !!this._def.checks.find((ch) => ch.kind === "ip");
1431
+ }
1432
+ get isCIDR() {
1433
+ return !!this._def.checks.find((ch) => ch.kind === "cidr");
1434
+ }
1435
+ get isBase64() {
1436
+ return !!this._def.checks.find((ch) => ch.kind === "base64");
1437
+ }
1438
+ get isBase64url() {
1439
+ return !!this._def.checks.find((ch) => ch.kind === "base64url");
1440
+ }
1441
+ get minLength() {
1442
+ let min = null;
1443
+ for (const ch of this._def.checks) {
1444
+ if (ch.kind === "min") {
1445
+ if (min === null || ch.value > min)
1446
+ min = ch.value;
1447
+ }
1448
+ }
1449
+ return min;
1450
+ }
1451
+ get maxLength() {
1452
+ let max = null;
1453
+ for (const ch of this._def.checks) {
1454
+ if (ch.kind === "max") {
1455
+ if (max === null || ch.value < max)
1456
+ max = ch.value;
1457
+ }
1458
+ }
1459
+ return max;
1460
+ }
1461
+ }
1462
+ ZodString.create = (params) => {
1463
+ var _a;
1464
+ return new ZodString({
1465
+ checks: [],
1466
+ typeName: ZodFirstPartyTypeKind.ZodString,
1467
+ coerce: (_a = params === null || params === void 0 ? void 0 : params.coerce) !== null && _a !== void 0 ? _a : false,
1468
+ ...processCreateParams(params)
1469
+ });
1470
+ };
1471
+ function floatSafeRemainder(val, step) {
1472
+ const valDecCount = (val.toString().split(".")[1] || "").length;
1473
+ const stepDecCount = (step.toString().split(".")[1] || "").length;
1474
+ const decCount = valDecCount > stepDecCount ? valDecCount : stepDecCount;
1475
+ const valInt = parseInt(val.toFixed(decCount).replace(".", ""));
1476
+ const stepInt = parseInt(step.toFixed(decCount).replace(".", ""));
1477
+ return valInt % stepInt / Math.pow(10, decCount);
1478
+ }
1479
+ class ZodNumber extends ZodType {
1480
+ constructor() {
1481
+ super(...arguments);
1482
+ this.min = this.gte;
1483
+ this.max = this.lte;
1484
+ this.step = this.multipleOf;
1485
+ }
1486
+ _parse(input) {
1487
+ if (this._def.coerce) {
1488
+ input.data = Number(input.data);
1489
+ }
1490
+ const parsedType = this._getType(input);
1491
+ if (parsedType !== ZodParsedType.number) {
1492
+ const ctx2 = this._getOrReturnCtx(input);
1493
+ addIssueToContext(ctx2, {
1494
+ code: ZodIssueCode.invalid_type,
1495
+ expected: ZodParsedType.number,
1496
+ received: ctx2.parsedType
1497
+ });
1498
+ return INVALID;
1499
+ }
1500
+ let ctx = void 0;
1501
+ const status = new ParseStatus();
1502
+ for (const check of this._def.checks) {
1503
+ if (check.kind === "int") {
1504
+ if (!util.isInteger(input.data)) {
1505
+ ctx = this._getOrReturnCtx(input, ctx);
1506
+ addIssueToContext(ctx, {
1507
+ code: ZodIssueCode.invalid_type,
1508
+ expected: "integer",
1509
+ received: "float",
1510
+ message: check.message
1511
+ });
1512
+ status.dirty();
1513
+ }
1514
+ } else if (check.kind === "min") {
1515
+ const tooSmall = check.inclusive ? input.data < check.value : input.data <= check.value;
1516
+ if (tooSmall) {
1517
+ ctx = this._getOrReturnCtx(input, ctx);
1518
+ addIssueToContext(ctx, {
1519
+ code: ZodIssueCode.too_small,
1520
+ minimum: check.value,
1521
+ type: "number",
1522
+ inclusive: check.inclusive,
1523
+ exact: false,
1524
+ message: check.message
1525
+ });
1526
+ status.dirty();
1527
+ }
1528
+ } else if (check.kind === "max") {
1529
+ const tooBig = check.inclusive ? input.data > check.value : input.data >= check.value;
1530
+ if (tooBig) {
1531
+ ctx = this._getOrReturnCtx(input, ctx);
1532
+ addIssueToContext(ctx, {
1533
+ code: ZodIssueCode.too_big,
1534
+ maximum: check.value,
1535
+ type: "number",
1536
+ inclusive: check.inclusive,
1537
+ exact: false,
1538
+ message: check.message
1539
+ });
1540
+ status.dirty();
1541
+ }
1542
+ } else if (check.kind === "multipleOf") {
1543
+ if (floatSafeRemainder(input.data, check.value) !== 0) {
1544
+ ctx = this._getOrReturnCtx(input, ctx);
1545
+ addIssueToContext(ctx, {
1546
+ code: ZodIssueCode.not_multiple_of,
1547
+ multipleOf: check.value,
1548
+ message: check.message
1549
+ });
1550
+ status.dirty();
1551
+ }
1552
+ } else if (check.kind === "finite") {
1553
+ if (!Number.isFinite(input.data)) {
1554
+ ctx = this._getOrReturnCtx(input, ctx);
1555
+ addIssueToContext(ctx, {
1556
+ code: ZodIssueCode.not_finite,
1557
+ message: check.message
1558
+ });
1559
+ status.dirty();
1560
+ }
1561
+ } else {
1562
+ util.assertNever(check);
1563
+ }
1564
+ }
1565
+ return { status: status.value, value: input.data };
1566
+ }
1567
+ gte(value, message) {
1568
+ return this.setLimit("min", value, true, errorUtil.toString(message));
1569
+ }
1570
+ gt(value, message) {
1571
+ return this.setLimit("min", value, false, errorUtil.toString(message));
1572
+ }
1573
+ lte(value, message) {
1574
+ return this.setLimit("max", value, true, errorUtil.toString(message));
1575
+ }
1576
+ lt(value, message) {
1577
+ return this.setLimit("max", value, false, errorUtil.toString(message));
1578
+ }
1579
+ setLimit(kind, value, inclusive, message) {
1580
+ return new ZodNumber({
1581
+ ...this._def,
1582
+ checks: [
1583
+ ...this._def.checks,
1584
+ {
1585
+ kind,
1586
+ value,
1587
+ inclusive,
1588
+ message: errorUtil.toString(message)
1589
+ }
1590
+ ]
1591
+ });
1592
+ }
1593
+ _addCheck(check) {
1594
+ return new ZodNumber({
1595
+ ...this._def,
1596
+ checks: [...this._def.checks, check]
1597
+ });
1598
+ }
1599
+ int(message) {
1600
+ return this._addCheck({
1601
+ kind: "int",
1602
+ message: errorUtil.toString(message)
1603
+ });
1604
+ }
1605
+ positive(message) {
1606
+ return this._addCheck({
1607
+ kind: "min",
1608
+ value: 0,
1609
+ inclusive: false,
1610
+ message: errorUtil.toString(message)
1611
+ });
1612
+ }
1613
+ negative(message) {
1614
+ return this._addCheck({
1615
+ kind: "max",
1616
+ value: 0,
1617
+ inclusive: false,
1618
+ message: errorUtil.toString(message)
1619
+ });
1620
+ }
1621
+ nonpositive(message) {
1622
+ return this._addCheck({
1623
+ kind: "max",
1624
+ value: 0,
1625
+ inclusive: true,
1626
+ message: errorUtil.toString(message)
1627
+ });
1628
+ }
1629
+ nonnegative(message) {
1630
+ return this._addCheck({
1631
+ kind: "min",
1632
+ value: 0,
1633
+ inclusive: true,
1634
+ message: errorUtil.toString(message)
1635
+ });
1636
+ }
1637
+ multipleOf(value, message) {
1638
+ return this._addCheck({
1639
+ kind: "multipleOf",
1640
+ value,
1641
+ message: errorUtil.toString(message)
1642
+ });
1643
+ }
1644
+ finite(message) {
1645
+ return this._addCheck({
1646
+ kind: "finite",
1647
+ message: errorUtil.toString(message)
1648
+ });
1649
+ }
1650
+ safe(message) {
1651
+ return this._addCheck({
1652
+ kind: "min",
1653
+ inclusive: true,
1654
+ value: Number.MIN_SAFE_INTEGER,
1655
+ message: errorUtil.toString(message)
1656
+ })._addCheck({
1657
+ kind: "max",
1658
+ inclusive: true,
1659
+ value: Number.MAX_SAFE_INTEGER,
1660
+ message: errorUtil.toString(message)
1661
+ });
1662
+ }
1663
+ get minValue() {
1664
+ let min = null;
1665
+ for (const ch of this._def.checks) {
1666
+ if (ch.kind === "min") {
1667
+ if (min === null || ch.value > min)
1668
+ min = ch.value;
1669
+ }
1670
+ }
1671
+ return min;
1672
+ }
1673
+ get maxValue() {
1674
+ let max = null;
1675
+ for (const ch of this._def.checks) {
1676
+ if (ch.kind === "max") {
1677
+ if (max === null || ch.value < max)
1678
+ max = ch.value;
1679
+ }
1680
+ }
1681
+ return max;
1682
+ }
1683
+ get isInt() {
1684
+ return !!this._def.checks.find((ch) => ch.kind === "int" || ch.kind === "multipleOf" && util.isInteger(ch.value));
1685
+ }
1686
+ get isFinite() {
1687
+ let max = null, min = null;
1688
+ for (const ch of this._def.checks) {
1689
+ if (ch.kind === "finite" || ch.kind === "int" || ch.kind === "multipleOf") {
1690
+ return true;
1691
+ } else if (ch.kind === "min") {
1692
+ if (min === null || ch.value > min)
1693
+ min = ch.value;
1694
+ } else if (ch.kind === "max") {
1695
+ if (max === null || ch.value < max)
1696
+ max = ch.value;
1697
+ }
1698
+ }
1699
+ return Number.isFinite(min) && Number.isFinite(max);
1700
+ }
1701
+ }
1702
+ ZodNumber.create = (params) => {
1703
+ return new ZodNumber({
1704
+ checks: [],
1705
+ typeName: ZodFirstPartyTypeKind.ZodNumber,
1706
+ coerce: (params === null || params === void 0 ? void 0 : params.coerce) || false,
1707
+ ...processCreateParams(params)
1708
+ });
1709
+ };
1710
+ class ZodBigInt extends ZodType {
1711
+ constructor() {
1712
+ super(...arguments);
1713
+ this.min = this.gte;
1714
+ this.max = this.lte;
1715
+ }
1716
+ _parse(input) {
1717
+ if (this._def.coerce) {
1718
+ try {
1719
+ input.data = BigInt(input.data);
1720
+ } catch (_a) {
1721
+ return this._getInvalidInput(input);
1722
+ }
1723
+ }
1724
+ const parsedType = this._getType(input);
1725
+ if (parsedType !== ZodParsedType.bigint) {
1726
+ return this._getInvalidInput(input);
1727
+ }
1728
+ let ctx = void 0;
1729
+ const status = new ParseStatus();
1730
+ for (const check of this._def.checks) {
1731
+ if (check.kind === "min") {
1732
+ const tooSmall = check.inclusive ? input.data < check.value : input.data <= check.value;
1733
+ if (tooSmall) {
1734
+ ctx = this._getOrReturnCtx(input, ctx);
1735
+ addIssueToContext(ctx, {
1736
+ code: ZodIssueCode.too_small,
1737
+ type: "bigint",
1738
+ minimum: check.value,
1739
+ inclusive: check.inclusive,
1740
+ message: check.message
1741
+ });
1742
+ status.dirty();
1743
+ }
1744
+ } else if (check.kind === "max") {
1745
+ const tooBig = check.inclusive ? input.data > check.value : input.data >= check.value;
1746
+ if (tooBig) {
1747
+ ctx = this._getOrReturnCtx(input, ctx);
1748
+ addIssueToContext(ctx, {
1749
+ code: ZodIssueCode.too_big,
1750
+ type: "bigint",
1751
+ maximum: check.value,
1752
+ inclusive: check.inclusive,
1753
+ message: check.message
1754
+ });
1755
+ status.dirty();
1756
+ }
1757
+ } else if (check.kind === "multipleOf") {
1758
+ if (input.data % check.value !== BigInt(0)) {
1759
+ ctx = this._getOrReturnCtx(input, ctx);
1760
+ addIssueToContext(ctx, {
1761
+ code: ZodIssueCode.not_multiple_of,
1762
+ multipleOf: check.value,
1763
+ message: check.message
1764
+ });
1765
+ status.dirty();
1766
+ }
1767
+ } else {
1768
+ util.assertNever(check);
1769
+ }
1770
+ }
1771
+ return { status: status.value, value: input.data };
1772
+ }
1773
+ _getInvalidInput(input) {
1774
+ const ctx = this._getOrReturnCtx(input);
1775
+ addIssueToContext(ctx, {
1776
+ code: ZodIssueCode.invalid_type,
1777
+ expected: ZodParsedType.bigint,
1778
+ received: ctx.parsedType
1779
+ });
1780
+ return INVALID;
1781
+ }
1782
+ gte(value, message) {
1783
+ return this.setLimit("min", value, true, errorUtil.toString(message));
1784
+ }
1785
+ gt(value, message) {
1786
+ return this.setLimit("min", value, false, errorUtil.toString(message));
1787
+ }
1788
+ lte(value, message) {
1789
+ return this.setLimit("max", value, true, errorUtil.toString(message));
1790
+ }
1791
+ lt(value, message) {
1792
+ return this.setLimit("max", value, false, errorUtil.toString(message));
1793
+ }
1794
+ setLimit(kind, value, inclusive, message) {
1795
+ return new ZodBigInt({
1796
+ ...this._def,
1797
+ checks: [
1798
+ ...this._def.checks,
1799
+ {
1800
+ kind,
1801
+ value,
1802
+ inclusive,
1803
+ message: errorUtil.toString(message)
1804
+ }
1805
+ ]
1806
+ });
1807
+ }
1808
+ _addCheck(check) {
1809
+ return new ZodBigInt({
1810
+ ...this._def,
1811
+ checks: [...this._def.checks, check]
1812
+ });
1813
+ }
1814
+ positive(message) {
1815
+ return this._addCheck({
1816
+ kind: "min",
1817
+ value: BigInt(0),
1818
+ inclusive: false,
1819
+ message: errorUtil.toString(message)
1820
+ });
1821
+ }
1822
+ negative(message) {
1823
+ return this._addCheck({
1824
+ kind: "max",
1825
+ value: BigInt(0),
1826
+ inclusive: false,
1827
+ message: errorUtil.toString(message)
1828
+ });
1829
+ }
1830
+ nonpositive(message) {
1831
+ return this._addCheck({
1832
+ kind: "max",
1833
+ value: BigInt(0),
1834
+ inclusive: true,
1835
+ message: errorUtil.toString(message)
1836
+ });
1837
+ }
1838
+ nonnegative(message) {
1839
+ return this._addCheck({
1840
+ kind: "min",
1841
+ value: BigInt(0),
1842
+ inclusive: true,
1843
+ message: errorUtil.toString(message)
1844
+ });
1845
+ }
1846
+ multipleOf(value, message) {
1847
+ return this._addCheck({
1848
+ kind: "multipleOf",
1849
+ value,
1850
+ message: errorUtil.toString(message)
1851
+ });
1852
+ }
1853
+ get minValue() {
1854
+ let min = null;
1855
+ for (const ch of this._def.checks) {
1856
+ if (ch.kind === "min") {
1857
+ if (min === null || ch.value > min)
1858
+ min = ch.value;
1859
+ }
1860
+ }
1861
+ return min;
1862
+ }
1863
+ get maxValue() {
1864
+ let max = null;
1865
+ for (const ch of this._def.checks) {
1866
+ if (ch.kind === "max") {
1867
+ if (max === null || ch.value < max)
1868
+ max = ch.value;
1869
+ }
1870
+ }
1871
+ return max;
1872
+ }
1873
+ }
1874
+ ZodBigInt.create = (params) => {
1875
+ var _a;
1876
+ return new ZodBigInt({
1877
+ checks: [],
1878
+ typeName: ZodFirstPartyTypeKind.ZodBigInt,
1879
+ coerce: (_a = params === null || params === void 0 ? void 0 : params.coerce) !== null && _a !== void 0 ? _a : false,
1880
+ ...processCreateParams(params)
1881
+ });
1882
+ };
1883
+ class ZodBoolean extends ZodType {
1884
+ _parse(input) {
1885
+ if (this._def.coerce) {
1886
+ input.data = Boolean(input.data);
1887
+ }
1888
+ const parsedType = this._getType(input);
1889
+ if (parsedType !== ZodParsedType.boolean) {
1890
+ const ctx = this._getOrReturnCtx(input);
1891
+ addIssueToContext(ctx, {
1892
+ code: ZodIssueCode.invalid_type,
1893
+ expected: ZodParsedType.boolean,
1894
+ received: ctx.parsedType
1895
+ });
1896
+ return INVALID;
1897
+ }
1898
+ return OK(input.data);
1899
+ }
1900
+ }
1901
+ ZodBoolean.create = (params) => {
1902
+ return new ZodBoolean({
1903
+ typeName: ZodFirstPartyTypeKind.ZodBoolean,
1904
+ coerce: (params === null || params === void 0 ? void 0 : params.coerce) || false,
1905
+ ...processCreateParams(params)
1906
+ });
1907
+ };
1908
+ class ZodDate extends ZodType {
1909
+ _parse(input) {
1910
+ if (this._def.coerce) {
1911
+ input.data = new Date(input.data);
1912
+ }
1913
+ const parsedType = this._getType(input);
1914
+ if (parsedType !== ZodParsedType.date) {
1915
+ const ctx2 = this._getOrReturnCtx(input);
1916
+ addIssueToContext(ctx2, {
1917
+ code: ZodIssueCode.invalid_type,
1918
+ expected: ZodParsedType.date,
1919
+ received: ctx2.parsedType
1920
+ });
1921
+ return INVALID;
1922
+ }
1923
+ if (isNaN(input.data.getTime())) {
1924
+ const ctx2 = this._getOrReturnCtx(input);
1925
+ addIssueToContext(ctx2, {
1926
+ code: ZodIssueCode.invalid_date
1927
+ });
1928
+ return INVALID;
1929
+ }
1930
+ const status = new ParseStatus();
1931
+ let ctx = void 0;
1932
+ for (const check of this._def.checks) {
1933
+ if (check.kind === "min") {
1934
+ if (input.data.getTime() < check.value) {
1935
+ ctx = this._getOrReturnCtx(input, ctx);
1936
+ addIssueToContext(ctx, {
1937
+ code: ZodIssueCode.too_small,
1938
+ message: check.message,
1939
+ inclusive: true,
1940
+ exact: false,
1941
+ minimum: check.value,
1942
+ type: "date"
1943
+ });
1944
+ status.dirty();
1945
+ }
1946
+ } else if (check.kind === "max") {
1947
+ if (input.data.getTime() > check.value) {
1948
+ ctx = this._getOrReturnCtx(input, ctx);
1949
+ addIssueToContext(ctx, {
1950
+ code: ZodIssueCode.too_big,
1951
+ message: check.message,
1952
+ inclusive: true,
1953
+ exact: false,
1954
+ maximum: check.value,
1955
+ type: "date"
1956
+ });
1957
+ status.dirty();
1958
+ }
1959
+ } else {
1960
+ util.assertNever(check);
1961
+ }
1962
+ }
1963
+ return {
1964
+ status: status.value,
1965
+ value: new Date(input.data.getTime())
1966
+ };
1967
+ }
1968
+ _addCheck(check) {
1969
+ return new ZodDate({
1970
+ ...this._def,
1971
+ checks: [...this._def.checks, check]
1972
+ });
1973
+ }
1974
+ min(minDate, message) {
1975
+ return this._addCheck({
1976
+ kind: "min",
1977
+ value: minDate.getTime(),
1978
+ message: errorUtil.toString(message)
1979
+ });
1980
+ }
1981
+ max(maxDate, message) {
1982
+ return this._addCheck({
1983
+ kind: "max",
1984
+ value: maxDate.getTime(),
1985
+ message: errorUtil.toString(message)
1986
+ });
1987
+ }
1988
+ get minDate() {
1989
+ let min = null;
1990
+ for (const ch of this._def.checks) {
1991
+ if (ch.kind === "min") {
1992
+ if (min === null || ch.value > min)
1993
+ min = ch.value;
1994
+ }
1995
+ }
1996
+ return min != null ? new Date(min) : null;
1997
+ }
1998
+ get maxDate() {
1999
+ let max = null;
2000
+ for (const ch of this._def.checks) {
2001
+ if (ch.kind === "max") {
2002
+ if (max === null || ch.value < max)
2003
+ max = ch.value;
2004
+ }
2005
+ }
2006
+ return max != null ? new Date(max) : null;
2007
+ }
2008
+ }
2009
+ ZodDate.create = (params) => {
2010
+ return new ZodDate({
2011
+ checks: [],
2012
+ coerce: (params === null || params === void 0 ? void 0 : params.coerce) || false,
2013
+ typeName: ZodFirstPartyTypeKind.ZodDate,
2014
+ ...processCreateParams(params)
2015
+ });
2016
+ };
2017
+ class ZodSymbol extends ZodType {
2018
+ _parse(input) {
2019
+ const parsedType = this._getType(input);
2020
+ if (parsedType !== ZodParsedType.symbol) {
2021
+ const ctx = this._getOrReturnCtx(input);
2022
+ addIssueToContext(ctx, {
2023
+ code: ZodIssueCode.invalid_type,
2024
+ expected: ZodParsedType.symbol,
2025
+ received: ctx.parsedType
2026
+ });
2027
+ return INVALID;
2028
+ }
2029
+ return OK(input.data);
2030
+ }
2031
+ }
2032
+ ZodSymbol.create = (params) => {
2033
+ return new ZodSymbol({
2034
+ typeName: ZodFirstPartyTypeKind.ZodSymbol,
2035
+ ...processCreateParams(params)
2036
+ });
2037
+ };
2038
+ class ZodUndefined extends ZodType {
2039
+ _parse(input) {
2040
+ const parsedType = this._getType(input);
2041
+ if (parsedType !== ZodParsedType.undefined) {
2042
+ const ctx = this._getOrReturnCtx(input);
2043
+ addIssueToContext(ctx, {
2044
+ code: ZodIssueCode.invalid_type,
2045
+ expected: ZodParsedType.undefined,
2046
+ received: ctx.parsedType
2047
+ });
2048
+ return INVALID;
2049
+ }
2050
+ return OK(input.data);
2051
+ }
2052
+ }
2053
+ ZodUndefined.create = (params) => {
2054
+ return new ZodUndefined({
2055
+ typeName: ZodFirstPartyTypeKind.ZodUndefined,
2056
+ ...processCreateParams(params)
2057
+ });
2058
+ };
2059
+ class ZodNull extends ZodType {
2060
+ _parse(input) {
2061
+ const parsedType = this._getType(input);
2062
+ if (parsedType !== ZodParsedType.null) {
2063
+ const ctx = this._getOrReturnCtx(input);
2064
+ addIssueToContext(ctx, {
2065
+ code: ZodIssueCode.invalid_type,
2066
+ expected: ZodParsedType.null,
2067
+ received: ctx.parsedType
2068
+ });
2069
+ return INVALID;
2070
+ }
2071
+ return OK(input.data);
2072
+ }
2073
+ }
2074
+ ZodNull.create = (params) => {
2075
+ return new ZodNull({
2076
+ typeName: ZodFirstPartyTypeKind.ZodNull,
2077
+ ...processCreateParams(params)
2078
+ });
2079
+ };
2080
+ class ZodAny extends ZodType {
2081
+ constructor() {
2082
+ super(...arguments);
2083
+ this._any = true;
2084
+ }
2085
+ _parse(input) {
2086
+ return OK(input.data);
2087
+ }
2088
+ }
2089
+ ZodAny.create = (params) => {
2090
+ return new ZodAny({
2091
+ typeName: ZodFirstPartyTypeKind.ZodAny,
2092
+ ...processCreateParams(params)
2093
+ });
2094
+ };
2095
+ class ZodUnknown extends ZodType {
2096
+ constructor() {
2097
+ super(...arguments);
2098
+ this._unknown = true;
2099
+ }
2100
+ _parse(input) {
2101
+ return OK(input.data);
2102
+ }
2103
+ }
2104
+ ZodUnknown.create = (params) => {
2105
+ return new ZodUnknown({
2106
+ typeName: ZodFirstPartyTypeKind.ZodUnknown,
2107
+ ...processCreateParams(params)
2108
+ });
2109
+ };
2110
+ class ZodNever extends ZodType {
2111
+ _parse(input) {
2112
+ const ctx = this._getOrReturnCtx(input);
2113
+ addIssueToContext(ctx, {
2114
+ code: ZodIssueCode.invalid_type,
2115
+ expected: ZodParsedType.never,
2116
+ received: ctx.parsedType
2117
+ });
2118
+ return INVALID;
2119
+ }
2120
+ }
2121
+ ZodNever.create = (params) => {
2122
+ return new ZodNever({
2123
+ typeName: ZodFirstPartyTypeKind.ZodNever,
2124
+ ...processCreateParams(params)
2125
+ });
2126
+ };
2127
+ class ZodVoid extends ZodType {
2128
+ _parse(input) {
2129
+ const parsedType = this._getType(input);
2130
+ if (parsedType !== ZodParsedType.undefined) {
2131
+ const ctx = this._getOrReturnCtx(input);
2132
+ addIssueToContext(ctx, {
2133
+ code: ZodIssueCode.invalid_type,
2134
+ expected: ZodParsedType.void,
2135
+ received: ctx.parsedType
2136
+ });
2137
+ return INVALID;
2138
+ }
2139
+ return OK(input.data);
2140
+ }
2141
+ }
2142
+ ZodVoid.create = (params) => {
2143
+ return new ZodVoid({
2144
+ typeName: ZodFirstPartyTypeKind.ZodVoid,
2145
+ ...processCreateParams(params)
2146
+ });
2147
+ };
2148
+ class ZodArray extends ZodType {
2149
+ _parse(input) {
2150
+ const { ctx, status } = this._processInputParams(input);
2151
+ const def = this._def;
2152
+ if (ctx.parsedType !== ZodParsedType.array) {
2153
+ addIssueToContext(ctx, {
2154
+ code: ZodIssueCode.invalid_type,
2155
+ expected: ZodParsedType.array,
2156
+ received: ctx.parsedType
2157
+ });
2158
+ return INVALID;
2159
+ }
2160
+ if (def.exactLength !== null) {
2161
+ const tooBig = ctx.data.length > def.exactLength.value;
2162
+ const tooSmall = ctx.data.length < def.exactLength.value;
2163
+ if (tooBig || tooSmall) {
2164
+ addIssueToContext(ctx, {
2165
+ code: tooBig ? ZodIssueCode.too_big : ZodIssueCode.too_small,
2166
+ minimum: tooSmall ? def.exactLength.value : void 0,
2167
+ maximum: tooBig ? def.exactLength.value : void 0,
2168
+ type: "array",
2169
+ inclusive: true,
2170
+ exact: true,
2171
+ message: def.exactLength.message
2172
+ });
2173
+ status.dirty();
2174
+ }
2175
+ }
2176
+ if (def.minLength !== null) {
2177
+ if (ctx.data.length < def.minLength.value) {
2178
+ addIssueToContext(ctx, {
2179
+ code: ZodIssueCode.too_small,
2180
+ minimum: def.minLength.value,
2181
+ type: "array",
2182
+ inclusive: true,
2183
+ exact: false,
2184
+ message: def.minLength.message
2185
+ });
2186
+ status.dirty();
2187
+ }
2188
+ }
2189
+ if (def.maxLength !== null) {
2190
+ if (ctx.data.length > def.maxLength.value) {
2191
+ addIssueToContext(ctx, {
2192
+ code: ZodIssueCode.too_big,
2193
+ maximum: def.maxLength.value,
2194
+ type: "array",
2195
+ inclusive: true,
2196
+ exact: false,
2197
+ message: def.maxLength.message
2198
+ });
2199
+ status.dirty();
2200
+ }
2201
+ }
2202
+ if (ctx.common.async) {
2203
+ return Promise.all([...ctx.data].map((item, i) => {
2204
+ return def.type._parseAsync(new ParseInputLazyPath(ctx, item, ctx.path, i));
2205
+ })).then((result2) => {
2206
+ return ParseStatus.mergeArray(status, result2);
2207
+ });
2208
+ }
2209
+ const result = [...ctx.data].map((item, i) => {
2210
+ return def.type._parseSync(new ParseInputLazyPath(ctx, item, ctx.path, i));
2211
+ });
2212
+ return ParseStatus.mergeArray(status, result);
2213
+ }
2214
+ get element() {
2215
+ return this._def.type;
2216
+ }
2217
+ min(minLength, message) {
2218
+ return new ZodArray({
2219
+ ...this._def,
2220
+ minLength: { value: minLength, message: errorUtil.toString(message) }
2221
+ });
2222
+ }
2223
+ max(maxLength, message) {
2224
+ return new ZodArray({
2225
+ ...this._def,
2226
+ maxLength: { value: maxLength, message: errorUtil.toString(message) }
2227
+ });
2228
+ }
2229
+ length(len, message) {
2230
+ return new ZodArray({
2231
+ ...this._def,
2232
+ exactLength: { value: len, message: errorUtil.toString(message) }
2233
+ });
2234
+ }
2235
+ nonempty(message) {
2236
+ return this.min(1, message);
2237
+ }
2238
+ }
2239
+ ZodArray.create = (schema, params) => {
2240
+ return new ZodArray({
2241
+ type: schema,
2242
+ minLength: null,
2243
+ maxLength: null,
2244
+ exactLength: null,
2245
+ typeName: ZodFirstPartyTypeKind.ZodArray,
2246
+ ...processCreateParams(params)
2247
+ });
2248
+ };
2249
+ function deepPartialify(schema) {
2250
+ if (schema instanceof ZodObject) {
2251
+ const newShape = {};
2252
+ for (const key in schema.shape) {
2253
+ const fieldSchema = schema.shape[key];
2254
+ newShape[key] = ZodOptional.create(deepPartialify(fieldSchema));
2255
+ }
2256
+ return new ZodObject({
2257
+ ...schema._def,
2258
+ shape: () => newShape
2259
+ });
2260
+ } else if (schema instanceof ZodArray) {
2261
+ return new ZodArray({
2262
+ ...schema._def,
2263
+ type: deepPartialify(schema.element)
2264
+ });
2265
+ } else if (schema instanceof ZodOptional) {
2266
+ return ZodOptional.create(deepPartialify(schema.unwrap()));
2267
+ } else if (schema instanceof ZodNullable) {
2268
+ return ZodNullable.create(deepPartialify(schema.unwrap()));
2269
+ } else if (schema instanceof ZodTuple) {
2270
+ return ZodTuple.create(schema.items.map((item) => deepPartialify(item)));
2271
+ } else {
2272
+ return schema;
2273
+ }
2274
+ }
2275
+ class ZodObject extends ZodType {
2276
+ constructor() {
2277
+ super(...arguments);
2278
+ this._cached = null;
2279
+ this.nonstrict = this.passthrough;
2280
+ this.augment = this.extend;
2281
+ }
2282
+ _getCached() {
2283
+ if (this._cached !== null)
2284
+ return this._cached;
2285
+ const shape = this._def.shape();
2286
+ const keys = util.objectKeys(shape);
2287
+ return this._cached = { shape, keys };
2288
+ }
2289
+ _parse(input) {
2290
+ const parsedType = this._getType(input);
2291
+ if (parsedType !== ZodParsedType.object) {
2292
+ const ctx2 = this._getOrReturnCtx(input);
2293
+ addIssueToContext(ctx2, {
2294
+ code: ZodIssueCode.invalid_type,
2295
+ expected: ZodParsedType.object,
2296
+ received: ctx2.parsedType
2297
+ });
2298
+ return INVALID;
2299
+ }
2300
+ const { status, ctx } = this._processInputParams(input);
2301
+ const { shape, keys: shapeKeys } = this._getCached();
2302
+ const extraKeys = [];
2303
+ if (!(this._def.catchall instanceof ZodNever && this._def.unknownKeys === "strip")) {
2304
+ for (const key in ctx.data) {
2305
+ if (!shapeKeys.includes(key)) {
2306
+ extraKeys.push(key);
2307
+ }
2308
+ }
2309
+ }
2310
+ const pairs = [];
2311
+ for (const key of shapeKeys) {
2312
+ const keyValidator = shape[key];
2313
+ const value = ctx.data[key];
2314
+ pairs.push({
2315
+ key: { status: "valid", value: key },
2316
+ value: keyValidator._parse(new ParseInputLazyPath(ctx, value, ctx.path, key)),
2317
+ alwaysSet: key in ctx.data
2318
+ });
2319
+ }
2320
+ if (this._def.catchall instanceof ZodNever) {
2321
+ const unknownKeys = this._def.unknownKeys;
2322
+ if (unknownKeys === "passthrough") {
2323
+ for (const key of extraKeys) {
2324
+ pairs.push({
2325
+ key: { status: "valid", value: key },
2326
+ value: { status: "valid", value: ctx.data[key] }
2327
+ });
2328
+ }
2329
+ } else if (unknownKeys === "strict") {
2330
+ if (extraKeys.length > 0) {
2331
+ addIssueToContext(ctx, {
2332
+ code: ZodIssueCode.unrecognized_keys,
2333
+ keys: extraKeys
2334
+ });
2335
+ status.dirty();
2336
+ }
2337
+ } else if (unknownKeys === "strip") ;
2338
+ else {
2339
+ throw new Error(`Internal ZodObject error: invalid unknownKeys value.`);
2340
+ }
2341
+ } else {
2342
+ const catchall = this._def.catchall;
2343
+ for (const key of extraKeys) {
2344
+ const value = ctx.data[key];
2345
+ pairs.push({
2346
+ key: { status: "valid", value: key },
2347
+ value: catchall._parse(
2348
+ new ParseInputLazyPath(ctx, value, ctx.path, key)
2349
+ //, ctx.child(key), value, getParsedType(value)
2350
+ ),
2351
+ alwaysSet: key in ctx.data
2352
+ });
2353
+ }
2354
+ }
2355
+ if (ctx.common.async) {
2356
+ return Promise.resolve().then(async () => {
2357
+ const syncPairs = [];
2358
+ for (const pair of pairs) {
2359
+ const key = await pair.key;
2360
+ const value = await pair.value;
2361
+ syncPairs.push({
2362
+ key,
2363
+ value,
2364
+ alwaysSet: pair.alwaysSet
2365
+ });
2366
+ }
2367
+ return syncPairs;
2368
+ }).then((syncPairs) => {
2369
+ return ParseStatus.mergeObjectSync(status, syncPairs);
2370
+ });
2371
+ } else {
2372
+ return ParseStatus.mergeObjectSync(status, pairs);
2373
+ }
2374
+ }
2375
+ get shape() {
2376
+ return this._def.shape();
2377
+ }
2378
+ strict(message) {
2379
+ errorUtil.errToObj;
2380
+ return new ZodObject({
2381
+ ...this._def,
2382
+ unknownKeys: "strict",
2383
+ ...message !== void 0 ? {
2384
+ errorMap: (issue, ctx) => {
2385
+ var _a, _b, _c, _d;
2386
+ const defaultError = (_c = (_b = (_a = this._def).errorMap) === null || _b === void 0 ? void 0 : _b.call(_a, issue, ctx).message) !== null && _c !== void 0 ? _c : ctx.defaultError;
2387
+ if (issue.code === "unrecognized_keys")
2388
+ return {
2389
+ message: (_d = errorUtil.errToObj(message).message) !== null && _d !== void 0 ? _d : defaultError
2390
+ };
2391
+ return {
2392
+ message: defaultError
2393
+ };
2394
+ }
2395
+ } : {}
2396
+ });
2397
+ }
2398
+ strip() {
2399
+ return new ZodObject({
2400
+ ...this._def,
2401
+ unknownKeys: "strip"
2402
+ });
2403
+ }
2404
+ passthrough() {
2405
+ return new ZodObject({
2406
+ ...this._def,
2407
+ unknownKeys: "passthrough"
2408
+ });
2409
+ }
2410
+ // const AugmentFactory =
2411
+ // <Def extends ZodObjectDef>(def: Def) =>
2412
+ // <Augmentation extends ZodRawShape>(
2413
+ // augmentation: Augmentation
2414
+ // ): ZodObject<
2415
+ // extendShape<ReturnType<Def["shape"]>, Augmentation>,
2416
+ // Def["unknownKeys"],
2417
+ // Def["catchall"]
2418
+ // > => {
2419
+ // return new ZodObject({
2420
+ // ...def,
2421
+ // shape: () => ({
2422
+ // ...def.shape(),
2423
+ // ...augmentation,
2424
+ // }),
2425
+ // }) as any;
2426
+ // };
2427
+ extend(augmentation) {
2428
+ return new ZodObject({
2429
+ ...this._def,
2430
+ shape: () => ({
2431
+ ...this._def.shape(),
2432
+ ...augmentation
2433
+ })
2434
+ });
2435
+ }
2436
+ /**
2437
+ * Prior to zod@1.0.12 there was a bug in the
2438
+ * inferred type of merged objects. Please
2439
+ * upgrade if you are experiencing issues.
2440
+ */
2441
+ merge(merging) {
2442
+ const merged = new ZodObject({
2443
+ unknownKeys: merging._def.unknownKeys,
2444
+ catchall: merging._def.catchall,
2445
+ shape: () => ({
2446
+ ...this._def.shape(),
2447
+ ...merging._def.shape()
2448
+ }),
2449
+ typeName: ZodFirstPartyTypeKind.ZodObject
2450
+ });
2451
+ return merged;
2452
+ }
2453
+ // merge<
2454
+ // Incoming extends AnyZodObject,
2455
+ // Augmentation extends Incoming["shape"],
2456
+ // NewOutput extends {
2457
+ // [k in keyof Augmentation | keyof Output]: k extends keyof Augmentation
2458
+ // ? Augmentation[k]["_output"]
2459
+ // : k extends keyof Output
2460
+ // ? Output[k]
2461
+ // : never;
2462
+ // },
2463
+ // NewInput extends {
2464
+ // [k in keyof Augmentation | keyof Input]: k extends keyof Augmentation
2465
+ // ? Augmentation[k]["_input"]
2466
+ // : k extends keyof Input
2467
+ // ? Input[k]
2468
+ // : never;
2469
+ // }
2470
+ // >(
2471
+ // merging: Incoming
2472
+ // ): ZodObject<
2473
+ // extendShape<T, ReturnType<Incoming["_def"]["shape"]>>,
2474
+ // Incoming["_def"]["unknownKeys"],
2475
+ // Incoming["_def"]["catchall"],
2476
+ // NewOutput,
2477
+ // NewInput
2478
+ // > {
2479
+ // const merged: any = new ZodObject({
2480
+ // unknownKeys: merging._def.unknownKeys,
2481
+ // catchall: merging._def.catchall,
2482
+ // shape: () =>
2483
+ // objectUtil.mergeShapes(this._def.shape(), merging._def.shape()),
2484
+ // typeName: ZodFirstPartyTypeKind.ZodObject,
2485
+ // }) as any;
2486
+ // return merged;
2487
+ // }
2488
+ setKey(key, schema) {
2489
+ return this.augment({ [key]: schema });
2490
+ }
2491
+ // merge<Incoming extends AnyZodObject>(
2492
+ // merging: Incoming
2493
+ // ): //ZodObject<T & Incoming["_shape"], UnknownKeys, Catchall> = (merging) => {
2494
+ // ZodObject<
2495
+ // extendShape<T, ReturnType<Incoming["_def"]["shape"]>>,
2496
+ // Incoming["_def"]["unknownKeys"],
2497
+ // Incoming["_def"]["catchall"]
2498
+ // > {
2499
+ // // const mergedShape = objectUtil.mergeShapes(
2500
+ // // this._def.shape(),
2501
+ // // merging._def.shape()
2502
+ // // );
2503
+ // const merged: any = new ZodObject({
2504
+ // unknownKeys: merging._def.unknownKeys,
2505
+ // catchall: merging._def.catchall,
2506
+ // shape: () =>
2507
+ // objectUtil.mergeShapes(this._def.shape(), merging._def.shape()),
2508
+ // typeName: ZodFirstPartyTypeKind.ZodObject,
2509
+ // }) as any;
2510
+ // return merged;
2511
+ // }
2512
+ catchall(index) {
2513
+ return new ZodObject({
2514
+ ...this._def,
2515
+ catchall: index
2516
+ });
2517
+ }
2518
+ pick(mask) {
2519
+ const shape = {};
2520
+ util.objectKeys(mask).forEach((key) => {
2521
+ if (mask[key] && this.shape[key]) {
2522
+ shape[key] = this.shape[key];
2523
+ }
2524
+ });
2525
+ return new ZodObject({
2526
+ ...this._def,
2527
+ shape: () => shape
2528
+ });
2529
+ }
2530
+ omit(mask) {
2531
+ const shape = {};
2532
+ util.objectKeys(this.shape).forEach((key) => {
2533
+ if (!mask[key]) {
2534
+ shape[key] = this.shape[key];
2535
+ }
2536
+ });
2537
+ return new ZodObject({
2538
+ ...this._def,
2539
+ shape: () => shape
2540
+ });
2541
+ }
2542
+ /**
2543
+ * @deprecated
2544
+ */
2545
+ deepPartial() {
2546
+ return deepPartialify(this);
2547
+ }
2548
+ partial(mask) {
2549
+ const newShape = {};
2550
+ util.objectKeys(this.shape).forEach((key) => {
2551
+ const fieldSchema = this.shape[key];
2552
+ if (mask && !mask[key]) {
2553
+ newShape[key] = fieldSchema;
2554
+ } else {
2555
+ newShape[key] = fieldSchema.optional();
2556
+ }
2557
+ });
2558
+ return new ZodObject({
2559
+ ...this._def,
2560
+ shape: () => newShape
2561
+ });
2562
+ }
2563
+ required(mask) {
2564
+ const newShape = {};
2565
+ util.objectKeys(this.shape).forEach((key) => {
2566
+ if (mask && !mask[key]) {
2567
+ newShape[key] = this.shape[key];
2568
+ } else {
2569
+ const fieldSchema = this.shape[key];
2570
+ let newField = fieldSchema;
2571
+ while (newField instanceof ZodOptional) {
2572
+ newField = newField._def.innerType;
2573
+ }
2574
+ newShape[key] = newField;
2575
+ }
2576
+ });
2577
+ return new ZodObject({
2578
+ ...this._def,
2579
+ shape: () => newShape
2580
+ });
2581
+ }
2582
+ keyof() {
2583
+ return createZodEnum(util.objectKeys(this.shape));
2584
+ }
2585
+ }
2586
+ ZodObject.create = (shape, params) => {
2587
+ return new ZodObject({
2588
+ shape: () => shape,
2589
+ unknownKeys: "strip",
2590
+ catchall: ZodNever.create(),
2591
+ typeName: ZodFirstPartyTypeKind.ZodObject,
2592
+ ...processCreateParams(params)
2593
+ });
2594
+ };
2595
+ ZodObject.strictCreate = (shape, params) => {
2596
+ return new ZodObject({
2597
+ shape: () => shape,
2598
+ unknownKeys: "strict",
2599
+ catchall: ZodNever.create(),
2600
+ typeName: ZodFirstPartyTypeKind.ZodObject,
2601
+ ...processCreateParams(params)
2602
+ });
2603
+ };
2604
+ ZodObject.lazycreate = (shape, params) => {
2605
+ return new ZodObject({
2606
+ shape,
2607
+ unknownKeys: "strip",
2608
+ catchall: ZodNever.create(),
2609
+ typeName: ZodFirstPartyTypeKind.ZodObject,
2610
+ ...processCreateParams(params)
2611
+ });
2612
+ };
2613
+ class ZodUnion extends ZodType {
2614
+ _parse(input) {
2615
+ const { ctx } = this._processInputParams(input);
2616
+ const options = this._def.options;
2617
+ function handleResults(results) {
2618
+ for (const result of results) {
2619
+ if (result.result.status === "valid") {
2620
+ return result.result;
2621
+ }
2622
+ }
2623
+ for (const result of results) {
2624
+ if (result.result.status === "dirty") {
2625
+ ctx.common.issues.push(...result.ctx.common.issues);
2626
+ return result.result;
2627
+ }
2628
+ }
2629
+ const unionErrors = results.map((result) => new ZodError(result.ctx.common.issues));
2630
+ addIssueToContext(ctx, {
2631
+ code: ZodIssueCode.invalid_union,
2632
+ unionErrors
2633
+ });
2634
+ return INVALID;
2635
+ }
2636
+ if (ctx.common.async) {
2637
+ return Promise.all(options.map(async (option) => {
2638
+ const childCtx = {
2639
+ ...ctx,
2640
+ common: {
2641
+ ...ctx.common,
2642
+ issues: []
2643
+ },
2644
+ parent: null
2645
+ };
2646
+ return {
2647
+ result: await option._parseAsync({
2648
+ data: ctx.data,
2649
+ path: ctx.path,
2650
+ parent: childCtx
2651
+ }),
2652
+ ctx: childCtx
2653
+ };
2654
+ })).then(handleResults);
2655
+ } else {
2656
+ let dirty = void 0;
2657
+ const issues = [];
2658
+ for (const option of options) {
2659
+ const childCtx = {
2660
+ ...ctx,
2661
+ common: {
2662
+ ...ctx.common,
2663
+ issues: []
2664
+ },
2665
+ parent: null
2666
+ };
2667
+ const result = option._parseSync({
2668
+ data: ctx.data,
2669
+ path: ctx.path,
2670
+ parent: childCtx
2671
+ });
2672
+ if (result.status === "valid") {
2673
+ return result;
2674
+ } else if (result.status === "dirty" && !dirty) {
2675
+ dirty = { result, ctx: childCtx };
2676
+ }
2677
+ if (childCtx.common.issues.length) {
2678
+ issues.push(childCtx.common.issues);
2679
+ }
2680
+ }
2681
+ if (dirty) {
2682
+ ctx.common.issues.push(...dirty.ctx.common.issues);
2683
+ return dirty.result;
2684
+ }
2685
+ const unionErrors = issues.map((issues2) => new ZodError(issues2));
2686
+ addIssueToContext(ctx, {
2687
+ code: ZodIssueCode.invalid_union,
2688
+ unionErrors
2689
+ });
2690
+ return INVALID;
2691
+ }
2692
+ }
2693
+ get options() {
2694
+ return this._def.options;
2695
+ }
2696
+ }
2697
+ ZodUnion.create = (types, params) => {
2698
+ return new ZodUnion({
2699
+ options: types,
2700
+ typeName: ZodFirstPartyTypeKind.ZodUnion,
2701
+ ...processCreateParams(params)
2702
+ });
2703
+ };
2704
+ const getDiscriminator = (type) => {
2705
+ if (type instanceof ZodLazy) {
2706
+ return getDiscriminator(type.schema);
2707
+ } else if (type instanceof ZodEffects) {
2708
+ return getDiscriminator(type.innerType());
2709
+ } else if (type instanceof ZodLiteral) {
2710
+ return [type.value];
2711
+ } else if (type instanceof ZodEnum) {
2712
+ return type.options;
2713
+ } else if (type instanceof ZodNativeEnum) {
2714
+ return util.objectValues(type.enum);
2715
+ } else if (type instanceof ZodDefault) {
2716
+ return getDiscriminator(type._def.innerType);
2717
+ } else if (type instanceof ZodUndefined) {
2718
+ return [void 0];
2719
+ } else if (type instanceof ZodNull) {
2720
+ return [null];
2721
+ } else if (type instanceof ZodOptional) {
2722
+ return [void 0, ...getDiscriminator(type.unwrap())];
2723
+ } else if (type instanceof ZodNullable) {
2724
+ return [null, ...getDiscriminator(type.unwrap())];
2725
+ } else if (type instanceof ZodBranded) {
2726
+ return getDiscriminator(type.unwrap());
2727
+ } else if (type instanceof ZodReadonly) {
2728
+ return getDiscriminator(type.unwrap());
2729
+ } else if (type instanceof ZodCatch) {
2730
+ return getDiscriminator(type._def.innerType);
2731
+ } else {
2732
+ return [];
2733
+ }
2734
+ };
2735
+ class ZodDiscriminatedUnion extends ZodType {
2736
+ _parse(input) {
2737
+ const { ctx } = this._processInputParams(input);
2738
+ if (ctx.parsedType !== ZodParsedType.object) {
2739
+ addIssueToContext(ctx, {
2740
+ code: ZodIssueCode.invalid_type,
2741
+ expected: ZodParsedType.object,
2742
+ received: ctx.parsedType
2743
+ });
2744
+ return INVALID;
2745
+ }
2746
+ const discriminator = this.discriminator;
2747
+ const discriminatorValue = ctx.data[discriminator];
2748
+ const option = this.optionsMap.get(discriminatorValue);
2749
+ if (!option) {
2750
+ addIssueToContext(ctx, {
2751
+ code: ZodIssueCode.invalid_union_discriminator,
2752
+ options: Array.from(this.optionsMap.keys()),
2753
+ path: [discriminator]
2754
+ });
2755
+ return INVALID;
2756
+ }
2757
+ if (ctx.common.async) {
2758
+ return option._parseAsync({
2759
+ data: ctx.data,
2760
+ path: ctx.path,
2761
+ parent: ctx
2762
+ });
2763
+ } else {
2764
+ return option._parseSync({
2765
+ data: ctx.data,
2766
+ path: ctx.path,
2767
+ parent: ctx
2768
+ });
2769
+ }
2770
+ }
2771
+ get discriminator() {
2772
+ return this._def.discriminator;
2773
+ }
2774
+ get options() {
2775
+ return this._def.options;
2776
+ }
2777
+ get optionsMap() {
2778
+ return this._def.optionsMap;
2779
+ }
2780
+ /**
2781
+ * The constructor of the discriminated union schema. Its behaviour is very similar to that of the normal z.union() constructor.
2782
+ * However, it only allows a union of objects, all of which need to share a discriminator property. This property must
2783
+ * have a different value for each object in the union.
2784
+ * @param discriminator the name of the discriminator property
2785
+ * @param types an array of object schemas
2786
+ * @param params
2787
+ */
2788
+ static create(discriminator, options, params) {
2789
+ const optionsMap = /* @__PURE__ */ new Map();
2790
+ for (const type of options) {
2791
+ const discriminatorValues = getDiscriminator(type.shape[discriminator]);
2792
+ if (!discriminatorValues.length) {
2793
+ throw new Error(`A discriminator value for key \`${discriminator}\` could not be extracted from all schema options`);
2794
+ }
2795
+ for (const value of discriminatorValues) {
2796
+ if (optionsMap.has(value)) {
2797
+ throw new Error(`Discriminator property ${String(discriminator)} has duplicate value ${String(value)}`);
2798
+ }
2799
+ optionsMap.set(value, type);
2800
+ }
2801
+ }
2802
+ return new ZodDiscriminatedUnion({
2803
+ typeName: ZodFirstPartyTypeKind.ZodDiscriminatedUnion,
2804
+ discriminator,
2805
+ options,
2806
+ optionsMap,
2807
+ ...processCreateParams(params)
2808
+ });
2809
+ }
2810
+ }
2811
+ function mergeValues(a, b) {
2812
+ const aType = getParsedType(a);
2813
+ const bType = getParsedType(b);
2814
+ if (a === b) {
2815
+ return { valid: true, data: a };
2816
+ } else if (aType === ZodParsedType.object && bType === ZodParsedType.object) {
2817
+ const bKeys = util.objectKeys(b);
2818
+ const sharedKeys = util.objectKeys(a).filter((key) => bKeys.indexOf(key) !== -1);
2819
+ const newObj = { ...a, ...b };
2820
+ for (const key of sharedKeys) {
2821
+ const sharedValue = mergeValues(a[key], b[key]);
2822
+ if (!sharedValue.valid) {
2823
+ return { valid: false };
2824
+ }
2825
+ newObj[key] = sharedValue.data;
2826
+ }
2827
+ return { valid: true, data: newObj };
2828
+ } else if (aType === ZodParsedType.array && bType === ZodParsedType.array) {
2829
+ if (a.length !== b.length) {
2830
+ return { valid: false };
2831
+ }
2832
+ const newArray = [];
2833
+ for (let index = 0; index < a.length; index++) {
2834
+ const itemA = a[index];
2835
+ const itemB = b[index];
2836
+ const sharedValue = mergeValues(itemA, itemB);
2837
+ if (!sharedValue.valid) {
2838
+ return { valid: false };
2839
+ }
2840
+ newArray.push(sharedValue.data);
2841
+ }
2842
+ return { valid: true, data: newArray };
2843
+ } else if (aType === ZodParsedType.date && bType === ZodParsedType.date && +a === +b) {
2844
+ return { valid: true, data: a };
2845
+ } else {
2846
+ return { valid: false };
2847
+ }
2848
+ }
2849
+ class ZodIntersection extends ZodType {
2850
+ _parse(input) {
2851
+ const { status, ctx } = this._processInputParams(input);
2852
+ const handleParsed = (parsedLeft, parsedRight) => {
2853
+ if (isAborted(parsedLeft) || isAborted(parsedRight)) {
2854
+ return INVALID;
2855
+ }
2856
+ const merged = mergeValues(parsedLeft.value, parsedRight.value);
2857
+ if (!merged.valid) {
2858
+ addIssueToContext(ctx, {
2859
+ code: ZodIssueCode.invalid_intersection_types
2860
+ });
2861
+ return INVALID;
2862
+ }
2863
+ if (isDirty(parsedLeft) || isDirty(parsedRight)) {
2864
+ status.dirty();
2865
+ }
2866
+ return { status: status.value, value: merged.data };
2867
+ };
2868
+ if (ctx.common.async) {
2869
+ return Promise.all([
2870
+ this._def.left._parseAsync({
2871
+ data: ctx.data,
2872
+ path: ctx.path,
2873
+ parent: ctx
2874
+ }),
2875
+ this._def.right._parseAsync({
2876
+ data: ctx.data,
2877
+ path: ctx.path,
2878
+ parent: ctx
2879
+ })
2880
+ ]).then(([left, right]) => handleParsed(left, right));
2881
+ } else {
2882
+ return handleParsed(this._def.left._parseSync({
2883
+ data: ctx.data,
2884
+ path: ctx.path,
2885
+ parent: ctx
2886
+ }), this._def.right._parseSync({
2887
+ data: ctx.data,
2888
+ path: ctx.path,
2889
+ parent: ctx
2890
+ }));
2891
+ }
2892
+ }
2893
+ }
2894
+ ZodIntersection.create = (left, right, params) => {
2895
+ return new ZodIntersection({
2896
+ left,
2897
+ right,
2898
+ typeName: ZodFirstPartyTypeKind.ZodIntersection,
2899
+ ...processCreateParams(params)
2900
+ });
2901
+ };
2902
+ class ZodTuple extends ZodType {
2903
+ _parse(input) {
2904
+ const { status, ctx } = this._processInputParams(input);
2905
+ if (ctx.parsedType !== ZodParsedType.array) {
2906
+ addIssueToContext(ctx, {
2907
+ code: ZodIssueCode.invalid_type,
2908
+ expected: ZodParsedType.array,
2909
+ received: ctx.parsedType
2910
+ });
2911
+ return INVALID;
2912
+ }
2913
+ if (ctx.data.length < this._def.items.length) {
2914
+ addIssueToContext(ctx, {
2915
+ code: ZodIssueCode.too_small,
2916
+ minimum: this._def.items.length,
2917
+ inclusive: true,
2918
+ exact: false,
2919
+ type: "array"
2920
+ });
2921
+ return INVALID;
2922
+ }
2923
+ const rest = this._def.rest;
2924
+ if (!rest && ctx.data.length > this._def.items.length) {
2925
+ addIssueToContext(ctx, {
2926
+ code: ZodIssueCode.too_big,
2927
+ maximum: this._def.items.length,
2928
+ inclusive: true,
2929
+ exact: false,
2930
+ type: "array"
2931
+ });
2932
+ status.dirty();
2933
+ }
2934
+ const items = [...ctx.data].map((item, itemIndex) => {
2935
+ const schema = this._def.items[itemIndex] || this._def.rest;
2936
+ if (!schema)
2937
+ return null;
2938
+ return schema._parse(new ParseInputLazyPath(ctx, item, ctx.path, itemIndex));
2939
+ }).filter((x) => !!x);
2940
+ if (ctx.common.async) {
2941
+ return Promise.all(items).then((results) => {
2942
+ return ParseStatus.mergeArray(status, results);
2943
+ });
2944
+ } else {
2945
+ return ParseStatus.mergeArray(status, items);
2946
+ }
2947
+ }
2948
+ get items() {
2949
+ return this._def.items;
2950
+ }
2951
+ rest(rest) {
2952
+ return new ZodTuple({
2953
+ ...this._def,
2954
+ rest
2955
+ });
2956
+ }
2957
+ }
2958
+ ZodTuple.create = (schemas, params) => {
2959
+ if (!Array.isArray(schemas)) {
2960
+ throw new Error("You must pass an array of schemas to z.tuple([ ... ])");
2961
+ }
2962
+ return new ZodTuple({
2963
+ items: schemas,
2964
+ typeName: ZodFirstPartyTypeKind.ZodTuple,
2965
+ rest: null,
2966
+ ...processCreateParams(params)
2967
+ });
2968
+ };
2969
+ class ZodRecord extends ZodType {
2970
+ get keySchema() {
2971
+ return this._def.keyType;
2972
+ }
2973
+ get valueSchema() {
2974
+ return this._def.valueType;
2975
+ }
2976
+ _parse(input) {
2977
+ const { status, ctx } = this._processInputParams(input);
2978
+ if (ctx.parsedType !== ZodParsedType.object) {
2979
+ addIssueToContext(ctx, {
2980
+ code: ZodIssueCode.invalid_type,
2981
+ expected: ZodParsedType.object,
2982
+ received: ctx.parsedType
2983
+ });
2984
+ return INVALID;
2985
+ }
2986
+ const pairs = [];
2987
+ const keyType = this._def.keyType;
2988
+ const valueType = this._def.valueType;
2989
+ for (const key in ctx.data) {
2990
+ pairs.push({
2991
+ key: keyType._parse(new ParseInputLazyPath(ctx, key, ctx.path, key)),
2992
+ value: valueType._parse(new ParseInputLazyPath(ctx, ctx.data[key], ctx.path, key)),
2993
+ alwaysSet: key in ctx.data
2994
+ });
2995
+ }
2996
+ if (ctx.common.async) {
2997
+ return ParseStatus.mergeObjectAsync(status, pairs);
2998
+ } else {
2999
+ return ParseStatus.mergeObjectSync(status, pairs);
3000
+ }
3001
+ }
3002
+ get element() {
3003
+ return this._def.valueType;
3004
+ }
3005
+ static create(first, second, third) {
3006
+ if (second instanceof ZodType) {
3007
+ return new ZodRecord({
3008
+ keyType: first,
3009
+ valueType: second,
3010
+ typeName: ZodFirstPartyTypeKind.ZodRecord,
3011
+ ...processCreateParams(third)
3012
+ });
3013
+ }
3014
+ return new ZodRecord({
3015
+ keyType: ZodString.create(),
3016
+ valueType: first,
3017
+ typeName: ZodFirstPartyTypeKind.ZodRecord,
3018
+ ...processCreateParams(second)
3019
+ });
3020
+ }
3021
+ }
3022
+ class ZodMap extends ZodType {
3023
+ get keySchema() {
3024
+ return this._def.keyType;
3025
+ }
3026
+ get valueSchema() {
3027
+ return this._def.valueType;
3028
+ }
3029
+ _parse(input) {
3030
+ const { status, ctx } = this._processInputParams(input);
3031
+ if (ctx.parsedType !== ZodParsedType.map) {
3032
+ addIssueToContext(ctx, {
3033
+ code: ZodIssueCode.invalid_type,
3034
+ expected: ZodParsedType.map,
3035
+ received: ctx.parsedType
3036
+ });
3037
+ return INVALID;
3038
+ }
3039
+ const keyType = this._def.keyType;
3040
+ const valueType = this._def.valueType;
3041
+ const pairs = [...ctx.data.entries()].map(([key, value], index) => {
3042
+ return {
3043
+ key: keyType._parse(new ParseInputLazyPath(ctx, key, ctx.path, [index, "key"])),
3044
+ value: valueType._parse(new ParseInputLazyPath(ctx, value, ctx.path, [index, "value"]))
3045
+ };
3046
+ });
3047
+ if (ctx.common.async) {
3048
+ const finalMap = /* @__PURE__ */ new Map();
3049
+ return Promise.resolve().then(async () => {
3050
+ for (const pair of pairs) {
3051
+ const key = await pair.key;
3052
+ const value = await pair.value;
3053
+ if (key.status === "aborted" || value.status === "aborted") {
3054
+ return INVALID;
3055
+ }
3056
+ if (key.status === "dirty" || value.status === "dirty") {
3057
+ status.dirty();
3058
+ }
3059
+ finalMap.set(key.value, value.value);
3060
+ }
3061
+ return { status: status.value, value: finalMap };
3062
+ });
3063
+ } else {
3064
+ const finalMap = /* @__PURE__ */ new Map();
3065
+ for (const pair of pairs) {
3066
+ const key = pair.key;
3067
+ const value = pair.value;
3068
+ if (key.status === "aborted" || value.status === "aborted") {
3069
+ return INVALID;
3070
+ }
3071
+ if (key.status === "dirty" || value.status === "dirty") {
3072
+ status.dirty();
3073
+ }
3074
+ finalMap.set(key.value, value.value);
3075
+ }
3076
+ return { status: status.value, value: finalMap };
3077
+ }
3078
+ }
3079
+ }
3080
+ ZodMap.create = (keyType, valueType, params) => {
3081
+ return new ZodMap({
3082
+ valueType,
3083
+ keyType,
3084
+ typeName: ZodFirstPartyTypeKind.ZodMap,
3085
+ ...processCreateParams(params)
3086
+ });
3087
+ };
3088
+ class ZodSet extends ZodType {
3089
+ _parse(input) {
3090
+ const { status, ctx } = this._processInputParams(input);
3091
+ if (ctx.parsedType !== ZodParsedType.set) {
3092
+ addIssueToContext(ctx, {
3093
+ code: ZodIssueCode.invalid_type,
3094
+ expected: ZodParsedType.set,
3095
+ received: ctx.parsedType
3096
+ });
3097
+ return INVALID;
3098
+ }
3099
+ const def = this._def;
3100
+ if (def.minSize !== null) {
3101
+ if (ctx.data.size < def.minSize.value) {
3102
+ addIssueToContext(ctx, {
3103
+ code: ZodIssueCode.too_small,
3104
+ minimum: def.minSize.value,
3105
+ type: "set",
3106
+ inclusive: true,
3107
+ exact: false,
3108
+ message: def.minSize.message
3109
+ });
3110
+ status.dirty();
3111
+ }
3112
+ }
3113
+ if (def.maxSize !== null) {
3114
+ if (ctx.data.size > def.maxSize.value) {
3115
+ addIssueToContext(ctx, {
3116
+ code: ZodIssueCode.too_big,
3117
+ maximum: def.maxSize.value,
3118
+ type: "set",
3119
+ inclusive: true,
3120
+ exact: false,
3121
+ message: def.maxSize.message
3122
+ });
3123
+ status.dirty();
3124
+ }
3125
+ }
3126
+ const valueType = this._def.valueType;
3127
+ function finalizeSet(elements2) {
3128
+ const parsedSet = /* @__PURE__ */ new Set();
3129
+ for (const element of elements2) {
3130
+ if (element.status === "aborted")
3131
+ return INVALID;
3132
+ if (element.status === "dirty")
3133
+ status.dirty();
3134
+ parsedSet.add(element.value);
3135
+ }
3136
+ return { status: status.value, value: parsedSet };
3137
+ }
3138
+ const elements = [...ctx.data.values()].map((item, i) => valueType._parse(new ParseInputLazyPath(ctx, item, ctx.path, i)));
3139
+ if (ctx.common.async) {
3140
+ return Promise.all(elements).then((elements2) => finalizeSet(elements2));
3141
+ } else {
3142
+ return finalizeSet(elements);
3143
+ }
3144
+ }
3145
+ min(minSize, message) {
3146
+ return new ZodSet({
3147
+ ...this._def,
3148
+ minSize: { value: minSize, message: errorUtil.toString(message) }
3149
+ });
3150
+ }
3151
+ max(maxSize, message) {
3152
+ return new ZodSet({
3153
+ ...this._def,
3154
+ maxSize: { value: maxSize, message: errorUtil.toString(message) }
3155
+ });
3156
+ }
3157
+ size(size, message) {
3158
+ return this.min(size, message).max(size, message);
3159
+ }
3160
+ nonempty(message) {
3161
+ return this.min(1, message);
3162
+ }
3163
+ }
3164
+ ZodSet.create = (valueType, params) => {
3165
+ return new ZodSet({
3166
+ valueType,
3167
+ minSize: null,
3168
+ maxSize: null,
3169
+ typeName: ZodFirstPartyTypeKind.ZodSet,
3170
+ ...processCreateParams(params)
3171
+ });
3172
+ };
3173
+ class ZodFunction extends ZodType {
3174
+ constructor() {
3175
+ super(...arguments);
3176
+ this.validate = this.implement;
3177
+ }
3178
+ _parse(input) {
3179
+ const { ctx } = this._processInputParams(input);
3180
+ if (ctx.parsedType !== ZodParsedType.function) {
3181
+ addIssueToContext(ctx, {
3182
+ code: ZodIssueCode.invalid_type,
3183
+ expected: ZodParsedType.function,
3184
+ received: ctx.parsedType
3185
+ });
3186
+ return INVALID;
3187
+ }
3188
+ function makeArgsIssue(args, error) {
3189
+ return makeIssue({
3190
+ data: args,
3191
+ path: ctx.path,
3192
+ errorMaps: [
3193
+ ctx.common.contextualErrorMap,
3194
+ ctx.schemaErrorMap,
3195
+ getErrorMap(),
3196
+ errorMap
3197
+ ].filter((x) => !!x),
3198
+ issueData: {
3199
+ code: ZodIssueCode.invalid_arguments,
3200
+ argumentsError: error
3201
+ }
3202
+ });
3203
+ }
3204
+ function makeReturnsIssue(returns, error) {
3205
+ return makeIssue({
3206
+ data: returns,
3207
+ path: ctx.path,
3208
+ errorMaps: [
3209
+ ctx.common.contextualErrorMap,
3210
+ ctx.schemaErrorMap,
3211
+ getErrorMap(),
3212
+ errorMap
3213
+ ].filter((x) => !!x),
3214
+ issueData: {
3215
+ code: ZodIssueCode.invalid_return_type,
3216
+ returnTypeError: error
3217
+ }
3218
+ });
3219
+ }
3220
+ const params = { errorMap: ctx.common.contextualErrorMap };
3221
+ const fn = ctx.data;
3222
+ if (this._def.returns instanceof ZodPromise) {
3223
+ const me = this;
3224
+ return OK(async function(...args) {
3225
+ const error = new ZodError([]);
3226
+ const parsedArgs = await me._def.args.parseAsync(args, params).catch((e) => {
3227
+ error.addIssue(makeArgsIssue(args, e));
3228
+ throw error;
3229
+ });
3230
+ const result = await Reflect.apply(fn, this, parsedArgs);
3231
+ const parsedReturns = await me._def.returns._def.type.parseAsync(result, params).catch((e) => {
3232
+ error.addIssue(makeReturnsIssue(result, e));
3233
+ throw error;
3234
+ });
3235
+ return parsedReturns;
3236
+ });
3237
+ } else {
3238
+ const me = this;
3239
+ return OK(function(...args) {
3240
+ const parsedArgs = me._def.args.safeParse(args, params);
3241
+ if (!parsedArgs.success) {
3242
+ throw new ZodError([makeArgsIssue(args, parsedArgs.error)]);
3243
+ }
3244
+ const result = Reflect.apply(fn, this, parsedArgs.data);
3245
+ const parsedReturns = me._def.returns.safeParse(result, params);
3246
+ if (!parsedReturns.success) {
3247
+ throw new ZodError([makeReturnsIssue(result, parsedReturns.error)]);
3248
+ }
3249
+ return parsedReturns.data;
3250
+ });
3251
+ }
3252
+ }
3253
+ parameters() {
3254
+ return this._def.args;
3255
+ }
3256
+ returnType() {
3257
+ return this._def.returns;
3258
+ }
3259
+ args(...items) {
3260
+ return new ZodFunction({
3261
+ ...this._def,
3262
+ args: ZodTuple.create(items).rest(ZodUnknown.create())
3263
+ });
3264
+ }
3265
+ returns(returnType) {
3266
+ return new ZodFunction({
3267
+ ...this._def,
3268
+ returns: returnType
3269
+ });
3270
+ }
3271
+ implement(func) {
3272
+ const validatedFunc = this.parse(func);
3273
+ return validatedFunc;
3274
+ }
3275
+ strictImplement(func) {
3276
+ const validatedFunc = this.parse(func);
3277
+ return validatedFunc;
3278
+ }
3279
+ static create(args, returns, params) {
3280
+ return new ZodFunction({
3281
+ args: args ? args : ZodTuple.create([]).rest(ZodUnknown.create()),
3282
+ returns: returns || ZodUnknown.create(),
3283
+ typeName: ZodFirstPartyTypeKind.ZodFunction,
3284
+ ...processCreateParams(params)
3285
+ });
3286
+ }
3287
+ }
3288
+ class ZodLazy extends ZodType {
3289
+ get schema() {
3290
+ return this._def.getter();
3291
+ }
3292
+ _parse(input) {
3293
+ const { ctx } = this._processInputParams(input);
3294
+ const lazySchema = this._def.getter();
3295
+ return lazySchema._parse({ data: ctx.data, path: ctx.path, parent: ctx });
3296
+ }
3297
+ }
3298
+ ZodLazy.create = (getter, params) => {
3299
+ return new ZodLazy({
3300
+ getter,
3301
+ typeName: ZodFirstPartyTypeKind.ZodLazy,
3302
+ ...processCreateParams(params)
3303
+ });
3304
+ };
3305
+ class ZodLiteral extends ZodType {
3306
+ _parse(input) {
3307
+ if (input.data !== this._def.value) {
3308
+ const ctx = this._getOrReturnCtx(input);
3309
+ addIssueToContext(ctx, {
3310
+ received: ctx.data,
3311
+ code: ZodIssueCode.invalid_literal,
3312
+ expected: this._def.value
3313
+ });
3314
+ return INVALID;
3315
+ }
3316
+ return { status: "valid", value: input.data };
3317
+ }
3318
+ get value() {
3319
+ return this._def.value;
3320
+ }
3321
+ }
3322
+ ZodLiteral.create = (value, params) => {
3323
+ return new ZodLiteral({
3324
+ value,
3325
+ typeName: ZodFirstPartyTypeKind.ZodLiteral,
3326
+ ...processCreateParams(params)
3327
+ });
3328
+ };
3329
+ function createZodEnum(values, params) {
3330
+ return new ZodEnum({
3331
+ values,
3332
+ typeName: ZodFirstPartyTypeKind.ZodEnum,
3333
+ ...processCreateParams(params)
3334
+ });
3335
+ }
3336
+ class ZodEnum extends ZodType {
3337
+ constructor() {
3338
+ super(...arguments);
3339
+ _ZodEnum_cache.set(this, void 0);
3340
+ }
3341
+ _parse(input) {
3342
+ if (typeof input.data !== "string") {
3343
+ const ctx = this._getOrReturnCtx(input);
3344
+ const expectedValues = this._def.values;
3345
+ addIssueToContext(ctx, {
3346
+ expected: util.joinValues(expectedValues),
3347
+ received: ctx.parsedType,
3348
+ code: ZodIssueCode.invalid_type
3349
+ });
3350
+ return INVALID;
3351
+ }
3352
+ if (!__classPrivateFieldGet(this, _ZodEnum_cache)) {
3353
+ __classPrivateFieldSet(this, _ZodEnum_cache, new Set(this._def.values));
3354
+ }
3355
+ if (!__classPrivateFieldGet(this, _ZodEnum_cache).has(input.data)) {
3356
+ const ctx = this._getOrReturnCtx(input);
3357
+ const expectedValues = this._def.values;
3358
+ addIssueToContext(ctx, {
3359
+ received: ctx.data,
3360
+ code: ZodIssueCode.invalid_enum_value,
3361
+ options: expectedValues
3362
+ });
3363
+ return INVALID;
3364
+ }
3365
+ return OK(input.data);
3366
+ }
3367
+ get options() {
3368
+ return this._def.values;
3369
+ }
3370
+ get enum() {
3371
+ const enumValues = {};
3372
+ for (const val of this._def.values) {
3373
+ enumValues[val] = val;
3374
+ }
3375
+ return enumValues;
3376
+ }
3377
+ get Values() {
3378
+ const enumValues = {};
3379
+ for (const val of this._def.values) {
3380
+ enumValues[val] = val;
3381
+ }
3382
+ return enumValues;
3383
+ }
3384
+ get Enum() {
3385
+ const enumValues = {};
3386
+ for (const val of this._def.values) {
3387
+ enumValues[val] = val;
3388
+ }
3389
+ return enumValues;
3390
+ }
3391
+ extract(values, newDef = this._def) {
3392
+ return ZodEnum.create(values, {
3393
+ ...this._def,
3394
+ ...newDef
3395
+ });
3396
+ }
3397
+ exclude(values, newDef = this._def) {
3398
+ return ZodEnum.create(this.options.filter((opt) => !values.includes(opt)), {
3399
+ ...this._def,
3400
+ ...newDef
3401
+ });
3402
+ }
3403
+ }
3404
+ _ZodEnum_cache = /* @__PURE__ */ new WeakMap();
3405
+ ZodEnum.create = createZodEnum;
3406
+ class ZodNativeEnum extends ZodType {
3407
+ constructor() {
3408
+ super(...arguments);
3409
+ _ZodNativeEnum_cache.set(this, void 0);
3410
+ }
3411
+ _parse(input) {
3412
+ const nativeEnumValues = util.getValidEnumValues(this._def.values);
3413
+ const ctx = this._getOrReturnCtx(input);
3414
+ if (ctx.parsedType !== ZodParsedType.string && ctx.parsedType !== ZodParsedType.number) {
3415
+ const expectedValues = util.objectValues(nativeEnumValues);
3416
+ addIssueToContext(ctx, {
3417
+ expected: util.joinValues(expectedValues),
3418
+ received: ctx.parsedType,
3419
+ code: ZodIssueCode.invalid_type
3420
+ });
3421
+ return INVALID;
3422
+ }
3423
+ if (!__classPrivateFieldGet(this, _ZodNativeEnum_cache)) {
3424
+ __classPrivateFieldSet(this, _ZodNativeEnum_cache, new Set(util.getValidEnumValues(this._def.values)));
3425
+ }
3426
+ if (!__classPrivateFieldGet(this, _ZodNativeEnum_cache).has(input.data)) {
3427
+ const expectedValues = util.objectValues(nativeEnumValues);
3428
+ addIssueToContext(ctx, {
3429
+ received: ctx.data,
3430
+ code: ZodIssueCode.invalid_enum_value,
3431
+ options: expectedValues
3432
+ });
3433
+ return INVALID;
3434
+ }
3435
+ return OK(input.data);
3436
+ }
3437
+ get enum() {
3438
+ return this._def.values;
3439
+ }
3440
+ }
3441
+ _ZodNativeEnum_cache = /* @__PURE__ */ new WeakMap();
3442
+ ZodNativeEnum.create = (values, params) => {
3443
+ return new ZodNativeEnum({
3444
+ values,
3445
+ typeName: ZodFirstPartyTypeKind.ZodNativeEnum,
3446
+ ...processCreateParams(params)
3447
+ });
3448
+ };
3449
+ class ZodPromise extends ZodType {
3450
+ unwrap() {
3451
+ return this._def.type;
3452
+ }
3453
+ _parse(input) {
3454
+ const { ctx } = this._processInputParams(input);
3455
+ if (ctx.parsedType !== ZodParsedType.promise && ctx.common.async === false) {
3456
+ addIssueToContext(ctx, {
3457
+ code: ZodIssueCode.invalid_type,
3458
+ expected: ZodParsedType.promise,
3459
+ received: ctx.parsedType
3460
+ });
3461
+ return INVALID;
3462
+ }
3463
+ const promisified = ctx.parsedType === ZodParsedType.promise ? ctx.data : Promise.resolve(ctx.data);
3464
+ return OK(promisified.then((data) => {
3465
+ return this._def.type.parseAsync(data, {
3466
+ path: ctx.path,
3467
+ errorMap: ctx.common.contextualErrorMap
3468
+ });
3469
+ }));
3470
+ }
3471
+ }
3472
+ ZodPromise.create = (schema, params) => {
3473
+ return new ZodPromise({
3474
+ type: schema,
3475
+ typeName: ZodFirstPartyTypeKind.ZodPromise,
3476
+ ...processCreateParams(params)
3477
+ });
3478
+ };
3479
+ class ZodEffects extends ZodType {
3480
+ innerType() {
3481
+ return this._def.schema;
3482
+ }
3483
+ sourceType() {
3484
+ return this._def.schema._def.typeName === ZodFirstPartyTypeKind.ZodEffects ? this._def.schema.sourceType() : this._def.schema;
3485
+ }
3486
+ _parse(input) {
3487
+ const { status, ctx } = this._processInputParams(input);
3488
+ const effect = this._def.effect || null;
3489
+ const checkCtx = {
3490
+ addIssue: (arg) => {
3491
+ addIssueToContext(ctx, arg);
3492
+ if (arg.fatal) {
3493
+ status.abort();
3494
+ } else {
3495
+ status.dirty();
3496
+ }
3497
+ },
3498
+ get path() {
3499
+ return ctx.path;
3500
+ }
3501
+ };
3502
+ checkCtx.addIssue = checkCtx.addIssue.bind(checkCtx);
3503
+ if (effect.type === "preprocess") {
3504
+ const processed = effect.transform(ctx.data, checkCtx);
3505
+ if (ctx.common.async) {
3506
+ return Promise.resolve(processed).then(async (processed2) => {
3507
+ if (status.value === "aborted")
3508
+ return INVALID;
3509
+ const result = await this._def.schema._parseAsync({
3510
+ data: processed2,
3511
+ path: ctx.path,
3512
+ parent: ctx
3513
+ });
3514
+ if (result.status === "aborted")
3515
+ return INVALID;
3516
+ if (result.status === "dirty")
3517
+ return DIRTY(result.value);
3518
+ if (status.value === "dirty")
3519
+ return DIRTY(result.value);
3520
+ return result;
3521
+ });
3522
+ } else {
3523
+ if (status.value === "aborted")
3524
+ return INVALID;
3525
+ const result = this._def.schema._parseSync({
3526
+ data: processed,
3527
+ path: ctx.path,
3528
+ parent: ctx
3529
+ });
3530
+ if (result.status === "aborted")
3531
+ return INVALID;
3532
+ if (result.status === "dirty")
3533
+ return DIRTY(result.value);
3534
+ if (status.value === "dirty")
3535
+ return DIRTY(result.value);
3536
+ return result;
3537
+ }
3538
+ }
3539
+ if (effect.type === "refinement") {
3540
+ const executeRefinement = (acc) => {
3541
+ const result = effect.refinement(acc, checkCtx);
3542
+ if (ctx.common.async) {
3543
+ return Promise.resolve(result);
3544
+ }
3545
+ if (result instanceof Promise) {
3546
+ throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");
3547
+ }
3548
+ return acc;
3549
+ };
3550
+ if (ctx.common.async === false) {
3551
+ const inner = this._def.schema._parseSync({
3552
+ data: ctx.data,
3553
+ path: ctx.path,
3554
+ parent: ctx
3555
+ });
3556
+ if (inner.status === "aborted")
3557
+ return INVALID;
3558
+ if (inner.status === "dirty")
3559
+ status.dirty();
3560
+ executeRefinement(inner.value);
3561
+ return { status: status.value, value: inner.value };
3562
+ } else {
3563
+ return this._def.schema._parseAsync({ data: ctx.data, path: ctx.path, parent: ctx }).then((inner) => {
3564
+ if (inner.status === "aborted")
3565
+ return INVALID;
3566
+ if (inner.status === "dirty")
3567
+ status.dirty();
3568
+ return executeRefinement(inner.value).then(() => {
3569
+ return { status: status.value, value: inner.value };
3570
+ });
3571
+ });
3572
+ }
3573
+ }
3574
+ if (effect.type === "transform") {
3575
+ if (ctx.common.async === false) {
3576
+ const base = this._def.schema._parseSync({
3577
+ data: ctx.data,
3578
+ path: ctx.path,
3579
+ parent: ctx
3580
+ });
3581
+ if (!isValid(base))
3582
+ return base;
3583
+ const result = effect.transform(base.value, checkCtx);
3584
+ if (result instanceof Promise) {
3585
+ throw new Error(`Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.`);
3586
+ }
3587
+ return { status: status.value, value: result };
3588
+ } else {
3589
+ return this._def.schema._parseAsync({ data: ctx.data, path: ctx.path, parent: ctx }).then((base) => {
3590
+ if (!isValid(base))
3591
+ return base;
3592
+ return Promise.resolve(effect.transform(base.value, checkCtx)).then((result) => ({ status: status.value, value: result }));
3593
+ });
3594
+ }
3595
+ }
3596
+ util.assertNever(effect);
3597
+ }
3598
+ }
3599
+ ZodEffects.create = (schema, effect, params) => {
3600
+ return new ZodEffects({
3601
+ schema,
3602
+ typeName: ZodFirstPartyTypeKind.ZodEffects,
3603
+ effect,
3604
+ ...processCreateParams(params)
3605
+ });
3606
+ };
3607
+ ZodEffects.createWithPreprocess = (preprocess, schema, params) => {
3608
+ return new ZodEffects({
3609
+ schema,
3610
+ effect: { type: "preprocess", transform: preprocess },
3611
+ typeName: ZodFirstPartyTypeKind.ZodEffects,
3612
+ ...processCreateParams(params)
3613
+ });
3614
+ };
3615
+ class ZodOptional extends ZodType {
3616
+ _parse(input) {
3617
+ const parsedType = this._getType(input);
3618
+ if (parsedType === ZodParsedType.undefined) {
3619
+ return OK(void 0);
3620
+ }
3621
+ return this._def.innerType._parse(input);
3622
+ }
3623
+ unwrap() {
3624
+ return this._def.innerType;
3625
+ }
3626
+ }
3627
+ ZodOptional.create = (type, params) => {
3628
+ return new ZodOptional({
3629
+ innerType: type,
3630
+ typeName: ZodFirstPartyTypeKind.ZodOptional,
3631
+ ...processCreateParams(params)
3632
+ });
3633
+ };
3634
+ class ZodNullable extends ZodType {
3635
+ _parse(input) {
3636
+ const parsedType = this._getType(input);
3637
+ if (parsedType === ZodParsedType.null) {
3638
+ return OK(null);
3639
+ }
3640
+ return this._def.innerType._parse(input);
3641
+ }
3642
+ unwrap() {
3643
+ return this._def.innerType;
3644
+ }
3645
+ }
3646
+ ZodNullable.create = (type, params) => {
3647
+ return new ZodNullable({
3648
+ innerType: type,
3649
+ typeName: ZodFirstPartyTypeKind.ZodNullable,
3650
+ ...processCreateParams(params)
3651
+ });
3652
+ };
3653
+ class ZodDefault extends ZodType {
3654
+ _parse(input) {
3655
+ const { ctx } = this._processInputParams(input);
3656
+ let data = ctx.data;
3657
+ if (ctx.parsedType === ZodParsedType.undefined) {
3658
+ data = this._def.defaultValue();
3659
+ }
3660
+ return this._def.innerType._parse({
3661
+ data,
3662
+ path: ctx.path,
3663
+ parent: ctx
3664
+ });
3665
+ }
3666
+ removeDefault() {
3667
+ return this._def.innerType;
3668
+ }
3669
+ }
3670
+ ZodDefault.create = (type, params) => {
3671
+ return new ZodDefault({
3672
+ innerType: type,
3673
+ typeName: ZodFirstPartyTypeKind.ZodDefault,
3674
+ defaultValue: typeof params.default === "function" ? params.default : () => params.default,
3675
+ ...processCreateParams(params)
3676
+ });
3677
+ };
3678
+ class ZodCatch extends ZodType {
3679
+ _parse(input) {
3680
+ const { ctx } = this._processInputParams(input);
3681
+ const newCtx = {
3682
+ ...ctx,
3683
+ common: {
3684
+ ...ctx.common,
3685
+ issues: []
3686
+ }
3687
+ };
3688
+ const result = this._def.innerType._parse({
3689
+ data: newCtx.data,
3690
+ path: newCtx.path,
3691
+ parent: {
3692
+ ...newCtx
3693
+ }
3694
+ });
3695
+ if (isAsync(result)) {
3696
+ return result.then((result2) => {
3697
+ return {
3698
+ status: "valid",
3699
+ value: result2.status === "valid" ? result2.value : this._def.catchValue({
3700
+ get error() {
3701
+ return new ZodError(newCtx.common.issues);
3702
+ },
3703
+ input: newCtx.data
3704
+ })
3705
+ };
3706
+ });
3707
+ } else {
3708
+ return {
3709
+ status: "valid",
3710
+ value: result.status === "valid" ? result.value : this._def.catchValue({
3711
+ get error() {
3712
+ return new ZodError(newCtx.common.issues);
3713
+ },
3714
+ input: newCtx.data
3715
+ })
3716
+ };
3717
+ }
3718
+ }
3719
+ removeCatch() {
3720
+ return this._def.innerType;
3721
+ }
3722
+ }
3723
+ ZodCatch.create = (type, params) => {
3724
+ return new ZodCatch({
3725
+ innerType: type,
3726
+ typeName: ZodFirstPartyTypeKind.ZodCatch,
3727
+ catchValue: typeof params.catch === "function" ? params.catch : () => params.catch,
3728
+ ...processCreateParams(params)
3729
+ });
3730
+ };
3731
+ class ZodNaN extends ZodType {
3732
+ _parse(input) {
3733
+ const parsedType = this._getType(input);
3734
+ if (parsedType !== ZodParsedType.nan) {
3735
+ const ctx = this._getOrReturnCtx(input);
3736
+ addIssueToContext(ctx, {
3737
+ code: ZodIssueCode.invalid_type,
3738
+ expected: ZodParsedType.nan,
3739
+ received: ctx.parsedType
3740
+ });
3741
+ return INVALID;
3742
+ }
3743
+ return { status: "valid", value: input.data };
3744
+ }
3745
+ }
3746
+ ZodNaN.create = (params) => {
3747
+ return new ZodNaN({
3748
+ typeName: ZodFirstPartyTypeKind.ZodNaN,
3749
+ ...processCreateParams(params)
3750
+ });
3751
+ };
3752
+ const BRAND = Symbol("zod_brand");
3753
+ class ZodBranded extends ZodType {
3754
+ _parse(input) {
3755
+ const { ctx } = this._processInputParams(input);
3756
+ const data = ctx.data;
3757
+ return this._def.type._parse({
3758
+ data,
3759
+ path: ctx.path,
3760
+ parent: ctx
3761
+ });
3762
+ }
3763
+ unwrap() {
3764
+ return this._def.type;
3765
+ }
3766
+ }
3767
+ class ZodPipeline extends ZodType {
3768
+ _parse(input) {
3769
+ const { status, ctx } = this._processInputParams(input);
3770
+ if (ctx.common.async) {
3771
+ const handleAsync = async () => {
3772
+ const inResult = await this._def.in._parseAsync({
3773
+ data: ctx.data,
3774
+ path: ctx.path,
3775
+ parent: ctx
3776
+ });
3777
+ if (inResult.status === "aborted")
3778
+ return INVALID;
3779
+ if (inResult.status === "dirty") {
3780
+ status.dirty();
3781
+ return DIRTY(inResult.value);
3782
+ } else {
3783
+ return this._def.out._parseAsync({
3784
+ data: inResult.value,
3785
+ path: ctx.path,
3786
+ parent: ctx
3787
+ });
3788
+ }
3789
+ };
3790
+ return handleAsync();
3791
+ } else {
3792
+ const inResult = this._def.in._parseSync({
3793
+ data: ctx.data,
3794
+ path: ctx.path,
3795
+ parent: ctx
3796
+ });
3797
+ if (inResult.status === "aborted")
3798
+ return INVALID;
3799
+ if (inResult.status === "dirty") {
3800
+ status.dirty();
3801
+ return {
3802
+ status: "dirty",
3803
+ value: inResult.value
3804
+ };
3805
+ } else {
3806
+ return this._def.out._parseSync({
3807
+ data: inResult.value,
3808
+ path: ctx.path,
3809
+ parent: ctx
3810
+ });
3811
+ }
3812
+ }
3813
+ }
3814
+ static create(a, b) {
3815
+ return new ZodPipeline({
3816
+ in: a,
3817
+ out: b,
3818
+ typeName: ZodFirstPartyTypeKind.ZodPipeline
3819
+ });
3820
+ }
3821
+ }
3822
+ class ZodReadonly extends ZodType {
3823
+ _parse(input) {
3824
+ const result = this._def.innerType._parse(input);
3825
+ const freeze = (data) => {
3826
+ if (isValid(data)) {
3827
+ data.value = Object.freeze(data.value);
3828
+ }
3829
+ return data;
3830
+ };
3831
+ return isAsync(result) ? result.then((data) => freeze(data)) : freeze(result);
3832
+ }
3833
+ unwrap() {
3834
+ return this._def.innerType;
3835
+ }
3836
+ }
3837
+ ZodReadonly.create = (type, params) => {
3838
+ return new ZodReadonly({
3839
+ innerType: type,
3840
+ typeName: ZodFirstPartyTypeKind.ZodReadonly,
3841
+ ...processCreateParams(params)
3842
+ });
3843
+ };
3844
+ function cleanParams(params, data) {
3845
+ const p = typeof params === "function" ? params(data) : typeof params === "string" ? { message: params } : params;
3846
+ const p2 = typeof p === "string" ? { message: p } : p;
3847
+ return p2;
3848
+ }
3849
+ function custom(check, _params = {}, fatal) {
3850
+ if (check)
3851
+ return ZodAny.create().superRefine((data, ctx) => {
3852
+ var _a, _b;
3853
+ const r = check(data);
3854
+ if (r instanceof Promise) {
3855
+ return r.then((r2) => {
3856
+ var _a2, _b2;
3857
+ if (!r2) {
3858
+ const params = cleanParams(_params, data);
3859
+ const _fatal = (_b2 = (_a2 = params.fatal) !== null && _a2 !== void 0 ? _a2 : fatal) !== null && _b2 !== void 0 ? _b2 : true;
3860
+ ctx.addIssue({ code: "custom", ...params, fatal: _fatal });
3861
+ }
3862
+ });
3863
+ }
3864
+ if (!r) {
3865
+ const params = cleanParams(_params, data);
3866
+ const _fatal = (_b = (_a = params.fatal) !== null && _a !== void 0 ? _a : fatal) !== null && _b !== void 0 ? _b : true;
3867
+ ctx.addIssue({ code: "custom", ...params, fatal: _fatal });
3868
+ }
3869
+ return;
3870
+ });
3871
+ return ZodAny.create();
3872
+ }
3873
+ const late = {
3874
+ object: ZodObject.lazycreate
3875
+ };
3876
+ var ZodFirstPartyTypeKind;
3877
+ (function(ZodFirstPartyTypeKind2) {
3878
+ ZodFirstPartyTypeKind2["ZodString"] = "ZodString";
3879
+ ZodFirstPartyTypeKind2["ZodNumber"] = "ZodNumber";
3880
+ ZodFirstPartyTypeKind2["ZodNaN"] = "ZodNaN";
3881
+ ZodFirstPartyTypeKind2["ZodBigInt"] = "ZodBigInt";
3882
+ ZodFirstPartyTypeKind2["ZodBoolean"] = "ZodBoolean";
3883
+ ZodFirstPartyTypeKind2["ZodDate"] = "ZodDate";
3884
+ ZodFirstPartyTypeKind2["ZodSymbol"] = "ZodSymbol";
3885
+ ZodFirstPartyTypeKind2["ZodUndefined"] = "ZodUndefined";
3886
+ ZodFirstPartyTypeKind2["ZodNull"] = "ZodNull";
3887
+ ZodFirstPartyTypeKind2["ZodAny"] = "ZodAny";
3888
+ ZodFirstPartyTypeKind2["ZodUnknown"] = "ZodUnknown";
3889
+ ZodFirstPartyTypeKind2["ZodNever"] = "ZodNever";
3890
+ ZodFirstPartyTypeKind2["ZodVoid"] = "ZodVoid";
3891
+ ZodFirstPartyTypeKind2["ZodArray"] = "ZodArray";
3892
+ ZodFirstPartyTypeKind2["ZodObject"] = "ZodObject";
3893
+ ZodFirstPartyTypeKind2["ZodUnion"] = "ZodUnion";
3894
+ ZodFirstPartyTypeKind2["ZodDiscriminatedUnion"] = "ZodDiscriminatedUnion";
3895
+ ZodFirstPartyTypeKind2["ZodIntersection"] = "ZodIntersection";
3896
+ ZodFirstPartyTypeKind2["ZodTuple"] = "ZodTuple";
3897
+ ZodFirstPartyTypeKind2["ZodRecord"] = "ZodRecord";
3898
+ ZodFirstPartyTypeKind2["ZodMap"] = "ZodMap";
3899
+ ZodFirstPartyTypeKind2["ZodSet"] = "ZodSet";
3900
+ ZodFirstPartyTypeKind2["ZodFunction"] = "ZodFunction";
3901
+ ZodFirstPartyTypeKind2["ZodLazy"] = "ZodLazy";
3902
+ ZodFirstPartyTypeKind2["ZodLiteral"] = "ZodLiteral";
3903
+ ZodFirstPartyTypeKind2["ZodEnum"] = "ZodEnum";
3904
+ ZodFirstPartyTypeKind2["ZodEffects"] = "ZodEffects";
3905
+ ZodFirstPartyTypeKind2["ZodNativeEnum"] = "ZodNativeEnum";
3906
+ ZodFirstPartyTypeKind2["ZodOptional"] = "ZodOptional";
3907
+ ZodFirstPartyTypeKind2["ZodNullable"] = "ZodNullable";
3908
+ ZodFirstPartyTypeKind2["ZodDefault"] = "ZodDefault";
3909
+ ZodFirstPartyTypeKind2["ZodCatch"] = "ZodCatch";
3910
+ ZodFirstPartyTypeKind2["ZodPromise"] = "ZodPromise";
3911
+ ZodFirstPartyTypeKind2["ZodBranded"] = "ZodBranded";
3912
+ ZodFirstPartyTypeKind2["ZodPipeline"] = "ZodPipeline";
3913
+ ZodFirstPartyTypeKind2["ZodReadonly"] = "ZodReadonly";
3914
+ })(ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {}));
3915
+ const instanceOfType = (cls, params = {
3916
+ message: `Input not instance of ${cls.name}`
3917
+ }) => custom((data) => data instanceof cls, params);
3918
+ const stringType = ZodString.create;
3919
+ const numberType = ZodNumber.create;
3920
+ const nanType = ZodNaN.create;
3921
+ const bigIntType = ZodBigInt.create;
3922
+ const booleanType = ZodBoolean.create;
3923
+ const dateType = ZodDate.create;
3924
+ const symbolType = ZodSymbol.create;
3925
+ const undefinedType = ZodUndefined.create;
3926
+ const nullType = ZodNull.create;
3927
+ const anyType = ZodAny.create;
3928
+ const unknownType = ZodUnknown.create;
3929
+ const neverType = ZodNever.create;
3930
+ const voidType = ZodVoid.create;
3931
+ const arrayType = ZodArray.create;
3932
+ const objectType = ZodObject.create;
3933
+ const strictObjectType = ZodObject.strictCreate;
3934
+ const unionType = ZodUnion.create;
3935
+ const discriminatedUnionType = ZodDiscriminatedUnion.create;
3936
+ const intersectionType = ZodIntersection.create;
3937
+ const tupleType = ZodTuple.create;
3938
+ const recordType = ZodRecord.create;
3939
+ const mapType = ZodMap.create;
3940
+ const setType = ZodSet.create;
3941
+ const functionType = ZodFunction.create;
3942
+ const lazyType = ZodLazy.create;
3943
+ const literalType = ZodLiteral.create;
3944
+ const enumType = ZodEnum.create;
3945
+ const nativeEnumType = ZodNativeEnum.create;
3946
+ const promiseType = ZodPromise.create;
3947
+ const effectsType = ZodEffects.create;
3948
+ const optionalType = ZodOptional.create;
3949
+ const nullableType = ZodNullable.create;
3950
+ const preprocessType = ZodEffects.createWithPreprocess;
3951
+ const pipelineType = ZodPipeline.create;
3952
+ const ostring = () => stringType().optional();
3953
+ const onumber = () => numberType().optional();
3954
+ const oboolean = () => booleanType().optional();
3955
+ const coerce = {
3956
+ string: (arg) => ZodString.create({ ...arg, coerce: true }),
3957
+ number: (arg) => ZodNumber.create({ ...arg, coerce: true }),
3958
+ boolean: (arg) => ZodBoolean.create({
3959
+ ...arg,
3960
+ coerce: true
3961
+ }),
3962
+ bigint: (arg) => ZodBigInt.create({ ...arg, coerce: true }),
3963
+ date: (arg) => ZodDate.create({ ...arg, coerce: true })
3964
+ };
3965
+ const NEVER = INVALID;
3966
+ var z = /* @__PURE__ */ Object.freeze({
3967
+ __proto__: null,
3968
+ defaultErrorMap: errorMap,
3969
+ setErrorMap,
3970
+ getErrorMap,
3971
+ makeIssue,
3972
+ EMPTY_PATH,
3973
+ addIssueToContext,
3974
+ ParseStatus,
3975
+ INVALID,
3976
+ DIRTY,
3977
+ OK,
3978
+ isAborted,
3979
+ isDirty,
3980
+ isValid,
3981
+ isAsync,
3982
+ get util() {
3983
+ return util;
3984
+ },
3985
+ get objectUtil() {
3986
+ return objectUtil;
3987
+ },
3988
+ ZodParsedType,
3989
+ getParsedType,
3990
+ ZodType,
3991
+ datetimeRegex,
3992
+ ZodString,
3993
+ ZodNumber,
3994
+ ZodBigInt,
3995
+ ZodBoolean,
3996
+ ZodDate,
3997
+ ZodSymbol,
3998
+ ZodUndefined,
3999
+ ZodNull,
4000
+ ZodAny,
4001
+ ZodUnknown,
4002
+ ZodNever,
4003
+ ZodVoid,
4004
+ ZodArray,
4005
+ ZodObject,
4006
+ ZodUnion,
4007
+ ZodDiscriminatedUnion,
4008
+ ZodIntersection,
4009
+ ZodTuple,
4010
+ ZodRecord,
4011
+ ZodMap,
4012
+ ZodSet,
4013
+ ZodFunction,
4014
+ ZodLazy,
4015
+ ZodLiteral,
4016
+ ZodEnum,
4017
+ ZodNativeEnum,
4018
+ ZodPromise,
4019
+ ZodEffects,
4020
+ ZodTransformer: ZodEffects,
4021
+ ZodOptional,
4022
+ ZodNullable,
4023
+ ZodDefault,
4024
+ ZodCatch,
4025
+ ZodNaN,
4026
+ BRAND,
4027
+ ZodBranded,
4028
+ ZodPipeline,
4029
+ ZodReadonly,
4030
+ custom,
4031
+ Schema: ZodType,
4032
+ ZodSchema: ZodType,
4033
+ late,
4034
+ get ZodFirstPartyTypeKind() {
4035
+ return ZodFirstPartyTypeKind;
4036
+ },
4037
+ coerce,
4038
+ any: anyType,
4039
+ array: arrayType,
4040
+ bigint: bigIntType,
4041
+ boolean: booleanType,
4042
+ date: dateType,
4043
+ discriminatedUnion: discriminatedUnionType,
4044
+ effect: effectsType,
4045
+ "enum": enumType,
4046
+ "function": functionType,
4047
+ "instanceof": instanceOfType,
4048
+ intersection: intersectionType,
4049
+ lazy: lazyType,
4050
+ literal: literalType,
4051
+ map: mapType,
4052
+ nan: nanType,
4053
+ nativeEnum: nativeEnumType,
4054
+ never: neverType,
4055
+ "null": nullType,
4056
+ nullable: nullableType,
4057
+ number: numberType,
4058
+ object: objectType,
4059
+ oboolean,
4060
+ onumber,
4061
+ optional: optionalType,
4062
+ ostring,
4063
+ pipeline: pipelineType,
4064
+ preprocess: preprocessType,
4065
+ promise: promiseType,
4066
+ record: recordType,
4067
+ set: setType,
4068
+ strictObject: strictObjectType,
4069
+ string: stringType,
4070
+ symbol: symbolType,
4071
+ transformer: effectsType,
4072
+ tuple: tupleType,
4073
+ "undefined": undefinedType,
4074
+ union: unionType,
4075
+ unknown: unknownType,
4076
+ "void": voidType,
4077
+ NEVER,
4078
+ ZodIssueCode,
4079
+ quotelessJson,
4080
+ ZodError
4081
+ });
4082
+ const commonValidation = {
4083
+ envUrl: z.string().url().min(1).regex(/[^\/]$/, { message: "Must not end with `/`" })
4084
+ };
4085
+ const __vite_import_meta_env__ = { "BASE_URL": "/", "DEV": false, "MODE": "development", "PROD": true, "SSR": false, "VITE_MODULES_CARDS_ADMIN_FRONTEND_BASE_URL": "https://dev-sso.6seconds.org", "VITE_MODULES_CARDS_HOME_FRONTEND_BASE_URL": "https://dev-sso.6seconds.org", "VITE_MODULES_CERT_FRONTEND_BASE_URL": "https://dev-sso.6seconds.org", "VITE_MODULES_ENV": "dev", "VITE_MODULES_EVENTS_FRONTEND_BASE_URL": "https://dev-sso.6seconds.org", "VITE_MODULES_SSO_BACKEND_BASE_URL": "https://dev-ssoapi.6seconds.org", "VITE_MODULES_SSO_FRONTEND_BASE_URL": "https://dev-sso.6seconds.org", "VITE_MODULES_TOOLS_FRONTEND_BASE_URL": "https://dev-sso.6seconds.org" };
4086
+ const env = createEnv({
4087
+ client: {
4088
+ // frontend
4089
+ VITE_MODULES_SSO_FRONTEND_BASE_URL: commonValidation.envUrl,
4090
+ VITE_MODULES_TOOLS_FRONTEND_BASE_URL: commonValidation.envUrl,
4091
+ VITE_MODULES_EVENTS_FRONTEND_BASE_URL: commonValidation.envUrl,
4092
+ VITE_MODULES_CARDS_HOME_FRONTEND_BASE_URL: commonValidation.envUrl,
4093
+ VITE_MODULES_CARDS_ADMIN_FRONTEND_BASE_URL: commonValidation.envUrl,
4094
+ VITE_MODULES_CERT_FRONTEND_BASE_URL: commonValidation.envUrl,
4095
+ // backends
4096
+ VITE_MODULES_SSO_BACKEND_BASE_URL: commonValidation.envUrl,
4097
+ VITE_MODULES_ENV: z.string()
4098
+ },
4099
+ runtimeEnv: __vite_import_meta_env__
4100
+ });
4101
+ const DEV = process.env.NODE_ENV === "development";
4102
+ const SERVER_STATUS_CODE = Object.freeze({
4103
+ notFound: 404,
4104
+ badRequest: 400,
4105
+ forbidden: 403,
4106
+ authenticationDenied: 401,
4107
+ serverError: 500,
4108
+ success: 200
4109
+ });
4110
+ const SERVER_STATUS = Object.freeze({
4111
+ success: "success",
4112
+ failure: "failure"
4113
+ });
4114
+ const APP_NAMES = Object.freeze({
4115
+ events: "Events",
4116
+ tools: "Tools",
4117
+ certHome: "Cert Home",
4118
+ cards: "Cards",
4119
+ sso: "SSO Admin",
4120
+ cardsHome: "Cards Home",
4121
+ cardsAdmin: "Cards Admin"
4122
+ });
4123
+ const ALERT_MESSAGES = Object.freeze({
4124
+ // not found
4125
+ dataNoFount: "Data not found",
4126
+ searchNotFount: "Sorry, there are no matches. Try a new search?",
4127
+ // generic
4128
+ commonLoadingMessage: "Please wait...",
4129
+ submittingSuccessMassage: "Detail Added Successfully",
4130
+ allFieldsRequired: "Please fill all required fields",
4131
+ NA: "N/A",
4132
+ // error
4133
+ fallbackError: "Something went wrong, Please try again later!",
4134
+ networkError: "Please check your internet connection!",
4135
+ timeOutError: "Your connection taking too long to get data!"
4136
+ });
4137
+ const ROLES = Object.freeze({
4138
+ master: "Master",
4139
+ distributor: "Distributor",
4140
+ coach: "Coach",
4141
+ referent: "Referent"
4142
+ });
4143
+ const REGEX = Object.freeze({
4144
+ email: /^[^\s@]+@[^\s@]+\.[^\s@]{2,}$/i,
4145
+ mobile: /^[6-9]\d{9}$/,
4146
+ website: /^(https?:\/\/)?(www\.)?[a-zA-Z0-9-]+\.[a-zA-Z]{2,}(\/.*)?$/,
4147
+ password: /^(?=.*[A-Z])(?=.*\d)(?=.*[@!$%^&*()_+[\]{};':"\\|,.<>/?#]).*$/
4148
+ });
4149
+ const WEBSITE_LINKS = Object.freeze({
4150
+ helpDisk: "#",
4151
+ instagram: "https://www.instagram.com/6secondseq/",
4152
+ facebook: "https://www.facebook.com/sixseconds",
4153
+ linkedin: "https://www.linkedin.com/company/six-seconds/",
4154
+ youtube: "https://www.youtube.com/c/SixSeconds",
4155
+ x: "https://x.com/6s_EQ",
4156
+ termsOfService: "https://www.6seconds.org/about/terms-of-use/",
4157
+ privacyPolicy: "https://www.6seconds.org/about/policies/privacy/",
4158
+ certUrl: "https://cert.6seconds.org/"
4159
+ });
4160
+ const RTK_ERROR_CODES = Object.freeze({
4161
+ fetchError: "FETCH_ERROR",
4162
+ parsingError: "PARSING_ERROR",
4163
+ timeOutError: "TIMEOUT_ERROR",
4164
+ customError: "CUSTOM_ERROR"
4165
+ });
4166
+ const NOTIFICATIONS_TYPES = Object.freeze({
4167
+ project: "Project",
4168
+ credit: "Credit",
4169
+ report: "Report",
4170
+ group: "Group",
4171
+ system: "System"
4172
+ });
4173
+ const TOOLS_ROUTES = {
4174
+ creditList: env.VITE_MODULES_TOOLS_FRONTEND_BASE_URL + "/credit/regular-credits",
4175
+ groupList: env.VITE_MODULES_TOOLS_FRONTEND_BASE_URL + "/sei/adult/groups",
4176
+ projectList: env.VITE_MODULES_TOOLS_FRONTEND_BASE_URL + "/sei/adult/projects",
4177
+ reportList: env.VITE_MODULES_TOOLS_FRONTEND_BASE_URL + "/sei/adult/reports"
4178
+ };
4179
+ const SSO_ROUTES = (APP_NAME) => {
4180
+ return {
4181
+ languages: `${env.VITE_MODULES_SSO_FRONTEND_BASE_URL}/languages?source=${APP_NAME}`,
4182
+ translations: `${env.VITE_MODULES_SSO_FRONTEND_BASE_URL}/translations?source=${APP_NAME}`,
4183
+ editProfile: `${APP_NAME !== APP_NAMES.sso ? env.VITE_MODULES_SSO_FRONTEND_BASE_URL : "."}/edit-profile?source=${APP_NAME}`,
4184
+ emailTemplate: `${env.VITE_MODULES_SSO_FRONTEND_BASE_URL}/email-templates?source=${APP_NAME}`,
4185
+ unauthorized: `${env.VITE_MODULES_SSO_FRONTEND_BASE_URL}/unauthorized`
4186
+ };
4187
+ };
4188
+ const ROUTES = {
4189
+ home: "/"
4190
+ };
4191
+ const STORAGE_VALUES = Object.freeze({
4192
+ // mainToken: env.NEXT_PUBLIC_TOKEN_NAME,
4193
+ previousLoginBanner: "previousLoginDetails-" + env.VITE_MODULES_ENV
4194
+ });
4195
+ const MAIN_DATE_FORMAT = "MM/DD/YYYY";
4196
+ const FILTER_DATE_FORMAT = "YYYY-MM-DD";
4197
+ const MAIN_TIME_FORMAT = "h:mm a";
4198
+ const TRANSLATION_PREFIX = Object.freeze({
4199
+ // elements
4200
+ tooltip: "tooltip_",
4201
+ validation: "validation_",
4202
+ toast: "toast_"
4203
+ });
4204
+ const COMMON_VALIDATION_MASSAGE = Object.freeze({
4205
+ // Requires
4206
+ password: TRANSLATION_PREFIX.validation + "password_is_required!",
4207
+ email: TRANSLATION_PREFIX.validation + "Email_is_required!",
4208
+ oldPassword: TRANSLATION_PREFIX.validation + "old_password_is_required!",
4209
+ gender: TRANSLATION_PREFIX.validation + "gender_is_required!",
4210
+ projectType: TRANSLATION_PREFIX.validation + "project_type_is_required!",
4211
+ name: TRANSLATION_PREFIX.validation + "name_is_required!",
4212
+ surname: TRANSLATION_PREFIX.validation + "surname_is_required!",
4213
+ language: TRANSLATION_PREFIX.validation + "language_is_required!",
4214
+ pricing: TRANSLATION_PREFIX.validation + "pricing scheme_is_required!",
4215
+ coach: TRANSLATION_PREFIX.validation + "coach_is_required!",
4216
+ amount: TRANSLATION_PREFIX.validation + "amount_is_required!",
4217
+ credit: TRANSLATION_PREFIX.validation + "credits_is_required!",
4218
+ report: TRANSLATION_PREFIX.validation + "report_language_is_required!",
4219
+ reportNorm: TRANSLATION_PREFIX.validation + "report_norm_is_required!",
4220
+ date: TRANSLATION_PREFIX.validation + "date_is_required!",
4221
+ parentDistributor: TRANSLATION_PREFIX.validation + "parent_distributor_is_required!",
4222
+ belongTo: TRANSLATION_PREFIX.validation + "belong_to_is_required!",
4223
+ notes: TRANSLATION_PREFIX.validation + "notes_is_required!",
4224
+ company: TRANSLATION_PREFIX.validation + "company_is_required!",
4225
+ orgLogo: TRANSLATION_PREFIX.validation + "organization_logo_is_required",
4226
+ url: TRANSLATION_PREFIX.validation + "url_is_Required!",
4227
+ description: TRANSLATION_PREFIX.validation + "description_is_Required!",
4228
+ // length
4229
+ maxVal: TRANSLATION_PREFIX.validation + "too_long!",
4230
+ minVal: TRANSLATION_PREFIX.validation + "too_short!",
4231
+ // validation
4232
+ emailValidation: TRANSLATION_PREFIX.validation + "email_is_not_valid!",
4233
+ urlValidation: TRANSLATION_PREFIX.validation + "url_must_be_a_valid!",
4234
+ // general
4235
+ certifications: TRANSLATION_PREFIX.validation + "Please select at least one certification!",
4236
+ questions: TRANSLATION_PREFIX.toast + "Please answer all questions!"
4237
+ });
4238
+ exports.ALERT_MESSAGES = ALERT_MESSAGES;
4239
+ exports.APP_NAMES = APP_NAMES;
4240
+ exports.COMMON_VALIDATION_MASSAGE = COMMON_VALIDATION_MASSAGE;
4241
+ exports.DEV = DEV;
4242
+ exports.FILTER_DATE_FORMAT = FILTER_DATE_FORMAT;
4243
+ exports.MAIN_DATE_FORMAT = MAIN_DATE_FORMAT;
4244
+ exports.MAIN_TIME_FORMAT = MAIN_TIME_FORMAT;
4245
+ exports.NOTIFICATIONS_TYPES = NOTIFICATIONS_TYPES;
4246
+ exports.REGEX = REGEX;
4247
+ exports.ROLES = ROLES;
4248
+ exports.ROUTES = ROUTES;
4249
+ exports.RTK_ERROR_CODES = RTK_ERROR_CODES;
4250
+ exports.SERVER_STATUS = SERVER_STATUS;
4251
+ exports.SERVER_STATUS_CODE = SERVER_STATUS_CODE;
4252
+ exports.SSO_ROUTES = SSO_ROUTES;
4253
+ exports.STORAGE_VALUES = STORAGE_VALUES;
4254
+ exports.TOOLS_ROUTES = TOOLS_ROUTES;
4255
+ exports.TRANSLATION_PREFIX = TRANSLATION_PREFIX;
4256
+ exports.WEBSITE_LINKS = WEBSITE_LINKS;
4257
+ exports.commonValidation = commonValidation;
4258
+ exports.env = env;
4259
+ //# sourceMappingURL=constants.es.js.map