@resconet/qp-bridge 0.0.1-alpha.5

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