@svazqz/api-contract-kit 0.1.6-alpha

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,3969 @@
1
+ function Zt(r) {
2
+ return r && r.__esModule && Object.prototype.hasOwnProperty.call(r, "default") ? r.default : r;
3
+ }
4
+ var ht = { exports: {} }, Z = ht.exports = {}, D, $;
5
+ function tt() {
6
+ throw new Error("setTimeout has not been defined");
7
+ }
8
+ function nt() {
9
+ throw new Error("clearTimeout has not been defined");
10
+ }
11
+ (function() {
12
+ try {
13
+ typeof setTimeout == "function" ? D = setTimeout : D = tt;
14
+ } catch {
15
+ D = tt;
16
+ }
17
+ try {
18
+ typeof clearTimeout == "function" ? $ = clearTimeout : $ = nt;
19
+ } catch {
20
+ $ = nt;
21
+ }
22
+ })();
23
+ function mt(r) {
24
+ if (D === setTimeout)
25
+ return setTimeout(r, 0);
26
+ if ((D === tt || !D) && setTimeout)
27
+ return D = setTimeout, setTimeout(r, 0);
28
+ try {
29
+ return D(r, 0);
30
+ } catch {
31
+ try {
32
+ return D.call(null, r, 0);
33
+ } catch {
34
+ return D.call(this, r, 0);
35
+ }
36
+ }
37
+ }
38
+ function Ct(r) {
39
+ if ($ === clearTimeout)
40
+ return clearTimeout(r);
41
+ if (($ === nt || !$) && clearTimeout)
42
+ return $ = clearTimeout, clearTimeout(r);
43
+ try {
44
+ return $(r);
45
+ } catch {
46
+ try {
47
+ return $.call(null, r);
48
+ } catch {
49
+ return $.call(this, r);
50
+ }
51
+ }
52
+ }
53
+ var U = [], ce = !1, K, Me = -1;
54
+ function It() {
55
+ !ce || !K || (ce = !1, K.length ? U = K.concat(U) : Me = -1, U.length && vt());
56
+ }
57
+ function vt() {
58
+ if (!ce) {
59
+ var r = mt(It);
60
+ ce = !0;
61
+ for (var e = U.length; e; ) {
62
+ for (K = U, U = []; ++Me < e; )
63
+ K && K[Me].run();
64
+ Me = -1, e = U.length;
65
+ }
66
+ K = null, ce = !1, Ct(r);
67
+ }
68
+ }
69
+ Z.nextTick = function(r) {
70
+ var e = new Array(arguments.length - 1);
71
+ if (arguments.length > 1)
72
+ for (var t = 1; t < arguments.length; t++)
73
+ e[t - 1] = arguments[t];
74
+ U.push(new gt(r, e)), U.length === 1 && !ce && mt(vt);
75
+ };
76
+ function gt(r, e) {
77
+ this.fun = r, this.array = e;
78
+ }
79
+ gt.prototype.run = function() {
80
+ this.fun.apply(null, this.array);
81
+ };
82
+ Z.title = "browser";
83
+ Z.browser = !0;
84
+ Z.env = {};
85
+ Z.argv = [];
86
+ Z.version = "";
87
+ Z.versions = {};
88
+ function W() {
89
+ }
90
+ Z.on = W;
91
+ Z.addListener = W;
92
+ Z.once = W;
93
+ Z.off = W;
94
+ Z.removeListener = W;
95
+ Z.removeAllListeners = W;
96
+ Z.emit = W;
97
+ Z.prependListener = W;
98
+ Z.prependOnceListener = W;
99
+ Z.listeners = function(r) {
100
+ return [];
101
+ };
102
+ Z.binding = function(r) {
103
+ throw new Error("process.binding is not supported");
104
+ };
105
+ Z.cwd = function() {
106
+ return "/";
107
+ };
108
+ Z.chdir = function(r) {
109
+ throw new Error("process.chdir is not supported");
110
+ };
111
+ Z.umask = function() {
112
+ return 0;
113
+ };
114
+ var Et = ht.exports;
115
+ const $e = /* @__PURE__ */ Zt(Et);
116
+ var Rt = null, ct = Rt;
117
+ function M(r) {
118
+ if (typeof r != "string")
119
+ throw new TypeError("Path must be a string. Received " + JSON.stringify(r));
120
+ }
121
+ function ut(r, e) {
122
+ for (var t = "", n = 0, s = -1, a = 0, i, o = 0; o <= r.length; ++o) {
123
+ if (o < r.length)
124
+ i = r.charCodeAt(o);
125
+ else {
126
+ if (i === 47)
127
+ break;
128
+ i = 47;
129
+ }
130
+ if (i === 47) {
131
+ if (!(s === o - 1 || a === 1)) if (s !== o - 1 && a === 2) {
132
+ if (t.length < 2 || n !== 2 || t.charCodeAt(t.length - 1) !== 46 || t.charCodeAt(t.length - 2) !== 46) {
133
+ if (t.length > 2) {
134
+ var c = t.lastIndexOf("/");
135
+ if (c !== t.length - 1) {
136
+ c === -1 ? (t = "", n = 0) : (t = t.slice(0, c), n = t.length - 1 - t.lastIndexOf("/")), s = o, a = 0;
137
+ continue;
138
+ }
139
+ } else if (t.length === 2 || t.length === 1) {
140
+ t = "", n = 0, s = o, a = 0;
141
+ continue;
142
+ }
143
+ }
144
+ e && (t.length > 0 ? t += "/.." : t = "..", n = 2);
145
+ } else
146
+ t.length > 0 ? t += "/" + r.slice(s + 1, o) : t = r.slice(s + 1, o), n = o - s - 1;
147
+ s = o, a = 0;
148
+ } else i === 46 && a !== -1 ? ++a : a = -1;
149
+ }
150
+ return t;
151
+ }
152
+ function Pt(r, e) {
153
+ var t = e.dir || e.root, n = e.base || (e.name || "") + (e.ext || "");
154
+ return t ? t === e.root ? t + n : t + r + n : n;
155
+ }
156
+ var ue = {
157
+ // path.resolve([from ...], to)
158
+ resolve: function() {
159
+ for (var e = "", t = !1, n, s = arguments.length - 1; s >= -1 && !t; s--) {
160
+ var a;
161
+ s >= 0 ? a = arguments[s] : (n === void 0 && (n = $e.cwd()), a = n), M(a), a.length !== 0 && (e = a + "/" + e, t = a.charCodeAt(0) === 47);
162
+ }
163
+ return e = ut(e, !t), t ? e.length > 0 ? "/" + e : "/" : e.length > 0 ? e : ".";
164
+ },
165
+ normalize: function(e) {
166
+ if (M(e), e.length === 0) return ".";
167
+ var t = e.charCodeAt(0) === 47, n = e.charCodeAt(e.length - 1) === 47;
168
+ return e = ut(e, !t), e.length === 0 && !t && (e = "."), e.length > 0 && n && (e += "/"), t ? "/" + e : e;
169
+ },
170
+ isAbsolute: function(e) {
171
+ return M(e), e.length > 0 && e.charCodeAt(0) === 47;
172
+ },
173
+ join: function() {
174
+ if (arguments.length === 0)
175
+ return ".";
176
+ for (var e, t = 0; t < arguments.length; ++t) {
177
+ var n = arguments[t];
178
+ M(n), n.length > 0 && (e === void 0 ? e = n : e += "/" + n);
179
+ }
180
+ return e === void 0 ? "." : ue.normalize(e);
181
+ },
182
+ relative: function(e, t) {
183
+ if (M(e), M(t), e === t || (e = ue.resolve(e), t = ue.resolve(t), e === t)) return "";
184
+ for (var n = 1; n < e.length && e.charCodeAt(n) === 47; ++n)
185
+ ;
186
+ for (var s = e.length, a = s - n, i = 1; i < t.length && t.charCodeAt(i) === 47; ++i)
187
+ ;
188
+ for (var o = t.length, c = o - i, u = a < c ? a : c, l = -1, h = 0; h <= u; ++h) {
189
+ if (h === u) {
190
+ if (c > u) {
191
+ if (t.charCodeAt(i + h) === 47)
192
+ return t.slice(i + h + 1);
193
+ if (h === 0)
194
+ return t.slice(i + h);
195
+ } else a > u && (e.charCodeAt(n + h) === 47 ? l = h : h === 0 && (l = 0));
196
+ break;
197
+ }
198
+ var j = e.charCodeAt(n + h), k = t.charCodeAt(i + h);
199
+ if (j !== k)
200
+ break;
201
+ j === 47 && (l = h);
202
+ }
203
+ var C = "";
204
+ for (h = n + l + 1; h <= s; ++h)
205
+ (h === s || e.charCodeAt(h) === 47) && (C.length === 0 ? C += ".." : C += "/..");
206
+ return C.length > 0 ? C + t.slice(i + l) : (i += l, t.charCodeAt(i) === 47 && ++i, t.slice(i));
207
+ },
208
+ _makeLong: function(e) {
209
+ return e;
210
+ },
211
+ dirname: function(e) {
212
+ if (M(e), e.length === 0) return ".";
213
+ for (var t = e.charCodeAt(0), n = t === 47, s = -1, a = !0, i = e.length - 1; i >= 1; --i)
214
+ if (t = e.charCodeAt(i), t === 47) {
215
+ if (!a) {
216
+ s = i;
217
+ break;
218
+ }
219
+ } else
220
+ a = !1;
221
+ return s === -1 ? n ? "/" : "." : n && s === 1 ? "//" : e.slice(0, s);
222
+ },
223
+ basename: function(e, t) {
224
+ if (t !== void 0 && typeof t != "string") throw new TypeError('"ext" argument must be a string');
225
+ M(e);
226
+ var n = 0, s = -1, a = !0, i;
227
+ if (t !== void 0 && t.length > 0 && t.length <= e.length) {
228
+ if (t.length === e.length && t === e) return "";
229
+ var o = t.length - 1, c = -1;
230
+ for (i = e.length - 1; i >= 0; --i) {
231
+ var u = e.charCodeAt(i);
232
+ if (u === 47) {
233
+ if (!a) {
234
+ n = i + 1;
235
+ break;
236
+ }
237
+ } else
238
+ c === -1 && (a = !1, c = i + 1), o >= 0 && (u === t.charCodeAt(o) ? --o === -1 && (s = i) : (o = -1, s = c));
239
+ }
240
+ return n === s ? s = c : s === -1 && (s = e.length), e.slice(n, s);
241
+ } else {
242
+ for (i = e.length - 1; i >= 0; --i)
243
+ if (e.charCodeAt(i) === 47) {
244
+ if (!a) {
245
+ n = i + 1;
246
+ break;
247
+ }
248
+ } else s === -1 && (a = !1, s = i + 1);
249
+ return s === -1 ? "" : e.slice(n, s);
250
+ }
251
+ },
252
+ extname: function(e) {
253
+ M(e);
254
+ for (var t = -1, n = 0, s = -1, a = !0, i = 0, o = e.length - 1; o >= 0; --o) {
255
+ var c = e.charCodeAt(o);
256
+ if (c === 47) {
257
+ if (!a) {
258
+ n = o + 1;
259
+ break;
260
+ }
261
+ continue;
262
+ }
263
+ s === -1 && (a = !1, s = o + 1), c === 46 ? t === -1 ? t = o : i !== 1 && (i = 1) : t !== -1 && (i = -1);
264
+ }
265
+ return t === -1 || s === -1 || // We saw a non-dot character immediately before the dot
266
+ i === 0 || // The (right-most) trimmed path component is exactly '..'
267
+ i === 1 && t === s - 1 && t === n + 1 ? "" : e.slice(t, s);
268
+ },
269
+ format: function(e) {
270
+ if (e === null || typeof e != "object")
271
+ throw new TypeError('The "pathObject" argument must be of type Object. Received type ' + typeof e);
272
+ return Pt("/", e);
273
+ },
274
+ parse: function(e) {
275
+ M(e);
276
+ var t = { root: "", dir: "", base: "", ext: "", name: "" };
277
+ if (e.length === 0) return t;
278
+ var n = e.charCodeAt(0), s = n === 47, a;
279
+ s ? (t.root = "/", a = 1) : a = 0;
280
+ for (var i = -1, o = 0, c = -1, u = !0, l = e.length - 1, h = 0; l >= a; --l) {
281
+ if (n = e.charCodeAt(l), n === 47) {
282
+ if (!u) {
283
+ o = l + 1;
284
+ break;
285
+ }
286
+ continue;
287
+ }
288
+ c === -1 && (u = !1, c = l + 1), n === 46 ? i === -1 ? i = l : h !== 1 && (h = 1) : i !== -1 && (h = -1);
289
+ }
290
+ return i === -1 || c === -1 || // We saw a non-dot character immediately before the dot
291
+ h === 0 || // The (right-most) trimmed path component is exactly '..'
292
+ h === 1 && i === c - 1 && i === o + 1 ? c !== -1 && (o === 0 && s ? t.base = t.name = e.slice(1, c) : t.base = t.name = e.slice(o, c)) : (o === 0 && s ? (t.name = e.slice(1, i), t.base = e.slice(1, c)) : (t.name = e.slice(o, i), t.base = e.slice(o, c)), t.ext = e.slice(i, c)), o > 0 ? t.dir = e.slice(0, o - 1) : s && (t.dir = "/"), t;
293
+ },
294
+ sep: "/",
295
+ delimiter: ":",
296
+ win32: null,
297
+ posix: null
298
+ };
299
+ ue.posix = ue;
300
+ var ze = ue, x;
301
+ (function(r) {
302
+ r.assertEqual = (s) => s;
303
+ function e(s) {
304
+ }
305
+ r.assertIs = e;
306
+ function t(s) {
307
+ throw new Error();
308
+ }
309
+ r.assertNever = t, r.arrayToEnum = (s) => {
310
+ const a = {};
311
+ for (const i of s)
312
+ a[i] = i;
313
+ return a;
314
+ }, r.getValidEnumValues = (s) => {
315
+ const a = r.objectKeys(s).filter((o) => typeof s[s[o]] != "number"), i = {};
316
+ for (const o of a)
317
+ i[o] = s[o];
318
+ return r.objectValues(i);
319
+ }, r.objectValues = (s) => r.objectKeys(s).map(function(a) {
320
+ return s[a];
321
+ }), r.objectKeys = typeof Object.keys == "function" ? (s) => Object.keys(s) : (s) => {
322
+ const a = [];
323
+ for (const i in s)
324
+ Object.prototype.hasOwnProperty.call(s, i) && a.push(i);
325
+ return a;
326
+ }, r.find = (s, a) => {
327
+ for (const i of s)
328
+ if (a(i))
329
+ return i;
330
+ }, r.isInteger = typeof Number.isInteger == "function" ? (s) => Number.isInteger(s) : (s) => typeof s == "number" && isFinite(s) && Math.floor(s) === s;
331
+ function n(s, a = " | ") {
332
+ return s.map((i) => typeof i == "string" ? `'${i}'` : i).join(a);
333
+ }
334
+ r.joinValues = n, r.jsonStringifyReplacer = (s, a) => typeof a == "bigint" ? a.toString() : a;
335
+ })(x || (x = {}));
336
+ var rt;
337
+ (function(r) {
338
+ r.mergeShapes = (e, t) => ({
339
+ ...e,
340
+ ...t
341
+ // second overwrites first
342
+ });
343
+ })(rt || (rt = {}));
344
+ const f = x.arrayToEnum([
345
+ "string",
346
+ "nan",
347
+ "number",
348
+ "integer",
349
+ "float",
350
+ "boolean",
351
+ "date",
352
+ "bigint",
353
+ "symbol",
354
+ "function",
355
+ "undefined",
356
+ "null",
357
+ "array",
358
+ "object",
359
+ "unknown",
360
+ "promise",
361
+ "void",
362
+ "never",
363
+ "map",
364
+ "set"
365
+ ]), F = (r) => {
366
+ switch (typeof r) {
367
+ case "undefined":
368
+ return f.undefined;
369
+ case "string":
370
+ return f.string;
371
+ case "number":
372
+ return isNaN(r) ? f.nan : f.number;
373
+ case "boolean":
374
+ return f.boolean;
375
+ case "function":
376
+ return f.function;
377
+ case "bigint":
378
+ return f.bigint;
379
+ case "symbol":
380
+ return f.symbol;
381
+ case "object":
382
+ 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;
383
+ default:
384
+ return f.unknown;
385
+ }
386
+ }, d = x.arrayToEnum([
387
+ "invalid_type",
388
+ "invalid_literal",
389
+ "custom",
390
+ "invalid_union",
391
+ "invalid_union_discriminator",
392
+ "invalid_enum_value",
393
+ "unrecognized_keys",
394
+ "invalid_arguments",
395
+ "invalid_return_type",
396
+ "invalid_date",
397
+ "invalid_string",
398
+ "too_small",
399
+ "too_big",
400
+ "invalid_intersection_types",
401
+ "not_multiple_of",
402
+ "not_finite"
403
+ ]), At = (r) => JSON.stringify(r, null, 2).replace(/"([^"]+)":/g, "$1:");
404
+ class A extends Error {
405
+ constructor(e) {
406
+ super(), this.issues = [], this.addIssue = (n) => {
407
+ this.issues = [...this.issues, n];
408
+ }, this.addIssues = (n = []) => {
409
+ this.issues = [...this.issues, ...n];
410
+ };
411
+ const t = new.target.prototype;
412
+ Object.setPrototypeOf ? Object.setPrototypeOf(this, t) : this.__proto__ = t, this.name = "ZodError", this.issues = e;
413
+ }
414
+ get errors() {
415
+ return this.issues;
416
+ }
417
+ format(e) {
418
+ const t = e || function(a) {
419
+ return a.message;
420
+ }, n = { _errors: [] }, s = (a) => {
421
+ for (const i of a.issues)
422
+ if (i.code === "invalid_union")
423
+ i.unionErrors.map(s);
424
+ else if (i.code === "invalid_return_type")
425
+ s(i.returnTypeError);
426
+ else if (i.code === "invalid_arguments")
427
+ s(i.argumentsError);
428
+ else if (i.path.length === 0)
429
+ n._errors.push(t(i));
430
+ else {
431
+ let o = n, c = 0;
432
+ for (; c < i.path.length; ) {
433
+ const u = i.path[c];
434
+ c === i.path.length - 1 ? (o[u] = o[u] || { _errors: [] }, o[u]._errors.push(t(i))) : o[u] = o[u] || { _errors: [] }, o = o[u], c++;
435
+ }
436
+ }
437
+ };
438
+ return s(this), n;
439
+ }
440
+ toString() {
441
+ return this.message;
442
+ }
443
+ get message() {
444
+ return JSON.stringify(this.issues, x.jsonStringifyReplacer, 2);
445
+ }
446
+ get isEmpty() {
447
+ return this.issues.length === 0;
448
+ }
449
+ flatten(e = (t) => t.message) {
450
+ const t = {}, n = [];
451
+ for (const s of this.issues)
452
+ s.path.length > 0 ? (t[s.path[0]] = t[s.path[0]] || [], t[s.path[0]].push(e(s))) : n.push(e(s));
453
+ return { formErrors: n, fieldErrors: t };
454
+ }
455
+ get formErrors() {
456
+ return this.flatten();
457
+ }
458
+ }
459
+ A.create = (r) => new A(r);
460
+ const xe = (r, e) => {
461
+ let t;
462
+ switch (r.code) {
463
+ case d.invalid_type:
464
+ r.received === f.undefined ? t = "Required" : t = `Expected ${r.expected}, received ${r.received}`;
465
+ break;
466
+ case d.invalid_literal:
467
+ t = `Invalid literal value, expected ${JSON.stringify(r.expected, x.jsonStringifyReplacer)}`;
468
+ break;
469
+ case d.unrecognized_keys:
470
+ t = `Unrecognized key(s) in object: ${x.joinValues(r.keys, ", ")}`;
471
+ break;
472
+ case d.invalid_union:
473
+ t = "Invalid input";
474
+ break;
475
+ case d.invalid_union_discriminator:
476
+ t = `Invalid discriminator value. Expected ${x.joinValues(r.options)}`;
477
+ break;
478
+ case d.invalid_enum_value:
479
+ t = `Invalid enum value. Expected ${x.joinValues(r.options)}, received '${r.received}'`;
480
+ break;
481
+ case d.invalid_arguments:
482
+ t = "Invalid function arguments";
483
+ break;
484
+ case d.invalid_return_type:
485
+ t = "Invalid function return type";
486
+ break;
487
+ case d.invalid_date:
488
+ t = "Invalid date";
489
+ break;
490
+ case d.invalid_string:
491
+ 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}"` : x.assertNever(r.validation) : r.validation !== "regex" ? t = `Invalid ${r.validation}` : t = "Invalid";
492
+ break;
493
+ case d.too_small:
494
+ 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";
495
+ break;
496
+ case d.too_big:
497
+ 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";
498
+ break;
499
+ case d.custom:
500
+ t = "Invalid input";
501
+ break;
502
+ case d.invalid_intersection_types:
503
+ t = "Intersection results could not be merged";
504
+ break;
505
+ case d.not_multiple_of:
506
+ t = `Number must be a multiple of ${r.multipleOf}`;
507
+ break;
508
+ case d.not_finite:
509
+ t = "Number must be finite";
510
+ break;
511
+ default:
512
+ t = e.defaultError, x.assertNever(r);
513
+ }
514
+ return { message: t };
515
+ };
516
+ let yt = xe;
517
+ function St(r) {
518
+ yt = r;
519
+ }
520
+ function Le() {
521
+ return yt;
522
+ }
523
+ const Ve = (r) => {
524
+ const { data: e, path: t, errorMaps: n, issueData: s } = r, a = [...t, ...s.path || []], i = {
525
+ ...s,
526
+ path: a
527
+ };
528
+ let o = "";
529
+ const c = n.filter((u) => !!u).slice().reverse();
530
+ for (const u of c)
531
+ o = u(i, { data: e, defaultError: o }).message;
532
+ return {
533
+ ...s,
534
+ path: a,
535
+ message: s.message || o
536
+ };
537
+ }, Nt = [];
538
+ function p(r, e) {
539
+ const t = Ve({
540
+ issueData: e,
541
+ data: r.data,
542
+ path: r.path,
543
+ errorMaps: [
544
+ r.common.contextualErrorMap,
545
+ r.schemaErrorMap,
546
+ Le(),
547
+ xe
548
+ // then global default map
549
+ ].filter((n) => !!n)
550
+ });
551
+ r.common.issues.push(t);
552
+ }
553
+ class I {
554
+ constructor() {
555
+ this.value = "valid";
556
+ }
557
+ dirty() {
558
+ this.value === "valid" && (this.value = "dirty");
559
+ }
560
+ abort() {
561
+ this.value !== "aborted" && (this.value = "aborted");
562
+ }
563
+ static mergeArray(e, t) {
564
+ const n = [];
565
+ for (const s of t) {
566
+ if (s.status === "aborted")
567
+ return g;
568
+ s.status === "dirty" && e.dirty(), n.push(s.value);
569
+ }
570
+ return { status: e.value, value: n };
571
+ }
572
+ static async mergeObjectAsync(e, t) {
573
+ const n = [];
574
+ for (const s of t)
575
+ n.push({
576
+ key: await s.key,
577
+ value: await s.value
578
+ });
579
+ return I.mergeObjectSync(e, n);
580
+ }
581
+ static mergeObjectSync(e, t) {
582
+ const n = {};
583
+ for (const s of t) {
584
+ const { key: a, value: i } = s;
585
+ if (a.status === "aborted" || i.status === "aborted")
586
+ return g;
587
+ a.status === "dirty" && e.dirty(), i.status === "dirty" && e.dirty(), a.value !== "__proto__" && (typeof i.value < "u" || s.alwaysSet) && (n[a.value] = i.value);
588
+ }
589
+ return { status: e.value, value: n };
590
+ }
591
+ }
592
+ const g = Object.freeze({
593
+ status: "aborted"
594
+ }), _t = (r) => ({ status: "dirty", value: r }), E = (r) => ({ status: "valid", value: r }), st = (r) => r.status === "aborted", at = (r) => r.status === "dirty", we = (r) => r.status === "valid", Ue = (r) => typeof Promise < "u" && r instanceof Promise;
595
+ var m;
596
+ (function(r) {
597
+ r.errToObj = (e) => typeof e == "string" ? { message: e } : e || {}, r.toString = (e) => typeof e == "string" ? e : e == null ? void 0 : e.message;
598
+ })(m || (m = {}));
599
+ class L {
600
+ constructor(e, t, n, s) {
601
+ this._cachedPath = [], this.parent = e, this.data = t, this._path = n, this._key = s;
602
+ }
603
+ get path() {
604
+ return this._cachedPath.length || (this._key instanceof Array ? this._cachedPath.push(...this._path, ...this._key) : this._cachedPath.push(...this._path, this._key)), this._cachedPath;
605
+ }
606
+ }
607
+ const dt = (r, e) => {
608
+ if (we(e))
609
+ return { success: !0, data: e.value };
610
+ if (!r.common.issues.length)
611
+ throw new Error("Validation failed but no issues detected.");
612
+ return {
613
+ success: !1,
614
+ get error() {
615
+ if (this._error)
616
+ return this._error;
617
+ const t = new A(r.common.issues);
618
+ return this._error = t, this._error;
619
+ }
620
+ };
621
+ };
622
+ function y(r) {
623
+ if (!r)
624
+ return {};
625
+ const { errorMap: e, invalid_type_error: t, required_error: n, description: s } = r;
626
+ if (e && (t || n))
627
+ throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);
628
+ return e ? { errorMap: e, description: s } : { errorMap: (i, o) => i.code !== "invalid_type" ? { message: o.defaultError } : typeof o.data > "u" ? { message: n ?? o.defaultError } : { message: t ?? o.defaultError }, description: s };
629
+ }
630
+ class b {
631
+ constructor(e) {
632
+ 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);
633
+ }
634
+ get description() {
635
+ return this._def.description;
636
+ }
637
+ _getType(e) {
638
+ return F(e.data);
639
+ }
640
+ _getOrReturnCtx(e, t) {
641
+ return t || {
642
+ common: e.parent.common,
643
+ data: e.data,
644
+ parsedType: F(e.data),
645
+ schemaErrorMap: this._def.errorMap,
646
+ path: e.path,
647
+ parent: e.parent
648
+ };
649
+ }
650
+ _processInputParams(e) {
651
+ return {
652
+ status: new I(),
653
+ ctx: {
654
+ common: e.parent.common,
655
+ data: e.data,
656
+ parsedType: F(e.data),
657
+ schemaErrorMap: this._def.errorMap,
658
+ path: e.path,
659
+ parent: e.parent
660
+ }
661
+ };
662
+ }
663
+ _parseSync(e) {
664
+ const t = this._parse(e);
665
+ if (Ue(t))
666
+ throw new Error("Synchronous parse encountered promise.");
667
+ return t;
668
+ }
669
+ _parseAsync(e) {
670
+ const t = this._parse(e);
671
+ return Promise.resolve(t);
672
+ }
673
+ parse(e, t) {
674
+ const n = this.safeParse(e, t);
675
+ if (n.success)
676
+ return n.data;
677
+ throw n.error;
678
+ }
679
+ safeParse(e, t) {
680
+ var n;
681
+ const s = {
682
+ common: {
683
+ issues: [],
684
+ async: (n = t == null ? void 0 : t.async) !== null && n !== void 0 ? n : !1,
685
+ contextualErrorMap: t == null ? void 0 : t.errorMap
686
+ },
687
+ path: (t == null ? void 0 : t.path) || [],
688
+ schemaErrorMap: this._def.errorMap,
689
+ parent: null,
690
+ data: e,
691
+ parsedType: F(e)
692
+ }, a = this._parseSync({ data: e, path: s.path, parent: s });
693
+ return dt(s, a);
694
+ }
695
+ async parseAsync(e, t) {
696
+ const n = await this.safeParseAsync(e, t);
697
+ if (n.success)
698
+ return n.data;
699
+ throw n.error;
700
+ }
701
+ async safeParseAsync(e, t) {
702
+ const n = {
703
+ common: {
704
+ issues: [],
705
+ contextualErrorMap: t == null ? void 0 : t.errorMap,
706
+ async: !0
707
+ },
708
+ path: (t == null ? void 0 : t.path) || [],
709
+ schemaErrorMap: this._def.errorMap,
710
+ parent: null,
711
+ data: e,
712
+ parsedType: F(e)
713
+ }, s = this._parse({ data: e, path: n.path, parent: n }), a = await (Ue(s) ? s : Promise.resolve(s));
714
+ return dt(n, a);
715
+ }
716
+ refine(e, t) {
717
+ const n = (s) => typeof t == "string" || typeof t > "u" ? { message: t } : typeof t == "function" ? t(s) : t;
718
+ return this._refinement((s, a) => {
719
+ const i = e(s), o = () => a.addIssue({
720
+ code: d.custom,
721
+ ...n(s)
722
+ });
723
+ return typeof Promise < "u" && i instanceof Promise ? i.then((c) => c ? !0 : (o(), !1)) : i ? !0 : (o(), !1);
724
+ });
725
+ }
726
+ refinement(e, t) {
727
+ return this._refinement((n, s) => e(n) ? !0 : (s.addIssue(typeof t == "function" ? t(n, s) : t), !1));
728
+ }
729
+ _refinement(e) {
730
+ return new N({
731
+ schema: this,
732
+ typeName: v.ZodEffects,
733
+ effect: { type: "refinement", refinement: e }
734
+ });
735
+ }
736
+ superRefine(e) {
737
+ return this._refinement(e);
738
+ }
739
+ optional() {
740
+ return B.create(this, this._def);
741
+ }
742
+ nullable() {
743
+ return ee.create(this, this._def);
744
+ }
745
+ nullish() {
746
+ return this.nullable().optional();
747
+ }
748
+ array() {
749
+ return S.create(this, this._def);
750
+ }
751
+ promise() {
752
+ return pe.create(this, this._def);
753
+ }
754
+ or(e) {
755
+ return je.create([this, e], this._def);
756
+ }
757
+ and(e) {
758
+ return Ze.create(this, e, this._def);
759
+ }
760
+ transform(e) {
761
+ return new N({
762
+ ...y(this._def),
763
+ schema: this,
764
+ typeName: v.ZodEffects,
765
+ effect: { type: "transform", transform: e }
766
+ });
767
+ }
768
+ default(e) {
769
+ const t = typeof e == "function" ? e : () => e;
770
+ return new Pe({
771
+ ...y(this._def),
772
+ innerType: this,
773
+ defaultValue: t,
774
+ typeName: v.ZodDefault
775
+ });
776
+ }
777
+ brand() {
778
+ return new xt({
779
+ typeName: v.ZodBranded,
780
+ type: this,
781
+ ...y(this._def)
782
+ });
783
+ }
784
+ catch(e) {
785
+ const t = typeof e == "function" ? e : () => e;
786
+ return new Fe({
787
+ ...y(this._def),
788
+ innerType: this,
789
+ catchValue: t,
790
+ typeName: v.ZodCatch
791
+ });
792
+ }
793
+ describe(e) {
794
+ const t = this.constructor;
795
+ return new t({
796
+ ...this._def,
797
+ description: e
798
+ });
799
+ }
800
+ pipe(e) {
801
+ return Ae.create(this, e);
802
+ }
803
+ readonly() {
804
+ return Je.create(this);
805
+ }
806
+ isOptional() {
807
+ return this.safeParse(void 0).success;
808
+ }
809
+ isNullable() {
810
+ return this.safeParse(null).success;
811
+ }
812
+ }
813
+ const Mt = /^c[^\s-]{8,}$/i, Dt = /^[a-z][a-z0-9]*$/, $t = /^[0-9A-HJKMNP-TV-Z]{26}$/, Lt = /^[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, Vt = /^(?!\.)(?!.*\.\.)([A-Z0-9_+-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i, Ut = "^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";
814
+ let et;
815
+ const Bt = /^(((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}))$/, qt = /^(([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})))$/, Wt = (r) => r.precision ? r.offset ? new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}\\.\\d{${r.precision}}(([+-]\\d{2}(:?\\d{2})?)|Z)$`) : new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}\\.\\d{${r.precision}}Z$`) : r.precision === 0 ? r.offset ? new RegExp("^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(([+-]\\d{2}(:?\\d{2})?)|Z)$") : new RegExp("^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}Z$") : r.offset ? new RegExp("^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(\\.\\d+)?(([+-]\\d{2}(:?\\d{2})?)|Z)$") : new RegExp("^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(\\.\\d+)?Z$");
816
+ function Ft(r, e) {
817
+ return !!((e === "v4" || !e) && Bt.test(r) || (e === "v6" || !e) && qt.test(r));
818
+ }
819
+ class P extends b {
820
+ _parse(e) {
821
+ if (this._def.coerce && (e.data = String(e.data)), this._getType(e) !== f.string) {
822
+ const a = this._getOrReturnCtx(e);
823
+ return p(
824
+ a,
825
+ {
826
+ code: d.invalid_type,
827
+ expected: f.string,
828
+ received: a.parsedType
829
+ }
830
+ //
831
+ ), g;
832
+ }
833
+ const n = new I();
834
+ let s;
835
+ for (const a of this._def.checks)
836
+ if (a.kind === "min")
837
+ e.data.length < a.value && (s = this._getOrReturnCtx(e, s), p(s, {
838
+ code: d.too_small,
839
+ minimum: a.value,
840
+ type: "string",
841
+ inclusive: !0,
842
+ exact: !1,
843
+ message: a.message
844
+ }), n.dirty());
845
+ else if (a.kind === "max")
846
+ e.data.length > a.value && (s = this._getOrReturnCtx(e, s), p(s, {
847
+ code: d.too_big,
848
+ maximum: a.value,
849
+ type: "string",
850
+ inclusive: !0,
851
+ exact: !1,
852
+ message: a.message
853
+ }), n.dirty());
854
+ else if (a.kind === "length") {
855
+ const i = e.data.length > a.value, o = e.data.length < a.value;
856
+ (i || o) && (s = this._getOrReturnCtx(e, s), i ? p(s, {
857
+ code: d.too_big,
858
+ maximum: a.value,
859
+ type: "string",
860
+ inclusive: !0,
861
+ exact: !0,
862
+ message: a.message
863
+ }) : o && p(s, {
864
+ code: d.too_small,
865
+ minimum: a.value,
866
+ type: "string",
867
+ inclusive: !0,
868
+ exact: !0,
869
+ message: a.message
870
+ }), n.dirty());
871
+ } else if (a.kind === "email")
872
+ Vt.test(e.data) || (s = this._getOrReturnCtx(e, s), p(s, {
873
+ validation: "email",
874
+ code: d.invalid_string,
875
+ message: a.message
876
+ }), n.dirty());
877
+ else if (a.kind === "emoji")
878
+ et || (et = new RegExp(Ut, "u")), et.test(e.data) || (s = this._getOrReturnCtx(e, s), p(s, {
879
+ validation: "emoji",
880
+ code: d.invalid_string,
881
+ message: a.message
882
+ }), n.dirty());
883
+ else if (a.kind === "uuid")
884
+ Lt.test(e.data) || (s = this._getOrReturnCtx(e, s), p(s, {
885
+ validation: "uuid",
886
+ code: d.invalid_string,
887
+ message: a.message
888
+ }), n.dirty());
889
+ else if (a.kind === "cuid")
890
+ Mt.test(e.data) || (s = this._getOrReturnCtx(e, s), p(s, {
891
+ validation: "cuid",
892
+ code: d.invalid_string,
893
+ message: a.message
894
+ }), n.dirty());
895
+ else if (a.kind === "cuid2")
896
+ Dt.test(e.data) || (s = this._getOrReturnCtx(e, s), p(s, {
897
+ validation: "cuid2",
898
+ code: d.invalid_string,
899
+ message: a.message
900
+ }), n.dirty());
901
+ else if (a.kind === "ulid")
902
+ $t.test(e.data) || (s = this._getOrReturnCtx(e, s), p(s, {
903
+ validation: "ulid",
904
+ code: d.invalid_string,
905
+ message: a.message
906
+ }), n.dirty());
907
+ else if (a.kind === "url")
908
+ try {
909
+ new URL(e.data);
910
+ } catch {
911
+ s = this._getOrReturnCtx(e, s), p(s, {
912
+ validation: "url",
913
+ code: d.invalid_string,
914
+ message: a.message
915
+ }), n.dirty();
916
+ }
917
+ else a.kind === "regex" ? (a.regex.lastIndex = 0, a.regex.test(e.data) || (s = this._getOrReturnCtx(e, s), p(s, {
918
+ validation: "regex",
919
+ code: d.invalid_string,
920
+ message: a.message
921
+ }), n.dirty())) : a.kind === "trim" ? e.data = e.data.trim() : a.kind === "includes" ? e.data.includes(a.value, a.position) || (s = this._getOrReturnCtx(e, s), p(s, {
922
+ code: d.invalid_string,
923
+ validation: { includes: a.value, position: a.position },
924
+ message: a.message
925
+ }), n.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) || (s = this._getOrReturnCtx(e, s), p(s, {
926
+ code: d.invalid_string,
927
+ validation: { startsWith: a.value },
928
+ message: a.message
929
+ }), n.dirty()) : a.kind === "endsWith" ? e.data.endsWith(a.value) || (s = this._getOrReturnCtx(e, s), p(s, {
930
+ code: d.invalid_string,
931
+ validation: { endsWith: a.value },
932
+ message: a.message
933
+ }), n.dirty()) : a.kind === "datetime" ? Wt(a).test(e.data) || (s = this._getOrReturnCtx(e, s), p(s, {
934
+ code: d.invalid_string,
935
+ validation: "datetime",
936
+ message: a.message
937
+ }), n.dirty()) : a.kind === "ip" ? Ft(e.data, a.version) || (s = this._getOrReturnCtx(e, s), p(s, {
938
+ validation: "ip",
939
+ code: d.invalid_string,
940
+ message: a.message
941
+ }), n.dirty()) : x.assertNever(a);
942
+ return { status: n.value, value: e.data };
943
+ }
944
+ _regex(e, t, n) {
945
+ return this.refinement((s) => e.test(s), {
946
+ validation: t,
947
+ code: d.invalid_string,
948
+ ...m.errToObj(n)
949
+ });
950
+ }
951
+ _addCheck(e) {
952
+ return new P({
953
+ ...this._def,
954
+ checks: [...this._def.checks, e]
955
+ });
956
+ }
957
+ email(e) {
958
+ return this._addCheck({ kind: "email", ...m.errToObj(e) });
959
+ }
960
+ url(e) {
961
+ return this._addCheck({ kind: "url", ...m.errToObj(e) });
962
+ }
963
+ emoji(e) {
964
+ return this._addCheck({ kind: "emoji", ...m.errToObj(e) });
965
+ }
966
+ uuid(e) {
967
+ return this._addCheck({ kind: "uuid", ...m.errToObj(e) });
968
+ }
969
+ cuid(e) {
970
+ return this._addCheck({ kind: "cuid", ...m.errToObj(e) });
971
+ }
972
+ cuid2(e) {
973
+ return this._addCheck({ kind: "cuid2", ...m.errToObj(e) });
974
+ }
975
+ ulid(e) {
976
+ return this._addCheck({ kind: "ulid", ...m.errToObj(e) });
977
+ }
978
+ ip(e) {
979
+ return this._addCheck({ kind: "ip", ...m.errToObj(e) });
980
+ }
981
+ datetime(e) {
982
+ var t;
983
+ return typeof e == "string" ? this._addCheck({
984
+ kind: "datetime",
985
+ precision: null,
986
+ offset: !1,
987
+ message: e
988
+ }) : this._addCheck({
989
+ kind: "datetime",
990
+ precision: typeof (e == null ? void 0 : e.precision) > "u" ? null : e == null ? void 0 : e.precision,
991
+ offset: (t = e == null ? void 0 : e.offset) !== null && t !== void 0 ? t : !1,
992
+ ...m.errToObj(e == null ? void 0 : e.message)
993
+ });
994
+ }
995
+ regex(e, t) {
996
+ return this._addCheck({
997
+ kind: "regex",
998
+ regex: e,
999
+ ...m.errToObj(t)
1000
+ });
1001
+ }
1002
+ includes(e, t) {
1003
+ return this._addCheck({
1004
+ kind: "includes",
1005
+ value: e,
1006
+ position: t == null ? void 0 : t.position,
1007
+ ...m.errToObj(t == null ? void 0 : t.message)
1008
+ });
1009
+ }
1010
+ startsWith(e, t) {
1011
+ return this._addCheck({
1012
+ kind: "startsWith",
1013
+ value: e,
1014
+ ...m.errToObj(t)
1015
+ });
1016
+ }
1017
+ endsWith(e, t) {
1018
+ return this._addCheck({
1019
+ kind: "endsWith",
1020
+ value: e,
1021
+ ...m.errToObj(t)
1022
+ });
1023
+ }
1024
+ min(e, t) {
1025
+ return this._addCheck({
1026
+ kind: "min",
1027
+ value: e,
1028
+ ...m.errToObj(t)
1029
+ });
1030
+ }
1031
+ max(e, t) {
1032
+ return this._addCheck({
1033
+ kind: "max",
1034
+ value: e,
1035
+ ...m.errToObj(t)
1036
+ });
1037
+ }
1038
+ length(e, t) {
1039
+ return this._addCheck({
1040
+ kind: "length",
1041
+ value: e,
1042
+ ...m.errToObj(t)
1043
+ });
1044
+ }
1045
+ /**
1046
+ * @deprecated Use z.string().min(1) instead.
1047
+ * @see {@link ZodString.min}
1048
+ */
1049
+ nonempty(e) {
1050
+ return this.min(1, m.errToObj(e));
1051
+ }
1052
+ trim() {
1053
+ return new P({
1054
+ ...this._def,
1055
+ checks: [...this._def.checks, { kind: "trim" }]
1056
+ });
1057
+ }
1058
+ toLowerCase() {
1059
+ return new P({
1060
+ ...this._def,
1061
+ checks: [...this._def.checks, { kind: "toLowerCase" }]
1062
+ });
1063
+ }
1064
+ toUpperCase() {
1065
+ return new P({
1066
+ ...this._def,
1067
+ checks: [...this._def.checks, { kind: "toUpperCase" }]
1068
+ });
1069
+ }
1070
+ get isDatetime() {
1071
+ return !!this._def.checks.find((e) => e.kind === "datetime");
1072
+ }
1073
+ get isEmail() {
1074
+ return !!this._def.checks.find((e) => e.kind === "email");
1075
+ }
1076
+ get isURL() {
1077
+ return !!this._def.checks.find((e) => e.kind === "url");
1078
+ }
1079
+ get isEmoji() {
1080
+ return !!this._def.checks.find((e) => e.kind === "emoji");
1081
+ }
1082
+ get isUUID() {
1083
+ return !!this._def.checks.find((e) => e.kind === "uuid");
1084
+ }
1085
+ get isCUID() {
1086
+ return !!this._def.checks.find((e) => e.kind === "cuid");
1087
+ }
1088
+ get isCUID2() {
1089
+ return !!this._def.checks.find((e) => e.kind === "cuid2");
1090
+ }
1091
+ get isULID() {
1092
+ return !!this._def.checks.find((e) => e.kind === "ulid");
1093
+ }
1094
+ get isIP() {
1095
+ return !!this._def.checks.find((e) => e.kind === "ip");
1096
+ }
1097
+ get minLength() {
1098
+ let e = null;
1099
+ for (const t of this._def.checks)
1100
+ t.kind === "min" && (e === null || t.value > e) && (e = t.value);
1101
+ return e;
1102
+ }
1103
+ get maxLength() {
1104
+ let e = null;
1105
+ for (const t of this._def.checks)
1106
+ t.kind === "max" && (e === null || t.value < e) && (e = t.value);
1107
+ return e;
1108
+ }
1109
+ }
1110
+ P.create = (r) => {
1111
+ var e;
1112
+ return new P({
1113
+ checks: [],
1114
+ typeName: v.ZodString,
1115
+ coerce: (e = r == null ? void 0 : r.coerce) !== null && e !== void 0 ? e : !1,
1116
+ ...y(r)
1117
+ });
1118
+ };
1119
+ function Ht(r, e) {
1120
+ const t = (r.toString().split(".")[1] || "").length, n = (e.toString().split(".")[1] || "").length, s = t > n ? t : n, a = parseInt(r.toFixed(s).replace(".", "")), i = parseInt(e.toFixed(s).replace(".", ""));
1121
+ return a % i / Math.pow(10, s);
1122
+ }
1123
+ class H extends b {
1124
+ constructor() {
1125
+ super(...arguments), this.min = this.gte, this.max = this.lte, this.step = this.multipleOf;
1126
+ }
1127
+ _parse(e) {
1128
+ if (this._def.coerce && (e.data = Number(e.data)), this._getType(e) !== f.number) {
1129
+ const a = this._getOrReturnCtx(e);
1130
+ return p(a, {
1131
+ code: d.invalid_type,
1132
+ expected: f.number,
1133
+ received: a.parsedType
1134
+ }), g;
1135
+ }
1136
+ let n;
1137
+ const s = new I();
1138
+ for (const a of this._def.checks)
1139
+ a.kind === "int" ? x.isInteger(e.data) || (n = this._getOrReturnCtx(e, n), p(n, {
1140
+ code: d.invalid_type,
1141
+ expected: "integer",
1142
+ received: "float",
1143
+ message: a.message
1144
+ }), s.dirty()) : a.kind === "min" ? (a.inclusive ? e.data < a.value : e.data <= a.value) && (n = this._getOrReturnCtx(e, n), p(n, {
1145
+ code: d.too_small,
1146
+ minimum: a.value,
1147
+ type: "number",
1148
+ inclusive: a.inclusive,
1149
+ exact: !1,
1150
+ message: a.message
1151
+ }), s.dirty()) : a.kind === "max" ? (a.inclusive ? e.data > a.value : e.data >= a.value) && (n = this._getOrReturnCtx(e, n), p(n, {
1152
+ code: d.too_big,
1153
+ maximum: a.value,
1154
+ type: "number",
1155
+ inclusive: a.inclusive,
1156
+ exact: !1,
1157
+ message: a.message
1158
+ }), s.dirty()) : a.kind === "multipleOf" ? Ht(e.data, a.value) !== 0 && (n = this._getOrReturnCtx(e, n), p(n, {
1159
+ code: d.not_multiple_of,
1160
+ multipleOf: a.value,
1161
+ message: a.message
1162
+ }), s.dirty()) : a.kind === "finite" ? Number.isFinite(e.data) || (n = this._getOrReturnCtx(e, n), p(n, {
1163
+ code: d.not_finite,
1164
+ message: a.message
1165
+ }), s.dirty()) : x.assertNever(a);
1166
+ return { status: s.value, value: e.data };
1167
+ }
1168
+ gte(e, t) {
1169
+ return this.setLimit("min", e, !0, m.toString(t));
1170
+ }
1171
+ gt(e, t) {
1172
+ return this.setLimit("min", e, !1, m.toString(t));
1173
+ }
1174
+ lte(e, t) {
1175
+ return this.setLimit("max", e, !0, m.toString(t));
1176
+ }
1177
+ lt(e, t) {
1178
+ return this.setLimit("max", e, !1, m.toString(t));
1179
+ }
1180
+ setLimit(e, t, n, s) {
1181
+ return new H({
1182
+ ...this._def,
1183
+ checks: [
1184
+ ...this._def.checks,
1185
+ {
1186
+ kind: e,
1187
+ value: t,
1188
+ inclusive: n,
1189
+ message: m.toString(s)
1190
+ }
1191
+ ]
1192
+ });
1193
+ }
1194
+ _addCheck(e) {
1195
+ return new H({
1196
+ ...this._def,
1197
+ checks: [...this._def.checks, e]
1198
+ });
1199
+ }
1200
+ int(e) {
1201
+ return this._addCheck({
1202
+ kind: "int",
1203
+ message: m.toString(e)
1204
+ });
1205
+ }
1206
+ positive(e) {
1207
+ return this._addCheck({
1208
+ kind: "min",
1209
+ value: 0,
1210
+ inclusive: !1,
1211
+ message: m.toString(e)
1212
+ });
1213
+ }
1214
+ negative(e) {
1215
+ return this._addCheck({
1216
+ kind: "max",
1217
+ value: 0,
1218
+ inclusive: !1,
1219
+ message: m.toString(e)
1220
+ });
1221
+ }
1222
+ nonpositive(e) {
1223
+ return this._addCheck({
1224
+ kind: "max",
1225
+ value: 0,
1226
+ inclusive: !0,
1227
+ message: m.toString(e)
1228
+ });
1229
+ }
1230
+ nonnegative(e) {
1231
+ return this._addCheck({
1232
+ kind: "min",
1233
+ value: 0,
1234
+ inclusive: !0,
1235
+ message: m.toString(e)
1236
+ });
1237
+ }
1238
+ multipleOf(e, t) {
1239
+ return this._addCheck({
1240
+ kind: "multipleOf",
1241
+ value: e,
1242
+ message: m.toString(t)
1243
+ });
1244
+ }
1245
+ finite(e) {
1246
+ return this._addCheck({
1247
+ kind: "finite",
1248
+ message: m.toString(e)
1249
+ });
1250
+ }
1251
+ safe(e) {
1252
+ return this._addCheck({
1253
+ kind: "min",
1254
+ inclusive: !0,
1255
+ value: Number.MIN_SAFE_INTEGER,
1256
+ message: m.toString(e)
1257
+ })._addCheck({
1258
+ kind: "max",
1259
+ inclusive: !0,
1260
+ value: Number.MAX_SAFE_INTEGER,
1261
+ message: m.toString(e)
1262
+ });
1263
+ }
1264
+ get minValue() {
1265
+ let e = null;
1266
+ for (const t of this._def.checks)
1267
+ t.kind === "min" && (e === null || t.value > e) && (e = t.value);
1268
+ return e;
1269
+ }
1270
+ get maxValue() {
1271
+ let e = null;
1272
+ for (const t of this._def.checks)
1273
+ t.kind === "max" && (e === null || t.value < e) && (e = t.value);
1274
+ return e;
1275
+ }
1276
+ get isInt() {
1277
+ return !!this._def.checks.find((e) => e.kind === "int" || e.kind === "multipleOf" && x.isInteger(e.value));
1278
+ }
1279
+ get isFinite() {
1280
+ let e = null, t = null;
1281
+ for (const n of this._def.checks) {
1282
+ if (n.kind === "finite" || n.kind === "int" || n.kind === "multipleOf")
1283
+ return !0;
1284
+ n.kind === "min" ? (t === null || n.value > t) && (t = n.value) : n.kind === "max" && (e === null || n.value < e) && (e = n.value);
1285
+ }
1286
+ return Number.isFinite(t) && Number.isFinite(e);
1287
+ }
1288
+ }
1289
+ H.create = (r) => new H({
1290
+ checks: [],
1291
+ typeName: v.ZodNumber,
1292
+ coerce: (r == null ? void 0 : r.coerce) || !1,
1293
+ ...y(r)
1294
+ });
1295
+ class J extends b {
1296
+ constructor() {
1297
+ super(...arguments), this.min = this.gte, this.max = this.lte;
1298
+ }
1299
+ _parse(e) {
1300
+ if (this._def.coerce && (e.data = BigInt(e.data)), this._getType(e) !== f.bigint) {
1301
+ const a = this._getOrReturnCtx(e);
1302
+ return p(a, {
1303
+ code: d.invalid_type,
1304
+ expected: f.bigint,
1305
+ received: a.parsedType
1306
+ }), g;
1307
+ }
1308
+ let n;
1309
+ const s = new I();
1310
+ for (const a of this._def.checks)
1311
+ a.kind === "min" ? (a.inclusive ? e.data < a.value : e.data <= a.value) && (n = this._getOrReturnCtx(e, n), p(n, {
1312
+ code: d.too_small,
1313
+ type: "bigint",
1314
+ minimum: a.value,
1315
+ inclusive: a.inclusive,
1316
+ message: a.message
1317
+ }), s.dirty()) : a.kind === "max" ? (a.inclusive ? e.data > a.value : e.data >= a.value) && (n = this._getOrReturnCtx(e, n), p(n, {
1318
+ code: d.too_big,
1319
+ type: "bigint",
1320
+ maximum: a.value,
1321
+ inclusive: a.inclusive,
1322
+ message: a.message
1323
+ }), s.dirty()) : a.kind === "multipleOf" ? e.data % a.value !== BigInt(0) && (n = this._getOrReturnCtx(e, n), p(n, {
1324
+ code: d.not_multiple_of,
1325
+ multipleOf: a.value,
1326
+ message: a.message
1327
+ }), s.dirty()) : x.assertNever(a);
1328
+ return { status: s.value, value: e.data };
1329
+ }
1330
+ gte(e, t) {
1331
+ return this.setLimit("min", e, !0, m.toString(t));
1332
+ }
1333
+ gt(e, t) {
1334
+ return this.setLimit("min", e, !1, m.toString(t));
1335
+ }
1336
+ lte(e, t) {
1337
+ return this.setLimit("max", e, !0, m.toString(t));
1338
+ }
1339
+ lt(e, t) {
1340
+ return this.setLimit("max", e, !1, m.toString(t));
1341
+ }
1342
+ setLimit(e, t, n, s) {
1343
+ return new J({
1344
+ ...this._def,
1345
+ checks: [
1346
+ ...this._def.checks,
1347
+ {
1348
+ kind: e,
1349
+ value: t,
1350
+ inclusive: n,
1351
+ message: m.toString(s)
1352
+ }
1353
+ ]
1354
+ });
1355
+ }
1356
+ _addCheck(e) {
1357
+ return new J({
1358
+ ...this._def,
1359
+ checks: [...this._def.checks, e]
1360
+ });
1361
+ }
1362
+ positive(e) {
1363
+ return this._addCheck({
1364
+ kind: "min",
1365
+ value: BigInt(0),
1366
+ inclusive: !1,
1367
+ message: m.toString(e)
1368
+ });
1369
+ }
1370
+ negative(e) {
1371
+ return this._addCheck({
1372
+ kind: "max",
1373
+ value: BigInt(0),
1374
+ inclusive: !1,
1375
+ message: m.toString(e)
1376
+ });
1377
+ }
1378
+ nonpositive(e) {
1379
+ return this._addCheck({
1380
+ kind: "max",
1381
+ value: BigInt(0),
1382
+ inclusive: !0,
1383
+ message: m.toString(e)
1384
+ });
1385
+ }
1386
+ nonnegative(e) {
1387
+ return this._addCheck({
1388
+ kind: "min",
1389
+ value: BigInt(0),
1390
+ inclusive: !0,
1391
+ message: m.toString(e)
1392
+ });
1393
+ }
1394
+ multipleOf(e, t) {
1395
+ return this._addCheck({
1396
+ kind: "multipleOf",
1397
+ value: e,
1398
+ message: m.toString(t)
1399
+ });
1400
+ }
1401
+ get minValue() {
1402
+ let e = null;
1403
+ for (const t of this._def.checks)
1404
+ t.kind === "min" && (e === null || t.value > e) && (e = t.value);
1405
+ return e;
1406
+ }
1407
+ get maxValue() {
1408
+ let e = null;
1409
+ for (const t of this._def.checks)
1410
+ t.kind === "max" && (e === null || t.value < e) && (e = t.value);
1411
+ return e;
1412
+ }
1413
+ }
1414
+ J.create = (r) => {
1415
+ var e;
1416
+ return new J({
1417
+ checks: [],
1418
+ typeName: v.ZodBigInt,
1419
+ coerce: (e = r == null ? void 0 : r.coerce) !== null && e !== void 0 ? e : !1,
1420
+ ...y(r)
1421
+ });
1422
+ };
1423
+ class ke extends b {
1424
+ _parse(e) {
1425
+ if (this._def.coerce && (e.data = !!e.data), this._getType(e) !== f.boolean) {
1426
+ const n = this._getOrReturnCtx(e);
1427
+ return p(n, {
1428
+ code: d.invalid_type,
1429
+ expected: f.boolean,
1430
+ received: n.parsedType
1431
+ }), g;
1432
+ }
1433
+ return E(e.data);
1434
+ }
1435
+ }
1436
+ ke.create = (r) => new ke({
1437
+ typeName: v.ZodBoolean,
1438
+ coerce: (r == null ? void 0 : r.coerce) || !1,
1439
+ ...y(r)
1440
+ });
1441
+ class X extends b {
1442
+ _parse(e) {
1443
+ if (this._def.coerce && (e.data = new Date(e.data)), this._getType(e) !== f.date) {
1444
+ const a = this._getOrReturnCtx(e);
1445
+ return p(a, {
1446
+ code: d.invalid_type,
1447
+ expected: f.date,
1448
+ received: a.parsedType
1449
+ }), g;
1450
+ }
1451
+ if (isNaN(e.data.getTime())) {
1452
+ const a = this._getOrReturnCtx(e);
1453
+ return p(a, {
1454
+ code: d.invalid_date
1455
+ }), g;
1456
+ }
1457
+ const n = new I();
1458
+ let s;
1459
+ for (const a of this._def.checks)
1460
+ a.kind === "min" ? e.data.getTime() < a.value && (s = this._getOrReturnCtx(e, s), p(s, {
1461
+ code: d.too_small,
1462
+ message: a.message,
1463
+ inclusive: !0,
1464
+ exact: !1,
1465
+ minimum: a.value,
1466
+ type: "date"
1467
+ }), n.dirty()) : a.kind === "max" ? e.data.getTime() > a.value && (s = this._getOrReturnCtx(e, s), p(s, {
1468
+ code: d.too_big,
1469
+ message: a.message,
1470
+ inclusive: !0,
1471
+ exact: !1,
1472
+ maximum: a.value,
1473
+ type: "date"
1474
+ }), n.dirty()) : x.assertNever(a);
1475
+ return {
1476
+ status: n.value,
1477
+ value: new Date(e.data.getTime())
1478
+ };
1479
+ }
1480
+ _addCheck(e) {
1481
+ return new X({
1482
+ ...this._def,
1483
+ checks: [...this._def.checks, e]
1484
+ });
1485
+ }
1486
+ min(e, t) {
1487
+ return this._addCheck({
1488
+ kind: "min",
1489
+ value: e.getTime(),
1490
+ message: m.toString(t)
1491
+ });
1492
+ }
1493
+ max(e, t) {
1494
+ return this._addCheck({
1495
+ kind: "max",
1496
+ value: e.getTime(),
1497
+ message: m.toString(t)
1498
+ });
1499
+ }
1500
+ get minDate() {
1501
+ let e = null;
1502
+ for (const t of this._def.checks)
1503
+ t.kind === "min" && (e === null || t.value > e) && (e = t.value);
1504
+ return e != null ? new Date(e) : null;
1505
+ }
1506
+ get maxDate() {
1507
+ let e = null;
1508
+ for (const t of this._def.checks)
1509
+ t.kind === "max" && (e === null || t.value < e) && (e = t.value);
1510
+ return e != null ? new Date(e) : null;
1511
+ }
1512
+ }
1513
+ X.create = (r) => new X({
1514
+ checks: [],
1515
+ coerce: (r == null ? void 0 : r.coerce) || !1,
1516
+ typeName: v.ZodDate,
1517
+ ...y(r)
1518
+ });
1519
+ class Be extends b {
1520
+ _parse(e) {
1521
+ if (this._getType(e) !== f.symbol) {
1522
+ const n = this._getOrReturnCtx(e);
1523
+ return p(n, {
1524
+ code: d.invalid_type,
1525
+ expected: f.symbol,
1526
+ received: n.parsedType
1527
+ }), g;
1528
+ }
1529
+ return E(e.data);
1530
+ }
1531
+ }
1532
+ Be.create = (r) => new Be({
1533
+ typeName: v.ZodSymbol,
1534
+ ...y(r)
1535
+ });
1536
+ class Te extends b {
1537
+ _parse(e) {
1538
+ if (this._getType(e) !== f.undefined) {
1539
+ const n = this._getOrReturnCtx(e);
1540
+ return p(n, {
1541
+ code: d.invalid_type,
1542
+ expected: f.undefined,
1543
+ received: n.parsedType
1544
+ }), g;
1545
+ }
1546
+ return E(e.data);
1547
+ }
1548
+ }
1549
+ Te.create = (r) => new Te({
1550
+ typeName: v.ZodUndefined,
1551
+ ...y(r)
1552
+ });
1553
+ class Oe extends b {
1554
+ _parse(e) {
1555
+ if (this._getType(e) !== f.null) {
1556
+ const n = this._getOrReturnCtx(e);
1557
+ return p(n, {
1558
+ code: d.invalid_type,
1559
+ expected: f.null,
1560
+ received: n.parsedType
1561
+ }), g;
1562
+ }
1563
+ return E(e.data);
1564
+ }
1565
+ }
1566
+ Oe.create = (r) => new Oe({
1567
+ typeName: v.ZodNull,
1568
+ ...y(r)
1569
+ });
1570
+ class fe extends b {
1571
+ constructor() {
1572
+ super(...arguments), this._any = !0;
1573
+ }
1574
+ _parse(e) {
1575
+ return E(e.data);
1576
+ }
1577
+ }
1578
+ fe.create = (r) => new fe({
1579
+ typeName: v.ZodAny,
1580
+ ...y(r)
1581
+ });
1582
+ class Q extends b {
1583
+ constructor() {
1584
+ super(...arguments), this._unknown = !0;
1585
+ }
1586
+ _parse(e) {
1587
+ return E(e.data);
1588
+ }
1589
+ }
1590
+ Q.create = (r) => new Q({
1591
+ typeName: v.ZodUnknown,
1592
+ ...y(r)
1593
+ });
1594
+ class q extends b {
1595
+ _parse(e) {
1596
+ const t = this._getOrReturnCtx(e);
1597
+ return p(t, {
1598
+ code: d.invalid_type,
1599
+ expected: f.never,
1600
+ received: t.parsedType
1601
+ }), g;
1602
+ }
1603
+ }
1604
+ q.create = (r) => new q({
1605
+ typeName: v.ZodNever,
1606
+ ...y(r)
1607
+ });
1608
+ class qe extends b {
1609
+ _parse(e) {
1610
+ if (this._getType(e) !== f.undefined) {
1611
+ const n = this._getOrReturnCtx(e);
1612
+ return p(n, {
1613
+ code: d.invalid_type,
1614
+ expected: f.void,
1615
+ received: n.parsedType
1616
+ }), g;
1617
+ }
1618
+ return E(e.data);
1619
+ }
1620
+ }
1621
+ qe.create = (r) => new qe({
1622
+ typeName: v.ZodVoid,
1623
+ ...y(r)
1624
+ });
1625
+ class S extends b {
1626
+ _parse(e) {
1627
+ const { ctx: t, status: n } = this._processInputParams(e), s = this._def;
1628
+ if (t.parsedType !== f.array)
1629
+ return p(t, {
1630
+ code: d.invalid_type,
1631
+ expected: f.array,
1632
+ received: t.parsedType
1633
+ }), g;
1634
+ if (s.exactLength !== null) {
1635
+ const i = t.data.length > s.exactLength.value, o = t.data.length < s.exactLength.value;
1636
+ (i || o) && (p(t, {
1637
+ code: i ? d.too_big : d.too_small,
1638
+ minimum: o ? s.exactLength.value : void 0,
1639
+ maximum: i ? s.exactLength.value : void 0,
1640
+ type: "array",
1641
+ inclusive: !0,
1642
+ exact: !0,
1643
+ message: s.exactLength.message
1644
+ }), n.dirty());
1645
+ }
1646
+ if (s.minLength !== null && t.data.length < s.minLength.value && (p(t, {
1647
+ code: d.too_small,
1648
+ minimum: s.minLength.value,
1649
+ type: "array",
1650
+ inclusive: !0,
1651
+ exact: !1,
1652
+ message: s.minLength.message
1653
+ }), n.dirty()), s.maxLength !== null && t.data.length > s.maxLength.value && (p(t, {
1654
+ code: d.too_big,
1655
+ maximum: s.maxLength.value,
1656
+ type: "array",
1657
+ inclusive: !0,
1658
+ exact: !1,
1659
+ message: s.maxLength.message
1660
+ }), n.dirty()), t.common.async)
1661
+ return Promise.all([...t.data].map((i, o) => s.type._parseAsync(new L(t, i, t.path, o)))).then((i) => I.mergeArray(n, i));
1662
+ const a = [...t.data].map((i, o) => s.type._parseSync(new L(t, i, t.path, o)));
1663
+ return I.mergeArray(n, a);
1664
+ }
1665
+ get element() {
1666
+ return this._def.type;
1667
+ }
1668
+ min(e, t) {
1669
+ return new S({
1670
+ ...this._def,
1671
+ minLength: { value: e, message: m.toString(t) }
1672
+ });
1673
+ }
1674
+ max(e, t) {
1675
+ return new S({
1676
+ ...this._def,
1677
+ maxLength: { value: e, message: m.toString(t) }
1678
+ });
1679
+ }
1680
+ length(e, t) {
1681
+ return new S({
1682
+ ...this._def,
1683
+ exactLength: { value: e, message: m.toString(t) }
1684
+ });
1685
+ }
1686
+ nonempty(e) {
1687
+ return this.min(1, e);
1688
+ }
1689
+ }
1690
+ S.create = (r, e) => new S({
1691
+ type: r,
1692
+ minLength: null,
1693
+ maxLength: null,
1694
+ exactLength: null,
1695
+ typeName: v.ZodArray,
1696
+ ...y(e)
1697
+ });
1698
+ function oe(r) {
1699
+ if (r instanceof T) {
1700
+ const e = {};
1701
+ for (const t in r.shape) {
1702
+ const n = r.shape[t];
1703
+ e[t] = B.create(oe(n));
1704
+ }
1705
+ return new T({
1706
+ ...r._def,
1707
+ shape: () => e
1708
+ });
1709
+ } else return r instanceof S ? new S({
1710
+ ...r._def,
1711
+ type: oe(r.element)
1712
+ }) : r instanceof B ? B.create(oe(r.unwrap())) : r instanceof ee ? ee.create(oe(r.unwrap())) : r instanceof V ? V.create(r.items.map((e) => oe(e))) : r;
1713
+ }
1714
+ class T extends b {
1715
+ constructor() {
1716
+ super(...arguments), this._cached = null, this.nonstrict = this.passthrough, this.augment = this.extend;
1717
+ }
1718
+ _getCached() {
1719
+ if (this._cached !== null)
1720
+ return this._cached;
1721
+ const e = this._def.shape(), t = x.objectKeys(e);
1722
+ return this._cached = { shape: e, keys: t };
1723
+ }
1724
+ _parse(e) {
1725
+ if (this._getType(e) !== f.object) {
1726
+ const u = this._getOrReturnCtx(e);
1727
+ return p(u, {
1728
+ code: d.invalid_type,
1729
+ expected: f.object,
1730
+ received: u.parsedType
1731
+ }), g;
1732
+ }
1733
+ const { status: n, ctx: s } = this._processInputParams(e), { shape: a, keys: i } = this._getCached(), o = [];
1734
+ if (!(this._def.catchall instanceof q && this._def.unknownKeys === "strip"))
1735
+ for (const u in s.data)
1736
+ i.includes(u) || o.push(u);
1737
+ const c = [];
1738
+ for (const u of i) {
1739
+ const l = a[u], h = s.data[u];
1740
+ c.push({
1741
+ key: { status: "valid", value: u },
1742
+ value: l._parse(new L(s, h, s.path, u)),
1743
+ alwaysSet: u in s.data
1744
+ });
1745
+ }
1746
+ if (this._def.catchall instanceof q) {
1747
+ const u = this._def.unknownKeys;
1748
+ if (u === "passthrough")
1749
+ for (const l of o)
1750
+ c.push({
1751
+ key: { status: "valid", value: l },
1752
+ value: { status: "valid", value: s.data[l] }
1753
+ });
1754
+ else if (u === "strict")
1755
+ o.length > 0 && (p(s, {
1756
+ code: d.unrecognized_keys,
1757
+ keys: o
1758
+ }), n.dirty());
1759
+ else if (u !== "strip") throw new Error("Internal ZodObject error: invalid unknownKeys value.");
1760
+ } else {
1761
+ const u = this._def.catchall;
1762
+ for (const l of o) {
1763
+ const h = s.data[l];
1764
+ c.push({
1765
+ key: { status: "valid", value: l },
1766
+ value: u._parse(
1767
+ new L(s, h, s.path, l)
1768
+ //, ctx.child(key), value, getParsedType(value)
1769
+ ),
1770
+ alwaysSet: l in s.data
1771
+ });
1772
+ }
1773
+ }
1774
+ return s.common.async ? Promise.resolve().then(async () => {
1775
+ const u = [];
1776
+ for (const l of c) {
1777
+ const h = await l.key;
1778
+ u.push({
1779
+ key: h,
1780
+ value: await l.value,
1781
+ alwaysSet: l.alwaysSet
1782
+ });
1783
+ }
1784
+ return u;
1785
+ }).then((u) => I.mergeObjectSync(n, u)) : I.mergeObjectSync(n, c);
1786
+ }
1787
+ get shape() {
1788
+ return this._def.shape();
1789
+ }
1790
+ strict(e) {
1791
+ return m.errToObj, new T({
1792
+ ...this._def,
1793
+ unknownKeys: "strict",
1794
+ ...e !== void 0 ? {
1795
+ errorMap: (t, n) => {
1796
+ var s, a, i, o;
1797
+ const c = (i = (a = (s = this._def).errorMap) === null || a === void 0 ? void 0 : a.call(s, t, n).message) !== null && i !== void 0 ? i : n.defaultError;
1798
+ return t.code === "unrecognized_keys" ? {
1799
+ message: (o = m.errToObj(e).message) !== null && o !== void 0 ? o : c
1800
+ } : {
1801
+ message: c
1802
+ };
1803
+ }
1804
+ } : {}
1805
+ });
1806
+ }
1807
+ strip() {
1808
+ return new T({
1809
+ ...this._def,
1810
+ unknownKeys: "strip"
1811
+ });
1812
+ }
1813
+ passthrough() {
1814
+ return new T({
1815
+ ...this._def,
1816
+ unknownKeys: "passthrough"
1817
+ });
1818
+ }
1819
+ // const AugmentFactory =
1820
+ // <Def extends ZodObjectDef>(def: Def) =>
1821
+ // <Augmentation extends ZodRawShape>(
1822
+ // augmentation: Augmentation
1823
+ // ): ZodObject<
1824
+ // extendShape<ReturnType<Def["shape"]>, Augmentation>,
1825
+ // Def["unknownKeys"],
1826
+ // Def["catchall"]
1827
+ // > => {
1828
+ // return new ZodObject({
1829
+ // ...def,
1830
+ // shape: () => ({
1831
+ // ...def.shape(),
1832
+ // ...augmentation,
1833
+ // }),
1834
+ // }) as any;
1835
+ // };
1836
+ extend(e) {
1837
+ return new T({
1838
+ ...this._def,
1839
+ shape: () => ({
1840
+ ...this._def.shape(),
1841
+ ...e
1842
+ })
1843
+ });
1844
+ }
1845
+ /**
1846
+ * Prior to zod@1.0.12 there was a bug in the
1847
+ * inferred type of merged objects. Please
1848
+ * upgrade if you are experiencing issues.
1849
+ */
1850
+ merge(e) {
1851
+ return new T({
1852
+ unknownKeys: e._def.unknownKeys,
1853
+ catchall: e._def.catchall,
1854
+ shape: () => ({
1855
+ ...this._def.shape(),
1856
+ ...e._def.shape()
1857
+ }),
1858
+ typeName: v.ZodObject
1859
+ });
1860
+ }
1861
+ // merge<
1862
+ // Incoming extends AnyZodObject,
1863
+ // Augmentation extends Incoming["shape"],
1864
+ // NewOutput extends {
1865
+ // [k in keyof Augmentation | keyof Output]: k extends keyof Augmentation
1866
+ // ? Augmentation[k]["_output"]
1867
+ // : k extends keyof Output
1868
+ // ? Output[k]
1869
+ // : never;
1870
+ // },
1871
+ // NewInput extends {
1872
+ // [k in keyof Augmentation | keyof Input]: k extends keyof Augmentation
1873
+ // ? Augmentation[k]["_input"]
1874
+ // : k extends keyof Input
1875
+ // ? Input[k]
1876
+ // : never;
1877
+ // }
1878
+ // >(
1879
+ // merging: Incoming
1880
+ // ): ZodObject<
1881
+ // extendShape<T, ReturnType<Incoming["_def"]["shape"]>>,
1882
+ // Incoming["_def"]["unknownKeys"],
1883
+ // Incoming["_def"]["catchall"],
1884
+ // NewOutput,
1885
+ // NewInput
1886
+ // > {
1887
+ // const merged: any = new ZodObject({
1888
+ // unknownKeys: merging._def.unknownKeys,
1889
+ // catchall: merging._def.catchall,
1890
+ // shape: () =>
1891
+ // objectUtil.mergeShapes(this._def.shape(), merging._def.shape()),
1892
+ // typeName: ZodFirstPartyTypeKind.ZodObject,
1893
+ // }) as any;
1894
+ // return merged;
1895
+ // }
1896
+ setKey(e, t) {
1897
+ return this.augment({ [e]: t });
1898
+ }
1899
+ // merge<Incoming extends AnyZodObject>(
1900
+ // merging: Incoming
1901
+ // ): //ZodObject<T & Incoming["_shape"], UnknownKeys, Catchall> = (merging) => {
1902
+ // ZodObject<
1903
+ // extendShape<T, ReturnType<Incoming["_def"]["shape"]>>,
1904
+ // Incoming["_def"]["unknownKeys"],
1905
+ // Incoming["_def"]["catchall"]
1906
+ // > {
1907
+ // // const mergedShape = objectUtil.mergeShapes(
1908
+ // // this._def.shape(),
1909
+ // // merging._def.shape()
1910
+ // // );
1911
+ // const merged: any = new ZodObject({
1912
+ // unknownKeys: merging._def.unknownKeys,
1913
+ // catchall: merging._def.catchall,
1914
+ // shape: () =>
1915
+ // objectUtil.mergeShapes(this._def.shape(), merging._def.shape()),
1916
+ // typeName: ZodFirstPartyTypeKind.ZodObject,
1917
+ // }) as any;
1918
+ // return merged;
1919
+ // }
1920
+ catchall(e) {
1921
+ return new T({
1922
+ ...this._def,
1923
+ catchall: e
1924
+ });
1925
+ }
1926
+ pick(e) {
1927
+ const t = {};
1928
+ return x.objectKeys(e).forEach((n) => {
1929
+ e[n] && this.shape[n] && (t[n] = this.shape[n]);
1930
+ }), new T({
1931
+ ...this._def,
1932
+ shape: () => t
1933
+ });
1934
+ }
1935
+ omit(e) {
1936
+ const t = {};
1937
+ return x.objectKeys(this.shape).forEach((n) => {
1938
+ e[n] || (t[n] = this.shape[n]);
1939
+ }), new T({
1940
+ ...this._def,
1941
+ shape: () => t
1942
+ });
1943
+ }
1944
+ /**
1945
+ * @deprecated
1946
+ */
1947
+ deepPartial() {
1948
+ return oe(this);
1949
+ }
1950
+ partial(e) {
1951
+ const t = {};
1952
+ return x.objectKeys(this.shape).forEach((n) => {
1953
+ const s = this.shape[n];
1954
+ e && !e[n] ? t[n] = s : t[n] = s.optional();
1955
+ }), new T({
1956
+ ...this._def,
1957
+ shape: () => t
1958
+ });
1959
+ }
1960
+ required(e) {
1961
+ const t = {};
1962
+ return x.objectKeys(this.shape).forEach((n) => {
1963
+ if (e && !e[n])
1964
+ t[n] = this.shape[n];
1965
+ else {
1966
+ let a = this.shape[n];
1967
+ for (; a instanceof B; )
1968
+ a = a._def.innerType;
1969
+ t[n] = a;
1970
+ }
1971
+ }), new T({
1972
+ ...this._def,
1973
+ shape: () => t
1974
+ });
1975
+ }
1976
+ keyof() {
1977
+ return bt(x.objectKeys(this.shape));
1978
+ }
1979
+ }
1980
+ T.create = (r, e) => new T({
1981
+ shape: () => r,
1982
+ unknownKeys: "strip",
1983
+ catchall: q.create(),
1984
+ typeName: v.ZodObject,
1985
+ ...y(e)
1986
+ });
1987
+ T.strictCreate = (r, e) => new T({
1988
+ shape: () => r,
1989
+ unknownKeys: "strict",
1990
+ catchall: q.create(),
1991
+ typeName: v.ZodObject,
1992
+ ...y(e)
1993
+ });
1994
+ T.lazycreate = (r, e) => new T({
1995
+ shape: r,
1996
+ unknownKeys: "strip",
1997
+ catchall: q.create(),
1998
+ typeName: v.ZodObject,
1999
+ ...y(e)
2000
+ });
2001
+ class je extends b {
2002
+ _parse(e) {
2003
+ const { ctx: t } = this._processInputParams(e), n = this._def.options;
2004
+ function s(a) {
2005
+ for (const o of a)
2006
+ if (o.result.status === "valid")
2007
+ return o.result;
2008
+ for (const o of a)
2009
+ if (o.result.status === "dirty")
2010
+ return t.common.issues.push(...o.ctx.common.issues), o.result;
2011
+ const i = a.map((o) => new A(o.ctx.common.issues));
2012
+ return p(t, {
2013
+ code: d.invalid_union,
2014
+ unionErrors: i
2015
+ }), g;
2016
+ }
2017
+ if (t.common.async)
2018
+ return Promise.all(n.map(async (a) => {
2019
+ const i = {
2020
+ ...t,
2021
+ common: {
2022
+ ...t.common,
2023
+ issues: []
2024
+ },
2025
+ parent: null
2026
+ };
2027
+ return {
2028
+ result: await a._parseAsync({
2029
+ data: t.data,
2030
+ path: t.path,
2031
+ parent: i
2032
+ }),
2033
+ ctx: i
2034
+ };
2035
+ })).then(s);
2036
+ {
2037
+ let a;
2038
+ const i = [];
2039
+ for (const c of n) {
2040
+ const u = {
2041
+ ...t,
2042
+ common: {
2043
+ ...t.common,
2044
+ issues: []
2045
+ },
2046
+ parent: null
2047
+ }, l = c._parseSync({
2048
+ data: t.data,
2049
+ path: t.path,
2050
+ parent: u
2051
+ });
2052
+ if (l.status === "valid")
2053
+ return l;
2054
+ l.status === "dirty" && !a && (a = { result: l, ctx: u }), u.common.issues.length && i.push(u.common.issues);
2055
+ }
2056
+ if (a)
2057
+ return t.common.issues.push(...a.ctx.common.issues), a.result;
2058
+ const o = i.map((c) => new A(c));
2059
+ return p(t, {
2060
+ code: d.invalid_union,
2061
+ unionErrors: o
2062
+ }), g;
2063
+ }
2064
+ }
2065
+ get options() {
2066
+ return this._def.options;
2067
+ }
2068
+ }
2069
+ je.create = (r, e) => new je({
2070
+ options: r,
2071
+ typeName: v.ZodUnion,
2072
+ ...y(e)
2073
+ });
2074
+ const De = (r) => r instanceof Ie ? De(r.schema) : r instanceof N ? De(r.innerType()) : r instanceof Ee ? [r.value] : r instanceof G ? r.options : r instanceof Re ? Object.keys(r.enum) : r instanceof Pe ? De(r._def.innerType) : r instanceof Te ? [void 0] : r instanceof Oe ? [null] : null;
2075
+ class Ke extends b {
2076
+ _parse(e) {
2077
+ const { ctx: t } = this._processInputParams(e);
2078
+ if (t.parsedType !== f.object)
2079
+ return p(t, {
2080
+ code: d.invalid_type,
2081
+ expected: f.object,
2082
+ received: t.parsedType
2083
+ }), g;
2084
+ const n = this.discriminator, s = t.data[n], a = this.optionsMap.get(s);
2085
+ return a ? t.common.async ? a._parseAsync({
2086
+ data: t.data,
2087
+ path: t.path,
2088
+ parent: t
2089
+ }) : a._parseSync({
2090
+ data: t.data,
2091
+ path: t.path,
2092
+ parent: t
2093
+ }) : (p(t, {
2094
+ code: d.invalid_union_discriminator,
2095
+ options: Array.from(this.optionsMap.keys()),
2096
+ path: [n]
2097
+ }), g);
2098
+ }
2099
+ get discriminator() {
2100
+ return this._def.discriminator;
2101
+ }
2102
+ get options() {
2103
+ return this._def.options;
2104
+ }
2105
+ get optionsMap() {
2106
+ return this._def.optionsMap;
2107
+ }
2108
+ /**
2109
+ * The constructor of the discriminated union schema. Its behaviour is very similar to that of the normal z.union() constructor.
2110
+ * However, it only allows a union of objects, all of which need to share a discriminator property. This property must
2111
+ * have a different value for each object in the union.
2112
+ * @param discriminator the name of the discriminator property
2113
+ * @param types an array of object schemas
2114
+ * @param params
2115
+ */
2116
+ static create(e, t, n) {
2117
+ const s = /* @__PURE__ */ new Map();
2118
+ for (const a of t) {
2119
+ const i = De(a.shape[e]);
2120
+ if (!i)
2121
+ throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);
2122
+ for (const o of i) {
2123
+ if (s.has(o))
2124
+ throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(o)}`);
2125
+ s.set(o, a);
2126
+ }
2127
+ }
2128
+ return new Ke({
2129
+ typeName: v.ZodDiscriminatedUnion,
2130
+ discriminator: e,
2131
+ options: t,
2132
+ optionsMap: s,
2133
+ ...y(n)
2134
+ });
2135
+ }
2136
+ }
2137
+ function it(r, e) {
2138
+ const t = F(r), n = F(e);
2139
+ if (r === e)
2140
+ return { valid: !0, data: r };
2141
+ if (t === f.object && n === f.object) {
2142
+ const s = x.objectKeys(e), a = x.objectKeys(r).filter((o) => s.indexOf(o) !== -1), i = { ...r, ...e };
2143
+ for (const o of a) {
2144
+ const c = it(r[o], e[o]);
2145
+ if (!c.valid)
2146
+ return { valid: !1 };
2147
+ i[o] = c.data;
2148
+ }
2149
+ return { valid: !0, data: i };
2150
+ } else if (t === f.array && n === f.array) {
2151
+ if (r.length !== e.length)
2152
+ return { valid: !1 };
2153
+ const s = [];
2154
+ for (let a = 0; a < r.length; a++) {
2155
+ const i = r[a], o = e[a], c = it(i, o);
2156
+ if (!c.valid)
2157
+ return { valid: !1 };
2158
+ s.push(c.data);
2159
+ }
2160
+ return { valid: !0, data: s };
2161
+ } else return t === f.date && n === f.date && +r == +e ? { valid: !0, data: r } : { valid: !1 };
2162
+ }
2163
+ class Ze extends b {
2164
+ _parse(e) {
2165
+ const { status: t, ctx: n } = this._processInputParams(e), s = (a, i) => {
2166
+ if (st(a) || st(i))
2167
+ return g;
2168
+ const o = it(a.value, i.value);
2169
+ return o.valid ? ((at(a) || at(i)) && t.dirty(), { status: t.value, value: o.data }) : (p(n, {
2170
+ code: d.invalid_intersection_types
2171
+ }), g);
2172
+ };
2173
+ return n.common.async ? Promise.all([
2174
+ this._def.left._parseAsync({
2175
+ data: n.data,
2176
+ path: n.path,
2177
+ parent: n
2178
+ }),
2179
+ this._def.right._parseAsync({
2180
+ data: n.data,
2181
+ path: n.path,
2182
+ parent: n
2183
+ })
2184
+ ]).then(([a, i]) => s(a, i)) : s(this._def.left._parseSync({
2185
+ data: n.data,
2186
+ path: n.path,
2187
+ parent: n
2188
+ }), this._def.right._parseSync({
2189
+ data: n.data,
2190
+ path: n.path,
2191
+ parent: n
2192
+ }));
2193
+ }
2194
+ }
2195
+ Ze.create = (r, e, t) => new Ze({
2196
+ left: r,
2197
+ right: e,
2198
+ typeName: v.ZodIntersection,
2199
+ ...y(t)
2200
+ });
2201
+ class V extends b {
2202
+ _parse(e) {
2203
+ const { status: t, ctx: n } = this._processInputParams(e);
2204
+ if (n.parsedType !== f.array)
2205
+ return p(n, {
2206
+ code: d.invalid_type,
2207
+ expected: f.array,
2208
+ received: n.parsedType
2209
+ }), g;
2210
+ if (n.data.length < this._def.items.length)
2211
+ return p(n, {
2212
+ code: d.too_small,
2213
+ minimum: this._def.items.length,
2214
+ inclusive: !0,
2215
+ exact: !1,
2216
+ type: "array"
2217
+ }), g;
2218
+ !this._def.rest && n.data.length > this._def.items.length && (p(n, {
2219
+ code: d.too_big,
2220
+ maximum: this._def.items.length,
2221
+ inclusive: !0,
2222
+ exact: !1,
2223
+ type: "array"
2224
+ }), t.dirty());
2225
+ const a = [...n.data].map((i, o) => {
2226
+ const c = this._def.items[o] || this._def.rest;
2227
+ return c ? c._parse(new L(n, i, n.path, o)) : null;
2228
+ }).filter((i) => !!i);
2229
+ return n.common.async ? Promise.all(a).then((i) => I.mergeArray(t, i)) : I.mergeArray(t, a);
2230
+ }
2231
+ get items() {
2232
+ return this._def.items;
2233
+ }
2234
+ rest(e) {
2235
+ return new V({
2236
+ ...this._def,
2237
+ rest: e
2238
+ });
2239
+ }
2240
+ }
2241
+ V.create = (r, e) => {
2242
+ if (!Array.isArray(r))
2243
+ throw new Error("You must pass an array of schemas to z.tuple([ ... ])");
2244
+ return new V({
2245
+ items: r,
2246
+ typeName: v.ZodTuple,
2247
+ rest: null,
2248
+ ...y(e)
2249
+ });
2250
+ };
2251
+ class Ce extends b {
2252
+ get keySchema() {
2253
+ return this._def.keyType;
2254
+ }
2255
+ get valueSchema() {
2256
+ return this._def.valueType;
2257
+ }
2258
+ _parse(e) {
2259
+ const { status: t, ctx: n } = this._processInputParams(e);
2260
+ if (n.parsedType !== f.object)
2261
+ return p(n, {
2262
+ code: d.invalid_type,
2263
+ expected: f.object,
2264
+ received: n.parsedType
2265
+ }), g;
2266
+ const s = [], a = this._def.keyType, i = this._def.valueType;
2267
+ for (const o in n.data)
2268
+ s.push({
2269
+ key: a._parse(new L(n, o, n.path, o)),
2270
+ value: i._parse(new L(n, n.data[o], n.path, o))
2271
+ });
2272
+ return n.common.async ? I.mergeObjectAsync(t, s) : I.mergeObjectSync(t, s);
2273
+ }
2274
+ get element() {
2275
+ return this._def.valueType;
2276
+ }
2277
+ static create(e, t, n) {
2278
+ return t instanceof b ? new Ce({
2279
+ keyType: e,
2280
+ valueType: t,
2281
+ typeName: v.ZodRecord,
2282
+ ...y(n)
2283
+ }) : new Ce({
2284
+ keyType: P.create(),
2285
+ valueType: e,
2286
+ typeName: v.ZodRecord,
2287
+ ...y(t)
2288
+ });
2289
+ }
2290
+ }
2291
+ class We extends b {
2292
+ get keySchema() {
2293
+ return this._def.keyType;
2294
+ }
2295
+ get valueSchema() {
2296
+ return this._def.valueType;
2297
+ }
2298
+ _parse(e) {
2299
+ const { status: t, ctx: n } = this._processInputParams(e);
2300
+ if (n.parsedType !== f.map)
2301
+ return p(n, {
2302
+ code: d.invalid_type,
2303
+ expected: f.map,
2304
+ received: n.parsedType
2305
+ }), g;
2306
+ const s = this._def.keyType, a = this._def.valueType, i = [...n.data.entries()].map(([o, c], u) => ({
2307
+ key: s._parse(new L(n, o, n.path, [u, "key"])),
2308
+ value: a._parse(new L(n, c, n.path, [u, "value"]))
2309
+ }));
2310
+ if (n.common.async) {
2311
+ const o = /* @__PURE__ */ new Map();
2312
+ return Promise.resolve().then(async () => {
2313
+ for (const c of i) {
2314
+ const u = await c.key, l = await c.value;
2315
+ if (u.status === "aborted" || l.status === "aborted")
2316
+ return g;
2317
+ (u.status === "dirty" || l.status === "dirty") && t.dirty(), o.set(u.value, l.value);
2318
+ }
2319
+ return { status: t.value, value: o };
2320
+ });
2321
+ } else {
2322
+ const o = /* @__PURE__ */ new Map();
2323
+ for (const c of i) {
2324
+ const u = c.key, l = c.value;
2325
+ if (u.status === "aborted" || l.status === "aborted")
2326
+ return g;
2327
+ (u.status === "dirty" || l.status === "dirty") && t.dirty(), o.set(u.value, l.value);
2328
+ }
2329
+ return { status: t.value, value: o };
2330
+ }
2331
+ }
2332
+ }
2333
+ We.create = (r, e, t) => new We({
2334
+ valueType: e,
2335
+ keyType: r,
2336
+ typeName: v.ZodMap,
2337
+ ...y(t)
2338
+ });
2339
+ class z extends b {
2340
+ _parse(e) {
2341
+ const { status: t, ctx: n } = this._processInputParams(e);
2342
+ if (n.parsedType !== f.set)
2343
+ return p(n, {
2344
+ code: d.invalid_type,
2345
+ expected: f.set,
2346
+ received: n.parsedType
2347
+ }), g;
2348
+ const s = this._def;
2349
+ s.minSize !== null && n.data.size < s.minSize.value && (p(n, {
2350
+ code: d.too_small,
2351
+ minimum: s.minSize.value,
2352
+ type: "set",
2353
+ inclusive: !0,
2354
+ exact: !1,
2355
+ message: s.minSize.message
2356
+ }), t.dirty()), s.maxSize !== null && n.data.size > s.maxSize.value && (p(n, {
2357
+ code: d.too_big,
2358
+ maximum: s.maxSize.value,
2359
+ type: "set",
2360
+ inclusive: !0,
2361
+ exact: !1,
2362
+ message: s.maxSize.message
2363
+ }), t.dirty());
2364
+ const a = this._def.valueType;
2365
+ function i(c) {
2366
+ const u = /* @__PURE__ */ new Set();
2367
+ for (const l of c) {
2368
+ if (l.status === "aborted")
2369
+ return g;
2370
+ l.status === "dirty" && t.dirty(), u.add(l.value);
2371
+ }
2372
+ return { status: t.value, value: u };
2373
+ }
2374
+ const o = [...n.data.values()].map((c, u) => a._parse(new L(n, c, n.path, u)));
2375
+ return n.common.async ? Promise.all(o).then((c) => i(c)) : i(o);
2376
+ }
2377
+ min(e, t) {
2378
+ return new z({
2379
+ ...this._def,
2380
+ minSize: { value: e, message: m.toString(t) }
2381
+ });
2382
+ }
2383
+ max(e, t) {
2384
+ return new z({
2385
+ ...this._def,
2386
+ maxSize: { value: e, message: m.toString(t) }
2387
+ });
2388
+ }
2389
+ size(e, t) {
2390
+ return this.min(e, t).max(e, t);
2391
+ }
2392
+ nonempty(e) {
2393
+ return this.min(1, e);
2394
+ }
2395
+ }
2396
+ z.create = (r, e) => new z({
2397
+ valueType: r,
2398
+ minSize: null,
2399
+ maxSize: null,
2400
+ typeName: v.ZodSet,
2401
+ ...y(e)
2402
+ });
2403
+ class de extends b {
2404
+ constructor() {
2405
+ super(...arguments), this.validate = this.implement;
2406
+ }
2407
+ _parse(e) {
2408
+ const { ctx: t } = this._processInputParams(e);
2409
+ if (t.parsedType !== f.function)
2410
+ return p(t, {
2411
+ code: d.invalid_type,
2412
+ expected: f.function,
2413
+ received: t.parsedType
2414
+ }), g;
2415
+ function n(o, c) {
2416
+ return Ve({
2417
+ data: o,
2418
+ path: t.path,
2419
+ errorMaps: [
2420
+ t.common.contextualErrorMap,
2421
+ t.schemaErrorMap,
2422
+ Le(),
2423
+ xe
2424
+ ].filter((u) => !!u),
2425
+ issueData: {
2426
+ code: d.invalid_arguments,
2427
+ argumentsError: c
2428
+ }
2429
+ });
2430
+ }
2431
+ function s(o, c) {
2432
+ return Ve({
2433
+ data: o,
2434
+ path: t.path,
2435
+ errorMaps: [
2436
+ t.common.contextualErrorMap,
2437
+ t.schemaErrorMap,
2438
+ Le(),
2439
+ xe
2440
+ ].filter((u) => !!u),
2441
+ issueData: {
2442
+ code: d.invalid_return_type,
2443
+ returnTypeError: c
2444
+ }
2445
+ });
2446
+ }
2447
+ const a = { errorMap: t.common.contextualErrorMap }, i = t.data;
2448
+ if (this._def.returns instanceof pe) {
2449
+ const o = this;
2450
+ return E(async function(...c) {
2451
+ const u = new A([]), l = await o._def.args.parseAsync(c, a).catch((k) => {
2452
+ throw u.addIssue(n(c, k)), u;
2453
+ }), h = await Reflect.apply(i, this, l);
2454
+ return await o._def.returns._def.type.parseAsync(h, a).catch((k) => {
2455
+ throw u.addIssue(s(h, k)), u;
2456
+ });
2457
+ });
2458
+ } else {
2459
+ const o = this;
2460
+ return E(function(...c) {
2461
+ const u = o._def.args.safeParse(c, a);
2462
+ if (!u.success)
2463
+ throw new A([n(c, u.error)]);
2464
+ const l = Reflect.apply(i, this, u.data), h = o._def.returns.safeParse(l, a);
2465
+ if (!h.success)
2466
+ throw new A([s(l, h.error)]);
2467
+ return h.data;
2468
+ });
2469
+ }
2470
+ }
2471
+ parameters() {
2472
+ return this._def.args;
2473
+ }
2474
+ returnType() {
2475
+ return this._def.returns;
2476
+ }
2477
+ args(...e) {
2478
+ return new de({
2479
+ ...this._def,
2480
+ args: V.create(e).rest(Q.create())
2481
+ });
2482
+ }
2483
+ returns(e) {
2484
+ return new de({
2485
+ ...this._def,
2486
+ returns: e
2487
+ });
2488
+ }
2489
+ implement(e) {
2490
+ return this.parse(e);
2491
+ }
2492
+ strictImplement(e) {
2493
+ return this.parse(e);
2494
+ }
2495
+ static create(e, t, n) {
2496
+ return new de({
2497
+ args: e || V.create([]).rest(Q.create()),
2498
+ returns: t || Q.create(),
2499
+ typeName: v.ZodFunction,
2500
+ ...y(n)
2501
+ });
2502
+ }
2503
+ }
2504
+ class Ie extends b {
2505
+ get schema() {
2506
+ return this._def.getter();
2507
+ }
2508
+ _parse(e) {
2509
+ const { ctx: t } = this._processInputParams(e);
2510
+ return this._def.getter()._parse({ data: t.data, path: t.path, parent: t });
2511
+ }
2512
+ }
2513
+ Ie.create = (r, e) => new Ie({
2514
+ getter: r,
2515
+ typeName: v.ZodLazy,
2516
+ ...y(e)
2517
+ });
2518
+ class Ee extends b {
2519
+ _parse(e) {
2520
+ if (e.data !== this._def.value) {
2521
+ const t = this._getOrReturnCtx(e);
2522
+ return p(t, {
2523
+ received: t.data,
2524
+ code: d.invalid_literal,
2525
+ expected: this._def.value
2526
+ }), g;
2527
+ }
2528
+ return { status: "valid", value: e.data };
2529
+ }
2530
+ get value() {
2531
+ return this._def.value;
2532
+ }
2533
+ }
2534
+ Ee.create = (r, e) => new Ee({
2535
+ value: r,
2536
+ typeName: v.ZodLiteral,
2537
+ ...y(e)
2538
+ });
2539
+ function bt(r, e) {
2540
+ return new G({
2541
+ values: r,
2542
+ typeName: v.ZodEnum,
2543
+ ...y(e)
2544
+ });
2545
+ }
2546
+ class G extends b {
2547
+ _parse(e) {
2548
+ if (typeof e.data != "string") {
2549
+ const t = this._getOrReturnCtx(e), n = this._def.values;
2550
+ return p(t, {
2551
+ expected: x.joinValues(n),
2552
+ received: t.parsedType,
2553
+ code: d.invalid_type
2554
+ }), g;
2555
+ }
2556
+ if (this._def.values.indexOf(e.data) === -1) {
2557
+ const t = this._getOrReturnCtx(e), n = this._def.values;
2558
+ return p(t, {
2559
+ received: t.data,
2560
+ code: d.invalid_enum_value,
2561
+ options: n
2562
+ }), g;
2563
+ }
2564
+ return E(e.data);
2565
+ }
2566
+ get options() {
2567
+ return this._def.values;
2568
+ }
2569
+ get enum() {
2570
+ const e = {};
2571
+ for (const t of this._def.values)
2572
+ e[t] = t;
2573
+ return e;
2574
+ }
2575
+ get Values() {
2576
+ const e = {};
2577
+ for (const t of this._def.values)
2578
+ e[t] = t;
2579
+ return e;
2580
+ }
2581
+ get Enum() {
2582
+ const e = {};
2583
+ for (const t of this._def.values)
2584
+ e[t] = t;
2585
+ return e;
2586
+ }
2587
+ extract(e) {
2588
+ return G.create(e);
2589
+ }
2590
+ exclude(e) {
2591
+ return G.create(this.options.filter((t) => !e.includes(t)));
2592
+ }
2593
+ }
2594
+ G.create = bt;
2595
+ class Re extends b {
2596
+ _parse(e) {
2597
+ const t = x.getValidEnumValues(this._def.values), n = this._getOrReturnCtx(e);
2598
+ if (n.parsedType !== f.string && n.parsedType !== f.number) {
2599
+ const s = x.objectValues(t);
2600
+ return p(n, {
2601
+ expected: x.joinValues(s),
2602
+ received: n.parsedType,
2603
+ code: d.invalid_type
2604
+ }), g;
2605
+ }
2606
+ if (t.indexOf(e.data) === -1) {
2607
+ const s = x.objectValues(t);
2608
+ return p(n, {
2609
+ received: n.data,
2610
+ code: d.invalid_enum_value,
2611
+ options: s
2612
+ }), g;
2613
+ }
2614
+ return E(e.data);
2615
+ }
2616
+ get enum() {
2617
+ return this._def.values;
2618
+ }
2619
+ }
2620
+ Re.create = (r, e) => new Re({
2621
+ values: r,
2622
+ typeName: v.ZodNativeEnum,
2623
+ ...y(e)
2624
+ });
2625
+ class pe extends b {
2626
+ unwrap() {
2627
+ return this._def.type;
2628
+ }
2629
+ _parse(e) {
2630
+ const { ctx: t } = this._processInputParams(e);
2631
+ if (t.parsedType !== f.promise && t.common.async === !1)
2632
+ return p(t, {
2633
+ code: d.invalid_type,
2634
+ expected: f.promise,
2635
+ received: t.parsedType
2636
+ }), g;
2637
+ const n = t.parsedType === f.promise ? t.data : Promise.resolve(t.data);
2638
+ return E(n.then((s) => this._def.type.parseAsync(s, {
2639
+ path: t.path,
2640
+ errorMap: t.common.contextualErrorMap
2641
+ })));
2642
+ }
2643
+ }
2644
+ pe.create = (r, e) => new pe({
2645
+ type: r,
2646
+ typeName: v.ZodPromise,
2647
+ ...y(e)
2648
+ });
2649
+ class N extends b {
2650
+ innerType() {
2651
+ return this._def.schema;
2652
+ }
2653
+ sourceType() {
2654
+ return this._def.schema._def.typeName === v.ZodEffects ? this._def.schema.sourceType() : this._def.schema;
2655
+ }
2656
+ _parse(e) {
2657
+ const { status: t, ctx: n } = this._processInputParams(e), s = this._def.effect || null, a = {
2658
+ addIssue: (i) => {
2659
+ p(n, i), i.fatal ? t.abort() : t.dirty();
2660
+ },
2661
+ get path() {
2662
+ return n.path;
2663
+ }
2664
+ };
2665
+ if (a.addIssue = a.addIssue.bind(a), s.type === "preprocess") {
2666
+ const i = s.transform(n.data, a);
2667
+ return n.common.issues.length ? {
2668
+ status: "dirty",
2669
+ value: n.data
2670
+ } : n.common.async ? Promise.resolve(i).then((o) => this._def.schema._parseAsync({
2671
+ data: o,
2672
+ path: n.path,
2673
+ parent: n
2674
+ })) : this._def.schema._parseSync({
2675
+ data: i,
2676
+ path: n.path,
2677
+ parent: n
2678
+ });
2679
+ }
2680
+ if (s.type === "refinement") {
2681
+ const i = (o) => {
2682
+ const c = s.refinement(o, a);
2683
+ if (n.common.async)
2684
+ return Promise.resolve(c);
2685
+ if (c instanceof Promise)
2686
+ throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");
2687
+ return o;
2688
+ };
2689
+ if (n.common.async === !1) {
2690
+ const o = this._def.schema._parseSync({
2691
+ data: n.data,
2692
+ path: n.path,
2693
+ parent: n
2694
+ });
2695
+ return o.status === "aborted" ? g : (o.status === "dirty" && t.dirty(), i(o.value), { status: t.value, value: o.value });
2696
+ } else
2697
+ return this._def.schema._parseAsync({ data: n.data, path: n.path, parent: n }).then((o) => o.status === "aborted" ? g : (o.status === "dirty" && t.dirty(), i(o.value).then(() => ({ status: t.value, value: o.value }))));
2698
+ }
2699
+ if (s.type === "transform")
2700
+ if (n.common.async === !1) {
2701
+ const i = this._def.schema._parseSync({
2702
+ data: n.data,
2703
+ path: n.path,
2704
+ parent: n
2705
+ });
2706
+ if (!we(i))
2707
+ return i;
2708
+ const o = s.transform(i.value, a);
2709
+ if (o instanceof Promise)
2710
+ throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");
2711
+ return { status: t.value, value: o };
2712
+ } else
2713
+ return this._def.schema._parseAsync({ data: n.data, path: n.path, parent: n }).then((i) => we(i) ? Promise.resolve(s.transform(i.value, a)).then((o) => ({ status: t.value, value: o })) : i);
2714
+ x.assertNever(s);
2715
+ }
2716
+ }
2717
+ N.create = (r, e, t) => new N({
2718
+ schema: r,
2719
+ typeName: v.ZodEffects,
2720
+ effect: e,
2721
+ ...y(t)
2722
+ });
2723
+ N.createWithPreprocess = (r, e, t) => new N({
2724
+ schema: e,
2725
+ effect: { type: "preprocess", transform: r },
2726
+ typeName: v.ZodEffects,
2727
+ ...y(t)
2728
+ });
2729
+ class B extends b {
2730
+ _parse(e) {
2731
+ return this._getType(e) === f.undefined ? E(void 0) : this._def.innerType._parse(e);
2732
+ }
2733
+ unwrap() {
2734
+ return this._def.innerType;
2735
+ }
2736
+ }
2737
+ B.create = (r, e) => new B({
2738
+ innerType: r,
2739
+ typeName: v.ZodOptional,
2740
+ ...y(e)
2741
+ });
2742
+ class ee extends b {
2743
+ _parse(e) {
2744
+ return this._getType(e) === f.null ? E(null) : this._def.innerType._parse(e);
2745
+ }
2746
+ unwrap() {
2747
+ return this._def.innerType;
2748
+ }
2749
+ }
2750
+ ee.create = (r, e) => new ee({
2751
+ innerType: r,
2752
+ typeName: v.ZodNullable,
2753
+ ...y(e)
2754
+ });
2755
+ class Pe extends b {
2756
+ _parse(e) {
2757
+ const { ctx: t } = this._processInputParams(e);
2758
+ let n = t.data;
2759
+ return t.parsedType === f.undefined && (n = this._def.defaultValue()), this._def.innerType._parse({
2760
+ data: n,
2761
+ path: t.path,
2762
+ parent: t
2763
+ });
2764
+ }
2765
+ removeDefault() {
2766
+ return this._def.innerType;
2767
+ }
2768
+ }
2769
+ Pe.create = (r, e) => new Pe({
2770
+ innerType: r,
2771
+ typeName: v.ZodDefault,
2772
+ defaultValue: typeof e.default == "function" ? e.default : () => e.default,
2773
+ ...y(e)
2774
+ });
2775
+ class Fe extends b {
2776
+ _parse(e) {
2777
+ const { ctx: t } = this._processInputParams(e), n = {
2778
+ ...t,
2779
+ common: {
2780
+ ...t.common,
2781
+ issues: []
2782
+ }
2783
+ }, s = this._def.innerType._parse({
2784
+ data: n.data,
2785
+ path: n.path,
2786
+ parent: {
2787
+ ...n
2788
+ }
2789
+ });
2790
+ return Ue(s) ? s.then((a) => ({
2791
+ status: "valid",
2792
+ value: a.status === "valid" ? a.value : this._def.catchValue({
2793
+ get error() {
2794
+ return new A(n.common.issues);
2795
+ },
2796
+ input: n.data
2797
+ })
2798
+ })) : {
2799
+ status: "valid",
2800
+ value: s.status === "valid" ? s.value : this._def.catchValue({
2801
+ get error() {
2802
+ return new A(n.common.issues);
2803
+ },
2804
+ input: n.data
2805
+ })
2806
+ };
2807
+ }
2808
+ removeCatch() {
2809
+ return this._def.innerType;
2810
+ }
2811
+ }
2812
+ Fe.create = (r, e) => new Fe({
2813
+ innerType: r,
2814
+ typeName: v.ZodCatch,
2815
+ catchValue: typeof e.catch == "function" ? e.catch : () => e.catch,
2816
+ ...y(e)
2817
+ });
2818
+ class He extends b {
2819
+ _parse(e) {
2820
+ if (this._getType(e) !== f.nan) {
2821
+ const n = this._getOrReturnCtx(e);
2822
+ return p(n, {
2823
+ code: d.invalid_type,
2824
+ expected: f.nan,
2825
+ received: n.parsedType
2826
+ }), g;
2827
+ }
2828
+ return { status: "valid", value: e.data };
2829
+ }
2830
+ }
2831
+ He.create = (r) => new He({
2832
+ typeName: v.ZodNaN,
2833
+ ...y(r)
2834
+ });
2835
+ const Jt = Symbol("zod_brand");
2836
+ class xt extends b {
2837
+ _parse(e) {
2838
+ const { ctx: t } = this._processInputParams(e), n = t.data;
2839
+ return this._def.type._parse({
2840
+ data: n,
2841
+ path: t.path,
2842
+ parent: t
2843
+ });
2844
+ }
2845
+ unwrap() {
2846
+ return this._def.type;
2847
+ }
2848
+ }
2849
+ class Ae extends b {
2850
+ _parse(e) {
2851
+ const { status: t, ctx: n } = this._processInputParams(e);
2852
+ if (n.common.async)
2853
+ return (async () => {
2854
+ const a = await this._def.in._parseAsync({
2855
+ data: n.data,
2856
+ path: n.path,
2857
+ parent: n
2858
+ });
2859
+ return a.status === "aborted" ? g : a.status === "dirty" ? (t.dirty(), _t(a.value)) : this._def.out._parseAsync({
2860
+ data: a.value,
2861
+ path: n.path,
2862
+ parent: n
2863
+ });
2864
+ })();
2865
+ {
2866
+ const s = this._def.in._parseSync({
2867
+ data: n.data,
2868
+ path: n.path,
2869
+ parent: n
2870
+ });
2871
+ return s.status === "aborted" ? g : s.status === "dirty" ? (t.dirty(), {
2872
+ status: "dirty",
2873
+ value: s.value
2874
+ }) : this._def.out._parseSync({
2875
+ data: s.value,
2876
+ path: n.path,
2877
+ parent: n
2878
+ });
2879
+ }
2880
+ }
2881
+ static create(e, t) {
2882
+ return new Ae({
2883
+ in: e,
2884
+ out: t,
2885
+ typeName: v.ZodPipeline
2886
+ });
2887
+ }
2888
+ }
2889
+ class Je extends b {
2890
+ _parse(e) {
2891
+ const t = this._def.innerType._parse(e);
2892
+ return we(t) && (t.value = Object.freeze(t.value)), t;
2893
+ }
2894
+ }
2895
+ Je.create = (r, e) => new Je({
2896
+ innerType: r,
2897
+ typeName: v.ZodReadonly,
2898
+ ...y(e)
2899
+ });
2900
+ const wt = (r, e = {}, t) => r ? fe.create().superRefine((n, s) => {
2901
+ var a, i;
2902
+ if (!r(n)) {
2903
+ const o = typeof e == "function" ? e(n) : typeof e == "string" ? { message: e } : e, c = (i = (a = o.fatal) !== null && a !== void 0 ? a : t) !== null && i !== void 0 ? i : !0, u = typeof o == "string" ? { message: o } : o;
2904
+ s.addIssue({ code: "custom", ...u, fatal: c });
2905
+ }
2906
+ }) : fe.create(), Gt = {
2907
+ object: T.lazycreate
2908
+ };
2909
+ var v;
2910
+ (function(r) {
2911
+ 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";
2912
+ })(v || (v = {}));
2913
+ const Yt = (r, e = {
2914
+ message: `Input not instance of ${r.name}`
2915
+ }) => wt((t) => t instanceof r, e), kt = P.create, Tt = H.create, Kt = He.create, Qt = J.create, Ot = ke.create, Xt = X.create, zt = Be.create, en = Te.create, tn = Oe.create, nn = fe.create, rn = Q.create, sn = q.create, an = qe.create, on = S.create, cn = T.create, un = T.strictCreate, dn = je.create, ln = Ke.create, fn = Ze.create, pn = V.create, hn = Ce.create, mn = We.create, vn = z.create, gn = de.create, yn = Ie.create, _n = Ee.create, bn = G.create, xn = Re.create, wn = pe.create, lt = N.create, kn = B.create, Tn = ee.create, On = N.createWithPreprocess, jn = Ae.create, Zn = () => kt().optional(), Cn = () => Tt().optional(), In = () => Ot().optional(), En = {
2916
+ string: (r) => P.create({ ...r, coerce: !0 }),
2917
+ number: (r) => H.create({ ...r, coerce: !0 }),
2918
+ boolean: (r) => ke.create({
2919
+ ...r,
2920
+ coerce: !0
2921
+ }),
2922
+ bigint: (r) => J.create({ ...r, coerce: !0 }),
2923
+ date: (r) => X.create({ ...r, coerce: !0 })
2924
+ }, Rn = g;
2925
+ var Pn = /* @__PURE__ */ Object.freeze({
2926
+ __proto__: null,
2927
+ defaultErrorMap: xe,
2928
+ setErrorMap: St,
2929
+ getErrorMap: Le,
2930
+ makeIssue: Ve,
2931
+ EMPTY_PATH: Nt,
2932
+ addIssueToContext: p,
2933
+ ParseStatus: I,
2934
+ INVALID: g,
2935
+ DIRTY: _t,
2936
+ OK: E,
2937
+ isAborted: st,
2938
+ isDirty: at,
2939
+ isValid: we,
2940
+ isAsync: Ue,
2941
+ get util() {
2942
+ return x;
2943
+ },
2944
+ get objectUtil() {
2945
+ return rt;
2946
+ },
2947
+ ZodParsedType: f,
2948
+ getParsedType: F,
2949
+ ZodType: b,
2950
+ ZodString: P,
2951
+ ZodNumber: H,
2952
+ ZodBigInt: J,
2953
+ ZodBoolean: ke,
2954
+ ZodDate: X,
2955
+ ZodSymbol: Be,
2956
+ ZodUndefined: Te,
2957
+ ZodNull: Oe,
2958
+ ZodAny: fe,
2959
+ ZodUnknown: Q,
2960
+ ZodNever: q,
2961
+ ZodVoid: qe,
2962
+ ZodArray: S,
2963
+ ZodObject: T,
2964
+ ZodUnion: je,
2965
+ ZodDiscriminatedUnion: Ke,
2966
+ ZodIntersection: Ze,
2967
+ ZodTuple: V,
2968
+ ZodRecord: Ce,
2969
+ ZodMap: We,
2970
+ ZodSet: z,
2971
+ ZodFunction: de,
2972
+ ZodLazy: Ie,
2973
+ ZodLiteral: Ee,
2974
+ ZodEnum: G,
2975
+ ZodNativeEnum: Re,
2976
+ ZodPromise: pe,
2977
+ ZodEffects: N,
2978
+ ZodTransformer: N,
2979
+ ZodOptional: B,
2980
+ ZodNullable: ee,
2981
+ ZodDefault: Pe,
2982
+ ZodCatch: Fe,
2983
+ ZodNaN: He,
2984
+ BRAND: Jt,
2985
+ ZodBranded: xt,
2986
+ ZodPipeline: Ae,
2987
+ ZodReadonly: Je,
2988
+ custom: wt,
2989
+ Schema: b,
2990
+ ZodSchema: b,
2991
+ late: Gt,
2992
+ get ZodFirstPartyTypeKind() {
2993
+ return v;
2994
+ },
2995
+ coerce: En,
2996
+ any: nn,
2997
+ array: on,
2998
+ bigint: Qt,
2999
+ boolean: Ot,
3000
+ date: Xt,
3001
+ discriminatedUnion: ln,
3002
+ effect: lt,
3003
+ enum: bn,
3004
+ function: gn,
3005
+ instanceof: Yt,
3006
+ intersection: fn,
3007
+ lazy: yn,
3008
+ literal: _n,
3009
+ map: mn,
3010
+ nan: Kt,
3011
+ nativeEnum: xn,
3012
+ never: sn,
3013
+ null: tn,
3014
+ nullable: Tn,
3015
+ number: Tt,
3016
+ object: cn,
3017
+ oboolean: In,
3018
+ onumber: Cn,
3019
+ optional: kn,
3020
+ ostring: Zn,
3021
+ pipeline: jn,
3022
+ preprocess: On,
3023
+ promise: wn,
3024
+ record: hn,
3025
+ set: vn,
3026
+ strictObject: un,
3027
+ string: kt,
3028
+ symbol: zt,
3029
+ transformer: lt,
3030
+ tuple: pn,
3031
+ undefined: en,
3032
+ union: dn,
3033
+ unknown: rn,
3034
+ void: an,
3035
+ NEVER: Rn,
3036
+ ZodIssueCode: d,
3037
+ quotelessJson: At,
3038
+ ZodError: A
3039
+ });
3040
+ function ye(r, e) {
3041
+ var t = {};
3042
+ for (var n in r) Object.prototype.hasOwnProperty.call(r, n) && e.indexOf(n) < 0 && (t[n] = r[n]);
3043
+ if (r != null && typeof Object.getOwnPropertySymbols == "function")
3044
+ for (var s = 0, n = Object.getOwnPropertySymbols(r); s < n.length; s++)
3045
+ e.indexOf(n[s]) < 0 && Object.prototype.propertyIsEnumerable.call(r, n[s]) && (t[n[s]] = r[n[s]]);
3046
+ return t;
3047
+ }
3048
+ function _(r, e) {
3049
+ var t;
3050
+ return ((t = r == null ? void 0 : r._def) === null || t === void 0 ? void 0 : t.typeName) === e;
3051
+ }
3052
+ function An(r) {
3053
+ return "_def" in r;
3054
+ }
3055
+ function me(r, e) {
3056
+ const t = r.ZodType.prototype[e];
3057
+ r.ZodType.prototype[e] = function(...n) {
3058
+ const s = t.apply(this, n);
3059
+ return s._def.openapi = this._def.openapi, s;
3060
+ };
3061
+ }
3062
+ function Sn(r) {
3063
+ if (typeof r.ZodType.prototype.openapi < "u")
3064
+ return;
3065
+ r.ZodType.prototype.openapi = function(s, a) {
3066
+ var i, o, c, u, l, h;
3067
+ const j = typeof s == "string" ? a : s, k = j ?? {}, { param: C } = k, O = ye(k, ["param"]), R = Object.assign(Object.assign({}, (i = this._def.openapi) === null || i === void 0 ? void 0 : i._internal), typeof s == "string" ? { refId: s } : void 0), Y = Object.assign(Object.assign(Object.assign({}, (o = this._def.openapi) === null || o === void 0 ? void 0 : o.metadata), O), !((u = (c = this._def.openapi) === null || c === void 0 ? void 0 : c.metadata) === null || u === void 0) && u.param || C ? {
3068
+ param: Object.assign(Object.assign({}, (h = (l = this._def.openapi) === null || l === void 0 ? void 0 : l.metadata) === null || h === void 0 ? void 0 : h.param), C)
3069
+ } : void 0), he = new this.constructor(Object.assign(Object.assign({}, this._def), { openapi: Object.assign(Object.assign({}, Object.keys(R).length > 0 ? { _internal: R } : void 0), Object.keys(Y).length > 0 ? { metadata: Y } : void 0) }));
3070
+ if (_(this, "ZodObject")) {
3071
+ const Se = this.extend;
3072
+ he.extend = function(...Ne) {
3073
+ var te, ne, re, se, ae, ie;
3074
+ const Xe = Se.apply(this, Ne);
3075
+ return Xe._def.openapi = {
3076
+ _internal: {
3077
+ extendedFrom: !((ne = (te = this._def.openapi) === null || te === void 0 ? void 0 : te._internal) === null || ne === void 0) && ne.refId ? { refId: (se = (re = this._def.openapi) === null || re === void 0 ? void 0 : re._internal) === null || se === void 0 ? void 0 : se.refId, schema: this } : (ae = this._def.openapi) === null || ae === void 0 ? void 0 : ae._internal.extendedFrom
3078
+ },
3079
+ metadata: (ie = Xe._def.openapi) === null || ie === void 0 ? void 0 : ie.metadata
3080
+ }, Xe;
3081
+ };
3082
+ }
3083
+ return he;
3084
+ }, me(r, "optional"), me(r, "nullable"), me(r, "default"), me(r, "transform"), me(r, "refine");
3085
+ const e = r.ZodObject.prototype.deepPartial;
3086
+ r.ZodObject.prototype.deepPartial = function() {
3087
+ const s = this._def.shape(), a = e.apply(this), i = a._def.shape();
3088
+ return Object.entries(i).forEach(([o, c]) => {
3089
+ var u, l;
3090
+ c._def.openapi = (l = (u = s[o]) === null || u === void 0 ? void 0 : u._def) === null || l === void 0 ? void 0 : l.openapi;
3091
+ }), a._def.openapi = void 0, a;
3092
+ };
3093
+ const t = r.ZodObject.prototype.pick;
3094
+ r.ZodObject.prototype.pick = function(...s) {
3095
+ const a = t.apply(this, s);
3096
+ return a._def.openapi = void 0, a;
3097
+ };
3098
+ const n = r.ZodObject.prototype.omit;
3099
+ r.ZodObject.prototype.omit = function(...s) {
3100
+ const a = n.apply(this, s);
3101
+ return a._def.openapi = void 0, a;
3102
+ };
3103
+ }
3104
+ function Ge(r, e) {
3105
+ if (r == null || e === null || e === void 0)
3106
+ return r === e;
3107
+ if (r === e || r.valueOf() === e.valueOf())
3108
+ return !0;
3109
+ if (Array.isArray(r) && (!Array.isArray(e) || r.length !== e.length) || !(r instanceof Object) || !(e instanceof Object))
3110
+ return !1;
3111
+ const t = Object.keys(r);
3112
+ return Object.keys(e).every((n) => t.indexOf(n) !== -1) && t.every((n) => Ge(r[n], e[n]));
3113
+ }
3114
+ class Nn {
3115
+ constructor() {
3116
+ this.buckets = /* @__PURE__ */ new Map();
3117
+ }
3118
+ put(e) {
3119
+ const t = this.hashCodeOf(e), n = this.buckets.get(t);
3120
+ if (!n) {
3121
+ this.buckets.set(t, [e]);
3122
+ return;
3123
+ }
3124
+ n.some((a) => Ge(a, e)) || n.push(e);
3125
+ }
3126
+ contains(e) {
3127
+ const t = this.hashCodeOf(e), n = this.buckets.get(t);
3128
+ return n ? n.some((s) => Ge(s, e)) : !1;
3129
+ }
3130
+ values() {
3131
+ return [...this.buckets.values()].flat();
3132
+ }
3133
+ stats() {
3134
+ let e = 0, t = 0, n = 0;
3135
+ for (const a of this.buckets.values())
3136
+ e += 1, t += a.length, a.length > 1 && (n += 1);
3137
+ const s = e / t;
3138
+ return { totalBuckets: e, collisions: n, totalValues: t, hashEffectiveness: s };
3139
+ }
3140
+ hashCodeOf(e) {
3141
+ let t = 0;
3142
+ if (Array.isArray(e)) {
3143
+ for (let n = 0; n < e.length; n++)
3144
+ t ^= this.hashCodeOf(e[n]) * n;
3145
+ return t;
3146
+ }
3147
+ if (typeof e == "string") {
3148
+ for (let n = 0; n < e.length; n++)
3149
+ t ^= e.charCodeAt(n) * n;
3150
+ return t;
3151
+ }
3152
+ if (typeof e == "number")
3153
+ return e;
3154
+ if (typeof e == "object")
3155
+ for (const [n, s] of Object.entries(e))
3156
+ t ^= this.hashCodeOf(n) + this.hashCodeOf(s ?? "");
3157
+ return t;
3158
+ }
3159
+ }
3160
+ function _e(r) {
3161
+ return r == null;
3162
+ }
3163
+ function be(r, e) {
3164
+ const t = {};
3165
+ return Object.entries(r).forEach(([n, s]) => {
3166
+ t[n] = e(s);
3167
+ }), t;
3168
+ }
3169
+ function Mn(r, e) {
3170
+ const t = {};
3171
+ return Object.entries(r).forEach(([n, s]) => {
3172
+ e.some((a) => a === n) || (t[n] = s);
3173
+ }), t;
3174
+ }
3175
+ function le(r, e) {
3176
+ const t = {};
3177
+ return Object.entries(r).forEach(([n, s]) => {
3178
+ e(s, n) || (t[n] = s);
3179
+ }), t;
3180
+ }
3181
+ function ft(r) {
3182
+ return r.filter((e) => !_e(e));
3183
+ }
3184
+ const ot = Ge;
3185
+ function Dn(r) {
3186
+ const e = new Nn();
3187
+ return r.forEach((t) => e.put(t)), [...e.values()];
3188
+ }
3189
+ function jt(r) {
3190
+ return typeof r == "string";
3191
+ }
3192
+ class $n {
3193
+ constructor(e) {
3194
+ this.parents = e, this._definitions = [];
3195
+ }
3196
+ get definitions() {
3197
+ var e, t;
3198
+ return [...(t = (e = this.parents) === null || e === void 0 ? void 0 : e.flatMap((s) => s.definitions)) !== null && t !== void 0 ? t : [], ...this._definitions];
3199
+ }
3200
+ /**
3201
+ * Registers a new component schema under /components/schemas/${name}
3202
+ */
3203
+ register(e, t) {
3204
+ const n = this.schemaWithRefId(e, t);
3205
+ return this._definitions.push({ type: "schema", schema: n }), n;
3206
+ }
3207
+ /**
3208
+ * Registers a new parameter schema under /components/parameters/${name}
3209
+ */
3210
+ registerParameter(e, t) {
3211
+ var n, s, a;
3212
+ const i = this.schemaWithRefId(e, t), o = (n = i._def.openapi) === null || n === void 0 ? void 0 : n.metadata, c = i.openapi(Object.assign(Object.assign({}, o), { param: Object.assign(Object.assign({}, o == null ? void 0 : o.param), { name: (a = (s = o == null ? void 0 : o.param) === null || s === void 0 ? void 0 : s.name) !== null && a !== void 0 ? a : e }) }));
3213
+ return this._definitions.push({
3214
+ type: "parameter",
3215
+ schema: c
3216
+ }), c;
3217
+ }
3218
+ /**
3219
+ * Registers a new path that would be generated under paths:
3220
+ */
3221
+ registerPath(e) {
3222
+ this._definitions.push({
3223
+ type: "route",
3224
+ route: e
3225
+ });
3226
+ }
3227
+ /**
3228
+ * Registers a new webhook that would be generated under webhooks:
3229
+ */
3230
+ registerWebhook(e) {
3231
+ this._definitions.push({
3232
+ type: "webhook",
3233
+ webhook: e
3234
+ });
3235
+ }
3236
+ /**
3237
+ * Registers a raw OpenAPI component. Use this if you have a simple object instead of a Zod schema.
3238
+ *
3239
+ * @param type The component type, e.g. `schemas`, `responses`, `securitySchemes`, etc.
3240
+ * @param name The name of the object, it is the key under the component
3241
+ * type in the resulting OpenAPI document
3242
+ * @param component The actual object to put there
3243
+ */
3244
+ registerComponent(e, t, n) {
3245
+ return this._definitions.push({
3246
+ type: "component",
3247
+ componentType: e,
3248
+ name: t,
3249
+ component: n
3250
+ }), {
3251
+ name: t,
3252
+ ref: { $ref: `#/components/${e}/${t}` }
3253
+ };
3254
+ }
3255
+ schemaWithRefId(e, t) {
3256
+ return t.openapi(e);
3257
+ }
3258
+ }
3259
+ class Qe {
3260
+ constructor(e) {
3261
+ this.message = e;
3262
+ }
3263
+ }
3264
+ class ve extends Qe {
3265
+ constructor(e, t) {
3266
+ super(e), this.data = t;
3267
+ }
3268
+ }
3269
+ class Ye extends Qe {
3270
+ constructor(e) {
3271
+ super(`Missing parameter data, please specify \`${e.missingField}\` and other OpenAPI parameter props using the \`param\` field of \`ZodSchema.openapi\``), this.data = e;
3272
+ }
3273
+ }
3274
+ function ge(r, e) {
3275
+ try {
3276
+ return r();
3277
+ } catch (t) {
3278
+ throw t instanceof Ye ? new Ye(Object.assign(Object.assign({}, t.data), e)) : t;
3279
+ }
3280
+ }
3281
+ class Ln extends Qe {
3282
+ constructor(e) {
3283
+ super("Unknown zod object type, please specify `type` and other OpenAPI props using `ZodSchema.openapi`."), this.data = e;
3284
+ }
3285
+ }
3286
+ class w {
3287
+ static getMetadata(e) {
3288
+ var t;
3289
+ const n = this.unwrapChained(e), s = e._def.openapi ? e._def.openapi : n._def.openapi, a = (t = e.description) !== null && t !== void 0 ? t : n.description;
3290
+ return {
3291
+ _internal: s == null ? void 0 : s._internal,
3292
+ metadata: Object.assign({ description: a }, s == null ? void 0 : s.metadata)
3293
+ };
3294
+ }
3295
+ static getInternalMetadata(e) {
3296
+ const t = this.unwrapChained(e), n = e._def.openapi ? e._def.openapi : t._def.openapi;
3297
+ return n == null ? void 0 : n._internal;
3298
+ }
3299
+ static getParamMetadata(e) {
3300
+ var t, n;
3301
+ const s = this.unwrapChained(e), a = e._def.openapi ? e._def.openapi : s._def.openapi, i = (t = e.description) !== null && t !== void 0 ? t : s.description;
3302
+ return {
3303
+ _internal: a == null ? void 0 : a._internal,
3304
+ metadata: Object.assign(Object.assign({}, a == null ? void 0 : a.metadata), {
3305
+ // A description provided from .openapi() should be taken with higher precedence
3306
+ param: Object.assign({ description: i }, (n = a == null ? void 0 : a.metadata) === null || n === void 0 ? void 0 : n.param)
3307
+ })
3308
+ };
3309
+ }
3310
+ /**
3311
+ * A method that omits all custom keys added to the regular OpenAPI
3312
+ * metadata properties
3313
+ */
3314
+ static buildSchemaMetadata(e) {
3315
+ return le(Mn(e, ["param"]), _e);
3316
+ }
3317
+ static buildParameterMetadata(e) {
3318
+ return le(e, _e);
3319
+ }
3320
+ static applySchemaMetadata(e, t) {
3321
+ return le(Object.assign(Object.assign({}, e), this.buildSchemaMetadata(t)), _e);
3322
+ }
3323
+ static getRefId(e) {
3324
+ var t;
3325
+ return (t = this.getInternalMetadata(e)) === null || t === void 0 ? void 0 : t.refId;
3326
+ }
3327
+ static unwrapChained(e) {
3328
+ return this.unwrapUntil(e);
3329
+ }
3330
+ static getDefaultValue(e) {
3331
+ const t = this.unwrapUntil(e, "ZodDefault");
3332
+ return t == null ? void 0 : t._def.defaultValue();
3333
+ }
3334
+ static unwrapUntil(e, t) {
3335
+ return t && _(e, t) ? e : _(e, "ZodOptional") || _(e, "ZodNullable") || _(e, "ZodBranded") ? this.unwrapUntil(e.unwrap(), t) : _(e, "ZodDefault") || _(e, "ZodReadonly") ? this.unwrapUntil(e._def.innerType, t) : _(e, "ZodEffects") ? this.unwrapUntil(e._def.schema, t) : _(e, "ZodPipeline") ? this.unwrapUntil(e._def.in, t) : t ? void 0 : e;
3336
+ }
3337
+ static isOptionalSchema(e) {
3338
+ return _(e, "ZodEffects") ? this.isOptionalSchema(e._def.schema) : e.isOptional();
3339
+ }
3340
+ }
3341
+ class Vn {
3342
+ transform(e, t, n) {
3343
+ var s, a;
3344
+ const i = e._def.type;
3345
+ return Object.assign(Object.assign({}, t("array")), { items: n(i), minItems: (s = e._def.minLength) === null || s === void 0 ? void 0 : s.value, maxItems: (a = e._def.maxLength) === null || a === void 0 ? void 0 : a.value });
3346
+ }
3347
+ }
3348
+ class Un {
3349
+ transform(e) {
3350
+ return Object.assign(Object.assign({}, e("string")), { pattern: "^d+$" });
3351
+ }
3352
+ }
3353
+ class Bn {
3354
+ transform(e, t, n, s, a) {
3355
+ const i = [...e.options.values()], o = i.map(s);
3356
+ return t ? {
3357
+ oneOf: n(o, t)
3358
+ } : {
3359
+ oneOf: o,
3360
+ discriminator: this.mapDiscriminator(i, e.discriminator, a)
3361
+ };
3362
+ }
3363
+ mapDiscriminator(e, t, n) {
3364
+ if (e.some((a) => w.getRefId(a) === void 0))
3365
+ return;
3366
+ const s = {};
3367
+ return e.forEach((a) => {
3368
+ var i;
3369
+ const o = w.getRefId(a), c = (i = a.shape) === null || i === void 0 ? void 0 : i[t];
3370
+ if (_(c, "ZodEnum") || _(c, "ZodNativeEnum")) {
3371
+ Object.values(c.enum).filter(jt).forEach((h) => {
3372
+ s[h] = n(o);
3373
+ });
3374
+ return;
3375
+ }
3376
+ const u = c == null ? void 0 : c._def.value;
3377
+ if (typeof u != "string")
3378
+ throw new Error(`Discriminator ${t} could not be found in one of the values of a discriminated union`);
3379
+ s[u] = n(o);
3380
+ }), {
3381
+ propertyName: t,
3382
+ mapping: s
3383
+ };
3384
+ }
3385
+ }
3386
+ class qn {
3387
+ transform(e, t) {
3388
+ return Object.assign(Object.assign({}, t("string")), { enum: e._def.values });
3389
+ }
3390
+ }
3391
+ class Wn {
3392
+ transform(e, t, n, s) {
3393
+ const i = {
3394
+ allOf: this.flattenIntersectionTypes(e).map(s)
3395
+ };
3396
+ return t ? {
3397
+ anyOf: n([i], t)
3398
+ } : i;
3399
+ }
3400
+ flattenIntersectionTypes(e) {
3401
+ if (!_(e, "ZodIntersection"))
3402
+ return [e];
3403
+ const t = this.flattenIntersectionTypes(e._def.left), n = this.flattenIntersectionTypes(e._def.right);
3404
+ return [...t, ...n];
3405
+ }
3406
+ }
3407
+ class Fn {
3408
+ transform(e, t) {
3409
+ return Object.assign(Object.assign({}, t(typeof e._def.value)), { enum: [e._def.value] });
3410
+ }
3411
+ }
3412
+ function Hn(r) {
3413
+ const t = Object.keys(r).filter((a) => typeof r[r[a]] != "number").map((a) => r[a]), n = t.filter((a) => typeof a == "number").length, s = n === 0 ? "string" : n === t.length ? "numeric" : "mixed";
3414
+ return { values: t, type: s };
3415
+ }
3416
+ class Jn {
3417
+ transform(e, t) {
3418
+ const { type: n, values: s } = Hn(e._def.values);
3419
+ if (n === "mixed")
3420
+ throw new Qe("Enum has mixed string and number values, please specify the OpenAPI type manually");
3421
+ return Object.assign(Object.assign({}, t(n === "numeric" ? "integer" : "string")), { enum: s });
3422
+ }
3423
+ }
3424
+ class Gn {
3425
+ transform(e, t, n) {
3426
+ return Object.assign(Object.assign({}, t(e.isInt ? "integer" : "number")), n(e._def.checks));
3427
+ }
3428
+ }
3429
+ class Yn {
3430
+ transform(e, t, n, s) {
3431
+ var a;
3432
+ const i = (a = w.getInternalMetadata(e)) === null || a === void 0 ? void 0 : a.extendedFrom, o = this.requiredKeysOf(e), c = be(e._def.shape(), s);
3433
+ if (!i)
3434
+ return Object.assign(Object.assign(Object.assign(Object.assign({}, n("object")), { properties: c, default: t }), o.length > 0 ? { required: o } : {}), this.generateAdditionalProperties(e, s));
3435
+ const u = i.schema;
3436
+ s(u);
3437
+ const l = this.requiredKeysOf(u), h = be(u == null ? void 0 : u._def.shape(), s), j = Object.fromEntries(Object.entries(c).filter(([O, R]) => !ot(h[O], R))), k = o.filter((O) => !l.includes(O)), C = Object.assign(Object.assign(Object.assign(Object.assign({}, n("object")), { default: t, properties: j }), k.length > 0 ? { required: k } : {}), this.generateAdditionalProperties(e, s));
3438
+ return {
3439
+ allOf: [
3440
+ { $ref: `#/components/schemas/${i.refId}` },
3441
+ C
3442
+ ]
3443
+ };
3444
+ }
3445
+ generateAdditionalProperties(e, t) {
3446
+ const n = e._def.unknownKeys, s = e._def.catchall;
3447
+ return _(s, "ZodNever") ? n === "strict" ? { additionalProperties: !1 } : {} : { additionalProperties: t(s) };
3448
+ }
3449
+ requiredKeysOf(e) {
3450
+ return Object.entries(e._def.shape()).filter(([t, n]) => !w.isOptionalSchema(n)).map(([t, n]) => t);
3451
+ }
3452
+ }
3453
+ class Kn {
3454
+ transform(e, t, n) {
3455
+ const s = e._def.valueType, a = e._def.keyType, i = n(s);
3456
+ if (_(a, "ZodEnum") || _(a, "ZodNativeEnum")) {
3457
+ const c = Object.values(a.enum).filter(jt).reduce((u, l) => Object.assign(Object.assign({}, u), { [l]: i }), {});
3458
+ return Object.assign(Object.assign({}, t("object")), { properties: c });
3459
+ }
3460
+ return Object.assign(Object.assign({}, t("object")), { additionalProperties: i });
3461
+ }
3462
+ }
3463
+ class Qn {
3464
+ transform(e, t) {
3465
+ var n, s, a;
3466
+ const i = this.getZodStringCheck(e, "regex"), o = (n = this.getZodStringCheck(e, "length")) === null || n === void 0 ? void 0 : n.value, c = Number.isFinite(e.minLength) && (s = e.minLength) !== null && s !== void 0 ? s : void 0, u = Number.isFinite(e.maxLength) && (a = e.maxLength) !== null && a !== void 0 ? a : void 0;
3467
+ return Object.assign(Object.assign({}, t("string")), {
3468
+ // FIXME: https://github.com/colinhacks/zod/commit/d78047e9f44596a96d637abb0ce209cd2732d88c
3469
+ minLength: o ?? c,
3470
+ maxLength: o ?? u,
3471
+ format: this.mapStringFormat(e),
3472
+ pattern: i == null ? void 0 : i.regex.source
3473
+ });
3474
+ }
3475
+ /**
3476
+ * Attempts to map Zod strings to known formats
3477
+ * https://json-schema.org/understanding-json-schema/reference/string.html#built-in-formats
3478
+ */
3479
+ mapStringFormat(e) {
3480
+ if (e.isUUID)
3481
+ return "uuid";
3482
+ if (e.isEmail)
3483
+ return "email";
3484
+ if (e.isURL)
3485
+ return "uri";
3486
+ if (e.isDatetime)
3487
+ return "date-time";
3488
+ if (e.isCUID)
3489
+ return "cuid";
3490
+ if (e.isCUID2)
3491
+ return "cuid2";
3492
+ if (e.isULID)
3493
+ return "ulid";
3494
+ if (e.isIP)
3495
+ return "ip";
3496
+ if (e.isEmoji)
3497
+ return "emoji";
3498
+ }
3499
+ getZodStringCheck(e, t) {
3500
+ return e._def.checks.find((n) => n.kind === t);
3501
+ }
3502
+ }
3503
+ class Xn {
3504
+ constructor(e) {
3505
+ this.versionSpecifics = e;
3506
+ }
3507
+ transform(e, t, n) {
3508
+ const { items: s } = e._def, a = s.map(n);
3509
+ return Object.assign(Object.assign({}, t("array")), this.versionSpecifics.mapTupleItems(a));
3510
+ }
3511
+ }
3512
+ class zn {
3513
+ transform(e, t, n) {
3514
+ const a = this.flattenUnionTypes(e).map((i) => {
3515
+ const o = this.unwrapNullable(i);
3516
+ return n(o);
3517
+ });
3518
+ return {
3519
+ anyOf: t(a)
3520
+ };
3521
+ }
3522
+ flattenUnionTypes(e) {
3523
+ return _(e, "ZodUnion") ? e._def.options.flatMap((n) => this.flattenUnionTypes(n)) : [e];
3524
+ }
3525
+ unwrapNullable(e) {
3526
+ return _(e, "ZodNullable") ? this.unwrapNullable(e.unwrap()) : e;
3527
+ }
3528
+ }
3529
+ class er {
3530
+ constructor(e) {
3531
+ this.versionSpecifics = e, this.objectTransformer = new Yn(), this.stringTransformer = new Qn(), this.numberTransformer = new Gn(), this.bigIntTransformer = new Un(), this.literalTransformer = new Fn(), this.enumTransformer = new qn(), this.nativeEnumTransformer = new Jn(), this.arrayTransformer = new Vn(), this.unionTransformer = new zn(), this.discriminatedUnionTransformer = new Bn(), this.intersectionTransformer = new Wn(), this.recordTransformer = new Kn(), this.tupleTransformer = new Xn(e);
3532
+ }
3533
+ transform(e, t, n, s, a) {
3534
+ if (_(e, "ZodNull"))
3535
+ return this.versionSpecifics.nullType;
3536
+ if (_(e, "ZodUnknown") || _(e, "ZodAny"))
3537
+ return this.versionSpecifics.mapNullableType(void 0, t);
3538
+ if (_(e, "ZodObject"))
3539
+ return this.objectTransformer.transform(
3540
+ e,
3541
+ a,
3542
+ // verified on TS level from input
3543
+ // verified on TS level from input
3544
+ (o) => this.versionSpecifics.mapNullableType(o, t),
3545
+ n
3546
+ );
3547
+ const i = this.transformSchemaWithoutDefault(e, t, n, s);
3548
+ return Object.assign(Object.assign({}, i), { default: a });
3549
+ }
3550
+ transformSchemaWithoutDefault(e, t, n, s) {
3551
+ if (_(e, "ZodUnknown") || _(e, "ZodAny"))
3552
+ return this.versionSpecifics.mapNullableType(void 0, t);
3553
+ if (_(e, "ZodString"))
3554
+ return this.stringTransformer.transform(e, (i) => this.versionSpecifics.mapNullableType(i, t));
3555
+ if (_(e, "ZodNumber"))
3556
+ return this.numberTransformer.transform(e, (i) => this.versionSpecifics.mapNullableType(i, t), (i) => this.versionSpecifics.getNumberChecks(i));
3557
+ if (_(e, "ZodBigInt"))
3558
+ return this.bigIntTransformer.transform((i) => this.versionSpecifics.mapNullableType(i, t));
3559
+ if (_(e, "ZodBoolean"))
3560
+ return this.versionSpecifics.mapNullableType("boolean", t);
3561
+ if (_(e, "ZodLiteral"))
3562
+ return this.literalTransformer.transform(e, (i) => this.versionSpecifics.mapNullableType(i, t));
3563
+ if (_(e, "ZodEnum"))
3564
+ return this.enumTransformer.transform(e, (i) => this.versionSpecifics.mapNullableType(i, t));
3565
+ if (_(e, "ZodNativeEnum"))
3566
+ return this.nativeEnumTransformer.transform(e, (i) => this.versionSpecifics.mapNullableType(i, t));
3567
+ if (_(e, "ZodArray"))
3568
+ return this.arrayTransformer.transform(e, (i) => this.versionSpecifics.mapNullableType(i, t), n);
3569
+ if (_(e, "ZodTuple"))
3570
+ return this.tupleTransformer.transform(e, (i) => this.versionSpecifics.mapNullableType(i, t), n);
3571
+ if (_(e, "ZodUnion"))
3572
+ return this.unionTransformer.transform(e, (i) => this.versionSpecifics.mapNullableOfArray(i, t), n);
3573
+ if (_(e, "ZodDiscriminatedUnion"))
3574
+ return this.discriminatedUnionTransformer.transform(e, t, (i) => this.versionSpecifics.mapNullableOfArray(i, t), n, s);
3575
+ if (_(e, "ZodIntersection"))
3576
+ return this.intersectionTransformer.transform(e, t, (i) => this.versionSpecifics.mapNullableOfArray(i, t), n);
3577
+ if (_(e, "ZodRecord"))
3578
+ return this.recordTransformer.transform(e, (i) => this.versionSpecifics.mapNullableType(i, t), n);
3579
+ if (_(e, "ZodDate"))
3580
+ return this.versionSpecifics.mapNullableType("string", t);
3581
+ const a = w.getRefId(e);
3582
+ throw new Ln({
3583
+ currentSchema: e._def,
3584
+ schemaName: a
3585
+ });
3586
+ }
3587
+ }
3588
+ class tr {
3589
+ constructor(e, t) {
3590
+ this.definitions = e, this.versionSpecifics = t, this.schemaRefs = {}, this.paramRefs = {}, this.pathRefs = {}, this.rawComponents = [], this.openApiTransformer = new er(t), this.sortDefinitions();
3591
+ }
3592
+ generateDocumentData() {
3593
+ return this.definitions.forEach((e) => this.generateSingle(e)), {
3594
+ components: this.buildComponents(),
3595
+ paths: this.pathRefs
3596
+ };
3597
+ }
3598
+ generateComponents() {
3599
+ return this.definitions.forEach((e) => this.generateSingle(e)), {
3600
+ components: this.buildComponents()
3601
+ };
3602
+ }
3603
+ buildComponents() {
3604
+ var e, t;
3605
+ const n = {};
3606
+ return this.rawComponents.forEach(({ componentType: s, name: a, component: i }) => {
3607
+ var o;
3608
+ (o = n[s]) !== null && o !== void 0 || (n[s] = {}), n[s][a] = i;
3609
+ }), Object.assign(Object.assign({}, n), { schemas: Object.assign(Object.assign({}, (e = n.schemas) !== null && e !== void 0 ? e : {}), this.schemaRefs), parameters: Object.assign(Object.assign({}, (t = n.parameters) !== null && t !== void 0 ? t : {}), this.paramRefs) });
3610
+ }
3611
+ sortDefinitions() {
3612
+ const e = [
3613
+ "schema",
3614
+ "parameter",
3615
+ "component",
3616
+ "route"
3617
+ ];
3618
+ this.definitions.sort((t, n) => {
3619
+ if (!("type" in t))
3620
+ return "type" in n ? -1 : 0;
3621
+ if (!("type" in n))
3622
+ return 1;
3623
+ const s = e.findIndex((i) => i === t.type), a = e.findIndex((i) => i === n.type);
3624
+ return s - a;
3625
+ });
3626
+ }
3627
+ generateSingle(e) {
3628
+ if (!("type" in e)) {
3629
+ this.generateSchemaWithRef(e);
3630
+ return;
3631
+ }
3632
+ switch (e.type) {
3633
+ case "parameter":
3634
+ this.generateParameterDefinition(e.schema);
3635
+ return;
3636
+ case "schema":
3637
+ this.generateSchemaWithRef(e.schema);
3638
+ return;
3639
+ case "route":
3640
+ this.generateSingleRoute(e.route);
3641
+ return;
3642
+ case "component":
3643
+ this.rawComponents.push(e);
3644
+ return;
3645
+ }
3646
+ }
3647
+ generateParameterDefinition(e) {
3648
+ const t = w.getRefId(e), n = this.generateParameter(e);
3649
+ return t && (this.paramRefs[t] = n), n;
3650
+ }
3651
+ getParameterRef(e, t) {
3652
+ var n, s, a, i, o;
3653
+ const c = (n = e == null ? void 0 : e.metadata) === null || n === void 0 ? void 0 : n.param, u = !((s = e == null ? void 0 : e._internal) === null || s === void 0) && s.refId ? this.paramRefs[(a = e._internal) === null || a === void 0 ? void 0 : a.refId] : void 0;
3654
+ if (!(!(!((i = e == null ? void 0 : e._internal) === null || i === void 0) && i.refId) || !u)) {
3655
+ if (c && u.in !== c.in || t != null && t.in && u.in !== t.in)
3656
+ throw new ve(`Conflicting location for parameter ${u.name}`, {
3657
+ key: "in",
3658
+ values: ft([
3659
+ u.in,
3660
+ t == null ? void 0 : t.in,
3661
+ c == null ? void 0 : c.in
3662
+ ])
3663
+ });
3664
+ if (c && u.name !== c.name || t != null && t.name && u.name !== (t == null ? void 0 : t.name))
3665
+ throw new ve("Conflicting names for parameter", {
3666
+ key: "name",
3667
+ values: ft([
3668
+ u.name,
3669
+ t == null ? void 0 : t.name,
3670
+ c == null ? void 0 : c.name
3671
+ ])
3672
+ });
3673
+ return {
3674
+ $ref: `#/components/parameters/${(o = e._internal) === null || o === void 0 ? void 0 : o.refId}`
3675
+ };
3676
+ }
3677
+ }
3678
+ generateInlineParameters(e, t) {
3679
+ var n;
3680
+ const s = w.getMetadata(e), a = (n = s == null ? void 0 : s.metadata) === null || n === void 0 ? void 0 : n.param, i = this.getParameterRef(s, { in: t });
3681
+ if (i)
3682
+ return [i];
3683
+ if (_(e, "ZodObject")) {
3684
+ const o = e._def.shape();
3685
+ return Object.entries(o).map(([u, l]) => {
3686
+ var h, j;
3687
+ const k = w.getMetadata(l), C = this.getParameterRef(k, {
3688
+ in: t,
3689
+ name: u
3690
+ });
3691
+ if (C)
3692
+ return C;
3693
+ const O = (h = k == null ? void 0 : k.metadata) === null || h === void 0 ? void 0 : h.param;
3694
+ if (O != null && O.name && O.name !== u)
3695
+ throw new ve("Conflicting names for parameter", {
3696
+ key: "name",
3697
+ values: [u, O.name]
3698
+ });
3699
+ if (O != null && O.in && O.in !== t)
3700
+ throw new ve(`Conflicting location for parameter ${(j = O.name) !== null && j !== void 0 ? j : u}`, {
3701
+ key: "in",
3702
+ values: [t, O.in]
3703
+ });
3704
+ return this.generateParameter(l.openapi({ param: { name: u, in: t } }));
3705
+ });
3706
+ }
3707
+ if (a != null && a.in && a.in !== t)
3708
+ throw new ve(`Conflicting location for parameter ${a.name}`, {
3709
+ key: "in",
3710
+ values: [t, a.in]
3711
+ });
3712
+ return [
3713
+ this.generateParameter(e.openapi({ param: { in: t } }))
3714
+ ];
3715
+ }
3716
+ generateSimpleParameter(e) {
3717
+ var t;
3718
+ const n = w.getParamMetadata(e), s = (t = n == null ? void 0 : n.metadata) === null || t === void 0 ? void 0 : t.param, a = !w.isOptionalSchema(e) && !e.isNullable(), i = this.generateSchemaWithRef(e);
3719
+ return Object.assign({
3720
+ schema: i,
3721
+ required: a
3722
+ }, s ? w.buildParameterMetadata(s) : {});
3723
+ }
3724
+ generateParameter(e) {
3725
+ var t;
3726
+ const n = w.getMetadata(e), s = (t = n == null ? void 0 : n.metadata) === null || t === void 0 ? void 0 : t.param, a = s == null ? void 0 : s.name, i = s == null ? void 0 : s.in;
3727
+ if (!a)
3728
+ throw new Ye({ missingField: "name" });
3729
+ if (!i)
3730
+ throw new Ye({
3731
+ missingField: "in",
3732
+ paramName: a
3733
+ });
3734
+ const o = this.generateSimpleParameter(e);
3735
+ return Object.assign(Object.assign({}, o), { in: i, name: a });
3736
+ }
3737
+ generateSchemaWithMetadata(e) {
3738
+ var t;
3739
+ const n = w.unwrapChained(e), s = w.getMetadata(e), a = w.getDefaultValue(e), i = !((t = s == null ? void 0 : s.metadata) === null || t === void 0) && t.type ? { type: s == null ? void 0 : s.metadata.type } : this.toOpenAPISchema(n, e.isNullable(), a);
3740
+ return s != null && s.metadata ? w.applySchemaMetadata(i, s.metadata) : le(i, _e);
3741
+ }
3742
+ /**
3743
+ * Same as above but applies nullable
3744
+ */
3745
+ constructReferencedOpenAPISchema(e) {
3746
+ var t;
3747
+ const n = w.getMetadata(e), s = w.unwrapChained(e), a = w.getDefaultValue(e), i = e.isNullable();
3748
+ return !((t = n == null ? void 0 : n.metadata) === null || t === void 0) && t.type ? this.versionSpecifics.mapNullableType(n.metadata.type, i) : this.toOpenAPISchema(s, i, a);
3749
+ }
3750
+ /**
3751
+ * Generates an OpenAPI SchemaObject or a ReferenceObject with all the provided metadata applied
3752
+ */
3753
+ generateSimpleSchema(e) {
3754
+ var t;
3755
+ const n = w.getMetadata(e), s = w.getRefId(e);
3756
+ if (!s || !this.schemaRefs[s])
3757
+ return this.generateSchemaWithMetadata(e);
3758
+ const a = this.schemaRefs[s], i = {
3759
+ $ref: this.generateSchemaRef(s)
3760
+ }, o = le(w.buildSchemaMetadata((t = n == null ? void 0 : n.metadata) !== null && t !== void 0 ? t : {}), (l, h) => l === void 0 || ot(l, a[h]));
3761
+ if (o.type)
3762
+ return {
3763
+ allOf: [i, o]
3764
+ };
3765
+ const c = le(this.constructReferencedOpenAPISchema(e), (l, h) => l === void 0 || ot(l, a[h])), u = w.applySchemaMetadata(c, o);
3766
+ return Object.keys(u).length > 0 ? {
3767
+ allOf: [i, u]
3768
+ } : i;
3769
+ }
3770
+ /**
3771
+ * Same as `generateSchema` but if the new schema is added into the
3772
+ * referenced schemas, it would return a ReferenceObject and not the
3773
+ * whole result.
3774
+ *
3775
+ * Should be used for nested objects, arrays, etc.
3776
+ */
3777
+ generateSchemaWithRef(e) {
3778
+ const t = w.getRefId(e), n = this.generateSimpleSchema(e);
3779
+ return t && this.schemaRefs[t] === void 0 ? (this.schemaRefs[t] = n, { $ref: this.generateSchemaRef(t) }) : n;
3780
+ }
3781
+ generateSchemaRef(e) {
3782
+ return `#/components/schemas/${e}`;
3783
+ }
3784
+ getRequestBody(e) {
3785
+ if (!e)
3786
+ return;
3787
+ const { content: t } = e, n = ye(e, ["content"]), s = this.getBodyContent(t);
3788
+ return Object.assign(Object.assign({}, n), { content: s });
3789
+ }
3790
+ getParameters(e) {
3791
+ if (!e)
3792
+ return [];
3793
+ const { headers: t } = e, n = this.cleanParameter(e.query), s = this.cleanParameter(e.params), a = this.cleanParameter(e.cookies), i = ge(() => n ? this.generateInlineParameters(n, "query") : [], { location: "query" }), o = ge(() => s ? this.generateInlineParameters(s, "path") : [], { location: "path" }), c = ge(() => a ? this.generateInlineParameters(a, "cookie") : [], { location: "cookie" }), u = ge(() => {
3794
+ if (Array.isArray(t))
3795
+ return t.flatMap((h) => this.generateInlineParameters(h, "header"));
3796
+ const l = this.cleanParameter(t);
3797
+ return l ? this.generateInlineParameters(l, "header") : [];
3798
+ }, { location: "header" });
3799
+ return [
3800
+ ...o,
3801
+ ...i,
3802
+ ...u,
3803
+ ...c
3804
+ ];
3805
+ }
3806
+ cleanParameter(e) {
3807
+ if (e)
3808
+ return _(e, "ZodEffects") ? this.cleanParameter(e._def.schema) : e;
3809
+ }
3810
+ generatePath(e) {
3811
+ const { method: t, path: n, request: s, responses: a } = e, i = ye(e, ["method", "path", "request", "responses"]), o = be(a, (h) => this.getResponse(h)), c = ge(() => this.getParameters(s), { route: `${t} ${n}` }), u = this.getRequestBody(s == null ? void 0 : s.body);
3812
+ return {
3813
+ [t]: Object.assign(Object.assign(Object.assign(Object.assign({}, i), c.length > 0 ? {
3814
+ parameters: [...i.parameters || [], ...c]
3815
+ } : {}), u ? { requestBody: u } : {}), { responses: o })
3816
+ };
3817
+ }
3818
+ generateSingleRoute(e) {
3819
+ const t = this.generatePath(e);
3820
+ return this.pathRefs[e.path] = Object.assign(Object.assign({}, this.pathRefs[e.path]), t), t;
3821
+ }
3822
+ getResponse(e) {
3823
+ var { content: t, headers: n } = e, s = ye(e, ["content", "headers"]);
3824
+ const a = t ? { content: this.getBodyContent(t) } : {};
3825
+ if (!n)
3826
+ return Object.assign(Object.assign({}, s), a);
3827
+ const i = _(n, "ZodObject") ? this.getResponseHeaders(n) : (
3828
+ // This is input data so it is okay to cast in the common generator
3829
+ // since this is the user's responsibility to keep it correct
3830
+ n
3831
+ );
3832
+ return Object.assign(Object.assign(Object.assign({}, s), { headers: i }), a);
3833
+ }
3834
+ getResponseHeaders(e) {
3835
+ const t = e._def.shape();
3836
+ return be(t, (s) => this.generateSimpleParameter(s));
3837
+ }
3838
+ getBodyContent(e) {
3839
+ return be(e, (t) => {
3840
+ if (!t || !An(t.schema))
3841
+ return t;
3842
+ const { schema: n } = t, s = ye(t, ["schema"]), a = this.generateSchemaWithRef(n);
3843
+ return Object.assign({ schema: a }, s);
3844
+ });
3845
+ }
3846
+ toOpenAPISchema(e, t, n) {
3847
+ return this.openApiTransformer.transform(e, t, (s) => this.generateSchemaWithRef(s), (s) => this.generateSchemaRef(s), n);
3848
+ }
3849
+ }
3850
+ class nr {
3851
+ get nullType() {
3852
+ return { nullable: !0 };
3853
+ }
3854
+ mapNullableOfArray(e, t) {
3855
+ return t ? [...e, this.nullType] : e;
3856
+ }
3857
+ mapNullableType(e, t) {
3858
+ return Object.assign(Object.assign({}, e ? { type: e } : void 0), t ? this.nullType : void 0);
3859
+ }
3860
+ mapTupleItems(e) {
3861
+ const t = Dn(e);
3862
+ return {
3863
+ items: t.length === 1 ? t[0] : { anyOf: t },
3864
+ minItems: e.length,
3865
+ maxItems: e.length
3866
+ };
3867
+ }
3868
+ getNumberChecks(e) {
3869
+ return Object.assign({}, ...e.map((t) => {
3870
+ switch (t.kind) {
3871
+ case "min":
3872
+ return t.inclusive ? { minimum: Number(t.value) } : { minimum: Number(t.value), exclusiveMinimum: !0 };
3873
+ case "max":
3874
+ return t.inclusive ? { maximum: Number(t.value) } : { maximum: Number(t.value), exclusiveMaximum: !0 };
3875
+ default:
3876
+ return {};
3877
+ }
3878
+ }));
3879
+ }
3880
+ }
3881
+ class rr {
3882
+ constructor(e) {
3883
+ const t = new nr();
3884
+ this.generator = new tr(e, t);
3885
+ }
3886
+ generateDocument(e) {
3887
+ const t = this.generator.generateDocumentData();
3888
+ return Object.assign(Object.assign({}, e), t);
3889
+ }
3890
+ generateComponents() {
3891
+ return this.generator.generateComponents();
3892
+ }
3893
+ }
3894
+ const sr = (r) => {
3895
+ var o, c, u, l, h, j, k, C, O, R, Y, he, Se, Ne, te, ne, re, se, ae, ie;
3896
+ const e = `${r.openapiPathPrefix ?? "/api"}`, t = `${r.endpoint ?? r.path ?? ""}`, n = r.codec ?? ar, s = {
3897
+ method: r.method,
3898
+ path: `${e}${t}`,
3899
+ summary: ((o = r.openapi) == null ? void 0 : o.summary) ?? "",
3900
+ request: {},
3901
+ responses: {}
3902
+ }, a = (c = r.schemas) != null && c.response ? {
3903
+ 200: {
3904
+ description: ((h = (l = (u = r.openapi) == null ? void 0 : u.responses) == null ? void 0 : l[200]) == null ? void 0 : h.description) ?? "",
3905
+ content: {
3906
+ [n.responseContentType]: {
3907
+ schema: (j = r.schemas) == null ? void 0 : j.response
3908
+ }
3909
+ }
3910
+ }
3911
+ } : {}, i = ((k = r.openapi) == null ? void 0 : k.responses) ?? {};
3912
+ return s.responses = { ...a, ...i }, (C = r.schemas) != null && C.queryParams && (s.request.query = (R = (O = r.schemas) == null ? void 0 : O.queryParams) == null ? void 0 : R.openapi("Query Params")), (Y = r.schemas) != null && Y.payload && (s.request.body = {
3913
+ description: "Body",
3914
+ content: {
3915
+ [n.requestContentType]: {
3916
+ schema: (he = r.schemas) == null ? void 0 : he.payload
3917
+ }
3918
+ },
3919
+ required: !0
3920
+ }), (Se = r.schemas) != null && Se.urlArgs && (s.request.params = (te = (Ne = r.schemas) == null ? void 0 : Ne.urlArgs) == null ? void 0 : te.openapi(
3921
+ "URL Params"
3922
+ )), s.description = (ne = r.openapi) == null ? void 0 : ne.description, s.tags = (re = r.openapi) == null ? void 0 : re.tags, s.operationId = (se = r.openapi) == null ? void 0 : se.operationId, s.deprecated = (ae = r.openapi) == null ? void 0 : ae.deprecated, s.security = (ie = r.openapi) == null ? void 0 : ie.security, s;
3923
+ }, ar = {
3924
+ requestContentType: "application/json",
3925
+ responseContentType: "application/json"
3926
+ }, ir = (r) => require(r), or = (r) => {
3927
+ const e = new $n();
3928
+ Sn(Pn);
3929
+ const t = r.outPath || `${r.baseDir}/dist`, n = r.pathPrefix || "/api", s = r.loadDefinitions ?? ir, a = r.mkdirFn ?? ((j) => ct.mkdirSync(j, { recursive: !0 })), i = r.writeFileFn ?? ((j, k) => ct.writeFileSync(j, k, {
3930
+ encoding: "utf-8"
3931
+ })), o = ze.resolve(r.baseDir, r.indexPath), c = s(o);
3932
+ Object.entries(c).forEach(([j, k]) => {
3933
+ Object.entries(k).forEach(([C, O]) => {
3934
+ const R = O, Y = R.apiConfig ?? sr({
3935
+ ...R,
3936
+ endpoint: R.endpoint ?? R.path,
3937
+ openapiPathPrefix: n
3938
+ });
3939
+ e.registerPath(Y);
3940
+ });
3941
+ });
3942
+ const l = new rr(e.definitions).generateDocument({
3943
+ info: {
3944
+ title: "",
3945
+ version: "1"
3946
+ },
3947
+ openapi: "3.0.0"
3948
+ }), h = ze.resolve(t, "apps/openapi");
3949
+ return a(h), i(ze.resolve(h, "docs.json"), JSON.stringify(l, null, 2)), l;
3950
+ }, cr = (r = $e.argv, e = {}) => {
3951
+ if (r.length < 4)
3952
+ throw new Error("You need to specify the index file (relative to project root) for API generation.");
3953
+ const t = e.baseDir ?? `${$e.cwd()}`, n = r[3], s = r[4] || `${t}/dist`, a = r[5] || "/api", i = or({
3954
+ baseDir: t,
3955
+ indexPath: n,
3956
+ outPath: s,
3957
+ pathPrefix: a,
3958
+ loadDefinitions: e.loadDefinitions,
3959
+ mkdirFn: e.mkdirFn,
3960
+ writeFileFn: e.writeFileFn
3961
+ });
3962
+ return console.log(JSON.stringify(i, null, 2)), i;
3963
+ }, pt = $e.argv[1] || "";
3964
+ (pt.endsWith("open-api.cjs.js") || pt.endsWith("open-api.es.js")) && cr();
3965
+ export {
3966
+ or as exportOpenApi,
3967
+ cr as runOpenApiCli
3968
+ };
3969
+ //# sourceMappingURL=open-api.es.js.map