@kbve/droid 0.0.4 → 0.0.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/index.js ADDED
@@ -0,0 +1,2972 @@
1
+ var g;
2
+ (function(r) {
3
+ r.assertEqual = (n) => n;
4
+ function e(n) {
5
+ }
6
+ r.assertIs = e;
7
+ function t(n) {
8
+ throw new Error();
9
+ }
10
+ r.assertNever = t, r.arrayToEnum = (n) => {
11
+ const a = {};
12
+ for (const i of n)
13
+ a[i] = i;
14
+ return a;
15
+ }, r.getValidEnumValues = (n) => {
16
+ const a = r.objectKeys(n).filter((o) => typeof n[n[o]] != "number"), i = {};
17
+ for (const o of a)
18
+ i[o] = n[o];
19
+ return r.objectValues(i);
20
+ }, r.objectValues = (n) => r.objectKeys(n).map(function(a) {
21
+ return n[a];
22
+ }), r.objectKeys = typeof Object.keys == "function" ? (n) => Object.keys(n) : (n) => {
23
+ const a = [];
24
+ for (const i in n)
25
+ Object.prototype.hasOwnProperty.call(n, i) && a.push(i);
26
+ return a;
27
+ }, r.find = (n, a) => {
28
+ for (const i of n)
29
+ if (a(i))
30
+ return i;
31
+ }, r.isInteger = typeof Number.isInteger == "function" ? (n) => Number.isInteger(n) : (n) => typeof n == "number" && isFinite(n) && Math.floor(n) === n;
32
+ function s(n, a = " | ") {
33
+ return n.map((i) => typeof i == "string" ? `'${i}'` : i).join(a);
34
+ }
35
+ r.joinValues = s, r.jsonStringifyReplacer = (n, a) => typeof a == "bigint" ? a.toString() : a;
36
+ })(g || (g = {}));
37
+ var ke;
38
+ (function(r) {
39
+ r.mergeShapes = (e, t) => ({
40
+ ...e,
41
+ ...t
42
+ // second overwrites first
43
+ });
44
+ })(ke || (ke = {}));
45
+ const f = g.arrayToEnum([
46
+ "string",
47
+ "nan",
48
+ "number",
49
+ "integer",
50
+ "float",
51
+ "boolean",
52
+ "date",
53
+ "bigint",
54
+ "symbol",
55
+ "function",
56
+ "undefined",
57
+ "null",
58
+ "array",
59
+ "object",
60
+ "unknown",
61
+ "promise",
62
+ "void",
63
+ "never",
64
+ "map",
65
+ "set"
66
+ ]), R = (r) => {
67
+ switch (typeof r) {
68
+ case "undefined":
69
+ return f.undefined;
70
+ case "string":
71
+ return f.string;
72
+ case "number":
73
+ return isNaN(r) ? f.nan : f.number;
74
+ case "boolean":
75
+ return f.boolean;
76
+ case "function":
77
+ return f.function;
78
+ case "bigint":
79
+ return f.bigint;
80
+ case "symbol":
81
+ return f.symbol;
82
+ case "object":
83
+ return Array.isArray(r) ? f.array : r === null ? f.null : r.then && typeof r.then == "function" && r.catch && typeof r.catch == "function" ? f.promise : typeof Map < "u" && r instanceof Map ? f.map : typeof Set < "u" && r instanceof Set ? f.set : typeof Date < "u" && r instanceof Date ? f.date : f.object;
84
+ default:
85
+ return f.unknown;
86
+ }
87
+ }, d = g.arrayToEnum([
88
+ "invalid_type",
89
+ "invalid_literal",
90
+ "custom",
91
+ "invalid_union",
92
+ "invalid_union_discriminator",
93
+ "invalid_enum_value",
94
+ "unrecognized_keys",
95
+ "invalid_arguments",
96
+ "invalid_return_type",
97
+ "invalid_date",
98
+ "invalid_string",
99
+ "too_small",
100
+ "too_big",
101
+ "invalid_intersection_types",
102
+ "not_multiple_of",
103
+ "not_finite"
104
+ ]), ze = (r) => JSON.stringify(r, null, 2).replace(/"([^"]+)":/g, "$1:");
105
+ class T extends Error {
106
+ get errors() {
107
+ return this.issues;
108
+ }
109
+ constructor(e) {
110
+ super(), this.issues = [], this.addIssue = (s) => {
111
+ this.issues = [...this.issues, s];
112
+ }, this.addIssues = (s = []) => {
113
+ this.issues = [...this.issues, ...s];
114
+ };
115
+ const t = new.target.prototype;
116
+ Object.setPrototypeOf ? Object.setPrototypeOf(this, t) : this.__proto__ = t, this.name = "ZodError", this.issues = e;
117
+ }
118
+ format(e) {
119
+ const t = e || function(a) {
120
+ return a.message;
121
+ }, s = { _errors: [] }, n = (a) => {
122
+ for (const i of a.issues)
123
+ if (i.code === "invalid_union")
124
+ i.unionErrors.map(n);
125
+ else if (i.code === "invalid_return_type")
126
+ n(i.returnTypeError);
127
+ else if (i.code === "invalid_arguments")
128
+ n(i.argumentsError);
129
+ else if (i.path.length === 0)
130
+ s._errors.push(t(i));
131
+ else {
132
+ let o = s, l = 0;
133
+ for (; l < i.path.length; ) {
134
+ const c = i.path[l];
135
+ l === i.path.length - 1 ? (o[c] = o[c] || { _errors: [] }, o[c]._errors.push(t(i))) : o[c] = o[c] || { _errors: [] }, o = o[c], l++;
136
+ }
137
+ }
138
+ };
139
+ return n(this), s;
140
+ }
141
+ static assert(e) {
142
+ if (!(e instanceof T))
143
+ throw new Error(`Not a ZodError: ${e}`);
144
+ }
145
+ toString() {
146
+ return this.message;
147
+ }
148
+ get message() {
149
+ return JSON.stringify(this.issues, g.jsonStringifyReplacer, 2);
150
+ }
151
+ get isEmpty() {
152
+ return this.issues.length === 0;
153
+ }
154
+ flatten(e = (t) => t.message) {
155
+ const t = {}, s = [];
156
+ for (const n of this.issues)
157
+ n.path.length > 0 ? (t[n.path[0]] = t[n.path[0]] || [], t[n.path[0]].push(e(n))) : s.push(e(n));
158
+ return { formErrors: s, fieldErrors: t };
159
+ }
160
+ get formErrors() {
161
+ return this.flatten();
162
+ }
163
+ }
164
+ T.create = (r) => new T(r);
165
+ const W = (r, e) => {
166
+ let t;
167
+ switch (r.code) {
168
+ case d.invalid_type:
169
+ r.received === f.undefined ? t = "Required" : t = `Expected ${r.expected}, received ${r.received}`;
170
+ break;
171
+ case d.invalid_literal:
172
+ t = `Invalid literal value, expected ${JSON.stringify(r.expected, g.jsonStringifyReplacer)}`;
173
+ break;
174
+ case d.unrecognized_keys:
175
+ t = `Unrecognized key(s) in object: ${g.joinValues(r.keys, ", ")}`;
176
+ break;
177
+ case d.invalid_union:
178
+ t = "Invalid input";
179
+ break;
180
+ case d.invalid_union_discriminator:
181
+ t = `Invalid discriminator value. Expected ${g.joinValues(r.options)}`;
182
+ break;
183
+ case d.invalid_enum_value:
184
+ t = `Invalid enum value. Expected ${g.joinValues(r.options)}, received '${r.received}'`;
185
+ break;
186
+ case d.invalid_arguments:
187
+ t = "Invalid function arguments";
188
+ break;
189
+ case d.invalid_return_type:
190
+ t = "Invalid function return type";
191
+ break;
192
+ case d.invalid_date:
193
+ t = "Invalid date";
194
+ break;
195
+ case d.invalid_string:
196
+ typeof r.validation == "object" ? "includes" in r.validation ? (t = `Invalid input: must include "${r.validation.includes}"`, typeof r.validation.position == "number" && (t = `${t} at one or more positions greater than or equal to ${r.validation.position}`)) : "startsWith" in r.validation ? t = `Invalid input: must start with "${r.validation.startsWith}"` : "endsWith" in r.validation ? t = `Invalid input: must end with "${r.validation.endsWith}"` : g.assertNever(r.validation) : r.validation !== "regex" ? t = `Invalid ${r.validation}` : t = "Invalid";
197
+ break;
198
+ case d.too_small:
199
+ r.type === "array" ? t = `Array must contain ${r.exact ? "exactly" : r.inclusive ? "at least" : "more than"} ${r.minimum} element(s)` : r.type === "string" ? t = `String must contain ${r.exact ? "exactly" : r.inclusive ? "at least" : "over"} ${r.minimum} character(s)` : r.type === "number" ? t = `Number must be ${r.exact ? "exactly equal to " : r.inclusive ? "greater than or equal to " : "greater than "}${r.minimum}` : r.type === "date" ? t = `Date must be ${r.exact ? "exactly equal to " : r.inclusive ? "greater than or equal to " : "greater than "}${new Date(Number(r.minimum))}` : t = "Invalid input";
200
+ break;
201
+ case d.too_big:
202
+ r.type === "array" ? t = `Array must contain ${r.exact ? "exactly" : r.inclusive ? "at most" : "less than"} ${r.maximum} element(s)` : r.type === "string" ? t = `String must contain ${r.exact ? "exactly" : r.inclusive ? "at most" : "under"} ${r.maximum} character(s)` : r.type === "number" ? t = `Number must be ${r.exact ? "exactly" : r.inclusive ? "less than or equal to" : "less than"} ${r.maximum}` : r.type === "bigint" ? t = `BigInt must be ${r.exact ? "exactly" : r.inclusive ? "less than or equal to" : "less than"} ${r.maximum}` : r.type === "date" ? t = `Date must be ${r.exact ? "exactly" : r.inclusive ? "smaller than or equal to" : "smaller than"} ${new Date(Number(r.maximum))}` : t = "Invalid input";
203
+ break;
204
+ case d.custom:
205
+ t = "Invalid input";
206
+ break;
207
+ case d.invalid_intersection_types:
208
+ t = "Intersection results could not be merged";
209
+ break;
210
+ case d.not_multiple_of:
211
+ t = `Number must be a multiple of ${r.multipleOf}`;
212
+ break;
213
+ case d.not_finite:
214
+ t = "Number must be finite";
215
+ break;
216
+ default:
217
+ t = e.defaultError, g.assertNever(r);
218
+ }
219
+ return { message: t };
220
+ };
221
+ let Oe = W;
222
+ function De(r) {
223
+ Oe = r;
224
+ }
225
+ function le() {
226
+ return Oe;
227
+ }
228
+ const fe = (r) => {
229
+ const { data: e, path: t, errorMaps: s, issueData: n } = r, a = [...t, ...n.path || []], i = {
230
+ ...n,
231
+ path: a
232
+ };
233
+ if (n.message !== void 0)
234
+ return {
235
+ ...n,
236
+ path: a,
237
+ message: n.message
238
+ };
239
+ let o = "";
240
+ const l = s.filter((c) => !!c).slice().reverse();
241
+ for (const c of l)
242
+ o = c(i, { data: e, defaultError: o }).message;
243
+ return {
244
+ ...n,
245
+ path: a,
246
+ message: o
247
+ };
248
+ }, Le = [];
249
+ function u(r, e) {
250
+ const t = le(), s = fe({
251
+ issueData: e,
252
+ data: r.data,
253
+ path: r.path,
254
+ errorMaps: [
255
+ r.common.contextualErrorMap,
256
+ // contextual error map is first priority
257
+ r.schemaErrorMap,
258
+ // then schema-bound map if available
259
+ t,
260
+ // then global override map
261
+ t === W ? void 0 : W
262
+ // then global default map
263
+ ].filter((n) => !!n)
264
+ });
265
+ r.common.issues.push(s);
266
+ }
267
+ class k {
268
+ constructor() {
269
+ this.value = "valid";
270
+ }
271
+ dirty() {
272
+ this.value === "valid" && (this.value = "dirty");
273
+ }
274
+ abort() {
275
+ this.value !== "aborted" && (this.value = "aborted");
276
+ }
277
+ static mergeArray(e, t) {
278
+ const s = [];
279
+ for (const n of t) {
280
+ if (n.status === "aborted")
281
+ return v;
282
+ n.status === "dirty" && e.dirty(), s.push(n.value);
283
+ }
284
+ return { status: e.value, value: s };
285
+ }
286
+ static async mergeObjectAsync(e, t) {
287
+ const s = [];
288
+ for (const n of t) {
289
+ const a = await n.key, i = await n.value;
290
+ s.push({
291
+ key: a,
292
+ value: i
293
+ });
294
+ }
295
+ return k.mergeObjectSync(e, s);
296
+ }
297
+ static mergeObjectSync(e, t) {
298
+ const s = {};
299
+ for (const n of t) {
300
+ const { key: a, value: i } = n;
301
+ if (a.status === "aborted" || i.status === "aborted")
302
+ return v;
303
+ a.status === "dirty" && e.dirty(), i.status === "dirty" && e.dirty(), a.value !== "__proto__" && (typeof i.value < "u" || n.alwaysSet) && (s[a.value] = i.value);
304
+ }
305
+ return { status: e.value, value: s };
306
+ }
307
+ }
308
+ const v = Object.freeze({
309
+ status: "aborted"
310
+ }), B = (r) => ({ status: "dirty", value: r }), w = (r) => ({ status: "valid", value: r }), be = (r) => r.status === "aborted", we = (r) => r.status === "dirty", z = (r) => r.status === "valid", G = (r) => typeof Promise < "u" && r instanceof Promise;
311
+ function he(r, e, t, s) {
312
+ if (typeof e == "function" ? r !== e || !0 : !e.has(r)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
313
+ return e.get(r);
314
+ }
315
+ function Ne(r, e, t, s, n) {
316
+ if (typeof e == "function" ? r !== e || !0 : !e.has(r)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
317
+ return e.set(r, t), t;
318
+ }
319
+ var h;
320
+ (function(r) {
321
+ r.errToObj = (e) => typeof e == "string" ? { message: e } : e || {}, r.toString = (e) => typeof e == "string" ? e : e?.message;
322
+ })(h || (h = {}));
323
+ var Y, H;
324
+ class O {
325
+ constructor(e, t, s, n) {
326
+ this._cachedPath = [], this.parent = e, this.data = t, this._path = s, this._key = n;
327
+ }
328
+ get path() {
329
+ return this._cachedPath.length || (this._key instanceof Array ? this._cachedPath.push(...this._path, ...this._key) : this._cachedPath.push(...this._path, this._key)), this._cachedPath;
330
+ }
331
+ }
332
+ const Ce = (r, e) => {
333
+ if (z(e))
334
+ return { success: !0, data: e.value };
335
+ if (!r.common.issues.length)
336
+ throw new Error("Validation failed but no issues detected.");
337
+ return {
338
+ success: !1,
339
+ get error() {
340
+ if (this._error)
341
+ return this._error;
342
+ const t = new T(r.common.issues);
343
+ return this._error = t, this._error;
344
+ }
345
+ };
346
+ };
347
+ function y(r) {
348
+ if (!r)
349
+ return {};
350
+ const { errorMap: e, invalid_type_error: t, required_error: s, description: n } = r;
351
+ if (e && (t || s))
352
+ throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);
353
+ return e ? { errorMap: e, description: n } : { errorMap: (i, o) => {
354
+ var l, c;
355
+ const { message: p } = r;
356
+ return i.code === "invalid_enum_value" ? { message: p ?? o.defaultError } : typeof o.data > "u" ? { message: (l = p ?? s) !== null && l !== void 0 ? l : o.defaultError } : i.code !== "invalid_type" ? { message: o.defaultError } : { message: (c = p ?? t) !== null && c !== void 0 ? c : o.defaultError };
357
+ }, description: n };
358
+ }
359
+ class _ {
360
+ get description() {
361
+ return this._def.description;
362
+ }
363
+ _getType(e) {
364
+ return R(e.data);
365
+ }
366
+ _getOrReturnCtx(e, t) {
367
+ return t || {
368
+ common: e.parent.common,
369
+ data: e.data,
370
+ parsedType: R(e.data),
371
+ schemaErrorMap: this._def.errorMap,
372
+ path: e.path,
373
+ parent: e.parent
374
+ };
375
+ }
376
+ _processInputParams(e) {
377
+ return {
378
+ status: new k(),
379
+ ctx: {
380
+ common: e.parent.common,
381
+ data: e.data,
382
+ parsedType: R(e.data),
383
+ schemaErrorMap: this._def.errorMap,
384
+ path: e.path,
385
+ parent: e.parent
386
+ }
387
+ };
388
+ }
389
+ _parseSync(e) {
390
+ const t = this._parse(e);
391
+ if (G(t))
392
+ throw new Error("Synchronous parse encountered promise.");
393
+ return t;
394
+ }
395
+ _parseAsync(e) {
396
+ const t = this._parse(e);
397
+ return Promise.resolve(t);
398
+ }
399
+ parse(e, t) {
400
+ const s = this.safeParse(e, t);
401
+ if (s.success)
402
+ return s.data;
403
+ throw s.error;
404
+ }
405
+ safeParse(e, t) {
406
+ var s;
407
+ const n = {
408
+ common: {
409
+ issues: [],
410
+ async: (s = t?.async) !== null && s !== void 0 ? s : !1,
411
+ contextualErrorMap: t?.errorMap
412
+ },
413
+ path: t?.path || [],
414
+ schemaErrorMap: this._def.errorMap,
415
+ parent: null,
416
+ data: e,
417
+ parsedType: R(e)
418
+ }, a = this._parseSync({ data: e, path: n.path, parent: n });
419
+ return Ce(n, a);
420
+ }
421
+ "~validate"(e) {
422
+ var t, s;
423
+ const n = {
424
+ common: {
425
+ issues: [],
426
+ async: !!this["~standard"].async
427
+ },
428
+ path: [],
429
+ schemaErrorMap: this._def.errorMap,
430
+ parent: null,
431
+ data: e,
432
+ parsedType: R(e)
433
+ };
434
+ if (!this["~standard"].async)
435
+ try {
436
+ const a = this._parseSync({ data: e, path: [], parent: n });
437
+ return z(a) ? {
438
+ value: a.value
439
+ } : {
440
+ issues: n.common.issues
441
+ };
442
+ } catch (a) {
443
+ !((s = (t = a?.message) === null || t === void 0 ? void 0 : t.toLowerCase()) === null || s === void 0) && s.includes("encountered") && (this["~standard"].async = !0), n.common = {
444
+ issues: [],
445
+ async: !0
446
+ };
447
+ }
448
+ return this._parseAsync({ data: e, path: [], parent: n }).then((a) => z(a) ? {
449
+ value: a.value
450
+ } : {
451
+ issues: n.common.issues
452
+ });
453
+ }
454
+ async parseAsync(e, t) {
455
+ const s = await this.safeParseAsync(e, t);
456
+ if (s.success)
457
+ return s.data;
458
+ throw s.error;
459
+ }
460
+ async safeParseAsync(e, t) {
461
+ const s = {
462
+ common: {
463
+ issues: [],
464
+ contextualErrorMap: t?.errorMap,
465
+ async: !0
466
+ },
467
+ path: t?.path || [],
468
+ schemaErrorMap: this._def.errorMap,
469
+ parent: null,
470
+ data: e,
471
+ parsedType: R(e)
472
+ }, n = this._parse({ data: e, path: s.path, parent: s }), a = await (G(n) ? n : Promise.resolve(n));
473
+ return Ce(s, a);
474
+ }
475
+ refine(e, t) {
476
+ const s = (n) => typeof t == "string" || typeof t > "u" ? { message: t } : typeof t == "function" ? t(n) : t;
477
+ return this._refinement((n, a) => {
478
+ const i = e(n), o = () => a.addIssue({
479
+ code: d.custom,
480
+ ...s(n)
481
+ });
482
+ return typeof Promise < "u" && i instanceof Promise ? i.then((l) => l ? !0 : (o(), !1)) : i ? !0 : (o(), !1);
483
+ });
484
+ }
485
+ refinement(e, t) {
486
+ return this._refinement((s, n) => e(s) ? !0 : (n.addIssue(typeof t == "function" ? t(s, n) : t), !1));
487
+ }
488
+ _refinement(e) {
489
+ return new S({
490
+ schema: this,
491
+ typeName: m.ZodEffects,
492
+ effect: { type: "refinement", refinement: e }
493
+ });
494
+ }
495
+ superRefine(e) {
496
+ return this._refinement(e);
497
+ }
498
+ constructor(e) {
499
+ this.spa = this.safeParseAsync, this._def = e, this.parse = this.parse.bind(this), this.safeParse = this.safeParse.bind(this), this.parseAsync = this.parseAsync.bind(this), this.safeParseAsync = this.safeParseAsync.bind(this), this.spa = this.spa.bind(this), this.refine = this.refine.bind(this), this.refinement = this.refinement.bind(this), this.superRefine = this.superRefine.bind(this), this.optional = this.optional.bind(this), this.nullable = this.nullable.bind(this), this.nullish = this.nullish.bind(this), this.array = this.array.bind(this), this.promise = this.promise.bind(this), this.or = this.or.bind(this), this.and = this.and.bind(this), this.transform = this.transform.bind(this), this.brand = this.brand.bind(this), this.default = this.default.bind(this), this.catch = this.catch.bind(this), this.describe = this.describe.bind(this), this.pipe = this.pipe.bind(this), this.readonly = this.readonly.bind(this), this.isNullable = this.isNullable.bind(this), this.isOptional = this.isOptional.bind(this), this["~standard"] = {
500
+ version: 1,
501
+ vendor: "zod",
502
+ validate: (t) => this["~validate"](t)
503
+ };
504
+ }
505
+ optional() {
506
+ return A.create(this, this._def);
507
+ }
508
+ nullable() {
509
+ return P.create(this, this._def);
510
+ }
511
+ nullish() {
512
+ return this.nullable().optional();
513
+ }
514
+ array() {
515
+ return C.create(this);
516
+ }
517
+ promise() {
518
+ return J.create(this, this._def);
519
+ }
520
+ or(e) {
521
+ return ee.create([this, e], this._def);
522
+ }
523
+ and(e) {
524
+ return te.create(this, e, this._def);
525
+ }
526
+ transform(e) {
527
+ return new S({
528
+ ...y(this._def),
529
+ schema: this,
530
+ typeName: m.ZodEffects,
531
+ effect: { type: "transform", transform: e }
532
+ });
533
+ }
534
+ default(e) {
535
+ const t = typeof e == "function" ? e : () => e;
536
+ return new ie({
537
+ ...y(this._def),
538
+ innerType: this,
539
+ defaultValue: t,
540
+ typeName: m.ZodDefault
541
+ });
542
+ }
543
+ brand() {
544
+ return new Ze({
545
+ typeName: m.ZodBranded,
546
+ type: this,
547
+ ...y(this._def)
548
+ });
549
+ }
550
+ catch(e) {
551
+ const t = typeof e == "function" ? e : () => e;
552
+ return new oe({
553
+ ...y(this._def),
554
+ innerType: this,
555
+ catchValue: t,
556
+ typeName: m.ZodCatch
557
+ });
558
+ }
559
+ describe(e) {
560
+ const t = this.constructor;
561
+ return new t({
562
+ ...this._def,
563
+ description: e
564
+ });
565
+ }
566
+ pipe(e) {
567
+ return ce.create(this, e);
568
+ }
569
+ readonly() {
570
+ return de.create(this);
571
+ }
572
+ isOptional() {
573
+ return this.safeParse(void 0).success;
574
+ }
575
+ isNullable() {
576
+ return this.safeParse(null).success;
577
+ }
578
+ }
579
+ const Ue = /^c[^\s-]{8,}$/i, Be = /^[0-9a-z]+$/, Fe = /^[0-9A-HJKMNP-TV-Z]{26}$/i, We = /^[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, qe = /^[a-z0-9_-]{21}$/i, Je = /^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/, Ye = /^[-+]?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)?)??$/, He = /^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i, Ge = "^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";
580
+ let xe;
581
+ const Xe = /^(?:(?: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])$/, Qe = /^(?:(?: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])$/, Ke = /^(([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]))$/, et = /^(([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])$/, tt = /^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/, rt = /^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/, Ee = "((\\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])))", st = new RegExp(`^${Ee}$`);
582
+ function Re(r) {
583
+ let e = "([01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d";
584
+ return r.precision ? e = `${e}\\.\\d{${r.precision}}` : r.precision == null && (e = `${e}(\\.\\d+)?`), e;
585
+ }
586
+ function nt(r) {
587
+ return new RegExp(`^${Re(r)}$`);
588
+ }
589
+ function Ie(r) {
590
+ let e = `${Ee}T${Re(r)}`;
591
+ const t = [];
592
+ return t.push(r.local ? "Z?" : "Z"), r.offset && t.push("([+-]\\d{2}:?\\d{2})"), e = `${e}(${t.join("|")})`, new RegExp(`^${e}$`);
593
+ }
594
+ function at(r, e) {
595
+ return !!((e === "v4" || !e) && Xe.test(r) || (e === "v6" || !e) && Ke.test(r));
596
+ }
597
+ function it(r, e) {
598
+ if (!Je.test(r))
599
+ return !1;
600
+ try {
601
+ const [t] = r.split("."), s = t.replace(/-/g, "+").replace(/_/g, "/").padEnd(t.length + (4 - t.length % 4) % 4, "="), n = JSON.parse(atob(s));
602
+ return !(typeof n != "object" || n === null || !n.typ || !n.alg || e && n.alg !== e);
603
+ } catch {
604
+ return !1;
605
+ }
606
+ }
607
+ function ot(r, e) {
608
+ return !!((e === "v4" || !e) && Qe.test(r) || (e === "v6" || !e) && et.test(r));
609
+ }
610
+ class Z extends _ {
611
+ _parse(e) {
612
+ if (this._def.coerce && (e.data = String(e.data)), this._getType(e) !== f.string) {
613
+ const a = this._getOrReturnCtx(e);
614
+ return u(a, {
615
+ code: d.invalid_type,
616
+ expected: f.string,
617
+ received: a.parsedType
618
+ }), v;
619
+ }
620
+ const s = new k();
621
+ let n;
622
+ for (const a of this._def.checks)
623
+ if (a.kind === "min")
624
+ e.data.length < a.value && (n = this._getOrReturnCtx(e, n), u(n, {
625
+ code: d.too_small,
626
+ minimum: a.value,
627
+ type: "string",
628
+ inclusive: !0,
629
+ exact: !1,
630
+ message: a.message
631
+ }), s.dirty());
632
+ else if (a.kind === "max")
633
+ e.data.length > a.value && (n = this._getOrReturnCtx(e, n), u(n, {
634
+ code: d.too_big,
635
+ maximum: a.value,
636
+ type: "string",
637
+ inclusive: !0,
638
+ exact: !1,
639
+ message: a.message
640
+ }), s.dirty());
641
+ else if (a.kind === "length") {
642
+ const i = e.data.length > a.value, o = e.data.length < a.value;
643
+ (i || o) && (n = this._getOrReturnCtx(e, n), i ? u(n, {
644
+ code: d.too_big,
645
+ maximum: a.value,
646
+ type: "string",
647
+ inclusive: !0,
648
+ exact: !0,
649
+ message: a.message
650
+ }) : o && u(n, {
651
+ code: d.too_small,
652
+ minimum: a.value,
653
+ type: "string",
654
+ inclusive: !0,
655
+ exact: !0,
656
+ message: a.message
657
+ }), s.dirty());
658
+ } else if (a.kind === "email")
659
+ He.test(e.data) || (n = this._getOrReturnCtx(e, n), u(n, {
660
+ validation: "email",
661
+ code: d.invalid_string,
662
+ message: a.message
663
+ }), s.dirty());
664
+ else if (a.kind === "emoji")
665
+ xe || (xe = new RegExp(Ge, "u")), xe.test(e.data) || (n = this._getOrReturnCtx(e, n), u(n, {
666
+ validation: "emoji",
667
+ code: d.invalid_string,
668
+ message: a.message
669
+ }), s.dirty());
670
+ else if (a.kind === "uuid")
671
+ We.test(e.data) || (n = this._getOrReturnCtx(e, n), u(n, {
672
+ validation: "uuid",
673
+ code: d.invalid_string,
674
+ message: a.message
675
+ }), s.dirty());
676
+ else if (a.kind === "nanoid")
677
+ qe.test(e.data) || (n = this._getOrReturnCtx(e, n), u(n, {
678
+ validation: "nanoid",
679
+ code: d.invalid_string,
680
+ message: a.message
681
+ }), s.dirty());
682
+ else if (a.kind === "cuid")
683
+ Ue.test(e.data) || (n = this._getOrReturnCtx(e, n), u(n, {
684
+ validation: "cuid",
685
+ code: d.invalid_string,
686
+ message: a.message
687
+ }), s.dirty());
688
+ else if (a.kind === "cuid2")
689
+ Be.test(e.data) || (n = this._getOrReturnCtx(e, n), u(n, {
690
+ validation: "cuid2",
691
+ code: d.invalid_string,
692
+ message: a.message
693
+ }), s.dirty());
694
+ else if (a.kind === "ulid")
695
+ Fe.test(e.data) || (n = this._getOrReturnCtx(e, n), u(n, {
696
+ validation: "ulid",
697
+ code: d.invalid_string,
698
+ message: a.message
699
+ }), s.dirty());
700
+ else if (a.kind === "url")
701
+ try {
702
+ new URL(e.data);
703
+ } catch {
704
+ n = this._getOrReturnCtx(e, n), u(n, {
705
+ validation: "url",
706
+ code: d.invalid_string,
707
+ message: a.message
708
+ }), s.dirty();
709
+ }
710
+ else a.kind === "regex" ? (a.regex.lastIndex = 0, a.regex.test(e.data) || (n = this._getOrReturnCtx(e, n), u(n, {
711
+ validation: "regex",
712
+ code: d.invalid_string,
713
+ message: a.message
714
+ }), s.dirty())) : a.kind === "trim" ? e.data = e.data.trim() : a.kind === "includes" ? e.data.includes(a.value, a.position) || (n = this._getOrReturnCtx(e, n), u(n, {
715
+ code: d.invalid_string,
716
+ validation: { includes: a.value, position: a.position },
717
+ message: a.message
718
+ }), s.dirty()) : a.kind === "toLowerCase" ? e.data = e.data.toLowerCase() : a.kind === "toUpperCase" ? e.data = e.data.toUpperCase() : a.kind === "startsWith" ? e.data.startsWith(a.value) || (n = this._getOrReturnCtx(e, n), u(n, {
719
+ code: d.invalid_string,
720
+ validation: { startsWith: a.value },
721
+ message: a.message
722
+ }), s.dirty()) : a.kind === "endsWith" ? e.data.endsWith(a.value) || (n = this._getOrReturnCtx(e, n), u(n, {
723
+ code: d.invalid_string,
724
+ validation: { endsWith: a.value },
725
+ message: a.message
726
+ }), s.dirty()) : a.kind === "datetime" ? Ie(a).test(e.data) || (n = this._getOrReturnCtx(e, n), u(n, {
727
+ code: d.invalid_string,
728
+ validation: "datetime",
729
+ message: a.message
730
+ }), s.dirty()) : a.kind === "date" ? st.test(e.data) || (n = this._getOrReturnCtx(e, n), u(n, {
731
+ code: d.invalid_string,
732
+ validation: "date",
733
+ message: a.message
734
+ }), s.dirty()) : a.kind === "time" ? nt(a).test(e.data) || (n = this._getOrReturnCtx(e, n), u(n, {
735
+ code: d.invalid_string,
736
+ validation: "time",
737
+ message: a.message
738
+ }), s.dirty()) : a.kind === "duration" ? Ye.test(e.data) || (n = this._getOrReturnCtx(e, n), u(n, {
739
+ validation: "duration",
740
+ code: d.invalid_string,
741
+ message: a.message
742
+ }), s.dirty()) : a.kind === "ip" ? at(e.data, a.version) || (n = this._getOrReturnCtx(e, n), u(n, {
743
+ validation: "ip",
744
+ code: d.invalid_string,
745
+ message: a.message
746
+ }), s.dirty()) : a.kind === "jwt" ? it(e.data, a.alg) || (n = this._getOrReturnCtx(e, n), u(n, {
747
+ validation: "jwt",
748
+ code: d.invalid_string,
749
+ message: a.message
750
+ }), s.dirty()) : a.kind === "cidr" ? ot(e.data, a.version) || (n = this._getOrReturnCtx(e, n), u(n, {
751
+ validation: "cidr",
752
+ code: d.invalid_string,
753
+ message: a.message
754
+ }), s.dirty()) : a.kind === "base64" ? tt.test(e.data) || (n = this._getOrReturnCtx(e, n), u(n, {
755
+ validation: "base64",
756
+ code: d.invalid_string,
757
+ message: a.message
758
+ }), s.dirty()) : a.kind === "base64url" ? rt.test(e.data) || (n = this._getOrReturnCtx(e, n), u(n, {
759
+ validation: "base64url",
760
+ code: d.invalid_string,
761
+ message: a.message
762
+ }), s.dirty()) : g.assertNever(a);
763
+ return { status: s.value, value: e.data };
764
+ }
765
+ _regex(e, t, s) {
766
+ return this.refinement((n) => e.test(n), {
767
+ validation: t,
768
+ code: d.invalid_string,
769
+ ...h.errToObj(s)
770
+ });
771
+ }
772
+ _addCheck(e) {
773
+ return new Z({
774
+ ...this._def,
775
+ checks: [...this._def.checks, e]
776
+ });
777
+ }
778
+ email(e) {
779
+ return this._addCheck({ kind: "email", ...h.errToObj(e) });
780
+ }
781
+ url(e) {
782
+ return this._addCheck({ kind: "url", ...h.errToObj(e) });
783
+ }
784
+ emoji(e) {
785
+ return this._addCheck({ kind: "emoji", ...h.errToObj(e) });
786
+ }
787
+ uuid(e) {
788
+ return this._addCheck({ kind: "uuid", ...h.errToObj(e) });
789
+ }
790
+ nanoid(e) {
791
+ return this._addCheck({ kind: "nanoid", ...h.errToObj(e) });
792
+ }
793
+ cuid(e) {
794
+ return this._addCheck({ kind: "cuid", ...h.errToObj(e) });
795
+ }
796
+ cuid2(e) {
797
+ return this._addCheck({ kind: "cuid2", ...h.errToObj(e) });
798
+ }
799
+ ulid(e) {
800
+ return this._addCheck({ kind: "ulid", ...h.errToObj(e) });
801
+ }
802
+ base64(e) {
803
+ return this._addCheck({ kind: "base64", ...h.errToObj(e) });
804
+ }
805
+ base64url(e) {
806
+ return this._addCheck({
807
+ kind: "base64url",
808
+ ...h.errToObj(e)
809
+ });
810
+ }
811
+ jwt(e) {
812
+ return this._addCheck({ kind: "jwt", ...h.errToObj(e) });
813
+ }
814
+ ip(e) {
815
+ return this._addCheck({ kind: "ip", ...h.errToObj(e) });
816
+ }
817
+ cidr(e) {
818
+ return this._addCheck({ kind: "cidr", ...h.errToObj(e) });
819
+ }
820
+ datetime(e) {
821
+ var t, s;
822
+ return typeof e == "string" ? this._addCheck({
823
+ kind: "datetime",
824
+ precision: null,
825
+ offset: !1,
826
+ local: !1,
827
+ message: e
828
+ }) : this._addCheck({
829
+ kind: "datetime",
830
+ precision: typeof e?.precision > "u" ? null : e?.precision,
831
+ offset: (t = e?.offset) !== null && t !== void 0 ? t : !1,
832
+ local: (s = e?.local) !== null && s !== void 0 ? s : !1,
833
+ ...h.errToObj(e?.message)
834
+ });
835
+ }
836
+ date(e) {
837
+ return this._addCheck({ kind: "date", message: e });
838
+ }
839
+ time(e) {
840
+ return typeof e == "string" ? this._addCheck({
841
+ kind: "time",
842
+ precision: null,
843
+ message: e
844
+ }) : this._addCheck({
845
+ kind: "time",
846
+ precision: typeof e?.precision > "u" ? null : e?.precision,
847
+ ...h.errToObj(e?.message)
848
+ });
849
+ }
850
+ duration(e) {
851
+ return this._addCheck({ kind: "duration", ...h.errToObj(e) });
852
+ }
853
+ regex(e, t) {
854
+ return this._addCheck({
855
+ kind: "regex",
856
+ regex: e,
857
+ ...h.errToObj(t)
858
+ });
859
+ }
860
+ includes(e, t) {
861
+ return this._addCheck({
862
+ kind: "includes",
863
+ value: e,
864
+ position: t?.position,
865
+ ...h.errToObj(t?.message)
866
+ });
867
+ }
868
+ startsWith(e, t) {
869
+ return this._addCheck({
870
+ kind: "startsWith",
871
+ value: e,
872
+ ...h.errToObj(t)
873
+ });
874
+ }
875
+ endsWith(e, t) {
876
+ return this._addCheck({
877
+ kind: "endsWith",
878
+ value: e,
879
+ ...h.errToObj(t)
880
+ });
881
+ }
882
+ min(e, t) {
883
+ return this._addCheck({
884
+ kind: "min",
885
+ value: e,
886
+ ...h.errToObj(t)
887
+ });
888
+ }
889
+ max(e, t) {
890
+ return this._addCheck({
891
+ kind: "max",
892
+ value: e,
893
+ ...h.errToObj(t)
894
+ });
895
+ }
896
+ length(e, t) {
897
+ return this._addCheck({
898
+ kind: "length",
899
+ value: e,
900
+ ...h.errToObj(t)
901
+ });
902
+ }
903
+ /**
904
+ * Equivalent to `.min(1)`
905
+ */
906
+ nonempty(e) {
907
+ return this.min(1, h.errToObj(e));
908
+ }
909
+ trim() {
910
+ return new Z({
911
+ ...this._def,
912
+ checks: [...this._def.checks, { kind: "trim" }]
913
+ });
914
+ }
915
+ toLowerCase() {
916
+ return new Z({
917
+ ...this._def,
918
+ checks: [...this._def.checks, { kind: "toLowerCase" }]
919
+ });
920
+ }
921
+ toUpperCase() {
922
+ return new Z({
923
+ ...this._def,
924
+ checks: [...this._def.checks, { kind: "toUpperCase" }]
925
+ });
926
+ }
927
+ get isDatetime() {
928
+ return !!this._def.checks.find((e) => e.kind === "datetime");
929
+ }
930
+ get isDate() {
931
+ return !!this._def.checks.find((e) => e.kind === "date");
932
+ }
933
+ get isTime() {
934
+ return !!this._def.checks.find((e) => e.kind === "time");
935
+ }
936
+ get isDuration() {
937
+ return !!this._def.checks.find((e) => e.kind === "duration");
938
+ }
939
+ get isEmail() {
940
+ return !!this._def.checks.find((e) => e.kind === "email");
941
+ }
942
+ get isURL() {
943
+ return !!this._def.checks.find((e) => e.kind === "url");
944
+ }
945
+ get isEmoji() {
946
+ return !!this._def.checks.find((e) => e.kind === "emoji");
947
+ }
948
+ get isUUID() {
949
+ return !!this._def.checks.find((e) => e.kind === "uuid");
950
+ }
951
+ get isNANOID() {
952
+ return !!this._def.checks.find((e) => e.kind === "nanoid");
953
+ }
954
+ get isCUID() {
955
+ return !!this._def.checks.find((e) => e.kind === "cuid");
956
+ }
957
+ get isCUID2() {
958
+ return !!this._def.checks.find((e) => e.kind === "cuid2");
959
+ }
960
+ get isULID() {
961
+ return !!this._def.checks.find((e) => e.kind === "ulid");
962
+ }
963
+ get isIP() {
964
+ return !!this._def.checks.find((e) => e.kind === "ip");
965
+ }
966
+ get isCIDR() {
967
+ return !!this._def.checks.find((e) => e.kind === "cidr");
968
+ }
969
+ get isBase64() {
970
+ return !!this._def.checks.find((e) => e.kind === "base64");
971
+ }
972
+ get isBase64url() {
973
+ return !!this._def.checks.find((e) => e.kind === "base64url");
974
+ }
975
+ get minLength() {
976
+ let e = null;
977
+ for (const t of this._def.checks)
978
+ t.kind === "min" && (e === null || t.value > e) && (e = t.value);
979
+ return e;
980
+ }
981
+ get maxLength() {
982
+ let e = null;
983
+ for (const t of this._def.checks)
984
+ t.kind === "max" && (e === null || t.value < e) && (e = t.value);
985
+ return e;
986
+ }
987
+ }
988
+ Z.create = (r) => {
989
+ var e;
990
+ return new Z({
991
+ checks: [],
992
+ typeName: m.ZodString,
993
+ coerce: (e = r?.coerce) !== null && e !== void 0 ? e : !1,
994
+ ...y(r)
995
+ });
996
+ };
997
+ function dt(r, e) {
998
+ const t = (r.toString().split(".")[1] || "").length, s = (e.toString().split(".")[1] || "").length, n = t > s ? t : s, a = parseInt(r.toFixed(n).replace(".", "")), i = parseInt(e.toFixed(n).replace(".", ""));
999
+ return a % i / Math.pow(10, n);
1000
+ }
1001
+ class j extends _ {
1002
+ constructor() {
1003
+ super(...arguments), this.min = this.gte, this.max = this.lte, this.step = this.multipleOf;
1004
+ }
1005
+ _parse(e) {
1006
+ if (this._def.coerce && (e.data = Number(e.data)), this._getType(e) !== f.number) {
1007
+ const a = this._getOrReturnCtx(e);
1008
+ return u(a, {
1009
+ code: d.invalid_type,
1010
+ expected: f.number,
1011
+ received: a.parsedType
1012
+ }), v;
1013
+ }
1014
+ let s;
1015
+ const n = new k();
1016
+ for (const a of this._def.checks)
1017
+ a.kind === "int" ? g.isInteger(e.data) || (s = this._getOrReturnCtx(e, s), u(s, {
1018
+ code: d.invalid_type,
1019
+ expected: "integer",
1020
+ received: "float",
1021
+ message: a.message
1022
+ }), n.dirty()) : a.kind === "min" ? (a.inclusive ? e.data < a.value : e.data <= a.value) && (s = this._getOrReturnCtx(e, s), u(s, {
1023
+ code: d.too_small,
1024
+ minimum: a.value,
1025
+ type: "number",
1026
+ inclusive: a.inclusive,
1027
+ exact: !1,
1028
+ message: a.message
1029
+ }), n.dirty()) : a.kind === "max" ? (a.inclusive ? e.data > a.value : e.data >= a.value) && (s = this._getOrReturnCtx(e, s), u(s, {
1030
+ code: d.too_big,
1031
+ maximum: a.value,
1032
+ type: "number",
1033
+ inclusive: a.inclusive,
1034
+ exact: !1,
1035
+ message: a.message
1036
+ }), n.dirty()) : a.kind === "multipleOf" ? dt(e.data, a.value) !== 0 && (s = this._getOrReturnCtx(e, s), u(s, {
1037
+ code: d.not_multiple_of,
1038
+ multipleOf: a.value,
1039
+ message: a.message
1040
+ }), n.dirty()) : a.kind === "finite" ? Number.isFinite(e.data) || (s = this._getOrReturnCtx(e, s), u(s, {
1041
+ code: d.not_finite,
1042
+ message: a.message
1043
+ }), n.dirty()) : g.assertNever(a);
1044
+ return { status: n.value, value: e.data };
1045
+ }
1046
+ gte(e, t) {
1047
+ return this.setLimit("min", e, !0, h.toString(t));
1048
+ }
1049
+ gt(e, t) {
1050
+ return this.setLimit("min", e, !1, h.toString(t));
1051
+ }
1052
+ lte(e, t) {
1053
+ return this.setLimit("max", e, !0, h.toString(t));
1054
+ }
1055
+ lt(e, t) {
1056
+ return this.setLimit("max", e, !1, h.toString(t));
1057
+ }
1058
+ setLimit(e, t, s, n) {
1059
+ return new j({
1060
+ ...this._def,
1061
+ checks: [
1062
+ ...this._def.checks,
1063
+ {
1064
+ kind: e,
1065
+ value: t,
1066
+ inclusive: s,
1067
+ message: h.toString(n)
1068
+ }
1069
+ ]
1070
+ });
1071
+ }
1072
+ _addCheck(e) {
1073
+ return new j({
1074
+ ...this._def,
1075
+ checks: [...this._def.checks, e]
1076
+ });
1077
+ }
1078
+ int(e) {
1079
+ return this._addCheck({
1080
+ kind: "int",
1081
+ message: h.toString(e)
1082
+ });
1083
+ }
1084
+ positive(e) {
1085
+ return this._addCheck({
1086
+ kind: "min",
1087
+ value: 0,
1088
+ inclusive: !1,
1089
+ message: h.toString(e)
1090
+ });
1091
+ }
1092
+ negative(e) {
1093
+ return this._addCheck({
1094
+ kind: "max",
1095
+ value: 0,
1096
+ inclusive: !1,
1097
+ message: h.toString(e)
1098
+ });
1099
+ }
1100
+ nonpositive(e) {
1101
+ return this._addCheck({
1102
+ kind: "max",
1103
+ value: 0,
1104
+ inclusive: !0,
1105
+ message: h.toString(e)
1106
+ });
1107
+ }
1108
+ nonnegative(e) {
1109
+ return this._addCheck({
1110
+ kind: "min",
1111
+ value: 0,
1112
+ inclusive: !0,
1113
+ message: h.toString(e)
1114
+ });
1115
+ }
1116
+ multipleOf(e, t) {
1117
+ return this._addCheck({
1118
+ kind: "multipleOf",
1119
+ value: e,
1120
+ message: h.toString(t)
1121
+ });
1122
+ }
1123
+ finite(e) {
1124
+ return this._addCheck({
1125
+ kind: "finite",
1126
+ message: h.toString(e)
1127
+ });
1128
+ }
1129
+ safe(e) {
1130
+ return this._addCheck({
1131
+ kind: "min",
1132
+ inclusive: !0,
1133
+ value: Number.MIN_SAFE_INTEGER,
1134
+ message: h.toString(e)
1135
+ })._addCheck({
1136
+ kind: "max",
1137
+ inclusive: !0,
1138
+ value: Number.MAX_SAFE_INTEGER,
1139
+ message: h.toString(e)
1140
+ });
1141
+ }
1142
+ get minValue() {
1143
+ let e = null;
1144
+ for (const t of this._def.checks)
1145
+ t.kind === "min" && (e === null || t.value > e) && (e = t.value);
1146
+ return e;
1147
+ }
1148
+ get maxValue() {
1149
+ let e = null;
1150
+ for (const t of this._def.checks)
1151
+ t.kind === "max" && (e === null || t.value < e) && (e = t.value);
1152
+ return e;
1153
+ }
1154
+ get isInt() {
1155
+ return !!this._def.checks.find((e) => e.kind === "int" || e.kind === "multipleOf" && g.isInteger(e.value));
1156
+ }
1157
+ get isFinite() {
1158
+ let e = null, t = null;
1159
+ for (const s of this._def.checks) {
1160
+ if (s.kind === "finite" || s.kind === "int" || s.kind === "multipleOf")
1161
+ return !0;
1162
+ s.kind === "min" ? (t === null || s.value > t) && (t = s.value) : s.kind === "max" && (e === null || s.value < e) && (e = s.value);
1163
+ }
1164
+ return Number.isFinite(t) && Number.isFinite(e);
1165
+ }
1166
+ }
1167
+ j.create = (r) => new j({
1168
+ checks: [],
1169
+ typeName: m.ZodNumber,
1170
+ coerce: r?.coerce || !1,
1171
+ ...y(r)
1172
+ });
1173
+ class M extends _ {
1174
+ constructor() {
1175
+ super(...arguments), this.min = this.gte, this.max = this.lte;
1176
+ }
1177
+ _parse(e) {
1178
+ if (this._def.coerce)
1179
+ try {
1180
+ e.data = BigInt(e.data);
1181
+ } catch {
1182
+ return this._getInvalidInput(e);
1183
+ }
1184
+ if (this._getType(e) !== f.bigint)
1185
+ return this._getInvalidInput(e);
1186
+ let s;
1187
+ const n = new k();
1188
+ for (const a of this._def.checks)
1189
+ a.kind === "min" ? (a.inclusive ? e.data < a.value : e.data <= a.value) && (s = this._getOrReturnCtx(e, s), u(s, {
1190
+ code: d.too_small,
1191
+ type: "bigint",
1192
+ minimum: a.value,
1193
+ inclusive: a.inclusive,
1194
+ message: a.message
1195
+ }), n.dirty()) : a.kind === "max" ? (a.inclusive ? e.data > a.value : e.data >= a.value) && (s = this._getOrReturnCtx(e, s), u(s, {
1196
+ code: d.too_big,
1197
+ type: "bigint",
1198
+ maximum: a.value,
1199
+ inclusive: a.inclusive,
1200
+ message: a.message
1201
+ }), n.dirty()) : a.kind === "multipleOf" ? e.data % a.value !== BigInt(0) && (s = this._getOrReturnCtx(e, s), u(s, {
1202
+ code: d.not_multiple_of,
1203
+ multipleOf: a.value,
1204
+ message: a.message
1205
+ }), n.dirty()) : g.assertNever(a);
1206
+ return { status: n.value, value: e.data };
1207
+ }
1208
+ _getInvalidInput(e) {
1209
+ const t = this._getOrReturnCtx(e);
1210
+ return u(t, {
1211
+ code: d.invalid_type,
1212
+ expected: f.bigint,
1213
+ received: t.parsedType
1214
+ }), v;
1215
+ }
1216
+ gte(e, t) {
1217
+ return this.setLimit("min", e, !0, h.toString(t));
1218
+ }
1219
+ gt(e, t) {
1220
+ return this.setLimit("min", e, !1, h.toString(t));
1221
+ }
1222
+ lte(e, t) {
1223
+ return this.setLimit("max", e, !0, h.toString(t));
1224
+ }
1225
+ lt(e, t) {
1226
+ return this.setLimit("max", e, !1, h.toString(t));
1227
+ }
1228
+ setLimit(e, t, s, n) {
1229
+ return new M({
1230
+ ...this._def,
1231
+ checks: [
1232
+ ...this._def.checks,
1233
+ {
1234
+ kind: e,
1235
+ value: t,
1236
+ inclusive: s,
1237
+ message: h.toString(n)
1238
+ }
1239
+ ]
1240
+ });
1241
+ }
1242
+ _addCheck(e) {
1243
+ return new M({
1244
+ ...this._def,
1245
+ checks: [...this._def.checks, e]
1246
+ });
1247
+ }
1248
+ positive(e) {
1249
+ return this._addCheck({
1250
+ kind: "min",
1251
+ value: BigInt(0),
1252
+ inclusive: !1,
1253
+ message: h.toString(e)
1254
+ });
1255
+ }
1256
+ negative(e) {
1257
+ return this._addCheck({
1258
+ kind: "max",
1259
+ value: BigInt(0),
1260
+ inclusive: !1,
1261
+ message: h.toString(e)
1262
+ });
1263
+ }
1264
+ nonpositive(e) {
1265
+ return this._addCheck({
1266
+ kind: "max",
1267
+ value: BigInt(0),
1268
+ inclusive: !0,
1269
+ message: h.toString(e)
1270
+ });
1271
+ }
1272
+ nonnegative(e) {
1273
+ return this._addCheck({
1274
+ kind: "min",
1275
+ value: BigInt(0),
1276
+ inclusive: !0,
1277
+ message: h.toString(e)
1278
+ });
1279
+ }
1280
+ multipleOf(e, t) {
1281
+ return this._addCheck({
1282
+ kind: "multipleOf",
1283
+ value: e,
1284
+ message: h.toString(t)
1285
+ });
1286
+ }
1287
+ get minValue() {
1288
+ let e = null;
1289
+ for (const t of this._def.checks)
1290
+ t.kind === "min" && (e === null || t.value > e) && (e = t.value);
1291
+ return e;
1292
+ }
1293
+ get maxValue() {
1294
+ let e = null;
1295
+ for (const t of this._def.checks)
1296
+ t.kind === "max" && (e === null || t.value < e) && (e = t.value);
1297
+ return e;
1298
+ }
1299
+ }
1300
+ M.create = (r) => {
1301
+ var e;
1302
+ return new M({
1303
+ checks: [],
1304
+ typeName: m.ZodBigInt,
1305
+ coerce: (e = r?.coerce) !== null && e !== void 0 ? e : !1,
1306
+ ...y(r)
1307
+ });
1308
+ };
1309
+ class X extends _ {
1310
+ _parse(e) {
1311
+ if (this._def.coerce && (e.data = !!e.data), this._getType(e) !== f.boolean) {
1312
+ const s = this._getOrReturnCtx(e);
1313
+ return u(s, {
1314
+ code: d.invalid_type,
1315
+ expected: f.boolean,
1316
+ received: s.parsedType
1317
+ }), v;
1318
+ }
1319
+ return w(e.data);
1320
+ }
1321
+ }
1322
+ X.create = (r) => new X({
1323
+ typeName: m.ZodBoolean,
1324
+ coerce: r?.coerce || !1,
1325
+ ...y(r)
1326
+ });
1327
+ class D extends _ {
1328
+ _parse(e) {
1329
+ if (this._def.coerce && (e.data = new Date(e.data)), this._getType(e) !== f.date) {
1330
+ const a = this._getOrReturnCtx(e);
1331
+ return u(a, {
1332
+ code: d.invalid_type,
1333
+ expected: f.date,
1334
+ received: a.parsedType
1335
+ }), v;
1336
+ }
1337
+ if (isNaN(e.data.getTime())) {
1338
+ const a = this._getOrReturnCtx(e);
1339
+ return u(a, {
1340
+ code: d.invalid_date
1341
+ }), v;
1342
+ }
1343
+ const s = new k();
1344
+ let n;
1345
+ for (const a of this._def.checks)
1346
+ a.kind === "min" ? e.data.getTime() < a.value && (n = this._getOrReturnCtx(e, n), u(n, {
1347
+ code: d.too_small,
1348
+ message: a.message,
1349
+ inclusive: !0,
1350
+ exact: !1,
1351
+ minimum: a.value,
1352
+ type: "date"
1353
+ }), s.dirty()) : a.kind === "max" ? e.data.getTime() > a.value && (n = this._getOrReturnCtx(e, n), u(n, {
1354
+ code: d.too_big,
1355
+ message: a.message,
1356
+ inclusive: !0,
1357
+ exact: !1,
1358
+ maximum: a.value,
1359
+ type: "date"
1360
+ }), s.dirty()) : g.assertNever(a);
1361
+ return {
1362
+ status: s.value,
1363
+ value: new Date(e.data.getTime())
1364
+ };
1365
+ }
1366
+ _addCheck(e) {
1367
+ return new D({
1368
+ ...this._def,
1369
+ checks: [...this._def.checks, e]
1370
+ });
1371
+ }
1372
+ min(e, t) {
1373
+ return this._addCheck({
1374
+ kind: "min",
1375
+ value: e.getTime(),
1376
+ message: h.toString(t)
1377
+ });
1378
+ }
1379
+ max(e, t) {
1380
+ return this._addCheck({
1381
+ kind: "max",
1382
+ value: e.getTime(),
1383
+ message: h.toString(t)
1384
+ });
1385
+ }
1386
+ get minDate() {
1387
+ let e = null;
1388
+ for (const t of this._def.checks)
1389
+ t.kind === "min" && (e === null || t.value > e) && (e = t.value);
1390
+ return e != null ? new Date(e) : null;
1391
+ }
1392
+ get maxDate() {
1393
+ let e = null;
1394
+ for (const t of this._def.checks)
1395
+ t.kind === "max" && (e === null || t.value < e) && (e = t.value);
1396
+ return e != null ? new Date(e) : null;
1397
+ }
1398
+ }
1399
+ D.create = (r) => new D({
1400
+ checks: [],
1401
+ coerce: r?.coerce || !1,
1402
+ typeName: m.ZodDate,
1403
+ ...y(r)
1404
+ });
1405
+ class pe extends _ {
1406
+ _parse(e) {
1407
+ if (this._getType(e) !== f.symbol) {
1408
+ const s = this._getOrReturnCtx(e);
1409
+ return u(s, {
1410
+ code: d.invalid_type,
1411
+ expected: f.symbol,
1412
+ received: s.parsedType
1413
+ }), v;
1414
+ }
1415
+ return w(e.data);
1416
+ }
1417
+ }
1418
+ pe.create = (r) => new pe({
1419
+ typeName: m.ZodSymbol,
1420
+ ...y(r)
1421
+ });
1422
+ class Q extends _ {
1423
+ _parse(e) {
1424
+ if (this._getType(e) !== f.undefined) {
1425
+ const s = this._getOrReturnCtx(e);
1426
+ return u(s, {
1427
+ code: d.invalid_type,
1428
+ expected: f.undefined,
1429
+ received: s.parsedType
1430
+ }), v;
1431
+ }
1432
+ return w(e.data);
1433
+ }
1434
+ }
1435
+ Q.create = (r) => new Q({
1436
+ typeName: m.ZodUndefined,
1437
+ ...y(r)
1438
+ });
1439
+ class K extends _ {
1440
+ _parse(e) {
1441
+ if (this._getType(e) !== f.null) {
1442
+ const s = this._getOrReturnCtx(e);
1443
+ return u(s, {
1444
+ code: d.invalid_type,
1445
+ expected: f.null,
1446
+ received: s.parsedType
1447
+ }), v;
1448
+ }
1449
+ return w(e.data);
1450
+ }
1451
+ }
1452
+ K.create = (r) => new K({
1453
+ typeName: m.ZodNull,
1454
+ ...y(r)
1455
+ });
1456
+ class q extends _ {
1457
+ constructor() {
1458
+ super(...arguments), this._any = !0;
1459
+ }
1460
+ _parse(e) {
1461
+ return w(e.data);
1462
+ }
1463
+ }
1464
+ q.create = (r) => new q({
1465
+ typeName: m.ZodAny,
1466
+ ...y(r)
1467
+ });
1468
+ class V extends _ {
1469
+ constructor() {
1470
+ super(...arguments), this._unknown = !0;
1471
+ }
1472
+ _parse(e) {
1473
+ return w(e.data);
1474
+ }
1475
+ }
1476
+ V.create = (r) => new V({
1477
+ typeName: m.ZodUnknown,
1478
+ ...y(r)
1479
+ });
1480
+ class I extends _ {
1481
+ _parse(e) {
1482
+ const t = this._getOrReturnCtx(e);
1483
+ return u(t, {
1484
+ code: d.invalid_type,
1485
+ expected: f.never,
1486
+ received: t.parsedType
1487
+ }), v;
1488
+ }
1489
+ }
1490
+ I.create = (r) => new I({
1491
+ typeName: m.ZodNever,
1492
+ ...y(r)
1493
+ });
1494
+ class me extends _ {
1495
+ _parse(e) {
1496
+ if (this._getType(e) !== f.undefined) {
1497
+ const s = this._getOrReturnCtx(e);
1498
+ return u(s, {
1499
+ code: d.invalid_type,
1500
+ expected: f.void,
1501
+ received: s.parsedType
1502
+ }), v;
1503
+ }
1504
+ return w(e.data);
1505
+ }
1506
+ }
1507
+ me.create = (r) => new me({
1508
+ typeName: m.ZodVoid,
1509
+ ...y(r)
1510
+ });
1511
+ class C extends _ {
1512
+ _parse(e) {
1513
+ const { ctx: t, status: s } = this._processInputParams(e), n = this._def;
1514
+ if (t.parsedType !== f.array)
1515
+ return u(t, {
1516
+ code: d.invalid_type,
1517
+ expected: f.array,
1518
+ received: t.parsedType
1519
+ }), v;
1520
+ if (n.exactLength !== null) {
1521
+ const i = t.data.length > n.exactLength.value, o = t.data.length < n.exactLength.value;
1522
+ (i || o) && (u(t, {
1523
+ code: i ? d.too_big : d.too_small,
1524
+ minimum: o ? n.exactLength.value : void 0,
1525
+ maximum: i ? n.exactLength.value : void 0,
1526
+ type: "array",
1527
+ inclusive: !0,
1528
+ exact: !0,
1529
+ message: n.exactLength.message
1530
+ }), s.dirty());
1531
+ }
1532
+ if (n.minLength !== null && t.data.length < n.minLength.value && (u(t, {
1533
+ code: d.too_small,
1534
+ minimum: n.minLength.value,
1535
+ type: "array",
1536
+ inclusive: !0,
1537
+ exact: !1,
1538
+ message: n.minLength.message
1539
+ }), s.dirty()), n.maxLength !== null && t.data.length > n.maxLength.value && (u(t, {
1540
+ code: d.too_big,
1541
+ maximum: n.maxLength.value,
1542
+ type: "array",
1543
+ inclusive: !0,
1544
+ exact: !1,
1545
+ message: n.maxLength.message
1546
+ }), s.dirty()), t.common.async)
1547
+ return Promise.all([...t.data].map((i, o) => n.type._parseAsync(new O(t, i, t.path, o)))).then((i) => k.mergeArray(s, i));
1548
+ const a = [...t.data].map((i, o) => n.type._parseSync(new O(t, i, t.path, o)));
1549
+ return k.mergeArray(s, a);
1550
+ }
1551
+ get element() {
1552
+ return this._def.type;
1553
+ }
1554
+ min(e, t) {
1555
+ return new C({
1556
+ ...this._def,
1557
+ minLength: { value: e, message: h.toString(t) }
1558
+ });
1559
+ }
1560
+ max(e, t) {
1561
+ return new C({
1562
+ ...this._def,
1563
+ maxLength: { value: e, message: h.toString(t) }
1564
+ });
1565
+ }
1566
+ length(e, t) {
1567
+ return new C({
1568
+ ...this._def,
1569
+ exactLength: { value: e, message: h.toString(t) }
1570
+ });
1571
+ }
1572
+ nonempty(e) {
1573
+ return this.min(1, e);
1574
+ }
1575
+ }
1576
+ C.create = (r, e) => new C({
1577
+ type: r,
1578
+ minLength: null,
1579
+ maxLength: null,
1580
+ exactLength: null,
1581
+ typeName: m.ZodArray,
1582
+ ...y(e)
1583
+ });
1584
+ function U(r) {
1585
+ if (r instanceof x) {
1586
+ const e = {};
1587
+ for (const t in r.shape) {
1588
+ const s = r.shape[t];
1589
+ e[t] = A.create(U(s));
1590
+ }
1591
+ return new x({
1592
+ ...r._def,
1593
+ shape: () => e
1594
+ });
1595
+ } else return r instanceof C ? new C({
1596
+ ...r._def,
1597
+ type: U(r.element)
1598
+ }) : r instanceof A ? A.create(U(r.unwrap())) : r instanceof P ? P.create(U(r.unwrap())) : r instanceof N ? N.create(r.items.map((e) => U(e))) : r;
1599
+ }
1600
+ class x extends _ {
1601
+ constructor() {
1602
+ super(...arguments), this._cached = null, this.nonstrict = this.passthrough, this.augment = this.extend;
1603
+ }
1604
+ _getCached() {
1605
+ if (this._cached !== null)
1606
+ return this._cached;
1607
+ const e = this._def.shape(), t = g.objectKeys(e);
1608
+ return this._cached = { shape: e, keys: t };
1609
+ }
1610
+ _parse(e) {
1611
+ if (this._getType(e) !== f.object) {
1612
+ const c = this._getOrReturnCtx(e);
1613
+ return u(c, {
1614
+ code: d.invalid_type,
1615
+ expected: f.object,
1616
+ received: c.parsedType
1617
+ }), v;
1618
+ }
1619
+ const { status: s, ctx: n } = this._processInputParams(e), { shape: a, keys: i } = this._getCached(), o = [];
1620
+ if (!(this._def.catchall instanceof I && this._def.unknownKeys === "strip"))
1621
+ for (const c in n.data)
1622
+ i.includes(c) || o.push(c);
1623
+ const l = [];
1624
+ for (const c of i) {
1625
+ const p = a[c], b = n.data[c];
1626
+ l.push({
1627
+ key: { status: "valid", value: c },
1628
+ value: p._parse(new O(n, b, n.path, c)),
1629
+ alwaysSet: c in n.data
1630
+ });
1631
+ }
1632
+ if (this._def.catchall instanceof I) {
1633
+ const c = this._def.unknownKeys;
1634
+ if (c === "passthrough")
1635
+ for (const p of o)
1636
+ l.push({
1637
+ key: { status: "valid", value: p },
1638
+ value: { status: "valid", value: n.data[p] }
1639
+ });
1640
+ else if (c === "strict")
1641
+ o.length > 0 && (u(n, {
1642
+ code: d.unrecognized_keys,
1643
+ keys: o
1644
+ }), s.dirty());
1645
+ else if (c !== "strip") throw new Error("Internal ZodObject error: invalid unknownKeys value.");
1646
+ } else {
1647
+ const c = this._def.catchall;
1648
+ for (const p of o) {
1649
+ const b = n.data[p];
1650
+ l.push({
1651
+ key: { status: "valid", value: p },
1652
+ value: c._parse(
1653
+ new O(n, b, n.path, p)
1654
+ //, ctx.child(key), value, getParsedType(value)
1655
+ ),
1656
+ alwaysSet: p in n.data
1657
+ });
1658
+ }
1659
+ }
1660
+ return n.common.async ? Promise.resolve().then(async () => {
1661
+ const c = [];
1662
+ for (const p of l) {
1663
+ const b = await p.key, ue = await p.value;
1664
+ c.push({
1665
+ key: b,
1666
+ value: ue,
1667
+ alwaysSet: p.alwaysSet
1668
+ });
1669
+ }
1670
+ return c;
1671
+ }).then((c) => k.mergeObjectSync(s, c)) : k.mergeObjectSync(s, l);
1672
+ }
1673
+ get shape() {
1674
+ return this._def.shape();
1675
+ }
1676
+ strict(e) {
1677
+ return h.errToObj, new x({
1678
+ ...this._def,
1679
+ unknownKeys: "strict",
1680
+ ...e !== void 0 ? {
1681
+ errorMap: (t, s) => {
1682
+ var n, a, i, o;
1683
+ const l = (i = (a = (n = this._def).errorMap) === null || a === void 0 ? void 0 : a.call(n, t, s).message) !== null && i !== void 0 ? i : s.defaultError;
1684
+ return t.code === "unrecognized_keys" ? {
1685
+ message: (o = h.errToObj(e).message) !== null && o !== void 0 ? o : l
1686
+ } : {
1687
+ message: l
1688
+ };
1689
+ }
1690
+ } : {}
1691
+ });
1692
+ }
1693
+ strip() {
1694
+ return new x({
1695
+ ...this._def,
1696
+ unknownKeys: "strip"
1697
+ });
1698
+ }
1699
+ passthrough() {
1700
+ return new x({
1701
+ ...this._def,
1702
+ unknownKeys: "passthrough"
1703
+ });
1704
+ }
1705
+ // const AugmentFactory =
1706
+ // <Def extends ZodObjectDef>(def: Def) =>
1707
+ // <Augmentation extends ZodRawShape>(
1708
+ // augmentation: Augmentation
1709
+ // ): ZodObject<
1710
+ // extendShape<ReturnType<Def["shape"]>, Augmentation>,
1711
+ // Def["unknownKeys"],
1712
+ // Def["catchall"]
1713
+ // > => {
1714
+ // return new ZodObject({
1715
+ // ...def,
1716
+ // shape: () => ({
1717
+ // ...def.shape(),
1718
+ // ...augmentation,
1719
+ // }),
1720
+ // }) as any;
1721
+ // };
1722
+ extend(e) {
1723
+ return new x({
1724
+ ...this._def,
1725
+ shape: () => ({
1726
+ ...this._def.shape(),
1727
+ ...e
1728
+ })
1729
+ });
1730
+ }
1731
+ /**
1732
+ * Prior to zod@1.0.12 there was a bug in the
1733
+ * inferred type of merged objects. Please
1734
+ * upgrade if you are experiencing issues.
1735
+ */
1736
+ merge(e) {
1737
+ return new x({
1738
+ unknownKeys: e._def.unknownKeys,
1739
+ catchall: e._def.catchall,
1740
+ shape: () => ({
1741
+ ...this._def.shape(),
1742
+ ...e._def.shape()
1743
+ }),
1744
+ typeName: m.ZodObject
1745
+ });
1746
+ }
1747
+ // merge<
1748
+ // Incoming extends AnyZodObject,
1749
+ // Augmentation extends Incoming["shape"],
1750
+ // NewOutput extends {
1751
+ // [k in keyof Augmentation | keyof Output]: k extends keyof Augmentation
1752
+ // ? Augmentation[k]["_output"]
1753
+ // : k extends keyof Output
1754
+ // ? Output[k]
1755
+ // : never;
1756
+ // },
1757
+ // NewInput extends {
1758
+ // [k in keyof Augmentation | keyof Input]: k extends keyof Augmentation
1759
+ // ? Augmentation[k]["_input"]
1760
+ // : k extends keyof Input
1761
+ // ? Input[k]
1762
+ // : never;
1763
+ // }
1764
+ // >(
1765
+ // merging: Incoming
1766
+ // ): ZodObject<
1767
+ // extendShape<T, ReturnType<Incoming["_def"]["shape"]>>,
1768
+ // Incoming["_def"]["unknownKeys"],
1769
+ // Incoming["_def"]["catchall"],
1770
+ // NewOutput,
1771
+ // NewInput
1772
+ // > {
1773
+ // const merged: any = new ZodObject({
1774
+ // unknownKeys: merging._def.unknownKeys,
1775
+ // catchall: merging._def.catchall,
1776
+ // shape: () =>
1777
+ // objectUtil.mergeShapes(this._def.shape(), merging._def.shape()),
1778
+ // typeName: ZodFirstPartyTypeKind.ZodObject,
1779
+ // }) as any;
1780
+ // return merged;
1781
+ // }
1782
+ setKey(e, t) {
1783
+ return this.augment({ [e]: t });
1784
+ }
1785
+ // merge<Incoming extends AnyZodObject>(
1786
+ // merging: Incoming
1787
+ // ): //ZodObject<T & Incoming["_shape"], UnknownKeys, Catchall> = (merging) => {
1788
+ // ZodObject<
1789
+ // extendShape<T, ReturnType<Incoming["_def"]["shape"]>>,
1790
+ // Incoming["_def"]["unknownKeys"],
1791
+ // Incoming["_def"]["catchall"]
1792
+ // > {
1793
+ // // const mergedShape = objectUtil.mergeShapes(
1794
+ // // this._def.shape(),
1795
+ // // merging._def.shape()
1796
+ // // );
1797
+ // const merged: any = new ZodObject({
1798
+ // unknownKeys: merging._def.unknownKeys,
1799
+ // catchall: merging._def.catchall,
1800
+ // shape: () =>
1801
+ // objectUtil.mergeShapes(this._def.shape(), merging._def.shape()),
1802
+ // typeName: ZodFirstPartyTypeKind.ZodObject,
1803
+ // }) as any;
1804
+ // return merged;
1805
+ // }
1806
+ catchall(e) {
1807
+ return new x({
1808
+ ...this._def,
1809
+ catchall: e
1810
+ });
1811
+ }
1812
+ pick(e) {
1813
+ const t = {};
1814
+ return g.objectKeys(e).forEach((s) => {
1815
+ e[s] && this.shape[s] && (t[s] = this.shape[s]);
1816
+ }), new x({
1817
+ ...this._def,
1818
+ shape: () => t
1819
+ });
1820
+ }
1821
+ omit(e) {
1822
+ const t = {};
1823
+ return g.objectKeys(this.shape).forEach((s) => {
1824
+ e[s] || (t[s] = this.shape[s]);
1825
+ }), new x({
1826
+ ...this._def,
1827
+ shape: () => t
1828
+ });
1829
+ }
1830
+ /**
1831
+ * @deprecated
1832
+ */
1833
+ deepPartial() {
1834
+ return U(this);
1835
+ }
1836
+ partial(e) {
1837
+ const t = {};
1838
+ return g.objectKeys(this.shape).forEach((s) => {
1839
+ const n = this.shape[s];
1840
+ e && !e[s] ? t[s] = n : t[s] = n.optional();
1841
+ }), new x({
1842
+ ...this._def,
1843
+ shape: () => t
1844
+ });
1845
+ }
1846
+ required(e) {
1847
+ const t = {};
1848
+ return g.objectKeys(this.shape).forEach((s) => {
1849
+ if (e && !e[s])
1850
+ t[s] = this.shape[s];
1851
+ else {
1852
+ let a = this.shape[s];
1853
+ for (; a instanceof A; )
1854
+ a = a._def.innerType;
1855
+ t[s] = a;
1856
+ }
1857
+ }), new x({
1858
+ ...this._def,
1859
+ shape: () => t
1860
+ });
1861
+ }
1862
+ keyof() {
1863
+ return je(g.objectKeys(this.shape));
1864
+ }
1865
+ }
1866
+ x.create = (r, e) => new x({
1867
+ shape: () => r,
1868
+ unknownKeys: "strip",
1869
+ catchall: I.create(),
1870
+ typeName: m.ZodObject,
1871
+ ...y(e)
1872
+ });
1873
+ x.strictCreate = (r, e) => new x({
1874
+ shape: () => r,
1875
+ unknownKeys: "strict",
1876
+ catchall: I.create(),
1877
+ typeName: m.ZodObject,
1878
+ ...y(e)
1879
+ });
1880
+ x.lazycreate = (r, e) => new x({
1881
+ shape: r,
1882
+ unknownKeys: "strip",
1883
+ catchall: I.create(),
1884
+ typeName: m.ZodObject,
1885
+ ...y(e)
1886
+ });
1887
+ class ee extends _ {
1888
+ _parse(e) {
1889
+ const { ctx: t } = this._processInputParams(e), s = this._def.options;
1890
+ function n(a) {
1891
+ for (const o of a)
1892
+ if (o.result.status === "valid")
1893
+ return o.result;
1894
+ for (const o of a)
1895
+ if (o.result.status === "dirty")
1896
+ return t.common.issues.push(...o.ctx.common.issues), o.result;
1897
+ const i = a.map((o) => new T(o.ctx.common.issues));
1898
+ return u(t, {
1899
+ code: d.invalid_union,
1900
+ unionErrors: i
1901
+ }), v;
1902
+ }
1903
+ if (t.common.async)
1904
+ return Promise.all(s.map(async (a) => {
1905
+ const i = {
1906
+ ...t,
1907
+ common: {
1908
+ ...t.common,
1909
+ issues: []
1910
+ },
1911
+ parent: null
1912
+ };
1913
+ return {
1914
+ result: await a._parseAsync({
1915
+ data: t.data,
1916
+ path: t.path,
1917
+ parent: i
1918
+ }),
1919
+ ctx: i
1920
+ };
1921
+ })).then(n);
1922
+ {
1923
+ let a;
1924
+ const i = [];
1925
+ for (const l of s) {
1926
+ const c = {
1927
+ ...t,
1928
+ common: {
1929
+ ...t.common,
1930
+ issues: []
1931
+ },
1932
+ parent: null
1933
+ }, p = l._parseSync({
1934
+ data: t.data,
1935
+ path: t.path,
1936
+ parent: c
1937
+ });
1938
+ if (p.status === "valid")
1939
+ return p;
1940
+ p.status === "dirty" && !a && (a = { result: p, ctx: c }), c.common.issues.length && i.push(c.common.issues);
1941
+ }
1942
+ if (a)
1943
+ return t.common.issues.push(...a.ctx.common.issues), a.result;
1944
+ const o = i.map((l) => new T(l));
1945
+ return u(t, {
1946
+ code: d.invalid_union,
1947
+ unionErrors: o
1948
+ }), v;
1949
+ }
1950
+ }
1951
+ get options() {
1952
+ return this._def.options;
1953
+ }
1954
+ }
1955
+ ee.create = (r, e) => new ee({
1956
+ options: r,
1957
+ typeName: m.ZodUnion,
1958
+ ...y(e)
1959
+ });
1960
+ const E = (r) => r instanceof se ? E(r.schema) : r instanceof S ? E(r.innerType()) : r instanceof ne ? [r.value] : r instanceof $ ? r.options : r instanceof ae ? g.objectValues(r.enum) : r instanceof ie ? E(r._def.innerType) : r instanceof Q ? [void 0] : r instanceof K ? [null] : r instanceof A ? [void 0, ...E(r.unwrap())] : r instanceof P ? [null, ...E(r.unwrap())] : r instanceof Ze || r instanceof de ? E(r.unwrap()) : r instanceof oe ? E(r._def.innerType) : [];
1961
+ class _e extends _ {
1962
+ _parse(e) {
1963
+ const { ctx: t } = this._processInputParams(e);
1964
+ if (t.parsedType !== f.object)
1965
+ return u(t, {
1966
+ code: d.invalid_type,
1967
+ expected: f.object,
1968
+ received: t.parsedType
1969
+ }), v;
1970
+ const s = this.discriminator, n = t.data[s], a = this.optionsMap.get(n);
1971
+ return a ? t.common.async ? a._parseAsync({
1972
+ data: t.data,
1973
+ path: t.path,
1974
+ parent: t
1975
+ }) : a._parseSync({
1976
+ data: t.data,
1977
+ path: t.path,
1978
+ parent: t
1979
+ }) : (u(t, {
1980
+ code: d.invalid_union_discriminator,
1981
+ options: Array.from(this.optionsMap.keys()),
1982
+ path: [s]
1983
+ }), v);
1984
+ }
1985
+ get discriminator() {
1986
+ return this._def.discriminator;
1987
+ }
1988
+ get options() {
1989
+ return this._def.options;
1990
+ }
1991
+ get optionsMap() {
1992
+ return this._def.optionsMap;
1993
+ }
1994
+ /**
1995
+ * The constructor of the discriminated union schema. Its behaviour is very similar to that of the normal z.union() constructor.
1996
+ * However, it only allows a union of objects, all of which need to share a discriminator property. This property must
1997
+ * have a different value for each object in the union.
1998
+ * @param discriminator the name of the discriminator property
1999
+ * @param types an array of object schemas
2000
+ * @param params
2001
+ */
2002
+ static create(e, t, s) {
2003
+ const n = /* @__PURE__ */ new Map();
2004
+ for (const a of t) {
2005
+ const i = E(a.shape[e]);
2006
+ if (!i.length)
2007
+ throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);
2008
+ for (const o of i) {
2009
+ if (n.has(o))
2010
+ throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(o)}`);
2011
+ n.set(o, a);
2012
+ }
2013
+ }
2014
+ return new _e({
2015
+ typeName: m.ZodDiscriminatedUnion,
2016
+ discriminator: e,
2017
+ options: t,
2018
+ optionsMap: n,
2019
+ ...y(s)
2020
+ });
2021
+ }
2022
+ }
2023
+ function Te(r, e) {
2024
+ const t = R(r), s = R(e);
2025
+ if (r === e)
2026
+ return { valid: !0, data: r };
2027
+ if (t === f.object && s === f.object) {
2028
+ const n = g.objectKeys(e), a = g.objectKeys(r).filter((o) => n.indexOf(o) !== -1), i = { ...r, ...e };
2029
+ for (const o of a) {
2030
+ const l = Te(r[o], e[o]);
2031
+ if (!l.valid)
2032
+ return { valid: !1 };
2033
+ i[o] = l.data;
2034
+ }
2035
+ return { valid: !0, data: i };
2036
+ } else if (t === f.array && s === f.array) {
2037
+ if (r.length !== e.length)
2038
+ return { valid: !1 };
2039
+ const n = [];
2040
+ for (let a = 0; a < r.length; a++) {
2041
+ const i = r[a], o = e[a], l = Te(i, o);
2042
+ if (!l.valid)
2043
+ return { valid: !1 };
2044
+ n.push(l.data);
2045
+ }
2046
+ return { valid: !0, data: n };
2047
+ } else return t === f.date && s === f.date && +r == +e ? { valid: !0, data: r } : { valid: !1 };
2048
+ }
2049
+ class te extends _ {
2050
+ _parse(e) {
2051
+ const { status: t, ctx: s } = this._processInputParams(e), n = (a, i) => {
2052
+ if (be(a) || be(i))
2053
+ return v;
2054
+ const o = Te(a.value, i.value);
2055
+ return o.valid ? ((we(a) || we(i)) && t.dirty(), { status: t.value, value: o.data }) : (u(s, {
2056
+ code: d.invalid_intersection_types
2057
+ }), v);
2058
+ };
2059
+ return s.common.async ? Promise.all([
2060
+ this._def.left._parseAsync({
2061
+ data: s.data,
2062
+ path: s.path,
2063
+ parent: s
2064
+ }),
2065
+ this._def.right._parseAsync({
2066
+ data: s.data,
2067
+ path: s.path,
2068
+ parent: s
2069
+ })
2070
+ ]).then(([a, i]) => n(a, i)) : n(this._def.left._parseSync({
2071
+ data: s.data,
2072
+ path: s.path,
2073
+ parent: s
2074
+ }), this._def.right._parseSync({
2075
+ data: s.data,
2076
+ path: s.path,
2077
+ parent: s
2078
+ }));
2079
+ }
2080
+ }
2081
+ te.create = (r, e, t) => new te({
2082
+ left: r,
2083
+ right: e,
2084
+ typeName: m.ZodIntersection,
2085
+ ...y(t)
2086
+ });
2087
+ class N extends _ {
2088
+ _parse(e) {
2089
+ const { status: t, ctx: s } = this._processInputParams(e);
2090
+ if (s.parsedType !== f.array)
2091
+ return u(s, {
2092
+ code: d.invalid_type,
2093
+ expected: f.array,
2094
+ received: s.parsedType
2095
+ }), v;
2096
+ if (s.data.length < this._def.items.length)
2097
+ return u(s, {
2098
+ code: d.too_small,
2099
+ minimum: this._def.items.length,
2100
+ inclusive: !0,
2101
+ exact: !1,
2102
+ type: "array"
2103
+ }), v;
2104
+ !this._def.rest && s.data.length > this._def.items.length && (u(s, {
2105
+ code: d.too_big,
2106
+ maximum: this._def.items.length,
2107
+ inclusive: !0,
2108
+ exact: !1,
2109
+ type: "array"
2110
+ }), t.dirty());
2111
+ const a = [...s.data].map((i, o) => {
2112
+ const l = this._def.items[o] || this._def.rest;
2113
+ return l ? l._parse(new O(s, i, s.path, o)) : null;
2114
+ }).filter((i) => !!i);
2115
+ return s.common.async ? Promise.all(a).then((i) => k.mergeArray(t, i)) : k.mergeArray(t, a);
2116
+ }
2117
+ get items() {
2118
+ return this._def.items;
2119
+ }
2120
+ rest(e) {
2121
+ return new N({
2122
+ ...this._def,
2123
+ rest: e
2124
+ });
2125
+ }
2126
+ }
2127
+ N.create = (r, e) => {
2128
+ if (!Array.isArray(r))
2129
+ throw new Error("You must pass an array of schemas to z.tuple([ ... ])");
2130
+ return new N({
2131
+ items: r,
2132
+ typeName: m.ZodTuple,
2133
+ rest: null,
2134
+ ...y(e)
2135
+ });
2136
+ };
2137
+ class re extends _ {
2138
+ get keySchema() {
2139
+ return this._def.keyType;
2140
+ }
2141
+ get valueSchema() {
2142
+ return this._def.valueType;
2143
+ }
2144
+ _parse(e) {
2145
+ const { status: t, ctx: s } = this._processInputParams(e);
2146
+ if (s.parsedType !== f.object)
2147
+ return u(s, {
2148
+ code: d.invalid_type,
2149
+ expected: f.object,
2150
+ received: s.parsedType
2151
+ }), v;
2152
+ const n = [], a = this._def.keyType, i = this._def.valueType;
2153
+ for (const o in s.data)
2154
+ n.push({
2155
+ key: a._parse(new O(s, o, s.path, o)),
2156
+ value: i._parse(new O(s, s.data[o], s.path, o)),
2157
+ alwaysSet: o in s.data
2158
+ });
2159
+ return s.common.async ? k.mergeObjectAsync(t, n) : k.mergeObjectSync(t, n);
2160
+ }
2161
+ get element() {
2162
+ return this._def.valueType;
2163
+ }
2164
+ static create(e, t, s) {
2165
+ return t instanceof _ ? new re({
2166
+ keyType: e,
2167
+ valueType: t,
2168
+ typeName: m.ZodRecord,
2169
+ ...y(s)
2170
+ }) : new re({
2171
+ keyType: Z.create(),
2172
+ valueType: e,
2173
+ typeName: m.ZodRecord,
2174
+ ...y(t)
2175
+ });
2176
+ }
2177
+ }
2178
+ class ve extends _ {
2179
+ get keySchema() {
2180
+ return this._def.keyType;
2181
+ }
2182
+ get valueSchema() {
2183
+ return this._def.valueType;
2184
+ }
2185
+ _parse(e) {
2186
+ const { status: t, ctx: s } = this._processInputParams(e);
2187
+ if (s.parsedType !== f.map)
2188
+ return u(s, {
2189
+ code: d.invalid_type,
2190
+ expected: f.map,
2191
+ received: s.parsedType
2192
+ }), v;
2193
+ const n = this._def.keyType, a = this._def.valueType, i = [...s.data.entries()].map(([o, l], c) => ({
2194
+ key: n._parse(new O(s, o, s.path, [c, "key"])),
2195
+ value: a._parse(new O(s, l, s.path, [c, "value"]))
2196
+ }));
2197
+ if (s.common.async) {
2198
+ const o = /* @__PURE__ */ new Map();
2199
+ return Promise.resolve().then(async () => {
2200
+ for (const l of i) {
2201
+ const c = await l.key, p = await l.value;
2202
+ if (c.status === "aborted" || p.status === "aborted")
2203
+ return v;
2204
+ (c.status === "dirty" || p.status === "dirty") && t.dirty(), o.set(c.value, p.value);
2205
+ }
2206
+ return { status: t.value, value: o };
2207
+ });
2208
+ } else {
2209
+ const o = /* @__PURE__ */ new Map();
2210
+ for (const l of i) {
2211
+ const c = l.key, p = l.value;
2212
+ if (c.status === "aborted" || p.status === "aborted")
2213
+ return v;
2214
+ (c.status === "dirty" || p.status === "dirty") && t.dirty(), o.set(c.value, p.value);
2215
+ }
2216
+ return { status: t.value, value: o };
2217
+ }
2218
+ }
2219
+ }
2220
+ ve.create = (r, e, t) => new ve({
2221
+ valueType: e,
2222
+ keyType: r,
2223
+ typeName: m.ZodMap,
2224
+ ...y(t)
2225
+ });
2226
+ class L extends _ {
2227
+ _parse(e) {
2228
+ const { status: t, ctx: s } = this._processInputParams(e);
2229
+ if (s.parsedType !== f.set)
2230
+ return u(s, {
2231
+ code: d.invalid_type,
2232
+ expected: f.set,
2233
+ received: s.parsedType
2234
+ }), v;
2235
+ const n = this._def;
2236
+ n.minSize !== null && s.data.size < n.minSize.value && (u(s, {
2237
+ code: d.too_small,
2238
+ minimum: n.minSize.value,
2239
+ type: "set",
2240
+ inclusive: !0,
2241
+ exact: !1,
2242
+ message: n.minSize.message
2243
+ }), t.dirty()), n.maxSize !== null && s.data.size > n.maxSize.value && (u(s, {
2244
+ code: d.too_big,
2245
+ maximum: n.maxSize.value,
2246
+ type: "set",
2247
+ inclusive: !0,
2248
+ exact: !1,
2249
+ message: n.maxSize.message
2250
+ }), t.dirty());
2251
+ const a = this._def.valueType;
2252
+ function i(l) {
2253
+ const c = /* @__PURE__ */ new Set();
2254
+ for (const p of l) {
2255
+ if (p.status === "aborted")
2256
+ return v;
2257
+ p.status === "dirty" && t.dirty(), c.add(p.value);
2258
+ }
2259
+ return { status: t.value, value: c };
2260
+ }
2261
+ const o = [...s.data.values()].map((l, c) => a._parse(new O(s, l, s.path, c)));
2262
+ return s.common.async ? Promise.all(o).then((l) => i(l)) : i(o);
2263
+ }
2264
+ min(e, t) {
2265
+ return new L({
2266
+ ...this._def,
2267
+ minSize: { value: e, message: h.toString(t) }
2268
+ });
2269
+ }
2270
+ max(e, t) {
2271
+ return new L({
2272
+ ...this._def,
2273
+ maxSize: { value: e, message: h.toString(t) }
2274
+ });
2275
+ }
2276
+ size(e, t) {
2277
+ return this.min(e, t).max(e, t);
2278
+ }
2279
+ nonempty(e) {
2280
+ return this.min(1, e);
2281
+ }
2282
+ }
2283
+ L.create = (r, e) => new L({
2284
+ valueType: r,
2285
+ minSize: null,
2286
+ maxSize: null,
2287
+ typeName: m.ZodSet,
2288
+ ...y(e)
2289
+ });
2290
+ class F extends _ {
2291
+ constructor() {
2292
+ super(...arguments), this.validate = this.implement;
2293
+ }
2294
+ _parse(e) {
2295
+ const { ctx: t } = this._processInputParams(e);
2296
+ if (t.parsedType !== f.function)
2297
+ return u(t, {
2298
+ code: d.invalid_type,
2299
+ expected: f.function,
2300
+ received: t.parsedType
2301
+ }), v;
2302
+ function s(o, l) {
2303
+ return fe({
2304
+ data: o,
2305
+ path: t.path,
2306
+ errorMaps: [
2307
+ t.common.contextualErrorMap,
2308
+ t.schemaErrorMap,
2309
+ le(),
2310
+ W
2311
+ ].filter((c) => !!c),
2312
+ issueData: {
2313
+ code: d.invalid_arguments,
2314
+ argumentsError: l
2315
+ }
2316
+ });
2317
+ }
2318
+ function n(o, l) {
2319
+ return fe({
2320
+ data: o,
2321
+ path: t.path,
2322
+ errorMaps: [
2323
+ t.common.contextualErrorMap,
2324
+ t.schemaErrorMap,
2325
+ le(),
2326
+ W
2327
+ ].filter((c) => !!c),
2328
+ issueData: {
2329
+ code: d.invalid_return_type,
2330
+ returnTypeError: l
2331
+ }
2332
+ });
2333
+ }
2334
+ const a = { errorMap: t.common.contextualErrorMap }, i = t.data;
2335
+ if (this._def.returns instanceof J) {
2336
+ const o = this;
2337
+ return w(async function(...l) {
2338
+ const c = new T([]), p = await o._def.args.parseAsync(l, a).catch((ge) => {
2339
+ throw c.addIssue(s(l, ge)), c;
2340
+ }), b = await Reflect.apply(i, this, p);
2341
+ return await o._def.returns._def.type.parseAsync(b, a).catch((ge) => {
2342
+ throw c.addIssue(n(b, ge)), c;
2343
+ });
2344
+ });
2345
+ } else {
2346
+ const o = this;
2347
+ return w(function(...l) {
2348
+ const c = o._def.args.safeParse(l, a);
2349
+ if (!c.success)
2350
+ throw new T([s(l, c.error)]);
2351
+ const p = Reflect.apply(i, this, c.data), b = o._def.returns.safeParse(p, a);
2352
+ if (!b.success)
2353
+ throw new T([n(p, b.error)]);
2354
+ return b.data;
2355
+ });
2356
+ }
2357
+ }
2358
+ parameters() {
2359
+ return this._def.args;
2360
+ }
2361
+ returnType() {
2362
+ return this._def.returns;
2363
+ }
2364
+ args(...e) {
2365
+ return new F({
2366
+ ...this._def,
2367
+ args: N.create(e).rest(V.create())
2368
+ });
2369
+ }
2370
+ returns(e) {
2371
+ return new F({
2372
+ ...this._def,
2373
+ returns: e
2374
+ });
2375
+ }
2376
+ implement(e) {
2377
+ return this.parse(e);
2378
+ }
2379
+ strictImplement(e) {
2380
+ return this.parse(e);
2381
+ }
2382
+ static create(e, t, s) {
2383
+ return new F({
2384
+ args: e || N.create([]).rest(V.create()),
2385
+ returns: t || V.create(),
2386
+ typeName: m.ZodFunction,
2387
+ ...y(s)
2388
+ });
2389
+ }
2390
+ }
2391
+ class se extends _ {
2392
+ get schema() {
2393
+ return this._def.getter();
2394
+ }
2395
+ _parse(e) {
2396
+ const { ctx: t } = this._processInputParams(e);
2397
+ return this._def.getter()._parse({ data: t.data, path: t.path, parent: t });
2398
+ }
2399
+ }
2400
+ se.create = (r, e) => new se({
2401
+ getter: r,
2402
+ typeName: m.ZodLazy,
2403
+ ...y(e)
2404
+ });
2405
+ class ne extends _ {
2406
+ _parse(e) {
2407
+ if (e.data !== this._def.value) {
2408
+ const t = this._getOrReturnCtx(e);
2409
+ return u(t, {
2410
+ received: t.data,
2411
+ code: d.invalid_literal,
2412
+ expected: this._def.value
2413
+ }), v;
2414
+ }
2415
+ return { status: "valid", value: e.data };
2416
+ }
2417
+ get value() {
2418
+ return this._def.value;
2419
+ }
2420
+ }
2421
+ ne.create = (r, e) => new ne({
2422
+ value: r,
2423
+ typeName: m.ZodLiteral,
2424
+ ...y(e)
2425
+ });
2426
+ function je(r, e) {
2427
+ return new $({
2428
+ values: r,
2429
+ typeName: m.ZodEnum,
2430
+ ...y(e)
2431
+ });
2432
+ }
2433
+ class $ extends _ {
2434
+ constructor() {
2435
+ super(...arguments), Y.set(this, void 0);
2436
+ }
2437
+ _parse(e) {
2438
+ if (typeof e.data != "string") {
2439
+ const t = this._getOrReturnCtx(e), s = this._def.values;
2440
+ return u(t, {
2441
+ expected: g.joinValues(s),
2442
+ received: t.parsedType,
2443
+ code: d.invalid_type
2444
+ }), v;
2445
+ }
2446
+ if (he(this, Y) || Ne(this, Y, new Set(this._def.values)), !he(this, Y).has(e.data)) {
2447
+ const t = this._getOrReturnCtx(e), s = this._def.values;
2448
+ return u(t, {
2449
+ received: t.data,
2450
+ code: d.invalid_enum_value,
2451
+ options: s
2452
+ }), v;
2453
+ }
2454
+ return w(e.data);
2455
+ }
2456
+ get options() {
2457
+ return this._def.values;
2458
+ }
2459
+ get enum() {
2460
+ const e = {};
2461
+ for (const t of this._def.values)
2462
+ e[t] = t;
2463
+ return e;
2464
+ }
2465
+ get Values() {
2466
+ const e = {};
2467
+ for (const t of this._def.values)
2468
+ e[t] = t;
2469
+ return e;
2470
+ }
2471
+ get Enum() {
2472
+ const e = {};
2473
+ for (const t of this._def.values)
2474
+ e[t] = t;
2475
+ return e;
2476
+ }
2477
+ extract(e, t = this._def) {
2478
+ return $.create(e, {
2479
+ ...this._def,
2480
+ ...t
2481
+ });
2482
+ }
2483
+ exclude(e, t = this._def) {
2484
+ return $.create(this.options.filter((s) => !e.includes(s)), {
2485
+ ...this._def,
2486
+ ...t
2487
+ });
2488
+ }
2489
+ }
2490
+ Y = /* @__PURE__ */ new WeakMap();
2491
+ $.create = je;
2492
+ class ae extends _ {
2493
+ constructor() {
2494
+ super(...arguments), H.set(this, void 0);
2495
+ }
2496
+ _parse(e) {
2497
+ const t = g.getValidEnumValues(this._def.values), s = this._getOrReturnCtx(e);
2498
+ if (s.parsedType !== f.string && s.parsedType !== f.number) {
2499
+ const n = g.objectValues(t);
2500
+ return u(s, {
2501
+ expected: g.joinValues(n),
2502
+ received: s.parsedType,
2503
+ code: d.invalid_type
2504
+ }), v;
2505
+ }
2506
+ if (he(this, H) || Ne(this, H, new Set(g.getValidEnumValues(this._def.values))), !he(this, H).has(e.data)) {
2507
+ const n = g.objectValues(t);
2508
+ return u(s, {
2509
+ received: s.data,
2510
+ code: d.invalid_enum_value,
2511
+ options: n
2512
+ }), v;
2513
+ }
2514
+ return w(e.data);
2515
+ }
2516
+ get enum() {
2517
+ return this._def.values;
2518
+ }
2519
+ }
2520
+ H = /* @__PURE__ */ new WeakMap();
2521
+ ae.create = (r, e) => new ae({
2522
+ values: r,
2523
+ typeName: m.ZodNativeEnum,
2524
+ ...y(e)
2525
+ });
2526
+ class J extends _ {
2527
+ unwrap() {
2528
+ return this._def.type;
2529
+ }
2530
+ _parse(e) {
2531
+ const { ctx: t } = this._processInputParams(e);
2532
+ if (t.parsedType !== f.promise && t.common.async === !1)
2533
+ return u(t, {
2534
+ code: d.invalid_type,
2535
+ expected: f.promise,
2536
+ received: t.parsedType
2537
+ }), v;
2538
+ const s = t.parsedType === f.promise ? t.data : Promise.resolve(t.data);
2539
+ return w(s.then((n) => this._def.type.parseAsync(n, {
2540
+ path: t.path,
2541
+ errorMap: t.common.contextualErrorMap
2542
+ })));
2543
+ }
2544
+ }
2545
+ J.create = (r, e) => new J({
2546
+ type: r,
2547
+ typeName: m.ZodPromise,
2548
+ ...y(e)
2549
+ });
2550
+ class S extends _ {
2551
+ innerType() {
2552
+ return this._def.schema;
2553
+ }
2554
+ sourceType() {
2555
+ return this._def.schema._def.typeName === m.ZodEffects ? this._def.schema.sourceType() : this._def.schema;
2556
+ }
2557
+ _parse(e) {
2558
+ const { status: t, ctx: s } = this._processInputParams(e), n = this._def.effect || null, a = {
2559
+ addIssue: (i) => {
2560
+ u(s, i), i.fatal ? t.abort() : t.dirty();
2561
+ },
2562
+ get path() {
2563
+ return s.path;
2564
+ }
2565
+ };
2566
+ if (a.addIssue = a.addIssue.bind(a), n.type === "preprocess") {
2567
+ const i = n.transform(s.data, a);
2568
+ if (s.common.async)
2569
+ return Promise.resolve(i).then(async (o) => {
2570
+ if (t.value === "aborted")
2571
+ return v;
2572
+ const l = await this._def.schema._parseAsync({
2573
+ data: o,
2574
+ path: s.path,
2575
+ parent: s
2576
+ });
2577
+ return l.status === "aborted" ? v : l.status === "dirty" || t.value === "dirty" ? B(l.value) : l;
2578
+ });
2579
+ {
2580
+ if (t.value === "aborted")
2581
+ return v;
2582
+ const o = this._def.schema._parseSync({
2583
+ data: i,
2584
+ path: s.path,
2585
+ parent: s
2586
+ });
2587
+ return o.status === "aborted" ? v : o.status === "dirty" || t.value === "dirty" ? B(o.value) : o;
2588
+ }
2589
+ }
2590
+ if (n.type === "refinement") {
2591
+ const i = (o) => {
2592
+ const l = n.refinement(o, a);
2593
+ if (s.common.async)
2594
+ return Promise.resolve(l);
2595
+ if (l instanceof Promise)
2596
+ throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");
2597
+ return o;
2598
+ };
2599
+ if (s.common.async === !1) {
2600
+ const o = this._def.schema._parseSync({
2601
+ data: s.data,
2602
+ path: s.path,
2603
+ parent: s
2604
+ });
2605
+ return o.status === "aborted" ? v : (o.status === "dirty" && t.dirty(), i(o.value), { status: t.value, value: o.value });
2606
+ } else
2607
+ return this._def.schema._parseAsync({ data: s.data, path: s.path, parent: s }).then((o) => o.status === "aborted" ? v : (o.status === "dirty" && t.dirty(), i(o.value).then(() => ({ status: t.value, value: o.value }))));
2608
+ }
2609
+ if (n.type === "transform")
2610
+ if (s.common.async === !1) {
2611
+ const i = this._def.schema._parseSync({
2612
+ data: s.data,
2613
+ path: s.path,
2614
+ parent: s
2615
+ });
2616
+ if (!z(i))
2617
+ return i;
2618
+ const o = n.transform(i.value, a);
2619
+ if (o instanceof Promise)
2620
+ throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");
2621
+ return { status: t.value, value: o };
2622
+ } else
2623
+ return this._def.schema._parseAsync({ data: s.data, path: s.path, parent: s }).then((i) => z(i) ? Promise.resolve(n.transform(i.value, a)).then((o) => ({ status: t.value, value: o })) : i);
2624
+ g.assertNever(n);
2625
+ }
2626
+ }
2627
+ S.create = (r, e, t) => new S({
2628
+ schema: r,
2629
+ typeName: m.ZodEffects,
2630
+ effect: e,
2631
+ ...y(t)
2632
+ });
2633
+ S.createWithPreprocess = (r, e, t) => new S({
2634
+ schema: e,
2635
+ effect: { type: "preprocess", transform: r },
2636
+ typeName: m.ZodEffects,
2637
+ ...y(t)
2638
+ });
2639
+ class A extends _ {
2640
+ _parse(e) {
2641
+ return this._getType(e) === f.undefined ? w(void 0) : this._def.innerType._parse(e);
2642
+ }
2643
+ unwrap() {
2644
+ return this._def.innerType;
2645
+ }
2646
+ }
2647
+ A.create = (r, e) => new A({
2648
+ innerType: r,
2649
+ typeName: m.ZodOptional,
2650
+ ...y(e)
2651
+ });
2652
+ class P extends _ {
2653
+ _parse(e) {
2654
+ return this._getType(e) === f.null ? w(null) : this._def.innerType._parse(e);
2655
+ }
2656
+ unwrap() {
2657
+ return this._def.innerType;
2658
+ }
2659
+ }
2660
+ P.create = (r, e) => new P({
2661
+ innerType: r,
2662
+ typeName: m.ZodNullable,
2663
+ ...y(e)
2664
+ });
2665
+ class ie extends _ {
2666
+ _parse(e) {
2667
+ const { ctx: t } = this._processInputParams(e);
2668
+ let s = t.data;
2669
+ return t.parsedType === f.undefined && (s = this._def.defaultValue()), this._def.innerType._parse({
2670
+ data: s,
2671
+ path: t.path,
2672
+ parent: t
2673
+ });
2674
+ }
2675
+ removeDefault() {
2676
+ return this._def.innerType;
2677
+ }
2678
+ }
2679
+ ie.create = (r, e) => new ie({
2680
+ innerType: r,
2681
+ typeName: m.ZodDefault,
2682
+ defaultValue: typeof e.default == "function" ? e.default : () => e.default,
2683
+ ...y(e)
2684
+ });
2685
+ class oe extends _ {
2686
+ _parse(e) {
2687
+ const { ctx: t } = this._processInputParams(e), s = {
2688
+ ...t,
2689
+ common: {
2690
+ ...t.common,
2691
+ issues: []
2692
+ }
2693
+ }, n = this._def.innerType._parse({
2694
+ data: s.data,
2695
+ path: s.path,
2696
+ parent: {
2697
+ ...s
2698
+ }
2699
+ });
2700
+ return G(n) ? n.then((a) => ({
2701
+ status: "valid",
2702
+ value: a.status === "valid" ? a.value : this._def.catchValue({
2703
+ get error() {
2704
+ return new T(s.common.issues);
2705
+ },
2706
+ input: s.data
2707
+ })
2708
+ })) : {
2709
+ status: "valid",
2710
+ value: n.status === "valid" ? n.value : this._def.catchValue({
2711
+ get error() {
2712
+ return new T(s.common.issues);
2713
+ },
2714
+ input: s.data
2715
+ })
2716
+ };
2717
+ }
2718
+ removeCatch() {
2719
+ return this._def.innerType;
2720
+ }
2721
+ }
2722
+ oe.create = (r, e) => new oe({
2723
+ innerType: r,
2724
+ typeName: m.ZodCatch,
2725
+ catchValue: typeof e.catch == "function" ? e.catch : () => e.catch,
2726
+ ...y(e)
2727
+ });
2728
+ class ye extends _ {
2729
+ _parse(e) {
2730
+ if (this._getType(e) !== f.nan) {
2731
+ const s = this._getOrReturnCtx(e);
2732
+ return u(s, {
2733
+ code: d.invalid_type,
2734
+ expected: f.nan,
2735
+ received: s.parsedType
2736
+ }), v;
2737
+ }
2738
+ return { status: "valid", value: e.data };
2739
+ }
2740
+ }
2741
+ ye.create = (r) => new ye({
2742
+ typeName: m.ZodNaN,
2743
+ ...y(r)
2744
+ });
2745
+ const ct = Symbol("zod_brand");
2746
+ class Ze extends _ {
2747
+ _parse(e) {
2748
+ const { ctx: t } = this._processInputParams(e), s = t.data;
2749
+ return this._def.type._parse({
2750
+ data: s,
2751
+ path: t.path,
2752
+ parent: t
2753
+ });
2754
+ }
2755
+ unwrap() {
2756
+ return this._def.type;
2757
+ }
2758
+ }
2759
+ class ce extends _ {
2760
+ _parse(e) {
2761
+ const { status: t, ctx: s } = this._processInputParams(e);
2762
+ if (s.common.async)
2763
+ return (async () => {
2764
+ const a = await this._def.in._parseAsync({
2765
+ data: s.data,
2766
+ path: s.path,
2767
+ parent: s
2768
+ });
2769
+ return a.status === "aborted" ? v : a.status === "dirty" ? (t.dirty(), B(a.value)) : this._def.out._parseAsync({
2770
+ data: a.value,
2771
+ path: s.path,
2772
+ parent: s
2773
+ });
2774
+ })();
2775
+ {
2776
+ const n = this._def.in._parseSync({
2777
+ data: s.data,
2778
+ path: s.path,
2779
+ parent: s
2780
+ });
2781
+ return n.status === "aborted" ? v : n.status === "dirty" ? (t.dirty(), {
2782
+ status: "dirty",
2783
+ value: n.value
2784
+ }) : this._def.out._parseSync({
2785
+ data: n.value,
2786
+ path: s.path,
2787
+ parent: s
2788
+ });
2789
+ }
2790
+ }
2791
+ static create(e, t) {
2792
+ return new ce({
2793
+ in: e,
2794
+ out: t,
2795
+ typeName: m.ZodPipeline
2796
+ });
2797
+ }
2798
+ }
2799
+ class de extends _ {
2800
+ _parse(e) {
2801
+ const t = this._def.innerType._parse(e), s = (n) => (z(n) && (n.value = Object.freeze(n.value)), n);
2802
+ return G(t) ? t.then((n) => s(n)) : s(t);
2803
+ }
2804
+ unwrap() {
2805
+ return this._def.innerType;
2806
+ }
2807
+ }
2808
+ de.create = (r, e) => new de({
2809
+ innerType: r,
2810
+ typeName: m.ZodReadonly,
2811
+ ...y(e)
2812
+ });
2813
+ function Se(r, e) {
2814
+ const t = typeof r == "function" ? r(e) : typeof r == "string" ? { message: r } : r;
2815
+ return typeof t == "string" ? { message: t } : t;
2816
+ }
2817
+ function Me(r, e = {}, t) {
2818
+ return r ? q.create().superRefine((s, n) => {
2819
+ var a, i;
2820
+ const o = r(s);
2821
+ if (o instanceof Promise)
2822
+ return o.then((l) => {
2823
+ var c, p;
2824
+ if (!l) {
2825
+ const b = Se(e, s), ue = (p = (c = b.fatal) !== null && c !== void 0 ? c : t) !== null && p !== void 0 ? p : !0;
2826
+ n.addIssue({ code: "custom", ...b, fatal: ue });
2827
+ }
2828
+ });
2829
+ if (!o) {
2830
+ const l = Se(e, s), c = (i = (a = l.fatal) !== null && a !== void 0 ? a : t) !== null && i !== void 0 ? i : !0;
2831
+ n.addIssue({ code: "custom", ...l, fatal: c });
2832
+ }
2833
+ }) : q.create();
2834
+ }
2835
+ const ut = {
2836
+ object: x.lazycreate
2837
+ };
2838
+ var m;
2839
+ (function(r) {
2840
+ r.ZodString = "ZodString", r.ZodNumber = "ZodNumber", r.ZodNaN = "ZodNaN", r.ZodBigInt = "ZodBigInt", r.ZodBoolean = "ZodBoolean", r.ZodDate = "ZodDate", r.ZodSymbol = "ZodSymbol", r.ZodUndefined = "ZodUndefined", r.ZodNull = "ZodNull", r.ZodAny = "ZodAny", r.ZodUnknown = "ZodUnknown", r.ZodNever = "ZodNever", r.ZodVoid = "ZodVoid", r.ZodArray = "ZodArray", r.ZodObject = "ZodObject", r.ZodUnion = "ZodUnion", r.ZodDiscriminatedUnion = "ZodDiscriminatedUnion", r.ZodIntersection = "ZodIntersection", r.ZodTuple = "ZodTuple", r.ZodRecord = "ZodRecord", r.ZodMap = "ZodMap", r.ZodSet = "ZodSet", r.ZodFunction = "ZodFunction", r.ZodLazy = "ZodLazy", r.ZodLiteral = "ZodLiteral", r.ZodEnum = "ZodEnum", r.ZodEffects = "ZodEffects", r.ZodNativeEnum = "ZodNativeEnum", r.ZodOptional = "ZodOptional", r.ZodNullable = "ZodNullable", r.ZodDefault = "ZodDefault", r.ZodCatch = "ZodCatch", r.ZodPromise = "ZodPromise", r.ZodBranded = "ZodBranded", r.ZodPipeline = "ZodPipeline", r.ZodReadonly = "ZodReadonly";
2841
+ })(m || (m = {}));
2842
+ const lt = (r, e = {
2843
+ message: `Input not instance of ${r.name}`
2844
+ }) => Me((t) => t instanceof r, e), $e = Z.create, Pe = j.create, ft = ye.create, ht = M.create, Ve = X.create, pt = D.create, mt = pe.create, vt = Q.create, yt = K.create, _t = q.create, gt = V.create, xt = I.create, kt = me.create, bt = C.create, wt = x.create, Tt = x.strictCreate, Zt = ee.create, Ct = _e.create, St = te.create, At = N.create, Ot = re.create, Nt = ve.create, Et = L.create, Rt = F.create, It = se.create, jt = ne.create, Mt = $.create, $t = ae.create, Pt = J.create, Ae = S.create, Vt = A.create, zt = P.create, Dt = S.createWithPreprocess, Lt = ce.create, Ut = () => $e().optional(), Bt = () => Pe().optional(), Ft = () => Ve().optional(), Wt = {
2845
+ string: (r) => Z.create({ ...r, coerce: !0 }),
2846
+ number: (r) => j.create({ ...r, coerce: !0 }),
2847
+ boolean: (r) => X.create({
2848
+ ...r,
2849
+ coerce: !0
2850
+ }),
2851
+ bigint: (r) => M.create({ ...r, coerce: !0 }),
2852
+ date: (r) => D.create({ ...r, coerce: !0 })
2853
+ }, qt = v;
2854
+ var Jt = /* @__PURE__ */ Object.freeze({
2855
+ __proto__: null,
2856
+ defaultErrorMap: W,
2857
+ setErrorMap: De,
2858
+ getErrorMap: le,
2859
+ makeIssue: fe,
2860
+ EMPTY_PATH: Le,
2861
+ addIssueToContext: u,
2862
+ ParseStatus: k,
2863
+ INVALID: v,
2864
+ DIRTY: B,
2865
+ OK: w,
2866
+ isAborted: be,
2867
+ isDirty: we,
2868
+ isValid: z,
2869
+ isAsync: G,
2870
+ get util() {
2871
+ return g;
2872
+ },
2873
+ get objectUtil() {
2874
+ return ke;
2875
+ },
2876
+ ZodParsedType: f,
2877
+ getParsedType: R,
2878
+ ZodType: _,
2879
+ datetimeRegex: Ie,
2880
+ ZodString: Z,
2881
+ ZodNumber: j,
2882
+ ZodBigInt: M,
2883
+ ZodBoolean: X,
2884
+ ZodDate: D,
2885
+ ZodSymbol: pe,
2886
+ ZodUndefined: Q,
2887
+ ZodNull: K,
2888
+ ZodAny: q,
2889
+ ZodUnknown: V,
2890
+ ZodNever: I,
2891
+ ZodVoid: me,
2892
+ ZodArray: C,
2893
+ ZodObject: x,
2894
+ ZodUnion: ee,
2895
+ ZodDiscriminatedUnion: _e,
2896
+ ZodIntersection: te,
2897
+ ZodTuple: N,
2898
+ ZodRecord: re,
2899
+ ZodMap: ve,
2900
+ ZodSet: L,
2901
+ ZodFunction: F,
2902
+ ZodLazy: se,
2903
+ ZodLiteral: ne,
2904
+ ZodEnum: $,
2905
+ ZodNativeEnum: ae,
2906
+ ZodPromise: J,
2907
+ ZodEffects: S,
2908
+ ZodTransformer: S,
2909
+ ZodOptional: A,
2910
+ ZodNullable: P,
2911
+ ZodDefault: ie,
2912
+ ZodCatch: oe,
2913
+ ZodNaN: ye,
2914
+ BRAND: ct,
2915
+ ZodBranded: Ze,
2916
+ ZodPipeline: ce,
2917
+ ZodReadonly: de,
2918
+ custom: Me,
2919
+ Schema: _,
2920
+ ZodSchema: _,
2921
+ late: ut,
2922
+ get ZodFirstPartyTypeKind() {
2923
+ return m;
2924
+ },
2925
+ coerce: Wt,
2926
+ any: _t,
2927
+ array: bt,
2928
+ bigint: ht,
2929
+ boolean: Ve,
2930
+ date: pt,
2931
+ discriminatedUnion: Ct,
2932
+ effect: Ae,
2933
+ enum: Mt,
2934
+ function: Rt,
2935
+ instanceof: lt,
2936
+ intersection: St,
2937
+ lazy: It,
2938
+ literal: jt,
2939
+ map: Nt,
2940
+ nan: ft,
2941
+ nativeEnum: $t,
2942
+ never: xt,
2943
+ null: yt,
2944
+ nullable: zt,
2945
+ number: Pe,
2946
+ object: wt,
2947
+ oboolean: Ft,
2948
+ onumber: Bt,
2949
+ optional: Vt,
2950
+ ostring: Ut,
2951
+ pipeline: Lt,
2952
+ preprocess: Dt,
2953
+ promise: Pt,
2954
+ record: Ot,
2955
+ set: Et,
2956
+ strictObject: Tt,
2957
+ string: $e,
2958
+ symbol: mt,
2959
+ transformer: Ae,
2960
+ tuple: At,
2961
+ undefined: vt,
2962
+ union: Zt,
2963
+ unknown: gt,
2964
+ void: kt,
2965
+ NEVER: qt,
2966
+ ZodIssueCode: d,
2967
+ quotelessJson: ze,
2968
+ ZodError: T
2969
+ });
2970
+ export {
2971
+ Jt as z
2972
+ };