@adgytec/adgytec-web-utils 0.0.1 → 0.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1,2728 +1,35 @@
1
- class Te extends Error {
2
- }
3
- function u(e, t, n) {
4
- function r(c, a) {
5
- if (c._zod || Object.defineProperty(c, "_zod", {
6
- value: {
7
- def: a,
8
- constr: s,
9
- traits: /* @__PURE__ */ new Set()
10
- },
11
- enumerable: !1
12
- }), c._zod.traits.has(e))
13
- return;
14
- c._zod.traits.add(e), t(c, a);
15
- const f = s.prototype, d = Object.keys(f);
16
- for (let l = 0; l < d.length; l++) {
17
- const h = d[l];
18
- h in c || (c[h] = f[h].bind(c));
19
- }
20
- }
21
- const o = n?.Parent ?? Object;
22
- class i extends o {
23
- }
24
- Object.defineProperty(i, "name", { value: e });
25
- function s(c) {
26
- var a;
27
- const f = n?.Parent ? new i() : this;
28
- r(f, c), (a = f._zod).deferred ?? (a.deferred = []);
29
- for (const d of f._zod.deferred)
30
- d();
31
- return f;
32
- }
33
- return Object.defineProperty(s, "init", { value: r }), Object.defineProperty(s, Symbol.hasInstance, {
34
- value: (c) => n?.Parent && c instanceof n.Parent ? !0 : c?._zod?.traits?.has(e)
35
- }), Object.defineProperty(s, "name", { value: e }), s;
36
- }
37
- class U extends Error {
38
- constructor() {
39
- super("Encountered Promise during synchronous parse. Use .parseAsync() instead.");
40
- }
41
- }
42
- class Ie extends Error {
43
- constructor(t) {
44
- super(`Encountered unidirectional transform during encode: ${t}`), this.name = "ZodEncodeError";
45
- }
46
- }
47
- const je = {};
48
- function T(e) {
49
- return je;
50
- }
51
- function Ae(e) {
52
- const t = Object.values(e).filter((r) => typeof r == "number");
53
- return Object.entries(e).filter(([r, o]) => t.indexOf(+r) === -1).map(([r, o]) => o);
54
- }
55
- function ne(e, t) {
56
- return typeof t == "bigint" ? t.toString() : t;
57
- }
58
- function se(e) {
59
- return {
60
- get value() {
61
- {
62
- const t = e();
63
- return Object.defineProperty(this, "value", { value: t }), t;
64
- }
65
- }
66
- };
67
- }
68
- function ie(e) {
69
- return e == null;
70
- }
71
- function ce(e) {
72
- const t = e.startsWith("^") ? 1 : 0, n = e.endsWith("$") ? e.length - 1 : e.length;
73
- return e.slice(t, n);
74
- }
75
- const le = /* @__PURE__ */ Symbol("evaluating");
76
- function g(e, t, n) {
77
- let r;
78
- Object.defineProperty(e, t, {
79
- get() {
80
- if (r !== le)
81
- return r === void 0 && (r = le, r = n()), r;
82
- },
83
- set(o) {
84
- Object.defineProperty(e, t, {
85
- value: o
86
- // configurable: true,
87
- });
88
- },
89
- configurable: !0
90
- });
91
- }
92
- function R(e, t, n) {
93
- Object.defineProperty(e, t, {
94
- value: n,
95
- writable: !0,
96
- enumerable: !0,
97
- configurable: !0
98
- });
99
- }
100
- function j(...e) {
101
- const t = {};
102
- for (const n of e) {
103
- const r = Object.getOwnPropertyDescriptors(n);
104
- Object.assign(t, r);
105
- }
106
- return Object.defineProperties({}, t);
107
- }
108
- function pe(e) {
109
- return JSON.stringify(e);
110
- }
111
- function it(e) {
112
- return e.toLowerCase().trim().replace(/[^\w\s-]/g, "").replace(/[\s_-]+/g, "-").replace(/^-+|-+$/g, "");
113
- }
114
- const Re = "captureStackTrace" in Error ? Error.captureStackTrace : (...e) => {
115
- };
116
- function q(e) {
117
- return typeof e == "object" && e !== null && !Array.isArray(e);
118
- }
119
- const ct = se(() => {
120
- if (typeof navigator < "u" && navigator?.userAgent?.includes("Cloudflare"))
121
- return !1;
122
- try {
123
- const e = Function;
124
- return new e(""), !0;
125
- } catch {
126
- return !1;
127
- }
128
- });
129
- function J(e) {
130
- if (q(e) === !1)
131
- return !1;
132
- const t = e.constructor;
133
- if (t === void 0 || typeof t != "function")
134
- return !0;
135
- const n = t.prototype;
136
- return !(q(n) === !1 || Object.prototype.hasOwnProperty.call(n, "isPrototypeOf") === !1);
137
- }
138
- function Ce(e) {
139
- return J(e) ? { ...e } : Array.isArray(e) ? [...e] : e;
140
- }
141
- const at = /* @__PURE__ */ new Set(["string", "number", "symbol"]);
142
- function Y(e) {
143
- return e.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
144
- }
145
- function A(e, t, n) {
146
- const r = new e._zod.constr(t ?? e._zod.def);
147
- return (!t || n?.parent) && (r._zod.parent = e), r;
148
- }
149
- function p(e) {
150
- const t = e;
151
- if (!t)
152
- return {};
153
- if (typeof t == "string")
154
- return { error: () => t };
155
- if (t?.message !== void 0) {
156
- if (t?.error !== void 0)
157
- throw new Error("Cannot specify both `message` and `error` params");
158
- t.error = t.message;
159
- }
160
- return delete t.message, typeof t.error == "string" ? { ...t, error: () => t.error } : t;
161
- }
162
- function ut(e) {
163
- return Object.keys(e).filter((t) => e[t]._zod.optin === "optional" && e[t]._zod.optout === "optional");
164
- }
165
- function ft(e, t) {
166
- const n = e._zod.def, r = n.checks;
167
- if (r && r.length > 0)
168
- throw new Error(".pick() cannot be used on object schemas containing refinements");
169
- const i = j(e._zod.def, {
170
- get shape() {
171
- const s = {};
172
- for (const c in t) {
173
- if (!(c in n.shape))
174
- throw new Error(`Unrecognized key: "${c}"`);
175
- t[c] && (s[c] = n.shape[c]);
176
- }
177
- return R(this, "shape", s), s;
178
- },
179
- checks: []
180
- });
181
- return A(e, i);
182
- }
183
- function dt(e, t) {
184
- const n = e._zod.def, r = n.checks;
185
- if (r && r.length > 0)
186
- throw new Error(".omit() cannot be used on object schemas containing refinements");
187
- const i = j(e._zod.def, {
188
- get shape() {
189
- const s = { ...e._zod.def.shape };
190
- for (const c in t) {
191
- if (!(c in n.shape))
192
- throw new Error(`Unrecognized key: "${c}"`);
193
- t[c] && delete s[c];
194
- }
195
- return R(this, "shape", s), s;
196
- },
197
- checks: []
198
- });
199
- return A(e, i);
200
- }
201
- function lt(e, t) {
202
- if (!J(t))
203
- throw new Error("Invalid input to extend: expected a plain object");
204
- const n = e._zod.def.checks;
205
- if (n && n.length > 0) {
206
- const i = e._zod.def.shape;
207
- for (const s in t)
208
- if (Object.getOwnPropertyDescriptor(i, s) !== void 0)
209
- throw new Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.");
210
- }
211
- const o = j(e._zod.def, {
212
- get shape() {
213
- const i = { ...e._zod.def.shape, ...t };
214
- return R(this, "shape", i), i;
215
- }
216
- });
217
- return A(e, o);
218
- }
219
- function pt(e, t) {
220
- if (!J(t))
221
- throw new Error("Invalid input to safeExtend: expected a plain object");
222
- const n = j(e._zod.def, {
223
- get shape() {
224
- const r = { ...e._zod.def.shape, ...t };
225
- return R(this, "shape", r), r;
226
- }
227
- });
228
- return A(e, n);
229
- }
230
- function ht(e, t) {
231
- const n = j(e._zod.def, {
232
- get shape() {
233
- const r = { ...e._zod.def.shape, ...t._zod.def.shape };
234
- return R(this, "shape", r), r;
235
- },
236
- get catchall() {
237
- return t._zod.def.catchall;
238
- },
239
- checks: []
240
- // delete existing checks
241
- });
242
- return A(e, n);
243
- }
244
- function mt(e, t, n) {
245
- const o = t._zod.def.checks;
246
- if (o && o.length > 0)
247
- throw new Error(".partial() cannot be used on object schemas containing refinements");
248
- const s = j(t._zod.def, {
249
- get shape() {
250
- const c = t._zod.def.shape, a = { ...c };
251
- if (n)
252
- for (const f in n) {
253
- if (!(f in c))
254
- throw new Error(`Unrecognized key: "${f}"`);
255
- n[f] && (a[f] = e ? new e({
256
- type: "optional",
257
- innerType: c[f]
258
- }) : c[f]);
259
- }
260
- else
261
- for (const f in c)
262
- a[f] = e ? new e({
263
- type: "optional",
264
- innerType: c[f]
265
- }) : c[f];
266
- return R(this, "shape", a), a;
267
- },
268
- checks: []
269
- });
270
- return A(t, s);
271
- }
272
- function gt(e, t, n) {
273
- const r = j(t._zod.def, {
274
- get shape() {
275
- const o = t._zod.def.shape, i = { ...o };
276
- if (n)
277
- for (const s in n) {
278
- if (!(s in i))
279
- throw new Error(`Unrecognized key: "${s}"`);
280
- n[s] && (i[s] = new e({
281
- type: "nonoptional",
282
- innerType: o[s]
283
- }));
284
- }
285
- else
286
- for (const s in o)
287
- i[s] = new e({
288
- type: "nonoptional",
289
- innerType: o[s]
290
- });
291
- return R(this, "shape", i), i;
292
- }
293
- });
294
- return A(t, r);
295
- }
296
- function N(e, t = 0) {
297
- if (e.aborted === !0)
298
- return !0;
299
- for (let n = t; n < e.issues.length; n++)
300
- if (e.issues[n]?.continue !== !0)
301
- return !0;
302
- return !1;
303
- }
304
- function D(e, t) {
305
- return t.map((n) => {
306
- var r;
307
- return (r = n).path ?? (r.path = []), n.path.unshift(e), n;
308
- });
309
- }
310
- function V(e) {
311
- return typeof e == "string" ? e : e?.message;
312
- }
313
- function I(e, t, n) {
314
- const r = { ...e, path: e.path ?? [] };
315
- if (!e.message) {
316
- const o = V(e.inst?._zod.def?.error?.(e)) ?? V(t?.error?.(e)) ?? V(n.customError?.(e)) ?? V(n.localeError?.(e)) ?? "Invalid input";
317
- r.message = o;
318
- }
319
- return delete r.inst, delete r.continue, t?.reportInput || delete r.input, r;
320
- }
321
- function ae(e) {
322
- return Array.isArray(e) ? "array" : typeof e == "string" ? "string" : "unknown";
323
- }
324
- function x(...e) {
325
- const [t, n, r] = e;
326
- return typeof t == "string" ? {
327
- message: t,
328
- code: "custom",
329
- input: n,
330
- inst: r
331
- } : { ...t };
332
- }
333
- const Ne = (e, t) => {
334
- e.name = "$ZodError", Object.defineProperty(e, "_zod", {
335
- value: e._zod,
336
- enumerable: !1
337
- }), Object.defineProperty(e, "issues", {
338
- value: t,
339
- enumerable: !1
340
- }), e.message = JSON.stringify(t, ne, 2), Object.defineProperty(e, "toString", {
341
- value: () => e.message,
342
- enumerable: !1
343
- });
344
- }, De = u("$ZodError", Ne), Ue = u("$ZodError", Ne, { Parent: Error });
345
- function _t(e, t = (n) => n.message) {
346
- const n = {}, r = [];
347
- for (const o of e.issues)
348
- o.path.length > 0 ? (n[o.path[0]] = n[o.path[0]] || [], n[o.path[0]].push(t(o))) : r.push(t(o));
349
- return { formErrors: r, fieldErrors: n };
350
- }
351
- function vt(e, t = (n) => n.message) {
352
- const n = { _errors: [] }, r = (o) => {
353
- for (const i of o.issues)
354
- if (i.code === "invalid_union" && i.errors.length)
355
- i.errors.map((s) => r({ issues: s }));
356
- else if (i.code === "invalid_key")
357
- r({ issues: i.issues });
358
- else if (i.code === "invalid_element")
359
- r({ issues: i.issues });
360
- else if (i.path.length === 0)
361
- n._errors.push(t(i));
362
- else {
363
- let s = n, c = 0;
364
- for (; c < i.path.length; ) {
365
- const a = i.path[c];
366
- c === i.path.length - 1 ? (s[a] = s[a] || { _errors: [] }, s[a]._errors.push(t(i))) : s[a] = s[a] || { _errors: [] }, s = s[a], c++;
367
- }
368
- }
369
- };
370
- return r(e), n;
371
- }
372
- const ue = (e) => (t, n, r, o) => {
373
- const i = r ? Object.assign(r, { async: !1 }) : { async: !1 }, s = t._zod.run({ value: n, issues: [] }, i);
374
- if (s instanceof Promise)
375
- throw new U();
376
- if (s.issues.length) {
377
- const c = new (o?.Err ?? e)(s.issues.map((a) => I(a, i, T())));
378
- throw Re(c, o?.callee), c;
379
- }
380
- return s.value;
381
- }, fe = (e) => async (t, n, r, o) => {
382
- const i = r ? Object.assign(r, { async: !0 }) : { async: !0 };
383
- let s = t._zod.run({ value: n, issues: [] }, i);
384
- if (s instanceof Promise && (s = await s), s.issues.length) {
385
- const c = new (o?.Err ?? e)(s.issues.map((a) => I(a, i, T())));
386
- throw Re(c, o?.callee), c;
387
- }
388
- return s.value;
389
- }, Q = (e) => (t, n, r) => {
390
- const o = r ? { ...r, async: !1 } : { async: !1 }, i = t._zod.run({ value: n, issues: [] }, o);
391
- if (i instanceof Promise)
392
- throw new U();
393
- return i.issues.length ? {
394
- success: !1,
395
- error: new (e ?? De)(i.issues.map((s) => I(s, o, T())))
396
- } : { success: !0, data: i.value };
397
- }, yt = /* @__PURE__ */ Q(Ue), ee = (e) => async (t, n, r) => {
398
- const o = r ? Object.assign(r, { async: !0 }) : { async: !0 };
399
- let i = t._zod.run({ value: n, issues: [] }, o);
400
- return i instanceof Promise && (i = await i), i.issues.length ? {
401
- success: !1,
402
- error: new e(i.issues.map((s) => I(s, o, T())))
403
- } : { success: !0, data: i.value };
404
- }, zt = /* @__PURE__ */ ee(Ue), wt = (e) => (t, n, r) => {
405
- const o = r ? Object.assign(r, { direction: "backward" }) : { direction: "backward" };
406
- return ue(e)(t, n, o);
407
- }, kt = (e) => (t, n, r) => ue(e)(t, n, r), bt = (e) => async (t, n, r) => {
408
- const o = r ? Object.assign(r, { direction: "backward" }) : { direction: "backward" };
409
- return fe(e)(t, n, o);
410
- }, $t = (e) => async (t, n, r) => fe(e)(t, n, r), Zt = (e) => (t, n, r) => {
411
- const o = r ? Object.assign(r, { direction: "backward" }) : { direction: "backward" };
412
- return Q(e)(t, n, o);
413
- }, Ot = (e) => (t, n, r) => Q(e)(t, n, r), St = (e) => async (t, n, r) => {
414
- const o = r ? Object.assign(r, { direction: "backward" }) : { direction: "backward" };
415
- return ee(e)(t, n, o);
416
- }, Pt = (e) => async (t, n, r) => ee(e)(t, n, r), Et = /^[cC][^\s-]{8,}$/, Tt = /^[0-9a-z]+$/, It = /^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/, jt = /^[0-9a-vA-V]{20}$/, At = /^[A-Za-z0-9]{27}$/, Rt = /^[a-zA-Z0-9_-]{21}$/, Ct = /^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/, Nt = /^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/, he = (e) => e ? new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${e}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`) : /^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/, Dt = /^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/, Ut = "^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";
417
- function Jt() {
418
- return new RegExp(Ut, "u");
419
- }
420
- const Ft = /^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/, Lt = /^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))$/, xt = /^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/([0-9]|[1-2][0-9]|3[0-2])$/, Mt = /^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/, Vt = /^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/, Je = /^[A-Za-z0-9_-]*$/, Wt = /^\+[1-9]\d{6,14}$/, Fe = "(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))", Kt = /* @__PURE__ */ new RegExp(`^${Fe}$`);
421
- function Le(e) {
422
- const t = "(?:[01]\\d|2[0-3]):[0-5]\\d";
423
- return typeof e.precision == "number" ? e.precision === -1 ? `${t}` : e.precision === 0 ? `${t}:[0-5]\\d` : `${t}:[0-5]\\d\\.\\d{${e.precision}}` : `${t}(?::[0-5]\\d(?:\\.\\d+)?)?`;
424
- }
425
- function Bt(e) {
426
- return new RegExp(`^${Le(e)}$`);
427
- }
428
- function qt(e) {
429
- const t = Le({ precision: e.precision }), n = ["Z"];
430
- e.local && n.push(""), e.offset && n.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");
431
- const r = `${t}(?:${n.join("|")})`;
432
- return new RegExp(`^${Fe}T(?:${r})$`);
433
- }
434
- const Gt = (e) => {
435
- const t = e ? `[\\s\\S]{${e?.minimum ?? 0},${e?.maximum ?? ""}}` : "[\\s\\S]*";
436
- return new RegExp(`^${t}$`);
437
- }, Ht = /^-?\d+(?:\.\d+)?$/, Xt = /^[^A-Z]*$/, Yt = /^[^a-z]*$/, E = /* @__PURE__ */ u("$ZodCheck", (e, t) => {
438
- var n;
439
- e._zod ?? (e._zod = {}), e._zod.def = t, (n = e._zod).onattach ?? (n.onattach = []);
440
- }), Qt = /* @__PURE__ */ u("$ZodCheckMaxLength", (e, t) => {
441
- var n;
442
- E.init(e, t), (n = e._zod.def).when ?? (n.when = (r) => {
443
- const o = r.value;
444
- return !ie(o) && o.length !== void 0;
445
- }), e._zod.onattach.push((r) => {
446
- const o = r._zod.bag.maximum ?? Number.POSITIVE_INFINITY;
447
- t.maximum < o && (r._zod.bag.maximum = t.maximum);
448
- }), e._zod.check = (r) => {
449
- const o = r.value;
450
- if (o.length <= t.maximum)
451
- return;
452
- const s = ae(o);
453
- r.issues.push({
454
- origin: s,
455
- code: "too_big",
456
- maximum: t.maximum,
457
- inclusive: !0,
458
- input: o,
459
- inst: e,
460
- continue: !t.abort
461
- });
462
- };
463
- }), en = /* @__PURE__ */ u("$ZodCheckMinLength", (e, t) => {
464
- var n;
465
- E.init(e, t), (n = e._zod.def).when ?? (n.when = (r) => {
466
- const o = r.value;
467
- return !ie(o) && o.length !== void 0;
468
- }), e._zod.onattach.push((r) => {
469
- const o = r._zod.bag.minimum ?? Number.NEGATIVE_INFINITY;
470
- t.minimum > o && (r._zod.bag.minimum = t.minimum);
471
- }), e._zod.check = (r) => {
472
- const o = r.value;
473
- if (o.length >= t.minimum)
474
- return;
475
- const s = ae(o);
476
- r.issues.push({
477
- origin: s,
478
- code: "too_small",
479
- minimum: t.minimum,
480
- inclusive: !0,
481
- input: o,
482
- inst: e,
483
- continue: !t.abort
484
- });
485
- };
486
- }), tn = /* @__PURE__ */ u("$ZodCheckLengthEquals", (e, t) => {
487
- var n;
488
- E.init(e, t), (n = e._zod.def).when ?? (n.when = (r) => {
489
- const o = r.value;
490
- return !ie(o) && o.length !== void 0;
491
- }), e._zod.onattach.push((r) => {
492
- const o = r._zod.bag;
493
- o.minimum = t.length, o.maximum = t.length, o.length = t.length;
494
- }), e._zod.check = (r) => {
495
- const o = r.value, i = o.length;
496
- if (i === t.length)
497
- return;
498
- const s = ae(o), c = i > t.length;
499
- r.issues.push({
500
- origin: s,
501
- ...c ? { code: "too_big", maximum: t.length } : { code: "too_small", minimum: t.length },
502
- inclusive: !0,
503
- exact: !0,
504
- input: r.value,
505
- inst: e,
506
- continue: !t.abort
507
- });
508
- };
509
- }), te = /* @__PURE__ */ u("$ZodCheckStringFormat", (e, t) => {
510
- var n, r;
511
- E.init(e, t), e._zod.onattach.push((o) => {
512
- const i = o._zod.bag;
513
- i.format = t.format, t.pattern && (i.patterns ?? (i.patterns = /* @__PURE__ */ new Set()), i.patterns.add(t.pattern));
514
- }), t.pattern ? (n = e._zod).check ?? (n.check = (o) => {
515
- t.pattern.lastIndex = 0, !t.pattern.test(o.value) && o.issues.push({
516
- origin: "string",
517
- code: "invalid_format",
518
- format: t.format,
519
- input: o.value,
520
- ...t.pattern ? { pattern: t.pattern.toString() } : {},
521
- inst: e,
522
- continue: !t.abort
523
- });
524
- }) : (r = e._zod).check ?? (r.check = () => {
525
- });
526
- }), nn = /* @__PURE__ */ u("$ZodCheckRegex", (e, t) => {
527
- te.init(e, t), e._zod.check = (n) => {
528
- t.pattern.lastIndex = 0, !t.pattern.test(n.value) && n.issues.push({
529
- origin: "string",
530
- code: "invalid_format",
531
- format: "regex",
532
- input: n.value,
533
- pattern: t.pattern.toString(),
534
- inst: e,
535
- continue: !t.abort
536
- });
537
- };
538
- }), rn = /* @__PURE__ */ u("$ZodCheckLowerCase", (e, t) => {
539
- t.pattern ?? (t.pattern = Xt), te.init(e, t);
540
- }), on = /* @__PURE__ */ u("$ZodCheckUpperCase", (e, t) => {
541
- t.pattern ?? (t.pattern = Yt), te.init(e, t);
542
- }), sn = /* @__PURE__ */ u("$ZodCheckIncludes", (e, t) => {
543
- E.init(e, t);
544
- const n = Y(t.includes), r = new RegExp(typeof t.position == "number" ? `^.{${t.position}}${n}` : n);
545
- t.pattern = r, e._zod.onattach.push((o) => {
546
- const i = o._zod.bag;
547
- i.patterns ?? (i.patterns = /* @__PURE__ */ new Set()), i.patterns.add(r);
548
- }), e._zod.check = (o) => {
549
- o.value.includes(t.includes, t.position) || o.issues.push({
550
- origin: "string",
551
- code: "invalid_format",
552
- format: "includes",
553
- includes: t.includes,
554
- input: o.value,
555
- inst: e,
556
- continue: !t.abort
557
- });
558
- };
559
- }), cn = /* @__PURE__ */ u("$ZodCheckStartsWith", (e, t) => {
560
- E.init(e, t);
561
- const n = new RegExp(`^${Y(t.prefix)}.*`);
562
- t.pattern ?? (t.pattern = n), e._zod.onattach.push((r) => {
563
- const o = r._zod.bag;
564
- o.patterns ?? (o.patterns = /* @__PURE__ */ new Set()), o.patterns.add(n);
565
- }), e._zod.check = (r) => {
566
- r.value.startsWith(t.prefix) || r.issues.push({
567
- origin: "string",
568
- code: "invalid_format",
569
- format: "starts_with",
570
- prefix: t.prefix,
571
- input: r.value,
572
- inst: e,
573
- continue: !t.abort
574
- });
575
- };
576
- }), an = /* @__PURE__ */ u("$ZodCheckEndsWith", (e, t) => {
577
- E.init(e, t);
578
- const n = new RegExp(`.*${Y(t.suffix)}$`);
579
- t.pattern ?? (t.pattern = n), e._zod.onattach.push((r) => {
580
- const o = r._zod.bag;
581
- o.patterns ?? (o.patterns = /* @__PURE__ */ new Set()), o.patterns.add(n);
582
- }), e._zod.check = (r) => {
583
- r.value.endsWith(t.suffix) || r.issues.push({
584
- origin: "string",
585
- code: "invalid_format",
586
- format: "ends_with",
587
- suffix: t.suffix,
588
- input: r.value,
589
- inst: e,
590
- continue: !t.abort
591
- });
592
- };
593
- }), un = /* @__PURE__ */ u("$ZodCheckOverwrite", (e, t) => {
594
- E.init(e, t), e._zod.check = (n) => {
595
- n.value = t.tx(n.value);
596
- };
597
- });
598
- class fn {
599
- constructor(t = []) {
600
- this.content = [], this.indent = 0, this && (this.args = t);
601
- }
602
- indented(t) {
603
- this.indent += 1, t(this), this.indent -= 1;
604
- }
605
- write(t) {
606
- if (typeof t == "function") {
607
- t(this, { execution: "sync" }), t(this, { execution: "async" });
608
- return;
609
- }
610
- const r = t.split(`
611
- `).filter((s) => s), o = Math.min(...r.map((s) => s.length - s.trimStart().length)), i = r.map((s) => s.slice(o)).map((s) => " ".repeat(this.indent * 2) + s);
612
- for (const s of i)
613
- this.content.push(s);
614
- }
615
- compile() {
616
- const t = Function, n = this?.args, o = [...(this?.content ?? [""]).map((i) => ` ${i}`)];
617
- return new t(...n, o.join(`
618
- `));
619
- }
620
- }
621
- const dn = {
622
- major: 4,
623
- minor: 3,
624
- patch: 5
625
- }, z = /* @__PURE__ */ u("$ZodType", (e, t) => {
626
- var n;
627
- e ?? (e = {}), e._zod.def = t, e._zod.bag = e._zod.bag || {}, e._zod.version = dn;
628
- const r = [...e._zod.def.checks ?? []];
629
- e._zod.traits.has("$ZodCheck") && r.unshift(e);
630
- for (const o of r)
631
- for (const i of o._zod.onattach)
632
- i(e);
633
- if (r.length === 0)
634
- (n = e._zod).deferred ?? (n.deferred = []), e._zod.deferred?.push(() => {
635
- e._zod.run = e._zod.parse;
636
- });
637
- else {
638
- const o = (s, c, a) => {
639
- let f = N(s), d;
640
- for (const l of c) {
641
- if (l._zod.def.when) {
642
- if (!l._zod.def.when(s))
643
- continue;
644
- } else if (f)
645
- continue;
646
- const h = s.issues.length, m = l._zod.check(s);
647
- if (m instanceof Promise && a?.async === !1)
648
- throw new U();
649
- if (d || m instanceof Promise)
650
- d = (d ?? Promise.resolve()).then(async () => {
651
- await m, s.issues.length !== h && (f || (f = N(s, h)));
652
- });
653
- else {
654
- if (s.issues.length === h)
655
- continue;
656
- f || (f = N(s, h));
657
- }
658
- }
659
- return d ? d.then(() => s) : s;
660
- }, i = (s, c, a) => {
661
- if (N(s))
662
- return s.aborted = !0, s;
663
- const f = o(c, r, a);
664
- if (f instanceof Promise) {
665
- if (a.async === !1)
666
- throw new U();
667
- return f.then((d) => e._zod.parse(d, a));
668
- }
669
- return e._zod.parse(f, a);
670
- };
671
- e._zod.run = (s, c) => {
672
- if (c.skipChecks)
673
- return e._zod.parse(s, c);
674
- if (c.direction === "backward") {
675
- const f = e._zod.parse({ value: s.value, issues: [] }, { ...c, skipChecks: !0 });
676
- return f instanceof Promise ? f.then((d) => i(d, s, c)) : i(f, s, c);
677
- }
678
- const a = e._zod.parse(s, c);
679
- if (a instanceof Promise) {
680
- if (c.async === !1)
681
- throw new U();
682
- return a.then((f) => o(f, r, c));
683
- }
684
- return o(a, r, c);
685
- };
686
- }
687
- g(e, "~standard", () => ({
688
- validate: (o) => {
689
- try {
690
- const i = yt(e, o);
691
- return i.success ? { value: i.data } : { issues: i.error?.issues };
692
- } catch {
693
- return zt(e, o).then((s) => s.success ? { value: s.data } : { issues: s.error?.issues });
694
- }
695
- },
696
- vendor: "zod",
697
- version: 1
698
- }));
699
- }), de = /* @__PURE__ */ u("$ZodString", (e, t) => {
700
- z.init(e, t), e._zod.pattern = [...e?._zod.bag?.patterns ?? []].pop() ?? Gt(e._zod.bag), e._zod.parse = (n, r) => {
701
- if (t.coerce)
702
- try {
703
- n.value = String(n.value);
704
- } catch {
705
- }
706
- return typeof n.value == "string" || n.issues.push({
707
- expected: "string",
708
- code: "invalid_type",
709
- input: n.value,
710
- inst: e
711
- }), n;
712
- };
713
- }), _ = /* @__PURE__ */ u("$ZodStringFormat", (e, t) => {
714
- te.init(e, t), de.init(e, t);
715
- }), ln = /* @__PURE__ */ u("$ZodGUID", (e, t) => {
716
- t.pattern ?? (t.pattern = Nt), _.init(e, t);
717
- }), pn = /* @__PURE__ */ u("$ZodUUID", (e, t) => {
718
- if (t.version) {
719
- const r = {
720
- v1: 1,
721
- v2: 2,
722
- v3: 3,
723
- v4: 4,
724
- v5: 5,
725
- v6: 6,
726
- v7: 7,
727
- v8: 8
728
- }[t.version];
729
- if (r === void 0)
730
- throw new Error(`Invalid UUID version: "${t.version}"`);
731
- t.pattern ?? (t.pattern = he(r));
732
- } else
733
- t.pattern ?? (t.pattern = he());
734
- _.init(e, t);
735
- }), hn = /* @__PURE__ */ u("$ZodEmail", (e, t) => {
736
- t.pattern ?? (t.pattern = Dt), _.init(e, t);
737
- }), mn = /* @__PURE__ */ u("$ZodURL", (e, t) => {
738
- _.init(e, t), e._zod.check = (n) => {
739
- try {
740
- const r = n.value.trim(), o = new URL(r);
741
- t.hostname && (t.hostname.lastIndex = 0, t.hostname.test(o.hostname) || n.issues.push({
742
- code: "invalid_format",
743
- format: "url",
744
- note: "Invalid hostname",
745
- pattern: t.hostname.source,
746
- input: n.value,
747
- inst: e,
748
- continue: !t.abort
749
- })), t.protocol && (t.protocol.lastIndex = 0, t.protocol.test(o.protocol.endsWith(":") ? o.protocol.slice(0, -1) : o.protocol) || n.issues.push({
750
- code: "invalid_format",
751
- format: "url",
752
- note: "Invalid protocol",
753
- pattern: t.protocol.source,
754
- input: n.value,
755
- inst: e,
756
- continue: !t.abort
757
- })), t.normalize ? n.value = o.href : n.value = r;
758
- return;
759
- } catch {
760
- n.issues.push({
761
- code: "invalid_format",
762
- format: "url",
763
- input: n.value,
764
- inst: e,
765
- continue: !t.abort
766
- });
767
- }
768
- };
769
- }), gn = /* @__PURE__ */ u("$ZodEmoji", (e, t) => {
770
- t.pattern ?? (t.pattern = Jt()), _.init(e, t);
771
- }), _n = /* @__PURE__ */ u("$ZodNanoID", (e, t) => {
772
- t.pattern ?? (t.pattern = Rt), _.init(e, t);
773
- }), vn = /* @__PURE__ */ u("$ZodCUID", (e, t) => {
774
- t.pattern ?? (t.pattern = Et), _.init(e, t);
775
- }), yn = /* @__PURE__ */ u("$ZodCUID2", (e, t) => {
776
- t.pattern ?? (t.pattern = Tt), _.init(e, t);
777
- }), zn = /* @__PURE__ */ u("$ZodULID", (e, t) => {
778
- t.pattern ?? (t.pattern = It), _.init(e, t);
779
- }), wn = /* @__PURE__ */ u("$ZodXID", (e, t) => {
780
- t.pattern ?? (t.pattern = jt), _.init(e, t);
781
- }), kn = /* @__PURE__ */ u("$ZodKSUID", (e, t) => {
782
- t.pattern ?? (t.pattern = At), _.init(e, t);
783
- }), bn = /* @__PURE__ */ u("$ZodISODateTime", (e, t) => {
784
- t.pattern ?? (t.pattern = qt(t)), _.init(e, t);
785
- }), $n = /* @__PURE__ */ u("$ZodISODate", (e, t) => {
786
- t.pattern ?? (t.pattern = Kt), _.init(e, t);
787
- }), Zn = /* @__PURE__ */ u("$ZodISOTime", (e, t) => {
788
- t.pattern ?? (t.pattern = Bt(t)), _.init(e, t);
789
- }), On = /* @__PURE__ */ u("$ZodISODuration", (e, t) => {
790
- t.pattern ?? (t.pattern = Ct), _.init(e, t);
791
- }), Sn = /* @__PURE__ */ u("$ZodIPv4", (e, t) => {
792
- t.pattern ?? (t.pattern = Ft), _.init(e, t), e._zod.bag.format = "ipv4";
793
- }), Pn = /* @__PURE__ */ u("$ZodIPv6", (e, t) => {
794
- t.pattern ?? (t.pattern = Lt), _.init(e, t), e._zod.bag.format = "ipv6", e._zod.check = (n) => {
795
- try {
796
- new URL(`http://[${n.value}]`);
797
- } catch {
798
- n.issues.push({
799
- code: "invalid_format",
800
- format: "ipv6",
801
- input: n.value,
802
- inst: e,
803
- continue: !t.abort
804
- });
805
- }
806
- };
807
- }), En = /* @__PURE__ */ u("$ZodCIDRv4", (e, t) => {
808
- t.pattern ?? (t.pattern = xt), _.init(e, t);
809
- }), Tn = /* @__PURE__ */ u("$ZodCIDRv6", (e, t) => {
810
- t.pattern ?? (t.pattern = Mt), _.init(e, t), e._zod.check = (n) => {
811
- const r = n.value.split("/");
812
- try {
813
- if (r.length !== 2)
814
- throw new Error();
815
- const [o, i] = r;
816
- if (!i)
817
- throw new Error();
818
- const s = Number(i);
819
- if (`${s}` !== i)
820
- throw new Error();
821
- if (s < 0 || s > 128)
822
- throw new Error();
823
- new URL(`http://[${o}]`);
824
- } catch {
825
- n.issues.push({
826
- code: "invalid_format",
827
- format: "cidrv6",
828
- input: n.value,
829
- inst: e,
830
- continue: !t.abort
831
- });
832
- }
833
- };
834
- });
835
- function xe(e) {
836
- if (e === "")
837
- return !0;
838
- if (e.length % 4 !== 0)
839
- return !1;
840
- try {
841
- return atob(e), !0;
842
- } catch {
843
- return !1;
844
- }
845
- }
846
- const In = /* @__PURE__ */ u("$ZodBase64", (e, t) => {
847
- t.pattern ?? (t.pattern = Vt), _.init(e, t), e._zod.bag.contentEncoding = "base64", e._zod.check = (n) => {
848
- xe(n.value) || n.issues.push({
849
- code: "invalid_format",
850
- format: "base64",
851
- input: n.value,
852
- inst: e,
853
- continue: !t.abort
854
- });
855
- };
856
- });
857
- function jn(e) {
858
- if (!Je.test(e))
859
- return !1;
860
- const t = e.replace(/[-_]/g, (r) => r === "-" ? "+" : "/"), n = t.padEnd(Math.ceil(t.length / 4) * 4, "=");
861
- return xe(n);
862
- }
863
- const An = /* @__PURE__ */ u("$ZodBase64URL", (e, t) => {
864
- t.pattern ?? (t.pattern = Je), _.init(e, t), e._zod.bag.contentEncoding = "base64url", e._zod.check = (n) => {
865
- jn(n.value) || n.issues.push({
866
- code: "invalid_format",
867
- format: "base64url",
868
- input: n.value,
869
- inst: e,
870
- continue: !t.abort
871
- });
872
- };
873
- }), Rn = /* @__PURE__ */ u("$ZodE164", (e, t) => {
874
- t.pattern ?? (t.pattern = Wt), _.init(e, t);
875
- });
876
- function Cn(e, t = null) {
877
- try {
878
- const n = e.split(".");
879
- if (n.length !== 3)
880
- return !1;
881
- const [r] = n;
882
- if (!r)
883
- return !1;
884
- const o = JSON.parse(atob(r));
885
- return !("typ" in o && o?.typ !== "JWT" || !o.alg || t && (!("alg" in o) || o.alg !== t));
886
- } catch {
887
- return !1;
888
- }
889
- }
890
- const Nn = /* @__PURE__ */ u("$ZodJWT", (e, t) => {
891
- _.init(e, t), e._zod.check = (n) => {
892
- Cn(n.value, t.alg) || n.issues.push({
893
- code: "invalid_format",
894
- format: "jwt",
895
- input: n.value,
896
- inst: e,
897
- continue: !t.abort
898
- });
899
- };
900
- }), Dn = /* @__PURE__ */ u("$ZodUnknown", (e, t) => {
901
- z.init(e, t), e._zod.parse = (n) => n;
902
- }), Un = /* @__PURE__ */ u("$ZodNever", (e, t) => {
903
- z.init(e, t), e._zod.parse = (n, r) => (n.issues.push({
904
- expected: "never",
905
- code: "invalid_type",
906
- input: n.value,
907
- inst: e
908
- }), n);
909
- });
910
- function me(e, t, n) {
911
- e.issues.length && t.issues.push(...D(n, e.issues)), t.value[n] = e.value;
912
- }
913
- const Jn = /* @__PURE__ */ u("$ZodArray", (e, t) => {
914
- z.init(e, t), e._zod.parse = (n, r) => {
915
- const o = n.value;
916
- if (!Array.isArray(o))
917
- return n.issues.push({
918
- expected: "array",
919
- code: "invalid_type",
920
- input: o,
921
- inst: e
922
- }), n;
923
- n.value = Array(o.length);
924
- const i = [];
925
- for (let s = 0; s < o.length; s++) {
926
- const c = o[s], a = t.element._zod.run({
927
- value: c,
928
- issues: []
929
- }, r);
930
- a instanceof Promise ? i.push(a.then((f) => me(f, n, s))) : me(a, n, s);
931
- }
932
- return i.length ? Promise.all(i).then(() => n) : n;
933
- };
934
- });
935
- function G(e, t, n, r, o) {
936
- if (e.issues.length) {
937
- if (o && !(n in r))
938
- return;
939
- t.issues.push(...D(n, e.issues));
940
- }
941
- e.value === void 0 ? n in r && (t.value[n] = void 0) : t.value[n] = e.value;
942
- }
943
- function Me(e) {
944
- const t = Object.keys(e.shape);
945
- for (const r of t)
946
- if (!e.shape?.[r]?._zod?.traits?.has("$ZodType"))
947
- throw new Error(`Invalid element at key "${r}": expected a Zod schema`);
948
- const n = ut(e.shape);
949
- return {
950
- ...e,
951
- keys: t,
952
- keySet: new Set(t),
953
- numKeys: t.length,
954
- optionalKeys: new Set(n)
955
- };
956
- }
957
- function Ve(e, t, n, r, o, i) {
958
- const s = [], c = o.keySet, a = o.catchall._zod, f = a.def.type, d = a.optout === "optional";
959
- for (const l in t) {
960
- if (c.has(l))
961
- continue;
962
- if (f === "never") {
963
- s.push(l);
964
- continue;
965
- }
966
- const h = a.run({ value: t[l], issues: [] }, r);
967
- h instanceof Promise ? e.push(h.then((m) => G(m, n, l, t, d))) : G(h, n, l, t, d);
968
- }
969
- return s.length && n.issues.push({
970
- code: "unrecognized_keys",
971
- keys: s,
972
- input: t,
973
- inst: i
974
- }), e.length ? Promise.all(e).then(() => n) : n;
975
- }
976
- const Fn = /* @__PURE__ */ u("$ZodObject", (e, t) => {
977
- if (z.init(e, t), !Object.getOwnPropertyDescriptor(t, "shape")?.get) {
978
- const c = t.shape;
979
- Object.defineProperty(t, "shape", {
980
- get: () => {
981
- const a = { ...c };
982
- return Object.defineProperty(t, "shape", {
983
- value: a
984
- }), a;
985
- }
986
- });
987
- }
988
- const r = se(() => Me(t));
989
- g(e._zod, "propValues", () => {
990
- const c = t.shape, a = {};
991
- for (const f in c) {
992
- const d = c[f]._zod;
993
- if (d.values) {
994
- a[f] ?? (a[f] = /* @__PURE__ */ new Set());
995
- for (const l of d.values)
996
- a[f].add(l);
997
- }
998
- }
999
- return a;
1000
- });
1001
- const o = q, i = t.catchall;
1002
- let s;
1003
- e._zod.parse = (c, a) => {
1004
- s ?? (s = r.value);
1005
- const f = c.value;
1006
- if (!o(f))
1007
- return c.issues.push({
1008
- expected: "object",
1009
- code: "invalid_type",
1010
- input: f,
1011
- inst: e
1012
- }), c;
1013
- c.value = {};
1014
- const d = [], l = s.shape;
1015
- for (const h of s.keys) {
1016
- const m = l[h], b = m._zod.optout === "optional", k = m._zod.run({ value: f[h], issues: [] }, a);
1017
- k instanceof Promise ? d.push(k.then((M) => G(M, c, h, f, b))) : G(k, c, h, f, b);
1018
- }
1019
- return i ? Ve(d, f, c, a, r.value, e) : d.length ? Promise.all(d).then(() => c) : c;
1020
- };
1021
- }), Ln = /* @__PURE__ */ u("$ZodObjectJIT", (e, t) => {
1022
- Fn.init(e, t);
1023
- const n = e._zod.parse, r = se(() => Me(t)), o = (h) => {
1024
- const m = new fn(["shape", "payload", "ctx"]), b = r.value, k = (P) => {
1025
- const Z = pe(P);
1026
- return `shape[${Z}]._zod.run({ value: input[${Z}], issues: [] }, ctx)`;
1027
- };
1028
- m.write("const input = payload.value;");
1029
- const M = /* @__PURE__ */ Object.create(null);
1030
- let rt = 0;
1031
- for (const P of b.keys)
1032
- M[P] = `key_${rt++}`;
1033
- m.write("const newResult = {};");
1034
- for (const P of b.keys) {
1035
- const Z = M[P], S = pe(P), st = h[P]?._zod?.optout === "optional";
1036
- m.write(`const ${Z} = ${k(P)};`), st ? m.write(`
1037
- if (${Z}.issues.length) {
1038
- if (${S} in input) {
1039
- payload.issues = payload.issues.concat(${Z}.issues.map(iss => ({
1040
- ...iss,
1041
- path: iss.path ? [${S}, ...iss.path] : [${S}]
1042
- })));
1043
- }
1044
- }
1045
-
1046
- if (${Z}.value === undefined) {
1047
- if (${S} in input) {
1048
- newResult[${S}] = undefined;
1049
- }
1050
- } else {
1051
- newResult[${S}] = ${Z}.value;
1052
- }
1053
-
1054
- `) : m.write(`
1055
- if (${Z}.issues.length) {
1056
- payload.issues = payload.issues.concat(${Z}.issues.map(iss => ({
1057
- ...iss,
1058
- path: iss.path ? [${S}, ...iss.path] : [${S}]
1059
- })));
1060
- }
1061
-
1062
- if (${Z}.value === undefined) {
1063
- if (${S} in input) {
1064
- newResult[${S}] = undefined;
1065
- }
1066
- } else {
1067
- newResult[${S}] = ${Z}.value;
1068
- }
1069
-
1070
- `);
1071
- }
1072
- m.write("payload.value = newResult;"), m.write("return payload;");
1073
- const ot = m.compile();
1074
- return (P, Z) => ot(h, P, Z);
1075
- };
1076
- let i;
1077
- const s = q, c = !je.jitless, f = c && ct.value, d = t.catchall;
1078
- let l;
1079
- e._zod.parse = (h, m) => {
1080
- l ?? (l = r.value);
1081
- const b = h.value;
1082
- return s(b) ? c && f && m?.async === !1 && m.jitless !== !0 ? (i || (i = o(t.shape)), h = i(h, m), d ? Ve([], b, h, m, l, e) : h) : n(h, m) : (h.issues.push({
1083
- expected: "object",
1084
- code: "invalid_type",
1085
- input: b,
1086
- inst: e
1087
- }), h);
1088
- };
1089
- });
1090
- function ge(e, t, n, r) {
1091
- for (const i of e)
1092
- if (i.issues.length === 0)
1093
- return t.value = i.value, t;
1094
- const o = e.filter((i) => !N(i));
1095
- return o.length === 1 ? (t.value = o[0].value, o[0]) : (t.issues.push({
1096
- code: "invalid_union",
1097
- input: t.value,
1098
- inst: n,
1099
- errors: e.map((i) => i.issues.map((s) => I(s, r, T())))
1100
- }), t);
1101
- }
1102
- const xn = /* @__PURE__ */ u("$ZodUnion", (e, t) => {
1103
- z.init(e, t), g(e._zod, "optin", () => t.options.some((o) => o._zod.optin === "optional") ? "optional" : void 0), g(e._zod, "optout", () => t.options.some((o) => o._zod.optout === "optional") ? "optional" : void 0), g(e._zod, "values", () => {
1104
- if (t.options.every((o) => o._zod.values))
1105
- return new Set(t.options.flatMap((o) => Array.from(o._zod.values)));
1106
- }), g(e._zod, "pattern", () => {
1107
- if (t.options.every((o) => o._zod.pattern)) {
1108
- const o = t.options.map((i) => i._zod.pattern);
1109
- return new RegExp(`^(${o.map((i) => ce(i.source)).join("|")})$`);
1110
- }
1111
- });
1112
- const n = t.options.length === 1, r = t.options[0]._zod.run;
1113
- e._zod.parse = (o, i) => {
1114
- if (n)
1115
- return r(o, i);
1116
- let s = !1;
1117
- const c = [];
1118
- for (const a of t.options) {
1119
- const f = a._zod.run({
1120
- value: o.value,
1121
- issues: []
1122
- }, i);
1123
- if (f instanceof Promise)
1124
- c.push(f), s = !0;
1125
- else {
1126
- if (f.issues.length === 0)
1127
- return f;
1128
- c.push(f);
1129
- }
1130
- }
1131
- return s ? Promise.all(c).then((a) => ge(a, o, e, i)) : ge(c, o, e, i);
1132
- };
1133
- }), Mn = /* @__PURE__ */ u("$ZodIntersection", (e, t) => {
1134
- z.init(e, t), e._zod.parse = (n, r) => {
1135
- const o = n.value, i = t.left._zod.run({ value: o, issues: [] }, r), s = t.right._zod.run({ value: o, issues: [] }, r);
1136
- return i instanceof Promise || s instanceof Promise ? Promise.all([i, s]).then(([a, f]) => _e(n, a, f)) : _e(n, i, s);
1137
- };
1138
- });
1139
- function re(e, t) {
1140
- if (e === t)
1141
- return { valid: !0, data: e };
1142
- if (e instanceof Date && t instanceof Date && +e == +t)
1143
- return { valid: !0, data: e };
1144
- if (J(e) && J(t)) {
1145
- const n = Object.keys(t), r = Object.keys(e).filter((i) => n.indexOf(i) !== -1), o = { ...e, ...t };
1146
- for (const i of r) {
1147
- const s = re(e[i], t[i]);
1148
- if (!s.valid)
1149
- return {
1150
- valid: !1,
1151
- mergeErrorPath: [i, ...s.mergeErrorPath]
1152
- };
1153
- o[i] = s.data;
1154
- }
1155
- return { valid: !0, data: o };
1156
- }
1157
- if (Array.isArray(e) && Array.isArray(t)) {
1158
- if (e.length !== t.length)
1159
- return { valid: !1, mergeErrorPath: [] };
1160
- const n = [];
1161
- for (let r = 0; r < e.length; r++) {
1162
- const o = e[r], i = t[r], s = re(o, i);
1163
- if (!s.valid)
1164
- return {
1165
- valid: !1,
1166
- mergeErrorPath: [r, ...s.mergeErrorPath]
1167
- };
1168
- n.push(s.data);
1169
- }
1170
- return { valid: !0, data: n };
1171
- }
1172
- return { valid: !1, mergeErrorPath: [] };
1173
- }
1174
- function _e(e, t, n) {
1175
- const r = /* @__PURE__ */ new Map();
1176
- let o;
1177
- for (const c of t.issues)
1178
- if (c.code === "unrecognized_keys") {
1179
- o ?? (o = c);
1180
- for (const a of c.keys)
1181
- r.has(a) || r.set(a, {}), r.get(a).l = !0;
1182
- } else
1183
- e.issues.push(c);
1184
- for (const c of n.issues)
1185
- if (c.code === "unrecognized_keys")
1186
- for (const a of c.keys)
1187
- r.has(a) || r.set(a, {}), r.get(a).r = !0;
1188
- else
1189
- e.issues.push(c);
1190
- const i = [...r].filter(([, c]) => c.l && c.r).map(([c]) => c);
1191
- if (i.length && o && e.issues.push({ ...o, keys: i }), N(e))
1192
- return e;
1193
- const s = re(t.value, n.value);
1194
- if (!s.valid)
1195
- throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(s.mergeErrorPath)}`);
1196
- return e.value = s.data, e;
1197
- }
1198
- const Vn = /* @__PURE__ */ u("$ZodRecord", (e, t) => {
1199
- z.init(e, t), e._zod.parse = (n, r) => {
1200
- const o = n.value;
1201
- if (!J(o))
1202
- return n.issues.push({
1203
- expected: "record",
1204
- code: "invalid_type",
1205
- input: o,
1206
- inst: e
1207
- }), n;
1208
- const i = [], s = t.keyType._zod.values;
1209
- if (s) {
1210
- n.value = {};
1211
- const c = /* @__PURE__ */ new Set();
1212
- for (const f of s)
1213
- if (typeof f == "string" || typeof f == "number" || typeof f == "symbol") {
1214
- c.add(typeof f == "number" ? f.toString() : f);
1215
- const d = t.valueType._zod.run({ value: o[f], issues: [] }, r);
1216
- d instanceof Promise ? i.push(d.then((l) => {
1217
- l.issues.length && n.issues.push(...D(f, l.issues)), n.value[f] = l.value;
1218
- })) : (d.issues.length && n.issues.push(...D(f, d.issues)), n.value[f] = d.value);
1219
- }
1220
- let a;
1221
- for (const f in o)
1222
- c.has(f) || (a = a ?? [], a.push(f));
1223
- a && a.length > 0 && n.issues.push({
1224
- code: "unrecognized_keys",
1225
- input: o,
1226
- inst: e,
1227
- keys: a
1228
- });
1229
- } else {
1230
- n.value = {};
1231
- for (const c of Reflect.ownKeys(o)) {
1232
- if (c === "__proto__")
1233
- continue;
1234
- let a = t.keyType._zod.run({ value: c, issues: [] }, r);
1235
- if (a instanceof Promise)
1236
- throw new Error("Async schemas not supported in object keys currently");
1237
- if (typeof c == "string" && Ht.test(c) && a.issues.length && a.issues.some((l) => l.code === "invalid_type" && l.expected === "number")) {
1238
- const l = t.keyType._zod.run({ value: Number(c), issues: [] }, r);
1239
- if (l instanceof Promise)
1240
- throw new Error("Async schemas not supported in object keys currently");
1241
- l.issues.length === 0 && (a = l);
1242
- }
1243
- if (a.issues.length) {
1244
- t.mode === "loose" ? n.value[c] = o[c] : n.issues.push({
1245
- code: "invalid_key",
1246
- origin: "record",
1247
- issues: a.issues.map((l) => I(l, r, T())),
1248
- input: c,
1249
- path: [c],
1250
- inst: e
1251
- });
1252
- continue;
1253
- }
1254
- const d = t.valueType._zod.run({ value: o[c], issues: [] }, r);
1255
- d instanceof Promise ? i.push(d.then((l) => {
1256
- l.issues.length && n.issues.push(...D(c, l.issues)), n.value[a.value] = l.value;
1257
- })) : (d.issues.length && n.issues.push(...D(c, d.issues)), n.value[a.value] = d.value);
1258
- }
1259
- }
1260
- return i.length ? Promise.all(i).then(() => n) : n;
1261
- };
1262
- }), Wn = /* @__PURE__ */ u("$ZodEnum", (e, t) => {
1263
- z.init(e, t);
1264
- const n = Ae(t.entries), r = new Set(n);
1265
- e._zod.values = r, e._zod.pattern = new RegExp(`^(${n.filter((o) => at.has(typeof o)).map((o) => typeof o == "string" ? Y(o) : o.toString()).join("|")})$`), e._zod.parse = (o, i) => {
1266
- const s = o.value;
1267
- return r.has(s) || o.issues.push({
1268
- code: "invalid_value",
1269
- values: n,
1270
- input: s,
1271
- inst: e
1272
- }), o;
1273
- };
1274
- }), Kn = /* @__PURE__ */ u("$ZodTransform", (e, t) => {
1275
- z.init(e, t), e._zod.parse = (n, r) => {
1276
- if (r.direction === "backward")
1277
- throw new Ie(e.constructor.name);
1278
- const o = t.transform(n.value, n);
1279
- if (r.async)
1280
- return (o instanceof Promise ? o : Promise.resolve(o)).then((s) => (n.value = s, n));
1281
- if (o instanceof Promise)
1282
- throw new U();
1283
- return n.value = o, n;
1284
- };
1285
- });
1286
- function ve(e, t) {
1287
- return e.issues.length && t === void 0 ? { issues: [], value: void 0 } : e;
1288
- }
1289
- const We = /* @__PURE__ */ u("$ZodOptional", (e, t) => {
1290
- z.init(e, t), e._zod.optin = "optional", e._zod.optout = "optional", g(e._zod, "values", () => t.innerType._zod.values ? /* @__PURE__ */ new Set([...t.innerType._zod.values, void 0]) : void 0), g(e._zod, "pattern", () => {
1291
- const n = t.innerType._zod.pattern;
1292
- return n ? new RegExp(`^(${ce(n.source)})?$`) : void 0;
1293
- }), e._zod.parse = (n, r) => {
1294
- if (t.innerType._zod.optin === "optional") {
1295
- const o = t.innerType._zod.run(n, r);
1296
- return o instanceof Promise ? o.then((i) => ve(i, n.value)) : ve(o, n.value);
1297
- }
1298
- return n.value === void 0 ? n : t.innerType._zod.run(n, r);
1299
- };
1300
- }), Bn = /* @__PURE__ */ u("$ZodExactOptional", (e, t) => {
1301
- We.init(e, t), g(e._zod, "values", () => t.innerType._zod.values), g(e._zod, "pattern", () => t.innerType._zod.pattern), e._zod.parse = (n, r) => t.innerType._zod.run(n, r);
1302
- }), qn = /* @__PURE__ */ u("$ZodNullable", (e, t) => {
1303
- z.init(e, t), g(e._zod, "optin", () => t.innerType._zod.optin), g(e._zod, "optout", () => t.innerType._zod.optout), g(e._zod, "pattern", () => {
1304
- const n = t.innerType._zod.pattern;
1305
- return n ? new RegExp(`^(${ce(n.source)}|null)$`) : void 0;
1306
- }), g(e._zod, "values", () => t.innerType._zod.values ? /* @__PURE__ */ new Set([...t.innerType._zod.values, null]) : void 0), e._zod.parse = (n, r) => n.value === null ? n : t.innerType._zod.run(n, r);
1307
- }), Gn = /* @__PURE__ */ u("$ZodDefault", (e, t) => {
1308
- z.init(e, t), e._zod.optin = "optional", g(e._zod, "values", () => t.innerType._zod.values), e._zod.parse = (n, r) => {
1309
- if (r.direction === "backward")
1310
- return t.innerType._zod.run(n, r);
1311
- if (n.value === void 0)
1312
- return n.value = t.defaultValue, n;
1313
- const o = t.innerType._zod.run(n, r);
1314
- return o instanceof Promise ? o.then((i) => ye(i, t)) : ye(o, t);
1315
- };
1316
- });
1317
- function ye(e, t) {
1318
- return e.value === void 0 && (e.value = t.defaultValue), e;
1319
- }
1320
- const Hn = /* @__PURE__ */ u("$ZodPrefault", (e, t) => {
1321
- z.init(e, t), e._zod.optin = "optional", g(e._zod, "values", () => t.innerType._zod.values), e._zod.parse = (n, r) => (r.direction === "backward" || n.value === void 0 && (n.value = t.defaultValue), t.innerType._zod.run(n, r));
1322
- }), Xn = /* @__PURE__ */ u("$ZodNonOptional", (e, t) => {
1323
- z.init(e, t), g(e._zod, "values", () => {
1324
- const n = t.innerType._zod.values;
1325
- return n ? new Set([...n].filter((r) => r !== void 0)) : void 0;
1326
- }), e._zod.parse = (n, r) => {
1327
- const o = t.innerType._zod.run(n, r);
1328
- return o instanceof Promise ? o.then((i) => ze(i, e)) : ze(o, e);
1329
- };
1330
- });
1331
- function ze(e, t) {
1332
- return !e.issues.length && e.value === void 0 && e.issues.push({
1333
- code: "invalid_type",
1334
- expected: "nonoptional",
1335
- input: e.value,
1336
- inst: t
1337
- }), e;
1338
- }
1339
- const Yn = /* @__PURE__ */ u("$ZodCatch", (e, t) => {
1340
- z.init(e, t), g(e._zod, "optin", () => t.innerType._zod.optin), g(e._zod, "optout", () => t.innerType._zod.optout), g(e._zod, "values", () => t.innerType._zod.values), e._zod.parse = (n, r) => {
1341
- if (r.direction === "backward")
1342
- return t.innerType._zod.run(n, r);
1343
- const o = t.innerType._zod.run(n, r);
1344
- return o instanceof Promise ? o.then((i) => (n.value = i.value, i.issues.length && (n.value = t.catchValue({
1345
- ...n,
1346
- error: {
1347
- issues: i.issues.map((s) => I(s, r, T()))
1348
- },
1349
- input: n.value
1350
- }), n.issues = []), n)) : (n.value = o.value, o.issues.length && (n.value = t.catchValue({
1351
- ...n,
1352
- error: {
1353
- issues: o.issues.map((i) => I(i, r, T()))
1354
- },
1355
- input: n.value
1356
- }), n.issues = []), n);
1357
- };
1358
- }), Qn = /* @__PURE__ */ u("$ZodPipe", (e, t) => {
1359
- z.init(e, t), g(e._zod, "values", () => t.in._zod.values), g(e._zod, "optin", () => t.in._zod.optin), g(e._zod, "optout", () => t.out._zod.optout), g(e._zod, "propValues", () => t.in._zod.propValues), e._zod.parse = (n, r) => {
1360
- if (r.direction === "backward") {
1361
- const i = t.out._zod.run(n, r);
1362
- return i instanceof Promise ? i.then((s) => W(s, t.in, r)) : W(i, t.in, r);
1363
- }
1364
- const o = t.in._zod.run(n, r);
1365
- return o instanceof Promise ? o.then((i) => W(i, t.out, r)) : W(o, t.out, r);
1366
- };
1367
- });
1368
- function W(e, t, n) {
1369
- return e.issues.length ? (e.aborted = !0, e) : t._zod.run({ value: e.value, issues: e.issues }, n);
1370
- }
1371
- const er = /* @__PURE__ */ u("$ZodReadonly", (e, t) => {
1372
- z.init(e, t), g(e._zod, "propValues", () => t.innerType._zod.propValues), g(e._zod, "values", () => t.innerType._zod.values), g(e._zod, "optin", () => t.innerType?._zod?.optin), g(e._zod, "optout", () => t.innerType?._zod?.optout), e._zod.parse = (n, r) => {
1373
- if (r.direction === "backward")
1374
- return t.innerType._zod.run(n, r);
1375
- const o = t.innerType._zod.run(n, r);
1376
- return o instanceof Promise ? o.then(we) : we(o);
1377
- };
1378
- });
1379
- function we(e) {
1380
- return e.value = Object.freeze(e.value), e;
1381
- }
1382
- const tr = /* @__PURE__ */ u("$ZodCustom", (e, t) => {
1383
- E.init(e, t), z.init(e, t), e._zod.parse = (n, r) => n, e._zod.check = (n) => {
1384
- const r = n.value, o = t.fn(r);
1385
- if (o instanceof Promise)
1386
- return o.then((i) => ke(i, n, r, e));
1387
- ke(o, n, r, e);
1388
- };
1389
- });
1390
- function ke(e, t, n, r) {
1391
- if (!e) {
1392
- const o = {
1393
- code: "custom",
1394
- input: n,
1395
- inst: r,
1396
- // incorporates params.error into issue reporting
1397
- path: [...r._zod.def.path ?? []],
1398
- // incorporates params.error into issue reporting
1399
- continue: !r._zod.def.abort
1400
- // params: inst._zod.def.params,
1401
- };
1402
- r._zod.def.params && (o.params = r._zod.def.params), t.issues.push(x(o));
1403
- }
1404
- }
1405
- var be;
1406
- class nr {
1407
- constructor() {
1408
- this._map = /* @__PURE__ */ new WeakMap(), this._idmap = /* @__PURE__ */ new Map();
1409
- }
1410
- add(t, ...n) {
1411
- const r = n[0];
1412
- return this._map.set(t, r), r && typeof r == "object" && "id" in r && this._idmap.set(r.id, t), this;
1413
- }
1414
- clear() {
1415
- return this._map = /* @__PURE__ */ new WeakMap(), this._idmap = /* @__PURE__ */ new Map(), this;
1416
- }
1417
- remove(t) {
1418
- const n = this._map.get(t);
1419
- return n && typeof n == "object" && "id" in n && this._idmap.delete(n.id), this._map.delete(t), this;
1420
- }
1421
- get(t) {
1422
- const n = t._zod.parent;
1423
- if (n) {
1424
- const r = { ...this.get(n) ?? {} };
1425
- delete r.id;
1426
- const o = { ...r, ...this._map.get(t) };
1427
- return Object.keys(o).length ? o : void 0;
1428
- }
1429
- return this._map.get(t);
1430
- }
1431
- has(t) {
1432
- return this._map.has(t);
1433
- }
1434
- }
1435
- function rr() {
1436
- return new nr();
1437
- }
1438
- (be = globalThis).__zod_globalRegistry ?? (be.__zod_globalRegistry = rr());
1439
- const L = globalThis.__zod_globalRegistry;
1440
- // @__NO_SIDE_EFFECTS__
1441
- function or(e, t) {
1442
- return new e({
1443
- type: "string",
1444
- ...p(t)
1445
- });
1446
- }
1447
- // @__NO_SIDE_EFFECTS__
1448
- function sr(e, t) {
1449
- return new e({
1450
- type: "string",
1451
- format: "email",
1452
- check: "string_format",
1453
- abort: !1,
1454
- ...p(t)
1455
- });
1456
- }
1457
- // @__NO_SIDE_EFFECTS__
1458
- function $e(e, t) {
1459
- return new e({
1460
- type: "string",
1461
- format: "guid",
1462
- check: "string_format",
1463
- abort: !1,
1464
- ...p(t)
1465
- });
1466
- }
1467
- // @__NO_SIDE_EFFECTS__
1468
- function ir(e, t) {
1469
- return new e({
1470
- type: "string",
1471
- format: "uuid",
1472
- check: "string_format",
1473
- abort: !1,
1474
- ...p(t)
1475
- });
1476
- }
1477
- // @__NO_SIDE_EFFECTS__
1478
- function cr(e, t) {
1479
- return new e({
1480
- type: "string",
1481
- format: "uuid",
1482
- check: "string_format",
1483
- abort: !1,
1484
- version: "v4",
1485
- ...p(t)
1486
- });
1487
- }
1488
- // @__NO_SIDE_EFFECTS__
1489
- function ar(e, t) {
1490
- return new e({
1491
- type: "string",
1492
- format: "uuid",
1493
- check: "string_format",
1494
- abort: !1,
1495
- version: "v6",
1496
- ...p(t)
1497
- });
1498
- }
1499
- // @__NO_SIDE_EFFECTS__
1500
- function ur(e, t) {
1501
- return new e({
1502
- type: "string",
1503
- format: "uuid",
1504
- check: "string_format",
1505
- abort: !1,
1506
- version: "v7",
1507
- ...p(t)
1508
- });
1509
- }
1510
- // @__NO_SIDE_EFFECTS__
1511
- function fr(e, t) {
1512
- return new e({
1513
- type: "string",
1514
- format: "url",
1515
- check: "string_format",
1516
- abort: !1,
1517
- ...p(t)
1518
- });
1519
- }
1520
- // @__NO_SIDE_EFFECTS__
1521
- function dr(e, t) {
1522
- return new e({
1523
- type: "string",
1524
- format: "emoji",
1525
- check: "string_format",
1526
- abort: !1,
1527
- ...p(t)
1528
- });
1529
- }
1530
- // @__NO_SIDE_EFFECTS__
1531
- function lr(e, t) {
1532
- return new e({
1533
- type: "string",
1534
- format: "nanoid",
1535
- check: "string_format",
1536
- abort: !1,
1537
- ...p(t)
1538
- });
1539
- }
1540
- // @__NO_SIDE_EFFECTS__
1541
- function pr(e, t) {
1542
- return new e({
1543
- type: "string",
1544
- format: "cuid",
1545
- check: "string_format",
1546
- abort: !1,
1547
- ...p(t)
1548
- });
1549
- }
1550
- // @__NO_SIDE_EFFECTS__
1551
- function hr(e, t) {
1552
- return new e({
1553
- type: "string",
1554
- format: "cuid2",
1555
- check: "string_format",
1556
- abort: !1,
1557
- ...p(t)
1558
- });
1559
- }
1560
- // @__NO_SIDE_EFFECTS__
1561
- function mr(e, t) {
1562
- return new e({
1563
- type: "string",
1564
- format: "ulid",
1565
- check: "string_format",
1566
- abort: !1,
1567
- ...p(t)
1568
- });
1569
- }
1570
- // @__NO_SIDE_EFFECTS__
1571
- function gr(e, t) {
1572
- return new e({
1573
- type: "string",
1574
- format: "xid",
1575
- check: "string_format",
1576
- abort: !1,
1577
- ...p(t)
1578
- });
1579
- }
1580
- // @__NO_SIDE_EFFECTS__
1581
- function _r(e, t) {
1582
- return new e({
1583
- type: "string",
1584
- format: "ksuid",
1585
- check: "string_format",
1586
- abort: !1,
1587
- ...p(t)
1588
- });
1589
- }
1590
- // @__NO_SIDE_EFFECTS__
1591
- function vr(e, t) {
1592
- return new e({
1593
- type: "string",
1594
- format: "ipv4",
1595
- check: "string_format",
1596
- abort: !1,
1597
- ...p(t)
1598
- });
1599
- }
1600
- // @__NO_SIDE_EFFECTS__
1601
- function yr(e, t) {
1602
- return new e({
1603
- type: "string",
1604
- format: "ipv6",
1605
- check: "string_format",
1606
- abort: !1,
1607
- ...p(t)
1608
- });
1609
- }
1610
- // @__NO_SIDE_EFFECTS__
1611
- function zr(e, t) {
1612
- return new e({
1613
- type: "string",
1614
- format: "cidrv4",
1615
- check: "string_format",
1616
- abort: !1,
1617
- ...p(t)
1618
- });
1619
- }
1620
- // @__NO_SIDE_EFFECTS__
1621
- function wr(e, t) {
1622
- return new e({
1623
- type: "string",
1624
- format: "cidrv6",
1625
- check: "string_format",
1626
- abort: !1,
1627
- ...p(t)
1628
- });
1629
- }
1630
- // @__NO_SIDE_EFFECTS__
1631
- function kr(e, t) {
1632
- return new e({
1633
- type: "string",
1634
- format: "base64",
1635
- check: "string_format",
1636
- abort: !1,
1637
- ...p(t)
1638
- });
1639
- }
1640
- // @__NO_SIDE_EFFECTS__
1641
- function br(e, t) {
1642
- return new e({
1643
- type: "string",
1644
- format: "base64url",
1645
- check: "string_format",
1646
- abort: !1,
1647
- ...p(t)
1648
- });
1649
- }
1650
- // @__NO_SIDE_EFFECTS__
1651
- function $r(e, t) {
1652
- return new e({
1653
- type: "string",
1654
- format: "e164",
1655
- check: "string_format",
1656
- abort: !1,
1657
- ...p(t)
1658
- });
1659
- }
1660
- // @__NO_SIDE_EFFECTS__
1661
- function Zr(e, t) {
1662
- return new e({
1663
- type: "string",
1664
- format: "jwt",
1665
- check: "string_format",
1666
- abort: !1,
1667
- ...p(t)
1668
- });
1669
- }
1670
- // @__NO_SIDE_EFFECTS__
1671
- function Or(e, t) {
1672
- return new e({
1673
- type: "string",
1674
- format: "datetime",
1675
- check: "string_format",
1676
- offset: !1,
1677
- local: !1,
1678
- precision: null,
1679
- ...p(t)
1680
- });
1681
- }
1682
- // @__NO_SIDE_EFFECTS__
1683
- function Sr(e, t) {
1684
- return new e({
1685
- type: "string",
1686
- format: "date",
1687
- check: "string_format",
1688
- ...p(t)
1689
- });
1690
- }
1691
- // @__NO_SIDE_EFFECTS__
1692
- function Pr(e, t) {
1693
- return new e({
1694
- type: "string",
1695
- format: "time",
1696
- check: "string_format",
1697
- precision: null,
1698
- ...p(t)
1699
- });
1700
- }
1701
- // @__NO_SIDE_EFFECTS__
1702
- function Er(e, t) {
1703
- return new e({
1704
- type: "string",
1705
- format: "duration",
1706
- check: "string_format",
1707
- ...p(t)
1708
- });
1709
- }
1710
- // @__NO_SIDE_EFFECTS__
1711
- function Tr(e) {
1712
- return new e({
1713
- type: "unknown"
1714
- });
1715
- }
1716
- // @__NO_SIDE_EFFECTS__
1717
- function Ir(e, t) {
1718
- return new e({
1719
- type: "never",
1720
- ...p(t)
1721
- });
1722
- }
1723
- // @__NO_SIDE_EFFECTS__
1724
- function Ke(e, t) {
1725
- return new Qt({
1726
- check: "max_length",
1727
- ...p(t),
1728
- maximum: e
1729
- });
1730
- }
1731
- // @__NO_SIDE_EFFECTS__
1732
- function H(e, t) {
1733
- return new en({
1734
- check: "min_length",
1735
- ...p(t),
1736
- minimum: e
1737
- });
1738
- }
1739
- // @__NO_SIDE_EFFECTS__
1740
- function Be(e, t) {
1741
- return new tn({
1742
- check: "length_equals",
1743
- ...p(t),
1744
- length: e
1745
- });
1746
- }
1747
- // @__NO_SIDE_EFFECTS__
1748
- function jr(e, t) {
1749
- return new nn({
1750
- check: "string_format",
1751
- format: "regex",
1752
- ...p(t),
1753
- pattern: e
1754
- });
1755
- }
1756
- // @__NO_SIDE_EFFECTS__
1757
- function Ar(e) {
1758
- return new rn({
1759
- check: "string_format",
1760
- format: "lowercase",
1761
- ...p(e)
1762
- });
1763
- }
1764
- // @__NO_SIDE_EFFECTS__
1765
- function Rr(e) {
1766
- return new on({
1767
- check: "string_format",
1768
- format: "uppercase",
1769
- ...p(e)
1770
- });
1771
- }
1772
- // @__NO_SIDE_EFFECTS__
1773
- function Cr(e, t) {
1774
- return new sn({
1775
- check: "string_format",
1776
- format: "includes",
1777
- ...p(t),
1778
- includes: e
1779
- });
1780
- }
1781
- // @__NO_SIDE_EFFECTS__
1782
- function Nr(e, t) {
1783
- return new cn({
1784
- check: "string_format",
1785
- format: "starts_with",
1786
- ...p(t),
1787
- prefix: e
1788
- });
1789
- }
1790
- // @__NO_SIDE_EFFECTS__
1791
- function Dr(e, t) {
1792
- return new an({
1793
- check: "string_format",
1794
- format: "ends_with",
1795
- ...p(t),
1796
- suffix: e
1797
- });
1798
- }
1799
- // @__NO_SIDE_EFFECTS__
1800
- function F(e) {
1801
- return new un({
1802
- check: "overwrite",
1803
- tx: e
1804
- });
1805
- }
1806
- // @__NO_SIDE_EFFECTS__
1807
- function Ur(e) {
1808
- return /* @__PURE__ */ F((t) => t.normalize(e));
1809
- }
1810
- // @__NO_SIDE_EFFECTS__
1811
- function Jr() {
1812
- return /* @__PURE__ */ F((e) => e.trim());
1813
- }
1814
- // @__NO_SIDE_EFFECTS__
1815
- function Fr() {
1816
- return /* @__PURE__ */ F((e) => e.toLowerCase());
1817
- }
1818
- // @__NO_SIDE_EFFECTS__
1819
- function Lr() {
1820
- return /* @__PURE__ */ F((e) => e.toUpperCase());
1821
- }
1822
- // @__NO_SIDE_EFFECTS__
1823
- function xr() {
1824
- return /* @__PURE__ */ F((e) => it(e));
1825
- }
1826
- // @__NO_SIDE_EFFECTS__
1827
- function Mr(e, t, n) {
1828
- return new e({
1829
- type: "array",
1830
- element: t,
1831
- // get element() {
1832
- // return element;
1833
- // },
1834
- ...p(n)
1835
- });
1836
- }
1837
- // @__NO_SIDE_EFFECTS__
1838
- function Vr(e, t, n) {
1839
- return new e({
1840
- type: "custom",
1841
- check: "custom",
1842
- fn: t,
1843
- ...p(n)
1844
- });
1845
- }
1846
- // @__NO_SIDE_EFFECTS__
1847
- function Wr(e) {
1848
- const t = /* @__PURE__ */ Kr((n) => (n.addIssue = (r) => {
1849
- if (typeof r == "string")
1850
- n.issues.push(x(r, n.value, t._zod.def));
1851
- else {
1852
- const o = r;
1853
- o.fatal && (o.continue = !1), o.code ?? (o.code = "custom"), o.input ?? (o.input = n.value), o.inst ?? (o.inst = t), o.continue ?? (o.continue = !t._zod.def.abort), n.issues.push(x(o));
1854
- }
1855
- }, e(n.value, n)));
1856
- return t;
1857
- }
1858
- // @__NO_SIDE_EFFECTS__
1859
- function Kr(e, t) {
1860
- const n = new E({
1861
- check: "custom",
1862
- ...p(t)
1863
- });
1864
- return n._zod.check = e, n;
1865
- }
1866
- function qe(e) {
1867
- let t = e?.target ?? "draft-2020-12";
1868
- return t === "draft-4" && (t = "draft-04"), t === "draft-7" && (t = "draft-07"), {
1869
- processors: e.processors ?? {},
1870
- metadataRegistry: e?.metadata ?? L,
1871
- target: t,
1872
- unrepresentable: e?.unrepresentable ?? "throw",
1873
- override: e?.override ?? (() => {
1874
- }),
1875
- io: e?.io ?? "output",
1876
- counter: 0,
1877
- seen: /* @__PURE__ */ new Map(),
1878
- cycles: e?.cycles ?? "ref",
1879
- reused: e?.reused ?? "inline",
1880
- external: e?.external ?? void 0
1881
- };
1882
- }
1883
- function y(e, t, n = { path: [], schemaPath: [] }) {
1884
- var r;
1885
- const o = e._zod.def, i = t.seen.get(e);
1886
- if (i)
1887
- return i.count++, n.schemaPath.includes(e) && (i.cycle = n.path), i.schema;
1888
- const s = { schema: {}, count: 1, cycle: void 0, path: n.path };
1889
- t.seen.set(e, s);
1890
- const c = e._zod.toJSONSchema?.();
1891
- if (c)
1892
- s.schema = c;
1893
- else {
1894
- const d = {
1895
- ...n,
1896
- schemaPath: [...n.schemaPath, e],
1897
- path: n.path
1898
- };
1899
- if (e._zod.processJSONSchema)
1900
- e._zod.processJSONSchema(t, s.schema, d);
1901
- else {
1902
- const h = s.schema, m = t.processors[o.type];
1903
- if (!m)
1904
- throw new Error(`[toJSONSchema]: Non-representable type encountered: ${o.type}`);
1905
- m(e, t, h, d);
1906
- }
1907
- const l = e._zod.parent;
1908
- l && (s.ref || (s.ref = l), y(l, t, d), t.seen.get(l).isParent = !0);
1909
- }
1910
- const a = t.metadataRegistry.get(e);
1911
- return a && Object.assign(s.schema, a), t.io === "input" && $(e) && (delete s.schema.examples, delete s.schema.default), t.io === "input" && s.schema._prefault && ((r = s.schema).default ?? (r.default = s.schema._prefault)), delete s.schema._prefault, t.seen.get(e).schema;
1912
- }
1913
- function Ge(e, t) {
1914
- const n = e.seen.get(t);
1915
- if (!n)
1916
- throw new Error("Unprocessed schema. This is a bug in Zod.");
1917
- const r = /* @__PURE__ */ new Map();
1918
- for (const s of e.seen.entries()) {
1919
- const c = e.metadataRegistry.get(s[0])?.id;
1920
- if (c) {
1921
- const a = r.get(c);
1922
- if (a && a !== s[0])
1923
- throw new Error(`Duplicate schema id "${c}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);
1924
- r.set(c, s[0]);
1925
- }
1926
- }
1927
- const o = (s) => {
1928
- const c = e.target === "draft-2020-12" ? "$defs" : "definitions";
1929
- if (e.external) {
1930
- const l = e.external.registry.get(s[0])?.id, h = e.external.uri ?? ((b) => b);
1931
- if (l)
1932
- return { ref: h(l) };
1933
- const m = s[1].defId ?? s[1].schema.id ?? `schema${e.counter++}`;
1934
- return s[1].defId = m, { defId: m, ref: `${h("__shared")}#/${c}/${m}` };
1935
- }
1936
- if (s[1] === n)
1937
- return { ref: "#" };
1938
- const f = `#/${c}/`, d = s[1].schema.id ?? `__schema${e.counter++}`;
1939
- return { defId: d, ref: f + d };
1940
- }, i = (s) => {
1941
- if (s[1].schema.$ref)
1942
- return;
1943
- const c = s[1], { ref: a, defId: f } = o(s);
1944
- c.def = { ...c.schema }, f && (c.defId = f);
1945
- const d = c.schema;
1946
- for (const l in d)
1947
- delete d[l];
1948
- d.$ref = a;
1949
- };
1950
- if (e.cycles === "throw")
1951
- for (const s of e.seen.entries()) {
1952
- const c = s[1];
1953
- if (c.cycle)
1954
- throw new Error(`Cycle detected: #/${c.cycle?.join("/")}/<root>
1955
-
1956
- Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`);
1957
- }
1958
- for (const s of e.seen.entries()) {
1959
- const c = s[1];
1960
- if (t === s[0]) {
1961
- i(s);
1962
- continue;
1963
- }
1964
- if (e.external) {
1965
- const f = e.external.registry.get(s[0])?.id;
1966
- if (t !== s[0] && f) {
1967
- i(s);
1968
- continue;
1969
- }
1970
- }
1971
- if (e.metadataRegistry.get(s[0])?.id) {
1972
- i(s);
1973
- continue;
1974
- }
1975
- if (c.cycle) {
1976
- i(s);
1977
- continue;
1978
- }
1979
- if (c.count > 1 && e.reused === "ref") {
1980
- i(s);
1981
- continue;
1982
- }
1983
- }
1984
- }
1985
- function He(e, t) {
1986
- const n = e.seen.get(t);
1987
- if (!n)
1988
- throw new Error("Unprocessed schema. This is a bug in Zod.");
1989
- const r = (s) => {
1990
- const c = e.seen.get(s);
1991
- if (c.ref === null)
1992
- return;
1993
- const a = c.def ?? c.schema, f = { ...a }, d = c.ref;
1994
- if (c.ref = null, d) {
1995
- r(d);
1996
- const h = e.seen.get(d), m = h.schema;
1997
- if (m.$ref && (e.target === "draft-07" || e.target === "draft-04" || e.target === "openapi-3.0") ? (a.allOf = a.allOf ?? [], a.allOf.push(m)) : Object.assign(a, m), Object.assign(a, f), s._zod.parent === d)
1998
- for (const k in a)
1999
- k === "$ref" || k === "allOf" || k in f || delete a[k];
2000
- if (m.$ref)
2001
- for (const k in a)
2002
- k === "$ref" || k === "allOf" || k in h.def && JSON.stringify(a[k]) === JSON.stringify(h.def[k]) && delete a[k];
2003
- }
2004
- const l = s._zod.parent;
2005
- if (l && l !== d) {
2006
- r(l);
2007
- const h = e.seen.get(l);
2008
- if (h?.schema.$ref && (a.$ref = h.schema.$ref, h.def))
2009
- for (const m in a)
2010
- m === "$ref" || m === "allOf" || m in h.def && JSON.stringify(a[m]) === JSON.stringify(h.def[m]) && delete a[m];
2011
- }
2012
- e.override({
2013
- zodSchema: s,
2014
- jsonSchema: a,
2015
- path: c.path ?? []
2016
- });
2017
- };
2018
- for (const s of [...e.seen.entries()].reverse())
2019
- r(s[0]);
2020
- const o = {};
2021
- if (e.target === "draft-2020-12" ? o.$schema = "https://json-schema.org/draft/2020-12/schema" : e.target === "draft-07" ? o.$schema = "http://json-schema.org/draft-07/schema#" : e.target === "draft-04" ? o.$schema = "http://json-schema.org/draft-04/schema#" : e.target, e.external?.uri) {
2022
- const s = e.external.registry.get(t)?.id;
2023
- if (!s)
2024
- throw new Error("Schema is missing an `id` property");
2025
- o.$id = e.external.uri(s);
2026
- }
2027
- Object.assign(o, n.def ?? n.schema);
2028
- const i = e.external?.defs ?? {};
2029
- for (const s of e.seen.entries()) {
2030
- const c = s[1];
2031
- c.def && c.defId && (i[c.defId] = c.def);
2032
- }
2033
- e.external || Object.keys(i).length > 0 && (e.target === "draft-2020-12" ? o.$defs = i : o.definitions = i);
2034
- try {
2035
- const s = JSON.parse(JSON.stringify(o));
2036
- return Object.defineProperty(s, "~standard", {
2037
- value: {
2038
- ...t["~standard"],
2039
- jsonSchema: {
2040
- input: X(t, "input", e.processors),
2041
- output: X(t, "output", e.processors)
2042
- }
2043
- },
2044
- enumerable: !1,
2045
- writable: !1
2046
- }), s;
2047
- } catch {
2048
- throw new Error("Error converting schema to JSON.");
2049
- }
2050
- }
2051
- function $(e, t) {
2052
- const n = t ?? { seen: /* @__PURE__ */ new Set() };
2053
- if (n.seen.has(e))
2054
- return !1;
2055
- n.seen.add(e);
2056
- const r = e._zod.def;
2057
- if (r.type === "transform")
2058
- return !0;
2059
- if (r.type === "array")
2060
- return $(r.element, n);
2061
- if (r.type === "set")
2062
- return $(r.valueType, n);
2063
- if (r.type === "lazy")
2064
- return $(r.getter(), n);
2065
- if (r.type === "promise" || r.type === "optional" || r.type === "nonoptional" || r.type === "nullable" || r.type === "readonly" || r.type === "default" || r.type === "prefault")
2066
- return $(r.innerType, n);
2067
- if (r.type === "intersection")
2068
- return $(r.left, n) || $(r.right, n);
2069
- if (r.type === "record" || r.type === "map")
2070
- return $(r.keyType, n) || $(r.valueType, n);
2071
- if (r.type === "pipe")
2072
- return $(r.in, n) || $(r.out, n);
2073
- if (r.type === "object") {
2074
- for (const o in r.shape)
2075
- if ($(r.shape[o], n))
2076
- return !0;
2077
- return !1;
2078
- }
2079
- if (r.type === "union") {
2080
- for (const o of r.options)
2081
- if ($(o, n))
2082
- return !0;
2083
- return !1;
2084
- }
2085
- if (r.type === "tuple") {
2086
- for (const o of r.items)
2087
- if ($(o, n))
2088
- return !0;
2089
- return !!(r.rest && $(r.rest, n));
2090
- }
2091
- return !1;
2092
- }
2093
- const Br = (e, t = {}) => (n) => {
2094
- const r = qe({ ...n, processors: t });
2095
- return y(e, r), Ge(r, e), He(r, e);
2096
- }, X = (e, t, n = {}) => (r) => {
2097
- const { libraryOptions: o, target: i } = r ?? {}, s = qe({ ...o ?? {}, target: i, io: t, processors: n });
2098
- return y(e, s), Ge(s, e), He(s, e);
2099
- }, qr = {
2100
- guid: "uuid",
2101
- url: "uri",
2102
- datetime: "date-time",
2103
- json_string: "json-string",
2104
- regex: ""
2105
- // do not set
2106
- }, Gr = (e, t, n, r) => {
2107
- const o = n;
2108
- o.type = "string";
2109
- const { minimum: i, maximum: s, format: c, patterns: a, contentEncoding: f } = e._zod.bag;
2110
- if (typeof i == "number" && (o.minLength = i), typeof s == "number" && (o.maxLength = s), c && (o.format = qr[c] ?? c, o.format === "" && delete o.format, c === "time" && delete o.format), f && (o.contentEncoding = f), a && a.size > 0) {
2111
- const d = [...a];
2112
- d.length === 1 ? o.pattern = d[0].source : d.length > 1 && (o.allOf = [
2113
- ...d.map((l) => ({
2114
- ...t.target === "draft-07" || t.target === "draft-04" || t.target === "openapi-3.0" ? { type: "string" } : {},
2115
- pattern: l.source
2116
- }))
2117
- ]);
2118
- }
2119
- }, Hr = (e, t, n, r) => {
2120
- n.not = {};
2121
- }, Xr = (e, t, n, r) => {
2122
- }, Yr = (e, t, n, r) => {
2123
- const o = e._zod.def, i = Ae(o.entries);
2124
- i.every((s) => typeof s == "number") && (n.type = "number"), i.every((s) => typeof s == "string") && (n.type = "string"), n.enum = i;
2125
- }, Qr = (e, t, n, r) => {
2126
- if (t.unrepresentable === "throw")
2127
- throw new Error("Custom types cannot be represented in JSON Schema");
2128
- }, eo = (e, t, n, r) => {
2129
- if (t.unrepresentable === "throw")
2130
- throw new Error("Transforms cannot be represented in JSON Schema");
2131
- }, to = (e, t, n, r) => {
2132
- const o = n, i = e._zod.def, { minimum: s, maximum: c } = e._zod.bag;
2133
- typeof s == "number" && (o.minItems = s), typeof c == "number" && (o.maxItems = c), o.type = "array", o.items = y(i.element, t, { ...r, path: [...r.path, "items"] });
2134
- }, no = (e, t, n, r) => {
2135
- const o = n, i = e._zod.def;
2136
- o.type = "object", o.properties = {};
2137
- const s = i.shape;
2138
- for (const f in s)
2139
- o.properties[f] = y(s[f], t, {
2140
- ...r,
2141
- path: [...r.path, "properties", f]
2142
- });
2143
- const c = new Set(Object.keys(s)), a = new Set([...c].filter((f) => {
2144
- const d = i.shape[f]._zod;
2145
- return t.io === "input" ? d.optin === void 0 : d.optout === void 0;
2146
- }));
2147
- a.size > 0 && (o.required = Array.from(a)), i.catchall?._zod.def.type === "never" ? o.additionalProperties = !1 : i.catchall ? i.catchall && (o.additionalProperties = y(i.catchall, t, {
2148
- ...r,
2149
- path: [...r.path, "additionalProperties"]
2150
- })) : t.io === "output" && (o.additionalProperties = !1);
2151
- }, ro = (e, t, n, r) => {
2152
- const o = e._zod.def, i = o.inclusive === !1, s = o.options.map((c, a) => y(c, t, {
2153
- ...r,
2154
- path: [...r.path, i ? "oneOf" : "anyOf", a]
2155
- }));
2156
- i ? n.oneOf = s : n.anyOf = s;
2157
- }, oo = (e, t, n, r) => {
2158
- const o = e._zod.def, i = y(o.left, t, {
2159
- ...r,
2160
- path: [...r.path, "allOf", 0]
2161
- }), s = y(o.right, t, {
2162
- ...r,
2163
- path: [...r.path, "allOf", 1]
2164
- }), c = (f) => "allOf" in f && Object.keys(f).length === 1, a = [
2165
- ...c(i) ? i.allOf : [i],
2166
- ...c(s) ? s.allOf : [s]
2167
- ];
2168
- n.allOf = a;
2169
- }, so = (e, t, n, r) => {
2170
- const o = n, i = e._zod.def;
2171
- o.type = "object";
2172
- const s = i.keyType, a = s._zod.bag?.patterns;
2173
- if (i.mode === "loose" && a && a.size > 0) {
2174
- const d = y(i.valueType, t, {
2175
- ...r,
2176
- path: [...r.path, "patternProperties", "*"]
2177
- });
2178
- o.patternProperties = {};
2179
- for (const l of a)
2180
- o.patternProperties[l.source] = d;
2181
- } else
2182
- (t.target === "draft-07" || t.target === "draft-2020-12") && (o.propertyNames = y(i.keyType, t, {
2183
- ...r,
2184
- path: [...r.path, "propertyNames"]
2185
- })), o.additionalProperties = y(i.valueType, t, {
2186
- ...r,
2187
- path: [...r.path, "additionalProperties"]
2188
- });
2189
- const f = s._zod.values;
2190
- if (f) {
2191
- const d = [...f].filter((l) => typeof l == "string" || typeof l == "number");
2192
- d.length > 0 && (o.required = d);
2193
- }
2194
- }, io = (e, t, n, r) => {
2195
- const o = e._zod.def, i = y(o.innerType, t, r), s = t.seen.get(e);
2196
- t.target === "openapi-3.0" ? (s.ref = o.innerType, n.nullable = !0) : n.anyOf = [i, { type: "null" }];
2197
- }, co = (e, t, n, r) => {
2198
- const o = e._zod.def;
2199
- y(o.innerType, t, r);
2200
- const i = t.seen.get(e);
2201
- i.ref = o.innerType;
2202
- }, ao = (e, t, n, r) => {
2203
- const o = e._zod.def;
2204
- y(o.innerType, t, r);
2205
- const i = t.seen.get(e);
2206
- i.ref = o.innerType, n.default = JSON.parse(JSON.stringify(o.defaultValue));
2207
- }, uo = (e, t, n, r) => {
2208
- const o = e._zod.def;
2209
- y(o.innerType, t, r);
2210
- const i = t.seen.get(e);
2211
- i.ref = o.innerType, t.io === "input" && (n._prefault = JSON.parse(JSON.stringify(o.defaultValue)));
2212
- }, fo = (e, t, n, r) => {
2213
- const o = e._zod.def;
2214
- y(o.innerType, t, r);
2215
- const i = t.seen.get(e);
2216
- i.ref = o.innerType;
2217
- let s;
2218
- try {
2219
- s = o.catchValue(void 0);
2220
- } catch {
2221
- throw new Error("Dynamic catch values are not supported in JSON Schema");
2222
- }
2223
- n.default = s;
2224
- }, lo = (e, t, n, r) => {
2225
- const o = e._zod.def, i = t.io === "input" ? o.in._zod.def.type === "transform" ? o.out : o.in : o.out;
2226
- y(i, t, r);
2227
- const s = t.seen.get(e);
2228
- s.ref = i;
2229
- }, po = (e, t, n, r) => {
2230
- const o = e._zod.def;
2231
- y(o.innerType, t, r);
2232
- const i = t.seen.get(e);
2233
- i.ref = o.innerType, n.readOnly = !0;
2234
- }, Xe = (e, t, n, r) => {
2235
- const o = e._zod.def;
2236
- y(o.innerType, t, r);
2237
- const i = t.seen.get(e);
2238
- i.ref = o.innerType;
2239
- }, ho = /* @__PURE__ */ u("ZodISODateTime", (e, t) => {
2240
- bn.init(e, t), v.init(e, t);
2241
- });
2242
- function mo(e) {
2243
- return /* @__PURE__ */ Or(ho, e);
2244
- }
2245
- const go = /* @__PURE__ */ u("ZodISODate", (e, t) => {
2246
- $n.init(e, t), v.init(e, t);
2247
- });
2248
- function _o(e) {
2249
- return /* @__PURE__ */ Sr(go, e);
2250
- }
2251
- const vo = /* @__PURE__ */ u("ZodISOTime", (e, t) => {
2252
- Zn.init(e, t), v.init(e, t);
2253
- });
2254
- function yo(e) {
2255
- return /* @__PURE__ */ Pr(vo, e);
2256
- }
2257
- const zo = /* @__PURE__ */ u("ZodISODuration", (e, t) => {
2258
- On.init(e, t), v.init(e, t);
2259
- });
2260
- function wo(e) {
2261
- return /* @__PURE__ */ Er(zo, e);
2262
- }
2263
- const ko = (e, t) => {
2264
- De.init(e, t), e.name = "ZodError", Object.defineProperties(e, {
2265
- format: {
2266
- value: (n) => vt(e, n)
2267
- // enumerable: false,
2268
- },
2269
- flatten: {
2270
- value: (n) => _t(e, n)
2271
- // enumerable: false,
2272
- },
2273
- addIssue: {
2274
- value: (n) => {
2275
- e.issues.push(n), e.message = JSON.stringify(e.issues, ne, 2);
2276
- }
2277
- // enumerable: false,
2278
- },
2279
- addIssues: {
2280
- value: (n) => {
2281
- e.issues.push(...n), e.message = JSON.stringify(e.issues, ne, 2);
2282
- }
2283
- // enumerable: false,
2284
- },
2285
- isEmpty: {
2286
- get() {
2287
- return e.issues.length === 0;
2288
- }
2289
- // enumerable: false,
2290
- }
2291
- });
2292
- }, O = u("ZodError", ko, {
2293
- Parent: Error
2294
- }), bo = /* @__PURE__ */ ue(O), $o = /* @__PURE__ */ fe(O), Zo = /* @__PURE__ */ Q(O), Oo = /* @__PURE__ */ ee(O), So = /* @__PURE__ */ wt(O), Po = /* @__PURE__ */ kt(O), Eo = /* @__PURE__ */ bt(O), To = /* @__PURE__ */ $t(O), Io = /* @__PURE__ */ Zt(O), jo = /* @__PURE__ */ Ot(O), Ao = /* @__PURE__ */ St(O), Ro = /* @__PURE__ */ Pt(O), w = /* @__PURE__ */ u("ZodType", (e, t) => (z.init(e, t), Object.assign(e["~standard"], {
2295
- jsonSchema: {
2296
- input: X(e, "input"),
2297
- output: X(e, "output")
2298
- }
2299
- }), e.toJSONSchema = Br(e, {}), e.def = t, e.type = t.type, Object.defineProperty(e, "_def", { value: t }), e.check = (...n) => e.clone(j(t, {
2300
- checks: [
2301
- ...t.checks ?? [],
2302
- ...n.map((r) => typeof r == "function" ? { _zod: { check: r, def: { check: "custom" }, onattach: [] } } : r)
2303
- ]
2304
- }), {
2305
- parent: !0
2306
- }), e.with = e.check, e.clone = (n, r) => A(e, n, r), e.brand = () => e, e.register = ((n, r) => (n.add(e, r), e)), e.parse = (n, r) => bo(e, n, r, { callee: e.parse }), e.safeParse = (n, r) => Zo(e, n, r), e.parseAsync = async (n, r) => $o(e, n, r, { callee: e.parseAsync }), e.safeParseAsync = async (n, r) => Oo(e, n, r), e.spa = e.safeParseAsync, e.encode = (n, r) => So(e, n, r), e.decode = (n, r) => Po(e, n, r), e.encodeAsync = async (n, r) => Eo(e, n, r), e.decodeAsync = async (n, r) => To(e, n, r), e.safeEncode = (n, r) => Io(e, n, r), e.safeDecode = (n, r) => jo(e, n, r), e.safeEncodeAsync = async (n, r) => Ao(e, n, r), e.safeDecodeAsync = async (n, r) => Ro(e, n, r), e.refine = (n, r) => e.check(Ss(n, r)), e.superRefine = (n) => e.check(Ps(n)), e.overwrite = (n) => e.check(/* @__PURE__ */ F(n)), e.optional = () => Se(e), e.exactOptional = () => hs(e), e.nullable = () => Pe(e), e.nullish = () => Se(Pe(e)), e.nonoptional = (n) => zs(e, n), e.array = () => Qe(e), e.or = (n) => et([e, n]), e.and = (n) => cs(e, n), e.transform = (n) => Ee(e, ls(n)), e.default = (n) => _s(e, n), e.prefault = (n) => ys(e, n), e.catch = (n) => ks(e, n), e.pipe = (n) => Ee(e, n), e.readonly = () => Zs(e), e.describe = (n) => {
2307
- const r = e.clone();
2308
- return L.add(r, { description: n }), r;
2309
- }, Object.defineProperty(e, "description", {
2310
- get() {
2311
- return L.get(e)?.description;
2312
- },
2313
- configurable: !0
2314
- }), e.meta = (...n) => {
2315
- if (n.length === 0)
2316
- return L.get(e);
2317
- const r = e.clone();
2318
- return L.add(r, n[0]), r;
2319
- }, e.isOptional = () => e.safeParse(void 0).success, e.isNullable = () => e.safeParse(null).success, e.apply = (n) => n(e), e)), Ye = /* @__PURE__ */ u("_ZodString", (e, t) => {
2320
- de.init(e, t), w.init(e, t), e._zod.processJSONSchema = (r, o, i) => Gr(e, r, o);
2321
- const n = e._zod.bag;
2322
- e.format = n.format ?? null, e.minLength = n.minimum ?? null, e.maxLength = n.maximum ?? null, e.regex = (...r) => e.check(/* @__PURE__ */ jr(...r)), e.includes = (...r) => e.check(/* @__PURE__ */ Cr(...r)), e.startsWith = (...r) => e.check(/* @__PURE__ */ Nr(...r)), e.endsWith = (...r) => e.check(/* @__PURE__ */ Dr(...r)), e.min = (...r) => e.check(/* @__PURE__ */ H(...r)), e.max = (...r) => e.check(/* @__PURE__ */ Ke(...r)), e.length = (...r) => e.check(/* @__PURE__ */ Be(...r)), e.nonempty = (...r) => e.check(/* @__PURE__ */ H(1, ...r)), e.lowercase = (r) => e.check(/* @__PURE__ */ Ar(r)), e.uppercase = (r) => e.check(/* @__PURE__ */ Rr(r)), e.trim = () => e.check(/* @__PURE__ */ Jr()), e.normalize = (...r) => e.check(/* @__PURE__ */ Ur(...r)), e.toLowerCase = () => e.check(/* @__PURE__ */ Fr()), e.toUpperCase = () => e.check(/* @__PURE__ */ Lr()), e.slugify = () => e.check(/* @__PURE__ */ xr());
2323
- }), Co = /* @__PURE__ */ u("ZodString", (e, t) => {
2324
- de.init(e, t), Ye.init(e, t), e.email = (n) => e.check(/* @__PURE__ */ sr(No, n)), e.url = (n) => e.check(/* @__PURE__ */ fr(Do, n)), e.jwt = (n) => e.check(/* @__PURE__ */ Zr(Yo, n)), e.emoji = (n) => e.check(/* @__PURE__ */ dr(Uo, n)), e.guid = (n) => e.check(/* @__PURE__ */ $e(Ze, n)), e.uuid = (n) => e.check(/* @__PURE__ */ ir(B, n)), e.uuidv4 = (n) => e.check(/* @__PURE__ */ cr(B, n)), e.uuidv6 = (n) => e.check(/* @__PURE__ */ ar(B, n)), e.uuidv7 = (n) => e.check(/* @__PURE__ */ ur(B, n)), e.nanoid = (n) => e.check(/* @__PURE__ */ lr(Jo, n)), e.guid = (n) => e.check(/* @__PURE__ */ $e(Ze, n)), e.cuid = (n) => e.check(/* @__PURE__ */ pr(Fo, n)), e.cuid2 = (n) => e.check(/* @__PURE__ */ hr(Lo, n)), e.ulid = (n) => e.check(/* @__PURE__ */ mr(xo, n)), e.base64 = (n) => e.check(/* @__PURE__ */ kr(Go, n)), e.base64url = (n) => e.check(/* @__PURE__ */ br(Ho, n)), e.xid = (n) => e.check(/* @__PURE__ */ gr(Mo, n)), e.ksuid = (n) => e.check(/* @__PURE__ */ _r(Vo, n)), e.ipv4 = (n) => e.check(/* @__PURE__ */ vr(Wo, n)), e.ipv6 = (n) => e.check(/* @__PURE__ */ yr(Ko, n)), e.cidrv4 = (n) => e.check(/* @__PURE__ */ zr(Bo, n)), e.cidrv6 = (n) => e.check(/* @__PURE__ */ wr(qo, n)), e.e164 = (n) => e.check(/* @__PURE__ */ $r(Xo, n)), e.datetime = (n) => e.check(mo(n)), e.date = (n) => e.check(_o(n)), e.time = (n) => e.check(yo(n)), e.duration = (n) => e.check(wo(n));
2325
- });
2326
- function K(e) {
2327
- return /* @__PURE__ */ or(Co, e);
2328
- }
2329
- const v = /* @__PURE__ */ u("ZodStringFormat", (e, t) => {
2330
- _.init(e, t), Ye.init(e, t);
2331
- }), No = /* @__PURE__ */ u("ZodEmail", (e, t) => {
2332
- hn.init(e, t), v.init(e, t);
2333
- }), Ze = /* @__PURE__ */ u("ZodGUID", (e, t) => {
2334
- ln.init(e, t), v.init(e, t);
2335
- }), B = /* @__PURE__ */ u("ZodUUID", (e, t) => {
2336
- pn.init(e, t), v.init(e, t);
2337
- }), Do = /* @__PURE__ */ u("ZodURL", (e, t) => {
2338
- mn.init(e, t), v.init(e, t);
2339
- }), Uo = /* @__PURE__ */ u("ZodEmoji", (e, t) => {
2340
- gn.init(e, t), v.init(e, t);
2341
- }), Jo = /* @__PURE__ */ u("ZodNanoID", (e, t) => {
2342
- _n.init(e, t), v.init(e, t);
2343
- }), Fo = /* @__PURE__ */ u("ZodCUID", (e, t) => {
2344
- vn.init(e, t), v.init(e, t);
2345
- }), Lo = /* @__PURE__ */ u("ZodCUID2", (e, t) => {
2346
- yn.init(e, t), v.init(e, t);
2347
- }), xo = /* @__PURE__ */ u("ZodULID", (e, t) => {
2348
- zn.init(e, t), v.init(e, t);
2349
- }), Mo = /* @__PURE__ */ u("ZodXID", (e, t) => {
2350
- wn.init(e, t), v.init(e, t);
2351
- }), Vo = /* @__PURE__ */ u("ZodKSUID", (e, t) => {
2352
- kn.init(e, t), v.init(e, t);
2353
- }), Wo = /* @__PURE__ */ u("ZodIPv4", (e, t) => {
2354
- Sn.init(e, t), v.init(e, t);
2355
- }), Ko = /* @__PURE__ */ u("ZodIPv6", (e, t) => {
2356
- Pn.init(e, t), v.init(e, t);
2357
- }), Bo = /* @__PURE__ */ u("ZodCIDRv4", (e, t) => {
2358
- En.init(e, t), v.init(e, t);
2359
- }), qo = /* @__PURE__ */ u("ZodCIDRv6", (e, t) => {
2360
- Tn.init(e, t), v.init(e, t);
2361
- }), Go = /* @__PURE__ */ u("ZodBase64", (e, t) => {
2362
- In.init(e, t), v.init(e, t);
2363
- }), Ho = /* @__PURE__ */ u("ZodBase64URL", (e, t) => {
2364
- An.init(e, t), v.init(e, t);
2365
- }), Xo = /* @__PURE__ */ u("ZodE164", (e, t) => {
2366
- Rn.init(e, t), v.init(e, t);
2367
- }), Yo = /* @__PURE__ */ u("ZodJWT", (e, t) => {
2368
- Nn.init(e, t), v.init(e, t);
2369
- }), Qo = /* @__PURE__ */ u("ZodUnknown", (e, t) => {
2370
- Dn.init(e, t), w.init(e, t), e._zod.processJSONSchema = (n, r, o) => Xr();
2371
- });
2372
- function Oe() {
2373
- return /* @__PURE__ */ Tr(Qo);
2374
- }
2375
- const es = /* @__PURE__ */ u("ZodNever", (e, t) => {
2376
- Un.init(e, t), w.init(e, t), e._zod.processJSONSchema = (n, r, o) => Hr(e, n, r);
2377
- });
2378
- function ts(e) {
2379
- return /* @__PURE__ */ Ir(es, e);
2380
- }
2381
- const ns = /* @__PURE__ */ u("ZodArray", (e, t) => {
2382
- Jn.init(e, t), w.init(e, t), e._zod.processJSONSchema = (n, r, o) => to(e, n, r, o), e.element = t.element, e.min = (n, r) => e.check(/* @__PURE__ */ H(n, r)), e.nonempty = (n) => e.check(/* @__PURE__ */ H(1, n)), e.max = (n, r) => e.check(/* @__PURE__ */ Ke(n, r)), e.length = (n, r) => e.check(/* @__PURE__ */ Be(n, r)), e.unwrap = () => e.element;
2383
- });
2384
- function Qe(e, t) {
2385
- return /* @__PURE__ */ Mr(ns, e, t);
2386
- }
2387
- const rs = /* @__PURE__ */ u("ZodObject", (e, t) => {
2388
- Ln.init(e, t), w.init(e, t), e._zod.processJSONSchema = (n, r, o) => no(e, n, r, o), g(e, "shape", () => t.shape), e.keyof = () => fs(Object.keys(e._zod.def.shape)), e.catchall = (n) => e.clone({ ...e._zod.def, catchall: n }), e.passthrough = () => e.clone({ ...e._zod.def, catchall: Oe() }), e.loose = () => e.clone({ ...e._zod.def, catchall: Oe() }), e.strict = () => e.clone({ ...e._zod.def, catchall: ts() }), e.strip = () => e.clone({ ...e._zod.def, catchall: void 0 }), e.extend = (n) => lt(e, n), e.safeExtend = (n) => pt(e, n), e.merge = (n) => ht(e, n), e.pick = (n) => ft(e, n), e.omit = (n) => dt(e, n), e.partial = (...n) => mt(tt, e, n[0]), e.required = (...n) => gt(nt, e, n[0]);
2389
- });
2390
- function os(e, t) {
2391
- const n = {
2392
- type: "object",
2393
- shape: e ?? {},
2394
- ...p(t)
2395
- };
2396
- return new rs(n);
2397
- }
2398
- const ss = /* @__PURE__ */ u("ZodUnion", (e, t) => {
2399
- xn.init(e, t), w.init(e, t), e._zod.processJSONSchema = (n, r, o) => ro(e, n, r, o), e.options = t.options;
2400
- });
2401
- function et(e, t) {
2402
- return new ss({
2403
- type: "union",
2404
- options: e,
2405
- ...p(t)
2406
- });
2407
- }
2408
- const is = /* @__PURE__ */ u("ZodIntersection", (e, t) => {
2409
- Mn.init(e, t), w.init(e, t), e._zod.processJSONSchema = (n, r, o) => oo(e, n, r, o);
2410
- });
2411
- function cs(e, t) {
2412
- return new is({
2413
- type: "intersection",
2414
- left: e,
2415
- right: t
2416
- });
2417
- }
2418
- const as = /* @__PURE__ */ u("ZodRecord", (e, t) => {
2419
- Vn.init(e, t), w.init(e, t), e._zod.processJSONSchema = (n, r, o) => so(e, n, r, o), e.keyType = t.keyType, e.valueType = t.valueType;
2420
- });
2421
- function us(e, t, n) {
2422
- return new as({
2423
- type: "record",
2424
- keyType: e,
2425
- valueType: t,
2426
- ...p(n)
2427
- });
2428
- }
2429
- const oe = /* @__PURE__ */ u("ZodEnum", (e, t) => {
2430
- Wn.init(e, t), w.init(e, t), e._zod.processJSONSchema = (r, o, i) => Yr(e, r, o), e.enum = t.entries, e.options = Object.values(t.entries);
2431
- const n = new Set(Object.keys(t.entries));
2432
- e.extract = (r, o) => {
2433
- const i = {};
2434
- for (const s of r)
2435
- if (n.has(s))
2436
- i[s] = t.entries[s];
2437
- else
2438
- throw new Error(`Key ${s} not found in enum`);
2439
- return new oe({
2440
- ...t,
2441
- checks: [],
2442
- ...p(o),
2443
- entries: i
2444
- });
2445
- }, e.exclude = (r, o) => {
2446
- const i = { ...t.entries };
2447
- for (const s of r)
2448
- if (n.has(s))
2449
- delete i[s];
2450
- else
2451
- throw new Error(`Key ${s} not found in enum`);
2452
- return new oe({
2453
- ...t,
2454
- checks: [],
2455
- ...p(o),
2456
- entries: i
2457
- });
2458
- };
2459
- });
2460
- function fs(e, t) {
2461
- const n = Array.isArray(e) ? Object.fromEntries(e.map((r) => [r, r])) : e;
2462
- return new oe({
2463
- type: "enum",
2464
- entries: n,
2465
- ...p(t)
2466
- });
2467
- }
2468
- const ds = /* @__PURE__ */ u("ZodTransform", (e, t) => {
2469
- Kn.init(e, t), w.init(e, t), e._zod.processJSONSchema = (n, r, o) => eo(e, n), e._zod.parse = (n, r) => {
2470
- if (r.direction === "backward")
2471
- throw new Ie(e.constructor.name);
2472
- n.addIssue = (i) => {
2473
- if (typeof i == "string")
2474
- n.issues.push(x(i, n.value, t));
2475
- else {
2476
- const s = i;
2477
- s.fatal && (s.continue = !1), s.code ?? (s.code = "custom"), s.input ?? (s.input = n.value), s.inst ?? (s.inst = e), n.issues.push(x(s));
2478
- }
2479
- };
2480
- const o = t.transform(n.value, n);
2481
- return o instanceof Promise ? o.then((i) => (n.value = i, n)) : (n.value = o, n);
2482
- };
2483
- });
2484
- function ls(e) {
2485
- return new ds({
2486
- type: "transform",
2487
- transform: e
2488
- });
2489
- }
2490
- const tt = /* @__PURE__ */ u("ZodOptional", (e, t) => {
2491
- We.init(e, t), w.init(e, t), e._zod.processJSONSchema = (n, r, o) => Xe(e, n, r, o), e.unwrap = () => e._zod.def.innerType;
2492
- });
2493
- function Se(e) {
2494
- return new tt({
2495
- type: "optional",
2496
- innerType: e
2497
- });
2498
- }
2499
- const ps = /* @__PURE__ */ u("ZodExactOptional", (e, t) => {
2500
- Bn.init(e, t), w.init(e, t), e._zod.processJSONSchema = (n, r, o) => Xe(e, n, r, o), e.unwrap = () => e._zod.def.innerType;
2501
- });
2502
- function hs(e) {
2503
- return new ps({
2504
- type: "optional",
2505
- innerType: e
2506
- });
2507
- }
2508
- const ms = /* @__PURE__ */ u("ZodNullable", (e, t) => {
2509
- qn.init(e, t), w.init(e, t), e._zod.processJSONSchema = (n, r, o) => io(e, n, r, o), e.unwrap = () => e._zod.def.innerType;
2510
- });
2511
- function Pe(e) {
2512
- return new ms({
2513
- type: "nullable",
2514
- innerType: e
2515
- });
2516
- }
2517
- const gs = /* @__PURE__ */ u("ZodDefault", (e, t) => {
2518
- Gn.init(e, t), w.init(e, t), e._zod.processJSONSchema = (n, r, o) => ao(e, n, r, o), e.unwrap = () => e._zod.def.innerType, e.removeDefault = e.unwrap;
2519
- });
2520
- function _s(e, t) {
2521
- return new gs({
2522
- type: "default",
2523
- innerType: e,
2524
- get defaultValue() {
2525
- return typeof t == "function" ? t() : Ce(t);
2526
- }
2527
- });
2528
- }
2529
- const vs = /* @__PURE__ */ u("ZodPrefault", (e, t) => {
2530
- Hn.init(e, t), w.init(e, t), e._zod.processJSONSchema = (n, r, o) => uo(e, n, r, o), e.unwrap = () => e._zod.def.innerType;
2531
- });
2532
- function ys(e, t) {
2533
- return new vs({
2534
- type: "prefault",
2535
- innerType: e,
2536
- get defaultValue() {
2537
- return typeof t == "function" ? t() : Ce(t);
2538
- }
2539
- });
2540
- }
2541
- const nt = /* @__PURE__ */ u("ZodNonOptional", (e, t) => {
2542
- Xn.init(e, t), w.init(e, t), e._zod.processJSONSchema = (n, r, o) => co(e, n, r, o), e.unwrap = () => e._zod.def.innerType;
2543
- });
2544
- function zs(e, t) {
2545
- return new nt({
2546
- type: "nonoptional",
2547
- innerType: e,
2548
- ...p(t)
2549
- });
2550
- }
2551
- const ws = /* @__PURE__ */ u("ZodCatch", (e, t) => {
2552
- Yn.init(e, t), w.init(e, t), e._zod.processJSONSchema = (n, r, o) => fo(e, n, r, o), e.unwrap = () => e._zod.def.innerType, e.removeCatch = e.unwrap;
2553
- });
2554
- function ks(e, t) {
2555
- return new ws({
2556
- type: "catch",
2557
- innerType: e,
2558
- catchValue: typeof t == "function" ? t : () => t
2559
- });
2560
- }
2561
- const bs = /* @__PURE__ */ u("ZodPipe", (e, t) => {
2562
- Qn.init(e, t), w.init(e, t), e._zod.processJSONSchema = (n, r, o) => lo(e, n, r, o), e.in = t.in, e.out = t.out;
2563
- });
2564
- function Ee(e, t) {
2565
- return new bs({
2566
- type: "pipe",
2567
- in: e,
2568
- out: t
2569
- // ...util.normalizeParams(params),
2570
- });
2571
- }
2572
- const $s = /* @__PURE__ */ u("ZodReadonly", (e, t) => {
2573
- er.init(e, t), w.init(e, t), e._zod.processJSONSchema = (n, r, o) => po(e, n, r, o), e.unwrap = () => e._zod.def.innerType;
2574
- });
2575
- function Zs(e) {
2576
- return new $s({
2577
- type: "readonly",
2578
- innerType: e
2579
- });
2580
- }
2581
- const Os = /* @__PURE__ */ u("ZodCustom", (e, t) => {
2582
- tr.init(e, t), w.init(e, t), e._zod.processJSONSchema = (n, r, o) => Qr(e, n);
2583
- });
2584
- function Ss(e, t = {}) {
2585
- return /* @__PURE__ */ Vr(Os, e, t);
2586
- }
2587
- function Ps(e) {
2588
- return /* @__PURE__ */ Wr(e);
2589
- }
2590
- const Es = os({
2591
- message: K().optional(),
2592
- fieldErrors: us(K(), et([K(), Qe(K())])).optional()
2593
- }), Ts = (e) => {
2594
- const t = Es.safeParse(e), n = t.success && !t.data.message && !t.data.fieldErrors;
2595
- return !t.success || n ? {
2596
- message: "Unexpected server error"
2597
- } : t.data;
2598
- };
2599
- class C extends Te {
2600
- data;
2601
- response;
2602
- constructor(t, n) {
2603
- super(n.message ?? "API Error"), this.name = "API Error", this.data = n, this.response = t;
2604
- }
2605
- }
2606
- const Is = 1e3, As = (e) => {
2607
- if (e instanceof TypeError && (e.message === "Failed to fetch" || e.message === "NetworkError when attempting to fetch resource." || e.message === "Load failed" || // Safari
2608
- e.message.includes("NetworkError") || e.message.includes("fetch")))
2609
- return {
2610
- errorCode: "network-error",
2611
- message: "Check your network connection or try again later."
2612
- };
2613
- if (e instanceof C) {
2614
- if (e.response.status >= 500)
2615
- return {
2616
- errorCode: "server-error",
2617
- message: e.data?.message ?? "Internal server error. Please try again later."
2618
- };
2619
- switch (e.response.status) {
2620
- case 422:
2621
- return {
2622
- errorCode: "form-field-error",
2623
- fieldErrors: e.data.fieldErrors ?? {}
2624
- };
2625
- case 400:
2626
- return {
2627
- errorCode: "user-action-error",
2628
- message: e.data?.message ?? "Something went wrong while processing your request."
2629
- };
2630
- case 401:
2631
- return {
2632
- errorCode: "authentication-error",
2633
- message: e.data?.message ?? "User login required."
2634
- };
2635
- case 403:
2636
- return {
2637
- errorCode: "authorization-error",
2638
- message: e.data?.message ?? "You don't have necessary permissions to perform the requested action."
2639
- };
2640
- case 404:
2641
- return {
2642
- errorCode: "not-found-error",
2643
- message: e.data?.message ?? "Requested action not found."
2644
- };
2645
- case 405:
2646
- return {
2647
- errorCode: "method-not-allowed-error",
2648
- message: e.data?.message ?? "Requested action method not allowed."
2649
- };
2650
- case 429:
2651
- const t = e.response.headers.get("retry-after");
2652
- let n = Is;
2653
- if (t) {
2654
- const r = parseInt(t, 10);
2655
- if (!isNaN(r))
2656
- n = r * 1e3;
2657
- else {
2658
- const o = new Date(t);
2659
- isNaN(o.getTime()) || (n = Math.max(0, o.getTime() - Date.now()));
2660
- }
2661
- }
2662
- return {
2663
- errorCode: "too-many-requests-error",
2664
- retryAfter: n,
2665
- message: "Too many requests. Try again later."
2666
- };
2667
- case 413:
2668
- return {
2669
- errorCode: "content-too-large-error",
2670
- message: e.data?.message ?? "Request content too large."
2671
- };
2672
- default:
2673
- return {
2674
- errorCode: "unknown-error",
2675
- message: e.data?.message ?? "Unexpected error occurred."
2676
- };
2677
- }
2678
- }
2679
- return e instanceof Te ? {
2680
- errorCode: "unknown-error",
2681
- message: e.message
2682
- } : {
2683
- errorCode: "unknown-error",
2684
- message: "Unknown error occurred. Please refresh this page or try again later."
2685
- };
2686
- };
2687
- async function Rs(e, t) {
2688
- const n = await e.text();
2689
- if (!n) {
2690
- if (e.ok) {
2691
- if (t)
2692
- throw new C(e, {
2693
- message: "Expected response body but received empty response"
2694
- });
2695
- return null;
2696
- }
2697
- throw new C(e, {
2698
- message: "Empty error response from server"
2699
- });
2700
- }
2701
- let r;
2702
- try {
2703
- r = JSON.parse(n);
2704
- } catch {
2705
- const s = e.ok ? "Malformed JSON response from server" : "Malformed error response from server";
2706
- throw new C(e, { message: s });
2707
- }
2708
- if (e.ok) {
2709
- if (!t)
2710
- return null;
2711
- const i = t.safeParse(r);
2712
- if (!i.success)
2713
- throw new C(e, {
2714
- message: `Invalid response shape from server: ${i.error.message}`
2715
- });
2716
- return i.data;
2717
- }
2718
- const o = Ts(r);
2719
- throw new C(e, o);
2720
- }
1
+ import { HTTP_DELETE as _, HTTP_GET as a, HTTP_HEADER_AUTHORIZATION as o, HTTP_HEADER_AUTHORIZATION_BASIC_SCHEME as e, HTTP_HEADER_AUTHORIZATION_BEARER_SCHEME as s, HTTP_HEADER_CONTENT_TYPE as A, HTTP_HEADER_CONTENT_TYPE_APPLICATION_JSON as P, HTTP_HEADER_USER_LOCALE as H, HTTP_PATCH as r, HTTP_POST as I, HTTP_PUT as R, HTTP_REQUEST_CREDENTIALS_INCLUDE as p, HTTP_REQUEST_CREDENTIALS_NONE as N, HTTP_REQUEST_CREDENTIALS_SAME_ORIGIN as d } from "./constants/index.js";
2
+ import { A as D, B as O, n as S } from "./chunks/apiError";
3
+ import { p as l } from "./chunks/parse";
4
+ import { U as n, n as m, a as L, b as f, c as i, t as w, d as x, u as M, e as B } from "./chunks/upload";
5
+ import { d as u } from "./chunks/decode";
2721
6
  export {
2722
- C as APIError,
2723
- Te as BaseError,
2724
- Rs as decodeAPIResponse,
2725
- Ts as newAPIErrorResponse,
2726
- As as parseError
7
+ D as APIError,
8
+ O as BaseError,
9
+ _ as HTTP_DELETE,
10
+ a as HTTP_GET,
11
+ o as HTTP_HEADER_AUTHORIZATION,
12
+ e as HTTP_HEADER_AUTHORIZATION_BASIC_SCHEME,
13
+ s as HTTP_HEADER_AUTHORIZATION_BEARER_SCHEME,
14
+ A as HTTP_HEADER_CONTENT_TYPE,
15
+ P as HTTP_HEADER_CONTENT_TYPE_APPLICATION_JSON,
16
+ H as HTTP_HEADER_USER_LOCALE,
17
+ r as HTTP_PATCH,
18
+ I as HTTP_POST,
19
+ R as HTTP_PUT,
20
+ p as HTTP_REQUEST_CREDENTIALS_INCLUDE,
21
+ N as HTTP_REQUEST_CREDENTIALS_NONE,
22
+ d as HTTP_REQUEST_CREDENTIALS_SAME_ORIGIN,
23
+ n as UploadDetailsAPIResSchema,
24
+ u as decodeAPIResponse,
25
+ S as newAPIErrorResponse,
26
+ m as newMediaInfo,
27
+ L as newMediaInfos,
28
+ f as newUploadDetails,
29
+ i as newUploadsDetails,
30
+ l as parseError,
31
+ w as toUploadPayload,
32
+ x as toUploadPayloads,
33
+ M as uploadItem,
34
+ B as uploadItems
2727
35
  };
2728
- //# sourceMappingURL=index.js.map