@magiclabs.ai/magicbook-client 0.6.3 → 0.6.5-canary

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4666 +0,0 @@
1
- var bs = Object.defineProperty;
2
- var ws = (t, e, s) => e in t ? bs(t, e, { enumerable: !0, configurable: !0, writable: !0, value: s }) : t[e] = s;
3
- var _ = (t, e, s) => (ws(t, typeof e != "symbol" ? e + "" : e, s), s);
4
- function xs(t, e, s) {
5
- const n = e.pop() || "", r = e.reduce(
6
- (a, i) => a[i] = a[i] || {},
7
- t
8
- );
9
- r[n] = s;
10
- }
11
- function jt(t, e) {
12
- return Object.keys(e).map((s) => {
13
- typeof t[s] == "object" && typeof e[s] == "object" ? jt(t[s], e[s]) : t[s] = e[s];
14
- }), t;
15
- }
16
- function ks(t) {
17
- return t.replace(/([a-z])([A-Z])/g, "$1_$2").toLowerCase();
18
- }
19
- function Zt(t) {
20
- return Object.keys(t).map((e) => {
21
- const s = ks(e);
22
- s.includes("_") && (t[s] = t[e], delete t[e]), typeof t[s] == "object" && (t[s] = Zt(t[s]));
23
- }), t;
24
- }
25
- function Ss(t) {
26
- return t.replace(/([-_][a-z])/g, (e) => e.toUpperCase().replace("-", "").replace("_", ""));
27
- }
28
- function Lt(t) {
29
- return Object.keys(t).map((e) => {
30
- const s = Ss(e);
31
- s !== e && (t[s] = t[e], delete t[e]), typeof t[s] == "object" && (t[s] = Lt(t[s]));
32
- }), t;
33
- }
34
- function Dt(t, e) {
35
- return function() {
36
- return t.apply(e, arguments);
37
- };
38
- }
39
- const { toString: Ts } = Object.prototype, { getPrototypeOf: ct } = Object, ze = ((t) => (e) => {
40
- const s = Ts.call(e);
41
- return t[s] || (t[s] = s.slice(8, -1).toLowerCase());
42
- })(/* @__PURE__ */ Object.create(null)), z = (t) => (t = t.toLowerCase(), (e) => ze(e) === t), Ve = (t) => (e) => typeof e === t, { isArray: le } = Array, de = Ve("undefined");
43
- function Es(t) {
44
- return t !== null && !de(t) && t.constructor !== null && !de(t.constructor) && j(t.constructor.isBuffer) && t.constructor.isBuffer(t);
45
- }
46
- const Pt = z("ArrayBuffer");
47
- function Os(t) {
48
- let e;
49
- return typeof ArrayBuffer < "u" && ArrayBuffer.isView ? e = ArrayBuffer.isView(t) : e = t && t.buffer && Pt(t.buffer), e;
50
- }
51
- const Ns = Ve("string"), j = Ve("function"), Bt = Ve("number"), Fe = (t) => t !== null && typeof t == "object", Cs = (t) => t === !0 || t === !1, Oe = (t) => {
52
- if (ze(t) !== "object")
53
- return !1;
54
- const e = ct(t);
55
- return (e === null || e === Object.prototype || Object.getPrototypeOf(e) === null) && !(Symbol.toStringTag in t) && !(Symbol.iterator in t);
56
- }, As = z("Date"), Rs = z("File"), Is = z("Blob"), js = z("FileList"), Zs = (t) => Fe(t) && j(t.pipe), Ls = (t) => {
57
- let e;
58
- return t && (typeof FormData == "function" && t instanceof FormData || j(t.append) && ((e = ze(t)) === "formdata" || // detect form-data instance
59
- e === "object" && j(t.toString) && t.toString() === "[object FormData]"));
60
- }, Ds = z("URLSearchParams"), Ps = (t) => t.trim ? t.trim() : t.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g, "");
61
- function ke(t, e, { allOwnKeys: s = !1 } = {}) {
62
- if (t === null || typeof t > "u")
63
- return;
64
- let n, r;
65
- if (typeof t != "object" && (t = [t]), le(t))
66
- for (n = 0, r = t.length; n < r; n++)
67
- e.call(null, t[n], n, t);
68
- else {
69
- const a = s ? Object.getOwnPropertyNames(t) : Object.keys(t), i = a.length;
70
- let o;
71
- for (n = 0; n < i; n++)
72
- o = a[n], e.call(null, t[o], o, t);
73
- }
74
- }
75
- function Mt(t, e) {
76
- e = e.toLowerCase();
77
- const s = Object.keys(t);
78
- let n = s.length, r;
79
- for (; n-- > 0; )
80
- if (r = s[n], e === r.toLowerCase())
81
- return r;
82
- return null;
83
- }
84
- const Ut = (() => typeof globalThis < "u" ? globalThis : typeof self < "u" ? self : typeof window < "u" ? window : global)(), $t = (t) => !de(t) && t !== Ut;
85
- function tt() {
86
- const { caseless: t } = $t(this) && this || {}, e = {}, s = (n, r) => {
87
- const a = t && Mt(e, r) || r;
88
- Oe(e[a]) && Oe(n) ? e[a] = tt(e[a], n) : Oe(n) ? e[a] = tt({}, n) : le(n) ? e[a] = n.slice() : e[a] = n;
89
- };
90
- for (let n = 0, r = arguments.length; n < r; n++)
91
- arguments[n] && ke(arguments[n], s);
92
- return e;
93
- }
94
- const Bs = (t, e, s, { allOwnKeys: n } = {}) => (ke(e, (r, a) => {
95
- s && j(r) ? t[a] = Dt(r, s) : t[a] = r;
96
- }, { allOwnKeys: n }), t), Ms = (t) => (t.charCodeAt(0) === 65279 && (t = t.slice(1)), t), Us = (t, e, s, n) => {
97
- t.prototype = Object.create(e.prototype, n), t.prototype.constructor = t, Object.defineProperty(t, "super", {
98
- value: e.prototype
99
- }), s && Object.assign(t.prototype, s);
100
- }, $s = (t, e, s, n) => {
101
- let r, a, i;
102
- const o = {};
103
- if (e = e || {}, t == null)
104
- return e;
105
- do {
106
- for (r = Object.getOwnPropertyNames(t), a = r.length; a-- > 0; )
107
- i = r[a], (!n || n(i, t, e)) && !o[i] && (e[i] = t[i], o[i] = !0);
108
- t = s !== !1 && ct(t);
109
- } while (t && (!s || s(t, e)) && t !== Object.prototype);
110
- return e;
111
- }, zs = (t, e, s) => {
112
- t = String(t), (s === void 0 || s > t.length) && (s = t.length), s -= e.length;
113
- const n = t.indexOf(e, s);
114
- return n !== -1 && n === s;
115
- }, Vs = (t) => {
116
- if (!t)
117
- return null;
118
- if (le(t))
119
- return t;
120
- let e = t.length;
121
- if (!Bt(e))
122
- return null;
123
- const s = new Array(e);
124
- for (; e-- > 0; )
125
- s[e] = t[e];
126
- return s;
127
- }, Fs = ((t) => (e) => t && e instanceof t)(typeof Uint8Array < "u" && ct(Uint8Array)), Hs = (t, e) => {
128
- const n = (t && t[Symbol.iterator]).call(t);
129
- let r;
130
- for (; (r = n.next()) && !r.done; ) {
131
- const a = r.value;
132
- e.call(t, a[0], a[1]);
133
- }
134
- }, Js = (t, e) => {
135
- let s;
136
- const n = [];
137
- for (; (s = t.exec(e)) !== null; )
138
- n.push(s);
139
- return n;
140
- }, Ws = z("HTMLFormElement"), Ks = (t) => t.toLowerCase().replace(
141
- /[-_\s]([a-z\d])(\w*)/g,
142
- function(s, n, r) {
143
- return n.toUpperCase() + r;
144
- }
145
- ), _t = (({ hasOwnProperty: t }) => (e, s) => t.call(e, s))(Object.prototype), qs = z("RegExp"), zt = (t, e) => {
146
- const s = Object.getOwnPropertyDescriptors(t), n = {};
147
- ke(s, (r, a) => {
148
- e(r, a, t) !== !1 && (n[a] = r);
149
- }), Object.defineProperties(t, n);
150
- }, Gs = (t) => {
151
- zt(t, (e, s) => {
152
- if (j(t) && ["arguments", "caller", "callee"].indexOf(s) !== -1)
153
- return !1;
154
- const n = t[s];
155
- if (j(n)) {
156
- if (e.enumerable = !1, "writable" in e) {
157
- e.writable = !1;
158
- return;
159
- }
160
- e.set || (e.set = () => {
161
- throw Error("Can not rewrite read-only method '" + s + "'");
162
- });
163
- }
164
- });
165
- }, Xs = (t, e) => {
166
- const s = {}, n = (r) => {
167
- r.forEach((a) => {
168
- s[a] = !0;
169
- });
170
- };
171
- return le(t) ? n(t) : n(String(t).split(e)), s;
172
- }, Ys = () => {
173
- }, Qs = (t, e) => (t = +t, Number.isFinite(t) ? t : e), Ge = "abcdefghijklmnopqrstuvwxyz", bt = "0123456789", Vt = {
174
- DIGIT: bt,
175
- ALPHA: Ge,
176
- ALPHA_DIGIT: Ge + Ge.toUpperCase() + bt
177
- }, en = (t = 16, e = Vt.ALPHA_DIGIT) => {
178
- let s = "";
179
- const { length: n } = e;
180
- for (; t--; )
181
- s += e[Math.random() * n | 0];
182
- return s;
183
- };
184
- function tn(t) {
185
- return !!(t && j(t.append) && t[Symbol.toStringTag] === "FormData" && t[Symbol.iterator]);
186
- }
187
- const sn = (t) => {
188
- const e = new Array(10), s = (n, r) => {
189
- if (Fe(n)) {
190
- if (e.indexOf(n) >= 0)
191
- return;
192
- if (!("toJSON" in n)) {
193
- e[r] = n;
194
- const a = le(n) ? [] : {};
195
- return ke(n, (i, o) => {
196
- const u = s(i, r + 1);
197
- !de(u) && (a[o] = u);
198
- }), e[r] = void 0, a;
199
- }
200
- }
201
- return n;
202
- };
203
- return s(t, 0);
204
- }, nn = z("AsyncFunction"), rn = (t) => t && (Fe(t) || j(t)) && j(t.then) && j(t.catch), c = {
205
- isArray: le,
206
- isArrayBuffer: Pt,
207
- isBuffer: Es,
208
- isFormData: Ls,
209
- isArrayBufferView: Os,
210
- isString: Ns,
211
- isNumber: Bt,
212
- isBoolean: Cs,
213
- isObject: Fe,
214
- isPlainObject: Oe,
215
- isUndefined: de,
216
- isDate: As,
217
- isFile: Rs,
218
- isBlob: Is,
219
- isRegExp: qs,
220
- isFunction: j,
221
- isStream: Zs,
222
- isURLSearchParams: Ds,
223
- isTypedArray: Fs,
224
- isFileList: js,
225
- forEach: ke,
226
- merge: tt,
227
- extend: Bs,
228
- trim: Ps,
229
- stripBOM: Ms,
230
- inherits: Us,
231
- toFlatObject: $s,
232
- kindOf: ze,
233
- kindOfTest: z,
234
- endsWith: zs,
235
- toArray: Vs,
236
- forEachEntry: Hs,
237
- matchAll: Js,
238
- isHTMLForm: Ws,
239
- hasOwnProperty: _t,
240
- hasOwnProp: _t,
241
- // an alias to avoid ESLint no-prototype-builtins detection
242
- reduceDescriptors: zt,
243
- freezeMethods: Gs,
244
- toObjectSet: Xs,
245
- toCamelCase: Ks,
246
- noop: Ys,
247
- toFiniteNumber: Qs,
248
- findKey: Mt,
249
- global: Ut,
250
- isContextDefined: $t,
251
- ALPHABET: Vt,
252
- generateString: en,
253
- isSpecCompliantForm: tn,
254
- toJSONObject: sn,
255
- isAsyncFn: nn,
256
- isThenable: rn
257
- };
258
- function T(t, e, s, n, r) {
259
- Error.call(this), Error.captureStackTrace ? Error.captureStackTrace(this, this.constructor) : this.stack = new Error().stack, this.message = t, this.name = "AxiosError", e && (this.code = e), s && (this.config = s), n && (this.request = n), r && (this.response = r);
260
- }
261
- c.inherits(T, Error, {
262
- toJSON: function() {
263
- return {
264
- // Standard
265
- message: this.message,
266
- name: this.name,
267
- // Microsoft
268
- description: this.description,
269
- number: this.number,
270
- // Mozilla
271
- fileName: this.fileName,
272
- lineNumber: this.lineNumber,
273
- columnNumber: this.columnNumber,
274
- stack: this.stack,
275
- // Axios
276
- config: c.toJSONObject(this.config),
277
- code: this.code,
278
- status: this.response && this.response.status ? this.response.status : null
279
- };
280
- }
281
- });
282
- const Ft = T.prototype, Ht = {};
283
- [
284
- "ERR_BAD_OPTION_VALUE",
285
- "ERR_BAD_OPTION",
286
- "ECONNABORTED",
287
- "ETIMEDOUT",
288
- "ERR_NETWORK",
289
- "ERR_FR_TOO_MANY_REDIRECTS",
290
- "ERR_DEPRECATED",
291
- "ERR_BAD_RESPONSE",
292
- "ERR_BAD_REQUEST",
293
- "ERR_CANCELED",
294
- "ERR_NOT_SUPPORT",
295
- "ERR_INVALID_URL"
296
- // eslint-disable-next-line func-names
297
- ].forEach((t) => {
298
- Ht[t] = { value: t };
299
- });
300
- Object.defineProperties(T, Ht);
301
- Object.defineProperty(Ft, "isAxiosError", { value: !0 });
302
- T.from = (t, e, s, n, r, a) => {
303
- const i = Object.create(Ft);
304
- return c.toFlatObject(t, i, function(u) {
305
- return u !== Error.prototype;
306
- }, (o) => o !== "isAxiosError"), T.call(i, t.message, e, s, n, r), i.cause = t, i.name = t.name, a && Object.assign(i, a), i;
307
- };
308
- const an = null;
309
- function st(t) {
310
- return c.isPlainObject(t) || c.isArray(t);
311
- }
312
- function Jt(t) {
313
- return c.endsWith(t, "[]") ? t.slice(0, -2) : t;
314
- }
315
- function wt(t, e, s) {
316
- return t ? t.concat(e).map(function(r, a) {
317
- return r = Jt(r), !s && a ? "[" + r + "]" : r;
318
- }).join(s ? "." : "") : e;
319
- }
320
- function on(t) {
321
- return c.isArray(t) && !t.some(st);
322
- }
323
- const ln = c.toFlatObject(c, {}, null, function(e) {
324
- return /^is[A-Z]/.test(e);
325
- });
326
- function He(t, e, s) {
327
- if (!c.isObject(t))
328
- throw new TypeError("target must be an object");
329
- e = e || new FormData(), s = c.toFlatObject(s, {
330
- metaTokens: !0,
331
- dots: !1,
332
- indexes: !1
333
- }, !1, function(S, V) {
334
- return !c.isUndefined(V[S]);
335
- });
336
- const n = s.metaTokens, r = s.visitor || f, a = s.dots, i = s.indexes, u = (s.Blob || typeof Blob < "u" && Blob) && c.isSpecCompliantForm(e);
337
- if (!c.isFunction(r))
338
- throw new TypeError("visitor must be a function");
339
- function l(g) {
340
- if (g === null)
341
- return "";
342
- if (c.isDate(g))
343
- return g.toISOString();
344
- if (!u && c.isBlob(g))
345
- throw new T("Blob is not supported. Use a Buffer instead.");
346
- return c.isArrayBuffer(g) || c.isTypedArray(g) ? u && typeof Blob == "function" ? new Blob([g]) : Buffer.from(g) : g;
347
- }
348
- function f(g, S, V) {
349
- let Z = g;
350
- if (g && !V && typeof g == "object") {
351
- if (c.endsWith(S, "{}"))
352
- S = n ? S : S.slice(0, -2), g = JSON.stringify(g);
353
- else if (c.isArray(g) && on(g) || (c.isFileList(g) || c.endsWith(S, "[]")) && (Z = c.toArray(g)))
354
- return S = Jt(S), Z.forEach(function(Ee, _s) {
355
- !(c.isUndefined(Ee) || Ee === null) && e.append(
356
- // eslint-disable-next-line no-nested-ternary
357
- i === !0 ? wt([S], _s, a) : i === null ? S : S + "[]",
358
- l(Ee)
359
- );
360
- }), !1;
361
- }
362
- return st(g) ? !0 : (e.append(wt(V, S, a), l(g)), !1);
363
- }
364
- const b = [], C = Object.assign(ln, {
365
- defaultVisitor: f,
366
- convertValue: l,
367
- isVisitable: st
368
- });
369
- function O(g, S) {
370
- if (!c.isUndefined(g)) {
371
- if (b.indexOf(g) !== -1)
372
- throw Error("Circular reference detected in " + S.join("."));
373
- b.push(g), c.forEach(g, function(Z, se) {
374
- (!(c.isUndefined(Z) || Z === null) && r.call(
375
- e,
376
- Z,
377
- c.isString(se) ? se.trim() : se,
378
- S,
379
- C
380
- )) === !0 && O(Z, S ? S.concat(se) : [se]);
381
- }), b.pop();
382
- }
383
- }
384
- if (!c.isObject(t))
385
- throw new TypeError("data must be an object");
386
- return O(t), e;
387
- }
388
- function xt(t) {
389
- const e = {
390
- "!": "%21",
391
- "'": "%27",
392
- "(": "%28",
393
- ")": "%29",
394
- "~": "%7E",
395
- "%20": "+",
396
- "%00": "\0"
397
- };
398
- return encodeURIComponent(t).replace(/[!'()~]|%20|%00/g, function(n) {
399
- return e[n];
400
- });
401
- }
402
- function ut(t, e) {
403
- this._pairs = [], t && He(t, this, e);
404
- }
405
- const Wt = ut.prototype;
406
- Wt.append = function(e, s) {
407
- this._pairs.push([e, s]);
408
- };
409
- Wt.toString = function(e) {
410
- const s = e ? function(n) {
411
- return e.call(this, n, xt);
412
- } : xt;
413
- return this._pairs.map(function(r) {
414
- return s(r[0]) + "=" + s(r[1]);
415
- }, "").join("&");
416
- };
417
- function cn(t) {
418
- return encodeURIComponent(t).replace(/%3A/gi, ":").replace(/%24/g, "$").replace(/%2C/gi, ",").replace(/%20/g, "+").replace(/%5B/gi, "[").replace(/%5D/gi, "]");
419
- }
420
- function Kt(t, e, s) {
421
- if (!e)
422
- return t;
423
- const n = s && s.encode || cn, r = s && s.serialize;
424
- let a;
425
- if (r ? a = r(e, s) : a = c.isURLSearchParams(e) ? e.toString() : new ut(e, s).toString(n), a) {
426
- const i = t.indexOf("#");
427
- i !== -1 && (t = t.slice(0, i)), t += (t.indexOf("?") === -1 ? "?" : "&") + a;
428
- }
429
- return t;
430
- }
431
- class un {
432
- constructor() {
433
- this.handlers = [];
434
- }
435
- /**
436
- * Add a new interceptor to the stack
437
- *
438
- * @param {Function} fulfilled The function to handle `then` for a `Promise`
439
- * @param {Function} rejected The function to handle `reject` for a `Promise`
440
- *
441
- * @return {Number} An ID used to remove interceptor later
442
- */
443
- use(e, s, n) {
444
- return this.handlers.push({
445
- fulfilled: e,
446
- rejected: s,
447
- synchronous: n ? n.synchronous : !1,
448
- runWhen: n ? n.runWhen : null
449
- }), this.handlers.length - 1;
450
- }
451
- /**
452
- * Remove an interceptor from the stack
453
- *
454
- * @param {Number} id The ID that was returned by `use`
455
- *
456
- * @returns {Boolean} `true` if the interceptor was removed, `false` otherwise
457
- */
458
- eject(e) {
459
- this.handlers[e] && (this.handlers[e] = null);
460
- }
461
- /**
462
- * Clear all interceptors from the stack
463
- *
464
- * @returns {void}
465
- */
466
- clear() {
467
- this.handlers && (this.handlers = []);
468
- }
469
- /**
470
- * Iterate over all the registered interceptors
471
- *
472
- * This method is particularly useful for skipping over any
473
- * interceptors that may have become `null` calling `eject`.
474
- *
475
- * @param {Function} fn The function to call for each interceptor
476
- *
477
- * @returns {void}
478
- */
479
- forEach(e) {
480
- c.forEach(this.handlers, function(n) {
481
- n !== null && e(n);
482
- });
483
- }
484
- }
485
- const kt = un, qt = {
486
- silentJSONParsing: !0,
487
- forcedJSONParsing: !0,
488
- clarifyTimeoutError: !1
489
- }, dn = typeof URLSearchParams < "u" ? URLSearchParams : ut, fn = typeof FormData < "u" ? FormData : null, hn = typeof Blob < "u" ? Blob : null, pn = (() => {
490
- let t;
491
- return typeof navigator < "u" && ((t = navigator.product) === "ReactNative" || t === "NativeScript" || t === "NS") ? !1 : typeof window < "u" && typeof document < "u";
492
- })(), mn = (() => typeof WorkerGlobalScope < "u" && // eslint-disable-next-line no-undef
493
- self instanceof WorkerGlobalScope && typeof self.importScripts == "function")(), M = {
494
- isBrowser: !0,
495
- classes: {
496
- URLSearchParams: dn,
497
- FormData: fn,
498
- Blob: hn
499
- },
500
- isStandardBrowserEnv: pn,
501
- isStandardBrowserWebWorkerEnv: mn,
502
- protocols: ["http", "https", "file", "blob", "url", "data"]
503
- };
504
- function yn(t, e) {
505
- return He(t, new M.classes.URLSearchParams(), Object.assign({
506
- visitor: function(s, n, r, a) {
507
- return M.isNode && c.isBuffer(s) ? (this.append(n, s.toString("base64")), !1) : a.defaultVisitor.apply(this, arguments);
508
- }
509
- }, e));
510
- }
511
- function gn(t) {
512
- return c.matchAll(/\w+|\[(\w*)]/g, t).map((e) => e[0] === "[]" ? "" : e[1] || e[0]);
513
- }
514
- function vn(t) {
515
- const e = {}, s = Object.keys(t);
516
- let n;
517
- const r = s.length;
518
- let a;
519
- for (n = 0; n < r; n++)
520
- a = s[n], e[a] = t[a];
521
- return e;
522
- }
523
- function Gt(t) {
524
- function e(s, n, r, a) {
525
- let i = s[a++];
526
- const o = Number.isFinite(+i), u = a >= s.length;
527
- return i = !i && c.isArray(r) ? r.length : i, u ? (c.hasOwnProp(r, i) ? r[i] = [r[i], n] : r[i] = n, !o) : ((!r[i] || !c.isObject(r[i])) && (r[i] = []), e(s, n, r[i], a) && c.isArray(r[i]) && (r[i] = vn(r[i])), !o);
528
- }
529
- if (c.isFormData(t) && c.isFunction(t.entries)) {
530
- const s = {};
531
- return c.forEachEntry(t, (n, r) => {
532
- e(gn(n), r, s, 0);
533
- }), s;
534
- }
535
- return null;
536
- }
537
- const _n = {
538
- "Content-Type": void 0
539
- };
540
- function bn(t, e, s) {
541
- if (c.isString(t))
542
- try {
543
- return (e || JSON.parse)(t), c.trim(t);
544
- } catch (n) {
545
- if (n.name !== "SyntaxError")
546
- throw n;
547
- }
548
- return (s || JSON.stringify)(t);
549
- }
550
- const Je = {
551
- transitional: qt,
552
- adapter: ["xhr", "http"],
553
- transformRequest: [function(e, s) {
554
- const n = s.getContentType() || "", r = n.indexOf("application/json") > -1, a = c.isObject(e);
555
- if (a && c.isHTMLForm(e) && (e = new FormData(e)), c.isFormData(e))
556
- return r && r ? JSON.stringify(Gt(e)) : e;
557
- if (c.isArrayBuffer(e) || c.isBuffer(e) || c.isStream(e) || c.isFile(e) || c.isBlob(e))
558
- return e;
559
- if (c.isArrayBufferView(e))
560
- return e.buffer;
561
- if (c.isURLSearchParams(e))
562
- return s.setContentType("application/x-www-form-urlencoded;charset=utf-8", !1), e.toString();
563
- let o;
564
- if (a) {
565
- if (n.indexOf("application/x-www-form-urlencoded") > -1)
566
- return yn(e, this.formSerializer).toString();
567
- if ((o = c.isFileList(e)) || n.indexOf("multipart/form-data") > -1) {
568
- const u = this.env && this.env.FormData;
569
- return He(
570
- o ? { "files[]": e } : e,
571
- u && new u(),
572
- this.formSerializer
573
- );
574
- }
575
- }
576
- return a || r ? (s.setContentType("application/json", !1), bn(e)) : e;
577
- }],
578
- transformResponse: [function(e) {
579
- const s = this.transitional || Je.transitional, n = s && s.forcedJSONParsing, r = this.responseType === "json";
580
- if (e && c.isString(e) && (n && !this.responseType || r)) {
581
- const i = !(s && s.silentJSONParsing) && r;
582
- try {
583
- return JSON.parse(e);
584
- } catch (o) {
585
- if (i)
586
- throw o.name === "SyntaxError" ? T.from(o, T.ERR_BAD_RESPONSE, this, null, this.response) : o;
587
- }
588
- }
589
- return e;
590
- }],
591
- /**
592
- * A timeout in milliseconds to abort a request. If set to 0 (default) a
593
- * timeout is not created.
594
- */
595
- timeout: 0,
596
- xsrfCookieName: "XSRF-TOKEN",
597
- xsrfHeaderName: "X-XSRF-TOKEN",
598
- maxContentLength: -1,
599
- maxBodyLength: -1,
600
- env: {
601
- FormData: M.classes.FormData,
602
- Blob: M.classes.Blob
603
- },
604
- validateStatus: function(e) {
605
- return e >= 200 && e < 300;
606
- },
607
- headers: {
608
- common: {
609
- Accept: "application/json, text/plain, */*"
610
- }
611
- }
612
- };
613
- c.forEach(["delete", "get", "head"], function(e) {
614
- Je.headers[e] = {};
615
- });
616
- c.forEach(["post", "put", "patch"], function(e) {
617
- Je.headers[e] = c.merge(_n);
618
- });
619
- const dt = Je, wn = c.toObjectSet([
620
- "age",
621
- "authorization",
622
- "content-length",
623
- "content-type",
624
- "etag",
625
- "expires",
626
- "from",
627
- "host",
628
- "if-modified-since",
629
- "if-unmodified-since",
630
- "last-modified",
631
- "location",
632
- "max-forwards",
633
- "proxy-authorization",
634
- "referer",
635
- "retry-after",
636
- "user-agent"
637
- ]), xn = (t) => {
638
- const e = {};
639
- let s, n, r;
640
- return t && t.split(`
641
- `).forEach(function(i) {
642
- r = i.indexOf(":"), s = i.substring(0, r).trim().toLowerCase(), n = i.substring(r + 1).trim(), !(!s || e[s] && wn[s]) && (s === "set-cookie" ? e[s] ? e[s].push(n) : e[s] = [n] : e[s] = e[s] ? e[s] + ", " + n : n);
643
- }), e;
644
- }, St = Symbol("internals");
645
- function ue(t) {
646
- return t && String(t).trim().toLowerCase();
647
- }
648
- function Ne(t) {
649
- return t === !1 || t == null ? t : c.isArray(t) ? t.map(Ne) : String(t);
650
- }
651
- function kn(t) {
652
- const e = /* @__PURE__ */ Object.create(null), s = /([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g;
653
- let n;
654
- for (; n = s.exec(t); )
655
- e[n[1]] = n[2];
656
- return e;
657
- }
658
- const Sn = (t) => /^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(t.trim());
659
- function Xe(t, e, s, n, r) {
660
- if (c.isFunction(n))
661
- return n.call(this, e, s);
662
- if (r && (e = s), !!c.isString(e)) {
663
- if (c.isString(n))
664
- return e.indexOf(n) !== -1;
665
- if (c.isRegExp(n))
666
- return n.test(e);
667
- }
668
- }
669
- function Tn(t) {
670
- return t.trim().toLowerCase().replace(/([a-z\d])(\w*)/g, (e, s, n) => s.toUpperCase() + n);
671
- }
672
- function En(t, e) {
673
- const s = c.toCamelCase(" " + e);
674
- ["get", "set", "has"].forEach((n) => {
675
- Object.defineProperty(t, n + s, {
676
- value: function(r, a, i) {
677
- return this[n].call(this, e, r, a, i);
678
- },
679
- configurable: !0
680
- });
681
- });
682
- }
683
- class We {
684
- constructor(e) {
685
- e && this.set(e);
686
- }
687
- set(e, s, n) {
688
- const r = this;
689
- function a(o, u, l) {
690
- const f = ue(u);
691
- if (!f)
692
- throw new Error("header name must be a non-empty string");
693
- const b = c.findKey(r, f);
694
- (!b || r[b] === void 0 || l === !0 || l === void 0 && r[b] !== !1) && (r[b || u] = Ne(o));
695
- }
696
- const i = (o, u) => c.forEach(o, (l, f) => a(l, f, u));
697
- return c.isPlainObject(e) || e instanceof this.constructor ? i(e, s) : c.isString(e) && (e = e.trim()) && !Sn(e) ? i(xn(e), s) : e != null && a(s, e, n), this;
698
- }
699
- get(e, s) {
700
- if (e = ue(e), e) {
701
- const n = c.findKey(this, e);
702
- if (n) {
703
- const r = this[n];
704
- if (!s)
705
- return r;
706
- if (s === !0)
707
- return kn(r);
708
- if (c.isFunction(s))
709
- return s.call(this, r, n);
710
- if (c.isRegExp(s))
711
- return s.exec(r);
712
- throw new TypeError("parser must be boolean|regexp|function");
713
- }
714
- }
715
- }
716
- has(e, s) {
717
- if (e = ue(e), e) {
718
- const n = c.findKey(this, e);
719
- return !!(n && this[n] !== void 0 && (!s || Xe(this, this[n], n, s)));
720
- }
721
- return !1;
722
- }
723
- delete(e, s) {
724
- const n = this;
725
- let r = !1;
726
- function a(i) {
727
- if (i = ue(i), i) {
728
- const o = c.findKey(n, i);
729
- o && (!s || Xe(n, n[o], o, s)) && (delete n[o], r = !0);
730
- }
731
- }
732
- return c.isArray(e) ? e.forEach(a) : a(e), r;
733
- }
734
- clear(e) {
735
- const s = Object.keys(this);
736
- let n = s.length, r = !1;
737
- for (; n--; ) {
738
- const a = s[n];
739
- (!e || Xe(this, this[a], a, e, !0)) && (delete this[a], r = !0);
740
- }
741
- return r;
742
- }
743
- normalize(e) {
744
- const s = this, n = {};
745
- return c.forEach(this, (r, a) => {
746
- const i = c.findKey(n, a);
747
- if (i) {
748
- s[i] = Ne(r), delete s[a];
749
- return;
750
- }
751
- const o = e ? Tn(a) : String(a).trim();
752
- o !== a && delete s[a], s[o] = Ne(r), n[o] = !0;
753
- }), this;
754
- }
755
- concat(...e) {
756
- return this.constructor.concat(this, ...e);
757
- }
758
- toJSON(e) {
759
- const s = /* @__PURE__ */ Object.create(null);
760
- return c.forEach(this, (n, r) => {
761
- n != null && n !== !1 && (s[r] = e && c.isArray(n) ? n.join(", ") : n);
762
- }), s;
763
- }
764
- [Symbol.iterator]() {
765
- return Object.entries(this.toJSON())[Symbol.iterator]();
766
- }
767
- toString() {
768
- return Object.entries(this.toJSON()).map(([e, s]) => e + ": " + s).join(`
769
- `);
770
- }
771
- get [Symbol.toStringTag]() {
772
- return "AxiosHeaders";
773
- }
774
- static from(e) {
775
- return e instanceof this ? e : new this(e);
776
- }
777
- static concat(e, ...s) {
778
- const n = new this(e);
779
- return s.forEach((r) => n.set(r)), n;
780
- }
781
- static accessor(e) {
782
- const n = (this[St] = this[St] = {
783
- accessors: {}
784
- }).accessors, r = this.prototype;
785
- function a(i) {
786
- const o = ue(i);
787
- n[o] || (En(r, i), n[o] = !0);
788
- }
789
- return c.isArray(e) ? e.forEach(a) : a(e), this;
790
- }
791
- }
792
- We.accessor(["Content-Type", "Content-Length", "Accept", "Accept-Encoding", "User-Agent", "Authorization"]);
793
- c.freezeMethods(We.prototype);
794
- c.freezeMethods(We);
795
- const F = We;
796
- function Ye(t, e) {
797
- const s = this || dt, n = e || s, r = F.from(n.headers);
798
- let a = n.data;
799
- return c.forEach(t, function(o) {
800
- a = o.call(s, a, r.normalize(), e ? e.status : void 0);
801
- }), r.normalize(), a;
802
- }
803
- function Xt(t) {
804
- return !!(t && t.__CANCEL__);
805
- }
806
- function Se(t, e, s) {
807
- T.call(this, t ?? "canceled", T.ERR_CANCELED, e, s), this.name = "CanceledError";
808
- }
809
- c.inherits(Se, T, {
810
- __CANCEL__: !0
811
- });
812
- function On(t, e, s) {
813
- const n = s.config.validateStatus;
814
- !s.status || !n || n(s.status) ? t(s) : e(new T(
815
- "Request failed with status code " + s.status,
816
- [T.ERR_BAD_REQUEST, T.ERR_BAD_RESPONSE][Math.floor(s.status / 100) - 4],
817
- s.config,
818
- s.request,
819
- s
820
- ));
821
- }
822
- const Nn = M.isStandardBrowserEnv ? (
823
- // Standard browser envs support document.cookie
824
- function() {
825
- return {
826
- write: function(s, n, r, a, i, o) {
827
- const u = [];
828
- u.push(s + "=" + encodeURIComponent(n)), c.isNumber(r) && u.push("expires=" + new Date(r).toGMTString()), c.isString(a) && u.push("path=" + a), c.isString(i) && u.push("domain=" + i), o === !0 && u.push("secure"), document.cookie = u.join("; ");
829
- },
830
- read: function(s) {
831
- const n = document.cookie.match(new RegExp("(^|;\\s*)(" + s + ")=([^;]*)"));
832
- return n ? decodeURIComponent(n[3]) : null;
833
- },
834
- remove: function(s) {
835
- this.write(s, "", Date.now() - 864e5);
836
- }
837
- };
838
- }()
839
- ) : (
840
- // Non standard browser env (web workers, react-native) lack needed support.
841
- function() {
842
- return {
843
- write: function() {
844
- },
845
- read: function() {
846
- return null;
847
- },
848
- remove: function() {
849
- }
850
- };
851
- }()
852
- );
853
- function Cn(t) {
854
- return /^([a-z][a-z\d+\-.]*:)?\/\//i.test(t);
855
- }
856
- function An(t, e) {
857
- return e ? t.replace(/\/+$/, "") + "/" + e.replace(/^\/+/, "") : t;
858
- }
859
- function Yt(t, e) {
860
- return t && !Cn(e) ? An(t, e) : e;
861
- }
862
- const Rn = M.isStandardBrowserEnv ? (
863
- // Standard browser envs have full support of the APIs needed to test
864
- // whether the request URL is of the same origin as current location.
865
- function() {
866
- const e = /(msie|trident)/i.test(navigator.userAgent), s = document.createElement("a");
867
- let n;
868
- function r(a) {
869
- let i = a;
870
- return e && (s.setAttribute("href", i), i = s.href), s.setAttribute("href", i), {
871
- href: s.href,
872
- protocol: s.protocol ? s.protocol.replace(/:$/, "") : "",
873
- host: s.host,
874
- search: s.search ? s.search.replace(/^\?/, "") : "",
875
- hash: s.hash ? s.hash.replace(/^#/, "") : "",
876
- hostname: s.hostname,
877
- port: s.port,
878
- pathname: s.pathname.charAt(0) === "/" ? s.pathname : "/" + s.pathname
879
- };
880
- }
881
- return n = r(window.location.href), function(i) {
882
- const o = c.isString(i) ? r(i) : i;
883
- return o.protocol === n.protocol && o.host === n.host;
884
- };
885
- }()
886
- ) : (
887
- // Non standard browser envs (web workers, react-native) lack needed support.
888
- function() {
889
- return function() {
890
- return !0;
891
- };
892
- }()
893
- );
894
- function In(t) {
895
- const e = /^([-+\w]{1,25})(:?\/\/|:)/.exec(t);
896
- return e && e[1] || "";
897
- }
898
- function jn(t, e) {
899
- t = t || 10;
900
- const s = new Array(t), n = new Array(t);
901
- let r = 0, a = 0, i;
902
- return e = e !== void 0 ? e : 1e3, function(u) {
903
- const l = Date.now(), f = n[a];
904
- i || (i = l), s[r] = u, n[r] = l;
905
- let b = a, C = 0;
906
- for (; b !== r; )
907
- C += s[b++], b = b % t;
908
- if (r = (r + 1) % t, r === a && (a = (a + 1) % t), l - i < e)
909
- return;
910
- const O = f && l - f;
911
- return O ? Math.round(C * 1e3 / O) : void 0;
912
- };
913
- }
914
- function Tt(t, e) {
915
- let s = 0;
916
- const n = jn(50, 250);
917
- return (r) => {
918
- const a = r.loaded, i = r.lengthComputable ? r.total : void 0, o = a - s, u = n(o), l = a <= i;
919
- s = a;
920
- const f = {
921
- loaded: a,
922
- total: i,
923
- progress: i ? a / i : void 0,
924
- bytes: o,
925
- rate: u || void 0,
926
- estimated: u && i && l ? (i - a) / u : void 0,
927
- event: r
928
- };
929
- f[e ? "download" : "upload"] = !0, t(f);
930
- };
931
- }
932
- const Zn = typeof XMLHttpRequest < "u", Ln = Zn && function(t) {
933
- return new Promise(function(s, n) {
934
- let r = t.data;
935
- const a = F.from(t.headers).normalize(), i = t.responseType;
936
- let o;
937
- function u() {
938
- t.cancelToken && t.cancelToken.unsubscribe(o), t.signal && t.signal.removeEventListener("abort", o);
939
- }
940
- c.isFormData(r) && (M.isStandardBrowserEnv || M.isStandardBrowserWebWorkerEnv ? a.setContentType(!1) : a.setContentType("multipart/form-data;", !1));
941
- let l = new XMLHttpRequest();
942
- if (t.auth) {
943
- const O = t.auth.username || "", g = t.auth.password ? unescape(encodeURIComponent(t.auth.password)) : "";
944
- a.set("Authorization", "Basic " + btoa(O + ":" + g));
945
- }
946
- const f = Yt(t.baseURL, t.url);
947
- l.open(t.method.toUpperCase(), Kt(f, t.params, t.paramsSerializer), !0), l.timeout = t.timeout;
948
- function b() {
949
- if (!l)
950
- return;
951
- const O = F.from(
952
- "getAllResponseHeaders" in l && l.getAllResponseHeaders()
953
- ), S = {
954
- data: !i || i === "text" || i === "json" ? l.responseText : l.response,
955
- status: l.status,
956
- statusText: l.statusText,
957
- headers: O,
958
- config: t,
959
- request: l
960
- };
961
- On(function(Z) {
962
- s(Z), u();
963
- }, function(Z) {
964
- n(Z), u();
965
- }, S), l = null;
966
- }
967
- if ("onloadend" in l ? l.onloadend = b : l.onreadystatechange = function() {
968
- !l || l.readyState !== 4 || l.status === 0 && !(l.responseURL && l.responseURL.indexOf("file:") === 0) || setTimeout(b);
969
- }, l.onabort = function() {
970
- l && (n(new T("Request aborted", T.ECONNABORTED, t, l)), l = null);
971
- }, l.onerror = function() {
972
- n(new T("Network Error", T.ERR_NETWORK, t, l)), l = null;
973
- }, l.ontimeout = function() {
974
- let g = t.timeout ? "timeout of " + t.timeout + "ms exceeded" : "timeout exceeded";
975
- const S = t.transitional || qt;
976
- t.timeoutErrorMessage && (g = t.timeoutErrorMessage), n(new T(
977
- g,
978
- S.clarifyTimeoutError ? T.ETIMEDOUT : T.ECONNABORTED,
979
- t,
980
- l
981
- )), l = null;
982
- }, M.isStandardBrowserEnv) {
983
- const O = (t.withCredentials || Rn(f)) && t.xsrfCookieName && Nn.read(t.xsrfCookieName);
984
- O && a.set(t.xsrfHeaderName, O);
985
- }
986
- r === void 0 && a.setContentType(null), "setRequestHeader" in l && c.forEach(a.toJSON(), function(g, S) {
987
- l.setRequestHeader(S, g);
988
- }), c.isUndefined(t.withCredentials) || (l.withCredentials = !!t.withCredentials), i && i !== "json" && (l.responseType = t.responseType), typeof t.onDownloadProgress == "function" && l.addEventListener("progress", Tt(t.onDownloadProgress, !0)), typeof t.onUploadProgress == "function" && l.upload && l.upload.addEventListener("progress", Tt(t.onUploadProgress)), (t.cancelToken || t.signal) && (o = (O) => {
989
- l && (n(!O || O.type ? new Se(null, t, l) : O), l.abort(), l = null);
990
- }, t.cancelToken && t.cancelToken.subscribe(o), t.signal && (t.signal.aborted ? o() : t.signal.addEventListener("abort", o)));
991
- const C = In(f);
992
- if (C && M.protocols.indexOf(C) === -1) {
993
- n(new T("Unsupported protocol " + C + ":", T.ERR_BAD_REQUEST, t));
994
- return;
995
- }
996
- l.send(r || null);
997
- });
998
- }, Ce = {
999
- http: an,
1000
- xhr: Ln
1001
- };
1002
- c.forEach(Ce, (t, e) => {
1003
- if (t) {
1004
- try {
1005
- Object.defineProperty(t, "name", { value: e });
1006
- } catch {
1007
- }
1008
- Object.defineProperty(t, "adapterName", { value: e });
1009
- }
1010
- });
1011
- const Dn = {
1012
- getAdapter: (t) => {
1013
- t = c.isArray(t) ? t : [t];
1014
- const { length: e } = t;
1015
- let s, n;
1016
- for (let r = 0; r < e && (s = t[r], !(n = c.isString(s) ? Ce[s.toLowerCase()] : s)); r++)
1017
- ;
1018
- if (!n)
1019
- throw n === !1 ? new T(
1020
- `Adapter ${s} is not supported by the environment`,
1021
- "ERR_NOT_SUPPORT"
1022
- ) : new Error(
1023
- c.hasOwnProp(Ce, s) ? `Adapter '${s}' is not available in the build` : `Unknown adapter '${s}'`
1024
- );
1025
- if (!c.isFunction(n))
1026
- throw new TypeError("adapter is not a function");
1027
- return n;
1028
- },
1029
- adapters: Ce
1030
- };
1031
- function Qe(t) {
1032
- if (t.cancelToken && t.cancelToken.throwIfRequested(), t.signal && t.signal.aborted)
1033
- throw new Se(null, t);
1034
- }
1035
- function Et(t) {
1036
- return Qe(t), t.headers = F.from(t.headers), t.data = Ye.call(
1037
- t,
1038
- t.transformRequest
1039
- ), ["post", "put", "patch"].indexOf(t.method) !== -1 && t.headers.setContentType("application/x-www-form-urlencoded", !1), Dn.getAdapter(t.adapter || dt.adapter)(t).then(function(n) {
1040
- return Qe(t), n.data = Ye.call(
1041
- t,
1042
- t.transformResponse,
1043
- n
1044
- ), n.headers = F.from(n.headers), n;
1045
- }, function(n) {
1046
- return Xt(n) || (Qe(t), n && n.response && (n.response.data = Ye.call(
1047
- t,
1048
- t.transformResponse,
1049
- n.response
1050
- ), n.response.headers = F.from(n.response.headers))), Promise.reject(n);
1051
- });
1052
- }
1053
- const Ot = (t) => t instanceof F ? t.toJSON() : t;
1054
- function ae(t, e) {
1055
- e = e || {};
1056
- const s = {};
1057
- function n(l, f, b) {
1058
- return c.isPlainObject(l) && c.isPlainObject(f) ? c.merge.call({ caseless: b }, l, f) : c.isPlainObject(f) ? c.merge({}, f) : c.isArray(f) ? f.slice() : f;
1059
- }
1060
- function r(l, f, b) {
1061
- if (c.isUndefined(f)) {
1062
- if (!c.isUndefined(l))
1063
- return n(void 0, l, b);
1064
- } else
1065
- return n(l, f, b);
1066
- }
1067
- function a(l, f) {
1068
- if (!c.isUndefined(f))
1069
- return n(void 0, f);
1070
- }
1071
- function i(l, f) {
1072
- if (c.isUndefined(f)) {
1073
- if (!c.isUndefined(l))
1074
- return n(void 0, l);
1075
- } else
1076
- return n(void 0, f);
1077
- }
1078
- function o(l, f, b) {
1079
- if (b in e)
1080
- return n(l, f);
1081
- if (b in t)
1082
- return n(void 0, l);
1083
- }
1084
- const u = {
1085
- url: a,
1086
- method: a,
1087
- data: a,
1088
- baseURL: i,
1089
- transformRequest: i,
1090
- transformResponse: i,
1091
- paramsSerializer: i,
1092
- timeout: i,
1093
- timeoutMessage: i,
1094
- withCredentials: i,
1095
- adapter: i,
1096
- responseType: i,
1097
- xsrfCookieName: i,
1098
- xsrfHeaderName: i,
1099
- onUploadProgress: i,
1100
- onDownloadProgress: i,
1101
- decompress: i,
1102
- maxContentLength: i,
1103
- maxBodyLength: i,
1104
- beforeRedirect: i,
1105
- transport: i,
1106
- httpAgent: i,
1107
- httpsAgent: i,
1108
- cancelToken: i,
1109
- socketPath: i,
1110
- responseEncoding: i,
1111
- validateStatus: o,
1112
- headers: (l, f) => r(Ot(l), Ot(f), !0)
1113
- };
1114
- return c.forEach(Object.keys(Object.assign({}, t, e)), function(f) {
1115
- const b = u[f] || r, C = b(t[f], e[f], f);
1116
- c.isUndefined(C) && b !== o || (s[f] = C);
1117
- }), s;
1118
- }
1119
- const Qt = "1.4.0", ft = {};
1120
- ["object", "boolean", "number", "function", "string", "symbol"].forEach((t, e) => {
1121
- ft[t] = function(n) {
1122
- return typeof n === t || "a" + (e < 1 ? "n " : " ") + t;
1123
- };
1124
- });
1125
- const Nt = {};
1126
- ft.transitional = function(e, s, n) {
1127
- function r(a, i) {
1128
- return "[Axios v" + Qt + "] Transitional option '" + a + "'" + i + (n ? ". " + n : "");
1129
- }
1130
- return (a, i, o) => {
1131
- if (e === !1)
1132
- throw new T(
1133
- r(i, " has been removed" + (s ? " in " + s : "")),
1134
- T.ERR_DEPRECATED
1135
- );
1136
- return s && !Nt[i] && (Nt[i] = !0, console.warn(
1137
- r(
1138
- i,
1139
- " has been deprecated since v" + s + " and will be removed in the near future"
1140
- )
1141
- )), e ? e(a, i, o) : !0;
1142
- };
1143
- };
1144
- function Pn(t, e, s) {
1145
- if (typeof t != "object")
1146
- throw new T("options must be an object", T.ERR_BAD_OPTION_VALUE);
1147
- const n = Object.keys(t);
1148
- let r = n.length;
1149
- for (; r-- > 0; ) {
1150
- const a = n[r], i = e[a];
1151
- if (i) {
1152
- const o = t[a], u = o === void 0 || i(o, a, t);
1153
- if (u !== !0)
1154
- throw new T("option " + a + " must be " + u, T.ERR_BAD_OPTION_VALUE);
1155
- continue;
1156
- }
1157
- if (s !== !0)
1158
- throw new T("Unknown option " + a, T.ERR_BAD_OPTION);
1159
- }
1160
- }
1161
- const nt = {
1162
- assertOptions: Pn,
1163
- validators: ft
1164
- }, W = nt.validators;
1165
- class Ie {
1166
- constructor(e) {
1167
- this.defaults = e, this.interceptors = {
1168
- request: new kt(),
1169
- response: new kt()
1170
- };
1171
- }
1172
- /**
1173
- * Dispatch a request
1174
- *
1175
- * @param {String|Object} configOrUrl The config specific for this request (merged with this.defaults)
1176
- * @param {?Object} config
1177
- *
1178
- * @returns {Promise} The Promise to be fulfilled
1179
- */
1180
- request(e, s) {
1181
- typeof e == "string" ? (s = s || {}, s.url = e) : s = e || {}, s = ae(this.defaults, s);
1182
- const { transitional: n, paramsSerializer: r, headers: a } = s;
1183
- n !== void 0 && nt.assertOptions(n, {
1184
- silentJSONParsing: W.transitional(W.boolean),
1185
- forcedJSONParsing: W.transitional(W.boolean),
1186
- clarifyTimeoutError: W.transitional(W.boolean)
1187
- }, !1), r != null && (c.isFunction(r) ? s.paramsSerializer = {
1188
- serialize: r
1189
- } : nt.assertOptions(r, {
1190
- encode: W.function,
1191
- serialize: W.function
1192
- }, !0)), s.method = (s.method || this.defaults.method || "get").toLowerCase();
1193
- let i;
1194
- i = a && c.merge(
1195
- a.common,
1196
- a[s.method]
1197
- ), i && c.forEach(
1198
- ["delete", "get", "head", "post", "put", "patch", "common"],
1199
- (g) => {
1200
- delete a[g];
1201
- }
1202
- ), s.headers = F.concat(i, a);
1203
- const o = [];
1204
- let u = !0;
1205
- this.interceptors.request.forEach(function(S) {
1206
- typeof S.runWhen == "function" && S.runWhen(s) === !1 || (u = u && S.synchronous, o.unshift(S.fulfilled, S.rejected));
1207
- });
1208
- const l = [];
1209
- this.interceptors.response.forEach(function(S) {
1210
- l.push(S.fulfilled, S.rejected);
1211
- });
1212
- let f, b = 0, C;
1213
- if (!u) {
1214
- const g = [Et.bind(this), void 0];
1215
- for (g.unshift.apply(g, o), g.push.apply(g, l), C = g.length, f = Promise.resolve(s); b < C; )
1216
- f = f.then(g[b++], g[b++]);
1217
- return f;
1218
- }
1219
- C = o.length;
1220
- let O = s;
1221
- for (b = 0; b < C; ) {
1222
- const g = o[b++], S = o[b++];
1223
- try {
1224
- O = g(O);
1225
- } catch (V) {
1226
- S.call(this, V);
1227
- break;
1228
- }
1229
- }
1230
- try {
1231
- f = Et.call(this, O);
1232
- } catch (g) {
1233
- return Promise.reject(g);
1234
- }
1235
- for (b = 0, C = l.length; b < C; )
1236
- f = f.then(l[b++], l[b++]);
1237
- return f;
1238
- }
1239
- getUri(e) {
1240
- e = ae(this.defaults, e);
1241
- const s = Yt(e.baseURL, e.url);
1242
- return Kt(s, e.params, e.paramsSerializer);
1243
- }
1244
- }
1245
- c.forEach(["delete", "get", "head", "options"], function(e) {
1246
- Ie.prototype[e] = function(s, n) {
1247
- return this.request(ae(n || {}, {
1248
- method: e,
1249
- url: s,
1250
- data: (n || {}).data
1251
- }));
1252
- };
1253
- });
1254
- c.forEach(["post", "put", "patch"], function(e) {
1255
- function s(n) {
1256
- return function(a, i, o) {
1257
- return this.request(ae(o || {}, {
1258
- method: e,
1259
- headers: n ? {
1260
- "Content-Type": "multipart/form-data"
1261
- } : {},
1262
- url: a,
1263
- data: i
1264
- }));
1265
- };
1266
- }
1267
- Ie.prototype[e] = s(), Ie.prototype[e + "Form"] = s(!0);
1268
- });
1269
- const Ae = Ie;
1270
- class ht {
1271
- constructor(e) {
1272
- if (typeof e != "function")
1273
- throw new TypeError("executor must be a function.");
1274
- let s;
1275
- this.promise = new Promise(function(a) {
1276
- s = a;
1277
- });
1278
- const n = this;
1279
- this.promise.then((r) => {
1280
- if (!n._listeners)
1281
- return;
1282
- let a = n._listeners.length;
1283
- for (; a-- > 0; )
1284
- n._listeners[a](r);
1285
- n._listeners = null;
1286
- }), this.promise.then = (r) => {
1287
- let a;
1288
- const i = new Promise((o) => {
1289
- n.subscribe(o), a = o;
1290
- }).then(r);
1291
- return i.cancel = function() {
1292
- n.unsubscribe(a);
1293
- }, i;
1294
- }, e(function(a, i, o) {
1295
- n.reason || (n.reason = new Se(a, i, o), s(n.reason));
1296
- });
1297
- }
1298
- /**
1299
- * Throws a `CanceledError` if cancellation has been requested.
1300
- */
1301
- throwIfRequested() {
1302
- if (this.reason)
1303
- throw this.reason;
1304
- }
1305
- /**
1306
- * Subscribe to the cancel signal
1307
- */
1308
- subscribe(e) {
1309
- if (this.reason) {
1310
- e(this.reason);
1311
- return;
1312
- }
1313
- this._listeners ? this._listeners.push(e) : this._listeners = [e];
1314
- }
1315
- /**
1316
- * Unsubscribe from the cancel signal
1317
- */
1318
- unsubscribe(e) {
1319
- if (!this._listeners)
1320
- return;
1321
- const s = this._listeners.indexOf(e);
1322
- s !== -1 && this._listeners.splice(s, 1);
1323
- }
1324
- /**
1325
- * Returns an object that contains a new `CancelToken` and a function that, when called,
1326
- * cancels the `CancelToken`.
1327
- */
1328
- static source() {
1329
- let e;
1330
- return {
1331
- token: new ht(function(r) {
1332
- e = r;
1333
- }),
1334
- cancel: e
1335
- };
1336
- }
1337
- }
1338
- const Bn = ht;
1339
- function Mn(t) {
1340
- return function(s) {
1341
- return t.apply(null, s);
1342
- };
1343
- }
1344
- function Un(t) {
1345
- return c.isObject(t) && t.isAxiosError === !0;
1346
- }
1347
- const rt = {
1348
- Continue: 100,
1349
- SwitchingProtocols: 101,
1350
- Processing: 102,
1351
- EarlyHints: 103,
1352
- Ok: 200,
1353
- Created: 201,
1354
- Accepted: 202,
1355
- NonAuthoritativeInformation: 203,
1356
- NoContent: 204,
1357
- ResetContent: 205,
1358
- PartialContent: 206,
1359
- MultiStatus: 207,
1360
- AlreadyReported: 208,
1361
- ImUsed: 226,
1362
- MultipleChoices: 300,
1363
- MovedPermanently: 301,
1364
- Found: 302,
1365
- SeeOther: 303,
1366
- NotModified: 304,
1367
- UseProxy: 305,
1368
- Unused: 306,
1369
- TemporaryRedirect: 307,
1370
- PermanentRedirect: 308,
1371
- BadRequest: 400,
1372
- Unauthorized: 401,
1373
- PaymentRequired: 402,
1374
- Forbidden: 403,
1375
- NotFound: 404,
1376
- MethodNotAllowed: 405,
1377
- NotAcceptable: 406,
1378
- ProxyAuthenticationRequired: 407,
1379
- RequestTimeout: 408,
1380
- Conflict: 409,
1381
- Gone: 410,
1382
- LengthRequired: 411,
1383
- PreconditionFailed: 412,
1384
- PayloadTooLarge: 413,
1385
- UriTooLong: 414,
1386
- UnsupportedMediaType: 415,
1387
- RangeNotSatisfiable: 416,
1388
- ExpectationFailed: 417,
1389
- ImATeapot: 418,
1390
- MisdirectedRequest: 421,
1391
- UnprocessableEntity: 422,
1392
- Locked: 423,
1393
- FailedDependency: 424,
1394
- TooEarly: 425,
1395
- UpgradeRequired: 426,
1396
- PreconditionRequired: 428,
1397
- TooManyRequests: 429,
1398
- RequestHeaderFieldsTooLarge: 431,
1399
- UnavailableForLegalReasons: 451,
1400
- InternalServerError: 500,
1401
- NotImplemented: 501,
1402
- BadGateway: 502,
1403
- ServiceUnavailable: 503,
1404
- GatewayTimeout: 504,
1405
- HttpVersionNotSupported: 505,
1406
- VariantAlsoNegotiates: 506,
1407
- InsufficientStorage: 507,
1408
- LoopDetected: 508,
1409
- NotExtended: 510,
1410
- NetworkAuthenticationRequired: 511
1411
- };
1412
- Object.entries(rt).forEach(([t, e]) => {
1413
- rt[e] = t;
1414
- });
1415
- const $n = rt;
1416
- function es(t) {
1417
- const e = new Ae(t), s = Dt(Ae.prototype.request, e);
1418
- return c.extend(s, Ae.prototype, e, { allOwnKeys: !0 }), c.extend(s, e, null, { allOwnKeys: !0 }), s.create = function(r) {
1419
- return es(ae(t, r));
1420
- }, s;
1421
- }
1422
- const A = es(dt);
1423
- A.Axios = Ae;
1424
- A.CanceledError = Se;
1425
- A.CancelToken = Bn;
1426
- A.isCancel = Xt;
1427
- A.VERSION = Qt;
1428
- A.toFormData = He;
1429
- A.AxiosError = T;
1430
- A.Cancel = A.CanceledError;
1431
- A.all = function(e) {
1432
- return Promise.all(e);
1433
- };
1434
- A.spread = Mn;
1435
- A.isAxiosError = Un;
1436
- A.mergeConfig = ae;
1437
- A.AxiosHeaders = F;
1438
- A.formToJSON = (t) => Gt(c.isHTMLForm(t) ? new FormData(t) : t);
1439
- A.HttpStatusCode = $n;
1440
- A.default = A;
1441
- const pt = A;
1442
- function mt({ apiKey: t, options: e }) {
1443
- let s = {};
1444
- return t && xs(s, ["headers", "Authorization"], `API-Key ${t}`), e && (s = jt(s, e)), s;
1445
- }
1446
- function yt(t) {
1447
- return t.replaceAll(" ", "").trim();
1448
- }
1449
- async function ts({ url: t, apiKey: e, options: s }) {
1450
- return await pt.get(yt(t), mt({ apiKey: e, options: s }));
1451
- }
1452
- async function gt({ url: t, apiKey: e, options: s, payload: n = {} }) {
1453
- return await pt.post(yt(t), n, mt({ apiKey: e, options: s }));
1454
- }
1455
- async function zn({ url: t, apiKey: e, options: s, payload: n }) {
1456
- return await pt.put(yt(t), n, mt({ apiKey: e, options: s }));
1457
- }
1458
- async function ce(t) {
1459
- try {
1460
- return await t();
1461
- } catch (e) {
1462
- return Promise.reject(e);
1463
- }
1464
- }
1465
- async function Vn({ apiKey: t, apiHost: e }, s, n) {
1466
- return ce(async () => {
1467
- const r = (await gt({ url: `${e}/v1/images/book/${s}`, apiKey: t, payload: n })).data;
1468
- return Vr.parse(r);
1469
- });
1470
- }
1471
- var E;
1472
- (function(t) {
1473
- t.assertEqual = (r) => r;
1474
- function e(r) {
1475
- }
1476
- t.assertIs = e;
1477
- function s(r) {
1478
- throw new Error();
1479
- }
1480
- t.assertNever = s, t.arrayToEnum = (r) => {
1481
- const a = {};
1482
- for (const i of r)
1483
- a[i] = i;
1484
- return a;
1485
- }, t.getValidEnumValues = (r) => {
1486
- const a = t.objectKeys(r).filter((o) => typeof r[r[o]] != "number"), i = {};
1487
- for (const o of a)
1488
- i[o] = r[o];
1489
- return t.objectValues(i);
1490
- }, t.objectValues = (r) => t.objectKeys(r).map(function(a) {
1491
- return r[a];
1492
- }), t.objectKeys = typeof Object.keys == "function" ? (r) => Object.keys(r) : (r) => {
1493
- const a = [];
1494
- for (const i in r)
1495
- Object.prototype.hasOwnProperty.call(r, i) && a.push(i);
1496
- return a;
1497
- }, t.find = (r, a) => {
1498
- for (const i of r)
1499
- if (a(i))
1500
- return i;
1501
- }, t.isInteger = typeof Number.isInteger == "function" ? (r) => Number.isInteger(r) : (r) => typeof r == "number" && isFinite(r) && Math.floor(r) === r;
1502
- function n(r, a = " | ") {
1503
- return r.map((i) => typeof i == "string" ? `'${i}'` : i).join(a);
1504
- }
1505
- t.joinValues = n, t.jsonStringifyReplacer = (r, a) => typeof a == "bigint" ? a.toString() : a;
1506
- })(E || (E = {}));
1507
- var at;
1508
- (function(t) {
1509
- t.mergeShapes = (e, s) => ({
1510
- ...e,
1511
- ...s
1512
- // second overwrites first
1513
- });
1514
- })(at || (at = {}));
1515
- const p = E.arrayToEnum([
1516
- "string",
1517
- "nan",
1518
- "number",
1519
- "integer",
1520
- "float",
1521
- "boolean",
1522
- "date",
1523
- "bigint",
1524
- "symbol",
1525
- "function",
1526
- "undefined",
1527
- "null",
1528
- "array",
1529
- "object",
1530
- "unknown",
1531
- "promise",
1532
- "void",
1533
- "never",
1534
- "map",
1535
- "set"
1536
- ]), K = (t) => {
1537
- switch (typeof t) {
1538
- case "undefined":
1539
- return p.undefined;
1540
- case "string":
1541
- return p.string;
1542
- case "number":
1543
- return isNaN(t) ? p.nan : p.number;
1544
- case "boolean":
1545
- return p.boolean;
1546
- case "function":
1547
- return p.function;
1548
- case "bigint":
1549
- return p.bigint;
1550
- case "symbol":
1551
- return p.symbol;
1552
- case "object":
1553
- return Array.isArray(t) ? p.array : t === null ? p.null : t.then && typeof t.then == "function" && t.catch && typeof t.catch == "function" ? p.promise : typeof Map < "u" && t instanceof Map ? p.map : typeof Set < "u" && t instanceof Set ? p.set : typeof Date < "u" && t instanceof Date ? p.date : p.object;
1554
- default:
1555
- return p.unknown;
1556
- }
1557
- }, h = E.arrayToEnum([
1558
- "invalid_type",
1559
- "invalid_literal",
1560
- "custom",
1561
- "invalid_union",
1562
- "invalid_union_discriminator",
1563
- "invalid_enum_value",
1564
- "unrecognized_keys",
1565
- "invalid_arguments",
1566
- "invalid_return_type",
1567
- "invalid_date",
1568
- "invalid_string",
1569
- "too_small",
1570
- "too_big",
1571
- "invalid_intersection_types",
1572
- "not_multiple_of",
1573
- "not_finite"
1574
- ]), Fn = (t) => JSON.stringify(t, null, 2).replace(/"([^"]+)":/g, "$1:");
1575
- class D extends Error {
1576
- constructor(e) {
1577
- super(), this.issues = [], this.addIssue = (n) => {
1578
- this.issues = [...this.issues, n];
1579
- }, this.addIssues = (n = []) => {
1580
- this.issues = [...this.issues, ...n];
1581
- };
1582
- const s = new.target.prototype;
1583
- Object.setPrototypeOf ? Object.setPrototypeOf(this, s) : this.__proto__ = s, this.name = "ZodError", this.issues = e;
1584
- }
1585
- get errors() {
1586
- return this.issues;
1587
- }
1588
- format(e) {
1589
- const s = e || function(a) {
1590
- return a.message;
1591
- }, n = { _errors: [] }, r = (a) => {
1592
- for (const i of a.issues)
1593
- if (i.code === "invalid_union")
1594
- i.unionErrors.map(r);
1595
- else if (i.code === "invalid_return_type")
1596
- r(i.returnTypeError);
1597
- else if (i.code === "invalid_arguments")
1598
- r(i.argumentsError);
1599
- else if (i.path.length === 0)
1600
- n._errors.push(s(i));
1601
- else {
1602
- let o = n, u = 0;
1603
- for (; u < i.path.length; ) {
1604
- const l = i.path[u];
1605
- u === i.path.length - 1 ? (o[l] = o[l] || { _errors: [] }, o[l]._errors.push(s(i))) : o[l] = o[l] || { _errors: [] }, o = o[l], u++;
1606
- }
1607
- }
1608
- };
1609
- return r(this), n;
1610
- }
1611
- toString() {
1612
- return this.message;
1613
- }
1614
- get message() {
1615
- return JSON.stringify(this.issues, E.jsonStringifyReplacer, 2);
1616
- }
1617
- get isEmpty() {
1618
- return this.issues.length === 0;
1619
- }
1620
- flatten(e = (s) => s.message) {
1621
- const s = {}, n = [];
1622
- for (const r of this.issues)
1623
- r.path.length > 0 ? (s[r.path[0]] = s[r.path[0]] || [], s[r.path[0]].push(e(r))) : n.push(e(r));
1624
- return { formErrors: n, fieldErrors: s };
1625
- }
1626
- get formErrors() {
1627
- return this.flatten();
1628
- }
1629
- }
1630
- D.create = (t) => new D(t);
1631
- const fe = (t, e) => {
1632
- let s;
1633
- switch (t.code) {
1634
- case h.invalid_type:
1635
- t.received === p.undefined ? s = "Required" : s = `Expected ${t.expected}, received ${t.received}`;
1636
- break;
1637
- case h.invalid_literal:
1638
- s = `Invalid literal value, expected ${JSON.stringify(t.expected, E.jsonStringifyReplacer)}`;
1639
- break;
1640
- case h.unrecognized_keys:
1641
- s = `Unrecognized key(s) in object: ${E.joinValues(t.keys, ", ")}`;
1642
- break;
1643
- case h.invalid_union:
1644
- s = "Invalid input";
1645
- break;
1646
- case h.invalid_union_discriminator:
1647
- s = `Invalid discriminator value. Expected ${E.joinValues(t.options)}`;
1648
- break;
1649
- case h.invalid_enum_value:
1650
- s = `Invalid enum value. Expected ${E.joinValues(t.options)}, received '${t.received}'`;
1651
- break;
1652
- case h.invalid_arguments:
1653
- s = "Invalid function arguments";
1654
- break;
1655
- case h.invalid_return_type:
1656
- s = "Invalid function return type";
1657
- break;
1658
- case h.invalid_date:
1659
- s = "Invalid date";
1660
- break;
1661
- case h.invalid_string:
1662
- typeof t.validation == "object" ? "includes" in t.validation ? (s = `Invalid input: must include "${t.validation.includes}"`, typeof t.validation.position == "number" && (s = `${s} at one or more positions greater than or equal to ${t.validation.position}`)) : "startsWith" in t.validation ? s = `Invalid input: must start with "${t.validation.startsWith}"` : "endsWith" in t.validation ? s = `Invalid input: must end with "${t.validation.endsWith}"` : E.assertNever(t.validation) : t.validation !== "regex" ? s = `Invalid ${t.validation}` : s = "Invalid";
1663
- break;
1664
- case h.too_small:
1665
- t.type === "array" ? s = `Array must contain ${t.exact ? "exactly" : t.inclusive ? "at least" : "more than"} ${t.minimum} element(s)` : t.type === "string" ? s = `String must contain ${t.exact ? "exactly" : t.inclusive ? "at least" : "over"} ${t.minimum} character(s)` : t.type === "number" ? s = `Number must be ${t.exact ? "exactly equal to " : t.inclusive ? "greater than or equal to " : "greater than "}${t.minimum}` : t.type === "date" ? s = `Date must be ${t.exact ? "exactly equal to " : t.inclusive ? "greater than or equal to " : "greater than "}${new Date(Number(t.minimum))}` : s = "Invalid input";
1666
- break;
1667
- case h.too_big:
1668
- t.type === "array" ? s = `Array must contain ${t.exact ? "exactly" : t.inclusive ? "at most" : "less than"} ${t.maximum} element(s)` : t.type === "string" ? s = `String must contain ${t.exact ? "exactly" : t.inclusive ? "at most" : "under"} ${t.maximum} character(s)` : t.type === "number" ? s = `Number must be ${t.exact ? "exactly" : t.inclusive ? "less than or equal to" : "less than"} ${t.maximum}` : t.type === "bigint" ? s = `BigInt must be ${t.exact ? "exactly" : t.inclusive ? "less than or equal to" : "less than"} ${t.maximum}` : t.type === "date" ? s = `Date must be ${t.exact ? "exactly" : t.inclusive ? "smaller than or equal to" : "smaller than"} ${new Date(Number(t.maximum))}` : s = "Invalid input";
1669
- break;
1670
- case h.custom:
1671
- s = "Invalid input";
1672
- break;
1673
- case h.invalid_intersection_types:
1674
- s = "Intersection results could not be merged";
1675
- break;
1676
- case h.not_multiple_of:
1677
- s = `Number must be a multiple of ${t.multipleOf}`;
1678
- break;
1679
- case h.not_finite:
1680
- s = "Number must be finite";
1681
- break;
1682
- default:
1683
- s = e.defaultError, E.assertNever(t);
1684
- }
1685
- return { message: s };
1686
- };
1687
- let ss = fe;
1688
- function Hn(t) {
1689
- ss = t;
1690
- }
1691
- function je() {
1692
- return ss;
1693
- }
1694
- const Ze = (t) => {
1695
- const { data: e, path: s, errorMaps: n, issueData: r } = t, a = [...s, ...r.path || []], i = {
1696
- ...r,
1697
- path: a
1698
- };
1699
- let o = "";
1700
- const u = n.filter((l) => !!l).slice().reverse();
1701
- for (const l of u)
1702
- o = l(i, { data: e, defaultError: o }).message;
1703
- return {
1704
- ...r,
1705
- path: a,
1706
- message: r.message || o
1707
- };
1708
- }, Jn = [];
1709
- function m(t, e) {
1710
- const s = Ze({
1711
- issueData: e,
1712
- data: t.data,
1713
- path: t.path,
1714
- errorMaps: [
1715
- t.common.contextualErrorMap,
1716
- t.schemaErrorMap,
1717
- je(),
1718
- fe
1719
- // then global default map
1720
- ].filter((n) => !!n)
1721
- });
1722
- t.common.issues.push(s);
1723
- }
1724
- class R {
1725
- constructor() {
1726
- this.value = "valid";
1727
- }
1728
- dirty() {
1729
- this.value === "valid" && (this.value = "dirty");
1730
- }
1731
- abort() {
1732
- this.value !== "aborted" && (this.value = "aborted");
1733
- }
1734
- static mergeArray(e, s) {
1735
- const n = [];
1736
- for (const r of s) {
1737
- if (r.status === "aborted")
1738
- return w;
1739
- r.status === "dirty" && e.dirty(), n.push(r.value);
1740
- }
1741
- return { status: e.value, value: n };
1742
- }
1743
- static async mergeObjectAsync(e, s) {
1744
- const n = [];
1745
- for (const r of s)
1746
- n.push({
1747
- key: await r.key,
1748
- value: await r.value
1749
- });
1750
- return R.mergeObjectSync(e, n);
1751
- }
1752
- static mergeObjectSync(e, s) {
1753
- const n = {};
1754
- for (const r of s) {
1755
- const { key: a, value: i } = r;
1756
- if (a.status === "aborted" || i.status === "aborted")
1757
- return w;
1758
- a.status === "dirty" && e.dirty(), i.status === "dirty" && e.dirty(), (typeof i.value < "u" || r.alwaysSet) && (n[a.value] = i.value);
1759
- }
1760
- return { status: e.value, value: n };
1761
- }
1762
- }
1763
- const w = Object.freeze({
1764
- status: "aborted"
1765
- }), ns = (t) => ({ status: "dirty", value: t }), I = (t) => ({ status: "valid", value: t }), it = (t) => t.status === "aborted", ot = (t) => t.status === "dirty", Le = (t) => t.status === "valid", De = (t) => typeof Promise < "u" && t instanceof Promise;
1766
- var y;
1767
- (function(t) {
1768
- t.errToObj = (e) => typeof e == "string" ? { message: e } : e || {}, t.toString = (e) => typeof e == "string" ? e : e == null ? void 0 : e.message;
1769
- })(y || (y = {}));
1770
- class U {
1771
- constructor(e, s, n, r) {
1772
- this._cachedPath = [], this.parent = e, this.data = s, this._path = n, this._key = r;
1773
- }
1774
- get path() {
1775
- return this._cachedPath.length || (this._key instanceof Array ? this._cachedPath.push(...this._path, ...this._key) : this._cachedPath.push(...this._path, this._key)), this._cachedPath;
1776
- }
1777
- }
1778
- const Ct = (t, e) => {
1779
- if (Le(e))
1780
- return { success: !0, data: e.value };
1781
- if (!t.common.issues.length)
1782
- throw new Error("Validation failed but no issues detected.");
1783
- return {
1784
- success: !1,
1785
- get error() {
1786
- if (this._error)
1787
- return this._error;
1788
- const s = new D(t.common.issues);
1789
- return this._error = s, this._error;
1790
- }
1791
- };
1792
- };
1793
- function x(t) {
1794
- if (!t)
1795
- return {};
1796
- const { errorMap: e, invalid_type_error: s, required_error: n, description: r } = t;
1797
- if (e && (s || n))
1798
- throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);
1799
- return e ? { errorMap: e, description: r } : { errorMap: (i, o) => i.code !== "invalid_type" ? { message: o.defaultError } : typeof o.data > "u" ? { message: n ?? o.defaultError } : { message: s ?? o.defaultError }, description: r };
1800
- }
1801
- class k {
1802
- constructor(e) {
1803
- this.spa = this.safeParseAsync, this._def = e, this.parse = this.parse.bind(this), this.safeParse = this.safeParse.bind(this), this.parseAsync = this.parseAsync.bind(this), this.safeParseAsync = this.safeParseAsync.bind(this), this.spa = this.spa.bind(this), this.refine = this.refine.bind(this), this.refinement = this.refinement.bind(this), this.superRefine = this.superRefine.bind(this), this.optional = this.optional.bind(this), this.nullable = this.nullable.bind(this), this.nullish = this.nullish.bind(this), this.array = this.array.bind(this), this.promise = this.promise.bind(this), this.or = this.or.bind(this), this.and = this.and.bind(this), this.transform = this.transform.bind(this), this.brand = this.brand.bind(this), this.default = this.default.bind(this), this.catch = this.catch.bind(this), this.describe = this.describe.bind(this), this.pipe = this.pipe.bind(this), this.isNullable = this.isNullable.bind(this), this.isOptional = this.isOptional.bind(this);
1804
- }
1805
- get description() {
1806
- return this._def.description;
1807
- }
1808
- _getType(e) {
1809
- return K(e.data);
1810
- }
1811
- _getOrReturnCtx(e, s) {
1812
- return s || {
1813
- common: e.parent.common,
1814
- data: e.data,
1815
- parsedType: K(e.data),
1816
- schemaErrorMap: this._def.errorMap,
1817
- path: e.path,
1818
- parent: e.parent
1819
- };
1820
- }
1821
- _processInputParams(e) {
1822
- return {
1823
- status: new R(),
1824
- ctx: {
1825
- common: e.parent.common,
1826
- data: e.data,
1827
- parsedType: K(e.data),
1828
- schemaErrorMap: this._def.errorMap,
1829
- path: e.path,
1830
- parent: e.parent
1831
- }
1832
- };
1833
- }
1834
- _parseSync(e) {
1835
- const s = this._parse(e);
1836
- if (De(s))
1837
- throw new Error("Synchronous parse encountered promise.");
1838
- return s;
1839
- }
1840
- _parseAsync(e) {
1841
- const s = this._parse(e);
1842
- return Promise.resolve(s);
1843
- }
1844
- parse(e, s) {
1845
- const n = this.safeParse(e, s);
1846
- if (n.success)
1847
- return n.data;
1848
- throw n.error;
1849
- }
1850
- safeParse(e, s) {
1851
- var n;
1852
- const r = {
1853
- common: {
1854
- issues: [],
1855
- async: (n = s == null ? void 0 : s.async) !== null && n !== void 0 ? n : !1,
1856
- contextualErrorMap: s == null ? void 0 : s.errorMap
1857
- },
1858
- path: (s == null ? void 0 : s.path) || [],
1859
- schemaErrorMap: this._def.errorMap,
1860
- parent: null,
1861
- data: e,
1862
- parsedType: K(e)
1863
- }, a = this._parseSync({ data: e, path: r.path, parent: r });
1864
- return Ct(r, a);
1865
- }
1866
- async parseAsync(e, s) {
1867
- const n = await this.safeParseAsync(e, s);
1868
- if (n.success)
1869
- return n.data;
1870
- throw n.error;
1871
- }
1872
- async safeParseAsync(e, s) {
1873
- const n = {
1874
- common: {
1875
- issues: [],
1876
- contextualErrorMap: s == null ? void 0 : s.errorMap,
1877
- async: !0
1878
- },
1879
- path: (s == null ? void 0 : s.path) || [],
1880
- schemaErrorMap: this._def.errorMap,
1881
- parent: null,
1882
- data: e,
1883
- parsedType: K(e)
1884
- }, r = this._parse({ data: e, path: n.path, parent: n }), a = await (De(r) ? r : Promise.resolve(r));
1885
- return Ct(n, a);
1886
- }
1887
- refine(e, s) {
1888
- const n = (r) => typeof s == "string" || typeof s > "u" ? { message: s } : typeof s == "function" ? s(r) : s;
1889
- return this._refinement((r, a) => {
1890
- const i = e(r), o = () => a.addIssue({
1891
- code: h.custom,
1892
- ...n(r)
1893
- });
1894
- return typeof Promise < "u" && i instanceof Promise ? i.then((u) => u ? !0 : (o(), !1)) : i ? !0 : (o(), !1);
1895
- });
1896
- }
1897
- refinement(e, s) {
1898
- return this._refinement((n, r) => e(n) ? !0 : (r.addIssue(typeof s == "function" ? s(n, r) : s), !1));
1899
- }
1900
- _refinement(e) {
1901
- return new B({
1902
- schema: this,
1903
- typeName: v.ZodEffects,
1904
- effect: { type: "refinement", refinement: e }
1905
- });
1906
- }
1907
- superRefine(e) {
1908
- return this._refinement(e);
1909
- }
1910
- optional() {
1911
- return H.create(this, this._def);
1912
- }
1913
- nullable() {
1914
- return te.create(this, this._def);
1915
- }
1916
- nullish() {
1917
- return this.nullable().optional();
1918
- }
1919
- array() {
1920
- return P.create(this, this._def);
1921
- }
1922
- promise() {
1923
- return oe.create(this, this._def);
1924
- }
1925
- or(e) {
1926
- return ye.create([this, e], this._def);
1927
- }
1928
- and(e) {
1929
- return ge.create(this, e, this._def);
1930
- }
1931
- transform(e) {
1932
- return new B({
1933
- ...x(this._def),
1934
- schema: this,
1935
- typeName: v.ZodEffects,
1936
- effect: { type: "transform", transform: e }
1937
- });
1938
- }
1939
- default(e) {
1940
- const s = typeof e == "function" ? e : () => e;
1941
- return new xe({
1942
- ...x(this._def),
1943
- innerType: this,
1944
- defaultValue: s,
1945
- typeName: v.ZodDefault
1946
- });
1947
- }
1948
- brand() {
1949
- return new as({
1950
- typeName: v.ZodBranded,
1951
- type: this,
1952
- ...x(this._def)
1953
- });
1954
- }
1955
- catch(e) {
1956
- const s = typeof e == "function" ? e : () => e;
1957
- return new Ue({
1958
- ...x(this._def),
1959
- innerType: this,
1960
- catchValue: s,
1961
- typeName: v.ZodCatch
1962
- });
1963
- }
1964
- describe(e) {
1965
- const s = this.constructor;
1966
- return new s({
1967
- ...this._def,
1968
- description: e
1969
- });
1970
- }
1971
- pipe(e) {
1972
- return Te.create(this, e);
1973
- }
1974
- isOptional() {
1975
- return this.safeParse(void 0).success;
1976
- }
1977
- isNullable() {
1978
- return this.safeParse(null).success;
1979
- }
1980
- }
1981
- const Wn = /^c[^\s-]{8,}$/i, Kn = /^[a-z][a-z0-9]*$/, qn = /[0-9A-HJKMNP-TV-Z]{26}/, Gn = /^([a-f0-9]{8}-[a-f0-9]{4}-[1-5][a-f0-9]{3}-[a-f0-9]{4}-[a-f0-9]{12}|00000000-0000-0000-0000-000000000000)$/i, Xn = /^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\])|(\[IPv6:(([a-f0-9]{1,4}:){7}|::([a-f0-9]{1,4}:){0,6}|([a-f0-9]{1,4}:){1}:([a-f0-9]{1,4}:){0,5}|([a-f0-9]{1,4}:){2}:([a-f0-9]{1,4}:){0,4}|([a-f0-9]{1,4}:){3}:([a-f0-9]{1,4}:){0,3}|([a-f0-9]{1,4}:){4}:([a-f0-9]{1,4}:){0,2}|([a-f0-9]{1,4}:){5}:([a-f0-9]{1,4}:){0,1})([a-f0-9]{1,4}|(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2})))\])|([A-Za-z0-9]([A-Za-z0-9-]*[A-Za-z0-9])*(\.[A-Za-z]{2,})+))$/, Yn = /^(\p{Extended_Pictographic}|\p{Emoji_Component})+$/u, Qn = /^(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))$/, er = /^(([a-f0-9]{1,4}:){7}|::([a-f0-9]{1,4}:){0,6}|([a-f0-9]{1,4}:){1}:([a-f0-9]{1,4}:){0,5}|([a-f0-9]{1,4}:){2}:([a-f0-9]{1,4}:){0,4}|([a-f0-9]{1,4}:){3}:([a-f0-9]{1,4}:){0,3}|([a-f0-9]{1,4}:){4}:([a-f0-9]{1,4}:){0,2}|([a-f0-9]{1,4}:){5}:([a-f0-9]{1,4}:){0,1})([a-f0-9]{1,4}|(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2})))$/, tr = (t) => t.precision ? t.offset ? new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}\\.\\d{${t.precision}}(([+-]\\d{2}(:?\\d{2})?)|Z)$`) : new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}\\.\\d{${t.precision}}Z$`) : t.precision === 0 ? t.offset ? new RegExp("^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(([+-]\\d{2}(:?\\d{2})?)|Z)$") : new RegExp("^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}Z$") : t.offset ? new RegExp("^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(\\.\\d+)?(([+-]\\d{2}(:?\\d{2})?)|Z)$") : new RegExp("^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(\\.\\d+)?Z$");
1982
- function sr(t, e) {
1983
- return !!((e === "v4" || !e) && Qn.test(t) || (e === "v6" || !e) && er.test(t));
1984
- }
1985
- class L extends k {
1986
- constructor() {
1987
- super(...arguments), this._regex = (e, s, n) => this.refinement((r) => e.test(r), {
1988
- validation: s,
1989
- code: h.invalid_string,
1990
- ...y.errToObj(n)
1991
- }), this.nonempty = (e) => this.min(1, y.errToObj(e)), this.trim = () => new L({
1992
- ...this._def,
1993
- checks: [...this._def.checks, { kind: "trim" }]
1994
- }), this.toLowerCase = () => new L({
1995
- ...this._def,
1996
- checks: [...this._def.checks, { kind: "toLowerCase" }]
1997
- }), this.toUpperCase = () => new L({
1998
- ...this._def,
1999
- checks: [...this._def.checks, { kind: "toUpperCase" }]
2000
- });
2001
- }
2002
- _parse(e) {
2003
- if (this._def.coerce && (e.data = String(e.data)), this._getType(e) !== p.string) {
2004
- const a = this._getOrReturnCtx(e);
2005
- return m(
2006
- a,
2007
- {
2008
- code: h.invalid_type,
2009
- expected: p.string,
2010
- received: a.parsedType
2011
- }
2012
- //
2013
- ), w;
2014
- }
2015
- const n = new R();
2016
- let r;
2017
- for (const a of this._def.checks)
2018
- if (a.kind === "min")
2019
- e.data.length < a.value && (r = this._getOrReturnCtx(e, r), m(r, {
2020
- code: h.too_small,
2021
- minimum: a.value,
2022
- type: "string",
2023
- inclusive: !0,
2024
- exact: !1,
2025
- message: a.message
2026
- }), n.dirty());
2027
- else if (a.kind === "max")
2028
- e.data.length > a.value && (r = this._getOrReturnCtx(e, r), m(r, {
2029
- code: h.too_big,
2030
- maximum: a.value,
2031
- type: "string",
2032
- inclusive: !0,
2033
- exact: !1,
2034
- message: a.message
2035
- }), n.dirty());
2036
- else if (a.kind === "length") {
2037
- const i = e.data.length > a.value, o = e.data.length < a.value;
2038
- (i || o) && (r = this._getOrReturnCtx(e, r), i ? m(r, {
2039
- code: h.too_big,
2040
- maximum: a.value,
2041
- type: "string",
2042
- inclusive: !0,
2043
- exact: !0,
2044
- message: a.message
2045
- }) : o && m(r, {
2046
- code: h.too_small,
2047
- minimum: a.value,
2048
- type: "string",
2049
- inclusive: !0,
2050
- exact: !0,
2051
- message: a.message
2052
- }), n.dirty());
2053
- } else if (a.kind === "email")
2054
- Xn.test(e.data) || (r = this._getOrReturnCtx(e, r), m(r, {
2055
- validation: "email",
2056
- code: h.invalid_string,
2057
- message: a.message
2058
- }), n.dirty());
2059
- else if (a.kind === "emoji")
2060
- Yn.test(e.data) || (r = this._getOrReturnCtx(e, r), m(r, {
2061
- validation: "emoji",
2062
- code: h.invalid_string,
2063
- message: a.message
2064
- }), n.dirty());
2065
- else if (a.kind === "uuid")
2066
- Gn.test(e.data) || (r = this._getOrReturnCtx(e, r), m(r, {
2067
- validation: "uuid",
2068
- code: h.invalid_string,
2069
- message: a.message
2070
- }), n.dirty());
2071
- else if (a.kind === "cuid")
2072
- Wn.test(e.data) || (r = this._getOrReturnCtx(e, r), m(r, {
2073
- validation: "cuid",
2074
- code: h.invalid_string,
2075
- message: a.message
2076
- }), n.dirty());
2077
- else if (a.kind === "cuid2")
2078
- Kn.test(e.data) || (r = this._getOrReturnCtx(e, r), m(r, {
2079
- validation: "cuid2",
2080
- code: h.invalid_string,
2081
- message: a.message
2082
- }), n.dirty());
2083
- else if (a.kind === "ulid")
2084
- qn.test(e.data) || (r = this._getOrReturnCtx(e, r), m(r, {
2085
- validation: "ulid",
2086
- code: h.invalid_string,
2087
- message: a.message
2088
- }), n.dirty());
2089
- else if (a.kind === "url")
2090
- try {
2091
- new URL(e.data);
2092
- } catch {
2093
- r = this._getOrReturnCtx(e, r), m(r, {
2094
- validation: "url",
2095
- code: h.invalid_string,
2096
- message: a.message
2097
- }), n.dirty();
2098
- }
2099
- else
2100
- a.kind === "regex" ? (a.regex.lastIndex = 0, a.regex.test(e.data) || (r = this._getOrReturnCtx(e, r), m(r, {
2101
- validation: "regex",
2102
- code: h.invalid_string,
2103
- message: a.message
2104
- }), n.dirty())) : a.kind === "trim" ? e.data = e.data.trim() : a.kind === "includes" ? e.data.includes(a.value, a.position) || (r = this._getOrReturnCtx(e, r), m(r, {
2105
- code: h.invalid_string,
2106
- validation: { includes: a.value, position: a.position },
2107
- message: a.message
2108
- }), n.dirty()) : a.kind === "toLowerCase" ? e.data = e.data.toLowerCase() : a.kind === "toUpperCase" ? e.data = e.data.toUpperCase() : a.kind === "startsWith" ? e.data.startsWith(a.value) || (r = this._getOrReturnCtx(e, r), m(r, {
2109
- code: h.invalid_string,
2110
- validation: { startsWith: a.value },
2111
- message: a.message
2112
- }), n.dirty()) : a.kind === "endsWith" ? e.data.endsWith(a.value) || (r = this._getOrReturnCtx(e, r), m(r, {
2113
- code: h.invalid_string,
2114
- validation: { endsWith: a.value },
2115
- message: a.message
2116
- }), n.dirty()) : a.kind === "datetime" ? tr(a).test(e.data) || (r = this._getOrReturnCtx(e, r), m(r, {
2117
- code: h.invalid_string,
2118
- validation: "datetime",
2119
- message: a.message
2120
- }), n.dirty()) : a.kind === "ip" ? sr(e.data, a.version) || (r = this._getOrReturnCtx(e, r), m(r, {
2121
- validation: "ip",
2122
- code: h.invalid_string,
2123
- message: a.message
2124
- }), n.dirty()) : E.assertNever(a);
2125
- return { status: n.value, value: e.data };
2126
- }
2127
- _addCheck(e) {
2128
- return new L({
2129
- ...this._def,
2130
- checks: [...this._def.checks, e]
2131
- });
2132
- }
2133
- email(e) {
2134
- return this._addCheck({ kind: "email", ...y.errToObj(e) });
2135
- }
2136
- url(e) {
2137
- return this._addCheck({ kind: "url", ...y.errToObj(e) });
2138
- }
2139
- emoji(e) {
2140
- return this._addCheck({ kind: "emoji", ...y.errToObj(e) });
2141
- }
2142
- uuid(e) {
2143
- return this._addCheck({ kind: "uuid", ...y.errToObj(e) });
2144
- }
2145
- cuid(e) {
2146
- return this._addCheck({ kind: "cuid", ...y.errToObj(e) });
2147
- }
2148
- cuid2(e) {
2149
- return this._addCheck({ kind: "cuid2", ...y.errToObj(e) });
2150
- }
2151
- ulid(e) {
2152
- return this._addCheck({ kind: "ulid", ...y.errToObj(e) });
2153
- }
2154
- ip(e) {
2155
- return this._addCheck({ kind: "ip", ...y.errToObj(e) });
2156
- }
2157
- datetime(e) {
2158
- var s;
2159
- return typeof e == "string" ? this._addCheck({
2160
- kind: "datetime",
2161
- precision: null,
2162
- offset: !1,
2163
- message: e
2164
- }) : this._addCheck({
2165
- kind: "datetime",
2166
- precision: typeof (e == null ? void 0 : e.precision) > "u" ? null : e == null ? void 0 : e.precision,
2167
- offset: (s = e == null ? void 0 : e.offset) !== null && s !== void 0 ? s : !1,
2168
- ...y.errToObj(e == null ? void 0 : e.message)
2169
- });
2170
- }
2171
- regex(e, s) {
2172
- return this._addCheck({
2173
- kind: "regex",
2174
- regex: e,
2175
- ...y.errToObj(s)
2176
- });
2177
- }
2178
- includes(e, s) {
2179
- return this._addCheck({
2180
- kind: "includes",
2181
- value: e,
2182
- position: s == null ? void 0 : s.position,
2183
- ...y.errToObj(s == null ? void 0 : s.message)
2184
- });
2185
- }
2186
- startsWith(e, s) {
2187
- return this._addCheck({
2188
- kind: "startsWith",
2189
- value: e,
2190
- ...y.errToObj(s)
2191
- });
2192
- }
2193
- endsWith(e, s) {
2194
- return this._addCheck({
2195
- kind: "endsWith",
2196
- value: e,
2197
- ...y.errToObj(s)
2198
- });
2199
- }
2200
- min(e, s) {
2201
- return this._addCheck({
2202
- kind: "min",
2203
- value: e,
2204
- ...y.errToObj(s)
2205
- });
2206
- }
2207
- max(e, s) {
2208
- return this._addCheck({
2209
- kind: "max",
2210
- value: e,
2211
- ...y.errToObj(s)
2212
- });
2213
- }
2214
- length(e, s) {
2215
- return this._addCheck({
2216
- kind: "length",
2217
- value: e,
2218
- ...y.errToObj(s)
2219
- });
2220
- }
2221
- get isDatetime() {
2222
- return !!this._def.checks.find((e) => e.kind === "datetime");
2223
- }
2224
- get isEmail() {
2225
- return !!this._def.checks.find((e) => e.kind === "email");
2226
- }
2227
- get isURL() {
2228
- return !!this._def.checks.find((e) => e.kind === "url");
2229
- }
2230
- get isEmoji() {
2231
- return !!this._def.checks.find((e) => e.kind === "emoji");
2232
- }
2233
- get isUUID() {
2234
- return !!this._def.checks.find((e) => e.kind === "uuid");
2235
- }
2236
- get isCUID() {
2237
- return !!this._def.checks.find((e) => e.kind === "cuid");
2238
- }
2239
- get isCUID2() {
2240
- return !!this._def.checks.find((e) => e.kind === "cuid2");
2241
- }
2242
- get isULID() {
2243
- return !!this._def.checks.find((e) => e.kind === "ulid");
2244
- }
2245
- get isIP() {
2246
- return !!this._def.checks.find((e) => e.kind === "ip");
2247
- }
2248
- get minLength() {
2249
- let e = null;
2250
- for (const s of this._def.checks)
2251
- s.kind === "min" && (e === null || s.value > e) && (e = s.value);
2252
- return e;
2253
- }
2254
- get maxLength() {
2255
- let e = null;
2256
- for (const s of this._def.checks)
2257
- s.kind === "max" && (e === null || s.value < e) && (e = s.value);
2258
- return e;
2259
- }
2260
- }
2261
- L.create = (t) => {
2262
- var e;
2263
- return new L({
2264
- checks: [],
2265
- typeName: v.ZodString,
2266
- coerce: (e = t == null ? void 0 : t.coerce) !== null && e !== void 0 ? e : !1,
2267
- ...x(t)
2268
- });
2269
- };
2270
- function nr(t, e) {
2271
- const s = (t.toString().split(".")[1] || "").length, n = (e.toString().split(".")[1] || "").length, r = s > n ? s : n, a = parseInt(t.toFixed(r).replace(".", "")), i = parseInt(e.toFixed(r).replace(".", ""));
2272
- return a % i / Math.pow(10, r);
2273
- }
2274
- class q extends k {
2275
- constructor() {
2276
- super(...arguments), this.min = this.gte, this.max = this.lte, this.step = this.multipleOf;
2277
- }
2278
- _parse(e) {
2279
- if (this._def.coerce && (e.data = Number(e.data)), this._getType(e) !== p.number) {
2280
- const a = this._getOrReturnCtx(e);
2281
- return m(a, {
2282
- code: h.invalid_type,
2283
- expected: p.number,
2284
- received: a.parsedType
2285
- }), w;
2286
- }
2287
- let n;
2288
- const r = new R();
2289
- for (const a of this._def.checks)
2290
- a.kind === "int" ? E.isInteger(e.data) || (n = this._getOrReturnCtx(e, n), m(n, {
2291
- code: h.invalid_type,
2292
- expected: "integer",
2293
- received: "float",
2294
- message: a.message
2295
- }), r.dirty()) : a.kind === "min" ? (a.inclusive ? e.data < a.value : e.data <= a.value) && (n = this._getOrReturnCtx(e, n), m(n, {
2296
- code: h.too_small,
2297
- minimum: a.value,
2298
- type: "number",
2299
- inclusive: a.inclusive,
2300
- exact: !1,
2301
- message: a.message
2302
- }), r.dirty()) : a.kind === "max" ? (a.inclusive ? e.data > a.value : e.data >= a.value) && (n = this._getOrReturnCtx(e, n), m(n, {
2303
- code: h.too_big,
2304
- maximum: a.value,
2305
- type: "number",
2306
- inclusive: a.inclusive,
2307
- exact: !1,
2308
- message: a.message
2309
- }), r.dirty()) : a.kind === "multipleOf" ? nr(e.data, a.value) !== 0 && (n = this._getOrReturnCtx(e, n), m(n, {
2310
- code: h.not_multiple_of,
2311
- multipleOf: a.value,
2312
- message: a.message
2313
- }), r.dirty()) : a.kind === "finite" ? Number.isFinite(e.data) || (n = this._getOrReturnCtx(e, n), m(n, {
2314
- code: h.not_finite,
2315
- message: a.message
2316
- }), r.dirty()) : E.assertNever(a);
2317
- return { status: r.value, value: e.data };
2318
- }
2319
- gte(e, s) {
2320
- return this.setLimit("min", e, !0, y.toString(s));
2321
- }
2322
- gt(e, s) {
2323
- return this.setLimit("min", e, !1, y.toString(s));
2324
- }
2325
- lte(e, s) {
2326
- return this.setLimit("max", e, !0, y.toString(s));
2327
- }
2328
- lt(e, s) {
2329
- return this.setLimit("max", e, !1, y.toString(s));
2330
- }
2331
- setLimit(e, s, n, r) {
2332
- return new q({
2333
- ...this._def,
2334
- checks: [
2335
- ...this._def.checks,
2336
- {
2337
- kind: e,
2338
- value: s,
2339
- inclusive: n,
2340
- message: y.toString(r)
2341
- }
2342
- ]
2343
- });
2344
- }
2345
- _addCheck(e) {
2346
- return new q({
2347
- ...this._def,
2348
- checks: [...this._def.checks, e]
2349
- });
2350
- }
2351
- int(e) {
2352
- return this._addCheck({
2353
- kind: "int",
2354
- message: y.toString(e)
2355
- });
2356
- }
2357
- positive(e) {
2358
- return this._addCheck({
2359
- kind: "min",
2360
- value: 0,
2361
- inclusive: !1,
2362
- message: y.toString(e)
2363
- });
2364
- }
2365
- negative(e) {
2366
- return this._addCheck({
2367
- kind: "max",
2368
- value: 0,
2369
- inclusive: !1,
2370
- message: y.toString(e)
2371
- });
2372
- }
2373
- nonpositive(e) {
2374
- return this._addCheck({
2375
- kind: "max",
2376
- value: 0,
2377
- inclusive: !0,
2378
- message: y.toString(e)
2379
- });
2380
- }
2381
- nonnegative(e) {
2382
- return this._addCheck({
2383
- kind: "min",
2384
- value: 0,
2385
- inclusive: !0,
2386
- message: y.toString(e)
2387
- });
2388
- }
2389
- multipleOf(e, s) {
2390
- return this._addCheck({
2391
- kind: "multipleOf",
2392
- value: e,
2393
- message: y.toString(s)
2394
- });
2395
- }
2396
- finite(e) {
2397
- return this._addCheck({
2398
- kind: "finite",
2399
- message: y.toString(e)
2400
- });
2401
- }
2402
- safe(e) {
2403
- return this._addCheck({
2404
- kind: "min",
2405
- inclusive: !0,
2406
- value: Number.MIN_SAFE_INTEGER,
2407
- message: y.toString(e)
2408
- })._addCheck({
2409
- kind: "max",
2410
- inclusive: !0,
2411
- value: Number.MAX_SAFE_INTEGER,
2412
- message: y.toString(e)
2413
- });
2414
- }
2415
- get minValue() {
2416
- let e = null;
2417
- for (const s of this._def.checks)
2418
- s.kind === "min" && (e === null || s.value > e) && (e = s.value);
2419
- return e;
2420
- }
2421
- get maxValue() {
2422
- let e = null;
2423
- for (const s of this._def.checks)
2424
- s.kind === "max" && (e === null || s.value < e) && (e = s.value);
2425
- return e;
2426
- }
2427
- get isInt() {
2428
- return !!this._def.checks.find((e) => e.kind === "int" || e.kind === "multipleOf" && E.isInteger(e.value));
2429
- }
2430
- get isFinite() {
2431
- let e = null, s = null;
2432
- for (const n of this._def.checks) {
2433
- if (n.kind === "finite" || n.kind === "int" || n.kind === "multipleOf")
2434
- return !0;
2435
- n.kind === "min" ? (s === null || n.value > s) && (s = n.value) : n.kind === "max" && (e === null || n.value < e) && (e = n.value);
2436
- }
2437
- return Number.isFinite(s) && Number.isFinite(e);
2438
- }
2439
- }
2440
- q.create = (t) => new q({
2441
- checks: [],
2442
- typeName: v.ZodNumber,
2443
- coerce: (t == null ? void 0 : t.coerce) || !1,
2444
- ...x(t)
2445
- });
2446
- class G extends k {
2447
- constructor() {
2448
- super(...arguments), this.min = this.gte, this.max = this.lte;
2449
- }
2450
- _parse(e) {
2451
- if (this._def.coerce && (e.data = BigInt(e.data)), this._getType(e) !== p.bigint) {
2452
- const a = this._getOrReturnCtx(e);
2453
- return m(a, {
2454
- code: h.invalid_type,
2455
- expected: p.bigint,
2456
- received: a.parsedType
2457
- }), w;
2458
- }
2459
- let n;
2460
- const r = new R();
2461
- for (const a of this._def.checks)
2462
- a.kind === "min" ? (a.inclusive ? e.data < a.value : e.data <= a.value) && (n = this._getOrReturnCtx(e, n), m(n, {
2463
- code: h.too_small,
2464
- type: "bigint",
2465
- minimum: a.value,
2466
- inclusive: a.inclusive,
2467
- message: a.message
2468
- }), r.dirty()) : a.kind === "max" ? (a.inclusive ? e.data > a.value : e.data >= a.value) && (n = this._getOrReturnCtx(e, n), m(n, {
2469
- code: h.too_big,
2470
- type: "bigint",
2471
- maximum: a.value,
2472
- inclusive: a.inclusive,
2473
- message: a.message
2474
- }), r.dirty()) : a.kind === "multipleOf" ? e.data % a.value !== BigInt(0) && (n = this._getOrReturnCtx(e, n), m(n, {
2475
- code: h.not_multiple_of,
2476
- multipleOf: a.value,
2477
- message: a.message
2478
- }), r.dirty()) : E.assertNever(a);
2479
- return { status: r.value, value: e.data };
2480
- }
2481
- gte(e, s) {
2482
- return this.setLimit("min", e, !0, y.toString(s));
2483
- }
2484
- gt(e, s) {
2485
- return this.setLimit("min", e, !1, y.toString(s));
2486
- }
2487
- lte(e, s) {
2488
- return this.setLimit("max", e, !0, y.toString(s));
2489
- }
2490
- lt(e, s) {
2491
- return this.setLimit("max", e, !1, y.toString(s));
2492
- }
2493
- setLimit(e, s, n, r) {
2494
- return new G({
2495
- ...this._def,
2496
- checks: [
2497
- ...this._def.checks,
2498
- {
2499
- kind: e,
2500
- value: s,
2501
- inclusive: n,
2502
- message: y.toString(r)
2503
- }
2504
- ]
2505
- });
2506
- }
2507
- _addCheck(e) {
2508
- return new G({
2509
- ...this._def,
2510
- checks: [...this._def.checks, e]
2511
- });
2512
- }
2513
- positive(e) {
2514
- return this._addCheck({
2515
- kind: "min",
2516
- value: BigInt(0),
2517
- inclusive: !1,
2518
- message: y.toString(e)
2519
- });
2520
- }
2521
- negative(e) {
2522
- return this._addCheck({
2523
- kind: "max",
2524
- value: BigInt(0),
2525
- inclusive: !1,
2526
- message: y.toString(e)
2527
- });
2528
- }
2529
- nonpositive(e) {
2530
- return this._addCheck({
2531
- kind: "max",
2532
- value: BigInt(0),
2533
- inclusive: !0,
2534
- message: y.toString(e)
2535
- });
2536
- }
2537
- nonnegative(e) {
2538
- return this._addCheck({
2539
- kind: "min",
2540
- value: BigInt(0),
2541
- inclusive: !0,
2542
- message: y.toString(e)
2543
- });
2544
- }
2545
- multipleOf(e, s) {
2546
- return this._addCheck({
2547
- kind: "multipleOf",
2548
- value: e,
2549
- message: y.toString(s)
2550
- });
2551
- }
2552
- get minValue() {
2553
- let e = null;
2554
- for (const s of this._def.checks)
2555
- s.kind === "min" && (e === null || s.value > e) && (e = s.value);
2556
- return e;
2557
- }
2558
- get maxValue() {
2559
- let e = null;
2560
- for (const s of this._def.checks)
2561
- s.kind === "max" && (e === null || s.value < e) && (e = s.value);
2562
- return e;
2563
- }
2564
- }
2565
- G.create = (t) => {
2566
- var e;
2567
- return new G({
2568
- checks: [],
2569
- typeName: v.ZodBigInt,
2570
- coerce: (e = t == null ? void 0 : t.coerce) !== null && e !== void 0 ? e : !1,
2571
- ...x(t)
2572
- });
2573
- };
2574
- class he extends k {
2575
- _parse(e) {
2576
- if (this._def.coerce && (e.data = !!e.data), this._getType(e) !== p.boolean) {
2577
- const n = this._getOrReturnCtx(e);
2578
- return m(n, {
2579
- code: h.invalid_type,
2580
- expected: p.boolean,
2581
- received: n.parsedType
2582
- }), w;
2583
- }
2584
- return I(e.data);
2585
- }
2586
- }
2587
- he.create = (t) => new he({
2588
- typeName: v.ZodBoolean,
2589
- coerce: (t == null ? void 0 : t.coerce) || !1,
2590
- ...x(t)
2591
- });
2592
- class Q extends k {
2593
- _parse(e) {
2594
- if (this._def.coerce && (e.data = new Date(e.data)), this._getType(e) !== p.date) {
2595
- const a = this._getOrReturnCtx(e);
2596
- return m(a, {
2597
- code: h.invalid_type,
2598
- expected: p.date,
2599
- received: a.parsedType
2600
- }), w;
2601
- }
2602
- if (isNaN(e.data.getTime())) {
2603
- const a = this._getOrReturnCtx(e);
2604
- return m(a, {
2605
- code: h.invalid_date
2606
- }), w;
2607
- }
2608
- const n = new R();
2609
- let r;
2610
- for (const a of this._def.checks)
2611
- a.kind === "min" ? e.data.getTime() < a.value && (r = this._getOrReturnCtx(e, r), m(r, {
2612
- code: h.too_small,
2613
- message: a.message,
2614
- inclusive: !0,
2615
- exact: !1,
2616
- minimum: a.value,
2617
- type: "date"
2618
- }), n.dirty()) : a.kind === "max" ? e.data.getTime() > a.value && (r = this._getOrReturnCtx(e, r), m(r, {
2619
- code: h.too_big,
2620
- message: a.message,
2621
- inclusive: !0,
2622
- exact: !1,
2623
- maximum: a.value,
2624
- type: "date"
2625
- }), n.dirty()) : E.assertNever(a);
2626
- return {
2627
- status: n.value,
2628
- value: new Date(e.data.getTime())
2629
- };
2630
- }
2631
- _addCheck(e) {
2632
- return new Q({
2633
- ...this._def,
2634
- checks: [...this._def.checks, e]
2635
- });
2636
- }
2637
- min(e, s) {
2638
- return this._addCheck({
2639
- kind: "min",
2640
- value: e.getTime(),
2641
- message: y.toString(s)
2642
- });
2643
- }
2644
- max(e, s) {
2645
- return this._addCheck({
2646
- kind: "max",
2647
- value: e.getTime(),
2648
- message: y.toString(s)
2649
- });
2650
- }
2651
- get minDate() {
2652
- let e = null;
2653
- for (const s of this._def.checks)
2654
- s.kind === "min" && (e === null || s.value > e) && (e = s.value);
2655
- return e != null ? new Date(e) : null;
2656
- }
2657
- get maxDate() {
2658
- let e = null;
2659
- for (const s of this._def.checks)
2660
- s.kind === "max" && (e === null || s.value < e) && (e = s.value);
2661
- return e != null ? new Date(e) : null;
2662
- }
2663
- }
2664
- Q.create = (t) => new Q({
2665
- checks: [],
2666
- coerce: (t == null ? void 0 : t.coerce) || !1,
2667
- typeName: v.ZodDate,
2668
- ...x(t)
2669
- });
2670
- class Pe extends k {
2671
- _parse(e) {
2672
- if (this._getType(e) !== p.symbol) {
2673
- const n = this._getOrReturnCtx(e);
2674
- return m(n, {
2675
- code: h.invalid_type,
2676
- expected: p.symbol,
2677
- received: n.parsedType
2678
- }), w;
2679
- }
2680
- return I(e.data);
2681
- }
2682
- }
2683
- Pe.create = (t) => new Pe({
2684
- typeName: v.ZodSymbol,
2685
- ...x(t)
2686
- });
2687
- class pe extends k {
2688
- _parse(e) {
2689
- if (this._getType(e) !== p.undefined) {
2690
- const n = this._getOrReturnCtx(e);
2691
- return m(n, {
2692
- code: h.invalid_type,
2693
- expected: p.undefined,
2694
- received: n.parsedType
2695
- }), w;
2696
- }
2697
- return I(e.data);
2698
- }
2699
- }
2700
- pe.create = (t) => new pe({
2701
- typeName: v.ZodUndefined,
2702
- ...x(t)
2703
- });
2704
- class me extends k {
2705
- _parse(e) {
2706
- if (this._getType(e) !== p.null) {
2707
- const n = this._getOrReturnCtx(e);
2708
- return m(n, {
2709
- code: h.invalid_type,
2710
- expected: p.null,
2711
- received: n.parsedType
2712
- }), w;
2713
- }
2714
- return I(e.data);
2715
- }
2716
- }
2717
- me.create = (t) => new me({
2718
- typeName: v.ZodNull,
2719
- ...x(t)
2720
- });
2721
- class ie extends k {
2722
- constructor() {
2723
- super(...arguments), this._any = !0;
2724
- }
2725
- _parse(e) {
2726
- return I(e.data);
2727
- }
2728
- }
2729
- ie.create = (t) => new ie({
2730
- typeName: v.ZodAny,
2731
- ...x(t)
2732
- });
2733
- class Y extends k {
2734
- constructor() {
2735
- super(...arguments), this._unknown = !0;
2736
- }
2737
- _parse(e) {
2738
- return I(e.data);
2739
- }
2740
- }
2741
- Y.create = (t) => new Y({
2742
- typeName: v.ZodUnknown,
2743
- ...x(t)
2744
- });
2745
- class J extends k {
2746
- _parse(e) {
2747
- const s = this._getOrReturnCtx(e);
2748
- return m(s, {
2749
- code: h.invalid_type,
2750
- expected: p.never,
2751
- received: s.parsedType
2752
- }), w;
2753
- }
2754
- }
2755
- J.create = (t) => new J({
2756
- typeName: v.ZodNever,
2757
- ...x(t)
2758
- });
2759
- class Be extends k {
2760
- _parse(e) {
2761
- if (this._getType(e) !== p.undefined) {
2762
- const n = this._getOrReturnCtx(e);
2763
- return m(n, {
2764
- code: h.invalid_type,
2765
- expected: p.void,
2766
- received: n.parsedType
2767
- }), w;
2768
- }
2769
- return I(e.data);
2770
- }
2771
- }
2772
- Be.create = (t) => new Be({
2773
- typeName: v.ZodVoid,
2774
- ...x(t)
2775
- });
2776
- class P extends k {
2777
- _parse(e) {
2778
- const { ctx: s, status: n } = this._processInputParams(e), r = this._def;
2779
- if (s.parsedType !== p.array)
2780
- return m(s, {
2781
- code: h.invalid_type,
2782
- expected: p.array,
2783
- received: s.parsedType
2784
- }), w;
2785
- if (r.exactLength !== null) {
2786
- const i = s.data.length > r.exactLength.value, o = s.data.length < r.exactLength.value;
2787
- (i || o) && (m(s, {
2788
- code: i ? h.too_big : h.too_small,
2789
- minimum: o ? r.exactLength.value : void 0,
2790
- maximum: i ? r.exactLength.value : void 0,
2791
- type: "array",
2792
- inclusive: !0,
2793
- exact: !0,
2794
- message: r.exactLength.message
2795
- }), n.dirty());
2796
- }
2797
- if (r.minLength !== null && s.data.length < r.minLength.value && (m(s, {
2798
- code: h.too_small,
2799
- minimum: r.minLength.value,
2800
- type: "array",
2801
- inclusive: !0,
2802
- exact: !1,
2803
- message: r.minLength.message
2804
- }), n.dirty()), r.maxLength !== null && s.data.length > r.maxLength.value && (m(s, {
2805
- code: h.too_big,
2806
- maximum: r.maxLength.value,
2807
- type: "array",
2808
- inclusive: !0,
2809
- exact: !1,
2810
- message: r.maxLength.message
2811
- }), n.dirty()), s.common.async)
2812
- return Promise.all([...s.data].map((i, o) => r.type._parseAsync(new U(s, i, s.path, o)))).then((i) => R.mergeArray(n, i));
2813
- const a = [...s.data].map((i, o) => r.type._parseSync(new U(s, i, s.path, o)));
2814
- return R.mergeArray(n, a);
2815
- }
2816
- get element() {
2817
- return this._def.type;
2818
- }
2819
- min(e, s) {
2820
- return new P({
2821
- ...this._def,
2822
- minLength: { value: e, message: y.toString(s) }
2823
- });
2824
- }
2825
- max(e, s) {
2826
- return new P({
2827
- ...this._def,
2828
- maxLength: { value: e, message: y.toString(s) }
2829
- });
2830
- }
2831
- length(e, s) {
2832
- return new P({
2833
- ...this._def,
2834
- exactLength: { value: e, message: y.toString(s) }
2835
- });
2836
- }
2837
- nonempty(e) {
2838
- return this.min(1, e);
2839
- }
2840
- }
2841
- P.create = (t, e) => new P({
2842
- type: t,
2843
- minLength: null,
2844
- maxLength: null,
2845
- exactLength: null,
2846
- typeName: v.ZodArray,
2847
- ...x(e)
2848
- });
2849
- function ne(t) {
2850
- if (t instanceof N) {
2851
- const e = {};
2852
- for (const s in t.shape) {
2853
- const n = t.shape[s];
2854
- e[s] = H.create(ne(n));
2855
- }
2856
- return new N({
2857
- ...t._def,
2858
- shape: () => e
2859
- });
2860
- } else
2861
- return t instanceof P ? new P({
2862
- ...t._def,
2863
- type: ne(t.element)
2864
- }) : t instanceof H ? H.create(ne(t.unwrap())) : t instanceof te ? te.create(ne(t.unwrap())) : t instanceof $ ? $.create(t.items.map((e) => ne(e))) : t;
2865
- }
2866
- class N extends k {
2867
- constructor() {
2868
- super(...arguments), this._cached = null, this.nonstrict = this.passthrough, this.augment = this.extend;
2869
- }
2870
- _getCached() {
2871
- if (this._cached !== null)
2872
- return this._cached;
2873
- const e = this._def.shape(), s = E.objectKeys(e);
2874
- return this._cached = { shape: e, keys: s };
2875
- }
2876
- _parse(e) {
2877
- if (this._getType(e) !== p.object) {
2878
- const l = this._getOrReturnCtx(e);
2879
- return m(l, {
2880
- code: h.invalid_type,
2881
- expected: p.object,
2882
- received: l.parsedType
2883
- }), w;
2884
- }
2885
- const { status: n, ctx: r } = this._processInputParams(e), { shape: a, keys: i } = this._getCached(), o = [];
2886
- if (!(this._def.catchall instanceof J && this._def.unknownKeys === "strip"))
2887
- for (const l in r.data)
2888
- i.includes(l) || o.push(l);
2889
- const u = [];
2890
- for (const l of i) {
2891
- const f = a[l], b = r.data[l];
2892
- u.push({
2893
- key: { status: "valid", value: l },
2894
- value: f._parse(new U(r, b, r.path, l)),
2895
- alwaysSet: l in r.data
2896
- });
2897
- }
2898
- if (this._def.catchall instanceof J) {
2899
- const l = this._def.unknownKeys;
2900
- if (l === "passthrough")
2901
- for (const f of o)
2902
- u.push({
2903
- key: { status: "valid", value: f },
2904
- value: { status: "valid", value: r.data[f] }
2905
- });
2906
- else if (l === "strict")
2907
- o.length > 0 && (m(r, {
2908
- code: h.unrecognized_keys,
2909
- keys: o
2910
- }), n.dirty());
2911
- else if (l !== "strip")
2912
- throw new Error("Internal ZodObject error: invalid unknownKeys value.");
2913
- } else {
2914
- const l = this._def.catchall;
2915
- for (const f of o) {
2916
- const b = r.data[f];
2917
- u.push({
2918
- key: { status: "valid", value: f },
2919
- value: l._parse(
2920
- new U(r, b, r.path, f)
2921
- //, ctx.child(key), value, getParsedType(value)
2922
- ),
2923
- alwaysSet: f in r.data
2924
- });
2925
- }
2926
- }
2927
- return r.common.async ? Promise.resolve().then(async () => {
2928
- const l = [];
2929
- for (const f of u) {
2930
- const b = await f.key;
2931
- l.push({
2932
- key: b,
2933
- value: await f.value,
2934
- alwaysSet: f.alwaysSet
2935
- });
2936
- }
2937
- return l;
2938
- }).then((l) => R.mergeObjectSync(n, l)) : R.mergeObjectSync(n, u);
2939
- }
2940
- get shape() {
2941
- return this._def.shape();
2942
- }
2943
- strict(e) {
2944
- return y.errToObj, new N({
2945
- ...this._def,
2946
- unknownKeys: "strict",
2947
- ...e !== void 0 ? {
2948
- errorMap: (s, n) => {
2949
- var r, a, i, o;
2950
- const u = (i = (a = (r = this._def).errorMap) === null || a === void 0 ? void 0 : a.call(r, s, n).message) !== null && i !== void 0 ? i : n.defaultError;
2951
- return s.code === "unrecognized_keys" ? {
2952
- message: (o = y.errToObj(e).message) !== null && o !== void 0 ? o : u
2953
- } : {
2954
- message: u
2955
- };
2956
- }
2957
- } : {}
2958
- });
2959
- }
2960
- strip() {
2961
- return new N({
2962
- ...this._def,
2963
- unknownKeys: "strip"
2964
- });
2965
- }
2966
- passthrough() {
2967
- return new N({
2968
- ...this._def,
2969
- unknownKeys: "passthrough"
2970
- });
2971
- }
2972
- // const AugmentFactory =
2973
- // <Def extends ZodObjectDef>(def: Def) =>
2974
- // <Augmentation extends ZodRawShape>(
2975
- // augmentation: Augmentation
2976
- // ): ZodObject<
2977
- // extendShape<ReturnType<Def["shape"]>, Augmentation>,
2978
- // Def["unknownKeys"],
2979
- // Def["catchall"]
2980
- // > => {
2981
- // return new ZodObject({
2982
- // ...def,
2983
- // shape: () => ({
2984
- // ...def.shape(),
2985
- // ...augmentation,
2986
- // }),
2987
- // }) as any;
2988
- // };
2989
- extend(e) {
2990
- return new N({
2991
- ...this._def,
2992
- shape: () => ({
2993
- ...this._def.shape(),
2994
- ...e
2995
- })
2996
- });
2997
- }
2998
- /**
2999
- * Prior to zod@1.0.12 there was a bug in the
3000
- * inferred type of merged objects. Please
3001
- * upgrade if you are experiencing issues.
3002
- */
3003
- merge(e) {
3004
- return new N({
3005
- unknownKeys: e._def.unknownKeys,
3006
- catchall: e._def.catchall,
3007
- shape: () => ({
3008
- ...this._def.shape(),
3009
- ...e._def.shape()
3010
- }),
3011
- typeName: v.ZodObject
3012
- });
3013
- }
3014
- // merge<
3015
- // Incoming extends AnyZodObject,
3016
- // Augmentation extends Incoming["shape"],
3017
- // NewOutput extends {
3018
- // [k in keyof Augmentation | keyof Output]: k extends keyof Augmentation
3019
- // ? Augmentation[k]["_output"]
3020
- // : k extends keyof Output
3021
- // ? Output[k]
3022
- // : never;
3023
- // },
3024
- // NewInput extends {
3025
- // [k in keyof Augmentation | keyof Input]: k extends keyof Augmentation
3026
- // ? Augmentation[k]["_input"]
3027
- // : k extends keyof Input
3028
- // ? Input[k]
3029
- // : never;
3030
- // }
3031
- // >(
3032
- // merging: Incoming
3033
- // ): ZodObject<
3034
- // extendShape<T, ReturnType<Incoming["_def"]["shape"]>>,
3035
- // Incoming["_def"]["unknownKeys"],
3036
- // Incoming["_def"]["catchall"],
3037
- // NewOutput,
3038
- // NewInput
3039
- // > {
3040
- // const merged: any = new ZodObject({
3041
- // unknownKeys: merging._def.unknownKeys,
3042
- // catchall: merging._def.catchall,
3043
- // shape: () =>
3044
- // objectUtil.mergeShapes(this._def.shape(), merging._def.shape()),
3045
- // typeName: ZodFirstPartyTypeKind.ZodObject,
3046
- // }) as any;
3047
- // return merged;
3048
- // }
3049
- setKey(e, s) {
3050
- return this.augment({ [e]: s });
3051
- }
3052
- // merge<Incoming extends AnyZodObject>(
3053
- // merging: Incoming
3054
- // ): //ZodObject<T & Incoming["_shape"], UnknownKeys, Catchall> = (merging) => {
3055
- // ZodObject<
3056
- // extendShape<T, ReturnType<Incoming["_def"]["shape"]>>,
3057
- // Incoming["_def"]["unknownKeys"],
3058
- // Incoming["_def"]["catchall"]
3059
- // > {
3060
- // // const mergedShape = objectUtil.mergeShapes(
3061
- // // this._def.shape(),
3062
- // // merging._def.shape()
3063
- // // );
3064
- // const merged: any = new ZodObject({
3065
- // unknownKeys: merging._def.unknownKeys,
3066
- // catchall: merging._def.catchall,
3067
- // shape: () =>
3068
- // objectUtil.mergeShapes(this._def.shape(), merging._def.shape()),
3069
- // typeName: ZodFirstPartyTypeKind.ZodObject,
3070
- // }) as any;
3071
- // return merged;
3072
- // }
3073
- catchall(e) {
3074
- return new N({
3075
- ...this._def,
3076
- catchall: e
3077
- });
3078
- }
3079
- pick(e) {
3080
- const s = {};
3081
- return E.objectKeys(e).forEach((n) => {
3082
- e[n] && this.shape[n] && (s[n] = this.shape[n]);
3083
- }), new N({
3084
- ...this._def,
3085
- shape: () => s
3086
- });
3087
- }
3088
- omit(e) {
3089
- const s = {};
3090
- return E.objectKeys(this.shape).forEach((n) => {
3091
- e[n] || (s[n] = this.shape[n]);
3092
- }), new N({
3093
- ...this._def,
3094
- shape: () => s
3095
- });
3096
- }
3097
- /**
3098
- * @deprecated
3099
- */
3100
- deepPartial() {
3101
- return ne(this);
3102
- }
3103
- partial(e) {
3104
- const s = {};
3105
- return E.objectKeys(this.shape).forEach((n) => {
3106
- const r = this.shape[n];
3107
- e && !e[n] ? s[n] = r : s[n] = r.optional();
3108
- }), new N({
3109
- ...this._def,
3110
- shape: () => s
3111
- });
3112
- }
3113
- required(e) {
3114
- const s = {};
3115
- return E.objectKeys(this.shape).forEach((n) => {
3116
- if (e && !e[n])
3117
- s[n] = this.shape[n];
3118
- else {
3119
- let a = this.shape[n];
3120
- for (; a instanceof H; )
3121
- a = a._def.innerType;
3122
- s[n] = a;
3123
- }
3124
- }), new N({
3125
- ...this._def,
3126
- shape: () => s
3127
- });
3128
- }
3129
- keyof() {
3130
- return rs(E.objectKeys(this.shape));
3131
- }
3132
- }
3133
- N.create = (t, e) => new N({
3134
- shape: () => t,
3135
- unknownKeys: "strip",
3136
- catchall: J.create(),
3137
- typeName: v.ZodObject,
3138
- ...x(e)
3139
- });
3140
- N.strictCreate = (t, e) => new N({
3141
- shape: () => t,
3142
- unknownKeys: "strict",
3143
- catchall: J.create(),
3144
- typeName: v.ZodObject,
3145
- ...x(e)
3146
- });
3147
- N.lazycreate = (t, e) => new N({
3148
- shape: t,
3149
- unknownKeys: "strip",
3150
- catchall: J.create(),
3151
- typeName: v.ZodObject,
3152
- ...x(e)
3153
- });
3154
- class ye extends k {
3155
- _parse(e) {
3156
- const { ctx: s } = this._processInputParams(e), n = this._def.options;
3157
- function r(a) {
3158
- for (const o of a)
3159
- if (o.result.status === "valid")
3160
- return o.result;
3161
- for (const o of a)
3162
- if (o.result.status === "dirty")
3163
- return s.common.issues.push(...o.ctx.common.issues), o.result;
3164
- const i = a.map((o) => new D(o.ctx.common.issues));
3165
- return m(s, {
3166
- code: h.invalid_union,
3167
- unionErrors: i
3168
- }), w;
3169
- }
3170
- if (s.common.async)
3171
- return Promise.all(n.map(async (a) => {
3172
- const i = {
3173
- ...s,
3174
- common: {
3175
- ...s.common,
3176
- issues: []
3177
- },
3178
- parent: null
3179
- };
3180
- return {
3181
- result: await a._parseAsync({
3182
- data: s.data,
3183
- path: s.path,
3184
- parent: i
3185
- }),
3186
- ctx: i
3187
- };
3188
- })).then(r);
3189
- {
3190
- let a;
3191
- const i = [];
3192
- for (const u of n) {
3193
- const l = {
3194
- ...s,
3195
- common: {
3196
- ...s.common,
3197
- issues: []
3198
- },
3199
- parent: null
3200
- }, f = u._parseSync({
3201
- data: s.data,
3202
- path: s.path,
3203
- parent: l
3204
- });
3205
- if (f.status === "valid")
3206
- return f;
3207
- f.status === "dirty" && !a && (a = { result: f, ctx: l }), l.common.issues.length && i.push(l.common.issues);
3208
- }
3209
- if (a)
3210
- return s.common.issues.push(...a.ctx.common.issues), a.result;
3211
- const o = i.map((u) => new D(u));
3212
- return m(s, {
3213
- code: h.invalid_union,
3214
- unionErrors: o
3215
- }), w;
3216
- }
3217
- }
3218
- get options() {
3219
- return this._def.options;
3220
- }
3221
- }
3222
- ye.create = (t, e) => new ye({
3223
- options: t,
3224
- typeName: v.ZodUnion,
3225
- ...x(e)
3226
- });
3227
- const Re = (t) => t instanceof _e ? Re(t.schema) : t instanceof B ? Re(t.innerType()) : t instanceof be ? [t.value] : t instanceof X ? t.options : t instanceof we ? Object.keys(t.enum) : t instanceof xe ? Re(t._def.innerType) : t instanceof pe ? [void 0] : t instanceof me ? [null] : null;
3228
- class Ke extends k {
3229
- _parse(e) {
3230
- const { ctx: s } = this._processInputParams(e);
3231
- if (s.parsedType !== p.object)
3232
- return m(s, {
3233
- code: h.invalid_type,
3234
- expected: p.object,
3235
- received: s.parsedType
3236
- }), w;
3237
- const n = this.discriminator, r = s.data[n], a = this.optionsMap.get(r);
3238
- return a ? s.common.async ? a._parseAsync({
3239
- data: s.data,
3240
- path: s.path,
3241
- parent: s
3242
- }) : a._parseSync({
3243
- data: s.data,
3244
- path: s.path,
3245
- parent: s
3246
- }) : (m(s, {
3247
- code: h.invalid_union_discriminator,
3248
- options: Array.from(this.optionsMap.keys()),
3249
- path: [n]
3250
- }), w);
3251
- }
3252
- get discriminator() {
3253
- return this._def.discriminator;
3254
- }
3255
- get options() {
3256
- return this._def.options;
3257
- }
3258
- get optionsMap() {
3259
- return this._def.optionsMap;
3260
- }
3261
- /**
3262
- * The constructor of the discriminated union schema. Its behaviour is very similar to that of the normal z.union() constructor.
3263
- * However, it only allows a union of objects, all of which need to share a discriminator property. This property must
3264
- * have a different value for each object in the union.
3265
- * @param discriminator the name of the discriminator property
3266
- * @param types an array of object schemas
3267
- * @param params
3268
- */
3269
- static create(e, s, n) {
3270
- const r = /* @__PURE__ */ new Map();
3271
- for (const a of s) {
3272
- const i = Re(a.shape[e]);
3273
- if (!i)
3274
- throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);
3275
- for (const o of i) {
3276
- if (r.has(o))
3277
- throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(o)}`);
3278
- r.set(o, a);
3279
- }
3280
- }
3281
- return new Ke({
3282
- typeName: v.ZodDiscriminatedUnion,
3283
- discriminator: e,
3284
- options: s,
3285
- optionsMap: r,
3286
- ...x(n)
3287
- });
3288
- }
3289
- }
3290
- function lt(t, e) {
3291
- const s = K(t), n = K(e);
3292
- if (t === e)
3293
- return { valid: !0, data: t };
3294
- if (s === p.object && n === p.object) {
3295
- const r = E.objectKeys(e), a = E.objectKeys(t).filter((o) => r.indexOf(o) !== -1), i = { ...t, ...e };
3296
- for (const o of a) {
3297
- const u = lt(t[o], e[o]);
3298
- if (!u.valid)
3299
- return { valid: !1 };
3300
- i[o] = u.data;
3301
- }
3302
- return { valid: !0, data: i };
3303
- } else if (s === p.array && n === p.array) {
3304
- if (t.length !== e.length)
3305
- return { valid: !1 };
3306
- const r = [];
3307
- for (let a = 0; a < t.length; a++) {
3308
- const i = t[a], o = e[a], u = lt(i, o);
3309
- if (!u.valid)
3310
- return { valid: !1 };
3311
- r.push(u.data);
3312
- }
3313
- return { valid: !0, data: r };
3314
- } else
3315
- return s === p.date && n === p.date && +t == +e ? { valid: !0, data: t } : { valid: !1 };
3316
- }
3317
- class ge extends k {
3318
- _parse(e) {
3319
- const { status: s, ctx: n } = this._processInputParams(e), r = (a, i) => {
3320
- if (it(a) || it(i))
3321
- return w;
3322
- const o = lt(a.value, i.value);
3323
- return o.valid ? ((ot(a) || ot(i)) && s.dirty(), { status: s.value, value: o.data }) : (m(n, {
3324
- code: h.invalid_intersection_types
3325
- }), w);
3326
- };
3327
- return n.common.async ? Promise.all([
3328
- this._def.left._parseAsync({
3329
- data: n.data,
3330
- path: n.path,
3331
- parent: n
3332
- }),
3333
- this._def.right._parseAsync({
3334
- data: n.data,
3335
- path: n.path,
3336
- parent: n
3337
- })
3338
- ]).then(([a, i]) => r(a, i)) : r(this._def.left._parseSync({
3339
- data: n.data,
3340
- path: n.path,
3341
- parent: n
3342
- }), this._def.right._parseSync({
3343
- data: n.data,
3344
- path: n.path,
3345
- parent: n
3346
- }));
3347
- }
3348
- }
3349
- ge.create = (t, e, s) => new ge({
3350
- left: t,
3351
- right: e,
3352
- typeName: v.ZodIntersection,
3353
- ...x(s)
3354
- });
3355
- class $ extends k {
3356
- _parse(e) {
3357
- const { status: s, ctx: n } = this._processInputParams(e);
3358
- if (n.parsedType !== p.array)
3359
- return m(n, {
3360
- code: h.invalid_type,
3361
- expected: p.array,
3362
- received: n.parsedType
3363
- }), w;
3364
- if (n.data.length < this._def.items.length)
3365
- return m(n, {
3366
- code: h.too_small,
3367
- minimum: this._def.items.length,
3368
- inclusive: !0,
3369
- exact: !1,
3370
- type: "array"
3371
- }), w;
3372
- !this._def.rest && n.data.length > this._def.items.length && (m(n, {
3373
- code: h.too_big,
3374
- maximum: this._def.items.length,
3375
- inclusive: !0,
3376
- exact: !1,
3377
- type: "array"
3378
- }), s.dirty());
3379
- const a = [...n.data].map((i, o) => {
3380
- const u = this._def.items[o] || this._def.rest;
3381
- return u ? u._parse(new U(n, i, n.path, o)) : null;
3382
- }).filter((i) => !!i);
3383
- return n.common.async ? Promise.all(a).then((i) => R.mergeArray(s, i)) : R.mergeArray(s, a);
3384
- }
3385
- get items() {
3386
- return this._def.items;
3387
- }
3388
- rest(e) {
3389
- return new $({
3390
- ...this._def,
3391
- rest: e
3392
- });
3393
- }
3394
- }
3395
- $.create = (t, e) => {
3396
- if (!Array.isArray(t))
3397
- throw new Error("You must pass an array of schemas to z.tuple([ ... ])");
3398
- return new $({
3399
- items: t,
3400
- typeName: v.ZodTuple,
3401
- rest: null,
3402
- ...x(e)
3403
- });
3404
- };
3405
- class ve extends k {
3406
- get keySchema() {
3407
- return this._def.keyType;
3408
- }
3409
- get valueSchema() {
3410
- return this._def.valueType;
3411
- }
3412
- _parse(e) {
3413
- const { status: s, ctx: n } = this._processInputParams(e);
3414
- if (n.parsedType !== p.object)
3415
- return m(n, {
3416
- code: h.invalid_type,
3417
- expected: p.object,
3418
- received: n.parsedType
3419
- }), w;
3420
- const r = [], a = this._def.keyType, i = this._def.valueType;
3421
- for (const o in n.data)
3422
- r.push({
3423
- key: a._parse(new U(n, o, n.path, o)),
3424
- value: i._parse(new U(n, n.data[o], n.path, o))
3425
- });
3426
- return n.common.async ? R.mergeObjectAsync(s, r) : R.mergeObjectSync(s, r);
3427
- }
3428
- get element() {
3429
- return this._def.valueType;
3430
- }
3431
- static create(e, s, n) {
3432
- return s instanceof k ? new ve({
3433
- keyType: e,
3434
- valueType: s,
3435
- typeName: v.ZodRecord,
3436
- ...x(n)
3437
- }) : new ve({
3438
- keyType: L.create(),
3439
- valueType: e,
3440
- typeName: v.ZodRecord,
3441
- ...x(s)
3442
- });
3443
- }
3444
- }
3445
- class Me extends k {
3446
- _parse(e) {
3447
- const { status: s, ctx: n } = this._processInputParams(e);
3448
- if (n.parsedType !== p.map)
3449
- return m(n, {
3450
- code: h.invalid_type,
3451
- expected: p.map,
3452
- received: n.parsedType
3453
- }), w;
3454
- const r = this._def.keyType, a = this._def.valueType, i = [...n.data.entries()].map(([o, u], l) => ({
3455
- key: r._parse(new U(n, o, n.path, [l, "key"])),
3456
- value: a._parse(new U(n, u, n.path, [l, "value"]))
3457
- }));
3458
- if (n.common.async) {
3459
- const o = /* @__PURE__ */ new Map();
3460
- return Promise.resolve().then(async () => {
3461
- for (const u of i) {
3462
- const l = await u.key, f = await u.value;
3463
- if (l.status === "aborted" || f.status === "aborted")
3464
- return w;
3465
- (l.status === "dirty" || f.status === "dirty") && s.dirty(), o.set(l.value, f.value);
3466
- }
3467
- return { status: s.value, value: o };
3468
- });
3469
- } else {
3470
- const o = /* @__PURE__ */ new Map();
3471
- for (const u of i) {
3472
- const l = u.key, f = u.value;
3473
- if (l.status === "aborted" || f.status === "aborted")
3474
- return w;
3475
- (l.status === "dirty" || f.status === "dirty") && s.dirty(), o.set(l.value, f.value);
3476
- }
3477
- return { status: s.value, value: o };
3478
- }
3479
- }
3480
- }
3481
- Me.create = (t, e, s) => new Me({
3482
- valueType: e,
3483
- keyType: t,
3484
- typeName: v.ZodMap,
3485
- ...x(s)
3486
- });
3487
- class ee extends k {
3488
- _parse(e) {
3489
- const { status: s, ctx: n } = this._processInputParams(e);
3490
- if (n.parsedType !== p.set)
3491
- return m(n, {
3492
- code: h.invalid_type,
3493
- expected: p.set,
3494
- received: n.parsedType
3495
- }), w;
3496
- const r = this._def;
3497
- r.minSize !== null && n.data.size < r.minSize.value && (m(n, {
3498
- code: h.too_small,
3499
- minimum: r.minSize.value,
3500
- type: "set",
3501
- inclusive: !0,
3502
- exact: !1,
3503
- message: r.minSize.message
3504
- }), s.dirty()), r.maxSize !== null && n.data.size > r.maxSize.value && (m(n, {
3505
- code: h.too_big,
3506
- maximum: r.maxSize.value,
3507
- type: "set",
3508
- inclusive: !0,
3509
- exact: !1,
3510
- message: r.maxSize.message
3511
- }), s.dirty());
3512
- const a = this._def.valueType;
3513
- function i(u) {
3514
- const l = /* @__PURE__ */ new Set();
3515
- for (const f of u) {
3516
- if (f.status === "aborted")
3517
- return w;
3518
- f.status === "dirty" && s.dirty(), l.add(f.value);
3519
- }
3520
- return { status: s.value, value: l };
3521
- }
3522
- const o = [...n.data.values()].map((u, l) => a._parse(new U(n, u, n.path, l)));
3523
- return n.common.async ? Promise.all(o).then((u) => i(u)) : i(o);
3524
- }
3525
- min(e, s) {
3526
- return new ee({
3527
- ...this._def,
3528
- minSize: { value: e, message: y.toString(s) }
3529
- });
3530
- }
3531
- max(e, s) {
3532
- return new ee({
3533
- ...this._def,
3534
- maxSize: { value: e, message: y.toString(s) }
3535
- });
3536
- }
3537
- size(e, s) {
3538
- return this.min(e, s).max(e, s);
3539
- }
3540
- nonempty(e) {
3541
- return this.min(1, e);
3542
- }
3543
- }
3544
- ee.create = (t, e) => new ee({
3545
- valueType: t,
3546
- minSize: null,
3547
- maxSize: null,
3548
- typeName: v.ZodSet,
3549
- ...x(e)
3550
- });
3551
- class re extends k {
3552
- constructor() {
3553
- super(...arguments), this.validate = this.implement;
3554
- }
3555
- _parse(e) {
3556
- const { ctx: s } = this._processInputParams(e);
3557
- if (s.parsedType !== p.function)
3558
- return m(s, {
3559
- code: h.invalid_type,
3560
- expected: p.function,
3561
- received: s.parsedType
3562
- }), w;
3563
- function n(o, u) {
3564
- return Ze({
3565
- data: o,
3566
- path: s.path,
3567
- errorMaps: [
3568
- s.common.contextualErrorMap,
3569
- s.schemaErrorMap,
3570
- je(),
3571
- fe
3572
- ].filter((l) => !!l),
3573
- issueData: {
3574
- code: h.invalid_arguments,
3575
- argumentsError: u
3576
- }
3577
- });
3578
- }
3579
- function r(o, u) {
3580
- return Ze({
3581
- data: o,
3582
- path: s.path,
3583
- errorMaps: [
3584
- s.common.contextualErrorMap,
3585
- s.schemaErrorMap,
3586
- je(),
3587
- fe
3588
- ].filter((l) => !!l),
3589
- issueData: {
3590
- code: h.invalid_return_type,
3591
- returnTypeError: u
3592
- }
3593
- });
3594
- }
3595
- const a = { errorMap: s.common.contextualErrorMap }, i = s.data;
3596
- return this._def.returns instanceof oe ? I(async (...o) => {
3597
- const u = new D([]), l = await this._def.args.parseAsync(o, a).catch((C) => {
3598
- throw u.addIssue(n(o, C)), u;
3599
- }), f = await i(...l);
3600
- return await this._def.returns._def.type.parseAsync(f, a).catch((C) => {
3601
- throw u.addIssue(r(f, C)), u;
3602
- });
3603
- }) : I((...o) => {
3604
- const u = this._def.args.safeParse(o, a);
3605
- if (!u.success)
3606
- throw new D([n(o, u.error)]);
3607
- const l = i(...u.data), f = this._def.returns.safeParse(l, a);
3608
- if (!f.success)
3609
- throw new D([r(l, f.error)]);
3610
- return f.data;
3611
- });
3612
- }
3613
- parameters() {
3614
- return this._def.args;
3615
- }
3616
- returnType() {
3617
- return this._def.returns;
3618
- }
3619
- args(...e) {
3620
- return new re({
3621
- ...this._def,
3622
- args: $.create(e).rest(Y.create())
3623
- });
3624
- }
3625
- returns(e) {
3626
- return new re({
3627
- ...this._def,
3628
- returns: e
3629
- });
3630
- }
3631
- implement(e) {
3632
- return this.parse(e);
3633
- }
3634
- strictImplement(e) {
3635
- return this.parse(e);
3636
- }
3637
- static create(e, s, n) {
3638
- return new re({
3639
- args: e || $.create([]).rest(Y.create()),
3640
- returns: s || Y.create(),
3641
- typeName: v.ZodFunction,
3642
- ...x(n)
3643
- });
3644
- }
3645
- }
3646
- class _e extends k {
3647
- get schema() {
3648
- return this._def.getter();
3649
- }
3650
- _parse(e) {
3651
- const { ctx: s } = this._processInputParams(e);
3652
- return this._def.getter()._parse({ data: s.data, path: s.path, parent: s });
3653
- }
3654
- }
3655
- _e.create = (t, e) => new _e({
3656
- getter: t,
3657
- typeName: v.ZodLazy,
3658
- ...x(e)
3659
- });
3660
- class be extends k {
3661
- _parse(e) {
3662
- if (e.data !== this._def.value) {
3663
- const s = this._getOrReturnCtx(e);
3664
- return m(s, {
3665
- received: s.data,
3666
- code: h.invalid_literal,
3667
- expected: this._def.value
3668
- }), w;
3669
- }
3670
- return { status: "valid", value: e.data };
3671
- }
3672
- get value() {
3673
- return this._def.value;
3674
- }
3675
- }
3676
- be.create = (t, e) => new be({
3677
- value: t,
3678
- typeName: v.ZodLiteral,
3679
- ...x(e)
3680
- });
3681
- function rs(t, e) {
3682
- return new X({
3683
- values: t,
3684
- typeName: v.ZodEnum,
3685
- ...x(e)
3686
- });
3687
- }
3688
- class X extends k {
3689
- _parse(e) {
3690
- if (typeof e.data != "string") {
3691
- const s = this._getOrReturnCtx(e), n = this._def.values;
3692
- return m(s, {
3693
- expected: E.joinValues(n),
3694
- received: s.parsedType,
3695
- code: h.invalid_type
3696
- }), w;
3697
- }
3698
- if (this._def.values.indexOf(e.data) === -1) {
3699
- const s = this._getOrReturnCtx(e), n = this._def.values;
3700
- return m(s, {
3701
- received: s.data,
3702
- code: h.invalid_enum_value,
3703
- options: n
3704
- }), w;
3705
- }
3706
- return I(e.data);
3707
- }
3708
- get options() {
3709
- return this._def.values;
3710
- }
3711
- get enum() {
3712
- const e = {};
3713
- for (const s of this._def.values)
3714
- e[s] = s;
3715
- return e;
3716
- }
3717
- get Values() {
3718
- const e = {};
3719
- for (const s of this._def.values)
3720
- e[s] = s;
3721
- return e;
3722
- }
3723
- get Enum() {
3724
- const e = {};
3725
- for (const s of this._def.values)
3726
- e[s] = s;
3727
- return e;
3728
- }
3729
- extract(e) {
3730
- return X.create(e);
3731
- }
3732
- exclude(e) {
3733
- return X.create(this.options.filter((s) => !e.includes(s)));
3734
- }
3735
- }
3736
- X.create = rs;
3737
- class we extends k {
3738
- _parse(e) {
3739
- const s = E.getValidEnumValues(this._def.values), n = this._getOrReturnCtx(e);
3740
- if (n.parsedType !== p.string && n.parsedType !== p.number) {
3741
- const r = E.objectValues(s);
3742
- return m(n, {
3743
- expected: E.joinValues(r),
3744
- received: n.parsedType,
3745
- code: h.invalid_type
3746
- }), w;
3747
- }
3748
- if (s.indexOf(e.data) === -1) {
3749
- const r = E.objectValues(s);
3750
- return m(n, {
3751
- received: n.data,
3752
- code: h.invalid_enum_value,
3753
- options: r
3754
- }), w;
3755
- }
3756
- return I(e.data);
3757
- }
3758
- get enum() {
3759
- return this._def.values;
3760
- }
3761
- }
3762
- we.create = (t, e) => new we({
3763
- values: t,
3764
- typeName: v.ZodNativeEnum,
3765
- ...x(e)
3766
- });
3767
- class oe extends k {
3768
- unwrap() {
3769
- return this._def.type;
3770
- }
3771
- _parse(e) {
3772
- const { ctx: s } = this._processInputParams(e);
3773
- if (s.parsedType !== p.promise && s.common.async === !1)
3774
- return m(s, {
3775
- code: h.invalid_type,
3776
- expected: p.promise,
3777
- received: s.parsedType
3778
- }), w;
3779
- const n = s.parsedType === p.promise ? s.data : Promise.resolve(s.data);
3780
- return I(n.then((r) => this._def.type.parseAsync(r, {
3781
- path: s.path,
3782
- errorMap: s.common.contextualErrorMap
3783
- })));
3784
- }
3785
- }
3786
- oe.create = (t, e) => new oe({
3787
- type: t,
3788
- typeName: v.ZodPromise,
3789
- ...x(e)
3790
- });
3791
- class B extends k {
3792
- innerType() {
3793
- return this._def.schema;
3794
- }
3795
- sourceType() {
3796
- return this._def.schema._def.typeName === v.ZodEffects ? this._def.schema.sourceType() : this._def.schema;
3797
- }
3798
- _parse(e) {
3799
- const { status: s, ctx: n } = this._processInputParams(e), r = this._def.effect || null;
3800
- if (r.type === "preprocess") {
3801
- const i = r.transform(n.data);
3802
- return n.common.async ? Promise.resolve(i).then((o) => this._def.schema._parseAsync({
3803
- data: o,
3804
- path: n.path,
3805
- parent: n
3806
- })) : this._def.schema._parseSync({
3807
- data: i,
3808
- path: n.path,
3809
- parent: n
3810
- });
3811
- }
3812
- const a = {
3813
- addIssue: (i) => {
3814
- m(n, i), i.fatal ? s.abort() : s.dirty();
3815
- },
3816
- get path() {
3817
- return n.path;
3818
- }
3819
- };
3820
- if (a.addIssue = a.addIssue.bind(a), r.type === "refinement") {
3821
- const i = (o) => {
3822
- const u = r.refinement(o, a);
3823
- if (n.common.async)
3824
- return Promise.resolve(u);
3825
- if (u instanceof Promise)
3826
- throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");
3827
- return o;
3828
- };
3829
- if (n.common.async === !1) {
3830
- const o = this._def.schema._parseSync({
3831
- data: n.data,
3832
- path: n.path,
3833
- parent: n
3834
- });
3835
- return o.status === "aborted" ? w : (o.status === "dirty" && s.dirty(), i(o.value), { status: s.value, value: o.value });
3836
- } else
3837
- return this._def.schema._parseAsync({ data: n.data, path: n.path, parent: n }).then((o) => o.status === "aborted" ? w : (o.status === "dirty" && s.dirty(), i(o.value).then(() => ({ status: s.value, value: o.value }))));
3838
- }
3839
- if (r.type === "transform")
3840
- if (n.common.async === !1) {
3841
- const i = this._def.schema._parseSync({
3842
- data: n.data,
3843
- path: n.path,
3844
- parent: n
3845
- });
3846
- if (!Le(i))
3847
- return i;
3848
- const o = r.transform(i.value, a);
3849
- if (o instanceof Promise)
3850
- throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");
3851
- return { status: s.value, value: o };
3852
- } else
3853
- return this._def.schema._parseAsync({ data: n.data, path: n.path, parent: n }).then((i) => Le(i) ? Promise.resolve(r.transform(i.value, a)).then((o) => ({ status: s.value, value: o })) : i);
3854
- E.assertNever(r);
3855
- }
3856
- }
3857
- B.create = (t, e, s) => new B({
3858
- schema: t,
3859
- typeName: v.ZodEffects,
3860
- effect: e,
3861
- ...x(s)
3862
- });
3863
- B.createWithPreprocess = (t, e, s) => new B({
3864
- schema: e,
3865
- effect: { type: "preprocess", transform: t },
3866
- typeName: v.ZodEffects,
3867
- ...x(s)
3868
- });
3869
- class H extends k {
3870
- _parse(e) {
3871
- return this._getType(e) === p.undefined ? I(void 0) : this._def.innerType._parse(e);
3872
- }
3873
- unwrap() {
3874
- return this._def.innerType;
3875
- }
3876
- }
3877
- H.create = (t, e) => new H({
3878
- innerType: t,
3879
- typeName: v.ZodOptional,
3880
- ...x(e)
3881
- });
3882
- class te extends k {
3883
- _parse(e) {
3884
- return this._getType(e) === p.null ? I(null) : this._def.innerType._parse(e);
3885
- }
3886
- unwrap() {
3887
- return this._def.innerType;
3888
- }
3889
- }
3890
- te.create = (t, e) => new te({
3891
- innerType: t,
3892
- typeName: v.ZodNullable,
3893
- ...x(e)
3894
- });
3895
- class xe extends k {
3896
- _parse(e) {
3897
- const { ctx: s } = this._processInputParams(e);
3898
- let n = s.data;
3899
- return s.parsedType === p.undefined && (n = this._def.defaultValue()), this._def.innerType._parse({
3900
- data: n,
3901
- path: s.path,
3902
- parent: s
3903
- });
3904
- }
3905
- removeDefault() {
3906
- return this._def.innerType;
3907
- }
3908
- }
3909
- xe.create = (t, e) => new xe({
3910
- innerType: t,
3911
- typeName: v.ZodDefault,
3912
- defaultValue: typeof e.default == "function" ? e.default : () => e.default,
3913
- ...x(e)
3914
- });
3915
- class Ue extends k {
3916
- _parse(e) {
3917
- const { ctx: s } = this._processInputParams(e), n = {
3918
- ...s,
3919
- common: {
3920
- ...s.common,
3921
- issues: []
3922
- }
3923
- }, r = this._def.innerType._parse({
3924
- data: n.data,
3925
- path: n.path,
3926
- parent: {
3927
- ...n
3928
- }
3929
- });
3930
- return De(r) ? r.then((a) => ({
3931
- status: "valid",
3932
- value: a.status === "valid" ? a.value : this._def.catchValue({
3933
- get error() {
3934
- return new D(n.common.issues);
3935
- },
3936
- input: n.data
3937
- })
3938
- })) : {
3939
- status: "valid",
3940
- value: r.status === "valid" ? r.value : this._def.catchValue({
3941
- get error() {
3942
- return new D(n.common.issues);
3943
- },
3944
- input: n.data
3945
- })
3946
- };
3947
- }
3948
- removeCatch() {
3949
- return this._def.innerType;
3950
- }
3951
- }
3952
- Ue.create = (t, e) => new Ue({
3953
- innerType: t,
3954
- typeName: v.ZodCatch,
3955
- catchValue: typeof e.catch == "function" ? e.catch : () => e.catch,
3956
- ...x(e)
3957
- });
3958
- class $e extends k {
3959
- _parse(e) {
3960
- if (this._getType(e) !== p.nan) {
3961
- const n = this._getOrReturnCtx(e);
3962
- return m(n, {
3963
- code: h.invalid_type,
3964
- expected: p.nan,
3965
- received: n.parsedType
3966
- }), w;
3967
- }
3968
- return { status: "valid", value: e.data };
3969
- }
3970
- }
3971
- $e.create = (t) => new $e({
3972
- typeName: v.ZodNaN,
3973
- ...x(t)
3974
- });
3975
- const rr = Symbol("zod_brand");
3976
- class as extends k {
3977
- _parse(e) {
3978
- const { ctx: s } = this._processInputParams(e), n = s.data;
3979
- return this._def.type._parse({
3980
- data: n,
3981
- path: s.path,
3982
- parent: s
3983
- });
3984
- }
3985
- unwrap() {
3986
- return this._def.type;
3987
- }
3988
- }
3989
- class Te extends k {
3990
- _parse(e) {
3991
- const { status: s, ctx: n } = this._processInputParams(e);
3992
- if (n.common.async)
3993
- return (async () => {
3994
- const a = await this._def.in._parseAsync({
3995
- data: n.data,
3996
- path: n.path,
3997
- parent: n
3998
- });
3999
- return a.status === "aborted" ? w : a.status === "dirty" ? (s.dirty(), ns(a.value)) : this._def.out._parseAsync({
4000
- data: a.value,
4001
- path: n.path,
4002
- parent: n
4003
- });
4004
- })();
4005
- {
4006
- const r = this._def.in._parseSync({
4007
- data: n.data,
4008
- path: n.path,
4009
- parent: n
4010
- });
4011
- return r.status === "aborted" ? w : r.status === "dirty" ? (s.dirty(), {
4012
- status: "dirty",
4013
- value: r.value
4014
- }) : this._def.out._parseSync({
4015
- data: r.value,
4016
- path: n.path,
4017
- parent: n
4018
- });
4019
- }
4020
- }
4021
- static create(e, s) {
4022
- return new Te({
4023
- in: e,
4024
- out: s,
4025
- typeName: v.ZodPipeline
4026
- });
4027
- }
4028
- }
4029
- const is = (t, e = {}, s) => t ? ie.create().superRefine((n, r) => {
4030
- var a, i;
4031
- if (!t(n)) {
4032
- const o = typeof e == "function" ? e(n) : typeof e == "string" ? { message: e } : e, u = (i = (a = o.fatal) !== null && a !== void 0 ? a : s) !== null && i !== void 0 ? i : !0, l = typeof o == "string" ? { message: o } : o;
4033
- r.addIssue({ code: "custom", ...l, fatal: u });
4034
- }
4035
- }) : ie.create(), ar = {
4036
- object: N.lazycreate
4037
- };
4038
- var v;
4039
- (function(t) {
4040
- t.ZodString = "ZodString", t.ZodNumber = "ZodNumber", t.ZodNaN = "ZodNaN", t.ZodBigInt = "ZodBigInt", t.ZodBoolean = "ZodBoolean", t.ZodDate = "ZodDate", t.ZodSymbol = "ZodSymbol", t.ZodUndefined = "ZodUndefined", t.ZodNull = "ZodNull", t.ZodAny = "ZodAny", t.ZodUnknown = "ZodUnknown", t.ZodNever = "ZodNever", t.ZodVoid = "ZodVoid", t.ZodArray = "ZodArray", t.ZodObject = "ZodObject", t.ZodUnion = "ZodUnion", t.ZodDiscriminatedUnion = "ZodDiscriminatedUnion", t.ZodIntersection = "ZodIntersection", t.ZodTuple = "ZodTuple", t.ZodRecord = "ZodRecord", t.ZodMap = "ZodMap", t.ZodSet = "ZodSet", t.ZodFunction = "ZodFunction", t.ZodLazy = "ZodLazy", t.ZodLiteral = "ZodLiteral", t.ZodEnum = "ZodEnum", t.ZodEffects = "ZodEffects", t.ZodNativeEnum = "ZodNativeEnum", t.ZodOptional = "ZodOptional", t.ZodNullable = "ZodNullable", t.ZodDefault = "ZodDefault", t.ZodCatch = "ZodCatch", t.ZodPromise = "ZodPromise", t.ZodBranded = "ZodBranded", t.ZodPipeline = "ZodPipeline";
4041
- })(v || (v = {}));
4042
- const ir = (t, e = {
4043
- message: `Input not instance of ${t.name}`
4044
- }) => is((s) => s instanceof t, e), os = L.create, ls = q.create, or = $e.create, lr = G.create, cs = he.create, cr = Q.create, ur = Pe.create, dr = pe.create, fr = me.create, hr = ie.create, pr = Y.create, mr = J.create, yr = Be.create, gr = P.create, vr = N.create, _r = N.strictCreate, br = ye.create, wr = Ke.create, xr = ge.create, kr = $.create, Sr = ve.create, Tr = Me.create, Er = ee.create, Or = re.create, Nr = _e.create, Cr = be.create, Ar = X.create, Rr = we.create, Ir = oe.create, At = B.create, jr = H.create, Zr = te.create, Lr = B.createWithPreprocess, Dr = Te.create, Pr = () => os().optional(), Br = () => ls().optional(), Mr = () => cs().optional(), Ur = {
4045
- string: (t) => L.create({ ...t, coerce: !0 }),
4046
- number: (t) => q.create({ ...t, coerce: !0 }),
4047
- boolean: (t) => he.create({
4048
- ...t,
4049
- coerce: !0
4050
- }),
4051
- bigint: (t) => G.create({ ...t, coerce: !0 }),
4052
- date: (t) => Q.create({ ...t, coerce: !0 })
4053
- }, $r = w;
4054
- var d = /* @__PURE__ */ Object.freeze({
4055
- __proto__: null,
4056
- defaultErrorMap: fe,
4057
- setErrorMap: Hn,
4058
- getErrorMap: je,
4059
- makeIssue: Ze,
4060
- EMPTY_PATH: Jn,
4061
- addIssueToContext: m,
4062
- ParseStatus: R,
4063
- INVALID: w,
4064
- DIRTY: ns,
4065
- OK: I,
4066
- isAborted: it,
4067
- isDirty: ot,
4068
- isValid: Le,
4069
- isAsync: De,
4070
- get util() {
4071
- return E;
4072
- },
4073
- get objectUtil() {
4074
- return at;
4075
- },
4076
- ZodParsedType: p,
4077
- getParsedType: K,
4078
- ZodType: k,
4079
- ZodString: L,
4080
- ZodNumber: q,
4081
- ZodBigInt: G,
4082
- ZodBoolean: he,
4083
- ZodDate: Q,
4084
- ZodSymbol: Pe,
4085
- ZodUndefined: pe,
4086
- ZodNull: me,
4087
- ZodAny: ie,
4088
- ZodUnknown: Y,
4089
- ZodNever: J,
4090
- ZodVoid: Be,
4091
- ZodArray: P,
4092
- ZodObject: N,
4093
- ZodUnion: ye,
4094
- ZodDiscriminatedUnion: Ke,
4095
- ZodIntersection: ge,
4096
- ZodTuple: $,
4097
- ZodRecord: ve,
4098
- ZodMap: Me,
4099
- ZodSet: ee,
4100
- ZodFunction: re,
4101
- ZodLazy: _e,
4102
- ZodLiteral: be,
4103
- ZodEnum: X,
4104
- ZodNativeEnum: we,
4105
- ZodPromise: oe,
4106
- ZodEffects: B,
4107
- ZodTransformer: B,
4108
- ZodOptional: H,
4109
- ZodNullable: te,
4110
- ZodDefault: xe,
4111
- ZodCatch: Ue,
4112
- ZodNaN: $e,
4113
- BRAND: rr,
4114
- ZodBranded: as,
4115
- ZodPipeline: Te,
4116
- custom: is,
4117
- Schema: k,
4118
- ZodSchema: k,
4119
- late: ar,
4120
- get ZodFirstPartyTypeKind() {
4121
- return v;
4122
- },
4123
- coerce: Ur,
4124
- any: hr,
4125
- array: gr,
4126
- bigint: lr,
4127
- boolean: cs,
4128
- date: cr,
4129
- discriminatedUnion: wr,
4130
- effect: At,
4131
- enum: Ar,
4132
- function: Or,
4133
- instanceof: ir,
4134
- intersection: xr,
4135
- lazy: Nr,
4136
- literal: Cr,
4137
- map: Tr,
4138
- nan: or,
4139
- nativeEnum: Rr,
4140
- never: mr,
4141
- null: fr,
4142
- nullable: Zr,
4143
- number: ls,
4144
- object: vr,
4145
- oboolean: Mr,
4146
- onumber: Br,
4147
- optional: jr,
4148
- ostring: Pr,
4149
- pipeline: Dr,
4150
- preprocess: Lr,
4151
- promise: Ir,
4152
- record: Sr,
4153
- set: Er,
4154
- strictObject: _r,
4155
- string: os,
4156
- symbol: ur,
4157
- transformer: At,
4158
- tuple: kr,
4159
- undefined: dr,
4160
- union: br,
4161
- unknown: pr,
4162
- void: yr,
4163
- NEVER: $r,
4164
- ZodIssueCode: h,
4165
- quotelessJson: Fn,
4166
- ZodError: D
4167
- });
4168
- class zr {
4169
- constructor(e, s) {
4170
- _(this, "client");
4171
- _(this, "parentId");
4172
- _(this, "images");
4173
- _(this, "length");
4174
- this.client = e, this.parentId = s, this.images = [], this.length = this.images.length;
4175
- }
4176
- async add(e) {
4177
- return this.images.push(e), this.length = this.images.length, await Vn(this.client, this.parentId, new Fr(e)), new Promise((s) => {
4178
- s(this.length);
4179
- });
4180
- }
4181
- }
4182
- const Vr = d.object({
4183
- handle: d.string(),
4184
- url: d.string(),
4185
- width: d.number(),
4186
- height: d.number(),
4187
- orientation: d.number(),
4188
- taken_at: d.string(),
4189
- camera_make: d.string().optional(),
4190
- camera: d.string().optional(),
4191
- filename: d.string()
4192
- });
4193
- class Fr {
4194
- constructor(e) {
4195
- _(this, "handle");
4196
- _(this, "url");
4197
- _(this, "width");
4198
- _(this, "height");
4199
- _(this, "orientation");
4200
- _(this, "taken_at");
4201
- _(this, "camera_make");
4202
- _(this, "camera");
4203
- _(this, "filename");
4204
- this.handle = e.handle, this.url = e.url, this.width = e.width, this.height = e.height, this.orientation = e.rotation, this.taken_at = e.captureTime, this.camera_make = e.cameraMake, this.camera = e.cameraModel, this.filename = e.filename;
4205
- }
4206
- }
4207
- const Hr = [
4208
- "new",
4209
- "ingesting",
4210
- "submitted",
4211
- "storyboarding",
4212
- "deduplication",
4213
- "image-selection",
4214
- "designing",
4215
- "laying-out",
4216
- "embellishing",
4217
- "polishing",
4218
- "ready",
4219
- "error",
4220
- "cancelled"
4221
- ], us = [
4222
- "baby",
4223
- "birthday",
4224
- "default",
4225
- "everyday",
4226
- "family",
4227
- "kids",
4228
- "life-stories",
4229
- "portfolio",
4230
- "school-memories",
4231
- "seasonal-holidays",
4232
- "special-celebrations",
4233
- "sports-and-hobbies",
4234
- "travel",
4235
- "wedding",
4236
- "year-in-review"
4237
- ], ds = {
4238
- 1005: { slug: "modern-black-sfly" },
4239
- 1101: { slug: "bon-voyage-sfly" },
4240
- 1103: { slug: "fun-in-the-sun-sfly" },
4241
- 1201: { slug: "modern-wedding-sfly" },
4242
- 3001: { slug: "digiscrap-sfly" },
4243
- 4034: { slug: "travel-snapshots-sfly" },
4244
- 4035: { slug: "vintage-travel-sfly" },
4245
- 5017: { slug: "natural-neutrals-sfly" },
4246
- 5033: { slug: "chalkboard-chic-sfly" },
4247
- 5079: { slug: "hello-spring-sfly" },
4248
- 5082: { slug: "familygram-sfly" },
4249
- 5085: { slug: "best-day-ever-sfly" },
4250
- 5091: { slug: "little-love-sfly" },
4251
- 5118: { slug: "a-year-in-color-sfly" },
4252
- 5120: { slug: "milestone-anniversaries-sfly" },
4253
- 5121: { slug: "the-travel-bug-sfly" },
4254
- 5122: { slug: "modern-white-sfly" },
4255
- 5127: { slug: "outdoor-wedding-sfly" },
4256
- 5134: { slug: "classic-wedding-sfly" },
4257
- 5138: { slug: "kraft-pop-sfly" },
4258
- 5142: { slug: "simply-black-sfly" },
4259
- 5144: { slug: "autumn-memories-sfly" },
4260
- 5146: { slug: "everyday-sentiments-sfly" },
4261
- 5149: { slug: "everyday-happiness-sfly" },
4262
- 5150: { slug: "its-a-girl-thing-sfly" },
4263
- 5155: { slug: "made-with-love-sfly" },
4264
- 5157: { slug: "high-school-memories-sfly" },
4265
- 5161: { slug: "rustic-wedding-sfly" },
4266
- 5165: { slug: "life-is-grand-sfly" },
4267
- 5167: { slug: "adventure-awaits-sfly" },
4268
- 5168: { slug: "disney-adventure-sfly" },
4269
- 5171: { slug: "world-travel-sfly" },
4270
- 5174: { slug: "hello-summer-sfly" },
4271
- 5183: { slug: "everything-sports-sfly" },
4272
- 5188: { slug: "everyday-watercolor-sfly" },
4273
- 5189: { slug: "holiday-memories-sfly" },
4274
- 5213: { slug: "love-and-thanks-sfly" },
4275
- 5218: { slug: "babys-first-year-sfly" },
4276
- 5219: { slug: "usa-travel-sfly" },
4277
- 5220: { slug: "vintage-wedding-sfly" },
4278
- 5226: { slug: "love-you-because-sfly" },
4279
- 5228: { slug: "reunion-sfly" },
4280
- 5238: { slug: "whimsy-chalkboard-sfly" },
4281
- 5242: { slug: "modern-indigo-sfly" },
4282
- 5250: { slug: "family-yearbook-sfly" },
4283
- 5255: { slug: "elegant-wedding-sfly" },
4284
- 5258: { slug: "family-vacation-sfly" },
4285
- 5259: { slug: "beach-travel-sfly" },
4286
- 5261: { slug: "sparkle-and-shine-sfly" },
4287
- 5262: { slug: "welcome-baby-sfly" },
4288
- 5265: { slug: "vivid-watercolor-sfly" },
4289
- 5266: { slug: "what-i-love-about-you-sfly" },
4290
- 5272: { slug: "love-grows-sfly" },
4291
- 5274: { slug: "painted-seasons-sfly" },
4292
- 5278: { slug: "vintage-disney-sfly" },
4293
- 5292: { slug: "modern-grey-sfly" },
4294
- 5297: { slug: "modern-love-story-sfly" },
4295
- 5299: { slug: "modern-travel-sfly" },
4296
- 5304: { slug: "beach-wedding-sfly" },
4297
- 5305: { slug: "rustic-farmhouse-sfly" },
4298
- 5308: { slug: "tropical-travel-sfly" },
4299
- 6e3: { slug: "travel-abroad-sfly" },
4300
- 6001: { slug: "everyday-rustic-sfly" },
4301
- 6002: { slug: "simply-modern-sfly" },
4302
- 6003: { slug: "modern-baby-sfly" },
4303
- 6004: { slug: "modern-photo-album-sfly" },
4304
- 6005: { slug: "travel-adventures-sfly" },
4305
- 6006: { slug: "watercolor-year-in-review-sfly" },
4306
- 6007: { slug: "beach-bliss-sfly" },
4307
- 6008: { slug: "simply-gray-sfly" },
4308
- 6009: { slug: "family-favorites-by-lure-design-sfly" },
4309
- 6010: { slug: "travel-gallery-sfly" },
4310
- 6011: { slug: "our-wedding-day-sfly" },
4311
- 6012: { slug: "chic-celebrations-by-float-paperie-sfly" },
4312
- 6013: { slug: "simply-bold-type-sfly" },
4313
- 6014: { slug: "colorful-florals-by-potts-design-sfly" },
4314
- 6015: { slug: "softly-rustic-sfly" },
4315
- 6016: { slug: "ombre-watercolor-sfly" },
4316
- 6017: { slug: "forever-love-by-with-merriment-sfly" },
4317
- 6018: { slug: "colorful-memories-by-britt-bass-sfly" },
4318
- 6019: { slug: "celebrate-family-by-float-paperie-sfly" },
4319
- 6020: { slug: "disney-family-adventures-sfly" },
4320
- 6021: { slug: "everyday-neutrals-sfly" },
4321
- 6022: { slug: "colorful-childhood-sfly" },
4322
- 6023: { slug: "everyday-indigo-sfly" },
4323
- 6024: { slug: "shimmer-and-shine-sfly" },
4324
- 6025: { slug: "summertime-fun-sfly" },
4325
- 6026: { slug: "pet-lover-sfly" },
4326
- 6027: { slug: "modern-wedding-story-sfly" },
4327
- 6028: { slug: "family-blessings-by-potts-design-sfly" },
4328
- 6030: { slug: "outdoor-adventures-by-sarah-hawkins-designs-sfly" },
4329
- 6031: { slug: "travel-memories-sfly" },
4330
- 6032: { slug: "tropical-travels-sfly" },
4331
- 6033: { slug: "everyday-chalkboard-by-potts-design-sfly" },
4332
- 6034: { slug: "classic-disney-sfly" },
4333
- 6035: { slug: "cheerful-color-sfly" },
4334
- 6036: { slug: "colorful-birthday-sfly" },
4335
- 6038: { slug: "classic-baby-sfly" },
4336
- 6039: { slug: "bold-year-in-review-by-float-paperie-sfly" },
4337
- 6040: { slug: "colorfully-fun-sfly" },
4338
- 6041: { slug: "colorful-year-in-review-by-sarah-hawkins-designs-sfly" },
4339
- 6042: { slug: "gilded-wedding-sfly" },
4340
- 6043: { slug: "road-trip-travel-by-sarah-hawkins-designs-sfly" },
4341
- 6044: { slug: "rustic-gilded-wedding-sfly" },
4342
- 6045: { slug: "elegantly-scripted-year-in-review-sfly" },
4343
- 6047: { slug: "2020-what-a-year-sfly" },
4344
- 6057: { slug: "best-mom-ever-sfly" },
4345
- 6052: { slug: "celebration-of-life-by-sarah-hawkins-designs-sfly" },
4346
- 6054: { slug: "colorful-school-days-by-float-paperie-sfly" },
4347
- 6051: { slug: "love-is-all-we-need-sfly" },
4348
- 6058: { slug: "graduation-celebration-sfly" },
4349
- 6056: { slug: "our-wedding-day-guestbook-sfly" },
4350
- 6055: { slug: "muted-everyday-abstract-sfly" },
4351
- 6046: { slug: "winter-memories-by-sarah-hawkins-design-sfly" },
4352
- 6053: { slug: "best-dad-ever-sfly" },
4353
- 6050: { slug: "watercolor-greenery-by-sarah-hawkins-designs-sfly" },
4354
- 6063: { slug: "watercolor-floral-wedding-by-kim-thoa-sfly" },
4355
- 6060: { slug: "watercolor-baby-girl-sfly" },
4356
- 6059: { slug: "watercolor-baby-boy-sfly" },
4357
- 6048: { slug: "simple-elegant-wedding-sfly" },
4358
- 6049: { slug: "gilded-wedding-guestbook-sfly" },
4359
- 6037: { slug: "everyday-fairytale-by-jenny-romanski-sfly" },
4360
- 6061: { slug: "best-grandparents-ever-sfly" },
4361
- 6068: { slug: "winter-getaway-sfly" },
4362
- 6067: { slug: "national-parks-travel-by-eiman-design-co-sfly" },
4363
- 6065: { slug: "go-sports-by-lure-design-sfly" },
4364
- 6066: { slug: "elegant-wedding-greenery-by-kim-thoa-sfly" },
4365
- 6064: { slug: "boho-travel-by-umaiana-studio-sfly" },
4366
- 6071: { slug: "modern-dark-neutrals-sfly" },
4367
- 6072: { slug: "modern-light-neutrals-sfly" },
4368
- 6073: { slug: "modern-celebrations-sfly" },
4369
- 6074: { slug: "bright-and-bold-kids-year-in-review-by-sarah-hawkins-designs-sfly" },
4370
- 6085: { slug: "classic-school-yearbook-sfly" },
4371
- 6084: { slug: "colorful-elementary-school-yearbook-sfly" },
4372
- 5402: { slug: "everyday-recipes-by-slightly-stationery-sfly" },
4373
- 6083: { slug: "school-days-yearbook-sfly" },
4374
- 6082: { slug: "the-story-of-me-sfly" },
4375
- 6086: { slug: "whimsical-recipes-by-slightly-stationery-sfly" },
4376
- 6101: { slug: "babys-first-sfly" },
4377
- 6103: { slug: "classic-recipes-sfly" },
4378
- 6104: { slug: "elevated-rustic-sfly" },
4379
- 6105: { slug: "boho-summer-sfly" },
4380
- 6116: { slug: "boho-baby-sfly" },
4381
- 6117: { slug: "simply-gallery-sfly" },
4382
- 6118: { slug: "this-is-love-sfly" },
4383
- 6120: { slug: "wedding-gallery-sfly" },
4384
- 6121: { slug: "watercolorwashes-sfly" },
4385
- 6124: { slug: "graduation-photo-album-sfly" },
4386
- 6125: { slug: "modern-year-in-review-photo-album-sfly" },
4387
- 6126: { slug: "black-white-photo-album-sfly" },
4388
- 6132: { slug: "travel-journal-sfly" },
4389
- 6133: { slug: "rustic-gallery-sfly" },
4390
- 6137: { slug: "summer-adventures-sfly" },
4391
- 6075: { slug: "together-again-sfly" },
4392
- 6078: { slug: "everyday-boho-by-umaiana-studio-sfly" },
4393
- 6089: { slug: "colorful-gradients-sfly" },
4394
- 6096: { slug: "simply-scrapbook-sfly" },
4395
- 6097: { slug: "boho-wedding-sfly" },
4396
- 6098: { slug: "black-and-white-rustic-sfly" },
4397
- 6099: { slug: "bright-color-pop-sfly" }
4398
- }, fs = ["8x8", "10x10", "12x12", "8x11", "11x8", "11x14"], hs = ["sc", "hc", "pl"], ps = ["sp", "sl", "dl"], ms = ["low", "medium", "high"], ys = ["best", "most", "all"], gs = ["none", "few", "lots"], vs = ["none", "few", "lots"], Jr = {
4399
- state: "error",
4400
- slug: "error",
4401
- progress: 100,
4402
- message: "Design failed"
4403
- }, Wr = {
4404
- state: "cancelled",
4405
- slug: "cancelled",
4406
- progress: 100,
4407
- message: "Design cancelled"
4408
- };
4409
- class Kr {
4410
- constructor(e) {
4411
- _(this, "occasion");
4412
- _(this, "style");
4413
- _(this, "book_size");
4414
- _(this, "cover_type");
4415
- _(this, "page_type");
4416
- _(this, "image_density");
4417
- _(this, "image_filtering_level");
4418
- _(this, "embellishment_level");
4419
- _(this, "text_sticker_level");
4420
- this.occasion = e.occasion, this.style = e.style, this.book_size = e.book_size, this.cover_type = e.cover_type, this.page_type = e.page_type, this.image_density = e.image_density, this.image_filtering_level = e.image_filtering_level, this.embellishment_level = e.embellishment_level, this.text_sticker_level = e.text_sticker_level;
4421
- }
4422
- }
4423
- const qr = d.object({
4424
- occasion: d.enum(us),
4425
- style: d.string(),
4426
- book_size: d.enum(fs),
4427
- cover_type: d.enum(hs),
4428
- page_type: d.enum(ps),
4429
- image_density: d.enum(ms),
4430
- image_filtering_level: d.enum(ys),
4431
- embellishment_level: d.enum(gs),
4432
- text_sticker_level: d.enum(vs)
4433
- }), vt = d.object({
4434
- id: d.string(),
4435
- title: d.string(),
4436
- design_request: qr,
4437
- state: d.enum(Hr).optional(),
4438
- guid: d.string().optional()
4439
- });
4440
- class qe {
4441
- constructor(e) {
4442
- _(this, "id");
4443
- _(this, "title");
4444
- _(this, "design_request");
4445
- _(this, "state");
4446
- _(this, "guid");
4447
- this.id = e.id, this.title = e.title, this.design_request = new Kr(e.design_request), this.state = e.state, this.guid = e.guid;
4448
- }
4449
- }
4450
- const Gr = d.object({
4451
- photoRefId: d.string(),
4452
- finalCrop: d.array(d.number())
4453
- }), Xr = d.object({
4454
- x: d.number(),
4455
- y: d.number(),
4456
- width: d.number().optional(),
4457
- height: d.number().optional(),
4458
- rotation: d.number()
4459
- }), Yr = d.object({
4460
- id: d.string(),
4461
- llx: d.number(),
4462
- lly: d.number(),
4463
- urx: d.number(),
4464
- ury: d.number(),
4465
- data: d.string().nullable(),
4466
- title: d.string(),
4467
- width: d.number(),
4468
- effect: d.string(),
4469
- height: d.number(),
4470
- source: d.string(),
4471
- rotation: d.number(),
4472
- uploadTime: d.string()
4473
- }), Qr = d.object({
4474
- key: d.string(),
4475
- value: d.any()
4476
- }), ea = d.object({
4477
- type: d.string(),
4478
- imageAssignment: Gr.optional(),
4479
- position: Xr,
4480
- seqNum: d.number(),
4481
- z: d.number(),
4482
- id: d.string().optional(),
4483
- horizJustification: d.string().optional(),
4484
- vertJustification: d.string().optional().nullable(),
4485
- text: d.string().optional(),
4486
- fontId: d.string().optional(),
4487
- fontSize: d.number().optional(),
4488
- fontColor: d.string().optional(),
4489
- frame: d.string().optional()
4490
- }), ta = d.object({
4491
- url: d.string(),
4492
- encryptId: d.string(),
4493
- photoRefId: d.string(),
4494
- photoId: d.string(),
4495
- photoMetadata: Yr
4496
- }), sa = d.object({
4497
- properties: d.array(Qr)
4498
- }), na = d.object({
4499
- backgroundId: d.string().nullable(),
4500
- assets: d.array(ea).optional()
4501
- }), ra = d.object({
4502
- pageNum: d.number(),
4503
- type: d.string(),
4504
- canvas: na
4505
- }), aa = d.object({
4506
- pages: d.array(ra),
4507
- photoStrip: d.array(ta)
4508
- }), ia = d.object({
4509
- title: d.string(),
4510
- binding: d.string(),
4511
- coverSpecId: d.string(),
4512
- styleId: d.number(),
4513
- userId: d.string(),
4514
- magicShopBook: aa,
4515
- reportingData: sa
4516
- });
4517
- async function oa({ apiHost: t, apiKey: e }, s) {
4518
- return ce(async () => {
4519
- const n = (await gt({ url: `${t}/v1/books`, apiKey: e, payload: s })).data;
4520
- return vt.safeParse(n), new qe(n);
4521
- });
4522
- }
4523
- async function Rt({ apiHost: t, apiKey: e }, s) {
4524
- return ce(async () => {
4525
- const n = (await zn({ url: `${t}/v1/books/${s.id}`, apiKey: e, payload: s })).data;
4526
- return vt.safeParse(n), new qe(n);
4527
- });
4528
- }
4529
- async function la({ apiHost: t, apiKey: e }, s) {
4530
- return ce(async () => {
4531
- const n = (await gt({ url: `${t}/v1/books/${s}/cancel`, apiKey: e })).data;
4532
- return vt.safeParse(n), new qe(n);
4533
- });
4534
- }
4535
- async function ca({ apiHost: t, apiKey: e }, s) {
4536
- return ce(async () => {
4537
- const n = (await ts({ url: `${t}/v1/books/${s}/format/galleon`, apiKey: e })).data;
4538
- return ia.parse(n);
4539
- });
4540
- }
4541
- const ua = "https://api.sfly-sls.magicbook.io", da = "wss://socket.sfly-sls.magicbook.io", fa = parseInt("30000") || 3e4;
4542
- function It(t) {
4543
- const e = ds[t.style].slug, s = Zt(JSON.parse(JSON.stringify(t)));
4544
- return s.style = e, new qe({
4545
- id: t.parentId,
4546
- guid: t.guid,
4547
- title: t.title,
4548
- design_request: s
4549
- });
4550
- }
4551
- const et = d.object({
4552
- maxPageCount: d.number(),
4553
- minPageCount: d.number(),
4554
- maxImageCount: d.number(),
4555
- avgImageCount: d.number(),
4556
- minImageCount: d.number()
4557
- }), ha = d.object({
4558
- high: et,
4559
- medium: et,
4560
- low: et
4561
- }), pa = d.object({
4562
- densities: ha
4563
- });
4564
- async function ma({ apiKey: t, apiHost: e }, s, n, r) {
4565
- return ce(async () => {
4566
- const a = await ts(
4567
- {
4568
- url: `${e}/v1/designoptions/booksize/${s}/imagecount/${n}
4569
- /imagefilteringlevel/${r}`,
4570
- apiKey: t
4571
- }
4572
- ), i = Lt(a.data);
4573
- return pa.parse(i);
4574
- });
4575
- }
4576
- class ya {
4577
- constructor(e, s, n) {
4578
- _(this, "client");
4579
- _(this, "webSocket");
4580
- _(this, "state");
4581
- _(this, "parentId");
4582
- _(this, "title");
4583
- _(this, "occasion");
4584
- _(this, "style");
4585
- _(this, "bookSize");
4586
- _(this, "coverType");
4587
- _(this, "pageType");
4588
- _(this, "imageDensity");
4589
- _(this, "imageFilteringLevel");
4590
- _(this, "embellishmentLevel");
4591
- _(this, "textStickerLevel");
4592
- _(this, "images");
4593
- _(this, "guid");
4594
- this.parentId = e, this.client = s, this.webSocket = new WebSocket(`${this.client.webSocketHost}/?book_id=${this.parentId}`), this.state = "new", this.title = (n == null ? void 0 : n.title) || "", this.occasion = (n == null ? void 0 : n.occasion) || us[0], this.style = (n == null ? void 0 : n.style) || parseInt(Object.keys(ds)[0]), this.bookSize = (n == null ? void 0 : n.bookSize) || fs[0], this.coverType = (n == null ? void 0 : n.coverType) || hs[0], this.pageType = (n == null ? void 0 : n.pageType) || ps[0], this.imageDensity = (n == null ? void 0 : n.imageDensity) || ms[0], this.imageFilteringLevel = (n == null ? void 0 : n.imageFilteringLevel) || ys[0], this.embellishmentLevel = (n == null ? void 0 : n.embellishmentLevel) || gs[0], this.textStickerLevel = (n == null ? void 0 : n.textStickerLevel) || vs[0], this.images = new zr(this.client, this.parentId);
4595
- }
4596
- async getOptions(e) {
4597
- return await ma(
4598
- this.client,
4599
- this.bookSize,
4600
- e || this.images.length,
4601
- this.imageFilteringLevel
4602
- );
4603
- }
4604
- async submit(e) {
4605
- return e && Object.assign(this, e), this.getProgress(), await Rt(this.client, It(this)), this;
4606
- }
4607
- async setGuid(e) {
4608
- return this.guid = e, await Rt(this.client, It(this)), this.guid;
4609
- }
4610
- async getJSON() {
4611
- return await ca(this.client, this.parentId);
4612
- }
4613
- async cancel() {
4614
- return await la(this.client, this.parentId), this.state = "cancelled", await this.eventHandler(Wr), this;
4615
- }
4616
- async eventHandler(e, s = "MagicBook.designRequestUpdated") {
4617
- const n = new CustomEvent(s, { detail: e });
4618
- window.dispatchEvent(n), ["error", "ready", "cancelled"].includes(e.slug) && this.webSocket.close();
4619
- }
4620
- timeoutHandler() {
4621
- return setTimeout(() => {
4622
- this.eventHandler(Jr);
4623
- }, fa);
4624
- }
4625
- async getProgress() {
4626
- let e;
4627
- this.webSocket.onmessage = (s) => {
4628
- const n = JSON.parse(s.data);
4629
- this.state !== n.slug && (e && clearTimeout(e), e = this.timeoutHandler(), this.eventHandler(n), this.state = n.slug);
4630
- }, this.webSocket.onclose = () => clearTimeout(e);
4631
- }
4632
- }
4633
- class va {
4634
- constructor(e, s = ua, n = da) {
4635
- _(this, "apiKey");
4636
- _(this, "apiHost");
4637
- _(this, "webSocketHost");
4638
- this.apiKey = e, this.apiHost = s, this.webSocketHost = n;
4639
- }
4640
- async createDesignRequest(e) {
4641
- const s = await oa(this);
4642
- return new ya(s.id, this, e);
4643
- }
4644
- }
4645
- export {
4646
- ya as DesignRequest,
4647
- Fr as ImageServer,
4648
- zr as Images,
4649
- va as MagicBookClient,
4650
- fs as bookSizes,
4651
- Wr as cancelledMessage,
4652
- hs as coverTypes,
4653
- pa as designOptionsSchema,
4654
- gs as embellishmentLevels,
4655
- ms as imageDensities,
4656
- et as imageDensityOptionSchema,
4657
- ha as imageDensityOptionsSchema,
4658
- ys as imageFilteringLevels,
4659
- Vr as imageServerSchema,
4660
- us as occasions,
4661
- ps as pageTypes,
4662
- Hr as states,
4663
- ds as styles,
4664
- vs as textStickerLevels,
4665
- Jr as timeoutMessage
4666
- };