@plyaz/types 1.7.21 → 1.7.23

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